diff --git a/Build.cmd b/Build.cmd index 7e7754462..075bdce94 100644 --- a/Build.cmd +++ b/Build.cmd @@ -1,3 +1,3 @@ @echo off -powershell -ExecutionPolicy ByPass -command "& """%~dp0eng\common\Build.ps1""" -restore -build %*" +call %~dp0eng\Build.cmd -restore -build %* exit /b %ErrorLevel% diff --git a/CMakeLists.txt b/CMakeLists.txt index ff558391a..2475b2e3f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,7 +5,7 @@ cmake_minimum_required(VERSION 2.8.12) if(CMAKE_VERSION VERSION_EQUAL 3.0 OR CMAKE_VERSION VERSION_GREATER 3.0) - cmake_policy(SET CMP0042 NEW) + cmake_policy(SET CMP0042 NEW) endif() # Set the project name @@ -19,10 +19,13 @@ if (WIN32) message(STATUS "VS_PLATFORM_NAME is ${CMAKE_VS_PLATFORM_NAME}") endif (WIN32) +set(ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}) +#set(VERSION_FILE_PATH "${CMAKE_BINARY_DIR}/version.cpp") + set(CORECLR_SET_RPATH ON) if(CORECLR_SET_RPATH) - # Enable @rpath support for shared libraries. - set(MACOSX_RPATH ON) + # Enable @rpath support for shared libraries. + set(MACOSX_RPATH ON) endif(CORECLR_SET_RPATH) OPTION(CLR_CMAKE_ENABLE_CODE_COVERAGE "Enable code coverage" OFF) @@ -31,7 +34,7 @@ OPTION(CLR_CMAKE_WARNINGS_ARE_ERRORS "Warnings are errors" ON) # Ensure that python is present find_program(PYTHON NAMES python2.7 python2 python) if (PYTHON STREQUAL "PYTHON-NOTFOUND") - message(FATAL_ERROR "PYTHON not found: Please install Python 2.7.9 or later from https://www.python.org/downloads/") + message(FATAL_ERROR "PYTHON not found: Please install Python 2.7.9 or later from https://www.python.org/downloads/") endif() # Ensure other tools are present @@ -450,9 +453,9 @@ endif(WIN32) # ./build-native.sh cmakeargs "-DCLR_ADDITIONAL_COMPILER_OPTIONS=<...>" cmakeargs "-DCLR_ADDITIONAL_LINKER_FLAGS=<...>" # if(CLR_CMAKE_PLATFORM_UNIX) - set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${CLR_ADDITIONAL_LINKER_FLAGS}") - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CLR_ADDITIONAL_LINKER_FLAGS}" ) - add_compile_options(${CLR_ADDITIONAL_COMPILER_OPTIONS}) + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${CLR_ADDITIONAL_LINKER_FLAGS}") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CLR_ADDITIONAL_LINKER_FLAGS}" ) + add_compile_options(${CLR_ADDITIONAL_COMPILER_OPTIONS}) endif(CLR_CMAKE_PLATFORM_UNIX) if(CLR_CMAKE_PLATFORM_LINUX) @@ -464,6 +467,7 @@ endif(CLR_CMAKE_PLATFORM_LINUX) #------------------------------------ # Definitions (for platform) #----------------------------------- + if (CLR_CMAKE_PLATFORM_ARCH_AMD64) add_definitions(-D_AMD64_) add_definitions(-D_WIN64) @@ -539,6 +543,86 @@ else () clr_unknown_arch() endif () +if (CLR_CMAKE_TARGET_ARCH_AMD64) + if (CLR_CMAKE_PLATFORM_UNIX) + add_definitions(-DDBG_TARGET_AMD64_UNIX) + endif() + add_definitions(-D_TARGET_64BIT_=1) + add_definitions(-D_TARGET_AMD64_=1) + add_definitions(-DDBG_TARGET_64BIT=1) + add_definitions(-DDBG_TARGET_AMD64=1) + add_definitions(-DDBG_TARGET_WIN64=1) +elseif (CLR_CMAKE_TARGET_ARCH_ARM64) + if (CLR_CMAKE_PLATFORM_UNIX) + add_definitions(-DDBG_TARGET_ARM64_UNIX) + endif() + add_definitions(-D_TARGET_ARM64_=1) + add_definitions(-D_TARGET_64BIT_=1) + add_definitions(-DDBG_TARGET_64BIT=1) + add_definitions(-DDBG_TARGET_ARM64=1) + add_definitions(-DDBG_TARGET_WIN64=1) + add_definitions(-DFEATURE_MULTIREG_RETURN) +elseif (CLR_CMAKE_TARGET_ARCH_ARM) + if (CLR_CMAKE_PLATFORM_UNIX) + add_definitions(-DDBG_TARGET_ARM_UNIX) + elseif (WIN32 AND NOT DEFINED CLR_CROSS_COMPONENTS_BUILD) + # Set this to ensure we can use Arm SDK for Desktop binary linkage when doing native (Arm32) build + add_definitions(-D_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE=1) + add_definitions(-D_ARM_WORKAROUND_) + endif (CLR_CMAKE_PLATFORM_UNIX) + add_definitions(-D_TARGET_ARM_=1) + add_definitions(-D_TARGET_WIN32_=1) + add_definitions(-DDBG_TARGET_32BIT=1) + add_definitions(-DDBG_TARGET_ARM=1) +elseif (CLR_CMAKE_TARGET_ARCH_I386) + add_definitions(-D_TARGET_X86_=1) + add_definitions(-DDBG_TARGET_32BIT=1) + add_definitions(-DDBG_TARGET_X86=1) +else () + clr_unknown_arch() +endif (CLR_CMAKE_TARGET_ARCH_AMD64) + +if(WIN32) + add_definitions(-DWIN32) + add_definitions(-D_WIN32) + add_definitions(-DWINVER=0x0602) + add_definitions(-D_WIN32_WINNT=0x0602) + add_definitions(-DWIN32_LEAN_AND_MEAN=1) + add_definitions(-D_CRT_SECURE_NO_WARNINGS) +endif(WIN32) + +#-------------------------------------- +# FEATURE Defines +#-------------------------------------- + +add_definitions(-DFEATURE_CORESYSTEM) + +if(CLR_CMAKE_PLATFORM_UNIX) + add_definitions(-DFEATURE_PAL) + add_definitions(-DFEATURE_PAL_ANSI) +endif(CLR_CMAKE_PLATFORM_UNIX) + +if(WIN32) + add_definitions(-DFEATURE_COMINTEROP) +endif(WIN32) + +if(NOT CMAKE_SYSTEM_NAME STREQUAL NetBSD) + add_definitions(-DFEATURE_HIJACK) +endif(NOT CMAKE_SYSTEM_NAME STREQUAL NetBSD) + +if(FEATURE_EVENT_TRACE) + add_definitions(-DFEATURE_EVENT_TRACE=1) + add_definitions(-DFEATURE_PERFTRACING=1) +endif(FEATURE_EVENT_TRACE) + +if(CLR_CMAKE_PLATFORM_UNIX_AMD64) + add_definitions(-DFEATURE_MULTIREG_RETURN) +endif (CLR_CMAKE_PLATFORM_UNIX_AMD64) + +if(CLR_CMAKE_PLATFORM_UNIX AND CLR_CMAKE_TARGET_ARCH_AMD64) + add_definitions(-DUNIX_AMD64_ABI) +endif(CLR_CMAKE_PLATFORM_UNIX AND CLR_CMAKE_TARGET_ARCH_AMD64) + #-------------------------------------- # Compile Options #-------------------------------------- diff --git a/README.md b/README.md index a7b0679e3..eed358df5 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,9 @@ .NET Core Diagnostics Repo ========================== -This repository contains the source code for various .NET Core runtime diagnostic tools. It currently contains the managed portion of SOS and the lldb SOS plugin. One of goals of this repo is to build the lldb SOS plugin for the portable Linux platform (Centos 7) and the platforms not supported by the portable build (Centos 6, Alpine, eventually macOS) and to test across various indexes in a very large matrix: OSs/distros (Centos 6/7, Ubuntu, Alpine, Fedora, Debian, RHEL 7.2), architectures (x64, x86, arm, arm64), lldb versions (3.9, 4.0, 5.0, 6.0) and even .NET Core versions (1.1, 2.0.x, 2.1). +**Currently under construction** + +This repository contains the source code for various .NET Core runtime diagnostic tools. It currently contains SOS, the managed portion of SOS and the lldb SOS plugin. One of goals of this repo is to build SOS and the lldb SOS plugin for the portable Linux platform (Centos 7) and the platforms not supported by the portable build (Centos 6, Alpine, eventually macOS) and to test across various indexes in a very large matrix: OSs/distros (Centos 6/7, Ubuntu, Alpine, Fedora, Debian, RHEL 7.2), architectures (x64, x86, arm, arm64), lldb versions (3.9, 4.0, 5.0, 6.0) and even .NET Core versions (1.1, 2.0.x, 2.1). Another goal to make it easier to obtain a version of lldb (currently 3.9) with scripts and documentation for platforms/distros like Centos, Alpine, Fedora, etc. that by default provide really old versions. diff --git a/Restore.cmd b/Restore.cmd index 3fc17e8f7..cb0cb90b1 100644 --- a/Restore.cmd +++ b/Restore.cmd @@ -1,3 +1,3 @@ @echo off -powershell -ExecutionPolicy ByPass -command "& """%~dp0eng\common\Build.ps1""" -restore %*" +call %~dp0eng\Build.cmd -restore %* exit /b %ErrorLevel% diff --git a/Test.cmd b/Test.cmd index 8a841f681..ef857c81d 100644 --- a/Test.cmd +++ b/Test.cmd @@ -1,3 +1,3 @@ @echo off -powershell -ExecutionPolicy ByPass -command "& """%~dp0eng\common\Build.ps1""" -test %*" -exit /b %ErrorLevel% \ No newline at end of file +call %~dp0eng\Build.cmd -test %* +exit /b %ErrorLevel% diff --git a/crossgen.cmake b/crossgen.cmake new file mode 100644 index 000000000..75739dfc7 --- /dev/null +++ b/crossgen.cmake @@ -0,0 +1,27 @@ +# Contains the crossgen build specific definitions. Included by the leaf crossgen cmake files. + +add_definitions( + -DCROSSGEN_COMPILE + -DCROSS_COMPILE + -DFEATURE_NATIVE_IMAGE_GENERATION + -DSELF_NO_HOST) + +remove_definitions( + -DFEATURE_CODE_VERSIONING + -DEnC_SUPPORTED + -DFEATURE_EVENT_TRACE=1 + -DFEATURE_LOADER_OPTIMIZATION + -DFEATURE_MULTICOREJIT + -DFEATURE_PERFMAP + -DFEATURE_REJIT + -DFEATURE_TIERED_COMPILATION + -DFEATURE_VERSIONING_LOG +) + +if(FEATURE_READYTORUN) + add_definitions(-DFEATURE_READYTORUN_COMPILER) +endif(FEATURE_READYTORUN) + +if(CLR_CMAKE_PLATFORM_LINUX) + add_definitions(-DFEATURE_PERFMAP) +endif(CLR_CMAKE_PLATFORM_LINUX) diff --git a/eng/Build-Native.cmd b/eng/Build-Native.cmd new file mode 100644 index 000000000..960024869 --- /dev/null +++ b/eng/Build-Native.cmd @@ -0,0 +1,371 @@ +@if not defined _echo @echo off +setlocal EnableDelayedExpansion EnableExtensions + +:: Define a prefix for most output progress messages that come from this script. That makes +:: it easier to see where these are coming from. Note that there is a trailing space here. +set "__MsgPrefix=BUILD: " + +echo %__MsgPrefix%Starting Build at %TIME% +set __ThisScriptFull="%~f0" +set __ThisScriptDir="%~dp0" + +call "%__ThisScriptDir%"\setup_vs_tools.cmd +if NOT '%ERRORLEVEL%' == '0' exit /b 1 + +if defined VS150COMNTOOLS ( + set "__VSToolsRoot=%VS150COMNTOOLS%" + set "__VCToolsRoot=%VS150COMNTOOLS%\..\..\VC\Auxiliary\Build" + set __VSVersion=vs2017 +) else ( + set "__VSToolsRoot=%VS140COMNTOOLS%" + set "__VCToolsRoot=%VS140COMNTOOLS%\..\..\VC" + set __VSVersion=vs2015 +) + +:: Work around Jenkins CI + msbuild problem: Jenkins sometimes creates very large environment +:: variables, and msbuild can't handle environment blocks with such large variables. So clear +:: out the variables that might be too large. +set ghprbCommentBody= + +:: Note that the msbuild project files (specifically, dir.proj) will use the following variables, if set: +:: __BuildArch -- default: x64 +:: __BuildType -- default: Debug +:: __BuildOS -- default: Windows_NT +:: __ProjectDir -- default: directory of the dir.props file +:: __SourceDir -- default: %__ProjectDir%\src\ +:: __RootBinDir -- default: %__ProjectDir%\artifacts\ +:: __BinDir -- default: %__RootBinDir%\bin\%__BuildOS%.%__BuildArch.%__BuildType%\ +:: __IntermediatesDir -- default: %__RootBinDir%\obj\%__BuildOS%.%__BuildArch.%__BuildType%\ +:: __LogDir -- default: %__RootBinDir%\log\%__BuildOS%.%__BuildArch.%__BuildType%\ +:: +:: Thus, these variables are not simply internal to this script! + +:: Set the default arguments for build +set __BuildArch=x64 +set __BuildType=Debug +set __BuildOS=Windows_NT +set __Build=0 +set __Test=0 + +:: Set the various build properties here so that CMake and MSBuild can pick them up +set "__ProjectDir=%~dp0" +:: remove trailing slash +if %__ProjectDir:~-1%==\ set "__ProjectDir=%__ProjectDir:~0,-1%" +set "__ProjectDir=%__ProjectDir%\.." +set "__SourceDir=%__ProjectDir%\src" +set "__PackagesDir=%DotNetRestorePackagesPath%" +if [%__PackagesDir%]==[] set "__PackagesDir=%__ProjectDir%\packages" +set "__RootBinDir=%__ProjectDir%\artifacts" + +REM __UnprocessedBuildArgs are args that we pass to msbuild (e.g. /p:__BuildArch=x64) +set "__args= %*" +set processedArgs= +set __UnprocessedBuildArgs= + +:Arg_Loop +if "%1" == "" goto ArgsDone + +if /i "%1" == "-?" goto Usage +if /i "%1" == "-h" goto Usage +if /i "%1" == "-help" goto Usage +if /i "%1" == "--help" goto Usage + +if /i "%1" == "-build" (set __Build=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) +if /i "%1" == "-test" (set __Test=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) +if /i "%1" == "-configuration" (set __BuildType=%2&set processedArgs=!processedArgs! %1 %2&shift&shift&goto Arg_Loop) +if /i "%1" == "-architecture" (set __BuildArch=%2&set processedArgs=!processedArgs! %1 %2&shift&shift&goto Arg_Loop) +rem these options are ignored for a native build +if /i "%1" == "-restore" (set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) +if /i "%1" == "-sign" (set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) +if /i "%1" == "-pack" (set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) +if /i "%1" == "-ci" (set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) +if /i "%1" == "-prepareMachine" (set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) + +if [!processedArgs!]==[] ( + set __UnprocessedBuildArgs=%__args% +) else ( + set __UnprocessedBuildArgs=%__args% + for %%t in (!processedArgs!) do ( + set __UnprocessedBuildArgs=!__UnprocessedBuildArgs:*%%t=! + ) +) + +:ArgsDone + +REM Determine if this is a cross-arch build + +if /i "%__BuildArch%"=="arm64" ( + set __DoCrossArchBuild=1 + set __CrossArch=x86 + ) + +if /i "%__BuildArch%"=="arm" ( + set __DoCrossArchBuild=1 + set __CrossArch=x64 + ) + +:: Set the remaining variables based upon the determined build configuration +set "__BinDir=%__RootBinDir%\bin\%__BuildOS%.%__BuildArch%.%__BuildType%" +set "__IntermediatesDir=%__RootBinDir%\obj\%__BuildOS%.%__BuildArch%.%__BuildType%" +set "__LogDir=%__RootBinDir%\log\%__BuildOS%.%__BuildArch%.%__BuildType%" +if "%__NMakeMakefiles%"=="1" (set "__IntermediatesDir=%__RootBinDir%\nmakeobj\%__BuildOS%.%__BuildArch%.%__BuildType%") + +set "__PackagesBinDir=%__BinDir%\.nuget" +set "__CrossComponentBinDir=%__BinDir%" +set "__CrossCompIntermediatesDir=%__IntermediatesDir%\crossgen" + +if NOT "%__CrossArch%" == "" set __CrossComponentBinDir=%__CrossComponentBinDir%\%__CrossArch% +set "__CrossGenCoreLibLog=%__LogDir%\CrossgenCoreLib_%__BuildOS%__%__BuildArch%__%__BuildType%.log" +set "__CrossgenExe=%__CrossComponentBinDir%\crossgen.exe" + +:: Generate path to be set for CMAKE_INSTALL_PREFIX to contain forward slash +set "__CMakeBinDir=%__BinDir%" +set "__CMakeBinDir=%__CMakeBinDir:\=/%" + +if not exist "%__BinDir%" md "%__BinDir%" +if not exist "%__IntermediatesDir%" md "%__IntermediatesDir%" +if not exist "%__LogDir%" md "%__LogDir%" + +echo %__MsgPrefix%Commencing diagnostics repo build + +:: Set the remaining variables based upon the determined build configuration + +echo %__MsgPrefix%Checking prerequisites +:: Eval the output from probe-win1.ps1 +for /f "delims=" %%a in ('powershell -NoProfile -ExecutionPolicy ByPass "& ""%__ProjectDir%\eng\probe-win.ps1"""') do %%a + +REM ========================================================================================= +REM === +REM === Start the build steps +REM === +REM ========================================================================================= + +@if defined _echo @echo on + +REM Parse the optdata package versions out of msbuild so that we can pass them on to CMake +set DotNetCli=%__ProjectDir%\.dotnet\dotnet.exe +if not exist "%DotNetCli%" ( + echo %__MsgPrefix%Assertion failed: dotnet.exe not found at path "%DotNetCli%" + exit /b 1 +) +set MSBuildPath=%__ProjectDir%\.dotnet\sdk\2.1.300-rc1-008673\msbuild.dll + +REM ========================================================================================= +REM === +REM === Build the native code +REM === +REM ========================================================================================= + +if %__Build% EQU 1 ( + REM Scope environment changes start { + setlocal + + echo %__MsgPrefix%Commencing build of native components for %__BuildOS%.%__BuildArch%.%__BuildType% + + set __NativePlatformArgs=-platform=%__BuildArch% + if not "%__ToolsetDir%" == "" ( set __NativePlatformArgs=-useEnv ) + + if not "%__ToolsetDir%" == "" ( + rem arm64 builds currently use private toolset which has not been released yet + REM TODO, remove once the toolset is open. + call :PrivateToolSet + goto GenVSSolution + ) + + :: Set the environment for the native build + set __VCBuildArch=x86_amd64 + if /i "%__BuildArch%" == "x86" ( set __VCBuildArch=x86 ) + if /i "%__BuildArch%" == "arm" ( + set __VCBuildArch=x86_arm + + REM Make CMake pick the highest installed version in the 10.0.* range + set ___SDKVersion="-DCMAKE_SYSTEM_VERSION=10.0" + ) + if /i "%__BuildArch%" == "arm64" ( + set __VCBuildArch=x86_arm64 + + REM Make CMake pick the highest installed version in the 10.0.* range + set ___SDKVersion="-DCMAKE_SYSTEM_VERSION=10.0" + ) + + echo %__MsgPrefix%Using environment: "%__VCToolsRoot%\vcvarsall.bat" !__VCBuildArch! + call "%__VCToolsRoot%\vcvarsall.bat" !__VCBuildArch! + @if defined _echo @echo on + + if not defined VSINSTALLDIR ( + echo %__MsgPrefix%Error: VSINSTALLDIR variable not defined. + exit /b 1 + ) + if not exist "!VSINSTALLDIR!DIA SDK" goto NoDIA + +:GenVSSolution + if defined __SkipConfigure goto SkipConfigure + + echo %__MsgPrefix%Regenerating the Visual Studio solution + + set "__ManagedBinaryDir=%__RootBinDir%\%__BuildType%\bin" + set "__ManagedBinaryDir=!__ManagedBinaryDir:\=/!" + set __ExtraCmakeArgs=!___SDKVersion! "-DCLR_MANAGED_BINARY_DIR=!__ManagedBinaryDir!" + + pushd "%__IntermediatesDir%" + call "%__ProjectDir%\eng\gen-buildsys-win.bat" "%__ProjectDir%" %__VSVersion% %__BuildArch% !__ExtraCmakeArgs! + @if defined _echo @echo on + popd + +:SkipConfigure + if defined __ConfigureOnly goto SkipNativeBuild + + if not exist "%__IntermediatesDir%\install.vcxproj" ( + echo %__MsgPrefix%Error: failed to generate native component build project! + exit /b 1 + ) + + set __BuildLogRootName=Native + set __BuildLog="%__LogDir%\!__BuildLogRootName!.log" + set __BuildWrn="%__LogDir%\!__BuildLogRootName!.wrn" + set __BuildErr="%__LogDir%\!__BuildLogRootName!.err" + set __MsbuildLog=/flp:Verbosity=normal;LogFile=!__BuildLog! + set __MsbuildWrn=/flp1:WarningsOnly;LogFile=!__BuildWrn! + set __MsbuildErr=/flp2:ErrorsOnly;LogFile=!__BuildErr! + + msbuild.exe %__IntermediatesDir%\install.vcxproj /v:m !__MsbuildLog! !__MsbuildWrn! !__MsbuildErr! /p:Configuration=%__BuildType% /p:Platform=%__BuildArch% %__UnprocessedBuildArgs% + + if not !errorlevel! == 0 ( + echo %__MsgPrefix%Error: native component build failed. Refer to the build log files for details: + echo !__BuildLog! + echo !__BuildWrn! + echo !__BuildErr! + exit /b 1 + ) + +:SkipNativeBuild + REM } Scope environment changes end + endlocal +) + +REM ========================================================================================= +REM === +REM === Build Cross-Architecture Native Components (if applicable) +REM === +REM ========================================================================================= + +if /i "%__DoCrossArchBuild%"=="1" ( + REM Scope environment changes start { + setlocal + + echo %__MsgPrefix%Commencing build of cross architecture native components for %__BuildOS%.%__BuildArch%.%__BuildType% + + :: Set the environment for the native build + set __VCBuildArch=x86_amd64 + if /i "%__CrossArch%" == "x86" ( set __VCBuildArch=x86 ) + + echo %__MsgPrefix%Using environment: "%__VCToolsRoot%\vcvarsall.bat" !__VCBuildArch! + call "%__VCToolsRoot%\vcvarsall.bat" !__VCBuildArch! + @if defined _echo @echo on + + if not exist "%__CrossCompIntermediatesDir%" md "%__CrossCompIntermediatesDir%" + if defined __SkipConfigure goto SkipConfigureCrossBuild + + set __CMakeBinDir=%__CrossComponentBinDir% + set "__CMakeBinDir=!__CMakeBinDir:\=/!" + + set "__ManagedBinaryDir=%__RootBinDir%\%__BuildType%\bin" + set "__ManagedBinaryDir=!__ManagedBinaryDir:\=/!" + set __ExtraCmakeArgs="-DCLR_MANAGED_BINARY_DIR=!__ManagedBinaryDir!" "-DCLR_CROSS_COMPONENTS_BUILD=1" "-DCLR_CMAKE_TARGET_ARCH=%__BuildArch%" "-DCMAKE_SYSTEM_VERSION=10.0" + + pushd "%__CrossCompIntermediatesDir%" + call "%__ProjectDir%\eng\gen-buildsys-win.bat" "%__ProjectDir%" %__VSVersion% %__CrossArch% !__ExtraCmakeArgs! + @if defined _echo @echo on + popd + +:SkipConfigureCrossBuild + if not exist "%__CrossCompIntermediatesDir%\install.vcxproj" ( + echo %__MsgPrefix%Error: failed to generate cross-arch components build project! + exit /b 1 + ) + + if defined __ConfigureOnly goto SkipCrossCompBuild + + set __BuildLogRootName=Native.Cross + set __BuildLog="%__LogDir%\!__BuildLogRootName!.log" + set __BuildWrn="%__LogDir%\!__BuildLogRootName!.wrn" + set __BuildErr="%__LogDir%\!__BuildLogRootName!.err" + set __MsbuildLog=/flp:Verbosity=normal;LogFile=!__BuildLog! + set __MsbuildWrn=/flp1:WarningsOnly;LogFile=!__BuildWrn! + set __MsbuildErr=/flp2:ErrorsOnly;LogFile=!__BuildErr! + + msbuild.exe %__CrossCompIntermediatesDir%\install.vcxproj /v:m !__MsbuildLog! !__MsbuildWrn! !__MsbuildErr! /p:Configuration=%__BuildType% /p:Platform=%__CrossArch% %__UnprocessedBuildArgs% + + if not !errorlevel! == 0 ( + echo %__MsgPrefix%Error: cross-arch components build failed. Refer to the build log files for details: + echo !__BuildLog! + echo !__BuildWrn! + echo !__BuildErr! + exit /b 1 + ) + +:SkipCrossCompBuild + REM } Scope environment changes end + endlocal +) + +REM ========================================================================================= +REM === +REM === All builds complete! +REM === +REM ========================================================================================= + +echo %__MsgPrefix%Repo successfully built. Finished at %TIME% +echo %__MsgPrefix%Product binaries are available at !__BinDir! +exit /b 0 + +REM ========================================================================================= +REM === +REM === Helper routines +REM === +REM ========================================================================================= + +:Usage +echo. +echo Build the Diagnostics repo. +echo. +echo Usage: +echo build-native.cmd [option1] [option2] +echo. +echo All arguments are optional. The options are: +echo. +echo.-? -h -help --help: view this message. +echo -build - build native components +echo -test - test native components +echo -architechure +echo -configuration +exit /b 1 + +:PrivateToolSet + +echo %__MsgPrefix%Setting up the usage of __ToolsetDir:%__ToolsetDir% + +if /i "%__ToolsetDir%" == "" ( + echo %__MsgPrefix%Error: A toolset directory is required for the Arm64 Windows build. Use the toolset_dir argument. + exit /b 1 +) + +if not exist "%__ToolsetDir%"\buildenv_arm64.cmd goto :Not_EWDK +call "%__ToolsetDir%"\buildenv_arm64.cmd +exit /b 0 + +:Not_EWDK +set PATH=%__ToolsetDir%\VC_sdk\bin;%PATH% +set LIB=%__ToolsetDir%\VC_sdk\lib\arm64;%__ToolsetDir%\sdpublic\sdk\lib\arm64 +set INCLUDE=^ +%__ToolsetDir%\VC_sdk\inc;^ +%__ToolsetDir%\sdpublic\sdk\inc;^ +%__ToolsetDir%\sdpublic\shared\inc;^ +%__ToolsetDir%\sdpublic\shared\inc\minwin;^ +%__ToolsetDir%\sdpublic\sdk\inc\ucrt;^ +%__ToolsetDir%\sdpublic\sdk\inc\minwin;^ +%__ToolsetDir%\sdpublic\sdk\inc\mincore;^ +%__ToolsetDir%\sdpublic\sdk\inc\abi;^ +%__ToolsetDir%\sdpublic\sdk\inc\clientcore;^ +%__ToolsetDir%\diasdk\include +exit /b 0 diff --git a/eng/Build.cmd b/eng/Build.cmd new file mode 100644 index 000000000..741751960 --- /dev/null +++ b/eng/Build.cmd @@ -0,0 +1,9 @@ +@echo off + +rem build/test managed components +powershell -ExecutionPolicy ByPass -command "& """%~dp0common\Build.ps1""" %*" +if NOT '%ERRORLEVEL%' == '0' exit /b %ERRORLEVEL% + +rem build/test native componments +call %~dp0build-native.cmd %* +exit /b %ERRORLEVEL% diff --git a/eng/CIBuild.cmd b/eng/CIBuild.cmd new file mode 100644 index 000000000..94fc7744b --- /dev/null +++ b/eng/CIBuild.cmd @@ -0,0 +1,3 @@ +@echo off +call %~dp0Build.cmd -restore -build -test -sign -ci %* +exit /b %ErrorLevel% diff --git a/eng/Versions.props b/eng/Versions.props index 18779ae02..59732b8e6 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -11,7 +11,7 @@ false - 1.6.0-preview2-26406-04 + 1.5.0 diff --git a/eng/build-native.sh b/eng/build-native.sh index d72343434..6d36189c6 100755 --- a/eng/build-native.sh +++ b/eng/build-native.sh @@ -30,6 +30,25 @@ __UnprocessedBuildArgs= __Build=0 __Test=0 +# resolve python-version to use +if [ "$PYTHON" == "" ] ; then + if ! PYTHON=$(command -v python2.7 || command -v python2 || command -v python) + then + echo "Unable to locate build-dependency python2.x!" 1>&2 + exit 1 + fi +fi + +# validate python-dependency +# useful in case of explicitly set option. +if ! command -v $PYTHON > /dev/null +then + echo "Unable to locate build-dependency python2.x ($PYTHON)!" 1>&2 + exit 1 +fi + +echo $PYTHON + usage() { echo "Usage: $0 [options]" @@ -37,7 +56,8 @@ usage() echo "--test - test native components" echo "--architechure " echo "--configuration " - echo "--clangx.y - optional argument to build using clang version x.y." + echo "--clangx.y - optional argument to build using clang version x.y" + echo "--help - this help message" exit 1 } @@ -197,6 +217,7 @@ done __RootBinDir=$__ProjectRoot/artifacts __IntermediatesDir="$__RootBinDir/obj/$__BuildOS.$__BuildArch.$__BuildType" __LogFileDir="$__RootBinDir/log/$__BuildOS.$__BuildArch.$__BuildType" +__ExtraCmakeArgs="-DCLR_MANAGED_BINARY_DIR=$__RootBinDir/$__BuildType/bin" # Specify path to be set for CMAKE_INSTALL_PREFIX. # This is where all built native libraries will copied to. @@ -213,6 +234,11 @@ if [[ $__ClangMajorVersion == 0 && $__ClangMinorVersion == 0 ]]; then fi fi +if [[ "$__BuildArch" == "armel" ]]; then + # Armel cross build is Tizen specific and does not support Portable RID build + __PortableBuild=0 +fi + mkdir -p "$__IntermediatesDir" mkdir -p "$__LogFileDir" mkdir -p "$__CMakeBinDir" @@ -260,7 +286,14 @@ initHostDistroRid() if [ "$__HostOS" == "Linux" ]; then if [ -e /etc/os-release ]; then source /etc/os-release + if [[ $ID == "rhel" ]]; then + # remove the last version digit + VERSION_ID=${VERSION_ID%.*} + fi __HostDistroRid="$ID.$VERSION_ID-$__HostArch" + if [[ $ID == "alpine" ]]; then + __HostDistroRid="linux-musl-$__HostArch" + fi elif [ -e /etc/redhat-release ]; then local redhatRelease=$(&2; + ExitWithExitCode 1 + fi; +} + +# install .NET Core +ReadJson "$scriptroot/../global.json" "version" + +# setting DOTNET_INSTALL_DIR prevents build.sh from installing it export DOTNET_INSTALL_DIR=$scriptroot/../.dotnet -"$scriptroot/install-dotnet.sh" $DOTNET_INSTALL_DIR 2.1.300-rc1-008673 +"$scriptroot/install-dotnet.sh" $DOTNET_INSTALL_DIR $readjsonvalue +if [[ $? != 0 ]]; then + exit 1 +fi # build/test managed components "$scriptroot/common/build.sh" $@ +if [[ $? != 0 ]]; then + exit 1 +fi # build/test native components "$scriptroot/build-native.sh" $@ diff --git a/eng/cibuild.sh b/eng/cibuild.sh index da5b4e51d..39fbbbba8 100755 --- a/eng/cibuild.sh +++ b/eng/cibuild.sh @@ -15,4 +15,4 @@ while [[ -h $source ]]; do done scriptroot="$( cd -P "$( dirname "$source" )" && pwd )" -"$scriptroot/build.sh" --restore --build --test --pack --ci $@ +"$scriptroot/build.sh" --restore --build --test --sign --ci $@ diff --git a/src/pal/tools/gen-buildsys-win.bat b/eng/gen-buildsys-win.bat similarity index 100% rename from src/pal/tools/gen-buildsys-win.bat rename to eng/gen-buildsys-win.bat diff --git a/eng/generateexportedsymbols.awk b/eng/generateexportedsymbols.awk new file mode 100644 index 000000000..1d9b200d2 --- /dev/null +++ b/eng/generateexportedsymbols.awk @@ -0,0 +1,11 @@ +{ + # Remove the CR character in case the sources are mapped from + # a Windows share and contain CRLF line endings + gsub(/\r/,"", $0); + + # Skip empty lines and comment lines starting with semicolon + if (NF && !match($0, /^[:space:]*;/)) + { + print "_" $0; + } +} diff --git a/eng/generateversionscript.awk b/eng/generateversionscript.awk new file mode 100644 index 000000000..226c6a545 --- /dev/null +++ b/eng/generateversionscript.awk @@ -0,0 +1,19 @@ +BEGIN { + print "V1.0 {"; + print " global:"; +} +{ + # Remove the CR character in case the sources are mapped from + # a Windows share and contain CRLF line endings + gsub(/\r/,"", $0); + + # Skip empty lines and comment lines starting with semicolon + if (NF && !match($0, /^[ \t]*;/)) + { + print " " $0 ";"; + } +} +END { + print " local: *;" + print "};"; +} diff --git a/eng/install-dotnet.sh b/eng/install-dotnet.sh index 8dd36a283..2f385d06f 100755 --- a/eng/install-dotnet.sh +++ b/eng/install-dotnet.sh @@ -86,3 +86,6 @@ if [ ! -e "$dotnet_root" ]; then tar -xf "$dotnet_root/dotnet.tar" fi +echo "Adding to current process PATH: \`$dotnet_root\`. Note: This change will be visible only when sourcing script." +export PATH="$dotnet_root":"$PATH" + diff --git a/src/pal/tools/probe-win.ps1 b/eng/probe-win.ps1 similarity index 100% rename from src/pal/tools/probe-win.ps1 rename to eng/probe-win.ps1 diff --git a/eng/setup_vs_tools.cmd b/eng/setup_vs_tools.cmd new file mode 100644 index 000000000..9af06e5bd --- /dev/null +++ b/eng/setup_vs_tools.cmd @@ -0,0 +1,48 @@ +@if not defined _echo @echo off + +REM This script is responsible for setting up either the vs2015 or vs2017 env +REM All passed arguments are ignored +REM Script will return with 0 if pass, 1 if there is a failure to find either +REM vs2015 or vs2017 + +:: Default to highest Visual Studio version available +:: +:: For VS2015 (and prior), only a single instance is allowed to be installed on a box +:: and VS140COMNTOOLS is set as a global environment variable by the installer. This +:: allows users to locate where the instance of VS2015 is installed. +:: +:: For VS2017, multiple instances can be installed on the same box SxS and VS150COMNTOOLS +:: is no longer set as a global environment variable and is instead only set if the user +:: has launched the VS2017 Developer Command Prompt. +:: +:: Following this logic, we will default to the VS2017 toolset if VS150COMNTOOLS tools is +:: set, as this indicates the user is running from the VS2017 Developer Command Prompt and +:: is already configured to use that toolset. Otherwise, we will fallback to using the VS2015 +:: toolset if it is installed. Finally, we will fail the script if no supported VS instance +:: can be found. + +if defined VisualStudioVersion ( + if not defined __VSVersion echo %__MsgPrefix%Detected Visual Studio %VisualStudioVersion% developer command ^prompt environment + goto skip_setup +) + +echo %__MsgPrefix%Searching ^for Visual Studio 2017 or 2015 installation +set _VSWHERE="%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" +if exist %_VSWHERE% ( + for /f "usebackq tokens=*" %%i in (`%_VSWHERE% -latest -prerelease -property installationPath`) do set _VSCOMNTOOLS=%%i\Common7\Tools + goto call_vs +) +if not exist "%_VSCOMNTOOLS%" set _VSCOMNTOOLS=%VS140COMNTOOLS% +echo VS2017 not found, using VS2015 +:call_vs +if not exist "%_VSCOMNTOOLS%" ( + echo %__MsgPrefix%Error: Visual Studio 2015 or 2017 required. + echo Please see https://github.com/dotnet/coreclr/blob/master/Documentation/building/windows-instructions.md for build instructions. + exit /b 1 +) +echo %__MsgPrefix%"%_VSCOMNTOOLS%\VsDevCmd.bat" +call "%_VSCOMNTOOLS%\VsDevCmd.bat" + +:skip_setup + +exit /b 0 \ No newline at end of file diff --git a/src/pal/tools/windows-compiler-override.txt b/eng/windows-compiler-override.txt similarity index 100% rename from src/pal/tools/windows-compiler-override.txt rename to eng/windows-compiler-override.txt diff --git a/functions.cmake b/functions.cmake index 913e71a65..afdd19006 100644 --- a/functions.cmake +++ b/functions.cmake @@ -11,6 +11,85 @@ function(clr_unknown_arch) endif() endfunction() +# Build a list of compiler definitions by putting -D in front of each define. +function(get_compile_definitions DefinitionName) + # Get the current list of definitions + get_directory_property(COMPILE_DEFINITIONS_LIST COMPILE_DEFINITIONS) + + foreach(DEFINITION IN LISTS COMPILE_DEFINITIONS_LIST) + if (${DEFINITION} MATCHES "^\\$<\\$]+)>:([^>]+)>$") + # The entries that contain generator expressions must have the -D inside of the + # expression. So we transform e.g. $<$:_DEBUG> to $<$:-D_DEBUG> + set(DEFINITION "$<$:-D${CMAKE_MATCH_2}>") + else() + set(DEFINITION -D${DEFINITION}) + endif() + list(APPEND DEFINITIONS ${DEFINITION}) + endforeach() + set(${DefinitionName} ${DEFINITIONS} PARENT_SCOPE) +endfunction(get_compile_definitions) + +# Build a list of include directories +function(get_include_directories IncludeDirectories) + get_directory_property(dirs INCLUDE_DIRECTORIES) + foreach(dir IN LISTS dirs) + + if (CLR_CMAKE_PLATFORM_ARCH_ARM AND WIN32) + list(APPEND INC_DIRECTORIES /I${dir}) + else() + list(APPEND INC_DIRECTORIES -I${dir}) + endif(CLR_CMAKE_PLATFORM_ARCH_ARM AND WIN32) + + endforeach() + set(${IncludeDirectories} ${INC_DIRECTORIES} PARENT_SCOPE) +endfunction(get_include_directories) + +# Set the passed in RetSources variable to the list of sources with added current source directory +# to form absolute paths. +# The parameters after the RetSources are the input files. +function(convert_to_absolute_path RetSources) + set(Sources ${ARGN}) + foreach(Source IN LISTS Sources) + list(APPEND AbsolutePathSources ${CMAKE_CURRENT_SOURCE_DIR}/${Source}) + endforeach() + set(${RetSources} ${AbsolutePathSources} PARENT_SCOPE) +endfunction(convert_to_absolute_path) + +#Preprocess exports definition file +function(preprocess_def_file inputFilename outputFilename) + get_compile_definitions(PREPROCESS_DEFINITIONS) + get_include_directories(ASM_INCLUDE_DIRECTORIES) + add_custom_command( + OUTPUT ${outputFilename} + COMMAND ${CMAKE_CXX_COMPILER} ${ASM_INCLUDE_DIRECTORIES} /P /EP /TC ${PREPROCESS_DEFINITIONS} /Fi${outputFilename} ${inputFilename} + DEPENDS ${inputFilename} + COMMENT "Preprocessing ${inputFilename} - ${CMAKE_CXX_COMPILER} ${ASM_INCLUDE_DIRECTORIES} /P /EP /TC ${PREPROCESS_DEFINITIONS} /Fi${outputFilename} ${inputFilename}" + ) + + set_source_files_properties(${outputFilename} + PROPERTIES GENERATED TRUE) +endfunction() +function(generate_exports_file) + set(INPUT_LIST ${ARGN}) + list(GET INPUT_LIST -1 outputFilename) + list(REMOVE_AT INPUT_LIST -1) + + if(CMAKE_SYSTEM_NAME STREQUAL Darwin) + set(AWK_SCRIPT eng/generateexportedsymbols.awk) + else() + set(AWK_SCRIPT eng/generateversionscript.awk) + endif(CMAKE_SYSTEM_NAME STREQUAL Darwin) + + add_custom_command( + OUTPUT ${outputFilename} + COMMAND ${AWK} -f ${CMAKE_SOURCE_DIR}/${AWK_SCRIPT} ${INPUT_LIST} >${outputFilename} + DEPENDS ${INPUT_LIST} ${CMAKE_SOURCE_DIR}/${AWK_SCRIPT} + COMMENT "Generating exports file ${outputFilename}" + ) + set_source_files_properties(${outputFilename} + PROPERTIES GENERATED TRUE) +endfunction() + function(strip_symbols targetName outputFilename) if (CLR_CMAKE_PLATFORM_UNIX) if (STRIP_SYMBOLS) @@ -69,18 +148,25 @@ function(install_clr targetName) install(PROGRAMS ${install_source_file} DESTINATION .) if(WIN32) - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/$/${targetName}.pdb DESTINATION PDB) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/$/${targetName}.pdb DESTINATION .) else() install(FILES ${strip_destination_file} DESTINATION .) endif() - if(CLR_CMAKE_PGO_INSTRUMENT) - if(WIN32) - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/$/${targetName}.pgd DESTINATION PGD OPTIONAL) - endif() - endif() endif() endfunction() +function(_add_executable) + if(NOT WIN32) + add_executable(${ARGV} ${VERSION_FILE_PATH}) + else() + add_executable(${ARGV}) + endif(NOT WIN32) + list(FIND CLR_CROSS_COMPONENTS_LIST ${ARGV0} INDEX) + if (DEFINED CLR_CROSS_COMPONENTS_LIST AND ${INDEX} EQUAL -1) + set_target_properties(${ARGV0} PROPERTIES EXCLUDE_FROM_ALL 1) + endif() +endfunction() + function(_add_library) if(NOT WIN32) add_library(${ARGV} ${VERSION_FILE_PATH}) @@ -96,3 +182,14 @@ endfunction() function(add_library_clr) _add_library(${ARGV}) endfunction() + +function(add_executable_clr) + _add_executable(${ARGV}) +endfunction() + +function(_install) + if(NOT DEFINED CLR_CROSS_COMPONENTS_BUILD) + install(${ARGV}) + endif() +endfunction() + diff --git a/pipeline.groovy b/pipeline.groovy index e1a440b50..0ca197ee8 100644 --- a/pipeline.groovy +++ b/pipeline.groovy @@ -41,7 +41,7 @@ buildConfigurations.each { config -> stage ('Build/Test') { if (os == "Windows_NT") { - bat ".\\eng\\common\\CIBuild.cmd -configuration ${config.Configuration} -prepareMachine" + bat ".\\eng\\CIBuild.cmd -configuration ${config.Configuration} -prepareMachine" } else { sh "./eng/cibuild.sh --configuration ${config.Configuration} --architechure ${config.Architechure} --prepareMachine" } diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 61a472d0f..9015d3d4d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1 +1,11 @@ +include_directories(${ROOT_DIR}/src/pal/prebuilt/inc) + +include_directories(inc) + +if (CLR_CMAKE_PLATFORM_UNIX) + add_subdirectory(palrt) + add_subdirectory(pal) +endif(CLR_CMAKE_PLATFORM_UNIX) + +add_subdirectory(inc) add_subdirectory(SOS) diff --git a/src/SOS/CMakeLists.txt b/src/SOS/CMakeLists.txt index cd30034b9..5837e0330 100644 --- a/src/SOS/CMakeLists.txt +++ b/src/SOS/CMakeLists.txt @@ -1,3 +1,30 @@ if(CLR_CMAKE_PLATFORM_UNIX) + include_directories(${ROOT_DIR}/src/pal/inc) + include_directories(${ROOT_DIR}/src/pal/inc/rt) + add_subdirectory(lldbplugin) endif(CLR_CMAKE_PLATFORM_UNIX) + +# lldbplugin doesn't build with these options +if(WIN32) + add_compile_options(/FIWarningControl.h) # force include of WarningControl.h + add_compile_options(/Zl) # omit default library name in .OBJ +endif(WIN32) + +add_definitions(-D_SECURE_SCL=0) + +add_subdirectory(NETCore) +add_subdirectory(Strike) + +if(CLR_CMAKE_PLATFORM_UNIX) + add_compile_options(-fPIC) + + # Include the dummy c++ include files + include_directories(${ROOT_DIR}/src/pal/inc/rt/cpp) + + # This prevents inclusion of standard C compiler headers + add_compile_options(-nostdinc) +endif(CLR_CMAKE_PLATFORM_UNIX) + +add_subdirectory(debugshim) +add_subdirectory(dbgutil) diff --git a/src/SOS/NETCore/CMakeLists.txt b/src/SOS/NETCore/CMakeLists.txt new file mode 100644 index 000000000..28ff7ea70 --- /dev/null +++ b/src/SOS/NETCore/CMakeLists.txt @@ -0,0 +1,8 @@ +project(SOS.NETCore) + +if(NOT ${CLR_MANAGED_BINARY_DIR} STREQUAL "") + set(MANAGED_BINDIR ${CLR_MANAGED_BINARY_DIR}/SOS.NETCore/netcoreapp1.0) + + install(FILES ${MANAGED_BINDIR}/SOS.NETCore.dll DESTINATION .) + install(FILES ${MANAGED_BINDIR}/SOS.NETCore.pdb DESTINATION .) +endif() diff --git a/src/ToolBox/SOS/Strike/CMakeLists.txt b/src/SOS/Strike/CMakeLists.txt similarity index 75% rename from src/ToolBox/SOS/Strike/CMakeLists.txt rename to src/SOS/Strike/CMakeLists.txt index 65c3f9585..1230d169b 100644 --- a/src/ToolBox/SOS/Strike/CMakeLists.txt +++ b/src/SOS/Strike/CMakeLists.txt @@ -1,3 +1,7 @@ +project(sos) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + # Set the RPATH of sos so that it can find dependencies without needing to set LD_LIBRARY_PATH # For more information: http://www.cmake.org/Wiki/CMake_RPATH_handling. if (CORECLR_SET_RPATH) @@ -10,44 +14,27 @@ if (CORECLR_SET_RPATH) endif (CORECLR_SET_RPATH) if(CLR_CMAKE_PLATFORM_ARCH_AMD64) - add_definitions(-DSOS_TARGET_AMD64=1) add_definitions(-D_TARGET_WIN64_=1) - add_definitions(-DDBG_TARGET_64BIT) - add_definitions(-DDBG_TARGET_WIN64=1) + add_definitions(-DSOS_TARGET_AMD64=1) if(WIN32) add_definitions(-DSOS_TARGET_ARM64=1) endif(WIN32) - remove_definitions(-D_TARGET_ARM64_=1) - add_definitions(-D_TARGET_AMD64_) - add_definitions(-DDBG_TARGET_AMD64) elseif(CLR_CMAKE_PLATFORM_ARCH_I386) add_definitions(-DSOS_TARGET_X86=1) - add_definitions(-D_TARGET_X86_=1) - add_definitions(-DDBG_TARGET_32BIT) if(WIN32) add_definitions(-DSOS_TARGET_ARM=1) endif(WIN32) elseif(CLR_CMAKE_PLATFORM_ARCH_ARM) add_definitions(-DSOS_TARGET_ARM=1) - add_definitions(-D_TARGET_WIN32_=1) - add_definitions(-D_TARGET_ARM_=1) - add_definitions(-DDBG_TARGET_32BIT) elseif(CLR_CMAKE_PLATFORM_ARCH_ARM64) - add_definitions(-DSOS_TARGET_ARM64=1) add_definitions(-D_TARGET_WIN64_=1) - add_definitions(-DDBG_TARGET_64BIT) - add_definitions(-DDBG_TARGET_WIN64=1) + add_definitions(-DSOS_TARGET_ARM64=1) endif() + add_definitions(-DSTRIKE) -remove_definitions(-DUNICODE) -remove_definitions(-D_UNICODE) - -include_directories(BEFORE ${VM_DIR}) -include_directories(${CLR_DIR}/src/gcdump) -include_directories(${CLR_DIR}/src/debug/shim) -include_directories(${CLR_DIR}/src/coreclr/hosts/unixcoreruncommon) -include_directories(${CLR_DIR}/src/coreclr/hosts/inc) +include_directories(${ROOT_DIR}/src/SOS/gcdump) +include_directories(${ROOT_DIR}/src/SOS/debugshim) if(WIN32) include_directories(inc) @@ -127,31 +114,50 @@ else(WIN32) strike.cpp sos.cpp util.cpp - ../../../coreclr/hosts/unixcoreruncommon/coreruncommon.cpp - ) - - set(SOS_LIBRARY - corguids - debugshim - dbgutil - # share the PAL in the dac module - mscordaccore - palrt ) set(DEF_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/sos_unixexports.src) set(EXPORTS_FILE ${CMAKE_CURRENT_BINARY_DIR}/sos.exports) generate_exports_file(${DEF_SOURCES} ${EXPORTS_FILE}) + + if(CMAKE_SYSTEM_NAME STREQUAL Linux OR CMAKE_SYSTEM_NAME STREQUAL FreeBSD OR CMAKE_SYSTEM_NAME STREQUAL NetBSD) + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Xlinker -Bsymbolic -Xlinker -Bsymbolic-functions") + + # These options are used to force every object to be included even if it's unused. + set(START_WHOLE_ARCHIVE -Wl,--whole-archive) + set(END_WHOLE_ARCHIVE -Wl,--no-whole-archive) + + set(EXPORTS_LINKER_OPTION -Wl,--version-script=${EXPORTS_FILE}) + endif(CMAKE_SYSTEM_NAME STREQUAL Linux OR CMAKE_SYSTEM_NAME STREQUAL FreeBSD OR CMAKE_SYSTEM_NAME STREQUAL NetBSD) + + if(CMAKE_SYSTEM_NAME STREQUAL Darwin) + # These options are used to force every object to be included even if it's unused. + set(START_WHOLE_ARCHIVE -force_load) + set(END_WHOLE_ARCHIVE ) + + set(EXPORTS_LINKER_OPTION -Wl,-exported_symbols_list,${EXPORTS_FILE}) + endif(CMAKE_SYSTEM_NAME STREQUAL Darwin) + + set(SOS_LIBRARY + corguids + debugshim + dbgutil + ${START_WHOLE_ARCHIVE} # force all PAL objects to be included so all exports are available + coreclrpal + ${END_WHOLE_ARCHIVE} + palrt + ) + endif(WIN32) if(CLR_CMAKE_PLATFORM_ARCH_AMD64) - if(CLR_CMAKE_PLATFORM_LINUX) - list(APPEND - SOS_LIBRARY - createdump_lib - ) - add_definitions(-DCREATE_DUMP_SUPPORTED) - endif(CLR_CMAKE_PLATFORM_LINUX) +# if(CLR_CMAKE_PLATFORM_LINUX) + #list(APPEND + # SOS_LIBRARY + # createdump_lib + #) + #add_definitions(-DCREATE_DUMP_SUPPORTED) +# endif(CLR_CMAKE_PLATFORM_LINUX) set(SOS_SOURCES_ARCH disasmX86.cpp ) @@ -201,8 +207,6 @@ if(CLR_CMAKE_PLATFORM_UNIX) set_property(TARGET sos APPEND_STRING PROPERTY LINK_FLAGS ${EXPORTS_LINKER_OPTION}) set_property(TARGET sos APPEND_STRING PROPERTY LINK_DEPENDS ${EXPORTS_FILE}) - - add_dependencies(sos mscordaccore) endif(CLR_CMAKE_PLATFORM_UNIX) target_link_libraries(sos ${SOS_LIBRARY}) diff --git a/src/ToolBox/SOS/Strike/EventCallbacks.cpp b/src/SOS/Strike/EventCallbacks.cpp similarity index 100% rename from src/ToolBox/SOS/Strike/EventCallbacks.cpp rename to src/SOS/Strike/EventCallbacks.cpp diff --git a/src/ToolBox/SOS/Strike/EventCallbacks.h b/src/SOS/Strike/EventCallbacks.h similarity index 100% rename from src/ToolBox/SOS/Strike/EventCallbacks.h rename to src/SOS/Strike/EventCallbacks.h diff --git a/src/ToolBox/SOS/Strike/ExpressionNode.cpp b/src/SOS/Strike/ExpressionNode.cpp similarity index 100% rename from src/ToolBox/SOS/Strike/ExpressionNode.cpp rename to src/SOS/Strike/ExpressionNode.cpp diff --git a/src/ToolBox/SOS/Strike/ExpressionNode.h b/src/SOS/Strike/ExpressionNode.h similarity index 100% rename from src/ToolBox/SOS/Strike/ExpressionNode.h rename to src/SOS/Strike/ExpressionNode.h diff --git a/src/ToolBox/SOS/Strike/Native.rc b/src/SOS/Strike/Native.rc similarity index 100% rename from src/ToolBox/SOS/Strike/Native.rc rename to src/SOS/Strike/Native.rc diff --git a/src/ToolBox/SOS/Strike/UtilCode.h b/src/SOS/Strike/UtilCode.h similarity index 100% rename from src/ToolBox/SOS/Strike/UtilCode.h rename to src/SOS/Strike/UtilCode.h diff --git a/src/ToolBox/SOS/Strike/WatchCmd.cpp b/src/SOS/Strike/WatchCmd.cpp similarity index 100% rename from src/ToolBox/SOS/Strike/WatchCmd.cpp rename to src/SOS/Strike/WatchCmd.cpp diff --git a/src/ToolBox/SOS/Strike/WatchCmd.h b/src/SOS/Strike/WatchCmd.h similarity index 100% rename from src/ToolBox/SOS/Strike/WatchCmd.h rename to src/SOS/Strike/WatchCmd.h diff --git a/src/ToolBox/SOS/Strike/data.h b/src/SOS/Strike/data.h similarity index 100% rename from src/ToolBox/SOS/Strike/data.h rename to src/SOS/Strike/data.h diff --git a/src/ToolBox/SOS/Strike/datatarget.cpp b/src/SOS/Strike/datatarget.cpp similarity index 100% rename from src/ToolBox/SOS/Strike/datatarget.cpp rename to src/SOS/Strike/datatarget.cpp diff --git a/src/ToolBox/SOS/Strike/datatarget.h b/src/SOS/Strike/datatarget.h similarity index 100% rename from src/ToolBox/SOS/Strike/datatarget.h rename to src/SOS/Strike/datatarget.h diff --git a/src/SOS/Strike/dbgutil.cpp b/src/SOS/Strike/dbgutil.cpp new file mode 100644 index 000000000..a16849868 --- /dev/null +++ b/src/SOS/Strike/dbgutil.cpp @@ -0,0 +1,426 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. +//***************************************************************************** +// dbgutil.cpp +// + +// +//***************************************************************************** + +// +// Various common helpers for PE resource reading used by multiple debug components. +// + +#include +#include "corerror.h" +#include +#include + +// Returns the RVA of the resource section for the module specified by the given data target and module base. +// Returns failure if the module doesn't have a resource section. +// +// Arguments +// pDataTarget - dataTarget for the process we are inspecting +// moduleBaseAddress - base address of a module we should inspect +// pwImageFileMachine - updated with the Machine from the IMAGE_FILE_HEADER +// pdwResourceSectionRVA - updated with the resultant RVA on success +HRESULT GetMachineAndResourceSectionRVA(ICorDebugDataTarget* pDataTarget, + ULONG64 moduleBaseAddress, + WORD* pwImageFileMachine, + DWORD* pdwResourceSectionRVA) +{ + // Fun code ahead... below is a hand written PE decoder with some of the file offsets hardcoded. + // It supports no more than what we absolutely have to to get to the resources we need. Any of the + // magic numbers used below can be determined by using the public documentation on the web. + // + // Yes utilcode has a PE decoder, no it does not support reading its data through a datatarget + // It was easier to inspect the small portion that I needed than to shove an abstraction layer under + // our utilcode and then make sure everything still worked. + + // SECURITY WARNING: all data provided by the data target should be considered untrusted. + // Do not allow malicious data to cause large reads, memory allocations, buffer overflow, + // or any other undesirable behavior. + + HRESULT hr = S_OK; + + // at offset 3c in the image is a 4 byte file pointer that indicates where the PE signature is + IMAGE_DOS_HEADER dosHeader; + hr = ReadFromDataTarget(pDataTarget, moduleBaseAddress, (BYTE*)&dosHeader, sizeof(dosHeader)); + + // verify there is a 4 byte PE signature there + DWORD peSigFilePointer = 0; + if (SUCCEEDED(hr)) + { + peSigFilePointer = dosHeader.e_lfanew; + DWORD peSig = 0; + hr = ReadFromDataTarget(pDataTarget, moduleBaseAddress + peSigFilePointer, (BYTE*)&peSig, 4); + if (SUCCEEDED(hr) && peSig != IMAGE_NT_SIGNATURE) + { + hr = E_FAIL; // PE signature not present + } + } + + // after the signature is a 20 byte image file header + // we need to parse this to figure out the target architecture + IMAGE_FILE_HEADER imageFileHeader; + if (SUCCEEDED(hr)) + { + hr = ReadFromDataTarget(pDataTarget, moduleBaseAddress + peSigFilePointer + 4, (BYTE*)&imageFileHeader, IMAGE_SIZEOF_FILE_HEADER); + } + + + + WORD optHeaderMagic = 0; + DWORD peOptImageHeaderFilePointer = 0; + if (SUCCEEDED(hr)) + { + if(pwImageFileMachine != NULL) + { + *pwImageFileMachine = imageFileHeader.Machine; + } + + // 4 bytes after the signature is the 20 byte image file header + // 24 bytes after the signature is the image-only header + // at the beginning of the image-only header is a 2 byte magic number indicating its format + peOptImageHeaderFilePointer = peSigFilePointer + IMAGE_SIZEOF_FILE_HEADER + sizeof(DWORD); + hr = ReadFromDataTarget(pDataTarget, moduleBaseAddress + peOptImageHeaderFilePointer, (BYTE*)&optHeaderMagic, 2); + } + + // Either 112 or 128 bytes after the beginning of the image-only header is an 8 byte resource table + // depending on whether the image is PE32 or PE32+ + DWORD resourceSectionRVA = 0; + if (SUCCEEDED(hr)) + { + if (optHeaderMagic == IMAGE_NT_OPTIONAL_HDR32_MAGIC) // PE32 + { + IMAGE_OPTIONAL_HEADER32 header32; + hr = ReadFromDataTarget(pDataTarget, moduleBaseAddress + peOptImageHeaderFilePointer, + (BYTE*)&header32, sizeof(header32)); + if (SUCCEEDED(hr)) + { + resourceSectionRVA = header32.DataDirectory[IMAGE_DIRECTORY_ENTRY_RESOURCE].VirtualAddress; + } + } + else if (optHeaderMagic == IMAGE_NT_OPTIONAL_HDR64_MAGIC) //PE32+ + { + IMAGE_OPTIONAL_HEADER64 header64; + hr = ReadFromDataTarget(pDataTarget, moduleBaseAddress + peOptImageHeaderFilePointer, + (BYTE*)&header64, sizeof(header64)); + if (SUCCEEDED(hr)) + { + resourceSectionRVA = header64.DataDirectory[IMAGE_DIRECTORY_ENTRY_RESOURCE].VirtualAddress; + } + } + else + { + hr = E_FAIL; // Invalid PE + } + } + + *pdwResourceSectionRVA = resourceSectionRVA; + return S_OK; +} + +HRESULT GetResourceRvaFromResourceSectionRva(ICorDebugDataTarget* pDataTarget, + ULONG64 moduleBaseAddress, + DWORD resourceSectionRva, + DWORD type, + DWORD name, + DWORD language, + DWORD* pResourceRva, + DWORD* pResourceSize) +{ + HRESULT hr = S_OK; + DWORD nameTableRva = 0; + DWORD langTableRva = 0; + DWORD resourceDataEntryRva = 0; + *pResourceRva = 0; + *pResourceSize = 0; + + // The resource section begins with a resource directory that indexes all the resources by type. + // Each entry it points to is another resource directory that indexes all the same type + // resources by name. And each entry in that table points to another resource directory that indexes + // all the same type/name resources by language. Entries in the final table give the RVA of the actual + // resource. + // Note all RVAs in this section are relative to the beginning of the resource section, + // not the beginning of the image. + + hr = GetNextLevelResourceEntryRVA(pDataTarget, type, moduleBaseAddress, resourceSectionRva, &nameTableRva); + + + if (SUCCEEDED(hr)) + { + nameTableRva += resourceSectionRva; + hr = GetNextLevelResourceEntryRVA(pDataTarget, name, moduleBaseAddress, nameTableRva, &langTableRva); + + } + if (SUCCEEDED(hr)) + { + langTableRva += resourceSectionRva; + hr = GetNextLevelResourceEntryRVA(pDataTarget, language, moduleBaseAddress, langTableRva, &resourceDataEntryRva); + } + + // The resource data entry has the first 4 bytes indicating the RVA of the resource + // The next 4 bytes indicate the size of the resource + if (SUCCEEDED(hr)) + { + resourceDataEntryRva += resourceSectionRva; + IMAGE_RESOURCE_DATA_ENTRY dataEntry; + hr = ReadFromDataTarget(pDataTarget, moduleBaseAddress + resourceDataEntryRva, + (BYTE*)&dataEntry, sizeof(dataEntry)); + *pResourceRva = dataEntry.OffsetToData; + *pResourceSize = dataEntry.Size; + } + + return hr; +} + +HRESULT GetResourceRvaFromResourceSectionRvaByName(ICorDebugDataTarget* pDataTarget, + ULONG64 moduleBaseAddress, + DWORD resourceSectionRva, + DWORD type, + LPCWSTR pwszName, + DWORD language, + DWORD* pResourceRva, + DWORD* pResourceSize) +{ + HRESULT hr = S_OK; + DWORD nameTableRva = 0; + DWORD langTableRva = 0; + DWORD resourceDataEntryRva = 0; + *pResourceRva = 0; + *pResourceSize = 0; + + // The resource section begins with a resource directory that indexes all the resources by type. + // Each entry it points to is another resource directory that indexes all the same type + // resources by name. And each entry in that table points to another resource directory that indexes + // all the same type/name resources by language. Entries in the final table give the RVA of the actual + // resource. + // Note all RVAs in this section are relative to the beginning of the resource section, + // not the beginning of the image. + hr = GetNextLevelResourceEntryRVA(pDataTarget, type, moduleBaseAddress, resourceSectionRva, &nameTableRva); + + + if (SUCCEEDED(hr)) + { + nameTableRva += resourceSectionRva; + hr = GetNextLevelResourceEntryRVAByName(pDataTarget, pwszName, moduleBaseAddress, nameTableRva, resourceSectionRva, &langTableRva); + } + if (SUCCEEDED(hr)) + { + langTableRva += resourceSectionRva; + hr = GetNextLevelResourceEntryRVA(pDataTarget, language, moduleBaseAddress, langTableRva, &resourceDataEntryRva); + } + + // The resource data entry has the first 4 bytes indicating the RVA of the resource + // The next 4 bytes indicate the size of the resource + if (SUCCEEDED(hr)) + { + resourceDataEntryRva += resourceSectionRva; + IMAGE_RESOURCE_DATA_ENTRY dataEntry; + hr = ReadFromDataTarget(pDataTarget, moduleBaseAddress + resourceDataEntryRva, + (BYTE*)&dataEntry, sizeof(dataEntry)); + *pResourceRva = dataEntry.OffsetToData; + *pResourceSize = dataEntry.Size; + } + + return hr; +} + +// Traverses down one level in the PE resource tree structure +// +// Arguments: +// pDataTarget - the data target for inspecting this process +// id - the id of the next node in the resource tree you want +// moduleBaseAddress - the base address of the module being inspected +// resourceDirectoryRVA - the base address of the beginning of the resource directory for this +// level of the tree +// pNextLevelRVA - out - The RVA for the next level tree directory or the RVA of the resource entry +// +// Returns: +// S_OK if succesful or an appropriate failing HRESULT +HRESULT GetNextLevelResourceEntryRVA(ICorDebugDataTarget* pDataTarget, + DWORD id, + ULONG64 moduleBaseAddress, + DWORD resourceDirectoryRVA, + DWORD* pNextLevelRVA) +{ + *pNextLevelRVA = 0; + HRESULT hr = S_OK; + + // A resource directory which consists of + // a header followed by a number of entries. In the header at offset 12 is + // the number entries identified by name, followed by the number of entries + // identified by ID at offset 14. Both are 2 bytes. + // This method only supports locating entries by ID, not by name + IMAGE_RESOURCE_DIRECTORY resourceDirectory; + hr = ReadFromDataTarget(pDataTarget, moduleBaseAddress + resourceDirectoryRVA, (BYTE*)&resourceDirectory, sizeof(resourceDirectory)); + + + + // The ith resource directory entry is at offset 16 + 8i from the beginning of the resource + // directory table + WORD numNameEntries; + WORD numIDEntries; + if (SUCCEEDED(hr)) + { + numNameEntries = resourceDirectory.NumberOfNamedEntries; + numIDEntries = resourceDirectory.NumberOfIdEntries; + + for (WORD i = numNameEntries; i < numNameEntries + numIDEntries; i++) + { + IMAGE_RESOURCE_DIRECTORY_ENTRY entry; + hr = ReadFromDataTarget(pDataTarget, moduleBaseAddress + resourceDirectoryRVA + sizeof(resourceDirectory) + sizeof(entry)*i, + (BYTE*)&entry, sizeof(entry)); + if (FAILED(hr)) + { + break; + } + if (entry.Id == id) + { + *pNextLevelRVA = entry.OffsetToDirectory; + break; + } + } + } + + // If we didn't find the entry + if (SUCCEEDED(hr) && *pNextLevelRVA == 0) + { + hr = E_FAIL; + } + + return hr; // resource not found +} + +// Traverses down one level in the PE resource tree structure +// +// Arguments: +// pDataTarget - the data target for inspecting this process +// name - the name of the next node in the resource tree you want +// moduleBaseAddress - the base address of the module being inspected +// resourceDirectoryRVA - the base address of the beginning of the resource directory for this +// level of the tree +// resourceSectionRVA - the rva of the beginning of the resource section of the PE file +// pNextLevelRVA - out - The RVA for the next level tree directory or the RVA of the resource entry +// +// Returns: +// S_OK if succesful or an appropriate failing HRESULT +HRESULT GetNextLevelResourceEntryRVAByName(ICorDebugDataTarget* pDataTarget, + LPCWSTR pwzName, + ULONG64 moduleBaseAddress, + DWORD resourceDirectoryRva, + DWORD resourceSectionRva, + DWORD* pNextLevelRva) +{ + HRESULT hr = S_OK; + DWORD nameLength = (DWORD)wcslen(pwzName); + WCHAR entryName[50]; + assert(nameLength < 50); // this implementation won't support matching a name longer + // than 50 characters. We only look up the hard coded name + // of the debug resource in clr.dll though, so it shouldn't be + // an issue. Increase this count if we ever want to look up + // larger names + if (nameLength >= 50) + { + hr = E_FAIL; // invalid name length + } + + // A resource directory which consists of + // a header followed by a number of entries. In the header at offset 12 is + // the number entries identified by name, followed by the number of entries + // identified by ID at offset 14. Both are 2 bytes. + // This method only supports locating entries by ID, not by name + IMAGE_RESOURCE_DIRECTORY resourceDirectory = { 0 }; + if (SUCCEEDED(hr)) + { + hr = ReadFromDataTarget(pDataTarget, moduleBaseAddress + resourceDirectoryRva, (BYTE*)&resourceDirectory, sizeof(resourceDirectory)); + } + + // The ith resource directory entry is at offset 16 + 8i from the beginning of the resource + // directory table + if (SUCCEEDED(hr)) + { + WORD numNameEntries = resourceDirectory.NumberOfNamedEntries; + for (WORD i = 0; i < numNameEntries; i++) + { + IMAGE_RESOURCE_DIRECTORY_ENTRY entry; + hr = ReadFromDataTarget(pDataTarget, moduleBaseAddress + resourceDirectoryRva + sizeof(resourceDirectory) + sizeof(entry)*i, + (BYTE*)&entry, sizeof(entry)); + if (FAILED(hr)) + { + break; + } + + // the NameRVAOrID field points to a UTF16 string with a 2 byte length in front of it + // read the 2 byte length first. The doc of course doesn't mention this, but the RVA is + // relative to the base of the resource section and needs the leading bit stripped. + WORD entryNameLength = 0; + hr = ReadFromDataTarget(pDataTarget, moduleBaseAddress + resourceSectionRva + + entry.NameOffset, (BYTE*)&entryNameLength, sizeof(entryNameLength)); + if (FAILED(hr)) + { + break; + } + if (entryNameLength != nameLength) + { + continue; // names aren't the same length, not a match + } + + // read the rest of the string data and check for a match + hr = ReadFromDataTarget(pDataTarget, moduleBaseAddress + resourceSectionRva + + entry.NameOffset + 2, (BYTE*)entryName, entryNameLength*sizeof(WCHAR)); + if (FAILED(hr)) + { + break; + } + if (memcmp(entryName, pwzName, entryNameLength*sizeof(WCHAR)) == 0) + { + *pNextLevelRva = entry.OffsetToDirectory; + break; + } + } + } + + if (SUCCEEDED(hr) && *pNextLevelRva == 0) + { + hr = E_FAIL; // resource not found + } + + return hr; +} + +// A small wrapper that reads from the data target and throws on error +HRESULT ReadFromDataTarget(ICorDebugDataTarget* pDataTarget, + ULONG64 addr, + BYTE* pBuffer, + ULONG32 bytesToRead) +{ + //PRECONDITION(CheckPointer(pDataTarget)); + //PRECONDITION(CheckPointer(pBuffer)); + + HRESULT hr = S_OK; + ULONG32 bytesReadTotal = 0; + ULONG32 bytesRead = 0; + do + { + if (FAILED(pDataTarget->ReadVirtual((CORDB_ADDRESS)(addr + bytesReadTotal), + pBuffer, + bytesToRead - bytesReadTotal, + &bytesRead))) + { + hr = CORDBG_E_READVIRTUAL_FAILURE; + break; + } + bytesReadTotal += bytesRead; + } while (bytesRead != 0 && (bytesReadTotal < bytesToRead)); + + // If we can't read all the expected memory, then fail + if (SUCCEEDED(hr) && (bytesReadTotal != bytesToRead)) + { + hr = HRESULT_FROM_WIN32(ERROR_PARTIAL_COPY); + } + + return hr; +} diff --git a/src/ToolBox/SOS/Strike/disasm.cpp b/src/SOS/Strike/disasm.cpp similarity index 100% rename from src/ToolBox/SOS/Strike/disasm.cpp rename to src/SOS/Strike/disasm.cpp diff --git a/src/ToolBox/SOS/Strike/disasm.h b/src/SOS/Strike/disasm.h similarity index 100% rename from src/ToolBox/SOS/Strike/disasm.h rename to src/SOS/Strike/disasm.h diff --git a/src/ToolBox/SOS/Strike/disasmARM.cpp b/src/SOS/Strike/disasmARM.cpp similarity index 100% rename from src/ToolBox/SOS/Strike/disasmARM.cpp rename to src/SOS/Strike/disasmARM.cpp diff --git a/src/ToolBox/SOS/Strike/disasmARM64.cpp b/src/SOS/Strike/disasmARM64.cpp similarity index 100% rename from src/ToolBox/SOS/Strike/disasmARM64.cpp rename to src/SOS/Strike/disasmARM64.cpp diff --git a/src/ToolBox/SOS/Strike/disasmX86.cpp b/src/SOS/Strike/disasmX86.cpp similarity index 100% rename from src/ToolBox/SOS/Strike/disasmX86.cpp rename to src/SOS/Strike/disasmX86.cpp diff --git a/src/ToolBox/SOS/Strike/dllsext.cpp b/src/SOS/Strike/dllsext.cpp similarity index 100% rename from src/ToolBox/SOS/Strike/dllsext.cpp rename to src/SOS/Strike/dllsext.cpp diff --git a/src/ToolBox/SOS/Strike/eeheap.cpp b/src/SOS/Strike/eeheap.cpp similarity index 100% rename from src/ToolBox/SOS/Strike/eeheap.cpp rename to src/SOS/Strike/eeheap.cpp diff --git a/src/ToolBox/SOS/Strike/exts.cpp b/src/SOS/Strike/exts.cpp similarity index 100% rename from src/ToolBox/SOS/Strike/exts.cpp rename to src/SOS/Strike/exts.cpp diff --git a/src/ToolBox/SOS/Strike/exts.h b/src/SOS/Strike/exts.h similarity index 94% rename from src/ToolBox/SOS/Strike/exts.h rename to src/SOS/Strike/exts.h index 36b5230c3..0d7ad392d 100644 --- a/src/ToolBox/SOS/Strike/exts.h +++ b/src/SOS/Strike/exts.h @@ -37,11 +37,10 @@ #include "platformspecific.h" -// We need to define the target address type. This has to be used in the -// functions that read directly from the debuggee address space, vs. using +// We need to define the target address type. This has to be used in the +// functions that read directly from the debuggee address space, vs. using // the DAC to read the DAC-ized data structures. #include "daccess.h" - #include "gcinfo.h" // Convert between CLRDATA_ADDRESS and TADDR. @@ -194,26 +193,26 @@ public: inline void EENotLoadedMessage(HRESULT Status) { - ExtOut("Failed to find runtime DLL (%s), 0x%08x\n", MAKEDLLNAME_A("coreclr"), Status); + ExtOut("Failed to find runtime module (%s), 0x%08x\n", MAKEDLLNAME_A("coreclr"), Status); ExtOut("Extension commands need it in order to have something to do.\n"); } inline void DACMessage(HRESULT Status) { - ExtOut("Failed to load data access DLL, 0x%08x\n", Status); + ExtOut("Failed to load data access module, 0x%08x\n", Status); #ifndef FEATURE_PAL ExtOut("Verify that 1) you have a recent build of the debugger (6.2.14 or newer)\n"); - ExtOut(" 2) the file mscordacwks.dll that matches your version of coreclr.dll is \n"); + ExtOut(" 2) the file mscordaccore.dll that matches your version of coreclr.dll is\n"); ExtOut(" in the version directory or on the symbol path\n"); ExtOut(" 3) or, if you are debugging a dump file, verify that the file \n"); - ExtOut(" mscordacwks___.dll is on your symbol path.\n"); + ExtOut(" mscordaccore___.dll is on your symbol path.\n"); ExtOut(" 4) you are debugging on supported cross platform architecture as \n"); ExtOut(" the dump file. For example, an ARM dump file must be debugged\n"); ExtOut(" on an X86 or an ARM machine; an AMD64 dump file must be\n"); ExtOut(" debugged on an AMD64 machine.\n"); ExtOut("\n"); ExtOut("You can also run the debugger command .cordll to control the debugger's\n"); - ExtOut("load of mscordacwks.dll. .cordll -ve -u -l will do a verbose reload.\n"); + ExtOut("load of mscordaccore.dll. .cordll -ve -u -l will do a verbose reload.\n"); ExtOut("If that succeeds, the SOS command should work on retry.\n"); ExtOut("\n"); ExtOut("If you are debugging a minidump, you need to make sure that your executable\n"); @@ -233,16 +232,21 @@ inline void DACMessage(HRESULT Status) HRESULT CheckEEDll(); -#define INIT_API_NOEE() \ +// The minimum initialization for a command +#define INIT_API_EXT() \ HRESULT Status; \ __ExtensionCleanUp __extensionCleanUp; \ if ((Status = ExtQuery(client)) != S_OK) return Status; \ - if ((Status = ArchQuery()) != S_OK) return Status; \ ControlC = FALSE; \ g_bDacBroken = TRUE; \ g_clrData = NULL; \ g_sos = NULL; +// Also initializes the target machine +#define INIT_API_NOEE() \ + INIT_API_EXT() \ + if ((Status = ArchQuery()) != S_OK) return Status; + #define INIT_API_EE() \ if ((Status = CheckEEDll()) != S_OK) \ { \ @@ -281,12 +285,12 @@ HRESULT CheckEEDll(); INIT_API_NOEE() \ if ((Status = CheckEEDll()) != S_OK) \ { \ - ExtOut("Failed to find runtime DLL (%s), 0x%08x\n", MAKEDLLNAME_A("coreclr"), Status); \ + ExtOut("Failed to find runtime module (%s), 0x%08x\n", MAKEDLLNAME_A("coreclr"), Status); \ ExtOut("Some functionality may be impaired\n"); \ } \ else if ((Status = LoadClrDebugDll()) != S_OK) \ { \ - ExtOut("Failed to load data access DLL (%s), 0x%08x\n", MAKEDLLNAME_A("mscordaccore"), Status); \ + ExtOut("Failed to load data access module (%s), 0x%08x\n", MAKEDLLNAME_A("mscordaccore"), Status); \ ExtOut("Some functionality may be impaired\n"); \ } \ else \ diff --git a/src/ToolBox/SOS/Strike/gchist.cpp b/src/SOS/Strike/gchist.cpp similarity index 99% rename from src/ToolBox/SOS/Strike/gchist.cpp rename to src/SOS/Strike/gchist.cpp index ee9d5b403..e2ca1a924 100644 --- a/src/ToolBox/SOS/Strike/gchist.cpp +++ b/src/SOS/Strike/gchist.cpp @@ -38,8 +38,6 @@ // functions that read directly from the debuggee address space, vs. using // the DAC tgo read the DAC-ized data structures. #include "daccess.h" -//#include "dbgeng.h" - #ifndef STRESS_LOG #define STRESS_LOG diff --git a/src/ToolBox/SOS/Strike/gcroot.cpp b/src/SOS/Strike/gcroot.cpp similarity index 100% rename from src/ToolBox/SOS/Strike/gcroot.cpp rename to src/SOS/Strike/gcroot.cpp diff --git a/src/ToolBox/SOS/Strike/inc/dbgeng.h b/src/SOS/Strike/inc/dbgeng.h similarity index 100% rename from src/ToolBox/SOS/Strike/inc/dbgeng.h rename to src/SOS/Strike/inc/dbgeng.h diff --git a/src/ToolBox/SOS/Strike/inc/dbghelp.h b/src/SOS/Strike/inc/dbghelp.h similarity index 100% rename from src/ToolBox/SOS/Strike/inc/dbghelp.h rename to src/SOS/Strike/inc/dbghelp.h diff --git a/src/ToolBox/SOS/Strike/inc/wdbgexts.h b/src/SOS/Strike/inc/wdbgexts.h similarity index 100% rename from src/ToolBox/SOS/Strike/inc/wdbgexts.h rename to src/SOS/Strike/inc/wdbgexts.h diff --git a/src/ToolBox/SOS/Strike/metadata.cpp b/src/SOS/Strike/metadata.cpp similarity index 99% rename from src/ToolBox/SOS/Strike/metadata.cpp rename to src/SOS/Strike/metadata.cpp index 073b979ba..09ed380ab 100644 --- a/src/ToolBox/SOS/Strike/metadata.cpp +++ b/src/SOS/Strike/metadata.cpp @@ -9,7 +9,7 @@ // ==--== #include "strike.h" #include "util.h" -#include "genericstackprobe.h" +//#include "genericstackprobe.h" /**********************************************************************\ * Routine Description: * diff --git a/src/ToolBox/SOS/Strike/ntinfo.h b/src/SOS/Strike/ntinfo.h similarity index 100% rename from src/ToolBox/SOS/Strike/ntinfo.h rename to src/SOS/Strike/ntinfo.h diff --git a/src/ToolBox/SOS/Strike/platformspecific.h b/src/SOS/Strike/platformspecific.h similarity index 99% rename from src/ToolBox/SOS/Strike/platformspecific.h rename to src/SOS/Strike/platformspecific.h index ee416dbcc..6f2dc6257 100644 --- a/src/ToolBox/SOS/Strike/platformspecific.h +++ b/src/SOS/Strike/platformspecific.h @@ -14,7 +14,7 @@ #define __PLATFORM_SPECIFIC_INCLUDED // The main debugger code already has target platform definitions for CONTEXT. -#include "../../../debug/inc/dbgtargetcontext.h" +#include #ifndef FEATURE_PAL diff --git a/src/ToolBox/SOS/Strike/sildasm.cpp b/src/SOS/Strike/sildasm.cpp similarity index 99% rename from src/ToolBox/SOS/Strike/sildasm.cpp rename to src/SOS/Strike/sildasm.cpp index 911ff091e..aa6b8762e 100644 --- a/src/ToolBox/SOS/Strike/sildasm.cpp +++ b/src/SOS/Strike/sildasm.cpp @@ -31,6 +31,7 @@ #include "sos_md.h" +#define _BLD_CLR 1 #define SOS_INCLUDE 1 #include "corhlpr.h" #include "corhlpr.cpp" diff --git a/src/ToolBox/SOS/Strike/sos.cpp b/src/SOS/Strike/sos.cpp similarity index 100% rename from src/ToolBox/SOS/Strike/sos.cpp rename to src/SOS/Strike/sos.cpp diff --git a/src/ToolBox/SOS/Strike/sos.def b/src/SOS/Strike/sos.def similarity index 98% rename from src/ToolBox/SOS/Strike/sos.def rename to src/SOS/Strike/sos.def index c8d08e731..e506babe3 100644 --- a/src/ToolBox/SOS/Strike/sos.def +++ b/src/SOS/Strike/sos.def @@ -91,6 +91,7 @@ EXPORTS GcWhere=GCWhere Help help=Help + soshelp=Help HistClear histclear=HistClear HistInit @@ -119,6 +120,8 @@ EXPORTS Printexception=PrintException SaveModule savemodule=SaveModule + SetHostRuntime + sethostruntime=SetHostRuntime SOSFlush sosflush=SOSFlush StopOnException diff --git a/src/ToolBox/SOS/Strike/sos.h b/src/SOS/Strike/sos.h similarity index 100% rename from src/ToolBox/SOS/Strike/sos.h rename to src/SOS/Strike/sos.h diff --git a/src/ToolBox/SOS/Strike/sos_md.h b/src/SOS/Strike/sos_md.h similarity index 100% rename from src/ToolBox/SOS/Strike/sos_md.h rename to src/SOS/Strike/sos_md.h diff --git a/src/ToolBox/SOS/Strike/sos_stacktrace.h b/src/SOS/Strike/sos_stacktrace.h similarity index 100% rename from src/ToolBox/SOS/Strike/sos_stacktrace.h rename to src/SOS/Strike/sos_stacktrace.h diff --git a/src/ToolBox/SOS/Strike/sos_unixexports.src b/src/SOS/Strike/sos_unixexports.src similarity index 98% rename from src/ToolBox/SOS/Strike/sos_unixexports.src rename to src/SOS/Strike/sos_unixexports.src index a8cc71228..efa270238 100644 --- a/src/ToolBox/SOS/Strike/sos_unixexports.src +++ b/src/SOS/Strike/sos_unixexports.src @@ -41,6 +41,7 @@ IP2MD Name2EE PrintException StopOnCatch +SetHostRuntime Threads ThreadState Token2EE diff --git a/src/ToolBox/SOS/Strike/sosdocs.txt b/src/SOS/Strike/sosdocs.txt similarity index 98% rename from src/ToolBox/SOS/Strike/sosdocs.txt rename to src/SOS/Strike/sosdocs.txt index 924d5f51b..e9cc28030 100644 --- a/src/ToolBox/SOS/Strike/sosdocs.txt +++ b/src/SOS/Strike/sosdocs.txt @@ -59,9 +59,9 @@ DumpCCW Examining the GC history Other ----------------------------- ----------------------------- -HistInit FAQ -HistRoot -HistObj +HistInit SetHostRuntime (sethostruntime) +HistRoot FAQ +HistObj soshelp HistObjFind HistClear \\ @@ -2132,20 +2132,19 @@ default one. ................. SUCCESS: Stress log dumped -To turn on the stress log, set the following registry keys under -HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework: +To turn on the stress log, set the following environment variables before +starting the .NET Core app: - -(DWORD) StressLog = 1 -(DWORD) LogFacility = 0xffffffbf (this is a bit mask, almost all logging is on. - This is also the default value if the key - isn't specified) -(DWORD) StressLogSize = 65536 (this is the default value if the key isn't - specified) -(DWORD) LogLevel = 6 (this is the default value if the key isn't - specified. The higher the number the more - detailed logs are generated. The maximum - value is decimal 10) +set COMPlus_StressLog = 1 +set COMPlus_LogFacility = 0xffffffbf (this is a bit mask, almost all logging is on. + This is also the default value if the key + isn't specified) +set COMPlus_StressLogSize = 65536 (this is the default value if the key isn't + specified) +set COMPlus_LogLevel = 6 (this is the default value if the key isn't + specified. The higher the number the more + detailed logs are generated. The maximum + value is decimal 10) StressLogSize is the size in bytes of the in-memory log allocated for each thread in the process. In the case above, each thread gets a 64K log. You @@ -2567,4 +2566,15 @@ The output contains the COM reference count of the CCW, which is useful for investigating lifetime issues of interop-heavy applications. \\ +COMMAND: sethostruntime. +!SetHostRuntime +This command sets the path to the .NET Core runtime to use to host the managed +code that runs as part of SOS in the debugger (cdb/windbg). The runtime needs +to be at least version 2.0.0 or greater. If there are spaces in directory, it +needs to be single-quoted ('). + +The default is to use the same runtime (coreclr.dll) being debugged. Use this +command when the runtime being debugged isn't working to run the SOS code or +if the version is less than 2.0.0. +\\ diff --git a/src/ToolBox/SOS/Strike/sosdocsunix.txt b/src/SOS/Strike/sosdocsunix.txt similarity index 97% rename from src/ToolBox/SOS/Strike/sosdocsunix.txt rename to src/SOS/Strike/sosdocsunix.txt index d0f19e323..2142aae9d 100644 --- a/src/ToolBox/SOS/Strike/sosdocsunix.txt +++ b/src/SOS/Strike/sosdocsunix.txt @@ -36,7 +36,7 @@ PrintException (pe) ClrStack (clrstack) Examining CLR data structures Diagnostic Utilities ----------------------------- ----------------------------- -DumpDomain VerifyHeap +DumpDomain (dumpdomain) VerifyHeap EEHeap (eeheap) FindAppDomain Name2EE (name2ee) DumpLog (dumplog) DumpMT (dumpmt) @@ -52,8 +52,8 @@ DumpSigElem Examining the GC history Other ----------------------------- ----------------------------- -HistInit (histinit) FAQ -HistRoot (histroot) CreateDump (createdump) +HistInit (histinit) SetHostRuntime (sethostruntime) +HistRoot (histroot) FAQ HistObj (histobj) Help (soshelp) HistObjFind (histobjfind) HistClear (histclear) @@ -619,15 +619,7 @@ hyperlinks to inspect the different managed stack frames and managed variables. \\ COMMAND: createdump. -createdump [options] [dumpFileName] --n - create minidump. --h - create minidump with heap (default). --t - create triage minidump. --f - create full core dump (everything). --d - enable diagnostic messages. - -Creates a platform (ELF core on Linux, etc.) minidump. The pid can be placed in the dump -file name with %d. The default is '/tmp/coredump.%d'. +Currently not implemented. \\ COMMAND: ip2md. @@ -1493,20 +1485,19 @@ default one. ................. SUCCESS: Stress log dumped -To turn on the stress log, set the following registry keys under -HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework: +To turn on the stress log, set the following environment variables before +starting the .NET Core app: - -(DWORD) StressLog = 1 -(DWORD) LogFacility = 0xffffffbf (this is a bit mask, almost all logging is on. - This is also the default value if the key - isn't specified) -(DWORD) StressLogSize = 65536 (this is the default value if the key isn't - specified) -(DWORD) LogLevel = 6 (this is the default value if the key isn't - specified. The higher the number the more - detailed logs are generated. The maximum - value is decimal 10) +export COMPlus_StressLog = 1 +export COMPlus_LogFacility = 0xffffffbf (this is a bit mask, almost all logging is on. + This is also the default value if the key + isn't specified) +export COMPlus_StressLogSize = 65536 (this is the default value if the key isn't + specified) +export COMPlus_LogLevel = 6 (this is the default value if the key isn't + specified. The higher the number the more + detailed logs are generated. The maximum + value is decimal 10) StressLogSize is the size in bytes of the in-memory log allocated for each thread in the process. In the case above, each thread gets a 64K log. You @@ -1722,3 +1713,16 @@ cleanup the previous resources. Completed successfully. \\ + +COMMAND: sethostruntime. +!SetHostRuntime + +This command sets the path to the .NET Core runtime to use to host the managed +code that runs as part of SOS in the debugger (lldb). The runtime needs +to be at least version 2.0.0 or greater. If there are spaces in directory, it +needs to be single-quoted ('). + +The default is to use the same runtime (libcoreclr) being debugged. Use this +command when the runtime being debugged isn't working to run the SOS code or +if the version is less than 2.0.0. +\\ diff --git a/src/ToolBox/SOS/Strike/stressLogDump.cpp b/src/SOS/Strike/stressLogDump.cpp similarity index 100% rename from src/ToolBox/SOS/Strike/stressLogDump.cpp rename to src/SOS/Strike/stressLogDump.cpp diff --git a/src/ToolBox/SOS/Strike/strike.cpp b/src/SOS/Strike/strike.cpp similarity index 99% rename from src/ToolBox/SOS/Strike/strike.cpp rename to src/SOS/Strike/strike.cpp index aaaf39aa4..182dfc607 100644 --- a/src/ToolBox/SOS/Strike/strike.cpp +++ b/src/SOS/Strike/strike.cpp @@ -113,7 +113,9 @@ #include "predeftlsslot.h" +#ifndef FEATURE_PAL #include "hillclimbing.h" +#endif #include "sos_md.h" @@ -436,10 +438,6 @@ void DumpStackInternal(DumpStackFlag *pDSFlag) DumpStackWorker(*pDSFlag); } -#if defined(FEATURE_PAL) && defined(_TARGET_AMD64_) -static BOOL UnwindStackFrames(ULONG32 osThreadId); -#endif - DECLARE_API(DumpStack) { INIT_API_NO_RET_ON_FAILURE(); @@ -488,16 +486,8 @@ DECLARE_API(DumpStack) g_ExtSystem->GetCurrentThreadId(&id); ExtOut("(%d)\n", id); -#if defined(FEATURE_PAL) && defined(_TARGET_AMD64_) - if (unwind) - { - UnwindStackFrames(sysId); - } - else -#endif - { - DumpStackInternal(&DSFlag); - } + DumpStackInternal(&DSFlag); + return Status; } @@ -1411,8 +1401,8 @@ DECLARE_API(DumpMT) if (MethodDescData.Request(g_sos, TO_CDADDR(methodDesc)) == S_OK) { // Is it an fcall? - if ((TO_TADDR(MethodDescData.NativeCodeAddr) >= TO_TADDR(moduleInfo[MSCORWKS].baseAddr)) && - ((TO_TADDR(MethodDescData.NativeCodeAddr) < TO_TADDR(moduleInfo[MSCORWKS].baseAddr + moduleInfo[MSCORWKS].size)))) + if ((TO_TADDR(MethodDescData.NativeCodeAddr) >= TO_TADDR(g_moduleInfo[MSCORWKS].baseAddr)) && + ((TO_TADDR(MethodDescData.NativeCodeAddr) < TO_TADDR(g_moduleInfo[MSCORWKS].baseAddr + g_moduleInfo[MSCORWKS].size)))) { pszJitType = "FCALL"; } @@ -7084,7 +7074,6 @@ DECLARE_API(bpmd) return Status; } - // We keep a list of managed breakpoints the user wants to set, and display pending bps // bpmd. If you call bpmd we will set or update an existing bp. // bpmd acts as a feeder of breakpoints to bp when the time is right. @@ -9007,7 +8996,7 @@ DECLARE_API (EEVersion) } else { - BOOL fRet = IsRetailBuild ((size_t)moduleInfo[eef].baseAddr); + BOOL fRet = IsRetailBuild ((size_t)g_moduleInfo[eef].baseAddr); if (fRet) ExtOut(" retail"); @@ -14516,6 +14505,43 @@ DECLARE_API(CreateDump) #endif // FEATURE_PAL +extern LPCSTR g_hostRuntimeDirectory; + +// +// Sets the .NET Core runtime path to use to run the managed code within SOS/native debugger. +// +DECLARE_API(SetHostRuntime) +{ + INIT_API_EXT(); + + StringHolder hostRuntimeDirectory; + CMDValue arg[] = + { + {&hostRuntimeDirectory.data, COSTRING}, + }; + size_t narg; + if (!GetCMDOption(args, nullptr, 0, arg, _countof(arg), &narg)) + { + return E_FAIL; + } + if (narg > 0) + { + if (g_hostRuntimeDirectory != nullptr) + { + free((void*)g_hostRuntimeDirectory); + } + g_hostRuntimeDirectory = _strdup(hostRuntimeDirectory.data); + } + else + { + if (g_hostRuntimeDirectory != nullptr) + { + ExtOut("%s\n", g_hostRuntimeDirectory); + } + } + return S_OK; +} + void PrintHelp (__in_z LPCSTR pszCmdName) { static LPSTR pText = NULL; @@ -14528,30 +14554,38 @@ void PrintHelp (__in_z LPCSTR pszCmdName) if (hResource) pText = (LPSTR) LockResource (hResource); if (pText == NULL) { - ExtOut("Error loading documentation resource\n"); + ExtErr("Error loading documentation resource\n"); return; } #else int err = PAL_InitializeDLL(); if(err != 0) { - ExtOut("Error initializing PAL\n"); + ExtErr("Error initializing PAL\n"); return; } + + ArrayHolder szSOSModulePath = new char[MAX_LONGPATH + 1]; + UINT cch = MAX_LONGPATH; + if (!PAL_GetPALDirectoryA(szSOSModulePath, &cch)) { + ExtErr("Error: Failed to get SOS module directory\n"); + return; + } + char lpFilename[MAX_LONGPATH + 12]; // + 12 to make enough room for strcat function. - strcpy_s(lpFilename, _countof(lpFilename), g_ExtServices->GetCoreClrDirectory()); + strcpy_s(lpFilename, _countof(lpFilename), szSOSModulePath); strcat_s(lpFilename, _countof(lpFilename), "sosdocsunix.txt"); HANDLE hSosDocFile = CreateFileA(lpFilename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); if (hSosDocFile == INVALID_HANDLE_VALUE) { - ExtOut("Error finding documentation file\n"); + ExtErr("Error finding documentation file\n"); return; } HANDLE hMappedSosDocFile = CreateFileMappingA(hSosDocFile, NULL, PAGE_READONLY, 0, 0, NULL); CloseHandle(hSosDocFile); if (hMappedSosDocFile == NULL) { - ExtOut("Error mapping documentation file\n"); + ExtErr("Error mapping documentation file\n"); return; } @@ -14559,7 +14593,7 @@ void PrintHelp (__in_z LPCSTR pszCmdName) CloseHandle(hMappedSosDocFile); if (pText == NULL) { - ExtOut("Error loading documentation file\n"); + ExtErr("Error loading documentation file\n"); return; } #endif @@ -14573,7 +14607,7 @@ void PrintHelp (__in_z LPCSTR pszCmdName) LPSTR pEnd = NULL; if (!pStart) { - ExtOut("Documentation for %s not found.\n", pszCmdName); + ExtErr("Documentation for %s not found.\n", pszCmdName); return; } @@ -14581,7 +14615,7 @@ void PrintHelp (__in_z LPCSTR pszCmdName) pStart = strchr(pStart, '\n'); if (!pStart) { - ExtOut("Expected newline in documentation resource.\n"); + ExtErr("Expected newline in documentation resource.\n"); return; } @@ -14619,11 +14653,7 @@ void PrintHelp (__in_z LPCSTR pszCmdName) \**********************************************************************/ DECLARE_API(Help) { - // Call extension initialization functions directly, because we don't need the DAC dll to be initialized to get help. - HRESULT Status; - __ExtensionCleanUp __extensionCleanUp; - if ((Status = ExtQuery(client)) != S_OK) return Status; - ControlC = FALSE; + INIT_API_EXT(); StringHolder commandName; CMDValue arg[] = @@ -14665,86 +14695,3 @@ DECLARE_API(Help) return S_OK; } - -#if defined(FEATURE_PAL) && defined(_TARGET_AMD64_) - -static BOOL -ReadMemoryAdapter(PVOID address, PVOID buffer, SIZE_T size) -{ - ULONG fetched; - HRESULT hr = g_ExtData->ReadVirtual(TO_CDADDR(address), buffer, size, &fetched); - return SUCCEEDED(hr); -} - -static BOOL -GetStackFrame(CONTEXT* context, ULONG numNativeFrames) -{ - KNONVOLATILE_CONTEXT_POINTERS contextPointers; - memset(&contextPointers, 0, sizeof(contextPointers)); - - ULONG64 baseAddress; - HRESULT hr = g_ExtSymbols->GetModuleByOffset(context->Rip, 0, NULL, &baseAddress); - if (FAILED(hr)) - { - PDEBUG_STACK_FRAME frame = &g_Frames[0]; - for (int i = 0; i < numNativeFrames; i++, frame++) { - if (frame->InstructionOffset == context->Rip) - { - if ((i + 1) >= numNativeFrames) { - return FALSE; - } - memcpy(context, &(g_FrameContexts[i + 1]), sizeof(*context)); - return TRUE; - } - } - return FALSE; - } - if (!PAL_VirtualUnwindOutOfProc(context, &contextPointers, baseAddress, ReadMemoryAdapter)) - { - return FALSE; - } - return TRUE; -} - -static BOOL -UnwindStackFrames(ULONG32 osThreadId) -{ - ULONG numNativeFrames = 0; - HRESULT hr = GetContextStackTrace(osThreadId, &numNativeFrames); - if (FAILED(hr)) - { - return FALSE; - } - CONTEXT context; - memset(&context, 0, sizeof(context)); - context.ContextFlags = CONTEXT_FULL; - - hr = g_ExtSystem->GetThreadContextById(osThreadId, CONTEXT_FULL, sizeof(context), (PBYTE)&context); - if (FAILED(hr)) - { - return FALSE; - } - TableOutput out(3, POINTERSIZE_HEX, AlignRight); - out.WriteRow("RSP", "RIP", "Call Site"); - - DEBUG_STACK_FRAME nativeFrame; - memset(&nativeFrame, 0, sizeof(nativeFrame)); - - do - { - if (context.Rip == 0) - { - break; - } - nativeFrame.InstructionOffset = context.Rip; - nativeFrame.ReturnOffset = context.Rip; - nativeFrame.FrameOffset = context.Rbp; - nativeFrame.StackOffset = context.Rsp; - ClrStackImpl::PrintNativeStackFrame(out, &nativeFrame, FALSE); - - } while (GetStackFrame(&context, numNativeFrames)); - - return TRUE; -} - -#endif // FEATURE_PAL && _TARGET_AMD64_ diff --git a/src/ToolBox/SOS/Strike/strike.h b/src/SOS/Strike/strike.h similarity index 100% rename from src/ToolBox/SOS/Strike/strike.h rename to src/SOS/Strike/strike.h diff --git a/src/ToolBox/SOS/Strike/util.cpp b/src/SOS/Strike/util.cpp similarity index 93% rename from src/ToolBox/SOS/Strike/util.cpp rename to src/SOS/Strike/util.cpp index 74cbc4cf0..416127ec1 100644 --- a/src/ToolBox/SOS/Strike/util.cpp +++ b/src/SOS/Strike/util.cpp @@ -44,13 +44,18 @@ char symBuffer[SYM_BUFFER_SIZE]; PIMAGEHLP_SYMBOL sym = (PIMAGEHLP_SYMBOL) symBuffer; #else #include -#include #include #endif // !FEATURE_PAL #include #include +#include +#if defined(__APPLE__) +#include +#endif + +LPCSTR g_hostRuntimeDirectory = nullptr; LoadSymbolsForModuleDelegate SymbolReader::loadSymbolsForModuleDelegate; DisposeDelegate SymbolReader::disposeDelegate; ResolveSequencePointDelegate SymbolReader::resolveSequencePointDelegate; @@ -668,7 +673,7 @@ HRESULT CreateInstanceCustom( * windbg. * * * \**********************************************************************/ -DWORD_PTR GetValueFromExpression (___in __in_z const char *const instr) +DWORD_PTR GetValueFromExpression(___in __in_z const char *const instr) { ULONG64 dwAddr; const char *str = instr; @@ -724,7 +729,7 @@ DWORD_PTR GetValueFromExpression (___in __in_z const char *const instr) #endif // FEATURE_PAL -ModuleInfo moduleInfo[MSCOREND] = {{0,FALSE,0},{0,FALSE,0},{0,FALSE,0}}; +ModuleInfo g_moduleInfo[MSCOREND] = {{0, FALSE, 0}, {0, FALSE, 0}, {0, FALSE, 0}}; void ReportOOM() { @@ -734,75 +739,41 @@ void ReportOOM() HRESULT CheckEEDll() { #ifndef FEATURE_PAL - VS_FIXEDFILEINFO ee = {}; - - static VS_FIXEDFILEINFO sos = {}; - static BOOL sosDataInit = FALSE; - - BOOL result = GetEEVersion(&ee); - if (result && !sosDataInit) + // Do we have coreclr.dll + if (g_moduleInfo[MSCORWKS].baseAddr == 0) { - result = GetSOSVersion(&sos); - - if (result) - sosDataInit = TRUE; - } + DEBUG_MODULE_PARAMETERS Params; - // We will ignore errors because it's possible sos is being loaded before CLR. - if (result) - { - if ((ee.dwFileVersionMS != sos.dwFileVersionMS) || (ee.dwFileVersionLS != sos.dwFileVersionLS)) + g_ExtSymbols->GetModuleByModuleName(MAIN_CLR_MODULE_NAME_A, 0, NULL, &g_moduleInfo[MSCORWKS].baseAddr); + if (g_moduleInfo[MSCORWKS].baseAddr != 0 && g_moduleInfo[MSCORWKS].hasPdb == FALSE) { - ExtOut("The version of SOS does not match the version of CLR you are debugging. Please\n"); - ExtOut("load the matching version of SOS for the version of CLR you are debugging.\n"); - ExtOut("CLR Version: %u.%u.%u.%u\n", - HIWORD(ee.dwFileVersionMS), - LOWORD(ee.dwFileVersionMS), - HIWORD(ee.dwFileVersionLS), - LOWORD(ee.dwFileVersionLS)); - - ExtOut("SOS Version: %u.%u.%u.%u\n", - HIWORD(sos.dwFileVersionMS), - LOWORD(sos.dwFileVersionMS), - HIWORD(sos.dwFileVersionLS), - LOWORD(sos.dwFileVersionLS)); - } - } - - DEBUG_MODULE_PARAMETERS Params; - - // Do we have clr.dll - if (moduleInfo[MSCORWKS].baseAddr == 0) - { - g_ExtSymbols->GetModuleByModuleName (MAIN_CLR_MODULE_NAME_A,0,NULL, - &moduleInfo[MSCORWKS].baseAddr); - if (moduleInfo[MSCORWKS].baseAddr != 0 && moduleInfo[MSCORWKS].hasPdb == FALSE) - { - g_ExtSymbols->GetModuleParameters (1, &moduleInfo[MSCORWKS].baseAddr, 0, &Params); + g_ExtSymbols->GetModuleParameters(1, &g_moduleInfo[MSCORWKS].baseAddr, 0, &Params); if (Params.SymbolType == SymDeferred) { g_ExtSymbols->Reload("/f " MAIN_CLR_DLL_NAME_A); - g_ExtSymbols->GetModuleParameters (1, &moduleInfo[MSCORWKS].baseAddr, 0, &Params); + g_ExtSymbols->GetModuleParameters(1, &g_moduleInfo[MSCORWKS].baseAddr, 0, &Params); } if (Params.SymbolType == SymPdb || Params.SymbolType == SymDia) { - moduleInfo[MSCORWKS].hasPdb = TRUE; + g_moduleInfo[MSCORWKS].hasPdb = TRUE; } - moduleInfo[MSCORWKS].size = Params.Size; + g_moduleInfo[MSCORWKS].size = Params.Size; + } + if (g_moduleInfo[MSCORWKS].baseAddr != 0 && g_moduleInfo[MSCORWKS].hasPdb == FALSE) + { + ExtOut("PDB symbol for coreclr.dll not loaded\n"); } - if (moduleInfo[MSCORWKS].baseAddr != 0 && moduleInfo[MSCORWKS].hasPdb == FALSE) - ExtOut("PDB symbol for clr.dll not loaded\n"); } - return (moduleInfo[MSCORWKS].baseAddr != 0) ? S_OK : E_FAIL; + return (g_moduleInfo[MSCORWKS].baseAddr != 0) ? S_OK : E_FAIL; #else return S_OK; #endif // FEATURE_PAL } -EEFLAVOR GetEEFlavor () +EEFLAVOR GetEEFlavor() { #ifdef FEATURE_PAL return MSCORWKS; @@ -816,7 +787,7 @@ EEFLAVOR GetEEFlavor () #endif // FEATURE_PAL else } -BOOL IsDumpFile () +BOOL IsDumpFile() { static int g_fDumpFile = -1; if (g_fDumpFile == -1) { @@ -1006,7 +977,7 @@ void IP2MethodDesc (DWORD_PTR IP, DWORD_PTR &methodDesc, JITTypes &jitType, gcinfoAddr = NULL; if (codeHeaderData.Request(g_sos, EIP) != S_OK) - { + { return; } @@ -1029,7 +1000,7 @@ void DisplayDataMember (DacpFieldDescData* pFD, DWORD_PTR dwAddr, BOOL fAlign=TR DWORD_PTR dwTmp = dwAddr; bool bVTStatic = (pFD->bIsStatic && pFD->Type == ELEMENT_TYPE_VALUETYPE); - + if (gElementTypeInfo[pFD->Type] != NO_SIZE || bVTStatic) { union Value @@ -1180,12 +1151,12 @@ void GetStaticFieldPTR(DWORD_PTR* pOutPtr, DacpDomainLocalModuleData* pDLMD, Dac if (pFlags && pMTD->bIsShared) { BYTE flags; - DWORD_PTR pTargetFlags = (DWORD_PTR) pDLMD->pClassData + RidFromToken(pMTD->cl) - 1; + DWORD_PTR pTargetFlags = (DWORD_PTR) pDLMD->pClassData + RidFromToken(pMTD->cl) - 1; move_xp (flags, pTargetFlags); *pFlags = flags; } - + *pOutPtr = dwTmp; } @@ -1239,12 +1210,12 @@ void GetThreadStaticFieldPTR(DWORD_PTR* pOutPtr, DacpThreadLocalModuleData* pTLM if (pFlags) { BYTE flags; - DWORD_PTR pTargetFlags = (DWORD_PTR) pTLMD->pClassData + RidFromToken(pMTD->cl) - 1; + DWORD_PTR pTargetFlags = (DWORD_PTR) pTLMD->pClassData + RidFromToken(pMTD->cl) - 1; move_xp (flags, pTargetFlags); *pFlags = flags; } - + *pOutPtr = dwTmp; } return; @@ -2749,7 +2720,7 @@ DWORD_PTR *ModuleFromName(__in_opt LPSTR mName, int *numModule) // >sxe ld:clr // >g // ... - // ModLoad: clr.dll + // ModLoad: coreclr.dll // >!bpmd Foo.dll Foo.Bar // we will correctly give the answer that whatever module you were looking for, it isn't loaded yet @@ -3661,20 +3632,21 @@ BOOL GetEEVersion(VS_FIXEDFILEINFO *pFileInfo) { _ASSERTE(g_ExtSymbols2); _ASSERTE(pFileInfo); + // Grab the version info directly from the module. - return g_ExtSymbols2->GetModuleVersionInformation(DEBUG_ANY_ID, - moduleInfo[GetEEFlavor()].baseAddr, - "\\", pFileInfo, sizeof(VS_FIXEDFILEINFO), NULL) == S_OK; + return g_ExtSymbols2->GetModuleVersionInformation( + DEBUG_ANY_ID, g_moduleInfo[GetEEFlavor()].baseAddr, "\\", pFileInfo, sizeof(VS_FIXEDFILEINFO), NULL) == S_OK; } extern HMODULE g_hInstance; + BOOL GetSOSVersion(VS_FIXEDFILEINFO *pFileInfo) { _ASSERTE(pFileInfo); - + WCHAR wszFullPath[MAX_LONGPATH]; DWORD cchFullPath = GetModuleFileNameW(g_hInstance, wszFullPath, _countof(wszFullPath)); - + DWORD dwHandle = 0; DWORD infoSize = GetFileVersionInfoSizeW(wszFullPath, &dwHandle); if (infoSize) @@ -3694,12 +3666,12 @@ BOOL GetSOSVersion(VS_FIXEDFILEINFO *pFileInfo) } } } - + return FALSE; } #endif // !FEATURE_PAL - + size_t ObjectSize(DWORD_PTR obj,BOOL fIsLargeObject) { DWORD_PTR dwMT; @@ -4226,9 +4198,14 @@ HRESULT LoadClrDebugDll(void) { return CORDBG_E_UNSUPPORTED; } - char dacModulePath[MAX_LONGPATH]; - strcpy_s(dacModulePath, _countof(dacModulePath), g_ExtServices->GetCoreClrDirectory()); - strcat_s(dacModulePath, _countof(dacModulePath), MAKEDLLNAME_A("mscordaccore")); + LPCSTR coreclrDirectory = g_ExtServices->GetCoreClrDirectory(); + if (coreclrDirectory == NULL) + { + return E_FAIL; + } + ArrayHolder dacModulePath = new char[MAX_LONGPATH + 1]; + strcpy_s(dacModulePath, MAX_LONGPATH, coreclrDirectory); + strcat_s(dacModulePath, MAX_LONGPATH, MAKEDLLNAME_A("mscordaccore")); HMODULE hdac = LoadLibraryA(dacModulePath); if (hdac == NULL) @@ -4303,20 +4280,20 @@ FindFileInPathCallback( ___in PVOID context ) { - HRESULT hr; - FindFileCallbackData* pCallbackData; - pCallbackData = (FindFileCallbackData*)context; - if (!pCallbackData) + FindFileCallbackData* pCallbackData = (FindFileCallbackData*)context; + if (pCallbackData == NULL) + { return TRUE; + } pCallbackData->hModule = LoadLibraryExW( filename, NULL, // __reserved LOAD_WITH_ALTERED_SEARCH_PATH); // Ensure we check the dir in wszFullPath first + if (pCallbackData->hModule == NULL) { - hr = HRESULT_FROM_WIN32(GetLastError()); - ExtOut("Unable to load '%S'. HRESULT = 0x%x.\n", filename, hr); + ExtOut("Unable to load '%S'. hr = 0x%x.\n", filename, HRESULT_FROM_WIN32(GetLastError())); return TRUE; } @@ -4328,8 +4305,9 @@ FindFileInPathCallback( &modInfo, sizeof(modInfo))) { - ExtOut("Failed to read module information for '%S'. HRESULT = 0x%x.\n", filename, HRESULT_FROM_WIN32(GetLastError())); + ExtOut("Failed to read module information for '%S'. hr = 0x%x.\n", filename, HRESULT_FROM_WIN32(GetLastError())); FreeLibrary(pCallbackData->hModule); + pCallbackData->hModule = NULL; return TRUE; } @@ -4343,6 +4321,7 @@ FindFileInPathCallback( ExtOut("Size: Expected '0x%x', Actual '0x%x'\n", pCallbackData->filesize, dwSizeActual); ExtOut("Time stamp: Expected '0x%x', Actual '0x%x'\n", pCallbackData->timestamp, dwTimeStampActual); FreeLibrary(pCallbackData->hModule); + pCallbackData->hModule = NULL; return TRUE; } @@ -4355,7 +4334,7 @@ FindFileInPathCallback( //--------------------------------------------------------------------------------------- // Provides a way for the public CLR debugging interface to find the appropriate // mscordbi.dll, DAC, etc. -class SOSLibraryProvider : public ICLRDebuggingLibraryProvider +class SOSLibraryProvider : public ICLRDebuggingLibraryProvider, ICLRDebuggingLibraryProvider2 { public: SOSLibraryProvider() : m_ref(0) @@ -4370,12 +4349,18 @@ public: { if (InterfaceId == IID_IUnknown) { - *pInterface = static_cast(this); + *pInterface = static_cast(static_cast(this)); } +#ifndef FEATURE_PAL else if (InterfaceId == IID_ICLRDebuggingLibraryProvider) { *pInterface = static_cast(this); } +#endif + else if (InterfaceId == IID_ICLRDebuggingLibraryProvider2) + { + *pInterface = static_cast(this); + } else { *pInterface = NULL; @@ -4401,9 +4386,143 @@ public: return ref; } + struct CoTaskStringHolder + { + private: + WCHAR* m_string; + public: + const int Length = MAX_LONGPATH; + CoTaskStringHolder() : m_string((WCHAR*)CoTaskMemAlloc(MAX_LONGPATH + 1)) { } + ~CoTaskStringHolder() { if (m_string != NULL) CoTaskMemFree(m_string); } + operator WCHAR* () { return m_string; } - // Called by the shim to locate and load mscordacwks and mscordbi + WCHAR* Detach() + { + WCHAR* ret = m_string; + m_string = NULL; + return ret; + } + }; + + HRESULT ProvideLibraryInternal( + const WCHAR* pwszFileName, + DWORD dwTimestamp, + DWORD dwSizeOfImage, + HMODULE* phModule, + LPWSTR* ppResolvedModulePath) + { +#ifndef FEATURE_PAL + HRESULT hr = S_OK; + FindFileCallbackData callbackData; + callbackData.hModule = NULL; + callbackData.timestamp = dwTimestamp; + callbackData.filesize = dwSizeOfImage; + + // if we are looking for the DAC, just load the one windbg already found + if (_wcsncmp(pwszFileName, W("mscordac"), _wcslen(W("mscordac"))) == 0) + { + HMODULE dacModule; + if (g_sos == NULL) + { + // we ensure that windbg loads DAC first so that we can be sure to use the same one + return E_UNEXPECTED; + } + if (FAILED(hr = g_sos->GetDacModuleHandle(&dacModule))) + { + ExtErr("Failed to get the dac module handle. hr=0x%x.\n", hr); + return hr; + } + CoTaskStringHolder dacPath; + DWORD len = GetModuleFileNameW(dacModule, dacPath, dacPath.Length); + if (len == 0 || len == MAX_LONGPATH) + { + hr = HRESULT_FROM_WIN32(GetLastError()); + ExtErr("GetModuleFileName(dacModuleHandle) failed. hr=0x%x.\n", hr); + return hr; + } + FindFileInPathCallback(dacPath, &callbackData); + if (ppResolvedModulePath != NULL) + { + *ppResolvedModulePath = dacPath.Detach(); + } + } + else { + ULONG64 hProcess; + hr = g_ExtSystem->GetCurrentProcessHandle(&hProcess); + if (FAILED(hr)) + { + ExtErr("IDebugSystemObjects::GetCurrentProcessHandle hr=0x%x.\n", hr); + return hr; + } + ToRelease spSym3(NULL); + hr = g_ExtSymbols->QueryInterface(__uuidof(IDebugSymbols3), (void**)&spSym3); + if (FAILED(hr)) + { + ExtErr("Unable to query IDebugSymbol3 hr=0x%x.\n", hr); + return hr; + } + ArrayHolder symbolPath = new WCHAR[MAX_LONGPATH + 1]; + hr = spSym3->GetSymbolPathWide(symbolPath, MAX_LONGPATH, NULL); + if (FAILED(hr)) + { + ExtErr("Unable to get symbol path. IDebugSymbols3::GetSymbolPathWide hr=0x%x.\n", hr); + return hr; + } + CoTaskStringHolder foundPath; + if (!SymFindFileInPathW( + (HANDLE)hProcess, + symbolPath, + pwszFileName, + (PVOID)(ULONG_PTR)dwTimestamp, + dwSizeOfImage, + 0, + SSRVOPT_DWORD, + foundPath, + (PFINDFILEINPATHCALLBACKW)&FindFileInPathCallback, + (PVOID)&callbackData)) + { + hr = HRESULT_FROM_WIN32(GetLastError()); + ExtErr("SymFindFileInPath failed for %S. hr=0x%x.\nPlease ensure that %S is on your symbol path.", pwszFileName, hr, pwszFileName); + return hr; + } + if (ppResolvedModulePath != NULL) + { + *ppResolvedModulePath = foundPath.Detach(); + } + } + if (phModule != NULL) + { + *phModule = callbackData.hModule; + } + return S_OK; +#else + _ASSERTE(phModule == NULL); + + LPCSTR coreclrDirectory = g_ExtServices->GetCoreClrDirectory(); + if (coreclrDirectory == NULL) + { + ExtErr("Runtime module (%s) not loaded yet", MAKEDLLNAME_A("coreclr")); + return E_FAIL; + } + ArrayHolder modulePath = new WCHAR[MAX_LONGPATH + 1]; + int length = MultiByteToWideChar(CP_ACP, 0, coreclrDirectory, -1, modulePath, MAX_LONGPATH); + if (0 >= length) + { + ExtErr("MultiByteToWideChar(coreclrDirectory) failed. Last error = 0x%x\n", GetLastError()); + return E_FAIL; + } + wcscat_s(modulePath, MAX_LONGPATH, pwszFileName); + + if (ppResolvedModulePath != NULL) + { + *ppResolvedModulePath = modulePath.Detach(); + } + return S_OK; +#endif // FEATURE_PAL + } + + // Called by the shim to locate and load mscordaccore and mscordbi // Parameters: // pwszFileName - the name of the file to load // dwTimestamp - the expected timestamp of the file @@ -4416,121 +4535,26 @@ public: const WCHAR * pwszFileName, DWORD dwTimestamp, DWORD dwSizeOfImage, - HMODULE * phModule) + HMODULE* phModule) { -#ifndef FEATURE_PAL - HRESULT hr; - FindFileCallbackData callbackData = {0}; - callbackData.timestamp = dwTimestamp; - callbackData.filesize = dwSizeOfImage; - if ((phModule == NULL) || (pwszFileName == NULL)) { return E_INVALIDARG; } + return ProvideLibraryInternal(pwszFileName, dwTimestamp, dwSizeOfImage, phModule, NULL); + } - HMODULE dacModule; - if(g_sos == NULL) + virtual HRESULT STDMETHODCALLTYPE ProvideLibrary2( + const WCHAR* pwszFileName, + DWORD dwTimestamp, + DWORD dwSizeOfImage, + LPWSTR* ppResolvedModulePath) + { + if ((pwszFileName == NULL) || (ppResolvedModulePath == NULL)) { - // we ensure that windbg loads DAC first so that we can be sure to use the same one - return E_UNEXPECTED; + return E_INVALIDARG; } - if (FAILED(hr = g_sos->GetDacModuleHandle(&dacModule))) - { - ExtOut("Failed to get the dac module handle. hr=0x%x.\n", hr); - return hr; - } - - WCHAR dacPath[MAX_LONGPATH]; - DWORD len = GetModuleFileNameW(dacModule, dacPath, MAX_LONGPATH); - if(len == 0 || len == MAX_LONGPATH) - { - ExtOut("GetModuleFileName(dacModuleHandle) failed. Last error = 0x%x\n", GetLastError()); - return E_FAIL; - } - - // if we are looking for the DAC, just load the one windbg already found - if(_wcsncmp(pwszFileName, W("mscordac"), _wcslen(W("mscordac")))==0) - { - FindFileInPathCallback(dacPath, &callbackData); - *phModule = callbackData.hModule; - return hr; - } - - ULONG64 hProcess; - hr = g_ExtSystem->GetCurrentProcessHandle(&hProcess); - if (FAILED(hr)) - { - ExtOut("IDebugSystemObjects::GetCurrentProcessHandle HRESULT=0x%x.\n", hr); - return hr; - } - - ToRelease spSym3(NULL); - hr = g_ExtSymbols->QueryInterface(__uuidof(IDebugSymbols3), (void**)&spSym3); - if (FAILED(hr)) - { - ExtOut("Unable to query IDebugSymbol3 HRESULT=0x%x.\n", hr); - return hr; - } - - ULONG pathSize = 0; - hr = spSym3->GetSymbolPathWide(NULL, 0, &pathSize); - if(FAILED(hr)) //S_FALSE if the path doesn't fit, but if the path was size 0 perhaps we would get S_OK? - { - ExtOut("Unable to get symbol path length. IDebugSymbols3::GetSymbolPathWide HRESULT=0x%x.\n", hr); - return hr; - } - - ArrayHolder symbolPath = new WCHAR[pathSize+MAX_LONGPATH+1]; - - - - hr = spSym3->GetSymbolPathWide(symbolPath, pathSize, NULL); - if(S_OK != hr) - { - ExtOut("Unable to get symbol path. IDebugSymbols3::GetSymbolPathWide HRESULT=0x%x.\n", hr); - return hr; - } - - WCHAR foundPath[MAX_LONGPATH]; - BOOL rc = SymFindFileInPathW((HANDLE)hProcess, - symbolPath, - pwszFileName, - (PVOID)(ULONG_PTR) dwTimestamp, - dwSizeOfImage, - 0, - SSRVOPT_DWORD, - foundPath, - (PFINDFILEINPATHCALLBACKW) &FindFileInPathCallback, - (PVOID) &callbackData - ); - if(!rc) - { - hr = HRESULT_FROM_WIN32(GetLastError()); - ExtOut("SymFindFileInPath failed for %S. HRESULT=0x%x.\nPlease ensure that %S is on your symbol path.", pwszFileName, hr, pwszFileName); - } - - *phModule = callbackData.hModule; - return hr; -#else - WCHAR modulePath[MAX_LONGPATH]; - int length = MultiByteToWideChar(CP_ACP, 0, g_ExtServices->GetCoreClrDirectory(), -1, modulePath, _countof(modulePath)); - if (0 >= length) - { - ExtOut("MultiByteToWideChar(coreclrDirectory) failed. Last error = 0x%x\n", GetLastError()); - return E_FAIL; - } - wcscat_s(modulePath, _countof(modulePath), pwszFileName); - - *phModule = LoadLibraryW(modulePath); - if (*phModule == NULL) - { - HRESULT hr = HRESULT_FROM_WIN32(GetLastError()); - ExtOut("Unable to load '%S'. HRESULT = 0x%x.\n", pwszFileName, hr); - return hr; - } - return S_OK; -#endif // FEATURE_PAL + return ProvideLibraryInternal(pwszFileName, dwTimestamp, dwSizeOfImage, NULL, ppResolvedModulePath); } protected: @@ -4935,17 +4959,17 @@ BOOL InitializeHeapData() BOOL IsServerBuild() { - return InitializeHeapData() ? g_pHeapData->bServerMode : FALSE; + return InitializeHeapData() ? g_pHeapData->bServerMode : FALSE; } UINT GetMaxGeneration() { - return InitializeHeapData() ? g_pHeapData->g_max_generation : 0; + return InitializeHeapData() ? g_pHeapData->g_max_generation : 0; } UINT GetGcHeapCount() { - return InitializeHeapData() ? g_pHeapData->HeapCount : 0; + return InitializeHeapData() ? g_pHeapData->HeapCount : 0; } BOOL GetGcStructuresValid() @@ -6224,25 +6248,29 @@ HRESULT SymbolReader::LoadSymbolsForPortablePDB(__in_z WCHAR* pModuleName, ___in return Status; } -#ifndef FEATURE_PAL +#ifdef FEATURE_PAL +#define TPALIST_SEPARATOR_STR_A ":" +#else +#define TPALIST_SEPARATOR_STR_A ";" +#endif void AddFilesFromDirectoryToTpaList(const char* directory, std::string& tpaList) { const char * const tpaExtensions[] = { "*.ni.dll", // Probe for .ni.dll first so that it's preferred if ni and il coexist in the same dir "*.dll", - "*.ni.exe", - "*.exe", }; - std::set addedAssemblies; + // Don't add this file to the list because we don't want to the one from the hosting runtime + addedAssemblies.insert(SymbolReaderDllName); + // Walk the directory for each extension separately so that we first get files with .ni.dll extension, // then files with .dll extension, etc. for (int extIndex = 0; extIndex < sizeof(tpaExtensions) / sizeof(tpaExtensions[0]); extIndex++) { const char* ext = tpaExtensions[extIndex]; - size_t extLength = strlen(ext); + size_t extLength = strlen(ext) - 1; // don't count the "*" std::string assemblyPath(directory); assemblyPath.append(DIRECTORY_SEPARATOR_STR_A); @@ -6271,7 +6299,7 @@ void AddFilesFromDirectoryToTpaList(const char* directory, std::string& tpaList) tpaList.append(directory); tpaList.append(DIRECTORY_SEPARATOR_STR_A); tpaList.append(filename); - tpaList.append(";"); + tpaList.append(TPALIST_SEPARATOR_STR_A); } } } @@ -6282,6 +6310,101 @@ void AddFilesFromDirectoryToTpaList(const char* directory, std::string& tpaList) } } +#ifdef FEATURE_PAL + +#if defined(__linux__) +#define symlinkEntrypointExecutable "/proc/self/exe" +#elif !defined(__APPLE__) +#define symlinkEntrypointExecutable "/proc/curproc/exe" +#endif + +bool GetAbsolutePath(const char* path, std::string& absolutePath) +{ + bool result = false; + + char realPath[PATH_MAX]; + if (realpath(path, realPath) != nullptr && realPath[0] != '\0') + { + absolutePath.assign(realPath); + // realpath should return canonicalized path without the trailing slash + assert(absolutePath.back() != '/'); + + result = true; + } + + return result; +} + +bool GetEntrypointExecutableAbsolutePath(std::string& entrypointExecutable) +{ + bool result = false; + + entrypointExecutable.clear(); + + // Get path to the executable for the current process using + // platform specific means. +#if defined(__APPLE__) + + // On Mac, we ask the OS for the absolute path to the entrypoint executable + uint32_t lenActualPath = 0; + if (_NSGetExecutablePath(nullptr, &lenActualPath) == -1) + { + // OSX has placed the actual path length in lenActualPath, + // so re-attempt the operation + std::string resizedPath(lenActualPath, '\0'); + char *pResizedPath = const_cast(resizedPath.c_str()); + if (_NSGetExecutablePath(pResizedPath, &lenActualPath) == 0) + { + entrypointExecutable.assign(pResizedPath); + result = true; + } + } +#elif defined (__FreeBSD__) + static const int name[] = { + CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1 + }; + char path[PATH_MAX]; + size_t len; + + len = sizeof(path); + if (sysctl(name, 4, path, &len, nullptr, 0) == 0) + { + entrypointExecutable.assign(path); + result = true; + } + else + { + // ENOMEM + result = false; + } +#elif defined(__NetBSD__) && defined(KERN_PROC_PATHNAME) + static const int name[] = { + CTL_KERN, KERN_PROC_ARGS, -1, KERN_PROC_PATHNAME, + }; + char path[MAXPATHLEN]; + size_t len; + + len = sizeof(path); + if (sysctl(name, __arraycount(name), path, &len, NULL, 0) != -1) + { + entrypointExecutable.assign(path); + result = true; + } + else + { + result = false; + } +#else + // On other OSs, return the symlink that will be resolved by GetAbsolutePath + // to fetch the entrypoint EXE absolute path, inclusive of filename. + result = GetAbsolutePath(symlinkEntrypointExecutable, entrypointExecutable); +#endif + + return result; +} + +#else // FEATURE_PAL + bool GetEntrypointExecutableAbsolutePath(std::string& entrypointExecutable) { ArrayHolder hostPath = new char[MAX_LONGPATH+1]; @@ -6298,6 +6421,58 @@ bool GetEntrypointExecutableAbsolutePath(std::string& entrypointExecutable) #endif // FEATURE_PAL +HRESULT GetHostRuntime(std::string& coreClrPath, std::string& hostRuntimeDirectory) +{ + // If the hosting runtime isn't already set, use the runtime we are debugging + if (g_hostRuntimeDirectory == nullptr) + { +#ifdef FEATURE_PAL + LPCSTR coreClrDirectory = g_ExtServices->GetCoreClrDirectory(); + if (coreClrDirectory == NULL) + { + ExtErr("Error: Runtime module (%s) not loaded yet", MAKEDLLNAME_A("coreclr")); + return E_FAIL; + } + if (!GetAbsolutePath(coreClrDirectory, hostRuntimeDirectory)) + { + ExtErr("Error: Failed to get coreclr absolute path\n"); + return E_FAIL; + } +#else + ULONG index; + HRESULT Status = g_ExtSymbols->GetModuleByModuleName(MAIN_CLR_MODULE_NAME_A, 0, &index, NULL); + if (FAILED(Status)) + { + ExtErr("Error: Can't find coreclr module\n"); + return Status; + } + ArrayHolder szModuleName = new char[MAX_LONGPATH + 1]; + Status = g_ExtSymbols->GetModuleNames(index, 0, szModuleName, MAX_LONGPATH, NULL, NULL, 0, NULL, NULL, 0, NULL); + if (FAILED(Status)) + { + ExtErr("Error: Failed to get coreclr module name\n"); + return Status; + } + coreClrPath = szModuleName; + + // Parse off the module name to get just the path + size_t lastSlash = coreClrPath.rfind(DIRECTORY_SEPARATOR_CHAR_A); + if (lastSlash == std::string::npos) + { + ExtErr("Error: Failed to parse coreclr module name\n"); + return E_FAIL; + } + hostRuntimeDirectory.assign(coreClrPath, 0, lastSlash); +#endif + g_hostRuntimeDirectory = _strdup(hostRuntimeDirectory.c_str()); + } + hostRuntimeDirectory.assign(g_hostRuntimeDirectory); + coreClrPath.assign(g_hostRuntimeDirectory); + coreClrPath.append(DIRECTORY_SEPARATOR_STR_A); + coreClrPath.append(MAIN_CLR_DLL_NAME_A); + return S_OK; +} + HRESULT SymbolReader::PrepareSymbolReader() { static bool attemptedSymbolReaderPreparation = false; @@ -6306,47 +6481,42 @@ HRESULT SymbolReader::PrepareSymbolReader() // If we already tried to set up the symbol reader, we won't try again. return E_FAIL; } - attemptedSymbolReaderPreparation = true; - std::string absolutePath; + std::string hostRuntimeDirectory; + std::string sosModuleDirectory; std::string coreClrPath; - HRESULT Status; + HRESULT Status = GetHostRuntime(coreClrPath, hostRuntimeDirectory); + if (FAILED(Status)) + { + return Status; + } #ifdef FEATURE_PAL - coreClrPath = g_ExtServices->GetCoreClrDirectory(); - if (!GetAbsolutePath(coreClrPath.c_str(), absolutePath)) - { - ExtErr("Error: Failed to get coreclr absolute path\n"); + ArrayHolder szSOSModulePath = new char[MAX_LONGPATH + 1]; + UINT cch = MAX_LONGPATH; + if (!PAL_GetPALDirectoryA(szSOSModulePath, &cch)) { + ExtErr("Error: Failed to get SOS module directory\n"); return E_FAIL; } - coreClrPath.append(DIRECTORY_SEPARATOR_STR_A); - coreClrPath.append(MAIN_CLR_DLL_NAME_A); + sosModuleDirectory = szSOSModulePath; #else - ULONG index; - Status = g_ExtSymbols->GetModuleByModuleName(MAIN_CLR_MODULE_NAME_A, 0, &index, NULL); - if (FAILED(Status)) + ArrayHolder szSOSModulePath = new char[MAX_LONGPATH + 1]; + if (GetModuleFileNameA(g_hInstance, szSOSModulePath, MAX_LONGPATH) == 0) { - ExtErr("Error: Can't find coreclr module\n"); - return Status; - } - ArrayHolder szModuleName = new char[MAX_LONGPATH + 1]; - Status = g_ExtSymbols->GetModuleNames(index, 0, szModuleName, MAX_LONGPATH, NULL, NULL, 0, NULL, NULL, 0, NULL); - if (FAILED(Status)) - { - ExtErr("Error: Failed to get coreclr module name\n"); - return Status; - } - coreClrPath = szModuleName; - - // Parse off the module name to get just the path - size_t pos = coreClrPath.rfind(DIRECTORY_SEPARATOR_CHAR_A); - if (pos == std::string::npos) - { - ExtErr("Error: Failed to parse coreclr module name\n"); + ExtErr("Error: Failed to get SOS module directory\n"); return E_FAIL; } - absolutePath.assign(coreClrPath, 0, pos); + sosModuleDirectory = szSOSModulePath; + + // Get just the sos module directory + size_t lastSlash = sosModuleDirectory.rfind(DIRECTORY_SEPARATOR_CHAR_A); + if (lastSlash == std::string::npos) + { + ExtErr("Error: Failed to parse sos module name\n"); + return E_FAIL; + } + sosModuleDirectory.erase(lastSlash); #endif // FEATURE_PAL HMODULE coreclrLib = LoadLibraryA(coreClrPath.c_str()); @@ -6366,7 +6536,19 @@ HRESULT SymbolReader::PrepareSymbolReader() } std::string tpaList; - AddFilesFromDirectoryToTpaList(absolutePath.c_str(), tpaList); + AddFilesFromDirectoryToTpaList(hostRuntimeDirectory.c_str(), tpaList); + + // The SOS managed assembly from the sos directory is the one to trust + tpaList.append(sosModuleDirectory); + tpaList.append(DIRECTORY_SEPARATOR_STR_A); + tpaList.append(SymbolReaderDllName); + tpaList.append(".dll"); + tpaList.append(TPALIST_SEPARATOR_STR_A); + + std::string appPaths; + appPaths.append(sosModuleDirectory); + appPaths.append(TPALIST_SEPARATOR_STR_A); + appPaths.append(hostRuntimeDirectory); const char *propertyKeys[] = { "TRUSTED_PLATFORM_ASSEMBLIES", "APP_PATHS", "APP_NI_PATHS", @@ -6375,11 +6557,11 @@ HRESULT SymbolReader::PrepareSymbolReader() const char *propertyValues[] = {// TRUSTED_PLATFORM_ASSEMBLIES tpaList.c_str(), // APP_PATHS - absolutePath.c_str(), + appPaths.c_str(), // APP_NI_PATHS - absolutePath.c_str(), + hostRuntimeDirectory.c_str(), // NATIVE_DLL_SEARCH_DIRECTORIES - absolutePath.c_str(), + hostRuntimeDirectory.c_str(), // AppDomainCompatSwitch "UseLatestBehaviorWhenTFMNotSpecified"}; diff --git a/src/ToolBox/SOS/Strike/util.h b/src/SOS/Strike/util.h similarity index 99% rename from src/ToolBox/SOS/Strike/util.h rename to src/SOS/Strike/util.h index 7ffba1cee..b2037847d 100644 --- a/src/ToolBox/SOS/Strike/util.h +++ b/src/SOS/Strike/util.h @@ -1514,7 +1514,7 @@ struct ModuleInfo ULONG64 size; BOOL hasPdb; }; -extern ModuleInfo moduleInfo[]; +extern ModuleInfo g_moduleInfo[]; BOOL InitializeHeapData(); BOOL IsServerBuild (); diff --git a/src/ToolBox/SOS/Strike/vm.cpp b/src/SOS/Strike/vm.cpp similarity index 100% rename from src/ToolBox/SOS/Strike/vm.cpp rename to src/SOS/Strike/vm.cpp diff --git a/src/ToolBox/SOS/Strike/xplat/dbgeng.h b/src/SOS/Strike/xplat/dbgeng.h similarity index 100% rename from src/ToolBox/SOS/Strike/xplat/dbgeng.h rename to src/SOS/Strike/xplat/dbgeng.h diff --git a/src/ToolBox/SOS/Strike/xplat/dbghelp.h b/src/SOS/Strike/xplat/dbghelp.h similarity index 100% rename from src/ToolBox/SOS/Strike/xplat/dbghelp.h rename to src/SOS/Strike/xplat/dbghelp.h diff --git a/src/ToolBox/SOS/Strike/xplat/wdbgexts.h b/src/SOS/Strike/xplat/wdbgexts.h similarity index 100% rename from src/ToolBox/SOS/Strike/xplat/wdbgexts.h rename to src/SOS/Strike/xplat/wdbgexts.h diff --git a/src/SOS/TestDebuggee/TestDebuggee.csproj b/src/SOS/TestDebuggee/TestDebuggee.csproj index 4624d7fd4..cb3144fc2 100644 --- a/src/SOS/TestDebuggee/TestDebuggee.csproj +++ b/src/SOS/TestDebuggee/TestDebuggee.csproj @@ -2,7 +2,7 @@ Exe - netcoreapp1.0;netcoreapp2.0 + netcoreapp2.0 true ;1591;1701 diff --git a/src/SOS/dbgutil/CMakeLists.txt b/src/SOS/dbgutil/CMakeLists.txt new file mode 100644 index 000000000..1c0d49a24 --- /dev/null +++ b/src/SOS/dbgutil/CMakeLists.txt @@ -0,0 +1,16 @@ +if(WIN32) + #use static crt + add_definitions(-MT) +endif(WIN32) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(DBGUTIL_SOURCES + dbgutil.cpp +) + +if(CLR_CMAKE_PLATFORM_UNIX) + add_compile_options(-fPIC) +endif(CLR_CMAKE_PLATFORM_UNIX) + +add_library_clr(dbgutil STATIC ${DBGUTIL_SOURCES}) diff --git a/src/SOS/dbgutil/dbgutil.cpp b/src/SOS/dbgutil/dbgutil.cpp new file mode 100644 index 000000000..a16849868 --- /dev/null +++ b/src/SOS/dbgutil/dbgutil.cpp @@ -0,0 +1,426 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. +//***************************************************************************** +// dbgutil.cpp +// + +// +//***************************************************************************** + +// +// Various common helpers for PE resource reading used by multiple debug components. +// + +#include +#include "corerror.h" +#include +#include + +// Returns the RVA of the resource section for the module specified by the given data target and module base. +// Returns failure if the module doesn't have a resource section. +// +// Arguments +// pDataTarget - dataTarget for the process we are inspecting +// moduleBaseAddress - base address of a module we should inspect +// pwImageFileMachine - updated with the Machine from the IMAGE_FILE_HEADER +// pdwResourceSectionRVA - updated with the resultant RVA on success +HRESULT GetMachineAndResourceSectionRVA(ICorDebugDataTarget* pDataTarget, + ULONG64 moduleBaseAddress, + WORD* pwImageFileMachine, + DWORD* pdwResourceSectionRVA) +{ + // Fun code ahead... below is a hand written PE decoder with some of the file offsets hardcoded. + // It supports no more than what we absolutely have to to get to the resources we need. Any of the + // magic numbers used below can be determined by using the public documentation on the web. + // + // Yes utilcode has a PE decoder, no it does not support reading its data through a datatarget + // It was easier to inspect the small portion that I needed than to shove an abstraction layer under + // our utilcode and then make sure everything still worked. + + // SECURITY WARNING: all data provided by the data target should be considered untrusted. + // Do not allow malicious data to cause large reads, memory allocations, buffer overflow, + // or any other undesirable behavior. + + HRESULT hr = S_OK; + + // at offset 3c in the image is a 4 byte file pointer that indicates where the PE signature is + IMAGE_DOS_HEADER dosHeader; + hr = ReadFromDataTarget(pDataTarget, moduleBaseAddress, (BYTE*)&dosHeader, sizeof(dosHeader)); + + // verify there is a 4 byte PE signature there + DWORD peSigFilePointer = 0; + if (SUCCEEDED(hr)) + { + peSigFilePointer = dosHeader.e_lfanew; + DWORD peSig = 0; + hr = ReadFromDataTarget(pDataTarget, moduleBaseAddress + peSigFilePointer, (BYTE*)&peSig, 4); + if (SUCCEEDED(hr) && peSig != IMAGE_NT_SIGNATURE) + { + hr = E_FAIL; // PE signature not present + } + } + + // after the signature is a 20 byte image file header + // we need to parse this to figure out the target architecture + IMAGE_FILE_HEADER imageFileHeader; + if (SUCCEEDED(hr)) + { + hr = ReadFromDataTarget(pDataTarget, moduleBaseAddress + peSigFilePointer + 4, (BYTE*)&imageFileHeader, IMAGE_SIZEOF_FILE_HEADER); + } + + + + WORD optHeaderMagic = 0; + DWORD peOptImageHeaderFilePointer = 0; + if (SUCCEEDED(hr)) + { + if(pwImageFileMachine != NULL) + { + *pwImageFileMachine = imageFileHeader.Machine; + } + + // 4 bytes after the signature is the 20 byte image file header + // 24 bytes after the signature is the image-only header + // at the beginning of the image-only header is a 2 byte magic number indicating its format + peOptImageHeaderFilePointer = peSigFilePointer + IMAGE_SIZEOF_FILE_HEADER + sizeof(DWORD); + hr = ReadFromDataTarget(pDataTarget, moduleBaseAddress + peOptImageHeaderFilePointer, (BYTE*)&optHeaderMagic, 2); + } + + // Either 112 or 128 bytes after the beginning of the image-only header is an 8 byte resource table + // depending on whether the image is PE32 or PE32+ + DWORD resourceSectionRVA = 0; + if (SUCCEEDED(hr)) + { + if (optHeaderMagic == IMAGE_NT_OPTIONAL_HDR32_MAGIC) // PE32 + { + IMAGE_OPTIONAL_HEADER32 header32; + hr = ReadFromDataTarget(pDataTarget, moduleBaseAddress + peOptImageHeaderFilePointer, + (BYTE*)&header32, sizeof(header32)); + if (SUCCEEDED(hr)) + { + resourceSectionRVA = header32.DataDirectory[IMAGE_DIRECTORY_ENTRY_RESOURCE].VirtualAddress; + } + } + else if (optHeaderMagic == IMAGE_NT_OPTIONAL_HDR64_MAGIC) //PE32+ + { + IMAGE_OPTIONAL_HEADER64 header64; + hr = ReadFromDataTarget(pDataTarget, moduleBaseAddress + peOptImageHeaderFilePointer, + (BYTE*)&header64, sizeof(header64)); + if (SUCCEEDED(hr)) + { + resourceSectionRVA = header64.DataDirectory[IMAGE_DIRECTORY_ENTRY_RESOURCE].VirtualAddress; + } + } + else + { + hr = E_FAIL; // Invalid PE + } + } + + *pdwResourceSectionRVA = resourceSectionRVA; + return S_OK; +} + +HRESULT GetResourceRvaFromResourceSectionRva(ICorDebugDataTarget* pDataTarget, + ULONG64 moduleBaseAddress, + DWORD resourceSectionRva, + DWORD type, + DWORD name, + DWORD language, + DWORD* pResourceRva, + DWORD* pResourceSize) +{ + HRESULT hr = S_OK; + DWORD nameTableRva = 0; + DWORD langTableRva = 0; + DWORD resourceDataEntryRva = 0; + *pResourceRva = 0; + *pResourceSize = 0; + + // The resource section begins with a resource directory that indexes all the resources by type. + // Each entry it points to is another resource directory that indexes all the same type + // resources by name. And each entry in that table points to another resource directory that indexes + // all the same type/name resources by language. Entries in the final table give the RVA of the actual + // resource. + // Note all RVAs in this section are relative to the beginning of the resource section, + // not the beginning of the image. + + hr = GetNextLevelResourceEntryRVA(pDataTarget, type, moduleBaseAddress, resourceSectionRva, &nameTableRva); + + + if (SUCCEEDED(hr)) + { + nameTableRva += resourceSectionRva; + hr = GetNextLevelResourceEntryRVA(pDataTarget, name, moduleBaseAddress, nameTableRva, &langTableRva); + + } + if (SUCCEEDED(hr)) + { + langTableRva += resourceSectionRva; + hr = GetNextLevelResourceEntryRVA(pDataTarget, language, moduleBaseAddress, langTableRva, &resourceDataEntryRva); + } + + // The resource data entry has the first 4 bytes indicating the RVA of the resource + // The next 4 bytes indicate the size of the resource + if (SUCCEEDED(hr)) + { + resourceDataEntryRva += resourceSectionRva; + IMAGE_RESOURCE_DATA_ENTRY dataEntry; + hr = ReadFromDataTarget(pDataTarget, moduleBaseAddress + resourceDataEntryRva, + (BYTE*)&dataEntry, sizeof(dataEntry)); + *pResourceRva = dataEntry.OffsetToData; + *pResourceSize = dataEntry.Size; + } + + return hr; +} + +HRESULT GetResourceRvaFromResourceSectionRvaByName(ICorDebugDataTarget* pDataTarget, + ULONG64 moduleBaseAddress, + DWORD resourceSectionRva, + DWORD type, + LPCWSTR pwszName, + DWORD language, + DWORD* pResourceRva, + DWORD* pResourceSize) +{ + HRESULT hr = S_OK; + DWORD nameTableRva = 0; + DWORD langTableRva = 0; + DWORD resourceDataEntryRva = 0; + *pResourceRva = 0; + *pResourceSize = 0; + + // The resource section begins with a resource directory that indexes all the resources by type. + // Each entry it points to is another resource directory that indexes all the same type + // resources by name. And each entry in that table points to another resource directory that indexes + // all the same type/name resources by language. Entries in the final table give the RVA of the actual + // resource. + // Note all RVAs in this section are relative to the beginning of the resource section, + // not the beginning of the image. + hr = GetNextLevelResourceEntryRVA(pDataTarget, type, moduleBaseAddress, resourceSectionRva, &nameTableRva); + + + if (SUCCEEDED(hr)) + { + nameTableRva += resourceSectionRva; + hr = GetNextLevelResourceEntryRVAByName(pDataTarget, pwszName, moduleBaseAddress, nameTableRva, resourceSectionRva, &langTableRva); + } + if (SUCCEEDED(hr)) + { + langTableRva += resourceSectionRva; + hr = GetNextLevelResourceEntryRVA(pDataTarget, language, moduleBaseAddress, langTableRva, &resourceDataEntryRva); + } + + // The resource data entry has the first 4 bytes indicating the RVA of the resource + // The next 4 bytes indicate the size of the resource + if (SUCCEEDED(hr)) + { + resourceDataEntryRva += resourceSectionRva; + IMAGE_RESOURCE_DATA_ENTRY dataEntry; + hr = ReadFromDataTarget(pDataTarget, moduleBaseAddress + resourceDataEntryRva, + (BYTE*)&dataEntry, sizeof(dataEntry)); + *pResourceRva = dataEntry.OffsetToData; + *pResourceSize = dataEntry.Size; + } + + return hr; +} + +// Traverses down one level in the PE resource tree structure +// +// Arguments: +// pDataTarget - the data target for inspecting this process +// id - the id of the next node in the resource tree you want +// moduleBaseAddress - the base address of the module being inspected +// resourceDirectoryRVA - the base address of the beginning of the resource directory for this +// level of the tree +// pNextLevelRVA - out - The RVA for the next level tree directory or the RVA of the resource entry +// +// Returns: +// S_OK if succesful or an appropriate failing HRESULT +HRESULT GetNextLevelResourceEntryRVA(ICorDebugDataTarget* pDataTarget, + DWORD id, + ULONG64 moduleBaseAddress, + DWORD resourceDirectoryRVA, + DWORD* pNextLevelRVA) +{ + *pNextLevelRVA = 0; + HRESULT hr = S_OK; + + // A resource directory which consists of + // a header followed by a number of entries. In the header at offset 12 is + // the number entries identified by name, followed by the number of entries + // identified by ID at offset 14. Both are 2 bytes. + // This method only supports locating entries by ID, not by name + IMAGE_RESOURCE_DIRECTORY resourceDirectory; + hr = ReadFromDataTarget(pDataTarget, moduleBaseAddress + resourceDirectoryRVA, (BYTE*)&resourceDirectory, sizeof(resourceDirectory)); + + + + // The ith resource directory entry is at offset 16 + 8i from the beginning of the resource + // directory table + WORD numNameEntries; + WORD numIDEntries; + if (SUCCEEDED(hr)) + { + numNameEntries = resourceDirectory.NumberOfNamedEntries; + numIDEntries = resourceDirectory.NumberOfIdEntries; + + for (WORD i = numNameEntries; i < numNameEntries + numIDEntries; i++) + { + IMAGE_RESOURCE_DIRECTORY_ENTRY entry; + hr = ReadFromDataTarget(pDataTarget, moduleBaseAddress + resourceDirectoryRVA + sizeof(resourceDirectory) + sizeof(entry)*i, + (BYTE*)&entry, sizeof(entry)); + if (FAILED(hr)) + { + break; + } + if (entry.Id == id) + { + *pNextLevelRVA = entry.OffsetToDirectory; + break; + } + } + } + + // If we didn't find the entry + if (SUCCEEDED(hr) && *pNextLevelRVA == 0) + { + hr = E_FAIL; + } + + return hr; // resource not found +} + +// Traverses down one level in the PE resource tree structure +// +// Arguments: +// pDataTarget - the data target for inspecting this process +// name - the name of the next node in the resource tree you want +// moduleBaseAddress - the base address of the module being inspected +// resourceDirectoryRVA - the base address of the beginning of the resource directory for this +// level of the tree +// resourceSectionRVA - the rva of the beginning of the resource section of the PE file +// pNextLevelRVA - out - The RVA for the next level tree directory or the RVA of the resource entry +// +// Returns: +// S_OK if succesful or an appropriate failing HRESULT +HRESULT GetNextLevelResourceEntryRVAByName(ICorDebugDataTarget* pDataTarget, + LPCWSTR pwzName, + ULONG64 moduleBaseAddress, + DWORD resourceDirectoryRva, + DWORD resourceSectionRva, + DWORD* pNextLevelRva) +{ + HRESULT hr = S_OK; + DWORD nameLength = (DWORD)wcslen(pwzName); + WCHAR entryName[50]; + assert(nameLength < 50); // this implementation won't support matching a name longer + // than 50 characters. We only look up the hard coded name + // of the debug resource in clr.dll though, so it shouldn't be + // an issue. Increase this count if we ever want to look up + // larger names + if (nameLength >= 50) + { + hr = E_FAIL; // invalid name length + } + + // A resource directory which consists of + // a header followed by a number of entries. In the header at offset 12 is + // the number entries identified by name, followed by the number of entries + // identified by ID at offset 14. Both are 2 bytes. + // This method only supports locating entries by ID, not by name + IMAGE_RESOURCE_DIRECTORY resourceDirectory = { 0 }; + if (SUCCEEDED(hr)) + { + hr = ReadFromDataTarget(pDataTarget, moduleBaseAddress + resourceDirectoryRva, (BYTE*)&resourceDirectory, sizeof(resourceDirectory)); + } + + // The ith resource directory entry is at offset 16 + 8i from the beginning of the resource + // directory table + if (SUCCEEDED(hr)) + { + WORD numNameEntries = resourceDirectory.NumberOfNamedEntries; + for (WORD i = 0; i < numNameEntries; i++) + { + IMAGE_RESOURCE_DIRECTORY_ENTRY entry; + hr = ReadFromDataTarget(pDataTarget, moduleBaseAddress + resourceDirectoryRva + sizeof(resourceDirectory) + sizeof(entry)*i, + (BYTE*)&entry, sizeof(entry)); + if (FAILED(hr)) + { + break; + } + + // the NameRVAOrID field points to a UTF16 string with a 2 byte length in front of it + // read the 2 byte length first. The doc of course doesn't mention this, but the RVA is + // relative to the base of the resource section and needs the leading bit stripped. + WORD entryNameLength = 0; + hr = ReadFromDataTarget(pDataTarget, moduleBaseAddress + resourceSectionRva + + entry.NameOffset, (BYTE*)&entryNameLength, sizeof(entryNameLength)); + if (FAILED(hr)) + { + break; + } + if (entryNameLength != nameLength) + { + continue; // names aren't the same length, not a match + } + + // read the rest of the string data and check for a match + hr = ReadFromDataTarget(pDataTarget, moduleBaseAddress + resourceSectionRva + + entry.NameOffset + 2, (BYTE*)entryName, entryNameLength*sizeof(WCHAR)); + if (FAILED(hr)) + { + break; + } + if (memcmp(entryName, pwzName, entryNameLength*sizeof(WCHAR)) == 0) + { + *pNextLevelRva = entry.OffsetToDirectory; + break; + } + } + } + + if (SUCCEEDED(hr) && *pNextLevelRva == 0) + { + hr = E_FAIL; // resource not found + } + + return hr; +} + +// A small wrapper that reads from the data target and throws on error +HRESULT ReadFromDataTarget(ICorDebugDataTarget* pDataTarget, + ULONG64 addr, + BYTE* pBuffer, + ULONG32 bytesToRead) +{ + //PRECONDITION(CheckPointer(pDataTarget)); + //PRECONDITION(CheckPointer(pBuffer)); + + HRESULT hr = S_OK; + ULONG32 bytesReadTotal = 0; + ULONG32 bytesRead = 0; + do + { + if (FAILED(pDataTarget->ReadVirtual((CORDB_ADDRESS)(addr + bytesReadTotal), + pBuffer, + bytesToRead - bytesReadTotal, + &bytesRead))) + { + hr = CORDBG_E_READVIRTUAL_FAILURE; + break; + } + bytesReadTotal += bytesRead; + } while (bytesRead != 0 && (bytesReadTotal < bytesToRead)); + + // If we can't read all the expected memory, then fail + if (SUCCEEDED(hr) && (bytesReadTotal != bytesToRead)) + { + hr = HRESULT_FROM_WIN32(ERROR_PARTIAL_COPY); + } + + return hr; +} diff --git a/src/SOS/debugshim/CMakeLists.txt b/src/SOS/debugshim/CMakeLists.txt new file mode 100644 index 000000000..8537f5642 --- /dev/null +++ b/src/SOS/debugshim/CMakeLists.txt @@ -0,0 +1,15 @@ +if(WIN32) + #use static crt + add_definitions(-MT) + add_definitions(-DHOST_IS_WINDOWS_OS) +endif(WIN32) + +if(CLR_CMAKE_PLATFORM_UNIX) + add_compile_options(-fPIC) +endif(CLR_CMAKE_PLATFORM_UNIX) + +set(DEBUGSHIM_SOURCES + debugshim.cpp +) + +add_library_clr(debugshim STATIC ${DEBUGSHIM_SOURCES}) diff --git a/src/SOS/debugshim/debugshim.cpp b/src/SOS/debugshim/debugshim.cpp new file mode 100644 index 000000000..828cbfeef --- /dev/null +++ b/src/SOS/debugshim/debugshim.cpp @@ -0,0 +1,768 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. +//***************************************************************************** +// debugshim.cpp +// + +// +//***************************************************************************** + +#include "debugshim.h" +#include "dbgutil.h" +#include +#include //has the CLR_ID_V4_DESKTOP guid in it +#include "palclr.h" + +#ifndef IMAGE_FILE_MACHINE_ARMNT +#define IMAGE_FILE_MACHINE_ARMNT 0x01c4 // ARM Thumb-2 Little-Endian +#endif + +#ifndef IMAGE_FILE_MACHINE_ARM64 +#define IMAGE_FILE_MACHINE_ARM64 0xAA64 // ARM64 Little-Endian +#endif + +// making the defines very clear, these represent the host architecture - aka +// the arch on which this code is running +#if defined(_X86_) +#define _HOST_X86_ +#elif defined(_AMD64_) +#define _HOST_AMD64_ +#elif defined(_ARM_) +#define _HOST_ARM_ +#elif defined(_ARM64_) +#define _HOST_ARM64_ +#endif + +//***************************************************************************** +// CLRDebuggingImpl implementation (ICLRDebugging) +//***************************************************************************** + +typedef HRESULT (STDAPICALLTYPE *OpenVirtualProcessImpl2FnPtr)(ULONG64 clrInstanceId, + IUnknown * pDataTarget, + LPCWSTR pDacModulePath, + CLR_DEBUGGING_VERSION * pMaxDebuggerSupportedVersion, + REFIID riid, + IUnknown ** ppInstance, + CLR_DEBUGGING_PROCESS_FLAGS * pdwFlags); + +typedef HRESULT (STDAPICALLTYPE *OpenVirtualProcessImplFnPtr)(ULONG64 clrInstanceId, + IUnknown * pDataTarget, + HMODULE hDacDll, + CLR_DEBUGGING_VERSION * pMaxDebuggerSupportedVersion, + REFIID riid, + IUnknown ** ppInstance, + CLR_DEBUGGING_PROCESS_FLAGS * pdwFlags); + +typedef HRESULT (STDAPICALLTYPE *OpenVirtualProcess2FnPtr)(ULONG64 clrInstanceId, + IUnknown * pDataTarget, + HMODULE hDacDll, + REFIID riid, + IUnknown ** ppInstance, + CLR_DEBUGGING_PROCESS_FLAGS * pdwFlags); + +typedef HMODULE (STDAPICALLTYPE *LoadLibraryWFnPtr)(LPCWSTR lpLibFileName); + +// Implementation of ICLRDebugging::OpenVirtualProcess +// +// Arguments: +// moduleBaseAddress - the address of the module which might be a CLR +// pDataTarget - the data target for inspecting the process +// pLibraryProvider - a callback for locating DBI and DAC +// pMaxDebuggerSupportedVersion - the max version of the CLR that this debugger will support debugging +// riidProcess - the IID of the interface that should be passed back in ppProcess +// ppProcess - output for the ICorDebugProcess# if this module is a CLR +// pVersion - the CLR version if this module is a CLR +// pFlags - output, see the CLR_DEBUGGING_PROCESS_FLAGS for more details. Right now this has only one possible +// value which indicates this runtime had an unhandled exception +STDMETHODIMP CLRDebuggingImpl::OpenVirtualProcess( + ULONG64 moduleBaseAddress, + IUnknown * pDataTarget, + ICLRDebuggingLibraryProvider * pLibraryProvider, + CLR_DEBUGGING_VERSION * pMaxDebuggerSupportedVersion, + REFIID riidProcess, + IUnknown ** ppProcess, + CLR_DEBUGGING_VERSION * pVersion, + CLR_DEBUGGING_PROCESS_FLAGS * pFlags) +{ + //PRECONDITION(CheckPointer(pDataTarget)); + + HRESULT hr = S_OK; + ICorDebugDataTarget * pDt = NULL; + HMODULE hDbi = NULL; + HMODULE hDac = NULL; + LPWSTR pDacModulePath = NULL; + LPWSTR pDbiModulePath = NULL; + DWORD dbiTimestamp; + DWORD dbiSizeOfImage; + WCHAR dbiName[MAX_PATH_FNAME] = { 0 }; + DWORD dacTimestamp; + DWORD dacSizeOfImage; + WCHAR dacName[MAX_PATH_FNAME] = { 0 }; + CLR_DEBUGGING_VERSION version; + BOOL versionSupportedByCaller = FALSE; + + // argument checking + if ((ppProcess != NULL || pFlags != NULL) && pLibraryProvider == NULL) + { + hr = E_POINTER; // the library provider must be specified if either + // ppProcess or pFlags is non-NULL + } + else if ((ppProcess != NULL || pFlags != NULL) && pMaxDebuggerSupportedVersion == NULL) + { + hr = E_POINTER; // the max supported version must be specified if either + // ppProcess or pFlags is non-NULL + } + else if (pVersion != NULL && pVersion->wStructVersion != 0) + { + hr = CORDBG_E_UNSUPPORTED_VERSION_STRUCT; + } + else if (FAILED(pDataTarget->QueryInterface(__uuidof(ICorDebugDataTarget), (void**)&pDt))) + { + hr = CORDBG_E_MISSING_DATA_TARGET_INTERFACE; + } + + if (SUCCEEDED(hr)) + { + // get CLR version + // The expectation is that new versions of the CLR will continue to use the same GUID + // (unless there's a reason to hide them from older shims), but debuggers will tell us the + // CLR version they're designed for and mscordbi.dll can decide whether or not to accept it. + version.wStructVersion = 0; + hr = GetCLRInfo(pDt, + moduleBaseAddress, + &version, + &dbiTimestamp, + &dbiSizeOfImage, + dbiName, + MAX_PATH_FNAME, + &dacTimestamp, + &dacSizeOfImage, + dacName, + MAX_PATH_FNAME); + } + + // If we need to fetch either the process info or the flags info then we need to find + // mscordbi and DAC and do the version specific OVP work + if (SUCCEEDED(hr) && (ppProcess != NULL || pFlags != NULL)) + { + ICLRDebuggingLibraryProvider2* pLibraryProvider2; + if (SUCCEEDED(pLibraryProvider->QueryInterface(__uuidof(ICLRDebuggingLibraryProvider2), (void**)&pLibraryProvider2))) + { + if (FAILED(pLibraryProvider2->ProvideLibrary2(dbiName, dbiTimestamp, dbiSizeOfImage, &pDbiModulePath)) || + pDbiModulePath == NULL) + { + hr = CORDBG_E_LIBRARY_PROVIDER_ERROR; + } + + if (SUCCEEDED(hr)) + { + hDbi = LoadLibraryW(pDbiModulePath); + if (hDbi == NULL) + { + hr = HRESULT_FROM_WIN32(GetLastError()); + } + } + + if (SUCCEEDED(hr)) + { + // Adjust the timestamp and size of image if this DAC is a known buggy version and needs to be retargeted + RetargetDacIfNeeded(&dacTimestamp, &dacSizeOfImage); + + // Ask library provider for dac + if (FAILED(pLibraryProvider2->ProvideLibrary2(dacName, dacTimestamp, dacSizeOfImage, &pDacModulePath)) || + pDacModulePath == NULL) + { + hr = CORDBG_E_LIBRARY_PROVIDER_ERROR; + } + + if (SUCCEEDED(hr)) + { + hDac = LoadLibraryW(pDacModulePath); + if (hDac == NULL) + { + hr = HRESULT_FROM_WIN32(GetLastError()); + } + } + } + + pLibraryProvider2->Release(); + } + else { + // Ask library provider for dbi + if (FAILED(pLibraryProvider->ProvideLibrary(dbiName, dbiTimestamp, dbiSizeOfImage, &hDbi)) || + hDbi == NULL) + { + hr = CORDBG_E_LIBRARY_PROVIDER_ERROR; + } + + if (SUCCEEDED(hr)) + { + // Adjust the timestamp and size of image if this DAC is a known buggy version and needs to be retargeted + RetargetDacIfNeeded(&dacTimestamp, &dacSizeOfImage); + + // ask library provider for dac + if (FAILED(pLibraryProvider->ProvideLibrary(dacName, dacTimestamp, dacSizeOfImage, &hDac)) || + hDac == NULL) + { + hr = CORDBG_E_LIBRARY_PROVIDER_ERROR; + } + } + } + + *ppProcess = NULL; + + if (SUCCEEDED(hr) && pDacModulePath != NULL) + { + // Get access to the latest OVP implementation and call it + OpenVirtualProcessImpl2FnPtr ovpFn = (OpenVirtualProcessImpl2FnPtr)GetProcAddress(hDbi, "OpenVirtualProcessImpl2"); + if (ovpFn != NULL) + { + hr = ovpFn(moduleBaseAddress, pDataTarget, pDacModulePath, pMaxDebuggerSupportedVersion, riidProcess, ppProcess, pFlags); + if (FAILED(hr)) + { + _ASSERTE(ppProcess == NULL || *ppProcess == NULL); + _ASSERTE(pFlags == NULL || *pFlags == 0); + } + } +#ifdef FEATURE_PAL + else + { + // On Linux/MacOS the DAC module handle needs to be re-created using the DAC PAL instance + // before being passed to DBI's OpenVirtualProcess* implementation. The DBI and DAC share + // the same PAL where dbgshim has it's own. + LoadLibraryWFnPtr loadLibraryWFn = (LoadLibraryWFnPtr)GetProcAddress(hDac, "LoadLibraryW"); + if (loadLibraryWFn != NULL) + { + hDac = loadLibraryWFn(pDacModulePath); + if (hDac == NULL) + { + hr = E_HANDLE; + } + } + else + { + hr = E_HANDLE; + } + } +#endif // FEATURE_PAL + } + + // If no errors so far and "OpenVirtualProcessImpl2" doesn't exist + if (SUCCEEDED(hr) && *ppProcess == NULL) + { + // Get access to OVP and call it + OpenVirtualProcessImplFnPtr ovpFn = (OpenVirtualProcessImplFnPtr)GetProcAddress(hDbi, "OpenVirtualProcessImpl"); + if (ovpFn == NULL) + { + // Fallback to CLR v4 Beta1 path, but skip some of the checking we'd normally do (maxSupportedVersion, etc.) + OpenVirtualProcess2FnPtr ovp2Fn = (OpenVirtualProcess2FnPtr)GetProcAddress(hDbi, "OpenVirtualProcess2"); + if (ovp2Fn == NULL) + { + hr = CORDBG_E_LIBRARY_PROVIDER_ERROR; + } + else + { + hr = ovp2Fn(moduleBaseAddress, pDataTarget, hDac, riidProcess, ppProcess, pFlags); + } + } + else + { + // Have a CLR v4 Beta2+ DBI, call it and let it do the version check + hr = ovpFn(moduleBaseAddress, pDataTarget, hDac, pMaxDebuggerSupportedVersion, riidProcess, ppProcess, pFlags); + if (FAILED(hr)) + { + _ASSERTE(ppProcess == NULL || *ppProcess == NULL); + _ASSERTE(pFlags == NULL || *pFlags == 0); + } + } + } + } + + //version is still valid in some failure cases + if (pVersion != NULL && + (SUCCEEDED(hr) || + (hr == CORDBG_E_UNSUPPORTED_DEBUGGING_MODEL) || + (hr == CORDBG_E_UNSUPPORTED_FORWARD_COMPAT))) + { + memcpy(pVersion, &version, sizeof(CLR_DEBUGGING_VERSION)); + } + + if (pDacModulePath != NULL) + { +#ifdef FEATURE_PAL + free(pDacModulePath); +#else + CoTaskMemFree(pDacModulePath); +#endif + } + + if (pDbiModulePath != NULL) + { +#ifdef FEATURE_PAL + free(pDbiModulePath); +#else + CoTaskMemFree(pDbiModulePath); +#endif + } + + // free the data target we QI'ed earlier + if (pDt != NULL) + { + pDt->Release(); + } + + return hr; +} + +// Checks to see if this DAC is one of a known set of old DAC builds which contains an issue. +// If so we retarget to a newer compatible version which has the bug fixed. This is done +// by changing the PE information used to lookup the DAC. +// +// Arguments +// pdwTimeStamp - on input, the timestamp of DAC as embedded in the CLR image +// on output, a potentially new timestamp for an updated DAC to use +// instead +// pdwSizeOfImage - on input, the sizeOfImage of DAC as embedded in the CLR image +// on output, a potentially new sizeOfImage for an updated DAC to use +// instead +VOID CLRDebuggingImpl::RetargetDacIfNeeded(DWORD* pdwTimeStamp, + DWORD* pdwSizeOfImage) +{ + + // This code is auto generated by the CreateRetargetTable tool + // on 3/4/2011 6:35 PM + // and then copy-pasted here. + // + // + // + // Retarget the GDR1 amd64 build + if( (*pdwTimeStamp == 0x4d536868) && (*pdwSizeOfImage == 0x17b000)) + { + *pdwTimeStamp = 0x4d71a160; + *pdwSizeOfImage = 0x17b000; + } + // Retarget the GDR1 x86 build + else if( (*pdwTimeStamp == 0x4d5368f2) && (*pdwSizeOfImage == 0x120000)) + { + *pdwTimeStamp = 0x4d71a14f; + *pdwSizeOfImage = 0x120000; + } + // Retarget the RTM amd64 build + else if( (*pdwTimeStamp == 0x4ba21fa7) && (*pdwSizeOfImage == 0x17b000)) + { + *pdwTimeStamp = 0x4d71a13c; + *pdwSizeOfImage = 0x17b000; + } + // Retarget the RTM x86 build + else if( (*pdwTimeStamp == 0x4ba1da25) && (*pdwSizeOfImage == 0x120000)) + { + *pdwTimeStamp = 0x4d71a128; + *pdwSizeOfImage = 0x120000; + } + // This code is auto generated by the CreateRetargetTable tool + // on 8/17/2011 1:28 AM + // and then copy-pasted here. + // + // + // + // Retarget the GDR2 amd64 build + else if( (*pdwTimeStamp == 0x4da428c7) && (*pdwSizeOfImage == 0x17b000)) + { + *pdwTimeStamp = 0x4e4b7bc2; + *pdwSizeOfImage = 0x17b000; + } + // Retarget the GDR2 x86 build + else if( (*pdwTimeStamp == 0x4da3fe52) && (*pdwSizeOfImage == 0x120000)) + { + *pdwTimeStamp = 0x4e4b7bb1; + *pdwSizeOfImage = 0x120000; + } + // End auto-generated code +} + +#define PE_FIXEDFILEINFO_SIGNATURE 0xFEEF04BD + +// The format of the special debugging resource we embed in CLRs starting in +// v4 +struct CLR_DEBUG_RESOURCE +{ + DWORD dwVersion; + GUID signature; + DWORD dwDacTimeStamp; + DWORD dwDacSizeOfImage; + DWORD dwDbiTimeStamp; + DWORD dwDbiSizeOfImage; +}; + +// Checks to see if a module is a CLR and if so, fetches the debug data +// from the embedded resource +// +// Arguments +// pDataTarget - dataTarget for the process we are inspecting +// moduleBaseAddress - base address of a module we should inspect +// pVersion - output, the version of the CLR detected if this is a CLR +// pdwDbiTimeStamp - the timestamp of DBI as embedded in the CLR image +// pdwDbiSizeOfImage - the SizeOfImage of DBI as embedded in the CLR image +// pDbiName - output, the filename of DBI (as calculated by this function but that might change) +// dwDbiNameCharCount - input, the number of WCHARs in the buffer pointed to by pDbiName +// pdwDacTimeStampe - the timestamp of DAC as embedded in the CLR image +// pdwDacSizeOfImage - the SizeOfImage of DAC as embedded in the CLR image +// pDacName - output, the filename of DAC (as calculated by this function but that might change) +// dwDacNameCharCount - input, the number of WCHARs in the buffer pointed to by pDacName +HRESULT CLRDebuggingImpl::GetCLRInfo(ICorDebugDataTarget* pDataTarget, + ULONG64 moduleBaseAddress, + CLR_DEBUGGING_VERSION* pVersion, + DWORD* pdwDbiTimeStamp, + DWORD* pdwDbiSizeOfImage, + __out_z __inout_ecount(dwDbiNameCharCount) WCHAR* pDbiName, + DWORD dwDbiNameCharCount, + DWORD* pdwDacTimeStamp, + DWORD* pdwDacSizeOfImage, + __out_z __inout_ecount(dwDacNameCharCount) WCHAR* pDacName, + DWORD dwDacNameCharCount) +{ +#ifndef FEATURE_PAL + WORD imageFileMachine = 0; + DWORD resourceSectionRVA = 0; + HRESULT hr = GetMachineAndResourceSectionRVA(pDataTarget, moduleBaseAddress, &imageFileMachine, &resourceSectionRVA); + + // We want the version resource which has type = RT_VERSION = 16, name = 1, language = 0x409 + DWORD versionResourceRVA = 0; + DWORD versionResourceSize = 0; + if(SUCCEEDED(hr)) + { + hr = GetResourceRvaFromResourceSectionRva(pDataTarget, moduleBaseAddress, resourceSectionRVA, 16, 1, 0x409, + &versionResourceRVA, &versionResourceSize); + } + + // At last we get our version info + VS_FIXEDFILEINFO fixedFileInfo = {0}; + if(SUCCEEDED(hr)) + { + // The version resource has 3 words, then the unicode string "VS_VERSION_INFO" + // (16 WCHARS including the null terminator) + // then padding to a 32-bit boundary, then the VS_FIXEDFILEINFO struct + DWORD fixedFileInfoRVA = ((versionResourceRVA + 3*2 + 16*2 + 3)/4)*4; + hr = ReadFromDataTarget(pDataTarget, moduleBaseAddress + fixedFileInfoRVA, (BYTE*)&fixedFileInfo, sizeof(fixedFileInfo)); + } + + //Verify the signature on the version resource + if(SUCCEEDED(hr) && fixedFileInfo.dwSignature != PE_FIXEDFILEINFO_SIGNATURE) + { + hr = CORDBG_E_NOT_CLR; + } + + // Record the version information + if(SUCCEEDED(hr)) + { + pVersion->wMajor = (WORD) (fixedFileInfo.dwProductVersionMS >> 16); + pVersion->wMinor = (WORD) (fixedFileInfo.dwProductVersionMS & 0xFFFF); + pVersion->wBuild = (WORD) (fixedFileInfo.dwProductVersionLS >> 16); + pVersion->wRevision = (WORD) (fixedFileInfo.dwProductVersionLS & 0xFFFF); + } + + // Now grab the special clr debug info resource + // We may need to scan a few different names searching though... + // 1) CLRDEBUGINFO where host_os = 'WINDOWS' or 'CORESYS' and host_arch = 'X86' or 'ARM' or 'AMD64' + // 2) For back-compat if the host os is windows and the host architecture matches the target then CLRDEBUGINFO is used with no suffix. + DWORD debugResourceRVA = 0; + DWORD debugResourceSize = 0; + BOOL useCrossPlatformNaming = FALSE; + if(SUCCEEDED(hr)) + { + // the initial state is that we haven't found a proper resource + HRESULT hrGetResource = E_FAIL; + + // First check for the resource which has type = RC_DATA = 10, name = "CLRDEBUGINFO", language = 0 +#if defined (HOST_IS_WINDOWS_OS) && defined(_HOST_X86_) + const WCHAR * resourceName = W("CLRDEBUGINFOWINDOWSX86"); +#endif + +#if !defined (HOST_IS_WINDOWS_OS) && defined(_HOST_X86_) + const WCHAR * resourceName = W("CLRDEBUGINFOCORESYSX86"); +#endif + +#if defined (HOST_IS_WINDOWS_OS) && defined(_HOST_AMD64_) + const WCHAR * resourceName = W("CLRDEBUGINFOWINDOWSAMD64"); +#endif + +#if !defined (HOST_IS_WINDOWS_OS) && defined(_HOST_AMD64_) + const WCHAR * resourceName = W("CLRDEBUGINFOCORESYSAMD64"); +#endif + +#if defined (HOST_IS_WINDOWS_OS) && defined(_HOST_ARM64_) + const WCHAR * resourceName = W("CLRDEBUGINFOWINDOWSARM64"); +#endif + +#if !defined (HOST_IS_WINDOWS_OS) && defined(_HOST_ARM64_) + const WCHAR * resourceName = W("CLRDEBUGINFOCORESYSARM64"); +#endif + +#if defined (HOST_IS_WINDOWS_OS) && defined(_HOST_ARM_) + const WCHAR * resourceName = W("CLRDEBUGINFOWINDOWSARM"); +#endif + +#if !defined (HOST_IS_WINDOWS_OS) && defined(_HOST_ARM_) + const WCHAR * resourceName = W("CLRDEBUGINFOCORESYSARM"); +#endif + + hrGetResource = GetResourceRvaFromResourceSectionRvaByName(pDataTarget, moduleBaseAddress, resourceSectionRVA, 10, resourceName, 0, + &debugResourceRVA, &debugResourceSize); + useCrossPlatformNaming = SUCCEEDED(hrGetResource); + + +#if defined(HOST_IS_WINDOWS_OS) && (defined(_HOST_X86_) || defined(_HOST_AMD64_) || defined(_HOST_ARM_)) + #if defined(_HOST_X86_) + #define _HOST_MACHINE_TYPE IMAGE_FILE_MACHINE_I386 + #elif defined(_HOST_AMD64_) + #define _HOST_MACHINE_TYPE IMAGE_FILE_MACHINE_AMD64 + #elif defined(_HOST_ARM_) + #define _HOST_MACHINE_TYPE IMAGE_FILE_MACHINE_ARMNT + #endif + + // if this is windows, and if host_arch matches target arch then we can fallback to searching for CLRDEBUGINFO on failure + if(FAILED(hrGetResource) && (imageFileMachine == _HOST_MACHINE_TYPE)) + { + hrGetResource = GetResourceRvaFromResourceSectionRvaByName(pDataTarget, moduleBaseAddress, resourceSectionRVA, 10, W("CLRDEBUGINFO"), 0, + &debugResourceRVA, &debugResourceSize); + } + + #undef _HOST_MACHINE_TYPE +#endif + // if the search failed, we don't recognize the CLR + if(FAILED(hrGetResource)) + hr = CORDBG_E_NOT_CLR; + } + + CLR_DEBUG_RESOURCE debugResource; + if(SUCCEEDED(hr) && debugResourceSize != sizeof(debugResource)) + { + hr = CORDBG_E_NOT_CLR; + } + + // Get the special debug resource from the image and return the results + if(SUCCEEDED(hr)) + { + hr = ReadFromDataTarget(pDataTarget, moduleBaseAddress + debugResourceRVA, (BYTE*)&debugResource, sizeof(debugResource)); + } + if(SUCCEEDED(hr) && (debugResource.dwVersion != 0)) + { + hr = CORDBG_E_NOT_CLR; + } + + // The signature needs to match m_skuId exactly, except for m_skuId=CLR_ID_ONECORE_CLR which is + // also compatible with the older CLR_ID_PHONE_CLR signature. + if(SUCCEEDED(hr) && + (debugResource.signature != m_skuId) && + !( (debugResource.signature == CLR_ID_PHONE_CLR) && (m_skuId == CLR_ID_ONECORE_CLR) )) + { + hr = CORDBG_E_NOT_CLR; + } + + if(SUCCEEDED(hr) && + (debugResource.signature != CLR_ID_ONECORE_CLR) && + useCrossPlatformNaming) + { + FormatLongDacModuleName(pDacName, dwDacNameCharCount, imageFileMachine, &fixedFileInfo); + swprintf_s(pDbiName, dwDbiNameCharCount, W("%s_%s.dll"), MAIN_DBI_MODULE_NAME_W, W("x86")); + } + else + { + if(m_skuId == CLR_ID_V4_DESKTOP) + swprintf_s(pDacName, dwDacNameCharCount, W("%s.dll"), CLR_DAC_MODULE_NAME_W); + else + swprintf_s(pDacName, dwDacNameCharCount, W("%s.dll"), CORECLR_DAC_MODULE_NAME_W); + swprintf_s(pDbiName, dwDbiNameCharCount, W("%s.dll"), MAIN_DBI_MODULE_NAME_W); + } + + if(SUCCEEDED(hr)) + { + *pdwDbiTimeStamp = debugResource.dwDbiTimeStamp; + *pdwDbiSizeOfImage = debugResource.dwDbiSizeOfImage; + *pdwDacTimeStamp = debugResource.dwDacTimeStamp; + *pdwDacSizeOfImage = debugResource.dwDacSizeOfImage; + } + + // any failure should be interpreted as this module not being a CLR + if(FAILED(hr)) + { + return CORDBG_E_NOT_CLR; + } + else + { + return S_OK; + } +#else + swprintf_s(pDacName, dwDacNameCharCount, W("%s"), MAKEDLLNAME_W(CORECLR_DAC_MODULE_NAME_W)); + swprintf_s(pDbiName, dwDbiNameCharCount, W("%s"), MAKEDLLNAME_W(MAIN_DBI_MODULE_NAME_W)); + + pVersion->wMajor = 0; + pVersion->wMinor = 0; + pVersion->wBuild = 0; + pVersion->wRevision = 0; + + *pdwDbiTimeStamp = 0; + *pdwDbiSizeOfImage = 0; + *pdwDacTimeStamp = 0; + *pdwDacSizeOfImage = 0; + + return S_OK; +#endif // FEATURE_PAL +} + +// Formats the long name for DAC +HRESULT CLRDebuggingImpl::FormatLongDacModuleName(__out_z __inout_ecount(cchBuffer) WCHAR * pBuffer, + DWORD cchBuffer, + DWORD targetImageFileMachine, + VS_FIXEDFILEINFO * pVersion) +{ + +#ifndef HOST_IS_WINDOWS_OS + _ASSERTE(!"NYI"); + return E_NOTIMPL; +#endif + +#if defined(_HOST_X86_) + const WCHAR* pHostArch = W("x86"); +#elif defined(_HOST_AMD64_) + const WCHAR* pHostArch = W("amd64"); +#elif defined(_HOST_ARM_) + const WCHAR* pHostArch = W("arm"); +#elif defined(_HOST_ARM64_) + const WCHAR* pHostArch = W("arm64"); +#else + _ASSERTE(!"Unknown host arch"); + return E_NOTIMPL; +#endif + + const WCHAR* pDacBaseName = NULL; + if(m_skuId == CLR_ID_V4_DESKTOP) + pDacBaseName = CLR_DAC_MODULE_NAME_W; + else if(m_skuId == CLR_ID_CORECLR || m_skuId == CLR_ID_PHONE_CLR || m_skuId == CLR_ID_ONECORE_CLR) + pDacBaseName = CORECLR_DAC_MODULE_NAME_W; + else + { + _ASSERTE(!"Unknown SKU id"); + return E_UNEXPECTED; + } + + const WCHAR* pTargetArch = NULL; + if(targetImageFileMachine == IMAGE_FILE_MACHINE_I386) + { + pTargetArch = W("x86"); + } + else if(targetImageFileMachine == IMAGE_FILE_MACHINE_AMD64) + { + pTargetArch = W("amd64"); + } + else if(targetImageFileMachine == IMAGE_FILE_MACHINE_ARMNT) + { + pTargetArch = W("arm"); + } + else if(targetImageFileMachine == IMAGE_FILE_MACHINE_ARM64) + { + pTargetArch = W("arm64"); + } + else + { + _ASSERTE(!"Unknown target image file machine type"); + return E_INVALIDARG; + } + + const WCHAR* pBuildFlavor = W(""); + if(pVersion->dwFileFlags & VS_FF_DEBUG) + { + if(pVersion->dwFileFlags & VS_FF_SPECIALBUILD) + pBuildFlavor = W(".dbg"); + else + pBuildFlavor = W(".chk"); + } + + // WARNING: if you change the formatting make sure you recalculate the maximum + // possible size string and verify callers pass a big enough buffer. This doesn't + // have to be a tight estimate, just make sure its >= the biggest possible DAC name + // and it can be calculated statically + DWORD minCchBuffer = + (DWORD) wcslen(CLR_DAC_MODULE_NAME_W) + (DWORD) wcslen(CORECLR_DAC_MODULE_NAME_W) + // max name + 10 + // max host arch + 10 + // max target arch + 40 + // max version + 10 + // max build flavor + (DWORD) wcslen(W("name_host_target_version.flavor.dll")) + // max intermediate formatting chars + 1; // null terminator + + // validate the output buffer is larger than our estimate above + _ASSERTE(cchBuffer >= minCchBuffer); + if(!(cchBuffer >= minCchBuffer)) return E_INVALIDARG; + + swprintf_s(pBuffer, cchBuffer, W("%s_%s_%s_%u.%u.%u.%02u%s.dll"), + pDacBaseName, + pHostArch, + pTargetArch, + pVersion->dwProductVersionMS >> 16, + pVersion->dwProductVersionMS & 0xFFFF, + pVersion->dwProductVersionLS >> 16, + pVersion->dwProductVersionLS & 0xFFFF, + pBuildFlavor); + return S_OK; +} + +// An implementation of ICLRDebugging::CanUnloadNow +// +// Arguments: +// hModule - a handle to a module provided earlier by ProvideLibrary +// +// Returns: +// S_OK if the library is no longer in use and can be unloaded, S_FALSE otherwise +// +STDMETHODIMP CLRDebuggingImpl::CanUnloadNow(HMODULE hModule) +{ + // In V4 at least we don't support any unloading. + HRESULT hr = S_FALSE; + + return hr; +} + + + +STDMETHODIMP CLRDebuggingImpl::QueryInterface(REFIID riid, void **ppvObject) +{ + HRESULT hr = S_OK; + + if (riid == __uuidof(IUnknown)) + { + IUnknown *pItf = static_cast(this); + pItf->AddRef(); + *ppvObject = pItf; + } + else if (riid == __uuidof(ICLRDebugging)) + { + ICLRDebugging *pItf = static_cast(this); + pItf->AddRef(); + *ppvObject = pItf; + } + else + hr = E_NOINTERFACE; + + return hr; +} + +// Standard AddRef implementation +ULONG CLRDebuggingImpl::AddRef() +{ + return InterlockedIncrement(&m_cRef); +} + +// Standard Release implementation. +ULONG CLRDebuggingImpl::Release() +{ + _ASSERTE(m_cRef > 0); + + ULONG cRef = InterlockedDecrement(&m_cRef); + + if (cRef == 0) + delete this; // Relies on virtual dtor to work properly. + + return cRef; +} diff --git a/src/SOS/debugshim/debugshim.h b/src/SOS/debugshim/debugshim.h new file mode 100644 index 000000000..c1d917387 --- /dev/null +++ b/src/SOS/debugshim/debugshim.h @@ -0,0 +1,90 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. +//***************************************************************************** +// debugshim.h +// + +// +//***************************************************************************** + +#ifndef _DEBUG_SHIM_ +#define _DEBUG_SHIM_ + +#include "cor.h" +#include "cordebug.h" +#include +#include + +#define CORECLR_DAC_MODULE_NAME_W W("mscordaccore") +#define CLR_DAC_MODULE_NAME_W W("mscordacwks") +#define MAIN_DBI_MODULE_NAME_W W("mscordbi") + +// forward declaration +struct ICorDebugDataTarget; + +// ICLRDebugging implementation. +class CLRDebuggingImpl : public ICLRDebugging +{ + +public: + CLRDebuggingImpl(GUID skuId) : m_cRef(0), m_skuId(skuId) + { + } + + virtual ~CLRDebuggingImpl() {} + +public: + // ICLRDebugging methods: + STDMETHOD(OpenVirtualProcess( + ULONG64 moduleBaseAddress, + IUnknown * pDataTarget, + ICLRDebuggingLibraryProvider * pLibraryProvider, + CLR_DEBUGGING_VERSION * pMaxDebuggerSupportedVersion, + REFIID riidProcess, + IUnknown ** ppProcess, + CLR_DEBUGGING_VERSION * pVersion, + CLR_DEBUGGING_PROCESS_FLAGS * pFlags)); + + STDMETHOD(CanUnloadNow(HMODULE hModule)); + + //IUnknown methods: + STDMETHOD(QueryInterface( + REFIID riid, + void **ppvObject)); + + // Standard AddRef implementation + STDMETHOD_(ULONG, AddRef()); + + // Standard Release implementation. + STDMETHOD_(ULONG, Release()); + + + +private: + VOID RetargetDacIfNeeded(DWORD* pdwTimeStamp, + DWORD* pdwSizeOfImage); + + HRESULT GetCLRInfo(ICorDebugDataTarget * pDataTarget, + ULONG64 moduleBaseAddress, + CLR_DEBUGGING_VERSION * pVersion, + DWORD * pdwDbiTimeStamp, + DWORD * pdwDbiSizeOfImage, + __out_z __inout_ecount(dwDbiNameCharCount) WCHAR * pDbiName, + DWORD dwDbiNameCharCount, + DWORD * pdwDacTimeStamp, + DWORD * pdwDacSizeOfImage, + __out_z __inout_ecount(dwDacNameCharCount) WCHAR * pDacName, + DWORD dwDacNameCharCount); + + HRESULT FormatLongDacModuleName(__out_z __inout_ecount(cchBuffer) WCHAR * pBuffer, + DWORD cchBuffer, + DWORD targetImageFileMachine, + VS_FIXEDFILEINFO * pVersion); + + volatile LONG m_cRef; + GUID m_skuId; + +}; // class CLRDebuggingImpl + +#endif diff --git a/src/gcdump/gcdump.cpp b/src/SOS/gcdump/gcdump.cpp similarity index 100% rename from src/gcdump/gcdump.cpp rename to src/SOS/gcdump/gcdump.cpp diff --git a/src/gcdump/gcdumpnonx86.cpp b/src/SOS/gcdump/gcdumpnonx86.cpp similarity index 99% rename from src/gcdump/gcdumpnonx86.cpp rename to src/SOS/gcdump/gcdumpnonx86.cpp index 7a7ebfe36..766b15423 100644 --- a/src/gcdump/gcdumpnonx86.cpp +++ b/src/SOS/gcdump/gcdumpnonx86.cpp @@ -527,5 +527,5 @@ void GCDump::DumpPtrsInFrame(PTR_CBYTE gcInfoBlock, #define GET_CALLER_SP(pREGDISPLAY) ((size_t)GetSP(pREGDISPLAY->pCallerContext)) #define VALIDATE_OBJECTREF(objref, fDeep) ((void)0) #define VALIDATE_ROOT(isInterior, hCallBack, pObjRef) ((void)0) -#include "../vm/gcinfodecoder.cpp" -#include "../gcinfo/gcinfodumper.cpp" +#include "gcinfodecoder.cpp" +#include "gcinfodumper.cpp" diff --git a/src/SOS/gcdump/gcinfodecoder.cpp b/src/SOS/gcdump/gcinfodecoder.cpp new file mode 100644 index 000000000..1a539b9e4 --- /dev/null +++ b/src/SOS/gcdump/gcinfodecoder.cpp @@ -0,0 +1,1843 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +#include "gcinfodecoder.h" + +#ifdef USE_GC_INFO_DECODER + +#ifndef CHECK_APP_DOMAIN +#define CHECK_APP_DOMAIN 0 +#endif + +#ifndef GCINFODECODER_CONTRACT +#define GCINFODECODER_CONTRACT LIMITED_METHOD_CONTRACT +#endif // !GCINFODECODER_CONTRACT + + +#ifndef GET_CALLER_SP +#define GET_CALLER_SP(pREGDISPLAY) EECodeManager::GetCallerSp(pREGDISPLAY) +#endif // !GET_CALLER_SP + +#ifndef VALIDATE_OBJECTREF +#if defined(DACCESS_COMPILE) || defined(CROSSGEN_COMPILE) +#define VALIDATE_OBJECTREF(objref, fDeep) +#else // DACCESS_COMPILE || CROSSGEN_COMPILE +#define VALIDATE_OBJECTREF(objref, fDeep) OBJECTREF_TO_UNCHECKED_OBJECTREF(objref)->Validate(fDeep) +#endif // DACCESS_COMPILE || CROSSGEN_COMPILE +#endif // !VALIDATE_OBJECTREF + +#ifndef VALIDATE_ROOT +#include "gcenv.h" +#define VALIDATE_ROOT(isInterior, hCallBack, pObjRef) \ + do { \ + /* Only call Object::Validate() with bDeep == TRUE if we are in the promote phase. */ \ + /* We should call Validate() with bDeep == FALSE if we are in the relocation phase. */ \ + /* Actually with the introduction of the POPO feature, we cannot validate during */ \ + /* relocate because POPO might have written over the object. It will require non */ \ + /* trivial amount of work to make this work.*/ \ + \ + GCCONTEXT* pGCCtx = (GCCONTEXT*)(hCallBack); \ + \ + if (!(isInterior) && !(m_Flags & DECODE_NO_VALIDATION) && (pGCCtx->sc->promotion)) { \ + VALIDATE_OBJECTREF(*(pObjRef), pGCCtx->sc->promotion == TRUE); \ + } \ + } while (0) +#endif // !VALIDATE_ROOT + +#ifndef LOG_PIPTR +#define LOG_PIPTR(pObjRef, gcFlags, hCallBack) \ + { \ + GCCONTEXT* pGCCtx = (GCCONTEXT*)(hCallBack); \ + if (pGCCtx->sc->promotion) \ + { \ + LOG((LF_GCROOTS, LL_INFO1000, /* Part Three */ \ + LOG_PIPTR_OBJECT_CLASS(OBJECTREF_TO_UNCHECKED_OBJECTREF(*pObjRef), (gcFlags & GC_CALL_PINNED), (gcFlags & GC_CALL_INTERIOR)))); \ + } \ + else \ + { \ + LOG((LF_GCROOTS, LL_INFO1000, /* Part Three */ \ + LOG_PIPTR_OBJECT(OBJECTREF_TO_UNCHECKED_OBJECTREF(*pObjRef), (gcFlags & GC_CALL_PINNED), (gcFlags & GC_CALL_INTERIOR)))); \ + } \ + } +#endif // !LOG_PIPTR + +bool GcInfoDecoder::SetIsInterruptibleCB (UINT32 startOffset, UINT32 stopOffset, void * hCallback) +{ + GcInfoDecoder *pThis = (GcInfoDecoder*)hCallback; + + + bool fStop = pThis->m_InstructionOffset >= startOffset && pThis->m_InstructionOffset < stopOffset; + + if (fStop) + pThis->m_IsInterruptible = true; + + return fStop; +} + +GcInfoDecoder::GcInfoDecoder( + GCInfoToken gcInfoToken, + GcInfoDecoderFlags flags, + UINT32 breakOffset + ) + : m_Reader(dac_cast(gcInfoToken.Info)) + , m_InstructionOffset(breakOffset) + , m_IsInterruptible(false) + , m_ReturnKind(RT_Illegal) +#ifdef _DEBUG + , m_Flags( flags ) + , m_GcInfoAddress(dac_cast(gcInfoToken.Info)) +#endif + , m_Version(gcInfoToken.Version) +{ + _ASSERTE( (flags & (DECODE_INTERRUPTIBILITY | DECODE_GC_LIFETIMES)) || (0 == breakOffset) ); + + // The current implementation doesn't support the two flags together + _ASSERTE( + ((flags & (DECODE_INTERRUPTIBILITY | DECODE_GC_LIFETIMES)) != (DECODE_INTERRUPTIBILITY | DECODE_GC_LIFETIMES)) + ); + + //-------------------------------------------- + // Pre-decode information + //-------------------------------------------- + + GcInfoHeaderFlags headerFlags; + bool slimHeader = (m_Reader.ReadOneFast() == 0); + + if (slimHeader) + { + headerFlags = (GcInfoHeaderFlags)(m_Reader.ReadOneFast() ? GC_INFO_HAS_STACK_BASE_REGISTER : 0); + } + else + { + int numFlagBits = (m_Version == 1) ? GC_INFO_FLAGS_BIT_SIZE_VERSION_1 : GC_INFO_FLAGS_BIT_SIZE; + headerFlags = (GcInfoHeaderFlags) m_Reader.Read(numFlagBits); + } + + m_IsVarArg = headerFlags & GC_INFO_IS_VARARG; + int hasSecurityObject = headerFlags & GC_INFO_HAS_SECURITY_OBJECT; + int hasGSCookie = headerFlags & GC_INFO_HAS_GS_COOKIE; + int hasPSPSym = headerFlags & GC_INFO_HAS_PSP_SYM; + int hasGenericsInstContext = (headerFlags & GC_INFO_HAS_GENERICS_INST_CONTEXT_MASK) != GC_INFO_HAS_GENERICS_INST_CONTEXT_NONE; + m_GenericSecretParamIsMD = (headerFlags & GC_INFO_HAS_GENERICS_INST_CONTEXT_MASK) == GC_INFO_HAS_GENERICS_INST_CONTEXT_MD; + m_GenericSecretParamIsMT = (headerFlags & GC_INFO_HAS_GENERICS_INST_CONTEXT_MASK) == GC_INFO_HAS_GENERICS_INST_CONTEXT_MT; + int hasStackBaseRegister = headerFlags & GC_INFO_HAS_STACK_BASE_REGISTER; +#ifdef _TARGET_AMD64_ + m_WantsReportOnlyLeaf = ((headerFlags & GC_INFO_WANTS_REPORT_ONLY_LEAF) != 0); +#elif defined(_TARGET_ARM_) || defined(_TARGET_ARM64_) + m_HasTailCalls = ((headerFlags & GC_INFO_HAS_TAILCALLS) != 0); +#endif // _TARGET_AMD64_ + int hasSizeOfEditAndContinuePreservedArea = headerFlags & GC_INFO_HAS_EDIT_AND_CONTINUE_PRESERVED_SLOTS; + + int hasReversePInvokeFrame = false; + if (gcInfoToken.IsReversePInvokeFrameAvailable()) + { + hasReversePInvokeFrame = headerFlags & GC_INFO_REVERSE_PINVOKE_FRAME; + } + + if (gcInfoToken.IsReturnKindAvailable()) + { + int returnKindBits = (slimHeader) ? SIZE_OF_RETURN_KIND_IN_SLIM_HEADER : SIZE_OF_RETURN_KIND_IN_FAT_HEADER; + m_ReturnKind = + (ReturnKind)((UINT32)m_Reader.Read(returnKindBits)); + } + else + { +#ifndef _TARGET_X86_ + m_ReturnKind = RT_Unset; +#endif // ! _TARGET_X86_ + } + + if (flags == DECODE_RETURN_KIND) { + // Bail, if we've decoded enough, + return; + } + + m_CodeLength = (UINT32) DENORMALIZE_CODE_LENGTH((UINT32) m_Reader.DecodeVarLengthUnsigned(CODE_LENGTH_ENCBASE)); + + if (flags == DECODE_CODE_LENGTH) { + // Bail, if we've decoded enough, + return; + } + + if (hasGSCookie) + { + // Note that normalization as a code offset can be different than + // normalization as code legnth + UINT32 normCodeLength = NORMALIZE_CODE_OFFSET(m_CodeLength); + + // Decode prolog/epilog information + UINT32 normPrologSize = (UINT32) m_Reader.DecodeVarLengthUnsigned(NORM_PROLOG_SIZE_ENCBASE) + 1; + UINT32 normEpilogSize = (UINT32) m_Reader.DecodeVarLengthUnsigned(NORM_EPILOG_SIZE_ENCBASE); + + m_ValidRangeStart = (UINT32) DENORMALIZE_CODE_OFFSET(normPrologSize); + m_ValidRangeEnd = (UINT32) DENORMALIZE_CODE_OFFSET(normCodeLength - normEpilogSize); + _ASSERTE(m_ValidRangeStart < m_ValidRangeEnd); + } + else if (hasSecurityObject || hasGenericsInstContext) + { + // Decode prolog information + UINT32 normPrologSize = (UINT32) m_Reader.DecodeVarLengthUnsigned(NORM_PROLOG_SIZE_ENCBASE) + 1; + m_ValidRangeStart = (UINT32) DENORMALIZE_CODE_OFFSET(normPrologSize); + // satisfy asserts that assume m_GSCookieValidRangeStart != 0 ==> m_GSCookieValidRangeStart < m_GSCookieValidRangeEnd + m_ValidRangeEnd = m_ValidRangeStart + 1; + } + else + { + m_ValidRangeStart = m_ValidRangeEnd = 0; + } + + if (flags == DECODE_PROLOG_LENGTH) { + // Bail, if we've decoded enough, + return; + } + + // Decode the offset to the security object. + if(hasSecurityObject) + { + m_SecurityObjectStackSlot = (INT32) DENORMALIZE_STACK_SLOT(m_Reader.DecodeVarLengthSigned(SECURITY_OBJECT_STACK_SLOT_ENCBASE)); + } + else + { + m_SecurityObjectStackSlot = NO_SECURITY_OBJECT; + } + + if (flags == DECODE_SECURITY_OBJECT) { + // Bail, if we've decoded enough, + return; + } + + // Decode the offset to the GS cookie. + if(hasGSCookie) + { + m_GSCookieStackSlot = (INT32) DENORMALIZE_STACK_SLOT(m_Reader.DecodeVarLengthSigned(GS_COOKIE_STACK_SLOT_ENCBASE)); + } + else + { + m_GSCookieStackSlot = NO_GS_COOKIE; + } + + if (flags == DECODE_GS_COOKIE) { + // Bail, if we've decoded enough, + return; + } + + // Decode the offset to the PSPSym. + // The PSPSym is relative to the caller SP on IA64 and the initial stack pointer before any stack allocation on X64 (InitialSP). + if(hasPSPSym) + { + m_PSPSymStackSlot = (INT32) DENORMALIZE_STACK_SLOT(m_Reader.DecodeVarLengthSigned(PSP_SYM_STACK_SLOT_ENCBASE)); + } + else + { + m_PSPSymStackSlot = NO_PSP_SYM; + } + + if (flags == DECODE_PSP_SYM) { + // Bail, if we've decoded enough, + return; + } + + // Decode the offset to the generics type context. + if(hasGenericsInstContext) + { + m_GenericsInstContextStackSlot = (INT32) DENORMALIZE_STACK_SLOT(m_Reader.DecodeVarLengthSigned(GENERICS_INST_CONTEXT_STACK_SLOT_ENCBASE)); + } + else + { + m_GenericsInstContextStackSlot = NO_GENERICS_INST_CONTEXT; + } + + if (flags == DECODE_GENERICS_INST_CONTEXT) { + // Bail, if we've decoded enough, + return; + } + + if(hasStackBaseRegister) + { + if (slimHeader) + { + m_StackBaseRegister = (UINT32) DENORMALIZE_STACK_BASE_REGISTER(0); + } + else + { + m_StackBaseRegister = (UINT32) DENORMALIZE_STACK_BASE_REGISTER(m_Reader.DecodeVarLengthUnsigned(STACK_BASE_REGISTER_ENCBASE)); + } + } + else + { + m_StackBaseRegister = NO_STACK_BASE_REGISTER; + } + + if (hasSizeOfEditAndContinuePreservedArea) + { + m_SizeOfEditAndContinuePreservedArea = (UINT32) m_Reader.DecodeVarLengthUnsigned(SIZE_OF_EDIT_AND_CONTINUE_PRESERVED_AREA_ENCBASE); + } + else + { + m_SizeOfEditAndContinuePreservedArea = NO_SIZE_OF_EDIT_AND_CONTINUE_PRESERVED_AREA; + } + + if (hasReversePInvokeFrame) + { + m_ReversePInvokeFrameStackSlot = (INT32)m_Reader.DecodeVarLengthSigned(REVERSE_PINVOKE_FRAME_ENCBASE); + } + else + { + m_ReversePInvokeFrameStackSlot = NO_REVERSE_PINVOKE_FRAME; + } + + +#ifdef FIXED_STACK_PARAMETER_SCRATCH_AREA + if (slimHeader) + { + m_SizeOfStackOutgoingAndScratchArea = 0; + } + else + { + m_SizeOfStackOutgoingAndScratchArea = (UINT32)DENORMALIZE_SIZE_OF_STACK_AREA(m_Reader.DecodeVarLengthUnsigned(SIZE_OF_STACK_AREA_ENCBASE)); + } +#endif // FIXED_STACK_PARAMETER_SCRATCH_AREA + +#ifdef PARTIALLY_INTERRUPTIBLE_GC_SUPPORTED + m_NumSafePoints = (UINT32) DENORMALIZE_NUM_SAFE_POINTS(m_Reader.DecodeVarLengthUnsigned(NUM_SAFE_POINTS_ENCBASE)); +#endif + + if (slimHeader) + { + m_NumInterruptibleRanges = 0; + } + else + { + m_NumInterruptibleRanges = (UINT32) DENORMALIZE_NUM_INTERRUPTIBLE_RANGES(m_Reader.DecodeVarLengthUnsigned(NUM_INTERRUPTIBLE_RANGES_ENCBASE)); + } + +#ifdef PARTIALLY_INTERRUPTIBLE_GC_SUPPORTED + if(flags & (DECODE_INTERRUPTIBILITY | DECODE_GC_LIFETIMES)) + { + if(m_NumSafePoints) + { + m_SafePointIndex = FindSafePoint(m_InstructionOffset); + } + else + { + m_SafePointIndex = 0; + } + } + else if(flags & DECODE_FOR_RANGES_CALLBACK) + { + // Note that normalization as a code offset can be different than + // normalization as code legnth + UINT32 normCodeLength = NORMALIZE_CODE_OFFSET(m_CodeLength); + + UINT32 numBitsPerOffset = CeilOfLog2(normCodeLength); + m_Reader.Skip(m_NumSafePoints * numBitsPerOffset); + } +#endif + + if(!m_IsInterruptible && (flags & DECODE_INTERRUPTIBILITY)) + { + EnumerateInterruptibleRanges(&SetIsInterruptibleCB, this); + } +} + +bool GcInfoDecoder::IsInterruptible() +{ + _ASSERTE( m_Flags & DECODE_INTERRUPTIBILITY ); + return m_IsInterruptible; +} + +bool GcInfoDecoder::HasMethodDescGenericsInstContext() +{ + _ASSERTE( m_Flags & DECODE_GENERICS_INST_CONTEXT ); + return m_GenericSecretParamIsMD; +} + +bool GcInfoDecoder::HasMethodTableGenericsInstContext() +{ + _ASSERTE( m_Flags & DECODE_GENERICS_INST_CONTEXT ); + return m_GenericSecretParamIsMT; +} + +#ifdef PARTIALLY_INTERRUPTIBLE_GC_SUPPORTED + +// This is used for gccoverage: is the given offset +// a call-return offset with partially-interruptible GC info? +bool GcInfoDecoder::IsSafePoint(UINT32 codeOffset) +{ + _ASSERTE(m_Flags == DECODE_EVERYTHING && m_InstructionOffset == 0); + if(m_NumSafePoints == 0) + return false; + +#if defined(_TARGET_AMD64_) || defined(_TARGET_ARM_) || defined(_TARGET_ARM64_) + // Safepoints are encoded with a -1 adjustment + codeOffset--; +#endif + size_t savedPos = m_Reader.GetCurrentPos(); + UINT32 safePointIndex = FindSafePoint(codeOffset); + m_Reader.SetCurrentPos(savedPos); + return (bool) (safePointIndex != m_NumSafePoints); + +} + +UINT32 GcInfoDecoder::FindSafePoint(UINT32 breakOffset) +{ + if(m_NumSafePoints == 0) + return 0; + + const size_t savedPos = m_Reader.GetCurrentPos(); + const UINT32 numBitsPerOffset = CeilOfLog2(NORMALIZE_CODE_OFFSET(m_CodeLength)); + UINT32 result = m_NumSafePoints; + +#if defined(_TARGET_ARM_) || defined(_TARGET_ARM64_) + // Safepoints are encoded with a -1 adjustment + // but normalizing them masks off the low order bit + // Thus only bother looking if the address is odd + if ((breakOffset & 1) != 0) +#endif + { + const UINT32 normBreakOffset = NORMALIZE_CODE_OFFSET(breakOffset); + + INT32 low = 0; + INT32 high = (INT32)m_NumSafePoints; + + while(low < high) + { + const INT32 mid = (low+high)/2; + _ASSERTE(mid >= 0 && mid < (INT32)m_NumSafePoints); + m_Reader.SetCurrentPos(savedPos + (UINT32)mid * numBitsPerOffset); + UINT32 normOffset = (UINT32)m_Reader.Read(numBitsPerOffset); + if(normOffset == normBreakOffset) + { + result = (UINT32) mid; + break; + } + + if(normOffset < normBreakOffset) + low = mid+1; + else + high = mid; + } + } + + m_Reader.SetCurrentPos(savedPos + m_NumSafePoints * numBitsPerOffset); + return result; +} + +void GcInfoDecoder::EnumerateSafePoints(EnumerateSafePointsCallback *pCallback, void * hCallback) +{ + if(m_NumSafePoints == 0) + return; + + const UINT32 numBitsPerOffset = CeilOfLog2(NORMALIZE_CODE_OFFSET(m_CodeLength)); + + for(UINT32 i = 0; i < m_NumSafePoints; i++) + { + UINT32 normOffset = (UINT32)m_Reader.Read(numBitsPerOffset); + UINT32 offset = DENORMALIZE_CODE_OFFSET(normOffset) + 2; + +#if defined(_TARGET_AMD64_) || defined(_TARGET_ARM_) || defined(_TARGET_ARM64_) + // Safepoints are encoded with a -1 adjustment + offset--; +#endif + + pCallback(offset, hCallback); + } +} +#endif + +void GcInfoDecoder::EnumerateInterruptibleRanges ( + EnumerateInterruptibleRangesCallback *pCallback, + void * hCallback) +{ + // If no info is found for the call site, we default to fully-interruptbile + LOG((LF_GCROOTS, LL_INFO1000000, "No GC info found for call site at offset %x. Defaulting to fully-interruptible information.\n", (int) m_InstructionOffset)); + + UINT32 lastInterruptibleRangeStopOffsetNormalized = 0; + + for(UINT32 i=0; i= normStart && normBreakOffset < normStop) + { + _ASSERTE(pseudoBreakOffset == 0); + countIntersections++; + pseudoBreakOffset = numInterruptibleLength + normBreakOffset - normStart; + } + numInterruptibleLength += normStopDelta; + lastNormStop = normStop; + } + _ASSERTE(countIntersections <= 1); + if(countIntersections == 0) + { + _ASSERTE(executionAborted); + LOG((LF_GCROOTS, LL_INFO100000, "Not reporting this frame because it is aborted and not fully interruptible.\n")); + goto ExitSuccess; + } + } + } +#else // !PARTIALLY_INTERRUPTIBLE_GC_SUPPORTED + + // Skip interruptibility information + for(UINT32 i=0; i 0) && m_Reader.ReadOneFast()) + { + numBitsPerOffset = (UINT32) m_Reader.DecodeVarLengthUnsigned(POINTER_SIZE_ENCBASE) + 1; + _ASSERTE(numBitsPerOffset != 0); + } + + //------------------------------------------------------------------------------ + // Try partially interruptible first + //------------------------------------------------------------------------------ + + if( !executionAborted && m_SafePointIndex != m_NumSafePoints ) + { + if (numBitsPerOffset) + { + const size_t offsetTablePos = m_Reader.GetCurrentPos(); + m_Reader.Skip(m_SafePointIndex * numBitsPerOffset); + const size_t liveStatesOffset = m_Reader.Read(numBitsPerOffset); + const size_t liveStatesStart = ((offsetTablePos + m_NumSafePoints * numBitsPerOffset + 7) & (~7)); + m_Reader.SetCurrentPos(liveStatesStart + liveStatesOffset); + if (m_Reader.ReadOneFast()) { + // RLE encoded + bool fSkip = (m_Reader.ReadOneFast() == 0); + bool fReport = true; + UINT32 readSlots = (UINT32)m_Reader.DecodeVarLengthUnsigned( fSkip ? LIVESTATE_RLE_SKIP_ENCBASE : LIVESTATE_RLE_RUN_ENCBASE ); + fSkip = !fSkip; + while (readSlots < numSlots) + { + UINT32 cnt = (UINT32)m_Reader.DecodeVarLengthUnsigned( fSkip ? LIVESTATE_RLE_SKIP_ENCBASE : LIVESTATE_RLE_RUN_ENCBASE ) + 1; + if (fReport) + { + for(UINT32 slotIndex = readSlots; slotIndex < readSlots + cnt; slotIndex++) + { + ReportSlotToGC(slotDecoder, + slotIndex, + pRD, + reportScratchSlots, + inputFlags, + pCallBack, + hCallBack + ); + } + } + readSlots += cnt; + fSkip = !fSkip; + fReport = !fReport; + } + _ASSERTE(readSlots == numSlots); + goto ReportUntracked; + } + // Just a normal live state (1 bit per slot), so use the normal decoding loop + } + else + { + m_Reader.Skip(m_SafePointIndex * numSlots); + } + + for(UINT32 slotIndex = 0; slotIndex < numSlots; slotIndex++) + { + if(m_Reader.ReadOneFast()) + { + ReportSlotToGC( + slotDecoder, + slotIndex, + pRD, + reportScratchSlots, + inputFlags, + pCallBack, + hCallBack + ); + } + } + goto ReportUntracked; + } + else + { + m_Reader.Skip(m_NumSafePoints * numSlots); + if(m_NumInterruptibleRanges == 0) + goto ReportUntracked; + } +#endif // PARTIALLY_INTERRUPTIBLE_GC_SUPPORTED + + _ASSERTE(m_NumInterruptibleRanges); + _ASSERTE(numInterruptibleLength); + + // If no info is found for the call site, we default to fully-interruptbile + LOG((LF_GCROOTS, LL_INFO1000000, "No GC info found for call site at offset %x. Defaulting to fully-interruptible information.\n", (int) m_InstructionOffset)); + + UINT32 numChunks = (numInterruptibleLength + NUM_NORM_CODE_OFFSETS_PER_CHUNK - 1) / NUM_NORM_CODE_OFFSETS_PER_CHUNK; + UINT32 breakChunk = pseudoBreakOffset / NUM_NORM_CODE_OFFSETS_PER_CHUNK; + _ASSERTE(breakChunk < numChunks); + + UINT32 numBitsPerPointer = (UINT32) m_Reader.DecodeVarLengthUnsigned(POINTER_SIZE_ENCBASE); + + if(!numBitsPerPointer) + goto ReportUntracked; + + size_t pointerTablePos = m_Reader.GetCurrentPos(); + + size_t chunkPointer; + UINT32 chunk = breakChunk; + for(;;) + { + m_Reader.SetCurrentPos(pointerTablePos + chunk * numBitsPerPointer); + chunkPointer = m_Reader.Read(numBitsPerPointer); + if(chunkPointer) + break; + + if(chunk-- == 0) + goto ReportUntracked; + } + + size_t chunksStartPos = ((pointerTablePos + numChunks * numBitsPerPointer + 7) & (~7)); + size_t chunkPos = chunksStartPos + chunkPointer - 1; + m_Reader.SetCurrentPos(chunkPos); + + { + BitStreamReader couldBeLiveReader(m_Reader); + + UINT32 numCouldBeLiveSlots = 0; + // A potentially compressed bit vector of which slots have any lifetimes + if (m_Reader.ReadOneFast()) + { + // RLE encoded + bool fSkip = (m_Reader.ReadOneFast() == 0); + bool fReport = true; + UINT32 readSlots = (UINT32)m_Reader.DecodeVarLengthUnsigned( fSkip ? LIVESTATE_RLE_SKIP_ENCBASE : LIVESTATE_RLE_RUN_ENCBASE ); + fSkip = !fSkip; + while (readSlots < numSlots) + { + UINT32 cnt = (UINT32)m_Reader.DecodeVarLengthUnsigned( fSkip ? LIVESTATE_RLE_SKIP_ENCBASE : LIVESTATE_RLE_RUN_ENCBASE ) + 1; + if (fReport) + { + numCouldBeLiveSlots += cnt; + } + readSlots += cnt; + fSkip = !fSkip; + fReport = !fReport; + } + _ASSERTE(readSlots == numSlots); + + } + else + { + for(UINT32 i = 0; i < numSlots; i++) + { + if(m_Reader.ReadOneFast()) + numCouldBeLiveSlots++; + } + } + _ASSERTE(numCouldBeLiveSlots > 0); + + BitStreamReader finalStateReader(m_Reader); + + m_Reader.Skip(numCouldBeLiveSlots); + + int lifetimeTransitionsCount = 0; + + UINT32 slotIndex = 0; + bool fSimple = (couldBeLiveReader.ReadOneFast() == 0); + bool fSkipFirst = false; // silence the warning + UINT32 cnt = 0; + if (!fSimple) + { + fSkipFirst = (couldBeLiveReader.ReadOneFast() == 0); + slotIndex = -1; + } + for(UINT32 i = 0; i < numCouldBeLiveSlots; i++) + { + if (fSimple) + { + while(!couldBeLiveReader.ReadOneFast()) + slotIndex++; + } + else if (cnt > 0) + { + // We have more from the last run to report + cnt--; + } + // We need to find a new run + else if (fSkipFirst) + { + UINT32 tmp = (UINT32)couldBeLiveReader.DecodeVarLengthUnsigned( LIVESTATE_RLE_SKIP_ENCBASE ) + 1; + slotIndex += tmp; + cnt = (UINT32)couldBeLiveReader.DecodeVarLengthUnsigned( LIVESTATE_RLE_RUN_ENCBASE ); + } + else + { + UINT32 tmp = (UINT32)couldBeLiveReader.DecodeVarLengthUnsigned( LIVESTATE_RLE_RUN_ENCBASE ) + 1; + slotIndex += tmp; + cnt = (UINT32)couldBeLiveReader.DecodeVarLengthUnsigned( LIVESTATE_RLE_SKIP_ENCBASE ); + } + + UINT32 isLive = (UINT32) finalStateReader.Read(1); + + if(chunk == breakChunk) + { + // Read transitions + UINT32 normBreakOffsetDelta = pseudoBreakOffset % NUM_NORM_CODE_OFFSETS_PER_CHUNK; + for(;;) + { + if(!m_Reader.ReadOneFast()) + break; + + UINT32 transitionOffset = (UINT32) m_Reader.Read(NUM_NORM_CODE_OFFSETS_PER_CHUNK_LOG2); + + lifetimeTransitionsCount++; + _ASSERTE(transitionOffset && transitionOffset < NUM_NORM_CODE_OFFSETS_PER_CHUNK); + if(transitionOffset > normBreakOffsetDelta) + { + isLive ^= 1; + } + } + } + + if(isLive) + { + ReportSlotToGC( + slotDecoder, + slotIndex, + pRD, + reportScratchSlots, + inputFlags, + pCallBack, + hCallBack + ); + } + + slotIndex++; + } + + LOG((LF_GCROOTS, LL_INFO1000000, "Decoded %d lifetime transitions.\n", (int) lifetimeTransitionsCount )); + } + } + +ReportUntracked: + + //------------------------------------------------------------------------------ + // Last report anything untracked + // But only for the leaf funclet/frame + // Turned on in the VM for regular GC reporting and the DAC for !CLRStack -gc + // But turned off in the #includes for nidump and sos's !u -gcinfo and !gcinfo + //------------------------------------------------------------------------------ + + if (slotDecoder.GetNumUntracked() && !(inputFlags & (ParentOfFuncletStackFrame | NoReportUntracked))) + { + ReportUntrackedSlots(slotDecoder, pRD, inputFlags, pCallBack, hCallBack); + } + +ExitSuccess: + + return true; +} + +void GcInfoDecoder::EnumerateUntrackedSlots( + PREGDISPLAY pRD, + unsigned inputFlags, + GCEnumCallback pCallBack, + void * hCallBack + ) +{ + _ASSERTE(GC_SLOT_INTERIOR == GC_CALL_INTERIOR); + _ASSERTE(GC_SLOT_PINNED == GC_CALL_PINNED); + + _ASSERTE( m_Flags & DECODE_GC_LIFETIMES ); + + GcSlotDecoder slotDecoder; + + // Skip interruptibility information + for(UINT32 i=0; i 0) + { + // We certainly predecode the first register + + _ASSERTE(i < MAX_PREDECODED_SLOTS); + + UINT32 normRegNum = (UINT32) reader.DecodeVarLengthUnsigned(REGISTER_ENCBASE); + UINT32 regNum = DENORMALIZE_REGISTER(normRegNum); + GcSlotFlags flags = (GcSlotFlags) reader.Read(2); + + m_SlotArray[0].Slot.RegisterNumber = regNum; + m_SlotArray[0].Flags = flags; + + UINT32 loopEnd = _min(m_NumRegisters, MAX_PREDECODED_SLOTS); + for(i++; i < loopEnd; i++) + { + if(flags) + { + normRegNum = (UINT32) reader.DecodeVarLengthUnsigned(REGISTER_ENCBASE); + regNum = DENORMALIZE_REGISTER(normRegNum); + flags = (GcSlotFlags) reader.Read(2); + } + else + { + UINT32 normRegDelta = (UINT32) reader.DecodeVarLengthUnsigned(REGISTER_DELTA_ENCBASE) + 1; + normRegNum += normRegDelta; + regNum = DENORMALIZE_REGISTER(normRegNum); + } + + m_SlotArray[i].Slot.RegisterNumber = regNum; + m_SlotArray[i].Flags = flags; + } + } + + if((numStackSlots > 0) && (i < MAX_PREDECODED_SLOTS)) + { + // We have stack slots left and more room to predecode + + GcStackSlotBase spBase = (GcStackSlotBase) reader.Read(2); + UINT32 normSpOffset = (INT32) reader.DecodeVarLengthSigned(STACK_SLOT_ENCBASE); + INT32 spOffset = DENORMALIZE_STACK_SLOT(normSpOffset); + GcSlotFlags flags = (GcSlotFlags) reader.Read(2); + + m_SlotArray[i].Slot.Stack.SpOffset = spOffset; + m_SlotArray[i].Slot.Stack.Base = spBase; + m_SlotArray[i].Flags = flags; + + UINT32 loopEnd = _min(m_NumRegisters + numStackSlots, MAX_PREDECODED_SLOTS); + for(i++; i < loopEnd; i++) + { + spBase = (GcStackSlotBase) reader.Read(2); + + if(flags) + { + normSpOffset = (INT32) reader.DecodeVarLengthSigned(STACK_SLOT_ENCBASE); + spOffset = DENORMALIZE_STACK_SLOT(normSpOffset); + flags = (GcSlotFlags) reader.Read(2); + } + else + { + INT32 normSpOffsetDelta = (INT32) reader.DecodeVarLengthUnsigned(STACK_SLOT_DELTA_ENCBASE); + normSpOffset += normSpOffsetDelta; + spOffset = DENORMALIZE_STACK_SLOT(normSpOffset); + } + + m_SlotArray[i].Slot.Stack.SpOffset = spOffset; + m_SlotArray[i].Slot.Stack.Base = spBase; + m_SlotArray[i].Flags = flags; + } + } + + if((m_NumUntracked > 0) && (i < MAX_PREDECODED_SLOTS)) + { + // We have untracked stack slots left and more room to predecode + + GcStackSlotBase spBase = (GcStackSlotBase) reader.Read(2); + UINT32 normSpOffset = (INT32) reader.DecodeVarLengthSigned(STACK_SLOT_ENCBASE); + INT32 spOffset = DENORMALIZE_STACK_SLOT(normSpOffset); + GcSlotFlags flags = (GcSlotFlags) reader.Read(2); + + m_SlotArray[i].Slot.Stack.SpOffset = spOffset; + m_SlotArray[i].Slot.Stack.Base = spBase; + m_SlotArray[i].Flags = flags; + + UINT32 loopEnd = _min(m_NumSlots, MAX_PREDECODED_SLOTS); + for(i++; i < loopEnd; i++) + { + spBase = (GcStackSlotBase) reader.Read(2); + + if(flags) + { + normSpOffset = (INT32) reader.DecodeVarLengthSigned(STACK_SLOT_ENCBASE); + spOffset = DENORMALIZE_STACK_SLOT(normSpOffset); + flags = (GcSlotFlags) reader.Read(2); + } + else + { + INT32 normSpOffsetDelta = (INT32) reader.DecodeVarLengthUnsigned(STACK_SLOT_DELTA_ENCBASE); + normSpOffset += normSpOffsetDelta; + spOffset = DENORMALIZE_STACK_SLOT(normSpOffset); + } + + m_SlotArray[i].Slot.Stack.SpOffset = spOffset; + m_SlotArray[i].Slot.Stack.Base = spBase; + m_SlotArray[i].Flags = flags; + } + } + + // Done pre-decoding + + if(i < m_NumSlots) + { + // Prepare for lazy decoding + + _ASSERTE(i == MAX_PREDECODED_SLOTS); + m_NumDecodedSlots = i; + m_pLastSlot = &m_SlotArray[MAX_PREDECODED_SLOTS - 1]; + + m_SlotReader = reader; + + // Move the argument reader past the end of the table + + GcSlotFlags flags = m_pLastSlot->Flags; + + // Skip any remaining registers + + for(; i < m_NumRegisters; i++) + { + if(flags) + { + reader.DecodeVarLengthUnsigned(REGISTER_ENCBASE); + flags = (GcSlotFlags) reader.Read(2); + } + else + { + reader.DecodeVarLengthUnsigned(REGISTER_DELTA_ENCBASE); + } + } + + if(numStackSlots > 0) + { + if(i == m_NumRegisters) + { + // Skip the first stack slot + + reader.Read(2); + reader.DecodeVarLengthSigned(STACK_SLOT_ENCBASE); + flags = (GcSlotFlags) reader.Read(2); + i++; + } + + // Skip any remaining stack slots + + const UINT32 loopEnd = m_NumRegisters + numStackSlots; + for(; i < loopEnd; i++) + { + reader.Read(2); + + if(flags) + { + reader.DecodeVarLengthSigned(STACK_SLOT_ENCBASE); + flags = (GcSlotFlags) reader.Read(2); + } + else + { + reader.DecodeVarLengthUnsigned(STACK_SLOT_DELTA_ENCBASE); + } + } + } + + if(m_NumUntracked > 0) + { + if(i == m_NumRegisters + numStackSlots) + { + // Skip the first untracked slot + + reader.Read(2); + reader.DecodeVarLengthSigned(STACK_SLOT_ENCBASE); + flags = (GcSlotFlags) reader.Read(2); + i++; + } + + // Skip any remaining untracked slots + + for(; i < m_NumSlots; i++) + { + reader.Read(2); + + if(flags) + { + reader.DecodeVarLengthSigned(STACK_SLOT_ENCBASE); + flags = (GcSlotFlags) reader.Read(2); + } + else + { + reader.DecodeVarLengthUnsigned(STACK_SLOT_DELTA_ENCBASE); + } + } + } + } +} + +const GcSlotDesc* GcSlotDecoder::GetSlotDesc(UINT32 slotIndex) +{ + _ASSERTE(slotIndex < m_NumSlots); + + if(slotIndex < MAX_PREDECODED_SLOTS) + { + return &m_SlotArray[slotIndex]; + } + + _ASSERTE(m_NumDecodedSlots >= MAX_PREDECODED_SLOTS && m_NumDecodedSlots < m_NumSlots); + _ASSERTE(m_NumDecodedSlots <= slotIndex); + + while(m_NumDecodedSlots <= slotIndex) + { + if(m_NumDecodedSlots < m_NumRegisters) + { + // + // Decode a register + // + + if(m_NumDecodedSlots == 0) + { + // Decode the first register + UINT32 normRegNum = (UINT32) m_SlotReader.DecodeVarLengthUnsigned(REGISTER_ENCBASE); + m_pLastSlot->Slot.RegisterNumber = DENORMALIZE_REGISTER(normRegNum); + m_pLastSlot->Flags = (GcSlotFlags) m_SlotReader.Read(2); + } + else + { + if(m_pLastSlot->Flags) + { + UINT32 normRegNum = (UINT32) m_SlotReader.DecodeVarLengthUnsigned(REGISTER_ENCBASE); + m_pLastSlot->Slot.RegisterNumber = DENORMALIZE_REGISTER(normRegNum); + m_pLastSlot->Flags = (GcSlotFlags) m_SlotReader.Read(2); + } + else + { + UINT32 normRegDelta = (UINT32) m_SlotReader.DecodeVarLengthUnsigned(REGISTER_DELTA_ENCBASE) + 1; + UINT32 normRegNum = normRegDelta + NORMALIZE_REGISTER(m_pLastSlot->Slot.RegisterNumber); + m_pLastSlot->Slot.RegisterNumber = DENORMALIZE_REGISTER(normRegNum); + } + } + } + else + { + // + // Decode a stack slot + // + + if((m_NumDecodedSlots == m_NumRegisters) || (m_NumDecodedSlots == GetNumTracked())) + { + // Decode the first stack slot or first untracked slot + m_pLastSlot->Slot.Stack.Base = (GcStackSlotBase) m_SlotReader.Read(2); + UINT32 normSpOffset = (INT32) m_SlotReader.DecodeVarLengthSigned(STACK_SLOT_ENCBASE); + m_pLastSlot->Slot.Stack.SpOffset = DENORMALIZE_STACK_SLOT(normSpOffset); + m_pLastSlot->Flags = (GcSlotFlags) m_SlotReader.Read(2); + } + else + { + m_pLastSlot->Slot.Stack.Base = (GcStackSlotBase) m_SlotReader.Read(2); + + if(m_pLastSlot->Flags) + { + INT32 normSpOffset = (INT32) m_SlotReader.DecodeVarLengthSigned(STACK_SLOT_ENCBASE); + m_pLastSlot->Slot.Stack.SpOffset = DENORMALIZE_STACK_SLOT(normSpOffset); + m_pLastSlot->Flags = (GcSlotFlags) m_SlotReader.Read(2); + } + else + { + INT32 normSpOffsetDelta = (INT32) m_SlotReader.DecodeVarLengthUnsigned(STACK_SLOT_DELTA_ENCBASE); + INT32 normSpOffset = normSpOffsetDelta + NORMALIZE_STACK_SLOT(m_pLastSlot->Slot.Stack.SpOffset); + m_pLastSlot->Slot.Stack.SpOffset = DENORMALIZE_STACK_SLOT(normSpOffset); + } + } + } + + m_NumDecodedSlots++; + } + + return m_pLastSlot; +} + + +//----------------------------------------------------------------------------- +// Platform-specific methods +//----------------------------------------------------------------------------- + +#if defined(_TARGET_AMD64_) + + +OBJECTREF* GcInfoDecoder::GetRegisterSlot( + int regNum, + PREGDISPLAY pRD + ) +{ + _ASSERTE(regNum >= 0 && regNum <= 16); + _ASSERTE(regNum != 4); // rsp + +#ifdef FEATURE_REDHAWK + PTR_UIntNative* ppRax = &pRD->pRax; + if (regNum > 4) regNum--; // rsp is skipped in Redhawk RegDisplay +#else + // The fields of KNONVOLATILE_CONTEXT_POINTERS are in the same order as + // the processor encoding numbers. + + ULONGLONG **ppRax = &pRD->pCurrentContextPointers->Rax; +#endif + + return (OBJECTREF*)*(ppRax + regNum); +} + +#ifdef FEATURE_PAL +OBJECTREF* GcInfoDecoder::GetCapturedRegister( + int regNum, + PREGDISPLAY pRD + ) +{ + _ASSERTE(regNum >= 0 && regNum <= 16); + _ASSERTE(regNum != 4); // rsp + + // The fields of CONTEXT are in the same order as + // the processor encoding numbers. + + ULONGLONG *pRax = &pRD->pCurrentContext->Rax; + + return (OBJECTREF*)(pRax + regNum); +} +#endif // FEATURE_PAL + +bool GcInfoDecoder::IsScratchRegister(int regNum, PREGDISPLAY pRD) +{ + _ASSERTE(regNum >= 0 && regNum <= 16); + _ASSERTE(regNum != 4); // rsp + + UINT16 PreservedRegMask = + (1 << 3) // rbx + | (1 << 5) // rbp +#ifndef UNIX_AMD64_ABI + | (1 << 6) // rsi + | (1 << 7) // rdi +#endif // UNIX_AMD64_ABI + | (1 << 12) // r12 + | (1 << 13) // r13 + | (1 << 14) // r14 + | (1 << 15); // r15 + + return !(PreservedRegMask & (1 << regNum)); +} + + +bool GcInfoDecoder::IsScratchStackSlot(INT32 spOffset, GcStackSlotBase spBase, PREGDISPLAY pRD) +{ +#ifdef FIXED_STACK_PARAMETER_SCRATCH_AREA + _ASSERTE( m_Flags & DECODE_GC_LIFETIMES ); + + TADDR pSlot = (TADDR) GetStackSlot(spOffset, spBase, pRD); + _ASSERTE(pSlot >= pRD->SP); + + return (pSlot < pRD->SP + m_SizeOfStackOutgoingAndScratchArea); +#else + return FALSE; +#endif +} + + +void GcInfoDecoder::ReportRegisterToGC( // AMD64 + int regNum, + unsigned gcFlags, + PREGDISPLAY pRD, + unsigned flags, + GCEnumCallback pCallBack, + void * hCallBack) +{ + GCINFODECODER_CONTRACT; + + _ASSERTE(regNum >= 0 && regNum <= 16); + _ASSERTE(regNum != 4); // rsp + + LOG((LF_GCROOTS, LL_INFO1000, "Reporting " FMT_REG, regNum )); + + OBJECTREF* pObjRef = GetRegisterSlot( regNum, pRD ); +#if defined(FEATURE_PAL) && !defined(SOS_TARGET_AMD64) + // On PAL, we don't always have the context pointers available due to + // a limitation of an unwinding library. In such case, the context + // pointers for some nonvolatile registers are NULL. + // In such case, we let the pObjRef point to the captured register + // value in the context and pin the object itself. + if (pObjRef == NULL) + { + // Report a pinned object to GC only in the promotion phase when the + // GC is scanning roots. + GCCONTEXT* pGCCtx = (GCCONTEXT*)(hCallBack); + if (!pGCCtx->sc->promotion) + { + return; + } + + pObjRef = GetCapturedRegister(regNum, pRD); + + gcFlags |= GC_CALL_PINNED; + } +#endif // FEATURE_PAL && !SOS_TARGET_AMD64 + +#ifdef _DEBUG + if(IsScratchRegister(regNum, pRD)) + { + // Scratch registers cannot be reported for non-leaf frames + _ASSERTE(flags & ActiveStackFrame); + } + + LOG((LF_GCROOTS, LL_INFO1000, /* Part Two */ + "at" FMT_ADDR "as ", DBG_ADDR(pObjRef) )); + + VALIDATE_ROOT((gcFlags & GC_CALL_INTERIOR), hCallBack, pObjRef); + + LOG_PIPTR(pObjRef, gcFlags, hCallBack); +#endif //_DEBUG + + gcFlags |= CHECK_APP_DOMAIN; + + pCallBack(hCallBack, pObjRef, gcFlags DAC_ARG(DacSlotLocation(regNum, 0, false))); +} + +#elif defined(_TARGET_ARM_) + +OBJECTREF* GcInfoDecoder::GetRegisterSlot( + int regNum, + PREGDISPLAY pRD + ) +{ + _ASSERTE(regNum >= 0 && regNum <= 14); + _ASSERTE(regNum != 13); // sp + + DWORD **ppReg; + + if(regNum <= 3) + { + ppReg = &pRD->volatileCurrContextPointers.R0; + return (OBJECTREF*)*(ppReg + regNum); + } + else if(regNum == 12) + { + return (OBJECTREF*) pRD->volatileCurrContextPointers.R12; + } + else if(regNum == 14) + { + return (OBJECTREF*) pRD->pCurrentContextPointers->Lr; + } + + ppReg = &pRD->pCurrentContextPointers->R4; + + return (OBJECTREF*)*(ppReg + regNum-4); + +} + +#ifdef FEATURE_PAL +OBJECTREF* GcInfoDecoder::GetCapturedRegister( + int regNum, + PREGDISPLAY pRD + ) +{ + _ASSERTE(regNum >= 0 && regNum <= 14); + _ASSERTE(regNum != 13); // sp + + // The fields of CONTEXT are in the same order as + // the processor encoding numbers. + + ULONG *pR0 = &pRD->pCurrentContext->R0; + + return (OBJECTREF*)(pR0 + regNum); +} +#endif // FEATURE_PAL + + +bool GcInfoDecoder::IsScratchRegister(int regNum, PREGDISPLAY pRD) +{ + _ASSERTE(regNum >= 0 && regNum <= 14); + _ASSERTE(regNum != 13); // sp + + return regNum <= 3 || regNum >= 12; // R12 and R14/LR are both scratch registers +} + + +bool GcInfoDecoder::IsScratchStackSlot(INT32 spOffset, GcStackSlotBase spBase, PREGDISPLAY pRD) +{ +#ifdef FIXED_STACK_PARAMETER_SCRATCH_AREA + _ASSERTE( m_Flags & DECODE_GC_LIFETIMES ); + + TADDR pSlot = (TADDR) GetStackSlot(spOffset, spBase, pRD); + _ASSERTE(pSlot >= pRD->SP); + + return (pSlot < pRD->SP + m_SizeOfStackOutgoingAndScratchArea); +#else + return FALSE; +#endif +} + + +void GcInfoDecoder::ReportRegisterToGC( // ARM + int regNum, + unsigned gcFlags, + PREGDISPLAY pRD, + unsigned flags, + GCEnumCallback pCallBack, + void * hCallBack) +{ + GCINFODECODER_CONTRACT; + + _ASSERTE(regNum >= 0 && regNum <= 14); + _ASSERTE(regNum != 13); // sp + + LOG((LF_GCROOTS, LL_INFO1000, "Reporting " FMT_REG, regNum )); + + OBJECTREF* pObjRef = GetRegisterSlot( regNum, pRD ); + +#ifdef _DEBUG + if(IsScratchRegister(regNum, pRD)) + { + // Scratch registers cannot be reported for non-leaf frames + _ASSERTE(flags & ActiveStackFrame); + } + + LOG((LF_GCROOTS, LL_INFO1000, /* Part Two */ + "at" FMT_ADDR "as ", DBG_ADDR(pObjRef) )); + + VALIDATE_ROOT((gcFlags & GC_CALL_INTERIOR), hCallBack, pObjRef); + + LOG_PIPTR(pObjRef, gcFlags, hCallBack); +#endif //_DEBUG + + gcFlags |= CHECK_APP_DOMAIN; + + pCallBack(hCallBack, pObjRef, gcFlags DAC_ARG(DacSlotLocation(regNum, 0, false))); +} + +#elif defined(_TARGET_ARM64_) + +OBJECTREF* GcInfoDecoder::GetRegisterSlot( + int regNum, + PREGDISPLAY pRD + ) +{ + _ASSERTE(regNum >= 0 && regNum <= 30); + _ASSERTE(regNum != 18); // TEB + + DWORD64 **ppReg; + + if(regNum <= 17) + { + ppReg = &pRD->volatileCurrContextPointers.X0; + return (OBJECTREF*)*(ppReg + regNum); + } + else if(regNum == 29) + { + return (OBJECTREF*) pRD->pCurrentContextPointers->Fp; + } + else if(regNum == 30) + { + return (OBJECTREF*) pRD->pCurrentContextPointers->Lr; + } + + ppReg = &pRD->pCurrentContextPointers->X19; + + return (OBJECTREF*)*(ppReg + regNum-19); +} + +bool GcInfoDecoder::IsScratchRegister(int regNum, PREGDISPLAY pRD) +{ + _ASSERTE(regNum >= 0 && regNum <= 30); + _ASSERTE(regNum != 18); + + return regNum <= 17 || regNum >= 29; // R12 and R14/LR are both scratch registers +} + +bool GcInfoDecoder::IsScratchStackSlot(INT32 spOffset, GcStackSlotBase spBase, PREGDISPLAY pRD) +{ +#ifdef FIXED_STACK_PARAMETER_SCRATCH_AREA + _ASSERTE( m_Flags & DECODE_GC_LIFETIMES ); + + TADDR pSlot = (TADDR) GetStackSlot(spOffset, spBase, pRD); + _ASSERTE(pSlot >= pRD->SP); + + return (pSlot < pRD->SP + m_SizeOfStackOutgoingAndScratchArea); +#else + return FALSE; +#endif + +} + +void GcInfoDecoder::ReportRegisterToGC( // ARM64 + int regNum, + unsigned gcFlags, + PREGDISPLAY pRD, + unsigned flags, + GCEnumCallback pCallBack, + void * hCallBack) +{ + GCINFODECODER_CONTRACT; + + _ASSERTE(regNum >= 0 && regNum <= 30); + _ASSERTE(regNum != 18); + + LOG((LF_GCROOTS, LL_INFO1000, "Reporting " FMT_REG, regNum )); + + OBJECTREF* pObjRef = GetRegisterSlot( regNum, pRD ); + +#ifdef _DEBUG + if(IsScratchRegister(regNum, pRD)) + { + // Scratch registers cannot be reported for non-leaf frames + _ASSERTE(flags & ActiveStackFrame); + } + + LOG((LF_GCROOTS, LL_INFO1000, /* Part Two */ + "at" FMT_ADDR "as ", DBG_ADDR(pObjRef) )); + + VALIDATE_ROOT((gcFlags & GC_CALL_INTERIOR), hCallBack, pObjRef); + + LOG_PIPTR(pObjRef, gcFlags, hCallBack); +#endif //_DEBUG + + gcFlags |= CHECK_APP_DOMAIN; + + pCallBack(hCallBack, pObjRef, gcFlags DAC_ARG(DacSlotLocation(regNum, 0, false))); +} + +#ifdef FEATURE_PAL +OBJECTREF* GcInfoDecoder::GetCapturedRegister( + int regNum, + PREGDISPLAY pRD + ) +{ + _ASSERTE(regNum >= 0 && regNum <= 28); + + // The fields of CONTEXT are in the same order as + // the processor encoding numbers. + + DWORD64 *pX0 = &pRD->pCurrentContext->X0; + + return (OBJECTREF*)(pX0 + regNum); +} +#endif // FEATURE_PAL + +#else // Unknown platform + +OBJECTREF* GcInfoDecoder::GetRegisterSlot( + int regNum, + PREGDISPLAY pRD + ) +{ + PORTABILITY_ASSERT("GcInfoDecoder::GetRegisterSlot"); + return NULL; +} + +bool GcInfoDecoder::IsScratchRegister(int regNum, PREGDISPLAY pRD) +{ + PORTABILITY_ASSERT("GcInfoDecoder::IsScratchRegister"); + return false; +} + +bool GcInfoDecoder::IsScratchStackSlot(INT32 spOffset, GcStackSlotBase spBase, PREGDISPLAY pRD) +{ + _ASSERTE( !"NYI" ); + return false; +} + +void GcInfoDecoder::ReportRegisterToGC( + int regNum, + unsigned gcFlags, + PREGDISPLAY pRD, + unsigned flags, + GCEnumCallback pCallBack, + void * hCallBack) +{ + _ASSERTE( !"NYI" ); +} + +#endif // Unknown platform + + +OBJECTREF* GcInfoDecoder::GetStackSlot( + INT32 spOffset, + GcStackSlotBase spBase, + PREGDISPLAY pRD + ) +{ +#ifdef CROSSGEN_COMPILE + _ASSERTE(!"GcInfoDecoder::GetStackSlot not supported in this build configuration"); + return NULL; +#else // CROSSGEN_COMPILE + OBJECTREF* pObjRef; + + if( GC_SP_REL == spBase ) + { + pObjRef = (OBJECTREF*) ((SIZE_T)pRD->SP + spOffset); + } + else if( GC_CALLER_SP_REL == spBase ) + { + pObjRef = (OBJECTREF*) (GET_CALLER_SP(pRD) + spOffset); + } + else + { + _ASSERTE( GC_FRAMEREG_REL == spBase ); + _ASSERTE( NO_STACK_BASE_REGISTER != m_StackBaseRegister ); + + SIZE_T * pFrameReg = (SIZE_T*) GetRegisterSlot(m_StackBaseRegister, pRD); + +#ifdef FEATURE_PAL + // On PAL, we don't always have the context pointers available due to + // a limitation of an unwinding library. In such case, the context + // pointers for some nonvolatile registers are NULL. + if (pFrameReg == NULL) + { + pFrameReg = (SIZE_T*) GetCapturedRegister(m_StackBaseRegister, pRD); + } +#endif // FEATURE_PAL + + pObjRef = (OBJECTREF*)(*pFrameReg + spOffset); + } + + return pObjRef; +#endif // CROSSGEN_COMPILE +} + +#ifdef DACCESS_COMPILE +int GcInfoDecoder::GetStackReg(int spBase) +{ +#if defined(_TARGET_AMD64_) + int esp = 4; +#elif defined(_TARGET_ARM_) + int esp = 13; +#elif defined(_TARGET_ARM64_) + int esp = 31; +#endif + + if( GC_SP_REL == spBase ) + return esp; + else if ( GC_CALLER_SP_REL == spBase ) + return -(esp+1); + else + return m_StackBaseRegister; +} +#endif // DACCESS_COMPILE + +void GcInfoDecoder::ReportStackSlotToGC( + INT32 spOffset, + GcStackSlotBase spBase, + unsigned gcFlags, + PREGDISPLAY pRD, + unsigned flags, + GCEnumCallback pCallBack, + void * hCallBack) +{ + GCINFODECODER_CONTRACT; + + OBJECTREF* pObjRef = GetStackSlot(spOffset, spBase, pRD); + _ASSERTE( IS_ALIGNED( pObjRef, sizeof( Object* ) ) ); + +#ifdef _DEBUG + LOG((LF_GCROOTS, LL_INFO1000, /* Part One */ + "Reporting %s" FMT_STK, + ( (GC_SP_REL == spBase) ? "" : + ((GC_CALLER_SP_REL == spBase) ? "caller's " : + ((GC_FRAMEREG_REL == spBase) ? "frame " : " "))), + DBG_STK(spOffset) )); + + LOG((LF_GCROOTS, LL_INFO1000, /* Part Two */ + "at" FMT_ADDR "as ", DBG_ADDR(pObjRef) )); + + VALIDATE_ROOT((gcFlags & GC_CALL_INTERIOR), hCallBack, pObjRef); + + LOG_PIPTR(pObjRef, gcFlags, hCallBack); +#endif + + gcFlags |= CHECK_APP_DOMAIN; + + pCallBack(hCallBack, pObjRef, gcFlags DAC_ARG(DacSlotLocation(GetStackReg(spBase), spOffset, true))); +} + + +#endif // USE_GC_INFO_DECODER + diff --git a/src/gcinfo/gcinfodumper.cpp b/src/SOS/gcdump/gcinfodumper.cpp similarity index 99% rename from src/gcinfo/gcinfodumper.cpp rename to src/SOS/gcdump/gcinfodumper.cpp index a9a096f81..618b23074 100644 --- a/src/gcinfo/gcinfodumper.cpp +++ b/src/SOS/gcdump/gcinfodumper.cpp @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -#include "common.h" #include "gcinfodumper.h" #include "gcinfodecoder.h" diff --git a/src/gcdump/i386/gcdumpx86.cpp b/src/SOS/gcdump/i386/gcdumpx86.cpp similarity index 100% rename from src/gcdump/i386/gcdumpx86.cpp rename to src/SOS/gcdump/i386/gcdumpx86.cpp diff --git a/src/SOS/lldbplugin/CMakeLists.txt b/src/SOS/lldbplugin/CMakeLists.txt index 5d3f11338..edf6d84f6 100644 --- a/src/SOS/lldbplugin/CMakeLists.txt +++ b/src/SOS/lldbplugin/CMakeLists.txt @@ -23,24 +23,8 @@ if(SKIP_LLDBPLUGIN) endif() if(CLR_CMAKE_PLATFORM_ARCH_AMD64) - add_definitions(-D_TARGET_AMD64_=1) - add_definitions(-DDBG_TARGET_64BIT=1) - add_definitions(-DDBG_TARGET_AMD64=1) - add_definitions(-DDBG_TARGET_WIN64=1) add_definitions(-DBIT64) -elseif(CLR_CMAKE_PLATFORM_ARCH_I386) - add_definitions(-D_TARGET_X86_=1) - add_definitions(-DDBG_TARGET_32BIT=1) - add_definitions(-DDBG_TARGET_X86=1) elseif(CLR_CMAKE_PLATFORM_ARCH_ARM) - add_definitions(-D_TARGET_ARM_=1) - add_definitions(-DDBG_TARGET_32BIT=1) - add_definitions(-DDBG_TARGET_ARM=1) -elseif(CLR_CMAKE_PLATFORM_ARCH_ARM64) - add_definitions(-D_TARGET_ARM64_=1) - add_definitions(-DDBG_TARGET_64BIT=1) - add_definitions(-DDBG_TARGET_ARM64=1) - add_definitions(-DDBG_TARGET_WIN64=1) add_definitions(-DBIT64) SET(REQUIRE_LLDBPLUGIN false) endif() diff --git a/src/SOS/lldbplugin/inc/crosscomp.h b/src/SOS/lldbplugin/inc/crosscomp.h deleted file mode 100644 index 200c343a4..000000000 --- a/src/SOS/lldbplugin/inc/crosscomp.h +++ /dev/null @@ -1,365 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -// -// crosscomp.h - cross-compilation enablement structures. -// - - -#pragma once - -#if defined(_X86_) && defined(_TARGET_ARM_) // Host X86 managing ARM related code - -#ifndef CROSS_COMPILE -#define CROSS_COMPILE -#endif - -#define ARM_MAX_BREAKPOINTS 8 -#define ARM_MAX_WATCHPOINTS 1 - -#define CONTEXT_UNWOUND_TO_CALL 0x20000000 - -typedef struct _NEON128 { - ULONGLONG Low; - LONGLONG High; -} NEON128, *PNEON128; - -typedef struct DECLSPEC_ALIGN(8) _T_CONTEXT { - // - // Control flags. - // - - DWORD ContextFlags; - - // - // Integer registers - // - - DWORD R0; - DWORD R1; - DWORD R2; - DWORD R3; - DWORD R4; - DWORD R5; - DWORD R6; - DWORD R7; - DWORD R8; - DWORD R9; - DWORD R10; - DWORD R11; - DWORD R12; - - // - // Control Registers - // - - DWORD Sp; - DWORD Lr; - DWORD Pc; - DWORD Cpsr; - - // - // Floating Point/NEON Registers - // - - DWORD Fpscr; - DWORD Padding; - union { - NEON128 Q[16]; - ULONGLONG D[32]; - DWORD S[32]; - }; - - // - // Debug registers - // - - DWORD Bvr[ARM_MAX_BREAKPOINTS]; - DWORD Bcr[ARM_MAX_BREAKPOINTS]; - DWORD Wvr[ARM_MAX_WATCHPOINTS]; - DWORD Wcr[ARM_MAX_WATCHPOINTS]; - - DWORD Padding2[2]; - -} T_CONTEXT, *PT_CONTEXT; - -// -// Define function table entry - a function table entry is generated for -// each frame function. -// - -#ifndef FEATURE_PAL -typedef struct _RUNTIME_FUNCTION { - DWORD BeginAddress; - DWORD UnwindData; -} RUNTIME_FUNCTION, *PRUNTIME_FUNCTION; - -// -// Define unwind history table structure. -// - -#define UNWIND_HISTORY_TABLE_SIZE 12 - -typedef struct _UNWIND_HISTORY_TABLE_ENTRY { - DWORD ImageBase; - PRUNTIME_FUNCTION FunctionEntry; -} UNWIND_HISTORY_TABLE_ENTRY, *PUNWIND_HISTORY_TABLE_ENTRY; - -typedef struct _UNWIND_HISTORY_TABLE { - DWORD Count; - BYTE LocalHint; - BYTE GlobalHint; - BYTE Search; - BYTE Once; - DWORD LowAddress; - DWORD HighAddress; - UNWIND_HISTORY_TABLE_ENTRY Entry[UNWIND_HISTORY_TABLE_SIZE]; -} UNWIND_HISTORY_TABLE, *PUNWIND_HISTORY_TABLE; -#endif // !FEATURE_PAL - - -// -// Nonvolatile context pointer record. -// - -typedef struct _T_KNONVOLATILE_CONTEXT_POINTERS { - - PDWORD R4; - PDWORD R5; - PDWORD R6; - PDWORD R7; - PDWORD R8; - PDWORD R9; - PDWORD R10; - PDWORD R11; - PDWORD Lr; - - PULONGLONG D8; - PULONGLONG D9; - PULONGLONG D10; - PULONGLONG D11; - PULONGLONG D12; - PULONGLONG D13; - PULONGLONG D14; - PULONGLONG D15; - -} T_KNONVOLATILE_CONTEXT_POINTERS, *PT_KNONVOLATILE_CONTEXT_POINTERS; - -// -// Define dynamic function table entry. -// - -typedef -PRUNTIME_FUNCTION -(*PGET_RUNTIME_FUNCTION_CALLBACK) ( - IN DWORD64 ControlPc, - IN PVOID Context - ); - -typedef struct _T_DISPATCHER_CONTEXT { - ULONG ControlPc; - ULONG ImageBase; - PRUNTIME_FUNCTION FunctionEntry; - ULONG EstablisherFrame; - ULONG TargetPc; - PT_CONTEXT ContextRecord; - PEXCEPTION_ROUTINE LanguageHandler; - PVOID HandlerData; - PUNWIND_HISTORY_TABLE HistoryTable; - ULONG ScopeIndex; - BOOLEAN ControlPcIsUnwound; - PUCHAR NonVolatileRegisters; -} T_DISPATCHER_CONTEXT, *PT_DISPATCHER_CONTEXT; - -#define T_RUNTIME_FUNCTION RUNTIME_FUNCTION -#define PT_RUNTIME_FUNCTION PRUNTIME_FUNCTION - -#elif defined(_AMD64_) && defined(_TARGET_ARM64_) // Host amd64 managing ARM64 related code - -#ifndef CROSS_COMPILE -#define CROSS_COMPILE -#endif - -// -// Specify the number of breakpoints and watchpoints that the OS -// will track. Architecturally, ARM64 supports up to 16. In practice, -// however, almost no one implements more than 4 of each. -// - -#define ARM64_MAX_BREAKPOINTS 8 -#define ARM64_MAX_WATCHPOINTS 2 - -#define CONTEXT_UNWOUND_TO_CALL 0x20000000 - -typedef union _NEON128 { - struct { - ULONGLONG Low; - LONGLONG High; - }; - double D[2]; - float S[4]; - WORD H[8]; - BYTE B[16]; -} NEON128, *PNEON128; - -typedef struct DECLSPEC_ALIGN(16) _T_CONTEXT { - - // - // Control flags. - // - - /* +0x000 */ DWORD ContextFlags; - - // - // Integer registers - // - - /* +0x004 */ DWORD Cpsr; // NZVF + DAIF + CurrentEL + SPSel - /* +0x008 */ union { - struct { - DWORD64 X0; - DWORD64 X1; - DWORD64 X2; - DWORD64 X3; - DWORD64 X4; - DWORD64 X5; - DWORD64 X6; - DWORD64 X7; - DWORD64 X8; - DWORD64 X9; - DWORD64 X10; - DWORD64 X11; - DWORD64 X12; - DWORD64 X13; - DWORD64 X14; - DWORD64 X15; - DWORD64 X16; - DWORD64 X17; - DWORD64 X18; - DWORD64 X19; - DWORD64 X20; - DWORD64 X21; - DWORD64 X22; - DWORD64 X23; - DWORD64 X24; - DWORD64 X25; - DWORD64 X26; - DWORD64 X27; - DWORD64 X28; - }; - DWORD64 X[29]; - }; - /* +0x0f0 */ DWORD64 Fp; - /* +0x0f8 */ DWORD64 Lr; - /* +0x100 */ DWORD64 Sp; - /* +0x108 */ DWORD64 Pc; - - // - // Floating Point/NEON Registers - // - - /* +0x110 */ NEON128 V[32]; - /* +0x310 */ DWORD Fpcr; - /* +0x314 */ DWORD Fpsr; - - // - // Debug registers - // - - /* +0x318 */ DWORD Bcr[ARM64_MAX_BREAKPOINTS]; - /* +0x338 */ DWORD64 Bvr[ARM64_MAX_BREAKPOINTS]; - /* +0x378 */ DWORD Wcr[ARM64_MAX_WATCHPOINTS]; - /* +0x380 */ DWORD64 Wvr[ARM64_MAX_WATCHPOINTS]; - /* +0x390 */ - -} T_CONTEXT, *PT_CONTEXT; - -// _IMAGE_ARM64_RUNTIME_FUNCTION_ENTRY (see ExternalAPIs\Win9CoreSystem\inc\winnt.h) -typedef struct _T_RUNTIME_FUNCTION { - DWORD BeginAddress; - union { - DWORD UnwindData; - struct { - DWORD Flag : 2; - DWORD FunctionLength : 11; - DWORD RegF : 3; - DWORD RegI : 4; - DWORD H : 1; - DWORD CR : 2; - DWORD FrameSize : 9; - } PackedUnwindData; - }; -} T_RUNTIME_FUNCTION, *PT_RUNTIME_FUNCTION; - - -// -// Define exception dispatch context structure. -// - -typedef struct _T_DISPATCHER_CONTEXT { - DWORD64 ControlPc; - DWORD64 ImageBase; - PT_RUNTIME_FUNCTION FunctionEntry; - DWORD64 EstablisherFrame; - DWORD64 TargetPc; - PCONTEXT ContextRecord; - PEXCEPTION_ROUTINE LanguageHandler; - PVOID HandlerData; - PUNWIND_HISTORY_TABLE HistoryTable; - DWORD ScopeIndex; - BOOLEAN ControlPcIsUnwound; - PBYTE NonVolatileRegisters; -} T_DISPATCHER_CONTEXT, *PT_DISPATCHER_CONTEXT; - - - -// -// Nonvolatile context pointer record. -// - -typedef struct _T_KNONVOLATILE_CONTEXT_POINTERS { - - PDWORD64 X19; - PDWORD64 X20; - PDWORD64 X21; - PDWORD64 X22; - PDWORD64 X23; - PDWORD64 X24; - PDWORD64 X25; - PDWORD64 X26; - PDWORD64 X27; - PDWORD64 X28; - PDWORD64 Fp; - PDWORD64 Lr; - - PDWORD64 D8; - PDWORD64 D9; - PDWORD64 D10; - PDWORD64 D11; - PDWORD64 D12; - PDWORD64 D13; - PDWORD64 D14; - PDWORD64 D15; - -} T_KNONVOLATILE_CONTEXT_POINTERS, *PT_KNONVOLATILE_CONTEXT_POINTERS; - -#else // !(defined(_X86_) && defined(_TARGET_ARM_)) && !(defined(_AMD64_) && defined(_TARGET_ARM64_)) - -#define T_CONTEXT CONTEXT -#define PT_CONTEXT PCONTEXT - -#define T_DISPATCHER_CONTEXT DISPATCHER_CONTEXT -#define PT_DISPATCHER_CONTEXT PDISPATCHER_CONTEXT - -#define T_KNONVOLATILE_CONTEXT_POINTERS KNONVOLATILE_CONTEXT_POINTERS -#define PT_KNONVOLATILE_CONTEXT_POINTERS PKNONVOLATILE_CONTEXT_POINTERS - -#define T_RUNTIME_FUNCTION RUNTIME_FUNCTION -#define PT_RUNTIME_FUNCTION PRUNTIME_FUNCTION - -#endif - - -#ifdef CROSSGEN_COMPILE -void CrossGenNotSupported(const char * message); -#endif diff --git a/src/SOS/lldbplugin/inc/dbgportable.h b/src/SOS/lldbplugin/inc/dbgportable.h deleted file mode 100644 index 4a035642c..000000000 --- a/src/SOS/lldbplugin/inc/dbgportable.h +++ /dev/null @@ -1,141 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#ifndef __DBG_PORTABLE_INCLUDED -#define __DBG_PORTABLE_INCLUDED - -// -// This header defines the template class Portable which is designed to wrap primitive types in such a way -// that their physical representation is in a canonical format that can be safely transferred between hosts on -// different platforms. -// -// This is achieved by storing the wrapped datum in little-endian format (since most of our platforms are -// little-endian this makes the most sense from a performance perspective). On little-endian platforms the -// wrapper code will become a no-op and get optimized away by the compiler. On big-endian platforms -// assignments to a Portable value will reverse the order of the bytes in the T value and reverse them back -// again on a read. -// -// Portable is typically used to wrap the fields of structures sent directly over a network channel. In -// this fashion many of the values that would otherwise require manual endian-ness fixups are now marshalled -// and unmarshalled transparent right at the network transition. -// -// Care must be taken to identify any code that takes the address of a Portable, since this is not -// generally safe (it could expose naive code to the network encoded form of the datum). In such situations -// the code is normally re-written to create a temporary instance of T on the stack, initialized to the -// correct host value by reading from the Portable field. The address of this variable can now be taken -// safely (assuming its value is required only for some lexically scoped operation). Once the value is no -// longer being used, and if there is a possibility that the value may have been updated, the new value can be -// copied back into the Portable field. -// -// Note that this header uses very basic data types only as it is included from both Win32/PAL code and native -// Mac code. -// - -#if BIGENDIAN || __BIG_ENDIAN__ -#define DBG_BYTE_SWAP_REQUIRED -#endif - -#if defined(_ASSERTE) -#define _PASSERT(_expr) _ASSERTE(_expr) -#elif defined(assert) -#define _PASSERT(_expr) assert(_expr) -#else -#define _PASSERT(_expr) -#endif - -// Lowest level helper used to reverse the order of a sequence of bytes, either as an in-place operation or as -// part of a copy. -inline void ByteSwapPrimitive(const void *pSrc, void *pDst, unsigned int cbSize) -{ - _PASSERT(cbSize == 2 || cbSize == 4 || cbSize == 8); - - unsigned char *pbSrc = (unsigned char*)pSrc; - unsigned char *pbDst = (unsigned char*)pDst; - - for (unsigned int i = 0; i < (cbSize / 2); i++) - { - unsigned int j = cbSize - i - 1; - unsigned char bTemp = pbSrc[i]; - pbDst[i] = pbSrc[j]; - pbDst[j] = bTemp; - } -} - -template -class Portable -{ - T m_data; - -public: - // No constructors -- this will be used in unions. - - // Convert data to portable format on assignment. - T operator = (T value) - { - _PASSERT(sizeof(value) <= sizeof(double)); -#ifdef DBG_BYTE_SWAP_REQUIRED - m_data = ByteSwap(value); -#else // DBG_BYTE_SWAP_REQUIRED - m_data = value; -#endif // DBG_BYTE_SWAP_REQUIRED - return value; - } - - // Return data in native format on access. - operator T () const - { -#ifdef DBG_BYTE_SWAP_REQUIRED - return ByteSwap(m_data); -#else // DBG_BYTE_SWAP_REQUIRED - return m_data; -#endif // DBG_BYTE_SWAP_REQUIRED - } - - bool operator == (T other) const - { -#ifdef DBG_BYTE_SWAP_REQUIRED - return ByteSwap(m_data) == other; -#else // DBG_BYTE_SWAP_REQUIRED - return m_data == other; -#endif // DBG_BYTE_SWAP_REQUIRED - } - - bool operator != (T other) const - { -#ifdef DBG_BYTE_SWAP_REQUIRED - return ByteSwap(m_data) != other; -#else // DBG_BYTE_SWAP_REQUIRED - return m_data != other; -#endif // DBG_BYTE_SWAP_REQUIRED - } - - T Unwrap() - { -#ifdef DBG_BYTE_SWAP_REQUIRED - return ByteSwap(m_data); -#else // DBG_BYTE_SWAP_REQUIRED - return m_data; -#endif // DBG_BYTE_SWAP_REQUIRED - } - -private: -#ifdef DBG_BYTE_SWAP_REQUIRED - // Big endian helper routine to swap the order of bytes of an arbitrary sized type - // (though obviously this type must be an integral primitive for this to make any - // sense). - static T ByteSwap(T inval) - { - if (sizeof(T) > 1) - { - T outval; - ByteSwapPrimitive(&inval, &outval, sizeof(T)); - return outval; - } - else - return inval; - } -#endif // DBG_BYTE_SWAP_REQUIRED -}; - -#endif // !__DBG_PORTABLE_INCLUDED diff --git a/src/SOS/lldbplugin/inc/dbgtargetcontext.h b/src/SOS/lldbplugin/inc/dbgtargetcontext.h deleted file mode 100644 index c2b45ee05..000000000 --- a/src/SOS/lldbplugin/inc/dbgtargetcontext.h +++ /dev/null @@ -1,458 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#ifndef __DBG_TARGET_CONTEXT_INCLUDED -#define __DBG_TARGET_CONTEXT_INCLUDED - -#include -#include -#include "crosscomp.h" - -// -// The right side of the debugger can now be built to target multiple platforms. This means it is no longer -// safe to use the CONTEXT structure directly: the context of the platform we're building for might not match -// that of the one the debugger is targetting. So now all right side code will use the DT_CONTEXT abstraction -// instead. When the debugger target is the local platform this will just resolve back into CONTEXT, but cross -// platform we'll provide a hand-rolled version. -// - -// -// For cross platform cases we also need to provide a helper function for byte-swapping a context structure -// should the endian-ness of the debugger and debuggee platforms differ. This is called ByteSwapContext and is -// obviously a no-op for those cases where the left and right sides agree on storage format. -// -// NOTE: Any changes to the field layout of DT_CONTEXT must be tracked in the associated definition of -// ByteSwapContext. -// - -// For now, the only cross-platform CONTEXTs we support are x86/PAL and ARM/Win. Look in -// rotor/pal/inc/rotor_pal.h for the original PAL definitions. - -// -// **** NOTE: Keep these in sync with rotor/pal/inc/rotor_pal.h **** -// - -// This odd define pattern is needed because in DBI we set _TARGET_ to match the host and -// DBG_TARGET to control our targeting. In x-plat DBI DBG_TARGET won't match _TARGET_ and -// DBG_TARGET needs to take precedence -#if defined(DBG_TARGET_X86) -#define DTCONTEXT_IS_X86 -#elif defined (DBG_TARGET_AMD64) -#define DTCONTEXT_IS_AMD64 -#elif defined (DBG_TARGET_ARM) -#define DTCONTEXT_IS_ARM -#elif defined (DBG_TARGET_ARM64) -#define DTCONTEXT_IS_ARM64 -#elif defined (_TARGET_X86_) -#define DTCONTEXT_IS_X86 -#elif defined (_TARGET_AMD64_) -#define DTCONTEXT_IS_AMD64 -#elif defined (_TARGET_ARM_) -#define DTCONTEXT_IS_ARM -#elif defined (_TARGET_ARM64_) -#define DTCONTEXT_IS_ARM64 -#endif - -#if defined(DTCONTEXT_IS_X86) - -#define DT_SIZE_OF_80387_REGISTERS 80 - -#define DT_CONTEXT_i386 0x00010000 -#define DT_CONTEXT_CONTROL (DT_CONTEXT_i386 | 0x00000001L) // SS:SP, CS:IP, FLAGS, BP -#define DT_CONTEXT_INTEGER (DT_CONTEXT_i386 | 0x00000002L) // AX, BX, CX, DX, SI, DI -#define DT_CONTEXT_SEGMENTS (DT_CONTEXT_i386 | 0x00000004L) -#define DT_CONTEXT_FLOATING_POINT (DT_CONTEXT_i386 | 0x00000008L) // 387 state -#define DT_CONTEXT_DEBUG_REGISTERS (DT_CONTEXT_i386 | 0x00000010L) - -#define DT_CONTEXT_FULL (DT_CONTEXT_CONTROL | DT_CONTEXT_INTEGER | DT_CONTEXT_SEGMENTS) -#define DT_CONTEXT_EXTENDED_REGISTERS (DT_CONTEXT_i386 | 0x00000020L) - -#define DT_MAXIMUM_SUPPORTED_EXTENSION 512 - -typedef struct { - DWORD ControlWord; - DWORD StatusWord; - DWORD TagWord; - DWORD ErrorOffset; - DWORD ErrorSelector; - DWORD DataOffset; - DWORD DataSelector; - BYTE RegisterArea[DT_SIZE_OF_80387_REGISTERS]; - DWORD Cr0NpxState; -} DT_FLOATING_SAVE_AREA; - -typedef struct { - ULONG ContextFlags; - - ULONG Dr0; - ULONG Dr1; - ULONG Dr2; - ULONG Dr3; - ULONG Dr6; - ULONG Dr7; - - DT_FLOATING_SAVE_AREA FloatSave; - - ULONG SegGs; - ULONG SegFs; - ULONG SegEs; - ULONG SegDs; - - ULONG Edi; - ULONG Esi; - ULONG Ebx; - ULONG Edx; - ULONG Ecx; - ULONG Eax; - - ULONG Ebp; - ULONG Eip; - ULONG SegCs; - ULONG EFlags; - ULONG Esp; - ULONG SegSs; - - UCHAR ExtendedRegisters[DT_MAXIMUM_SUPPORTED_EXTENSION]; - -} DT_CONTEXT; - -// Since the target is little endian in this case we only have to provide a real implementation of -// ByteSwapContext if the platform we're building on is big-endian. -#ifdef BIGENDIAN -inline void ByteSwapContext(DT_CONTEXT *pContext) -{ - // Our job is simplified since the context has large contiguous ranges with fields of the same size. Keep - // the following logic in sync with the definition of DT_CONTEXT above. - BYTE *pbContext = (BYTE*)pContext; - - // The first span consists of 4 byte fields. - DWORD cbFields = (offsetof(DT_CONTEXT, FloatSave) + offsetof(DT_FLOATING_SAVE_AREA, RegisterArea)) / 4; - for (DWORD i = 0; i < cbFields; i++) - { - ByteSwapPrimitive(pbContext, pbContext, 4); - pbContext += 4; - } - - // Then there's a float save area containing 8 byte fields. - cbFields = sizeof(pContext->FloatSave.RegisterArea); - for (DWORD i = 0; i < cbFields; i++) - { - ByteSwapPrimitive(pbContext, pbContext, 8); - pbContext += 8; - } - - // Back to 4 byte fields. - cbFields = (offsetof(DT_CONTEXT, ExtendedRegisters) - offsetof(DT_CONTEXT, SegGs)) / 4; - for (DWORD i = 0; i < cbFields; i++) - { - ByteSwapPrimitive(pbContext, pbContext, 4); - pbContext += 4; - } - - // We don't know the formatting of the extended register area, but the debugger doesn't access this data - // on the left side, so just leave it in left-side format for now. - - // Validate that we converted up to where we think we did as a hedge against DT_CONTEXT layout changes. - _PASSERT((pbContext - ((BYTE*)pContext)) == (sizeof(DT_CONTEXT) - sizeof(pContext->ExtendedRegisters))); -} -#else // BIGENDIAN -inline void ByteSwapContext(DT_CONTEXT *pContext) -{ -} -#endif // BIGENDIAN - -#elif defined(DTCONTEXT_IS_AMD64) - -#define DT_CONTEXT_AMD64 0x00100000L - -#define DT_CONTEXT_CONTROL (DT_CONTEXT_AMD64 | 0x00000001L) -#define DT_CONTEXT_INTEGER (DT_CONTEXT_AMD64 | 0x00000002L) -#define DT_CONTEXT_SEGMENTS (DT_CONTEXT_AMD64 | 0x00000004L) -#define DT_CONTEXT_FLOATING_POINT (DT_CONTEXT_AMD64 | 0x00000008L) -#define DT_CONTEXT_DEBUG_REGISTERS (DT_CONTEXT_AMD64 | 0x00000010L) - -#define DT_CONTEXT_FULL (DT_CONTEXT_CONTROL | DT_CONTEXT_INTEGER | DT_CONTEXT_FLOATING_POINT) -#define DT_CONTEXT_ALL (DT_CONTEXT_CONTROL | DT_CONTEXT_INTEGER | DT_CONTEXT_SEGMENTS | DT_CONTEXT_FLOATING_POINT | DT_CONTEXT_DEBUG_REGISTERS) - -typedef struct { - ULONGLONG Low; - LONGLONG High; -} DT_M128A; - -typedef struct { - WORD ControlWord; - WORD StatusWord; - BYTE TagWord; - BYTE Reserved1; - WORD ErrorOpcode; - DWORD ErrorOffset; - WORD ErrorSelector; - WORD Reserved2; - DWORD DataOffset; - WORD DataSelector; - WORD Reserved3; - DWORD MxCsr; - DWORD MxCsr_Mask; - DT_M128A FloatRegisters[8]; - DT_M128A XmmRegisters[16]; - BYTE Reserved4[96]; -} DT_XMM_SAVE_AREA32; - -typedef struct DECLSPEC_ALIGN(16) { - - DWORD64 P1Home; - DWORD64 P2Home; - DWORD64 P3Home; - DWORD64 P4Home; - DWORD64 P5Home; - DWORD64 P6Home; - - DWORD ContextFlags; - DWORD MxCsr; - - WORD SegCs; - WORD SegDs; - WORD SegEs; - WORD SegFs; - WORD SegGs; - WORD SegSs; - DWORD EFlags; - - DWORD64 Dr0; - DWORD64 Dr1; - DWORD64 Dr2; - DWORD64 Dr3; - DWORD64 Dr6; - DWORD64 Dr7; - - DWORD64 Rax; - DWORD64 Rcx; - DWORD64 Rdx; - DWORD64 Rbx; - DWORD64 Rsp; - DWORD64 Rbp; - DWORD64 Rsi; - DWORD64 Rdi; - DWORD64 R8; - DWORD64 R9; - DWORD64 R10; - DWORD64 R11; - DWORD64 R12; - DWORD64 R13; - DWORD64 R14; - DWORD64 R15; - - DWORD64 Rip; - - union { - DT_XMM_SAVE_AREA32 FltSave; - struct { - DT_M128A Header[2]; - DT_M128A Legacy[8]; - DT_M128A Xmm0; - DT_M128A Xmm1; - DT_M128A Xmm2; - DT_M128A Xmm3; - DT_M128A Xmm4; - DT_M128A Xmm5; - DT_M128A Xmm6; - DT_M128A Xmm7; - DT_M128A Xmm8; - DT_M128A Xmm9; - DT_M128A Xmm10; - DT_M128A Xmm11; - DT_M128A Xmm12; - DT_M128A Xmm13; - DT_M128A Xmm14; - DT_M128A Xmm15; - }; - }; - - DT_M128A VectorRegister[26]; - DWORD64 VectorControl; - - DWORD64 DebugControl; - DWORD64 LastBranchToRip; - DWORD64 LastBranchFromRip; - DWORD64 LastExceptionToRip; - DWORD64 LastExceptionFromRip; -} DT_CONTEXT; - -#elif defined(DTCONTEXT_IS_ARM) - -#define DT_CONTEXT_ARM 0x00200000L - -#define DT_CONTEXT_CONTROL (DT_CONTEXT_ARM | 0x1L) -#define DT_CONTEXT_INTEGER (DT_CONTEXT_ARM | 0x2L) -#define DT_CONTEXT_FLOATING_POINT (DT_CONTEXT_ARM | 0x4L) -#define DT_CONTEXT_DEBUG_REGISTERS (DT_CONTEXT_ARM | 0x8L) - -#define DT_CONTEXT_FULL (DT_CONTEXT_CONTROL | DT_CONTEXT_INTEGER | DT_CONTEXT_FLOATING_POINT) -#define DT_CONTEXT_ALL (DT_CONTEXT_CONTROL | DT_CONTEXT_INTEGER | DT_CONTEXT_FLOATING_POINT | DT_CONTEXT_DEBUG_REGISTERS) - -#define DT_ARM_MAX_BREAKPOINTS 8 -#define DT_ARM_MAX_WATCHPOINTS 1 - -typedef struct { - ULONGLONG Low; - LONGLONG High; -} DT_NEON128; - -typedef DECLSPEC_ALIGN(8) struct { - - // - // Control flags. - // - - DWORD ContextFlags; - - // - // Integer registers - // - - DWORD R0; - DWORD R1; - DWORD R2; - DWORD R3; - DWORD R4; - DWORD R5; - DWORD R6; - DWORD R7; - DWORD R8; - DWORD R9; - DWORD R10; - DWORD R11; - DWORD R12; - - // - // Control Registers - // - - DWORD Sp; - DWORD Lr; - DWORD Pc; - DWORD Cpsr; - - // - // Floating Point/NEON Registers - // - - DWORD Fpscr; - DWORD Padding; - union { - DT_NEON128 Q[16]; - ULONGLONG D[32]; - DWORD S[32]; - } DUMMYUNIONNAME; - - // - // Debug registers - // - - DWORD Bvr[DT_ARM_MAX_BREAKPOINTS]; - DWORD Bcr[DT_ARM_MAX_BREAKPOINTS]; - DWORD Wvr[DT_ARM_MAX_WATCHPOINTS]; - DWORD Wcr[DT_ARM_MAX_WATCHPOINTS]; - - DWORD Padding2[2]; - -} DT_CONTEXT; - -#elif defined(DTCONTEXT_IS_ARM64) - -#define DT_CONTEXT_ARM64 0x00400000L - -#define DT_CONTEXT_CONTROL (DT_CONTEXT_ARM64 | 0x1L) -#define DT_CONTEXT_INTEGER (DT_CONTEXT_ARM64 | 0x2L) -#define DT_CONTEXT_FLOATING_POINT (DT_CONTEXT_ARM64 | 0x4L) -#define DT_CONTEXT_DEBUG_REGISTERS (DT_CONTEXT_ARM64 | 0x8L) - -#define DT_CONTEXT_FULL (DT_CONTEXT_CONTROL | DT_CONTEXT_INTEGER | DT_CONTEXT_FLOATING_POINT) -#define DT_CONTEXT_ALL (DT_CONTEXT_CONTROL | DT_CONTEXT_INTEGER | DT_CONTEXT_FLOATING_POINT | DT_CONTEXT_DEBUG_REGISTERS) - -#define DT_ARM64_MAX_BREAKPOINTS 8 -#define DT_ARM64_MAX_WATCHPOINTS 2 - -typedef struct { - ULONGLONG Low; - LONGLONG High; -} DT_NEON128; - -typedef DECLSPEC_ALIGN(16) struct { - // - // Control flags. - // - - /* +0x000 */ DWORD ContextFlags; - - // - // Integer registers - // - - /* +0x004 */ DWORD Cpsr; // NZVF + DAIF + CurrentEL + SPSel - /* +0x008 */ union { - struct { - DWORD64 X0; - DWORD64 X1; - DWORD64 X2; - DWORD64 X3; - DWORD64 X4; - DWORD64 X5; - DWORD64 X6; - DWORD64 X7; - DWORD64 X8; - DWORD64 X9; - DWORD64 X10; - DWORD64 X11; - DWORD64 X12; - DWORD64 X13; - DWORD64 X14; - DWORD64 X15; - DWORD64 X16; - DWORD64 X17; - DWORD64 X18; - DWORD64 X19; - DWORD64 X20; - DWORD64 X21; - DWORD64 X22; - DWORD64 X23; - DWORD64 X24; - DWORD64 X25; - DWORD64 X26; - DWORD64 X27; - DWORD64 X28; - }; - DWORD64 X[29]; - }; - /* +0x0f0 */ DWORD64 Fp; - /* +0x0f8 */ DWORD64 Lr; - /* +0x100 */ DWORD64 Sp; - /* +0x108 */ DWORD64 Pc; - - // - // Floating Point/NEON Registers - // - - /* +0x110 */ DT_NEON128 V[32]; - /* +0x310 */ DWORD Fpcr; - /* +0x314 */ DWORD Fpsr; - - // - // Debug registers - // - - /* +0x318 */ DWORD Bcr[DT_ARM64_MAX_BREAKPOINTS]; - /* +0x338 */ DWORD64 Bvr[DT_ARM64_MAX_BREAKPOINTS]; - /* +0x378 */ DWORD Wcr[DT_ARM64_MAX_WATCHPOINTS]; - /* +0x380 */ DWORD64 Wvr[DT_ARM64_MAX_WATCHPOINTS]; - /* +0x390 */ - -} DT_CONTEXT; - -#else -#error Unsupported platform -#endif - - -#endif // __DBG_TARGET_CONTEXT_INCLUDED diff --git a/src/SOS/lldbplugin/inc/lldbservices.h b/src/SOS/lldbplugin/inc/lldbservices.h index b9e1fbc96..ffb22242d 100644 --- a/src/SOS/lldbplugin/inc/lldbservices.h +++ b/src/SOS/lldbplugin/inc/lldbservices.h @@ -11,6 +11,10 @@ #ifndef __LLDBSERVICES_H__ #define __LLDBSERVICES_H__ +#include +#include +#include + #ifdef __cplusplus extern "C" { #endif diff --git a/src/SOS/lldbplugin/inc/pal.h b/src/SOS/lldbplugin/inc/pal.h deleted file mode 100644 index 2ee0cb220..000000000 --- a/src/SOS/lldbplugin/inc/pal.h +++ /dev/null @@ -1,222 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -// Contains some definitions duplicated from pal.h, palrt.h, rpc.h, -// etc. because they have various conflicits with the linux standard -// runtime h files like wchar_t, memcpy, etc. - -#include -#include -#include - -#define MAX_PATH 260 -#define MAX_LONGPATH 1024 /* max. length of full pathname */ - -// Platform-specific library naming -// -#ifdef __APPLE__ -#define MAKEDLLNAME_W(name) u"lib" name u".dylib" -#define MAKEDLLNAME_A(name) "lib" name ".dylib" -#elif defined(_AIX) -#define MAKEDLLNAME_W(name) L"lib" name L".a" -#define MAKEDLLNAME_A(name) "lib" name ".a" -#elif defined(__hppa__) || defined(_IA64_) -#define MAKEDLLNAME_W(name) L"lib" name L".sl" -#define MAKEDLLNAME_A(name) "lib" name ".sl" -#else -#define MAKEDLLNAME_W(name) u"lib" name u".so" -#define MAKEDLLNAME_A(name) "lib" name ".so" -#endif - -#define interface struct -typedef GUID IID; - -#ifdef __cplusplus -#define REFGUID const GUID & -#else -#define REFGUID const GUID * -#endif - -typedef GUID *LPGUID; -typedef const GUID FAR *LPCGUID; - -#ifdef __cplusplus -extern "C++" { -#if !defined _SYS_GUID_OPERATOR_EQ_ && !defined _NO_SYS_GUID_OPERATOR_EQ_ -#define _SYS_GUID_OPERATOR_EQ_ -inline int IsEqualGUID(REFGUID rguid1, REFGUID rguid2) - { return !memcmp(&rguid1, &rguid2, sizeof(GUID)); } -inline int operator==(REFGUID guidOne, REFGUID guidOther) - { return IsEqualGUID(guidOne,guidOther); } -inline int operator!=(REFGUID guidOne, REFGUID guidOther) - { return !IsEqualGUID(guidOne,guidOther); } -#endif -}; -#endif // __cplusplus - -#ifdef __cplusplus -#define REFIID const IID & -#else -#define REFIID const IID * -#endif -#define IsEqualIID(riid1, riid2) IsEqualGUID(riid1, riid2) - -#ifndef _DECLSPEC_DEFINED_ -#define _DECLSPEC_DEFINED_ - -#if defined(_MSC_VER) -#define DECLSPEC_NOVTABLE __declspec(novtable) -#define DECLSPEC_IMPORT __declspec(dllimport) -#define DECLSPEC_SELECTANY __declspec(selectany) -#elif defined(__GNUC__) -#define DECLSPEC_NOVTABLE -#define DECLSPEC_IMPORT -#define DECLSPEC_SELECTANY __attribute__((weak)) -#else -#define DECLSPEC_NOVTABLE -#define DECLSPEC_IMPORT -#define DECLSPEC_SELECTANY -#endif - -#if defined(_MSC_VER) || defined(__llvm__) -#define DECLSPEC_ALIGN(x) __declspec(align(x)) -#else -#define DECLSPEC_ALIGN(x) -#endif - -#endif // !_DECLSPEC_DEFINED_ - -#define DECLSPEC_UUID(x) __declspec(uuid(x)) -#define MIDL_INTERFACE(x) struct DECLSPEC_UUID(x) DECLSPEC_NOVTABLE - -#define STDMETHODCALLTYPE __cdecl -#define STDMETHODVCALLTYPE __cdecl - -#define STDAPICALLTYPE __cdecl -#define STDAPIVCALLTYPE __cdecl - -#ifdef RC_INVOKED -#define _HRESULT_TYPEDEF_(_sc) _sc -#else // RC_INVOKED -#define _HRESULT_TYPEDEF_(_sc) ((HRESULT)_sc) -#endif // RC_INVOKED - -#define S_OK _HRESULT_TYPEDEF_(0x00000000L) -#define S_FALSE _HRESULT_TYPEDEF_(0x00000001L) - -#define E_NOTIMPL _HRESULT_TYPEDEF_(0x80004001L) -#define E_NOINTERFACE _HRESULT_TYPEDEF_(0x80004002L) -#define E_UNEXPECTED _HRESULT_TYPEDEF_(0x8000FFFFL) -#define E_OUTOFMEMORY _HRESULT_TYPEDEF_(0x8007000EL) -#define E_INVALIDARG _HRESULT_TYPEDEF_(0x80070057L) -#define E_POINTER _HRESULT_TYPEDEF_(0x80004003L) -#define E_HANDLE _HRESULT_TYPEDEF_(0x80070006L) -#define E_ABORT _HRESULT_TYPEDEF_(0x80004004L) -#define E_FAIL _HRESULT_TYPEDEF_(0x80004005L) -#define E_ACCESSDENIED _HRESULT_TYPEDEF_(0x80070005L) -#define E_PENDING _HRESULT_TYPEDEF_(0x8000000AL) - -#define EXCEPTION_MAXIMUM_PARAMETERS 15 - -typedef struct _EXCEPTION_RECORD64 { - DWORD ExceptionCode; - ULONG ExceptionFlags; - ULONG64 ExceptionRecord; - ULONG64 ExceptionAddress; - ULONG NumberParameters; - ULONG __unusedAlignment; - ULONG64 ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS]; -} EXCEPTION_RECORD64, *PEXCEPTION_RECORD64; - -#include - -#ifndef FORCEINLINE -#if _MSC_VER < 1200 -#define FORCEINLINE inline -#else -#define FORCEINLINE __forceinline -#endif -#endif - -FORCEINLINE void PAL_ArmInterlockedOperationBarrier() -{ -#ifdef _ARM64_ - // On arm64, most of the __sync* functions generate a code sequence like: - // loop: - // ldaxr (load acquire exclusive) - // ... - // stlxr (store release exclusive) - // cbnz loop - // - // It is possible for a load following the code sequence above to be reordered to occur prior to the store above due to the - // release barrier, this is substantiated by https://github.com/dotnet/coreclr/pull/17508. Interlocked operations in the PAL - // require the load to occur after the store. This memory barrier should be used following a call to a __sync* function to - // prevent that reordering. Code generated for arm32 includes a 'dmb' after 'cbnz', so no issue there at the moment. - __sync_synchronize(); -#endif // _ARM64_ -} - -/*++ -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 -InterlockedIncrement( - IN OUT LONG volatile *lpAddend) -{ - LONG result = __sync_add_and_fetch(lpAddend, (LONG)1); - PAL_ArmInterlockedOperationBarrier(); - return result; -} - -/*++ -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 -InterlockedDecrement( - IN OUT LONG volatile *lpAddend) -{ - LONG result = __sync_sub_and_fetch(lpAddend, (LONG)1); - PAL_ArmInterlockedOperationBarrier(); - return result; -} diff --git a/src/SOS/lldbplugin/inc/pal_mstypes.h b/src/SOS/lldbplugin/inc/pal_mstypes.h deleted file mode 100644 index 0aa35ae1e..000000000 --- a/src/SOS/lldbplugin/inc/pal_mstypes.h +++ /dev/null @@ -1,721 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*++ - - - - - ---*/ - -//////////////////////////////////////////////////////////////////////// -// Extensions to the usual posix header files -//////////////////////////////////////////////////////////////////////// - -#ifndef __PAL_MSTYPES_H__ -#define __PAL_MSTYPES_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -//////////////////////////////////////////////////////////////////////// -// calling convention stuff -//////////////////////////////////////////////////////////////////////// - - -#ifdef __cplusplus -#define EXTERN_C extern "C" -#else -#define EXTERN_C -#endif // __cplusplus - -#ifndef _MSC_VER - -// Note: Win32-hosted GCC predefines __stdcall and __cdecl, but Unix- -// hosted GCC does not. - -#ifdef __i386__ - -#if !defined(__stdcall) -#define __stdcall __attribute__((stdcall)) -#endif -#if !defined(_stdcall) -#define _stdcall __stdcall -#endif - -#if !defined(__cdecl) -#define __cdecl __attribute__((cdecl)) -#endif -#if !defined(_cdecl) -#define _cdecl __cdecl -#endif -#if !defined(CDECL) -#define CDECL __cdecl -#endif - - -#else // !defined(__i386__) - -#define __stdcall -#define _stdcall -#define __cdecl -#define _cdecl -#define CDECL - -// On ARM __fastcall is ignored and causes a compile error -#if !defined(PAL_STDCPP_COMPAT) || defined(__arm__) -# undef __fastcall -# undef _fastcall -# define __fastcall -# define _fastcall -#endif // !defined(PAL_STDCPP_COMPAT) || defined(__arm__) - -#endif // !defined(__i386__) - -#define CALLBACK __cdecl - -#if !defined(_declspec) -#define _declspec(e) __declspec(e) -#endif - -#if defined(_VAC_) && defined(__cplusplus) -#define __inline inline -#endif - -#define __forceinline inline - -#endif // !_MSC_VER - -#ifdef _MSC_VER - -#if defined(PAL_IMPLEMENTATION) -#define PALIMPORT -#else -#define PALIMPORT __declspec(dllimport) -#endif -#define PAL_NORETURN __declspec(noreturn) - -#else - -#define PALIMPORT -#define PAL_NORETURN __attribute__((noreturn)) - -#endif - -#define PALAPI __cdecl -#define PALAPIV __cdecl - -//////////////////////////////////////////////////////////////////////// -// Type attribute stuff -//////////////////////////////////////////////////////////////////////// - -#define CONST const -#define IN -#define OUT -#define OPTIONAL -#define FAR - -#ifdef UNICODE -#define __TEXT(x) L##x -#else -#define __TEXT(x) x -#endif -#define TEXT(x) __TEXT(x) - -//////////////////////////////////////////////////////////////////////// -// Some special values -//////////////////////////////////////////////////////////////////////// - -#ifndef TRUE -#define TRUE 1 -#endif - -#ifndef FALSE -#define FALSE 0 -#endif - -//////////////////////////////////////////////////////////////////////// -// Misc. type helpers -//////////////////////////////////////////////////////////////////////// - -#ifdef _MSC_VER - -// MSVC's way of declaring large integer constants -// If you define these in one step, without the _HELPER macros, you -// get extra whitespace when composing these with other concatenating macros. -#define I64_HELPER(x) x ## i64 -#define I64(x) I64_HELPER(x) - -#define UI64_HELPER(x) x ## ui64 -#define UI64(x) UI64_HELPER(x) - -#else // _MSC_VER - -// GCC's way of declaring large integer constants -// If you define these in one step, without the _HELPER macros, you -// get extra whitespace when composing these with other concatenating macros. -#define I64_HELPER(x) x ## LL -#define I64(x) I64_HELPER(x) - -#define UI64_HELPER(x) x ## ULL -#define UI64(x) UI64_HELPER(x) - -#endif // _MSC_VER - -//////////////////////////////////////////////////////////////////////// -// Misc. types -//////////////////////////////////////////////////////////////////////// - -#ifndef _MSC_VER - -// A bunch of source files (e.g. most of the ndp tree) include pal.h -// but are written to be LLP64, not LP64. (LP64 => long = 64 bits -// LLP64 => longs = 32 bits, long long = 64 bits) -// -// To handle this difference, we #define long to be int (and thus 32 bits) when -// compiling those files. (See the bottom of this file or search for -// #define long to see where we do this.) -// -// But this fix is more complicated than it seems, because we also use the -// preprocessor to #define __int64 to long for LP64 architectures (__int64 -// isn't a builtin in gcc). We don't want __int64 to be an int (by cascading -// macro rules). So we play this little trick below where we add -// __cppmungestrip before "long", which is what we're really #defining __int64 -// to. The preprocessor sees __cppmungestriplong as something different than -// long, so it doesn't replace it with int. The during the cppmunge phase, we -// remove the __cppmungestrip part, leaving long for the compiler to see. -// -// Note that we can't just use a typedef to define __int64 as long before -// #defining long because typedefed types can't be signedness-agnostic (i.e. -// they must be either signed or unsigned) and we want to be able to use -// __int64 as though it were intrinsic - -#ifdef BIT64 -#define __int64 long -#else // BIT64 -#define __int64 long long -#endif // BIT64 - -#define __int32 int -#define __int16 short int -#define __int8 char // assumes char is signed - -#endif // _MSC_VER - -#ifndef PAL_STDCPP_COMPAT -// Defined in gnu's types.h. For non PAL_IMPLEMENTATION system -// includes are not included, so we need to define them. -#ifndef PAL_IMPLEMENTATION - -// OS X already defines these types in 64 bit -#if !defined(_TARGET_MAC64) -typedef __int64 int64_t; -typedef unsigned __int64 uint64_t; -typedef __int32 int32_t; -typedef unsigned __int32 uint32_t; -typedef __int16 int16_t; -typedef unsigned __int16 uint16_t; -typedef __int8 int8_t; -typedef unsigned __int8 uint8_t; -#endif - -#endif // PAL_IMPLEMENTATION - -#ifndef _MSC_VER - -#if _WIN64 -typedef long double LONG_DOUBLE; -#endif - -#endif // _MSC_VER -#endif // !PAL_STDCPP_COMPAT - -typedef void VOID; - -typedef int LONG; // NOTE: diff from windows.h, for LP64 compat -typedef unsigned int ULONG; // NOTE: diff from windows.h, for LP64 compat - -typedef __int64 LONGLONG; -typedef unsigned __int64 ULONGLONG; -typedef ULONGLONG DWORD64; -typedef DWORD64 *PDWORD64; -typedef LONGLONG *PLONG64; -typedef ULONGLONG *PULONG64; -typedef ULONGLONG *PULONGLONG; -typedef ULONG *PULONG; -typedef short SHORT; -typedef SHORT *PSHORT; -typedef unsigned short USHORT; -typedef USHORT *PUSHORT; -typedef unsigned char UCHAR; -typedef UCHAR *PUCHAR; -typedef char *PSZ; -typedef ULONGLONG DWORDLONG; - -typedef unsigned int DWORD; // NOTE: diff from windows.h, for LP64 compat -typedef unsigned int DWORD32, *PDWORD32; - -typedef int BOOL; -typedef unsigned char BYTE; -typedef unsigned short WORD; -typedef float FLOAT; -typedef double DOUBLE; -typedef BOOL *PBOOL; -typedef BOOL *LPBOOL; -typedef BYTE *PBYTE; -typedef BYTE *LPBYTE; -typedef const BYTE *LPCBYTE; -typedef int *PINT; -typedef int *LPINT; -typedef WORD *PWORD; -typedef WORD *LPWORD; -typedef LONG *LPLONG; -typedef LPLONG PLONG; -typedef DWORD *PDWORD; -typedef DWORD *LPDWORD; -typedef void *PVOID; -typedef void *LPVOID; -typedef CONST void *LPCVOID; -typedef int INT; -typedef unsigned int UINT; -typedef unsigned int *PUINT; -typedef BYTE BOOLEAN; -typedef BOOLEAN *PBOOLEAN; - -typedef unsigned __int8 UINT8; -typedef signed __int8 INT8; -typedef unsigned __int16 UINT16; -typedef signed __int16 INT16; -typedef unsigned __int32 UINT32, *PUINT32; -typedef signed __int32 INT32, *PINT32; -typedef unsigned __int64 UINT64, *PUINT64; -typedef signed __int64 INT64, *PINT64; - -typedef unsigned __int32 ULONG32, *PULONG32; -typedef signed __int32 LONG32, *PLONG32; -typedef unsigned __int64 ULONG64; -typedef signed __int64 LONG64; - -#if defined(_X86_) && _MSC_VER >= 1300 -#define _W64 __w64 -#else -#define _W64 -#endif - -#ifdef BIT64 - -#define _atoi64 (__int64)atoll - -typedef __int64 INT_PTR, *PINT_PTR; -typedef unsigned __int64 UINT_PTR, *PUINT_PTR; -typedef __int64 LONG_PTR, *PLONG_PTR; -typedef unsigned __int64 ULONG_PTR, *PULONG_PTR; -typedef unsigned __int64 DWORD_PTR, *PDWORD_PTR; - -/* maximum signed 64 bit value */ -#define LONG_PTR_MAX I64(9223372036854775807) -/* maximum unsigned 64 bit value */ -#define ULONG_PTR_MAX UI64(0xffffffffffffffff) - -#ifndef SIZE_MAX -#define SIZE_MAX _UI64_MAX -#endif - -#define __int3264 __int64 - -#if !defined(BIT64) -__inline -unsigned long -HandleToULong( - const void *h - ) -{ - return((unsigned long) (ULONG_PTR) h ); -} - -__inline -long -HandleToLong( - const void *h - ) -{ - return((long) (LONG_PTR) h ); -} - -__inline -void * -ULongToHandle( - const unsigned long h - ) -{ - return((void *) (UINT_PTR) h ); -} - - -__inline -void * -LongToHandle( - const long h - ) -{ - return((void *) (INT_PTR) h ); -} - - -__inline -unsigned long -PtrToUlong( - const void *p - ) -{ - return((unsigned long) (ULONG_PTR) p ); -} - -__inline -unsigned int -PtrToUint( - const void *p - ) -{ - return((unsigned int) (UINT_PTR) p ); -} - -__inline -unsigned short -PtrToUshort( - const void *p - ) -{ - return((unsigned short) (unsigned long) (ULONG_PTR) p ); -} - -__inline -long -PtrToLong( - const void *p - ) -{ - return((long) (LONG_PTR) p ); -} - -__inline -int -PtrToInt( - const void *p - ) -{ - return((int) (INT_PTR) p ); -} - -__inline -short -PtrToShort( - const void *p - ) -{ - return((short) (long) (LONG_PTR) p ); -} - -__inline -void * -IntToPtr( - const int i - ) -// Caution: IntToPtr() sign-extends the int value. -{ - return( (void *)(INT_PTR)i ); -} - -__inline -void * -UIntToPtr( - const unsigned int ui - ) -// Caution: UIntToPtr() zero-extends the unsigned int value. -{ - return( (void *)(UINT_PTR)ui ); -} - -__inline -void * -LongToPtr( - const long l - ) -// Caution: LongToPtr() sign-extends the long value. -{ - return( (void *)(LONG_PTR)l ); -} - -__inline -void * -ULongToPtr( - const unsigned long ul - ) -// Caution: ULongToPtr() zero-extends the unsigned long value. -{ - return( (void *)(ULONG_PTR)ul ); -} - -__inline -void * -ShortToPtr( - const short s - ) -// Caution: ShortToPtr() sign-extends the short value. -{ - return( (void *)(INT_PTR)s ); -} - -__inline -void * -UShortToPtr( - const unsigned short us - ) -// Caution: UShortToPtr() zero-extends the unsigned short value. -{ - return( (void *)(UINT_PTR)us ); -} - -#else // !defined(BIT64) -#define HandleToULong( h ) ((ULONG)(ULONG_PTR)(h) ) -#define HandleToLong( h ) ((LONG)(LONG_PTR) (h) ) -#define ULongToHandle( ul ) ((HANDLE)(ULONG_PTR) (ul) ) -#define LongToHandle( h ) ((HANDLE)(LONG_PTR) (h) ) -#define PtrToUlong( p ) ((ULONG)(ULONG_PTR) (p) ) -#define PtrToLong( p ) ((LONG)(LONG_PTR) (p) ) -#define PtrToUint( p ) ((UINT)(UINT_PTR) (p) ) -#define PtrToInt( p ) ((INT)(INT_PTR) (p) ) -#define PtrToUshort( p ) ((unsigned short)(ULONG_PTR)(p) ) -#define PtrToShort( p ) ((short)(LONG_PTR)(p) ) -#define IntToPtr( i ) ((VOID *)(INT_PTR)((int)(i))) -#define UIntToPtr( ui ) ((VOID *)(UINT_PTR)((unsigned int)(ui))) -#define LongToPtr( l ) ((VOID *)(LONG_PTR)((long)(l))) -#define ULongToPtr( ul ) ((VOID *)(ULONG_PTR)((unsigned long)(ul))) -#define ShortToPtr( s ) ((VOID *)(INT_PTR)((short)(s))) -#define UShortToPtr( us ) ((VOID *)(UINT_PTR)((unsigned short)(s))) -#endif // !defined(BIT64) - - - -#else - -typedef _W64 __int32 INT_PTR; -typedef _W64 unsigned __int32 UINT_PTR; - -typedef _W64 __int32 LONG_PTR; -typedef _W64 unsigned __int32 ULONG_PTR, *PULONG_PTR; -typedef _W64 unsigned __int32 DWORD_PTR, *PDWORD_PTR; - -/* maximum signed 32 bit value */ -#define LONG_PTR_MAX 2147483647L -/* maximum unsigned 32 bit value */ -#define ULONG_PTR_MAX 0xffffffffUL - -#ifndef SIZE_MAX -#define SIZE_MAX UINT_MAX -#endif - -#define __int3264 __int32 - -#define HandleToULong( h ) ((ULONG)(ULONG_PTR)(h) ) -#define HandleToLong( h ) ((LONG)(LONG_PTR) (h) ) -#define ULongToHandle( ul ) ((HANDLE)(ULONG_PTR) (ul) ) -#define LongToHandle( h ) ((HANDLE)(LONG_PTR) (h) ) -#define PtrToUlong( p ) ((ULONG)(ULONG_PTR) (p) ) -#define PtrToLong( p ) ((LONG)(LONG_PTR) (p) ) -#define PtrToUint( p ) ((UINT)(UINT_PTR) (p) ) -#define PtrToInt( p ) ((INT)(INT_PTR) (p) ) -#define PtrToUshort( p ) ((unsigned short)(ULONG_PTR)(p) ) -#define PtrToShort( p ) ((short)(LONG_PTR)(p) ) -#define IntToPtr( i ) ((VOID *)(INT_PTR)((int)i)) -#define UIntToPtr( ui ) ((VOID *)(UINT_PTR)((unsigned int)ui)) -#define LongToPtr( l ) ((VOID *)(LONG_PTR)((long)l)) -#define ULongToPtr( ul ) ((VOID *)(ULONG_PTR)((unsigned long)ul)) -#define ShortToPtr( s ) ((VOID *)(INT_PTR)((short)s)) -#define UShortToPtr( us ) ((VOID *)(UINT_PTR)((unsigned short)s)) - -#endif - -#define HandleToUlong(h) HandleToULong(h) -#define UlongToHandle(ul) ULongToHandle(ul) -#define UlongToPtr(ul) ULongToPtr(ul) -#define UintToPtr(ui) UIntToPtr(ui) - -typedef ULONG_PTR SIZE_T, *PSIZE_T; -typedef LONG_PTR SSIZE_T, *PSSIZE_T; - -#ifndef SIZE_T_MAX -#define SIZE_T_MAX ULONG_PTR_MAX -#endif // SIZE_T_MAX - -#ifndef SSIZE_T_MAX -#define SSIZE_T_MAX LONG_PTR_MAX -#endif - -#ifndef SSIZE_T_MIN -#define SSIZE_T_MIN I64(0x8000000000000000) -#endif - -#ifndef PAL_STDCPP_COMPAT -#if defined(__APPLE_CC__) || defined(__linux__) -#ifdef BIT64 -typedef unsigned long size_t; -typedef long ptrdiff_t; -#else // !BIT64 -typedef unsigned int size_t; -typedef int ptrdiff_t; -#endif // !BIT64 -#else -typedef ULONG_PTR size_t; -typedef LONG_PTR ptrdiff_t; -#endif -#endif // !PAL_STDCPP_COMPAT -#define _SIZE_T_DEFINED - -typedef LONG_PTR LPARAM; - -#define _PTRDIFF_T_DEFINED -#ifdef _MINGW_ -// We need to define _PTRDIFF_T to make sure ptrdiff_t doesn't get defined -// again by system headers - but only for MinGW. -#define _PTRDIFF_T -#endif - -#ifdef PAL_STDCPP_COMPAT - -#ifdef BIT64 -typedef unsigned long int uintptr_t; -#else // !BIT64 -typedef unsigned int uintptr_t; -#endif // !BIT64 - -typedef char16_t WCHAR; - -#else // PAL_STDCPP_COMPAT - -typedef wchar_t WCHAR; -#if defined(__linux__) -#ifdef BIT64 -typedef long int intptr_t; -typedef unsigned long int uintptr_t; -#else // !BIT64 -typedef int intptr_t; -typedef unsigned int uintptr_t; -#endif // !BIT64 -#else -typedef INT_PTR intptr_t; -typedef UINT_PTR uintptr_t; -#endif - -#endif // PAL_STDCPP_COMPAT - -#define _INTPTR_T_DEFINED -#define _UINTPTR_T_DEFINED - -typedef DWORD LCID; -typedef PDWORD PLCID; -typedef WORD LANGID; - -typedef DWORD LCTYPE; - -typedef WCHAR *PWCHAR; -typedef WCHAR *LPWCH, *PWCH; -typedef CONST WCHAR *LPCWCH, *PCWCH; -typedef WCHAR *NWPSTR; -typedef WCHAR *LPWSTR, *PWSTR; - -typedef CONST WCHAR *LPCWSTR, *PCWSTR; - -typedef char CHAR; -typedef CHAR *PCHAR; -typedef CHAR *LPCH, *PCH; -typedef CONST CHAR *LPCCH, *PCCH; -typedef CHAR *NPSTR; -typedef CHAR *LPSTR, *PSTR; -typedef CONST CHAR *LPCSTR, *PCSTR; - -#ifdef UNICODE -typedef WCHAR TCHAR; -typedef WCHAR _TCHAR; -#else -typedef CHAR TCHAR; -typedef CHAR _TCHAR; -#endif -typedef TCHAR *PTCHAR; -typedef TCHAR *LPTSTR, *PTSTR; -typedef CONST TCHAR *LPCTSTR; - -#define MAKEWORD(a, b) ((WORD)(((BYTE)((DWORD_PTR)(a) & 0xff)) | ((WORD)((BYTE)((DWORD_PTR)(b) & 0xff))) << 8)) -#define MAKELONG(a, b) ((LONG)(((WORD)((DWORD_PTR)(a) & 0xffff)) | ((DWORD)((WORD)((DWORD_PTR)(b) & 0xffff))) << 16)) -#define LOWORD(l) ((WORD)((DWORD_PTR)(l) & 0xffff)) -#define HIWORD(l) ((WORD)((DWORD_PTR)(l) >> 16)) -#define LOBYTE(w) ((BYTE)((DWORD_PTR)(w) & 0xff)) -#define HIBYTE(w) ((BYTE)((DWORD_PTR)(w) >> 8)) - -typedef VOID *HANDLE; -typedef HANDLE HWND; -typedef struct __PAL_RemoteHandle__ { HANDLE h; } *RHANDLE; -typedef HANDLE *PHANDLE; -typedef HANDLE *LPHANDLE; -#define INVALID_HANDLE_VALUE ((VOID *)(-1)) -#define INVALID_FILE_SIZE ((DWORD)0xFFFFFFFF) -#define INVALID_FILE_ATTRIBUTES ((DWORD) -1) -typedef HANDLE HMODULE; -typedef HANDLE HINSTANCE; -typedef HANDLE HGLOBAL; -typedef HANDLE HLOCAL; -typedef HANDLE HRSRC; - -typedef LONG HRESULT; -typedef LONG NTSTATUS; - -typedef union _LARGE_INTEGER { - struct { -#if BIGENDIAN - LONG HighPart; - DWORD LowPart; -#else - DWORD LowPart; - LONG HighPart; -#endif - } u; - LONGLONG QuadPart; -} LARGE_INTEGER, *PLARGE_INTEGER; - -#ifndef GUID_DEFINED -typedef struct _GUID { - ULONG Data1; // NOTE: diff from Win32, for LP64 - USHORT Data2; - USHORT Data3; - UCHAR Data4[ 8 ]; -} GUID; -typedef const GUID *LPCGUID; -#define GUID_DEFINED -#endif // !GUID_DEFINED - -typedef struct _FILETIME { - DWORD dwLowDateTime; - DWORD dwHighDateTime; -} FILETIME, *PFILETIME, *LPFILETIME; - -/* Code Page Default Values */ -#define CP_ACP 0 /* default to ANSI code page */ -#define CP_OEMCP 1 /* default to OEM code page */ -#define CP_MACCP 2 /* default to MAC code page */ -#define CP_THREAD_ACP 3 /* current thread's ANSI code page */ -#define CP_WINUNICODE 1200 -#define CP_UNICODE 1200 /* Unicode */ -#define CP_UNICODESWAP 1201 /* Unicode Big-Endian */ -#define CP_UTF7 65000 /* UTF-7 translation */ -#define CP_UTF8 65001 /* UTF-8 translation */ - -typedef PVOID PSID; - -#ifdef __cplusplus -} -#endif - -#endif // __PAL_MSTYPES_H__ diff --git a/src/SOS/lldbplugin/inc/unknwn.h b/src/SOS/lldbplugin/inc/unknwn.h deleted file mode 100644 index e33921da8..000000000 --- a/src/SOS/lldbplugin/inc/unknwn.h +++ /dev/null @@ -1,64 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -// - -// -// =========================================================================== -// File: unknwn.h -// -// =========================================================================== -// simplified unknwn.h for PAL - - -#ifndef __IUnknown_INTERFACE_DEFINED__ -#define __IUnknown_INTERFACE_DEFINED__ - -typedef interface IUnknown IUnknown; - -typedef /* [unique] */ IUnknown *LPUNKNOWN; - -// 00000000-0000-0000-C000-000000000046 -EXTERN_C const IID IID_IUnknown; - -MIDL_INTERFACE("00000000-0000-0000-C000-000000000046") -IUnknown -{ - virtual HRESULT STDMETHODCALLTYPE QueryInterface( - REFIID riid, - void **ppvObject) = 0; - - virtual ULONG STDMETHODCALLTYPE AddRef( void) = 0; - - virtual ULONG STDMETHODCALLTYPE Release( void) = 0; - - template - HRESULT - STDMETHODCALLTYPE - QueryInterface(Q** pp) - { - return QueryInterface(__uuidof(Q), (void **)pp); - } -}; - -#endif // __IUnknown_INTERFACE_DEFINED__ - -#ifndef __IClassFactory_INTERFACE_DEFINED__ -#define __IClassFactory_INTERFACE_DEFINED__ - -// 00000001-0000-0000-C000-000000000046 -EXTERN_C const IID IID_IClassFactory; - -MIDL_INTERFACE("00000001-0000-0000-C000-000000000046") -IClassFactory : public IUnknown -{ - virtual HRESULT STDMETHODCALLTYPE CreateInstance( - IUnknown *pUnkOuter, - REFIID riid, - void **ppvObject) = 0; - - virtual HRESULT STDMETHODCALLTYPE LockServer( - BOOL fLock) = 0; -}; - -#endif // __IClassFactory_INTERFACE_DEFINED__ diff --git a/src/SOS/lldbplugin/mstypes.h b/src/SOS/lldbplugin/mstypes.h new file mode 100644 index 000000000..9b6f261be --- /dev/null +++ b/src/SOS/lldbplugin/mstypes.h @@ -0,0 +1,27 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +// Contains some definitions duplicated from pal.h, palrt.h, rpc.h, +// etc. because they have various conflicits with the linux standard +// runtime h files like wchar_t, memcpy, etc. + +#include + +#define MAX_PATH 260 + +// Platform-specific library naming +// +#ifdef __APPLE__ +#define MAKEDLLNAME_W(name) u"lib" name u".dylib" +#define MAKEDLLNAME_A(name) "lib" name ".dylib" +#elif defined(_AIX) +#define MAKEDLLNAME_W(name) L"lib" name L".a" +#define MAKEDLLNAME_A(name) "lib" name ".a" +#elif defined(__hppa__) || defined(_IA64_) +#define MAKEDLLNAME_W(name) L"lib" name L".sl" +#define MAKEDLLNAME_A(name) "lib" name ".sl" +#else +#define MAKEDLLNAME_W(name) u"lib" name u".so" +#define MAKEDLLNAME_A(name) "lib" name ".so" +#endif diff --git a/src/SOS/lldbplugin/services.cpp b/src/SOS/lldbplugin/services.cpp index 3186920eb..547bc2788 100644 --- a/src/SOS/lldbplugin/services.cpp +++ b/src/SOS/lldbplugin/services.cpp @@ -7,12 +7,14 @@ #include "sosplugin.h" #include #include +#include #define CONVERT_FROM_SIGN_EXTENDED(offset) ((ULONG_PTR)(offset)) ULONG g_currentThreadIndex = -1; ULONG g_currentThreadSystemId = -1; char *g_coreclrDirectory; +char *g_pluginModuleDirectory; LLDBServices::LLDBServices(lldb::SBDebugger &debugger, lldb::SBCommandReturnObject &returnObject, lldb::SBProcess *process, lldb::SBThread *thread) : m_ref(1), @@ -77,6 +79,21 @@ LLDBServices::Release() PCSTR LLDBServices::GetCoreClrDirectory() { + if (g_coreclrDirectory == nullptr) + { + const char *coreclrModule = MAKEDLLNAME_A("coreclr"); + const char *directory = GetModuleDirectory(coreclrModule); + if (directory != nullptr) + { + std::string path(directory); + path.append("/"); + g_coreclrDirectory = strdup(path.c_str()); + } + else + { + Output(DEBUG_OUTPUT_WARNING, "The %s module is not loaded yet in the target process\n", coreclrModule); + } + } return g_coreclrDirectory; } @@ -1744,3 +1761,32 @@ LLDBServices::GetCurrentFrame() return frame; } + +void +DummyFunction() +{ +} + +PCSTR +LLDBServices::GetPluginModuleDirectory() +{ + if (g_pluginModuleDirectory == nullptr) + { + Dl_info info; + if (dladdr((void *)&DummyFunction, &info) != 0) + { + std::string path(info.dli_fname); + + // Parse off the module name to get just the path + size_t lastSlash = path.rfind('/'); + if (lastSlash != std::string::npos) + { + path.erase(lastSlash); + path.append("/"); + g_pluginModuleDirectory = strdup(path.c_str()); + } + } + } + return g_pluginModuleDirectory; +} + diff --git a/src/SOS/lldbplugin/services.h b/src/SOS/lldbplugin/services.h index 650904002..6648c091d 100644 --- a/src/SOS/lldbplugin/services.h +++ b/src/SOS/lldbplugin/services.h @@ -271,4 +271,6 @@ public: PCSTR GetModuleDirectory( PCSTR name); + + PCSTR GetPluginModuleDirectory(); }; diff --git a/src/SOS/lldbplugin/setclrpathcommand.cpp b/src/SOS/lldbplugin/setclrpathcommand.cpp index 220830667..43387245e 100644 --- a/src/SOS/lldbplugin/setclrpathcommand.cpp +++ b/src/SOS/lldbplugin/setclrpathcommand.cpp @@ -23,7 +23,7 @@ public: { if (arguments[0] == NULL) { - result.Printf("Load path for sos/dac/dbi: '%s'\n", g_coreclrDirectory == NULL ? "" : g_coreclrDirectory); + result.Printf("Load path for dac/dbi: '%s'\n", g_coreclrDirectory == NULL ? "" : g_coreclrDirectory); } else { if (g_coreclrDirectory != NULL) @@ -38,7 +38,7 @@ public: } g_coreclrDirectory = strdup(path.c_str()); - result.Printf("Set load path for sos/dac/dbi to '%s'\n", g_coreclrDirectory); + result.Printf("Set load path for dac/dbi to '%s'\n", g_coreclrDirectory); } return result.Succeeded(); } @@ -48,6 +48,6 @@ bool setclrpathCommandInitialize(lldb::SBDebugger debugger) { lldb::SBCommandInterpreter interpreter = debugger.GetCommandInterpreter(); - lldb::SBCommand command = interpreter.AddCommand("setclrpath", new setclrpathCommand(), "Set the path to load coreclr sos/dac/dbi files. setclrpath "); + lldb::SBCommand command = interpreter.AddCommand("setclrpath", new setclrpathCommand(), "Set the path to load coreclr dac/dbi files. setclrpath "); return true; } diff --git a/src/SOS/lldbplugin/soscommand.cpp b/src/SOS/lldbplugin/soscommand.cpp index 64d198cb5..53680a096 100644 --- a/src/SOS/lldbplugin/soscommand.cpp +++ b/src/SOS/lldbplugin/soscommand.cpp @@ -12,11 +12,17 @@ class sosCommand : public lldb::SBCommandPluginInterface const char *m_command; void *m_sosHandle; + // If true, use the directory that libsosplugin is in to load + // libsos, otherwise (if false) use the libcoreclr module + // directory (legacy behavior). + bool m_usePluginDirectory; + public: sosCommand(const char *command) { m_command = command; m_sosHandle = NULL; + m_usePluginDirectory = true; } virtual bool @@ -27,7 +33,7 @@ public: LLDBServices* services = new LLDBServices(debugger, result); LoadSos(services); - if (m_sosHandle) + if (m_sosHandle != NULL) { const char* sosCommand = m_command; if (sosCommand == NULL) @@ -74,37 +80,33 @@ public: { if (m_sosHandle == NULL) { - if (g_coreclrDirectory == NULL) + if (m_usePluginDirectory) { - const char *coreclrModule = MAKEDLLNAME_A("coreclr"); - const char *directory = services->GetModuleDirectory(coreclrModule); - if (directory != NULL) + const char *loadDirectory = services->GetPluginModuleDirectory(); + if (loadDirectory != NULL) { - std::string path(directory); - path.append("/"); - g_coreclrDirectory = strdup(path.c_str()); - } - else - { - services->Output(DEBUG_OUTPUT_WARNING, "The %s module is not loaded yet in the target process\n", coreclrModule); + m_sosHandle = LoadModule(services, loadDirectory, MAKEDLLNAME_A("sos")); } } - - if (g_coreclrDirectory != NULL) + else { - // Load the DAC module first explicitly because SOS and DBI - // have implicit references to the DAC's PAL. - LoadModule(services, MAKEDLLNAME_A("mscordaccore")); + const char *loadDirectory = services->GetCoreClrDirectory(); + if (loadDirectory != NULL) + { + // Load the DAC module first explicitly because SOS and DBI + // have implicit references to the DAC's PAL. + LoadModule(services, loadDirectory, MAKEDLLNAME_A("mscordaccore")); - m_sosHandle = LoadModule(services, MAKEDLLNAME_A("sos")); + m_sosHandle = LoadModule(services, loadDirectory, MAKEDLLNAME_A("sos")); + } } } } void * - LoadModule(LLDBServices *services, const char *moduleName) + LoadModule(LLDBServices *services, const char *loadDirectory, const char *moduleName) { - std::string modulePath(g_coreclrDirectory); + std::string modulePath(loadDirectory); modulePath.append(moduleName); void *moduleHandle = dlopen(modulePath.c_str(), RTLD_NOW); @@ -128,6 +130,7 @@ sosCommandInitialize(lldb::SBDebugger debugger) interpreter.AddCommand("createdump", new sosCommand("CreateDump"), "Create a xplat minidump."); interpreter.AddCommand("clru", new sosCommand("u"), "Displays an annotated disassembly of a managed method."); interpreter.AddCommand("dumpclass", new sosCommand("DumpClass"), "Displays information about a EE class structure at the specified address."); + interpreter.AddCommand("dumpdomain", new sosCommand("DumpDomain"), "Displays information all the AppDomains and all assemblies within the domains."); interpreter.AddCommand("dumpheap", new sosCommand("DumpHeap"), "Displays info about the garbage-collected heap and collection statistics about objects."); interpreter.AddCommand("dumpil", new sosCommand("DumpIL"), "Displays the Microsoft intermediate language (MSIL) that is associated with a managed method."); interpreter.AddCommand("dumplog", new sosCommand("DumpLog"), "Writes the contents of an in-memory stress log to the specified file."); @@ -148,6 +151,7 @@ sosCommandInitialize(lldb::SBDebugger debugger) interpreter.AddCommand("histobj", new sosCommand("HistObj"), "Examines all stress log relocation records and displays the chain of garbage collection relocations that may have led to the address passed in as an argument."); interpreter.AddCommand("histobjfind", new sosCommand("HistObjFind"), "Displays all the log entries that reference an object at the specified address."); interpreter.AddCommand("histroot", new sosCommand("HistRoot"), "Displays information related to both promotions and relocations of the specified root."); + interpreter.AddCommand("sethostruntime", new sosCommand("SetHostRuntime"), "Sets or displays the .NET Core runtime directory to use to run managed code in SOS."); interpreter.AddCommand("soshelp", new sosCommand("Help"), "Displays all available commands when no parameter is specified, or displays detailed help information about the specified command. soshelp "); return true; } diff --git a/src/SOS/lldbplugin/sosplugin.h b/src/SOS/lldbplugin/sosplugin.h index ad3a68483..588ec468e 100644 --- a/src/SOS/lldbplugin/sosplugin.h +++ b/src/SOS/lldbplugin/sosplugin.h @@ -3,8 +3,8 @@ // See the LICENSE file in the project root for more information. #include +#include "mstypes.h" #define DEFINE_EXCEPTION_RECORD -#include #include #include #include "services.h" diff --git a/src/SOS/tests/README.md b/src/SOS/tests/README.md index 1b9c1eac2..a4ad7dce9 100644 --- a/src/SOS/tests/README.md +++ b/src/SOS/tests/README.md @@ -1,24 +1,24 @@ Testing libsosplugin ===================================== -**Test assembly** -Compile test assembly file using any C# compiler you have, for example: -- `gmcs test.cs` -- `corerun csc.exe /nologo /r:System.Private.CoreLib.dll test.cs` +**Running tests** + +The test.sh and testsos.sh scripts launches these tests and makes the following a lot easier. -**Running tests** -Make sure that python's lldb module is accessible. To run the tests, use the following command: -`python2 test_libsosplugin.py --corerun=corerun --sosplugin=sosplugin --assembly=assembly --timeout=timeout` +Make sure that python's lldb module is accessible. To run the tests manually, use the following command: + +`python2 test_libsosplugin.py --lldb --host --plugin --logfiledir --assembly ` + - `lldb` is a path to `lldb` to run -- `clrdir` is a directory with `corerun` and sosplugin -- `assembly` is a compiled test assembly (e.g. Test.exe) +- `host` is a path to .NET Core host like `corerun` or `dotnet` +- `plugin` is the path to the lldb sos plugin +- `logfiledir` is the path to put the log files +- `assembly` is a compiled test assembly (e.g. TestDebuggee.dll) - `timeout` is a deadline for a single test (in seconds) - `regex` is a regular expression matching tests to run - `repeat` is a number of passes for each test - - Log files for both failed and passed tests are `*.log` and `*.log.2` for standard output and error correspondingly. diff --git a/src/SOS/tests/t_cmd_bpmd_clear.py b/src/SOS/tests/t_cmd_bpmd_clear.py index a1ed820cd..c80d130fc 100644 --- a/src/SOS/tests/t_cmd_bpmd_clear.py +++ b/src/SOS/tests/t_cmd_bpmd_clear.py @@ -6,7 +6,7 @@ import lldb import re import testutils as test -# bpmd -clearall +# bpmd -clear def runScenario(assembly, debugger, target): @@ -30,10 +30,10 @@ def runScenario(assembly, debugger, target): # Output is not empty # Should be at least 'Adding pending breakpoints...' - test.assertTrue(len(out_msg) > 0) + test.assertTrue(res.GetOutputSize() > 0) # Error message is empty - test.assertTrue(len(err_msg) == 0) + test.assertTrue(res.GetErrorSize() == 0) # Delete the first breakpoint @@ -50,15 +50,15 @@ def runScenario(assembly, debugger, target): test.assertTrue(match) # Error message is empty - test.assertEqual(err_msg, '') + test.assertTrue(res.GetErrorSize() == 0) process.Continue() # Process must be exited - test.assertEqual(process.GetState(), lldb.eStateExited) + test.assertEqual(process.GetState(), lldb.eStateStopped) # The reason of this stop must be a breakpoint test.assertEqual(process.GetSelectedThread().GetStopReason(), - lldb.eStopReasonNone) + lldb.eStopReasonBreakpoint) # diff --git a/src/SOS/tests/t_cmd_bpmd_clearall.py b/src/SOS/tests/t_cmd_bpmd_clearall.py index 625fb0eef..2c3218505 100644 --- a/src/SOS/tests/t_cmd_bpmd_clearall.py +++ b/src/SOS/tests/t_cmd_bpmd_clearall.py @@ -53,6 +53,8 @@ def runScenario(assembly, debugger, target): test.assertTrue(res.GetErrorSize() == 0) process.Continue() + process.Continue() + # Process must be exited test.assertEqual(process.GetState(), lldb.eStateExited) diff --git a/src/SOS/tests/test_libsosplugin.py b/src/SOS/tests/test_libsosplugin.py old mode 100644 new mode 100755 index 15b9108e0..a2d711c20 --- a/src/SOS/tests/test_libsosplugin.py +++ b/src/SOS/tests/test_libsosplugin.py @@ -93,6 +93,9 @@ class TestSosCommands(unittest.TestCase): def t_cmd_bpmd_methoddesc(self): self.do_test('t_cmd_bpmd_methoddesc') + def t_cmd_bpmd_clear(self): + self.do_test('t_cmd_bpmd_clear') + def t_cmd_bpmd_clearall(self): self.do_test('t_cmd_bpmd_clearall') diff --git a/src/SOS/tests/testsos.sh b/src/SOS/tests/testsos.sh index 41ebcd8d2..b1b9a02b7 100755 --- a/src/SOS/tests/testsos.sh +++ b/src/SOS/tests/testsos.sh @@ -36,7 +36,13 @@ fi echo $__LLDB_Path +# Turn on stress logging so the dumplog and histinit commands pass +export COMPlus_LogFacility=0xffffffbf +export COMPlus_LogLevel=6 +export COMPlus_StressLog=1 +export COMPlus_StressLogSize=65536 + cd $__ProjectRoot/src/SOS/tests/ rm -f StressLog.txt -python2 $__ProjectRoot/src/SOS/tests/test_libsosplugin.py --lldb $__LLDB_Path --host $__Host --plugin $__Plugin --logfiledir $__LogFileDir --assembly $__TestProgram +python $__ProjectRoot/src/SOS/tests/test_libsosplugin.py --lldb $__LLDB_Path --host $__Host --plugin $__Plugin --logfiledir $__LogFileDir --assembly $__TestProgram diff --git a/src/ToolBox/SOS/Strike/ApolloNative.rc b/src/ToolBox/SOS/Strike/ApolloNative.rc deleted file mode 100644 index ba320af91..000000000 --- a/src/ToolBox/SOS/Strike/ApolloNative.rc +++ /dev/null @@ -1,10 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#define FX_VER_FILEDESCRIPTION_STR "Microsoft NTSD extension for .NET Runtime\0" - -#include -#include - -DOCUMENTATION TEXT DISCARDABLE "apollososdocs.txt" diff --git a/src/ToolBox/SOS/Strike/apollososdocs.txt b/src/ToolBox/SOS/Strike/apollososdocs.txt deleted file mode 100644 index 29dd8b626..000000000 --- a/src/ToolBox/SOS/Strike/apollososdocs.txt +++ /dev/null @@ -1,2725 +0,0 @@ -------------------------------------------------------------------------------- -NOTE: THIS FILE CONTAINS SOS DOCUMENTATION. THE FORMAT OF THE FILE IS: - - -COMMAND: - -\\ - - - -The first command is "contents" which is the general help screen. The rest -correspond to SOS command names. This file is embedded as a resource in the SOS -binary. Be sure to list any new commands here. -------------------------------------------------------------------------------- - - - -COMMAND: contents. -SOS is a debugger extension DLL designed to aid in the debugging of managed -programs. Functions are listed by category, then roughly in order of -importance. Shortcut names for popular functions are listed in parenthesis. -Type "!help " for detailed info on that function. - -Object Inspection Examining code and stacks ------------------------------ ----------------------------- -DumpObj (do) Threads -DumpArray (da) ThreadState -DumpStackObjects (dso) IP2MD -DumpHeap U -DumpVC DumpStack -GCRoot EEStack -ObjSize CLRStack -FinalizeQueue GCInfo -PrintException (pe) EHInfo -TraverseHeap BPMD -Watch COMState - StopOnCatch - SuppressJitOptimization - -Examining CLR data structures Diagnostic Utilities ------------------------------ ----------------------------- -DumpDomain VerifyHeap -EEHeap VerifyObj -Name2EE FindRoots -SyncBlk HeapStat -DumpMT GCWhere -DumpClass ListNearObj (lno) -DumpMD GCHandles -Token2EE GCHandleLeaks -EEVersion FinalizeQueue (fq) -DumpModule FindAppDomain -ThreadPool SaveModule -DumpAssembly ProcInfo -DumpSigElem StopOnException (soe) -DumpRuntimeTypes DumpLog -DumpSig VMMap -RCWCleanupList VMStat -DumpIL MinidumpMode -DumpRCW AnalyzeOOM (ao) -DumpCCW - -Examining the GC history Other ------------------------------ ----------------------------- -HistInit FAQ -HistRoot SaveState -HistObj -HistObjFind -HistClear -\\ - -COMMAND: faq. ->> Where can I get the right version of SOS for my build? - -If you are running version 1.1 or 2.0 of the CLR, SOS.DLL is installed in the -same directory as the main CLR dll (CLR.DLL). Newer versions of the -Windows Debugger provide a command to make it easy to load the right copy of -SOS.DLL: - - ".loadby sos clr" - -That will load the SOS extension DLL from the same place that CLR.DLL is -loaded in the process. You shouldn't attempt to use a version of SOS.DLL that -doesn't match the version of CLR.DLL. You can find the version of -CLR.DLL by running - - "lmvm clr" - -in the debugger. Note that if you are running CoreCLR (e.g. Silverlight) -then you should replace "clr" with "coreclr". - -If you are using a dump file created on another machine, it is a little bit -more complex. You need to make sure the mscordacwks.dll file that came with -that install is on your symbol path, and you need to load the corresponding -version of sos.dll (typing .load rather than using the -.loadby shortcut). Within the Microsoft corpnet, we keep tagged versions -of mscordacwks.dll, with names like mscordacwks__.dll -that the Windows Debugger can load. If you have the correct symbol path to the -binaries for that version of the Runtime, the Windows Debugger will load the -correct mscordacwks.dll file. - ->> I have a chicken and egg problem. I want to use SOS commands, but the CLR - isn't loaded yet. What can I do? - -In the debugger at startup you can type: - - "sxe clrn" - -Let the program run, and it will stop with the notice - - "CLR notification: module 'mscorlib' loaded" - -At this time you can use SOS commands. To turn off spurious notifications, -type: - - "sxd clrn" - ->> I got the following error message. Now what? - - 0:000> .loadby sos clr - 0:000> !DumpStackObjects - Failed to find runtime DLL (clr.dll), 0x80004005 - Extension commands need clr.dll in order to have something to do. - 0:000> - -This means that the CLR is not loaded yet, or has been unloaded. You need to -wait until your managed program is running in order to use these commands. If -you have just started the program a good way to do this is to type - - bp clr!EEStartup "g @$ra" - -in the debugger, and let it run. After the function EEStartup is finished, -there will be a minimal managed environment for executing SOS commands. - ->> I have a partial memory minidump, and !DumpObj doesn't work. Why? - -In order to run SOS commands, many CLR data structures need to be traversed. -When creating a minidump without full memory, special functions are called at -dump creation time to bring those structures into the minidump, and allow a -minimum set of SOS debugging commands to work. At this time, those commands -that can provide full or partial output are: - -CLRStack -Threads -Help -PrintException -EEVersion - -For a minidump created with this minimal set of functionality in mind, you -will get an error message when running any other commands. A full memory dump -(obtained with ".dump /ma " in the Windows Debugger) is often the -best way to debug a managed program at this level. - ->> What other tools can I use to find my bug? - -Turn on Managed Debugging Assistants. These enable additional runtime diagnostics, -particularly in the area of PInvoke/Interop. Adam Nathan has written some great -information about that: - -http://blogs.msdn.com/adam_nathan/ - ->> Does SOS support DML? - -Yes. SOS respects the .prefer_dml option in the debugger. If this setting is -turned on, then SOS will output DML by default. Alternatively, you may leave -it off and add /D to the beginning of a command to get DML based output for it. -Not all SOS commands support DML output. - -\\ - -COMMAND: stoponexception. -!StopOnException [-derived] - [-create | -create2] - - [] - -!StopOnException helps when you want the Windows Debugger to stop on a -particular managed exception, say a System.OutOfMemoryException, but continue -running if other exceptions are thrown. The command can be used in two ways: - -1) When you just want to stop on one particular CLR exception - - At the debugger prompt, anytime after loading SOS, type: - - !StopOnException -create System.OutOfMemoryException 1 - - The pseudo-register number (1) indicates that SOS can use register $t1 for - maintaining the breakpoint. The -create parameter allows SOS to go ahead - and set up the breakpoint as a first-chance exception. -create2 would set - it up as a 2nd-chance exception. - -2) When you need more complex logic for stopping on a CLR exception - - !StopOnException can be used purely as a predicate in a larger expression. - If you type: - - !StopOnException System.OutOfMemoryException 3 - - then register $t3 will be set to 1 if the last thrown exception on the - current thread is a System.OutOfMemoryException. Otherwise, $t3 will be set - to 0. Using the Windows Debugger scripting language, you could chain - such calls together to stop on various exception types. You'll have to - manually create such predicates, for example: - - sxe -c "!soe System.OutOfMemoryException 3; - !soe -derived System.IOException 4; - .if(@$t3==1 || @$t4==1) { .echo 'stop' } .else {g}" - -The -derived option will cause StopOnException to set the pseudo-register to -1 even if the thrown exception type doesn't exactly match the exception type -given, but merely derives from it. So, "-derived System.Exception" would catch -every exception in the System.Exception heirarchy. - -The pseudo-register number is optional. If you don't pass a number, SOS will -use pseudo-register $t1. - -Note that !PrintException with no parameters will print out the last thrown -exception on the current thread (if any). You can use !soe as a shortcut for -!StopOnException. -\\ - -COMMAND: minidumpmode. -!MinidumpMode <0 or 1> - -Minidumps created with ".dump /m" or ".dump" have a very small set of -CLR-specific data, just enough to run a subset of SOS commands correctly. You -are able to run other SOS commands, but they may fail with unexpected errors -because required areas of memory are not mapped in or only partially mapped -in. At this time, SOS cannot reliably detect if a dump file is of this type -(for one thing, custom dump commands can map in additional memory, but there -is no facility to read meta-information about this memory). You can turn this -option on to protect against running unsafe commands against small minidumps. - -By default, MinidumpMode is 0, so there is no restriction on commands that will -run against a minidump. -\\ - -COMMAND: dumpobj. -!DumpObj [-nofields] - -This command allows you to examine the fields of an object, as well as learn -important properties of the object such as the EEClass, the MethodTable, and -the size. - -You might find an object pointer by running !DumpStackObjects and choosing -from the resultant list. Here is a simple object: - - 0:000> !DumpObj a79d40 - Name: Customer - MethodTable: 009038ec - EEClass: 03ee1b84 - Size: 20(0x14) bytes - (C:\pub\unittest.exe) - Fields: - MT Field Offset Type VT Attr Value Name - 009038ec 4000008 4 Customer 0 instance 00a79ce4 name - 009038ec 4000009 8 Bank 0 instance 00a79d2c bank - -Note that fields of type Customer and Bank are themselves objects, and you can -run !DumpObj on them too. You could look at the field directly in memory using -the offset given. "dd a79d40+8 l1" would allow you to look at the bank field -directly. Be careful about using this to set memory breakpoints, since objects -can move around in the garbage collected heap. - -What else can you do with an object? You might run !GCRoot, to determine what -roots are keeping it alive. Or you can find all objects of that type with -"!DumpHeap -type Customer". - -The column VT contains the value 1 if the field is a valuetype structure, and -0 if the field contains a pointer to another object. For valuetypes, you can -take the MethodTable pointer in the MT column, and the Value and pass them to -the command !DumpVC. - -The abbreviation !do can be used for brevity. - -The arguments in detail: --nofields: do not print fields of the object, useful for objects like - String -\\ - -COMMAND: dumparray. -!DumpArray - [-start ] - [-length ] - [-details] - [-nofields] - - -This command allows you to examine elements of an array object. -The arguments in detail: - -start : optional, only supported for single dimension array. - Specify from which index the command shows the elements. - -length : optional, only supported for single dimension array. - Specify how many elements to show. - -details: optional. Ask the command to print out details - of the element using !DumpObj and !DumpVC format. - -nofields: optional, only takes effect when -details is used. Do - not print fields of the elements. Useful for arrays of - objects like String - - Example output: - - 0:000> !dumparray -start 2 -length 3 -details 00ad28d0 - Name: Value[] - MethodTable: 03e41044 - EEClass: 03e40fc0 - Size: 132(0x84) bytes - Array: Rank 1, Number of elements 10, Type VALUETYPE - Element Type: Value - [2] 00ad28f0 - Name: Value - MethodTable 03e40f4c - EEClass: 03ef1698 - Size: 20(0x14) bytes - (C:\bugs\225271\arraytest.exe) - Fields: - MT Field Offset Type Attr Value Name - 5b9a628c 4000001 0 System.Int32 instance 2 x - 5b9a628c 4000002 4 System.Int32 instance 4 y - 5b9a628c 4000003 8 System.Int32 instance 6 z - [3] 00ad28fc - Name: Value - MethodTable 03e40f4c - EEClass: 03ef1698 - Size: 20(0x14) bytes - (C:\bugs\225271\arraytest.exe) - Fields: - MT Field Offset Type Attr Value Name - 5b9a628c 4000001 0 System.Int32 instance 3 x - 5b9a628c 4000002 4 System.Int32 instance 6 y - 5b9a628c 4000003 8 System.Int32 instance 9 z - [4] 00ad2908 - Name: Value - MethodTable 03e40f4c - EEClass: 03ef1698 - Size: 20(0x14) bytes - (C:\bugs\225271\arraytest.exe) - Fields: - MT Field Offset Type Attr Value Name - 5b9a628c 4000001 0 System.Int32 instance 4 x - 5b9a628c 4000002 4 System.Int32 instance 8 y - 5b9a628c 4000003 8 System.Int32 instance 12 z - - -\\ - -COMMAND: dumpstackobjects. -!DumpStackObjects [-verify] [top stack [bottom stack]] - -This command will display any managed objects it finds within the bounds of -the current stack. Combined with the stack tracing commands like K and -!CLRStack, it is a good aid to determining the values of locals and -parameters. - -If you use the -verify option, each non-static CLASS field of an object -candidate is validated. This helps to eliminate false positives. It is not -on by default because very often in a debugging scenario, you are -interested in objects with invalid fields. - -The abbreviation !dso can be used for brevity. -\\ - -COMMAND: dumpheap. -!DumpHeap [-stat] - [-strings] - [-short] - [-min ] - [-max ] - [-thinlock] - [-startAtLowerBound] - [-mt ] - [-type ] - [start [end]] - -!DumpHeap is a powerful command that traverses the garbage collected heap, -collection statistics about objects. With it's various options, it can look for -particular types, restrict to a range, or look for ThinLocks (see !SyncBlk -documentation). Finally, it will provide a warning if it detects excessive -fragmentation in the GC heap. - -When called without options, the output is first a list of objects in the heap, -followed by a report listing all the types found, their size and number: - - 0:000> !dumpheap - Address MT Size - 00a71000 0015cde8 12 Free - 00a7100c 0015cde8 12 Free - 00a71018 0015cde8 12 Free - 00a71024 5ba58328 68 - 00a71068 5ba58380 68 - 00a710ac 5ba58430 68 - 00a710f0 5ba5dba4 68 - ... - total 619 objects - Statistics: - MT Count TotalSize Class Name - 5ba7607c 1 12 System.Security.Permissions.HostProtectionResource - 5ba75d54 1 12 System.Security.Permissions.SecurityPermissionFlag - 5ba61f18 1 12 System.Collections.CaseInsensitiveComparer - ... - 0015cde8 6 10260 Free - 5ba57bf8 318 18136 System.String - ... - -"Free" objects are simply regions of space the garbage collector can use later. -If 30% or more of the heap contains "Free" objects, the process may suffer from -heap fragmentation. This is usually caused by pinning objects for a long time -combined with a high rate of allocation. Here is example output where !DumpHeap -provides a warning about fragmentation: - - - Fragmented blocks larger than 1MB: - Addr Size Followed by - 00a780c0 1.5MB 00bec800 System.Byte[] - 00da4e38 1.2MB 00ed2c00 System.Byte[] - 00f16df0 1.2MB 01044338 System.Byte[] - -The arguments in detail: - --stat Restrict the output to the statistical type summary --strings Restrict the output to a statistical string value summary --short Limits output to just the address of each object. This allows you - to easily pipe output from the command to another debugger - command for automation. --min Ignore objects less than the size given in bytes --max Ignore objects larger than the size given in bytes --thinlock Report on any ThinLocks (an efficient locking scheme, see !SyncBlk - documentation for more info) --startAtLowerBound - Force heap walk to begin at lower bound of a supplied address range. - (During plan phase, the heap is often not walkable because objects - are being moved. In this case, DumpHeap may report spurious errors, - in particular bad objects. It may be possible to traverse more of - the heap after the reported bad object. Even if you specify an - address range, !DumpHeap will start its walk from the beginning of - the heap by default. If it finds a bad object before the specified - range, it will stop before displaying the part of the heap in which - you are interested. This switch will force !DumpHeap to begin its - walk at the specified lower bound. You must supply the address of a - good object as the lower bound for this to work. Display memory at - the address of the bad object to manually find the next method - table (use !dumpmt to verify). If the GC is currently in a call to - memcopy, You may also be able to find the next object's address by - adding the size to the start address given as parameters.) --mt List only those objects with the MethodTable given --type List only those objects whose type name is a substring match of the - string provided. -start Begin listing from this address -end Stop listing at this address - -A special note about -type: Often, you'd like to find not only Strings, but -System.Object arrays that are constrained to contain Strings. ("new -String[100]" actually creates a System.Object array, but it can only hold -System.String object pointers). You can use -type in a special way to find -these arrays. Just pass "-type System.String[]" and those Object arrays will -be returned. More generally, "-type []". - -The start/end parameters can be obtained from the output of !EEHeap -gc. For -example, if you only want to list objects in the large heap segment: - - 0:000> !eeheap -gc - Number of GC Heaps: 1 - generation 0 starts at 0x00c32754 - generation 1 starts at 0x00c32748 - generation 2 starts at 0x00a71000 - segment begin allocated size - 00a70000 00a71000 010443a8 005d33a8(6108072) - Large object heap starts at 0x01a71000 - segment begin allocated size - 01a70000 01a71000 01a75000 0x00004000(16384) - Total Size 0x5d73a8(6124456) - ------------------------------ - GC Heap Size 0x5d73a8(6124456) - - 0:000> !dumpheap 1a71000 1a75000 - Address MT Size - 01a71000 5ba88bd8 2064 - 01a71810 0019fe48 2032 Free - 01a72000 5ba88bd8 4096 - 01a73000 0019fe48 4096 Free - 01a74000 5ba88bd8 4096 - total 5 objects - Statistics: - MT Count TotalSize Class Name - 0019fe48 2 6128 Free - 5ba88bd8 3 10256 System.Object[] - Total 5 objects - -Finally, if GC heap corruption is present, you may see an error like this: - - 0:000> !dumpheap -stat - object 00a73d24: does not have valid MT - curr_object : 00a73d24 - Last good object: 00a73d14 - ---------------- - -That indicates a serious problem. See the help for !VerifyHeap for more -information on diagnosing the cause. -\\ - -COMMAND: dumpvc. -!DumpVC
- -!DumpVC allows you to examine the fields of a value class. In C#, this is a -struct, and lives on the stack or within an Object on the GC heap. You need -to know the MethodTable address to tell SOS how to interpret the fields, as -a value class is not a first-class object with it's own MethodTable as the -first field. For example: - - 0:000> !DumpObj a79d98 - Name: Mainy - MethodTable: 009032d8 - EEClass: 03ee1424 - Size: 28(0x1c) bytes - (C:\pub\unittest.exe) - Fields: - MT Field Offset Type Attr Value Name - 0090320c 4000010 4 VALUETYPE instance 00a79d9c m_valuetype - 009032d8 400000f 4 CLASS static 00a79d54 m_sExcep - -m_valuetype is a value type. The value in the MT column (0090320c) is the -MethodTable for it, and the Value column provides the start address: - - 0:000> !DumpVC 0090320c 00a79d9c - Name: Funny - MethodTable 0090320c - EEClass: 03ee14b8 - Size: 28(0x1c) bytes - (C:\pub\unittest.exe) - Fields: - MT Field Offset Type Attr Value Name - 0090320c 4000001 0 CLASS instance 00a743d8 signature - 0090320c 4000002 8 System.Int32 instance 2345 m1 - 0090320c 4000003 10 System.Boolean instance 1 b1 - 0090320c 4000004 c System.Int32 instance 1234 m2 - 0090320c 4000005 4 CLASS instance 00a79d98 backpointer - -!DumpVC is quite a specialized function. Some managed programs make heavy use -of value classes, while others do not. -\\ - -COMMAND: gcroot. -!GCRoot [-nostacks] - -!GCRoot looks for references (or roots) to an object. These can exist in four -places: - - 1. On the stack - 2. Within a GC Handle - 3. In an object ready for finalization - 4. As a member of an object found in 1, 2 or 3 above. - -First, all stacks will be searched for roots, then handle tables, and finally -the freachable queue of the finalizer. Some caution about the stack roots: -!GCRoot doesn't attempt to determine if a stack root it encountered is valid -or is old (discarded) data. You would have to use !CLRStack and !U to -disassemble the frame that the local or argument value belongs to in order to -determine if it is still in use. - -Because people often want to restrict the search to gc handles and freachable -objects, there is a -nostacks option. -\\ - -COMMAND: objsize. -!ObjSize [] | [-aggregate] [-stat] - -With no parameters, !ObjSize lists the size of all objects found on managed -threads. It also enumerates all GCHandles in the process, and totals the size -of any objects pointed to by those handles. In calculating object size, -!ObjSize includes the size of all child objects in addition to the parent. - -For example, !DumpObj lists a size of 20 bytes for this Customer object: - - 0:000> !do a79d40 - Name: Customer - MethodTable: 009038ec - EEClass: 03ee1b84 - Size: 20(0x14) bytes - (C:\pub\unittest.exe) - Fields: - MT Field Offset Type Attr Value Name - 009038ec 4000008 4 CLASS instance 00a79ce4 name - 009038ec 4000009 8 CLASS instance 00a79d2c bank - 009038ec 400000a c System.Boolean instance 1 valid - -but !ObjSize lists 152 bytes: - - 0:000> !ObjSize a79d40 - sizeof(00a79d40) = 152 ( 0x98) bytes (Customer) - -This is because a Customer points to a Bank, has a name, and the Bank points to -an Address string. You can use !ObjSize to identify any particularly large -objects, such as a managed cache in a web server. - -While running ObjSize with no arguments may point to specific roots that hold -onto large amounts of memory it does not provide information regarding the -amount of managed memory that is still alive. This is due to the fact that a -number of roots can share a common subgraph, and that part will be reported in -the size of all the roots that reference the subgraph. The -aggregate argument -is meant to answer this question: - -The -aggregate option can be used in conjunction with the -stat argument to get -a detailed view of what are the types that are still rooted. Using !dumpheap --stat and !objsize -aggregate -stat one can determine what are the the objects -that are not rooted any more and diagnose various memory issues. - -Sample output when using the -aggregate and -stat: - - 0:003> !ObjSize -aggregate -stat - Scan Thread 0 OSTHread f70 - Scan Thread 2 OSTHread ef8 - Statistics: - MT Count TotalSize Class Name - 01e63768 1 12 Test+d - 01e63660 1 16 Test+c - 01e63548 1 16 Test+b - 01e632f8 1 16 Test+a - ... - 5b6c6d40 9 504 System.Collections.Hashtable - 5b6ebe28 3 552 System.Byte[] - 5b6ec0bc 9 1296 System.Collections.Hashtable+bucket[] - 5b6ec200 9 1436 System.Char[] - 5b6c447c 77 2468 System.String - 5b6ebd64 8 9020 System.Object[] - Total 203 objects - Total Memory Size 18332 (0x479c) bytes - -\\ - -COMMAND: finalizequeue. -!FinalizeQueue [-detail] | [-allReady] [-short] - -This command lists the objects registered for finalization. Here is output from -a simple program: - - 0:000> !finalizequeue - SyncBlocks to be cleaned up: 0 - MTA Interfaces to be released: 0 - STA Interfaces to be released: 1 - generation 0 has 4 finalizable objects (0015bc90->0015bca0) - generation 1 has 0 finalizable objects (0015bc90->0015bc90) - generation 2 has 0 finalizable objects (0015bc90->0015bc90) - Ready for finalization 0 objects (0015bca0->0015bca0) - Statistics: - MT Count TotalSize Class Name - 5ba6cf78 1 24 Microsoft.Win32.SafeHandles.SafeFileHandle - 5ba5db04 1 68 System.Threading.Thread - 5ba73e28 2 112 System.IO.StreamWriter - Total 4 objects - -The GC heap is divided into generations, and objects are listed accordingly. We -see that only generation 0 (the youngest generation) has any objects registered -for finalization. The notation "(0015bc90->0015bca0)" means that if you look at -memory in that range, you'll see the object pointers that are registered: - -0:000> dd 15bc90 15bca0-4 -0015bc90 00a743f4 00a79f00 00a7b3d8 00a7b47c - -You could run !DumpObj on any of those pointers to learn more. In this example, -there are no objects ready for finalization, presumably because they still have -roots (You can use !GCRoot to find out). The statistics section provides a -higher-level summary of the objects registered for finalization. Note that -objects ready for finalization are also included in the statistics (if any). - -Specifying -short will inhibit any display related to SyncBlocks or RCWs. - -The arguments in detail: - --allReady Specifying this argument will allow for the display of all objects - that are ready for finalization, whether they are already marked by - the GC as such, or whether the next GC will. The objects that are - not in the "Ready for finalization" list are finalizable objects that - are no longer rooted. This option can be very expensive, as it - verifies whether all the objects in the finalizable queues are still - rooted or not. --short Limits the output to just the address of each object. If used in - conjunction with -allReady it enumerates all objects that have a - finalizer that are no longer rooted. If used independently it lists - all objects in the finalizable and "ready for finalization" queues. --detail Will display extra information on any SyncBlocks that need to be - cleaned up, and on any RuntimeCallableWrappers (RCWs) that await - cleanup. Both of these data structures are cached and cleaned up by - the finalizer thread when it gets a chance to run. -\\ - -COMMAND: printexception. -!PrintException [-nested] [-lines] [] - -This will format fields of any object derived from System.Exception. One of the -more useful aspects is that it will format the _stackTrace field, which is a -binary array. If _stackTraceString field is not filled in, that can be helpful -for debugging. You can of course use !DumpObj on the same exception object to -explore more fields. - -If called with no parameters, PrintException will look for the last outstanding -exception on the current thread and print it. This will be the same exception -that shows up in a run of !Threads. - -!PrintException will notify you if there are any nested exceptions on the -current managed thread. (A nested exception occurs when you throw another -exception within a catch handler already being called for another exception). -If there are nested exceptions, you can re-run !PrintException with the -"-nested" option to get full details on the nested exception objects. The -!Threads command will also tell you which threads have nested exceptions. - -!PrintException can display source information if available, by specifying the --lines command line argument. - -The abbreviation !pe can be used for brevity. -\\ - -COMMAND: traverseheap. -!TraverseHeap [-xml] [-verify] - -!TraverseHeap writes out a file in a format understood by the CLR Profiler. -You can download the CLR Profiler from this link: - -http://www.microsoft.com/downloads/details.aspx?FamilyId=86CE6052-D7F4-4AEB- -9B7A-94635BEEBDDA&displaylang=en - -It creates a graphical display of the GC heap to help you analyze the state of -your application. - -If you pass the -verify option it will do more sanity checking of the heap -as it dumps it. Use this option if heap corruption is suspected. - -If you pass the "-xml" flag, the file is instead written out in an easy to -understand xml format: - - - - - ... - - - - - ... - - - - - - ... - - ... - - - -You can break into your process, load SOS, take a snapshot of your heap with -this function, then continue. -\\ -COMMAND: threadstate. -!ThreadState value - -The !Threads command outputs, among other things, the state of the thread. -This is a bit field which corresponds to various states the thread is in. -To check the state of the thread, simply pass that bit field from the -output of !Threads into !ThreadState. - -Example: - 0:003> !Threads - ThreadCount: 2 - UnstartedThread: 0 - BackgroundThread: 1 - PendingThread: 0 - DeadThread: 0 - Hosted Runtime: no - PreEmptive GC Alloc Lock - ID OSID ThreadOBJ State GC Context Domain Count APT Exception - 0 1 250 0019b068 a020 Disabled 02349668:02349fe8 0015def0 0 MTA - 2 2 944 001a6020 b220 Enabled 00000000:00000000 0015def0 0 MTA (Finalizer) - 0:003> !ThreadState b220 - Legal to Join - Background - CLR Owns - CoInitialized - In Multi Threaded Apartment - -Possible thread states: - Thread Abort Requested - GC Suspend Pending - User Suspend Pending - Debug Suspend Pending - GC On Transitions - Legal to Join - Yield Requested - Hijacked by the GC - Blocking GC for Stack Overflow - Background - Unstarted - Dead - CLR Owns - CoInitialized - In Single Threaded Apartment - In Multi Threaded Apartment - Reported Dead - Fully initialized - Task Reset - Sync Suspended - Debug Will Sync - Stack Crawl Needed - Suspend Unstarted - Aborted - Thread Pool Worker Thread - Interruptible - Interrupted - Completion Port Thread - Abort Initiated - Finalized - Failed to Start - Detached -\\ -COMMAND: threads. -!Threads [-live] [-special] - -!Threads lists all the mananaged threads in the process. - --live: optional. Only print threads associated with a live thread. --special: optional. With this switch, the command will display all the special - threads created by CLR. Those threads might not be managed threads - so they might not be shown in the first part of the command's - output. Example of special threads include: GC threads (in - concurrent GC and server GC), Debugger helper threads, Finalizer - threads, AppDomain Unload threads, and Threadpool timer threads. - -Each thread has many attributes, many of which can be ignored. The important -ones are discussed below: - -There are three ID columns: - -1) The debugger shorthand ID (When the runtime is hosted this column might - display the special string "<<<<" when this internal thread object is not - associated with any physical thread - this may happen when the host reuses - the runtime internal thread object) -2) The CLR Thread ID -3) The OS thread ID. - -If PreEmptiveGC is enabled for a thread, then a garbage collection -can occur while that thread is running. For example, if you break in while -a managed thread is making a PInvoke call to a Win32 function, that thread -will be in PreEmptive GC mode. - -The Domain column indicates what AppDomain the thread is currently executing -in. You can pass this value to !DumpDomain to find out more. - -The APT column gives the COM apartment mode. - -Exception will list the last thrown exception (if any) for the thread. More -details can be obtained by passing the pointer value to !PrintException. If -you get the notation "(nested exceptions)", you can get details on those -exceptions by switching to the thread in question, and running -"!PrintException -nested". -\\ - -COMMAND: clrstack. -!CLRStack [-a] [-l] [-p] [-n] -!CLRStack [-a] [-l] [-p] [-i] [variable name] [frame] - -CLRStack attempts to provide a true stack trace for managed code only. It is -handy for clean, simple traces when debugging straightforward managed -programs. The -p parameter will show arguments to the managed function. The --l parameter can be used to show information on local variables in a frame. -SOS can't retrieve local names at this time, so the output for locals is in -the format = . The -a (all) parameter is a short-cut -for -l and -p combined. - -If the debugger has the option SYMOPT_LOAD_LINES specified (either by the -.lines or .symopt commands), SOS will look up the symbols for every managed -frame and if successful will display the corresponding source file name and -line number. The -n (No line numbers) parameter can be specified to disable -this behavior. - -When you see methods with the name "[Frame:...", that indicates a transition -between managed and unmanaged code. You could run !IP2MD on the return -addresses in the call stack to get more information on each managed method. - -On x64 platforms, Transition Frames are not displayed at this time. To avoid -heavy optimization of parameters and locals one can request the JIT compiler -to not optimize functions in the managed app by creating a file myapp.ini -(if your program is myapp.exe) in the same directory. Put the following lines -in myapp.ini and re-run: - -[.NET Framework Debugging Control] -GenerateTrackingInfo=1 -AllowOptimize=0 - -The -i option is a new EXPERIMENTAL addition to CLRStack and will use the ICorDebug -interfaces to display the managed stack and variables. With this option you can also -view and expand arrays and fields for managed variables. If a stack frame number is -specified in the command line, CLRStack will show you the parameters and/or locals -only for that frame (provided you specify -l or -p or -a of course). If a variable -name and a stack frame number are specified in the command line, CLRStack will show -you the parameters and/or locals for that frame, and will also show you the fields -for that variable name you specified. Here are some examples: - !CLRStack -i -a : This will show you all parameters and locals for all frames - !CLRStack -i -a 3 : This will show you all parameters and locals, for frame 3 - !CLRStack -i var1 0 : This will show you the fields of 'var1' for frame 0 - !CLRStack -i var1.abc 2 : This will show you the fields of 'var1', and expand - 'var1.abc' to show you the fields of the 'abc' field, - for frame 2. - !CLRStack -i var1.[basetype] 0 : This will show you the fields of 'var1', and - expand the base type of 'var1' to show you its - fields. - !CLRStack -i var1.[6] 0 : If 'var1' is an array, this will show you the element - at index 6 in the array, along with its fields -The -i options uses DML output for a better debugging experience, so typically you -should only need to execute "!CLRStack -i", and from there, click on the DML -hyperlinks to inspect the different managed stack frames and managed variables. -\\ - -COMMAND: ip2md. -!IP2MD - -Given an address in managed JITTED code, IP2MD attempts to find the MethodDesc -associated with it. For example, this output from K: - - 0:000> K - ChildEBP RetAddr - 00a79c78 03ef02ab image00400000!Mainy.Top()+0xb - 00a79c78 03ef01a6 image00400000!Mainy.Level(Int32)+0xb - 00a79c78 5d3725a1 image00400000!Mainy.Main()+0xee - 0012ea04 5d512f59 clr!CallDescrWorkerInternal+0x30 - 0012ee34 5d7946aa clr!CallDescrWorker+0x109 - - 0:000> !IP2MD 03ef01a6 - MethodDesc: 00902f40 - Method Name: Mainy.Main() - Class: 03ee1424 - MethodTable: 009032d8 - mdToken: 0600000d - Module: 001caa38 - IsJitted: yes - CodeAddr: 03ef00b8 - Source file: c:\Code\prj.mini\exc.cs @ 39 - -We have taken a return address into Mainy.Main, and discovered information -about that method. You could run !U, !DumpMT, !DumpClass, !DumpMD, or -!DumpModule on the fields listed to learn more. - -The "Source line" output will only be present if the debugger can find the -symbols for the managed module containing the given , and if the -debugger is configured to load line number information. -\\ - -COMMAND: u. -!U [-gcinfo] [-ehinfo] [-n] | - -Presents an annotated disassembly of a managed method when given a MethodDesc -pointer for the method, or a code address within the method body. Unlike the -debugger "U" function, the entire method from start to finish is printed, -with annotations that convert metadata tokens to names. - - - ... - 03ef015d b901000000 mov ecx,0x1 - 03ef0162 ff156477a25b call dword ptr [mscorlib_dll+0x3c7764 (5ba27764)] (System.Console.InitializeStdOutError(Boolean), mdToken: 06000713) - 03ef0168 a17c20a701 mov eax,[01a7207c] (Object: SyncTextWriter) - 03ef016d 89442414 mov [esp+0x14],eax - -If you pass the -gcinfo flag, you'll get inline display of the GCInfo for -the method. You can also obtain this information with the !GCInfo command. - -If you pass the -ehinfo flag, you'll get inline display of exception info -for the method. (Beginning and end of try/finally/catch handlers, etc.). -You can also obtain this information with the !EHInfo command. - -If the debugger has the option SYMOPT_LOAD_LINES specified (either by the -.lines or .symopt commands), and if symbols are available for the managed -module containing the method being examined, the output of the command will -include the source file name and line number corresponding to the -disassembly. The -n (No line numbers) flag can be specified to disable this -behavior. - - - ... - c:\Code\prj.mini\exc.cs @ 38: - 001b00b0 8b0d3020ab03 mov ecx,dword ptr ds:[3AB2030h] ("Break in debugger. When done type to continue: ") - 001b00b6 e8d5355951 call mscorlib_ni+0x8b3690 (51743690) (System.Console.Write(System.String), mdToken: 0600091b) - 001b00bb 90 nop - - c:\Code\prj.mini\exc.cs @ 39: - 001b00bc e863cdc651 call mscorlib_ni+0xf8ce24 (51e1ce24) (System.Console.ReadLine(), mdToken: 060008f6) - >>> 001b00c1 90 nop - ... -\\ - -COMMAND: dumpstack. -!DumpStack [-EE] [-n] [top stack [bottom stack]] - -[x86 and x64 documentation] - -This command provides a verbose stack trace obtained by "scraping." Therefore -the output is very noisy and potentially confusing. The command is good for -viewing the complete call stack when "kb" gets confused. For best results, -make sure you have valid symbols. - --EE will only show managed functions. - -If the debugger has the option SYMOPT_LOAD_LINES specified (either by the -.lines or .symopt commands), SOS will look up the symbols for every managed -frame and if successful will display the corresponding source file name and -line number. The -n (No line numbers) parameter can be specified to disable -this behavior. - -You can also pass a stack range to limit the output. Use the debugger -extension !teb to get the top and bottom stack values. - -\\ - -COMMAND: eestack. -!EEStack [-short] [-EE] - -This command runs !DumpStack on all threads in the process. The -EE option is -passed directly to !DumpStack. The -short option tries to narrow down the -output to "interesting" threads only, which is defined by - -1) The thread has taken a lock. -2) The thread has been "hijacked" in order to allow a garbage collection. -3) The thread is currently in managed code. - -See the documentation for !DumpStack for more info. -\\ - -COMMAND: ehinfo. -!EHInfo ( | ) - -!EHInfo shows the exception handling blocks in a jitted method. For each -handler, it shows the type, including code addresses and offsets for the clause -block and the handler block. For a TYPED handler, this would be the "try" and -"catch" blocks respectively. - -Sample output: - - 0:000> !ehinfo 33bbd3a - MethodDesc: 03310f68 - Method Name: MainClass.Main() - Class: 03571358 - MethodTable: 0331121c - mdToken: 0600000b - Module: 001e2fd8 - IsJitted: yes - CodeAddr: 033bbca0 - - EHHandler 0: TYPED catch(System.IO.FileNotFoundException) - Clause: [033bbd2b, 033bbd3c] [8b, 9c] - Handler: [033bbd3c, 033bbd50] [9c, b0] - - EHHandler 1: FINALLY - Clause: [033bbd83, 033bbda3] [e3, 103] - Handler: [033bbda3, 033bbdc5] [103, 125] - - EHHandler 2: TYPED catch(System.Exception) - Clause: [033bbd7a, 033bbdc5] [da, 125] - Handler: [033bbdc5, 033bbdd6] [125, 136] - -\\ - -COMMAND: gcinfo. -!GCInfo ( | ) - -!GCInfo is especially useful for CLR Devs who are trying to determine if there -is a bug in the JIT Compiler. It parses the GCEncoding for a method, which is a -compressed stream of data indicating when registers or stack locations contain -managed objects. It is important to keep track of this information, because if -a garbage collection occurs, the collector needs to know where roots are so it -can update them with new object pointer values. - -Here is sample output where you can see the change in register state. Normally -you would print this output out and read it alongside a disassembly of the -method. For example, the notation "reg EDI becoming live" at offset 0x11 of the -method might correspond to a "mov edi,ecx" statement. - - 0:000> !gcinfo 5b68dbb8 (5b68dbb8 is the start of a JITTED method) - entry point 5b68dbb8 - preJIT generated code - GC info 5b9f2f09 - Method info block: - method size = 0036 - prolog size = 19 - epilog size = 8 - epilog count = 1 - epilog end = yes - saved reg. mask = 000B - ebp frame = yes - fully interruptible=yes - double align = no - security check = no - exception handlers = no - local alloc = no - edit & continue = no - varargs = no - argument count = 4 - stack frame size = 1 - untracked count = 5 - var ptr tab count = 0 - epilog at 002E - 36 D4 8C C7 AA | - 93 F3 40 05 | - - Pointer table: - 14 | [EBP+14H] an untracked local - 10 | [EBP+10H] an untracked local - 0C | [EBP+0CH] an untracked local - 08 | [EBP+08H] an untracked local - 44 | [EBP-04H] an untracked local - F1 79 | 0011 reg EDI becoming live - 72 | 0013 reg ESI becoming live - 83 | 0016 push ptr 0 - 8B | 0019 push ptr 1 - 93 | 001C push ptr 2 - 9B | 001F push ptr 3 - 56 | 0025 reg EDX becoming live - 4A | 0027 reg ECX becoming live - 0E | 002D reg ECX becoming dead - 10 | 002D reg EDX becoming dead - E0 | 002D pop 4 ptrs - F0 31 | 0036 reg ESI becoming dead - 38 | 0036 reg EDI becoming dead - FF | - -This function is important for CLR Devs, but very difficult for anyone else to -make sense of it. You would usually come to use it if you suspect a gc heap -corruption bug caused by invalid GCEncoding for a particular method. -\\ - -COMMAND: comstate. -!COMState - -!COMState lists the com apartment model for each thread, as well as a Context -pointer if provided. -\\ - -COMMAND: bpmd. -!BPMD [-nofuturemodule] [] -!BPMD : -!BPMD -md -!BPMD -list -!BPMD -clear -!BPMD -clearall - -!BPMD provides managed breakpoint support. If it can resolve the method name -to a loaded, jitted or ngen'd function it will create a breakpoint with "bp". -If not then either the module that contains the method hasn't been loaded yet -or the module is loaded, but the function is not jitted yet. In these cases, -!bpmd asks the Windows Debugger to receive CLR Notifications, and waits to -receive news of module loads and JITs, at which time it will try to resolve -the function to a breakpoint. -nofuturemodule can be used to suppress -creating a breakpoint against a module that has not yet been loaded. - -Management of the list of pending breakpoints can be done via !BPMD -list, -!BPMD -clear, and !BPMD -clearall commands. !BPMD -list generates a list of -all of the pending breakpoints. If the pending breakpoint has a non-zero -module id, then that pending breakpoint is specific to function in that -particular loaded module. If the pending breakpoint has a zero module id, then -the breakpoint applies to modules that have not yet been loaded. Use -!BPMD -clear or !BPMD -clearall to remove pending breakpoints from the list. - -This brings up a good question: "I want to set a breakpoint on the main -method of my application. How can I do this?" - - 1) If you know the full path to SOS, use this command and skip to step 6 - .load - - 2) If you don't know the full path to sos, its usually next to clr.dll - You can wait for clr to load and then find it. - Start the debugger and type: - sxe -c "" clrn - 3) g - 4) You'll get the following notification from the debugger: - "CLR notification: module 'mscorlib' loaded" - 5) Now you can load SOS. Type - .loadby sos clr - - 6) Add the breakpoint with command such as: - !bpmd myapp.exe MyApp.Main - 7) g - 8) You will stop at the start of MyApp.Main. If you type "bl" you will - see the breakpoint listed. - -You can specify breakpoints by file and line number if: - a) You have some version of .Net Framework installed on your machine. Any OS from - Vista onwards should have .Net Framework installed by default. - b) You have PDBs for the managed modules that need breakpoints, and your symbol - path points to those PDBs. -This is often easier than module and method name syntax. For example: - !bpmd Demo.cs:15 - - -To correctly specify explicitly implemented methods make sure to retrieve the -method name from the metadata, or from the output of the "!dumpmt -md" command. -For example: - - public interface I1 - { - void M1(); - } - public class ExplicitItfImpl : I1 - { - ... - void I1.M1() // this method's name is 'I1.M1' - { ... } - } - - !bpmd myapp.exe ExplicitItfImpl.I1.M1 - - -!BPMD works equally well with generic types. Adding a breakpoint on a generic -type sets breakpoints on all already JIT-ted generic methods and sets a pending -breakpoint for any instantiation that will be JIT-ted in the future. - -Example for generics: - Given the following two classes: - - class G3 - { - ... - public void F(T1 p1, T2 p2, T3 p3) - { ... } - } - - public class G1 { - // static method - static public void G(W w) - { ... } - } - - One would issue the following commands to set breapoints on G3.F() and - G1.G(): - - !bpmd myapp.exe G3`3.F - !bpmd myapp.exe G1`1.G - -And for explicitly implemented methods on generic interfaces: - public interface IT1 - { - void M1(T t); - } - - public class ExplicitItfImpl : IT1 - { - ... - void IT1.M1(U u) // this method's name is 'IT1.M1' - { ... } - } - - !bpmd bpmd.exe ExplicitItfImpl`1.IT1.M1 - -Additional examples: - If IT1 and ExplicitItfImpl are types declared inside another class, - Outer, the bpmd command would become: - - !bpmd bpmd.exe Outer+ExplicitItfImpl`1.Outer.IT1.M1 - - (note that the fully qualified type name for ExplicitItfImpl became - Outer+ExplicitItfImpl, using the '+' separator, while the method name - is Outer.IT1.M1, using a '.' as the separator) - - Furthermore, if the Outer class resides in a namespace, NS, the bpmd - command to use becomes: - - !bpmd bpmd.exe NS.Outer+ExplicitItfImpl`1.NS.Outer.IT1.M1 - -!BPMD does not accept offsets nor parameters in the method name. You can add -an IL offset as an optional parameter seperate from the name. If there are overloaded -methods, !bpmd will set a breakpoint for all of them. - -In the case of hosted environments such as SQL, the module name may be -complex, like 'price, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'. -For this case, just be sure to surround the module name with single quotes, -like: - -!bpmd 'price, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' Price.M2 - -\\ - -COMMAND: dumpdomain. -!DumpDomain [] - -When called with no parameters, !DumpDomain will list all the AppDomains in the -process. It enumerates each Assembly loaded into those AppDomains as well. -In addition to your application domain, and any domains it might create, there -are two special domains: the Shared Domain and the System Domain. - -Any Assembly pointer in the output can be passed to !DumpAssembly. Any Module -pointer in the output can be passed to !DumpModule. Any AppDomain pointer can -be passed to !DumpDomain to limit output only to that AppDomain. Other -functions provide an AppDomain pointer as well, such as !Threads where it lists -the current AppDomain for each thread. -\\ - -COMMAND: eeheap. -!EEHeap [-gc] [-loader] - -!EEHeap enumerates process memory consumed by internal CLR data structures. You -can limit the output by passing "-gc" or "-loader". All information will be -displayed otherwise. - -The information for the Garbage Collector lists the ranges of each Segment in -the managed heap. This can be useful if you believe you have an object pointer. -If the pointer falls within a segment range given by "!EEHeap -gc", then you do -have an object pointer, and can attempt to run "!DumpObj" on it. - -Here is output for a simple program: - - 0:000> !eeheap -gc - Number of GC Heaps: 1 - generation 0 starts at 0x00a71018 - generation 1 starts at 0x00a7100c - generation 2 starts at 0x00a71000 - segment begin allocated size - 00a70000 00a71000 00a7e01c 0000d01c(53276) - Large object heap starts at 0x01a71000 - segment begin allocated size - 01a70000 01a71000 01a76000 0x00005000(20480) - Total Size 0x1201c(73756) - ------------------------------ - GC Heap Size 0x1201c(73756) - -So the total size of the GC Heap is only 72K. On a large web server, with -multiple processors, you can expect to see a GC Heap of 400MB or more. The -Garbage Collector attempts to collect and reclaim memory only when required to -by memory pressure for better performance. You can also see the notion of -"generations," wherein the youngest objects live in generation 0, and -long-lived objects eventually get "promoted" to generation 2. - -The loader output lists various private heaps associated with AppDomains. It -also lists heaps associated with the JIT compiler, and heaps associated with -Modules. For example: - - 0:000> !EEHeap -loader - Loader Heap: - -------------------------------------- - System Domain: 5e0662a0 - LowFrequencyHeap:008f0000(00002000:00001000) Size: 0x00001000 bytes. - HighFrequencyHeap:008f2000(00008000:00001000) Size: 0x00001000 bytes. - StubHeap:008fa000(00002000:00001000) Size: 0x00001000 bytes. - Total size: 0x3000(12288)bytes - -------------------------------------- - Shared Domain: 5e066970 - LowFrequencyHeap:00920000(00002000:00001000) 03e30000(00010000:00003000) Size: 0x00004000 bytes. - Wasted: 0x00001000 bytes. - HighFrequencyHeap:00922000(00008000:00001000) Size: 0x00001000 bytes. - StubHeap:0092a000(00002000:00001000) Size: 0x00001000 bytes. - Total size: 0x6000(24576)bytes - -------------------------------------- - Domain 1: 14f000 - LowFrequencyHeap:00900000(00002000:00001000) 03ee0000(00010000:00003000) Size: 0x00004000 bytes. - Wasted: 0x00001000 bytes. - HighFrequencyHeap:00902000(00008000:00003000) Size: 0x00003000 bytes. - StubHeap:0090a000(00002000:00001000) Size: 0x00001000 bytes. - Total size: 0x8000(32768)bytes - -------------------------------------- - Jit code heap: - Normal JIT:03ef0000(00010000:00002000) Size: 0x00002000 bytes. - Total size: 0x2000(8192)bytes - -------------------------------------- - Module Thunk heaps: - Module 5ba22410: Size: 0x00000000 bytes. - Module 001c1320: Size: 0x00000000 bytes. - Module 001c03f0: Size: 0x00000000 bytes. - Module 001caa38: Size: 0x00000000 bytes. - Total size: 0x0(0)bytes - -------------------------------------- - Module Lookup Table heaps: - Module 5ba22410:Size: 0x00000000 bytes. - Module 001c1320:Size: 0x00000000 bytes. - Module 001c03f0:Size: 0x00000000 bytes. - Module 001caa38:03ec0000(00010000:00002000) Size: 0x00002000 bytes. - Total size: 0x2000(8192)bytes - -------------------------------------- - Total LoaderHeap size: 0x15000(86016)bytes - ======================================= - -By using !EEHeap to keep track of the growth of these private heaps, we are -able to rule out or include them as a source of a memory leak. -\\ - -COMMAND: name2ee. -!Name2EE -!Name2EE ! - -This function allows you to turn a class name into a MethodTable and EEClass. -It turns a method name into a MethodDesc. Here is an example for a method: - - 0:000> !name2ee unittest.exe MainClass.Main - Module: 001caa38 - Token: 0x0600000d - MethodDesc: 00902f40 - Name: MainClass.Main() - JITTED Code Address: 03ef00b8 - -and for a class: - - 0:000> !name2ee unittest!MainClass - Module: 001caa38 - Token: 0x02000005 - MethodTable: 009032d8 - EEClass: 03ee1424 - Name: MainClass - -The module you are "browsing" with Name2EE needs to be loaded in the process. -To get a type name exactly right, first browse the module with ILDASM. You -can also pass * as the to search all loaded managed modules. - can also be the debugger's name for a module, such as -mscorlib or image00400000. - -The Windows Debugger syntax of ! is also supported. You can -use an asterisk on the left of the !, but the type on the right side needs -to be fully qualified. - -If you are looking for a way to display a static field of a class (and you -don't have an instance of the class, so !dumpobj won't help you), note that -once you have the EEClass, you can run !DumpClass, which will display the -value of all static fields. - -There is yet one more way to specify a module name. In the case of modules -loaded from an assembly store (such as a SQL db) rather than disk, the -module name will look like this: - -price, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null - -For this kind of module, simply use price as the module name: - - 0:044> !name2ee price Price - Module: 10f028b0 (price, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null) - Token: 0x02000002 - MethodTable: 11a47ae0 - EEClass: 11a538c8 - Name: Price - -Where are we getting these module names from? Run !DumpDomain to see a list of -all loaded modules in all domains. And remember that you can browse all the -types in a module with !DumpModule -mt . -\\ - -COMMAND: syncblk. -!SyncBlk [-all | ] - -A SyncBlock is a holder for extra information that doesn't need to be created -for every object. It can hold COM Interop data, HashCodes, and locking -information for thread-safe operations. - -When called without arguments, !SyncBlk will print the list of SyncBlocks -corresponding to objects that are owned by a thread. For example, a - - lock(MyObject) - { - .... - } - -statement will set MyObject to be owned by the current thread. A SyncBlock will -be created for MyObject, and the thread ownership information stored there -(this is an oversimplification, see NOTE below). If another thread tries to -execute the same code, they won't be able to enter the block until the first -thread exits. - -This makes !SyncBlk useful for detecting managed deadlocks. Consider that the -following code is executed by Threads A & B: - - Resource r1 = new Resource(); - Resource r2 = new Resource(); - - ... - - lock(r1) lock(r2) - { { - lock(r2) lock(r1) - { { - ... ... - } } - } } - -This is a deadlock situation, as Thread A could take r1, and Thread B r2, -leaving both threads with no option but to wait forever in the second lock -statement. !SyncBlk will detect this with the following output: - - 0:003> !syncblk - Index SyncBlock MonitorHeld Recursion Owning Thread Info SyncBlock Owner - 238 001e40ec 3 1 001e4e60 e04 3 00a7a194 Resource - 239 001e4124 3 1 001e5980 ab8 4 00a7a1a4 Resource - -It means that Thread e04 owns object 00a7a194, and Thread ab8 owns object -00a7a1a4. Combine that information with the call stacks of the deadlock: - -(threads 3 and 4 have similar output) - 0:003> k - ChildEBP RetAddr - 0404ea04 77f5c524 SharedUserData!SystemCallStub+0x4 - 0404ea08 77e75ee0 ntdll!NtWaitForMultipleObjects+0xc - 0404eaa4 5d9de9d6 KERNEL32!WaitForMultipleObjectsEx+0x12c - 0404eb38 5d9def80 clr!Thread::DoAppropriateAptStateWait+0x156 - 0404ecc4 5d9dd8bb clr!Thread::DoAppropriateWaitWorker+0x360 - 0404ed20 5da628dd clr!Thread::DoAppropriateWait+0xbb - 0404ede4 5da4e2e2 clr!CLREvent::Wait+0x29d - 0404ee70 5da4dd41 clr!AwareLock::EnterEpilog+0x132 - 0404ef34 5da4efa3 clr!AwareLock::Enter+0x2c1 - 0404f09c 5d767880 clr!AwareLock::Contention+0x483 - 0404f1c4 03f00229 clr!JITutil_MonContention+0x2c0 - 0404f1f4 5b6ef077 image00400000!Worker.Work()+0x79 - ... - -By looking at the code corresponding to Worker.Work()+0x79 (run "!u 03f00229"), -you can see that thread 3 is attempting to acquire the Resource 00a7a1a4, which -is owned by thread 4. - -NOTE: -It is not always the case that a SyncBlock will be created for every object -that is locked by a thread. In version 2.0 of the CLR and above, a mechanism -called a ThinLock will be used if there is not already a SyncBlock for the -object in question. ThinLocks will not be reported by the !SyncBlk command. -You can use "!DumpHeap -thinlock" to list objects locked in this way. -\\ - -COMMAND: dumpmt. -!DumpMT [-MD] - -Examine a MethodTable. Each managed object has a MethodTable pointer at the -start. If you pass the "-MD" flag, you'll also see a list of all the methods -defined on the object. -\\ - -COMMAND: dumpclass. -!DumpClass - -The EEClass is a data structure associated with an object type. !DumpClass -will show attributes, as well as list the fields of the type. The output is -similar to !DumpObj. Although static field values will be displayed, -non-static values won't because you need an instance of an object for that. - -You can get an EEClass to look at from !DumpMT, !DumpObj, !Name2EE, and -!Token2EE among others. -\\ - -COMMAND: dumpmd. -!DumpMD - -This command lists information about a MethodDesc. You can use !IP2MD to turn -a code address in a managed function into a MethodDesc: - - 0:000> !dumpmd 902f40 - Method Name: Mainy.Main() - Class: 03ee1424 - MethodTable: 009032d8 - mdToken: 0600000d - Module: 001caa78 - IsJitted: yes - CodeAddr: 03ef00b8 - -If IsJitted is "yes," you can run !U on the CodeAddr pointer to see a -disassembly of the JITTED code. You can also call !DumpClass, !DumpMT, -!DumpModule on the Class, MethodTable and Module fields above. -\\ - -COMMAND: token2ee. -!Token2EE - -This function allows you to turn a metadata token into a MethodTable or -MethodDesc. Here is an example showing class tokens being resolved: - - 0:000> !token2ee unittest.exe 02000003 - Module: 001caa38 - Token: 0x02000003 - MethodTable: 0090375c - EEClass: 03ee1ae0 - Name: Bank - 0:000> !token2ee image00400000 02000004 - Module: 001caa38 - Token: 0x02000004 - MethodTable: 009038ec - EEClass: 03ee1b84 - Name: Customer - -The module you are "browsing" with Token2EE needs to be loaded in the process. -This function doesn't see much use, especially since a tool like ILDASM can -show the mapping between metadata tokens and types/methods in a friendlier way. -But it could be handy sometimes. - -You can pass "*" for to find what that token maps to in every -loaded managed module. can also be the debugger's name for a -module, such as mscorlib or image00400000. -\\ - -COMMAND: eeversion. -!EEVersion - -This prints the Common Language Runtime version. It also tells you if the code -is running in "Workstation" or "Server" mode, a distinction which affects the -garbage collector. The most apparent difference in the debugger is that in -"Server" mode there is one dedicated garbage collector thread per CPU. - -A handy supplement to this function is to also run "lm v m clr". That -will provide more details about the CLR, including where clr.dll is -loaded from. -\\ - -COMMAND: dumpmodule. -!DumpModule [-mt] - -You can get a Module address from !DumpDomain, !DumpAssembly and other -functions. Here is sample output: - - 0:000> !DumpModule 1caa50 - Name: C:\pub\unittest.exe - Attributes: PEFile - Assembly: 001ca248 - LoaderHeap: 001cab3c - TypeDefToMethodTableMap: 03ec0010 - TypeRefToMethodTableMap: 03ec0024 - MethodDefToDescMap: 03ec0064 - FieldDefToDescMap: 03ec00a4 - MemberRefToDescMap: 03ec00e8 - FileReferencesMap: 03ec0128 - AssemblyReferencesMap: 03ec012c - MetaData start address: 00402230 (1888 bytes) - -The Maps listed map metadata tokens to CLR data structures. Without going into -too much detail, you can examine memory at those addresses to find the -appropriate structures. For example, the TypeDefToMethodTableMap above can be -examined: - - 0:000> dd 3ec0010 - 03ec0010 00000000 00000000 0090320c 0090375c - 03ec0020 009038ec ... - -This means TypeDef token 2 maps to a MethodTable with the value 0090320c. You -can run !DumpMT to verify that. The MethodDefToDescMap takes a MethodDef token -and maps it to a MethodDesc, which can be passed to !DumpMD. - -There is a new option "-mt", which will display the types defined in a module, -and the types referenced by the module. For example: - - 0:000> !dumpmodule -mt 1aa580 - Name: C:\pub\unittest.exe - ...... - MetaData start address: 0040220c (1696 bytes) - - Types defined in this module - - MT TypeDef Name - -------------------------------------------------------------------------- - 030d115c 0x02000002 Funny - 030d1228 0x02000003 Mainy - - Types referenced in this module - - MT TypeRef Name - -------------------------------------------------------------------------- - 030b6420 0x01000001 System.ValueType - 030b5cb0 0x01000002 System.Object - 030fceb4 0x01000003 System.Exception - 0334e374 0x0100000c System.Console - 03167a50 0x0100000e System.Runtime.InteropServices.GCHandle - 0336a048 0x0100000f System.GC - -\\ - -COMMAND: threadpool. -!ThreadPool - -This command lists basic information about the ThreadPool, including the number -of work requests in the queue, number of completion port threads, and number of -timers. -\\ - -COMMAND: dumpassembly. -!DumpAssembly - -Example output: - - 0:000> !dumpassembly 1ca248 - Parent Domain: 0014f000 - Name: C:\pub\unittest.exe - ClassLoader: 001ca060 - Module Name - 001caa50 C:\pub\unittest.exe - -An assembly can consist of multiple modules, and those will be listed. You can -get an Assembly address from the output of !DumpDomain. -\\ - -COMMAND: dumpruntimetypes. -!DumpRuntimeTypes - -!DumpRuntimeTypes finds all System.RuntimeType objects in the gc heap and -prints the type name and MethodTable they refer too. Sample output: - - Address Domain MT Type Name - ------------------------------------------------------------------------------ - a515f4 14a740 5baf8d28 System.TypedReference - a51608 14a740 5bb05764 System.Globalization.BaseInfoTable - a51958 14a740 5bb05b24 System.Globalization.CultureInfo - a51a44 14a740 5bb06298 System.Globalization.GlobalizationAssembly - a51de0 14a740 5bb069c8 System.Globalization.TextInfo - a56b98 14a740 5bb12d28 System.Security.Permissions.HostProtectionResource - a56bbc 14a740 5baf7248 System.Int32 - a56bd0 14a740 5baf3fdc System.String - a56cfc 14a740 5baf36a4 System.ValueType - ... - -This command will print a "?" in the domain column if the type is loaded into multiple -AppDomains. For example: - - 0:000> !DumpRuntimeTypes - Address Domain MT Type Name - ------------------------------------------------------------------------------ - 28435a0 ? 3f6a8c System.TypedReference - 28435b4 ? 214d6c System.ValueType - 28435c8 ? 216314 System.Enum - 28435dc ? 2147cc System.Object - 284365c ? 3cd57c System.IntPtr - 2843670 ? 3feaac System.Byte - 2843684 ? 23a544c System.IEquatable`1[[System.IntPtr, mscorlib]] - 2843784 ? 3c999c System.Int32 - 2843798 ? 3caa04 System.IEquatable`1[[System.Int32, mscorlib]] - -\\ - -COMMAND: dumpsig. -!DumpSig - -This command dumps the signature of a method or field given by . This is -useful when you are debugging parts of the runtime which returns a raw PCCOR_SIGNATURE -structure and need to know what its contents are. - -Sample output for a method: - 0:000> !dumpsig 0x000007fe`ec20879d 0x000007fe`eabd1000 - [DEFAULT] [hasThis] Void (Boolean,String,String) - -The first section of the output is the calling convention. This includes, but is not -limited to, "[DEFAULT]", "[C]", "[STDCALL]", "[THISCALL]", and so on. The second -portion of the output is either "[hasThis]" or "[explicit]" for whether the method -is an instance method or a static method respectively. The third portion of the -output is the return value (in this case a "void"). Finally, the method's arguments -are printed as the final portion of the output. - -Sample output for a field: - 0:000> !dumpsig 0x000007fe`eb7fd8cd 0x000007fe`eabd1000 - [FIELD] ValueClass System.RuntimeTypeHandle - -!DumpSig will also work with generics. Here is the output for the following -function: - public A Test(IEnumerable n) - - 0:000> !dumpsig 00000000`00bc2437 000007ff00043178 - [DEFAULT] [hasThis] __Canon (Class System.Collections.Generic.IEnumerable`1<__Canon>) - -\\ - -COMMAND: dumpsigelem. -!DumpSigElem - -This command dumps a single element of a signature object. For most circumstances, -you should use !DumpSig to look at individual signature objects, but if you find a -signature that has been corrupted in some manner you can use !DumpSigElem to read out -the valid portions of it. - -If we look at a valid signature object for a method we see the following: - 0:000> !dumpsig 0x000007fe`ec20879d 0x000007fe`eabd1000 - [DEFAULT] [hasThis] Void (Boolean,String,String) - -We can look at the individual elements of this object by adding the offsets into the -object which correspond to the return value and parameters: - 0:000> !dumpsigelem 0x000007fe`ec20879d+2 0x000007fe`eabd1000 - Void - 0:000> !dumpsigelem 0x000007fe`ec20879d+3 0x000007fe`eabd1000 - Boolean - 0:000> !dumpsigelem 0x000007fe`ec20879d+4 0x000007fe`eabd1000 - String - 0:000> !dumpsigelem 0x000007fe`ec20879d+5 0x000007fe`eabd1000 - String - -We can do something similar for fields. Here is the full signature of a field: - 0:000> !dumpsig 0x000007fe`eb7fd8cd 0x000007fe`eabd1000 - [FIELD] ValueClass System.RuntimeTypeHandle - -Using !DumpSigElem we can find the type of the field by adding the offset of it (1) to -the address of the signature: - 0:000> !dumpsigelem 0x000007fe`eb7fd8cd+1 0x000007fe`eabd1000 - ValueClass System.RuntimeTypeHandle - -!DumpSigElem will also work with generics. Let a function be defined as follows: - public A Test(IEnumerable n) - -The elements of this signature can be obtained by adding offsets into the signature -when calling !DumpSigElem: - - 0:000> !dumpsigelem 00000000`00bc2437+2 000007ff00043178 - __Canon - 0:000> !dumpsigelem 00000000`00bc2437+4 000007ff00043178 - Class System.Collections.Generic.IEnumerable`1<__Canon> - -The actual offsets that you should add are determined by the contents of the -signature itself. By trial and error you should be able to find various elements -of the signature. - -\\ - -COMMAND: rcwcleanuplist. -!RCWCleanupList [address] - -A RuntimeCallableWrapper is an internal CLR structure used to host COM objects -which are exposed to managed code. This is exposed to managed code through the -System.__ComObject class, and when objects of this type are collected, and a -reference to the underlying COM object is no longer needed, the corresponding -RCW is cleaned up. If you are trying to debug an issue related to one of these -RCWs, then you can use the !RCWCleanupList function to display which COM objects -will be released the next time a cleanup occurs. - -If given an address, this function will display the RCWCleanupList at that address. -If no address is specified, it displays the default cleanup list, printing the -wrapper, the context, and the thread of the object. - -Example: - 0:002> !rcwcleanuplist 001c04d0 - RuntimeCallableWrappers (RCW) to be cleaned: - RCW CONTEXT THREAD Apartment - 1d54e0 192008 181180 STA - 1d4140 192178 0 MTA - 1dff50 192178 0 MTA - MTA Interfaces to be released: 2 - STA Interfaces to be released: 1 - -Note that CLR keeps track of which RCWs are bound to which managed objects through -the SyncBlock of the object. As such, you can see more information about RCW -objects through the !SyncBlk command. You can find more information about RCW -cleanup through the !FinalizeQueue command. - -\\ - -COMMAND: dumpil. -!DumpIL | - | - | - /i - -!DumpIL prints the IL code associated with a managed method. We added this -function specifically to debug DynamicMethod code which was constructed on -the fly. Happily it works for non-dynamic code as well. - -You can use it in four ways: - - 1) If you have a System.Reflection.Emit.DynamicMethod object, just pass - the pointer as the first argument. - 2) If you have a DynamicMethodDesc pointer you can use that to print the - IL associated with the dynamic method. - 3) If you have an ordinary MethodDesc, you can see the IL for that as well, - just pass it as the first argument. - 4) If you have a pointer directly to the IL, specify /i followed by the - the IL address. This is useful for writers of profilers that instrument - IL. - - -Note that dynamic IL is constructed a bit differently. Rather than referring -to metadata tokens, the IL points to objects in a managed object array. Here -is a simple example of the output for a dynamic method: - - 0:000> !dumpil b741dc - This is dynamic IL. Exception info is not reported at this time. - If a token is unresolved, run "!do " on the addr given - in parenthesis. You can also look at the token table yourself, by - running "!DumpArray 00b77388". - - IL_0000: ldstr 70000002 "Inside invoked method " - IL_0005: call 6000003 System.Console.WriteLine(System.String) - IL_000a: ldc.i4.1 - IL_000b: newarr 2000004 "System.Int32" - IL_0010: stloc.0 - IL_0011: ldloc.0 - IL_0012: ret - -\\ - -COMMAND: verifyheap. -!VerifyHeap - -!VerifyHeap is a diagnostic tool that checks the garbage collected heap for -signs of corruption. It walks objects one by one in a pattern like this: - - o = firstobject; - while(o != endobject) - { - o.ValidateAllFields(); - o = (Object *) o + o.Size(); - } - -If an error is found, !VerifyHeap will report it. I'll take a perfectly good -object and corrupt it: - - 0:000> !DumpObj a79d40 - Name: Customer - MethodTable: 009038ec - EEClass: 03ee1b84 - Size: 20(0x14) bytes - (C:\pub\unittest.exe) - Fields: - MT Field Offset Type Attr Value Name - 009038ec 4000008 4 CLASS instance 00a79ce4 name - 009038ec 4000009 8 CLASS instance 00a79d2c bank - 009038ec 400000a c System.Boolean instance 1 valid - - 0:000> ed a79d40+4 01 (change the name field to the bogus pointer value 1) - 0:000> !VerifyHeap - object 01ee60dc: bad member 00000003 at 01EE6168 - Last good object: 01EE60C4. - -If this gc heap corruption exists, there is a serious bug in your own code or -in the CLR. In user code, an error in constructing PInvoke calls can cause -this problem, and running with Managed Debugging Assistants is advised. If that -possibility is eliminated, consider contacting Microsoft Product Support for -help. - -\\ - -COMMAND: verifyobj. -!VerifyObj - -!VerifyObj is a diagnostic tool that checks the object that is passed as an -argument for signs of corruption. - - 0:002> !verifyobj 028000ec - object 0x28000ec does not have valid method table - - 0:002> !verifyobj 0680017c - object 0x680017c: bad member 00000001 at 06800184 - -\\ - -COMMAND: findroots. -!FindRoots -gen | -gen any | - -The "-gen" form causes the debugger to break in the debuggee on the next -collection of the specified generation. The effect is reset as soon as the -break occurs, in other words, if you need to break on the next collection you -would need to reissue the command. - -The last form of this command is meant to be used after the break caused by the -other forms has occurred. Now the debuggee is in the right state for -!FindRoots to be able to identify roots for objects from the current condemned -generations. - -!FindRoots is a diagnostic command that is meant to answer the following -question: - -"I see that GCs are happening, however my objects have still not been -collected. Why? Who is holding onto them?" - -The process of answering the question would go something like this: - -1. Find out the generation of the object of interest using the !GCWhere -command, say it is gen 1: - !GCWhere - -2. Instruct the runtime to stop the next time it collects that generation using -the !FindRoots command: - !FindRoots -gen 1 - g - -3. When the next GC starts, and has proceeded past the mark phase a CLR -notification will cause a break in the debugger: - (fd0.ec4): CLR notification exception - code e0444143 (first chance) - CLR notification: GC - end of mark phase. - Condemned generation: 1. - -4. Now we can use the !FindRoots to find out the cross -generational references to the object of interest. In other words, even if the -object is not referenced by any "proper" root it may still be referenced by an -older object (from an older generation), from a generation that has not yet been -scheduled for collection. At this point !FindRoots will search those older -generations too, and report those roots. - 0:002> !findroots 06808094 - older generations::Root: 068012f8(AAA.Test+a)-> - 06808094(AAA.Test+b) - - -\\ - -COMMAND: heapstat. -!HeapStat [-inclUnrooted | -iu] - -This command shows the generation sizes for each heap and the total, how much free -space there is in each generation on each heap. If the -inclUnrooted option is -specified the report will include information about the managed objects from the -GC heap that are not rooted anymore. - -Sample output: - - 0:002> !heapstat - Heap Gen0 Gen1 Gen2 LOH - Heap0 177904 12 306956 8784 - Heap1 159652 12 12 16 - Total 337556 24 306968 8800 - - Free space: Percentage - Heap0 28 12 12 64 SOH: 0% LOH: 0% - Heap1 104 12 12 16 SOH: 0% LOH:100% - Total 132 24 24 80 - - 0:002> !heapstat -inclUnrooted - Heap Gen0 Gen1 Gen2 LOH - Heap0 177904 12 306956 8784 - Heap1 159652 12 12 16 - Total 337556 24 306968 8800 - - Free space: Percentage - Heap0 28 12 12 64 SOH: 0% LOH: 0% - Heap1 104 12 12 16 SOH: 0% LOH:100% - Total 132 24 24 80 - - Unrooted objects: Percentage - Heap0 152212 0 306196 0 SOH: 94% LOH: 0% - Heap1 155704 0 0 0 SOH: 97% LOH: 0% - Total 307916 0 306196 0 - -The percentage column contains a breakout of free or unrooted bytes to total bytes. - -\\ - -COMMAND: analyzeoom. -!AnalyzeOOM - -!AnalyzeOOM displays the info of the last OOM occurred on an allocation request to -the GC heap (in Server GC it displays OOM, if any, on each GC heap). - -To see the managed exception(s) use the !Threads command which will show you -managed exception(s), if any, on each managed thread. If you do see an -OutOfMemoryException exception you can use the !PrintException command on it. -To get the full callstack use the "kb" command in the debugger for that thread. -For example, to display thread 3's stack use ~3kb. - -OOM exceptions could be because of the following reasons: - -1) allocation request to GC heap - in which case you will see JIT_New* on the call stack because managed code called new. -2) other runtime allocation failure - for example, failure to expand the finalize queue when GC.ReRegisterForFinalize is - called. -3) some other code you use throws a managed OOM exception - for example, some .NET framework code converts a native OOM exception to managed - and throws it. - -The !AnalyzeOOM command aims to help you with investigating 1) which is the most -difficult because it requires some internal info from GC. The only exception is -we don't support allocating objects larger than 2GB on CLR v2.0 or prior. And this -command will not display any managed OOM because we will throw OOM right away -instead of even trying to allocate it on the GC heap. - -There are 2 legitimate scenarios where GC would return OOM to allocation requests - -one is if the process is running out of VM space to reserve a segment; the other -is if the system is running out physical memory (+ page file if you have one) so -GC can not commit memory it needs. You can look at these scenarios by using performance -counters or debugger commands. For example for the former scenario the "!address --summary" debugger command will show you the largest free region in the VM. For -the latter scenario you can look at the "Memory\% Committed Bytes In Use" see -if you are running low on commit space. One important thing to keep in mind is -when you do this kind of memory analysis it could an aftereffect and doesn't -completely agree with what this command tells you, in which case the command should -be respected because it truly reflects what happened during GC. - -The other cases should be fairly obvious from the callstack. - -Sample output: - -0:011> !ao ----------Heap 2 --------- -Managed OOM occurred after GC #28 (Requested to allocate 1234 bytes) -Reason: Didn't have enough memory to commit -Detail: SOH: Didn't have enough memory to grow the internal GC datastructures (800000 bytes) - - on GC entry available commit space was 500 MB ----------Heap 4 --------- -Managed OOM occurred after GC #12 (Requested to allocate 100000 bytes) -Reason: Didn't have enough memory to allocate an LOH segment -Detail: LOH: Failed to reserve memory (16777216 bytes) - -\\ - -COMMAND: gcwhere. -!GCWhere - -!GCWhere displays the location in the GC heap of the argument passed in. - - 0:002> !GCWhere 02800038 - Address Gen Heap segment begin allocated size - 02800038 2 0 02800000 02800038 0282b740 12 - -When the argument lies in the managed heap, but is not a valid *object* address -the "size" is displayed as 0: - - 0:002> !GCWhere 0280003c - Address Gen Heap segment begin allocated size - 0280003c 2 0 02800000 02800038 0282b740 0 - -\\ - -COMMAND: listnearobj. -!ListNearObj - -!ListNearObj is a diagnostic tool that displays the object preceeding and -succeeding the address passed in: - -The command looks for the address in the GC heap that looks like a valid -beginning of a managed object (based on a valid method table) and the object -following the argument address. - - 0:002> !ListNearObj 028000ec - Before: 0x28000a4 72 (0x48 ) System.StackOverflowException - After: 0x2800134 72 (0x48 ) System.Threading.ThreadAbortException - Heap local consistency confirmed. - - 0:002> !ListNearObj 028000f0 - Before: 0x28000ec 72 (0x48 ) System.ExecutionEngineException - After: 0x2800134 72 (0x48 ) System.Threading.ThreadAbortException - Heap local consistency confirmed. - -The command considers the heap as "locally consistent" if: - prev_obj_addr + prev_obj_size = arg_addr && arg_obj + arg_size = next_obj_addr -OR - prev_obj_addr + prev_obj_size = next_obj_addr - -When the condition is not satisfied: - - 0:002> !lno 028000ec - Before: 0x28000a4 72 (0x48 ) System.StackOverflowException - After: 0x2800134 72 (0x48 ) System.Threading.ThreadAbortException - Heap local consistency not confirmed. - -\\ - -COMMAND: dumplog. -!DumpLog [-addr ] [] - -To aid in diagnosing hard-to-reproduce stress failures, the CLR team added an -in-memory log capability. The idea was to avoid using locks or I/O which could -disturb a fragile repro environment. The !DumpLog function allows you to write -that log out to a file. If no Filename is specified, the file "Stresslog.txt" -in the current directory is created. - -The optional argument addr allows one to specify a stress log other then the -default one. - - 0:000> !DumpLog - Attempting to dump Stress log to file 'StressLog.txt' - ................. - SUCCESS: Stress log dumped - -To turn on the stress log, set the following registry keys under -HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework: - - -(DWORD) StressLog = 1 -(DWORD) LogFacility = 0xffffffbf (this is a bit mask, almost all logging is on. - This is also the default value if the key - isn't specified) -(DWORD) StressLogSize = 65536 (this is the default value if the key isn't - specified) -(DWORD) LogLevel = 6 (this is the default value if the key isn't - specified. The higher the number the more - detailed logs are generated. The maximum - value is decimal 10) - -StressLogSize is the size in bytes of the in-memory log allocated for each -thread in the process. In the case above, each thread gets a 64K log. You -could increase this to get more logging, but more memory will be required for -this log in the process. For example, 20 threads with 524288 bytes per thread -has a memory demand of 10 Megabytes. The stress log is circular so new entries -will replace older ones on threads which have reached their buffer limit. - -The log facilities are defined as follows: - GC 0x00000001 - GCINFO 0x00000002 - STUBS 0x00000004 - JIT 0x00000008 - LOADER 0x00000010 - METADATA 0x00000020 - SYNC 0x00000040 - EEMEM 0x00000080 - GCALLOC 0x00000100 - CORDB 0x00000200 - CLASSLOADER 0x00000400 - CORPROF 0x00000800 - REMOTING 0x00001000 - DBGALLOC 0x00002000 - EH 0x00004000 - ENC 0x00008000 - ASSERT 0x00010000 - VERIFIER 0x00020000 - THREADPOOL 0x00040000 - GCROOTS 0x00080000 - INTEROP 0x00100000 - MARSHALER 0x00200000 - IJW 0x00400000 - ZAP 0x00800000 - STARTUP 0x01000000 - APPDOMAIN 0x02000000 - CODESHARING 0x04000000 - STORE 0x08000000 - SECURITY 0x10000000 - LOCKS 0x20000000 - BCL 0x40000000 - -Here is some sample output: - - 3560 9.981137099 : `SYNC` RareEnablePremptiveGC: entering. - Thread state = a030 - - 3560 9.981135033 : `GC`GCALLOC`GCROOTS` ========== ENDGC 4194 (gen = 2, - collect_classes = 0) ==========={ - - 3560 9.981125826 : `GC` Segment mem 00C61000 alloc - = 00D071F0 used 00D09254 committed 00D17000 - - 3560 9.981125726 : `GC` Generation 0 [00CED07C, 00000000 - ] cur = 00000000 - - 3560 9.981125529 : `GC` Generation 1 [00CED070, 00000000 - ] cur = 00000000 - - 3560 9.981125103 : `GC` Generation 2 [00C61000, 00000000 - ] cur = 00000000 - - 3560 9.981124963 : `GC` GC Heap 00000000 - - 3560 9.980618994 : `GC`GCROOTS` GcScanHandles (Promotion Phase = 0) - -The first column is the OS thread ID for the thread appending to the log, -the second column is the timestamp, the third is the facility category for the -log entry, and the fourth contains the log message. The facility field is -expressed as `facility1`facility2`facility3`. This facilitates the creation of -filters for displaying only specific message categories. To make sense of this -log, you would probably want the Shared Source CLI to find out exactly where -the log comes from. -\\ - -COMMAND: findappdomain. -!FindAppDomain - -!FindAppDomain will attempt to resolve the AppDomain of an object. For example, -using an Object Pointer from the output of !DumpStackObjects: - - 0:000> !findappdomain 00a79d98 - AppDomain: 0014f000 - Name: unittest.exe - ID: 1 - -You can find out more about the AppDomain with the !DumpDomain command. Not -every object has enough clues about it's origin to determine the AppDomain. -Objects with Finalizers are the easiest case, as the CLR needs to be able to -call those when an AppDomain shuts down. -\\ - -COMMAND: savemodule. -!SaveModule - -This command allows you to take a image loaded in memory and write it to a -file. This is especially useful if you are debugging a full memory dump, and -don't have the original DLLs or EXEs. This is most often used to save a managed -binary to a file, so you can disassemble the code and browse types with ILDASM. - -The base address of an image can be found with the "LM" debugger command: - - 0:000> lm - start end module name - 00400000 00408000 image00400000 (deferred) - 10200000 102ac000 MSVCR80D (deferred) - 5a000000 5a0b1000 mscoree (deferred) - 5a140000 5a29e000 clrjit (deferred) - 5b660000 5c440000 mscorlib_dll (deferred) - 5d1d0000 5e13c000 clr (deferred) - ... - -If I wanted to save a copy of clr.dll, I could run: - - 0:000> !SaveModule 5d1d0000 c:\pub\out.tmp - 4 sections in file - section 0 - VA=1000, VASize=e82da9, FileAddr=400, FileSize=e82e00 - section 1 - VA=e84000, VASize=24d24, FileAddr=e83200, FileSize=ec00 - section 2 - VA=ea9000, VASize=5a8, FileAddr=e91e00, FileSize=600 - section 3 - VA=eaa000, VASize=c183c, FileAddr=e92400, FileSize=c1a00 - -The diagnostic output indicates that the operation was successful. If -c:\pub\out.tmp already exists, it will be overwritten. -\\ - -COMMAND: gchandles. -!GCHandles [-type handletype] [-stat] [-perdomain] - -!GCHandles provides statistics about GCHandles in the process. - -Paremeters: - stat - Only display the statistics and not the list of handles and - what they point to. - perdomain - Break down the statistics by the app domain in which - the handles reside. - type - A type of handle to filter it by. The handle types are: - Pinned - RefCounted - WeakShort - WeakLong - Strong - Variable - AsyncPinned - SizedRef - -Sometimes the source of a memory leak is a GCHandle leak. For example, code -might keep a 50 Megabyte array alive because a strong GCHandle points to it, -and the handle was discarded without freeing it. - -The most common handles are "Strong Handles," which keep the object they point -to alive until the handle is explicitly freed. "Pinned Handles" are used to -prevent the garbage collector from moving an object during collection. These -should be used sparingly, and for short periods of time. If you don't follow -that precept, the gc heap can become very fragmented. - -Here is sample output from a very simple program. Note that the "RefCount" -field only applies to RefCount Handles, and this field will contain the -reference count: - - 0:000> !GCHandles - Handle Type Object Size RefCount Type - 001611c0 Strong 01d00b58 84 System.IndexOutOfRangeException - 001611c4 Strong 01d00b58 84 System.IndexOutOfRangeException - 001611c8 Strong 01d1b48c 40 System.Diagnostics.LogSwitch - 001611d0 Strong 01cfd2c0 36 System.Security.PermissionSet - 001611d4 Strong 01cf7484 56 System.Object[] - 001611d8 Strong 01cf1238 32 System.SharedStatics - 001611dc Strong 01cf11c8 84 System.Threading.ThreadAbortException - 001611e0 Strong 01cf1174 84 System.Threading.ThreadAbortException - 001611e4 Strong 01cf1120 84 System.ExecutionEngineException - 001611e8 Strong 01cf10cc 84 System.StackOverflowException - 001611ec Strong 01cf1078 84 System.OutOfMemoryException - 001611f0 Strong 01cf1024 84 System.Exception - 001611f8 Strong 01cf2068 48 System.Threading.Thread - 001611fc Strong 01cf1328 112 System.AppDomain - 001613ec Pinned 02cf3268 8176 System.Object[] - 001613f0 Pinned 02cf2258 4096 System.Object[] - 001613f4 Pinned 02cf2038 528 System.Object[] - 001613f8 Pinned 01cf121c 12 System.Object - 001613fc Pinned 02cf1010 4116 System.Object[] - - Statistics: - MT Count TotalSize Class Name - 563266dc 1 12 System.Object - 56329708 1 32 System.SharedStatics - 5632bc38 1 36 System.Security.PermissionSet - 5635f934 1 40 System.Diagnostics.LogSwitch - 5632759c 1 48 System.Threading.Thread - 5632735c 1 84 System.ExecutionEngineException - 56327304 1 84 System.StackOverflowException - 563272ac 1 84 System.OutOfMemoryException - 563270c4 1 84 System.Exception - 56328914 1 112 System.AppDomain - 56335f78 2 168 System.IndexOutOfRangeException - 563273b4 2 168 System.Threading.ThreadAbortException - 563208d0 5 16972 System.Object[] - Total 19 objects - - Handles: - Strong Handles: 14 - Pinned Handles: 5 -\\ - -COMMAND: gchandleleaks. -!GCHandleLeaks - -This command is an aid in tracking down GCHandle leaks. It searches all of -memory for any references to the Strong and Pinned GCHandles in the process, -and reports what it found. If a handle is found, you'll see the address of the -reference. This might be a stack address or a field within an object, for -example. If a handle is not found in memory, you'll get notification of that -too. - -The command has diagnostic output which doesn't need to be repeated here. One -thing to keep in mind is that anytime you search all of memory for a value, you -can get false positives because even though the value was found, it might be -garbage in that no code knows about the address. You can also get false -negatives because a user is free to pass that GCHandle to unmanaged code that -might store the handle in a strange way (shifting bits, for example). - -For example, a GCHandle valuetype is stored on the stack with the low bit set -if it points to a Pinned handle. So !GCHandleLeaks ignores the low bit in it's -searches. - -That said, if a serious leak is going on, you'll get a ever-growing set of -handle addresses that couldn't be found. -\\ - -COMMAND: vmmap. -!VMMap - -!VMMap traverses the virtual address space and lists the type of protection -applied to each region. Sample output: - - 0:000> !VMMap - Start Stop Length AllocProtect Protect State Type - 00000000-0000ffff 00010000 NA Free - 00010000-00011fff 00002000 RdWr RdWr Commit Private - 00012000-0001ffff 0000e000 NA Free - 00020000-00020fff 00001000 RdWr RdWr Commit Private - 00021000-0002ffff 0000f000 NA Free - 00030000-00030fff 00001000 RdWr Reserve Private - ... -\\ - -COMMAND: vmstat. -!VMStat - -Provides a summary view of the virtual address space, ordered by each type of -protection applied to that memory (free, reserved, committed, private, mapped, -image). The TOTAL column is (AVERAGE * BLK COUNT). Sample output below: - - 0:000> !VMStat - ~~~~ ~~~~~~~ ~~~~~~~ ~~~~~~~ ~~~~~~~~~ ~~~~~ - TYPE MINIMUM MAXIMUM AVERAGE BLK COUNT TOTAL - Free: - Small 4,096 65,536 48,393 27 1,306,611 - Medium 139,264 528,384 337,920 4 1,351,680 - Large 6,303,744 974,778,368 169,089,706 12 2,029,076,472 - Summary 4,096 974,778,368 47,249,646 43 2,031,734,778 - - Reserve: - Small 4,096 65,536 43,957 41 1,802,237 - Medium 249,856 1,019,904 521,557 6 3,129,342 - Large 2,461,696 16,703,488 11,956,224 3 35,868,672 - Summary 4,096 16,703,488 816,005 50 40,800,250 - -\\ - -COMMAND: procinfo. -!ProcInfo [-env] [-time] [-mem] - -!ProcInfo lists the environment variables for the process, kernel CPU time, as -well as memory usage statistics. -\\ - -COMMAND: histinit. -!HistInit - -Before running any of the Hist - family commands you need to initialize the SOS -structures from the stress log saved in the debuggee. This is achieved by the -HistInit command. - -Sample output: - - 0:001> !HistInit - Attempting to read Stress log - STRESS LOG: - facilitiesToLog = 0xffffffff - levelToLog = 6 - MaxLogSizePerThread = 0x10000 (65536) - MaxTotalLogSize = 0x1000000 (16777216) - CurrentTotalLogChunk = 9 - ThreadsWithLogs = 3 - Clock frequency = 3.392 GHz - Start time 15:26:31 - Last message time 15:26:56 - Total elapsed time 25.077 sec - ..................................... - ---------------------------- 2407 total entries ----------------------------- - - - SUCCESS: GCHist structures initialized - -\\ - -COMMAND: histobjfind. -!HistObjFind - -To examine log entries related to an object whose present address is known one -would use this command. The output of this command contains all entries that -reference the object: - - 0:003> !HistObjFind 028970d4 - GCCount Object Message - --------------------------------------------------------- - 2296 028970d4 Promotion for root 01e411b8 (MT = 5b6c5cd8) - 2296 028970d4 Relocation NEWVALUE for root 00223fc4 - 2296 028970d4 Relocation NEWVALUE for root 01e411b8 - ... - 2295 028970d4 Promotion for root 01e411b8 (MT = 5b6c5cd8) - 2295 028970d4 Relocation NEWVALUE for root 00223fc4 - 2295 028970d4 Relocation NEWVALUE for root 01e411b8 - ... - -\\ - -COMMAND: histroot. -!HistRoot - -The root value obtained from !HistObjFind can be used to track the movement of -an object through the GCs. - -HistRoot provides information related to both promotions and relocations of the -root specified as the argument. - - 0:003> !HistRoot 01e411b8 - GCCount Value MT Promoted? Notes - --------------------------------------------------------- - 2296 028970d4 5b6c5cd8 yes - 2295 028970d4 5b6c5cd8 yes - 2294 028970d4 5b6c5cd8 yes - 2293 028970d4 5b6c5cd8 yes - 2292 028970d4 5b6c5cd8 yes - 2291 028970d4 5b6c5cd8 yes - 2290 028970d4 5b6c5cd8 yes - 2289 028970d4 5b6c5cd8 yes - 2288 028970d4 5b6c5cd8 yes - 2287 028970d4 5b6c5cd8 yes - 2286 028970d4 5b6c5cd8 yes - 2285 028970d4 5b6c5cd8 yes - 322 028970e8 5b6c5cd8 yes Duplicate promote/relocs - ... - -\\ - -COMMAND: histobj. -!HistObj - -This command examines all stress log relocation records and displays the chain -of GC relocations that may have led to the address passed in as an argument. -Conceptually the output is: - - GenN obj_address root1, root2, root3, - GenN-1 prev_obj_addr root1, root2, - GenN-2 prev_prev_oa root1, root4, - ... - -Sample output: - 0:003> !HistObj 028970d4 - GCCount Object Roots - --------------------------------------------------------- - 2296 028970d4 00223fc4, 01e411b8, - 2295 028970d4 00223fc4, 01e411b8, - 2294 028970d4 00223fc4, 01e411b8, - 2293 028970d4 00223fc4, 01e411b8, - 2292 028970d4 00223fc4, 01e411b8, - 2291 028970d4 00223fc4, 01e411b8, - 2290 028970d4 00223fc4, 01e411b8, - 2289 028970d4 00223fc4, 01e411b8, - 2288 028970d4 00223fc4, 01e411b8, - 2287 028970d4 00223fc4, 01e411b8, - 2286 028970d4 00223fc4, 01e411b8, - 2285 028970d4 00223fc4, 01e411b8, - 322 028970d4 01e411b8, - 0 028970d4 - -\\ - -COMMAND: histclear. -!HistClear - -This command releases any resources used by the Hist-family of commands. -Generally there's no need to call this explicitly, as each HistInit will first -cleanup the previous resources. - - 0:003> !HistClear - Completed successfully. - -\\ - -COMMAND: dumprcw. -!DumpRCW - -This command lists information about a Runtime Callable Wrapper. You can use -!DumpObj to obtain the RCW address corresponding to a managed object. - -The output contains all COM interface pointers that the RCW holds on to, which -is useful for investigating lifetime issues of interop-heavy applications. -\\ - -COMMAND: dumpccw. -!DumpCCW - -This command lists information about a COM Callable Wrapper. You can use -!DumpObj to obtain the CCW address corresponding to a managed object or pass -a COM interface pointer to which the object has been marshaled. - -The output contains the COM reference count of the CCW, which is useful for -investigating lifetime issues of interop-heavy applications. -\\ - -COMMAND: suppressjitoptimization. -!SuppressJitOptimization [on|off] - -!SuppressJitOptimization helps when you want the CLR to generate more debuggable -jitted code. This will turn off inlining, enregistering of local variables, -optimizing across sequence point boundaries, and precise variable lifetimes. -The resulting code should step more cleanly and make local variables more -accesible to inspection. The cost is that code quality is lower so your -application may execute a little slower. - -Once you execute !SuppressJitOptimization on, all managed modules that load -from that point onwards will not be optimized. The setting is only checked once -per module, at the time that module loads. Changing the setting later will only -affect modules that are loaded later. The recommendation is to set this once at -app startup and let the same setting apply for all managed modules. -\\ - -COMMAND: stoponcatch. -!StopOnCatch - -This commands sets a one-time breakpoint on the first managed catch clause -entered by managed code. This will cause the debugger to stop on the first line -of the catch handler. This is useful step from from the point of an exception -throw to the catch handler. -\\ - - -COMMAND: savestate. -!SaveState - -!SaveState serializes SOS managed breakpoints and watch values into a script file -that can be executed on a future windbg session to restore them. Use the windbg -command <$ to execute the saved script. -\\ - -COMMAND: watch. -!Watch -!Watch -add -!Watch -remove -!Watch -save -!Watch -rename -!Watch [-filter ] [-expand [type_cast]] - -!Watch displays the value of managed expressions, and manages the list of -expressions. A quick example... - -DEBUGGEE CODE: - static int Main(string[] args) - { - int p14 = -123; - MyStruct ms = new MyStruct(); - ms.a = p14; - ms.b = true; - MyStruct.c = "Foo"; - ... - -COMMAND WINDOW: -0:000> !Watch -add ms -0:000> !Watch -add p14 -0:000> !Watch - 1) MyStruct ms @ 0x0093D1CC - 2) int p14 = -123 - -ms in the command window will be a DML link, if you click on it then you see: - -COMMAND WINDOW: -0:000> !watch -expand 1 (MyStruct)ms - 1) MyStruct ms @ 0x0093D1CC - |- int a = -123 - |- bool b = true - |- string c = null - 2) int p14 = -123 - - - -Watch is capable of parsing a variety of different expressions. Expressions -can start with the name of a local variable or parameter in any stack frame. -To access fields of classes and structures simply add a '.' and then the field -name. To access array elements use standard [] notation. In the above -code example these would be valid expressions: -args[19] -p14 -ms.a - -Additionally 'this' is available in the leafmost frame to access fields. -You can not use unqualified field names. For example if there is a class: -class C -{ - int m_foo; - public void Hello() { Console.WriteLine(m_foo); } -} - -this.m_foo is a legal expression when executing inside C.Hello(), -m_foo would not work. - -Expressions also allow fully qualified type names and dereferencing static -fields from those types using the same '.' syntax. For example: -System.Int32 -System.Type.Missing - -Generic types can be used, though don't forget to use the CLI type -name which adds ` to the type name you would see -in VB or C#. For example: -System.Collections.Generic.Dictionary`2 - -Dereferencing fields or array indices can recurse as you might expect. A -made up example: -foo.bar.baz[19][12].m_field[4] - -Property values and method invocations can not be used in expressions as -the !Watch command will never execute any managed code to evaluate the -expressions. - -To remove entries in the list use !Watch -remove where index is -the number printed next to the expression in the viewing list. In our -initial example !Watch -remove 2 would remove the 'p14' expression from -the list. - -Saving/Renaming/Filtering -Sometimes it can be helpful to see only those values which have changed -since some point in the past. As an example assume that MyStruct.c changes -values during the go: - -0:000> !Watch -save myOldValues -0:000> g -... -0:000> !Watch -filter myOldValues - 3) string MyStruct.c = "Foo" - -When saving a list of expressions, the string that would be displayed in a -!Watch command is also saved. It is this string that is compared to determine -if the value has changed. Some changes might not alter the console string -representation. In the first example changing the value of ms.a would not -cause the 'ms' expression to be different. - -Renaming can be useful in scripts. It allows the name of a saved watch list to -change after saving it. For example: -0:000> !Watch -rename myCurrentValues myOldValues -0:000> !Watch -save myCurrentValues -0:000> !Watch -filter myOldValues - 3) string MyStruct.c = "Foo" - -Placing that pattern inside a script shows the changed watch values -since the last time the script was run. -\\ - diff --git a/src/ToolBox/SOS/tests/README.md b/src/ToolBox/SOS/tests/README.md deleted file mode 100644 index 1b9c1eac2..000000000 --- a/src/ToolBox/SOS/tests/README.md +++ /dev/null @@ -1,44 +0,0 @@ -Testing libsosplugin -===================================== - -**Test assembly** -Compile test assembly file using any C# compiler you have, for example: -- `gmcs test.cs` -- `corerun csc.exe /nologo /r:System.Private.CoreLib.dll test.cs` - - -**Running tests** -Make sure that python's lldb module is accessible. To run the tests, use the following command: -`python2 test_libsosplugin.py --corerun=corerun --sosplugin=sosplugin --assembly=assembly --timeout=timeout` -- `lldb` is a path to `lldb` to run -- `clrdir` is a directory with `corerun` and sosplugin -- `assembly` is a compiled test assembly (e.g. Test.exe) -- `timeout` is a deadline for a single test (in seconds) -- `regex` is a regular expression matching tests to run -- `repeat` is a number of passes for each test - - - -Log files for both failed and passed tests are `*.log` and `*.log.2` for standard output and error correspondingly. - - -**Writing tests** -Tests start with the `TestSosCommands` class defined in `test_libsosplugin.py`. To add a test to the suite, start with implementing a new method inside this class whose name begins with `test_`. Most new commands will require only one line of code in this method: `self.do_test("scenarioname")`. This command will launch a new `lldb` instance, which in turn will call the `runScenario` method from `scenarioname` module. `scenarioname` is the name of the python module that will be running the scenario inside `lldb` (found in `tests` folder alongside with `test_libsosplugin.py` and named `scenarioname.py`). -An example of a scenario looks like this: - - import lldb - def runScenario(assemblyName, debugger, target): - process = target.GetProcess() - - # do some work - - process.Continue() - return True - - `runScenario` method does all the work related to running the scenario: setting breakpoints, running SOS commands and examining their output. It should return a boolean value indicating a success or a failure. -***Note:*** `testutils.py` defines some useful commands that can be reused in many scenarios. - - -**Useful links** -[Python scripting in LLDB](http://lldb.llvm.org/python-reference.html) -[Python unittest framework](https://docs.python.org/2.7/library/unittest.html) diff --git a/src/ToolBox/SOS/tests/Test.cs b/src/ToolBox/SOS/tests/Test.cs deleted file mode 100644 index bd3829739..000000000 --- a/src/ToolBox/SOS/tests/Test.cs +++ /dev/null @@ -1,98 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; - -class Test -{ - static void LikelyInlined() - { - Console.WriteLine("I would like to be inlined"); - } - - static void UnlikelyInlined() - { - Console.Write("I"); - Console.Write(" "); - Console.Write("w"); - Console.Write("o"); - Console.Write("u"); - Console.Write("l"); - Console.Write("d"); - Console.Write(" "); - Console.Write("n"); - Console.Write("o"); - Console.Write("t"); - Console.Write(" "); - Console.Write("l"); - Console.Write("i"); - Console.Write("k"); - Console.Write("e"); - Console.Write(" "); - Console.Write("t"); - Console.Write("o"); - Console.Write(" "); - Console.Write("b"); - Console.Write("e"); - Console.Write(" "); - Console.Write("i"); - Console.Write("n"); - Console.Write("l"); - Console.Write("i"); - Console.Write("n"); - Console.Write("e"); - Console.Write("d"); - Console.Write("\n"); - } - - static void ClrU() - { - Console.WriteLine("test dumpclass"); - } - - static void DumpClass() - { - Console.WriteLine("test dumpclass"); - } - - static void DumpIL() - { - Console.WriteLine("test dumpil"); - } - - static void DumpMD() - { - Console.WriteLine("test dumpmd"); - } - - static void DumpModule() - { - Console.WriteLine("test dumpmodule"); - } - - static void DumpObject() - { - Console.WriteLine("test dumpobject"); - } - - static void DumpStackObjects() - { - Console.WriteLine("test dso"); - } - - static void Name2EE() - { - Console.WriteLine("test name2ee"); - } - - - static int Main() - { - DumpIL(); - LikelyInlined(); - UnlikelyInlined(); - - return 0; - } -} diff --git a/src/ToolBox/SOS/tests/t_cmd_bpmd_clear.py b/src/ToolBox/SOS/tests/t_cmd_bpmd_clear.py deleted file mode 100644 index a1ed820cd..000000000 --- a/src/ToolBox/SOS/tests/t_cmd_bpmd_clear.py +++ /dev/null @@ -1,66 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -import lldb -import re -import testutils as test - -# bpmd -clearall - - -def runScenario(assembly, debugger, target): - process = target.GetProcess() - res = lldb.SBCommandReturnObject() - ci = debugger.GetCommandInterpreter() - - # Run debugger, wait until libcoreclr is loaded, - # set breakpoint at Test.Main and stop there - test.stop_in_main(debugger, assembly) - - # Set breakpoint - - ci.HandleCommand("bpmd " + assembly + " Test.UnlikelyInlined", res) - out_msg = res.GetOutput() - err_msg = res.GetError() - print(out_msg) - print(err_msg) - # Interpreter must have this command and able to run it - test.assertTrue(res.Succeeded()) - - # Output is not empty - # Should be at least 'Adding pending breakpoints...' - test.assertTrue(len(out_msg) > 0) - - # Error message is empty - test.assertTrue(len(err_msg) == 0) - - # Delete the first breakpoint - - ci.HandleCommand("bpmd -clear 1", res) - out_msg = res.GetOutput() - err_msg = res.GetError() - print(out_msg) - print(err_msg) - # Interpreter must have this command and able to run it - test.assertTrue(res.Succeeded()) - - match = re.search('Cleared', out_msg) - # Check for specific output - test.assertTrue(match) - - # Error message is empty - test.assertEqual(err_msg, '') - - process.Continue() - # Process must be exited - test.assertEqual(process.GetState(), lldb.eStateExited) - - # The reason of this stop must be a breakpoint - test.assertEqual(process.GetSelectedThread().GetStopReason(), - lldb.eStopReasonNone) - - # - - # Delete all breakpoints, continue current process and checks its exit code - test.exit_lldb(debugger, assembly) diff --git a/src/ToolBox/SOS/tests/t_cmd_bpmd_clearall.py b/src/ToolBox/SOS/tests/t_cmd_bpmd_clearall.py deleted file mode 100644 index 98d86df93..000000000 --- a/src/ToolBox/SOS/tests/t_cmd_bpmd_clearall.py +++ /dev/null @@ -1,66 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -import lldb -import re -import testutils as test - -# bpmd -clearall - - -def runScenario(assembly, debugger, target): - process = target.GetProcess() - res = lldb.SBCommandReturnObject() - ci = debugger.GetCommandInterpreter() - - # Run debugger, wait until libcoreclr is loaded, - # set breakpoint at Test.Main and stop there - test.stop_in_main(debugger, assembly) - - # Set breakpoint - - ci.HandleCommand("bpmd " + assembly + " Test.UnlikelyInlined", res) - out_msg = res.GetOutput() - err_msg = res.GetError() - print(out_msg) - print(err_msg) - # Interpreter must have this command and able to run it - test.assertTrue(res.Succeeded()) - - # Output is not empty - # Should be at least 'Adding pending breakpoints...' - test.assertTrue(len(out_msg) > 0) - - # Error message is empty - test.assertTrue(len(err_msg) == 0) - - # Delete all breakpoints - - ci.HandleCommand("bpmd -clearall", res) - out_msg = res.GetOutput() - err_msg = res.GetError() - print(out_msg) - print(err_msg) - # Interpreter must have this command and able to run it - test.assertTrue(res.Succeeded()) - - match = re.search('All pending breakpoints cleared.', out_msg) - # Check for specific output - test.assertTrue(match) - - # Error message is empty - test.assertEqual(err_msg, '') - - process.Continue() - # Process must be exited - test.assertEqual(process.GetState(), lldb.eStateExited) - - # The reason of this stop must be a breakpoint - test.assertEqual(process.GetSelectedThread().GetStopReason(), - lldb.eStopReasonNone) - - # - - # Delete all breakpoints, continue current process and checks its exit code - test.exit_lldb(debugger, assembly) diff --git a/src/ToolBox/SOS/tests/t_cmd_bpmd_methoddesc.py b/src/ToolBox/SOS/tests/t_cmd_bpmd_methoddesc.py deleted file mode 100644 index a6a85f00d..000000000 --- a/src/ToolBox/SOS/tests/t_cmd_bpmd_methoddesc.py +++ /dev/null @@ -1,49 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -import lldb -import re -import testutils as test - -# bpmd -md - - -def runScenario(assembly, debugger, target): - process = target.GetProcess() - res = lldb.SBCommandReturnObject() - ci = debugger.GetCommandInterpreter() - - # Run debugger, wait until libcoreclr is loaded, - # set breakpoint at Test.Main and stop there - test.stop_in_main(debugger, assembly) - - md_addr = test.get_methoddesc(debugger, assembly, "Test.UnlikelyInlined") - - ci.HandleCommand("bpmd -md %s" % md_addr, res) - out_msg = res.GetOutput() - err_msg = res.GetError() - print(out_msg) - print(err_msg) - # Interpreter must have this command and able to run it - test.assertTrue(res.Succeeded()) - - # Output is not empty - # Should be at least 'Adding pending breakpoints...' - test.assertTrue(len(out_msg) > 0) - - # Error message is empty - test.assertTrue(len(err_msg) == 0) - - process.Continue() - # Process must be stopped at UnlinkelyInlined - test.assertEqual(process.GetState(), lldb.eStateStopped) - - # The reason of this stop must be a breakpoint - test.assertEqual(process.GetSelectedThread().GetStopReason(), - lldb.eStopReasonBreakpoint) - - # - - # Continue current process and checks its exit code - test.exit_lldb(debugger, assembly) diff --git a/src/ToolBox/SOS/tests/t_cmd_bpmd_module_function.py b/src/ToolBox/SOS/tests/t_cmd_bpmd_module_function.py deleted file mode 100644 index f66fe5019..000000000 --- a/src/ToolBox/SOS/tests/t_cmd_bpmd_module_function.py +++ /dev/null @@ -1,47 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -import lldb -import re -import testutils as test - -# bpmd - - -def runScenario(assembly, debugger, target): - process = target.GetProcess() - res = lldb.SBCommandReturnObject() - ci = debugger.GetCommandInterpreter() - - # Run debugger, wait until libcoreclr is loaded, - # set breakpoint at Test.Main and stop there - test.stop_in_main(debugger, assembly) - - ci.HandleCommand("bpmd " + assembly + " Test.UnlikelyInlined", res) - out_msg = res.GetOutput() - err_msg = res.GetError() - print(out_msg) - print(err_msg) - # Interpreter must have this command and able to run it - test.assertTrue(res.Succeeded()) - - # Output is not empty - # Should be at least 'Adding pending breakpoints...' - test.assertTrue(len(out_msg) > 0) - - # Error message is empty - test.assertTrue(len(err_msg) == 0) - - process.Continue() - # Process must be stopped at UnlinkelyInlined - test.assertEqual(process.GetState(), lldb.eStateStopped) - - # The reason of this stop must be a breakpoint - test.assertEqual(process.GetSelectedThread().GetStopReason(), - lldb.eStopReasonBreakpoint) - - # - - # Delete all breakpoints, continue current process and checks its exit code - test.exit_lldb(debugger, assembly) diff --git a/src/ToolBox/SOS/tests/t_cmd_bpmd_module_function_iloffset.py b/src/ToolBox/SOS/tests/t_cmd_bpmd_module_function_iloffset.py deleted file mode 100644 index 1c4441f79..000000000 --- a/src/ToolBox/SOS/tests/t_cmd_bpmd_module_function_iloffset.py +++ /dev/null @@ -1,47 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -import lldb -import re -import testutils as test - -# bpmd [] - - -def runScenario(assembly, debugger, target): - process = target.GetProcess() - res = lldb.SBCommandReturnObject() - ci = debugger.GetCommandInterpreter() - - # Run debugger, wait until libcoreclr is loaded, - # set breakpoint at Test.Main and stop there - test.stop_in_main(debugger, assembly) - - ci.HandleCommand("bpmd " + assembly + " Test.UnlikelyInlined 66", res) - out_msg = res.GetOutput() - err_msg = res.GetError() - print(out_msg) - print(err_msg) - # Interpreter must have this command and able to run it - test.assertTrue(res.Succeeded()) - - # Output is not empty - # Should be at least 'Adding pending breakpoints...' - test.assertTrue(len(out_msg) > 0) - - # Error message is empty - test.assertTrue(len(err_msg) == 0) - - process.Continue() - # Process must be stopped at UnlinkelyInlined - test.assertEqual(process.GetState(), lldb.eStateStopped) - - # The reason of this stop must be a breakpoint - test.assertEqual(process.GetSelectedThread().GetStopReason(), - lldb.eStopReasonBreakpoint) - - # - - # Delete all breakpoints, continue current process and checks its exit code - test.exit_lldb(debugger, assembly) diff --git a/src/ToolBox/SOS/tests/t_cmd_bpmd_nofuturemodule_module_function.py b/src/ToolBox/SOS/tests/t_cmd_bpmd_nofuturemodule_module_function.py deleted file mode 100644 index daeac12ca..000000000 --- a/src/ToolBox/SOS/tests/t_cmd_bpmd_nofuturemodule_module_function.py +++ /dev/null @@ -1,52 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -import lldb -import re -import testutils as test - -# bpmd -nofuturemodule - - -def runScenario(assembly, debugger, target): - process = target.GetProcess() - res = lldb.SBCommandReturnObject() - ci = debugger.GetCommandInterpreter() - - # Process must be stopped here while libcoreclr loading. - # This test usually fails on release version of coreclr - # since we depend on 'LoadLibraryExW' symbol present. - test.assertEqual(process.GetState(), lldb.eStateStopped) - - # The reason of this stop must be a breakpoint - test.assertEqual(process.GetSelectedThread().GetStopReason(), - lldb.eStopReasonBreakpoint) - - ci.HandleCommand("bpmd -nofuturemodule " + assembly + " Test.Main", res) - out_msg = res.GetOutput() - err_msg = res.GetError() - print(out_msg) - print(err_msg) - # Interpreter must have this command and able to run it - test.assertTrue(res.Succeeded()) - - # Output is not empty - # Should be at least 'Adding pending breakpoints...' - test.assertTrue(len(out_msg) == 0) - - # Error message is empty - test.assertTrue(len(err_msg) == 0) - - process.Continue() - # Process must be exited because of -nofuturemodule flag - test.assertEqual(process.GetState(), lldb.eStateExited) - - # The reason of this stop must be a breakpoint - test.assertEqual(process.GetSelectedThread().GetStopReason(), - lldb.eStopReasonNone) - - # - - # Delete all breakpoints, continue current process and checks its exit code - test.exit_lldb(debugger, assembly) diff --git a/src/ToolBox/SOS/tests/t_cmd_clrstack.py b/src/ToolBox/SOS/tests/t_cmd_clrstack.py deleted file mode 100644 index 76bb5169e..000000000 --- a/src/ToolBox/SOS/tests/t_cmd_clrstack.py +++ /dev/null @@ -1,40 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -import lldb -import re -import testutils as test - - -def runScenario(assembly, debugger, target): - process = target.GetProcess() - res = lldb.SBCommandReturnObject() - ci = debugger.GetCommandInterpreter() - - # Run debugger, wait until libcoreclr is loaded, - # set breakpoint at Test.Main and stop there - test.stop_in_main(debugger, assembly) - - ci.HandleCommand("clrstack", res) - print(res.GetOutput()) - print(res.GetError()) - # Interpreter must have this command and able to run it - test.assertTrue(res.Succeeded()) - - output = res.GetOutput() - # Output is not empty - test.assertTrue(len(output) > 0) - - match = re.search('OS Thread Id', output) - # Specific string must be in the output - test.assertTrue(match) - - match = re.search('Failed to start', output) - # Check if a fail was reported - test.assertFalse(match) - - # TODO: test other use cases - - # Continue current process and checks its exit code - test.exit_lldb(debugger, assembly) diff --git a/src/ToolBox/SOS/tests/t_cmd_clrthreads.py b/src/ToolBox/SOS/tests/t_cmd_clrthreads.py deleted file mode 100644 index 5e374dd06..000000000 --- a/src/ToolBox/SOS/tests/t_cmd_clrthreads.py +++ /dev/null @@ -1,35 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -import lldb -import re -import testutils as test - - -def runScenario(assembly, debugger, target): - process = target.GetProcess() - res = lldb.SBCommandReturnObject() - ci = debugger.GetCommandInterpreter() - - # Run debugger, wait until libcoreclr is loaded, - # set breakpoint at Test.Main and stop there - test.stop_in_main(debugger, assembly) - - ci.HandleCommand("clrthreads", res) - print(res.GetOutput()) - print(res.GetError()) - # Interpreter must have this command and able to run it - test.assertTrue(res.Succeeded()) - - output = res.GetOutput() - # Output is not empty - test.assertTrue(len(output) > 0) - - # Specific string must be in the output - test.assertNotEqual(output.find("ThreadCount:"), -1) - - # TODO: test other use cases - - # Continue current process and checks its exit code - test.exit_lldb(debugger, assembly) diff --git a/src/ToolBox/SOS/tests/t_cmd_clru.py b/src/ToolBox/SOS/tests/t_cmd_clru.py deleted file mode 100644 index 6f2971f61..000000000 --- a/src/ToolBox/SOS/tests/t_cmd_clru.py +++ /dev/null @@ -1,50 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -import lldb -import re -import testutils as test - - -def runScenario(assembly, debugger, target): - process = target.GetProcess() - res = lldb.SBCommandReturnObject() - ci = debugger.GetCommandInterpreter() - - # Run debugger, wait until libcoreclr is loaded, - # set breakpoint at Test.Main and stop there - test.stop_in_main(debugger, assembly) - - ci.HandleCommand("name2ee " + assembly + " Test.Main", res) - print(res.GetOutput()) - print(res.GetError()) - # Interpreter must have this command and able to run it - test.assertTrue(res.Succeeded()) - - output = res.GetOutput() - # Output is not empty - test.assertTrue(len(output) > 0) - - match = re.search('JITTED Code Address:\s+([0-9a-fA-F]+)', output) - # Line matched - test.assertTrue(match) - - groups = match.groups() - # Match has a single subgroup - test.assertEqual(len(groups), 1) - - jit_addr = groups[0] - # Address must be a hex number - test.assertTrue(test.is_hexnum(jit_addr)) - - ci.HandleCommand("clru " + jit_addr, res) - print(res.GetOutput()) - print(res.GetError()) - # Interpreter must have this command and able to run it - test.assertTrue(res.Succeeded()) - - # TODO: test other use cases - - # Continue current process and checks its exit code - test.exit_lldb(debugger, assembly) diff --git a/src/ToolBox/SOS/tests/t_cmd_dso.py b/src/ToolBox/SOS/tests/t_cmd_dso.py deleted file mode 100644 index fc6761559..000000000 --- a/src/ToolBox/SOS/tests/t_cmd_dso.py +++ /dev/null @@ -1,35 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -import lldb -import re -import testutils as test - - -def runScenario(assembly, debugger, target): - process = target.GetProcess() - res = lldb.SBCommandReturnObject() - ci = debugger.GetCommandInterpreter() - - # Run debugger, wait until libcoreclr is loaded, - # set breakpoint at Test.Main and stop there - test.stop_in_main(debugger, assembly) - - ci.HandleCommand("dso", res) - print(res.GetOutput()) - print(res.GetError()) - # Interpreter must have this command and able to run it - test.assertTrue(res.Succeeded()) - - output = res.GetOutput() - # Output is not empty - test.assertTrue(len(output) > 0) - - # Specific string must be in the output - test.assertNotEqual(output.find("SP/REG"), -1) - - # TODO: test other use cases - - # Continue current process and checks its exit code - test.exit_lldb(debugger, assembly) diff --git a/src/ToolBox/SOS/tests/t_cmd_dumpclass.py b/src/ToolBox/SOS/tests/t_cmd_dumpclass.py deleted file mode 100644 index 8026122d6..000000000 --- a/src/ToolBox/SOS/tests/t_cmd_dumpclass.py +++ /dev/null @@ -1,72 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -import lldb -import re -import testutils as test - - -def runScenario(assembly, debugger, target): - process = target.GetProcess() - res = lldb.SBCommandReturnObject() - ci = debugger.GetCommandInterpreter() - - # Run debugger, wait until libcoreclr is loaded, - # set breakpoint at Test.Main and stop there - test.stop_in_main(debugger, assembly) - - ci.HandleCommand("name2ee " + assembly + " Test.Main", res) - print(res.GetOutput()) - print(res.GetError()) - # Interpreter must have this command and able to run it - test.assertTrue(res.Succeeded()) - - output = res.GetOutput() - # Output is not empty - test.assertTrue(len(output) > 0) - - match = re.search('MethodDesc:\s+([0-9a-fA-F]+)', output) - # Line matched - test.assertTrue(match) - - groups = match.groups() - # Match has a single subgroup - test.assertEqual(len(groups), 1) - - md_addr = groups[0] - # Address must be a hex number - test.assertTrue(test.is_hexnum(md_addr)) - - ci.HandleCommand("dumpmd " + md_addr, res) - print(res.GetOutput()) - print(res.GetError()) - # Interpreter must have this command and able to run it - test.assertTrue(res.Succeeded()) - - output = res.GetOutput() - # Output is not empty - test.assertTrue(len(output) > 0) - - match = re.search('Class:\s+([0-9a-fA-F]+)', output) - # Line matched - test.assertTrue(match) - - groups = match.groups() - # Match has a single subgroup - test.assertEqual(len(groups), 1) - - class_addr = groups[0] - # Address must be a hex number - test.assertTrue(test.is_hexnum(class_addr)) - - ci.HandleCommand("dumpmd " + class_addr, res) - print(res.GetOutput()) - print(res.GetError()) - # Interpreter must have this command and able to run it - test.assertTrue(res.Succeeded()) - - # TODO: test other use cases - - # Continue current process and checks its exit code - test.exit_lldb(debugger, assembly) diff --git a/src/ToolBox/SOS/tests/t_cmd_dumpheap.py b/src/ToolBox/SOS/tests/t_cmd_dumpheap.py deleted file mode 100644 index 018643566..000000000 --- a/src/ToolBox/SOS/tests/t_cmd_dumpheap.py +++ /dev/null @@ -1,35 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -import lldb -import re -import testutils as test - - -def runScenario(assembly, debugger, target): - process = target.GetProcess() - res = lldb.SBCommandReturnObject() - ci = debugger.GetCommandInterpreter() - - # Run debugger, wait until libcoreclr is loaded, - # set breakpoint at Test.Main and stop there - test.stop_in_main(debugger, assembly) - - ci.HandleCommand("dumpheap", res) - print(res.GetOutput()) - print(res.GetError()) - # Interpreter must have this command and able to run it - test.assertTrue(res.Succeeded()) - - output = res.GetOutput() - # Output is not empty - test.assertTrue(len(output) > 0) - - # Specific string must be in the output - test.assertNotEqual(output.find("Address"), -1) - - # TODO: test other use cases - - # Continue current process and checks its exit code - test.exit_lldb(debugger, assembly) diff --git a/src/ToolBox/SOS/tests/t_cmd_dumpil.py b/src/ToolBox/SOS/tests/t_cmd_dumpil.py deleted file mode 100644 index 1ddd482b0..000000000 --- a/src/ToolBox/SOS/tests/t_cmd_dumpil.py +++ /dev/null @@ -1,42 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -import lldb -import re -import testutils as test - - -def runScenario(assembly, debugger, target): - process = target.GetProcess() - res = lldb.SBCommandReturnObject() - ci = debugger.GetCommandInterpreter() - - # Run debugger, wait until libcoreclr is loaded, - # set breakpoint at Test.Main and stop there - test.stop_in_main(debugger, assembly) - - md_addr = test.get_methoddesc(debugger, assembly, "Test.DumpIL") - - ci.HandleCommand("dumpil " + md_addr, res) - print(res.GetOutput()) - print(res.GetError()) - # Interpreter must have this command and able to run it - test.assertTrue(res.Succeeded()) - - insts = res.GetOutput() - print(insts) - # Function must have some instructions - test.assertTrue(len(insts) > 0) - - match = re.search(r'IL_\w{4}:\sldstr.*test\sdumpil.*' + - r'IL_\w{4}:\scall.*System\.Console::WriteLine.*' + - r'IL_\w{4}:\sret', - insts.replace('\n', ' ')) - # Must have ldstr, call and ret instructions - test.assertTrue(match) - - # TODO: test other use cases - - # Continue current process and checks its exit code - test.exit_lldb(debugger, assembly) diff --git a/src/ToolBox/SOS/tests/t_cmd_dumplog.py b/src/ToolBox/SOS/tests/t_cmd_dumplog.py deleted file mode 100644 index 631beb48a..000000000 --- a/src/ToolBox/SOS/tests/t_cmd_dumplog.py +++ /dev/null @@ -1,35 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -import lldb -import re -import testutils as test - - -def runScenario(assembly, debugger, target): - process = target.GetProcess() - res = lldb.SBCommandReturnObject() - ci = debugger.GetCommandInterpreter() - - # Run debugger, wait until libcoreclr is loaded, - # set breakpoint at Test.Main and stop there - test.stop_in_main(debugger, assembly) - - ci.HandleCommand("dumplog", res) - print(res.GetOutput()) - print(res.GetError()) - # Interpreter must have this command and able to run it - test.assertTrue(res.Succeeded()) - - output = res.GetOutput() - # Output is not empty - test.assertTrue(len(output) > 0) - - # Specific string must be in the output - test.assertNotEqual(output.find(" dump "), -1) - - # TODO: test other use cases - - # Continue current process and checks its exit code - test.exit_lldb(debugger, assembly) diff --git a/src/ToolBox/SOS/tests/t_cmd_dumpmd.py b/src/ToolBox/SOS/tests/t_cmd_dumpmd.py deleted file mode 100644 index b2b020b4d..000000000 --- a/src/ToolBox/SOS/tests/t_cmd_dumpmd.py +++ /dev/null @@ -1,50 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -import lldb -import re -import testutils as test - - -def runScenario(assembly, debugger, target): - process = target.GetProcess() - res = lldb.SBCommandReturnObject() - ci = debugger.GetCommandInterpreter() - - # Run debugger, wait until libcoreclr is loaded, - # set breakpoint at Test.Main and stop there - test.stop_in_main(debugger, assembly) - - ci.HandleCommand("name2ee " + assembly + " Test.Main", res) - print(res.GetOutput()) - print(res.GetError()) - # Interpreter must have this command and able to run it - test.assertTrue(res.Succeeded()) - - output = res.GetOutput() - # Output is not empty - test.assertTrue(len(output) > 0) - - match = re.search('MethodDesc:\s+([0-9a-fA-F]+)', output) - # Line matched - test.assertTrue(match) - - groups = match.groups() - # Match has a single subgroup - test.assertEqual(len(groups), 1) - - md_addr = groups[0] - # Address must be a hex number - test.assertTrue(test.is_hexnum(md_addr)) - - ci.HandleCommand("dumpmd " + md_addr, res) - print(res.GetOutput()) - print(res.GetError()) - # Interpreter must have this command and able to run it - test.assertTrue(res.Succeeded()) - - # TODO: test other use cases - - # Continue current process and checks its exit code - test.exit_lldb(debugger, assembly) diff --git a/src/ToolBox/SOS/tests/t_cmd_dumpmodule.py b/src/ToolBox/SOS/tests/t_cmd_dumpmodule.py deleted file mode 100644 index 5f256b12f..000000000 --- a/src/ToolBox/SOS/tests/t_cmd_dumpmodule.py +++ /dev/null @@ -1,50 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -import lldb -import re -import testutils as test - - -def runScenario(assembly, debugger, target): - process = target.GetProcess() - res = lldb.SBCommandReturnObject() - ci = debugger.GetCommandInterpreter() - - # Run debugger, wait until libcoreclr is loaded, - # set breakpoint at Test.Main and stop there - test.stop_in_main(debugger, assembly) - - ci.HandleCommand("name2ee " + assembly + " Test.Main", res) - print(res.GetOutput()) - print(res.GetError()) - # Interpreter must have this command and able to run it - test.assertTrue(res.Succeeded()) - - output = res.GetOutput() - # Output is not empty - test.assertTrue(len(output) > 0) - - match = re.search('Module:\s+([0-9a-fA-F]+)', output) - # Line matched - test.assertTrue(match) - - groups = match.groups() - # Match has a single subgroup - test.assertEqual(len(groups), 1) - - md_addr = groups[0] - # Address must be a hex number - test.assertTrue(test.is_hexnum(md_addr)) - - ci.HandleCommand("dumpmodule " + md_addr, res) - print(res.GetOutput()) - print(res.GetError()) - # Interpreter must have this command and able to run it - test.assertTrue(res.Succeeded()) - - # TODO: test other use cases - - # Continue current process and checks its exit code - test.exit_lldb(debugger, assembly) diff --git a/src/ToolBox/SOS/tests/t_cmd_dumpmt.py b/src/ToolBox/SOS/tests/t_cmd_dumpmt.py deleted file mode 100644 index 3640a4b55..000000000 --- a/src/ToolBox/SOS/tests/t_cmd_dumpmt.py +++ /dev/null @@ -1,72 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -import lldb -import re -import testutils as test - - -def runScenario(assembly, debugger, target): - process = target.GetProcess() - res = lldb.SBCommandReturnObject() - ci = debugger.GetCommandInterpreter() - - # Run debugger, wait until libcoreclr is loaded, - # set breakpoint at Test.Main and stop there - test.stop_in_main(debugger, assembly) - - ci.HandleCommand("name2ee " + assembly + " Test.Main", res) - print(res.GetOutput()) - print(res.GetError()) - # Interpreter must have this command and able to run it - test.assertTrue(res.Succeeded()) - - output = res.GetOutput() - # Output is not empty - test.assertTrue(len(output) > 0) - - match = re.search('MethodDesc:\s+([0-9a-fA-F]+)', output) - # Line matched - test.assertTrue(match) - - groups = match.groups() - # Match has a single subgroup - test.assertEqual(len(groups), 1) - - md_addr = groups[0] - # Address must be a hex number - test.assertTrue(test.is_hexnum(md_addr)) - - ci.HandleCommand("dumpmd " + md_addr, res) - print(res.GetOutput()) - print(res.GetError()) - # Interpreter must have this command and able to run it - test.assertTrue(res.Succeeded()) - - output = res.GetOutput() - # Output is not empty - test.assertTrue(len(output) > 0) - - match = re.search('MethodTable:\s+([0-9a-fA-F]+)', output) - # Line matched - test.assertTrue(match) - - groups = match.groups() - # Match has a single subgroup - test.assertEqual(len(groups), 1) - - mt_addr = groups[0] - # Address must be a hex number - test.assertTrue(test.is_hexnum(mt_addr)) - - ci.HandleCommand("dumpmt " + mt_addr, res) - print(res.GetOutput()) - print(res.GetError()) - # Interpreter must have this command and able to run it - test.assertTrue(res.Succeeded()) - - # TODO: test other use cases - - # Continue current process and checks its exit code - test.exit_lldb(debugger, assembly) diff --git a/src/ToolBox/SOS/tests/t_cmd_dumpobj.py b/src/ToolBox/SOS/tests/t_cmd_dumpobj.py deleted file mode 100644 index a6f2e3934..000000000 --- a/src/ToolBox/SOS/tests/t_cmd_dumpobj.py +++ /dev/null @@ -1,73 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -import lldb -import re -import testutils as test - - -def runScenario(assembly, debugger, target): - process = target.GetProcess() - res = lldb.SBCommandReturnObject() - ci = debugger.GetCommandInterpreter() - - # Run debugger, wait until libcoreclr is loaded, - # set breakpoint at Test.Main and stop there - test.stop_in_main(debugger, assembly) - - ci.HandleCommand("dso", res) - print(res.GetOutput()) - print(res.GetError()) - # Interpreter must have this command and able to run it - test.assertTrue(res.Succeeded()) - - output = res.GetOutput() - # Output is not empty - test.assertTrue(len(output) > 0) - - # Get all objects - objects = [] - for line in output.split('\n'): - match = re.match('([0-9a-fA-F]+)\s+([0-9a-fA-F]+)\s', line) - # Not all lines list objects - if match: - groups = match.groups() - # Match has exactly two subgroups - test.assertEqual(len(groups), 2) - - obj_addr = groups[1] - # Address must be a hex number - test.assertTrue(test.is_hexnum(obj_addr)) - - objects.append(obj_addr) - - # There must be at least one object - test.assertTrue(len(objects) > 0) - - for obj in objects: - ci.HandleCommand("dumpobj " + obj, res) - print(res.GetOutput()) - print(res.GetError()) - # Interpreter must have this command and able to run it - test.assertTrue(res.Succeeded()) - - output = res.GetOutput() - # Output is not empty - test.assertTrue(len(output) > 0) - - match = re.search('Name:\s+\S+', output) - test.assertTrue(match) - match = re.search('MethodTable:\s+[0-9a-fA-F]+', output) - test.assertTrue(match) - match = re.search('EEClass:\s+[0-9a-fA-F]+', output) - test.assertTrue(match) - match = re.search('Size:\s+[0-9a-fA-F]+', output) - test.assertTrue(match) - match = re.search('Fields:', output) - test.assertTrue(match) - - # TODO: test other use cases - - # Continue current process and checks its exit code - test.exit_lldb(debugger, assembly) diff --git a/src/ToolBox/SOS/tests/t_cmd_dumpstack.py b/src/ToolBox/SOS/tests/t_cmd_dumpstack.py deleted file mode 100644 index 24ae1a5bd..000000000 --- a/src/ToolBox/SOS/tests/t_cmd_dumpstack.py +++ /dev/null @@ -1,35 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -import lldb -import re -import testutils as test - - -def runScenario(assembly, debugger, target): - process = target.GetProcess() - res = lldb.SBCommandReturnObject() - ci = debugger.GetCommandInterpreter() - - # Run debugger, wait until libcoreclr is loaded, - # set breakpoint at Test.Main and stop there - test.stop_in_main(debugger, assembly) - - ci.HandleCommand("dumpstack", res) - print(res.GetOutput()) - print(res.GetError()) - # Interpreter must have this command and able to run it - test.assertTrue(res.Succeeded()) - - output = res.GetOutput() - # Output is not empty - test.assertTrue(len(output) > 0) - - # Specific string must be in the output - test.assertNotEqual(output.find("Test.Main()"), -1) - - # TODO: test other use cases - - # Continue current process and checks its exit code - test.exit_lldb(debugger, assembly) diff --git a/src/ToolBox/SOS/tests/t_cmd_eeheap.py b/src/ToolBox/SOS/tests/t_cmd_eeheap.py deleted file mode 100644 index 8c9596467..000000000 --- a/src/ToolBox/SOS/tests/t_cmd_eeheap.py +++ /dev/null @@ -1,35 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -import lldb -import re -import testutils as test - - -def runScenario(assembly, debugger, target): - process = target.GetProcess() - res = lldb.SBCommandReturnObject() - ci = debugger.GetCommandInterpreter() - - # Run debugger, wait until libcoreclr is loaded, - # set breakpoint at Test.Main and stop there - test.stop_in_main(debugger, assembly) - - ci.HandleCommand("eeheap", res) - print(res.GetOutput()) - print(res.GetError()) - # Interpreter must have this command and able to run it - test.assertTrue(res.Succeeded()) - - output = res.GetOutput() - # Output is not empty - test.assertTrue(len(output) > 0) - - # Specific string must be in the output - test.assertNotEqual(output.find("Loader Heap"), -1) - - # TODO: test other use cases - - # Continue current process and checks its exit code - test.exit_lldb(debugger, assembly) diff --git a/src/ToolBox/SOS/tests/t_cmd_eestack.py b/src/ToolBox/SOS/tests/t_cmd_eestack.py deleted file mode 100644 index 8764bccf4..000000000 --- a/src/ToolBox/SOS/tests/t_cmd_eestack.py +++ /dev/null @@ -1,35 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -import lldb -import re -import testutils as test - - -def runScenario(assembly, debugger, target): - process = target.GetProcess() - res = lldb.SBCommandReturnObject() - ci = debugger.GetCommandInterpreter() - - # Run debugger, wait until libcoreclr is loaded, - # set breakpoint at Test.Main and stop there - test.stop_in_main(debugger, assembly) - - ci.HandleCommand("eestack", res) - print(res.GetOutput()) - print(res.GetError()) - # Interpreter must have this command and able to run it - test.assertTrue(res.Succeeded()) - - output = res.GetOutput() - # Output is not empty - test.assertTrue(len(output) > 0) - - # Specific string must be in the output - test.assertNotEqual(output.find("Current frame"), -1) - - # TODO: test other use cases - - # Continue current process and checks its exit code - test.exit_lldb(debugger, assembly) diff --git a/src/ToolBox/SOS/tests/t_cmd_gcroot.py b/src/ToolBox/SOS/tests/t_cmd_gcroot.py deleted file mode 100644 index 636578d69..000000000 --- a/src/ToolBox/SOS/tests/t_cmd_gcroot.py +++ /dev/null @@ -1,65 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -import lldb -import re -import testutils as test - - -def runScenario(assembly, debugger, target): - process = target.GetProcess() - res = lldb.SBCommandReturnObject() - ci = debugger.GetCommandInterpreter() - - # Run debugger, wait until libcoreclr is loaded, - # set breakpoint at Test.Main and stop there - test.stop_in_main(debugger, assembly) - - ci.HandleCommand("dso", res) - print(res.GetOutput()) - print(res.GetError()) - # Interpreter must have this command and able to run it - test.assertTrue(res.Succeeded()) - - output = res.GetOutput() - # Output is not empty - test.assertTrue(len(output) > 0) - - # Get all objects - objects = [] - for line in output.split('\n'): - match = re.match('([0-9a-fA-F]+)\s+([0-9a-fA-F]+)\s', line) - # Not all lines list objects - if match: - groups = match.groups() - # Match has exactly two subgroups - test.assertEqual(len(groups), 2) - - obj_addr = groups[1] - # Address must be a hex number - test.assertTrue(test.is_hexnum(obj_addr)) - - objects.append(obj_addr) - - # There must be at least one object - test.assertTrue(len(objects) > 0) - - for obj in objects: - ci.HandleCommand("gcroot " + obj, res) - print(res.GetOutput()) - print(res.GetError()) - # Interpreter must have this command and able to run it - test.assertTrue(res.Succeeded()) - - output = res.GetOutput() - # Output is not empty - test.assertTrue(len(output) > 0) - - match = re.search('Found', output) - test.assertTrue(match) - - # TODO: test other use cases - - # Continue current process and checks its exit code - test.exit_lldb(debugger, assembly) diff --git a/src/ToolBox/SOS/tests/t_cmd_histclear.py b/src/ToolBox/SOS/tests/t_cmd_histclear.py deleted file mode 100644 index b5206a7cd..000000000 --- a/src/ToolBox/SOS/tests/t_cmd_histclear.py +++ /dev/null @@ -1,35 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -import lldb -import re -import testutils as test - - -def runScenario(assembly, debugger, target): - process = target.GetProcess() - res = lldb.SBCommandReturnObject() - ci = debugger.GetCommandInterpreter() - - # Run debugger, wait until libcoreclr is loaded, - # set breakpoint at Test.Main and stop there - test.stop_in_main(debugger, assembly) - - ci.HandleCommand("histclear", res) - print(res.GetOutput()) - print(res.GetError()) - # Interpreter must have this command and able to run it - test.assertTrue(res.Succeeded()) - - output = res.GetOutput() - # Output is not empty - test.assertTrue(len(output) > 0) - - # Specific string must be in the output - test.assertNotEqual(output.find("Completed successfully."), -1) - - # TODO: test other use cases - - # Continue current process and checks its exit code - test.exit_lldb(debugger, assembly) diff --git a/src/ToolBox/SOS/tests/t_cmd_histinit.py b/src/ToolBox/SOS/tests/t_cmd_histinit.py deleted file mode 100644 index d0b2e8929..000000000 --- a/src/ToolBox/SOS/tests/t_cmd_histinit.py +++ /dev/null @@ -1,35 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -import lldb -import re -import testutils as test - - -def runScenario(assembly, debugger, target): - process = target.GetProcess() - res = lldb.SBCommandReturnObject() - ci = debugger.GetCommandInterpreter() - - # Run debugger, wait until libcoreclr is loaded, - # set breakpoint at Test.Main and stop there - test.stop_in_main(debugger, assembly) - - ci.HandleCommand("histinit", res) - print(res.GetOutput()) - print(res.GetError()) - # Interpreter must have this command and able to run it - test.assertTrue(res.Succeeded()) - - output = res.GetOutput() - # Output is not empty - test.assertTrue(len(output) > 0) - - # Specific string must be in the output - test.assertNotEqual(output.find("STRESS LOG:"), -1) - - # TODO: test other use cases - - # Continue current process and checks its exit code - test.exit_lldb(debugger, assembly) diff --git a/src/ToolBox/SOS/tests/t_cmd_histobj.py b/src/ToolBox/SOS/tests/t_cmd_histobj.py deleted file mode 100644 index 402f04214..000000000 --- a/src/ToolBox/SOS/tests/t_cmd_histobj.py +++ /dev/null @@ -1,65 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -import lldb -import re -import testutils as test - - -def runScenario(assembly, debugger, target): - process = target.GetProcess() - res = lldb.SBCommandReturnObject() - ci = debugger.GetCommandInterpreter() - - # Run debugger, wait until libcoreclr is loaded, - # set breakpoint at Test.Main and stop there - test.stop_in_main(debugger, assembly) - - ci.HandleCommand("dso", res) - print(res.GetOutput()) - print(res.GetError()) - # Interpreter must have this command and able to run it - test.assertTrue(res.Succeeded()) - - output = res.GetOutput() - # Output is not empty - test.assertTrue(len(output) > 0) - - # Get all objects - objects = [] - for line in output.split('\n'): - match = re.match('([0-9a-fA-F]+)\s+([0-9a-fA-F]+)\s', line) - # Not all lines list objects - if match: - groups = match.groups() - # Match has exactly two subgroups - test.assertEqual(len(groups), 2) - - obj_addr = groups[1] - # Address must be a hex number - test.assertTrue(test.is_hexnum(obj_addr)) - - objects.append(obj_addr) - - # There must be at least one object - test.assertTrue(len(objects) > 0) - - for obj in objects: - ci.HandleCommand("histobj " + obj, res) - print(res.GetOutput()) - print(res.GetError()) - # Interpreter must have this command and able to run it - test.assertTrue(res.Succeeded()) - - output = res.GetOutput() - # Output is not empty - test.assertTrue(len(output) > 0) - - match = re.search('GCCount', output) - test.assertTrue(match) - - # TODO: test other use cases - - # Continue current process and checks its exit code - test.exit_lldb(debugger, assembly) diff --git a/src/ToolBox/SOS/tests/t_cmd_histobjfind.py b/src/ToolBox/SOS/tests/t_cmd_histobjfind.py deleted file mode 100644 index 611639978..000000000 --- a/src/ToolBox/SOS/tests/t_cmd_histobjfind.py +++ /dev/null @@ -1,65 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -import lldb -import re -import testutils as test - - -def runScenario(assembly, debugger, target): - process = target.GetProcess() - res = lldb.SBCommandReturnObject() - ci = debugger.GetCommandInterpreter() - - # Run debugger, wait until libcoreclr is loaded, - # set breakpoint at Test.Main and stop there - test.stop_in_main(debugger, assembly) - - ci.HandleCommand("dso", res) - print(res.GetOutput()) - print(res.GetError()) - # Interpreter must have this command and able to run it - test.assertTrue(res.Succeeded()) - - output = res.GetOutput() - # Output is not empty - test.assertTrue(len(output) > 0) - - # Get all objects - objects = [] - for line in output.split('\n'): - match = re.match('([0-9a-fA-F]+)\s+([0-9a-fA-F]+)\s', line) - # Not all lines list objects - if match: - groups = match.groups() - # Match has exactly two subgroups - test.assertEqual(len(groups), 2) - - obj_addr = groups[1] - # Address must be a hex number - test.assertTrue(test.is_hexnum(obj_addr)) - - objects.append(obj_addr) - - # There must be at least one object - test.assertTrue(len(objects) > 0) - - for obj in objects: - ci.HandleCommand("histobjfind " + obj, res) - print(res.GetOutput()) - print(res.GetError()) - # Interpreter must have this command and able to run it - test.assertTrue(res.Succeeded()) - - output = res.GetOutput() - # Output is not empty - test.assertTrue(len(output) > 0) - - match = re.search('GCCount', output) - test.assertTrue(match) - - # TODO: test other use cases - - # Continue current process and checks its exit code - test.exit_lldb(debugger, assembly) diff --git a/src/ToolBox/SOS/tests/t_cmd_histroot.py b/src/ToolBox/SOS/tests/t_cmd_histroot.py deleted file mode 100644 index e212b1f08..000000000 --- a/src/ToolBox/SOS/tests/t_cmd_histroot.py +++ /dev/null @@ -1,65 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -import lldb -import re -import testutils as test - - -def runScenario(assembly, debugger, target): - process = target.GetProcess() - res = lldb.SBCommandReturnObject() - ci = debugger.GetCommandInterpreter() - - # Run debugger, wait until libcoreclr is loaded, - # set breakpoint at Test.Main and stop there - test.stop_in_main(debugger, assembly) - - ci.HandleCommand("dso", res) - print(res.GetOutput()) - print(res.GetError()) - # Interpreter must have this command and able to run it - test.assertTrue(res.Succeeded()) - - output = res.GetOutput() - # Output is not empty - test.assertTrue(len(output) > 0) - - # Get all objects - objects = [] - for line in output.split('\n'): - match = re.match('([0-9a-fA-F]+)\s+([0-9a-fA-F]+)\s', line) - # Not all lines list objects - if match: - groups = match.groups() - # Match has exactly two subgroups - test.assertEqual(len(groups), 2) - - obj_addr = groups[1] - # Address must be a hex number - test.assertTrue(test.is_hexnum(obj_addr)) - - objects.append(obj_addr) - - # There must be at least one object - test.assertTrue(len(objects) > 0) - - for obj in objects: - ci.HandleCommand("histroot " + obj, res) - print(res.GetOutput()) - print(res.GetError()) - # Interpreter must have this command and able to run it - test.assertTrue(res.Succeeded()) - - output = res.GetOutput() - # Output is not empty - test.assertTrue(len(output) > 0) - - match = re.search('GCCount', output) - test.assertTrue(match) - - # TODO: test other use cases - - # Continue current process and checks its exit code - test.exit_lldb(debugger, assembly) diff --git a/src/ToolBox/SOS/tests/t_cmd_ip2md.py b/src/ToolBox/SOS/tests/t_cmd_ip2md.py deleted file mode 100644 index 78bebe95f..000000000 --- a/src/ToolBox/SOS/tests/t_cmd_ip2md.py +++ /dev/null @@ -1,57 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -import lldb -import re -import testutils as test - - -def runScenario(assembly, debugger, target): - process = target.GetProcess() - res = lldb.SBCommandReturnObject() - ci = debugger.GetCommandInterpreter() - - # Run debugger, wait until libcoreclr is loaded, - # set breakpoint at Test.Main and stop there - test.stop_in_main(debugger, assembly) - - ci.HandleCommand("name2ee " + assembly + " Test.Main", res) - print(res.GetOutput()) - print(res.GetError()) - # Interpreter must have this command and able to run it - test.assertTrue(res.Succeeded()) - - output = res.GetOutput() - # Output is not empty - test.assertTrue(len(output) > 0) - - match = re.search('JITTED Code Address:\s+([0-9a-fA-F]+)', output) - # Line matched - test.assertTrue(match) - - groups = match.groups() - # Match has a single subgroup - test.assertEqual(len(groups), 1) - - jit_addr = groups[0] - # Address must be a hex number - test.assertTrue(test.is_hexnum(jit_addr)) - - ci.HandleCommand("ip2md " + jit_addr, res) - print(res.GetOutput()) - print(res.GetError()) - # Interpreter must have this command and able to run it - test.assertTrue(res.Succeeded()) - - output = res.GetOutput() - # Output is not empty - test.assertTrue(len(output) > 0) - - # Specific string must be in the output - test.assertNotEqual(output.find("MethodDesc:"), -1) - - # TODO: test other use cases - - # Continue current process and checks its exit code - test.exit_lldb(debugger, assembly) diff --git a/src/ToolBox/SOS/tests/t_cmd_name2ee.py b/src/ToolBox/SOS/tests/t_cmd_name2ee.py deleted file mode 100644 index 71d421251..000000000 --- a/src/ToolBox/SOS/tests/t_cmd_name2ee.py +++ /dev/null @@ -1,50 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -import lldb -import re -import testutils as test - - -def runScenario(assembly, debugger, target): - process = target.GetProcess() - res = lldb.SBCommandReturnObject() - ci = debugger.GetCommandInterpreter() - - # Run debugger, wait until libcoreclr is loaded, - # set breakpoint at Test.Main and stop there - test.stop_in_main(debugger, assembly) - - ci.HandleCommand("name2ee " + assembly + " Test.Main", res) - print(res.GetOutput()) - print(res.GetError()) - # Interpreter must have this command and able to run it - test.assertTrue(res.Succeeded()) - - output = res.GetOutput() - # Output is not empty - test.assertTrue(len(output) > 0) - - match = re.search('Module:\s+[0-9a-fA-F]+', output) - test.assertTrue(match) - match = re.search('Assembly:\s+\S+', output) - test.assertTrue(match) - match = re.search('Token:\s+[0-9a-fA-F]+', output) - test.assertTrue(match) - match = re.search('MethodDesc:\s+[0-9a-fA-F]+', output) - test.assertTrue(match) - match = re.search('Name:\s+\S+', output) - test.assertTrue(match) - - process.Continue() - # Process must exit - test.assertEqual(process.GetState(), lldb.eStateExited) - - # Process must exit with zero code - test.assertEqual(process.GetExitStatus(), 0) - - # TODO: test other use cases - - # Continue current process and checks its exit code - test.exit_lldb(debugger, assembly) diff --git a/src/ToolBox/SOS/tests/t_cmd_pe.py b/src/ToolBox/SOS/tests/t_cmd_pe.py deleted file mode 100644 index 0a8701493..000000000 --- a/src/ToolBox/SOS/tests/t_cmd_pe.py +++ /dev/null @@ -1,28 +0,0 @@ -import lldb -import re -import testutils as test - - -def runScenario(assembly, debugger, target): - process = target.GetProcess() - res = lldb.SBCommandReturnObject() - ci = debugger.GetCommandInterpreter() - - # Run debugger, wait until libcoreclr is loaded, - # set breakpoint at Test.Main and stop there - test.stop_in_main(debugger, assembly) - - ci.HandleCommand("dso", res) - print(res.GetOutput()) - print(res.GetError()) - # Interpreter must have this command and able to run it - test.assertTrue(res.Succeeded()) - - output = res.GetOutput() - # Output is not empty - test.assertTrue(len(output) > 0) - - # TODO: test other use cases - - # Continue current process and checks its exit code - test.exit_lldb(debugger, assembly) diff --git a/src/ToolBox/SOS/tests/t_cmd_sos.py b/src/ToolBox/SOS/tests/t_cmd_sos.py deleted file mode 100644 index b407491d7..000000000 --- a/src/ToolBox/SOS/tests/t_cmd_sos.py +++ /dev/null @@ -1,31 +0,0 @@ -import lldb -import re -import testutils as test - - -def runScenario(assembly, debugger, target): - process = target.GetProcess() - res = lldb.SBCommandReturnObject() - ci = debugger.GetCommandInterpreter() - - # Run debugger, wait until libcoreclr is loaded, - # set breakpoint at Test.Main and stop there - test.stop_in_main(debugger, assembly) - - ci.HandleCommand("sos", res) - print(res.GetOutput()) - print(res.GetError()) - # Interpreter must have this command and able to run it - test.assertTrue(res.Succeeded()) - - output = res.GetOutput() - # Output is not empty - test.assertTrue(len(output) > 0) - - # Specific string must be in the output - test.assertNotEqual(output.find("SOS"), -1) - - # TODO: test other use cases - - # Continue current process and checks its exit code - test.exit_lldb(debugger, assembly) diff --git a/src/ToolBox/SOS/tests/t_cmd_soshelp.py b/src/ToolBox/SOS/tests/t_cmd_soshelp.py deleted file mode 100644 index 8bb51dad5..000000000 --- a/src/ToolBox/SOS/tests/t_cmd_soshelp.py +++ /dev/null @@ -1,31 +0,0 @@ -import lldb -import re -import testutils as test - - -def runScenario(assembly, debugger, target): - process = target.GetProcess() - res = lldb.SBCommandReturnObject() - ci = debugger.GetCommandInterpreter() - - # Run debugger, wait until libcoreclr is loaded, - # set breakpoint at Test.Main and stop there - test.stop_in_main(debugger, assembly) - - ci.HandleCommand("soshelp", res) - print(res.GetOutput()) - print(res.GetError()) - # Interpreter must have this command and able to run it - test.assertTrue(res.Succeeded()) - - output = res.GetOutput() - # Output is not empty - test.assertTrue(len(output) > 0) - - # Specific string must be in the output - test.assertNotEqual(output.find("soshelp "), -1) - - # TODO: test other use cases - - # Continue current process and checks its exit code - test.exit_lldb(debugger, assembly) diff --git a/src/ToolBox/SOS/tests/test_libsosplugin.py b/src/ToolBox/SOS/tests/test_libsosplugin.py deleted file mode 100644 index e7bab1453..000000000 --- a/src/ToolBox/SOS/tests/test_libsosplugin.py +++ /dev/null @@ -1,288 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -from __future__ import print_function -import unittest -import argparse -import re -import tempfile -import subprocess -import threading -import os -import sys -import inspect - -lldb = '' -clrdir = '' -workdir = '' -corerun = '' -sosplugin = '' -assembly = '' -fail_flag = '' -fail_flag_lldb = '' -summary_file = '' -timeout = 0 -regex = '' -repeat = 0 - - -def runWithTimeout(cmd): - p = None - - def run(): - global p - p = subprocess.Popen(cmd, shell=True) - p.communicate() - - thread = threading.Thread(target=run) - thread.start() - - thread.join(timeout) - if thread.is_alive(): - with open(summary_file, 'a+') as summary: - print('Timeout!', file=summary) - p.kill() - thread.join() - - -class TestSosCommands(unittest.TestCase): - - def do_test(self, command): - open(fail_flag, 'a').close() - try: - os.unlink(fail_flag_lldb) - except: - pass - - cmd = (('%s -b ' % lldb) + - ("-k \"script open('%s', 'a').close()\" " % fail_flag_lldb) + - ("-k 'quit' ") + - ("--no-lldbinit ") + - ("-O \"plugin load %s \" " % sosplugin) + - ("-o \"script import testutils as test\" ") + - ("-o \"script test.fail_flag = '%s'\" " % fail_flag) + - ("-o \"script test.summary_file = '%s'\" " % summary_file) + - ("-o \"script test.run('%s', '%s')\" " % (assembly, command)) + - ("-o \"quit\" ") + - (" -- %s %s > %s.log 2> %s.log.2" % (corerun, assembly, - command, command))) - - runWithTimeout(cmd) - self.assertFalse(os.path.isfile(fail_flag)) - self.assertFalse(os.path.isfile(fail_flag_lldb)) - - try: - os.unlink(fail_flag) - except: - pass - try: - os.unlink(fail_flag_lldb) - except: - pass - - def t_cmd_bpmd_nofuturemodule_module_function(self): - self.do_test('t_cmd_bpmd_nofuturemodule_module_function') - - def t_cmd_bpmd_module_function(self): - self.do_test('t_cmd_bpmd_module_function') - - def t_cmd_bpmd_module_function_iloffset(self): - self.do_test('t_cmd_bpmd_module_function_iloffset') - - def t_cmd_bpmd_methoddesc(self): - self.do_test('t_cmd_bpmd_methoddesc') - - def t_cmd_bpmd_clearall(self): - self.do_test('t_cmd_bpmd_clearall') - - def t_cmd_clrstack(self): - self.do_test('t_cmd_clrstack') - - def t_cmd_clrthreads(self): - self.do_test('t_cmd_clrthreads') - - def t_cmd_clru(self): - self.do_test('t_cmd_clru') - - def t_cmd_dumpclass(self): - self.do_test('t_cmd_dumpclass') - - def t_cmd_dumpheap(self): - self.do_test('t_cmd_dumpheap') - - def t_cmd_dumpil(self): - self.do_test('t_cmd_dumpil') - - def t_cmd_dumplog(self): - self.do_test('t_cmd_dumplog') - - def t_cmd_dumpmd(self): - self.do_test('t_cmd_dumpmd') - - def t_cmd_dumpmodule(self): - self.do_test('t_cmd_dumpmodule') - - def t_cmd_dumpmt(self): - self.do_test('t_cmd_dumpmt') - - def t_cmd_dumpobj(self): - self.do_test('t_cmd_dumpobj') - - def t_cmd_dumpstack(self): - self.do_test('t_cmd_dumpstack') - - def t_cmd_dso(self): - self.do_test('t_cmd_dso') - - def t_cmd_eeheap(self): - self.do_test('t_cmd_eeheap') - - def t_cmd_eestack(self): - self.do_test('t_cmd_eestack') - - def t_cmd_gcroot(self): - self.do_test('t_cmd_gcroot') - - def t_cmd_ip2md(self): - self.do_test('t_cmd_ip2md') - - def t_cmd_name2ee(self): - self.do_test('t_cmd_name2ee') - - def t_cmd_pe(self): - self.do_test('t_cmd_pe') - - def t_cmd_histclear(self): - self.do_test('t_cmd_histclear') - - def t_cmd_histinit(self): - self.do_test('t_cmd_histinit') - - def t_cmd_histobj(self): - self.do_test('t_cmd_histobj') - - def t_cmd_histobjfind(self): - self.do_test('t_cmd_histobjfind') - - def t_cmd_histroot(self): - self.do_test('t_cmd_histroot') - - def t_cmd_sos(self): - self.do_test('t_cmd_sos') - - def t_cmd_soshelp(self): - self.do_test('t_cmd_soshelp') - - -def generate_report(): - report = [{'name': 'TOTAL', True: 0, False: 0, 'completed': True}] - fail_messages = [] - - if not os.path.isfile(summary_file): - print('No summary file to process!') - return - - with open(summary_file, 'r') as summary: - for line in summary: - if line.startswith('new_suite: '): - report.append({'name': line.split()[-1], True: 0, False: 0, - 'completed': False, 'timeout': False}) - elif line.startswith('True'): - report[-1][True] += 1 - elif line.startswith('False'): - report[-1][False] += 1 - elif line.startswith('Completed!'): - report[-1]['completed'] = True - elif line.startswith('Timeout!'): - report[-1]['timeout'] = True - elif line.startswith('!!! '): - fail_messages.append(line.rstrip('\n')) - - for suite in report[1:]: - report[0][True] += suite[True] - report[0][False] += suite[False] - report[0]['completed'] &= suite['completed'] - - for line in fail_messages: - print(line) - - print() - print('=' * 79) - print('{:72} {:6}'.format('Test suite', 'Result')) - print('-' * 79) - for suite in report[1:]: - if suite['timeout']: - result = 'Timeout' - elif suite[False]: - result = 'Fail' - elif not suite['completed']: - result = 'Crash' - elif suite[True]: - result = 'Success' - else: - result = 'Please, report' - print('{:68} {:>10}'.format(suite['name'], result)) - print('=' * 79) - - -if __name__ == '__main__': - parser = argparse.ArgumentParser() - parser.add_argument('--lldb', default='lldb') - parser.add_argument('--clrdir', default='.') - parser.add_argument('--workdir', default='.') - parser.add_argument('--assembly', default='Test.exe') - parser.add_argument('--timeout', default=90) - parser.add_argument('--regex', default='t_cmd_') - parser.add_argument('--repeat', default=1) - parser.add_argument('unittest_args', nargs='*') - - args = parser.parse_args() - - lldb = args.lldb - clrdir = args.clrdir - workdir = args.workdir - assembly = args.assembly - timeout = int(args.timeout) - regex = args.regex - repeat = int(args.repeat) - print("lldb: %s" % lldb) - print("clrdir: %s" % clrdir) - print("workdir: %s" % workdir) - print("assembly: %s" % assembly) - print("timeout: %i" % timeout) - print("regex: %s" % regex) - print("repeat: %i" % repeat) - - corerun = os.path.join(clrdir, 'corerun') - sosplugin = os.path.join(clrdir, 'libsosplugin.so') - if os.name != 'posix': - print('Not implemented: corerun.exe, sosplugin.dll?') - exit(1) - - print("corerun: %s" % corerun) - print("sosplugin: %s" % sosplugin) - - fail_flag = os.path.join(workdir, 'fail_flag') - fail_flag_lldb = os.path.join(workdir, 'fail_flag.lldb') - - print("fail_flag: %s" % fail_flag) - print("fail_flag_lldb: %s" % fail_flag_lldb) - - summary_file = os.path.join(workdir, 'summary') - print("summary_file: %s" % summary_file) - - try: - os.unlink(summary_file) - except: - pass - - sys.argv[1:] = args.unittest_args - suite = unittest.TestSuite() - all_tests = inspect.getmembers(TestSosCommands, predicate=inspect.ismethod) - for (test_name, test_func) in all_tests: - if re.match(regex, test_name): - suite.addTest(TestSosCommands(test_name)) - unittest.TextTestRunner(verbosity=1).run(suite) - - generate_report() diff --git a/src/ToolBox/SOS/tests/testutils.py b/src/ToolBox/SOS/tests/testutils.py deleted file mode 100644 index 80139aee4..000000000 --- a/src/ToolBox/SOS/tests/testutils.py +++ /dev/null @@ -1,210 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -from __future__ import print_function -import lldb -import re -import inspect -import sys -import os -import importlib - -summary_file = '' -fail_flag = '' - -failed = False - - -def assertCommon(passed, fatal): - global failed - with open(summary_file, 'a+') as summary: - print(bool(passed), file=summary) - if (not passed): - failed = True - print('!!! test failed:', file=summary) - for s in inspect.stack()[2:]: - print("!!! %s:%i" % (s[1], s[2]), file=summary) - print("!!! %s" % s[4][0], file=summary) - if re.match('\W*t_\w+\.py$', s[1]): - break - print('!!! ', file=summary) - - if fatal: - exit(1) - - -def assertTrue(x, fatal=True): - passed = bool(x) - assertCommon(passed, fatal) - - -def assertFalse(x, fatal=True): - passed = not bool(x) - assertCommon(passed, fatal) - - -def assertEqual(x, y, fatal=True): - passed = (x == y) - if not passed: - print(str(x), ' != ', str(y)) - assertCommon(passed, fatal) - - -def assertNotEqual(x, y, fatal=True): - passed = (x != y) - if not passed: - print(str(x), ' == ', str(y)) - assertCommon(passed, fatal) - - -def checkResult(res): - if not res.Succeeded(): - print(res.GetOutput()) - print(res.GetError()) - exit(1) - - -def is_hexnum(s): - try: - int(s, 16) - return True - except ValueError: - return False - - -def exec_and_find(commandInterpreter, cmd, regexp): - res = lldb.SBCommandReturnObject() - commandInterpreter.HandleCommand(cmd, res) - checkResult(res) - - expr = re.compile(regexp) - addr = None - - print(res.GetOutput()) - lines = res.GetOutput().splitlines() - for line in lines: - match = expr.match(line) - if match: - addr = match.group(1) - break - - print("Found addr: " + str(addr)) - return addr - - -def stop_in_main(debugger, assembly): - ci = debugger.GetCommandInterpreter() - target = debugger.GetSelectedTarget() - process = target.GetProcess() - res = lldb.SBCommandReturnObject() - - # Process must be stopped here while libcoreclr loading. - # This test usually fails on release version of coreclr - # since we depend on 'LoadLibraryExW' symbol present. - assertEqual(process.GetState(), lldb.eStateStopped) - - # The reason of this stop must be a breakpoint - assertEqual(process.GetSelectedThread().GetStopReason(), - lldb.eStopReasonBreakpoint) - - ci.HandleCommand("bpmd " + assembly + " Test.Main", res) - out_msg = res.GetOutput() - err_msg = res.GetError() - print(res.GetOutput()) - print(res.GetError()) - # Interpreter must have this command and able to run it - assertTrue(res.Succeeded()) - - # Output is not empty - # Should be at least 'Adding pending breakpoints...' - assertTrue(len(out_msg) > 0) - - # Error message is empty - assertTrue(len(err_msg) == 0) - - process.Continue() - # Process must be stopped here if bpmd works at all - assertEqual(process.GetState(), lldb.eStateStopped) - - # The reason of this stop must be a breakpoint - assertEqual(process.GetSelectedThread().GetStopReason(), - lldb.eStopReasonBreakpoint) - - -def exit_lldb(debugger, assembly): - ci = debugger.GetCommandInterpreter() - target = debugger.GetSelectedTarget() - process = target.GetProcess() - res = lldb.SBCommandReturnObject() - - ci.HandleCommand("breakpoint delete --force", res) - out_msg = res.GetOutput() - err_msg = res.GetError() - print(out_msg) - print(err_msg) - # Interpreter must have this command and able to run it - # assertTrue(res.Succeeded()) - - process.Continue() - # Process must exit - assertEqual(process.GetState(), lldb.eStateExited) - - # Process must exit with zero code - assertEqual(process.GetExitStatus(), 0) - - -def get_methoddesc(debugger, assembly, funcname): - ci = debugger.GetCommandInterpreter() - target = debugger.GetSelectedTarget() - process = target.GetProcess() - res = lldb.SBCommandReturnObject() - - ci.HandleCommand("name2ee %s %s" % (assembly, funcname), res) - print(res.GetOutput()) - print(res.GetError()) - # Interpreter must have this command and able to run it - assertTrue(res.Succeeded()) - - output = res.GetOutput() - # Output is not empty - assertTrue(len(output) > 0) - - match = re.search('MethodDesc:\s+([0-9a-fA-F]+)', output) - # Line matched - assertTrue(match) - - groups = match.groups() - # Match has a single subgroup - assertEqual(len(groups), 1) - - md_addr = groups[0] - # Address must be a hex number - assertTrue(is_hexnum(md_addr)) - - return md_addr - - -def run(assembly, module): - with open(summary_file, 'a+') as summary: - print('new_suite: %s' % module, file=summary) - - debugger = lldb.debugger - - debugger.SetAsync(False) - target = lldb.target - - debugger.HandleCommand("breakpoint set --one-shot --name coreclr_execute_assembly") - debugger.HandleCommand("process launch") - - # run the scenario - print("starting scenario...") - i = importlib.import_module(module) - scenarioResult = i.runScenario(os.path.basename(assembly), debugger, - target) - - if (target.GetProcess().GetExitStatus() == 0) and not failed: - os.unlink(fail_flag) - - with open(summary_file, 'a+') as summary: - print('Completed!', file=summary) diff --git a/src/gcinfo/CMakeLists.txt b/src/gcinfo/CMakeLists.txt deleted file mode 100644 index ab7e48dcf..000000000 --- a/src/gcinfo/CMakeLists.txt +++ /dev/null @@ -1,37 +0,0 @@ -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set( GCINFO_SOURCES - arraylist.cpp - gcinfoencoder.cpp -) - - -if(CLR_CMAKE_TARGET_ARCH_I386) - list(APPEND GCINFO_SOURCES - ../gcdump/gcdump.cpp - ../gcdump/${ARCH_SOURCES_DIR}/gcdumpx86.cpp - ) -endif(CLR_CMAKE_TARGET_ARCH_I386) - - -convert_to_absolute_path(GCINFO_SOURCES ${GCINFO_SOURCES}) - -if(CLR_CMAKE_PLATFORM_UNIX) - add_compile_options(-fPIC) -endif(CLR_CMAKE_PLATFORM_UNIX) - -add_subdirectory(lib) -add_subdirectory(crossgen) - -if (CLR_CMAKE_PLATFORM_ARCH_I386) - # On x86, build RyuJIT/ARM32 cross-compiling altjit. - add_subdirectory(gcinfo_arm) -endif () - -if (CLR_CMAKE_PLATFORM_ARCH_AMD64) - # On amd64, build RyuJIT/ARM64 cross-compiling altjit. - add_subdirectory(gcinfo_arm64) -endif () - -_install (FILES gcinfoencoder.cpp - DESTINATION gcinfo) diff --git a/src/gcinfo/arraylist.cpp b/src/gcinfo/arraylist.cpp deleted file mode 100644 index 566304c7a..000000000 --- a/src/gcinfo/arraylist.cpp +++ /dev/null @@ -1,104 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#include -#include -#include "debugmacros.h" -#include "iallocator.h" -#include "gcinfoarraylist.h" -#include "safemath.h" - -inline size_t roundUp(size_t size, size_t alignment) -{ - // `alignment` must be a power of two - assert(alignment != 0); - assert((alignment & (alignment - 1)) == 0); - - return (size + (alignment - 1)) & ~(alignment - 1); -} - -GcInfoArrayListBase::GcInfoArrayListBase(IAllocator* allocator) - : m_allocator(allocator), - m_firstChunk(nullptr), - m_lastChunk(nullptr), - m_lastChunkCount(0), - m_lastChunkCapacity(0), - m_itemCount(0) -{ - assert(m_allocator != nullptr); -} - -GcInfoArrayListBase::~GcInfoArrayListBase() -{ - for (ChunkBase* list = m_firstChunk, *chunk; list != nullptr; list = chunk) - { - chunk = list->m_next; - m_allocator->Free(list); - } -} - -void GcInfoArrayListBase::AppendNewChunk(size_t firstChunkCapacity, size_t elementSize, size_t chunkAlignment) -{ - size_t chunkCapacity = (m_firstChunk == nullptr) ? firstChunkCapacity : (m_lastChunkCapacity * GrowthFactor); - - S_SIZE_T chunkSize = S_SIZE_T(roundUp(sizeof(ChunkBase), chunkAlignment)) + (S_SIZE_T(elementSize) * S_SIZE_T(chunkCapacity)); - assert(!chunkSize.IsOverflow()); - - ChunkBase* chunk = reinterpret_cast(m_allocator->Alloc(chunkSize.Value())); - chunk->m_next = nullptr; - - if (m_lastChunk != nullptr) - { - assert(m_firstChunk != nullptr); - m_lastChunk->m_next = chunk; - } - else - { - assert(m_lastChunk == nullptr); - m_firstChunk = chunk; - } - - m_lastChunk = chunk; - m_lastChunkCount = 0; - m_lastChunkCapacity = chunkCapacity; -} - -GcInfoArrayListBase::IteratorBase::IteratorBase(GcInfoArrayListBase* list, size_t firstChunkCapacity) - : m_list(list) -{ - assert(m_list != nullptr); - - // Note: if the list is empty, m_list->firstChunk == nullptr == m_list->lastChunk and m_lastChunkCount == 0. - // In that case, the next two lines will set m_currentChunk to nullptr and m_currentChunkCount to 0. - m_currentChunk = m_list->m_firstChunk; - m_currentChunkCount = (m_currentChunk == m_list->m_lastChunk) ? m_list->m_lastChunkCount : firstChunkCapacity; -} - -GcInfoArrayListBase::ChunkBase* GcInfoArrayListBase::IteratorBase::GetNextChunk(size_t& elementCount) -{ - if (m_currentChunk == nullptr) - { - elementCount = 0; - return nullptr; - } - - ChunkBase* chunk = m_currentChunk; - elementCount = m_currentChunkCount; - - m_currentChunk = m_currentChunk->m_next; - if (m_currentChunk == nullptr) - { - m_currentChunkCount = 0; - } - else if (m_currentChunk == m_list->m_lastChunk) - { - m_currentChunkCount = m_list->m_lastChunkCount; - } - else - { - m_currentChunkCount *= GrowthFactor; - } - - return chunk; -} diff --git a/src/gcinfo/crossgen/CMakeLists.txt b/src/gcinfo/crossgen/CMakeLists.txt deleted file mode 100644 index 5e1652147..000000000 --- a/src/gcinfo/crossgen/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -include(${CLR_DIR}/crossgen.cmake) - -add_library_clr(gcinfo_crossgen - STATIC - ${GCINFO_SOURCES} -) diff --git a/src/gcinfo/gcinfo_arm/CMakeLists.txt b/src/gcinfo/gcinfo_arm/CMakeLists.txt deleted file mode 100644 index 3617c97f3..000000000 --- a/src/gcinfo/gcinfo_arm/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -remove_definitions(-D_TARGET_X86_=1) -add_definitions(-D_TARGET_ARM_) - -add_library_clr(gcinfo_arm - STATIC - ${GCINFO_SOURCES} -) diff --git a/src/gcinfo/gcinfo_arm64/CMakeLists.txt b/src/gcinfo/gcinfo_arm64/CMakeLists.txt deleted file mode 100644 index 116ed7c1d..000000000 --- a/src/gcinfo/gcinfo_arm64/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -remove_definitions(-D_TARGET_AMD64_=1) -add_definitions(-D_TARGET_ARM64_) - -add_library_clr(gcinfo_arm64 - STATIC - ${GCINFO_SOURCES} -) diff --git a/src/gcinfo/gcinfoencoder.cpp b/src/gcinfo/gcinfoencoder.cpp deleted file mode 100644 index 9e07d1b69..000000000 --- a/src/gcinfo/gcinfoencoder.cpp +++ /dev/null @@ -1,2725 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/***************************************************************************** - * - * GC Information Encoding API - * - */ - -#include - -#include "gcinfoencoder.h" - -#ifdef _DEBUG - #ifndef LOGGING - #define LOGGING - #endif -#endif - -#ifndef STANDALONE_BUILD -#include "log.h" -#include "simplerhash.h" -#include "bitposition.h" -#endif - -#ifdef MEASURE_GCINFO -#define GCINFO_WRITE(writer, val, numBits, counter) \ - { \ - writer.Write(val, numBits); \ - m_CurrentMethodSize.counter += numBits; \ - m_CurrentMethodSize.TotalSize += numBits; \ - } -#define GCINFO_WRITE_VARL_U(writer, val, base, counter) \ - { \ - size_t __temp = \ - writer.EncodeVarLengthUnsigned(val, base); \ - m_CurrentMethodSize.counter += __temp; \ - m_CurrentMethodSize.TotalSize += __temp; \ - } -#define GCINFO_WRITE_VARL_S(writer, val, base, counter) \ - { \ - size_t __temp = \ - writer.EncodeVarLengthSigned(val, base); \ - m_CurrentMethodSize.counter += __temp; \ - m_CurrentMethodSize.TotalSize += __temp; \ - } -#define GCINFO_WRITE_VECTOR(writer, vector, counter) \ - { \ - WriteSlotStateVector(writer, vector); \ - for(UINT32 i = 0; i < m_NumSlots; i++) \ - { \ - if(!m_SlotTable[i].IsDeleted() && \ - !m_SlotTable[i].IsUntracked()) \ - { \ - m_CurrentMethodSize.counter++; \ - m_CurrentMethodSize.TotalSize++; \ - } \ - } \ - } -#define GCINFO_WRITE_VAR_VECTOR(writer, vector, baseSkip, baseRun, counter) \ - { \ - size_t __temp = \ - WriteSlotStateVarLengthVector(writer, vector, baseSkip, baseRun); \ - m_CurrentMethodSize.counter += __temp; \ - m_CurrentMethodSize.TotalSize += __temp; \ - } -#else -#define GCINFO_WRITE(writer, val, numBits, counter) \ - writer.Write(val, numBits); - -#define GCINFO_WRITE_VARL_U(writer, val, base, counter) \ - writer.EncodeVarLengthUnsigned(val, base); - -#define GCINFO_WRITE_VARL_S(writer, val, base, counter) \ - writer.EncodeVarLengthSigned(val, base); - -#define GCINFO_WRITE_VECTOR(writer, vector, counter) \ - WriteSlotStateVector(writer, vector); - -#define GCINFO_WRITE_VAR_VECTOR(writer, vector, baseSkip, baseRun, counter) \ - WriteSlotStateVarLengthVector(writer, vector, baseSkip, baseRun); -#endif - -#define LOG_GCSLOTDESC_FMT "%s%c%d%s%s%s" -#define LOG_GCSLOTDESC_ARGS(pDesc) (pDesc)->IsRegister() ? "register" \ - : GcStackSlotBaseNames[(pDesc)->Slot.Stack.Base], \ - (pDesc)->IsRegister() ? ' ' : (pDesc)->Slot.Stack.SpOffset < 0 ? '-' : '+', \ - (pDesc)->IsRegister() ? (pDesc)->Slot.RegisterNumber \ - : ((pDesc)->Slot.Stack.SpOffset), \ - (pDesc)->IsPinned() ? " pinned" : "", \ - (pDesc)->IsInterior() ? " interior" : "", \ - (pDesc)->IsUntracked() ? " untracked" : "" - -#define LOG_REGTRANSITION_FMT "register %u%s%s" -#define LOG_REGTRANSITION_ARGS(RegisterNumber, Flags) \ - RegisterNumber, \ - (Flags & GC_SLOT_PINNED) ? " pinned" : "", \ - (Flags & GC_SLOT_INTERIOR) ? " interior" : "" - -#define LOG_STACKTRANSITION_FMT "%s%c%d%s%s%s" -#define LOG_STACKTRANSITION_ARGS(BaseRegister, StackOffset, Flags) \ - GcStackSlotBaseNames[BaseRegister], \ - ((StackOffset) < 0) ? '-' : '+', \ - ((StackOffset) >= 0) ? (StackOffset) \ - : -(StackOffset), \ - (Flags & GC_SLOT_PINNED) ? " pinned" : "", \ - (Flags & GC_SLOT_INTERIOR) ? " interior" : "", \ - (Flags & GC_SLOT_UNTRACKED) ? " untracked" : "" - -class BitArray -{ - friend class BitArrayIterator; -public: - BitArray(IAllocator* pJitAllocator, size_t size_tCount) - { - m_pData = (size_t*)pJitAllocator->Alloc(size_tCount*sizeof(size_t)); - m_pEndData = m_pData + size_tCount; -#ifdef MUST_CALL_IALLOCATOR_FREE - m_pJitAllocator = pJitAllocator; -#endif - } - - inline size_t* DataPtr() - { - return m_pData; - } - - inline void SetBit( size_t pos ) - { - size_t element = pos / BITS_PER_SIZE_T; - int bpos = (int)(pos % BITS_PER_SIZE_T); - m_pData[element] |= ((size_t)1 << bpos); - } - - inline void ClearBit( size_t pos ) - { - size_t element = pos / BITS_PER_SIZE_T; - int bpos = (int)(pos % BITS_PER_SIZE_T); - m_pData[element] &= ~((size_t)1 << bpos); - } - - inline void SetAll() - { - size_t* ptr = m_pData; - while(ptr < m_pEndData) - *(ptr++) = (size_t)(SSIZE_T)(-1); - } - - inline void ClearAll() - { - size_t* ptr = m_pData; - while(ptr < m_pEndData) - *(ptr++) = (size_t) 0; - } - - inline void WriteBit( size_t pos, BOOL val) - { - if(val) - SetBit(pos); - else - ClearBit(pos); - } - - inline size_t ReadBit( size_t pos ) const - { - size_t element = pos / BITS_PER_SIZE_T; - int bpos = (int)(pos % BITS_PER_SIZE_T); - return (m_pData[element] & ((size_t)1 << bpos)); - } - - inline bool operator==(const BitArray &other) const - { - _ASSERTE(other.m_pEndData - other.m_pData == m_pEndData - m_pData); - size_t* dest = m_pData; - size_t* src = other.m_pData; - return 0 == memcmp(dest, src, (m_pEndData - m_pData) * sizeof(*m_pData)); - } - - inline int GetHashCode() const - { - const int* src = (const int*)m_pData; - int result = *src++; - while(src < (const int*)m_pEndData) - result = _rotr(result, 5) ^ *src++; - - return result; - } - - inline BitArray& operator=(const BitArray &other) - { - _ASSERTE(other.m_pEndData - other.m_pData == m_pEndData - m_pData); - size_t* dest = m_pData; - size_t* src = other.m_pData; - while(dest < m_pEndData) - *(dest++) = *(src++); - - return *this; - } - - inline BitArray& operator|=(const BitArray &other) - { - _ASSERTE(other.m_pEndData - other.m_pData == m_pEndData - m_pData); - size_t* dest = m_pData; - size_t* src = other.m_pData; - while(dest < m_pEndData) - *(dest++) |= *(src++); - - return *this; - } - -#ifdef MUST_CALL_IALLOCATOR_FREE - ~BitArray() - { - m_pAllocator->Free( m_pData ); - } -#endif - - static void* operator new(size_t size, IAllocator* allocator) - { - return allocator->Alloc(size); - } - -private: - size_t * m_pData; - size_t * m_pEndData; -#ifdef MUST_CALL_IALLOCATOR_FREE - IAllocator* m_pJitAllocator; -#endif -}; - - -class BitArrayIterator -{ -public: - BitArrayIterator(BitArray* bitArray) - { - m_pCurData = (unsigned *)bitArray->m_pData; - m_pEndData = (unsigned *)bitArray->m_pEndData; - m_curBits = *m_pCurData; - m_curBit = 0; - m_curBase = 0; - GetNext(); - } - void operator++(int dummy) //int dummy is c++ for "this is postfix ++" - { - GetNext(); - } - - void operator++() // prefix ++ - { - GetNext(); - } - void GetNext() - { - m_curBits -= m_curBit; - while (m_curBits == 0) - { - m_pCurData++; - m_curBase += 32; - if (m_pCurData == m_pEndData) - break; - m_curBits = *m_pCurData; - } - m_curBit = (unsigned)((int)m_curBits & -(int)m_curBits); - } - unsigned operator*() - { - assert(!end() && (m_curBit != 0)); - unsigned bitPosition = BitPosition(m_curBit); - return bitPosition + m_curBase; - } - bool end() - { - return (m_pCurData == m_pEndData); - } -private: - unsigned* m_pCurData; - unsigned* m_pEndData; - unsigned m_curBits; - unsigned m_curBit; - unsigned m_curBase; -}; - -class LiveStateFuncs -{ -public: - static int GetHashCode(const BitArray * key) - { - return key->GetHashCode(); - } - - static bool Equals(const BitArray * k1, const BitArray * k2) - { - return *k1 == *k2; - } -}; - -class GcInfoNoMemoryException -{ -}; - -class GcInfoHashBehavior -{ -public: - static const unsigned s_growth_factor_numerator = 3; - static const unsigned s_growth_factor_denominator = 2; - - static const unsigned s_density_factor_numerator = 3; - static const unsigned s_density_factor_denominator = 4; - - static const unsigned s_minimum_allocation = 7; - - inline static void DECLSPEC_NORETURN NoMemory() - { - throw GcInfoNoMemoryException(); - } -}; - -typedef SimplerHashTable LiveStateHashTable; - -#ifdef MEASURE_GCINFO -// Fi = fully-interruptible; we count any method that has one or more interruptible ranges -// Pi = partially-interruptible; methods with zero fully-interruptible ranges -GcInfoSize g_FiGcInfoSize; -GcInfoSize g_PiGcInfoSize; -// Number of methods with GcInfo that have SlimHeader -size_t g_NumSlimHeaders = 0; -// Number of methods with GcInfo that have FatHeader -size_t g_NumFatHeaders = 0; - -GcInfoSize::GcInfoSize() -{ - memset(this, 0, sizeof(*this)); -} - -GcInfoSize& GcInfoSize::operator+=(const GcInfoSize& other) -{ - TotalSize += other.TotalSize; - - NumMethods += other.NumMethods; - NumCallSites += other.NumCallSites; - NumRanges += other.NumRanges; - NumRegs += other.NumRegs; - NumStack += other.NumStack; - NumUntracked += other.NumUntracked; - NumTransitions += other.NumTransitions; - SizeOfCode += other.SizeOfCode; - EncPreservedSlots += other.EncPreservedSlots; - - UntrackedSlotSize += other.UntrackedSlotSize; - NumUntrackedSize += other.NumUntrackedSize; - FlagsSize += other.FlagsSize; - CodeLengthSize += other.CodeLengthSize; - ProEpilogSize += other.ProEpilogSize; - SecObjSize += other.SecObjSize; - GsCookieSize += other.GsCookieSize; - GenericsCtxSize += other.GenericsCtxSize; - PspSymSize += other.PspSymSize; - StackBaseSize += other.StackBaseSize; - ReversePInvokeFrameSize += other.ReversePInvokeFrameSize; - FixedAreaSize += other.FixedAreaSize; - NumCallSitesSize += other.NumCallSitesSize; - NumRangesSize += other.NumRangesSize; - CallSitePosSize += other.CallSitePosSize; - RangeSize += other.RangeSize; - NumRegsSize += other.NumRegsSize; - NumStackSize += other.NumStackSize; - RegSlotSize += other.RegSlotSize; - StackSlotSize += other.StackSlotSize; - CallSiteStateSize += other.CallSiteStateSize; - EhPosSize += other.EhPosSize; - EhStateSize += other.EhStateSize; - ChunkPtrSize += other.ChunkPtrSize; - ChunkMaskSize += other.ChunkMaskSize; - ChunkFinalStateSize += other.ChunkFinalStateSize; - ChunkTransitionSize += other.ChunkTransitionSize; - - return *this; -} - -void GcInfoSize::Log(DWORD level, const char * header) -{ - if(LoggingOn(LF_GCINFO, level)) - { - LogSpew(LF_GCINFO, level, header); - - LogSpew(LF_GCINFO, level, "---COUNTS---\n"); - LogSpew(LF_GCINFO, level, "NumMethods: %Iu\n", NumMethods); - LogSpew(LF_GCINFO, level, "NumCallSites: %Iu\n", NumCallSites); - LogSpew(LF_GCINFO, level, "NumRanges: %Iu\n", NumRanges); - LogSpew(LF_GCINFO, level, "NumRegs: %Iu\n", NumRegs); - LogSpew(LF_GCINFO, level, "NumStack: %Iu\n", NumStack); - LogSpew(LF_GCINFO, level, "NumUntracked: %Iu\n", NumUntracked); - LogSpew(LF_GCINFO, level, "NumTransitions: %Iu\n", NumTransitions); - LogSpew(LF_GCINFO, level, "SizeOfCode: %Iu\n", SizeOfCode); - LogSpew(LF_GCINFO, level, "EncPreservedSlots: %Iu\n", EncPreservedSlots); - - LogSpew(LF_GCINFO, level, "---SIZES(bits)---\n"); - LogSpew(LF_GCINFO, level, "Total: %Iu\n", TotalSize); - LogSpew(LF_GCINFO, level, "UntrackedSlot: %Iu\n", UntrackedSlotSize); - LogSpew(LF_GCINFO, level, "NumUntracked: %Iu\n", NumUntrackedSize); - LogSpew(LF_GCINFO, level, "Flags: %Iu\n", FlagsSize); - LogSpew(LF_GCINFO, level, "CodeLength: %Iu\n", CodeLengthSize); - LogSpew(LF_GCINFO, level, "Prolog/Epilog: %Iu\n", ProEpilogSize); - LogSpew(LF_GCINFO, level, "SecObj: %Iu\n", SecObjSize); - LogSpew(LF_GCINFO, level, "GsCookie: %Iu\n", GsCookieSize); - LogSpew(LF_GCINFO, level, "PspSym: %Iu\n", PspSymSize); - LogSpew(LF_GCINFO, level, "GenericsCtx: %Iu\n", GenericsCtxSize); - LogSpew(LF_GCINFO, level, "StackBase: %Iu\n", StackBaseSize); - LogSpew(LF_GCINFO, level, "FixedArea: %Iu\n", FixedAreaSize); - LogSpew(LF_GCINFO, level, "ReversePInvokeFrame: %Iu\n", ReversePInvokeFrameSize); - LogSpew(LF_GCINFO, level, "NumCallSites: %Iu\n", NumCallSitesSize); - LogSpew(LF_GCINFO, level, "NumRanges: %Iu\n", NumRangesSize); - LogSpew(LF_GCINFO, level, "CallSiteOffsets: %Iu\n", CallSitePosSize); - LogSpew(LF_GCINFO, level, "Ranges: %Iu\n", RangeSize); - LogSpew(LF_GCINFO, level, "NumRegs: %Iu\n", NumRegsSize); - LogSpew(LF_GCINFO, level, "NumStack: %Iu\n", NumStackSize); - LogSpew(LF_GCINFO, level, "RegSlots: %Iu\n", RegSlotSize); - LogSpew(LF_GCINFO, level, "StackSlots: %Iu\n", StackSlotSize); - LogSpew(LF_GCINFO, level, "CallSiteStates: %Iu\n", CallSiteStateSize); - LogSpew(LF_GCINFO, level, "EhOffsets: %Iu\n", EhPosSize); - LogSpew(LF_GCINFO, level, "EhStates: %Iu\n", EhStateSize); - LogSpew(LF_GCINFO, level, "ChunkPointers: %Iu\n", ChunkPtrSize); - LogSpew(LF_GCINFO, level, "ChunkMasks: %Iu\n", ChunkMaskSize); - LogSpew(LF_GCINFO, level, "ChunkFinalStates: %Iu\n", ChunkFinalStateSize); - LogSpew(LF_GCINFO, level, "Transitions: %Iu\n", ChunkTransitionSize); - } -} - -#endif - -GcInfoEncoder::GcInfoEncoder( - ICorJitInfo* pCorJitInfo, - CORINFO_METHOD_INFO* pMethodInfo, - IAllocator* pJitAllocator, - NoMemoryFunction pNoMem - ) - : m_Info1( pJitAllocator ), - m_Info2( pJitAllocator ), - m_InterruptibleRanges( pJitAllocator ), - m_LifetimeTransitions( pJitAllocator ) -{ -#ifdef MEASURE_GCINFO - // This causes multiple complus.log files in JIT64. TODO: consider using ICorJitInfo::logMsg instead. - InitializeLogging(); -#endif - - _ASSERTE( pCorJitInfo != NULL ); - _ASSERTE( pMethodInfo != NULL ); - _ASSERTE( pJitAllocator != NULL ); - _ASSERTE( pNoMem != NULL ); - - m_pCorJitInfo = pCorJitInfo; - m_pMethodInfo = pMethodInfo; - m_pAllocator = pJitAllocator; - m_pNoMem = pNoMem; - -#ifdef _DEBUG - CORINFO_METHOD_HANDLE methodHandle = pMethodInfo->ftn; - - // Get the name of the current method along with the enclosing class - // or module name. - m_MethodName = - pCorJitInfo->getMethodName(methodHandle, (const char **)&m_ModuleName); -#endif - - - m_SlotTableSize = m_SlotTableInitialSize; - m_SlotTable = (GcSlotDesc*) m_pAllocator->Alloc( m_SlotTableSize*sizeof(GcSlotDesc) ); - m_NumSlots = 0; -#ifdef PARTIALLY_INTERRUPTIBLE_GC_SUPPORTED - m_pCallSites = NULL; - m_pCallSiteSizes = NULL; - m_NumCallSites = 0; -#endif - - m_SecurityObjectStackSlot = NO_SECURITY_OBJECT; - m_GSCookieStackSlot = NO_GS_COOKIE; - m_GSCookieValidRangeStart = 0; - _ASSERTE(sizeof(m_GSCookieValidRangeEnd) == sizeof(UINT32)); - m_GSCookieValidRangeEnd = (UINT32) (-1); // == UINT32.MaxValue - m_PSPSymStackSlot = NO_PSP_SYM; - m_GenericsInstContextStackSlot = NO_GENERICS_INST_CONTEXT; - m_contextParamType = GENERIC_CONTEXTPARAM_NONE; - - m_StackBaseRegister = NO_STACK_BASE_REGISTER; - m_SizeOfEditAndContinuePreservedArea = NO_SIZE_OF_EDIT_AND_CONTINUE_PRESERVED_AREA; - m_ReversePInvokeFrameSlot = NO_REVERSE_PINVOKE_FRAME; -#ifdef _TARGET_AMD64_ - m_WantsReportOnlyLeaf = false; -#elif defined(_TARGET_ARM_) || defined(_TARGET_ARM64_) - m_HasTailCalls = false; -#endif // _TARGET_AMD64_ - m_IsVarArg = false; - m_pLastInterruptibleRange = NULL; - -#ifdef _DEBUG - m_IsSlotTableFrozen = FALSE; -#endif //_DEBUG - -#ifndef _TARGET_X86_ - // If the compiler doesn't set the GCInfo, report RT_Unset. - // This is used for compatibility with JITs that aren't updated to use the new API. - m_ReturnKind = RT_Unset; -#else - m_ReturnKind = RT_Illegal; -#endif // _TARGET_X86_ - m_CodeLength = 0; -#ifdef FIXED_STACK_PARAMETER_SCRATCH_AREA - m_SizeOfStackOutgoingAndScratchArea = -1; -#endif // FIXED_STACK_PARAMETER_SCRATCH_AREA - -} - -#ifdef PARTIALLY_INTERRUPTIBLE_GC_SUPPORTED -void GcInfoEncoder::DefineCallSites(UINT32* pCallSites, BYTE* pCallSiteSizes, UINT32 numCallSites) -{ - m_pCallSites = pCallSites; - m_pCallSiteSizes = pCallSiteSizes; - m_NumCallSites = numCallSites; -#ifdef _DEBUG - for(UINT32 i=0; i 0); - _ASSERTE(DENORMALIZE_CODE_OFFSET(NORMALIZE_CODE_OFFSET(pCallSites[i])) == pCallSites[i]); - if(i > 0) - { - UINT32 prevEnd = pCallSites[i-1] + pCallSiteSizes[i-1]; - UINT32 curStart = pCallSites[i]; - _ASSERTE(curStart >= prevEnd); - } - } -#endif -} -#endif - -GcSlotId GcInfoEncoder::GetRegisterSlotId( UINT32 regNum, GcSlotFlags flags ) -{ - // We could lookup an existing identical slot in the slot table (via some hashtable mechanism). - // We just create duplicates for now. - -#ifdef _DEBUG - _ASSERTE( !m_IsSlotTableFrozen ); -#endif - - if( m_NumSlots == m_SlotTableSize ) - { - GrowSlotTable(); - } - _ASSERTE( m_NumSlots < m_SlotTableSize ); - - _ASSERTE( (flags & (GC_SLOT_IS_REGISTER | GC_SLOT_IS_DELETED | GC_SLOT_UNTRACKED)) == 0 ); - m_SlotTable[ m_NumSlots ].Slot.RegisterNumber = regNum; - m_SlotTable[ m_NumSlots ].Flags = (GcSlotFlags) (flags | GC_SLOT_IS_REGISTER); - - GcSlotId newSlotId; - newSlotId = m_NumSlots++; - - return newSlotId; -} - -GcSlotId GcInfoEncoder::GetStackSlotId( INT32 spOffset, GcSlotFlags flags, GcStackSlotBase spBase ) -{ - // We could lookup an existing identical slot in the slot table (via some hashtable mechanism). - // We just create duplicates for now. - -#ifdef _DEBUG - _ASSERTE( !m_IsSlotTableFrozen ); -#endif - - if( m_NumSlots == m_SlotTableSize ) - { - GrowSlotTable(); - } - _ASSERTE( m_NumSlots < m_SlotTableSize ); - - // Not valid to reference anything below the current stack pointer - _ASSERTE(GC_SP_REL != spBase || spOffset >= 0); - - _ASSERTE( (flags & (GC_SLOT_IS_REGISTER | GC_SLOT_IS_DELETED)) == 0 ); - - // the spOffset for the stack slot is required to be pointer size aligned - _ASSERTE((spOffset % TARGET_POINTER_SIZE) == 0); - - m_SlotTable[ m_NumSlots ].Slot.Stack.SpOffset = spOffset; - m_SlotTable[ m_NumSlots ].Slot.Stack.Base = spBase; - m_SlotTable[ m_NumSlots ].Flags = flags; - - GcSlotId newSlotId; - newSlotId = m_NumSlots++; - - return newSlotId; -} - -void GcInfoEncoder::GrowSlotTable() -{ - m_SlotTableSize *= 2; - GcSlotDesc* newSlotTable = (GcSlotDesc*) m_pAllocator->Alloc( m_SlotTableSize * sizeof(GcSlotDesc) ); - memcpy( newSlotTable, m_SlotTable, m_NumSlots * sizeof(GcSlotDesc) ); - -#ifdef MUST_CALL_JITALLOCATOR_FREE - m_pAllocator->Free( m_SlotTable ); -#endif - - m_SlotTable = newSlotTable; -} - -void GcInfoEncoder::WriteSlotStateVector(BitStreamWriter &writer, const BitArray& vector) -{ - for(UINT32 i = 0; i < m_NumSlots && !m_SlotTable[i].IsUntracked(); i++) - { - if(!m_SlotTable[i].IsDeleted()) - writer.Write(vector.ReadBit(i) ? 1 : 0, 1); - else - _ASSERTE(vector.ReadBit(i) == 0); - } -} - -void GcInfoEncoder::DefineInterruptibleRange( UINT32 startInstructionOffset, UINT32 length ) -{ - UINT32 stopInstructionOffset = startInstructionOffset + length; - - UINT32 normStartOffset = NORMALIZE_CODE_OFFSET(startInstructionOffset); - UINT32 normStopOffset = NORMALIZE_CODE_OFFSET(stopInstructionOffset); - - // Ranges must not overlap and must be passed sorted by increasing offset - _ASSERTE( - m_pLastInterruptibleRange == NULL || - normStartOffset >= m_pLastInterruptibleRange->NormStopOffset - ); - - // Ignore empty ranges - if(normStopOffset > normStartOffset) - { - if(m_pLastInterruptibleRange - && normStartOffset == m_pLastInterruptibleRange->NormStopOffset) - { - // Merge adjacent ranges - m_pLastInterruptibleRange->NormStopOffset = normStopOffset; - } - else - { - InterruptibleRange range; - range.NormStartOffset = normStartOffset; - range.NormStopOffset = normStopOffset; - m_pLastInterruptibleRange = m_InterruptibleRanges.Append(); - *m_pLastInterruptibleRange = range; - } - } - - LOG((LF_GCINFO, LL_INFO1000000, "interruptible at %x length %x\n", startInstructionOffset, length)); -} - - - -// -// For inputs, pass zero as offset -// -void GcInfoEncoder::SetSlotState( - UINT32 instructionOffset, - GcSlotId slotId, - GcSlotState slotState - ) -{ - _ASSERTE( (m_SlotTable[ slotId ].Flags & GC_SLOT_UNTRACKED) == 0 ); - - LifetimeTransition transition; - - transition.SlotId = slotId; - transition.CodeOffset = instructionOffset; - transition.BecomesLive = ( slotState == GC_SLOT_LIVE ); - transition.IsDeleted = FALSE; - - *( m_LifetimeTransitions.Append() ) = transition; - - LOG((LF_GCINFO, LL_INFO1000000, LOG_GCSLOTDESC_FMT " %s at %x\n", LOG_GCSLOTDESC_ARGS(&m_SlotTable[slotId]), slotState == GC_SLOT_LIVE ? "live" : "dead", instructionOffset)); -} - - -void GcInfoEncoder::SetIsVarArg() -{ - m_IsVarArg = true; -} - -void GcInfoEncoder::SetCodeLength( UINT32 length ) -{ - _ASSERTE( length > 0 ); - _ASSERTE( m_CodeLength == 0 || m_CodeLength == length ); - m_CodeLength = length; -} - - -void GcInfoEncoder::SetSecurityObjectStackSlot( INT32 spOffset ) -{ - _ASSERTE( spOffset != NO_SECURITY_OBJECT ); -#if defined(_TARGET_AMD64_) - _ASSERTE( spOffset < 0x10 && "The security object cannot reside in an input variable!" ); -#endif - _ASSERTE( m_SecurityObjectStackSlot == NO_SECURITY_OBJECT || m_SecurityObjectStackSlot == spOffset ); - - m_SecurityObjectStackSlot = spOffset; -} - -void GcInfoEncoder::SetPrologSize( UINT32 prologSize ) -{ - _ASSERTE(prologSize != 0); - _ASSERTE(m_GSCookieValidRangeStart == 0 || m_GSCookieValidRangeStart == prologSize); - _ASSERTE(m_GSCookieValidRangeEnd == (UINT32)(-1) || m_GSCookieValidRangeEnd == prologSize+1); - - m_GSCookieValidRangeStart = prologSize; - // satisfy asserts that assume m_GSCookieValidRangeStart != 0 ==> m_GSCookieValidRangeStart < m_GSCookieValidRangeEnd - m_GSCookieValidRangeEnd = prologSize+1; -} - -void GcInfoEncoder::SetGSCookieStackSlot( INT32 spOffsetGSCookie, UINT32 validRangeStart, UINT32 validRangeEnd ) -{ - _ASSERTE( spOffsetGSCookie != NO_GS_COOKIE ); - _ASSERTE( m_GSCookieStackSlot == NO_GS_COOKIE || m_GSCookieStackSlot == spOffsetGSCookie ); - _ASSERTE( validRangeStart < validRangeEnd ); - - m_GSCookieStackSlot = spOffsetGSCookie; - m_GSCookieValidRangeStart = validRangeStart; - m_GSCookieValidRangeEnd = validRangeEnd; -} - -void GcInfoEncoder::SetPSPSymStackSlot( INT32 spOffsetPSPSym ) -{ - _ASSERTE( spOffsetPSPSym != NO_PSP_SYM ); - _ASSERTE( m_PSPSymStackSlot == NO_PSP_SYM || m_PSPSymStackSlot == spOffsetPSPSym ); - - m_PSPSymStackSlot = spOffsetPSPSym; -} - -void GcInfoEncoder::SetGenericsInstContextStackSlot( INT32 spOffsetGenericsContext, GENERIC_CONTEXTPARAM_TYPE type) -{ - _ASSERTE( spOffsetGenericsContext != NO_GENERICS_INST_CONTEXT); - _ASSERTE( m_GenericsInstContextStackSlot == NO_GENERICS_INST_CONTEXT || m_GenericsInstContextStackSlot == spOffsetGenericsContext ); - - m_GenericsInstContextStackSlot = spOffsetGenericsContext; - m_contextParamType = type; -} - -void GcInfoEncoder::SetStackBaseRegister( UINT32 regNum ) -{ - _ASSERTE( regNum != NO_STACK_BASE_REGISTER ); - _ASSERTE(DENORMALIZE_STACK_BASE_REGISTER(NORMALIZE_STACK_BASE_REGISTER(regNum)) == regNum); - _ASSERTE( m_StackBaseRegister == NO_STACK_BASE_REGISTER || m_StackBaseRegister == regNum ); - m_StackBaseRegister = regNum; -} - -void GcInfoEncoder::SetSizeOfEditAndContinuePreservedArea( UINT32 slots ) -{ - _ASSERTE( slots != NO_SIZE_OF_EDIT_AND_CONTINUE_PRESERVED_AREA ); - _ASSERTE( m_SizeOfEditAndContinuePreservedArea == NO_SIZE_OF_EDIT_AND_CONTINUE_PRESERVED_AREA ); - m_SizeOfEditAndContinuePreservedArea = slots; -} - -#ifdef _TARGET_AMD64_ -void GcInfoEncoder::SetWantsReportOnlyLeaf() -{ - m_WantsReportOnlyLeaf = true; -} -#elif defined(_TARGET_ARM_) || defined(_TARGET_ARM64_) -void GcInfoEncoder::SetHasTailCalls() -{ - m_HasTailCalls = true; -} -#endif // _TARGET_AMD64_ - -#ifdef FIXED_STACK_PARAMETER_SCRATCH_AREA -void GcInfoEncoder::SetSizeOfStackOutgoingAndScratchArea( UINT32 size ) -{ - _ASSERTE( size != (UINT32)-1 ); - _ASSERTE( m_SizeOfStackOutgoingAndScratchArea == (UINT32)-1 || m_SizeOfStackOutgoingAndScratchArea == size ); - m_SizeOfStackOutgoingAndScratchArea = size; -} -#endif // FIXED_STACK_PARAMETER_SCRATCH_AREA - -void GcInfoEncoder::SetReversePInvokeFrameSlot(INT32 spOffset) -{ - m_ReversePInvokeFrameSlot = spOffset; -} - -void GcInfoEncoder::SetReturnKind(ReturnKind returnKind) -{ - _ASSERTE(IsValidReturnKind(returnKind)); - - m_ReturnKind = returnKind; -} - -struct GcSlotDescAndId -{ - GcSlotDesc m_SlotDesc; - UINT32 m_SlotId; -}; - -int __cdecl CompareSlotDescAndIdBySlotDesc(const void* p1, const void* p2) -{ - const GcSlotDesc* pFirst = &reinterpret_cast(p1)->m_SlotDesc; - const GcSlotDesc* pSecond = &reinterpret_cast(p2)->m_SlotDesc; - - int firstFlags = pFirst->Flags ^ GC_SLOT_UNTRACKED; - int secondFlags = pSecond->Flags ^ GC_SLOT_UNTRACKED; - - // All registers come before all stack slots - // All untracked come last - // Then sort them by flags, ensuring that the least-frequent interior/pinned flag combinations are first - // This is accomplished in the comparison of flags, since we encode IsRegister in the highest flag bit - // And we XOR the UNTRACKED flag to place them last in the second highest flag bit - if( firstFlags > secondFlags ) return -1; - if( firstFlags < secondFlags ) return 1; - - // Then sort them by slot - if( pFirst->IsRegister() ) - { - _ASSERTE( pSecond->IsRegister() ); - if( pFirst->Slot.RegisterNumber < pSecond->Slot.RegisterNumber ) return -1; - if( pFirst->Slot.RegisterNumber > pSecond->Slot.RegisterNumber ) return 1; - } - else - { - _ASSERTE( !pSecond->IsRegister() ); - if( pFirst->Slot.Stack.SpOffset < pSecond->Slot.Stack.SpOffset ) return -1; - if( pFirst->Slot.Stack.SpOffset > pSecond->Slot.Stack.SpOffset ) return 1; - - // This is arbitrary, but we want to make sure they are considered separate slots - if( pFirst->Slot.Stack.Base < pSecond->Slot.Stack.Base ) return -1; - if( pFirst->Slot.Stack.Base > pSecond->Slot.Stack.Base ) return 1; - } - - // If we get here, the slots are identical - _ASSERTE(!"Duplicate slots definitions found in GC information!"); - return 0; -} - - -int __cdecl CompareLifetimeTransitionsByOffsetThenSlot(const void* p1, const void* p2) -{ - const GcInfoEncoder::LifetimeTransition* pFirst = (const GcInfoEncoder::LifetimeTransition*) p1; - const GcInfoEncoder::LifetimeTransition* pSecond = (const GcInfoEncoder::LifetimeTransition*) p2; - - UINT32 firstOffset = pFirst->CodeOffset; - UINT32 secondOffset = pSecond->CodeOffset; - - if (firstOffset == secondOffset) - { - return pFirst->SlotId - pSecond->SlotId; - } - else - { - return firstOffset - secondOffset; - } -} - - -int __cdecl CompareLifetimeTransitionsBySlot(const void* p1, const void* p2) -{ - const GcInfoEncoder::LifetimeTransition* pFirst = (const GcInfoEncoder::LifetimeTransition*) p1; - const GcInfoEncoder::LifetimeTransition* pSecond = (const GcInfoEncoder::LifetimeTransition*) p2; - - UINT32 firstOffset = pFirst->CodeOffset; - UINT32 secondOffset = pSecond->CodeOffset; - - _ASSERTE(GetNormCodeOffsetChunk(firstOffset) == GetNormCodeOffsetChunk(secondOffset)); - - // Sort them by slot - if( pFirst->SlotId < pSecond->SlotId ) return -1; - if( pFirst->SlotId > pSecond->SlotId ) return 1; - - // Then sort them by code offset - if( firstOffset < secondOffset ) - return -1; - else - { - _ASSERTE(( firstOffset > secondOffset ) && "Redundant transitions found in GC info!"); - return 1; - } -} - -BitStreamWriter::MemoryBlockList::MemoryBlockList() - : m_head(nullptr), - m_tail(nullptr) -{ -} - -BitStreamWriter::MemoryBlock* BitStreamWriter::MemoryBlockList::AppendNew(IAllocator* allocator, size_t bytes) -{ - auto* memBlock = reinterpret_cast(allocator->Alloc(sizeof(MemoryBlock) + bytes)); - memBlock->m_next = nullptr; - - if (m_tail != nullptr) - { - _ASSERTE(m_head != nullptr); - m_tail->m_next = memBlock; - } - else - { - _ASSERTE(m_head == nullptr); - m_head = memBlock; - } - - m_tail = memBlock; - return memBlock; -} - -void BitStreamWriter::MemoryBlockList::Dispose(IAllocator* allocator) -{ -#ifdef MUST_CALL_JITALLOCATOR_FREE - for (MemoryBlock* block = m_head, *next; block != nullptr; block = next) - { - next = block->m_next; - allocator->Free(block); - } - m_head = nullptr; - m_tail = nullptr; -#endif -} - -void BitStreamWriter::Write(BitArray& a, UINT32 count) -{ - size_t* dataPtr = a.DataPtr(); - for(;;) - { - if(count <= BITS_PER_SIZE_T) - { - Write(*dataPtr, count); - break; - } - Write(*(dataPtr++), BITS_PER_SIZE_T); - count -= BITS_PER_SIZE_T; - } -} - -void GcInfoEncoder::FinalizeSlotIds() -{ -#ifdef _DEBUG - m_IsSlotTableFrozen = TRUE; -#endif -} - -bool GcInfoEncoder::IsAlwaysScratch(GcSlotDesc &slotDesc) -{ -#if defined(_TARGET_ARM_) - - _ASSERTE( m_SizeOfStackOutgoingAndScratchArea != (UINT32)-1 ); - if(slotDesc.IsRegister()) - { - int regNum = (int) slotDesc.Slot.RegisterNumber; - _ASSERTE(regNum >= 0 && regNum <= 14); - _ASSERTE(regNum != 13); // sp - - return ((regNum <= 3) || (regNum >= 12)); // R12 and R14/LR are both scratch registers - } - else if (!slotDesc.IsUntracked() && (slotDesc.Slot.Stack.Base == GC_SP_REL) && - ((UINT32)slotDesc.Slot.Stack.SpOffset < m_SizeOfStackOutgoingAndScratchArea)) - { - return TRUE; - } - else - return FALSE; - -#elif defined(_TARGET_AMD64_) - - _ASSERTE( m_SizeOfStackOutgoingAndScratchArea != (UINT32)-1 ); - if(slotDesc.IsRegister()) - { - int regNum = (int) slotDesc.Slot.RegisterNumber; - _ASSERTE(regNum >= 0 && regNum <= 16); - _ASSERTE(regNum != 4); // rsp - - UINT16 PreservedRegMask = - (1 << 3) // rbx - | (1 << 5) // rbp -#ifndef UNIX_AMD64_ABI - | (1 << 6) // rsi - | (1 << 7) // rdi -#endif // UNIX_AMD64_ABI - | (1 << 12) // r12 - | (1 << 13) // r13 - | (1 << 14) // r14 - | (1 << 15); // r15 - - return !(PreservedRegMask & (1 << regNum)); - } - else if (!slotDesc.IsUntracked() && (slotDesc.Slot.Stack.Base == GC_SP_REL) && - ((UINT32)slotDesc.Slot.Stack.SpOffset < m_SizeOfStackOutgoingAndScratchArea)) - { - return TRUE; - } - else - return FALSE; - -#else - return FALSE; -#endif -} - -void GcInfoEncoder::Build() -{ -#ifdef _DEBUG - _ASSERTE(m_IsSlotTableFrozen || m_NumSlots == 0); -#endif - - _ASSERTE((1 << NUM_NORM_CODE_OFFSETS_PER_CHUNK_LOG2) == NUM_NORM_CODE_OFFSETS_PER_CHUNK); - - LOG((LF_GCINFO, LL_INFO100, - "Entering GcInfoEncoder::Build() for method %s[%s]\n", - m_MethodName, m_ModuleName - )); - - - /////////////////////////////////////////////////////////////////////// - // Method header - /////////////////////////////////////////////////////////////////////// - - - UINT32 hasSecurityObject = (m_SecurityObjectStackSlot != NO_SECURITY_OBJECT); - UINT32 hasGSCookie = (m_GSCookieStackSlot != NO_GS_COOKIE); - UINT32 hasContextParamType = (m_GenericsInstContextStackSlot != NO_GENERICS_INST_CONTEXT); - UINT32 hasReversePInvokeFrame = (m_ReversePInvokeFrameSlot != NO_REVERSE_PINVOKE_FRAME); - - BOOL slimHeader = (!m_IsVarArg && !hasSecurityObject && !hasGSCookie && (m_PSPSymStackSlot == NO_PSP_SYM) && - !hasContextParamType && (m_InterruptibleRanges.Count() == 0) && !hasReversePInvokeFrame && - ((m_StackBaseRegister == NO_STACK_BASE_REGISTER) || (NORMALIZE_STACK_BASE_REGISTER(m_StackBaseRegister) == 0))) && - (m_SizeOfEditAndContinuePreservedArea == NO_SIZE_OF_EDIT_AND_CONTINUE_PRESERVED_AREA) && -#ifdef _TARGET_AMD64_ - !m_WantsReportOnlyLeaf && -#elif defined(_TARGET_ARM_) || defined(_TARGET_ARM64_) - !m_HasTailCalls && -#endif // _TARGET_AMD64_ - !IsStructReturnKind(m_ReturnKind); - - // All new code is generated for the latest GCINFO_VERSION. - // So, always encode RetunrKind and encode ReversePInvokeFrameSlot where applicable. - if (slimHeader) - { - // Slim encoding means nothing special, partially interruptible, maybe a default frame register - GCINFO_WRITE(m_Info1, 0, 1, FlagsSize); // Slim encoding - GCINFO_WRITE(m_Info1, (m_StackBaseRegister == NO_STACK_BASE_REGISTER) ? 0 : 1, 1, FlagsSize); - - GCINFO_WRITE(m_Info1, m_ReturnKind, SIZE_OF_RETURN_KIND_IN_SLIM_HEADER, RetKindSize); - } - else - { - GCINFO_WRITE(m_Info1, 1, 1, FlagsSize); // Fat encoding - GCINFO_WRITE(m_Info1, (m_IsVarArg ? 1 : 0), 1, FlagsSize); - GCINFO_WRITE(m_Info1, (hasSecurityObject ? 1 : 0), 1, FlagsSize); - GCINFO_WRITE(m_Info1, (hasGSCookie ? 1 : 0), 1, FlagsSize); - GCINFO_WRITE(m_Info1, ((m_PSPSymStackSlot != NO_PSP_SYM) ? 1 : 0), 1, FlagsSize); - GCINFO_WRITE(m_Info1, m_contextParamType, 2, FlagsSize); - GCINFO_WRITE(m_Info1, ((m_StackBaseRegister != NO_STACK_BASE_REGISTER) ? 1 : 0), 1, FlagsSize); -#ifdef _TARGET_AMD64_ - GCINFO_WRITE(m_Info1, (m_WantsReportOnlyLeaf ? 1 : 0), 1, FlagsSize); -#elif defined(_TARGET_ARM_) || defined(_TARGET_ARM64_) - GCINFO_WRITE(m_Info1, (m_HasTailCalls ? 1 : 0), 1, FlagsSize); -#endif // _TARGET_AMD64_ - GCINFO_WRITE(m_Info1, ((m_SizeOfEditAndContinuePreservedArea != NO_SIZE_OF_EDIT_AND_CONTINUE_PRESERVED_AREA) ? 1 : 0), 1, FlagsSize); - GCINFO_WRITE(m_Info1, (hasReversePInvokeFrame ? 1 : 0), 1, FlagsSize); - - GCINFO_WRITE(m_Info1, m_ReturnKind, SIZE_OF_RETURN_KIND_IN_FAT_HEADER, RetKindSize); - } - - _ASSERTE( m_CodeLength > 0 ); - _ASSERTE(DENORMALIZE_CODE_LENGTH(NORMALIZE_CODE_LENGTH(m_CodeLength)) == m_CodeLength); - GCINFO_WRITE_VARL_U(m_Info1, NORMALIZE_CODE_LENGTH(m_CodeLength), CODE_LENGTH_ENCBASE, CodeLengthSize); - - if(hasGSCookie) - { - _ASSERTE(!slimHeader); - // Save the valid code range, to be used for determining when GS cookie validation - // should be performed - // Encode an intersection of valid offsets - UINT32 intersectionStart = m_GSCookieValidRangeStart; - UINT32 intersectionEnd = m_GSCookieValidRangeEnd; - - _ASSERTE(intersectionStart > 0 && intersectionStart < m_CodeLength); - _ASSERTE(intersectionEnd > 0 && intersectionEnd <= m_CodeLength); - _ASSERTE(intersectionStart <= intersectionEnd); - UINT32 normPrologSize = NORMALIZE_CODE_OFFSET(intersectionStart); - UINT32 normEpilogSize = NORMALIZE_CODE_OFFSET(m_CodeLength) - NORMALIZE_CODE_OFFSET(intersectionEnd); - _ASSERTE(normPrologSize > 0 && normPrologSize < m_CodeLength); - _ASSERTE(normEpilogSize < m_CodeLength); - - GCINFO_WRITE_VARL_U(m_Info1, normPrologSize-1, NORM_PROLOG_SIZE_ENCBASE, ProEpilogSize); - GCINFO_WRITE_VARL_U(m_Info1, normEpilogSize, NORM_EPILOG_SIZE_ENCBASE, ProEpilogSize); - } - else if (hasSecurityObject || hasContextParamType) - { - _ASSERTE(!slimHeader); - // Save the prolog size, to be used for determining when it is not safe - // to report generics param context and the security object - _ASSERTE(m_GSCookieValidRangeStart > 0 && m_GSCookieValidRangeStart < m_CodeLength); - UINT32 normPrologSize = NORMALIZE_CODE_OFFSET(m_GSCookieValidRangeStart); - _ASSERTE(normPrologSize > 0 && normPrologSize < m_CodeLength); - - GCINFO_WRITE_VARL_U(m_Info1, normPrologSize-1, NORM_PROLOG_SIZE_ENCBASE, ProEpilogSize); - } - - // Encode the offset to the security object. - if(hasSecurityObject) - { - _ASSERTE(!slimHeader); -#ifdef _DEBUG - LOG((LF_GCINFO, LL_INFO1000, "Security object at " FMT_STK "\n", - DBG_STK(m_SecurityObjectStackSlot) - )); -#endif - - GCINFO_WRITE_VARL_S(m_Info1, NORMALIZE_STACK_SLOT(m_SecurityObjectStackSlot), SECURITY_OBJECT_STACK_SLOT_ENCBASE, SecObjSize); - } - - // Encode the offset to the GS cookie. - if(hasGSCookie) - { - _ASSERTE(!slimHeader); -#ifdef _DEBUG - LOG((LF_GCINFO, LL_INFO1000, "GS cookie at " FMT_STK "\n", - DBG_STK(m_GSCookieStackSlot) - )); -#endif - - GCINFO_WRITE_VARL_S(m_Info1, NORMALIZE_STACK_SLOT(m_GSCookieStackSlot), GS_COOKIE_STACK_SLOT_ENCBASE, GsCookieSize); - - } - - // Encode the offset to the PSPSym. - // The PSPSym is relative to the caller SP on IA64 and the initial stack pointer before stack allocations on X64. - if(m_PSPSymStackSlot != NO_PSP_SYM) - { - _ASSERTE(!slimHeader); -#ifdef _DEBUG - LOG((LF_GCINFO, LL_INFO1000, "Parent PSP at " FMT_STK "\n", DBG_STK(m_PSPSymStackSlot))); -#endif - GCINFO_WRITE_VARL_S(m_Info1, NORMALIZE_STACK_SLOT(m_PSPSymStackSlot), PSP_SYM_STACK_SLOT_ENCBASE, PspSymSize); - } - - // Encode the offset to the generics type context. - if(m_GenericsInstContextStackSlot != NO_GENERICS_INST_CONTEXT) - { - _ASSERTE(!slimHeader); -#ifdef _DEBUG - LOG((LF_GCINFO, LL_INFO1000, "Generics instantiation context at " FMT_STK "\n", - DBG_STK(m_GenericsInstContextStackSlot) - )); -#endif - GCINFO_WRITE_VARL_S(m_Info1, NORMALIZE_STACK_SLOT(m_GenericsInstContextStackSlot), GENERICS_INST_CONTEXT_STACK_SLOT_ENCBASE, GenericsCtxSize); - } - - if(!slimHeader && (m_StackBaseRegister != NO_STACK_BASE_REGISTER)) - { - GCINFO_WRITE_VARL_U(m_Info1, NORMALIZE_STACK_BASE_REGISTER(m_StackBaseRegister), STACK_BASE_REGISTER_ENCBASE, StackBaseSize); - } - - if (m_SizeOfEditAndContinuePreservedArea != NO_SIZE_OF_EDIT_AND_CONTINUE_PRESERVED_AREA) - { - GCINFO_WRITE_VARL_U(m_Info1, m_SizeOfEditAndContinuePreservedArea, SIZE_OF_EDIT_AND_CONTINUE_PRESERVED_AREA_ENCBASE, EncPreservedSlots); - } - - if (hasReversePInvokeFrame) - { - _ASSERTE(!slimHeader); - GCINFO_WRITE_VARL_S(m_Info1, NORMALIZE_STACK_SLOT(m_ReversePInvokeFrameSlot), REVERSE_PINVOKE_FRAME_ENCBASE, ReversePInvokeFrameSize); - } - -#ifdef FIXED_STACK_PARAMETER_SCRATCH_AREA - if (!slimHeader) - { - _ASSERTE( m_SizeOfStackOutgoingAndScratchArea != (UINT32)-1 ); - GCINFO_WRITE_VARL_U(m_Info1, NORMALIZE_SIZE_OF_STACK_AREA(m_SizeOfStackOutgoingAndScratchArea), SIZE_OF_STACK_AREA_ENCBASE, FixedAreaSize); - } -#endif // FIXED_STACK_PARAMETER_SCRATCH_AREA - - UINT32 numInterruptibleRanges = (UINT32) m_InterruptibleRanges.Count(); - - InterruptibleRange *pRanges = NULL; - if(numInterruptibleRanges) - { - pRanges = (InterruptibleRange*) m_pAllocator->Alloc(numInterruptibleRanges * sizeof(InterruptibleRange)); - m_InterruptibleRanges.CopyTo(pRanges); - } - - int size_tCount = (m_NumSlots + BITS_PER_SIZE_T - 1) / BITS_PER_SIZE_T; - BitArray liveState(m_pAllocator, size_tCount); - BitArray couldBeLive(m_pAllocator, size_tCount); - liveState.ClearAll(); - couldBeLive.ClearAll(); - -#ifdef PARTIALLY_INTERRUPTIBLE_GC_SUPPORTED - _ASSERTE(m_NumCallSites == 0 || m_pCallSites != NULL); - - /////////////////////////////////////////////////////////////////////// - // Normalize call sites - // Eliminate call sites that fall inside interruptible ranges - /////////////////////////////////////////////////////////////////////// - - UINT32 numCallSites = 0; - for(UINT32 callSiteIndex = 0; callSiteIndex < m_NumCallSites; callSiteIndex++) - { - UINT32 callSite = m_pCallSites[callSiteIndex]; - // There's a contract with the EE that says for non-leaf stack frames, where the - // method is stopped at a call site, the EE will not query with the return PC, but - // rather the return PC *minus 1*. - // The reason is that variable/register liveness may change at the instruction immediately after the - // call, so we want such frames to appear as if they are "within" the call. - // Since we use "callSite" as the "key" when we search for the matching descriptor, also subtract 1 here - // (after, of course, adding the size of the call instruction to get the return PC). - callSite += m_pCallSiteSizes[callSiteIndex] - 1; - - _ASSERTE(DENORMALIZE_CODE_OFFSET(NORMALIZE_CODE_OFFSET(callSite)) == callSite); - UINT32 normOffset = NORMALIZE_CODE_OFFSET(callSite); - - BOOL keepIt = TRUE; - - for(UINT32 intRangeIndex = 0; intRangeIndex < numInterruptibleRanges; intRangeIndex++) - { - InterruptibleRange *pRange = &pRanges[intRangeIndex]; - if(pRange->NormStopOffset > normOffset) - { - if(pRange->NormStartOffset <= normOffset) - { - keepIt = FALSE; - } - break; - } - } - - if(keepIt) - m_pCallSites[numCallSites++] = normOffset; - } - - GCINFO_WRITE_VARL_U(m_Info1, NORMALIZE_NUM_SAFE_POINTS(numCallSites), NUM_SAFE_POINTS_ENCBASE, NumCallSitesSize); - m_NumCallSites = numCallSites; -#endif // PARTIALLY_INTERRUPTIBLE_GC_SUPPORTED - - if (slimHeader) - { - _ASSERTE(numInterruptibleRanges == 0); - } - else - { - GCINFO_WRITE_VARL_U(m_Info1, NORMALIZE_NUM_INTERRUPTIBLE_RANGES(numInterruptibleRanges), NUM_INTERRUPTIBLE_RANGES_ENCBASE, NumRangesSize); - } - - - -#ifdef PARTIALLY_INTERRUPTIBLE_GC_SUPPORTED - /////////////////////////////////////////////////////////////////////// - // Encode call site offsets - /////////////////////////////////////////////////////////////////////// - - UINT32 numBitsPerOffset = CeilOfLog2(NORMALIZE_CODE_OFFSET(m_CodeLength)); - - for(UINT32 callSiteIndex = 0; callSiteIndex < m_NumCallSites; callSiteIndex++) - { - UINT32 normOffset = m_pCallSites[callSiteIndex]; - - _ASSERTE(normOffset < (UINT32)1 << (numBitsPerOffset+1)); - GCINFO_WRITE(m_Info1, normOffset, numBitsPerOffset, CallSitePosSize); - } -#endif // PARTIALLY_INTERRUPTIBLE_GC_SUPPORTED - - - /////////////////////////////////////////////////////////////////////// - // Encode fully-interruptible ranges - /////////////////////////////////////////////////////////////////////// - - if(numInterruptibleRanges) - { - UINT32 lastStopOffset = 0; - - for(UINT32 i = 0; i < numInterruptibleRanges; i++) - { - UINT32 normStartOffset = pRanges[i].NormStartOffset; - UINT32 normStopOffset = pRanges[i].NormStopOffset; - - size_t normStartDelta = normStartOffset - lastStopOffset; - size_t normStopDelta = normStopOffset - normStartOffset; - _ASSERTE(normStopDelta > 0); - - lastStopOffset = normStopOffset; - - GCINFO_WRITE_VARL_U(m_Info1, normStartDelta, INTERRUPTIBLE_RANGE_DELTA1_ENCBASE, RangeSize); - - GCINFO_WRITE_VARL_U(m_Info1, normStopDelta-1, INTERRUPTIBLE_RANGE_DELTA2_ENCBASE, RangeSize); - } - } - - - /////////////////////////////////////////////////////////////////////// - // Pre-process transitions - /////////////////////////////////////////////////////////////////////// - - - size_t numTransitions = m_LifetimeTransitions.Count(); - LifetimeTransition *pTransitions = (LifetimeTransition*)m_pAllocator->Alloc(numTransitions * sizeof(LifetimeTransition)); - m_LifetimeTransitions.CopyTo(pTransitions); - - LifetimeTransition* pEndTransitions = pTransitions + numTransitions; - LifetimeTransition* pCurrent; - - //----------------------------------------------------------------- - // Sort the lifetime transitions by offset (then by slot id). - //----------------------------------------------------------------- - - // Don't use the CQuickSort algorithm, it's prone to stack overflows - qsort( - pTransitions, - numTransitions, - sizeof(LifetimeTransition), - CompareLifetimeTransitionsByOffsetThenSlot - ); - - // Eliminate transitions outside the method - while(pEndTransitions > pTransitions) - { - LifetimeTransition *pPrev = pEndTransitions - 1; - if(pPrev->CodeOffset < m_CodeLength) - break; - - _ASSERTE(pPrev->CodeOffset == m_CodeLength && !pPrev->BecomesLive); - pEndTransitions = pPrev; - } - - // Now eliminate any pairs of dead/live transitions for the same slot at the same offset. - EliminateRedundantLiveDeadPairs(&pTransitions, &numTransitions, &pEndTransitions); - -#ifdef _DEBUG - numTransitions = -1; -#endif - /////////////////////////////////////////////////////////////////////// - // Sort the slot table - /////////////////////////////////////////////////////////////////////// - - { - GcSlotDescAndId* sortedSlots = (GcSlotDescAndId*) m_pAllocator->Alloc(m_NumSlots * sizeof(GcSlotDescAndId)); - UINT32* sortOrder = (UINT32*) m_pAllocator->Alloc(m_NumSlots * sizeof(UINT32)); - - for(UINT32 i = 0; i < m_NumSlots; i++) - { - sortedSlots[i].m_SlotDesc = m_SlotTable[i]; - sortedSlots[i].m_SlotId = i; - } - - qsort(sortedSlots, m_NumSlots, sizeof(GcSlotDescAndId), CompareSlotDescAndIdBySlotDesc); - - for(UINT32 i = 0; i < m_NumSlots; i++) - { - sortOrder[sortedSlots[i].m_SlotId] = i; - } - - // Re-order the slot table - for(UINT32 i = 0; i < m_NumSlots; i++) - { - m_SlotTable[i] = sortedSlots[i].m_SlotDesc; - } - - // Update transitions to assign new slot ids - for(pCurrent = pTransitions; pCurrent < pEndTransitions; pCurrent++) - { - UINT32 newSlotId = sortOrder[pCurrent->SlotId]; - pCurrent->SlotId = newSlotId; - } - -#ifdef MUST_CALL_JITALLOCATOR_FREE - m_pAllocator->Free( sortedSlots ); - m_pAllocator->Free( sortOrder ); -#endif - } - -#if CODE_OFFSETS_NEED_NORMALIZATION - // Do a pass to normalize transition offsets - for(pCurrent = pTransitions; pCurrent < pEndTransitions; pCurrent++) - { - _ASSERTE(pCurrent->CodeOffset <= m_CodeLength); - pCurrent->CodeOffset = NORMALIZE_CODE_OFFSET(pCurrent->CodeOffset); - } -#endif - - /////////////////////////////////////////////////////////////////// - // Find out which slots are really used - /////////////////////////////////////////////////////////////////// - - couldBeLive.ClearAll(); - -#ifdef PARTIALLY_INTERRUPTIBLE_GC_SUPPORTED - if(m_NumCallSites) - { - _ASSERTE(m_pCallSites != NULL); - liveState.ClearAll(); - - UINT32 callSiteIndex = 0; - UINT32 callSite = m_pCallSites[0]; - - for(pCurrent = pTransitions; pCurrent < pEndTransitions; ) - { - if(pCurrent->CodeOffset > callSite) - { - couldBeLive |= liveState; - - if(++callSiteIndex == m_NumCallSites) - break; - - callSite = m_pCallSites[callSiteIndex]; - } - else - { - UINT32 slotIndex = pCurrent->SlotId; - if(!IsAlwaysScratch(m_SlotTable[slotIndex])) - { - BYTE becomesLive = pCurrent->BecomesLive; - _ASSERTE((liveState.ReadBit(slotIndex) && !becomesLive) - || (!liveState.ReadBit(slotIndex) && becomesLive)); - - liveState.WriteBit(slotIndex, becomesLive); - } - pCurrent++; - } - } - // There could be call sites after the last transition - if(callSiteIndex < m_NumCallSites) - { - couldBeLive |= liveState; - } - } - - if(numInterruptibleRanges) - { - liveState.ClearAll(); - - InterruptibleRange *pCurrentRange = pRanges; - InterruptibleRange *pEndRanges = pRanges + numInterruptibleRanges; - - for(pCurrent = pTransitions; pCurrent < pEndTransitions; ) - { - // Find the first transition at offset > of the start of the current range - LifetimeTransition *pFirstAfterStart = pCurrent; - while(pFirstAfterStart->CodeOffset <= pCurrentRange->NormStartOffset) - { - UINT32 slotIndex = (UINT32) (pFirstAfterStart->SlotId); - BYTE becomesLive = pFirstAfterStart->BecomesLive; - _ASSERTE((liveState.ReadBit(slotIndex) && !becomesLive) - || (!liveState.ReadBit(slotIndex) && becomesLive)); - liveState.WriteBit(slotIndex, becomesLive); - - if(++pFirstAfterStart == pEndTransitions) - break; - } - - couldBeLive |= liveState; - - // Now iterate through all the remaining transitions in the range, - // making the offset range-relative, and tracking live state - UINT32 rangeStop = pCurrentRange->NormStopOffset; - - for(pCurrent = pFirstAfterStart; pCurrent < pEndTransitions && pCurrent->CodeOffset < rangeStop; pCurrent++) - { - UINT32 slotIndex = (UINT32) (pCurrent->SlotId); - BYTE becomesLive = pCurrent->BecomesLive; - _ASSERTE((liveState.ReadBit(slotIndex) && !becomesLive) - || (!liveState.ReadBit(slotIndex) && becomesLive)); - liveState.WriteBit(slotIndex, becomesLive); - couldBeLive.SetBit(slotIndex); - } - - // Move to the next range - if(pCurrentRange < pEndRanges - 1) - { - pCurrentRange++; - } - else - { - break; - } - } - } - - //----------------------------------------------------------------- - // Mark unneeded slots as deleted - //----------------------------------------------------------------- - - UINT32 numUsedSlots = 0; - for(UINT32 i = 0; i < m_NumSlots; i++) - { - if(!(m_SlotTable[i].IsUntracked()) && (couldBeLive.ReadBit(i) == 0)) - { - m_SlotTable[i].MarkDeleted(); - } - else - numUsedSlots++; - } - - if(numUsedSlots < m_NumSlots) - { - // Delete transitions on unused slots - LifetimeTransition *pNextFree = pTransitions; - for(pCurrent = pTransitions; pCurrent < pEndTransitions; pCurrent++) - { - UINT32 slotId = pCurrent->SlotId; - if(!m_SlotTable[slotId].IsDeleted()) - { - if(pCurrent > pNextFree) - { - *pNextFree = *pCurrent; - } - pNextFree++; - } - } - pEndTransitions = pNextFree; - } - -#else // PARTIALLY_INTERRUPTIBLE_GC_SUPPORTED - - UINT32 numUsedSlots = m_NumSlots; - -#endif // PARTIALLY_INTERRUPTIBLE_GC_SUPPORTED - - - /////////////////////////////////////////////////////////////////////// - // Encode slot table - /////////////////////////////////////////////////////////////////////// - - //------------------------------------------------------------------ - // Count registers and stack slots - //------------------------------------------------------------------ - - UINT32 numRegisters; - UINT32 numUntrackedSlots; - UINT32 numStackSlots; - - { - UINT32 numDeleted = 0; - UINT32 i; - for(i = 0; i < m_NumSlots && m_SlotTable[i].IsRegister(); i++) - { - if(m_SlotTable[i].IsDeleted()) - { - numDeleted++; - } - } - numRegisters = i - numDeleted; - - for(; i < m_NumSlots && !m_SlotTable[i].IsUntracked(); i++) - { - if(m_SlotTable[i].IsDeleted()) - { - numDeleted++; - } - } - numStackSlots = i - (numRegisters + numDeleted); - } - numUntrackedSlots = numUsedSlots - (numRegisters + numStackSlots); - - // Common case: nothing, or a few registers - if (numRegisters) - { - GCINFO_WRITE(m_Info1, 1, 1, FlagsSize); - GCINFO_WRITE_VARL_U(m_Info1, numRegisters, NUM_REGISTERS_ENCBASE, NumRegsSize); - } - else - { - GCINFO_WRITE(m_Info1, 0, 1, FlagsSize); - } - if (numStackSlots || numUntrackedSlots) - { - GCINFO_WRITE(m_Info1, 1, 1, FlagsSize); - GCINFO_WRITE_VARL_U(m_Info1, numStackSlots, NUM_STACK_SLOTS_ENCBASE, NumStackSize); - GCINFO_WRITE_VARL_U(m_Info1, numUntrackedSlots, NUM_UNTRACKED_SLOTS_ENCBASE, NumUntrackedSize); - } - else - { - GCINFO_WRITE(m_Info1, 0, 1, FlagsSize); - } - - UINT32 currentSlot = 0; - - if(numUsedSlots == 0) - goto lExitSuccess; - - if(numRegisters > 0) - { - GcSlotDesc *pSlotDesc; - do - { - _ASSERTE(currentSlot < m_NumSlots); - pSlotDesc = &m_SlotTable[currentSlot++]; - } - while(pSlotDesc->IsDeleted()); - _ASSERTE(pSlotDesc->IsRegister()); - - // Encode slot identification - UINT32 currentNormRegNum = NORMALIZE_REGISTER(pSlotDesc->Slot.RegisterNumber); - GCINFO_WRITE_VARL_U(m_Info1, currentNormRegNum, REGISTER_ENCBASE, RegSlotSize); - GCINFO_WRITE(m_Info1, pSlotDesc->Flags, 2, RegSlotSize); - - for(UINT32 j = 1; j < numRegisters; j++) - { - UINT32 lastNormRegNum = currentNormRegNum; - GcSlotFlags lastFlags = pSlotDesc->Flags; - - do - { - _ASSERTE(currentSlot < m_NumSlots); - pSlotDesc = &m_SlotTable[currentSlot++]; - } - while(pSlotDesc->IsDeleted()); - _ASSERTE(pSlotDesc->IsRegister()); - - currentNormRegNum = NORMALIZE_REGISTER(pSlotDesc->Slot.RegisterNumber); - - if(lastFlags != GC_SLOT_IS_REGISTER) - { - GCINFO_WRITE_VARL_U(m_Info1, currentNormRegNum, REGISTER_ENCBASE, RegSlotSize); - GCINFO_WRITE(m_Info1, pSlotDesc->Flags, 2, RegSlotSize); - } - else - { - _ASSERTE(pSlotDesc->Flags == GC_SLOT_IS_REGISTER); - GCINFO_WRITE_VARL_U(m_Info1, currentNormRegNum - lastNormRegNum - 1, REGISTER_DELTA_ENCBASE, RegSlotSize); - } - } - } - - if(numStackSlots > 0) - { - GcSlotDesc *pSlotDesc; - do - { - _ASSERTE(currentSlot < m_NumSlots); - pSlotDesc = &m_SlotTable[currentSlot++]; - } - while(pSlotDesc->IsDeleted()); - _ASSERTE(!pSlotDesc->IsRegister()); - _ASSERTE(!pSlotDesc->IsUntracked()); - - // Encode slot identification - _ASSERTE((pSlotDesc->Slot.Stack.Base & ~3) == 0); - GCINFO_WRITE(m_Info1, pSlotDesc->Slot.Stack.Base, 2, StackSlotSize); - INT32 currentNormStackSlot = NORMALIZE_STACK_SLOT(pSlotDesc->Slot.Stack.SpOffset); - GCINFO_WRITE_VARL_S(m_Info1, currentNormStackSlot, STACK_SLOT_ENCBASE, StackSlotSize); - - GCINFO_WRITE(m_Info1, pSlotDesc->Flags, 2, StackSlotSize); - - for(UINT32 j = 1; j < numStackSlots; j++) - { - INT32 lastNormStackSlot = currentNormStackSlot; - GcSlotFlags lastFlags = pSlotDesc->Flags; - - do - { - _ASSERTE(currentSlot < m_NumSlots); - pSlotDesc = &m_SlotTable[currentSlot++]; - } - while(pSlotDesc->IsDeleted()); - _ASSERTE(!pSlotDesc->IsRegister()); - _ASSERTE(!pSlotDesc->IsUntracked()); - - currentNormStackSlot = NORMALIZE_STACK_SLOT(pSlotDesc->Slot.Stack.SpOffset); - - _ASSERTE((pSlotDesc->Slot.Stack.Base & ~3) == 0); - GCINFO_WRITE(m_Info1, pSlotDesc->Slot.Stack.Base, 2, StackSlotSize); - - if(lastFlags != GC_SLOT_BASE) - { - GCINFO_WRITE_VARL_S(m_Info1, currentNormStackSlot, STACK_SLOT_ENCBASE, StackSlotSize); - GCINFO_WRITE(m_Info1, pSlotDesc->Flags, 2, StackSlotSize); - } - else - { - _ASSERTE(pSlotDesc->Flags == GC_SLOT_BASE); - GCINFO_WRITE_VARL_U(m_Info1, currentNormStackSlot - lastNormStackSlot, STACK_SLOT_DELTA_ENCBASE, StackSlotSize); - } - } - } - - if(numUntrackedSlots > 0) - { - GcSlotDesc *pSlotDesc; - do - { - _ASSERTE(currentSlot < m_NumSlots); - pSlotDesc = &m_SlotTable[currentSlot++]; - } - while(pSlotDesc->IsDeleted()); - _ASSERTE(!pSlotDesc->IsRegister()); - _ASSERTE(pSlotDesc->IsUntracked()); - - // Encode slot identification - _ASSERTE((pSlotDesc->Slot.Stack.Base & ~3) == 0); - GCINFO_WRITE(m_Info1, pSlotDesc->Slot.Stack.Base, 2, UntrackedSlotSize); - INT32 currentNormStackSlot = NORMALIZE_STACK_SLOT(pSlotDesc->Slot.Stack.SpOffset); - GCINFO_WRITE_VARL_S(m_Info1, currentNormStackSlot, STACK_SLOT_ENCBASE, UntrackedSlotSize); - - GCINFO_WRITE(m_Info1, pSlotDesc->Flags, 2, UntrackedSlotSize); - - for(UINT32 j = 1; j < numUntrackedSlots; j++) - { - INT32 lastNormStackSlot = currentNormStackSlot; - GcSlotFlags lastFlags = pSlotDesc->Flags; - - do - { - _ASSERTE(currentSlot < m_NumSlots); - pSlotDesc = &m_SlotTable[currentSlot++]; - } - while(pSlotDesc->IsDeleted()); - _ASSERTE(!pSlotDesc->IsRegister()); - _ASSERTE(pSlotDesc->IsUntracked()); - - currentNormStackSlot = NORMALIZE_STACK_SLOT(pSlotDesc->Slot.Stack.SpOffset); - - _ASSERTE((pSlotDesc->Slot.Stack.Base & ~3) == 0); - GCINFO_WRITE(m_Info1, pSlotDesc->Slot.Stack.Base, 2, UntrackedSlotSize); - - if(lastFlags != GC_SLOT_UNTRACKED) - { - GCINFO_WRITE_VARL_S(m_Info1, currentNormStackSlot, STACK_SLOT_ENCBASE, UntrackedSlotSize); - GCINFO_WRITE(m_Info1, pSlotDesc->Flags, 2, UntrackedSlotSize); - } - else - { - _ASSERTE(pSlotDesc->Flags == GC_SLOT_UNTRACKED); - GCINFO_WRITE_VARL_U(m_Info1, currentNormStackSlot - lastNormStackSlot, STACK_SLOT_DELTA_ENCBASE, UntrackedSlotSize); - } - } - } - - -#ifdef PARTIALLY_INTERRUPTIBLE_GC_SUPPORTED - //----------------------------------------------------------------- - // Encode GC info at call sites - //----------------------------------------------------------------- - - if(m_NumCallSites) - { - - _ASSERTE(m_pCallSites != NULL); - - liveState.ClearAll(); - - UINT32 callSiteIndex = 0; - UINT32 callSite = m_pCallSites[0]; - - // Create a hash table for storing the locations of the live sets - LiveStateHashTable hashMap(m_pAllocator); - - bool outOfMemory = false; - try - { - for(pCurrent = pTransitions; pCurrent < pEndTransitions; ) - { - if(pCurrent->CodeOffset > callSite) - { - // Time to record the call site - - // Add it to the table if it doesn't exist - UINT32 liveStateOffset = 0; - if (!hashMap.Lookup(&liveState, &liveStateOffset)) - { - BitArray * newLiveState = new (m_pAllocator) BitArray(m_pAllocator, size_tCount); - *newLiveState = liveState; - hashMap.Set(newLiveState, (UINT32)(-1)); - } - - - if(++callSiteIndex == m_NumCallSites) - break; - - callSite = m_pCallSites[callSiteIndex]; - } - else - { - UINT32 slotIndex = pCurrent->SlotId; - BYTE becomesLive = pCurrent->BecomesLive; - _ASSERTE((liveState.ReadBit(slotIndex) && !becomesLive) - || (!liveState.ReadBit(slotIndex) && becomesLive)); - liveState.WriteBit(slotIndex, becomesLive); - pCurrent++; - } - } - - // Check for call sites at offsets past the last transition - if (callSiteIndex < m_NumCallSites) - { - UINT32 liveStateOffset = 0; - if (!hashMap.Lookup(&liveState, &liveStateOffset)) - { - BitArray * newLiveState = new (m_pAllocator) BitArray(m_pAllocator, size_tCount); - *newLiveState = liveState; - hashMap.Set(newLiveState, (UINT32)(-1)); - } - } - } - catch (GcInfoNoMemoryException& e) - { - outOfMemory = true; - } - - if (outOfMemory) - { - m_pNoMem(); - } - - // Figure out the largest offset, and total size of the sets - // Be sure to figure out the largest offset in the order that we will be emitting - // them in and not the order of their appearances in the safe point array. - // TODO: we should sort this to improve locality (the more frequent ones at the beginning) - // and to improve the indirection size (if the largest one is last, we *might* be able - // so use 1 less bit for each indirection for the offset encoding). - UINT32 largestSetOffset = 0; - UINT32 sizeofSets = 0; - for (LiveStateHashTable::KeyIterator iter = hashMap.Begin(), end = hashMap.End(); !iter.Equal(end); iter.Next()) - { - largestSetOffset = sizeofSets; - sizeofSets += SizeofSlotStateVarLengthVector(*iter.Get(), LIVESTATE_RLE_SKIP_ENCBASE, LIVESTATE_RLE_RUN_ENCBASE); - } - - // Now that we know the largest offset, we can figure out how much the indirection - // will cost us and commit - UINT32 numBitsPerPointer = ((largestSetOffset < 2) ? 1 : CeilOfLog2(largestSetOffset + 1)); - const size_t sizeofEncodedNumBitsPerPointer = BitStreamWriter::SizeofVarLengthUnsigned(numBitsPerPointer, POINTER_SIZE_ENCBASE); - const size_t sizeofNoIndirection = m_NumCallSites * (numRegisters + numStackSlots); - const size_t sizeofIndirection = sizeofEncodedNumBitsPerPointer // Encode the pointer sizes - + (m_NumCallSites * numBitsPerPointer) // Encoe the pointers - + 7 // Up to 7 bits of alignment padding - + sizeofSets; // Encode the actual live sets - - liveState.ClearAll(); - - callSiteIndex = 0; - callSite = m_pCallSites[0]; - - if (sizeofIndirection < sizeofNoIndirection) - { - // we are using an indirection - GCINFO_WRITE(m_Info1, 1, 1, FlagsSize); - GCINFO_WRITE_VARL_U(m_Info1, numBitsPerPointer - 1, POINTER_SIZE_ENCBASE, CallSiteStateSize); - - // Now encode the live sets and record the real offset - for (LiveStateHashTable::KeyIterator iter = hashMap.Begin(), end = hashMap.End(); !iter.Equal(end); iter.Next()) - { - _ASSERTE(FitsIn(m_Info2.GetBitCount())); - iter.SetValue((UINT32)m_Info2.GetBitCount()); - GCINFO_WRITE_VAR_VECTOR(m_Info2, *iter.Get(), LIVESTATE_RLE_SKIP_ENCBASE, LIVESTATE_RLE_RUN_ENCBASE, CallSiteStateSize); - } - - _ASSERTE(sizeofSets == m_Info2.GetBitCount()); - - for(pCurrent = pTransitions; pCurrent < pEndTransitions; ) - { - if(pCurrent->CodeOffset > callSite) - { - // Time to encode the call site - - // Find the match and emit it - UINT32 liveStateOffset; - bool found = hashMap.Lookup(&liveState, &liveStateOffset); - _ASSERTE(found); - (void)found; - GCINFO_WRITE(m_Info1, liveStateOffset, numBitsPerPointer, CallSiteStateSize); - - - if(++callSiteIndex == m_NumCallSites) - break; - - callSite = m_pCallSites[callSiteIndex]; - } - else - { - UINT32 slotIndex = pCurrent->SlotId; - BYTE becomesLive = pCurrent->BecomesLive; - _ASSERTE((liveState.ReadBit(slotIndex) && !becomesLive) - || (!liveState.ReadBit(slotIndex) && becomesLive)); - liveState.WriteBit(slotIndex, becomesLive); - pCurrent++; - } - } - - // Encode call sites at offsets past the last transition - { - UINT32 liveStateOffset; - bool found = hashMap.Lookup(&liveState, &liveStateOffset); - _ASSERTE(found); - (void)found; - for( ; callSiteIndex < m_NumCallSites; callSiteIndex++) - { - GCINFO_WRITE(m_Info1, liveStateOffset, numBitsPerPointer, CallSiteStateSize); - } - } - } - else - { - // we are not using an indirection - GCINFO_WRITE(m_Info1, 0, 1, FlagsSize); - - for(pCurrent = pTransitions; pCurrent < pEndTransitions; ) - { - if(pCurrent->CodeOffset > callSite) - { - // Time to encode the call site - GCINFO_WRITE_VECTOR(m_Info1, liveState, CallSiteStateSize); - - if(++callSiteIndex == m_NumCallSites) - break; - - callSite = m_pCallSites[callSiteIndex]; - } - else - { - UINT32 slotIndex = pCurrent->SlotId; - BYTE becomesLive = pCurrent->BecomesLive; - _ASSERTE((liveState.ReadBit(slotIndex) && !becomesLive) - || (!liveState.ReadBit(slotIndex) && becomesLive)); - liveState.WriteBit(slotIndex, becomesLive); - pCurrent++; - } - } - - // Encode call sites at offsets past the last transition - for( ; callSiteIndex < m_NumCallSites; callSiteIndex++) - { - GCINFO_WRITE_VECTOR(m_Info1, liveState, CallSiteStateSize); - } - } - -#ifdef MUST_CALL_JITALLOCATOR_FREE - // Cleanup - for (LiveStateHashTable::KeyIterator iter = hashMap.Begin(), end = hashMap.End(); !iter.Equal(end); iter.Next()) - { - m_pAllocator->Free((LPVOID)iter.Get()); - } -#endif // MUST_CALL_JITALLOCATOR_FREE - - } -#endif // PARTIALLY_INTERRUPTIBLE_GC_SUPPORTED - - - /////////////////////////////////////////////////////////////////////// - // Fully-interruptible: Encode lifetime transitions - /////////////////////////////////////////////////////////////////////// - - if(numInterruptibleRanges) - { -#ifdef PARTIALLY_INTERRUPTIBLE_GC_SUPPORTED - //----------------------------------------------------- - // Under partially-interruptible, make the transition - // offsets relative to the interruptible regions - //----------------------------------------------------- - - // Compute total length of interruptible ranges - UINT32 totalInterruptibleLength = 0; - for(UINT32 i = 0; i < numInterruptibleRanges; i++) - { - InterruptibleRange *pRange = &pRanges[i]; - totalInterruptibleLength += pRange->NormStopOffset - pRange->NormStartOffset; - } - _ASSERTE(totalInterruptibleLength <= NORMALIZE_CODE_OFFSET(m_CodeLength)); - - liveState.ClearAll(); - // Re-use couldBeLive - BitArray& liveStateAtPrevRange = couldBeLive; - liveStateAtPrevRange.ClearAll(); - - InterruptibleRange *pCurrentRange = pRanges; - InterruptibleRange *pEndRanges = pRanges + numInterruptibleRanges; - UINT32 cumInterruptibleLength = 0; - - for(pCurrent = pTransitions; pCurrent < pEndTransitions; ) - { - _ASSERTE(!m_SlotTable[pCurrent->SlotId].IsDeleted()); - - // Find the first transition at offset > of the start of the current range - LifetimeTransition *pFirstAfterStart = pCurrent; - while(pFirstAfterStart->CodeOffset <= pCurrentRange->NormStartOffset) - { - UINT32 slotIndex = (UINT32) (pFirstAfterStart->SlotId); - BYTE becomesLive = pFirstAfterStart->BecomesLive; - _ASSERTE((liveState.ReadBit(slotIndex) && !becomesLive) - || (!liveState.ReadBit(slotIndex) && becomesLive)); - liveState.WriteBit(slotIndex, becomesLive); - - if(++pFirstAfterStart == pEndTransitions) - break; - } - - // Now compare the liveState with liveStateAtPrevRange - LifetimeTransition *pFirstPreserved = pFirstAfterStart; - for(UINT32 slotIndex = 0; slotIndex < m_NumSlots; slotIndex++) - { - size_t isLive = liveState.ReadBit(slotIndex); - if(isLive != liveStateAtPrevRange.ReadBit(slotIndex)) - { - pFirstPreserved--; - _ASSERTE(pFirstPreserved >= pCurrent); - pFirstPreserved->CodeOffset = cumInterruptibleLength; - pFirstPreserved->SlotId = slotIndex; - pFirstPreserved->BecomesLive = (isLive) ? 1 : 0; - _ASSERTE(!pFirstPreserved->IsDeleted); - } - } - - // Mark all the other transitions since last range as deleted - _ASSERTE(pCurrent <= pFirstPreserved); - while(pCurrent < pFirstPreserved) - { - (pCurrent++)->IsDeleted = TRUE; - } - - // Now iterate through all the remaining transitions in the range, - // making the offset range-relative, and tracking live state - UINT32 rangeStop = pCurrentRange->NormStopOffset; - - for(pCurrent = pFirstAfterStart; pCurrent < pEndTransitions && pCurrent->CodeOffset < rangeStop; pCurrent++) - { - pCurrent->CodeOffset = - pCurrent->CodeOffset - - pCurrentRange->NormStartOffset + - cumInterruptibleLength; - - UINT32 slotIndex = (UINT32) (pCurrent->SlotId); - BYTE becomesLive = pCurrent->BecomesLive; - _ASSERTE((liveState.ReadBit(slotIndex) && !becomesLive) - || (!liveState.ReadBit(slotIndex) && becomesLive)); - liveState.WriteBit(slotIndex, becomesLive); - } - - // Move to the next range - if(pCurrentRange < pEndRanges - 1) - { - cumInterruptibleLength += pCurrentRange->NormStopOffset - pCurrentRange->NormStartOffset; - pCurrentRange++; - - liveStateAtPrevRange = liveState; - } - else - { - pEndTransitions = pCurrent; - break; - } - } - - // Make another pass, deleting everything that's marked as deleted - LifetimeTransition *pNextFree = pTransitions; - for(pCurrent = pTransitions; pCurrent < pEndTransitions; pCurrent++) - { - if(!pCurrent->IsDeleted) - { - if(pCurrent > pNextFree) - { - *pNextFree = *pCurrent; - } - pNextFree++; - } - } - pEndTransitions = pNextFree; - -#else - UINT32 totalInterruptibleLength = NORMALIZE_CODE_OFFSET(m_CodeLength); - -#endif //PARTIALLY_INTERRUPTIBLE_GC_SUPPORTED - - // - // Initialize chunk pointers - // - UINT32 numChunks = (totalInterruptibleLength + NUM_NORM_CODE_OFFSETS_PER_CHUNK - 1) / NUM_NORM_CODE_OFFSETS_PER_CHUNK; - _ASSERTE(numChunks > 0); - - size_t* pChunkPointers = (size_t*) m_pAllocator->Alloc(numChunks*sizeof(size_t)); - ZeroMemory(pChunkPointers, numChunks*sizeof(size_t)); - - //------------------------------------------------------------------ - // Encode transitions - //------------------------------------------------------------------ - - LOG((LF_GCINFO, LL_INFO1000, "Encoding %i lifetime transitions.\n", pEndTransitions - pTransitions)); - - - liveState.ClearAll(); - couldBeLive.ClearAll(); - - for(pCurrent = pTransitions; pCurrent < pEndTransitions; ) - { - _ASSERTE(pCurrent->CodeOffset < m_CodeLength); - - UINT32 currentChunk = GetNormCodeOffsetChunk(pCurrent->CodeOffset); - _ASSERTE(currentChunk < numChunks); - UINT32 numTransitionsInCurrentChunk = 1; - - for(;;) - { - UINT32 slotIndex = (UINT32) (pCurrent->SlotId); - BYTE becomesLive = pCurrent->BecomesLive; - _ASSERTE((liveState.ReadBit(slotIndex) && !becomesLive) - || (!liveState.ReadBit(slotIndex) && becomesLive)); - liveState.WriteBit(slotIndex, becomesLive); - couldBeLive.SetBit(slotIndex); - - pCurrent++; - if(pCurrent == pEndTransitions || GetNormCodeOffsetChunk(pCurrent->CodeOffset) != currentChunk) - break; - - numTransitionsInCurrentChunk++; - } - - //----------------------------------------------------- - // Time to encode the chunk - //----------------------------------------------------- - - _ASSERTE(numTransitionsInCurrentChunk > 0); - - // Sort the transitions in this chunk by slot - qsort( - pCurrent - numTransitionsInCurrentChunk, - numTransitionsInCurrentChunk, - sizeof(LifetimeTransition), - CompareLifetimeTransitionsBySlot - ); - - // Save chunk pointer - pChunkPointers[currentChunk] = m_Info2.GetBitCount() + 1; - - // Write couldBeLive slot map - GCINFO_WRITE_VAR_VECTOR(m_Info2, couldBeLive, LIVESTATE_RLE_SKIP_ENCBASE, LIVESTATE_RLE_RUN_ENCBASE, ChunkMaskSize); - - LOG((LF_GCINFO, LL_INFO100000, - "Chunk %d couldBeLive (%04x-%04x):\n", currentChunk, - currentChunk * NUM_NORM_CODE_OFFSETS_PER_CHUNK, - ((currentChunk + 1) * NUM_NORM_CODE_OFFSETS_PER_CHUNK) - 1 - )); - - // Write final state - // For all the bits set in couldBeLive. - UINT32 i; - for (BitArrayIterator iter(&couldBeLive); !iter.end(); iter++) - { - i = *iter; - { - _ASSERTE(!m_SlotTable[i].IsDeleted()); - _ASSERTE(!m_SlotTable[i].IsUntracked()); - GCINFO_WRITE( m_Info2, - liveState.ReadBit(i) ? 1 : 0, - 1, - ChunkFinalStateSize - ); - - LOG((LF_GCINFO, LL_INFO100000, - "\t" LOG_GCSLOTDESC_FMT " %s at end of chunk.\n", - LOG_GCSLOTDESC_ARGS(&m_SlotTable[i]), - liveState.ReadBit(i) ? "live" : "dead")); - } - } - - // Write transitions offsets - UINT32 normChunkBaseCodeOffset = currentChunk * NUM_NORM_CODE_OFFSETS_PER_CHUNK; - - LifetimeTransition* pT = pCurrent - numTransitionsInCurrentChunk; - - for (BitArrayIterator iter(&couldBeLive); !iter.end(); iter++) - { - i = *iter; - - while(pT < pCurrent) - { - GcSlotId slotId = pT->SlotId; - if(slotId != i) - break; - - _ASSERTE(couldBeLive.ReadBit(slotId)); - - LOG((LF_GCINFO, LL_INFO100000, - "\tTransition " LOG_GCSLOTDESC_FMT " going %s at offset %04x.\n", - LOG_GCSLOTDESC_ARGS(&m_SlotTable[pT->SlotId]), - pT->BecomesLive ? "live" : "dead", - (int) pT->CodeOffset )); - - // Write code offset delta - UINT32 normCodeOffset = pT->CodeOffset; - UINT32 normCodeOffsetDelta = normCodeOffset - normChunkBaseCodeOffset; - - // Don't encode transitions at offset 0 as they are useless - if(normCodeOffsetDelta) - { - _ASSERTE(normCodeOffsetDelta < NUM_NORM_CODE_OFFSETS_PER_CHUNK); - - GCINFO_WRITE(m_Info2, 1, 1, ChunkTransitionSize); - GCINFO_WRITE(m_Info2, normCodeOffsetDelta, NUM_NORM_CODE_OFFSETS_PER_CHUNK_LOG2, ChunkTransitionSize); - -#ifdef MEASURE_GCINFO - m_CurrentMethodSize.NumTransitions++; -#endif - } - - pT++; - } - - // Write terminator - GCINFO_WRITE(m_Info2, 0, 1, ChunkTransitionSize); - - } - _ASSERTE(pT == pCurrent); - - couldBeLive = liveState; - } - - //--------------------------------------------------------------------- - // The size of chunk encodings is now known. Write the chunk pointers. - //--------------------------------------------------------------------- - - - // Find the largest pointer - size_t largestPointer = 0; - for(int i = numChunks - 1; i >=0; i--) - { - largestPointer = pChunkPointers[i]; - if(largestPointer > 0) - break; - } - - UINT32 numBitsPerPointer = CeilOfLog2(largestPointer + 1); - GCINFO_WRITE_VARL_U(m_Info1, numBitsPerPointer, POINTER_SIZE_ENCBASE, ChunkPtrSize); - - if(numBitsPerPointer) - { - for(UINT32 i = 0; i < numChunks; i++) - { - GCINFO_WRITE(m_Info1, pChunkPointers[i], numBitsPerPointer, ChunkPtrSize); - } - } - - //------------------------------------------------------------------- - // Cleanup - //------------------------------------------------------------------- - -#ifdef MUST_CALL_JITALLOCATOR_FREE - m_pAllocator->Free(pRanges); - m_pAllocator->Free(pChunkPointers); -#endif - } - - -#ifdef MUST_CALL_JITALLOCATOR_FREE - m_pAllocator->Free(pTransitions); -#endif - - -lExitSuccess:; - - //------------------------------------------------------------------- - // Update global stats - //------------------------------------------------------------------- - -#ifdef MEASURE_GCINFO - if (slimHeader) - { - g_NumSlimHeaders++; - } - else - { - g_NumFatHeaders++; - } - - m_CurrentMethodSize.NumMethods = 1; -#ifdef PARTIALLY_INTERRUPTIBLE_GC_SUPPORTED - m_CurrentMethodSize.NumCallSites = m_NumCallSites; -#endif - m_CurrentMethodSize.NumRanges = numInterruptibleRanges; - m_CurrentMethodSize.NumRegs = numRegisters; - m_CurrentMethodSize.NumStack = numStackSlots; - m_CurrentMethodSize.NumUntracked = numUntrackedSlots; - m_CurrentMethodSize.SizeOfCode = m_CodeLength; - if(numInterruptibleRanges) - { - g_FiGcInfoSize += m_CurrentMethodSize; - m_CurrentMethodSize.Log(LL_INFO100, "=== FullyInterruptible method breakdown ===\r\n"); - g_FiGcInfoSize.Log(LL_INFO10, "=== FullyInterruptible global breakdown ===\r\n"); - } - else - { - g_PiGcInfoSize += m_CurrentMethodSize; - m_CurrentMethodSize.Log(LL_INFO100, "=== PartiallyInterruptible method breakdown ===\r\n"); - g_PiGcInfoSize.Log(LL_INFO10, "=== PartiallyInterruptible global breakdown ===\r\n"); - } - LogSpew(LF_GCINFO, LL_INFO10, "Total SlimHeaders: %Iu\n", g_NumSlimHeaders); - LogSpew(LF_GCINFO, LL_INFO10, "NumMethods: %Iu\n", g_NumFatHeaders); -#endif -} - -void GcInfoEncoder::SizeofSlotStateVarLengthVector(const BitArray &vector, - UINT32 baseSkip, - UINT32 baseRun, - UINT32 *pSizeofSimple, - UINT32 *pSizeofRLE, - UINT32 *pSizeofRLENeg) -{ - // Try 3 different encodings - UINT32 sizeofSimple = 1; - UINT32 sizeofRLE; - UINT32 sizeofRLENeg; - for(UINT32 i = 0; i < m_NumSlots && !m_SlotTable[i].IsUntracked(); i++) - { - if(!m_SlotTable[i].IsDeleted()) - sizeofSimple++; - } - - if (sizeofSimple <= 2 + baseSkip + 1 + baseRun + 1) - { - // simple encoding is smaller than the smallest of the others - // without even trying - sizeofRLE = sizeofSimple + 1; - sizeofRLENeg = sizeofSimple + 1; - } - else - { - sizeofRLE = 2; // For the header - sizeofRLENeg = 2; - - UINT32 rleStart = 0; - bool fPrev = false; - UINT32 i; - for(i = 0; i < m_NumSlots && !m_SlotTable[i].IsUntracked(); i++) - { - if(!m_SlotTable[i].IsDeleted()) - { - if (vector.ReadBit(i)) - { - if (!fPrev) - { - // Skipping is done - sizeofRLE += BitStreamWriter::SizeofVarLengthUnsigned(i - rleStart, baseSkip); - sizeofRLENeg += BitStreamWriter::SizeofVarLengthUnsigned(i - rleStart, baseRun); - rleStart = i + 1; - fPrev = true; - } - } - else - { - if (fPrev) - { - // Run is done - sizeofRLE += BitStreamWriter::SizeofVarLengthUnsigned(i - rleStart, baseRun); - sizeofRLENeg += BitStreamWriter::SizeofVarLengthUnsigned(i - rleStart, baseSkip); - rleStart = i + 1; - fPrev = false; - } - } - } - else - { - rleStart++; - } - } - - _ASSERTE(i >= rleStart); - sizeofRLE += BitStreamWriter::SizeofVarLengthUnsigned(i - rleStart, fPrev ? baseRun : baseSkip); - sizeofRLENeg += BitStreamWriter::SizeofVarLengthUnsigned(i - rleStart, fPrev ? baseSkip : baseRun); - } - - *pSizeofSimple = sizeofSimple; - *pSizeofRLE = sizeofRLE; - *pSizeofRLENeg = sizeofRLENeg; -} - -UINT32 GcInfoEncoder::SizeofSlotStateVarLengthVector(const BitArray &vector, - UINT32 baseSkip, - UINT32 baseRun) -{ - // Try 3 different encodings - UINT32 sizeofSimple; - UINT32 sizeofRLE; - UINT32 sizeofRLENeg; - SizeofSlotStateVarLengthVector(vector, baseSkip, baseRun, &sizeofSimple, &sizeofRLE, &sizeofRLENeg); - - if (sizeofSimple <= sizeofRLE && sizeofSimple <= sizeofRLENeg) - return sizeofSimple; - if (sizeofRLE <= sizeofRLENeg) - return sizeofRLE; - return sizeofRLENeg; -} - -UINT32 GcInfoEncoder::WriteSlotStateVarLengthVector(BitStreamWriter &writer, - const BitArray &vector, - UINT32 baseSkip, - UINT32 baseRun) -{ - // Try 3 different encodings - UINT32 sizeofSimple; - UINT32 sizeofRLE; - UINT32 sizeofRLENeg; - SizeofSlotStateVarLengthVector(vector, baseSkip, baseRun, &sizeofSimple, &sizeofRLE, &sizeofRLENeg); - UINT32 result; - -#ifdef _DEBUG - size_t initial = writer.GetBitCount(); -#endif // _DEBUG - - if (sizeofSimple <= sizeofRLE && sizeofSimple <= sizeofRLENeg) - { - // Simple encoding is smallest - writer.Write(0, 1); - WriteSlotStateVector(writer, vector); - result = sizeofSimple; - } - else - { - // One of the RLE encodings is the smallest - writer.Write(1, 1); - - if (sizeofRLENeg < sizeofRLE) - { - writer.Write(1, 1); - UINT32 swap = baseSkip; - baseSkip = baseRun; - baseRun = swap; - result = sizeofRLENeg; - } - else - { - writer.Write(0, 1); - result = sizeofRLE; - } - - - UINT32 rleStart = 0; - UINT32 i; - bool fPrev = false; - for(i = 0; i < m_NumSlots && !m_SlotTable[i].IsUntracked(); i++) - { - if(!m_SlotTable[i].IsDeleted()) - { - - if (vector.ReadBit(i)) - { - if (!fPrev) - { - // Skipping is done - writer.EncodeVarLengthUnsigned(i - rleStart, baseSkip); - rleStart = i + 1; - fPrev = true; - } - } - else - { - if (fPrev) - { - // Run is done - writer.EncodeVarLengthUnsigned(i - rleStart, baseRun); - rleStart = i + 1; - fPrev = false; - } - } - } - else - { - rleStart++; - } - } - - _ASSERTE(i >= rleStart); - writer.EncodeVarLengthUnsigned(i - rleStart, fPrev ? baseRun : baseSkip); - } - -#ifdef _DEBUG - _ASSERTE(result + initial == writer.GetBitCount()); -#endif // _DEBUG - - return result; -} - - -void GcInfoEncoder::EliminateRedundantLiveDeadPairs(LifetimeTransition** ppTransitions, - size_t* pNumTransitions, - LifetimeTransition** ppEndTransitions) -{ - LifetimeTransition* pTransitions = *ppTransitions; - LifetimeTransition* pEndTransitions = *ppEndTransitions; - - LifetimeTransition* pNewTransitions = NULL; - LifetimeTransition* pNewTransitionsCopyPtr = NULL; - for (LifetimeTransition* pCurrent = pTransitions; pCurrent < pEndTransitions; pCurrent++) - { - // Is pCurrent the first of a dead/live pair? - LifetimeTransition* pNext = pCurrent + 1; - if (pNext < pEndTransitions && - pCurrent->CodeOffset == pNext->CodeOffset && - pCurrent->SlotId == pNext->SlotId && - pCurrent->IsDeleted == pNext->IsDeleted && - pCurrent->BecomesLive != pNext->BecomesLive) - { - // They are a pair we want to delete. If this is the first pair we've encountered, allocate - // the new array: - if (pNewTransitions == NULL) - { - pNewTransitions = (LifetimeTransition*)m_pAllocator->Alloc((*pNumTransitions) * sizeof(LifetimeTransition)); - pNewTransitionsCopyPtr = pNewTransitions; - // Copy from the start up to (but not including) pCurrent... - for (LifetimeTransition* pCopyPtr = pTransitions; pCopyPtr < pCurrent; pCopyPtr++, pNewTransitionsCopyPtr++) - *pNewTransitionsCopyPtr = *pCopyPtr; - } - pCurrent++; - } - else - { - // pCurrent is not part of a pair. If we're copying, copy. - if (pNewTransitionsCopyPtr != NULL) - { - *pNewTransitionsCopyPtr++ = *pCurrent; - } - } - } - // If we deleted any pairs, substitute the new array for the old. - if (pNewTransitions != NULL) - { - m_pAllocator->Free(pTransitions); - *ppTransitions = pNewTransitions; - assert(pNewTransitionsCopyPtr != NULL); - *ppEndTransitions = pNewTransitionsCopyPtr; - *pNumTransitions = (*ppEndTransitions) - (*ppTransitions); - } -} - -// -// Write encoded information to its final destination and frees temporary buffers. -// The encoder shouldn't be used anymore after calling this method. -// -BYTE* GcInfoEncoder::Emit() -{ - size_t cbGcInfoSize = m_Info1.GetByteCount() + - m_Info2.GetByteCount(); - - LOG((LF_GCINFO, LL_INFO100, "GcInfoEncoder::Emit(): Size of GC info is %u bytes, code size %u bytes.\n", (unsigned)cbGcInfoSize, m_CodeLength )); - - BYTE* destBuffer = (BYTE *)eeAllocGCInfo(cbGcInfoSize); - // Allocator will throw an exception on failure. - // NOTE: the returned pointer may not be aligned during ngen. - _ASSERTE( destBuffer ); - - BYTE* ptr = destBuffer; - - m_Info1.CopyTo( ptr ); - ptr += m_Info1.GetByteCount(); - m_Info1.Dispose(); - - m_Info2.CopyTo( ptr ); - ptr += m_Info2.GetByteCount(); - m_Info2.Dispose(); - -#ifdef MUST_CALL_JITALLOCATOR_FREE - m_pAllocator->Free( m_SlotTable ); -#endif - - return destBuffer; -} - -void * GcInfoEncoder::eeAllocGCInfo (size_t blockSize) -{ - return m_pCorJitInfo->allocGCInfo(blockSize); -} - - -BitStreamWriter::BitStreamWriter( IAllocator* pAllocator ) -{ - m_pAllocator = pAllocator; - m_BitCount = 0; -#ifdef _DEBUG - m_MemoryBlocksCount = 0; -#endif - - // Allocate memory blocks lazily - m_OutOfBlockSlot = m_pCurrentSlot = (size_t*) NULL; - m_FreeBitsInCurrentSlot = 0; -} - -// -// bit 0 is the least significative bit -// The stream encodes the first come bit in the least significant bit of each byte -// -void BitStreamWriter::Write( size_t data, UINT32 count ) -{ - _ASSERT(count <= BITS_PER_SIZE_T); - - if(count) - { - // Increment it now as we change count later on - m_BitCount += count; - - if( count > m_FreeBitsInCurrentSlot ) - { - if( m_FreeBitsInCurrentSlot > 0 ) - { - _ASSERTE(m_FreeBitsInCurrentSlot < BITS_PER_SIZE_T); - WriteInCurrentSlot( data, m_FreeBitsInCurrentSlot ); - count -= m_FreeBitsInCurrentSlot; - data >>= m_FreeBitsInCurrentSlot; - } - - _ASSERTE( count > 0 ); - - // Initialize the next slot - if( ++m_pCurrentSlot >= m_OutOfBlockSlot ) - { - // Get a new memory block - AllocMemoryBlock(); - } - - InitCurrentSlot(); - - // Write the remainder - WriteInCurrentSlot( data, count ); - m_FreeBitsInCurrentSlot -= count; - } - else - { - WriteInCurrentSlot( data, count ); - m_FreeBitsInCurrentSlot -= count; - // if m_FreeBitsInCurrentSlot becomes 0 a nwe slot will initialized on the next request - } - } -} - - -void BitStreamWriter::CopyTo( BYTE* buffer ) -{ - int i,c; - BYTE* source = NULL; - - MemoryBlock* pMemBlock = m_MemoryBlocks.Head(); - if( pMemBlock == NULL ) - return; - - while (pMemBlock->Next() != NULL) - { - source = (BYTE*) pMemBlock->Contents; - // @TODO: use memcpy instead - for( i = 0; i < m_MemoryBlockSize; i++ ) - { - *( buffer++ ) = *( source++ ); - } - - pMemBlock = pMemBlock->Next(); - } - - source = (BYTE*) pMemBlock->Contents; - // The number of bytes to copy in the last block - c = (int) ((BYTE*) ( m_pCurrentSlot + 1 ) - source - m_FreeBitsInCurrentSlot/8); - _ASSERTE( c >= 0 ); - // @TODO: use memcpy instead - for( i = 0; i < c; i++ ) - { - *( buffer++ ) = *( source++ ); - } - -} - -void BitStreamWriter::Dispose() -{ - m_MemoryBlocks.Dispose(m_pAllocator); -} - -int BitStreamWriter::SizeofVarLengthUnsigned( size_t n, UINT32 base) -{ - // If a value gets so big we are probably doing something wrong - _ASSERTE(((INT32)(UINT32)n) >= 0); - _ASSERTE((base > 0) && (base < BITS_PER_SIZE_T)); - size_t numEncodings = 1 << base; - int bitsUsed; - for(bitsUsed = base+1; ; bitsUsed += base+1) - { - if( n < numEncodings ) - { - return bitsUsed; - } - else - { - n >>= base; - } - } - return bitsUsed; -} - -int BitStreamWriter::EncodeVarLengthUnsigned( size_t n, UINT32 base) -{ - // If a value gets so big we are probably doing something wrong - _ASSERTE(((INT32)(UINT32)n) >= 0); - _ASSERTE((base > 0) && (base < BITS_PER_SIZE_T)); - size_t numEncodings = 1 << base; - int bitsUsed; - for(bitsUsed = base+1; ; bitsUsed += base+1) - { - if( n < numEncodings ) - { - Write( n, base+1 ); // This sets the extension bit to zero - return bitsUsed; - } - else - { - size_t currentChunk = n & (numEncodings-1); - Write( currentChunk | numEncodings, base+1 ); - n >>= base; - } - } - return bitsUsed; -} - -int BitStreamWriter::EncodeVarLengthSigned( SSIZE_T n, UINT32 base ) -{ - _ASSERTE((base > 0) && (base < BITS_PER_SIZE_T)); - size_t numEncodings = 1 << base; - for(int bitsUsed = base+1; ; bitsUsed += base+1) - { - size_t currentChunk = ((size_t) n) & (numEncodings-1); - size_t topmostBit = currentChunk & (numEncodings >> 1); - n >>= base; // signed arithmetic shift - if((topmostBit && (n == (SSIZE_T)-1)) || (!topmostBit && (n == 0))) - { - // The topmost bit correctly represents the sign - Write( currentChunk, base+1 ); // This sets the extension bit to zero - return bitsUsed; - } - else - { - Write( currentChunk | numEncodings, base+1 ); - } - } -} - diff --git a/src/gcinfo/lib/CMakeLists.txt b/src/gcinfo/lib/CMakeLists.txt deleted file mode 100644 index ec44c2ba5..000000000 --- a/src/gcinfo/lib/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -add_library_clr(gcinfo - STATIC - ${GCINFO_SOURCES} -) diff --git a/src/inc/CMakeLists.txt b/src/inc/CMakeLists.txt index c109c2f3a..a9bee4289 100644 --- a/src/inc/CMakeLists.txt +++ b/src/inc/CMakeLists.txt @@ -1,3 +1,8 @@ +if(CLR_CMAKE_PLATFORM_UNIX) + include_directories(${ROOT_DIR}/src/pal/inc) + include_directories(${ROOT_DIR}/src/pal/inc/rt) +endif(CLR_CMAKE_PLATFORM_UNIX) + set( CORGUIDS_IDL_SOURCES cordebug.idl xcordebug.idl @@ -67,20 +72,3 @@ endif(FEATURE_JIT_PITCHING) # Compile *_i.cpp to lib _add_library(corguids ${CORGUIDS_SOURCES}) - -# Binplace the inc files for packaging later. - -_install (FILES cfi.h - cor.h - cordebuginfo.h - coredistools.h - corhdr.h - corinfo.h - corjit.h - corjithost.h - opcode.def - openum.h - gcinfoencoder.h - gcinfotypes.h - DESTINATION inc) -_install (TARGETS corguids DESTINATION lib) diff --git a/src/inc/CrstTypeTool.cs b/src/inc/CrstTypeTool.cs deleted file mode 100644 index d6d90e427..000000000 --- a/src/inc/CrstTypeTool.cs +++ /dev/null @@ -1,990 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -// -// This tool exists to transform a high level description of Crst dependencies (i.e. which Crst type may be -// acquired before or after other Crst types) into a header file that defines a enum to describe each Crst -// type and tables that map type to numerical ranking and a string based name. -// -// To use the tool, run "csc.exe CrstTypeTool.cs" and run the resulting executable. -// -// The Crst type definition file is written in a very simple language. Comments begin with '//' and continue -// to the end of the line. All remaining tokens after comment removal are simply sequences of non-whitespace -// characters separated by whitespace. Keywords are case-insensitive and identifiers (which are always Crst -// type names) are case sensitive. The language grammar is given below in EBNF-like form: -// -// TopLevel ::= CrstDefinition* -// -// CrstDefinition ::= 'Crst' CrstDependency* 'End' -// -// CrstDependency ::= 'AcquiredBefore' * -// | 'AcquiredAfter' * -// | 'SameLevelAs' * -// | 'Unordered' -// -// Crst type names match the CrstType enums used in the source code minus the 'Crst' prefix. For example -// CrstAppDomainCache is written as 'AppDomainCache' in the .def file. -// -// The dependency "A 'AcquiredBefore' B" indicates that CrstA may be legally held while CrstB is acquired. -// Similarly "A 'AcquiredAfter' B" indicates that CrstA may be legally acquired while CrstB is held. "A -// 'AcquiredBefore' B" is logically equivalent to "B 'AcquiredAfter' A" and authors may enter the dependency -// is whichever seems to make the most sense to them (or add both rules if they so desire). -// -// 'Unordered' indicates that the Crst type does not participate in ranking (there should be very few Crsts -// like this and those that are know how to avoid or deal with deadlocks manually). -// -// 'SameLevelAs' indicates the given Crst type may be acquired alongside any number of instances of the Crst -// types indicated. "A 'SameLevel' B" automatically implies "B 'SameLevel' A" so it's not necessary to specify -// the dependency both ways though authors can do so if they wish. -// -// Simple validation of the .def file (over and above syntax checking) is performed by this tool prior to -// emitting the header file. This will catch logic errors such as referencing a Crst type that is not -// defined or using the 'Unordered' attribute along with any other attribute within a single definition. It -// will also catch cycles in the dependency graph (i.e. definitions that logically describe a system where the -// Crst types can't be ranked). -// - -using System; -using System.Collections.Generic; -using System.Text; -using System.IO; -using System.Text.RegularExpressions; - -// The main application class containing the program entry point. -class CrstTypeTool -{ - // A hash containing every Crst type defined by the input .def file along with its attributes. Keyed by - // Crst type name (which is case sensitive and doesn't include the 'Crst' enum prefix). - Dictionary m_crsts = new Dictionary(); - - // The program entry point. - public static int Main() - { - try - { - // Calculate the filenames of the input and output files. - string inputFile = "CrstTypes.def"; - string outputFile = "CrstTypes.h"; - - // A common error is to forget to check out the CrstTypes.h file first. Handle this case specially - // so we can give a good error message. - if (File.Exists(outputFile) && (File.GetAttributes(outputFile) & FileAttributes.ReadOnly) != 0) - { - Console.WriteLine(outputFile + " is read-only, you must check it out of TFS/SD first"); - return 2; - } - - // Create an instance of our application class to store state in (specifically the collection of - // Crst type definitions). - CrstTypeTool app = new CrstTypeTool(); - - // Create a parser for the CrstTypes.def file and run it over the input file (errors are signalled - // via exception, in common with all the following steps except validation). - new TypeFileParser().ParseFile(inputFile, app.m_crsts); - - // Validate the collection of Crst type definitions we built up during parsing for common logic - // errors and the presence of dependency cycles. False is returned from ValidateCrsts if an error - // was detected (an error message will have already been output to the console at this point). - if (!app.ValidateCrsts()) - return 3; - - // Perform a topological sort to map each Crst type to a numeric ranking. - app.LevelCrsts(); - - // Emit the new header file containing Crst type definitions and ranking information. - app.WriteHeaderFile(outputFile); - - // If we get here the transformation was successful; inform the user and we're done. - Console.WriteLine(outputFile + " successfully updated"); - return 0; - } - catch (TypeFileParser.ParseError pe) - { - // Syntax errors specific to parsing the input file. - Console.WriteLine("ParseError: " + pe.Message); - return 4; - } - catch (Exception e) - { - // Any other general errors (file I/O problems, out of memory etc.). - Console.WriteLine("Unexpected exception:"); - Console.WriteLine(e); - return 5; - } - } - - // Emit the CrstTypes.h output file. - void WriteHeaderFile(string fileName) - { - FileStream stream = new FileStream(fileName, FileMode.Create, FileAccess.Write, FileShare.None); - StreamWriter writer = new StreamWriter(stream); - - // Create a collection based on all the Crst types we've stored in the hash. We do this so we can sort - // the Crst types we emit (lexically, based on type name). - Dictionary.ValueCollection crstCollection = m_crsts.Values; - CrstType[] crsts = new CrstType[crstCollection.Count]; - crstCollection.CopyTo(crsts, 0); - Array.Sort(crsts); - - // Emit the header. Contains copyright information, the usual goop to avoid multiple inclusion and a - // header comment to discourage direct editing and point the user at the CrstTypes.def file instead - // (where all will be explained in greater detail). - writer.WriteLine("//"); - writer.WriteLine("// Licensed to the .NET Foundation under one or more agreements."); - writer.WriteLine("// The .NET Foundation licenses this file to you under the MIT license."); - writer.WriteLine("// See the LICENSE file in the project root for more information."); - writer.WriteLine("//"); - writer.WriteLine(); - writer.WriteLine("#ifndef __CRST_TYPES_INCLUDED"); - writer.WriteLine("#define __CRST_TYPES_INCLUDED"); - writer.WriteLine(); - writer.WriteLine("// **** THIS IS AN AUTOMATICALLY GENERATED HEADER FILE -- DO NOT EDIT!!! ****"); - writer.WriteLine(); - writer.WriteLine("// This file describes the range of Crst types available and their mapping to a numeric level (used by the"); - writer.WriteLine("// runtime in debug mode to validate we're deadlock free). To modify these settings edit the"); - writer.WriteLine("// file:CrstTypes.def file and run the clr\\bin\\CrstTypeTool utility to generate a new version of this file."); - writer.WriteLine(); - - // Emit the CrstType enum to define a value for each crst type (along with the kNumberOfCrstTypes - // constant). - writer.WriteLine("// Each Crst type is declared as a value in the following CrstType enum."); - writer.WriteLine("enum CrstType"); - writer.WriteLine("{"); - for (int i = 0; i < crsts.Length; i++) - writer.WriteLine(" Crst" + crsts[i].Name + " = " + i.ToString() + ","); - writer.WriteLine(" kNumberOfCrstTypes = " + crsts.Length.ToString()); - writer.WriteLine("};"); - writer.WriteLine(); - - // This is the end of the regular part of the header included by most files. - writer.WriteLine("#endif // __CRST_TYPES_INCLUDED"); - writer.WriteLine(); - - // There is a second section of the header intended for inclusion only by vm\Crst.cpp. This contains - // some data tables used to map crst type to rank or name. We could instead define two separate - // headers, but on the whole it seems simpler to do it this way. - writer.WriteLine("// Define some debug data in one module only -- vm\\crst.cpp."); - writer.WriteLine("#if defined(__IN_CRST_CPP) && defined(_DEBUG)"); - writer.WriteLine(); - - // Emit the crst type to rank mapping table. - writer.WriteLine("// An array mapping CrstType to level."); - writer.WriteLine("int g_rgCrstLevelMap[] ="); - writer.WriteLine("{"); - foreach (CrstType crst in crsts) - writer.WriteLine(" " + crst.Level + ",\t\t\t// Crst" + crst.Name); - writer.WriteLine("};"); - writer.WriteLine(); - - // Emit the crst type to name mapping table. - writer.WriteLine("// An array mapping CrstType to a stringized name."); - writer.WriteLine("LPCSTR g_rgCrstNameMap[] ="); - writer.WriteLine("{"); - foreach (CrstType crst in crsts) - writer.WriteLine(" \"Crst" + crst.Name + "\","); - writer.WriteLine("};"); - writer.WriteLine(); - - // Emit the constant Crst.cpp uses to record an unordered rank. - writer.WriteLine("// Define a special level constant for unordered locks."); - writer.WriteLine("#define CRSTUNORDERED (-1)"); - writer.WriteLine(); - - // Emit a couple of inline helpers to map type to rank or name (and validate the type while they're at - // it). - writer.WriteLine("// Define inline helpers to map Crst types to names and levels."); - writer.WriteLine("inline static int GetCrstLevel(CrstType crstType)"); - writer.WriteLine("{"); - writer.WriteLine(" LIMITED_METHOD_CONTRACT;"); - writer.WriteLine(" _ASSERTE(crstType >= 0 && crstType < kNumberOfCrstTypes);"); - writer.WriteLine(" return g_rgCrstLevelMap[crstType];"); - writer.WriteLine("}"); - writer.WriteLine("inline static LPCSTR GetCrstName(CrstType crstType)"); - writer.WriteLine("{"); - writer.WriteLine(" LIMITED_METHOD_CONTRACT;"); - writer.WriteLine(" _ASSERTE(crstType >= 0 && crstType < kNumberOfCrstTypes);"); - writer.WriteLine(" return g_rgCrstNameMap[crstType];"); - writer.WriteLine("}"); - writer.WriteLine(); - - // And that's the end of the second section of the header file. - writer.WriteLine("#endif // defined(__IN_CRST_CPP) && defined(_DEBUG)"); - - writer.Close(); - stream.Close(); - } - - // Peform checking of the Crst type definitions we've read just read. Various forms of logic error are - // scanned for including cycles in the dependency graph. Returns true if no errors are found. If false is - // returned a descriptive error message will have already been written to the console. - bool ValidateCrsts() - { - // Look at each Crst type definition in turn. - foreach (CrstType crst in m_crsts.Values) - { - // Catch Crst types that are referenced but never defined. - if (!crst.Defined) - { - Console.WriteLine(String.Format("Error: CrstType 'Crst{0}' is referenced without being defined", - crst.Name)); - return false; - } - - // Catch the use of the 'Unordered' attribute alongside the 'AcquiredBefore' attribute (which - // indicates an ordering). - if (crst.Level == CrstType.CrstUnordered && (crst.AcquiredBeforeList.Count > 0 || - crst.Group != null)) - { - Console.WriteLine(String.Format("Error: CrstType 'Crst{0}' is declared as both unordered and acquired before 'Crst{1}'", - crst.Name, crst.AcquiredBeforeList[0].Name)); - return false; - } - - // Catch the use of the 'Unordered' attribute alongside the 'SameLevelAs' attribute (which - // indicates an ordering). - if (crst.Level == CrstType.CrstUnordered && crst.Group != null) - { - Console.WriteLine(String.Format("Error: CrstType 'Crst{0}' is declared as both unordered and in the same level as another CrstType", - crst.Name)); - return false; - } - - // Catch the simple cycle where the Crst type depends on itself. - if (crst.AcquiredBeforeList.Contains(crst)) - { - Console.WriteLine(String.Format("Error: CrstType 'Crst{0}' is declared as being acquired before itself", - crst.Name)); - return false; - } - - // Look for deeper cycles using a recursive algorithm in 'FindCycle()'. - List cycleList = new List(); - if (FindCycle(crst, crst, cycleList)) - { - Console.WriteLine(String.Format("Error: CrstType 'Crst{0}' is involved in a dependency cycle with the following CrstTypes:", - crst.Name)); - foreach (CrstType cycleCrst in cycleList) - Console.WriteLine(String.Format(" Crst{0}", cycleCrst.Name)); - return false; - } - } - - // Perform normalization of each set of Crst types that are included in the same group (i.e. have a - // 'SameLevelAs' relationship). Normalization means that each Crst type in a group will have exactly - // the same set of dependency rules as all the others. - CrstTypeGroup.NormalizeAllRules(); - - // The normalization process could have introduced cycles in the dependency graph so run the cycle - // detection pass again. We do separate passes like this since normalizing can lead to less intuitive - // error messages if a cycle is found: so if the cycle exists before normalization takes place we want - // to generate an error message then. - foreach (CrstType crst in m_crsts.Values) - { - List cycleList = new List(); - if (FindCycle(crst, crst, cycleList)) - { - Console.WriteLine(String.Format("Error: CrstType 'Crst{0}' is involved in a dependency cycle with the following CrstTypes:", - crst.Name)); - foreach (CrstType cycleCrst in cycleList) - Console.WriteLine(String.Format(" Crst{0}", cycleCrst)); - Console.WriteLine("Note that the cycle was detected only after 'SameLevelAs' processing was performed so some CrstType dependencies are implied by peer CrstTypes"); - return false; - } - } - - return true; - } - - // Recursively determine if a cycle exists in the Crst type dependency graph rooted at the 'rootCrst' - // type. The 'currCrst' indicates the next dependency to be examined (it will be the same as the - // 'rootCrst' when we're first called). The 'cycleList' argument contains a list of Crst types we've - // already examined in this branch of the algorithm and serves both to avoid checking the same node twice - // and to provide a list of the involved Crst types should a cycle be detected. - // Note that this algorithm is not designed to detect general cycles in the graph, only those that involve - // the 'rootCrst' directly. This is somewhat inefficient but gives us a simple way to generate clear error - // messages. - bool FindCycle(CrstType rootCrst, CrstType currCrst, List cycleList) - { - // Add the current Crst type to the list of those we've seen. - cycleList.Add(currCrst); - - // Look through all the dependencies of the current Crst type. - foreach (CrstType childCrst in currCrst.AcquiredBeforeList) - { - // If we find a reference back to the root Crst type then we've found a cycle. Start backing out - // from the recursion (keeping the list of nodes we visited intact) by returning true. - if (childCrst == rootCrst) - return true; - - // Otherwise iterate over the dependencies of the current node and for each one that we haven't - // already seen and recursively extend the search. - if (!cycleList.Contains(childCrst)) - if (FindCycle(rootCrst, childCrst, cycleList)) - return true; - } - - // Didn't find any cycles involving the root and this node; remove this node from the potential cycle - // list and return up to our caller indicating such. - cycleList.RemoveAt(cycleList.Count - 1); - - return false; - } - - // Topologically sort all the Crsts so we can assign a total ordering to them (in the form of a numeric - // ranking). Ranks start from 0 (Crst types that may be acquired at any time) and increment from there - // (Crst types that may only be acquired if a lower type is not already held). - // **** NOTE: The leveling process is destructive in that we will lose all dependency information from the - // Crst type definitions during the course of the algorithm. - void LevelCrsts() - { - // Note that Crst type dependency rules have been normalized (by the input parser) so that all - // AcquiredBefore/AcquiredAfter relationships have been reduced to AcquiredBefore relationships (i.e. - // any rule of the form "A AcquiredAfter B" has been converted to "B AcquiredBefore A". Any - // normalization makes the algorithm easier to program, but a normaliztion to AcquiredBefore - // relationships was chosen since it makes it particularly easy to implement an algorithm that assigns - // ranks beginning with zero and moving up to an arbitrary level. Any type that doesn't have any - // AcquiredBefore dependencies can always be ranked at a lower level than any remaining unranked types - // by definition and from this we can derive a simple iterative process to rank all the crst types. - - // Calculate how many Crst types we have left to rank (some are not included in this step because - // they've been marked as 'Unordered' in the input file). - int unsorted = 0; - foreach (CrstType crst in m_crsts.Values) - if (crst.Level == CrstType.CrstUnassigned) - unsorted++; - - // The ranking level we're going to assign to Crst types on the next pass of the algorithm. - int currLevel = 0; - - // Iterate while we still have Crst types left to rank. On each pass we'll assign a rank to those - // types that no longer have any dependencies forcing them to have a higher rank and then remove - // dependency rules involving those newly ranked types from the remaining types. - while (unsorted > 0) - { - // Record a flag indicating whether we manage to assign a rank to at least one Crst type on this - // pass. If we ever fail to do this we've hit a cycle (this is just paranoia, the Crst declaration - // validation performed in ValidateCrsts() should have detected such a cycle first). - bool madeProgress = false; - - // If we spot any types that are in a group (SameLevelAs relationship) then we defer assigning a - // rank till we've dealt with any non-group types (we wish to always place type groups in their - // very own rank else the Crst rank violation detection code won't detect violations between - // members of the group and singleton types that happened to be assigned rank on the same pass). - List deferredGroups = new List(); - - // Scan through all the Crst types. - foreach (CrstType crst in m_crsts.Values) - { - // Skip those types that already have a rank assigned. - if (crst.Level != CrstType.CrstUnassigned) - continue; - - // We're looking for Crst types that no longer have any types that can be acquired while they - // are already held. This indicates that it's safe to assign the current rank to them (since - // there are no remaining dependencies that need to be ranked first (i.e. with a lower rank - // value than this type). - if (crst.AcquiredBeforeList.Count == 0) - { - if (crst.Group == null) - { - // If this type is not part of the group we can go and assign the rank right away. - crst.Level = currLevel; - madeProgress = true; - unsorted--; - } - else if (!deferredGroups.Contains(crst.Group)) - // Otherwise we'll defer ranking this group member until all the singletons are - // processed. - deferredGroups.Add(crst.Group); - } - } - - // We've gone through the entire collection of Crst types and assigned the current rank level to - // any singleton Crst types that qualify. Now deal with any group members we detected (it's - // possible that more than one group qualifies for ranking at this level but we need to be careful - // to assign distinct rank values to each group to avoid hiding lock rank violations (since group - // members are always allowed to be acquired alongside any other type with the same rank value). - // Iterate over each distinct group that we found in this pass. - foreach (CrstTypeGroup group in deferredGroups) - { - // Look at our progress flag here. If it is false then we didn't have any singleton Crst types - // ranked at this level and we haven't processed any other groups at this level either. Thus - // we can rank this group at the current level. Otherwise at least one type was already ranked - // with this level so we need to increment to a new, distinct level to avoid ranking - // ambiguity. - if (madeProgress) - currLevel++; - - // Iterate through each Crst type that is a member of this group assigning them the (same) - // current rank. - foreach (CrstType crst in group.Members) - { - // Double check that each member has the same dependencies (i.e. they should all be empty - // by now). There should be no way that this error should ever occur, it's just paranoia - // on my part. - if (crst.AcquiredBeforeList.Count != 0) - throw new Exception("Internal error: SameLevel CrstTypes with differing rulesets"); - - crst.Level = currLevel; - unsorted--; - } - - // Once we've processed at least one group we've made progress this iteration. - madeProgress = true; - } - - // If we didn't manage to assign rank to at least one Crst type then we're not going to do any - // better next iteration either (because no state was updated in this iteration). This should only - // occur in the presence of a dependency cycle and we shouldn't get that here after a successful - // call to ValidateCrsts(), so this check is pure paranoia. - if (!madeProgress) - { - Console.WriteLine(String.Format("{0} unsorted remain", unsorted)); - throw new Exception("Cycle detected trying to assign level " + currLevel.ToString()); - } - - // Loop through all the unranked Crsts types and remove any AcquiredBefore relationships that - // involve types we've already leveled (since those types, by definition, have already been - // assigned a lower rank). - foreach (CrstType crst in m_crsts.Values) - { - if (crst.Level != CrstType.CrstUnassigned) - continue; - List prunedCrsts = crst.AcquiredBeforeList.FindAll(Unleveled); - crst.AcquiredBeforeList = prunedCrsts; - } - - // Done with this rank level, move to the next. - currLevel++; - } - } - - // Predicate method used with List.FindAll() to locate Crst types that haven't had their rank assigned - // yet. - static bool Unleveled(CrstType crst) - { - return crst.Level == CrstType.CrstUnassigned; - } -} - -// Class used to parse a CrstTypes.def file into a dictionary of Crst type definitions. It uses a simple lexer -// that removes comments then forms tokens out of any consecutive non-whitespace characters. An equally simple -// recursive descent parser forms Crst instances by parsing the token stream. -class TypeFileParser -{ - // Remember the input file name and the dictionary we're meant to populate. - string m_typeFileName; - Dictionary m_crsts; - - // Compile regular expressions for detecting comments and tokens in the parser input. - Regex m_commentRegex = new Regex(@"//.*"); - Regex m_tokenRegex = new Regex(@"^(\s*(\S+)\s*)*"); - - // Input is lexed into an array of tokens. We record the index of the token being currently parsed. - Token[] m_tokens; - int m_currToken; - - // Parse the given file into Crst type definitions and place these definitions in the dictionary provided. - // Syntax errors are signalled via ParseError derived exceptions. - public void ParseFile(string typeFileName, Dictionary crsts) - { - m_typeFileName = typeFileName; - m_crsts = crsts; - - // Lex the file into tokens. - InitTokenStream(); - - // Parse the tokens according to the grammar set out at the top of this file. - // Loop until we have no further tokens to process. - while (!IsEof()) - { - // Grab the next token. - Token token = NextToken(); - - // We're at the top level, so the token had better be 'Crst'. - if (token.Id != KeywordId.Crst) - throw new UnexpectedTokenError(token, KeywordId.Crst); - - // OK, parse the rest of this single Crst type definition. - ParseCrst(); - } - } - - // Parse a single Crst type definition. - void ParseCrst() - { - // The next token had better be an identifier (the Crst type name). - Token token = NextToken(); - if (token.Id != KeywordId.Id) - throw new UnexpectedTokenError(token, KeywordId.Id); - - // The Crst instance might already exist in the dictionary (forward references to a Crst type cause - // these entries to auto-vivify). But in that case the entry better not be marked as 'Defined' which - // would indicate a double declaration. - CrstType crst; - if (m_crsts.ContainsKey(token.Text)) - { - crst = m_crsts[token.Text]; - if (crst.Defined) - throw new ParseError(String.Format("Duplicate definition for CrstType '{0}'", token.Text), token); - } - else - { - // Otherwise this Crst type hasn't been seen thus far so we allocate a new instance and add it to - // the dictionary. - crst = new CrstType(token.Text); - m_crsts.Add(crst.Name, crst); - } - - // We're defining, not just referencing this type. - crst.Defined = true; - - // Parse any attributes inside this definition (until we see an 'End' token). - bool parsingCrst = true; - while (parsingCrst) - { - // Get the next token. Either some attribute keyword or 'End'. - token = NextToken(); - List list; - - switch (token.Id) - { - - case KeywordId.AcquiredBefore: - // Simply parse the following list of Crst types into the current type's AcquiredBefore list. - ParseList(crst.AcquiredBeforeList); - break; - - case KeywordId.AcquiredAfter: - // AcquiredAfter is trickier. To make the ranking algorithm's life easier we actually - // normalize all rules to the AcquiredBefore form (see LevelCrsts() for the reasoning). So we - // capture the list of Crst types that follow the AcquiredAfter keyword and then append the - // current type to the AcquiredBefore list of each type found. - list = new List(); - ParseList(list); - foreach (CrstType priorCrst in list) - priorCrst.AcquiredBeforeList.Add(crst); - break; - - case KeywordId.SameLevelAs: - // Parse the following list of Crst types them let the CrstTypeGroup class handle the - // resulting updates to the type groups we're currently maintaining. See the comments for the - // CrstTypeGroup class for more details. - list = new List(); - ParseList(list); - foreach (CrstType sameLevelCrst in list) - CrstTypeGroup.Join(crst, sameLevelCrst); - break; - - case KeywordId.Unordered: - crst.Level = CrstType.CrstUnordered; - break; - - case KeywordId.End: - parsingCrst = false; - break; - - default: - throw new UnexpectedTokenError(token, - KeywordId.AcquiredBefore, - KeywordId.AcquiredAfter, - KeywordId.SameLevelAs, - KeywordId.Unordered); - } - } - } - - // Parse a list of Crst type names. Any other token terminates the list (without error and without - // consuming that token from the stream). The list of tokens is returned as a list of corresponding - // CrstTypes (which are auto-vivified in the output dictionary if they haven't been declared yet). - void ParseList(List list) - { - // Parse tokens until we find a non-indentifier. - while (true) - { - Token token = NextToken(); - if (token.Id != KeywordId.Id) - { - // We found the list terminator. Push the non-identifier token back into the stream for our - // caller to parse correctly. - UnwindToken(); - return; - } - - // Look up or add a new CrstType corresponding to this type name. - CrstType crst; - if (m_crsts.ContainsKey(token.Text)) - crst = m_crsts[token.Text]; - else - { - crst = new CrstType(token.Text); - m_crsts[crst.Name] = crst; - } - - // Add the type to the output list we're building. - list.Add(crst); - } - } - - // Lex the input file into an array of tokens. - void InitTokenStream() - { - StreamReader file = new StreamReader(m_typeFileName); - int lineNumber = 1; - List tokenList = new List(); - - // Read the file a line at a time. - string line; - while ((line = file.ReadLine()) != null) - { - // Remove comments from the current line. - line = m_commentRegex.Replace(line, ""); - - // Match all contiguous non-whitespace characters as individual tokens. - Match match = m_tokenRegex.Match(line); - if (match.Success) - { - // For each token captured build a token instance and record the token text and the file, line - // and column at which it was encountered (these latter in order to produce useful syntax - // error messages). - CaptureCollection cap = match.Groups[2].Captures; - for (int i = 0; i < cap.Count; i++) - tokenList.Add(new Token(m_typeFileName, cap[i].Value, lineNumber, cap[i].Index)); - } - - lineNumber++; - } - - // Record the list of tokens we captured as an array and reset the index of the next token to be - // handled by the parser. - m_tokens = tokenList.ToArray(); - m_currToken = 0; - } - - // Have we run out of tokens to parse? - bool IsEof() - { - return m_currToken >= m_tokens.Length; - } - - // Get the next token and throw an exception if we ran out. - Token NextToken() - { - if (m_currToken >= m_tokens.Length) - throw new UnexpectedEofError(); - return m_tokens[m_currToken++]; - } - - // Push the last token parsed back into the stream. - void UnwindToken() - { - if (m_currToken <= 0) - throw new InvalidOperationException(); - m_currToken--; - } - - // The various keywords we can encounter (plus Id for identifiers, which are currently always Crst type - // names). - internal enum KeywordId - { - Id, - Crst, - End, - AcquiredBefore, - AcquiredAfter, - Unordered, - SameLevelAs, - } - - // Class encapsulating a single token captured from the input file. - internal class Token - { - // Hash of keyword text to enum values. - static Dictionary s_keywords; - - // The characters comprising the text of the token from the input file. - string m_text; - - // Where the token was found (for error messages). - string m_file; - int m_line; - int m_column; - - // The ID of the keyword this token represents (or KeywordId.Id). - KeywordId m_id; - - // Static class initialization. - static Token() - { - // Populate the keyword hash. No sense building complex finite state machines to improve the - // efficiency of keyword lexing here since the input file (and keyword set) is never going to be - // big enough to justify the extra work. - s_keywords = new Dictionary(); - s_keywords.Add("crst", KeywordId.Crst); - s_keywords.Add("end", KeywordId.End); - s_keywords.Add("acquiredbefore", KeywordId.AcquiredBefore); - s_keywords.Add("acquiredafter", KeywordId.AcquiredAfter); - s_keywords.Add("unordered", KeywordId.Unordered); - s_keywords.Add("samelevelas", KeywordId.SameLevelAs); - } - - public Token(string file, string text, int line, int column) - { - m_file = file; - m_text = text; - m_line = line; - m_column = column; - - // Map token text to keyword ID. True keywords (not identifiers) are case insensitive so normalize - // the text to lower case before performing the keyword hash lookup. - string canonName = m_text.ToLower(); - if (s_keywords.ContainsKey(canonName)) - m_id = s_keywords[canonName]; - else - m_id = KeywordId.Id; - } - - public string Text {get { return m_text; }} - public string Location {get { return String.Format("{0} line {1}, column {2}", m_file, m_line, m_column); }} - public KeywordId Id {get { return m_id; }} - } - - // Base class for all syntax errors reported by the parser. - internal class ParseError : Exception - { - // A raw error message. - public ParseError(string message) - : base(message) - {} - - // An error message tagged with a file, line and column (coming from an error token). - public ParseError(string message, Token errorToken) - : base(String.Format("{0}: {1}", errorToken.Location, message)) - {} - - // Produce a textual name for the given keyword type. - protected static string IdToName(KeywordId id) - { - if (id == KeywordId.Id) - return "a CrstType name"; - return String.Format("'{0}'", id.ToString()); - } - } - - // Syntax error used when an unexpected token is encountered which further lists the valid tokens that - // would otherwise have been accepted. - internal class UnexpectedTokenError : ParseError - { - // Produce an unexpected token message with a file, line and column coming from an error token and - // optionally the names of zero or more tokens that would have been accepted. - public UnexpectedTokenError(Token errorToken, params KeywordId[] expected) - : base(FormatErrorMessage(errorToken, expected)) - {} - - static string FormatErrorMessage(Token errorToken, KeywordId[] expected) - { - StringBuilder message = new StringBuilder(String.Format("Unexpected token '{0}' at {1}", - errorToken.Text, errorToken.Location)); - if (expected.Length == 0) - { - } - else if (expected.Length == 1) - { - message.Append(String.Format("; expected {0}", IdToName(expected[0]))); - } - else - { - message.Append("; expected one of "); - for (int i = 0; i < expected.Length - 1; i++) - message.Append(String.Format("{0}, ", IdToName(expected[i]))); - message.Append(IdToName(expected[expected.Length - 1])); - - } - - return message.ToString(); - } - } - - // Syntax error used when we unexpectedly ran out of tokens. - internal class UnexpectedEofError : ParseError - { - public UnexpectedEofError() - : base("Unexpected end of file") - {} - } -} - -// This class represents an instance of a Crst type. These are unqiuely identified by case-sensitive name (the -// same as the enum name used in vm code, minus the 'Crst' prefix). -class CrstType : IComparable -{ - // Special level constants used to indicate unordered Crst types or those types we haven't gotten around - // to ranking yet. - public static readonly int CrstUnordered = -1; - public static readonly int CrstUnassigned = -2; - - // Name of the type, e.g. "AppDomainCache" for the CrstAppDomainCache type. - string m_name; - - // The numeric ranking assigned to this type. Starts as CrstUnassigned and then becomes either - // CrstUnordered (while parsing the input file) or a number >= 0 (during LevelCrsts()). - int m_level; - - // List of Crst types that can be legally acquired while this one is held. (AcquiredAfter relationships - // are by switching the terms and adding to the second type's AcquiredBefore list). - List m_acquiredBeforeCrsts; - - // Either null if this Crst type is not in (or has not yet been determined to be in) a SameLevelAs - // relationship or points to a CrstTypeGroup that records all the sibling types at the same level (that - // have been discovered thus far during parsing). - CrstTypeGroup m_group; - - // Set once a definition for this type has been discovered. Used to detect double definitions and types - // referenced without definitions. - bool m_defined; - - public CrstType(string name) - { - m_name = name; - m_level = CrstUnassigned; - m_acquiredBeforeCrsts = new List(); - m_group = null; - m_defined = false; - } - - public string Name {get { return m_name; }} - public int Level {get { return m_level; } set { m_level = value; }} - public List AcquiredBeforeList {get { return m_acquiredBeforeCrsts; } set { m_acquiredBeforeCrsts = value; }} - public CrstTypeGroup Group {get { return m_group; } set { m_group = value; }} - public bool Defined {get {return m_defined; } set { m_defined = value; }} - - // Helper used to sort CrstTypes. The sort order is lexical based on the type name. - public int CompareTo(object other) - { - return m_name.CompareTo(((CrstType)other).m_name); - } -} - -// Every time a SameLevelAs relationship is used we need to be careful to keep track of the transitive closure -// of all types bound in the relationship. That's because such a relationship impacts the other dependency -// rules (each member of a SameLevelAs group must behave as though it has exactly the same dependency rules as -// all the others). Identifying all the members is tricky because "A SameLevelAs B" and "B SameLevelAs C" -// implies "A SameLevelAs C". So we use a separate tracking structure, instances of the CrstTypeGroup type, to -// do the bookkeeping for us. Each Crst type belongs to either zero or one CrstTypeGroups. As we find new -// SameLevelAs relationships we create new groups, add types to existing groups or merge groups (as previous -// distinct groups are merged by the discovery of a SameLevelAs relationship that links them). By the time -// parsing has finished we are guaranteed to have discovered all the distinct, disjoint groups and to have -// fully populated them with the transitive closure of all related types. We can them normalize all groups -// members so they share the same AcquiredBefore relationships. -class CrstTypeGroup -{ - // We record every group that has been formed so far. This makes normalizing all groups easier. - static List s_groups = new List(); - - // Crst types that are members of the current group. There are no duplicates in this list. - List m_members = new List(); - - // Declare a SameLevelAs relationship between the two Crst types given. Groups will be assigned, created - // or merged as required to maintain our guarantees (each CrstType is a member of at most one group and - // all CrstTypes involved in the same transitive closure of a SameLevelAs relationship are members of one - // group). - public static void Join(CrstType crst1, CrstType crst2) - { - CrstTypeGroup group; - - if (crst1 == crst2) - { - // In this case the type refers to itself. Create a singleton group for this type if it doesn't - // already exist. - if (crst1.Group == null) - { - group = new CrstTypeGroup(); - group.m_members.Add(crst1); - - s_groups.Add(group); - - crst1.Group = group; - } - } - else if (crst1.Group == null && crst2.Group == null) - { - // Neither types belong to a group already. So we can create a new one and add both types to it. - group = new CrstTypeGroup(); - group.m_members.Add(crst1); - group.m_members.Add(crst2); - - s_groups.Add(group); - - crst1.Group = group; - crst2.Group = group; - } - else if (crst1.Group == null) - { - // The first type doesn't belong to a group yet but the second does. So we can simply add the - // first type to the second group. - group = crst2.Group; - group.m_members.Add(crst1); - - crst1.Group = group; - } - else if (crst2.Group == null) - { - // As for the case above but the group/no-group positions are reversed. - group = crst1.Group; - group.m_members.Add(crst2); - - crst2.Group = group; - } - else if (crst1.Group != crst2.Group) - { - // Both types belong to different groups so we'll have to merge them. Add the members of group 2 - // to group 1 and throw away group 2. - group = crst1.Group; - CrstTypeGroup absorbGroup = crst2.Group; - foreach (CrstType crst in absorbGroup.m_members) - { - group.m_members.Add(crst); - crst.Group = group; - } - - s_groups.Remove(absorbGroup); - } - - // The only case left is when both types are already in the same group and there's no work needed in - // this case. - } - - // Normalize all the groups we created during parsing. See below for the definition of normalization. - public static void NormalizeAllRules() - { - foreach (CrstTypeGroup group in s_groups) - group.NormalizeRules(); - } - - // Normalize this group. This involves adjusting the AcquiredBefore list of each member to be the union of - // all such rules within the group. This step allows us to detect cycles in the dependency graph that - // would otherwise remain hidden if we only examined the unnormalized AcquiredBefore rules. - void NormalizeRules() - { - // This local will contain the union of all AcquiredBefore rules. - List acquiredBeforeList = new List(); - - // Iterate through each member of the group. - foreach (CrstType crst in m_members) - { - // Add each AcquiredBefore rule we haven't already seen to the union. - foreach (CrstType afterCrst in crst.AcquiredBeforeList) - if (!acquiredBeforeList.Contains(afterCrst)) - acquiredBeforeList.Add(afterCrst); - } - - // Reset each member's AcquiredBefore list to a copy of the union we calculated. Note it's important - // to make a (shallow) copy because the ranking process modifies this list and so a shared copy would - // cause unexpected results. - foreach (CrstType crst in m_members) - crst.AcquiredBeforeList = acquiredBeforeList.GetRange(0, acquiredBeforeList.Count); - } - - public List Members {get { return m_members; }} -} diff --git a/src/inc/CrstTypes.def b/src/inc/CrstTypes.def deleted file mode 100644 index f8632e047..000000000 --- a/src/inc/CrstTypes.def +++ /dev/null @@ -1,793 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -// -// This file is used to describe the different types of Crst and their dependencies on other Crst types (in -// terms of which types may be legally held while others are acquired). -// -// The CrstTypeTool utility is used to parse this file, verify that there are no logical inconsistencies (such -// as a cycle in the dependencies) and generate an enum value and numerical ranking for each type. This -// ranking is used by the runtime (in checked builds) to verify that none of the rules described below are -// violated (which could lead to a deadlock). -// -// When you add a new Crst type you need to be aware of which Crst types may be already held when your Crst is -// acquired and which other types may be subsequently acquired. You can then add a Crst definition to this -// file and annotate it with those dependencies. Running CrstTypeTool will check to see if this introduces a -// potential deadlock problem and if everything checks out will generate a new version of -// file:CrstTypes.h (be sure to check this file out from TFS/SD before running CrstTypeTool). -// -// The format of this file is a very simple language. Comments are introduced with '//' and continue to the -// end of the line. Keywords are case insensitive (Crst type names, however, are case sensitive since they'll -// be translated directly to C++ enum values). Crst type names are used without the 'Crst' prefix used in C++ -// code (e.g. CrstAppDomainCache is referred to as AppDomainCache). The following words are reserved keywords -// and may not be used as the names of Crst types: -// Crst -// End -// AcquiredBefore -// AcquiredAfter -// Unordered -// SameLevelAs -// -// Each Crst type definition has the following format (where [] indicates optional and ... indicates zero or -// more repetitions): -// Crst -// [AcquiredBefore ...] -// [AcquiredAfter ...] -// [SameLevelAs ...] -// [Unordered] -// End -// -// For example: -// Crst Foo -// AcquiredBefore Bar -// AcquiredAfter Zob Baz -// SameLevelAs Foo -// End -// -// This introduces a new Crst type Foo (CrstFoo inside the runtime). This type may be legally acquired when -// the current thread holds Crst instances of type Zob, Bar or even other instances of Foo. While Foo is held -// it is legal to acquire Crsts of type Bar. Assuming that this definition does not introduce any dependency -// cycles, CrstTypeTool will assign a numeric rank to CrstFoo that maximizes the chance that any other Crst -// type interaction you didn't explicitly specify (e.g. holding Foo while taking a Crst of type Wibble) will -// generate a ranking violation assert in the checked build. -// -// Note that the following set of definitions: -// Crst A AcquiredBefore B End -// Crst B End -// -// Crst A End -// Crst B AcquiredAfter A End -// -// Crst A AcquiredBefore B End -// Crst B AcquiredAfter A End -// -// are all equivalent. You are free to use whichever variant seems clearest to you (CrstTypeTool will tell you -// if you introduce conflicting rules). Similarly "A SameLevelAs B" implies "B SameLevelAs A". The initial -// contents of this file uses AcquiredBefore in preference to AcquiredAfter purely because it was generated -// automatically by a profiling mechanism (the initial rules were seeded from observations of Crst usage while -// running our test suites). Feel free to add meaningful comments to existing rules if you feel they can -// usefully clarify the reasons for particular dependencies. -// -// CrstTypeTool is a csScript file at file:..\..\bin\CrstTypeTool.csScript. Simply typing "CrstTypeTool" from a -// clrenv command window prompt should rebuild file:CrstTypes.h from the current CrstTypes.def (again, -// remember to check out CrstTypes.h first). -// Note: If you cannot run the script from command line, because of this error: -// Script language type is unsupported. -// Use /? for more help on usage. -// Or because .csscript extension is not associated with anything on your machine, -// Then use "csc.exe CrstTypeTool.csscript" from ClrEnv environment and run the resulting executable. -// -// Each Crst type definition is currently in alphabetical order. Please maintain this convention. -// - -Crst AllowedFiles - AcquiredBefore JumpStubCache UniqueStack -End - -Crst AppDomainCache - AcquiredBefore FusionBindContext FusionLoadContext LoaderHeap UniqueStack UnresolvedClassLock -End - -Crst AppDomainHandleTable - AcquiredBefore AvailableParamTypes HandleTable IbcProfile SyncBlockCache SystemDomainDelayedUnloadList - ThreadStore SystemDomain -End - -Crst ArgBasedStubCache -End - -Crst AssemblyIdentityCache -End - -Crst AssemblyLoader - AcquiredBefore DeadlockDetection UniqueStack -End - -Crst AvailableClass - AcquiredBefore LoaderHeap -End - -Crst AssemblyDependencyGraph -End - -Crst AvailableParamTypes - AcquiredBefore FusionBindContext FusionLoadContext IbcProfile LoaderHeap -End - -Crst BaseDomain - AcquiredBefore LoaderHeap UniqueStack -End - -Crst CCompRC - Unordered -End - -Crst Cer - AcquiredBefore JumpStubCache UniqueStack -End - -Crst ClassFactInfoHash - AcquiredBefore SyncBlockCache ThreadStore -End - -Crst ClassInit - AcquiredBefore DeadlockDetection IbcProfile - SameLevelAs Jit -End - -Crst ClrNotification - Unordered -End - -Crst CrstCLRPrivBinderLocalWinMDPath -End - -Crst CLRPrivBinderMaps -End - -Crst CLRPrivBinderMapsAdd - AcquiredBefore CLRPrivBinderMaps -End - -Crst COMWrapperCache - AcquiredBefore HandleTable UniqueStack -End - -Crst ConnectionNameTable -End - -Crst Contexts - AcquiredBefore AvailableParamTypes Cer ClassInit DeadlockDetection DomainLocalBlock FuncPtrStubs - GlobalStrLiteralMap Jit LoaderHeap ModuleLookupTable RWLock SigConvert SingleUseLock - StubUnwindInfoHeapSegments SyncBlockCache TypeIDMap UnresolvedClassLock FusionClosure -End - -Crst CoreCLRBinderLog - Unordered -End - -Crst CSPCache - AcquiredBefore JumpStubCache -End - -Crst DeadlockDetection -End - -Crst DebuggerController - // AcquiredBefore DebuggerHeapLock DebuggerJitInfo LoaderHeap - - // See bug: 581892. This has a conflict with CrstInstMethodHashTableRanking. - // The controller logic will be moved to OOP in V3, and so this lock will no longer be necessary. - // Fixing this in-proc would be difficult, and it would all be throwaway as we go oop. - Unordered -End - -// This is a leaf debugger lock. -Crst DebuggerFavorLock - AcquiredAfter DebuggerJitInfo DebuggerMutex -End - -// This is the lock used by the DebuggerHeapExecutableMemoryAllocator for allocating/freeing memory. -Crst DebuggerHeapExecMemLock -End - -// Debugger Heap lock is the smallest of the debugger locks. -Crst DebuggerHeapLock - AcquiredAfter DebuggerFavorLock DebuggerJitInfo DebuggerMutex - // Disabled per bug 581892 - // AcquiredAfter DebuggerController -End - -Crst DebuggerJitInfo - AcquiredBefore DebuggerHeapLock -End - -// This is the major debugger lock. -// It's the largest of the debugger locks. -Crst DebuggerMutex - AcquiredBefore AvailableParamTypes ConnectionNameTable - DynamicIL LoaderHeap ModuleLookupTable ThreadStore - - // Disabled per bug 581892 - // AcquiredBefore DebuggerController - AcquiredBefore DebuggerHeapLock DebuggerJitInfo - -End - -// This lock is used only for testing data consistency (see code:DataTest::TestDataSafety) -// and is released before taking any other lock except for CrstDataTest2 -Crst DataTest1 - AcquiredAfter DebuggerMutex -End - -// This lock is used only for testing data consistency (see code:DataTest::TestDataSafety) -// and is released before taking any other lockCrst DataTest2 -Crst DataTest2 - AcquiredAfter DataTest1 -End - - -Crst DbgTransport -End - -Crst DelegateToFPtrHash -End - -Crst DomainLocalBlock - AcquiredBefore AppDomainHandleTable IbcProfile LoaderHeap SystemDomainDelayedUnloadList UniqueStack -End - -Crst DynamicIL -End - -Crst DynamicMT - AcquiredBefore IbcProfile -End - -Crst DynLinkZapItems - AcquiredBefore LoaderHeap -End - -Crst EventStore -End - -Crst Exception -End - -Crst ExecuteManLock - AcquiredBefore UniqueStack -End - -Crst ExecuteManRangeLock -End - -Crst FCall - AcquiredBefore LoaderHeap -End - -Crst RetThunkCache - AcquiredBefore LoaderHeap -End - -Crst FriendAccessCache - AcquiredBefore JumpStubCache UniqueStack -End - -Crst FuncPtrStubs - AcquiredBefore IbcProfile LoaderHeap UniqueStack CodeFragmentHeap JumpStubCache PatchEntryPoint -End - -Crst FusionAppCtx - AcquiredBefore FusionPolicyConfigPool FusionSingleUse FusionAssemblyDownload -End - -Crst FusionAssemblyDownload - AcquiredBefore FusionDownload UniqueStack -End - -Crst FusionBindResult -End - -Crst FusionClb -End - -Crst FusionClosure - AcquiredBefore FusionBindContext FusionLoadContext FusionAppCtx FusionClosureGraph DomainLocalBlock ModuleFixup -End - -Crst FusionClosureGraph - AcquiredBefore FusionAppCtx FusionBindContext FusionLoadContext -End - -Crst FusionConfigSettings -End - -Crst FusionDownload -End - -Crst FusionLoadContext - AcquiredBefore PEImage -End - -Crst FusionBindContext - AcquiredBefore PEImage -End - -Crst FusionLog - AcquiredBefore IbcProfile UniqueStack -End - -Crst FusionWarningLog - AcquiredBefore FusionBindContext FusionLoadContext FusionLog -End - -Crst FusionNgenIndex - AcquiredBefore SystemDomainDelayedUnloadList -End - -Crst FusionNgenIndexPool - AcquiredBefore SystemDomainDelayedUnloadList -End - -Crst FusionPcyCache -End - -Crst FusionPolicyConfigPool - AcquiredBefore UniqueStack -End - -Crst FusionSingleUse - AcquiredBefore PEImage -End - -Crst FusionIsoLibInit -End - -Crst NativeBinderInit - Unordered -End - -Crst NativeImageCache - Unordered -End - -Crst GCCover - AcquiredBefore LoaderHeap -End - -Crst GCMemoryPressure -End - -Crst GlobalStrLiteralMap - AcquiredBefore HandleTable IbcProfile SyncBlockCache SystemDomainDelayedUnloadList ThreadStore UniqueStack -End - -Crst HandleTable - SameLevelAs HandleTable -End - -Crst HostAssemblyMap -End - -Crst HostAssemblyMapAdd - AcquiredBefore HostAssemblyMap -End - -Crst IbcProfile -End - -Crst IJWFixupData - AcquiredBefore FuncPtrStubs IJWHash LoaderHeap -End - -Crst IJWHash -End - -Crst ILStubGen - AcquiredBefore DeadlockDetection UniqueStack -End - -Crst InstMethodHashTable - AcquiredBefore FusionBindContext FusionLoadContext LoaderHeap UniqueStack JumpStubCache -End - -Crst InterfaceVTableMap -End - -Crst Interop - AcquiredBefore AppDomainHandleTable AvailableParamTypes Cer ClassInit DeadlockDetection DomainLocalBlock - HandleTable InstMethodHashTable InteropData JitGenericHandleCache LoaderHeap SigConvert - StubDispatchCache StubUnwindInfoHeapSegments SyncBlockCache TypeIDMap UnresolvedClassLock -End - -Crst InteropData - AcquiredBefore LoaderHeap UniqueStack -End - -Crst IOThreadpoolWorker - AcquiredBefore ThreadIdDispenser ThreadStore -End - -Crst IsJMCMethod -End - -Crst ISymUnmanagedReader - AcquiredBefore PEImagePDBStream UniqueStack JumpStubCache -End - -Crst Jit - AcquiredBefore DeadlockDetection JumpStubCache - SameLevelAs ClassInit -End - -Crst JitGenericHandleCache -End - -Crst JitPerf - Unordered -End - -Crst JumpStubCache - AcquiredBefore ExecuteManRangeLock LoaderHeap SingleUseLock - AcquiredAfter AppDomainCache ExecuteManLock FusionAssemblyDownload FusionNgenIndex FusionNgenIndexPool - ILStubGen SharedBaseDomain ThreadpoolTimerQueue ThreadpoolWaitThreads - TPMethodTable TypeIDMap BaseDomain AssemblyLoader -End - -Crst ListLock - Unordered -End - -// Leaflock leveling, used for crsts that explicitly want to be a leaf lock -Crst LeafLock -End - -Crst LoaderAllocator - AcquiredBefore AppDomainHandleTable HandleTable UniqueStack ThreadStore - AcquiredAfter DomainLocalBlock -End - -Crst LoaderAllocatorReferences - AcquiredBefore LoaderAllocator - AcquiredAfter PendingTypeLoadEntry InstMethodHashTable -End - -Crst AssemblyList - AcquiredAfter LoaderAllocatorReferences ThreadStore AssemblyLoader -End - -Crst LoaderHeap -End - -Crst Mda -End - -Crst MetadataTracker - Unordered -End - -Crst StubCache - AcquiredBefore LoaderHeap -End - -Crst ModIntPairList -End - -Crst Module - AcquiredBefore LoaderHeap UniqueStack -End - -Crst ModuleFixup - AcquiredBefore AppDomainHandleTable GlobalStrLiteralMap IbcProfile SyncBlockCache -End - -Crst ModuleLookupTable - AcquiredBefore LoaderHeap -End - -Crst MUThunkHash -End - -Crst Nls -End - -Crst ObjectList - SameLevelAs ObjectList -End - -Crst OnEventManager -End - -Crst PatchEntryPoint -End - -Crst PEFileSecurityManager -End - -Crst PEImage - AcquiredBefore UniqueStack -End - -Crst ILFingerprintCache - AcquiredBefore PEImage -End - -Crst PEImagePDBStream -End - -Crst PendingTypeLoadEntry - AcquiredBefore AppDomainCache AppDomainHandleTable AssemblyLoader AvailableClass AvailableParamTypes - BaseDomain ClassInit DeadlockDetection DebuggerController DebuggerJitInfo DebuggerMutex - DomainLocalBlock DynLinkZapItems Exception ExecuteManRangeLock FuncPtrStubs - FusionAppCtx FusionAssemblyDownload FusionBindResult FusionClosure FusionDownload - FusionBindContext FusionLoadContext FusionNgenIndex FusionNgenIndexPool FusionPcyCache - FusionPolicyConfigPool FusionSingleUse GlobalStrLiteralMap HandleTable IbcProfile - IJWFixupData IJWHash ISymUnmanagedReader Jit JumpStubCache LoaderHeap ModIntPairList - Module ModuleLookupTable PEImage SecurityStackwalkCache SharedAssemblyCreate - SharedBaseDomain SigConvert SingleUseLock StubDispatchCache StubUnwindInfoHeapSegments - SyncBlockCache SystemDomain ThreadIdDispenser ThreadStore TypeIDMap UnresolvedClassLock - SameLevelAs PendingTypeLoadEntry -End - -Crst PinHandle -End - -// ProfilerGCRefDataFreeList synchronizes access to the profiler API's list of -// free, previously allocated structures that track moved references and -// root references during a GC. -Crst ProfilerGCRefDataFreeList -End - -// ProfilingAPIStatus serializes attempts to transition the global status -// from state to state, and access to the ProfilerDetachInfo structure -// between the thread executing DetachProfiler(), and the DetachThread -// carrying out the evacuation order. -Crst ProfilingAPIStatus -End - -Crst PublisherCertificate -End - -Crst RCWCache - AcquiredBefore IbcProfile LoaderHeap RCWCleanupList -End - -Crst RCWRefCache - AcquiredBefore HandleTable -End - -Crst RCWCleanupList -End - -Crst ReDacl -End - -Crst Reflection - AcquiredBefore LoaderHeap UnresolvedClassLock -End - -// Used to synchronize all rejit information stored in a given AppDomain. One of these -// crsts exist per domain (except the SharedDomain--see below) -Crst ReJITDomainTable - AcquiredBefore LoaderHeap SingleUseLock DeadlockDetection JumpStubCache DebuggerController - AcquiredAfter ReJITGlobalRequest ThreadStore GlobalStrLiteralMap SystemDomain DebuggerMutex -End - -// Same as ReJITDomainTable, but this is for the SharedDomain's ReJitManager. Only -// reason we have a special type for the SharedDomain's ReJitManager is so that we can -// explicitly level this guy differently from ReJITDomainTable, so that both the -// SharedDomain's ReJitManager table lock AND one non-SharedDomain's ReJitManager table -// lock may be held simultaneously. This is useful during ETW rundown. -Crst ReJITSharedDomainTable - AcquiredBefore ReJITDomainTable - AcquiredAfter ReJITGlobalRequest ThreadStore GlobalStrLiteralMap SystemDomain DebuggerMutex -End - -// Used to synchronize all global requests (which may span multiple AppDomains) which add -// new functions to rejit tables, or request Reverts on existing functions in the rejit -// tables. One of these crsts exist per runtime. -Crst ReJITGlobalRequest - AcquiredBefore ThreadStore ReJITSharedDomainTable ReJITDomainTable SystemDomain -End - -// ETW infrastructure uses this crst to protect a hash table of TypeHandles which is -// used to remember which types have been logged (to avoid duplicate logging of the -// same type). -Crst EtwTypeLogHash - AcquiredAfter ThreadStore AllowedFiles Cer TPMethodTable - AcquiredBefore AvailableParamTypes ConnectionNameTable DeadlockDetection DebuggerController - DebuggerHeapLock DebuggerJitInfo DynamicIL ExecuteManRangeLock HandleTable IbcProfile - JitGenericHandleCache JumpStubCache LoaderHeap ModuleLookupTable ProfilingAPIStatus - ProfilerGCRefDataFreeList RWLock SingleUseLock SyncBlockCache SystemDomainDelayedUnloadList - ThreadIdDispenser ThreadStaticDataHashTable -End - -Crst Remoting - AcquiredBefore AppDomainHandleTable AvailableParamTypes Cer ClassInit DeadlockDetection DebuggerController - DebuggerHeapLock DebuggerJitInfo DebuggerMutex DomainLocalBlock ExecuteManRangeLock - FuncPtrStubs GlobalStrLiteralMap HandleTable InstMethodHashTable Jit JitGenericHandleCache - JumpStubCache LoaderHeap StubCache Module ModuleLookupTable SecurityStackwalkCache SigConvert - SingleUseLock StubUnwindInfoHeapSegments SyncBlockCache SystemDomainDelayedUnloadList - ThreadStore UnresolvedClassLock PendingTypeLoadEntry -End - -Crst RWLock -End - -Crst SavedExceptionInfo - AcquiredBefore DebuggerController -End - -Crst SaveModuleProfileData -End - -Crst SecurityPolicyCache -End - -Crst SecurityPolicyInit - AcquiredBefore SecurityPolicyCache -End - -Crst SecurityStackwalkCache -End - -Crst SharedAssemblyCreate - AcquiredBefore DeadlockDetection UniqueStack -End - -Crst SharedBaseDomain - AcquiredBefore UniqueStack -End - -Crst SigConvert - AcquiredBefore LoaderHeap -End - -Crst SingleUseLock - AcquiredBefore ExecuteManRangeLock LoaderHeap UniqueStack DebuggerJitInfo -End - -Crst UnwindInfoTableLock - AcquiredAfter StubUnwindInfoHeapSegments SingleUseLock - AcquiredBefore StressLog -End - -Crst SpecialStatics -End - -Crst StressLog - Unordered -End - -Crst StrongName -End - -Crst CodeFragmentHeap - AcquiredBefore SingleUseLock -End - -Crst StubDispatchCache -End - -Crst StubUnwindInfoHeapSegments - AcquiredAfter StubCache -End - -Crst SyncBlockCache - AcquiredBefore ThreadIdDispenser -End - -Crst SyncHashLock -End - -Crst SystemBaseDomain -End - -Crst SystemDomain - AcquiredBefore DebuggerMutex HandleTable IbcProfile SaveModuleProfileData SecurityPolicyCache - ThreadIdDispenser ThreadStore -End - -Crst SystemDomainDelayedUnloadList -End - -Crst ThreadIdDispenser -End - -Crst ThreadpoolEventCache -End - -Crst ThreadpoolTimerQueue - AcquiredBefore UniqueStack -End - -Crst ThreadpoolWaitThreads - AcquiredBefore UniqueStack -End - -Crst ThreadpoolWorker - AcquiredBefore ThreadIdDispenser ThreadStore -End - -Crst ThreadStaticDataHashTable - AcquiredBefore SyncBlockCache -End - -Crst ThreadStore - AcquiredBefore AvailableParamTypes ConnectionNameTable DeadlockDetection DebuggerController - DebuggerHeapLock DebuggerJitInfo DynamicIL ExecuteManRangeLock HandleTable IbcProfile - JitGenericHandleCache JumpStubCache LoaderHeap ModuleLookupTable ProfilingAPIStatus - ProfilerGCRefDataFreeList RWLock SingleUseLock SyncBlockCache SystemDomainDelayedUnloadList - ThreadIdDispenser ThreadStaticDataHashTable -End - -Crst TPMethodTable - AcquiredBefore DebuggerHeapLock LoaderHeap UniqueStack AvailableParamTypes -End - -Crst TypeIDMap - AcquiredBefore UniqueStack -End - -Crst TypeEquivalenceMap - AcquiredBefore LoaderHeap -End - -Crst UMThunkHash -End - -Crst UniqueStack - AcquiredBefore LoaderHeap -End - -Crst UnresolvedClassLock - AcquiredBefore AvailableParamTypes DynLinkZapItems IbcProfile JumpStubCache -End - -Crst WrapperTemplate - AcquiredBefore IbcProfile -End - -Crst UMEntryThunkCache - AcquiredBefore LoaderHeap -End - -Crst PinnedByrefValidation -End - -Crst VSDIndirectionCellLock - AcquiredBefore LoaderHeap -End - -Crst MulticoreJitHash -End - -Crst MulticoreJitManager - AcquiredBefore MulticoreJitHash ThreadStore -End - -Crst WinRTFactoryCache - AcquiredBefore HandleTable -End - -Crst SqmManager -End - -Crst StackSampler -End - -Crst InlineTrackingMap - AcquiredBefore IbcProfile -End - -Crst EventPipe - AcquiredBefore ThreadIdDispenser ThreadStore DomainLocalBlock InstMethodHashTable -End - -Crst NotifyGdb -End - -Crst ReadyToRunEntryPointToMethodDescMap - AcquiredBefore ExecuteManRangeLock -End diff --git a/src/inc/OpCodeGen.pl b/src/inc/OpCodeGen.pl deleted file mode 100644 index c29d4976e..000000000 --- a/src/inc/OpCodeGen.pl +++ /dev/null @@ -1,483 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. -# -# OpCodeGen.pl -# -# PERL script used to generate the numbering of the reference opcodes -# -#use strict 'vars'; -#use strict 'subs'; -#use strict 'refs'; - - -my $ret = 0; -my %opcodeEnum; -my %oneByte; -my %twoByte; -my %controlFlow; -my @singleByteArg; -my %stackbehav; -my %opcodetype; -my %operandtype; -my %opcodes; -my $popstate; -my $pushstate; - -$ctrlflowcount = 0; - -$count = 0; - -my @lowercaseAlphabet = ('a'..'z','0'..'9'); -my %upcaseAlphabet = (); - -foreach $letter (@lowercaseAlphabet) { - $j = $letter; - $j=~tr/a-z/A-Z/; - $upcaseAlphabet{$letter}=$j; -} - -$license = "// Licensed to the .NET Foundation under one or more agreements.\n"; -$license .= "// The .NET Foundation licenses this file to you under the MIT license.\n"; -$license .= "// See the LICENSE file in the project root for more information.\n\n"; - -$startHeaderComment = "/*============================================================\n**\n"; -$endHeaderComment = "**\n** THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT BY HAND!\n"; -$endHeaderComment .= "** See \$(RepoRoot)\\src\\inc\\OpCodeGen.pl for more information.**\n"; -$endHeaderComment .= "==============================================================*/\n\n"; - -$usingAndRefEmitNmsp = "using System;\n\nnamespace System.Reflection.Emit\n{\n\n"; -$obsoleteAttr = " [Obsolete(\"This API has been deprecated. http://go.microsoft.com/fwlink/?linkid=14202\")]\n"; - -# Open source file and target files - -open (OPCODE, "opcode.def") or die "Couldn't open opcode.def: $!\n"; -open (OUTPUT, ">OpCodes.cs") or die "Couldn't open OpCodes.cs: $!\n"; -open (FCOUTPUT, ">FlowControl.cs") or die "Couldn't open FlowControl.cs: $!\n"; -open (SOUTPUT, ">StackBehaviour.cs") or die "Couldn't open StackBehaviour.cs: $!\n"; -open (OCOUTPUT, ">OpCodeType.cs") or die "Couldn't open OpCodeType.cs: $!\n"; -open (OPOUTPUT, ">OperandType.cs") or die "Couldn't open OperandType.cs: $!\n"; - -print OUTPUT $license; -print OUTPUT $startHeaderComment; -print OUTPUT "** Class: OpCodes\n"; -print OUTPUT "**\n"; -print OUTPUT "** Purpose: Exposes all of the IL instructions supported by the runtime.\n"; -print OUTPUT $endHeaderComment; - -print OUTPUT $usingAndRefEmitNmsp; - -print FCOUTPUT $license; -print FCOUTPUT $startHeaderComment; -print FCOUTPUT "** Enumeration: FlowControl\n"; -print FCOUTPUT "**\n"; -print FCOUTPUT "** Purpose: Exposes FlowControl Attribute of IL.\n"; -print FCOUTPUT $endHeaderComment; - -print FCOUTPUT $usingAndRefEmitNmsp; -print FCOUTPUT " public enum FlowControl\n {\n"; - -print SOUTPUT $license; -print SOUTPUT $startHeaderComment; -print SOUTPUT "** Enumeration: StackBehaviour\n"; -print SOUTPUT "**\n"; -print SOUTPUT "** Purpose: Exposes StackBehaviour Attribute of IL.\n"; -print SOUTPUT $endHeaderComment; - -print SOUTPUT $usingAndRefEmitNmsp; -print SOUTPUT " public enum StackBehaviour\n {\n"; - -print OCOUTPUT $license; -print OCOUTPUT $startHeaderComment; -print OCOUTPUT "** Enumeration: OpCodeType\n"; -print OCOUTPUT "**\n"; -print OCOUTPUT "** Purpose: Exposes OpCodeType Attribute of IL.\n"; -print OCOUTPUT $endHeaderComment; - -print OCOUTPUT $usingAndRefEmitNmsp; -print OCOUTPUT " public enum OpCodeType\n {\n"; - -print OPOUTPUT $license; -print OPOUTPUT $startHeaderComment; -print OPOUTPUT "** Enumeration: OperandType\n"; -print OPOUTPUT "**\n"; -print OPOUTPUT "** Purpose: Exposes OperandType Attribute of IL.\n"; -print OPOUTPUT $endHeaderComment; - -print OPOUTPUT $usingAndRefEmitNmsp; -print OPOUTPUT " public enum OperandType\n {\n"; - -while () -{ - # Process only OPDEF(....) lines - if (/OPDEF\(\s*/) - { - chop; # Strip off trailing CR - s/^OPDEF\(\s*//; # Strip off "OP(" - s/,\s*/,/g; # Remove whitespace - s/\).*$//; # Strip off ")" and everything behind it at end - - # Split the line up into its basic parts - ($enumname, $stringname, $pop, $push, $operand, $type, $size, $s1, $s2, $ctrl) = split(/,/); - $s1 =~ s/0x//; - $s1 = hex($s1); - $s2 =~ s/0x//; - $s2 = hex($s2); - - if ($size == 0) - { - next; - } - - next if ($enumname =~ /UNUSED/); - - #Remove the prefix - $enumname=~s/CEE_//g; - - #Convert name to our casing convention - $enumname=~tr/A-Z/a-z/; - $enumname=~s/^(.)/\u$1/g; - $enumname=~s/_(.)/_\u$1/g; - - #Convert pop to our casing convention - $pop=~tr/A-Z/a-z/; - $pop=~s/^(.)/\u$1/g; - $pop=~s/_(.)/_\u$1/g; - - #Convert push to our casing convention - $push=~tr/A-Z/a-z/; - $push=~s/^(.)/\u$1/g; - $push=~s/_(.)/_\u$1/g; - - #Convert operand to our casing convention - #$operand=~tr/A-Z/a-z/; - #$operand=~s/^(.)/\u$1/g; - #$operand=~s/_(.)/_\u$1/g; - - #Remove the I prefix on type - $type=~s/I//g; - - #Convert Type to our casing convention - $type=~tr/A-Z/a-z/; - $type=~s/^(.)/\u$1/g; - $type=~s/_(.)/_\u$1/g; - - #Convert ctrl to our casing convention - $ctrl=~tr/A-Z/a-z/; - $ctrl=~s/^(.)/\u$1/g; - $ctrl=~s/_(.)/_\u$1/g; - - # Make a list of the flow Control type - - # Make a list of the opcodes and their values - if ($opcodes{$enumname}) - { - } - elsif ($size == 1) - { - $opcodes{$enumname} = $s2; - } - elsif ($size == 2) - { - $opcodes{$enumname} = ($s2 + 256 * $s1); - } - - #Make a list of the instructions which only take one-byte arguments - if ($enumname =~ /^.*_S$/) { - #but exclude the deprecated expressions (sometimes spelled "depricated") - if (!($enumname=~/^Depr.cated.*/)) { - my $caseStatement = sprintf(" case %-20s: \n", $enumname); - push(@singleByteArg, $caseStatement); - } - } - - #make a list of the control Flow Types - if ($controlFlow{$ctrl}) - { - #printf("DUPE Control Flow\n"); - } - else - { - $controlFlow{$ctrl} = $ctrlflowcount; - $ctrlflowcount++; - } - - $ctrlflowcount = 0; - #make a list of the StackBehaviour Types - $pop=~s/\+/_/g; - if ($stackbehav{$pop}) - { - #printf("DUPE stack behaviour pop\n"); - } - else - { - $stackbehav{$pop} = $ctrlflowcount; - $ctrlflowcount++; - } - - #make a list of the StackBehaviour Types - $push=~s/\+/_/g; - if ($stackbehav{$push}) - { - #printf("DUPE stack behaviour push\n"); - } - else - { - $stackbehav{$push} = $ctrlflowcount; - $ctrlflowcount++; - } - #make a list of operand types - if ($operandtype{$operand}) - { - #printf("DUPE operand type\n"); - } - else - { - $operandtype{$operand} = $ctrlflowcount; - $ctrlflowcount++; - } - - - #make a list of opcode types - if ($opcodetype{$type}) - { - #printf("DUPE opcode type\n"); - } - else - { - $opcodetype{$type} = $ctrlflowcount; - $ctrlflowcount++; - } - - my $opcodeName = $enumname; - - # Tailcall OpCode enum name does not comply with convention - # that all enum names are exactly the same as names in opcode.def - # file less leading CEE_ and changed casing convention - $enumname = substr $enumname, 0, 4 unless $enumname !~ m/Tailcall$/; - - # If string name ends with dot OpCode enum name ends with underscore - $enumname .= "_" unless $stringname !~ m/\."$/; - - printf(" OpCode name:%20s,\t\tEnum label:%20s,\t\tString name:%20s\n", $opcodeName, $enumname, $stringname); - if ($stringname eq "arglist") - { - print "This is arglist----------\n"; - } - - my $lineEnum; - if ($size == 1) - { - $lineEnum = sprintf(" %s = 0x%.2x,\n", $enumname, $s2); - $opcodeEnum{$s2} = $lineEnum; - } - elsif ($size == 2) - { - $lineEnum = sprintf(" %s = 0x%.4x,\n", $enumname, $s2 + 256 * $s1); - $opcodeEnum{$s2 + 256 * $s1} = $lineEnum; - } - - my $line; - $line = sprintf(" public static readonly OpCode %s = new OpCode(OpCodeValues.%s,\n", $opcodeName, $enumname); - $line .= sprintf(" ((int)OperandType.%s) |\n", $operand); - $line .= sprintf(" ((int)FlowControl.%s << OpCode.FlowControlShift) |\n", $ctrl); - $line .= sprintf(" ((int)OpCodeType.%s << OpCode.OpCodeTypeShift) |\n", $type); - $line .= sprintf(" ((int)StackBehaviour.%s << OpCode.StackBehaviourPopShift) |\n", $pop); - $line .= sprintf(" ((int)StackBehaviour.%s << OpCode.StackBehaviourPushShift) |\n", $push); - - $popstate = 0; - if($pop eq "Pop0" || $pop eq "Varpop") - { - $popstate = 0; - } - elsif ($pop eq "Pop1" || $pop eq "Popi" || $pop eq "Popref") - { - $popstate = $popstate -1; - } - elsif ($pop eq "Pop1_pop1" || $pop eq "Popi_pop1" || $pop eq "Popi_popi" || $pop eq "Popi_popi8" || $pop eq "Popi_popr4" || $pop eq "Popi_popr8" || $pop eq "Popref_pop1" || $pop eq "Popref_popi") - { - $popstate = $popstate -2; - } - elsif ($pop eq "Popi_popi_popi" || $pop eq "Popref_popi_popi" || $pop eq "Popref_popi_popi8" || $pop eq "Popref_popi_popr4" || $pop eq "Popref_popi_popr8" || $pop eq "Popref_popi_popref") - { - $popstate = $popstate -3; - } - - if ($push eq "Push1" || $push eq "Pushi" ||$push eq "Pushi8" ||$push eq "Pushr4" ||$push eq "Pushr8" ||$push eq "Pushref") - { - $popstate = $popstate + 1; - } - elsif($push eq "Push1_push1") - { - $popstate = $popstate + 2; - } - - $line .= sprintf(" (%s << OpCode.SizeShift) |\n", $size); - if ($ctrl =~ m/Return/ || $ctrl =~ m/^Branch/ || $ctrl =~ m/^Throw/ || $enumname =~ m/Jmp/){ - $line .= sprintf(" OpCode.EndsUncondJmpBlkFlag |\n", $size); - } - $line .= sprintf(" (%d << OpCode.StackChangeShift)\n", $popstate); - $line .= sprintf(" );\n\n"); - - if ($size == 1) - { - if ($oneByte{$s2}) - { - printf("Error opcode 0x%x already defined!\n", $s2); - print " Old = $oneByte{$s2}"; - print " New = $line"; - $ret = -1; - } - $oneByte{$s2} = $line; - } - elsif ($size == 2) - { - if ($twoByte{$s2}) - { - printf("Error opcode 0x%x%x already defined!\n", $s1, $s2); - print " Old = $oneByte{$s2}"; - print " New = $line"; - $ret = -1; - } - - $twoByte{$s2 + 256 * $s1} = $line; - } - else - { - $line .= "\n"; - push(@deprecated, $line); - printf("deprecated code!\n"); - } - $count++; - } -} - -# Generate the Flow Control enum -$ctrlflowcount = 0; -foreach $key (sort {$a cmp $b} keys (%controlFlow)) -{ - print FCOUTPUT " $key"; - print FCOUTPUT " = $ctrlflowcount,\n"; - $ctrlflowcount++; - if ($key =~ m/Next/){ - print FCOUTPUT $obsoleteAttr; - print FCOUTPUT " Phi"; - print FCOUTPUT " = $ctrlflowcount,\n"; - $ctrlflowcount++; - } -} -#end the flowcontrol enum -print FCOUTPUT " }\n}\n"; - -# Generate the StackBehaviour enum -$ctrlflowcount = 0; -foreach $key (sort {$a cmp $b} keys (%stackbehav)) -{ - if ($key !~ m/Popref_popi_pop1/){ - print SOUTPUT " $key"; - print SOUTPUT " = $ctrlflowcount,\n"; - $ctrlflowcount++; - } -} -print SOUTPUT " Popref_popi_pop1 = $ctrlflowcount,\n"; -#end the StackBehaviour enum -print SOUTPUT " }\n}\n"; - -# Generate OpCodeType enum -$ctrlflowcount = 0; -foreach $key (sort {$a cmp $b} keys (%opcodetype)) -{ - if ($ctrlflowcount == 0){ - print OCOUTPUT $obsoleteAttr; - print OCOUTPUT " Annotation = 0,\n"; - $ctrlflowcount++; - } - print OCOUTPUT " $key"; - print OCOUTPUT " = $ctrlflowcount,\n"; - $ctrlflowcount++; -} -# end the OpCodeType enum -print OCOUTPUT " }\n}\n"; - -# Generate OperandType enum -$ctrlflowcount = 0; -foreach $key (sort {$a cmp $b} keys (%operandtype)) -{ - print OPOUTPUT " $key"; - print OPOUTPUT " = $ctrlflowcount,\n"; - $ctrlflowcount++; - if ($key =~ m/InlineNone/){ - print OPOUTPUT $obsoleteAttr; - print OPOUTPUT " InlinePhi = 6,\n"; - $ctrlflowcount++; - } - if ($key =~ m/^InlineR$/){ - $ctrlflowcount++; - } -} -#end the OperandType enum -print OPOUTPUT " }\n}\n"; - -# Generate OpCodeValues internal enum -print OUTPUT " ///\n"; -print OUTPUT " /// Internal enum OpCodeValues for opcode values.\n"; -print OUTPUT " ///\n"; -print OUTPUT " ///\n"; -print OUTPUT " /// Note that the value names are used to construct publicly visible\n"; -print OUTPUT " /// ilasm-compatible opcode names, so their exact form is important!\n"; -print OUTPUT " ///\n"; -print OUTPUT " internal enum OpCodeValues\n"; -print OUTPUT " {\n"; - -foreach $opcodeValue (sort {$a <=> $b} keys(%opcodeEnum)) { - print OUTPUT $opcodeEnum{$opcodeValue}; -} - -# End generating OpCodeValues internal enum -print OUTPUT " }\n\n"; - - -# Generate public OpCodes class -print OUTPUT " /// \n"; -print OUTPUT " /// \n"; -print OUTPUT " /// The IL instruction opcodes supported by the runtime.\n"; -print OUTPUT " /// The Specification of IL Instruction describes each Opcode.\n"; -print OUTPUT " /// \n"; -print OUTPUT " /// \n"; -print OUTPUT " /// \n"; -print OUTPUT " public class OpCodes\n"; -print OUTPUT " {\n\n";; -print OUTPUT " private OpCodes()\n {\n }\n\n"; - -my $opcode; -my $lastOp = -1; -foreach $opcode (sort {$a <=> $b} keys(%oneByte)) { - printf("***** GAP %d instrs ****\n", $opcode - $lastOp) if ($lastOp + 1 != $opcode && $lastOp > 0); - print OUTPUT $oneByte{$opcode}; - $lastOp = $opcode; -} - -$lastOp = -1; -foreach $opcode (sort {$a <=> $b} keys(%twoByte)) { - printf("***** GAP %d instrs ****\n", $opcode - $lastOp) if ($lastOp + 1 != $opcode && $lastOp > 0); - print OUTPUT $twoByte{$opcode}; - $lastOp = $opcode; -} - -print OUTPUT "\n";; -print OUTPUT " public static bool TakesSingleByteArgument(OpCode inst)\n"; -print OUTPUT " {\n"; -print OUTPUT " switch (inst.OperandType)\n"; -print OUTPUT " {\n"; -print OUTPUT " case OperandType.ShortInlineBrTarget:\n"; -print OUTPUT " case OperandType.ShortInlineI:\n"; -print OUTPUT " case OperandType.ShortInlineVar:\n"; -print OUTPUT " return true;\n"; -print OUTPUT " };\n"; -print OUTPUT " return false;\n"; -print OUTPUT " }\n"; - -# End Generate public OpCodes class and close namespace -print OUTPUT " }\n}\n"; - -exit($ret); diff --git a/src/inc/_version.h b/src/inc/_version.h new file mode 100644 index 000000000..684aa96d5 --- /dev/null +++ b/src/inc/_version.h @@ -0,0 +1,29 @@ +#ifndef VER_COMPANYNAME_STR +#define VER_COMPANYNAME_STR "Microsoft Corporation" +#endif +#ifndef VER_FILEDESCRIPTION_STR +#define VER_FILEDESCRIPTION_STR "build" +#endif +#ifndef VER_INTERNALNAME_STR +#define VER_INTERNALNAME_STR VER_FILEDESCRIPTION_STR +#endif +#ifndef VER_ORIGINALFILENAME_STR +#define VER_ORIGINALFILENAME_STR VER_FILEDESCRIPTION_STR +#endif +#ifndef VER_PRODUCTNAME_STR +#define VER_PRODUCTNAME_STR "Microsoft\xae .NET Framework" +#endif +#undef VER_PRODUCTVERSION +#define VER_PRODUCTVERSION 4,6,26508,0 +#undef VER_PRODUCTVERSION_STR +#define VER_PRODUCTVERSION_STR "4.6.26508.0" +#undef VER_FILEVERSION +#define VER_FILEVERSION 4,6,26508,0 +#undef VER_FILEVERSION_STR +#define VER_FILEVERSION_STR "4.6.26508.0" +#ifndef VER_LEGALCOPYRIGHT_STR +#define VER_LEGALCOPYRIGHT_STR "\xa9 Microsoft Corporation. All rights reserved." +#endif +#ifndef VER_DEBUG +#define VER_DEBUG VS_FF_DEBUG +#endif diff --git a/src/inc/allocacheck.h b/src/inc/allocacheck.h deleted file mode 100644 index 3ba2e4da4..000000000 --- a/src/inc/allocacheck.h +++ /dev/null @@ -1,84 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -/*********************************************************************/ -/* AllocaCheck */ -/*********************************************************************/ - -/* check for alloca overruns (which otherwise are hard to track down - and often only repro on optimized builds). - - USAGE: - - void foo() { - ALLOCA_CHECK(); // Declare at function level scope - - .... - void* mem = ALLOCA(size); // does an alloca, - - } // destructor of ALLOCA_CHECK for buffer overruns. -*/ - -/* */ -/*********************************************************************/ - -#ifndef AllocaCheck_h -#define AllocaCheck_h -#include // for alloca itself - -#if defined(assert) && !defined(_ASSERTE) -#define _ASSERTE assert -#endif - -#if defined(_DEBUG) || defined(DEBUG) - -/*********************************************************************/ -class AllocaCheck { -public: - enum { CheckBytes = 0xCCCDCECF, - }; - - struct AllocaSentinal { - int check; - AllocaSentinal* next; - }; - -public: - /***************************************************/ - AllocaCheck() { - sentinals = 0; - } - - ~AllocaCheck() { - AllocaSentinal* ptr = sentinals; - while (ptr != 0) { - if (ptr->check != (int)CheckBytes) - _ASSERTE(!"alloca buffer overrun"); - ptr = ptr->next; - } - } - - void* add(void* allocaBuff, unsigned size) { - AllocaSentinal* newSentinal = (AllocaSentinal*) ((char*) allocaBuff + size); - newSentinal->check = CheckBytes; - newSentinal->next = sentinals; - sentinals = newSentinal; - memset(allocaBuff, 0xDD, size); - return allocaBuff; - } - -private: - AllocaSentinal* sentinals; -}; - -#define ALLOCA_CHECK() AllocaCheck __allocaChecker -#define ALLOCA(size) __allocaChecker.add(_alloca(size+sizeof(AllocaCheck::AllocaSentinal)), size); - -#else - -#define ALLOCA_CHECK() -#define ALLOCA(size) _alloca(size) - -#endif - -#endif diff --git a/src/inc/apithreadstress.cpp b/src/inc/apithreadstress.cpp deleted file mode 100644 index 0a802a2f1..000000000 --- a/src/inc/apithreadstress.cpp +++ /dev/null @@ -1,171 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -// --------------------------------------------------------------------------- -// APIThreadStress.cpp (API thread stresser) -// --------------------------------------------------------------------------- - -#include "stdafx.h" - -#ifdef _DEBUG -#define LOGGING 1 -#endif - -#include "apithreadstress.h" -#include "clrhost.h" -#include "ex.h" -#include "log.h" - - - -// For now, thread stress is incompatible with hosting. We need a host CreateThread -// to fix this. -#undef SetEvent -#undef ResetEvent - -int APIThreadStress::s_threadStressCount = 0; - -APIThreadStress::APIThreadStress() -{ - m_threadCount = 0; - - // Don't "fork" stress threads - if (ClrFlsGetValue(TlsIdx_StressThread) == NULL) - m_threadCount = s_threadStressCount; - - if (m_threadCount != 0) - { - m_setupOK = TRUE; - - m_hThreadArray = new (nothrow) HANDLE [ m_threadCount ]; - if (m_hThreadArray == NULL) - m_setupOK = FALSE; - else - { - HANDLE *p = m_hThreadArray; - HANDLE *pEnd = p + m_threadCount; - - while (p < pEnd) - { - DWORD id; - *p = ::CreateThread(NULL, 0, StartThread, this, 0, &id); - if (*p == NULL) - m_setupOK = FALSE; - p++; - } - } - - m_syncEvent = ClrCreateManualEvent(FALSE); - if (m_syncEvent == INVALID_HANDLE_VALUE) - m_setupOK = FALSE; - } -} - -APIThreadStress::~APIThreadStress() -{ - if (m_threadCount > 0) - { - HANDLE *p = m_hThreadArray; - HANDLE *pEnd = p + m_threadCount; - - if (p != NULL) - { - while (p < pEnd) - { - if (*p != NULL) - { - if (m_threadCount > 0 && m_setupOK) - WaitForSingleObjectEx(*p, INFINITE, FALSE); - - ::CloseHandle(*p); - } - p++; - } - delete [] m_hThreadArray; - } - - if (m_syncEvent != INVALID_HANDLE_VALUE) - CloseHandle(m_syncEvent); - } -} - -void APIThreadStress::SetThreadStressCount(int threadCount) -{ - s_threadStressCount = threadCount; -} - - -DWORD WINAPI APIThreadStress::StartThread(void *arg) -{ - APIThreadStress *pThis = (APIThreadStress *) arg; - - ClrFlsSetValue(TlsIdx_StressThread, pThis); - - EX_TRY - { - // Perform initial synchronization - WaitForSingleObjectEx(pThis->m_syncEvent, INFINITE, FALSE); - InterlockedIncrement(&pThis->m_runCount); - - LOG((LF_SYNC, LL_INFO100, "Stressing operation on thread %d\n", GetCurrentThreadId())); - ((APIThreadStress *)arg)->Invoke(); - LOG((LF_SYNC, LL_INFO100, "End stress operation on thread %d\n", GetCurrentThreadId())); - - if (InterlockedDecrement(&pThis->m_runCount) == 0) - ::SetEvent(pThis->m_syncEvent); - } - EX_CATCH - { - LOG((LF_SYNC, LL_ERROR, "Exception during stress operation on thread %d\n", GetCurrentThreadId())); - } - EX_END_CATCH(SwallowAllExceptions); - - return 0; -} - -BOOL APIThreadStress::DoThreadStress() -{ - if (m_threadCount > 0 && m_setupOK) - { - HANDLE *p = m_hThreadArray; - HANDLE *pEnd = p + m_threadCount; - - while (p < pEnd) - { - ::ResumeThread(*p); - p++; - } - - // Start the threads at the same time - ::SetEvent(m_syncEvent); - - return TRUE; - } - else - { - SyncThreadStress(); - return FALSE; - } -} - -void APIThreadStress::SyncThreadStress() -{ - APIThreadStress *pThis = (APIThreadStress *) ClrFlsGetValue(TlsIdx_StressThread); - - if (pThis != NULL) - { - LOG((LF_SYNC, LL_INFO1000, "Syncing stress operation on thread %d\n", GetCurrentThreadId())); - - ::ResetEvent(pThis->m_syncEvent); - - if (InterlockedDecrement(&pThis->m_runCount) == 0) - ::SetEvent(pThis->m_syncEvent); - else - WaitForSingleObjectEx(pThis->m_syncEvent, INFINITE, FALSE); - InterlockedIncrement(&pThis->m_runCount); - - LOG((LF_SYNC, LL_INFO1000, "Resuming stress operation on thread %d\n", GetCurrentThreadId())); - } -} - diff --git a/src/inc/apithreadstress.h b/src/inc/apithreadstress.h deleted file mode 100644 index a0c6cdeb0..000000000 --- a/src/inc/apithreadstress.h +++ /dev/null @@ -1,57 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -// --------------------------------------------------------------------------- -// APIThreadStress.h (API thread stresser) -// --------------------------------------------------------------------------- - -// --------------------------------------------------------------------------- -// This class provides a simple base to wrap "thread stress" logic around an API, -// which will (in thread stress mode) cause an API to "fork" onto many threads -// executing the same operation simulatenously. This can help to expose race -// conditions. -// -// Usage: -// -// First, subtype APIThreadStress and override Invoke to implement the operation. -// You will likely need to add data members for the arguments. -// -// Next, inside the API, write code like this: -// -// void MyRoutine(int a1, void *a2) -// { -// class stress : APIThreadStress -// { -// int a1; -// void *a2; -// stress(int a1, void *a2) : a1(a1), a2(a2) -// { DoThreadStress(); } -// void Invoke() { MyRoutine(a1, a2); } -// } ts (a1, a2); -// -// // implementation -// -// // perhaps we have a common sub-point in the routine where we want the threads to -// // queue up and race again -// -// ts.SyncThreadStress(); -// -// // more implementation -// } -// --------------------------------------------------------------------------- - - -#ifndef _APITHREADSTRESS_H_ -#define _APITHREADSTRESS_H_ - -#include "utilcode.h" - -class APIThreadStress -{ - public: - BOOL DoThreadStress() { return FALSE; } - static void SyncThreadStress() { } - static void SetThreadStressCount(int count) { } -}; - -#endif // _APITHREADSTRESS_H_ diff --git a/src/inc/appxutil.h b/src/inc/appxutil.h deleted file mode 100644 index 312c48633..000000000 --- a/src/inc/appxutil.h +++ /dev/null @@ -1,52 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -// - - -#pragma once - -#ifdef FEATURE_APPX - -#include "clrtypes.h" -#include "appmodel.h" -#include "fusionsetup.h" - -#define PACKAGE_FILTER_CLR_DEFAULT (PACKAGE_FILTER_HEAD|PACKAGE_FILTER_DIRECT) - - -typedef PACKAGE_INFO * PPACKAGE_INFO; -typedef PACKAGE_INFO const * PCPACKAGE_INFO; - -//--------------------------------------------------------------------------------------------- -// Forward declarations -template -class NewArrayHolder; -BOOL WinRTSupported(); - - -namespace AppX -{ - // Returns true if process is immersive (or if running in mockup environment). - bool IsAppXProcess(); - - // On CoreCLR, the host is in charge of determining whether the process is AppX or not. - void SetIsAppXProcess(bool); - -#ifdef DACCESS_COMPILE - bool DacIsAppXProcess(); -#endif // DACCESS_COMPILE -}; - - -#else // FEATURE_APPX - -namespace AppX -{ - inline bool IsAppXProcess() - { - return false; - } -} - -#endif // FEATURE_APPX diff --git a/src/inc/arraylist.h b/src/inc/arraylist.h deleted file mode 100644 index f45085bf3..000000000 --- a/src/inc/arraylist.h +++ /dev/null @@ -1,305 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - - -#ifndef ARRAYLIST_H_ -#define ARRAYLIST_H_ - -#include -#include -#include // offsetof - -// -// ArrayList is a simple class which is used to contain a growable -// list of pointers, stored in chunks. Modification is by appending -// only currently. Access is by index (efficient if the number of -// elements stays small) and iteration (efficient in all cases). -// -// An important property of an ArrayList is that the list remains -// coherent while it is being modified. This means that readers -// never need to lock when accessing it. -// - -#ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable : 4200) // Disable zero-sized array warning -#endif - -class ArrayListBase -{ - public: - - enum - { - ARRAY_BLOCK_SIZE_START = 5, - }; - - private: - - struct ArrayListBlock - { - SPTR(ArrayListBlock) m_next; - DWORD m_blockSize; -#ifdef _WIN64 - DWORD m_padding; -#endif - PTR_VOID m_array[0]; - -#ifdef DACCESS_COMPILE - static ULONG32 DacSize(TADDR addr) - { - LIMITED_METHOD_CONTRACT; - return offsetof(ArrayListBlock, m_array) + - (*PTR_DWORD(addr + offsetof(ArrayListBlock, m_blockSize)) * sizeof(void*)); - } -#endif - }; - typedef SPTR(ArrayListBlock) PTR_ArrayListBlock; - - struct FirstArrayListBlock - { - PTR_ArrayListBlock m_next; - DWORD m_blockSize; -#ifdef _WIN64 - DWORD m_padding; -#endif - void * m_array[ARRAY_BLOCK_SIZE_START]; - }; - - typedef DPTR(FirstArrayListBlock) PTR_FirstArrayListBlock; - - DWORD m_count; - FirstArrayListBlock m_firstBlock; - - public: - - PTR_VOID *GetPtr(DWORD index) const; - PTR_VOID Get(DWORD index) const - { - WRAPPER_NO_CONTRACT; - SUPPORTS_DAC; - - return *GetPtr(index); - } - - void Set(DWORD index, PTR_VOID element) - { - WRAPPER_NO_CONTRACT; - STATIC_CONTRACT_SO_INTOLERANT; - *GetPtr(index) = element; - } - - DWORD GetCount() const { LIMITED_METHOD_DAC_CONTRACT; return m_count; } - - HRESULT Append(void *element); - - enum { NOT_FOUND = -1 }; - DWORD FindElement(DWORD start, PTR_VOID element) const; - - void Clear(); - - void Init() - { - LIMITED_METHOD_CONTRACT; - STATIC_CONTRACT_SO_INTOLERANT; - - m_count = 0; - m_firstBlock.m_next = NULL; - m_firstBlock.m_blockSize = ARRAY_BLOCK_SIZE_START; - } - - void Destroy() - { - WRAPPER_NO_CONTRACT; - STATIC_CONTRACT_SO_INTOLERANT; - Clear(); - } - -#ifdef DACCESS_COMPILE - void EnumMemoryRegions(CLRDataEnumMemoryFlags flags); -#endif - - class ConstIterator; - - class Iterator - { - friend class ArrayListBase; - friend class ConstIterator; - - public: - BOOL Next(); - - void SetEmpty() - { - LIMITED_METHOD_CONTRACT; - - m_block = NULL; - m_index = (DWORD)-1; - m_remaining = 0; - m_total = 0; - } - - PTR_VOID GetElement() {LIMITED_METHOD_DAC_CONTRACT; return m_block->m_array[m_index]; } - PTR_VOID * GetElementPtr() {LIMITED_METHOD_CONTRACT; return m_block->m_array + m_index; } - DWORD GetIndex() {LIMITED_METHOD_CONTRACT; return m_index + m_total; } - void *GetBlock() { return m_block; } - - private: - ArrayListBlock* m_block; - DWORD m_index; - DWORD m_remaining; - DWORD m_total; - static Iterator Create(ArrayListBlock* block, DWORD remaining) - { - LIMITED_METHOD_DAC_CONTRACT; - STATIC_CONTRACT_SO_INTOLERANT; - Iterator i; - i.m_block = block; - i.m_index = (DWORD) -1; - i.m_remaining = remaining; - i.m_total = 0; - return i; - } - }; - - class ConstIterator - { - public: - ConstIterator(ArrayListBlock *pBlock, DWORD dwRemaining) : m_iterator(Iterator::Create(pBlock, dwRemaining)) - { - } - - BOOL Next() - { - WRAPPER_NO_CONTRACT; - return m_iterator.Next(); - } - - PTR_VOID GetElement() - { - WRAPPER_NO_CONTRACT; - return m_iterator.GetElement(); - } - - private: - Iterator m_iterator; - }; - - Iterator Iterate() - { - STATIC_CONTRACT_SO_INTOLERANT; - WRAPPER_NO_CONTRACT; - return Iterator::Create((ArrayListBlock*)&m_firstBlock, m_count); - } - - ConstIterator Iterate() const - { - STATIC_CONTRACT_SO_INTOLERANT; - - // Const cast is safe because ConstIterator does not expose any way to modify the block - ArrayListBlock *pFirstBlock = const_cast(reinterpret_cast(&m_firstBlock)); - return ConstIterator(pFirstBlock, m_count); - } - - // BlockIterator is used for only memory walking, such as prejit save/fixup. - // It is not appropriate for other more typical ArrayList use. - class BlockIterator - { - private: - - ArrayListBlock *m_block; - DWORD m_remaining; - - friend class ArrayListBase; - BlockIterator(ArrayListBlock *block, DWORD remaining) - : m_block(block), m_remaining(remaining) - { - } - - public: - - BOOL Next() - { - if (m_block != NULL) - { - // Prevent m_remaining from underflowing - we can have completely empty block at the end. - if (m_remaining > m_block->m_blockSize) - m_remaining -= m_block->m_blockSize; - else - m_remaining = 0; - - m_block = m_block->m_next; - } - return m_block != NULL; - } - - void ClearUnusedMemory() - { - if (m_remaining < m_block->m_blockSize) - ZeroMemory(&(m_block->m_array[m_remaining]), (m_block->m_blockSize - m_remaining) * sizeof(void*)); -#ifdef _WIN64 - m_block->m_padding = 0; -#endif - } - - void **GetNextPtr() - { - return (void **) &m_block->m_next; - } - - void *GetBlock() - { - return m_block; - } - - SIZE_T GetBlockSize() - { - return offsetof(ArrayListBlock, m_array) + (m_block->m_blockSize * sizeof(void*)); - } - }; - - void **GetInitialNextPtr() - { - return (void **) &m_firstBlock.m_next; - } - - BlockIterator IterateBlocks() - { - return BlockIterator((ArrayListBlock *) &m_firstBlock, m_count); - } - -}; - -class ArrayList : public ArrayListBase -{ -public: -#ifndef DACCESS_COMPILE - ArrayList() - { - STATIC_CONTRACT_SO_INTOLERANT; - WRAPPER_NO_CONTRACT; - Init(); - } - - ~ArrayList() - { - STATIC_CONTRACT_SO_INTOLERANT; - WRAPPER_NO_CONTRACT; - Destroy(); - } -#endif -}; - -/* to be used as static variable - no constructor/destructor, assumes zero - initialized memory */ -class ArrayListStatic : public ArrayListBase -{ -}; - -typedef DPTR(ArrayListStatic) PTR_ArrayListStatic; -#ifdef _MSC_VER -#pragma warning(pop) -#endif - -#endif diff --git a/src/inc/bbsweep.h b/src/inc/bbsweep.h deleted file mode 100644 index d5526d8e5..000000000 --- a/src/inc/bbsweep.h +++ /dev/null @@ -1,425 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*****************************************************************************\ -* * -* BBSweep.h - Classes for sweeping profile data to disk * -* * -* Version 1.0 * -******************************************************************************* -* * -* THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY * -* KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE * -* IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR * -* PURPOSE. * -* * -\*****************************************************************************/ - -#ifndef _BBSWEEP_H_ -#define _BBSWEEP_H_ - -#ifndef FEATURE_PAL -#include -#endif // !FEATURE_PAL - -// The CLR headers don't allow us to use methods like SetEvent directly (instead -// we need to use the host APIs). However, this file is included both in the CLR -// and in the BBSweep tool, and the host API is not available in the tool. Moreover, -// BBSweep is not designed to work in an environment where the host controls -// synchronization. For this reason, we work around the problem by undefining -// these APIs (the CLR redefines them so that they will not be used). -#pragma push_macro("SetEvent") -#pragma push_macro("ResetEvent") -#pragma push_macro("ReleaseSemaphore") -#pragma push_macro("LocalFree") -#undef SetEvent -#undef ResetEvent -#undef ReleaseSemaphore -#undef LocalFree - -// MAX_COUNT is the maximal number of runtime processes that can run at a given time -#define MAX_COUNT 20 - -#define INVALID_PID -1 - -/* CLRBBSweepCallback is implemented by the CLR which passes it as an argument to WatchForSweepEvents. - * It is used by BBSweep to tell the CLR to write the profile data to disk at the right time. - */ - -class ICLRBBSweepCallback -{ -public: - virtual HRESULT WriteProfileData() = NULL; // tells the runtime to write the profile data to disk -}; - -/* BBSweep is used by both the CLR and the BBSweep utility. - * BBSweep: calls the PerformSweep method which returns after all the CLR processes - * have written their profile data to disk. - * CLR: starts up a sweeper thread which calls WatchForSweepEvents and waits until the - * sweeper program is invoked. At that point, all the CLR processes will synchronize - * and write their profile data to disk one at a time. The sweeper threads will then - * wait for the next sweep event. The CLR also calls ShutdownBBSweepThread at - * shutdown which returns when the BBSweep thread has terminated. - */ - -class BBSweep -{ -public: - BBSweep() - { - // The BBSweep constructor could be called even the the object is not used, so - // don't do any work here. - bInitialized = false; - bTerminate = false; - hSweepMutex = NULL; - hProfDataWriterMutex = NULL; - hSweepEvent = NULL; - hTerminationEvent = NULL; - hProfWriterSemaphore = NULL; - hBBSweepThread = NULL; - } - - ~BBSweep() - { - // When the destructor is called, everything should be cleaned up already. - } - - // Called by the sweeper utility to tell all the CLR threads to write their profile - // data to disk. - // THIS FUNCTIONALITY IS ALSO DUPLICATED IN TOOLBOX\MPGO\BBSWEEP.CS - // IF YOU CHANGE THIS CODE, YOU MUST ALSO CHANGE THAT TO MATCH! - bool PerformSweep(DWORD processID = INVALID_PID) - { - bool success = true; - - if (!Initialize(processID, FALSE)) return false; - - ::WaitForSingleObject(hSweepMutex, INFINITE); - { - success = success && ::SetEvent(hSweepEvent); - { - for (int i=0; iWriteProfileData())) - success = false; - } - ::ReleaseMutex(hProfDataWriterMutex); - - ::ReleaseSemaphore(hProfWriterSemaphore, 1, NULL); - } - - return success; - } - - void SetBBSweepThreadHandle(HANDLE threadHandle) - { - hBBSweepThread = threadHandle; - } - - void ShutdownBBSweepThread() - { - // Set the termination event and wait for the BBSweep thread to terminate on its own. - // Note that this is called by the shutdown thread (and never called by the BBSweep thread). - if (hBBSweepThread && bInitialized) - { - bTerminate = true; - ::SetEvent(hTerminationEvent); - ::WaitForSingleObject(hBBSweepThread, INFINITE); - Cleanup(); - } - } - - void Cleanup() - { - if (hSweepMutex) { ::CloseHandle(hSweepMutex); hSweepMutex = NULL;} - if (hProfDataWriterMutex) { ::CloseHandle(hProfDataWriterMutex); hProfDataWriterMutex = NULL;} - if (hSweepEvent) { ::CloseHandle(hSweepEvent); hSweepEvent = NULL;} - if (hTerminationEvent) { ::CloseHandle(hTerminationEvent); hTerminationEvent = NULL;} - if (hProfWriterSemaphore) { ::CloseHandle(hProfWriterSemaphore); hProfWriterSemaphore = NULL;} - } - -private: - - // THIS FUNCTIONALITY IS ALSO DUPLICATED IN TOOLBOX\MPGO\BBSWEEP.CS - // IF YOU CHANGE THIS CODE, YOU MUST ALSO CHANGE THAT TO MATCH! - bool Initialize(DWORD processID = INVALID_PID, BOOL fromRuntime = TRUE) - { - if (!bInitialized) - { - SECURITY_ATTRIBUTES * pSecurityAttributes = NULL; - -#ifndef FEATURE_CORESYSTEM // @CORESYSTEMTODO - PSECURITY_DESCRIPTOR pSD = NULL; - PSID pAdminSid = NULL; - HANDLE hToken = NULL; - PACL pACL = NULL; - LPVOID buffer = NULL; - - if (!OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &hToken)) - goto cleanup; - - // don't set pSecurityAttributes for Metro processes - if(!IsAppContainerProcess(hToken)) - { - SECURITY_ATTRIBUTES securityAttributes; - PSID pUserSid = NULL; - SID_IDENTIFIER_AUTHORITY SIDAuthNT = SECURITY_NT_AUTHORITY; - DWORD retLength; - -#ifdef _PREFAST_ -#pragma warning(push) -#pragma warning(disable:6211) // PREfast warning: Leaking memory 'pSD' due to an exception. -#endif /*_PREFAST_ */ - pSD = (PSECURITY_DESCRIPTOR) new char[SECURITY_DESCRIPTOR_MIN_LENGTH]; - if (!pSD) - goto cleanup; - - if (GetTokenInformation(hToken, TokenOwner, NULL, 0, &retLength)) - goto cleanup; - - buffer = (LPVOID) new char[retLength]; - if (!buffer) - goto cleanup; -#ifdef _PREFAST_ -#pragma warning(pop) -#endif /*_PREFAST_*/ - - // Get the SID for the current user - if (!GetTokenInformation(hToken, TokenOwner, (LPVOID) buffer, retLength, &retLength)) - goto cleanup; - - pUserSid = ((TOKEN_OWNER *) buffer)->Owner; - - // Get the SID for the admin group - // Create a SID for the BUILTIN\Administrators group. - if(! AllocateAndInitializeSid(&SIDAuthNT, 2, - SECURITY_BUILTIN_DOMAIN_RID, - DOMAIN_ALIAS_RID_ADMINS, - 0, 0, 0, 0, 0, 0, - &pAdminSid)) - goto cleanup; - - EXPLICIT_ACCESS ea[2]; - ZeroMemory(ea, 2 * sizeof(EXPLICIT_ACCESS)); - - // Initialize an EXPLICIT_ACCESS structure for an ACE. - // The ACE will allow the current user full access - ea[0].grfAccessPermissions = STANDARD_RIGHTS_ALL | SPECIFIC_RIGHTS_ALL; // KEY_ALL_ACCESS; - ea[0].grfAccessMode = SET_ACCESS; - ea[0].grfInheritance= NO_INHERITANCE; - ea[0].Trustee.TrusteeForm = TRUSTEE_IS_SID; - ea[0].Trustee.TrusteeType = TRUSTEE_IS_USER; - ea[0].Trustee.ptstrName = (LPTSTR) pUserSid; - - // Initialize an EXPLICIT_ACCESS structure for an ACE. - // The ACE will allow admins full access - ea[1].grfAccessPermissions = STANDARD_RIGHTS_ALL | SPECIFIC_RIGHTS_ALL; //KEY_ALL_ACCESS; - ea[1].grfAccessMode = SET_ACCESS; - ea[1].grfInheritance= NO_INHERITANCE; - ea[1].Trustee.TrusteeForm = TRUSTEE_IS_SID; - ea[1].Trustee.TrusteeType = TRUSTEE_IS_GROUP; - ea[1].Trustee.ptstrName = (LPTSTR) pAdminSid; - - if (SetEntriesInAcl(2, ea, NULL, &pACL) != ERROR_SUCCESS) - goto cleanup; - - if (!InitializeSecurityDescriptor(pSD, SECURITY_DESCRIPTOR_REVISION)) - goto cleanup; - - if (!SetSecurityDescriptorDacl(pSD, TRUE, pACL, FALSE)) - goto cleanup; - - memset((void *) &securityAttributes, 0, sizeof(SECURITY_ATTRIBUTES)); - securityAttributes.nLength = sizeof(SECURITY_ATTRIBUTES); - securityAttributes.lpSecurityDescriptor = pSD; - securityAttributes.bInheritHandle = FALSE; - - pSecurityAttributes = &securityAttributes; - } -#endif // !FEATURE_CORESYSTEM - - WCHAR objectName[MAX_LONGPATH] = {0}; - WCHAR objectNamePrefix[MAX_LONGPATH] = {0}; - GetObjectNamePrefix(processID, fromRuntime, objectNamePrefix); - // if there is a non-empty name prefix, append a '\' - if (objectNamePrefix[0] != '\0') - wcscat_s(objectNamePrefix, ARRAYSIZE(objectNamePrefix), W("\\")); - swprintf_s(objectName, MAX_LONGPATH, W("%sBBSweep_hSweepMutex"), objectNamePrefix); - hSweepMutex = ::WszCreateMutex(pSecurityAttributes, false, objectName); - swprintf_s(objectName, MAX_LONGPATH, W("%sBBSweep_hProfDataWriterMutex"), objectNamePrefix); - hProfDataWriterMutex = ::WszCreateMutex(pSecurityAttributes, false, objectName); - swprintf_s(objectName, MAX_LONGPATH, W("%sBBSweep_hSweepEvent"), objectNamePrefix); - hSweepEvent = ::WszCreateEvent(pSecurityAttributes, true, false, objectName); - - // Note that hTerminateEvent is not a named event. That is because it is not - // shared amongst the CLR processes (each process terminates at a different time) - hTerminationEvent = ::WszCreateEvent(pSecurityAttributes, true, false, NULL); - swprintf_s(objectName, MAX_LONGPATH, W("%sBBSweep_hProfWriterSemaphore"), objectNamePrefix); - hProfWriterSemaphore = ::WszCreateSemaphore(pSecurityAttributes, MAX_COUNT, MAX_COUNT, objectName); - -#ifndef FEATURE_CORESYSTEM // @CORESYSTEMTODO -cleanup: - if (pSD) delete [] ((char *) pSD); - if (pAdminSid) FreeSid(pAdminSid); - if (hToken) CloseHandle(hToken); - if (pACL) LocalFree(pACL); - if (buffer) delete [] ((char *) buffer); -#endif - } - - bInitialized = hSweepMutex && - hProfDataWriterMutex && - hSweepEvent && - hTerminationEvent && - hProfWriterSemaphore; - - if (!bInitialized) Cleanup(); - return bInitialized; - } - -#ifndef FEATURE_PAL - BOOL IsAppContainerProcess(HANDLE hToken) - { -#ifndef TokenIsAppContainer -#define TokenIsAppContainer ((TOKEN_INFORMATION_CLASS) 29) -#endif - BOOL fIsAppContainerProcess; - DWORD dwReturnLength; - if (!GetTokenInformation(hToken, TokenIsAppContainer, &fIsAppContainerProcess, sizeof(BOOL), &dwReturnLength) || - dwReturnLength != sizeof(BOOL)) - { - fIsAppContainerProcess = FALSE; - } - return fIsAppContainerProcess; - } -#endif // !FEATURE_PAL - - // helper to get the correct object name prefix - void GetObjectNamePrefix(DWORD processID, BOOL fromRuntime, __inout_z WCHAR* objectNamePrefix) - { - // default prefix - swprintf_s(objectNamePrefix, MAX_LONGPATH, W("Global")); -#ifndef FEATURE_PAL - // - // This method can be called: - // 1. From process init code - // 2. From bbsweepclr.exe - // - // When called from process init code, processID is always INVALID_PID. - // In case it is a Win8-Metro/WP8 process, we need to add the AppContainerNamedObjectPath to prefix. - // And if it is a non-Metro process, we will continue to use the default prefix (Global). - // We use IsAppContainerProcess(CurrentProcessId) to make this decision. - // - // - // When called from bbsweepclr, processID is valid when sweeping a Metro or WP8 process. - // We use this valid processID to determine if the process being swept is Metro/WP8 indeed and then - // add AppContainerNamedObjectPath to prefix. This is done by IsAppContainerProcess(processID). - // - // In case INVALID_PID is passed(non-Metro process), we have to use default prefix. To handle this - // case we use IsAppContainerProcess(CurrentProcessId) and since bbsweepclr is a non-Metro process, - // this check always returns false and we end up using the intended(default) prefix. - // - if(processID == INVALID_PID) { - // we reach here when: - // * called from process init code: - // * called from bbsweepclr.exe and no processID has been passed as argument, that is, when sweeping a non-Metro process - processID = GetCurrentProcessId(); - } - - HandleHolder hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, processID); - if (hProcess != INVALID_HANDLE_VALUE) - { - HandleHolder hToken = NULL; - // if in the process init code of a Metro app or if bbsweepclr is used to sweep a Metro app, - // construct the object name prefix using AppContainerNamedObjectPath - if (OpenProcessToken(hProcess, TOKEN_QUERY, &hToken) && IsAppContainerProcess(hToken)) - { - WCHAR appxNamedObjPath[MAX_LONGPATH] = { 0 }; - ULONG appxNamedObjPathBufLen = 0; - - if (fromRuntime) - { - // for Metro apps, create the object in the "default" object path, i.e. do not provide any prefix - objectNamePrefix[0] = W('\0'); - } - else - { -#if defined (FEATURE_CORESYSTEM) && !defined(CROSSGEN_COMPILE) && !defined(DACCESS_COMPILE) -#define MODULE_NAME W("api-ms-win-security-appcontainer-l1-1-0.dll") -#else -#define MODULE_NAME W("kernel32.dll") -#endif - typedef BOOL(WINAPI *PFN_GetAppContainerNamedObjectPath) - (HANDLE Token, PSID AppContainerSid, ULONG ObjectPathLength, WCHAR * ObjectPath, PULONG ReturnLength); - - PFN_GetAppContainerNamedObjectPath pfnGetAppContainerNamedObjectPath = (PFN_GetAppContainerNamedObjectPath) - GetProcAddress(WszGetModuleHandle(MODULE_NAME), "GetAppContainerNamedObjectPath"); - if (pfnGetAppContainerNamedObjectPath) - { - // for bbsweepclr sweeping a Metro app, create the object specifying the AppContainer's path - DWORD sessionId = 0; - ProcessIdToSessionId(processID, &sessionId); - pfnGetAppContainerNamedObjectPath(hToken, NULL, sizeof (appxNamedObjPath) / sizeof (WCHAR), appxNamedObjPath, &appxNamedObjPathBufLen); - swprintf_s(objectNamePrefix, MAX_LONGPATH, W("Global\\Session\\%d\\%s"), sessionId, appxNamedObjPath); - } - } - } - } -#endif // FEATURE_PAL - } -private: - - bool bInitialized; // true when the BBSweep object has initialized successfully - bool bTerminate; // set to true when the CLR wants us to terminate - HANDLE hSweepMutex; // prevents processing from incrementing the semaphore after the sweep has began - HANDLE hProfDataWriterMutex; // guarantees that profile data will be written by one process at a time - HANDLE hSweepEvent; // tells the CLR processes to sweep their profile data - HANDLE hTerminationEvent; // set when the CLR process is ready to terminate - HANDLE hProfWriterSemaphore; // helps determine when all the writers are finished - HANDLE hBBSweepThread; // a handle to the CLR sweeper thread (that calls watch for sweep events) -}; - -#pragma pop_macro("LocalFree") -#pragma pop_macro("ReleaseSemaphore") -#pragma pop_macro("ResetEvent") -#pragma pop_macro("SetEvent") - -#endif //_BBSWEEP_H diff --git a/src/inc/bitmask.h b/src/inc/bitmask.h deleted file mode 100644 index a59d2e252..000000000 --- a/src/inc/bitmask.h +++ /dev/null @@ -1,103 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -// - -// -------------------------------------------------------------------------------- -// BitMask.h -// -------------------------------------------------------------------------------- - -// -------------------------------------------------------------------------------- -// BitMask is an arbitrarily large sized bitfield which has optimal storage -// for 32 bits or less. -// Storage is proportional to the highest index which is set. -// -------------------------------------------------------------------------------- - - -#include - -#ifndef _BITMASK_H_ -#define _BITMASK_H_ - -class BitMask -{ - public: - - BitMask(); - ~BitMask(); - - BOOL TestBit(int bit); - void SetBit(int bit); - void ClearBit(int bit); - - // returns true if any bit is set - BOOL TestAnyBit(); - - void ClearAllBits(); - - // Allocation exposed for ngen save/fixup - size_t GetAllocatedBlockOffset(); - void *GetAllocatedBlock(); - COUNT_T GetAllocatedBlockSize(); - - private: - - static const int BIT_SIZE_SHIFT = 5; - static const int BIT_SIZE = (1<writer so be very careful - // when taking this lock else you might deadlock your own thread! - SimpleRWLock m_bitMaskLock; -}; - -#include - -#endif // _BITMASK_H_ diff --git a/src/inc/bitmask.inl b/src/inc/bitmask.inl deleted file mode 100644 index 00bfe0138..000000000 --- a/src/inc/bitmask.inl +++ /dev/null @@ -1,292 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -// - -// -------------------------------------------------------------------------------- -// BitMask.inl -// -------------------------------------------------------------------------------- - -#include - -#ifndef _BITMASK_INL_ -#define _BITMASK_INL_ - -inline BOOL BitMask::IsArray() -{ - LIMITED_METHOD_CONTRACT; - return (m_mask&1) == 0; -} - -// Indexing computations -inline COUNT_T BitMask::BitToIndex(int bit) -{ - LIMITED_METHOD_CONTRACT; - // First word has one less bit due to tag - return (bit+1) >> BIT_SIZE_SHIFT; -} - -inline COUNT_T BitMask::BitToShift(int bit) -{ - LIMITED_METHOD_CONTRACT; - // First word has one less bit due to tag - return (bit+1) & BIT_SIZE_MASK; -} - -// Array access. Note the first array element is the count of the -// rest of the elements - -inline COUNT_T *BitMask::GetMaskArray() -{ - LIMITED_METHOD_CONTRACT; - if (IsArray()) - { - CONSISTENCY_CHECK(CheckPointer(m_maskArray)); - return m_maskArray+1; - } - else - return &m_mask; -} - -inline COUNT_T BitMask::GetMaskArraySize() -{ - LIMITED_METHOD_CONTRACT; - if (IsArray()) - return *m_maskArray; - else - return 1; -} - -inline void BitMask::GrowArray(COUNT_T newSize) -{ - CONTRACTL - { - THROWS; - } - CONTRACTL_END; - - // Ensure we don't grow too often - - COUNT_T oldSize = GetMaskArraySize(); - if (newSize <= oldSize) - return; - - if (newSize < oldSize*2) - newSize = oldSize*2; - if (newSize < MIN_ARRAY_ALLOCATION) - newSize = MIN_ARRAY_ALLOCATION; - - // Allocate new array - - COUNT_T *newArray = new COUNT_T [newSize+1]; - *newArray = newSize; - - CopyMemory(newArray+1, GetMaskArray(), oldSize * sizeof(COUNT_T)); - ZeroMemory(newArray+oldSize+1, (newSize - oldSize) * sizeof(COUNT_T)); - - if (IsArray()) - delete [] m_maskArray; - - m_maskArray = newArray; -} - -inline BitMask::BitMask() - : m_mask(1) -{ - LIMITED_METHOD_CONTRACT; -} - -inline BitMask::~BitMask() -{ - LIMITED_METHOD_CONTRACT; - - if (IsArray()) - delete [] m_maskArray; -} - -inline BOOL BitMask::TestBit(int bit) -{ - LIMITED_METHOD_CONTRACT; - - COUNT_T index = BitToIndex(bit); - - if (index >= GetMaskArraySize()) - return FALSE; - - return ( GetMaskArray()[index] >> BitToShift(bit) ) & 1; -} - -inline void BitMask::SetBit(int bit) -{ - CONTRACTL - { - THROWS; - } - CONTRACTL_END; - - COUNT_T index = BitToIndex(bit); - - if (index >= GetMaskArraySize()) - GrowArray(index+1); - - GetMaskArray()[index] |= (1 << BitToShift(bit)); -} - -inline void BitMask::ClearBit(int bit) -{ - LIMITED_METHOD_CONTRACT; - - COUNT_T index = BitToIndex(bit); - - if (index >= GetMaskArraySize()) - return; - - GetMaskArray()[index] &= ~(1 << BitToShift(bit)); -} - -inline BOOL BitMask::TestAnyBit() -{ - LIMITED_METHOD_CONTRACT; - - if (IsArray()) - { - COUNT_T *mask = m_maskArray+1; - COUNT_T *maskEnd = mask + m_maskArray[0]; - - while (mask < maskEnd) - { - if (*mask != 0) - return TRUE; - mask++; - } - - return FALSE; - } - else - return m_mask != (COUNT_T) 1; -} - -inline void BitMask::ClearAllBits() -{ - LIMITED_METHOD_CONTRACT; - - if (IsArray()) - delete [] m_maskArray; - - m_mask = 1; -} - -inline size_t BitMask::GetAllocatedBlockOffset() -{ - LIMITED_METHOD_CONTRACT; - - return offsetof(BitMask, m_maskArray); -} - -inline void *BitMask::GetAllocatedBlock() -{ - LIMITED_METHOD_CONTRACT; - - if (IsArray()) - return m_maskArray; - else - return NULL; -} - -inline COUNT_T BitMask::GetAllocatedBlockSize() -{ - LIMITED_METHOD_CONTRACT; - - if (IsArray()) - return (GetMaskArraySize()+1) * sizeof(COUNT_T); - else - return 0; -} - -///////////////////////////////////////////////////////////////////////////////////////////// -///////////////////////////////////////////////////////////////////////////////////////////// - -inline SynchronizedBitMask::SynchronizedBitMask() - : m_bitMaskLock(PREEMPTIVE, LOCK_TYPE_DEFAULT) -{ - LIMITED_METHOD_CONTRACT; -} - -inline BOOL SynchronizedBitMask::TestBit(int bit) -{ - CONTRACTL - { - NOTHROW; - MODE_ANY; - CAN_TAKE_LOCK; - } - CONTRACTL_END; - - SimpleReadLockHolder holder(&m_bitMaskLock); - - return m_bitMask.TestBit(bit); -} - -inline void SynchronizedBitMask::SetBit(int bit) -{ - CONTRACTL - { - THROWS; - MODE_ANY; - CAN_TAKE_LOCK; - } - CONTRACTL_END; - - SimpleWriteLockHolder holder(&m_bitMaskLock); - - m_bitMask.SetBit(bit); -} - -inline void SynchronizedBitMask::ClearBit(int bit) -{ - CONTRACTL - { - NOTHROW; - MODE_ANY; - CAN_TAKE_LOCK; - } - CONTRACTL_END; - - SimpleWriteLockHolder holder(&m_bitMaskLock); - - m_bitMask.ClearBit(bit); -} - -inline BOOL SynchronizedBitMask::TestAnyBit() -{ - CONTRACTL - { - NOTHROW; - MODE_ANY; - CAN_TAKE_LOCK; - } - CONTRACTL_END; - - SimpleReadLockHolder holder(&m_bitMaskLock); - - return m_bitMask.TestAnyBit(); -} - -inline void SynchronizedBitMask::ClearAllBits() -{ - CONTRACTL - { - NOTHROW; - MODE_ANY; - CAN_TAKE_LOCK; - } - CONTRACTL_END; - - SimpleWriteLockHolder holder(&m_bitMaskLock); - - m_bitMask.ClearAllBits(); -} - -#endif // _BITMASK_INL_ - diff --git a/src/inc/bitposition.h b/src/inc/bitposition.h deleted file mode 100644 index df7915546..000000000 --- a/src/inc/bitposition.h +++ /dev/null @@ -1,59 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#ifndef _BITPOSITION_H_ -#define _BITPOSITION_H_ - -//------------------------------------------------------------------------ -// BitPosition: Return the position of the single bit that is set in 'value'. -// -// Return Value: -// The position (0 is LSB) of bit that is set in 'value' -// -// Notes: -// 'value' must have exactly one bit set. -// The algorithm is as follows: -// - PRIME is a prime bigger than sizeof(unsigned int), which is not of the -// form 2^n-1. -// - Taking the modulo of 'value' with this will produce a unique hash for all -// powers of 2 (which is what "value" is). -// - Entries in hashTable[] which are -1 should never be used. There -// should be PRIME-8*sizeof(value) entries which are -1 . -// -inline -unsigned BitPosition(unsigned value) -{ - _ASSERTE((value != 0) && ((value & (value-1)) == 0)); -#if defined(_ARM_) && defined(__llvm__) - // use intrinsic functions for arm32 - // this is applied for LLVM only but it may work for some compilers - DWORD index = __builtin_clz(__builtin_arm_rbit(value)); -#elif !defined(_AMD64_) - const unsigned PRIME = 37; - - static const char hashTable[PRIME] = - { - -1, 0, 1, 26, 2, 23, 27, -1, 3, 16, - 24, 30, 28, 11, -1, 13, 4, 7, 17, -1, - 25, 22, 31, 15, 29, 10, 12, 6, -1, 21, - 14, 9, 5, 20, 8, 19, 18 - }; - - _ASSERTE(PRIME >= 8*sizeof(value)); - _ASSERTE(sizeof(hashTable) == PRIME); - - - unsigned hash = value % PRIME; - unsigned index = hashTable[hash]; - _ASSERTE(index != (unsigned char)-1); -#else - // not enabled for x86 because BSF is extremely slow on Atom - // (15 clock cycles vs 1-3 on any other Intel CPU post-P4) - DWORD index; - BitScanForward(&index, value); -#endif - return index; -} - -#endif diff --git a/src/inc/bitvector.h b/src/inc/bitvector.h deleted file mode 100644 index a4181dbb8..000000000 --- a/src/inc/bitvector.h +++ /dev/null @@ -1,462 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - - -/***************************************************************************/ -/* BitVector.h */ -/***************************************************************************/ -// Routines to support a growable bitvector -/***************************************************************************/ - -#ifndef BITVECTOR_H -#define BITVECTOR_H 1 - - -#ifndef LIMITED_METHOD_CONTRACT -#define LIMITED_METHOD_CONTRACT -#define UNDEF_LIMITED_METHOD_CONTRACT -#endif - -#ifndef WRAPPER_NO_CONTRACT -#define WRAPPER_NO_CONTRACT -#define UNDEF_WRAPPER_NO_CONTRACT -#endif - -#ifndef SUPPORTS_DAC -#define SUPPORTS_DAC -#define UNDEF_SUPPORTS_DAC -#endif - -#ifndef _ASSERTE -#define _ASSERTE(x) -#define UNDEF_ASSERTE -#endif - -#define USE_BITVECTOR 1 -#if USE_BITVECTOR - -/* The bitvector class is meant to be a drop in replacement for an integer - (that is you use it like an integer), however it grows as needed. - - Features: - plug compatible with normal integers; - grows as needed - Optimized for the small case when the vector fits in machine word - Uses one machine word if vector fits in machine word (minus a bit) - - Some caveates: - You should use mutator operators &=, |= ... instead of the - non-mutators whenever possible to avoid creating a temps - - Specifically did NOT supply automatic coersions to - and from short types so that the programmer is aware of - when code was being injected on his behalf. The upshot of this - is that you have to use the BitVector() toUnsigned() to convert -*/ - -/***************************************************************************/ - -class BitVector { - // Set this to be unsigned char to do testing, should be UINT_PTR for real life - - typedef UINT_PTR ChunkType; // The size of integer type that the machine can operate on directly -// typedef BYTE ChunkType; // Use for testing - - // Maximum number of bits in our bitvector -#define MAX_PTRARG_OFS 1024 - - enum { - IS_BIG = 1, // The low bit is used to discrimate m_val and m_vals - CHUNK_BITS = sizeof(ChunkType)*8, // The number of bits that we can manipuate as a chunk - SMALL_BITS = CHUNK_BITS - 1, // The number of bits we can fit in the small representation -// SMALL_BITS = 5, // TESTING ONLY: The number of bits we can fit in the small representation - VALS_COUNT = MAX_PTRARG_OFS / CHUNK_BITS, // The number of ChunkType elements in the Vals array - }; - -public: - BitVector() - { - LIMITED_METHOD_CONTRACT; - SUPPORTS_DAC; - - m_val = 0; - } - - BOOL isBig() const - { - LIMITED_METHOD_CONTRACT; - SUPPORTS_DAC; - - return ((m_val & IS_BIG) != 0); - } - - void toBig() - { - LIMITED_METHOD_CONTRACT; - SUPPORTS_DAC; - - if (!isBig()) - { - doBigInit(smallBits()); - } - } - - explicit BitVector(ChunkType arg) - { - WRAPPER_NO_CONTRACT; - SUPPORTS_DAC; - - if (arg > MaxVal) - { - doBigInit(arg); - } - else - { - m_val = ChunkType(arg << 1); - } - } - - BitVector(ChunkType arg, UINT shift) - { - WRAPPER_NO_CONTRACT; - SUPPORTS_DAC; - - if ((arg > MaxVal) || (shift >= SMALL_BITS) || (arg > (MaxVal >> shift))) - { - doBigInit(arg); - doBigLeftShiftAssign(shift); - } - else - { - m_val = ChunkType(arg << (shift+1)); - } - } - -#define CONSTRUCT_ptrArgTP(arg,shift) BitVector((arg), (shift)) - - BitVector(const BitVector& arg) - { - WRAPPER_NO_CONTRACT; - SUPPORTS_DAC; - - if (arg.isBig()) - { - doBigInit(arg); - } - else - { - m_val = arg.m_val; - } - } - - void operator <<=(unsigned shift) - { - WRAPPER_NO_CONTRACT; - SUPPORTS_DAC; - - if ((m_val == 0) || (shift == 0)) // Zero is a special case, don't need to do anything - return; - - if (isBig() || (shift >= SMALL_BITS) || (m_val > (MaxVal >> (shift-1)))) - { - doBigLeftShiftAssign(shift); - } - else - { - m_val <<= shift; - } - } - - void operator >>=(unsigned shift) - { - WRAPPER_NO_CONTRACT; - SUPPORTS_DAC; - - if (isBig()) - { - doBigRightShiftAssign(shift); - } - else - { - m_val >>= shift; - m_val &= ~IS_BIG; // clear the isBig bit if it got set - } - } - - void operator |=(const BitVector& arg) - { - WRAPPER_NO_CONTRACT; - SUPPORTS_DAC; - - if (((m_val | arg.m_val) & IS_BIG) != 0) - { - doBigOrAssign(arg); - } - else - { - m_val |= arg.m_val; - } - } - - // Note that that is set difference, not subtration - void operator -=(const BitVector& arg) - { - WRAPPER_NO_CONTRACT; - SUPPORTS_DAC; - - if (((m_val | arg.m_val) & IS_BIG) != 0) - { - doBigDiffAssign(arg); - } - else - { - m_val &= ~arg.m_val; - } - } - - void operator &=(const BitVector& arg) - { - WRAPPER_NO_CONTRACT; - SUPPORTS_DAC; - - if (((m_val | arg.m_val) & IS_BIG) != 0) - { - doBigAndAssign(arg); - } - else - { - m_val &= arg.m_val; - } - } - - friend void setDiff(BitVector& target, const BitVector& arg) - { - WRAPPER_NO_CONTRACT; - SUPPORTS_DAC; - - target -= arg; - } - - friend BOOL intersect(const BitVector& arg1, const BitVector& arg2) - { - WRAPPER_NO_CONTRACT; - SUPPORTS_DAC; - - if (((arg1.m_val | arg2.m_val) & IS_BIG) != 0) - { - return arg1.doBigIntersect(arg2); - } - else - { - return ((arg1.m_val & arg2.m_val) != 0); - } - } - - BOOL operator ==(const BitVector& arg) const - { - WRAPPER_NO_CONTRACT; - SUPPORTS_DAC; - - if ((m_val | arg.m_val) & IS_BIG) - { - return doBigEquals(arg); - } - else - { - return m_val == arg.m_val; - } - } - - BOOL operator !=(const BitVector& arg) const - { - WRAPPER_NO_CONTRACT; - SUPPORTS_DAC; - - return !(*this == arg); - } - - friend ChunkType toUnsigned(const BitVector& arg) - { - WRAPPER_NO_CONTRACT; - SUPPORTS_DAC; - - if (arg.isBig()) - { - return arg.m_vals.m_chunks[0]; // Note truncation - } - else - { - return arg.smallBits(); - } - } - - // Note that we require the invariant that zero is always stored in the - // small form so that this works bitvector is zero iff (m_val == 0) - friend BOOL isZero(const BitVector& arg) - { - WRAPPER_NO_CONTRACT; - SUPPORTS_DAC; - - return arg.m_val == 0; - } - - /* currently only used in asserts */ - BitVector operator &(const BitVector& arg) const - { - WRAPPER_NO_CONTRACT; - SUPPORTS_DAC; - - BitVector ret = *this; - ret &= arg; - return ret; - } - - int NumBits() const; - -private: - - static const ChunkType MaxVal = ((ChunkType)1 << SMALL_BITS) - 1; // Maximum value that can be stored in m_val - - // This is the structure that we use when the bit vector overflows. - // It is a simple vector. - struct Vals { - unsigned m_encodedLength; // An encoding of the current length of the 'm_chunks' array - ChunkType m_chunks[VALS_COUNT]; - - BOOL isBig() const - { - LIMITED_METHOD_CONTRACT; - SUPPORTS_DAC; - - return ((m_encodedLength & IS_BIG) != 0); - } - - unsigned GetLength() const - { - LIMITED_METHOD_CONTRACT; - SUPPORTS_DAC; - - if (isBig()) - { - unsigned length = (m_encodedLength >> 1); - _ASSERTE(length > 0); - return length; - } - else - { - return 0; - } - } - - void SetLength(unsigned length) - { - LIMITED_METHOD_CONTRACT; - SUPPORTS_DAC; - - _ASSERTE(length > 0); - _ASSERTE(length <= VALS_COUNT); - - m_encodedLength = (ChunkType) (length << 1); - m_encodedLength |= (ChunkType) IS_BIG; - } - }; - - // - // This is the instance data for the bitvector - // - // We discrimininate on this - union { - ChunkType m_val; // if m_val bit 0 is false, then bits 1-N are the bit vector - Vals m_vals; // if m_val bit 1 is true, then use Vals - }; - - - ChunkType smallBits() const - { - LIMITED_METHOD_CONTRACT; - SUPPORTS_DAC; - - _ASSERTE(!isBig()); - return (m_val >> 1); - } - -#ifdef STRIKE - void doBigInit(ChunkType arg) {} -#else - void doBigInit(ChunkType arg); -#endif - void doBigInit(const BitVector& arg); - void doBigLeftShiftAssign(unsigned arg); - void doBigRightShiftAssign(unsigned arg); - void doBigDiffAssign(const BitVector&); - void doBigAndAssign(const BitVector&); - void doBigOrAssign(const BitVector& arg); - BOOL doBigEquals(const BitVector&) const; - BOOL doBigIntersect(const BitVector&) const; -}; - -typedef BitVector ptrArgTP; - -#else // !USE_BITVECTOR - -typedef unsigned __int64 ptrArgTP; - - // Maximum number of bits in our bitvector -#define MAX_PTRARG_OFS (sizeof(ptrArgTP) * 8) - -#define CONSTRUCT_ptrArgTP(arg,shift) (((ptrArgTP) (arg)) << (shift)) - -inline BOOL isZero(const ptrArgTP& arg) -{ - LIMITED_METHOD_CONTRACT; - SUPPORTS_DAC; - return (arg == 0); -} - -inline ptrArgTP toUnsigned(const ptrArgTP& arg) -{ - LIMITED_METHOD_CONTRACT; - SUPPORTS_DAC; - return arg; -} - -inline void setDiff(ptrArgTP& target, const ptrArgTP& arg) -{ - LIMITED_METHOD_CONTRACT; - SUPPORTS_DAC; - - target &= ~arg; -} - -inline BOOL intersect(const ptrArgTP arg1, const ptrArgTP arg2) -{ - LIMITED_METHOD_CONTRACT; - SUPPORTS_DAC; - - return ((arg1 & arg2) != 0); -} - -#endif // !USE_BITVECTOR - -#ifdef UNDEF_LIMITED_METHOD_CONTRACT -#undef LIMITED_METHOD_CONTRACT -#undef UNDEF_LIMITED_METHOD_CONTRACT -#endif - -#ifdef UNDEF_WRAPPER_NO_CONTRACT -#undef WRAPPER_NO_CONTRACT -#undef UNDEF_WRAPPER_NO_CONTRACT -#endif - -#ifdef UNDEF_SUPPORTS_DAC -#undef SUPPORTS_DAC -#undef UNDEF_SUPPORTS_DAC -#endif - -#ifdef UNDEF_ASSERTE -#undef _ASSERTE -#undef UNDEF_ASSERTE -#endif - -#endif // BITVECTOR_H diff --git a/src/inc/blobfetcher.h b/src/inc/blobfetcher.h deleted file mode 100644 index 0c640f0d6..000000000 --- a/src/inc/blobfetcher.h +++ /dev/null @@ -1,174 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -//***************************************************************************** -// CBlobFetcher - it fetches binary chunks, similar to new, but more controlled -// -// Fast, dynamic, memory management which doesn't relocate blocks -// m_pIndex has array of pillars, where each pillar starts off empty and has -// just-in-time allocation. As each pillar fills up, we move to the next pillar -// If the entire array of pillars fill up, we need to allocate a new array and -// copy the pillars over. But the actual data returned from GetBlock() never -// gets moved. So everyone's happy. -// -//***************************************************************************** - - -#ifndef __BLOB_FETCHER_H_ -#define __BLOB_FETCHER_H_ - -#include - - -class CBlobFetcher -{ -protected: - - class CPillar { - public: - CPillar(); - ~CPillar(); - - void SetAllocateSize(unsigned nSize); - unsigned GetAllocateSize() const; - - char* MakeNewBlock(unsigned len, unsigned pad); - void StealDataFrom(CPillar & src); - unsigned GetDataLen() const; - char* GetRawDataStart(); - BOOL Contains(__in char *ptr); - ULONG32 GetOffset(__in char *ptr); - - protected: - unsigned m_nTargetSize; // when we allocate, make it this large - - // Make these public so CBlobFetcher can do easy manipulation - public: - char* m_dataAlloc; - char* m_dataStart; - char* m_dataCur; - char* m_dataEnd; - }; - - - CPillar * m_pIndex; // array of pillars - - unsigned m_nIndexMax; // actual size of m_ppIndex - unsigned m_nIndexUsed; // current pillar, so start at 0 - - unsigned m_nDataLen; // sum of all pillars' lengths - -// Don't allow these because they'll mess up the ownership - CBlobFetcher(const CBlobFetcher & src); - CBlobFetcher& operator=(const CBlobFetcher & src); - -public: -#if defined(_WIN64) - // needs to be 64 so that we can purposefully cache align code in ngen'd images - enum { maxAlign = 64 }; // maximum alignment we support -#else - enum { maxAlign = 32 }; // maximum alignment we support -#endif - CBlobFetcher(); - ~CBlobFetcher(); - -// get a block to write on (use instead of write to avoid copy) - char * MakeNewBlock(unsigned int nSize, unsigned align=1); - -// Index segment as if this were linear - char * ComputePointer(unsigned offset) const; - -// Determine if pointer came from this fetcher - BOOL ContainsPointer(__in char *ptr) const; - -// Find an offset as if this were linear - unsigned ComputeOffset(__in char *ptr) const; - -// Write out the section to the stream - HRESULT Write(HANDLE file); - -// Write out the section to memory - HRESULT WriteMem(void ** pMem); - -// Get the total length of all our data (sum of all the pillar's data length's) -// cached value, so light weight & no computations - unsigned GetDataLen() const; - - HRESULT Merge(CBlobFetcher *destination); - -// Set the blob fetcher to slow growth mode. This should be done before any allocations - void SetInitialGrowth(unsigned growth); -}; - - -//***************************************************************************** -// Inlines -//***************************************************************************** - -// Set the size that the Pillar will allocate if we call getBlock() -inline void CBlobFetcher::CPillar::SetAllocateSize(unsigned nSize) -{ - LIMITED_METHOD_CONTRACT; - m_nTargetSize = nSize; -} - -// Get the size we will allocate so we can decide if we need to change it -// This is not the same as the GetDataLen() and is only useful -// before we do the allocation -inline unsigned CBlobFetcher::CPillar::GetAllocateSize() const -{ - LIMITED_METHOD_CONTRACT; - return m_nTargetSize; -} - -inline char* CBlobFetcher::CPillar::GetRawDataStart() -{ - LIMITED_METHOD_CONTRACT; - return m_dataStart; -} - -inline BOOL CBlobFetcher::CPillar::Contains(__in char *ptr) -{ - LIMITED_METHOD_CONTRACT; - - return ptr >= m_dataStart && ptr < m_dataCur; -} - -inline ULONG32 CBlobFetcher::CPillar::GetOffset(__in char *ptr) -{ - LIMITED_METHOD_CONTRACT; - _ASSERTE(Contains(ptr)); - - return (ULONG32)(ptr - m_dataStart); -} - -//----------------------------------------------------------------------------- -// Calculate the length of data being used, (not the length allocated) -//----------------------------------------------------------------------------- -inline unsigned CBlobFetcher::CPillar::GetDataLen() const -{ - LIMITED_METHOD_CONTRACT; - - _ASSERTE((m_dataCur >= m_dataStart) && (m_dataCur <= m_dataEnd)); - - return (unsigned)(m_dataCur - m_dataStart); -} - -inline unsigned CBlobFetcher::GetDataLen() const -{ - LIMITED_METHOD_CONTRACT; - - return m_nDataLen; -} - -// Set the blob fetcher to slow growth mode. This should be done before any allocations -inline void CBlobFetcher::SetInitialGrowth(unsigned growth) -{ - _ASSERTE(GetDataLen() == 0); - if (GetDataLen() == 0) - { - m_pIndex[0].SetAllocateSize(growth); - } -} - -#endif // __BLOB_FETCHER_H_ diff --git a/src/inc/cahlpr.h b/src/inc/cahlpr.h deleted file mode 100644 index 903d3abdd..000000000 --- a/src/inc/cahlpr.h +++ /dev/null @@ -1,41 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -//***************************************************************************** -// File: CAHLPR.H -// -// -// -//***************************************************************************** -#ifndef __CAHLPR_H__ -#define __CAHLPR_H__ - -#include "caparser.h" - -//***************************************************************************** -// This class assists in the parsing of CustomAttribute blobs. -//***************************************************************************** -struct CaValue -{ - union - { - signed __int8 i1; - unsigned __int8 u1; - signed __int16 i2; - unsigned __int16 u2; - signed __int32 i4; - unsigned __int32 u4; - signed __int64 i8; - unsigned __int64 u8; - float r4; - double r8; - struct - { - LPCUTF8 pStr; - ULONG cbStr; - } str; - }; - unsigned __int8 tag; -}; - -#endif // __CAHLPR_H__ diff --git a/src/inc/caparser.h b/src/inc/caparser.h deleted file mode 100644 index 0dfbb918b..000000000 --- a/src/inc/caparser.h +++ /dev/null @@ -1,377 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -// -// File: caparser.h -// - - -// - -// -// ============================================================================ - -#ifndef __CAPARSER_H__ -#define __CAPARSER_H__ - -#include "stgpooli.h" - -class CustomAttributeParser { -public: - CustomAttributeParser( // Constructor for CustomAttributeParser. - const void *pvBlob, // Pointer to the CustomAttribute blob. - ULONG cbBlob) // Size of the CustomAttribute blob. - : m_pbCur(reinterpret_cast(pvBlob)), - m_pbBlob(reinterpret_cast(pvBlob)), - m_cbBlob(cbBlob) - { - LIMITED_METHOD_CONTRACT; - } - -private: - signed __int8 GetI1() - { - LIMITED_METHOD_CONTRACT; - signed __int8 tmp = *reinterpret_cast(m_pbCur); - m_pbCur += sizeof(signed __int8); - return tmp; - } - unsigned __int8 GetU1() - { - LIMITED_METHOD_CONTRACT; - unsigned __int8 tmp = *reinterpret_cast(m_pbCur); - m_pbCur += sizeof(unsigned __int8); - return tmp; - } - - signed __int16 GetI2() - { - LIMITED_METHOD_CONTRACT; - signed __int16 tmp = GET_UNALIGNED_VAL16(m_pbCur); - m_pbCur += sizeof(signed __int16); - return tmp; - } - unsigned __int16 GetU2() - { - LIMITED_METHOD_CONTRACT; - unsigned __int16 tmp = GET_UNALIGNED_VAL16(m_pbCur); - m_pbCur += sizeof(unsigned __int16 ); - return tmp; - } - - signed __int32 GetI4() - { - LIMITED_METHOD_CONTRACT; - signed __int32 tmp = GET_UNALIGNED_VAL32(m_pbCur); - m_pbCur += sizeof(signed __int32 ); - return tmp; - } - unsigned __int32 GetU4() - { - LIMITED_METHOD_CONTRACT; - unsigned __int32 tmp = GET_UNALIGNED_VAL32(m_pbCur); - m_pbCur += sizeof(unsigned __int32 ); - return tmp; - } - - signed __int64 GetI8() - { - LIMITED_METHOD_CONTRACT; - signed __int64 tmp = GET_UNALIGNED_VAL64(m_pbCur); - m_pbCur += sizeof(signed __int64 ); - return tmp; - } - unsigned __int64 GetU8() - { - LIMITED_METHOD_CONTRACT; - unsigned __int64 tmp = GET_UNALIGNED_VAL64(m_pbCur); - m_pbCur += sizeof(unsigned __int64 ); - return tmp; - } - -public: - float GetR4() - { - LIMITED_METHOD_CONTRACT; - __int32 tmp = GET_UNALIGNED_VAL32(m_pbCur); - _ASSERTE(sizeof(__int32) == sizeof(float)); - m_pbCur += sizeof(float); - return (float &)tmp; - } - - double GetR8() - { - LIMITED_METHOD_CONTRACT; - __int64 tmp = GET_UNALIGNED_VAL64(m_pbCur); - _ASSERTE(sizeof(__int64) == sizeof(double)); - m_pbCur += sizeof(double); - return (double &)tmp; - } - -private: - unsigned __int16 GetProlog() - { - WRAPPER_NO_CONTRACT; - unsigned __int16 val; - VERIFY(SUCCEEDED(GetProlog(&val))); - return val; - } - - LPCUTF8 GetString(ULONG *pcbString) - { - WRAPPER_NO_CONTRACT; - LPCUTF8 val; - VERIFY(SUCCEEDED(GetString(&val, pcbString))); - return val; - } - -public: - HRESULT GetI1(signed __int8 *pVal) - { - WRAPPER_NO_CONTRACT; - - if (BytesLeft() < (int) sizeof(signed __int8)) - return META_E_CA_INVALID_BLOB; - *pVal = GetI1(); - return S_OK; - } - - HRESULT GetTag(CorSerializationType *pVal) - { - WRAPPER_NO_CONTRACT; - HRESULT hr; - signed __int8 tmp; - IfFailRet(GetI1(&tmp)); - *pVal = (CorSerializationType)((unsigned __int8)tmp); - return hr; - } - - HRESULT GetU1(unsigned __int8 *pVal) - { - WRAPPER_NO_CONTRACT; - - if (BytesLeft() < (int) sizeof(unsigned __int8)) - return META_E_CA_INVALID_BLOB; - *pVal = GetU1(); - return S_OK; - } - - HRESULT GetI2(signed __int16 *pVal) - { - WRAPPER_NO_CONTRACT; - - if (BytesLeft() < (int) sizeof(signed __int16)) - return META_E_CA_INVALID_BLOB; - *pVal = GetI2(); - return S_OK; - } - HRESULT GetU2(unsigned __int16 *pVal) - { - WRAPPER_NO_CONTRACT; - - if (BytesLeft() < (int) sizeof(unsigned __int16)) - return META_E_CA_INVALID_BLOB; - *pVal = GetU2(); - return S_OK; - } - - HRESULT GetI4(signed __int32 *pVal) - { - WRAPPER_NO_CONTRACT; - - if (BytesLeft() < (int) sizeof(signed __int32)) - return META_E_CA_INVALID_BLOB; - *pVal = GetI4(); - return S_OK; - } - HRESULT GetU4(unsigned __int32 *pVal) - { - WRAPPER_NO_CONTRACT; - - if (BytesLeft() < (int) sizeof(unsigned __int32)) - return META_E_CA_INVALID_BLOB; - *pVal = GetU4(); - return S_OK; - } - - HRESULT GetI8(signed __int64 *pVal) - { - WRAPPER_NO_CONTRACT; - - if (BytesLeft() < (int) sizeof(signed __int64)) - return META_E_CA_INVALID_BLOB; - *pVal = GetI8(); - return S_OK; - } - HRESULT GetU8(unsigned __int64 *pVal) - { - WRAPPER_NO_CONTRACT; - - if (BytesLeft() < (int) sizeof(unsigned __int64)) - return META_E_CA_INVALID_BLOB; - *pVal = GetU8(); - return S_OK; - } - - HRESULT GetR4(float *pVal) - { - WRAPPER_NO_CONTRACT; - - if (BytesLeft() < (int) sizeof(float)) - return META_E_CA_INVALID_BLOB; - *pVal = GetR4(); - return S_OK; - } - HRESULT GetR8(double *pVal) - { - WRAPPER_NO_CONTRACT; - - if (BytesLeft() < (int) sizeof(double)) - return META_E_CA_INVALID_BLOB; - *pVal = GetR8(); - return S_OK; - } - - HRESULT GetProlog(unsigned __int16 *pVal) - { - WRAPPER_NO_CONTRACT; - - m_pbCur = m_pbBlob; - - if (BytesLeft() < (int)(sizeof(BYTE) * 2)) - return META_E_CA_INVALID_BLOB; - - return GetU2(pVal); - } - - // Added for compatibility with anyone that may emit - // blobs where the prolog is the only incorrect data. - HRESULT SkipProlog() - { - unsigned __int16 val; - return GetProlog(&val); - } - - HRESULT ValidateProlog() - { - HRESULT hr; - unsigned __int16 val; - IfFailRet(GetProlog(&val)); - - if (val != 0x0001) - return META_E_CA_INVALID_BLOB; - - return hr; - } - - // - // IMPORTANT: the returned string is typically not null-terminated. - // - // This can return any of three distinct valid results: - // - NULL string, indicated by *pszString==NULL, *pcbString==0 - // - empty string, indicated by *pszString!=NULL, *pcbString==0 - // - non-empty string, indicated by *pdzString!=NULL, *pcbString!=0 - // If you expect non-null or non-empty strings in your usage scenario, - // call the GetNonNullString and GetNonEmptyString helpers below. - // - HRESULT GetString(LPCUTF8 *pszString, ULONG *pcbString) - { - STATIC_CONTRACT_NOTHROW; - STATIC_CONTRACT_FORBID_FAULT; - - HRESULT hr; - - if (BytesLeft() == 0) - { // Need to check for NULL string sentinal (see below), - // so need to have at least one byte to read. - IfFailRet(META_E_CA_INVALID_BLOB); - } - - if (*m_pbCur == 0xFF) - { // 0xFF indicates the NULL string, which is semantically - // different than the empty string. - *pszString = NULL; - *pcbString = 0; - m_pbCur++; - return S_OK; - } - - // Get the length, pointer to data following the length. - return GetData((BYTE const **)pszString, pcbString); - } - - // - // This can return any of two distinct valid results: - // - empty string, indicated by *pszString!=NULL, *pcbString==0 - // - non-empty string, indicated by *pszString!=NULL, *pcbString!=0 - // If you expect non-null or non-empty strings in your usage scenario, - // call the GetNonNullString and GetNonEmptyString helpers below. - // - HRESULT GetNonNullString(LPCUTF8 *pszString, ULONG *pcbString) - { - STATIC_CONTRACT_NOTHROW; - STATIC_CONTRACT_FORBID_FAULT; - - HRESULT hr; - - IfFailRet(GetString(pszString, pcbString)); - - if (*pszString == NULL) - { - return META_E_CA_INVALID_BLOB; - } - - return S_OK; - } - - // - // This function will only return success if the string is valid, - // non-NULL and non-empty; i.e., *pszString!=NULL, *pcbString!=0 - // - HRESULT GetNonEmptyString(LPCUTF8 *pszString, ULONG *pcbString) - { - STATIC_CONTRACT_NOTHROW; - STATIC_CONTRACT_FORBID_FAULT; - - HRESULT hr; - - IfFailRet(GetNonNullString(pszString, pcbString)); - - if (*pcbString == 0) - { - return META_E_CA_INVALID_BLOB; - } - - return S_OK; - } - - // IMPORTANT: do not use with string fetching - use GetString instead. - HRESULT GetData(BYTE const **ppbData, ULONG *pcbData) - { - HRESULT hr; - IfFailRet(CPackedLen::SafeGetData(m_pbCur, m_pbBlob + m_cbBlob, pcbData, ppbData)); - // Move past the data we just recovered - m_pbCur = *ppbData + *pcbData; - - return S_OK; - } - - // IMPORTANT: do not use with string fetching - use GetString instead. - HRESULT GetPackedValue(ULONG *pcbData) - { - return CPackedLen::SafeGetLength(m_pbCur, m_pbBlob + m_cbBlob, pcbData, &m_pbCur); - } - - int BytesLeft() - { - LIMITED_METHOD_CONTRACT; - return (int)(m_cbBlob - (m_pbCur - m_pbBlob)); - } - -private: - const BYTE *m_pbCur; - const BYTE *m_pbBlob; - ULONG m_cbBlob; -}; - -#endif // __CAPARSER_H__ diff --git a/src/inc/ceefilegenwriter.h b/src/inc/ceefilegenwriter.h deleted file mode 100644 index 8bfea464c..000000000 --- a/src/inc/ceefilegenwriter.h +++ /dev/null @@ -1,245 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -// =========================================================================== -// File: CeeFileGenWriter.h -// -// =========================================================================== - -#ifndef _CEEFILEGENWRITER_H_ -#define _CEEFILEGENWRITER_H_ -// - -// CeeFileGenWriter contains all the code necessary to actually write an exe -// while CCeeGen contains everything else. This lets CeeGen.exe and the VM -// share more code without forcing the VM to carry the extra code to write an -// exe. -#include -#include "ceegen.h" -#include "iceefilegen.h" - -class PEWriter; -class CeeFileGenWriter; - -// default setting for PE file -const UINT32 CEE_IMAGE_BASE_32 = 0x00400000; -const UINT64 CEE_IMAGE_BASE_64 = UI64(0x0000000140000000); -const int CEE_IMAGE_SUBSYSTEM_MAJOR_VERSION = 4; -const int CEE_IMAGE_SUBSYSTEM_MINOR_VERSION = 0; - -class CeeFileGenWriter : public CCeeGen -{ - mdToken m_entryPoint; // token for entry point - DWORD m_comImageFlags; - - LPWSTR m_outputFileName; - LPWSTR m_resourceFileName; - LPWSTR m_libraryName; - GUID m_libraryGuid; - bool m_dllSwitch; - - ULONG m_iatOffset; - DWORD m_dwMacroDefinitionRVA; - DWORD m_dwMacroDefinitionSize; - - DWORD m_dwManifestRVA; - DWORD m_dwManifestSize; - - DWORD m_dwStrongNameRVA; - DWORD m_dwStrongNameSize; - - DWORD m_dwVTableRVA; - DWORD m_dwVTableSize; - - bool m_linked; - bool m_fixed; - - HRESULT checkForErrors(); - - struct IDataDllInfo { - const char *m_name; - int m_numMethods; - const char **m_methodName; - int m_iltOffset; - int m_ibnOffset; - int m_iatOffset; - int m_nameOffset; - } *m_iDataDlls; - int m_dllCount; - - CeeSection *m_iDataSectionIAT; - int m_iDataOffsetIAT; - char *m_iDataIAT; - -#ifdef EMIT_FIXUPS - - CeeSection * m_sectionFixups; - IMAGE_DEBUG_DIRECTORY * m_pDebugDir; - bool m_fFixupsUpdated; - bool m_fEmitFixups; - -#endif - - HRESULT allocateIAT(); -public: - // Create with one of these two methods, not operator new - static HRESULT CreateNewInstance(CCeeGen *pCeeFileGenFrom, CeeFileGenWriter* & pGenWriter, - DWORD createFlags = ICEE_CREATE_FILE_PURE_IL); - // See ICeeFileGen.h for the definition of the bits used in createFlags - static HRESULT CreateNewInstanceEx(CCeeGen *pCeeFileGenFrom, CeeFileGenWriter* & pGenWriter, - DWORD createFlags, LPCWSTR seedFileName = NULL); - - virtual HRESULT Cleanup(); - - PEWriter &getPEWriter(); - - HRESULT link(); // Layout the sections and assign their starting addresses - HRESULT fixup(); // Apply relocations to any pointer data. Also generate PE base relocs - HRESULT generateImage(void **ppImage); - - HRESULT setImageBase(size_t imageBase); - HRESULT setImageBase64(ULONGLONG imageBase); - HRESULT setFileAlignment(ULONG fileAlignment); - HRESULT setSubsystem(DWORD subsystem, DWORD major, DWORD minor); - - HRESULT getMethodRVA(ULONG codeOffset, ULONG *codeRVA); - - HRESULT setEntryPoint(mdMethodDef method); - mdMethodDef getEntryPoint(); - - HRESULT setComImageFlags(DWORD mask); - HRESULT clearComImageFlags(DWORD mask); - DWORD getComImageFlags(); - - HRESULT setOutputFileName(__in LPWSTR outputFileName); - LPWSTR getOutputFileName(); - - HRESULT setResourceFileName(__in LPWSTR resourceFileName); - LPWSTR getResourceFileName(); - - HRESULT setLibraryName(__in LPWSTR libraryName); - LPWSTR getLibraryName(); - - HRESULT setDirectoryEntry(CeeSection §ion, ULONG entry, ULONG size, ULONG offset=0); - HRESULT computeSectionOffset(CeeSection §ion, __in char *ptr, - unsigned *offset); - HRESULT computeOffset(__in char *ptr, CeeSection **pSection, - unsigned *offset); - HRESULT getCorHeader(IMAGE_COR20_HEADER **ppHeader); - - HRESULT getFileTimeStamp(DWORD *pTimeStamp); - -//@FUTURE: this entry point is only here so that down level clients of this interface -// can import the method by name in the exports table using the original name. -// These things really ought to be exported through a v-table so there is no -// name mangling issues. It would make the export table much smaller as well. - HRESULT emitLibraryName(IMetaDataEmit *emitter); - HRESULT setLibraryGuid(__in LPWSTR libraryGuid); - - HRESULT setDllSwitch(bool dllSwitch); - bool getDllSwitch(); - HRESULT setObjSwitch(bool objSwitch); - bool getObjSwitch(); - HRESULT EmitMacroDefinitions(void *pData, DWORD cData); - HRESULT setManifestEntry(ULONG size, ULONG offset); - HRESULT setStrongNameEntry(ULONG size, ULONG offset); - HRESULT setEnCRvaBase(ULONG dataBase, ULONG rdataBase); - HRESULT setVTableEntry(ULONG size, ULONG offset); - HRESULT setVTableEntry64(ULONG size, void* ptr); - -protected: - CeeFileGenWriter(); // ctor is protected - - HRESULT emitResourceSection(); - HRESULT emitExeMain(); - - HRESULT setAddrReloc(UCHAR *instrAddr, DWORD value); - HRESULT addAddrReloc(CeeSection &thisSection, UCHAR *instrAddr, DWORD offset, CeeSection *targetSection); - - HRESULT MapTokens(CeeGenTokenMapper *pMapper, IMetaDataImport *pImport); - HRESULT MapTokensForMethod(CeeGenTokenMapper *pMapper,BYTE *pCode, LPCWSTR szMethodName); - -#ifdef EMIT_FIXUPS - - HRESULT InitFixupSection(); - HRESULT UpdateFixups(); - HRESULT setEmitFixups(); - -#ifdef TEST_EMIT_FIXUPS - HRESULT TestEmitFixups(); -#endif - -public: - HRESULT addFixup(CeeSection& secFixups, unsigned offset, CeeSectionRelocType reloc, CeeSection * relativeTo = NULL, CeeSectionRelocExtra *extra = 0); -#endif -}; - - -inline PEWriter &CeeFileGenWriter::getPEWriter() -{ - return (PEWriter &) *m_peSectionMan; -} - -inline LPWSTR CeeFileGenWriter::getOutputFileName() { - return m_outputFileName; -} - -inline LPWSTR CeeFileGenWriter::getResourceFileName() { - return m_resourceFileName; -} - -inline HRESULT CeeFileGenWriter::setDllSwitch(bool dllSwitch) { - if((m_dllSwitch = dllSwitch)) m_objSwitch = FALSE; return S_OK; -} - -inline bool CeeFileGenWriter::getDllSwitch() { - return m_dllSwitch; -} - -inline HRESULT CeeFileGenWriter::setObjSwitch(bool objSwitch) { - if((m_objSwitch = objSwitch)) m_dllSwitch = FALSE; return S_OK; -} - -inline bool CeeFileGenWriter::getObjSwitch() { - return m_objSwitch; -} - -inline LPWSTR CeeFileGenWriter::getLibraryName() { - return m_libraryName; -} - -inline mdMethodDef CeeFileGenWriter::getEntryPoint() { - return m_entryPoint; -} - -inline HRESULT CeeFileGenWriter::setEntryPoint(mdMethodDef method) { - m_entryPoint = method; - return S_OK; -} - -inline HRESULT CeeFileGenWriter::setComImageFlags(DWORD mask) { - m_comImageFlags |= mask; return S_OK; -} - -inline HRESULT CeeFileGenWriter::clearComImageFlags(DWORD mask) { - m_comImageFlags &= ~mask; return S_OK; -} - -inline DWORD CeeFileGenWriter::getComImageFlags() { - return m_comImageFlags; -} - - -// -#if defined(_IMAGE_FILE_4K_SECTION_ALIGNMENT_) -#define IMAGE_NT_OPTIONAL_HDR_SECTION_ALIGNMENT 0x1000 -#else -#define IMAGE_NT_OPTIONAL_HDR_SECTION_ALIGNMENT 0x2000 -#endif - -// The stub is always x86 so we always mark the image as x86 -#define IMAGE_FILE_MACHINE IMAGE_FILE_MACHINE_I386 - - -#endif // _CEEFILEGENWRITER_H_ - diff --git a/src/inc/ceegen.h b/src/inc/ceegen.h deleted file mode 100644 index c7d2af261..000000000 --- a/src/inc/ceegen.h +++ /dev/null @@ -1,437 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -// =========================================================================== -// File: CEEGEN.H -// -// =========================================================================== - -#ifndef _CEEGEN_H_ -#define _CEEGEN_H_ - -#include "cor.h" -#include "iceefilegen.h" -#include "ceegentokenmapper.h" - -class CeeSection; -class CeeSectionString; -class CCeeGen; -class PESectionMan; -class PESection; - -typedef DWORD StringRef; - -#if 0 - - This is a description of the current implementation of these types for generating - CLR modules. - - ICeeGen - interface to generate in-memory CLR module. - - CCeeGen - implementation of ICeeGen. Currently it uses both CeeSections - as well as PESections (inside PESectionMan), and maintains a - 1:1 relation between them. This is ugly. - - CeeFileGenWriter - Provides functionality to write in-memory module to - PE format file. Uses PEWriter (m_pSectionMan) for - file-writing functionality - - PEWriter - It can generate a PE format file. It also knows to apply - pointer relocs when it lays out the PESections. - - - ICeeFileGen - Interface used by compilers, ngen, etc, to generate - a CLR file. - Has a bunch of methods to emit signatures, tokens, methods, - etc which are not implemented. These are left over from before - - +----------------------------+ - | ICeeGen | - | | - | COM-style version of | - | ICeeFileGen. HCEEFILE is | - | replaced with "this" | - +-------------------------+ | | - | CeeSectionImpl | +----------------------------+ - +-------------------------+ | - | | | - | | v - | v +---------------------------+ - | +------------+ | CCeeGen | - | | | +---------------------------+ - | | CeeSection | contains | | - | | |<-------------| CeeSection* m_sections | - | +------------+ | | - | /| PESectionMan m_pSectionMan| - | / | | - | +-----------------+ / +---------------------------+ - v | PESectionMan |<----+ | - +-----------+ | | contains | - | PESection | +-----------------+ | - | | contains | PESection * | v - | |<----------| sectStart, | +------------------------------+ - +-----------+ | sectCur, | | CeeFileGenWriter | - | sectEnd | +------------------------------+ - +-----------------+ | Does meta-data specific | - | | stuff and then dispatches to | - | | m_pSectionMan.PEWriter::***()| - | | | - v +------------------------------+ - +------------------------+ ^ - | PEWriter | |wraps - +------------------------+ | - | Low -level file writer | +----------------------------+ - | Knows how to do | | ICeeFileGen | - | pointer relocs | | | - | | | C-style inteface. Deals | - +------------------------+ | with HCEEFILE, HCEESECTION | - | etc. It is mostly just a | - | thin wrapper for a | - | CeeFileGenWriter | - +----------------------------+ - -#endif // 0 - -// ***** CeeSection classes - -class CeeSectionImpl { - public: - virtual unsigned dataLen() = 0; - virtual char * getBlock( - unsigned len, - unsigned align = 1) = 0; - virtual HRESULT addSectReloc( - unsigned offset, - CeeSection & relativeTo, - CeeSectionRelocType reloc = srRelocAbsolute, - CeeSectionRelocExtra * extra = NULL) = 0; - virtual HRESULT addBaseReloc( - unsigned offset, - CeeSectionRelocType reloc = srRelocHighLow, - CeeSectionRelocExtra * extra = NULL) = 0; - virtual HRESULT directoryEntry(unsigned num) = 0; - virtual unsigned char * name() = 0; - virtual char * computePointer(unsigned offset) const = 0; - virtual BOOL containsPointer(__in char * ptr) const = 0; - virtual unsigned computeOffset(__in char * ptr) const = 0; - virtual unsigned getBaseRVA() = 0; - virtual void SetInitialGrowth(unsigned growth) = 0; -}; - -class CeeSection { - // m_ceeFile allows inter-section communication - CCeeGen &m_ceeFile; - - // abstract away implementation to allow inheritance from CeeSection - CeeSectionImpl &m_impl; - - public: - enum RelocFlags { - RELOC_NONE = 0, - - // address should be fixed up to be a RVA not a normal address - RELOC_RVA = 1 - }; - - CeeSection(CCeeGen &ceeFile, CeeSectionImpl &impl) - : m_ceeFile(ceeFile), m_impl(impl) { LIMITED_METHOD_CONTRACT; } - - virtual ~CeeSection() {LIMITED_METHOD_CONTRACT; } - - // bytes in this section at present - unsigned dataLen(); - - // section base, after linking - unsigned getBaseRVA(); - - // get a block to write on (use instead of write to avoid copy) - char* getBlock(unsigned len, unsigned align=1); - - // Indicates that the DWORD at 'offset' in the current section should - // have the base of section 'relativeTo added to it - HRESULT addSectReloc(unsigned offset, CeeSection& relativeTo, - CeeSectionRelocType = srRelocAbsolute, CeeSectionRelocExtra *extra = 0); - // Add a base reloc for the given offset in the current section - virtual HRESULT addBaseReloc(unsigned offset, CeeSectionRelocType reloc = srRelocHighLow, CeeSectionRelocExtra *extra = 0); - - - // this section will be directory entry 'num' - HRESULT directoryEntry(unsigned num); - - // return section name - unsigned char *name(); - - // simulate the base + offset with a more complex data storage - char * computePointer(unsigned offset) const; - BOOL containsPointer(__in char *ptr) const; - unsigned computeOffset(__in char *ptr) const; - - CeeSectionImpl &getImpl(); - CCeeGen &ceeFile(); - void SetInitialGrowth(unsigned growth); -}; - -// ***** CCeeGen class -// Only handles in memory stuff -// Base class for CeeFileGenWriter (which actually generates PEFiles) - -class CCeeGen : public ICeeGen, ICeeGenInternal { - LONG m_cRefs; - BOOL m_encMode; - protected: - short m_textIdx; // m_sections[] index for the .text section - short m_metaIdx; // m_sections[] index for metadata (.text, or .cormeta for obj files) - short m_corHdrIdx; // m_sections[] index for the COM+ header (.text0) - short m_stringIdx; // m_sections[] index for strings (.text, or .rdata for EnC) - short m_ilIdx; // m_sections[] index for IL (.text) - bool m_objSwitch; - - CeeGenTokenMapper *m_pTokenMap; - BOOLEAN m_fTokenMapSupported; // temporary to support both models - IMapToken *m_pRemapHandler; - - CeeSection **m_sections; - short m_numSections; - short m_allocSections; - - PESectionMan * m_peSectionMan; - - IMAGE_COR20_HEADER *m_corHeader; - DWORD m_corHeaderOffset; - - HRESULT allocateCorHeader(); - - HRESULT addSection(CeeSection *section, short *sectionIdx); - - HRESULT setEnCMode(); - -// Init process: Call static CreateNewInstance() , not operator new - protected: - HRESULT Init(); - CCeeGen(); - - public: - - virtual ~CCeeGen() {} - - static HRESULT CreateNewInstance(CCeeGen* & pCeeFileGen); // call this to instantiate - - virtual HRESULT Cleanup(); - - // ICeeGen interfaces - - ULONG STDMETHODCALLTYPE AddRef(); - ULONG STDMETHODCALLTYPE Release(); - STDMETHODIMP QueryInterface( - REFIID riid, - void **ppInterface); - - STDMETHODIMP EmitString ( - __in LPWSTR lpString, // [IN] String to emit - ULONG *RVA); - - STDMETHODIMP GetString ( - ULONG RVA, - __inout LPWSTR *lpString); - - STDMETHODIMP AllocateMethodBuffer ( - ULONG cchBuffer, // [IN] Length of string to emit - UCHAR **lpBuffer, // [OUT] Returned buffer - ULONG *RVA); - - STDMETHODIMP GetMethodBuffer ( - ULONG RVA, - UCHAR **lpBuffer); - - STDMETHODIMP GetIMapTokenIface ( - IUnknown **pIMapToken); - - STDMETHODIMP GenerateCeeFile (); - - STDMETHODIMP GetIlSection ( - HCEESECTION *section); - - STDMETHODIMP GetStringSection ( - HCEESECTION *section); - - STDMETHODIMP AddSectionReloc ( - HCEESECTION section, - ULONG offset, - HCEESECTION relativeTo, - CeeSectionRelocType relocType); - - STDMETHODIMP GetSectionCreate ( - const char *name, - DWORD flags, - HCEESECTION *section); - - STDMETHODIMP GetSectionDataLen ( - HCEESECTION section, - ULONG *dataLen); - - STDMETHODIMP GetSectionBlock ( - HCEESECTION section, - ULONG len, - ULONG align=1, - void **ppBytes=0); - - STDMETHODIMP TruncateSection ( - HCEESECTION section, - ULONG len); - - STDMETHODIMP GenerateCeeMemoryImage (void **ppImage); - - STDMETHODIMP ComputePointer ( - HCEESECTION section, - ULONG RVA, // [IN] RVA for method to return - UCHAR **lpBuffer); // [OUT] Returned buffer - - - STDMETHODIMP AddNotificationHandler(IUnknown *pHandler); - - // Write the metadata in "emitter" to the default metadata section is "section" is 0 - // If 'section != 0, it will put the data in 'buffer'. This - // buffer is assumed to be in 'section' at 'offset' and of size 'buffLen' - // (should use GetSaveSize to insure that buffer is big enough - virtual HRESULT emitMetaData(IMetaDataEmit *emitter, - CeeSection* section=0, DWORD offset=0, BYTE* buffer=0, unsigned buffLen=0); - virtual HRESULT getMethodRVA(ULONG codeOffset, ULONG *codeRVA); - - STDMETHODIMP SetInitialGrowth(DWORD growth); - - CeeSection &getTextSection(); - CeeSection &getMetaSection(); - CeeSection &getCorHeaderSection(); - CeeSectionString &getStringSection(); - CeeSection &getIlSection(); - - virtual HRESULT getSectionCreate (const char *name, DWORD flags, CeeSection **section=NULL, short *sectionIdx = NULL); - - PESectionMan* getPESectionMan() { - LIMITED_METHOD_CONTRACT; - return m_peSectionMan; - } - - virtual HRESULT getMapTokenIface(IUnknown **pIMapToken, IMetaDataEmit *emitter=0); - - CeeGenTokenMapper *getTokenMapper() { - LIMITED_METHOD_CONTRACT; - return m_pTokenMap; - } - - virtual HRESULT addNotificationHandler(IUnknown *pHandler); - - //Clone is actually a misnomer here. This method will copy all of the - //instance variables and then do a deep copy (as necessary) of the sections. - //Section data will be appended onto any information already in the section. - //This is done to support the DynamicIL -> PersistedIL transform. - virtual HRESULT cloneInstance(CCeeGen *destination); - -#ifdef EMIT_FIXUPS -public: - virtual HRESULT addFixup(CeeSection& sectionSource, unsigned offset, CeeSectionRelocType reloc, CeeSection * sectionTarget = NULL, CeeSectionRelocExtra *extra = 0) { - LIMITED_METHOD_CONTRACT; - - return(E_NOTIMPL); - } -#endif -}; - -// ***** CeeSection inline methods - -inline unsigned CeeSection::dataLen() { - WRAPPER_NO_CONTRACT; - return m_impl.dataLen(); } - -inline unsigned CeeSection::getBaseRVA() { - WRAPPER_NO_CONTRACT; - return m_impl.getBaseRVA(); } - -inline char *CeeSection::getBlock(unsigned len, unsigned align) { - WRAPPER_NO_CONTRACT; - return m_impl.getBlock(len, align); } - -inline HRESULT CeeSection::addSectReloc( - unsigned offset, CeeSection& relativeTo, CeeSectionRelocType reloc, CeeSectionRelocExtra *extra) { - WRAPPER_NO_CONTRACT; - return(m_impl.addSectReloc(offset, relativeTo, reloc, extra)); -} - -inline HRESULT CeeSection::addBaseReloc(unsigned offset, CeeSectionRelocType reloc, CeeSectionRelocExtra *extra) { - WRAPPER_NO_CONTRACT; - return(m_impl.addBaseReloc(offset, reloc, extra)); -} - - -inline HRESULT CeeSection::directoryEntry(unsigned num) { - WRAPPER_NO_CONTRACT; - TESTANDRETURN(num < IMAGE_NUMBEROF_DIRECTORY_ENTRIES, E_INVALIDARG); - m_impl.directoryEntry(num); - return S_OK; -} - -inline CCeeGen &CeeSection::ceeFile() { - LIMITED_METHOD_CONTRACT; - return m_ceeFile; } - -inline CeeSectionImpl &CeeSection::getImpl() { - LIMITED_METHOD_CONTRACT; - return m_impl; } - -inline unsigned char *CeeSection::name() { - WRAPPER_NO_CONTRACT; - return m_impl.name(); -} - -inline char * CeeSection::computePointer(unsigned offset) const -{ - WRAPPER_NO_CONTRACT; - return m_impl.computePointer(offset); -} - -inline BOOL CeeSection::containsPointer(__in char *ptr) const -{ - WRAPPER_NO_CONTRACT; - return m_impl.containsPointer(ptr); -} - -inline unsigned CeeSection::computeOffset(__in char *ptr) const -{ - WRAPPER_NO_CONTRACT; - return m_impl.computeOffset(ptr); -} - -inline void CeeSection::SetInitialGrowth(unsigned growth) -{ - WRAPPER_NO_CONTRACT; - m_impl.SetInitialGrowth(growth); -} - -// ***** CCeeGen inline methods - -inline CeeSection &CCeeGen::getTextSection() { - LIMITED_METHOD_CONTRACT; - - return *m_sections[m_textIdx]; } - -inline CeeSection &CCeeGen::getMetaSection() { - LIMITED_METHOD_CONTRACT; - - return *m_sections[m_metaIdx]; } - -inline CeeSection &CCeeGen::getCorHeaderSection() { - LIMITED_METHOD_CONTRACT; - _ASSERTE(m_corHdrIdx >= 0); - return *m_sections[m_corHdrIdx]; } - -inline CeeSectionString &CCeeGen::getStringSection() { - LIMITED_METHOD_CONTRACT; - - return *(CeeSectionString*)m_sections[m_stringIdx]; } - -inline CeeSection &CCeeGen::getIlSection() { - LIMITED_METHOD_CONTRACT; - - return *m_sections[m_ilIdx]; } - -#endif diff --git a/src/inc/ceegentokenmapper.h b/src/inc/ceegentokenmapper.h deleted file mode 100644 index b323ee48b..000000000 --- a/src/inc/ceegentokenmapper.h +++ /dev/null @@ -1,142 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -//***************************************************************************** -// CeeGenTokenMapper.h -// -// This helper class tracks mapped tokens from their old value to the new value -// which can happen when the data is optimized on save. -// -//***************************************************************************** - -#ifndef __CeeGenTokenMapper_h__ -#define __CeeGenTokenMapper_h__ - -#include "utilcode.h" - -typedef CDynArray TOKENMAP; - -#define INDEX_OF_TYPE(type) ((type) >> 24) -//r#define INDEX_FROM_TYPE(type) case INDEX_OF_TYPE(mdt ## type): return (tkix ## type) - -// Define the list of CeeGen tracked tokens -#define CEEGEN_TRACKED_TOKENS() \ - CEEGEN_TRACKED_TOKEN(TypeDef) \ - CEEGEN_TRACKED_TOKEN(InterfaceImpl) \ - CEEGEN_TRACKED_TOKEN(MethodDef) \ - CEEGEN_TRACKED_TOKEN(TypeRef) \ - CEEGEN_TRACKED_TOKEN(MemberRef) \ - CEEGEN_TRACKED_TOKEN(CustomAttribute) \ - CEEGEN_TRACKED_TOKEN(FieldDef) \ - CEEGEN_TRACKED_TOKEN(ParamDef) \ - CEEGEN_TRACKED_TOKEN(File) \ - CEEGEN_TRACKED_TOKEN(GenericParam) \ - -class CCeeGen; - -#define CEEGEN_TRACKED_TOKEN(x) tkix ## x, - -class CeeGenTokenMapper : public IMapToken -{ -friend class CCeeGen; -friend class PESectionMan; -public: - enum - { - CEEGEN_TRACKED_TOKENS() - MAX_TOKENMAP - }; - - static int IndexForType(mdToken tk); - - CeeGenTokenMapper() : m_pIImport(0), m_cRefs(1), m_pIMapToken(NULL) { LIMITED_METHOD_CONTRACT; } - virtual ~CeeGenTokenMapper() {} - -//***************************************************************************** -// IUnknown implementation. -//***************************************************************************** - virtual ULONG STDMETHODCALLTYPE AddRef() - {LIMITED_METHOD_CONTRACT; return ++m_cRefs; } - - virtual ULONG STDMETHODCALLTYPE Release() - { - STATIC_CONTRACT_NOTHROW; - STATIC_CONTRACT_FORBID_FAULT; - SUPPORTS_DAC_HOST_ONLY; - - ULONG cRefs = --m_cRefs; - if (cRefs == 0) - { - if (m_pIMapToken) - { - m_pIMapToken->Release(); - m_pIMapToken = NULL; - } - - delete this; - } - return cRefs; - } - - virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, PVOID *ppIUnk); - -//***************************************************************************** -// Called by the meta data engine when a token is remapped to a new location. -// This value is recorded in the m_rgMap array based on type and rid of the -// from token value. -//***************************************************************************** - virtual HRESULT STDMETHODCALLTYPE Map(mdToken tkImp, mdToken tkEmit); - -//***************************************************************************** -// Check the given token to see if it has moved to a new location. If so, -// return true and give back the new token. -//***************************************************************************** - virtual int HasTokenMoved(mdToken tkFrom, mdToken &tkTo); - - int GetMaxMapSize() const - { LIMITED_METHOD_CONTRACT; return (MAX_TOKENMAP); } - - IUnknown *GetMapTokenIface() const - { LIMITED_METHOD_CONTRACT; return ((IUnknown *) this); } - - -//***************************************************************************** -// Hand out a copy of the meta data information. -//***************************************************************************** - virtual HRESULT GetMetaData(IMetaDataImport **ppIImport); - -//***************************************************************************** -// Add another token mapper. -//***************************************************************************** - virtual HRESULT AddTokenMapper(IMapToken *pIMapToken) - { - STATIC_CONTRACT_NOTHROW; - STATIC_CONTRACT_FORBID_FAULT; - - // Add the token mapper, if there isn't already one. - if (m_pIMapToken == NULL) - { - m_pIMapToken = pIMapToken; - m_pIMapToken->AddRef(); - return S_OK; - } - else - { - _ASSERTE(!"Token mapper already set!"); - return E_FAIL; - } - } - -protected: -// m_rgMap is an array indexed by token type. For each type, an array of -// tokens is kept, indexed by from rid. To see if a token has been moved, -// do a lookup by type to get the right array, then use the from rid to -// find the to rid. - TOKENMAP m_rgMap[MAX_TOKENMAP]; - IMetaDataImport *m_pIImport; - ULONG m_cRefs; // Ref count. - IMapToken *m_pIMapToken; - -}; - -#endif // __CeeGenTokenMapper_h__ diff --git a/src/inc/ceesectionstring.h b/src/inc/ceesectionstring.h deleted file mode 100644 index 06a534a0c..000000000 --- a/src/inc/ceesectionstring.h +++ /dev/null @@ -1,55 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -// =========================================================================== -// File: CeeSectionString.h -// -// =========================================================================== - -#ifndef CeeSectionString_H -#define CeeSectionString_H - -#include -#include "ceegen.h" - -// This class is responsible for managing all the strings that have -// been emitted for the PE file. - -// This class manages the strings that are added to the .rdata section. -// It keeps track of each string that has been added using a hashtable. -// The hash table is effectively 2-dimensional. There is a large "virtual -// hash space" that is used to get a wide hash code distribution. The -// virtual hash space is mapped into a real hash table where each n -// hash values in the virtual space fall into a given hash bucket for -// real hash table size n. Within the bucket, elements are stored in a linked -// list in-order. When an virtual hash entry corresponds to a given bucket, -// that bucket is searched for the matching hash id. If not found, it is -// inserted, otherwise, the value is returned. The idea is that for smaller -// apps, there won't be a large number of strings, so that collisions are -// minimal and the length of each bucket's chain is small. For larger -// numbers of strings, having a large hash space also reduces numbers -// of collisions, avoiding string compares unless the hash codes match. - -struct StringTableEntry; - -class CeeSectionString : public CeeSection { - enum { MaxRealEntries = 100, MaxVirtualEntries = 10000 }; - StringTableEntry *stringTable[MaxRealEntries]; - - StringTableEntry *createEntry(__in_z LPWSTR target, ULONG hashId); - StringTableEntry *findStringInsert( - StringTableEntry *&entry, __in_z LPWSTR targetValue, ULONG hashId); - void deleteEntries(StringTableEntry *e); -#ifdef RDATA_STATS - int dumpEntries(StringTableEntry *e); - void dumpTable(); -#endif - - public: - ~CeeSectionString(); - CeeSectionString(CCeeGen &ceeFile, CeeSectionImpl &impl); - virtual HRESULT getEmittedStringRef(__in_z LPWSTR targetValue, StringRef *ref); -}; - -#endif - diff --git a/src/inc/cfi.h b/src/inc/cfi.h deleted file mode 100644 index d5d77840e..000000000 --- a/src/inc/cfi.h +++ /dev/null @@ -1,33 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#ifndef CFI_H_ -#define CFI_H_ - -#define DWARF_REG_ILLEGAL -1 -enum CFI_OPCODE -{ - CFI_ADJUST_CFA_OFFSET, // Offset is adjusted relative to the current one. - CFI_DEF_CFA_REGISTER, // New register is used to compute CFA - CFI_REL_OFFSET // Register is saved at offset from the current CFA -}; - -struct CFI_CODE -{ - unsigned char CodeOffset;// Offset from the start of code the frame covers. - unsigned char CfiOpCode; - short DwarfReg; // Dwarf register number. 0~32 for x64. - int Offset; - CFI_CODE(unsigned char codeOffset, unsigned char cfiOpcode, - short dwarfReg, int offset) - : CodeOffset(codeOffset) - , CfiOpCode(cfiOpcode) - , DwarfReg(dwarfReg) - , Offset(offset) - {} -}; -typedef CFI_CODE* PCFI_CODE; - -#endif // CFI_H - diff --git a/src/inc/check.h b/src/inc/check.h deleted file mode 100644 index b1fdba921..000000000 --- a/src/inc/check.h +++ /dev/null @@ -1,734 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -// --------------------------------------------------------------------------- -// Check.h -// - -// -// Assertion checking infrastructure -// --------------------------------------------------------------------------- - - -#ifndef CHECK_H_ -#define CHECK_H_ - -#include "static_assert.h" -#include "daccess.h" - -#ifdef _DEBUG - -#ifdef _MSC_VER -// Make sure we can recurse deep enough for FORCEINLINE -#pragma inline_recursion(on) -#pragma inline_depth(16) -#pragma warning(disable:4714) -#endif // _MSC_VER - -#if !defined(DISABLE_CONTRACTS) -#define CHECK_INVARIANTS 1 -#define VALIDATE_OBJECTS 1 -#endif - -#endif // _DEBUG - -#if defined(_DEBUG) && !defined(DACCESS_COMPILE) -#define _DEBUG_IMPL 1 -#endif - -#ifdef _DEBUG -#define DEBUG_ARG(x) , x -#else -#define DEBUG_ARG(x) -#endif - -#define CHECK_STRESS 1 - -//-------------------------------------------------------------------------------- -// A CHECK is an object which encapsulates a potential assertion -// failure. It not only contains the result of the check, but if the check fails, -// also records information about the condition and call site. -// -// CHECK also serves as a holder to prevent recursive CHECKS. These can be -// particularly common when putting preconditions inside predicates, especially -// routines called by an invariant. -// -// Note that using CHECK is perfectly efficient in a free build - the CHECK becomes -// a simple string constant pointer (typically either NULL or (LPCSTR)1, although some -// check failures may include messages) -// -// NOTE: you should NEVER use the CHECK class API directly - use the macros below. -//-------------------------------------------------------------------------------- - -class SString; - -class CHECK -{ -protected: - // On retail, this is a pointer to a string literal, null or (LPCSTR)1. - // On debug, this is a pointer to dynamically allocated memory - that - // lets us have formatted strings in debug builds. - LPCSTR m_message; - -#ifdef _DEBUG - LPCSTR m_condition; - LPCSTR m_file; - INT m_line; - LONG *m_pCount; - - // Keep leakage counters. - static size_t s_cLeakedBytes; - static size_t s_cNumFailures; -#endif - - static BOOL s_neverEnforceAsserts; - -public: // !!! NOTE: Called from macros only!!! - - // If we are not in a check, return TRUE and PushCheck; otherwise return FALSE - BOOL EnterAssert(); - - // Pops check count - void LeaveAssert(); - - // Just return if we are in a check - BOOL IsInAssert(); - - // Should we skip enforcing asserts - static BOOL EnforceAssert(); - - static BOOL EnforceAssert_StaticCheckOnly(); - - static void ResetAssert(); - -#ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable:4702) // Disable bogus unreachable code warning -#endif // _MSC_VER - CHECK() : m_message(NULL) -#ifdef _DEBUG - , m_condition (NULL) - , m_file(NULL) - , m_line(NULL) - , m_pCount(NULL) -#endif - {} -#ifdef _MSC_VER -#pragma warning(pop) -#endif // _MSC_VER - - // Fail records the result of a condition check. Can take either a - // boolean value or another check result - BOOL Fail(BOOL condition); - BOOL Fail(const CHECK &check); - - // Setup records context info after a failure. - void Setup(LPCSTR message DEBUG_ARG(LPCSTR condition) DEBUG_ARG(LPCSTR file) DEBUG_ARG(INT line)); - static LPCSTR FormatMessage(LPCSTR messageFormat, ...); - - // Trigger triggers the actual check failure. The trigger may provide a reason - // to include in the failure message. - void Trigger(LPCSTR reason); - - // Finally, convert to a BOOL to allow just testing the result of a Check function - operator BOOL(); - - BOOL operator!(); - - CHECK &operator()() { return *this; } - - static inline const CHECK OK() { - return CHECK(); - } - - static void SetAssertEnforcement(BOOL value); - - static void ReleaseTls(void* pCountTLS); - - private: - static LONG* InitTls(); -#ifdef _DEBUG - static LPCSTR AllocateDynamicMessage(const SString &s); -#endif -}; - - -//-------------------------------------------------------------------------------- -// These CHECK macros are the correct way to propagate an assertion. These -// routines are designed for use inside "Check" routines. Such routines may -// be Invariants, Validate routines, or any other assertional predicates. -// -// A Check routine should return a value of type CHECK. -// -// It should consist of multiple CHECK or CHECK_MSG statements (along with appropritate -// control flow) and should end with CHECK_OK() if all other checks pass. -// -// It may contain a CONTRACT_CHECK contract, but this is only appropriate if the -// check is used for non-assertional purposes (otherwise the contract will never execute). -// Note that CONTRACT_CHECK contracts do not support postconditions. -// -// CHECK: Check the given condition, return a CHECK failure if FALSE -// CHECK_MSG: Same, but include a message paramter if the check fails -// CHECK_OK: Return a successful check value; -//-------------------------------------------------------------------------------- - -#ifdef _DEBUG -#define DEBUG_ONLY_MESSAGE(msg) msg -#else -// On retail, we don't want to add a bunch of string literals to the image, -// so we just use the same one everywhere. -#define DEBUG_ONLY_MESSAGE(msg) ((LPCSTR)1) -#endif - -#define CHECK_MSG_EX(_condition, _message, _RESULT) \ -do \ -{ \ - CHECK _check; \ - if (_check.Fail(_condition)) \ - { \ - ENTER_DEBUG_ONLY_CODE; \ - _check.Setup(DEBUG_ONLY_MESSAGE(_message) \ - DEBUG_ARG(#_condition) \ - DEBUG_ARG(__FILE__) \ - DEBUG_ARG(__LINE__)); \ - _RESULT(_check); \ - LEAVE_DEBUG_ONLY_CODE; \ - } \ -} while (0) - -#define RETURN_RESULT(r) return r - -#define CHECK_MSG(_condition, _message) \ - CHECK_MSG_EX(_condition, _message, RETURN_RESULT) - -#define CHECK(_condition) \ - CHECK_MSG(_condition, "") - -#define CHECK_MSGF(_condition, _args) \ - CHECK_MSG(_condition, CHECK::FormatMessage _args) - -#define CHECK_FAIL(_message) \ - CHECK_MSG(FALSE, _message); UNREACHABLE() - -#define CHECK_FAILF(_args) \ - CHECK_MSGF(FALSE, _args); UNREACHABLE() - -#define CHECK_OK \ - return CHECK::OK() - -//-------------------------------------------------------------------------------- -// ASSERT_CHECK is the proper way to trigger a check result. If the CHECK -// has failed, the diagnostic assertion routines will fire with appropriate -// context information. -// -// Note that the condition may either be a raw boolean expression or a CHECK result -// returned from a Check routine. -// -// Recursion note: ASSERT_CHECKs are only performed if there is no current check in -// progress. -//-------------------------------------------------------------------------------- - -#ifndef ENTER_DEBUG_ONLY_CODE -#define ENTER_DEBUG_ONLY_CODE -#endif - -#ifndef LEAVE_DEBUG_ONLY_CODE -#define LEAVE_DEBUG_ONLY_CODE -#endif - -#define ASSERT_CHECK(_condition, _message, _reason) \ -do \ -{ \ - CHECK _check; \ - if (_check.EnterAssert()) \ - { \ - ENTER_DEBUG_ONLY_CODE; \ - if (_check.Fail(_condition)) \ - { \ - _check.Setup(_message \ - DEBUG_ARG(#_condition) \ - DEBUG_ARG(__FILE__) \ - DEBUG_ARG(__LINE__)); \ - _check.Trigger(_reason); \ - } \ - LEAVE_DEBUG_ONLY_CODE; \ - _check.LeaveAssert(); \ - } \ -} while (0) - -// ex: ASSERT_CHECKF(1+2==4, "my reason", ("Woah %d", 1+3)); -// note that the double parenthesis, the 'args' param below will include one pair of parens. -#define ASSERT_CHECKF(_condition, _reason, _args) \ - ASSERT_CHECK(_condition, CHECK::FormatMessage _args, _reason) - -//-------------------------------------------------------------------------------- -// INVARIANTS are descriptions of conditions which are always true at well defined -// points of execution. Invariants may be checked by the caller or callee at any -// time as paranoia requires. -// -// There are really two flavors of invariant. The "public invariant" describes -// to the caller invariant behavior about the abstraction which is visible from -// the public API (and of course it should be expressible in that public API). -// -// The "internal invariant" (or representation invariant), on the other hand, is -// a description of the private implementation of the abstraction, which may examine -// internal state of the abstraction or use private entry points. -// -// Classes with invariants should introduce methods called -// void Invariant(); -// and -// void InternalInvariant(); -// to allow invariant checks. -//-------------------------------------------------------------------------------- - -#if CHECK_INVARIANTS - -template -CHECK CheckInvariant(TYPENAME &obj) -{ - __if_exists(TYPENAME::Invariant) - { - CHECK(obj.Invariant()); - } - __if_exists(TYPENAME::InternalInvariant) - { - CHECK(obj.InternalInvariant()); - } - - CHECK_OK; -} - -#define CHECK_INVARIANT(o) \ - ASSERT_CHECK(CheckInvariant(o), NULL, "Invariant failure") - -#else - -#define CHECK_INVARIANT(o) do { } while (0) - -#endif - -//-------------------------------------------------------------------------------- -// VALIDATE is a check to be made on an object type which identifies a pointer as -// a valid instance of the object, by calling CheckPointer on it. Normally a null -// pointer is treated as an error; VALIDATE_NULL (or CheckPointer(o, NULL_OK)) -// may be used when a null pointer is acceptible. -// -// In addition to the null/non-null check, a type may provide a specific Check method -// for more sophisticated identification. In general, the Check method -// should answer the question -// "Is this a valid instance of its declared compile-time type?". For instance, if -// runtype type identification were supported for the type, it should be invoked here. -// -// Note that CheckPointer will also check the invariant(s) if appropriate, so the -// invariants should NOT be explicitly invoked from the Check method. -//-------------------------------------------------------------------------------- - -enum IsNullOK -{ - NULL_NOT_OK = 0, - NULL_OK = 1 -}; - -#if CHECK_INVARIANTS -template -CHECK CheckPointer(TYPENAME *o, IsNullOK ok = NULL_NOT_OK) -{ - if (o == NULL) - { - CHECK_MSG(ok, "Illegal null pointer"); - } - else - { - __if_exists(TYPENAME::Check) - { - CHECK(o->Check()); - } - } - - CHECK_OK; -} - -template -CHECK CheckValue(TYPENAME &val) -{ - __if_exists(TYPENAME::Check) - { - CHECK(val.Check()); - } - - CHECK(CheckInvariant(val)); - - CHECK_OK; -} -#else // CHECK_INVARIANTS - -#ifdef _DEBUG_IMPL -// Don't defined these functions to be nops for the non-debug -// build as it may hide important checks -template -CHECK CheckPointer(TYPENAME *o, IsNullOK ok = NULL_NOT_OK) -{ - if (o == NULL) - { - CHECK_MSG(ok, "Illegal null pointer"); - } - - CHECK_OK; -} - -template -CHECK CheckValue(TYPENAME &val) -{ - CHECK_OK; -} -#endif - -#endif // CHECK_INVARIANTS - -#if VALIDATE_OBJECTS - -#define VALIDATE(o) \ - ASSERT_CHECK(CheckPointer(o), "Validation failure") -#define VALIDATE_NULL(o) \ - ASSERT_CHECK(CheckPointer(o, NULL_OK), "Validation failure") - -#else - -#define VALIDATE(o) do { } while (0) -#define VALIDATE_NULL(o) do { } while (0) - -#endif - -//-------------------------------------------------------------------------------- -// CONSISTENCY_CHECKS are ad-hoc assertions about the expected state of the program -// at a given time. A failure in one of these indicates a bug in the code. -// -// Note that the condition may either be a raw boolean expression or a CHECK result -// returned from a Check routine. -//-------------------------------------------------------------------------------- - -#define CONSISTENCY_CHECK(_condition) \ - CONSISTENCY_CHECK_MSG(_condition, "") - -#ifdef _DEBUG_IMPL - -#define CONSISTENCY_CHECK_MSG(_condition, _message) \ - ASSERT_CHECK(_condition, _message, "Consistency check failed") - -#define CONSISTENCY_CHECK_MSGF(_condition, args) \ - ASSERT_CHECKF(_condition, "Consistency check failed", args) - -#else - -#define CONSISTENCY_CHECK_MSG(_condition, _message) do { } while (0) -#define CONSISTENCY_CHECK_MSGF(_condition, args) do { } while (0) - -#endif - -//-------------------------------------------------------------------------------- -// SIMPLIFYING_ASSUMPTIONS are workarounds which are placed in the code to allow progress -// to be made in the case of difficult corner cases. These should NOT be left in the -// code; they are really just markers of things which need to be fixed. -// -// Note that the condition may either be a raw boolean expression or a CHECK result -// returned from a Check routine. -//-------------------------------------------------------------------------------- - -// Ex usage: -// SIMPLIFYING_ASSUMPTION(SomeExpression()); -#define SIMPLIFYING_ASSUMPTION(_condition) \ - SIMPLIFYING_ASSUMPTION_MSG(_condition, "") - - -// Helper for HRs. Will provide formatted message showing the failure code. -#define SIMPLIFYING_ASSUMPTION_SUCCEEDED(__hr) \ - { \ - HRESULT __hr2 = (__hr); \ - (void)__hr2; \ - SIMPLIFYING_ASSUMPTION_MSGF(SUCCEEDED(__hr2), ("HRESULT failed.\n Expected success.\n Actual=0x%x\n", __hr2)); \ - } - -#ifdef _DEBUG_IMPL - -// Ex usage: -// SIMPLIFYING_ASSUMPTION_MSG(SUCCEEDED(hr), "It failed!"); -#define SIMPLIFYING_ASSUMPTION_MSG(_condition, _message) \ - ASSERT_CHECK(_condition, _message, "Unhandled special case detected") - -// use a formatted string. Ex usage: -// SIMPLIFYING_ASSUMPTION_MSGF(SUCCEEDED(hr), ("Woah it failed! 0x%08x", hr)); -#define SIMPLIFYING_ASSUMPTION_MSGF(_condition, args) \ - ASSERT_CHECKF(_condition, "Unhandled special case detected", args) - -#else // !_DEBUG_IMPL - -#define SIMPLIFYING_ASSUMPTION_MSG(_condition, _message) do { } while (0) -#define SIMPLIFYING_ASSUMPTION_MSGF(_condition, args) do { } while (0) - -#endif // !_DEBUG_IMPL - -//-------------------------------------------------------------------------------- -// COMPILER_ASSUME_MSG is a statement that tells the compiler to assume the -// condition is true. In a checked build these turn into asserts; -// in a free build they are passed through to the compiler to use in optimization. -//-------------------------------------------------------------------------------- - -#if defined(_PREFAST_) || defined(_PREFIX_) -#define COMPILER_ASSUME_MSG(_condition, _message) if (!(_condition)) __UNREACHABLE(); -#define COMPILER_ASSUME_MSGF(_condition, args) if (!(_condition)) __UNREACHABLE(); -#else - -#if defined(DACCESS_COMPILE) -#define COMPILER_ASSUME_MSG(_condition, _message) do { } while (0) -#define COMPILER_ASSUME_MSGF(_condition, args) do { } while (0) -#else - -#if defined(_DEBUG) -#define COMPILER_ASSUME_MSG(_condition, _message) \ - ASSERT_CHECK(_condition, _message, "Compiler optimization assumption invalid") -#define COMPILER_ASSUME_MSGF(_condition, args) \ - ASSERT_CHECKF(_condition, "Compiler optimization assumption invalid", args) -#else -#define COMPILER_ASSUME_MSG(_condition, _message) __assume(_condition) -#define COMPILER_ASSUME_MSGF(_condition, args) __assume(_condition) -#endif // _DEBUG - -#endif // DACCESS_COMPILE - -#endif // _PREFAST_ || _PREFIX_ - - -#define COMPILER_ASSUME(_condition) \ - COMPILER_ASSUME_MSG(_condition, "") - - -//-------------------------------------------------------------------------------- -// PREFIX_ASSUME_MSG and PREFAST_ASSUME_MSG are just another name -// for COMPILER_ASSUME_MSG -// In a checked build these turn into asserts; in a free build -// they are passed through to the compiler to use in optimization; -// via an __assume(_condition) optimization hint. -//-------------------------------------------------------------------------------- - -#define PREFIX_ASSUME_MSG(_condition, _message) \ - COMPILER_ASSUME_MSG(_condition, _message) - -#define PREFIX_ASSUME_MSGF(_condition, args) \ - COMPILER_ASSUME_MSGF(_condition, args) - -#define PREFIX_ASSUME(_condition) \ - COMPILER_ASSUME_MSG(_condition, "") - -#define PREFAST_ASSUME_MSG(_condition, _message) \ - COMPILER_ASSUME_MSG(_condition, _message) - -#define PREFAST_ASSUME_MSGF(_condition, args) \ - COMPILER_ASSUME_MSGF(_condition, args) - -#define PREFAST_ASSUME(_condition) \ - COMPILER_ASSUME_MSG(_condition, "") - -//-------------------------------------------------------------------------------- -// UNREACHABLE points are locations in the code which should not be able to be -// reached under any circumstances (e.g. a default in a switch which is supposed to -// cover all cases.). This macro tells the compiler this, and also embeds a check -// to make sure it is always true. -//-------------------------------------------------------------------------------- - -#define UNREACHABLE() \ - UNREACHABLE_MSG("") - -#ifdef __llvm__ - -// LLVM complains if a function does not return what it says. -#define UNREACHABLE_RET() do { UNREACHABLE(); return 0; } while (0) -#define UNREACHABLE_MSG_RET(_message) UNREACHABLE_MSG(_message); return 0; - -#else // __llvm__ - -#define UNREACHABLE_RET() UNREACHABLE() -#define UNREACHABLE_MSG_RET(_message) UNREACHABLE_MSG(_message) - -#endif // __llvm__ else - -#if defined(_MSC_VER) || defined(_PREFIX_) -#if defined(_TARGET_AMD64_) -// Empty methods that consist of UNREACHABLE() result in a zero-sized declspec(noreturn) method -// which causes the pdb file to make the next method declspec(noreturn) as well, thus breaking BBT -// Remove when we get a VC compiler that fixes VSW 449170 -# define __UNREACHABLE() DebugBreak(); __assume(0); -#else -# define __UNREACHABLE() __assume(0) -#endif -#else -#define __UNREACHABLE() do { } while(true) -#endif - -#ifdef _DEBUG_IMPL - -// Note that the "do { } while (0)" syntax trick here doesn't work, as the compiler -// gives an error that the while(0) is unreachable code -#define UNREACHABLE_MSG(_message) \ -{ \ - CHECK _check; \ - _check.Setup(_message, "", __FILE__, __LINE__); \ - _check.Trigger("Reached the \"unreachable\""); \ -} __UNREACHABLE() - -#else - -#define UNREACHABLE_MSG(_message) __UNREACHABLE() - -#endif - - -//-------------------------------------------------------------------------------- -// STRESS_CHECK represents a check which is included in a free build -// @todo: behavior on trigger -// -// Note that the condition may either be a raw boolean expression or a CHECK result -// returned from a Check routine. -// -// Since Retail builds don't allow formatted checks, there's no STRESS_CHECK_MSGF. -//-------------------------------------------------------------------------------- - -#if CHECK_STRESS - -#define STRESS_CHECK(_condition, _message) \ - ASSERT_CHECK(_condition, _message, "Stress Assertion Failure") - -#else - -#define STRESS_CHECK(_condition, _message) do { } while (0) - -#endif - -//-------------------------------------------------------------------------------- -// CONTRACT_CHECK is used to put contracts on Check function. Note that it does -// not support postconditions. -//-------------------------------------------------------------------------------- - -#define CONTRACT_CHECK CONTRACTL -#define CONTRACT_CHECK_END CONTRACTL_END - -//-------------------------------------------------------------------------------- -// CCHECK is used for Check functions which may fail due to out of memory -// or other transient failures. These failures should be ignored when doing -// assertions, but they cannot be ignored when the Check function is used in -// normal code. -// @todo: really crufty to have 2 sets of CHECK macros -//-------------------------------------------------------------------------------- - -#ifdef _DEBUG - -#define CCHECK_START \ - { \ - BOOL ___exception = FALSE; \ - BOOL ___transient = FALSE; \ - CHECK ___result = CHECK::OK(); \ - EX_TRY { - -#define CCHECK_END \ - } EX_CATCH { \ - if (___result.IsInAssert()) \ - { \ - ___exception = TRUE; \ - ___transient = GET_EXCEPTION()->IsTransient(); \ - } \ - else \ - EX_RETHROW; \ - } EX_END_CATCH(RethrowTerminalExceptions); \ - \ - if (___exception) \ - { \ - if (___transient) \ - CHECK_OK; \ - else \ - CHECK_FAIL("Nontransient exception occurred during check"); \ - } \ - CHECK(___result); \ - } - -#define CRETURN_RESULT(r) ___result = r - -#define CCHECK_MSG(_condition, _message) \ - CHECK_MSG_EX(_condition, _message, CRETURN_RESULT) - -#define CCHECK(_condition) \ - CCHECK_MSG(_condition, "") - -#define CCHECK_MSGF(_condition, _args) \ - CCHECK_MSG(_condition, CHECK::FormatMessage _args) - -#define CCHECK_FAIL(_message) \ - CCHECK_MSG(FALSE, _message); UNREACHABLE() - -#define CCHECK_FAILF(_args) \ - CCHECK_MSGF(FALSE, _args); UNREACHABLE() - -#else // _DEBUG - -#define CCHECK_START -#define CCHECK_END - -#define CCHECK CHECK -#define CCHECK_MSG CHECK_MSG -#define CCHECK_MSGF CHECK_MSGF -#define CCHECK_FAIL CHECK_FAIL -#define CCHECK_FAILF CHECK_FAILF - -#endif - - - -//-------------------------------------------------------------------------------- -// Common base level checks -//-------------------------------------------------------------------------------- - -CHECK CheckAlignment(UINT alignment); - -CHECK CheckAligned(UINT value, UINT alignment); -#if defined(_MSC_VER) -CHECK CheckAligned(ULONG value, UINT alignment); -#endif -CHECK CheckAligned(UINT64 value, UINT alignment); -CHECK CheckAligned(const void *address, UINT alignment); - -CHECK CheckOverflow(UINT value1, UINT value2); -#if defined(_MSC_VER) -CHECK CheckOverflow(ULONG value1, ULONG value2); -#endif -CHECK CheckOverflow(UINT64 value1, UINT64 value2); -CHECK CheckOverflow(PTR_CVOID address, UINT offset); -#if defined(_MSC_VER) -CHECK CheckOverflow(const void *address, ULONG offset); -#endif -CHECK CheckOverflow(const void *address, UINT64 offset); - -CHECK CheckUnderflow(UINT value1, UINT value2); -#if defined(_MSC_VER) -CHECK CheckUnderflow(ULONG value1, ULONG value2); -#endif -CHECK CheckUnderflow(UINT64 value1, UINT64 value2); -CHECK CheckUnderflow(const void *address, UINT offset); -#if defined(_MSC_VER) -CHECK CheckUnderflow(const void *address, ULONG offset); -#endif -CHECK CheckUnderflow(const void *address, UINT64 offset); -CHECK CheckUnderflow(const void *address, void *address2); - -CHECK CheckZeroedMemory(const void *memory, SIZE_T size); - -// These include overflow checks -CHECK CheckBounds(const void *rangeBase, UINT32 rangeSize, UINT32 offset); -CHECK CheckBounds(const void *rangeBase, UINT32 rangeSize, UINT32 offset, UINT32 size); - -void WINAPI ReleaseCheckTls(LPVOID pTlsData); - -// ================================================================================ -// Inline definitions -// ================================================================================ - -#include "check.inl" - -#endif // CHECK_H_ diff --git a/src/inc/check.inl b/src/inc/check.inl deleted file mode 100644 index 9a3597ef8..000000000 --- a/src/inc/check.inl +++ /dev/null @@ -1,367 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#ifndef CHECK_INL_ -#define CHECK_INL_ - -#include "check.h" -#include "clrhost.h" -#include "debugmacros.h" -#include "clrtypes.h" - -inline LONG *CHECK::InitTls() -{ -#pragma push_macro("HeapAlloc") -#pragma push_macro("GetProcessHeap") -#undef HeapAlloc -#undef GetProcessHeap - - LONG *pCount = (LONG *)::HeapAlloc(GetProcessHeap(), 0, sizeof(LONG)); - if (pCount) - *pCount = 0; - -#pragma pop_macro("HeapAlloc") -#pragma pop_macro("GetProcessHeap") - ClrFlsSetValue(TlsIdx_Check, pCount); - ClrFlsAssociateCallback(TlsIdx_Check, ReleaseCheckTls); - return pCount; -} - -inline void CHECK::ReleaseTls(void* pCountTLS) -{ -#pragma push_macro("HeapFree") -#pragma push_macro("GetProcessHeap") -#undef HeapFree -#undef GetProcessHeap - LONG* pCount = (LONG*) pCountTLS; - if (pCount) - ::HeapFree(GetProcessHeap(), 0, pCount); - -#pragma pop_macro("HeapFree") -#pragma pop_macro("GetProcessHeap") -} - -FORCEINLINE BOOL CHECK::EnterAssert() -{ - if (s_neverEnforceAsserts) - return FALSE; - -#ifdef _DEBUG_IMPL - m_pCount = (LONG *)ClrFlsGetValue(TlsIdx_Check); - if (!m_pCount) - { - m_pCount = InitTls(); - if (!m_pCount) - return FALSE; - } - - if (!*m_pCount) - { - *m_pCount = 1; - return TRUE; - } - else - return FALSE; -#else - // Don't bother doing recursive checks on a free build, since checks should - // be extremely isolated - return TRUE; -#endif -} - -FORCEINLINE void CHECK::LeaveAssert() -{ -#ifdef _DEBUG_IMPL - *m_pCount = 0; -#endif -} - -FORCEINLINE BOOL CHECK::IsInAssert() -{ -#ifdef _DEBUG_IMPL - if (!m_pCount) - m_pCount = (LONG *)ClrFlsGetValue(TlsIdx_Check); - - if (!m_pCount) - return FALSE; - else - return *m_pCount; -#else - return FALSE; -#endif -} - -FORCEINLINE BOOL CHECK::EnforceAssert() -{ - if (s_neverEnforceAsserts) - return FALSE; - else - { - CHECK chk; - return !chk.IsInAssert(); - } -} - -FORCEINLINE void CHECK::ResetAssert() -{ - CHECK chk; - if (chk.IsInAssert()) - chk.LeaveAssert(); -} - -inline void CHECK::SetAssertEnforcement(BOOL value) -{ - s_neverEnforceAsserts = !value; -} - -// Fail records the result of a condition check. Can take either a -// boolean value or another check result -FORCEINLINE BOOL CHECK::Fail(BOOL condition) -{ -#ifdef _DEBUG - if (!condition) - { - m_condition = NULL; - m_file = NULL; - m_line = 0; - } -#endif - return !condition; -} - -FORCEINLINE BOOL CHECK::Fail(const CHECK &check) -{ - m_message = check.m_message; -#ifdef _DEBUG - if (m_message != NULL) - { - m_condition = check.m_condition; - m_file = check.m_file; - m_line = check.m_line; - } -#endif - return m_message != NULL; -} - -#ifndef _DEBUG -FORCEINLINE void CHECK::Setup(LPCSTR message) -{ - m_message = message; -} - -FORCEINLINE LPCSTR CHECK::FormatMessage(LPCSTR messageFormat, ...) -{ - return messageFormat; -} -#endif - -FORCEINLINE CHECK::operator BOOL () -{ - return m_message == NULL; -} - -FORCEINLINE BOOL CHECK::operator!() -{ - return m_message != NULL; -} - -inline CHECK CheckAlignment(UINT alignment) -{ - STATIC_CONTRACT_WRAPPER; - CHECK((alignment & (alignment-1)) == 0); - CHECK_OK; -} - -inline CHECK CheckAligned(UINT value, UINT alignment) -{ - STATIC_CONTRACT_WRAPPER; - CHECK(AlignmentTrim(value, alignment) == 0); - CHECK_OK; -} - -#ifndef PLATFORM_UNIX -// For Unix this and the previous function get the same types. -// So, exclude this one. -inline CHECK CheckAligned(ULONG value, UINT alignment) -{ - STATIC_CONTRACT_WRAPPER; - CHECK(AlignmentTrim(value, alignment) == 0); - CHECK_OK; -} -#endif // PLATFORM_UNIX - -inline CHECK CheckAligned(UINT64 value, UINT alignment) -{ - STATIC_CONTRACT_WRAPPER; - CHECK(AlignmentTrim(value, alignment) == 0); - CHECK_OK; -} - -inline CHECK CheckAligned(const void *address, UINT alignment) -{ - STATIC_CONTRACT_WRAPPER; - CHECK(AlignmentTrim((SIZE_T)address, alignment) == 0); - CHECK_OK; -} - -inline CHECK CheckOverflow(UINT value1, UINT value2) -{ - CHECK(value1 + value2 >= value1); - CHECK_OK; -} - -#if defined(_MSC_VER) -inline CHECK CheckOverflow(ULONG value1, ULONG value2) -{ - CHECK(value1 + value2 >= value1); - CHECK_OK; -} -#endif - -inline CHECK CheckOverflow(UINT64 value1, UINT64 value2) -{ - CHECK(value1 + value2 >= value1); - CHECK_OK; -} - -inline CHECK CheckOverflow(PTR_CVOID address, UINT offset) -{ - TADDR targetAddr = dac_cast(address); -#if POINTER_BITS == 32 - CHECK((UINT) (SIZE_T)(targetAddr) + offset >= (UINT) (SIZE_T) (targetAddr)); -#else - CHECK((UINT64) targetAddr + offset >= (UINT64) targetAddr); -#endif - - CHECK_OK; -} - -#if defined(_MSC_VER) -inline CHECK CheckOverflow(const void *address, ULONG offset) -{ -#if POINTER_BITS == 32 - CHECK((ULONG) (SIZE_T) address + offset >= (ULONG) (SIZE_T) address); -#else - CHECK((UINT64) address + offset >= (UINT64) address); -#endif - - CHECK_OK; -} -#endif - -inline CHECK CheckOverflow(const void *address, UINT64 offset) -{ -#if POINTER_BITS == 32 - CHECK(offset >> 32 == 0); - CHECK((UINT) (SIZE_T) address + (UINT) offset >= (UINT) (SIZE_T) address); -#else - CHECK((UINT64) address + offset >= (UINT64) address); -#endif - - CHECK_OK; -} - - -inline CHECK CheckUnderflow(UINT value1, UINT value2) -{ - CHECK(value1 - value2 <= value1); - - CHECK_OK; -} - -#ifndef PLATFORM_UNIX -// For Unix this and the previous function get the same types. -// So, exclude this one. -inline CHECK CheckUnderflow(ULONG value1, ULONG value2) -{ - CHECK(value1 - value2 <= value1); - - CHECK_OK; -} -#endif // PLATFORM_UNIX - -inline CHECK CheckUnderflow(UINT64 value1, UINT64 value2) -{ - CHECK(value1 - value2 <= value1); - - CHECK_OK; -} - -inline CHECK CheckUnderflow(const void *address, UINT offset) -{ -#if POINTER_BITS == 32 - CHECK((UINT) (SIZE_T) address - offset <= (UINT) (SIZE_T) address); -#else - CHECK((UINT64) address - offset <= (UINT64) address); -#endif - - CHECK_OK; -} - -#if defined(_MSC_VER) -inline CHECK CheckUnderflow(const void *address, ULONG offset) -{ -#if POINTER_BITS == 32 - CHECK((ULONG) (SIZE_T) address - offset <= (ULONG) (SIZE_T) address); -#else - CHECK((UINT64) address - offset <= (UINT64) address); -#endif - - CHECK_OK; -} -#endif - -inline CHECK CheckUnderflow(const void *address, UINT64 offset) -{ -#if POINTER_BITS == 32 - CHECK(offset >> 32 == 0); - CHECK((UINT) (SIZE_T) address - (UINT) offset <= (UINT) (SIZE_T) address); -#else - CHECK((UINT64) address - offset <= (UINT64) address); -#endif - - CHECK_OK; -} - -inline CHECK CheckUnderflow(const void *address, void *address2) -{ -#if POINTER_BITS == 32 - CHECK((UINT) (SIZE_T) address - (UINT) (SIZE_T) address2 <= (UINT) (SIZE_T) address); -#else - CHECK((UINT64) address - (UINT64) address2 <= (UINT64) address); -#endif - - CHECK_OK; -} - -inline CHECK CheckZeroedMemory(const void *memory, SIZE_T size) -{ - CHECK(CheckOverflow(memory, size)); - - BYTE *p = (BYTE *) memory; - BYTE *pEnd = p + size; - - while (p < pEnd) - CHECK(*p++ == 0); - - CHECK_OK; -} - -inline CHECK CheckBounds(const void *rangeBase, UINT32 rangeSize, UINT32 offset) -{ - CHECK(CheckOverflow(dac_cast(rangeBase), rangeSize)); - CHECK(offset <= rangeSize); - CHECK_OK; -} - -inline CHECK CheckBounds(const void *rangeBase, UINT32 rangeSize, UINT32 offset, UINT32 size) -{ - CHECK(CheckOverflow(dac_cast(rangeBase), rangeSize)); - CHECK(CheckOverflow(offset, size)); - CHECK(offset + size <= rangeSize); - CHECK_OK; -} - -#endif // CHECK_INL_ - diff --git a/src/inc/circularlog.h b/src/inc/circularlog.h deleted file mode 100644 index 4ee8d2fa9..000000000 --- a/src/inc/circularlog.h +++ /dev/null @@ -1,38 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - - -#ifndef _CIRCULARLOG_H__ - -#define _CIRCULARLOG_H__ - -#include "sstring.h" - -class CircularLog -{ -public: - CircularLog(); - ~CircularLog(); - - bool Init(const WCHAR* logname, const WCHAR* logHeader, DWORD maxSize = 1024*1024); - void Shutdown(); - void Log(const WCHAR* string); - -protected: - - void CheckForLogReset(BOOL fOverflow); - BOOL CheckLogHeader(); - HANDLE OpenFile(); - void CloseFile(); - - bool m_bInit; - SString m_LogFilename; - SString m_LogHeader; - SString m_OldLogFilename; - SString m_LockFilename; - DWORD m_MaxSize; - unsigned m_uLogCount; -}; - -#endif diff --git a/src/inc/clr/fs.h b/src/inc/clr/fs.h deleted file mode 100644 index d6bcb7530..000000000 --- a/src/inc/clr/fs.h +++ /dev/null @@ -1,16 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -// - -// -// This header will include all headers relating to file system functionality. - -#ifndef _clr_fs_h_ -#define _clr_fs_h_ - -#include "fs/path.h" -#include "fs/file.h" -#include "fs/dir.h" - -#endif // _clr_fs_h_ diff --git a/src/inc/clr/fs/dir.h b/src/inc/clr/fs/dir.h deleted file mode 100644 index 2516151a5..000000000 --- a/src/inc/clr/fs/dir.h +++ /dev/null @@ -1,129 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -// - -// -// This header provides general directory-related file system services. - -#ifndef _clr_fs_Dir_h_ -#define _clr_fs_Dir_h_ - -#include "clrtypes.h" -#include "clr/str.h" -#include "strsafe.h" - -#ifndef countof - #define countof(x) (sizeof(x) / sizeof(x[0])) -#endif // !countof - -namespace clr -{ - namespace fs - { - class Dir - { - public: - static inline bool Exists( - LPCWSTR wzDirPath) - { - DWORD attrs = WszGetFileAttributes(wzDirPath); - return (attrs != INVALID_FILE_ATTRIBUTES) && (attrs & FILE_ATTRIBUTE_DIRECTORY); - } - - //----------------------------------------------------------------------------------------- - // Creates new directory indicated by wzDirPath. - // - // Returns: - // S_OK - on success directory creation - // S_FALSE - when directory previously existed - // HR(ERROR_PATH_NOT_FOUND) - when creation of dir fails. - static inline HRESULT Create( - LPCWSTR wzDirPath) - { - HRESULT hr = S_OK; - - if (!WszCreateDirectory(wzDirPath, nullptr)) - { - hr = HRESULT_FROM_GetLastError(); - if (hr == HRESULT_FROM_WIN32(ERROR_ALREADY_EXISTS)) - { - hr = S_FALSE; - } - } - return hr; - } - - //----------------------------------------------------------------------------------------- - // Creates the specified directory and all required subdirectories. wzDirPath will be - // temporarily modified in the process. - // - // Returns: - // S_OK - on success directory creation - // S_FALSE - when directory previously existed - // HR(ERROR_PATH_NOT_FOUND) - when creation of any dir fails. - static inline HRESULT CreateRecursively( - __inout_z LPWSTR wzDirPath, - size_t cchDirPath = 0) - { - HRESULT hr = S_OK; - - if (wzDirPath == nullptr) - { - return E_POINTER; - } - - if (cchDirPath == 0) - { - cchDirPath = wcslen(wzDirPath); - } - - // Try to create the path. If it fails, assume that's because the parent folder does - // not exist. Try to create the parent then re-attempt. - WCHAR chOrig = wzDirPath[cchDirPath]; - hr = Create(wzDirPath); - if (hr == HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND)) - { - for (WCHAR* pCurCh = wzDirPath + cchDirPath - 1; pCurCh != wzDirPath; --pCurCh) - { - if (*pCurCh == W('\\') || *pCurCh == W('\0')) - { - WCHAR chOrig = *pCurCh; - *pCurCh = W('\0'); - IfFailRet(CreateRecursively(wzDirPath, pCurCh - wzDirPath)); - *pCurCh = chOrig; - break; - } - } - IfFailRet(Create(wzDirPath)); - } - - return hr; - } - - //----------------------------------------------------------------------------------------- - // Creates the specified directory and all required subdirectories. - static inline HRESULT CreateRecursively( - LPCWSTR wzDirPath) - { - HRESULT hr = S_OK; - - if (wzDirPath == nullptr) - { - return E_POINTER; - } - - // Make a writable copy of wzDirPath - size_t cchDirPath = wcslen(wzDirPath); - CQuickWSTR wzBuffer; - IfFailRet(wzBuffer.ReSizeNoThrow(cchDirPath + 1)); - wcscpy_s(wzBuffer.Ptr(), wzBuffer.Size(), wzDirPath); - IfFailRet(CreateRecursively(wzBuffer.Ptr(), cchDirPath)); - - return hr; - } - }; - } -} - -#endif // _clr_fs_Dir_h_ diff --git a/src/inc/clr/fs/file.h b/src/inc/clr/fs/file.h deleted file mode 100644 index 70f22a29f..000000000 --- a/src/inc/clr/fs/file.h +++ /dev/null @@ -1,40 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -// - -// -// This header provides general filename-related file system services. - -#ifndef _clr_fs_File_h_ -#define _clr_fs_File_h_ - -#include "clrtypes.h" -#include "cor.h" // SELECTANY - -namespace clr -{ - namespace fs - { - // This list taken from ndp/clr/src/bcl/system/io/path.cs - SELECTANY WCHAR const g_rgInvalidFileNameChars[] = - { W('"'), W('<'), W('>'), W('|'), W('\0'), (WCHAR)1, (WCHAR)2, (WCHAR)3, (WCHAR)4, (WCHAR)5, (WCHAR)6, - (WCHAR)7, (WCHAR)8, (WCHAR)9, (WCHAR)10, (WCHAR)11, (WCHAR)12, (WCHAR)13, (WCHAR)14, - (WCHAR)15, (WCHAR)16, (WCHAR)17, (WCHAR)18, (WCHAR)19, (WCHAR)20, (WCHAR)21, (WCHAR)22, - (WCHAR)23, (WCHAR)24, (WCHAR)25, (WCHAR)26, (WCHAR)27, (WCHAR)28, (WCHAR)29, (WCHAR)30, - (WCHAR)31, W(':'), W('*'), W('?'), W('\\'), W('/') }; - - class File - { - public: - static inline bool Exists( - LPCWSTR wzFilePath) - { - DWORD attrs = WszGetFileAttributes(wzFilePath); - return (attrs != INVALID_FILE_ATTRIBUTES) && !(attrs & FILE_ATTRIBUTE_DIRECTORY); - } - }; - } -} - -#endif // _clr_fs_File_h_ diff --git a/src/inc/clr/fs/path.h b/src/inc/clr/fs/path.h deleted file mode 100644 index 7c1995ecb..000000000 --- a/src/inc/clr/fs/path.h +++ /dev/null @@ -1,141 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -// - -// -// This header provides general path-related file system services. - -#ifndef _clr_fs_Path_h_ -#define _clr_fs_Path_h_ - -#include "clrtypes.h" -#include "cor.h" // SELECTANY - -#include "strsafe.h" - -#include "clr/str.h" - -#ifndef LONG_FORMAT_PATH_PREFIX - #define LONG_FORMAT_PATH_PREFIX W("\\\\?\\") -#endif - -namespace clr -{ - namespace fs - { - // This list taken from ndp/clr/src/bcl/system/io/path.cs - SELECTANY WCHAR const g_rgInvalidPathChars[] = - { W('"'), W('<'), W('>'), W('|'), W('\0'), (WCHAR)1, (WCHAR)2, (WCHAR)3, (WCHAR)4, (WCHAR)5, (WCHAR)6, - (WCHAR)7, (WCHAR)8, (WCHAR)9, (WCHAR)10, (WCHAR)11, (WCHAR)12, (WCHAR)13, (WCHAR)14, - (WCHAR)15, (WCHAR)16, (WCHAR)17, (WCHAR)18, (WCHAR)19, (WCHAR)20, (WCHAR)21, (WCHAR)22, - (WCHAR)23, (WCHAR)24, (WCHAR)25, (WCHAR)26, (WCHAR)27, (WCHAR)28, (WCHAR)29, (WCHAR)30, - (WCHAR)31 }; - - class Path - { - public: - //----------------------------------------------------------------------------------------- - static inline bool - Exists( - LPCWSTR wzPath) - { - DWORD attrs = WszGetFileAttributes(wzPath); - return (attrs != INVALID_FILE_ATTRIBUTES); - } - - //----------------------------------------------------------------------------------------- - // Returns true if wzPath represents a long format path (i.e., prefixed with '\\?\'). - static inline bool - HasLongFormatPrefix(LPCWSTR wzPath) - { - _ASSERTE(!clr::str::IsNullOrEmpty(wzPath)); // Must check this first. - return wcscmp(wzPath, LONG_FORMAT_PATH_PREFIX) == 0; - } - - //----------------------------------------------------------------------------------------- - // Returns true if wzPath represents a relative path. - static inline bool - IsRelative(LPCWSTR wzPath) - { - _ASSERTE(wzPath != nullptr); - - // Similar to System.IO.Path.IsRelative() -#if PLATFORM_UNIX - if(wzPath[0] == VOLUME_SEPARATOR_CHAR_W) - { - return false; - } -#else - // Check for a paths like "C:\..." or "\\...". Additional notes: - // - "\\?\..." - long format paths are considered as absolute paths due to the "\\" prefix - // - "\..." - these paths are relative, as they depend on the current drive - // - "C:..." and not "C:\..." - these paths are relative, as they depend on the current directory for drive C - if (wzPath[0] != W('\0') && - wzPath[1] == VOLUME_SEPARATOR_CHAR_W && - wzPath[2] == DIRECTORY_SEPARATOR_CHAR_W && - ( - (wzPath[0] >= W('A') && wzPath[0] <= W('Z')) || - (wzPath[0] >= W('a') && wzPath[0] <= W('z')) - )) - { - return false; - } - if (wzPath[0] == DIRECTORY_SEPARATOR_CHAR_W && wzPath[1] == DIRECTORY_SEPARATOR_CHAR_W) - { - return false; - } -#endif - - return true; - } - - //----------------------------------------------------------------------------------------- - // Combines two path parts. wzPathLeft must be a directory path and may be either absolute - // or relative. wzPathRight may be a directory or file path and must be relative. The - // result is placed in wzBuffer and the number of chars written is placed in pcchBuffer on - // success; otherwise an error HRESULT is returned. - static HRESULT - Combine(LPCWSTR wzPathLeft, LPCWSTR wzPathRight, __in DWORD *pcchBuffer, __out_ecount(*pcchBuffer) LPWSTR wzBuffer) - { - STATIC_CONTRACT_NOTHROW; - - HRESULT hr = S_OK; - - if (clr::str::IsNullOrEmpty(wzPathLeft) || clr::str::IsNullOrEmpty(wzPathRight) || pcchBuffer == nullptr) - return E_INVALIDARG; - - LPWSTR wzBuf = wzBuffer; - size_t cchBuf = *pcchBuffer; - - IfFailRet(StringCchCopyExW(wzBuf, cchBuf, wzPathLeft, &wzBuf, &cchBuf, STRSAFE_NULL_ON_FAILURE)); - IfFailRet(StringCchCatExW(wzBuf, cchBuf, wzBuf[-1] == DIRECTORY_SEPARATOR_CHAR_W ? W("") : DIRECTORY_SEPARATOR_STR_W, &wzBuf, &cchBuf, STRSAFE_NULL_ON_FAILURE)); - IfFailRet(StringCchCatExW(wzBuf, cchBuf, wzPathRight, &wzBuf, &cchBuf, STRSAFE_NULL_ON_FAILURE)); - - return S_OK; - } - - //----------------------------------------------------------------------------------------- - // Checks if the path provided is valid within the specified constraints. - // ***NOTE: does not yet check for invalid path characters. - static bool - IsValid(LPCWSTR wzPath, DWORD cchPath, bool fAllowLongFormat) - { - if (clr::str::IsNullOrEmpty(wzPath)) - return false; - - bool fIsLongFormat = HasLongFormatPrefix(wzPath); - - if (fIsLongFormat && !fAllowLongFormat) - return false; - - if (!fIsLongFormat && cchPath > _MAX_PATH) - return false; - - return true; - } - }; - } -} - -#endif // _clr_fs_Path_h_ diff --git a/src/inc/clr/stack.h b/src/inc/clr/stack.h deleted file mode 100644 index f9741b274..000000000 --- a/src/inc/clr/stack.h +++ /dev/null @@ -1,99 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -// - -// -// This header provides a basic stack implementation - -#ifndef _clr_Stack_h_ -#define _clr_Stack_h_ - -namespace clr -{ - //------------------------------------------------------------------------------------------------- - // A basic stack class. - // - template < typename T > - class Stack - { - private: - //--------------------------------------------------------------------------------------------- - struct Link - { - template < typename A1 > - Link(A1 && a1, Link * next = nullptr) - : _value(std::forward(a1)) - , _next(next) - {} - - T _value; - Link * _next; - }; - - public: - //--------------------------------------------------------------------------------------------- - // Empty stack constructor. - Stack() - : _top(nullptr) - , _size(0) - {} - - //--------------------------------------------------------------------------------------------- - // Move constructor. - Stack(Stack && stack) - : _top(nullptr) - , _size(0) - { *this = std::move(stack); } - - //--------------------------------------------------------------------------------------------- - ~Stack() - { - while (!empty()) - { - pop(); - } - } - - //--------------------------------------------------------------------------------------------- - // Move assignment. - Stack& operator=(Stack && stack) - { std::swap(_top, stack._top); std::swap(_size, stack._size); } - - //--------------------------------------------------------------------------------------------- - bool empty() const - { return _top == nullptr; } - - //--------------------------------------------------------------------------------------------- - size_t size() const - { return _size; } - - //--------------------------------------------------------------------------------------------- - T & top() - { return _top->_value; } - - //--------------------------------------------------------------------------------------------- - T const & top() const - { return _top->_value; } - - //--------------------------------------------------------------------------------------------- - template < typename A1 > inline - void push(A1 && value) - { - STATIC_CONTRACT_THROWS; - _top = new Link(std::forward(value), _top); - ++_size; - } - - //--------------------------------------------------------------------------------------------- - void pop() - { Link * del = _top; _top = _top->_next; --_size; delete del; } - - private: - //--------------------------------------------------------------------------------------------- - Link * _top; - size_t _size; - }; -} // namespace clr - -#endif // _clr_Stack_h_ diff --git a/src/inc/clr/str.h b/src/inc/clr/str.h deleted file mode 100644 index 94c8ed46b..000000000 --- a/src/inc/clr/str.h +++ /dev/null @@ -1,28 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -// - -// -// This header provides general standard string services. -// - -#ifndef _clr_str_h_ -#define _clr_str_h_ - -namespace clr -{ - namespace str - { - //----------------------------------------------------------------------------------------- - // Returns true if the provided string is a null pointer or the empty string. - static inline bool - IsNullOrEmpty(LPCWSTR wzStr) - { - return wzStr == nullptr || *wzStr == W('\0'); - } - } -} - -#endif // _clr_str_h_ - diff --git a/src/inc/clr/win32.h b/src/inc/clr/win32.h deleted file mode 100644 index a0e00c632..000000000 --- a/src/inc/clr/win32.h +++ /dev/null @@ -1,38 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -// -// clr/win32.h -// -// Provides Win32-specific utility functionality. -// - -// - -#ifndef clr_win32_h -#define clr_win32_h - -#include "winwrap.h" - -namespace clr -{ - namespace win32 - { - // Prevents an HMODULE from being unloaded until process termination. - inline - HRESULT PreventModuleUnload(HMODULE hMod) - { - if (!WszGetModuleHandleEx( - GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_PIN, - reinterpret_cast(hMod), - &hMod)) - { - return HRESULT_FROM_GetLastError(); - } - - return S_OK; - } - } // namespace win -} // namespace clr - -#endif // clr_win32_h diff --git a/src/inc/clrconfig.h b/src/inc/clrconfig.h deleted file mode 100644 index 7e74e6514..000000000 --- a/src/inc/clrconfig.h +++ /dev/null @@ -1,231 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -// -// -------------------------------------------------------------------------------------------------- -// CLRConfig.h -// - -// -// Unified method of accessing configuration values from environment variables, registry and config file(s). -// This class replaces all GetConfigDWORD and GetConfigString methods in EEConfig and REGUTIL. To define a -// flag, add an entry in the table in file:CLRConfigValues.h. -// -// -// -// -// -------------------------------------------------------------------------------------------------- - - -#include "utilcode.h" -#include "holder.h" - -#ifndef __CLRConfig_h__ -#define __CLRConfig_h__ - -class CLRConfig -{ -public: - // - // Types - // - - // Setting each option results in some change to the config value lookup method. Default behavior is (in - // the following order): - // * Look at environment variables (prepending COMPlus to the name) - // * Look at the framework registry keys (HKCU\Software\Microsoft\.NETFramework then - // HKLM\Software\Microsoft\.NETFramework) - // * Look at the available config files (system, application, host and user). For details see TODO: - // Link to BOTR documentation - enum LookupOptions { - // If set, don't look in environment variables. - IgnoreEnv = 0x1, - // If set, do not prepend "COMPlus_" when doing environment variable lookup. - DontPrependCOMPlus_ = 0x2, - // If set, don't look in HKLM in the registry. - IgnoreHKLM = 0x4, - // If set, don't look in HKCU in the registry. - IgnoreHKCU = 0x8, - // If set, don't look in any config files - IgnoreConfigFiles = 0x10, - // If set, look in config file(s) before looking in env/registry. - FavorConfigFile = 0x20, - // If set, look only in the system config file, ignoring other config files. - // (This option does not affect environment variable and registry lookups) - ConfigFile_SystemOnly = 0x40, - // If set, reverse the order of config file lookups (application config file first). - // (This option does not affect environment variable and registry lookups) - ConfigFile_ApplicationFirst = 0x80, - // Remove any whitespace at beginning and end of value. (Only applicable for - // *string* configuration values.) - TrimWhiteSpaceFromStringValue = 0x100, - - // Legacy REGUTIL-style lookup. - REGUTIL_default = IgnoreConfigFiles, - // Legacy EEConfig-style lookup. - EEConfig_default = 0, - }; - - // Function pointer definition used for calling EEConfig::GetConfigValueCallback . - typedef HRESULT (* GetConfigValueFunction) - (__in_z LPCWSTR /*pKey*/, __deref_out_opt LPCWSTR* /*value*/, BOOL /*systemOnly*/, BOOL /*applicationFirst*/); - - // Struct used to store information about where/how to find a Config DWORD. - // NOTE: Please do NOT create instances of this struct. Use the macros in file:CLRConfigValues.h instead. - typedef struct ConfigDWORDInfo - { - LPCWSTR name; - DWORD defaultValue; - LookupOptions options; - } ConfigDWORDInfo; - - // Struct used to store information about where/how to find a Config String. - // NOTE: Please do NOT create instances of this struct. Use the macros in file:CLRConfigValues.h instead. - typedef struct ConfigStringInfo - { - LPCWSTR name; - LookupOptions options; - } ConfigStringInfo; - - // - // Declaring structs using the macro table in CLRConfigValues.h - // - - // These macros declare ConfigDWORDInfo structs. - #define RETAIL_CONFIG_DWORD_INFO(symbol, name, defaultValue, description) \ - static const ConfigDWORDInfo symbol; - #define RETAIL_CONFIG_DWORD_INFO_EX(symbol, name, defaultValue, description, lookupOptions) \ - static const ConfigDWORDInfo symbol; - - // These macros declare ConfigStringInfo structs. - #define RETAIL_CONFIG_STRING_INFO(symbol, name, description) \ - static const ConfigStringInfo symbol; - #define RETAIL_CONFIG_STRING_INFO_EX(symbol, name, description, lookupOptions) \ - static const ConfigStringInfo symbol; - - // TEMPORARY macros that declare strings. These are used for config value accesses that haven't been - // moved over to CLRConfig yet. Once all accesses have been moved, these macros (and corresponding - // instantiations in file:../utilcode/CLRConfig.cpp) should be removed. - #define RETAIL_CONFIG_DWORD_INFO_DIRECT_ACCESS(symbol, name, description) \ - static const LPCWSTR symbol; - #define RETAIL_CONFIG_STRING_INFO_DIRECT_ACCESS(symbol, name, description) \ - static const LPCWSTR symbol; - - // - // Debug versions of the macros - // -#ifdef _DEBUG - #define CONFIG_DWORD_INFO(symbol, name, defaultValue, description) \ - static const ConfigDWORDInfo symbol; - #define CONFIG_DWORD_INFO_EX(symbol, name, defaultValue, description, lookupOptions) \ - static const ConfigDWORDInfo symbol; - #define CONFIG_STRING_INFO(symbol, name, description) \ - static const ConfigStringInfo symbol; - #define CONFIG_STRING_INFO_EX(symbol, name, description, lookupOptions) \ - static const ConfigStringInfo symbol; - #define CONFIG_DWORD_INFO_DIRECT_ACCESS(symbol, name, description) \ - static const LPCWSTR symbol; - #define CONFIG_STRING_INFO_DIRECT_ACCESS(symbol, name, description) \ - static const LPCWSTR symbol; -#else - #define CONFIG_DWORD_INFO(symbol, name, defaultValue, description) - #define CONFIG_DWORD_INFO_EX(symbol, name, defaultValue, description, lookupOptions) - #define CONFIG_STRING_INFO(symbol, name, description) - #define CONFIG_STRING_INFO_EX(symbol, name, description, lookupOptions) - #define CONFIG_DWORD_INFO_DIRECT_ACCESS(symbol, name, description) - #define CONFIG_STRING_INFO_DIRECT_ACCESS(symbol, name, description) -#endif // _DEBUG - // Now that we have defined what what the macros in file:CLRConfigValues.h mean, include it to generate the code. - #include "clrconfigvalues.h" - - #undef RETAIL_CONFIG_DWORD_INFO - #undef RETAIL_CONFIG_STRING_INFO - #undef RETAIL_CONFIG_DWORD_INFO_EX - #undef RETAIL_CONFIG_STRING_INFO_EX - #undef RETAIL_CONFIG_DWORD_INFO_DIRECT_ACCESS - #undef RETAIL_CONFIG_STRING_INFO_DIRECT_ACCESS - #undef CONFIG_DWORD_INFO - #undef CONFIG_STRING_INFO - #undef CONFIG_DWORD_INFO_EX - #undef CONFIG_STRING_INFO_EX - #undef CONFIG_DWORD_INFO_DIRECT_ACCESS - #undef CONFIG_STRING_INFO_DIRECT_ACCESS - - // - // Methods to do config value (DWORD and String) lookups. - // - static BOOL IsConfigEnabled(const ConfigDWORDInfo & info); - - // Look up a DWORD config value. - static DWORD GetConfigValue(const ConfigDWORDInfo & info); - - // Look up a DWORD config value. - static DWORD GetConfigValue(const ConfigDWORDInfo & info, bool acceptExplicitDefaultFromRegutil, /* [Out] */ bool *isDefault); - - // Look up a string config value. - // You own the string that's returned. - static LPWSTR GetConfigValue(const ConfigStringInfo & info); - - // Look up a string config value, passing it out through a pointer reference. Reports out of memory - // errors (HRESULT E_OUTOFMEMORY). - // You own the string that's returned. - static HRESULT GetConfigValue(const ConfigStringInfo & info, __deref_out_z LPWSTR * outVal); - - // - // Check whether an option is specified (e.g. explicitly listed) in any of the CLRConfig - // locations: environment or registry (with or without COMPlus_) or any config file. - // The result is therefore a conservative approximation (some settings do not actually - // take effect everywhere and no setting is valid both with and without COMPlus_) - // - static BOOL IsConfigOptionSpecified(LPCWSTR name); - - // Free a string returned by GetConfigValue - static void FreeConfigString(__in __in_z LPWSTR name); - - // Register EEConfig's GetConfigValueCallback function so CLRConfig can look in config files. - static void RegisterGetConfigValueCallback(GetConfigValueFunction func); - -private: - // Function pointer to EEConfig's GetConfigValueCallback function (can't static bind from utilcode to VM) - static GetConfigValueFunction s_GetConfigValueCallback; - - - // Helper method to translate LookupOptions to REGUTIL::CORConfigLevel - static REGUTIL::CORConfigLevel GetConfigLevel(LookupOptions options); - - // - // Helper methods. - // - - // Helper method to check if a certain option is set in a ConfigDWORDInfo struct. - static inline BOOL CheckLookupOption(const ConfigDWORDInfo & info, LookupOptions option) - { - LIMITED_METHOD_CONTRACT; - return ((info.options & option) == option) ? TRUE : FALSE; - } - - // Helper method to check if a certain option is set in a ConfigStringInfo struct. - static inline BOOL CheckLookupOption(const ConfigStringInfo & info, LookupOptions option) - { - LIMITED_METHOD_CONTRACT; - return ((info.options & option) == option) ? TRUE : FALSE; - } - - // Helper method to check if a certain option is set in an options enum. - static inline BOOL CheckLookupOption(LookupOptions infoOptions, LookupOptions optionToCheck) - { - LIMITED_METHOD_CONTRACT; - return ((infoOptions & optionToCheck) == optionToCheck) ? TRUE : FALSE; - } - - static HRESULT TrimWhiteSpace(LPCWSTR wszOrig, __deref_out_z LPWSTR * pwszTrimmed); -}; - -inline CLRConfig::LookupOptions operator|(CLRConfig::LookupOptions lhs, CLRConfig::LookupOptions rhs) -{ - return static_cast(static_cast(lhs) | static_cast(rhs)); -} - -typedef Wrapper CLRConfigStringHolder; - -#endif //__CLRConfig_h__ diff --git a/src/inc/clrconfigvalues.h b/src/inc/clrconfigvalues.h deleted file mode 100644 index 12a2c0f37..000000000 --- a/src/inc/clrconfigvalues.h +++ /dev/null @@ -1,845 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -//***************************************************************************** -// CLRConfigValues.h -// - -// -// Unified method of accessing configuration values from environment variables, -// registry and config file. -// -//***************************************************************************** - -// IMPORTANT: Before adding a new config value, please read up on naming conventions (see -// code:#NamingConventions) -// -// ========== -// CONTENTS -// ========== -// * How to define config values (see code:#Define) -// * How to access config values (see code:#Access) -// * Naming conventions (see code:#NamingConventions) -// -// -// ===================================== -// #Define - Use one of the following macros to define config values. (See code:#DWORDs and code:#Strings) -// ===================================== -// -// By default, all macros are DEBUG ONLY. Add the "RETAIL_" prefix to make the config value available in retail builds. -// -// #DWORDs: -// -------------------------------------------------------------------------- -// CONFIG_DWORD_INFO(symbol, name, defaultValue, description) -// -------------------------------------------------------------------------- -// Use this macro to define a basic DWORD value. CLRConfig will look in environment variables (adding -// COMPlus_ to the name), the registry (HKLM and HKCU), and all the config files for this value. To customize -// where CLRConfig looks, use the extended version of the macro below. IMPORTANT: please follow the -// code:#NamingConventions for the symbol and the name! -// -// Example: CONFIG_DWORD_INFO(INTERNAL_AllowCrossModuleInlining, W("AllowCrossModuleInlining"), 0, "") -// -// -------------------------------------------------------------------------- -// CONFIG_DWORD_INFO_EX(symbol, name, defaultValue, description, lookupOptions) -// -------------------------------------------------------------------------- -// To customize where CLRConfig looks to get a DWORD, use the extended (_EX) version of the macro. For a list -// of options and their descriptions, see code:CLRConfig.LookupOptions -// -// Example: CONFIG_DWORD_INFO_EX(INTERNAL_EnableInternetHREFexes, W("EnableInternetHREFexes"), 0, "", -// (CLRConfig::LookupOptions) (CLRConfig::IgnoreEnv | CLRConfig::IgnoreHKCU)) -// -// #Strings: -// -------------------------------------------------------------------------- -// CONFIG_STRING_INFO(symbol, name, description) -// -------------------------------------------------------------------------- -// Defines a string value. Same rules apply as DWORDs. -// -// -------------------------------------------------------------------------- -// CONFIG_STRING_INFO_EX(symbol, name, description, lookupOptions) -// -------------------------------------------------------------------------- -// Extended version of the String macro. Again, similar to the DWORD extended macro. -// -// -// =============================================================== -// #Access - Use the following overloaded method to access config values. -// =============================================================== -// From anywhere, use CLRConfig::GetConfigValue(CLRConfig::) to access any value defined in this -// file. -// -// -// =============================================================== -// #NamingConventions -// =============================================================== -// ---------------- -// #Symbol - used to access values from the source. (using CLRConfig::) -// ---------------- -// The symbol for each config value is named as such: -// ### __ ### -// -// indicates which of the following buckets the value is in: -// * INTERNAL ? this value is for internal (CLR team) use only -// * UNSUPPORTED ? this value is available to partners/developers, but is not officially supported -// * EXTERNAL ? this value is available for anyone to use and is publicly documented -// -// Examples: -// * INTERNAL_Security_FullAccessChecks -// * UNSUPPORTED_Security_DisableTransparency -// * EXTERNAL_Security_LegacyHMACMode -// -// ---------------- -// #Name - the name of the registry value or environment variable that CLRConfig looks up. -// ---------------- -// The name of each value is the same as the symbol, with one exception. Names of external values do NOT -// contain the EXTERNAL prefix. -// -// For compatibility reasons, current names do not follow the convention. -// -// Examples: -// * W("INTERNAL_Security_FullAccessChecks") -// * W("UNSUPPORTED_Security_DisableTransparency") -// * W("Security_LegacyHMACMode") <---------------------- (No EXTERNAL prefix) - -/// -/// AppDomain -/// -CONFIG_DWORD_INFO(INTERNAL_ADBreakOnCannotUnload, W("ADBreakOnCannotUnload"), 0, "Used to troubleshoot failures to unload appdomain (e.g. someone sitting in unmanged code). In some cases by the time we throw the appropriate exception the thread has moved from the offending call. This setting allows in an instrumented build to stop exactly at the right moment.") -RETAIL_CONFIG_DWORD_INFO_DIRECT_ACCESS(UNSUPPORTED_AddRejitNops, W("AddRejitNops"), "Control for the profiler rejit feature infrastructure") -CONFIG_DWORD_INFO(INTERNAL_ADDumpSB, W("ADDumpSB"), 0, "Not used") -CONFIG_DWORD_INFO(INTERNAL_ADForceSB, W("ADForceSB"), 0, "Forces sync block creation for all objects") -CONFIG_DWORD_INFO(INTERNAL_ADLogMemory, W("ADLogMemory"), 0, "Superseded by test hooks") -CONFIG_DWORD_INFO(INTERNAL_ADTakeDHSnapShot, W("ADTakeDHSnapShot"), 0, "Superseded by test hooks") -CONFIG_DWORD_INFO(INTERNAL_ADTakeSnapShot, W("ADTakeSnapShot"), 0, "Superseded by test hooks") -CONFIG_DWORD_INFO_DIRECT_ACCESS(INTERNAL_EnableFullDebug, W("EnableFullDebug"), "Heavy-weight checking for AD boundary violations (AD leaks)") -RETAIL_CONFIG_DWORD_INFO(EXTERNAL_ADULazyMemoryRelease, W("ADULazyMemoryRelease"), 1, "On by default. Turned off in cases when people try to catch memory leaks, in which case AD unload should be immediately followed by GC)") -RETAIL_CONFIG_DWORD_INFO_DIRECT_ACCESS(EXTERNAL_ADURetryCount, W("ADURetryCount"), "Controls timeout of AD unload. Used for workarounds when machine is too slow, there are network issues etc.") - -// For the proposal and discussion on why finalizers are not run on shutdown by default anymore in CoreCLR, see the API review: -// https://github.com/dotnet/corefx/issues/5205 -#define DEFAULT_FinalizeOnShutdown (0) -RETAIL_CONFIG_DWORD_INFO(EXTERNAL_FinalizeOnShutdown, W("FinalizeOnShutdown"), DEFAULT_FinalizeOnShutdown, "When enabled, on shutdown, blocks all user threads and calls finalizers for all finalizable objects, including live objects") - -/// -/// ARM -/// -RETAIL_CONFIG_DWORD_INFO(UNSUPPORTED_ARMEnabled, W("ARMEnabled"), (DWORD)0, "Set it to 1 to enable ARM") - -/// -/// Jit Pitching -/// -RETAIL_CONFIG_DWORD_INFO(INTERNAL_JitPitchEnabled, W("JitPitchEnabled"), (DWORD)0, "Set it to 1 to enable Jit Pitching") -RETAIL_CONFIG_DWORD_INFO(INTERNAL_JitPitchMemThreshold, W("JitPitchMemThreshold"), (DWORD)0, "Do Jit Pitching when code heap usage is larger than this (in bytes)") -RETAIL_CONFIG_DWORD_INFO(INTERNAL_JitPitchMethodSizeThreshold, W("JitPitchMethodSizeThreshold"), (DWORD)0, "Do Jit Pitching for methods whose native code size larger than this (in bytes)") -RETAIL_CONFIG_DWORD_INFO(INTERNAL_JitPitchTimeInterval, W("JitPitchTimeInterval"), (DWORD)0, "Time interval between Jit Pitchings in ms") -RETAIL_CONFIG_DWORD_INFO(INTERNAL_JitPitchPrintStat, W("JitPitchPrintStat"), (DWORD)0, "Print statistics about Jit Pitching") -RETAIL_CONFIG_DWORD_INFO(INTERNAL_JitPitchMinVal, W("JitPitchMinVal"), (DWORD)0, "Do Jit Pitching if the value of the inner counter greater than this value (for debugging purpose only)") -RETAIL_CONFIG_DWORD_INFO(INTERNAL_JitPitchMaxVal, W("JitPitchMaxVal"), (DWORD)0xffffffff, "Do Jit Pitching the value of the inner counter less then this value (for debuggin purpose only)") - -/// -/// Assembly Loader -/// -RETAIL_CONFIG_DWORD_INFO_EX(EXTERNAL_DesignerNamespaceResolutionEnabled, W("designerNamespaceResolution"), FALSE, "Set it to 1 to enable DesignerNamespaceResolve event for WinRT types", CLRConfig::IgnoreEnv | CLRConfig::IgnoreHKLM | CLRConfig::IgnoreHKCU | CLRConfig::FavorConfigFile) -CONFIG_DWORD_INFO_EX(INTERNAL_GetAssemblyIfLoadedIgnoreRidMap, W("GetAssemblyIfLoadedIgnoreRidMap"), 0, "Used to force loader to ignore assemblies cached in the rid-map", CLRConfig::REGUTIL_default) - -/// -/// Conditional breakpoints -/// -RETAIL_CONFIG_DWORD_INFO_EX(UNSUPPORTED_BreakOnBadExit, W("BreakOnBadExit"), 0, "", CLRConfig::REGUTIL_default) -CONFIG_STRING_INFO(INTERNAL_BreakOnClassBuild, W("BreakOnClassBuild"), "Very useful for debugging class layout code.") -CONFIG_STRING_INFO(INTERNAL_BreakOnClassLoad, W("BreakOnClassLoad"), "Very useful for debugging class loading code.") -CONFIG_STRING_INFO(INTERNAL_BreakOnComToClrNativeInfoInit, W("BreakOnComToClrNativeInfoInit"), "Throws an assert when native information about a COM -> CLR call are about to be gathered.") -CONFIG_DWORD_INFO_EX(INTERNAL_BreakOnDebugBreak, W("BreakOnDebugBreak"), 0, "Allows an assert in debug builds when a user break is hit", CLRConfig::REGUTIL_default) -CONFIG_DWORD_INFO_EX(INTERNAL_BreakOnDILoad, W("BreakOnDILoad"), 0, "Allows an assert when the DI is loaded", CLRConfig::REGUTIL_default) -CONFIG_DWORD_INFO_EX(INTERNAL_BreakOnDumpToken, W("BreakOnDumpToken"), 0xffffffff, "Breaks when using internal logging on a particular token value.", CLRConfig::REGUTIL_default) -RETAIL_CONFIG_DWORD_INFO_EX(UNSUPPORTED_BreakOnEELoad, W("BreakOnEELoad"), 0, "", CLRConfig::REGUTIL_default) -CONFIG_DWORD_INFO(INTERNAL_BreakOnEEShutdown, W("BreakOnEEShutdown"), 0, "") -CONFIG_DWORD_INFO_EX(INTERNAL_BreakOnExceptionInGetThrowable, W("BreakOnExceptionInGetThrowable"), 0, "", CLRConfig::REGUTIL_default) -RETAIL_CONFIG_DWORD_INFO(UNSUPPORTED_BreakOnFinalizeTimeOut, W("BreakOnFinalizeTimeOut"), 0, "Triggers a debug break on the finalizer thread when it has exceeded the maximum wait time") -CONFIG_DWORD_INFO(INTERNAL_BreakOnFindMethod, W("BreakOnFindMethod"), 0, "Breaks in findMethodInternal when it searches for the specified token.") -CONFIG_DWORD_INFO_EX(INTERNAL_BreakOnFirstPass, W("BreakOnFirstPass"), 0, "", CLRConfig::REGUTIL_default) -CONFIG_DWORD_INFO_EX(INTERNAL_BreakOnHR, W("BreakOnHR"), 0, "Debug.cpp, IfFailxxx use this macro to stop if hr matches ", CLRConfig::REGUTIL_default) -CONFIG_STRING_INFO(INTERNAL_BreakOnInstantiation, W("BreakOnInstantiation"), "Very useful for debugging generic class instantiation.") -CONFIG_STRING_INFO(INTERNAL_BreakOnInteropStubSetup, W("BreakOnInteropStubSetup"), "Throws an assert when marshaling stub for the given method is about to be built.") -CONFIG_STRING_INFO_EX(INTERNAL_BreakOnInteropVTableBuild, W("BreakOnInteropVTableBuild"), "Specifies a type name for which an assert should be thrown when building interop v-table.", CLRConfig::REGUTIL_default) -CONFIG_STRING_INFO(INTERNAL_BreakOnMethodName, W("BreakOnMethodName"), "Very useful for debugging method override placement code.") -RETAIL_CONFIG_DWORD_INFO_EX(UNSUPPORTED_BreakOnNGenRegistryAccessCount, W("BreakOnNGenRegistryAccessCount"), 0, "Breaks on the Nth' root store write", CLRConfig::REGUTIL_default) -CONFIG_DWORD_INFO_EX(INTERNAL_BreakOnNotify, W("BreakOnNotify"), 0, "", CLRConfig::REGUTIL_default) -RETAIL_CONFIG_DWORD_INFO_EX(INTERNAL_BreakOnRetailAssert, W("BreakOnRetailAssert"), 0, "Used for debugging \"retail\" asserts (fatal errors)", CLRConfig::REGUTIL_default) -CONFIG_DWORD_INFO_EX(INTERNAL_BreakOnSecondPass, W("BreakOnSecondPass"), 0, "", CLRConfig::REGUTIL_default) -RETAIL_CONFIG_DWORD_INFO_EX(UNSUPPORTED_BreakOnSO, W("BreakOnSO"), 0, "", CLRConfig::REGUTIL_default) -CONFIG_STRING_INFO(INTERNAL_BreakOnStructMarshalSetup, W("BreakOnStructMarshalSetup"), "Throws an assert when field marshalers for the given type with layout are about to be created.") -CONFIG_DWORD_INFO_EX(INTERNAL_BreakOnUEF, W("BreakOnUEF"), 0, "", CLRConfig::REGUTIL_default) -CONFIG_DWORD_INFO_EX(INTERNAL_BreakOnUncaughtException, W("BreakOnUncaughtException"), 0, "", CLRConfig::REGUTIL_default) - -/// - -/// Debugger -/// -RETAIL_CONFIG_DWORD_INFO_EX(EXTERNAL_EnableDiagnostics, W("EnableDiagnostics"), 1, "Allows the debugger and profiler diagnostics to be disabled", CLRConfig::REGUTIL_default) -CONFIG_DWORD_INFO_EX(INTERNAL_D__FCE, W("D::FCE"), 0, "Allows an assert when crawling the managed stack for an exception handler", CLRConfig::REGUTIL_default) -CONFIG_DWORD_INFO_EX(INTERNAL_DbgBreakIfLocksUnavailable, W("DbgBreakIfLocksUnavailable"), 0, "Allows an assert when the debugger can't take a lock ", CLRConfig::REGUTIL_default) -CONFIG_DWORD_INFO_EX(INTERNAL_DbgBreakOnErr, W("DbgBreakOnErr"), 0, "Allows an assert when we get a failing hresult", CLRConfig::REGUTIL_default) -CONFIG_DWORD_INFO_EX(INTERNAL_DbgBreakOnMapPatchToDJI, W("DbgBreakOnMapPatchToDJI"), 0, "Allows an assert when mapping a patch to an address", CLRConfig::REGUTIL_default) -CONFIG_DWORD_INFO_EX(INTERNAL_DbgBreakOnRawInt3, W("DbgBreakOnRawInt3"), 0, "Allows an assert for test coverage for debug break or other int3 breaks", CLRConfig::REGUTIL_default) -CONFIG_DWORD_INFO_EX(INTERNAL_DbgBreakOnSendBreakpoint, W("DbgBreakOnSendBreakpoint"), 0, "Allows an assert when sending a breakpoint to the right side", CLRConfig::REGUTIL_default) -CONFIG_DWORD_INFO_EX(INTERNAL_DbgBreakOnSetIP, W("DbgBreakOnSetIP"), 0, "Allows an assert when setting the IP", CLRConfig::REGUTIL_default) -CONFIG_DWORD_INFO_EX(INTERNAL_DbgCheckInt3, W("DbgCheckInt3"), 0, "Asserts if the debugger explicitly writes int3 instead of calling SetUnmanagedBreakpoint", CLRConfig::REGUTIL_default) -CONFIG_DWORD_INFO_DIRECT_ACCESS(INTERNAL_DbgDACAssertOnMismatch, W("DbgDACAssertOnMismatch"), "Allows an assert when the mscordacwks and mscorwks dll versions don't match") -CONFIG_DWORD_INFO_EX(INTERNAL_DbgDACEnableAssert, W("DbgDACEnableAssert"), 0, "Enables extra validity checking in DAC - assumes target isn't corrupt", CLRConfig::REGUTIL_default) -RETAIL_CONFIG_DWORD_INFO_EX(INTERNAL_DbgDACSkipVerifyDlls, W("DbgDACSkipVerifyDlls"), 0, "Allows disabling the check to ensure mscordacwks and mscorwks dll versions match", CLRConfig::REGUTIL_default) -CONFIG_DWORD_INFO_EX(INTERNAL_DbgDelayHelper, W("DbgDelayHelper"), 0, "Varies the wait in the helper thread startup for testing race between threads", CLRConfig::REGUTIL_default) -RETAIL_CONFIG_DWORD_INFO_EX(INTERNAL_DbgDisableDynamicSymsCompat, W("DbgDisableDynamicSymsCompat"), 0, "", CLRConfig::REGUTIL_default) -CONFIG_DWORD_INFO_EX(INTERNAL_DbgDisableTargetConsistencyAsserts, W("DbgDisableTargetConsistencyAsserts"), 0, "Allows explicitly testing with corrupt targets", CLRConfig::REGUTIL_default) -RETAIL_CONFIG_DWORD_INFO_EX(INTERNAL_DbgEnableMixedModeDebugging, W("DbgEnableMixedModeDebuggingInternalOnly"), 0, "", CLRConfig::REGUTIL_default) -CONFIG_DWORD_INFO_EX(INTERNAL_DbgExtraThreads, W("DbgExtraThreads"), 0, "Allows extra unmanaged threads to run and throw debug events for stress testing", CLRConfig::REGUTIL_default) -CONFIG_DWORD_INFO_EX(INTERNAL_DbgExtraThreadsCantStop, W("DbgExtraThreadsCantStop"), 0, "Allows extra unmanaged threads in can't stop region to run and throw debug events for stress testing", CLRConfig::REGUTIL_default) -CONFIG_DWORD_INFO_EX(INTERNAL_DbgExtraThreadsIB, W("DbgExtraThreadsIB"), 0, "Allows extra in-band unmanaged threads to run and throw debug events for stress testing", CLRConfig::REGUTIL_default) -CONFIG_DWORD_INFO_EX(INTERNAL_DbgExtraThreadsOOB, W("DbgExtraThreadsOOB"), 0, "Allows extra out of band unmanaged threads to run and throw debug events for stress testing", CLRConfig::REGUTIL_default) -CONFIG_DWORD_INFO_EX(INTERNAL_DbgFaultInHandleIPCEvent, W("DbgFaultInHandleIPCEvent"), 0, "Allows testing the unhandled event filter", CLRConfig::REGUTIL_default) -CONFIG_DWORD_INFO_EX(INTERNAL_DbgInjectFEE, W("DbgInjectFEE"), 0, "Allows injecting a fatal execution error for testing Watson", CLRConfig::REGUTIL_default) -CONFIG_DWORD_INFO_EX(INTERNAL_DbgLeakCheck, W("DbgLeakCheck"), 0, "Allows checking for leaked Cordb objects", CLRConfig::REGUTIL_default) -CONFIG_DWORD_INFO_EX(INTERNAL_DbgNo2ndChance, W("DbgNo2ndChance"), 0, "Allows breaking on (and catching bogus) 2nd chance exceptions", CLRConfig::REGUTIL_default) -CONFIG_DWORD_INFO_EX(INTERNAL_DbgNoDebugger, W("DbgNoDebugger"), 0, "Allows breaking if we don't want to lazily initialize the debugger", CLRConfig::REGUTIL_default) -RETAIL_CONFIG_DWORD_INFO_EX(UNSUPPORTED_DbgNoForceContinue, W("DbgNoForceContinue"), 1, "Used to force a continue on longhorn", CLRConfig::REGUTIL_default) -CONFIG_DWORD_INFO_EX(INTERNAL_DbgNoOpenMDByFile, W("DbgNoOpenMDByFile"), 0, "Allows opening MD by memory for perf testing", CLRConfig::REGUTIL_default) -CONFIG_DWORD_INFO(INTERNAL_DbgOOBinFEEE, W("DbgOOBinFEEE"), 0, "Allows forcing oob breakpoints when a fatal error occurs") -RETAIL_CONFIG_STRING_INFO_DIRECT_ACCESS(EXTERNAL_DbgPackShimPath, W("DbgPackShimPath"), "CoreCLR path to dbgshim.dll - we are trying to figure out if we can remove this") -CONFIG_DWORD_INFO_EX(INTERNAL_DbgPingInterop, W("DbgPingInterop"), 0, "Allows checking for deadlocks in interop debugging", CLRConfig::REGUTIL_default) -CONFIG_DWORD_INFO_EX(INTERNAL_DbgRace, W("DbgRace"), 0, "Allows pausing for native debug events to get hijicked", CLRConfig::REGUTIL_default) -RETAIL_CONFIG_DWORD_INFO_EX(UNSUPPORTED_DbgRedirect, W("DbgRedirect"), 0, "Allows for redirecting the event pipeline", CLRConfig::REGUTIL_default) -RETAIL_CONFIG_STRING_INFO_DIRECT_ACCESS(EXTERNAL_DbgRedirectApplication, W("DbgRedirectApplication"), "Specifies the auxiliary debugger application to launch.") -RETAIL_CONFIG_STRING_INFO_DIRECT_ACCESS(EXTERNAL_DbgRedirectAttachCmd, W("DbgRedirectAttachCmd"), "Specifies command parameters for attaching the auxiliary debugger.") -RETAIL_CONFIG_STRING_INFO_DIRECT_ACCESS(EXTERNAL_DbgRedirectCommonCmd, W("DbgRedirectCommonCmd"), "Specifies a command line format string for the auxiliary debugger.") -RETAIL_CONFIG_STRING_INFO_DIRECT_ACCESS(EXTERNAL_DbgRedirectCreateCmd, W("DbgRedirectCreateCmd"), "Specifies command parameters when creating the auxiliary debugger.") -CONFIG_DWORD_INFO_EX(INTERNAL_DbgShortcutCanary, W("DbgShortcutCanary"), 0, "Allows a way to force canary to fail to be able to test failure paths", CLRConfig::REGUTIL_default) -CONFIG_DWORD_INFO_EX(INTERNAL_DbgSkipMEOnStep, W("DbgSkipMEOnStep"), 0, "Turns off MethodEnter checks", CLRConfig::REGUTIL_default) -CONFIG_DWORD_INFO_EX(INTERNAL_DbgSkipVerCheck, W("DbgSkipVerCheck"), 0, "Allows different RS and LS versions (for servicing work)", CLRConfig::REGUTIL_default) -CONFIG_DWORD_INFO_EX(INTERNAL_DbgTC, W("DbgTC"), 0, "Allows checking boundary compression for offset mappings", CLRConfig::REGUTIL_default) -CONFIG_DWORD_INFO_EX(INTERNAL_DbgTransportFaultInject, W("DbgTransportFaultInject"), 0, "Allows injecting a fault for testing the debug transport", CLRConfig::REGUTIL_default) -CONFIG_DWORD_INFO_DIRECT_ACCESS(INTERNAL_DbgTransportLog, W("DbgTransportLog"), "Turns on logging for the debug transport") -CONFIG_DWORD_INFO_DIRECT_ACCESS(INTERNAL_DbgTransportLogClass, W("DbgTransportLogClass"), "Mask to control what is logged in DbgTransportLog") -RETAIL_CONFIG_STRING_INFO_EX(UNSUPPORTED_DbgTransportProxyAddress, W("DbgTransportProxyAddress"), "Allows specifying the transport proxy address", CLRConfig::REGUTIL_default) -CONFIG_DWORD_INFO_EX(INTERNAL_DbgTrapOnSkip, W("DbgTrapOnSkip"), 0, "Allows breaking when we skip a breakpoint", CLRConfig::REGUTIL_default) -CONFIG_DWORD_INFO_EX(INTERNAL_DbgWaitTimeout, W("DbgWaitTimeout"), 1, "Specifies the timeout value for waits", CLRConfig::REGUTIL_default) -RETAIL_CONFIG_DWORD_INFO_EX(UNSUPPORTED_DbgWFDETimeout, W("DbgWFDETimeout"), 25, "Specifies the timeout value for wait when waiting for a debug event", CLRConfig::REGUTIL_default) -CONFIG_DWORD_INFO_EX(INTERNAL_RaiseExceptionOnAssert, W("RaiseExceptionOnAssert"), 0, "Raise a first chance (if set to 1) or second chance (if set to 2) exception on asserts.", CLRConfig::REGUTIL_default) -CONFIG_DWORD_INFO_EX(INTERNAL_DebugBreakOnAssert, W("DebugBreakOnAssert"), 0, "If DACCESS_COMPILE is defined, break on asserts.", CLRConfig::REGUTIL_default) -CONFIG_DWORD_INFO_EX(INTERNAL_DebugBreakOnVerificationFailure, W("DebugBreakOnVerificationFailure"), 0, "Halts the jit on verification failure", CLRConfig::REGUTIL_default) -CONFIG_STRING_INFO_EX(INTERNAL_DebuggerBreakPoint, W("DebuggerBreakPoint"), "Allows counting various debug events", CLRConfig::REGUTIL_default) -CONFIG_STRING_INFO_EX(INTERNAL_DebugVerify, W("DebugVerify"), "Control for tracing in peverify", CLRConfig::REGUTIL_default) -CONFIG_DWORD_INFO(INTERNAL_EncApplyChanges, W("EncApplyChanges"), 0, "Allows breaking when ApplyEditAndContinue is called") -CONFIG_DWORD_INFO_EX(INTERNAL_EnCBreakOnRemapComplete, W("EnCBreakOnRemapComplete"), 0, "Allows breaking after N RemapCompletes", CLRConfig::REGUTIL_default) -CONFIG_DWORD_INFO_EX(INTERNAL_EnCBreakOnRemapOpportunity, W("EnCBreakOnRemapOpportunity"), 0, "Allows breaking after N RemapOpportunities", CLRConfig::REGUTIL_default) -CONFIG_DWORD_INFO(INTERNAL_EncDumpApplyChanges, W("EncDumpApplyChanges"), 0, "Allows dumping edits in delta metadata and il files") -CONFIG_DWORD_INFO(INTERNAL_EncFixupFieldBreak, W("EncFixupFieldBreak"), 0, "Unlikely that this is used anymore.") -CONFIG_DWORD_INFO(INTERNAL_EncJitUpdatedFunction, W("EncJitUpdatedFunction"), 0, "Allows breaking when an updated function is jitted") -CONFIG_DWORD_INFO(INTERNAL_EnCResolveField, W("EnCResolveField"), 0, "Allows breaking when computing the address of an EnC-added field") -CONFIG_DWORD_INFO(INTERNAL_EncResumeInUpdatedFunction, W("EncResumeInUpdatedFunction"), 0, "Allows breaking when execution resumes in a new EnC version of a function") -CONFIG_DWORD_INFO_EX(INTERNAL_DbgAssertOnDebuggeeDebugBreak, W("DbgAssertOnDebuggeeDebugBreak"), 0, "If non-zero causes the managed-only debugger to assert on unhandled breakpoints in the debuggee", CLRConfig::REGUTIL_default) -RETAIL_CONFIG_DWORD_INFO(UNSUPPORTED_DbgDontResumeThreadsOnUnhandledException, W("UNSUPPORTED_DbgDontResumeThreadsOnUnhandledException"), 0, "If non-zero, then don't try to unsuspend threads after continuing a 2nd-chance native exception") -RETAIL_CONFIG_DWORD_INFO_EX(UNSUPPORTED_DbgSkipStackCheck, W("DbgSkipStackCheck"), 0, "Skip the stack pointer check during stackwalking", CLRConfig::REGUTIL_default) -#ifdef DACCESS_COMPILE -CONFIG_DWORD_INFO(INTERNAL_DumpGeneration_IntentionallyCorruptDataFromTarget, W("IntentionallyCorruptDataFromTarget"), 0, "Intentionally fakes bad data retrieved from target to try and break dump generation.") -#endif -// Note that Debugging_RequiredVersion is sometimes an 'INTERNAL' knob and sometimes an 'UNSUPPORTED' knob, but we don't change it's name. -CONFIG_DWORD_INFO(UNSUPPORTED_Debugging_RequiredVersion, W("UNSUPPORTED_Debugging_RequiredVersion"), 0, "The lowest ICorDebug version we should attempt to emulate, or 0 for default policy. Use 2 for CLRv2, 4 for CLRv4, etc.") - -#ifdef FEATURE_MINIMETADATA_IN_TRIAGEDUMPS -RETAIL_CONFIG_DWORD_INFO(INTERNAL_MiniMdBufferCapacity, W("MiniMdBufferCapacity"), 64 * 1024, "The max size of the buffer to store mini metadata information for triage- and mini-dumps.") -#endif // FEATURE_MINIMETADATA_IN_TRIAGEDUMPS - -CONFIG_DWORD_INFO_EX(INTERNAL_DbgNativeCodeBpBindsAcrossVersions, W("DbgNativeCodeBpBindsAcrossVersions"), 0, "If non-zero causes native breakpoints at offset 0 to bind in all tiered compilation versions of the given method", CLRConfig::REGUTIL_default) - -/// -/// Diagnostics (internal general-purpose) -/// -CONFIG_DWORD_INFO_DIRECT_ACCESS(INTERNAL_ConditionalContracts, W("ConditionalContracts"), "If ENABLE_CONTRACTS_IMPL is defined, sets whether contracts are conditional. (?)") -CONFIG_DWORD_INFO(INTERNAL_ConsistencyCheck, W("ConsistencyCheck"), 0, "") -CONFIG_DWORD_INFO_EX(INTERNAL_ContinueOnAssert, W("ContinueOnAssert"), 0, "If set, doesn't break on asserts.", CLRConfig::REGUTIL_default) -RETAIL_CONFIG_DWORD_INFO_EX(UNSUPPORTED_disableStackOverflowProbing, W("disableStackOverflowProbing"), 0, "", CLRConfig::FavorConfigFile) -CONFIG_DWORD_INFO_DIRECT_ACCESS(INTERNAL_InjectFatalError, W("InjectFatalError"), "") -CONFIG_DWORD_INFO_EX(INTERNAL_InjectFault, W("InjectFault"), 0, "", CLRConfig::REGUTIL_default) -CONFIG_DWORD_INFO_DIRECT_ACCESS(INTERNAL_SuppressChecks, W("SuppressChecks"), "") -#ifdef WIN64EXCEPTIONS -CONFIG_DWORD_INFO(INTERNAL_SuppressLockViolationsOnReentryFromOS, W("SuppressLockViolationsOnReentryFromOS"), 0, "64 bit OOM tests re-enter the CLR via RtlVirtualUnwind. This indicates whether to suppress resulting locking violations.") -#endif // WIN64EXCEPTIONS -CONFIG_STRING_INFO(INTERNAL_TestHooks, W("TestHooks"), "Used by tests to get test an insight on various CLR workings") - - -/// -/// Exception Handling -/// -CONFIG_DWORD_INFO_DIRECT_ACCESS(INTERNAL_AssertOnFailFast, W("AssertOnFailFast"), "") -RETAIL_CONFIG_DWORD_INFO_EX(UNSUPPORTED_legacyCorruptedStateExceptionsPolicy, W("legacyCorruptedStateExceptionsPolicy"), 0, "Enabled Pre-V4 CSE behavior", CLRConfig::FavorConfigFile) -CONFIG_DWORD_INFO_EX(INTERNAL_SuppressLostExceptionTypeAssert, W("SuppressLostExceptionTypeAssert"), 0, "", CLRConfig::REGUTIL_default) -RETAIL_CONFIG_DWORD_INFO_EX(UNSUPPORTED_FailFastOnCorruptedStateException, W("FailFastOnCorruptedStateException"), 0, "Failfast if a CSE is encountered", CLRConfig::FavorConfigFile) - -/// -/// Garbage collector -/// -CONFIG_DWORD_INFO(INTERNAL_FastGCCheckStack, W("FastGCCheckStack"), 0, "") -CONFIG_DWORD_INFO_DIRECT_ACCESS(INTERNAL_FastGCStress, W("FastGCStress"), "Reduce the number of GCs done by enabling GCStress") -RETAIL_CONFIG_DWORD_INFO_DIRECT_ACCESS(UNSUPPORTED_GCBreakOnOOM, W("GCBreakOnOOM"), "Does a DebugBreak at the soonest time we detect an OOM") -RETAIL_CONFIG_DWORD_INFO(UNSUPPORTED_gcConcurrent, W("gcConcurrent"), (DWORD)-1, "Enables/Disables concurrent GC") - -#ifdef FEATURE_CONSERVATIVE_GC -RETAIL_CONFIG_DWORD_INFO(UNSUPPORTED_gcConservative, W("gcConservative"), 0, "Enables/Disables conservative GC") -#endif -RETAIL_CONFIG_DWORD_INFO(UNSUPPORTED_gcServer, W("gcServer"), 0, "Enables server GC") -CONFIG_STRING_INFO(INTERNAL_GcCoverage, W("GcCoverage"), "Specify a method or regular expression of method names to run with GCStress") -CONFIG_STRING_INFO(INTERNAL_SkipGCCoverage, W("SkipGcCoverage"), "Specify a list of assembly names to skip with GC Coverage") -RETAIL_CONFIG_DWORD_INFO_DIRECT_ACCESS(UNSUPPORTED_gcForceCompact, W("gcForceCompact"), "When set to true, always do compacting GC") -RETAIL_CONFIG_DWORD_INFO_DIRECT_ACCESS(UNSUPPORTED_GCgen0size, W("GCgen0size"), "Specifies the smallest gen0 size") -RETAIL_CONFIG_DWORD_INFO(INTERNAL_GCStressMix, W("GCStressMix"), 0, "Specifies whether the GC mix mode is enabled or not") -RETAIL_CONFIG_DWORD_INFO(INTERNAL_GCStressStep, W("GCStressStep"), 1, "Specifies how often StressHeap will actually do a GC in GCStressMix mode") -RETAIL_CONFIG_DWORD_INFO(INTERNAL_GCStressMaxFGCsPerBGC, W("GCStressMaxFGCsPerBGC"), ~0U, "Specifies how many FGCs will occur during one BGC in GCStressMix mode") -RETAIL_CONFIG_DWORD_INFO(UNSUPPORTED_StatsUpdatePeriod, W("StatsUpdatePeriod"), 60, "Specifies the interval, in seconds, at which to update the statistics") -RETAIL_CONFIG_STRING_INFO(UNSUPPORTED_SuspendTimeLog, W("SuspendTimeLog"), "Specifies the name of the log file for suspension statistics") -RETAIL_CONFIG_STRING_INFO(UNSUPPORTED_GCMixLog, W("GCMixLog"), "Specifies the name of the log file for GC mix statistics") -CONFIG_DWORD_INFO_DIRECT_ACCESS(INTERNAL_GCLatencyMode, W("GCLatencyMode"), "Specifies the GC latency mode - batch, interactive or low latency (note that the same thing can be specified via API which is the supported way)") -RETAIL_CONFIG_DWORD_INFO(EXTERNAL_GCLatencyLevel, W("GCLatencyLevel"), 1, "Specifies the GC latency level that you want to optimize for") -RETAIL_CONFIG_DWORD_INFO(UNSUPPORTED_GCConfigLogEnabled, W("GCConfigLogEnabled"), 0, "Specifies if you want to turn on config logging in GC") -RETAIL_CONFIG_DWORD_INFO(UNSUPPORTED_GCLogEnabled, W("GCLogEnabled"), 0, "Specifies if you want to turn on logging in GC") -RETAIL_CONFIG_STRING_INFO(UNSUPPORTED_GCLogFile, W("GCLogFile"), "Specifies the name of the GC log file") -RETAIL_CONFIG_STRING_INFO(UNSUPPORTED_GCConfigLogFile, W("GCConfigLogFile"), "Specifies the name of the GC config log file") -RETAIL_CONFIG_DWORD_INFO(UNSUPPORTED_GCLogFileSize, W("GCLogFileSize"), 0, "Specifies the GC log file size") -RETAIL_CONFIG_DWORD_INFO(UNSUPPORTED_GCCompactRatio, W("GCCompactRatio"), 0, "Specifies the ratio compacting GCs vs sweeping ") -RETAIL_CONFIG_DWORD_INFO_DIRECT_ACCESS(EXTERNAL_GCPollType, W("GCPollType"), "") -RETAIL_CONFIG_DWORD_INFO(UNSUPPORTED_GCRetainVM, W("GCRetainVM"), 0, "When set we put the segments that should be deleted on a standby list (instead of releasing them back to the OS) which will be considered to satisfy new segment requests (note that the same thing can be specified via API which is the supported way)") -RETAIL_CONFIG_DWORD_INFO_DIRECT_ACCESS(UNSUPPORTED_GCSegmentSize, W("GCSegmentSize"), "Specifies the managed heap segment size") -RETAIL_CONFIG_DWORD_INFO_DIRECT_ACCESS(UNSUPPORTED_GCLOHCompact, W("GCLOHCompact"), "Specifies the LOH compaction mode") -RETAIL_CONFIG_DWORD_INFO(EXTERNAL_gcAllowVeryLargeObjects, W("gcAllowVeryLargeObjects"), 1, "Allow allocation of 2GB+ objects on GC heap") -RETAIL_CONFIG_DWORD_INFO_EX(EXTERNAL_GCStress, W("GCStress"), 0, "Trigger GCs at regular intervals", CLRConfig::REGUTIL_default) -CONFIG_DWORD_INFO_EX(INTERNAL_GcStressOnDirectCalls, W("GcStressOnDirectCalls"), 0, "Whether to trigger a GC on direct calls", CLRConfig::REGUTIL_default) -RETAIL_CONFIG_DWORD_INFO(EXTERNAL_GCStressStart, W("GCStressStart"), 0, "Start GCStress after N stress GCs have been attempted") -RETAIL_CONFIG_DWORD_INFO(INTERNAL_GCStressStartAtJit, W("GCStressStartAtJit"), 0, "Start GCStress after N items are jitted") -RETAIL_CONFIG_DWORD_INFO_DIRECT_ACCESS(EXTERNAL_gcTrimCommitOnLowMemory, W("gcTrimCommitOnLowMemory"), "When set we trim the committed space more aggressively for the ephemeral seg. This is used for running many instances of server processes where they want to keep as little memory committed as possible") -RETAIL_CONFIG_DWORD_INFO(UNSUPPORTED_BGCSpinCount, W("BGCSpinCount"), 140, "Specifies the bgc spin count") -RETAIL_CONFIG_DWORD_INFO(UNSUPPORTED_BGCSpin, W("BGCSpin"), 2, "Specifies the bgc spin time") -RETAIL_CONFIG_DWORD_INFO_DIRECT_ACCESS(UNSUPPORTED_HeapVerify, W("HeapVerify"), "When set verifies the integrity of the managed heap on entry and exit of each GC") -RETAIL_CONFIG_STRING_INFO_EX(EXTERNAL_SetupGcCoverage, W("SetupGcCoverage"), "This doesn't appear to be a config flag", CLRConfig::REGUTIL_default) -RETAIL_CONFIG_DWORD_INFO(UNSUPPORTED_GCNumaAware, W("GCNumaAware"), 1, "Specifies if to enable GC NUMA aware") -RETAIL_CONFIG_DWORD_INFO(EXTERNAL_GCCpuGroup, W("GCCpuGroup"), 0, "Specifies if to enable GC to support CPU groups") -RETAIL_CONFIG_DWORD_INFO(UNSUPPORTED_GCHeapCount, W("GCHeapCount"), 0, "") -RETAIL_CONFIG_DWORD_INFO(UNSUPPORTED_GCNoAffinitize, W("GCNoAffinitize"), 0, "") -RETAIL_CONFIG_STRING_INFO(EXTERNAL_GCName, W("GCName"), "") - -/// -/// IBC -/// -RETAIL_CONFIG_DWORD_INFO_EX(UNSUPPORTED_ConvertIbcData, W("ConvertIbcData"), 1, "Converts between v1 and v2 IBC data", CLRConfig::REGUTIL_default) -RETAIL_CONFIG_DWORD_INFO_DIRECT_ACCESS(UNSUPPORTED_DisableHotCold, W("DisableHotCold"), "Master hot/cold splitting switch in Jit64") -RETAIL_CONFIG_DWORD_INFO_EX(UNSUPPORTED_DisableIBC, W("DisableIBC"), 0, "Disables the use of IBC data", CLRConfig::REGUTIL_default) -RETAIL_CONFIG_DWORD_INFO_EX(EXTERNAL_UseIBCFile, W("UseIBCFile"), 0, "", CLRConfig::REGUTIL_default) - - -/// -/// JIT -/// -RETAIL_CONFIG_DWORD_INFO_DIRECT_ACCESS(UNSUPPORTED_JitAlignLoops, W("JitAlignLoops"), "Aligns loop targets to 8 byte boundaries") -CONFIG_DWORD_INFO_EX(INTERNAL_JitBreakEmit, W("JitBreakEmit"), (DWORD)-1, "", CLRConfig::REGUTIL_default) -CONFIG_DWORD_INFO_DIRECT_ACCESS(INTERNAL_JitDebuggable, W("JitDebuggable"), "") -#if !defined(DEBUG) && !defined(_DEBUG) -#define INTERNAL_JitEnableNoWayAssert_Default 0 -#else -#define INTERNAL_JitEnableNoWayAssert_Default 1 -#endif -RETAIL_CONFIG_DWORD_INFO_EX(INTERNAL_JitEnableNoWayAssert, W("JitEnableNoWayAssert"), INTERNAL_JitEnableNoWayAssert_Default, "", CLRConfig::REGUTIL_default) -RETAIL_CONFIG_DWORD_INFO_DIRECT_ACCESS(UNSUPPORTED_JitFramed, W("JitFramed"), "Forces EBP frames") -CONFIG_DWORD_INFO_EX(INTERNAL_JitGCStress, W("JitGCStress"), 0, "GC stress mode for jit", CLRConfig::REGUTIL_default) -CONFIG_DWORD_INFO(INTERNAL_JitHeartbeat, W("JitHeartbeat"), 0, "") -CONFIG_DWORD_INFO(INTERNAL_JitHelperLogging, W("JitHelperLogging"), 0, "") -RETAIL_CONFIG_DWORD_INFO_DIRECT_ACCESS(UNSUPPORTED_JITMinOpts, W("JITMinOpts"), "Forces MinOpts") -RETAIL_CONFIG_STRING_INFO(EXTERNAL_JitName, W("JitName"), "Primary Jit to use") -#if defined(ALLOW_SXS_JIT) -RETAIL_CONFIG_STRING_INFO_EX(EXTERNAL_AltJitName, W("AltJitName"), "Alternative Jit to use, will fall back to primary jit.", CLRConfig::REGUTIL_default) -RETAIL_CONFIG_STRING_INFO_EX(EXTERNAL_AltJit, W("AltJit"), "Enables AltJit and selectively limits it to the specified methods.", CLRConfig::REGUTIL_default) -RETAIL_CONFIG_STRING_INFO_EX(EXTERNAL_AltJitExcludeAssemblies, W("AltJitExcludeAssemblies"), "Do not use AltJit on this semicolon-delimited list of assemblies.", CLRConfig::REGUTIL_default) -#endif // defined(ALLOW_SXS_JIT) - -#if defined(FEATURE_STACK_SAMPLING) -RETAIL_CONFIG_DWORD_INFO(UNSUPPORTED_StackSamplingEnabled, W("StackSamplingEnabled"), 0, "Is stack sampling based tracking of evolving hot methods enabled.") -RETAIL_CONFIG_DWORD_INFO(UNSUPPORTED_StackSamplingAfter, W("StackSamplingAfter"), 0, "When to start sampling (for some sort of app steady state), i.e., initial delay for sampling start in milliseconds.") -RETAIL_CONFIG_DWORD_INFO(UNSUPPORTED_StackSamplingEvery, W("StackSamplingEvery"), 100, "How frequent should thread stacks be sampled in milliseconds.") -RETAIL_CONFIG_DWORD_INFO(UNSUPPORTED_StackSamplingNumMethods, W("StackSamplingNumMethods"), 32, "Number of evolving methods to track as hot and JIT them in the background at a given point of execution.") -#endif // defined(FEATURE_JIT_SAMPLING) - -#if defined(ALLOW_SXS_JIT_NGEN) -RETAIL_CONFIG_STRING_INFO_EX(INTERNAL_AltJitNgen, W("AltJitNgen"), "Enables AltJit for NGEN and selectively limits it to the specified methods.", CLRConfig::REGUTIL_default) -#endif // defined(ALLOW_SXS_JIT_NGEN) - -RETAIL_CONFIG_DWORD_INFO_DIRECT_ACCESS(EXTERNAL_JitOptimizeType, W("JitOptimizeType"), "") -RETAIL_CONFIG_DWORD_INFO_EX(EXTERNAL_JitPrintInlinedMethods, W("JitPrintInlinedMethods"), 0, "", CLRConfig::REGUTIL_default) -RETAIL_CONFIG_DWORD_INFO(EXTERNAL_JitTelemetry, W("JitTelemetry"), 1, "If non-zero, gather JIT telemetry data") -RETAIL_CONFIG_STRING_INFO(INTERNAL_JitTimeLogFile, W("JitTimeLogFile"), "If set, gather JIT throughput data and write to this file.") -RETAIL_CONFIG_STRING_INFO(INTERNAL_JitTimeLogCsv, W("JitTimeLogCsv"), "If set, gather JIT throughput data and write to a CSV file. This mode must be used in internal retail builds.") -RETAIL_CONFIG_STRING_INFO(INTERNAL_JitFuncInfoLogFile, W("JitFuncInfoLogFile"), "If set, gather JIT function info and write to this file.") -CONFIG_DWORD_INFO_DIRECT_ACCESS(INTERNAL_JitVerificationDisable, W("JitVerificationDisable"), "") -RETAIL_CONFIG_DWORD_INFO(INTERNAL_JitLockWrite, W("JitLockWrite"), 0, "Force all volatile writes to be 'locked'") -CONFIG_STRING_INFO_EX(INTERNAL_TailCallMax, W("TailCallMax"), "", CLRConfig::REGUTIL_default) -RETAIL_CONFIG_STRING_INFO_EX(EXTERNAL_TailCallOpt, W("TailCallOpt"), "", CLRConfig::REGUTIL_default) -RETAIL_CONFIG_DWORD_INFO(EXTERNAL_TailCallLoopOpt, W("TailCallLoopOpt"), 1, "Convert recursive tail calls to loops") -RETAIL_CONFIG_DWORD_INFO(EXTERNAL_Jit_NetFx40PInvokeStackResilience, W("NetFx40_PInvokeStackResilience"), (DWORD)-1, "Makes P/Invoke resilient against mismatched signature and calling convention (significant perf penalty).") - -// AltJitAssertOnNYI should be 0 on targets where JIT is under development or bring up stage, so as to facilitate fallback to main JIT on hitting a NYI. -#if defined(_TARGET_X86_) -RETAIL_CONFIG_DWORD_INFO(INTERNAL_AltJitAssertOnNYI, W("AltJitAssertOnNYI"), 0, "Controls the AltJit behavior of NYI stuff") -#else -RETAIL_CONFIG_DWORD_INFO(INTERNAL_AltJitAssertOnNYI, W("AltJitAssertOnNYI"), 1, "Controls the AltJit behavior of NYI stuff") -#endif -CONFIG_DWORD_INFO_EX(INTERNAL_JitLargeBranches, W("JitLargeBranches"), 0, "Force using the largest conditional branch format", CLRConfig::REGUTIL_default) -RETAIL_CONFIG_DWORD_INFO_EX(EXTERNAL_JitRegisterFP, W("JitRegisterFP"), 3, "Control FP enregistration", CLRConfig::REGUTIL_default) -RETAIL_CONFIG_DWORD_INFO(INTERNAL_JitELTHookEnabled, W("JitELTHookEnabled"), 0, "On ARM, setting this will emit Enter/Leave/TailCall callbacks") -RETAIL_CONFIG_DWORD_INFO_EX(INTERNAL_JitMemStats, W("JitMemStats"), 0, "Display JIT memory usage statistics", CLRConfig::REGUTIL_default) -RETAIL_CONFIG_DWORD_INFO(INTERNAL_JitVNMapSelBudget, W("JitVNMapSelBudget"), 100, "Max # of MapSelect's considered for a particular top-level invocation.") -#if defined(_TARGET_AMD64_) || defined(_TARGET_X86_) || defined(_TARGET_ARM64_) -#define EXTERNAL_FeatureSIMD_Default 1 -#else // !(defined(_TARGET_AMD64_) || defined(_TARGET_X86_) || defined(_TARGET_ARM64_)) -#define EXTERNAL_FeatureSIMD_Default 0 -#endif // !(defined(_TARGET_AMD64_) || defined(_TARGET_X86_) || defined(_TARGET_ARM64_)) -#if defined(_TARGET_AMD64_) || defined(_TARGET_X86_) -#define EXTERNAL_JitEnableAVX_Default 1 -#else // !(defined(_TARGET_AMD64_) || defined(_TARGET_X86_) -#define EXTERNAL_JitEnableAVX_Default 0 -#endif // !(defined(_TARGET_AMD64_) || defined(_TARGET_X86_) -RETAIL_CONFIG_DWORD_INFO_EX(EXTERNAL_FeatureSIMD, W("FeatureSIMD"), EXTERNAL_FeatureSIMD_Default, "Enable SIMD intrinsics recognition in System.Numerics.dll and/or System.Numerics.Vectors.dll", CLRConfig::REGUTIL_default) -RETAIL_CONFIG_DWORD_INFO(INTERNAL_SIMD16ByteOnly, W("SIMD16ByteOnly"), 0, "Limit maximum SIMD vector length to 16 bytes (used by x64_arm64_altjit)") -RETAIL_CONFIG_DWORD_INFO_EX(EXTERNAL_EnableAVX, W("EnableAVX"), EXTERNAL_JitEnableAVX_Default, "Enable AVX instruction set for wide operations as default", CLRConfig::REGUTIL_default) - -#ifdef FEATURE_MULTICOREJIT - -RETAIL_CONFIG_STRING_INFO(INTERNAL_MultiCoreJitProfile, W("MultiCoreJitProfile"), "If set, use the file to store/control multi-core JIT.") -RETAIL_CONFIG_DWORD_INFO(INTERNAL_MultiCoreJitProfileWriteDelay, W("MultiCoreJitProfileWriteDelay"), 12, "Set the delay after which the multi-core JIT profile will be written to disk.") - -#endif - -#ifdef FEATURE_INTERPRETER -/// -/// Interpreter -/// -RETAIL_CONFIG_STRING_INFO_EX(INTERNAL_Interpret, W("Interpret"), "Selectively uses the interpreter to execute the specified methods", CLRConfig::REGUTIL_default) -RETAIL_CONFIG_STRING_INFO_EX(INTERNAL_InterpretExclude, W("InterpretExclude"), "Excludes the specified methods from the set selected by 'Interpret'", CLRConfig::REGUTIL_default) -RETAIL_CONFIG_DWORD_INFO(INTERNAL_InterpreterMethHashMin, W("InterpreterMethHashMin"), 0, "Only interpret methods selected by 'Interpret' whose hash is at least this value. or after nth") -RETAIL_CONFIG_DWORD_INFO(INTERNAL_InterpreterMethHashMax, W("InterpreterMethHashMax"), UINT32_MAX, "If non-zero, only interpret methods selected by 'Interpret' whose hash is at most this value") -RETAIL_CONFIG_DWORD_INFO(INTERNAL_InterpreterStubMin, W("InterpreterStubMin"), 0, "Only interpret methods selected by 'Interpret' whose stub num is at least this value.") -RETAIL_CONFIG_DWORD_INFO(INTERNAL_InterpreterStubMax, W("InterpreterStubMax"), UINT32_MAX, "If non-zero, only interpret methods selected by 'Interpret' whose stub number is at most this value.") -RETAIL_CONFIG_DWORD_INFO(INTERNAL_InterpreterJITThreshold, W("InterpreterJITThreshold"), 10, "The number of times a method should be interpreted before being JITted") -RETAIL_CONFIG_DWORD_INFO(INTERNAL_InterpreterDoLoopMethods, W("InterpreterDoLoopMethods"), 0, "If set, don't check for loops, start by interpreting *all* methods") -RETAIL_CONFIG_DWORD_INFO_EX(INTERNAL_InterpreterUseCaching, W("InterpreterUseCaching"), 1, "If non-zero, use the caching mechanism.", CLRConfig::REGUTIL_default) -RETAIL_CONFIG_DWORD_INFO_EX(INTERNAL_InterpreterLooseRules, W("InterpreterLooseRules"), 1, "If non-zero, allow ECMA spec violations required by managed C++.", CLRConfig::REGUTIL_default) -RETAIL_CONFIG_DWORD_INFO(INTERNAL_InterpreterPrintPostMortem, W("InterpreterPrintPostMortem"), 0, "Prints summary information about the execution to the console") -RETAIL_CONFIG_STRING_INFO_EX(INTERNAL_InterpreterLogFile, W("InterpreterLogFile"), "If non-null, append interpreter logging to this file, else use stdout", CLRConfig::REGUTIL_default) -RETAIL_CONFIG_DWORD_INFO(INTERNAL_DumpInterpreterStubs, W("DumpInterpreterStubs"), 0, "Prints all interpreter stubs that are created to the console") -RETAIL_CONFIG_DWORD_INFO(INTERNAL_TraceInterpreterEntries, W("TraceInterpreterEntries"), 0, "Logs entries to interpreted methods to the console") -RETAIL_CONFIG_DWORD_INFO(INTERNAL_TraceInterpreterIL, W("TraceInterpreterIL"), 0, "Logs individual instructions of interpreted methods to the console") -RETAIL_CONFIG_DWORD_INFO(INTERNAL_TraceInterpreterOstack, W("TraceInterpreterOstack"), 0, "Logs operand stack after each IL instruction of interpreted methods to the console") -CONFIG_DWORD_INFO(INTERNAL_TraceInterpreterVerbose, W("TraceInterpreterVerbose"), 0, "Logs interpreter progress with detailed messages to the console") -CONFIG_DWORD_INFO(INTERNAL_TraceInterpreterJITTransition, W("TraceInterpreterJITTransition"), 0, "Logs when the interpreter determines a method should be JITted") -#endif -// The JIT queries this ConfigDWORD but it doesn't know if FEATURE_INTERPRETER is enabled -RETAIL_CONFIG_DWORD_INFO(INTERNAL_InterpreterFallback, W("InterpreterFallback"), 0, "Fallback to the interpreter when the JIT compiler fails") - -/// -/// Loader -/// -CONFIG_DWORD_INFO_DIRECT_ACCESS(INTERNAL_APIThreadStress, W("APIThreadStress"), "Used to test Loader for race conditions") -RETAIL_CONFIG_DWORD_INFO_DIRECT_ACCESS(EXTERNAL_ForceLog, W("ForceLog"), "Fusion flag to enforce assembly binding log. Heavily used and documented in MSDN and BLOGS.") -RETAIL_CONFIG_DWORD_INFO_DIRECT_ACCESS(EXTERNAL_LoaderOptimization, W("LoaderOptimization"), "Controls code sharing behavior") -RETAIL_CONFIG_STRING_INFO(INTERNAL_CoreClrBinderLog, W("CoreClrBinderLog"), "Debug flag that enabled detailed log for new binder (similar to stress logging).") -RETAIL_CONFIG_DWORD_INFO(EXTERNAL_DisableIJWVersionCheck, W("DisableIJWVersionCheck"), 0, "Don't perform the new version check that prevents unsupported IJW in-proc SxS.") -RETAIL_CONFIG_DWORD_INFO(UNSUPPORTED_EnableFastBindClosure, W("EnableFastBindClosure"), 0, "If set to >0 the binder uses CFastAssemblyBindingClosure instances") -RETAIL_CONFIG_DWORD_INFO(INTERNAL_DisableFXClosureWalk, W("DisableFXClosureWalk"), 0, "Disable full closure walks even in the presence of FX binding redirects") -CONFIG_DWORD_INFO(INTERNAL_TagAssemblyNames, W("TagAssemblyNames"), 0, "Enable CAssemblyName::_tag field for more convenient debugging.") -RETAIL_CONFIG_STRING_INFO(INTERNAL_WinMDPath, W("WinMDPath"), "Path for Windows WinMD files") - -/// -/// Loader heap -/// -CONFIG_DWORD_INFO_EX(INTERNAL_LoaderHeapCallTracing, W("LoaderHeapCallTracing"), 0, "Loader heap troubleshooting", CLRConfig::REGUTIL_default) -RETAIL_CONFIG_DWORD_INFO(INTERNAL_CodeHeapReserveForJumpStubs, W("CodeHeapReserveForJumpStubs"), 1, "Percentage of code heap to reserve for jump stubs") -RETAIL_CONFIG_DWORD_INFO(INTERNAL_NGenReserveForJumpStubs, W("NGenReserveForJumpStubs"), 0, "Percentage of ngen image size to reserve for jump stubs") -RETAIL_CONFIG_DWORD_INFO(INTERNAL_BreakOnOutOfMemoryWithinRange, W("BreakOnOutOfMemoryWithinRange"), 0, "Break before out of memory within range exception is thrown") - -/// -/// Log -/// -RETAIL_CONFIG_DWORD_INFO_DIRECT_ACCESS(INTERNAL_LogEnable, W("LogEnable"), "Turns on the traditional CLR log.") -RETAIL_CONFIG_DWORD_INFO_DIRECT_ACCESS(INTERNAL_LogFacility, W("LogFacility"), "Specifies a facility mask for CLR log. (See 'loglf.h'; VM interprets string value as hex number.) Also used by stresslog.") -RETAIL_CONFIG_DWORD_INFO_DIRECT_ACCESS(INTERNAL_LogFacility2, W("LogFacility2"), "Specifies a facility mask for CLR log. (See 'loglf.h'; VM interprets string value as hex number.) Also used by stresslog.") -RETAIL_CONFIG_DWORD_INFO(EXTERNAL_logFatalError, W("logFatalError"), 1, "Specifies whether EventReporter logs fatal errors in the Windows event log.") -CONFIG_STRING_INFO_EX(INTERNAL_LogFile, W("LogFile"), "Specifies a file name for the CLR log.", CLRConfig::REGUTIL_default) -CONFIG_DWORD_INFO_DIRECT_ACCESS(INTERNAL_LogFileAppend, W("LogFileAppend"), "Specifies whether to append to or replace the CLR log file.") -CONFIG_DWORD_INFO_DIRECT_ACCESS(INTERNAL_LogFlushFile, W("LogFlushFile"), "Specifies whether to flush the CLR log file on each write.") -RETAIL_CONFIG_DWORD_INFO_DIRECT_ACCESS(EXTERNAL_LogLevel, W("LogLevel"), "4=10 msgs, 9=1000000, 10=everything") -RETAIL_CONFIG_STRING_INFO_DIRECT_ACCESS(INTERNAL_LogPath, W("LogPath"), "?Fusion debug log path.") -RETAIL_CONFIG_DWORD_INFO_DIRECT_ACCESS(INTERNAL_LogToConsole, W("LogToConsole"), "Writes the CLR log to console.") -CONFIG_DWORD_INFO_DIRECT_ACCESS(INTERNAL_LogToDebugger, W("LogToDebugger"), "Writes the CLR log to debugger (OutputDebugStringA).") -CONFIG_DWORD_INFO_DIRECT_ACCESS(INTERNAL_LogToFile, W("LogToFile"), "Writes the CLR log to a file.") -CONFIG_DWORD_INFO_DIRECT_ACCESS(INTERNAL_LogWithPid, W("LogWithPid"), "Appends pid to filename for the CLR log.") - -/// -/// MetaData -/// -CONFIG_DWORD_INFO_EX(INTERNAL_MD_ApplyDeltaBreak, W("MD_ApplyDeltaBreak"), 0, "ASSERT when applying EnC", CLRConfig::REGUTIL_default) -RETAIL_CONFIG_DWORD_INFO_DIRECT_ACCESS(INTERNAL_AssertOnBadImageFormat, W("AssertOnBadImageFormat"), "ASSERT when invalid MD read") -RETAIL_CONFIG_DWORD_INFO_EX(INTERNAL_MD_DeltaCheck, W("MD_DeltaCheck"), 1, "Some checks of GUID when applying EnC (?)", CLRConfig::REGUTIL_default) -CONFIG_DWORD_INFO_EX(INTERNAL_MD_EncDelta, W("MD_EncDelta"), 0, "Forces EnC Delta format in MD (?)", CLRConfig::REGUTIL_default) -RETAIL_CONFIG_DWORD_INFO_EX(INTERNAL_MD_ForceNoColDesSharing, W("MD_ForceNoColDesSharing"), 0, "Don't know - the only usage I could find is #if 0 (?)", CLRConfig::REGUTIL_default) -CONFIG_DWORD_INFO_EX(INTERNAL_MD_KeepKnownCA, W("MD_KeepKnownCA"), 0, "Something with known CAs (?)", CLRConfig::REGUTIL_default) -CONFIG_DWORD_INFO_EX(INTERNAL_MD_MiniMDBreak, W("MD_MiniMDBreak"), 0, "ASSERT when creating CMiniMdRw class", CLRConfig::REGUTIL_default) -CONFIG_DWORD_INFO_EX(INTERNAL_MD_PreSaveBreak, W("MD_PreSaveBreak"), 0, "ASSERT when calling CMiniMdRw::PreSave", CLRConfig::REGUTIL_default) -CONFIG_DWORD_INFO_EX(INTERNAL_MD_RegMetaBreak, W("MD_RegMetaBreak"), 0, "ASSERT when creating RegMeta class", CLRConfig::REGUTIL_default) -CONFIG_DWORD_INFO_EX(INTERNAL_MD_RegMetaDump, W("MD_RegMetaDump"), 0, "Dump MD in 4 functions (?)", CLRConfig::REGUTIL_default) -// MetaData - Desktop-only -CONFIG_DWORD_INFO_EX(INTERNAL_MD_WinMD_Disable, W("MD_WinMD_Disable"), 0, "Never activate the WinMD import adapter", CLRConfig::REGUTIL_default) -CONFIG_DWORD_INFO_EX(INTERNAL_MD_WinMD_AssertOnIllegalUsage, W("MD_WinMD_AssertOnIllegalUsage"), 0, "ASSERT if a WinMD import adapter detects a tool incompatibility", CLRConfig::REGUTIL_default) - -// Metadata - mscordbi only - this flag is only intended to mitigate potential issues in bug fix 458597. -RETAIL_CONFIG_DWORD_INFO_EX(EXTERNAL_MD_PreserveDebuggerMetadataMemory, W("MD_PreserveDebuggerMetadataMemory"), 0, "Save all versions of metadata memory in the debugger when debuggee metadata is updated", CLRConfig::REGUTIL_default) - -/// -/// Spinning heuristics -/// -// Note that these only take effect once the runtime has been started; prior to that the values hardcoded in g_SpinConstants (vars.cpp) are used -RETAIL_CONFIG_DWORD_INFO_EX(EXTERNAL_SpinInitialDuration, W("SpinInitialDuration"), 0x32, "Hex value specifying the first spin duration", EEConfig_default) -RETAIL_CONFIG_DWORD_INFO_EX(EXTERNAL_SpinBackoffFactor, W("SpinBackoffFactor"), 0x3, "Hex value specifying the growth of each successive spin duration", EEConfig_default) -RETAIL_CONFIG_DWORD_INFO_EX(EXTERNAL_SpinLimitProcCap, W("SpinLimitProcCap"), 0xFFFFFFFF, "Hex value specifying the largest value of NumProcs to use when calculating the maximum spin duration", EEConfig_default) -RETAIL_CONFIG_DWORD_INFO_EX(EXTERNAL_SpinLimitProcFactor, W("SpinLimitProcFactor"), 0x4E20, "Hex value specifying the multiplier on NumProcs to use when calculating the maximum spin duration", EEConfig_default) -RETAIL_CONFIG_DWORD_INFO_EX(EXTERNAL_SpinLimitConstant, W("SpinLimitConstant"), 0x0, "Hex value specifying the constant to add when calculating the maximum spin duration", EEConfig_default) -RETAIL_CONFIG_DWORD_INFO_EX(EXTERNAL_SpinRetryCount, W("SpinRetryCount"), 0xA, "Hex value specifying the number of times the entire spin process is repeated (when applicable)", EEConfig_default) -RETAIL_CONFIG_DWORD_INFO_EX(INTERNAL_Monitor_SpinCount, W("Monitor_SpinCount"), 0x1e, "Hex value specifying the maximum number of spin iterations Monitor may perform upon contention on acquiring the lock before waiting.", EEConfig_default) - -/// -/// Native Binder -/// - -CONFIG_DWORD_INFO(INTERNAL_NgenBind_ZapForbid, W("NgenBind_ZapForbid"), 0, "Assert if an assembly succeeds in binding to a native image") -CONFIG_STRING_INFO(INTERNAL_NgenBind_ZapForbidExcludeList, W("NgenBind_ZapForbidExcludeList"), "") -CONFIG_STRING_INFO(INTERNAL_NgenBind_ZapForbidList, W("NgenBind_ZapForbidList"), "") - -CONFIG_DWORD_INFO_EX(INTERNAL_SymDiffDump, W("SymDiffDump"), 0, "Used to create the map file while binding the assembly. Used by SemanticDiffer", CLRConfig::REGUTIL_default) - -/// -/// NGEN -/// -RETAIL_CONFIG_STRING_INFO_EX(EXTERNAL_NGen_JitName, W("NGen_JitName"), "", CLRConfig::REGUTIL_default) -RETAIL_CONFIG_DWORD_INFO_EX(UNSUPPORTED_NGenFramed, W("NGenFramed"), -1, "Same as JitFramed, but for ngen", CLRConfig::REGUTIL_default) -CONFIG_DWORD_INFO_EX(INTERNAL_NGenOnlyOneMethod, W("NGenOnlyOneMethod"), 0, "", CLRConfig::REGUTIL_default) -CONFIG_DWORD_INFO_EX(INTERNAL_NgenOrder, W("NgenOrder"), 0, "", CLRConfig::REGUTIL_default) -CONFIG_DWORD_INFO_EX(INTERNAL_partialNGenStress, W("partialNGenStress"), 0, "", CLRConfig::REGUTIL_default) -CONFIG_DWORD_INFO_EX(INTERNAL_ZapDoNothing, W("ZapDoNothing"), 0, "", CLRConfig::REGUTIL_default) -RETAIL_CONFIG_DWORD_INFO_DIRECT_ACCESS(EXTERNAL_HardPrejitEnabled, W("HardPrejitEnabled"), "") -RETAIL_CONFIG_DWORD_INFO_EX(INTERNAL_EnableHardbinding, W("EnableHardbinding"), 0, "Enables the use of hardbinding", CLRConfig::REGUTIL_default) -CONFIG_DWORD_INFO_EX(INTERNAL_NgenForceFailureMask, W("NgenForceFailureMask"), -1, "Bitmask used to control which locations will check and raise the failure (defaults to bits: -1)", CLRConfig::REGUTIL_default) -CONFIG_DWORD_INFO_EX(INTERNAL_NgenForceFailureCount, W("NgenForceFailureCount"), 0, "If set to >0 and we have IBC data we will force a failure after we reference an IBC data item times", CLRConfig::REGUTIL_default) -CONFIG_DWORD_INFO_EX(INTERNAL_NgenForceFailureKind, W("NgenForceFailureKind"), 1, "If set to 1, We will throw a TypeLoad exception; If set to 2, We will cause an A/V", CLRConfig::REGUTIL_default) -RETAIL_CONFIG_DWORD_INFO(UNSUPPORTED_NGenEnableCreatePdb, W("NGenEnableCreatePdb"), 0, "If set to >0 ngen.exe displays help on, recognizes createpdb in the command line") -RETAIL_CONFIG_DWORD_INFO(INTERNAL_NGenSimulateDiskFull, W("NGenSimulateDiskFull"), 0, "If set to 1, ngen will throw a Disk full exception in ZapWriter.cpp:Save()") -RETAIL_CONFIG_DWORD_INFO(INTERNAL_PartialNGen, W("PartialNGen"), -1, "Generate partial NGen images") -RETAIL_CONFIG_DWORD_INFO(INTERNAL_NgenAllowMscorlibSoftbind, W("NgenAllowMscorlibSoftbind"), 0, "Disable forced hard-binding to mscorlib") - -CONFIG_DWORD_INFO(INTERNAL_NoASLRForNgen, W("NoASLRForNgen"), 0, "Turn off IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE bit in generated ngen images. Makes nidump output repeatable from run to run.") - -#ifdef CROSSGEN_COMPILE -RETAIL_CONFIG_DWORD_INFO(INTERNAL_CrossGenAssumeInputSigned, W("CrossGenAssumeInputSigned"), 1, "CrossGen should assume that its input assemblies will be signed before deployment") -#endif - -/// -/// Performance -/// -RETAIL_CONFIG_STRING_INFO(EXTERNAL_PerformanceScenario, W("performanceScenario"), "Activates a set of workload-specific default values for performance settings") - -/// -/// Profiling API / ETW -/// -RETAIL_CONFIG_DWORD_INFO_EX(EXTERNAL_COR_ENABLE_PROFILING, W("COR_ENABLE_PROFILING"), 0, "Flag to indicate whether profiling should be enabled for the currently running process.", CLRConfig::DontPrependCOMPlus_ | CLRConfig::IgnoreConfigFiles) -RETAIL_CONFIG_STRING_INFO_EX(EXTERNAL_COR_PROFILER, W("COR_PROFILER"), "Specifies GUID of profiler to load into currently running process", CLRConfig::DontPrependCOMPlus_) -RETAIL_CONFIG_STRING_INFO_EX(EXTERNAL_COR_PROFILER_PATH, W("COR_PROFILER_PATH"), "Specifies the path to the DLL of profiler to load into currently running process", CLRConfig::DontPrependCOMPlus_) -RETAIL_CONFIG_STRING_INFO_EX(EXTERNAL_COR_PROFILER_PATH_32, W("COR_PROFILER_PATH_32"), "Specifies the path to the DLL of profiler to load into currently running 32 bits process", CLRConfig::DontPrependCOMPlus_) -RETAIL_CONFIG_STRING_INFO_EX(EXTERNAL_COR_PROFILER_PATH_64, W("COR_PROFILER_PATH_64"), "Specifies the path to the DLL of profiler to load into currently running 64 bits process", CLRConfig::DontPrependCOMPlus_) -RETAIL_CONFIG_DWORD_INFO_EX(EXTERNAL_CORECLR_ENABLE_PROFILING, W("CORECLR_ENABLE_PROFILING"), 0, "CoreCLR only: Flag to indicate whether profiling should be enabled for the currently running process.", CLRConfig::DontPrependCOMPlus_ | CLRConfig::IgnoreConfigFiles) -RETAIL_CONFIG_STRING_INFO_EX(EXTERNAL_CORECLR_PROFILER, W("CORECLR_PROFILER"), "CoreCLR only: Specifies GUID of profiler to load into currently running process", CLRConfig::DontPrependCOMPlus_) -RETAIL_CONFIG_STRING_INFO_EX(EXTERNAL_CORECLR_PROFILER_PATH, W("CORECLR_PROFILER_PATH"), "CoreCLR only: Specifies the path to the DLL of profiler to load into currently running process", CLRConfig::DontPrependCOMPlus_) -RETAIL_CONFIG_STRING_INFO_EX(EXTERNAL_CORECLR_PROFILER_PATH_32, W("CORECLR_PROFILER_PATH_32"), "CoreCLR only: Specifies the path to the DLL of profiler to load into currently running 32 process", CLRConfig::DontPrependCOMPlus_) -RETAIL_CONFIG_STRING_INFO_EX(EXTERNAL_CORECLR_PROFILER_PATH_64, W("CORECLR_PROFILER_PATH_64"), "CoreCLR only: Specifies the path to the DLL of profiler to load into currently running 64 process", CLRConfig::DontPrependCOMPlus_) -RETAIL_CONFIG_STRING_INFO_EX(EXTERNAL_ProfAPI_ProfilerCompatibilitySetting, W("ProfAPI_ProfilerCompatibilitySetting"), "Specifies the profiler loading policy (the default is not to load a V2 profiler in V4)", CLRConfig::REGUTIL_default | CLRConfig::TrimWhiteSpaceFromStringValue) -RETAIL_CONFIG_DWORD_INFO_DIRECT_ACCESS(EXTERNAL_AttachThreadAlwaysOn, W("AttachThreadAlwaysOn"), "Forces profapi attach thread to be created on startup, instead of on-demand.") -RETAIL_CONFIG_DWORD_INFO(EXTERNAL_MsBetweenAttachCheck, W("MsBetweenAttachCheck"), 500, "") -RETAIL_CONFIG_DWORD_INFO(EXTERNAL_ProfAPIMaxWaitForTriggerMs, W("ProfAPIMaxWaitForTriggerMs"), 5*60*1000, "Timeout in ms for profilee to wait for each blocking operation performed by trigger app.") -RETAIL_CONFIG_DWORD_INFO(EXTERNAL_ProfAPI_DetachMinSleepMs, W("ProfAPI_DetachMinSleepMs"), 0, "The minimum time, in milliseconds, the CLR will wait before checking whether a profiler that is in the process of detaching is ready to be unloaded.") -RETAIL_CONFIG_DWORD_INFO(EXTERNAL_ProfAPI_DetachMaxSleepMs, W("ProfAPI_DetachMaxSleepMs"), 0, "The maximum time, in milliseconds, the CLR will wait before checking whether a profiler that is in the process of detaching is ready to be unloaded.") -CONFIG_DWORD_INFO(INTERNAL_ProfAPI_EnableRejitDiagnostics, W("ProfAPI_EnableRejitDiagnostics"), 0, "Enable extra dumping to stdout of rejit structures") -RETAIL_CONFIG_DWORD_INFO(EXTERNAL_ProfAPI_AttachProfilerMinTimeoutInMs, W("ProfAPI_AttachProfilerMinTimeoutInMs"), 10*1000, "Timeout in ms for the minimum time out value of AttachProfiler") -CONFIG_DWORD_INFO(INTERNAL_ProfAPIFault, W("ProfAPIFault"), 0, "Test-only bitmask to inject various types of faults in the profapi code") -CONFIG_DWORD_INFO(INTERNAL_TestOnlyAllowedEventMask, W("TestOnlyAllowedEventMask"), 0, "Test-only bitmask to allow profiler tests to override CLR enforcement of COR_PRF_ALLOWABLE_AFTER_ATTACH and COR_PRF_MONITOR_IMMUTABLE") -CONFIG_DWORD_INFO(INTERNAL_TestOnlyEnableICorProfilerInfo, W("ProfAPI_TestOnlyEnableICorProfilerInfo"), 0, "Test-only flag to allow attaching profiler tests to call ICorProfilerInfo interface, which would otherwise be disallowed for attaching profilers") -CONFIG_DWORD_INFO(INTERNAL_TestOnlyEnableObjectAllocatedHook, W("TestOnlyEnableObjectAllocatedHook"), 0, "Test-only flag that forces CLR to initialize on startup as if ObjectAllocated callback were requested, to enable post-attach ObjectAllocated functionality.") -CONFIG_DWORD_INFO(INTERNAL_TestOnlyEnableSlowELTHooks, W("TestOnlyEnableSlowELTHooks"), 0, "Test-only flag that forces CLR to initialize on startup as if slow-ELT were requested, to enable post-attach ELT functionality.") - -RETAIL_CONFIG_DWORD_INFO_EX(EXTERNAL_PreVistaETWEnabled, W("ETWEnabled"), 0, "This flag is used on OSes < Vista to enable/disable ETW. It is disabled by default", CLRConfig::REGUTIL_default) -RETAIL_CONFIG_DWORD_INFO_EX(EXTERNAL_VistaAndAboveETWEnabled, W("ETWEnabled"), 1, "This flag is used on OSes >= Vista to enable/disable ETW. It is enabled by default", CLRConfig::REGUTIL_default) -RETAIL_CONFIG_STRING_INFO_EX(UNSUPPORTED_ETW_ObjectAllocationEventsPerTypePerSec, W("ETW_ObjectAllocationEventsPerTypePerSec"), "Desired number of GCSampledObjectAllocation ETW events to be logged per type per second. If 0, then the default built in to the implementation for the enabled event (e.g., High, Low), will be used.", CLRConfig::REGUTIL_default) -RETAIL_CONFIG_DWORD_INFO(UNSUPPORTED_ProfAPI_ValidateNGENInstrumentation, W("ProfAPI_ValidateNGENInstrumentation"), 0, "This flag enables additional validations when using the IMetaDataEmit APIs for NGEN'ed images to ensure only supported edits are made.") - -#ifdef FEATURE_PERFMAP -RETAIL_CONFIG_DWORD_INFO_EX(EXTERNAL_PerfMapEnabled, W("PerfMapEnabled"), 0, "This flag is used on Linux to enable writing /tmp/perf-$pid.map. It is disabled by default", CLRConfig::REGUTIL_default) -RETAIL_CONFIG_DWORD_INFO_EX(EXTERNAL_PerfMapIgnoreSignal, W("PerfMapIgnoreSignal"), 0, "When perf map is enabled, this option will configure the specified signal to be accepted and ignored as a marker in the perf logs. It is disabled by default", CLRConfig::REGUTIL_default) -#endif - -RETAIL_CONFIG_STRING_INFO(EXTERNAL_StartupDelayMS, W("StartupDelayMS"), "") - -/// -/// Stress -/// -CONFIG_DWORD_INFO_EX(INTERNAL_StressCOMCall, W("StressCOMCall"), 0, "", CLRConfig::REGUTIL_default) -RETAIL_CONFIG_DWORD_INFO_DIRECT_ACCESS(UNSUPPORTED_StressLog, W("StressLog"), "Turns on the stress log.") -RETAIL_CONFIG_DWORD_INFO_DIRECT_ACCESS(UNSUPPORTED_ForceEnc, W("ForceEnc"), "Forces Edit and Continue to be on for all eligible modules.") -RETAIL_CONFIG_DWORD_INFO_DIRECT_ACCESS(UNSUPPORTED_StressLogSize, W("StressLogSize"), "Stress log size in bytes per thread.") -CONFIG_DWORD_INFO_DIRECT_ACCESS(INTERNAL_StressOn, W("StressOn"), "Enables the STRESS_ASSERT macro that stops runtime quickly (to prevent the clr state from changing significantly before breaking)") -CONFIG_DWORD_INFO_EX(INTERNAL_stressSynchronized, W("stressSynchronized"), 0, "Unknown if or where this is used; unless a test is specifically depending on this, it can be removed.", CLRConfig::REGUTIL_default) -RETAIL_CONFIG_DWORD_INFO_DIRECT_ACCESS(EXTERNAL_StressThreadCount, W("StressThreadCount"), "") - -/// -/// Thread Suspend -/// -CONFIG_DWORD_INFO(INTERNAL_DiagnosticSuspend, W("DiagnosticSuspend"), 0, "") -CONFIG_DWORD_INFO(INTERNAL_SuspendDeadlockTimeout, W("SuspendDeadlockTimeout"), 40000, "") -CONFIG_DWORD_INFO(INTERNAL_SuspendThreadDeadlockTimeoutMs, W("SuspendThreadDeadlockTimeoutMs"), 2000, "") -RETAIL_CONFIG_DWORD_INFO(INTERNAL_ThreadSuspendInjection, W("INTERNAL_ThreadSuspendInjection"), 1, "Specifies whether to inject activations for thread suspension on Unix") - -/// -/// Thread (miscellaneous) -/// -RETAIL_CONFIG_DWORD_INFO(INTERNAL_Thread_DeadThreadCountThresholdForGCTrigger, W("Thread_DeadThreadCountThresholdForGCTrigger"), 75, "In the heuristics to clean up dead threads, this threshold must be reached before triggering a GC will be considered. Set to 0 to disable triggering a GC based on dead threads.") -RETAIL_CONFIG_DWORD_INFO(INTERNAL_Thread_DeadThreadGCTriggerPeriodMilliseconds, W("Thread_DeadThreadGCTriggerPeriodMilliseconds"), 1000 * 60 * 30, "In the heuristics to clean up dead threads, this much time must have elapsed since the previous max-generation GC before triggering another GC will be considered") - -/// -/// Threadpool -/// -RETAIL_CONFIG_DWORD_INFO(INTERNAL_ThreadPool_ForceMinWorkerThreads, W("ThreadPool_ForceMinWorkerThreads"), 0, "Overrides the MinThreads setting for the ThreadPool worker pool") -RETAIL_CONFIG_DWORD_INFO(INTERNAL_ThreadPool_ForceMaxWorkerThreads, W("ThreadPool_ForceMaxWorkerThreads"), 0, "Overrides the MaxThreads setting for the ThreadPool worker pool") -RETAIL_CONFIG_DWORD_INFO(INTERNAL_ThreadPool_DisableStarvationDetection, W("ThreadPool_DisableStarvationDetection"), 0, "Disables the ThreadPool feature that forces new threads to be added when workitems run for too long") -RETAIL_CONFIG_DWORD_INFO(INTERNAL_ThreadPool_DebugBreakOnWorkerStarvation, W("ThreadPool_DebugBreakOnWorkerStarvation"), 0, "Breaks into the debugger if the ThreadPool detects work queue starvation") -RETAIL_CONFIG_DWORD_INFO(INTERNAL_ThreadPool_EnableWorkerTracking, W("ThreadPool_EnableWorkerTracking"), 0, "Enables extra expensive tracking of how many workers threads are working simultaneously") -#ifdef _TARGET_ARM64_ -// Spinning scheme is currently different on ARM64, see CLRLifoSemaphore::Wait(DWORD, UINT32, UINT32) -RETAIL_CONFIG_DWORD_INFO(INTERNAL_ThreadPool_UnfairSemaphoreSpinLimit, W("ThreadPool_UnfairSemaphoreSpinLimit"), 0x32, "Maximum number of spins per processor a thread pool worker thread performs before waiting for work") -#else // !_TARGET_ARM64_ -RETAIL_CONFIG_DWORD_INFO(INTERNAL_ThreadPool_UnfairSemaphoreSpinLimit, W("ThreadPool_UnfairSemaphoreSpinLimit"), 0x46, "Maximum number of spins a thread pool worker thread performs before waiting for work") -#endif // _TARGET_ARM64_ -RETAIL_CONFIG_DWORD_INFO(EXTERNAL_Thread_UseAllCpuGroups, W("Thread_UseAllCpuGroups"), 0, "Specifies if to automatically distribute thread across CPU Groups") - -CONFIG_DWORD_INFO(INTERNAL_ThreadpoolTickCountAdjustment, W("ThreadpoolTickCountAdjustment"), 0, "") - -RETAIL_CONFIG_DWORD_INFO(INTERNAL_HillClimbing_Disable, W("HillClimbing_Disable"), 0, "Disables hill climbing for thread adjustments in the thread pool"); -RETAIL_CONFIG_DWORD_INFO(INTERNAL_HillClimbing_WavePeriod, W("HillClimbing_WavePeriod"), 4, ""); -RETAIL_CONFIG_DWORD_INFO(INTERNAL_HillClimbing_TargetSignalToNoiseRatio, W("HillClimbing_TargetSignalToNoiseRatio"), 300, ""); -RETAIL_CONFIG_DWORD_INFO(INTERNAL_HillClimbing_ErrorSmoothingFactor, W("HillClimbing_ErrorSmoothingFactor"), 1, ""); -RETAIL_CONFIG_DWORD_INFO(INTERNAL_HillClimbing_WaveMagnitudeMultiplier, W("HillClimbing_WaveMagnitudeMultiplier"), 100, ""); -RETAIL_CONFIG_DWORD_INFO(INTERNAL_HillClimbing_MaxWaveMagnitude, W("HillClimbing_MaxWaveMagnitude"), 20, ""); -RETAIL_CONFIG_DWORD_INFO(INTERNAL_HillClimbing_WaveHistorySize, W("HillClimbing_WaveHistorySize"), 8, ""); -RETAIL_CONFIG_DWORD_INFO(INTERNAL_HillClimbing_Bias, W("HillClimbing_Bias"), 15, "The 'cost' of a thread. 0 means drive for increased throughput regardless of thread count; higher values bias more against higher thread counts."); -RETAIL_CONFIG_DWORD_INFO(INTERNAL_HillClimbing_MaxChangePerSecond, W("HillClimbing_MaxChangePerSecond"), 4, ""); -RETAIL_CONFIG_DWORD_INFO(INTERNAL_HillClimbing_MaxChangePerSample, W("HillClimbing_MaxChangePerSample"), 20, ""); -RETAIL_CONFIG_DWORD_INFO(INTERNAL_HillClimbing_MaxSampleErrorPercent, W("HillClimbing_MaxSampleErrorPercent"), 15, ""); -RETAIL_CONFIG_DWORD_INFO(INTERNAL_HillClimbing_SampleIntervalLow, W("HillClimbing_SampleIntervalLow"), 10, ""); -RETAIL_CONFIG_DWORD_INFO(INTERNAL_HillClimbing_SampleIntervalHigh, W("HillClimbing_SampleIntervalHigh"), 200, ""); -RETAIL_CONFIG_DWORD_INFO(INTERNAL_HillClimbing_GainExponent, W("HillClimbing_GainExponent"), 200, "The exponent to apply to the gain, times 100. 100 means to use linear gain, higher values will enhance large moves and damp small ones."); - - -/// -/// Tiered Compilation -/// -#ifdef FEATURE_TIERED_COMPILATION -RETAIL_CONFIG_DWORD_INFO(EXTERNAL_TieredCompilation, W("TieredCompilation"), 0, "Enables tiered compilation") -RETAIL_CONFIG_DWORD_INFO(UNSUPPORTED_LEGACY_TieredCompilation, W("EXPERIMENTAL_TieredCompilation"), 0, "Deprecated - Use COMPLUS_TieredCompilation") -RETAIL_CONFIG_DWORD_INFO(UNSUPPORTED_TieredCompilation_Tier1CallCountThreshold, W("TieredCompilation_Tier1CallCountThreshold"), 30, "Number of times a method must be called after which it is promoted to tier 1.") -RETAIL_CONFIG_DWORD_INFO(UNSUPPORTED_TieredCompilation_Tier1CallCountingDelayMs, W("TieredCompilation_Tier1CallCountingDelayMs"), 100, "Delay in milliseconds since process startup or the last tier 0 JIT before call counting begins for tier 1 promotion.") - -RETAIL_CONFIG_DWORD_INFO(UNSUPPORTED_TieredCompilation_Test_CallCounting, W("TieredCompilation_Test_CallCounting"), 1, "Enabled by default (only activates when TieredCompilation is also enabled). If disabled immediately backpatches prestub, and likely prevents any tier1 promotion") -RETAIL_CONFIG_DWORD_INFO(UNSUPPORTED_TieredCompilation_Test_OptimizeTier0, W("TieredCompilation_Test_OptimizeTier0"), 0, "Use optimized codegen (normally used by tier1) in tier0") -#endif - - -/// -/// TypeLoader -/// -CONFIG_DWORD_INFO(INTERNAL_TypeLoader_InjectInterfaceDuplicates, W("INTERNAL_TypeLoader_InjectInterfaceDuplicates"), 0, "Injects duplicates in interface map for all types.") - -/// -/// Virtual call stubs -/// -CONFIG_DWORD_INFO_EX(INTERNAL_VirtualCallStubCollideMonoPct, W("VirtualCallStubCollideMonoPct"), 0, "Used only when STUB_LOGGING is defined, which by default is not.", CLRConfig::REGUTIL_default) -CONFIG_DWORD_INFO_EX(INTERNAL_VirtualCallStubCollideWritePct, W("VirtualCallStubCollideWritePct"), 100, "Used only when STUB_LOGGING is defined, which by default is not.", CLRConfig::REGUTIL_default) -CONFIG_DWORD_INFO_EX(INTERNAL_VirtualCallStubDumpLogCounter, W("VirtualCallStubDumpLogCounter"), 0, "Used only when STUB_LOGGING is defined, which by default is not.", CLRConfig::REGUTIL_default) -CONFIG_DWORD_INFO_EX(INTERNAL_VirtualCallStubDumpLogIncr, W("VirtualCallStubDumpLogIncr"), 0, "Used only when STUB_LOGGING is defined, which by default is not.", CLRConfig::REGUTIL_default) -RETAIL_CONFIG_DWORD_INFO_EX(EXTERNAL_VirtualCallStubLogging, W("VirtualCallStubLogging"), 0, "Worth keeping, but should be moved into \"#ifdef STUB_LOGGING\" blocks. This goes for most (or all) of the stub logging infrastructure.", CLRConfig::REGUTIL_default) -CONFIG_DWORD_INFO_EX(INTERNAL_VirtualCallStubMissCount, W("VirtualCallStubMissCount"), 100, "Used only when STUB_LOGGING is defined, which by default is not.", CLRConfig::REGUTIL_default) -CONFIG_DWORD_INFO_EX(INTERNAL_VirtualCallStubResetCacheCounter, W("VirtualCallStubResetCacheCounter"), 0, "Used only when STUB_LOGGING is defined, which by default is not.", CLRConfig::REGUTIL_default) -CONFIG_DWORD_INFO_EX(INTERNAL_VirtualCallStubResetCacheIncr, W("VirtualCallStubResetCacheIncr"), 0, "Used only when STUB_LOGGING is defined, which by default is not.", CLRConfig::REGUTIL_default) - -/// -/// Watson -/// -RETAIL_CONFIG_DWORD_INFO(INTERNAL_DisableWatsonForManagedExceptions, W("DisableWatsonForManagedExceptions"), 0, "Disable Watson and debugger launching for managed exceptions") - -/// -/// Zap -/// -RETAIL_CONFIG_STRING_INFO_EX(INTERNAL_ZapBBInstr, W("ZapBBInstr"), "", CLRConfig::REGUTIL_default) -RETAIL_CONFIG_STRING_INFO(EXTERNAL_ZapBBInstrDir, W("ZapBBInstrDir"), "") -RETAIL_CONFIG_DWORD_INFO(EXTERNAL_ZapDisable, W("ZapDisable"), 0, "") -CONFIG_STRING_INFO_EX(INTERNAL_ZapExclude, W("ZapExclude"), "", CLRConfig::REGUTIL_default) -CONFIG_STRING_INFO_EX(INTERNAL_ZapOnly, W("ZapOnly"), "", CLRConfig::REGUTIL_default) -RETAIL_CONFIG_DWORD_INFO_DIRECT_ACCESS(EXTERNAL_ZapRequire, W("ZapRequire"), "") -RETAIL_CONFIG_STRING_INFO(EXTERNAL_ZapRequireExcludeList, W("ZapRequireExcludeList"), "") -RETAIL_CONFIG_STRING_INFO(EXTERNAL_ZapRequireList, W("ZapRequireList"), "") -RETAIL_CONFIG_STRING_INFO_EX(EXTERNAL_ZapSet, W("ZapSet"), "", CLRConfig::REGUTIL_default) - -#ifdef FEATURE_LAZY_COW_PAGES - -#ifdef FEATURE_WINDOWSPHONE -RETAIL_CONFIG_DWORD_INFO(INTERNAL_ZapLazyCOWPagesEnabled, W("ZapLazyCOWPagesEnabled"), 1, ""); -#else //FEATURE_WINDOWSPHONE -RETAIL_CONFIG_DWORD_INFO(INTERNAL_ZapLazyCOWPagesEnabled, W("ZapLazyCOWPagesEnabled"), 0, ""); -#endif //FEATURE_WINDOWSPHONE - -CONFIG_DWORD_INFO(INTERNAL_DebugAssertOnMissedCOWPage, W("DebugAssertOnMissedCOWPage"), 1, ""); - -#endif //FEATURE_LAZY_COW_PAGES - -RETAIL_CONFIG_DWORD_INFO(EXTERNAL_ReadyToRun, W("ReadyToRun"), 1, "Enable/disable use of ReadyToRun native code") // On by default for CoreCLR -RETAIL_CONFIG_STRING_INFO(EXTERNAL_ReadyToRunExcludeList, W("ReadyToRunExcludeList"), "List of assemblies that cannot use Ready to Run images") -RETAIL_CONFIG_STRING_INFO(EXTERNAL_ReadyToRunLogFile, W("ReadyToRunLogFile"), "Name of file to log success/failure of using Ready to Run images") - -#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 -RETAIL_CONFIG_STRING_INFO(INTERNAL_EventSourceFilter, W("EventSourceFilter"), "") -RETAIL_CONFIG_STRING_INFO(INTERNAL_EventNameFilter, W("EventNameFilter"), "") -#endif //defined(FEATURE_EVENT_TRACE) || defined(FEATURE_EVENTSOURCE_XPLAT) - -/// -/// Interop -/// -CONFIG_DWORD_INFO_DIRECT_ACCESS(INTERNAL_ExposeExceptionsInCOM, W("ExposeExceptionsInCOM"), "") -RETAIL_CONFIG_DWORD_INFO(EXTERNAL_ComInsteadOfManagedRemoting, W("PreferComInsteadOfManagedRemoting"), 0, "When communicating with a cross app domain CCW, use COM instead of managed remoting.") -CONFIG_DWORD_INFO(INTERNAL_GenerateStubForHost, W("GenerateStubForHost"), 0, "Forces the host hook stub to be built for all unmanaged calls, even when not running hosted.") -RETAIL_CONFIG_DWORD_INFO_DIRECT_ACCESS(EXTERNAL_legacyComHierarchyVisibility, W("legacyComHierarchyVisibility"), "") -RETAIL_CONFIG_DWORD_INFO_DIRECT_ACCESS(EXTERNAL_legacyComVTableLayout, W("legacyComVTableLayout"), "") -RETAIL_CONFIG_DWORD_INFO_DIRECT_ACCESS(EXTERNAL_newComVTableLayout, W("newComVTableLayout"), "") -RETAIL_CONFIG_STRING_INFO_EX(EXTERNAL_PInvokeInline, W("PInvokeInline"), "", CLRConfig::REGUTIL_default) -RETAIL_CONFIG_DWORD_INFO(UNSUPPORTED_InteropValidatePinnedObjects, W("InteropValidatePinnedObjects"), 0, "After returning from a managed-to-unmanaged interop call, validate GC heap around objects pinned by IL stubs.") -RETAIL_CONFIG_DWORD_INFO(EXTERNAL_InteropLogArguments, W("InteropLogArguments"), 0, "Log all pinned arguments passed to an interop call") -RETAIL_CONFIG_STRING_INFO(UNSUPPORTED_LogCCWRefCountChange, W("LogCCWRefCountChange"), "Outputs debug information and calls LogCCWRefCountChange_BREAKPOINT when AddRef or Release is called on a CCW.") -RETAIL_CONFIG_DWORD_INFO(INTERNAL_EnableRCWCleanupOnSTAShutdown, W("EnableRCWCleanupOnSTAShutdown"), 0, "Performs RCW cleanup when STA shutdown is detected using IInitializeSpy in classic processes.") -RETAIL_CONFIG_STRING_INFO(INTERNAL_LocalWinMDPath, W("LocalWinMDPath"), "Additional path to probe for WinMD files in if a WinRT type is not resolved using the standard paths.") -RETAIL_CONFIG_DWORD_INFO(EXTERNAL_AllowDComReflection, W("AllowDComReflection"), 0, "Allows out of process DCOM clients to marshal blocked reflection types.") - -// -// EventPipe -// -RETAIL_CONFIG_DWORD_INFO(INTERNAL_EnableEventPipe, W("EnableEventPipe"), 0, "Enable/disable event pipe. Non-zero values enable tracing.") -RETAIL_CONFIG_STRING_INFO(INTERNAL_EventPipeOutputFile, W("EventPipeOutputFile"), "The full path including file name for the trace file that will be written when COMPlus_EnableEventPipe&=1") -RETAIL_CONFIG_STRING_INFO(INTERNAL_EventPipeConfig, W("EventPipeConfig"), "Configuration for EventPipe.") -RETAIL_CONFIG_DWORD_INFO(INTERNAL_EventPipeRundown, W("EventPipeRundown"), 1, "Enable/disable eventpipe rundown.") - -#ifdef FEATURE_GDBJIT -/// -/// GDBJIT -/// -CONFIG_STRING_INFO(INTERNAL_GDBJitElfDump, W("GDBJitElfDump"), "Dump ELF for specified method") -#ifdef FEATURE_GDBJIT_FRAME -RETAIL_CONFIG_DWORD_INFO(INTERNAL_GDBJitEmitDebugFrame, W("GDBJitEmitDebugFrame"), TRUE, "Enable .debug_frame generation") -#endif -#endif - -/// -/// Uncategorized -/// -// -// Unknown -// -//--------------------------------------------------------------------------------------- -// ** -// PLEASE MOVE ANY CONFIG SWITCH YOU OWN OUT OF THIS SECTION INTO A CATEGORY ABOVE -// -// DO NOT ADD ANY MORE CONFIG SWITCHES TO THIS SECTION! -// ** -CONFIG_DWORD_INFO_EX(INTERNAL_ActivatePatchSkip, W("ActivatePatchSkip"), 0, "Allows an assert when ActivatePatchSkip is called", CLRConfig::REGUTIL_default) -CONFIG_DWORD_INFO_DIRECT_ACCESS(INTERNAL_AlwaysUseMetadataInterfaceMapLayout, W("AlwaysUseMetadataInterfaceMapLayout"), "Used for debugging generic interface map layout.") -CONFIG_DWORD_INFO(INTERNAL_AssertOnUnneededThis, W("AssertOnUnneededThis"), 0, "While the ConfigDWORD is unnecessary, the contained ASSERT should be kept. This may result in some work tracking down violating MethodDescCallSites.") -CONFIG_DWORD_INFO_EX(INTERNAL_AssertStacktrace, W("AssertStacktrace"), 1, "", CLRConfig::REGUTIL_default) -CONFIG_DWORD_INFO_EX(INTERNAL_clearNativeImageStress, W("clearNativeImageStress"), 0, "", CLRConfig::REGUTIL_default) -CONFIG_DWORD_INFO_DIRECT_ACCESS(INTERNAL_CPUFamily, W("CPUFamily"), "") -CONFIG_DWORD_INFO_DIRECT_ACCESS(INTERNAL_CPUFeatures, W("CPUFeatures"), "") -RETAIL_CONFIG_DWORD_INFO_EX(EXTERNAL_DisableConfigCache, W("DisableConfigCache"), 0, "Used to disable the \"probabilistic\" config cache, which walks through the appropriate config registry keys on init and probabilistically keeps track of which exist.", CLRConfig::REGUTIL_default) -RETAIL_CONFIG_DWORD_INFO_DIRECT_ACCESS(EXTERNAL_DisableStackwalkCache, W("DisableStackwalkCache"), "") -RETAIL_CONFIG_DWORD_INFO_DIRECT_ACCESS(UNSUPPORTED_DoubleArrayToLargeObjectHeap, W("DoubleArrayToLargeObjectHeap"), "Controls double[] placement") -CONFIG_DWORD_INFO(INTERNAL_DumpConfiguration, W("DumpConfiguration"), 0, "Dumps runtime properties of xml configuration files to the log.") -CONFIG_STRING_INFO(INTERNAL_DumpOnClassLoad, W("DumpOnClassLoad"), "Dumps information about loaded class to log.") -CONFIG_DWORD_INFO_DIRECT_ACCESS(INTERNAL_ExpandAllOnLoad, W("ExpandAllOnLoad"), "") -CONFIG_STRING_INFO_DIRECT_ACCESS(INTERNAL_ForcedRuntime, W("ForcedRuntime"), "Verify version of CLR loaded") -CONFIG_DWORD_INFO_EX(INTERNAL_ForceRelocs, W("ForceRelocs"), 0, "", CLRConfig::REGUTIL_default) -CONFIG_DWORD_INFO_DIRECT_ACCESS(INTERNAL_GenerateLongJumpDispatchStubRatio, W("GenerateLongJumpDispatchStubRatio"), "Useful for testing VSD on AMD64") -CONFIG_DWORD_INFO_EX(INTERNAL_HashStack, W("HashStack"), 0, "", CLRConfig::REGUTIL_default) -CONFIG_DWORD_INFO(INTERNAL_HostManagerConfig, W("HostManagerConfig"), (DWORD)-1, "") -CONFIG_DWORD_INFO(INTERNAL_HostTestADUnload, W("HostTestADUnload"), 0, "Allows setting Rude unload as default") -CONFIG_DWORD_INFO(INTERNAL_HostTestThreadAbort, W("HostTestThreadAbort"), 0, "") -RETAIL_CONFIG_DWORD_INFO_EX(UNSUPPORTED_IgnoreDllMainReturn, W("IgnoreDllMainReturn"), 0, "Don't check the return value of DllMain if this is set", CLRConfig::ConfigFile_ApplicationFirst) -CONFIG_STRING_INFO(INTERNAL_InvokeHalt, W("InvokeHalt"), "Throws an assert when the given method is invoked through reflection.") -RETAIL_CONFIG_DWORD_INFO_DIRECT_ACCESS(UNSUPPORTED_legacyNullReferenceExceptionPolicy, W("legacyNullReferenceExceptionPolicy"), "") -RETAIL_CONFIG_DWORD_INFO_DIRECT_ACCESS(UNSUPPORTED_legacyUnhandledExceptionPolicy, W("legacyUnhandledExceptionPolicy"), "") -CONFIG_DWORD_INFO_DIRECT_ACCESS(INTERNAL_MaxStackDepth, W("MaxStackDepth"), "") -CONFIG_DWORD_INFO_DIRECT_ACCESS(INTERNAL_MaxStubUnwindInfoSegmentSize, W("MaxStubUnwindInfoSegmentSize"), "") -CONFIG_DWORD_INFO_DIRECT_ACCESS(INTERNAL_MaxThreadRecord, W("MaxThreadRecord"), "") -CONFIG_DWORD_INFO(INTERNAL_MessageDebugOut, W("MessageDebugOut"), 0, "") -CONFIG_DWORD_INFO_EX(INTERNAL_MscorsnLogging, W("MscorsnLogging"), 0, "Enables strong name logging", CLRConfig::REGUTIL_default) -RETAIL_CONFIG_DWORD_INFO_EX(EXTERNAL_NativeImageRequire, W("NativeImageRequire"), 0, "", CLRConfig::REGUTIL_default) -CONFIG_DWORD_INFO_EX(INTERNAL_NestedEhOom, W("NestedEhOom"), 0, "", CLRConfig::REGUTIL_default) -RETAIL_CONFIG_DWORD_INFO_EX(EXTERNAL_NO_SO_NOT_MAINLINE, W("NO_SO_NOT_MAINLINE"), 0, "", CLRConfig::REGUTIL_default) -#define INTERNAL_NoGuiOnAssert_Default 1 -RETAIL_CONFIG_DWORD_INFO_EX(INTERNAL_NoGuiOnAssert, W("NoGuiOnAssert"), INTERNAL_NoGuiOnAssert_Default, "", CLRConfig::REGUTIL_default) -RETAIL_CONFIG_DWORD_INFO_EX(EXTERNAL_NoProcedureSplitting, W("NoProcedureSplitting"), 0, "", CLRConfig::REGUTIL_default) -CONFIG_DWORD_INFO_EX(INTERNAL_NoStringInterning, W("NoStringInterning"), 1, "Disallows string interning. I see no value in it anymore.", CLRConfig::REGUTIL_default) -RETAIL_CONFIG_DWORD_INFO_DIRECT_ACCESS(EXTERNAL_NotifyBadAppCfg, W("NotifyBadAppCfg"), "Whether to show a message box for bad application config file.") -CONFIG_DWORD_INFO_DIRECT_ACCESS(INTERNAL_PauseOnLoad, W("PauseOnLoad"), "Stops in SystemDomain::init. I think it can be removed.") -CONFIG_DWORD_INFO(INTERNAL_PerfAllocsSizeThreshold, W("PerfAllocsSizeThreshold"), 0x3FFFFFFF, "Log facility LF_GCALLOC logs object allocations. This flag controls which ones also log stacktraces. Predates ClrProfiler.") -CONFIG_DWORD_INFO(INTERNAL_PerfNumAllocsThreshold, W("PerfNumAllocsThreshold"), 0x3FFFFFFF, "Log facility LF_GCALLOC logs object allocations. This flag controls which ones also log stacktraces. Predates ClrProfiler.") -CONFIG_STRING_INFO(INTERNAL_PerfTypesToLog, W("PerfTypesToLog"), "Log facility LF_GCALLOC logs object allocations. This flag controls which ones also log stacktraces. Predates ClrProfiler.") -RETAIL_CONFIG_DWORD_INFO(EXTERNAL_Prepopulate1, W("Prepopulate1"), 1, "") -CONFIG_STRING_INFO(INTERNAL_PrestubGC, W("PrestubGC"), "") -CONFIG_STRING_INFO(INTERNAL_PrestubHalt, W("PrestubHalt"), "") -RETAIL_CONFIG_STRING_INFO(EXTERNAL_RestrictedGCStressExe, W("RestrictedGCStressExe"), "") -CONFIG_DWORD_INFO_EX(INTERNAL_ReturnSourceTypeForTesting, W("ReturnSourceTypeForTesting"), 0, "Allows returning the (internal only) source type of an IL to Native mapping for debugging purposes", CLRConfig::REGUTIL_default) -RETAIL_CONFIG_DWORD_INFO_EX(UNSUPPORTED_RSStressLog, W("RSStressLog"), 0, "Allows turning on logging for RS startup", CLRConfig::REGUTIL_default) -CONFIG_DWORD_INFO_DIRECT_ACCESS(INTERNAL_SaveThreadInfo, W("SaveThreadInfo"), "") -CONFIG_DWORD_INFO_DIRECT_ACCESS(INTERNAL_SaveThreadInfoMask, W("SaveThreadInfoMask"), "") -CONFIG_DWORD_INFO(INTERNAL_SBDumpOnNewIndex, W("SBDumpOnNewIndex"), 0, "Used for Syncblock debugging. It's been a while since any of those have been used.") -CONFIG_DWORD_INFO(INTERNAL_SBDumpOnResize, W("SBDumpOnResize"), 0, "Used for Syncblock debugging. It's been a while since any of those have been used.") -CONFIG_DWORD_INFO(INTERNAL_SBDumpStyle, W("SBDumpStyle"), 0, "Used for Syncblock debugging. It's been a while since any of those have been used.") -RETAIL_CONFIG_STRING_INFO_DIRECT_ACCESS(UNSUPPORTED_ShimDatabaseVersion, W("ShimDatabaseVersion"), "Force using shim database version in registry") -RETAIL_CONFIG_DWORD_INFO(UNSUPPORTED_SleepOnExit, W("SleepOnExit"), 0, "Used for lrak detection. I'd say deprecated by umdh.") -CONFIG_DWORD_INFO_DIRECT_ACCESS(INTERNAL_StubLinkerUnwindInfoVerificationOn, W("StubLinkerUnwindInfoVerificationOn"), "") -RETAIL_CONFIG_DWORD_INFO_EX(UNSUPPORTED_SuccessExit, W("SuccessExit"), 0, "", CLRConfig::REGUTIL_default) -CONFIG_DWORD_INFO(INTERNAL_SupressAllowUntrustedCallerChecks, W("SupressAllowUntrustedCallerChecks"), 0, "Disable APTCA") -RETAIL_CONFIG_DWORD_INFO_DIRECT_ACCESS(EXTERNAL_SymbolReadingPolicy, W("SymbolReadingPolicy"), "Specifies when PDBs may be read") -RETAIL_CONFIG_DWORD_INFO(UNSUPPORTED_TestDataConsistency, W("TestDataConsistency"), FALSE, "Allows ensuring the left side is not holding locks (and may thus be in an inconsistent state) when inspection occurs") -RETAIL_CONFIG_DWORD_INFO_EX(EXTERNAL_ThreadGuardPages, W("ThreadGuardPages"), 0, "", CLRConfig::REGUTIL_default) -RETAIL_CONFIG_DWORD_INFO_EX(EXTERNAL_Timeline, W("Timeline"), 0, "", CLRConfig::REGUTIL_default) -RETAIL_CONFIG_DWORD_INFO_DIRECT_ACCESS(UNSUPPORTED_TotalStressLogSize, W("TotalStressLogSize"), "Total stress log size in bytes.") - -#ifdef _DEBUG -RETAIL_CONFIG_DWORD_INFO_DIRECT_ACCESS(EXTERNAL_TraceIUnknown, W("TraceIUnknown"), "") -RETAIL_CONFIG_DWORD_INFO_DIRECT_ACCESS(EXTERNAL_TraceWrap, W("TraceWrap"), "") -#endif - -RETAIL_CONFIG_DWORD_INFO_DIRECT_ACCESS(EXTERNAL_TURNOFFDEBUGINFO, W("TURNOFFDEBUGINFO"), "") -RETAIL_CONFIG_DWORD_INFO(EXTERNAL_UseMethodDataCache, W("UseMethodDataCache"), FALSE, "Used during feature development; may now be removed.") -RETAIL_CONFIG_DWORD_INFO(EXTERNAL_UseParentMethodData, W("UseParentMethodData"), TRUE, "Used during feature development; may now be removed.") -CONFIG_DWORD_INFO_DIRECT_ACCESS(INTERNAL_VerifierOff, W("VerifierOff"), "") -RETAIL_CONFIG_DWORD_INFO_DIRECT_ACCESS(EXTERNAL_VerifyAllOnLoad, W("VerifyAllOnLoad"), "") -// ** -// PLEASE MOVE ANY CONFIG SWITCH YOU OWN OUT OF THIS SECTION INTO A CATEGORY ABOVE -// -// DO NOT ADD ANY MORE CONFIG SWITCHES TO THIS SECTION! -// ** -//--------------------------------------------------------------------------------------- diff --git a/src/inc/clrhost.h b/src/inc/clrhost.h deleted file mode 100644 index 9fe978f95..000000000 --- a/src/inc/clrhost.h +++ /dev/null @@ -1,623 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -// - -// - - -#ifndef __CLRHOST_H__ -#define __CLRHOST_H__ - -#include "windows.h" // worth to include before mscoree.h so we are guaranteed to pick few definitions -#ifdef CreateSemaphore -#undef CreateSemaphore -#endif -#include "mscoree.h" -#include "clrinternal.h" -#include "switches.h" -#include "holder.h" -#include "new.hpp" -#include "staticcontract.h" -#include "predeftlsslot.h" -#include "safemath.h" -#include "debugreturn.h" - -#if !defined(_DEBUG_IMPL) && defined(_DEBUG) && !defined(DACCESS_COMPILE) -#define _DEBUG_IMPL 1 -#endif - -#define BEGIN_PRESERVE_LAST_ERROR \ - { \ - DWORD __dwLastError = ::GetLastError(); \ - DEBUG_ASSURE_NO_RETURN_BEGIN(PRESERVE_LAST_ERROR); \ - { - -#define END_PRESERVE_LAST_ERROR \ - } \ - DEBUG_ASSURE_NO_RETURN_END(PRESERVE_LAST_ERROR); \ - ::SetLastError(__dwLastError); \ - } - -// -// TRASH_LASTERROR macro sets bogus last error in debug builds to help find places that fail to save it -// -#ifdef _DEBUG - -#define LAST_ERROR_TRASH_VALUE 42424 - -#define TRASH_LASTERROR \ - SetLastError(LAST_ERROR_TRASH_VALUE) - -#else // _DEBUG - -#define TRASH_LASTERROR - -#endif // _DEBUG - -IExecutionEngine *GetExecutionEngine(); -IEEMemoryManager *GetEEMemoryManager(); - -LPVOID ClrVirtualAlloc(LPVOID lpAddress, SIZE_T dwSize, DWORD flAllocationType, DWORD flProtect); -BOOL ClrVirtualFree(LPVOID lpAddress, SIZE_T dwSize, DWORD dwFreeType); -SIZE_T ClrVirtualQuery(LPCVOID lpAddress, PMEMORY_BASIC_INFORMATION lpBuffer, SIZE_T dwLength); -BOOL ClrVirtualProtect(LPVOID lpAddress, SIZE_T dwSize, DWORD flNewProtect, PDWORD lpflOldProtect); -LPVOID ClrDebugAlloc (size_t size, LPCSTR pszFile, int iLineNo); -HANDLE ClrGetProcessHeap(); -HANDLE ClrHeapCreate(DWORD flOptions, SIZE_T dwInitialSize, SIZE_T dwMaximumSize); -BOOL ClrHeapDestroy(HANDLE hHeap); -LPVOID ClrHeapAlloc(HANDLE hHeap, DWORD dwFlags, S_SIZE_T dwBytes); -BOOL ClrHeapFree(HANDLE hHeap, DWORD dwFlags, LPVOID lpMem); -BOOL ClrHeapValidate(HANDLE hHeap, DWORD dwFlags, LPCVOID lpMem); -HANDLE ClrGetProcessExecutableHeap(); - - -#ifdef FAILPOINTS_ENABLED -extern int RFS_HashStack(); -#endif - - -void ClrFlsAssociateCallback(DWORD slot, PTLS_CALLBACK_FUNCTION callback); - -typedef LPVOID* (*CLRFLSGETBLOCK)(); -extern CLRFLSGETBLOCK __ClrFlsGetBlock; - -// Combining getter/setter into a single call -inline void ClrFlsIncrementValue(DWORD slot, int increment) -{ - STATIC_CONTRACT_NOTHROW; - STATIC_CONTRACT_GC_NOTRIGGER; - STATIC_CONTRACT_MODE_ANY; - STATIC_CONTRACT_CANNOT_TAKE_LOCK; - STATIC_CONTRACT_SO_TOLERANT; - - _ASSERTE(increment != 0); - - void **block = (*__ClrFlsGetBlock)(); - size_t value; - - if (block != NULL) - { - value = (size_t) block[slot]; - - _ASSERTE((increment > 0) || (value + increment < value)); - block[slot] = (void *) (value + increment); - } - else - { - BEGIN_PRESERVE_LAST_ERROR; - - ANNOTATION_VIOLATION(SOToleranceViolation); - - IExecutionEngine * pEngine = GetExecutionEngine(); - value = (size_t) pEngine->TLS_GetValue(slot); - - _ASSERTE((increment > 0) || (value + increment < value)); - pEngine->TLS_SetValue(slot, (void *) (value + increment)); - - END_PRESERVE_LAST_ERROR; - } -} - - -inline void * ClrFlsGetValue (DWORD slot) -{ - STATIC_CONTRACT_NOTHROW; - STATIC_CONTRACT_GC_NOTRIGGER; - STATIC_CONTRACT_MODE_ANY; - STATIC_CONTRACT_CANNOT_TAKE_LOCK; - STATIC_CONTRACT_SO_TOLERANT; - - void **block = (*__ClrFlsGetBlock)(); - if (block != NULL) - { - return block[slot]; - } - else - { - ANNOTATION_VIOLATION(SOToleranceViolation); - - void * value = GetExecutionEngine()->TLS_GetValue(slot); - return value; - } -} - - -inline BOOL ClrFlsCheckValue(DWORD slot, void ** pValue) -{ - STATIC_CONTRACT_NOTHROW; - STATIC_CONTRACT_GC_NOTRIGGER; - STATIC_CONTRACT_MODE_ANY; - STATIC_CONTRACT_SO_TOLERANT; - -#ifdef _DEBUG - *pValue = ULongToPtr(0xcccccccc); -#endif //_DEBUG - void **block = (*__ClrFlsGetBlock)(); - if (block != NULL) - { - *pValue = block[slot]; - return TRUE; - } - else - { - ANNOTATION_VIOLATION(SOToleranceViolation); - BOOL result = GetExecutionEngine()->TLS_CheckValue(slot, pValue); - return result; - } -} - -inline void ClrFlsSetValue(DWORD slot, void *pData) -{ - STATIC_CONTRACT_NOTHROW; - STATIC_CONTRACT_GC_NOTRIGGER; - STATIC_CONTRACT_MODE_ANY; - STATIC_CONTRACT_CANNOT_TAKE_LOCK; - STATIC_CONTRACT_SO_TOLERANT; - - void **block = (*__ClrFlsGetBlock)(); - if (block != NULL) - { - block[slot] = pData; - } - else - { - BEGIN_PRESERVE_LAST_ERROR; - - ANNOTATION_VIOLATION(SOToleranceViolation); - GetExecutionEngine()->TLS_SetValue(slot, pData); - - END_PRESERVE_LAST_ERROR; - } -} - -typedef LPVOID (*FastAllocInProcessHeapFunc)(DWORD dwFlags, SIZE_T dwBytes); -extern FastAllocInProcessHeapFunc __ClrAllocInProcessHeap; -inline LPVOID ClrAllocInProcessHeap(DWORD dwFlags, S_SIZE_T dwBytes) -{ - STATIC_CONTRACT_SUPPORTS_DAC_HOST_ONLY; - if (dwBytes.IsOverflow()) - { - return NULL; - } - -#ifndef SELF_NO_HOST - return __ClrAllocInProcessHeap(dwFlags, dwBytes.Value()); -#else -#undef HeapAlloc -#undef GetProcessHeap - static HANDLE ProcessHeap = NULL; - if (ProcessHeap == NULL) - ProcessHeap = GetProcessHeap(); - return ::HeapAlloc(ProcessHeap,dwFlags,dwBytes.Value()); -#define HeapAlloc(hHeap, dwFlags, dwBytes) Dont_Use_HeapAlloc(hHeap, dwFlags, dwBytes) -#define GetProcessHeap() Dont_Use_GetProcessHeap() -#endif -} - -typedef BOOL (*FastFreeInProcessHeapFunc)(DWORD dwFlags, LPVOID lpMem); -extern FastFreeInProcessHeapFunc __ClrFreeInProcessHeap; -inline BOOL ClrFreeInProcessHeap(DWORD dwFlags, LPVOID lpMem) -{ - STATIC_CONTRACT_SUPPORTS_DAC_HOST_ONLY; -#ifndef SELF_NO_HOST - return __ClrFreeInProcessHeap(dwFlags, lpMem); -#else -#undef HeapFree -#undef GetProcessHeap - static HANDLE ProcessHeap = NULL; - if (ProcessHeap == NULL) - ProcessHeap = GetProcessHeap(); - return (BOOL)(BYTE)::HeapFree(ProcessHeap, dwFlags, lpMem); -#define HeapFree(hHeap, dwFlags, lpMem) Dont_Use_HeapFree(hHeap, dwFlags, lpMem) -#define GetProcessHeap() Dont_Use_GetProcessHeap() -#endif -} - -// Critical section support for CLR DLLs other than the the EE. -// Include the header defining each Crst type and its corresponding level (relative rank). This is -// auto-generated from a tool that takes a high-level description of each Crst type and its dependencies. -#include "crsttypes.h" - -// critical section api -CRITSEC_COOKIE ClrCreateCriticalSection(CrstType type, CrstFlags flags); -HRESULT ClrDeleteCriticalSection(CRITSEC_COOKIE cookie); -void ClrEnterCriticalSection(CRITSEC_COOKIE cookie); -void ClrLeaveCriticalSection(CRITSEC_COOKIE cookie); - -// event api -EVENT_COOKIE ClrCreateAutoEvent(BOOL bInitialState); -EVENT_COOKIE ClrCreateManualEvent(BOOL bInitialState); -void ClrCloseEvent(EVENT_COOKIE event); -BOOL ClrSetEvent(EVENT_COOKIE event); -BOOL ClrResetEvent(EVENT_COOKIE event); -DWORD ClrWaitEvent(EVENT_COOKIE event, DWORD dwMilliseconds, BOOL bAlertable); - -// semaphore api -SEMAPHORE_COOKIE ClrCreateSemaphore(DWORD dwInitial, DWORD dwMax); -void ClrCloseSemaphore(SEMAPHORE_COOKIE semaphore); -BOOL ClrReleaseSemaphore(SEMAPHORE_COOKIE semaphore, LONG lReleaseCount, LONG *lpPreviousCount); -DWORD ClrWaitSemaphore(SEMAPHORE_COOKIE semaphore, DWORD dwMilliseconds, BOOL bAlertable); - -// mutex api -MUTEX_COOKIE ClrCreateMutex(LPSECURITY_ATTRIBUTES lpMutexAttributes,BOOL bInitialOwner,LPCTSTR lpName); -void ClrCloseMutex(MUTEX_COOKIE mutex); -BOOL ClrReleaseMutex(MUTEX_COOKIE mutex); -DWORD ClrWaitForMutex(MUTEX_COOKIE mutex,DWORD dwMilliseconds,BOOL bAlertable); -DWORD ClrSleepEx(DWORD dwMilliseconds, BOOL bAlertable); - -// Rather than use the above APIs directly, it is recommended that holder classes -// be used. This guarantees that the locks will be vacated when the scope is popped, -// either on exception or on return. - -typedef Holder CRITSEC_Holder; - -// Use this holder to manage CRITSEC_COOKIE allocation to ensure it will be released if anything goes wrong -FORCEINLINE void VoidClrDeleteCriticalSection(CRITSEC_COOKIE cs) { if (cs != NULL) ClrDeleteCriticalSection(cs); } -typedef Wrapper, VoidClrDeleteCriticalSection, NULL> CRITSEC_AllocationHolder; - -class Event { -public: - Event () - : m_event(NULL) - {STATIC_CONTRACT_LEAF;} - ~Event () - { - STATIC_CONTRACT_WRAPPER; - CloseEvent(); - } - - void CreateAutoEvent(BOOL bInitialState) - { - STATIC_CONTRACT_WRAPPER; - m_event = ClrCreateAutoEvent(bInitialState); - } - void CreateManualEvent(BOOL bInitialState) - { - STATIC_CONTRACT_WRAPPER; - m_event = ClrCreateManualEvent(bInitialState); - } - void CloseEvent() - { - STATIC_CONTRACT_WRAPPER; - if (m_event != NULL) - ClrCloseEvent(m_event); - m_event = NULL; - } - - BOOL Set() - { - STATIC_CONTRACT_WRAPPER; - return ClrSetEvent(m_event); - } - BOOL Reset() - { - STATIC_CONTRACT_WRAPPER; - return ClrResetEvent(m_event); - } - DWORD Wait(DWORD dwMilliseconds, BOOL bAlertable) - { - STATIC_CONTRACT_WRAPPER; - return ClrWaitEvent(m_event, dwMilliseconds, bAlertable); - } - -private: - EVENT_COOKIE m_event; -}; - -class Semaphore { -public: - Semaphore () - : m_semaphore(NULL) - {STATIC_CONTRACT_LEAF;} - ~Semaphore () - { - STATIC_CONTRACT_WRAPPER; - Close(); - } - - void Create(DWORD dwInitial, DWORD dwMax) - { - STATIC_CONTRACT_WRAPPER; - m_semaphore = ClrCreateSemaphore(dwInitial, dwMax); - } - void Close() - { - STATIC_CONTRACT_WRAPPER; - if (m_semaphore != NULL) - ClrCloseSemaphore(m_semaphore); - m_semaphore = NULL; - } - - BOOL Release(LONG lReleaseCount, LONG* lpPreviousCount) - { - STATIC_CONTRACT_WRAPPER; - return ClrReleaseSemaphore(m_semaphore, lReleaseCount, lpPreviousCount); - } - DWORD Wait(DWORD dwMilliseconds, BOOL bAlertable) - { - STATIC_CONTRACT_WRAPPER; - return ClrWaitSemaphore(m_semaphore, dwMilliseconds, bAlertable); - } - -private: - SEMAPHORE_COOKIE m_semaphore; -}; - -HMODULE GetCLRModule (); - -#ifndef FEATURE_NO_HOST -/* - Here we start the list of functions we want to deprecate. - We use a define to generate a linker error. - We must insure to include the header file that has the definition we are about - to deprecate before we use the #define otherwise we will run into a linker error - when legitimately undef'ing the function -*/ - -// -// following are windows deprecates -// -#include - -/* - If you are reading this, you have probably tracked down the fact that memory Alloc, - etc. don't work inside your DLL because you are using src\inc & src\utilcode - services. - You need to use the ClrXXX equivalent functions to properly guarantee your code - works correctly wrt hosting and others execution engine requirements. - Check the list of Clr functions above -*/ - -#define GetProcessHeap() \ - Dont_Use_GetProcessHeap() - -#define VirtualAlloc(lpAddress, dwSize, flAllocationType, flProtect) \ - Dont_Use_VirtualAlloc(lpAddress, dwSize, flAllocationType, flProtect) - -#define VirtualFree(lpAddress, dwSize, dwFreeType) \ - Dont_Use_VirtualFree(lpAddress, dwSize, dwFreeType) - -#define VirtualQuery(lpAddress, lpBuffer, dwLength) \ - Dont_Use_VirtualQuery(lpAddress, lpBuffer, dwLength) - -#define VirtualProtect(lpAddress, dwSize, flNewProtect, lpflOldProtect) \ - Dont_Use_VirtualProtect(lpAddress, dwSize, flNewProtect, lpflOldProtect) - -#define HeapCreate(flOptions, dwInitialSize, dwMaximumSize) \ - Dont_Use_HeapCreate(flOptions, dwInitialSize, dwMaximumSize) - -#define HeapDestroy(hHeap) \ - Dont_Use_HeapDestroy(hHeap) - -#define HeapAlloc(hHeap, dwFlags, dwBytes) \ - Dont_Use_HeapAlloc(hHeap, dwFlags, dwBytes) - -#define HeapReAlloc(hHeap, dwFlags, lpMem, dwBytes) \ - Dont_Use_HeapReAlloc(hHeap, dwFlags, lpMem, dwBytes) - -#define HeapFree(hHeap, dwFlags, lpMem) \ - Dont_Use_HeapFree(hHeap, dwFlags, lpMem) - -#define HeapValidate(hHeap, dwFlags, lpMem) \ - Dont_Use_HeapValidate(hHeap, dwFlags, lpMem) - -#define LocalAlloc(uFlags, uBytes) \ - Dont_Use_LocalAlloc(uFlags, uBytes) - -#define LocalFree(hMem) \ - Dont_Use_LocalFree(hMem) - -#define LocalReAlloc(hMem, uBytes, uFlags) \ - Dont_Use_LocalReAlloc(hMem, uBytes, uFlags) - -#define GlobalAlloc(uFlags, dwBytes) \ - Dont_Use_GlobalAlloc(uFlags, dwBytes) - -#define GlobalFree(hMem) \ - Dont_Use_GlobalFree(hMem) - -//#define ExitThread Dont_Use_ExitThread - -#define ExitProcess Dont_Use_ExitProcess - -/* - If you are reading this, you have probably tracked down the fact that TlsAlloc, - etc. don't work inside your DLL because you are using src\inc & src\utilcode - services. - - This is because the CLR can operate in a fiberized environment under host control. - When this is the case, logical thread local storage must be fiber-relative rather - than thread-relative. - - Although the OS provides FLS routines on .NET Server, it does not yet provide - those services on WinXP or Win2K. So you cannot just use fiber routines from - the OS. - - Instead, you must use the ClrFls_ routines described above. However, there are - some important differences between these EE-provided services and the OS TLS - services that you are used to: - - 1) There is no TlsAlloc/FlsAlloc equivalent. You must statically describe - your needs via the PredefinedTlsSlots below. If you have dynamic requirements, - you should give yourself a single static slot and then build your dynamic - requirements on top of this. The lack of a dynamic API is a deliberate - choice on my part, rather than lack of time. - - 2) You can provide a cleanup routine, which we will call on your behalf. However, - this can be called on a different thread than the "thread" (fiber or thread) - which holds the data. It can be called after that thread has actually been - terminated. It can be called before you see a DLL_THREAD_DETACH on your - physical thread. The circumstances vary based on whether the process is hosted - and based on whether TS_WeOwn is set on the internal Thread object. Make - no assumptions here. -*/ -#define TlsAlloc() \ - Dont_Use_TlsAlloc() - -#define TlsSetValue(dwTlsIndex, lpTlsValue) \ - Dont_Use_TlsSetValue(dwTlsIndex, lpTlsValue) - -#define TlsGetValue(dwTlsIndex) \ - Dont_Use_TlsGetValue(dwTlsIndex) - -#define TlsFree(dwTlsIndex) \ - Dont_Use_TlsFree(dwTlsIndex) - - -/* - If you are reading this, you have probably tracked down the fact that synchronization objects - and critical sections don't work inside your DLL because you are using src\inc & src\utilcode services. - Please refer to the ClrXXX functions described above to make proper use of synchronization obejct, etc. - - Also it's extremely useful to look at the Holder classes defined above. - Those classes provide a nice encapsulation for synchronization object that allows automatic release of locks. -*/ -#define InitializeCriticalSection(lpCriticalSection) \ - Dont_Use_InitializeCriticalSection(lpCriticalSection) - -#define InitializeCriticalSectionAndSpinCount(lpCriticalSection, dwSpinCount) \ - Dont_Use_InitializeCriticalSectionAndSpinCount(lpCriticalSection, dwSpinCount) - -#define DeleteCriticalSection(lpCriticalSection) \ - Dont_Use_DeleteCriticalSection(lpCriticalSection) - -#define EnterCriticalSection(lpCriticalSection) \ - Dont_Use_EnterCriticalSection(lpCriticalSection) - -#define TryEnterCriticalSection(lpCriticalSection) \ - Dont_Use_TryEnterCriticalSection(lpCriticalSection) - -#define LeaveCriticalSection(lpCriticalSection) \ - Dont_Use_LeaveCriticalSection(lpCriticalSection) - -#ifdef CreateEvent -#undef CreateEvent -#endif -#define CreateEvent(lpEventAttributes, bManualReset, bInitialState, lpName) \ - Dont_Use_CreateEvent(lpEventAttributes, bManualReset, bInitialState, lpName) - -#ifdef OpenEvent -#undef OpenEvent -#endif -#define OpenEvent(dwDesiredAccess, bInheritHandle, lpName) \ - Dont_Use_OpenEvent(dwDesiredAccess, bInheritHandle, lpName) - -#define ResetEvent(hEvent) \ - Dont_Use_ResetEvent(hEvent) - -#define SetEvent(hEvent) \ - Dont_Use_SetEvent(hEvent) - -#define PulseEvent(hEvent) \ - Dont_Use_PulseEvent(hEvent) - -#ifdef CreateSemaphore -#undef CreateSemaphore -#endif -#define CreateSemaphore(lpSemaphoreAttributes, lInitialCount, lMaximumCount, lpName) \ - Dont_Use_CreateSemaphore(lpSemaphoreAttributes, lInitialCount, lMaximumCount, lpName) - -#ifdef OpenSemaphore -#undef OpenSemaphore -#endif -#define OpenSemaphore(dwDesiredAccess, bInheritHandle, lpName) \ - Dont_Use_OpenSemaphore(dwDesiredAccess, bInheritHandle, lpName) - -#define ReleaseSemaphore(hSemaphore, lReleaseCount, lpPreviousCount) \ - Dont_Use_ReleaseSemaphore(hSemaphore, lReleaseCount, lpPreviousCount) - -#ifdef Sleep -#undef Sleep -#endif -#define Sleep(dwMilliseconds) \ - Dont_Use_Sleep(dwMilliseconds) - -#ifdef SleepEx -#undef SleepEx -#endif -#define SleepEx(dwMilliseconds,bAlertable) \ - Dont_Use_SleepEx(dwMilliseconds,bAlertable) - -// -// following are clib deprecates -// -#include -#include - -#ifdef malloc -#undef malloc -#endif - -#define _CRT_EXCEPTION_NO_MALLOC -#define malloc(size) \ - Dont_Use_malloc(size) - -#ifdef realloc -#undef realloc -#endif -#define realloc(memblock, size) \ - Dont_Use_realloc(memblock, size) - -#ifdef free -#undef free -#endif -#define free(memblock) \ - Dont_Use_free(memblock) - -#endif //!FEATURE_NO_HOST - -extern void IncCantAllocCount(); -extern void DecCantAllocCount(); - -class CantAllocHolder -{ -public: - CantAllocHolder () - { - IncCantAllocCount (); - } - ~CantAllocHolder() - { - DecCantAllocCount (); - } -}; - -// At places where want to allocate stress log, we need to first check if we are allowed to do so. -// If ClrTlsInfo doesn't exist for this thread, we take it as can alloc -inline bool IsInCantAllocRegion () -{ - size_t count = 0; - if (ClrFlsCheckValue(TlsIdx_CantAllocCount, (LPVOID *)&count)) - { - _ASSERTE (count >= 0); - return count > 0; - } - return false; -} -// for stress log the rule is more restrict, we have to check the global counter too -extern BOOL IsInCantAllocStressLogRegion(); - -#include "genericstackprobe.inl" - -#endif diff --git a/src/inc/clrnt.h b/src/inc/clrnt.h deleted file mode 100644 index 487a370d0..000000000 --- a/src/inc/clrnt.h +++ /dev/null @@ -1,1040 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - - -#ifndef CLRNT_H_ -#define CLRNT_H_ - -#include "staticcontract.h" -#include "cfi.h" - -// -// This file is the result of some changes to the SDK header files. -// In particular, nt.h and some of its dependencies are no longer -// available except as "nonship" files. As a result, this file -// was created as a simple cut and past of structures and functions -// from NT that are either not yet documented or have been overlooked -// as being part of the platform SDK. -// - -// -// ALL PLATFORMS -// - -#define STATUS_INVALID_PARAMETER_3 ((NTSTATUS)0xC00000F1L) -#define STATUS_INVALID_PARAMETER_4 ((NTSTATUS)0xC00000F2L) -#define STATUS_UNSUCCESSFUL ((NTSTATUS)0xC0000001L) -#define STATUS_SUCCESS ((NTSTATUS)0x00000000L) - -#ifndef STATUS_UNWIND -#define STATUS_UNWIND ((NTSTATUS)0x80000027L) -#endif - -#ifndef DBG_PRINTEXCEPTION_C -#define DBG_PRINTEXCEPTION_C ((DWORD)0x40010006L) -#endif - -#ifndef STATUS_UNWIND_CONSOLIDATE -#define STATUS_UNWIND_CONSOLIDATE ((NTSTATUS)0x80000029L) -#endif - -#ifndef STATUS_LONGJUMP -#define STATUS_LONGJUMP ((NTSTATUS)0x80000026L) -#endif - -#ifndef LOCALE_NAME_MAX_LENGTH -#define LOCALE_NAME_MAX_LENGTH 85 -#endif // !LOCALE_NAME_MAX_LENGTH - -#ifndef SUBLANG_CUSTOM_DEFAULT -#define SUBLANG_CUSTOM_DEFAULT 0x03 // default custom language/locale -#define SUBLANG_CUSTOM_UNSPECIFIED 0x04 // custom language/locale -#define LOCALE_CUSTOM_DEFAULT \ - (MAKELCID(MAKELANGID(LANG_NEUTRAL, SUBLANG_CUSTOM_DEFAULT), SORT_DEFAULT)) -#define LOCALE_CUSTOM_UNSPECIFIED \ - (MAKELCID(MAKELANGID(LANG_NEUTRAL, SUBLANG_CUSTOM_UNSPECIFIED), SORT_DEFAULT)) -#endif // !SUBLANG_CUSTOM_DEFAULT - -#ifndef __out_xcount_opt -#define __out_xcount_opt(var) __out -#endif - -#ifndef __encoded_pointer -#define __encoded_pointer -#endif - -#ifndef __range -#define __range(min, man) -#endif - -#ifndef __field_bcount -#define __field_bcount(size) -#endif - -#ifndef __field_ecount_opt -#define __field_ecount_opt(nFields) -#endif - -#ifndef __field_ecount -#define __field_ecount(EHCount) -#endif - -#undef _Ret_bytecap_ -#define _Ret_bytecap_(_Size) - -#ifndef NT_SUCCESS -#define NT_SUCCESS(Status) (((NTSTATUS)(Status)) >= 0) -#endif - -#define ARGUMENT_PRESENT(ArgumentPointer) (\ - (CHAR *)(ArgumentPointer) != (CHAR *)(NULL) ) - -#define EXCEPTION_CHAIN_END ((PEXCEPTION_REGISTRATION_RECORD)-1) - -typedef signed char SCHAR; -typedef SCHAR *PSCHAR; -typedef LONG NTSTATUS; - -#ifndef FEATURE_PAL - -#define TLS_MINIMUM_AVAILABLE 64 // winnt -#define TLS_EXPANSION_SLOTS 1024 - -typedef enum _THREADINFOCLASS { - ThreadBasicInformation, - ThreadTimes, - ThreadPriority, - ThreadBasePriority, - ThreadAffinityMask, - ThreadImpersonationToken, - ThreadDescriptorTableEntry, - ThreadEnableAlignmentFaultFixup, - ThreadEventPair_Reusable, - ThreadQuerySetWin32StartAddress, - ThreadZeroTlsCell, - ThreadPerformanceCount, - ThreadAmILastThread, - ThreadIdealProcessor, - ThreadPriorityBoost, - ThreadSetTlsArrayAddress, - ThreadIsIoPending, - ThreadHideFromDebugger, - ThreadBreakOnTermination, - MaxThreadInfoClass - } THREADINFOCLASS; - -typedef enum _SYSTEM_INFORMATION_CLASS { - SystemBasicInformation, - SystemProcessorInformation, // obsolete...delete - SystemPerformanceInformation, - SystemTimeOfDayInformation, - SystemPathInformation, - SystemProcessInformation, - SystemCallCountInformation, - SystemDeviceInformation, - SystemProcessorPerformanceInformation, - SystemFlagsInformation, - SystemCallTimeInformation, - SystemModuleInformation, - SystemLocksInformation, - SystemStackTraceInformation, - SystemPagedPoolInformation, - SystemNonPagedPoolInformation, - SystemHandleInformation, - SystemObjectInformation, - SystemPageFileInformation, - SystemVdmInstemulInformation, - SystemVdmBopInformation, - SystemFileCacheInformation, - SystemPoolTagInformation, - SystemInterruptInformation, - SystemDpcBehaviorInformation, - SystemFullMemoryInformation, - SystemLoadGdiDriverInformation, - SystemUnloadGdiDriverInformation, - SystemTimeAdjustmentInformation, - SystemSummaryMemoryInformation, - SystemMirrorMemoryInformation, - SystemPerformanceTraceInformation, - SystemObsolete0, - SystemExceptionInformation, - SystemCrashDumpStateInformation, - SystemKernelDebuggerInformation, - SystemContextSwitchInformation, - SystemRegistryQuotaInformation, - SystemExtendServiceTableInformation, - SystemPrioritySeperation, - SystemVerifierAddDriverInformation, - SystemVerifierRemoveDriverInformation, - SystemProcessorIdleInformation, - SystemLegacyDriverInformation, - SystemCurrentTimeZoneInformation, - SystemLookasideInformation, - SystemTimeSlipNotification, - SystemSessionCreate, - SystemSessionDetach, - SystemSessionInformation, - SystemRangeStartInformation, - SystemVerifierInformation, - SystemVerifierThunkExtend, - SystemSessionProcessInformation, - SystemLoadGdiDriverInSystemSpace, - SystemNumaProcessorMap, - SystemPrefetcherInformation, - SystemExtendedProcessInformation, - SystemRecommendedSharedDataAlignment, - SystemComPlusPackage, - SystemNumaAvailableMemory, - SystemProcessorPowerInformation, - SystemEmulationBasicInformation, - SystemEmulationProcessorInformation, - SystemExtendedHandleInformation, - SystemLostDelayedWriteInformation -} SYSTEM_INFORMATION_CLASS; - -typedef enum _EVENT_INFORMATION_CLASS { - EventBasicInformation - } EVENT_INFORMATION_CLASS; - -typedef struct _SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION { - LARGE_INTEGER IdleTime; - LARGE_INTEGER KernelTime; - LARGE_INTEGER UserTime; - LARGE_INTEGER DpcTime; // DEVL only - LARGE_INTEGER InterruptTime; // DEVL only - ULONG InterruptCount; -} SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION, *PSYSTEM_PROCESSOR_PERFORMANCE_INFORMATION; - -typedef enum _EVENT_TYPE { - NotificationEvent, - SynchronizationEvent - } EVENT_TYPE; - -typedef struct _EVENT_BASIC_INFORMATION { - EVENT_TYPE EventType; - LONG EventState; -} EVENT_BASIC_INFORMATION, *PEVENT_BASIC_INFORMATION; - -#define RTL_MEG (1024UL * 1024UL) -#define RTLP_IMAGE_MAX_DOS_HEADER ( 256UL * RTL_MEG) - -typedef struct _SYSTEM_KERNEL_DEBUGGER_INFORMATION { - BOOLEAN KernelDebuggerEnabled; - BOOLEAN KernelDebuggerNotPresent; -} SYSTEM_KERNEL_DEBUGGER_INFORMATION, *PSYSTEM_KERNEL_DEBUGGER_INFORMATION; - -typedef struct _STRING { - USHORT Length; - USHORT MaximumLength; -#ifdef MIDL_PASS - [size_is(MaximumLength), length_is(Length) ] -#endif // MIDL_PASS - PCHAR Buffer; -} STRING; -typedef STRING *PSTRING; - -typedef STRING ANSI_STRING; -typedef PSTRING PANSI_STRING; - -typedef STRING OEM_STRING; -typedef PSTRING POEM_STRING; -typedef CONST STRING* PCOEM_STRING; - -typedef struct _UNICODE_STRING { - USHORT Length; - USHORT MaximumLength; -#ifdef MIDL_PASS - [size_is(MaximumLength / 2), length_is((Length) / 2) ] USHORT * Buffer; -#else // MIDL_PASS - PWSTR Buffer; -#endif // MIDL_PASS -} UNICODE_STRING; -typedef UNICODE_STRING *PUNICODE_STRING; -typedef const UNICODE_STRING *PCUNICODE_STRING; -#define UNICODE_NULL ((WCHAR)0) // winnt - -typedef struct _STRING32 { - USHORT Length; - USHORT MaximumLength; - ULONG Buffer; -} STRING32; -typedef STRING32 *PSTRING32; - -typedef STRING32 UNICODE_STRING32; -typedef UNICODE_STRING32 *PUNICODE_STRING32; - -typedef STRING32 ANSI_STRING32; -typedef ANSI_STRING32 *PANSI_STRING32; - - -typedef struct _STRING64 { - USHORT Length; - USHORT MaximumLength; - ULONGLONG Buffer; -} STRING64; -typedef STRING64 *PSTRING64; - -typedef STRING64 UNICODE_STRING64; -typedef UNICODE_STRING64 *PUNICODE_STRING64; - -typedef STRING64 ANSI_STRING64; -typedef ANSI_STRING64 *PANSI_STRING64; - -#define GDI_HANDLE_BUFFER_SIZE32 34 -#define GDI_HANDLE_BUFFER_SIZE64 60 - -#if !defined(_TARGET_AMD64_) -#define GDI_HANDLE_BUFFER_SIZE GDI_HANDLE_BUFFER_SIZE32 -#else -#define GDI_HANDLE_BUFFER_SIZE GDI_HANDLE_BUFFER_SIZE64 -#endif - -typedef ULONG GDI_HANDLE_BUFFER32[GDI_HANDLE_BUFFER_SIZE32]; -typedef ULONG GDI_HANDLE_BUFFER64[GDI_HANDLE_BUFFER_SIZE64]; -typedef ULONG GDI_HANDLE_BUFFER [GDI_HANDLE_BUFFER_SIZE ]; - - -typedef struct _PEB_LDR_DATA { - ULONG Length; - BOOLEAN Initialized; - HANDLE SsHandle; - LIST_ENTRY InLoadOrderModuleList; - LIST_ENTRY InMemoryOrderModuleList; - LIST_ENTRY InInitializationOrderModuleList; - PVOID EntryInProgress; -} PEB_LDR_DATA, *PPEB_LDR_DATA; - -typedef struct _PEB_FREE_BLOCK { - struct _PEB_FREE_BLOCK *Next; - ULONG Size; -} PEB_FREE_BLOCK, *PPEB_FREE_BLOCK; - -typedef PVOID* PPVOID; - -typedef -VOID -(*PPS_POST_PROCESS_INIT_ROUTINE) ( - VOID - ); - -typedef struct _LDR_DATA_TABLE_ENTRY { - LIST_ENTRY InLoadOrderLinks; - LIST_ENTRY InMemoryOrderLinks; - LIST_ENTRY InInitializationOrderLinks; - PVOID DllBase; - PVOID EntryPoint; - ULONG SizeOfImage; - UNICODE_STRING FullDllName; - UNICODE_STRING BaseDllName; - ULONG Flags; - USHORT LoadCount; - USHORT TlsIndex; - union _foo { - LIST_ENTRY HashLinks; - struct _bar { - PVOID SectionPointer; - ULONG CheckSum; - }; - }; - union _foo2 { - struct _bar2 { - ULONG TimeDateStamp; - }; - struct _bar3 { - PVOID LoadedImports; - }; - }; - PVOID EntryPointActivationContext; -} LDR_DATA_TABLE_ENTRY, *PLDR_DATA_TABLE_ENTRY; - -#define TYPE3(arg) arg - -typedef struct _PEB { - BOOLEAN InheritedAddressSpace; // These four fields cannot change unless the - BOOLEAN ReadImageFileExecOptions; // - BOOLEAN BeingDebugged; // - BOOLEAN SpareBool; // - HANDLE Mutant; // INITIAL_PEB structure is also updated. - - PVOID ImageBaseAddress; - PPEB_LDR_DATA Ldr; - TYPE3(struct _RTL_USER_PROCESS_PARAMETERS*) ProcessParameters; - PVOID SubSystemData; - PVOID ProcessHeap; - TYPE3(struct _RTL_CRITICAL_SECTION*) FastPebLock; - PVOID FastPebLockRoutine; - PVOID FastPebUnlockRoutine; - ULONG EnvironmentUpdateCount; - PVOID KernelCallbackTable; - ULONG SystemReserved[1]; - - struct _foo { - ULONG ExecuteOptions : 2; - ULONG SpareBits : 30; - }; - - - PPEB_FREE_BLOCK FreeList; - ULONG TlsExpansionCounter; - PVOID TlsBitmap; - ULONG TlsBitmapBits[2]; // TLS_MINIMUM_AVAILABLE bits - PVOID ReadOnlySharedMemoryBase; - PVOID ReadOnlySharedMemoryHeap; - PPVOID ReadOnlyStaticServerData; - PVOID AnsiCodePageData; - PVOID OemCodePageData; - PVOID UnicodeCaseTableData; - - // - // Useful information for LdrpInitialize - ULONG NumberOfProcessors; - ULONG NtGlobalFlag; - - // - // Passed up from MmCreatePeb from Session Manager registry key - // - - LARGE_INTEGER CriticalSectionTimeout; - SIZE_T HeapSegmentReserve; - SIZE_T HeapSegmentCommit; - SIZE_T HeapDeCommitTotalFreeThreshold; - SIZE_T HeapDeCommitFreeBlockThreshold; - - // - // Where heap manager keeps track of all heaps created for a process - // Fields initialized by MmCreatePeb. ProcessHeaps is initialized - // to point to the first free byte after the PEB and MaximumNumberOfHeaps - // is computed from the page size used to hold the PEB, less the fixed - // size of this data structure. - // - - ULONG NumberOfHeaps; - ULONG MaximumNumberOfHeaps; - PPVOID ProcessHeaps; - - // - // - PVOID GdiSharedHandleTable; - PVOID ProcessStarterHelper; - ULONG GdiDCAttributeList; - PVOID LoaderLock; - - // - // Following fields filled in by MmCreatePeb from system values and/or - // image header. - // - - ULONG OSMajorVersion; - ULONG OSMinorVersion; - USHORT OSBuildNumber; - USHORT OSCSDVersion; - ULONG OSPlatformId; - ULONG ImageSubsystem; - ULONG ImageSubsystemMajorVersion; - ULONG ImageSubsystemMinorVersion; - ULONG_PTR ImageProcessAffinityMask; - GDI_HANDLE_BUFFER GdiHandleBuffer; - PPS_POST_PROCESS_INIT_ROUTINE PostProcessInitRoutine; - - PVOID TlsExpansionBitmap; - ULONG TlsExpansionBitmapBits[32]; // TLS_EXPANSION_SLOTS bits - - // - // Id of the Hydra session in which this process is running - // - ULONG SessionId; - - // - // Filled in by LdrpInstallAppcompatBackend - // - ULARGE_INTEGER AppCompatFlags; - - // - // ntuser appcompat flags - // - ULARGE_INTEGER AppCompatFlagsUser; - - // - // Filled in by LdrpInstallAppcompatBackend - // - PVOID pShimData; - - // - // Filled in by LdrQueryImageFileExecutionOptions - // - PVOID AppCompatInfo; - - // - // Used by GetVersionExW as the szCSDVersion string - // - UNICODE_STRING CSDVersion; - - // - // Fusion stuff - // - PVOID ActivationContextData; - PVOID ProcessAssemblyStorageMap; - PVOID SystemDefaultActivationContextData; - PVOID SystemAssemblyStorageMap; - - // - // Enforced minimum initial commit stack - // - SIZE_T MinimumStackCommit; - -} PEB, *PPEB; - -#define ACTIVATION_CONTEXT_STACK_FLAG_QUERIES_DISABLED (0x00000001) - -typedef struct _ACTIVATION_CONTEXT_STACK { - ULONG Flags; - ULONG NextCookieSequenceNumber; - PVOID ActiveFrame; - LIST_ENTRY FrameListCache; - -#if NT_SXS_PERF_COUNTERS_ENABLED - struct _ACTIVATION_CONTEXT_STACK_PERF_COUNTERS { - ULONGLONG Activations; - ULONGLONG ActivationCycles; - ULONGLONG Deactivations; - ULONGLONG DeactivationCycles; - } Counters; -#endif // NT_SXS_PERF_COUNTERS_ENABLED -} ACTIVATION_CONTEXT_STACK, *PACTIVATION_CONTEXT_STACK; - -typedef const ACTIVATION_CONTEXT_STACK *PCACTIVATION_CONTEXT_STACK; - -#define TEB_ACTIVE_FRAME_CONTEXT_FLAG_EXTENDED (0x00000001) - -typedef struct _TEB_ACTIVE_FRAME_CONTEXT { - ULONG Flags; - PCSTR FrameName; -} TEB_ACTIVE_FRAME_CONTEXT, *PTEB_ACTIVE_FRAME_CONTEXT; - -typedef const struct _TEB_ACTIVE_FRAME_CONTEXT *PCTEB_ACTIVE_FRAME_CONTEXT; - -typedef struct _TEB_ACTIVE_FRAME_CONTEXT_EX { - TEB_ACTIVE_FRAME_CONTEXT BasicContext; - PCSTR SourceLocation; // e.g. "Z:\foo\bar\baz.c" -} TEB_ACTIVE_FRAME_CONTEXT_EX, *PTEB_ACTIVE_FRAME_CONTEXT_EX; - -typedef const struct _TEB_ACTIVE_FRAME_CONTEXT_EX *PCTEB_ACTIVE_FRAME_CONTEXT_EX; - -#define TEB_ACTIVE_FRAME_FLAG_EXTENDED (0x00000001) - -typedef struct _TEB_ACTIVE_FRAME { - ULONG Flags; - TYPE3(struct _TEB_ACTIVE_FRAME*) Previous; - PCTEB_ACTIVE_FRAME_CONTEXT Context; -} TEB_ACTIVE_FRAME, *PTEB_ACTIVE_FRAME; - -typedef const struct _TEB_ACTIVE_FRAME *PCTEB_ACTIVE_FRAME; - -typedef struct _TEB_ACTIVE_FRAME_EX { - TEB_ACTIVE_FRAME BasicFrame; - PVOID ExtensionIdentifier; // use address of your DLL Main or something unique to your mapping in the address space -} TEB_ACTIVE_FRAME_EX, *PTEB_ACTIVE_FRAME_EX; - -typedef const struct _TEB_ACTIVE_FRAME_EX *PCTEB_ACTIVE_FRAME_EX; - -typedef struct _CLIENT_ID { - HANDLE UniqueProcess; - HANDLE UniqueThread; -} CLIENT_ID; -typedef CLIENT_ID *PCLIENT_ID; - -#define GDI_BATCH_BUFFER_SIZE 310 - -typedef struct _GDI_TEB_BATCH { - ULONG Offset; - ULONG_PTR HDC; - ULONG Buffer[GDI_BATCH_BUFFER_SIZE]; -} GDI_TEB_BATCH,*PGDI_TEB_BATCH; - -typedef struct _Wx86ThreadState { - PULONG CallBx86Eip; - PVOID DeallocationCpu; - BOOLEAN UseKnownWx86Dll; - char OleStubInvoked; -} WX86THREAD, *PWX86THREAD; - -#define STATIC_UNICODE_BUFFER_LENGTH 261 -#define WIN32_CLIENT_INFO_LENGTH 62 - -typedef struct _PEB* PPEB; - -typedef struct _TEB { - NT_TIB NtTib; - PVOID EnvironmentPointer; - CLIENT_ID ClientId; - PVOID ActiveRpcHandle; - PVOID ThreadLocalStoragePointer; -#if defined(PEBTEB_BITS) - PVOID ProcessEnvironmentBlock; -#else - PPEB ProcessEnvironmentBlock; -#endif - ULONG LastErrorValue; - ULONG CountOfOwnedCriticalSections; - PVOID CsrClientThread; - PVOID Win32ThreadInfo; // PtiCurrent - ULONG User32Reserved[26]; // user32.dll items - ULONG UserReserved[5]; // Winsrv SwitchStack - PVOID WOW32Reserved; // used by WOW - LCID CurrentLocale; - ULONG FpSoftwareStatusRegister; // offset known by outsiders! - PVOID SystemReserved1[54]; // Used by FP emulator - NTSTATUS ExceptionCode; // for RaiseUserException - ACTIVATION_CONTEXT_STACK ActivationContextStack; // Fusion activation stack - // sizeof(PVOID) is a way to express processor-dependence, more generally than #ifdef _WIN64 - UCHAR SpareBytes1[48 - sizeof(PVOID) - sizeof(ACTIVATION_CONTEXT_STACK)]; - GDI_TEB_BATCH GdiTebBatch; // Gdi batching - CLIENT_ID RealClientId; - HANDLE GdiCachedProcessHandle; - ULONG GdiClientPID; - ULONG GdiClientTID; - PVOID GdiThreadLocalInfo; - ULONG_PTR Win32ClientInfo[WIN32_CLIENT_INFO_LENGTH]; // User32 Client Info - PVOID glDispatchTable[233]; // OpenGL - ULONG_PTR glReserved1[29]; // OpenGL - PVOID glReserved2; // OpenGL - PVOID glSectionInfo; // OpenGL - PVOID glSection; // OpenGL - PVOID glTable; // OpenGL - PVOID glCurrentRC; // OpenGL - PVOID glContext; // OpenGL - ULONG LastStatusValue; - UNICODE_STRING StaticUnicodeString; - WCHAR StaticUnicodeBuffer[STATIC_UNICODE_BUFFER_LENGTH]; - PVOID DeallocationStack; - PVOID TlsSlots[TLS_MINIMUM_AVAILABLE]; - LIST_ENTRY TlsLinks; - PVOID Vdm; - PVOID ReservedForNtRpc; - PVOID DbgSsReserved[2]; - ULONG HardErrorsAreDisabled; - PVOID Instrumentation[16]; - PVOID WinSockData; // WinSock - ULONG GdiBatchCount; - BOOLEAN InDbgPrint; - BOOLEAN FreeStackOnTermination; - BOOLEAN HasFiberData; - BOOLEAN IdealProcessor; - ULONG Spare3; - PVOID ReservedForPerf; - PVOID ReservedForOle; - ULONG WaitingOnLoaderLock; - WX86THREAD Wx86Thread; - PPVOID TlsExpansionSlots; - LCID ImpersonationLocale; // Current locale of impersonated user - ULONG IsImpersonating; // Thread impersonation status - PVOID NlsCache; // NLS thread cache - PVOID pShimData; // Per thread data used in the shim - ULONG HeapVirtualAffinity; - HANDLE CurrentTransactionHandle;// reserved for TxF transaction context - PTEB_ACTIVE_FRAME ActiveFrame; -} TEB; -typedef TEB *PTEB; - -typedef struct _CURDIR { - UNICODE_STRING DosPath; - HANDLE Handle; -} CURDIR, *PCURDIR; - -#define RTL_USER_PROC_CURDIR_CLOSE 0x00000002 -#define RTL_USER_PROC_CURDIR_INHERIT 0x00000003 - -typedef struct _RTL_DRIVE_LETTER_CURDIR { - USHORT Flags; - USHORT Length; - ULONG TimeStamp; - STRING DosPath; -} RTL_DRIVE_LETTER_CURDIR, *PRTL_DRIVE_LETTER_CURDIR; - - -#define RTL_MAX_DRIVE_LETTERS 32 -#define RTL_DRIVE_LETTER_VALID (USHORT)0x0001 - -typedef struct _RTL_USER_PROCESS_PARAMETERS { - ULONG MaximumLength; - ULONG Length; - - ULONG Flags; - ULONG DebugFlags; - - HANDLE ConsoleHandle; - ULONG ConsoleFlags; - HANDLE StandardInput; - HANDLE StandardOutput; - HANDLE StandardError; - - CURDIR CurrentDirectory; // ProcessParameters - UNICODE_STRING DllPath; // ProcessParameters - UNICODE_STRING ImagePathName; // ProcessParameters - UNICODE_STRING CommandLine; // ProcessParameters - PVOID Environment; // NtAllocateVirtualMemory - - ULONG StartingX; - ULONG StartingY; - ULONG CountX; - ULONG CountY; - ULONG CountCharsX; - ULONG CountCharsY; - ULONG FillAttribute; - - ULONG WindowFlags; - ULONG ShowWindowFlags; - UNICODE_STRING WindowTitle; // ProcessParameters - UNICODE_STRING DesktopInfo; // ProcessParameters - UNICODE_STRING ShellInfo; // ProcessParameters - UNICODE_STRING RuntimeData; // ProcessParameters - RTL_DRIVE_LETTER_CURDIR CurrentDirectores[ RTL_MAX_DRIVE_LETTERS ]; -} RTL_USER_PROCESS_PARAMETERS, *PRTL_USER_PROCESS_PARAMETERS; - - -typedef enum _PROCESSINFOCLASS { - ProcessBasicInformation, - ProcessQuotaLimits, - ProcessIoCounters, - ProcessVmCounters, - ProcessTimes, - ProcessBasePriority, - ProcessRaisePriority, - ProcessDebugPort, - ProcessExceptionPort, - ProcessAccessToken, - ProcessLdtInformation, - ProcessLdtSize, - ProcessDefaultHardErrorMode, - ProcessIoPortHandlers, // Note: this is kernel mode only - ProcessPooledUsageAndLimits, - ProcessWorkingSetWatch, - ProcessUserModeIOPL, - ProcessEnableAlignmentFaultFixup, - ProcessPriorityClass, - ProcessWx86Information, - ProcessHandleCount, - ProcessAffinityMask, - ProcessPriorityBoost, - ProcessDeviceMap, - ProcessSessionInformation, - ProcessForegroundInformation, - ProcessWow64Information, - ProcessImageFileName, - ProcessLUIDDeviceMapsEnabled, - ProcessBreakOnTermination, - ProcessDebugObjectHandle, - ProcessDebugFlags, - ProcessHandleTracing, - MaxProcessInfoClass // MaxProcessInfoClass should always be the last enum - } PROCESSINFOCLASS; - - -typedef struct _VM_COUNTERS { - SIZE_T PeakVirtualSize; - SIZE_T VirtualSize; - ULONG PageFaultCount; - SIZE_T PeakWorkingSetSize; - SIZE_T WorkingSetSize; - SIZE_T QuotaPeakPagedPoolUsage; - SIZE_T QuotaPagedPoolUsage; - SIZE_T QuotaPeakNonPagedPoolUsage; - SIZE_T QuotaNonPagedPoolUsage; - SIZE_T PagefileUsage; - SIZE_T PeakPagefileUsage; -} VM_COUNTERS; -typedef VM_COUNTERS *PVM_COUNTERS; - -#undef TYPE3 - -#endif // !defined(FEATURE_PAL) - -#if !defined(_TARGET_X86_) - -typedef enum _FUNCTION_TABLE_TYPE { - RF_SORTED, - RF_UNSORTED, - RF_CALLBACK -} FUNCTION_TABLE_TYPE; - -typedef struct _DYNAMIC_FUNCTION_TABLE { - LIST_ENTRY Links; - PT_RUNTIME_FUNCTION FunctionTable; - LARGE_INTEGER TimeStamp; - -#ifdef _TARGET_ARM_ - ULONG MinimumAddress; - ULONG MaximumAddress; - ULONG BaseAddress; -#else - ULONG64 MinimumAddress; - ULONG64 MaximumAddress; - ULONG64 BaseAddress; -#endif - - PGET_RUNTIME_FUNCTION_CALLBACK Callback; - PVOID Context; - PWSTR OutOfProcessCallbackDll; - FUNCTION_TABLE_TYPE Type; - ULONG EntryCount; -} DYNAMIC_FUNCTION_TABLE, *PDYNAMIC_FUNCTION_TABLE; - -#endif // !_TARGET_X86_ - -// -// AMD64 -// -#ifdef _TARGET_AMD64_ - -#define RUNTIME_FUNCTION__BeginAddress(prf) (prf)->BeginAddress -#define RUNTIME_FUNCTION__SetBeginAddress(prf,address) ((prf)->BeginAddress = (address)) - -#define RUNTIME_FUNCTION__EndAddress(prf, ImageBase) (prf)->EndAddress - -#define RUNTIME_FUNCTION__GetUnwindInfoAddress(prf) (prf)->UnwindData -#define RUNTIME_FUNCTION__SetUnwindInfoAddress(prf,address) do { (prf)->UnwindData = (address); } while (0) -#define OFFSETOF__RUNTIME_FUNCTION__UnwindInfoAddress offsetof(T_RUNTIME_FUNCTION, UnwindData) - -#include "win64unwind.h" - -typedef -PEXCEPTION_ROUTINE -(RtlVirtualUnwindFn) ( - IN ULONG HandlerType, - IN ULONG64 ImageBase, - IN ULONG64 ControlPc, - IN PT_RUNTIME_FUNCTION FunctionEntry, - IN OUT PCONTEXT ContextRecord, - OUT PVOID *HandlerData, - OUT PULONG64 EstablisherFrame, - IN OUT PKNONVOLATILE_CONTEXT_POINTERS ContextPointers OPTIONAL - ); - -#ifndef FEATURE_PAL -extern RtlVirtualUnwindFn* RtlVirtualUnwind_Unsafe; -#else // !FEATURE_PAL -PEXCEPTION_ROUTINE -RtlVirtualUnwind_Unsafe( - IN ULONG HandlerType, - IN ULONG64 ImageBase, - IN ULONG64 ControlPc, - IN PT_RUNTIME_FUNCTION FunctionEntry, - IN OUT PCONTEXT ContextRecord, - OUT PVOID *HandlerData, - OUT PULONG64 EstablisherFrame, - IN OUT PKNONVOLATILE_CONTEXT_POINTERS ContextPointers OPTIONAL - ); -#endif // !FEATURE_PAL - -#endif // _TARGET_AMD64_ - -// -// X86 -// - -#ifdef _TARGET_X86_ -#ifndef FEATURE_PAL -// -// x86 ABI does not define RUNTIME_FUNCTION. Define our own to allow unification between x86 and other platforms. -// -typedef struct _RUNTIME_FUNCTION { - DWORD BeginAddress; - DWORD UnwindData; -} RUNTIME_FUNCTION, *PRUNTIME_FUNCTION; - -typedef struct _DISPATCHER_CONTEXT { - _EXCEPTION_REGISTRATION_RECORD* RegistrationPointer; -} DISPATCHER_CONTEXT, *PDISPATCHER_CONTEXT; - -#endif // !FEATURE_PAL - -#define RUNTIME_FUNCTION__BeginAddress(prf) (prf)->BeginAddress -#define RUNTIME_FUNCTION__SetBeginAddress(prf,addr) ((prf)->BeginAddress = (addr)) - -#ifdef WIN64EXCEPTIONS -#include "win64unwind.h" - -FORCEINLINE -DWORD -RtlpGetFunctionEndAddress ( - __in PT_RUNTIME_FUNCTION FunctionEntry, - __in TADDR ImageBase - ) -{ - PTR_UNWIND_INFO pUnwindInfo = (PTR_UNWIND_INFO)(ImageBase + FunctionEntry->UnwindData); - - return FunctionEntry->BeginAddress + pUnwindInfo->FunctionLength; -} - -#define RUNTIME_FUNCTION__EndAddress(prf, ImageBase) RtlpGetFunctionEndAddress(prf, ImageBase) - -#define RUNTIME_FUNCTION__GetUnwindInfoAddress(prf) (prf)->UnwindData -#define RUNTIME_FUNCTION__SetUnwindInfoAddress(prf, addr) do { (prf)->UnwindData = (addr); } while(0) - -EXTERN_C -NTSYSAPI -PEXCEPTION_ROUTINE -NTAPI -RtlVirtualUnwind ( - __in DWORD HandlerType, - __in DWORD ImageBase, - __in DWORD ControlPc, - __in PRUNTIME_FUNCTION FunctionEntry, - __inout PT_CONTEXT ContextRecord, - __out PVOID *HandlerData, - __out PDWORD EstablisherFrame, - __inout_opt PT_KNONVOLATILE_CONTEXT_POINTERS ContextPointers - ); -#endif // WIN64EXCEPTIONS - -#endif // _TARGET_X86_ - -#ifdef _TARGET_ARM_ -#include "daccess.h" - -// -// Define unwind information flags. -// - -#define UNW_FLAG_NHANDLER 0x0 /* any handler */ -#define UNW_FLAG_EHANDLER 0x1 /* filter handler */ -#define UNW_FLAG_UHANDLER 0x2 /* unwind handler */ - -// This function returns the length of a function using the new unwind info on arm. -// Taken from minkernel\ntos\rtl\arm\ntrtlarm.h. -FORCEINLINE -ULONG -RtlpGetFunctionEndAddress ( - __in PT_RUNTIME_FUNCTION FunctionEntry, - __in ULONG ImageBase - ) -{ - ULONG FunctionLength; - - FunctionLength = FunctionEntry->UnwindData; - if ((FunctionLength & 3) != 0) { - FunctionLength = (FunctionLength >> 2) & 0x7ff; - } else { - FunctionLength = *(PTR_ULONG)(ImageBase + FunctionLength) & 0x3ffff; - } - - return FunctionEntry->BeginAddress + 2 * FunctionLength; -} - -#define RUNTIME_FUNCTION__BeginAddress(FunctionEntry) ThumbCodeToDataPointer((FunctionEntry)->BeginAddress) -#define RUNTIME_FUNCTION__SetBeginAddress(FunctionEntry,address) ((FunctionEntry)->BeginAddress = DataPointerToThumbCode(address)) - -#define RUNTIME_FUNCTION__EndAddress(FunctionEntry, ImageBase) ThumbCodeToDataPointer(RtlpGetFunctionEndAddress(FunctionEntry, ImageBase)) - -#define RUNTIME_FUNCTION__SetUnwindInfoAddress(prf,address) do { (prf)->UnwindData = (address); } while (0) - -typedef struct _UNWIND_INFO { - // dummy -} UNWIND_INFO, *PUNWIND_INFO; - -EXTERN_C -NTSYSAPI -VOID -NTAPI -RtlUnwindEx ( - __in_opt PVOID TargetFrame, - __in_opt PVOID TargetIp, - __in_opt PEXCEPTION_RECORD ExceptionRecord, - __in PVOID ReturnValue, - __in PT_CONTEXT ContextRecord, - __in_opt PUNWIND_HISTORY_TABLE HistoryTable - ); - -EXTERN_C -NTSYSAPI -PEXCEPTION_ROUTINE -NTAPI -RtlVirtualUnwind ( - __in DWORD HandlerType, - __in DWORD ImageBase, - __in DWORD ControlPc, - __in PRUNTIME_FUNCTION FunctionEntry, - __inout PT_CONTEXT ContextRecord, - __out PVOID *HandlerData, - __out PDWORD EstablisherFrame, - __inout_opt PT_KNONVOLATILE_CONTEXT_POINTERS ContextPointers - ); - -#define UNW_FLAG_NHANDLER 0x0 - -#endif // _TARGET_ARM_ - -#ifdef _TARGET_ARM64_ -#include "daccess.h" - -#define UNW_FLAG_NHANDLER 0x0 /* any handler */ -#define UNW_FLAG_EHANDLER 0x1 /* filter handler */ -#define UNW_FLAG_UHANDLER 0x2 /* unwind handler */ - -// This function returns the RVA of the end of the function (exclusive, so one byte after the actual end) -// using the unwind info on ARM64. (see ExternalAPIs\Win9CoreSystem\inc\winnt.h) -FORCEINLINE -ULONG64 -RtlpGetFunctionEndAddress ( - __in PT_RUNTIME_FUNCTION FunctionEntry, - __in ULONG64 ImageBase - ) -{ - ULONG64 FunctionLength; - - FunctionLength = FunctionEntry->UnwindData; - if ((FunctionLength & 3) != 0) { - FunctionLength = (FunctionLength >> 2) & 0x7ff; - } else { - FunctionLength = *(PTR_ULONG64)(ImageBase + FunctionLength) & 0x3ffff; - } - - return FunctionEntry->BeginAddress + 4 * FunctionLength; -} - -#define RUNTIME_FUNCTION__BeginAddress(FunctionEntry) ((FunctionEntry)->BeginAddress) -#define RUNTIME_FUNCTION__SetBeginAddress(FunctionEntry,address) ((FunctionEntry)->BeginAddress = (address)) - -#define RUNTIME_FUNCTION__EndAddress(FunctionEntry, ImageBase) (RtlpGetFunctionEndAddress(FunctionEntry, (ULONG64)(ImageBase))) - -#define RUNTIME_FUNCTION__SetUnwindInfoAddress(prf,address) do { (prf)->UnwindData = (address); } while (0) - -typedef struct _UNWIND_INFO { - // dummy -} UNWIND_INFO, *PUNWIND_INFO; - -EXTERN_C -NTSYSAPI -PEXCEPTION_ROUTINE -NTAPI -RtlVirtualUnwind( - IN ULONG HandlerType, - IN ULONG64 ImageBase, - IN ULONG64 ControlPc, - IN PRUNTIME_FUNCTION FunctionEntry, - IN OUT PCONTEXT ContextRecord, - OUT PVOID *HandlerData, - OUT PULONG64 EstablisherFrame, - IN OUT PKNONVOLATILE_CONTEXT_POINTERS ContextPointers OPTIONAL - ); - -#ifndef IMAGE_FILE_MACHINE_ARM64 -#define IMAGE_FILE_MACHINE_ARM64 0xAA64 // ARM64 Little-Endian -#endif - -#ifndef IMAGE_REL_ARM64_BRANCH26 -#define IMAGE_REL_ARM64_BRANCH26 0x0003 // 26 bit offset << 2 & sign ext. for B & BL -#endif - -#ifndef IMAGE_REL_ARM64_PAGEBASE_REL21 -#define IMAGE_REL_ARM64_PAGEBASE_REL21 0x0004 // ADRP 21 bit PC-relative page address -#endif - -#ifndef IMAGE_REL_ARM64_PAGEOFFSET_12A -#define IMAGE_REL_ARM64_PAGEOFFSET_12A 0x0006 // ADD 12 bit page offset -#endif - -#endif - -#endif // CLRNT_H_ diff --git a/src/inc/clrprivbinderutil.h b/src/inc/clrprivbinderutil.h deleted file mode 100644 index d42f2b8d6..000000000 --- a/src/inc/clrprivbinderutil.h +++ /dev/null @@ -1,747 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -// - -// -// Contains helper types for assembly binding host infrastructure. - -#ifndef __CLRPRIVBINDERUTIL_H__ -#define __CLRPRIVBINDERUTIL_H__ - -#include "holder.h" -#include "internalunknownimpl.h" -#include "clrprivbinding.h" -#include "slist.h" -#ifdef FEATURE_COMINTEROP -#include "windowsstring.h" -#endif // FEATURE_COMINTEROP -#include "strongnameholders.h" - -//===================================================================================================================== -#define STANDARD_BIND_CONTRACT \ - CONTRACTL { \ - NOTHROW; \ - GC_TRIGGERS; \ - MODE_PREEMPTIVE; \ - } CONTRACTL_END - -//===================================================================================================================== -// Forward declarations -interface ICLRPrivAssembly; -typedef DPTR(ICLRPrivAssembly) PTR_ICLRPrivAssembly; -typedef DPTR(ICLRPrivBinder) PTR_ICLRPrivBinder; -class PEAssembly; -class AssemblySpec; - -//===================================================================================================================== -#define VALIDATE_CONDITION(condition, fail_op) \ - do { \ - _ASSERTE((condition)); \ - if (!(condition)) \ - fail_op; \ - } while (false) - -#define VALIDATE_PTR_RET(val) VALIDATE_CONDITION(val != nullptr, return E_POINTER) -#define VALIDATE_PTR_THROW(val) VALIDATE_CONDITION(val != nullptr, ThrowHR(E_POINTER)) -#define VALIDATE_ARG_RET(condition) VALIDATE_CONDITION(condition, return E_INVALIDARG) -#define VALIDATE_ARG_THROW(condition) VALIDATE_CONDITION(condition, ThrowHR(E_INVALIDARG)) - -//===================================================================================================================== -namespace CLRPrivBinderUtil -{ - //================================================================================================================= - enum BindFlags - { - BF_BindIL = 1, - BF_BindNI = 2, - BF_Default = BF_BindIL | BF_BindNI, - }; - - //================================================================================================================= - template - inline ItfT * ToInterface( - ObjT * && pObj) - { - STATIC_CONTRACT_THROWS; - - ItfT * pItf = nullptr; - IfFailThrow(pObj->QueryInterface(__uuidof(ItfT), (void **)&pItf)); - return pItf; - } - - //================================================================================================================= - template - inline ItfT * ToInterface_NoThrow( - ObjT * && pObj) - { - LIMITED_METHOD_CONTRACT; - - ItfT * pItf = nullptr; - if (FAILED(pObj->QueryInterface(__uuidof(ItfT), (void **)&pItf))) - { - return nullptr; - } - return pItf; - } - - //===================================================================================================================== - - //================================================================================================================= - // Used to create an identity-only ICLRPrivAssembly from an ICLRPrivBinder. This is currently used when - // creating dynamic assemblies as these use the parent assembly's ICLRPrivBinder object to provide binding - // functionaltiy. - - class CLRPrivBinderAsAssemblyWrapper : - public IUnknownCommon - { - public: - //----------------------------------------------------------------------------------------------------------------- - CLRPrivBinderAsAssemblyWrapper( - ICLRPrivBinder *pWrapped) - : _pWrapped(clr::SafeAddRef(pWrapped)) - { - STANDARD_VM_CONTRACT; - VALIDATE_ARG_THROW(pWrapped); - } - - //----------------------------------------------------------------------------------------------------------------- - // Forwards to wrapped binder. - STDMETHOD(BindAssemblyByName)( - IAssemblyName * pAssemblyName, - ICLRPrivAssembly ** ppAssembly) - { - WRAPPER_NO_CONTRACT; - return _pWrapped->BindAssemblyByName(pAssemblyName, ppAssembly); - } - - //----------------------------------------------------------------------------------------------------------------- - // Forwards to wrapped binder. - STDMETHOD(VerifyBind)( - IAssemblyName *pAssemblyName, - ICLRPrivAssembly *pAssembly, - ICLRPrivAssemblyInfo *pAssemblyInfo) - { - WRAPPER_NO_CONTRACT; - return _pWrapped->VerifyBind(pAssemblyName, pAssembly, pAssemblyInfo); - } - - //--------------------------------------------------------------------------------------------- - // Forwards to wrapped binder. - STDMETHOD(GetBinderFlags)( - DWORD *pBinderFlags) - { - WRAPPER_NO_CONTRACT; - return _pWrapped->GetBinderFlags(pBinderFlags); - } - - //----------------------------------------------------------------------------------------------------------------- - // Forwards to wrapped binder. - STDMETHOD(GetBinderID)( - UINT_PTR *pBinderId) - { - WRAPPER_NO_CONTRACT; - return _pWrapped->GetBinderID(pBinderId); - } - - //----------------------------------------------------------------------------------------------------------------- - // Forwards to wrapped binder. - STDMETHOD(FindAssemblyBySpec)( - LPVOID pvAppDomain, - LPVOID pvAssemblySpec, - HRESULT * pResult, - ICLRPrivAssembly ** ppAssembly) - { STATIC_CONTRACT_WRAPPER; return _pWrapped->FindAssemblyBySpec(pvAppDomain, pvAssemblySpec, pResult, ppAssembly); } - - //----------------------------------------------------------------------------------------------------------------- - // ICLRPrivAssembly method is unsupported. - STDMETHOD(IsShareable)( - BOOL * pbIsShareable) - { - LIMITED_METHOD_CONTRACT; - _ASSERTE_MSG(false, "CLRPrivBinderAsAssemblyWrapper does not support ICLRPrivAssembly methods (just ICLRPrivBinder ones)!"); - VALIDATE_ARG_RET(pbIsShareable); - *pbIsShareable = FALSE; - return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED); - } - - //----------------------------------------------------------------------------------------------------------------- - // ICLRPrivAssembly method is unsupported. - STDMETHOD(GetAvailableImageTypes)( - LPDWORD pdwImageTypes) - { - LIMITED_METHOD_CONTRACT; - _ASSERTE_MSG(false, "CLRPrivBinderAsAssemblyWrapper does not support ICLRPrivAssembly methods (just ICLRPrivBinder ones)!"); - VALIDATE_ARG_RET(pdwImageTypes); - *pdwImageTypes = 0; - return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED); - } - - //----------------------------------------------------------------------------------------------------------------- - // ICLRPrivAssembly method is unsupported. - STDMETHOD(GetImageResource)( - DWORD dwImageType, - DWORD* pdwImageType, - ICLRPrivResource ** ppIResource) - { - LIMITED_METHOD_CONTRACT; - _ASSERTE_MSG(false, "CLRPrivBinderAsAssemblyWrapper does not support ICLRPrivAssembly methods (just ICLRPrivBinder ones)!"); - VALIDATE_ARG_RET(pdwImageType); - *pdwImageType = 0; - return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED); - } - - private: - ReleaseHolder _pWrapped; - }; - - //================================================================================================================= - // Provides a struct that can be accessed at the QWORD, DWORD, or WORD level, and is structured - - struct AssemblyVersion - { -#if BIGENDIAN - union - { - UINT64 qwMajorMinorBuildRevision; - struct - { - union - { - DWORD dwMajorMinor; - struct - { - WORD wMajor; - WORD wMinor; - }; - }; - union - { - DWORD dwBuildRevision; - struct - { - WORD wBuild; - WORD wRevision; - }; - }; - }; - }; -#else - union - { - UINT64 qwMajorMinorBuildRevision; - struct - { - union - { - DWORD dwBuildRevision; - struct - { - WORD wRevision; - WORD wBuild; - }; - }; - union - { - DWORD dwMajorMinor; - struct - { - WORD wMinor; - WORD wMajor; - }; - }; - }; - }; -#endif - - // Default value is 0.0.0.0 - AssemblyVersion() - : qwMajorMinorBuildRevision(static_cast(0)) - { LIMITED_METHOD_CONTRACT; } - - // Copy constructor - AssemblyVersion(AssemblyVersion const & other) - : qwMajorMinorBuildRevision(other.qwMajorMinorBuildRevision) - { LIMITED_METHOD_CONTRACT; } - - // Initialize version using an IAssemblyName object. - HRESULT Initialize(IAssemblyName * pName); - - // Initialize version using an ICLRPrivAssemblyInfo object. - HRESULT Initialize(ICLRPrivAssemblyInfo * pInfo); - - // Relative ordering of versions. - static inline int Compare( - AssemblyVersion const & left, - AssemblyVersion const & right) - { - LIMITED_METHOD_CONTRACT; - - if (left.qwMajorMinorBuildRevision < right.qwMajorMinorBuildRevision) - return -1; - else if (left.qwMajorMinorBuildRevision == right.qwMajorMinorBuildRevision) - return 0; - else - return 1; - } - }; // struct AssemblyVersion - - inline bool operator ==(AssemblyVersion const & lhs, AssemblyVersion const & rhs) - { LIMITED_METHOD_CONTRACT; return lhs.qwMajorMinorBuildRevision == rhs.qwMajorMinorBuildRevision; } - - inline bool operator !=(AssemblyVersion const & lhs, AssemblyVersion const & rhs) - { LIMITED_METHOD_CONTRACT; return lhs.qwMajorMinorBuildRevision != rhs.qwMajorMinorBuildRevision; } - - inline bool operator <(AssemblyVersion const & lhs, AssemblyVersion const & rhs) - { LIMITED_METHOD_CONTRACT; return lhs.qwMajorMinorBuildRevision < rhs.qwMajorMinorBuildRevision; } - - inline bool operator <=(AssemblyVersion const & lhs, AssemblyVersion const & rhs) - { LIMITED_METHOD_CONTRACT; return lhs.qwMajorMinorBuildRevision <= rhs.qwMajorMinorBuildRevision; } - - inline bool operator >(AssemblyVersion const & lhs, AssemblyVersion const & rhs) - { LIMITED_METHOD_CONTRACT; return lhs.qwMajorMinorBuildRevision > rhs.qwMajorMinorBuildRevision; } - - inline bool operator >=(AssemblyVersion const & lhs, AssemblyVersion const & rhs) - { LIMITED_METHOD_CONTRACT; return lhs.qwMajorMinorBuildRevision >= rhs.qwMajorMinorBuildRevision; } - - //================================================================================================================= - // Encapsulates PublicKey value, can be initialized using a variety of data sources. - - struct PublicKey - { - // Defaults to empty value. - PublicKey() - : m_key(nullptr) - , m_key_owned(false) - , m_size((DWORD)-1) - { LIMITED_METHOD_CONTRACT; } - - // Construct directly from existing public key data. - PublicKey(PBYTE pbKey, DWORD cbKey) - : m_key(pbKey) - , m_key_owned(false) - , m_size(cbKey) - { LIMITED_METHOD_CONTRACT; } - - ~PublicKey() - { WRAPPER_NO_CONTRACT; Uninitialize(); } - - // Frees any public key data and resets to default value. - void Uninitialize() - { - LIMITED_METHOD_CONTRACT; - - if (m_key_owned) - { - delete [] m_key; - m_key_owned = false; - } - m_key = nullptr; - m_size = 0; - } - - // Initialize PK data form an ICLRPrivAssemblyInfo object. - HRESULT Initialize(ICLRPrivAssemblyInfo * pAssemblyInfo); - - // Returns PK data pointer. - inline BYTE const * GetKey() const - { LIMITED_METHOD_CONTRACT; return m_key; } - - // Returns size in bytes of the PK data. - inline DWORD GetSize() const - { LIMITED_METHOD_CONTRACT; return m_size; } - - private: - PBYTE m_key; - bool m_key_owned; - DWORD m_size; - }; - - //================================================================================================================= - // Encapsulates PublicKeyToken value, can be initialized using a variety of data sources. - // - // Constraints: assumes that non-empty PKT data will always be 8 bytes long. - // - - struct PublicKeyToken - { - PublicKeyToken() - : m_cbKeyToken(0) - { LIMITED_METHOD_CONTRACT; ZeroMemory(&m_rbKeyToken, sizeof(m_rbKeyToken)); } - - PublicKeyToken(PublicKeyToken const & other) - : m_cbKeyToken(other.m_cbKeyToken) - { LIMITED_METHOD_CONTRACT; CopyMemory(m_rbKeyToken, other.m_rbKeyToken, sizeof(m_rbKeyToken)); } - - // Initialize directly from PKT data. - HRESULT Initialize(BYTE * pbKeyToken, DWORD cbKeyToken); - - // Converts PK data to PKT data. - HRESULT Initialize(PublicKey const & pk); - - // Initialize using the PKT value contained by pName; returns S_FALSE if there is no associated PKT. - HRESULT Initialize(IAssemblyName * pName); - - // Initialize using the PK data contained by pInfo; returns S_FALSE if there is no associated PK. - HRESULT Initialize(ICLRPrivAssemblyInfo * pInfo); - - // PKT data. - BYTE const * GetToken() const - { LIMITED_METHOD_CONTRACT; return m_rbKeyToken; } - - // Size in bytes of the PKT (should always be 0 or 8). - DWORD GetSize() const - { LIMITED_METHOD_CONTRACT; return m_cbKeyToken; } - - private: - static const DWORD PUBLIC_KEY_TOKEN_LEN1 = 8; - BYTE m_rbKeyToken[PUBLIC_KEY_TOKEN_LEN1]; - DWORD m_cbKeyToken; - }; - - bool operator==(PublicKeyToken const & lhs, PublicKeyToken const & rhs); - - inline bool operator!=(PublicKeyToken const & lhs, PublicKeyToken const & rhs) - { WRAPPER_NO_CONTRACT; return !(lhs == rhs); } - - //================================================================================================================= - // Encapsulates data required for packaged assembly identity: simple name, version, and public key token. - // - // Constraints: assumes that the assembly simple name is no longer than _MAX_PATH - // - - struct AssemblyIdentity - { - AssemblyIdentity() - { LIMITED_METHOD_CONTRACT; Name[0] = W('\0'); } - - AssemblyIdentity(AssemblyIdentity const & other) - : Version(other.Version) - , KeyToken(other.KeyToken) - { LIMITED_METHOD_CONTRACT; CopyMemory(Name, other.Name, sizeof(Name)); } - - // Initialize from assembly simple name; default version and empty PKT values are used. - HRESULT Initialize(LPCWSTR wzName); - - // Initialize from an ICLRPrivAssemblyInfo object. - HRESULT Initialize(ICLRPrivAssemblyInfo * pAssemblyInfo); - - // Initialize from an IAssemblyName object. - HRESULT Initialize(IAssemblyName * pAssemblyName); - - // Initialize from an AssemblySpec object. - HRESULT Initialize(AssemblySpec * pSpec); - - // Assembly simple name - WCHAR Name[_MAX_PATH]; - - // Assembly version; defaults to 0.0.0.0. - CLRPrivBinderUtil::AssemblyVersion Version; - - // Assembly public key token; defaults to none. - CLRPrivBinderUtil::PublicKeyToken KeyToken; - }; - - //================================================================================================================= - HRESULT VerifyBind( - IAssemblyName *pRefAssemblyName, - ICLRPrivAssemblyInfo *pDefAssemblyInfo); - - //================================================================================================================= - HRESULT VerifyBind( - CLRPrivBinderUtil::AssemblyIdentity const & refIdentity, - CLRPrivBinderUtil::AssemblyIdentity const & defIdentity); - - //================================================================================================= - template - struct CLRPrivResourceBase : - public IUnknownCommon - { - //--------------------------------------------------------------------------------------------- - STDMETHOD(GetResourceType)( - IID *pIID) - { - LIMITED_METHOD_CONTRACT; - if (pIID == nullptr) - return E_INVALIDARG; - *pIID = __uuidof(ItfT); - return S_OK; - } - }; - - //================================================================================================================= - class CLRPrivResourcePathImpl : - public IUnknownCommon< ItfBase< CLRPrivResourceBase< ICLRPrivResourcePath > >, - ICLRPrivResourcePath > - { - public: - //--------------------------------------------------------------------------------------------- - CLRPrivResourcePathImpl(LPCWSTR wzPath); - - //--------------------------------------------------------------------------------------------- - LPCWSTR GetPath() - { return m_wzPath; } - - // - // ICLRPrivResourcePath methods - // - - //--------------------------------------------------------------------------------------------- - STDMETHOD(GetPath)( - DWORD cchBuffer, - LPDWORD pcchBuffer, - __inout_ecount_part(cchBuffer, *pcchBuffer) LPWSTR wzBuffer); - - private: - //--------------------------------------------------------------------------------------------- - NewArrayHolder m_wzPath; - }; - - //================================================================================================================= - class CLRPrivResourceStreamImpl : - public IUnknownCommon< ItfBase< CLRPrivResourceBase >, - ICLRPrivResourceStream> - { - public: - //--------------------------------------------------------------------------------------------- - CLRPrivResourceStreamImpl(IStream * pStream); - - //--------------------------------------------------------------------------------------------- - STDMETHOD(GetStream)( - REFIID riid, - LPVOID * ppvStream); - - private: - //--------------------------------------------------------------------------------------------- - ReleaseHolder m_pStream; - }; - - //================================================================================================================= - // Helper to prioritize binder errors. This class will ensure that all other errors have priority over - // CLR_E_BIND_UNRECOGNIZED_IDENTITY_FORMAT. This class should be used just like an HRESULT variable. - class BinderHRESULT - { - public: - BinderHRESULT() - : m_hr(S_OK) - {} - - BinderHRESULT(HRESULT hr) - : m_hr(hr) - {} - - operator HRESULT() const - { return m_hr; } - - BinderHRESULT & operator=(HRESULT hr) - { - // Always record change in success/failure status. - if (FAILED(hr) != FAILED(m_hr)) - m_hr = hr; - - if (FAILED(hr)) - { - if (SUCCEEDED(m_hr)) - m_hr = hr; - else if (m_hr == CLR_E_BIND_UNRECOGNIZED_IDENTITY_FORMAT) - m_hr = hr; - } - else - { - m_hr = hr; - } - return *this; - } - - private: - HRESULT m_hr; - }; // class BinderHRESULT - - //================================================================================================================= - // Types for WStringList (used in WinRT binders) - - typedef SListElem< PTR_WSTR > WStringListElem; - typedef DPTR(WStringListElem) PTR_WStringListElem; - typedef SList< WStringListElem, false /* = fHead default value */, PTR_WStringListElem > WStringList; - typedef DPTR(WStringList) PTR_WStringList; - - // Destroys list of strings (code:WStringList). - void WStringList_Delete(WStringList * pList); - -#ifndef DACCESS_COMPILE - //===================================================================================================================== - // Holder of allocated code:WStringList (helper class for WinRT binders - e.g. code:CLRPrivBinderWinRT::GetFileNameListForNamespace). - class WStringListHolder - { - public: - WStringListHolder(WStringList * pList = nullptr) - { - LIMITED_METHOD_CONTRACT; - m_pList = pList; - } - ~WStringListHolder() - { - LIMITED_METHOD_CONTRACT; - Destroy(); - } - - void InsertTail(LPCWSTR wszValue) - { - CONTRACTL - { - THROWS; - GC_NOTRIGGER; - MODE_ANY; - } - CONTRACTL_END; - - NewArrayHolder wszElemValue = DuplicateStringThrowing(wszValue); - NewHolder pElem = new WStringListElem(wszElemValue); - - if (m_pList == nullptr) - { - m_pList = new WStringList(); - } - - m_pList->InsertTail(pElem.Extract()); - // The string is now owned by the list - wszElemValue.SuppressRelease(); - } - - WStringList * GetValue() - { - LIMITED_METHOD_CONTRACT; - return m_pList; - } - - WStringList * Extract() - { - LIMITED_METHOD_CONTRACT; - - WStringList * pList = m_pList; - m_pList = nullptr; - return pList; - } - - private: - void Destroy() - { - LIMITED_METHOD_CONTRACT; - - if (m_pList != nullptr) - { - WStringList_Delete(m_pList); - m_pList = nullptr; - } - } - - private: - WStringList * m_pList; - }; // class WStringListHolder -#endif //!DACCESS_COMPILE - -#ifdef FEATURE_COMINTEROP - //===================================================================================================================== - // Holder of allocated array of HSTRINGs (helper class for WinRT binders - e.g. code:CLRPrivBinderWinRT::m_rgAltPaths). - class HSTRINGArrayHolder - { - public: - HSTRINGArrayHolder() - { - LIMITED_METHOD_CONTRACT; - - m_cValues = 0; - m_rgValues = nullptr; - } -#ifndef DACCESS_COMPILE - ~HSTRINGArrayHolder() - { - LIMITED_METHOD_CONTRACT; - Destroy(); - } - - // Destroys current array and allocates a new one with cValues elements. - void Allocate(DWORD cValues) - { - STANDARD_VM_CONTRACT; - - Destroy(); - _ASSERTE(m_cValues == 0); - - if (cValues > 0) - { - m_rgValues = new HSTRING[cValues]; - m_cValues = cValues; - - // Initialize the array values - for (DWORD i = 0; i < cValues; i++) - { - m_rgValues[i] = nullptr; - } - } - } -#endif //!DACCESS_COMPILE - - HSTRING GetAt(DWORD index) const - { - LIMITED_METHOD_CONTRACT; - return m_rgValues[index]; - } - - HSTRING * GetRawArray() - { - LIMITED_METHOD_CONTRACT; - return m_rgValues; - } - - DWORD GetCount() - { - LIMITED_METHOD_CONTRACT; - return m_cValues; - } - - private: -#ifndef DACCESS_COMPILE - void Destroy() - { - LIMITED_METHOD_CONTRACT; - - for (DWORD i = 0; i < m_cValues; i++) - { - if (m_rgValues[i] != nullptr) - { - WindowsDeleteString(m_rgValues[i]); - } - } - m_cValues = 0; - - if (m_rgValues != nullptr) - { - delete [] m_rgValues; - m_rgValues = nullptr; - } - } -#endif //!DACCESS_COMPILE - - private: - DWORD m_cValues; - HSTRING * m_rgValues; - }; // class HSTRINGArrayHolder - -#endif // FEATURE_COMINTEROP - - //////////////////////////////////////////////////////////////////////////////////////////////////// - ///// ----------------------------- Questionable stuff ------------------------------------------- - //////////////////////////////////////////////////////////////////////////////////////////////////// - - /** probably should be exposed on an instance (of something) method rather that magically calling GetAppDomain() **/ - ICLRPrivAssembly* RaiseAssemblyResolveEvent(IAssemblyName *pAssemblyName, ICLRPrivAssembly* pRequestingAssembly); - - /** Ultimately, only the binder can do ref-def matching, and it should be opaque to CLR. - This is not trivial to do, however, since we cannot do data conversion as the function is nofault **/ - BOOL CompareHostBinderSpecs(AssemblySpec* a1, AssemblySpec* a2); - - /** PLACEHOLDER - the same issue as CompareHostBinderSpecs applies to hashing assemblyspecs **/ -} // namespace CLRPrivBinderUtil - -#endif // __CLRPRIVBINDERUTIL_H__ diff --git a/src/inc/clrtypes.h b/src/inc/clrtypes.h deleted file mode 100644 index b0b1fc23f..000000000 --- a/src/inc/clrtypes.h +++ /dev/null @@ -1,422 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -// ================================================================================ -// Standard primitive types for CLR code -// -// This header serves as a platform layer containing all of the primitive types -// which we use across CLR implementation code. -// ================================================================================ - - -#ifndef CLRTYPES_H_ -#define CLRTYPES_H_ - -#if defined(_MSC_VER) && !defined(SOURCE_FORMATTING) && defined(FEATURE_CORESYSTEM) - // Prefer intsafe.h when available, which defines many of the MAX/MIN - // values below (which is why they are in #ifndef blocks). - #include -#endif - -#include "crtwrap.h" -#include "winwrap.h" -#include "staticcontract.h" -#include "static_assert.h" - -#if _WIN64 - #define POINTER_BITS 64 -#else - #define POINTER_BITS 32 -#endif - -// ================================================================================ -// Integral types - use these for all integral types -// These types are in ALL_CAPS. Each type has a _MIN and _MAX defined for it. -// ================================================================================ - -// -------------------------------------------------------------------------------- -// Use these types for fixed size integers: -// INT8 UINT8 INT16 UINT16 INT32 UINT32 INT64 UINT64 -// -------------------------------------------------------------------------------- - -#ifndef INT8_MAX - typedef signed char INT8; - typedef unsigned char UINT8; - typedef short INT16; - typedef unsigned short UINT16; - typedef int INT32; - typedef unsigned int UINT32; - typedef __int64 INT64; - typedef unsigned __int64 UINT64; - - #ifdef _MSC_VER - /* These macros must exactly match those in the Windows SDK's intsafe.h */ - #define INT8_MIN (-127i8 - 1) - #define INT16_MIN (-32767i16 - 1) - #define INT32_MIN (-2147483647i32 - 1) - #define INT64_MIN (-9223372036854775807i64 - 1) - - #define INT8_MAX 127i8 - #define INT16_MAX 32767i16 - #define INT32_MAX 2147483647i32 - #define INT64_MAX 9223372036854775807i64 - - #define UINT8_MAX 0xffui8 - #define UINT16_MAX 0xffffui16 - #define UINT32_MAX 0xffffffffui32 - #define UINT64_MAX 0xffffffffffffffffui64 - #else - #define INT8_MIN ((INT8)0x80) - #define INT16_MIN ((INT16)0x8000) - #define INT32_MIN ((INT32)0x80000000) - #define INT64_MIN ((INT64) I64(0x8000000000000000)) - - #define INT8_MAX ((INT8)0x7f) - #define INT16_MAX ((INT16)0x7fff) - #define INT32_MAX ((INT32)0x7fffffff) - #define INT64_MAX ((INT64) I64(0x7fffffffffffffff)) - - #define UINT8_MAX ((UINT8)0xffU) - #define UINT16_MAX ((UINT16)0xffffU) - #define UINT32_MAX ((UINT32)0xffffffffU) - #define UINT64_MAX ((UINT64) UI64(0xffffffffffffffff)) - #endif -#endif // !INT8_MAX - -// UINTX_MINs aren't defined in standard header files, -// so definition must be separately predicated. -#ifndef UINT8_MIN - #ifdef _MSC_VER - #define UINT8_MIN 0ui8 - #define UINT16_MIN 0ui16 - #define UINT32_MIN 0ui32 - #define UINT64_MIN 0ui64 - #else - #define UINT8_MIN ((UINT8)0U) - #define UINT16_MIN ((UINT16)0U) - #define UINT32_MIN ((UINT32)0U) - #define UINT64_MIN ((UINT64) UI64(0)) - #endif -#endif - - -// -------------------------------------------------------------------------------- -// Use these types for pointer-sized integral types -// SIZE_T SSIZE_T -// -// These types are the ONLY types which can be safely cast back and forth from a -// pointer. -// -------------------------------------------------------------------------------- - -#ifndef SIZE_T_MAX - #if NEED_POINTER_SIZED_TYPEDEFS - typedef size_t SIZE_T; - typedef ptrdiff_t SSIZE_T; - #endif - - #if POINTER_BITS == 64 - #define SIZE_T_MAX UINT64_MAX - #define SIZE_T_MIN UINT64_MIN - - #define SSIZE_T_MAX INT64_MAX - #define SSIZE_T_MIN INT64_MIN - #else - #define SIZE_T_MAX UINT32_MAX - #define SIZE_T_MIN UINT32_MIN - - #define SSIZE_T_MAX INT32_MAX - #define SSIZE_T_MIN INT32_MIN - #endif -#endif - -// -------------------------------------------------------------------------------- -// Non-pointer sized types -// COUNT_T SCOUNT_T -// -// Use these types for "large" counts or indexes which will not exceed 32 bits. They -// may also be used for pointer differences, if you can guarantee that the pointers -// are pointing to the same region of memory. (It can NOT be used for arbitrary -// pointer subtraction.) -// -------------------------------------------------------------------------------- - -#ifndef COUNT_T_MAX - typedef UINT32 COUNT_T; - typedef INT32 SCOUNT_T; - - #define COUNT_T_MAX UINT32_MAX - #define COUNT_T_MIN UINT32_MIN - - #define SCOUNT_T_MAX INT32_MAX - #define SCOUNT_T_MIN INT32_MIN -#endif - -// -------------------------------------------------------------------------------- -// Integral types with additional semantic content -// BOOL BYTE -// -------------------------------------------------------------------------------- - -#ifndef BYTE_MAX - #if NEED_BOOL_TYPEDEF - typedef bool BOOL; - #endif - - #define BOOL_MAX 1 - #define BOOL_MIN 0 - - #define TRUE 1 - #define FALSE 0 - - typedef UINT8 BYTE; - - #define BYTE_MAX UINT8_MAX - #define BYTE_MIN UINT8_MIN -#endif - -// -------------------------------------------------------------------------------- -// Character types -// CHAR SCHAR UCHAR WCHAR -// -------------------------------------------------------------------------------- - -typedef char CHAR; -typedef signed char SCHAR; -typedef unsigned char UCHAR; -typedef wchar_t WCHAR; - -typedef CHAR ASCII; -typedef CHAR ANSI; -typedef CHAR UTF8; - -// Standard C defines: - -// CHAR_MAX -// CHAR_MIN -// SCHAR_MAX -// SCHAR_MIN -// UCHAR_MAX -// UCHAR_MIN -// WCHAR_MAX -// WCHAR_MIN - -#ifndef ASCII_MAX - #define ASCII_MIN ((ASCII)0) - #define ASCII_MAX ((ASCII)127) - - #define ANSI_MIN ((ANSI)0) - #define ANSI_MAX ((ANSI)255) - - #define UTF8_MIN ((UTF8)0) - #define UTF8_MAX ((UTF8)255) -#endif - -// ================================================================================ -// Non-integral types -// These types are in ALL_CAPS. -// ================================================================================ - -// -------------------------------------------------------------------------------- -// Floating point types -// FLOAT DOUBLE -// -------------------------------------------------------------------------------- - -// ================================================================================ -// Runtime type definitions - these are guaranteed to be identical with the -// corresponding managed type -// ================================================================================ - -typedef WCHAR CLR_CHAR; -typedef INT8 CLR_I1; -typedef UINT8 CLR_U1; -typedef INT16 CLR_I2; -typedef UINT16 CLR_U2; -typedef INT32 CLR_I4; -typedef UINT32 CLR_U4; -typedef INT64 CLR_I8; -typedef UINT64 CLR_U8; -typedef FLOAT CLR_R4; -typedef DOUBLE CLR_R8; -typedef SSIZE_T CLR_I; -typedef SIZE_T CLR_U; - -#define CLR_CHAR_MAX WCHAR_MAX -#define CLR_CHAR_MIN WCHAR_MIN - -#define CLR_I1_MAX INT8_MAX -#define CLR_I1_MIN INT8_MIN - -#define CLR_U1_MAX UINT8_MAX -#define CLR_U1_MIN UINT8_MIN - -#define CLR_I2_MAX INT16_MAX -#define CLR_I2_MIN INT16_MIN - -#define CLR_U2_MAX UINT16_MAX -#define CLR_U2_MIN UINT16_MIN - -#define CLR_I4_MAX INT32_MAX -#define CLR_I4_MIN INT32_MIN - -#define CLR_U4_MAX UINT32_MAX -#define CLR_U4_MIN UINT32_MIN - -#define CLR_I8_MAX INT64_MAX -#define CLR_I8_MIN INT64_MIN - -#define CLR_U8_MAX UINT64_MAX -#define CLR_U8_MIN UINT64_MIN - -#define CLR_I_MAX SSIZE_T_MAX -#define CLR_I_MIN SSIZE_T_MIN - -#define CLR_U_MAX SIZE_T_MAX -#define CLR_U_MIN SIZE_T_MIN - - typedef bool CLR_BOOL; - -static_assert_no_msg(sizeof(CLR_BOOL) == 1); - -#define CLR_BOOL_MAX BOOL_MAX -#define CLR_BOOL_MIN BOOL_MIN - -#define CLR_NAN_32 0xFFC00000 -#define CLR_NAN_64 I64(0xFFF8000000000000) - -// ================================================================================ -// Simple utility functions -// ================================================================================ - -// Note that these routines are in terms of UINT, ULONG, and ULONG64, since those are -// the unsigned integral types the compiler overloads based on. - -// -------------------------------------------------------------------------------- -// Min/Max -// -------------------------------------------------------------------------------- - -template -T Min(T v1, T v2) -{ - STATIC_CONTRACT_LEAF; - STATIC_CONTRACT_SO_TOLERANT; - return v1 < v2 ? v1 : v2; -} - -template -T Max(T v1, T v2) -{ - STATIC_CONTRACT_LEAF; - STATIC_CONTRACT_SO_TOLERANT; - return v1 > v2 ? v1 : v2; -} - -// -------------------------------------------------------------------------------- -// Alignment bit twiddling macros - "alignment" must be power of 2 -// -// AlignUp - align value to given increment, rounding up -// AlignmentPad - amount adjusted by AlignUp -// AlignUp(value, x) == value + AlignmentPad(value, x) -// -// AlignDown - align value to given increment, rounding down -// AlignmentTrim - amount adjusted by AlignDown -// AlignDown(value, x) == value - AlignmentTrim(value, x) -// -------------------------------------------------------------------------------- - -inline UINT AlignUp(UINT value, UINT alignment) -{ - STATIC_CONTRACT_LEAF; - STATIC_CONTRACT_SO_TOLERANT; - STATIC_CONTRACT_SUPPORTS_DAC; - return (value+alignment-1)&~(alignment-1); -} - -#if defined(_MSC_VER) -inline ULONG AlignUp(ULONG value, UINT alignment) -{ - STATIC_CONTRACT_LEAF; - STATIC_CONTRACT_SO_TOLERANT; - STATIC_CONTRACT_SUPPORTS_DAC; - return (value+alignment-1)&~(alignment-1); -} -#endif - -inline UINT64 AlignUp(UINT64 value, UINT alignment) -{ - STATIC_CONTRACT_LEAF; - STATIC_CONTRACT_SO_TOLERANT; - STATIC_CONTRACT_SUPPORTS_DAC; - return (value+alignment-1)&~(UINT64)(alignment-1); -} - -inline UINT AlignDown(UINT value, UINT alignment) -{ - STATIC_CONTRACT_LEAF; - STATIC_CONTRACT_SO_TOLERANT; - STATIC_CONTRACT_SUPPORTS_DAC; - return (value&~(alignment-1)); -} - -#if defined(_MSC_VER) -inline ULONG AlignDown(ULONG value, UINT alignment) -{ - STATIC_CONTRACT_LEAF; - STATIC_CONTRACT_SO_TOLERANT; - STATIC_CONTRACT_SUPPORTS_DAC; - return (value&~(ULONG)(alignment-1)); -} -#endif - -inline UINT64 AlignDown(UINT64 value, UINT alignment) -{ - STATIC_CONTRACT_LEAF; - STATIC_CONTRACT_SO_TOLERANT; - STATIC_CONTRACT_SUPPORTS_DAC; - return (value&~(UINT64)(alignment-1)); -} - -inline UINT AlignmentPad(UINT value, UINT alignment) -{ - STATIC_CONTRACT_WRAPPER; - return AlignUp(value, alignment) - value; -} - -#if defined(_MSC_VER) -inline UINT AlignmentPad(ULONG value, UINT alignment) -{ - STATIC_CONTRACT_WRAPPER; - return AlignUp(value, alignment) - value; -} -#endif - -inline UINT AlignmentPad(UINT64 value, UINT alignment) -{ - STATIC_CONTRACT_WRAPPER; - return (UINT) (AlignUp(value, alignment) - value); -} - -inline UINT AlignmentTrim(UINT value, UINT alignment) -{ - STATIC_CONTRACT_LEAF; - STATIC_CONTRACT_SO_TOLERANT; - STATIC_CONTRACT_SUPPORTS_DAC; - return value&(alignment-1); -} - -#ifndef PLATFORM_UNIX -// For Unix this and the previous function get the same types. -// So, exclude this one. -inline UINT AlignmentTrim(ULONG value, UINT alignment) -{ - STATIC_CONTRACT_LEAF; - STATIC_CONTRACT_SO_TOLERANT; - STATIC_CONTRACT_SUPPORTS_DAC; - return value&(alignment-1); -} -#endif // PLATFORM_UNIX - -inline UINT AlignmentTrim(UINT64 value, UINT alignment) -{ - STATIC_CONTRACT_LEAF; - STATIC_CONTRACT_SO_TOLERANT; - STATIC_CONTRACT_SUPPORTS_DAC; - return ((UINT)value)&(alignment-1); -} - -#endif // CLRTYPES_H_ diff --git a/src/inc/complex.h b/src/inc/complex.h deleted file mode 100644 index 159c81d04..000000000 --- a/src/inc/complex.h +++ /dev/null @@ -1,80 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -// -// complex.h -// - -// -// Defines a basic complex number data type. We cannot use the standard C++ library's -// complex implementation, because the CLR links to the wrong CRT. -// - -#ifndef _COMPLEX_H_ -#define _COMPLEX_H_ - -#include - -// -// Default compilation mode is /fp:precise, which disables fp intrinsics. This causes us to pull in FP stuff (sqrt,etc.) from -// The CRT, and increases our download size. We don't need the extra precision this gets us, so let's switch to -// the intrinsic versions. -// -#ifdef _MSC_VER -#pragma float_control(precise, off, push) -#endif - - -class Complex -{ -public: - double r; - double i; - - Complex() : r(0), i(0) {} - Complex(double real) : r(real), i(0) {} - Complex(double real, double imag) : r(real), i(imag) {} - Complex(const Complex& other) : r(other.r), i(other.i) {} -}; - -inline Complex operator+(Complex left, Complex right) -{ - LIMITED_METHOD_CONTRACT; - return Complex(left.r + right.r, left.i + right.i); -} - -inline Complex operator-(Complex left, Complex right) -{ - LIMITED_METHOD_CONTRACT; - return Complex(left.r - right.r, left.i - right.i); -} - -inline Complex operator*(Complex left, Complex right) -{ - LIMITED_METHOD_CONTRACT; - return Complex( - left.r * right.r - left.i * right.i, - left.r * right.i + left.i * right.r); -} - -inline Complex operator/(Complex left, Complex right) -{ - LIMITED_METHOD_CONTRACT; - double denom = right.r * right.r + right.i * right.i; - return Complex( - (left.r * right.r + left.i * right.i) / denom, - (-left.r * right.i + left.i * right.r) / denom); -} - -inline double abs(Complex c) -{ - LIMITED_METHOD_CONTRACT; - return sqrt(c.r * c.r + c.i * c.i); -} - -#ifdef _MSC_VER -#pragma float_control(pop) -#endif - - -#endif //_COMPLEX_H_ diff --git a/src/inc/configuration.h b/src/inc/configuration.h deleted file mode 100644 index d8f8dff72..000000000 --- a/src/inc/configuration.h +++ /dev/null @@ -1,57 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -// -// -------------------------------------------------------------------------------------------------- -// configuration.h -// -// -// Access and update configuration values, falling back on legacy CLRConfig methods where necessary. -// -// -------------------------------------------------------------------------------------------------- - -#include "clrconfig.h" - -#ifndef __configuration_h__ -#define __configuration_h__ - -class Configuration -{ -public: - static void InitializeConfigurationKnobs(int numberOfConfigs, LPCWSTR *configNames, LPCWSTR *configValues); - - // Returns (in priority order): - // - The value of the ConfigDWORDInfo if it's set - // - The value of the ConfigurationKnob (searched by name) if it's set (performs a wcstoul). - // - The default set in the ConfigDWORDInfo - static DWORD GetKnobDWORDValue(LPCWSTR name, const CLRConfig::ConfigDWORDInfo& dwordInfo); - - // Returns (in priority order): - // - The value of the ConfigurationKnob (searched by name) if it's set (performs a wcstoul) - // - The default value passed in - static DWORD GetKnobDWORDValue(LPCWSTR name, DWORD defaultValue); - - // Returns (in priority order): - // - The value of the ConfigStringInfo if it's set - // - The value of the ConfigurationKnob (searched by name) if it's set - // - nullptr - static LPCWSTR GetKnobStringValue(LPCWSTR name, const CLRConfig::ConfigStringInfo& stringInfo); - - // Returns (in priority order): - // - The value of the ConfigurationKnob (searched by name) if it's set - // - nullptr - static LPCWSTR GetKnobStringValue(LPCWSTR name); - - // Returns (in priority order): - // - The value of the ConfigDWORDInfo if it's set (1 is true, anything else is false) - // - The value of the ConfigurationKnob (searched by name) if it's set (performs a wcscmp with "true"). - // - The default set in the ConfigDWORDInfo (1 is true, anything else is false) - static bool GetKnobBooleanValue(LPCWSTR name, const CLRConfig::ConfigDWORDInfo& dwordInfo); - - // Returns (in priority order): - // - The value of the ConfigurationKnob (searched by name) if it's set (performs a wcscmp with "true"). - // - The default value passed in - static bool GetKnobBooleanValue(LPCWSTR name, bool defaultValue); -}; - -#endif // __configuration_h__ diff --git a/src/inc/contract.h b/src/inc/contract.h deleted file mode 100644 index dd66d2a6e..000000000 --- a/src/inc/contract.h +++ /dev/null @@ -1,2598 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -// --------------------------------------------------------------------------- -// Contract.h -// - -// ! I am the owner for issues in the contract *infrastructure*, not for every -// ! CONTRACT_VIOLATION dialog that comes up. If you interrupt my work for a routine -// ! CONTRACT_VIOLATION, you will become the new owner of this file. -//-------------------------------------------------------------------------------- -// CONTRACTS - User Reference -// -// A CONTRACT is a container for a set of checked declarations about a -// function. Besides giving developers a "laundry list" of checks to -// make checking more complete, contracts compile these checks -// as hidden annotations into the checked executable that our static scanner -// uses to detect violations automatically. -// -// Contracts can be dynamic or static. Dynamic contracts perform runtime checks -// as well as being visible to the static scanner. Static contracts generate no -// runtime code but are still visible to the scanner. Dynamic contracts are -// preferred unless perf or other considerations preclude them. -// -// The following annotations can appear in contracts: -// -// -// THROWS an exception might be thrown out of the function -// -or- NOTHROW an exception will NOT be thrown out of the function -// -// -// -// INJECT_FAULT(statement) function might require its caller to handle an OOM -// -or- FAULT_FORBID function will NOT require its caller to handle an OOM -// -// -// -// GC_TRIGGERS the function can trigger a GC -// -or- GC_NOTRIGGER the function will never trigger a GC provided its -// called in coop mode. -// -// -// MODE_COOPERATIVE the function requires Cooperative GC mode on entry -// -or- MODE_PREEMPTIVE the function requires Preemptive GC mode on entry -// -or- MODE_ANY the function can be entered in either mode -// -// LOADS_TYPE(level) the function promises not to load any types beyond "level" -// -// SO_INTOLERANT the function cannot tolerate an SO at any point and must run behind an -// an SO probe via BEGIN_SO_INTOLERANT_XXX. This is the default. We want most -// of our code to run behind an SO probe. The only time you need to explicitly -// mark something as SO_INTOLERANT is if the static analysis tool incorrectly -// flags it as an entry point. -// -or- SO_TOLERANT the function can tolerate an SO. It either does not update any global state -// that needs to be cleaned up should a random SO occur, or it protects those -// updates behind an SO probe. -// -or- SO_NOT_MAINLINE the function is not hardened to SO and should never run on a managed thread -// where we need to be hardened to SO. You can use this for functions that run -// only for ngen or Win9X etc. -// -// CAN_TAKE_LOCK the function has a code path that takes a lock -// _or_ (CAN_TAKE_LOCK and CANNOT_RETAKE_LOCK) -// the function has a code path that takes a lock, but never tries to reenter -// locks held at the time this function was called. -// -or- CANNOT_TAKE_LOCK the function will never allow a lock to be taken -// -or- the default is WRAPPER(CAN_TAKE_LOCK). i.e., if any callees take locks, -// then it's ok for this function to as well. If LIMITED_METHOD_CONTRACT is specified, -// however, then CANNOT_TAKE_LOCK is assumed. -// -// EE_THREAD_NOT_REQUIRED the function does not assume an EE Thread object is available in TLS. -// Either GetThread() is never called, or any code path that requires a Thread -// has another code path that deals with the absence of a Thread. Any call to -// to GetThread() must be bracketed with BEGIN_GETTHREAD_ALLOWED / -// END_GETTHREAD_ALLOWED to avoid bogus asserts (the short-form -// GetThreadNULLOk() may be used as well). However, this is only allowed if visual -// inspection of the call site makes it patently obvious that the function deals -// appropriately with the GetThread() == NULL case. -// -or- EE_THREAD_REQUIRED the function requires an EE Thread object in TLS (i.e., GetThread() != NULL) -// If this contract is used, we will ASSERT on entry to the function that -// GetThread() != NULL. -// -or- the default is DISABLED(EE_THREAD_REQUIRED). i.e., we do not assert -// GetThread() != NULL on entry to the function and do not assert on any -// unprotected uses of GetThread(). -// See code:GetThreadGenericFullCheck for info on how these -// contracts are enforced. -// -// SUPPORTS_DAC The function has been written to be callable from out-of-process using DAC. -// In builds where DACCESS_COMPILE is defined, such functions can only call -// other such functions (and a few primitives like new). Functions that support -// DAC must be carefully written to conform to the rules in daccess.h. -// -// SUPPORTS_DAC_HOST_ONLY The function and its call graph has been written to be callable from out of process -// using DAC, but it differs from SUPPORTS_DAC in that these functions won't perform -// any marshalling. Because it does no marshalling, SUPPORTS_DAC_HOST_ONLY functions -// and their call graph won't be checked by DacCop. This should only be used by utility -// functions which will never marshal anything. -// -// PRECONDITION(X) - generic CHECK or BOOL expression which should be true -// on function entry -// -// POSTCONDITION(X) - generic CHECK or BOOL expression which should be true -// on function entry. Note that variable RETVAL will be -// available for use in the expression. -// -// -// INSTANCE_CHECK - equivalent of: -// PRECONDITION(CheckPointer(this)); -// POSTCONDITION(CheckInvariant(this)); -// INSTANCE_CHECK_NULL - equivalent of: -// PRECONDITION(CheckPointer(this, NULL_OK)); -// POSTCONDITION(CheckInvariant(this, NULL_OK)); -// CONSTRUCTOR_CHECK - equivalent of: -// POSTCONDITION(CheckPointer(this)); -// DESTRUCTOR_CHECK - equivalent of: -// PRECONDITION(CheckPointer(this)); -// -// -// -// -// Contracts come in the following flavors: -// -// Dynamic: -// CONTRACTL the standard version used for all dynamic contracts -// except those including postconditions. -// -// CONTRACT(rettype) an uglier version of CONTRACTL that's unfortunately -// needed to support postconditions. You must specify -// the correct return type and it cannot be "void." -// (Use CONTRACT_VOID instead) You must use the -// RETURN macro rather than the "return" keyword. -// -// CONTRACT_VOID you can't supply "void" to a CONTRACT - use this -// instead. -// -// Static: -// LIMITED_METHOD_CONTRACT -// A static contract equivalent to NOTHROW/GC_NOTRIGGER/FORBID_FAULT/MODE_ANY. -// Use only for trivial functions that call only functions with LIMITED_METHOD_CONTRACTs -// (as long as there is no cycle that may introduce infinite recursion). -// -// STATIC_CONTRACT_THROWS -// STATIC_CONTRACT_NOTHROW -// STATIC_CONTRACT_GC_TRIGGERS -// STATIC_CONTRACT_GCNOTRIGGER -// STATIC_CONTRACT_FAULT -// STATIC_CONTRACT_FORBID_FAULT -// STATIC_CONTRACT_SO_INTOLERANT -// STATIC_CONTRACT_SO_TOLERANT -// STATIC_CONTRACT_SO_NOT_MAINLINE -// use to implement statically checkable contracts -// when runtime contracts cannot be used. -// -// -// WRAPPER(annotation) -// -// When a function does not explicitly caused a condition, use the WRAPPER macro around -// the declaration. This implies that the function is dependent on the functions it calls -// for its behaviour, and guarantees nothing. -// -// -// CONTRACT_VIOLATION(violationmask): -// -// A bandaid used to suppress contract assertions. A contract violation -// is always a bug and you're expected to remove it before shipping. -// If a violation cannot be fixed immediately, however, it's better -// to use this on the offending callsite than to disable a contract entirely. -// -// The violationmask can be one or more of the following OR'd together. -// -// ThrowsViolation -// GCViolation -// ModeViolation -// FaultViolation -// SOToleranceViolation -// FaultNotFatal -// HostViolation -// LoadsTypeViolation -// TakesLockViolation -// -// The associated assertion will be suppressed until you leave the scope -// containing the CONTRACT_VIOLATION. Note, however, that any called -// function that redeclares the associated annotation reinstates -// the assert for the scope of *its* call. This prevents a CONTRACT_VIOLATION -// placed at the root of a calltree from decimating our entire protection. -// -// -// PERMANENT_CONTRACT_VIOLATION(violationmask, permanentContractViolationReason): -// -// Like a CONTRACT_VIOLATION but also indicates that the violation was a deliberate decision -// and we don't plan on removing the violation in the next release. The reason -// for the violation should be given as the second parameter to the macro. Reasons -// are currently for documentation purposes only and do not have an effect on the binary. -// Valid values are listed below in the definition of PermanentContractViolationReason. -// -// -// CONDITIONAL_CONTRACT_VIOLATION(violationmask, condition): -// -// Similar to CONTRACT_VIOLATION, but only suppresses the contract if the -// condition evaluates to non-zero. The need for this macro should be very -// rare, but it can be useful if a contract should be suppressed based on a -// condition known only at run-time. For example, if a particular test causes -// call sequences never expected by real scenarios, you may want to suppress -// resulting violations, but only when that test is run. -// -// WRAPPER_NO_CONTRACT -// -// A do-nothing contract used by functions that trivially wrap another. -// -// -// "LEGACY" stuff - these features have been mostly superceded by better solutions -// so their use should be discouraged. -// -// -// DISABLED(annotation) -// -// Indicates that a condition is supposed to be checked but is being suppressed -// due to some temporary bug. The more surgical CONTRACT_VIOLATION is -// preferred over DISABLED. -// -// UNCHECKED(annotation) -// -// Indicates that a condition is supposed to be checked but is being suppressed -// due for perf reasons. Use STATIC_CONTRACT over this. -// -// -// Default values: -// If you don't specify certain annotaions, you get defaults. -// - THROWS/NOTHROW defaults to THROWS -// - GCTRIGGERS/GCNOTRIGGER defaults to GCTRIGGERS within the VM directory -// and to no check otherwise -// - INJECT/FORBID_FAULT defaults to no check -// - MODE defaults to MODE_ANY -// -// The problem is that defaults don't work well with static contracts. -// The scanner will always treat a missing annotation as DISABLED. -// New code should not rely on defaults. Explicitly state your invariants. -// -// -//-------------------------------------------------------------------------------- - - - - -#ifndef CONTRACT_H_ -#define CONTRACT_H_ - -#ifdef _MSC_VER -#pragma warning(disable:4189) //local variable is initialized but not referenced -#endif - - -// We only enable contracts in _DEBUG builds -#if defined(_DEBUG) && !defined(DISABLE_CONTRACTS) -#define ENABLE_CONTRACTS_DATA -#endif - -// Also, we won't enable contracts if this is a DAC build. -// @ARMTODO: Disable for ARM for now, contracts slow down the debug build far too much -#if defined(ENABLE_CONTRACTS_DATA) && !defined(DACCESS_COMPILE) && !defined(CROSS_COMPILE) && !defined(_TARGET_ARM_) -#define ENABLE_CONTRACTS -#endif - -// Finally, only define the implementaiton parts of contracts if this isn't a DAC build. -#if defined(_DEBUG_IMPL) && defined(ENABLE_CONTRACTS) -#define ENABLE_CONTRACTS_IMPL -#endif - -#include "specstrings.h" -#include "clrtypes.h" -#include "malloc.h" -#include "check.h" -#include "debugreturn.h" -#include "staticcontract.h" - -#ifdef ENABLE_CONTRACTS_DATA - -#include "eh.h" - -// We chain these onto a stack to give us a stack trace of contract assertions (useful -// when the bug report doesn't contain valid symbols) - -struct ContractStackRecord -{ - ContractStackRecord *m_pNext; - const char *m_szFunction; - const char *m_szFile; - int m_lineNum; - UINT m_testmask; // Bitmask of Contract::TestEnum bitsf - const char *m_construct; // The syntactic construct that pushed this thing -}; - -class CrstBase; - -// The next few enums / structs are used to keep track of all kinds of locks -// currently taken by the current thread (crsts, spinlocks, CLR critical sections). -// Across the VM, there are still multiple counts of locks. The lock counts in these -// contract structs are used to verify consistency of lock take/release in EE code, and -// for contracts. Both user and EE locks are tracked here, but it's EE code consistency -// we're verifying. The Thread object keeps its own counts as well, primarily of user -// locks for implementing thread abort & escalation policy. We tried to have the Thread -// counts also be used for consistency checking, but that doesn't work. Thread counters -// have the following behavior that hurts our internal consistency checks: -// - They only count user locks. -// - Counters are reset & restored as we leave and return to AppDomains - -// An array of these is stored in DbgStateLockData::m_rgTakenLockInfos -// to remember which locks we've taken. If you hit an assert that -// indicates we're exiting locks in the wrong order, or that locks were -// taken when we expected none to be taken, then you can use -// DbgStateLockData::m_rgTakenLockInfos to see the locks we know about. -struct TakenLockInfo -{ - // Generally, this will be a pointer to the lock, but really it's just - // a value that identifies which lock is taken. Ya see, sometimes we don't - // have a lock pointer handy (e.g., if the lock is based on a GC object, - // which has no persistent object pointer we can use). Look at the source - // indicated by m_szFile / m_lineNum to see what was specified as m_pvLock. - // - // A common case is that the lock is just a Crst, so to aid debugging, we - // also include a statically typed version of this pointer (m_pCrstBase) just - // for Crsts. Again, you'll want look at m_szFile / m_lineNum to see how to - // interpret this union. - union - { - void * m_pvLock; - CrstBase * m_pCrstBase; - }; - - // File & line of the *LOCK_TAKEN* macro that added this lock to our list - const char * m_szFile; - int m_lineNum; -}; - -enum DbgStateLockType -{ - // EE locks (used to sync EE structures). These do not include - // CRST_HOST_BREAKABLE Crsts, and are thus not held while managed - // code runs - kDbgStateLockType_EE, - - // CRST_HOST_BREAKABLE Crsts. These can be held while arbitrary - // managed code runs. - kDbgStateLockType_HostBreakableCrst, - - // User locks (e.g., Monitor.Enter, ReaderWriterLock class) - kDbgStateLockType_User, - - // add more lock types here - - kDbgStateLockType_Count -}; - -// This keeps track of how many locks, and which locks, are currently owned -// by the current thread. There is one instance of this structure per -// thread (no EE Thread object required). This is in contrast to the -// ClrDebugState structure, which is instantiated once per function -// on the stack. Reason is that ClrDebugState resets its state on exit -// of function (Contract destructor reinstates previous ClrDebugState), whereas -// we want DbgStateLockData to persist across function enters & exits. -struct DbgStateLockData -{ - // When a lock is taken, we keep track of its pointer and file/line# when it - // was added in a static-size array DbgStateLockData::m_rgTakenLockInfos. This is - // the size of that array, and therefore indicates the maximum number of locks we - // expect one thread to hold at the same time. If we should exceed this limit, - // we'll lose this data for the latter locks that exceed this limit - // (though still maintaining an accurate *count* of locks). - static const int kMaxAllowedSimultaneousLocks = 20; - - // Count of locks taken, separately by type - UINT m_rgcLocksTaken[kDbgStateLockType_Count]; - - // List of the specific locks that have been taken (all DbgStateLockTypes - // intermingled), in the order they were taken. If we exceed the elements - // in the array, we just won't track the latter locks in here (though they are - // included in the counts above) - TakenLockInfo m_rgTakenLockInfos[kMaxAllowedSimultaneousLocks]; - - void SetStartingValues(); - void LockTaken(DbgStateLockType dbgStateLockType, - UINT cEntrances, - void * pvLock, - __in_z const char * szFunction, - __in_z const char * szFile, - int lineNum); - void LockReleased(DbgStateLockType dbgStateLockType, UINT cExits, void * pvLock); - UINT GetLockCount(DbgStateLockType dbgStateLockType); - UINT GetCombinedLockCount(); -}; - -// This struct contains all lock contract information. It is created and destroyed along with -// ClrDebugState. m_pLockData points to a DbgStateLockData object that is allocated per thread -// and persists across function enters and exists. -struct DbgStateLockState -{ -private: - // Count of locks taken at the time the function with CANNOT_RETAKE_LOCK contract - // was called - UINT m_cLocksEnteringCannotRetakeLock; - - DbgStateLockData * m_pLockData; // How many and which locks are currently taken on this thread - -public: - void SetStartingValues(); - void OnEnterCannotRetakeLockFunction(); - BOOL IsLockRetaken(void * pvLock); - BOOL IsSafeToRelease(UINT cReleases); - void SetDbgStateLockData(DbgStateLockData * pDbgStateLockData); - DbgStateLockData * GetDbgStateLockData(); -}; - - -#define CONTRACT_BITMASK_OK_TO_THROW 0x1 << 0 -#define CONTRACT_BITMASK_FAULT_FORBID 0x1 << 1 -#define CONTRACT_BITMASK_HOSTCALLS 0x1 << 2 -#define CONTRACT_BITMASK_SOTOLERANT 0x1 << 3 -#define CONTRACT_BITMASK_DEBUGONLY 0x1 << 4 -#define CONTRACT_BITMASK_SONOTMAINLINE 0x1 << 5 -#define CONTRACT_BITMASK_ALLOWGETTHREAD 0x1 << 6 -#define CONTRACT_BITMASK_OK_TO_LOCK 0x1 << 7 -#define CONTRACT_BITMASK_OK_TO_RETAKE_LOCK 0x1 << 8 - - -#define CONTRACT_BITMASK_IS_SET(whichbit) ((m_flags & (whichbit)) != 0) -#define CONTRACT_BITMASK_SET(whichbit) (m_flags |= (whichbit)) -#define CONTRACT_BITMASK_RESET(whichbit) (m_flags &= ~(whichbit)) -#define CONTRACT_BITMASK_UPDATE(whichbit, value) ((value)?CONTRACT_BITMASK_SET(whichbit):CONTRACT_BITMASK_RESET(whichbit)) - - -// Stored in the FLS under TlsIdx_ClrDebugState. -struct ClrDebugState -{ -private: - UINT_PTR m_flags; - UINT_PTR m_violationmask; // Current CONTRACT_VIOLATIONS in effect - ContractStackRecord *m_pContractStackTrace; - UINT m_GCNoTriggerCount; - UINT m_GCForbidCount; - UINT m_maxLoadTypeLevel; // taken from enum ClassLoadLevel - BOOL m_allowGetThread; // TRUE if GetThread() is ok in this scope -#ifdef FEATURE_STACK_PROBE //StackMarkerStack required only when SO infrastructure is enabled - /* Used to validate backout stack consumption required for StackOverflow infrastructure */ - StackMarkerStack m_StackMarkerStack; // The stack of stack markers -#endif - DbgStateLockState m_LockState; - -public: - // Use an explicit Init rather than ctor as we don't want automatic - // construction of the ClrDebugState embedded inside the contract. - void SetStartingValues() - { - m_violationmask = 0; // No violations allowed - - // Default is we're in a THROWS scope. This is not ideal, but there are - // just too many places that I'd have to go clean up right now - // (hundreds) in order to make this FALSE by default. - // Faults not forbidden (an unfortunate default but - // we'd never get this debug infrastructure bootstrapped otherwise.) - // We start out in SO-tolerant mode and must probe before entering SO-intolerant - // any global state updates. - // Initial mode is non-debug until we say otherwise - // Everthing defaults to mainline - // By default, GetThread() is perfectly fine to call - // By default, it's ok to take a lock (or call someone who does) - m_flags = CONTRACT_BITMASK_OK_TO_THROW| - CONTRACT_BITMASK_HOSTCALLS| - CONTRACT_BITMASK_SOTOLERANT| - CONTRACT_BITMASK_ALLOWGETTHREAD| - CONTRACT_BITMASK_OK_TO_LOCK| - CONTRACT_BITMASK_OK_TO_RETAKE_LOCK; - - m_pContractStackTrace = NULL; // At top of stack, no contracts in force - m_GCNoTriggerCount = 0; - m_GCForbidCount = 0; - - m_maxLoadTypeLevel = ((UINT)(-1)); // ideally CLASS_LOAD_LEVEL_FINAL but we don't have access to that #define, so - // the max integer value will do as a substitute. - - m_allowGetThread = TRUE; // By default, GetThread() is perfectly fine to call - -#ifdef FEATURE_STACK_PROBE - m_StackMarkerStack.Init(); -#endif - - m_LockState.SetStartingValues(); - } - - void CheckOkayToThrow(__in_z const char *szFunction, __in_z const char *szFile, int lineNum); // Asserts if its not okay to throw. - BOOL CheckOkayToThrowNoAssert(); // Returns if OK to throw - - //--// - - UINT_PTR* ViolationMaskPtr() - { - return &m_violationmask; - } - - UINT_PTR ViolationMask() - { - return m_violationmask; - } - - void ViolationMaskSet( UINT_PTR value ) - { - m_violationmask |= value; - } - - void ViolationMaskReset( UINT_PTR value ) - { - m_violationmask &= ~value; - } - - //--// - - BOOL IsOkToThrow() - { - return CONTRACT_BITMASK_IS_SET(CONTRACT_BITMASK_OK_TO_THROW); - } - - void SetOkToThrow() - { - CONTRACT_BITMASK_SET(CONTRACT_BITMASK_OK_TO_THROW); - } - - BOOL SetOkToThrow( BOOL value ) - { - BOOL prevState = CONTRACT_BITMASK_IS_SET(CONTRACT_BITMASK_OK_TO_THROW); - CONTRACT_BITMASK_UPDATE(CONTRACT_BITMASK_OK_TO_THROW, value); - return prevState; - } - - void ResetOkToThrow() - { - CONTRACT_BITMASK_RESET(CONTRACT_BITMASK_OK_TO_THROW); - } - //--// - - BOOL IsFaultForbid() - { - return CONTRACT_BITMASK_IS_SET(CONTRACT_BITMASK_FAULT_FORBID); - } - - - void SetFaultForbid() - { - CONTRACT_BITMASK_SET(CONTRACT_BITMASK_FAULT_FORBID); - } - - BOOL SetFaultForbid(BOOL value) - { - BOOL prevState = CONTRACT_BITMASK_IS_SET(CONTRACT_BITMASK_FAULT_FORBID); - CONTRACT_BITMASK_UPDATE(CONTRACT_BITMASK_FAULT_FORBID, value); - return prevState; - } - - void ResetFaultForbid() - { - CONTRACT_BITMASK_RESET(CONTRACT_BITMASK_FAULT_FORBID); - } - - //--// - BOOL IsHostCaller() - { - return CONTRACT_BITMASK_IS_SET(CONTRACT_BITMASK_HOSTCALLS); - } - - void SetHostCaller() - { - CONTRACT_BITMASK_SET(CONTRACT_BITMASK_HOSTCALLS); - } - - - BOOL SetHostCaller(BOOL value) - { - BOOL prevState = CONTRACT_BITMASK_IS_SET(CONTRACT_BITMASK_HOSTCALLS); - CONTRACT_BITMASK_UPDATE(CONTRACT_BITMASK_HOSTCALLS,value); - return prevState; - } - - void ResetHostCaller() - { - CONTRACT_BITMASK_RESET(CONTRACT_BITMASK_HOSTCALLS); - } - -#ifdef FEATURE_STACK_PROBE //SO contract functions only required when SO infrastructure is enabled - //--// - BOOL IsSOTolerant() - { - return CONTRACT_BITMASK_IS_SET(CONTRACT_BITMASK_SOTOLERANT); - } - - void SetSOTolerance() - { - CONTRACT_BITMASK_SET(CONTRACT_BITMASK_SOTOLERANT); - } - - BOOL SetSOTolerance(BOOL tolerance) - { - BOOL prevState = CONTRACT_BITMASK_IS_SET(CONTRACT_BITMASK_SOTOLERANT); - CONTRACT_BITMASK_UPDATE(CONTRACT_BITMASK_SOTOLERANT,tolerance); - return prevState; - } - - void ResetSOTolerance() - { - CONTRACT_BITMASK_RESET(CONTRACT_BITMASK_SOTOLERANT); - } - -#endif - - //--// - BOOL IsDebugOnly() - { - STATIC_CONTRACT_WRAPPER; - return CONTRACT_BITMASK_IS_SET(CONTRACT_BITMASK_DEBUGONLY); - } - - void SetDebugOnly() - { - STATIC_CONTRACT_WRAPPER; - CONTRACT_BITMASK_SET(CONTRACT_BITMASK_DEBUGONLY); - } - - BOOL SetDebugOnly(BOOL value) - { - STATIC_CONTRACT_WRAPPER; - BOOL prevState = CONTRACT_BITMASK_IS_SET(CONTRACT_BITMASK_DEBUGONLY); - CONTRACT_BITMASK_UPDATE(CONTRACT_BITMASK_DEBUGONLY,value); - return prevState; - } - - void ResetDebugOnly() - { - STATIC_CONTRACT_LIMITED_METHOD; - CONTRACT_BITMASK_RESET(CONTRACT_BITMASK_DEBUGONLY); - } - - #ifdef FEATURE_STACK_PROBE - //--// - BOOL IsSONotMainline() - { - return CONTRACT_BITMASK_IS_SET(CONTRACT_BITMASK_SONOTMAINLINE); - } - - void SetSONotMainline() - { - CONTRACT_BITMASK_SET(CONTRACT_BITMASK_SONOTMAINLINE); - } - - BOOL SetSONotMainline(BOOL value) - { - BOOL prevState = CONTRACT_BITMASK_IS_SET(CONTRACT_BITMASK_SONOTMAINLINE); - CONTRACT_BITMASK_UPDATE(CONTRACT_BITMASK_SONOTMAINLINE,value); - return prevState; - } - - void ResetSONotMainline() - { - CONTRACT_BITMASK_RESET(CONTRACT_BITMASK_SONOTMAINLINE); - } -#endif - - //--// - BOOL IsGetThreadAllowed() - { - return CONTRACT_BITMASK_IS_SET(CONTRACT_BITMASK_ALLOWGETTHREAD); - - } - void SetGetThreadAllowed() - { - CONTRACT_BITMASK_SET(CONTRACT_BITMASK_ALLOWGETTHREAD); - } - - - BOOL SetGetThreadAllowed(BOOL value) - { - BOOL prevState = CONTRACT_BITMASK_IS_SET(CONTRACT_BITMASK_ALLOWGETTHREAD); - CONTRACT_BITMASK_UPDATE(CONTRACT_BITMASK_ALLOWGETTHREAD,value); - return prevState; - } - - void ResetGetThreadAllowed() - { - CONTRACT_BITMASK_RESET(CONTRACT_BITMASK_ALLOWGETTHREAD); - } - - //--// - BOOL IsOkToLock() - { - return CONTRACT_BITMASK_IS_SET(CONTRACT_BITMASK_OK_TO_LOCK); - } - - void SetOkToLock() - { - CONTRACT_BITMASK_SET(CONTRACT_BITMASK_OK_TO_LOCK); - } - - BOOL SetOkToLock( BOOL value ) - { - BOOL prevState = CONTRACT_BITMASK_IS_SET(CONTRACT_BITMASK_OK_TO_LOCK); - CONTRACT_BITMASK_UPDATE(CONTRACT_BITMASK_OK_TO_LOCK, value); - return prevState; - } - - void ResetOkToLock() - { - CONTRACT_BITMASK_RESET(CONTRACT_BITMASK_OK_TO_LOCK); - } - - //--// - BOOL IsOkToRetakeLock() - { - return CONTRACT_BITMASK_IS_SET(CONTRACT_BITMASK_OK_TO_RETAKE_LOCK); - } - - void ResetOkToRetakeLock() - { - CONTRACT_BITMASK_RESET(CONTRACT_BITMASK_OK_TO_RETAKE_LOCK); - } - - - //--// - void LinkContractStackTrace( ContractStackRecord* pContractStackTrace ) - { - pContractStackTrace->m_pNext = m_pContractStackTrace; - - m_pContractStackTrace = pContractStackTrace; - } - - ContractStackRecord* GetContractStackTrace() - { - return m_pContractStackTrace; - } - - void SetContractStackTrace(ContractStackRecord* pContractStackTrace ) - { - m_pContractStackTrace = pContractStackTrace; - } - - //--// - - UINT GetGCNoTriggerCount() - { - return m_GCNoTriggerCount; - } - - void DecrementGCNoTriggerCount() - { - m_GCNoTriggerCount--; - } - - void IncrementGCNoTriggerCount() - { - m_GCNoTriggerCount++; - } - - - UINT GetGCForbidCount() - { - return m_GCForbidCount; - } - - void DecrementGCForbidCount() - { - m_GCForbidCount--; - } - - void IncrementGCForbidCount() - { - m_GCForbidCount++; - } - - UINT GetMaxLoadTypeLevel() - { - return m_maxLoadTypeLevel; - } - - void SetMaxLoadTypeLevel(UINT newLevel) - { - m_maxLoadTypeLevel = newLevel; - } - - //--// - - void SetDbgStateLockData(DbgStateLockData * pDbgStateLockData) - { - m_LockState.SetDbgStateLockData(pDbgStateLockData); - } - - DbgStateLockData * GetDbgStateLockData() - { - return m_LockState.GetDbgStateLockData(); - } - - void OnEnterCannotRetakeLockFunction() - { - m_LockState.OnEnterCannotRetakeLockFunction(); - } - -#ifdef FEATURE_STACK_PROBE //SO contract functions only required when SO infrastructure is enabled - BOOL IsSOIntolerant() - { - return !IsSOTolerant(); - } - - BOOL BeginSOTolerant() - { - return SetSOTolerance(TRUE); - } - - BOOL BeginSOIntolerant() - { - return SetSOTolerance(FALSE); - } - - - void CheckIfSOIntolerantOK(const char *szFunction, const char *szFile, int lineNum); - - - - - - //--// - - StackMarkerStack& GetStackMarkerStack() - { - return m_StackMarkerStack; - } -#endif - - void CheckOkayToLock(__in_z const char *szFunction, __in_z const char *szFile, int lineNum); // Asserts if its not okay to lock - BOOL CheckOkayToLockNoAssert(); // Returns if OK to lock - void LockTaken(DbgStateLockType dbgStateLockType, - UINT cEntrances, - void * pvLock, - __in_z const char * szFunction, - __in_z const char * szFile, - int lineNum); - void LockReleased(DbgStateLockType dbgStateLockType, UINT cExits, void * pvLock); - UINT GetLockCount(DbgStateLockType dbgStateLockType); - UINT GetCombinedLockCount(); -}; - -#endif // ENABLE_CONTRACTS - -#ifdef ENABLE_CONTRACTS_IMPL -// Create ClrDebugState. -// This routine is not allowed to return NULL. If it can't allocate the memory needed, -// it should return a pointer to a global static ClrDebugState that indicates -// that debug assertions should be skipped. -ClrDebugState *CLRInitDebugState(); -ClrDebugState *GetClrDebugState(BOOL fAlloc = TRUE); - - -// This function returns a ClrDebugState if one has been created, but will not create one itself. -inline ClrDebugState *CheckClrDebugState() -{ - STATIC_CONTRACT_LIMITED_METHOD; - STATIC_CONTRACT_SO_TOLERANT; - ClrDebugState *ret = (ClrDebugState*)ClrFlsGetValue(TlsIdx_ClrDebugState); - return ret; -} - -void CONTRACT_ASSERT(const char *szElaboration, - UINT whichTest, - UINT whichTestMask, - const char *szFunction, - const char *szFile, - int lineNum - ); - -#endif - -// This needs to be defined up here b/c it is used by ASSERT_CHECK which is used by the contract impl -#ifdef _DEBUG -#ifdef ENTER_DEBUG_ONLY_CODE -#undef ENTER_DEBUG_ONLY_CODE -#endif -#ifdef LEAVE_DEBUG_ONLY_CODE -#undef LEAVE_DEBUG_ONLY_CODE -#endif - -#ifdef ENABLE_CONTRACTS_IMPL -// This can only appear in a debug function so don't define it non-debug -class DebugOnlyCodeHolder -{ -public: - // We use GetClrDebugState on entry, but CheckClrDebugState on Leave - // That way we make sure to create one if we need to set state, but - // we don't recreated one on exit if its been deleted. - DEBUG_NOINLINE void Enter() - { - SCAN_SCOPE_BEGIN; - STATIC_CONTRACT_DEBUG_ONLY; - - m_pClrDebugState = GetClrDebugState(); - if (m_pClrDebugState) - { - m_oldDebugOnlyValue = m_pClrDebugState->IsDebugOnly(); - m_pClrDebugState->SetDebugOnly(); - } - } - - DEBUG_NOINLINE void Leave() - { - SCAN_SCOPE_END; - STATIC_CONTRACT_DEBUG_ONLY; - - m_pClrDebugState = CheckClrDebugState(); - if (m_pClrDebugState) - { - m_pClrDebugState->SetDebugOnly( m_oldDebugOnlyValue ); - } - } - -private: -BOOL m_oldDebugOnlyValue; -ClrDebugState *m_pClrDebugState; -}; - -#define ENTER_DEBUG_ONLY_CODE \ - DebugOnlyCodeHolder __debugOnlyCodeHolder; \ - __debugOnlyCodeHolder.Enter(); - -#define LEAVE_DEBUG_ONLY_CODE \ - __debugOnlyCodeHolder.Leave(); - - -class AutoCleanupDebugOnlyCodeHolder : public DebugOnlyCodeHolder -{ -public: - DEBUG_NOINLINE AutoCleanupDebugOnlyCodeHolder() - { - SCAN_SCOPE_BEGIN; - STATIC_CONTRACT_DEBUG_ONLY; - - Enter(); - }; - - DEBUG_NOINLINE ~AutoCleanupDebugOnlyCodeHolder() - { - SCAN_SCOPE_END; - - Leave(); - }; -}; - -#define DEBUG_ONLY_FUNCTION \ - STATIC_CONTRACT_DEBUG_ONLY; \ - AutoCleanupDebugOnlyCodeHolder __debugOnlyCodeHolder; - -#define DEBUG_ONLY_REGION() \ - AutoCleanupDebugOnlyCodeHolder __debugOnlyCodeHolder; - - -#define BEGIN_DEBUG_ONLY_CODE \ - { \ - AutoCleanupDebugOnlyCodeHolder __debugOnlyCodeHolder; - -#define END_DEBUG_ONLY_CODE \ - } - -#else // ENABLE_CONTRACTS_IMPL -#define DEBUG_ONLY_FUNCTION STATIC_CONTRACT_DEBUG_ONLY -#define DEBUG_ONLY_REGION() -#define BEGIN_DEBUG_ONLY_CODE -#define END_DEBUG_ONLY_CODE -#define ENTER_DEBUG_ONLY_CODE -#define LEAVE_DEBUG_ONLY_CODE -#endif - -#else // _DEBUG -#define DEBUG_ONLY_REGION() -#endif - - -#ifdef ENABLE_CONTRACTS_IMPL - -// These helpers encapsulate our access to our FLS debug state. To improve -// contract perf, we'll soon move these to a private alloced block -// so we can reuse the pointer instead of constantly refetching it. -// Thus, these helpers are just to bridge this transition. -inline LPVOID GetViolationMask() -{ - ClrDebugState *pState = CheckClrDebugState(); - if (pState) - { - return (LPVOID)pState->ViolationMask(); - } - else - { - return 0; - } -} - -// This is the default binding of the MAYBETEMPLATE identifier, -// used in the RETURN macro -template -class ___maybetemplate -{ - public: - FORCEINLINE void *operator new (size_t size) - { - return NULL; - } -}; - -// This is an abstract base class for contracts. The main reason we have this is so that the dtor for many derived class can -// be performant. If this class was not abstract and had a dtor, then the dtor for the derived class adds EH overhead (even if the derived -// class did not anything special in its dtor) -class BaseContract -{ - // Really private, but used by macros - public: - - // We use a single integer to specify all the settings for intrinsic tests - // such as THROWS and GC_TRIGGERS. The compiler should be able to fold all - // these clauses into a single constant. - // - // The value "0" is significant as this is what the entire mask will be initialized to - // in the absence of any clauses. Hence, whichever value is assigned "0" will be the - // default setting for the test. - // - // Also, there must be a "disabled" setting for each category in order to support - // the DISABLED macro. - enum TestEnum - { - THROWS_Mask = 0x00000003, - THROWS_Yes = 0x00000000, // the default - THROWS_No = 0x00000001, - THROWS_Disabled = 0x00000002, - - GC_Mask = 0x0000000C, - GC_Triggers = 0x00000000, // the default - GC_NoTrigger = 0x00000004, - GC_Disabled = 0x00000008, - - FAULT_Mask = 0x00000030, - FAULT_Disabled = 0x00000000, // the default - FAULT_Inject = 0x00000010, - FAULT_Forbid = 0x00000020, - - MODE_Mask = 0x000000C0, - MODE_Disabled = 0x00000000, // the default - MODE_Preempt = 0x00000040, - MODE_Coop = 0x00000080, - - // The following are used to assert the type of global state update being done by the function. - // This is used by the SO infrastructure to detect if we are probing properly. A CLR process will - // run in one of two states: SO-tolerant or SO-intolerant. In SO-tolerant mode, an SO is OK and we - // will not corrupt any global state. However, we cannot allow an SO to occur in SO-intolerant code - // because we might end up with our global state being corrupted. - // - // When we enter the EE from any entry point, we will begin in SO-tolerant mode and must probe for sufficient - // stack before entering SO-intolerant code. We will tell the differnce between SO-tolerant and SO-intolerant code - // by contract annotations on that function: SO_TOLERANT and SO_INTOLERANT. - - // We enter the EE in SO_TOLERANT mode. All entry point functions into the EE must be marked as SO_TOLERANT and - // and must probe before calling an SO-intolerant function. We have a static analsysis tool that ensures that every - // entry point is tagged as SO_TOLERANT and that it probes before calling an SO_TOLERANT function. - - // By default, all unannotated functions in the EE are SO_INTOLERANT which means that they must run behind a probe. - // Our contract checking will verify this at runtime. We only need to annotate a function explicilty as SO_INTOLERANT - // to tell our static analysis tool that they are not entry points (if it can't find a caller for a function, it assumes that the - // function is an entry point and should be marked SO_INTOLERANT.) - - SO_TOLERANCE_Mask = 0x00000300, - SO_TOLERANT_No = 0x00000000, // the default. - SO_TOLERANT_Yes = 0x00000100, - SO_TOLERANCE_Disabled = 0x00000200, - - DEBUG_ONLY_Yes = 0x00000400, // code runs under debug only - - SO_MAINLINE_No = 0x00000800, // code is not part of our mainline SO scenario - - // Any place where we can't safely call into the host should have a HOST_NoCalls contract - HOST_Mask = 0x00003000, - HOST_Calls = 0x00002000, - HOST_NoCalls = 0x00001000, - HOST_Disabled = 0x00000000, // the default - - // This enforces the EE_THREAD_NOT_REQUIRED contract by clearing - // ClrDebugState::m_allowGetThread in its scope. That causes raw calls - // to GetThread() to assert, unless inside a temporary "don't worry it's ok" scope - // via BEGIN/END_GETTHREAD_ALLOWED. Useful for enforcing our docs that - // state certain unmanaged API entrypoints (e.g., some from profiling API) - // are callable without an EE Thread in TLS. - EE_THREAD_Mask = 0x0000C000, - EE_THREAD_Disabled = 0x00000000, // the default - EE_THREAD_Required = 0x00004000, - EE_THREAD_Not_Required = 0x00008000, - - // These enforce the CAN_TAKE_LOCK / CANNOT_TAKE_LOCK contracts - CAN_TAKE_LOCK_Mask = 0x00060000, - CAN_TAKE_LOCK_Yes = 0x00020000, - CAN_TAKE_LOCK_No = 0x00040000, - CAN_TAKE_LOCK_Disabled = 0x00000000, // the default - - // These enforce the CANNOT_RETAKE_LOCK contract - CAN_RETAKE_LOCK_No = 0x00080000, - CAN_RETAKE_LOCK_No_Disabled = 0x00000000, // the default - - PRECONDITION_Used = 0x00010000, // a PRECONDITION appeared inside the contract - - // IMPORTANT!!! LOADS_TYPE_Mask and LOADS_TYPE_Shift must be kept in sync. - LOADS_TYPE_Mask = 0x00f00000, // the max loadstype level + 1 ("+1" because 0 is reserved for the default which is "disabled") - LOADS_TYPE_Shift = 20, // # of bits to right-shift to get loadstype bits to rightmost position. - LOADS_TYPE_Disabled = 0x00000000, // the default - - ALL_Disabled = THROWS_Disabled|GC_Disabled|FAULT_Disabled|MODE_Disabled|LOADS_TYPE_Disabled| - SO_TOLERANCE_Disabled|HOST_Disabled|EE_THREAD_Disabled|CAN_TAKE_LOCK_Disabled|CAN_RETAKE_LOCK_No_Disabled - - }; - - enum Operation - { - Setup = 0x01, - Preconditions = 0x02, - Postconditions = 0x04, - }; - - - __declspec(nothrow) BaseContract() : m_pClrDebugState(NULL), m_testmask(0) - { - } - __declspec(nothrow) void Restore() - { - // m_pClrDebugState is setup in BaseContract::DoChecks. If an SO happens after the - // BaseContract object is constructed but before DoChecks is invoked, m_pClrDebugState - // will remain NULL (which is what it is set to in the BaseContract ctor). - // - // Thus, we should check for it being NULL before dereferencing it. - if (m_pClrDebugState) - { - // Backout all changes to debug state. - *m_pClrDebugState = m_IncomingClrDebugState; - } - } - - void DoChecks(UINT testmask, __in_z const char *szFunction, __in_z char *szFile, int lineNum); - void Disable() - { - } - BOOL CheckFaultInjection(); - - protected: - UINT m_testmask; - // Override this function in any derived class to indicate that you have defined a destructor for that class - // and that dtor calls Restore() - virtual void DestructorDefinedThatCallsRestore() = 0; - - - protected: - ClrDebugState *m_pClrDebugState; - ClrDebugState m_IncomingClrDebugState; - - ContractStackRecord m_contractStackRecord; - - public: - // -------------------------------------------------------------------------------- - // These classes and declarations are used to implement our fake return keyword. - // -------------------------------------------------------------------------------- - - // ___box is used to protect the "detected" return value from being combined with other parts - // of the return expression after we have processed it. This can happen if the return - // expression is a non-parenthesized expression with an operator of lower precedence than - // ">". - // - // If you have such a case (and see this class listed in an error message), - // parenthesize your return value expression. - template - class Box__USE_PARENS_WITH_THIS_EXPRESSION - { - const T &value; - - public: - - FORCEINLINE Box__USE_PARENS_WITH_THIS_EXPRESSION(const T &value) - : value(value) - { - } - - FORCEINLINE const T& Unbox() - { - return value; - } - }; - - // PseudoTemplate is a class which can be instantated with a template-like syntax, resulting - // in an expression which simply boxes a following value in a Box - - template - class PseudoTemplate - { - public: - FORCEINLINE void *operator new (size_t size) - { - return NULL; - } - - FORCEINLINE Box__USE_PARENS_WITH_THIS_EXPRESSION operator>(const T &value) - { - return Box__USE_PARENS_WITH_THIS_EXPRESSION(value); - } - - FORCEINLINE PseudoTemplate operator<(int dummy) - { - return PseudoTemplate(); - } - }; - - // Returner is used to assign the return value to the RETVAL local. Note the use of - // operator , because of its low precedence. - - template - class Returner - { - RETURNTYPE &m_value; - BOOL m_got; - public: - - FORCEINLINE Returner(RETURNTYPE &value) - : m_value(value), - m_got(FALSE) - { - } - - template - FORCEINLINE RETURNTYPE operator,(Box__USE_PARENS_WITH_THIS_EXPRESSION value) - { - m_value = value.Unbox(); - m_got = TRUE; - return m_value; - } - - FORCEINLINE void operator,(___maybetemplate<0> &dummy) - { - m_got = TRUE; - } - - FORCEINLINE BOOL GotReturn() - { - return m_got; - } - }; - - // This type ensures that postconditions were run via RETURN or RETURN_VOID - class RanPostconditions - { - public: - bool ran; - int count; - const char *function; - - FORCEINLINE RanPostconditions(const char *function) - : ran(false), - count(0), - function(function) - { - } - - FORCEINLINE int operator++() - { - return ++count; - } - - FORCEINLINE ~RanPostconditions() - { - // Note: __uncaught_exception() is not a perfect check. It will return TRUE during any exception - // processing. So, if there is a contract called from an exception filter (like our - // COMPlusFrameHandler) then it will return TRUE and the saftey check below will not be performed. - if (!__uncaught_exception()) - ASSERT_CHECK(count == 0 || ran, function, "Didn't run postconditions - be sure to use RETURN at the end of the function"); - } - - }; - - // Set contract enforcement level - static void SetUnconditionalContractEnforcement(BOOL enforceUnconditionally); - - // Check contract enforcement - static BOOL EnforceContract(); - - private: - static BOOL s_alwaysEnforceContracts; -}; - -class Contract: public BaseContract -{ - // Have to override this function in any derived class to indicate that a valid destructor is defined for this class - virtual void DestructorDefinedThatCallsRestore(){} - - public: - __declspec(nothrow) ~Contract() - { - Restore(); - } -}; - -#endif // ENABLE_CONTRACTS_IMPL - - -#ifdef _DEBUG - -// Valid parameters for CONTRACT_VIOLATION macro -enum ContractViolationBits -{ - ThrowsViolation = 0x00000001, // suppress THROW tags in this scope - GCViolation = 0x00000002, // suppress GCTRIGGER tags in this scope - ModeViolation = 0x00000004, // suppress MODE_PREEMP and MODE_COOP tags in this scope - FaultViolation = 0x00000008, // suppress INJECT_FAULT assertions in this scope - FaultNotFatal = 0x00000010, // suppress INJECT_FAULT but not fault injection by harness - SOToleranceViolation = 0x00000020, // suppress SO_TOLERANCE tags in this scope - LoadsTypeViolation = 0x00000040, // suppress LOADS_TYPE tags in this scope - TakesLockViolation = 0x00000080, // suppress CAN_TAKE_LOCK tags in this scope - HostViolation = 0x00000100, // suppress HOST_CALLS tags in this scope - EEThreadViolation = 0x00000200, // suppress EE_THREAD_REQUIRED tags in this scope - - //These are not violation bits. We steal some bits out of the violation mask to serve as - // general flag bits. - CanFreeMe = 0x00010000, // If this bit is ON, the ClrDebugState was allocated by - // a version of utilcode that registers an Fls Callback to free - // the state. If this bit is OFF, the ClrDebugState was allocated - // by an old version of utilcode that doesn't. (And you can't - // assume that the old utilcode used the same allocator as the new utilcode.) - // (Most likely, this is because you are using an older shim with - // a newer mscorwks.dll) - // - // The Fls callback must only attempt to free debugstates that - // have this bit on. - - BadDebugState = 0x00020000, // If we OOM creating the ClrDebugState, we return a pointer to - // a static ClrDebugState that has this bit turned on. (We don't - // want to slow down contracts with null tests everywhere.) - // Other than this specific bit, all other fields of the DebugState - // must be considered trash. You can stomp on them and you can bit-test them - // but you can't throw up any asserts based on them and you certainly - // can't deref any pointers stored in the bad DebugState. - - AllViolation = 0xFFFFFFFF, -}; - -#endif - -#ifdef ENABLE_CONTRACTS_IMPL - -// Global variables allow PRECONDITION and POSTCONDITION to be used outside contracts -static const BaseContract::Operation ___op = (Contract::Operation) (Contract::Preconditions - |Contract::Postconditions); -enum { - ___disabled = 0 -}; - -static UINT ___testmask; - -// End of global variables - -static int ___ran; - -class __SafeToUsePostCondition { -public: - static int safe_to_use_postcondition() {return 0;}; -}; - -class __YouCannotUseAPostConditionHere { -private: - static int safe_to_use_postcondition() {return 0;}; -}; - -typedef __SafeToUsePostCondition __PostConditionOK; - -// Uncomment the following line to disable runtime contracts completely - PRE/POST conditions will still be present -//#define __FORCE_NORUNTIME_CONTRACTS__ 1 - -#ifndef __FORCE_NORUNTIME_CONTRACTS__ - -#define CONTRACT_SETUP(_contracttype, _returntype, _returnexp) \ - _returntype RETVAL; \ - _contracttype ___contract; \ - Contract::Returner<_returntype> ___returner(RETVAL); \ - Contract::RanPostconditions ___ran(__FUNCTION__); \ - Contract::Operation ___op = Contract::Setup; \ - DEBUG_ASSURE_NO_RETURN_BEGIN(CONTRACT) \ - BOOL ___contract_enabled = Contract::EnforceContract(); \ - enum {___disabled = 0}; \ - if (!___contract_enabled) \ - ___contract.Disable(); \ - else \ - { \ - enum { ___CheckMustBeInside_CONTRACT = 1 }; \ - if (0) \ - { \ - /* If you see an "unreferenced label" warning with this name, */\ - /* Be sure that you have a RETURN at the end of your */ \ - /* CONTRACT_VOID function */ \ - ___run_postconditions_DID_YOU_FORGET_A_RETURN: \ - if (___contract_enabled) \ - { \ - ___op = Contract::Postconditions; \ - ___ran.ran = true; \ - } \ - else \ - { \ - DEBUG_OK_TO_RETURN_BEGIN(CONTRACT) \ - ___run_return: \ - return _returnexp; \ - DEBUG_OK_TO_RETURN_END(CONTRACT) \ - } \ - } \ - if (0) \ - { \ - ___run_preconditions: \ - ___op = Contract::Preconditions; \ - } \ - UINT ___testmask = 0; \ - -#define CONTRACTL_SETUP(_contracttype) \ - _contracttype ___contract; \ - BOOL ___contract_enabled = Contract::EnforceContract(); \ - enum {___disabled = 0}; \ - if (!___contract_enabled) \ - ___contract.Disable(); \ - else \ - { \ - typedef __YouCannotUseAPostConditionHere __PostConditionOK; \ - enum { ___CheckMustBeInside_CONTRACT = 1 }; \ - Contract::Operation ___op = Contract::Setup; \ - enum {___disabled = 0}; \ - if (0) \ - { \ - ___run_preconditions: \ - ___op = Contract::Preconditions; \ - } \ - if (0) \ - { \ - /* define for CONTRACT_END even though we can't get here */ \ - ___run_return: \ - UNREACHABLE(); \ - } \ - UINT ___testmask = 0; \ - -#else // #ifndef __FORCE_NORUNTIME_CONTRACTS__ - -#define CONTRACT_SETUP(_contracttype, _returntype, _returnexp) \ - _returntype RETVAL; \ - Contract::Returner<_returntype> ___returner(RETVAL); \ - Contract::RanPostconditions ___ran(__FUNCTION__); \ - Contract::Operation ___op = Contract::Setup; \ - DEBUG_ASSURE_NO_RETURN_BEGIN(CONTRACT) \ - BOOL ___contract_enabled = Contract::EnforceContract(); \ - enum {___disabled = 0}; \ - { \ - enum { ___CheckMustBeInside_CONTRACT = 1 }; \ - if (0) \ - { \ - /* If you see an "unreferenced label" warning with this name, */\ - /* Be sure that you have a RETURN at the end of your */ \ - /* CONTRACT_VOID function */ \ - ___run_postconditions_DID_YOU_FORGET_A_RETURN: \ - if (___contract_enabled) \ - { \ - ___op = Contract::Postconditions; \ - ___ran.ran = true; \ - } \ - else \ - { \ - DEBUG_OK_TO_RETURN_BEGIN(CONTRACT) \ - ___run_return: \ - return _returnexp; \ - DEBUG_OK_TO_RETURN_END(CONTRACT) \ - } \ - } \ - if (0) \ - { \ - ___run_preconditions: \ - ___op = Contract::Preconditions; \ - } \ - UINT ___testmask = 0; \ - - - - -#define CONTRACTL_SETUP(_contracttype) \ - BOOL ___contract_enabled = Contract::EnforceContract(); \ - enum {___disabled = 0}; \ - { \ - typedef __YouCannotUseAPostConditionHere __PostConditionOK; \ - enum { ___CheckMustBeInside_CONTRACT = 1 }; \ - Contract::Operation ___op = Contract::Setup; \ - enum {___disabled = 0}; \ - if (0) \ - { \ - ___run_preconditions: \ - ___op = Contract::Preconditions; \ - } \ - if (0) \ - { \ - /* define for CONTRACT_END even though we can't get here */ \ - ___run_return: \ - UNREACHABLE(); \ - } \ - UINT ___testmask = 0; \ - -#endif // __FORCE_NORUNTIME_CONTRACTS__ - - -#define CUSTOM_CONTRACT(_contracttype, _returntype) \ - typedef Contract::PseudoTemplate<_returntype> ___maybetemplate; \ - CONTRACT_SETUP(_contracttype, _returntype, RETVAL) - -#define CUSTOM_CONTRACT_VOID(_contracttype) \ - CONTRACT_SETUP(_contracttype, int, ;) - -#define CUSTOM_CONTRACTL(_contracttype) \ - CONTRACTL_SETUP(_contracttype) - -// Although this thing only needs to run in the Setup phase, we'll let it -// run unconditionally. This way, the compiler will see a sequence like this: -// -// THROWS; GC_TRIGGERS; FORBID_FAULT ==> -// -// ___testmask |= constant -// ___testmask |= constant -// ___testmask |= constant -// -// and be able to fold all these into a single constant at runtime. -// -#define REQUEST_TEST(thetest, todisable) (___testmask |= (___CheckMustBeInside_CONTRACT, (___disabled ? (todisable) : (thetest)))) - - -#define INJECT_FAULT(_statement) \ - do \ - { \ - STATIC_CONTRACT_FAULT; \ - REQUEST_TEST(Contract::FAULT_Inject, Contract::FAULT_Disabled); \ - if (0) \ - { \ - _statement; \ - } \ - } \ - while(0) \ - - -#define FORBID_FAULT do { STATIC_CONTRACT_FORBID_FAULT; REQUEST_TEST(Contract::FAULT_Forbid, Contract::FAULT_Disabled); } while(0) - -#define THROWS do { STATIC_CONTRACT_THROWS; REQUEST_TEST(Contract::THROWS_Yes, Contract::THROWS_Disabled); } while(0) - -#define NOTHROW do { STATIC_CONTRACT_NOTHROW; REQUEST_TEST(Contract::THROWS_No, Contract::THROWS_Disabled); } while(0) \ - -#define ENTRY_POINT do { STATIC_CONTRACT_ENTRY_POINT; REQUEST_TEST(Contract::SO_TOLERANT_Yes, Contract::SO_TOLERANCE_Disabled); } while(0) - -#define LOADS_TYPE(maxlevel) do { REQUEST_TEST( ((maxlevel) + 1) << Contract::LOADS_TYPE_Shift, Contract::LOADS_TYPE_Disabled ); } while(0) - -#define SO_TOLERANT do { STATIC_CONTRACT_SO_TOLERANT; REQUEST_TEST(Contract::SO_TOLERANT_Yes, Contract::SO_TOLERANCE_Disabled); } while(0) - -#define SO_INTOLERANT do { STATIC_CONTRACT_SO_INTOLERANT; REQUEST_TEST(Contract::SO_TOLERANT_No, Contract::SO_TOLERANCE_Disabled); } while(0) - -#define SO_NOT_MAINLINE do { STATIC_CONTRACT_SO_NOT_MAINLINE; REQUEST_TEST(Contract::SO_MAINLINE_No, 0); } while (0) - -#define CAN_TAKE_LOCK do { STATIC_CONTRACT_CAN_TAKE_LOCK; REQUEST_TEST(Contract::CAN_TAKE_LOCK_Yes, Contract::CAN_TAKE_LOCK_Disabled); } while(0) - -#define CANNOT_TAKE_LOCK do { STATIC_CONTRACT_CANNOT_TAKE_LOCK; REQUEST_TEST(Contract::CAN_TAKE_LOCK_No, Contract::CAN_TAKE_LOCK_Disabled); } while(0) - -#define CANNOT_RETAKE_LOCK do { REQUEST_TEST(Contract::CAN_RETAKE_LOCK_No, Contract::CAN_RETAKE_LOCK_No_Disabled); } while(0) - -#define DEBUG_ONLY do { STATIC_CONTRACT_DEBUG_ONLY; REQUEST_TEST(Contract::DEBUG_ONLY_Yes, 0); } while (0) - -#ifndef __DISABLE_PREPOST_CONDITIONS__ -#define PRECONDITION_MSG(_expression, _message) \ - do \ - { \ - enum { ___CheckMustBeInside_CONTRACT = 1 }; \ - REQUEST_TEST(Contract::PRECONDITION_Used, 0); \ - if ((___op&Contract::Preconditions) && !___disabled) \ - ASSERT_CHECK(_expression, _message, "Precondition failure"); \ - } \ - while(0) - - -#define PRECONDITION(_expression) \ - PRECONDITION_MSG(_expression, NULL) - -#define POSTCONDITION_MSG(_expression, _message) \ - ++___ran; \ - if ((!(0 && __PostConditionOK::safe_to_use_postcondition())) && \ - (___op&Contract::Postconditions) && \ - !___disabled) \ - { \ - ASSERT_CHECK(_expression, _message, "Postcondition failure"); \ - } - -#define POSTCONDITION(_expression) \ - POSTCONDITION_MSG(_expression, NULL) - -#define INSTANCE_CHECK \ - ___CheckMustBeInside_CONTRACT; \ - if ((___op&Contract::Preconditions) && !___disabled) \ - ASSERT_CHECK(CheckPointer(this), NULL, "Instance precheck failure"); \ - ++___ran; \ - if ((___op&Contract::Postconditions) && !___disabled) \ - ASSERT_CHECK(CheckPointer(this), NULL, "Instance postcheck failure"); - -#define INSTANCE_CHECK_NULL \ - ___CheckMustBeInside_CONTRACT; \ - if ((___op&Contract::Preconditions) && !___disabled) \ - ASSERT_CHECK(CheckPointer(this, NULL_OK), NULL, "Instance precheck failure"); \ - ++___ran; \ - if ((___op&Contract::Postconditions) && !___disabled) \ - ASSERT_CHECK(CheckPointer(this, NULL_OK), NULL, "Instance postcheck failure"); - -#define CONSTRUCTOR_CHECK \ - ___CheckMustBeInside_CONTRACT; \ - ++___ran; \ - if ((___op&Contract::Postconditions) && !___disabled) \ - ASSERT_CHECK(CheckPointer(this), NULL, "Instance postcheck failure"); - -#define DESTRUCTOR_CHECK \ - ___CheckMustBeInside_CONTRACT; \ - NOTHROW; \ - if ((___op&Contract::Preconditions) && !___disabled) \ - ASSERT_CHECK(CheckPointer(this), NULL, "Instance precheck failure"); -#else // __DISABLE_PREPOST_CONDITIONS__ - - -#define PRECONDITION_MSG(_expression, _message) do { } while(0) -#define PRECONDITION(_expression) do { } while(0) -#define POSTCONDITION_MSG(_expression, _message) do { } while(0) -#define POSTCONDITION(_expression) do { } while(0) -#define INSTANCE_CHECK -#define INSTANCE_CHECK_NULL -#define CONSTRUCTOR_CHECK -#define DESTRUCTOR_CHECK - -#endif // __DISABLE_PREPOST_CONDITIONS__ - -#define UNCHECKED(thecheck) \ - do { \ - ANNOTATION_UNCHECKED(thecheck); \ - enum {___disabled = 1 }; \ - thecheck; \ - } while(0) - -#define DISABLED(thecheck) UNCHECKED(thecheck) - -#define WRAPPER(thecheck) UNCHECKED(thecheck) - -// This keyword is redundant but it's handy for reducing the nuisance editing you -// have to when repeatedly enabling and disabling contract items while debugging. -// You shouldn't check in code that explicitly uses ENABLED. -#define ENABLED(_check) _check - - -#ifndef __FORCE_NORUNTIME_CONTRACTS__ -#define CONTRACTL_END \ - if (___op & Contract::Setup) \ - { \ - ___contract.DoChecks(___testmask, __FUNCTION__, __FILE__, __LINE__); \ - if (___testmask & Contract::PRECONDITION_Used) \ - { \ - goto ___run_preconditions; \ - } \ - } \ - else if (___op & Contract::Postconditions) \ - { \ - goto ___run_return; \ - } \ - ___CheckMustBeInside_CONTRACT; \ - } - -#else - -#define CONTRACTL_END \ - if (___op & Contract::Setup) \ - { \ - if (___testmask & Contract::PRECONDITION_Used) \ - { \ - goto ___run_preconditions; \ - } \ - } \ - else if (___op & Contract::Postconditions) \ - { \ - goto ___run_return; \ - } \ - ___CheckMustBeInside_CONTRACT; \ - } \ - -#endif // __FORCE_NORUNTIME_CONTRACTS__ - -#define CONTRACT_END CONTRACTL_END \ - DEBUG_ASSURE_NO_RETURN_END(CONTRACT) \ - - -// The final expression in the RETURN macro deserves special explanation (or something.) -// The expression is constructed so as to be syntactically ambiguous, depending on whether -// __maybetemplate is a template or not. If it is a template, the expression is syntactically -// correct as-is. If it is not, the angle brackets are interpreted as -// less than & greater than, and the expression is incomplete. This is the point - we can -// choose whether we need an expression or not based on the context in which the macro is used. -// This allows the same RETURN macro to be used both in value-returning and void-returning -// contracts. -// -// The "__returner ," portion of the expression is used instead of "RETVAL =", since "," -// has lower precedence than "=". (Ain't overloaded operators fun.) -// -// Also note that the < and > operators on the non-template version of __maybetemplate -// are overridden to "box" the return value in a special type and pass it -// through to the __returner's "," operator. This is so we can detect a case where an -// operator with lower precedence than ">" is in the return expression - in such a case we -// will get a type error message, which instructs that parens be placed around the return -// value expression. - -#define RETURN_BODY \ - if (___returner.GotReturn()) \ - goto ___run_postconditions_DID_YOU_FORGET_A_RETURN; \ - else \ - ___returner, * new ___maybetemplate < 0 > - - -// We have two versions of the RETURN macro. CONTRACT_RETURN is for use inside the CONTRACT -// scope where it is OK to return this way, even though the CONTRACT macro itself does not -// allow a return. RETURN is for use inside the function body where it might not be OK -// to return and we need to ensure that we don't allow a return where one should not happen -// -#define RETURN \ - while (DEBUG_ASSURE_SAFE_TO_RETURN, TRUE) \ - RETURN_BODY \ - -#define RETURN_VOID \ - RETURN - -#define CONTRACT_RETURN \ - while (___CheckMustBeInside_CONTRACT, TRUE) \ - RETURN_BODY \ - -#define CONTRACT_RETURN_VOID \ - CONTRACT_RETURN \ - -#if 0 -#define CUSTOM_LIMITED_METHOD_CONTRACT(_contracttype) \ - { \ - _contracttype ___contract; \ - STATIC_CONTRACT_LEAF; \ - ___contract.DoChecks(Contract::THROWS_No|Contract::GC_NoTrigger|Contract::MODE_Disabled|Contract::FAULT_Disabled); \ - /* Should add some assertion mechanism to ensure no other contracts are called */ \ - } -#else -#define CUSTOM_LIMITED_METHOD_CONTRACT(_contracttype) \ - { \ - STATIC_CONTRACT_LEAF; \ - } -#endif - -#define CUSTOM_WRAPPER_NO_CONTRACT(_contracttype) \ - { \ - /* Should add some assertion mechanism to ensure one other contract is called */ \ - STATIC_CONTRACT_WRAPPER; \ - } - -#define CONTRACT_THROWS() \ - { \ - ::GetClrDebugState()->CheckOkayToThrow(__FUNCTION__, __FILE__, __LINE__); \ - } - -#define CONTRACT_THROWSEX(__func, __file, __line) \ - { \ - ::GetClrDebugState()->CheckOkayToThrow(__func, __file, __line); \ - } - -#else // ENABLE_CONTRACTS_IMPL -#define CUSTOM_CONTRACT(_contracttype, _returntype) if (0) { struct YouCannotUseThisHere { int x; }; // This temporary typedef allows retail use of -#define CUSTOM_CONTRACT_VOID(_contracttype) if (0) { struct YouCannotUseThisHere { int x; }; // FORBIDGC_LOADER_USE_ENABLED -#define CUSTOM_CONTRACTL(_contracttype) if (0) { struct YouCannotUseThisHere { int x; }; // inside contracts and asserts but nowhere else. - -#define INJECT_FAULT(_statement) -#define FORBID_FAULT -#define THROWS -#define NOTHROW -#define CAN_TAKE_LOCK -#define CANNOT_TAKE_LOCK -#define CANNOT_RETAKE_LOCK -#define LOADS_TYPE(maxlevel) -#define SO_TOLERANT -#define SO_INTOLERANT -#define SO_NOT_MAINLINE -#define ENTRY_POINT - -#ifdef _DEBUG -// This can only appear in a debug function so don't define it non-debug -#define DEBUG_ONLY STATIC_CONTRACT_DEBUG_ONLY -#else -#define DEBUG_ONLY -#endif - -#define PRECONDITION_MSG(_expression, _message) do { } while(0) -#define PRECONDITION(_expression) do { } while(0) -#define POSTCONDITION_MSG(_expression, _message) do { } while(0) -#define POSTCONDITION(_expression) do { } while(0) -#define INSTANCE_CHECK -#define INSTANCE_CHECK_NULL -#define CONSTRUCTOR_CHECK -#define DESTRUCTOR_CHECK -#define UNCHECKED(thecheck) -#define DISABLED(thecheck) -#define WRAPPER(thecheck) -#define ENABLED(_check) -#define CONTRACT_END } -#define CONTRACTL_END } - -#define CUSTOM_LIMITED_METHOD_CONTRACT(_contracttype) \ - { \ - /* Should add some assertion mechanism to ensure one other contract is called */ \ - STATIC_CONTRACT_LEAF; \ - } -#define CUSTOM_WRAPPER_NO_CONTRACT(_contracttype) \ - { \ - /* Should add some assertion mechanism to ensure one other contract is called */ \ - STATIC_CONTRACT_WRAPPER; \ - } - - -#define RETURN return -#define RETURN_VOID RETURN - -#define CONTRACT_THROWS() -#define CONTRACT_THROWSEX(__func, __file, __line) - -#endif // ENABLE_CONTRACTS_IMPL - - -#define CONTRACT(_returntype) CUSTOM_CONTRACT(Contract, _returntype) -#define CONTRACT_VOID CUSTOM_CONTRACT_VOID(Contract) -#define CONTRACTL CUSTOM_CONTRACTL(Contract) - -// See description near the top of the file -#define LIMITED_METHOD_CONTRACT CUSTOM_LIMITED_METHOD_CONTRACT(Contract) - -#define WRAPPER_NO_CONTRACT CUSTOM_WRAPPER_NO_CONTRACT(Contract) - -// GC_NOTRIGGER allowed but not currently enforced at runtime -#define GC_NOTRIGGER STATIC_CONTRACT_GC_NOTRIGGER -#define GC_TRIGGERS static_assert(false, "TriggersGC not supported in utilcode contracts") - -#ifdef ENABLE_CONTRACTS_IMPL -template -class ContractViolationHolder -{ -public: - ContractViolationHolder() - { - m_pviolationmask = NULL; - m_oldviolationmask = 0; - } - - DEBUG_NOINLINE void Enter(); - - DEBUG_NOINLINE void Leave() - { - SCAN_SCOPE_END; - LeaveInternal(); - }; - -protected: - // We require that violationMask is passed as a parameter here to hopefully defeat the - // compiler's desire to fold all the Enter and Ctor implementations together. - FORCEINLINE void EnterInternal(UINT_PTR violationMask) - { - _ASSERTE(0 == (violationMask & ~(ThrowsViolation | GCViolation | ModeViolation | FaultViolation | - FaultNotFatal | SOToleranceViolation | HostViolation | - TakesLockViolation | LoadsTypeViolation)) || - violationMask == AllViolation); - - m_pviolationmask = GetClrDebugState()->ViolationMaskPtr(); - m_oldviolationmask = *m_pviolationmask; - *m_pviolationmask = (m_oldviolationmask | violationMask); - }; - - FORCEINLINE void LeaveInternal() - { - // This can be used in places where our debug state has been destroyed, so check for it first. - if (CheckClrDebugState()) - { - _ASSERTE(m_pviolationmask != NULL); - *m_pviolationmask = m_oldviolationmask; - } - }; - - UINT_PTR *m_pviolationmask; - UINT_PTR m_oldviolationmask; -}; - -template -class AutoCleanupContractViolationHolder : ContractViolationHolder -{ -public: - DEBUG_NOINLINE AutoCleanupContractViolationHolder(BOOL fEnterViolation = TRUE); - - DEBUG_NOINLINE ~AutoCleanupContractViolationHolder() - { - SCAN_SCOPE_END; - LeaveInternal(); - }; -}; - -#endif // ENABLE_CONTRACTS_IMPL - -#ifdef ENABLE_CONTRACTS_IMPL -#define BEGIN_CONTRACT_VIOLATION(violationmask) \ - { \ - ContractViolationHolder __violationHolder_onlyOneAllowedPerScope; \ - __violationHolder_onlyOneAllowedPerScope.Enter(); \ - DEBUG_ASSURE_NO_RETURN_BEGIN(CONTRACT) \ - -// Use this to jump out prematurely from a violation. Used for EH -// when the function might not return -#define RESET_CONTRACT_VIOLATION() \ - __violationHolder_onlyOneAllowedPerScope.Leave(); \ - -#define END_CONTRACT_VIOLATION \ - DEBUG_ASSURE_NO_RETURN_END(CONTRACT) \ - __violationHolder_onlyOneAllowedPerScope.Leave(); \ - } \ - -// See description near the top of the file -#define CONTRACT_VIOLATION(violationMask) \ - AutoCleanupContractViolationHolder __violationHolder_onlyOneAllowedPerScope; - - -// Reasons for having the violation. Use one of these values as an additional parameter to -// E.g. PERMANENT_CONTRACT_VIOLATION(ThrowsViolation, ReasonContractInfrastructure) -// New values and explanations can be added when needed. -enum PermanentContractViolationReason -{ - ReasonContractInfrastructure, // This violation is there for contract test or infrastructure purposes. - ReasonDebugOnly, // Code path doesn't occur on retail builds - ReasonNonShippingCode, // Code runs in undocumented non-shipping feature - ReasonIBC, // Code runs in IBC scenarios only and the violation is safe. - ReasonNGEN, // Code runs in NGEN scenarios only and the violation is safe. - ReasonProfilerCallout, // Profiler implementers are guaranteed not to throw. - ReasonUnsupportedForSQLF1Profiling, // This code path violates HOST_NOCALLS, but that's ok b/c SQL will never - // invoke it, and thus SQL/F1 profiling (the primary reason to enforce - // HOST_NOCALLS) is not in danger. - ReasonRuntimeReentrancy, // e.g. SafeQueryInterface - ReasonShutdownOnly, // Code path only runs as part of Shutdown and the violation is safe. - ReasonSOTolerance, // We would like to redesign SO contracts anyways - ReasonStartupOnly, // Code path only runs as part of Startup and the violation is safe. - ReasonWorkaroundForScanBug, // Violation is needed because of a bug in SCAN - ReasonProfilerAsyncCannotRetakeLock, // Profiler may call this from redirected thread, causing a CANNOT_TAKE_LOCK - // violation, but the scope is still protected with CANNOT_RETAKE_LOCK - ReasonILStubWillNotThrow, // Specially-crafted reverse COM IL stubs will not throw -}; - -// See the discussion near the top of the file on the use of PERMANENT_CONTRACT_VIOLATION -// The reasonEnum is currently only used for documentation and searchability. Here -// we have the compiler check for a typo. -#define PERMANENT_CONTRACT_VIOLATION(violationMask, reasonEnum) \ - if (0) \ - PermanentContractViolationReason reason = reasonEnum; \ - CONTRACT_VIOLATION(violationMask) - -#define CONDITIONAL_CONTRACT_VIOLATION(violationMask, condition) \ - AutoCleanupContractViolationHolder __violationHolder_onlyOneAllowedPerScope((condition)); - -#else -#define BEGIN_CONTRACT_VIOLATION(violationmask) -#define RESET_CONTRACT_VIOLATION() -#define END_CONTRACT_VIOLATION -#define CONTRACT_VIOLATION(violationmask) -#define CONDITIONAL_CONTRACT_VIOLATION(violationMask, condition) -#define PERMANENT_CONTRACT_VIOLATION(violationMask, reasonEnum) -#endif - - - -#ifdef ENABLE_CONTRACTS_IMPL -// Holder for setting up a faultforbid region -class FaultForbidHolder -{ - public: - DEBUG_NOINLINE FaultForbidHolder(BOOL fConditional, BOOL fAlloc, const char *szFunction, const char *szFile, int lineNum) - { - SCAN_SCOPE_BEGIN; - STATIC_CONTRACT_FORBID_FAULT; - - m_fConditional = fConditional; - if (m_fConditional) - { - m_pClrDebugState = GetClrDebugState(fAlloc); - - // - // If we fail to get a debug state, then we must not be allocating and - // we simply no-op this holder. - // - if (m_pClrDebugState == NULL) - { - _ASSERTE(!fAlloc); - m_fConditional = FALSE; - return; - } - - m_oldClrDebugState = *m_pClrDebugState; - - m_pClrDebugState->ViolationMaskReset( FaultViolation|FaultNotFatal ); - m_pClrDebugState->SetFaultForbid(); - - m_ContractStackRecord.m_szFunction = szFunction; - m_ContractStackRecord.m_szFile = szFile; - m_ContractStackRecord.m_lineNum = lineNum; - m_ContractStackRecord.m_testmask = (Contract::ALL_Disabled & ~((UINT)(Contract::FAULT_Mask))) | Contract::FAULT_Forbid; - m_ContractStackRecord.m_construct = "FAULT_FORBID"; - m_pClrDebugState->LinkContractStackTrace( &m_ContractStackRecord ); - } - } - - DEBUG_NOINLINE ~FaultForbidHolder() - { - SCAN_SCOPE_END; - - if (m_fConditional) - { - *m_pClrDebugState = m_oldClrDebugState; - } - } - - private: - ClrDebugState *m_pClrDebugState; - ClrDebugState m_oldClrDebugState; - BOOL m_fConditional; - ContractStackRecord m_ContractStackRecord; - -}; -#endif // ENABLE_CONTRACTS_IMPL - - -#ifdef ENABLE_CONTRACTS_IMPL - -#define FAULT_FORBID() FaultForbidHolder _ffh(TRUE, TRUE, __FUNCTION__, __FILE__, __LINE__); -#define FAULT_FORBID_NO_ALLOC() FaultForbidHolder _ffh(TRUE, FALSE, __FUNCTION__, __FILE__, __LINE__); -#define MAYBE_FAULT_FORBID(cond) FaultForbidHolder _ffh(cond, TRUE, __FUNCTION__, __FILE__, __LINE__); -#define MAYBE_FAULT_FORBID_NO_ALLOC(cond) FaultForbidHolder _ffh(cond, FALSE, __FUNCTION__, __FILE__, __LINE__); - -#else // ENABLE_CONTRACTS_IMPL - -#define FAULT_FORBID() ; -#define FAULT_FORBID_NO_ALLOC() ; -#define MAYBE_FAULT_FORBID(cond) ; -#define MAYBE_FAULT_FORBID_NO_ALLOC(cond) ; - -#endif // ENABLE_CONTRACTS_IMPL - - -#ifdef ENABLE_CONTRACTS_IMPL - -inline BOOL AreFaultsForbiddenHelper() -{ - STATIC_CONTRACT_DEBUG_ONLY; - STATIC_CONTRACT_NOTHROW; - - ClrDebugState *pClrDebugState = CheckClrDebugState(); - if (!pClrDebugState) - { - // By default, faults are not forbidden. Not the most desirable default - // but we'd never get this debug infrastructure bootstrapped otherwise. - return FALSE; - } - else - { - return pClrDebugState->IsFaultForbid() && (!(pClrDebugState->ViolationMask() & (FaultViolation|FaultNotFatal|BadDebugState))); - } -} - -#define ARE_FAULTS_FORBIDDEN() AreFaultsForbiddenHelper() -#else - -// If you got an error about ARE_FAULTS_FORBIDDEN being undefined, it's because you tried -// to use this predicate in a free build outside of a CONTRACT or ASSERT. -// -#define ARE_FAULTS_FORBIDDEN() (sizeof(YouCannotUseThisHere) != 0) -#endif - - -// This allows a fault-forbid region to invoke a non-mandatory allocation, such as for the -// purpose of growing a lookaside cache (if the allocation fails, the code can abandon the -// cache growing operation without negative effect.) -// -// Although it's implemented using CONTRACT_VIOLATION(), it's not a bug to have this in the code. -// -// It *is* a bug to use this to hide a situation where an OOM is genuinely fatal but not handled. -#define FAULT_NOT_FATAL() CONTRACT_VIOLATION(FaultNotFatal) - - - -#ifdef ENABLE_CONTRACTS_IMPL - -//------------------------------------------------------------------------------------ -// Underlying class support for TRIGGERS_TYPE_LOAD and OVERRIDE_TYPE_LOAD_LEVEL_LIMIT. -// Don't reference this class directly. Use the macros. -//------------------------------------------------------------------------------------ -class LoadsTypeHolder -{ - public: - LoadsTypeHolder(BOOL fConditional, - UINT newLevel, - BOOL fEnforceLevelChangeDirection, - const char *szFunction, - const char *szFile, - int lineNum - ); - - ~LoadsTypeHolder(); - - private: - ClrDebugState *m_pClrDebugState; - ClrDebugState m_oldClrDebugState; - BOOL m_fConditional; - ContractStackRecord m_contractStackRecord; - -}; - -#endif // ENABLE_CONTRACTS_IMPL - - -//------------------------------------------------------------------------------------ -// TRIGGERS_TYPE_LOAD(newLevel) -// Works just LOADS_TYPE in contracts but lets you protect individual scopes -// -// OVERRIDE_TYPE_LOAD_LEVEL_LIMIT(newLevel) -// Sets a new limit just like TRIGGERS_TYPE_LOAD but does not restrict you -// to decreasing the limit. Only the loader should use this and only when it -// can prove structurally that no recursion will occur as a result. -//------------------------------------------------------------------------------------ -#ifdef ENABLE_CONTRACTS_IMPL - -#define TRIGGERS_TYPE_LOAD(newLevel) LoadsTypeHolder _lth(TRUE, newLevel, TRUE, __FUNCTION__, __FILE__, __LINE__); -#define MAYBE_TRIGGERS_TYPE_LOAD(newLevel, fEnable) LoadsTypeHolder _lth(fEnable, newLevel, TRUE, __FUNCTION__, __FILE__, __LINE__); -#define OVERRIDE_TYPE_LOAD_LEVEL_LIMIT(newLevel) LoadsTypeHolder _lth(TRUE, newLevel, FALSE, __FUNCTION__, __FILE__, __LINE__); -#define MAYBE_OVERRIDE_TYPE_LOAD_LEVEL_LIMIT(newLevel, fEnable) LoadsTypeHolder _lth(fEnable, newLevel, FALSE, __FUNCTION__, __FILE__, __LINE__); - -#else // ENABLE_CONTRACTS_IMPL - -#define TRIGGERS_TYPE_LOAD(newLevel) -#define MAYBE_TRIGGERS_TYPE_LOAD(newLevel, fEnable) -#define OVERRIDE_TYPE_LOAD_LEVEL_LIMIT(newLevel) -#define MAYBE_OVERRIDE_TYPE_LOAD_LEVEL_LIMIT(newLevel, fEnable) - -#endif // ENABLE_CONTRACTS_IMPL - - - -#ifdef ENABLE_CONTRACTS_IMPL -class PAL_TryMarker -{ -public: - DEBUG_NOINLINE void Enter(); - DEBUG_NOINLINE void Leave(); -}; - -#define PAL_ENTER_THROWS_REGION \ - PAL_TryMarker __throwsHolder_onlyOneAllowedPerScope; \ - __throwsHolder_onlyOneAllowedPerScope.Enter(); - -#define PAL_LEAVE_THROWS_REGION \ - __throwsHolder_onlyOneAllowedPerScope.Leave(); - -// This sets up a marker that says its okay to throw on this thread. This is not a public macro, and should only be -// used from within the implementation of various try/catch macros. -class ClrTryMarkerHolder -{ -public: - DEBUG_NOINLINE ClrTryMarkerHolder() - { - SCAN_SCOPE_BEGIN; - STATIC_CONTRACT_THROWS; - - m_pClrDebugState = GetClrDebugState(); - m_oldOkayToThrowValue = m_pClrDebugState->IsOkToThrow(); - m_pClrDebugState->SetOkToThrow(); - } - - DEBUG_NOINLINE ~ClrTryMarkerHolder() - { - SCAN_SCOPE_END; - - m_pClrDebugState->SetOkToThrow( m_oldOkayToThrowValue ); - } - -private: - BOOL m_oldOkayToThrowValue; - ClrDebugState *m_pClrDebugState; -}; - -#define CLR_TRY_MARKER() ClrTryMarkerHolder ___tryMarkerHolder; - -#else // ENABLE_CONTRACTS_IMPL - -#define CLR_TRY_MARKER() -#define PAL_ENTER_THROWS_REGION -#define PAL_LEAVE_THROWS_REGION - -#endif - -#ifdef ENABLE_CONTRACTS_IMPL -// Note: This routine will create a ClrDebugState if called for the first time. -// It cannot return NULL (see comment for InitClrDebugState). -inline ClrDebugState *GetClrDebugState(BOOL fAlloc) -{ - STATIC_CONTRACT_LIMITED_METHOD; - STATIC_CONTRACT_SO_NOT_MAINLINE; - - ClrDebugState *pState = CheckClrDebugState(); - - if (pState) - { - return pState; - } - - if (fAlloc) - { - return CLRInitDebugState(); - } - - return NULL; -} -#endif // ENABLE_CONTRACTS_IMPL - -#ifdef FEATURE_STACK_PROBE - -#ifdef ENABLE_CONTRACTS_IMPL -class SONotMainlineHolder -{ - public: - DEBUG_NOINLINE void Enter() - { - SCAN_SCOPE_BEGIN; - STATIC_CONTRACT_SO_NOT_MAINLINE; - - m_pClrDebugState = GetClrDebugState(); - if (m_pClrDebugState) - { - m_oldSONotMainlineValue = m_pClrDebugState->IsSONotMainline(); - m_pClrDebugState->SetSONotMainline(); - } - } - - DEBUG_NOINLINE void Leave() - { - SCAN_SCOPE_END; - - m_pClrDebugState = CheckClrDebugState(); - if (m_pClrDebugState) - { - m_pClrDebugState->SetSONotMainline( m_oldSONotMainlineValue ); - } - } - - private: - BOOL m_oldSONotMainlineValue; - ClrDebugState *m_pClrDebugState; -}; - -#define ENTER_SO_NOT_MAINLINE_CODE \ - SONotMainlineHolder __soNotMainlineHolder; \ - __soNotMainlineHolder.Enter(); - -#define LEAVE_SO_NOT_MAINLINE_CODE \ - __soNotMainlineHolder.Leave(); - - -class AutoCleanupSONotMainlineHolder : public SONotMainlineHolder -{ - public: - DEBUG_NOINLINE AutoCleanupSONotMainlineHolder() - { - SCAN_SCOPE_BEGIN; - STATIC_CONTRACT_SO_NOT_MAINLINE; - - Enter(); - } - - DEBUG_NOINLINE ~AutoCleanupSONotMainlineHolder() - { - SCAN_SCOPE_END; - - Leave(); - } -}; - -#define SO_NOT_MAINLINE_FUNCTION \ - AutoCleanupSONotMainlineHolder __soNotMainlineHolder; - -#define SO_NOT_MAINLINE_REGION() \ - AutoCleanupSONotMainlineHolder __soNotMainlineHolder; - -#else // ENABLE_CONTRACTS_IMPL -#define SO_NOT_MAINLINE_FUNCTION STATIC_CONTRACT_SO_NOT_MAINLINE -#define SO_NOT_MAINLINE_REGION() STATIC_CONTRACT_SO_NOT_MAINLINE -#define ENTER_SO_NOT_MAINLINE_CODE -#define LEAVE_SO_NOT_MAINLINE_CODE -#endif - -#else // FEATURE_STACK_PROBE - -#define SO_NOT_MAINLINE_FUNCTION -#define SO_NOT_MAINLINE_REGION() -#define ENTER_SO_NOT_MAINLINE_CODE -#define LEAVE_SO_NOT_MAINLINE_CODE - -#endif // FEATURE_STACK_PROBE - -#ifdef ENABLE_CONTRACTS_IMPL - -class HostNoCallHolder -{ - public: - DEBUG_NOINLINE HostNoCallHolder() - { - SCAN_SCOPE_BEGIN; - STATIC_CONTRACT_HOST_NOCALLS; - - m_clrDebugState = GetClrDebugState(); - m_previousState = m_clrDebugState->SetHostCaller(FALSE); - } - - DEBUG_NOINLINE ~HostNoCallHolder() - { - SCAN_SCOPE_END; - - m_clrDebugState->SetHostCaller(m_previousState); - } - - private: - BOOL m_previousState; - ClrDebugState* m_clrDebugState; - -}; - -#define BEGIN_HOST_NOCALL_CODE \ - { \ - HostNoCallHolder __hostNoCallHolder; \ - CantAllocHolder __cantAlloc; - -#define END_HOST_NOCALL_CODE \ - } - -#else // ENABLE_CONTRACTS_IMPL -#define BEGIN_HOST_NOCALL_CODE \ - { \ - CantAllocHolder __cantAlloc; \ - -#define END_HOST_NOCALL_CODE \ - } -#endif - -#ifdef ENABLE_CONTRACTS_IMPL - -class GetThreadAllowedHolder -{ - public: - GetThreadAllowedHolder(BOOL newState) - { - m_clrDebugState = ::GetClrDebugState(); - m_previousState = m_clrDebugState->SetGetThreadAllowed(newState); - } - - ~GetThreadAllowedHolder() - { - m_clrDebugState->SetGetThreadAllowed(m_previousState); - } - -private: - BOOL m_previousState; - ClrDebugState* m_clrDebugState; -}; - -// When in an EE_THREAD_NOT_REQUIRED contracted scope, it's expected that the -// function does not assume an EE Thread object is available in TLS. Either -// GetThread() is never called, or any code path that requires a Thread -// has another code path that deals with the absence of a Thread. Any call to -// to GetThread() must be bracketed with BEGIN_GETTHREAD_ALLOWED / -// END_GETTHREAD_ALLOWED to avoid bogus asserts (the short-form -// GetThreadNULLOk() may be used as well). However, this is only allowed if visual -// inspection of the call site makes it patently obvious that the function deals -// appropriately with the GetThread() == NULL case (or that case has already been -// dealt with and control has exited before the BEGIN_GETTHREAD_ALLOWED / -// END_GETTHREAD_ALLOWED block. -// -// These use holder objects, which causes the compiler to generate EH code and prevent -// inlining. So try to avoid these in small, downstream functions (like inline -// EE Thread member functions). Use the _IN_NO_THROW_REGION variants below instead. - -#define BEGIN_GETTHREAD_ALLOWED \ - { \ - GetThreadAllowedHolder __getThreadAllowedHolder(TRUE); \ - -#define END_GETTHREAD_ALLOWED \ - } - -// These are lighter-weight versions of BEGIN_GETTHREAD_ALLOWED / -// END_GETTHREAD_ALLOWED. These don't use holders, so be sure only to -// use these to bracket code that won't throw exceptions -#define BEGIN_GETTHREAD_ALLOWED_IN_NO_THROW_REGION \ - { \ - ClrDebugState * __clrDebugState = ::GetClrDebugState(); \ - BOOL __previousState = __clrDebugState->SetGetThreadAllowed(TRUE); \ - -#define END_GETTHREAD_ALLOWED_IN_NO_THROW_REGION \ - __clrDebugState->SetGetThreadAllowed(__previousState); \ - } - -#else // ENABLE_CONTRACTS_IMPL -#define BEGIN_GETTHREAD_ALLOWED -#define END_GETTHREAD_ALLOWED -#define BEGIN_GETTHREAD_ALLOWED_IN_NO_THROW_REGION -#define END_GETTHREAD_ALLOWED_IN_NO_THROW_REGION -#endif - -#if defined(ENABLE_CONTRACTS_IMPL) - -// Macros to indicate we're taking or releasing locks - -// Most general macros, not used directly -#define LOCK_TAKEN_MULTIPLE(dbgStateLockType, cEntrances, pvLock) \ - ::GetClrDebugState()->LockTaken((dbgStateLockType), (cEntrances), (void*) (pvLock), __FUNCTION__, __FILE__, __LINE__) -#define LOCK_RELEASED_MULTIPLE(dbgStateLockType, cExits, pvLock) \ - ::GetClrDebugState()->LockReleased((dbgStateLockType), (cExits), (void*) (pvLock)) - -// Use these only if you need to force multiple entrances or exits in a single -// line (e.g., to restore the lock to a previous state). CRWLock in vm\rwlock.cpp does this -#define EE_LOCK_TAKEN_MULTIPLE(cEntrances, pvLock) \ - LOCK_TAKEN_MULTIPLE(kDbgStateLockType_EE, cEntrances, pvLock) -#define EE_LOCK_RELEASED_MULTIPLE(cExits, pvLock) \ - LOCK_RELEASED_MULTIPLE(kDbgStateLockType_EE, cExits, pvLock) -#define HOST_BREAKABLE_CRST_TAKEN_MULTIPLE(cEntrances, pvLock) \ - LOCK_TAKEN_MULTIPLE(kDbgStateLockType_HostBreakableCrst, cEntrances, pvLock) -#define HOST_BREAKABLE_CRST_RELEASED_MULTIPLE(cExits, pvLock) \ - LOCK_RELEASED_MULTIPLE(kDbgStateLockType_HostBreakableCrst, cExits, pvLock) -#define USER_LOCK_TAKEN_MULTIPLE(cEntrances, pvLock) \ - LOCK_TAKEN_MULTIPLE(kDbgStateLockType_User, cEntrances, pvLock) -#define USER_LOCK_RELEASED_MULTIPLE(cExits, pvLock) \ - LOCK_RELEASED_MULTIPLE(kDbgStateLockType_User, cExits, pvLock) - -// These are most typically used -#define EE_LOCK_TAKEN(pvLock) \ - LOCK_TAKEN_MULTIPLE(kDbgStateLockType_EE, 1, pvLock) -#define EE_LOCK_RELEASED(pvLock) \ - LOCK_RELEASED_MULTIPLE(kDbgStateLockType_EE, 1, pvLock) -#define HOST_BREAKABLE_CRST_TAKEN(pvLock) \ - LOCK_TAKEN_MULTIPLE(kDbgStateLockType_HostBreakableCrst, 1, pvLock) -#define HOST_BREAKABLE_CRST_RELEASED(pvLock) \ - LOCK_RELEASED_MULTIPLE(kDbgStateLockType_HostBreakableCrst, 1, pvLock) -#define USER_LOCK_TAKEN(pvLock) \ - LOCK_TAKEN_MULTIPLE(kDbgStateLockType_User, 1, pvLock) -#define USER_LOCK_RELEASED(pvLock) \ - LOCK_RELEASED_MULTIPLE(kDbgStateLockType_User, 1, pvLock) - -#else // defined(ENABLE_CONTRACTS_IMPL) - -#define LOCK_TAKEN_MULTIPLE(dbgStateLockType, cEntrances, pvLock) -#define LOCK_RELEASED_MULTIPLE(dbgStateLockType, cExits, pvLock) -#define EE_LOCK_TAKEN_MULTIPLE(cEntrances, pvLock) -#define EE_LOCK_RELEASED_MULTIPLE(cExits, pvLock) -#define HOST_BREAKABLE_CRST_TAKEN_MULTIPLE(cEntrances, pvLock) -#define HOST_BREAKABLE_CRST_RELEASED_MULTIPLE(cExits, pvLock) -#define USER_LOCK_TAKEN_MULTIPLE(cEntrances, pvLock) -#define USER_LOCK_RELEASED_MULTIPLE(cExits, pvLock) -#define EE_LOCK_TAKEN(pvLock) -#define EE_LOCK_RELEASED(pvLock) -#define HOST_BREAKABLE_CRST_TAKEN(pvLock) -#define HOST_BREAKABLE_CRST_RELEASED(pvLock) -#define USER_LOCK_TAKEN(pvLock) -#define USER_LOCK_RELEASED(pvLock) - -#endif // defined(ENABLE_CONTRACTS_IMPL) - -#if defined(ENABLE_CONTRACTS_IMPL) - -// Abbreviation for an assert that is only considered if there is a valid -// ClrDebugState available. Useful if you want to assert based on the value -// of GetDbgStateLockCount(), where a return of 0 (the default if there is no -// valid ClrDebugState available) would cause your assert to fire. The variable -// __pClrDebugState is set to the current ClrDebugState, and may be used within -// your assert expression -#define ASSERT_UNLESS_NO_DEBUG_STATE(e) \ - { \ - ClrDebugState * __pClrDebugState = GetClrDebugState(); \ - _ASSERTE(((__pClrDebugState->ViolationMask() & BadDebugState) != 0) || (e)); \ - } - -#else // defined(ENABLE_CONTRACTS_IMPL) - -#define ASSERT_UNLESS_NO_DEBUG_STATE(e) - -#endif // defined(ENABLE_CONTRACTS_IMPL) - - -//----------------------------------------------------------------------------- -// Debug support to ensure that nobody calls New on the helper thread. -// This is for interop debugging. -// They should be using the InteropSafe heap. -// Having this in the meantime allows us to -// assert that the helper thread never calls new, and maintain a finite list of -// exceptions (bugs). -// Eventually, all those bugs should be fixed this holder can be completely removed. -// -// It is also the case that we disallow allocations when any thread is OS suspended -// This happens for a short time when we are suspending the EE. We supress both -// of these. -// -// @todo- ideally this would be rolled into the ContractViolation. -// also, we'd have contract bit for whether APIs can be called on the helper thread. -// @todo - if we really wanted to be strict, we should make this per-thread. -//----------------------------------------------------------------------------- -#ifdef ENABLE_CONTRACTS_IMPL -extern Volatile g_DbgSuppressAllocationAsserts; -#define SUPPRESS_ALLOCATION_ASSERTS_IN_THIS_SCOPE CounterHolder _AllowNewOnHelperHolder(&g_DbgSuppressAllocationAsserts); -#else -// Nothing in retail since this holder just disabled an assert. -#define SUPPRESS_ALLOCATION_ASSERTS_IN_THIS_SCOPE -#endif - - -//----------------------------------------------------------------------------- -// Support for contracts in DAC builds -// -// At the moment, most of the contract system is disabled in DAC builds. -// We do however want some simple static contracts in order to support static -// analysis tools that run on mscordacwks.dll like DacCop. -// Note that we want these static contracts in both DEBUG and retail builds. -// We also already get simple static contracts like WRAPPER and LEAF. -// -//----------------------------------------------------------------------------- -#if defined(DACCESS_COMPILE) - -// SUPPORTS_DAC is an annotation that says the function is designed to be used in DAC builds. -// This enables full DacCop analysis on the function, including verifying that all functions that are -// called also support DAC. -#define SUPPORTS_DAC do { STATIC_CONTRACT_SUPPORTS_DAC; } while(0) - -// Normally a function can be annotated just with WRAPPER_NO_CONTRACT, which (in addition to the normal -// contract meaning) indicates to DacCop that the function should be considered to support DAC when -// it is called from a supports-dac function. This is to avoid having to add a DAC-specific contract -// to all the trivial one-line wrapper functions we have. -// However, we occasionally want these semantics even for functions which are not appropriate to label -// as WRAPPER_NO_CONTRACT. For example, a template function may support DAC for certain template arguments, -// but not others (due to the functions it calls). We want to ensure that when such a function is called -// in a DAC code path, analysis is enabled on that particular instantiation including checking all of the -// call targets specific to this template instantiation. But we don't want to require that the call targets -// for ALL instantiations support dac, since we may not even be using them in DAC code paths. Ideally we'd -// remove any such code from the DAC build, but this will take time. -#define SUPPORTS_DAC_WRAPPER do { STATIC_CONTRACT_WRAPPER; } while(0) - -// SUPPORTS_DAC_HOST_ONLY indicates that a function is allowed to be called in DAC builds, but rather -// than being a normal DAC function which operates on marshalled data, it is a host-only utility function -// that knows nothing about DAC and operates solely on the host. For example, DbgAssertDialog is a utility -// function for popping assert dialogs - there is nothing DAC-specific about this. Ideally such utility -// functions would be confined to their own library which had no access to DAC functionality, and which -// is not analyzed by DacCop. At the moment splitting utilcode into two variations like this is too -// painful, but we hope to do it in the future (primarily to support functions which can be used in either -// DAC or host-only mode). -// WARNING: This contract disables DacCop analysis on the function and any functions it calls, so it -// should be used very carefully. -#define SUPPORTS_DAC_HOST_ONLY do { STATIC_CONTRACT_SUPPORTS_DAC_HOST_ONLY; } while(0) - -#else -#define SUPPORTS_DAC -#define SUPPORTS_DAC_HOST_ONLY -#define SUPPORTS_DAC_WRAPPER -#endif // DACCESS_COMPILE - -// LIMITED_METHOD_DAC_CONTRACT is a shortcut for LIMITED_METHOD_CONTRACT and SUPPORTS_DAC. Usefull for one-line inline functions. -#define LIMITED_METHOD_DAC_CONTRACT LIMITED_METHOD_CONTRACT; SUPPORTS_DAC - -// -// The default contract is the recommended contract for ordinary code. -// The ordinary code can throw or trigger GC any time, does not operate -// on raw object refs, etc. -// - -#define STANDARD_VM_CHECK \ - THROWS; \ - SO_INTOLERANT; \ - -#define STANDARD_VM_CONTRACT \ - CONTRACTL \ - { \ - STANDARD_VM_CHECK; \ - } \ - CONTRACTL_END; \ - -#define STATIC_STANDARD_VM_CONTRACT \ - STATIC_CONTRACT_THROWS; \ - STATIC_CONTRACT_GC_TRIGGERS; \ - STATIC_CONTRACT_MODE_PREEMPTIVE; \ - STATIC_CONTRACT_SO_INTOLERANT - -#define AFTER_CONTRACTS -#include "volatile.h" - -#endif // CONTRACT_H_ diff --git a/src/inc/contract.inl b/src/inc/contract.inl deleted file mode 100644 index ff165cf55..000000000 --- a/src/inc/contract.inl +++ /dev/null @@ -1,748 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -// --------------------------------------------------------------------------- -// Contract.inl -// - -// ! I am the owner for issues in the contract *infrastructure*, not for every -// ! CONTRACT_VIOLATION dialog that comes up. If you interrupt my work for a routine -// ! CONTRACT_VIOLATION, you will become the new owner of this file. -// --------------------------------------------------------------------------- - -#ifndef CONTRACT_INL_ -#define CONTRACT_INL_ - -#include "contract.h" -#include - -#ifndef _countof -#define _countof(x) (sizeof(x)/sizeof(x[0])) -#endif - -#ifdef ENABLE_CONTRACTS_IMPL - -#ifdef FEATURE_STACK_PROBE -/* FLAG to turn on/off dynamic SO Contract checking */ -extern BOOL g_EnableDefaultRWValidation; - -/* Used to report any code with SO_NOT_MAINLINE being run in a test environment - * with COMPLUS_NO_SO_NOT_MAINLINE enabled - */ -void SONotMainlineViolation(const char *szFunction, const char *szFile, int lineNum); - -/* Wrapper over SOTolerantViolation(). Used to report SO_Intolerant functions being called - * from SO_tolerant funcs without stack probing. - */ -void SoTolerantViolationHelper(const char *szFunction, - const char *szFile, - int lineNum); -#endif - - -inline void BaseContract::DoChecks(UINT testmask, __in_z const char *szFunction, __in_z char *szFile, int lineNum) -{ - STATIC_CONTRACT_DEBUG_ONLY; - STATIC_CONTRACT_NOTHROW; - STATIC_CONTRACT_GC_NOTRIGGER; - - // Cache the pointer to our ClrDebugState if it's not already cached. - // Derived types could set up this ptr before calling BaseContract::DoChecks if they have access to the Thread ptr - if (m_pClrDebugState == NULL) - { - m_pClrDebugState = GetClrDebugState(); - } - - // Save the incoming contents for restoration in the destructor - m_IncomingClrDebugState = *m_pClrDebugState; - - m_testmask = testmask; // Save the testmask for destructor - - // Setup the new stack record. - m_contractStackRecord.m_szFunction = szFunction; - m_contractStackRecord.m_szFile = szFile; - m_contractStackRecord.m_lineNum = lineNum; - m_contractStackRecord.m_testmask = testmask; - m_contractStackRecord.m_construct = "CONTRACT"; - - // Link the new ContractStackRecord into the chain for this thread. - m_pClrDebugState->LinkContractStackTrace( &m_contractStackRecord ); - - if (testmask & DEBUG_ONLY_Yes) - { - m_pClrDebugState->SetDebugOnly(); - } - -#ifdef FEATURE_STACK_PROBE //Dynamic SO contract checks only required when SO infrastructure is present. - - if (testmask & SO_MAINLINE_No) - { - static DWORD dwCheckNotMainline = -1; - - // Some tests should never hit an SO_NOT_MAINLINE contract - if (dwCheckNotMainline == -1) - dwCheckNotMainline = CLRConfig::GetConfigValue(CLRConfig::EXTERNAL_NO_SO_NOT_MAINLINE); - - - if (dwCheckNotMainline) - { - SONotMainlineViolation(m_contractStackRecord.m_szFunction, - m_contractStackRecord.m_szFile, - m_contractStackRecord.m_lineNum); - } - - m_pClrDebugState->SetSONotMainline(); - } - -#endif // FEATURE_STACK_PROBE - - switch (testmask & FAULT_Mask) - { - case FAULT_Forbid: - m_pClrDebugState->ViolationMaskReset( FaultViolation|FaultNotFatal ); - m_pClrDebugState->SetFaultForbid(); - break; - - case FAULT_Inject: - if (m_pClrDebugState->IsFaultForbid() && - !(m_pClrDebugState->ViolationMask() & (FaultViolation|FaultNotFatal|BadDebugState))) - { - CONTRACT_ASSERT("INJECT_FAULT called in a FAULTFORBID region.", - BaseContract::FAULT_Forbid, - BaseContract::FAULT_Mask, - m_contractStackRecord.m_szFunction, - m_contractStackRecord.m_szFile, - m_contractStackRecord.m_lineNum); - } - break; - - case FAULT_Disabled: - // Nothing - break; - - default: - UNREACHABLE(); - } - - switch (testmask & THROWS_Mask) - { - case THROWS_Yes: - m_pClrDebugState->CheckOkayToThrow(m_contractStackRecord.m_szFunction, - m_contractStackRecord.m_szFile, - m_contractStackRecord.m_lineNum); - break; - - case THROWS_No: - m_pClrDebugState->ViolationMaskReset( ThrowsViolation ); - m_pClrDebugState->ResetOkToThrow(); - break; - - case THROWS_Disabled: - // Nothing - break; - - default: - UNREACHABLE(); - } - - // LOADS_TYPE check - switch (testmask & LOADS_TYPE_Mask) - { - case LOADS_TYPE_Disabled: - // Nothing - break; - - default: - { - UINT newTypeLoadLevel = ((testmask & LOADS_TYPE_Mask) >> LOADS_TYPE_Shift) - 1; - if (newTypeLoadLevel > m_pClrDebugState->GetMaxLoadTypeLevel()) - { - if (!((LoadsTypeViolation|BadDebugState) & m_pClrDebugState->ViolationMask())) - { - CONTRACT_ASSERT("A function tried to load a type past the current level limit.", - (m_pClrDebugState->GetMaxLoadTypeLevel() + 1) << LOADS_TYPE_Shift, - Contract::LOADS_TYPE_Mask, - m_contractStackRecord.m_szFunction, - m_contractStackRecord.m_szFile, - m_contractStackRecord.m_lineNum - ); - } - } - m_pClrDebugState->SetMaxLoadTypeLevel(newTypeLoadLevel); - m_pClrDebugState->ViolationMaskReset(LoadsTypeViolation); - - } - break; - } - -#ifdef FEATURE_STACK_PROBE - - switch (testmask & SO_TOLERANCE_Mask) - { - case SO_TOLERANT_No: - if (g_EnableDefaultRWValidation) - { - m_pClrDebugState->CheckIfSOIntolerantOK(m_contractStackRecord.m_szFunction, - m_contractStackRecord.m_szFile, - m_contractStackRecord.m_lineNum); - } - break; - - case SO_TOLERANT_Yes: - case SO_TOLERANCE_Disabled: - // Nothing - break; - - default: - UNREACHABLE(); - } - -#endif // FEATURE_STACK_PROBE - - if (testmask & CAN_RETAKE_LOCK_No) - { - m_pClrDebugState->OnEnterCannotRetakeLockFunction(); - m_pClrDebugState->ResetOkToRetakeLock(); - } - - switch (testmask & CAN_TAKE_LOCK_Mask) - { - case CAN_TAKE_LOCK_Yes: - m_pClrDebugState->CheckOkayToLock(m_contractStackRecord.m_szFunction, - m_contractStackRecord.m_szFile, - m_contractStackRecord.m_lineNum); - break; - - case CAN_TAKE_LOCK_No: - m_pClrDebugState->ViolationMaskReset(TakesLockViolation); - m_pClrDebugState->ResetOkToLock(); - break; - - case CAN_TAKE_LOCK_Disabled: - // Nothing - break; - - default: - UNREACHABLE(); - } - -} - -FORCEINLINE BOOL BaseContract::CheckFaultInjection() -{ - // ??? use m_tag to see if we should trigger an injection - return FALSE; -} - -inline BOOL ClrDebugState::CheckOkayToThrowNoAssert() -{ - if (!IsOkToThrow() && !(m_violationmask & (ThrowsViolation|BadDebugState))) - { - return FALSE; - } - return TRUE; -} - -inline void ClrDebugState::CheckOkayToThrow(__in_z const char *szFunction, __in_z const char *szFile, int lineNum) -{ - STATIC_CONTRACT_DEBUG_ONLY; - STATIC_CONTRACT_NOTHROW; - STATIC_CONTRACT_GC_NOTRIGGER; - - if (!CheckOkayToThrowNoAssert()) - { - CONTRACT_ASSERT("THROWS called in a NOTHROW region.", - BaseContract::THROWS_No, - BaseContract::THROWS_Mask, - szFunction, - szFile, - lineNum); - } -} - -inline BOOL ClrDebugState::CheckOkayToLockNoAssert() -{ - STATIC_CONTRACT_DEBUG_ONLY; - STATIC_CONTRACT_NOTHROW; - STATIC_CONTRACT_GC_NOTRIGGER; - - if (!IsOkToLock() && !(m_violationmask & (TakesLockViolation|BadDebugState))) - { - return FALSE; - } - return TRUE; -} - -inline void ClrDebugState::CheckOkayToLock(__in_z const char *szFunction, __in_z const char *szFile, int lineNum) -{ - STATIC_CONTRACT_DEBUG_ONLY; - STATIC_CONTRACT_NOTHROW; - STATIC_CONTRACT_GC_NOTRIGGER; - - if (!CheckOkayToLockNoAssert()) - { - - CONTRACT_ASSERT("CAN_TAKE_LOCK called in a CANNOT_TAKE_LOCK region.", - BaseContract::CAN_TAKE_LOCK_No, - BaseContract::CAN_TAKE_LOCK_Mask, - szFunction, - szFile, - lineNum); - - } -} - - -inline void ClrDebugState::LockTaken(DbgStateLockType dbgStateLockType, - UINT cTakes, - void * pvLock, - __in_z const char * szFunction, - __in_z const char * szFile, - int lineNum) -{ - STATIC_CONTRACT_DEBUG_ONLY; - STATIC_CONTRACT_NOTHROW; - STATIC_CONTRACT_GC_NOTRIGGER; - - if ((m_violationmask & BadDebugState) != 0) - { - return; - } - - // Assert if we're taking a lock in a CANNOT_TAKE_LOCK scope. Even if this asserts, we'll - // continue to the following lines to track the lock - CheckOkayToLock(szFunction, szFile, lineNum); - - _ASSERTE(GetDbgStateLockData() != NULL); - - if (!IsOkToRetakeLock()) - { - if (m_LockState.IsLockRetaken(pvLock)) - { - CONTRACT_ASSERT("You cannot take a lock which is already being held in a CANNOT_RETAKE_LOCK scope.", - BaseContract::CAN_RETAKE_LOCK_No, - BaseContract::CAN_RETAKE_LOCK_No, - szFunction, - szFile, - lineNum); - } - } - - GetDbgStateLockData()->LockTaken(dbgStateLockType, cTakes, pvLock, szFunction, szFile, lineNum); -} - -inline void ClrDebugState::LockReleased(DbgStateLockType dbgStateLockType, UINT cReleases, void * pvLock) -{ - STATIC_CONTRACT_DEBUG_ONLY; - STATIC_CONTRACT_NOTHROW; - STATIC_CONTRACT_GC_NOTRIGGER; - - if ((m_violationmask & BadDebugState) != 0) - { - return; - } - - _ASSERTE(GetDbgStateLockData() != NULL); - - if (!IsOkToRetakeLock()) - { - // It is very suspicious to release any locks being hold at the time this function was - // called in a CANNOT_RETAKE_LOCK scope - _ASSERTE(m_LockState.IsSafeToRelease(cReleases)); - } - - GetDbgStateLockData()->LockReleased(dbgStateLockType, cReleases, pvLock); -} - -inline UINT ClrDebugState::GetLockCount(DbgStateLockType dbgStateLockType) -{ - STATIC_CONTRACT_DEBUG_ONLY; - STATIC_CONTRACT_NOTHROW; - STATIC_CONTRACT_GC_NOTRIGGER; - - if ((m_violationmask & BadDebugState) != 0) - { - return 0; - } - - _ASSERTE(GetDbgStateLockData() != NULL); - return GetDbgStateLockData()->GetLockCount(dbgStateLockType); -} - -inline UINT ClrDebugState::GetCombinedLockCount() -{ - STATIC_CONTRACT_DEBUG_ONLY; - STATIC_CONTRACT_NOTHROW; - STATIC_CONTRACT_GC_NOTRIGGER; - - if ((m_violationmask & BadDebugState) != 0) - { - return 0; - } - - _ASSERTE(GetDbgStateLockData() != NULL); - return GetDbgStateLockData()->GetCombinedLockCount(); -} - -inline void DbgStateLockData::LockTaken(DbgStateLockType dbgStateLockType, - UINT cTakes, // # times we're taking this lock (usually 1) - void * pvLock, - __in_z const char * szFunction, - __in_z const char * szFile, - int lineNum) -{ - STATIC_CONTRACT_NOTHROW; - STATIC_CONTRACT_GC_NOTRIGGER; - - // Technically the lock's already been taken before we're called, but it's - // handy to have this contract here at the leaf end of the call chain, as it - // ensures SCAN will enforce that no use of the LOCK_TAKEN macros occurs - // in a CANNOT_TAKE_LOCK scope (as LOCK_TAKEN macros just call this function). - STATIC_CONTRACT_CAN_TAKE_LOCK; - - // Valid enum? - _ASSERTE(UINT(dbgStateLockType) < kDbgStateLockType_Count); - - UINT cCombinedLocks = GetCombinedLockCount(); - - // Are we exceeding the threshold for what we can store in m_rgTakenLockInfos? - // If so, assert a warning, but we'll deal with it. - if ((cCombinedLocks <= _countof(m_rgTakenLockInfos)) && - (cCombinedLocks + cTakes > _countof(m_rgTakenLockInfos))) - { - // Actually, for now we are NOT asserting until I can dedicate more time - // to this. Some class loader code paths legally hold many simultaneous - // locks (>10). Need to do further analysis on reasonable value to set - // for kMaxAllowedSimultaneousLocks. Since lock order checking is turned - // off for the moment anyway, exceeding kMaxAllowedSimultaneousLocks - // has no consequences for now anyway. - } - - m_rgcLocksTaken[dbgStateLockType] += cTakes; - - // Remember as many of these new entrances in m_rgTakenLockInfos as we can - for (UINT i = cCombinedLocks; - i < min (_countof(m_rgTakenLockInfos), cCombinedLocks + cTakes); - i++) - { - m_rgTakenLockInfos[i].m_pvLock = pvLock; - m_rgTakenLockInfos[i].m_szFile = szFile; - m_rgTakenLockInfos[i].m_lineNum = lineNum; - } -} - -inline void DbgStateLockData::LockReleased(DbgStateLockType dbgStateLockType, UINT cReleases, void * pvLock) -{ - // Valid enum? - _ASSERTE(UINT(dbgStateLockType) < kDbgStateLockType_Count); - - if (cReleases > m_rgcLocksTaken[dbgStateLockType]) - { - _ASSERTE(!"Releasing lock(s) that were never taken"); - cReleases = m_rgcLocksTaken[dbgStateLockType]; - } - - UINT cCombinedLocks = GetCombinedLockCount(); - - // If lock count is within range of our m_rgTakenLockInfos buffer size, then - // make sure we're releasing locks in reverse order of how we took them - for (UINT i = cCombinedLocks - cReleases; - i < min (_countof(m_rgTakenLockInfos), cCombinedLocks); - i++) - { - if (m_rgTakenLockInfos[i].m_pvLock != pvLock) - { - // Ok, I lied. We're not really checking that we're releasing locks in reverse - // order, because sometimes we legally release them out of order. (The loader - // does this intentionally in a few places.) We should consider whether those - // places can be changed, or whether we can add some kind of macro to declare - // that we're releasing out of order, and that it's ok & intentional. At that - // point, we can place a nice ASSERTE right here. Until then, do nothing. - } - - // We may be clearing out the wrong entry in m_rgTakenLockInfos here, if the locks - // were released out of order. However, it will eventually correct itself once all - // the out-of-order locks have been released. And our count - // (i.e., m_rgcLocksTaken[dbgStateLockType]) will always be accurate - memset(&(m_rgTakenLockInfos[i]), - 0, - sizeof(m_rgTakenLockInfos[i])); - } - - m_rgcLocksTaken[dbgStateLockType] -= cReleases; -} - -inline void DbgStateLockData::SetStartingValues() -{ - memset(this, 0, sizeof(*this)); -} - -inline UINT DbgStateLockData::GetLockCount(DbgStateLockType dbgStateLockType) -{ - _ASSERTE(UINT(dbgStateLockType) < kDbgStateLockType_Count); - return m_rgcLocksTaken[dbgStateLockType]; -} - -inline UINT DbgStateLockData::GetCombinedLockCount() -{ - // If this fires, the set of lock types must have changed. You'll need to - // fix the sum below to include all lock types - _ASSERTE(kDbgStateLockType_Count == 3); - - return m_rgcLocksTaken[0] + m_rgcLocksTaken[1] + m_rgcLocksTaken[2]; -} - -inline void DbgStateLockState::SetStartingValues() -{ - m_cLocksEnteringCannotRetakeLock = 0; - m_pLockData = NULL; // Will get filled in by CLRInitDebugState() -} - -// We set a marker to record the number of locks that have been taken when -// CANNOT_RETAKE_LOCK contract is constructed. -inline void DbgStateLockState::OnEnterCannotRetakeLockFunction() -{ - m_cLocksEnteringCannotRetakeLock = m_pLockData->GetCombinedLockCount(); -} - -inline BOOL DbgStateLockState::IsLockRetaken(void * pvLock) -{ - // m_cLocksEnteringCannotRetakeLock must be in valid range - _ASSERTE(m_cLocksEnteringCannotRetakeLock <= m_pLockData->GetCombinedLockCount()); - - // m_cLocksEnteringCannotRetakeLock records the number of locks that were taken - // when CANNOT_RETAKE_LOCK contract was constructed. - for (UINT i = 0; - i < min(_countof(m_pLockData->m_rgTakenLockInfos), m_cLocksEnteringCannotRetakeLock); - ++i) - { - if (m_pLockData->m_rgTakenLockInfos[i].m_pvLock == pvLock) - { - return TRUE; - } - } - return FALSE; -} - -inline BOOL DbgStateLockState::IsSafeToRelease(UINT cReleases) -{ - return m_cLocksEnteringCannotRetakeLock <= (m_pLockData->GetCombinedLockCount() - cReleases); -} - -inline void DbgStateLockState::SetDbgStateLockData(DbgStateLockData * pDbgStateLockData) -{ - m_pLockData = pDbgStateLockData; -} - -inline DbgStateLockData * DbgStateLockState::GetDbgStateLockData() -{ - return m_pLockData; -} - -#ifdef FEATURE_STACK_PROBE -// We don't want to allow functions that use holders to EX_TRY to be intolerant -// code... if an exception were to occur, the holders and EX_CATCH/FINALLY would -// have less than 1/4 clean up. -inline void EnsureSOIntolerantOK(const char *szFunction, - const char *szFile, - int lineNum) -{ - // We don't want to use a holder here, because a holder will - // call EnsureSOIntolerantOK - - DWORD error = GetLastError(); - if (! g_EnableDefaultRWValidation) - { - SetLastError(error); - return; - } - ClrDebugState *pClrDebugState = CheckClrDebugState(); - if (! pClrDebugState) - { - SetLastError(error); - return; - } - pClrDebugState->CheckIfSOIntolerantOK(szFunction, szFile, lineNum); - SetLastError(error); -} - -inline void ClrDebugState::CheckIfSOIntolerantOK(const char *szFunction, - const char *szFile, - int lineNum) - -{ - // If we are an RW function on a managed thread, we must be in SO-intolerant mode. Ie. we must be behind a probe. - if (IsSOIntolerant() || IsDebugOnly() || IsSONotMainline() || (m_violationmask & SOToleranceViolation) || - !g_fpShouldValidateSOToleranceOnThisThread || !g_fpShouldValidateSOToleranceOnThisThread()) - { - return; - } - SoTolerantViolationHelper(szFunction, szFile, lineNum); -} - -#endif - -inline -void CONTRACT_ASSERT(const char *szElaboration, - UINT whichTest, - UINT whichTestMask, - const char *szFunction, - const char *szFile, - int lineNum) -{ - if (CheckClrDebugState() && ( CheckClrDebugState()->ViolationMask() & BadDebugState)) - { - _ASSERTE(!"Someone tried to assert a contract violation although the contracts were disabled in this thread due to" - " an OOM or a shim/mscorwks mismatch. You can probably safely ignore this assert - however, whoever" - " called CONTRACT_ASSERT was supposed to checked if the current violationmask had the BadDebugState set." - " Look up the stack, see who called CONTRACT_ASSERT and file a bug against the owner."); - return; - } - - // prevent recursion - we use the same mechanism as CHECK, so this will - // also prevent mutual recursion involving ASSERT_CHECKs - CHECK _check; - if (_check.EnterAssert()) - { - char Buf[512*20 + 2048 + 1024]; - - sprintf_s(Buf,_countof(Buf), "CONTRACT VIOLATION by %s at \"%s\" @ %d\n\n%s\n", szFunction, szFile, lineNum, szElaboration); - - int count = 20; - ContractStackRecord *pRec = CheckClrDebugState() ? CheckClrDebugState()->GetContractStackTrace() : NULL; - BOOL foundconflict = FALSE; - BOOL exceptionBuildingStack = FALSE; - - PAL_TRY_NAKED - { - while (pRec != NULL) - { - char tmpbuf[512]; - BOOL fshowconflict = FALSE; - - if (!foundconflict) - { - if (whichTest == (pRec->m_testmask & whichTestMask)) - { - foundconflict = TRUE; - fshowconflict = TRUE; - } - } - - if (count != 0 || fshowconflict) - { - if (count != 0) - { - count--; - } - else - { - // Show that some lines have been skipped - strcat_s(Buf, _countof(Buf), "\n ..."); - - } - - sprintf_s(tmpbuf,_countof(tmpbuf), - "\n%s %s in %s at \"%s\" @ %d", - fshowconflict ? "VIOLATED-->" : " ", - pRec->m_construct, - pRec->m_szFunction, - pRec->m_szFile, - pRec->m_lineNum - ); - - strcat_s(Buf, _countof(Buf), tmpbuf); - } - - pRec = pRec->m_pNext; - } - } - PAL_EXCEPT_NAKED(EXCEPTION_EXECUTE_HANDLER) - { - // We're done trying to walk the stack of contracts. We faulted trying to form the contract stack trace, - // and that usually means that its corrupted. A common cause of this is having CONTRACTs in functions that - // never return, but instead do a non-local goto. - count = 0; - exceptionBuildingStack = TRUE; - } - PAL_ENDTRY_NAKED; - - if (count == 0) - { - strcat_s(Buf,_countof(Buf), "\n ..."); - } - - if (exceptionBuildingStack) - { - strcat_s(Buf,_countof(Buf), - "\n" - "\nError forming contract stack. Any contract stack displayed above is correct," - "\nbut it's most probably truncated. This is probably due to a CONTRACT in a" - "\nfunction that does a non-local goto. There are two bugs here:" - "\n" - "\n 1) the CONTRACT violation, and" - "\n 2) the CONTRACT in the function with the non-local goto." - "\n" - "\nPlease fix both bugs!" - "\n" - ); - } - - strcat_s(Buf,_countof(Buf), "\n\n"); - - if (!foundconflict && count != 0) - { - if (whichTest == BaseContract::THROWS_No) - { - strcat_s(Buf,_countof(Buf), "You can't throw here because there is no handler on the stack.\n"); - } - else - { - strcat_s(Buf,_countof(Buf), "We can't find the violated contract. Look for an old-style non-holder-based contract.\n"); - } - } - - DbgAssertDialog((char *)szFile, lineNum, Buf); - _check.LeaveAssert(); - } -} - - -FORCEINLINE BOOL BaseContract::EnforceContract() -{ - if (s_alwaysEnforceContracts) - return TRUE; - else - return CHECK::EnforceAssert(); -} - -inline void BaseContract::SetUnconditionalContractEnforcement(BOOL value) -{ - s_alwaysEnforceContracts = value; -} - -inline UINT GetDbgStateCombinedLockCount() -{ - return GetClrDebugState()->GetCombinedLockCount(); -} -inline UINT GetDbgStateLockCount(DbgStateLockType dbgStateLockType) -{ - return GetClrDebugState()->GetLockCount(dbgStateLockType); -} - -#define ASSERT_NO_USER_LOCKS_HELD() \ - _ASSERTE(GetDbgStateLockCount(kDbgStateLockType_User) == 0) -#define ASSERT_NO_HOST_BREAKABLE_CRSTS_HELD() \ - _ASSERTE(GetDbgStateLockCount(kDbgStateLockType_HostBreakableCrst) == 0) -#define ASSERT_NO_EE_LOCKS_HELD() \ - _ASSERTE(GetDbgStateLockCount(kDbgStateLockType_EE) == 0) - -#else // ENABLE_CONTRACTS_IMPL - -#define ASSERT_NO_USER_LOCKS_HELD() -#define ASSERT_NO_HOST_BREAKABLE_CRSTS_HELD() -#define ASSERT_NO_EE_LOCKS_HELD() - -#endif // ENABLE_CONTRACTS_IMPL - -#endif // CONTRACT_INL_ diff --git a/src/inc/contxt.h b/src/inc/contxt.h deleted file mode 100644 index 98240b333..000000000 --- a/src/inc/contxt.h +++ /dev/null @@ -1,3472 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/* this ALWAYS GENERATED file contains the definitions for the interfaces */ - - -/* File created by MIDL compiler version 5.01.0164 */ -/* at Mon May 01 14:39:38 2000 - */ -/* Compiler settings for contxt.idl: - Os (OptLev=s), W1, Zp8, env=Win32, ms_ext, c_ext - error checks: allocation ref bounds_check enum stub_data -*/ -//@@MIDL_FILE_HEADING( ) - - -/* verify that the version is high enough to compile this file*/ -#ifndef __REQUIRED_RPCNDR_H_VERSION__ -#define __REQUIRED_RPCNDR_H_VERSION__ 440 -#endif - -#include "rpc.h" -#include "rpcndr.h" - -#ifndef __RPCNDR_H_VERSION__ -#error this stub requires an updated version of -#endif // __RPCNDR_H_VERSION__ - -#ifndef COM_NO_WINDOWS_H -#include "windows.h" -#include "ole2.h" -#endif /*COM_NO_WINDOWS_H*/ - -#ifndef __contxt_h__ -#define __contxt_h__ - -#ifdef __cplusplus -extern "C"{ -#endif - -/* Forward Declarations */ - -#ifndef __IEnumContextProps_FWD_DEFINED__ -#define __IEnumContextProps_FWD_DEFINED__ -typedef interface IEnumContextProps IEnumContextProps; -#endif /* __IEnumContextProps_FWD_DEFINED__ */ - - -#ifndef __IContext_FWD_DEFINED__ -#define __IContext_FWD_DEFINED__ -typedef interface IContext IContext; -#endif /* __IContext_FWD_DEFINED__ */ - - -#ifndef __IContextMarshaler_FWD_DEFINED__ -#define __IContextMarshaler_FWD_DEFINED__ -typedef interface IContextMarshaler IContextMarshaler; -#endif /* __IContextMarshaler_FWD_DEFINED__ */ - - -#ifndef __IObjContext_FWD_DEFINED__ -#define __IObjContext_FWD_DEFINED__ -typedef interface IObjContext IObjContext; -#endif /* __IObjContext_FWD_DEFINED__ */ - - -#ifndef __IGetContextId_FWD_DEFINED__ -#define __IGetContextId_FWD_DEFINED__ -typedef interface IGetContextId IGetContextId; -#endif /* __IGetContextId_FWD_DEFINED__ */ - - -#ifndef __IAggregator_FWD_DEFINED__ -#define __IAggregator_FWD_DEFINED__ -typedef interface IAggregator IAggregator; -#endif /* __IAggregator_FWD_DEFINED__ */ - - -#ifndef __ICall_FWD_DEFINED__ -#define __ICall_FWD_DEFINED__ -typedef interface ICall ICall; -#endif /* __ICall_FWD_DEFINED__ */ - - -#ifndef __IRpcCall_FWD_DEFINED__ -#define __IRpcCall_FWD_DEFINED__ -typedef interface IRpcCall IRpcCall; -#endif /* __IRpcCall_FWD_DEFINED__ */ - - -#ifndef __ICallInfo_FWD_DEFINED__ -#define __ICallInfo_FWD_DEFINED__ -typedef interface ICallInfo ICallInfo; -#endif /* __ICallInfo_FWD_DEFINED__ */ - - -#ifndef __IPolicy_FWD_DEFINED__ -#define __IPolicy_FWD_DEFINED__ -typedef interface IPolicy IPolicy; -#endif /* __IPolicy_FWD_DEFINED__ */ - - -#ifndef __IPolicyAsync_FWD_DEFINED__ -#define __IPolicyAsync_FWD_DEFINED__ -typedef interface IPolicyAsync IPolicyAsync; -#endif /* __IPolicyAsync_FWD_DEFINED__ */ - - -#ifndef __IPolicySet_FWD_DEFINED__ -#define __IPolicySet_FWD_DEFINED__ -typedef interface IPolicySet IPolicySet; -#endif /* __IPolicySet_FWD_DEFINED__ */ - - -#ifndef __IComObjIdentity_FWD_DEFINED__ -#define __IComObjIdentity_FWD_DEFINED__ -typedef interface IComObjIdentity IComObjIdentity; -#endif /* __IComObjIdentity_FWD_DEFINED__ */ - - -#ifndef __IPolicyMaker_FWD_DEFINED__ -#define __IPolicyMaker_FWD_DEFINED__ -typedef interface IPolicyMaker IPolicyMaker; -#endif /* __IPolicyMaker_FWD_DEFINED__ */ - - -#ifndef __IExceptionNotification_FWD_DEFINED__ -#define __IExceptionNotification_FWD_DEFINED__ -typedef interface IExceptionNotification IExceptionNotification; -#endif /* __IExceptionNotification_FWD_DEFINED__ */ - - -#ifndef __IMarshalEnvoy_FWD_DEFINED__ -#define __IMarshalEnvoy_FWD_DEFINED__ -typedef interface IMarshalEnvoy IMarshalEnvoy; -#endif /* __IMarshalEnvoy_FWD_DEFINED__ */ - - -#ifndef __IWrapperInfo_FWD_DEFINED__ -#define __IWrapperInfo_FWD_DEFINED__ -typedef interface IWrapperInfo IWrapperInfo; -#endif /* __IWrapperInfo_FWD_DEFINED__ */ - - -#ifndef __IComThreadingInfo_FWD_DEFINED__ -#define __IComThreadingInfo_FWD_DEFINED__ -typedef interface IComThreadingInfo IComThreadingInfo; -#endif /* __IComThreadingInfo_FWD_DEFINED__ */ - - -#ifndef __IComDispatchInfo_FWD_DEFINED__ -#define __IComDispatchInfo_FWD_DEFINED__ -typedef interface IComDispatchInfo IComDispatchInfo; -#endif /* __IComDispatchInfo_FWD_DEFINED__ */ - - -/* header files for imported files */ -#include "wtypes.h" -#include "objidl.h" - -void __RPC_FAR * __RPC_USER MIDL_user_allocate(size_t); -void __RPC_USER MIDL_user_free( void __RPC_FAR * ); - -/* interface __MIDL_itf_contxt_0000 */ -/* [local] */ - -enum tagCONTEXTEVENT - { CONTEXTEVENT_NONE = 0, - CONTEXTEVENT_CALL = 0x1, - CONTEXTEVENT_ENTER = 0x2, - CONTEXTEVENT_LEAVE = 0x4, - CONTEXTEVENT_RETURN = 0x8, - CONTEXTEVENT_CALLFILLBUFFER = 0x10, - CONTEXTEVENT_ENTERWITHBUFFER = 0x20, - CONTEXTEVENT_LEAVEFILLBUFFER = 0x40, - CONTEXTEVENT_RETURNWITHBUFFER = 0x80, - CONTEXTEVENT_BEGINCALL = 0x100, - CONTEXTEVENT_BEGINENTER = 0x200, - CONTEXTEVENT_BEGINLEAVE = 0x400, - CONTEXTEVENT_BEGINRETURN = 0x800, - CONTEXTEVENT_FINISHCALL = 0x1000, - CONTEXTEVENT_FINISHENTER = 0x2000, - CONTEXTEVENT_FINISHLEAVE = 0x4000, - CONTEXTEVENT_FINISHRETURN = 0x8000, - CONTEXTEVENT_BEGINCALLFILLBUFFER = 0x10000, - CONTEXTEVENT_BEGINENTERWITHBUFFER = 0x20000, - CONTEXTEVENT_FINISHLEAVEFILLBUFFER = 0x40000, - CONTEXTEVENT_FINISHRETURNWITHBUFFER = 0x80000, - CONTEXTEVENT_LEAVEEXCEPTION = 0x100000, - CONTEXTEVENT_LEAVEEXCEPTIONFILLBUFFER = 0x200000, - CONTEXTEVENT_RETURNEXCEPTION = 0x400000, - CONTEXTEVENT_RETURNEXCEPTIONWITHBUFFER = 0x800000, - CONTEXTEVENT_ADDREFPOLICY = 0x10000000, - CONTEXTEVENT_RELEASEPOLICY = 0x20000000 - }; -typedef DWORD ContextEvent; - - -enum tagCPFLAGS - { CPFLAG_NONE = 0, - CPFLAG_PROPAGATE = 0x1, - CPFLAG_EXPOSE = 0x2, - CPFLAG_ENVOY = 0x4, - CPFLAG_MONITORSTUB = 0x8, - CPFLAG_MONITORPROXY = 0x10, - CPFLAG_DONTCOMPARE = 0x20 - }; -typedef DWORD CPFLAGS; - -extern RPC_IF_HANDLE __MIDL_itf_contxt_0000_v0_0_c_ifspec; -extern RPC_IF_HANDLE __MIDL_itf_contxt_0000_v0_0_s_ifspec; - -#ifndef __IEnumContextProps_INTERFACE_DEFINED__ -#define __IEnumContextProps_INTERFACE_DEFINED__ - -/* interface IEnumContextProps */ -/* [unique][uuid][object] */ - -typedef /* [unique] */ IEnumContextProps __RPC_FAR *LPENUMCONTEXTPROPS; - - -EXTERN_C const IID IID_IEnumContextProps; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("000001c1-0000-0000-C000-000000000046") - IEnumContextProps : public IUnknown - { - public: - virtual HRESULT STDMETHODCALLTYPE Next( - /* [in] */ ULONG celt, - /* [length_is][size_is][out] */ ContextProperty __RPC_FAR *pContextProperties, - /* [out] */ ULONG __RPC_FAR *pceltFetched) = 0; - - virtual HRESULT STDMETHODCALLTYPE Skip( - /* [in] */ ULONG celt) = 0; - - virtual HRESULT STDMETHODCALLTYPE Reset( void) = 0; - - virtual HRESULT STDMETHODCALLTYPE Clone( - /* [out] */ IEnumContextProps __RPC_FAR *__RPC_FAR *ppEnumContextProps) = 0; - - virtual HRESULT STDMETHODCALLTYPE Count( - /* [out] */ ULONG __RPC_FAR *pcelt) = 0; - - }; - -#else /* C style interface */ - - typedef struct IEnumContextPropsVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( - IEnumContextProps __RPC_FAR * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject); - - ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( - IEnumContextProps __RPC_FAR * This); - - ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( - IEnumContextProps __RPC_FAR * This); - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Next )( - IEnumContextProps __RPC_FAR * This, - /* [in] */ ULONG celt, - /* [length_is][size_is][out] */ ContextProperty __RPC_FAR *pContextProperties, - /* [out] */ ULONG __RPC_FAR *pceltFetched); - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Skip )( - IEnumContextProps __RPC_FAR * This, - /* [in] */ ULONG celt); - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Reset )( - IEnumContextProps __RPC_FAR * This); - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Clone )( - IEnumContextProps __RPC_FAR * This, - /* [out] */ IEnumContextProps __RPC_FAR *__RPC_FAR *ppEnumContextProps); - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Count )( - IEnumContextProps __RPC_FAR * This, - /* [out] */ ULONG __RPC_FAR *pcelt); - - END_INTERFACE - } IEnumContextPropsVtbl; - - interface IEnumContextProps - { - CONST_VTBL struct IEnumContextPropsVtbl __RPC_FAR *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define IEnumContextProps_QueryInterface(This,riid,ppvObject) \ - (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) - -#define IEnumContextProps_AddRef(This) \ - (This)->lpVtbl -> AddRef(This) - -#define IEnumContextProps_Release(This) \ - (This)->lpVtbl -> Release(This) - - -#define IEnumContextProps_Next(This,celt,pContextProperties,pceltFetched) \ - (This)->lpVtbl -> Next(This,celt,pContextProperties,pceltFetched) - -#define IEnumContextProps_Skip(This,celt) \ - (This)->lpVtbl -> Skip(This,celt) - -#define IEnumContextProps_Reset(This) \ - (This)->lpVtbl -> Reset(This) - -#define IEnumContextProps_Clone(This,ppEnumContextProps) \ - (This)->lpVtbl -> Clone(This,ppEnumContextProps) - -#define IEnumContextProps_Count(This,pcelt) \ - (This)->lpVtbl -> Count(This,pcelt) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - -HRESULT STDMETHODCALLTYPE IEnumContextProps_Next_Proxy( - IEnumContextProps __RPC_FAR * This, - /* [in] */ ULONG celt, - /* [length_is][size_is][out] */ ContextProperty __RPC_FAR *pContextProperties, - /* [out] */ ULONG __RPC_FAR *pceltFetched); - - -void __RPC_STUB IEnumContextProps_Next_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IEnumContextProps_Skip_Proxy( - IEnumContextProps __RPC_FAR * This, - /* [in] */ ULONG celt); - - -void __RPC_STUB IEnumContextProps_Skip_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IEnumContextProps_Reset_Proxy( - IEnumContextProps __RPC_FAR * This); - - -void __RPC_STUB IEnumContextProps_Reset_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IEnumContextProps_Clone_Proxy( - IEnumContextProps __RPC_FAR * This, - /* [out] */ IEnumContextProps __RPC_FAR *__RPC_FAR *ppEnumContextProps); - - -void __RPC_STUB IEnumContextProps_Clone_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IEnumContextProps_Count_Proxy( - IEnumContextProps __RPC_FAR * This, - /* [out] */ ULONG __RPC_FAR *pcelt); - - -void __RPC_STUB IEnumContextProps_Count_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - - -#endif /* __IEnumContextProps_INTERFACE_DEFINED__ */ - - -#ifndef __IContext_INTERFACE_DEFINED__ -#define __IContext_INTERFACE_DEFINED__ - -/* interface IContext */ -/* [unique][uuid][object][local] */ - - -EXTERN_C const IID IID_IContext; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("000001c0-0000-0000-C000-000000000046") - IContext : public IUnknown - { - public: - virtual HRESULT STDMETHODCALLTYPE SetProperty( - /* [in] */ REFGUID rpolicyId, - /* [in] */ CPFLAGS flags, - /* [in] */ IUnknown __RPC_FAR *pUnk) = 0; - - virtual HRESULT STDMETHODCALLTYPE RemoveProperty( - /* [in] */ REFGUID rPolicyId) = 0; - - virtual HRESULT STDMETHODCALLTYPE GetProperty( - /* [in] */ REFGUID rGuid, - /* [out] */ CPFLAGS __RPC_FAR *pFlags, - /* [out] */ IUnknown __RPC_FAR *__RPC_FAR *ppUnk) = 0; - - virtual HRESULT STDMETHODCALLTYPE EnumContextProps( - /* [out] */ IEnumContextProps __RPC_FAR *__RPC_FAR *ppEnumContextProps) = 0; - - }; - -#else /* C style interface */ - - typedef struct IContextVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( - IContext __RPC_FAR * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject); - - ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( - IContext __RPC_FAR * This); - - ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( - IContext __RPC_FAR * This); - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *SetProperty )( - IContext __RPC_FAR * This, - /* [in] */ REFGUID rpolicyId, - /* [in] */ CPFLAGS flags, - /* [in] */ IUnknown __RPC_FAR *pUnk); - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *RemoveProperty )( - IContext __RPC_FAR * This, - /* [in] */ REFGUID rPolicyId); - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetProperty )( - IContext __RPC_FAR * This, - /* [in] */ REFGUID rGuid, - /* [out] */ CPFLAGS __RPC_FAR *pFlags, - /* [out] */ IUnknown __RPC_FAR *__RPC_FAR *ppUnk); - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *EnumContextProps )( - IContext __RPC_FAR * This, - /* [out] */ IEnumContextProps __RPC_FAR *__RPC_FAR *ppEnumContextProps); - - END_INTERFACE - } IContextVtbl; - - interface IContext - { - CONST_VTBL struct IContextVtbl __RPC_FAR *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define IContext_QueryInterface(This,riid,ppvObject) \ - (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) - -#define IContext_AddRef(This) \ - (This)->lpVtbl -> AddRef(This) - -#define IContext_Release(This) \ - (This)->lpVtbl -> Release(This) - - -#define IContext_SetProperty(This,rpolicyId,flags,pUnk) \ - (This)->lpVtbl -> SetProperty(This,rpolicyId,flags,pUnk) - -#define IContext_RemoveProperty(This,rPolicyId) \ - (This)->lpVtbl -> RemoveProperty(This,rPolicyId) - -#define IContext_GetProperty(This,rGuid,pFlags,ppUnk) \ - (This)->lpVtbl -> GetProperty(This,rGuid,pFlags,ppUnk) - -#define IContext_EnumContextProps(This,ppEnumContextProps) \ - (This)->lpVtbl -> EnumContextProps(This,ppEnumContextProps) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - -HRESULT STDMETHODCALLTYPE IContext_SetProperty_Proxy( - IContext __RPC_FAR * This, - /* [in] */ REFGUID rpolicyId, - /* [in] */ CPFLAGS flags, - /* [in] */ IUnknown __RPC_FAR *pUnk); - - -void __RPC_STUB IContext_SetProperty_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IContext_RemoveProperty_Proxy( - IContext __RPC_FAR * This, - /* [in] */ REFGUID rPolicyId); - - -void __RPC_STUB IContext_RemoveProperty_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IContext_GetProperty_Proxy( - IContext __RPC_FAR * This, - /* [in] */ REFGUID rGuid, - /* [out] */ CPFLAGS __RPC_FAR *pFlags, - /* [out] */ IUnknown __RPC_FAR *__RPC_FAR *ppUnk); - - -void __RPC_STUB IContext_GetProperty_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IContext_EnumContextProps_Proxy( - IContext __RPC_FAR * This, - /* [out] */ IEnumContextProps __RPC_FAR *__RPC_FAR *ppEnumContextProps); - - -void __RPC_STUB IContext_EnumContextProps_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - - -#endif /* __IContext_INTERFACE_DEFINED__ */ - - -#ifndef __IContextMarshaler_INTERFACE_DEFINED__ -#define __IContextMarshaler_INTERFACE_DEFINED__ - -/* interface IContextMarshaler */ -/* [uuid][object][local] */ - -typedef /* [unique] */ IContextMarshaler __RPC_FAR *LPCTXMARSHALER; - - -EXTERN_C const IID IID_IContextMarshaler; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("000001D8-0000-0000-C000-000000000046") - IContextMarshaler : public IUnknown - { - public: - virtual HRESULT STDMETHODCALLTYPE GetMarshalSizeMax( - /* [in] */ REFIID riid, - /* [unique][in] */ void __RPC_FAR *pv, - /* [in] */ DWORD dwDestContext, - /* [unique][in] */ void __RPC_FAR *pvDestContext, - /* [in] */ DWORD mshlflags, - /* [out] */ DWORD __RPC_FAR *pSize) = 0; - - virtual HRESULT STDMETHODCALLTYPE MarshalInterface( - /* [unique][in] */ IStream __RPC_FAR *pStm, - /* [in] */ REFIID riid, - /* [unique][in] */ void __RPC_FAR *pv, - /* [in] */ DWORD dwDestContext, - /* [unique][in] */ void __RPC_FAR *pvDestContext, - /* [in] */ DWORD mshlflags) = 0; - - }; - -#else /* C style interface */ - - typedef struct IContextMarshalerVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( - IContextMarshaler __RPC_FAR * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject); - - ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( - IContextMarshaler __RPC_FAR * This); - - ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( - IContextMarshaler __RPC_FAR * This); - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetMarshalSizeMax )( - IContextMarshaler __RPC_FAR * This, - /* [in] */ REFIID riid, - /* [unique][in] */ void __RPC_FAR *pv, - /* [in] */ DWORD dwDestContext, - /* [unique][in] */ void __RPC_FAR *pvDestContext, - /* [in] */ DWORD mshlflags, - /* [out] */ DWORD __RPC_FAR *pSize); - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *MarshalInterface )( - IContextMarshaler __RPC_FAR * This, - /* [unique][in] */ IStream __RPC_FAR *pStm, - /* [in] */ REFIID riid, - /* [unique][in] */ void __RPC_FAR *pv, - /* [in] */ DWORD dwDestContext, - /* [unique][in] */ void __RPC_FAR *pvDestContext, - /* [in] */ DWORD mshlflags); - - END_INTERFACE - } IContextMarshalerVtbl; - - interface IContextMarshaler - { - CONST_VTBL struct IContextMarshalerVtbl __RPC_FAR *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define IContextMarshaler_QueryInterface(This,riid,ppvObject) \ - (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) - -#define IContextMarshaler_AddRef(This) \ - (This)->lpVtbl -> AddRef(This) - -#define IContextMarshaler_Release(This) \ - (This)->lpVtbl -> Release(This) - - -#define IContextMarshaler_GetMarshalSizeMax(This,riid,pv,dwDestContext,pvDestContext,mshlflags,pSize) \ - (This)->lpVtbl -> GetMarshalSizeMax(This,riid,pv,dwDestContext,pvDestContext,mshlflags,pSize) - -#define IContextMarshaler_MarshalInterface(This,pStm,riid,pv,dwDestContext,pvDestContext,mshlflags) \ - (This)->lpVtbl -> MarshalInterface(This,pStm,riid,pv,dwDestContext,pvDestContext,mshlflags) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - -HRESULT STDMETHODCALLTYPE IContextMarshaler_GetMarshalSizeMax_Proxy( - IContextMarshaler __RPC_FAR * This, - /* [in] */ REFIID riid, - /* [unique][in] */ void __RPC_FAR *pv, - /* [in] */ DWORD dwDestContext, - /* [unique][in] */ void __RPC_FAR *pvDestContext, - /* [in] */ DWORD mshlflags, - /* [out] */ DWORD __RPC_FAR *pSize); - - -void __RPC_STUB IContextMarshaler_GetMarshalSizeMax_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IContextMarshaler_MarshalInterface_Proxy( - IContextMarshaler __RPC_FAR * This, - /* [unique][in] */ IStream __RPC_FAR *pStm, - /* [in] */ REFIID riid, - /* [unique][in] */ void __RPC_FAR *pv, - /* [in] */ DWORD dwDestContext, - /* [unique][in] */ void __RPC_FAR *pvDestContext, - /* [in] */ DWORD mshlflags); - - -void __RPC_STUB IContextMarshaler_MarshalInterface_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - - -#endif /* __IContextMarshaler_INTERFACE_DEFINED__ */ - - -// Placing the following definition here rather than with the IObjContext stuff -// below is a temporary workaround to get around build problems where the system -// objidl.h now has a IObjContext section but has not made much public (all the -// interface methods are marked as reserved and the following typedef does not -// exist). Once the system objidl.h is updated again we can remove the entire -// section. -#ifndef __PFNCTXCALLBACK_HACK -#define __PFNCTXCALLBACK_HACK -typedef /* [ref] */ HRESULT ( __stdcall __RPC_FAR *PFNCTXCALLBACK )( - void __RPC_FAR *pParam); -#endif - -#ifndef __IObjContext_INTERFACE_DEFINED__ -#define __IObjContext_INTERFACE_DEFINED__ - -/* interface IObjContext */ -/* [unique][uuid][object][local] */ - - -EXTERN_C const IID IID_IObjContext; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("000001c6-0000-0000-C000-000000000046") - IObjContext : public IContext - { - public: - virtual HRESULT STDMETHODCALLTYPE Freeze( void) = 0; - - virtual HRESULT STDMETHODCALLTYPE DoCallback( - /* [in] */ PFNCTXCALLBACK pfnCallback, - /* [in] */ void __RPC_FAR *pParam, - /* [in] */ REFIID riid, - /* [in] */ unsigned int iMethod) = 0; - - virtual HRESULT STDMETHODCALLTYPE SetContextMarshaler( - /* [in] */ IContextMarshaler __RPC_FAR *pICM) = 0; - - virtual HRESULT STDMETHODCALLTYPE GetContextMarshaler( - /* [out] */ IContextMarshaler __RPC_FAR *__RPC_FAR *pICM) = 0; - - virtual HRESULT STDMETHODCALLTYPE SetContextFlags( - /* [in] */ DWORD dwFlags) = 0; - - virtual HRESULT STDMETHODCALLTYPE ClearContextFlags( - /* [in] */ DWORD dwFlags) = 0; - - virtual HRESULT STDMETHODCALLTYPE GetContextFlags( - /* [out] */ DWORD __RPC_FAR *pdwFlags) = 0; - - }; - -#else /* C style interface */ - - typedef struct IObjContextVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( - IObjContext __RPC_FAR * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject); - - ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( - IObjContext __RPC_FAR * This); - - ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( - IObjContext __RPC_FAR * This); - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *SetProperty )( - IObjContext __RPC_FAR * This, - /* [in] */ REFGUID rpolicyId, - /* [in] */ CPFLAGS flags, - /* [in] */ IUnknown __RPC_FAR *pUnk); - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *RemoveProperty )( - IObjContext __RPC_FAR * This, - /* [in] */ REFGUID rPolicyId); - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetProperty )( - IObjContext __RPC_FAR * This, - /* [in] */ REFGUID rGuid, - /* [out] */ CPFLAGS __RPC_FAR *pFlags, - /* [out] */ IUnknown __RPC_FAR *__RPC_FAR *ppUnk); - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *EnumContextProps )( - IObjContext __RPC_FAR * This, - /* [out] */ IEnumContextProps __RPC_FAR *__RPC_FAR *ppEnumContextProps); - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Freeze )( - IObjContext __RPC_FAR * This); - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *DoCallback )( - IObjContext __RPC_FAR * This, - /* [in] */ PFNCTXCALLBACK pfnCallback, - /* [in] */ void __RPC_FAR *pParam, - /* [in] */ REFIID riid, - /* [in] */ unsigned int iMethod); - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *SetContextMarshaler )( - IObjContext __RPC_FAR * This, - /* [in] */ IContextMarshaler __RPC_FAR *pICM); - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetContextMarshaler )( - IObjContext __RPC_FAR * This, - /* [out] */ IContextMarshaler __RPC_FAR *__RPC_FAR *pICM); - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *SetContextFlags )( - IObjContext __RPC_FAR * This, - /* [in] */ DWORD dwFlags); - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *ClearContextFlags )( - IObjContext __RPC_FAR * This, - /* [in] */ DWORD dwFlags); - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetContextFlags )( - IObjContext __RPC_FAR * This, - /* [out] */ DWORD __RPC_FAR *pdwFlags); - - END_INTERFACE - } IObjContextVtbl; - - interface IObjContext - { - CONST_VTBL struct IObjContextVtbl __RPC_FAR *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define IObjContext_QueryInterface(This,riid,ppvObject) \ - (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) - -#define IObjContext_AddRef(This) \ - (This)->lpVtbl -> AddRef(This) - -#define IObjContext_Release(This) \ - (This)->lpVtbl -> Release(This) - - -#define IObjContext_SetProperty(This,rpolicyId,flags,pUnk) \ - (This)->lpVtbl -> SetProperty(This,rpolicyId,flags,pUnk) - -#define IObjContext_RemoveProperty(This,rPolicyId) \ - (This)->lpVtbl -> RemoveProperty(This,rPolicyId) - -#define IObjContext_GetProperty(This,rGuid,pFlags,ppUnk) \ - (This)->lpVtbl -> GetProperty(This,rGuid,pFlags,ppUnk) - -#define IObjContext_EnumContextProps(This,ppEnumContextProps) \ - (This)->lpVtbl -> EnumContextProps(This,ppEnumContextProps) - - -#define IObjContext_Freeze(This) \ - (This)->lpVtbl -> Freeze(This) - -#define IObjContext_DoCallback(This,pfnCallback,pParam,riid,iMethod) \ - (This)->lpVtbl -> DoCallback(This,pfnCallback,pParam,riid,iMethod) - -#define IObjContext_SetContextMarshaler(This,pICM) \ - (This)->lpVtbl -> SetContextMarshaler(This,pICM) - -#define IObjContext_GetContextMarshaler(This,pICM) \ - (This)->lpVtbl -> GetContextMarshaler(This,pICM) - -#define IObjContext_SetContextFlags(This,dwFlags) \ - (This)->lpVtbl -> SetContextFlags(This,dwFlags) - -#define IObjContext_ClearContextFlags(This,dwFlags) \ - (This)->lpVtbl -> ClearContextFlags(This,dwFlags) - -#define IObjContext_GetContextFlags(This,pdwFlags) \ - (This)->lpVtbl -> GetContextFlags(This,pdwFlags) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - -HRESULT STDMETHODCALLTYPE IObjContext_Freeze_Proxy( - IObjContext __RPC_FAR * This); - - -void __RPC_STUB IObjContext_Freeze_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IObjContext_DoCallback_Proxy( - IObjContext __RPC_FAR * This, - /* [in] */ PFNCTXCALLBACK pfnCallback, - /* [in] */ void __RPC_FAR *pParam, - /* [in] */ REFIID riid, - /* [in] */ unsigned int iMethod); - - -void __RPC_STUB IObjContext_DoCallback_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IObjContext_SetContextMarshaler_Proxy( - IObjContext __RPC_FAR * This, - /* [in] */ IContextMarshaler __RPC_FAR *pICM); - - -void __RPC_STUB IObjContext_SetContextMarshaler_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IObjContext_GetContextMarshaler_Proxy( - IObjContext __RPC_FAR * This, - /* [out] */ IContextMarshaler __RPC_FAR *__RPC_FAR *pICM); - - -void __RPC_STUB IObjContext_GetContextMarshaler_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IObjContext_SetContextFlags_Proxy( - IObjContext __RPC_FAR * This, - /* [in] */ DWORD dwFlags); - - -void __RPC_STUB IObjContext_SetContextFlags_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IObjContext_ClearContextFlags_Proxy( - IObjContext __RPC_FAR * This, - /* [in] */ DWORD dwFlags); - - -void __RPC_STUB IObjContext_ClearContextFlags_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IObjContext_GetContextFlags_Proxy( - IObjContext __RPC_FAR * This, - /* [out] */ DWORD __RPC_FAR *pdwFlags); - - -void __RPC_STUB IObjContext_GetContextFlags_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - - -#endif /* __IObjContext_INTERFACE_DEFINED__ */ - - -#ifndef __IGetContextId_INTERFACE_DEFINED__ -#define __IGetContextId_INTERFACE_DEFINED__ - -/* interface IGetContextId */ -/* [unique][uuid][object][local] */ - - -EXTERN_C const IID IID_IGetContextId; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("000001dd-0000-0000-C000-000000000046") - IGetContextId : public IUnknown - { - public: - virtual HRESULT STDMETHODCALLTYPE GetContextId( - /* [out] */ GUID __RPC_FAR *pguidCtxtId) = 0; - - }; - -#else /* C style interface */ - - typedef struct IGetContextIdVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( - IGetContextId __RPC_FAR * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject); - - ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( - IGetContextId __RPC_FAR * This); - - ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( - IGetContextId __RPC_FAR * This); - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetContextId )( - IGetContextId __RPC_FAR * This, - /* [out] */ GUID __RPC_FAR *pguidCtxtId); - - END_INTERFACE - } IGetContextIdVtbl; - - interface IGetContextId - { - CONST_VTBL struct IGetContextIdVtbl __RPC_FAR *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define IGetContextId_QueryInterface(This,riid,ppvObject) \ - (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) - -#define IGetContextId_AddRef(This) \ - (This)->lpVtbl -> AddRef(This) - -#define IGetContextId_Release(This) \ - (This)->lpVtbl -> Release(This) - - -#define IGetContextId_GetContextId(This,pguidCtxtId) \ - (This)->lpVtbl -> GetContextId(This,pguidCtxtId) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - -HRESULT STDMETHODCALLTYPE IGetContextId_GetContextId_Proxy( - IGetContextId __RPC_FAR * This, - /* [out] */ GUID __RPC_FAR *pguidCtxtId); - - -void __RPC_STUB IGetContextId_GetContextId_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - - -#endif /* __IGetContextId_INTERFACE_DEFINED__ */ - - -#ifndef __IAggregator_INTERFACE_DEFINED__ -#define __IAggregator_INTERFACE_DEFINED__ - -/* interface IAggregator */ -/* [unique][uuid][object][local] */ - -typedef /* [unique] */ IAggregator __RPC_FAR *IAGGREGATOR; - - -EXTERN_C const IID IID_IAggregator; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("000001d8-0000-0000-C000-000000000046") - IAggregator : public IUnknown - { - public: - virtual HRESULT STDMETHODCALLTYPE Aggregate( - /* [in] */ IUnknown __RPC_FAR *pInnerUnk) = 0; - - }; - -#else /* C style interface */ - - typedef struct IAggregatorVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( - IAggregator __RPC_FAR * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject); - - ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( - IAggregator __RPC_FAR * This); - - ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( - IAggregator __RPC_FAR * This); - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Aggregate )( - IAggregator __RPC_FAR * This, - /* [in] */ IUnknown __RPC_FAR *pInnerUnk); - - END_INTERFACE - } IAggregatorVtbl; - - interface IAggregator - { - CONST_VTBL struct IAggregatorVtbl __RPC_FAR *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define IAggregator_QueryInterface(This,riid,ppvObject) \ - (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) - -#define IAggregator_AddRef(This) \ - (This)->lpVtbl -> AddRef(This) - -#define IAggregator_Release(This) \ - (This)->lpVtbl -> Release(This) - - -#define IAggregator_Aggregate(This,pInnerUnk) \ - (This)->lpVtbl -> Aggregate(This,pInnerUnk) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - -HRESULT STDMETHODCALLTYPE IAggregator_Aggregate_Proxy( - IAggregator __RPC_FAR * This, - /* [in] */ IUnknown __RPC_FAR *pInnerUnk); - - -void __RPC_STUB IAggregator_Aggregate_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - - -#endif /* __IAggregator_INTERFACE_DEFINED__ */ - - -#ifndef __ICall_INTERFACE_DEFINED__ -#define __ICall_INTERFACE_DEFINED__ - -/* interface ICall */ -/* [unique][uuid][object][local] */ - -typedef /* [unique] */ ICall __RPC_FAR *LPCALL; - - -EXTERN_C const IID IID_ICall; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("000001d6-0000-0000-C000-000000000046") - ICall : public IUnknown - { - public: - virtual HRESULT STDMETHODCALLTYPE GetCallInfo( - /* [out] */ const void __RPC_FAR *__RPC_FAR *ppIdentity, - /* [out] */ IID __RPC_FAR *piid, - /* [out] */ DWORD __RPC_FAR *pdwMethod, - /* [out] */ HRESULT __RPC_FAR *phr) = 0; - - virtual HRESULT STDMETHODCALLTYPE Nullify( - /* [in] */ HRESULT hr) = 0; - - virtual HRESULT STDMETHODCALLTYPE GetServerHR( - /* [out] */ HRESULT __RPC_FAR *phr) = 0; - - }; - -#else /* C style interface */ - - typedef struct ICallVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( - ICall __RPC_FAR * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject); - - ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( - ICall __RPC_FAR * This); - - ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( - ICall __RPC_FAR * This); - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetCallInfo )( - ICall __RPC_FAR * This, - /* [out] */ const void __RPC_FAR *__RPC_FAR *ppIdentity, - /* [out] */ IID __RPC_FAR *piid, - /* [out] */ DWORD __RPC_FAR *pdwMethod, - /* [out] */ HRESULT __RPC_FAR *phr); - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Nullify )( - ICall __RPC_FAR * This, - /* [in] */ HRESULT hr); - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetServerHR )( - ICall __RPC_FAR * This, - /* [out] */ HRESULT __RPC_FAR *phr); - - END_INTERFACE - } ICallVtbl; - - interface ICall - { - CONST_VTBL struct ICallVtbl __RPC_FAR *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define ICall_QueryInterface(This,riid,ppvObject) \ - (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) - -#define ICall_AddRef(This) \ - (This)->lpVtbl -> AddRef(This) - -#define ICall_Release(This) \ - (This)->lpVtbl -> Release(This) - - -#define ICall_GetCallInfo(This,ppIdentity,piid,pdwMethod,phr) \ - (This)->lpVtbl -> GetCallInfo(This,ppIdentity,piid,pdwMethod,phr) - -#define ICall_Nullify(This,hr) \ - (This)->lpVtbl -> Nullify(This,hr) - -#define ICall_GetServerHR(This,phr) \ - (This)->lpVtbl -> GetServerHR(This,phr) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - -HRESULT STDMETHODCALLTYPE ICall_GetCallInfo_Proxy( - ICall __RPC_FAR * This, - /* [out] */ const void __RPC_FAR *__RPC_FAR *ppIdentity, - /* [out] */ IID __RPC_FAR *piid, - /* [out] */ DWORD __RPC_FAR *pdwMethod, - /* [out] */ HRESULT __RPC_FAR *phr); - - -void __RPC_STUB ICall_GetCallInfo_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE ICall_Nullify_Proxy( - ICall __RPC_FAR * This, - /* [in] */ HRESULT hr); - - -void __RPC_STUB ICall_Nullify_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE ICall_GetServerHR_Proxy( - ICall __RPC_FAR * This, - /* [out] */ HRESULT __RPC_FAR *phr); - - -void __RPC_STUB ICall_GetServerHR_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - - -#endif /* __ICall_INTERFACE_DEFINED__ */ - - -#ifndef __IRpcCall_INTERFACE_DEFINED__ -#define __IRpcCall_INTERFACE_DEFINED__ - -/* interface IRpcCall */ -/* [unique][uuid][object][local] */ - -typedef /* [unique] */ IRpcCall __RPC_FAR *LPRPCCALL; - - -EXTERN_C const IID IID_IRpcCall; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("000001c5-0000-0000-C000-000000000046") - IRpcCall : public IUnknown - { - public: - virtual HRESULT STDMETHODCALLTYPE GetRpcOleMessage( - /* [out] */ RPCOLEMESSAGE __RPC_FAR *__RPC_FAR *ppMessage) = 0; - - }; - -#else /* C style interface */ - - typedef struct IRpcCallVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( - IRpcCall __RPC_FAR * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject); - - ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( - IRpcCall __RPC_FAR * This); - - ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( - IRpcCall __RPC_FAR * This); - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetRpcOleMessage )( - IRpcCall __RPC_FAR * This, - /* [out] */ RPCOLEMESSAGE __RPC_FAR *__RPC_FAR *ppMessage); - - END_INTERFACE - } IRpcCallVtbl; - - interface IRpcCall - { - CONST_VTBL struct IRpcCallVtbl __RPC_FAR *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define IRpcCall_QueryInterface(This,riid,ppvObject) \ - (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) - -#define IRpcCall_AddRef(This) \ - (This)->lpVtbl -> AddRef(This) - -#define IRpcCall_Release(This) \ - (This)->lpVtbl -> Release(This) - - -#define IRpcCall_GetRpcOleMessage(This,ppMessage) \ - (This)->lpVtbl -> GetRpcOleMessage(This,ppMessage) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - -HRESULT STDMETHODCALLTYPE IRpcCall_GetRpcOleMessage_Proxy( - IRpcCall __RPC_FAR * This, - /* [out] */ RPCOLEMESSAGE __RPC_FAR *__RPC_FAR *ppMessage); - - -void __RPC_STUB IRpcCall_GetRpcOleMessage_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - - -#endif /* __IRpcCall_INTERFACE_DEFINED__ */ - - -/* interface __MIDL_itf_contxt_0083 */ -/* [local] */ - -typedef -enum _CALLSOURCE - { CALLSOURCE_CROSSAPT = 0, - CALLSOURCE_CROSSCTX = 1 - } CALLSOURCE; - - - -extern RPC_IF_HANDLE __MIDL_itf_contxt_0083_v0_0_c_ifspec; -extern RPC_IF_HANDLE __MIDL_itf_contxt_0083_v0_0_s_ifspec; - -#ifndef __ICallInfo_INTERFACE_DEFINED__ -#define __ICallInfo_INTERFACE_DEFINED__ - -/* interface ICallInfo */ -/* [unique][uuid][object][local] */ - - -EXTERN_C const IID IID_ICallInfo; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("000001dc-0000-0000-C000-000000000046") - ICallInfo : public IUnknown - { - public: - virtual HRESULT STDMETHODCALLTYPE GetCallSource( - /* [out] */ CALLSOURCE __RPC_FAR *pCallSource) = 0; - - }; - -#else /* C style interface */ - - typedef struct ICallInfoVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( - ICallInfo __RPC_FAR * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject); - - ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( - ICallInfo __RPC_FAR * This); - - ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( - ICallInfo __RPC_FAR * This); - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetCallSource )( - ICallInfo __RPC_FAR * This, - /* [out] */ CALLSOURCE __RPC_FAR *pCallSource); - - END_INTERFACE - } ICallInfoVtbl; - - interface ICallInfo - { - CONST_VTBL struct ICallInfoVtbl __RPC_FAR *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define ICallInfo_QueryInterface(This,riid,ppvObject) \ - (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) - -#define ICallInfo_AddRef(This) \ - (This)->lpVtbl -> AddRef(This) - -#define ICallInfo_Release(This) \ - (This)->lpVtbl -> Release(This) - - -#define ICallInfo_GetCallSource(This,pCallSource) \ - (This)->lpVtbl -> GetCallSource(This,pCallSource) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - -HRESULT STDMETHODCALLTYPE ICallInfo_GetCallSource_Proxy( - ICallInfo __RPC_FAR * This, - /* [out] */ CALLSOURCE __RPC_FAR *pCallSource); - - -void __RPC_STUB ICallInfo_GetCallSource_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - - -#endif /* __ICallInfo_INTERFACE_DEFINED__ */ - - -#ifndef __IPolicy_INTERFACE_DEFINED__ -#define __IPolicy_INTERFACE_DEFINED__ - -/* interface IPolicy */ -/* [unique][uuid][object][local] */ - - -EXTERN_C const IID IID_IPolicy; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("000001c2-0000-0000-C000-000000000046") - IPolicy : public IUnknown - { - public: - virtual HRESULT STDMETHODCALLTYPE Call( - /* [in] */ ICall __RPC_FAR *pCall) = 0; - - virtual HRESULT STDMETHODCALLTYPE Enter( - /* [in] */ ICall __RPC_FAR *pCall) = 0; - - virtual HRESULT STDMETHODCALLTYPE Leave( - /* [in] */ ICall __RPC_FAR *pCall) = 0; - - virtual HRESULT STDMETHODCALLTYPE Return( - /* [in] */ ICall __RPC_FAR *pCall) = 0; - - virtual HRESULT STDMETHODCALLTYPE CallGetSize( - /* [in] */ ICall __RPC_FAR *pCall, - /* [out] */ ULONG __RPC_FAR *pcb) = 0; - - virtual HRESULT STDMETHODCALLTYPE CallFillBuffer( - /* [in] */ ICall __RPC_FAR *pCall, - /* [in] */ void __RPC_FAR *pvBuf, - /* [out] */ ULONG __RPC_FAR *pcb) = 0; - - virtual HRESULT STDMETHODCALLTYPE EnterWithBuffer( - /* [in] */ ICall __RPC_FAR *pCall, - /* [in] */ void __RPC_FAR *pvBuf, - /* [in] */ ULONG cb) = 0; - - virtual HRESULT STDMETHODCALLTYPE LeaveGetSize( - /* [in] */ ICall __RPC_FAR *pCall, - /* [out] */ ULONG __RPC_FAR *pcb) = 0; - - virtual HRESULT STDMETHODCALLTYPE LeaveFillBuffer( - /* [in] */ ICall __RPC_FAR *pCall, - /* [in] */ void __RPC_FAR *pvBuf, - /* [out] */ ULONG __RPC_FAR *pcb) = 0; - - virtual HRESULT STDMETHODCALLTYPE ReturnWithBuffer( - /* [in] */ ICall __RPC_FAR *pCall, - /* [in] */ void __RPC_FAR *pvBuf, - /* [in] */ ULONG cb) = 0; - - virtual ULONG STDMETHODCALLTYPE AddRefPolicy( void) = 0; - - virtual ULONG STDMETHODCALLTYPE ReleasePolicy( void) = 0; - - }; - -#else /* C style interface */ - - typedef struct IPolicyVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( - IPolicy __RPC_FAR * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject); - - ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( - IPolicy __RPC_FAR * This); - - ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( - IPolicy __RPC_FAR * This); - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Call )( - IPolicy __RPC_FAR * This, - /* [in] */ ICall __RPC_FAR *pCall); - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Enter )( - IPolicy __RPC_FAR * This, - /* [in] */ ICall __RPC_FAR *pCall); - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Leave )( - IPolicy __RPC_FAR * This, - /* [in] */ ICall __RPC_FAR *pCall); - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Return )( - IPolicy __RPC_FAR * This, - /* [in] */ ICall __RPC_FAR *pCall); - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *CallGetSize )( - IPolicy __RPC_FAR * This, - /* [in] */ ICall __RPC_FAR *pCall, - /* [out] */ ULONG __RPC_FAR *pcb); - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *CallFillBuffer )( - IPolicy __RPC_FAR * This, - /* [in] */ ICall __RPC_FAR *pCall, - /* [in] */ void __RPC_FAR *pvBuf, - /* [out] */ ULONG __RPC_FAR *pcb); - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *EnterWithBuffer )( - IPolicy __RPC_FAR * This, - /* [in] */ ICall __RPC_FAR *pCall, - /* [in] */ void __RPC_FAR *pvBuf, - /* [in] */ ULONG cb); - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *LeaveGetSize )( - IPolicy __RPC_FAR * This, - /* [in] */ ICall __RPC_FAR *pCall, - /* [out] */ ULONG __RPC_FAR *pcb); - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *LeaveFillBuffer )( - IPolicy __RPC_FAR * This, - /* [in] */ ICall __RPC_FAR *pCall, - /* [in] */ void __RPC_FAR *pvBuf, - /* [out] */ ULONG __RPC_FAR *pcb); - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *ReturnWithBuffer )( - IPolicy __RPC_FAR * This, - /* [in] */ ICall __RPC_FAR *pCall, - /* [in] */ void __RPC_FAR *pvBuf, - /* [in] */ ULONG cb); - - ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRefPolicy )( - IPolicy __RPC_FAR * This); - - ULONG ( STDMETHODCALLTYPE __RPC_FAR *ReleasePolicy )( - IPolicy __RPC_FAR * This); - - END_INTERFACE - } IPolicyVtbl; - - interface IPolicy - { - CONST_VTBL struct IPolicyVtbl __RPC_FAR *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define IPolicy_QueryInterface(This,riid,ppvObject) \ - (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) - -#define IPolicy_AddRef(This) \ - (This)->lpVtbl -> AddRef(This) - -#define IPolicy_Release(This) \ - (This)->lpVtbl -> Release(This) - - -#define IPolicy_Call(This,pCall) \ - (This)->lpVtbl -> Call(This,pCall) - -#define IPolicy_Enter(This,pCall) \ - (This)->lpVtbl -> Enter(This,pCall) - -#define IPolicy_Leave(This,pCall) \ - (This)->lpVtbl -> Leave(This,pCall) - -#define IPolicy_Return(This,pCall) \ - (This)->lpVtbl -> Return(This,pCall) - -#define IPolicy_CallGetSize(This,pCall,pcb) \ - (This)->lpVtbl -> CallGetSize(This,pCall,pcb) - -#define IPolicy_CallFillBuffer(This,pCall,pvBuf,pcb) \ - (This)->lpVtbl -> CallFillBuffer(This,pCall,pvBuf,pcb) - -#define IPolicy_EnterWithBuffer(This,pCall,pvBuf,cb) \ - (This)->lpVtbl -> EnterWithBuffer(This,pCall,pvBuf,cb) - -#define IPolicy_LeaveGetSize(This,pCall,pcb) \ - (This)->lpVtbl -> LeaveGetSize(This,pCall,pcb) - -#define IPolicy_LeaveFillBuffer(This,pCall,pvBuf,pcb) \ - (This)->lpVtbl -> LeaveFillBuffer(This,pCall,pvBuf,pcb) - -#define IPolicy_ReturnWithBuffer(This,pCall,pvBuf,cb) \ - (This)->lpVtbl -> ReturnWithBuffer(This,pCall,pvBuf,cb) - -#define IPolicy_AddRefPolicy(This) \ - (This)->lpVtbl -> AddRefPolicy(This) - -#define IPolicy_ReleasePolicy(This) \ - (This)->lpVtbl -> ReleasePolicy(This) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - -HRESULT STDMETHODCALLTYPE IPolicy_Call_Proxy( - IPolicy __RPC_FAR * This, - /* [in] */ ICall __RPC_FAR *pCall); - - -void __RPC_STUB IPolicy_Call_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IPolicy_Enter_Proxy( - IPolicy __RPC_FAR * This, - /* [in] */ ICall __RPC_FAR *pCall); - - -void __RPC_STUB IPolicy_Enter_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IPolicy_Leave_Proxy( - IPolicy __RPC_FAR * This, - /* [in] */ ICall __RPC_FAR *pCall); - - -void __RPC_STUB IPolicy_Leave_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IPolicy_Return_Proxy( - IPolicy __RPC_FAR * This, - /* [in] */ ICall __RPC_FAR *pCall); - - -void __RPC_STUB IPolicy_Return_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IPolicy_CallGetSize_Proxy( - IPolicy __RPC_FAR * This, - /* [in] */ ICall __RPC_FAR *pCall, - /* [out] */ ULONG __RPC_FAR *pcb); - - -void __RPC_STUB IPolicy_CallGetSize_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IPolicy_CallFillBuffer_Proxy( - IPolicy __RPC_FAR * This, - /* [in] */ ICall __RPC_FAR *pCall, - /* [in] */ void __RPC_FAR *pvBuf, - /* [out] */ ULONG __RPC_FAR *pcb); - - -void __RPC_STUB IPolicy_CallFillBuffer_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IPolicy_EnterWithBuffer_Proxy( - IPolicy __RPC_FAR * This, - /* [in] */ ICall __RPC_FAR *pCall, - /* [in] */ void __RPC_FAR *pvBuf, - /* [in] */ ULONG cb); - - -void __RPC_STUB IPolicy_EnterWithBuffer_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IPolicy_LeaveGetSize_Proxy( - IPolicy __RPC_FAR * This, - /* [in] */ ICall __RPC_FAR *pCall, - /* [out] */ ULONG __RPC_FAR *pcb); - - -void __RPC_STUB IPolicy_LeaveGetSize_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IPolicy_LeaveFillBuffer_Proxy( - IPolicy __RPC_FAR * This, - /* [in] */ ICall __RPC_FAR *pCall, - /* [in] */ void __RPC_FAR *pvBuf, - /* [out] */ ULONG __RPC_FAR *pcb); - - -void __RPC_STUB IPolicy_LeaveFillBuffer_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IPolicy_ReturnWithBuffer_Proxy( - IPolicy __RPC_FAR * This, - /* [in] */ ICall __RPC_FAR *pCall, - /* [in] */ void __RPC_FAR *pvBuf, - /* [in] */ ULONG cb); - - -void __RPC_STUB IPolicy_ReturnWithBuffer_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -ULONG STDMETHODCALLTYPE IPolicy_AddRefPolicy_Proxy( - IPolicy __RPC_FAR * This); - - -void __RPC_STUB IPolicy_AddRefPolicy_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -ULONG STDMETHODCALLTYPE IPolicy_ReleasePolicy_Proxy( - IPolicy __RPC_FAR * This); - - -void __RPC_STUB IPolicy_ReleasePolicy_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - - -#endif /* __IPolicy_INTERFACE_DEFINED__ */ - - -#ifndef __IPolicyAsync_INTERFACE_DEFINED__ -#define __IPolicyAsync_INTERFACE_DEFINED__ - -/* interface IPolicyAsync */ -/* [unique][uuid][object][local] */ - - -EXTERN_C const IID IID_IPolicyAsync; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("000001cd-0000-0000-C000-000000000046") - IPolicyAsync : public IUnknown - { - public: - virtual HRESULT STDMETHODCALLTYPE BeginCallGetSize( - /* [in] */ ICall __RPC_FAR *pCall, - /* [out] */ ULONG __RPC_FAR *pcb) = 0; - - virtual HRESULT STDMETHODCALLTYPE BeginCall( - /* [in] */ ICall __RPC_FAR *pCall) = 0; - - virtual HRESULT STDMETHODCALLTYPE BeginCallFillBuffer( - /* [in] */ ICall __RPC_FAR *pCall, - /* [in] */ void __RPC_FAR *pvBuf, - /* [out] */ ULONG __RPC_FAR *pcb) = 0; - - virtual HRESULT STDMETHODCALLTYPE BeginEnter( - /* [in] */ ICall __RPC_FAR *pCall) = 0; - - virtual HRESULT STDMETHODCALLTYPE BeginEnterWithBuffer( - /* [in] */ ICall __RPC_FAR *pCall, - /* [in] */ void __RPC_FAR *pvBuf, - /* [in] */ ULONG cb) = 0; - - virtual HRESULT STDMETHODCALLTYPE BeginLeave( - /* [in] */ ICall __RPC_FAR *pCall) = 0; - - virtual HRESULT STDMETHODCALLTYPE BeginReturn( - /* [in] */ ICall __RPC_FAR *pCall) = 0; - - virtual HRESULT STDMETHODCALLTYPE FinishCall( - /* [in] */ ICall __RPC_FAR *pCall) = 0; - - virtual HRESULT STDMETHODCALLTYPE FinishEnter( - /* [in] */ ICall __RPC_FAR *pCall) = 0; - - virtual HRESULT STDMETHODCALLTYPE FinishLeaveGetSize( - /* [in] */ ICall __RPC_FAR *pCall, - /* [out] */ ULONG __RPC_FAR *pcb) = 0; - - virtual HRESULT STDMETHODCALLTYPE FinishLeave( - /* [in] */ ICall __RPC_FAR *pCall) = 0; - - virtual HRESULT STDMETHODCALLTYPE FinishLeaveFillBuffer( - /* [in] */ ICall __RPC_FAR *pCall, - /* [in] */ void __RPC_FAR *pvBuf, - /* [out] */ ULONG __RPC_FAR *pcb) = 0; - - virtual HRESULT STDMETHODCALLTYPE FinishReturn( - /* [in] */ ICall __RPC_FAR *pCall) = 0; - - virtual HRESULT STDMETHODCALLTYPE FinishReturnWithBuffer( - /* [in] */ ICall __RPC_FAR *pCall, - /* [in] */ void __RPC_FAR *pvBuf, - /* [in] */ ULONG cb) = 0; - - }; - -#else /* C style interface */ - - typedef struct IPolicyAsyncVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( - IPolicyAsync __RPC_FAR * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject); - - ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( - IPolicyAsync __RPC_FAR * This); - - ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( - IPolicyAsync __RPC_FAR * This); - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *BeginCallGetSize )( - IPolicyAsync __RPC_FAR * This, - /* [in] */ ICall __RPC_FAR *pCall, - /* [out] */ ULONG __RPC_FAR *pcb); - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *BeginCall )( - IPolicyAsync __RPC_FAR * This, - /* [in] */ ICall __RPC_FAR *pCall); - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *BeginCallFillBuffer )( - IPolicyAsync __RPC_FAR * This, - /* [in] */ ICall __RPC_FAR *pCall, - /* [in] */ void __RPC_FAR *pvBuf, - /* [out] */ ULONG __RPC_FAR *pcb); - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *BeginEnter )( - IPolicyAsync __RPC_FAR * This, - /* [in] */ ICall __RPC_FAR *pCall); - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *BeginEnterWithBuffer )( - IPolicyAsync __RPC_FAR * This, - /* [in] */ ICall __RPC_FAR *pCall, - /* [in] */ void __RPC_FAR *pvBuf, - /* [in] */ ULONG cb); - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *BeginLeave )( - IPolicyAsync __RPC_FAR * This, - /* [in] */ ICall __RPC_FAR *pCall); - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *BeginReturn )( - IPolicyAsync __RPC_FAR * This, - /* [in] */ ICall __RPC_FAR *pCall); - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *FinishCall )( - IPolicyAsync __RPC_FAR * This, - /* [in] */ ICall __RPC_FAR *pCall); - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *FinishEnter )( - IPolicyAsync __RPC_FAR * This, - /* [in] */ ICall __RPC_FAR *pCall); - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *FinishLeaveGetSize )( - IPolicyAsync __RPC_FAR * This, - /* [in] */ ICall __RPC_FAR *pCall, - /* [out] */ ULONG __RPC_FAR *pcb); - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *FinishLeave )( - IPolicyAsync __RPC_FAR * This, - /* [in] */ ICall __RPC_FAR *pCall); - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *FinishLeaveFillBuffer )( - IPolicyAsync __RPC_FAR * This, - /* [in] */ ICall __RPC_FAR *pCall, - /* [in] */ void __RPC_FAR *pvBuf, - /* [out] */ ULONG __RPC_FAR *pcb); - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *FinishReturn )( - IPolicyAsync __RPC_FAR * This, - /* [in] */ ICall __RPC_FAR *pCall); - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *FinishReturnWithBuffer )( - IPolicyAsync __RPC_FAR * This, - /* [in] */ ICall __RPC_FAR *pCall, - /* [in] */ void __RPC_FAR *pvBuf, - /* [in] */ ULONG cb); - - END_INTERFACE - } IPolicyAsyncVtbl; - - interface IPolicyAsync - { - CONST_VTBL struct IPolicyAsyncVtbl __RPC_FAR *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define IPolicyAsync_QueryInterface(This,riid,ppvObject) \ - (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) - -#define IPolicyAsync_AddRef(This) \ - (This)->lpVtbl -> AddRef(This) - -#define IPolicyAsync_Release(This) \ - (This)->lpVtbl -> Release(This) - - -#define IPolicyAsync_BeginCallGetSize(This,pCall,pcb) \ - (This)->lpVtbl -> BeginCallGetSize(This,pCall,pcb) - -#define IPolicyAsync_BeginCall(This,pCall) \ - (This)->lpVtbl -> BeginCall(This,pCall) - -#define IPolicyAsync_BeginCallFillBuffer(This,pCall,pvBuf,pcb) \ - (This)->lpVtbl -> BeginCallFillBuffer(This,pCall,pvBuf,pcb) - -#define IPolicyAsync_BeginEnter(This,pCall) \ - (This)->lpVtbl -> BeginEnter(This,pCall) - -#define IPolicyAsync_BeginEnterWithBuffer(This,pCall,pvBuf,cb) \ - (This)->lpVtbl -> BeginEnterWithBuffer(This,pCall,pvBuf,cb) - -#define IPolicyAsync_BeginLeave(This,pCall) \ - (This)->lpVtbl -> BeginLeave(This,pCall) - -#define IPolicyAsync_BeginReturn(This,pCall) \ - (This)->lpVtbl -> BeginReturn(This,pCall) - -#define IPolicyAsync_FinishCall(This,pCall) \ - (This)->lpVtbl -> FinishCall(This,pCall) - -#define IPolicyAsync_FinishEnter(This,pCall) \ - (This)->lpVtbl -> FinishEnter(This,pCall) - -#define IPolicyAsync_FinishLeaveGetSize(This,pCall,pcb) \ - (This)->lpVtbl -> FinishLeaveGetSize(This,pCall,pcb) - -#define IPolicyAsync_FinishLeave(This,pCall) \ - (This)->lpVtbl -> FinishLeave(This,pCall) - -#define IPolicyAsync_FinishLeaveFillBuffer(This,pCall,pvBuf,pcb) \ - (This)->lpVtbl -> FinishLeaveFillBuffer(This,pCall,pvBuf,pcb) - -#define IPolicyAsync_FinishReturn(This,pCall) \ - (This)->lpVtbl -> FinishReturn(This,pCall) - -#define IPolicyAsync_FinishReturnWithBuffer(This,pCall,pvBuf,cb) \ - (This)->lpVtbl -> FinishReturnWithBuffer(This,pCall,pvBuf,cb) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - -HRESULT STDMETHODCALLTYPE IPolicyAsync_BeginCallGetSize_Proxy( - IPolicyAsync __RPC_FAR * This, - /* [in] */ ICall __RPC_FAR *pCall, - /* [out] */ ULONG __RPC_FAR *pcb); - - -void __RPC_STUB IPolicyAsync_BeginCallGetSize_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IPolicyAsync_BeginCall_Proxy( - IPolicyAsync __RPC_FAR * This, - /* [in] */ ICall __RPC_FAR *pCall); - - -void __RPC_STUB IPolicyAsync_BeginCall_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IPolicyAsync_BeginCallFillBuffer_Proxy( - IPolicyAsync __RPC_FAR * This, - /* [in] */ ICall __RPC_FAR *pCall, - /* [in] */ void __RPC_FAR *pvBuf, - /* [out] */ ULONG __RPC_FAR *pcb); - - -void __RPC_STUB IPolicyAsync_BeginCallFillBuffer_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IPolicyAsync_BeginEnter_Proxy( - IPolicyAsync __RPC_FAR * This, - /* [in] */ ICall __RPC_FAR *pCall); - - -void __RPC_STUB IPolicyAsync_BeginEnter_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IPolicyAsync_BeginEnterWithBuffer_Proxy( - IPolicyAsync __RPC_FAR * This, - /* [in] */ ICall __RPC_FAR *pCall, - /* [in] */ void __RPC_FAR *pvBuf, - /* [in] */ ULONG cb); - - -void __RPC_STUB IPolicyAsync_BeginEnterWithBuffer_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IPolicyAsync_BeginLeave_Proxy( - IPolicyAsync __RPC_FAR * This, - /* [in] */ ICall __RPC_FAR *pCall); - - -void __RPC_STUB IPolicyAsync_BeginLeave_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IPolicyAsync_BeginReturn_Proxy( - IPolicyAsync __RPC_FAR * This, - /* [in] */ ICall __RPC_FAR *pCall); - - -void __RPC_STUB IPolicyAsync_BeginReturn_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IPolicyAsync_FinishCall_Proxy( - IPolicyAsync __RPC_FAR * This, - /* [in] */ ICall __RPC_FAR *pCall); - - -void __RPC_STUB IPolicyAsync_FinishCall_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IPolicyAsync_FinishEnter_Proxy( - IPolicyAsync __RPC_FAR * This, - /* [in] */ ICall __RPC_FAR *pCall); - - -void __RPC_STUB IPolicyAsync_FinishEnter_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IPolicyAsync_FinishLeaveGetSize_Proxy( - IPolicyAsync __RPC_FAR * This, - /* [in] */ ICall __RPC_FAR *pCall, - /* [out] */ ULONG __RPC_FAR *pcb); - - -void __RPC_STUB IPolicyAsync_FinishLeaveGetSize_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IPolicyAsync_FinishLeave_Proxy( - IPolicyAsync __RPC_FAR * This, - /* [in] */ ICall __RPC_FAR *pCall); - - -void __RPC_STUB IPolicyAsync_FinishLeave_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IPolicyAsync_FinishLeaveFillBuffer_Proxy( - IPolicyAsync __RPC_FAR * This, - /* [in] */ ICall __RPC_FAR *pCall, - /* [in] */ void __RPC_FAR *pvBuf, - /* [out] */ ULONG __RPC_FAR *pcb); - - -void __RPC_STUB IPolicyAsync_FinishLeaveFillBuffer_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IPolicyAsync_FinishReturn_Proxy( - IPolicyAsync __RPC_FAR * This, - /* [in] */ ICall __RPC_FAR *pCall); - - -void __RPC_STUB IPolicyAsync_FinishReturn_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IPolicyAsync_FinishReturnWithBuffer_Proxy( - IPolicyAsync __RPC_FAR * This, - /* [in] */ ICall __RPC_FAR *pCall, - /* [in] */ void __RPC_FAR *pvBuf, - /* [in] */ ULONG cb); - - -void __RPC_STUB IPolicyAsync_FinishReturnWithBuffer_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - - -#endif /* __IPolicyAsync_INTERFACE_DEFINED__ */ - - -#ifndef __IPolicySet_INTERFACE_DEFINED__ -#define __IPolicySet_INTERFACE_DEFINED__ - -/* interface IPolicySet */ -/* [unique][uuid][object][local] */ - - -EXTERN_C const IID IID_IPolicySet; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("000001c3-0000-0000-C000-000000000046") - IPolicySet : public IUnknown - { - public: - virtual HRESULT STDMETHODCALLTYPE AddPolicy( - /* [in] */ ContextEvent ctxEvent, - /* [in] */ REFGUID rguid, - /* [in] */ IPolicy __RPC_FAR *pPolicy) = 0; - - }; - -#else /* C style interface */ - - typedef struct IPolicySetVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( - IPolicySet __RPC_FAR * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject); - - ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( - IPolicySet __RPC_FAR * This); - - ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( - IPolicySet __RPC_FAR * This); - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *AddPolicy )( - IPolicySet __RPC_FAR * This, - /* [in] */ ContextEvent ctxEvent, - /* [in] */ REFGUID rguid, - /* [in] */ IPolicy __RPC_FAR *pPolicy); - - END_INTERFACE - } IPolicySetVtbl; - - interface IPolicySet - { - CONST_VTBL struct IPolicySetVtbl __RPC_FAR *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define IPolicySet_QueryInterface(This,riid,ppvObject) \ - (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) - -#define IPolicySet_AddRef(This) \ - (This)->lpVtbl -> AddRef(This) - -#define IPolicySet_Release(This) \ - (This)->lpVtbl -> Release(This) - - -#define IPolicySet_AddPolicy(This,ctxEvent,rguid,pPolicy) \ - (This)->lpVtbl -> AddPolicy(This,ctxEvent,rguid,pPolicy) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - -HRESULT STDMETHODCALLTYPE IPolicySet_AddPolicy_Proxy( - IPolicySet __RPC_FAR * This, - /* [in] */ ContextEvent ctxEvent, - /* [in] */ REFGUID rguid, - /* [in] */ IPolicy __RPC_FAR *pPolicy); - - -void __RPC_STUB IPolicySet_AddPolicy_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - - -#endif /* __IPolicySet_INTERFACE_DEFINED__ */ - - -#ifndef __IComObjIdentity_INTERFACE_DEFINED__ -#define __IComObjIdentity_INTERFACE_DEFINED__ - -/* interface IComObjIdentity */ -/* [unique][uuid][object][local] */ - - -EXTERN_C const IID IID_IComObjIdentity; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("000001d7-0000-0000-C000-000000000046") - IComObjIdentity : public IUnknown - { - public: - virtual BOOL STDMETHODCALLTYPE IsServer( void) = 0; - - virtual BOOL STDMETHODCALLTYPE IsDeactivated( void) = 0; - - virtual HRESULT STDMETHODCALLTYPE GetIdentity( - /* [out] */ IUnknown __RPC_FAR *__RPC_FAR *ppUnk) = 0; - - }; - -#else /* C style interface */ - - typedef struct IComObjIdentityVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( - IComObjIdentity __RPC_FAR * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject); - - ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( - IComObjIdentity __RPC_FAR * This); - - ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( - IComObjIdentity __RPC_FAR * This); - - BOOL ( STDMETHODCALLTYPE __RPC_FAR *IsServer )( - IComObjIdentity __RPC_FAR * This); - - BOOL ( STDMETHODCALLTYPE __RPC_FAR *IsDeactivated )( - IComObjIdentity __RPC_FAR * This); - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetIdentity )( - IComObjIdentity __RPC_FAR * This, - /* [out] */ IUnknown __RPC_FAR *__RPC_FAR *ppUnk); - - END_INTERFACE - } IComObjIdentityVtbl; - - interface IComObjIdentity - { - CONST_VTBL struct IComObjIdentityVtbl __RPC_FAR *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define IComObjIdentity_QueryInterface(This,riid,ppvObject) \ - (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) - -#define IComObjIdentity_AddRef(This) \ - (This)->lpVtbl -> AddRef(This) - -#define IComObjIdentity_Release(This) \ - (This)->lpVtbl -> Release(This) - - -#define IComObjIdentity_IsServer(This) \ - (This)->lpVtbl -> IsServer(This) - -#define IComObjIdentity_IsDeactivated(This) \ - (This)->lpVtbl -> IsDeactivated(This) - -#define IComObjIdentity_GetIdentity(This,ppUnk) \ - (This)->lpVtbl -> GetIdentity(This,ppUnk) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - -BOOL STDMETHODCALLTYPE IComObjIdentity_IsServer_Proxy( - IComObjIdentity __RPC_FAR * This); - - -void __RPC_STUB IComObjIdentity_IsServer_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -BOOL STDMETHODCALLTYPE IComObjIdentity_IsDeactivated_Proxy( - IComObjIdentity __RPC_FAR * This); - - -void __RPC_STUB IComObjIdentity_IsDeactivated_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IComObjIdentity_GetIdentity_Proxy( - IComObjIdentity __RPC_FAR * This, - /* [out] */ IUnknown __RPC_FAR *__RPC_FAR *ppUnk); - - -void __RPC_STUB IComObjIdentity_GetIdentity_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - - -#endif /* __IComObjIdentity_INTERFACE_DEFINED__ */ - - -#ifndef __IPolicyMaker_INTERFACE_DEFINED__ -#define __IPolicyMaker_INTERFACE_DEFINED__ - -/* interface IPolicyMaker */ -/* [unique][uuid][object][local] */ - - -EXTERN_C const IID IID_IPolicyMaker; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("000001c4-0000-0000-C000-000000000046") - IPolicyMaker : public IUnknown - { - public: - virtual HRESULT STDMETHODCALLTYPE AddClientPoliciesToSet( - /* [in] */ IPolicySet __RPC_FAR *pPS, - /* [in] */ IContext __RPC_FAR *pClientContext, - /* [in] */ IContext __RPC_FAR *pServerContext) = 0; - - virtual HRESULT STDMETHODCALLTYPE AddEnvoyPoliciesToSet( - /* [in] */ IPolicySet __RPC_FAR *pPS, - /* [in] */ IContext __RPC_FAR *pClientContext, - /* [in] */ IContext __RPC_FAR *pServerContext) = 0; - - virtual HRESULT STDMETHODCALLTYPE AddServerPoliciesToSet( - /* [in] */ IPolicySet __RPC_FAR *pPS, - /* [in] */ IContext __RPC_FAR *pClientContext, - /* [in] */ IContext __RPC_FAR *pServerContext) = 0; - - virtual HRESULT STDMETHODCALLTYPE Freeze( - /* [in] */ IObjContext __RPC_FAR *pObjContext) = 0; - - virtual HRESULT STDMETHODCALLTYPE CreateStub( - /* [in] */ IComObjIdentity __RPC_FAR *pID) = 0; - - virtual HRESULT STDMETHODCALLTYPE DestroyStub( - /* [in] */ IComObjIdentity __RPC_FAR *pID) = 0; - - virtual HRESULT STDMETHODCALLTYPE CreateProxy( - /* [in] */ IComObjIdentity __RPC_FAR *pID) = 0; - - virtual HRESULT STDMETHODCALLTYPE DestroyProxy( - /* [in] */ IComObjIdentity __RPC_FAR *pID) = 0; - - }; - -#else /* C style interface */ - - typedef struct IPolicyMakerVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( - IPolicyMaker __RPC_FAR * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject); - - ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( - IPolicyMaker __RPC_FAR * This); - - ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( - IPolicyMaker __RPC_FAR * This); - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *AddClientPoliciesToSet )( - IPolicyMaker __RPC_FAR * This, - /* [in] */ IPolicySet __RPC_FAR *pPS, - /* [in] */ IContext __RPC_FAR *pClientContext, - /* [in] */ IContext __RPC_FAR *pServerContext); - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *AddEnvoyPoliciesToSet )( - IPolicyMaker __RPC_FAR * This, - /* [in] */ IPolicySet __RPC_FAR *pPS, - /* [in] */ IContext __RPC_FAR *pClientContext, - /* [in] */ IContext __RPC_FAR *pServerContext); - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *AddServerPoliciesToSet )( - IPolicyMaker __RPC_FAR * This, - /* [in] */ IPolicySet __RPC_FAR *pPS, - /* [in] */ IContext __RPC_FAR *pClientContext, - /* [in] */ IContext __RPC_FAR *pServerContext); - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Freeze )( - IPolicyMaker __RPC_FAR * This, - /* [in] */ IObjContext __RPC_FAR *pObjContext); - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *CreateStub )( - IPolicyMaker __RPC_FAR * This, - /* [in] */ IComObjIdentity __RPC_FAR *pID); - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *DestroyStub )( - IPolicyMaker __RPC_FAR * This, - /* [in] */ IComObjIdentity __RPC_FAR *pID); - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *CreateProxy )( - IPolicyMaker __RPC_FAR * This, - /* [in] */ IComObjIdentity __RPC_FAR *pID); - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *DestroyProxy )( - IPolicyMaker __RPC_FAR * This, - /* [in] */ IComObjIdentity __RPC_FAR *pID); - - END_INTERFACE - } IPolicyMakerVtbl; - - interface IPolicyMaker - { - CONST_VTBL struct IPolicyMakerVtbl __RPC_FAR *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define IPolicyMaker_QueryInterface(This,riid,ppvObject) \ - (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) - -#define IPolicyMaker_AddRef(This) \ - (This)->lpVtbl -> AddRef(This) - -#define IPolicyMaker_Release(This) \ - (This)->lpVtbl -> Release(This) - - -#define IPolicyMaker_AddClientPoliciesToSet(This,pPS,pClientContext,pServerContext) \ - (This)->lpVtbl -> AddClientPoliciesToSet(This,pPS,pClientContext,pServerContext) - -#define IPolicyMaker_AddEnvoyPoliciesToSet(This,pPS,pClientContext,pServerContext) \ - (This)->lpVtbl -> AddEnvoyPoliciesToSet(This,pPS,pClientContext,pServerContext) - -#define IPolicyMaker_AddServerPoliciesToSet(This,pPS,pClientContext,pServerContext) \ - (This)->lpVtbl -> AddServerPoliciesToSet(This,pPS,pClientContext,pServerContext) - -#define IPolicyMaker_Freeze(This,pObjContext) \ - (This)->lpVtbl -> Freeze(This,pObjContext) - -#define IPolicyMaker_CreateStub(This,pID) \ - (This)->lpVtbl -> CreateStub(This,pID) - -#define IPolicyMaker_DestroyStub(This,pID) \ - (This)->lpVtbl -> DestroyStub(This,pID) - -#define IPolicyMaker_CreateProxy(This,pID) \ - (This)->lpVtbl -> CreateProxy(This,pID) - -#define IPolicyMaker_DestroyProxy(This,pID) \ - (This)->lpVtbl -> DestroyProxy(This,pID) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - -HRESULT STDMETHODCALLTYPE IPolicyMaker_AddClientPoliciesToSet_Proxy( - IPolicyMaker __RPC_FAR * This, - /* [in] */ IPolicySet __RPC_FAR *pPS, - /* [in] */ IContext __RPC_FAR *pClientContext, - /* [in] */ IContext __RPC_FAR *pServerContext); - - -void __RPC_STUB IPolicyMaker_AddClientPoliciesToSet_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IPolicyMaker_AddEnvoyPoliciesToSet_Proxy( - IPolicyMaker __RPC_FAR * This, - /* [in] */ IPolicySet __RPC_FAR *pPS, - /* [in] */ IContext __RPC_FAR *pClientContext, - /* [in] */ IContext __RPC_FAR *pServerContext); - - -void __RPC_STUB IPolicyMaker_AddEnvoyPoliciesToSet_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IPolicyMaker_AddServerPoliciesToSet_Proxy( - IPolicyMaker __RPC_FAR * This, - /* [in] */ IPolicySet __RPC_FAR *pPS, - /* [in] */ IContext __RPC_FAR *pClientContext, - /* [in] */ IContext __RPC_FAR *pServerContext); - - -void __RPC_STUB IPolicyMaker_AddServerPoliciesToSet_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IPolicyMaker_Freeze_Proxy( - IPolicyMaker __RPC_FAR * This, - /* [in] */ IObjContext __RPC_FAR *pObjContext); - - -void __RPC_STUB IPolicyMaker_Freeze_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IPolicyMaker_CreateStub_Proxy( - IPolicyMaker __RPC_FAR * This, - /* [in] */ IComObjIdentity __RPC_FAR *pID); - - -void __RPC_STUB IPolicyMaker_CreateStub_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IPolicyMaker_DestroyStub_Proxy( - IPolicyMaker __RPC_FAR * This, - /* [in] */ IComObjIdentity __RPC_FAR *pID); - - -void __RPC_STUB IPolicyMaker_DestroyStub_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IPolicyMaker_CreateProxy_Proxy( - IPolicyMaker __RPC_FAR * This, - /* [in] */ IComObjIdentity __RPC_FAR *pID); - - -void __RPC_STUB IPolicyMaker_CreateProxy_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IPolicyMaker_DestroyProxy_Proxy( - IPolicyMaker __RPC_FAR * This, - /* [in] */ IComObjIdentity __RPC_FAR *pID); - - -void __RPC_STUB IPolicyMaker_DestroyProxy_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - - -#endif /* __IPolicyMaker_INTERFACE_DEFINED__ */ - - -#ifndef __IExceptionNotification_INTERFACE_DEFINED__ -#define __IExceptionNotification_INTERFACE_DEFINED__ - -/* interface IExceptionNotification */ -/* [unique][uuid][object][local] */ - - -EXTERN_C const IID IID_IExceptionNotification; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("000001db-0000-0000-C000-000000000046") - IExceptionNotification : public IUnknown - { - public: - virtual void STDMETHODCALLTYPE ServerException( - /* [in] */ void __RPC_FAR *pExcepPtrs) = 0; - - }; - -#else /* C style interface */ - - typedef struct IExceptionNotificationVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( - IExceptionNotification __RPC_FAR * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject); - - ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( - IExceptionNotification __RPC_FAR * This); - - ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( - IExceptionNotification __RPC_FAR * This); - - void ( STDMETHODCALLTYPE __RPC_FAR *ServerException )( - IExceptionNotification __RPC_FAR * This, - /* [in] */ void __RPC_FAR *pExcepPtrs); - - END_INTERFACE - } IExceptionNotificationVtbl; - - interface IExceptionNotification - { - CONST_VTBL struct IExceptionNotificationVtbl __RPC_FAR *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define IExceptionNotification_QueryInterface(This,riid,ppvObject) \ - (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) - -#define IExceptionNotification_AddRef(This) \ - (This)->lpVtbl -> AddRef(This) - -#define IExceptionNotification_Release(This) \ - (This)->lpVtbl -> Release(This) - - -#define IExceptionNotification_ServerException(This,pExcepPtrs) \ - (This)->lpVtbl -> ServerException(This,pExcepPtrs) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - -void STDMETHODCALLTYPE IExceptionNotification_ServerException_Proxy( - IExceptionNotification __RPC_FAR * This, - /* [in] */ void __RPC_FAR *pExcepPtrs); - - -void __RPC_STUB IExceptionNotification_ServerException_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - - -#endif /* __IExceptionNotification_INTERFACE_DEFINED__ */ - - -#ifndef __IMarshalEnvoy_INTERFACE_DEFINED__ -#define __IMarshalEnvoy_INTERFACE_DEFINED__ - -/* interface IMarshalEnvoy */ -/* [unique][uuid][object][local] */ - - -EXTERN_C const IID IID_IMarshalEnvoy; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("000001c8-0000-0000-C000-000000000046") - IMarshalEnvoy : public IUnknown - { - public: - virtual HRESULT STDMETHODCALLTYPE GetEnvoyUnmarshalClass( - /* [in] */ DWORD dwDestContext, - /* [out] */ CLSID __RPC_FAR *pClsid) = 0; - - virtual HRESULT STDMETHODCALLTYPE GetEnvoySizeMax( - /* [in] */ DWORD dwDestContext, - /* [out] */ DWORD __RPC_FAR *pcb) = 0; - - virtual HRESULT STDMETHODCALLTYPE MarshalEnvoy( - /* [in] */ IStream __RPC_FAR *pStream, - /* [in] */ DWORD dwDestContext) = 0; - - virtual HRESULT STDMETHODCALLTYPE UnmarshalEnvoy( - /* [in] */ IStream __RPC_FAR *pStream, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppunk) = 0; - - }; - -#else /* C style interface */ - - typedef struct IMarshalEnvoyVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( - IMarshalEnvoy __RPC_FAR * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject); - - ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( - IMarshalEnvoy __RPC_FAR * This); - - ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( - IMarshalEnvoy __RPC_FAR * This); - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetEnvoyUnmarshalClass )( - IMarshalEnvoy __RPC_FAR * This, - /* [in] */ DWORD dwDestContext, - /* [out] */ CLSID __RPC_FAR *pClsid); - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetEnvoySizeMax )( - IMarshalEnvoy __RPC_FAR * This, - /* [in] */ DWORD dwDestContext, - /* [out] */ DWORD __RPC_FAR *pcb); - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *MarshalEnvoy )( - IMarshalEnvoy __RPC_FAR * This, - /* [in] */ IStream __RPC_FAR *pStream, - /* [in] */ DWORD dwDestContext); - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *UnmarshalEnvoy )( - IMarshalEnvoy __RPC_FAR * This, - /* [in] */ IStream __RPC_FAR *pStream, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppunk); - - END_INTERFACE - } IMarshalEnvoyVtbl; - - interface IMarshalEnvoy - { - CONST_VTBL struct IMarshalEnvoyVtbl __RPC_FAR *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define IMarshalEnvoy_QueryInterface(This,riid,ppvObject) \ - (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) - -#define IMarshalEnvoy_AddRef(This) \ - (This)->lpVtbl -> AddRef(This) - -#define IMarshalEnvoy_Release(This) \ - (This)->lpVtbl -> Release(This) - - -#define IMarshalEnvoy_GetEnvoyUnmarshalClass(This,dwDestContext,pClsid) \ - (This)->lpVtbl -> GetEnvoyUnmarshalClass(This,dwDestContext,pClsid) - -#define IMarshalEnvoy_GetEnvoySizeMax(This,dwDestContext,pcb) \ - (This)->lpVtbl -> GetEnvoySizeMax(This,dwDestContext,pcb) - -#define IMarshalEnvoy_MarshalEnvoy(This,pStream,dwDestContext) \ - (This)->lpVtbl -> MarshalEnvoy(This,pStream,dwDestContext) - -#define IMarshalEnvoy_UnmarshalEnvoy(This,pStream,riid,ppunk) \ - (This)->lpVtbl -> UnmarshalEnvoy(This,pStream,riid,ppunk) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - -HRESULT STDMETHODCALLTYPE IMarshalEnvoy_GetEnvoyUnmarshalClass_Proxy( - IMarshalEnvoy __RPC_FAR * This, - /* [in] */ DWORD dwDestContext, - /* [out] */ CLSID __RPC_FAR *pClsid); - - -void __RPC_STUB IMarshalEnvoy_GetEnvoyUnmarshalClass_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IMarshalEnvoy_GetEnvoySizeMax_Proxy( - IMarshalEnvoy __RPC_FAR * This, - /* [in] */ DWORD dwDestContext, - /* [out] */ DWORD __RPC_FAR *pcb); - - -void __RPC_STUB IMarshalEnvoy_GetEnvoySizeMax_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IMarshalEnvoy_MarshalEnvoy_Proxy( - IMarshalEnvoy __RPC_FAR * This, - /* [in] */ IStream __RPC_FAR *pStream, - /* [in] */ DWORD dwDestContext); - - -void __RPC_STUB IMarshalEnvoy_MarshalEnvoy_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IMarshalEnvoy_UnmarshalEnvoy_Proxy( - IMarshalEnvoy __RPC_FAR * This, - /* [in] */ IStream __RPC_FAR *pStream, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppunk); - - -void __RPC_STUB IMarshalEnvoy_UnmarshalEnvoy_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - - -#endif /* __IMarshalEnvoy_INTERFACE_DEFINED__ */ - - -#ifndef __IWrapperInfo_INTERFACE_DEFINED__ -#define __IWrapperInfo_INTERFACE_DEFINED__ - -/* interface IWrapperInfo */ -/* [unique][uuid][object][local] */ - - -EXTERN_C const IID IID_IWrapperInfo; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("5052f924-7ab8-11d3-b93f-00c04f990176") - IWrapperInfo : public IUnknown - { - public: - virtual void STDMETHODCALLTYPE SetMapping( - void __RPC_FAR *pv) = 0; - - virtual void __RPC_FAR *STDMETHODCALLTYPE GetMapping( void) = 0; - - virtual IObjContext __RPC_FAR *STDMETHODCALLTYPE GetServerObjectContext( void) = 0; - - virtual IUnknown __RPC_FAR *STDMETHODCALLTYPE GetServerObject( void) = 0; - - }; - -#else /* C style interface */ - - typedef struct IWrapperInfoVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( - IWrapperInfo __RPC_FAR * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject); - - ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( - IWrapperInfo __RPC_FAR * This); - - ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( - IWrapperInfo __RPC_FAR * This); - - void ( STDMETHODCALLTYPE __RPC_FAR *SetMapping )( - IWrapperInfo __RPC_FAR * This, - void __RPC_FAR *pv); - - void __RPC_FAR *( STDMETHODCALLTYPE __RPC_FAR *GetMapping )( - IWrapperInfo __RPC_FAR * This); - - IObjContext __RPC_FAR *( STDMETHODCALLTYPE __RPC_FAR *GetServerObjectContext )( - IWrapperInfo __RPC_FAR * This); - - IUnknown __RPC_FAR *( STDMETHODCALLTYPE __RPC_FAR *GetServerObject )( - IWrapperInfo __RPC_FAR * This); - - END_INTERFACE - } IWrapperInfoVtbl; - - interface IWrapperInfo - { - CONST_VTBL struct IWrapperInfoVtbl __RPC_FAR *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define IWrapperInfo_QueryInterface(This,riid,ppvObject) \ - (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) - -#define IWrapperInfo_AddRef(This) \ - (This)->lpVtbl -> AddRef(This) - -#define IWrapperInfo_Release(This) \ - (This)->lpVtbl -> Release(This) - - -#define IWrapperInfo_SetMapping(This,pv) \ - (This)->lpVtbl -> SetMapping(This,pv) - -#define IWrapperInfo_GetMapping(This) \ - (This)->lpVtbl -> GetMapping(This) - -#define IWrapperInfo_GetServerObjectContext(This) \ - (This)->lpVtbl -> GetServerObjectContext(This) - -#define IWrapperInfo_GetServerObject(This) \ - (This)->lpVtbl -> GetServerObject(This) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - -void STDMETHODCALLTYPE IWrapperInfo_SetMapping_Proxy( - IWrapperInfo __RPC_FAR * This, - void __RPC_FAR *pv); - - -void __RPC_STUB IWrapperInfo_SetMapping_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -void __RPC_FAR *STDMETHODCALLTYPE IWrapperInfo_GetMapping_Proxy( - IWrapperInfo __RPC_FAR * This); - - -void __RPC_STUB IWrapperInfo_GetMapping_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -IObjContext __RPC_FAR *STDMETHODCALLTYPE IWrapperInfo_GetServerObjectContext_Proxy( - IWrapperInfo __RPC_FAR * This); - - -void __RPC_STUB IWrapperInfo_GetServerObjectContext_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -IUnknown __RPC_FAR *STDMETHODCALLTYPE IWrapperInfo_GetServerObject_Proxy( - IWrapperInfo __RPC_FAR * This); - - -void __RPC_STUB IWrapperInfo_GetServerObject_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - - -#endif /* __IWrapperInfo_INTERFACE_DEFINED__ */ - - -/* interface __MIDL_itf_contxt_0092 */ -/* [local] */ - - -typedef DWORD APARTMENTID; - - - -extern RPC_IF_HANDLE __MIDL_itf_contxt_0092_v0_0_c_ifspec; -extern RPC_IF_HANDLE __MIDL_itf_contxt_0092_v0_0_s_ifspec; - -#ifndef __IComThreadingInfo_INTERFACE_DEFINED__ -#define __IComThreadingInfo_INTERFACE_DEFINED__ - -/* interface IComThreadingInfo */ -/* [unique][uuid][object][local] */ - - -EXTERN_C const IID IID_IComThreadingInfo; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("000001ce-0000-0000-C000-000000000046") - IComThreadingInfo : public IUnknown - { - public: - virtual HRESULT STDMETHODCALLTYPE GetCurrentApartmentType( - /* [out] */ APTTYPE __RPC_FAR *pAptType) = 0; - - virtual HRESULT STDMETHODCALLTYPE GetCurrentThreadType( - /* [out] */ THDTYPE __RPC_FAR *pThreadType) = 0; - - virtual HRESULT STDMETHODCALLTYPE GetCurrentLogicalThreadId( - /* [out] */ GUID __RPC_FAR *pguidLogicalThreadId) = 0; - - virtual HRESULT STDMETHODCALLTYPE SetCurrentLogicalThreadId( - /* [in] */ REFGUID rguid) = 0; - - }; - -#else /* C style interface */ - - typedef struct IComThreadingInfoVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( - IComThreadingInfo __RPC_FAR * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject); - - ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( - IComThreadingInfo __RPC_FAR * This); - - ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( - IComThreadingInfo __RPC_FAR * This); - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetCurrentApartmentType )( - IComThreadingInfo __RPC_FAR * This, - /* [out] */ APTTYPE __RPC_FAR *pAptType); - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetCurrentThreadType )( - IComThreadingInfo __RPC_FAR * This, - /* [out] */ THDTYPE __RPC_FAR *pThreadType); - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetCurrentLogicalThreadId )( - IComThreadingInfo __RPC_FAR * This, - /* [out] */ GUID __RPC_FAR *pguidLogicalThreadId); - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *SetCurrentLogicalThreadId )( - IComThreadingInfo __RPC_FAR * This, - /* [in] */ REFGUID rguid); - - END_INTERFACE - } IComThreadingInfoVtbl; - - interface IComThreadingInfo - { - CONST_VTBL struct IComThreadingInfoVtbl __RPC_FAR *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define IComThreadingInfo_QueryInterface(This,riid,ppvObject) \ - (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) - -#define IComThreadingInfo_AddRef(This) \ - (This)->lpVtbl -> AddRef(This) - -#define IComThreadingInfo_Release(This) \ - (This)->lpVtbl -> Release(This) - - -#define IComThreadingInfo_GetCurrentApartmentType(This,pAptType) \ - (This)->lpVtbl -> GetCurrentApartmentType(This,pAptType) - -#define IComThreadingInfo_GetCurrentThreadType(This,pThreadType) \ - (This)->lpVtbl -> GetCurrentThreadType(This,pThreadType) - -#define IComThreadingInfo_GetCurrentLogicalThreadId(This,pguidLogicalThreadId) \ - (This)->lpVtbl -> GetCurrentLogicalThreadId(This,pguidLogicalThreadId) - -#define IComThreadingInfo_SetCurrentLogicalThreadId(This,rguid) \ - (This)->lpVtbl -> SetCurrentLogicalThreadId(This,rguid) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - -HRESULT STDMETHODCALLTYPE IComThreadingInfo_GetCurrentApartmentType_Proxy( - IComThreadingInfo __RPC_FAR * This, - /* [out] */ APTTYPE __RPC_FAR *pAptType); - - -void __RPC_STUB IComThreadingInfo_GetCurrentApartmentType_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IComThreadingInfo_GetCurrentThreadType_Proxy( - IComThreadingInfo __RPC_FAR * This, - /* [out] */ THDTYPE __RPC_FAR *pThreadType); - - -void __RPC_STUB IComThreadingInfo_GetCurrentThreadType_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IComThreadingInfo_GetCurrentLogicalThreadId_Proxy( - IComThreadingInfo __RPC_FAR * This, - /* [out] */ GUID __RPC_FAR *pguidLogicalThreadId); - - -void __RPC_STUB IComThreadingInfo_GetCurrentLogicalThreadId_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IComThreadingInfo_SetCurrentLogicalThreadId_Proxy( - IComThreadingInfo __RPC_FAR * This, - /* [in] */ REFGUID rguid); - - -void __RPC_STUB IComThreadingInfo_SetCurrentLogicalThreadId_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - - -#endif /* __IComThreadingInfo_INTERFACE_DEFINED__ */ - - -#ifndef __IComDispatchInfo_INTERFACE_DEFINED__ -#define __IComDispatchInfo_INTERFACE_DEFINED__ - -/* interface IComDispatchInfo */ -/* [unique][uuid][object][local] */ - - -EXTERN_C const IID IID_IComDispatchInfo; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("000001d9-0000-0000-C000-000000000046") - IComDispatchInfo : public IUnknown - { - public: - virtual HRESULT STDMETHODCALLTYPE EnableComInits( - /* [out] */ void __RPC_FAR *__RPC_FAR *ppvCookie) = 0; - - virtual HRESULT STDMETHODCALLTYPE DisableComInits( - /* [in] */ void __RPC_FAR *pvCookie) = 0; - - }; - -#else /* C style interface */ - - typedef struct IComDispatchInfoVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( - IComDispatchInfo __RPC_FAR * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject); - - ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( - IComDispatchInfo __RPC_FAR * This); - - ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( - IComDispatchInfo __RPC_FAR * This); - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *EnableComInits )( - IComDispatchInfo __RPC_FAR * This, - /* [out] */ void __RPC_FAR *__RPC_FAR *ppvCookie); - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *DisableComInits )( - IComDispatchInfo __RPC_FAR * This, - /* [in] */ void __RPC_FAR *pvCookie); - - END_INTERFACE - } IComDispatchInfoVtbl; - - interface IComDispatchInfo - { - CONST_VTBL struct IComDispatchInfoVtbl __RPC_FAR *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define IComDispatchInfo_QueryInterface(This,riid,ppvObject) \ - (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) - -#define IComDispatchInfo_AddRef(This) \ - (This)->lpVtbl -> AddRef(This) - -#define IComDispatchInfo_Release(This) \ - (This)->lpVtbl -> Release(This) - - -#define IComDispatchInfo_EnableComInits(This,ppvCookie) \ - (This)->lpVtbl -> EnableComInits(This,ppvCookie) - -#define IComDispatchInfo_DisableComInits(This,pvCookie) \ - (This)->lpVtbl -> DisableComInits(This,pvCookie) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - -HRESULT STDMETHODCALLTYPE IComDispatchInfo_EnableComInits_Proxy( - IComDispatchInfo __RPC_FAR * This, - /* [out] */ void __RPC_FAR *__RPC_FAR *ppvCookie); - - -void __RPC_STUB IComDispatchInfo_EnableComInits_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IComDispatchInfo_DisableComInits_Proxy( - IComDispatchInfo __RPC_FAR * This, - /* [in] */ void __RPC_FAR *pvCookie); - - -void __RPC_STUB IComDispatchInfo_DisableComInits_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - - -#endif /* __IComDispatchInfo_INTERFACE_DEFINED__ */ - - -/* interface __MIDL_itf_contxt_0094 */ -/* [local] */ - -typedef DWORD HActivator; - -STDAPI CoCreateObjectInContext(IUnknown *pUnk, IObjContext *pObjectCtx, REFIID riid, void **ppv); -STDAPI CoGetApartmentID(APTTYPE dAptType, HActivator* pAptID); -STDAPI CoDeactivateObject(IUnknown *pUnk, IUnknown **ppCookie); -STDAPI CoReactivateObject(IUnknown *pUnk, IUnknown *pCookie); -#define MSHLFLAGS_NO_IEC 0x8 // don't use IExternalConnextion -#define MSHLFLAGS_NO_IMARSHAL 0x10 // don't use IMarshal -#define CONTEXTFLAGS_FROZEN 0x01 // Frozen context -#define CONTEXTFLAGS_ALLOWUNAUTH 0x02 // Allow unauthenticated calls -#define CONTEXTFLAGS_ENVOYCONTEXT 0x04 // Envoy context -#define CONTEXTFLAGS_DEFAULTCONTEXT 0x08 // Default context -#define CONTEXTFLAGS_STATICCONTEXT 0x10 // Static context -#define CONTEXTFLAGS_INPROPTABLE 0x20 // Is in property table -#define CONTEXTFLAGS_INDESTRUCTOR 0x40 // Is in destructor -#define CONTEXTFLAGS_URTPROPPRESENT 0x80 // CLR property added - - -extern RPC_IF_HANDLE __MIDL_itf_contxt_0094_v0_0_c_ifspec; -extern RPC_IF_HANDLE __MIDL_itf_contxt_0094_v0_0_s_ifspec; - -/* Additional Prototypes for ALL interfaces */ - -/* end of Additional Prototypes */ - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/src/inc/corbbtprof.h b/src/inc/corbbtprof.h deleted file mode 100644 index 5aa778254..000000000 --- a/src/inc/corbbtprof.h +++ /dev/null @@ -1,592 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*****************************************************************************\ -* * -* CorBBTProf.h - File format for profile data * -* * -* Version 1.0 * -******************************************************************************* -* * -* THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY * -* KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE * -* IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR * -* PURPOSE. * -* * -\*****************************************************************************/ - -#ifndef _COR_BBTPROF_H_ -#define _COR_BBTPROF_H_ - -#include -#include - -const CorTokenType ibcExternalNamespace = CorTokenType(0x61000000); -const CorTokenType ibcExternalType = CorTokenType(0x62000000); -const CorTokenType ibcExternalSignature = CorTokenType(0x63000000); -const CorTokenType ibcExternalMethod = CorTokenType(0x64000000); -const CorTokenType ibcTypeSpec = CorTokenType(0x68000000); -const CorTokenType ibcMethodSpec = CorTokenType(0x69000000); - -typedef mdToken idExternalNamespace; // External Namespace token in the IBC data -typedef mdToken idExternalType; // External Type token in the IBC data -typedef mdToken idExternalSignature; // External Signature token in the IBC data -typedef mdToken idExternalMethod; // External Method token in the IBC data -typedef mdToken idTypeSpec; // TypeSpec token in the IBC data -typedef mdToken idMethodSpec; // MethodSpec token in the IBC data - -#define idExternalNamespaceNil ((idExternalNamespace) ibcExternalNamespace) -#define idExternalTypeNil ((idExternalType) ibcExternalType) -#define idExternalSignatureNil ((idExternalSignature) ibcExternalSignature) -#define idExternalMethodNil ((idExternalMethod) ibcExternalMethod) -#define idTypeSpecNil ((idTypeSpec) ibcTypeSpec) -#define idMethodSpecNil ((idMethodSpec) ibcMethodSpec) - -// -// File format: -// -// CORBBTPROF_FILE_HEADER -// CORBBTPROF_SECTION_TABLE_HEADER -// CORBBTPROF_SECTION_TABLE_ENTRY -// ... (can be multiple entries) -// -// Method block counts section: -// CORBBTPROF_METHOD_BLOCK_COUNTS_SECTION_HEADER -// CORBBTPROF_METHOD_HEADER -// CORBBTPROF_BLOCK_DATA -// ... (can be multiple method header/block data entries) -// -// Method load order section: -// CORBBTPROF_TOKEN_LIST_SECTION_HEADER -// ... (list of tokens) -// -// Type token usage information -// CORBBTPROF_TOKEN_LIST_SECTION_HEADER -// ... (list of tokens) -// - -// MethodDef token usage information -// CORBBTPROF_TOKEN_LIST_SECTION_HEADER -// ... (list of tokens) -// - -// RIDs to not use slim headers section -// CORBBTPROF_TOKEN_LIST_SECTION_HEADER -// ... (list of tokens) -// - -// Metadata hints to re-order some tables -// Instantiated TypeSPecs to re-order EEClasses -// -// The header for the profile data file. -// ... (list of CORBBTPROF_BLOB_ENTRY) -// terminated by null - -struct CORBBTPROF_FILE_HEADER -{ - DWORD HeaderSize; - DWORD Magic; - DWORD Version; - GUID MVID; -}; - -// Optional in V1 and V2. Usually present in V2. Must be present in V3. -struct CORBBTPROF_FILE_OPTIONAL_HEADER -{ - DWORD Size; // Including the size field - DWORD MinorVersion; - DWORD FileFlags; // Only in V3 or later - // future fields -}; - -enum CORBBTPROF_FILE_FLAGS -{ - CORBBTPROF_FILE_FLAG_MINIFIED = 1, - CORBBTPROF_FILE_FLAG_PARTIAL_NGEN = 2 -}; - -enum -{ - CORBBTPROF_V0_VERSION = 0, - CORBBTPROF_V1_VERSION = 1, - CORBBTPROF_V2_VERSION = 2, - CORBBTPROF_V3_VERSION = 3, - CORBBTPROF_CURRENT_VERSION = CORBBTPROF_V2_VERSION, // V3 is opt-in - CORBBTPROF_MAGIC = 0xb1d0f11e, - CORBBTPROF_END_TOKEN = 0xb4356f98 -}; - -// -// The profile data can be mapped anywhere in memory. So instead of using pointers, -// to denote sections, we will instead use offsets from the beginning of the file. -// - -struct Section -{ - DWORD Offset; - DWORD Size; -}; - -// -// Section types, where various sections contains different types of profile data. -// - -#define CORBBTPROF_TOKEN_MAX_NUM_FLAGS 32 - -enum TypeProfilingDataFlags -{ - // Important: update toolbox\ibcmerge\ibcmerge.cs if you change these - ReadMethodTable = 0, // 0x00001 - ReadEEClass = 1, // 0x00002 - WriteEEClass = 2, // 0x00004 -// ReadStoredEnumData = 3, // 0x00008 // obsolete - ReadFieldDescs = 4, // 0x00010 - ReadCCtorInfo = 5, // 0x00020 - ReadClassHashTable = 6, // 0x00040 - ReadDispatchMap = 7, // 0x00080 - ReadDispatchTable = 8, // 0x00100 - ReadMethodTableWriteableData = 9, // 0x00200 - ReadFieldMarshalers = 10, // 0x00400 -// WriteDispatchTable = 11, // 0x00800 // obsolete -// WriteMethodTable = 12, // 0x01000 // obsolete - WriteMethodTableWriteableData = 13, // 0x02000 - ReadTypeDesc = 14, // 0x04000 - WriteTypeDesc = 15, // 0x08000 - ReadTypeHashTable = 16, // 0x10000 -// WriteTypeHashTable = 17, // 0x20000 // obsolete -// ReadDictionary = 18, // 0x40000 // obsolete -// WriteDictionary = 19, // 0x80000 // obsolete - ReadNonVirtualSlots = 20, // 0x100000 -}; - -enum MethodProfilingDataFlags -{ - // Important: update toolbox\ibcmerge\ibcmerge.cs if you change these - ReadMethodCode = 0, // 0x00001 // Also means the method was executed - ReadMethodDesc = 1, // 0x00002 - RunOnceMethod = 2, // 0x00004 - RunNeverMethod = 3, // 0x00008 -// MethodStoredDataAccess = 4, // 0x00010 // obsolete - WriteMethodDesc = 5, // 0x00020 -// ReadFCallHash = 6, // 0x00040 // obsolete - ReadGCInfo = 7, // 0x00080 - CommonReadGCInfo = 8, // 0x00100 -// ReadMethodDefRidMap = 9, // 0x00200 // obsolete - ReadCerMethodList = 10, // 0x00400 - ReadMethodPrecode = 11, // 0x00800 - WriteMethodPrecode = 12, // 0x01000 - ExcludeHotMethodCode = 13, // 0x02000 // Hot method should be excluded from the ReadyToRun image - ExcludeColdMethodCode = 14, // 0x04000 // Cold method should be excluded from the ReadyToRun image - DisableInlining = 15, // 0x08000 // Disable inlining of this method in optimized AOT native code -}; - -enum GeneralProfilingDataFlags -{ - // Important: update ibcmerge.cs if you change these - // ZapImage.h depends on 0xFFFFFFFF being an invalid flag value. If this - // changes, update ReadFlagWithMemory in that file. - // Important: make sure these don't collide with TypeProfilingDataFlags or MethodProfilingDataFlags - // These grow downward from CORBBTPROF_TOKEN_MAX_NUM_FLAGS-1 to minimize the chance of collision - ProfilingFlags_MetaData = 31, // 0x800... - CommonMetaData = 30, // 0x400... - RidMap = 29, // 0x200... - RVAFieldData = 28, // 0x100... - ProfilingFlags_MetaDataSearch = 27, // 0x080... -}; - -enum BlobType -{ - /* IMPORTANT: Keep the first four enums together in the same order and at - the very begining of this enum. See MetaModelPub.h for the order */ - MetadataStringPool = 0, - MetadataGuidPool = 1, - MetadataBlobPool = 2, - MetadataUserStringPool = 3, - - FirstMetadataPool = 0, - LastMetadataPool = 3, - - // SectionFormat only supports tokens, which have to already exist in the module. - // For instantiated paramterized types, there may be no corresponding token - // in the module, if a dependent module caused the type to be instantiated. - // For such instantiated types, we save a blob/signature to identify the type. - // - ParamTypeSpec = 4, // Instantiated Type Signature - ParamMethodSpec = 5, // Instantiated Method Signature - ExternalNamespaceDef = 6, // External Namespace Token Definition - ExternalTypeDef = 7, // External Type Token Definition - ExternalSignatureDef = 8, // External Signature Definition - ExternalMethodDef = 9, // External Method Token Definition - - IllegalBlob = 10, // Failed to allocate the blob - - EndOfBlobStream = -1 -}; - -enum SectionFormat -{ - // Important: update ibcmerge.cs if you change these - ScenarioInfo = 0, - MethodBlockCounts = 1, // Basic-block counts. Cold blocks will be placed in the cold-code section - BlobStream = 2, // metadata access, inst-type-spec and inst-method-spec blobs - - FirstTokenFlagSection = 3, - - ModuleProfilingData = FirstTokenFlagSection + (mdtModule >> 24), - TypeRefProfilingData = FirstTokenFlagSection + (mdtTypeRef >> 24), - TypeProfilingData = FirstTokenFlagSection + (mdtTypeDef >> 24), - FieldDefProfilingData = FirstTokenFlagSection + (mdtFieldDef >> 24), - MethodProfilingData = FirstTokenFlagSection + (mdtMethodDef >> 24), - ParamDefProfilingData = FirstTokenFlagSection + (mdtParamDef >> 24), - InterfaceImplProfilingData = FirstTokenFlagSection + (mdtInterfaceImpl >> 24), - MemberRefProfilingData = FirstTokenFlagSection + (mdtMemberRef >> 24), - CustomAttributeProfilingData = FirstTokenFlagSection + (mdtCustomAttribute >> 24), - PermissionProfilingData = FirstTokenFlagSection + (mdtPermission >> 24), - SignatureProfilingData = FirstTokenFlagSection + (mdtSignature >> 24), - EventProfilingData = FirstTokenFlagSection + (mdtEvent >> 24), - PropertyProfilingData = FirstTokenFlagSection + (mdtProperty >> 24), - ModuleRefProfilingData = FirstTokenFlagSection + (mdtModuleRef >> 24), - TypeSpecProfilingData = FirstTokenFlagSection + (mdtTypeSpec >> 24), - AssemblyProfilingData = FirstTokenFlagSection + (mdtAssembly >> 24), - AssemblyRefProfilingData = FirstTokenFlagSection + (mdtAssemblyRef >> 24), - FileProfilingData = FirstTokenFlagSection + (mdtFile >> 24), - ExportedTypeProfilingData = FirstTokenFlagSection + (mdtExportedType >> 24), - ManifestResourceProfilingData = FirstTokenFlagSection + (mdtManifestResource >> 24), - GenericParamProfilingData = FirstTokenFlagSection + (mdtGenericParam >> 24), - MethodSpecProfilingData = FirstTokenFlagSection + (mdtMethodSpec >> 24), - GenericParamConstraintProfilingData = FirstTokenFlagSection + (mdtGenericParamConstraint >> 24), - - StringPoolProfilingData, - GuidPoolProfilingData, - BlobPoolProfilingData, - UserStringPoolProfilingData, - - FirstMetadataPoolSection = StringPoolProfilingData, - LastMetadataPoolSection = UserStringPoolProfilingData, - LastTokenFlagSection = LastMetadataPoolSection, - - IbcTypeSpecSection, - IbcMethodSpecSection, - - GenericTypeProfilingData = 63, // Deprecated with V2 IBC data - SectionFormatCount = 64, // 0x40 - - SectionFormatInvalid = -1 -}; - -struct CORBBTPROF_SECTION_TABLE_ENTRY -{ - SectionFormat FormatID; - Section Data; -}; - -struct CORBBTPROF_SECTION_TABLE_HEADER -{ - DWORD NumEntries; - CORBBTPROF_SECTION_TABLE_ENTRY Entries[0]; -}; - -// -// ScenarioInfo section -// - -struct CORBBTPROF_SCENARIO_RUN -{ - FILETIME runTime; // the FILETIME when the scenario was cnt - GUID mvid; // The GUID of this assembly when the scenario was run (useful for incremental ibcdata) - DWORD cCmdLine; // the count of WCHAR's in the cmdLine for this run of the scenario - DWORD cSystemInfo; // the count of WCHAR's in the systemInfo string for this run of the scenario - WCHAR cmdLine[0]; // the command line used, the array is 'cName' in length -// WCHAR systemInfo[]; // the system information, the array is 'cSystemInfo' in length - - DWORD sizeofCmdLine() - { - return (cCmdLine * (DWORD)sizeof(WCHAR)); - } - - DWORD sizeofSystemInfo() - { - return (cSystemInfo * (DWORD)sizeof(WCHAR)); - } - - DWORD Size() - { - return (DWORD)sizeof(CORBBTPROF_SCENARIO_RUN) + sizeofCmdLine() + sizeofSystemInfo(); - } - - CORBBTPROF_SCENARIO_RUN* GetNextRun() - { - return reinterpret_cast< CORBBTPROF_SCENARIO_RUN* >( - reinterpret_cast< PBYTE >( this + 1 ) + Size() ); - } -}; - -struct CORBBTPROF_SCENARIO_INFO -{ - DWORD ordinal; // the id number for this scenario - DWORD mask; // the one-bit mask use to identify this scenario - DWORD priority; // the priority of this scenario - DWORD numRuns; // the number of times this scenario was run - DWORD cName; // the count of WCHAR's in name[] - WCHAR name[0]; // the name of this scenario, the array is 'cName' in length -// CORBBTPROF_SCENARIO_RUN run[]; // the array is 'numRuns' in length - - DWORD sizeofName() - { - return (DWORD) (cName * sizeof(WCHAR)); - } - - DWORD Size() - { - return (DWORD) sizeof(CORBBTPROF_SCENARIO_INFO) + sizeofName() + sizeofRuns(); - } - - CORBBTPROF_SCENARIO_RUN* GetScenarioRun() - { - return reinterpret_cast< CORBBTPROF_SCENARIO_RUN* >( - reinterpret_cast< PBYTE >( this ) + (DWORD)sizeof(CORBBTPROF_SCENARIO_INFO) + sizeofName()); - } - - DWORD sizeofRuns() - { - DWORD sum = 0; - if (numRuns > 0) - { - DWORD cnt = 1; - CORBBTPROF_SCENARIO_RUN* pRun = GetScenarioRun(); - do - { - sum += pRun->Size(); - if (cnt == numRuns) - break; - cnt++; - pRun = pRun->GetNextRun(); - } - while (true); - } - return sum; - } -}; - -struct CORBBTPROF_SCENARIO_HEADER -{ - DWORD size; // Size to skip to get to the next CORBBTPROF_SCENARIO_HEADER - CORBBTPROF_SCENARIO_INFO scenario; - - DWORD Size() - { - return (DWORD) sizeof(CORBBTPROF_SCENARIO_HEADER) + scenario.sizeofName() + scenario.sizeofRuns(); - } -}; - -struct CORBBTPROF_SCENARIO_INFO_SECTION_HEADER -{ - DWORD TotalNumRuns; - DWORD NumScenarios; -// CORBBTPROF_SCENARIO_HEADER scenario[0]; // array is 'NumScenarios' in length -}; - -// -// MethodBlockCounts section -// - -struct CORBBTPROF_METHOD_BLOCK_COUNTS_SECTION_HEADER_V1 -{ - DWORD NumMethods; - DWORD NumRuns; -}; - -struct CORBBTPROF_METHOD_BLOCK_COUNTS_SECTION_HEADER -{ - DWORD NumMethods; -}; - -struct CORBBTPROF_BLOCK_DATA // Also defined here code:ICorJitInfo.ProfileBuffer -{ - DWORD ILOffset; - DWORD ExecutionCount; -}; - -struct CORBBTPROF_METHOD_DETAIL_HEADER -{ - DWORD size; // Size to skip to get to the next CORBBTPROF_METHOD_DETAIL_HEADER at this level - DWORD kind; // Identifier that specifies what kind this CORBBTPROF_METHOD_DETAIL_HEADER actually represents - - size_t Size() - { - return size; - } -}; - -// -// This struct records the basic block execution counts for a method -// -struct CORBBTPROF_METHOD_INFO -{ - DWORD token; // token for this method - DWORD ILSize; // IL size for this method - DWORD cBlock; // count for block[] - CORBBTPROF_BLOCK_DATA block[0]; // actually 'cBlock' in length - - size_t Size() - { - return sizeof(CORBBTPROF_METHOD_INFO) + sizeofBlock(); - } - - size_t sizeofBlock() - { - return cBlock * sizeof(CORBBTPROF_BLOCK_DATA); - } -}; - -struct CORBBTPROF_METHOD_HEADER_V1 -{ - DWORD HeaderSize; - mdToken MethodToken; - DWORD Size; -}; - -struct CORBBTPROF_METHOD_HEADER -{ - DWORD size; // Size to skip to get to the next CORBBTPROF_METHOD_HEADER - DWORD cDetail; // the count of CORBBTPROF_METHOD_DETAIL_HEADER records that folow this record - CORBBTPROF_METHOD_INFO method; // Basic block execution counts for a method - // ... followed by 'cDetail' occurances of CORBBTPROF_METHOD_DETAIL_HEADER - - size_t Size() - { - return sizeof(CORBBTPROF_METHOD_HEADER) + method.sizeofBlock(); - } -}; - - -struct CORBBTPROF_TOKEN_LIST_SECTION_HEADER -{ - DWORD NumTokens; -}; - -struct CORBBTPROF_TOKEN_LIST_ENTRY_V1 -{ - mdToken token; - DWORD flags; -}; - -struct CORBBTPROF_TOKEN_INFO // Was CORBBTPROF_TOKEN_LIST_ENTRY -{ - mdToken token; - DWORD flags; - DWORD scenarios; // Could use UINT64 instead - - CORBBTPROF_TOKEN_INFO() - : token(0) - , flags(0) - , scenarios(0) - {} - - CORBBTPROF_TOKEN_INFO( mdToken t, DWORD f = 0, DWORD s = 0) - : token(t) - , flags(f) - , scenarios(s) - {} - - CORBBTPROF_TOKEN_INFO( CORBBTPROF_TOKEN_INFO const & right ) - : token(right.token) - , flags(right.flags) - , scenarios(right.scenarios) - {} - - CORBBTPROF_TOKEN_INFO operator=( CORBBTPROF_TOKEN_INFO const & right ) - { - token = right.token; - flags = right.flags; - scenarios = right.scenarios; - return *this; - } - - bool operator<( CORBBTPROF_TOKEN_INFO const & right ) const - { - return token < right.token; - } -}; - -struct CORBBTPROF_BLOB_ENTRY_V1 -{ - BlobType blobType; - DWORD flags; - DWORD cBuffer; - BYTE pBuffer[0]; // actually 'cBuffer' in length - - CORBBTPROF_BLOB_ENTRY_V1 * GetNextEntry() - { - return reinterpret_cast< CORBBTPROF_BLOB_ENTRY_V1* >( - reinterpret_cast< PBYTE >( this + 1 ) + cBuffer ); - } -}; - -struct CORBBTPROF_BLOB_ENTRY -{ - DWORD size; - BlobType type; - mdToken token; // The code:CORBBTPROF_BLOB_ENTRY.token field is not a real meta-data token - // but a look-alike that IBCMerge makes to represent blob entry - - bool TypeIsValid() - { - return (type >= MetadataStringPool) && (type < IllegalBlob); - } - - CORBBTPROF_BLOB_ENTRY * GetNextEntry() - { - return reinterpret_cast< CORBBTPROF_BLOB_ENTRY* >( - reinterpret_cast< PBYTE >( this ) + size); - } -}; - -struct CORBBTPROF_BLOB_PARAM_SIG_ENTRY -{ - CORBBTPROF_BLOB_ENTRY blob; - DWORD cSig; - COR_SIGNATURE sig[0]; // actually 'cSig' in length -}; - -struct CORBBTPROF_BLOB_NAMESPACE_DEF_ENTRY -{ - CORBBTPROF_BLOB_ENTRY blob; - DWORD cName; - CHAR name[0]; // actually cName in length -}; - -struct CORBBTPROF_BLOB_TYPE_DEF_ENTRY -{ - CORBBTPROF_BLOB_ENTRY blob; - mdToken assemblyRefToken; - mdToken nestedClassToken; - mdToken nameSpaceToken; - DWORD cName; - CHAR name[0]; // actually cName in length -}; - -struct CORBBTPROF_BLOB_SIGNATURE_DEF_ENTRY -{ - CORBBTPROF_BLOB_ENTRY blob; - DWORD cSig; - COR_SIGNATURE sig[0]; // actually 'cSig' in length -}; - -struct CORBBTPROF_BLOB_METHOD_DEF_ENTRY -{ - CORBBTPROF_BLOB_ENTRY blob; - mdToken nestedClassToken; - mdToken signatureToken; - DWORD cName; - CHAR name[0]; // actually cName in length -}; - -struct CORBBTPROF_BLOB_POOL_ENTRY -{ - CORBBTPROF_BLOB_ENTRY blob; - DWORD cBuffer; - BYTE buffer[0]; // actually 'cBuffer' in length -}; -#endif /* COR_BBTPROF_H_ */ diff --git a/src/inc/corcompile.h b/src/inc/corcompile.h deleted file mode 100644 index 6de9c8e34..000000000 --- a/src/inc/corcompile.h +++ /dev/null @@ -1,1831 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*****************************************************************************\ -* * -* CorCompile.h - EE / Compiler interface * -* * -* Version 1.0 * -******************************************************************************* -* * -* * -* * -\*****************************************************************************/ -// See code:CorProfileData for information on Hot Cold splitting using profile data. - - -#ifndef _COR_COMPILE_H_ -#define _COR_COMPILE_H_ - -#ifndef FEATURE_PREJIT -#error FEATURE_PREJIT is required for this file -#endif // FEATURE_PREJIT - -#if !defined(_TARGET_X86_) || defined(FEATURE_PAL) -#ifndef WIN64EXCEPTIONS -#define WIN64EXCEPTIONS -#endif -#endif // !_TARGET_X86_ || FEATURE_PAL - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -typedef DPTR(struct CORCOMPILE_CODE_MANAGER_ENTRY) - PTR_CORCOMPILE_CODE_MANAGER_ENTRY; -typedef DPTR(struct CORCOMPILE_EE_INFO_TABLE) - PTR_CORCOMPILE_EE_INFO_TABLE; -typedef DPTR(struct CORCOMPILE_HEADER) - PTR_CORCOMPILE_HEADER; -typedef DPTR(struct CORCOMPILE_IMPORT_TABLE_ENTRY) - PTR_CORCOMPILE_IMPORT_TABLE_ENTRY; -typedef DPTR(struct CORCOMPILE_COLD_METHOD_ENTRY) - PTR_CORCOMPILE_COLD_METHOD_ENTRY; -typedef DPTR(struct CORCOMPILE_EXCEPTION_LOOKUP_TABLE) - PTR_CORCOMPILE_EXCEPTION_LOOKUP_TABLE; -typedef DPTR(struct CORCOMPILE_EXCEPTION_LOOKUP_TABLE_ENTRY) - PTR_CORCOMPILE_EXCEPTION_LOOKUP_TABLE_ENTRY; -typedef DPTR(struct CORCOMPILE_EXCEPTION_CLAUSE) - PTR_CORCOMPILE_EXCEPTION_CLAUSE; -typedef DPTR(struct CORCOMPILE_VIRTUAL_IMPORT_THUNK) - PTR_CORCOMPILE_VIRTUAL_IMPORT_THUNK; -typedef DPTR(struct CORCOMPILE_EXTERNAL_METHOD_THUNK) - PTR_CORCOMPILE_EXTERNAL_METHOD_THUNK; -typedef DPTR(struct CORCOMPILE_EXTERNAL_METHOD_DATA_ENTRY) - PTR_CORCOMPILE_EXTERNAL_METHOD_DATA_ENTRY; -typedef DPTR(struct CORCOMPILE_VIRTUAL_SECTION_INFO) - PTR_CORCOMPILE_VIRTUAL_SECTION_INFO; -typedef DPTR(struct CORCOMPILE_IMPORT_SECTION) - PTR_CORCOMPILE_IMPORT_SECTION; - -#ifdef _TARGET_X86_ - -typedef DPTR(RUNTIME_FUNCTION) PTR_RUNTIME_FUNCTION; - - -// Chained unwind info. Used for cold methods. -#define RUNTIME_FUNCTION_INDIRECT 0x80000000 - -#endif // _TARGET_X86_ - -// The stride is choosen as maximum value that still gives good page locality of RUNTIME_FUNCTION table touches (only one page of -// RUNTIME_FUNCTION table is going to be touched during most IP2MD lookups). -// -// Smaller stride values also improve speed of IP2MD lookups, but this improvement is not significant (5% when going -// from 8192 to 1024), so the working set / page locality was used as the metric to choose the optimum value. -// -#define RUNTIME_FUNCTION_LOOKUP_STRIDE 8192 - - -typedef DPTR(struct CORCOMPILE_METHOD_PROFILE_LIST) - PTR_CORCOMPILE_METHOD_PROFILE_LIST; -typedef DPTR(struct CORCOMPILE_RUNTIME_DLL_INFO) - PTR_CORCOMPILE_RUNTIME_DLL_INFO; -typedef DPTR(struct CORCOMPILE_VERSION_INFO) PTR_CORCOMPILE_VERSION_INFO; -typedef DPTR(struct COR_ILMETHOD) PTR_COR_ILMETHOD; - -// This can be used to specify a dll that should be used as the compiler during ngen. -// If this is not specified, the default compiler dll will be used. -// If this is specified, it needs to be specified for all the assemblies that are ngenned. -#define NGEN_COMPILER_OVERRIDE_KEY W("NGen_JitName") - -// -// CORCOMPILE_IMPORT_SECTION describes image range with references to other assemblies or runtime data structures -// -// There is number of different types of these ranges: eagerly initialized at image load vs. lazily initialized at method entry -// vs. lazily initialized on first use; hot vs. cold, handles vs. code pointers, etc. -// -struct CORCOMPILE_IMPORT_SECTION -{ - IMAGE_DATA_DIRECTORY Section; // Section containing values to be fixed up - USHORT Flags; // One or more of CorCompileImportFlags - BYTE Type; // One of CorCompileImportType - BYTE EntrySize; - DWORD Signatures; // RVA of optional signature descriptors - DWORD AuxiliaryData; // RVA of optional auxiliary data (typically GC info) -}; - -enum CorCompileImportType -{ - CORCOMPILE_IMPORT_TYPE_UNKNOWN = 0, - CORCOMPILE_IMPORT_TYPE_EXTERNAL_METHOD = 1, - CORCOMPILE_IMPORT_TYPE_STUB_DISPATCH = 2, - CORCOMPILE_IMPORT_TYPE_STRING_HANDLE = 3, - CORCOMPILE_IMPORT_TYPE_TYPE_HANDLE = 4, - CORCOMPILE_IMPORT_TYPE_METHOD_HANDLE = 5, - CORCOMPILE_IMPORT_TYPE_VIRTUAL_METHOD = 6, -}; - -enum CorCompileImportFlags -{ - CORCOMPILE_IMPORT_FLAGS_EAGER = 0x0001, // Section at module load time. - CORCOMPILE_IMPORT_FLAGS_CODE = 0x0002, // Section contains code. - CORCOMPILE_IMPORT_FLAGS_PCODE = 0x0004, // Section contains pointers to code. -}; - -// ================================================================================ -// Portable tagged union of a pointer field with a 30 bit scalar value -// ================================================================================ - -// The lowest bit of the tag will be set for tagged pointers. We also set the highest bit for convenience. -// It makes dereferences of tagged pointers to crash under normal circumstances. -// The highest bit of the tag will be set for tagged indexes (e.g. classid). - -#define CORCOMPILE_TOKEN_TAG 0x80000001 - -// These two macros are mostly used just for debug-only checks to ensure that we have either tagged pointer (lowest bit is set) -// or tagged index (highest bit is set). -#define CORCOMPILE_IS_POINTER_TAGGED(token) ((((SIZE_T)(token)) & 0x00000001) != 0) -#define CORCOMPILE_IS_INDEX_TAGGED(token) ((((SIZE_T)(token)) & 0x80000000) != 0) - -// The token (RVA of the fixup in most cases) is stored in the mid 30 bits of DWORD -#define CORCOMPILE_TAG_TOKEN(token) ((SIZE_T)(((token)<<1)|CORCOMPILE_TOKEN_TAG)) -#define CORCOMPILE_UNTAG_TOKEN(token) ((((SIZE_T)(token))&~CORCOMPILE_TOKEN_TAG)>>1) - -#ifdef _TARGET_ARM_ -// Tagging of code pointers on ARM uses inverse logic because of the thumb bit. -#define CORCOMPILE_IS_PCODE_TAGGED(token) ((((SIZE_T)(token)) & 0x00000001) == 0x00000000) -#define CORCOMPILE_TAG_PCODE(token) ((SIZE_T)(((token)<<1)|0x80000000)) -#else -#define CORCOMPILE_IS_PCODE_TAGGED(token) CORCOMPILE_IS_POINTER_TAGGED(token) -#define CORCOMPILE_TAG_PCODE(token) CORCOMPILE_TAG_TOKEN(token) -#endif - -inline BOOL CORCOMPILE_IS_FIXUP_TAGGED(SIZE_T fixup, PTR_CORCOMPILE_IMPORT_SECTION pSection) -{ -#ifdef _TARGET_ARM_ - // Tagging of code pointers on ARM has to use inverse logic because of the thumb bit - if (pSection->Flags & CORCOMPILE_IMPORT_FLAGS_PCODE) - { - return CORCOMPILE_IS_PCODE_TAGGED(fixup); - } -#endif - - return ((((SIZE_T)(fixup)) & CORCOMPILE_TOKEN_TAG) == CORCOMPILE_TOKEN_TAG); -} - -enum CorCompileBuild -{ - CORCOMPILE_BUILD_CHECKED, - CORCOMPILE_BUILD_FREE -}; - -enum CorCompileCodegen -{ - CORCOMPILE_CODEGEN_DEBUGGING = 0x0001, // suports debugging (unoptimized code with symbol info) - - CORCOMPILE_CODEGEN_PROFILING = 0x0004, // supports profiling - CORCOMPILE_CODEGEN_PROF_INSTRUMENTING = 0x0008, // code is instrumented to collect profile count info - -}; - - -// Used for INativeImageInstallInfo::GetConfigMask() -// A bind will ask for the particular bits it needs set; if all bits are set, it is a match. Additional -// bits are ignored. - -enum CorCompileConfigFlags -{ - CORCOMPILE_CONFIG_DEBUG_NONE = 0x01, // Assembly has Optimized code - CORCOMPILE_CONFIG_DEBUG = 0x02, // Assembly has non-Optimized debuggable code - CORCOMPILE_CONFIG_DEBUG_DEFAULT = 0x08, // Additional flag set if this particular setting is the - // one indicated by the assembly debug custom attribute. - - CORCOMPILE_CONFIG_PROFILING_NONE = 0x100, // Assembly code has profiling hooks - CORCOMPILE_CONFIG_PROFILING = 0x200, // Assembly code has profiling hooks - - CORCOMPILE_CONFIG_INSTRUMENTATION_NONE = 0x1000, // Assembly code has no instrumentation - CORCOMPILE_CONFIG_INSTRUMENTATION = 0x2000, // Assembly code has basic block instrumentation -}; - -// Values for Flags field of CORCOMPILE_HEADER. -enum CorCompileHeaderFlags -{ - CORCOMPILE_HEADER_HAS_SECURITY_DIRECTORY = 0x00000001, // Original image had a security directory - // Note it is useless to cache the actual directory contents - // since it must be verified as part of the original image - CORCOMPILE_HEADER_IS_IBC_OPTIMIZED = 0x00000002, - - CORCOMPILE_HEADER_IS_READY_TO_RUN = 0x00000004, -}; - -// -// !!! INCREMENT THE MAJOR VERSION ANY TIME THERE IS CHANGE IN CORCOMPILE_HEADER STRUCTURE !!! -// -#define CORCOMPILE_SIGNATURE 0x0045474E // 'NGEN' -#define CORCOMPILE_MAJOR_VERSION 0x0001 -#define CORCOMPILE_MINOR_VERSION 0x0000 - -// This structure is pointed to by the code:IMAGE_COR20_HEADER (see file:corcompile.h#ManagedHeader) -// See the file:../../doc/BookOfTheRuntime/NGEN/NGENDesign.doc for more -struct CORCOMPILE_HEADER -{ - // For backward compatibility reasons, VersionInfo field must be at offset 40, ManifestMetaData - // must be at 88, PEKind must be at 112/116 bytes, Machine must be at 120/124 bytes, and - // size of CORCOMPILE_HEADER must be 164/168 bytes. Be careful when you modify this struct. - // See code:PEDecoder::GetMetaDataHelper. - DWORD Signature; - USHORT MajorVersion; - USHORT MinorVersion; - - IMAGE_DATA_DIRECTORY HelperTable; // Table of function pointers to JIT helpers indexed by helper number - IMAGE_DATA_DIRECTORY ImportSections; // points to array of code:CORCOMPILE_IMPORT_SECTION - IMAGE_DATA_DIRECTORY ImportTable; // points to table CORCOMPILE_IMPORT_TABLE_ENTRY - IMAGE_DATA_DIRECTORY StubsData; // contains the value to register with the stub manager for the delegate stubs & AMD64 tail call stubs - IMAGE_DATA_DIRECTORY VersionInfo; // points to a code:CORCOMPILE_VERSION_INFO - IMAGE_DATA_DIRECTORY Dependencies; // points to an array of code:CORCOMPILE_DEPENDENCY - IMAGE_DATA_DIRECTORY DebugMap; // points to an array of code:CORCOMPILE_DEBUG_RID_ENTRY hashed by method RID - IMAGE_DATA_DIRECTORY ModuleImage; // points to the freeze dried Module structure - IMAGE_DATA_DIRECTORY CodeManagerTable; // points to a code:CORCOMPILE_CODE_MANAGER_ENTRY - IMAGE_DATA_DIRECTORY ProfileDataList;// points to the list of code:CORCOMPILE_METHOD_PROFILE_LIST - IMAGE_DATA_DIRECTORY ManifestMetaData; // points to the native manifest metadata - IMAGE_DATA_DIRECTORY VirtualSectionsTable;// List of CORCOMPILE_VIRTUAL_SECTION_INFO. Contains a list of Section - // ranges for debugging purposes. There is one entry in this table per - // ZapVirtualSection in the NGEN image. This data is used to fire ETW - // events that describe the various VirtualSection in the NGEN image. These - // events are used for diagnostics and performance purposes. Some of the - // questions these events help answer are like : how effective is IBC - // training data. They can also be used to have better nidump support for - // decoding virtual section information ( start - end ranges for each - // virtual section ) - - TADDR ImageBase; // Actual image base address (ASLR fakes the image base in PE header while applying relocations in kernel) - DWORD Flags; // Flags, see CorCompileHeaderFlags above - - DWORD PEKind; // CorPEKind of the original IL image - - ULONG COR20Flags; // Cached value of code:IMAGE_COR20_HEADER.Flags from original IL image - WORD Machine; // Cached value of _IMAGE_FILE_HEADER.Machine from original IL image - WORD Characteristics;// Cached value of _IMAGE_FILE_HEADER.Characteristics from original IL image - - IMAGE_DATA_DIRECTORY EEInfoTable; // points to a code:CORCOMPILE_EE_INFO_TABLE - - // For backward compatibility (see above) - IMAGE_DATA_DIRECTORY Dummy1; - IMAGE_DATA_DIRECTORY Dummy2; - IMAGE_DATA_DIRECTORY Dummy3; - IMAGE_DATA_DIRECTORY Dummy4; -}; - -// CORCOMPILE_VIRTUAL_SECTION_INFO describes virtual section ranges. This data is used by nidump -// and to fire ETW that are used for diagnostics and performance purposes. Some of the questions -// these events help answer are like : how effective is IBC training data. -struct CORCOMPILE_VIRTUAL_SECTION_INFO -{ - ULONG VirtualAddress; - ULONG Size; - DWORD SectionType; -}; - -#define CORCOMPILE_SECTION_TYPES() \ - CORCOMPILE_SECTION_TYPE(Module) \ - CORCOMPILE_SECTION_TYPE(EETable) \ - CORCOMPILE_SECTION_TYPE(WriteData) \ - CORCOMPILE_SECTION_TYPE(WriteableData) \ - CORCOMPILE_SECTION_TYPE(Data) \ - CORCOMPILE_SECTION_TYPE(RVAStatics) \ - CORCOMPILE_SECTION_TYPE(EEData) \ - CORCOMPILE_SECTION_TYPE(DelayLoadInfoTableEager) \ - CORCOMPILE_SECTION_TYPE(DelayLoadInfoTable) \ - CORCOMPILE_SECTION_TYPE(EEReadonlyData) \ - CORCOMPILE_SECTION_TYPE(ReadonlyData) \ - CORCOMPILE_SECTION_TYPE(Class) \ - CORCOMPILE_SECTION_TYPE(CrossDomainInfo) \ - CORCOMPILE_SECTION_TYPE(MethodDesc) \ - CORCOMPILE_SECTION_TYPE(MethodDescWriteable) \ - CORCOMPILE_SECTION_TYPE(Exception) \ - CORCOMPILE_SECTION_TYPE(Instrument) \ - CORCOMPILE_SECTION_TYPE(VirtualImportThunk) \ - CORCOMPILE_SECTION_TYPE(ExternalMethodThunk) \ - CORCOMPILE_SECTION_TYPE(HelperTable) \ - CORCOMPILE_SECTION_TYPE(MethodPrecodeWriteable) \ - CORCOMPILE_SECTION_TYPE(MethodPrecodeWrite) \ - CORCOMPILE_SECTION_TYPE(MethodPrecode) \ - CORCOMPILE_SECTION_TYPE(Win32Resources) \ - CORCOMPILE_SECTION_TYPE(Header) \ - CORCOMPILE_SECTION_TYPE(Metadata) \ - CORCOMPILE_SECTION_TYPE(DelayLoadInfo) \ - CORCOMPILE_SECTION_TYPE(ImportTable) \ - CORCOMPILE_SECTION_TYPE(Code) \ - CORCOMPILE_SECTION_TYPE(CodeHeader) \ - CORCOMPILE_SECTION_TYPE(CodeManager) \ - CORCOMPILE_SECTION_TYPE(UnwindData) \ - CORCOMPILE_SECTION_TYPE(RuntimeFunction) \ - CORCOMPILE_SECTION_TYPE(Stubs) \ - CORCOMPILE_SECTION_TYPE(StubDispatchData) \ - CORCOMPILE_SECTION_TYPE(ExternalMethodData) \ - CORCOMPILE_SECTION_TYPE(DelayLoadInfoDelayList) \ - CORCOMPILE_SECTION_TYPE(ReadonlyShared) \ - CORCOMPILE_SECTION_TYPE(Readonly) \ - CORCOMPILE_SECTION_TYPE(IL) \ - CORCOMPILE_SECTION_TYPE(GCInfo) \ - CORCOMPILE_SECTION_TYPE(ILMetadata) \ - CORCOMPILE_SECTION_TYPE(Resources) \ - CORCOMPILE_SECTION_TYPE(CompressedMaps) \ - CORCOMPILE_SECTION_TYPE(Debug) \ - CORCOMPILE_SECTION_TYPE(BaseRelocs) \ - -// Hot: Items are frequently accessed ( Indicated by either IBC data, or -// statically known ) - -// Warm : Items are less frequently accessed, or frequently accessed -// but were not touched during IBC profiling. - -// Cold : Least frequently accessed /shouldn't not be accessed -// when running a scenario that was used during IBC -// training ( training scenario ) - -// HotColdSorted : Sections marked with this category means they contain both -// Hot items and Cold items. The hot items are placed before -// the cold items (Sorted) - -#define CORCOMPILE_SECTION_RANGE_TYPES() \ - CORCOMPILE_SECTION_RANGE_TYPE(Hot, 0x00010000) \ - CORCOMPILE_SECTION_RANGE_TYPE(Warm, 0x00020000) \ - CORCOMPILE_SECTION_RANGE_TYPE(Cold, 0x00040000) \ - CORCOMPILE_SECTION_RANGE_TYPE(HotColdSorted, 0x00080000) \ - - -// IBCUnProfiled: Items in this VirtualSection are statically determined to be cold. -// (IBC Profiling wouldn't have helped put these item in a hot section). -// Items that currently doesn't have IBC probs, or are always put in a specific section -// regardless of IBC data should fall in this category. - -// IBCProfiled: IBC profiling placed items in this section, or -// items are NOT placed into a hot section they didn't have IBC profiling data -// ( IBC profiling would have helped put these items in a hot section ) - -#define CORCOMPILE_SECTION_IBCTYPES() \ - CORCOMPILE_SECTION_IBCTYPE(IBCUnProfiled, 0x01000000) \ - CORCOMPILE_SECTION_IBCTYPE(IBCProfiled, 0x02000000) \ - - -// Support for VirtualSection Metadata/Categories -// Please update the VirtualSetionType ETW map in ClrEtwAll.man if you changed this enum. -// ZapVirtualSectionType is used to describe metadata about VirtualSections. -// The metadata consists of 3 sub-metadata parts. -// --------------------------------------------------- -// 1 byte 1 byte 2 bytes -- -// -- -// --------------------------------------------------- -// -// -// VirtualSections are a CLR concept to aggregate data -// items that share common properties together (Hot/Cold/Warm, Writeable/ -// Readonly ...etc.). VirtualSections are tagged with some categories when they -// are created (code:NewVirtualSection) -// The VirtualSection categorize are described more in VirtualSectionType enum. -// The categories describe 2 important aspects for each VirtualSection -// -// *********************************************** -// IBCProfiled v.s NonIBCProfiled Categories. -// ********************************************** -// -// IBCProfiled: Distinguish between sections that IBC profiling data has been used -// to decide the layout of the data items in this section. -// NonIBCProfiled: We don't have IBC data for all our datastructures. -// The access pattern/frequency for some data structures -// are statically determined. Sections that contain these data items -// are marked as NonIBCProfiled. -// -//*************************************************** -// Access Frequency categories -// ************************************************** -// Hot: Data is frequently accessed -// Warm: Less frequently accessed than Hot -// Cold: Should be rarely accessed. -// -// The combination of these 2 sub-categories gives us the following valid categories -// 1-IBCProfiled | Hot: Hot based on IBC profiling data. -// 2-IBCProfiled | Cold: IBC profiling could have helped make this section hot. -// 3-NonIBCProfiled | Hot: Statically determined hot. -// 4-NonIBCProfiled | Warm: Staticaly determined warm. -// 5-NonIBCProfiled | Cold: Statically determined cold. -// -// We should try to place data items into the correct section based on -// the above categorization, this could mean that we might split -// a virtual section into 2 sections if it contains multiple heterogeneous items. - -enum ZapVirtualSectionType -{ - // - IBCTypeReservedFlag = 0xFF000000, -#define CORCOMPILE_SECTION_IBCTYPE(ibcType, flag) ibcType##Section = flag, - CORCOMPILE_SECTION_IBCTYPES() -#undef CORCOMPILE_SECTION_IBCTYPE - - // - RangeTypeReservedFlag = 0x00FF0000, -#define CORCOMPILE_SECTION_RANGE_TYPE(rangeType, flag) rangeType##Range = flag, - CORCOMPILE_SECTION_RANGE_TYPES() -#undef CORCOMPILE_SECTION_RANGE_TYPE - - // - VirtualSectionTypeReservedFlag = 0x0000FFFF, - VirtualSectionTypeStartSection = 0x0, // reserved so the first section start at 0x1 -#define CORCOMPILE_SECTION_TYPE(virtualSectionType) virtualSectionType##Section, - CORCOMPILE_SECTION_TYPES() -#undef CORCOMPILE_SECTION_TYPE - - CORCOMPILE_SECTION_TYPE_COUNT -}; - -class VirtualSectionData -{ - -public : - static UINT8 IBCType(DWORD sectionType) { return (UINT8) ((sectionType & IBCTypeReservedFlag) >> 24); } - static UINT8 RangeType(DWORD sectionType) { return (UINT8) ((sectionType & RangeTypeReservedFlag) >> 16); } - static UINT16 VirtualSectionType(DWORD sectionType) { return (UINT16) ((sectionType & VirtualSectionTypeReservedFlag)); } - static BOOL IsIBCProfiledColdSection(DWORD sectionType) - { - return ((sectionType & ColdRange) == ColdRange) && ((sectionType & IBCProfiledSection) == IBCProfiledSection); - } -}; - -struct CORCOMPILE_IMPORT_TABLE_ENTRY -{ - USHORT wAssemblyRid; - USHORT wModuleRid; -}; - -struct CORCOMPILE_EE_INFO_TABLE -{ - TADDR inlinedCallFrameVptr; - PTR_LONG addrOfCaptureThreadGlobal; - PTR_DWORD addrOfJMCFlag; - SIZE_T gsCookie; - CORINFO_Object ** emptyString; - - DWORD threadTlsIndex; - - DWORD rvaStaticTlsIndex; -}; - -/*********************************************************************************/ - -// This is the offset to the compressed blob of debug information - -typedef ULONG CORCOMPILE_DEBUG_ENTRY; - -// A single generic method may be get compiled into multiple copies of code for -// different instantiations, and can have multiple entries for the same RID. - -struct CORCOMPILE_DEBUG_LABELLED_ENTRY -{ - DWORD nativeCodeRVA; // the ngen code RVA distinguishes this entry from others with the same RID. - CORCOMPILE_DEBUG_ENTRY debugInfoOffset; // offset to the debug information for this native code -}; - -// Debug information is accessed using a table of RVAs indexed by the RID token for -// the method. - -typedef CORCOMPILE_DEBUG_ENTRY CORCOMPILE_DEBUG_RID_ENTRY; - -// If this bit is not set, the CORCOMPILE_DEBUG_RID_ENTRY RVA points to a compressed -// debug information blob. -// If this bit is set, the RVA points to CORCOMPILE_DEBUG_LABELLED_ENTRY. -// If this bit is set in CORCOMPILE_DEBUG_LABELLED_ENTRY, there is another entry following it. - -const CORCOMPILE_DEBUG_RID_ENTRY CORCOMPILE_DEBUG_MULTIPLE_ENTRIES = 0x80000000; - -inline bool IsMultipleLabelledEntries(CORCOMPILE_DEBUG_RID_ENTRY rva) -{ - SUPPORTS_DAC; - - return (rva & CORCOMPILE_DEBUG_MULTIPLE_ENTRIES) != 0; -} - -inline unsigned GetDebugRidEntryHash(mdToken token) -{ - SUPPORTS_DAC; - - unsigned hashCode = token; - - // mix it - hashCode -= hashCode >> 17; - hashCode -= hashCode >> 11; - hashCode -= hashCode >> 5; - - return hashCode; -} - -typedef DPTR(CORCOMPILE_DEBUG_ENTRY) PTR_CORCOMPILE_DEBUG_ENTRY; -typedef DPTR(struct CORCOMPILE_DEBUG_LABELLED_ENTRY) PTR_CORCOMPILE_DEBUG_LABELLED_ENTRY; -typedef DPTR(CORCOMPILE_DEBUG_RID_ENTRY) PTR_CORCOMPILE_DEBUG_RID_ENTRY; - -/*********************************************************************************/ - -struct CORCOMPILE_CODE_MANAGER_ENTRY -{ - IMAGE_DATA_DIRECTORY HotCode; - IMAGE_DATA_DIRECTORY Code; - IMAGE_DATA_DIRECTORY ColdCode; - - IMAGE_DATA_DIRECTORY ROData; - - //Layout is - //HOT COMMON - //HOT IBC - //HOT GENERICS - //Hot due to procedure splitting - ULONG HotIBCMethodOffset; - ULONG HotGenericsMethodOffset; - - //Layout is - //COLD IBC - //Cold due to procedure splitting. - ULONG ColdUntrainedMethodOffset; -}; - -#if defined(_TARGET_X86_) || defined(_TARGET_AMD64_) - -#define _PRECODE_EXTERNAL_METHOD_THUNK 0x41 -#define _PRECODE_VIRTUAL_IMPORT_THUNK 0x42 - - struct CORCOMPILE_VIRTUAL_IMPORT_THUNK - { - BYTE callJmp[5]; // Call/Jmp Pc-Rel32 - BYTE precodeType; // 0x42 _PRECODE_VIRTUAL_IMPORT_THUNK - WORD slotNum; - }; - - struct CORCOMPILE_EXTERNAL_METHOD_THUNK - { - BYTE callJmp[5]; // Call/Jmp Pc-Rel32 - BYTE precodeType; // 0x41 _PRECODE_EXTERNAL_METHOD_THUNK - WORD padding; - }; - -#elif defined(_TARGET_ARM_) - - struct CORCOMPILE_VIRTUAL_IMPORT_THUNK - { - // Array of words to do the following: - // - // mov r12, pc ; Save the current address relative to which we will get slot ID and address to patch. - // ldr pc, [pc, #4] ; Load the target address. Initially it will point to the helper stub that will patch it - // ; to point to the actual target on the first run. - WORD m_rgCode[3]; - - // WORD to store the slot ID - WORD slotNum; - - // The target address - initially, this will point to VirtualMethodFixupStub. - // Post patchup by the stub, it will point to the actual method body. - PCODE m_pTarget; - }; - - struct CORCOMPILE_EXTERNAL_METHOD_THUNK - { - // Array of words to do the following: - // - // mov r12, pc ; Save the current address relative to which we will get GCRef bitmap and address to patch. - // ldr pc, [pc, #4] ; Load the target address. Initially it will point to the helper stub that will patch it - // ; to point to the actual target on the first run. - WORD m_rgCode[3]; - - WORD m_padding; - - // The target address - initially, this will point to ExternalMethodFixupStub. - // Post patchup by the stub, it will point to the actual method body. - PCODE m_pTarget; - }; - -#elif defined(_TARGET_ARM64_) - struct CORCOMPILE_VIRTUAL_IMPORT_THUNK - { - // Array of words to do the following: - // - // adr x12, #0 ; Save the current address relative to which we will get slot ID and address to patch. - // ldr x10, [x12, #16] ; Load the target address. - // br x10 ; Jump to the target - DWORD m_rgCode[3]; - - // WORD to store the slot ID - WORD slotNum; - - // The target address - initially, this will point to VirtualMethodFixupStub. - // Post patchup by the stub, it will point to the actual method body. - PCODE m_pTarget; - }; - - struct CORCOMPILE_EXTERNAL_METHOD_THUNK - { - // Array of words to do the following: - // adr x12, #0 ; Save the current address relative to which we will get slot ID and address to patch. - // ldr x10, [x12, #16] ; Load the target address. - // br x10 ; Jump to the target - DWORD m_rgCode[3]; - - DWORD m_padding; //aligning stack to 16 bytes - - // The target address - initially, this will point to ExternalMethodFixupStub. - // Post patchup by the stub, it will point to the actual method body. - PCODE m_pTarget; - }; - -#endif - -// -// GCRefMap blob starts with DWORDs lookup index of relative offsets into the blob. This lookup index is used to limit amount -// of linear scanning required to find entry in the GCRefMap. The size of this lookup index is -// / GCREFMAP_LOOKUP_STRIDE. -// -#define GCREFMAP_LOOKUP_STRIDE 1024 - -enum CORCOMPILE_GCREFMAP_TOKENS -{ - GCREFMAP_SKIP = 0, - GCREFMAP_REF = 1, - GCREFMAP_INTERIOR = 2, - GCREFMAP_METHOD_PARAM = 3, - GCREFMAP_TYPE_PARAM = 4, - GCREFMAP_VASIG_COOKIE = 5, -}; - -// Tags for fixup blobs -enum CORCOMPILE_FIXUP_BLOB_KIND -{ - ENCODE_NONE = 0, - - ENCODE_MODULE_OVERRIDE = 0x80, /* When the high bit is set, override of the module immediately follows */ - - ENCODE_DICTIONARY_LOOKUP_THISOBJ = 0x07, - ENCODE_DICTIONARY_LOOKUP_TYPE = 0x08, - ENCODE_DICTIONARY_LOOKUP_METHOD = 0x09, - - ENCODE_TYPE_HANDLE = 0x10, /* Type handle */ - ENCODE_METHOD_HANDLE, /* Method handle */ - ENCODE_FIELD_HANDLE, /* Field handle */ - - ENCODE_METHOD_ENTRY, /* For calling a method entry point */ - ENCODE_METHOD_ENTRY_DEF_TOKEN, /* Smaller version of ENCODE_METHOD_ENTRY - method is def token */ - ENCODE_METHOD_ENTRY_REF_TOKEN, /* Smaller version of ENCODE_METHOD_ENTRY - method is ref token */ - - ENCODE_VIRTUAL_ENTRY, /* For invoking a virtual method */ - ENCODE_VIRTUAL_ENTRY_DEF_TOKEN, /* Smaller version of ENCODE_VIRTUAL_ENTRY - method is def token */ - ENCODE_VIRTUAL_ENTRY_REF_TOKEN, /* Smaller version of ENCODE_VIRTUAL_ENTRY - method is ref token */ - ENCODE_VIRTUAL_ENTRY_SLOT, /* Smaller version of ENCODE_VIRTUAL_ENTRY - type & slot */ - - ENCODE_READYTORUN_HELPER, /* ReadyToRun helper */ - ENCODE_STRING_HANDLE, /* String token */ - - ENCODE_NEW_HELPER, /* Dynamically created new helpers */ - ENCODE_NEW_ARRAY_HELPER, - - ENCODE_ISINSTANCEOF_HELPER, /* Dynamically created casting helper */ - ENCODE_CHKCAST_HELPER, - - ENCODE_FIELD_ADDRESS, /* For accessing a cross-module static fields */ - ENCODE_CCTOR_TRIGGER, /* Static constructor trigger */ - - ENCODE_STATIC_BASE_NONGC_HELPER, /* Dynamically created static base helpers */ - ENCODE_STATIC_BASE_GC_HELPER, - ENCODE_THREAD_STATIC_BASE_NONGC_HELPER, - ENCODE_THREAD_STATIC_BASE_GC_HELPER, - - ENCODE_FIELD_BASE_OFFSET, /* Field base */ - ENCODE_FIELD_OFFSET, - - ENCODE_TYPE_DICTIONARY, - ENCODE_METHOD_DICTIONARY, - - ENCODE_CHECK_TYPE_LAYOUT, - ENCODE_CHECK_FIELD_OFFSET, - - ENCODE_DELEGATE_CTOR, - - ENCODE_DECLARINGTYPE_HANDLE, - - ENCODE_MODULE_HANDLE = 0x50, /* Module token */ - ENCODE_STATIC_FIELD_ADDRESS, /* For accessing a static field */ - ENCODE_MODULE_ID_FOR_STATICS, /* For accessing static fields */ - ENCODE_MODULE_ID_FOR_GENERIC_STATICS, /* For accessing static fields */ - ENCODE_CLASS_ID_FOR_STATICS, /* For accessing static fields */ - ENCODE_SYNC_LOCK, /* For synchronizing access to a type */ - ENCODE_INDIRECT_PINVOKE_TARGET, /* For calling a pinvoke method ptr */ - ENCODE_PROFILING_HANDLE, /* For the method's profiling counter */ - ENCODE_VARARGS_METHODDEF, /* For calling a varargs method */ - ENCODE_VARARGS_METHODREF, - ENCODE_VARARGS_SIG, - ENCODE_ACTIVE_DEPENDENCY, /* Conditional active dependency */ - ENCODE_METHOD_NATIVE_ENTRY, /* NativeCallable method token */ -}; - -enum EncodeMethodSigFlags -{ - ENCODE_METHOD_SIG_UnboxingStub = 0x01, - ENCODE_METHOD_SIG_InstantiatingStub = 0x02, - ENCODE_METHOD_SIG_MethodInstantiation = 0x04, - ENCODE_METHOD_SIG_SlotInsteadOfToken = 0x08, - ENCODE_METHOD_SIG_MemberRefToken = 0x10, - ENCODE_METHOD_SIG_Constrained = 0x20, - ENCODE_METHOD_SIG_OwnerType = 0x40, -}; - -enum EncodeFieldSigFlags -{ - ENCODE_FIELD_SIG_IndexInsteadOfToken = 0x08, - ENCODE_FIELD_SIG_MemberRefToken = 0x10, - ENCODE_FIELD_SIG_OwnerType = 0x40, -}; - -class SBuffer; -class SigBuilder; -class PEDecoder; -class GCRefMapBuilder; - -//REVIEW: include for ee exception info -#include "eexcp.h" - -struct CORCOMPILE_EXCEPTION_LOOKUP_TABLE_ENTRY -{ - DWORD MethodStartRVA; - DWORD ExceptionInfoRVA; -}; - -struct CORCOMPILE_EXCEPTION_LOOKUP_TABLE -{ - // pointer to the first element of m_numLookupEntries elements - CORCOMPILE_EXCEPTION_LOOKUP_TABLE_ENTRY m_Entries[1]; - - CORCOMPILE_EXCEPTION_LOOKUP_TABLE_ENTRY* ExceptionLookupEntry(unsigned i) - { - SUPPORTS_DAC_WRAPPER; - return &(PTR_CORCOMPILE_EXCEPTION_LOOKUP_TABLE_ENTRY(PTR_HOST_MEMBER_TADDR(CORCOMPILE_EXCEPTION_LOOKUP_TABLE,this,m_Entries))[i]); - } -}; - -struct CORCOMPILE_EXCEPTION_CLAUSE -{ - CorExceptionFlag Flags; - DWORD TryStartPC; - DWORD TryEndPC; - DWORD HandlerStartPC; - DWORD HandlerEndPC; - union { - mdToken ClassToken; - DWORD FilterOffset; - }; -}; - -//lower order bit (HAS_EXCEPTION_INFO_MASK) used to determine if the method has any exception handling -#define HAS_EXCEPTION_INFO_MASK 1 - -struct CORCOMPILE_COLD_METHOD_ENTRY -{ -#ifdef WIN64EXCEPTIONS - DWORD mainFunctionEntryRVA; -#endif - // TODO: hotCodeSize should be encoded in GC info - ULONG hotCodeSize; -}; - -// MVID used by the metadata of all ngen images -// {70E9452F-5F0A-4f0e-8E02-203992F4221C} -EXTERN_GUID(NGEN_IMAGE_MVID, 0x70e9452f, 0x5f0a, 0x4f0e, 0x8e, 0x2, 0x20, 0x39, 0x92, 0xf4, 0x22, 0x1c); - -typedef GUID CORCOMPILE_NGEN_SIGNATURE; - -// To indicate that the dependency is not hardbound -// {DB15CD8C-1378-4963-9DF3-14D97E95D1A1} -EXTERN_GUID(INVALID_NGEN_SIGNATURE, 0xdb15cd8c, 0x1378, 0x4963, 0x9d, 0xf3, 0x14, 0xd9, 0x7e, 0x95, 0xd1, 0xa1); - -struct CORCOMPILE_ASSEMBLY_SIGNATURE -{ - // Metadata MVID. - GUID mvid; - - // timestamp and IL image size for the source IL assembly. - // This is used for mini-dump to find matching metadata. - DWORD timeStamp; - DWORD ilImageSize; -}; - -typedef enum -{ - CORECLR_INFO, - CROSSGEN_COMPILER_INFO, - NUM_RUNTIME_DLLS -} CorCompileRuntimeDlls; - -extern LPCWSTR CorCompileGetRuntimeDllName(CorCompileRuntimeDlls id); - -// Will always return a valid HMODULE for CLR_INFO, but will return NULL for NGEN_COMPILER_INFO -// if the DLL has not yet been loaded (it does not try to cause a load). -extern HMODULE CorCompileGetRuntimeDll(CorCompileRuntimeDlls id); - -struct CORCOMPILE_RUNTIME_DLL_INFO -{ - // This structure can only contain information not updated by authenticode signing. It is required - // for crossgen to work in buildlab. It particular, it cannot contain PE checksum because of it is - // update by authenticode signing. - DWORD timeStamp; - DWORD virtualSize; -}; - - - -struct CORCOMPILE_VERSION_INFO -{ - // OS - WORD wOSPlatformID; - WORD wOSMajorVersion; - - // For backward compatibility reasons, the following four fields must start at offset 4, - // be consequtive, and be 2 bytes each. See code:PEDecoder::GetMetaDataHelper. - // EE Version - WORD wVersionMajor; - WORD wVersionMinor; - WORD wVersionBuildNumber; - WORD wVersionPrivateBuildNumber; - - // Codegen flags - WORD wCodegenFlags; - WORD wConfigFlags; - WORD wBuild; - - // Processor - WORD wMachine; - CORINFO_CPU cpuInfo; - - // Signature of source assembly - CORCOMPILE_ASSEMBLY_SIGNATURE sourceAssembly; - - // Signature which identifies this ngen image - CORCOMPILE_NGEN_SIGNATURE signature; - - // Timestamp info for runtime dlls - CORCOMPILE_RUNTIME_DLL_INFO runtimeDllInfo[NUM_RUNTIME_DLLS]; -}; - - - - -struct CORCOMPILE_DEPENDENCY -{ - // Pre-bind Ref - mdAssemblyRef dwAssemblyRef; - - // Post-bind Def - mdAssemblyRef dwAssemblyDef; - CORCOMPILE_ASSEMBLY_SIGNATURE signAssemblyDef; - - CORCOMPILE_NGEN_SIGNATURE signNativeImage; // INVALID_NGEN_SIGNATURE if this a soft-bound dependency - - -}; - -/*********************************************************************************/ -// Flags used to encode HelperTable -#if defined(_TARGET_ARM64_) -#define HELPER_TABLE_ENTRY_LEN 16 -#else -#define HELPER_TABLE_ENTRY_LEN 8 -#endif //defined(_TARGET_ARM64_) - -#define HELPER_TABLE_ALIGN 8 -#define CORCOMPILE_HELPER_PTR 0x80000000 // The entry is pointer to the helper (jump thunk otherwise) - -// The layout of this struct is required to be -// a 'next' pointer followed by a CORBBTPROF_METHOD_HEADER -// -struct CORCOMPILE_METHOD_PROFILE_LIST -{ - CORCOMPILE_METHOD_PROFILE_LIST * next; -// CORBBTPROF_METHOD_HEADER info; - - CORBBTPROF_METHOD_HEADER * GetInfo() - { return (CORBBTPROF_METHOD_HEADER *) (this+1); } -}; - -// see code:CorProfileData.GetHotTokens for how we determine what is in hot meta-data. -class CorProfileData -{ -public: - CorProfileData(void * rawProfileData); // really of type ZapImage::ProfileDataSection* - - struct CORBBTPROF_TOKEN_INFO * GetTokenFlagsData(SectionFormat section) - { - if (this == NULL) - return NULL; - return this->profilingTokenFlagsData[section].data; - } - - DWORD GetTokenFlagsCount(SectionFormat section) - { - if (this == NULL) - return 0; - return this->profilingTokenFlagsData[section].count; - } - - CORBBTPROF_BLOB_ENTRY * GetBlobStream() - { - if (this == NULL) - return NULL; - return this->blobStream; - } - - - // see code:MetaData::HotMetaDataHeader for details on reading hot meta-data - // - // for detail on where we use the API to store the hot meta data - // * code:CMiniMdRW.SaveFullTablesToStream#WritingHotMetaData - // * code:CMiniMdRW.SaveHotPoolsToStream - // * code:CMiniMdRW.SaveHotPoolToStream#CallToGetHotTokens - // - ULONG GetHotTokens(int table, DWORD mask, DWORD hotValue, mdToken *tokenBuffer, ULONG maxCount) - { - ULONG count = 0; - SectionFormat format = (SectionFormat)(FirstTokenFlagSection + table); - - CORBBTPROF_TOKEN_INFO *profilingData = profilingTokenFlagsData[format].data; - DWORD cProfilingData = profilingTokenFlagsData[format].count; - - if (profilingData != NULL) - { - for (DWORD i = 0; i < cProfilingData; i++) - { - if ((profilingData[i].flags & mask) == hotValue) - { - if (tokenBuffer != NULL && count < maxCount) - tokenBuffer[count] = profilingData[i].token; - count++; - } - } - } - return count; - } - - // - // Token lookup methods - // - ULONG GetTypeProfilingFlagsOfToken(mdToken token) - { - _ASSERTE(TypeFromToken(token) == mdtTypeDef); - return GetProfilingFlagsOfToken(token); - } - - CORBBTPROF_BLOB_PARAM_SIG_ENTRY *GetBlobSigEntry(mdToken token) - { - _ASSERTE((TypeFromToken(token) == ibcTypeSpec) || (TypeFromToken(token) == ibcMethodSpec)); - - CORBBTPROF_BLOB_ENTRY * pBlobEntry = GetBlobEntry(token); - if (pBlobEntry == NULL) - return NULL; - - _ASSERTE(pBlobEntry->token == token); - _ASSERTE((pBlobEntry->type == ParamTypeSpec) || (pBlobEntry->type == ParamMethodSpec)); - - return (CORBBTPROF_BLOB_PARAM_SIG_ENTRY *) pBlobEntry; - } - - CORBBTPROF_BLOB_NAMESPACE_DEF_ENTRY *GetBlobExternalNamespaceDef(mdToken token) - { - _ASSERTE(TypeFromToken(token) == ibcExternalNamespace); - - CORBBTPROF_BLOB_ENTRY * pBlobEntry = GetBlobEntry(token); - if (pBlobEntry == NULL) - return NULL; - - _ASSERTE(pBlobEntry->token == token); - _ASSERTE(pBlobEntry->type == ExternalNamespaceDef); - - return (CORBBTPROF_BLOB_NAMESPACE_DEF_ENTRY *) pBlobEntry; - } - - CORBBTPROF_BLOB_TYPE_DEF_ENTRY *GetBlobExternalTypeDef(mdToken token) - { - _ASSERTE(TypeFromToken(token) == ibcExternalType); - - CORBBTPROF_BLOB_ENTRY * pBlobEntry = GetBlobEntry(token); - if (pBlobEntry == NULL) - return NULL; - - _ASSERTE(pBlobEntry->token == token); - _ASSERTE(pBlobEntry->type == ExternalTypeDef); - - return (CORBBTPROF_BLOB_TYPE_DEF_ENTRY *) pBlobEntry; - } - - CORBBTPROF_BLOB_SIGNATURE_DEF_ENTRY *GetBlobExternalSignatureDef(mdToken token) - { - _ASSERTE(TypeFromToken(token) == ibcExternalSignature); - - CORBBTPROF_BLOB_ENTRY * pBlobEntry = GetBlobEntry(token); - if (pBlobEntry == NULL) - return NULL; - - _ASSERTE(pBlobEntry->token == token); - _ASSERTE(pBlobEntry->type == ExternalSignatureDef); - - return (CORBBTPROF_BLOB_SIGNATURE_DEF_ENTRY *) pBlobEntry; - } - - CORBBTPROF_BLOB_METHOD_DEF_ENTRY *GetBlobExternalMethodDef(mdToken token) - { - _ASSERTE(TypeFromToken(token) == ibcExternalMethod); - - CORBBTPROF_BLOB_ENTRY * pBlobEntry = GetBlobEntry(token); - if (pBlobEntry == NULL) - return NULL; - - _ASSERTE(pBlobEntry->token == token); - _ASSERTE(pBlobEntry->type == ExternalMethodDef); - - return (CORBBTPROF_BLOB_METHOD_DEF_ENTRY *) pBlobEntry; - } - -private: - ULONG GetProfilingFlagsOfToken(mdToken token) - { - SectionFormat section = (SectionFormat)((TypeFromToken(token) >> 24) + FirstTokenFlagSection); - - CORBBTPROF_TOKEN_INFO *profilingData = this->profilingTokenFlagsData[section].data; - DWORD cProfilingData = this->profilingTokenFlagsData[section].count; - - if (profilingData != NULL) - { - for (DWORD i = 0; i < cProfilingData; i++) - { - if (profilingData[i].token == token) - return profilingData[i].flags; - } - } - return 0; - } - - CORBBTPROF_BLOB_ENTRY *GetBlobEntry(idTypeSpec token) - { - CORBBTPROF_BLOB_ENTRY * pBlobEntry = this->GetBlobStream(); - if (pBlobEntry == NULL) - return NULL; - - while (pBlobEntry->TypeIsValid()) - { - if (pBlobEntry->token == token) - { - return pBlobEntry; - } - pBlobEntry = pBlobEntry->GetNextEntry(); - } - - return NULL; - } - -private: - struct - { - struct CORBBTPROF_TOKEN_INFO *data; - DWORD count; - } - profilingTokenFlagsData[SectionFormatCount]; - - CORBBTPROF_BLOB_ENTRY* blobStream; -}; - -/*********************************************************************************/ -// IL region is used to group frequently used IL method bodies together - -enum CorCompileILRegion -{ - CORCOMPILE_ILREGION_INLINEABLE, // Public inlineable methods - CORCOMPILE_ILREGION_WARM, // Other inlineable methods and methods that failed to NGen - CORCOMPILE_ILREGION_GENERICS, // Generic methods (may be needed to compile non-NGened instantiations) - CORCOMPILE_ILREGION_COLD, // Everything else (should be touched in rare scenarios like reflection or profiling only) - CORCOMPILE_ILREGION_COUNT, -}; - -/********************************************************************************* - * ICorCompilePreloader is used to query preloaded EE data structures - *********************************************************************************/ - -class ICorCompilePreloader -{ - public: - typedef void (__stdcall *CORCOMPILE_CompileStubCallback)(LPVOID pContext, CORINFO_METHOD_HANDLE hStub, CORJIT_FLAGS jitFlags); - - // - // Map methods are available after Serialize() is called - // (which will cause it to allocate its data.) Note that returned - // results are RVAs into the image. - // - // If compiling after serializing the preloaded image, these methods can - // be used to avoid making entries in the various info tables. - // Else, use ICorCompileInfo::CanEmbedXXX() - // - - virtual DWORD MapMethodEntryPoint( - CORINFO_METHOD_HANDLE handle - ) = 0; - - virtual DWORD MapClassHandle( - CORINFO_CLASS_HANDLE handle - ) = 0; - - virtual DWORD MapMethodHandle( - CORINFO_METHOD_HANDLE handle - ) = 0; - - virtual DWORD MapFieldHandle( - CORINFO_FIELD_HANDLE handle - ) = 0; - - virtual DWORD MapAddressOfPInvokeFixup( - CORINFO_METHOD_HANDLE handle - ) = 0; - - virtual DWORD MapGenericHandle( - CORINFO_GENERIC_HANDLE handle - ) = 0; - - virtual DWORD MapModuleIDHandle( - CORINFO_MODULE_HANDLE handle - ) = 0; - - // Load a method for the specified method def - // If the class or method is generic, instantiate all parameters with - virtual CORINFO_METHOD_HANDLE LookupMethodDef(mdMethodDef token) = 0; - - // For the given ftnHnd fill in the methInfo structure and return true if successful. - virtual bool GetMethodInfo(mdMethodDef token, CORINFO_METHOD_HANDLE ftnHnd, CORINFO_METHOD_INFO * methInfo) = 0; - - // Returns region that the IL should be emitted in - virtual CorCompileILRegion GetILRegion(mdMethodDef token) = 0; - - // Find the (parameterized) method for the given blob from the profile data - virtual CORINFO_METHOD_HANDLE FindMethodForProfileEntry(CORBBTPROF_BLOB_PARAM_SIG_ENTRY * profileBlobEntry) = 0; - - virtual void ReportInlining(CORINFO_METHOD_HANDLE inliner, CORINFO_METHOD_HANDLE inlinee) = 0; - - // - // Call Link when you want all the fixups - // to be applied. You may call this e.g. after - // compiling all the code for the module. - // Return some stats about the types in the ngen image - // - virtual void Link() = 0; - - virtual void FixupRVAs() = 0; - - virtual void SetRVAsForFields(IMetaDataEmit * pEmit) = 0; - - virtual void GetRVAFieldData(mdFieldDef fd, PVOID * ppData, DWORD * pcbSize, DWORD * pcbAlignment) = 0; - - // The preloader also maintains a set of uncompiled generic - // methods or methods in generic classes. A single method can be - // registered or all the methods in a class can be registered. - // The method is added to the set only if it should be compiled - // into this ngen image - // - // The zapper registers methods and classes that are resolved by - // findClass and findMethod during compilation - virtual void AddMethodToTransitiveClosureOfInstantiations(CORINFO_METHOD_HANDLE handle) = 0; - virtual void AddTypeToTransitiveClosureOfInstantiations(CORINFO_CLASS_HANDLE handle) = 0; - - // Report reference to the given method from compiled code - virtual void MethodReferencedByCompiledCode(CORINFO_METHOD_HANDLE handle) = 0; - - virtual BOOL IsUncompiledMethod(CORINFO_METHOD_HANDLE handle) = 0; - - // Return a method handle that was previously registered and - // hasn't been compiled already, and remove it from the set - // of uncompiled methods. - // Return NULL if the set is empty - virtual CORINFO_METHOD_HANDLE NextUncompiledMethod() = 0; - - // Prepare a method and its statically determinable call graph if - // a hint attribute has been applied. This is called to save - // additional preparation information into the ngen image that - // wouldn't normally be there (since we can't automatically - // determine it's needed). - virtual void PrePrepareMethodIfNecessary(CORINFO_METHOD_HANDLE hMethod) = 0; - - // If a method requires stubs, this will call back passing method - // handles for those stubs. - virtual void GenerateMethodStubs( - CORINFO_METHOD_HANDLE hMethod, - bool fNgenProfileImage, - CORCOMPILE_CompileStubCallback pfnCallback, - LPVOID pCallbackContext) = 0; - - // Determines whether or not a method is a dynamic method. This is used - // to prevent operations that may require metadata knowledge at times other - // than compile time. - virtual bool IsDynamicMethod(CORINFO_METHOD_HANDLE hMethod) = 0; - - // Set method profiling flags for layout of EE datastructures - virtual void SetMethodProfilingFlags(CORINFO_METHOD_HANDLE hMethod, DWORD flags) = 0; - - // Returns false if precompiled code must ensure that - // the EE's DoPrestub function gets run before the - // code for the method is used, i.e. if it returns false - // then an indirect call must be made. - // - // Returning true does not guaratee that a direct call can be made: - // there can be other reasons why the entry point cannot be embedded. - // - virtual bool CanSkipMethodPreparation ( - CORINFO_METHOD_HANDLE callerHnd, /* IN */ - CORINFO_METHOD_HANDLE calleeHnd, /* IN */ - CorInfoIndirectCallReason *pReason = NULL, - CORINFO_ACCESS_FLAGS accessFlags = CORINFO_ACCESS_ANY) = 0; - - virtual BOOL CanEmbedModuleHandle( - CORINFO_MODULE_HANDLE moduleHandle) = 0; - - // These check if we can hardbind to a handle. They guarantee either that - // the structure referred to by the handle is in a referenced zapped image - // or will be saved into the module currently being zapped. That is the - // corresponding GetLoaderModuleForEmeddableXYZ call will return - // either the module currently being zapped or a referenced zapped module. - virtual BOOL CanEmbedClassID(CORINFO_CLASS_HANDLE typeHandle) = 0; - virtual BOOL CanEmbedModuleID(CORINFO_MODULE_HANDLE moduleHandle) = 0; - virtual BOOL CanEmbedClassHandle(CORINFO_CLASS_HANDLE typeHandle) = 0; - virtual BOOL CanEmbedMethodHandle(CORINFO_METHOD_HANDLE methodHandle, CORINFO_METHOD_HANDLE contextHandle = NULL) = 0; - virtual BOOL CanEmbedFieldHandle(CORINFO_FIELD_HANDLE fieldHandle) = 0; - - // Return true if we can both embed a direct hardbind to the handle _and_ - // no "restore" action is needed on the handle. Equivalent to "CanEmbed + Prerestored". - // - // Typically a handle needs runtime restore it has embedded cross-module references - // or other data that cannot be persisted directly. - virtual BOOL CanPrerestoreEmbedClassHandle( - CORINFO_CLASS_HANDLE classHnd) = 0; - - // Return true if a method needs runtime restore - // This is only the case if it is instantiated and any of its type arguments need restoring. - virtual BOOL CanPrerestoreEmbedMethodHandle( - CORINFO_METHOD_HANDLE methodHnd) = 0; - - // Can a method entry point be embedded? - virtual BOOL CanEmbedFunctionEntryPoint( - CORINFO_METHOD_HANDLE methodHandle, - CORINFO_METHOD_HANDLE contextHandle = NULL, - CORINFO_ACCESS_FLAGS accessFlags = CORINFO_ACCESS_ANY - ) = 0; - - // Prestub is not able to handle method restore in all cases for generics. - // If it is the case the method has to be restored explicitly upfront. - // See the comment inside the implemenation method for more details. - virtual BOOL DoesMethodNeedRestoringBeforePrestubIsRun( - CORINFO_METHOD_HANDLE methodHandle - ) = 0; - - // Returns true if the given activation fixup is not necessary - virtual BOOL CanSkipDependencyActivation( - CORINFO_METHOD_HANDLE context, - CORINFO_MODULE_HANDLE moduleFrom, - CORINFO_MODULE_HANDLE moduleTo) = 0; - - virtual CORINFO_MODULE_HANDLE GetPreferredZapModuleForClassHandle( - CORINFO_CLASS_HANDLE classHnd - ) = 0; - - virtual void NoteDeduplicatedCode( - CORINFO_METHOD_HANDLE method, - CORINFO_METHOD_HANDLE duplicateMethod) = 0; - -#ifdef FEATURE_READYTORUN_COMPILER - // Returns a compressed encoding of the inline tracking map - // for this compilation - virtual void GetSerializedInlineTrackingMap( - IN OUT SBuffer * pSerializedInlineTrackingMap - ) = 0; -#endif - - // - // Release frees the preloader - // - - virtual ULONG Release() = 0; -}; - -// -// The DataImage provides several "sections", which can be used -// to sort data into different sets for locality control. The Arrange -// phase is responsible for placing items into sections. -// - -#define CORCOMPILE_SECTIONS() \ - CORCOMPILE_SECTION(MODULE) \ - CORCOMPILE_SECTION(WRITE) \ - CORCOMPILE_SECTION(METHOD_PRECODE_WRITE) \ - CORCOMPILE_SECTION(HOT_WRITEABLE) \ - CORCOMPILE_SECTION(WRITEABLE) \ - CORCOMPILE_SECTION(HOT) \ - CORCOMPILE_SECTION(METHOD_PRECODE_HOT) \ - CORCOMPILE_SECTION(RVA_STATICS_HOT) \ - CORCOMPILE_SECTION(RVA_STATICS_COLD) \ - CORCOMPILE_SECTION(WARM) \ - CORCOMPILE_SECTION(READONLY_SHARED_HOT) \ - CORCOMPILE_SECTION(READONLY_HOT) \ - CORCOMPILE_SECTION(READONLY_WARM) \ - CORCOMPILE_SECTION(READONLY_COLD) \ - CORCOMPILE_SECTION(READONLY_VCHUNKS_AND_DICTIONARY) \ - CORCOMPILE_SECTION(CLASS_COLD) \ - CORCOMPILE_SECTION(CROSS_DOMAIN_INFO) \ - CORCOMPILE_SECTION(METHOD_PRECODE_COLD) \ - CORCOMPILE_SECTION(METHOD_PRECODE_COLD_WRITEABLE) \ - CORCOMPILE_SECTION(METHOD_DESC_COLD) \ - CORCOMPILE_SECTION(METHOD_DESC_COLD_WRITEABLE) \ - CORCOMPILE_SECTION(MODULE_COLD) \ - CORCOMPILE_SECTION(DEBUG_COLD) \ - CORCOMPILE_SECTION(COMPRESSED_MAPS) \ - -enum CorCompileSection -{ -#define CORCOMPILE_SECTION(section) CORCOMPILE_SECTION_##section, - CORCOMPILE_SECTIONS() -#undef CORCOMPILE_SECTION - - CORCOMPILE_SECTION_COUNT -}; - -enum VerboseLevel -{ - CORCOMPILE_NO_LOG, - CORCOMPILE_STATS, - CORCOMPILE_VERBOSE -}; - -class ZapImage; - -// When NGEN install /Profile is run, the ZapProfilingHandleImport fixup table contains -// these 5 values per MethodDesc -enum -{ - kZapProfilingHandleImportValueIndexFixup = 0, - kZapProfilingHandleImportValueIndexEnterAddr = 1, - kZapProfilingHandleImportValueIndexLeaveAddr = 2, - kZapProfilingHandleImportValueIndexTailcallAddr = 3, - kZapProfilingHandleImportValueIndexClientData = 4, - - kZapProfilingHandleImportValueIndexCount -}; - -class ICorCompileDataStore -{ - public: - // Returns ZapImage - virtual ZapImage * GetZapImage() = 0; - - // Report an error during preloading: - // 'token' is the metadata token that triggered the error - // hr is the HRESULT from the thrown Exception, or S_OK if we don't have an thrown exception - // resID is the resourceID with additional information from the thrown Exception, or 0 - // - virtual void Error(mdToken token, HRESULT hr, UINT _resID, LPCWSTR description) = 0; -}; - - -class ICorCompilationDomain -{ - public: - - // Sets the application context for fusion - // to use when binding, using a shell exe file path - virtual HRESULT SetContextInfo( - LPCWSTR path, - BOOL isExe - ) = 0; - - // Retrieves the dependencies of the code which - // has been compiled - virtual HRESULT GetDependencies( - CORCOMPILE_DEPENDENCY **ppDependencies, - DWORD *cDependencies - ) = 0; - - -#ifdef CROSSGEN_COMPILE - virtual HRESULT SetPlatformWinmdPaths( - LPCWSTR pwzPlatformWinmdPaths - ) = 0; -#endif -}; - -/********************************************************************************* - * ICorCompileInfo is the interface for a compiler - *********************************************************************************/ -// Define function pointer ENCODEMODULE_CALLBACK -typedef DWORD (*ENCODEMODULE_CALLBACK)(LPVOID pModuleContext, CORINFO_MODULE_HANDLE moduleHandle); - -// Define function pointer DEFINETOKEN_CALLBACK -typedef void (*DEFINETOKEN_CALLBACK)(LPVOID pModuleContext, CORINFO_MODULE_HANDLE moduleHandle, DWORD index, mdTypeRef* token); - -typedef HRESULT (*CROSS_DOMAIN_CALLBACK)(LPVOID pArgs); - -class ICorCompileInfo -{ - public: - - - // - // Currently no other instance of the EE may be running inside - // a process that is used as an NGEN compilation process. - // - // So, the host must call StartupAsCompilationProcess before compiling - // any code, and Shutdown after finishing. - // - // The arguments control which native image of mscorlib to use. - // This matters for hardbinding. - // - - virtual HRESULT Startup( - BOOL fForceDebug, - BOOL fForceProfiling, - BOOL fForceInstrument) = 0; - - // Creates a new compilation domain - // The BOOL arguments control what kind of a native image is - // to be generated. Other factors affect what kind of a native image - // will actually be generated. GetAssemblyVersionInfo() ultimately reflects - // the kind of native image that will be generated - // - // pEmitter - sets this as the emitter to use when generating tokens for - // the dependency list. If this is NULL, dependencies won't be computed. - - virtual HRESULT CreateDomain( - ICorCompilationDomain **ppDomain, // [OUT] - IMetaDataAssemblyEmit *pEmitter, - BOOL fForceDebug, - BOOL fForceProfiling, - BOOL fForceInstrument - ) = 0; - - // calls pfnCallback in the specified domain - virtual HRESULT MakeCrossDomainCallback( - ICorCompilationDomain* pDomain, - CROSS_DOMAIN_CALLBACK pfnCallback, - LPVOID pArgs - ) = 0; - - // Destroys a compilation domain - virtual HRESULT DestroyDomain( - ICorCompilationDomain *pDomain - ) = 0; - - // Loads an assembly manifest module into the EE - // and returns a handle to it. - virtual HRESULT LoadAssemblyByPath( - LPCWSTR wzPath, - BOOL fExplicitBindToNativeImage, - CORINFO_ASSEMBLY_HANDLE *pHandle - ) = 0; - - -#ifdef FEATURE_COMINTEROP - // Loads a WinRT typeref into the EE and returns - // a handle to it. We have to load all typerefs - // during dependency computation since assemblyrefs - // are meaningless to WinRT. - virtual HRESULT LoadTypeRefWinRT( - IMDInternalImport *pAssemblyImport, - mdTypeRef ref, - CORINFO_ASSEMBLY_HANDLE *pHandle - ) = 0; -#endif - - virtual BOOL IsInCurrentVersionBubble(CORINFO_MODULE_HANDLE hModule) = 0; - - // Loads a module from an assembly into the EE - // and returns a handle to it. - virtual HRESULT LoadAssemblyModule( - CORINFO_ASSEMBLY_HANDLE assembly, - mdFile file, - CORINFO_MODULE_HANDLE *pHandle - ) = 0; - - - // Checks to see if an up to date zap exists for the - // assembly - virtual BOOL CheckAssemblyZap( - CORINFO_ASSEMBLY_HANDLE assembly, - __out_ecount_opt(*cAssemblyManifestModulePath) - LPWSTR assemblyManifestModulePath, - LPDWORD cAssemblyManifestModulePath - ) = 0; - - // Sets up the compilation target in the EE - virtual HRESULT SetCompilationTarget( - CORINFO_ASSEMBLY_HANDLE assembly, - CORINFO_MODULE_HANDLE module - ) = 0; - - - // Returns the dependency load setting for an assembly ref - virtual HRESULT GetLoadHint( - CORINFO_ASSEMBLY_HANDLE hAssembly, - CORINFO_ASSEMBLY_HANDLE hAssemblyDependency, - LoadHintEnum *loadHint, - LoadHintEnum *defaultLoadHint = NULL - ) = 0; - - // Returns information on how the assembly has been loaded - virtual HRESULT GetAssemblyVersionInfo( - CORINFO_ASSEMBLY_HANDLE hAssembly, - CORCOMPILE_VERSION_INFO *pInfo - ) = 0; - - // Returns the manifest metadata for an assembly - // Use the internal IMDInternalImport for performance. - // Creation of the public IMetaDataImport * triggers - // conversion to R/W metadata that slows down all subsequent accesses. - virtual IMDInternalImport * GetAssemblyMetaDataImport( - CORINFO_ASSEMBLY_HANDLE assembly - ) = 0; - - // Returns an interface to query the metadata for a loaded module - // Use the internal IMDInternalImport for performance. - // Creation of the public IMetaDataAssemblyImport * triggers - // conversion to R/W metadata that slows down all subsequent accesses. - virtual IMDInternalImport * GetModuleMetaDataImport( - CORINFO_MODULE_HANDLE module - ) = 0; - - // Returns the module of the assembly which contains the manifest, - // or NULL if the manifest is standalone. - virtual CORINFO_MODULE_HANDLE GetAssemblyModule( - CORINFO_ASSEMBLY_HANDLE assembly - ) = 0; - - // Returns the assembly of a loaded module - virtual CORINFO_ASSEMBLY_HANDLE GetModuleAssembly( - CORINFO_MODULE_HANDLE module - ) = 0; - - // Returns the current PEDecoder of a loaded module. - virtual PEDecoder * GetModuleDecoder( - CORINFO_MODULE_HANDLE module - ) = 0; - - // Gets the full file name, including path, of a loaded module - virtual void GetModuleFileName( - CORINFO_MODULE_HANDLE module, - SString &result - ) = 0; - - // Get a class def token - virtual HRESULT GetTypeDef( - CORINFO_CLASS_HANDLE classHandle, - mdTypeDef *token - ) = 0; - - // Get a method def token - virtual HRESULT GetMethodDef( - CORINFO_METHOD_HANDLE methodHandle, - mdMethodDef *token - ) = 0; - - // Get a field def token - virtual HRESULT GetFieldDef( - CORINFO_FIELD_HANDLE fieldHandle, - mdFieldDef *token - ) = 0; - - // Get the loader module for mscorlib - virtual CORINFO_MODULE_HANDLE GetLoaderModuleForMscorlib() = 0; - - // Get the loader module for a type (where the type is regarded as - // living for the purposes of loading, unloading, and ngen). - // - // classHandle must have passed CanEmbedClassHandle, since the zapper - // should only care about the module where a type - // prefers to be saved if it knows that that module is either - // an zapped module or is the module currently being compiled. - // See vm\ceeload.h for more information - virtual CORINFO_MODULE_HANDLE GetLoaderModuleForEmbeddableType( - CORINFO_CLASS_HANDLE classHandle - ) = 0; - - // Get the loader module for a method (where the method is regarded as - // living for the purposes of loading, unloading, and ngen) - // - // methodHandle must have passed CanEmbedMethodHandle, since the zapper - // should only care about the module where a type - // prefers to be saved if it knows that that module is either - // an zapped module or is the module currently being compiled. - // See vm\ceeload.h for more information - virtual CORINFO_MODULE_HANDLE GetLoaderModuleForEmbeddableMethod( - CORINFO_METHOD_HANDLE methodHandle - ) = 0; - - // Get the loader module for a method (where the method is regarded as - // living for the purposes of loading, unloading, and ngen) - // See vm\ceeload.h for more information - virtual CORINFO_MODULE_HANDLE GetLoaderModuleForEmbeddableField( - CORINFO_FIELD_HANDLE fieldHandle - ) = 0; - - // Set the list of assemblies we can hard bind to - virtual void SetAssemblyHardBindList( - __in_ecount(cHardBindList) - LPWSTR * pHardBindList, - DWORD cHardBindList - ) = 0; - - // Encode a module for the imports table - virtual void EncodeModuleAsIndexes( - CORINFO_MODULE_HANDLE fromHandle, - CORINFO_MODULE_HANDLE handle, - DWORD *pAssemblyIndex, - DWORD *pModuleIndex, - IMetaDataAssemblyEmit *pAssemblyEmit) = 0; - - - // Encode a class into the given SigBuilder. - virtual void EncodeClass( - CORINFO_MODULE_HANDLE referencingModule, - CORINFO_CLASS_HANDLE classHandle, - SigBuilder * pSigBuilder, - LPVOID encodeContext, - ENCODEMODULE_CALLBACK pfnEncodeModule) = 0; - - // Encode a method into the given SigBuilder. - virtual void EncodeMethod( - CORINFO_MODULE_HANDLE referencingModule, - CORINFO_METHOD_HANDLE handle, - SigBuilder * pSigBuilder, - LPVOID encodeContext, - ENCODEMODULE_CALLBACK pfnEncodeModule, - CORINFO_RESOLVED_TOKEN * pResolvedToken = NULL, - CORINFO_RESOLVED_TOKEN * pConstrainedResolvedToken = NULL, - BOOL fEncodeUsingResolvedTokenSpecStreams = FALSE) = 0; - - // Returns non-null methoddef or memberref token if it is sufficient to encode the method (no generic instantiations, etc.) - virtual mdToken TryEncodeMethodAsToken( - CORINFO_METHOD_HANDLE handle, - CORINFO_RESOLVED_TOKEN * pResolvedToken, - CORINFO_MODULE_HANDLE * referencingModule) = 0; - - // Returns method slot (for encoding virtual stub dispatch) - virtual DWORD TryEncodeMethodSlot( - CORINFO_METHOD_HANDLE handle) = 0; - - // Encode a field into the given SigBuilder. - virtual void EncodeField( - CORINFO_MODULE_HANDLE referencingModule, - CORINFO_FIELD_HANDLE handle, - SigBuilder * pSigBuilder, - LPVOID encodeContext, - ENCODEMODULE_CALLBACK pfnEncodeModule, - CORINFO_RESOLVED_TOKEN * pResolvedToken = NULL, - BOOL fEncodeUsingResolvedTokenSpecStreams = FALSE) = 0; - - - // Encode generic dictionary signature - virtual void EncodeGenericSignature( - LPVOID signature, - BOOL fMethod, - SigBuilder * pSigBuilder, - LPVOID encodeContext, - ENCODEMODULE_CALLBACK pfnEncodeModule) = 0; - - - virtual BOOL IsEmptyString( - mdString token, - CORINFO_MODULE_HANDLE module) = 0; - - - // Preload a modules' EE data structures - // directly into an executable image - - virtual ICorCompilePreloader * PreloadModule( - CORINFO_MODULE_HANDLE moduleHandle, - ICorCompileDataStore *pData, - CorProfileData *profileData - ) = 0; - - // Gets the codebase URL for the assembly - virtual void GetAssemblyCodeBase( - CORINFO_ASSEMBLY_HANDLE hAssembly, - SString &result) = 0; - - // Returns the GC-information for a method. This is the simple representation - // and can be used when a code that can trigger a GC does not have access - // to the CORINFO_METHOD_HANDLE (which is normally used to access the GC information) - // - // Returns S_FALSE if there is no simple representation for the method's GC info - // - virtual void GetCallRefMap( - CORINFO_METHOD_HANDLE hMethod, - GCRefMapBuilder * pBuilder) = 0; - - // Returns a compressed block of debug information - // - // Uncompressed debug maps are passed in. - // Writes to outgoing SBuffer. - // Throws on failure. - virtual void CompressDebugInfo( - IN ICorDebugInfo::OffsetMapping * pOffsetMapping, - IN ULONG iOffsetMapping, - IN ICorDebugInfo::NativeVarInfo * pNativeVarInfo, - IN ULONG iNativeVarInfo, - IN OUT SBuffer * pDebugInfoBuffer - ) = 0; - - - - // Allows to set verbose level for log messages, enabled in retail build too for stats - virtual HRESULT SetVerboseLevel( - IN VerboseLevel level) = 0; - - // Get the compilation flags that are shared between JIT and NGen - virtual HRESULT GetBaseJitFlags( - IN CORINFO_METHOD_HANDLE hMethod, - OUT CORJIT_FLAGS *pFlags) = 0; - - // needed for stubs to obtain the number of bytes to copy into the native image - // return the beginning of the stub and the size to copy (in bytes) - virtual void* GetStubSize(void *pStubAddress, DWORD *pSizeToCopy) = 0; - - // Takes a stub and blits it into the buffer, resetting the reference count - // to 1 on the clone. The buffer has to be large enough to hold the stub object and the code - virtual HRESULT GetStubClone(void *pStub, BYTE *pBuffer, DWORD dwBufferSize) = 0; - - // true if the method has [NativeCallableAttribute] - virtual BOOL IsNativeCallableMethod(CORINFO_METHOD_HANDLE handle) = 0; - - virtual BOOL GetIsGeneratingNgenPDB() = 0; - virtual void SetIsGeneratingNgenPDB(BOOL fGeneratingNgenPDB) = 0; - -#ifdef FEATURE_READYTORUN_COMPILER - virtual CORCOMPILE_FIXUP_BLOB_KIND GetFieldBaseOffset( - CORINFO_CLASS_HANDLE classHnd, - DWORD * pBaseOffset - ) = 0; - - virtual BOOL NeedsTypeLayoutCheck(CORINFO_CLASS_HANDLE classHnd) = 0; - virtual void EncodeTypeLayout(CORINFO_CLASS_HANDLE classHandle, SigBuilder * pSigBuilder) = 0; - - virtual BOOL AreAllClassesFullyLoaded(CORINFO_MODULE_HANDLE moduleHandle) = 0; - - virtual int GetVersionResilientTypeHashCode(CORINFO_MODULE_HANDLE moduleHandle, mdToken token) = 0; - - virtual int GetVersionResilientMethodHashCode(CORINFO_METHOD_HANDLE methodHandle) = 0; -#endif - - virtual BOOL HasCustomAttribute(CORINFO_METHOD_HANDLE method, LPCSTR customAttributeName) = 0; -}; - -/*****************************************************************************/ -// This function determines the compile flags to use for a generic intatiation -// since only the open instantiation can be verified. -// See the comment associated with CORJIT_FLAG_SKIP_VERIFICATION for details. -// -// On return: -// if *raiseVerificationException=TRUE, the caller should raise a VerificationException. -// if *unverifiableGenericCode=TRUE, the method is a generic instantiation with -// unverifiable code - -CORJIT_FLAGS GetCompileFlagsIfGenericInstantiation( - CORINFO_METHOD_HANDLE method, - CORJIT_FLAGS compileFlags, - ICorJitInfo * pCorJitInfo, - BOOL * raiseVerificationException, - BOOL * unverifiableGenericCode); - -// Returns the global instance of JIT->EE interface for NGen - -extern "C" ICorDynamicInfo * __stdcall GetZapJitInfo(); - -// Returns the global instance of Zapper->EE interface - -extern "C" ICorCompileInfo * __stdcall GetCompileInfo(); - -// Stress mode to leave some methods/types uncompiled in the ngen image. -// Those methods will be JIT-compiled at runtime as needed. - -extern "C" unsigned __stdcall PartialNGenStressPercentage(); - -// create a PDB dumping all functions in hAssembly into pdbPath -extern "C" HRESULT __stdcall CreatePdb(CORINFO_ASSEMBLY_HANDLE hAssembly, BSTR pNativeImagePath, BSTR pPdbPath, BOOL pdbLines, BSTR pManagedPdbSearchPath, LPCWSTR pDiasymreaderPath); - -extern bool g_fNGenMissingDependenciesOk; - -extern bool g_fNGenWinMDResilient; - -#ifdef FEATURE_READYTORUN_COMPILER -extern bool g_fReadyToRunCompilation; -#endif - -inline bool IsReadyToRunCompilation() -{ -#ifdef FEATURE_READYTORUN_COMPILER - return g_fReadyToRunCompilation; -#else - return false; -#endif -} - -#endif /* COR_COMPILE_H_ */ diff --git a/src/inc/cordbpriv.h b/src/inc/cordbpriv.h deleted file mode 100644 index 30231d378..000000000 --- a/src/inc/cordbpriv.h +++ /dev/null @@ -1,68 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/* ------------------------------------------------------------------------- * - * cordbpriv.h -- header file for private Debugger data shared by various - * Runtime components. - * ------------------------------------------------------------------------- */ - -#ifndef _cordbpriv_h_ -#define _cordbpriv_h_ - -#include "corhdr.h" -#include - -// -// Initial value for EnC versions -// -#define CorDB_DEFAULT_ENC_FUNCTION_VERSION 1 -#define CorDB_UNKNOWN_ENC_FUNCTION_VERSION ((SIZE_T)(-1)) - -enum DebuggerLaunchSetting -{ - DLS_ASK_USER = 0, - DLS_ATTACH_DEBUGGER = 1 -}; - - -// -// Flags used to control the Runtime's debugging modes. These indicate to -// the Runtime that it needs to load the Runtime Controller, track data -// during JIT's, etc. -// -enum DebuggerControlFlag -{ - DBCF_NORMAL_OPERATION = 0x0000, - - DBCF_USER_MASK = 0x00FF, - DBCF_GENERATE_DEBUG_CODE = 0x0001, - DBCF_ALLOW_JIT_OPT = 0x0008, - DBCF_PROFILER_ENABLED = 0x0020, -// DBCF_ACTIVATE_REMOTE_DEBUGGING = 0x0040, Deprecated. DO NOT USE - - DBCF_INTERNAL_MASK = 0xFF00, - DBCF_PENDING_ATTACH = 0x0100, - DBCF_ATTACHED = 0x0200, - DBCF_FIBERMODE = 0x0400 -}; - -// -// Flags used to control the debuggable state of modules and -// assemblies. -// -enum DebuggerAssemblyControlFlags -{ - DACF_NONE = 0x00, - DACF_USER_OVERRIDE = 0x01, - DACF_ALLOW_JIT_OPTS = 0x02, - DACF_OBSOLETE_TRACK_JIT_INFO = 0x04, // obsolete in V2.0, we're always tracking. - DACF_ENC_ENABLED = 0x08, - DACF_IGNORE_PDBS = 0x20, - DACF_CONTROL_FLAGS_MASK = 0x2F, - - DACF_PDBS_COPIED = 0x10, - DACF_MISC_FLAGS_MASK = 0x10, -}; - -#endif /* _cordbpriv_h_ */ diff --git a/src/inc/cordebuginfo.h b/src/inc/cordebuginfo.h deleted file mode 100644 index b065c5fc0..000000000 --- a/src/inc/cordebuginfo.h +++ /dev/null @@ -1,323 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/**********************************************************************************/ -// DebugInfo types shared by JIT-EE interface and EE-Debugger interface - -class ICorDebugInfo -{ -public: - /*----------------------------- Boundary-info ---------------------------*/ - - enum MappingTypes - { - NO_MAPPING = -1, - PROLOG = -2, - EPILOG = -3, - MAX_MAPPING_VALUE = -3 // Sentinal value. This should be set to the largest magnitude value in the enum - // so that the compression routines know the enum's range. - }; - - enum BoundaryTypes - { - NO_BOUNDARIES = 0x00, // No implicit boundaries - STACK_EMPTY_BOUNDARIES = 0x01, // Boundary whenever the IL evaluation stack is empty - NOP_BOUNDARIES = 0x02, // Before every CEE_NOP instruction - CALL_SITE_BOUNDARIES = 0x04, // Before every CEE_CALL, CEE_CALLVIRT, etc instruction - - // Set of boundaries that debugger should always reasonably ask the JIT for. - DEFAULT_BOUNDARIES = STACK_EMPTY_BOUNDARIES | NOP_BOUNDARIES | CALL_SITE_BOUNDARIES - }; - - // Note that SourceTypes can be OR'd together - it's possible that - // a sequence point will also be a stack_empty point, and/or a call site. - // The debugger will check to see if a boundary offset's source field & - // SEQUENCE_POINT is true to determine if the boundary is a sequence point. - - enum SourceTypes - { - SOURCE_TYPE_INVALID = 0x00, // To indicate that nothing else applies - SEQUENCE_POINT = 0x01, // The debugger asked for it. - STACK_EMPTY = 0x02, // The stack is empty here - CALL_SITE = 0x04, // This is a call site. - NATIVE_END_OFFSET_UNKNOWN = 0x08, // Indicates a epilog endpoint - CALL_INSTRUCTION = 0x10 // The actual instruction of a call. - - }; - - struct OffsetMapping - { - DWORD nativeOffset; - DWORD ilOffset; - SourceTypes source; // The debugger needs this so that - // we don't put Edit and Continue breakpoints where - // the stack isn't empty. We can put regular breakpoints - // there, though, so we need a way to discriminate - // between offsets. - }; - - /*------------------------------ Var-info -------------------------------*/ - - // Note: The debugger needs to target register numbers on platforms other than which the debugger itself - // is running. To this end it maintains its own values for REGNUM_SP and REGNUM_AMBIENT_SP across multiple - // platforms. So any change here that may effect these values should be reflected in the definitions - // contained in debug/inc/DbgIPCEvents.h. - enum RegNum - { -#ifdef _TARGET_X86_ - REGNUM_EAX, - REGNUM_ECX, - REGNUM_EDX, - REGNUM_EBX, - REGNUM_ESP, - REGNUM_EBP, - REGNUM_ESI, - REGNUM_EDI, -#elif _TARGET_ARM_ - REGNUM_R0, - REGNUM_R1, - REGNUM_R2, - REGNUM_R3, - REGNUM_R4, - REGNUM_R5, - REGNUM_R6, - REGNUM_R7, - REGNUM_R8, - REGNUM_R9, - REGNUM_R10, - REGNUM_R11, - REGNUM_R12, - REGNUM_SP, - REGNUM_LR, - REGNUM_PC, -#elif _TARGET_ARM64_ - REGNUM_X0, - REGNUM_X1, - REGNUM_X2, - REGNUM_X3, - REGNUM_X4, - REGNUM_X5, - REGNUM_X6, - REGNUM_X7, - REGNUM_X8, - REGNUM_X9, - REGNUM_X10, - REGNUM_X11, - REGNUM_X12, - REGNUM_X13, - REGNUM_X14, - REGNUM_X15, - REGNUM_X16, - REGNUM_X17, - REGNUM_X18, - REGNUM_X19, - REGNUM_X20, - REGNUM_X21, - REGNUM_X22, - REGNUM_X23, - REGNUM_X24, - REGNUM_X25, - REGNUM_X26, - REGNUM_X27, - REGNUM_X28, - REGNUM_FP, - REGNUM_LR, - REGNUM_SP, - REGNUM_PC, -#elif _TARGET_AMD64_ - REGNUM_RAX, - REGNUM_RCX, - REGNUM_RDX, - REGNUM_RBX, - REGNUM_RSP, - REGNUM_RBP, - REGNUM_RSI, - REGNUM_RDI, - REGNUM_R8, - REGNUM_R9, - REGNUM_R10, - REGNUM_R11, - REGNUM_R12, - REGNUM_R13, - REGNUM_R14, - REGNUM_R15, -#else - PORTABILITY_WARNING("Register numbers not defined on this platform") -#endif - REGNUM_COUNT, - REGNUM_AMBIENT_SP, // ambient SP support. Ambient SP is the original SP in the non-BP based frame. - // Ambient SP should not change even if there are push/pop operations in the method. - -#ifdef _TARGET_X86_ - REGNUM_FP = REGNUM_EBP, - REGNUM_SP = REGNUM_ESP, -#elif _TARGET_AMD64_ - REGNUM_SP = REGNUM_RSP, -#elif _TARGET_ARM_ -#ifdef REDHAWK - REGNUM_FP = REGNUM_R7, -#else - REGNUM_FP = REGNUM_R11, -#endif //REDHAWK -#elif _TARGET_ARM64_ - //Nothing to do here. FP is already alloted. -#else - // RegNum values should be properly defined for this platform - REGNUM_FP = 0, - REGNUM_SP = 1, -#endif - - }; - - // VarLoc describes the location of a native variable. Note that currently, VLT_REG_BYREF and VLT_STK_BYREF - // are only used for value types on X64. - - enum VarLocType - { - VLT_REG, // variable is in a register - VLT_REG_BYREF, // address of the variable is in a register - VLT_REG_FP, // variable is in an fp register - VLT_STK, // variable is on the stack (memory addressed relative to the frame-pointer) - VLT_STK_BYREF, // address of the variable is on the stack (memory addressed relative to the frame-pointer) - VLT_REG_REG, // variable lives in two registers - VLT_REG_STK, // variable lives partly in a register and partly on the stack - VLT_STK_REG, // reverse of VLT_REG_STK - VLT_STK2, // variable lives in two slots on the stack - VLT_FPSTK, // variable lives on the floating-point stack - VLT_FIXED_VA, // variable is a fixed argument in a varargs function (relative to VARARGS_HANDLE) - - VLT_COUNT, - VLT_INVALID, - }; - - struct VarLoc - { - VarLocType vlType; - - union - { - // VLT_REG/VLT_REG_FP -- Any pointer-sized enregistered value (TYP_INT, TYP_REF, etc) - // eg. EAX - // VLT_REG_BYREF -- the specified register contains the address of the variable - // eg. [EAX] - - struct - { - RegNum vlrReg; - } vlReg; - - // VLT_STK -- Any 32 bit value which is on the stack - // eg. [ESP+0x20], or [EBP-0x28] - // VLT_STK_BYREF -- the specified stack location contains the address of the variable - // eg. mov EAX, [ESP+0x20]; [EAX] - - struct - { - RegNum vlsBaseReg; - signed vlsOffset; - } vlStk; - - // VLT_REG_REG -- TYP_LONG with both DWords enregistred - // eg. RBM_EAXEDX - - struct - { - RegNum vlrrReg1; - RegNum vlrrReg2; - } vlRegReg; - - // VLT_REG_STK -- Partly enregistered TYP_LONG - // eg { LowerDWord=EAX UpperDWord=[ESP+0x8] } - - struct - { - RegNum vlrsReg; - struct - { - RegNum vlrssBaseReg; - signed vlrssOffset; - } vlrsStk; - } vlRegStk; - - // VLT_STK_REG -- Partly enregistered TYP_LONG - // eg { LowerDWord=[ESP+0x8] UpperDWord=EAX } - - struct - { - struct - { - RegNum vlsrsBaseReg; - signed vlsrsOffset; - } vlsrStk; - RegNum vlsrReg; - } vlStkReg; - - // VLT_STK2 -- Any 64 bit value which is on the stack, - // in 2 successsive DWords. - // eg 2 DWords at [ESP+0x10] - - struct - { - RegNum vls2BaseReg; - signed vls2Offset; - } vlStk2; - - // VLT_FPSTK -- enregisterd TYP_DOUBLE (on the FP stack) - // eg. ST(3). Actually it is ST("FPstkHeigth - vpFpStk") - - struct - { - unsigned vlfReg; - } vlFPstk; - - // VLT_FIXED_VA -- fixed argument of a varargs function. - // The argument location depends on the size of the variable - // arguments (...). Inspecting the VARARGS_HANDLE indicates the - // location of the first arg. This argument can then be accessed - // relative to the position of the first arg - - struct - { - unsigned vlfvOffset; - } vlFixedVarArg; - - // VLT_MEMORY - - struct - { - void *rpValue; // pointer to the in-process - // location of the value. - } vlMemory; - }; - }; - - // This is used to report implicit/hidden arguments - - enum - { - VARARGS_HND_ILNUM = -1, // Value for the CORINFO_VARARGS_HANDLE varNumber - RETBUF_ILNUM = -2, // Pointer to the return-buffer - TYPECTXT_ILNUM = -3, // ParamTypeArg for CORINFO_GENERICS_CTXT_FROM_PARAMTYPEARG - - UNKNOWN_ILNUM = -4, // Unknown variable - - MAX_ILNUM = -4 // Sentinal value. This should be set to the largest magnitude value in th enum - // so that the compression routines know the enum's range. - }; - - struct ILVarInfo - { - DWORD startOffset; - DWORD endOffset; - DWORD varNumber; - }; - - struct NativeVarInfo - { - DWORD startOffset; - DWORD endOffset; - DWORD varNumber; - VarLoc loc; - }; -}; diff --git a/src/inc/coreclrhost.h b/src/inc/coreclrhost.h new file mode 100644 index 000000000..dd11cb6a5 --- /dev/null +++ b/src/inc/coreclrhost.h @@ -0,0 +1,55 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +// +// APIs for hosting CoreCLR +// + +#ifndef __CORECLR_HOST_H__ +#define __CORECLR_HOST_H__ + +// For each hosting API, we define a function prototype and a function pointer +// The prototype is useful for implicit linking against the dynamic coreclr +// library and the pointer for explicit dynamic loading (dlopen, LoadLibrary) +#define CORECLR_HOSTING_API(function, ...) \ + extern "C" int function(__VA_ARGS__); \ + typedef int (*function##_ptr)(__VA_ARGS__) + +CORECLR_HOSTING_API(coreclr_initialize, + const char* exePath, + const char* appDomainFriendlyName, + int propertyCount, + const char** propertyKeys, + const char** propertyValues, + void** hostHandle, + unsigned int* domainId); + +CORECLR_HOSTING_API(coreclr_shutdown, + void* hostHandle, + unsigned int domainId); + +CORECLR_HOSTING_API(coreclr_shutdown_2, + void* hostHandle, + unsigned int domainId, + int* latchedExitCode); + +CORECLR_HOSTING_API(coreclr_create_delegate, + void* hostHandle, + unsigned int domainId, + const char* entryPointAssemblyName, + const char* entryPointTypeName, + const char* entryPointMethodName, + void** delegate); + +CORECLR_HOSTING_API(coreclr_execute_assembly, + void* hostHandle, + unsigned int domainId, + int argc, + const char** argv, + const char* managedAssemblyPath, + unsigned int* exitCode); + +#undef CORECLR_HOSTING_API + +#endif // __CORECLR_HOST_H__ diff --git a/src/inc/coredistools.h b/src/inc/coredistools.h deleted file mode 100644 index 54146058e..000000000 --- a/src/inc/coredistools.h +++ /dev/null @@ -1,149 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -//===--------- coredistools.h - Dissassembly tools for CoreClr ------------===// -// -// Core Disassembly Tools API Version 1.0.1-prerelease -// Disassembly tools required by CoreCLR for utilities like -// GCStress and SuperPMI -//===----------------------------------------------------------------------===// - -#if !defined(_COREDISTOOLS_H_) -#define _COREDISTOOLS_H_ - -#include - -#if defined(__cplusplus) -#define EXTERN_C extern "C" -#else -#define EXTERN_C -#endif // defined(__cplusplus) - -#if defined(_MSC_VER) -#if defined(DllInterfaceExporter) -#define DllIface EXTERN_C __declspec(dllexport) -#else -#define DllIface EXTERN_C __declspec(dllimport) -#endif // defined(DllInterfaceExporter) -#else -#if !defined(__cdecl) -#if defined(__i386__) -#define __cdecl __attribute__((cdecl)) -#else -#define __cdecl -#endif -#endif -#define DllIface EXTERN_C -#endif // defined(_MSC_VER) - -enum TargetArch { - Target_Host, // Target is the same as host architecture - Target_X86, - Target_X64, - Target_Thumb, - Target_Arm64 -}; - -struct CorDisasm; -struct CorAsmDiff; - -// The custom print functionality to be provide by the -// users of this Library -typedef void(__cdecl *Printer)(const char *msg, ...); -struct PrintControl { - const Printer Error; - const Printer Warning; - const Printer Log; - const Printer Dump; -}; - -// The type of a custom function provided by the user to determine -// if two offsets are considered equivalent wrt diffing code blocks. -// Offset1 and Offset2 are the two offsets to be compared. -// BlockOffset is the offest of the instructions (that contain Offset1 -// and Offset2) from the beginning of their respective code blocks. -// InstructionLength is the length of the current instruction being -// compared for equivalency. -typedef bool(__cdecl *OffsetComparator)(const void *UserData, size_t BlockOffset, - size_t InstructionLength, uint64_t Offset1, - uint64_t Offset2); - -// The Export/Import definitions for CoreDistools library are defined below. -// A typedef for each interface function's type is defined in order to aid -// the importer. - -// Initialize the disassembler, using default print controls -typedef CorDisasm * __cdecl InitDisasm_t(enum TargetArch Target); -DllIface InitDisasm_t InitDisasm; - -// Initialize the disassembler using custom print controls -typedef CorDisasm * __cdecl NewDisasm_t(enum TargetArch Target, - const PrintControl *PControl); -DllIface NewDisasm_t NewDisasm; - -// Delete the disassembler -typedef void __cdecl FinishDisasm_t(const CorDisasm *Disasm); -DllIface FinishDisasm_t FinishDisasm; - -// DisasmInstruction -- Disassemble one instruction -// Arguments: -// Disasm -- The Disassembler -// Address -- The address at which the bytes of the instruction -// are intended to execute -// Bytes -- Pointer to the actual bytes which need to be disassembled -// MaxLength -- Number of bytes available in Bytes buffer -// Returns: -// -- The Size of the disassembled instruction -// -- Zero on failure -typedef size_t __cdecl DisasmInstruction_t(const CorDisasm *Disasm, - const uint8_t *Address, - const uint8_t *Bytes, size_t Maxlength); -DllIface DisasmInstruction_t DisasmInstruction; - -// Initialize the Code Differ -typedef CorAsmDiff * __cdecl NewDiffer_t(enum TargetArch Target, - const PrintControl *PControl, - const OffsetComparator Comparator); -DllIface NewDiffer_t NewDiffer; - -// Delete the Code Differ -typedef void __cdecl FinishDiff_t(const CorAsmDiff *AsmDiff); -DllIface FinishDiff_t FinishDiff; - -// NearDiffCodeBlocks -- Compare two code blocks for semantic -// equivalence -// Arguments: -// AsmDiff -- The Asm-differ -// UserData -- Any data the user wishes to pass through into -// the OffsetComparator -// Address1 -- Address at which first block will execute -// Bytes1 -- Pointer to the actual bytes of the first block -// Size1 -- The size of the first block -// Address2 -- Address at which second block will execute -// Bytes2 -- Pointer to the actual bytes of the second block -// Size2 -- The size of the second block -// Returns: -// -- true if the two blocks are equivalent, false if not. -typedef bool __cdecl NearDiffCodeBlocks_t(const CorAsmDiff *AsmDiff, - const void *UserData, - const uint8_t *Address1, - const uint8_t *Bytes1, size_t Size1, - const uint8_t *Address2, - const uint8_t *Bytes2, size_t Size2); -DllIface NearDiffCodeBlocks_t NearDiffCodeBlocks; - -// Print a code block according to the Disassembler's Print Controls -typedef void __cdecl DumpCodeBlock_t(const CorDisasm *Disasm, const uint8_t *Address, - const uint8_t *Bytes, size_t Size); -DllIface DumpCodeBlock_t DumpCodeBlock; - -// Print the two code blocks being diffed, according to -// AsmDiff's PrintControls. -typedef void __cdecl DumpDiffBlocks_t(const CorAsmDiff *AsmDiff, - const uint8_t *Address1, const uint8_t *Bytes1, - size_t Size1, const uint8_t *Address2, - const uint8_t *Bytes2, size_t Size2); -DllIface DumpDiffBlocks_t DumpDiffBlocks; - -#endif // !defined(_COREDISTOOLS_H_) diff --git a/src/inc/coregen.h b/src/inc/coregen.h deleted file mode 100644 index f8d07a57a..000000000 --- a/src/inc/coregen.h +++ /dev/null @@ -1,23 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -// -// ngencommon.h - cross-compilation enablement structures. -// - - - -#ifndef _NGENCOMMON_H_ -#define _NGENCOMMON_H_ - -#define NGENWORKER_FLAGS_TUNING 0x0001 - -#define NGENWORKER_FLAGS_MISSINGDEPENDENCIESOK 0x0004 - -#define NGENWORKER_FLAGS_WINMD_RESILIENT 0x1000 -#define NGENWORKER_FLAGS_READYTORUN 0x2000 -#define NGENWORKER_FLAGS_NO_METADATA 0x4000 -#define NGENWORKER_FLAGS_SILENT 0x8000 -#define NGENWORKER_FLAGS_VERBOSE 0x10000 - -#endif // _NGENCOMMON_H_ diff --git a/src/inc/corerror.xml b/src/inc/corerror.xml deleted file mode 100644 index a859cfac5..000000000 --- a/src/inc/corerror.xml +++ /dev/null @@ -1,6993 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - CLDB_S_TRUNCATION - STATUS: Data value was truncated. - - - - CLDB_S_NULL - NULL data value. - - - - CLDB_S_INDEX_TABLESCANREQUIRED - Table scan required to run query. - - - - TLBX_I_TYPEINFO_IMPORTED - Typelib import: progress report. - - - - TLBX_I_PIA_REGISTERED_FOR_TLB - Primary interop assembly '{0}' is already registered for type library '{1}'. - - - - TLBX_I_AGNOSTIC_ASSEMBLY - Importing a type library into a platform agnostic assembly. This can cause errors if the type library is not truly platform agnostic. - - - - TLBX_I_USEIUNKNOWN - Typelib export: substituted IUnknown for type. - - - - TLBX_I_UNCONVERTABLE_ARGS - Typelib import: signature can't be converted (eg, struct**) - - - - TLBX_I_UNCONVERTABLE_FIELD - Typelib import: signature can't be converted (eg, struct**) - - - - TLBX_W_WARNING_MESSAGE - Typelib export: Warning message wrapper. - - - - TLBX_W_ASSEMBLY_HAS_EMBEDDED_TLB - Type library is being exported for assembly '{0}' which already contains an embedded type library - - - - TLBX_W_CROSS_COMPILE_NO_REFS - When cross-compiling, all type library references should be included on the command line to ensure the correct bit-specific type libraries are loaded. - - - - TLBX_W_PURE_CROSS_COMPILE - Performing cross-compile of 32-bit non-agnostic assembly to 64-bit type library or 64-bit non-agnostic assembly to 32-bit type library. This is dangerous as pointer sizes and processor dependence will likely cause incompatibility between the assembly and resultant type library. - - - - TLBX_I_TYPE_EXPORTED - Typelib export: type exported - - - - TLBX_I_DUPLICATE_DISPID - Typelib export: duplicate dispid -- auto corrected. - - - - TLBX_I_REF_TYPE_AS_STRUCT - Typelib export: reference type had layout, exported as struct. - - - - TLBX_I_GENERIC_TYPE - TypeLib export: generic type definition - - - - TLBX_W_NON_INTEGRAL_CA_TYPE - TypeLib import: Ignoring IDL custom attribute -- does not have an integral value. - - - - TLBX_W_IENUM_CA_ON_IUNK - TypeLib import: Ignoring IDL custom attribute -- using IEnum CA on an IUnknown derived interface. - - - - META_S_PARAM_MISMATCH - Merge: Parameter information mismatched. - - - - META_S_DUPLICATE - Attempt to define an object that already exists in valid scenerios. - - - - TLBX_S_REFERENCED_TYPELIB - TypeLib import: reference to an external typelib. - - - - TLBX_S_NOSTDINTERFACE - Typelib export: Found an interface marked as IID_IDispatch or IID_IUnknown. - - - - TLBX_S_DUPLICATE_DISPID - Typelib export: duplicate dispid found; ignored. - - - - TLBX_W_ENUM_VALUE_TOOBIG - Typelib export: The enum value is not legal for a typelib. - - - - TLBX_W_EXPORTING_AUTO_LAYOUT - TypeLib export: Exporting an auto-layout type. - - - - TLBX_W_DEFAULT_INTF_NOT_VISIBLE - TypeLib export: ComDefaultInterface is not COMVisible. - - - - TLBX_W_BAD_SAFEARRAYFIELD_NO_ELEMENTVT - TypeLib export: System.Array SAFEARRAY field without a SafeArraySubType. - - - - TLBX_W_LAYOUTCLASS_AS_INTERFACE - TypeLib export: Class with layout parameter of field marked with UnmanagedType.Interface - - - - TLBX_I_GENERIC_BASE_TYPE - TypeLib export: type deriving from a generic type. - - - - VLDTR_S_WRN - Warnings found in the validator. - - - - VLDTR_S_ERR - Errors found in the validator. - - - - VLDTR_S_WRNERR - Warnings and errors found in the validator. - - - - CORDBG_S_BAD_START_SEQUENCE_POINT - Attempt to SetIP not at a sequence point sequence point. - - - - CORDBG_S_BAD_END_SEQUENCE_POINT - Attempt to SetIP when not going to a sequence point. If both this and CORDBG_E_BAD_START_SEQUENCE_POINT are true, only CORDBG_E_BAD_START_SEQUENCE_POINT will be reported. - - - - CORDBG_S_INSUFFICIENT_INFO_FOR_SET_IP - SetIP is possible, but the debugger doesn't have enough info to fix variable locations, GC refs, or anything else. Use at your own risk. - - - - CORDBG_S_FUNC_EVAL_HAS_NO_RESULT - Some Func evals will lack a return value, - - - - CORDBG_S_VALUE_POINTS_TO_VOID - The Debugging API doesn't support dereferencing void pointers. - - - - CORDBG_S_FUNC_EVAL_ABORTED - The func eval completed, but was aborted. - - - - CORDBG_S_AT_END_OF_STACK - "The stack walk has reached the end of the stack. There are no more frames to walk." - The stack walk has reached the end of the stack. There are no more frames to walk. - - - - CORDBG_S_NOT_ALL_BITS_SET - Not all bits specified were successfully applied - - - - CEE_E_ENTRYPOINT - "Invalid entrypoint information." - The entry point info is invalid. - - - - CEE_E_CVTRES_NOT_FOUND - "cvtres.exe not found." - cannot find cvtres.exe - - - - MSEE_E_LOADLIBFAILED - "Failed to delayload a library." - Failed to delay load library %s (Win32 error: %d). - - - - MSEE_E_GETPROCFAILED - "Failed to get dll entrypoint." - Failed to get entry point %s (Win32 error: %d). - - - - MSEE_E_MULTCOPIESLOADED - "Multiple copies of mscoree.dll have been loaded into the same process." - Multiple copies of MSCOREE.dll have been loaded by the same process. - - - - COR_E_TYPEUNLOADED - "Type has been unloaded." - The type had been unloaded. - - - - COR_E_APPDOMAINUNLOADED - "Attempted to access an unloaded appdomain." - access unloaded appdomain - - - - COR_E_CANNOTUNLOADAPPDOMAIN - "Error while unloading appdomain." - Error while unloading an appdomain - - - - MSEE_E_ASSEMBLYLOADINPROGRESS - "Assembly is still being loaded." - Assembly is being currently being loaded - - - - MSEE_E_CANNOTCREATEAPPDOMAIN - "Attempt to create appdomain failed." - Attempt to create appdomain failed - - - - COR_E_ASSEMBLYEXPECTED - "The module was expected to contain an assembly manifest." - The module was expected to contain an assembly manifest. - - - - COR_E_FIXUPSINEXE - "Attempt to load an unverifiable executable with fixups (IAT with more than 2 sections or a TLS section.)" - Attempt to load an unverifiable exe with fixups (IAT with more than 2 sections or a TLS section) - - - - COR_E_NO_LOADLIBRARY_ALLOWED - "Attempt to LoadLibrary a managed image in an improper way (only assemblies with EAT area allowed)." - Attempt to LoadLibrary a managed image in an improper way (only assemblies with EAT's area allowed.) - - - - COR_E_NEWER_RUNTIME - "This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded." - The assembly is built by a runtime newer than the currently loaded runtime, and cannot be loaded. - - - - COR_E_CANNOT_SET_POLICY - "Cannot set security policy under MultiDomain after non-GAC assemblies have been loaded in appdomain." - Unable to set app domain security policy after non-GAC domain neutral assemblies are loaded - - - - COR_E_CANNOT_SPECIFY_EVIDENCE - "Cannot specify assembly evidence under MultiDomain after non-GAC assemblies with default evidence have been loaded in appdomain." - Unable to use assembly evidence after non-GAC domain neutral assemblies are loaded - - - - COR_E_MULTIMODULEASSEMBLIESDIALLOWED - "The module cannot be loaded because only single file assemblies are supported." - The module cannot be loaded because only single file assemblies are supported. - - - - HOST_E_DEADLOCK - "Host detected a deadlock on a blocking operation." - Host detects deadlock on a blocking operation - - - - HOST_E_INTERRUPTED - "Host interrupted a wait." - Host interrupts a wait, similar to APC - - - - HOST_E_INVALIDOPERATION - "Invalid operation." - The operation is invalid - - - - HOST_E_CLRNOTAVAILABLE - "CLR has been disabled due to unrecoverable error." - CLR has been disabled due to unrecoverable error - - - - HOST_E_TIMEOUT - "A wait has timed out." - A wait times out - - - - HOST_E_NOT_OWNER - "The leave operation has been attempted on a synchronization primitive that is not owned by the current thread." - - - - - HOST_E_ABANDONED - "An event has been abandoned." - An event is abandoned - - - - HOST_E_EXITPROCESS_THREADABORT - "Process exited due to ThreadAbort escalation." - ExitProcess due to ThreadAbort escalation - - - - HOST_E_EXITPROCESS_ADUNLOAD - "Process exited due to AD Unload escalation." - ExitProcess due to AD Unload escalation - - - - HOST_E_EXITPROCESS_TIMEOUT - "Process exited due to Timeout escalation." - ExitProcess due to Timeout escalation - - - - HOST_E_EXITPROCESS_OUTOFMEMORY - "Process exited due to OutOfMemory escalation." - ExitProcess due to OutOfMemory escalation - - - - HOST_E_EXITPROCESS_STACKOVERFLOW - "Process exited due to StackOverflow escalation." - ExitProcess due to StackOverflow escalation - - - - COR_E_MODULE_HASH_CHECK_FAILED - "The check of the module's hash failed." - The check of the module's hash failed. - - - - FUSION_E_REF_DEF_MISMATCH - "The located assembly's manifest definition does not match the assembly reference." - The located assembly's manifest definition does not match the assembly reference. - - - - FUSION_E_INVALID_PRIVATE_ASM_LOCATION - "The private assembly was located outside the appbase directory." - The private assembly was located outside the appbase directory. - - - - FUSION_E_ASM_MODULE_MISSING - "A module specified in the manifest was not found." - A module specified in the manifest was not found. - - - - FUSION_E_UNEXPECTED_MODULE_FOUND - "Modules which are not in the manifest were streamed in." - Modules which are not in the manifest were streamed in. - - - - FUSION_E_PRIVATE_ASM_DISALLOWED - "A strongly-named assembly is required." - A strongly-named assembly is required. - - - - FUSION_E_SIGNATURE_CHECK_FAILED - "Strong name signature could not be verified. The assembly may have been tampered with, or it was delay signed but not fully signed with the correct private key." - The check of the signature failed. - - - - FUSION_E_DATABASE_ERROR - "An unexpected error was encountered in the Assembly Cache database." - An unexpected error was encountered in the Assembly Cache database. - - - - FUSION_E_INVALID_NAME - "The given assembly name or codebase was invalid." - The given assembly name or codebase was invalid. - - - - FUSION_E_CODE_DOWNLOAD_DISABLED - "HTTP download of assemblies has been disabled for this appdomain." - HTTP download of assemblies has been disabled for this appdomain. - - - - FUSION_E_UNINSTALL_DISALLOWED - "Uninstall of given assembly is not allowed." - Uninstall of given assembly is not allowed. - - - - CLR_E_APP_CONFIG_NOT_ALLOWED_IN_APPX_PROCESS - "Application configuration file not allowed in AppX process." - Application configuration file not allowed in AppX process. - - - - FUSION_E_HOST_GAC_ASM_MISMATCH - "Assembly in host store has a different signature than assembly in GAC." - Assembly in host store has a different signature than assembly in GAC - - - - FUSION_E_LOADFROM_BLOCKED - "LoadFrom(), LoadFile(), Load(byte[]) and LoadModule() have been disabled by the host." - Hosted environment doesn't permit loading by location - - - - FUSION_E_CACHEFILE_FAILED - "Failed to add file to AppDomain cache." - Failed to add file to AppDomain cache - - - - FUSION_E_APP_DOMAIN_LOCKED - "The requested assembly version conflicts with what is already bound in the app domain or specified in the manifest." - The requested assembly version conflicts with what is already bound in the app domain or specified in the manifest - - - - FUSION_E_CONFIGURATION_ERROR - "The requested assembly name was neither found in the GAC nor in the manifest or the manifest's specified location is wrong." - The requested assembly name was neither found in the GAC nor in the manifest or the manifest's specified location is wrong - - - - FUSION_E_MANIFEST_PARSE_ERROR - "Unexpected error while parsing the specified manifest." - Unexpected error while parsing the specified manifest - - - - FUSION_E_INVALID_ASSEMBLY_REFERENCE - "The given assembly name is invalid because a processor architecture is specified." - The given assembly name is invalid because a processor architecture is specified - - - - COR_E_ASSEMBLY_NOT_EXPECTED - "The module was expected to not contain an assembly manifest." - The module was expected to not contain an assembly manifest. - - - - COR_E_LOADING_REFERENCE_ASSEMBLY - "Reference assemblies should not be loaded for execution. They can only be loaded in the Reflection-only loader context." - Reference assemblies should not be loaded for execution. They can only be loaded in the Reflection-only loader context. - - - - COR_E_NI_AND_RUNTIME_VERSION_MISMATCH - "The native image could not be loaded, because it was generated for use by a different version of the runtime." - The native image could not be loaded, because it was generated for use by a different version of the runtime. - - - - COR_E_LOADING_WINMD_REFERENCE_ASSEMBLY - "Contract Windows Runtime assemblies cannot be loaded for execution. Make sure your application only contains non-contract Windows Runtime assemblies." - Contract Windows Runtime assemblies cannot be loaded for execution. Make sure your application only contains non-contract Windows Runtime assemblies - - - - CLDB_E_FILE_BADREAD - "Error occurred during a read." - Error occurred during a read. - - - - CLDB_E_FILE_BADWRITE - "Error occurred during a write." - Error occurred during a write. - - - - CLDB_E_FILE_READONLY - "File is read only." - File is read only. - - - - CLDB_E_NAME_ERROR - "Ill-formed name." - An ill-formed name was given. - - - - CLDB_E_TRUNCATION - "Data value was truncated." - ERROR: Data value was truncated. - - - - CLDB_E_FILE_OLDVER - "Old version error." - Old version error. - - - - CLDB_E_RELOCATED - "A shared memory open failed to open at the originally assigned memory address." - A shared mem open failed to open at the originally - - - - CLDB_E_SMDUPLICATE - "Create of shared memory failed. A memory mapping of the same name already exists." - Create of shared memory failed. A memory mapping of the same name already exists. - - - - CLDB_E_NO_DATA - "No .CLB data in the memory or stream." - There isn't .CLB data in the memory or stream. - - - - CLDB_E_READONLY - "Database is read only." - Database is read only. - - - - CLDB_E_INCOMPATIBLE - "Importing scope is not compatible with the emitting scope." - The importing scope is not comptabile with the emitting scope - - - - CLDB_E_FILE_CORRUPT - "File is corrupt." - File is corrupt. - - - - CLDB_E_SCHEMA_VERNOTFOUND - "Required version of schema not found." - Version %d of schema '%s' not found. - - - - CLDB_E_BADUPDATEMODE - "Cannot open a incrementally build scope for full update." - cannot open a incrementally build scope for full update - - - - CLDB_E_INDEX_NONULLKEYS - "Null value not allowed in unique index or primary key." - Null value not allowed in unique index or primary key. - - - - CLDB_E_INDEX_DUPLICATE - "Index has been duplicated." - Unique index %s has been violated. - - - - CLDB_E_INDEX_BADTYPE - "The columns data type is not allowed in an index." - The columns data type is not allowed in an index. - - - - CLDB_E_INDEX_NOTFOUND - "Index not found." - Index %s not found. - - - - CLDB_E_RECORD_NOTFOUND - "Record not found on lookup." - Record wasn't found on lookup. - - - - CLDB_E_RECORD_OVERFLOW - "Too many records were returned for criteria." - Too many records were returned for criteria. - - - - CLDB_E_RECORD_DUPLICATE - "Record is a duplicate." - Record is a duplicate. - - - - CLDB_E_RECORD_PKREQUIRED - "Primary key value is required." - Primary key value is required. - - - - CLDB_E_RECORD_DELETED - "Record is valid but deleted." - Record is valid but deleted. - - - - CLDB_E_RECORD_OUTOFORDER - "Record is emitted out of order." - Record is emitted out of order. - - - - CLDB_E_COLUMN_OVERFLOW - "Data too large." - Data too large. - - - - CLDB_E_COLUMN_READONLY - "Column cannot be changed." - Column cannot be changed. - - - - CLDB_E_COLUMN_SPECIALCOL - "Too many RID or primary key columns, 1 is max." - Too many RID or primary key columns, 1 is max. - - - - CLDB_E_COLUMN_PKNONULLS - "Primary key column may not allow the null value." - Primary key column %s may not allow the null value. - - - - CLDB_E_TABLE_CANTDROP - "Attempted auto-drop of table while open." - Can't auto-drop table while open. - - - - CLDB_E_OBJECT_NOTFOUND - "Object not found in the database." - Object was not found in the database. - - - - CLDB_E_OBJECT_COLNOTFOUND - "Column not found." - The column was not found. - - - - CLDB_E_VECTOR_BADINDEX - "Invalid index." - The index given was invalid. - - - - CLDB_E_TOO_BIG - "A blob or string was too big." - A blob or string was too big. - - - - META_E_INVALID_TOKEN_TYPE - "A token of the wrong type passed to a metadata function." - A token of the wrong type passed to a metadata function. - - - - TLBX_E_INVALID_TYPEINFO - "Typelib import: Invalid type, not converted." - Typelib import: invalid type, not converted. - - - - TLBX_E_INVALID_TYPEINFO_UNNAMED - "Typelib import: Invalid type, not converted - name unknown." - Typelib import: invalid type, not converted -- name unknown. - - - - TLBX_E_CTX_NESTED - "Typelib export: TLBX_E_CTX_NESTED" - Typelib export: Format string for nested contexts. - - - - TLBX_E_ERROR_MESSAGE - "Typelib export: General error. See IError info for more information." - Typelib export: Error message wrapper. - - - - TLBX_E_CANT_SAVE - "Typelib export: SaveAllChanges() failed." - Typelib export: cant "SaveAllChanges()" - - - - TLBX_W_LIBNOTREGISTERED - "Typelib export: Type library is not registered." - Typelib export: type library is not registered. - - - - TLBX_E_CANTLOADLIBRARY - "Typelib export: Type library could not be loaded." - Typelib export: type library cannot be loaded. - - - - TLBX_E_BAD_VT_TYPE - "Typelib import: Invalid vartype, not converted." - Typelib import: invalid VT_*, not converted. - - - - TLBX_E_NO_MSCOREE_TLB - "Typelib export: Could not load mscoree.tlb." - Typelib export: can't load mscoree.tlb - - - - TLBX_E_BAD_MSCOREE_TLB - "Typelib export: Could not get a required typeinfo from mscoree.tlb." - Typelib export: can't get a required typeinfo from mscoree.tlb. - - - - TLBX_E_TLB_EXCEPTION - "Typelib import: Fault reading a typelib." - Typelib import: fault reading a typelib. - - - - TLBX_E_MULTIPLE_LCIDS - "Typelib import: Multiple [lcid] parameters on a method." - Typelib import: Multiple LCID's parameters on a method. - - - - TLBX_E_AMBIGUOUS_RETURN - "Typelib import: Duplicate or ambiguous return types." - Typelib import: duplicate or ambiguous return types. - - - - TLBX_E_DUPLICATE_TYPE_NAME - "Typelib import: Duplicate name (due to user-defined name)." - Typelib import: duplicate name (due to user-defined name). - - - - TLBX_I_NONSEQUENTIALSTRUCT - "Typelib export: Cannot convert non-sequential structs." - Typelib export: Can't convert non-sequential structs. - - - - TLBX_I_RESOLVEREFFAILED - "Typelib import: The resolve ref call failed." - Typelib import: The resolve ref call failed. - - - - TLBX_E_ASANY - "Typelib export: Encountered AsAny - ignored." - Typelib export: Encounterd "AsAny" -- ignored. - - - - TLBX_E_INVALIDLCIDPARAM - "Typelib export: Encountered an [lcid] attribute set to an invalid parameter." - Typelib export: Encounterd an LCID attribute set to an invalid param. - - - - TLBX_E_LCIDONDISPONLYITF - "Typelib export: Encountered an [lcid] attribute on a pure dispatch interface." - Typelib export: Encounterd an LCID attribute on a disp only interface. - - - - TLBX_E_NONPUBLIC_FIELD - "Typelib export: Non-public field in public struct." - Typelib export: Non-public field in public struct. - - - - TLBX_E_BAD_NAMES - "Typelib export: Bad names list." - Typelib export: bad names list. - - - - TLBX_E_GENERICINST_SIGNATURE - "TypeLib export: generic type instance in signature." - TypeLib export: generic type instance in signature. - - - - TLBX_E_GENERICPAR_SIGNATURE - "TypeLib export: generic type parameter in signature." - TypeLib export: generic type parameter in signature. - - - - META_E_DUPLICATE - "Attempted to define an object that already exists." - Attempt to define an object that already exists. - - - - META_E_GUID_REQUIRED - "A guid was not provided where one was required." - A guid was not provided where one was required. - - - - META_E_TYPEDEF_MISMATCH - "Merge: an import typedef matched ns.name, but not version and guid." - Merge: an import typedef matched ns.name, but not version and guid. - - - - META_E_MERGE_COLLISION - "Merge: conflict between import and emit." - Merge: conflict between import and emit - - - - TLBX_E_NO_SAFEHANDLE_ARRAYS - "TypeLib export: Detected array of SafeHandles." - TypeLib export: detected array of SafeHandles - - - - META_E_METHD_NOT_FOUND - "Merge: Class already in emit scope, but member not found." - Merge: Class already in emit scope, but member not found - - - - META_E_FIELD_NOT_FOUND - "Merge: Class already in emit scope, but member not found." - Merge: Class already in emit scope, but member not found - - - - META_E_PARAM_MISMATCH - "Merge: Parameter information mismatched." - Merge: Parameter information mismatched. - - - - META_E_BADMETADATA - "Merge: Inconsistency in meta data import scope." - Merge: Inconsistency in meta data import scope - - - - META_E_INTFCEIMPL_NOT_FOUND - "Merge: Class already in emit scope, but interfaceimpl not found." - Merge: Class already in emit scope, but interfaceimpl not found - - - - TLBX_E_NO_CRITICALHANDLE_ARRAYS - "TypeLib export: Detected array of CriticalHandles." - TypeLib export: detected array of CriticalHandles - - - - META_E_CLASS_LAYOUT_INCONSISTENT - "Merge: Duplicate classes have inconsistent class layout information." - Merge: Class is duplicated but class layout information is not consistent - - - - META_E_FIELD_MARSHAL_NOT_FOUND - "Merge: Field is duplicated but no matching FieldMarshal information." - Merge: Field is duplicated but we cannot find the matching FieldMarshal information - - - - META_E_METHODSEM_NOT_FOUND - Merge: - - - - META_E_EVENT_NOT_FOUND - "Merge: Method is duplicated but no matching event info." - Merge: Method is duplicated but we cannot find the matching event info. - - - - META_E_PROP_NOT_FOUND - "Merge: Method is duplicated but no matching property info." - Merge: Method is duplicated but we cannot find the maching property info. - - - - META_E_BAD_SIGNATURE - "Bad binary signature." - Bad binary signature - - - - META_E_BAD_INPUT_PARAMETER - "Bad input parameters." - Bad input parameters - - - - META_E_METHDIMPL_INCONSISTENT - "Merge: duplicated methods have inconsistent ImplFlags." - Merge: duplicated methods have inconsistent ImplFlags - - - - META_E_MD_INCONSISTENCY - "Merge: Inconsistency in meta data." - Merge: Inconsistency in meta data - - - - META_E_CANNOTRESOLVETYPEREF - "Cannot resolve typeref." - Cannot resolve typeref - - - - META_E_STRINGSPACE_FULL - "No logical space left to create more user strings." - No logical space left to create more user strings. - - - - META_E_UNEXPECTED_REMAP - "Unexpected TokenRemap." - A TokenRemap occurred which we weren't prepared to handle. - - - - META_E_HAS_UNMARKALL - "Unmark all has been called already." - Unmark all has been called already - - - - META_E_MUST_CALL_UNMARKALL - "Must call UnmarkAll first before marking." - Must call UnmarkAll first before marking. - - - - META_E_GENERICPARAM_INCONSISTENT - "Merge: duplicated types or methods have inconsistent GenericParams." - Merge: duplicated types/methods have inconsistent GenericParams - - - - META_E_EVENT_COUNTS - "Merge: different event counts in import and emit scopes." - Merge: different event counts in import and emit scopes. - - - - META_E_PROPERTY_COUNTS - "Merge: different property counts in import and emit scopes." - Merge: different property counts in import and emit scopes. - - - - META_E_TYPEDEF_MISSING - "Merge: An input scope has a TypeRef which does not have a matching TypeDef." - Merge: An input scope has a TypeRef which should but doesn't have a matching TypeDef. - - - - TLBX_E_CANT_LOAD_MODULE - "TypeLib export: cannot open the module to export." - TypeLib export: can't open the module to export. - - - - TLBX_E_CANT_LOAD_CLASS - "TypeLib export: cannot load a class." - TypeLib export: can't load a class. - - - - TLBX_E_NULL_MODULE - "TypeLib export: the hModule of a loaded class is 0; cannot export it." - TypeLib export: the hMod of a loaded class is 0; can't export it. - - - - TLBX_E_NO_CLSID_KEY - "TypeLib export: no CLSID or Interface subkey to HKCR." - TypeLib export: no CLSID or Interface subkey to HKCR. - - - - TLBX_E_CIRCULAR_EXPORT - "TypeLib export: attempted to export an Assembly imported from a TLB." - TypeLib export: attempt to export a CLB imported from a TLB. - - - - TLBX_E_CIRCULAR_IMPORT - "TypeLib import: attempted to import a TLB exported from an Assembly." - TypeLib import: attempt to import a TLB exported from a CLB. - - - - TLBX_E_BAD_NATIVETYPE - "TypeLib export: bad Native type in method signature." - TypeLib export: bad Native type in method signature. - - - - TLBX_E_BAD_VTABLE - "TypeLib import: non-increasing vtable (duplicate slots)." - TypeLib import: non-increasing vtable (duplicate slots). - - - - TLBX_E_CRM_NON_STATIC - "TypeLib export: the COM register method is non static." - TypeLib export: the COM register method is non static. - - - - TLBX_E_CRM_INVALID_SIG - "TypeLib export: the specified COM register method does not have the correct signature." - TypeLib export: the specified COM register method does not have the correct signature. - - - - TLBX_E_CLASS_LOAD_EXCEPTION - "TypeLib export: cannot load CLR type." - TypeLib export: can't load, have the class load exception. - - - - TLBX_E_UNKNOWN_SIGNATURE - "TypeLib export: unknown element in signature." - TypeLib export: unknown element in signature. - - - - TLBX_E_REFERENCED_TYPELIB - "TypeLib import: reference to an external typelib." - TypeLib import: reference to an external typelib. - - - - TLBX_E_INVALID_NAMESPACE - "TypeLib import: an imported typelib has an invalid namespace name." - TypeLib import: an imported typelib has an invalid namespace name. - - - - TLBX_E_LAYOUT_ERROR - "Typelib export: an error on Layout()" - Typelib export: an error on Layout() - - - - TLBX_E_NOTIUNKNOWN - "Typelib import: Interface not derived from IUnknown." - Typelib import: Interface not derived from IUnknown. - - - - TLBX_E_NONVISIBLEVALUECLASS - "Typelib export: Non COM visible value type in method signature." - Typelib export: Non COM visible value type in method signature. - - - - TLBX_E_LPTSTR_NOT_ALLOWED - "Typelib export: Types which contain the native type NATIVE_TYPE_LPTSTR are not allowed to be exported to COM." - Typelib export: Types which contain the native type NATIVE_TYPE_LPTSTR are not allowed to be exported to COM. - - - - TLBX_E_AUTO_CS_NOT_ALLOWED - "Typelib export: Types with a charset of auto are not allowed to be exported to COM." - Typelib export: Types with a char set of auto are not allowed to be exported to COM. - - - - TLBX_E_ENUM_VALUE_INVALID - "Typelib export: The enum value is not legal for a typelib." - Typelib export: The enum value is not legal for a typelib. - - - - TLBX_E_DUPLICATE_IID - "Typelib export: Duplicate IID." - Typelib export: Duplicate IID - - - - TLBX_E_NO_NESTED_ARRAYS - "Typelib export: detected nested arrays." - Tyeplib export: detected nested arrays. - - - - TLBX_E_PARAM_ERROR_NAMED - "Typelib import: parameter type could not be converted." - Typelib import: param type couldn't be converted. - - - - TLBX_E_PARAM_ERROR_UNNAMED - "Typelib import: parameter type could not be converted - parameter name unknown." - Typelib import: param type couldn't be converted -- param name unknown. - - - - TLBX_E_AGNOST_SIGNATURE - "TypeLib export: size agnostic element in signature." - TypeLib export: size agnostic element in signature. - - - - TLBX_E_CONVERT_FAIL - "TypeLib export: exporter failed." - TypeLib export: exporter failed. - - - - TLBX_W_DUAL_NOT_DISPATCH - "Typelib import: [dual] interface not derived from IDispatch." - Typelib import: [dual] interface not derived from IDispatch. - - - - TLBX_E_BAD_SIGNATURE - "Typelib export: bad signature." - Typelib export: unconvertable signature (use specific error for reporting!) - - - - TLBX_E_ARRAY_NEEDS_NT_FIXED - "Typelib export: non-fixed or non-safearray array in struct." - Typelib export: non-fixed/non-safearray array in struct - - - - TLBX_E_CLASS_NEEDS_NT_INTF - "Typelib export: non-interface class in struct." - Typelib export: non-interface class in struct - - - - META_E_CA_INVALID_TARGET - "Known custom attribute on invalid target." - Known custom attribute on invalid target. - - - - META_E_CA_INVALID_VALUE - "Known custom attribute had invalid value." - Known custom attribute had invalid value. - - - - META_E_CA_INVALID_BLOB - "Known custom attribute blob has bad format." - Known custom attribute blob is bad format. - - - - META_E_CA_REPEATED_ARG - "Known custom attribute blob has repeated named argument." - Known custom attribute blob has repeated named argument. - - - - META_E_CA_UNKNOWN_ARGUMENT - "Known custom attribute named argument not recognized." - Known custom attrubte named arg not recognized. - - - - META_E_CA_VARIANT_NYI - "Known attribute named argument does not support variant." - Known attribute named argument doesn't support variant. - - - - META_E_CA_ARRAY_NYI - "Known attribute named argument does not support array." - Known attribute named argument doesn't support array. - - - - META_E_CA_UNEXPECTED_TYPE - "Known attribute parser found unexpected type." - Known attribute parser found unexpected type. - - - - META_E_CA_INVALID_ARGTYPE - "Known attribute parser only handles fields, not properties." - Known attribute parser only handles fields -- no properties. - - - - META_E_CA_INVALID_ARG_FOR_TYPE - "Known attribute parser found an argument that is invalid for the object it is applied to." - Known attribute parser found an argument that is invalid for the object it is applied to. - - - - META_E_CA_INVALID_UUID - "The format of the UUID was invalid." - The format of the UUID was invalid. - - - - META_E_CA_INVALID_MARSHALAS_FIELDS - "The MarshalAs attribute has fields set that are not valid for the specified unmanaged type." - The MarshalAs attribute has fields set that are not valid for the specified unmanaged type. - - - - META_E_CA_NT_FIELDONLY - "The specified unmanaged type is only valid on fields." - The specified unmanaged type is only valid on fields. - - - - META_E_CA_NEGATIVE_PARAMINDEX - "The parameter index cannot be negative." - The parameter index cannot be negative. - - - - META_E_CA_NEGATIVE_MULTIPLIER - "The multiplier cannot be negative." - The multiplier cannot be negative. - - - - META_E_CA_NEGATIVE_CONSTSIZE - "The constant size cannot be negative." - The constant size cannot be negative. - - - - META_E_CA_FIXEDSTR_SIZE_REQUIRED - "A fixed string requires a size." - A fixed string requires a size. - - - - META_E_CA_CUSTMARSH_TYPE_REQUIRED - "A custom marshaler requires the custom marshaler type." - A custom marshaler requires the custom marshaler type. - - - - META_E_CA_FILENAME_REQUIRED - "A DllImport attribute requires a filename." - A DllImport attribute requires a filename. - - - - TLBX_W_NO_PROPS_IN_EVENTS - "TypeLib import: Detected properties in a source dispinterface." - TypeLib import: Detected properties in a source dispinterface. - - - - META_E_NOT_IN_ENC_MODE - "SaveDelta was called without being in EnC mode." - SaveDelta was called without being in EnC mode - - - - META_E_METHOD_COUNTS - "Merge: different method counts in import and emit scopes." - Merge: different method counts in import and emit scopes. - - - - META_E_FIELD_COUNTS - "Merge: different field counts in import and emit scopes." - Merge: different field counts in import and emit scopes. - - - - META_E_PARAM_COUNTS - "Merge: different parameter counts in import and emit scopes." - Merge: different param counts in import and emit scopes. - - - - TLBX_E_TYPED_REF - "TypeLib export: Exporting a TypedReference." - TypeLib export: Exporting a TypedReference. - - - - TLBX_E_BITNESS_MISMATCH - "TypeLib export: bitness of assembly does not match bitness of output type library." - TypeLib export: bitness of assembly doesn't match bitness of output type library - - - - TLBX_E_EVENT_WITH_NEWENUM - TypeLib import: source interface with NewEnum member. - - - - TLBX_E_PROPGET_WITHOUT_RETURN - TypeLib import: propget without return type - - - - META_E_MISMATCHED_VISIBLITY - Merge - Match found for type/method/etc but differs in visiblity - - - - META_E_CA_BAD_FRIENDS_ARGS - "InternalsVisibleTo can't have a version, culture, or processor architecture." - InternalsVisibleTo can't have a version, culture, or processor architecture. - - - - META_E_CA_FRIENDS_SN_REQUIRED - Strong-name signed assemblies can only grant friend access to strong name-signed assemblies - - - - VLDTR_E_RID_OUTOFRANGE - "Rid is out of range." - Rid is out of range. - - - - VLDTR_E_CDTKN_OUTOFRANGE - "Coded token type is out of range." - Coded token type is out of range. - - - - VLDTR_E_CDRID_OUTOFRANGE - "Coded rid is out of range." - Coded rid is out of range. - - - - VLDTR_E_STRING_INVALID - "String offset is invalid." - String offset is invalid. - - - - VLDTR_E_GUID_INVALID - "GUID offset is invalid." - GUID offset is invalid. - - - - VLDTR_E_BLOB_INVALID - "Blob offset if invalid." - Blob offset if invalid. - - - - VLDTR_E_MOD_MULTI - "Multiple module records found." - Multiple module records found. - - - - VLDTR_E_MOD_NULLMVID - "Module has null MVID." - Module has null MVID. - - - - VLDTR_E_TR_NAMENULL - "TypeRef name is NULL." - TypeRef name is NULL. - - - - VLDTR_E_TR_DUP - "TypeRef has a duplicate." - TypeRef has a dup. - - - - VLDTR_E_TD_NAMENULL - "TypeDef name is NULL." - TypeDef name is NULL. - - - - VLDTR_E_TD_DUPNAME - "TypeDef has a duplicate based on name+namespace." - TypeDef has a dup based on name+namespace. - - - - VLDTR_E_TD_DUPGUID - "TypeDef has a duplicate based on GUID." - TypeDef has a dup based on GUID. - - - - VLDTR_E_TD_NOTIFACEOBJEXTNULL - "TypeDef that is not an Interface and not System.Object extends nil parent." - TypeDef that's not an Interface and not System.Object extends nil parent. - - - - VLDTR_E_TD_OBJEXTENDSNONNULL - "System.Object extends a non-nil parent." - System.Object extends a non-nil parent. - - - - VLDTR_E_TD_EXTENDSSEALED - "TypeDef extends sealed class." - TypeDef extends sealed class. - - - - VLDTR_E_TD_DLTNORTSPCL - "TypeDef is Deleted but not marked with RTSpecialName." - TypeDef is Deleted but not marked with RTSpecialName. - - - - VLDTR_E_TD_RTSPCLNOTDLT - "TypeDef is marked RTSpecialName, but is not a Deleted record." - TypeDef is marked RTSpecialName, but is not a Deleted record. - - - - VLDTR_E_MI_DECLPRIV - "MethodImpl's Decl is private." - MethodImpl's Decl is private - - - - VLDTR_E_AS_BADNAME - "Assembly [Ref] name has path and/or extension." - Assembly [Ref] name has path and/or extension. - - - - VLDTR_E_FILE_SYSNAME - "File has a system name (con, com, aux, etc.)." - File has a system name (con, com, aux, etc.). - - - - VLDTR_E_MI_BODYSTATIC - "MethodImpl's body is static." - MethodImpl's body is static. - - - - VLDTR_E_TD_IFACENOTABS - "TypeDef is marked Interface but not Abstract." - TypeDef is marked Interface but not Abstract. - - - - VLDTR_E_TD_IFACEPARNOTNIL - "TypeDef is marked Interface but parent is not Nil." - TypeDef is marked Interface but parent is not Nil. - - - - VLDTR_E_TD_IFACEGUIDNULL - "TypeDef is marked Interface but GUID is NULL." - TypeDef is marked Interface but GUID is NULL. - - - - VLDTR_E_MI_DECLFINAL - "TMethodImpl's Decl is final." - TMethodImpl's Decl is final. - - - - VLDTR_E_TD_VTNOTSEAL - "TypeDef is marked ValueType but not marked Sealed." - TypeDef is marked ValueType but not marked Sealed. - - - - VLDTR_E_PD_BADFLAGS - "Parameter has extra bits in flags." - Param has extra bits in flags. - - - - VLDTR_E_IFACE_DUP - "InterfaceImpl has a duplicate." - InterfaceImpl has a dup. - - - - VLDTR_E_MR_NAMENULL - "MemberRef name is NULL." - MemberRef name is NULL. - - - - VLDTR_E_MR_VTBLNAME - "MemberRef has an invalid name, _VtblGap*." - MemberRef has an invalid name, _VtblGap*. - - - - VLDTR_E_MR_DELNAME - "MemberRef has an invalid name, _Deleted*." - MemberRef has an invalid name, _Deleted*. - - - - VLDTR_E_MR_PARNIL - "MemberRef parent Nil in a PE file." - MemberRef parent Nil in a PE file. - - - - VLDTR_E_MR_BADCALLINGCONV - "MemberRef has invalid calling convention." - MemberRef has invalid calling convention. - - - - VLDTR_E_MR_NOTVARARG - "MemberRef has Method parent but calling convention is not VARARG." - MemberRef has Method parent but calling convention is not VARARG. - - - - VLDTR_E_MR_NAMEDIFF - "MemberRef name different from parent MethodDef." - MemberRef name different from parent MethodDef. - - - - VLDTR_E_MR_SIGDIFF - "MemberRef signature different from parent MethodDef." - MemberRef signature different from parent MethodDef. - - - - VLDTR_E_MR_DUP - "MemberRef has a duplicate." - MemberRef has a dup. - - - - VLDTR_E_CL_TDAUTO - "ClassLayout parent TypeDef is marked AutoLayout." - ClassLayout parent TypeDef is marked AutoLayout. - - - - VLDTR_E_CL_BADPCKSZ - "ClassLayout has bad PackingSize." - ClassLayout has bad PackingSize. - - - - VLDTR_E_CL_DUP - "ClassLayout has a duplicate." - ClassLayout has dup. - - - - VLDTR_E_FL_BADOFFSET - "FieldLayout2 has bad offset." - FieldLayout2 has bad offset. - - - - VLDTR_E_FL_TDNIL - "FieldLayout2 has field with nil parent." - FieldLayout2 has field with nil parent. - - - - VLDTR_E_FL_NOCL - "FieldLayout2 has no ClassLayout record." - FieldLayout2 has no ClassLayout record. - - - - VLDTR_E_FL_TDNOTEXPLCT - "FieldLayout2 parent TypeDef is not marked with ExplicitLayout." - FieldLayout2 parent TypeDef is not marked with ExplicitLayout. - - - - VLDTR_E_FL_FLDSTATIC - "FieldLayout2 has field marked Static." - FieldLayout2 has field marked Static. - - - - VLDTR_E_FL_DUP - "FieldLayout2 has a duplicate." - FieldLayout2 has a dup. - - - - VLDTR_E_MODREF_NAMENULL - "ModuleRef name is NULL." - ModuleRef name is NULL. - - - - VLDTR_E_MODREF_DUP - "ModuleRef has a duplicate." - ModuleRef has a dup. - - - - VLDTR_E_TR_BADSCOPE - "TypeRef has a bad resolution scope." - TypeRef has a bad resolution scope. - - - - VLDTR_E_TD_NESTEDNOENCL - "TypeDef marked nested has no encloser." - TypeDef marked nested has no encloser. - - - - VLDTR_E_TD_EXTTRRES - "TypeDef extends a TypeRef which resolves to a TypeDef in the same module." - TypeDef extends a TypeRef which resolves to a TypeDef in the same module. - - - - VLDTR_E_SIGNULL - "Signature specified is zero-sized." - Signature specified is zero-sized. - - - - VLDTR_E_SIGNODATA - "Signature does not have enough data at specified byte." - Signature does not have enough data at specified byte. - - - - VLDTR_E_MD_BADCALLINGCONV - "Method signature has invalid calling convention." - Method signature has invalid calling convention. - - - - VLDTR_E_MD_THISSTATIC - "Method is marked static but has HASTHIS/EXPLICITTHIS set on the calling convention." - Method is marked static but has HASTHIS/EXPLICITTHIS set on the calling convention. - - - - VLDTR_E_MD_NOTTHISNOTSTATIC - "Method is not marked static but is not HASTHIS or EXPLICITTHIS." - Method is not marked static but is not HASTHIS/EXPLICITTHIS. - - - - VLDTR_E_MD_NOARGCNT - "Method signature is missing the argument count." - Method signature is missing the argument count. - - - - VLDTR_E_SIG_MISSELTYPE - "Signature missing element type." - Signature missing element type. - - - - VLDTR_E_SIG_MISSTKN - "Signature missing token." - Signature missing token. - - - - VLDTR_E_SIG_TKNBAD - "Signature has bad token." - Signature has bad token. - - - - VLDTR_E_SIG_MISSFPTR - "Signature is missing function pointer." - Signature is missing function pointer. - - - - VLDTR_E_SIG_MISSFPTRARGCNT - "Signature has function pointer missing argument count." - Signature has function pointer missing argument count. - - - - VLDTR_E_SIG_MISSRANK - "Signature is missing rank specification." - Signature is missing rank specification. - - - - VLDTR_E_SIG_MISSNSIZE - "Signature is missing count of sized dimensions." - Signature is missing count of sized dimensions. - - - - VLDTR_E_SIG_MISSSIZE - "Signature is missing size of dimension." - Signature is missing size of dimension. - - - - VLDTR_E_SIG_MISSNLBND - "Signature is missing count of lower bounds." - Signature is missing count of lower bounds. - - - - VLDTR_E_SIG_MISSLBND - "Signature is missing a lower bound." - Signature is missing a lower bound. - - - - VLDTR_E_SIG_BADELTYPE - "Signature has bad element type." - Signature has bad element type. - - - - VLDTR_E_SIG_MISSVASIZE - "Signature has value array missing size." - Signature has value array missing size. - - - - VLDTR_E_FD_BADCALLINGCONV - "Field signature has invalid calling convention." - Field signature has invalid calling convention. - - - - VLDTR_E_MD_NAMENULL - "Method name is NULL." - Method name is NULL. - - - - VLDTR_E_MD_PARNIL - "Method has parent NIL." - Method has parent NIL. - - - - VLDTR_E_MD_DUP - "Method has a duplicate." - Method has dup. - - - - VLDTR_E_FD_NAMENULL - "Field name is NULL." - Field name is NULL. - - - - VLDTR_E_FD_PARNIL - "Field parent is Nil." - Field parent is Nil. - - - - VLDTR_E_FD_DUP - "Field has a duplicate." - Field has dup. - - - - VLDTR_E_AS_MULTI - "Multiple Assembly records found." - Multiple Assembly records found. - - - - VLDTR_E_AS_NAMENULL - "Assembly name is NULL." - Assembly name is NULL. - - - - VLDTR_E_SIG_TOKTYPEMISMATCH - "E_T_VALUETYPE<class token> or E_T_CLASS<vtype token>." - E_T_VALUETYPE<class token> or E_T_CLASS<vtype token>. - - - - VLDTR_E_CL_TDINTF - "Class layout on an Interface." - Class layout on an Interface. - - - - VLDTR_E_ASOS_OSPLTFRMIDINVAL - "AssemblyOS platform ID invalid." - AssemblyOS platform ID invalid. - - - - VLDTR_E_AR_NAMENULL - "AssemblyRef name is NULL." - AssemblyRef name is NULL. - - - - VLDTR_E_TD_ENCLNOTNESTED - "TypeDef not nested has encloser." - TypeDef not nested has encloser. - - - - VLDTR_E_AROS_OSPLTFRMIDINVAL - "AssemblyRefOS has invalid platform ID." - AssemblyRefOS has invalid platform ID. - - - - VLDTR_E_FILE_NAMENULL - "File name is NULL." - File name is NULL. - - - - VLDTR_E_CT_NAMENULL - "ExportedType name is NULL." - ExportedType name is NULL. - - - - VLDTR_E_TD_EXTENDSCHILD - "TypeDef extends its own child." - TypeDef extends its own child. - - - - VLDTR_E_MAR_NAMENULL - "ManifestResource name is NULL." - ManifestResource name is NULL. - - - - VLDTR_E_FILE_DUP - "File has a duplicate." - File has dup. - - - - VLDTR_E_FILE_NAMEFULLQLFD - "File name is fully qualified." - File name is fully qualified. - - - - VLDTR_E_CT_DUP - "ExportedType has a duplicate." - ExportedType has dup. - - - - VLDTR_E_MAR_DUP - "ManifestResource has a duplicate." - ManifestResource has dup. - - - - VLDTR_E_MAR_NOTPUBPRIV - "ManifestResource is neither Public nor Private." - ManifestResource is neither Public not Private. - - - - VLDTR_E_TD_ENUMNOVALUE - "Enum has no value__ field." - Enum has no "value__" field. - - - - VLDTR_E_TD_ENUMVALSTATIC - "Enum's value__ field is static." - Enum's "value__" field is static. - - - - VLDTR_E_TD_ENUMVALNOTSN - "Enum's value__ field is not SpecialName." - Enum's "value__" field is not SpecialName. - - - - VLDTR_E_TD_ENUMFLDNOTST - "Enum's field is not static." - Enum's field is not static. - - - - VLDTR_E_TD_ENUMFLDNOTLIT - "Enum's field is not literal." - Enum's field is not literal. - - - - VLDTR_E_TD_ENUMNOLITFLDS - "Enum has no literal fields." - Enum has no literal fields. - - - - VLDTR_E_TD_ENUMFLDSIGMISMATCH - "Enum's field signature does not match value__ signature." - Enum's field sig does not match value__ sig. - - - - VLDTR_E_TD_ENUMVALNOT1ST - "Enum's value__ field is not first." - Enum's "value__" field is not first. - - - - VLDTR_E_FD_NOTVALUERTSN - "Field is RTSpecialName but name is not value__." - Field is RTSpecialName but name is not "value__". - - - - VLDTR_E_FD_VALUEPARNOTENUM - "Field value__ in not Enum class." - Field "value__" in not Enum class. - - - - VLDTR_E_FD_INSTINIFACE - "Instance field in interface." - Instance field in interface. - - - - VLDTR_E_FD_NOTPUBINIFACE - "Non-public field in interface." - Non-public field in interface. - - - - VLDTR_E_FMD_GLOBALNOTPUBPRIVSC - "Global field or method is neither Public nor PrivateScope." - Global field/method neither Public nor PrivateScope. - - - - VLDTR_E_FMD_GLOBALNOTSTATIC - "Global field or method is not static." - Global field/method not static. - - - - VLDTR_E_FD_GLOBALNORVA - "Global field has no RVA." - Global field has no RVA. - - - - VLDTR_E_MD_CTORZERORVA - ".ctor or .cctor has zero RVA." - .ctor,.cctor has zero RVA. - - - - VLDTR_E_FD_MARKEDNOMARSHAL - "Field is marked marshaled but has no marshaling record." - Field is marked marshaled but has no marshaling rec. - - - - VLDTR_E_FD_MARSHALNOTMARKED - "Field has marshaling record but is not marked marshaled." - Field has marshaling rec but is not marked marshaled. - - - - VLDTR_E_FD_MARKEDNODEFLT - "Field is marked HasDefault but has no const value." - Field is marked HasDefault but has no const value. - - - - VLDTR_E_FD_DEFLTNOTMARKED - "Field has const value record but is not marked HasDefault." - Field has const value rec but is not marked HasDefault. - - - - VLDTR_E_FMD_MARKEDNOSECUR - "Field or method is marked HasSecurity but has no security record." - Field/method is marked HasSecurity but has no security rec. - - - - VLDTR_E_FMD_SECURNOTMARKED - "Field or method has security record but is not marked HasSecurity." - Field/method has security rec but is not marked HasSecurity. - - - - VLDTR_E_FMD_PINVOKENOTSTATIC - "Field or method is PInvoke but is not marked Static." - Field/method is PInvoke but is not marked Static. - - - - VLDTR_E_FMD_MARKEDNOPINVOKE - "Field or method is marked PInvoke but has no ImplMap." - Field/method is marked PInvoke but has no ImplMap. - - - - VLDTR_E_FMD_PINVOKENOTMARKED - "Field or method has ImplMap but is not marked PInvoke." - Field/method has ImplMap but is not marked PInvoke. - - - - VLDTR_E_FMD_BADIMPLMAP - "Field or method has invalid ImplMap." - Field/method has invalid ImplMap - - - - VLDTR_E_IMAP_BADMODREF - "ImplMap has invalid ModuleRef." - ImplMap has invalid ModuleRef - - - - VLDTR_E_IMAP_BADMEMBER - "ImplMap has invalid MemberForwarded." - ImplMap has invalid MemberForwarded - - - - VLDTR_E_IMAP_BADIMPORTNAME - "ImplMap has invalid ImportName." - ImplMap has invalid ImportName - - - - VLDTR_E_IMAP_BADCALLCONV - "ImplMap has invalid call conv." - ImplMap has invalid call conv - - - - VLDTR_E_FMD_BADACCESSFLAG - "Field or method has invalid access flag." - Field/method has invalid access flag - - - - VLDTR_E_FD_INITONLYANDLITERAL - "Field is InitOnly and Literal." - Field is InitOnly and Literal - - - - VLDTR_E_FD_LITERALNOTSTATIC - "Field is Literal but not Static." - Field is Literal but not Static - - - - VLDTR_E_FMD_RTSNNOTSN - "Field or method is RTSpec.Name but not Spec.Name." - Field/method is RTSpec.Name but not Spec.Name - - - - VLDTR_E_MD_ABSTPARNOTABST - "Method is abstract, parent is not." - Method is abstract, parent is not - - - - VLDTR_E_MD_NOTSTATABSTININTF - "Method not static or abstract in interface." - Method not static or abstract in interface - - - - VLDTR_E_MD_NOTPUBININTF - "Method not public in interface." - Method not public in interface - - - - VLDTR_E_MD_CTORININTF - ".ctor in interface." - ctor in interface - - - - VLDTR_E_MD_GLOBALCTORCCTOR - "global .ctor or .cctor." - global ctor or cctor - - - - VLDTR_E_MD_CTORSTATIC - "static .ctor." - static ctor - - - - VLDTR_E_MD_CTORNOTSNRTSN - ".ctor or .cctor not marked SpecialName or RTSpecialName." - ctor,cctor not marked SpecialName,RTSpecialName - - - - VLDTR_E_MD_CTORVIRT - "virtual .ctor or .cctor." - virtual ctor,cctor - - - - VLDTR_E_MD_CTORABST - "abstract .ctor or .cctor." - abstract ctor,cctor - - - - VLDTR_E_MD_CCTORNOTSTATIC - "instance .cctor." - instance cctor - - - - VLDTR_E_MD_ZERORVA - "RVA set to zero, but method not abstract or pinvoke or runtime, or reverse." - RVA=0, method not abstract or pinvoke or runtime, or reverse - - - - VLDTR_E_MD_FINNOTVIRT - "Method is final and not virtual." - Method is final and not virtual - - - - VLDTR_E_MD_STATANDFINORVIRT - "Method is static and final or virtual." - Method is static and final or virtual - - - - VLDTR_E_MD_ABSTANDFINAL - "Method is abstract and final." - Method is abstract and final - - - - VLDTR_E_MD_ABSTANDIMPL - "Method is abstract and implemented." - Method is abstract and implemented - - - - VLDTR_E_MD_ABSTANDPINVOKE - "Method is abstract and pinvoke." - Method is abstract and pinvoke - - - - VLDTR_E_MD_ABSTNOTVIRT - "Method is abstract and not virtual." - Method is abstract and not virtual - - - - VLDTR_E_MD_NOTABSTNOTIMPL - "Method is not abstract and not implemented." - Method is not abstract and not implemented - - - - VLDTR_E_MD_NOTABSTBADFLAGSRVA - "Method is not abstract and not (non-zero RVA or PInvoke or runtime)." - Method is not abstract and not (RVA!=0 or pinvoke or runtime) - - - - VLDTR_E_MD_PRIVSCOPENORVA - "Method is PrivateScope and has RVA set to zero." - Method is PrivateScope and has RVA==0 - - - - VLDTR_E_MD_GLOBALABSTORVIRT - "Global method is abstract or virtual." - Global method is abstract or virtual - - - - VLDTR_E_SIG_LONGFORM - "Signature uses long form." - Signature uses long form - - - - VLDTR_E_MD_MULTIPLESEMANTICS - "Method has multiple semantics (warning)." - Method has multiple semantics (warning) - - - - VLDTR_E_MD_INVALIDSEMANTICS - "Method has invalid semantics (not event or property.)" - Method has invalid semantics (not event or prop) - - - - VLDTR_E_MD_SEMANTICSNOTEXIST - "Method has semantics association that does not exist." - Method has semantics assoc that does not exist - - - - VLDTR_E_MI_DECLNOTVIRT - "MethodImpl's Decl is not virtual." - MethodImpl's Decl is not virtual - - - - VLDTR_E_FMD_GLOBALITEM - "Global field or method (warning, CLS)." - Global field/method (warning,CLS) - - - - VLDTR_E_MD_MULTSEMANTICFLAGS - "Method has multiple semantic flags set." - Method has multiple semantic flags set - - - - VLDTR_E_MD_NOSEMANTICFLAGS - "Method has no semantic flags set." - Method has no semantic flags set - - - - VLDTR_E_FD_FLDINIFACE - "Field in Interface (warning, CLS)." - Field in Interface (warning, CLS) - - - - VLDTR_E_AS_HASHALGID - "Unrecognized Hash Alg ID (warning)." - Unrecognized Hash Alg ID (warning) - - - - VLDTR_E_AS_PROCID - "Unrecognized Processor ID in Assembly(warning)." - Unrecognized Processor ID in Assembly(warning) - - - - VLDTR_E_AR_PROCID - "Unrecognized Processor ID in AssemblyRef(warning)." - Unrecognized Processor ID in AssemblyRef(warning) - - - - VLDTR_E_CN_PARENTRANGE - "Constant: parent token out of range." - Constant: parent token out of range - - - - VLDTR_E_AS_BADFLAGS - "Invalid flags in Assembly." - Invalid flags in Assembly - - - - VLDTR_E_TR_HASTYPEDEF - "There is TypeDef with same name as TypeRef (warning)." - There is TypeDef with same name as TypeRef (warning) - - - - VLDTR_E_IFACE_BADIMPL - "In InterfaceImpl, the implementing token is not TypeDef." - In InterfaceImpl, the implementing token is not TypeDef - - - - VLDTR_E_IFACE_BADIFACE - "In InterfaceImpl, the implemented token is not TypeDef or TypeRef." - In InterfaceImpl, the implemented token is not TypeDef or TypeRef - - - - VLDTR_E_TD_SECURNOTMARKED - "TypeDef has security record but it is not marked HasSecurity." - TypeDef has security rec but not marked HasSecurity - - - - VLDTR_E_TD_MARKEDNOSECUR - "TypeDef marked HasSecurity but has no security record." - TypeDef marked HasSecurity but has no security rec - - - - VLDTR_E_MD_CCTORHASARGS - ".cctor has arguments." - .cctor has arguments - - - - VLDTR_E_CT_BADIMPL - "ExportedType has invalid Implementation." - ExportedType has invalid Implementation - - - - VLDTR_E_MI_ALIENBODY - "MethodImpl has body from other class." - MethodImpl has body from other class - - - - VLDTR_E_MD_CCTORCALLCONV - ".cctor has invalid calling convention." - .cctor has invalid calling convention - - - - VLDTR_E_MI_BADCLASS - "MethodImpl has invalid Class token." - MethodImpl has invalid Class token - - - - VLDTR_E_MI_CLASSISINTF - "MethodImpl declared in Interface." - MethodImpl declared in Interface - - - - VLDTR_E_MI_BADDECL - "MethodImpl has invalid MethodDeclaration token." - MethodImpl has invalid MethodDeclaration token - - - - VLDTR_E_MI_BADBODY - "MethodImpl has invalid MethodBody token." - MethodImpl has invalid MethodBody token - - - - VLDTR_E_MI_DUP - "MethodImpl has duplicate." - MethodImpl has duplicate - - - - VLDTR_E_FD_BADPARENT - "Bad field parent." - Bad field parent - - - - VLDTR_E_MD_PARAMOUTOFSEQ - "Parameter out of sequence (warning)." - Param out of sequence (warning) - - - - VLDTR_E_MD_PARASEQTOOBIG - "Parameter's sequence number exceeds number of arguments." - Param's sequence num exceeds num of args - - - - VLDTR_E_MD_PARMMARKEDNOMARSHAL - "Parameter marked HasMarshal, has no marshaling info." - Param marked HasMarshal, has no marshaling info - - - - VLDTR_E_MD_PARMMARSHALNOTMARKED - "Parameter has marshaling info, not marked HasMarshal." - Param has marshaling info, not marked HasMarshal - - - - VLDTR_E_MD_PARMMARKEDNODEFLT - "Parameter marked HasDefault, has no const value." - Param marked HasDefault, has no const value - - - - VLDTR_E_MD_PARMDEFLTNOTMARKED - "Parameter has const value, not marked HasDefault." - Param has const value, not marked HasDefault - - - - VLDTR_E_PR_BADSCOPE - "Property has invalid scope." - Prop has invalid scope - - - - VLDTR_E_PR_NONAME - "Property has no name." - Prop has no name - - - - VLDTR_E_PR_NOSIG - "Property has no signature." - Prop has no signature - - - - VLDTR_E_PR_DUP - "Property has a duplicate." - Prop has a duplicate - - - - VLDTR_E_PR_BADCALLINGCONV - "Property has bad calling convention." - Prop has bad calling convention - - - - VLDTR_E_PR_MARKEDNODEFLT - "Property marked HasDefault, has no const value." - Prop marked HasDefault, has no const value - - - - VLDTR_E_PR_DEFLTNOTMARKED - "Property has const value, not marked HasDefault." - Prop has const value, not marked HasDefault - - - - VLDTR_E_PR_BADSEMANTICS - "Property has method that is neither a Setter nor a Getter." - Prop has method not (Setter,Getter, or Other) - - - - VLDTR_E_PR_BADMETHOD - "Property has method with invalid token." - Prop has method with invalid token - - - - VLDTR_E_PR_ALIENMETHOD - "Property has method from another class." - Prop has method from another class - - - - VLDTR_E_CN_BLOBNOTNULL - "Const has non-null blob when it should not." - Const has non-null blob when it should not - - - - VLDTR_E_CN_BLOBNULL - "Const has null value blob." - Const has null value blob - - - - VLDTR_E_EV_BADSCOPE - "Event has invalid scope." - Event has invalid scope - - - - VLDTR_E_EV_NONAME - "Event has no name." - Event has no name - - - - VLDTR_E_EV_DUP - "Event has a duplicate." - Event has a duplicate - - - - VLDTR_E_EV_BADEVTYPE - "Event has invalid EventType." - Event has invalid EventType - - - - VLDTR_E_EV_EVTYPENOTCLASS - "Event's EventType is not a class." - Event's EventType is not a class - - - - VLDTR_E_EV_BADSEMANTICS - "Event has method not (AddOn,RemoveOn,Fire,Other)." - Event has method not (AddOn,RemoveOn,Fire,Other) - - - - VLDTR_E_EV_BADMETHOD - "Event has method with invalid token." - Event has method with invalid token - - - - VLDTR_E_EV_ALIENMETHOD - "Event has method from another class." - Event has method from another class - - - - VLDTR_E_EV_NOADDON - "Event has no AddOn method." - Event has no AddOn method - - - - VLDTR_E_EV_NOREMOVEON - "Event has no RemoveOn method." - Event has no RemoveOn method - - - - VLDTR_E_CT_DUPTDNAME - "ExportedType has same name as TypeDef." - ExportedType has same name as TypeDef - - - - VLDTR_E_MAR_BADOFFSET - "MRes refers to non-PE file with non-zero offset." - MRes refers to non-PE file with offset !=0 - - - - VLDTR_E_DS_BADOWNER - "Declarative security has invalid owner token." - Decl.security has invalid owner token - - - - VLDTR_E_DS_BADFLAGS - "Declarative security has invalid action flags." - Decl.security has invalid action flags - - - - VLDTR_E_DS_NOBLOB - "Declarative security has no permission blob." - Decl.security has no permission blob - - - - VLDTR_E_MAR_BADIMPL - "Manifest resource has invalid Implementation." - Manifest resource has invalid Implementation - - - - VLDTR_E_MR_VARARGCALLINGCONV - "MemberRef has VARARG calling conv. (CLS warning)." - MemberRef has VARARG calling conv. (CLS warning) - - - - VLDTR_E_MD_CTORNOTVOID - ".ctor or .cctor returns something other than void." - .ctor,.cctor returning not void - - - - VLDTR_E_EV_FIRENOTVOID - "Fire method returns something other than void." - Fire method returning not void - - - - VLDTR_E_AS_BADLOCALE - "Invalid locale." - Invalid locale - - - - VLDTR_E_CN_PARENTTYPE - "Constant has parent of invalid type." - Constant has parent of invalid type - - - - VLDTR_E_SIG_SENTINMETHODDEF - "E_T_SENTINEL in MethodDef signature." - E_T_SENTINEL in MethodDef signature - - - - VLDTR_E_SIG_SENTMUSTVARARG - "E_T_SENTINEL <=> VARARG." - E_T_SENTINEL <=> VARARG - - - - VLDTR_E_SIG_MULTSENTINELS - "Multiple E_T_SENTINELs." - Multiple E_T_SENTINELs - - - - VLDTR_E_SIG_LASTSENTINEL - "E_T_SENTINEL not followed by type." - E_T_SENTINEL not followed by type - - - - VLDTR_E_SIG_MISSARG - "Signature missing argument." - Signature missing argument - - - - VLDTR_E_SIG_BYREFINFIELD - "Field of ByRef type." - Field of ByRef type - - - - VLDTR_E_MD_SYNCMETHODINVTYPE - "Synchronized method in value class." - Synchronized method in value class - - - - VLDTR_E_TD_NAMETOOLONG - "TypeDef name too long." - TypeDef name too long - - - - VLDTR_E_AS_PROCDUP - "Duplicate Assembly Processor." - Duplicate Assembly Processor - - - - VLDTR_E_ASOS_DUP - "Duplicate Assembly OS (ID+ver.major+ver.minor)." - Duplicate Assembly OS (ID+ver.major+ver.minor) - - - - VLDTR_E_MAR_BADFLAGS - "Manifest Resource has bad flags." - Manifest Resource has bad flags - - - - VLDTR_E_CT_NOTYPEDEFID - "ExportedType has nil TypeDefId." - ExportedType has nil TypeDefId - - - - VLDTR_E_FILE_BADFLAGS - "File has bad flags." - File has bad flags - - - - VLDTR_E_FILE_NULLHASH - "File has no hash blob." - File has no hash blob - - - - VLDTR_E_MOD_NONAME - "Module has no name." - Module has no name - - - - VLDTR_E_MOD_NAMEFULLQLFD - "Module has fully-qualified name." - Module has fully-qualified name - - - - VLDTR_E_TD_RTSPCLNOTSPCL - "TypeDef is tdRTSpecialName but not tdSpecialName." - TypeDef is tdRTSpecialName but not tdSpecialName - - - - VLDTR_E_TD_EXTENDSIFACE - "TypeDef extends interface." - TypeDef extends interface - - - - VLDTR_E_MD_CTORPINVOKE - ".ctor or .cctor is PInvokeImpl." - .ctor,.cctor is PInvokeImpl - - - - VLDTR_E_TD_SYSENUMNOTCLASS - "System.Enum is not a class." - System.Enum is not a class - - - - VLDTR_E_TD_SYSENUMNOTEXTVTYPE - "System.Enum extends not System.ValueType." - System.Enum extends not System.ValueType - - - - VLDTR_E_MI_SIGMISMATCH - "MethodImpl's Decl and Body signatures mismatch." - MethodImpl's Decl and Body signatures mismatch - - - - VLDTR_E_TD_ENUMHASMETHODS - "TypeDef extends System.Enum but has methods." - TypeDef extends System.Enum but has methods - - - - VLDTR_E_TD_ENUMIMPLIFACE - "TypeDef extends System.Enum but implements an interface." - TypeDef extends System.Enum but impls interface(s) - - - - VLDTR_E_TD_ENUMHASPROP - "TypeDef extends System.Enum but has a property." - TypeDef extends System.Enum but has prop(s) - - - - VLDTR_E_TD_ENUMHASEVENT - "TypeDef extends System.Enum but has an event." - TypeDef extends System.Enum but has event(s) - - - - VLDTR_E_TD_BADMETHODLST - "TypeDef has MethodList > Nmethods+1." - TypeDef has MethodList > Nmethods+1 - - - - VLDTR_E_TD_BADFIELDLST - "TypeDef has FieldList > Nfields+1." - TypeDef has FieldList > Nfields+1 - - - - VLDTR_E_CN_BADTYPE - "Constant has wrong type." - Constant has wrong type - - - - VLDTR_E_TD_ENUMNOINSTFLD - "Enum has no instance fields." - Enum has no instance fields - - - - VLDTR_E_TD_ENUMMULINSTFLD - "Enum has multiple instance fields." - Enum has multiple instance fields - - - - VLDTR_E_INTERRUPTED - "Validator has been interrupted by the VEHandler." - Validator has been interrupted by the VEHandler. - - - - VLDTR_E_NOTINIT - "Validator failed to initialize correctly." - Validator failed to initialize correctly. - - - - CORDBG_E_UNRECOVERABLE_ERROR - "Unrecoverable API error." - Unrecoverable API error. - - - - CORDBG_E_PROCESS_TERMINATED - "Process was terminated." - Process was terminated. - - - - CORDBG_E_PROCESS_NOT_SYNCHRONIZED - "Process not synchronized." - Process not synchronized. - - - - CORDBG_E_CLASS_NOT_LOADED - "A class is not loaded." - A class is not loaded. - - - - CORDBG_E_IL_VAR_NOT_AVAILABLE - "An IL variable is not available at the current native IP." - An IL variable is not available at the - - - - CORDBG_E_BAD_REFERENCE_VALUE - "A reference value was found to be bad during dereferencing." - A reference value was found to be bad - - - - CORDBG_E_FIELD_NOT_AVAILABLE - "A field in a class is not available, because the runtime optimized it away." - A field in a class is not available, - - - - CORDBG_E_NON_NATIVE_FRAME - "'Native-frame-only' operation on non-native frame." - "Native frame only" operation on - - - - CORDBG_E_NONCONTINUABLE_EXCEPTION - "Cannot Continue on non-continuable exception." - Continue on non-continuable exception - - - - CORDBG_E_CODE_NOT_AVAILABLE - "The code is currently unavailable." - The code is currently unavailable - - - - CORDBG_E_FUNCTION_NOT_IL - "Attempt to get a ICorDebugFunction for a function that is not IL." - Attempt to get a ICorDebugFunction for - - - - CORDBG_E_CANT_SET_IP_INTO_FINALLY - "SetIP is not possible because SetIP would move EIP from outside of an exception handling finally clause to a point inside of one." - SetIP isn't possible, because SetIP would - - - - CORDBG_E_CANT_SET_IP_OUT_OF_FINALLY - "SetIP is not possible because it would move EIP from within an exception handling finally clause to a point outside of one." - SetIP isn't possible because it would move - - - - CORDBG_E_CANT_SET_IP_INTO_CATCH - "SetIP is not possible, because SetIP would move EIP from outside of an exception handling catch clause to a point inside of one." - SetIP isn't possible, because SetIP would - - - - CORDBG_E_SET_IP_NOT_ALLOWED_ON_NONLEAF_FRAME - "SetIP cannot be done on any frame except the leaf frame." - Setip cannot be done on any frame except - - - - CORDBG_E_SET_IP_IMPOSSIBLE - "SetIP is not allowed." - SetIP isn't allowed. For example, there is - - - - CORDBG_E_FUNC_EVAL_BAD_START_POINT - "Func eval cannot work. Bad starting point." - Func eval can't work if we're, for example, - - - - CORDBG_E_INVALID_OBJECT - "This object value is no longer valid." - This object value is no longer valid. - - - - CORDBG_E_FUNC_EVAL_NOT_COMPLETE - "CordbEval::GetResult called before func eval has finished." - If you call CordbEval::GetResult before the - - - - CORDBG_E_INPROC_NOT_IMPL - "The in-process version of the debugging API does not support this function." - The inproc version of the debugging API - - - - CORDBG_E_STATIC_VAR_NOT_AVAILABLE - "A static variable is not available because it has not been initialized yet." - A static variable isn't available because - - - - CORDBG_E_OBJECT_IS_NOT_COPYABLE_VALUE_CLASS - "Cannot copy a VC with object refs in it." - Can't copy a VC with object refs in it. - - - - CORDBG_E_CANT_SETIP_INTO_OR_OUT_OF_FILTER - "SetIP cannot leave or enter a filter." - SetIP can't leave or enter a filter - - - - CORDBG_E_CANT_CHANGE_JIT_SETTING_FOR_ZAP_MODULE - "JIT settings for ZAP modules cannot be changed." - You can't change JIT settings for ZAP - - - - CORDBG_E_CANT_SET_IP_OUT_OF_FINALLY_ON_WIN64 - "SetIP is not possible because it would move EIP from within a finally clause to a point outside of one on WIN64 platforms." - SetIP isn't possible because it would move - - - - CORDBG_E_CANT_SET_IP_OUT_OF_CATCH_ON_WIN64 - "SetIP is not possible because it would move EIP from within a catch clause to a point outside of one on WIN64 platforms." - SetIP isn't possible because it would move - - - - CORDBG_E_REMOTE_CONNECTION_CONN_RESET - "The remote device closed the connection." - The remote device closed the connection. - - - - CORDBG_E_REMOTE_CONNECTION_KEEP_ALIVE - "The connection was closed due to a keep-alive failure." - The connection was closed due to akeep alive failure. - - - - CORDBG_E_REMOTE_CONNECTION_FATAL_ERROR - "Generic error that the device connection has been broken with no chance for recovery." - Generic error that the device connection has been broken with no chance for recovery. - - - - CORDBG_E_CANT_SET_TO_JMC - "Cannot use JMC on this code (likely wrong JIT settings)." - Can't use JMC on this code (likely wrong jit settings). - - - - CORDBG_E_NO_CONTEXT_FOR_INTERNAL_FRAME - "Internal frame markers have no associated context." - Internal frame markers have no associated context. - - - - CORDBG_E_NOT_CHILD_FRAME - "The current frame is not a child frame." - The current frame is not a child frame. - - - - CORDBG_E_NON_MATCHING_CONTEXT - "The provided CONTEXT does not match the specified thread." - The provided CONTEXT does not match the specified thread. - The stack pointer in the provided CONTEXT must match the cached stack base and stack limit of the thread. - - - - - CORDBG_E_PAST_END_OF_STACK - "The stackwalker is now past the end of stack. No information is available." - The stackwalker is now past the end of stack. No information is available. - - - - CORDBG_E_FUNC_EVAL_CANNOT_UPDATE_REGISTER_IN_NONLEAF_FRAME - "Func eval cannot update a variable stored in a register on a non-leaf frame. The most likely cause is that such a variable is passed as a ref/out argument." - Func eval cannot update a variable stored in a register on a non-leaf frame. The most likely cause is that such a variable is passed as a ref/out argument. - - - - CORDBG_E_BAD_THREAD_STATE - "The state of the thread is invalid." - The state of the thread is invalid. - - - - CORDBG_E_DEBUGGER_ALREADY_ATTACHED - "This process has already been attached." - This process has already been attached to - - - - CORDBG_E_SUPERFLOUS_CONTINUE - "Returned from a call to Continue that was not matched with a stopping event." - Returned from a call to Continue that was - - - - CORDBG_E_SET_VALUE_NOT_ALLOWED_ON_NONLEAF_FRAME - "Cannot perfrom SetValue on non-leaf frames." - Can't perfrom SetValue on non-leaf frames. - - - - CORDBG_E_ENC_EH_MAX_NESTING_LEVEL_CANT_INCREASE - "When doing Edit and Continue, some JITs do not allow increasing the maximum level to which exception handling can be nested." - When doing EnC, some JITters don't let you - - - - CORDBG_E_ENC_MODULE_NOT_ENC_ENABLED - "Tried to do Edit and Continue on a module that was not started in Edit and Continue mode." - Tried to do EnC on a module that wasn't - - - - CORDBG_E_SET_IP_NOT_ALLOWED_ON_EXCEPTION - "SetIP cannot be done on any exception." - Setip cannot be done on any exception - - - - CORDBG_E_VARIABLE_IS_ACTUALLY_LITERAL - "The 'variable' does not exist because it is a literal optimized away by the compiler." - The 'variable' doesn't exist because it is a - - - - CORDBG_E_PROCESS_DETACHED - "Process has been detached." - Process has been detached from - - - - CORDBG_E_ENC_METHOD_SIG_CHANGED - "Not allowed to change the signature of an existing method." - Not allowed to change the signature of an - - - - CORDBG_E_ENC_METHOD_NO_LOCAL_SIG - "Cannot get the local signature for the method." - Can't get the local signature for the method - - - - CORDBG_E_ENC_CANT_ADD_FIELD_TO_VALUE_OR_LAYOUT_CLASS - "Adding a field to a value or layout class is prohibited." - Adding a field to a value or layout class is prohibitted, - - - - CORDBG_E_ENC_CANT_CHANGE_FIELD - "Cannot change field after adding." - Once you've got a field, you're not allowed to change - - - - CORDBG_E_ENC_CANT_ADD_NON_PRIVATE_MEMBER - "Only support addition of private members." - Only support addition of private members. - - - - CORDBG_E_FIELD_NOT_STATIC - "GetStaticFieldValue called on a non-static field." - Returned if someone tries to call GetStaticFieldValue - - - - CORDBG_E_FIELD_NOT_INSTANCE - "Returned if someone tries to call GetStaticFieldValue on a non-instance field." - Returned if someone tries to call GetStaticFieldValue - - - - CORDBG_E_ENC_ZAPPED_WITHOUT_ENC - "If a zap file was created without the Edit and Continue flag set, then we cannot do Edit and Continue on it, no matter what." - If a zap file was created without the EnC flag set, then - - - - CORDBG_E_ENC_BAD_METHOD_INFO - "Lacking information about method." - Lacking information about method. - - - - CORDBG_E_ENC_JIT_CANT_UPDATE - "The JIT is unable to update the method." - The JIT is unable to update the method. - - - - CORDBG_E_ENC_MISSING_CLASS - "An internal structure about the class is missing." - An internal structure about the class is missing - - - - CORDBG_E_ENC_INTERNAL_ERROR - "Internal Runtime Error while doing Edit-and-Continue." - Generic message for "Something user doesn't control went wrong" message. - - - - CORDBG_E_ENC_HANGING_FIELD - "The field was added via Edit and Continue after the class was loaded." - The field was added via EnC after the class was loaded, and so instead of the the field being contiguous with the other fields, it's 'hanging' off the instance or type. This error is used to indicate that either the storage for this field is not yet available and so the field value cannot be read, or the debugger needs to use an EnC specific code path to get the value. - - - - CORDBG_E_MODULE_NOT_LOADED - "Module not loaded." - If the module isn't loaded, including if it's been unloaded. - - - - CORDBG_E_ENC_CANT_CHANGE_SUPERCLASS - "Not allowed to change base class." - Not allowed to change which class something inherits from - - - - CORDBG_E_UNABLE_TO_SET_BREAKPOINT - "Cannot set a breakpoint here." - Can't set a breakpoint here. - - - - CORDBG_E_DEBUGGING_NOT_POSSIBLE - "Debugging is not possible due to an incompatibility within the CLR implementation." - Debugging isn't possible due to an incompatibility within the CLR implementation. - - - - CORDBG_E_KERNEL_DEBUGGER_ENABLED - "A kernel debugger is enabled on the system. User-mode debugging will trap to the kernel debugger." - Debugging isn't possible because a kernel debugger is enabled on the system. - - - - CORDBG_E_KERNEL_DEBUGGER_PRESENT - "A kernel debugger is present on the system. User-mode debugging will trap to the kernel debugger." - Debugging isn't possible because a kernel debugger is present on the system. - - - - CORDBG_E_HELPER_THREAD_DEAD - "The debugger's internal helper thread is dead." - The debugger's internal helper thread is dead. - - - - CORDBG_E_INTERFACE_INHERITANCE_CANT_CHANGE - "Not allowed to change interface inheritance." - Not allowed to change interface inheritance. - - - - CORDBG_E_INCOMPATIBLE_PROTOCOL - "The debugger's protocol is incompatible with the debuggee." - The debugger's protocol is incompatible with the debuggee. - - - - CORDBG_E_TOO_MANY_PROCESSES - "The debugger can only handle a finite number of debuggees." - The debugger can only handle a finite number of debuggees. - - - - CORDBG_E_INTEROP_NOT_SUPPORTED - "Interop debugging is not supported." - Interop debugging is not supported - - - - CORDBG_E_NO_REMAP_BREAKPIONT - "Cannot call RemapFunction until have received RemapBreakpoint." - Cannot call RemapFunction until have received RemapBreakpoint - - - - CORDBG_E_OBJECT_NEUTERED - "Object is in a zombie state." - Object has been neutered (it's in a zombie state). - - - - CORPROF_E_FUNCTION_NOT_COMPILED - "Function not yet compiled." - Function not yet compiled. - - - - CORPROF_E_DATAINCOMPLETE - "The ID is not fully loaded/defined yet." - The ID is not fully loaded/defined yet. - - - - CORPROF_E_NOT_REJITABLE_METHODS - "The Module is not configured for updateable methods." - The Module is not configured for updateable methods. - - - - CORPROF_E_CANNOT_UPDATE_METHOD - "The Method could not be updated for re-JIT." - The Method could not be updated for re-jit. - - - - CORPROF_E_FUNCTION_NOT_IL - "The Method has no associated IL." - The Method has no associated IL - - - - CORPROF_E_NOT_MANAGED_THREAD - "The thread has never run managed code before." - The thread has never run managed code before - - - - CORPROF_E_CALL_ONLY_FROM_INIT - "The function may only be called during profiler initialization." - The function may only be called during profiler init - - - - CORPROF_E_INPROC_NOT_ENABLED - "In-process debugging must be enabled during initialization." - Inprocess debugging must be enabled during init - - - - CORPROF_E_JITMAPS_NOT_ENABLED - "Cannot get a JIT map becuase they are not enabled." - Can't get a JIT map becuase they are not enabled - - - - CORPROF_E_INPROC_ALREADY_BEGUN - "BeginInprocDebugging already called." - If a profiler tries to call BeginInprocDebugging more than - - - - CORPROF_E_INPROC_NOT_AVAILABLE - "In-process debugging not allowed at this point." - States that inprocess debugging not allowed at this point - - - - CORPROF_E_NOT_YET_AVAILABLE - "Requested information is not yet available." - This is a general error used to indicated that the information - - - - CORPROF_E_TYPE_IS_PARAMETERIZED - "The given type is a generic and cannot be used with this method." - The given type is a generic and cannot be used with this method. - - - - CORPROF_E_FUNCTION_IS_PARAMETERIZED - "The given function is a generic and cannot be used with this method." - The given function is a generic and cannot be used with this method. - - - - CORPROF_E_STACKSNAPSHOT_INVALID_TGT_THREAD - A profiler tried to walk the stack of an invalid thread - - - - CORPROF_E_STACKSNAPSHOT_UNMANAGED_CTX - A profiler can not walk a thread that is currently executing unmanaged code - - - - CORPROF_E_STACKSNAPSHOT_UNSAFE - A stackwalk at this point may cause dead locks or data corruption - - - - CORPROF_E_STACKSNAPSHOT_ABORTED - Stackwalking callback requested the walk to abort - - - - CORPROF_E_LITERALS_HAVE_NO_ADDRESS - Returned when asked for the address of a static that is a literal. - - - - CORPROF_E_UNSUPPORTED_CALL_SEQUENCE - A call was made at an unsupported time. Examples include illegally calling a profiling API method asynchronously, calling a method that might trigger a GC at an unsafe time, and calling a method at a time that could cause locks to be taken out of order. - - - - CORPROF_E_ASYNCHRONOUS_UNSAFE - A legal asynchronous call was made at an unsafe time (e.g., CLR locks are held) - - - - CORPROF_E_CLASSID_IS_ARRAY - The specified ClassID cannot be inspected by this function because it is an array - - - - CORPROF_E_CLASSID_IS_COMPOSITE - The specified ClassID is a non-array composite type (e.g., ref) and cannot be inspected - - - - CORPROF_E_PROFILER_DETACHING - The profiler's call into the CLR is disallowed because the profiler is attempting to detach. - - - - CORPROF_E_PROFILER_NOT_ATTACHABLE - The profiler does not support attaching to a live process. - - - - CORPROF_E_UNRECOGNIZED_PIPE_MSG_FORMAT - The message sent on the profiling API attach pipe is in an unrecognized format. - - - - CORPROF_E_PROFILER_ALREADY_ACTIVE - The request to attach a profiler was denied because a profiler is already loaded. - - - - CORPROF_E_PROFILEE_INCOMPATIBLE_WITH_TRIGGER - Unable to request a profiler attach because the target profilee's runtime is of a version incompatible with the current process calling AttachProfiler(). - - - - CORPROF_E_IPC_FAILED - AttachProfiler() encountered an error while communicating on the pipe to the target profilee. This is often caused by a target profilee that is shutting down or killed while AttachProfiler() is reading or writing the pipe. - - - - CORPROF_E_PROFILEE_PROCESS_NOT_FOUND - AttachProfiler() was unable to find a profilee with the specified process ID. - - - - CORPROF_E_CALLBACK3_REQUIRED - Profiler must implement ICorProfilerCallback3 interface for this call to be supported. - - - - CORPROF_E_UNSUPPORTED_FOR_ATTACHING_PROFILER - This call was attempted by a profiler that attached to the process after startup, but this call is only supported by profilers that are loaded into the process on startup. - - - - CORPROF_E_IRREVERSIBLE_INSTRUMENTATION_PRESENT - Detach is impossible because the profiler has either instrumented IL or inserted enter/leave hooks. Detach was not attempted; the profiler is still fully attached. - - - - CORPROF_E_RUNTIME_UNINITIALIZED - The profiler called a function that cannot complete because the CLR is not yet fully initialized. The profiler may try again once the CLR has fully started. - - - - CORPROF_E_IMMUTABLE_FLAGS_SET - Detach is impossible because immutable flags were set by the profiler at startup. Detach was not attempted; the profiler is still fully attached. - - - - CORPROF_E_PROFILER_NOT_YET_INITIALIZED - The profiler called a function that cannot complete because the profiler is not yet fully initialized. - - - - CORPROF_E_INCONSISTENT_WITH_FLAGS - The profiler called a function that first requires additional flags to be set in the event mask. This HRESULT may also indicate that the profiler called a function that first requires that some of the flags currently set in the event mask be reset. - - - - CORPROF_E_PROFILER_CANCEL_ACTIVATION - The profiler has requested that the CLR instance not load the profiler into this process. - - - - CORPROF_E_CONCURRENT_GC_NOT_PROFILABLE - Concurrent GC mode is enabled, which prevents use of COR_PRF_MONITOR_GC - - - - CORPROF_E_INCONSISTENT_FLAGS_WITH_HOST_PROTECTION_SETTING - Host enforces host protection attributes, which prevents use of COR_PRF_USE_PROFILE_IMAGES, COR_PRF_MONITOR_CODE_TRANSITIONS, and COR_PRF_MONITOR_ENTERLEAVE - - - - CORPROF_E_DEBUGGING_DISABLED - This functionality requires CoreCLR debugging to be enabled. - - - - CORPROF_E_TIMEOUT_WAITING_FOR_CONCURRENT_GC - Timed out on waiting for concurrent GC to finish during attach. - - - - CORPROF_E_MODULE_IS_DYNAMIC - The specified module was dynamically generated (e.g., via Reflection.Emit API), and is thus not supported by this API method. - - - - CORPROF_E_CALLBACK4_REQUIRED - Profiler must implement ICorProfilerCallback4 interface for this call to be supported. - - - - CORPROF_E_REJIT_NOT_ENABLED - This call is not supported unless ReJIT is first enabled during initialization by setting COR_PRF_ENABLE_REJIT via SetEventMask. - - - - CORPROF_E_ACTIVE_REJIT_REQUEST_NOT_FOUND - Could not revert the specified method, because a corresponding active ReJIT request was not found. Either the method was never requested to be reJITted OR the method was already reverted. - - - - CORPROF_E_FUNCTION_IS_COLLECTIBLE - The specified function is instantiated into a collectible assembly, and is thus not supported by this API method. - - - - CORPROF_E_REJIT_REQUIRES_DISABLE_NGEN - If the profiler specifies COR_PRF_ENABLE_REJIT to SetEventMask, it must also specify COR_PRF_DISABLE_ALL_NGEN_IMAGES. - - - - CORPROF_E_CALLBACK6_REQUIRED - Profiler must implement ICorProfilerCallback6 interface for this call to be supported. - - - - - - CORPROF_E_CALLBACK7_REQUIRED - Profiler must implement ICorProfilerCallback7 interface for this call to be supported. - - - - SECURITY_E_XML_TO_ASN_ENCODING - "Failed to convert XML to ASN." - Failed to convert XML to ASN - - - - SECURITY_E_INCOMPATIBLE_SHARE - "Loading this assembly would produce a different grant set from other instances." - Loading this assembly would produce a different grant set from other instances - - - - SECURITY_E_UNVERIFIABLE - "Unverifiable code failed policy check." - Unverifable code failed policy check - - - - SECURITY_E_INCOMPATIBLE_EVIDENCE - "Assembly already loaded without additional security evidence." - Assembly already loaded without additional security evidence. - - - - CORSEC_E_DECODE_SET - "Failure decoding permission set." - Failure decoding permission set - - - - CORSEC_E_ENCODE_SET - "Failure encoding permission set." - Failure encoding permission set - - - - CORSEC_E_UNSUPPORTED_FORMAT - "Unrecognized encoding format." - Unrecognized encoding format - - - - SN_CRYPTOAPI_CALL_FAILED - StrongName APIs not supported on system - - - - CORSEC_E_CRYPTOAPI_CALL_FAILED - "StrongName APIs not supported on system." - StrongName APIs not supported on system - - - - SN_NO_SUITABLE_CSP - StrongName APIs couldn't locate a matching CSP - - - - CORSEC_E_NO_SUITABLE_CSP - "StrongName APIs could not locate a matching CSP." - StrongName APIs couldn't locate a matching CSP - - - - CORSEC_E_INVALID_ATTR - "Invalid security custom attribute." - Invalid security custom attribute - - - - CORSEC_E_POLICY_EXCEPTION - "PolicyException thrown." - PolicyException thrown - - - - CORSEC_E_MIN_GRANT_FAIL - "Failed to grant minimum permission requests." - Failed to grant minimum permission requests - - - - CORSEC_E_NO_EXEC_PERM - "Failed to grant permission to execute." - Failed to grant permission to execute - - - - CORSEC_E_XMLSYNTAX - "XML Syntax error." - XML Syntax error - - - - CORSEC_E_INVALID_STRONGNAME - "Strong name validation failed." - Strong name validation failed - - - - CORSEC_E_MISSING_STRONGNAME - "Assembly is not strong named." - Assembly is not strong named - - - - CORSEC_E_CONTAINER_NOT_FOUND - "Strong name key container not found." - Strong name key container not found - - - - CORSEC_E_INVALID_IMAGE_FORMAT - "Invalid assembly file format." - Invalid assembly file format - - - - CORSEC_E_INVALID_PUBLICKEY - "Invalid assembly public key." - Invalid assembly public key - - - - CORSEC_E_SIGNATURE_MISMATCH - "Signature size mismatch." - Signature size mismatch - - - - SN_E_PUBLICKEY_MISMATCH - "Public key of assembly did not match signing public key." - Public key of assembly did not match signing public key - - - - CORSEC_E_INVALID_SIGNATUREKEY - "Invalid signature public key specified in AssemblySignatureKeyAttribute." - Invalid signature key (or invalid key format) specified in the assembly's attribute - - - - CORSEC_E_INVALID_COUNTERSIGNATURE - "Invalid countersignature specified in AssemblySignatureKeyAttribute." - Invalid signature (or invalid signature format) specified in the assembly's attribute - - - - CORSEC_E_CRYPTO - "Failure during Cryptographic operation." - generic CryptographicException - - - - CORSEC_E_CRYPTO_UNEX_OPER - "Unexpected Cryptographic operation." - generic CryptographicUnexpectedOperationException - - - - CORSECATTR_E_BAD_ATTRIBUTE - "Generic problem with a custom attribute." - Generic problem with a custom attribute - - - - CORSECATTR_E_MISSING_CONSTRUCTOR - "Missing a required constructor." - Missing a required constructor - - - - CORSECATTR_E_FAILED_TO_CREATE_PERM - "Unable to create a permission for this attribute." - Unable to create a permission for this attribute - - - - CORSECATTR_E_BAD_ACTION_ASM - "SecurityAction type invalid on assembly." - SecurityAction type invalid on assembly - - - - CORSECATTR_E_BAD_ACTION_OTHER - "SecurityAction type invalid on types and methods." - SecurityAction type invalid on types and methods - - - - CORSECATTR_E_BAD_PARENT - "Security custom attribute attached to invalid parent." - Security custom attribute attached to invalid parent - - - - CORSECATTR_E_TRUNCATED - "Bad custom attribute serialized blob." - Bad custom attribute serialized blob - - - - CORSECATTR_E_BAD_VERSION - "Bad custom attribute serialized blob version." - Bad custom attribute serialized blob version - - - - CORSECATTR_E_BAD_ACTION - "Invalid security action code." - Invalid security action code - - - - CORSECATTR_E_NO_SELF_REF - "CA reference to CA definition in same assembly." - CA ref to CA def'd in same assembly - - - - CORSECATTR_E_BAD_NONCAS - "Use of non-CAS permission with invalid action." - Use of non-CAS perm with invalid action - - - - CORSECATTR_E_ASSEMBLY_LOAD_FAILED - "Failed to load assembly containing CA (or required CA type)." - Failed to load assembly containing CA (or req'd CA type) - - - - CORSECATTR_E_ASSEMBLY_LOAD_FAILED_EX - "Failed to load assembly containing CA (or required CA type)." - Failed to load assembly containing CA (or req'd CA type) - - - - CORSECATTR_E_TYPE_LOAD_FAILED - "Failed to load CA type (or required CA type)." - Failed to load CA type (or reqd CA type) - - - - CORSECATTR_E_TYPE_LOAD_FAILED_EX - "Failed to load CA type (or required CA type)." - Failed to load CA type (or reqd CA type) - - - - CORSECATTR_E_ABSTRACT - "CA type is abstract." - CA type is abstract - - - - CORSECATTR_E_UNSUPPORTED_TYPE - "Security custom attributes do not support array or Type fields and properties." - Security custom attributes do not support array or Type fields and properties - - - - CORSECATTR_E_UNSUPPORTED_ENUM_TYPE - "Unsupported base type for enum field or property." - Unsupported base type for enum field/property - - - - CORSECATTR_E_NO_FIELD - "Could not find a CA field." - Couldn't find a CA field - - - - CORSECATTR_E_NO_PROPERTY - "Could not find a CA property." - Couldn't find a CA property - - - - CORSECATTR_E_EXCEPTION - "Unexpected exception." - Unexpected exception - - - - CORSECATTR_E_EXCEPTION_HR - "Unexpected exception." - Unexpected exception - - - - ISS_E_ISOSTORE_START - - - - ISS_E_ISOSTORE - "IsolatedStorage operation failed." - - - - ISS_E_OPEN_STORE_FILE - "Unable to open the store." - - - - ISS_E_OPEN_FILE_MAPPING - "Unable to create store file mapping." - - - - ISS_E_MAP_VIEW_OF_FILE - "Unable to map the store file." - - - - ISS_E_GET_FILE_SIZE - "Unable to determine store file size." - - - - ISS_E_CREATE_MUTEX - "Unable to create mutex." - - - - ISS_E_LOCK_FAILED - "Unable to lock the store." - - - - ISS_E_FILE_WRITE - "File Write failed." - - - - ISS_E_SET_FILE_POINTER - "Cannot set file pointer." - - - - ISS_E_CREATE_DIR - "Unable to create the store directory." - - - - ISS_E_STORE_NOT_OPEN - "Store must be open for this operation." - - - - ISS_E_CORRUPTED_STORE_FILE - "Store file is corrupt." - - - - ISS_E_STORE_VERSION - "Store version is not supported." - - - - ISS_E_FILE_NOT_MAPPED - "Store file is not mapped." - - - - ISS_E_BLOCK_SIZE_TOO_SMALL - "Block size is too small." - - - - ISS_E_ALLOC_TOO_LARGE - "Allocation size is too large." - - - - ISS_E_USAGE_WILL_EXCEED_QUOTA - "Allowed quota is fully used." - - - - ISS_E_TABLE_ROW_NOT_FOUND - "Row not found." - - - - ISS_E_DEPRECATE - "Unable to deprecate old store." - - - - ISS_E_CALLER - "Unable to determine the caller." - - - - ISS_E_PATH_LENGTH - "Path length is too long." - - - - ISS_E_MACHINE - "Machine Store is not supported." - - - - ISS_E_MACHINE_DACL - "The DACL for the machine store is incorrect or could not be created." - - - - ISS_E_ISOSTORE_END - - - - COR_E_EXCEPTION - "General Exception" - Base class for all exceptions in the runtime - - - - COR_E_SYSTEM - "System.Exception" - The base class for the runtime's "less serious" exceptions - - - - COR_E_ARGUMENTOUTOFRANGE - "An argument was out of its legal range." - An argument was out of its legal range. - - - - COR_E_ARRAYTYPEMISMATCH - "Attempted to store an object of the wrong type in an array." - Attempted to store an object of the wrong type in an array - - - - COR_E_CONTEXTMARSHAL - "Attempted to marshal an object across a context boundary." - - - - - COR_E_TIMEOUT - "Operation timed out." - - - - - COR_E_EXECUTIONENGINE - "Internal CLR error." - An internal error happened in the Common Language Runtime's Execution Engine - - - - COR_E_FIELDACCESS - "Access to this field is denied." - Access to this field is denied. - - - - COR_E_INDEXOUTOFRANGE - "Array subscript out of range." - Attempted to access an element within an array by using an index that is - - - - COR_E_INVALIDOPERATION - "An operation is not legal in the current state." - An operation is not legal in the current state. - - - - COR_E_SECURITY - "An error relating to security occurred." - An error relating to security occurred. - - - - COR_E_REMOTING - "An error relating to remoting occurred." - An error relating to remoting occurred. - - - - COR_E_SERIALIZATION - "An error relating to serialization occurred." - An error relating to serialization has occurred. - - - - COR_E_VERIFICATION - "A verification failure has occurred." - A verification failure occurred - - - - COR_E_SERVER - "An error relating to remoting occurred." - - - - COR_E_SERVICEDCOMPONENT - "An error relating to ServicedComponent occurred." - An error relating to ServicedComponent occurred. - - - - COR_E_METHODACCESS - "Access to this method is denied." - Access to this method is denied. - - - - COR_E_MISSINGFIELD - "Field does not exist." - An attempt was made to dynamically access a field that does not exist. - - - - COR_E_MISSINGMEMBER - "Member does not exist." - An attempt was made to dynamically invoke or access a field or method - - - - COR_E_MISSINGMETHOD - "Method does not exist." - An attempt was made to dynamically invoke a method that does not exist - - - - COR_E_MULTICASTNOTSUPPORTED - "Attempt to combine delegates that are not multicast." - Attempted to combine delegates that are not multicast - - - - COR_E_NOTSUPPORTED - "Operation is not supported." - The operation is not supported - - - - COR_E_OVERFLOW - "Arithmetic, casting or conversion operation overflowed or underflowed." - An arithmetic, casting, or conversion operation overflowed or underflowed. - - - - COR_E_RANK - "An array has the wrong number of dimensions for a particular operation." - An array has the wrong number of dimensions for a particular operation. - - - - COR_E_SYNCHRONIZATIONLOCK - "This operation must be called from a synchronized block." - Wait(), Notify() or NotifyAll() was called from an unsynchronized ** block of c - - - - COR_E_THREADINTERRUPTED - "Thread was interrupted from a waiting state." - Indicates that the thread was interrupted from a waiting state - - - - COR_E_MEMBERACCESS - "Access to this member is denied." - Access to this member is denied. - - - - COR_E_THREADSTATE - "Thread is in an invalid state for this operation." - Indicate that the Thread class is in an invalid state for the method call - - - - COR_E_THREADSTOP - "Thread is stopping." - Thrown into a thread to cause it to stop. This exception is typically not caught - - - - COR_E_TYPELOAD - "Could not find or load a type." - Could not find or load a specific type (class, enum, etc). - - - - COR_E_ENTRYPOINTNOTFOUND - "Could not find the specified DllImport entrypoint." - Could not find the specified DllImport entry point - - - - COR_E_DLLNOTFOUND - "Could not find the specified DllImport Dll." - Could not find the specified DllImport DLL. - - - - COR_E_THREADSTART - Indicate that a user thread fails to start. - - - - COR_E_INVALIDCOMOBJECT - "An invalid __ComObject has been used." - An invalid __ComObject has been used. - - - - COR_E_NOTFINITENUMBER - "Not a Number." - Thrown if value (a floating point number) is either the not a number value (NaN) or +- infinity value - - - - COR_E_DUPLICATEWAITOBJECT - "An object appears more than once in the wait objects array." - An object appears more than once in the wait objects array. - - - - COR_E_SEMAPHOREFULL - "Reached maximum count for semaphore." - Adding the given count to the semaphore would cause it to exceed its maximum count. - - - - COR_E_WAITHANDLECANNOTBEOPENED - "No semaphore of the given name exists." - No Semaphore of the given name exists. - - - - COR_E_ABANDONEDMUTEX - "The wait completed due to an abandoned mutex." - The wait completed due to an abandoned mutex. - - - - COR_E_THREADABORTED - "Thread has aborted." - Thrown into a thread to cause it to abort. Not catchable. - - - - COR_E_INVALIDOLEVARIANTTYPE - "OLE Variant has an invalid type." - The type of an OLE variant that was passed into the runtime is invalid. - - - - COR_E_MISSINGMANIFESTRESOURCE - "An expected resource in the assembly manifest was missing." - An expected resource in the assembly manifest was missing. - - - - COR_E_SAFEARRAYTYPEMISMATCH - "A mismatch has occurred between the runtime type of the array and the sub type recorded in the metadata." - A mismatch has occurred between the runtime type of the array and the subtype recorded in the metadata - - - - COR_E_TYPEINITIALIZATION - "Uncaught exception during type initialization." - An exception was thrown by a type's initializer (.cctor). - - - - COR_E_MARSHALDIRECTIVE - "Invalid marshaling directives." - The marshaling directives are invalid. - - - - COR_E_MISSINGSATELLITEASSEMBLY - "An expected satellite assembly containing the ultimate fallback resources for a given culture was not found or could not be loaded." - An expected satellite assembly containing the ultimate fallback resources - - - - COR_E_FORMAT - "The format of one argument does not meet the contract of the method." - The format of one argument does not meet the contract of the method. - - - - COR_E_SAFEARRAYRANKMISMATCH - "A mismatch has occurred between the runtime rank of the array and the rank recorded in the metadata." - A mismatch has occurred between the runtime rank of the array and the rank recorded in the metadata - - - - COR_E_PLATFORMNOTSUPPORTED - "Operation is not supported on this platform." - The method is not supported on this platform - - - - COR_E_INVALIDPROGRAM - "Invalid IL or CLR metadata." - A program contained invalid IL or bad metadata. Usually this is a compiler bug. - - - - COR_E_OPERATIONCANCELED - "The operation was cancelled." - The operation was cancelled. - - - - COR_E_INSUFFICIENTMEMORY - Not enough memory was available for an operation. - - - - COR_E_RUNTIMEWRAPPED - An object that does not derive from System.Exception has been wrapped in a RuntimeWrappedException. - - - - COR_E_DEVICESNOTSUPPORTED - "Devices not supported." - - - - - COR_E_DATAMISALIGNED - "A datatype misalignment was detected in a load or store instruction." - A datatype misalignment was detected in a load or store instruction. - - - - COR_E_CODECONTRACTFAILED - "A managed code contract (ie, precondition, postcondition, invariant, or assert) failed." - A managed code contract (ie, precondition, postcondition, invariant, or assert) failed. - - - - COR_E_TYPEACCESS - "Access to this type is denied." - Access to this type is denied. - - - - COR_E_ACCESSING_CCW - "Fail to access a CCW because the corresponding managed object is already collected." - Fail to access a CCW because the corresponding managed object is already collected. - - - - COR_E_MAXMETHODSIZE - "A method in this assembly is greater than the maximum allowed method size." - This is Apollo only. - - - - - COR_E_KEYNOTFOUND - "The given key was not present in the dictionary." - - - - - COR_E_INSUFFICIENTEXECUTIONSTACK - "Insufficient stack to continue executing the program safely. This can happen from having too many functions on the call stack or function on the stack using too much stack space." - Insufficient stack to continue executing the program safely. This can happen from having too many functions on the call stack or function on the stack using too much stack space. - - - - COR_E_APPLICATION - "Application exception" - The base class for all "less serious" exceptions. - - - - COR_E_INVALIDFILTERCRITERIA - "The given filter criteria does not match the filter content." - The given filter criteria does not match the filter contract. - - - - COR_E_REFLECTIONTYPELOAD - "Could not find or load a specific class that was requested through Reflection." - Could not find or load a specific class that was requested through Reflection - - - - COR_E_TARGET - "Attempt to invoke non-static method with a null Object." - - If you attempt to invoke a non-static method with a null Object - If you atte - - - - COR_E_TARGETINVOCATION - "Uncaught exception thrown by method called through Reflection." - If the method called throws an exception - - - - COR_E_CUSTOMATTRIBUTEFORMAT - "Custom attribute has invalid format." - If the binary format of a custom attribute is invalid. - - - - COR_E_IO - "Error during managed I/O." - Some sort of I/O error. - - - - COR_E_FILELOAD - "Could not find or load a specific file." - - - - - COR_E_OBJECTDISPOSED - "The object has already been disposed." - The object has already been disposed. - - - - COR_E_FAILFAST - "Runtime operation halted by call to System.Environment.FailFast()." - Runtime operation halted by call to System.Environment.FailFast(). - - - - COR_E_HOSTPROTECTION - "The host has forbidden this operation." - Attempted to perform an operation that was forbidden by the host. - - - - COR_E_ILLEGAL_REENTRANCY - "Attempted to call into managed code when executing inside a low level extensibility point." - Attempted to call into managed code when executing inside a low level extensibility point. - - - - CLR_E_SHIM_RUNTIMELOAD - "Failed to load the runtime." - Failed to load the runtime - - - - CLR_E_SHIM_RUNTIMEEXPORT - "Failed to find a required export in the runtime." - Failed to find a required export in the runtime - - - - CLR_E_SHIM_INSTALLROOT - "Install root is not defined." - Install root is not defined - - - - CLR_E_SHIM_INSTALLCOMP - "Expected component of the runtime is not available." - Expected component of the runtime is not available - - - - CLR_E_SHIM_LEGACYRUNTIMEALREADYBOUND - "A runtime has already been bound for legacy activation policy use." - - - - CLR_E_SHIM_SHUTDOWNINPROGRESS - "The operation is invalid because the process may be shutting down." - - - - VER_E_HRESULT - - - - VER_E_OFFSET - - - - VER_E_OPCODE - - - - VER_E_OPERAND - - - - VER_E_TOKEN - - - - VER_E_EXCEPT - - - - VER_E_STACK_SLOT - - - - VER_E_LOC - - - - VER_E_ARG - - - - VER_E_FOUND - - - - VER_E_EXPECTED - - - - VER_E_LOC_BYNAME - - - - VER_E_UNKNOWN_OPCODE - "Unknown opcode." - - - - VER_E_SIG_CALLCONV - "Unknown calling convention." - - - - VER_E_SIG_ELEMTYPE - "Unknown ELEMENT_TYPE." - - - - VER_E_RET_SIG - "[return sig]" - - - - VER_E_FIELD_SIG - "[field sig]" - - - - VER_E_OPEN_DLGT_PROT_ACC - "Protected method access through an open instance delegate is not verifiable." - - - - VER_E_INTERNAL - "Internal error." - - - - VER_E_STACK_TOO_LARGE - "Stack is too large." - - - - VER_E_ARRAY_NAME_LONG - "Array name is too long." - - - - VER_E_FALLTHRU - "fall through end of the method without returning" - - - - VER_E_TRY_GTEQ_END - "try start >= try end" - - - - VER_E_TRYEND_GT_CS - "try end > code size" - - - - VER_E_HND_GTEQ_END - "handler start >= handler end" - - - - VER_E_HNDEND_GT_CS - "handler end > code size" - - - - VER_E_FLT_GTEQ_CS - - - - VER_E_TRY_START - "Try starts in the middle of an instruction." - - - - VER_E_HND_START - "Handler starts in the middle of an instruction." - - - - VER_E_FLT_START - - - - VER_E_TRY_OVERLAP - "Try block overlap with another block." - - - - VER_E_TRY_EQ_HND_FIL - "Try and filter/handler blocks are equivalent." - - - - VER_E_TRY_SHARE_FIN_FAL - "Shared try has finally or fault handler." - - - - VER_E_HND_OVERLAP - "Handler block overlaps with another block." - - - - VER_E_HND_EQ - "Handler block is the same as another block." - - - - VER_E_FIL_OVERLAP - "Filter block overlaps with another block." - - - - VER_E_FIL_EQ - "Filter block is the same as another block." - - - - VER_E_FIL_CONT_TRY - "Filter contains try." - - - - VER_E_FIL_CONT_HND - "Filter contains handler." - - - - VER_E_FIL_CONT_FIL - "Nested filters." - - - - VER_E_FIL_GTEQ_CS - "filter >= code size" - - - - VER_E_FIL_START - "Filter starts in the middle of an instruction." - - - - VER_E_FALLTHRU_EXCEP - "fallthru the end of an exception block" - - - - VER_E_FALLTHRU_INTO_HND - "fallthru into an exception handler" - - - - VER_E_FALLTHRU_INTO_FIL - "fallthru into an exception filter" - - - - VER_E_LEAVE - "Leave from outside a try or catch block." - - - - VER_E_RETHROW - "Rethrow from outside a catch handler." - - - - VER_E_ENDFINALLY - "Endfinally from outside a finally handler" - - - - VER_E_ENDFILTER - "Endfilter from outside an exception filter block" - - - - VER_E_ENDFILTER_MISSING - "Missing Endfilter." - - - - VER_E_BR_INTO_TRY - "Branch into try block." - - - - VER_E_BR_INTO_HND - "Branch into exception handler block." - - - - VER_E_BR_INTO_FIL - "Branch into exception filter block." - - - - VER_E_BR_OUTOF_TRY - "Branch out of try block." - - - - VER_E_BR_OUTOF_HND - "Branch out of exception handler block." - - - - VER_E_BR_OUTOF_FIL - "Branch out of exception filter block." - - - - VER_E_BR_OUTOF_FIN - "Branch out of finally block." - - - - VER_E_RET_FROM_TRY - "Return out of try block." - - - - VER_E_RET_FROM_HND - "Return out of exception handler block." - - - - VER_E_RET_FROM_FIL - "Return out of exception filter block." - - - - VER_E_BAD_JMP_TARGET - "jmp / exception into the middle of an instruction." - - - - VER_E_PATH_LOC - "Non-compatible types depending on path." - - - - VER_E_PATH_THIS - "Init state for this differs depending on path." - - - - VER_E_PATH_STACK - "Non-compatible types on stack depending on path." - - - - VER_E_PATH_STACK_DEPTH - "Stack depth differs depending on path." - - - - VER_E_THIS - "Instance variable (this) missing." - - - - VER_E_THIS_UNINIT_EXCEP - "Uninitialized this on entering a try block." - - - - VER_E_THIS_UNINIT_STORE - "Store into this when it is uninitialized." - - - - VER_E_THIS_UNINIT_RET - "Return from .ctor when this is uninitialized." - - - - VER_E_THIS_UNINIT_V_RET - "Return from .ctor before all fields are initialized." - - - - VER_E_THIS_UNINIT_BR - "Branch back when this is uninitialized." - - - - VER_E_LDFTN_CTOR - "ldftn and ldvirtftn not allowed on .ctor." - - - - VER_E_STACK_NOT_EQ - "Non-compatible types on the stack." - - - - VER_E_STACK_UNEXPECTED - "Unexpected type on the stack." - - - - VER_E_STACK_EXCEPTION - "Missing stack slot for exception." - - - - VER_E_STACK_OVERFLOW - "Stack overflow." - - - - VER_E_STACK_UNDERFLOW - "Stack underflow." - - - - VER_E_STACK_EMPTY - "Stack empty." - - - - VER_E_STACK_UNINIT - "Uninitialized item on stack." - - - - VER_E_STACK_I_I4_I8 - "Expected I, I4, or I8 on the stack." - - - - VER_E_STACK_R_R4_R8 - "Expected R, R4, or R8 on the stack." - - - - VER_E_STACK_NO_R_I8 - "unexpected R, R4, R8, or I8 on the stack." - - - - VER_E_STACK_NUMERIC - "Expected numeric type on the stack." - - - - VER_E_STACK_OBJREF - "Expected an ObjRef on the stack." - - - - VER_E_STACK_P_OBJREF - "Expected address of an ObjRef on the stack." - - - - VER_E_STACK_BYREF - "Expected ByRef on the stack." - - - - VER_E_STACK_METHOD - "Expected pointer to function on the stack." - - - - VER_E_STACK_ARRAY_SD - "Expected single dimension array on the stack." - - - - VER_E_STACK_VALCLASS - "Expected value type instance on the stack." - - - - VER_E_STACK_P_VALCLASS - "Expected address of value type on the stack." - - - - VER_E_STACK_NO_VALCLASS - "Unexpected value type instance on the stack." - - - - VER_E_LOC_DEAD - "Local variable is unusable at this point." - - - - VER_E_LOC_NUM - "Unrecognized local variable number." - - - - VER_E_ARG_NUM - "Unrecognized argument number." - - - - VER_E_TOKEN_RESOLVE - "Unable to resolve token." - - - - VER_E_TOKEN_TYPE - "Unable to resolve type of the token." - - - - VER_E_TOKEN_TYPE_MEMBER - "Expected memberRef, memberDef or methodSpec token." - - - - VER_E_TOKEN_TYPE_FIELD - "Expected memberRef or fieldDef token." - - - - VER_E_TOKEN_TYPE_SIG - "Expected signature token." - - - - VER_E_UNVERIFIABLE - "Instruction cannot be verified." - - - - VER_E_LDSTR_OPERAND - "Operand does not point to a valid string ref." - - - - VER_E_RET_PTR_TO_STACK - "Return type is ByRef, TypedReference, ArgHandle, or ArgIterator." - - - - VER_E_RET_VOID - "Stack must be empty on return from a void function." - - - - VER_E_RET_MISSING - "Return value missing on the stack." - - - - VER_E_RET_EMPTY - "Stack must contain only the return value." - - - - VER_E_RET_UNINIT - "Return uninitialized data." - - - - VER_E_ARRAY_ACCESS - "Illegal array access." - - - - VER_E_ARRAY_V_STORE - "Store non Object type into Object array." - - - - VER_E_ARRAY_SD - "Expected single dimension array." - - - - VER_E_ARRAY_SD_PTR - "Expected single dimension array of pointer types." - - - - VER_E_ARRAY_FIELD - "Array field access is denied." - - - - VER_E_ARGLIST - "Allowed only in vararg methods." - - - - VER_E_VALCLASS - "Value type expected." - - - - VER_E_METHOD_ACCESS - "Method is not visible." - - - - VER_E_FIELD_ACCESS - "Field is not visible." - - - - VER_E_DEAD - "Item is unusable at this point." - - - - VER_E_FIELD_STATIC - "Expected static field." - - - - VER_E_FIELD_NO_STATIC - "Expected non-static field." - - - - VER_E_ADDR - "Address of not allowed for this item." - - - - VER_E_ADDR_BYREF - "Address of not allowed for ByRef." - - - - VER_E_ADDR_LITERAL - "Address of not allowed for literal field." - - - - VER_E_INITONLY - "Cannot change initonly field outside its .ctor." - - - - VER_E_THROW - "Cannot throw this object." - - - - VER_E_CALLVIRT_VALCLASS - "Callvirt on a value type method." - - - - VER_E_CALL_SIG - "Call signature mismatch." - - - - VER_E_CALL_STATIC - "Static function expected." - - - - VER_E_CTOR - ".ctor expected." - - - - VER_E_CTOR_VIRT - "Cannot use callvirt on .ctor." - - - - VER_E_CTOR_OR_SUPER - "Only super::ctor or typeof(this)::ctor allowed here." - - - - VER_E_CTOR_MUL_INIT - "Possible call to .ctor more than once." - - - - VER_E_SIG - "Unrecognized signature." - - - - VER_E_SIG_ARRAY - "Cannot resolve Array type." - - - - VER_E_SIG_ARRAY_PTR - "Array of ELEMENT_TYPE_PTR." - - - - VER_E_SIG_ARRAY_BYREF - "Array of ELEMENT_TYPE_BYREF or ELEMENT_TYPE_TYPEDBYREF." - - - - VER_E_SIG_ELEM_PTR - "ELEMENT_TYPE_PTR cannot be verified." - - - - VER_E_SIG_VARARG - "Unexpected vararg." - - - - VER_E_SIG_VOID - "Unexpected Void." - - - - VER_E_SIG_BYREF_BYREF - "ByRef of ByRef" - - - - VER_E_CODE_SIZE_ZERO - "Code size is zero." - - - - VER_E_BAD_VARARG - "Unrecognized use of vararg." - - - - VER_E_TAIL_CALL - "Missing call, callvirt or calli." - - - - VER_E_TAIL_BYREF - "Cannot pass ByRef to a tail call." - - - - VER_E_TAIL_RET - "Missing ret." - - - - VER_E_TAIL_RET_VOID - "Void ret type expected for tail call." - - - - VER_E_TAIL_RET_TYPE - "Tail call return type not compatible." - - - - VER_E_TAIL_STACK_EMPTY - "Stack not empty after tail call." - - - - VER_E_METHOD_END - "Method ends in the middle of an instruction." - - - - VER_E_BAD_BRANCH - "Branch out of the method." - - - - VER_E_FIN_OVERLAP - "Finally handler blocks overlap." - - - - VER_E_LEXICAL_NESTING - "Lexical nesting." - - - - VER_E_VOLATILE - "Missing ldsfld, stsfld, ldind, stind, ldfld, stfld, ldobj, stobj, initblk or cpblk." - - - - VER_E_UNALIGNED - "Missing ldind, stind, ldfld, stfld, ldobj, stobj, initblk or cpblk." - - - - VER_E_INNERMOST_FIRST - "Innermost exception blocks should be declared first." - - - - VER_E_CALLI_VIRTUAL - "Calli not allowed on virtual methods." - - - - VER_E_CALL_ABSTRACT - "Call not allowed on abstract methods." - - - - VER_E_STACK_UNEXP_ARRAY - "Unexpected array type on the stack." - - - - VER_E_NOT_IN_GC_HEAP - "Value type with NotInGCHeap attribute being created on the GC heap." - - - - VER_E_TRY_N_EMPTY_STACK - "Attempt to enter a try block with nonempty stack." - - - - VER_E_DLGT_CTOR - "Unrecognized arguments for delegate .ctor." - - - - VER_E_DLGT_BB - "Delegate .ctor not allowed at the start of a basic block when the function pointer argument is a virtual method." - - - - VER_E_DLGT_PATTERN - "Dup, ldvirtftn, newobj delegate::.ctor() pattern expected (in the same basic block)." - - - - VER_E_DLGT_LDFTN - "Ldftn or ldvirtftn instruction required before call to a delegate .ctor." - - - - VER_E_FTN_ABSTRACT - "Attempt to load address of an abstract method." - - - - VER_E_SIG_C_VC - "ELEMENT_TYPE_CLASS ValueClass in signature." - - - - VER_E_SIG_VC_C - "ELEMENT_TYPE_VALUETYPE non-ValueClass in signature." - - - - VER_E_BOX_PTR_TO_STACK - "Box operation on TypedReference, ArgHandle, or ArgIterator." - - - - VER_E_SIG_BYREF_TB_AH - "ByRef of TypedReference, ArgHandle, or ArgIterator." - - - - VER_E_SIG_ARRAY_TB_AH - "Array of TypedReference, ArgHandle, or ArgIterator." - - - - VER_E_ENDFILTER_STACK - "Stack not empty when leaving an exception filter." - - - - VER_E_DLGT_SIG_I - "Unrecognized delegate .ctor signature; expected I." - - - - VER_E_DLGT_SIG_O - "Unrecognized delegate .ctor signature; expected Object." - - - - VER_E_RA_PTR_TO_STACK - "Mkrefany on TypedReference, ArgHandle, or ArgIterator." - - - - VER_E_CATCH_VALUE_TYPE - "Value type not allowed as catch type." - - - - VER_E_CATCH_BYREF - "ByRef not allowed as catch type." - - - - VER_E_FIL_PRECEED_HND - "filter block should immediately precede handler block" - - - - VER_E_LDVIRTFTN_STATIC - "ldvirtftn on static" - - - - VER_E_CALLVIRT_STATIC - "callvirt on static" - - - - VER_E_INITLOCALS - "initlocals must be set for verifiable methods with one or more local variables." - - - - VER_E_BR_TO_EXCEPTION - "branch or leave to the beginning of a catch/filter handler" - - - - VER_E_CALL_CTOR - "Call to .ctor only allowed to initialize this pointer from within a .ctor. Try newobj." - - - - VER_E_VALCLASS_OBJREF_VAR - "Value type, ObjRef type or variable type expected." - - - - VER_E_STACK_P_VALCLASS_OBJREF_VAR - "Expected address of value type, ObjRef type or variable type on the stack." - - - - VER_E_SIG_VAR_PARAM - "Unrecognized type parameter of enclosing class." - - - - VER_E_SIG_MVAR_PARAM - "Unrecognized type parameter of enclosing method." - - - - VER_E_SIG_VAR_ARG - "Unrecognized type argument of referenced class instantiation." - - - - VER_E_SIG_MVAR_ARG - "Unrecognized type argument of referenced method instantiation." - - - - VER_E_SIG_GENERICINST - "Cannot resolve generic type." - - - - VER_E_SIG_METHOD_INST - "Method instantiation contains non boxable type arguments." - - - - VER_E_SIG_METHOD_PARENT_INST - "Method parent instantiation contains non boxable type arguments." - - - - VER_E_SIG_FIELD_PARENT_INST - "Field parent instantiation contains non boxable type arguments." - - - - VER_E_CALLCONV_NOT_GENERICINST - "Unrecognized calling convention for an instantiated generic method." - - - - VER_E_TOKEN_BAD_METHOD_SPEC - "Unrecognized generic method in method instantiation." - - - - VER_E_BAD_READONLY_PREFIX - "Missing ldelema or call following readonly. prefix." - - - - VER_E_BAD_CONSTRAINED_PREFIX - "Missing callvirt following constrained. prefix." - - - - VER_E_CIRCULAR_VAR_CONSTRAINTS - "Method parent has circular class type parameter constraints." - - - - VER_E_CIRCULAR_MVAR_CONSTRAINTS - "Method has circular method type parameter constraints." - - - - VER_E_UNSATISFIED_METHOD_INST - "Method instantiation has unsatisfied method type parameter constraints." - - - - VER_E_UNSATISFIED_METHOD_PARENT_INST - "Method parent instantiation has unsatisfied class type parameter constraints." - - - - VER_E_UNSATISFIED_FIELD_PARENT_INST - "Field parent instantiation has unsatisfied class type parameter constraints." - - - - VER_E_UNSATISFIED_BOX_OPERAND - "Type operand of box instruction has unsatisfied class type parameter constraints." - - - - VER_E_CONSTRAINED_CALL_WITH_NON_BYREF_THIS - "The 'this' argument to a constrained call must have ByRef type." - - - - VER_E_CONSTRAINED_OF_NON_VARIABLE_TYPE - "The operand to a constrained prefix instruction must be a type parameter." - - - - VER_E_READONLY_UNEXPECTED_CALLEE - "The readonly prefix may only be applied to calls to array methods returning ByRefs." - - - - VER_E_READONLY_ILLEGAL_WRITE - "Illegal write to readonly ByRef." - - - - VER_E_READONLY_IN_MKREFANY - "A readonly ByRef cannot be used with mkrefany." - - - - VER_E_UNALIGNED_ALIGNMENT - "Alignment specified for 'unaligned' prefix must be 1, 2, or 4." - - - - VER_E_TAILCALL_INSIDE_EH - "The tail.call (or calli or callvirt) instruction cannot be used to transfer control out of a try, filter, catch, or finally block." - - - - VER_E_BACKWARD_BRANCH - "Stack height at all points must be determinable in a single forward scan of IL." - - - - VER_E_CALL_TO_VTYPE_BASE - "Call to base type of valuetype." - - - - VER_E_NEWOBJ_OF_ABSTRACT_CLASS - "Cannot construct an instance of abstract class." - - - - VER_E_UNMANAGED_POINTER - "Unmanaged pointers are not a verifiable type." - - - - VER_E_LDFTN_NON_FINAL_VIRTUAL - "Cannot LDFTN a non-final virtual method." - - - - VER_E_FIELD_OVERLAP - "Accessing type with overlapping fields." - - - - VER_E_THIS_MISMATCH - "The 'this' parameter to the call must be the calling method's 'this' parameter." - - - - VER_E_STACK_I_I4 - "Expected I4 on the stack." - - - - VER_E_BAD_PE - "Unverifiable PE Header/native stub." - - - - VER_E_BAD_MD - "Unrecognized metadata, unable to verify IL." - - - - VER_E_BAD_APPDOMAIN - "Unrecognized appdomain pointer." - - - - VER_E_TYPELOAD - "Type load failed." - - - - VER_E_PE_LOAD - "Module load failed." - - - - VER_E_WRITE_RVA_STATIC - "Cannot modify an imaged based (RVA) static" - - - - VER_E_INITIALIZE_ARRAY_MISSING_TOKEN - "Ldtoken instruction required before call to System.Runtime.CompilerServices.InitializeArray." - - - - COR_E_SqlException - System.Data.SqlClient.SqlClientException - - - - COR_E_Data - - - - COR_E_DataDeletedRowInaccessible - - - - COR_E_DataDuplicateName - - - - COR_E_DataInRowChangingEvent - - - - COR_E_DataInvalidConstraint - - - - COR_E_DataMissingPrimaryKey - - - - COR_E_DataNoNullAllowed - - - - COR_E_DataReadOnly - - - - COR_E_DataRowNotInTable - - - - COR_E_DataVersionNotFound - - - - COR_E_DataConstraint - - - - COR_E_StrongTyping - - - - COR_E_SqlType - - - - COR_E_SqlNullValue - - - - COR_E_SqlTruncate - - - - COR_E_AdapterMapping - - - - COR_E_DataAdapter - - - - COR_E_DBConcurrency - - - - COR_E_OperationAborted - - - - COR_E_InvalidUdt - - - - COR_E_OdbcException - System.Data.Odbc.OdbcException - - - - COR_E_OracleException - System.Data.OracleClient.OracleException - - - - COR_E_Xml - - - - COR_E_XmlSchema - - - - COR_E_XmlXslt - - - - COR_E_XmlXPath - - - - COR_E_XmlQuery - - - - VLDTR_E_IFACE_NOTIFACE - "Interface in InterfaceImpl is not marked tdInterface." - Interface in InterfaceImpl is not marked tdInterface - - - - VLDTR_E_FD_RVAHASNORVA - "Field marked fdHasFieldRVA but has no RVA record." - Field marked fdHasFieldRVA but has no RVA rec - - - - VLDTR_E_FD_RVAHASZERORVA - "Field marked fdHasFieldRVA has RVA set to zero." - Field marked fdHasFieldRVA has RVA =0 - - - - VLDTR_E_MD_RVAANDIMPLMAP - "Method has both non-zero RVA and ImplMap." - Method has both RVA !=0 and ImplMap - - - - VLDTR_E_TD_EXTRAFLAGS - "TypeDef has extraneous bits in flags." - TypeDef has extraneous bits in flags - - - - VLDTR_E_TD_EXTENDSITSELF - "TypeDef extends itself." - TypeDef extends itself - - - - VLDTR_E_TD_SYSVTNOTEXTOBJ - "System.ValueType does not extend System.Object." - System.ValueType does not extend System.Object - - - - VLDTR_E_TD_EXTTYPESPEC - "Class extends TypeSpec (warning)." - Class extends TypeSpec (warning) - - - - VLDTR_E_TD_VTNOSIZE - "Value Class has zero size." - Value Class has zero size - - - - VLDTR_E_TD_IFACESEALED - "Interface is sealed." - Interface is sealed - - - - VLDTR_E_NC_BADNESTED - "Bad 'nested' token in NestedClass." - Bad "nested" token in NestedClass - - - - VLDTR_E_NC_BADENCLOSER - "Bad 'enclosing' token in NestedClass." - Bad "enclosing" token in NestedClass - - - - VLDTR_E_NC_DUP - "Duplicate NestedClass record." - Duplicate NestedClass record - - - - VLDTR_E_NC_DUPENCLOSER - "Duplicate NestedClass with different encloser." - Duplicate NestedClass with different encloser - - - - VLDTR_E_FRVA_ZERORVA - "RVA set to zero in FieldRVA record." - RVA=0 in FieldRVA record - - - - VLDTR_E_FRVA_BADFIELD - "Invalid field token in FieldRVA record." - Invalid field token in FieldRVA record - - - - VLDTR_E_FRVA_DUPRVA - "Duplicate RVA in FieldRVA record." - Duplicate RVA in FieldRVA record - - - - VLDTR_E_FRVA_DUPFIELD - "Duplicate field in FieldRVA record." - Duplicate field in FieldRVA record - - - - VLDTR_E_EP_BADTOKEN - "Bad token as entry point in CLR header." - Bad token as entry point in CLR header - - - - VLDTR_E_EP_INSTANCE - "Entry point in CLR header is a token of instance method." - Entry point in CLR header is a token of instance method - - - - VLDTR_E_TD_ENUMFLDBADTYPE - "Enum has non-integral underlying type." - Enum has non-integral underlying type - - - - VLDTR_E_MD_BADRVA - "Method has bogus RVA." - Method has bogus RVA - - - - VLDTR_E_FD_LITERALNODEFAULT - "Literal field has no const value." - Literal field has no const value - - - - VLDTR_E_IFACE_METHNOTIMPL - "Class implementing an interface does not implement one of methods." - Class implementing an interface doesn't impl.one of methods - - - - VLDTR_E_CA_BADPARENT - "CA has invalid owner." - CA has invalid owner - - - - VLDTR_E_CA_BADTYPE - "CA has invalid type." - CA has invalid type - - - - VLDTR_E_CA_NOTCTOR - "CA type is not .ctor." - CA type is not .ctor - - - - VLDTR_E_CA_BADSIG - "CA type has bad signature." - CA type has bad signature - - - - VLDTR_E_CA_NOSIG - "CA type has no signature." - CA type has no signature - - - - VLDTR_E_CA_BADPROLOG - "CA blob has bad prolog (not 0x01 0x00)." - CA blob has bad prolog (not 0x01 0x00) - - - - VLDTR_E_MD_BADLOCALSIGTOK - "Method has invalid LocalSig token." - Method has invalid LocalSig token - - - - VLDTR_E_MD_BADHEADER - "Method has invalid header." - Method has invalid header - - - - VLDTR_E_EP_TOOMANYARGS - "Entry point has more than one argument." - Entry point has more than one arg - - - - VLDTR_E_EP_BADRET - "Entry point has bad return type." - Entry point has bad return type - - - - VLDTR_E_EP_BADARG - "Entry point has bad argument." - Entry point has bad argument - - - - VLDTR_E_SIG_BADVOID - "Illegal 'void' in signature." - Illegal "void" in signature - - - - VLDTR_E_IFACE_METHMULTIMPL - "Multiple implementation of method." - Multiple implementation of method - - - - VLDTR_E_GP_NAMENULL - "GenericParam name is NULL." - GenericParam name is NULL - - - - VLDTR_E_GP_OWNERNIL - "GenericParam has nil owner." - GenericParam has nil owner. - - - - VLDTR_E_GP_DUPNAME - "GenericParam has duplicate by owner and name." - GenericParam has duplicate by owner and name. - - - - VLDTR_E_GP_DUPNUMBER - "GenericParam has duplicate by owner and number." - GenericParam has duplicate by owner and number. - - - - VLDTR_E_GP_NONSEQ_BY_OWNER - "GenericParam is non sequential by owner." - GenericParam is non sequential by owner - - - - VLDTR_E_GP_NONSEQ_BY_NUMBER - "GenericParam is non sequential by number." - GenericParam is non sequential by number - - - - VLDTR_E_GP_UNEXPECTED_OWNER_FOR_VARIANT_VAR - "GenericParam has variance but its owner is not an interface or delegate." - GenericParam has variance but its owner is not an interface or delegate - - - - VLDTR_E_GP_ILLEGAL_VARIANT_MVAR - "GenericParam is a method type parameter and must be non-variant." - GenericParam is a method type parameter and must be non-variant - - - - VLDTR_E_GP_ILLEGAL_VARIANCE_FLAGS - "GenericParam has illegal value for variance flags." - GenericParam has illegal value for variance flags - - - - VLDTR_E_GP_REFANDVALUETYPE - "GenericParam has incompatible special constraints reference type and valuetype." - GenericParam has incompatible special constraints reference type and valuetype - - - - VLDTR_E_GPC_OWNERNIL - "GenericParamConstraint has nil owner." - GenericParamConstraint has nil owner - - - - VLDTR_E_GPC_DUP - "GenericParamConstraint has duplicate by owner and constraint." - GenericParamConstraint has duplicate by owner and constraint - - - - VLDTR_E_GPC_NONCONTIGUOUS - "GenericParamConstraint is non-contiguous with preceeding constraints for same owner." - GenericParamConstraint is non-contiguous with preceeding constraints for same owner - - - - VLDTR_E_MS_METHODNIL - "MethodSpec has nil method." - MethodSpec has nil method - - - - VLDTR_E_MS_DUP - "MethodSpec has duplicate based on method and instantiation." - MethodSpec has duplicate based own method and instantiation - - - - VLDTR_E_MS_BADCALLINGCONV - "MethodSpec signature has invalid calling convention." - MethodSpec signature has invalid calling convention - - - - VLDTR_E_MS_MISSARITY - "MethodSpec signature is missing arity specification." - MethodSpec signature is missing arity specification - - - - VLDTR_E_MS_MISSARG - "MethodSpec signature is missing type argument." - MethodSpec signature is missing type argument - - - - VLDTR_E_MS_ARITYMISMATCH - "MethodSpec arity of generic method and instantiation do not match." - MethodSpec arity of generic method and instantiation do not match - - - - VLDTR_E_MS_METHODNOTGENERIC - "MethodSpec method is not generic." - MethodSpec method is not generic - - - - VLDTR_E_SIG_MISSARITY - "Signature missing arity of instantiated generic type." - Signature missing arity of instantiated generic type - - - - VLDTR_E_SIG_ARITYMISMATCH - "Signature has generic type of arity instantiated at different arity." - Signature has generic type of arity instantiated at different arity - - - - VLDTR_E_MD_GENERIC_CCTOR - "Method cannot be both generic and a class constructor." - Method cannot be both generic and a class constructor - - - - VLDTR_E_MD_GENERIC_CTOR - "Method cannot be both generic and an instance constructor." - Method cannot be both generic and an instance constructor - - - - VLDTR_E_MD_GENERIC_IMPORT - "Method cannot be both generic and defined on an imported type." - Method cannot be both generic and defined on an imported type - - - - VLDTR_E_MD_GENERIC_BADCALLCONV - "Method cannot be both generic and have non-default calling convention." - Method cannot be both generic and have non-default calling convention - - - - VLDTR_E_EP_GENERIC_METHOD - "Entry point in CLR header is the token for a generic method." - Entry point in CLR header is the token for a generic method - - - - VLDTR_E_MD_MISSARITY - "Method signature is generic but is missing its arity." - Method signature is generic but is missing its arity - - - - VLDTR_E_MD_ARITYZERO - "Method signature is generic but its arity is zero." - Method signature is generic but its arity is zero - - - - VLDTR_E_SIG_ARITYZERO - "Signature has generic type instantiated at arity 0." - Signature has generic type instantiated at arity 0 - - - - VLDTR_E_MS_ARITYZERO - "MethodSpec signature has arity 0." - MethodSpec signature has arity 0 - - - - VLDTR_E_MD_GPMISMATCH - "MethodDef signature has arity n but owns m GenericParams." - MethodDef signature has arity n but owns m GenericParams - - - - VLDTR_E_EP_GENERIC_TYPE - "Entry point in CLR header is the token for a method in a generic type." - Entry point in CLR header is the token for a method in a generic type - - - - VLDTR_E_MI_DECLNOTGENERIC - "MethodImpl overrides non-generic method with generic method." - MethodImpl overrides non-generic method with generic method - - - - VLDTR_E_MI_IMPLNOTGENERIC - "MethodImpl overrides non-generic method with generic method." - MethodImpl overrides non-generic method with generic method - - - - VLDTR_E_MI_ARITYMISMATCH - "MethodImpl overrides generic method of arity n with generic method of arity m." - MethodImpl overrides generic method of arity n with generic method of arity m - - - - VLDTR_E_TD_EXTBADTYPESPEC - "TypeDef extends a TypeSpec that is not an instantiated type." - TypeDef extends a TypeSpec that is not an instantiated type - - - - VLDTR_E_SIG_BYREFINST - "Signature has type instantiated at ByRef at offset i." - Signature has type instantiated at byref at offset i - - - - VLDTR_E_MS_BYREFINST - "Signature has type instantiated at ByRef at offset i." - Signature has type instantiated at byref at offset i - - - - VLDTR_E_TS_EMPTY - "TypeSpec has empty signature." - TypeSpec has empty signature - - - - VLDTR_E_TS_HASSENTINALS - "TypeSpec has signature containing one or more sentinels." - TypeSpec has signature containing one or more sentinals - - - - VLDTR_E_TD_GENERICHASEXPLAYOUT - "TypeDef is generic but has explicit layout." - TypeDef is generic but has explicit layout - - - - VLDTR_E_SIG_BADTOKTYPE - "Signature has token following ELEMENT_TYPE_CLASS (_VALUETYPE) that is not a TypeDef or TypeRef." - Signature has token following ELEMENT_TYPE_CLASS (_VALUETYPE) that is not a TypeDef or TypeRef - - - - VLDTR_E_IFACE_METHNOTIMPLTHISMOD - "Warning: Class does not implement interface method in this module." - Warn:Class doesn't implement interface method in this module - - - - TLBX_E_CIRCULAR_EXPORT2 - "TypeLib export: attempted to export an Assembly imported from a TLB." - TypeLib export: attempt to export a CLB imported from a TLB. - - - - CORDBG_E_THREAD_NOT_SCHEDULED - "Thread is not scheduled. Thus we may not have OSThreadId, handle, or context." - Thread is not scheduled. Thus we may not have OSThreadId, handle, or context - - - - CORDBG_E_HANDLE_HAS_BEEN_DISPOSED - "Handle has been disposed." - Handle has been disposed. - - - - CORDBG_E_NONINTERCEPTABLE_EXCEPTION - "Cannot intercept this exception." - Cant intercept this exception. - - - - CORDBG_E_CANT_UNWIND_ABOVE_CALLBACK - "When intercepting an exception, cannot intercept above the current frame." - When intercepting an exception, cannot intercept above the current frame. - - - - CORDBG_E_INTERCEPT_FRAME_ALREADY_SET - "The intercept frame for this exception has already been set." - The intercept frame for this exception has already been set. - - - - CORDBG_E_NO_NATIVE_PATCH_AT_ADDR - "There is no native patch at the given address." - there's no native patch at the given address. - - - - CORDBG_E_MUST_BE_INTEROP_DEBUGGING - "This API is only allowed when interop debugging." - This API is only allowed when interop debugging. - - - - CORDBG_E_NATIVE_PATCH_ALREADY_AT_ADDR - "There is already a native patch at the address." - There's already a native patch at the address - - - - CORDBG_E_TIMEOUT - "A wait timed out, likely an indication of deadlock." - a wait timed out .. likely an indication of deadlock. - - - - CORDBG_E_CANT_CALL_ON_THIS_THREAD - "Cannot use the API on this thread." - Can't use the API on this thread. - - - - CORDBG_E_ENC_INFOLESS_METHOD - "Method was not JIT'd in EnC mode." - Method was not JITed in EnC mode - - - - CORDBG_E_ENC_NESTED_HANLDERS - "Frame cannot be updated due to change in max nesting of handlers." - Frame cant be updated due to change in max nesting of handlers - - - - CORDBG_E_ENC_IN_FUNCLET - "Method is in a callable handler/filter. Cannot increase stack." - Method is in a callable handler/filter. Cant grow stack - - - - CORDBG_E_ENC_LOCALLOC - "Frame cannot be updated due to localloc." - Frame cant be updated due to localloc - - - - CORDBG_E_ENC_EDIT_NOT_SUPPORTED - "Attempt to perform unsupported edit." - Attempt to perform unsupported edit - - - - CORDBG_E_FEABORT_DELAYED_UNTIL_THREAD_RESUMED - "Attempt to func eval abort on a suspended thread." - Attempt to func eval abort on a suspended thread. - - - - CORDBG_E_NOTREADY - "The LS is not in a good spot to perform the requested operation." - The LS is not in a good spot to perform the requested operation. - - - - CORDBG_E_CANNOT_RESOLVE_ASSEMBLY - "We failed to resolve assembly given an AssemblyRef token. Assembly may be not loaded yet or not a valid token." - We failed to resolve assembly given an AssemblyRef token. Assembly may be not loaded yet or not a valid token. - - - - CORDBG_E_MUST_BE_IN_LOAD_MODULE - "Must be in context of LoadModule callback to perform requested operation." - Must be in context of LoadModule callback to perform requested operation - - - - CORDBG_E_CANNOT_BE_ON_ATTACH - "Requested operation cannot be performed during an attach operation." - Requested operation cannot be performed during an attach operation - - - - CORDBG_E_NGEN_NOT_SUPPORTED - "NGEN must be supported to perform the requested operation." - NGEN must be supported to perform the requested operation - - - - CORDBG_E_ILLEGAL_SHUTDOWN_ORDER - "Trying to shutdown out of order." - Trying to shutdown out of order. - - - - CORDBG_E_CANNOT_DEBUG_FIBER_PROCESS - "Debugging fiber mode managed process is not supported." - For Whidbey, we don't support debugging fiber mode managed process - - - - CORDBG_E_MUST_BE_IN_CREATE_PROCESS - "Must be in context of CreateProcess callback to perform requested operation." - Must be in context of CreateProcess callback to perform requested operation - - - - CORDBG_E_DETACH_FAILED_OUTSTANDING_EVALS - "All outstanding func-evals have not completed, detaching is not allowed at this time." - All outstanding func-evals have not completed, detaching is not allowed at this time. - - - - CORDBG_E_DETACH_FAILED_OUTSTANDING_STEPPERS - "All outstanding steppers have not been closed, detaching is not allowed at this time." - All outstanding steppers have not been closed, detaching is not allowed at this time. - - - - CORDBG_E_CANT_INTEROP_STEP_OUT - "Cannot have an ICorDebugStepper do a native step-out." - Can't have an ICorDebugStepper do a native step-out. - - - - CORDBG_E_DETACH_FAILED_OUTSTANDING_BREAKPOINTS - "All outstanding breakpoints have not been closed, detaching is not allowed at this time." - All outstanding breakpoints have not been closed, detaching is not allowed at this time. - - - - CORDBG_E_ILLEGAL_IN_STACK_OVERFLOW - "The operation is illegal because of a stack overflow." - the operation is illegal because of a stackoverflow. - - - - CORDBG_E_ILLEGAL_AT_GC_UNSAFE_POINT - "The operation failed because it is a GC unsafe point." - The operation failed because it's a GC unsafe point. - - - - CORDBG_E_ILLEGAL_IN_PROLOG - "The operation failed because the thread is in the prolog." - The operation failed because the thread is in the prolog - - - - CORDBG_E_ILLEGAL_IN_NATIVE_CODE - "The operation failed because the thread is in native code." - The operation failed because the thread is in native code - - - - CORDBG_E_ILLEGAL_IN_OPTIMIZED_CODE - "The operation failed because the thread is in optimized code." - The operation failed because the thread is in optimized code. - - - - CORDBG_E_MINIDUMP_UNSUPPORTED - "The information requested is not supported by minidumps." - - - - - CORDBG_E_APPDOMAIN_MISMATCH - "A supplied object or type belongs to the wrong AppDomain." - A supplied object or type belongs to the wrong AppDomain - - - - CORDBG_E_CONTEXT_UNVAILABLE - "The thread's context is not available." - The thread's context is not available. - - - - CORDBG_E_UNCOMPATIBLE_PLATFORMS - "The operation failed because debuggee and debugger are on incompatible platforms." - The operation failed because debuggee and debugger are on incompatible platform - - - - CORDBG_E_DEBUGGING_DISABLED - "The operation failed because the debugging has been disabled" - The operation failed because the debugging has been disabled - - - - CORDBG_E_DETACH_FAILED_ON_ENC - "Detach is illegal after an Edit and Continue on a module." - Detach is illegal after a module has been EnCed. - - - - CORDBG_E_CURRENT_EXCEPTION_IS_OUTSIDE_CURRENT_EXECUTION_SCOPE - "Cannot intercept the current exception at the specified frame." - Interception of the current exception is not legal - - - - CORDBG_E_HELPER_MAY_DEADLOCK - "The debugger helper thread cannot obtain the locks it needs to perform this operation." - Helper thread can not safely run code. The opereration may work at a later time. - - - - CORDBG_E_MISSING_METADATA - "The operation failed because the debugger could not get the metadata." - The operation failed because the debugger could not get the metadata. - - - - CORDBG_E_TARGET_INCONSISTENT - "The debuggee is in a corrupt state." - The debuggee is in a corrupt state. - - - - CORDBG_E_DETACH_FAILED_OUTSTANDING_TARGET_RESOURCES - "Detach failed because there are outstanding resources in the target." - The debugger is holding resource in the target (such as GC handles, function evaluations, etc). - These resources must be released through the appropriate ICorDebug API before detach can succeed. - - - - CORDBG_E_TARGET_READONLY - "The debuggee is read-only." - The provided ICorDebugDataTarget does not implement ICorDebugMutableDataTarget. - - - - CORDBG_E_MISMATCHED_CORWKS_AND_DACWKS_DLLS - "The version of clr.dll in the target does not match the one mscordacwks.dll was built for." - A clr/mscordacwks mismatch will cause DAC to fail to initialize in ClrDataAccess::Initialize - - - - CORDBG_E_MODULE_LOADED_FROM_DISK - "Symbols are not supplied for modules loaded from disk." - Symbols are not supplied for modules loaded from disk - - - - CORDBG_E_SYMBOLS_NOT_AVAILABLE - "The application did not supply symbols when it loaded or created this module, or they are not yet available." - The application did not supply symbols when it loaded or created this module, or they are not yet available - - - - CORDBG_E_DEBUG_COMPONENT_MISSING - "A debug component is not installed." - A debug component is not installed - - - - CORDBG_E_REMOTE_MISMATCHED_CERTS - "Connection authentication failed due to mismatched certificates." - Connection authentication failed due to mismatched certificates - - - - CORDBG_E_REMOTE_NETWORK_FAILURE - "Connection failed due to a miscellaneous network error." - Connection failed due to a miscellaneous network error - - - - CORDBG_E_REMOTE_NO_LISTENER - "Connection failed due to no endpoint at remote machine (no proxy configured?)." - Connection failed due to no endpoint at remote machine (no proxy configured?) - - - - CORDBG_E_REMOTE_UNKNOWN_TARGET - "Connection failed due to inability to locate remote machine." - Connection failed due to inability to locate remote machine - - - - CORDBG_E_REMOTE_INVALID_CONFIG - "Local debugger configuration was missing or invalid." - Local debugger configuration was missing or invalid - - - - CORDBG_E_REMOTE_MISMATCHED_PROTOCOLS - "Connection failed due to protocol version mismatch between local and remote components." - Connection failed due to protocol version mismatch between local and remote components - - - - CORDBG_E_LIBRARY_PROVIDER_ERROR - "The ICLRDebuggingLibraryProvider callback returned an error or did not provide a valid handle." - The ICLRDebuggingLibraryProvider callback returned an error or did not provide a valid handle - - - - CORDBG_E_NOT_CLR - "The module at the base address indicated was not recognized as a CLR" - The module at the base address indicated was not recognized as a CLR - - - - CORDBG_E_MISSING_DATA_TARGET_INTERFACE - "The provided data target does not implement the required interfaces for this version of the runtime" - The provided data target does not implement the required interfaces for this version of the runtime - - - - CORDBG_E_UNSUPPORTED_DEBUGGING_MODEL - "This debugging model is unsupported by the specified runtime" - This debugging model is unsupported by the specified runtime - - - - CORDBG_E_UNSUPPORTED_FORWARD_COMPAT - "The debugger is not designed to support the version of the CLR the debuggee is using." - The debugger is not designed to support the version of the CLR the debuggee is using. - - - - CORDBG_E_UNSUPPORTED_VERSION_STRUCT - "The version struct has an unrecognized value for wStructVersion" - The version struct has an unrecognized value for wStructVersion - - - - CORDBG_E_READVIRTUAL_FAILURE - "A call into a ReadVirtual implementation returned failure" - A call into a ReadVirtual implementation returned failure - - - - CORDBG_E_VALUE_POINTS_TO_FUNCTION - "The Debugging API doesn't support dereferencing function pointers." - The Debugging API doesn't support dereferencing function pointers. - - - - CORDBG_E_CORRUPT_OBJECT - "The address provided does not point to a valid managed object." - The address provided does not point to a valid managed object. - - - - CORDBG_E_GC_STRUCTURES_INVALID - "The GC heap structures are not in a valid state for traversal." - The GC heap structures are not in a valid state for traversal. - - - - CORDBG_E_INVALID_OPCODE - "The specified IL offset or opcode is not supported for this operation." - The specified IL offset or opcode is not supported for this operation. - - - - CORDBG_E_UNSUPPORTED - "The specified action is unsupported by this version of the runtime." - The specified action is unsupported by this version of the runtime. - - - - CORDBG_E_MISSING_DEBUGGER_EXPORTS - "The debuggee memory space does not have the expected debugging export table." - The debuggee memory space does not have the expected debugging export table. - - - - CORDBG_E_DATA_TARGET_ERROR - "Failure when calling a data target method." - Failure when calling a data target method. - - - - CORDBG_E_CODE_HAS_NO_METADATA - "Couldn't find metadata for the given executable code." - Couldn't find metadata for the given executable code. - - - - CORDBG_E_CODE_UNRECOGNIZED - "Given executable code is not managed." - Given executable code is not managed. - - - - CORDBG_E_NO_IMAGE_AVAILABLE - "Couldn't find a native image." - Couldn't find a native image. - - - - CORDBG_E_TYPE_NOT_FOUND - "The type doesn't exist in the given module." - The type doesn't exist in the given module. - - - - CORDBG_E_VTABLE_HAS_NO_METADATA - "Couldn't find metadata for the given vtable." - Couldn't find metadata for the given vtable. - - - - CORDBG_E_NO_GENERIC_INFO - "Couldn't find any generics information." - Couldn't find any generics information. - - - - PEFMT_E_NO_CONTENTS - "File is empty." - File is empty - - - - PEFMT_E_NO_NTHEADERS - "File has no NT headers." - File has no NT headers - - - - PEFMT_E_64BIT - "File is PE32+." - File is PE32+ - - - - PEFMT_E_NO_CORHEADER - "File has no COR header." - File has no COR header - - - - PEFMT_E_NOT_ILONLY - "Flag IL_ONLY not set." - Flag IL_ONLY not set - - - - PEFMT_E_IMPORT_DLLS - "Bad import DLLs." - Bad import DLLs - - - - PEFMT_E_EXE_NOENTRYPOINT - "EXE file has no mgd entry point." - EXE file has no mgd entry point - - - - PEFMT_E_BASE_RELOCS - "Bad base relocations." - Bad base relocations - - - - PEFMT_E_ENTRYPOINT - "Bad managed entry point." - Bad managed entry point - - - - PEFMT_E_ZERO_SIZEOFCODE - "OptHeader.SizeOfCode is set to zero." - OptHeader.SizeOfCode==0 - - - - PEFMT_E_BAD_CORHEADER - "File has invalid COR header." - File has invalid COR header - - - - PEFMT_E_32BIT - "File is PE32" - File is PE32 - - - - CLR_OPTSVC_E_CONTROLLER_INTERRUPT - "The operation was interrupted by the CLR Optimization Service controller." - Service controller interrupted work - - - - NGEN_FAILED_GET_DEPENDENCIES - "Failed to get dependencies for assembly." - Service manager failed to get ICorSvcDependencies interface - - - - NGEN_FAILED_NATIVE_IMAGE_DELETE - "Failed to delete native image." - Failed to delete native image - - - - NGEN_E_TOO_MANY_INTERFACES - "Module contains too many interfaces to successfully compile all methods." - Module contains too many interfaces to successfully compile all methods. - - - - NGEN_E_OLDER_RUNTIME - "Requested runtime does not support side-by-side NGen." - Requested runtime does not support side-by-side NGen. - - - - NGEN_E_WORKER_UNEXPECTED_EXIT - "Worker exited unexpectedly during startup" - An NGen worker process exited before it could be reached via DCOM. - - - - NGEN_E_WORKER_UNEXPECTED_SYNC - "Failed to synchronize with worker during startup" - Synchronizing with an NGen worker process returned an unexpected result. - - - - NGEN_E_SYS_ASM_NI_MISSING - "NGen cannot proceed because Mscorlib.dll does not have a native image" - Compiling any assembly other than mscorlib in the absence of mscorlib.ni.dll is not allowed. - - - - NGEN_E_EXE_MACHINE_TYPE_MISMATCH - "The image file is not compatible with the version of Ngen you're running. Use 32bit Ngen for 32bit assemblies, and 64bit Ngen for 64bit assemblies." - The image file is not compatible with the version of Ngen you're running. Use 32bit Ngen for 32bit assemblies, and 64bit Ngen for 64bit assemblies. - - - - NGEN_E_ASSEMBLY_EXCLUSION_FILE_PARSE_ERROR - "There was an error parsing the NGen assembly exclusion Xml file." - There was an error parsing the NGen assembly exclusion Xml file. - - - - NGEN_E_HARDBOUND_DEPENDENCY_MISSING - "A hardbound dependent native image is missing." - A hardbound dependent native image is missing. - - - - NGEN_E_NOT_RUNNING_IN_EXPECTED_PACKAGE - "NGen is not running in expected package." - NGen is not running in expected package. - - - - NGEN_E_FILE_NOT_ASSEMBLY - "The image being compiled is not a .NET assembly" - The image being compiled is not a .NET assembly - - - - CLDB_E_INTERNALERROR - - - - CLR_E_BIND_ASSEMBLY_VERSION_TOO_LOW - "The bound assembly has a version that is lower than that of the request." - For AppX binder, indicates that bound assembly has a version lower than that requested, and we will refuse version rollback. - - - - CLR_E_BIND_ASSEMBLY_PUBLIC_KEY_MISMATCH - "The assembly version has a public key token that does not match that of the request." - For AppX binder, indicates that bound assembly's public key token doesn't match the key in the assembly name. - - - - CLR_E_BIND_IMAGE_UNAVAILABLE - "The requested image was not found or is unavailable." - Occurs if a request for a native image is made on an ICLRPrivAssembly interface when one is not available. - - - - CLR_E_BIND_UNRECOGNIZED_IDENTITY_FORMAT - "The provided identity format is not recognized." - If a binder is provided an identity format that it cannot parse, it returns this error. - - - - CLR_E_BIND_ASSEMBLY_NOT_FOUND - "A binding for the specified assembly name was not found." - Returned by binders that bind based on assembly identity. - - - - CLR_E_BIND_TYPE_NOT_FOUND - "A binding for the specified type name was not found." - Returned by binders that bind based on type identity. - - - - CLR_E_BIND_SYS_ASM_NI_MISSING - "Could not use native image because Mscorlib.dll is missing a native image" - Returned when loading an assembly that only has a native image and no IL and cannot hardbind to mscorlib.ni.dll. - - - - CLR_E_BIND_NI_SECURITY_FAILURE - "Native image was generated in a different trust level than present at runtime" - Returned when an assembly is NGened in full trust and then used in partial trust or vice versa. - - - - CLR_E_BIND_NI_DEP_IDENTITY_MISMATCH - "Native image identity mismatch with respect to its dependencies" - Returned when an assembly's identities have changed so the native image is no longer valid. - - - - CLR_E_GC_OOM - "Failfast due to an OOM during a GC" - During a GC when we try to allocate memory for GC datastructures we could not. - - - - COR_E_UNAUTHORIZEDACCESS - 0x80070005 // Access is denied. - - - - COR_E_ARGUMENT - 0x80070057 // An argument does not meet the contract of the method. - - - - COR_E_INVALIDCAST - 0x80004002 // Indicates a bad cast condition - - - - COR_E_OUTOFMEMORY - 0x8007000E // The EE thows this exception when no more memory is avaible to continue execution - - - - COR_E_NULLREFERENCE - 0x80004003 // Dereferencing a null reference. In general class libraries should not throw this - - - - COR_E_ARITHMETIC - 0x80070216 // Overflow or underflow in mathematical operations. - - - - COR_E_BAD_PATHNAME - The specified path is invalid. - - - - COR_E_PATHTOOLONG - The specified path was too long. - - - - COR_E_FILENOTFOUND - - - - - COR_E_ENDOFSTREAM - Thrown when the End of file is reached - - - - COR_E_DIRECTORYNOTFOUND - The specified path couldn't be found. - - - - COR_E_STACKOVERFLOW - 0x800703E9 // Is raised by the EE when the execution stack overflows as it is attempting to ex - - - - COR_E_AMBIGUOUSMATCH - While late binding to a method via reflection, could not resolve between - - - - COR_E_TARGETPARAMCOUNT - DISP_E_BADPARAMCOUNT // There was a mismatch between number of arguments provided and the number expected - - - - COR_E_DIVIDEBYZERO - DISP_E_DIVBYZERO // Attempted to divide a number by zero. - - - - COR_E_BADIMAGEFORMAT - "The format of a DLL or executable being loaded is invalid." - The format of DLL or executable being loaded is invalid. - - - - diff --git a/src/inc/corhlprpriv.cpp b/src/inc/corhlprpriv.cpp deleted file mode 100644 index 47e0cb13d..000000000 --- a/src/inc/corhlprpriv.cpp +++ /dev/null @@ -1,313 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/**************************************************************************** - ** ** - ** Corhlprpriv.cpp - signature helpers. ** - ** ** - ****************************************************************************/ -#ifndef SOS_INCLUDE - -#ifdef _BLD_CLR -#include "utilcode.h" -#endif -#include "corhlprpriv.h" -#include - -/************************************************************************************* -* -* implementation of CQuickMemoryBase -* -*************************************************************************************/ - -template -HRESULT CQuickMemoryBase::ReSizeNoThrow(SIZE_T iItems) -{ -#ifdef _BLD_CLR -#ifdef _DEBUG -#ifndef DACCESS_COMPILE - // Exercise heap for OOM-fault injection purposes - // But we can't do this if current thread suspends EE - if (!IsSuspendEEThread ()) - { - BYTE *pTmp = NEW_NOTHROW(iItems); - if (!pTmp) - { - return E_OUTOFMEMORY; - } - delete [] pTmp; - } -#endif -#endif -#endif - BYTE *pbBuffNew; - if (iItems <= cbTotal) - { - iSize = iItems; - return NOERROR; - } - -#ifdef _BLD_CLR -#ifndef DACCESS_COMPILE - // not allowed to do allocation if current thread suspends EE - if (IsSuspendEEThread ()) - return E_OUTOFMEMORY; -#endif -#endif - pbBuffNew = NEW_NOTHROW(iItems + INCREMENT); - if (!pbBuffNew) - return E_OUTOFMEMORY; - if (pbBuff) - { - memcpy(pbBuffNew, pbBuff, cbTotal); - delete [] pbBuff; - } - else - { - _ASSERTE(cbTotal == SIZE); - memcpy(pbBuffNew, rgData, cbTotal); - } - cbTotal = iItems + INCREMENT; - iSize = iItems; - pbBuff = pbBuffNew; - return NOERROR; -} - - -/************************************************************************************* -* -* get number of bytes consumed by one argument/return type -* -*************************************************************************************/ -#define CHECK_REMAINDER if(cbTotal >= cbTotalMax){hr=E_FAIL; goto ErrExit;} -HRESULT _CountBytesOfOneArg( - PCCOR_SIGNATURE pbSig, - ULONG *pcbTotal) // Initially, *pcbTotal contains the remaining size of the sig blob -{ - ULONG cb; - ULONG cbTotal=0; - ULONG cbTotalMax; - CorElementType ulElementType; - ULONG ulData; - ULONG ulTemp; - int iData; - mdToken tk; - ULONG cArg; - ULONG callingconv; - ULONG cArgsIndex; - HRESULT hr = NOERROR; - - if(pcbTotal==NULL) return E_FAIL; - cbTotalMax = *pcbTotal; - - CHECK_REMAINDER; - cbTotal = CorSigUncompressElementType(pbSig, &ulElementType); - while (CorIsModifierElementType((CorElementType) ulElementType)) - { - CHECK_REMAINDER; - cbTotal += CorSigUncompressElementType(&pbSig[cbTotal], &ulElementType); - } - switch (ulElementType) - { - case ELEMENT_TYPE_SZARRAY: - case 0x1e /* obsolete */: - // skip over base type - CHECK_REMAINDER; - cb = cbTotalMax - cbTotal; - IfFailGo( _CountBytesOfOneArg(&pbSig[cbTotal], &cb) ); - cbTotal += cb; - break; - - case ELEMENT_TYPE_FNPTR: - CHECK_REMAINDER; - cbTotal += CorSigUncompressData (&pbSig[cbTotal], &callingconv); - - // remember number of bytes to represent the arg counts - CHECK_REMAINDER; - cbTotal += CorSigUncompressData (&pbSig[cbTotal], &cArg); - - // how many bytes to represent the return type - CHECK_REMAINDER; - cb = cbTotalMax - cbTotal; - IfFailGo( _CountBytesOfOneArg( &pbSig[cbTotal], &cb) ); - cbTotal += cb; - - // loop through argument - for (cArgsIndex = 0; cArgsIndex < cArg; cArgsIndex++) - { - CHECK_REMAINDER; - cb = cbTotalMax - cbTotal; - IfFailGo( _CountBytesOfOneArg( &pbSig[cbTotal], &cb) ); - cbTotal += cb; - } - - break; - - case ELEMENT_TYPE_ARRAY: - // syntax : ARRAY BaseType [i size_1... size_i] [j lowerbound_1 ... lowerbound_j] - - // skip over base type - CHECK_REMAINDER; - cb = cbTotalMax - cbTotal; - IfFailGo( _CountBytesOfOneArg(&pbSig[cbTotal], &cb) ); - cbTotal += cb; - - // Parse for the rank - CHECK_REMAINDER; - cbTotal += CorSigUncompressData(&pbSig[cbTotal], &ulData); - - // if rank == 0, we are done - if (ulData == 0) - break; - - // any size of dimension specified? - CHECK_REMAINDER; - cbTotal += CorSigUncompressData(&pbSig[cbTotal], &ulData); - while (ulData--) - { - CHECK_REMAINDER; - cbTotal += CorSigUncompressData(&pbSig[cbTotal], &ulTemp); - } - - // any lower bound specified? - CHECK_REMAINDER; - cbTotal += CorSigUncompressData(&pbSig[cbTotal], &ulData); - - while (ulData--) - { - CHECK_REMAINDER; - cbTotal += CorSigUncompressSignedInt(&pbSig[cbTotal], &iData); - } - - break; - case ELEMENT_TYPE_VALUETYPE: - case ELEMENT_TYPE_CLASS: - case ELEMENT_TYPE_CMOD_REQD: - case ELEMENT_TYPE_CMOD_OPT: - // count the bytes for the token compression - CHECK_REMAINDER; - cbTotal += CorSigUncompressToken(&pbSig[cbTotal], &tk); - if ( ulElementType == ELEMENT_TYPE_CMOD_REQD || - ulElementType == ELEMENT_TYPE_CMOD_OPT) - { - // skip over base type - CHECK_REMAINDER; - cb = cbTotalMax - cbTotal; - IfFailGo( _CountBytesOfOneArg(&pbSig[cbTotal], &cb) ); - cbTotal += cb; - } - break; - default: - break; - } - - *pcbTotal = cbTotal; -ErrExit: - return hr; -} -#undef CHECK_REMAINDER - -//***************************************************************************** -// copy fixed part of VarArg signature to a buffer -//***************************************************************************** -HRESULT _GetFixedSigOfVarArg( // S_OK or error. - PCCOR_SIGNATURE pvSigBlob, // [IN] point to a blob of COM+ method signature - ULONG cbSigBlob, // [IN] size of signature - CQuickBytes *pqbSig, // [OUT] output buffer for fixed part of VarArg Signature - ULONG *pcbSigBlob) // [OUT] number of bytes written to the above output buffer -{ - HRESULT hr = NOERROR; - ULONG cbCalling; - ULONG cbTyArgsNumber = 0; // number of bytes to store the type arg count (generics only) - ULONG cbArgsNumber; // number of bytes to store the original arg count - ULONG cbArgsNumberTemp; // number of bytes to store the fixed arg count - ULONG cbTotal = 0; // total of number bytes for return type + all fixed arguments - ULONG cbCur = 0; // index through the pvSigBlob - ULONG cb; - ULONG cArg; - ULONG cTyArg; - ULONG callingconv; - ULONG cArgsIndex; - CorElementType ulElementType; - BYTE *pbSig; - - _ASSERTE (pvSigBlob && pcbSigBlob); - - // remember the number of bytes to represent the calling convention - cbCalling = CorSigUncompressData (pvSigBlob, &callingconv); - if (cbCalling == ((ULONG)(-1))) - { - return E_INVALIDARG; - } - _ASSERTE (isCallConv(callingconv, IMAGE_CEE_CS_CALLCONV_VARARG)); - cbCur += cbCalling; - - if (callingconv & IMAGE_CEE_CS_CALLCONV_GENERIC) - { - cbTyArgsNumber = CorSigUncompressData(&pvSigBlob[cbCur], &cTyArg); - if (cbTyArgsNumber == ((ULONG)(-1))) - { - return E_INVALIDARG; - } - cbCur += cbTyArgsNumber; - } - - // remember number of bytes to represent the arg counts - cbArgsNumber= CorSigUncompressData (&pvSigBlob[cbCur], &cArg); - if (cbArgsNumber == ((ULONG)(-1))) - { - return E_INVALIDARG; - } - - cbCur += cbArgsNumber; - - // how many bytes to represent the return type - cb = cbSigBlob-cbCur; - IfFailGo( _CountBytesOfOneArg( &pvSigBlob[cbCur], &cb) ); - cbCur += cb; - cbTotal += cb; - - // loop through argument until we found ELEMENT_TYPE_SENTINEL or run - // out of arguments - for (cArgsIndex = 0; cArgsIndex < cArg; cArgsIndex++) - { - _ASSERTE(cbCur < cbSigBlob); - - // peak the outer most ELEMENT_TYPE_* - CorSigUncompressElementType (&pvSigBlob[cbCur], &ulElementType); - if (ulElementType == ELEMENT_TYPE_SENTINEL) - break; - cb = cbSigBlob-cbCur; - IfFailGo( _CountBytesOfOneArg( &pvSigBlob[cbCur], &cb) ); - cbTotal += cb; - cbCur += cb; - } - - cbArgsNumberTemp = CorSigCompressData(cArgsIndex, &cArg); - - // now cbCalling : the number of bytes needed to store the calling convention - // cbArgNumberTemp : number of bytes to store the fixed arg count - // cbTotal : the number of bytes to store the ret and fixed arguments - - *pcbSigBlob = cbCalling + cbArgsNumberTemp + cbTotal; - - // resize the buffer - IfFailGo( pqbSig->ReSizeNoThrow(*pcbSigBlob) ); - pbSig = (BYTE *)pqbSig->Ptr(); - - // copy over the calling convention - cb = CorSigCompressData(callingconv, pbSig); - - // copy over the fixed arg count - cbArgsNumberTemp = CorSigCompressData(cArgsIndex, &pbSig[cb]); - - // copy over the fixed args + ret type - memcpy(&pbSig[cb + cbArgsNumberTemp], &pvSigBlob[cbCalling + cbArgsNumber], cbTotal); - -ErrExit: - return hr; -} - - -#endif // !SOS_INCLUDE diff --git a/src/inc/corhlprpriv.h b/src/inc/corhlprpriv.h deleted file mode 100644 index 73b89951d..000000000 --- a/src/inc/corhlprpriv.h +++ /dev/null @@ -1,773 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/***************************************************************************** - ** ** - ** Corhlprpriv.h - ** - ** ** - *****************************************************************************/ - -#ifndef __CORHLPRPRIV_H__ -#define __CORHLPRPRIV_H__ - -#include "corhlpr.h" -#include "fstring.h" - -#if defined(_MSC_VER) && defined(_TARGET_X86_) -#pragma optimize("y", on) // If routines don't get inlined, don't pay the EBP frame penalty -#endif - -//***************************************************************************** -// -//***** Utility helpers -// -//***************************************************************************** - -#ifndef SOS_INCLUDE - -//***************************************************************************** -// -// **** CQuickBytes -// This helper class is useful for cases where 90% of the time you allocate 512 -// or less bytes for a data structure. This class contains a 512 byte buffer. -// Alloc() will return a pointer to this buffer if your allocation is small -// enough, otherwise it asks the heap for a larger buffer which is freed for -// you. No mutex locking is required for the small allocation case, making the -// code run faster, less heap fragmentation, etc... Each instance will allocate -// 520 bytes, so use accordinly. -// -//***************************************************************************** -namespace NSQuickBytesHelper -{ - template - struct _AllocBytes; - - template <> - struct _AllocBytes - { - static BYTE *Invoke(SIZE_T iItems) - { - return NEW_THROWS(iItems); - } - }; - - template <> - struct _AllocBytes - { - static BYTE *Invoke(SIZE_T iItems) - { - return NEW_NOTHROW(iItems); - } - }; -}; - -void DECLSPEC_NORETURN ThrowHR(HRESULT hr); - -template -class CQuickMemoryBase -{ -protected: - template - static ELEM_T Min(ELEM_T a, ELEM_T b) - { return a < b ? a : b; } - - template - static ELEM_T Max(ELEM_T a, ELEM_T b) - { return a < b ? b : a; } - - // bGrow - indicates that this is a resize and that the original data - // needs to be copied over. - // bThrow - indicates whether or not memory allocations will throw. - template - void *_Alloc(SIZE_T iItems) - { -#if defined(_BLD_CLR) && defined(_DEBUG) - { // Exercise heap for OOM-fault injection purposes - BYTE * pb = NSQuickBytesHelper::_AllocBytes::Invoke(iItems); - _ASSERTE(!bThrow || pb != NULL); // _AllocBytes would have thrown if bThrow == TRUE - if (pb == NULL) return NULL; // bThrow == FALSE and we failed to allocate memory - delete [] pb; // Success, delete allocated memory. - } -#endif - if (iItems <= cbTotal) - { // Fits within existing memory allocation - iSize = iItems; - } - else if (iItems <= SIZE) - { // Will fit in internal buffer. - if (pbBuff == NULL) - { // Any previous allocation is in the internal buffer and the new - // allocation fits in the internal buffer, so just update the size. - iSize = iItems; - cbTotal = SIZE; - } - else - { // There was a previous allocation, sitting in pbBuff - if (bGrow) - { // If growing, need to copy any existing data over. - memcpy(&rgData[0], pbBuff, Min(cbTotal, SIZE)); - } - - delete [] pbBuff; - pbBuff = NULL; - iSize = iItems; - cbTotal = SIZE; - } - } - else - { // Need to allocate a new buffer - SIZE_T cbTotalNew = iItems + (bGrow ? INCREMENT : 0); - BYTE * pbBuffNew = NSQuickBytesHelper::_AllocBytes::Invoke(cbTotalNew); - - if (!bThrow && pbBuffNew == NULL) - { // Allocation failed. Zero out structure. - if (pbBuff != NULL) - { // Delete old buffer - delete [] pbBuff; - } - pbBuff = NULL; - iSize = 0; - cbTotal = 0; - return NULL; - } - - if (bGrow && cbTotal > 0) - { // If growing, need to copy any existing data over. - memcpy(pbBuffNew, (BYTE *)Ptr(), Min(cbTotal, cbTotalNew)); - } - - if (pbBuff != NULL) - { // Delete old pre-existing buffer - delete [] pbBuff; - pbBuff = NULL; - } - - pbBuff = pbBuffNew; - cbTotal = cbTotalNew; - iSize = iItems; - } - - return Ptr(); - } - -public: - void Init() - { - pbBuff = 0; - iSize = 0; - cbTotal = SIZE; - } - - void Destroy() - { - if (pbBuff) - { - delete [] pbBuff; - pbBuff = 0; - } - } - - void *AllocThrows(SIZE_T iItems) - { - return _Alloc(iItems); - } - - void *AllocNoThrow(SIZE_T iItems) - { - return _Alloc(iItems); - } - - void ReSizeThrows(SIZE_T iItems) - { - _Alloc(iItems); - } - -#ifdef __llvm__ - // This makes sure that we will not get an undefined symbol - // when building a release version of libcoreclr using LLVM. - __attribute__((used)) -#endif // __llvm__ - HRESULT ReSizeNoThrow(SIZE_T iItems); - - void Shrink(SIZE_T iItems) - { - _ASSERTE(iItems <= cbTotal); - iSize = iItems; - } - - operator PVOID() - { - return ((pbBuff) ? pbBuff : (PVOID)&rgData[0]); - } - - void *Ptr() - { - return ((pbBuff) ? pbBuff : (PVOID)&rgData[0]); - } - - const void *Ptr() const - { - return ((pbBuff) ? pbBuff : (PVOID)&rgData[0]); - } - - SIZE_T Size() const - { - return (iSize); - } - - SIZE_T MaxSize() const - { - return (cbTotal); - } - - void Maximize() - { - iSize = cbTotal; - } - - - // Convert UTF8 string to UNICODE string, optimized for speed - HRESULT ConvertUtf8_UnicodeNoThrow(const char * utf8str) - { - bool allAscii; - DWORD length; - - HRESULT hr = FString::Utf8_Unicode_Length(utf8str, & allAscii, & length); - - if (SUCCEEDED(hr)) - { - LPWSTR buffer = (LPWSTR) AllocNoThrow((length + 1) * sizeof(WCHAR)); - - if (buffer == NULL) - { - hr = E_OUTOFMEMORY; - } - else - { - hr = FString::Utf8_Unicode(utf8str, allAscii, buffer, length); - } - } - - return hr; - } - - // Convert UTF8 string to UNICODE string, optimized for speed - void ConvertUtf8_Unicode(const char * utf8str) - { - bool allAscii; - DWORD length; - - HRESULT hr = FString::Utf8_Unicode_Length(utf8str, & allAscii, & length); - - if (SUCCEEDED(hr)) - { - LPWSTR buffer = (LPWSTR) AllocThrows((length + 1) * sizeof(WCHAR)); - - hr = FString::Utf8_Unicode(utf8str, allAscii, buffer, length); - } - - if (FAILED(hr)) - { - ThrowHR(hr); - } - } - - // Convert UNICODE string to UTF8 string, optimized for speed - void ConvertUnicode_Utf8(const WCHAR * pString) - { - bool allAscii; - DWORD length; - - HRESULT hr = FString::Unicode_Utf8_Length(pString, & allAscii, & length); - - if (SUCCEEDED(hr)) - { - LPSTR buffer = (LPSTR) AllocThrows((length + 1) * sizeof(char)); - - hr = FString::Unicode_Utf8(pString, allAscii, buffer, length); - } - - if (FAILED(hr)) - { - ThrowHR(hr); - } - } - - // Copy single byte string and hold it - const char * SetStringNoThrow(const char * pStr, SIZE_T len) - { - LPSTR buffer = (LPSTR) AllocNoThrow(len + 1); - - if (buffer != NULL) - { - memcpy(buffer, pStr, len); - buffer[len] = 0; - } - - return buffer; - } - -#ifdef DACCESS_COMPILE - void - EnumMemoryRegions(CLRDataEnumMemoryFlags flags) - { - // Assume that 'this' is enumerated, either explicitly - // or because this class is embedded in another. - DacEnumMemoryRegion(dac_cast(pbBuff), iSize); - } -#endif // DACCESS_COMPILE - - BYTE *pbBuff; - SIZE_T iSize; // number of bytes used - SIZE_T cbTotal; // total bytes allocated in the buffer - // use UINT64 to enforce the alignment of the memory - UINT64 rgData[(SIZE+sizeof(UINT64)-1)/sizeof(UINT64)]; -}; - -// These should be multiples of 8 so that data can be naturally aligned. -#define CQUICKBYTES_BASE_SIZE 512 -#define CQUICKBYTES_INCREMENTAL_SIZE 128 - -class CQuickBytesBase : public CQuickMemoryBase -{ -}; - - -class CQuickBytes : public CQuickBytesBase -{ -public: - CQuickBytes() - { - Init(); - } - - ~CQuickBytes() - { - Destroy(); - } -}; - -/* to be used as static variable - no constructor/destructor, assumes zero - initialized memory */ -class CQuickBytesStatic : public CQuickBytesBase -{ -}; - -template -class CQuickBytesSpecifySizeBase : public CQuickMemoryBase -{ -}; - -template -class CQuickBytesSpecifySize : public CQuickBytesSpecifySizeBase -{ -public: - CQuickBytesSpecifySize() - { - this->Init(); - } - - ~CQuickBytesSpecifySize() - { - this->Destroy(); - } -}; - -/* to be used as static variable - no constructor/destructor, assumes zero - initialized memory */ -template -class CQuickBytesSpecifySizeStatic : public CQuickBytesSpecifySizeBase -{ -}; - -template class CQuickArrayBase : public CQuickBytesBase -{ -public: - T* AllocThrows(SIZE_T iItems) - { - CheckOverflowThrows(iItems); - return (T*)CQuickBytesBase::AllocThrows(iItems * sizeof(T)); - } - - void ReSizeThrows(SIZE_T iItems) - { - CheckOverflowThrows(iItems); - CQuickBytesBase::ReSizeThrows(iItems * sizeof(T)); - } - - T* AllocNoThrow(SIZE_T iItems) - { - if (!CheckOverflowNoThrow(iItems)) - { - return NULL; - } - return (T*)CQuickBytesBase::AllocNoThrow(iItems * sizeof(T)); - } - - HRESULT ReSizeNoThrow(SIZE_T iItems) - { - if (!CheckOverflowNoThrow(iItems)) - { - return E_OUTOFMEMORY; - } - return CQuickBytesBase::ReSizeNoThrow(iItems * sizeof(T)); - } - - void Shrink(SIZE_T iItems) - { - CQuickBytesBase::Shrink(iItems * sizeof(T)); - } - - T* Ptr() - { - return (T*) CQuickBytesBase::Ptr(); - } - - const T* Ptr() const - { - return (T*) CQuickBytesBase::Ptr(); - } - - SIZE_T Size() const - { - return CQuickBytesBase::Size() / sizeof(T); - } - - SIZE_T MaxSize() const - { - return CQuickBytesBase::cbTotal / sizeof(T); - } - - T& operator[] (SIZE_T ix) - { - _ASSERTE(ix < Size()); - return *(Ptr() + ix); - } - - const T& operator[] (SIZE_T ix) const - { - _ASSERTE(ix < Size()); - return *(Ptr() + ix); - } - -private: - inline - BOOL CheckOverflowNoThrow(SIZE_T iItems) - { - SIZE_T totalSize = iItems * sizeof(T); - - if (totalSize / sizeof(T) != iItems) - { - return FALSE; - } - - return TRUE; - } - - inline - void CheckOverflowThrows(SIZE_T iItems) - { - if (!CheckOverflowNoThrow(iItems)) - { - THROW_OUT_OF_MEMORY(); - } - } -}; - -template class CQuickArray : public CQuickArrayBase -{ -public: - CQuickArray() - { - this->Init(); - } - - ~CQuickArray() - { - this->Destroy(); - } -}; - -// This is actually more of a stack with array access. Essentially, you can -// only add elements through Push and remove them through Pop, but you can -// access and modify any random element with the index operator. You cannot -// access elements that have not been added. - -template -class CQuickArrayList : protected CQuickArray -{ -private: - SIZE_T m_curSize; - -public: - // Make these specific functions public. - using CQuickArray::AllocThrows; - using CQuickArray::ReSizeThrows; - using CQuickArray::AllocNoThrow; - using CQuickArray::ReSizeNoThrow; - using CQuickArray::MaxSize; - - CQuickArrayList() - : m_curSize(0) - { - this->Init(); - } - - ~CQuickArrayList() - { - this->Destroy(); - } - - // Can only access values that have been pushed. - T& operator[] (SIZE_T ix) - { - _ASSERTE(ix < m_curSize); - return CQuickArray::operator[](ix); - } - - // Can only access values that have been pushed. - const T& operator[] (SIZE_T ix) const - { - _ASSERTE(ix < m_curSize); - return CQuickArray::operator[](ix); - } - - // THROWS: Resizes if necessary. - void Push(const T & value) - { - // Resize if necessary - thows. - if (m_curSize + 1 >= CQuickArray::Size()) - ReSizeThrows((m_curSize + 1) * 2); - - // Append element to end of array. - _ASSERTE(m_curSize + 1 < CQuickArray::Size()); - SIZE_T ix = m_curSize++; - (*this)[ix] = value; - } - - T Pop() - { - _ASSERTE(m_curSize > 0); - T retval = (*this)[m_curSize - 1]; - INDEBUG(ZeroMemory(&(this->Ptr()[m_curSize - 1]), sizeof(T));) - --m_curSize; - return retval; - } - - SIZE_T Size() const - { - return m_curSize; - } - - void Shrink() - { - CQuickArray::Shrink(m_curSize); - } -}; - - -/* to be used as static variable - no constructor/destructor, assumes zero - initialized memory */ -template class CQuickArrayStatic : public CQuickArrayBase -{ -}; - -typedef CQuickArrayBase CQuickWSTRBase; -typedef CQuickArray CQuickWSTR; -typedef CQuickArrayStatic CQuickWSTRStatic; - -typedef CQuickArrayBase CQuickSTRBase; -typedef CQuickArray CQuickSTR; -typedef CQuickArrayStatic CQuickSTRStatic; - -class RidBitmap -{ -public: - HRESULT InsertToken(mdToken token) - { - HRESULT hr = S_OK; - mdToken rid = RidFromToken(token); - SIZE_T index = rid / 8; - BYTE bit = (1 << (rid % 8)); - - if (index >= buffer.Size()) - { - SIZE_T oldSize = buffer.Size(); - SIZE_T newSize = index+1+oldSize/8; - IfFailRet(buffer.ReSizeNoThrow(newSize)); - memset(&buffer[oldSize], 0, newSize-oldSize); - } - - buffer[index] |= bit; - return hr; - } - - bool IsTokenInBitmap(mdToken token) - { - mdToken rid = RidFromToken(token); - SIZE_T index = rid / 8; - BYTE bit = (1 << (rid % 8)); - - return ((index < buffer.Size()) && (buffer[index] & bit)); - } - - void Reset() - { - if (buffer.Size()) - { - memset(&buffer[0], 0, buffer.Size()); - } - } - -private: - CQuickArray buffer; -}; - -//***************************************************************************** -// -//***** Signature helpers -// -//***************************************************************************** - -HRESULT _CountBytesOfOneArg( - PCCOR_SIGNATURE pbSig, - ULONG *pcbTotal); - -HRESULT _GetFixedSigOfVarArg( // S_OK or error. - PCCOR_SIGNATURE pvSigBlob, // [IN] point to a blob of CLR signature - ULONG cbSigBlob, // [IN] size of signature - CQuickBytes *pqbSig, // [OUT] output buffer for fixed part of VarArg Signature - ULONG *pcbSigBlob); // [OUT] number of bytes written to the above output buffer - -#endif //!SOS_INCLUDE - -#if defined(_MSC_VER) && defined(_TARGET_X86_) -#pragma optimize("", on) // restore command line default optimizations -#endif - - -//--------------------------------------------------------------------------------------- -// -// Reads compressed integer from buffer pData, fills the result to *pnDataOut. Advances buffer pointer. -// Doesn't read behind the end of the buffer (the end starts at pDataEnd). -// -inline -__checkReturn -HRESULT -CorSigUncompressData_EndPtr( - PCCOR_SIGNATURE & pData, // [IN,OUT] Buffer - PCCOR_SIGNATURE pDataEnd, // End of buffer - DWORD * pnDataOut) // [OUT] Compressed integer read from the buffer -{ - _ASSERTE(pData <= pDataEnd); - HRESULT hr = S_OK; - - INT_PTR cbDataSize = pDataEnd - pData; - if (cbDataSize > 4) - { // Compressed integer cannot be bigger than 4 bytes - cbDataSize = 4; - } - DWORD dwDataSize = (DWORD)cbDataSize; - - ULONG cbDataOutLength; - IfFailRet(CorSigUncompressData( - pData, - dwDataSize, - pnDataOut, - &cbDataOutLength)); - pData += cbDataOutLength; - - return hr; -} // CorSigUncompressData_EndPtr - -//--------------------------------------------------------------------------------------- -// -// Reads CorElementType (1 byte) from buffer pData, fills the result to *pTypeOut. Advances buffer pointer. -// Doesn't read behind the end of the buffer (the end starts at pDataEnd). -// -inline -__checkReturn -HRESULT -CorSigUncompressElementType_EndPtr( - PCCOR_SIGNATURE & pData, // [IN,OUT] Buffer - PCCOR_SIGNATURE pDataEnd, // End of buffer - CorElementType * pTypeOut) // [OUT] ELEMENT_TYPE_* value read from the buffer -{ - _ASSERTE(pData <= pDataEnd); - // We don't expect pData > pDataEnd, but the runtime check doesn't cost much and it is more secure in - // case caller has a bug - if (pData >= pDataEnd) - { // No data - return META_E_BAD_SIGNATURE; - } - // Read 'type' as 1 byte - *pTypeOut = (CorElementType)*pData; - pData++; - - return S_OK; -} // CorSigUncompressElementType_EndPtr - -//--------------------------------------------------------------------------------------- -// -// Reads pointer (4/8 bytes) from buffer pData, fills the result to *ppvPointerOut. Advances buffer pointer. -// Doesn't read behind the end of the buffer (the end starts at pDataEnd). -// -inline -__checkReturn -HRESULT -CorSigUncompressPointer_EndPtr( - PCCOR_SIGNATURE & pData, // [IN,OUT] Buffer - PCCOR_SIGNATURE pDataEnd, // End of buffer - void ** ppvPointerOut) // [OUT] Pointer value read from the buffer -{ - _ASSERTE(pData <= pDataEnd); - // We could just skip this check as pointers should be only in trusted (and therefore correct) - // signatures and we check for that on the caller side, but it won't hurt to have this check and it will - // make it easier to catch invalid signatures in trusted code (e.g. IL stubs, NGEN images, etc.) - if (pData + sizeof(void *) > pDataEnd) - { // Not enough data in the buffer - _ASSERTE(!"This signature is invalid. Note that caller should check that it is not comming from untrusted source!"); - return META_E_BAD_SIGNATURE; - } - *ppvPointerOut = *(void * UNALIGNED *)pData; - pData += sizeof(void *); - - return S_OK; -} // CorSigUncompressPointer_EndPtr - -//--------------------------------------------------------------------------------------- -// -// Reads compressed TypeDef/TypeRef/TypeSpec token, fills the result to *pnDataOut. Advances buffer pointer. -// Doesn't read behind the end of the buffer (the end starts at pDataEnd). -// -inline -__checkReturn -HRESULT -CorSigUncompressToken_EndPtr( - PCCOR_SIGNATURE & pData, // [IN,OUT] Buffer - PCCOR_SIGNATURE pDataEnd, // End of buffer - mdToken * ptkTokenOut) // [OUT] Token read from the buffer -{ - _ASSERTE(pData <= pDataEnd); - HRESULT hr = S_OK; - - INT_PTR cbDataSize = pDataEnd - pData; - if (cbDataSize > 4) - { // Compressed token cannot be bigger than 4 bytes - cbDataSize = 4; - } - DWORD dwDataSize = (DWORD)cbDataSize; - - ULONG cbTokenOutLength; - IfFailRet(CorSigUncompressToken( - pData, - dwDataSize, - ptkTokenOut, - &cbTokenOutLength)); - pData += cbTokenOutLength; - - return hr; -} // CorSigUncompressToken_EndPtr - -#endif // __CORHLPRPRIV_H__ diff --git a/src/inc/corhost.h b/src/inc/corhost.h deleted file mode 100644 index 299057615..000000000 --- a/src/inc/corhost.h +++ /dev/null @@ -1,479 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -// - -// -//***************************************************************************** -// CorHost.h -// -// Class factories are used by the pluming in COM to activate new objects. -// This module contains the class factory code to instantiate the debugger -// objects described in . -// -//***************************************************************************** - -#ifndef __CorHost__h__ -#define __CorHost__h__ - - -#include "windows.h" // worth to include before mscoree.h so we are guaranteed to pick few definitions -#ifdef CreateSemaphore -#undef CreateSemaphore -#endif - -#include "mscoree.h" - -#include "clrinternal.h" - -#include "holder.h" - -#include "clrprivhosting.h" - -#ifdef FEATURE_COMINTEROP -#include "activation.h" // WinRT activation. -#endif - -class DangerousNonHostedSpinLock; - -#define INVALID_STACK_BASE_MARKER_FOR_CHECK_STATE 2 - -class AppDomain; -class Assembly; - - -class CorExecutionManager - : public ICLRExecutionManager -{ -public: - CorExecutionManager(); - - STDMETHODIMP STDMETHODCALLTYPE Pause(DWORD dwAppDomainId, DWORD dwFlags); - STDMETHODIMP STDMETHODCALLTYPE Resume(DWORD dwAppDomainId); - -private: - DWORD m_dwFlags; //flags passed to the last Pause call. - INT64 m_pauseStartTime; -}; - -class CorRuntimeHostBase -{ -protected: - CorRuntimeHostBase() - :m_Started(FALSE), - m_cRef(0) - , m_fStarted(FALSE) - {LIMITED_METHOD_CONTRACT;} - - STDMETHODIMP_(ULONG) AddRef(void); - - // Starts the runtime. This is equivalent to CoInitializeCor() - STDMETHODIMP Start(); - -#ifdef FEATURE_COMINTEROP - // Creates a domain in the runtime. The identity array is - // a pointer to an array TYPE containing IIdentity objects defining - // the security identity. - STDMETHODIMP CreateDomain(LPCWSTR pwzFriendlyName, // Optional - IUnknown* pIdentityArray, // Optional - IUnknown ** pAppDomain); - - // Returns the default domain. - STDMETHODIMP GetDefaultDomain(IUnknown ** pAppDomain); - - // Enumerate currently existing domains. - STDMETHODIMP EnumDomains(HDOMAINENUM *hEnum); - - // Returns S_FALSE when there are no more domains. A domain - // is passed out only when S_OK is returned. - STDMETHODIMP NextDomain(HDOMAINENUM hEnum, - IUnknown** pAppDomain); - - // Close the enumeration releasing resources - STDMETHODIMP CloseEnum(HDOMAINENUM hEnum); - - STDMETHODIMP CreateDomainEx(LPCWSTR pwzFriendlyName, - IUnknown* pSetup, // Optional - IUnknown* pEvidence, // Optional - IUnknown ** pAppDomain); - - // Create appdomain setup object that can be passed into CreateDomainEx - STDMETHODIMP CreateDomainSetup(IUnknown** pAppDomainSetup); - - // Create Evidence object that can be passed into CreateDomainEx - STDMETHODIMP CreateEvidence(IUnknown** pEvidence); - - // Unload a domain, releasing the reference will only release the - // the wrapper to the domain not unload the domain. - STDMETHODIMP UnloadDomain(IUnknown* pAppDomain); - - // Returns the threads domain if there is one. - STDMETHODIMP CurrentDomain(IUnknown ** pAppDomain); -#endif // FEATURE_COMINTEROP - - STDMETHODIMP MapFile( // Return code. - HANDLE hFile, // [in] Handle for file - HMODULE *hMapAddress // [out] HINSTANCE for mapped file - ); - - STDMETHODIMP LocksHeldByLogicalThread( // Return code. - DWORD *pCount // [out] Number of locks that the current thread holds. - ); - -protected: - BOOL m_Started; // Has START been called? - - LONG m_cRef; // Ref count. - - // This flag will be used to ensure that a CoreCLR host can invoke Start/Stop in pairs only. - BOOL m_fStarted; - BOOL m_fAppDomainCreated; // this flag is used when an appdomain can only create a single appdomain - - static ULONG m_Version; // Version of ICorRuntimeHost. - // Some functions are only available in ICLRRuntimeHost. - // Some functions are no-op in ICLRRuntimeHost. - - STDMETHODIMP UnloadAppDomain(DWORD dwDomainId, BOOL fWaitUntilDone); - - STDMETHODIMP UnloadAppDomain2(DWORD dwDomainId, BOOL fWaitUntilDone, int *pLatchedExitCode); -public: - static ULONG GetHostVersion() - { - LIMITED_METHOD_CONTRACT; - _ASSERTE (m_Version != 0); - return m_Version; - } - -}; - - -class ConnectionNameTable; -typedef DPTR(class ConnectionNameTable) PTR_ConnectionNameTable; - -class CrstStatic; - -// Defines the precedence (in increading oder) of the two symbol reading knobs -enum ESymbolReadingSetBy -{ - eSymbolReadingSetByDefault, - eSymbolReadingSetByConfig, // EEConfig - config file, env var, etc. - eSymbolReadingSetByHost, // Hosting API - highest precedence - eSymbolReadingSetBy_COUNT -}; - - -#if defined(FEATURE_WINDOWSPHONE) -class CCLRErrorReportingManager : -#ifdef FEATURE_WINDOWSPHONE - public ICLRErrorReportingManager2 -#else - public ICLRErrorReportingManager -#endif // FEATURE_WINDOWSPHONE -{ - friend class ClrDataAccess; - friend struct _DacGlobals; - - SVAL_DECL(ECustomDumpFlavor, g_ECustomDumpFlavor); - -#ifdef FEATURE_WINDOWSPHONE - WCHAR* m_pApplicationId; - WCHAR* m_pInstanceId; - - class BucketParamsCache - { - private: - WCHAR** m_pParams; - DWORD const m_cMaxParams; - public: - BucketParamsCache(DWORD maxNumParams); - ~BucketParamsCache(); - - WCHAR const* GetAt(BucketParameterIndex index); - HRESULT SetAt(BucketParameterIndex index, WCHAR const* val); - }; - - BucketParamsCache* m_pBucketParamsCache; - - HRESULT CopyToDataCache(_In_ WCHAR** pTarget, WCHAR const* pSource); -#endif // FEATURE_WINDOWSPHONE - -public: - CCLRErrorReportingManager(); - ~CCLRErrorReportingManager(); - - STDMETHODIMP QueryInterface(REFIID riid, void** ppv); - STDMETHODIMP_(ULONG) AddRef(void); - STDMETHODIMP_(ULONG) Release(void); - - // ICLRErrorReportingManager APIs // - - // Get Watson bucket parameters for "current" exception (on calling thread). - STDMETHODIMP GetBucketParametersForCurrentException(BucketParameters *pParams); - STDMETHODIMP BeginCustomDump( ECustomDumpFlavor dwFlavor, - DWORD dwNumItems, - CustomDumpItem items[], - DWORD dwReserved); - STDMETHODIMP EndCustomDump(); - -#ifdef FEATURE_WINDOWSPHONE - // ICLRErrorReportingManager2 APIs // - - STDMETHODIMP SetApplicationData(ApplicationDataKey key, WCHAR const* pValue); - STDMETHODIMP SetBucketParametersForUnhandledException(BucketParameters const* pBucketParams, DWORD* pCountParams); - - // internal APIs - - // returns the application data for the specified key if available, else returns NULL. - WCHAR const* GetApplicationData(ApplicationDataKey key); - - // returns bucket parameter override data if available, else returns NULL. - WCHAR const* GetBucketParamOverride(BucketParameterIndex bucketParamId); -#endif // FEATURE_WINDOWSPHONE -}; - -extern CCLRErrorReportingManager g_CLRErrorReportingManager; -#endif // defined(FEATURE_WINDOWSPHONE) - -#ifdef FEATURE_IPCMAN -// @TODO:: a-meicht -// consolidate the following class with DebuggerManager. -// -class CCLRSecurityAttributeManager -{ -public: - - // Set ACL on shared section, events, and process - STDMETHODIMP SetDACL(PACL pacl); - - // Returning the current ACL that CLR is using - STDMETHODIMP GetDACL(PACL *pacl); - - static void ProcessInit(); - static void ProcessCleanUp(); - - // retrieving Host security attribute setting. If host does not set it, default to - // our default policy. - static HRESULT GetHostSecurityAttributes(SECURITY_ATTRIBUTES **ppSA); - static void DestroyHostSecurityAttributes(SECURITY_ATTRIBUTES *pSA); - - static CrstStatic m_hostSAMutex; - -private: - static PACL m_pACL; - - // Security attributes cached for the current process. - static SECURITY_ATTRIBUTES m_hostSA; - static SECURITY_DESCRIPTOR m_hostSD; - - static HRESULT CopyACL(PACL pAclOriginal, PACL ppAclNew); -}; -#endif // FEATURE_IPCMAN - -class CorHost2 : - public CorRuntimeHostBase -#ifndef FEATURE_PAL - , public IPrivateManagedExceptionReporting /* This interface is for internal Watson testing only*/ -#endif // FEATURE_PAL - , public ICLRRuntimeHost4 - , public CorExecutionManager -{ - friend struct _DacGlobals; - -public: - CorHost2(); - virtual ~CorHost2() {} - - // *** IUnknown methods *** - STDMETHODIMP QueryInterface(REFIID riid, void** ppv); - STDMETHODIMP_(ULONG) AddRef(void) - { - WRAPPER_NO_CONTRACT; - return CorRuntimeHostBase::AddRef(); - } - STDMETHODIMP_(ULONG) Release(void); - - - // *** ICorRuntimeHost methods *** - -#ifndef FEATURE_PAL - // defined in IPrivateManagedExceptionReporting interface for internal Watson testing only - STDMETHODIMP GetBucketParametersForCurrentException(BucketParameters *pParams); -#endif // FEATURE_PAL - - // Starts the runtime. This is equivalent to CoInitializeCor(). - STDMETHODIMP Start(); - STDMETHODIMP Stop(); - - STDMETHODIMP ExecuteInAppDomain(DWORD dwAppDomainId, - FExecuteInAppDomainCallback pCallback, - void * cookie); - - STDMETHODIMP LocksHeldByLogicalThread( // Return code. - DWORD *pCount // [out] Number of locks that the current thread holds. - ) - { - WRAPPER_NO_CONTRACT; - return CorRuntimeHostBase::LocksHeldByLogicalThread(pCount); - } - - // Class factory hook-up. - static HRESULT CreateObject(REFIID riid, void **ppUnk); - - STDMETHODIMP MapFile( // Return code. - HANDLE hFile, // [in] Handle for file - HMODULE *hMapAddress // [out] HINSTANCE for mapped file - ) - { - WRAPPER_NO_CONTRACT; - return CorRuntimeHostBase::MapFile(hFile,hMapAddress); - } - - STDMETHODIMP STDMETHODCALLTYPE SetHostControl( - IHostControl* pHostControl); - - STDMETHODIMP STDMETHODCALLTYPE GetCLRControl( - ICLRControl** pCLRControl); - - STDMETHODIMP UnloadAppDomain(DWORD dwDomainId, BOOL fWaitUntilDone); - - STDMETHODIMP UnloadAppDomain2(DWORD dwDomainId, BOOL fWaitUntilDone, int *pLatchedExitCode); - - STDMETHODIMP GetCurrentAppDomainId(DWORD *pdwAppDomainId); - - STDMETHODIMP ExecuteApplication(LPCWSTR pwzAppFullName, - DWORD dwManifestPaths, - LPCWSTR *ppwzManifestPaths, - DWORD dwActivationData, - LPCWSTR *ppwzActivationData, - int *pReturnValue); - - STDMETHODIMP ExecuteInDefaultAppDomain(LPCWSTR pwzAssemblyPath, - LPCWSTR pwzTypeName, - LPCWSTR pwzMethodName, - LPCWSTR pwzArgument, - DWORD *pReturnValue); - - // *** ICLRRuntimeHost2 methods *** - STDMETHODIMP CreateAppDomainWithManager( - LPCWSTR wszFriendlyName, - DWORD dwSecurityFlags, - LPCWSTR wszAppDomainManagerAssemblyName, - LPCWSTR wszAppDomainManagerTypeName, - int nProperties, - LPCWSTR* pPropertyNames, - LPCWSTR* pPropertyValues, - DWORD* pAppDomainID); - - STDMETHODIMP CreateDelegate( - DWORD appDomainID, - LPCWSTR wszAssemblyName, - LPCWSTR wszClassName, - LPCWSTR wszMethodName, - INT_PTR* fnPtr); - - STDMETHODIMP Authenticate(ULONGLONG authKey); - - STDMETHODIMP RegisterMacEHPort(); - STDMETHODIMP SetStartupFlags(STARTUP_FLAGS flag); - STDMETHODIMP DllGetActivationFactory( - DWORD appDomainID, - LPCWSTR wszTypeName, - IActivationFactory ** factory); - - STDMETHODIMP ExecuteAssembly( - DWORD dwAppDomainId, - LPCWSTR pwzAssemblyPath, - int argc, - LPCWSTR* argv, - DWORD* pReturnValue); - - static STARTUP_FLAGS GetStartupFlags(); - - static EInitializeNewDomainFlags GetAppDomainManagerInitializeNewDomainFlags(); - - static BOOL HasStarted() - { - return m_RefCount != 0; - } - -private: - // This flag indicates if this instance was the first to load and start CoreCLR - BOOL m_fFirstToLoadCLR; - - // This flag indicates if the host has authenticated with us or not - BOOL m_fIsHostAuthenticated; - - - // Helpers for both ICLRRuntimeHost2 and ICLRPrivRuntime - HRESULT _CreateAppDomain( - LPCWSTR wszFriendlyName, - DWORD dwFlags, - LPCWSTR wszAppDomainManagerAssemblyName, - LPCWSTR wszAppDomainManagerTypeName, - int nProperties, - LPCWSTR* pPropertyNames, - LPCWSTR* pPropertyValues, - DWORD* pAppDomainID); - - HRESULT _CreateDelegate( - DWORD appDomainID, - LPCWSTR wszAssemblyName, - LPCWSTR wszClassName, - LPCWSTR wszMethodName, - INT_PTR* fnPtr); - - // entrypoint helper to be wrapped in a filter to process unhandled exceptions - VOID ExecuteMainInner(Assembly* pRootAssembly); - - static LONG m_RefCount; - - static IHostControl *m_HostControl; - - SVAL_DECL(STARTUP_FLAGS, m_dwStartupFlags); -}; - -class CorHostProtectionManager -{ -private: - EApiCategories m_eProtectedCategories; - bool m_fEagerSerializeGrantSet; - bool m_fFrozen; - -public: - CorHostProtectionManager(); - - // IUnknown methods - HRESULT STDMETHODCALLTYPE QueryInterface( - REFIID id, - void **pInterface); - ULONG STDMETHODCALLTYPE AddRef(); - ULONG STDMETHODCALLTYPE Release(); - - // Interface methods - virtual HRESULT STDMETHODCALLTYPE SetProtectedCategories(/* [in] */ EApiCategories eFullTrustOnlyResources); - virtual HRESULT STDMETHODCALLTYPE SetEagerSerializeGrantSets(); - - // Getters - EApiCategories GetProtectedCategories(); - bool GetEagerSerializeGrantSets() const; - - void Freeze(); -}; - -#ifdef FEATURE_COMINTEROP -extern "C" -HRESULT STDMETHODCALLTYPE DllGetActivationFactoryImpl( - LPCWSTR wszAssemblyName, - LPCWSTR wszTypeName, - LPCWSTR wszCodeBase, - IActivationFactory ** factory); - -#endif // defined(FEATURE_COMINTEROP) - -extern SIZE_T Host_SegmentSize; -extern SIZE_T Host_MaxGen0Size; -extern BOOL Host_fSegmentSizeSet; -extern BOOL Host_fMaxGen0SizeSet; - -#define PARTIAL_TRUST_VISIBLE_ASSEMBLIES_PROPERTY W("PARTIAL_TRUST_VISIBLE_ASSEMBLIES") -#endif // __CorHost__h__ diff --git a/src/inc/corimage.h b/src/inc/corimage.h deleted file mode 100644 index 554eb2042..000000000 --- a/src/inc/corimage.h +++ /dev/null @@ -1,67 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - - -// - -/*============================================================ -** -** CorImage.h -** -** IMAGEHLP routines so we can avoid early binding to that DLL. -** -===========================================================*/ - -#ifndef _CORIMAGE_H_ -#define _CORIMAGE_H_ - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -IMAGE_NT_HEADERS *Cor_RtlImageNtHeader(VOID *pvBase, - ULONG FileLength); - -PIMAGE_SECTION_HEADER -Cor_RtlImageRvaToSection(PTR_IMAGE_NT_HEADERS NtHeaders, - ULONG Rva, - ULONG FileLength); - -PIMAGE_SECTION_HEADER -Cor_RtlImageRvaRangeToSection(PTR_IMAGE_NT_HEADERS NtHeaders, - ULONG Rva, - ULONG Range, - ULONG FileLength); - -DWORD Cor_RtlImageRvaToOffset(PTR_IMAGE_NT_HEADERS NtHeaders, - ULONG Rva, - ULONG FileLength); - -PBYTE Cor_RtlImageRvaToVa(PTR_IMAGE_NT_HEADERS NtHeaders, - PBYTE Base, - ULONG Rva, - ULONG FileLength); - -PBYTE Cor_RtlImageDirToVa(PTR_IMAGE_NT_HEADERS NtHeaders, - PBYTE Base, - UINT DirIndex, - ULONG FileLength); - -PBYTE Cor_RtlImageRvaToVa32(PTR_IMAGE_NT_HEADERS32 NtHeaders, - PBYTE Base, - ULONG Rva, - ULONG FileLength); - -PBYTE Cor_RtlImageRvaToVa64(PTR_IMAGE_NT_HEADERS64 NtHeaders, - PBYTE Base, - ULONG Rva, - ULONG FileLength); - -#ifdef __cplusplus -} -#endif - -#endif // _CORIMAGE_H_ diff --git a/src/inc/corinfo.h b/src/inc/corinfo.h deleted file mode 100644 index d430412f3..000000000 --- a/src/inc/corinfo.h +++ /dev/null @@ -1,3179 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -// - -/*****************************************************************************\ -* * -* CorInfo.h - EE / Code generator interface * -* * -******************************************************************************* -* -* This file exposes CLR runtime functionality. It can be used by compilers, -* both Just-in-time and ahead-of-time, to generate native code which -* executes in the runtime environment. -******************************************************************************* - -////////////////////////////////////////////////////////////////////////////////////////////////////////// -// -// NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE -// -// The JIT/EE interface is versioned. By "interface", we mean mean any and all communication between the -// JIT and the EE. Any time a change is made to the interface, the JIT/EE interface version identifier -// must be updated. See code:JITEEVersionIdentifier for more information. -// -// NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE -// -////////////////////////////////////////////////////////////////////////////////////////////////////////// - -#EEJitContractDetails - -The semantic contract between the EE and the JIT should be documented here It is incomplete, but as time goes -on, that hopefully will change - -See file:../../doc/BookOfTheRuntime/JIT/JIT%20Design.doc for details on the JIT compiler. See -code:EEStartup#TableOfContents for information on the runtime as a whole. - -------------------------------------------------------------------------------- -#Tokens - -The tokens in IL stream needs to be resolved to EE handles (CORINFO_CLASS/METHOD/FIELD_HANDLE) that -the runtime operates with. ICorStaticInfo::resolveToken is the method that resolves the found in IL stream -to set of EE handles (CORINFO_RESOLVED_TOKEN). All other APIs take resolved token as input. This design -avoids redundant token resolutions. - -The token validation is done as part of token resolution. The JIT is not required to do explicit upfront -token validation. - -------------------------------------------------------------------------------- -#ClassConstruction - -First of all class contruction comes in two flavors precise and 'beforeFieldInit'. In C# you get the former -if you declare an explicit class constructor method and the later if you declaratively initialize static -fields. Precise class construction guarentees that the .cctor is run precisely before the first access to any -method or field of the class. 'beforeFieldInit' semantics guarentees only that the .cctor will be run some -time before the first static field access (note that calling methods (static or insance) or accessing -instance fields does not cause .cctors to be run). - -Next you need to know that there are two kinds of code generation that can happen in the JIT: appdomain -neutral and appdomain specialized. The difference between these two kinds of code is how statics are handled. -For appdomain specific code, the address of a particular static variable is embeded in the code. This makes -it usable only for one appdomain (since every appdomain gets a own copy of its statics). Appdomain neutral -code calls a helper that looks up static variables off of a thread local variable. Thus the same code can be -used by mulitple appdomains in the same process. - -Generics also introduce a similar issue. Code for generic classes might be specialised for a particular set -of type arguments, or it could use helpers to access data that depends on type parameters and thus be shared -across several instantiations of the generic type. - -Thus there four cases - - * BeforeFieldInitCCtor - Unshared code. Cctors are only called when static fields are fetched. At the - time the method that touches the static field is JITed (or fixed up in the case of NGENed code), the - .cctor is called. - * BeforeFieldInitCCtor - Shared code. Since the same code is used for multiple classes, the act of JITing - the code can not be used as a hook. However, it is also the case that since the code is shared, it - can not wire in a particular address for the static and thus needs to use a helper that looks up the - correct address based on the thread ID. This helper does the .cctor check, and thus no additional - cctor logic is needed. - * PreciseCCtor - Unshared code. Any time a method is JITTed (or fixed up in the case of NGEN), a cctor - check for the class of the method being JITTed is done. In addition the JIT inserts explicit checks - before any static field accesses. Instance methods and fields do NOT have hooks because a .ctor - method must be called before the instance can be created. - * PreciseCctor - Shared code .cctor checks are placed in the prolog of every .ctor and static method. All - methods that access static fields have an explicit .cctor check before use. Again instance methods - don't have hooks because a .ctor would have to be called first. - -Technically speaking, however the optimization of avoiding checks on instance methods is flawed. It requires -that a .ctor always preceed a call to an instance methods. This break down when - - * A NULL is passed to an instance method. - * A .ctor does not call its superclasses .ctor. This allows an instance to be created without necessarily - calling all the .cctors of all the superclasses. A virtual call can then be made to a instance of a - superclass without necessarily calling the superclass's .cctor. - * The class is a value class (which exists without a .ctor being called) - -Nevertheless, the cost of plugging these holes is considered to high and the benefit is low. - ----------------------------------------------------------------------- - -#ClassConstructionFlags - -Thus the JIT's cctor responsibilities require it to check with the EE on every static field access using -initClass and before jitting any method to see if a .cctor check must be placed in the prolog. - - * CORINFO_FLG_BEFOREFIELDINIT indicate the class has beforeFieldInit semantics. The jit does not strictly - need this information however, it is valuable in optimizing static field fetch helper calls. Helper - call for classes with BeforeFieldInit semantics can be hoisted before other side effects where - classes with precise .cctor semantics do not allow this optimization. - -Inlining also complicates things. Because the class could have precise semantics it is also required that the -inlining of any constructor or static method must also do the initClass check. The inliner has the option of -inserting any required runtime check or simply not inlining the function. - -------------------------------------------------------------------------------- - -#StaticFields - -The first 4 options are mutially exclusive - - * CORINFO_FLG_HELPER If the field has this set, then the JIT must call getFieldHelper and call the - returned helper with the object ref (for an instance field) and a fieldDesc. Note that this should be - able to handle ANY field so to get a JIT up quickly, it has the option of using helper calls for all - field access (and skip the complexity below). Note that for statics it is assumed that you will - alwasy ask for the ADDRESSS helper and to the fetch in the JIT. - - * CORINFO_FLG_SHARED_HELPER This is currently only used for static fields. If this bit is set it means - that the field is feched by a helper call that takes a module identifier (see getModuleDomainID) and - a class identifier (see getClassDomainID) as arguments. The exact helper to call is determined by - getSharedStaticBaseHelper. The return value is of this function is the base of all statics in the - module. The offset from getFieldOffset must be added to this value to get the address of the field - itself. (see also CORINFO_FLG_STATIC_IN_HEAP). - - - * CORINFO_FLG_GENERICS_STATIC This is currently only used for static fields (of generic type). This - function is intended to be called with a Generic handle as a argument (from embedGenericHandle). The - exact helper to call is determined by getSharedStaticBaseHelper. The returned value is the base of - all statics in the class. The offset from getFieldOffset must be added to this value to get the - address of the (see also CORINFO_FLG_STATIC_IN_HEAP). - - * CORINFO_FLG_TLS This indicate that the static field is a Windows style Thread Local Static. (We also - have managed thread local statics, which work through the HELPER. Support for this is considered - legacy, and going forward, the EE should - - * This is a normal static field. Its address in in memory is determined by getFieldAddress. (see - also CORINFO_FLG_STATIC_IN_HEAP). - - -This last field can modify any of the cases above except CORINFO_FLG_HELPER - -CORINFO_FLG_STATIC_IN_HEAP This is currently only used for static fields of value classes. If the field has -this set then after computing what would normally be the field, what you actually get is a object pointer -(that must be reported to the GC) to a boxed version of the value. Thus the actual field address is computed -by addr = (*addr+sizeof(OBJECTREF)) - -Instance fields - - * CORINFO_FLG_HELPER This is used if the class is MarshalByRef, which means that the object might be a - proxyt to the real object in some other appdomain or process. If the field has this set, then the JIT - must call getFieldHelper and call the returned helper with the object ref. If the helper returned is - helpers that are for structures the args are as follows - - * CORINFO_HELP_GETFIELDSTRUCT - args are: retBuff, object, fieldDesc - * CORINFO_HELP_SETFIELDSTRUCT - args are object fieldDesc value - -The other GET helpers take an object fieldDesc and return the value The other SET helpers take an object -fieldDesc and value - - Note that unlike static fields there is no helper to take the address of a field because in general there - is no address for proxies (LDFLDA is illegal on proxies). - - CORINFO_FLG_EnC This is to support adding new field for edit and continue. This field also indicates that - a helper is needed to access this field. However this helper is always CORINFO_HELP_GETFIELDADDR, and - this helper always takes the object and field handle and returns the address of the field. It is the - JIT's responcibility to do the fetch or set. - -------------------------------------------------------------------------------- - -TODO: Talk about initializing strutures before use - - -******************************************************************************* -*/ - -#ifndef _COR_INFO_H_ -#define _COR_INFO_H_ - -#include -#include - -////////////////////////////////////////////////////////////////////////////////////////////////////////// -// -// NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE -// -// #JITEEVersionIdentifier -// -// This GUID represents the version of the JIT/EE interface. Any time the interface between the JIT and -// the EE changes (by adding or removing methods to any interface shared between them), this GUID should -// be changed. This is the identifier verified by ICorJitCompiler::getVersionIdentifier(). -// -// You can use "uuidgen.exe -s" to generate this value. -// -// **** NOTE TO INTEGRATORS: -// -// If there is a merge conflict here, because the version changed in two different places, you must -// create a **NEW** GUID, not simply choose one or the other! -// -// NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE -// -////////////////////////////////////////////////////////////////////////////////////////////////////////// - -#if !defined(SELECTANY) - #define SELECTANY extern __declspec(selectany) -#endif - -SELECTANY const GUID JITEEVersionIdentifier = { /* 0ba106c8-81a0-407f-99a1-928448c1eb62 */ - 0x0ba106c8, - 0x81a0, - 0x407f, - {0x99, 0xa1, 0x92, 0x84, 0x48, 0xc1, 0xeb, 0x62} -}; - -////////////////////////////////////////////////////////////////////////////////////////////////////////// -// -// END JITEEVersionIdentifier -// -////////////////////////////////////////////////////////////////////////////////////////////////////////// - -// For System V on the CLR type system number of registers to pass in and return a struct is the same. -// The CLR type system allows only up to 2 eightbytes to be passed in registers. There is no SSEUP classification types. -#define CLR_SYSTEMV_MAX_EIGHTBYTES_COUNT_TO_PASS_IN_REGISTERS 2 -#define CLR_SYSTEMV_MAX_EIGHTBYTES_COUNT_TO_RETURN_IN_REGISTERS 2 -#define CLR_SYSTEMV_MAX_STRUCT_BYTES_TO_PASS_IN_REGISTERS 16 - -// System V struct passing -// The Classification types are described in the ABI spec at http://www.x86-64.org/documentation/abi.pdf -enum SystemVClassificationType : unsigned __int8 -{ - SystemVClassificationTypeUnknown = 0, - SystemVClassificationTypeStruct = 1, - SystemVClassificationTypeNoClass = 2, - SystemVClassificationTypeMemory = 3, - SystemVClassificationTypeInteger = 4, - SystemVClassificationTypeIntegerReference = 5, - SystemVClassificationTypeIntegerByRef = 6, - SystemVClassificationTypeSSE = 7, - // SystemVClassificationTypeSSEUp = Unused, // Not supported by the CLR. - // SystemVClassificationTypeX87 = Unused, // Not supported by the CLR. - // SystemVClassificationTypeX87Up = Unused, // Not supported by the CLR. - // SystemVClassificationTypeComplexX87 = Unused, // Not supported by the CLR. - - // Internal flags - never returned outside of the classification implementation. - - // This value represents a very special type with two eightbytes. - // First ByRef, second Integer (platform int). - // The VM has a special Elem type for this type - ELEMENT_TYPE_TYPEDBYREF. - // This is the classification counterpart for that element type. It is used to detect - // the special TypedReference type and specialize its classification. - // This type is represented as a struct with two fields. The classification needs to do - // special handling of it since the source/methadata type of the fieds is IntPtr. - // The VM changes the first to ByRef. The second is left as IntPtr (TYP_I_IMPL really). The classification needs to match this and - // special handling is warranted (similar thing is done in the getGCLayout function for this type). - SystemVClassificationTypeTypedReference = 8, - SystemVClassificationTypeMAX = 9, -}; - -// Represents classification information for a struct. -struct SYSTEMV_AMD64_CORINFO_STRUCT_REG_PASSING_DESCRIPTOR -{ - SYSTEMV_AMD64_CORINFO_STRUCT_REG_PASSING_DESCRIPTOR() - { - Initialize(); - } - - bool passedInRegisters; // Whether the struct is passable/passed (this includes struct returning) in registers. - unsigned __int8 eightByteCount; // Number of eightbytes for this struct. - SystemVClassificationType eightByteClassifications[CLR_SYSTEMV_MAX_EIGHTBYTES_COUNT_TO_PASS_IN_REGISTERS]; // The eightbytes type classification. - unsigned __int8 eightByteSizes[CLR_SYSTEMV_MAX_EIGHTBYTES_COUNT_TO_PASS_IN_REGISTERS]; // The size of the eightbytes (an eightbyte could include padding. This represents the no padding size of the eightbyte). - unsigned __int8 eightByteOffsets[CLR_SYSTEMV_MAX_EIGHTBYTES_COUNT_TO_PASS_IN_REGISTERS]; // The start offset of the eightbytes (in bytes). - - // Members - - //------------------------------------------------------------------------ - // CopyFrom: Copies a struct classification into this one. - // - // Arguments: - // 'copyFrom' the struct classification to copy from. - // - void CopyFrom(const SYSTEMV_AMD64_CORINFO_STRUCT_REG_PASSING_DESCRIPTOR& copyFrom) - { - passedInRegisters = copyFrom.passedInRegisters; - eightByteCount = copyFrom.eightByteCount; - - for (int i = 0; i < CLR_SYSTEMV_MAX_EIGHTBYTES_COUNT_TO_PASS_IN_REGISTERS; i++) - { - eightByteClassifications[i] = copyFrom.eightByteClassifications[i]; - eightByteSizes[i] = copyFrom.eightByteSizes[i]; - eightByteOffsets[i] = copyFrom.eightByteOffsets[i]; - } - } - - //------------------------------------------------------------------------ - // IsIntegralSlot: Returns whether the eightbyte at slotIndex is of integral type. - // - // Arguments: - // 'slotIndex' the slot number we are determining if it is of integral type. - // - // Return value: - // returns true if we the eightbyte at index slotIndex is of integral type. - // - - bool IsIntegralSlot(unsigned slotIndex) const - { - return ((eightByteClassifications[slotIndex] == SystemVClassificationTypeInteger) || - (eightByteClassifications[slotIndex] == SystemVClassificationTypeIntegerReference) || - (eightByteClassifications[slotIndex] == SystemVClassificationTypeIntegerByRef)); - } - - //------------------------------------------------------------------------ - // IsSseSlot: Returns whether the eightbyte at slotIndex is SSE type. - // - // Arguments: - // 'slotIndex' the slot number we are determining if it is of SSE type. - // - // Return value: - // returns true if we the eightbyte at index slotIndex is of SSE type. - // - // Follows the rules of the AMD64 System V ABI specification at www.x86-64.org/documentation/abi.pdf. - // Please reffer to it for definitions/examples. - // - bool IsSseSlot(unsigned slotIndex) const - { - return (eightByteClassifications[slotIndex] == SystemVClassificationTypeSSE); - } - -private: - void Initialize() - { - passedInRegisters = false; - eightByteCount = 0; - - for (int i = 0; i < CLR_SYSTEMV_MAX_EIGHTBYTES_COUNT_TO_PASS_IN_REGISTERS; i++) - { - eightByteClassifications[i] = SystemVClassificationTypeUnknown; - eightByteSizes[i] = 0; - eightByteOffsets[i] = 0; - } - } -}; - -// CorInfoHelpFunc defines the set of helpers (accessed via the ICorDynamicInfo::getHelperFtn()) -// These helpers can be called by native code which executes in the runtime. -// Compilers can emit calls to these helpers. -// -// The signatures of the helpers are below (see RuntimeHelperArgumentCheck) - -enum CorInfoHelpFunc -{ - CORINFO_HELP_UNDEF, // invalid value. This should never be used - - /* Arithmetic helpers */ - - CORINFO_HELP_DIV, // For the ARM 32-bit integer divide uses a helper call :-( - CORINFO_HELP_MOD, - CORINFO_HELP_UDIV, - CORINFO_HELP_UMOD, - - CORINFO_HELP_LLSH, - CORINFO_HELP_LRSH, - CORINFO_HELP_LRSZ, - CORINFO_HELP_LMUL, - CORINFO_HELP_LMUL_OVF, - CORINFO_HELP_ULMUL_OVF, - CORINFO_HELP_LDIV, - CORINFO_HELP_LMOD, - CORINFO_HELP_ULDIV, - CORINFO_HELP_ULMOD, - CORINFO_HELP_LNG2DBL, // Convert a signed int64 to a double - CORINFO_HELP_ULNG2DBL, // Convert a unsigned int64 to a double - CORINFO_HELP_DBL2INT, - CORINFO_HELP_DBL2INT_OVF, - CORINFO_HELP_DBL2LNG, - CORINFO_HELP_DBL2LNG_OVF, - CORINFO_HELP_DBL2UINT, - CORINFO_HELP_DBL2UINT_OVF, - CORINFO_HELP_DBL2ULNG, - CORINFO_HELP_DBL2ULNG_OVF, - CORINFO_HELP_FLTREM, - CORINFO_HELP_DBLREM, - CORINFO_HELP_FLTROUND, - CORINFO_HELP_DBLROUND, - - /* Allocating a new object. Always use ICorClassInfo::getNewHelper() to decide - which is the right helper to use to allocate an object of a given type. */ - - CORINFO_HELP_NEW_CROSSCONTEXT, // cross context new object - CORINFO_HELP_NEWFAST, - CORINFO_HELP_NEWSFAST, // allocator for small, non-finalizer, non-array object - CORINFO_HELP_NEWSFAST_ALIGN8, // allocator for small, non-finalizer, non-array object, 8 byte aligned - CORINFO_HELP_NEW_MDARR, // multi-dim array helper (with or without lower bounds - dimensions passed in as vararg) - CORINFO_HELP_NEW_MDARR_NONVARARG,// multi-dim array helper (with or without lower bounds - dimensions passed in as unmanaged array) - CORINFO_HELP_NEWARR_1_DIRECT, // helper for any one dimensional array creation - CORINFO_HELP_NEWARR_1_R2R_DIRECT, // wrapper for R2R direct call, which extracts method table from ArrayTypeDesc - CORINFO_HELP_NEWARR_1_OBJ, // optimized 1-D object arrays - CORINFO_HELP_NEWARR_1_VC, // optimized 1-D value class arrays - CORINFO_HELP_NEWARR_1_ALIGN8, // like VC, but aligns the array start - - CORINFO_HELP_STRCNS, // create a new string literal - CORINFO_HELP_STRCNS_CURRENT_MODULE, // create a new string literal from the current module (used by NGen code) - - /* Object model */ - - CORINFO_HELP_INITCLASS, // Initialize class if not already initialized - CORINFO_HELP_INITINSTCLASS, // Initialize class for instantiated type - - // Use ICorClassInfo::getCastingHelper to determine - // the right helper to use - - CORINFO_HELP_ISINSTANCEOFINTERFACE, // Optimized helper for interfaces - CORINFO_HELP_ISINSTANCEOFARRAY, // Optimized helper for arrays - CORINFO_HELP_ISINSTANCEOFCLASS, // Optimized helper for classes - CORINFO_HELP_ISINSTANCEOFANY, // Slow helper for any type - - CORINFO_HELP_CHKCASTINTERFACE, - CORINFO_HELP_CHKCASTARRAY, - CORINFO_HELP_CHKCASTCLASS, - CORINFO_HELP_CHKCASTANY, - CORINFO_HELP_CHKCASTCLASS_SPECIAL, // Optimized helper for classes. Assumes that the trivial cases - // has been taken care of by the inlined check - - CORINFO_HELP_BOX, - CORINFO_HELP_BOX_NULLABLE, // special form of boxing for Nullable - CORINFO_HELP_UNBOX, - CORINFO_HELP_UNBOX_NULLABLE, // special form of unboxing for Nullable - CORINFO_HELP_GETREFANY, // Extract the byref from a TypedReference, checking that it is the expected type - - CORINFO_HELP_ARRADDR_ST, // assign to element of object array with type-checking - CORINFO_HELP_LDELEMA_REF, // does a precise type comparision and returns address - - /* Exceptions */ - - CORINFO_HELP_THROW, // Throw an exception object - CORINFO_HELP_RETHROW, // Rethrow the currently active exception - CORINFO_HELP_USER_BREAKPOINT, // For a user program to break to the debugger - CORINFO_HELP_RNGCHKFAIL, // array bounds check failed - CORINFO_HELP_OVERFLOW, // throw an overflow exception - CORINFO_HELP_THROWDIVZERO, // throw a divide by zero exception - CORINFO_HELP_THROWNULLREF, // throw a null reference exception - - CORINFO_HELP_INTERNALTHROW, // Support for really fast jit - CORINFO_HELP_VERIFICATION, // Throw a VerificationException - CORINFO_HELP_SEC_UNMGDCODE_EXCPT, // throw a security unmanaged code exception - CORINFO_HELP_FAIL_FAST, // Kill the process avoiding any exceptions or stack and data dependencies (use for GuardStack unsafe buffer checks) - - CORINFO_HELP_METHOD_ACCESS_EXCEPTION,//Throw an access exception due to a failed member/class access check. - CORINFO_HELP_FIELD_ACCESS_EXCEPTION, - CORINFO_HELP_CLASS_ACCESS_EXCEPTION, - - CORINFO_HELP_ENDCATCH, // call back into the EE at the end of a catch block - - /* Synchronization */ - - CORINFO_HELP_MON_ENTER, - CORINFO_HELP_MON_EXIT, - CORINFO_HELP_MON_ENTER_STATIC, - CORINFO_HELP_MON_EXIT_STATIC, - - CORINFO_HELP_GETCLASSFROMMETHODPARAM, // Given a generics method handle, returns a class handle - CORINFO_HELP_GETSYNCFROMCLASSHANDLE, // Given a generics class handle, returns the sync monitor - // in its ManagedClassObject - - /* Security callout support */ - - CORINFO_HELP_SECURITY_PROLOG, // Required if CORINFO_FLG_SECURITYCHECK is set, or CORINFO_FLG_NOSECURITYWRAP is not set - CORINFO_HELP_SECURITY_PROLOG_FRAMED, // Slow version of CORINFO_HELP_SECURITY_PROLOG. Used for instrumentation. - - CORINFO_HELP_METHOD_ACCESS_CHECK, // Callouts to runtime security access checks - CORINFO_HELP_FIELD_ACCESS_CHECK, - CORINFO_HELP_CLASS_ACCESS_CHECK, - - CORINFO_HELP_DELEGATE_SECURITY_CHECK, // Callout to delegate security transparency check - - /* Verification runtime callout support */ - - CORINFO_HELP_VERIFICATION_RUNTIME_CHECK, // Do a Demand for UnmanagedCode permission at runtime - - /* GC support */ - - CORINFO_HELP_STOP_FOR_GC, // Call GC (force a GC) - CORINFO_HELP_POLL_GC, // Ask GC if it wants to collect - - CORINFO_HELP_STRESS_GC, // Force a GC, but then update the JITTED code to be a noop call - CORINFO_HELP_CHECK_OBJ, // confirm that ECX is a valid object pointer (debugging only) - - /* GC Write barrier support */ - - CORINFO_HELP_ASSIGN_REF, // universal helpers with F_CALL_CONV calling convention - CORINFO_HELP_CHECKED_ASSIGN_REF, - CORINFO_HELP_ASSIGN_REF_ENSURE_NONHEAP, // Do the store, and ensure that the target was not in the heap. - - CORINFO_HELP_ASSIGN_BYREF, - CORINFO_HELP_ASSIGN_STRUCT, - - - /* Accessing fields */ - - // For COM object support (using COM get/set routines to update object) - // and EnC and cross-context support - CORINFO_HELP_GETFIELD8, - CORINFO_HELP_SETFIELD8, - CORINFO_HELP_GETFIELD16, - CORINFO_HELP_SETFIELD16, - CORINFO_HELP_GETFIELD32, - CORINFO_HELP_SETFIELD32, - CORINFO_HELP_GETFIELD64, - CORINFO_HELP_SETFIELD64, - CORINFO_HELP_GETFIELDOBJ, - CORINFO_HELP_SETFIELDOBJ, - CORINFO_HELP_GETFIELDSTRUCT, - CORINFO_HELP_SETFIELDSTRUCT, - CORINFO_HELP_GETFIELDFLOAT, - CORINFO_HELP_SETFIELDFLOAT, - CORINFO_HELP_GETFIELDDOUBLE, - CORINFO_HELP_SETFIELDDOUBLE, - - CORINFO_HELP_GETFIELDADDR, - - CORINFO_HELP_GETSTATICFIELDADDR_CONTEXT, // Helper for context-static fields - CORINFO_HELP_GETSTATICFIELDADDR_TLS, // Helper for PE TLS fields - - // There are a variety of specialized helpers for accessing static fields. The JIT should use - // ICorClassInfo::getSharedStaticsOrCCtorHelper to determine which helper to use - - // Helpers for regular statics - CORINFO_HELP_GETGENERICS_GCSTATIC_BASE, - CORINFO_HELP_GETGENERICS_NONGCSTATIC_BASE, - CORINFO_HELP_GETSHARED_GCSTATIC_BASE, - CORINFO_HELP_GETSHARED_NONGCSTATIC_BASE, - CORINFO_HELP_GETSHARED_GCSTATIC_BASE_NOCTOR, - CORINFO_HELP_GETSHARED_NONGCSTATIC_BASE_NOCTOR, - CORINFO_HELP_GETSHARED_GCSTATIC_BASE_DYNAMICCLASS, - CORINFO_HELP_GETSHARED_NONGCSTATIC_BASE_DYNAMICCLASS, - // Helper to class initialize shared generic with dynamicclass, but not get static field address - CORINFO_HELP_CLASSINIT_SHARED_DYNAMICCLASS, - - // Helpers for thread statics - CORINFO_HELP_GETGENERICS_GCTHREADSTATIC_BASE, - CORINFO_HELP_GETGENERICS_NONGCTHREADSTATIC_BASE, - CORINFO_HELP_GETSHARED_GCTHREADSTATIC_BASE, - CORINFO_HELP_GETSHARED_NONGCTHREADSTATIC_BASE, - CORINFO_HELP_GETSHARED_GCTHREADSTATIC_BASE_NOCTOR, - CORINFO_HELP_GETSHARED_NONGCTHREADSTATIC_BASE_NOCTOR, - CORINFO_HELP_GETSHARED_GCTHREADSTATIC_BASE_DYNAMICCLASS, - CORINFO_HELP_GETSHARED_NONGCTHREADSTATIC_BASE_DYNAMICCLASS, - - /* Debugger */ - - CORINFO_HELP_DBG_IS_JUST_MY_CODE, // Check if this is "JustMyCode" and needs to be stepped through. - - /* Profiling enter/leave probe addresses */ - CORINFO_HELP_PROF_FCN_ENTER, // record the entry to a method (caller) - CORINFO_HELP_PROF_FCN_LEAVE, // record the completion of current method (caller) - CORINFO_HELP_PROF_FCN_TAILCALL, // record the completionof current method through tailcall (caller) - - /* Miscellaneous */ - - CORINFO_HELP_BBT_FCN_ENTER, // record the entry to a method for collecting Tuning data - - CORINFO_HELP_PINVOKE_CALLI, // Indirect pinvoke call - CORINFO_HELP_TAILCALL, // Perform a tail call - - CORINFO_HELP_GETCURRENTMANAGEDTHREADID, - - CORINFO_HELP_INIT_PINVOKE_FRAME, // initialize an inlined PInvoke Frame for the JIT-compiler - - CORINFO_HELP_MEMSET, // Init block of memory - CORINFO_HELP_MEMCPY, // Copy block of memory - - CORINFO_HELP_RUNTIMEHANDLE_METHOD, // determine a type/field/method handle at run-time - CORINFO_HELP_RUNTIMEHANDLE_METHOD_LOG, // determine a type/field/method handle at run-time, with IBC logging - CORINFO_HELP_RUNTIMEHANDLE_CLASS, // determine a type/field/method handle at run-time - CORINFO_HELP_RUNTIMEHANDLE_CLASS_LOG, // determine a type/field/method handle at run-time, with IBC logging - - // These helpers are required for MDIL backward compatibility only. They are not used by current JITed code. - CORINFO_HELP_TYPEHANDLE_TO_RUNTIMETYPEHANDLE_OBSOLETE, // Convert from a TypeHandle (native structure pointer) to RuntimeTypeHandle at run-time - CORINFO_HELP_METHODDESC_TO_RUNTIMEMETHODHANDLE_OBSOLETE, // Convert from a MethodDesc (native structure pointer) to RuntimeMethodHandle at run-time - CORINFO_HELP_FIELDDESC_TO_RUNTIMEFIELDHANDLE_OBSOLETE, // Convert from a FieldDesc (native structure pointer) to RuntimeFieldHandle at run-time - - CORINFO_HELP_TYPEHANDLE_TO_RUNTIMETYPE, // Convert from a TypeHandle (native structure pointer) to RuntimeType at run-time - CORINFO_HELP_TYPEHANDLE_TO_RUNTIMETYPE_MAYBENULL, // Convert from a TypeHandle (native structure pointer) to RuntimeType at run-time, the type may be null - CORINFO_HELP_METHODDESC_TO_STUBRUNTIMEMETHOD, // Convert from a MethodDesc (native structure pointer) to RuntimeMethodHandle at run-time - CORINFO_HELP_FIELDDESC_TO_STUBRUNTIMEFIELD, // Convert from a FieldDesc (native structure pointer) to RuntimeFieldHandle at run-time - - CORINFO_HELP_VIRTUAL_FUNC_PTR, // look up a virtual method at run-time - //CORINFO_HELP_VIRTUAL_FUNC_PTR_LOG, // look up a virtual method at run-time, with IBC logging - - // Not a real helpers. Instead of taking handle arguments, these helpers point to a small stub that loads the handle argument and calls the static helper. - CORINFO_HELP_READYTORUN_NEW, - CORINFO_HELP_READYTORUN_NEWARR_1, - CORINFO_HELP_READYTORUN_ISINSTANCEOF, - CORINFO_HELP_READYTORUN_CHKCAST, - CORINFO_HELP_READYTORUN_STATIC_BASE, - CORINFO_HELP_READYTORUN_VIRTUAL_FUNC_PTR, - CORINFO_HELP_READYTORUN_GENERIC_HANDLE, - CORINFO_HELP_READYTORUN_DELEGATE_CTOR, - CORINFO_HELP_READYTORUN_GENERIC_STATIC_BASE, - - CORINFO_HELP_EE_PRESTUB, // Not real JIT helper. Used in native images. - - CORINFO_HELP_EE_PRECODE_FIXUP, // Not real JIT helper. Used for Precode fixup in native images. - CORINFO_HELP_EE_PINVOKE_FIXUP, // Not real JIT helper. Used for PInvoke target fixup in native images. - CORINFO_HELP_EE_VSD_FIXUP, // Not real JIT helper. Used for VSD cell fixup in native images. - CORINFO_HELP_EE_EXTERNAL_FIXUP, // Not real JIT helper. Used for to fixup external method thunks in native images. - CORINFO_HELP_EE_VTABLE_FIXUP, // Not real JIT helper. Used for inherited vtable slot fixup in native images. - - CORINFO_HELP_EE_REMOTING_THUNK, // Not real JIT helper. Used for remoting precode in native images. - - CORINFO_HELP_EE_PERSONALITY_ROUTINE,// Not real JIT helper. Used in native images. - CORINFO_HELP_EE_PERSONALITY_ROUTINE_FILTER_FUNCLET,// Not real JIT helper. Used in native images to detect filter funclets. - - // ASSIGN_REF_EAX - CHECKED_ASSIGN_REF_EBP: NOGC_WRITE_BARRIERS JIT helper calls - // - // For unchecked versions EDX is required to point into GC heap. - // - // NOTE: these helpers are only used for x86. - CORINFO_HELP_ASSIGN_REF_EAX, // EAX holds GC ptr, do a 'mov [EDX], EAX' and inform GC - CORINFO_HELP_ASSIGN_REF_EBX, // EBX holds GC ptr, do a 'mov [EDX], EBX' and inform GC - CORINFO_HELP_ASSIGN_REF_ECX, // ECX holds GC ptr, do a 'mov [EDX], ECX' and inform GC - CORINFO_HELP_ASSIGN_REF_ESI, // ESI holds GC ptr, do a 'mov [EDX], ESI' and inform GC - CORINFO_HELP_ASSIGN_REF_EDI, // EDI holds GC ptr, do a 'mov [EDX], EDI' and inform GC - CORINFO_HELP_ASSIGN_REF_EBP, // EBP holds GC ptr, do a 'mov [EDX], EBP' and inform GC - - CORINFO_HELP_CHECKED_ASSIGN_REF_EAX, // These are the same as ASSIGN_REF above ... - CORINFO_HELP_CHECKED_ASSIGN_REF_EBX, // ... but also check if EDX points into heap. - CORINFO_HELP_CHECKED_ASSIGN_REF_ECX, - CORINFO_HELP_CHECKED_ASSIGN_REF_ESI, - CORINFO_HELP_CHECKED_ASSIGN_REF_EDI, - CORINFO_HELP_CHECKED_ASSIGN_REF_EBP, - - CORINFO_HELP_LOOP_CLONE_CHOICE_ADDR, // Return the reference to a counter to decide to take cloned path in debug stress. - CORINFO_HELP_DEBUG_LOG_LOOP_CLONING, // Print a message that a loop cloning optimization has occurred in debug mode. - - CORINFO_HELP_THROW_ARGUMENTEXCEPTION, // throw ArgumentException - CORINFO_HELP_THROW_ARGUMENTOUTOFRANGEEXCEPTION, // throw ArgumentOutOfRangeException - CORINFO_HELP_THROW_PLATFORM_NOT_SUPPORTED, // throw PlatformNotSupportedException - CORINFO_HELP_THROW_TYPE_NOT_SUPPORTED, // throw TypeNotSupportedException - - CORINFO_HELP_JIT_PINVOKE_BEGIN, // Transition to preemptive mode before a P/Invoke, frame is the first argument - CORINFO_HELP_JIT_PINVOKE_END, // Transition to cooperative mode after a P/Invoke, frame is the first argument - - CORINFO_HELP_JIT_REVERSE_PINVOKE_ENTER, // Transition to cooperative mode in reverse P/Invoke prolog, frame is the first argument - CORINFO_HELP_JIT_REVERSE_PINVOKE_EXIT, // Transition to preemptive mode in reverse P/Invoke epilog, frame is the first argument - - CORINFO_HELP_GVMLOOKUP_FOR_SLOT, // Resolve a generic virtual method target from this pointer and runtime method handle - - CORINFO_HELP_COUNT, -}; - -#define CORINFO_HELP_READYTORUN_ATYPICAL_CALLSITE 0x40000000 - -//This describes the signature for a helper method. -enum CorInfoHelpSig -{ - CORINFO_HELP_SIG_UNDEF, - CORINFO_HELP_SIG_NO_ALIGN_STUB, - CORINFO_HELP_SIG_NO_UNWIND_STUB, - CORINFO_HELP_SIG_REG_ONLY, - CORINFO_HELP_SIG_4_STACK, - CORINFO_HELP_SIG_8_STACK, - CORINFO_HELP_SIG_12_STACK, - CORINFO_HELP_SIG_16_STACK, - CORINFO_HELP_SIG_8_VA, //2 arguments plus varargs - - CORINFO_HELP_SIG_EBPCALL, //special calling convention that uses EDX and - //EBP as arguments - - CORINFO_HELP_SIG_CANNOT_USE_ALIGN_STUB, - - CORINFO_HELP_SIG_COUNT -}; - -// The enumeration is returned in 'getSig','getType', getArgType methods -enum CorInfoType -{ - CORINFO_TYPE_UNDEF = 0x0, - CORINFO_TYPE_VOID = 0x1, - CORINFO_TYPE_BOOL = 0x2, - CORINFO_TYPE_CHAR = 0x3, - CORINFO_TYPE_BYTE = 0x4, - CORINFO_TYPE_UBYTE = 0x5, - CORINFO_TYPE_SHORT = 0x6, - CORINFO_TYPE_USHORT = 0x7, - CORINFO_TYPE_INT = 0x8, - CORINFO_TYPE_UINT = 0x9, - CORINFO_TYPE_LONG = 0xa, - CORINFO_TYPE_ULONG = 0xb, - CORINFO_TYPE_NATIVEINT = 0xc, - CORINFO_TYPE_NATIVEUINT = 0xd, - CORINFO_TYPE_FLOAT = 0xe, - CORINFO_TYPE_DOUBLE = 0xf, - CORINFO_TYPE_STRING = 0x10, // Not used, should remove - CORINFO_TYPE_PTR = 0x11, - CORINFO_TYPE_BYREF = 0x12, - CORINFO_TYPE_VALUECLASS = 0x13, - CORINFO_TYPE_CLASS = 0x14, - CORINFO_TYPE_REFANY = 0x15, - - // CORINFO_TYPE_VAR is for a generic type variable. - // Generic type variables only appear when the JIT is doing - // verification (not NOT compilation) of generic code - // for the EE, in which case we're running - // the JIT in "import only" mode. - - CORINFO_TYPE_VAR = 0x16, - CORINFO_TYPE_COUNT, // number of jit types -}; - -enum CorInfoTypeWithMod -{ - CORINFO_TYPE_MASK = 0x3F, // lower 6 bits are type mask - CORINFO_TYPE_MOD_PINNED = 0x40, // can be applied to CLASS, or BYREF to indiate pinned -}; - -inline CorInfoType strip(CorInfoTypeWithMod val) { - return CorInfoType(val & CORINFO_TYPE_MASK); -} - -// The enumeration is returned in 'getSig' - -enum CorInfoCallConv -{ - // These correspond to CorCallingConvention - - CORINFO_CALLCONV_DEFAULT = 0x0, - CORINFO_CALLCONV_C = 0x1, - CORINFO_CALLCONV_STDCALL = 0x2, - CORINFO_CALLCONV_THISCALL = 0x3, - CORINFO_CALLCONV_FASTCALL = 0x4, - CORINFO_CALLCONV_VARARG = 0x5, - CORINFO_CALLCONV_FIELD = 0x6, - CORINFO_CALLCONV_LOCAL_SIG = 0x7, - CORINFO_CALLCONV_PROPERTY = 0x8, - CORINFO_CALLCONV_NATIVEVARARG = 0xb, // used ONLY for IL stub PInvoke vararg calls - - CORINFO_CALLCONV_MASK = 0x0f, // Calling convention is bottom 4 bits - CORINFO_CALLCONV_GENERIC = 0x10, - CORINFO_CALLCONV_HASTHIS = 0x20, - CORINFO_CALLCONV_EXPLICITTHIS=0x40, - CORINFO_CALLCONV_PARAMTYPE = 0x80, // Passed last. Same as CORINFO_GENERICS_CTXT_FROM_PARAMTYPEARG -}; - -#ifdef UNIX_X86_ABI -inline bool IsCallerPop(CorInfoCallConv callConv) -{ - unsigned int umask = CORINFO_CALLCONV_STDCALL - | CORINFO_CALLCONV_THISCALL - | CORINFO_CALLCONV_FASTCALL; - - return !(callConv & umask); -} -#endif // UNIX_X86_ABI - -enum CorInfoUnmanagedCallConv -{ - // These correspond to CorUnmanagedCallingConvention - - CORINFO_UNMANAGED_CALLCONV_UNKNOWN, - CORINFO_UNMANAGED_CALLCONV_C, - CORINFO_UNMANAGED_CALLCONV_STDCALL, - CORINFO_UNMANAGED_CALLCONV_THISCALL, - CORINFO_UNMANAGED_CALLCONV_FASTCALL -}; - -// These are returned from getMethodOptions -enum CorInfoOptions -{ - CORINFO_OPT_INIT_LOCALS = 0x00000010, // zero initialize all variables - - CORINFO_GENERICS_CTXT_FROM_THIS = 0x00000020, // is this shared generic code that access the generic context from the this pointer? If so, then if the method has SEH then the 'this' pointer must always be reported and kept alive. - CORINFO_GENERICS_CTXT_FROM_METHODDESC = 0x00000040, // is this shared generic code that access the generic context from the ParamTypeArg(that is a MethodDesc)? If so, then if the method has SEH then the 'ParamTypeArg' must always be reported and kept alive. Same as CORINFO_CALLCONV_PARAMTYPE - CORINFO_GENERICS_CTXT_FROM_METHODTABLE = 0x00000080, // is this shared generic code that access the generic context from the ParamTypeArg(that is a MethodTable)? If so, then if the method has SEH then the 'ParamTypeArg' must always be reported and kept alive. Same as CORINFO_CALLCONV_PARAMTYPE - CORINFO_GENERICS_CTXT_MASK = (CORINFO_GENERICS_CTXT_FROM_THIS | - CORINFO_GENERICS_CTXT_FROM_METHODDESC | - CORINFO_GENERICS_CTXT_FROM_METHODTABLE), - CORINFO_GENERICS_CTXT_KEEP_ALIVE = 0x00000100, // Keep the generics context alive throughout the method even if there is no explicit use, and report its location to the CLR - -}; - -// -// what type of code region we are in -// -enum CorInfoRegionKind -{ - CORINFO_REGION_NONE, - CORINFO_REGION_HOT, - CORINFO_REGION_COLD, - CORINFO_REGION_JIT, -}; - - -// these are the attribute flags for fields and methods (getMethodAttribs) -enum CorInfoFlag -{ -// CORINFO_FLG_UNUSED = 0x00000001, -// CORINFO_FLG_UNUSED = 0x00000002, - CORINFO_FLG_PROTECTED = 0x00000004, - CORINFO_FLG_STATIC = 0x00000008, - CORINFO_FLG_FINAL = 0x00000010, - CORINFO_FLG_SYNCH = 0x00000020, - CORINFO_FLG_VIRTUAL = 0x00000040, -// CORINFO_FLG_UNUSED = 0x00000080, - CORINFO_FLG_NATIVE = 0x00000100, - CORINFO_FLG_INTRINSIC_TYPE = 0x00000200, // This type is marked by [Intrinsic] - CORINFO_FLG_ABSTRACT = 0x00000400, - - CORINFO_FLG_EnC = 0x00000800, // member was added by Edit'n'Continue - - // These are internal flags that can only be on methods - CORINFO_FLG_FORCEINLINE = 0x00010000, // The method should be inlined if possible. - CORINFO_FLG_SHAREDINST = 0x00020000, // the code for this method is shared between different generic instantiations (also set on classes/types) - CORINFO_FLG_DELEGATE_INVOKE = 0x00040000, // "Delegate - CORINFO_FLG_PINVOKE = 0x00080000, // Is a P/Invoke call - CORINFO_FLG_SECURITYCHECK = 0x00100000, // Is one of the security routines that does a stackwalk (e.g. Assert, Demand) - CORINFO_FLG_NOGCCHECK = 0x00200000, // This method is FCALL that has no GC check. Don't put alone in loops - CORINFO_FLG_INTRINSIC = 0x00400000, // This method MAY have an intrinsic ID - CORINFO_FLG_CONSTRUCTOR = 0x00800000, // This method is an instance or type initializer -// CORINFO_FLG_UNUSED = 0x01000000, -// CORINFO_FLG_UNUSED = 0x02000000, - CORINFO_FLG_NOSECURITYWRAP = 0x04000000, // The method requires no security checks - CORINFO_FLG_DONT_INLINE = 0x10000000, // The method should not be inlined - CORINFO_FLG_DONT_INLINE_CALLER = 0x20000000, // The method should not be inlined, nor should its callers. It cannot be tail called. - CORINFO_FLG_JIT_INTRINSIC = 0x40000000, // Method is a potential jit intrinsic; verify identity by name check - - // These are internal flags that can only be on Classes - CORINFO_FLG_VALUECLASS = 0x00010000, // is the class a value class -// This flag is define din the Methods section, but is also valid on classes. -// CORINFO_FLG_SHAREDINST = 0x00020000, // This class is satisfies TypeHandle::IsCanonicalSubtype - CORINFO_FLG_VAROBJSIZE = 0x00040000, // the object size varies depending of constructor args - CORINFO_FLG_ARRAY = 0x00080000, // class is an array class (initialized differently) - CORINFO_FLG_OVERLAPPING_FIELDS = 0x00100000, // struct or class has fields that overlap (aka union) - CORINFO_FLG_INTERFACE = 0x00200000, // it is an interface - CORINFO_FLG_CONTEXTFUL = 0x00400000, // is this a contextful class? - CORINFO_FLG_CUSTOMLAYOUT = 0x00800000, // does this struct have custom layout? - CORINFO_FLG_CONTAINS_GC_PTR = 0x01000000, // does the class contain a gc ptr ? - CORINFO_FLG_DELEGATE = 0x02000000, // is this a subclass of delegate or multicast delegate ? - CORINFO_FLG_MARSHAL_BYREF = 0x04000000, // is this a subclass of MarshalByRef ? - CORINFO_FLG_CONTAINS_STACK_PTR = 0x08000000, // This class has a stack pointer inside it - CORINFO_FLG_VARIANCE = 0x10000000, // MethodTable::HasVariance (sealed does *not* mean uncast-able) - CORINFO_FLG_BEFOREFIELDINIT = 0x20000000, // Additional flexibility for when to run .cctor (see code:#ClassConstructionFlags) - CORINFO_FLG_GENERIC_TYPE_VARIABLE = 0x40000000, // This is really a handle for a variable type - CORINFO_FLG_UNSAFE_VALUECLASS = 0x80000000, // Unsafe (C++'s /GS) value type -}; - -// Flags computed by a runtime compiler -enum CorInfoMethodRuntimeFlags -{ - CORINFO_FLG_BAD_INLINEE = 0x00000001, // The method is not suitable for inlining - CORINFO_FLG_VERIFIABLE = 0x00000002, // The method has verifiable code - CORINFO_FLG_UNVERIFIABLE = 0x00000004, // The method has unverifiable code -}; - - -enum CORINFO_ACCESS_FLAGS -{ - CORINFO_ACCESS_ANY = 0x0000, // Normal access - CORINFO_ACCESS_THIS = 0x0001, // Accessed via the this reference - CORINFO_ACCESS_UNWRAP = 0x0002, // Accessed via an unwrap reference - - CORINFO_ACCESS_NONNULL = 0x0004, // Instance is guaranteed non-null - - CORINFO_ACCESS_LDFTN = 0x0010, // Accessed via ldftn - - // Field access flags - CORINFO_ACCESS_GET = 0x0100, // Field get (ldfld) - CORINFO_ACCESS_SET = 0x0200, // Field set (stfld) - CORINFO_ACCESS_ADDRESS = 0x0400, // Field address (ldflda) - CORINFO_ACCESS_INIT_ARRAY = 0x0800, // Field use for InitializeArray - CORINFO_ACCESS_ATYPICAL_CALLSITE = 0x4000, // Atypical callsite that cannot be disassembled by delay loading helper - CORINFO_ACCESS_INLINECHECK= 0x8000, // Return fieldFlags and fieldAccessor only. Used by JIT64 during inlining. -}; - -// These are the flags set on an CORINFO_EH_CLAUSE -enum CORINFO_EH_CLAUSE_FLAGS -{ - CORINFO_EH_CLAUSE_NONE = 0, - CORINFO_EH_CLAUSE_FILTER = 0x0001, // If this bit is on, then this EH entry is for a filter - CORINFO_EH_CLAUSE_FINALLY = 0x0002, // This clause is a finally clause - CORINFO_EH_CLAUSE_FAULT = 0x0004, // This clause is a fault clause - CORINFO_EH_CLAUSE_DUPLICATE = 0x0008, // Duplicated clause. This clause was duplicated to a funclet which was pulled out of line - CORINFO_EH_CLAUSE_SAMETRY = 0x0010, // This clause covers same try block as the previous one. (Used by CoreRT ABI.) -}; - -// This enumeration is passed to InternalThrow -enum CorInfoException -{ - CORINFO_NullReferenceException, - CORINFO_DivideByZeroException, - CORINFO_InvalidCastException, - CORINFO_IndexOutOfRangeException, - CORINFO_OverflowException, - CORINFO_SynchronizationLockException, - CORINFO_ArrayTypeMismatchException, - CORINFO_RankException, - CORINFO_ArgumentNullException, - CORINFO_ArgumentException, - CORINFO_Exception_Count, -}; - - -// This enumeration is returned by getIntrinsicID. Methods corresponding to -// these values will have "well-known" specified behavior. Calls to these -// methods could be replaced with inlined code corresponding to the -// specified behavior (without having to examine the IL beforehand). - -enum CorInfoIntrinsics -{ - CORINFO_INTRINSIC_Sin, - CORINFO_INTRINSIC_Cos, - CORINFO_INTRINSIC_Cbrt, - CORINFO_INTRINSIC_Sqrt, - CORINFO_INTRINSIC_Abs, - CORINFO_INTRINSIC_Round, - CORINFO_INTRINSIC_Cosh, - CORINFO_INTRINSIC_Sinh, - CORINFO_INTRINSIC_Tan, - CORINFO_INTRINSIC_Tanh, - CORINFO_INTRINSIC_Asin, - CORINFO_INTRINSIC_Asinh, - CORINFO_INTRINSIC_Acos, - CORINFO_INTRINSIC_Acosh, - CORINFO_INTRINSIC_Atan, - CORINFO_INTRINSIC_Atan2, - CORINFO_INTRINSIC_Atanh, - CORINFO_INTRINSIC_Log10, - CORINFO_INTRINSIC_Pow, - CORINFO_INTRINSIC_Exp, - CORINFO_INTRINSIC_Ceiling, - CORINFO_INTRINSIC_Floor, - CORINFO_INTRINSIC_GetChar, // fetch character out of string - CORINFO_INTRINSIC_Array_GetDimLength, // Get number of elements in a given dimension of an array - CORINFO_INTRINSIC_Array_Get, // Get the value of an element in an array - CORINFO_INTRINSIC_Array_Address, // Get the address of an element in an array - CORINFO_INTRINSIC_Array_Set, // Set the value of an element in an array - CORINFO_INTRINSIC_StringGetChar, // fetch character out of string - CORINFO_INTRINSIC_StringLength, // get the length - CORINFO_INTRINSIC_InitializeArray, // initialize an array from static data - CORINFO_INTRINSIC_GetTypeFromHandle, - CORINFO_INTRINSIC_RTH_GetValueInternal, - CORINFO_INTRINSIC_TypeEQ, - CORINFO_INTRINSIC_TypeNEQ, - CORINFO_INTRINSIC_Object_GetType, - CORINFO_INTRINSIC_StubHelpers_GetStubContext, - CORINFO_INTRINSIC_StubHelpers_GetStubContextAddr, - CORINFO_INTRINSIC_StubHelpers_GetNDirectTarget, - CORINFO_INTRINSIC_InterlockedAdd32, - CORINFO_INTRINSIC_InterlockedAdd64, - CORINFO_INTRINSIC_InterlockedXAdd32, - CORINFO_INTRINSIC_InterlockedXAdd64, - CORINFO_INTRINSIC_InterlockedXchg32, - CORINFO_INTRINSIC_InterlockedXchg64, - CORINFO_INTRINSIC_InterlockedCmpXchg32, - CORINFO_INTRINSIC_InterlockedCmpXchg64, - CORINFO_INTRINSIC_MemoryBarrier, - CORINFO_INTRINSIC_GetCurrentManagedThread, - CORINFO_INTRINSIC_GetManagedThreadId, - CORINFO_INTRINSIC_ByReference_Ctor, - CORINFO_INTRINSIC_ByReference_Value, - CORINFO_INTRINSIC_Span_GetItem, - CORINFO_INTRINSIC_ReadOnlySpan_GetItem, - CORINFO_INTRINSIC_GetRawHandle, - - CORINFO_INTRINSIC_Count, - CORINFO_INTRINSIC_Illegal = -1, // Not a true intrinsic, -}; - -// Can a value be accessed directly from JITed code. -enum InfoAccessType -{ - IAT_VALUE, // The info value is directly available - IAT_PVALUE, // The value needs to be accessed via an indirection - IAT_PPVALUE // The value needs to be accessed via a double indirection -}; - -enum CorInfoGCType -{ - TYPE_GC_NONE, // no embedded objectrefs - TYPE_GC_REF, // Is an object ref - TYPE_GC_BYREF, // Is an interior pointer - promote it but don't scan it - TYPE_GC_OTHER // requires type-specific treatment -}; - -enum CorInfoClassId -{ - CLASSID_SYSTEM_OBJECT, - CLASSID_TYPED_BYREF, - CLASSID_TYPE_HANDLE, - CLASSID_FIELD_HANDLE, - CLASSID_METHOD_HANDLE, - CLASSID_STRING, - CLASSID_ARGUMENT_HANDLE, - CLASSID_RUNTIME_TYPE, -}; - -enum CorInfoInline -{ - INLINE_PASS = 0, // Inlining OK - - // failures are negative - INLINE_FAIL = -1, // Inlining not OK for this case only - INLINE_NEVER = -2, // This method should never be inlined, regardless of context -}; - -enum CorInfoInlineRestrictions -{ - INLINE_RESPECT_BOUNDARY = 0x00000001, // You can inline if there are no calls from the method being inlined - INLINE_NO_CALLEE_LDSTR = 0x00000002, // You can inline only if you guarantee that if inlinee does an ldstr - // inlinee's module will never see that string (by any means). - // This is due to how we implement the NoStringInterningAttribute - // (by reusing the fixup table). - INLINE_SAME_THIS = 0x00000004, // You can inline only if the callee is on the same this reference as caller -}; - - -// If you add more values here, keep it in sync with TailCallTypeMap in ..\vm\ClrEtwAll.man -// and the string enum in CEEInfo::reportTailCallDecision in ..\vm\JITInterface.cpp -enum CorInfoTailCall -{ - TAILCALL_OPTIMIZED = 0, // Optimized tail call (epilog + jmp) - TAILCALL_RECURSIVE = 1, // Optimized into a loop (only when a method tail calls itself) - TAILCALL_HELPER = 2, // Helper assisted tail call (call to JIT_TailCall) - - // failures are negative - TAILCALL_FAIL = -1, // Couldn't do a tail call -}; - -enum CorInfoCanSkipVerificationResult -{ - CORINFO_VERIFICATION_CANNOT_SKIP = 0, // Cannot skip verification during jit time. - CORINFO_VERIFICATION_CAN_SKIP = 1, // Can skip verification during jit time. - CORINFO_VERIFICATION_RUNTIME_CHECK = 2, // Cannot skip verification during jit time, - // but need to insert a callout to the VM to ask during runtime - // whether to raise a verification or not (if the method is unverifiable). - CORINFO_VERIFICATION_DONT_JIT = 3, // Cannot skip verification during jit time, - // but do not jit the method if is is unverifiable. -}; - -enum CorInfoInitClassResult -{ - CORINFO_INITCLASS_NOT_REQUIRED = 0x00, // No class initialization required, but the class is not actually initialized yet - // (e.g. we are guaranteed to run the static constructor in method prolog) - CORINFO_INITCLASS_INITIALIZED = 0x01, // Class initialized - CORINFO_INITCLASS_SPECULATIVE = 0x02, // Class may be initialized speculatively - CORINFO_INITCLASS_USE_HELPER = 0x04, // The JIT must insert class initialization helper call. - CORINFO_INITCLASS_DONT_INLINE = 0x08, // The JIT should not inline the method requesting the class initialization. The class - // initialization requires helper class now, but will not require initialization - // if the method is compiled standalone. Or the method cannot be inlined due to some - // requirement around class initialization such as shared generics. -}; - -// Reason codes for making indirect calls -#define INDIRECT_CALL_REASONS() \ - INDIRECT_CALL_REASON_FUNC(CORINFO_INDIRECT_CALL_UNKNOWN) \ - INDIRECT_CALL_REASON_FUNC(CORINFO_INDIRECT_CALL_EXOTIC) \ - INDIRECT_CALL_REASON_FUNC(CORINFO_INDIRECT_CALL_PINVOKE) \ - INDIRECT_CALL_REASON_FUNC(CORINFO_INDIRECT_CALL_GENERIC) \ - INDIRECT_CALL_REASON_FUNC(CORINFO_INDIRECT_CALL_NO_CODE) \ - INDIRECT_CALL_REASON_FUNC(CORINFO_INDIRECT_CALL_FIXUPS) \ - INDIRECT_CALL_REASON_FUNC(CORINFO_INDIRECT_CALL_STUB) \ - INDIRECT_CALL_REASON_FUNC(CORINFO_INDIRECT_CALL_REMOTING) \ - INDIRECT_CALL_REASON_FUNC(CORINFO_INDIRECT_CALL_CER) \ - INDIRECT_CALL_REASON_FUNC(CORINFO_INDIRECT_CALL_RESTORE_METHOD) \ - INDIRECT_CALL_REASON_FUNC(CORINFO_INDIRECT_CALL_RESTORE_FIRST_CALL) \ - INDIRECT_CALL_REASON_FUNC(CORINFO_INDIRECT_CALL_RESTORE_VALUE_TYPE) \ - INDIRECT_CALL_REASON_FUNC(CORINFO_INDIRECT_CALL_RESTORE) \ - INDIRECT_CALL_REASON_FUNC(CORINFO_INDIRECT_CALL_CANT_PATCH) \ - INDIRECT_CALL_REASON_FUNC(CORINFO_INDIRECT_CALL_PROFILING) \ - INDIRECT_CALL_REASON_FUNC(CORINFO_INDIRECT_CALL_OTHER_LOADER_MODULE) \ - -enum CorInfoIndirectCallReason -{ - #undef INDIRECT_CALL_REASON_FUNC - #define INDIRECT_CALL_REASON_FUNC(x) x, - INDIRECT_CALL_REASONS() - - #undef INDIRECT_CALL_REASON_FUNC - - CORINFO_INDIRECT_CALL_COUNT -}; - -// This is for use when the JIT is compiling an instantiation -// of generic code. The JIT needs to know if the generic code itself -// (which can be verified once and for all independently of the -// instantiations) passed verification. -enum CorInfoInstantiationVerification -{ - // The method is NOT a concrete instantiation (eg. List.Add()) of a method - // in a generic class or a generic method. It is either the typical instantiation - // (eg. List.Add()) or entirely non-generic. - INSTVER_NOT_INSTANTIATION = 0, - - // The method is an instantiation of a method in a generic class or a generic method, - // and the generic class was successfully verified - INSTVER_GENERIC_PASSED_VERIFICATION = 1, - - // The method is an instantiation of a method in a generic class or a generic method, - // and the generic class failed verification - INSTVER_GENERIC_FAILED_VERIFICATION = 2, -}; - -// When using CORINFO_HELPER_TAILCALL, the JIT needs to pass certain special -// calling convention/argument passing/handling details to the helper -enum CorInfoHelperTailCallSpecialHandling -{ - CORINFO_TAILCALL_NORMAL = 0x00000000, - CORINFO_TAILCALL_STUB_DISPATCH_ARG = 0x00000001, -}; - - -inline bool dontInline(CorInfoInline val) { - return(val < 0); -} - -// Cookie types consumed by the code generator (these are opaque values -// not inspected by the code generator): - -typedef struct CORINFO_ASSEMBLY_STRUCT_* CORINFO_ASSEMBLY_HANDLE; -typedef struct CORINFO_MODULE_STRUCT_* CORINFO_MODULE_HANDLE; -typedef struct CORINFO_DEPENDENCY_STRUCT_* CORINFO_DEPENDENCY_HANDLE; -typedef struct CORINFO_CLASS_STRUCT_* CORINFO_CLASS_HANDLE; -typedef struct CORINFO_METHOD_STRUCT_* CORINFO_METHOD_HANDLE; -typedef struct CORINFO_FIELD_STRUCT_* CORINFO_FIELD_HANDLE; -typedef struct CORINFO_ARG_LIST_STRUCT_* CORINFO_ARG_LIST_HANDLE; // represents a list of argument types -typedef struct CORINFO_JUST_MY_CODE_HANDLE_*CORINFO_JUST_MY_CODE_HANDLE; -typedef struct CORINFO_PROFILING_STRUCT_* CORINFO_PROFILING_HANDLE; // a handle guaranteed to be unique per process -typedef struct CORINFO_GENERIC_STRUCT_* CORINFO_GENERIC_HANDLE; // a generic handle (could be any of the above) - -// what is actually passed on the varargs call -typedef struct CORINFO_VarArgInfo * CORINFO_VARARGS_HANDLE; - -// Generic tokens are resolved with respect to a context, which is usually the method -// being compiled. The CORINFO_CONTEXT_HANDLE indicates which exact instantiation -// (or the open instantiation) is being referred to. -// CORINFO_CONTEXT_HANDLE is more tightly scoped than CORINFO_MODULE_HANDLE. For cases -// where the exact instantiation does not matter, CORINFO_MODULE_HANDLE is used. -typedef CORINFO_METHOD_HANDLE CORINFO_CONTEXT_HANDLE; - -typedef struct CORINFO_DEPENDENCY_STRUCT_ -{ - CORINFO_MODULE_HANDLE moduleFrom; - CORINFO_MODULE_HANDLE moduleTo; -} CORINFO_DEPENDENCY; - -// Bit-twiddling of contexts assumes word-alignment of method handles and type handles -// If this ever changes, some other encoding will be needed -enum CorInfoContextFlags -{ - CORINFO_CONTEXTFLAGS_METHOD = 0x00, // CORINFO_CONTEXT_HANDLE is really a CORINFO_METHOD_HANDLE - CORINFO_CONTEXTFLAGS_CLASS = 0x01, // CORINFO_CONTEXT_HANDLE is really a CORINFO_CLASS_HANDLE - CORINFO_CONTEXTFLAGS_MASK = 0x01 -}; - -#define MAKE_CLASSCONTEXT(c) (CORINFO_CONTEXT_HANDLE((size_t) (c) | CORINFO_CONTEXTFLAGS_CLASS)) -#define MAKE_METHODCONTEXT(m) (CORINFO_CONTEXT_HANDLE((size_t) (m) | CORINFO_CONTEXTFLAGS_METHOD)) - -enum CorInfoSigInfoFlags -{ - CORINFO_SIGFLAG_IS_LOCAL_SIG = 0x01, - CORINFO_SIGFLAG_IL_STUB = 0x02, -}; - -struct CORINFO_SIG_INST -{ - unsigned classInstCount; - CORINFO_CLASS_HANDLE * classInst; // (representative, not exact) instantiation for class type variables in signature - unsigned methInstCount; - CORINFO_CLASS_HANDLE * methInst; // (representative, not exact) instantiation for method type variables in signature -}; - -struct CORINFO_SIG_INFO -{ - CorInfoCallConv callConv; - CORINFO_CLASS_HANDLE retTypeClass; // if the return type is a value class, this is its handle (enums are normalized) - CORINFO_CLASS_HANDLE retTypeSigClass;// returns the value class as it is in the sig (enums are not converted to primitives) - CorInfoType retType : 8; - unsigned flags : 8; // used by IL stubs code - unsigned numArgs : 16; - struct CORINFO_SIG_INST sigInst; // information about how type variables are being instantiated in generic code - CORINFO_ARG_LIST_HANDLE args; - PCCOR_SIGNATURE pSig; - unsigned cbSig; - CORINFO_MODULE_HANDLE scope; // passed to getArgClass - mdToken token; - - CorInfoCallConv getCallConv() { return CorInfoCallConv((callConv & CORINFO_CALLCONV_MASK)); } - bool hasThis() { return ((callConv & CORINFO_CALLCONV_HASTHIS) != 0); } - bool hasExplicitThis() { return ((callConv & CORINFO_CALLCONV_EXPLICITTHIS) != 0); } - unsigned totalILArgs() { return (numArgs + hasThis()); } - bool isVarArg() { return ((getCallConv() == CORINFO_CALLCONV_VARARG) || (getCallConv() == CORINFO_CALLCONV_NATIVEVARARG)); } - bool hasTypeArg() { return ((callConv & CORINFO_CALLCONV_PARAMTYPE) != 0); } -}; - -struct CORINFO_METHOD_INFO -{ - CORINFO_METHOD_HANDLE ftn; - CORINFO_MODULE_HANDLE scope; - BYTE * ILCode; - unsigned ILCodeSize; - unsigned maxStack; - unsigned EHcount; - CorInfoOptions options; - CorInfoRegionKind regionKind; - CORINFO_SIG_INFO args; - CORINFO_SIG_INFO locals; -}; - -//---------------------------------------------------------------------------- -// Looking up handles and addresses. -// -// When the JIT requests a handle, the EE may direct the JIT that it must -// access the handle in a variety of ways. These are packed as -// CORINFO_CONST_LOOKUP -// or CORINFO_LOOKUP (contains either a CORINFO_CONST_LOOKUP or a CORINFO_RUNTIME_LOOKUP) -// -// Constant Lookups v. Runtime Lookups (i.e. when will Runtime Lookups be generated?) -// ----------------------------------------------------------------------------------- -// -// CORINFO_LOOKUP_KIND is part of the result type of embedGenericHandle, -// getVirtualCallInfo and any other functions that may require a -// runtime lookup when compiling shared generic code. -// -// CORINFO_LOOKUP_KIND indicates whether a particular token in the instruction stream can be: -// (a) Mapped to a handle (type, field or method) at compile-time (!needsRuntimeLookup) -// (b) Must be looked up at run-time, and if so which runtime lookup technique should be used (see below) -// -// If the JIT or EE does not support code sharing for generic code, then -// all CORINFO_LOOKUP results will be "constant lookups", i.e. -// the needsRuntimeLookup of CORINFO_LOOKUP.lookupKind.needsRuntimeLookup -// will be false. -// -// Constant Lookups -// ---------------- -// -// Constant Lookups are either: -// IAT_VALUE: immediate (relocatable) values, -// IAT_PVALUE: immediate values access via an indirection through an immediate (relocatable) address -// IAT_PPVALUE: immediate values access via a double indirection through an immediate (relocatable) address -// -// Runtime Lookups -// --------------- -// -// CORINFO_LOOKUP_KIND is part of the result type of embedGenericHandle, -// getVirtualCallInfo and any other functions that may require a -// runtime lookup when compiling shared generic code. -// -// CORINFO_LOOKUP_KIND indicates whether a particular token in the instruction stream can be: -// (a) Mapped to a handle (type, field or method) at compile-time (!needsRuntimeLookup) -// (b) Must be looked up at run-time using the class dictionary -// stored in the vtable of the this pointer (needsRuntimeLookup && THISOBJ) -// (c) Must be looked up at run-time using the method dictionary -// stored in the method descriptor parameter passed to a generic -// method (needsRuntimeLookup && METHODPARAM) -// (d) Must be looked up at run-time using the class dictionary stored -// in the vtable parameter passed to a method in a generic -// struct (needsRuntimeLookup && CLASSPARAM) - -struct CORINFO_CONST_LOOKUP -{ - // If the handle is obtained at compile-time, then this handle is the "exact" handle (class, method, or field) - // Otherwise, it's a representative... - // If accessType is - // IAT_VALUE --> "handle" stores the real handle or "addr " stores the computed address - // IAT_PVALUE --> "addr" stores a pointer to a location which will hold the real handle - // IAT_PPVALUE --> "addr" stores a double indirection to a location which will hold the real handle - - InfoAccessType accessType; - union - { - CORINFO_GENERIC_HANDLE handle; - void * addr; - }; -}; - -enum CORINFO_RUNTIME_LOOKUP_KIND -{ - CORINFO_LOOKUP_THISOBJ, - CORINFO_LOOKUP_METHODPARAM, - CORINFO_LOOKUP_CLASSPARAM, -}; - -struct CORINFO_LOOKUP_KIND -{ - bool needsRuntimeLookup; - CORINFO_RUNTIME_LOOKUP_KIND runtimeLookupKind; - - // The 'runtimeLookupFlags' and 'runtimeLookupArgs' fields - // are just for internal VM / ZAP communication, not to be used by the JIT. - WORD runtimeLookupFlags; - void * runtimeLookupArgs; -} ; - - -// CORINFO_RUNTIME_LOOKUP indicates the details of the runtime lookup -// operation to be performed. -// -// CORINFO_MAXINDIRECTIONS is the maximum number of -// indirections used by runtime lookups. -// This accounts for up to 2 indirections to get at a dictionary followed by a possible spill slot -// -#define CORINFO_MAXINDIRECTIONS 4 -#define CORINFO_USEHELPER ((WORD) 0xffff) - -struct CORINFO_RUNTIME_LOOKUP -{ - // This is signature you must pass back to the runtime lookup helper - LPVOID signature; - - // Here is the helper you must call. It is one of CORINFO_HELP_RUNTIMEHANDLE_* helpers. - CorInfoHelpFunc helper; - - // Number of indirections to get there - // CORINFO_USEHELPER = don't know how to get it, so use helper function at run-time instead - // 0 = use the this pointer itself (e.g. token is C inside code in sealed class C) - // or method desc itself (e.g. token is method void M::mymeth() inside code in M::mymeth) - // Otherwise, follow each byte-offset stored in the "offsets[]" array (may be negative) - WORD indirections; - - // If set, test for null and branch to helper if null - bool testForNull; - - // If set, test the lowest bit and dereference if set (see code:FixupPointer) - bool testForFixup; - - SIZE_T offsets[CORINFO_MAXINDIRECTIONS]; - - // If set, first offset is indirect. - // 0 means that value stored at first offset (offsets[0]) from pointer is next pointer, to which the next offset - // (offsets[1]) is added and so on. - // 1 means that value stored at first offset (offsets[0]) from pointer is offset1, and the next pointer is - // stored at pointer+offsets[0]+offset1. - bool indirectFirstOffset; - - // If set, second offset is indirect. - // 0 means that value stored at second offset (offsets[1]) from pointer is next pointer, to which the next offset - // (offsets[2]) is added and so on. - // 1 means that value stored at second offset (offsets[1]) from pointer is offset2, and the next pointer is - // stored at pointer+offsets[1]+offset2. - bool indirectSecondOffset; -} ; - -// Result of calling embedGenericHandle -struct CORINFO_LOOKUP -{ - CORINFO_LOOKUP_KIND lookupKind; - - union - { - // If kind.needsRuntimeLookup then this indicates how to do the lookup - CORINFO_RUNTIME_LOOKUP runtimeLookup; - - // If the handle is obtained at compile-time, then this handle is the "exact" handle (class, method, or field) - // Otherwise, it's a representative... If accessType is - // IAT_VALUE --> "handle" stores the real handle or "addr " stores the computed address - // IAT_PVALUE --> "addr" stores a pointer to a location which will hold the real handle - // IAT_PPVALUE --> "addr" stores a double indirection to a location which will hold the real handle - CORINFO_CONST_LOOKUP constLookup; - }; -}; - -enum CorInfoGenericHandleType -{ - CORINFO_HANDLETYPE_UNKNOWN, - CORINFO_HANDLETYPE_CLASS, - CORINFO_HANDLETYPE_METHOD, - CORINFO_HANDLETYPE_FIELD -}; - -//---------------------------------------------------------------------------- -// Embedding type, method and field handles (for "ldtoken" or to pass back to helpers) - -// Result of calling embedGenericHandle -struct CORINFO_GENERICHANDLE_RESULT -{ - CORINFO_LOOKUP lookup; - - // compileTimeHandle is guaranteed to be either NULL or a handle that is usable during compile time. - // It must not be embedded in the code because it might not be valid at run-time. - CORINFO_GENERIC_HANDLE compileTimeHandle; - - // Type of the result - CorInfoGenericHandleType handleType; -}; - -#define CORINFO_ACCESS_ALLOWED_MAX_ARGS 4 - -enum CorInfoAccessAllowedHelperArgType -{ - CORINFO_HELPER_ARG_TYPE_Invalid = 0, - CORINFO_HELPER_ARG_TYPE_Field = 1, - CORINFO_HELPER_ARG_TYPE_Method = 2, - CORINFO_HELPER_ARG_TYPE_Class = 3, - CORINFO_HELPER_ARG_TYPE_Module = 4, - CORINFO_HELPER_ARG_TYPE_Const = 5, -}; -struct CORINFO_HELPER_ARG -{ - union - { - CORINFO_FIELD_HANDLE fieldHandle; - CORINFO_METHOD_HANDLE methodHandle; - CORINFO_CLASS_HANDLE classHandle; - CORINFO_MODULE_HANDLE moduleHandle; - size_t constant; - }; - CorInfoAccessAllowedHelperArgType argType; - - void Set(CORINFO_METHOD_HANDLE handle) - { - argType = CORINFO_HELPER_ARG_TYPE_Method; - methodHandle = handle; - } - - void Set(CORINFO_FIELD_HANDLE handle) - { - argType = CORINFO_HELPER_ARG_TYPE_Field; - fieldHandle = handle; - } - - void Set(CORINFO_CLASS_HANDLE handle) - { - argType = CORINFO_HELPER_ARG_TYPE_Class; - classHandle = handle; - } - - void Set(size_t value) - { - argType = CORINFO_HELPER_ARG_TYPE_Const; - constant = value; - } -}; - -struct CORINFO_HELPER_DESC -{ - CorInfoHelpFunc helperNum; - unsigned numArgs; - CORINFO_HELPER_ARG args[CORINFO_ACCESS_ALLOWED_MAX_ARGS]; -}; - -//---------------------------------------------------------------------------- -// getCallInfo and CORINFO_CALL_INFO: The EE instructs the JIT about how to make a call -// -// callKind -// -------- -// -// CORINFO_CALL : -// Indicates that the JIT can use getFunctionEntryPoint to make a call, -// i.e. there is nothing abnormal about the call. The JITs know what to do if they get this. -// Except in the case of constraint calls (see below), [targetMethodHandle] will hold -// the CORINFO_METHOD_HANDLE that a call to findMethod would -// have returned. -// This flag may be combined with nullInstanceCheck=TRUE for uses of callvirt on methods that can -// be resolved at compile-time (non-virtual, final or sealed). -// -// CORINFO_CALL_CODE_POINTER (shared generic code only) : -// Indicates that the JIT should do an indirect call to the entrypoint given by address, which may be specified -// as a runtime lookup by CORINFO_CALL_INFO::codePointerLookup. -// [targetMethodHandle] will not hold a valid value. -// This flag may be combined with nullInstanceCheck=TRUE for uses of callvirt on methods whose target method can -// be resolved at compile-time but whose instantiation can be resolved only through runtime lookup. -// -// CORINFO_VIRTUALCALL_STUB (interface calls) : -// Indicates that the EE supports "stub dispatch" and request the JIT to make a -// "stub dispatch" call (an indirect call through CORINFO_CALL_INFO::stubLookup, -// similar to CORINFO_CALL_CODE_POINTER). -// "Stub dispatch" is a specialized calling sequence (that may require use of NOPs) -// which allow the runtime to determine the call-site after the call has been dispatched. -// If the call is too complex for the JIT (e.g. because -// fetching the dispatch stub requires a runtime lookup, i.e. lookupKind.needsRuntimeLookup -// is set) then the JIT is allowed to implement the call as if it were CORINFO_VIRTUALCALL_LDVIRTFTN -// [targetMethodHandle] will hold the CORINFO_METHOD_HANDLE that a call to findMethod would -// have returned. -// This flag is always accompanied by nullInstanceCheck=TRUE. -// -// CORINFO_VIRTUALCALL_LDVIRTFTN (virtual generic methods) : -// Indicates that the EE provides no way to implement the call directly and -// that the JIT should use a LDVIRTFTN sequence (as implemented by CORINFO_HELP_VIRTUAL_FUNC_PTR) -// followed by an indirect call. -// [targetMethodHandle] will hold the CORINFO_METHOD_HANDLE that a call to findMethod would -// have returned. -// This flag is always accompanied by nullInstanceCheck=TRUE though typically the null check will -// be implicit in the access through the instance pointer. -// -// CORINFO_VIRTUALCALL_VTABLE (regular virtual methods) : -// Indicates that the EE supports vtable dispatch and that the JIT should use getVTableOffset etc. -// to implement the call. -// [targetMethodHandle] will hold the CORINFO_METHOD_HANDLE that a call to findMethod would -// have returned. -// This flag is always accompanied by nullInstanceCheck=TRUE though typically the null check will -// be implicit in the access through the instance pointer. -// -// thisTransform and constraint calls -// ---------------------------------- -// -// For evertyhing besides "constrained." calls "thisTransform" is set to -// CORINFO_NO_THIS_TRANSFORM. -// -// For "constrained." calls the EE attempts to resolve the call at compile -// time to a more specific method, or (shared generic code only) to a runtime lookup -// for a code pointer for the more specific method. -// -// In order to permit this, the "this" pointer supplied for a "constrained." call -// is a byref to an arbitrary type (see the IL spec). The "thisTransform" field -// will indicate how the JIT must transform the "this" pointer in order -// to be able to call the resolved method: -// -// CORINFO_NO_THIS_TRANSFORM --> Leave it as a byref to an unboxed value type -// CORINFO_BOX_THIS --> Box it to produce an object -// CORINFO_DEREF_THIS --> Deref the byref to get an object reference -// -// In addition, the "kind" field will be set as follows for constraint calls: - -// CORINFO_CALL --> the call was resolved at compile time, and -// can be compiled like a normal call. -// CORINFO_CALL_CODE_POINTER --> the call was resolved, but the target address will be -// computed at runtime. Only returned for shared generic code. -// CORINFO_VIRTUALCALL_STUB, -// CORINFO_VIRTUALCALL_LDVIRTFTN, -// CORINFO_VIRTUALCALL_VTABLE --> usual values indicating that a virtual call must be made - -enum CORINFO_CALL_KIND -{ - CORINFO_CALL, - CORINFO_CALL_CODE_POINTER, - CORINFO_VIRTUALCALL_STUB, - CORINFO_VIRTUALCALL_LDVIRTFTN, - CORINFO_VIRTUALCALL_VTABLE -}; - -// Indicates that the CORINFO_VIRTUALCALL_VTABLE lookup needn't do a chunk indirection -#define CORINFO_VIRTUALCALL_NO_CHUNK 0xFFFFFFFF - -enum CORINFO_THIS_TRANSFORM -{ - CORINFO_NO_THIS_TRANSFORM, - CORINFO_BOX_THIS, - CORINFO_DEREF_THIS -}; - -enum CORINFO_CALLINFO_FLAGS -{ - CORINFO_CALLINFO_NONE = 0x0000, - CORINFO_CALLINFO_ALLOWINSTPARAM = 0x0001, // Can the compiler generate code to pass an instantiation parameters? Simple compilers should not use this flag - CORINFO_CALLINFO_CALLVIRT = 0x0002, // Is it a virtual call? - CORINFO_CALLINFO_KINDONLY = 0x0004, // This is set to only query the kind of call to perform, without getting any other information - CORINFO_CALLINFO_VERIFICATION = 0x0008, // Gets extra verification information. - CORINFO_CALLINFO_SECURITYCHECKS = 0x0010, // Perform security checks. - CORINFO_CALLINFO_LDFTN = 0x0020, // Resolving target of LDFTN - CORINFO_CALLINFO_ATYPICAL_CALLSITE = 0x0040, // Atypical callsite that cannot be disassembled by delay loading helper -}; - -enum CorInfoIsAccessAllowedResult -{ - CORINFO_ACCESS_ALLOWED = 0, // Call allowed - CORINFO_ACCESS_ILLEGAL = 1, // Call not allowed - CORINFO_ACCESS_RUNTIME_CHECK = 2, // Ask at runtime whether to allow the call or not -}; - - -// This enum is used for JIT to tell EE where this token comes from. -// E.g. Depending on different opcodes, we might allow/disallow certain types of tokens or -// return different types of handles (e.g. boxed vs. regular entrypoints) -enum CorInfoTokenKind -{ - CORINFO_TOKENKIND_Class = 0x01, - CORINFO_TOKENKIND_Method = 0x02, - CORINFO_TOKENKIND_Field = 0x04, - CORINFO_TOKENKIND_Mask = 0x07, - - // token comes from CEE_LDTOKEN - CORINFO_TOKENKIND_Ldtoken = 0x10 | CORINFO_TOKENKIND_Class | CORINFO_TOKENKIND_Method | CORINFO_TOKENKIND_Field, - - // token comes from CEE_CASTCLASS or CEE_ISINST - CORINFO_TOKENKIND_Casting = 0x20 | CORINFO_TOKENKIND_Class, - - // token comes from CEE_NEWARR - CORINFO_TOKENKIND_Newarr = 0x40 | CORINFO_TOKENKIND_Class, - - // token comes from CEE_BOX - CORINFO_TOKENKIND_Box = 0x80 | CORINFO_TOKENKIND_Class, - - // token comes from CEE_CONSTRAINED - CORINFO_TOKENKIND_Constrained = 0x100 | CORINFO_TOKENKIND_Class, - - // token comes from CEE_NEWOBJ - CORINFO_TOKENKIND_NewObj = 0x200 | CORINFO_TOKENKIND_Method, - - // token comes from CEE_LDVIRTFTN - CORINFO_TOKENKIND_Ldvirtftn = 0x400 | CORINFO_TOKENKIND_Method, -}; - -struct CORINFO_RESOLVED_TOKEN -{ - // - // [In] arguments of resolveToken - // - CORINFO_CONTEXT_HANDLE tokenContext; //Context for resolution of generic arguments - CORINFO_MODULE_HANDLE tokenScope; - mdToken token; //The source token - CorInfoTokenKind tokenType; - - // - // [Out] arguments of resolveToken. - // - Type handle is always non-NULL. - // - At most one of method and field handles is non-NULL (according to the token type). - // - Method handle is an instantiating stub only for generic methods. Type handle - // is required to provide the full context for methods in generic types. - // - CORINFO_CLASS_HANDLE hClass; - CORINFO_METHOD_HANDLE hMethod; - CORINFO_FIELD_HANDLE hField; - - // - // [Out] TypeSpec and MethodSpec signatures for generics. NULL otherwise. - // - PCCOR_SIGNATURE pTypeSpec; - ULONG cbTypeSpec; - PCCOR_SIGNATURE pMethodSpec; - ULONG cbMethodSpec; -}; - -struct CORINFO_CALL_INFO -{ - CORINFO_METHOD_HANDLE hMethod; //target method handle - unsigned methodFlags; //flags for the target method - - unsigned classFlags; //flags for CORINFO_RESOLVED_TOKEN::hClass - - CORINFO_SIG_INFO sig; - - //Verification information - unsigned verMethodFlags; // flags for CORINFO_RESOLVED_TOKEN::hMethod - CORINFO_SIG_INFO verSig; - //All of the regular method data is the same... hMethod might not be the same as CORINFO_RESOLVED_TOKEN::hMethod - - - //If set to: - // - CORINFO_ACCESS_ALLOWED - The access is allowed. - // - CORINFO_ACCESS_ILLEGAL - This access cannot be allowed (i.e. it is public calling private). The - // JIT may either insert the callsiteCalloutHelper into the code (as per a verification error) or - // call throwExceptionFromHelper on the callsiteCalloutHelper. In this case callsiteCalloutHelper - // is guaranteed not to return. - // - CORINFO_ACCESS_RUNTIME_CHECK - The jit must insert the callsiteCalloutHelper at the call site. - // the helper may return - CorInfoIsAccessAllowedResult accessAllowed; - CORINFO_HELPER_DESC callsiteCalloutHelper; - - // See above section on constraintCalls to understand when these are set to unusual values. - CORINFO_THIS_TRANSFORM thisTransform; - - CORINFO_CALL_KIND kind; - BOOL nullInstanceCheck; - - // Context for inlining and hidden arg - CORINFO_CONTEXT_HANDLE contextHandle; - BOOL exactContextNeedsRuntimeLookup; // Set if contextHandle is approx handle. Runtime lookup is required to get the exact handle. - - // If kind.CORINFO_VIRTUALCALL_STUB then stubLookup will be set. - // If kind.CORINFO_CALL_CODE_POINTER then entryPointLookup will be set. - union - { - CORINFO_LOOKUP stubLookup; - - CORINFO_LOOKUP codePointerLookup; - }; - - CORINFO_CONST_LOOKUP instParamLookup; // Used by Ready-to-Run - - BOOL secureDelegateInvoke; -}; - -//---------------------------------------------------------------------------- -// getFieldInfo and CORINFO_FIELD_INFO: The EE instructs the JIT about how to access a field - -enum CORINFO_FIELD_ACCESSOR -{ - CORINFO_FIELD_INSTANCE, // regular instance field at given offset from this-ptr - CORINFO_FIELD_INSTANCE_WITH_BASE, // instance field with base offset (used by Ready-to-Run) - CORINFO_FIELD_INSTANCE_HELPER, // instance field accessed using helper (arguments are this, FieldDesc * and the value) - CORINFO_FIELD_INSTANCE_ADDR_HELPER, // instance field accessed using address-of helper (arguments are this and FieldDesc *) - - CORINFO_FIELD_STATIC_ADDRESS, // field at given address - CORINFO_FIELD_STATIC_RVA_ADDRESS, // RVA field at given address - CORINFO_FIELD_STATIC_SHARED_STATIC_HELPER, // static field accessed using the "shared static" helper (arguments are ModuleID + ClassID) - CORINFO_FIELD_STATIC_GENERICS_STATIC_HELPER, // static field access using the "generic static" helper (argument is MethodTable *) - CORINFO_FIELD_STATIC_ADDR_HELPER, // static field accessed using address-of helper (argument is FieldDesc *) - CORINFO_FIELD_STATIC_TLS, // unmanaged TLS access - CORINFO_FIELD_STATIC_READYTORUN_HELPER, // static field access using a runtime lookup helper - - CORINFO_FIELD_INTRINSIC_ZERO, // intrinsic zero (IntPtr.Zero, UIntPtr.Zero) - CORINFO_FIELD_INTRINSIC_EMPTY_STRING, // intrinsic emptry string (String.Empty) - CORINFO_FIELD_INTRINSIC_ISLITTLEENDIAN, // intrinsic BitConverter.IsLittleEndian -}; - -// Set of flags returned in CORINFO_FIELD_INFO::fieldFlags -enum CORINFO_FIELD_FLAGS -{ - CORINFO_FLG_FIELD_STATIC = 0x00000001, - CORINFO_FLG_FIELD_UNMANAGED = 0x00000002, // RVA field - CORINFO_FLG_FIELD_FINAL = 0x00000004, - CORINFO_FLG_FIELD_STATIC_IN_HEAP = 0x00000008, // See code:#StaticFields. This static field is in the GC heap as a boxed object - CORINFO_FLG_FIELD_SAFESTATIC_BYREF_RETURN = 0x00000010, // Field can be returned safely (has GC heap lifetime) - CORINFO_FLG_FIELD_INITCLASS = 0x00000020, // initClass has to be called before accessing the field - CORINFO_FLG_FIELD_PROTECTED = 0x00000040, -}; - -struct CORINFO_FIELD_INFO -{ - CORINFO_FIELD_ACCESSOR fieldAccessor; - unsigned fieldFlags; - - // Helper to use if the field access requires it - CorInfoHelpFunc helper; - - // Field offset if there is one - DWORD offset; - - CorInfoType fieldType; - CORINFO_CLASS_HANDLE structType; //possibly null - - //See CORINFO_CALL_INFO.accessAllowed - CorInfoIsAccessAllowedResult accessAllowed; - CORINFO_HELPER_DESC accessCalloutHelper; - - CORINFO_CONST_LOOKUP fieldLookup; // Used by Ready-to-Run -}; - -//---------------------------------------------------------------------------- -// Exception handling - -struct CORINFO_EH_CLAUSE -{ - CORINFO_EH_CLAUSE_FLAGS Flags; - DWORD TryOffset; - DWORD TryLength; - DWORD HandlerOffset; - DWORD HandlerLength; - union - { - DWORD ClassToken; // use for type-based exception handlers - DWORD FilterOffset; // use for filter-based exception handlers (COR_ILEXCEPTION_FILTER is set) - }; -}; - -enum CORINFO_OS -{ - CORINFO_WINNT, - CORINFO_PAL, -}; - -struct CORINFO_CPU -{ - DWORD dwCPUType; - DWORD dwFeatures; - DWORD dwExtendedFeatures; -}; - -enum CORINFO_RUNTIME_ABI -{ - CORINFO_DESKTOP_ABI = 0x100, - CORINFO_CORECLR_ABI = 0x200, - CORINFO_CORERT_ABI = 0x300, -}; - -// For some highly optimized paths, the JIT must generate code that directly -// manipulates internal EE data structures. The getEEInfo() helper returns -// this structure containing the needed offsets and values. -struct CORINFO_EE_INFO -{ - // Information about the InlinedCallFrame structure layout - struct InlinedCallFrameInfo - { - // Size of the Frame structure - unsigned size; - - unsigned offsetOfGSCookie; - unsigned offsetOfFrameVptr; - unsigned offsetOfFrameLink; - unsigned offsetOfCallSiteSP; - unsigned offsetOfCalleeSavedFP; - unsigned offsetOfCallTarget; - unsigned offsetOfReturnAddress; - } - inlinedCallFrameInfo; - - // Offsets into the Thread structure - unsigned offsetOfThreadFrame; // offset of the current Frame - unsigned offsetOfGCState; // offset of the preemptive/cooperative state of the Thread - - // Delegate offsets - unsigned offsetOfDelegateInstance; - unsigned offsetOfDelegateFirstTarget; - - // Secure delegate offsets - unsigned offsetOfSecureDelegateIndirectCell; - - // Remoting offsets - unsigned offsetOfTransparentProxyRP; - unsigned offsetOfRealProxyServer; - - // Array offsets - unsigned offsetOfObjArrayData; - - // Reverse PInvoke offsets - unsigned sizeOfReversePInvokeFrame; - - // OS Page size - size_t osPageSize; - - // Null object offset - size_t maxUncheckedOffsetForNullObject; - - // Target ABI. Combined with target architecture and OS to determine - // GC, EH, and unwind styles. - CORINFO_RUNTIME_ABI targetAbi; - - CORINFO_OS osType; - unsigned osMajor; - unsigned osMinor; - unsigned osBuild; -}; - -// This is used to indicate that a finally has been called -// "locally" by the try block -enum { LCL_FINALLY_MARK = 0xFC }; // FC = "Finally Call" - -/********************************************************************************** - * The following is the internal structure of an object that the compiler knows about - * when it generates code - **********************************************************************************/ - -#include - -typedef void* CORINFO_MethodPtr; // a generic method pointer - -struct CORINFO_Object -{ - CORINFO_MethodPtr *methTable; // the vtable for the object -}; - -struct CORINFO_String : public CORINFO_Object -{ - unsigned stringLen; - wchar_t chars[1]; // actually of variable size -}; - -struct CORINFO_Array : public CORINFO_Object -{ - unsigned length; -#ifdef _WIN64 - unsigned alignpad; -#endif // _WIN64 - -#if 0 - /* Multi-dimensional arrays have the lengths and bounds here */ - unsigned dimLength[length]; - unsigned dimBound[length]; -#endif - - union - { - __int8 i1Elems[1]; // actually of variable size - unsigned __int8 u1Elems[1]; - __int16 i2Elems[1]; - unsigned __int16 u2Elems[1]; - __int32 i4Elems[1]; - unsigned __int32 u4Elems[1]; - float r4Elems[1]; - }; -}; - -#include -struct CORINFO_Array8 : public CORINFO_Object -{ - unsigned length; -#ifdef _WIN64 - unsigned alignpad; -#endif // _WIN64 - - union - { - double r8Elems[1]; - __int64 i8Elems[1]; - unsigned __int64 u8Elems[1]; - }; -}; - -#include - -struct CORINFO_RefArray : public CORINFO_Object -{ - unsigned length; -#ifdef _WIN64 - unsigned alignpad; -#endif // _WIN64 - -#if 0 - /* Multi-dimensional arrays have the lengths and bounds here */ - unsigned dimLength[length]; - unsigned dimBound[length]; -#endif - - CORINFO_Object* refElems[1]; // actually of variable size; -}; - -struct CORINFO_RefAny -{ - void * dataPtr; - CORINFO_CLASS_HANDLE type; -}; - -// The jit assumes the CORINFO_VARARGS_HANDLE is a pointer to a subclass of this -struct CORINFO_VarArgInfo -{ - unsigned argBytes; // number of bytes the arguments take up. - // (The CORINFO_VARARGS_HANDLE counts as an arg) -}; - -#include - -enum CorInfoSecurityRuntimeChecks -{ - CORINFO_ACCESS_SECURITY_NONE = 0, - CORINFO_ACCESS_SECURITY_TRANSPARENCY = 0x0001 // check that transparency rules are enforced between the caller and callee -}; - - -/* data to optimize delegate construction */ -struct DelegateCtorArgs -{ - void * pMethod; - void * pArg3; - void * pArg4; - void * pArg5; -}; - -// use offsetof to get the offset of the fields above -#include // offsetof -#ifndef offsetof -#define offsetof(s,m) ((size_t)&(((s *)0)->m)) -#endif - -// Guard-stack cookie for preventing against stack buffer overruns -typedef SIZE_T GSCookie; - -#include "cordebuginfo.h" - -/**********************************************************************************/ -// Some compilers cannot arbitrarily allow the handler nesting level to grow -// arbitrarily during Edit'n'Continue. -// This is the maximum nesting level that a compiler needs to support for EnC - -const int MAX_EnC_HANDLER_NESTING_LEVEL = 6; - -// Results from type comparison queries -enum class TypeCompareState -{ - MustNot = -1, // types are not equal - May = 0, // types may be equal (must test at runtime) - Must = 1, // type are equal -}; - -// -// This interface is logically split into sections for each class of information -// (ICorMethodInfo, ICorModuleInfo, etc.). This split used to exist physically as well -// using virtual inheritance, but was eliminated to improve efficiency of the JIT-EE -// interface calls. -// -class ICorStaticInfo -{ -public: - /**********************************************************************************/ - // - // ICorMethodInfo - // - /**********************************************************************************/ - - // return flags (defined above, CORINFO_FLG_PUBLIC ...) - virtual DWORD getMethodAttribs ( - CORINFO_METHOD_HANDLE ftn /* IN */ - ) = 0; - - // sets private JIT flags, which can be, retrieved using getAttrib. - virtual void setMethodAttribs ( - CORINFO_METHOD_HANDLE ftn, /* IN */ - CorInfoMethodRuntimeFlags attribs /* IN */ - ) = 0; - - // Given a method descriptor ftnHnd, extract signature information into sigInfo - // - // 'memberParent' is typically only set when verifying. It should be the - // result of calling getMemberParent. - virtual void getMethodSig ( - CORINFO_METHOD_HANDLE ftn, /* IN */ - CORINFO_SIG_INFO *sig, /* OUT */ - CORINFO_CLASS_HANDLE memberParent = NULL /* IN */ - ) = 0; - - /********************************************************************* - * Note the following methods can only be used on functions known - * to be IL. This includes the method being compiled and any method - * that 'getMethodInfo' returns true for - *********************************************************************/ - - // return information about a method private to the implementation - // returns false if method is not IL, or is otherwise unavailable. - // This method is used to fetch data needed to inline functions - virtual bool getMethodInfo ( - CORINFO_METHOD_HANDLE ftn, /* IN */ - CORINFO_METHOD_INFO* info /* OUT */ - ) = 0; - - // Decides if you have any limitations for inlining. If everything's OK, it will return - // INLINE_PASS and will fill out pRestrictions with a mask of restrictions the caller of this - // function must respect. If caller passes pRestrictions = NULL, if there are any restrictions - // INLINE_FAIL will be returned - // - // The callerHnd must be the immediate caller (i.e. when we have a chain of inlined calls) - // - // The inlined method need not be verified - - virtual CorInfoInline canInline ( - CORINFO_METHOD_HANDLE callerHnd, /* IN */ - CORINFO_METHOD_HANDLE calleeHnd, /* IN */ - DWORD* pRestrictions /* OUT */ - ) = 0; - - // Reports whether or not a method can be inlined, and why. canInline is responsible for reporting all - // inlining results when it returns INLINE_FAIL and INLINE_NEVER. All other results are reported by the - // JIT. - virtual void reportInliningDecision (CORINFO_METHOD_HANDLE inlinerHnd, - CORINFO_METHOD_HANDLE inlineeHnd, - CorInfoInline inlineResult, - const char * reason) = 0; - - - // Returns false if the call is across security boundaries thus we cannot tailcall - // - // The callerHnd must be the immediate caller (i.e. when we have a chain of inlined calls) - virtual bool canTailCall ( - CORINFO_METHOD_HANDLE callerHnd, /* IN */ - CORINFO_METHOD_HANDLE declaredCalleeHnd, /* IN */ - CORINFO_METHOD_HANDLE exactCalleeHnd, /* IN */ - bool fIsTailPrefix /* IN */ - ) = 0; - - // Reports whether or not a method can be tail called, and why. - // canTailCall is responsible for reporting all results when it returns - // false. All other results are reported by the JIT. - virtual void reportTailCallDecision (CORINFO_METHOD_HANDLE callerHnd, - CORINFO_METHOD_HANDLE calleeHnd, - bool fIsTailPrefix, - CorInfoTailCall tailCallResult, - const char * reason) = 0; - - // get individual exception handler - virtual void getEHinfo( - CORINFO_METHOD_HANDLE ftn, /* IN */ - unsigned EHnumber, /* IN */ - CORINFO_EH_CLAUSE* clause /* OUT */ - ) = 0; - - // return class it belongs to - virtual CORINFO_CLASS_HANDLE getMethodClass ( - CORINFO_METHOD_HANDLE method - ) = 0; - - // return module it belongs to - virtual CORINFO_MODULE_HANDLE getMethodModule ( - CORINFO_METHOD_HANDLE method - ) = 0; - - // This function returns the offset of the specified method in the - // vtable of it's owning class or interface. - virtual void getMethodVTableOffset ( - CORINFO_METHOD_HANDLE method, /* IN */ - unsigned* offsetOfIndirection, /* OUT */ - unsigned* offsetAfterIndirection, /* OUT */ - bool* isRelative /* OUT */ - ) = 0; - - // Find the virtual method in implementingClass that overrides virtualMethod, - // or the method in implementingClass that implements the interface method - // represented by virtualMethod. - // - // Return null if devirtualization is not possible. Owner type is optional - // and provides additional context for shared interface devirtualization. - virtual CORINFO_METHOD_HANDLE resolveVirtualMethod( - CORINFO_METHOD_HANDLE virtualMethod, /* IN */ - CORINFO_CLASS_HANDLE implementingClass, /* IN */ - CORINFO_CONTEXT_HANDLE ownerType = NULL /* IN */ - ) = 0; - - // Get the unboxed entry point for a method, if possible. - virtual CORINFO_METHOD_HANDLE getUnboxedEntry( - CORINFO_METHOD_HANDLE ftn, - bool* requiresInstMethodTableArg = NULL /* OUT */ - ) = 0; - - // Given T, return the type of the default EqualityComparer. - // Returns null if the type can't be determined exactly. - virtual CORINFO_CLASS_HANDLE getDefaultEqualityComparerClass( - CORINFO_CLASS_HANDLE elemType - ) = 0; - - // Given resolved token that corresponds to an intrinsic classified as - // a CORINFO_INTRINSIC_GetRawHandle intrinsic, fetch the handle associated - // with the token. If this is not possible at compile-time (because the current method's - // code is shared and the token contains generic parameters) then indicate - // how the handle should be looked up at runtime. - virtual void expandRawHandleIntrinsic( - CORINFO_RESOLVED_TOKEN * pResolvedToken, - CORINFO_GENERICHANDLE_RESULT * pResult) = 0; - - // If a method's attributes have (getMethodAttribs) CORINFO_FLG_INTRINSIC set, - // getIntrinsicID() returns the intrinsic ID. - // *pMustExpand tells whether or not JIT must expand the intrinsic. - virtual CorInfoIntrinsics getIntrinsicID( - CORINFO_METHOD_HANDLE method, - bool* pMustExpand = NULL /* OUT */ - ) = 0; - - // Is the given module the System.Numerics.Vectors module? - // This defaults to false. - virtual bool isInSIMDModule( - CORINFO_CLASS_HANDLE classHnd - ) { return false; } - - // return the unmanaged calling convention for a PInvoke - virtual CorInfoUnmanagedCallConv getUnmanagedCallConv( - CORINFO_METHOD_HANDLE method - ) = 0; - - // return if any marshaling is required for PInvoke methods. Note that - // method == 0 => calli. The call site sig is only needed for the varargs or calli case - virtual BOOL pInvokeMarshalingRequired( - CORINFO_METHOD_HANDLE method, - CORINFO_SIG_INFO* callSiteSig - ) = 0; - - // Check constraints on method type arguments (only). - // The parent class should be checked separately using satisfiesClassConstraints(parent). - virtual BOOL satisfiesMethodConstraints( - CORINFO_CLASS_HANDLE parent, // the exact parent of the method - CORINFO_METHOD_HANDLE method - ) = 0; - - // Given a delegate target class, a target method parent class, a target method, - // a delegate class, check if the method signature is compatible with the Invoke method of the delegate - // (under the typical instantiation of any free type variables in the memberref signatures). - virtual BOOL isCompatibleDelegate( - CORINFO_CLASS_HANDLE objCls, /* type of the delegate target, if any */ - CORINFO_CLASS_HANDLE methodParentCls, /* exact parent of the target method, if any */ - CORINFO_METHOD_HANDLE method, /* (representative) target method, if any */ - CORINFO_CLASS_HANDLE delegateCls, /* exact type of the delegate */ - BOOL *pfIsOpenDelegate /* is the delegate open */ - ) = 0; - - // Indicates if the method is an instance of the generic - // method that passes (or has passed) verification - virtual CorInfoInstantiationVerification isInstantiationOfVerifiedGeneric ( - CORINFO_METHOD_HANDLE method /* IN */ - ) = 0; - - // Loads the constraints on a typical method definition, detecting cycles; - // for use in verification. - virtual void initConstraintsForVerification( - CORINFO_METHOD_HANDLE method, /* IN */ - BOOL *pfHasCircularClassConstraints, /* OUT */ - BOOL *pfHasCircularMethodConstraint /* OUT */ - ) = 0; - - // Returns enum whether the method does not require verification - // Also see ICorModuleInfo::canSkipVerification - virtual CorInfoCanSkipVerificationResult canSkipMethodVerification ( - CORINFO_METHOD_HANDLE ftnHandle - ) = 0; - - // load and restore the method - virtual void methodMustBeLoadedBeforeCodeIsRun( - CORINFO_METHOD_HANDLE method - ) = 0; - - virtual CORINFO_METHOD_HANDLE mapMethodDeclToMethodImpl( - CORINFO_METHOD_HANDLE method - ) = 0; - - // Returns the global cookie for the /GS unsafe buffer checks - // The cookie might be a constant value (JIT), or a handle to memory location (Ngen) - virtual void getGSCookie( - GSCookie * pCookieVal, // OUT - GSCookie ** ppCookieVal // OUT - ) = 0; - - /**********************************************************************************/ - // - // ICorModuleInfo - // - /**********************************************************************************/ - - // Resolve metadata token into runtime method handles. This function may not - // return normally (e.g. it may throw) if it encounters invalid metadata or other - // failures during token resolution. - virtual void resolveToken(/* IN, OUT */ CORINFO_RESOLVED_TOKEN * pResolvedToken) = 0; - - // Attempt to resolve a metadata token into a runtime method handle. Returns true - // if resolution succeeded and false otherwise (e.g. if it encounters invalid metadata - // during token reoslution). This method should be used instead of `resolveToken` in - // situations that need to be resilient to invalid metadata. - virtual bool tryResolveToken(/* IN, OUT */ CORINFO_RESOLVED_TOKEN * pResolvedToken) = 0; - - // Signature information about the call sig - virtual void findSig ( - CORINFO_MODULE_HANDLE module, /* IN */ - unsigned sigTOK, /* IN */ - CORINFO_CONTEXT_HANDLE context, /* IN */ - CORINFO_SIG_INFO *sig /* OUT */ - ) = 0; - - // for Varargs, the signature at the call site may differ from - // the signature at the definition. Thus we need a way of - // fetching the call site information - virtual void findCallSiteSig ( - CORINFO_MODULE_HANDLE module, /* IN */ - unsigned methTOK, /* IN */ - CORINFO_CONTEXT_HANDLE context, /* IN */ - CORINFO_SIG_INFO *sig /* OUT */ - ) = 0; - - virtual CORINFO_CLASS_HANDLE getTokenTypeAsHandle ( - CORINFO_RESOLVED_TOKEN * pResolvedToken /* IN */) = 0; - - // Returns true if the module does not require verification - // - // If fQuickCheckOnlyWithoutCommit=TRUE, the function only checks that the - // module does not currently require verification in the current AppDomain. - // This decision could change in the future, and so should not be cached. - // If it is cached, it should only be used as a hint. - // This is only used by ngen for calculating certain hints. - // - - // Returns enum whether the module does not require verification - // Also see ICorMethodInfo::canSkipMethodVerification(); - virtual CorInfoCanSkipVerificationResult canSkipVerification ( - CORINFO_MODULE_HANDLE module /* IN */ - ) = 0; - - // Checks if the given metadata token is valid - virtual BOOL isValidToken ( - CORINFO_MODULE_HANDLE module, /* IN */ - unsigned metaTOK /* IN */ - ) = 0; - - // Checks if the given metadata token is valid StringRef - virtual BOOL isValidStringRef ( - CORINFO_MODULE_HANDLE module, /* IN */ - unsigned metaTOK /* IN */ - ) = 0; - - virtual BOOL shouldEnforceCallvirtRestriction( - CORINFO_MODULE_HANDLE scope - ) = 0; - - /**********************************************************************************/ - // - // ICorClassInfo - // - /**********************************************************************************/ - - // If the value class 'cls' is isomorphic to a primitive type it will - // return that type, otherwise it will return CORINFO_TYPE_VALUECLASS - virtual CorInfoType asCorInfoType ( - CORINFO_CLASS_HANDLE cls - ) = 0; - - // for completeness - virtual const char* getClassName ( - CORINFO_CLASS_HANDLE cls - ) = 0; - - // Return class name as in metadata, or nullptr if there is none. - // Suitable for non-debugging use. - virtual const char* getClassNameFromMetadata ( - CORINFO_CLASS_HANDLE cls, - const char **namespaceName /* OUT */ - ) = 0; - - // Return the type argument of the instantiated generic class, - // which is specified by the index - virtual CORINFO_CLASS_HANDLE getTypeInstantiationArgument( - CORINFO_CLASS_HANDLE cls, - unsigned index - ) = 0; - - - // Append a (possibly truncated) representation of the type cls to the preallocated buffer ppBuf of length pnBufLen - // If fNamespace=TRUE, include the namespace/enclosing classes - // If fFullInst=TRUE (regardless of fNamespace and fAssembly), include namespace and assembly for any type parameters - // If fAssembly=TRUE, suffix with a comma and the full assembly qualification - // return size of representation - virtual int appendClassName( - __deref_inout_ecount(*pnBufLen) WCHAR** ppBuf, - int* pnBufLen, - CORINFO_CLASS_HANDLE cls, - BOOL fNamespace, - BOOL fFullInst, - BOOL fAssembly - ) = 0; - - // Quick check whether the type is a value class. Returns the same value as getClassAttribs(cls) & CORINFO_FLG_VALUECLASS, except faster. - virtual BOOL isValueClass(CORINFO_CLASS_HANDLE cls) = 0; - - // If this method returns true, JIT will do optimization to inline the check for - // GetTypeFromHandle(handle) == obj.GetType() - virtual BOOL canInlineTypeCheckWithObjectVTable(CORINFO_CLASS_HANDLE cls) = 0; - - // return flags (defined above, CORINFO_FLG_PUBLIC ...) - virtual DWORD getClassAttribs ( - CORINFO_CLASS_HANDLE cls - ) = 0; - - // Returns "TRUE" iff "cls" is a struct type such that return buffers used for returning a value - // of this type must be stack-allocated. This will generally be true only if the struct - // contains GC pointers, and does not exceed some size limit. Maintaining this as an invariant allows - // an optimization: the JIT may assume that return buffer pointers for return types for which this predicate - // returns TRUE are always stack allocated, and thus, that stores to the GC-pointer fields of such return - // buffers do not require GC write barriers. - virtual BOOL isStructRequiringStackAllocRetBuf(CORINFO_CLASS_HANDLE cls) = 0; - - virtual CORINFO_MODULE_HANDLE getClassModule ( - CORINFO_CLASS_HANDLE cls - ) = 0; - - // Returns the assembly that contains the module "mod". - virtual CORINFO_ASSEMBLY_HANDLE getModuleAssembly ( - CORINFO_MODULE_HANDLE mod - ) = 0; - - // Returns the name of the assembly "assem". - virtual const char* getAssemblyName ( - CORINFO_ASSEMBLY_HANDLE assem - ) = 0; - - // Allocate and delete process-lifetime objects. Should only be - // referred to from static fields, lest a leak occur. - // Note that "LongLifetimeFree" does not execute destructors, if "obj" - // is an array of a struct type with a destructor. - virtual void* LongLifetimeMalloc(size_t sz) = 0; - virtual void LongLifetimeFree(void* obj) = 0; - - virtual size_t getClassModuleIdForStatics ( - CORINFO_CLASS_HANDLE cls, - CORINFO_MODULE_HANDLE *pModule, - void **ppIndirection - ) = 0; - - // return the number of bytes needed by an instance of the class - virtual unsigned getClassSize ( - CORINFO_CLASS_HANDLE cls - ) = 0; - - virtual unsigned getClassAlignmentRequirement ( - CORINFO_CLASS_HANDLE cls, - BOOL fDoubleAlignHint = FALSE - ) = 0; - - // This is only called for Value classes. It returns a boolean array - // in representing of 'cls' from a GC perspective. The class is - // assumed to be an array of machine words - // (of length // getClassSize(cls) / TARGET_POINTER_SIZE), - // 'gcPtrs' is a pointer to an array of BYTEs of this length. - // getClassGClayout fills in this array so that gcPtrs[i] is set - // to one of the CorInfoGCType values which is the GC type of - // the i-th machine word of an object of type 'cls' - // returns the number of GC pointers in the array - virtual unsigned getClassGClayout ( - CORINFO_CLASS_HANDLE cls, /* IN */ - BYTE *gcPtrs /* OUT */ - ) = 0; - - // returns the number of instance fields in a class - virtual unsigned getClassNumInstanceFields ( - CORINFO_CLASS_HANDLE cls /* IN */ - ) = 0; - - virtual CORINFO_FIELD_HANDLE getFieldInClass( - CORINFO_CLASS_HANDLE clsHnd, - INT num - ) = 0; - - virtual BOOL checkMethodModifier( - CORINFO_METHOD_HANDLE hMethod, - LPCSTR modifier, - BOOL fOptional - ) = 0; - - // returns the "NEW" helper optimized for "newCls." - virtual CorInfoHelpFunc getNewHelper( - CORINFO_RESOLVED_TOKEN * pResolvedToken, - CORINFO_METHOD_HANDLE callerHandle - ) = 0; - - // returns the newArr (1-Dim array) helper optimized for "arrayCls." - virtual CorInfoHelpFunc getNewArrHelper( - CORINFO_CLASS_HANDLE arrayCls - ) = 0; - - // returns the optimized "IsInstanceOf" or "ChkCast" helper - virtual CorInfoHelpFunc getCastingHelper( - CORINFO_RESOLVED_TOKEN * pResolvedToken, - bool fThrowing - ) = 0; - - // returns helper to trigger static constructor - virtual CorInfoHelpFunc getSharedCCtorHelper( - CORINFO_CLASS_HANDLE clsHnd - ) = 0; - - virtual CorInfoHelpFunc getSecurityPrologHelper( - CORINFO_METHOD_HANDLE ftn - ) = 0; - - // This is not pretty. Boxing nullable actually returns - // a boxed not a boxed Nullable. This call allows the verifier - // to call back to the EE on the 'box' instruction and get the transformed - // type to use for verification. - virtual CORINFO_CLASS_HANDLE getTypeForBox( - CORINFO_CLASS_HANDLE cls - ) = 0; - - // returns the correct box helper for a particular class. Note - // that if this returns CORINFO_HELP_BOX, the JIT can assume - // 'standard' boxing (allocate object and copy), and optimize - virtual CorInfoHelpFunc getBoxHelper( - CORINFO_CLASS_HANDLE cls - ) = 0; - - // returns the unbox helper. If 'helperCopies' points to a true - // value it means the JIT is requesting a helper that unboxes the - // value into a particular location and thus has the signature - // void unboxHelper(void* dest, CORINFO_CLASS_HANDLE cls, Object* obj) - // Otherwise (it is null or points at a FALSE value) it is requesting - // a helper that returns a pointer to the unboxed data - // void* unboxHelper(CORINFO_CLASS_HANDLE cls, Object* obj) - // The EE has the option of NOT returning the copy style helper - // (But must be able to always honor the non-copy style helper) - // The EE set 'helperCopies' on return to indicate what kind of - // helper has been created. - - virtual CorInfoHelpFunc getUnBoxHelper( - CORINFO_CLASS_HANDLE cls - ) = 0; - - virtual bool getReadyToRunHelper( - CORINFO_RESOLVED_TOKEN * pResolvedToken, - CORINFO_LOOKUP_KIND * pGenericLookupKind, - CorInfoHelpFunc id, - CORINFO_CONST_LOOKUP * pLookup - ) = 0; - - virtual void getReadyToRunDelegateCtorHelper( - CORINFO_RESOLVED_TOKEN * pTargetMethod, - CORINFO_CLASS_HANDLE delegateType, - CORINFO_LOOKUP * pLookup - ) = 0; - - virtual const char* getHelperName( - CorInfoHelpFunc - ) = 0; - - // This function tries to initialize the class (run the class constructor). - // this function returns whether the JIT must insert helper calls before - // accessing static field or method. - // - // See code:ICorClassInfo#ClassConstruction. - virtual CorInfoInitClassResult initClass( - CORINFO_FIELD_HANDLE field, // Non-NULL - inquire about cctor trigger before static field access - // NULL - inquire about cctor trigger in method prolog - CORINFO_METHOD_HANDLE method, // Method referencing the field or prolog - CORINFO_CONTEXT_HANDLE context, // Exact context of method - BOOL speculative = FALSE // TRUE means don't actually run it - ) = 0; - - // This used to be called "loadClass". This records the fact - // that the class must be loaded (including restored if necessary) before we execute the - // code that we are currently generating. When jitting code - // the function loads the class immediately. When zapping code - // the zapper will if necessary use the call to record the fact that we have - // to do a fixup/restore before running the method currently being generated. - // - // This is typically used to ensure value types are loaded before zapped - // code that manipulates them is executed, so that the GC can access information - // about those value types. - virtual void classMustBeLoadedBeforeCodeIsRun( - CORINFO_CLASS_HANDLE cls - ) = 0; - - // returns the class handle for the special builtin classes - virtual CORINFO_CLASS_HANDLE getBuiltinClass ( - CorInfoClassId classId - ) = 0; - - // "System.Int32" ==> CORINFO_TYPE_INT.. - virtual CorInfoType getTypeForPrimitiveValueClass( - CORINFO_CLASS_HANDLE cls - ) = 0; - - // "System.Int32" ==> CORINFO_TYPE_INT.. - // "System.UInt32" ==> CORINFO_TYPE_UINT.. - virtual CorInfoType getTypeForPrimitiveNumericClass( - CORINFO_CLASS_HANDLE cls - ) = 0; - - // TRUE if child is a subtype of parent - // if parent is an interface, then does child implement / extend parent - virtual BOOL canCast( - CORINFO_CLASS_HANDLE child, // subtype (extends parent) - CORINFO_CLASS_HANDLE parent // base type - ) = 0; - - // TRUE if cls1 and cls2 are considered equivalent types. - virtual BOOL areTypesEquivalent( - CORINFO_CLASS_HANDLE cls1, - CORINFO_CLASS_HANDLE cls2 - ) = 0; - - // See if a cast from fromClass to toClass will succeed, fail, or needs - // to be resolved at runtime. - virtual TypeCompareState compareTypesForCast( - CORINFO_CLASS_HANDLE fromClass, - CORINFO_CLASS_HANDLE toClass - ) = 0; - - // See if types represented by cls1 and cls2 compare equal, not - // equal, or the comparison needs to be resolved at runtime. - virtual TypeCompareState compareTypesForEquality( - CORINFO_CLASS_HANDLE cls1, - CORINFO_CLASS_HANDLE cls2 - ) = 0; - - // returns is the intersection of cls1 and cls2. - virtual CORINFO_CLASS_HANDLE mergeClasses( - CORINFO_CLASS_HANDLE cls1, - CORINFO_CLASS_HANDLE cls2 - ) = 0; - - // Given a class handle, returns the Parent type. - // For COMObjectType, it returns Class Handle of System.Object. - // Returns 0 if System.Object is passed in. - virtual CORINFO_CLASS_HANDLE getParentType ( - CORINFO_CLASS_HANDLE cls - ) = 0; - - // Returns the CorInfoType of the "child type". If the child type is - // not a primitive type, *clsRet will be set. - // Given an Array of Type Foo, returns Foo. - // Given BYREF Foo, returns Foo - virtual CorInfoType getChildType ( - CORINFO_CLASS_HANDLE clsHnd, - CORINFO_CLASS_HANDLE *clsRet - ) = 0; - - // Check constraints on type arguments of this class and parent classes - virtual BOOL satisfiesClassConstraints( - CORINFO_CLASS_HANDLE cls - ) = 0; - - // Check if this is a single dimensional array type - virtual BOOL isSDArray( - CORINFO_CLASS_HANDLE cls - ) = 0; - - // Get the numbmer of dimensions in an array - virtual unsigned getArrayRank( - CORINFO_CLASS_HANDLE cls - ) = 0; - - // Get static field data for an array - virtual void * getArrayInitializationData( - CORINFO_FIELD_HANDLE field, - DWORD size - ) = 0; - - // Check Visibility rules. - virtual CorInfoIsAccessAllowedResult canAccessClass( - CORINFO_RESOLVED_TOKEN * pResolvedToken, - CORINFO_METHOD_HANDLE callerHandle, - CORINFO_HELPER_DESC *pAccessHelper /* If canAccessMethod returns something other - than ALLOWED, then this is filled in. */ - ) = 0; - - /**********************************************************************************/ - // - // ICorFieldInfo - // - /**********************************************************************************/ - - // this function is for debugging only. It returns the field name - // and if 'moduleName' is non-null, it sets it to something that will - // says which method (a class name, or a module name) - virtual const char* getFieldName ( - CORINFO_FIELD_HANDLE ftn, /* IN */ - const char **moduleName /* OUT */ - ) = 0; - - // return class it belongs to - virtual CORINFO_CLASS_HANDLE getFieldClass ( - CORINFO_FIELD_HANDLE field - ) = 0; - - // Return the field's type, if it is CORINFO_TYPE_VALUECLASS 'structType' is set - // the field's value class (if 'structType' == 0, then don't bother - // the structure info). - // - // 'memberParent' is typically only set when verifying. It should be the - // result of calling getMemberParent. - virtual CorInfoType getFieldType( - CORINFO_FIELD_HANDLE field, - CORINFO_CLASS_HANDLE *structType, - CORINFO_CLASS_HANDLE memberParent = NULL /* IN */ - ) = 0; - - // return the data member's instance offset - virtual unsigned getFieldOffset( - CORINFO_FIELD_HANDLE field - ) = 0; - - // TODO: jit64 should be switched to the same plan as the i386 jits - use - // getClassGClayout to figure out the need for writebarrier helper, and inline the copying. - // The interpretted value class copy is slow. Once this happens, USE_WRITE_BARRIER_HELPERS - virtual bool isWriteBarrierHelperRequired( - CORINFO_FIELD_HANDLE field) = 0; - - virtual void getFieldInfo (CORINFO_RESOLVED_TOKEN * pResolvedToken, - CORINFO_METHOD_HANDLE callerHandle, - CORINFO_ACCESS_FLAGS flags, - CORINFO_FIELD_INFO *pResult - ) = 0; - - // Returns true iff "fldHnd" represents a static field. - virtual bool isFieldStatic(CORINFO_FIELD_HANDLE fldHnd) = 0; - - /*********************************************************************************/ - // - // ICorDebugInfo - // - /*********************************************************************************/ - - // Query the EE to find out where interesting break points - // in the code are. The native compiler will ensure that these places - // have a corresponding break point in native code. - // - // Note that unless CORJIT_FLAG_DEBUG_CODE is specified, this function will - // be used only as a hint and the native compiler should not change its - // code generation. - virtual void getBoundaries( - CORINFO_METHOD_HANDLE ftn, // [IN] method of interest - unsigned int *cILOffsets, // [OUT] size of pILOffsets - DWORD **pILOffsets, // [OUT] IL offsets of interest - // jit MUST free with freeArray! - ICorDebugInfo::BoundaryTypes *implictBoundaries // [OUT] tell jit, all boundries of this type - ) = 0; - - // Report back the mapping from IL to native code, - // this map should include all boundaries that 'getBoundaries' - // reported as interesting to the debugger. - - // Note that debugger (and profiler) is assuming that all of the - // offsets form a contiguous block of memory, and that the - // OffsetMapping is sorted in order of increasing native offset. - virtual void setBoundaries( - CORINFO_METHOD_HANDLE ftn, // [IN] method of interest - ULONG32 cMap, // [IN] size of pMap - ICorDebugInfo::OffsetMapping *pMap // [IN] map including all points of interest. - // jit allocated with allocateArray, EE frees - ) = 0; - - // Query the EE to find out the scope of local varables. - // normally the JIT would trash variables after last use, but - // under debugging, the JIT needs to keep them live over their - // entire scope so that they can be inspected. - // - // Note that unless CORJIT_FLAG_DEBUG_CODE is specified, this function will - // be used only as a hint and the native compiler should not change its - // code generation. - virtual void getVars( - CORINFO_METHOD_HANDLE ftn, // [IN] method of interest - ULONG32 *cVars, // [OUT] size of 'vars' - ICorDebugInfo::ILVarInfo **vars, // [OUT] scopes of variables of interest - // jit MUST free with freeArray! - bool *extendOthers // [OUT] it TRUE, then assume the scope - // of unmentioned vars is entire method - ) = 0; - - // Report back to the EE the location of every variable. - // note that the JIT might split lifetimes into different - // locations etc. - - virtual void setVars( - CORINFO_METHOD_HANDLE ftn, // [IN] method of interest - ULONG32 cVars, // [IN] size of 'vars' - ICorDebugInfo::NativeVarInfo *vars // [IN] map telling where local vars are stored at what points - // jit allocated with allocateArray, EE frees - ) = 0; - - /*-------------------------- Misc ---------------------------------------*/ - - // Used to allocate memory that needs to handed to the EE. - // For eg, use this to allocated memory for reporting debug info, - // which will be handed to the EE by setVars() and setBoundaries() - virtual void * allocateArray( - ULONG cBytes - ) = 0; - - // JitCompiler will free arrays passed by the EE using this - // For eg, The EE returns memory in getVars() and getBoundaries() - // to the JitCompiler, which the JitCompiler should release using - // freeArray() - virtual void freeArray( - void *array - ) = 0; - - /*********************************************************************************/ - // - // ICorArgInfo - // - /*********************************************************************************/ - - // advance the pointer to the argument list. - // a ptr of 0, is special and always means the first argument - virtual CORINFO_ARG_LIST_HANDLE getArgNext ( - CORINFO_ARG_LIST_HANDLE args /* IN */ - ) = 0; - - // Get the type of a particular argument - // CORINFO_TYPE_UNDEF is returned when there are no more arguments - // If the type returned is a primitive type (or an enum) *vcTypeRet set to NULL - // otherwise it is set to the TypeHandle associted with the type - // Enumerations will always look their underlying type (probably should fix this) - // Otherwise vcTypeRet is the type as would be seen by the IL, - // The return value is the type that is used for calling convention purposes - // (Thus if the EE wants a value class to be passed like an int, then it will - // return CORINFO_TYPE_INT - virtual CorInfoTypeWithMod getArgType ( - CORINFO_SIG_INFO* sig, /* IN */ - CORINFO_ARG_LIST_HANDLE args, /* IN */ - CORINFO_CLASS_HANDLE *vcTypeRet /* OUT */ - ) = 0; - - // If the Arg is a CORINFO_TYPE_CLASS fetch the class handle associated with it - virtual CORINFO_CLASS_HANDLE getArgClass ( - CORINFO_SIG_INFO* sig, /* IN */ - CORINFO_ARG_LIST_HANDLE args /* IN */ - ) = 0; - - // Returns type of HFA for valuetype - virtual CorInfoType getHFAType ( - CORINFO_CLASS_HANDLE hClass - ) = 0; - - /***************************************************************************** - * ICorErrorInfo contains methods to deal with SEH exceptions being thrown - * from the corinfo interface. These methods may be called when an exception - * with code EXCEPTION_COMPLUS is caught. - *****************************************************************************/ - - // Returns the HRESULT of the current exception - virtual HRESULT GetErrorHRESULT( - struct _EXCEPTION_POINTERS *pExceptionPointers - ) = 0; - - // Fetches the message of the current exception - // Returns the size of the message (including terminating null). This can be - // greater than bufferLength if the buffer is insufficient. - virtual ULONG GetErrorMessage( - __inout_ecount(bufferLength) LPWSTR buffer, - ULONG bufferLength - ) = 0; - - // returns EXCEPTION_EXECUTE_HANDLER if it is OK for the compile to handle the - // exception, abort some work (like the inlining) and continue compilation - // returns EXCEPTION_CONTINUE_SEARCH if exception must always be handled by the EE - // things like ThreadStoppedException ... - // returns EXCEPTION_CONTINUE_EXECUTION if exception is fixed up by the EE - - virtual int FilterException( - struct _EXCEPTION_POINTERS *pExceptionPointers - ) = 0; - - // Cleans up internal EE tracking when an exception is caught. - virtual void HandleException( - struct _EXCEPTION_POINTERS *pExceptionPointers - ) = 0; - - virtual void ThrowExceptionForJitResult( - HRESULT result) = 0; - - //Throws an exception defined by the given throw helper. - virtual void ThrowExceptionForHelper( - const CORINFO_HELPER_DESC * throwHelper) = 0; - - // Runs the given function under an error trap. This allows the JIT to make calls - // to interface functions that may throw exceptions without needing to be aware of - // the EH ABI, exception types, etc. Returns true if the given function completed - // successfully and false otherwise. - virtual bool runWithErrorTrap( - void (*function)(void*), // The function to run - void* parameter // The context parameter that will be passed to the function and the handler - ) = 0; - -/***************************************************************************** - * ICorStaticInfo contains EE interface methods which return values that are - * constant from invocation to invocation. Thus they may be embedded in - * persisted information like statically generated code. (This is of course - * assuming that all code versions are identical each time.) - *****************************************************************************/ - - // Return details about EE internal data structures - virtual void getEEInfo( - CORINFO_EE_INFO *pEEInfoOut - ) = 0; - - // Returns name of the JIT timer log - virtual LPCWSTR getJitTimeLogFilename() = 0; - - /*********************************************************************************/ - // - // Diagnostic methods - // - /*********************************************************************************/ - - // this function is for debugging only. Returns method token. - // Returns mdMethodDefNil for dynamic methods. - virtual mdMethodDef getMethodDefFromMethod( - CORINFO_METHOD_HANDLE hMethod - ) = 0; - - // this function is for debugging only. It returns the method name - // and if 'moduleName' is non-null, it sets it to something that will - // says which method (a class name, or a module name) - virtual const char* getMethodName ( - CORINFO_METHOD_HANDLE ftn, /* IN */ - const char **moduleName /* OUT */ - ) = 0; - - // Return method name as in metadata, or nullptr if there is none, - // and optionally return the class and namespace names as in metadata. - // Suitable for non-debugging use. - virtual const char* getMethodNameFromMetadata( - CORINFO_METHOD_HANDLE ftn, /* IN */ - const char **className, /* OUT */ - const char **namespaceName /* OUT */ - ) = 0; - - // this function is for debugging only. It returns a value that - // is will always be the same for a given method. It is used - // to implement the 'jitRange' functionality - virtual unsigned getMethodHash ( - CORINFO_METHOD_HANDLE ftn /* IN */ - ) = 0; - - // this function is for debugging only. - virtual size_t findNameOfToken ( - CORINFO_MODULE_HANDLE module, /* IN */ - mdToken metaTOK, /* IN */ - __out_ecount (FQNameCapacity) char * szFQName, /* OUT */ - size_t FQNameCapacity /* IN */ - ) = 0; - - // returns whether the struct is enregisterable. Only valid on a System V VM. Returns true on success, false on failure. - virtual bool getSystemVAmd64PassStructInRegisterDescriptor( - /* IN */ CORINFO_CLASS_HANDLE structHnd, - /* OUT */ SYSTEMV_AMD64_CORINFO_STRUCT_REG_PASSING_DESCRIPTOR* structPassInRegDescPtr - ) = 0; - -}; - -/***************************************************************************** - * ICorDynamicInfo contains EE interface methods which return values that may - * change from invocation to invocation. They cannot be embedded in persisted - * data; they must be requeried each time the EE is run. - *****************************************************************************/ - -class ICorDynamicInfo : public ICorStaticInfo -{ -public: - - // - // These methods return values to the JIT which are not constant - // from session to session. - // - // These methods take an extra parameter : void **ppIndirection. - // If a JIT supports generation of prejit code (install-o-jit), it - // must pass a non-null value for this parameter, and check the - // resulting value. If *ppIndirection is NULL, code should be - // generated normally. If non-null, then the value of - // *ppIndirection is an address in the cookie table, and the code - // generator needs to generate an indirection through the table to - // get the resulting value. In this case, the return result of the - // function must NOT be directly embedded in the generated code. - // - // Note that if a JIT does not support prejit code generation, it - // may ignore the extra parameter & pass the default of NULL - the - // prejit ICorDynamicInfo implementation will see this & generate - // an error if the jitter is used in a prejit scenario. - // - - // Return details about EE internal data structures - - virtual DWORD getThreadTLSIndex( - void **ppIndirection = NULL - ) = 0; - - virtual const void * getInlinedCallFrameVptr( - void **ppIndirection = NULL - ) = 0; - - virtual LONG * getAddrOfCaptureThreadGlobal( - void **ppIndirection = NULL - ) = 0; - - // return the native entry point to an EE helper (see CorInfoHelpFunc) - virtual void* getHelperFtn ( - CorInfoHelpFunc ftnNum, - void **ppIndirection = NULL - ) = 0; - - // return a callable address of the function (native code). This function - // may return a different value (depending on whether the method has - // been JITed or not. - virtual void getFunctionEntryPoint( - CORINFO_METHOD_HANDLE ftn, /* IN */ - CORINFO_CONST_LOOKUP * pResult, /* OUT */ - CORINFO_ACCESS_FLAGS accessFlags = CORINFO_ACCESS_ANY) = 0; - - // return a directly callable address. This can be used similarly to the - // value returned by getFunctionEntryPoint() except that it is - // guaranteed to be multi callable entrypoint. - virtual void getFunctionFixedEntryPoint( - CORINFO_METHOD_HANDLE ftn, - CORINFO_CONST_LOOKUP * pResult) = 0; - - // get the synchronization handle that is passed to monXstatic function - virtual void* getMethodSync( - CORINFO_METHOD_HANDLE ftn, - void **ppIndirection = NULL - ) = 0; - - // get slow lazy string literal helper to use (CORINFO_HELP_STRCNS*). - // Returns CORINFO_HELP_UNDEF if lazy string literal helper cannot be used. - virtual CorInfoHelpFunc getLazyStringLiteralHelper( - CORINFO_MODULE_HANDLE handle - ) = 0; - - virtual CORINFO_MODULE_HANDLE embedModuleHandle( - CORINFO_MODULE_HANDLE handle, - void **ppIndirection = NULL - ) = 0; - - virtual CORINFO_CLASS_HANDLE embedClassHandle( - CORINFO_CLASS_HANDLE handle, - void **ppIndirection = NULL - ) = 0; - - virtual CORINFO_METHOD_HANDLE embedMethodHandle( - CORINFO_METHOD_HANDLE handle, - void **ppIndirection = NULL - ) = 0; - - virtual CORINFO_FIELD_HANDLE embedFieldHandle( - CORINFO_FIELD_HANDLE handle, - void **ppIndirection = NULL - ) = 0; - - // Given a module scope (module), a method handle (context) and - // a metadata token (metaTOK), fetch the handle - // (type, field or method) associated with the token. - // If this is not possible at compile-time (because the current method's - // code is shared and the token contains generic parameters) - // then indicate how the handle should be looked up at run-time. - // - virtual void embedGenericHandle( - CORINFO_RESOLVED_TOKEN * pResolvedToken, - BOOL fEmbedParent, // TRUE - embeds parent type handle of the field/method handle - CORINFO_GENERICHANDLE_RESULT * pResult) = 0; - - // Return information used to locate the exact enclosing type of the current method. - // Used only to invoke .cctor method from code shared across generic instantiations - // !needsRuntimeLookup statically known (enclosing type of method itself) - // needsRuntimeLookup: - // CORINFO_LOOKUP_THISOBJ use vtable pointer of 'this' param - // CORINFO_LOOKUP_CLASSPARAM use vtable hidden param - // CORINFO_LOOKUP_METHODPARAM use enclosing type of method-desc hidden param - virtual CORINFO_LOOKUP_KIND getLocationOfThisType( - CORINFO_METHOD_HANDLE context - ) = 0; - - // NOTE: the two methods below--getPInvokeUnmanagedTarget and getAddressOfPInvokeFixup--are - // deprecated. New code should instead use getAddressOfPInvokeTarget, which subsumes the - // functionality of these methods. - - // return the unmanaged target *if method has already been prelinked.* - virtual void* getPInvokeUnmanagedTarget( - CORINFO_METHOD_HANDLE method, - void **ppIndirection = NULL - ) = 0; - - // return address of fixup area for late-bound PInvoke calls. - virtual void* getAddressOfPInvokeFixup( - CORINFO_METHOD_HANDLE method, - void **ppIndirection = NULL - ) = 0; - - // return the address of the PInvoke target. May be a fixup area in the - // case of late-bound PInvoke calls. - virtual void getAddressOfPInvokeTarget( - CORINFO_METHOD_HANDLE method, - CORINFO_CONST_LOOKUP *pLookup - ) = 0; - - // Generate a cookie based on the signature that would needs to be passed - // to CORINFO_HELP_PINVOKE_CALLI - virtual LPVOID GetCookieForPInvokeCalliSig( - CORINFO_SIG_INFO* szMetaSig, - void ** ppIndirection = NULL - ) = 0; - - // returns true if a VM cookie can be generated for it (might be false due to cross-module - // inlining, in which case the inlining should be aborted) - virtual bool canGetCookieForPInvokeCalliSig( - CORINFO_SIG_INFO* szMetaSig - ) = 0; - - // Gets a handle that is checked to see if the current method is - // included in "JustMyCode" - virtual CORINFO_JUST_MY_CODE_HANDLE getJustMyCodeHandle( - CORINFO_METHOD_HANDLE method, - CORINFO_JUST_MY_CODE_HANDLE**ppIndirection = NULL - ) = 0; - - // Gets a method handle that can be used to correlate profiling data. - // This is the IP of a native method, or the address of the descriptor struct - // for IL. Always guaranteed to be unique per process, and not to move. */ - virtual void GetProfilingHandle( - BOOL *pbHookFunction, - void **pProfilerHandle, - BOOL *pbIndirectedHandles - ) = 0; - - // Returns instructions on how to make the call. See code:CORINFO_CALL_INFO for possible return values. - virtual void getCallInfo( - // Token info - CORINFO_RESOLVED_TOKEN * pResolvedToken, - - //Generics info - CORINFO_RESOLVED_TOKEN * pConstrainedResolvedToken, - - //Security info - CORINFO_METHOD_HANDLE callerHandle, - - //Jit info - CORINFO_CALLINFO_FLAGS flags, - - //out params - CORINFO_CALL_INFO *pResult - ) = 0; - - virtual BOOL canAccessFamily(CORINFO_METHOD_HANDLE hCaller, - CORINFO_CLASS_HANDLE hInstanceType) = 0; - - // Returns TRUE if the Class Domain ID is the RID of the class (currently true for every class - // except reflection emitted classes and generics) - virtual BOOL isRIDClassDomainID(CORINFO_CLASS_HANDLE cls) = 0; - - // returns the class's domain ID for accessing shared statics - virtual unsigned getClassDomainID ( - CORINFO_CLASS_HANDLE cls, - void **ppIndirection = NULL - ) = 0; - - - // return the data's address (for static fields only) - virtual void* getFieldAddress( - CORINFO_FIELD_HANDLE field, - void **ppIndirection = NULL - ) = 0; - - // registers a vararg sig & returns a VM cookie for it (which can contain other stuff) - virtual CORINFO_VARARGS_HANDLE getVarArgsHandle( - CORINFO_SIG_INFO *pSig, - void **ppIndirection = NULL - ) = 0; - - // returns true if a VM cookie can be generated for it (might be false due to cross-module - // inlining, in which case the inlining should be aborted) - virtual bool canGetVarArgsHandle( - CORINFO_SIG_INFO *pSig - ) = 0; - - // Allocate a string literal on the heap and return a handle to it - virtual InfoAccessType constructStringLiteral( - CORINFO_MODULE_HANDLE module, - mdToken metaTok, - void **ppValue - ) = 0; - - virtual InfoAccessType emptyStringLiteral( - void **ppValue - ) = 0; - - // (static fields only) given that 'field' refers to thread local store, - // return the ID (TLS index), which is used to find the begining of the - // TLS data area for the particular DLL 'field' is associated with. - virtual DWORD getFieldThreadLocalStoreID ( - CORINFO_FIELD_HANDLE field, - void **ppIndirection = NULL - ) = 0; - - // Sets another object to intercept calls to "self" and current method being compiled - virtual void setOverride( - ICorDynamicInfo *pOverride, - CORINFO_METHOD_HANDLE currentMethod - ) = 0; - - // Adds an active dependency from the context method's module to the given module - // This is internal callback for the EE. JIT should not call it directly. - virtual void addActiveDependency( - CORINFO_MODULE_HANDLE moduleFrom, - CORINFO_MODULE_HANDLE moduleTo - ) = 0; - - virtual CORINFO_METHOD_HANDLE GetDelegateCtor( - CORINFO_METHOD_HANDLE methHnd, - CORINFO_CLASS_HANDLE clsHnd, - CORINFO_METHOD_HANDLE targetMethodHnd, - DelegateCtorArgs * pCtorData - ) = 0; - - virtual void MethodCompileComplete( - CORINFO_METHOD_HANDLE methHnd - ) = 0; - - // return a thunk that will copy the arguments for the given signature. - virtual void* getTailCallCopyArgsThunk ( - CORINFO_SIG_INFO *pSig, - CorInfoHelperTailCallSpecialHandling flags - ) = 0; -}; - -/**********************************************************************************/ - -// It would be nicer to use existing IMAGE_REL_XXX constants instead of defining our own here... -#define IMAGE_REL_BASED_REL32 0x10 -#define IMAGE_REL_BASED_THUMB_BRANCH24 0x13 - -// The identifier for ARM32-specific PC-relative address -// computation corresponds to the following instruction -// sequence: -// l0: movw rX, #imm_lo // 4 byte -// l4: movt rX, #imm_hi // 4 byte -// l8: add rX, pc <- after this instruction rX = relocTarget -// -// Program counter at l8 is address of l8 + 4 -// Address of relocated movw/movt is l0 -// So, imm should be calculated as the following: -// imm = relocTarget - (l8 + 4) = relocTarget - (l0 + 8 + 4) = relocTarget - (l_0 + 12) -// So, the value of offset correction is 12 -// -#define IMAGE_REL_BASED_REL_THUMB_MOV32_PCREL 0x14 - -#endif // _COR_INFO_H_ diff --git a/src/inc/corjit.h b/src/inc/corjit.h deleted file mode 100644 index cadfdff38..000000000 --- a/src/inc/corjit.h +++ /dev/null @@ -1,487 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*****************************************************************************\ -* * -* CorJit.h - EE / JIT interface * -* * -* Version 1.0 * -******************************************************************************* -* * -* * -* * -\*****************************************************************************/ - -////////////////////////////////////////////////////////////////////////////////////////////////////////// -// -// NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE -// -// The JIT/EE interface is versioned. By "interface", we mean mean any and all communication between the -// JIT and the EE. Any time a change is made to the interface, the JIT/EE interface version identifier -// must be updated. See code:JITEEVersionIdentifier for more information. -// -// NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE -// -////////////////////////////////////////////////////////////////////////////////////////////////////////// - -#ifndef _COR_JIT_H_ -#define _COR_JIT_H_ - -#include - -#include - -#include - -#define CORINFO_STACKPROBE_DEPTH 256*sizeof(UINT_PTR) // Guaranteed stack until an fcall/unmanaged - // code can set up a frame. Please make sure - // this is less than a page. This is due to - // 2 reasons: - // - // If we need to probe more than a page - // size, we need one instruction per page - // (7 bytes per instruction) - // - // The JIT wants some safe space so it doesn't - // have to put a probe on every call site. It achieves - // this by probing n bytes more than CORINFO_STACKPROBE_DEPTH - // If it hasn't used more than n for its own stuff, it - // can do a call without doing any other probe - // - // In any case, we do really expect this define to be - // small, as setting up a frame should be only pushing - // a couple of bytes on the stack - // - // There is a compile time assert - // in the x86 jit to protect you from this - // - - - - -/*****************************************************************************/ - // These are error codes returned by CompileMethod -enum CorJitResult -{ - // Note that I dont use FACILITY_NULL for the facility number, - // we may want to get a 'real' facility number - CORJIT_OK = NO_ERROR, - CORJIT_BADCODE = MAKE_HRESULT(SEVERITY_ERROR,FACILITY_NULL, 1), - CORJIT_OUTOFMEM = MAKE_HRESULT(SEVERITY_ERROR,FACILITY_NULL, 2), - CORJIT_INTERNALERROR = MAKE_HRESULT(SEVERITY_ERROR,FACILITY_NULL, 3), - CORJIT_SKIPPED = MAKE_HRESULT(SEVERITY_ERROR,FACILITY_NULL, 4), - CORJIT_RECOVERABLEERROR = MAKE_HRESULT(SEVERITY_ERROR,FACILITY_NULL, 5), -}; - -/***************************************************************************** -Here is how CORJIT_FLAG_SKIP_VERIFICATION should be interepreted. -Note that even if any method is inlined, it need not be verified. - -if (CORJIT_FLAG_SKIP_VERIFICATION is passed in to ICorJitCompiler::compileMethod()) -{ - No verification needs to be done. - Just compile the method, generating unverifiable code if necessary -} -else -{ - switch(ICorMethodInfo::isInstantiationOfVerifiedGeneric()) - { - case INSTVER_NOT_INSTANTIATION: - - // - // Non-generic case, or open generic instantiation - // - - switch(canSkipMethodVerification()) - { - case CORINFO_VERIFICATION_CANNOT_SKIP: - { - ICorMethodInfo::initConstraintsForVerification(&circularConstraints) - if (circularConstraints) - { - Just emit code to call CORINFO_HELP_VERIFICATION - The IL will not be compiled - } - else - { - Verify the method. - if (unverifiable code is detected) - { - In place of branches with unverifiable code, emit code to call CORINFO_HELP_VERIFICATION - Mark the method (and any of its instantiations) as unverifiable - } - Compile the rest of the verifiable code - } - } - - case CORINFO_VERIFICATION_CAN_SKIP: - { - No verification needs to be done. - Just compile the method, generating unverifiable code if necessary - } - - case CORINFO_VERIFICATION_RUNTIME_CHECK: - { - ICorMethodInfo::initConstraintsForVerification(&circularConstraints) - if (circularConstraints) - { - Just emit code to call CORINFO_HELP_VERIFICATION - The IL will not be compiled - - TODO: This could be changed to call CORINFO_HELP_VERIFICATION_RUNTIME_CHECK - } - else - { - Verify the method. - if (unverifiable code is detected) - { - In the prolog, emit code to call CORINFO_HELP_VERIFICATION_RUNTIME_CHECK - Mark the method (and any of its instantiations) as unverifiable - } - Compile the method, generating unverifiable code if necessary - } - } - case CORINFO_VERIFICATION_DONT_JIT: - { - ICorMethodInfo::initConstraintsForVerification(&circularConstraints) - if (circularConstraints) - { - Just emit code to call CORINFO_HELP_VERIFICATION - The IL will not be compiled - } - else - { - Verify the method. - if (unverifiable code is detected) - { - Fail the jit - } - } - } - } - - case INSTVER_GENERIC_PASSED_VERIFICATION: - { - This cannot ever happen because the VM would pass in CORJIT_FLAG_SKIP_VERIFICATION. - } - - case INSTVER_GENERIC_FAILED_VERIFICATION: - - switch(canSkipMethodVerification()) - { - case CORINFO_VERIFICATION_CANNOT_SKIP: - { - This cannot be supported because the compiler does not know which branches should call CORINFO_HELP_VERIFICATION. - The CLR will throw a VerificationException instead of trying to compile this method - } - - case CORINFO_VERIFICATION_CAN_SKIP: - { - This cannot ever happen because the CLR would pass in CORJIT_FLAG_SKIP_VERIFICATION. - } - - case CORINFO_VERIFICATION_RUNTIME_CHECK: - { - No verification needs to be done. - In the prolog, emit code to call CORINFO_HELP_VERIFICATION_RUNTIME_CHECK - Compile the method, generating unverifiable code if necessary - } - case CORINFO_VERIFICATION_DONT_JIT: - { - Fail the jit - } - } - } -} - -*/ - -/*****************************************************************************/ -// These are flags passed to ICorJitInfo::allocMem -// to guide the memory allocation for the code, readonly data, and read-write data -enum CorJitAllocMemFlag -{ - CORJIT_ALLOCMEM_DEFAULT_CODE_ALIGN = 0x00000000, // The code will be use the normal alignment - CORJIT_ALLOCMEM_FLG_16BYTE_ALIGN = 0x00000001, // The code will be 16-byte aligned - CORJIT_ALLOCMEM_FLG_RODATA_16BYTE_ALIGN = 0x00000002, // The read-only data will be 16-byte aligned -}; - -inline CorJitAllocMemFlag operator |(CorJitAllocMemFlag a, CorJitAllocMemFlag b) -{ - return static_cast(static_cast(a) | static_cast(b)); -} - -enum CorJitFuncKind -{ - CORJIT_FUNC_ROOT, // The main/root function (always id==0) - CORJIT_FUNC_HANDLER, // a funclet associated with an EH handler (finally, fault, catch, filter handler) - CORJIT_FUNC_FILTER // a funclet associated with an EH filter -}; - -// We have a performance-investigation mode (defined by the FEATURE_USE_ASM_GC_WRITE_BARRIERS and -// FEATURE_COUNT_GC_WRITE_BARRIER preprocessor symbols) in which the JIT adds an argument of this -// enumeration to checked write barrier calls in order to classify them. -enum CheckedWriteBarrierKinds { - CWBKind_Unclassified, // Not one of the ones below. - CWBKind_RetBuf, // Store through a return buffer pointer argument. - CWBKind_ByRefArg, // Store through a by-ref argument (not an implicit return buffer). - CWBKind_OtherByRefLocal, // Store through a by-ref local variable. - CWBKind_AddrOfLocal, // Store through the address of a local (arguably a bug that this happens at all). -}; - -#include "corjithost.h" - -extern "C" void __stdcall jitStartup(ICorJitHost* host); - -class ICorJitCompiler; -class ICorJitInfo; -struct IEEMemoryManager; - -extern "C" ICorJitCompiler* __stdcall getJit(); - -// #EEToJitInterface -// ICorJitCompiler is the interface that the EE uses to get IL bytecode converted to native code. Note that -// to accomplish this the JIT has to call back to the EE to get symbolic information. The code:ICorJitInfo -// type passed as 'comp' to compileMethod is the mechanism to get this information. This is often the more -// interesting interface. -// -// -class ICorJitCompiler -{ -public: - // compileMethod is the main routine to ask the JIT Compiler to create native code for a method. The - // method to be compiled is passed in the 'info' parameter, and the code:ICorJitInfo is used to allow the - // JIT to resolve tokens, and make any other callbacks needed to create the code. nativeEntry, and - // nativeSizeOfCode are just for convenience because the JIT asks the EE for the memory to emit code into - // (see code:ICorJitInfo.allocMem), so really the EE already knows where the method starts and how big - // it is (in fact, it could be in more than one chunk). - // - // * In the 32 bit jit this is implemented by code:CILJit.compileMethod - // * For the 64 bit jit this is implemented by code:PreJit.compileMethod - // - // Note: Obfuscators that are hacking the JIT depend on this method having __stdcall calling convention - virtual CorJitResult __stdcall compileMethod ( - ICorJitInfo *comp, /* IN */ - struct CORINFO_METHOD_INFO *info, /* IN */ - unsigned /* code:CorJitFlag */ flags, /* IN */ - BYTE **nativeEntry, /* OUT */ - ULONG *nativeSizeOfCode /* OUT */ - ) = 0; - - // Some JIT compilers (most notably Phoenix), cache information about EE structures from one invocation - // of the compiler to the next. This can be a problem when appdomains are unloaded, as some of this - // cached information becomes stale. The code:ICorJitCompiler.isCacheCleanupRequired is called by the EE - // early first to see if jit needs these notifications, and if so, the EE will call ClearCache is called - // whenever the compiler should abandon its cache (eg on appdomain unload) - virtual void clearCache() = 0; - virtual BOOL isCacheCleanupRequired() = 0; - - // Do any appropriate work at process shutdown. Default impl is to do nothing. - virtual void ProcessShutdownWork(ICorStaticInfo* info) {}; - - // The EE asks the JIT for a "version identifier". This represents the version of the JIT/EE interface. - // If the JIT doesn't implement the same JIT/EE interface expected by the EE (because the JIT doesn't - // return the version identifier that the EE expects), then the EE fails to load the JIT. - // - virtual void getVersionIdentifier( - GUID* versionIdentifier /* OUT */ - ) = 0; - - // When the EE loads the System.Numerics.Vectors assembly, it asks the JIT what length (in bytes) of - // SIMD vector it supports as an intrinsic type. Zero means that the JIT does not support SIMD - // intrinsics, so the EE should use the default size (i.e. the size of the IL implementation). - virtual unsigned getMaxIntrinsicSIMDVectorLength(CORJIT_FLAGS cpuCompileFlags) { return 0; } - - // IL obfuscators sometimes interpose on the EE-JIT interface. This function allows the VM to - // tell the JIT to use a particular ICorJitCompiler to implement the methods of this interface, - // and not to implement those methods itself. The JIT must not return this method when getJit() - // is called. Instead, it must pass along all calls to this interface from within its own - // ICorJitCompiler implementation. If 'realJitCompiler' is nullptr, then the JIT should resume - // executing all the functions itself. - virtual void setRealJit(ICorJitCompiler* realJitCompiler) { } - -}; - -//------------------------------------------------------------------------------------------ -// #JitToEEInterface -// -// ICorJitInfo is the main interface that the JIT uses to call back to the EE and get information. It is -// the companion to code:ICorJitCompiler#EEToJitInterface. The concrete implementation of this in the -// runtime is the code:CEEJitInfo type. There is also a version of this for the NGEN case. -// -// See code:ICorMethodInfo#EEJitContractDetails for subtle conventions used by this interface. -// -// There is more information on the JIT in the book of the runtime entry -// http://devdiv/sites/CLR/Product%20Documentation/2.0/BookOfTheRuntime/JIT/JIT%20Design.doc -// -class ICorJitInfo : public ICorDynamicInfo -{ -public: - // return memory manager that the JIT can use to allocate a regular memory - virtual IEEMemoryManager* getMemoryManager() = 0; - - // get a block of memory for the code, readonly data, and read-write data - virtual void allocMem ( - ULONG hotCodeSize, /* IN */ - ULONG coldCodeSize, /* IN */ - ULONG roDataSize, /* IN */ - ULONG xcptnsCount, /* IN */ - CorJitAllocMemFlag flag, /* IN */ - void ** hotCodeBlock, /* OUT */ - void ** coldCodeBlock, /* OUT */ - void ** roDataBlock /* OUT */ - ) = 0; - - // Reserve memory for the method/funclet's unwind information. - // Note that this must be called before allocMem. It should be - // called once for the main method, once for every funclet, and - // once for every block of cold code for which allocUnwindInfo - // will be called. - // - // This is necessary because jitted code must allocate all the - // memory needed for the unwindInfo at the allocMem call. - // For prejitted code we split up the unwinding information into - // separate sections .rdata and .pdata. - // - virtual void reserveUnwindInfo ( - BOOL isFunclet, /* IN */ - BOOL isColdCode, /* IN */ - ULONG unwindSize /* IN */ - ) = 0; - - // Allocate and initialize the .rdata and .pdata for this method or - // funclet, and get the block of memory needed for the machine-specific - // unwind information (the info for crawling the stack frame). - // Note that allocMem must be called first. - // - // Parameters: - // - // pHotCode main method code buffer, always filled in - // pColdCode cold code buffer, only filled in if this is cold code, - // null otherwise - // startOffset start of code block, relative to appropriate code buffer - // (e.g. pColdCode if cold, pHotCode if hot). - // endOffset end of code block, relative to appropriate code buffer - // unwindSize size of unwind info pointed to by pUnwindBlock - // pUnwindBlock pointer to unwind info - // funcKind type of funclet (main method code, handler, filter) - // - virtual void allocUnwindInfo ( - BYTE * pHotCode, /* IN */ - BYTE * pColdCode, /* IN */ - ULONG startOffset, /* IN */ - ULONG endOffset, /* IN */ - ULONG unwindSize, /* IN */ - BYTE * pUnwindBlock, /* IN */ - CorJitFuncKind funcKind /* IN */ - ) = 0; - - // Get a block of memory needed for the code manager information, - // (the info for enumerating the GC pointers while crawling the - // stack frame). - // Note that allocMem must be called first - virtual void * allocGCInfo ( - size_t size /* IN */ - ) = 0; - - virtual void yieldExecution() = 0; - - // Indicate how many exception handler blocks are to be returned. - // This is guaranteed to be called before any 'setEHinfo' call. - // Note that allocMem must be called before this method can be called. - virtual void setEHcount ( - unsigned cEH /* IN */ - ) = 0; - - // Set the values for one particular exception handler block. - // - // Handler regions should be lexically contiguous. - // This is because FinallyIsUnwinding() uses lexicality to - // determine if a "finally" clause is executing. - virtual void setEHinfo ( - unsigned EHnumber, /* IN */ - const CORINFO_EH_CLAUSE *clause /* IN */ - ) = 0; - - // Level -> fatalError, Level 2 -> Error, Level 3 -> Warning - // Level 4 means happens 10 times in a run, level 5 means 100, level 6 means 1000 ... - // returns non-zero if the logging succeeded - virtual BOOL logMsg(unsigned level, const char* fmt, va_list args) = 0; - - // do an assert. will return true if the code should retry (DebugBreak) - // returns false, if the assert should be igored. - virtual int doAssert(const char* szFile, int iLine, const char* szExpr) = 0; - - virtual void reportFatalError(CorJitResult result) = 0; - - struct ProfileBuffer // Also defined here: code:CORBBTPROF_BLOCK_DATA - { - ULONG ILOffset; - ULONG ExecutionCount; - }; - - // allocate a basic block profile buffer where execution counts will be stored - // for jitted basic blocks. - virtual HRESULT allocBBProfileBuffer ( - ULONG count, // The number of basic blocks that we have - ProfileBuffer ** profileBuffer - ) = 0; - - // get profile information to be used for optimizing the current method. The format - // of the buffer is the same as the format the JIT passes to allocBBProfileBuffer. - virtual HRESULT getBBProfileData( - CORINFO_METHOD_HANDLE ftnHnd, - ULONG * count, // The number of basic blocks that we have - ProfileBuffer ** profileBuffer, - ULONG * numRuns - ) = 0; - - // Associates a native call site, identified by its offset in the native code stream, with - // the signature information and method handle the JIT used to lay out the call site. If - // the call site has no signature information (e.g. a helper call) or has no method handle - // (e.g. a CALLI P/Invoke), then null should be passed instead. - virtual void recordCallSite( - ULONG instrOffset, /* IN */ - CORINFO_SIG_INFO * callSig, /* IN */ - CORINFO_METHOD_HANDLE methodHandle /* IN */ - ) = 0; - - // A relocation is recorded if we are pre-jitting. - // A jump thunk may be inserted if we are jitting - virtual void recordRelocation( - void * location, /* IN */ - void * target, /* IN */ - WORD fRelocType, /* IN */ - WORD slotNum = 0, /* IN */ - INT32 addlDelta = 0 /* IN */ - ) = 0; - - virtual WORD getRelocTypeHint(void * target) = 0; - - // A callback to identify the range of address known to point to - // compiler-generated native entry points that call back into - // MSIL. - virtual void getModuleNativeEntryPointRange( - void ** pStart, /* OUT */ - void ** pEnd /* OUT */ - ) = 0; - - // For what machine does the VM expect the JIT to generate code? The VM - // returns one of the IMAGE_FILE_MACHINE_* values. Note that if the VM - // is cross-compiling (such as the case for crossgen), it will return a - // different value than if it was compiling for the host architecture. - // - virtual DWORD getExpectedTargetArchitecture() = 0; - - // Fetches extended flags for a particular compilation instance. Returns - // the number of bytes written to the provided buffer. - virtual DWORD getJitFlags( - CORJIT_FLAGS* flags, /* IN: Points to a buffer that will hold the extended flags. */ - DWORD sizeInBytes /* IN: The size of the buffer. Note that this is effectively a - version number for the CORJIT_FLAGS value. */ - ) = 0; -}; - -/**********************************************************************************/ -#endif // _COR_CORJIT_H_ diff --git a/src/inc/corjithost.h b/src/inc/corjithost.h deleted file mode 100644 index 8242fab2b..000000000 --- a/src/inc/corjithost.h +++ /dev/null @@ -1,48 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#ifndef __CORJITHOST_H__ -#define __CORJITHOST_H__ - -// ICorJitHost -// -// ICorJitHost provides the interface that the JIT uses to access some functionality that -// would normally be provided by the operating system. This is intended to allow for -// host-specific policies re: memory allocation, configuration value access, etc. It is -// expected that the `ICorJitHost` value provided to `jitStartup` lives at least as -// long as the JIT itself. -class ICorJitHost -{ -public: - // Allocate memory of the given size in bytes. All bytes of the returned block - // must be initialized to zero. If `usePageAllocator` is true, the implementation - // should use an allocator that deals in OS pages if one exists. - virtual void* allocateMemory(size_t size, bool usePageAllocator = false) = 0; - - // Frees memory previous obtained by a call to `ICorJitHost::allocateMemory`. The - // value of the `usePageAllocator` parameter must match the value that was - // provided to the call to used to allocate the memory. - virtual void freeMemory(void* block, bool usePageAllocator = false) = 0; - - // Return an integer config value for the given key, if any exists. - virtual int getIntConfigValue( - const wchar_t* name, - int defaultValue - ) = 0; - - // Return a string config value for the given key, if any exists. - virtual const wchar_t* getStringConfigValue( - const wchar_t* name - ) = 0; - - // Free a string ConfigValue returned by the runtime. - // JITs using the getStringConfigValue query are required - // to return the string values to the runtime for deletion. - // This avoids leaking the memory in the JIT. - virtual void freeStringConfigValue( - const wchar_t* value - ) = 0; -}; - -#endif diff --git a/src/inc/corpriv.h b/src/inc/corpriv.h deleted file mode 100644 index edd55e911..000000000 --- a/src/inc/corpriv.h +++ /dev/null @@ -1,540 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -// =========================================================================== -// File: CORPRIV.H -// -// =========================================================================== - -#ifndef _CORPRIV_H_ -#define _CORPRIV_H_ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 - -// %%Includes: --------------------------------------------------------------- -// avoid taking DLL import hit on intra-DLL calls -#define NODLLIMPORT -#include -#include "cor.h" -#include "corimage.h" -#include "metadata.h" -#include -#include "peinformation.h" -// - -interface IAssemblyName; - -// PE images loaded through the runtime. -typedef struct _dummyCOR { BYTE b; } *HCORMODULE; - -class UTSemReadWrite; - -// Helper function to get a pointer to the Dispenser interface. -STDAPI MetaDataGetDispenser( // Return HRESULT - REFCLSID rclsid, // The class to desired. - REFIID riid, // Interface wanted on class factory. - LPVOID FAR *ppv); // Return interface pointer here. - -// Helper function to check whether policy allows accessing the file -STDAPI RuntimeCheckLocationAccess(LPCWSTR wszLocation); -STDAPI RuntimeIsNativeImageOptedOut(IAssemblyName* pAssemblyDef); - -LocaleID RuntimeGetFileSystemLocale(); - -BOOL RuntimeFileNotFound(HRESULT hr); - -// Helper function to get an Internal interface with an in-memory metadata section -STDAPI GetMetaDataInternalInterface( - LPVOID pData, // [IN] in memory metadata section - ULONG cbData, // [IN] size of the metadata section - DWORD flags, // [IN] CorOpenFlags - REFIID riid, // [IN] desired interface - void **ppv); // [OUT] returned interface - -// Helper function to get an internal scopeless interface given a scope. -STDAPI GetMetaDataInternalInterfaceFromPublic( - IUnknown *pv, // [IN] Given interface - REFIID riid, // [IN] desired interface - void **ppv); // [OUT] returned interface - -// Helper function to get an internal scopeless interface given a scope. -STDAPI GetMetaDataPublicInterfaceFromInternal( - void *pv, // [IN] Given interface - REFIID riid, // [IN] desired interface - void **ppv); // [OUT] returned interface - -// Converts an internal MD import API into the read/write version of this API. -// This could support edit and continue, or modification of the metadata at -// runtime (say for profiling). -STDAPI ConvertMDInternalImport( // S_OK or error. - IMDInternalImport *pIMD, // [IN] The metadata to be updated. - IMDInternalImport **ppIMD); // [OUT] Put RW interface here. - -STDAPI GetAssemblyMDInternalImport( // Return code. - LPCWSTR szFileName, // [IN] The scope to open. - REFIID riid, // [IN] The interface desired. - IUnknown **ppIUnk); // [OUT] Return interface on success. - -HRESULT GetAssemblyMDInternalImportFromImage( - HCORMODULE hImage, //[IN] pointer to module handle to get the metadata from. - REFIID riid, //[IN] The interface desired. - IUnknown **ppIUnk); //[OUT] Return Interface on success. - -STDAPI GetAssemblyMDInternalImportByStream( // Return code. - IStream *pIStream, // [IN] The IStream for the file - UINT64 AssemblyId, // [IN] Unique Id for the assembly - REFIID riid, // [IN] The interface desired. - IUnknown **ppIUnk); // [OUT] Return interface on success. - - -enum MDInternalImportFlags -{ - MDInternalImport_Default = 0, - MDInternalImport_NoCache = 1, // Do not share/cached the results of opening the image -#ifdef FEATURE_PREJIT - MDInternalImport_TrustedNativeImage = 2, // The image is a native image, and so its format can be trusted - MDInternalImport_ILMetaData = 4, // Open the IL metadata, even if this is a native image - MDInternalImport_TrustedNativeImage_and_IL = MDInternalImport_TrustedNativeImage | MDInternalImport_ILMetaData, - MDInternalImport_NativeImageInstall = 0x100, // The image is a native image that is being installed into NIC -#endif - MDInternalImport_CheckLongPath =8, // also check long version of the path - MDInternalImport_CheckShortPath =0x10, // also check long version of the path - MDInternalImport_OnlyLookInCache =0x20, // Only look in the cache. (If the cache does not have the image already loaded, return NULL) -}; // enum MDInternalImportFlags - - - -STDAPI GetAssemblyMDInternalImportEx( // Return code. - LPCWSTR szFileName, // [IN] The scope to open. - REFIID riid, // [IN] The interface desired. - MDInternalImportFlags flags, // [in] Flags to control opening the assembly - IUnknown **ppIUnk, // [OUT] Return interface on success. - HANDLE hFile = INVALID_HANDLE_VALUE); - -STDAPI GetAssemblyMDInternalImportByStreamEx( // Return code. - IStream *pIStream, // [IN] The IStream for the file - UINT64 AssemblyId, // [IN] Unique Id for the assembly - REFIID riid, // [IN] The interface desired. - MDInternalImportFlags flags, // [in] Flags to control opening the assembly - IUnknown **ppIUnk); // [OUT] Return interface on success. - - -// Returns part of the "Zap string" which describes the properties of a native image - -__success(SUCCEEDED(return)) -STDAPI GetNativeImageDescription( - __in_z LPCWSTR wzCustomString, // [IN] Custom string of the native image - DWORD dwConfigMask, // [IN] Config mask of the native image - __out_ecount_part_opt(*pdwLength,*pdwLength) LPWSTR pwzZapInfo,// [OUT] The description string. Can be NULL to find the size of buffer to allocate - LPDWORD pdwLength); // [IN/OUT] Length of the pwzZapInfo buffer on IN. - // Number of WCHARs (including termintating NULL) on OUT - - -class CQuickBytes; - - -// predefined constant for parent token for global functions -#define COR_GLOBAL_PARENT_TOKEN TokenFromRid(1, mdtTypeDef) - - - -////////////////////////////////////////////////////////////////////////// -// -////////////////////////////////////////////////////////////////////////// - -// %%Interfaces: ------------------------------------------------------------- - -// interface IMetaDataHelper - -// {AD93D71D-E1F2-11d1-9409-0000F8083460} -EXTERN_GUID(IID_IMetaDataHelper, 0xad93d71d, 0xe1f2, 0x11d1, 0x94, 0x9, 0x0, 0x0, 0xf8, 0x8, 0x34, 0x60); - -#undef INTERFACE -#define INTERFACE IMetaDataHelper -DECLARE_INTERFACE_(IMetaDataHelper, IUnknown) -{ - // helper functions - // This function is exposing the ability to translate signature from a given - // source scope to a given target scope. - // - STDMETHOD(TranslateSigWithScope)( - IMetaDataAssemblyImport *pAssemImport, // [IN] importing assembly interface - const void *pbHashValue, // [IN] Hash Blob for Assembly. - ULONG cbHashValue, // [IN] Count of bytes. - IMetaDataImport *import, // [IN] importing interface - PCCOR_SIGNATURE pbSigBlob, // [IN] signature in the importing scope - ULONG cbSigBlob, // [IN] count of bytes of signature - IMetaDataAssemblyEmit *pAssemEmit, // [IN] emit assembly interface - IMetaDataEmit *emit, // [IN] emit interface - PCOR_SIGNATURE pvTranslatedSig, // [OUT] buffer to hold translated signature - ULONG cbTranslatedSigMax, - ULONG *pcbTranslatedSig) PURE;// [OUT] count of bytes in the translated signature - - STDMETHOD(GetMetadata)( - ULONG ulSelect, // [IN] Selector. - void **ppData) PURE; // [OUT] Put pointer to data here. - - STDMETHOD_(IUnknown *, GetCachedInternalInterface)(BOOL fWithLock) PURE; // S_OK or error - STDMETHOD(SetCachedInternalInterface)(IUnknown * pUnk) PURE; // S_OK or error - STDMETHOD_(UTSemReadWrite*, GetReaderWriterLock)() PURE; // return the reader writer lock - STDMETHOD(SetReaderWriterLock)(UTSemReadWrite * pSem) PURE; -}; // IMetaDataHelper - - -EXTERN_GUID(IID_IMetaDataEmitHelper, 0x5c240ae4, 0x1e09, 0x11d3, 0x94, 0x24, 0x0, 0x0, 0xf8, 0x8, 0x34, 0x60); - -#undef INTERFACE -#define INTERFACE IMetaDataEmitHelper -DECLARE_INTERFACE_(IMetaDataEmitHelper, IUnknown) -{ - // emit helper functions - STDMETHOD(DefineMethodSemanticsHelper)( - mdToken tkAssociation, // [IN] property or event token - DWORD dwFlags, // [IN] semantics - mdMethodDef md) PURE; // [IN] method to associated with - - STDMETHOD(SetFieldLayoutHelper)( // Return hresult. - mdFieldDef fd, // [IN] field to associate the layout info - ULONG ulOffset) PURE; // [IN] the offset for the field - - STDMETHOD(DefineEventHelper) ( - mdTypeDef td, // [IN] the class/interface on which the event is being defined - LPCWSTR szEvent, // [IN] Name of the event - DWORD dwEventFlags, // [IN] CorEventAttr - mdToken tkEventType, // [IN] a reference (mdTypeRef or mdTypeRef) to the Event class - mdEvent *pmdEvent) PURE; // [OUT] output event token - - STDMETHOD(AddDeclarativeSecurityHelper) ( - mdToken tk, // [IN] Parent token (typedef/methoddef) - DWORD dwAction, // [IN] Security action (CorDeclSecurity) - void const *pValue, // [IN] Permission set blob - DWORD cbValue, // [IN] Byte count of permission set blob - mdPermission*pmdPermission) PURE; // [OUT] Output permission token - - STDMETHOD(SetResolutionScopeHelper)( // Return hresult. - mdTypeRef tr, // [IN] TypeRef record to update - mdToken rs) PURE; // [IN] new ResolutionScope - - STDMETHOD(SetManifestResourceOffsetHelper)( // Return hresult. - mdManifestResource mr, // [IN] The manifest token - ULONG ulOffset) PURE; // [IN] new offset - - STDMETHOD(SetTypeParent)( // Return hresult. - mdTypeDef td, // [IN] Type definition - mdToken tkExtends) PURE; // [IN] parent type - - STDMETHOD(AddInterfaceImpl)( // Return hresult. - mdTypeDef td, // [IN] Type definition - mdToken tkInterface) PURE; // [IN] interface type - -}; // IMetaDataEmitHelper - -////////////////////////////////////////////////////////////////////////////// -// enum CorElementTypeZapSig defines some additional internal ELEMENT_TYPE's -// values that are only used by ZapSig signatures. -////////////////////////////////////////////////////////////////////////////// -typedef enum CorElementTypeZapSig -{ - // ZapSig encoding for ELEMENT_TYPE_VAR and ELEMENT_TYPE_MVAR. It is always followed - // by the RID of a GenericParam token, encoded as a compressed integer. - ELEMENT_TYPE_VAR_ZAPSIG = 0x3b, - - // ZapSig encoding for an array MethodTable to allow it to remain such after decoding - // (rather than being transformed into the TypeHandle representing that array) - // - // The element is always followed by ELEMENT_TYPE_SZARRAY or ELEMENT_TYPE_ARRAY - ELEMENT_TYPE_NATIVE_ARRAY_TEMPLATE_ZAPSIG = 0x3c, - - // ZapSig encoding for native value types in IL stubs. IL stub signatures may contain - // ELEMENT_TYPE_INTERNAL followed by ParamTypeDesc with ELEMENT_TYPE_VALUETYPE element - // type. It acts like a modifier to the underlying structure making it look like its - // unmanaged view (size determined by unmanaged layout, blittable, no GC pointers). - // - // ELEMENT_TYPE_NATIVE_VALUETYPE_ZAPSIG is used when encoding such types to NGEN images. - // The signature looks like this: ET_NATIVE_VALUETYPE_ZAPSIG ET_VALUETYPE . - // See code:ZapSig.GetSignatureForTypeHandle and code:SigPointer.GetTypeHandleThrowing - // where the encoding/decoding takes place. - ELEMENT_TYPE_NATIVE_VALUETYPE_ZAPSIG = 0x3d, - - ELEMENT_TYPE_CANON_ZAPSIG = 0x3e, // zapsig encoding for [mscorlib]System.__Canon - ELEMENT_TYPE_MODULE_ZAPSIG = 0x3f, // zapsig encoding for external module id# - -} CorElementTypeZapSig; - -typedef enum CorCallingConventionInternal -{ - // IL stub signatures containing types that need to be restored have the highest - // bit of the calling convention set. - IMAGE_CEE_CS_CALLCONV_NEEDSRESTORE = 0x80, - -} CorCallingConventionInternal; - -////////////////////////////////////////////////////////////////////////// -// Obsoleted ELEMENT_TYPE values which are not supported anymore. -// They are not part of CLI ECMA spec, they were only experimental before v1.0 RTM. -// They are needed for indexing arrays initialized using file:corTypeInfo.h -// 0x17 ... VALUEARRAY -// 0x1a ... CPU native floating-point type -////////////////////////////////////////////////////////////////////////// -#define ELEMENT_TYPE_VALUEARRAY_UNSUPPORTED ((CorElementType) 0x17) -#define ELEMENT_TYPE_R_UNSUPPORTED ((CorElementType) 0x1a) - -// Use this guid in the SetOption if Reflection.Emit wants to control size of the initially allocated -// MetaData. See values: code:CorMetaDataInitialSize. -// -// {2675b6bf-f504-4cb4-a4d5-084eea770ddc} -EXTERN_GUID(MetaDataInitialSize, 0x2675b6bf, 0xf504, 0x4cb4, 0xa4, 0xd5, 0x08, 0x4e, 0xea, 0x77, 0x0d, 0xdc); - -// Allowed values for code:MetaDataInitialSize option. -typedef enum CorMetaDataInitialSize -{ - MDInitialSizeDefault = 0, - MDInitialSizeMinimal = 1 -} CorMetaDataInitialSize; - -// Internal extension of open flags code:CorOpenFlags -typedef enum CorOpenFlagsInternal -{ -#ifdef FEATURE_METADATA_LOAD_TRUSTED_IMAGES - // Flag code:ofTrustedImage is used by mscordbi.dll, therefore defined in file:CorPriv.h - ofTrustedImage = ofReserved3 // We trust this PE file (we are willing to do a LoadLibrary on it). - // It is optional and only an (VM) optimization - typically for NGEN images - // opened by debugger. -#endif -} CorOpenFlagsInternal; - -#ifdef FEATURE_METADATA_LOAD_TRUSTED_IMAGES -#define IsOfTrustedImage(x) ((x) & ofTrustedImage) -#endif - -// %%Classes: ---------------------------------------------------------------- -#ifndef offsetof -#define offsetof(s,f) ((ULONG)(&((s*)0)->f)) -#endif -#ifndef lengthof -#define lengthof(rg) (sizeof(rg)/sizeof(rg[0])) -#endif - -#define COR_MODULE_CLASS "" -#define COR_WMODULE_CLASS W("") - -STDAPI RuntimeOpenImage(LPCWSTR pszFileName, HCORMODULE* hHandle); -STDAPI RuntimeOpenImageInternal(LPCWSTR pszFileName, HCORMODULE* hHandle, - DWORD *pdwLength, MDInternalImportFlags flags, HANDLE hFile = INVALID_HANDLE_VALUE); -STDAPI RuntimeOpenImageByStream(IStream* pIStream, UINT64 AssemblyId, DWORD dwModuleId, - HCORMODULE* hHandle, DWORD *pdwLength, MDInternalImportFlags flags); - -void RuntimeAddRefHandle(HCORMODULE hHandle); -STDAPI RuntimeReleaseHandle(HCORMODULE hHandle); -STDAPI RuntimeGetImageBase(HCORMODULE hHandle, LPVOID* base, BOOL bMapped, COUNT_T* dwSize); -STDAPI RuntimeGetImageKind(HCORMODULE hHandle, DWORD* pdwKind, DWORD* pdwMachine); -STDAPI RuntimeOSHandle(HCORMODULE hHandle, HMODULE* hModule); -STDAPI RuntimeGetAssemblyStrongNameHashForModule(HCORMODULE hModule, - IMetaDataImport *pMDimport, - BYTE *pbSNHash, - DWORD *pcbSNHash); -STDAPI RuntimeGetMDInternalImport(HCORMODULE hHandle, - MDInternalImportFlags flags, - IMDInternalImport** ppMDImport); - -FORCEINLINE -void ReleaseHCorModule(HCORMODULE hModule) -{ - HRESULT hr = RuntimeReleaseHandle(hModule); - _ASSERTE(SUCCEEDED(hr)); -} - -typedef Wrapper, ReleaseHCorModule, (UINT_PTR) NULL> HCORMODULEHolder; - - -// =========================================================================== -// ISNAssemblySignature (similar to IAssemblySignature in V1) -// -// This is a private interface that allows querying of the strong name -// signature. -// This can be used for (strong-named) assemblies added to the GAC as -// a unique identifier. -// - -// {848845BC-0C4A-42e3-8915-DC850112443D} -EXTERN_GUID(IID_ISNAssemblySignature, 0x848845BC, 0x0C4A, 0x42e3, 0x89, 0x15, 0xDC, 0x85, 0x01, 0x12, 0x44, 0x3D); - -#undef INTERFACE -#define INTERFACE ISNAssemblySignature -DECLARE_INTERFACE_(ISNAssemblySignature, IUnknown) -{ - // Returns the strong-name signature if the assembly is strong-name-signed - // Returns the MVID if the assembly is delay-signed. - // Fails if the assembly is not signed at all. - STDMETHOD(GetSNAssemblySignature) ( - BYTE *pbSig, // [IN, OUT] Buffer to write signature - DWORD *pcbSig // [IN, OUT] Size of buffer, bytes written - ) PURE; -}; - -//------------------------------------- -//--- ICeeGenInternal -//------------------------------------- -// {9fd3c7af-dc4e-4b9b-be22-9cf8cc577489} -EXTERN_GUID(IID_ICeeGenInternal, 0x9fd3c7af, 0xdc4e, 0x4b9b, 0xbe, 0x22, 0x9c, 0xf8, 0xcc, 0x57, 0x74, 0x89); - -#undef INTERFACE -#define INTERFACE ICeeGenInternal -DECLARE_INTERFACE_(ICeeGenInternal, IUnknown) -{ - STDMETHOD (SetInitialGrowth) (DWORD growth) PURE; -}; - -// =========================================================================== -#ifdef FEATURE_PREJIT -// =========================================================================== - - -// Use the default JIT compiler -#define DEFAULT_NGEN_COMPILER_DLL_NAME W("clrjit.dll") - - -struct CORCOMPILE_ASSEMBLY_SIGNATURE; - -// -// IGetIMDInternalImport -// -// Private interface exposed by -// AssemblyMDInternalImport - gives us access to the internally stored IMDInternalImport*. -// -// RegMeta, WinMDImport - supports the internal GetMetaDataInternalInterfaceFromPublic() "api". -// -// {92B2FEF9-F7F5-420d-AD42-AECEEE10A1EF} -EXTERN_GUID(IID_IGetIMDInternalImport, 0x92b2fef9, 0xf7f5, 0x420d, 0xad, 0x42, 0xae, 0xce, 0xee, 0x10, 0xa1, 0xef); -#undef INTERFACE -#define INTERFACE IGetIMDInternalImport -DECLARE_INTERFACE_(IGetIMDInternalImport, IUnknown) -{ - STDMETHOD(GetIMDInternalImport) ( - IMDInternalImport ** ppIMDInternalImport // [OUT] Buffer to receive IMDInternalImport* - ) PURE; -}; - - - -#ifndef DACCESS_COMPILE - -/* --------------------------------------------------------------------------- * - * NGen logger - * --------------------------------------------------------------------------- */ - #include "mscorsvc.h" - -struct ICorSvcLogger; -class SvcLogger -{ -public: - - SvcLogger(); - ~SvcLogger(); - void ReleaseLogger(); - void SetSvcLogger(ICorSvcLogger *pCorSvcLoggerArg); - BOOL HasSvcLogger(); - ICorSvcLogger* GetSvcLogger(); - void Printf(const CHAR *format, ...); - void SvcPrintf(const CHAR *format, ...); - void Printf(const WCHAR *format, ...); - void Printf(CorSvcLogLevel logLevel, const WCHAR *format, ...); - void SvcPrintf(const WCHAR *format, ...); - void Log(const WCHAR *message, CorSvcLogLevel logLevel = LogLevel_Warning); - //Need to add this to allocate StackSString, as we don't want static class - -private: - - void LogHelper(SString s, CorSvcLogLevel logLevel = LogLevel_Success); - //instantiations that need VM services like contracts in dllmain. - void CheckInit(); - - StackSString* pss; - ICorSvcLogger *pCorSvcLogger; -}; // class SvcLogger - -SvcLogger *GetSvcLogger(); -BOOL HasSvcLogger(); -#endif // #ifndef DACCESS_COMPILE - -// =========================================================================== -#endif // #ifdef FEATURE_PREJIT -// =========================================================================== - -struct CORCOMPILE_ASSEMBLY_SIGNATURE; -struct CORCOMPILE_VERSION_INFO; -struct CORCOMPILE_DEPENDENCY; -typedef GUID CORCOMPILE_NGEN_SIGNATURE; - - -//********************************************************************** -// Internal versions of shim functions for use by the CLR. - -STDAPI GetCORSystemDirectoryInternaL( - SString& pBuffer - ); - -//LONGPATH:TODO: Remove this once Desktop usage has been removed -STDAPI GetCORSystemDirectoryInternal( - __out_ecount_part_opt(cchBuffer, *pdwLength) LPWSTR pBuffer, - DWORD cchBuffer, - __out_opt DWORD* pdwLength - ); - -STDAPI GetCORVersionInternal( - __out_ecount_z_opt(cchBuffer) LPWSTR pBuffer, - DWORD cchBuffer, - __out DWORD *pdwLength); - - -#ifdef FEATURE_PREJIT - -//********************************************************************** -// Access to native image validation logic in the runtime. -// -// An interface only a mother could live as this logic should really be encapsulated in -// the native binder. But for historical reasons, it lives in the VM directory -// and is shared by the desktop and coreclr's which have separate native binders. -// Hence, this interface inherits a lot of "baggage." - - - -// A small shim around PEAssemblies/IBindResult that allow us to write Fusion/CLR-agnostic code -// for logging native bind failures to the Fusion log/CLR log. -// -// These objects are stack-based and non-thread-safe. They are created for the duration of a single RuntimeVerify call. -// The methods are expected to compute their data lazily as they are only used in bind failures or in checked builds. -// -// This class also exposes the IFusionBindLog pointer. This isn't really the appropriate place to expose that but -// it serves to avoid compiling references to IFUsionBindLog into code that doesn't define FEATURE_FUSION. -class LoggableAssembly -{ - public: - virtual SString DisplayString() = 0; // Returns an unspecified representation suitable for injecting into log messages. -}; - - -// Validates that an NI matches the running CLR, OS, CPU, etc. -BOOL RuntimeVerifyNativeImageVersion(const CORCOMPILE_VERSION_INFO *pVerInfo, LoggableAssembly *pLogAsm); - -// Validates that an NI matches the required flavor (debug, instrumented, etc.) -BOOL RuntimeVerifyNativeImageFlavor(const CORCOMPILE_VERSION_INFO *pVerInfo, LoggableAssembly *pLogAsm); - -// Validates that a hard-dep matches the a parent NI's compile-time hard-dep. -BOOL RuntimeVerifyNativeImageDependency(const CORCOMPILE_NGEN_SIGNATURE &ngenSigExpected, - const CORCOMPILE_VERSION_INFO *pActual, - LoggableAssembly *pLogAsm); - -BOOL RuntimeVerifyNativeImageDependency(const CORCOMPILE_DEPENDENCY *pExpected, - const CORCOMPILE_VERSION_INFO *pActual, - LoggableAssembly *pLogAsm); - -#endif // FEATURE_PREJIT - - - - -#endif // _CORPRIV_H_ -// EOF ======================================================================= - diff --git a/src/inc/cortpoolhdr.h b/src/inc/cortpoolhdr.h deleted file mode 100644 index 1db08b121..000000000 --- a/src/inc/cortpoolhdr.h +++ /dev/null @@ -1,50 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -//+------------------------------------------------------------------------ -// -// Declare DLL entry points for Cor API to threadpool -// -//------------------------------------------------------------------------- - -#ifdef EXPORTING_THREADPOOL_API -#define DllExportOrImport extern "C" __declspec (dllexport) -#else -#define DllExportOrImport extern "C" -#endif - -typedef VOID (__stdcall *WAITORTIMERCALLBACK)(PVOID, BOOL); - -DllExportOrImport BOOL __cdecl CorRegisterWaitForSingleObject(PHANDLE phNewWaitObject, - HANDLE hWaitObject, - WAITORTIMERCALLBACK Callback, - PVOID Context, - ULONG timeout, - BOOL executeOnlyOnce ); - - - -DllExportOrImport BOOL __cdecl CorUnregisterWait(HANDLE hWaitObject,HANDLE CompletionEvent); - -DllExportOrImport BOOL __cdecl CorQueueUserWorkItem(LPTHREAD_START_ROUTINE Function, - PVOID Context, - BOOL executeOnlyOnce ); - - -DllExportOrImport BOOL __cdecl CorCreateTimer(PHANDLE phNewTimer, - WAITORTIMERCALLBACK Callback, - PVOID Parameter, - DWORD DueTime, - DWORD Period); - -DllExportOrImport BOOL __cdecl CorChangeTimer(HANDLE Timer, - ULONG DueTime, - ULONG Period); - -DllExportOrImport BOOL __cdecl CorDeleteTimer(HANDLE Timer, - HANDLE CompletionEvent); - -DllExportOrImport VOID __cdecl CorBindIoCompletionCallback(HANDLE fileHandle, LPOVERLAPPED_COMPLETION_ROUTINE callback); - - -DllExportOrImport VOID __cdecl CorDoDelegateInvocation(int cookie); diff --git a/src/inc/crsttypes.h b/src/inc/crsttypes.h deleted file mode 100644 index 4e2e5b19a..000000000 --- a/src/inc/crsttypes.h +++ /dev/null @@ -1,570 +0,0 @@ -// -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -// - -#ifndef __CRST_TYPES_INCLUDED -#define __CRST_TYPES_INCLUDED - -// **** THIS IS AN AUTOMATICALLY GENERATED HEADER FILE -- DO NOT EDIT!!! **** - -// This file describes the range of Crst types available and their mapping to a numeric level (used by the -// runtime in debug mode to validate we're deadlock free). To modify these settings edit the -// file:CrstTypes.def file and run the clr\bin\CrstTypeTool utility to generate a new version of this file. - -// Each Crst type is declared as a value in the following CrstType enum. -enum CrstType -{ - CrstAllowedFiles = 0, - CrstAppDomainCache = 1, - CrstAppDomainHandleTable = 2, - CrstArgBasedStubCache = 3, - CrstAssemblyDependencyGraph = 4, - CrstAssemblyIdentityCache = 5, - CrstAssemblyList = 6, - CrstAssemblyLoader = 7, - CrstAvailableClass = 8, - CrstAvailableParamTypes = 9, - CrstBaseDomain = 10, - CrstCCompRC = 11, - CrstCer = 12, - CrstClassFactInfoHash = 13, - CrstClassInit = 14, - CrstClrNotification = 15, - CrstCLRPrivBinderMaps = 16, - CrstCLRPrivBinderMapsAdd = 17, - CrstCodeFragmentHeap = 18, - CrstCOMWrapperCache = 19, - CrstConnectionNameTable = 20, - CrstContexts = 21, - CrstCoreCLRBinderLog = 22, - CrstCrstCLRPrivBinderLocalWinMDPath = 23, - CrstCSPCache = 24, - CrstDataTest1 = 25, - CrstDataTest2 = 26, - CrstDbgTransport = 27, - CrstDeadlockDetection = 28, - CrstDebuggerController = 29, - CrstDebuggerFavorLock = 30, - CrstDebuggerHeapExecMemLock = 31, - CrstDebuggerHeapLock = 32, - CrstDebuggerJitInfo = 33, - CrstDebuggerMutex = 34, - CrstDelegateToFPtrHash = 35, - CrstDomainLocalBlock = 36, - CrstDynamicIL = 37, - CrstDynamicMT = 38, - CrstDynLinkZapItems = 39, - CrstEtwTypeLogHash = 40, - CrstEventPipe = 41, - CrstEventStore = 42, - CrstException = 43, - CrstExecuteManLock = 44, - CrstExecuteManRangeLock = 45, - CrstFCall = 46, - CrstFriendAccessCache = 47, - CrstFuncPtrStubs = 48, - CrstFusionAppCtx = 49, - CrstFusionAssemblyDownload = 50, - CrstFusionBindContext = 51, - CrstFusionBindResult = 52, - CrstFusionClb = 53, - CrstFusionClosure = 54, - CrstFusionClosureGraph = 55, - CrstFusionConfigSettings = 56, - CrstFusionDownload = 57, - CrstFusionIsoLibInit = 58, - CrstFusionLoadContext = 59, - CrstFusionLog = 60, - CrstFusionNgenIndex = 61, - CrstFusionNgenIndexPool = 62, - CrstFusionPcyCache = 63, - CrstFusionPolicyConfigPool = 64, - CrstFusionSingleUse = 65, - CrstFusionWarningLog = 66, - CrstGCCover = 67, - CrstGCMemoryPressure = 68, - CrstGlobalStrLiteralMap = 69, - CrstHandleTable = 70, - CrstHostAssemblyMap = 71, - CrstHostAssemblyMapAdd = 72, - CrstIbcProfile = 73, - CrstIJWFixupData = 74, - CrstIJWHash = 75, - CrstILFingerprintCache = 76, - CrstILStubGen = 77, - CrstInlineTrackingMap = 78, - CrstInstMethodHashTable = 79, - CrstInterfaceVTableMap = 80, - CrstInterop = 81, - CrstInteropData = 82, - CrstIOThreadpoolWorker = 83, - CrstIsJMCMethod = 84, - CrstISymUnmanagedReader = 85, - CrstJit = 86, - CrstJitGenericHandleCache = 87, - CrstJitPerf = 88, - CrstJumpStubCache = 89, - CrstLeafLock = 90, - CrstListLock = 91, - CrstLoaderAllocator = 92, - CrstLoaderAllocatorReferences = 93, - CrstLoaderHeap = 94, - CrstMda = 95, - CrstMetadataTracker = 96, - CrstModIntPairList = 97, - CrstModule = 98, - CrstModuleFixup = 99, - CrstModuleLookupTable = 100, - CrstMulticoreJitHash = 101, - CrstMulticoreJitManager = 102, - CrstMUThunkHash = 103, - CrstNativeBinderInit = 104, - CrstNativeImageCache = 105, - CrstNls = 106, - CrstNotifyGdb = 107, - CrstObjectList = 108, - CrstOnEventManager = 109, - CrstPatchEntryPoint = 110, - CrstPEFileSecurityManager = 111, - CrstPEImage = 112, - CrstPEImagePDBStream = 113, - CrstPendingTypeLoadEntry = 114, - CrstPinHandle = 115, - CrstPinnedByrefValidation = 116, - CrstProfilerGCRefDataFreeList = 117, - CrstProfilingAPIStatus = 118, - CrstPublisherCertificate = 119, - CrstRCWCache = 120, - CrstRCWCleanupList = 121, - CrstRCWRefCache = 122, - CrstReadyToRunEntryPointToMethodDescMap = 123, - CrstReDacl = 124, - CrstReflection = 125, - CrstReJITDomainTable = 126, - CrstReJITGlobalRequest = 127, - CrstReJITSharedDomainTable = 128, - CrstRemoting = 129, - CrstRetThunkCache = 130, - CrstRWLock = 131, - CrstSavedExceptionInfo = 132, - CrstSaveModuleProfileData = 133, - CrstSecurityPolicyCache = 134, - CrstSecurityPolicyInit = 135, - CrstSecurityStackwalkCache = 136, - CrstSharedAssemblyCreate = 137, - CrstSharedBaseDomain = 138, - CrstSigConvert = 139, - CrstSingleUseLock = 140, - CrstSpecialStatics = 141, - CrstSqmManager = 142, - CrstStackSampler = 143, - CrstStressLog = 144, - CrstStrongName = 145, - CrstStubCache = 146, - CrstStubDispatchCache = 147, - CrstStubUnwindInfoHeapSegments = 148, - CrstSyncBlockCache = 149, - CrstSyncHashLock = 150, - CrstSystemBaseDomain = 151, - CrstSystemDomain = 152, - CrstSystemDomainDelayedUnloadList = 153, - CrstThreadIdDispenser = 154, - CrstThreadpoolEventCache = 155, - CrstThreadpoolTimerQueue = 156, - CrstThreadpoolWaitThreads = 157, - CrstThreadpoolWorker = 158, - CrstThreadStaticDataHashTable = 159, - CrstThreadStore = 160, - CrstTPMethodTable = 161, - CrstTypeEquivalenceMap = 162, - CrstTypeIDMap = 163, - CrstUMEntryThunkCache = 164, - CrstUMThunkHash = 165, - CrstUniqueStack = 166, - CrstUnresolvedClassLock = 167, - CrstUnwindInfoTableLock = 168, - CrstVSDIndirectionCellLock = 169, - CrstWinRTFactoryCache = 170, - CrstWrapperTemplate = 171, - kNumberOfCrstTypes = 172 -}; - -#endif // __CRST_TYPES_INCLUDED - -// Define some debug data in one module only -- vm\crst.cpp. -#if defined(__IN_CRST_CPP) && defined(_DEBUG) - -// An array mapping CrstType to level. -int g_rgCrstLevelMap[] = -{ - 9, // CrstAllowedFiles - 9, // CrstAppDomainCache - 13, // CrstAppDomainHandleTable - 0, // CrstArgBasedStubCache - 0, // CrstAssemblyDependencyGraph - 0, // CrstAssemblyIdentityCache - 0, // CrstAssemblyList - 7, // CrstAssemblyLoader - 3, // CrstAvailableClass - 6, // CrstAvailableParamTypes - 7, // CrstBaseDomain - -1, // CrstCCompRC - 9, // CrstCer - 11, // CrstClassFactInfoHash - 8, // CrstClassInit - -1, // CrstClrNotification - 0, // CrstCLRPrivBinderMaps - 3, // CrstCLRPrivBinderMapsAdd - 6, // CrstCodeFragmentHeap - 4, // CrstCOMWrapperCache - 0, // CrstConnectionNameTable - 17, // CrstContexts - -1, // CrstCoreCLRBinderLog - 0, // CrstCrstCLRPrivBinderLocalWinMDPath - 7, // CrstCSPCache - 3, // CrstDataTest1 - 0, // CrstDataTest2 - 0, // CrstDbgTransport - 0, // CrstDeadlockDetection - -1, // CrstDebuggerController - 3, // CrstDebuggerFavorLock - 0, // CrstDebuggerHeapExecMemLock - 0, // CrstDebuggerHeapLock - 4, // CrstDebuggerJitInfo - 11, // CrstDebuggerMutex - 0, // CrstDelegateToFPtrHash - 15, // CrstDomainLocalBlock - 0, // CrstDynamicIL - 3, // CrstDynamicMT - 3, // CrstDynLinkZapItems - 7, // CrstEtwTypeLogHash - 17, // CrstEventPipe - 0, // CrstEventStore - 0, // CrstException - 7, // CrstExecuteManLock - 0, // CrstExecuteManRangeLock - 3, // CrstFCall - 7, // CrstFriendAccessCache - 7, // CrstFuncPtrStubs - 9, // CrstFusionAppCtx - 7, // CrstFusionAssemblyDownload - 5, // CrstFusionBindContext - 0, // CrstFusionBindResult - 0, // CrstFusionClb - 16, // CrstFusionClosure - 10, // CrstFusionClosureGraph - 0, // CrstFusionConfigSettings - 0, // CrstFusionDownload - 0, // CrstFusionIsoLibInit - 5, // CrstFusionLoadContext - 4, // CrstFusionLog - 7, // CrstFusionNgenIndex - 7, // CrstFusionNgenIndexPool - 0, // CrstFusionPcyCache - 4, // CrstFusionPolicyConfigPool - 5, // CrstFusionSingleUse - 6, // CrstFusionWarningLog - 3, // CrstGCCover - 0, // CrstGCMemoryPressure - 11, // CrstGlobalStrLiteralMap - 1, // CrstHandleTable - 0, // CrstHostAssemblyMap - 3, // CrstHostAssemblyMapAdd - 0, // CrstIbcProfile - 9, // CrstIJWFixupData - 0, // CrstIJWHash - 5, // CrstILFingerprintCache - 7, // CrstILStubGen - 3, // CrstInlineTrackingMap - 16, // CrstInstMethodHashTable - 0, // CrstInterfaceVTableMap - 17, // CrstInterop - 4, // CrstInteropData - 11, // CrstIOThreadpoolWorker - 0, // CrstIsJMCMethod - 7, // CrstISymUnmanagedReader - 8, // CrstJit - 0, // CrstJitGenericHandleCache - -1, // CrstJitPerf - 6, // CrstJumpStubCache - 0, // CrstLeafLock - -1, // CrstListLock - 14, // CrstLoaderAllocator - 15, // CrstLoaderAllocatorReferences - 0, // CrstLoaderHeap - 0, // CrstMda - -1, // CrstMetadataTracker - 0, // CrstModIntPairList - 4, // CrstModule - 14, // CrstModuleFixup - 3, // CrstModuleLookupTable - 0, // CrstMulticoreJitHash - 11, // CrstMulticoreJitManager - 0, // CrstMUThunkHash - -1, // CrstNativeBinderInit - -1, // CrstNativeImageCache - 0, // CrstNls - 0, // CrstNotifyGdb - 2, // CrstObjectList - 0, // CrstOnEventManager - 0, // CrstPatchEntryPoint - 0, // CrstPEFileSecurityManager - 4, // CrstPEImage - 0, // CrstPEImagePDBStream - 18, // CrstPendingTypeLoadEntry - 0, // CrstPinHandle - 0, // CrstPinnedByrefValidation - 0, // CrstProfilerGCRefDataFreeList - 0, // CrstProfilingAPIStatus - 0, // CrstPublisherCertificate - 3, // CrstRCWCache - 0, // CrstRCWCleanupList - 3, // CrstRCWRefCache - 3, // CrstReadyToRunEntryPointToMethodDescMap - 0, // CrstReDacl - 9, // CrstReflection - 7, // CrstReJITDomainTable - 13, // CrstReJITGlobalRequest - 9, // CrstReJITSharedDomainTable - 19, // CrstRemoting - 3, // CrstRetThunkCache - 0, // CrstRWLock - 3, // CrstSavedExceptionInfo - 0, // CrstSaveModuleProfileData - 0, // CrstSecurityPolicyCache - 3, // CrstSecurityPolicyInit - 0, // CrstSecurityStackwalkCache - 4, // CrstSharedAssemblyCreate - 7, // CrstSharedBaseDomain - 3, // CrstSigConvert - 5, // CrstSingleUseLock - 0, // CrstSpecialStatics - 0, // CrstSqmManager - 0, // CrstStackSampler - -1, // CrstStressLog - 0, // CrstStrongName - 5, // CrstStubCache - 0, // CrstStubDispatchCache - 4, // CrstStubUnwindInfoHeapSegments - 3, // CrstSyncBlockCache - 0, // CrstSyncHashLock - 0, // CrstSystemBaseDomain - 12, // CrstSystemDomain - 0, // CrstSystemDomainDelayedUnloadList - 0, // CrstThreadIdDispenser - 0, // CrstThreadpoolEventCache - 7, // CrstThreadpoolTimerQueue - 7, // CrstThreadpoolWaitThreads - 11, // CrstThreadpoolWorker - 4, // CrstThreadStaticDataHashTable - 10, // CrstThreadStore - 9, // CrstTPMethodTable - 3, // CrstTypeEquivalenceMap - 7, // CrstTypeIDMap - 3, // CrstUMEntryThunkCache - 0, // CrstUMThunkHash - 3, // CrstUniqueStack - 7, // CrstUnresolvedClassLock - 3, // CrstUnwindInfoTableLock - 3, // CrstVSDIndirectionCellLock - 3, // CrstWinRTFactoryCache - 3, // CrstWrapperTemplate -}; - -// An array mapping CrstType to a stringized name. -LPCSTR g_rgCrstNameMap[] = -{ - "CrstAllowedFiles", - "CrstAppDomainCache", - "CrstAppDomainHandleTable", - "CrstArgBasedStubCache", - "CrstAssemblyDependencyGraph", - "CrstAssemblyIdentityCache", - "CrstAssemblyList", - "CrstAssemblyLoader", - "CrstAvailableClass", - "CrstAvailableParamTypes", - "CrstBaseDomain", - "CrstCCompRC", - "CrstCer", - "CrstClassFactInfoHash", - "CrstClassInit", - "CrstClrNotification", - "CrstCLRPrivBinderMaps", - "CrstCLRPrivBinderMapsAdd", - "CrstCodeFragmentHeap", - "CrstCOMWrapperCache", - "CrstConnectionNameTable", - "CrstContexts", - "CrstCoreCLRBinderLog", - "CrstCrstCLRPrivBinderLocalWinMDPath", - "CrstCSPCache", - "CrstDataTest1", - "CrstDataTest2", - "CrstDbgTransport", - "CrstDeadlockDetection", - "CrstDebuggerController", - "CrstDebuggerFavorLock", - "CrstDebuggerHeapExecMemLock", - "CrstDebuggerHeapLock", - "CrstDebuggerJitInfo", - "CrstDebuggerMutex", - "CrstDelegateToFPtrHash", - "CrstDomainLocalBlock", - "CrstDynamicIL", - "CrstDynamicMT", - "CrstDynLinkZapItems", - "CrstEtwTypeLogHash", - "CrstEventPipe", - "CrstEventStore", - "CrstException", - "CrstExecuteManLock", - "CrstExecuteManRangeLock", - "CrstFCall", - "CrstFriendAccessCache", - "CrstFuncPtrStubs", - "CrstFusionAppCtx", - "CrstFusionAssemblyDownload", - "CrstFusionBindContext", - "CrstFusionBindResult", - "CrstFusionClb", - "CrstFusionClosure", - "CrstFusionClosureGraph", - "CrstFusionConfigSettings", - "CrstFusionDownload", - "CrstFusionIsoLibInit", - "CrstFusionLoadContext", - "CrstFusionLog", - "CrstFusionNgenIndex", - "CrstFusionNgenIndexPool", - "CrstFusionPcyCache", - "CrstFusionPolicyConfigPool", - "CrstFusionSingleUse", - "CrstFusionWarningLog", - "CrstGCCover", - "CrstGCMemoryPressure", - "CrstGlobalStrLiteralMap", - "CrstHandleTable", - "CrstHostAssemblyMap", - "CrstHostAssemblyMapAdd", - "CrstIbcProfile", - "CrstIJWFixupData", - "CrstIJWHash", - "CrstILFingerprintCache", - "CrstILStubGen", - "CrstInlineTrackingMap", - "CrstInstMethodHashTable", - "CrstInterfaceVTableMap", - "CrstInterop", - "CrstInteropData", - "CrstIOThreadpoolWorker", - "CrstIsJMCMethod", - "CrstISymUnmanagedReader", - "CrstJit", - "CrstJitGenericHandleCache", - "CrstJitPerf", - "CrstJumpStubCache", - "CrstLeafLock", - "CrstListLock", - "CrstLoaderAllocator", - "CrstLoaderAllocatorReferences", - "CrstLoaderHeap", - "CrstMda", - "CrstMetadataTracker", - "CrstModIntPairList", - "CrstModule", - "CrstModuleFixup", - "CrstModuleLookupTable", - "CrstMulticoreJitHash", - "CrstMulticoreJitManager", - "CrstMUThunkHash", - "CrstNativeBinderInit", - "CrstNativeImageCache", - "CrstNls", - "CrstNotifyGdb", - "CrstObjectList", - "CrstOnEventManager", - "CrstPatchEntryPoint", - "CrstPEFileSecurityManager", - "CrstPEImage", - "CrstPEImagePDBStream", - "CrstPendingTypeLoadEntry", - "CrstPinHandle", - "CrstPinnedByrefValidation", - "CrstProfilerGCRefDataFreeList", - "CrstProfilingAPIStatus", - "CrstPublisherCertificate", - "CrstRCWCache", - "CrstRCWCleanupList", - "CrstRCWRefCache", - "CrstReadyToRunEntryPointToMethodDescMap", - "CrstReDacl", - "CrstReflection", - "CrstReJITDomainTable", - "CrstReJITGlobalRequest", - "CrstReJITSharedDomainTable", - "CrstRemoting", - "CrstRetThunkCache", - "CrstRWLock", - "CrstSavedExceptionInfo", - "CrstSaveModuleProfileData", - "CrstSecurityPolicyCache", - "CrstSecurityPolicyInit", - "CrstSecurityStackwalkCache", - "CrstSharedAssemblyCreate", - "CrstSharedBaseDomain", - "CrstSigConvert", - "CrstSingleUseLock", - "CrstSpecialStatics", - "CrstSqmManager", - "CrstStackSampler", - "CrstStressLog", - "CrstStrongName", - "CrstStubCache", - "CrstStubDispatchCache", - "CrstStubUnwindInfoHeapSegments", - "CrstSyncBlockCache", - "CrstSyncHashLock", - "CrstSystemBaseDomain", - "CrstSystemDomain", - "CrstSystemDomainDelayedUnloadList", - "CrstThreadIdDispenser", - "CrstThreadpoolEventCache", - "CrstThreadpoolTimerQueue", - "CrstThreadpoolWaitThreads", - "CrstThreadpoolWorker", - "CrstThreadStaticDataHashTable", - "CrstThreadStore", - "CrstTPMethodTable", - "CrstTypeEquivalenceMap", - "CrstTypeIDMap", - "CrstUMEntryThunkCache", - "CrstUMThunkHash", - "CrstUniqueStack", - "CrstUnresolvedClassLock", - "CrstUnwindInfoTableLock", - "CrstVSDIndirectionCellLock", - "CrstWinRTFactoryCache", - "CrstWrapperTemplate", -}; - -// Define a special level constant for unordered locks. -#define CRSTUNORDERED (-1) - -// Define inline helpers to map Crst types to names and levels. -inline static int GetCrstLevel(CrstType crstType) -{ - LIMITED_METHOD_CONTRACT; - _ASSERTE(crstType >= 0 && crstType < kNumberOfCrstTypes); - return g_rgCrstLevelMap[crstType]; -} -inline static LPCSTR GetCrstName(CrstType crstType) -{ - LIMITED_METHOD_CONTRACT; - _ASSERTE(crstType >= 0 && crstType < kNumberOfCrstTypes); - return g_rgCrstNameMap[crstType]; -} - -#endif // defined(__IN_CRST_CPP) && defined(_DEBUG) diff --git a/src/inc/crtwrap.h b/src/inc/crtwrap.h deleted file mode 100644 index 56f63cb42..000000000 --- a/src/inc/crtwrap.h +++ /dev/null @@ -1,30 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -//***************************************************************************** -// CrtWrap.h -// -// Wrapper code for the C runtime library. -// -//***************************************************************************** - -#ifndef __CrtWrap_h__ -#define __CrtWrap_h__ - -#include -#include -#include -#include -#include "debugmacros.h" -#include -#include -#include -#include - -#ifndef PUB -// PUB is defined to influence method visibility for some compilers. -#define PUB -#endif // !PUB - -#endif // __CrtWrap_h__ - diff --git a/src/inc/cvconst.h b/src/inc/cvconst.h deleted file mode 100644 index 98eb19e25..000000000 --- a/src/inc/cvconst.h +++ /dev/null @@ -1,3728 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -// cvconst.h - codeview constant definitions -//----------------------------------------------------------------- -// -// Copyright Microsoft Corporation. All Rights Reserved. -// -//--------------------------------------------------------------- -#ifndef _CVCONST_H_ -#define _CVCONST_H_ - - - -// Enumeration for function call type - - -typedef enum CV_call_e { - CV_CALL_NEAR_C = 0x00, // near right to left push, caller pops stack - CV_CALL_FAR_C = 0x01, // far right to left push, caller pops stack - CV_CALL_NEAR_PASCAL = 0x02, // near left to right push, callee pops stack - CV_CALL_FAR_PASCAL = 0x03, // far left to right push, callee pops stack - CV_CALL_NEAR_FAST = 0x04, // near left to right push with regs, callee pops stack - CV_CALL_FAR_FAST = 0x05, // far left to right push with regs, callee pops stack - CV_CALL_SKIPPED = 0x06, // skipped (unused) call index - CV_CALL_NEAR_STD = 0x07, // near standard call - CV_CALL_FAR_STD = 0x08, // far standard call - CV_CALL_NEAR_SYS = 0x09, // near sys call - CV_CALL_FAR_SYS = 0x0a, // far sys call - CV_CALL_THISCALL = 0x0b, // this call (this passed in register) - CV_CALL_MIPSCALL = 0x0c, // Mips call - CV_CALL_GENERIC = 0x0d, // Generic call sequence - CV_CALL_ALPHACALL = 0x0e, // Alpha call - CV_CALL_PPCCALL = 0x0f, // PPC call - CV_CALL_SHCALL = 0x10, // Hitachi SuperH call - CV_CALL_ARMCALL = 0x11, // ARM call - CV_CALL_AM33CALL = 0x12, // AM33 call - CV_CALL_TRICALL = 0x13, // TriCore Call - CV_CALL_SH5CALL = 0x14, // Hitachi SuperH-5 call - CV_CALL_M32RCALL = 0x15, // M32R Call - CV_CALL_CLRCALL = 0x16, // clr call - CV_CALL_INLINE = 0x17, // Marker for routines always inlined and thus lacking a convention - CV_CALL_NEAR_VECTOR = 0x18, // near left to right push with regs, callee pops stack - CV_CALL_RESERVED = 0x19 // first unused call enumeration - - // Do NOT add any more machine specific conventions. This is to be used for - // calling conventions in the source only (e.g. __cdecl, __stdcall). -} CV_call_e; - - -// Values for the access protection of class attributes - - -typedef enum CV_access_e { - CV_private = 1, - CV_protected = 2, - CV_public = 3 -} CV_access_e; - -typedef enum THUNK_ORDINAL { - THUNK_ORDINAL_NOTYPE, // standard thunk - THUNK_ORDINAL_ADJUSTOR, // "this" adjustor thunk - THUNK_ORDINAL_VCALL, // virtual call thunk - THUNK_ORDINAL_PCODE, // pcode thunk - THUNK_ORDINAL_LOAD, // thunk which loads the address to jump to - // via unknown means... - - // trampoline thunk ordinals - only for use in Trampoline thunk symbols - THUNK_ORDINAL_TRAMP_INCREMENTAL, - THUNK_ORDINAL_TRAMP_BRANCHISLAND, - -} THUNK_ORDINAL; - - -enum CV_SourceChksum_t { - CHKSUM_TYPE_NONE = 0, // indicates no checksum is available - CHKSUM_TYPE_MD5, - CHKSUM_TYPE_SHA1, - CHKSUM_TYPE_SHA_256, -}; - -// -// DIA enums -// - -enum SymTagEnum -{ - SymTagNull, - SymTagExe, - SymTagCompiland, - SymTagCompilandDetails, - SymTagCompilandEnv, - SymTagFunction, - SymTagBlock, - SymTagData, - SymTagAnnotation, - SymTagLabel, - SymTagPublicSymbol, - SymTagUDT, - SymTagEnum, - SymTagFunctionType, - SymTagPointerType, - SymTagArrayType, - SymTagBaseType, - SymTagTypedef, - SymTagBaseClass, - SymTagFriend, - SymTagFunctionArgType, - SymTagFuncDebugStart, - SymTagFuncDebugEnd, - SymTagUsingNamespace, - SymTagVTableShape, - SymTagVTable, - SymTagCustom, - SymTagThunk, - SymTagCustomType, - SymTagManagedType, - SymTagDimension, - SymTagCallSite, - SymTagInlineSite, - SymTagBaseInterface, - SymTagVectorType, - SymTagMatrixType, - SymTagHLSLType, - SymTagCaller, - SymTagCallee, - SymTagExport, - SymTagHeapAllocationSite, - SymTagCoffGroup, - SymTagMax -}; - -enum LocationType -{ - LocIsNull, - LocIsStatic, - LocIsTLS, - LocIsRegRel, - LocIsThisRel, - LocIsEnregistered, - LocIsBitField, - LocIsSlot, - LocIsIlRel, - LocInMetaData, - LocIsConstant, - LocTypeMax -}; - -enum DataKind -{ - DataIsUnknown, - DataIsLocal, - DataIsStaticLocal, - DataIsParam, - DataIsObjectPtr, - DataIsFileStatic, - DataIsGlobal, - DataIsMember, - DataIsStaticMember, - DataIsConstant -}; - -enum UdtKind -{ - UdtStruct, - UdtClass, - UdtUnion, - UdtInterface -}; - -enum BasicType -{ - btNoType = 0, - btVoid = 1, - btChar = 2, - btWChar = 3, - btInt = 6, - btUInt = 7, - btFloat = 8, - btBCD = 9, - btBool = 10, - btLong = 13, - btULong = 14, - btCurrency = 25, - btDate = 26, - btVariant = 27, - btComplex = 28, - btBit = 29, - btBSTR = 30, - btHresult = 31, - btChar16 = 32, // char16_t - btChar32 = 33, // char32_t -}; - - -// enumeration for type modifier values - -typedef enum CV_modifier_e { - // 0x0000 - 0x01ff - Reserved. - - CV_MOD_INVALID = 0x0000, - - // Standard modifiers. - - CV_MOD_CONST = 0x0001, - CV_MOD_VOLATILE = 0x0002, - CV_MOD_UNALIGNED = 0x0003, - - // 0x0200 - 0x03ff - HLSL modifiers. - - CV_MOD_HLSL_UNIFORM = 0x0200, - CV_MOD_HLSL_LINE = 0x0201, - CV_MOD_HLSL_TRIANGLE = 0x0202, - CV_MOD_HLSL_LINEADJ = 0x0203, - CV_MOD_HLSL_TRIANGLEADJ = 0x0204, - CV_MOD_HLSL_LINEAR = 0x0205, - CV_MOD_HLSL_CENTROID = 0x0206, - CV_MOD_HLSL_CONSTINTERP = 0x0207, - CV_MOD_HLSL_NOPERSPECTIVE = 0x0208, - CV_MOD_HLSL_SAMPLE = 0x0209, - CV_MOD_HLSL_CENTER = 0x020a, - CV_MOD_HLSL_SNORM = 0x020b, - CV_MOD_HLSL_UNORM = 0x020c, - CV_MOD_HLSL_PRECISE = 0x020d, - CV_MOD_HLSL_UAV_GLOBALLY_COHERENT = 0x020e, - - // 0x0400 - 0xffff - Unused. - -} CV_modifier_e; - - -// built-in type kinds - - -typedef enum CV_builtin_e { - - // 0x0000 - 0x01ff - Reserved. - CV_BI_INVALID = 0x0000, - - // 0x0200 - 0x03ff - HLSL types. - - CV_BI_HLSL_INTERFACE_POINTER = 0x0200, - CV_BI_HLSL_TEXTURE1D = 0x0201, - CV_BI_HLSL_TEXTURE1D_ARRAY = 0x0202, - CV_BI_HLSL_TEXTURE2D = 0x0203, - CV_BI_HLSL_TEXTURE2D_ARRAY = 0x0204, - CV_BI_HLSL_TEXTURE3D = 0x0205, - CV_BI_HLSL_TEXTURECUBE = 0x0206, - CV_BI_HLSL_TEXTURECUBE_ARRAY = 0x0207, - CV_BI_HLSL_TEXTURE2DMS = 0x0208, - CV_BI_HLSL_TEXTURE2DMS_ARRAY = 0x0209, - CV_BI_HLSL_SAMPLER = 0x020a, - CV_BI_HLSL_SAMPLERCOMPARISON = 0x020b, - CV_BI_HLSL_BUFFER = 0x020c, - CV_BI_HLSL_POINTSTREAM = 0x020d, - CV_BI_HLSL_LINESTREAM = 0x020e, - CV_BI_HLSL_TRIANGLESTREAM = 0x020f, - CV_BI_HLSL_INPUTPATCH = 0x0210, - CV_BI_HLSL_OUTPUTPATCH = 0x0211, - CV_BI_HLSL_RWTEXTURE1D = 0x0212, - CV_BI_HLSL_RWTEXTURE1D_ARRAY = 0x0213, - CV_BI_HLSL_RWTEXTURE2D = 0x0214, - CV_BI_HLSL_RWTEXTURE2D_ARRAY = 0x0215, - CV_BI_HLSL_RWTEXTURE3D = 0x0216, - CV_BI_HLSL_RWBUFFER = 0x0217, - CV_BI_HLSL_BYTEADDRESS_BUFFER = 0x0218, - CV_BI_HLSL_RWBYTEADDRESS_BUFFER = 0x0219, - CV_BI_HLSL_STRUCTURED_BUFFER = 0x021a, - CV_BI_HLSL_RWSTRUCTURED_BUFFER = 0x021b, - CV_BI_HLSL_APPEND_STRUCTURED_BUFFER = 0x021c, - CV_BI_HLSL_CONSUME_STRUCTURED_BUFFER= 0x021d, - CV_BI_HLSL_MIN8FLOAT = 0x021e, - CV_BI_HLSL_MIN10FLOAT = 0x021f, - CV_BI_HLSL_MIN16FLOAT = 0x0220, - CV_BI_HLSL_MIN12INT = 0x0221, - CV_BI_HLSL_MIN16INT = 0x0222, - CV_BI_HLSL_MIN16UINT = 0x0223, - - // 0x0400 - 0xffff - Unused. - -} CV_builtin_e; - - -// enum describing the compile flag source language - - -typedef enum CV_CFL_LANG { - CV_CFL_C = 0x00, - CV_CFL_CXX = 0x01, - CV_CFL_FORTRAN = 0x02, - CV_CFL_MASM = 0x03, - CV_CFL_PASCAL = 0x04, - CV_CFL_BASIC = 0x05, - CV_CFL_COBOL = 0x06, - CV_CFL_LINK = 0x07, - CV_CFL_CVTRES = 0x08, - CV_CFL_CVTPGD = 0x09, - CV_CFL_CSHARP = 0x0A, // C# - CV_CFL_VB = 0x0B, // Visual Basic - CV_CFL_ILASM = 0x0C, // IL (as in CLR) ASM - CV_CFL_JAVA = 0x0D, - CV_CFL_JSCRIPT = 0x0E, - CV_CFL_MSIL = 0x0F, // Unknown MSIL (LTCG of .NETMODULE) - CV_CFL_HLSL = 0x10, // High Level Shader Language -} CV_CFL_LANG; - - -// enum describing target processor - - -typedef enum CV_CPU_TYPE_e { - CV_CFL_8080 = 0x00, - CV_CFL_8086 = 0x01, - CV_CFL_80286 = 0x02, - CV_CFL_80386 = 0x03, - CV_CFL_80486 = 0x04, - CV_CFL_PENTIUM = 0x05, - CV_CFL_PENTIUMII = 0x06, - CV_CFL_PENTIUMPRO = CV_CFL_PENTIUMII, - CV_CFL_PENTIUMIII = 0x07, - CV_CFL_MIPS = 0x10, - CV_CFL_MIPSR4000 = CV_CFL_MIPS, // don't break current code - CV_CFL_MIPS16 = 0x11, - CV_CFL_MIPS32 = 0x12, - CV_CFL_MIPS64 = 0x13, - CV_CFL_MIPSI = 0x14, - CV_CFL_MIPSII = 0x15, - CV_CFL_MIPSIII = 0x16, - CV_CFL_MIPSIV = 0x17, - CV_CFL_MIPSV = 0x18, - CV_CFL_M68000 = 0x20, - CV_CFL_M68010 = 0x21, - CV_CFL_M68020 = 0x22, - CV_CFL_M68030 = 0x23, - CV_CFL_M68040 = 0x24, - CV_CFL_ALPHA = 0x30, - CV_CFL_ALPHA_21064 = 0x30, - CV_CFL_ALPHA_21164 = 0x31, - CV_CFL_ALPHA_21164A = 0x32, - CV_CFL_ALPHA_21264 = 0x33, - CV_CFL_ALPHA_21364 = 0x34, - CV_CFL_PPC601 = 0x40, - CV_CFL_PPC603 = 0x41, - CV_CFL_PPC604 = 0x42, - CV_CFL_PPC620 = 0x43, - CV_CFL_PPCFP = 0x44, - CV_CFL_PPCBE = 0x45, - CV_CFL_SH3 = 0x50, - CV_CFL_SH3E = 0x51, - CV_CFL_SH3DSP = 0x52, - CV_CFL_SH4 = 0x53, - CV_CFL_SHMEDIA = 0x54, - CV_CFL_ARM3 = 0x60, - CV_CFL_ARM4 = 0x61, - CV_CFL_ARM4T = 0x62, - CV_CFL_ARM5 = 0x63, - CV_CFL_ARM5T = 0x64, - CV_CFL_ARM6 = 0x65, - CV_CFL_ARM_XMAC = 0x66, - CV_CFL_ARM_WMMX = 0x67, - CV_CFL_ARM7 = 0x68, - CV_CFL_OMNI = 0x70, - CV_CFL_IA64 = 0x80, - CV_CFL_IA64_1 = 0x80, - CV_CFL_IA64_2 = 0x81, - CV_CFL_CEE = 0x90, - CV_CFL_AM33 = 0xA0, - CV_CFL_M32R = 0xB0, - CV_CFL_TRICORE = 0xC0, - CV_CFL_X64 = 0xD0, - CV_CFL_AMD64 = CV_CFL_X64, - CV_CFL_EBC = 0xE0, - CV_CFL_THUMB = 0xF0, - CV_CFL_ARMNT = 0xF4, - CV_CFL_ARM64 = 0xF6, - CV_CFL_D3D11_SHADER = 0x100, -} CV_CPU_TYPE_e; - -typedef enum CV_HREG_e { - // Register subset shared by all processor types, - // must not overlap with any of the ranges below, hence the high values - - CV_ALLREG_ERR = 30000, - CV_ALLREG_TEB = 30001, - CV_ALLREG_TIMER = 30002, - CV_ALLREG_EFAD1 = 30003, - CV_ALLREG_EFAD2 = 30004, - CV_ALLREG_EFAD3 = 30005, - CV_ALLREG_VFRAME= 30006, - CV_ALLREG_HANDLE= 30007, - CV_ALLREG_PARAMS= 30008, - CV_ALLREG_LOCALS= 30009, - CV_ALLREG_TID = 30010, - CV_ALLREG_ENV = 30011, - CV_ALLREG_CMDLN = 30012, - - - // Register set for the Intel 80x86 and ix86 processor series - // (plus PCODE registers) - - CV_REG_NONE = 0, - CV_REG_AL = 1, - CV_REG_CL = 2, - CV_REG_DL = 3, - CV_REG_BL = 4, - CV_REG_AH = 5, - CV_REG_CH = 6, - CV_REG_DH = 7, - CV_REG_BH = 8, - CV_REG_AX = 9, - CV_REG_CX = 10, - CV_REG_DX = 11, - CV_REG_BX = 12, - CV_REG_SP = 13, - CV_REG_BP = 14, - CV_REG_SI = 15, - CV_REG_DI = 16, - CV_REG_EAX = 17, - CV_REG_ECX = 18, - CV_REG_EDX = 19, - CV_REG_EBX = 20, - CV_REG_ESP = 21, - CV_REG_EBP = 22, - CV_REG_ESI = 23, - CV_REG_EDI = 24, - CV_REG_ES = 25, - CV_REG_CS = 26, - CV_REG_SS = 27, - CV_REG_DS = 28, - CV_REG_FS = 29, - CV_REG_GS = 30, - CV_REG_IP = 31, - CV_REG_FLAGS = 32, - CV_REG_EIP = 33, - CV_REG_EFLAGS = 34, - CV_REG_TEMP = 40, // PCODE Temp - CV_REG_TEMPH = 41, // PCODE TempH - CV_REG_QUOTE = 42, // PCODE Quote - CV_REG_PCDR3 = 43, // PCODE reserved - CV_REG_PCDR4 = 44, // PCODE reserved - CV_REG_PCDR5 = 45, // PCODE reserved - CV_REG_PCDR6 = 46, // PCODE reserved - CV_REG_PCDR7 = 47, // PCODE reserved - CV_REG_CR0 = 80, // CR0 -- control registers - CV_REG_CR1 = 81, - CV_REG_CR2 = 82, - CV_REG_CR3 = 83, - CV_REG_CR4 = 84, // Pentium - CV_REG_DR0 = 90, // Debug register - CV_REG_DR1 = 91, - CV_REG_DR2 = 92, - CV_REG_DR3 = 93, - CV_REG_DR4 = 94, - CV_REG_DR5 = 95, - CV_REG_DR6 = 96, - CV_REG_DR7 = 97, - CV_REG_GDTR = 110, - CV_REG_GDTL = 111, - CV_REG_IDTR = 112, - CV_REG_IDTL = 113, - CV_REG_LDTR = 114, - CV_REG_TR = 115, - - CV_REG_PSEUDO1 = 116, - CV_REG_PSEUDO2 = 117, - CV_REG_PSEUDO3 = 118, - CV_REG_PSEUDO4 = 119, - CV_REG_PSEUDO5 = 120, - CV_REG_PSEUDO6 = 121, - CV_REG_PSEUDO7 = 122, - CV_REG_PSEUDO8 = 123, - CV_REG_PSEUDO9 = 124, - - CV_REG_ST0 = 128, - CV_REG_ST1 = 129, - CV_REG_ST2 = 130, - CV_REG_ST3 = 131, - CV_REG_ST4 = 132, - CV_REG_ST5 = 133, - CV_REG_ST6 = 134, - CV_REG_ST7 = 135, - CV_REG_CTRL = 136, - CV_REG_STAT = 137, - CV_REG_TAG = 138, - CV_REG_FPIP = 139, - CV_REG_FPCS = 140, - CV_REG_FPDO = 141, - CV_REG_FPDS = 142, - CV_REG_ISEM = 143, - CV_REG_FPEIP = 144, - CV_REG_FPEDO = 145, - - CV_REG_MM0 = 146, - CV_REG_MM1 = 147, - CV_REG_MM2 = 148, - CV_REG_MM3 = 149, - CV_REG_MM4 = 150, - CV_REG_MM5 = 151, - CV_REG_MM6 = 152, - CV_REG_MM7 = 153, - - CV_REG_XMM0 = 154, // KATMAI registers - CV_REG_XMM1 = 155, - CV_REG_XMM2 = 156, - CV_REG_XMM3 = 157, - CV_REG_XMM4 = 158, - CV_REG_XMM5 = 159, - CV_REG_XMM6 = 160, - CV_REG_XMM7 = 161, - - CV_REG_XMM00 = 162, // KATMAI sub-registers - CV_REG_XMM01 = 163, - CV_REG_XMM02 = 164, - CV_REG_XMM03 = 165, - CV_REG_XMM10 = 166, - CV_REG_XMM11 = 167, - CV_REG_XMM12 = 168, - CV_REG_XMM13 = 169, - CV_REG_XMM20 = 170, - CV_REG_XMM21 = 171, - CV_REG_XMM22 = 172, - CV_REG_XMM23 = 173, - CV_REG_XMM30 = 174, - CV_REG_XMM31 = 175, - CV_REG_XMM32 = 176, - CV_REG_XMM33 = 177, - CV_REG_XMM40 = 178, - CV_REG_XMM41 = 179, - CV_REG_XMM42 = 180, - CV_REG_XMM43 = 181, - CV_REG_XMM50 = 182, - CV_REG_XMM51 = 183, - CV_REG_XMM52 = 184, - CV_REG_XMM53 = 185, - CV_REG_XMM60 = 186, - CV_REG_XMM61 = 187, - CV_REG_XMM62 = 188, - CV_REG_XMM63 = 189, - CV_REG_XMM70 = 190, - CV_REG_XMM71 = 191, - CV_REG_XMM72 = 192, - CV_REG_XMM73 = 193, - - CV_REG_XMM0L = 194, - CV_REG_XMM1L = 195, - CV_REG_XMM2L = 196, - CV_REG_XMM3L = 197, - CV_REG_XMM4L = 198, - CV_REG_XMM5L = 199, - CV_REG_XMM6L = 200, - CV_REG_XMM7L = 201, - - CV_REG_XMM0H = 202, - CV_REG_XMM1H = 203, - CV_REG_XMM2H = 204, - CV_REG_XMM3H = 205, - CV_REG_XMM4H = 206, - CV_REG_XMM5H = 207, - CV_REG_XMM6H = 208, - CV_REG_XMM7H = 209, - - CV_REG_MXCSR = 211, // XMM status register - - CV_REG_EDXEAX = 212, // EDX:EAX pair - - CV_REG_EMM0L = 220, // XMM sub-registers (WNI integer) - CV_REG_EMM1L = 221, - CV_REG_EMM2L = 222, - CV_REG_EMM3L = 223, - CV_REG_EMM4L = 224, - CV_REG_EMM5L = 225, - CV_REG_EMM6L = 226, - CV_REG_EMM7L = 227, - - CV_REG_EMM0H = 228, - CV_REG_EMM1H = 229, - CV_REG_EMM2H = 230, - CV_REG_EMM3H = 231, - CV_REG_EMM4H = 232, - CV_REG_EMM5H = 233, - CV_REG_EMM6H = 234, - CV_REG_EMM7H = 235, - - // do not change the order of these regs, first one must be even too - CV_REG_MM00 = 236, - CV_REG_MM01 = 237, - CV_REG_MM10 = 238, - CV_REG_MM11 = 239, - CV_REG_MM20 = 240, - CV_REG_MM21 = 241, - CV_REG_MM30 = 242, - CV_REG_MM31 = 243, - CV_REG_MM40 = 244, - CV_REG_MM41 = 245, - CV_REG_MM50 = 246, - CV_REG_MM51 = 247, - CV_REG_MM60 = 248, - CV_REG_MM61 = 249, - CV_REG_MM70 = 250, - CV_REG_MM71 = 251, - - CV_REG_YMM0 = 252, // AVX registers - CV_REG_YMM1 = 253, - CV_REG_YMM2 = 254, - CV_REG_YMM3 = 255, - CV_REG_YMM4 = 256, - CV_REG_YMM5 = 257, - CV_REG_YMM6 = 258, - CV_REG_YMM7 = 259, - - CV_REG_YMM0H = 260, - CV_REG_YMM1H = 261, - CV_REG_YMM2H = 262, - CV_REG_YMM3H = 263, - CV_REG_YMM4H = 264, - CV_REG_YMM5H = 265, - CV_REG_YMM6H = 266, - CV_REG_YMM7H = 267, - - CV_REG_YMM0I0 = 268, // AVX integer registers - CV_REG_YMM0I1 = 269, - CV_REG_YMM0I2 = 270, - CV_REG_YMM0I3 = 271, - CV_REG_YMM1I0 = 272, - CV_REG_YMM1I1 = 273, - CV_REG_YMM1I2 = 274, - CV_REG_YMM1I3 = 275, - CV_REG_YMM2I0 = 276, - CV_REG_YMM2I1 = 277, - CV_REG_YMM2I2 = 278, - CV_REG_YMM2I3 = 279, - CV_REG_YMM3I0 = 280, - CV_REG_YMM3I1 = 281, - CV_REG_YMM3I2 = 282, - CV_REG_YMM3I3 = 283, - CV_REG_YMM4I0 = 284, - CV_REG_YMM4I1 = 285, - CV_REG_YMM4I2 = 286, - CV_REG_YMM4I3 = 287, - CV_REG_YMM5I0 = 288, - CV_REG_YMM5I1 = 289, - CV_REG_YMM5I2 = 290, - CV_REG_YMM5I3 = 291, - CV_REG_YMM6I0 = 292, - CV_REG_YMM6I1 = 293, - CV_REG_YMM6I2 = 294, - CV_REG_YMM6I3 = 295, - CV_REG_YMM7I0 = 296, - CV_REG_YMM7I1 = 297, - CV_REG_YMM7I2 = 298, - CV_REG_YMM7I3 = 299, - - CV_REG_YMM0F0 = 300, // AVX floating-point single precise registers - CV_REG_YMM0F1 = 301, - CV_REG_YMM0F2 = 302, - CV_REG_YMM0F3 = 303, - CV_REG_YMM0F4 = 304, - CV_REG_YMM0F5 = 305, - CV_REG_YMM0F6 = 306, - CV_REG_YMM0F7 = 307, - CV_REG_YMM1F0 = 308, - CV_REG_YMM1F1 = 309, - CV_REG_YMM1F2 = 310, - CV_REG_YMM1F3 = 311, - CV_REG_YMM1F4 = 312, - CV_REG_YMM1F5 = 313, - CV_REG_YMM1F6 = 314, - CV_REG_YMM1F7 = 315, - CV_REG_YMM2F0 = 316, - CV_REG_YMM2F1 = 317, - CV_REG_YMM2F2 = 318, - CV_REG_YMM2F3 = 319, - CV_REG_YMM2F4 = 320, - CV_REG_YMM2F5 = 321, - CV_REG_YMM2F6 = 322, - CV_REG_YMM2F7 = 323, - CV_REG_YMM3F0 = 324, - CV_REG_YMM3F1 = 325, - CV_REG_YMM3F2 = 326, - CV_REG_YMM3F3 = 327, - CV_REG_YMM3F4 = 328, - CV_REG_YMM3F5 = 329, - CV_REG_YMM3F6 = 330, - CV_REG_YMM3F7 = 331, - CV_REG_YMM4F0 = 332, - CV_REG_YMM4F1 = 333, - CV_REG_YMM4F2 = 334, - CV_REG_YMM4F3 = 335, - CV_REG_YMM4F4 = 336, - CV_REG_YMM4F5 = 337, - CV_REG_YMM4F6 = 338, - CV_REG_YMM4F7 = 339, - CV_REG_YMM5F0 = 340, - CV_REG_YMM5F1 = 341, - CV_REG_YMM5F2 = 342, - CV_REG_YMM5F3 = 343, - CV_REG_YMM5F4 = 344, - CV_REG_YMM5F5 = 345, - CV_REG_YMM5F6 = 346, - CV_REG_YMM5F7 = 347, - CV_REG_YMM6F0 = 348, - CV_REG_YMM6F1 = 349, - CV_REG_YMM6F2 = 350, - CV_REG_YMM6F3 = 351, - CV_REG_YMM6F4 = 352, - CV_REG_YMM6F5 = 353, - CV_REG_YMM6F6 = 354, - CV_REG_YMM6F7 = 355, - CV_REG_YMM7F0 = 356, - CV_REG_YMM7F1 = 357, - CV_REG_YMM7F2 = 358, - CV_REG_YMM7F3 = 359, - CV_REG_YMM7F4 = 360, - CV_REG_YMM7F5 = 361, - CV_REG_YMM7F6 = 362, - CV_REG_YMM7F7 = 363, - - CV_REG_YMM0D0 = 364, // AVX floating-point double precise registers - CV_REG_YMM0D1 = 365, - CV_REG_YMM0D2 = 366, - CV_REG_YMM0D3 = 367, - CV_REG_YMM1D0 = 368, - CV_REG_YMM1D1 = 369, - CV_REG_YMM1D2 = 370, - CV_REG_YMM1D3 = 371, - CV_REG_YMM2D0 = 372, - CV_REG_YMM2D1 = 373, - CV_REG_YMM2D2 = 374, - CV_REG_YMM2D3 = 375, - CV_REG_YMM3D0 = 376, - CV_REG_YMM3D1 = 377, - CV_REG_YMM3D2 = 378, - CV_REG_YMM3D3 = 379, - CV_REG_YMM4D0 = 380, - CV_REG_YMM4D1 = 381, - CV_REG_YMM4D2 = 382, - CV_REG_YMM4D3 = 383, - CV_REG_YMM5D0 = 384, - CV_REG_YMM5D1 = 385, - CV_REG_YMM5D2 = 386, - CV_REG_YMM5D3 = 387, - CV_REG_YMM6D0 = 388, - CV_REG_YMM6D1 = 389, - CV_REG_YMM6D2 = 390, - CV_REG_YMM6D3 = 391, - CV_REG_YMM7D0 = 392, - CV_REG_YMM7D1 = 393, - CV_REG_YMM7D2 = 394, - CV_REG_YMM7D3 = 395, - - CV_REG_BND0 = 396, - CV_REG_BND1 = 397, - CV_REG_BND2 = 398, - CV_REG_BND3 = 399, - - // registers for the 68K processors - - CV_R68_D0 = 0, - CV_R68_D1 = 1, - CV_R68_D2 = 2, - CV_R68_D3 = 3, - CV_R68_D4 = 4, - CV_R68_D5 = 5, - CV_R68_D6 = 6, - CV_R68_D7 = 7, - CV_R68_A0 = 8, - CV_R68_A1 = 9, - CV_R68_A2 = 10, - CV_R68_A3 = 11, - CV_R68_A4 = 12, - CV_R68_A5 = 13, - CV_R68_A6 = 14, - CV_R68_A7 = 15, - CV_R68_CCR = 16, - CV_R68_SR = 17, - CV_R68_USP = 18, - CV_R68_MSP = 19, - CV_R68_SFC = 20, - CV_R68_DFC = 21, - CV_R68_CACR = 22, - CV_R68_VBR = 23, - CV_R68_CAAR = 24, - CV_R68_ISP = 25, - CV_R68_PC = 26, - //reserved 27 - CV_R68_FPCR = 28, - CV_R68_FPSR = 29, - CV_R68_FPIAR = 30, - //reserved 31 - CV_R68_FP0 = 32, - CV_R68_FP1 = 33, - CV_R68_FP2 = 34, - CV_R68_FP3 = 35, - CV_R68_FP4 = 36, - CV_R68_FP5 = 37, - CV_R68_FP6 = 38, - CV_R68_FP7 = 39, - //reserved 40 - CV_R68_MMUSR030 = 41, - CV_R68_MMUSR = 42, - CV_R68_URP = 43, - CV_R68_DTT0 = 44, - CV_R68_DTT1 = 45, - CV_R68_ITT0 = 46, - CV_R68_ITT1 = 47, - //reserved 50 - CV_R68_PSR = 51, - CV_R68_PCSR = 52, - CV_R68_VAL = 53, - CV_R68_CRP = 54, - CV_R68_SRP = 55, - CV_R68_DRP = 56, - CV_R68_TC = 57, - CV_R68_AC = 58, - CV_R68_SCC = 59, - CV_R68_CAL = 60, - CV_R68_TT0 = 61, - CV_R68_TT1 = 62, - //reserved 63 - CV_R68_BAD0 = 64, - CV_R68_BAD1 = 65, - CV_R68_BAD2 = 66, - CV_R68_BAD3 = 67, - CV_R68_BAD4 = 68, - CV_R68_BAD5 = 69, - CV_R68_BAD6 = 70, - CV_R68_BAD7 = 71, - CV_R68_BAC0 = 72, - CV_R68_BAC1 = 73, - CV_R68_BAC2 = 74, - CV_R68_BAC3 = 75, - CV_R68_BAC4 = 76, - CV_R68_BAC5 = 77, - CV_R68_BAC6 = 78, - CV_R68_BAC7 = 79, - - // Register set for the MIPS 4000 - - CV_M4_NOREG = CV_REG_NONE, - - CV_M4_IntZERO = 10, /* CPU REGISTER */ - CV_M4_IntAT = 11, - CV_M4_IntV0 = 12, - CV_M4_IntV1 = 13, - CV_M4_IntA0 = 14, - CV_M4_IntA1 = 15, - CV_M4_IntA2 = 16, - CV_M4_IntA3 = 17, - CV_M4_IntT0 = 18, - CV_M4_IntT1 = 19, - CV_M4_IntT2 = 20, - CV_M4_IntT3 = 21, - CV_M4_IntT4 = 22, - CV_M4_IntT5 = 23, - CV_M4_IntT6 = 24, - CV_M4_IntT7 = 25, - CV_M4_IntS0 = 26, - CV_M4_IntS1 = 27, - CV_M4_IntS2 = 28, - CV_M4_IntS3 = 29, - CV_M4_IntS4 = 30, - CV_M4_IntS5 = 31, - CV_M4_IntS6 = 32, - CV_M4_IntS7 = 33, - CV_M4_IntT8 = 34, - CV_M4_IntT9 = 35, - CV_M4_IntKT0 = 36, - CV_M4_IntKT1 = 37, - CV_M4_IntGP = 38, - CV_M4_IntSP = 39, - CV_M4_IntS8 = 40, - CV_M4_IntRA = 41, - CV_M4_IntLO = 42, - CV_M4_IntHI = 43, - - CV_M4_Fir = 50, - CV_M4_Psr = 51, - - CV_M4_FltF0 = 60, /* Floating point registers */ - CV_M4_FltF1 = 61, - CV_M4_FltF2 = 62, - CV_M4_FltF3 = 63, - CV_M4_FltF4 = 64, - CV_M4_FltF5 = 65, - CV_M4_FltF6 = 66, - CV_M4_FltF7 = 67, - CV_M4_FltF8 = 68, - CV_M4_FltF9 = 69, - CV_M4_FltF10 = 70, - CV_M4_FltF11 = 71, - CV_M4_FltF12 = 72, - CV_M4_FltF13 = 73, - CV_M4_FltF14 = 74, - CV_M4_FltF15 = 75, - CV_M4_FltF16 = 76, - CV_M4_FltF17 = 77, - CV_M4_FltF18 = 78, - CV_M4_FltF19 = 79, - CV_M4_FltF20 = 80, - CV_M4_FltF21 = 81, - CV_M4_FltF22 = 82, - CV_M4_FltF23 = 83, - CV_M4_FltF24 = 84, - CV_M4_FltF25 = 85, - CV_M4_FltF26 = 86, - CV_M4_FltF27 = 87, - CV_M4_FltF28 = 88, - CV_M4_FltF29 = 89, - CV_M4_FltF30 = 90, - CV_M4_FltF31 = 91, - CV_M4_FltFsr = 92, - - - // Register set for the ALPHA AXP - - CV_ALPHA_NOREG = CV_REG_NONE, - - CV_ALPHA_FltF0 = 10, // Floating point registers - CV_ALPHA_FltF1 = 11, - CV_ALPHA_FltF2 = 12, - CV_ALPHA_FltF3 = 13, - CV_ALPHA_FltF4 = 14, - CV_ALPHA_FltF5 = 15, - CV_ALPHA_FltF6 = 16, - CV_ALPHA_FltF7 = 17, - CV_ALPHA_FltF8 = 18, - CV_ALPHA_FltF9 = 19, - CV_ALPHA_FltF10 = 20, - CV_ALPHA_FltF11 = 21, - CV_ALPHA_FltF12 = 22, - CV_ALPHA_FltF13 = 23, - CV_ALPHA_FltF14 = 24, - CV_ALPHA_FltF15 = 25, - CV_ALPHA_FltF16 = 26, - CV_ALPHA_FltF17 = 27, - CV_ALPHA_FltF18 = 28, - CV_ALPHA_FltF19 = 29, - CV_ALPHA_FltF20 = 30, - CV_ALPHA_FltF21 = 31, - CV_ALPHA_FltF22 = 32, - CV_ALPHA_FltF23 = 33, - CV_ALPHA_FltF24 = 34, - CV_ALPHA_FltF25 = 35, - CV_ALPHA_FltF26 = 36, - CV_ALPHA_FltF27 = 37, - CV_ALPHA_FltF28 = 38, - CV_ALPHA_FltF29 = 39, - CV_ALPHA_FltF30 = 40, - CV_ALPHA_FltF31 = 41, - - CV_ALPHA_IntV0 = 42, // Integer registers - CV_ALPHA_IntT0 = 43, - CV_ALPHA_IntT1 = 44, - CV_ALPHA_IntT2 = 45, - CV_ALPHA_IntT3 = 46, - CV_ALPHA_IntT4 = 47, - CV_ALPHA_IntT5 = 48, - CV_ALPHA_IntT6 = 49, - CV_ALPHA_IntT7 = 50, - CV_ALPHA_IntS0 = 51, - CV_ALPHA_IntS1 = 52, - CV_ALPHA_IntS2 = 53, - CV_ALPHA_IntS3 = 54, - CV_ALPHA_IntS4 = 55, - CV_ALPHA_IntS5 = 56, - CV_ALPHA_IntFP = 57, - CV_ALPHA_IntA0 = 58, - CV_ALPHA_IntA1 = 59, - CV_ALPHA_IntA2 = 60, - CV_ALPHA_IntA3 = 61, - CV_ALPHA_IntA4 = 62, - CV_ALPHA_IntA5 = 63, - CV_ALPHA_IntT8 = 64, - CV_ALPHA_IntT9 = 65, - CV_ALPHA_IntT10 = 66, - CV_ALPHA_IntT11 = 67, - CV_ALPHA_IntRA = 68, - CV_ALPHA_IntT12 = 69, - CV_ALPHA_IntAT = 70, - CV_ALPHA_IntGP = 71, - CV_ALPHA_IntSP = 72, - CV_ALPHA_IntZERO = 73, - - - CV_ALPHA_Fpcr = 74, // Control registers - CV_ALPHA_Fir = 75, - CV_ALPHA_Psr = 76, - CV_ALPHA_FltFsr = 77, - CV_ALPHA_SoftFpcr = 78, - - // Register Set for Motorola/IBM PowerPC - - /* - ** PowerPC General Registers ( User Level ) - */ - CV_PPC_GPR0 = 1, - CV_PPC_GPR1 = 2, - CV_PPC_GPR2 = 3, - CV_PPC_GPR3 = 4, - CV_PPC_GPR4 = 5, - CV_PPC_GPR5 = 6, - CV_PPC_GPR6 = 7, - CV_PPC_GPR7 = 8, - CV_PPC_GPR8 = 9, - CV_PPC_GPR9 = 10, - CV_PPC_GPR10 = 11, - CV_PPC_GPR11 = 12, - CV_PPC_GPR12 = 13, - CV_PPC_GPR13 = 14, - CV_PPC_GPR14 = 15, - CV_PPC_GPR15 = 16, - CV_PPC_GPR16 = 17, - CV_PPC_GPR17 = 18, - CV_PPC_GPR18 = 19, - CV_PPC_GPR19 = 20, - CV_PPC_GPR20 = 21, - CV_PPC_GPR21 = 22, - CV_PPC_GPR22 = 23, - CV_PPC_GPR23 = 24, - CV_PPC_GPR24 = 25, - CV_PPC_GPR25 = 26, - CV_PPC_GPR26 = 27, - CV_PPC_GPR27 = 28, - CV_PPC_GPR28 = 29, - CV_PPC_GPR29 = 30, - CV_PPC_GPR30 = 31, - CV_PPC_GPR31 = 32, - - /* - ** PowerPC Condition Register ( User Level ) - */ - CV_PPC_CR = 33, - CV_PPC_CR0 = 34, - CV_PPC_CR1 = 35, - CV_PPC_CR2 = 36, - CV_PPC_CR3 = 37, - CV_PPC_CR4 = 38, - CV_PPC_CR5 = 39, - CV_PPC_CR6 = 40, - CV_PPC_CR7 = 41, - - /* - ** PowerPC Floating Point Registers ( User Level ) - */ - CV_PPC_FPR0 = 42, - CV_PPC_FPR1 = 43, - CV_PPC_FPR2 = 44, - CV_PPC_FPR3 = 45, - CV_PPC_FPR4 = 46, - CV_PPC_FPR5 = 47, - CV_PPC_FPR6 = 48, - CV_PPC_FPR7 = 49, - CV_PPC_FPR8 = 50, - CV_PPC_FPR9 = 51, - CV_PPC_FPR10 = 52, - CV_PPC_FPR11 = 53, - CV_PPC_FPR12 = 54, - CV_PPC_FPR13 = 55, - CV_PPC_FPR14 = 56, - CV_PPC_FPR15 = 57, - CV_PPC_FPR16 = 58, - CV_PPC_FPR17 = 59, - CV_PPC_FPR18 = 60, - CV_PPC_FPR19 = 61, - CV_PPC_FPR20 = 62, - CV_PPC_FPR21 = 63, - CV_PPC_FPR22 = 64, - CV_PPC_FPR23 = 65, - CV_PPC_FPR24 = 66, - CV_PPC_FPR25 = 67, - CV_PPC_FPR26 = 68, - CV_PPC_FPR27 = 69, - CV_PPC_FPR28 = 70, - CV_PPC_FPR29 = 71, - CV_PPC_FPR30 = 72, - CV_PPC_FPR31 = 73, - - /* - ** PowerPC Floating Point Status and Control Register ( User Level ) - */ - CV_PPC_FPSCR = 74, - - /* - ** PowerPC Machine State Register ( Supervisor Level ) - */ - CV_PPC_MSR = 75, - - /* - ** PowerPC Segment Registers ( Supervisor Level ) - */ - CV_PPC_SR0 = 76, - CV_PPC_SR1 = 77, - CV_PPC_SR2 = 78, - CV_PPC_SR3 = 79, - CV_PPC_SR4 = 80, - CV_PPC_SR5 = 81, - CV_PPC_SR6 = 82, - CV_PPC_SR7 = 83, - CV_PPC_SR8 = 84, - CV_PPC_SR9 = 85, - CV_PPC_SR10 = 86, - CV_PPC_SR11 = 87, - CV_PPC_SR12 = 88, - CV_PPC_SR13 = 89, - CV_PPC_SR14 = 90, - CV_PPC_SR15 = 91, - - /* - ** For all of the special purpose registers add 100 to the SPR# that the - ** Motorola/IBM documentation gives with the exception of any imaginary - ** registers. - */ - - /* - ** PowerPC Special Purpose Registers ( User Level ) - */ - CV_PPC_PC = 99, // PC (imaginary register) - - CV_PPC_MQ = 100, // MPC601 - CV_PPC_XER = 101, - CV_PPC_RTCU = 104, // MPC601 - CV_PPC_RTCL = 105, // MPC601 - CV_PPC_LR = 108, - CV_PPC_CTR = 109, - - CV_PPC_COMPARE = 110, // part of XER (internal to the debugger only) - CV_PPC_COUNT = 111, // part of XER (internal to the debugger only) - - /* - ** PowerPC Special Purpose Registers ( Supervisor Level ) - */ - CV_PPC_DSISR = 118, - CV_PPC_DAR = 119, - CV_PPC_DEC = 122, - CV_PPC_SDR1 = 125, - CV_PPC_SRR0 = 126, - CV_PPC_SRR1 = 127, - CV_PPC_SPRG0 = 372, - CV_PPC_SPRG1 = 373, - CV_PPC_SPRG2 = 374, - CV_PPC_SPRG3 = 375, - CV_PPC_ASR = 280, // 64-bit implementations only - CV_PPC_EAR = 382, - CV_PPC_PVR = 287, - CV_PPC_BAT0U = 628, - CV_PPC_BAT0L = 629, - CV_PPC_BAT1U = 630, - CV_PPC_BAT1L = 631, - CV_PPC_BAT2U = 632, - CV_PPC_BAT2L = 633, - CV_PPC_BAT3U = 634, - CV_PPC_BAT3L = 635, - CV_PPC_DBAT0U = 636, - CV_PPC_DBAT0L = 637, - CV_PPC_DBAT1U = 638, - CV_PPC_DBAT1L = 639, - CV_PPC_DBAT2U = 640, - CV_PPC_DBAT2L = 641, - CV_PPC_DBAT3U = 642, - CV_PPC_DBAT3L = 643, - - /* - ** PowerPC Special Purpose Registers Implementation Dependent ( Supervisor Level ) - */ - - /* - ** Doesn't appear that IBM/Motorola has finished defining these. - */ - - CV_PPC_PMR0 = 1044, // MPC620, - CV_PPC_PMR1 = 1045, // MPC620, - CV_PPC_PMR2 = 1046, // MPC620, - CV_PPC_PMR3 = 1047, // MPC620, - CV_PPC_PMR4 = 1048, // MPC620, - CV_PPC_PMR5 = 1049, // MPC620, - CV_PPC_PMR6 = 1050, // MPC620, - CV_PPC_PMR7 = 1051, // MPC620, - CV_PPC_PMR8 = 1052, // MPC620, - CV_PPC_PMR9 = 1053, // MPC620, - CV_PPC_PMR10 = 1054, // MPC620, - CV_PPC_PMR11 = 1055, // MPC620, - CV_PPC_PMR12 = 1056, // MPC620, - CV_PPC_PMR13 = 1057, // MPC620, - CV_PPC_PMR14 = 1058, // MPC620, - CV_PPC_PMR15 = 1059, // MPC620, - - CV_PPC_DMISS = 1076, // MPC603 - CV_PPC_DCMP = 1077, // MPC603 - CV_PPC_HASH1 = 1078, // MPC603 - CV_PPC_HASH2 = 1079, // MPC603 - CV_PPC_IMISS = 1080, // MPC603 - CV_PPC_ICMP = 1081, // MPC603 - CV_PPC_RPA = 1082, // MPC603 - - CV_PPC_HID0 = 1108, // MPC601, MPC603, MPC620 - CV_PPC_HID1 = 1109, // MPC601 - CV_PPC_HID2 = 1110, // MPC601, MPC603, MPC620 ( IABR ) - CV_PPC_HID3 = 1111, // Not Defined - CV_PPC_HID4 = 1112, // Not Defined - CV_PPC_HID5 = 1113, // MPC601, MPC604, MPC620 ( DABR ) - CV_PPC_HID6 = 1114, // Not Defined - CV_PPC_HID7 = 1115, // Not Defined - CV_PPC_HID8 = 1116, // MPC620 ( BUSCSR ) - CV_PPC_HID9 = 1117, // MPC620 ( L2CSR ) - CV_PPC_HID10 = 1118, // Not Defined - CV_PPC_HID11 = 1119, // Not Defined - CV_PPC_HID12 = 1120, // Not Defined - CV_PPC_HID13 = 1121, // MPC604 ( HCR ) - CV_PPC_HID14 = 1122, // Not Defined - CV_PPC_HID15 = 1123, // MPC601, MPC604, MPC620 ( PIR ) - - // - // JAVA VM registers - // - - CV_JAVA_PC = 1, - - // - // Register set for the Hitachi SH3 - // - - CV_SH3_NOREG = CV_REG_NONE, - - CV_SH3_IntR0 = 10, // CPU REGISTER - CV_SH3_IntR1 = 11, - CV_SH3_IntR2 = 12, - CV_SH3_IntR3 = 13, - CV_SH3_IntR4 = 14, - CV_SH3_IntR5 = 15, - CV_SH3_IntR6 = 16, - CV_SH3_IntR7 = 17, - CV_SH3_IntR8 = 18, - CV_SH3_IntR9 = 19, - CV_SH3_IntR10 = 20, - CV_SH3_IntR11 = 21, - CV_SH3_IntR12 = 22, - CV_SH3_IntR13 = 23, - CV_SH3_IntFp = 24, - CV_SH3_IntSp = 25, - CV_SH3_Gbr = 38, - CV_SH3_Pr = 39, - CV_SH3_Mach = 40, - CV_SH3_Macl = 41, - - CV_SH3_Pc = 50, - CV_SH3_Sr = 51, - - CV_SH3_BarA = 60, - CV_SH3_BasrA = 61, - CV_SH3_BamrA = 62, - CV_SH3_BbrA = 63, - CV_SH3_BarB = 64, - CV_SH3_BasrB = 65, - CV_SH3_BamrB = 66, - CV_SH3_BbrB = 67, - CV_SH3_BdrB = 68, - CV_SH3_BdmrB = 69, - CV_SH3_Brcr = 70, - - // - // Additional registers for Hitachi SH processors - // - - CV_SH_Fpscr = 75, // floating point status/control register - CV_SH_Fpul = 76, // floating point communication register - - CV_SH_FpR0 = 80, // Floating point registers - CV_SH_FpR1 = 81, - CV_SH_FpR2 = 82, - CV_SH_FpR3 = 83, - CV_SH_FpR4 = 84, - CV_SH_FpR5 = 85, - CV_SH_FpR6 = 86, - CV_SH_FpR7 = 87, - CV_SH_FpR8 = 88, - CV_SH_FpR9 = 89, - CV_SH_FpR10 = 90, - CV_SH_FpR11 = 91, - CV_SH_FpR12 = 92, - CV_SH_FpR13 = 93, - CV_SH_FpR14 = 94, - CV_SH_FpR15 = 95, - - CV_SH_XFpR0 = 96, - CV_SH_XFpR1 = 97, - CV_SH_XFpR2 = 98, - CV_SH_XFpR3 = 99, - CV_SH_XFpR4 = 100, - CV_SH_XFpR5 = 101, - CV_SH_XFpR6 = 102, - CV_SH_XFpR7 = 103, - CV_SH_XFpR8 = 104, - CV_SH_XFpR9 = 105, - CV_SH_XFpR10 = 106, - CV_SH_XFpR11 = 107, - CV_SH_XFpR12 = 108, - CV_SH_XFpR13 = 109, - CV_SH_XFpR14 = 110, - CV_SH_XFpR15 = 111, - - // - // Register set for the ARM processor. - // - - CV_ARM_NOREG = CV_REG_NONE, - - CV_ARM_R0 = 10, - CV_ARM_R1 = 11, - CV_ARM_R2 = 12, - CV_ARM_R3 = 13, - CV_ARM_R4 = 14, - CV_ARM_R5 = 15, - CV_ARM_R6 = 16, - CV_ARM_R7 = 17, - CV_ARM_R8 = 18, - CV_ARM_R9 = 19, - CV_ARM_R10 = 20, - CV_ARM_R11 = 21, // Frame pointer, if allocated - CV_ARM_R12 = 22, - CV_ARM_SP = 23, // Stack pointer - CV_ARM_LR = 24, // Link Register - CV_ARM_PC = 25, // Program counter - CV_ARM_CPSR = 26, // Current program status register - - CV_ARM_ACC0 = 27, // DSP co-processor 0 40 bit accumulator - - // - // Registers for ARM VFP10 support - // - - CV_ARM_FPSCR = 40, - CV_ARM_FPEXC = 41, - - CV_ARM_FS0 = 50, - CV_ARM_FS1 = 51, - CV_ARM_FS2 = 52, - CV_ARM_FS3 = 53, - CV_ARM_FS4 = 54, - CV_ARM_FS5 = 55, - CV_ARM_FS6 = 56, - CV_ARM_FS7 = 57, - CV_ARM_FS8 = 58, - CV_ARM_FS9 = 59, - CV_ARM_FS10 = 60, - CV_ARM_FS11 = 61, - CV_ARM_FS12 = 62, - CV_ARM_FS13 = 63, - CV_ARM_FS14 = 64, - CV_ARM_FS15 = 65, - CV_ARM_FS16 = 66, - CV_ARM_FS17 = 67, - CV_ARM_FS18 = 68, - CV_ARM_FS19 = 69, - CV_ARM_FS20 = 70, - CV_ARM_FS21 = 71, - CV_ARM_FS22 = 72, - CV_ARM_FS23 = 73, - CV_ARM_FS24 = 74, - CV_ARM_FS25 = 75, - CV_ARM_FS26 = 76, - CV_ARM_FS27 = 77, - CV_ARM_FS28 = 78, - CV_ARM_FS29 = 79, - CV_ARM_FS30 = 80, - CV_ARM_FS31 = 81, - - // - // ARM VFP Floating Point Extra control registers - // - - CV_ARM_FPEXTRA0 = 90, - CV_ARM_FPEXTRA1 = 91, - CV_ARM_FPEXTRA2 = 92, - CV_ARM_FPEXTRA3 = 93, - CV_ARM_FPEXTRA4 = 94, - CV_ARM_FPEXTRA5 = 95, - CV_ARM_FPEXTRA6 = 96, - CV_ARM_FPEXTRA7 = 97, - - // XSCALE Concan co-processor registers - CV_ARM_WR0 = 128, - CV_ARM_WR1 = 129, - CV_ARM_WR2 = 130, - CV_ARM_WR3 = 131, - CV_ARM_WR4 = 132, - CV_ARM_WR5 = 133, - CV_ARM_WR6 = 134, - CV_ARM_WR7 = 135, - CV_ARM_WR8 = 136, - CV_ARM_WR9 = 137, - CV_ARM_WR10 = 138, - CV_ARM_WR11 = 139, - CV_ARM_WR12 = 140, - CV_ARM_WR13 = 141, - CV_ARM_WR14 = 142, - CV_ARM_WR15 = 143, - - // XSCALE Concan co-processor control registers - CV_ARM_WCID = 144, - CV_ARM_WCON = 145, - CV_ARM_WCSSF = 146, - CV_ARM_WCASF = 147, - CV_ARM_WC4 = 148, - CV_ARM_WC5 = 149, - CV_ARM_WC6 = 150, - CV_ARM_WC7 = 151, - CV_ARM_WCGR0 = 152, - CV_ARM_WCGR1 = 153, - CV_ARM_WCGR2 = 154, - CV_ARM_WCGR3 = 155, - CV_ARM_WC12 = 156, - CV_ARM_WC13 = 157, - CV_ARM_WC14 = 158, - CV_ARM_WC15 = 159, - - // - // ARM VFPv3/Neon extended floating Point - // - - CV_ARM_FS32 = 200, - CV_ARM_FS33 = 201, - CV_ARM_FS34 = 202, - CV_ARM_FS35 = 203, - CV_ARM_FS36 = 204, - CV_ARM_FS37 = 205, - CV_ARM_FS38 = 206, - CV_ARM_FS39 = 207, - CV_ARM_FS40 = 208, - CV_ARM_FS41 = 209, - CV_ARM_FS42 = 210, - CV_ARM_FS43 = 211, - CV_ARM_FS44 = 212, - CV_ARM_FS45 = 213, - CV_ARM_FS46 = 214, - CV_ARM_FS47 = 215, - CV_ARM_FS48 = 216, - CV_ARM_FS49 = 217, - CV_ARM_FS50 = 218, - CV_ARM_FS51 = 219, - CV_ARM_FS52 = 220, - CV_ARM_FS53 = 221, - CV_ARM_FS54 = 222, - CV_ARM_FS55 = 223, - CV_ARM_FS56 = 224, - CV_ARM_FS57 = 225, - CV_ARM_FS58 = 226, - CV_ARM_FS59 = 227, - CV_ARM_FS60 = 228, - CV_ARM_FS61 = 229, - CV_ARM_FS62 = 230, - CV_ARM_FS63 = 231, - - // ARM double-precision floating point - - CV_ARM_ND0 = 300, - CV_ARM_ND1 = 301, - CV_ARM_ND2 = 302, - CV_ARM_ND3 = 303, - CV_ARM_ND4 = 304, - CV_ARM_ND5 = 305, - CV_ARM_ND6 = 306, - CV_ARM_ND7 = 307, - CV_ARM_ND8 = 308, - CV_ARM_ND9 = 309, - CV_ARM_ND10 = 310, - CV_ARM_ND11 = 311, - CV_ARM_ND12 = 312, - CV_ARM_ND13 = 313, - CV_ARM_ND14 = 314, - CV_ARM_ND15 = 315, - CV_ARM_ND16 = 316, - CV_ARM_ND17 = 317, - CV_ARM_ND18 = 318, - CV_ARM_ND19 = 319, - CV_ARM_ND20 = 320, - CV_ARM_ND21 = 321, - CV_ARM_ND22 = 322, - CV_ARM_ND23 = 323, - CV_ARM_ND24 = 324, - CV_ARM_ND25 = 325, - CV_ARM_ND26 = 326, - CV_ARM_ND27 = 327, - CV_ARM_ND28 = 328, - CV_ARM_ND29 = 329, - CV_ARM_ND30 = 330, - CV_ARM_ND31 = 331, - - // ARM extended precision floating point - - CV_ARM_NQ0 = 400, - CV_ARM_NQ1 = 401, - CV_ARM_NQ2 = 402, - CV_ARM_NQ3 = 403, - CV_ARM_NQ4 = 404, - CV_ARM_NQ5 = 405, - CV_ARM_NQ6 = 406, - CV_ARM_NQ7 = 407, - CV_ARM_NQ8 = 408, - CV_ARM_NQ9 = 409, - CV_ARM_NQ10 = 410, - CV_ARM_NQ11 = 411, - CV_ARM_NQ12 = 412, - CV_ARM_NQ13 = 413, - CV_ARM_NQ14 = 414, - CV_ARM_NQ15 = 415, - - // - // Register set for ARM64 - // - - CV_ARM64_NOREG = CV_REG_NONE, - - // General purpose 32-bit integer registers - - CV_ARM64_W0 = 10, - CV_ARM64_W1 = 11, - CV_ARM64_W2 = 12, - CV_ARM64_W3 = 13, - CV_ARM64_W4 = 14, - CV_ARM64_W5 = 15, - CV_ARM64_W6 = 16, - CV_ARM64_W7 = 17, - CV_ARM64_W8 = 18, - CV_ARM64_W9 = 19, - CV_ARM64_W10 = 20, - CV_ARM64_W11 = 21, - CV_ARM64_W12 = 22, - CV_ARM64_W13 = 23, - CV_ARM64_W14 = 24, - CV_ARM64_W15 = 25, - CV_ARM64_W16 = 26, - CV_ARM64_W17 = 27, - CV_ARM64_W18 = 28, - CV_ARM64_W19 = 29, - CV_ARM64_W20 = 30, - CV_ARM64_W21 = 31, - CV_ARM64_W22 = 32, - CV_ARM64_W23 = 33, - CV_ARM64_W24 = 34, - CV_ARM64_W25 = 35, - CV_ARM64_W26 = 36, - CV_ARM64_W27 = 37, - CV_ARM64_W28 = 38, - CV_ARM64_W29 = 39, - CV_ARM64_W30 = 40, - CV_ARM64_WZR = 41, - - // General purpose 64-bit integer registers - - CV_ARM64_X0 = 50, - CV_ARM64_X1 = 51, - CV_ARM64_X2 = 52, - CV_ARM64_X3 = 53, - CV_ARM64_X4 = 54, - CV_ARM64_X5 = 55, - CV_ARM64_X6 = 56, - CV_ARM64_X7 = 57, - CV_ARM64_X8 = 58, - CV_ARM64_X9 = 59, - CV_ARM64_X10 = 60, - CV_ARM64_X11 = 61, - CV_ARM64_X12 = 62, - CV_ARM64_X13 = 63, - CV_ARM64_X14 = 64, - CV_ARM64_X15 = 65, - CV_ARM64_IP0 = 66, - CV_ARM64_IP1 = 67, - CV_ARM64_X18 = 68, - CV_ARM64_X19 = 69, - CV_ARM64_X20 = 70, - CV_ARM64_X21 = 71, - CV_ARM64_X22 = 72, - CV_ARM64_X23 = 73, - CV_ARM64_X24 = 74, - CV_ARM64_X25 = 75, - CV_ARM64_X26 = 76, - CV_ARM64_X27 = 77, - CV_ARM64_X28 = 78, - CV_ARM64_FP = 79, - CV_ARM64_LR = 80, - CV_ARM64_SP = 81, - CV_ARM64_ZR = 82, - - // statue register - - CV_ARM64_NZCV = 90, - - // 32-bit floating point registers - - CV_ARM64_S0 = 100, - CV_ARM64_S1 = 101, - CV_ARM64_S2 = 102, - CV_ARM64_S3 = 103, - CV_ARM64_S4 = 104, - CV_ARM64_S5 = 105, - CV_ARM64_S6 = 106, - CV_ARM64_S7 = 107, - CV_ARM64_S8 = 108, - CV_ARM64_S9 = 109, - CV_ARM64_S10 = 110, - CV_ARM64_S11 = 111, - CV_ARM64_S12 = 112, - CV_ARM64_S13 = 113, - CV_ARM64_S14 = 114, - CV_ARM64_S15 = 115, - CV_ARM64_S16 = 116, - CV_ARM64_S17 = 117, - CV_ARM64_S18 = 118, - CV_ARM64_S19 = 119, - CV_ARM64_S20 = 120, - CV_ARM64_S21 = 121, - CV_ARM64_S22 = 122, - CV_ARM64_S23 = 123, - CV_ARM64_S24 = 124, - CV_ARM64_S25 = 125, - CV_ARM64_S26 = 126, - CV_ARM64_S27 = 127, - CV_ARM64_S28 = 128, - CV_ARM64_S29 = 129, - CV_ARM64_S30 = 130, - CV_ARM64_S31 = 131, - - // 64-bit floating point registers - - CV_ARM64_D0 = 140, - CV_ARM64_D1 = 141, - CV_ARM64_D2 = 142, - CV_ARM64_D3 = 143, - CV_ARM64_D4 = 144, - CV_ARM64_D5 = 145, - CV_ARM64_D6 = 146, - CV_ARM64_D7 = 147, - CV_ARM64_D8 = 148, - CV_ARM64_D9 = 149, - CV_ARM64_D10 = 150, - CV_ARM64_D11 = 151, - CV_ARM64_D12 = 152, - CV_ARM64_D13 = 153, - CV_ARM64_D14 = 154, - CV_ARM64_D15 = 155, - CV_ARM64_D16 = 156, - CV_ARM64_D17 = 157, - CV_ARM64_D18 = 158, - CV_ARM64_D19 = 159, - CV_ARM64_D20 = 160, - CV_ARM64_D21 = 161, - CV_ARM64_D22 = 162, - CV_ARM64_D23 = 163, - CV_ARM64_D24 = 164, - CV_ARM64_D25 = 165, - CV_ARM64_D26 = 166, - CV_ARM64_D27 = 167, - CV_ARM64_D28 = 168, - CV_ARM64_D29 = 169, - CV_ARM64_D30 = 170, - CV_ARM64_D31 = 171, - - // 128-bit SIMD registers - - CV_ARM64_Q0 = 180, - CV_ARM64_Q1 = 181, - CV_ARM64_Q2 = 182, - CV_ARM64_Q3 = 183, - CV_ARM64_Q4 = 184, - CV_ARM64_Q5 = 185, - CV_ARM64_Q6 = 186, - CV_ARM64_Q7 = 187, - CV_ARM64_Q8 = 188, - CV_ARM64_Q9 = 189, - CV_ARM64_Q10 = 190, - CV_ARM64_Q11 = 191, - CV_ARM64_Q12 = 192, - CV_ARM64_Q13 = 193, - CV_ARM64_Q14 = 194, - CV_ARM64_Q15 = 195, - CV_ARM64_Q16 = 196, - CV_ARM64_Q17 = 197, - CV_ARM64_Q18 = 198, - CV_ARM64_Q19 = 199, - CV_ARM64_Q20 = 200, - CV_ARM64_Q21 = 201, - CV_ARM64_Q22 = 202, - CV_ARM64_Q23 = 203, - CV_ARM64_Q24 = 204, - CV_ARM64_Q25 = 205, - CV_ARM64_Q26 = 206, - CV_ARM64_Q27 = 207, - CV_ARM64_Q28 = 208, - CV_ARM64_Q29 = 209, - CV_ARM64_Q30 = 210, - CV_ARM64_Q31 = 211, - - // Floating point status register - - CV_ARM64_FPSR = 220, - - // - // Register set for Intel IA64 - // - - CV_IA64_NOREG = CV_REG_NONE, - - // Branch Registers - - CV_IA64_Br0 = 512, - CV_IA64_Br1 = 513, - CV_IA64_Br2 = 514, - CV_IA64_Br3 = 515, - CV_IA64_Br4 = 516, - CV_IA64_Br5 = 517, - CV_IA64_Br6 = 518, - CV_IA64_Br7 = 519, - - // Predicate Registers - - CV_IA64_P0 = 704, - CV_IA64_P1 = 705, - CV_IA64_P2 = 706, - CV_IA64_P3 = 707, - CV_IA64_P4 = 708, - CV_IA64_P5 = 709, - CV_IA64_P6 = 710, - CV_IA64_P7 = 711, - CV_IA64_P8 = 712, - CV_IA64_P9 = 713, - CV_IA64_P10 = 714, - CV_IA64_P11 = 715, - CV_IA64_P12 = 716, - CV_IA64_P13 = 717, - CV_IA64_P14 = 718, - CV_IA64_P15 = 719, - CV_IA64_P16 = 720, - CV_IA64_P17 = 721, - CV_IA64_P18 = 722, - CV_IA64_P19 = 723, - CV_IA64_P20 = 724, - CV_IA64_P21 = 725, - CV_IA64_P22 = 726, - CV_IA64_P23 = 727, - CV_IA64_P24 = 728, - CV_IA64_P25 = 729, - CV_IA64_P26 = 730, - CV_IA64_P27 = 731, - CV_IA64_P28 = 732, - CV_IA64_P29 = 733, - CV_IA64_P30 = 734, - CV_IA64_P31 = 735, - CV_IA64_P32 = 736, - CV_IA64_P33 = 737, - CV_IA64_P34 = 738, - CV_IA64_P35 = 739, - CV_IA64_P36 = 740, - CV_IA64_P37 = 741, - CV_IA64_P38 = 742, - CV_IA64_P39 = 743, - CV_IA64_P40 = 744, - CV_IA64_P41 = 745, - CV_IA64_P42 = 746, - CV_IA64_P43 = 747, - CV_IA64_P44 = 748, - CV_IA64_P45 = 749, - CV_IA64_P46 = 750, - CV_IA64_P47 = 751, - CV_IA64_P48 = 752, - CV_IA64_P49 = 753, - CV_IA64_P50 = 754, - CV_IA64_P51 = 755, - CV_IA64_P52 = 756, - CV_IA64_P53 = 757, - CV_IA64_P54 = 758, - CV_IA64_P55 = 759, - CV_IA64_P56 = 760, - CV_IA64_P57 = 761, - CV_IA64_P58 = 762, - CV_IA64_P59 = 763, - CV_IA64_P60 = 764, - CV_IA64_P61 = 765, - CV_IA64_P62 = 766, - CV_IA64_P63 = 767, - - CV_IA64_Preds = 768, - - // Banked General Registers - - CV_IA64_IntH0 = 832, - CV_IA64_IntH1 = 833, - CV_IA64_IntH2 = 834, - CV_IA64_IntH3 = 835, - CV_IA64_IntH4 = 836, - CV_IA64_IntH5 = 837, - CV_IA64_IntH6 = 838, - CV_IA64_IntH7 = 839, - CV_IA64_IntH8 = 840, - CV_IA64_IntH9 = 841, - CV_IA64_IntH10 = 842, - CV_IA64_IntH11 = 843, - CV_IA64_IntH12 = 844, - CV_IA64_IntH13 = 845, - CV_IA64_IntH14 = 846, - CV_IA64_IntH15 = 847, - - // Special Registers - - CV_IA64_Ip = 1016, - CV_IA64_Umask = 1017, - CV_IA64_Cfm = 1018, - CV_IA64_Psr = 1019, - - // Banked General Registers - - CV_IA64_Nats = 1020, - CV_IA64_Nats2 = 1021, - CV_IA64_Nats3 = 1022, - - // General-Purpose Registers - - // Integer registers - CV_IA64_IntR0 = 1024, - CV_IA64_IntR1 = 1025, - CV_IA64_IntR2 = 1026, - CV_IA64_IntR3 = 1027, - CV_IA64_IntR4 = 1028, - CV_IA64_IntR5 = 1029, - CV_IA64_IntR6 = 1030, - CV_IA64_IntR7 = 1031, - CV_IA64_IntR8 = 1032, - CV_IA64_IntR9 = 1033, - CV_IA64_IntR10 = 1034, - CV_IA64_IntR11 = 1035, - CV_IA64_IntR12 = 1036, - CV_IA64_IntR13 = 1037, - CV_IA64_IntR14 = 1038, - CV_IA64_IntR15 = 1039, - CV_IA64_IntR16 = 1040, - CV_IA64_IntR17 = 1041, - CV_IA64_IntR18 = 1042, - CV_IA64_IntR19 = 1043, - CV_IA64_IntR20 = 1044, - CV_IA64_IntR21 = 1045, - CV_IA64_IntR22 = 1046, - CV_IA64_IntR23 = 1047, - CV_IA64_IntR24 = 1048, - CV_IA64_IntR25 = 1049, - CV_IA64_IntR26 = 1050, - CV_IA64_IntR27 = 1051, - CV_IA64_IntR28 = 1052, - CV_IA64_IntR29 = 1053, - CV_IA64_IntR30 = 1054, - CV_IA64_IntR31 = 1055, - - // Register Stack - CV_IA64_IntR32 = 1056, - CV_IA64_IntR33 = 1057, - CV_IA64_IntR34 = 1058, - CV_IA64_IntR35 = 1059, - CV_IA64_IntR36 = 1060, - CV_IA64_IntR37 = 1061, - CV_IA64_IntR38 = 1062, - CV_IA64_IntR39 = 1063, - CV_IA64_IntR40 = 1064, - CV_IA64_IntR41 = 1065, - CV_IA64_IntR42 = 1066, - CV_IA64_IntR43 = 1067, - CV_IA64_IntR44 = 1068, - CV_IA64_IntR45 = 1069, - CV_IA64_IntR46 = 1070, - CV_IA64_IntR47 = 1071, - CV_IA64_IntR48 = 1072, - CV_IA64_IntR49 = 1073, - CV_IA64_IntR50 = 1074, - CV_IA64_IntR51 = 1075, - CV_IA64_IntR52 = 1076, - CV_IA64_IntR53 = 1077, - CV_IA64_IntR54 = 1078, - CV_IA64_IntR55 = 1079, - CV_IA64_IntR56 = 1080, - CV_IA64_IntR57 = 1081, - CV_IA64_IntR58 = 1082, - CV_IA64_IntR59 = 1083, - CV_IA64_IntR60 = 1084, - CV_IA64_IntR61 = 1085, - CV_IA64_IntR62 = 1086, - CV_IA64_IntR63 = 1087, - CV_IA64_IntR64 = 1088, - CV_IA64_IntR65 = 1089, - CV_IA64_IntR66 = 1090, - CV_IA64_IntR67 = 1091, - CV_IA64_IntR68 = 1092, - CV_IA64_IntR69 = 1093, - CV_IA64_IntR70 = 1094, - CV_IA64_IntR71 = 1095, - CV_IA64_IntR72 = 1096, - CV_IA64_IntR73 = 1097, - CV_IA64_IntR74 = 1098, - CV_IA64_IntR75 = 1099, - CV_IA64_IntR76 = 1100, - CV_IA64_IntR77 = 1101, - CV_IA64_IntR78 = 1102, - CV_IA64_IntR79 = 1103, - CV_IA64_IntR80 = 1104, - CV_IA64_IntR81 = 1105, - CV_IA64_IntR82 = 1106, - CV_IA64_IntR83 = 1107, - CV_IA64_IntR84 = 1108, - CV_IA64_IntR85 = 1109, - CV_IA64_IntR86 = 1110, - CV_IA64_IntR87 = 1111, - CV_IA64_IntR88 = 1112, - CV_IA64_IntR89 = 1113, - CV_IA64_IntR90 = 1114, - CV_IA64_IntR91 = 1115, - CV_IA64_IntR92 = 1116, - CV_IA64_IntR93 = 1117, - CV_IA64_IntR94 = 1118, - CV_IA64_IntR95 = 1119, - CV_IA64_IntR96 = 1120, - CV_IA64_IntR97 = 1121, - CV_IA64_IntR98 = 1122, - CV_IA64_IntR99 = 1123, - CV_IA64_IntR100 = 1124, - CV_IA64_IntR101 = 1125, - CV_IA64_IntR102 = 1126, - CV_IA64_IntR103 = 1127, - CV_IA64_IntR104 = 1128, - CV_IA64_IntR105 = 1129, - CV_IA64_IntR106 = 1130, - CV_IA64_IntR107 = 1131, - CV_IA64_IntR108 = 1132, - CV_IA64_IntR109 = 1133, - CV_IA64_IntR110 = 1134, - CV_IA64_IntR111 = 1135, - CV_IA64_IntR112 = 1136, - CV_IA64_IntR113 = 1137, - CV_IA64_IntR114 = 1138, - CV_IA64_IntR115 = 1139, - CV_IA64_IntR116 = 1140, - CV_IA64_IntR117 = 1141, - CV_IA64_IntR118 = 1142, - CV_IA64_IntR119 = 1143, - CV_IA64_IntR120 = 1144, - CV_IA64_IntR121 = 1145, - CV_IA64_IntR122 = 1146, - CV_IA64_IntR123 = 1147, - CV_IA64_IntR124 = 1148, - CV_IA64_IntR125 = 1149, - CV_IA64_IntR126 = 1150, - CV_IA64_IntR127 = 1151, - - // Floating-Point Registers - - // Low Floating Point Registers - CV_IA64_FltF0 = 2048, - CV_IA64_FltF1 = 2049, - CV_IA64_FltF2 = 2050, - CV_IA64_FltF3 = 2051, - CV_IA64_FltF4 = 2052, - CV_IA64_FltF5 = 2053, - CV_IA64_FltF6 = 2054, - CV_IA64_FltF7 = 2055, - CV_IA64_FltF8 = 2056, - CV_IA64_FltF9 = 2057, - CV_IA64_FltF10 = 2058, - CV_IA64_FltF11 = 2059, - CV_IA64_FltF12 = 2060, - CV_IA64_FltF13 = 2061, - CV_IA64_FltF14 = 2062, - CV_IA64_FltF15 = 2063, - CV_IA64_FltF16 = 2064, - CV_IA64_FltF17 = 2065, - CV_IA64_FltF18 = 2066, - CV_IA64_FltF19 = 2067, - CV_IA64_FltF20 = 2068, - CV_IA64_FltF21 = 2069, - CV_IA64_FltF22 = 2070, - CV_IA64_FltF23 = 2071, - CV_IA64_FltF24 = 2072, - CV_IA64_FltF25 = 2073, - CV_IA64_FltF26 = 2074, - CV_IA64_FltF27 = 2075, - CV_IA64_FltF28 = 2076, - CV_IA64_FltF29 = 2077, - CV_IA64_FltF30 = 2078, - CV_IA64_FltF31 = 2079, - - // High Floating Point Registers - CV_IA64_FltF32 = 2080, - CV_IA64_FltF33 = 2081, - CV_IA64_FltF34 = 2082, - CV_IA64_FltF35 = 2083, - CV_IA64_FltF36 = 2084, - CV_IA64_FltF37 = 2085, - CV_IA64_FltF38 = 2086, - CV_IA64_FltF39 = 2087, - CV_IA64_FltF40 = 2088, - CV_IA64_FltF41 = 2089, - CV_IA64_FltF42 = 2090, - CV_IA64_FltF43 = 2091, - CV_IA64_FltF44 = 2092, - CV_IA64_FltF45 = 2093, - CV_IA64_FltF46 = 2094, - CV_IA64_FltF47 = 2095, - CV_IA64_FltF48 = 2096, - CV_IA64_FltF49 = 2097, - CV_IA64_FltF50 = 2098, - CV_IA64_FltF51 = 2099, - CV_IA64_FltF52 = 2100, - CV_IA64_FltF53 = 2101, - CV_IA64_FltF54 = 2102, - CV_IA64_FltF55 = 2103, - CV_IA64_FltF56 = 2104, - CV_IA64_FltF57 = 2105, - CV_IA64_FltF58 = 2106, - CV_IA64_FltF59 = 2107, - CV_IA64_FltF60 = 2108, - CV_IA64_FltF61 = 2109, - CV_IA64_FltF62 = 2110, - CV_IA64_FltF63 = 2111, - CV_IA64_FltF64 = 2112, - CV_IA64_FltF65 = 2113, - CV_IA64_FltF66 = 2114, - CV_IA64_FltF67 = 2115, - CV_IA64_FltF68 = 2116, - CV_IA64_FltF69 = 2117, - CV_IA64_FltF70 = 2118, - CV_IA64_FltF71 = 2119, - CV_IA64_FltF72 = 2120, - CV_IA64_FltF73 = 2121, - CV_IA64_FltF74 = 2122, - CV_IA64_FltF75 = 2123, - CV_IA64_FltF76 = 2124, - CV_IA64_FltF77 = 2125, - CV_IA64_FltF78 = 2126, - CV_IA64_FltF79 = 2127, - CV_IA64_FltF80 = 2128, - CV_IA64_FltF81 = 2129, - CV_IA64_FltF82 = 2130, - CV_IA64_FltF83 = 2131, - CV_IA64_FltF84 = 2132, - CV_IA64_FltF85 = 2133, - CV_IA64_FltF86 = 2134, - CV_IA64_FltF87 = 2135, - CV_IA64_FltF88 = 2136, - CV_IA64_FltF89 = 2137, - CV_IA64_FltF90 = 2138, - CV_IA64_FltF91 = 2139, - CV_IA64_FltF92 = 2140, - CV_IA64_FltF93 = 2141, - CV_IA64_FltF94 = 2142, - CV_IA64_FltF95 = 2143, - CV_IA64_FltF96 = 2144, - CV_IA64_FltF97 = 2145, - CV_IA64_FltF98 = 2146, - CV_IA64_FltF99 = 2147, - CV_IA64_FltF100 = 2148, - CV_IA64_FltF101 = 2149, - CV_IA64_FltF102 = 2150, - CV_IA64_FltF103 = 2151, - CV_IA64_FltF104 = 2152, - CV_IA64_FltF105 = 2153, - CV_IA64_FltF106 = 2154, - CV_IA64_FltF107 = 2155, - CV_IA64_FltF108 = 2156, - CV_IA64_FltF109 = 2157, - CV_IA64_FltF110 = 2158, - CV_IA64_FltF111 = 2159, - CV_IA64_FltF112 = 2160, - CV_IA64_FltF113 = 2161, - CV_IA64_FltF114 = 2162, - CV_IA64_FltF115 = 2163, - CV_IA64_FltF116 = 2164, - CV_IA64_FltF117 = 2165, - CV_IA64_FltF118 = 2166, - CV_IA64_FltF119 = 2167, - CV_IA64_FltF120 = 2168, - CV_IA64_FltF121 = 2169, - CV_IA64_FltF122 = 2170, - CV_IA64_FltF123 = 2171, - CV_IA64_FltF124 = 2172, - CV_IA64_FltF125 = 2173, - CV_IA64_FltF126 = 2174, - CV_IA64_FltF127 = 2175, - - // Application Registers - - CV_IA64_ApKR0 = 3072, - CV_IA64_ApKR1 = 3073, - CV_IA64_ApKR2 = 3074, - CV_IA64_ApKR3 = 3075, - CV_IA64_ApKR4 = 3076, - CV_IA64_ApKR5 = 3077, - CV_IA64_ApKR6 = 3078, - CV_IA64_ApKR7 = 3079, - CV_IA64_AR8 = 3080, - CV_IA64_AR9 = 3081, - CV_IA64_AR10 = 3082, - CV_IA64_AR11 = 3083, - CV_IA64_AR12 = 3084, - CV_IA64_AR13 = 3085, - CV_IA64_AR14 = 3086, - CV_IA64_AR15 = 3087, - CV_IA64_RsRSC = 3088, - CV_IA64_RsBSP = 3089, - CV_IA64_RsBSPSTORE = 3090, - CV_IA64_RsRNAT = 3091, - CV_IA64_AR20 = 3092, - CV_IA64_StFCR = 3093, - CV_IA64_AR22 = 3094, - CV_IA64_AR23 = 3095, - CV_IA64_EFLAG = 3096, - CV_IA64_CSD = 3097, - CV_IA64_SSD = 3098, - CV_IA64_CFLG = 3099, - CV_IA64_StFSR = 3100, - CV_IA64_StFIR = 3101, - CV_IA64_StFDR = 3102, - CV_IA64_AR31 = 3103, - CV_IA64_ApCCV = 3104, - CV_IA64_AR33 = 3105, - CV_IA64_AR34 = 3106, - CV_IA64_AR35 = 3107, - CV_IA64_ApUNAT = 3108, - CV_IA64_AR37 = 3109, - CV_IA64_AR38 = 3110, - CV_IA64_AR39 = 3111, - CV_IA64_StFPSR = 3112, - CV_IA64_AR41 = 3113, - CV_IA64_AR42 = 3114, - CV_IA64_AR43 = 3115, - CV_IA64_ApITC = 3116, - CV_IA64_AR45 = 3117, - CV_IA64_AR46 = 3118, - CV_IA64_AR47 = 3119, - CV_IA64_AR48 = 3120, - CV_IA64_AR49 = 3121, - CV_IA64_AR50 = 3122, - CV_IA64_AR51 = 3123, - CV_IA64_AR52 = 3124, - CV_IA64_AR53 = 3125, - CV_IA64_AR54 = 3126, - CV_IA64_AR55 = 3127, - CV_IA64_AR56 = 3128, - CV_IA64_AR57 = 3129, - CV_IA64_AR58 = 3130, - CV_IA64_AR59 = 3131, - CV_IA64_AR60 = 3132, - CV_IA64_AR61 = 3133, - CV_IA64_AR62 = 3134, - CV_IA64_AR63 = 3135, - CV_IA64_RsPFS = 3136, - CV_IA64_ApLC = 3137, - CV_IA64_ApEC = 3138, - CV_IA64_AR67 = 3139, - CV_IA64_AR68 = 3140, - CV_IA64_AR69 = 3141, - CV_IA64_AR70 = 3142, - CV_IA64_AR71 = 3143, - CV_IA64_AR72 = 3144, - CV_IA64_AR73 = 3145, - CV_IA64_AR74 = 3146, - CV_IA64_AR75 = 3147, - CV_IA64_AR76 = 3148, - CV_IA64_AR77 = 3149, - CV_IA64_AR78 = 3150, - CV_IA64_AR79 = 3151, - CV_IA64_AR80 = 3152, - CV_IA64_AR81 = 3153, - CV_IA64_AR82 = 3154, - CV_IA64_AR83 = 3155, - CV_IA64_AR84 = 3156, - CV_IA64_AR85 = 3157, - CV_IA64_AR86 = 3158, - CV_IA64_AR87 = 3159, - CV_IA64_AR88 = 3160, - CV_IA64_AR89 = 3161, - CV_IA64_AR90 = 3162, - CV_IA64_AR91 = 3163, - CV_IA64_AR92 = 3164, - CV_IA64_AR93 = 3165, - CV_IA64_AR94 = 3166, - CV_IA64_AR95 = 3167, - CV_IA64_AR96 = 3168, - CV_IA64_AR97 = 3169, - CV_IA64_AR98 = 3170, - CV_IA64_AR99 = 3171, - CV_IA64_AR100 = 3172, - CV_IA64_AR101 = 3173, - CV_IA64_AR102 = 3174, - CV_IA64_AR103 = 3175, - CV_IA64_AR104 = 3176, - CV_IA64_AR105 = 3177, - CV_IA64_AR106 = 3178, - CV_IA64_AR107 = 3179, - CV_IA64_AR108 = 3180, - CV_IA64_AR109 = 3181, - CV_IA64_AR110 = 3182, - CV_IA64_AR111 = 3183, - CV_IA64_AR112 = 3184, - CV_IA64_AR113 = 3185, - CV_IA64_AR114 = 3186, - CV_IA64_AR115 = 3187, - CV_IA64_AR116 = 3188, - CV_IA64_AR117 = 3189, - CV_IA64_AR118 = 3190, - CV_IA64_AR119 = 3191, - CV_IA64_AR120 = 3192, - CV_IA64_AR121 = 3193, - CV_IA64_AR122 = 3194, - CV_IA64_AR123 = 3195, - CV_IA64_AR124 = 3196, - CV_IA64_AR125 = 3197, - CV_IA64_AR126 = 3198, - CV_IA64_AR127 = 3199, - - // CPUID Registers - - CV_IA64_CPUID0 = 3328, - CV_IA64_CPUID1 = 3329, - CV_IA64_CPUID2 = 3330, - CV_IA64_CPUID3 = 3331, - CV_IA64_CPUID4 = 3332, - - // Control Registers - - CV_IA64_ApDCR = 4096, - CV_IA64_ApITM = 4097, - CV_IA64_ApIVA = 4098, - CV_IA64_CR3 = 4099, - CV_IA64_CR4 = 4100, - CV_IA64_CR5 = 4101, - CV_IA64_CR6 = 4102, - CV_IA64_CR7 = 4103, - CV_IA64_ApPTA = 4104, - CV_IA64_ApGPTA = 4105, - CV_IA64_CR10 = 4106, - CV_IA64_CR11 = 4107, - CV_IA64_CR12 = 4108, - CV_IA64_CR13 = 4109, - CV_IA64_CR14 = 4110, - CV_IA64_CR15 = 4111, - CV_IA64_StIPSR = 4112, - CV_IA64_StISR = 4113, - CV_IA64_CR18 = 4114, - CV_IA64_StIIP = 4115, - CV_IA64_StIFA = 4116, - CV_IA64_StITIR = 4117, - CV_IA64_StIIPA = 4118, - CV_IA64_StIFS = 4119, - CV_IA64_StIIM = 4120, - CV_IA64_StIHA = 4121, - CV_IA64_CR26 = 4122, - CV_IA64_CR27 = 4123, - CV_IA64_CR28 = 4124, - CV_IA64_CR29 = 4125, - CV_IA64_CR30 = 4126, - CV_IA64_CR31 = 4127, - CV_IA64_CR32 = 4128, - CV_IA64_CR33 = 4129, - CV_IA64_CR34 = 4130, - CV_IA64_CR35 = 4131, - CV_IA64_CR36 = 4132, - CV_IA64_CR37 = 4133, - CV_IA64_CR38 = 4134, - CV_IA64_CR39 = 4135, - CV_IA64_CR40 = 4136, - CV_IA64_CR41 = 4137, - CV_IA64_CR42 = 4138, - CV_IA64_CR43 = 4139, - CV_IA64_CR44 = 4140, - CV_IA64_CR45 = 4141, - CV_IA64_CR46 = 4142, - CV_IA64_CR47 = 4143, - CV_IA64_CR48 = 4144, - CV_IA64_CR49 = 4145, - CV_IA64_CR50 = 4146, - CV_IA64_CR51 = 4147, - CV_IA64_CR52 = 4148, - CV_IA64_CR53 = 4149, - CV_IA64_CR54 = 4150, - CV_IA64_CR55 = 4151, - CV_IA64_CR56 = 4152, - CV_IA64_CR57 = 4153, - CV_IA64_CR58 = 4154, - CV_IA64_CR59 = 4155, - CV_IA64_CR60 = 4156, - CV_IA64_CR61 = 4157, - CV_IA64_CR62 = 4158, - CV_IA64_CR63 = 4159, - CV_IA64_SaLID = 4160, - CV_IA64_SaIVR = 4161, - CV_IA64_SaTPR = 4162, - CV_IA64_SaEOI = 4163, - CV_IA64_SaIRR0 = 4164, - CV_IA64_SaIRR1 = 4165, - CV_IA64_SaIRR2 = 4166, - CV_IA64_SaIRR3 = 4167, - CV_IA64_SaITV = 4168, - CV_IA64_SaPMV = 4169, - CV_IA64_SaCMCV = 4170, - CV_IA64_CR75 = 4171, - CV_IA64_CR76 = 4172, - CV_IA64_CR77 = 4173, - CV_IA64_CR78 = 4174, - CV_IA64_CR79 = 4175, - CV_IA64_SaLRR0 = 4176, - CV_IA64_SaLRR1 = 4177, - CV_IA64_CR82 = 4178, - CV_IA64_CR83 = 4179, - CV_IA64_CR84 = 4180, - CV_IA64_CR85 = 4181, - CV_IA64_CR86 = 4182, - CV_IA64_CR87 = 4183, - CV_IA64_CR88 = 4184, - CV_IA64_CR89 = 4185, - CV_IA64_CR90 = 4186, - CV_IA64_CR91 = 4187, - CV_IA64_CR92 = 4188, - CV_IA64_CR93 = 4189, - CV_IA64_CR94 = 4190, - CV_IA64_CR95 = 4191, - CV_IA64_CR96 = 4192, - CV_IA64_CR97 = 4193, - CV_IA64_CR98 = 4194, - CV_IA64_CR99 = 4195, - CV_IA64_CR100 = 4196, - CV_IA64_CR101 = 4197, - CV_IA64_CR102 = 4198, - CV_IA64_CR103 = 4199, - CV_IA64_CR104 = 4200, - CV_IA64_CR105 = 4201, - CV_IA64_CR106 = 4202, - CV_IA64_CR107 = 4203, - CV_IA64_CR108 = 4204, - CV_IA64_CR109 = 4205, - CV_IA64_CR110 = 4206, - CV_IA64_CR111 = 4207, - CV_IA64_CR112 = 4208, - CV_IA64_CR113 = 4209, - CV_IA64_CR114 = 4210, - CV_IA64_CR115 = 4211, - CV_IA64_CR116 = 4212, - CV_IA64_CR117 = 4213, - CV_IA64_CR118 = 4214, - CV_IA64_CR119 = 4215, - CV_IA64_CR120 = 4216, - CV_IA64_CR121 = 4217, - CV_IA64_CR122 = 4218, - CV_IA64_CR123 = 4219, - CV_IA64_CR124 = 4220, - CV_IA64_CR125 = 4221, - CV_IA64_CR126 = 4222, - CV_IA64_CR127 = 4223, - - // Protection Key Registers - - CV_IA64_Pkr0 = 5120, - CV_IA64_Pkr1 = 5121, - CV_IA64_Pkr2 = 5122, - CV_IA64_Pkr3 = 5123, - CV_IA64_Pkr4 = 5124, - CV_IA64_Pkr5 = 5125, - CV_IA64_Pkr6 = 5126, - CV_IA64_Pkr7 = 5127, - CV_IA64_Pkr8 = 5128, - CV_IA64_Pkr9 = 5129, - CV_IA64_Pkr10 = 5130, - CV_IA64_Pkr11 = 5131, - CV_IA64_Pkr12 = 5132, - CV_IA64_Pkr13 = 5133, - CV_IA64_Pkr14 = 5134, - CV_IA64_Pkr15 = 5135, - - // Region Registers - - CV_IA64_Rr0 = 6144, - CV_IA64_Rr1 = 6145, - CV_IA64_Rr2 = 6146, - CV_IA64_Rr3 = 6147, - CV_IA64_Rr4 = 6148, - CV_IA64_Rr5 = 6149, - CV_IA64_Rr6 = 6150, - CV_IA64_Rr7 = 6151, - - // Performance Monitor Data Registers - - CV_IA64_PFD0 = 7168, - CV_IA64_PFD1 = 7169, - CV_IA64_PFD2 = 7170, - CV_IA64_PFD3 = 7171, - CV_IA64_PFD4 = 7172, - CV_IA64_PFD5 = 7173, - CV_IA64_PFD6 = 7174, - CV_IA64_PFD7 = 7175, - CV_IA64_PFD8 = 7176, - CV_IA64_PFD9 = 7177, - CV_IA64_PFD10 = 7178, - CV_IA64_PFD11 = 7179, - CV_IA64_PFD12 = 7180, - CV_IA64_PFD13 = 7181, - CV_IA64_PFD14 = 7182, - CV_IA64_PFD15 = 7183, - CV_IA64_PFD16 = 7184, - CV_IA64_PFD17 = 7185, - - // Performance Monitor Config Registers - - CV_IA64_PFC0 = 7424, - CV_IA64_PFC1 = 7425, - CV_IA64_PFC2 = 7426, - CV_IA64_PFC3 = 7427, - CV_IA64_PFC4 = 7428, - CV_IA64_PFC5 = 7429, - CV_IA64_PFC6 = 7430, - CV_IA64_PFC7 = 7431, - CV_IA64_PFC8 = 7432, - CV_IA64_PFC9 = 7433, - CV_IA64_PFC10 = 7434, - CV_IA64_PFC11 = 7435, - CV_IA64_PFC12 = 7436, - CV_IA64_PFC13 = 7437, - CV_IA64_PFC14 = 7438, - CV_IA64_PFC15 = 7439, - - // Instruction Translation Registers - - CV_IA64_TrI0 = 8192, - CV_IA64_TrI1 = 8193, - CV_IA64_TrI2 = 8194, - CV_IA64_TrI3 = 8195, - CV_IA64_TrI4 = 8196, - CV_IA64_TrI5 = 8197, - CV_IA64_TrI6 = 8198, - CV_IA64_TrI7 = 8199, - - // Data Translation Registers - - CV_IA64_TrD0 = 8320, - CV_IA64_TrD1 = 8321, - CV_IA64_TrD2 = 8322, - CV_IA64_TrD3 = 8323, - CV_IA64_TrD4 = 8324, - CV_IA64_TrD5 = 8325, - CV_IA64_TrD6 = 8326, - CV_IA64_TrD7 = 8327, - - // Instruction Breakpoint Registers - - CV_IA64_DbI0 = 8448, - CV_IA64_DbI1 = 8449, - CV_IA64_DbI2 = 8450, - CV_IA64_DbI3 = 8451, - CV_IA64_DbI4 = 8452, - CV_IA64_DbI5 = 8453, - CV_IA64_DbI6 = 8454, - CV_IA64_DbI7 = 8455, - - // Data Breakpoint Registers - - CV_IA64_DbD0 = 8576, - CV_IA64_DbD1 = 8577, - CV_IA64_DbD2 = 8578, - CV_IA64_DbD3 = 8579, - CV_IA64_DbD4 = 8580, - CV_IA64_DbD5 = 8581, - CV_IA64_DbD6 = 8582, - CV_IA64_DbD7 = 8583, - - // - // Register set for the TriCore processor. - // - - CV_TRI_NOREG = CV_REG_NONE, - - // General Purpose Data Registers - - CV_TRI_D0 = 10, - CV_TRI_D1 = 11, - CV_TRI_D2 = 12, - CV_TRI_D3 = 13, - CV_TRI_D4 = 14, - CV_TRI_D5 = 15, - CV_TRI_D6 = 16, - CV_TRI_D7 = 17, - CV_TRI_D8 = 18, - CV_TRI_D9 = 19, - CV_TRI_D10 = 20, - CV_TRI_D11 = 21, - CV_TRI_D12 = 22, - CV_TRI_D13 = 23, - CV_TRI_D14 = 24, - CV_TRI_D15 = 25, - - // General Purpose Address Registers - - CV_TRI_A0 = 26, - CV_TRI_A1 = 27, - CV_TRI_A2 = 28, - CV_TRI_A3 = 29, - CV_TRI_A4 = 30, - CV_TRI_A5 = 31, - CV_TRI_A6 = 32, - CV_TRI_A7 = 33, - CV_TRI_A8 = 34, - CV_TRI_A9 = 35, - CV_TRI_A10 = 36, - CV_TRI_A11 = 37, - CV_TRI_A12 = 38, - CV_TRI_A13 = 39, - CV_TRI_A14 = 40, - CV_TRI_A15 = 41, - - // Extended (64-bit) data registers - - CV_TRI_E0 = 42, - CV_TRI_E2 = 43, - CV_TRI_E4 = 44, - CV_TRI_E6 = 45, - CV_TRI_E8 = 46, - CV_TRI_E10 = 47, - CV_TRI_E12 = 48, - CV_TRI_E14 = 49, - - // Extended (64-bit) address registers - - CV_TRI_EA0 = 50, - CV_TRI_EA2 = 51, - CV_TRI_EA4 = 52, - CV_TRI_EA6 = 53, - CV_TRI_EA8 = 54, - CV_TRI_EA10 = 55, - CV_TRI_EA12 = 56, - CV_TRI_EA14 = 57, - - CV_TRI_PSW = 58, - CV_TRI_PCXI = 59, - CV_TRI_PC = 60, - CV_TRI_FCX = 61, - CV_TRI_LCX = 62, - CV_TRI_ISP = 63, - CV_TRI_ICR = 64, - CV_TRI_BIV = 65, - CV_TRI_BTV = 66, - CV_TRI_SYSCON = 67, - CV_TRI_DPRx_0 = 68, - CV_TRI_DPRx_1 = 69, - CV_TRI_DPRx_2 = 70, - CV_TRI_DPRx_3 = 71, - CV_TRI_CPRx_0 = 68, - CV_TRI_CPRx_1 = 69, - CV_TRI_CPRx_2 = 70, - CV_TRI_CPRx_3 = 71, - CV_TRI_DPMx_0 = 68, - CV_TRI_DPMx_1 = 69, - CV_TRI_DPMx_2 = 70, - CV_TRI_DPMx_3 = 71, - CV_TRI_CPMx_0 = 68, - CV_TRI_CPMx_1 = 69, - CV_TRI_CPMx_2 = 70, - CV_TRI_CPMx_3 = 71, - CV_TRI_DBGSSR = 72, - CV_TRI_EXEVT = 73, - CV_TRI_SWEVT = 74, - CV_TRI_CREVT = 75, - CV_TRI_TRnEVT = 76, - CV_TRI_MMUCON = 77, - CV_TRI_ASI = 78, - CV_TRI_TVA = 79, - CV_TRI_TPA = 80, - CV_TRI_TPX = 81, - CV_TRI_TFA = 82, - - // - // Register set for the AM33 and related processors. - // - - CV_AM33_NOREG = CV_REG_NONE, - - // "Extended" (general purpose integer) registers - CV_AM33_E0 = 10, - CV_AM33_E1 = 11, - CV_AM33_E2 = 12, - CV_AM33_E3 = 13, - CV_AM33_E4 = 14, - CV_AM33_E5 = 15, - CV_AM33_E6 = 16, - CV_AM33_E7 = 17, - - // Address registers - CV_AM33_A0 = 20, - CV_AM33_A1 = 21, - CV_AM33_A2 = 22, - CV_AM33_A3 = 23, - - // Integer data registers - CV_AM33_D0 = 30, - CV_AM33_D1 = 31, - CV_AM33_D2 = 32, - CV_AM33_D3 = 33, - - // (Single-precision) floating-point registers - CV_AM33_FS0 = 40, - CV_AM33_FS1 = 41, - CV_AM33_FS2 = 42, - CV_AM33_FS3 = 43, - CV_AM33_FS4 = 44, - CV_AM33_FS5 = 45, - CV_AM33_FS6 = 46, - CV_AM33_FS7 = 47, - CV_AM33_FS8 = 48, - CV_AM33_FS9 = 49, - CV_AM33_FS10 = 50, - CV_AM33_FS11 = 51, - CV_AM33_FS12 = 52, - CV_AM33_FS13 = 53, - CV_AM33_FS14 = 54, - CV_AM33_FS15 = 55, - CV_AM33_FS16 = 56, - CV_AM33_FS17 = 57, - CV_AM33_FS18 = 58, - CV_AM33_FS19 = 59, - CV_AM33_FS20 = 60, - CV_AM33_FS21 = 61, - CV_AM33_FS22 = 62, - CV_AM33_FS23 = 63, - CV_AM33_FS24 = 64, - CV_AM33_FS25 = 65, - CV_AM33_FS26 = 66, - CV_AM33_FS27 = 67, - CV_AM33_FS28 = 68, - CV_AM33_FS29 = 69, - CV_AM33_FS30 = 70, - CV_AM33_FS31 = 71, - - // Special purpose registers - - // Stack pointer - CV_AM33_SP = 80, - - // Program counter - CV_AM33_PC = 81, - - // Multiply-divide/accumulate registers - CV_AM33_MDR = 82, - CV_AM33_MDRQ = 83, - CV_AM33_MCRH = 84, - CV_AM33_MCRL = 85, - CV_AM33_MCVF = 86, - - // CPU status words - CV_AM33_EPSW = 87, - CV_AM33_FPCR = 88, - - // Loop buffer registers - CV_AM33_LIR = 89, - CV_AM33_LAR = 90, - - // - // Register set for the Mitsubishi M32R - // - - CV_M32R_NOREG = CV_REG_NONE, - - CV_M32R_R0 = 10, - CV_M32R_R1 = 11, - CV_M32R_R2 = 12, - CV_M32R_R3 = 13, - CV_M32R_R4 = 14, - CV_M32R_R5 = 15, - CV_M32R_R6 = 16, - CV_M32R_R7 = 17, - CV_M32R_R8 = 18, - CV_M32R_R9 = 19, - CV_M32R_R10 = 20, - CV_M32R_R11 = 21, - CV_M32R_R12 = 22, // Gloabal Pointer, if used - CV_M32R_R13 = 23, // Frame Pointer, if allocated - CV_M32R_R14 = 24, // Link Register - CV_M32R_R15 = 25, // Stack Pointer - CV_M32R_PSW = 26, // Preocessor Status Register - CV_M32R_CBR = 27, // Condition Bit Register - CV_M32R_SPI = 28, // Interrupt Stack Pointer - CV_M32R_SPU = 29, // User Stack Pointer - CV_M32R_SPO = 30, // OS Stack Pointer - CV_M32R_BPC = 31, // Backup Program Counter - CV_M32R_ACHI = 32, // Accumulator High - CV_M32R_ACLO = 33, // Accumulator Low - CV_M32R_PC = 34, // Program Counter - - // - // Register set for the SuperH SHMedia processor including compact - // mode - // - - // Integer - 64 bit general registers - CV_SHMEDIA_NOREG = CV_REG_NONE, - CV_SHMEDIA_R0 = 10, - CV_SHMEDIA_R1 = 11, - CV_SHMEDIA_R2 = 12, - CV_SHMEDIA_R3 = 13, - CV_SHMEDIA_R4 = 14, - CV_SHMEDIA_R5 = 15, - CV_SHMEDIA_R6 = 16, - CV_SHMEDIA_R7 = 17, - CV_SHMEDIA_R8 = 18, - CV_SHMEDIA_R9 = 19, - CV_SHMEDIA_R10 = 20, - CV_SHMEDIA_R11 = 21, - CV_SHMEDIA_R12 = 22, - CV_SHMEDIA_R13 = 23, - CV_SHMEDIA_R14 = 24, - CV_SHMEDIA_R15 = 25, - CV_SHMEDIA_R16 = 26, - CV_SHMEDIA_R17 = 27, - CV_SHMEDIA_R18 = 28, - CV_SHMEDIA_R19 = 29, - CV_SHMEDIA_R20 = 30, - CV_SHMEDIA_R21 = 31, - CV_SHMEDIA_R22 = 32, - CV_SHMEDIA_R23 = 33, - CV_SHMEDIA_R24 = 34, - CV_SHMEDIA_R25 = 35, - CV_SHMEDIA_R26 = 36, - CV_SHMEDIA_R27 = 37, - CV_SHMEDIA_R28 = 38, - CV_SHMEDIA_R29 = 39, - CV_SHMEDIA_R30 = 40, - CV_SHMEDIA_R31 = 41, - CV_SHMEDIA_R32 = 42, - CV_SHMEDIA_R33 = 43, - CV_SHMEDIA_R34 = 44, - CV_SHMEDIA_R35 = 45, - CV_SHMEDIA_R36 = 46, - CV_SHMEDIA_R37 = 47, - CV_SHMEDIA_R38 = 48, - CV_SHMEDIA_R39 = 49, - CV_SHMEDIA_R40 = 50, - CV_SHMEDIA_R41 = 51, - CV_SHMEDIA_R42 = 52, - CV_SHMEDIA_R43 = 53, - CV_SHMEDIA_R44 = 54, - CV_SHMEDIA_R45 = 55, - CV_SHMEDIA_R46 = 56, - CV_SHMEDIA_R47 = 57, - CV_SHMEDIA_R48 = 58, - CV_SHMEDIA_R49 = 59, - CV_SHMEDIA_R50 = 60, - CV_SHMEDIA_R51 = 61, - CV_SHMEDIA_R52 = 62, - CV_SHMEDIA_R53 = 63, - CV_SHMEDIA_R54 = 64, - CV_SHMEDIA_R55 = 65, - CV_SHMEDIA_R56 = 66, - CV_SHMEDIA_R57 = 67, - CV_SHMEDIA_R58 = 68, - CV_SHMEDIA_R59 = 69, - CV_SHMEDIA_R60 = 70, - CV_SHMEDIA_R61 = 71, - CV_SHMEDIA_R62 = 72, - CV_SHMEDIA_R63 = 73, - - // Target Registers - 32 bit - CV_SHMEDIA_TR0 = 74, - CV_SHMEDIA_TR1 = 75, - CV_SHMEDIA_TR2 = 76, - CV_SHMEDIA_TR3 = 77, - CV_SHMEDIA_TR4 = 78, - CV_SHMEDIA_TR5 = 79, - CV_SHMEDIA_TR6 = 80, - CV_SHMEDIA_TR7 = 81, - CV_SHMEDIA_TR8 = 82, // future-proof - CV_SHMEDIA_TR9 = 83, // future-proof - CV_SHMEDIA_TR10 = 84, // future-proof - CV_SHMEDIA_TR11 = 85, // future-proof - CV_SHMEDIA_TR12 = 86, // future-proof - CV_SHMEDIA_TR13 = 87, // future-proof - CV_SHMEDIA_TR14 = 88, // future-proof - CV_SHMEDIA_TR15 = 89, // future-proof - - // Single - 32 bit fp registers - CV_SHMEDIA_FR0 = 128, - CV_SHMEDIA_FR1 = 129, - CV_SHMEDIA_FR2 = 130, - CV_SHMEDIA_FR3 = 131, - CV_SHMEDIA_FR4 = 132, - CV_SHMEDIA_FR5 = 133, - CV_SHMEDIA_FR6 = 134, - CV_SHMEDIA_FR7 = 135, - CV_SHMEDIA_FR8 = 136, - CV_SHMEDIA_FR9 = 137, - CV_SHMEDIA_FR10 = 138, - CV_SHMEDIA_FR11 = 139, - CV_SHMEDIA_FR12 = 140, - CV_SHMEDIA_FR13 = 141, - CV_SHMEDIA_FR14 = 142, - CV_SHMEDIA_FR15 = 143, - CV_SHMEDIA_FR16 = 144, - CV_SHMEDIA_FR17 = 145, - CV_SHMEDIA_FR18 = 146, - CV_SHMEDIA_FR19 = 147, - CV_SHMEDIA_FR20 = 148, - CV_SHMEDIA_FR21 = 149, - CV_SHMEDIA_FR22 = 150, - CV_SHMEDIA_FR23 = 151, - CV_SHMEDIA_FR24 = 152, - CV_SHMEDIA_FR25 = 153, - CV_SHMEDIA_FR26 = 154, - CV_SHMEDIA_FR27 = 155, - CV_SHMEDIA_FR28 = 156, - CV_SHMEDIA_FR29 = 157, - CV_SHMEDIA_FR30 = 158, - CV_SHMEDIA_FR31 = 159, - CV_SHMEDIA_FR32 = 160, - CV_SHMEDIA_FR33 = 161, - CV_SHMEDIA_FR34 = 162, - CV_SHMEDIA_FR35 = 163, - CV_SHMEDIA_FR36 = 164, - CV_SHMEDIA_FR37 = 165, - CV_SHMEDIA_FR38 = 166, - CV_SHMEDIA_FR39 = 167, - CV_SHMEDIA_FR40 = 168, - CV_SHMEDIA_FR41 = 169, - CV_SHMEDIA_FR42 = 170, - CV_SHMEDIA_FR43 = 171, - CV_SHMEDIA_FR44 = 172, - CV_SHMEDIA_FR45 = 173, - CV_SHMEDIA_FR46 = 174, - CV_SHMEDIA_FR47 = 175, - CV_SHMEDIA_FR48 = 176, - CV_SHMEDIA_FR49 = 177, - CV_SHMEDIA_FR50 = 178, - CV_SHMEDIA_FR51 = 179, - CV_SHMEDIA_FR52 = 180, - CV_SHMEDIA_FR53 = 181, - CV_SHMEDIA_FR54 = 182, - CV_SHMEDIA_FR55 = 183, - CV_SHMEDIA_FR56 = 184, - CV_SHMEDIA_FR57 = 185, - CV_SHMEDIA_FR58 = 186, - CV_SHMEDIA_FR59 = 187, - CV_SHMEDIA_FR60 = 188, - CV_SHMEDIA_FR61 = 189, - CV_SHMEDIA_FR62 = 190, - CV_SHMEDIA_FR63 = 191, - - // Double - 64 bit synonyms for 32bit fp register pairs - // subtract 128 to find first base single register - CV_SHMEDIA_DR0 = 256, - CV_SHMEDIA_DR2 = 258, - CV_SHMEDIA_DR4 = 260, - CV_SHMEDIA_DR6 = 262, - CV_SHMEDIA_DR8 = 264, - CV_SHMEDIA_DR10 = 266, - CV_SHMEDIA_DR12 = 268, - CV_SHMEDIA_DR14 = 270, - CV_SHMEDIA_DR16 = 272, - CV_SHMEDIA_DR18 = 274, - CV_SHMEDIA_DR20 = 276, - CV_SHMEDIA_DR22 = 278, - CV_SHMEDIA_DR24 = 280, - CV_SHMEDIA_DR26 = 282, - CV_SHMEDIA_DR28 = 284, - CV_SHMEDIA_DR30 = 286, - CV_SHMEDIA_DR32 = 288, - CV_SHMEDIA_DR34 = 290, - CV_SHMEDIA_DR36 = 292, - CV_SHMEDIA_DR38 = 294, - CV_SHMEDIA_DR40 = 296, - CV_SHMEDIA_DR42 = 298, - CV_SHMEDIA_DR44 = 300, - CV_SHMEDIA_DR46 = 302, - CV_SHMEDIA_DR48 = 304, - CV_SHMEDIA_DR50 = 306, - CV_SHMEDIA_DR52 = 308, - CV_SHMEDIA_DR54 = 310, - CV_SHMEDIA_DR56 = 312, - CV_SHMEDIA_DR58 = 314, - CV_SHMEDIA_DR60 = 316, - CV_SHMEDIA_DR62 = 318, - - // Vector - 128 bit synonyms for 32bit fp register quads - // subtract 384 to find first base single register - CV_SHMEDIA_FV0 = 512, - CV_SHMEDIA_FV4 = 516, - CV_SHMEDIA_FV8 = 520, - CV_SHMEDIA_FV12 = 524, - CV_SHMEDIA_FV16 = 528, - CV_SHMEDIA_FV20 = 532, - CV_SHMEDIA_FV24 = 536, - CV_SHMEDIA_FV28 = 540, - CV_SHMEDIA_FV32 = 544, - CV_SHMEDIA_FV36 = 548, - CV_SHMEDIA_FV40 = 552, - CV_SHMEDIA_FV44 = 556, - CV_SHMEDIA_FV48 = 560, - CV_SHMEDIA_FV52 = 564, - CV_SHMEDIA_FV56 = 568, - CV_SHMEDIA_FV60 = 572, - - // Matrix - 512 bit synonyms for 16 adjacent 32bit fp registers - // subtract 896 to find first base single register - CV_SHMEDIA_MTRX0 = 1024, - CV_SHMEDIA_MTRX16 = 1040, - CV_SHMEDIA_MTRX32 = 1056, - CV_SHMEDIA_MTRX48 = 1072, - - // Control - Implementation defined 64bit control registers - CV_SHMEDIA_CR0 = 2000, - CV_SHMEDIA_CR1 = 2001, - CV_SHMEDIA_CR2 = 2002, - CV_SHMEDIA_CR3 = 2003, - CV_SHMEDIA_CR4 = 2004, - CV_SHMEDIA_CR5 = 2005, - CV_SHMEDIA_CR6 = 2006, - CV_SHMEDIA_CR7 = 2007, - CV_SHMEDIA_CR8 = 2008, - CV_SHMEDIA_CR9 = 2009, - CV_SHMEDIA_CR10 = 2010, - CV_SHMEDIA_CR11 = 2011, - CV_SHMEDIA_CR12 = 2012, - CV_SHMEDIA_CR13 = 2013, - CV_SHMEDIA_CR14 = 2014, - CV_SHMEDIA_CR15 = 2015, - CV_SHMEDIA_CR16 = 2016, - CV_SHMEDIA_CR17 = 2017, - CV_SHMEDIA_CR18 = 2018, - CV_SHMEDIA_CR19 = 2019, - CV_SHMEDIA_CR20 = 2020, - CV_SHMEDIA_CR21 = 2021, - CV_SHMEDIA_CR22 = 2022, - CV_SHMEDIA_CR23 = 2023, - CV_SHMEDIA_CR24 = 2024, - CV_SHMEDIA_CR25 = 2025, - CV_SHMEDIA_CR26 = 2026, - CV_SHMEDIA_CR27 = 2027, - CV_SHMEDIA_CR28 = 2028, - CV_SHMEDIA_CR29 = 2029, - CV_SHMEDIA_CR30 = 2030, - CV_SHMEDIA_CR31 = 2031, - CV_SHMEDIA_CR32 = 2032, - CV_SHMEDIA_CR33 = 2033, - CV_SHMEDIA_CR34 = 2034, - CV_SHMEDIA_CR35 = 2035, - CV_SHMEDIA_CR36 = 2036, - CV_SHMEDIA_CR37 = 2037, - CV_SHMEDIA_CR38 = 2038, - CV_SHMEDIA_CR39 = 2039, - CV_SHMEDIA_CR40 = 2040, - CV_SHMEDIA_CR41 = 2041, - CV_SHMEDIA_CR42 = 2042, - CV_SHMEDIA_CR43 = 2043, - CV_SHMEDIA_CR44 = 2044, - CV_SHMEDIA_CR45 = 2045, - CV_SHMEDIA_CR46 = 2046, - CV_SHMEDIA_CR47 = 2047, - CV_SHMEDIA_CR48 = 2048, - CV_SHMEDIA_CR49 = 2049, - CV_SHMEDIA_CR50 = 2050, - CV_SHMEDIA_CR51 = 2051, - CV_SHMEDIA_CR52 = 2052, - CV_SHMEDIA_CR53 = 2053, - CV_SHMEDIA_CR54 = 2054, - CV_SHMEDIA_CR55 = 2055, - CV_SHMEDIA_CR56 = 2056, - CV_SHMEDIA_CR57 = 2057, - CV_SHMEDIA_CR58 = 2058, - CV_SHMEDIA_CR59 = 2059, - CV_SHMEDIA_CR60 = 2060, - CV_SHMEDIA_CR61 = 2061, - CV_SHMEDIA_CR62 = 2062, - CV_SHMEDIA_CR63 = 2063, - - CV_SHMEDIA_FPSCR = 2064, - - // Compact mode synonyms - CV_SHMEDIA_GBR = CV_SHMEDIA_R16, - CV_SHMEDIA_MACL = 90, // synonym for lower 32bits of media R17 - CV_SHMEDIA_MACH = 91, // synonym for upper 32bits of media R17 - CV_SHMEDIA_PR = CV_SHMEDIA_R18, - CV_SHMEDIA_T = 92, // synonym for lowest bit of media R19 - CV_SHMEDIA_FPUL = CV_SHMEDIA_FR32, - CV_SHMEDIA_PC = 93, - CV_SHMEDIA_SR = CV_SHMEDIA_CR0, - - // - // AMD64 registers - // - - CV_AMD64_AL = 1, - CV_AMD64_CL = 2, - CV_AMD64_DL = 3, - CV_AMD64_BL = 4, - CV_AMD64_AH = 5, - CV_AMD64_CH = 6, - CV_AMD64_DH = 7, - CV_AMD64_BH = 8, - CV_AMD64_AX = 9, - CV_AMD64_CX = 10, - CV_AMD64_DX = 11, - CV_AMD64_BX = 12, - CV_AMD64_SP = 13, - CV_AMD64_BP = 14, - CV_AMD64_SI = 15, - CV_AMD64_DI = 16, - CV_AMD64_EAX = 17, - CV_AMD64_ECX = 18, - CV_AMD64_EDX = 19, - CV_AMD64_EBX = 20, - CV_AMD64_ESP = 21, - CV_AMD64_EBP = 22, - CV_AMD64_ESI = 23, - CV_AMD64_EDI = 24, - CV_AMD64_ES = 25, - CV_AMD64_CS = 26, - CV_AMD64_SS = 27, - CV_AMD64_DS = 28, - CV_AMD64_FS = 29, - CV_AMD64_GS = 30, - CV_AMD64_FLAGS = 32, - CV_AMD64_RIP = 33, - CV_AMD64_EFLAGS = 34, - - // Control registers - CV_AMD64_CR0 = 80, - CV_AMD64_CR1 = 81, - CV_AMD64_CR2 = 82, - CV_AMD64_CR3 = 83, - CV_AMD64_CR4 = 84, - CV_AMD64_CR8 = 88, - - // Debug registers - CV_AMD64_DR0 = 90, - CV_AMD64_DR1 = 91, - CV_AMD64_DR2 = 92, - CV_AMD64_DR3 = 93, - CV_AMD64_DR4 = 94, - CV_AMD64_DR5 = 95, - CV_AMD64_DR6 = 96, - CV_AMD64_DR7 = 97, - CV_AMD64_DR8 = 98, - CV_AMD64_DR9 = 99, - CV_AMD64_DR10 = 100, - CV_AMD64_DR11 = 101, - CV_AMD64_DR12 = 102, - CV_AMD64_DR13 = 103, - CV_AMD64_DR14 = 104, - CV_AMD64_DR15 = 105, - - CV_AMD64_GDTR = 110, - CV_AMD64_GDTL = 111, - CV_AMD64_IDTR = 112, - CV_AMD64_IDTL = 113, - CV_AMD64_LDTR = 114, - CV_AMD64_TR = 115, - - CV_AMD64_ST0 = 128, - CV_AMD64_ST1 = 129, - CV_AMD64_ST2 = 130, - CV_AMD64_ST3 = 131, - CV_AMD64_ST4 = 132, - CV_AMD64_ST5 = 133, - CV_AMD64_ST6 = 134, - CV_AMD64_ST7 = 135, - CV_AMD64_CTRL = 136, - CV_AMD64_STAT = 137, - CV_AMD64_TAG = 138, - CV_AMD64_FPIP = 139, - CV_AMD64_FPCS = 140, - CV_AMD64_FPDO = 141, - CV_AMD64_FPDS = 142, - CV_AMD64_ISEM = 143, - CV_AMD64_FPEIP = 144, - CV_AMD64_FPEDO = 145, - - CV_AMD64_MM0 = 146, - CV_AMD64_MM1 = 147, - CV_AMD64_MM2 = 148, - CV_AMD64_MM3 = 149, - CV_AMD64_MM4 = 150, - CV_AMD64_MM5 = 151, - CV_AMD64_MM6 = 152, - CV_AMD64_MM7 = 153, - - CV_AMD64_XMM0 = 154, // KATMAI registers - CV_AMD64_XMM1 = 155, - CV_AMD64_XMM2 = 156, - CV_AMD64_XMM3 = 157, - CV_AMD64_XMM4 = 158, - CV_AMD64_XMM5 = 159, - CV_AMD64_XMM6 = 160, - CV_AMD64_XMM7 = 161, - - CV_AMD64_XMM0_0 = 162, // KATMAI sub-registers - CV_AMD64_XMM0_1 = 163, - CV_AMD64_XMM0_2 = 164, - CV_AMD64_XMM0_3 = 165, - CV_AMD64_XMM1_0 = 166, - CV_AMD64_XMM1_1 = 167, - CV_AMD64_XMM1_2 = 168, - CV_AMD64_XMM1_3 = 169, - CV_AMD64_XMM2_0 = 170, - CV_AMD64_XMM2_1 = 171, - CV_AMD64_XMM2_2 = 172, - CV_AMD64_XMM2_3 = 173, - CV_AMD64_XMM3_0 = 174, - CV_AMD64_XMM3_1 = 175, - CV_AMD64_XMM3_2 = 176, - CV_AMD64_XMM3_3 = 177, - CV_AMD64_XMM4_0 = 178, - CV_AMD64_XMM4_1 = 179, - CV_AMD64_XMM4_2 = 180, - CV_AMD64_XMM4_3 = 181, - CV_AMD64_XMM5_0 = 182, - CV_AMD64_XMM5_1 = 183, - CV_AMD64_XMM5_2 = 184, - CV_AMD64_XMM5_3 = 185, - CV_AMD64_XMM6_0 = 186, - CV_AMD64_XMM6_1 = 187, - CV_AMD64_XMM6_2 = 188, - CV_AMD64_XMM6_3 = 189, - CV_AMD64_XMM7_0 = 190, - CV_AMD64_XMM7_1 = 191, - CV_AMD64_XMM7_2 = 192, - CV_AMD64_XMM7_3 = 193, - - CV_AMD64_XMM0L = 194, - CV_AMD64_XMM1L = 195, - CV_AMD64_XMM2L = 196, - CV_AMD64_XMM3L = 197, - CV_AMD64_XMM4L = 198, - CV_AMD64_XMM5L = 199, - CV_AMD64_XMM6L = 200, - CV_AMD64_XMM7L = 201, - - CV_AMD64_XMM0H = 202, - CV_AMD64_XMM1H = 203, - CV_AMD64_XMM2H = 204, - CV_AMD64_XMM3H = 205, - CV_AMD64_XMM4H = 206, - CV_AMD64_XMM5H = 207, - CV_AMD64_XMM6H = 208, - CV_AMD64_XMM7H = 209, - - CV_AMD64_MXCSR = 211, // XMM status register - - CV_AMD64_EMM0L = 220, // XMM sub-registers (WNI integer) - CV_AMD64_EMM1L = 221, - CV_AMD64_EMM2L = 222, - CV_AMD64_EMM3L = 223, - CV_AMD64_EMM4L = 224, - CV_AMD64_EMM5L = 225, - CV_AMD64_EMM6L = 226, - CV_AMD64_EMM7L = 227, - - CV_AMD64_EMM0H = 228, - CV_AMD64_EMM1H = 229, - CV_AMD64_EMM2H = 230, - CV_AMD64_EMM3H = 231, - CV_AMD64_EMM4H = 232, - CV_AMD64_EMM5H = 233, - CV_AMD64_EMM6H = 234, - CV_AMD64_EMM7H = 235, - - // do not change the order of these regs, first one must be even too - CV_AMD64_MM00 = 236, - CV_AMD64_MM01 = 237, - CV_AMD64_MM10 = 238, - CV_AMD64_MM11 = 239, - CV_AMD64_MM20 = 240, - CV_AMD64_MM21 = 241, - CV_AMD64_MM30 = 242, - CV_AMD64_MM31 = 243, - CV_AMD64_MM40 = 244, - CV_AMD64_MM41 = 245, - CV_AMD64_MM50 = 246, - CV_AMD64_MM51 = 247, - CV_AMD64_MM60 = 248, - CV_AMD64_MM61 = 249, - CV_AMD64_MM70 = 250, - CV_AMD64_MM71 = 251, - - // Extended KATMAI registers - CV_AMD64_XMM8 = 252, // KATMAI registers - CV_AMD64_XMM9 = 253, - CV_AMD64_XMM10 = 254, - CV_AMD64_XMM11 = 255, - CV_AMD64_XMM12 = 256, - CV_AMD64_XMM13 = 257, - CV_AMD64_XMM14 = 258, - CV_AMD64_XMM15 = 259, - - CV_AMD64_XMM8_0 = 260, // KATMAI sub-registers - CV_AMD64_XMM8_1 = 261, - CV_AMD64_XMM8_2 = 262, - CV_AMD64_XMM8_3 = 263, - CV_AMD64_XMM9_0 = 264, - CV_AMD64_XMM9_1 = 265, - CV_AMD64_XMM9_2 = 266, - CV_AMD64_XMM9_3 = 267, - CV_AMD64_XMM10_0 = 268, - CV_AMD64_XMM10_1 = 269, - CV_AMD64_XMM10_2 = 270, - CV_AMD64_XMM10_3 = 271, - CV_AMD64_XMM11_0 = 272, - CV_AMD64_XMM11_1 = 273, - CV_AMD64_XMM11_2 = 274, - CV_AMD64_XMM11_3 = 275, - CV_AMD64_XMM12_0 = 276, - CV_AMD64_XMM12_1 = 277, - CV_AMD64_XMM12_2 = 278, - CV_AMD64_XMM12_3 = 279, - CV_AMD64_XMM13_0 = 280, - CV_AMD64_XMM13_1 = 281, - CV_AMD64_XMM13_2 = 282, - CV_AMD64_XMM13_3 = 283, - CV_AMD64_XMM14_0 = 284, - CV_AMD64_XMM14_1 = 285, - CV_AMD64_XMM14_2 = 286, - CV_AMD64_XMM14_3 = 287, - CV_AMD64_XMM15_0 = 288, - CV_AMD64_XMM15_1 = 289, - CV_AMD64_XMM15_2 = 290, - CV_AMD64_XMM15_3 = 291, - - CV_AMD64_XMM8L = 292, - CV_AMD64_XMM9L = 293, - CV_AMD64_XMM10L = 294, - CV_AMD64_XMM11L = 295, - CV_AMD64_XMM12L = 296, - CV_AMD64_XMM13L = 297, - CV_AMD64_XMM14L = 298, - CV_AMD64_XMM15L = 299, - - CV_AMD64_XMM8H = 300, - CV_AMD64_XMM9H = 301, - CV_AMD64_XMM10H = 302, - CV_AMD64_XMM11H = 303, - CV_AMD64_XMM12H = 304, - CV_AMD64_XMM13H = 305, - CV_AMD64_XMM14H = 306, - CV_AMD64_XMM15H = 307, - - CV_AMD64_EMM8L = 308, // XMM sub-registers (WNI integer) - CV_AMD64_EMM9L = 309, - CV_AMD64_EMM10L = 310, - CV_AMD64_EMM11L = 311, - CV_AMD64_EMM12L = 312, - CV_AMD64_EMM13L = 313, - CV_AMD64_EMM14L = 314, - CV_AMD64_EMM15L = 315, - - CV_AMD64_EMM8H = 316, - CV_AMD64_EMM9H = 317, - CV_AMD64_EMM10H = 318, - CV_AMD64_EMM11H = 319, - CV_AMD64_EMM12H = 320, - CV_AMD64_EMM13H = 321, - CV_AMD64_EMM14H = 322, - CV_AMD64_EMM15H = 323, - - // Low byte forms of some standard registers - CV_AMD64_SIL = 324, - CV_AMD64_DIL = 325, - CV_AMD64_BPL = 326, - CV_AMD64_SPL = 327, - - // 64-bit regular registers - CV_AMD64_RAX = 328, - CV_AMD64_RBX = 329, - CV_AMD64_RCX = 330, - CV_AMD64_RDX = 331, - CV_AMD64_RSI = 332, - CV_AMD64_RDI = 333, - CV_AMD64_RBP = 334, - CV_AMD64_RSP = 335, - - // 64-bit integer registers with 8-, 16-, and 32-bit forms (B, W, and D) - CV_AMD64_R8 = 336, - CV_AMD64_R9 = 337, - CV_AMD64_R10 = 338, - CV_AMD64_R11 = 339, - CV_AMD64_R12 = 340, - CV_AMD64_R13 = 341, - CV_AMD64_R14 = 342, - CV_AMD64_R15 = 343, - - CV_AMD64_R8B = 344, - CV_AMD64_R9B = 345, - CV_AMD64_R10B = 346, - CV_AMD64_R11B = 347, - CV_AMD64_R12B = 348, - CV_AMD64_R13B = 349, - CV_AMD64_R14B = 350, - CV_AMD64_R15B = 351, - - CV_AMD64_R8W = 352, - CV_AMD64_R9W = 353, - CV_AMD64_R10W = 354, - CV_AMD64_R11W = 355, - CV_AMD64_R12W = 356, - CV_AMD64_R13W = 357, - CV_AMD64_R14W = 358, - CV_AMD64_R15W = 359, - - CV_AMD64_R8D = 360, - CV_AMD64_R9D = 361, - CV_AMD64_R10D = 362, - CV_AMD64_R11D = 363, - CV_AMD64_R12D = 364, - CV_AMD64_R13D = 365, - CV_AMD64_R14D = 366, - CV_AMD64_R15D = 367, - - // AVX registers 256 bits - CV_AMD64_YMM0 = 368, - CV_AMD64_YMM1 = 369, - CV_AMD64_YMM2 = 370, - CV_AMD64_YMM3 = 371, - CV_AMD64_YMM4 = 372, - CV_AMD64_YMM5 = 373, - CV_AMD64_YMM6 = 374, - CV_AMD64_YMM7 = 375, - CV_AMD64_YMM8 = 376, - CV_AMD64_YMM9 = 377, - CV_AMD64_YMM10 = 378, - CV_AMD64_YMM11 = 379, - CV_AMD64_YMM12 = 380, - CV_AMD64_YMM13 = 381, - CV_AMD64_YMM14 = 382, - CV_AMD64_YMM15 = 383, - - // AVX registers upper 128 bits - CV_AMD64_YMM0H = 384, - CV_AMD64_YMM1H = 385, - CV_AMD64_YMM2H = 386, - CV_AMD64_YMM3H = 387, - CV_AMD64_YMM4H = 388, - CV_AMD64_YMM5H = 389, - CV_AMD64_YMM6H = 390, - CV_AMD64_YMM7H = 391, - CV_AMD64_YMM8H = 392, - CV_AMD64_YMM9H = 393, - CV_AMD64_YMM10H = 394, - CV_AMD64_YMM11H = 395, - CV_AMD64_YMM12H = 396, - CV_AMD64_YMM13H = 397, - CV_AMD64_YMM14H = 398, - CV_AMD64_YMM15H = 399, - - //Lower/upper 8 bytes of XMM registers. Unlike CV_AMD64_XMM, these - //values reprsesent the bit patterns of the registers as 64-bit integers, not - //the representation of these registers as a double. - CV_AMD64_XMM0IL = 400, - CV_AMD64_XMM1IL = 401, - CV_AMD64_XMM2IL = 402, - CV_AMD64_XMM3IL = 403, - CV_AMD64_XMM4IL = 404, - CV_AMD64_XMM5IL = 405, - CV_AMD64_XMM6IL = 406, - CV_AMD64_XMM7IL = 407, - CV_AMD64_XMM8IL = 408, - CV_AMD64_XMM9IL = 409, - CV_AMD64_XMM10IL = 410, - CV_AMD64_XMM11IL = 411, - CV_AMD64_XMM12IL = 412, - CV_AMD64_XMM13IL = 413, - CV_AMD64_XMM14IL = 414, - CV_AMD64_XMM15IL = 415, - - CV_AMD64_XMM0IH = 416, - CV_AMD64_XMM1IH = 417, - CV_AMD64_XMM2IH = 418, - CV_AMD64_XMM3IH = 419, - CV_AMD64_XMM4IH = 420, - CV_AMD64_XMM5IH = 421, - CV_AMD64_XMM6IH = 422, - CV_AMD64_XMM7IH = 423, - CV_AMD64_XMM8IH = 424, - CV_AMD64_XMM9IH = 425, - CV_AMD64_XMM10IH = 426, - CV_AMD64_XMM11IH = 427, - CV_AMD64_XMM12IH = 428, - CV_AMD64_XMM13IH = 429, - CV_AMD64_XMM14IH = 430, - CV_AMD64_XMM15IH = 431, - - CV_AMD64_YMM0I0 = 432, // AVX integer registers - CV_AMD64_YMM0I1 = 433, - CV_AMD64_YMM0I2 = 434, - CV_AMD64_YMM0I3 = 435, - CV_AMD64_YMM1I0 = 436, - CV_AMD64_YMM1I1 = 437, - CV_AMD64_YMM1I2 = 438, - CV_AMD64_YMM1I3 = 439, - CV_AMD64_YMM2I0 = 440, - CV_AMD64_YMM2I1 = 441, - CV_AMD64_YMM2I2 = 442, - CV_AMD64_YMM2I3 = 443, - CV_AMD64_YMM3I0 = 444, - CV_AMD64_YMM3I1 = 445, - CV_AMD64_YMM3I2 = 446, - CV_AMD64_YMM3I3 = 447, - CV_AMD64_YMM4I0 = 448, - CV_AMD64_YMM4I1 = 449, - CV_AMD64_YMM4I2 = 450, - CV_AMD64_YMM4I3 = 451, - CV_AMD64_YMM5I0 = 452, - CV_AMD64_YMM5I1 = 453, - CV_AMD64_YMM5I2 = 454, - CV_AMD64_YMM5I3 = 455, - CV_AMD64_YMM6I0 = 456, - CV_AMD64_YMM6I1 = 457, - CV_AMD64_YMM6I2 = 458, - CV_AMD64_YMM6I3 = 459, - CV_AMD64_YMM7I0 = 460, - CV_AMD64_YMM7I1 = 461, - CV_AMD64_YMM7I2 = 462, - CV_AMD64_YMM7I3 = 463, - CV_AMD64_YMM8I0 = 464, - CV_AMD64_YMM8I1 = 465, - CV_AMD64_YMM8I2 = 466, - CV_AMD64_YMM8I3 = 467, - CV_AMD64_YMM9I0 = 468, - CV_AMD64_YMM9I1 = 469, - CV_AMD64_YMM9I2 = 470, - CV_AMD64_YMM9I3 = 471, - CV_AMD64_YMM10I0 = 472, - CV_AMD64_YMM10I1 = 473, - CV_AMD64_YMM10I2 = 474, - CV_AMD64_YMM10I3 = 475, - CV_AMD64_YMM11I0 = 476, - CV_AMD64_YMM11I1 = 477, - CV_AMD64_YMM11I2 = 478, - CV_AMD64_YMM11I3 = 479, - CV_AMD64_YMM12I0 = 480, - CV_AMD64_YMM12I1 = 481, - CV_AMD64_YMM12I2 = 482, - CV_AMD64_YMM12I3 = 483, - CV_AMD64_YMM13I0 = 484, - CV_AMD64_YMM13I1 = 485, - CV_AMD64_YMM13I2 = 486, - CV_AMD64_YMM13I3 = 487, - CV_AMD64_YMM14I0 = 488, - CV_AMD64_YMM14I1 = 489, - CV_AMD64_YMM14I2 = 490, - CV_AMD64_YMM14I3 = 491, - CV_AMD64_YMM15I0 = 492, - CV_AMD64_YMM15I1 = 493, - CV_AMD64_YMM15I2 = 494, - CV_AMD64_YMM15I3 = 495, - - CV_AMD64_YMM0F0 = 496, // AVX floating-point single precise registers - CV_AMD64_YMM0F1 = 497, - CV_AMD64_YMM0F2 = 498, - CV_AMD64_YMM0F3 = 499, - CV_AMD64_YMM0F4 = 500, - CV_AMD64_YMM0F5 = 501, - CV_AMD64_YMM0F6 = 502, - CV_AMD64_YMM0F7 = 503, - CV_AMD64_YMM1F0 = 504, - CV_AMD64_YMM1F1 = 505, - CV_AMD64_YMM1F2 = 506, - CV_AMD64_YMM1F3 = 507, - CV_AMD64_YMM1F4 = 508, - CV_AMD64_YMM1F5 = 509, - CV_AMD64_YMM1F6 = 510, - CV_AMD64_YMM1F7 = 511, - CV_AMD64_YMM2F0 = 512, - CV_AMD64_YMM2F1 = 513, - CV_AMD64_YMM2F2 = 514, - CV_AMD64_YMM2F3 = 515, - CV_AMD64_YMM2F4 = 516, - CV_AMD64_YMM2F5 = 517, - CV_AMD64_YMM2F6 = 518, - CV_AMD64_YMM2F7 = 519, - CV_AMD64_YMM3F0 = 520, - CV_AMD64_YMM3F1 = 521, - CV_AMD64_YMM3F2 = 522, - CV_AMD64_YMM3F3 = 523, - CV_AMD64_YMM3F4 = 524, - CV_AMD64_YMM3F5 = 525, - CV_AMD64_YMM3F6 = 526, - CV_AMD64_YMM3F7 = 527, - CV_AMD64_YMM4F0 = 528, - CV_AMD64_YMM4F1 = 529, - CV_AMD64_YMM4F2 = 530, - CV_AMD64_YMM4F3 = 531, - CV_AMD64_YMM4F4 = 532, - CV_AMD64_YMM4F5 = 533, - CV_AMD64_YMM4F6 = 534, - CV_AMD64_YMM4F7 = 535, - CV_AMD64_YMM5F0 = 536, - CV_AMD64_YMM5F1 = 537, - CV_AMD64_YMM5F2 = 538, - CV_AMD64_YMM5F3 = 539, - CV_AMD64_YMM5F4 = 540, - CV_AMD64_YMM5F5 = 541, - CV_AMD64_YMM5F6 = 542, - CV_AMD64_YMM5F7 = 543, - CV_AMD64_YMM6F0 = 544, - CV_AMD64_YMM6F1 = 545, - CV_AMD64_YMM6F2 = 546, - CV_AMD64_YMM6F3 = 547, - CV_AMD64_YMM6F4 = 548, - CV_AMD64_YMM6F5 = 549, - CV_AMD64_YMM6F6 = 550, - CV_AMD64_YMM6F7 = 551, - CV_AMD64_YMM7F0 = 552, - CV_AMD64_YMM7F1 = 553, - CV_AMD64_YMM7F2 = 554, - CV_AMD64_YMM7F3 = 555, - CV_AMD64_YMM7F4 = 556, - CV_AMD64_YMM7F5 = 557, - CV_AMD64_YMM7F6 = 558, - CV_AMD64_YMM7F7 = 559, - CV_AMD64_YMM8F0 = 560, - CV_AMD64_YMM8F1 = 561, - CV_AMD64_YMM8F2 = 562, - CV_AMD64_YMM8F3 = 563, - CV_AMD64_YMM8F4 = 564, - CV_AMD64_YMM8F5 = 565, - CV_AMD64_YMM8F6 = 566, - CV_AMD64_YMM8F7 = 567, - CV_AMD64_YMM9F0 = 568, - CV_AMD64_YMM9F1 = 569, - CV_AMD64_YMM9F2 = 570, - CV_AMD64_YMM9F3 = 571, - CV_AMD64_YMM9F4 = 572, - CV_AMD64_YMM9F5 = 573, - CV_AMD64_YMM9F6 = 574, - CV_AMD64_YMM9F7 = 575, - CV_AMD64_YMM10F0 = 576, - CV_AMD64_YMM10F1 = 577, - CV_AMD64_YMM10F2 = 578, - CV_AMD64_YMM10F3 = 579, - CV_AMD64_YMM10F4 = 580, - CV_AMD64_YMM10F5 = 581, - CV_AMD64_YMM10F6 = 582, - CV_AMD64_YMM10F7 = 583, - CV_AMD64_YMM11F0 = 584, - CV_AMD64_YMM11F1 = 585, - CV_AMD64_YMM11F2 = 586, - CV_AMD64_YMM11F3 = 587, - CV_AMD64_YMM11F4 = 588, - CV_AMD64_YMM11F5 = 589, - CV_AMD64_YMM11F6 = 590, - CV_AMD64_YMM11F7 = 591, - CV_AMD64_YMM12F0 = 592, - CV_AMD64_YMM12F1 = 593, - CV_AMD64_YMM12F2 = 594, - CV_AMD64_YMM12F3 = 595, - CV_AMD64_YMM12F4 = 596, - CV_AMD64_YMM12F5 = 597, - CV_AMD64_YMM12F6 = 598, - CV_AMD64_YMM12F7 = 599, - CV_AMD64_YMM13F0 = 600, - CV_AMD64_YMM13F1 = 601, - CV_AMD64_YMM13F2 = 602, - CV_AMD64_YMM13F3 = 603, - CV_AMD64_YMM13F4 = 604, - CV_AMD64_YMM13F5 = 605, - CV_AMD64_YMM13F6 = 606, - CV_AMD64_YMM13F7 = 607, - CV_AMD64_YMM14F0 = 608, - CV_AMD64_YMM14F1 = 609, - CV_AMD64_YMM14F2 = 610, - CV_AMD64_YMM14F3 = 611, - CV_AMD64_YMM14F4 = 612, - CV_AMD64_YMM14F5 = 613, - CV_AMD64_YMM14F6 = 614, - CV_AMD64_YMM14F7 = 615, - CV_AMD64_YMM15F0 = 616, - CV_AMD64_YMM15F1 = 617, - CV_AMD64_YMM15F2 = 618, - CV_AMD64_YMM15F3 = 619, - CV_AMD64_YMM15F4 = 620, - CV_AMD64_YMM15F5 = 621, - CV_AMD64_YMM15F6 = 622, - CV_AMD64_YMM15F7 = 623, - - CV_AMD64_YMM0D0 = 624, // AVX floating-point double precise registers - CV_AMD64_YMM0D1 = 625, - CV_AMD64_YMM0D2 = 626, - CV_AMD64_YMM0D3 = 627, - CV_AMD64_YMM1D0 = 628, - CV_AMD64_YMM1D1 = 629, - CV_AMD64_YMM1D2 = 630, - CV_AMD64_YMM1D3 = 631, - CV_AMD64_YMM2D0 = 632, - CV_AMD64_YMM2D1 = 633, - CV_AMD64_YMM2D2 = 634, - CV_AMD64_YMM2D3 = 635, - CV_AMD64_YMM3D0 = 636, - CV_AMD64_YMM3D1 = 637, - CV_AMD64_YMM3D2 = 638, - CV_AMD64_YMM3D3 = 639, - CV_AMD64_YMM4D0 = 640, - CV_AMD64_YMM4D1 = 641, - CV_AMD64_YMM4D2 = 642, - CV_AMD64_YMM4D3 = 643, - CV_AMD64_YMM5D0 = 644, - CV_AMD64_YMM5D1 = 645, - CV_AMD64_YMM5D2 = 646, - CV_AMD64_YMM5D3 = 647, - CV_AMD64_YMM6D0 = 648, - CV_AMD64_YMM6D1 = 649, - CV_AMD64_YMM6D2 = 650, - CV_AMD64_YMM6D3 = 651, - CV_AMD64_YMM7D0 = 652, - CV_AMD64_YMM7D1 = 653, - CV_AMD64_YMM7D2 = 654, - CV_AMD64_YMM7D3 = 655, - CV_AMD64_YMM8D0 = 656, - CV_AMD64_YMM8D1 = 657, - CV_AMD64_YMM8D2 = 658, - CV_AMD64_YMM8D3 = 659, - CV_AMD64_YMM9D0 = 660, - CV_AMD64_YMM9D1 = 661, - CV_AMD64_YMM9D2 = 662, - CV_AMD64_YMM9D3 = 663, - CV_AMD64_YMM10D0 = 664, - CV_AMD64_YMM10D1 = 665, - CV_AMD64_YMM10D2 = 666, - CV_AMD64_YMM10D3 = 667, - CV_AMD64_YMM11D0 = 668, - CV_AMD64_YMM11D1 = 669, - CV_AMD64_YMM11D2 = 670, - CV_AMD64_YMM11D3 = 671, - CV_AMD64_YMM12D0 = 672, - CV_AMD64_YMM12D1 = 673, - CV_AMD64_YMM12D2 = 674, - CV_AMD64_YMM12D3 = 675, - CV_AMD64_YMM13D0 = 676, - CV_AMD64_YMM13D1 = 677, - CV_AMD64_YMM13D2 = 678, - CV_AMD64_YMM13D3 = 679, - CV_AMD64_YMM14D0 = 680, - CV_AMD64_YMM14D1 = 681, - CV_AMD64_YMM14D2 = 682, - CV_AMD64_YMM14D3 = 683, - CV_AMD64_YMM15D0 = 684, - CV_AMD64_YMM15D1 = 685, - CV_AMD64_YMM15D2 = 686, - CV_AMD64_YMM15D3 = 687 - - - // Note: Next set of platform registers need to go into a new enum... - // this one is above 44K now. - -} CV_HREG_e; - -typedef enum CV_HLSLREG_e { - CV_HLSLREG_TEMP = 0, - CV_HLSLREG_INPUT = 1, - CV_HLSLREG_OUTPUT = 2, - CV_HLSLREG_INDEXABLE_TEMP = 3, - CV_HLSLREG_IMMEDIATE32 = 4, - CV_HLSLREG_IMMEDIATE64 = 5, - CV_HLSLREG_SAMPLER = 6, - CV_HLSLREG_RESOURCE = 7, - CV_HLSLREG_CONSTANT_BUFFER = 8, - CV_HLSLREG_IMMEDIATE_CONSTANT_BUFFER = 9, - CV_HLSLREG_LABEL = 10, - CV_HLSLREG_INPUT_PRIMITIVEID = 11, - CV_HLSLREG_OUTPUT_DEPTH = 12, - CV_HLSLREG_NULL = 13, - CV_HLSLREG_RASTERIZER = 14, - CV_HLSLREG_OUTPUT_COVERAGE_MASK = 15, - CV_HLSLREG_STREAM = 16, - CV_HLSLREG_FUNCTION_BODY = 17, - CV_HLSLREG_FUNCTION_TABLE = 18, - CV_HLSLREG_INTERFACE = 19, - CV_HLSLREG_FUNCTION_INPUT = 20, - CV_HLSLREG_FUNCTION_OUTPUT = 21, - CV_HLSLREG_OUTPUT_CONTROL_POINT_ID = 22, - CV_HLSLREG_INPUT_FORK_INSTANCE_ID = 23, - CV_HLSLREG_INPUT_JOIN_INSTANCE_ID = 24, - CV_HLSLREG_INPUT_CONTROL_POINT = 25, - CV_HLSLREG_OUTPUT_CONTROL_POINT = 26, - CV_HLSLREG_INPUT_PATCH_CONSTANT = 27, - CV_HLSLREG_INPUT_DOMAIN_POINT = 28, - CV_HLSLREG_THIS_POINTER = 29, - CV_HLSLREG_UNORDERED_ACCESS_VIEW = 30, - CV_HLSLREG_THREAD_GROUP_SHARED_MEMORY = 31, - CV_HLSLREG_INPUT_THREAD_ID = 32, - CV_HLSLREG_INPUT_THREAD_GROUP_ID = 33, - CV_HLSLREG_INPUT_THREAD_ID_IN_GROUP = 34, - CV_HLSLREG_INPUT_COVERAGE_MASK = 35, - CV_HLSLREG_INPUT_THREAD_ID_IN_GROUP_FLATTENED = 36, - CV_HLSLREG_INPUT_GS_INSTANCE_ID = 37, - CV_HLSLREG_OUTPUT_DEPTH_GREATER_EQUAL = 38, - CV_HLSLREG_OUTPUT_DEPTH_LESS_EQUAL = 39, - CV_HLSLREG_CYCLE_COUNTER = 40, -} CV_HLSLREG_e; - -enum StackFrameTypeEnum -{ - FrameTypeFPO, // Frame pointer omitted, FPO info available - FrameTypeTrap, // Kernel Trap frame - FrameTypeTSS, // Kernel Trap frame - FrameTypeStandard, // Standard EBP stackframe - FrameTypeFrameData, // Frame pointer omitted, FrameData info available - - FrameTypeUnknown = -1, // Frame which does not have any debug info -}; - -enum MemoryTypeEnum -{ - MemTypeCode, // Read only code memory - MemTypeData, // Read only data/stack memory - MemTypeStack, // Read only stack memory - MemTypeCodeOnHeap, // Read only memory for code generated on heap by runtime - - MemTypeAny = -1, -}; - -typedef enum CV_HLSLMemorySpace_e -{ - // HLSL specific memory spaces - - CV_HLSL_MEMSPACE_DATA = 0x00, - CV_HLSL_MEMSPACE_SAMPLER = 0x01, - CV_HLSL_MEMSPACE_RESOURCE = 0x02, - CV_HLSL_MEMSPACE_RWRESOURCE = 0x03, - - CV_HLSL_MEMSPACE_MAX = 0x0F, -} CV_HLSLMemorySpace_e; - -#endif diff --git a/src/inc/cvinfo.h b/src/inc/cvinfo.h deleted file mode 100644 index c2e42e5d7..000000000 --- a/src/inc/cvinfo.h +++ /dev/null @@ -1,4989 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*** cvinfo.h - Generic CodeView information definitions - * - * Structures, constants, etc. for accessing and interpreting - * CodeView information. - * - */ - - -/*** The master copy of this file resides in the langapi project. - * All Microsoft projects are required to use the master copy without - * modification. Modification of the master version or a copy - * without consultation with all parties concerned is extremely - * risky. - * - */ - -#pragma once - -#include "cvconst.h" - -#ifndef _CV_INFO_INCLUDED -#define _CV_INFO_INCLUDED - -#ifdef __cplusplus -#pragma warning ( disable: 4200 ) -#endif - -#ifndef __INLINE -#ifdef __cplusplus -#define __INLINE inline -#else -#define __INLINE __inline -#endif -#endif - -#pragma pack ( push, 1 ) -typedef unsigned long CV_uoff32_t; -typedef long CV_off32_t; -typedef unsigned short CV_uoff16_t; -typedef short CV_off16_t; -typedef unsigned short CV_typ16_t; -typedef unsigned long CV_typ_t; -typedef unsigned long CV_pubsymflag_t; // must be same as CV_typ_t. -typedef unsigned short _2BYTEPAD; -typedef unsigned long CV_tkn_t; - -#if !defined (CV_ZEROLEN) -#define CV_ZEROLEN -#endif - -#if !defined (FLOAT10) -#if defined(_M_I86) // 16 bit x86 supporting long double -typedef long double FLOAT10; -#else // 32 bit w/o long double support -typedef struct FLOAT10 -{ - char b[10]; -} FLOAT10; -#endif -#endif - - -#define CV_SIGNATURE_C6 0L // Actual signature is >64K -#define CV_SIGNATURE_C7 1L // First explicit signature -#define CV_SIGNATURE_C11 2L // C11 (vc5.x) 32-bit types -#define CV_SIGNATURE_C13 4L // C13 (vc7.x) zero terminated names -#define CV_SIGNATURE_RESERVED 5L // All signatures from 5 to 64K are reserved - -#define CV_MAXOFFSET 0xffffffff - -#ifndef GUID_DEFINED -#define GUID_DEFINED - -typedef struct _GUID { // size is 16 - unsigned long Data1; - unsigned short Data2; - unsigned short Data3; - unsigned char Data4[8]; -} GUID; - -#endif // !GUID_DEFINED - -typedef GUID SIG70; // new to 7.0 are 16-byte guid-like signatures -typedef SIG70 * PSIG70; -typedef const SIG70 * PCSIG70; - - - -/** CodeView Symbol and Type OMF type information is broken up into two - * ranges. Type indices less than 0x1000 describe type information - * that is frequently used. Type indices above 0x1000 are used to - * describe more complex features such as functions, arrays and - * structures. - */ - - - - -/** Primitive types have predefined meaning that is encoded in the - * values of the various bit fields in the value. - * - * A CodeView primitive type is defined as: - * - * 1 1 - * 1 089 7654 3 210 - * r mode type r sub - * - * Where - * mode is the pointer mode - * type is a type indicator - * sub is a subtype enumeration - * r is a reserved field - * - * See Microsoft Symbol and Type OMF (Version 4.0) for more - * information. - */ - - -#define CV_MMASK 0x700 // mode mask -#define CV_TMASK 0x0f0 // type mask - -// can we use the reserved bit ?? -#define CV_SMASK 0x00f // subtype mask - -#define CV_MSHIFT 8 // primitive mode right shift count -#define CV_TSHIFT 4 // primitive type right shift count -#define CV_SSHIFT 0 // primitive subtype right shift count - -// macros to extract primitive mode, type and size - -#define CV_MODE(typ) (((typ) & CV_MMASK) >> CV_MSHIFT) -#define CV_TYPE(typ) (((typ) & CV_TMASK) >> CV_TSHIFT) -#define CV_SUBT(typ) (((typ) & CV_SMASK) >> CV_SSHIFT) - -// macros to insert new primitive mode, type and size - -#define CV_NEWMODE(typ, nm) ((CV_typ_t)(((typ) & ~CV_MMASK) | ((nm) << CV_MSHIFT))) -#define CV_NEWTYPE(typ, nt) (((typ) & ~CV_TMASK) | ((nt) << CV_TSHIFT)) -#define CV_NEWSUBT(typ, ns) (((typ) & ~CV_SMASK) | ((ns) << CV_SSHIFT)) - - - -// pointer mode enumeration values - -typedef enum CV_prmode_e { - CV_TM_DIRECT = 0, // mode is not a pointer - CV_TM_NPTR = 1, // mode is a near pointer - CV_TM_FPTR = 2, // mode is a far pointer - CV_TM_HPTR = 3, // mode is a huge pointer - CV_TM_NPTR32 = 4, // mode is a 32 bit near pointer - CV_TM_FPTR32 = 5, // mode is a 32 bit far pointer - CV_TM_NPTR64 = 6, // mode is a 64 bit near pointer - CV_TM_NPTR128 = 7, // mode is a 128 bit near pointer -} CV_prmode_e; - - - - -// type enumeration values - - -typedef enum CV_type_e { - CV_SPECIAL = 0x00, // special type size values - CV_SIGNED = 0x01, // signed integral size values - CV_UNSIGNED = 0x02, // unsigned integral size values - CV_BOOLEAN = 0x03, // Boolean size values - CV_REAL = 0x04, // real number size values - CV_COMPLEX = 0x05, // complex number size values - CV_SPECIAL2 = 0x06, // second set of special types - CV_INT = 0x07, // integral (int) values - CV_CVRESERVED = 0x0f, -} CV_type_e; - - - - -// subtype enumeration values for CV_SPECIAL - - -typedef enum CV_special_e { - CV_SP_NOTYPE = 0x00, - CV_SP_ABS = 0x01, - CV_SP_SEGMENT = 0x02, - CV_SP_VOID = 0x03, - CV_SP_CURRENCY = 0x04, - CV_SP_NBASICSTR = 0x05, - CV_SP_FBASICSTR = 0x06, - CV_SP_NOTTRANS = 0x07, - CV_SP_HRESULT = 0x08, -} CV_special_e; - - - - -// subtype enumeration values for CV_SPECIAL2 - - -typedef enum CV_special2_e { - CV_S2_BIT = 0x00, - CV_S2_PASCHAR = 0x01, // Pascal CHAR - CV_S2_BOOL32FF = 0x02, // 32-bit BOOL where true is 0xffffffff -} CV_special2_e; - - - - - -// subtype enumeration values for CV_SIGNED, CV_UNSIGNED and CV_BOOLEAN - - -typedef enum CV_integral_e { - CV_IN_1BYTE = 0x00, - CV_IN_2BYTE = 0x01, - CV_IN_4BYTE = 0x02, - CV_IN_8BYTE = 0x03, - CV_IN_16BYTE = 0x04 -} CV_integral_e; - - - - - -// subtype enumeration values for CV_REAL and CV_COMPLEX - - -typedef enum CV_real_e { - CV_RC_REAL32 = 0x00, - CV_RC_REAL64 = 0x01, - CV_RC_REAL80 = 0x02, - CV_RC_REAL128 = 0x03, - CV_RC_REAL48 = 0x04, - CV_RC_REAL32PP = 0x05, // 32-bit partial precision real - CV_RC_REAL16 = 0x06, -} CV_real_e; - - - - -// subtype enumeration values for CV_INT (really int) - - -typedef enum CV_int_e { - CV_RI_CHAR = 0x00, - CV_RI_INT1 = 0x00, - CV_RI_WCHAR = 0x01, - CV_RI_UINT1 = 0x01, - CV_RI_INT2 = 0x02, - CV_RI_UINT2 = 0x03, - CV_RI_INT4 = 0x04, - CV_RI_UINT4 = 0x05, - CV_RI_INT8 = 0x06, - CV_RI_UINT8 = 0x07, - CV_RI_INT16 = 0x08, - CV_RI_UINT16 = 0x09, - CV_RI_CHAR16 = 0x0a, // char16_t - CV_RI_CHAR32 = 0x0b, // char32_t -} CV_int_e; - - - -// macros to check the type of a primitive - -#define CV_TYP_IS_DIRECT(typ) (CV_MODE(typ) == CV_TM_DIRECT) -#define CV_TYP_IS_PTR(typ) (CV_MODE(typ) != CV_TM_DIRECT) -#define CV_TYP_IS_NPTR(typ) (CV_MODE(typ) == CV_TM_NPTR) -#define CV_TYP_IS_FPTR(typ) (CV_MODE(typ) == CV_TM_FPTR) -#define CV_TYP_IS_HPTR(typ) (CV_MODE(typ) == CV_TM_HPTR) -#define CV_TYP_IS_NPTR32(typ) (CV_MODE(typ) == CV_TM_NPTR32) -#define CV_TYP_IS_FPTR32(typ) (CV_MODE(typ) == CV_TM_FPTR32) - -#define CV_TYP_IS_SIGNED(typ) (((CV_TYPE(typ) == CV_SIGNED) && CV_TYP_IS_DIRECT(typ)) || \ - (typ == T_INT1) || \ - (typ == T_INT2) || \ - (typ == T_INT4) || \ - (typ == T_INT8) || \ - (typ == T_INT16) || \ - (typ == T_RCHAR)) - -#define CV_TYP_IS_UNSIGNED(typ) (((CV_TYPE(typ) == CV_UNSIGNED) && CV_TYP_IS_DIRECT(typ)) || \ - (typ == T_UINT1) || \ - (typ == T_UINT2) || \ - (typ == T_UINT4) || \ - (typ == T_UINT8) || \ - (typ == T_UINT16)) - -#define CV_TYP_IS_REAL(typ) ((CV_TYPE(typ) == CV_REAL) && CV_TYP_IS_DIRECT(typ)) - -#define CV_FIRST_NONPRIM 0x1000 -#define CV_IS_PRIMITIVE(typ) ((typ) < CV_FIRST_NONPRIM) -#define CV_TYP_IS_COMPLEX(typ) ((CV_TYPE(typ) == CV_COMPLEX) && CV_TYP_IS_DIRECT(typ)) -#define CV_IS_INTERNAL_PTR(typ) (CV_IS_PRIMITIVE(typ) && \ - CV_TYPE(typ) == CV_CVRESERVED && \ - CV_TYP_IS_PTR(typ)) - - - - - - -// selected values for type_index - for a more complete definition, see -// Microsoft Symbol and Type OMF document - - - - -// Special Types - -typedef enum TYPE_ENUM_e { -// Special Types - - T_NOTYPE = 0x0000, // uncharacterized type (no type) - T_ABS = 0x0001, // absolute symbol - T_SEGMENT = 0x0002, // segment type - T_VOID = 0x0003, // void - T_HRESULT = 0x0008, // OLE/COM HRESULT - T_32PHRESULT = 0x0408, // OLE/COM HRESULT __ptr32 * - T_64PHRESULT = 0x0608, // OLE/COM HRESULT __ptr64 * - - T_PVOID = 0x0103, // near pointer to void - T_PFVOID = 0x0203, // far pointer to void - T_PHVOID = 0x0303, // huge pointer to void - T_32PVOID = 0x0403, // 32 bit pointer to void - T_32PFVOID = 0x0503, // 16:32 pointer to void - T_64PVOID = 0x0603, // 64 bit pointer to void - T_CURRENCY = 0x0004, // BASIC 8 byte currency value - T_NBASICSTR = 0x0005, // Near BASIC string - T_FBASICSTR = 0x0006, // Far BASIC string - T_NOTTRANS = 0x0007, // type not translated by cvpack - T_BIT = 0x0060, // bit - T_PASCHAR = 0x0061, // Pascal CHAR - T_BOOL32FF = 0x0062, // 32-bit BOOL where true is 0xffffffff - - -// Character types - - T_CHAR = 0x0010, // 8 bit signed - T_PCHAR = 0x0110, // 16 bit pointer to 8 bit signed - T_PFCHAR = 0x0210, // 16:16 far pointer to 8 bit signed - T_PHCHAR = 0x0310, // 16:16 huge pointer to 8 bit signed - T_32PCHAR = 0x0410, // 32 bit pointer to 8 bit signed - T_32PFCHAR = 0x0510, // 16:32 pointer to 8 bit signed - T_64PCHAR = 0x0610, // 64 bit pointer to 8 bit signed - - T_UCHAR = 0x0020, // 8 bit unsigned - T_PUCHAR = 0x0120, // 16 bit pointer to 8 bit unsigned - T_PFUCHAR = 0x0220, // 16:16 far pointer to 8 bit unsigned - T_PHUCHAR = 0x0320, // 16:16 huge pointer to 8 bit unsigned - T_32PUCHAR = 0x0420, // 32 bit pointer to 8 bit unsigned - T_32PFUCHAR = 0x0520, // 16:32 pointer to 8 bit unsigned - T_64PUCHAR = 0x0620, // 64 bit pointer to 8 bit unsigned - - -// really a character types - - T_RCHAR = 0x0070, // really a char - T_PRCHAR = 0x0170, // 16 bit pointer to a real char - T_PFRCHAR = 0x0270, // 16:16 far pointer to a real char - T_PHRCHAR = 0x0370, // 16:16 huge pointer to a real char - T_32PRCHAR = 0x0470, // 32 bit pointer to a real char - T_32PFRCHAR = 0x0570, // 16:32 pointer to a real char - T_64PRCHAR = 0x0670, // 64 bit pointer to a real char - - -// really a wide character types - - T_WCHAR = 0x0071, // wide char - T_PWCHAR = 0x0171, // 16 bit pointer to a wide char - T_PFWCHAR = 0x0271, // 16:16 far pointer to a wide char - T_PHWCHAR = 0x0371, // 16:16 huge pointer to a wide char - T_32PWCHAR = 0x0471, // 32 bit pointer to a wide char - T_32PFWCHAR = 0x0571, // 16:32 pointer to a wide char - T_64PWCHAR = 0x0671, // 64 bit pointer to a wide char - -// really a 16-bit unicode char - - T_CHAR16 = 0x007a, // 16-bit unicode char - T_PCHAR16 = 0x017a, // 16 bit pointer to a 16-bit unicode char - T_PFCHAR16 = 0x027a, // 16:16 far pointer to a 16-bit unicode char - T_PHCHAR16 = 0x037a, // 16:16 huge pointer to a 16-bit unicode char - T_32PCHAR16 = 0x047a, // 32 bit pointer to a 16-bit unicode char - T_32PFCHAR16 = 0x057a, // 16:32 pointer to a 16-bit unicode char - T_64PCHAR16 = 0x067a, // 64 bit pointer to a 16-bit unicode char - -// really a 32-bit unicode char - - T_CHAR32 = 0x007b, // 32-bit unicode char - T_PCHAR32 = 0x017b, // 16 bit pointer to a 32-bit unicode char - T_PFCHAR32 = 0x027b, // 16:16 far pointer to a 32-bit unicode char - T_PHCHAR32 = 0x037b, // 16:16 huge pointer to a 32-bit unicode char - T_32PCHAR32 = 0x047b, // 32 bit pointer to a 32-bit unicode char - T_32PFCHAR32 = 0x057b, // 16:32 pointer to a 32-bit unicode char - T_64PCHAR32 = 0x067b, // 64 bit pointer to a 32-bit unicode char - -// 8 bit int types - - T_INT1 = 0x0068, // 8 bit signed int - T_PINT1 = 0x0168, // 16 bit pointer to 8 bit signed int - T_PFINT1 = 0x0268, // 16:16 far pointer to 8 bit signed int - T_PHINT1 = 0x0368, // 16:16 huge pointer to 8 bit signed int - T_32PINT1 = 0x0468, // 32 bit pointer to 8 bit signed int - T_32PFINT1 = 0x0568, // 16:32 pointer to 8 bit signed int - T_64PINT1 = 0x0668, // 64 bit pointer to 8 bit signed int - - T_UINT1 = 0x0069, // 8 bit unsigned int - T_PUINT1 = 0x0169, // 16 bit pointer to 8 bit unsigned int - T_PFUINT1 = 0x0269, // 16:16 far pointer to 8 bit unsigned int - T_PHUINT1 = 0x0369, // 16:16 huge pointer to 8 bit unsigned int - T_32PUINT1 = 0x0469, // 32 bit pointer to 8 bit unsigned int - T_32PFUINT1 = 0x0569, // 16:32 pointer to 8 bit unsigned int - T_64PUINT1 = 0x0669, // 64 bit pointer to 8 bit unsigned int - - -// 16 bit short types - - T_SHORT = 0x0011, // 16 bit signed - T_PSHORT = 0x0111, // 16 bit pointer to 16 bit signed - T_PFSHORT = 0x0211, // 16:16 far pointer to 16 bit signed - T_PHSHORT = 0x0311, // 16:16 huge pointer to 16 bit signed - T_32PSHORT = 0x0411, // 32 bit pointer to 16 bit signed - T_32PFSHORT = 0x0511, // 16:32 pointer to 16 bit signed - T_64PSHORT = 0x0611, // 64 bit pointer to 16 bit signed - - T_USHORT = 0x0021, // 16 bit unsigned - T_PUSHORT = 0x0121, // 16 bit pointer to 16 bit unsigned - T_PFUSHORT = 0x0221, // 16:16 far pointer to 16 bit unsigned - T_PHUSHORT = 0x0321, // 16:16 huge pointer to 16 bit unsigned - T_32PUSHORT = 0x0421, // 32 bit pointer to 16 bit unsigned - T_32PFUSHORT = 0x0521, // 16:32 pointer to 16 bit unsigned - T_64PUSHORT = 0x0621, // 64 bit pointer to 16 bit unsigned - - -// 16 bit int types - - T_INT2 = 0x0072, // 16 bit signed int - T_PINT2 = 0x0172, // 16 bit pointer to 16 bit signed int - T_PFINT2 = 0x0272, // 16:16 far pointer to 16 bit signed int - T_PHINT2 = 0x0372, // 16:16 huge pointer to 16 bit signed int - T_32PINT2 = 0x0472, // 32 bit pointer to 16 bit signed int - T_32PFINT2 = 0x0572, // 16:32 pointer to 16 bit signed int - T_64PINT2 = 0x0672, // 64 bit pointer to 16 bit signed int - - T_UINT2 = 0x0073, // 16 bit unsigned int - T_PUINT2 = 0x0173, // 16 bit pointer to 16 bit unsigned int - T_PFUINT2 = 0x0273, // 16:16 far pointer to 16 bit unsigned int - T_PHUINT2 = 0x0373, // 16:16 huge pointer to 16 bit unsigned int - T_32PUINT2 = 0x0473, // 32 bit pointer to 16 bit unsigned int - T_32PFUINT2 = 0x0573, // 16:32 pointer to 16 bit unsigned int - T_64PUINT2 = 0x0673, // 64 bit pointer to 16 bit unsigned int - - -// 32 bit long types - - T_LONG = 0x0012, // 32 bit signed - T_ULONG = 0x0022, // 32 bit unsigned - T_PLONG = 0x0112, // 16 bit pointer to 32 bit signed - T_PULONG = 0x0122, // 16 bit pointer to 32 bit unsigned - T_PFLONG = 0x0212, // 16:16 far pointer to 32 bit signed - T_PFULONG = 0x0222, // 16:16 far pointer to 32 bit unsigned - T_PHLONG = 0x0312, // 16:16 huge pointer to 32 bit signed - T_PHULONG = 0x0322, // 16:16 huge pointer to 32 bit unsigned - - T_32PLONG = 0x0412, // 32 bit pointer to 32 bit signed - T_32PULONG = 0x0422, // 32 bit pointer to 32 bit unsigned - T_32PFLONG = 0x0512, // 16:32 pointer to 32 bit signed - T_32PFULONG = 0x0522, // 16:32 pointer to 32 bit unsigned - T_64PLONG = 0x0612, // 64 bit pointer to 32 bit signed - T_64PULONG = 0x0622, // 64 bit pointer to 32 bit unsigned - - -// 32 bit int types - - T_INT4 = 0x0074, // 32 bit signed int - T_PINT4 = 0x0174, // 16 bit pointer to 32 bit signed int - T_PFINT4 = 0x0274, // 16:16 far pointer to 32 bit signed int - T_PHINT4 = 0x0374, // 16:16 huge pointer to 32 bit signed int - T_32PINT4 = 0x0474, // 32 bit pointer to 32 bit signed int - T_32PFINT4 = 0x0574, // 16:32 pointer to 32 bit signed int - T_64PINT4 = 0x0674, // 64 bit pointer to 32 bit signed int - - T_UINT4 = 0x0075, // 32 bit unsigned int - T_PUINT4 = 0x0175, // 16 bit pointer to 32 bit unsigned int - T_PFUINT4 = 0x0275, // 16:16 far pointer to 32 bit unsigned int - T_PHUINT4 = 0x0375, // 16:16 huge pointer to 32 bit unsigned int - T_32PUINT4 = 0x0475, // 32 bit pointer to 32 bit unsigned int - T_32PFUINT4 = 0x0575, // 16:32 pointer to 32 bit unsigned int - T_64PUINT4 = 0x0675, // 64 bit pointer to 32 bit unsigned int - - -// 64 bit quad types - - T_QUAD = 0x0013, // 64 bit signed - T_PQUAD = 0x0113, // 16 bit pointer to 64 bit signed - T_PFQUAD = 0x0213, // 16:16 far pointer to 64 bit signed - T_PHQUAD = 0x0313, // 16:16 huge pointer to 64 bit signed - T_32PQUAD = 0x0413, // 32 bit pointer to 64 bit signed - T_32PFQUAD = 0x0513, // 16:32 pointer to 64 bit signed - T_64PQUAD = 0x0613, // 64 bit pointer to 64 bit signed - - T_UQUAD = 0x0023, // 64 bit unsigned - T_PUQUAD = 0x0123, // 16 bit pointer to 64 bit unsigned - T_PFUQUAD = 0x0223, // 16:16 far pointer to 64 bit unsigned - T_PHUQUAD = 0x0323, // 16:16 huge pointer to 64 bit unsigned - T_32PUQUAD = 0x0423, // 32 bit pointer to 64 bit unsigned - T_32PFUQUAD = 0x0523, // 16:32 pointer to 64 bit unsigned - T_64PUQUAD = 0x0623, // 64 bit pointer to 64 bit unsigned - - -// 64 bit int types - - T_INT8 = 0x0076, // 64 bit signed int - T_PINT8 = 0x0176, // 16 bit pointer to 64 bit signed int - T_PFINT8 = 0x0276, // 16:16 far pointer to 64 bit signed int - T_PHINT8 = 0x0376, // 16:16 huge pointer to 64 bit signed int - T_32PINT8 = 0x0476, // 32 bit pointer to 64 bit signed int - T_32PFINT8 = 0x0576, // 16:32 pointer to 64 bit signed int - T_64PINT8 = 0x0676, // 64 bit pointer to 64 bit signed int - - T_UINT8 = 0x0077, // 64 bit unsigned int - T_PUINT8 = 0x0177, // 16 bit pointer to 64 bit unsigned int - T_PFUINT8 = 0x0277, // 16:16 far pointer to 64 bit unsigned int - T_PHUINT8 = 0x0377, // 16:16 huge pointer to 64 bit unsigned int - T_32PUINT8 = 0x0477, // 32 bit pointer to 64 bit unsigned int - T_32PFUINT8 = 0x0577, // 16:32 pointer to 64 bit unsigned int - T_64PUINT8 = 0x0677, // 64 bit pointer to 64 bit unsigned int - - -// 128 bit octet types - - T_OCT = 0x0014, // 128 bit signed - T_POCT = 0x0114, // 16 bit pointer to 128 bit signed - T_PFOCT = 0x0214, // 16:16 far pointer to 128 bit signed - T_PHOCT = 0x0314, // 16:16 huge pointer to 128 bit signed - T_32POCT = 0x0414, // 32 bit pointer to 128 bit signed - T_32PFOCT = 0x0514, // 16:32 pointer to 128 bit signed - T_64POCT = 0x0614, // 64 bit pointer to 128 bit signed - - T_UOCT = 0x0024, // 128 bit unsigned - T_PUOCT = 0x0124, // 16 bit pointer to 128 bit unsigned - T_PFUOCT = 0x0224, // 16:16 far pointer to 128 bit unsigned - T_PHUOCT = 0x0324, // 16:16 huge pointer to 128 bit unsigned - T_32PUOCT = 0x0424, // 32 bit pointer to 128 bit unsigned - T_32PFUOCT = 0x0524, // 16:32 pointer to 128 bit unsigned - T_64PUOCT = 0x0624, // 64 bit pointer to 128 bit unsigned - - -// 128 bit int types - - T_INT16 = 0x0078, // 128 bit signed int - T_PINT16 = 0x0178, // 16 bit pointer to 128 bit signed int - T_PFINT16 = 0x0278, // 16:16 far pointer to 128 bit signed int - T_PHINT16 = 0x0378, // 16:16 huge pointer to 128 bit signed int - T_32PINT16 = 0x0478, // 32 bit pointer to 128 bit signed int - T_32PFINT16 = 0x0578, // 16:32 pointer to 128 bit signed int - T_64PINT16 = 0x0678, // 64 bit pointer to 128 bit signed int - - T_UINT16 = 0x0079, // 128 bit unsigned int - T_PUINT16 = 0x0179, // 16 bit pointer to 128 bit unsigned int - T_PFUINT16 = 0x0279, // 16:16 far pointer to 128 bit unsigned int - T_PHUINT16 = 0x0379, // 16:16 huge pointer to 128 bit unsigned int - T_32PUINT16 = 0x0479, // 32 bit pointer to 128 bit unsigned int - T_32PFUINT16 = 0x0579, // 16:32 pointer to 128 bit unsigned int - T_64PUINT16 = 0x0679, // 64 bit pointer to 128 bit unsigned int - - -// 16 bit real types - - T_REAL16 = 0x0046, // 16 bit real - T_PREAL16 = 0x0146, // 16 bit pointer to 16 bit real - T_PFREAL16 = 0x0246, // 16:16 far pointer to 16 bit real - T_PHREAL16 = 0x0346, // 16:16 huge pointer to 16 bit real - T_32PREAL16 = 0x0446, // 32 bit pointer to 16 bit real - T_32PFREAL16 = 0x0546, // 16:32 pointer to 16 bit real - T_64PREAL16 = 0x0646, // 64 bit pointer to 16 bit real - - -// 32 bit real types - - T_REAL32 = 0x0040, // 32 bit real - T_PREAL32 = 0x0140, // 16 bit pointer to 32 bit real - T_PFREAL32 = 0x0240, // 16:16 far pointer to 32 bit real - T_PHREAL32 = 0x0340, // 16:16 huge pointer to 32 bit real - T_32PREAL32 = 0x0440, // 32 bit pointer to 32 bit real - T_32PFREAL32 = 0x0540, // 16:32 pointer to 32 bit real - T_64PREAL32 = 0x0640, // 64 bit pointer to 32 bit real - - -// 32 bit partial-precision real types - - T_REAL32PP = 0x0045, // 32 bit PP real - T_PREAL32PP = 0x0145, // 16 bit pointer to 32 bit PP real - T_PFREAL32PP = 0x0245, // 16:16 far pointer to 32 bit PP real - T_PHREAL32PP = 0x0345, // 16:16 huge pointer to 32 bit PP real - T_32PREAL32PP = 0x0445, // 32 bit pointer to 32 bit PP real - T_32PFREAL32PP = 0x0545, // 16:32 pointer to 32 bit PP real - T_64PREAL32PP = 0x0645, // 64 bit pointer to 32 bit PP real - - -// 48 bit real types - - T_REAL48 = 0x0044, // 48 bit real - T_PREAL48 = 0x0144, // 16 bit pointer to 48 bit real - T_PFREAL48 = 0x0244, // 16:16 far pointer to 48 bit real - T_PHREAL48 = 0x0344, // 16:16 huge pointer to 48 bit real - T_32PREAL48 = 0x0444, // 32 bit pointer to 48 bit real - T_32PFREAL48 = 0x0544, // 16:32 pointer to 48 bit real - T_64PREAL48 = 0x0644, // 64 bit pointer to 48 bit real - - -// 64 bit real types - - T_REAL64 = 0x0041, // 64 bit real - T_PREAL64 = 0x0141, // 16 bit pointer to 64 bit real - T_PFREAL64 = 0x0241, // 16:16 far pointer to 64 bit real - T_PHREAL64 = 0x0341, // 16:16 huge pointer to 64 bit real - T_32PREAL64 = 0x0441, // 32 bit pointer to 64 bit real - T_32PFREAL64 = 0x0541, // 16:32 pointer to 64 bit real - T_64PREAL64 = 0x0641, // 64 bit pointer to 64 bit real - - -// 80 bit real types - - T_REAL80 = 0x0042, // 80 bit real - T_PREAL80 = 0x0142, // 16 bit pointer to 80 bit real - T_PFREAL80 = 0x0242, // 16:16 far pointer to 80 bit real - T_PHREAL80 = 0x0342, // 16:16 huge pointer to 80 bit real - T_32PREAL80 = 0x0442, // 32 bit pointer to 80 bit real - T_32PFREAL80 = 0x0542, // 16:32 pointer to 80 bit real - T_64PREAL80 = 0x0642, // 64 bit pointer to 80 bit real - - -// 128 bit real types - - T_REAL128 = 0x0043, // 128 bit real - T_PREAL128 = 0x0143, // 16 bit pointer to 128 bit real - T_PFREAL128 = 0x0243, // 16:16 far pointer to 128 bit real - T_PHREAL128 = 0x0343, // 16:16 huge pointer to 128 bit real - T_32PREAL128 = 0x0443, // 32 bit pointer to 128 bit real - T_32PFREAL128 = 0x0543, // 16:32 pointer to 128 bit real - T_64PREAL128 = 0x0643, // 64 bit pointer to 128 bit real - - -// 32 bit complex types - - T_CPLX32 = 0x0050, // 32 bit complex - T_PCPLX32 = 0x0150, // 16 bit pointer to 32 bit complex - T_PFCPLX32 = 0x0250, // 16:16 far pointer to 32 bit complex - T_PHCPLX32 = 0x0350, // 16:16 huge pointer to 32 bit complex - T_32PCPLX32 = 0x0450, // 32 bit pointer to 32 bit complex - T_32PFCPLX32 = 0x0550, // 16:32 pointer to 32 bit complex - T_64PCPLX32 = 0x0650, // 64 bit pointer to 32 bit complex - - -// 64 bit complex types - - T_CPLX64 = 0x0051, // 64 bit complex - T_PCPLX64 = 0x0151, // 16 bit pointer to 64 bit complex - T_PFCPLX64 = 0x0251, // 16:16 far pointer to 64 bit complex - T_PHCPLX64 = 0x0351, // 16:16 huge pointer to 64 bit complex - T_32PCPLX64 = 0x0451, // 32 bit pointer to 64 bit complex - T_32PFCPLX64 = 0x0551, // 16:32 pointer to 64 bit complex - T_64PCPLX64 = 0x0651, // 64 bit pointer to 64 bit complex - - -// 80 bit complex types - - T_CPLX80 = 0x0052, // 80 bit complex - T_PCPLX80 = 0x0152, // 16 bit pointer to 80 bit complex - T_PFCPLX80 = 0x0252, // 16:16 far pointer to 80 bit complex - T_PHCPLX80 = 0x0352, // 16:16 huge pointer to 80 bit complex - T_32PCPLX80 = 0x0452, // 32 bit pointer to 80 bit complex - T_32PFCPLX80 = 0x0552, // 16:32 pointer to 80 bit complex - T_64PCPLX80 = 0x0652, // 64 bit pointer to 80 bit complex - - -// 128 bit complex types - - T_CPLX128 = 0x0053, // 128 bit complex - T_PCPLX128 = 0x0153, // 16 bit pointer to 128 bit complex - T_PFCPLX128 = 0x0253, // 16:16 far pointer to 128 bit complex - T_PHCPLX128 = 0x0353, // 16:16 huge pointer to 128 bit real - T_32PCPLX128 = 0x0453, // 32 bit pointer to 128 bit complex - T_32PFCPLX128 = 0x0553, // 16:32 pointer to 128 bit complex - T_64PCPLX128 = 0x0653, // 64 bit pointer to 128 bit complex - - -// boolean types - - T_BOOL08 = 0x0030, // 8 bit boolean - T_PBOOL08 = 0x0130, // 16 bit pointer to 8 bit boolean - T_PFBOOL08 = 0x0230, // 16:16 far pointer to 8 bit boolean - T_PHBOOL08 = 0x0330, // 16:16 huge pointer to 8 bit boolean - T_32PBOOL08 = 0x0430, // 32 bit pointer to 8 bit boolean - T_32PFBOOL08 = 0x0530, // 16:32 pointer to 8 bit boolean - T_64PBOOL08 = 0x0630, // 64 bit pointer to 8 bit boolean - - T_BOOL16 = 0x0031, // 16 bit boolean - T_PBOOL16 = 0x0131, // 16 bit pointer to 16 bit boolean - T_PFBOOL16 = 0x0231, // 16:16 far pointer to 16 bit boolean - T_PHBOOL16 = 0x0331, // 16:16 huge pointer to 16 bit boolean - T_32PBOOL16 = 0x0431, // 32 bit pointer to 18 bit boolean - T_32PFBOOL16 = 0x0531, // 16:32 pointer to 16 bit boolean - T_64PBOOL16 = 0x0631, // 64 bit pointer to 18 bit boolean - - T_BOOL32 = 0x0032, // 32 bit boolean - T_PBOOL32 = 0x0132, // 16 bit pointer to 32 bit boolean - T_PFBOOL32 = 0x0232, // 16:16 far pointer to 32 bit boolean - T_PHBOOL32 = 0x0332, // 16:16 huge pointer to 32 bit boolean - T_32PBOOL32 = 0x0432, // 32 bit pointer to 32 bit boolean - T_32PFBOOL32 = 0x0532, // 16:32 pointer to 32 bit boolean - T_64PBOOL32 = 0x0632, // 64 bit pointer to 32 bit boolean - - T_BOOL64 = 0x0033, // 64 bit boolean - T_PBOOL64 = 0x0133, // 16 bit pointer to 64 bit boolean - T_PFBOOL64 = 0x0233, // 16:16 far pointer to 64 bit boolean - T_PHBOOL64 = 0x0333, // 16:16 huge pointer to 64 bit boolean - T_32PBOOL64 = 0x0433, // 32 bit pointer to 64 bit boolean - T_32PFBOOL64 = 0x0533, // 16:32 pointer to 64 bit boolean - T_64PBOOL64 = 0x0633, // 64 bit pointer to 64 bit boolean - - -// ??? - - T_NCVPTR = 0x01f0, // CV Internal type for created near pointers - T_FCVPTR = 0x02f0, // CV Internal type for created far pointers - T_HCVPTR = 0x03f0, // CV Internal type for created huge pointers - T_32NCVPTR = 0x04f0, // CV Internal type for created near 32-bit pointers - T_32FCVPTR = 0x05f0, // CV Internal type for created far 32-bit pointers - T_64NCVPTR = 0x06f0, // CV Internal type for created near 64-bit pointers - -} TYPE_ENUM_e; - -/** No leaf index can have a value of 0x0000. The leaf indices are - * separated into ranges depending upon the use of the type record. - * The second range is for the type records that are directly referenced - * in symbols. The first range is for type records that are not - * referenced by symbols but instead are referenced by other type - * records. All type records must have a starting leaf index in these - * first two ranges. The third range of leaf indices are used to build - * up complex lists such as the field list of a class type record. No - * type record can begin with one of the leaf indices. The fourth ranges - * of type indices are used to represent numeric data in a symbol or - * type record. These leaf indices are greater than 0x8000. At the - * point that type or symbol processor is expecting a numeric field, the - * next two bytes in the type record are examined. If the value is less - * than 0x8000, then the two bytes contain the numeric value. If the - * value is greater than 0x8000, then the data follows the leaf index in - * a format specified by the leaf index. The final range of leaf indices - * are used to force alignment of subfields within a complex type record.. - */ - - -typedef enum LEAF_ENUM_e { - // leaf indices starting records but referenced from symbol records - - LF_MODIFIER_16t = 0x0001, - LF_POINTER_16t = 0x0002, - LF_ARRAY_16t = 0x0003, - LF_CLASS_16t = 0x0004, - LF_STRUCTURE_16t = 0x0005, - LF_UNION_16t = 0x0006, - LF_ENUM_16t = 0x0007, - LF_PROCEDURE_16t = 0x0008, - LF_MFUNCTION_16t = 0x0009, - LF_VTSHAPE = 0x000a, - LF_COBOL0_16t = 0x000b, - LF_COBOL1 = 0x000c, - LF_BARRAY_16t = 0x000d, - LF_LABEL = 0x000e, - LF_NULL = 0x000f, - LF_NOTTRAN = 0x0010, - LF_DIMARRAY_16t = 0x0011, - LF_VFTPATH_16t = 0x0012, - LF_PRECOMP_16t = 0x0013, // not referenced from symbol - LF_ENDPRECOMP = 0x0014, // not referenced from symbol - LF_OEM_16t = 0x0015, // oem definable type string - LF_TYPESERVER_ST = 0x0016, // not referenced from symbol - - // leaf indices starting records but referenced only from type records - - LF_SKIP_16t = 0x0200, - LF_ARGLIST_16t = 0x0201, - LF_DEFARG_16t = 0x0202, - LF_LIST = 0x0203, - LF_FIELDLIST_16t = 0x0204, - LF_DERIVED_16t = 0x0205, - LF_BITFIELD_16t = 0x0206, - LF_METHODLIST_16t = 0x0207, - LF_DIMCONU_16t = 0x0208, - LF_DIMCONLU_16t = 0x0209, - LF_DIMVARU_16t = 0x020a, - LF_DIMVARLU_16t = 0x020b, - LF_REFSYM = 0x020c, - - LF_BCLASS_16t = 0x0400, - LF_VBCLASS_16t = 0x0401, - LF_IVBCLASS_16t = 0x0402, - LF_ENUMERATE_ST = 0x0403, - LF_FRIENDFCN_16t = 0x0404, - LF_INDEX_16t = 0x0405, - LF_MEMBER_16t = 0x0406, - LF_STMEMBER_16t = 0x0407, - LF_METHOD_16t = 0x0408, - LF_NESTTYPE_16t = 0x0409, - LF_VFUNCTAB_16t = 0x040a, - LF_FRIENDCLS_16t = 0x040b, - LF_ONEMETHOD_16t = 0x040c, - LF_VFUNCOFF_16t = 0x040d, - -// 32-bit type index versions of leaves, all have the 0x1000 bit set -// - LF_TI16_MAX = 0x1000, - - LF_MODIFIER = 0x1001, - LF_POINTER = 0x1002, - LF_ARRAY_ST = 0x1003, - LF_CLASS_ST = 0x1004, - LF_STRUCTURE_ST = 0x1005, - LF_UNION_ST = 0x1006, - LF_ENUM_ST = 0x1007, - LF_PROCEDURE = 0x1008, - LF_MFUNCTION = 0x1009, - LF_COBOL0 = 0x100a, - LF_BARRAY = 0x100b, - LF_DIMARRAY_ST = 0x100c, - LF_VFTPATH = 0x100d, - LF_PRECOMP_ST = 0x100e, // not referenced from symbol - LF_OEM = 0x100f, // oem definable type string - LF_ALIAS_ST = 0x1010, // alias (typedef) type - LF_OEM2 = 0x1011, // oem definable type string - - // leaf indices starting records but referenced only from type records - - LF_SKIP = 0x1200, - LF_ARGLIST = 0x1201, - LF_DEFARG_ST = 0x1202, - LF_FIELDLIST = 0x1203, - LF_DERIVED = 0x1204, - LF_BITFIELD = 0x1205, - LF_METHODLIST = 0x1206, - LF_DIMCONU = 0x1207, - LF_DIMCONLU = 0x1208, - LF_DIMVARU = 0x1209, - LF_DIMVARLU = 0x120a, - - LF_BCLASS = 0x1400, - LF_VBCLASS = 0x1401, - LF_IVBCLASS = 0x1402, - LF_FRIENDFCN_ST = 0x1403, - LF_INDEX = 0x1404, - LF_MEMBER_ST = 0x1405, - LF_STMEMBER_ST = 0x1406, - LF_METHOD_ST = 0x1407, - LF_NESTTYPE_ST = 0x1408, - LF_VFUNCTAB = 0x1409, - LF_FRIENDCLS = 0x140a, - LF_ONEMETHOD_ST = 0x140b, - LF_VFUNCOFF = 0x140c, - LF_NESTTYPEEX_ST = 0x140d, - LF_MEMBERMODIFY_ST = 0x140e, - LF_MANAGED_ST = 0x140f, - - // Types w/ SZ names - - LF_ST_MAX = 0x1500, - - LF_TYPESERVER = 0x1501, // not referenced from symbol - LF_ENUMERATE = 0x1502, - LF_ARRAY = 0x1503, - LF_CLASS = 0x1504, - LF_STRUCTURE = 0x1505, - LF_UNION = 0x1506, - LF_ENUM = 0x1507, - LF_DIMARRAY = 0x1508, - LF_PRECOMP = 0x1509, // not referenced from symbol - LF_ALIAS = 0x150a, // alias (typedef) type - LF_DEFARG = 0x150b, - LF_FRIENDFCN = 0x150c, - LF_MEMBER = 0x150d, - LF_STMEMBER = 0x150e, - LF_METHOD = 0x150f, - LF_NESTTYPE = 0x1510, - LF_ONEMETHOD = 0x1511, - LF_NESTTYPEEX = 0x1512, - LF_MEMBERMODIFY = 0x1513, - LF_MANAGED = 0x1514, - LF_TYPESERVER2 = 0x1515, - - LF_STRIDED_ARRAY = 0x1516, // same as LF_ARRAY, but with stride between adjacent elements - LF_HLSL = 0x1517, - LF_MODIFIER_EX = 0x1518, - LF_INTERFACE = 0x1519, - LF_BINTERFACE = 0x151a, - LF_VECTOR = 0x151b, - LF_MATRIX = 0x151c, - - LF_VFTABLE = 0x151d, // a virtual function table - LF_ENDOFLEAFRECORD = LF_VFTABLE, - - LF_TYPE_LAST, // one greater than the last type record - LF_TYPE_MAX = LF_TYPE_LAST - 1, - - LF_FUNC_ID = 0x1601, // global func ID - LF_MFUNC_ID = 0x1602, // member func ID - LF_BUILDINFO = 0x1603, // build info: tool, version, command line, src/pdb file - LF_SUBSTR_LIST = 0x1604, // similar to LF_ARGLIST, for list of sub strings - LF_STRING_ID = 0x1605, // string ID - - LF_UDT_SRC_LINE = 0x1606, // source and line on where an UDT is defined - // only generated by compiler - - LF_UDT_MOD_SRC_LINE = 0x1607, // module, source and line on where an UDT is defined - // only generated by linker - - LF_ID_LAST, // one greater than the last ID record - LF_ID_MAX = LF_ID_LAST - 1, - - LF_NUMERIC = 0x8000, - LF_CHAR = 0x8000, - LF_SHORT = 0x8001, - LF_USHORT = 0x8002, - LF_LONG = 0x8003, - LF_ULONG = 0x8004, - LF_REAL32 = 0x8005, - LF_REAL64 = 0x8006, - LF_REAL80 = 0x8007, - LF_REAL128 = 0x8008, - LF_QUADWORD = 0x8009, - LF_UQUADWORD = 0x800a, - LF_REAL48 = 0x800b, - LF_COMPLEX32 = 0x800c, - LF_COMPLEX64 = 0x800d, - LF_COMPLEX80 = 0x800e, - LF_COMPLEX128 = 0x800f, - LF_VARSTRING = 0x8010, - - LF_OCTWORD = 0x8017, - LF_UOCTWORD = 0x8018, - - LF_DECIMAL = 0x8019, - LF_DATE = 0x801a, - LF_UTF8STRING = 0x801b, - - LF_REAL16 = 0x801c, - - LF_PAD0 = 0xf0, - LF_PAD1 = 0xf1, - LF_PAD2 = 0xf2, - LF_PAD3 = 0xf3, - LF_PAD4 = 0xf4, - LF_PAD5 = 0xf5, - LF_PAD6 = 0xf6, - LF_PAD7 = 0xf7, - LF_PAD8 = 0xf8, - LF_PAD9 = 0xf9, - LF_PAD10 = 0xfa, - LF_PAD11 = 0xfb, - LF_PAD12 = 0xfc, - LF_PAD13 = 0xfd, - LF_PAD14 = 0xfe, - LF_PAD15 = 0xff, - -} LEAF_ENUM_e; - -// end of leaf indices - - - - -// Type enum for pointer records -// Pointers can be one of the following types - - -typedef enum CV_ptrtype_e { - CV_PTR_NEAR = 0x00, // 16 bit pointer - CV_PTR_FAR = 0x01, // 16:16 far pointer - CV_PTR_HUGE = 0x02, // 16:16 huge pointer - CV_PTR_BASE_SEG = 0x03, // based on segment - CV_PTR_BASE_VAL = 0x04, // based on value of base - CV_PTR_BASE_SEGVAL = 0x05, // based on segment value of base - CV_PTR_BASE_ADDR = 0x06, // based on address of base - CV_PTR_BASE_SEGADDR = 0x07, // based on segment address of base - CV_PTR_BASE_TYPE = 0x08, // based on type - CV_PTR_BASE_SELF = 0x09, // based on self - CV_PTR_NEAR32 = 0x0a, // 32 bit pointer - CV_PTR_FAR32 = 0x0b, // 16:32 pointer - CV_PTR_64 = 0x0c, // 64 bit pointer - CV_PTR_UNUSEDPTR = 0x0d // first unused pointer type -} CV_ptrtype_e; - - - - - -// Mode enum for pointers -// Pointers can have one of the following modes -// -// To support for l-value and r-value reference, we added CV_PTR_MODE_LVREF -// and CV_PTR_MODE_RVREF. CV_PTR_MODE_REF should be removed at some point. -// We keep it now so that old code that uses it won't be broken. -// - -typedef enum CV_ptrmode_e { - CV_PTR_MODE_PTR = 0x00, // "normal" pointer - CV_PTR_MODE_REF = 0x01, // "old" reference - CV_PTR_MODE_LVREF = 0x01, // l-value reference - CV_PTR_MODE_PMEM = 0x02, // pointer to data member - CV_PTR_MODE_PMFUNC = 0x03, // pointer to member function - CV_PTR_MODE_RVREF = 0x04, // r-value reference - CV_PTR_MODE_RESERVED= 0x05 // first unused pointer mode -} CV_ptrmode_e; - - -// enumeration for pointer-to-member types - -typedef enum CV_pmtype_e { - CV_PMTYPE_Undef = 0x00, // not specified (pre VC8) - CV_PMTYPE_D_Single = 0x01, // member data, single inheritance - CV_PMTYPE_D_Multiple= 0x02, // member data, multiple inheritance - CV_PMTYPE_D_Virtual = 0x03, // member data, virtual inheritance - CV_PMTYPE_D_General = 0x04, // member data, most general - CV_PMTYPE_F_Single = 0x05, // member function, single inheritance - CV_PMTYPE_F_Multiple= 0x06, // member function, multiple inheritance - CV_PMTYPE_F_Virtual = 0x07, // member function, virtual inheritance - CV_PMTYPE_F_General = 0x08, // member function, most general -} CV_pmtype_e; - -// enumeration for method properties - -typedef enum CV_methodprop_e { - CV_MTvanilla = 0x00, - CV_MTvirtual = 0x01, - CV_MTstatic = 0x02, - CV_MTfriend = 0x03, - CV_MTintro = 0x04, - CV_MTpurevirt = 0x05, - CV_MTpureintro = 0x06 -} CV_methodprop_e; - - - - -// enumeration for virtual shape table entries - -typedef enum CV_VTS_desc_e { - CV_VTS_near = 0x00, - CV_VTS_far = 0x01, - CV_VTS_thin = 0x02, - CV_VTS_outer = 0x03, - CV_VTS_meta = 0x04, - CV_VTS_near32 = 0x05, - CV_VTS_far32 = 0x06, - CV_VTS_unused = 0x07 -} CV_VTS_desc_e; - - - - -// enumeration for LF_LABEL address modes - -typedef enum CV_LABEL_TYPE_e { - CV_LABEL_NEAR = 0, // near return - CV_LABEL_FAR = 4 // far return -} CV_LABEL_TYPE_e; - - - -// enumeration for LF_MODIFIER values - - -typedef struct CV_modifier_t { - unsigned short MOD_const :1; - unsigned short MOD_volatile :1; - unsigned short MOD_unaligned :1; - unsigned short MOD_unused :13; -} CV_modifier_t; - - - - -// enumeration for HFA kinds - -typedef enum CV_HFA_e { - CV_HFA_none = 0, - CV_HFA_float = 1, - CV_HFA_double = 2, - CV_HFA_other = 3 -} CV_HFA_e; - -// enumeration for MoCOM UDT kinds - -typedef enum CV_MOCOM_UDT_e { - CV_MOCOM_UDT_none = 0, - CV_MOCOM_UDT_ref = 1, - CV_MOCOM_UDT_value = 2, - CV_MOCOM_UDT_interface = 3 -} CV_MOCOM_UDT_e; - -// bit field structure describing class/struct/union/enum properties - -typedef struct CV_prop_t { - unsigned short packed :1; // true if structure is packed - unsigned short ctor :1; // true if constructors or destructors present - unsigned short ovlops :1; // true if overloaded operators present - unsigned short isnested :1; // true if this is a nested class - unsigned short cnested :1; // true if this class contains nested types - unsigned short opassign :1; // true if overloaded assignment (=) - unsigned short opcast :1; // true if casting methods - unsigned short fwdref :1; // true if forward reference (incomplete defn) - unsigned short scoped :1; // scoped definition - unsigned short hasuniquename :1; // true if there is a decorated name following the regular name - unsigned short sealed :1; // true if class cannot be used as a base class - unsigned short hfa :2; // CV_HFA_e - unsigned short intrinsic :1; // true if class is an intrinsic type (e.g. __m128d) - unsigned short mocom :2; // CV_MOCOM_UDT_e -} CV_prop_t; - - - - -// class field attribute - -typedef struct CV_fldattr_t { - unsigned short access :2; // access protection CV_access_t - unsigned short mprop :3; // method properties CV_methodprop_t - unsigned short pseudo :1; // compiler generated fcn and does not exist - unsigned short noinherit :1; // true if class cannot be inherited - unsigned short noconstruct :1; // true if class cannot be constructed - unsigned short compgenx :1; // compiler generated fcn and does exist - unsigned short sealed :1; // true if method cannot be overridden - unsigned short unused :6; // unused -} CV_fldattr_t; - - -// function flags - -typedef struct CV_funcattr_t { - unsigned char cxxreturnudt :1; // true if C++ style ReturnUDT - unsigned char ctor :1; // true if func is an instance constructor - unsigned char ctorvbase :1; // true if func is an instance constructor of a class with virtual bases - unsigned char unused :5; // unused -} CV_funcattr_t; - - -// matrix flags - -typedef struct CV_matrixattr_t { - unsigned char row_major :1; // true if matrix has row-major layout (column-major is default) - unsigned char unused :7; // unused -} CV_matrixattr_t; - - -// Structures to access to the type records - - -typedef struct TYPTYPE { - unsigned short len; - unsigned short leaf; - unsigned char data[CV_ZEROLEN]; -} TYPTYPE; // general types record - -__INLINE char *NextType ( _In_ char * pType) { - return (pType + ((TYPTYPE *)pType)->len + sizeof(unsigned short)); -} - -typedef enum CV_PMEMBER { - CV_PDM16_NONVIRT = 0x00, // 16:16 data no virtual fcn or base - CV_PDM16_VFCN = 0x01, // 16:16 data with virtual functions - CV_PDM16_VBASE = 0x02, // 16:16 data with virtual bases - CV_PDM32_NVVFCN = 0x03, // 16:32 data w/wo virtual functions - CV_PDM32_VBASE = 0x04, // 16:32 data with virtual bases - - CV_PMF16_NEARNVSA = 0x05, // 16:16 near method nonvirtual single address point - CV_PMF16_NEARNVMA = 0x06, // 16:16 near method nonvirtual multiple address points - CV_PMF16_NEARVBASE = 0x07, // 16:16 near method virtual bases - CV_PMF16_FARNVSA = 0x08, // 16:16 far method nonvirtual single address point - CV_PMF16_FARNVMA = 0x09, // 16:16 far method nonvirtual multiple address points - CV_PMF16_FARVBASE = 0x0a, // 16:16 far method virtual bases - - CV_PMF32_NVSA = 0x0b, // 16:32 method nonvirtual single address point - CV_PMF32_NVMA = 0x0c, // 16:32 method nonvirtual multiple address point - CV_PMF32_VBASE = 0x0d // 16:32 method virtual bases -} CV_PMEMBER; - - - -// memory representation of pointer to member. These representations are -// indexed by the enumeration above in the LF_POINTER record - - - - -// representation of a 16:16 pointer to data for a class with no -// virtual functions or virtual bases - - -struct CV_PDMR16_NONVIRT { - CV_off16_t mdisp; // displacement to data (NULL = -1) -}; - - - - -// representation of a 16:16 pointer to data for a class with virtual -// functions - - -struct CV_PMDR16_VFCN { - CV_off16_t mdisp; // displacement to data ( NULL = 0) -}; - - - - -// representation of a 16:16 pointer to data for a class with -// virtual bases - - -struct CV_PDMR16_VBASE { - CV_off16_t mdisp; // displacement to data - CV_off16_t pdisp; // this pointer displacement to vbptr - CV_off16_t vdisp; // displacement within vbase table - // NULL = (,,0xffff) -}; - - - - -// representation of a 32 bit pointer to data for a class with -// or without virtual functions and no virtual bases - - -struct CV_PDMR32_NVVFCN { - CV_off32_t mdisp; // displacement to data (NULL = 0x80000000) -}; - - - - -// representation of a 32 bit pointer to data for a class -// with virtual bases - - -struct CV_PDMR32_VBASE { - CV_off32_t mdisp; // displacement to data - CV_off32_t pdisp; // this pointer displacement - CV_off32_t vdisp; // vbase table displacement - // NULL = (,,0xffffffff) -}; - - - - -// representation of a 16:16 pointer to near member function for a -// class with no virtual functions or bases and a single address point - - -struct CV_PMFR16_NEARNVSA { - CV_uoff16_t off; // near address of function (NULL = 0) -}; - - - -// representation of a 16 bit pointer to member functions of a -// class with no virtual bases and multiple address points - - -struct CV_PMFR16_NEARNVMA { - CV_uoff16_t off; // offset of function (NULL = 0,x) - signed short disp; -}; - - - - -// representation of a 16 bit pointer to member function of a -// class with virtual bases - - -struct CV_PMFR16_NEARVBASE { - CV_uoff16_t off; // offset of function (NULL = 0,x,x,x) - CV_off16_t mdisp; // displacement to data - CV_off16_t pdisp; // this pointer displacement - CV_off16_t vdisp; // vbase table displacement -}; - - - - -// representation of a 16:16 pointer to far member function for a -// class with no virtual bases and a single address point - - -struct CV_PMFR16_FARNVSA { - CV_uoff16_t off; // offset of function (NULL = 0:0) - unsigned short seg; // segment of function -}; - - - - -// representation of a 16:16 far pointer to member functions of a -// class with no virtual bases and multiple address points - - -struct CV_PMFR16_FARNVMA { - CV_uoff16_t off; // offset of function (NULL = 0:0,x) - unsigned short seg; - signed short disp; -}; - - - - -// representation of a 16:16 far pointer to member function of a -// class with virtual bases - - -struct CV_PMFR16_FARVBASE { - CV_uoff16_t off; // offset of function (NULL = 0:0,x,x,x) - unsigned short seg; - CV_off16_t mdisp; // displacement to data - CV_off16_t pdisp; // this pointer displacement - CV_off16_t vdisp; // vbase table displacement - -}; - - - - -// representation of a 32 bit pointer to member function for a -// class with no virtual bases and a single address point - - -struct CV_PMFR32_NVSA { - CV_uoff32_t off; // near address of function (NULL = 0L) -}; - - - - -// representation of a 32 bit pointer to member function for a -// class with no virtual bases and multiple address points - - -struct CV_PMFR32_NVMA { - CV_uoff32_t off; // near address of function (NULL = 0L,x) - CV_off32_t disp; -}; - - - - -// representation of a 32 bit pointer to member function for a -// class with virtual bases - - -struct CV_PMFR32_VBASE { - CV_uoff32_t off; // near address of function (NULL = 0L,x,x,x) - CV_off32_t mdisp; // displacement to data - CV_off32_t pdisp; // this pointer displacement - CV_off32_t vdisp; // vbase table displacement -}; - - - - - -// Easy leaf - used for generic casting to reference leaf field -// of a subfield of a complex list - -typedef struct lfEasy { - unsigned short leaf; // LF_... -} lfEasy; - - -/** The following type records are basically variant records of the - * above structure. The "unsigned short leaf" of the above structure and - * the "unsigned short leaf" of the following type definitions are the same - * symbol. When the OMF record is locked via the MHOMFLock API - * call, the address of the "unsigned short leaf" is returned - */ - -/** Notes on alignment - * Alignment of the fields in most of the type records is done on the - * basis of the TYPTYPE record base. That is why in most of the lf* - * records that the CV_typ_t (32-bit types) is located on what appears to - * be a offset mod 4 == 2 boundary. The exception to this rule are those - * records that are in a list (lfFieldList, lfMethodList), which are - * aligned to their own bases since they don't have the length field - */ - -/**** Change log for 16-bit to 32-bit type and symbol records - - Record type Change (f == field arrangement, p = padding added) - ---------------------------------------------------------------------- - lfModifer f - lfPointer fp - lfClass f - lfStructure f - lfUnion f - lfEnum f - lfVFTPath p - lfPreComp p - lfOEM p - lfArgList p - lfDerived p - mlMethod p (method list member) - lfBitField f - lfDimCon f - lfDimVar p - lfIndex p (field list member) - lfBClass f (field list member) - lfVBClass f (field list member) - lfFriendCls p (field list member) - lfFriendFcn p (field list member) - lfMember f (field list member) - lfSTMember f (field list member) - lfVFuncTab p (field list member) - lfVFuncOff p (field list member) - lfNestType p (field list member) - - DATASYM32 f - PROCSYM32 f - VPATHSYM32 f - REGREL32 f - THREADSYM32 f - PROCSYMMIPS f - - -*/ - -// Type record for LF_MODIFIER - -typedef struct lfModifier_16t { - unsigned short leaf; // LF_MODIFIER_16t - CV_modifier_t attr; // modifier attribute modifier_t - CV_typ16_t type; // modified type -} lfModifier_16t; - -typedef struct lfModifier { - unsigned short leaf; // LF_MODIFIER - CV_typ_t type; // modified type - CV_modifier_t attr; // modifier attribute modifier_t -} lfModifier; - - - - -// type record for LF_POINTER - -#ifndef __cplusplus -typedef struct lfPointer_16t { -#endif - struct lfPointerBody_16t { - unsigned short leaf; // LF_POINTER_16t - struct lfPointerAttr_16t { - unsigned char ptrtype :5; // ordinal specifying pointer type (CV_ptrtype_e) - unsigned char ptrmode :3; // ordinal specifying pointer mode (CV_ptrmode_e) - unsigned char isflat32 :1; // true if 0:32 pointer - unsigned char isvolatile :1; // TRUE if volatile pointer - unsigned char isconst :1; // TRUE if const pointer - unsigned char isunaligned :1; // TRUE if unaligned pointer - unsigned char unused :4; - } attr; - CV_typ16_t utype; // type index of the underlying type -#if (defined(__cplusplus) || defined(_MSC_VER)) // for C++ and MS compilers that support unnamed unions - }; -#else - } u; -#endif -#ifdef __cplusplus -typedef struct lfPointer_16t : public lfPointerBody_16t { -#endif - union { - struct { - CV_typ16_t pmclass; // index of containing class for pointer to member - unsigned short pmenum; // enumeration specifying pm format (CV_pmtype_e) - } pm; - unsigned short bseg; // base segment if PTR_BASE_SEG - unsigned char Sym[1]; // copy of base symbol record (including length) - struct { - CV_typ16_t index; // type index if CV_PTR_BASE_TYPE - unsigned char name[1]; // name of base type - } btype; - } pbase; -} lfPointer_16t; - -#ifndef __cplusplus -typedef struct lfPointer { -#endif - struct lfPointerBody { - unsigned short leaf; // LF_POINTER - CV_typ_t utype; // type index of the underlying type - struct lfPointerAttr { - unsigned long ptrtype :5; // ordinal specifying pointer type (CV_ptrtype_e) - unsigned long ptrmode :3; // ordinal specifying pointer mode (CV_ptrmode_e) - unsigned long isflat32 :1; // true if 0:32 pointer - unsigned long isvolatile :1; // TRUE if volatile pointer - unsigned long isconst :1; // TRUE if const pointer - unsigned long isunaligned :1; // TRUE if unaligned pointer - unsigned long isrestrict :1; // TRUE if restricted pointer (allow agressive opts) - unsigned long size :6; // size of pointer (in bytes) - unsigned long ismocom :1; // TRUE if it is a MoCOM pointer (^ or %) - unsigned long islref :1; // TRUE if it is this pointer of member function with & ref-qualifier - unsigned long isrref :1; // TRUE if it is this pointer of member function with && ref-qualifier - unsigned long unused :10;// pad out to 32-bits for following cv_typ_t's - } attr; -#if (defined(__cplusplus) || defined(_MSC_VER)) // for C++ and MS compilers that support unnamed unions - }; -#else - } u; -#endif -#ifdef __cplusplus -typedef struct lfPointer : public lfPointerBody { -#endif - union { - struct { - CV_typ_t pmclass; // index of containing class for pointer to member - unsigned short pmenum; // enumeration specifying pm format (CV_pmtype_e) - } pm; - unsigned short bseg; // base segment if PTR_BASE_SEG - unsigned char Sym[1]; // copy of base symbol record (including length) - struct { - CV_typ_t index; // type index if CV_PTR_BASE_TYPE - unsigned char name[1]; // name of base type - } btype; - } pbase; -} lfPointer; - - - - -// type record for LF_ARRAY - - -typedef struct lfArray_16t { - unsigned short leaf; // LF_ARRAY_16t - CV_typ16_t elemtype; // type index of element type - CV_typ16_t idxtype; // type index of indexing type - unsigned char data[CV_ZEROLEN]; // variable length data specifying - // size in bytes and name -} lfArray_16t; - -typedef struct lfArray { - unsigned short leaf; // LF_ARRAY - CV_typ_t elemtype; // type index of element type - CV_typ_t idxtype; // type index of indexing type - unsigned char data[CV_ZEROLEN]; // variable length data specifying - // size in bytes and name -} lfArray; - -typedef struct lfStridedArray { - unsigned short leaf; // LF_STRIDED_ARRAY - CV_typ_t elemtype; // type index of element type - CV_typ_t idxtype; // type index of indexing type - unsigned long stride; - unsigned char data[CV_ZEROLEN]; // variable length data specifying - // size in bytes and name -} lfStridedArray; - - - - -// type record for LF_VECTOR - - -typedef struct lfVector { - unsigned short leaf; // LF_VECTOR - CV_typ_t elemtype; // type index of element type - unsigned long count; // number of elements in the vector - unsigned char data[CV_ZEROLEN]; // variable length data specifying - // size in bytes and name -} lfVector; - - - - -// type record for LF_MATRIX - - -typedef struct lfMatrix { - unsigned short leaf; // LF_MATRIX - CV_typ_t elemtype; // type index of element type - unsigned long rows; // number of rows - unsigned long cols; // number of columns - unsigned long majorStride; - CV_matrixattr_t matattr; // attributes - unsigned char data[CV_ZEROLEN]; // variable length data specifying - // size in bytes and name -} lfMatrix; - - - - -// type record for LF_CLASS, LF_STRUCTURE - - -typedef struct lfClass_16t { - unsigned short leaf; // LF_CLASS_16t, LF_STRUCT_16t - unsigned short count; // count of number of elements in class - CV_typ16_t field; // type index of LF_FIELD descriptor list - CV_prop_t property; // property attribute field (prop_t) - CV_typ16_t derived; // type index of derived from list if not zero - CV_typ16_t vshape; // type index of vshape table for this class - unsigned char data[CV_ZEROLEN]; // data describing length of structure in - // bytes and name -} lfClass_16t; -typedef lfClass_16t lfStructure_16t; - - -typedef struct lfClass { - unsigned short leaf; // LF_CLASS, LF_STRUCT, LF_INTERFACE - unsigned short count; // count of number of elements in class - CV_prop_t property; // property attribute field (prop_t) - CV_typ_t field; // type index of LF_FIELD descriptor list - CV_typ_t derived; // type index of derived from list if not zero - CV_typ_t vshape; // type index of vshape table for this class - unsigned char data[CV_ZEROLEN]; // data describing length of structure in - // bytes and name -} lfClass; -typedef lfClass lfStructure; -typedef lfClass lfInterface; - -// type record for LF_UNION - - -typedef struct lfUnion_16t { - unsigned short leaf; // LF_UNION_16t - unsigned short count; // count of number of elements in class - CV_typ16_t field; // type index of LF_FIELD descriptor list - CV_prop_t property; // property attribute field - unsigned char data[CV_ZEROLEN]; // variable length data describing length of - // structure and name -} lfUnion_16t; - - -typedef struct lfUnion { - unsigned short leaf; // LF_UNION - unsigned short count; // count of number of elements in class - CV_prop_t property; // property attribute field - CV_typ_t field; // type index of LF_FIELD descriptor list - unsigned char data[CV_ZEROLEN]; // variable length data describing length of - // structure and name -} lfUnion; - - -// type record for LF_ALIAS - -typedef struct lfAlias { - unsigned short leaf; // LF_ALIAS - CV_typ_t utype; // underlying type - unsigned char Name[1]; // alias name -} lfAlias; - -// Item Id is a stricter typeindex which may referenced from symbol stream. -// The code item always had a name. - -typedef CV_typ_t CV_ItemId; - -typedef struct lfFuncId { - unsigned short leaf; // LF_FUNC_ID - CV_ItemId scopeId; // parent scope of the ID, 0 if global - CV_typ_t type; // function type - unsigned char name[CV_ZEROLEN]; -} lfFuncId; - -typedef struct lfMFuncId { - unsigned short leaf; // LF_MFUNC_ID - CV_typ_t parentType; // type index of parent - CV_typ_t type; // function type - unsigned char name[CV_ZEROLEN]; -} lfMFuncId; - -typedef struct lfStringId { - unsigned short leaf; // LF_STRING_ID - CV_ItemId id; // ID to list of sub string IDs - unsigned char name[CV_ZEROLEN]; -} lfStringId; - -typedef struct lfUdtSrcLine { - unsigned short leaf; // LF_UDT_SRC_LINE - CV_typ_t type; // UDT's type index - CV_ItemId src; // index to LF_STRING_ID record where source file name is saved - unsigned long line; // line number -} lfUdtSrcLine; - -typedef struct lfUdtModSrcLine { - unsigned short leaf; // LF_UDT_MOD_SRC_LINE - CV_typ_t type; // UDT's type index - CV_ItemId src; // index into string table where source file name is saved - unsigned long line; // line number - unsigned short imod; // module that contributes this UDT definition -} lfUdtModSrcLine; - -typedef enum CV_BuildInfo_e { - CV_BuildInfo_CurrentDirectory = 0, - CV_BuildInfo_BuildTool = 1, // Cl.exe - CV_BuildInfo_SourceFile = 2, // foo.cpp - CV_BuildInfo_ProgramDatabaseFile = 3, // foo.pdb - CV_BuildInfo_CommandArguments = 4, // -I etc - CV_BUILDINFO_KNOWN -} CV_BuildInfo_e; - -// type record for build information - -typedef struct lfBuildInfo { - unsigned short leaf; // LF_BUILDINFO - unsigned short count; // number of arguments - CV_ItemId arg[CV_BUILDINFO_KNOWN]; // arguments as CodeItemId -} lfBuildInfo; - -// type record for LF_MANAGED - -typedef struct lfManaged { - unsigned short leaf; // LF_MANAGED - unsigned char Name[1]; // utf8, zero terminated managed type name -} lfManaged; - - -// type record for LF_ENUM - - -typedef struct lfEnum_16t { - unsigned short leaf; // LF_ENUM_16t - unsigned short count; // count of number of elements in class - CV_typ16_t utype; // underlying type of the enum - CV_typ16_t field; // type index of LF_FIELD descriptor list - CV_prop_t property; // property attribute field - unsigned char Name[1]; // length prefixed name of enum -} lfEnum_16t; - -typedef struct lfEnum { - unsigned short leaf; // LF_ENUM - unsigned short count; // count of number of elements in class - CV_prop_t property; // property attribute field - CV_typ_t utype; // underlying type of the enum - CV_typ_t field; // type index of LF_FIELD descriptor list - unsigned char Name[1]; // length prefixed name of enum -} lfEnum; - - - -// Type record for LF_PROCEDURE - - -typedef struct lfProc_16t { - unsigned short leaf; // LF_PROCEDURE_16t - CV_typ16_t rvtype; // type index of return value - unsigned char calltype; // calling convention (CV_call_t) - CV_funcattr_t funcattr; // attributes - unsigned short parmcount; // number of parameters - CV_typ16_t arglist; // type index of argument list -} lfProc_16t; - -typedef struct lfProc { - unsigned short leaf; // LF_PROCEDURE - CV_typ_t rvtype; // type index of return value - unsigned char calltype; // calling convention (CV_call_t) - CV_funcattr_t funcattr; // attributes - unsigned short parmcount; // number of parameters - CV_typ_t arglist; // type index of argument list -} lfProc; - - - -// Type record for member function - - -typedef struct lfMFunc_16t { - unsigned short leaf; // LF_MFUNCTION_16t - CV_typ16_t rvtype; // type index of return value - CV_typ16_t classtype; // type index of containing class - CV_typ16_t thistype; // type index of this pointer (model specific) - unsigned char calltype; // calling convention (call_t) - CV_funcattr_t funcattr; // attributes - unsigned short parmcount; // number of parameters - CV_typ16_t arglist; // type index of argument list - long thisadjust; // this adjuster (long because pad required anyway) -} lfMFunc_16t; - -typedef struct lfMFunc { - unsigned short leaf; // LF_MFUNCTION - CV_typ_t rvtype; // type index of return value - CV_typ_t classtype; // type index of containing class - CV_typ_t thistype; // type index of this pointer (model specific) - unsigned char calltype; // calling convention (call_t) - CV_funcattr_t funcattr; // attributes - unsigned short parmcount; // number of parameters - CV_typ_t arglist; // type index of argument list - long thisadjust; // this adjuster (long because pad required anyway) -} lfMFunc; - - - - -// type record for virtual function table shape - - -typedef struct lfVTShape { - unsigned short leaf; // LF_VTSHAPE - unsigned short count; // number of entries in vfunctable - unsigned char desc[CV_ZEROLEN]; // 4 bit (CV_VTS_desc) descriptors -} lfVTShape; - -// type record for a virtual function table -typedef struct lfVftable { - unsigned short leaf; // LF_VFTABLE - CV_typ_t type; // class/structure that owns the vftable - CV_typ_t baseVftable; // vftable from which this vftable is derived - unsigned long offsetInObjectLayout; // offset of the vfptr to this table, relative to the start of the object layout. - unsigned long len; // length of the Names array below in bytes. - unsigned char Names[1]; // array of names. - // The first is the name of the vtable. - // The others are the names of the methods. - // TS-TODO: replace a name with a NamedCodeItem once Weiping is done, to - // avoid duplication of method names. -} lfVftable; - -// type record for cobol0 - - -typedef struct lfCobol0_16t { - unsigned short leaf; // LF_COBOL0_16t - CV_typ16_t type; // parent type record index - unsigned char data[CV_ZEROLEN]; -} lfCobol0_16t; - -typedef struct lfCobol0 { - unsigned short leaf; // LF_COBOL0 - CV_typ_t type; // parent type record index - unsigned char data[CV_ZEROLEN]; -} lfCobol0; - - - - -// type record for cobol1 - - -typedef struct lfCobol1 { - unsigned short leaf; // LF_COBOL1 - unsigned char data[CV_ZEROLEN]; -} lfCobol1; - - - - -// type record for basic array - - -typedef struct lfBArray_16t { - unsigned short leaf; // LF_BARRAY_16t - CV_typ16_t utype; // type index of underlying type -} lfBArray_16t; - -typedef struct lfBArray { - unsigned short leaf; // LF_BARRAY - CV_typ_t utype; // type index of underlying type -} lfBArray; - -// type record for assembler labels - - -typedef struct lfLabel { - unsigned short leaf; // LF_LABEL - unsigned short mode; // addressing mode of label -} lfLabel; - - - -// type record for dimensioned arrays - - -typedef struct lfDimArray_16t { - unsigned short leaf; // LF_DIMARRAY_16t - CV_typ16_t utype; // underlying type of the array - CV_typ16_t diminfo; // dimension information - unsigned char name[1]; // length prefixed name -} lfDimArray_16t; - -typedef struct lfDimArray { - unsigned short leaf; // LF_DIMARRAY - CV_typ_t utype; // underlying type of the array - CV_typ_t diminfo; // dimension information - unsigned char name[1]; // length prefixed name -} lfDimArray; - - - -// type record describing path to virtual function table - - -typedef struct lfVFTPath_16t { - unsigned short leaf; // LF_VFTPATH_16t - unsigned short count; // count of number of bases in path - CV_typ16_t base[1]; // bases from root to leaf -} lfVFTPath_16t; - -typedef struct lfVFTPath { - unsigned short leaf; // LF_VFTPATH - unsigned long count; // count of number of bases in path - CV_typ_t base[1]; // bases from root to leaf -} lfVFTPath; - - -// type record describing inclusion of precompiled types - - -typedef struct lfPreComp_16t { - unsigned short leaf; // LF_PRECOMP_16t - unsigned short start; // starting type index included - unsigned short count; // number of types in inclusion - unsigned long signature; // signature - unsigned char name[CV_ZEROLEN]; // length prefixed name of included type file -} lfPreComp_16t; - -typedef struct lfPreComp { - unsigned short leaf; // LF_PRECOMP - unsigned long start; // starting type index included - unsigned long count; // number of types in inclusion - unsigned long signature; // signature - unsigned char name[CV_ZEROLEN]; // length prefixed name of included type file -} lfPreComp; - - - -// type record describing end of precompiled types that can be -// included by another file - - -typedef struct lfEndPreComp { - unsigned short leaf; // LF_ENDPRECOMP - unsigned long signature; // signature -} lfEndPreComp; - - - - - -// type record for OEM definable type strings - - -typedef struct lfOEM_16t { - unsigned short leaf; // LF_OEM_16t - unsigned short cvOEM; // MS assigned OEM identified - unsigned short recOEM; // OEM assigned type identifier - unsigned short count; // count of type indices to follow - CV_typ16_t index[CV_ZEROLEN]; // array of type indices followed - // by OEM defined data -} lfOEM_16t; - -typedef struct lfOEM { - unsigned short leaf; // LF_OEM - unsigned short cvOEM; // MS assigned OEM identified - unsigned short recOEM; // OEM assigned type identifier - unsigned long count; // count of type indices to follow - CV_typ_t index[CV_ZEROLEN]; // array of type indices followed - // by OEM defined data -} lfOEM; - -#define OEM_MS_FORTRAN90 0xF090 -#define OEM_ODI 0x0010 -#define OEM_THOMSON_SOFTWARE 0x5453 -#define OEM_ODI_REC_BASELIST 0x0000 - -typedef struct lfOEM2 { - unsigned short leaf; // LF_OEM2 - unsigned char idOem[16]; // an oem ID (GUID) - unsigned long count; // count of type indices to follow - CV_typ_t index[CV_ZEROLEN]; // array of type indices followed - // by OEM defined data -} lfOEM2; - -// type record describing using of a type server - -typedef struct lfTypeServer { - unsigned short leaf; // LF_TYPESERVER - unsigned long signature; // signature - unsigned long age; // age of database used by this module - unsigned char name[CV_ZEROLEN]; // length prefixed name of PDB -} lfTypeServer; - -// type record describing using of a type server with v7 (GUID) signatures - -typedef struct lfTypeServer2 { - unsigned short leaf; // LF_TYPESERVER2 - SIG70 sig70; // guid signature - unsigned long age; // age of database used by this module - unsigned char name[CV_ZEROLEN]; // length prefixed name of PDB -} lfTypeServer2; - -// description of type records that can be referenced from -// type records referenced by symbols - - - -// type record for skip record - - -typedef struct lfSkip_16t { - unsigned short leaf; // LF_SKIP_16t - CV_typ16_t type; // next valid index - unsigned char data[CV_ZEROLEN]; // pad data -} lfSkip_16t; - -typedef struct lfSkip { - unsigned short leaf; // LF_SKIP - CV_typ_t type; // next valid index - unsigned char data[CV_ZEROLEN]; // pad data -} lfSkip; - - - -// argument list leaf - - -typedef struct lfArgList_16t { - unsigned short leaf; // LF_ARGLIST_16t - unsigned short count; // number of arguments - CV_typ16_t arg[CV_ZEROLEN]; // number of arguments -} lfArgList_16t; - -typedef struct lfArgList { - unsigned short leaf; // LF_ARGLIST, LF_SUBSTR_LIST - unsigned long count; // number of arguments - CV_typ_t arg[CV_ZEROLEN]; // number of arguments -} lfArgList; - - - - -// derived class list leaf - - -typedef struct lfDerived_16t { - unsigned short leaf; // LF_DERIVED_16t - unsigned short count; // number of arguments - CV_typ16_t drvdcls[CV_ZEROLEN]; // type indices of derived classes -} lfDerived_16t; - -typedef struct lfDerived { - unsigned short leaf; // LF_DERIVED - unsigned long count; // number of arguments - CV_typ_t drvdcls[CV_ZEROLEN]; // type indices of derived classes -} lfDerived; - - - - -// leaf for default arguments - - -typedef struct lfDefArg_16t { - unsigned short leaf; // LF_DEFARG_16t - CV_typ16_t type; // type of resulting expression - unsigned char expr[CV_ZEROLEN]; // length prefixed expression string -} lfDefArg_16t; - -typedef struct lfDefArg { - unsigned short leaf; // LF_DEFARG - CV_typ_t type; // type of resulting expression - unsigned char expr[CV_ZEROLEN]; // length prefixed expression string -} lfDefArg; - - - -// list leaf -// This list should no longer be used because the utilities cannot -// verify the contents of the list without knowing what type of list -// it is. New specific leaf indices should be used instead. - - -typedef struct lfList { - unsigned short leaf; // LF_LIST - char data[CV_ZEROLEN]; // data format specified by indexing type -} lfList; - - - - -// field list leaf -// This is the header leaf for a complex list of class and structure -// subfields. - - -typedef struct lfFieldList_16t { - unsigned short leaf; // LF_FIELDLIST_16t - char data[CV_ZEROLEN]; // field list sub lists -} lfFieldList_16t; - - -typedef struct lfFieldList { - unsigned short leaf; // LF_FIELDLIST - char data[CV_ZEROLEN]; // field list sub lists -} lfFieldList; - - - - - - - -// type record for non-static methods and friends in overloaded method list - -typedef struct mlMethod_16t { - CV_fldattr_t attr; // method attribute - CV_typ16_t index; // index to type record for procedure - unsigned long vbaseoff[CV_ZEROLEN]; // offset in vfunctable if intro virtual -} mlMethod_16t; - -typedef struct mlMethod { - CV_fldattr_t attr; // method attribute - _2BYTEPAD pad0; // internal padding, must be 0 - CV_typ_t index; // index to type record for procedure - unsigned long vbaseoff[CV_ZEROLEN]; // offset in vfunctable if intro virtual -} mlMethod; - - -typedef struct lfMethodList_16t { - unsigned short leaf; - unsigned char mList[CV_ZEROLEN]; // really a mlMethod_16t type -} lfMethodList_16t; - -typedef struct lfMethodList { - unsigned short leaf; - unsigned char mList[CV_ZEROLEN]; // really a mlMethod type -} lfMethodList; - - - - - -// type record for LF_BITFIELD - - -typedef struct lfBitfield_16t { - unsigned short leaf; // LF_BITFIELD_16t - unsigned char length; - unsigned char position; - CV_typ16_t type; // type of bitfield - -} lfBitfield_16t; - -typedef struct lfBitfield { - unsigned short leaf; // LF_BITFIELD - CV_typ_t type; // type of bitfield - unsigned char length; - unsigned char position; - -} lfBitfield; - - - - -// type record for dimensioned array with constant bounds - - -typedef struct lfDimCon_16t { - unsigned short leaf; // LF_DIMCONU_16t or LF_DIMCONLU_16t - unsigned short rank; // number of dimensions - CV_typ16_t typ; // type of index - unsigned char dim[CV_ZEROLEN]; // array of dimension information with - // either upper bounds or lower/upper bound -} lfDimCon_16t; - -typedef struct lfDimCon { - unsigned short leaf; // LF_DIMCONU or LF_DIMCONLU - CV_typ_t typ; // type of index - unsigned short rank; // number of dimensions - unsigned char dim[CV_ZEROLEN]; // array of dimension information with - // either upper bounds or lower/upper bound -} lfDimCon; - - - - -// type record for dimensioned array with variable bounds - - -typedef struct lfDimVar_16t { - unsigned short leaf; // LF_DIMVARU_16t or LF_DIMVARLU_16t - unsigned short rank; // number of dimensions - CV_typ16_t typ; // type of index - CV_typ16_t dim[CV_ZEROLEN]; // array of type indices for either - // variable upper bound or variable - // lower/upper bound. The referenced - // types must be LF_REFSYM or T_VOID -} lfDimVar_16t; - -typedef struct lfDimVar { - unsigned short leaf; // LF_DIMVARU or LF_DIMVARLU - unsigned long rank; // number of dimensions - CV_typ_t typ; // type of index - CV_typ_t dim[CV_ZEROLEN]; // array of type indices for either - // variable upper bound or variable - // lower/upper bound. The count of type - // indices is rank or rank*2 depending on - // whether it is LFDIMVARU or LF_DIMVARLU. - // The referenced types must be - // LF_REFSYM or T_VOID -} lfDimVar; - - - - -// type record for referenced symbol - - -typedef struct lfRefSym { - unsigned short leaf; // LF_REFSYM - unsigned char Sym[1]; // copy of referenced symbol record - // (including length) -} lfRefSym; - - - -// type record for generic HLSL type - - -typedef struct lfHLSL { - unsigned short leaf; // LF_HLSL - CV_typ_t subtype; // sub-type index, if any - unsigned short kind; // kind of built-in type from CV_builtin_e - unsigned short numprops : 4; // number of numeric properties - unsigned short unused : 12; // padding, must be 0 - unsigned char data[CV_ZEROLEN]; // variable-length array of numeric properties - // followed by byte size -} lfHLSL; - - - - -// type record for a generalized built-in type modifier - - -typedef struct lfModifierEx { - unsigned short leaf; // LF_MODIFIER_EX - CV_typ_t type; // type being modified - unsigned short count; // count of modifier values - unsigned short mods[CV_ZEROLEN]; // modifiers from CV_modifier_e -} lfModifierEx; - - - - -/** the following are numeric leaves. They are used to indicate the - * size of the following variable length data. When the numeric - * data is a single byte less than 0x8000, then the data is output - * directly. If the data is more the 0x8000 or is a negative value, - * then the data is preceeded by the proper index. - */ - - - -// signed character leaf - -typedef struct lfChar { - unsigned short leaf; // LF_CHAR - signed char val; // signed 8-bit value -} lfChar; - - - - -// signed short leaf - -typedef struct lfShort { - unsigned short leaf; // LF_SHORT - short val; // signed 16-bit value -} lfShort; - - - - -// unsigned short leaf - -typedef struct lfUShort { - unsigned short leaf; // LF_unsigned short - unsigned short val; // unsigned 16-bit value -} lfUShort; - - - - -// signed long leaf - -typedef struct lfLong { - unsigned short leaf; // LF_LONG - long val; // signed 32-bit value -} lfLong; - - - - -// unsigned long leaf - -typedef struct lfULong { - unsigned short leaf; // LF_ULONG - unsigned long val; // unsigned 32-bit value -} lfULong; - - - - -// signed quad leaf - -typedef struct lfQuad { - unsigned short leaf; // LF_QUAD - unsigned char val[8]; // signed 64-bit value -} lfQuad; - - - - -// unsigned quad leaf - -typedef struct lfUQuad { - unsigned short leaf; // LF_UQUAD - unsigned char val[8]; // unsigned 64-bit value -} lfUQuad; - - -// signed int128 leaf - -typedef struct lfOct { - unsigned short leaf; // LF_OCT - unsigned char val[16]; // signed 128-bit value -} lfOct; - -// unsigned int128 leaf - -typedef struct lfUOct { - unsigned short leaf; // LF_UOCT - unsigned char val[16]; // unsigned 128-bit value -} lfUOct; - - - - -// real 16-bit leaf - -typedef struct lfReal16 { - unsigned short leaf; // LF_REAL16 - unsigned short val; // 16-bit real value -} lfReal16; - - - - -// real 32-bit leaf - -typedef struct lfReal32 { - unsigned short leaf; // LF_REAL32 - float val; // 32-bit real value -} lfReal32; - - - - -// real 48-bit leaf - -typedef struct lfReal48 { - unsigned short leaf; // LF_REAL48 - unsigned char val[6]; // 48-bit real value -} lfReal48; - - - - -// real 64-bit leaf - -typedef struct lfReal64 { - unsigned short leaf; // LF_REAL64 - double val; // 64-bit real value -} lfReal64; - - - - -// real 80-bit leaf - -typedef struct lfReal80 { - unsigned short leaf; // LF_REAL80 - FLOAT10 val; // real 80-bit value -} lfReal80; - - - - -// real 128-bit leaf - -typedef struct lfReal128 { - unsigned short leaf; // LF_REAL128 - char val[16]; // real 128-bit value -} lfReal128; - - - - -// complex 32-bit leaf - -typedef struct lfCmplx32 { - unsigned short leaf; // LF_COMPLEX32 - float val_real; // real component - float val_imag; // imaginary component -} lfCmplx32; - - - - -// complex 64-bit leaf - -typedef struct lfCmplx64 { - unsigned short leaf; // LF_COMPLEX64 - double val_real; // real component - double val_imag; // imaginary component -} flCmplx64; - - - - -// complex 80-bit leaf - -typedef struct lfCmplx80 { - unsigned short leaf; // LF_COMPLEX80 - FLOAT10 val_real; // real component - FLOAT10 val_imag; // imaginary component -} lfCmplx80; - - - - -// complex 128-bit leaf - -typedef struct lfCmplx128 { - unsigned short leaf; // LF_COMPLEX128 - char val_real[16]; // real component - char val_imag[16]; // imaginary component -} lfCmplx128; - - - -// variable length numeric field - -typedef struct lfVarString { - unsigned short leaf; // LF_VARSTRING - unsigned short len; // length of value in bytes - unsigned char value[CV_ZEROLEN]; // value -} lfVarString; - -//*********************************************************************** - - -// index leaf - contains type index of another leaf -// a major use of this leaf is to allow the compilers to emit a -// long complex list (LF_FIELD) in smaller pieces. - -typedef struct lfIndex_16t { - unsigned short leaf; // LF_INDEX_16t - CV_typ16_t index; // type index of referenced leaf -} lfIndex_16t; - -typedef struct lfIndex { - unsigned short leaf; // LF_INDEX - _2BYTEPAD pad0; // internal padding, must be 0 - CV_typ_t index; // type index of referenced leaf -} lfIndex; - - -// subfield record for base class field - -typedef struct lfBClass_16t { - unsigned short leaf; // LF_BCLASS_16t - CV_typ16_t index; // type index of base class - CV_fldattr_t attr; // attribute - unsigned char offset[CV_ZEROLEN]; // variable length offset of base within class -} lfBClass_16t; - -typedef struct lfBClass { - unsigned short leaf; // LF_BCLASS, LF_BINTERFACE - CV_fldattr_t attr; // attribute - CV_typ_t index; // type index of base class - unsigned char offset[CV_ZEROLEN]; // variable length offset of base within class -} lfBClass; -typedef lfBClass lfBInterface; - - - - -// subfield record for direct and indirect virtual base class field - -typedef struct lfVBClass_16t { - unsigned short leaf; // LF_VBCLASS_16t | LV_IVBCLASS_16t - CV_typ16_t index; // type index of direct virtual base class - CV_typ16_t vbptr; // type index of virtual base pointer - CV_fldattr_t attr; // attribute - unsigned char vbpoff[CV_ZEROLEN]; // virtual base pointer offset from address point - // followed by virtual base offset from vbtable -} lfVBClass_16t; - -typedef struct lfVBClass { - unsigned short leaf; // LF_VBCLASS | LV_IVBCLASS - CV_fldattr_t attr; // attribute - CV_typ_t index; // type index of direct virtual base class - CV_typ_t vbptr; // type index of virtual base pointer - unsigned char vbpoff[CV_ZEROLEN]; // virtual base pointer offset from address point - // followed by virtual base offset from vbtable -} lfVBClass; - - - - - -// subfield record for friend class - - -typedef struct lfFriendCls_16t { - unsigned short leaf; // LF_FRIENDCLS_16t - CV_typ16_t index; // index to type record of friend class -} lfFriendCls_16t; - -typedef struct lfFriendCls { - unsigned short leaf; // LF_FRIENDCLS - _2BYTEPAD pad0; // internal padding, must be 0 - CV_typ_t index; // index to type record of friend class -} lfFriendCls; - - - - - -// subfield record for friend function - - -typedef struct lfFriendFcn_16t { - unsigned short leaf; // LF_FRIENDFCN_16t - CV_typ16_t index; // index to type record of friend function - unsigned char Name[1]; // name of friend function -} lfFriendFcn_16t; - -typedef struct lfFriendFcn { - unsigned short leaf; // LF_FRIENDFCN - _2BYTEPAD pad0; // internal padding, must be 0 - CV_typ_t index; // index to type record of friend function - unsigned char Name[1]; // name of friend function -} lfFriendFcn; - - - -// subfield record for non-static data members - -typedef struct lfMember_16t { - unsigned short leaf; // LF_MEMBER_16t - CV_typ16_t index; // index of type record for field - CV_fldattr_t attr; // attribute mask - unsigned char offset[CV_ZEROLEN]; // variable length offset of field followed - // by length prefixed name of field -} lfMember_16t; - -typedef struct lfMember { - unsigned short leaf; // LF_MEMBER - CV_fldattr_t attr; // attribute mask - CV_typ_t index; // index of type record for field - unsigned char offset[CV_ZEROLEN]; // variable length offset of field followed - // by length prefixed name of field -} lfMember; - - - -// type record for static data members - -typedef struct lfSTMember_16t { - unsigned short leaf; // LF_STMEMBER_16t - CV_typ16_t index; // index of type record for field - CV_fldattr_t attr; // attribute mask - unsigned char Name[1]; // length prefixed name of field -} lfSTMember_16t; - -typedef struct lfSTMember { - unsigned short leaf; // LF_STMEMBER - CV_fldattr_t attr; // attribute mask - CV_typ_t index; // index of type record for field - unsigned char Name[1]; // length prefixed name of field -} lfSTMember; - - - -// subfield record for virtual function table pointer - -typedef struct lfVFuncTab_16t { - unsigned short leaf; // LF_VFUNCTAB_16t - CV_typ16_t type; // type index of pointer -} lfVFuncTab_16t; - -typedef struct lfVFuncTab { - unsigned short leaf; // LF_VFUNCTAB - _2BYTEPAD pad0; // internal padding, must be 0 - CV_typ_t type; // type index of pointer -} lfVFuncTab; - - - -// subfield record for virtual function table pointer with offset - -typedef struct lfVFuncOff_16t { - unsigned short leaf; // LF_VFUNCOFF_16t - CV_typ16_t type; // type index of pointer - CV_off32_t offset; // offset of virtual function table pointer -} lfVFuncOff_16t; - -typedef struct lfVFuncOff { - unsigned short leaf; // LF_VFUNCOFF - _2BYTEPAD pad0; // internal padding, must be 0. - CV_typ_t type; // type index of pointer - CV_off32_t offset; // offset of virtual function table pointer -} lfVFuncOff; - - - -// subfield record for overloaded method list - - -typedef struct lfMethod_16t { - unsigned short leaf; // LF_METHOD_16t - unsigned short count; // number of occurrences of function - CV_typ16_t mList; // index to LF_METHODLIST record - unsigned char Name[1]; // length prefixed name of method -} lfMethod_16t; - -typedef struct lfMethod { - unsigned short leaf; // LF_METHOD - unsigned short count; // number of occurrences of function - CV_typ_t mList; // index to LF_METHODLIST record - unsigned char Name[1]; // length prefixed name of method -} lfMethod; - - - -// subfield record for nonoverloaded method - - -typedef struct lfOneMethod_16t { - unsigned short leaf; // LF_ONEMETHOD_16t - CV_fldattr_t attr; // method attribute - CV_typ16_t index; // index to type record for procedure - unsigned long vbaseoff[CV_ZEROLEN]; // offset in vfunctable if - // intro virtual followed by - // length prefixed name of method -} lfOneMethod_16t; - -typedef struct lfOneMethod { - unsigned short leaf; // LF_ONEMETHOD - CV_fldattr_t attr; // method attribute - CV_typ_t index; // index to type record for procedure - unsigned long vbaseoff[CV_ZEROLEN]; // offset in vfunctable if - // intro virtual followed by - // length prefixed name of method -} lfOneMethod; - - -// subfield record for enumerate - -typedef struct lfEnumerate { - unsigned short leaf; // LF_ENUMERATE - CV_fldattr_t attr; // access - unsigned char value[CV_ZEROLEN]; // variable length value field followed - // by length prefixed name -} lfEnumerate; - - -// type record for nested (scoped) type definition - -typedef struct lfNestType_16t { - unsigned short leaf; // LF_NESTTYPE_16t - CV_typ16_t index; // index of nested type definition - unsigned char Name[1]; // length prefixed type name -} lfNestType_16t; - -typedef struct lfNestType { - unsigned short leaf; // LF_NESTTYPE - _2BYTEPAD pad0; // internal padding, must be 0 - CV_typ_t index; // index of nested type definition - unsigned char Name[1]; // length prefixed type name -} lfNestType; - -// type record for nested (scoped) type definition, with attributes -// new records for vC v5.0, no need to have 16-bit ti versions. - -typedef struct lfNestTypeEx { - unsigned short leaf; // LF_NESTTYPEEX - CV_fldattr_t attr; // member access - CV_typ_t index; // index of nested type definition - unsigned char Name[1]; // length prefixed type name -} lfNestTypeEx; - -// type record for modifications to members - -typedef struct lfMemberModify { - unsigned short leaf; // LF_MEMBERMODIFY - CV_fldattr_t attr; // the new attributes - CV_typ_t index; // index of base class type definition - unsigned char Name[1]; // length prefixed member name -} lfMemberModify; - -// type record for pad leaf - -typedef struct lfPad { - unsigned char leaf; -} SYM_PAD; - - - -// Symbol definitions - -typedef enum SYM_ENUM_e { - S_COMPILE = 0x0001, // Compile flags symbol - S_REGISTER_16t = 0x0002, // Register variable - S_CONSTANT_16t = 0x0003, // constant symbol - S_UDT_16t = 0x0004, // User defined type - S_SSEARCH = 0x0005, // Start Search - S_END = 0x0006, // Block, procedure, "with" or thunk end - S_SKIP = 0x0007, // Reserve symbol space in $$Symbols table - S_CVRESERVE = 0x0008, // Reserved symbol for CV internal use - S_OBJNAME_ST = 0x0009, // path to object file name - S_ENDARG = 0x000a, // end of argument/return list - S_COBOLUDT_16t = 0x000b, // special UDT for cobol that does not symbol pack - S_MANYREG_16t = 0x000c, // multiple register variable - S_RETURN = 0x000d, // return description symbol - S_ENTRYTHIS = 0x000e, // description of this pointer on entry - - S_BPREL16 = 0x0100, // BP-relative - S_LDATA16 = 0x0101, // Module-local symbol - S_GDATA16 = 0x0102, // Global data symbol - S_PUB16 = 0x0103, // a public symbol - S_LPROC16 = 0x0104, // Local procedure start - S_GPROC16 = 0x0105, // Global procedure start - S_THUNK16 = 0x0106, // Thunk Start - S_BLOCK16 = 0x0107, // block start - S_WITH16 = 0x0108, // with start - S_LABEL16 = 0x0109, // code label - S_CEXMODEL16 = 0x010a, // change execution model - S_VFTABLE16 = 0x010b, // address of virtual function table - S_REGREL16 = 0x010c, // register relative address - - S_BPREL32_16t = 0x0200, // BP-relative - S_LDATA32_16t = 0x0201, // Module-local symbol - S_GDATA32_16t = 0x0202, // Global data symbol - S_PUB32_16t = 0x0203, // a public symbol (CV internal reserved) - S_LPROC32_16t = 0x0204, // Local procedure start - S_GPROC32_16t = 0x0205, // Global procedure start - S_THUNK32_ST = 0x0206, // Thunk Start - S_BLOCK32_ST = 0x0207, // block start - S_WITH32_ST = 0x0208, // with start - S_LABEL32_ST = 0x0209, // code label - S_CEXMODEL32 = 0x020a, // change execution model - S_VFTABLE32_16t = 0x020b, // address of virtual function table - S_REGREL32_16t = 0x020c, // register relative address - S_LTHREAD32_16t = 0x020d, // local thread storage - S_GTHREAD32_16t = 0x020e, // global thread storage - S_SLINK32 = 0x020f, // static link for MIPS EH implementation - - S_LPROCMIPS_16t = 0x0300, // Local procedure start - S_GPROCMIPS_16t = 0x0301, // Global procedure start - - // if these ref symbols have names following then the names are in ST format - S_PROCREF_ST = 0x0400, // Reference to a procedure - S_DATAREF_ST = 0x0401, // Reference to data - S_ALIGN = 0x0402, // Used for page alignment of symbols - - S_LPROCREF_ST = 0x0403, // Local Reference to a procedure - S_OEM = 0x0404, // OEM defined symbol - - // sym records with 32-bit types embedded instead of 16-bit - // all have 0x1000 bit set for easy identification - // only do the 32-bit target versions since we don't really - // care about 16-bit ones anymore. - S_TI16_MAX = 0x1000, - - S_REGISTER_ST = 0x1001, // Register variable - S_CONSTANT_ST = 0x1002, // constant symbol - S_UDT_ST = 0x1003, // User defined type - S_COBOLUDT_ST = 0x1004, // special UDT for cobol that does not symbol pack - S_MANYREG_ST = 0x1005, // multiple register variable - S_BPREL32_ST = 0x1006, // BP-relative - S_LDATA32_ST = 0x1007, // Module-local symbol - S_GDATA32_ST = 0x1008, // Global data symbol - S_PUB32_ST = 0x1009, // a public symbol (CV internal reserved) - S_LPROC32_ST = 0x100a, // Local procedure start - S_GPROC32_ST = 0x100b, // Global procedure start - S_VFTABLE32 = 0x100c, // address of virtual function table - S_REGREL32_ST = 0x100d, // register relative address - S_LTHREAD32_ST = 0x100e, // local thread storage - S_GTHREAD32_ST = 0x100f, // global thread storage - - S_LPROCMIPS_ST = 0x1010, // Local procedure start - S_GPROCMIPS_ST = 0x1011, // Global procedure start - - S_FRAMEPROC = 0x1012, // extra frame and proc information - S_COMPILE2_ST = 0x1013, // extended compile flags and info - - // new symbols necessary for 16-bit enumerates of IA64 registers - // and IA64 specific symbols - - S_MANYREG2_ST = 0x1014, // multiple register variable - S_LPROCIA64_ST = 0x1015, // Local procedure start (IA64) - S_GPROCIA64_ST = 0x1016, // Global procedure start (IA64) - - // Local symbols for IL - S_LOCALSLOT_ST = 0x1017, // local IL sym with field for local slot index - S_PARAMSLOT_ST = 0x1018, // local IL sym with field for parameter slot index - - S_ANNOTATION = 0x1019, // Annotation string literals - - // symbols to support managed code debugging - S_GMANPROC_ST = 0x101a, // Global proc - S_LMANPROC_ST = 0x101b, // Local proc - S_RESERVED1 = 0x101c, // reserved - S_RESERVED2 = 0x101d, // reserved - S_RESERVED3 = 0x101e, // reserved - S_RESERVED4 = 0x101f, // reserved - S_LMANDATA_ST = 0x1020, - S_GMANDATA_ST = 0x1021, - S_MANFRAMEREL_ST= 0x1022, - S_MANREGISTER_ST= 0x1023, - S_MANSLOT_ST = 0x1024, - S_MANMANYREG_ST = 0x1025, - S_MANREGREL_ST = 0x1026, - S_MANMANYREG2_ST= 0x1027, - S_MANTYPREF = 0x1028, // Index for type referenced by name from metadata - S_UNAMESPACE_ST = 0x1029, // Using namespace - - // Symbols w/ SZ name fields. All name fields contain utf8 encoded strings. - S_ST_MAX = 0x1100, // starting point for SZ name symbols - - S_OBJNAME = 0x1101, // path to object file name - S_THUNK32 = 0x1102, // Thunk Start - S_BLOCK32 = 0x1103, // block start - S_WITH32 = 0x1104, // with start - S_LABEL32 = 0x1105, // code label - S_REGISTER = 0x1106, // Register variable - S_CONSTANT = 0x1107, // constant symbol - S_UDT = 0x1108, // User defined type - S_COBOLUDT = 0x1109, // special UDT for cobol that does not symbol pack - S_MANYREG = 0x110a, // multiple register variable - S_BPREL32 = 0x110b, // BP-relative - S_LDATA32 = 0x110c, // Module-local symbol - S_GDATA32 = 0x110d, // Global data symbol - S_PUB32 = 0x110e, // a public symbol (CV internal reserved) - S_LPROC32 = 0x110f, // Local procedure start - S_GPROC32 = 0x1110, // Global procedure start - S_REGREL32 = 0x1111, // register relative address - S_LTHREAD32 = 0x1112, // local thread storage - S_GTHREAD32 = 0x1113, // global thread storage - - S_LPROCMIPS = 0x1114, // Local procedure start - S_GPROCMIPS = 0x1115, // Global procedure start - S_COMPILE2 = 0x1116, // extended compile flags and info - S_MANYREG2 = 0x1117, // multiple register variable - S_LPROCIA64 = 0x1118, // Local procedure start (IA64) - S_GPROCIA64 = 0x1119, // Global procedure start (IA64) - S_LOCALSLOT = 0x111a, // local IL sym with field for local slot index - S_SLOT = S_LOCALSLOT, // alias for LOCALSLOT - S_PARAMSLOT = 0x111b, // local IL sym with field for parameter slot index - - // symbols to support managed code debugging - S_LMANDATA = 0x111c, - S_GMANDATA = 0x111d, - S_MANFRAMEREL = 0x111e, - S_MANREGISTER = 0x111f, - S_MANSLOT = 0x1120, - S_MANMANYREG = 0x1121, - S_MANREGREL = 0x1122, - S_MANMANYREG2 = 0x1123, - S_UNAMESPACE = 0x1124, // Using namespace - - // ref symbols with name fields - S_PROCREF = 0x1125, // Reference to a procedure - S_DATAREF = 0x1126, // Reference to data - S_LPROCREF = 0x1127, // Local Reference to a procedure - S_ANNOTATIONREF = 0x1128, // Reference to an S_ANNOTATION symbol - S_TOKENREF = 0x1129, // Reference to one of the many MANPROCSYM's - - // continuation of managed symbols - S_GMANPROC = 0x112a, // Global proc - S_LMANPROC = 0x112b, // Local proc - - // short, light-weight thunks - S_TRAMPOLINE = 0x112c, // trampoline thunks - S_MANCONSTANT = 0x112d, // constants with metadata type info - - // native attributed local/parms - S_ATTR_FRAMEREL = 0x112e, // relative to virtual frame ptr - S_ATTR_REGISTER = 0x112f, // stored in a register - S_ATTR_REGREL = 0x1130, // relative to register (alternate frame ptr) - S_ATTR_MANYREG = 0x1131, // stored in >1 register - - // Separated code (from the compiler) support - S_SEPCODE = 0x1132, - - S_LOCAL_2005 = 0x1133, // defines a local symbol in optimized code - S_DEFRANGE_2005 = 0x1134, // defines a single range of addresses in which symbol can be evaluated - S_DEFRANGE2_2005 = 0x1135, // defines ranges of addresses in which symbol can be evaluated - - S_SECTION = 0x1136, // A COFF section in a PE executable - S_COFFGROUP = 0x1137, // A COFF group - S_EXPORT = 0x1138, // A export - - S_CALLSITEINFO = 0x1139, // Indirect call site information - S_FRAMECOOKIE = 0x113a, // Security cookie information - - S_DISCARDED = 0x113b, // Discarded by LINK /OPT:REF (experimental, see richards) - - S_COMPILE3 = 0x113c, // Replacement for S_COMPILE2 - S_ENVBLOCK = 0x113d, // Environment block split off from S_COMPILE2 - - S_LOCAL = 0x113e, // defines a local symbol in optimized code - S_DEFRANGE = 0x113f, // defines a single range of addresses in which symbol can be evaluated - S_DEFRANGE_SUBFIELD = 0x1140, // ranges for a subfield - - S_DEFRANGE_REGISTER = 0x1141, // ranges for en-registered symbol - S_DEFRANGE_FRAMEPOINTER_REL = 0x1142, // range for stack symbol. - S_DEFRANGE_SUBFIELD_REGISTER = 0x1143, // ranges for en-registered field of symbol - S_DEFRANGE_FRAMEPOINTER_REL_FULL_SCOPE = 0x1144, // range for stack symbol span valid full scope of function body, gap might apply. - S_DEFRANGE_REGISTER_REL = 0x1145, // range for symbol address as register + offset. - - // S_PROC symbols that reference ID instead of type - S_LPROC32_ID = 0x1146, - S_GPROC32_ID = 0x1147, - S_LPROCMIPS_ID = 0x1148, - S_GPROCMIPS_ID = 0x1149, - S_LPROCIA64_ID = 0x114a, - S_GPROCIA64_ID = 0x114b, - - S_BUILDINFO = 0x114c, // build information. - S_INLINESITE = 0x114d, // inlined function callsite. - S_INLINESITE_END = 0x114e, - S_PROC_ID_END = 0x114f, - - S_DEFRANGE_HLSL = 0x1150, - S_GDATA_HLSL = 0x1151, - S_LDATA_HLSL = 0x1152, - - S_FILESTATIC = 0x1153, - -#if defined(CC_DP_CXX) && CC_DP_CXX - - S_LOCAL_DPC_GROUPSHARED = 0x1154, // DPC groupshared variable - S_LPROC32_DPC = 0x1155, // DPC local procedure start - S_LPROC32_DPC_ID = 0x1156, - S_DEFRANGE_DPC_PTR_TAG = 0x1157, // DPC pointer tag definition range - S_DPC_SYM_TAG_MAP = 0x1158, // DPC pointer tag value to symbol record map - -#endif // CC_DP_CXX - - S_ARMSWITCHTABLE = 0x1159, - S_CALLEES = 0x115a, - S_CALLERS = 0x115b, - S_POGODATA = 0x115c, - S_INLINESITE2 = 0x115d, // extended inline site information - - S_HEAPALLOCSITE = 0x115e, // heap allocation site - - S_MOD_TYPEREF = 0x115f, // only generated at link time - - S_REF_MINIPDB = 0x1160, // only generated at link time for mini PDB - S_PDBMAP = 0x1161, // only generated at link time for mini PDB - - S_GDATA_HLSL32 = 0x1162, - S_LDATA_HLSL32 = 0x1163, - - S_GDATA_HLSL32_EX = 0x1164, - S_LDATA_HLSL32_EX = 0x1165, - - S_RECTYPE_MAX, // one greater than last - S_RECTYPE_LAST = S_RECTYPE_MAX - 1, - S_RECTYPE_PAD = S_RECTYPE_MAX + 0x100 // Used *only* to verify symbol record types so that current PDB code can potentially read - // future PDBs (assuming no format change, etc). - -} SYM_ENUM_e; - - -// enum describing compile flag ambient data model - - -typedef enum CV_CFL_DATA { - CV_CFL_DNEAR = 0x00, - CV_CFL_DFAR = 0x01, - CV_CFL_DHUGE = 0x02 -} CV_CFL_DATA; - - - - -// enum describing compile flag ambiant code model - - -typedef enum CV_CFL_CODE_e { - CV_CFL_CNEAR = 0x00, - CV_CFL_CFAR = 0x01, - CV_CFL_CHUGE = 0x02 -} CV_CFL_CODE_e; - - - - -// enum describing compile flag target floating point package - -typedef enum CV_CFL_FPKG_e { - CV_CFL_NDP = 0x00, - CV_CFL_EMU = 0x01, - CV_CFL_ALT = 0x02 -} CV_CFL_FPKG_e; - - -// enum describing function return method - - -typedef struct CV_PROCFLAGS { - union { - unsigned char bAll; - unsigned char grfAll; - struct { - unsigned char CV_PFLAG_NOFPO :1; // frame pointer present - unsigned char CV_PFLAG_INT :1; // interrupt return - unsigned char CV_PFLAG_FAR :1; // far return - unsigned char CV_PFLAG_NEVER :1; // function does not return - unsigned char CV_PFLAG_NOTREACHED:1; // label isn't fallen into - unsigned char CV_PFLAG_CUST_CALL :1; // custom calling convention - unsigned char CV_PFLAG_NOINLINE :1; // function marked as noinline - unsigned char CV_PFLAG_OPTDBGINFO:1; // function has debug information for optimized code - }; - }; -} CV_PROCFLAGS; - -// Extended proc flags -// -typedef struct CV_EXPROCFLAGS { - CV_PROCFLAGS cvpf; - union { - unsigned char grfAll; - struct { - unsigned char __reserved_byte :8; // must be zero - }; - }; -} CV_EXPROCFLAGS; - -// local variable flags -typedef struct CV_LVARFLAGS { - unsigned short fIsParam :1; // variable is a parameter - unsigned short fAddrTaken :1; // address is taken - unsigned short fCompGenx :1; // variable is compiler generated - unsigned short fIsAggregate :1; // the symbol is splitted in temporaries, - // which are treated by compiler as - // independent entities - unsigned short fIsAggregated :1; // Counterpart of fIsAggregate - tells - // that it is a part of a fIsAggregate symbol - unsigned short fIsAliased :1; // variable has multiple simultaneous lifetimes - unsigned short fIsAlias :1; // represents one of the multiple simultaneous lifetimes - unsigned short fIsRetValue :1; // represents a function return value - unsigned short fIsOptimizedOut :1; // variable has no lifetimes - unsigned short fIsEnregGlob :1; // variable is an enregistered global - unsigned short fIsEnregStat :1; // variable is an enregistered static - - unsigned short unused :5; // must be zero - -} CV_LVARFLAGS; - -// extended attributes common to all local variables -typedef struct CV_lvar_attr { - CV_uoff32_t off; // first code address where var is live - unsigned short seg; - CV_LVARFLAGS flags; // local var flags -} CV_lvar_attr; - -// This is max length of a lexical linear IP range. -// The upper number are reserved for seeded and flow based range - -#define CV_LEXICAL_RANGE_MAX 0xF000 - -// represents an address range, used for optimized code debug info - -typedef struct CV_LVAR_ADDR_RANGE { // defines a range of addresses - CV_uoff32_t offStart; - unsigned short isectStart; - unsigned short cbRange; -} CV_LVAR_ADDR_RANGE; - -// Represents the holes in overall address range, all address is pre-bbt. -// it is for compress and reduce the amount of relocations need. - -typedef struct CV_LVAR_ADDR_GAP { - unsigned short gapStartOffset; // relative offset from the beginning of the live range. - unsigned short cbRange; // length of this gap. -} CV_LVAR_ADDR_GAP; - -#if defined(CC_DP_CXX) && CC_DP_CXX - -// Represents a mapping from a DPC pointer tag value to the corresponding symbol record -typedef struct CV_DPC_SYM_TAG_MAP_ENTRY { - unsigned int tagValue; // address taken symbol's pointer tag value. - CV_off32_t symRecordOffset; // offset of the symbol record from the S_LPROC32_DPC record it is nested within -} CV_DPC_SYM_TAG_MAP_ENTRY; - -#endif // CC_DP_CXX - -// enum describing function data return method - -typedef enum CV_GENERIC_STYLE_e { - CV_GENERIC_VOID = 0x00, // void return type - CV_GENERIC_REG = 0x01, // return data is in registers - CV_GENERIC_ICAN = 0x02, // indirect caller allocated near - CV_GENERIC_ICAF = 0x03, // indirect caller allocated far - CV_GENERIC_IRAN = 0x04, // indirect returnee allocated near - CV_GENERIC_IRAF = 0x05, // indirect returnee allocated far - CV_GENERIC_UNUSED = 0x06 // first unused -} CV_GENERIC_STYLE_e; - - -typedef struct CV_GENERIC_FLAG { - unsigned short cstyle :1; // true push varargs right to left - unsigned short rsclean :1; // true if returnee stack cleanup - unsigned short unused :14; // unused -} CV_GENERIC_FLAG; - - -// flag bitfields for separated code attributes - -typedef struct CV_SEPCODEFLAGS { - unsigned long fIsLexicalScope : 1; // S_SEPCODE doubles as lexical scope - unsigned long fReturnsToParent : 1; // code frag returns to parent - unsigned long pad : 30; // must be zero -} CV_SEPCODEFLAGS; - -// Generic layout for symbol records - -typedef struct SYMTYPE { - unsigned short reclen; // Record length - unsigned short rectyp; // Record type - char data[CV_ZEROLEN]; -} SYMTYPE; - -__INLINE SYMTYPE *NextSym (SYMTYPE * pSym) { - return (SYMTYPE *) ((char *)pSym + pSym->reclen + sizeof(unsigned short)); -} - -// non-model specific symbol types - - - -typedef struct REGSYM_16t { - unsigned short reclen; // Record length - unsigned short rectyp; // S_REGISTER_16t - CV_typ16_t typind; // Type index - unsigned short reg; // register enumerate - unsigned char name[1]; // Length-prefixed name -} REGSYM_16t; - -typedef struct REGSYM { - unsigned short reclen; // Record length - unsigned short rectyp; // S_REGISTER - CV_typ_t typind; // Type index or Metadata token - unsigned short reg; // register enumerate - unsigned char name[1]; // Length-prefixed name -} REGSYM; - -typedef struct ATTRREGSYM { - unsigned short reclen; // Record length - unsigned short rectyp; // S_MANREGISTER | S_ATTR_REGISTER - CV_typ_t typind; // Type index or Metadata token - CV_lvar_attr attr; // local var attributes - unsigned short reg; // register enumerate - unsigned char name[1]; // Length-prefixed name -} ATTRREGSYM; - -typedef struct MANYREGSYM_16t { - unsigned short reclen; // Record length - unsigned short rectyp; // S_MANYREG_16t - CV_typ16_t typind; // Type index - unsigned char count; // count of number of registers - unsigned char reg[1]; // count register enumerates followed by - // length-prefixed name. Registers are - // most significant first. -} MANYREGSYM_16t; - -typedef struct MANYREGSYM { - unsigned short reclen; // Record length - unsigned short rectyp; // S_MANYREG - CV_typ_t typind; // Type index or metadata token - unsigned char count; // count of number of registers - unsigned char reg[1]; // count register enumerates followed by - // length-prefixed name. Registers are - // most significant first. -} MANYREGSYM; - -typedef struct MANYREGSYM2 { - unsigned short reclen; // Record length - unsigned short rectyp; // S_MANYREG2 - CV_typ_t typind; // Type index or metadata token - unsigned short count; // count of number of registers - unsigned short reg[1]; // count register enumerates followed by - // length-prefixed name. Registers are - // most significant first. -} MANYREGSYM2; - -typedef struct ATTRMANYREGSYM { - unsigned short reclen; // Record length - unsigned short rectyp; // S_MANMANYREG - CV_typ_t typind; // Type index or metadata token - CV_lvar_attr attr; // local var attributes - unsigned char count; // count of number of registers - unsigned char reg[1]; // count register enumerates followed by - // length-prefixed name. Registers are - // most significant first. - unsigned char name[CV_ZEROLEN]; // utf-8 encoded zero terminate name -} ATTRMANYREGSYM; - -typedef struct ATTRMANYREGSYM2 { - unsigned short reclen; // Record length - unsigned short rectyp; // S_MANMANYREG2 | S_ATTR_MANYREG - CV_typ_t typind; // Type index or metadata token - CV_lvar_attr attr; // local var attributes - unsigned short count; // count of number of registers - unsigned short reg[1]; // count register enumerates followed by - // length-prefixed name. Registers are - // most significant first. - unsigned char name[CV_ZEROLEN]; // utf-8 encoded zero terminate name -} ATTRMANYREGSYM2; - -typedef struct CONSTSYM_16t { - unsigned short reclen; // Record length - unsigned short rectyp; // S_CONSTANT_16t - CV_typ16_t typind; // Type index (containing enum if enumerate) - unsigned short value; // numeric leaf containing value - unsigned char name[CV_ZEROLEN]; // Length-prefixed name -} CONSTSYM_16t; - -typedef struct CONSTSYM { - unsigned short reclen; // Record length - unsigned short rectyp; // S_CONSTANT or S_MANCONSTANT - CV_typ_t typind; // Type index (containing enum if enumerate) or metadata token - unsigned short value; // numeric leaf containing value - unsigned char name[CV_ZEROLEN]; // Length-prefixed name -} CONSTSYM; - - -typedef struct UDTSYM_16t { - unsigned short reclen; // Record length - unsigned short rectyp; // S_UDT_16t | S_COBOLUDT_16t - CV_typ16_t typind; // Type index - unsigned char name[1]; // Length-prefixed name -} UDTSYM_16t; - - -typedef struct UDTSYM { - unsigned short reclen; // Record length - unsigned short rectyp; // S_UDT | S_COBOLUDT - CV_typ_t typind; // Type index - unsigned char name[1]; // Length-prefixed name -} UDTSYM; - -typedef struct MANTYPREF { - unsigned short reclen; // Record length - unsigned short rectyp; // S_MANTYPREF - CV_typ_t typind; // Type index -} MANTYPREF; - -typedef struct SEARCHSYM { - unsigned short reclen; // Record length - unsigned short rectyp; // S_SSEARCH - unsigned long startsym; // offset of the procedure - unsigned short seg; // segment of symbol -} SEARCHSYM; - - -typedef struct CFLAGSYM { - unsigned short reclen; // Record length - unsigned short rectyp; // S_COMPILE - unsigned char machine; // target processor - struct { - unsigned char language :8; // language index - unsigned char pcode :1; // true if pcode present - unsigned char floatprec :2; // floating precision - unsigned char floatpkg :2; // float package - unsigned char ambdata :3; // ambient data model - unsigned char ambcode :3; // ambient code model - unsigned char mode32 :1; // true if compiled 32 bit mode - unsigned char pad :4; // reserved - } flags; - unsigned char ver[1]; // Length-prefixed compiler version string -} CFLAGSYM; - - -typedef struct COMPILESYM { - unsigned short reclen; // Record length - unsigned short rectyp; // S_COMPILE2 - struct { - unsigned long iLanguage : 8; // language index - unsigned long fEC : 1; // compiled for E/C - unsigned long fNoDbgInfo : 1; // not compiled with debug info - unsigned long fLTCG : 1; // compiled with LTCG - unsigned long fNoDataAlign : 1; // compiled with -Bzalign - unsigned long fManagedPresent : 1; // managed code/data present - unsigned long fSecurityChecks : 1; // compiled with /GS - unsigned long fHotPatch : 1; // compiled with /hotpatch - unsigned long fCVTCIL : 1; // converted with CVTCIL - unsigned long fMSILModule : 1; // MSIL netmodule - unsigned long pad : 15; // reserved, must be 0 - } flags; - unsigned short machine; // target processor - unsigned short verFEMajor; // front end major version # - unsigned short verFEMinor; // front end minor version # - unsigned short verFEBuild; // front end build version # - unsigned short verMajor; // back end major version # - unsigned short verMinor; // back end minor version # - unsigned short verBuild; // back end build version # - unsigned char verSt[1]; // Length-prefixed compiler version string, followed - // by an optional block of zero terminated strings - // terminated with a double zero. -} COMPILESYM; - -typedef struct COMPILESYM3 { - unsigned short reclen; // Record length - unsigned short rectyp; // S_COMPILE3 - struct { - unsigned long iLanguage : 8; // language index - unsigned long fEC : 1; // compiled for E/C - unsigned long fNoDbgInfo : 1; // not compiled with debug info - unsigned long fLTCG : 1; // compiled with LTCG - unsigned long fNoDataAlign : 1; // compiled with -Bzalign - unsigned long fManagedPresent : 1; // managed code/data present - unsigned long fSecurityChecks : 1; // compiled with /GS - unsigned long fHotPatch : 1; // compiled with /hotpatch - unsigned long fCVTCIL : 1; // converted with CVTCIL - unsigned long fMSILModule : 1; // MSIL netmodule - unsigned long fSdl : 1; // compiled with /sdl - unsigned long fPGO : 1; // compiled with /ltcg:pgo or pgu - unsigned long fExp : 1; // .exp module - unsigned long pad : 12; // reserved, must be 0 - } flags; - unsigned short machine; // target processor - unsigned short verFEMajor; // front end major version # - unsigned short verFEMinor; // front end minor version # - unsigned short verFEBuild; // front end build version # - unsigned short verFEQFE; // front end QFE version # - unsigned short verMajor; // back end major version # - unsigned short verMinor; // back end minor version # - unsigned short verBuild; // back end build version # - unsigned short verQFE; // back end QFE version # - char verSz[1]; // Zero terminated compiler version string -} COMPILESYM3; - -typedef struct ENVBLOCKSYM { - unsigned short reclen; // Record length - unsigned short rectyp; // S_ENVBLOCK - struct { - unsigned char rev : 1; // reserved - unsigned char pad : 7; // reserved, must be 0 - } flags; - unsigned char rgsz[1]; // Sequence of zero-terminated strings -} ENVBLOCKSYM; - -typedef struct OBJNAMESYM { - unsigned short reclen; // Record length - unsigned short rectyp; // S_OBJNAME - unsigned long signature; // signature - unsigned char name[1]; // Length-prefixed name -} OBJNAMESYM; - - -typedef struct ENDARGSYM { - unsigned short reclen; // Record length - unsigned short rectyp; // S_ENDARG -} ENDARGSYM; - - -typedef struct RETURNSYM { - unsigned short reclen; // Record length - unsigned short rectyp; // S_RETURN - CV_GENERIC_FLAG flags; // flags - unsigned char style; // CV_GENERIC_STYLE_e return style - // followed by return method data -} RETURNSYM; - - -typedef struct ENTRYTHISSYM { - unsigned short reclen; // Record length - unsigned short rectyp; // S_ENTRYTHIS - unsigned char thissym; // symbol describing this pointer on entry -} ENTRYTHISSYM; - - -// symbol types for 16:16 memory model - - -typedef struct BPRELSYM16 { - unsigned short reclen; // Record length - unsigned short rectyp; // S_BPREL16 - CV_off16_t off; // BP-relative offset - CV_typ16_t typind; // Type index - unsigned char name[1]; // Length-prefixed name -} BPRELSYM16; - - -typedef struct DATASYM16 { - unsigned short reclen; // Record length - unsigned short rectyp; // S_LDATA or S_GDATA - CV_uoff16_t off; // offset of symbol - unsigned short seg; // segment of symbol - CV_typ16_t typind; // Type index - unsigned char name[1]; // Length-prefixed name -} DATASYM16; -typedef DATASYM16 PUBSYM16; - - -typedef struct PROCSYM16 { - unsigned short reclen; // Record length - unsigned short rectyp; // S_GPROC16 or S_LPROC16 - unsigned long pParent; // pointer to the parent - unsigned long pEnd; // pointer to this blocks end - unsigned long pNext; // pointer to next symbol - unsigned short len; // Proc length - unsigned short DbgStart; // Debug start offset - unsigned short DbgEnd; // Debug end offset - CV_uoff16_t off; // offset of symbol - unsigned short seg; // segment of symbol - CV_typ16_t typind; // Type index - CV_PROCFLAGS flags; // Proc flags - unsigned char name[1]; // Length-prefixed name -} PROCSYM16; - - -typedef struct THUNKSYM16 { - unsigned short reclen; // Record length - unsigned short rectyp; // S_THUNK - unsigned long pParent; // pointer to the parent - unsigned long pEnd; // pointer to this blocks end - unsigned long pNext; // pointer to next symbol - CV_uoff16_t off; // offset of symbol - unsigned short seg; // segment of symbol - unsigned short len; // length of thunk - unsigned char ord; // THUNK_ORDINAL specifying type of thunk - unsigned char name[1]; // name of thunk - unsigned char variant[CV_ZEROLEN]; // variant portion of thunk -} THUNKSYM16; - -typedef struct LABELSYM16 { - unsigned short reclen; // Record length - unsigned short rectyp; // S_LABEL16 - CV_uoff16_t off; // offset of symbol - unsigned short seg; // segment of symbol - CV_PROCFLAGS flags; // flags - unsigned char name[1]; // Length-prefixed name -} LABELSYM16; - - -typedef struct BLOCKSYM16 { - unsigned short reclen; // Record length - unsigned short rectyp; // S_BLOCK16 - unsigned long pParent; // pointer to the parent - unsigned long pEnd; // pointer to this blocks end - unsigned short len; // Block length - CV_uoff16_t off; // offset of symbol - unsigned short seg; // segment of symbol - unsigned char name[1]; // Length-prefixed name -} BLOCKSYM16; - - -typedef struct WITHSYM16 { - unsigned short reclen; // Record length - unsigned short rectyp; // S_WITH16 - unsigned long pParent; // pointer to the parent - unsigned long pEnd; // pointer to this blocks end - unsigned short len; // Block length - CV_uoff16_t off; // offset of symbol - unsigned short seg; // segment of symbol - unsigned char expr[1]; // Length-prefixed expression -} WITHSYM16; - - -typedef enum CEXM_MODEL_e { - CEXM_MDL_table = 0x00, // not executable - CEXM_MDL_jumptable = 0x01, // Compiler generated jump table - CEXM_MDL_datapad = 0x02, // Data padding for alignment - CEXM_MDL_native = 0x20, // native (actually not-pcode) - CEXM_MDL_cobol = 0x21, // cobol - CEXM_MDL_codepad = 0x22, // Code padding for alignment - CEXM_MDL_code = 0x23, // code - CEXM_MDL_sql = 0x30, // sql - CEXM_MDL_pcode = 0x40, // pcode - CEXM_MDL_pcode32Mac = 0x41, // macintosh 32 bit pcode - CEXM_MDL_pcode32MacNep = 0x42, // macintosh 32 bit pcode native entry point - CEXM_MDL_javaInt = 0x50, - CEXM_MDL_unknown = 0xff -} CEXM_MODEL_e; - -// use the correct enumerate name -#define CEXM_MDL_SQL CEXM_MDL_sql - -typedef enum CV_COBOL_e { - CV_COBOL_dontstop, - CV_COBOL_pfm, - CV_COBOL_false, - CV_COBOL_extcall -} CV_COBOL_e; - -typedef struct CEXMSYM16 { - unsigned short reclen; // Record length - unsigned short rectyp; // S_CEXMODEL16 - CV_uoff16_t off; // offset of symbol - unsigned short seg; // segment of symbol - unsigned short model; // execution model - union { - struct { - CV_uoff16_t pcdtable; // offset to pcode function table - CV_uoff16_t pcdspi; // offset to segment pcode information - } pcode; - struct { - unsigned short subtype; // see CV_COBOL_e above - unsigned short flag; - } cobol; - }; -} CEXMSYM16; - - -typedef struct VPATHSYM16 { - unsigned short reclen; // record length - unsigned short rectyp; // S_VFTPATH16 - CV_uoff16_t off; // offset of virtual function table - unsigned short seg; // segment of virtual function table - CV_typ16_t root; // type index of the root of path - CV_typ16_t path; // type index of the path record -} VPATHSYM16; - - -typedef struct REGREL16 { - unsigned short reclen; // Record length - unsigned short rectyp; // S_REGREL16 - CV_uoff16_t off; // offset of symbol - unsigned short reg; // register index - CV_typ16_t typind; // Type index - unsigned char name[1]; // Length-prefixed name -} REGREL16; - - -typedef struct BPRELSYM32_16t { - unsigned short reclen; // Record length - unsigned short rectyp; // S_BPREL32_16t - CV_off32_t off; // BP-relative offset - CV_typ16_t typind; // Type index - unsigned char name[1]; // Length-prefixed name -} BPRELSYM32_16t; - -typedef struct BPRELSYM32 { - unsigned short reclen; // Record length - unsigned short rectyp; // S_BPREL32 - CV_off32_t off; // BP-relative offset - CV_typ_t typind; // Type index or Metadata token - unsigned char name[1]; // Length-prefixed name -} BPRELSYM32; - -typedef struct FRAMERELSYM { - unsigned short reclen; // Record length - unsigned short rectyp; // S_MANFRAMEREL | S_ATTR_FRAMEREL - CV_off32_t off; // Frame relative offset - CV_typ_t typind; // Type index or Metadata token - CV_lvar_attr attr; // local var attributes - unsigned char name[1]; // Length-prefixed name -} FRAMERELSYM; - -typedef FRAMERELSYM ATTRFRAMERELSYM; - - -typedef struct SLOTSYM32 { - unsigned short reclen; // Record length - unsigned short rectyp; // S_LOCALSLOT or S_PARAMSLOT - unsigned long iSlot; // slot index - CV_typ_t typind; // Type index or Metadata token - unsigned char name[1]; // Length-prefixed name -} SLOTSYM32; - -typedef struct ATTRSLOTSYM { - unsigned short reclen; // Record length - unsigned short rectyp; // S_MANSLOT - unsigned long iSlot; // slot index - CV_typ_t typind; // Type index or Metadata token - CV_lvar_attr attr; // local var attributes - unsigned char name[1]; // Length-prefixed name -} ATTRSLOTSYM; - -typedef struct ANNOTATIONSYM { - unsigned short reclen; // Record length - unsigned short rectyp; // S_ANNOTATION - CV_uoff32_t off; - unsigned short seg; - unsigned short csz; // Count of zero terminated annotation strings - unsigned char rgsz[1]; // Sequence of zero terminated annotation strings -} ANNOTATIONSYM; - -typedef struct DATASYM32_16t { - unsigned short reclen; // Record length - unsigned short rectyp; // S_LDATA32_16t, S_GDATA32_16t or S_PUB32_16t - CV_uoff32_t off; - unsigned short seg; - CV_typ16_t typind; // Type index - unsigned char name[1]; // Length-prefixed name -} DATASYM32_16t; -typedef DATASYM32_16t PUBSYM32_16t; - -typedef struct DATASYM32 { - unsigned short reclen; // Record length - unsigned short rectyp; // S_LDATA32, S_GDATA32, S_LMANDATA, S_GMANDATA - CV_typ_t typind; // Type index, or Metadata token if a managed symbol - CV_uoff32_t off; - unsigned short seg; - unsigned char name[1]; // Length-prefixed name -} DATASYM32; - -typedef struct DATASYMHLSL { - unsigned short reclen; // Record length - unsigned short rectyp; // S_GDATA_HLSL, S_LDATA_HLSL - CV_typ_t typind; // Type index - unsigned short regType; // register type from CV_HLSLREG_e - unsigned short dataslot; // Base data (cbuffer, groupshared, etc.) slot - unsigned short dataoff; // Base data byte offset start - unsigned short texslot; // Texture slot start - unsigned short sampslot; // Sampler slot start - unsigned short uavslot; // UAV slot start - unsigned char name[1]; // name -} DATASYMHLSL; - -typedef struct DATASYMHLSL32 { - unsigned short reclen; // Record length - unsigned short rectyp; // S_GDATA_HLSL32, S_LDATA_HLSL32 - CV_typ_t typind; // Type index - unsigned long dataslot; // Base data (cbuffer, groupshared, etc.) slot - unsigned long dataoff; // Base data byte offset start - unsigned long texslot; // Texture slot start - unsigned long sampslot; // Sampler slot start - unsigned long uavslot; // UAV slot start - unsigned short regType; // register type from CV_HLSLREG_e - unsigned char name[1]; // name -} DATASYMHLSL32; - -typedef struct DATASYMHLSL32_EX { - unsigned short reclen; // Record length - unsigned short rectyp; // S_GDATA_HLSL32_EX, S_LDATA_HLSL32_EX - CV_typ_t typind; // Type index - unsigned long regID; // Register index - unsigned long dataoff; // Base data byte offset start - unsigned long bindSpace; // Binding space - unsigned long bindSlot; // Lower bound in binding space - unsigned short regType; // register type from CV_HLSLREG_e - unsigned char name[1]; // name -} DATASYMHLSL32_EX; - -typedef enum CV_PUBSYMFLAGS_e - { - cvpsfNone = 0, - cvpsfCode = 0x00000001, - cvpsfFunction = 0x00000002, - cvpsfManaged = 0x00000004, - cvpsfMSIL = 0x00000008, -} CV_PUBSYMFLAGS_e; - -typedef union CV_PUBSYMFLAGS { - CV_pubsymflag_t grfFlags; - struct { - CV_pubsymflag_t fCode : 1; // set if public symbol refers to a code address - CV_pubsymflag_t fFunction : 1; // set if public symbol is a function - CV_pubsymflag_t fManaged : 1; // set if managed code (native or IL) - CV_pubsymflag_t fMSIL : 1; // set if managed IL code - CV_pubsymflag_t __unused : 28; // must be zero - }; -} CV_PUBSYMFLAGS; - -typedef struct PUBSYM32 { - unsigned short reclen; // Record length - unsigned short rectyp; // S_PUB32 - CV_PUBSYMFLAGS pubsymflags; - CV_uoff32_t off; - unsigned short seg; - unsigned char name[1]; // Length-prefixed name -} PUBSYM32; - - -typedef struct PROCSYM32_16t { - unsigned short reclen; // Record length - unsigned short rectyp; // S_GPROC32_16t or S_LPROC32_16t - unsigned long pParent; // pointer to the parent - unsigned long pEnd; // pointer to this blocks end - unsigned long pNext; // pointer to next symbol - unsigned long len; // Proc length - unsigned long DbgStart; // Debug start offset - unsigned long DbgEnd; // Debug end offset - CV_uoff32_t off; - unsigned short seg; - CV_typ16_t typind; // Type index - CV_PROCFLAGS flags; // Proc flags - unsigned char name[1]; // Length-prefixed name -} PROCSYM32_16t; - -typedef struct PROCSYM32 { - unsigned short reclen; // Record length - unsigned short rectyp; // S_GPROC32, S_LPROC32, S_GPROC32_ID, S_LPROC32_ID, S_LPROC32_DPC or S_LPROC32_DPC_ID - unsigned long pParent; // pointer to the parent - unsigned long pEnd; // pointer to this blocks end - unsigned long pNext; // pointer to next symbol - unsigned long len; // Proc length - unsigned long DbgStart; // Debug start offset - unsigned long DbgEnd; // Debug end offset - CV_typ_t typind; // Type index or ID - CV_uoff32_t off; - unsigned short seg; - CV_PROCFLAGS flags; // Proc flags - unsigned char name[1]; // Length-prefixed name -} PROCSYM32; - -typedef struct MANPROCSYM { - unsigned short reclen; // Record length - unsigned short rectyp; // S_GMANPROC, S_LMANPROC, S_GMANPROCIA64 or S_LMANPROCIA64 - unsigned long pParent; // pointer to the parent - unsigned long pEnd; // pointer to this blocks end - unsigned long pNext; // pointer to next symbol - unsigned long len; // Proc length - unsigned long DbgStart; // Debug start offset - unsigned long DbgEnd; // Debug end offset - CV_tkn_t token; // COM+ metadata token for method - CV_uoff32_t off; - unsigned short seg; - CV_PROCFLAGS flags; // Proc flags - unsigned short retReg; // Register return value is in (may not be used for all archs) - unsigned char name[1]; // optional name field -} MANPROCSYM; - -typedef struct MANPROCSYMMIPS { - unsigned short reclen; // Record length - unsigned short rectyp; // S_GMANPROCMIPS or S_LMANPROCMIPS - unsigned long pParent; // pointer to the parent - unsigned long pEnd; // pointer to this blocks end - unsigned long pNext; // pointer to next symbol - unsigned long len; // Proc length - unsigned long DbgStart; // Debug start offset - unsigned long DbgEnd; // Debug end offset - unsigned long regSave; // int register save mask - unsigned long fpSave; // fp register save mask - CV_uoff32_t intOff; // int register save offset - CV_uoff32_t fpOff; // fp register save offset - CV_tkn_t token; // COM+ token type - CV_uoff32_t off; - unsigned short seg; - unsigned char retReg; // Register return value is in - unsigned char frameReg; // Frame pointer register - unsigned char name[1]; // optional name field -} MANPROCSYMMIPS; - -typedef struct THUNKSYM32 { - unsigned short reclen; // Record length - unsigned short rectyp; // S_THUNK32 - unsigned long pParent; // pointer to the parent - unsigned long pEnd; // pointer to this blocks end - unsigned long pNext; // pointer to next symbol - CV_uoff32_t off; - unsigned short seg; - unsigned short len; // length of thunk - unsigned char ord; // THUNK_ORDINAL specifying type of thunk - unsigned char name[1]; // Length-prefixed name - unsigned char variant[CV_ZEROLEN]; // variant portion of thunk -} THUNKSYM32; - -typedef enum TRAMP_e { // Trampoline subtype - trampIncremental, // incremental thunks - trampBranchIsland, // Branch island thunks -} TRAMP_e; - -typedef struct TRAMPOLINESYM { // Trampoline thunk symbol - unsigned short reclen; // Record length - unsigned short rectyp; // S_TRAMPOLINE - unsigned short trampType; // trampoline sym subtype - unsigned short cbThunk; // size of the thunk - CV_uoff32_t offThunk; // offset of the thunk - CV_uoff32_t offTarget; // offset of the target of the thunk - unsigned short sectThunk; // section index of the thunk - unsigned short sectTarget; // section index of the target of the thunk -} TRAMPOLINE; - -typedef struct LABELSYM32 { - unsigned short reclen; // Record length - unsigned short rectyp; // S_LABEL32 - CV_uoff32_t off; - unsigned short seg; - CV_PROCFLAGS flags; // flags - unsigned char name[1]; // Length-prefixed name -} LABELSYM32; - - -typedef struct BLOCKSYM32 { - unsigned short reclen; // Record length - unsigned short rectyp; // S_BLOCK32 - unsigned long pParent; // pointer to the parent - unsigned long pEnd; // pointer to this blocks end - unsigned long len; // Block length - CV_uoff32_t off; // Offset in code segment - unsigned short seg; // segment of label - unsigned char name[1]; // Length-prefixed name -} BLOCKSYM32; - - -typedef struct WITHSYM32 { - unsigned short reclen; // Record length - unsigned short rectyp; // S_WITH32 - unsigned long pParent; // pointer to the parent - unsigned long pEnd; // pointer to this blocks end - unsigned long len; // Block length - CV_uoff32_t off; // Offset in code segment - unsigned short seg; // segment of label - unsigned char expr[1]; // Length-prefixed expression string -} WITHSYM32; - - - -typedef struct CEXMSYM32 { - unsigned short reclen; // Record length - unsigned short rectyp; // S_CEXMODEL32 - CV_uoff32_t off; // offset of symbol - unsigned short seg; // segment of symbol - unsigned short model; // execution model - union { - struct { - CV_uoff32_t pcdtable; // offset to pcode function table - CV_uoff32_t pcdspi; // offset to segment pcode information - } pcode; - struct { - unsigned short subtype; // see CV_COBOL_e above - unsigned short flag; - } cobol; - struct { - CV_uoff32_t calltableOff; // offset to function table - unsigned short calltableSeg; // segment of function table - } pcode32Mac; - }; -} CEXMSYM32; - - - -typedef struct VPATHSYM32_16t { - unsigned short reclen; // record length - unsigned short rectyp; // S_VFTABLE32_16t - CV_uoff32_t off; // offset of virtual function table - unsigned short seg; // segment of virtual function table - CV_typ16_t root; // type index of the root of path - CV_typ16_t path; // type index of the path record -} VPATHSYM32_16t; - -typedef struct VPATHSYM32 { - unsigned short reclen; // record length - unsigned short rectyp; // S_VFTABLE32 - CV_typ_t root; // type index of the root of path - CV_typ_t path; // type index of the path record - CV_uoff32_t off; // offset of virtual function table - unsigned short seg; // segment of virtual function table -} VPATHSYM32; - - - - - -typedef struct REGREL32_16t { - unsigned short reclen; // Record length - unsigned short rectyp; // S_REGREL32_16t - CV_uoff32_t off; // offset of symbol - unsigned short reg; // register index for symbol - CV_typ16_t typind; // Type index - unsigned char name[1]; // Length-prefixed name -} REGREL32_16t; - -typedef struct REGREL32 { - unsigned short reclen; // Record length - unsigned short rectyp; // S_REGREL32 - CV_uoff32_t off; // offset of symbol - CV_typ_t typind; // Type index or metadata token - unsigned short reg; // register index for symbol - unsigned char name[1]; // Length-prefixed name -} REGREL32; - -typedef struct ATTRREGREL { - unsigned short reclen; // Record length - unsigned short rectyp; // S_MANREGREL | S_ATTR_REGREL - CV_uoff32_t off; // offset of symbol - CV_typ_t typind; // Type index or metadata token - unsigned short reg; // register index for symbol - CV_lvar_attr attr; // local var attributes - unsigned char name[1]; // Length-prefixed name -} ATTRREGREL; - -typedef ATTRREGREL ATTRREGRELSYM; - -typedef struct THREADSYM32_16t { - unsigned short reclen; // record length - unsigned short rectyp; // S_LTHREAD32_16t | S_GTHREAD32_16t - CV_uoff32_t off; // offset into thread storage - unsigned short seg; // segment of thread storage - CV_typ16_t typind; // type index - unsigned char name[1]; // length prefixed name -} THREADSYM32_16t; - -typedef struct THREADSYM32 { - unsigned short reclen; // record length - unsigned short rectyp; // S_LTHREAD32 | S_GTHREAD32 - CV_typ_t typind; // type index - CV_uoff32_t off; // offset into thread storage - unsigned short seg; // segment of thread storage - unsigned char name[1]; // length prefixed name -} THREADSYM32; - -typedef struct SLINK32 { - unsigned short reclen; // record length - unsigned short rectyp; // S_SLINK32 - unsigned long framesize; // frame size of parent procedure - CV_off32_t off; // signed offset where the static link was saved relative to the value of reg - unsigned short reg; -} SLINK32; - -typedef struct PROCSYMMIPS_16t { - unsigned short reclen; // Record length - unsigned short rectyp; // S_GPROCMIPS_16t or S_LPROCMIPS_16t - unsigned long pParent; // pointer to the parent - unsigned long pEnd; // pointer to this blocks end - unsigned long pNext; // pointer to next symbol - unsigned long len; // Proc length - unsigned long DbgStart; // Debug start offset - unsigned long DbgEnd; // Debug end offset - unsigned long regSave; // int register save mask - unsigned long fpSave; // fp register save mask - CV_uoff32_t intOff; // int register save offset - CV_uoff32_t fpOff; // fp register save offset - CV_uoff32_t off; // Symbol offset - unsigned short seg; // Symbol segment - CV_typ16_t typind; // Type index - unsigned char retReg; // Register return value is in - unsigned char frameReg; // Frame pointer register - unsigned char name[1]; // Length-prefixed name -} PROCSYMMIPS_16t; - -typedef struct PROCSYMMIPS { - unsigned short reclen; // Record length - unsigned short rectyp; // S_GPROCMIPS or S_LPROCMIPS - unsigned long pParent; // pointer to the parent - unsigned long pEnd; // pointer to this blocks end - unsigned long pNext; // pointer to next symbol - unsigned long len; // Proc length - unsigned long DbgStart; // Debug start offset - unsigned long DbgEnd; // Debug end offset - unsigned long regSave; // int register save mask - unsigned long fpSave; // fp register save mask - CV_uoff32_t intOff; // int register save offset - CV_uoff32_t fpOff; // fp register save offset - CV_typ_t typind; // Type index - CV_uoff32_t off; // Symbol offset - unsigned short seg; // Symbol segment - unsigned char retReg; // Register return value is in - unsigned char frameReg; // Frame pointer register - unsigned char name[1]; // Length-prefixed name -} PROCSYMMIPS; - -typedef struct PROCSYMIA64 { - unsigned short reclen; // Record length - unsigned short rectyp; // S_GPROCIA64 or S_LPROCIA64 - unsigned long pParent; // pointer to the parent - unsigned long pEnd; // pointer to this blocks end - unsigned long pNext; // pointer to next symbol - unsigned long len; // Proc length - unsigned long DbgStart; // Debug start offset - unsigned long DbgEnd; // Debug end offset - CV_typ_t typind; // Type index - CV_uoff32_t off; // Symbol offset - unsigned short seg; // Symbol segment - unsigned short retReg; // Register return value is in - CV_PROCFLAGS flags; // Proc flags - unsigned char name[1]; // Length-prefixed name -} PROCSYMIA64; - -typedef struct REFSYM { - unsigned short reclen; // Record length - unsigned short rectyp; // S_PROCREF_ST, S_DATAREF_ST, or S_LPROCREF_ST - unsigned long sumName; // SUC of the name - unsigned long ibSym; // Offset of actual symbol in $$Symbols - unsigned short imod; // Module containing the actual symbol - unsigned short usFill; // align this record -} REFSYM; - -typedef struct REFSYM2 { - unsigned short reclen; // Record length - unsigned short rectyp; // S_PROCREF, S_DATAREF, or S_LPROCREF - unsigned long sumName; // SUC of the name - unsigned long ibSym; // Offset of actual symbol in $$Symbols - unsigned short imod; // Module containing the actual symbol - unsigned char name[1]; // hidden name made a first class member -} REFSYM2; - -typedef struct ALIGNSYM { - unsigned short reclen; // Record length - unsigned short rectyp; // S_ALIGN -} ALIGNSYM; - -typedef struct OEMSYMBOL { - unsigned short reclen; // Record length - unsigned short rectyp; // S_OEM - unsigned char idOem[16]; // an oem ID (GUID) - CV_typ_t typind; // Type index - unsigned long rgl[]; // user data, force 4-byte alignment -} OEMSYMBOL; - -// generic block definition symbols -// these are similar to the equivalent 16:16 or 16:32 symbols but -// only define the length, type and linkage fields - -typedef struct PROCSYM { - unsigned short reclen; // Record length - unsigned short rectyp; // S_GPROC16 or S_LPROC16 - unsigned long pParent; // pointer to the parent - unsigned long pEnd; // pointer to this blocks end - unsigned long pNext; // pointer to next symbol -} PROCSYM; - - -typedef struct THUNKSYM { - unsigned short reclen; // Record length - unsigned short rectyp; // S_THUNK - unsigned long pParent; // pointer to the parent - unsigned long pEnd; // pointer to this blocks end - unsigned long pNext; // pointer to next symbol -} THUNKSYM; - -typedef struct BLOCKSYM { - unsigned short reclen; // Record length - unsigned short rectyp; // S_BLOCK16 - unsigned long pParent; // pointer to the parent - unsigned long pEnd; // pointer to this blocks end -} BLOCKSYM; - - -typedef struct WITHSYM { - unsigned short reclen; // Record length - unsigned short rectyp; // S_WITH16 - unsigned long pParent; // pointer to the parent - unsigned long pEnd; // pointer to this blocks end -} WITHSYM; - -typedef struct FRAMEPROCSYM { - unsigned short reclen; // Record length - unsigned short rectyp; // S_FRAMEPROC - unsigned long cbFrame; // count of bytes of total frame of procedure - unsigned long cbPad; // count of bytes of padding in the frame - CV_uoff32_t offPad; // offset (relative to frame poniter) to where - // padding starts - unsigned long cbSaveRegs; // count of bytes of callee save registers - CV_uoff32_t offExHdlr; // offset of exception handler - unsigned short sectExHdlr; // section id of exception handler - - struct { - unsigned long fHasAlloca : 1; // function uses _alloca() - unsigned long fHasSetJmp : 1; // function uses setjmp() - unsigned long fHasLongJmp : 1; // function uses longjmp() - unsigned long fHasInlAsm : 1; // function uses inline asm - unsigned long fHasEH : 1; // function has EH states - unsigned long fInlSpec : 1; // function was speced as inline - unsigned long fHasSEH : 1; // function has SEH - unsigned long fNaked : 1; // function is __declspec(naked) - unsigned long fSecurityChecks : 1; // function has buffer security check introduced by /GS. - unsigned long fAsyncEH : 1; // function compiled with /EHa - unsigned long fGSNoStackOrdering : 1; // function has /GS buffer checks, but stack ordering couldn't be done - unsigned long fWasInlined : 1; // function was inlined within another function - unsigned long fGSCheck : 1; // function is __declspec(strict_gs_check) - unsigned long fSafeBuffers : 1; // function is __declspec(safebuffers) - unsigned long encodedLocalBasePointer : 2; // record function's local pointer explicitly. - unsigned long encodedParamBasePointer : 2; // record function's parameter pointer explicitly. - unsigned long fPogoOn : 1; // function was compiled with PGO/PGU - unsigned long fValidCounts : 1; // Do we have valid Pogo counts? - unsigned long fOptSpeed : 1; // Did we optimize for speed? - unsigned long fGuardCF : 1; // function contains CFG checks (and no write checks) - unsigned long fGuardCFW : 1; // function contains CFW checks and/or instrumentation - unsigned long pad : 9; // must be zero - } flags; -} FRAMEPROCSYM; - -#ifdef __cplusplus -namespace CodeViewInfo -{ -__inline unsigned short ExpandEncodedBasePointerReg(unsigned machineType, unsigned encodedFrameReg) -{ - static const unsigned short rgFramePointerRegX86[] = { - CV_REG_NONE, CV_ALLREG_VFRAME, CV_REG_EBP, CV_REG_EBX}; - static const unsigned short rgFramePointerRegX64[] = { - CV_REG_NONE, CV_AMD64_RSP, CV_AMD64_RBP, CV_AMD64_R13}; - static const unsigned short rgFramePointerRegArm[] = { - CV_REG_NONE, CV_ARM_SP, CV_ARM_R7, CV_REG_NONE}; - - if (encodedFrameReg >= 4) { - return CV_REG_NONE; - } - switch (machineType) { - case CV_CFL_8080 : - case CV_CFL_8086 : - case CV_CFL_80286 : - case CV_CFL_80386 : - case CV_CFL_80486 : - case CV_CFL_PENTIUM : - case CV_CFL_PENTIUMII : - case CV_CFL_PENTIUMIII : - return rgFramePointerRegX86[encodedFrameReg]; - case CV_CFL_AMD64 : - return rgFramePointerRegX64[encodedFrameReg]; - case CV_CFL_ARMNT : - return rgFramePointerRegArm[encodedFrameReg]; - default: - return CV_REG_NONE; - } -} -} -#endif - -typedef struct UNAMESPACE { - unsigned short reclen; // Record length - unsigned short rectyp; // S_UNAMESPACE - unsigned char name[1]; // name -} UNAMESPACE; - -typedef struct SEPCODESYM { - unsigned short reclen; // Record length - unsigned short rectyp; // S_SEPCODE - unsigned long pParent; // pointer to the parent - unsigned long pEnd; // pointer to this block's end - unsigned long length; // count of bytes of this block - CV_SEPCODEFLAGS scf; // flags - CV_uoff32_t off; // sect:off of the separated code - CV_uoff32_t offParent; // sectParent:offParent of the enclosing scope - unsigned short sect; // (proc, block, or sepcode) - unsigned short sectParent; -} SEPCODESYM; - -typedef struct BUILDINFOSYM { - unsigned short reclen; // Record length - unsigned short rectyp; // S_BUILDINFO - CV_ItemId id; // CV_ItemId of Build Info. -} BUILDINFOSYM; - -typedef struct INLINESITESYM { - unsigned short reclen; // Record length - unsigned short rectyp; // S_INLINESITE - unsigned long pParent; // pointer to the inliner - unsigned long pEnd; // pointer to this block's end - CV_ItemId inlinee; // CV_ItemId of inlinee - unsigned char binaryAnnotations[CV_ZEROLEN]; // an array of compressed binary annotations. -} INLINESITESYM; - -typedef struct INLINESITESYM2 { - unsigned short reclen; // Record length - unsigned short rectyp; // S_INLINESITE2 - unsigned long pParent; // pointer to the inliner - unsigned long pEnd; // pointer to this block's end - CV_ItemId inlinee; // CV_ItemId of inlinee - unsigned long invocations; // entry count - unsigned char binaryAnnotations[CV_ZEROLEN]; // an array of compressed binary annotations. -} INLINESITESYM2; - - -// Defines a locals and it is live range, how to evaluate. -// S_DEFRANGE modifies previous local S_LOCAL, it has to consecutive. - -typedef struct LOCALSYM { - unsigned short reclen; // Record length - unsigned short rectyp; // S_LOCAL - CV_typ_t typind; // type index - CV_LVARFLAGS flags; // local var flags - - unsigned char name[CV_ZEROLEN]; // Name of this symbol, a null terminated array of UTF8 characters. -} LOCALSYM; - -typedef struct FILESTATICSYM { - unsigned short reclen; // Record length - unsigned short rectyp; // S_FILESTATIC - CV_typ_t typind; // type index - CV_uoff32_t modOffset; // index of mod filename in stringtable - CV_LVARFLAGS flags; // local var flags - - unsigned char name[CV_ZEROLEN]; // Name of this symbol, a null terminated array of UTF8 characters -} FILESTATICSYM; - -typedef struct DEFRANGESYM { // A live range of sub field of variable - unsigned short reclen; // Record length - unsigned short rectyp; // S_DEFRANGE - - CV_uoff32_t program; // DIA program to evaluate the value of the symbol - - CV_LVAR_ADDR_RANGE range; // Range of addresses where this program is valid - CV_LVAR_ADDR_GAP gaps[CV_ZEROLEN]; // The value is not available in following gaps. -} DEFRANGESYM; - -typedef struct DEFRANGESYMSUBFIELD { // A live range of sub field of variable. like locala.i - unsigned short reclen; // Record length - unsigned short rectyp; // S_DEFRANGE_SUBFIELD - - CV_uoff32_t program; // DIA program to evaluate the value of the symbol - - CV_uoff32_t offParent; // Offset in parent variable. - - CV_LVAR_ADDR_RANGE range; // Range of addresses where this program is valid - CV_LVAR_ADDR_GAP gaps[CV_ZEROLEN]; // The value is not available in following gaps. -} DEFRANGESYMSUBFIELD; - -typedef struct CV_RANGEATTR { - unsigned short maybe : 1; // May have no user name on one of control flow path. - unsigned short padding : 15; // Padding for future use. -} CV_RANGEATTR; - -typedef struct DEFRANGESYMREGISTER { // A live range of en-registed variable - unsigned short reclen; // Record length - unsigned short rectyp; // S_DEFRANGE_REGISTER - unsigned short reg; // Register to hold the value of the symbol - CV_RANGEATTR attr; // Attribute of the register range. - CV_LVAR_ADDR_RANGE range; // Range of addresses where this program is valid - CV_LVAR_ADDR_GAP gaps[CV_ZEROLEN]; // The value is not available in following gaps. -} DEFRANGESYMREGISTER; - -typedef struct DEFRANGESYMFRAMEPOINTERREL { // A live range of frame variable - unsigned short reclen; // Record length - unsigned short rectyp; // S_DEFRANGE_FRAMEPOINTER_REL - - CV_off32_t offFramePointer; // offset to frame pointer - - CV_LVAR_ADDR_RANGE range; // Range of addresses where this program is valid - CV_LVAR_ADDR_GAP gaps[CV_ZEROLEN]; // The value is not available in following gaps. -} DEFRANGESYMFRAMEPOINTERREL; - -typedef struct DEFRANGESYMFRAMEPOINTERREL_FULL_SCOPE { // A frame variable valid in all function scope - unsigned short reclen; // Record length - unsigned short rectyp; // S_DEFRANGE_FRAMEPOINTER_REL - - CV_off32_t offFramePointer; // offset to frame pointer -} DEFRANGESYMFRAMEPOINTERREL_FULL_SCOPE; - -#define CV_OFFSET_PARENT_LENGTH_LIMIT 12 - -// Note DEFRANGESYMREGISTERREL and DEFRANGESYMSUBFIELDREGISTER had same layout. -typedef struct DEFRANGESYMSUBFIELDREGISTER { // A live range of sub field of variable. like locala.i - unsigned short reclen; // Record length - unsigned short rectyp; // S_DEFRANGE_SUBFIELD_REGISTER - - unsigned short reg; // Register to hold the value of the symbol - CV_RANGEATTR attr; // Attribute of the register range. - CV_uoff32_t offParent : CV_OFFSET_PARENT_LENGTH_LIMIT; // Offset in parent variable. - CV_uoff32_t padding : 20; // Padding for future use. - CV_LVAR_ADDR_RANGE range; // Range of addresses where this program is valid - CV_LVAR_ADDR_GAP gaps[CV_ZEROLEN]; // The value is not available in following gaps. -} DEFRANGESYMSUBFIELDREGISTER; - -// Note DEFRANGESYMREGISTERREL and DEFRANGESYMSUBFIELDREGISTER had same layout. -// Used when /GS Copy parameter as local variable or other variable don't cover by FRAMERELATIVE. -typedef struct DEFRANGESYMREGISTERREL { // A live range of variable related to a register. - unsigned short reclen; // Record length - unsigned short rectyp; // S_DEFRANGE_REGISTER_REL - - unsigned short baseReg; // Register to hold the base pointer of the symbol - unsigned short spilledUdtMember : 1; // Spilled member for s.i. - unsigned short padding : 3; // Padding for future use. - unsigned short offsetParent : CV_OFFSET_PARENT_LENGTH_LIMIT; // Offset in parent variable. - CV_off32_t offBasePointer; // offset to register - - CV_LVAR_ADDR_RANGE range; // Range of addresses where this program is valid - CV_LVAR_ADDR_GAP gaps[CV_ZEROLEN]; // The value is not available in following gaps. -} DEFRANGESYMREGISTERREL; - -typedef struct DEFRANGESYMHLSL { // A live range of variable related to a symbol in HLSL code. - unsigned short reclen; // Record length - unsigned short rectyp; // S_DEFRANGE_HLSL or S_DEFRANGE_DPC_PTR_TAG - - unsigned short regType; // register type from CV_HLSLREG_e - - unsigned short regIndices : 2; // 0, 1 or 2, dimensionality of register space - unsigned short spilledUdtMember : 1; // this is a spilled member - unsigned short memorySpace : 4; // memory space - unsigned short padding : 9; // for future use - - unsigned short offsetParent; // Offset in parent variable. - unsigned short sizeInParent; // Size of enregistered portion - - CV_LVAR_ADDR_RANGE range; // Range of addresses where this program is valid - unsigned char data[CV_ZEROLEN]; // variable length data specifying gaps where the value is not available - // followed by multi-dimensional offset of variable location in register - // space (see CV_DEFRANGESYMHLSL_* macros below) -} DEFRANGESYMHLSL; - -#define CV_DEFRANGESYM_GAPS_COUNT(x) \ - (((x)->reclen + sizeof((x)->reclen) - sizeof(DEFRANGESYM)) / sizeof(CV_LVAR_ADDR_GAP)) - -#define CV_DEFRANGESYMSUBFIELD_GAPS_COUNT(x) \ - (((x)->reclen + sizeof((x)->reclen) - sizeof(DEFRANGESYMSUBFIELD)) / sizeof(CV_LVAR_ADDR_GAP)) - -#define CV_DEFRANGESYMHLSL_GAPS_COUNT(x) \ - (((x)->reclen + sizeof((x)->reclen) - sizeof(DEFRANGESYMHLSL) - (x)->regIndices * sizeof(CV_uoff32_t)) / sizeof(CV_LVAR_ADDR_GAP)) - -#define CV_DEFRANGESYMHLSL_GAPS_PTR_BASE(x, t) reinterpret_cast((x)->data) - -#define CV_DEFRANGESYMHLSL_GAPS_CONST_PTR(x) \ - CV_DEFRANGESYMHLSL_GAPS_PTR_BASE(x, const CV_LVAR_ADDR_GAP*) - -#define CV_DEFRANGESYMHLSL_GAPS_PTR(x) \ - CV_DEFRANGESYMHLSL_GAPS_PTR_BASE(x, CV_LVAR_ADDR_GAP*) - -#define CV_DEFRANGESYMHLSL_OFFSET_PTR_BASE(x, t) \ - reinterpret_cast(((CV_LVAR_ADDR_GAP*)(x)->data) + CV_DEFRANGESYMHLSL_GAPS_COUNT(x)) - -#define CV_DEFRANGESYMHLSL_OFFSET_CONST_PTR(x) \ - CV_DEFRANGESYMHLSL_OFFSET_PTR_BASE(x, const CV_uoff32_t*) - -#define CV_DEFRANGESYMHLSL_OFFSET_PTR(x) \ - CV_DEFRANGESYMHLSL_OFFSET_PTR_BASE(x, CV_uoff32_t*) - -#if defined(CC_DP_CXX) && CC_DP_CXX - -// Defines a local DPC group shared variable and its location. -typedef struct LOCALDPCGROUPSHAREDSYM { - unsigned short reclen; // Record length - unsigned short rectyp; // S_LOCAL_DPC_GROUPSHARED - CV_typ_t typind; // type index - CV_LVARFLAGS flags; // local var flags - - unsigned short dataslot; // Base data (cbuffer, groupshared, etc.) slot - unsigned short dataoff; // Base data byte offset start - - unsigned char name[CV_ZEROLEN]; // Name of this symbol, a null terminated array of UTF8 characters. -} LOCALDPCGROUPSHAREDSYM; - -typedef struct DPCSYMTAGMAP { // A map for DPC pointer tag values to symbol records. - unsigned short reclen; // Record length - unsigned short rectyp; // S_DPC_SYM_TAG_MAP - - CV_DPC_SYM_TAG_MAP_ENTRY mapEntries[CV_ZEROLEN]; // Array of mappings from DPC pointer tag values to symbol record offsets -} DPCSYMTAGMAP; - -#define CV_DPCSYMTAGMAP_COUNT(x) \ - (((x)->reclen + sizeof((x)->reclen) - sizeof(DPCSYMTAGMAP)) / sizeof(CV_DPC_SYM_TAG_MAP_ENTRY)) - -#endif // CC_DP_CXX - -typedef enum CV_armswitchtype { - CV_SWT_INT1 = 0, - CV_SWT_UINT1 = 1, - CV_SWT_INT2 = 2, - CV_SWT_UINT2 = 3, - CV_SWT_INT4 = 4, - CV_SWT_UINT4 = 5, - CV_SWT_POINTER = 6, - CV_SWT_UINT1SHL1 = 7, - CV_SWT_UINT2SHL1 = 8, - CV_SWT_INT1SHL1 = 9, - CV_SWT_INT2SHL1 = 10, - CV_SWT_TBB = CV_SWT_UINT1SHL1, - CV_SWT_TBH = CV_SWT_UINT2SHL1, -} CV_armswitchtype; - -typedef struct FUNCTIONLIST { - unsigned short reclen; // Record length - unsigned short rectyp; // S_CALLERS or S_CALLEES - - unsigned long count; // Number of functions - CV_typ_t funcs[CV_ZEROLEN]; // List of functions, dim == count - // unsigned long invocations[CV_ZEROLEN]; Followed by a parallel array of - // invocation counts. Counts > reclen are assumed to be zero -} FUNCTIONLIST; - -typedef struct POGOINFO { - unsigned short reclen; // Record length - unsigned short rectyp; // S_POGODATA - - unsigned long invocations; // Number of times function was called - __int64 dynCount; // Dynamic instruction count - unsigned long numInstrs; // Static instruction count - unsigned long staInstLive; // Final static instruction count (post inlining) -} POGOINFO; - -typedef struct ARMSWITCHTABLE { - unsigned short reclen; // Record length - unsigned short rectyp; // S_ARMSWITCHTABLE - - CV_uoff32_t offsetBase; // Section-relative offset to the base for switch offsets - unsigned short sectBase; // Section index of the base for switch offsets - unsigned short switchType; // type of each entry - CV_uoff32_t offsetBranch; // Section-relative offset to the table branch instruction - CV_uoff32_t offsetTable; // Section-relative offset to the start of the table - unsigned short sectBranch; // Section index of the table branch instruction - unsigned short sectTable; // Section index of the table - unsigned long cEntries; // number of switch table entries -} ARMSWITCHTABLE; - -typedef struct MODTYPEREF { - unsigned short reclen; // Record length - unsigned short rectyp; // S_MOD_TYPEREF - - unsigned long fNone : 1; // module doesn't reference any type - unsigned long fRefTMPCT : 1; // reference /Z7 PCH types - unsigned long fOwnTMPCT : 1; // module contains /Z7 PCH types - unsigned long fOwnTMR : 1; // module contains type info (/Z7) - unsigned long fOwnTM : 1; // module contains type info (/Zi or /ZI) - unsigned long fRefTM : 1; // module references type info owned by other module - unsigned long reserved : 9; - - unsigned short word0; // these two words contain SN or module index depending - unsigned short word1; // on above flags -} MODTYPEREF; - -typedef struct SECTIONSYM { - unsigned short reclen; // Record length - unsigned short rectyp; // S_SECTION - - unsigned short isec; // Section number - unsigned char align; // Alignment of this section (power of 2) - unsigned char bReserved; // Reserved. Must be zero. - unsigned long rva; - unsigned long cb; - unsigned long characteristics; - unsigned char name[1]; // name -} SECTIONSYM; - -typedef struct COFFGROUPSYM { - unsigned short reclen; // Record length - unsigned short rectyp; // S_COFFGROUP - - unsigned long cb; - unsigned long characteristics; - CV_uoff32_t off; // Symbol offset - unsigned short seg; // Symbol segment - unsigned char name[1]; // name -} COFFGROUPSYM; - -typedef struct EXPORTSYM { - unsigned short reclen; // Record length - unsigned short rectyp; // S_EXPORT - - unsigned short ordinal; - unsigned short fConstant : 1; // CONSTANT - unsigned short fData : 1; // DATA - unsigned short fPrivate : 1; // PRIVATE - unsigned short fNoName : 1; // NONAME - unsigned short fOrdinal : 1; // Ordinal was explicitly assigned - unsigned short fForwarder : 1; // This is a forwarder - unsigned short reserved : 10; // Reserved. Must be zero. - unsigned char name[1]; // name of -} EXPORTSYM; - -// -// Symbol for describing indirect calls when they are using -// a function pointer cast on some other type or temporary. -// Typical content will be an LF_POINTER to an LF_PROCEDURE -// type record that should mimic an actual variable with the -// function pointer type in question. -// -// Since the compiler can sometimes tail-merge a function call -// through a function pointer, there may be more than one -// S_CALLSITEINFO record at an address. This is similar to what -// you could do in your own code by: -// -// if (expr) -// pfn = &function1; -// else -// pfn = &function2; -// -// (*pfn)(arg list); -// - -typedef struct CALLSITEINFO { - unsigned short reclen; // Record length - unsigned short rectyp; // S_CALLSITEINFO - CV_off32_t off; // offset of call site - unsigned short sect; // section index of call site - unsigned short __reserved_0; // alignment padding field, must be zero - CV_typ_t typind; // type index describing function signature -} CALLSITEINFO; - -typedef struct HEAPALLOCSITE { - unsigned short reclen; // Record length - unsigned short rectyp; // S_HEAPALLOCSITE - CV_off32_t off; // offset of call site - unsigned short sect; // section index of call site - unsigned short cbInstr; // length of heap allocation call instruction - CV_typ_t typind; // type index describing function signature -} HEAPALLOCSITE; - -// Frame cookie information - -typedef enum CV_cookietype_e -{ - CV_COOKIETYPE_COPY = 0, - CV_COOKIETYPE_XOR_SP, - CV_COOKIETYPE_XOR_BP, - CV_COOKIETYPE_XOR_R13, -} CV_cookietype_e; - -// Symbol for describing security cookie's position and type -// (raw, xor'd with esp, xor'd with ebp). - -typedef struct FRAMECOOKIE { - unsigned short reclen; // Record length - unsigned short rectyp; // S_FRAMECOOKIE - CV_off32_t off; // Frame relative offset - unsigned short reg; // Register index - CV_cookietype_e cookietype; // Type of the cookie - unsigned char flags; // Flags describing this cookie -} FRAMECOOKIE; - -typedef enum CV_DISCARDED_e -{ - CV_DISCARDED_UNKNOWN, - CV_DISCARDED_NOT_SELECTED, - CV_DISCARDED_NOT_REFERENCED, -} CV_DISCARDED_e; - -typedef struct DISCARDEDSYM { - unsigned short reclen; // Record length - unsigned short rectyp; // S_DISCARDED - unsigned long discarded : 8; // CV_DISCARDED_e - unsigned long reserved : 24; // Unused - unsigned long fileid; // First FILEID if line number info present - unsigned long linenum; // First line number - char data[CV_ZEROLEN]; // Original record(s) with invalid type indices -} DISCARDEDSYM; - -typedef struct REFMINIPDB { - unsigned short reclen; // Record length - unsigned short rectyp; // S_REF_MINIPDB - union { - unsigned long isectCoff; // coff section - CV_typ_t typind; // type index - }; - unsigned short imod; // mod index - unsigned short fLocal : 1; // reference to local (vs. global) func or data - unsigned short fData : 1; // reference to data (vs. func) - unsigned short fUDT : 1; // reference to UDT - unsigned short fLabel : 1; // reference to label - unsigned short fConst : 1; // reference to const - unsigned short reserved : 11; // reserved, must be zero - unsigned char name[1]; // zero terminated name string -} REFMINIPDB; - -typedef struct PDBMAP { - unsigned short reclen; // Record length - unsigned short rectyp; // S_PDBMAP - unsigned char name[CV_ZEROLEN]; // zero terminated source PDB filename followed by zero - // terminated destination PDB filename, both in wchar_t -} PDBMAP; - -// -// V7 line number data types -// - -enum DEBUG_S_SUBSECTION_TYPE { - DEBUG_S_IGNORE = 0x80000000, // if this bit is set in a subsection type then ignore the subsection contents - - DEBUG_S_SYMBOLS = 0xf1, - DEBUG_S_LINES, - DEBUG_S_STRINGTABLE, - DEBUG_S_FILECHKSMS, - DEBUG_S_FRAMEDATA, - DEBUG_S_INLINEELINES, - DEBUG_S_CROSSSCOPEIMPORTS, - DEBUG_S_CROSSSCOPEEXPORTS, - - DEBUG_S_IL_LINES, - DEBUG_S_FUNC_MDTOKEN_MAP, - DEBUG_S_TYPE_MDTOKEN_MAP, - DEBUG_S_MERGED_ASSEMBLYINPUT, - - DEBUG_S_COFF_SYMBOL_RVA, -}; - -struct CV_DebugSSubsectionHeader_t { - enum DEBUG_S_SUBSECTION_TYPE type; - CV_off32_t cbLen; -}; - -struct CV_DebugSLinesHeader_t { - CV_off32_t offCon; - unsigned short segCon; - unsigned short flags; - CV_off32_t cbCon; -}; - -struct CV_DebugSLinesFileBlockHeader_t { - CV_off32_t offFile; - CV_off32_t nLines; - CV_off32_t cbBlock; - // CV_Line_t lines[nLines]; - // CV_Column_t columns[nColumns]; -}; - -// -// Line flags (data present) -// -#define CV_LINES_HAVE_COLUMNS 0x0001 - -struct CV_Line_t { - unsigned long offset; // Offset to start of code bytes for line number - unsigned long linenumStart:24; // line where statement/expression starts - unsigned long deltaLineEnd:7; // delta to line where statement ends (optional) - unsigned long fStatement:1; // true if a statement linenumber, else an expression line num -}; - -typedef unsigned short CV_columnpos_t; // byte offset in a source line - -struct CV_Column_t { - CV_columnpos_t offColumnStart; - CV_columnpos_t offColumnEnd; -}; - -struct tagFRAMEDATA { - unsigned long ulRvaStart; - unsigned long cbBlock; - unsigned long cbLocals; - unsigned long cbParams; - unsigned long cbStkMax; - unsigned long frameFunc; - unsigned short cbProlog; - unsigned short cbSavedRegs; - unsigned long fHasSEH:1; - unsigned long fHasEH:1; - unsigned long fIsFunctionStart:1; - unsigned long reserved:29; -}; - -typedef struct tagFRAMEDATA FRAMEDATA, * PFRAMEDATA; - -typedef struct tagXFIXUP_DATA { - unsigned short wType; - unsigned short wExtra; - unsigned long rva; - unsigned long rvaTarget; -} XFIXUP_DATA; - -// Those cross scope IDs are private convention, -// it used to delay the ID merging for frontend and backend even linker. -// It is transparent for DIA client. -// Use those ID will let DIA run a litter slower and but -// avoid the copy type tree in some scenarios. - -#ifdef __cplusplus -namespace CodeViewInfo -{ - -typedef struct ComboID -{ - static const unsigned int IndexBitWidth = 20; - static const unsigned int ImodBitWidth = 12; - - ComboID(unsigned short imod, unsigned int index) - { - m_comboID = (((unsigned int) imod) << IndexBitWidth) | index; - } - - ComboID(unsigned int comboID) - { - m_comboID = comboID; - } - - operator unsigned int() - { - return m_comboID; - } - - unsigned short GetModIndex() - { - return (unsigned short) (m_comboID >> IndexBitWidth); - } - - unsigned int GetIndex() - { - return (m_comboID & ((1 << IndexBitWidth) - 1)); - } - -private: - - unsigned int m_comboID; -} ComboID; - - -typedef struct CrossScopeId -{ - static const unsigned int LocalIdBitWidth = 20; - static const unsigned int IdScopeBitWidth = 11; - static const unsigned int StartCrossScopeId = - (unsigned int) (1 << (LocalIdBitWidth + IdScopeBitWidth)); - static const unsigned int LocalIdMask = (1 << LocalIdBitWidth) - 1; - static const unsigned int ScopeIdMask = StartCrossScopeId - (1 << LocalIdBitWidth); - - // Compilation unit at most reference 1M constructed type. - static const unsigned int MaxLocalId = (1 << LocalIdBitWidth) - 1; - - // Compilation unit at most reference to another 2K compilation units. - static const unsigned int MaxScopeId = (1 << IdScopeBitWidth) - 1; - - CrossScopeId(unsigned short aIdScopeId, unsigned int aLocalId) - { - crossScopeId = StartCrossScopeId - | (aIdScopeId << LocalIdBitWidth) - | aLocalId; - } - - operator unsigned int() { - return crossScopeId; - } - - unsigned int GetLocalId() { - return crossScopeId & LocalIdMask; - } - - unsigned int GetIdScopeId() { - return (crossScopeId & ScopeIdMask) >> LocalIdBitWidth; - } - - static bool IsCrossScopeId(unsigned int i) - { - return (StartCrossScopeId & i) != 0; - } - - static CrossScopeId Decode(unsigned int i) - { - CrossScopeId retval; - retval.crossScopeId = i; - return retval; - } - -private: - - CrossScopeId() {} - - unsigned int crossScopeId; - -} CrossScopeId; - -// Combined encoding of TI or FuncId, In compiler implementation -// Id prefixed by 1 if it is function ID. - -typedef struct DecoratedItemId -{ - DecoratedItemId(bool isFuncId, CV_ItemId inputId) { - if (isFuncId) { - decoratedItemId = 0x80000000 | inputId; - } else { - decoratedItemId = inputId; - } - } - - DecoratedItemId(CV_ItemId encodedId) { - decoratedItemId = encodedId; - } - - operator unsigned int() { - return decoratedItemId; - } - - bool IsFuncId() - { - return (decoratedItemId & 0x80000000) == 0x80000000; - } - - CV_ItemId GetItemId() - { - return decoratedItemId & 0x7fffffff; - } - -private: - - unsigned int decoratedItemId; - -} DecoratedItemId; - -// Compilation Unit object file path include library name -// Or compile time PDB full path - -typedef struct tagPdbIdScope { - CV_off32_t offObjectFilePath; -} PdbIdScope; - -// An array of all imports by import module. -// List all cross reference for a specific ID scope. -// Format of DEBUG_S_CROSSSCOPEIMPORTS subsection is -typedef struct tagCrossScopeReferences { - PdbIdScope externalScope; // Module of definition Scope. - unsigned int countOfCrossReferences; // Count of following array. - CV_ItemId referenceIds[CV_ZEROLEN]; // CV_ItemId in another compilation unit. -} CrossScopeReferences; - -// An array of all exports in this module. -// Format of DEBUG_S_CROSSSCOPEEXPORTS subsection is -typedef struct tagLocalIdAndGlobalIdPair { - CV_ItemId localId; // local id inside the compile time PDB scope. 0 based - CV_ItemId globalId; // global id inside the link time PDB scope, if scope are different. -} LocalIdAndGlobalIdPair; - -// Format of DEBUG_S_INLINEELINEINFO subsection -// List start source file information for an inlined function. - -#define CV_INLINEE_SOURCE_LINE_SIGNATURE 0x0 -#define CV_INLINEE_SOURCE_LINE_SIGNATURE_EX 0x1 - -typedef struct tagInlineeSourceLine { - CV_ItemId inlinee; // function id. - CV_off32_t fileId; // offset into file table DEBUG_S_FILECHKSMS - CV_off32_t sourceLineNum; // definition start line number. -} InlineeSourceLine; - -typedef struct tagInlineeSourceLineEx { - CV_ItemId inlinee; // function id - CV_off32_t fileId; // offset into file table DEBUG_S_FILECHKSMS - CV_off32_t sourceLineNum; // definition start line number - unsigned int countOfExtraFiles; - CV_off32_t extraFileId[CV_ZEROLEN]; -} InlineeSourceLineEx; - -// BinaryAnnotations ::= BinaryAnnotationInstruction+ -// BinaryAnnotationInstruction ::= BinaryAnnotationOpcode Operand+ -// -// The binary annotation mechanism supports recording a list of annotations -// in an instruction stream. The X64 unwind code and the DWARF standard have -// similar design. -// -// One annotation contains opcode and a number of 32bits operands. -// -// The initial set of annotation instructions are for line number table -// encoding only. These annotations append to S_INLINESITE record, and -// operands are unsigned except for BA_OP_ChangeLineOffset. - -enum BinaryAnnotationOpcode -{ - BA_OP_Invalid, // link time pdb contains PADDINGs - BA_OP_CodeOffset, // param : start offset - BA_OP_ChangeCodeOffsetBase, // param : nth separated code chunk (main code chunk == 0) - BA_OP_ChangeCodeOffset, // param : delta of offset - BA_OP_ChangeCodeLength, // param : length of code, default next start - BA_OP_ChangeFile, // param : fileId - BA_OP_ChangeLineOffset, // param : line offset (signed) - BA_OP_ChangeLineEndDelta, // param : how many lines, default 1 - BA_OP_ChangeRangeKind, // param : either 1 (default, for statement) - // or 0 (for expression) - - BA_OP_ChangeColumnStart, // param : start column number, 0 means no column info - BA_OP_ChangeColumnEndDelta, // param : end column number delta (signed) - - // Combo opcodes for smaller encoding size. - - BA_OP_ChangeCodeOffsetAndLineOffset, // param : ((sourceDelta << 4) | CodeDelta) - BA_OP_ChangeCodeLengthAndCodeOffset, // param : codeLength, codeOffset - - BA_OP_ChangeColumnEnd, // param : end column number -}; - -inline int BinaryAnnotationInstructionOperandCount(BinaryAnnotationOpcode op) -{ - return (op == BA_OP_ChangeCodeLengthAndCodeOffset) ? 2 : 1; -} - -/////////////////////////////////////////////////////////////////////////////// -// -// This routine a simplified variant from cor.h. -// -// Compress an unsigned integer (iLen) and store the result into pDataOut. -// -// Return value is the number of bytes that the compressed data occupies. It -// is caller's responsibilityt to ensure *pDataOut has at least 4 bytes to be -// written to. -// -// Note that this function returns -1 if iLen is too big to be compressed. -// We currently can only encode numbers no larger than 0x1FFFFFFF. -// -/////////////////////////////////////////////////////////////////////////////// - -typedef unsigned __int8 UInt8; -typedef unsigned __int32 UInt32; - -typedef UInt8 CompressedAnnotation; -typedef CompressedAnnotation* PCompressedAnnotation; - -inline UInt32 CVCompressData( - UInt32 iLen, // [IN] given uncompressed data - void * pDataOut) // [OUT] buffer for the compressed data -{ - UInt8 *pBytes = reinterpret_cast(pDataOut); - - if (iLen <= 0x7F) { - *pBytes = UInt8(iLen); - return 1; - } - - if (iLen <= 0x3FFF) { - *pBytes = UInt8((iLen >> 8) | 0x80); - *(pBytes+1) = UInt8(iLen & 0xff); - return 2; - } - - if (iLen <= 0x1FFFFFFF) { - *pBytes = UInt8((iLen >> 24) | 0xC0); - *(pBytes+1) = UInt8((iLen >> 16) & 0xff); - *(pBytes+2) = UInt8((iLen >> 8) & 0xff); - *(pBytes+3) = UInt8(iLen & 0xff); - return 4; - } - - return (UInt32) -1; -} - -/////////////////////////////////////////////////////////////////////////////// -// -// Uncompress the data in pData and store the result into pDataOut. -// -// Return value is the uncompressed unsigned integer. pData is incremented to -// point to the next piece of uncompressed data. -// -// Returns -1 if what is passed in is incorrectly compressed data, such as -// (*pBytes & 0xE0) == 0xE0. -// -/////////////////////////////////////////////////////////////////////////////// - -inline UInt32 CVUncompressData( - PCompressedAnnotation & pData) // [IN,OUT] compressed data -{ - UInt32 res = (UInt32)(-1); - - if ((*pData & 0x80) == 0x00) { - // 0??? ???? - - res = (UInt32)(*pData++); - } - else if ((*pData & 0xC0) == 0x80) { - // 10?? ???? - - res = (UInt32)((*pData++ & 0x3f) << 8); - res |= *pData++; - } - else if ((*pData & 0xE0) == 0xC0) { - // 110? ???? - - res = (*pData++ & 0x1f) << 24; - res |= *pData++ << 16; - res |= *pData++ << 8; - res |= *pData++; - } - - return res; -} - -// Encode smaller absolute numbers with smaller buffer. -// -// General compression only work for input < 0x1FFFFFFF -// algorithm will not work on 0x80000000 - -inline unsigned __int32 EncodeSignedInt32(__int32 input) -{ - unsigned __int32 rotatedInput; - - if (input >= 0) { - rotatedInput = input << 1; - } else { - rotatedInput = ((-input) << 1) | 1; - } - - return rotatedInput; -} - -inline __int32 DecodeSignedInt32(unsigned __int32 input) -{ - __int32 rotatedInput; - - if (input & 1) { - rotatedInput = - (int)(input >> 1); - } else { - rotatedInput = input >> 1; - } - - return rotatedInput; -} - -} -#endif -#pragma pack ( pop ) - -#endif /* CV_INFO_INCLUDED */ diff --git a/src/inc/cycletimer.h b/src/inc/cycletimer.h deleted file mode 100644 index 229fddb33..000000000 --- a/src/inc/cycletimer.h +++ /dev/null @@ -1,56 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -// -// CycleTimer has methods related to getting cycle timer values. -// It uses an all-statics class as a namespace mechanism. -// - -#ifndef _CYCLETIMER_H_ -#define _CYCLETIMER_H_ - -#include "windef.h" - -class CycleTimer -{ - // This returns the value of the *non-thread-virtualized* cycle counter. - static unsigned __int64 GetCycleCount64(); - - - // This wraps GetCycleCount64 in the signature of QueryThreadCycleTime -- but note - // that it ignores the "thrd" argument. - static BOOL WINAPI DefaultQueryThreadCycleTime(__in HANDLE thrd, __out PULONG64 cyclesPtr); - - // The function pointer type for QueryThreadCycleTime. - typedef BOOL (WINAPI *QueryThreadCycleTimeSig)(__in HANDLE, __out PULONG64); - - // Returns a function pointer for QueryThreadCycleTime, or else BadFPtr. - static QueryThreadCycleTimeSig GetQueryThreadCycleTime(); - - // Initialized once from NULL to either BadFPtr or QueryThreadCycleTime. - static QueryThreadCycleTimeSig s_QueryThreadCycleTimeFPtr; - - public: - - // This method computes the number of cycles/sec for the current machine. The cycles are those counted - // by GetThreadCycleTime; we assume that these are of equal duration, though that is not necessarily true. - // If any OS interaction fails, returns 0.0. - static double CyclesPerSecond(); - - // Does a large number of queries, and returns the average of their overhead, so other measurements - // can adjust for this. - static unsigned __int64 QueryOverhead(); - - // There's no "native" atomic add for 64 bit, so we have this convenience function. - static void InterlockedAddU64(unsigned __int64* loc, unsigned __int64 amount); - - // Attempts to query the cycle counter of the current thread. If successful, returns "true" and sets - // *cycles to the cycle counter value. Otherwise, returns false. Note that the value returned is (currently) - // virtualized to the current thread only on Windows; on non-windows x86/x64 platforms, directly reads - // the cycle counter and returns that value. - static bool GetThreadCyclesS(unsigned __int64* cycles); -}; - -#endif // _CYCLETIMER_H_ - diff --git a/src/inc/daccess.h b/src/inc/daccess.h index 01ed65dc7..819328cf4 100644 --- a/src/inc/daccess.h +++ b/src/inc/daccess.h @@ -5,524 +5,6 @@ // File: daccess.h // -// -// Support for external access of runtime data structures. These -// macros and templates hide the details of pointer and data handling -// so that data structures and code can be compiled to work both -// in-process and through a special memory access layer. -// -// This code assumes the existence of two different pieces of code, -// the target, the runtime code that is going to be examined, and -// the host, the code that's doing the examining. Access to the -// target is abstracted so the target may be a live process on the -// same machine, a live process on a different machine, a dump file -// or whatever. No assumptions should be made about accessibility -// of the target. -// -// This code assumes that the data in the target is static. Any -// time the target's data changes the interfaces must be reset so -// that potentially stale data is discarded. -// -// This code is intended for read access and there is no -// way to write data back currently. -// -// DAC-ized code: -// - is read-only (non-invasive). So DACized codepaths can not trigger a GC. -// - has no Thread* object. In reality, DAC-ized codepaths are -// ReadProcessMemory calls from out-of-process. Conceptually, they -// are like a pure-native (preemptive) thread. -//// -// This means that in particular, you cannot DACize a GCTRIGGERS function. -// Neither can you DACize a function that throws if this will involve -// allocating a new exception object. There may be -// exceptions to these rules if you can guarantee that the DACized -// part of the code path cannot cause a garbage collection (see -// EditAndContinueModule::ResolveField for an example). -// If you need to DACize a function that may trigger -// a GC, it is probably best to refactor the function so that the DACized -// part of the code path is in a separate function. For instance, -// functions with GetOrCreate() semantics are hard to DAC-ize because -// they the Create portion is inherently invasive. Instead, consider refactoring -// into a GetOrFail() function that DAC can call; and then make GetOrCreate() -// a wrapper around that. - -// -// This code works by hiding the details of access to target memory. -// Access is divided into two types: -// 1. DPTR - access to a piece of data. -// 2. VPTR - access to a class with a vtable. The class can only have -// a single vtable pointer at the beginning of the class instance. -// Things only need to be declared as VPTRs when it is necessary to -// call virtual functions in the host. In that case the access layer -// must do extra work to provide a host vtable for the object when -// it is retrieved so that virtual functions can be called. -// -// When compiling with DACCESS_COMPILE the macros turn into templates -// which replace pointers with smart pointers that know how to fetch -// data from the target process and provide a host process version of it. -// Normal data structure access will transparently receive a host copy -// of the data and proceed, so code such as -// typedef DPTR(Class) PTR_Class; -// PTR_Class cls; -// int val = cls->m_Int; -// will work without modification. The appropriate operators are overloaded -// to provide transparent access, such as the -> operator in this case. -// Note that the convention is to create an appropriate typedef for -// each type that will be accessed. This hides the particular details -// of the type declaration and makes the usage look more like regular code. -// -// The ?PTR classes also have an implicit base type cast operator to -// produce a host-pointer instance of the given type. For example -// Class* cls = PTR_Class(addr); -// works by implicit conversion from the PTR_Class created by wrapping -// to a host-side Class instance. Again, this means that existing code -// can work without modification. -// -// Code Example: -// -// typedef struct _rangesection -// { -// PTR_IJitManager pjit; -// PTR_RangeSection pright; -// PTR_RangeSection pleft; -// ... Other fields omitted ... -// } RangeSection; -// -// RangeSection* pRS = m_RangeTree; -// -// while (pRS != NULL) -// { -// if (currentPC < pRS->LowAddress) -// pRS=pRS->pleft; -// else if (currentPC > pRS->HighAddress) -// pRS=pRS->pright; -// else -// { -// return pRS->pjit; -// } -// } -// -// This code does not require any modifications. The global reference -// provided by m_RangeTree will be a host version of the RangeSection -// instantiated by conversion. The references to pRS->pleft and -// pRS->pright will refer to DPTRs due to the modified declaration. -// In the assignment statement the compiler will automatically use -// the implicit conversion from PTR_RangeSection to RangeSection*, -// causing a host instance to be created. Finally, if an appropriate -// section is found the use of pRS->pjit will cause an implicit -// conversion from PTR_IJitManager to IJitManager. The VPTR code -// will look at target memory to determine the actual derived class -// for the JitManager and instantiate the right class in the host so -// that host virtual functions can be used just as they would in -// the target. -// -// There are situations where code modifications are required, though. -// -// 1. Any time the actual value of an address matters, such as using -// it as a search key in a tree, the target address must be used. -// -// An example of this is the RangeSection tree used to locate JIT -// managers. A portion of this code is shown above. Each -// RangeSection node in the tree describes a range of addresses -// managed by the JitMan. These addresses are just being used as -// values, not to dereference through, so there are not DPTRs. When -// searching the range tree for an address the address used in the -// search must be a target address as that's what values are kept in -// the RangeSections. In the code shown above, currentPC must be a -// target address as the RangeSections in the tree are all target -// addresses. Use dac_cast to retrieve the target address -// of a ?PTR, as well as to convert a host address to the -// target address used to retrieve that particular instance. Do not -// use dac_cast with any raw target pointer types (such as BYTE*). -// -// 2. Any time an address is modified, such as by address arithmetic, -// the arithmetic must be performed on the target address. -// -// When a host instance is created it is created for the type in use. -// There is no particular relation to any other instance, so address -// arithmetic cannot be used to get from one instance to any other -// part of memory. For example -// char* Func(Class* cls) -// { -// // String follows the basic Class data. -// return (char*)(cls + 1); -// } -// does not work with external access because the Class* used would -// have retrieved only a Class worth of data. There is no string -// following the host instance. Instead, this code should use -// dac_cast to get the target address of the Class -// instance, add sizeof(*cls) and then create a new ?PTR to access -// the desired data. Note that the newly retrieved data will not -// be contiguous with the Class instance, so address arithmetic -// will still not work. -// -// Previous Code: -// -// BOOL IsTarget(LPVOID ip) -// { -// StubCallInstrs* pStubCallInstrs = GetStubCallInstrs(); -// -// if (ip == (LPVOID) &(pStubCallInstrs->m_op)) -// { -// return TRUE; -// } -// -// Modified Code: -// -// BOOL IsTarget(LPVOID ip) -// { -// StubCallInstrs* pStubCallInstrs = GetStubCallInstrs(); -// -// if ((TADDR)ip == dac_cast(pStubCallInstrs) + -// (TADDR)offsetof(StubCallInstrs, m_op)) -// { -// return TRUE; -// } -// -// The parameter ip is a target address, so the host pStubCallInstrs -// cannot be used to derive an address from. The member & reference -// has to be replaced with a conversion from host to target address -// followed by explicit offsetting for the field. -// -// PTR_HOST_MEMBER_TADDR is a convenience macro that encapsulates -// these two operations, so the above code could also be: -// -// if ((TADDR)ip == -// PTR_HOST_MEMBER_TADDR(StubCallInstrs, pStubCallInstrs, m_op)) -// -// 3. Any time the amount of memory referenced through an address -// changes, such as by casting to a different type, a new ?PTR -// must be created. -// -// Host instances are created and stored based on both the target -// address and size of access. The access code has no way of knowing -// all possible ways that data will be retrieved for a given address -// so if code changes the way it accesses through an address a new -// ?PTR must be used, which may lead to a difference instance and -// different host address. This means that pointer identity does not hold -// across casts, so code like -// Class* cls = PTR_Class(addr); -// Class2* cls2 = PTR_Class2(addr); -// return cls == cls2; -// will fail because the host-side instances have no relation to each -// other. That isn't a problem, since by rule #1 you shouldn't be -// relying on specific host address values. -// -// Previous Code: -// -// return (ArrayClass *) m_pMethTab->GetClass(); -// -// Modified Code: -// -// return PTR_ArrayClass(m_pMethTab->GetClass()); -// -// The ?PTR templates have an implicit conversion from a host pointer -// to a target address, so the cast above constructs a new -// PTR_ArrayClass by implicitly converting the host pointer result -// from GetClass() to its target address and using that as the address -// of the new PTR_ArrayClass. As mentioned, the actual host-side -// pointer values may not be the same. -// -// Host pointer identity can be assumed as long as the type of access -// is the same. In the example above, if both accesses were of type -// Class then the host pointer will be the same, so it is safe to -// retrieve the target address of an instance and then later get -// a new host pointer for the target address using the same type as -// the host pointer in that case will be the same. This is enabled -// by caching all of the retrieved host instances. This cache is searched -// by the addr:size pair and when there's a match the existing instance -// is reused. This increases performance and also allows simple -// pointer identity to hold. It does mean that host memory grows -// in proportion to the amount of target memory being referenced, -// so retrieving extraneous data should be avoided. -// The host-side data cache grows until the Flush() method is called, -// at which point all host-side data is discarded. No host -// instance pointers should be held across a Flush(). -// -// Accessing into an object can lead to some unusual behavior. For -// example, the SList class relies on objects to contain an SLink -// instance that it uses for list maintenance. This SLink can be -// embedded anywhere in the larger object. The SList access is always -// purely to an SLink, so when using the access layer it will only -// retrieve an SLink's worth of data. The SList template will then -// do some address arithmetic to determine the start of the real -// object and cast the resulting pointer to the final object type. -// When using the access layer this results in a new ?PTR being -// created and used, so a new instance will result. The internal -// SLink instance will have no relation to the new object instance -// even though in target address terms one is embedded in the other. -// The assumption of data stability means that this won't cause -// a problem, but care must be taken with the address arithmetic, -// as layed out in rules #2 and #3. -// -// 4. Global address references cannot be used. Any reference to a -// global piece of code or data, such as a function address, global -// variable or class static variable, must be changed. -// -// The external access code may load at a different base address than -// the target process code. Global addresses are therefore not -// meaningful and must be replaced with something else. There isn't -// a single solution, so replacements must be done on a case-by-case -// basis. -// -// The simplest case is a global or class static variable. All -// declarations must be replaced with a special declaration that -// compiles into a modified accessor template value when compiled for -// external data access. Uses of the variable automatically are fixed -// up by the template instance. Note that assignment to the global -// must be independently ifdef'ed as the external access layer should -// not make any modifications. -// -// Macros allow for simple declaration of a class static and global -// values that compile into an appropriate templated value. -// -// Previous Code: -// -// static RangeSection* m_RangeTree; -// RangeSection* ExecutionManager::m_RangeTree; -// -// extern ThreadStore* g_pThreadStore; -// ThreadStore* g_pThreadStore = &StaticStore; -// class SystemDomain : public BaseDomain { -// ... -// ArrayListStatic m_appDomainIndexList; -// ... -// } -// -// SystemDomain::m_appDomainIndexList; -// -// extern DWORD gThreadTLSIndex; -// -// DWORD gThreadTLSIndex = TLS_OUT_OF_INDEXES; -// -// Modified Code: -// -// typedef DPTR(RangeSection) PTR_RangeSection; -// SPTR_DECL(RangeSection, m_RangeTree); -// SPTR_IMPL(RangeSection, ExecutionManager, m_RangeTree); -// -// typedef DPTR(ThreadStore) PTR_ThreadStore -// GPTR_DECL(ThreadStore, g_pThreadStore); -// GPTR_IMPL_INIT(ThreadStore, g_pThreadStore, &StaticStore); -// -// class SystemDomain : public BaseDomain { -// ... -// SVAL_DECL(ArrayListStatic; m_appDomainIndexList); -// ... -// } -// -// SVAL_IMPL(ArrayListStatic, SystemDomain, m_appDomainIndexList); -// -// GVAL_DECL(DWORD, gThreadTLSIndex); -// -// GVAL_IMPL_INIT(DWORD, gThreadTLSIndex, TLS_OUT_OF_INDEXES); -// -// When declaring the variable, the first argument declares the -// variable's type and the second argument declares the variable's -// name. When defining the variable the arguments are similar, with -// an extra class name parameter for the static class variable case. -// If an initializer is needed the IMPL_INIT macro should be used. -// -// Things get slightly more complicated when declaring an embedded -// array. In this case the data element is not a single element and -// therefore cannot be represented by a ?PTR. In the case of a global -// array, you should use the GARY_DECL and GARY_IMPL macros. -// We durrently have no support for declaring static array data members -// or initialized arrays. Array data members that are dynamically allocated -// need to be treated as pointer members. To reference individual elements -// you must use pointer arithmetic (see rule 2 above). An array declared -// as a local variable within a function does not need to be DACized. -// -// -// All uses of ?VAL_DECL must have a corresponding entry given in the -// DacGlobals structure in src\inc\dacvars.h. For SVAL_DECL the entry -// is class__name. For GVAL_DECL the entry is dac__name. You must add -// these entries in dacvars.h using the DEFINE_DACVAR macro. Note that -// these entries also are used for dumping memory in mini dumps and -// heap dumps. If it's not appropriate to dump a variable, (e.g., -// it's an array or some other value that is not important to have -// in a minidump) a second macro, DEFINE_DACVAR_NO_DUMP, will allow -// you to make the required entry in the DacGlobals structure without -// dumping its value. -// -// For convenience, here is a list of the various variable declaration and -// initialization macros: -// SVAL_DECL(type, name) static non-pointer data class MyClass -// member declared within { -// the class declaration // static int i; -// SVAL_DECL(int, i); -// } -// -// SVAL_IMPL(type, cls, name) static non-pointer data // int MyClass::i; -// member defined outside SVAL_IMPL(int, MyClass, i); -// the class declaration -// -// SVAL_IMPL_INIT(type, cls, static non-pointer data // int MyClass::i = 0; -// name, val) member defined and SVAL_IMPL_INIT(int, MyClass, i, 0); -// initialized outside the -// class declaration -// ------------------------------------------------------------------------------------------------ -// SPTR_DECL(type, name) static pointer data class MyClass -// member declared within { -// the class declaration // static int * pInt; -// SPTR_DECL(int, pInt); -// } -// -// SPTR_IMPL(type, cls, name) static pointer data // int * MyClass::pInt; -// member defined outside SPTR_IMPL(int, MyClass, pInt); -// the class declaration -// -// SPTR_IMPL_INIT(type, cls, static pointer data // int * MyClass::pInt = NULL; -// name, val) member defined and SPTR_IMPL_INIT(int, MyClass, pInt, NULL); -// initialized outside the -// class declaration -// ------------------------------------------------------------------------------------------------ -// GVAL_DECL(type, name) extern declaration of // extern int g_i -// global non-pointer GVAL_DECL(int, g_i); -// variable -// -// GVAL_IMPL(type, name) declaration of a // int g_i -// global non-pointer GVAL_IMPL(int, g_i); -// variable -// -// GVAL_IMPL_INIT (type, declaration and // int g_i = 0; -// name, initialization of a GVAL_IMPL_INIT(int, g_i, 0); -// val) global non-pointer -// variable -// ****Note**** -// If you use GVAL_? to declare a global variable of a structured type and you need to -// access a member of the type, you cannot use the dot operator. Instead, you must take the -// address of the variable and use the arrow operator. For example: -// struct -// { -// int x; -// char ch; -// } MyStruct; -// GVAL_IMPL(MyStruct, g_myStruct); -// int i = (&g_myStruct)->x; -// ------------------------------------------------------------------------------------------------ -// GPTR_DECL(type, name) extern declaration of // extern int * g_pInt -// global pointer GPTR_DECL(int, g_pInt); -// variable -// -// GPTR_IMPL(type, name) declaration of a // int * g_pInt -// global pointer GPTR_IMPL(int, g_pInt); -// variable -// -// GPTR_IMPL_INIT (type, declaration and // int * g_pInt = 0; -// name, initialization of a GPTR_IMPL_INIT(int, g_pInt, NULL); -// val) global pointer -// variable -// ------------------------------------------------------------------------------------------------ -// GARY_DECL(type, name) extern declaration of // extern int g_rgIntList[MAX_ELEMENTS]; -// a global array GPTR_DECL(int, g_rgIntList, MAX_ELEMENTS); -// variable -// -// GARY_IMPL(type, name) declaration of a // int g_rgIntList[MAX_ELEMENTS]; -// global pointer GPTR_IMPL(int, g_rgIntList, MAX_ELEMENTS); -// variable -// -// -// Certain pieces of code, such as the stack walker, rely on identifying -// an object from its vtable address. As the target vtable addresses -// do not necessarily correspond to the vtables used in the host, these -// references must be translated. The access layer maintains translation -// tables for all classes used with VPTR and can return the target -// vtable pointer for any host vtable in the known list of VPTR classes. -// -// ----- Errors: -// -// All errors in the access layer are reported via exceptions. The -// formal access layer methods catch all such exceptions and turn -// them into the appropriate error, so this generally isn't visible -// to users of the access layer. -// -// ----- DPTR Declaration: -// -// Create a typedef for the type with typedef DPTR(type) PTR_type; -// Replace type* with PTR_type. -// -// ----- VPTR Declaration: -// -// VPTR can only be used on classes that have a single vtable -// pointer at the beginning of the object. This should be true -// for a normal single-inheritance object. -// -// All of the classes that may be instantiated need to be identified -// and marked. In the base class declaration add either -// VPTR_BASE_VTABLE_CLASS if the class is abstract or -// VPTR_BASE_CONCRETE_VTABLE_CLASS if the class is concrete. In each -// derived class add VPTR_VTABLE_CLASS. If you end up with compile or -// link errors for an unresolved method called VPtrSize you missed a -// derived class declaration. -// -// As described above, dac can only handle classes with a single -// vtable. However, there's a special case for multiple inheritance -// situations when only one of the classes is needed for dac. If -// the base class needed is the first class in the derived class's -// layout then it can be used with dac via using the VPTR_MULTI_CLASS -// macros. Use with extreme care. -// -// All classes to be instantiated must be listed in src\inc\vptr_list.h. -// -// Create a typedef for the type with typedef VPTR(type) PTR_type; -// When using a VPTR, replace Class* with PTR_Class. -// -// ----- Specific Macros: -// -// PTR_TO_TADDR(ptr) -// Retrieves the raw target address for a ?PTR. -// See code:dac_cast for the preferred alternative -// -// PTR_HOST_TO_TADDR(host) -// Given a host address of an instance produced by a ?PTR reference, -// return the original target address. The host address must -// be an exact match for an instance. -// See code:dac_cast for the preferred alternative -// -// PTR_HOST_INT_TO_TADDR(host) -// Given a host address which resides somewhere within an instance -// produced by a ?PTR reference (a host interior pointer) return the -// corresponding target address. This is useful for evaluating -// relative pointers (e.g. RelativePointer) where calculating the -// target address requires knowledge of the target address of the -// relative pointer field itself. This lookup is slower than that for -// a non-interior host pointer so use it sparingly. -// -// VPTR_HOST_VTABLE_TO_TADDR(host) -// Given the host vtable pointer for a known VPTR class, return -// the target vtable pointer. -// -// PTR_HOST_MEMBER_TADDR(type, host, memb) -// Retrieves the target address of a host instance pointer and -// offsets it by the given member's offset within the type. -// -// PTR_HOST_INT_MEMBER_TADDR(type, host, memb) -// As above but will work for interior host pointers (see the -// description of PTR_HOST_INT_TO_TADDR for an explanation of host -// interior pointers). -// -// PTR_READ(addr, size) -// Reads a block of memory from the target and returns a host -// pointer for it. Useful for reading blocks of data from the target -// whose size is only known at runtime, such as raw code for a jitted -// method. If the data being read is actually an object, use SPTR -// instead to get better type semantics. -// -// DAC_EMPTY() -// DAC_EMPTY_ERR() -// DAC_EMPTY_RET(retVal) -// DAC_UNEXPECTED() -// Provides an empty method implementation when compiled -// for DACCESS_COMPILE. For example, use to stub out methods needed -// for vtable entries but otherwise unused. -// -// These macros are designed to turn into normal code when compiled -// without DACCESS_COMPILE. -// -//***************************************************************************** - - #ifndef __daccess_h__ #define __daccess_h__ @@ -532,45 +14,10 @@ #include "safemath.h" #include "corerror.h" -#ifndef __in -#include -#endif - -#define DACCESS_TABLE_RESOURCE "COREXTERNALDATAACCESSRESOURCE" - #ifdef PAL_STDCPP_COMPAT #include -#else -#include "clr_std/type_traits" -#include "crosscomp.h" #endif -// Information stored in the DAC table of interest to the DAC implementation -// Note that this information is shared between all instantiations of ClrDataAccess, so initialize -// it just once in code:ClrDataAccess.GetDacGlobals (rather than use fields in ClrDataAccess); -struct DacTableInfo -{ - // On Windows, the first DWORD is the 32-bit timestamp read out of the runtime dll's debug directory. - // The remaining 3 DWORDS must all be 0. - // On Mac, this is the 16-byte UUID of the runtime dll. - // It is used to validate that mscorwks is the same version as mscordacwks - DWORD dwID0; - DWORD dwID1; - DWORD dwID2; - DWORD dwID3; -}; - -// The header of the DAC table. This includes the number of globals, the number of vptrs, and -// the DacTableInfo structure. We need the DacTableInfo and DacTableHeader structs outside -// of a DACCESS_COMPILE since soshost walks the Dac table headers to find the UUID of CoreCLR -// in the target process. -struct DacTableHeader -{ - ULONG numGlobals; - ULONG numVptrs; - DacTableInfo info; -}; - // // This version of things wraps pointer access in // templates which understand how to retrieve data @@ -590,1499 +37,6 @@ typedef ULONG_PTR TADDR; // which reflects the host pointer size. typedef SIZE_T TSIZE_T; - -// -// The following table contains all the global information that data access needs to begin -// operation. All of the values stored here are RVAs. DacGlobalBase() returns the current -// base address to combine with to get a full target address. -// - -typedef struct _DacGlobals -{ -#ifdef FEATURE_PAL - static void Initialize(); - void InitializeEntries(TADDR baseAddress); -#endif // FEATURE_PAL - -// These will define all of the dac related mscorwks static and global variables -#define DEFINE_DACVAR(id_type, size, id, var) id_type id; -#define DEFINE_DACVAR_NO_DUMP(id_type, size, id, var) id_type id; -#include "dacvars.h" - - // Global functions. - ULONG fn__ThreadpoolMgr__AsyncTimerCallbackCompletion; - ULONG fn__DACNotifyCompilationFinished; - ULONG fn__ThePreStub; - -#ifdef _TARGET_ARM_ - ULONG fn__ThePreStubCompactARM; -#endif // _TARGET_ARM_ - - ULONG fn__ThePreStubPatchLabel; - ULONG fn__PrecodeFixupThunk; - ULONG fn__StubDispatchFixupStub; - ULONG fn__StubDispatchFixupPatchLabel;; -#ifdef FEATURE_COMINTEROP - ULONG fn__Unknown_AddRef; - ULONG fn__Unknown_AddRefSpecial; - ULONG fn__Unknown_AddRefInner; -#endif - - // Vtable pointer values for all classes that must - // be instanted using vtable pointers as the identity. -#define VPTR_CLASS(name) ULONG name##__vtAddr; -#define VPTR_MULTI_CLASS(name, keyBase) ULONG name##__##keyBase##__mvtAddr; -#include -#undef VPTR_CLASS -#undef VPTR_MULTI_CLASS -} DacGlobals; - -#ifdef DACCESS_COMPILE - -extern DacTableInfo g_dacTableInfo; -extern DacGlobals g_dacGlobals; - -#ifdef __cplusplus -extern "C" { -#endif - -// These two functions are largely just for marking code -// that is not fully converted. DacWarning prints a debug -// message, while DacNotImpl throws a not-implemented exception. -void __cdecl DacWarning(__in __in_z char* format, ...); -void DacNotImpl(void); - -void DacError(HRESULT err); -void DECLSPEC_NORETURN DacError_NoRet(HRESULT err); -TADDR DacGlobalBase(void); -HRESULT DacReadAll(TADDR addr, PVOID buffer, ULONG32 size, bool throwEx); -HRESULT DacWriteAll(TADDR addr, PVOID buffer, ULONG32 size, bool throwEx); -HRESULT DacAllocVirtual(TADDR addr, ULONG32 size, - ULONG32 typeFlags, ULONG32 protectFlags, - bool throwEx, TADDR* mem); -HRESULT DacFreeVirtual(TADDR mem, ULONG32 size, ULONG32 typeFlags, - bool throwEx); -PVOID DacInstantiateTypeByAddress(TADDR addr, ULONG32 size, bool throwEx); -PVOID DacInstantiateTypeByAddressNoReport(TADDR addr, ULONG32 size, bool throwEx); -PVOID DacInstantiateClassByVTable(TADDR addr, ULONG32 minSize, bool throwEx); - -// Copy a null-terminated ascii or unicode string from the target to the host. -// Note that most of the work here is to find the null terminator. If you know the exact length, -// then you can also just call DacInstantiateTypebyAddress. -PSTR DacInstantiateStringA(TADDR addr, ULONG32 maxChars, bool throwEx); -PWSTR DacInstantiateStringW(TADDR addr, ULONG32 maxChars, bool throwEx); - -TADDR DacGetTargetAddrForHostAddr(LPCVOID ptr, bool throwEx); -TADDR DacGetTargetAddrForHostInteriorAddr(LPCVOID ptr, bool throwEx); -TADDR DacGetTargetVtForHostVt(LPCVOID vtHost, bool throwEx); -PWSTR DacGetVtNameW(TADDR targetVtable); - -// Report a region of memory to the debugger -bool DacEnumMemoryRegion(TADDR addr, TSIZE_T size, bool fExpectSuccess = true); - -// Report a region of memory to the debugger -bool DacUpdateMemoryRegion(TADDR addr, TSIZE_T bufferSize, BYTE* buffer); - -HRESULT DacWriteHostInstance(PVOID host, bool throwEx); - -// This is meant to mimic the RethrowTerminalExceptions/ -// SwallowAllExceptions/RethrowTransientExceptions macros to allow minidump -// gathering cancelation for details see -// code:ClrDataAccess.EnumMemoryRegionsWrapper - -// This is usable in EX_TRY exactly how RethrowTerminalExceptions et cetera -#define RethrowCancelExceptions \ - if (GET_EXCEPTION()->GetHR() == COR_E_OPERATIONCANCELED) \ - { \ - EX_RETHROW; \ - } - -// Occasionally it's necessary to allocate some host memory for -// instance data that's created on the fly and so doesn't directly -// correspond to target memory. These are held and freed on flush -// like other instances but can't be looked up by address. -PVOID DacAllocHostOnlyInstance(ULONG32 size, bool throwEx); - -// Determines whether ASSERTs should be raised when inconsistencies in the target are detected -bool DacTargetConsistencyAssertsEnabled(); - -// Host instances can be marked as they are enumerated in -// order to break cycles. This function returns true if -// the instance is already marked, otherwise it marks the -// instance and returns false. -bool DacHostPtrHasEnumMark(LPCVOID host); - -// Determines if EnumMemoryRegions has been called on a method descriptor. -// This helps perf for minidumps of apps with large managed stacks. -bool DacHasMethodDescBeenEnumerated(LPCVOID pMD); - -// Sets a flag indicating that EnumMemoryRegions on a method desciptor -// has been successfully called. The function returns true if -// this flag had been previously set. -bool DacSetMethodDescEnumerated(LPCVOID pMD); - -// Determines if a method descriptor is valid -BOOL DacValidateMD(LPCVOID pMD); - -// Enumerate the instructions around a call site to help debugger stack walking heuristics -void DacEnumCodeForStackwalk(TADDR taCallEnd); - -// Given the address and the size of a memory range which is stored in the buffer, replace all the patches -// in the buffer with the real opcodes. This is especially important on X64 where the unwinder needs to -// disassemble the native instructions. -class MemoryRange; -HRESULT DacReplacePatchesInHostMemory(MemoryRange range, PVOID pBuffer); - -// -// Convenience macros for EnumMemoryRegions implementations. -// - -// Enumerate the given host instance and return -// true if the instance hasn't already been enumerated. -#define DacEnumHostDPtrMem(host) \ - (!DacHostPtrHasEnumMark(host) ? \ - (DacEnumMemoryRegion(PTR_HOST_TO_TADDR(host), sizeof(*host)), \ - true) : false) -#define DacEnumHostSPtrMem(host, type) \ - (!DacHostPtrHasEnumMark(host) ? \ - (DacEnumMemoryRegion(PTR_HOST_TO_TADDR(host), \ - type::DacSize(PTR_HOST_TO_TADDR(host))), \ - true) : false) -#define DacEnumHostVPtrMem(host) \ - (!DacHostPtrHasEnumMark(host) ? \ - (DacEnumMemoryRegion(PTR_HOST_TO_TADDR(host), (host)->VPtrSize()), \ - true) : false) - -// Check enumeration of 'this' and return if this has already been -// enumerated. Making this the first line of an object's EnumMemoryRegions -// method will prevent cycles. -#define DAC_CHECK_ENUM_THIS() \ - if (DacHostPtrHasEnumMark(this)) return -#define DAC_ENUM_DTHIS() \ - if (!DacEnumHostDPtrMem(this)) return -#define DAC_ENUM_STHIS(type) \ - if (!DacEnumHostSPtrMem(this, type)) return -#define DAC_ENUM_VTHIS() \ - if (!DacEnumHostVPtrMem(this)) return - -#ifdef __cplusplus -} -class ReflectionModule; -interface IMDInternalImport* DacGetMDImport(const class PEFile* peFile, - bool throwEx); -interface IMDInternalImport* DacGetMDImport(const ReflectionModule* reflectionModule, - bool throwEx); - -int DacGetIlMethodSize(TADDR methAddr); -struct COR_ILMETHOD* DacGetIlMethod(TADDR methAddr); -#ifdef WIN64EXCEPTIONS -struct _UNWIND_INFO * DacGetUnwindInfo(TADDR taUnwindInfo); - -// virtually unwind a CONTEXT out-of-process -struct _KNONVOLATILE_CONTEXT_POINTERS; -BOOL DacUnwindStackFrame(T_CONTEXT * pContext, T_KNONVOLATILE_CONTEXT_POINTERS* pContextPointers); -#endif // WIN64EXCEPTIONS - -#if defined(FEATURE_PAL) -// call back through data target to unwind out-of-process -HRESULT DacVirtualUnwind(ULONG32 threadId, PT_CONTEXT context, PT_KNONVOLATILE_CONTEXT_POINTERS contextPointers); -#endif // FEATURE_PAL - -#ifdef FEATURE_MINIMETADATA_IN_TRIAGEDUMPS -class SString; -void DacMdCacheAddEEName(TADDR taEE, const SString& ssEEName); -bool DacMdCacheGetEEName(TADDR taEE, SString & ssEEName); -#endif // FEATURE_MINIMETADATA_IN_TRIAGEDUMPS - -// -// Computes (taBase + (dwIndex * dwElementSize()), with overflow checks. -// -// Arguments: -// taBase the base TADDR value -// dwIndex the index of the offset -// dwElementSize the size of each element (to multiply the offset by) -// -// Return value: -// The resulting TADDR, or throws CORDB_E_TARGET_INCONSISTENT on overlow. -// -// Notes: -// The idea here is that overflows during address arithmetic suggest that we're operating on corrupt -// pointers. It helps to improve reliability to detect the cases we can (like overflow) and fail. Note -// that this is just a heuristic, not a security measure. We can't trust target data regardless - -// failing on overflow is just one easy case of corruption to detect. There is no need to use checked -// arithmetic everywhere in the DAC infrastructure, this is intended just for the places most likely to -// help catch bugs (eg. __DPtr::operator[]). -// -inline TADDR DacTAddrOffset( TADDR taBase, TSIZE_T dwIndex, TSIZE_T dwElementSize ) -{ - ClrSafeInt t(taBase); - t += ClrSafeInt(dwIndex) * ClrSafeInt(dwElementSize); - if( t.IsOverflow() ) - { - // Pointer arithmetic overflow - probably due to corrupt target data - DacError(CORDBG_E_TARGET_INCONSISTENT); - } - return t.Value(); -} - - -// Base pointer wrapper which provides common behavior. -class __TPtrBase -{ -public: - __TPtrBase(void) - { - // Make uninitialized pointers obvious. - m_addr = (TADDR)-1; - } - __TPtrBase(TADDR addr) - { - m_addr = addr; - } - - bool operator!() const - { - return m_addr == 0; - } - // We'd like to have an implicit conversion to bool here since the C++ - // standard says all pointer types are implicitly converted to bool. - // Unfortunately, that would cause ambiguous overload errors for uses - // of operator== and operator!=. Instead callers will have to compare - // directly against NULL. - - bool operator==(TADDR addr) const - { - return m_addr == addr; - } - bool operator!=(TADDR addr) const - { - return m_addr != addr; - } - bool operator<(TADDR addr) const - { - return m_addr < addr; - } - bool operator>(TADDR addr) const - { - return m_addr > addr; - } - bool operator<=(TADDR addr) const - { - return m_addr <= addr; - } - bool operator>=(TADDR addr) const - { - return m_addr >= addr; - } - - TADDR GetAddr(void) const - { - return m_addr; - } - TADDR SetAddr(TADDR addr) - { - m_addr = addr; - return addr; - } - -protected: - TADDR m_addr; -}; - -// Pointer wrapper base class for various forms of normal data. -// This has the common functionality between __DPtr and __ArrayDPtr. -// The DPtrType type parameter is the actual derived type in use. This is necessary so that -// inhereted functions preserve exact return types. -template -class __DPtrBase : public __TPtrBase -{ -public: - typedef type _Type; - typedef type* _Ptr; - -protected: - // Constructors - // All protected - this type should not be used directly - use one of the derived types instead. - __DPtrBase< type, DPtrType >(void) : __TPtrBase() {} - __DPtrBase< type, DPtrType >(TADDR addr) : __TPtrBase(addr) {} - - explicit __DPtrBase< type, DPtrType >(__TPtrBase addr) - { - m_addr = addr.GetAddr(); - } - explicit __DPtrBase< type, DPtrType >(type const * host) - { - m_addr = DacGetTargetAddrForHostAddr(host, true); - } - -public: - DPtrType& operator=(const __TPtrBase& ptr) - { - m_addr = ptr.GetAddr(); - return DPtrType(m_addr); - } - DPtrType& operator=(TADDR addr) - { - m_addr = addr; - return DPtrType(m_addr); - } - - type& operator*(void) const - { - return *(type*)DacInstantiateTypeByAddress(m_addr, sizeof(type), true); - } - - bool operator==(const DPtrType& ptr) const - { - return m_addr == ptr.GetAddr(); - } - bool operator==(TADDR addr) const - { - return m_addr == addr; - } - bool operator!=(const DPtrType& ptr) const - { - return !operator==(ptr); - } - bool operator!=(TADDR addr) const - { - return m_addr != addr; - } - bool operator<(const DPtrType& ptr) const - { - return m_addr < ptr.GetAddr(); - } - bool operator>(const DPtrType& ptr) const - { - return m_addr > ptr.GetAddr(); - } - bool operator<=(const DPtrType& ptr) const - { - return m_addr <= ptr.GetAddr(); - } - bool operator>=(const DPtrType& ptr) const - { - return m_addr >= ptr.GetAddr(); - } - - // Array index operator - // we want an operator[] for all possible numeric types (rather than rely on - // implicit numeric conversions on the argument) to prevent ambiguity with - // DPtr's implicit conversion to type* and the built-in operator[]. - // @dbgtodo : we could also use this technique to simplify other operators below. - template - type& operator[](indexType index) - { - // Compute the address of the element. - TADDR elementAddr; - if( index >= 0 ) - { - elementAddr = DacTAddrOffset(m_addr, index, sizeof(type)); - } - else - { - // Don't bother trying to do overflow checking for negative indexes - they are rare compared to - // positive ones. ClrSafeInt doesn't support signed datatypes yet (although we should be able to add it - // pretty easily). - elementAddr = m_addr + index * sizeof(type); - } - - // Marshal over a single instance and return a reference to it. - return *(type*) DacInstantiateTypeByAddress(elementAddr, sizeof(type), true); - } - - template - type const & operator[](indexType index) const - { - return (*const_cast<__DPtrBase*>(this))[index]; - } - - //------------------------------------------------------------------------- - // operator+ - - DPtrType operator+(unsigned short val) - { - return DPtrType(DacTAddrOffset(m_addr, val, sizeof(type))); - } - DPtrType operator+(short val) - { - return DPtrType(m_addr + val * sizeof(type)); - } - // size_t is unsigned int on Win32, so we need - // to ifdef here to make sure the unsigned int - // and size_t overloads don't collide. size_t - // is marked __w64 so a simple unsigned int - // will not work on Win32, it has to be size_t. - DPtrType operator+(size_t val) - { - return DPtrType(DacTAddrOffset(m_addr, val, sizeof(type))); - } -#if defined (_WIN64) - DPtrType operator+(unsigned int val) - { - return DPtrType(DacTAddrOffset(m_addr, val, sizeof(type))); - } -#endif - DPtrType operator+(int val) - { - return DPtrType(m_addr + val * sizeof(type)); - } - // Because of the size difference between long and int on non MS compilers, - // we only need to define these operators on Windows. These provide compatible - // overloads for DWORD addition operations. -#ifdef _MSC_VER - DPtrType operator+(unsigned long val) - { - return DPtrType(DacTAddrOffset(m_addr, val, sizeof(type))); - } - DPtrType operator+(long val) - { - return DPtrType(m_addr + val * sizeof(type)); - } -#endif - - //------------------------------------------------------------------------- - // operator- - - DPtrType operator-(unsigned short val) - { - return DPtrType(m_addr - val * sizeof(type)); - } - DPtrType operator-(short val) - { - return DPtrType(m_addr - val * sizeof(type)); - } - // size_t is unsigned int on Win32, so we need - // to ifdef here to make sure the unsigned int - // and size_t overloads don't collide. size_t - // is marked __w64 so a simple unsigned int - // will not work on Win32, it has to be size_t. - DPtrType operator-(size_t val) - { - return DPtrType(m_addr - val * sizeof(type)); - } -#ifdef _WIN64 - DPtrType operator-(unsigned int val) - { - return DPtrType(m_addr - val * sizeof(type)); - } -#endif - DPtrType operator-(int val) - { - return DPtrType(m_addr - val * sizeof(type)); - } - // Because of the size difference between long and int on non MS compilers, - // we only need to define these operators on Windows. These provide compatible - // overloads for DWORD addition operations. -#ifdef _MSC_VER // for now, everything else is 32 bit - DPtrType operator-(unsigned long val) - { - return DPtrType(m_addr - val * sizeof(type)); - } - DPtrType operator-(long val) - { - return DPtrType(m_addr - val * sizeof(type)); - } -#endif - size_t operator-(const DPtrType& val) - { - return (m_addr - val.m_addr) / sizeof(type); - } - - //------------------------------------------------------------------------- - - DPtrType& operator+=(size_t val) - { - m_addr += val * sizeof(type); - return static_cast(*this); - } - DPtrType& operator-=(size_t val) - { - m_addr -= val * sizeof(type); - return static_cast(*this); - } - - DPtrType& operator++() - { - m_addr += sizeof(type); - return static_cast(*this); - } - DPtrType& operator--() - { - m_addr -= sizeof(type); - return static_cast(*this); - } - DPtrType operator++(int postfix) - { - DPtrType orig = DPtrType(*this); - m_addr += sizeof(type); - return orig; - } - DPtrType operator--(int postfix) - { - DPtrType orig = DPtrType(*this); - m_addr -= sizeof(type); - return orig; - } - - bool IsValid(void) const - { - return m_addr && - DacInstantiateTypeByAddress(m_addr, sizeof(type), - false) != NULL; - } - void EnumMem(void) const - { - DacEnumMemoryRegion(m_addr, sizeof(type)); - } -}; - -// forward declaration -template -class __GlobalPtr; - -// Pointer wrapper for objects which are just plain data -// and need no special handling. -template -class __DPtr : public __DPtrBase > -{ -public: - // constructors - all chain to __DPtrBase constructors - __DPtr< type >(void) : __DPtrBase >() {} - __DPtr< type >(TADDR addr) : __DPtrBase >(addr) {} - - // construct const from non-const - typedef typename std::remove_const::type mutable_type; - __DPtr< type >(__DPtr const & rhs) : __DPtrBase >(rhs.GetAddr()) {} - - // construct from GlobalPtr - explicit __DPtr< type >(__GlobalPtr< type*, __DPtr< type > > globalPtr) : - __DPtrBase >(globalPtr.GetAddr()) {} - - explicit __DPtr< type >(__TPtrBase addr) : __DPtrBase >(addr) {} - explicit __DPtr< type >(type const * host) : __DPtrBase >(host) {} - - operator type*() const - { - return (type*)DacInstantiateTypeByAddress(this->m_addr, sizeof(type), true); - } - type* operator->() const - { - return (type*)DacInstantiateTypeByAddress(this->m_addr, sizeof(type), true); - } -}; - -#define DPTR(type) __DPtr< type > - -// A restricted form of DPtr that doesn't have any conversions to pointer types. -// This is useful for pointer types that almost always represent arrays, as opposed -// to pointers to single instances (eg. PTR_BYTE). In these cases, allowing implicit -// conversions to (for eg.) BYTE* would usually result in incorrect usage (eg. pointer -// arithmetic and array indexing), since only a single instance has been marshalled to the host. -// If you really must marshal a single instance (eg. converting T* to PTR_T is too painful for now), -// then use code:DacUnsafeMarshalSingleElement so we can identify such unsafe code. -template -class __ArrayDPtr : public __DPtrBase > -{ -public: - // constructors - all chain to __DPtrBase constructors - __ArrayDPtr< type >(void) : __DPtrBase >() {} - __ArrayDPtr< type >(TADDR addr) : __DPtrBase >(addr) {} - - // construct const from non-const - typedef typename std::remove_const::type mutable_type; - __ArrayDPtr< type >(__ArrayDPtr const & rhs) : __DPtrBase >(rhs.GetAddr()) {} - - explicit __ArrayDPtr< type >(__TPtrBase addr) : __DPtrBase >(addr) {} - - // Note that there is also no explicit constructor from host instances (type*). - // Going this direction is less problematic, but often still represents risky coding. -}; - -#define ArrayDPTR(type) __ArrayDPtr< type > - - -// Pointer wrapper for objects which are just plain data -// but whose size is not the same as the base type size. -// This can be used for prefetching data for arrays or -// for cases where an object has a variable size. -template -class __SPtr : public __TPtrBase -{ -public: - typedef type _Type; - typedef type* _Ptr; - - __SPtr< type >(void) : __TPtrBase() {} - __SPtr< type >(TADDR addr) : __TPtrBase(addr) {} - explicit __SPtr< type >(__TPtrBase addr) - { - m_addr = addr.GetAddr(); - } - explicit __SPtr< type >(type* host) - { - m_addr = DacGetTargetAddrForHostAddr(host, true); - } - - __SPtr< type >& operator=(const __TPtrBase& ptr) - { - m_addr = ptr.GetAddr(); - return *this; - } - __SPtr< type >& operator=(TADDR addr) - { - m_addr = addr; - return *this; - } - - operator type*() const - { - if (m_addr) - { - return (type*)DacInstantiateTypeByAddress(m_addr, - type::DacSize(m_addr), - true); - } - else - { - return (type*)NULL; - } - } - type* operator->() const - { - if (m_addr) - { - return (type*)DacInstantiateTypeByAddress(m_addr, - type::DacSize(m_addr), - true); - } - else - { - return (type*)NULL; - } - } - type& operator*(void) const - { - if (!m_addr) - { - DacError(E_INVALIDARG); - } - - return *(type*)DacInstantiateTypeByAddress(m_addr, - type::DacSize(m_addr), - true); - } - - bool IsValid(void) const - { - return m_addr && - DacInstantiateTypeByAddress(m_addr, type::DacSize(m_addr), - false) != NULL; - } - void EnumMem(void) const - { - if (m_addr) - { - DacEnumMemoryRegion(m_addr, type::DacSize(m_addr)); - } - } -}; - -#define SPTR(type) __SPtr< type > - -// Pointer wrapper for objects which have a single leading -// vtable, such as objects in a single-inheritance tree. -// The base class of all such trees must have use -// VPTR_BASE_VTABLE_CLASS in their declaration and all -// instantiable members of the tree must be listed in vptr_list.h. -template -class __VPtr : public __TPtrBase -{ -public: - // VPtr::_Type has to be a pointer as - // often the type is an abstract class. - // This type is not expected to be used anyway. - typedef type* _Type; - typedef type* _Ptr; - - __VPtr< type >(void) : __TPtrBase() {} - __VPtr< type >(TADDR addr) : __TPtrBase(addr) {} - explicit __VPtr< type >(__TPtrBase addr) - { - m_addr = addr.GetAddr(); - } - explicit __VPtr< type >(type* host) - { - m_addr = DacGetTargetAddrForHostAddr(host, true); - } - - __VPtr< type >& operator=(const __TPtrBase& ptr) - { - m_addr = ptr.GetAddr(); - return *this; - } - __VPtr< type >& operator=(TADDR addr) - { - m_addr = addr; - return *this; - } - - operator type*() const - { - return (type*)DacInstantiateClassByVTable(m_addr, sizeof(type), true); - } - type* operator->() const - { - return (type*)DacInstantiateClassByVTable(m_addr, sizeof(type), true); - } - - bool operator==(const __VPtr< type >& ptr) const - { - return m_addr == ptr.m_addr; - } - bool operator==(TADDR addr) const - { - return m_addr == addr; - } - bool operator!=(const __VPtr< type >& ptr) const - { - return !operator==(ptr); - } - bool operator!=(TADDR addr) const - { - return m_addr != addr; - } - - bool IsValid(void) const - { - return m_addr && - DacInstantiateClassByVTable(m_addr, sizeof(type), false) != NULL; - } - void EnumMem(void) const - { - if (IsValid()) - { - DacEnumMemoryRegion(m_addr, (operator->())->VPtrSize()); - } - } -}; - -#define VPTR(type) __VPtr< type > - -// Pointer wrapper for 8-bit strings. -template -class __Str8Ptr : public __DPtr -{ -public: - typedef type _Type; - typedef type* _Ptr; - - __Str8Ptr< type, maxChars >(void) : __DPtr() {} - __Str8Ptr< type, maxChars >(TADDR addr) : __DPtr(addr) {} - explicit __Str8Ptr< type, maxChars >(__TPtrBase addr) - { - m_addr = addr.GetAddr(); - } - explicit __Str8Ptr< type, maxChars >(type* host) - { - m_addr = DacGetTargetAddrForHostAddr(host, true); - } - - __Str8Ptr< type, maxChars >& operator=(const __TPtrBase& ptr) - { - m_addr = ptr.GetAddr(); - return *this; - } - __Str8Ptr< type, maxChars >& operator=(TADDR addr) - { - m_addr = addr; - return *this; - } - - operator type*() const - { - return (type*)DacInstantiateStringA(m_addr, maxChars, true); - } - - bool IsValid(void) const - { - return m_addr && - DacInstantiateStringA(m_addr, maxChars, false) != NULL; - } - void EnumMem(void) const - { - char* str = DacInstantiateStringA(m_addr, maxChars, false); - if (str) - { - DacEnumMemoryRegion(m_addr, strlen(str) + 1); - } - } -}; - -#define S8PTR(type) __Str8Ptr< type > -#define S8PTRMAX(type, maxChars) __Str8Ptr< type, maxChars > - -// Pointer wrapper for 16-bit strings. -template -class __Str16Ptr : public __DPtr -{ -public: - typedef type _Type; - typedef type* _Ptr; - - __Str16Ptr< type, maxChars >(void) : __DPtr() {} - __Str16Ptr< type, maxChars >(TADDR addr) : __DPtr(addr) {} - explicit __Str16Ptr< type, maxChars >(__TPtrBase addr) - { - m_addr = addr.GetAddr(); - } - explicit __Str16Ptr< type, maxChars >(type* host) - { - m_addr = DacGetTargetAddrForHostAddr(host, true); - } - - __Str16Ptr< type, maxChars >& operator=(const __TPtrBase& ptr) - { - m_addr = ptr.GetAddr(); - return *this; - } - __Str16Ptr< type, maxChars >& operator=(TADDR addr) - { - m_addr = addr; - return *this; - } - - operator type*() const - { - return (type*)DacInstantiateStringW(m_addr, maxChars, true); - } - - bool IsValid(void) const - { - return m_addr && - DacInstantiateStringW(m_addr, maxChars, false) != NULL; - } - void EnumMem(void) const - { - char* str = DacInstantiateStringW(m_addr, maxChars, false); - if (str) - { - DacEnumMemoryRegion(m_addr, strlen(str) + 1); - } - } -}; - -#define S16PTR(type) __Str16Ptr< type > -#define S16PTRMAX(type, maxChars) __Str16Ptr< type, maxChars > - -template -class __GlobalVal -{ -public: - __GlobalVal< type >(PULONG rvaPtr) - { - m_rvaPtr = rvaPtr; - } - - operator type() const - { - return (type)*__DPtr< type >(DacGlobalBase() + *m_rvaPtr); - } - - __DPtr< type > operator&() const - { - return __DPtr< type >(DacGlobalBase() + *m_rvaPtr); - } - - // @dbgtodo dac support: This updates values in the host. This seems extremely dangerous - // to do silently. I'd prefer that a specific (searchable) write function - // was used. Try disabling this and see what fails... - __GlobalVal & operator=(const type & val) - { - type* ptr = __DPtr< type >(DacGlobalBase() + *m_rvaPtr); - // Update the host copy; - *ptr = val; - // Write back to the target. - DacWriteHostInstance(ptr, true); - return *this; - } - - bool IsValid(void) const - { - return __DPtr< type >(DacGlobalBase() + *m_rvaPtr).IsValid(); - } - void EnumMem(void) const - { - TADDR p = DacGlobalBase() + *m_rvaPtr; - __DPtr< type >(p).EnumMem(); - } - -private: - PULONG m_rvaPtr; -}; - -template -class __GlobalArray -{ -public: - __GlobalArray< type, size >(PULONG rvaPtr) - { - m_rvaPtr = rvaPtr; - } - - __DPtr< type > operator&() const - { - return __DPtr< type >(DacGlobalBase() + *m_rvaPtr); - } - - type& operator[](unsigned int index) const - { - return __DPtr< type >(DacGlobalBase() + *m_rvaPtr)[index]; - } - - bool IsValid(void) const - { - // Only validates the base pointer, not the full array range. - return __DPtr< type >(DacGlobalBase() + *m_rvaPtr).IsValid(); - } - void EnumMem(void) const - { - DacEnumMemoryRegion(DacGlobalBase() + *m_rvaPtr, sizeof(type) * size); - } - -private: - PULONG m_rvaPtr; -}; - -template -class __GlobalPtr -{ -public: - __GlobalPtr< acc_type, store_type >(PULONG rvaPtr) - { - m_rvaPtr = rvaPtr; - } - - __DPtr< store_type > operator&() const - { - return __DPtr< store_type >(DacGlobalBase() + *m_rvaPtr); - } - - store_type & operator=(store_type & val) - { - store_type* ptr = __DPtr< store_type >(DacGlobalBase() + *m_rvaPtr); - // Update the host copy; - *ptr = val; - // Write back to the target. - DacWriteHostInstance(ptr, true); - return val; - } - - acc_type operator->() const - { - return (acc_type)*__DPtr< store_type >(DacGlobalBase() + *m_rvaPtr); - } - operator acc_type() const - { - return (acc_type)*__DPtr< store_type >(DacGlobalBase() + *m_rvaPtr); - } - operator store_type() const - { - return *__DPtr< store_type >(DacGlobalBase() + *m_rvaPtr); - } - bool operator!() const - { - return !*__DPtr< store_type >(DacGlobalBase() + *m_rvaPtr); - } - - typename store_type::_Type& operator[](int index) - { - return (*__DPtr< store_type >(DacGlobalBase() + *m_rvaPtr))[index]; - } - - typename store_type::_Type& operator[](unsigned int index) - { - return (*__DPtr< store_type >(DacGlobalBase() + *m_rvaPtr))[index]; - } - - TADDR GetAddr() const - { - return (*__DPtr< store_type >(DacGlobalBase() + *m_rvaPtr)).GetAddr(); - } - - TADDR GetAddrRaw () const - { - return DacGlobalBase() + *m_rvaPtr; - } - - // This is only testing the the pointer memory is available but does not verify - // the memory that it points to. - // - bool IsValidPtr(void) const - { - return __DPtr< store_type >(DacGlobalBase() + *m_rvaPtr).IsValid(); - } - - bool IsValid(void) const - { - return __DPtr< store_type >(DacGlobalBase() + *m_rvaPtr).IsValid() && - (*__DPtr< store_type >(DacGlobalBase() + *m_rvaPtr)).IsValid(); - } - void EnumMem(void) const - { - __DPtr< store_type > ptr(DacGlobalBase() + *m_rvaPtr); - ptr.EnumMem(); - if (ptr.IsValid()) - { - (*ptr).EnumMem(); - } - } - - PULONG m_rvaPtr; -}; - -template -inline bool operator==(const __GlobalPtr& gptr, - acc_type host) -{ - return DacGetTargetAddrForHostAddr(host, true) == - *__DPtr< TADDR >(DacGlobalBase() + *gptr.m_rvaPtr); -} -template -inline bool operator!=(const __GlobalPtr& gptr, - acc_type host) -{ - return !operator==(gptr, host); -} - -template -inline bool operator==(acc_type host, - const __GlobalPtr& gptr) -{ - return DacGetTargetAddrForHostAddr(host, true) == - *__DPtr< TADDR >(DacGlobalBase() + *gptr.m_rvaPtr); -} -template -inline bool operator!=(acc_type host, - const __GlobalPtr& gptr) -{ - return !operator==(host, gptr); -} - - -// -// __VoidPtr is a type that behaves like void* but for target pointers. -// Behavior of PTR_VOID: -// * has void* semantics. Will compile to void* in non-DAC builds (just like -// other PTR types. Unlike TADDR, we want pointer semantics. -// * NOT assignable from host pointer types or convertible to host pointer -// types - ensures we can't confuse host and target pointers (we'll get -// compiler errors if we try and cast between them). -// * like void*, no pointer arithmetic or dereferencing is allowed -// * like TADDR, can be used to construct any __DPtr / __VPtr instance -// * representation is the same as a void* (for marshalling / casting) -// -// One way in which __VoidPtr is unlike void* is that it can't be cast to -// pointer or integer types. On the one hand, this is a good thing as it forces -// us to keep target pointers separate from other data types. On the other hand -// in practice this means we have to use dac_cast in places where we used -// to use a (TADDR) cast. Unfortunately C++ provides us no way to allow the -// explicit cast to primitive types without also allowing implicit conversions. -// -// This is very similar in spirit to TADDR. The primary difference is that -// PTR_VOID has pointer semantics, where TADDR has integer semantics. When -// dacizing uses of void* to TADDR, casts must be inserted everywhere back to -// pointer types. If we switch a use of TADDR to PTR_VOID, those casts in -// DACCESS_COMPILE regions no longer compile (see above). Also, TADDR supports -// pointer arithmetic, but that might not be necessary (could use PTR_BYTE -// instead etc.). Ideally we'd probably have just one type for this purpose -// (named TADDR but with the semantics of PTR_VOID), but outright conversion -// would require too much work. -// -class __VoidPtr : public __TPtrBase -{ -public: - __VoidPtr(void) : __TPtrBase() {} - __VoidPtr(TADDR addr) : __TPtrBase(addr) {} - - // Note, unlike __DPtr, this ctor form is not explicit. We allow implicit - // conversions from any pointer type (just like for void*). - __VoidPtr(__TPtrBase addr) - { - m_addr = addr.GetAddr(); - } - - // Like TPtrBase, VoidPtrs can also be created impicitly from all GlobalPtrs - template - __VoidPtr(__GlobalPtr globalPtr) - { - m_addr = globalPtr.GetAddr(); - } - - // Note, unlike __DPtr, there is no explicit conversion from host pointer - // types. Since void* cannot be marshalled, there is no such thing as - // a void* DAC instance in the host. - - // Also, we don't want an implicit conversion to TADDR because then the - // compiler will allow pointer arithmetic (which it wouldn't allow for - // void*). Instead, callers can use dac_cast if they want. - - // Note, unlike __DPtr, any pointer type can be assigned to a __VoidPtr - // This is to mirror the assignability of any pointer type to a void* - __VoidPtr& operator=(const __TPtrBase& ptr) - { - m_addr = ptr.GetAddr(); - return *this; - } - __VoidPtr& operator=(TADDR addr) - { - m_addr = addr; - return *this; - } - - // note, no marshalling operators (type* conversion, operator ->, operator*) - // A void* can't be marshalled because we don't know how much to copy - - // PTR_Void can be compared to any other pointer type (because conceptually, - // any other pointer type should be implicitly convertible to void*) - bool operator==(const __TPtrBase& ptr) const - { - return m_addr == ptr.GetAddr(); - } - bool operator==(TADDR addr) const - { - return m_addr == addr; - } - bool operator!=(const __TPtrBase& ptr) const - { - return !operator==(ptr); - } - bool operator!=(TADDR addr) const - { - return m_addr != addr; - } - bool operator<(const __TPtrBase& ptr) const - { - return m_addr < ptr.GetAddr(); - } - bool operator>(const __TPtrBase& ptr) const - { - return m_addr > ptr.GetAddr(); - } - bool operator<=(const __TPtrBase& ptr) const - { - return m_addr <= ptr.GetAddr(); - } - bool operator>=(const __TPtrBase& ptr) const - { - return m_addr >= ptr.GetAddr(); - } -}; - -typedef __VoidPtr PTR_VOID; -typedef DPTR(PTR_VOID) PTR_PTR_VOID; - -// For now we treat pointers to const and non-const void the same in DAC -// builds. In general, DAC is read-only anyway and so there isn't a danger of -// writing to these pointers. Also, the non-dac builds will ensure -// const-correctness. However, if we wanted to support true void* / const void* -// behavior, we could probably build the follow functionality by templating -// __VoidPtr: -// * A PTR_VOID would be implicitly convertable to PTR_CVOID -// * An explicit coercion (ideally const_cast) would be required to convert a -// PTR_CVOID to a PTR_VOID -// * Similarily, an explicit coercion would be required to convert a cost PTR -// type (eg. PTR_CBYTE) to a PTR_VOID. -typedef __VoidPtr PTR_CVOID; - - -// The special empty ctor declared here allows the whole -// class hierarchy to be instantiated easily by the -// external access code. The actual class body will be -// read externally so no members should be initialized. - -// -// VPTR_ANY_CLASS_METHODS - Defines the following methods for all VPTR classes -// -// VPtrSize -// Returns the size of the dynamic type of the object (as opposed to sizeof -// which is based only on the static type). -// -// VPtrHostVTable -// Returns the address of the vtable for this type. -// We create a temporary instance of this type in order to read it's vtable pointer -// (at offset 0). For this temporary instance, we do not want to initialize any fields, -// so we use the marshalling ctor. Since we didn't initialize any fields, we also don't -// wan't to run the dtor (marshaled data structures don't normally expect their destructor -// or non-DAC constructors to be called in DAC builds anyway). So, rather than create a -// normal stack object, or put the object on the heap, we create the temporary object -// on the stack using placement-new and alloca, and don't destruct it. -// -#define VPTR_ANY_CLASS_METHODS(name) \ - virtual ULONG32 VPtrSize(void) { SUPPORTS_DAC; return sizeof(name); } \ - static PVOID VPtrHostVTable() { \ - void * pBuf = _alloca(sizeof(name)); \ - name * dummy = new (pBuf) name((TADDR)0, (TADDR)0); \ - return *((PVOID*)dummy); } - -#define VPTR_CLASS_METHODS(name) \ - VPTR_ANY_CLASS_METHODS(name) \ - static TADDR VPtrTargetVTable() { \ - SUPPORTS_DAC; \ - return DacGlobalBase() + g_dacGlobals.name##__vtAddr; } - -#define VPTR_MULTI_CLASS_METHODS(name, keyBase) \ - VPTR_ANY_CLASS_METHODS(name) \ - static TADDR VPtrTargetVTable() { \ - SUPPORTS_DAC; \ - return DacGlobalBase() + g_dacGlobals.name##__##keyBase##__mvtAddr; } - -#define VPTR_VTABLE_CLASS(name, base) \ -public: name(TADDR addr, TADDR vtAddr) : base(addr, vtAddr) {} \ - VPTR_CLASS_METHODS(name) - -#define VPTR_VTABLE_CLASS_AND_CTOR(name, base) \ - VPTR_VTABLE_CLASS(name, base) - -#define VPTR_MULTI_VTABLE_CLASS(name, base) \ -public: name(TADDR addr, TADDR vtAddr) : base(addr, vtAddr) {} \ - VPTR_MULTI_CLASS_METHODS(name, base) - -// Used for base classes that can be instantiated directly. -// The fake vfn is still used to force a vtable even when -// all the normal vfns are ifdef'ed out. -#define VPTR_BASE_CONCRETE_VTABLE_CLASS(name) \ -public: name(TADDR addr, TADDR vtAddr) {} \ - VPTR_CLASS_METHODS(name) - -#define VPTR_BASE_CONCRETE_VTABLE_CLASS_NO_CTOR_BODY(name) \ -public: name(TADDR addr, TADDR vtAddr); \ - VPTR_CLASS_METHODS(name) - -// The pure virtual method forces all derivations to use -// VPTR_VTABLE_CLASS to compile. -#define VPTR_BASE_VTABLE_CLASS(name) \ -public: name(TADDR addr, TADDR vtAddr) {} \ - virtual ULONG32 VPtrSize(void) = 0; - -#define VPTR_BASE_VTABLE_CLASS_AND_CTOR(name) \ - VPTR_BASE_VTABLE_CLASS(name) - -#define VPTR_BASE_VTABLE_CLASS_NO_CTOR_BODY(name) \ -public: name(TADDR addr, TADDR vtAddr); \ - virtual ULONG32 VPtrSize(void) = 0; - -#define VPTR_ABSTRACT_VTABLE_CLASS(name, base) \ -public: name(TADDR addr, TADDR vtAddr) : base(addr, vtAddr) {} - -#define VPTR_ABSTRACT_VTABLE_CLASS_AND_CTOR(name, base) \ - VPTR_ABSTRACT_VTABLE_CLASS(name, base) - -#define VPTR_ABSTRACT_VTABLE_CLASS_NO_CTOR_BODY(name, base) \ -public: name(TADDR addr, TADDR vtAddr); - -// helper macro to make the vtables unique for DAC -#define VPTR_UNIQUE(unique) - -// Safe access for retrieving the target address of a PTR. -#define PTR_TO_TADDR(ptr) ((ptr).GetAddr()) - -#define GFN_TADDR(name) (DacGlobalBase() + g_dacGlobals.fn__ ## name) - -// ROTORTODO - g++ 3 doesn't like the use of the operator& in __GlobalVal -// here. Putting GVAL_ADDR in to get things to compile while I discuss -// this matter with the g++ authors. - -#define GVAL_ADDR(g) \ - ((g).operator&()) - -// -// References to class static and global data. -// These all need to be redirected through the global -// data table. -// - -#define _SPTR_DECL(acc_type, store_type, var) \ - static __GlobalPtr< acc_type, store_type > var -#define _SPTR_IMPL(acc_type, store_type, cls, var) \ - __GlobalPtr< acc_type, store_type > cls::var(&g_dacGlobals.cls##__##var) -#define _SPTR_IMPL_INIT(acc_type, store_type, cls, var, init) \ - __GlobalPtr< acc_type, store_type > cls::var(&g_dacGlobals.cls##__##var) -#define _SPTR_IMPL_NS(acc_type, store_type, ns, cls, var) \ - __GlobalPtr< acc_type, store_type > cls::var(&g_dacGlobals.ns##__##cls##__##var) -#define _SPTR_IMPL_NS_INIT(acc_type, store_type, ns, cls, var, init) \ - __GlobalPtr< acc_type, store_type > cls::var(&g_dacGlobals.ns##__##cls##__##var) - -#define _GPTR_DECL(acc_type, store_type, var) \ - extern __GlobalPtr< acc_type, store_type > var -#define _GPTR_IMPL(acc_type, store_type, var) \ - __GlobalPtr< acc_type, store_type > var(&g_dacGlobals.dac__##var) -#define _GPTR_IMPL_INIT(acc_type, store_type, var, init) \ - __GlobalPtr< acc_type, store_type > var(&g_dacGlobals.dac__##var) - -#define SVAL_DECL(type, var) \ - static __GlobalVal< type > var -#define SVAL_IMPL(type, cls, var) \ - __GlobalVal< type > cls::var(&g_dacGlobals.cls##__##var) -#define SVAL_IMPL_INIT(type, cls, var, init) \ - __GlobalVal< type > cls::var(&g_dacGlobals.cls##__##var) -#define SVAL_IMPL_NS(type, ns, cls, var) \ - __GlobalVal< type > cls::var(&g_dacGlobals.ns##__##cls##__##var) -#define SVAL_IMPL_NS_INIT(type, ns, cls, var, init) \ - __GlobalVal< type > cls::var(&g_dacGlobals.ns##__##cls##__##var) - -#define GVAL_DECL(type, var) \ - extern __GlobalVal< type > var -#define GVAL_IMPL(type, var) \ - __GlobalVal< type > var(&g_dacGlobals.dac__##var) -#define GVAL_IMPL_INIT(type, var, init) \ - __GlobalVal< type > var(&g_dacGlobals.dac__##var) - -#define GARY_DECL(type, var, size) \ - extern __GlobalArray< type, size > var -#define GARY_IMPL(type, var, size) \ - __GlobalArray< type, size > var(&g_dacGlobals.dac__##var) - -// Translation from a host pointer back to the target address -// that was used to retrieve the data for the host pointer. -#define PTR_HOST_TO_TADDR(host) DacGetTargetAddrForHostAddr(host, true) -// Translation from a host interior pointer back to the corresponding -// target address. The host address must reside within a previously -// retrieved instance. -#define PTR_HOST_INT_TO_TADDR(host) DacGetTargetAddrForHostInteriorAddr(host, true) -// Translation from a host vtable pointer to a target vtable pointer. -#define VPTR_HOST_VTABLE_TO_TADDR(host) DacGetTargetVtForHostVt(host, true) - -// Construct a pointer to a member of the given type. -#define PTR_HOST_MEMBER_TADDR(type, host, memb) \ - (PTR_HOST_TO_TADDR(host) + (TADDR)offsetof(type, memb)) - -// Construct a pointer to a member of the given type given an interior -// host address. -#define PTR_HOST_INT_MEMBER_TADDR(type, host, memb) \ - (PTR_HOST_INT_TO_TADDR(host) + (TADDR)offsetof(type, memb)) - -#define PTR_TO_MEMBER_TADDR(type, ptr, memb) \ - (PTR_TO_TADDR(ptr) + (TADDR)offsetof(type, memb)) - -// Constructs an arbitrary data instance for a piece of -// memory in the target. -#define PTR_READ(addr, size) \ - DacInstantiateTypeByAddress(addr, size, true) - -// This value is used to intiailize target pointers to NULL. We want this to be TADDR type -// (as opposed to, say, __TPtrBase) so that it can be used in the non-explicit ctor overloads, -// eg. as an argument default value. -// We can't always just use NULL because that's 0 which (in C++) can be any integer or pointer -// type (causing an ambiguous overload compiler error when used in explicit ctor forms). -#define PTR_NULL ((TADDR)0) - -// Provides an empty method implementation when compiled -// for DACCESS_COMPILE. For example, use to stub out methods needed -// for vtable entries but otherwise unused. -// Note that these functions are explicitly NOT marked SUPPORTS_DAC so that we'll get a -// DacCop warning if any calls to them are detected. -// @dbgtodo : It's probably almost always wrong to call any such function, so -// we should probably throw a better error (DacNotImpl), and ideally mark the function -// DECLSPEC_NORETURN so we don't have to deal with fabricating return values and we can -// get compiler warnings (unreachable code) anytime functions marked this way are called. -#define DAC_EMPTY() { LIMITED_METHOD_CONTRACT; } -#define DAC_EMPTY_ERR() { LIMITED_METHOD_CONTRACT; DacError(E_UNEXPECTED); } -#define DAC_EMPTY_RET(retVal) { LIMITED_METHOD_CONTRACT; DacError(E_UNEXPECTED); return retVal; } -#define DAC_UNEXPECTED() { LIMITED_METHOD_CONTRACT; DacError_NoRet(E_UNEXPECTED); } - -#endif // #ifdef __cplusplus - -// Implementation details for dac_cast, should never be accessed directly. -// See code:dac_cast for details and discussion. -namespace dac_imp -{ - // Helper functions to get the target address of specific types - inline TADDR getTaddr(TADDR addr) { return addr; } - inline TADDR getTaddr(__TPtrBase const &tptr) { return PTR_TO_TADDR(tptr); } - inline TADDR getTaddr(void const * host) { return PTR_HOST_TO_TADDR((void *)host); } - template - inline TADDR getTaddr(__GlobalPtr const &gptr) { return PTR_TO_TADDR(gptr); } - - // It is an error to try dac_cast on a __GlobalVal or a __GlobalArray. Declare - // but do not define the methods so that a compile-time error results. - template - TADDR getTaddr(__GlobalVal const &gval); - template - TADDR getTaddr(__GlobalArray const &garr); - - // Helper class to instantiate DAC instances from a TADDR - // The default implementation assumes we want to create an instance of a PTR type - template struct makeDacInst - { - static inline T fromTaddr(TADDR addr) - { - static_assert((std::is_base_of<__TPtrBase, T>::value), "is_base_of constraint violation"); - return T(addr); - } - }; - - // Partial specialization for creating TADDRs - // This is the only other way to create a DAC type instance other than PTR types (above) - template<> struct makeDacInst - { - static inline TADDR fromTaddr(TADDR addr) { return addr; } - }; -} // namespace dac_imp - - -// DacCop in-line exclusion mechanism - -// Warnings - official home is DacCop\Shared\Warnings.cs, but we want a way for users to indicate -// warning codes in a way that is descriptive to readers (not just code numbers). The names here -// don't matter - DacCop just looks at the value -enum DacCopWarningCode -{ - // General Rules - FieldAccess = 1, - PointerArith = 2, - PointerComparison = 3, - InconsistentMarshalling = 4, - CastBetweenAddressSpaces = 5, - CastOfMarshalledType = 6, - VirtualCallToNonVPtr = 7, - UndacizedGlobalVariable = 8, - - // Function graph related - CallUnknown = 701, - CallNonDac = 702, - CallVirtualUnknown = 704, - CallVirtualNonDac = 705, -}; - -// DACCOP_IGNORE is a mechanism to suppress DacCop violations from within the source-code. -// See the DacCop wiki for guidance on how best to use this: http://mswikis/clr/dev/Pages/DacCop.aspx -// -// DACCOP_IGNORE will suppress a DacCop violation for the following (non-compound) statement. -// For example: -// // The "dual-mode DAC problem" occurs in a few places where a class is used both -// // in the host, and marshalled from the target ... -// DACCOP_IGNORE(CastBetweenAddressSpaces,"SBuffer has the dual-mode DAC problem"); -// TADDR bufAddr = (TADDR)m_buffer; -// -// A call to DACCOP_IGNORE must occur as it's own statement, and can apply only to following -// single-statements (not to compound statement blocks). Occasionally it is necessary to hoist -// violation-inducing code out to its own statement (e.g., if it occurs in the conditional of an -// if). -// -// Arguments: -// code: a literal value from DacCopWarningCode indicating which violation should be suppressed. -// szReasonString: a short description of why this exclusion is necessary. This is intended just -// to help readers of the code understand the source of the problem, and what would be required -// to fix it. More details can be provided in comments if desired. -// -inline void DACCOP_IGNORE(DacCopWarningCode code, const char * szReasonString) -{ - // DacCop detects calls to this function. No implementation is necessary. -} - -#else // #ifdef DACCESS_COMPILE - // // This version of the macros turns into normal pointers // for unmodified in-proc compilation. @@ -2115,121 +69,6 @@ typedef const void* PTR_CVOID; #define S16PTR(type) type* #define S16PTRMAX(type, maxChars) type* -#if defined(FEATURE_PAL) - -#define VPTR_VTABLE_CLASS(name, base) \ - friend struct _DacGlobals; \ -public: name(int dummy) : base(dummy) {} - -#define VPTR_VTABLE_CLASS_AND_CTOR(name, base) \ - VPTR_VTABLE_CLASS(name, base) \ - name() : base() {} - -#define VPTR_MULTI_VTABLE_CLASS(name, base) \ - friend struct _DacGlobals; \ -public: name(int dummy) : base(dummy) {} - -#define VPTR_BASE_CONCRETE_VTABLE_CLASS(name) \ - friend struct _DacGlobals; \ -public: name(int dummy) {} - -#define VPTR_BASE_VTABLE_CLASS(name) \ - friend struct _DacGlobals; \ -public: name(int dummy) {} - -#define VPTR_BASE_VTABLE_CLASS_AND_CTOR(name) \ - VPTR_BASE_VTABLE_CLASS(name) \ - name() {} - -#define VPTR_ABSTRACT_VTABLE_CLASS(name, base) \ - friend struct _DacGlobals; \ -public: name(int dummy) : base(dummy) {} - -#define VPTR_ABSTRACT_VTABLE_CLASS_AND_CTOR(name, base) \ - VPTR_ABSTRACT_VTABLE_CLASS(name, base) \ - name() : base() {} - -#else // FEATURE_PAL - -#define VPTR_VTABLE_CLASS(name, base) -#define VPTR_VTABLE_CLASS_AND_CTOR(name, base) -#define VPTR_MULTI_VTABLE_CLASS(name, base) -#define VPTR_BASE_CONCRETE_VTABLE_CLASS(name) -#define VPTR_BASE_VTABLE_CLASS(name) -#define VPTR_BASE_VTABLE_CLASS_AND_CTOR(name) -#define VPTR_ABSTRACT_VTABLE_CLASS(name, base) -#define VPTR_ABSTRACT_VTABLE_CLASS_AND_CTOR(name, base) - -#endif // FEATURE_PAL - -// helper macro to make the vtables unique for DAC -#define VPTR_UNIQUE(unique) virtual int MakeVTableUniqueForDAC() { STATIC_CONTRACT_SO_TOLERANT; return unique; } -#define VPTR_UNIQUE_BaseDomain (100000) -#define VPTR_UNIQUE_SystemDomain (VPTR_UNIQUE_BaseDomain + 1) -#define VPTR_UNIQUE_ComMethodFrame (VPTR_UNIQUE_SystemDomain + 1) -#define VPTR_UNIQUE_StubHelperFrame (VPTR_UNIQUE_ComMethodFrame + 1) -#define VPTR_UNIQUE_RedirectedThreadFrame (VPTR_UNIQUE_StubHelperFrame + 1) -#define VPTR_UNIQUE_HijackFrame (VPTR_UNIQUE_RedirectedThreadFrame + 1) - -#define PTR_TO_TADDR(ptr) ((TADDR)(ptr)) -#define GFN_TADDR(name) ((TADDR)(name)) - -#define GVAL_ADDR(g) (&(g)) -#define _SPTR_DECL(acc_type, store_type, var) \ - static store_type var -#define _SPTR_IMPL(acc_type, store_type, cls, var) \ - store_type cls::var -#define _SPTR_IMPL_INIT(acc_type, store_type, cls, var, init) \ - store_type cls::var = init -#define _SPTR_IMPL_NS(acc_type, store_type, ns, cls, var) \ - store_type cls::var -#define _SPTR_IMPL_NS_INIT(acc_type, store_type, ns, cls, var, init) \ - store_type cls::var = init -#define _GPTR_DECL(acc_type, store_type, var) \ - extern store_type var -#define _GPTR_IMPL(acc_type, store_type, var) \ - store_type var -#define _GPTR_IMPL_INIT(acc_type, store_type, var, init) \ - store_type var = init -#define SVAL_DECL(type, var) \ - static type var -#define SVAL_IMPL(type, cls, var) \ - type cls::var -#define SVAL_IMPL_INIT(type, cls, var, init) \ - type cls::var = init -#define SVAL_IMPL_NS(type, ns, cls, var) \ - type cls::var -#define SVAL_IMPL_NS_INIT(type, ns, cls, var, init) \ - type cls::var = init -#define GVAL_DECL(type, var) \ - extern type var -#define GVAL_IMPL(type, var) \ - type var -#define GVAL_IMPL_INIT(type, var, init) \ - type var = init -#define GARY_DECL(type, var, size) \ - extern type var[size] -#define GARY_IMPL(type, var, size) \ - type var[size] -#define PTR_HOST_TO_TADDR(host) ((TADDR)(host)) -#define PTR_HOST_INT_TO_TADDR(host) ((TADDR)(host)) -#define VPTR_HOST_VTABLE_TO_TADDR(host) ((TADDR)(host)) -#define PTR_HOST_MEMBER_TADDR(type, host, memb) ((TADDR)&(host)->memb) -#define PTR_HOST_INT_MEMBER_TADDR(type, host, memb) ((TADDR)&(host)->memb) -#define PTR_TO_MEMBER_TADDR(type, ptr, memb) ((TADDR)&((ptr)->memb)) -#define PTR_READ(addr, size) ((PVOID)(addr)) - -#define PTR_NULL NULL - -#define DAC_EMPTY() -#define DAC_EMPTY_ERR() -#define DAC_EMPTY_RET(retVal) -#define DAC_UNEXPECTED() - -#define DACCOP_IGNORE(warningCode, reasonString) - -#endif // #ifdef DACCESS_COMPILE - //---------------------------------------------------------------------------- // dac_cast // Casting utility, to be used for casting one class pointer type to another. @@ -2287,45 +126,12 @@ public: name(int dummy) : base(dummy) {} template inline Tgt dac_cast(Src src) { -#ifdef DACCESS_COMPILE - // In DAC builds, first get a TADDR for the source, then create the - // appropriate destination instance. - TADDR addr = dac_imp::getTaddr(src); - return dac_imp::makeDacInst::fromTaddr(addr); -#else // In non-DAC builds, dac_cast is the same as a C-style cast because we need to support: // - casting away const // - conversions between pointers and TADDR // Perhaps we should more precisely restrict it's usage, but we get the precise // restrictions in DAC builds, so it wouldn't buy us much. return (Tgt)(src); -#endif -} - -//---------------------------------------------------------------------------- -// -// Convenience macros which work for either mode. -// -//---------------------------------------------------------------------------- - -#define SPTR_DECL(type, var) _SPTR_DECL(type*, PTR_##type, var) -#define SPTR_IMPL(type, cls, var) _SPTR_IMPL(type*, PTR_##type, cls, var) -#define SPTR_IMPL_INIT(type, cls, var, init) _SPTR_IMPL_INIT(type*, PTR_##type, cls, var, init) -#define SPTR_IMPL_NS(type, ns, cls, var) _SPTR_IMPL_NS(type*, PTR_##type, ns, cls, var) -#define SPTR_IMPL_NS_INIT(type, ns, cls, var, init) _SPTR_IMPL_NS_INIT(type*, PTR_##type, ns, cls, var, init) -#define GPTR_DECL(type, var) _GPTR_DECL(type*, PTR_##type, var) -#define GPTR_IMPL(type, var) _GPTR_IMPL(type*, PTR_##type, var) -#define GPTR_IMPL_INIT(type, var, init) _GPTR_IMPL_INIT(type*, PTR_##type, var, init) - - -// If you want to marshal a single instance of an ArrayDPtr over to the host and -// return a pointer to it, you can use this function. However, this is unsafe because -// users of value may assume they can do pointer arithmetic on it. This is exactly -// the bugs ArrayDPtr is designed to prevent. See code:__ArrayDPtr for details. -template -inline type* DacUnsafeMarshalSingleElement( ArrayDPTR(type) arrayPtr ) -{ - return (DPTR(type))(arrayPtr); } //---------------------------------------------------------------------------- @@ -2389,28 +195,6 @@ typedef DPTR(IMAGE_NT_HEADERS64) PTR_IMAGE_NT_HEADERS64; typedef DPTR(IMAGE_SECTION_HEADER) PTR_IMAGE_SECTION_HEADER; typedef DPTR(IMAGE_TLS_DIRECTORY) PTR_IMAGE_TLS_DIRECTORY; -#if defined(DACCESS_COMPILE) -#include -#include -#include -#endif - -#if defined(_TARGET_X86_) && defined(FEATURE_PAL) -typedef DPTR(struct _UNWIND_INFO) PTR_UNWIND_INFO; -#endif - -#ifdef _WIN64 -typedef DPTR(T_RUNTIME_FUNCTION) PTR_RUNTIME_FUNCTION; -typedef DPTR(struct _UNWIND_INFO) PTR_UNWIND_INFO; -#if defined(_TARGET_AMD64_) -typedef DPTR(union _UNWIND_CODE) PTR_UNWIND_CODE; -#endif // _TARGET_AMD64_ -#endif // _WIN64 - -#ifdef _TARGET_ARM_ -typedef DPTR(RUNTIME_FUNCTION) PTR_RUNTIME_FUNCTION; -#endif - //---------------------------------------------------------------------------- // // A PCODE is a valid PC/IP value -- a pointer to an instruction, possibly including some processor mode bits. @@ -2421,44 +205,4 @@ typedef TADDR PCODE; typedef DPTR(PCODE) PTR_PCODE; typedef DPTR(PTR_PCODE) PTR_PTR_PCODE; -// There is another concept we should have, "pointer to the start of an instruction" -- a PCODE with any mode bits masked off. -// Attempts to introduce this concept, and classify uses of PCODE as one or the other, -// turned out to be too hard: either name choice required *many* code changes, and decisions in unfamiliar code. So despite the -// the comment above, the PCODE is currently sometimes used for the PINSTR concept. - -// See PCODEToPINSTR in utilcode.h for conversion from PCODE to PINSTR. - -//---------------------------------------------------------------------------- -// -// The access code compile must compile data structures that exactly -// match the real structures for access to work. The access code -// doesn't want all of the debugging validation code, though, so -// distinguish between _DEBUG, for declaring general debugging data -// and always-on debug code, and _DEBUG_IMPL, for debugging code -// which will be disabled when compiling for external access. -// -//---------------------------------------------------------------------------- - -#if !defined(_DEBUG_IMPL) && defined(_DEBUG) && !defined(DACCESS_COMPILE) -#define _DEBUG_IMPL 1 -#endif - -// Helper macro for tracking EnumMemoryRegions progress. -#if 0 -#define EMEM_OUT(args) DacWarning args -#else -#define EMEM_OUT(args) -#endif - -// Macros like MAIN_CLR_MODULE_NAME* for the DAC module -#define MAIN_DAC_MODULE_NAME_W W("mscordaccore") -#define MAIN_DAC_MODULE_DLL_NAME_W W("mscordaccore.dll") - -// TARGET_CONSISTENCY_CHECK represents a condition that should not fail unless the DAC target is corrupt. -// This is in contrast to ASSERTs in DAC infrastructure code which shouldn't fail regardless of the memory -// read from the target. At the moment we treat these the same, but in the future we will want a mechanism -// for disabling just the target consistency checks (eg. for tests that intentionally use corrupted targets). -// @dbgtodo : Separating asserts and target consistency checks is tracked by DevDiv Bugs 31674 -#define TARGET_CONSISTENCY_CHECK(expr,msg) _ASSERTE_MSG(expr,msg) - #endif // #ifndef __daccess_h__ diff --git a/src/inc/dacvars.h b/src/inc/dacvars.h deleted file mode 100644 index a4209f12a..000000000 --- a/src/inc/dacvars.h +++ /dev/null @@ -1,270 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -// This file contains the globals and statics that are visible to DAC. -// It is used for the following: -// 1. in daccess.h to build the table of DAC globals -// 2. in enummem.cpp to dump out the related memory of static and globals -// in a mini dump or heap dump -// 3. in DacUpdateDll and toolbox\DacTablenGen\main.cs -// -// To use this functionality for other tools or purposes, define the -// DEFINE_DACVAR macro & include dacvars.h like so (see enummem.cpp and/or -// daccess.h for examples): -// -// #define DEFINE_DACVAR(type, size, id, var) type id; //this defn. discards -// //the size -// #include "dacvars.h" -// -// @dbgtodo: -// Ideally we may be able to build a tool that generates this automatically. -// At the least, we should automatically verify that the contents of this file -// are consistent with the uses of all the macros like SVAL_DECL and GARY_DECL. -// -//================================================= -// INSTRUCTIONS FOR ADDING VARIABLES TO THIS FILE -//================================================= -// You need to add a global or static declared with DAC macros, such as SPTR_* -// GPTR_*, SVAL_*, GVAL_*, or GARY_*, only if the global or static is actually used -// in a DACized code path. If you have declared a static or global that way just -// because you were pattern-matching or because you anticipate that the variable -// may eventually be used in a DACized code path, you don't need to add it here, -// although in that case, you should not really use the DAC macro when you declare -// the global or static. -// * * * -// The FIRST ARGUMENT should always be specified as ULONG. This is the type of -// the offsets for the corresponding id in the _DacGlobals table. -// @dbgtodo: -// We should get rid of the ULONG argument since it's always the same. We would -// also need to modify DacTablenGen\main.cs. -// * * * -// The SECOND ARGUMENT, "true_type," is used to calculate the true size of the -// static/global variable. It is currently used only in enummem.cpp to write out -// theproper size of memory for dumps. -// * * * -// The THIRD ARGUMENT should be a qualified name. If the variable is a static data -// member, the name should be __. If the variable is a -// global, the name should be __. -// * * * -// The FOURTH ARGUMENT should be the actual name of the static/global variable. If -// static data the should be [::]::. If global, -// it should look like . -// * * * -// If you need to add an entry to this file, your type may not be visible when -// this file is compiled. In that case, you need to do one of two things: -// - If the type is a pointer type, you can simply use UNKNOWN_POINTER_TYPE as the -// "true type." It may be useful to specify the non-visible type in a comment. -// - If the type is a composite/user-defined type, you must #include the header -// file that defines the type in enummem.cpp. Do NOT #include it in daccess.h -// Array types may be dumped via an explicit call to enumMem, so they should -// be declared with DEFINE_DACVAR_NO_DUMP. The size in this case is immaterial, since -// nothing will be dumped. - -#ifndef DEFINE_DACVAR -#define DEFINE_DACVAR(type, true_type, id, var) -#endif - -// Use this macro to define a static var that is known to DAC, but not captured in a dump. -#ifndef DEFINE_DACVAR_NO_DUMP -#define DEFINE_DACVAR_NO_DUMP(type, true_type, id, var) -#endif - -#define UNKNOWN_POINTER_TYPE SIZE_T - -DEFINE_DACVAR(ULONG, PTR_RangeSection, ExecutionManager__m_CodeRangeList, ExecutionManager::m_CodeRangeList) -DEFINE_DACVAR(ULONG, PTR_EECodeManager, ExecutionManager__m_pDefaultCodeMan, ExecutionManager::m_pDefaultCodeMan) -DEFINE_DACVAR(ULONG, LONG, ExecutionManager__m_dwReaderCount, ExecutionManager::m_dwReaderCount) -DEFINE_DACVAR(ULONG, LONG, ExecutionManager__m_dwWriterLock, ExecutionManager::m_dwWriterLock) - -DEFINE_DACVAR(ULONG, PTR_EEJitManager, ExecutionManager__m_pEEJitManager, ExecutionManager::m_pEEJitManager) -#ifdef FEATURE_PREJIT -DEFINE_DACVAR(ULONG, PTR_NativeImageJitManager, ExecutionManager__m_pNativeImageJitManager, ExecutionManager::m_pNativeImageJitManager) -#endif -#ifdef FEATURE_READYTORUN -DEFINE_DACVAR(ULONG, PTR_ReadyToRunJitManager, ExecutionManager__m_pReadyToRunJitManager, ExecutionManager::m_pReadyToRunJitManager) -#endif - -DEFINE_DACVAR_NO_DUMP(ULONG, VMHELPDEF *, dac__hlpFuncTable, ::hlpFuncTable) -DEFINE_DACVAR(ULONG, VMHELPDEF *, dac__hlpDynamicFuncTable, ::hlpDynamicFuncTable) - -DEFINE_DACVAR(ULONG, PTR_StubManager, StubManager__g_pFirstManager, StubManager::g_pFirstManager) -DEFINE_DACVAR(ULONG, PTR_PrecodeStubManager, PrecodeStubManager__g_pManager, PrecodeStubManager::g_pManager) -DEFINE_DACVAR(ULONG, PTR_StubLinkStubManager, StubLinkStubManager__g_pManager, StubLinkStubManager::g_pManager) -DEFINE_DACVAR(ULONG, PTR_ThunkHeapStubManager, ThunkHeapStubManager__g_pManager, ThunkHeapStubManager::g_pManager) -DEFINE_DACVAR(ULONG, PTR_JumpStubStubManager, JumpStubStubManager__g_pManager, JumpStubStubManager::g_pManager) -DEFINE_DACVAR(ULONG, PTR_RangeSectionStubManager, RangeSectionStubManager__g_pManager, RangeSectionStubManager::g_pManager) -DEFINE_DACVAR(ULONG, PTR_DelegateInvokeStubManager, DelegateInvokeStubManager__g_pManager, DelegateInvokeStubManager::g_pManager) -DEFINE_DACVAR(ULONG, PTR_VirtualCallStubManagerManager, VirtualCallStubManagerManager__g_pManager, VirtualCallStubManagerManager::g_pManager) - -DEFINE_DACVAR(ULONG, PTR_ThreadStore, ThreadStore__s_pThreadStore, ThreadStore::s_pThreadStore) - -DEFINE_DACVAR(ULONG, int, ThreadpoolMgr__cpuUtilization, ThreadpoolMgr::cpuUtilization) -DEFINE_DACVAR(ULONG, ThreadpoolMgr::ThreadCounter, ThreadpoolMgr__WorkerCounter, ThreadpoolMgr::WorkerCounter) -DEFINE_DACVAR(ULONG, int, ThreadpoolMgr__MinLimitTotalWorkerThreads, ThreadpoolMgr::MinLimitTotalWorkerThreads) -DEFINE_DACVAR(ULONG, DWORD, ThreadpoolMgr__MaxLimitTotalWorkerThreads, ThreadpoolMgr::MaxLimitTotalWorkerThreads) -DEFINE_DACVAR(ULONG, UNKNOWN_POINTER_TYPE /*PTR_WorkRequest*/, ThreadpoolMgr__WorkRequestHead, ThreadpoolMgr::WorkRequestHead) // PTR_WorkRequest is not defined. So use a pointer type -DEFINE_DACVAR(ULONG, UNKNOWN_POINTER_TYPE /*PTR_WorkRequest*/, ThreadpoolMgr__WorkRequestTail, ThreadpoolMgr::WorkRequestTail) // -DEFINE_DACVAR(ULONG, ThreadpoolMgr::ThreadCounter, ThreadpoolMgr__CPThreadCounter, ThreadpoolMgr::CPThreadCounter) -DEFINE_DACVAR(ULONG, LONG, ThreadpoolMgr__MaxFreeCPThreads, ThreadpoolMgr::MaxFreeCPThreads) -DEFINE_DACVAR(ULONG, LONG, ThreadpoolMgr__MaxLimitTotalCPThreads, ThreadpoolMgr::MaxLimitTotalCPThreads) -DEFINE_DACVAR(ULONG, LONG, ThreadpoolMgr__MinLimitTotalCPThreads, ThreadpoolMgr::MinLimitTotalCPThreads) -DEFINE_DACVAR(ULONG, LIST_ENTRY, ThreadpoolMgr__TimerQueue, ThreadpoolMgr::TimerQueue) -DEFINE_DACVAR_NO_DUMP(ULONG, SIZE_T, dac__HillClimbingLog, ::HillClimbingLog) -DEFINE_DACVAR(ULONG, int, dac__HillClimbingLogFirstIndex, ::HillClimbingLogFirstIndex) -DEFINE_DACVAR(ULONG, int, dac__HillClimbingLogSize, ::HillClimbingLogSize) - -DEFINE_DACVAR(ULONG, PTR_Thread, dac__g_pFinalizerThread, ::g_pFinalizerThread) -DEFINE_DACVAR(ULONG, PTR_Thread, dac__g_pSuspensionThread, ::g_pSuspensionThread) - -DEFINE_DACVAR(ULONG, DWORD, dac__g_heap_type, g_heap_type) -DEFINE_DACVAR(ULONG, PTR_GcDacVars, dac__g_gcDacGlobals, g_gcDacGlobals) - -DEFINE_DACVAR(ULONG, PTR_SystemDomain, SystemDomain__m_pSystemDomain, SystemDomain::m_pSystemDomain) -DEFINE_DACVAR(ULONG, ArrayListStatic, SystemDomain__m_appDomainIndexList, SystemDomain::m_appDomainIndexList) -DEFINE_DACVAR(ULONG, BOOL, SystemDomain__s_fForceDebug, SystemDomain::s_fForceDebug) -DEFINE_DACVAR(ULONG, BOOL, SystemDomain__s_fForceProfiling, SystemDomain::s_fForceProfiling) -DEFINE_DACVAR(ULONG, BOOL, SystemDomain__s_fForceInstrument, SystemDomain::s_fForceInstrument) -DEFINE_DACVAR(ULONG, PTR_SharedDomain, SharedDomain__m_pSharedDomain, SharedDomain::m_pSharedDomain) - -#ifdef FEATURE_INTEROP_DEBUGGING -DEFINE_DACVAR(ULONG, DWORD, dac__g_debuggerWordTLSIndex, g_debuggerWordTLSIndex) -#endif -DEFINE_DACVAR(ULONG, DWORD, dac__g_TlsIndex, g_TlsIndex) - -#if defined(FEATURE_WINDOWSPHONE) -DEFINE_DACVAR(ULONG, int, CCLRErrorReportingManager__g_ECustomDumpFlavor, CCLRErrorReportingManager::g_ECustomDumpFlavor) -#endif - -DEFINE_DACVAR(ULONG, PTR_SString, SString__s_Empty, SString::s_Empty) - -#ifdef FEATURE_APPX -DEFINE_DACVAR(ULONG, BOOL, dac__g_fAppX, ::g_fAppX) -#endif // FEATURE_APPX - -DEFINE_DACVAR(ULONG, BOOL, SString__s_IsANSIMultibyte, SString::s_IsANSIMultibyte) - - -DEFINE_DACVAR(ULONG, INT32, ArrayBase__s_arrayBoundsZero, ArrayBase::s_arrayBoundsZero) - -DEFINE_DACVAR(ULONG, BOOL, StackwalkCache__s_Enabled, StackwalkCache::s_Enabled) - -DEFINE_DACVAR(ULONG, PTR_JITNotification, dac__g_pNotificationTable, ::g_pNotificationTable) -DEFINE_DACVAR(ULONG, ULONG32, dac__g_dacNotificationFlags, ::g_dacNotificationFlags) -DEFINE_DACVAR(ULONG, PTR_GcNotification, dac__g_pGcNotificationTable, ::g_pGcNotificationTable) - -DEFINE_DACVAR(ULONG, PTR_EEConfig, dac__g_pConfig, ::g_pConfig) - -DEFINE_DACVAR(ULONG, MscorlibBinder, dac__g_Mscorlib, ::g_Mscorlib) - -#if defined(PROFILING_SUPPORTED) || defined(PROFILING_SUPPORTED_DATA) -DEFINE_DACVAR(ULONG, ProfControlBlock, dac__g_profControlBlock, ::g_profControlBlock) -#endif // defined(PROFILING_SUPPORTED) || defined(PROFILING_SUPPORTED_DATA) - -DEFINE_DACVAR(ULONG, PTR_DWORD, dac__g_card_table, ::g_card_table) -DEFINE_DACVAR(ULONG, PTR_BYTE, dac__g_lowest_address, ::g_lowest_address) -DEFINE_DACVAR(ULONG, PTR_BYTE, dac__g_highest_address, ::g_highest_address) - -DEFINE_DACVAR(ULONG, IGCHeap, dac__g_pGCHeap, ::g_pGCHeap) - -DEFINE_DACVAR(ULONG, UNKNOWN_POINTER_TYPE, dac__g_pThinLockThreadIdDispenser, ::g_pThinLockThreadIdDispenser) -DEFINE_DACVAR(ULONG, UNKNOWN_POINTER_TYPE, dac__g_pModuleIndexDispenser, ::g_pModuleIndexDispenser) -DEFINE_DACVAR(ULONG, UNKNOWN_POINTER_TYPE, dac__g_pObjectClass, ::g_pObjectClass) -DEFINE_DACVAR(ULONG, UNKNOWN_POINTER_TYPE, dac__g_pRuntimeTypeClass, ::g_pRuntimeTypeClass) -DEFINE_DACVAR(ULONG, UNKNOWN_POINTER_TYPE, dac__g_pCanonMethodTableClass, ::g_pCanonMethodTableClass) -DEFINE_DACVAR(ULONG, UNKNOWN_POINTER_TYPE, dac__g_pStringClass, ::g_pStringClass) -DEFINE_DACVAR(ULONG, UNKNOWN_POINTER_TYPE, dac__g_pArrayClass, ::g_pArrayClass) -DEFINE_DACVAR(ULONG, UNKNOWN_POINTER_TYPE, dac__g_pSZArrayHelperClass, ::g_pSZArrayHelperClass) -DEFINE_DACVAR(ULONG, UNKNOWN_POINTER_TYPE, dac__g_pNullableClass, ::g_pNullableClass) -DEFINE_DACVAR(ULONG, UNKNOWN_POINTER_TYPE, dac__g_pByReferenceClass, ::g_pByReferenceClass) -DEFINE_DACVAR(ULONG, UNKNOWN_POINTER_TYPE, dac__g_pExceptionClass, ::g_pExceptionClass) -DEFINE_DACVAR(ULONG, UNKNOWN_POINTER_TYPE, dac__g_pThreadAbortExceptionClass, ::g_pThreadAbortExceptionClass) -DEFINE_DACVAR(ULONG, UNKNOWN_POINTER_TYPE, dac__g_pOutOfMemoryExceptionClass, ::g_pOutOfMemoryExceptionClass) -DEFINE_DACVAR(ULONG, UNKNOWN_POINTER_TYPE, dac__g_pStackOverflowExceptionClass, ::g_pStackOverflowExceptionClass) -DEFINE_DACVAR(ULONG, UNKNOWN_POINTER_TYPE, dac__g_pExecutionEngineExceptionClass, ::g_pExecutionEngineExceptionClass) -DEFINE_DACVAR(ULONG, UNKNOWN_POINTER_TYPE, dac__g_pDelegateClass, ::g_pDelegateClass) -DEFINE_DACVAR(ULONG, UNKNOWN_POINTER_TYPE, dac__g_pMulticastDelegateClass, ::g_pMulticastDelegateClass) -DEFINE_DACVAR(ULONG, UNKNOWN_POINTER_TYPE, dac__g_pFreeObjectMethodTable, ::g_pFreeObjectMethodTable) -DEFINE_DACVAR(ULONG, UNKNOWN_POINTER_TYPE, dac__g_pOverlappedDataClass, ::g_pOverlappedDataClass) -DEFINE_DACVAR(ULONG, UNKNOWN_POINTER_TYPE, dac__g_pValueTypeClass, ::g_pValueTypeClass) -DEFINE_DACVAR(ULONG, UNKNOWN_POINTER_TYPE, dac__g_pEnumClass, ::g_pEnumClass) -DEFINE_DACVAR(ULONG, UNKNOWN_POINTER_TYPE, dac__g_pThreadClass, ::g_pThreadClass) -DEFINE_DACVAR(ULONG, UNKNOWN_POINTER_TYPE, dac__g_pPredefinedArrayTypes, ::g_pPredefinedArrayTypes) -DEFINE_DACVAR(ULONG, UNKNOWN_POINTER_TYPE, dac__g_TypedReferenceMT, ::g_TypedReferenceMT) -DEFINE_DACVAR(ULONG, UNKNOWN_POINTER_TYPE, dac__g_pByteArrayMT, ::g_pByteArrayMT) - -#ifdef FEATURE_COMINTEROP -DEFINE_DACVAR(ULONG, UNKNOWN_POINTER_TYPE, dac__g_pBaseCOMObject, ::g_pBaseCOMObject) -DEFINE_DACVAR(ULONG, UNKNOWN_POINTER_TYPE, dac__g_pBaseRuntimeClass, ::g_pBaseRuntimeClass) -#endif - -#ifdef FEATURE_ICASTABLE -DEFINE_DACVAR(ULONG, UNKNOWN_POINTER_TYPE, dac__g_pICastableInterface, ::g_pICastableInterface) -#endif // FEATURE_ICASTABLE - -DEFINE_DACVAR(ULONG, UNKNOWN_POINTER_TYPE, dac__g_pExecuteBackoutCodeHelperMethod, ::g_pExecuteBackoutCodeHelperMethod) - -DEFINE_DACVAR(ULONG, UNKNOWN_POINTER_TYPE, dac__g_pObjectFinalizerMD, ::g_pObjectFinalizerMD) - -DEFINE_DACVAR(ULONG, bool, dac__g_fProcessDetach, ::g_fProcessDetach) -DEFINE_DACVAR(ULONG, DWORD, dac__g_fEEShutDown, ::g_fEEShutDown) -DEFINE_DACVAR(ULONG, DWORD, dac__g_fHostConfig, ::g_fHostConfig) - -DEFINE_DACVAR(ULONG, ULONG, dac__g_CORDebuggerControlFlags, ::g_CORDebuggerControlFlags) -DEFINE_DACVAR(ULONG, UNKNOWN_POINTER_TYPE, dac__g_pDebugger, ::g_pDebugger) -DEFINE_DACVAR(ULONG, UNKNOWN_POINTER_TYPE, dac__g_pDebugInterface, ::g_pDebugInterface) -DEFINE_DACVAR(ULONG, UNKNOWN_POINTER_TYPE, dac__g_pEEDbgInterfaceImpl, ::g_pEEDbgInterfaceImpl) -DEFINE_DACVAR(ULONG, UNKNOWN_POINTER_TYPE, dac__g_pEEInterface, ::g_pEEInterface) -DEFINE_DACVAR(ULONG, ULONG, dac__CLRJitAttachState, ::CLRJitAttachState) - -DEFINE_DACVAR(ULONG, BOOL, Debugger__s_fCanChangeNgenFlags, Debugger::s_fCanChangeNgenFlags) - -DEFINE_DACVAR(ULONG, PTR_DebuggerPatchTable, DebuggerController__g_patches, DebuggerController::g_patches) -DEFINE_DACVAR(ULONG, BOOL, DebuggerController__g_patchTableValid, DebuggerController::g_patchTableValid) - -DEFINE_DACVAR(ULONG, SIZE_T, dac__gLowestFCall, ::gLowestFCall) -DEFINE_DACVAR(ULONG, SIZE_T, dac__gHighestFCall, ::gHighestFCall) -DEFINE_DACVAR(ULONG, SIZE_T, dac__gFCallMethods, ::gFCallMethods) - -DEFINE_DACVAR(ULONG, PTR_SyncTableEntry, dac__g_pSyncTable, ::g_pSyncTable) -#ifdef FEATURE_COMINTEROP -DEFINE_DACVAR(ULONG, UNKNOWN_POINTER_TYPE, dac__g_pRCWCleanupList, ::g_pRCWCleanupList) -DEFINE_DACVAR(ULONG, BOOL, RCWWalker__s_bIsGlobalPeggingOn, RCWWalker::s_bIsGlobalPeggingOn) -#endif // FEATURE_COMINTEROP - -#ifndef FEATURE_PAL -DEFINE_DACVAR(ULONG, SIZE_T, dac__g_runtimeLoadedBaseAddress, ::g_runtimeLoadedBaseAddress) -DEFINE_DACVAR(ULONG, SIZE_T, dac__g_runtimeVirtualSize, ::g_runtimeVirtualSize) -#endif // !FEATURE_PAL - -DEFINE_DACVAR(ULONG, SyncBlockCache *, SyncBlockCache__s_pSyncBlockCache, SyncBlockCache::s_pSyncBlockCache) - -DEFINE_DACVAR(ULONG, UNKNOWN_POINTER_TYPE, dac__g_pStressLog, ::g_pStressLog) - -DEFINE_DACVAR(ULONG, SIZE_T, dac__s_gsCookie, ::s_gsCookie) - -#ifdef FEATURE_IPCMAN -DEFINE_DACVAR(ULONG, UNKNOWN_POINTER_TYPE, dac__g_pIPCManagerInterface, ::g_pIPCManagerInterface) -#endif // FEATURE_IPCMAN - -DEFINE_DACVAR_NO_DUMP(ULONG, SIZE_T, dac__g_FCDynamicallyAssignedImplementations, ::g_FCDynamicallyAssignedImplementations) - -#ifndef FEATURE_PAL -DEFINE_DACVAR(ULONG, HANDLE, dac__g_hContinueStartupEvent, ::g_hContinueStartupEvent) -#endif // !FEATURE_PAL -DEFINE_DACVAR(ULONG, DWORD, CorHost2__m_dwStartupFlags, CorHost2::m_dwStartupFlags) - -DEFINE_DACVAR(ULONG, HRESULT, dac__g_hrFatalError, ::g_hrFatalError) - -#if defined(DEBUGGING_SUPPORTED) && defined (FEATURE_PREJIT) - DEFINE_DACVAR(ULONG, DWORD, PEFile__s_NGENDebugFlags, PEFile::s_NGENDebugFlags) -#endif //defined(DEBUGGING_SUPPORTED) && defined (FEATURE_PREJIT) - -#ifdef FEATURE_MINIMETADATA_IN_TRIAGEDUMPS -DEFINE_DACVAR(ULONG, DWORD, dac__g_MiniMetaDataBuffMaxSize, ::g_MiniMetaDataBuffMaxSize) -DEFINE_DACVAR(ULONG, TADDR, dac__g_MiniMetaDataBuffAddress, ::g_MiniMetaDataBuffAddress) -#endif // FEATURE_MINIMETADATA_IN_TRIAGEDUMPS - -DEFINE_DACVAR(ULONG, SIZE_T, dac__g_clrNotificationArguments, ::g_clrNotificationArguments) - -#undef DEFINE_DACVAR -#undef DEFINE_DACVAR_NO_DUMP diff --git a/src/inc/dbgconfigstrings.h b/src/inc/dbgconfigstrings.h deleted file mode 100644 index acbb7eb0a..000000000 --- a/src/inc/dbgconfigstrings.h +++ /dev/null @@ -1,23 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -// -// This header lists the names of the string resources used by the Windows portion of Mac CoreCLR debugging -// configuration. It's designed to be included multiple times with different definitions of CORECLR_STRING_DEF -// to build either enumerated integer values for each key or a table mapping enum values to key names. -// - -CORECLR_STRING_DEF(CreateFile) -CORECLR_STRING_DEF(WriteFile) -CORECLR_STRING_DEF(CreateDir) -CORECLR_STRING_DEF(InternalError) -CORECLR_STRING_DEF(DecryptFailure) -CORECLR_STRING_DEF(OutOfMemory) -CORECLR_STRING_DEF(Success) -CORECLR_STRING_DEF(DialogTitleMain) -CORECLR_STRING_DEF(DialogTitleInfo) -CORECLR_STRING_DEF(DialogTitleError) -CORECLR_STRING_DEF(OKButton) -CORECLR_STRING_DEF(CancelButton) -CORECLR_STRING_DEF(HeaderText) diff --git a/src/inc/dbgenginemetrics.h b/src/inc/dbgenginemetrics.h deleted file mode 100644 index 174888565..000000000 --- a/src/inc/dbgenginemetrics.h +++ /dev/null @@ -1,30 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -// -// DbgEngineMetrics.h -// -// This file contains the defintion of CLR_ENGINE_METRICS. This struct is used for Silverlight debugging. -// -// ====================================================================================== - - - -#ifndef __DbgEngineMetrics_h__ -#define __DbgEngineMetrics_h__ - -//--------------------------------------------------------------------------------------- -// -// This struct contains information necessary for Silverlight debugging. coreclr.dll has a static struct -// of this type. It is read by dbgshim.dll to help synchronize the debugger and coreclr.dll in launch -// and early attach scenarios. -// - -typedef struct tagCLR_ENGINE_METRICS -{ - DWORD cbSize; // the size of the struct; also identifies the format of the struct - DWORD dwDbiVersion; // the version of the debugging interface expected by this CoreCLR - LPVOID phContinueStartupEvent; // pointer to the continue startup event handle -} CLR_ENGINE_METRICS; - -#endif // __DbgEngineMetrics_h__ diff --git a/src/inc/dbgmeta.h b/src/inc/dbgmeta.h deleted file mode 100644 index ce7a3bbdf..000000000 --- a/src/inc/dbgmeta.h +++ /dev/null @@ -1,38 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/* ------------------------------------------------------------------------- * - * DbgMeta.h - header file for debugger metadata routines - * ------------------------------------------------------------------------- */ - -#ifndef _DbgMeta_h_ -#define _DbgMeta_h_ - -#include - -/* ------------------------------------------------------------------------- * - * Structs to support line numbers and variables - * ------------------------------------------------------------------------- */ - -class DebuggerLexicalScope; - -// -// DebuggerVarInfo -// -// Holds basic information about local variables, method arguments, -// and class static and instance variables. -// -struct DebuggerVarInfo -{ - LPCSTR name; - PCCOR_SIGNATURE sig; - unsigned int varNumber; // placement info for IL code - DebuggerLexicalScope* scope; // containing scope - - DebuggerVarInfo() : name(NULL), sig(NULL), varNumber(0), - scope(NULL) {} -}; - -#endif /* _DbgMeta_h_ */ - diff --git a/src/inc/dbgutil.h b/src/inc/dbgutil.h new file mode 100644 index 000000000..8dae6d32a --- /dev/null +++ b/src/inc/dbgutil.h @@ -0,0 +1,93 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. +//***************************************************************************** +// dbgutil.h +// + +// +//***************************************************************************** + +#pragma once +#include +#include +#include + +// +// Various common helpers used by multiple debug components. +// + +// Returns the RVA of the resource section for the module specified by the given data target and module base. +// Returns failure if the module doesn't have a resource section. +// +// Arguments +// pDataTarget - dataTarget for the process we are inspecting +// moduleBaseAddress - base address of a module we should inspect +// pwImageFileMachine - updated with the Machine from the IMAGE_FILE_HEADER +// pdwResourceSectionRVA - updated with the resultant RVA on success +HRESULT GetMachineAndResourceSectionRVA(ICorDebugDataTarget* pDataTarget, + ULONG64 moduleBaseAddress, + WORD* pwImageFileMachine, + DWORD* pdwResourceSectionRVA); + +HRESULT GetResourceRvaFromResourceSectionRva(ICorDebugDataTarget* pDataTarget, + ULONG64 moduleBaseAddress, + DWORD resourceSectionRva, + DWORD type, + DWORD name, + DWORD language, + DWORD* pResourceRva, + DWORD* pResourceSize); + +HRESULT GetResourceRvaFromResourceSectionRvaByName(ICorDebugDataTarget* pDataTarget, + ULONG64 moduleBaseAddress, + DWORD resourceSectionRva, + DWORD type, + LPCWSTR pwszName, + DWORD language, + DWORD* pResourceRva, + DWORD* pResourceSize); + +// Traverses down one level in the PE resource tree structure +// +// Arguments: +// pDataTarget - the data target for inspecting this process +// id - the id of the next node in the resource tree you want +// moduleBaseAddress - the base address of the module being inspected +// resourceDirectoryRVA - the base address of the beginning of the resource directory for this +// level of the tree +// pNextLevelRVA - out - The RVA for the next level tree directory or the RVA of the resource entry +// +// Returns: +// S_OK if succesful or an appropriate failing HRESULT +HRESULT GetNextLevelResourceEntryRVA(ICorDebugDataTarget* pDataTarget, + DWORD id, + ULONG64 moduleBaseAddress, + DWORD resourceDirectoryRVA, + DWORD* pNextLevelRVA); + +// Traverses down one level in the PE resource tree structure +// +// Arguments: +// pDataTarget - the data target for inspecting this process +// name - the name of the next node in the resource tree you want +// moduleBaseAddress - the base address of the module being inspected +// resourceDirectoryRVA - the base address of the beginning of the resource directory for this +// level of the tree +// resourceSectionRVA - the rva of the beginning of the resource section of the PE file +// pNextLevelRVA - out - The RVA for the next level tree directory or the RVA of the resource entry +// +// Returns: +// S_OK if succesful or an appropriate failing HRESULT +HRESULT GetNextLevelResourceEntryRVAByName(ICorDebugDataTarget* pDataTarget, + LPCWSTR pwzName, + ULONG64 moduleBaseAddress, + DWORD resourceDirectoryRva, + DWORD resourceSectionRva, + DWORD* pNextLevelRva); + +// A small wrapper that reads from the data target and throws on error +HRESULT ReadFromDataTarget(ICorDebugDataTarget* pDataTarget, + ULONG64 addr, + BYTE* pBuffer, + ULONG32 bytesToRead); diff --git a/src/inc/debugreturn.h b/src/inc/debugreturn.h deleted file mode 100644 index e5013ccab..000000000 --- a/src/inc/debugreturn.h +++ /dev/null @@ -1,129 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - - -#ifndef _DEBUGRETURN_H_ -#define _DEBUGRETURN_H_ - -// Note that with OACR Prefast is run over checked (_DEBUG is defined) sources -// so we have to first check the _PREFAST_ define followed by the _DEBUG define -// -#ifdef _PREFAST_ - -// Use prefast to detect gotos out of no-return blocks. The gotos out of no-return blocks -// should be reported as memory leaks by prefast. The (nothrow) is because PREfix sees the -// throw from the new statement, and doesn't like these macros used in a destructor (and -// the NULL returned by failure works just fine in delete[]) - -#define DEBUG_ASSURE_NO_RETURN_BEGIN(arg) { char* __noReturnInThisBlock_##arg = ::new (nothrow) char[1]; -#define DEBUG_ASSURE_NO_RETURN_END(arg) ::delete[] __noReturnInThisBlock_##arg; } - -#define DEBUG_OK_TO_RETURN_BEGIN(arg) { ::delete[] __noReturnInThisBlock_##arg; -#define DEBUG_OK_TO_RETURN_END(arg) __noReturnInThisBlock_##arg = ::new (nothrow) char[1]; } - -#define DEBUG_ASSURE_SAFE_TO_RETURN TRUE -#define return return - -#else // !_PREFAST_ - -// This is disabled in build 190024315 (a pre-release build after VS 2015 Update 3) and -// earlier because those builds only support C++11 constexpr, which doesn't allow the -// use of 'if' statements within the body of a constexpr function. Later builds support -// C++14 constexpr. -#if defined(_DEBUG) && (!defined(_MSC_FULL_VER) || _MSC_FULL_VER > 190024315) - -// Code to generate a compile-time error if return statements appear where they -// shouldn't. -// -// Here's the way it works... -// -// We create two classes with a safe_to_return() method. The method is static, -// returns void, and does nothing. One class has the method as public, the other -// as private. We introduce a global scope typedef for __ReturnOK that refers to -// the class with the public method. So, by default, the expression -// -// __ReturnOK::safe_to_return() -// -// quietly compiles and does nothing. When we enter a block in which we want to -// inhibit returns, we introduce a new typedef that defines __ReturnOK as the -// class with the private method. Inside this scope, -// -// __ReturnOK::safe_to_return() -// -// generates a compile-time error. -// -// To cause the method to be called, we have to #define the return keyword. -// The simplest working version would be -// -// #define return if (0) __ReturnOK::safe_to_return(); else return -// -// but we've used -// -// #define return for (;1;__ReturnOK::safe_to_return()) return -// -// because it happens to generate somewhat faster code in a checked build. (They -// both introduce no overhead in a fastchecked build.) -// -class __SafeToReturn { -public: - static int safe_to_return() {return 0;}; - static int used() {return 0;}; -}; - -class __YouCannotUseAReturnStatementHere { -private: - // If you got here, and you're wondering what you did wrong -- you're using - // a return statement where it's not allowed. Likely, it's inside one of: - // GCPROTECT_BEGIN ... GCPROTECT_END - // HELPER_METHOD_FRAME_BEGIN ... HELPER_METHOD_FRAME_END - // - static int safe_to_return() {return 0;}; -public: - // Some compilers warn if all member functions in a class are private - // or if a typedef is unused. Rather than disable the warning, we'll work - // around it here. - static int used() {return 0;}; -}; - -typedef __SafeToReturn __ReturnOK; - -// Use this to ensure that it is safe to return from a given scope -#define DEBUG_ASSURE_SAFE_TO_RETURN __ReturnOK::safe_to_return() - -// Unfortunately, the only way to make this work is to #define all return statements -- -// even the ones at global scope. This actually generates better code that appears. -// The call is dead, and does not appear in the generated code, even in a checked -// build. (And, in fastchecked, there is no penalty at all.) -// -#ifdef _MSC_VER -#define return if (0 && __ReturnOK::safe_to_return()) { } else return -#else // _MSC_VER -#define return for (;1;__ReturnOK::safe_to_return()) return -#endif // _MSC_VER - -#define DEBUG_ASSURE_NO_RETURN_BEGIN(arg) { typedef __YouCannotUseAReturnStatementHere __ReturnOK; if (0 && __ReturnOK::used()) { } else { -#define DEBUG_ASSURE_NO_RETURN_END(arg) } } - -// rotor_pal.h defaulted these to empty macros; this file redefines them -#undef DEBUG_OK_TO_RETURN_BEGIN -#undef DEBUG_OK_TO_RETURN_END - -#define DEBUG_OK_TO_RETURN_BEGIN(arg) { typedef __SafeToReturn __ReturnOK; if (0 && __ReturnOK::used()) { } else { -#define DEBUG_OK_TO_RETURN_END(arg) } } - -#else // defined(_DEBUG) && (!defined(_MSC_FULL_VER) || _MSC_FULL_VER > 190024315) - -#define DEBUG_ASSURE_SAFE_TO_RETURN TRUE - -#define DEBUG_ASSURE_NO_RETURN_BEGIN(arg) { -#define DEBUG_ASSURE_NO_RETURN_END(arg) } - -#define DEBUG_OK_TO_RETURN_BEGIN(arg) { -#define DEBUG_OK_TO_RETURN_END(arg) } - -#endif // defined(_DEBUG) && (!defined(_MSC_FULL_VER) || _MSC_FULL_VER > 190024315) - -#endif // !_PREFAST_ - -#endif // _DEBUGRETURN_H_ diff --git a/src/inc/declsec.h b/src/inc/declsec.h deleted file mode 100644 index e55916e07..000000000 --- a/src/inc/declsec.h +++ /dev/null @@ -1,255 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/* - * COM+99 Declarative Security Header - * - * HISTORY: Created, 4/15/98 - */ - -#ifndef _DECLSEC_H -#define _DECLSEC_H -// -// PSECURITY_PROPS and PSECURITY_VALUES are opaque types (void*s) defined in cor.h -// so that cor.h does not need to know about these structures. This file relates -// the opaque types in cor.h to concrete types, which are also defined here. -// -// a PSECURITY_PROPS is a pSecurityProperties -// a PSECURITY_VALUE is a pSecurityValue -// - -#include "cor.h" - -// First, some flag values - -#define DECLSEC_DEMANDS 0x00000001 -#define DECLSEC_ASSERTIONS 0x00000002 -#define DECLSEC_DENIALS 0x00000004 -#define DECLSEC_INHERIT_CHECKS 0x00000008 -#define DECLSEC_LINK_CHECKS 0x00000010 -#define DECLSEC_PERMITONLY 0x00000020 -#define DECLSEC_REQUESTS 0x00000040 -#define DECLSEC_UNMNGD_ACCESS_DEMAND 0x00000080 // Used by PInvoke/Interop -#define DECLSEC_NONCAS_DEMANDS 0x00000100 -#define DECLSEC_NONCAS_LINK_DEMANDS 0x00000200 -#define DECLSEC_NONCAS_INHERITANCE 0x00000400 -#define DECLSEC_LINK_CHECKS_HPONLY 0x00000800 // If the DECLSEC_LINK_CHECKS flag is set due to HPA (and not due to any CAS linkdemand), this flag is set - -#define DECLSEC_NULL_OFFSET 16 - -#define DECLSEC_NULL_INHERIT_CHECKS (DECLSEC_INHERIT_CHECKS << DECLSEC_NULL_OFFSET) -#define DECLSEC_NULL_LINK_CHECKS (DECLSEC_LINK_CHECKS << DECLSEC_NULL_OFFSET) - -#define DECLSEC_RUNTIME_ACTIONS (DECLSEC_DEMANDS | \ - DECLSEC_NONCAS_DEMANDS | \ - DECLSEC_ASSERTIONS | \ - DECLSEC_DENIALS | \ - DECLSEC_PERMITONLY | \ - DECLSEC_UNMNGD_ACCESS_DEMAND) - -#define DECLSEC_FRAME_ACTIONS (DECLSEC_ASSERTIONS | \ - DECLSEC_DENIALS | \ - DECLSEC_PERMITONLY) - -#define DECLSEC_OVERRIDES (DECLSEC_DENIALS | \ - DECLSEC_PERMITONLY) - -#define DECLSEC_NON_RUNTIME_ACTIONS (DECLSEC_REQUESTS | \ - DECLSEC_INHERIT_CHECKS | \ - DECLSEC_LINK_CHECKS | \ - DECLSEC_NONCAS_LINK_DEMANDS | \ - DECLSEC_NONCAS_INHERITANCE) - -#define BIT_TST(I,B) ((I) & (B)) -#define BIT_SET(I,B) ((I) |= (B)) -#define BIT_CLR(I,B) ((I) &= (~(B))) - -class LoaderHeap; - -class SecurityProperties -{ -#ifdef DACCESS_COMPILE - friend class NativeImageDumper; -#endif -private: - DWORD dwFlags ; -// PermList plDemands ; - -public: - void *operator new(size_t size, LoaderHeap *pHeap); - void operator delete(void *pMem); - - SecurityProperties () - { - LIMITED_METHOD_CONTRACT; - dwFlags = 0 ; - } - SecurityProperties(DWORD _dwFlags) - { - LIMITED_METHOD_CONTRACT; - dwFlags = _dwFlags; - } - ~SecurityProperties () - { - LIMITED_METHOD_CONTRACT; - dwFlags = 0 ; - } - inline BOOL FDemandsOnly() - { - LIMITED_METHOD_CONTRACT; - return ( (dwFlags & ~(DECLSEC_DEMANDS|DECLSEC_UNMNGD_ACCESS_DEMAND)) == 0); - } - inline BOOL FDeclarationsExist() - { - LIMITED_METHOD_CONTRACT; - return dwFlags; - } - inline BOOL FDemandsExist() - { - LIMITED_METHOD_CONTRACT; - return BIT_TST(dwFlags, DECLSEC_DEMANDS); - } - inline void SetDemandsExist() - { - LIMITED_METHOD_CONTRACT; - BIT_SET(dwFlags, DECLSEC_DEMANDS); - } - inline void ResetDemandsExist() - { - LIMITED_METHOD_CONTRACT; - BIT_CLR(dwFlags, DECLSEC_DEMANDS); - } - - inline BOOL FAssertionsExist() - { - LIMITED_METHOD_CONTRACT; - return BIT_TST(dwFlags, DECLSEC_ASSERTIONS); - } - inline void SetAssertionsExist() - { - LIMITED_METHOD_CONTRACT; - BIT_SET(dwFlags, DECLSEC_ASSERTIONS); - } - inline void ResetAssertionsExist() - { - LIMITED_METHOD_CONTRACT; - BIT_CLR(dwFlags, DECLSEC_ASSERTIONS); - } - - inline BOOL FDenialsExist() - { - LIMITED_METHOD_CONTRACT; - return BIT_TST(dwFlags, DECLSEC_DENIALS); - } - inline void SetDenialsExist() - { - LIMITED_METHOD_CONTRACT; - BIT_SET(dwFlags, DECLSEC_DENIALS); - } - inline void ResetDenialsExist() - { - LIMITED_METHOD_CONTRACT; - BIT_CLR(dwFlags, DECLSEC_DENIALS); - } - - inline BOOL FInherit_ChecksExist() - { - LIMITED_METHOD_CONTRACT; - return BIT_TST(dwFlags, DECLSEC_INHERIT_CHECKS); - } - inline void SetInherit_ChecksExist() - { - LIMITED_METHOD_CONTRACT; - BIT_SET(dwFlags, DECLSEC_INHERIT_CHECKS); - } - inline void ResetInherit_ChecksExist() - { - LIMITED_METHOD_CONTRACT; - BIT_CLR(dwFlags, DECLSEC_INHERIT_CHECKS); - } - - // The class requires an inheritance check only if there are inherit checks and - // they aren't null. - inline BOOL RequiresCasInheritanceCheck () {LIMITED_METHOD_CONTRACT; return (dwFlags & (DECLSEC_INHERIT_CHECKS | DECLSEC_NULL_INHERIT_CHECKS)) - == DECLSEC_INHERIT_CHECKS ;} - - inline BOOL RequiresNonCasInheritanceCheck () {LIMITED_METHOD_CONTRACT; return dwFlags & DECLSEC_NONCAS_INHERITANCE;} - - - inline BOOL RequiresInheritanceCheck () {WRAPPER_NO_CONTRACT; return (RequiresCasInheritanceCheck() || - RequiresNonCasInheritanceCheck()) ;} - - inline BOOL FLink_ChecksExist() - { - LIMITED_METHOD_CONTRACT; - return BIT_TST(dwFlags, DECLSEC_LINK_CHECKS); - } - inline void SetLink_ChecksExist() - { - LIMITED_METHOD_CONTRACT; - BIT_SET(dwFlags, DECLSEC_LINK_CHECKS); - } - inline void ResetLink_ChecksExist() - { - LIMITED_METHOD_CONTRACT; - BIT_CLR(dwFlags, DECLSEC_LINK_CHECKS); - } - - inline BOOL RequiresCasLinktimeCheck () {LIMITED_METHOD_CONTRACT; return (dwFlags & (DECLSEC_LINK_CHECKS | DECLSEC_NULL_LINK_CHECKS)) - == DECLSEC_LINK_CHECKS ;} - - inline BOOL RequiresNonCasLinktimeCheck () {LIMITED_METHOD_CONTRACT; return (dwFlags & DECLSEC_NONCAS_LINK_DEMANDS);} - - - inline BOOL RequiresLinktimeCheck () {WRAPPER_NO_CONTRACT; return RequiresCasLinktimeCheck() || - RequiresNonCasLinktimeCheck();} - inline BOOL RequiresLinkTimeCheckHostProtectionOnly () {LIMITED_METHOD_CONTRACT; return (dwFlags & DECLSEC_LINK_CHECKS_HPONLY);} - - inline BOOL FPermitOnlyExist() - { - LIMITED_METHOD_CONTRACT; - return BIT_TST(dwFlags, DECLSEC_PERMITONLY); - } - inline void SetPermitOnlyExist() - { - LIMITED_METHOD_CONTRACT; - BIT_SET(dwFlags, DECLSEC_PERMITONLY); - } - inline void ResetPermitOnlyExist() - { - LIMITED_METHOD_CONTRACT; - BIT_CLR(dwFlags, DECLSEC_PERMITONLY); - } - - inline void SetFlags(DWORD dw) - { - LIMITED_METHOD_CONTRACT; - dwFlags = dw; - } - - inline void SetFlags(DWORD dw, DWORD dwNull) - { - LIMITED_METHOD_CONTRACT; - - dwFlags = (dw | (dwNull << DECLSEC_NULL_OFFSET)); - } - - inline DWORD GetRuntimeActions() - { - LIMITED_METHOD_CONTRACT; - - return dwFlags & DECLSEC_RUNTIME_ACTIONS; - } - - inline DWORD GetNullRuntimeActions() - { - LIMITED_METHOD_CONTRACT; - - return (dwFlags >> DECLSEC_NULL_OFFSET) & DECLSEC_RUNTIME_ACTIONS; - } -} ; - -typedef SecurityProperties * PSecurityProperties, ** PpSecurityProperties ; - -#endif diff --git a/src/inc/defaultallocator.h b/src/inc/defaultallocator.h deleted file mode 100644 index ee342dff8..000000000 --- a/src/inc/defaultallocator.h +++ /dev/null @@ -1,49 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#ifndef _DEFAULTALLOCATOR_H_ -#define _DEFAULTALLOCATOR_H_ - -// The "DefaultAllocator" class may be used by classes that wish to -// provide the flexibility of using an "IAllocator" may avoid writing -// conditionals at allocation sites about whether a non-default -// "IAllocator" has been provided: if none is, they can simply set the -// allocator to DefaultAllocator::Singleton(). -class DefaultAllocator: public IAllocator -{ - static DefaultAllocator s_singleton; - -public: - void* Alloc(size_t sz) - { - return ::operator new(sz); - } - - void* ArrayAlloc(size_t elemSize, size_t numElems) - { - ClrSafeInt safeElemSize(elemSize); - ClrSafeInt safeNumElems(numElems); - ClrSafeInt sz = safeElemSize * safeNumElems; - if (sz.IsOverflow()) - { - return NULL; - } - else - { - return ::operator new(sz.Value()); - } - } - - virtual void Free(void * p) - { - ::operator delete(p); - } - - static DefaultAllocator* Singleton() - { - return &s_singleton; - } -}; - -#endif // _DEFAULTALLOCATOR_H_ diff --git a/src/inc/delayloadhelpers.h b/src/inc/delayloadhelpers.h deleted file mode 100644 index 2a62a8d95..000000000 --- a/src/inc/delayloadhelpers.h +++ /dev/null @@ -1,113 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -// - -// -// Contains convenience functionality for lazily loading modules -// and getting entrypoints within them. -// - -#ifndef DelayLoadHelpers_h -#define DelayLoadHelpers_h - -#include "volatile.h" - -namespace DelayLoad -{ - //================================================================================================================= - // Contains information needed to load and cache a module. Use through - // the DELAY_LOADED_MODULE macro defined below. - struct Module - { - LPCWSTR const m_wzDllName; - HMODULE m_hMod; - HRESULT m_hr; - Volatile m_fInitialized; - - // Returns a non-ref-counted HMODULE; will load the module if necessary. - // Do not FreeLibrary the returned value. - HRESULT GetValue(HMODULE *pHMODULE); - }; -} - -//===================================================================================================================== -// Use at global scope to declare a delay loaded module represented as a -// DelayLoad::Module instance. The module may then be accessed as -// 'DelayLoad::Modules::DLL_NAME'. -// -// Parameters: -// DLL_NAME - the simple name (without extension) of the DLL. -// -// Example: -// DELAY_LOADED_MODULE(Kernel32); -// void Foo() { -// HMODULE hModKernel32 = nullptr; -// IfFailThrow(DelayLoad::Modules::Kernel32.GetValue(&hModKernel32)); -// // Use hModKernel32 as needed. Do not FreeLibrary the value! -// } - -#define DELAY_LOADED_MODULE(DLL_NAME) \ - namespace DelayLoad { \ - namespace Modules { \ - SELECTANY Module DLL_NAME = { L#DLL_NAME W(".dll"), nullptr, S_OK, false }; \ - } \ - } - -namespace DelayLoad -{ - //================================================================================================================= - // Contains information needed to load a function pointer from a DLL. Builds - // on the DelayLoad::Module functionality, and should be used through - // the DELAY_LOADED_FUNCTION macro defined below. - struct Function - { - Module * const m_pModule; - LPCSTR const m_szFunctionName; - PVOID m_pvFunction; - HRESULT m_hr; - Volatile m_fInitialized; - - // On success, ppvFunc is set to point to the entrypoint corresponding to - // m_szFunctionName as exported from m_pModule. - HRESULT GetValue(LPVOID * ppvFunc); - - // Convenience function that does the necessary casting for you. - template inline - HRESULT GetValue(FnT ** ppFunc) - { - return GetValue(reinterpret_cast(ppFunc)); - } - }; -} - -//===================================================================================================================== -// Use at global scope to declare a delay loaded function and its associated module, -// represented as DelayLoad::Function and DelayLoad::Module instances, respectively. -// The function may then be accessed as 'DelayLoad::DLL_NAME::FUNC_NAME', and the -// module may be access as described in DELAY_LOADED_MODULE's comment. -// -// Parameters: -// DLL_NAME - unquoted simple name (without extension) of the DLL containing -// the function. -// FUNC_NAME - unquoted entrypoint name exported from the DLL. -// -// Example: -// DELAY_LOADED_FUNCTION(MyDll, MyFunction); -// HRESULT Foo(...) { -// typedef HRESULT MyFunction_t(); -// MyFunction_t * pFunc = nullptr; -// IfFailRet(DelayLoad::WinTypes::RoResolveNamespace.GetValue(&pFunc)); -// return (*pFunc)(...); -// } - -#define DELAY_LOADED_FUNCTION(DLL_NAME, FUNC_NAME) \ - DELAY_LOADED_MODULE(DLL_NAME) \ - namespace DelayLoad { \ - namespace DLL_NAME { \ - SELECTANY Function FUNC_NAME = { &Modules::##DLL_NAME, #FUNC_NAME, nullptr, S_OK, false }; \ - } \ - } - -#endif // DelayLoadHelpers_h - diff --git a/src/inc/dlwrap.h b/src/inc/dlwrap.h deleted file mode 100644 index 853bc58d7..000000000 --- a/src/inc/dlwrap.h +++ /dev/null @@ -1,205 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - - -// - -#ifndef _DLWRAP_H -#define _DLWRAP_H - -//include this file if you get contract violation because of delayload - -//nothrow implementations - -#if defined(VER_H) && !defined (GetFileVersionInfoSizeW_NoThrow) -DWORD -GetFileVersionInfoSizeW_NoThrow( - LPCWSTR lptstrFilename, /* Filename of version stamped file */ - LPDWORD lpdwHandle - ); -#endif - -#if defined(VER_H) && !defined (GetFileVersionInfoW_NoThrow) -BOOL -GetFileVersionInfoW_NoThrow( - LPCWSTR lptstrFilename, /* Filename of version stamped file */ - DWORD dwHandle, /* Information from GetFileVersionSize */ - DWORD dwLen, /* Length of buffer for info */ - LPVOID lpData - ); -#endif - -#if defined(VER_H) && !defined (VerQueryValueW_NoThrow) -BOOL -VerQueryValueW_NoThrow( - const LPVOID pBlock, - LPCWSTR lpSubBlock, - LPVOID * lplpBuffer, - PUINT puLen - ); -#endif - -#if defined(_WININET_) && !defined (CreateUrlCacheEntryW_NoThrow) -__success(return) -BOOL -CreateUrlCacheEntryW_NoThrow( - IN LPCWSTR lpszUrlName, - IN DWORD dwExpectedFileSize, - IN LPCWSTR lpszFileExtension, - __out_ecount(MAX_LONGPATH+1) LPWSTR lpszFileName, - IN DWORD dwReserved - ); -#endif - -#if defined(_WININET_) && !defined (CommitUrlCacheEntryW_NoThrow) -BOOL -CommitUrlCacheEntryW_NoThrow( - IN LPCWSTR lpszUrlName, - IN LPCWSTR lpszLocalFileName, - IN FILETIME ExpireTime, - IN FILETIME LastModifiedTime, - IN DWORD CacheEntryType, - IN LPCWSTR lpHeaderInfo, - IN DWORD dwHeaderSize, - IN LPCWSTR lpszFileExtension, - IN LPCWSTR lpszOriginalUrl - ); -#endif - -#if defined(_WININET_) && !defined (InternetTimeToSystemTimeA_NoThrow) -BOOL -InternetTimeToSystemTimeA_NoThrow( - IN LPCSTR lpszTime, // NULL terminated string - OUT SYSTEMTIME *pst, // output in GMT time - IN DWORD dwReserved - ); -#endif - -#if defined(__urlmon_h__) && !defined(CoInternetCreateSecurityManager_NoThrow) -HRESULT -CoInternetCreateSecurityManager_NoThrow( - IServiceProvider *pSP, - IInternetSecurityManager **ppSM, - DWORD dwReserved - ); -#endif - -#if defined(__urlmon_h__) && !defined(URLDownloadToCacheFileW_NoThrow) -HRESULT -URLDownloadToCacheFileW_NoThrow( - LPUNKNOWN lpUnkcaller, - LPCWSTR szURL, - __out_ecount(dwBufLength) LPWSTR szFileName, - DWORD dwBufLength, - DWORD dwReserved, - IBindStatusCallback *pBSC - ); -#endif - -#if defined(__urlmon_h__) && !defined(CoInternetGetSession_NoThrow) -HRESULT -CoInternetGetSession_NoThrow( - WORD dwSessionMode, - IInternetSession **ppIInternetSession, - DWORD dwReserved - ); -#endif - -#if defined(__urlmon_h__) && !defined(CopyBindInfo_NoThrow) -HRESULT -CopyBindInfo_NoThrow( - const BINDINFO * pcbiSrc, BINDINFO * pbiDest - ); -#endif - - - -//overrides -#undef InternetTimeToSystemTimeA -#undef CommitUrlCacheEntryW -#undef HttpQueryInfoA -#undef InternetCloseHandle -#undef HttpSendRequestA -#undef HttpOpenRequestA -#undef InternetConnectA -#undef InternetOpenA -#undef InternetReadFile -#undef CreateUrlCacheEntryW -#undef CoInternetGetSession -#undef CopyBindInfo -#undef CoInternetCreateSecurityManager -#undef URLDownloadToCacheFileW -#undef FDICreate -#undef FDIIsCabinet -#undef FDICopy -#undef FDIDestroy -#undef VerQueryValueW -#undef GetFileVersionInfoW -#undef GetFileVersionInfoSizeW -#undef VerQueryValueA -#undef GetFileVersionInfoA -#undef GetFileVersionInfoSizeA - - -#define InternetTimeToSystemTimeA InternetTimeToSystemTimeA_NoThrow -#define CommitUrlCacheEntryW CommitUrlCacheEntryW_NoThrow -#define CreateUrlCacheEntryW CreateUrlCacheEntryW_NoThrow -#define CoInternetGetSession CoInternetGetSession_NoThrow -#define CopyBindInfo CopyBindInfo_NoThrow -#define CoInternetCreateSecurityManager CoInternetCreateSecurityManager_NoThrow -#define URLDownloadToCacheFileW URLDownloadToCacheFileW_NoThrow -#define VerQueryValueW VerQueryValueW_NoThrow -#define GetFileVersionInfoW GetFileVersionInfoW_NoThrow -#define GetFileVersionInfoSizeW GetFileVersionInfoSizeW_NoThrow -#define VerQueryValueA Use_VerQueryValueW -#define GetFileVersionInfoA Use_GetFileVersionInfoW -#define GetFileVersionInfoSizeA Use_GetFileVersionInfoSizeW - -#if defined(_WININET_) - inline - HRESULT HrCreateUrlCacheEntryW( - IN LPCWSTR lpszUrlName, - IN DWORD dwExpectedFileSize, - IN LPCWSTR lpszFileExtension, - __out_ecount(MAX_LONGPATH+1) LPWSTR lpszFileName, - IN DWORD dwReserved - ) - { - if (!CreateUrlCacheEntryW(lpszUrlName, dwExpectedFileSize, lpszFileExtension, lpszFileName, dwReserved)) - { - return HRESULT_FROM_WIN32(GetLastError()); - } - else - { - return S_OK; - } - } - - inline - HRESULT HrCommitUrlCacheEntryW( - IN LPCWSTR lpszUrlName, - IN LPCWSTR lpszLocalFileName, - IN FILETIME ExpireTime, - IN FILETIME LastModifiedTime, - IN DWORD CacheEntryType, - IN LPCWSTR lpHeaderInfo, - IN DWORD dwHeaderSize, - IN LPCWSTR lpszFileExtension, - IN LPCWSTR lpszOriginalUrl - ) - { - if (!CommitUrlCacheEntryW(lpszUrlName, lpszLocalFileName, ExpireTime, LastModifiedTime, CacheEntryType, - lpHeaderInfo, dwHeaderSize, lpszFileExtension, lpszOriginalUrl)) - { - return HRESULT_FROM_WIN32(GetLastError()); - } - else - { - return S_OK; - } - } -#endif // defined(_WININET_) - -#endif - diff --git a/src/inc/eetwain.h b/src/inc/eetwain.h deleted file mode 100644 index 9597e30e4..000000000 --- a/src/inc/eetwain.h +++ /dev/null @@ -1,799 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -//***************************************************************************** -// -// EETwain.h -// -// This file has the definition of ICodeManager and EECodeManager. -// -// ICorJitCompiler compiles the IL of a method to native code, and stores -// auxilliary data called as GCInfo (via ICorJitInfo::allocGCInfo()). -// The data is used by the EE to manage the method's garbage collection, -// exception handling, stack-walking etc. -// This data can be parsed by an ICodeManager corresponding to that -// ICorJitCompiler. -// -// EECodeManager is an implementation of ICodeManager for a default format -// of GCInfo. Various ICorJitCompiler's are free to share this format so that -// they do not need to provide their own implementation of ICodeManager -// (though they are permitted to, if they want). -// -//***************************************************************************** - -#ifndef _EETWAIN_H -#define _EETWAIN_H -//***************************************************************************** - -#include -#include "regdisp.h" -#include "corjit.h" // For NativeVarInfo -#include "stackwalktypes.h" -#include "bitvector.h" -#include "gcinfotypes.h" - -#if !defined(_TARGET_X86_) -#define USE_GC_INFO_DECODER -#endif - -#if (defined(_TARGET_X86_) && !defined(FEATURE_PAL)) || defined(_TARGET_AMD64_) -#define HAS_QUICKUNWIND -#endif - -#define CHECK_APP_DOMAIN 0 - -#define NO_OVERRIDE_OFFSET (DWORD)-1 - -struct EHContext; - -#ifdef DACCESS_COMPILE -typedef struct _DAC_SLOT_LOCATION -{ - int reg; - int regOffset; - bool targetPtr; - - _DAC_SLOT_LOCATION(int _reg, int _regOffset, bool _targetPtr) - : reg(_reg), regOffset(_regOffset), targetPtr(_targetPtr) - { - } -} DacSlotLocation; -#endif - -typedef void (*GCEnumCallback)( - LPVOID hCallback, // callback data - OBJECTREF* pObject, // address of obect-reference we are reporting - uint32_t flags // is this a pinned and/or interior pointer - DAC_ARG(DacSlotLocation loc) // where the reference came from -); - -/****************************************************************************** - The stackwalker maintains some state on behalf of ICodeManager. -*/ - -const int CODEMAN_STATE_SIZE = 512; - -struct CodeManState -{ - DWORD dwIsSet; // Is set to 0 by the stackwalk as appropriate - BYTE stateBuf[CODEMAN_STATE_SIZE]; -}; - -/****************************************************************************** - These flags are used by some functions, although not all combinations might - make sense for all functions. -*/ - -enum ICodeManagerFlags -{ - ActiveStackFrame = 0x0001, // this is the currently active function - ExecutionAborted = 0x0002, // execution of this function has been aborted - // (i.e. it will not continue execution at the - // current location) - AbortingCall = 0x0004, // The current call will never return - UpdateAllRegs = 0x0008, // update full register set - CodeAltered = 0x0010, // code of that function might be altered - // (e.g. by debugger), need to call EE - // for original code - SpeculativeStackwalk - = 0x0020, // we're in the middle of a stackwalk seeded - // by an untrusted source (e.g., sampling profiler) - - ParentOfFuncletStackFrame - = 0x0040, // A funclet for this frame was previously reported - NoReportUntracked - = 0x0080, // EnumGCRefs/EnumerateLiveSlots should *not* include - // any untracked slots -}; - -//***************************************************************************** -// -// EECodeInfo is used by ICodeManager to get information about the -// method whose GCInfo is being processed. -// It is useful so that some information which is available elsewhere does -// not need to be cached in the GCInfo. -// - -class EECodeInfo; - -enum GenericParamContextType -{ - GENERIC_PARAM_CONTEXT_NONE = 0, - GENERIC_PARAM_CONTEXT_THIS = 1, - GENERIC_PARAM_CONTEXT_METHODDESC = 2, - GENERIC_PARAM_CONTEXT_METHODTABLE = 3 -}; - -//***************************************************************************** -// -// ICodeManager is the abstract class that all CodeManagers -// must inherit from. This will probably need to move into -// cor.h and become a real com interface. -// -//***************************************************************************** - -class ICodeManager -{ - VPTR_BASE_VTABLE_CLASS_AND_CTOR(ICodeManager) - -public: - -/* - Last chance for the runtime support to do fixups in the context - before execution continues inside a filter, catch handler, or fault/finally -*/ - -enum ContextType -{ - FILTER_CONTEXT, - CATCH_CONTEXT, - FINALLY_CONTEXT -}; - -/* Type of funclet corresponding to a shadow stack-pointer */ - -enum -{ - SHADOW_SP_IN_FILTER = 0x1, - SHADOW_SP_FILTER_DONE = 0x2, - SHADOW_SP_BITS = 0x3 -}; - -#ifndef DACCESS_COMPILE -#ifndef WIN64EXCEPTIONS -virtual void FixContext(ContextType ctxType, - EHContext *ctx, - EECodeInfo *pCodeInfo, - DWORD dwRelOffset, - DWORD nestingLevel, - OBJECTREF thrownObject, - CodeManState *pState, - size_t ** ppShadowSP, // OUT - size_t ** ppEndRegion) = 0; // OUT -#endif // !WIN64EXCEPTIONS -#endif // #ifndef DACCESS_COMPILE - -#ifdef _TARGET_X86_ -/* - Gets the ambient stack pointer value at the given nesting level within - the method. -*/ -virtual TADDR GetAmbientSP(PREGDISPLAY pContext, - EECodeInfo *pCodeInfo, - DWORD dwRelOffset, - DWORD nestingLevel, - CodeManState *pState) = 0; -#endif // _TARGET_X86_ - -/* - Get the number of bytes used for stack parameters. - This is currently only used on x86. -*/ -virtual ULONG32 GetStackParameterSize(EECodeInfo* pCodeInfo) = 0; - -#ifndef CROSSGEN_COMPILE -/* - Unwind the current stack frame, i.e. update the virtual register - set in pContext. This will be similar to the state after the function - returns back to caller (IP points to after the call, Frame and Stack - pointer has been reset, callee-saved registers restored - (if UpdateAllRegs), callee-UNsaved registers are trashed) - Returns success of operation. -*/ -virtual bool UnwindStackFrame(PREGDISPLAY pContext, - EECodeInfo *pCodeInfo, - unsigned flags, - CodeManState *pState, - StackwalkCacheUnwindInfo *pUnwindInfo) = 0; -#endif // CROSSGEN_COMPILE - -/* - Is the function currently at a "GC safe point" ? - Can call EnumGcRefs() successfully -*/ -virtual bool IsGcSafe(EECodeInfo *pCodeInfo, - DWORD dwRelOffset) = 0; - -#if defined(_TARGET_ARM_) || defined(_TARGET_ARM64_) -virtual bool HasTailCalls(EECodeInfo *pCodeInfo) = 0; -#endif // _TARGET_ARM_ || _TARGET_ARM64_ - -#if defined(_TARGET_AMD64_) && defined(_DEBUG) -/* - Locates the end of the last interruptible region in the given code range. - Returns 0 if the entire range is uninterruptible. Returns the end point - if the entire range is interruptible. -*/ -virtual unsigned FindEndOfLastInterruptibleRegion(unsigned curOffset, - unsigned endOffset, - GCInfoToken gcInfoToken) = 0; -#endif // _TARGET_AMD64_ && _DEBUG - -#ifndef CROSSGEN_COMPILE -/* - Enumerate all live object references in that function using - the virtual register set. Same reference location cannot be enumerated - multiple times (but all differenct references pointing to the same - object have to be individually enumerated). - Returns success of operation. -*/ -virtual bool EnumGcRefs(PREGDISPLAY pContext, - EECodeInfo *pCodeInfo, - unsigned flags, - GCEnumCallback pCallback, - LPVOID hCallBack, - DWORD relOffsetOverride = NO_OVERRIDE_OFFSET) = 0; -#endif // !CROSSGEN_COMPILE - -#if !defined(DACCESS_COMPILE) && !defined(CROSSGEN_COMPILE) -/* - Return the address of the local security object reference - (if available). -*/ -virtual OBJECTREF* GetAddrOfSecurityObject(CrawlFrame *pCF) = 0; -#endif // !DACCESS_COMPILE && !CROSSGEN_COMPILE - -#ifndef CROSSGEN_COMPILE -/* - For a non-static method, "this" pointer is passed in as argument 0. - However, if there is a "ldarga 0" or "starg 0" in the IL, - JIT will create a copy of arg0 and redirect all "ldarg(a) 0" and "starg 0" to this copy. - (See Compiler::lvaArg0Var for more details.) - - The following method returns the original "this" argument, i.e. the one that is passed in, - if it is a non-static method AND the object is still alive. - Returns NULL in all other cases. -*/ -virtual OBJECTREF GetInstance(PREGDISPLAY pContext, - EECodeInfo* pCodeInfo) = 0; -#endif // !CROSSGEN_COMPILE - -#ifndef CROSSGEN_COMPILE -/* - Returns the extra argument passed to to shared generic code if it is still alive. - Returns NULL in all other cases. -*/ -virtual PTR_VOID GetParamTypeArg(PREGDISPLAY pContext, - EECodeInfo * pCodeInfo) = 0; -#endif // !CROSSGEN_COMPILE - -// Returns the type of the context parameter (this, methodtable, methoddesc, or none) -virtual GenericParamContextType GetParamContextType(PREGDISPLAY pContext, - EECodeInfo * pCodeInfo) = 0; - -#ifndef CROSSGEN_COMPILE -/* - Returns the offset of the GuardStack cookie if it exists. - Returns NULL if there is no cookie. -*/ -virtual void * GetGSCookieAddr(PREGDISPLAY pContext, - EECodeInfo * pCodeInfo, - CodeManState * pState) = 0; -#endif - -#ifndef USE_GC_INFO_DECODER -/* - Returns true if the given IP is in the given method's prolog or an epilog. -*/ -virtual bool IsInPrologOrEpilog(DWORD relPCOffset, - GCInfoToken gcInfoToken, - size_t* prologSize) = 0; - -/* - Returns true if the given IP is in the synchronized region of the method (valid for synchronized methods only) -*/ -virtual bool IsInSynchronizedRegion( - DWORD relOffset, - GCInfoToken gcInfoToken, - unsigned flags) = 0; -#endif // !USE_GC_INFO_DECODER - -/* - Returns the size of a given function as reported in the GC info (does - not take procedure splitting into account). For the actual size of - the hot region call IJitManager::JitTokenToMethodHotSize. -*/ -virtual size_t GetFunctionSize(GCInfoToken gcInfoToken) = 0; - -/* -Returns the ReturnKind of a given function as reported in the GC info. -*/ - -virtual ReturnKind GetReturnKind(GCInfoToken gcInfotoken) = 0; - -#ifndef USE_GC_INFO_DECODER -/* - Returns the size of the frame (barring localloc) -*/ -virtual unsigned int GetFrameSize(GCInfoToken gcInfoToken) = 0; -#endif // USE_GC_INFO_DECODER - -#ifndef DACCESS_COMPILE - -/* Debugger API */ - -#ifndef WIN64EXCEPTIONS -virtual const BYTE* GetFinallyReturnAddr(PREGDISPLAY pReg)=0; - -virtual BOOL IsInFilter(GCInfoToken gcInfoToken, - unsigned offset, - PCONTEXT pCtx, - DWORD curNestLevel) = 0; - -virtual BOOL LeaveFinally(GCInfoToken gcInfoToken, - unsigned offset, - PCONTEXT pCtx) = 0; - -virtual void LeaveCatch(GCInfoToken gcInfoToken, - unsigned offset, - PCONTEXT pCtx)=0; -#endif // WIN64EXCEPTIONS - -#ifdef EnC_SUPPORTED - -/* - Last chance for the runtime support to do fixups in the context - before execution continues inside an EnC updated function. -*/ - -virtual HRESULT FixContextForEnC(PCONTEXT pCtx, - EECodeInfo * pOldCodeInfo, - const ICorDebugInfo::NativeVarInfo * oldMethodVars, - SIZE_T oldMethodVarsCount, - EECodeInfo * pNewCodeInfo, - const ICorDebugInfo::NativeVarInfo * newMethodVars, - SIZE_T newMethodVarsCount) = 0; - -#endif // EnC_SUPPORTED - -#endif // #ifndef DACCESS_COMPILE - - -#ifdef DACCESS_COMPILE - virtual void EnumMemoryRegions(CLRDataEnumMemoryFlags flags) = 0; -#endif -}; - -//***************************************************************************** -// -// EECodeManager is the EE's implementation of the ICodeManager which -// supports the default format of GCInfo. -// -//***************************************************************************** - -struct hdrInfo; - -class EECodeManager : public ICodeManager { - - VPTR_VTABLE_CLASS_AND_CTOR(EECodeManager, ICodeManager) - -public: - - -#ifndef DACCESS_COMPILE -#ifndef WIN64EXCEPTIONS -/* - Last chance for the runtime support to do fixups in the context - before execution continues inside a filter, catch handler, or finally -*/ -virtual -void FixContext(ContextType ctxType, - EHContext *ctx, - EECodeInfo *pCodeInfo, - DWORD dwRelOffset, - DWORD nestingLevel, - OBJECTREF thrownObject, - CodeManState *pState, - size_t ** ppShadowSP, // OUT - size_t ** ppEndRegion); // OUT -#endif // !WIN64EXCEPTIONS -#endif // #ifndef DACCESS_COMPILE - -#ifdef _TARGET_X86_ -/* - Gets the ambient stack pointer value at the given nesting level within - the method. -*/ -virtual -TADDR GetAmbientSP(PREGDISPLAY pContext, - EECodeInfo *pCodeInfo, - DWORD dwRelOffset, - DWORD nestingLevel, - CodeManState *pState); -#endif // _TARGET_X86_ - -/* - Get the number of bytes used for stack parameters. - This is currently only used on x86. -*/ -virtual -ULONG32 GetStackParameterSize(EECodeInfo* pCodeInfo); - -#ifndef CROSSGEN_COMPILE -/* - Unwind the current stack frame, i.e. update the virtual register - set in pContext. This will be similar to the state after the function - returns back to caller (IP points to after the call, Frame and Stack - pointer has been reset, callee-saved registers restored - (if UpdateAllRegs), callee-UNsaved registers are trashed) - Returns success of operation. -*/ -virtual -bool UnwindStackFrame( - PREGDISPLAY pContext, - EECodeInfo *pCodeInfo, - unsigned flags, - CodeManState *pState, - StackwalkCacheUnwindInfo *pUnwindInfo); -#endif // CROSSGEN_COMPILE - -#ifdef HAS_QUICKUNWIND -enum QuickUnwindFlag -{ - UnwindCurrentStackFrame, - EnsureCallerStackFrameIsValid -}; - -/* - * Light unwind the current stack frame, using provided cache entry. - * only pPC and Esp of pContext are updated. And pEbp if necessary. - */ - -static -void QuickUnwindStackFrame( - PREGDISPLAY pRD, - StackwalkCacheEntry *pCacheEntry, - QuickUnwindFlag flag); -#endif // HAS_QUICKUNWIND - -/* - Is the function currently at a "GC safe point" ? - Can call EnumGcRefs() successfully -*/ -virtual -bool IsGcSafe( EECodeInfo *pCodeInfo, - DWORD dwRelOffset); - -#if defined(_TARGET_ARM_) || defined(_TARGET_ARM64_) -virtual -bool HasTailCalls(EECodeInfo *pCodeInfo); -#endif // _TARGET_ARM_ || _TARGET_ARM64_ - -#if defined(_TARGET_AMD64_) && defined(_DEBUG) -/* - Locates the end of the last interruptible region in the given code range. - Returns 0 if the entire range is uninterruptible. Returns the end point - if the entire range is interruptible. -*/ -virtual -unsigned FindEndOfLastInterruptibleRegion(unsigned curOffset, - unsigned endOffset, - GCInfoToken gcInfoToken); -#endif // _TARGET_AMD64_ && _DEBUG - -#ifndef CROSSGEN_COMPILE -/* - Enumerate all live object references in that function using - the virtual register set. Same reference location cannot be enumerated - multiple times (but all differenct references pointing to the same - object have to be individually enumerated). - Returns success of operation. -*/ -virtual -bool EnumGcRefs(PREGDISPLAY pContext, - EECodeInfo *pCodeInfo, - unsigned flags, - GCEnumCallback pCallback, - LPVOID hCallBack, - DWORD relOffsetOverride = NO_OVERRIDE_OFFSET); -#endif // !CROSSGEN_COMPILE - -#ifdef FEATURE_CONSERVATIVE_GC -// Temporary conservative collection, for testing purposes, until we have -// accurate gc info from the JIT. -bool EnumGcRefsConservative(PREGDISPLAY pRD, - EECodeInfo *pCodeInfo, - unsigned flags, - GCEnumCallback pCallBack, - LPVOID hCallBack); -#endif // FEATURE_CONSERVATIVE_GC - -#ifdef _TARGET_X86_ -/* - Return the address of the local security object reference - using data that was previously cached before in UnwindStackFrame - using StackwalkCacheUnwindInfo -*/ -static OBJECTREF* GetAddrOfSecurityObjectFromCachedInfo( - PREGDISPLAY pRD, - StackwalkCacheUnwindInfo * stackwalkCacheUnwindInfo); -#endif // _TARGET_X86_ - -#if !defined(DACCESS_COMPILE) && !defined(CROSSGEN_COMPILE) -virtual -OBJECTREF* GetAddrOfSecurityObject(CrawlFrame *pCF) DAC_UNEXPECTED(); -#endif // !DACCESS_COMPILE && !CROSSGEN_COMPILE - -#ifndef CROSSGEN_COMPILE -virtual -OBJECTREF GetInstance( - PREGDISPLAY pContext, - EECodeInfo * pCodeInfo); -#endif // !CROSSGEN_COMPILE - -#ifndef CROSSGEN_COMPILE -/* - Returns the extra argument passed to to shared generic code if it is still alive. - Returns NULL in all other cases. -*/ -virtual -PTR_VOID GetParamTypeArg(PREGDISPLAY pContext, - EECodeInfo * pCodeInfo); -#endif // !CROSSGEN_COMPILE - -// Returns the type of the context parameter (this, methodtable, methoddesc, or none) -virtual GenericParamContextType GetParamContextType(PREGDISPLAY pContext, - EECodeInfo * pCodeInfo); - -#if defined(WIN64EXCEPTIONS) && defined(USE_GC_INFO_DECODER) && !defined(CROSSGEN_COMPILE) -/* - Returns the generics token. This is used by GetInstance() and GetParamTypeArg() on WIN64. -*/ -static -PTR_VOID GetExactGenericsToken(PREGDISPLAY pContext, - EECodeInfo * pCodeInfo); - -static -PTR_VOID GetExactGenericsToken(SIZE_T baseStackSlot, - EECodeInfo * pCodeInfo); - - -#endif // WIN64EXCEPTIONS && USE_GC_INFO_DECODER && !CROSSGEN_COMPILE - -#ifndef CROSSGEN_COMPILE -/* - Returns the offset of the GuardStack cookie if it exists. - Returns NULL if there is no cookie. -*/ -virtual -void * GetGSCookieAddr(PREGDISPLAY pContext, - EECodeInfo * pCodeInfo, - CodeManState * pState); -#endif - - -#ifndef USE_GC_INFO_DECODER -/* - Returns true if the given IP is in the given method's prolog or an epilog. -*/ -virtual -bool IsInPrologOrEpilog( - DWORD relOffset, - GCInfoToken gcInfoToken, - size_t* prologSize); - -/* - Returns true if the given IP is in the synchronized region of the method (valid for synchronized functions only) -*/ -virtual -bool IsInSynchronizedRegion( - DWORD relOffset, - GCInfoToken gcInfoToken, - unsigned flags); -#endif // !USE_GC_INFO_DECODER - -/* - Returns the size of a given function. -*/ -virtual -size_t GetFunctionSize(GCInfoToken gcInfoToken); - -/* -Returns the ReturnKind of a given function. -*/ -virtual ReturnKind GetReturnKind(GCInfoToken gcInfotoken); - -#ifndef USE_GC_INFO_DECODER -/* - Returns the size of the frame (barring localloc) -*/ -virtual -unsigned int GetFrameSize(GCInfoToken gcInfoToken); -#endif // USE_GC_INFO_DECODER - -#ifndef DACCESS_COMPILE - -#ifndef WIN64EXCEPTIONS -virtual const BYTE* GetFinallyReturnAddr(PREGDISPLAY pReg); -virtual BOOL IsInFilter(GCInfoToken gcInfoToken, - unsigned offset, - PCONTEXT pCtx, - DWORD curNestLevel); -virtual BOOL LeaveFinally(GCInfoToken gcInfoToken, - unsigned offset, - PCONTEXT pCtx); -virtual void LeaveCatch(GCInfoToken gcInfoToken, - unsigned offset, - PCONTEXT pCtx); -#endif // WIN64EXCEPTIONS - -#ifdef EnC_SUPPORTED -/* - Last chance for the runtime support to do fixups in the context - before execution continues inside an EnC updated function. -*/ -virtual -HRESULT FixContextForEnC(PCONTEXT pCtx, - EECodeInfo * pOldCodeInfo, - const ICorDebugInfo::NativeVarInfo * oldMethodVars, - SIZE_T oldMethodVarsCount, - EECodeInfo * pNewCodeInfo, - const ICorDebugInfo::NativeVarInfo * newMethodVars, - SIZE_T newMethodVarsCount); -#endif // EnC_SUPPORTED - -#endif // #ifndef DACCESS_COMPILE - -#ifdef WIN64EXCEPTIONS - static void EnsureCallerContextIsValid( PREGDISPLAY pRD, StackwalkCacheEntry* pCacheEntry, EECodeInfo * pCodeInfo = NULL ); - static size_t GetCallerSp( PREGDISPLAY pRD ); -#ifdef _TARGET_X86_ - static size_t GetResumeSp( PCONTEXT pContext ); -#endif // _TARGET_X86_ -#endif // WIN64EXCEPTIONS - -#ifdef DACCESS_COMPILE - virtual void EnumMemoryRegions(CLRDataEnumMemoryFlags flags); -#endif - -}; - -#ifdef _TARGET_X86_ -bool UnwindStackFrame(PREGDISPLAY pContext, - EECodeInfo *pCodeInfo, - unsigned flags, - CodeManState *pState, - StackwalkCacheUnwindInfo *pUnwindInfo); -#endif - -/***************************************************************************** - ToDo: Do we want to include JIT/IL/target.h? - */ - -enum regNum -{ - REGI_EAX, REGI_ECX, REGI_EDX, REGI_EBX, - REGI_ESP, REGI_EBP, REGI_ESI, REGI_EDI, - REGI_COUNT, - REGI_NA = REGI_COUNT -}; - -/***************************************************************************** - Register masks - */ - -enum RegMask -{ - RM_EAX = 0x01, - RM_ECX = 0x02, - RM_EDX = 0x04, - RM_EBX = 0x08, - RM_ESP = 0x10, - RM_EBP = 0x20, - RM_ESI = 0x40, - RM_EDI = 0x80, - - RM_NONE = 0x00, - RM_ALL = (RM_EAX|RM_ECX|RM_EDX|RM_EBX|RM_ESP|RM_EBP|RM_ESI|RM_EDI), - RM_CALLEE_SAVED = (RM_EBP|RM_EBX|RM_ESI|RM_EDI), - RM_CALLEE_TRASHED = (RM_ALL & ~RM_CALLEE_SAVED), -}; - -/***************************************************************************** - * - * Helper to extract basic info from a method info block. - */ - -struct hdrInfo -{ - unsigned int methodSize; // native code bytes - unsigned int argSize; // in bytes - unsigned int stackSize; // including callee saved registers - unsigned int rawStkSize; // excluding callee saved registers - ReturnKind returnKind; // The ReturnKind for this method. - - unsigned int prologSize; - - // Size of the epilogs in the method. - // For methods which use CEE_JMP, some epilogs may end with a "ret" instruction - // and some may end with a "jmp". The epilogSize reported should be for the - // epilog with the smallest size. - unsigned int epilogSize; - - unsigned char epilogCnt; - bool epilogEnd; // is the epilog at the end of the method - - bool ebpFrame; // locals and arguments addressed relative to EBP - bool doubleAlign; // is the stack double-aligned? locals addressed relative to ESP, and arguments relative to EBP - bool interruptible; // intr. at all times (excluding prolog/epilog), not just call sites - - bool securityCheck; // has a slot for security object - bool handlers; // has callable handlers - bool localloc; // uses localloc - bool editNcontinue; // has been compiled in EnC mode - bool varargs; // is this a varargs routine - bool profCallbacks; // does the method have Enter-Leave callbacks - bool genericsContext;// has a reported generic context paramter - bool genericsContextIsMethodDesc;// reported generic context parameter is methoddesc - bool isSpeculativeStackWalk; // is the stackwalk seeded by an untrusted source (e.g., sampling profiler)? - - // These always includes EBP for EBP-frames and double-aligned-frames - RegMask savedRegMask:8; // which callee-saved regs are saved on stack - - // Count of the callee-saved registers, excluding the frame pointer. - // This does not include EBP for EBP-frames and double-aligned-frames. - unsigned int savedRegsCountExclFP; - - unsigned int untrackedCnt; - unsigned int varPtrTableSize; - unsigned int argTabOffset; // INVALID_ARGTAB_OFFSET if argtab must be reached by stepping through ptr tables - unsigned int gsCookieOffset; // INVALID_GS_COOKIE_OFFSET if there is no GuardStack cookie - - unsigned int syncStartOffset; // start/end code offset of the protected region in synchronized methods. - unsigned int syncEndOffset; // INVALID_SYNC_OFFSET if there not synchronized method - unsigned int syncEpilogStart; // The start of the epilog. Synchronized methods are guaranteed to have no more than one epilog. - unsigned int revPInvokeOffset; // INVALID_REV_PINVOKE_OFFSET if there is no Reverse PInvoke frame - - enum { NOT_IN_PROLOG = -1, NOT_IN_EPILOG = -1 }; - - int prologOffs; // NOT_IN_PROLOG if not in prolog - int epilogOffs; // NOT_IN_EPILOG if not in epilog. It is never 0 - - // - // Results passed back from scanArgRegTable - // - regNum thisPtrResult; // register holding "this" - RegMask regMaskResult; // registers currently holding GC ptrs - RegMask iregMaskResult; // iptr qualifier for regMaskResult - unsigned argHnumResult; - PTR_CBYTE argTabResult; // Table of encoded offsets of pending ptr args - unsigned argTabBytes; // Number of bytes in argTabResult[] - - // These next two are now large structs (i.e 132 bytes each) - - ptrArgTP argMaskResult; // pending arguments mask - ptrArgTP iargMaskResult; // iptr qualifier for argMaskResult -}; - -/***************************************************************************** - How the stackwalkers buffer will be interpreted -*/ - -struct CodeManStateBuf -{ - DWORD hdrInfoSize; - hdrInfo hdrInfoBody; -}; -//***************************************************************************** -#endif // _EETWAIN_H -//***************************************************************************** diff --git a/src/inc/eexcp.h b/src/inc/eexcp.h deleted file mode 100644 index b91522b4d..000000000 --- a/src/inc/eexcp.h +++ /dev/null @@ -1,156 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -// ==++== -// - -// -// - -// -// ==--== - - -#ifndef __eexcp_h__ -#define __eexcp_h__ - -#include "corhlpr.h" -#include "daccess.h" - -struct EE_ILEXCEPTION_CLAUSE; -typedef DPTR(EE_ILEXCEPTION_CLAUSE) PTR_EE_ILEXCEPTION_CLAUSE; - -// The exception handling sub-system needs to keep track of EH clause that is handling given exception. -// PTR_EXCEPTION_CLAUSE_TOKEN is opaque pointer that uniquely identifies -// exception handling clause. It abstracts away encoding differences of EH clauses between JIT and NGen. -typedef PTR_VOID PTR_EXCEPTION_CLAUSE_TOKEN; - -struct EE_ILEXCEPTION_CLAUSE { - //Flags is not marked as volatile since it is always accessed - // from within a critical section - CorExceptionFlag Flags; - DWORD TryStartPC; - DWORD TryEndPC; - DWORD HandlerStartPC; - DWORD HandlerEndPC; - union { - void* TypeHandle; - mdToken ClassToken; - DWORD FilterOffset; - }; -}; - -struct EE_ILEXCEPTION; -typedef DPTR(EE_ILEXCEPTION) PTR_EE_ILEXCEPTION; - -struct EE_ILEXCEPTION : public COR_ILMETHOD_SECT_FAT -{ - EE_ILEXCEPTION_CLAUSE Clauses[1]; // actually variable size - - void Init(unsigned ehCount) - { - LIMITED_METHOD_CONTRACT; - - SetKind(CorILMethod_Sect_FatFormat); - SetDataSize((unsigned)sizeof(EE_ILEXCEPTION_CLAUSE) * ehCount); - } - - unsigned EHCount() const - { - LIMITED_METHOD_CONTRACT; - - return GetDataSize() / (DWORD) sizeof(EE_ILEXCEPTION_CLAUSE); - } - - static unsigned Size(unsigned ehCount) - { - LIMITED_METHOD_CONTRACT; - - _ASSERTE(ehCount > 0); - - return (offsetof(EE_ILEXCEPTION, Clauses) + sizeof(EE_ILEXCEPTION_CLAUSE) * ehCount); - } - EE_ILEXCEPTION_CLAUSE *EHClause(unsigned i) - { - LIMITED_METHOD_DAC_CONTRACT; - return &(PTR_EE_ILEXCEPTION_CLAUSE(PTR_HOST_MEMBER_TADDR(EE_ILEXCEPTION,this,Clauses))[i]); - } -}; - -#define COR_ILEXCEPTION_CLAUSE_CACHED_CLASS 0x10000000 - -inline BOOL HasCachedTypeHandle(EE_ILEXCEPTION_CLAUSE *EHClause) -{ - _ASSERTE(sizeof(EHClause->Flags) == sizeof(DWORD)); - return (EHClause->Flags & COR_ILEXCEPTION_CLAUSE_CACHED_CLASS); -} - -inline void SetHasCachedTypeHandle(EE_ILEXCEPTION_CLAUSE *EHClause) -{ - _ASSERTE(! HasCachedTypeHandle(EHClause)); - EHClause->Flags = (CorExceptionFlag)(EHClause->Flags | COR_ILEXCEPTION_CLAUSE_CACHED_CLASS); -} - -inline BOOL IsFinally(EE_ILEXCEPTION_CLAUSE *EHClause) -{ - LIMITED_METHOD_CONTRACT; - - return (EHClause->Flags & COR_ILEXCEPTION_CLAUSE_FINALLY); -} - -inline BOOL IsFault(EE_ILEXCEPTION_CLAUSE *EHClause) -{ - LIMITED_METHOD_CONTRACT; - - return (EHClause->Flags & COR_ILEXCEPTION_CLAUSE_FAULT); -} - -inline BOOL IsFaultOrFinally(EE_ILEXCEPTION_CLAUSE *EHClause) -{ - return IsFault(EHClause) || IsFinally(EHClause); -} - -inline BOOL IsFilterHandler(EE_ILEXCEPTION_CLAUSE *EHClause) -{ - LIMITED_METHOD_CONTRACT; - - return EHClause->Flags & COR_ILEXCEPTION_CLAUSE_FILTER; -} - -inline BOOL IsTypedHandler(EE_ILEXCEPTION_CLAUSE *EHClause) -{ - return ! (IsFilterHandler(EHClause) || IsFaultOrFinally(EHClause)); -} - -inline BOOL IsDuplicateClause(EE_ILEXCEPTION_CLAUSE* pEHClause) -{ - return pEHClause->Flags & COR_ILEXCEPTION_CLAUSE_DUPLICATED; -} - -#if defined(_TARGET_AMD64_) || defined(_TARGET_ARM64_) -// Finally is the only EH construct that can be part of the execution as being fall-through. -// -// "Cloned" finally is a contruct that represents a finally block that is used as -// fall through for normal try-block execution. Such a "cloned" finally will: -// -// 1) Have its try-clause's Start and End PC the same as its handler's start PC (i.e. will have -// zero length try block), AND -// 2) Is marked duplicate -// -// Because of their fall-through nature, JIT guarantees that only finally constructs can be cloned, -// and not catch or fault (since they cannot be fallen through but are invoked as funclets). -// -// The cloned finally construct is also used to mark "call to finally" thunks that are not within -// the EH region protected by the finally, and also not within the enclosing region. This is done -// to prevent ThreadAbortException from creating an infinite loop of calling the same finally. -inline BOOL IsClonedFinally(EE_ILEXCEPTION_CLAUSE* pEHClause) -{ - return ((pEHClause->TryStartPC == pEHClause->TryEndPC) && - (pEHClause->TryStartPC == pEHClause->HandlerStartPC) && - IsFinally(pEHClause) && IsDuplicateClause(pEHClause)); -} -#endif // defined(_TARGET_AMD64_) || defined(_TARGET_ARM64_) - -#endif // __eexcp_h__ - diff --git a/src/inc/entrypoints.h b/src/inc/entrypoints.h deleted file mode 100644 index 064f4ede2..000000000 --- a/src/inc/entrypoints.h +++ /dev/null @@ -1,60 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -//----------------------------------------------------------------------------- -// Entrypoint markers -// Used to identify all external entrypoints into the CLR (via COM, exports, etc) -// and perform various tasks on all of them -//----------------------------------------------------------------------------- - - -#ifndef __ENTRYPOINTS_h__ -#define __ENTRYPOINTS_h__ - -#define BEGIN_ENTRYPOINT_THROWS \ - BEGIN_SO_INTOLERANT_CODE(GetThread()) \ - - -#define END_ENTRYPOINT_THROWS \ - END_SO_INTOLERANT_CODE; - -#define BEGIN_ENTRYPOINT_THROWS_WITH_THREAD(____thread) \ - BEGIN_SO_INTOLERANT_CODE(____thread) \ - -#define END_ENTRYPOINT_THROWS_WITH_THREAD \ - END_SO_INTOLERANT_CODE; - -#define BEGIN_ENTRYPOINT_NOTHROW_WITH_THREAD(___thread) \ - BEGIN_SO_INTOLERANT_CODE_NO_THROW_CHECK_THREAD(return COR_E_STACKOVERFLOW) - -#define END_ENTRYPOINT_NOTHROW_WITH_THREAD \ - END_SO_INTOLERANT_CODE; - -#define BEGIN_ENTRYPOINT_NOTHROW \ - BEGIN_SO_INTOLERANT_CODE_NO_THROW_CHECK_THREAD(return COR_E_STACKOVERFLOW) - -#define END_ENTRYPOINT_NOTHROW \ - END_SO_INTOLERANT_CODE; - -extern void (*g_fpHandleSoftStackOverflow)(BOOL fSkipDebugger); -inline void FailedVoidEntryPoint() -{ - if (g_fpHandleSoftStackOverflow) - { - g_fpHandleSoftStackOverflow(FALSE); - } -} -#define BEGIN_ENTRYPOINT_VOIDRET \ - BEGIN_SO_INTOLERANT_CODE_NO_THROW_CHECK_THREAD(FailedVoidEntryPoint();) - -#define END_ENTRYPOINT_VOIDRET \ - END_SO_INTOLERANT_CODE; - -#define BEGIN_CLEANUP_ENTRYPOINT \ - VALIDATE_BACKOUT_STACK_CONSUMPTION; - -#define END_CLEANUP_ENTRYPOINT - -#endif // __ENTRYPOINTS_h__ - - diff --git a/src/inc/eventtrace.h b/src/inc/eventtrace.h deleted file mode 100644 index 1564c944b..000000000 --- a/src/inc/eventtrace.h +++ /dev/null @@ -1,361 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -// -// File: eventtrace.h -// Abstract: This module implements Event Tracing support. This includes -// eventtracebase.h, and adds VM-specific ETW helpers to support features like type -// logging, allocation logging, and gc heap walk logging. -// - -// - -// -// -// #EventTracing -// Windows -// ETW (Event Tracing for Windows) is a high-performance, low overhead and highly scalable -// tracing facility provided by the Windows Operating System. ETW is available on Win2K and above. There are -// four main types of components in ETW: event providers, controllers, consumers, and event trace sessions. -// An event provider is a logical entity that writes events to ETW sessions. The event provider must register -// a provider ID with ETW through the registration API. A provider first registers with ETW and writes events -// from various points in the code by invoking the ETW logging API. When a provider is enabled dynamically by -// the ETW controller application, calls to the logging API sends events to a specific trace session -// designated by the controller. Each event sent by the event provider to the trace session consists of a -// fixed header that includes event metadata and additional variable user-context data. CLR is an event -// provider. - -// Mac -// DTrace is similar to ETW and has been made to look like ETW at most of the places. -// For convenience, it is called ETM (Event Tracing for Mac) and exists only on the Mac Leopard OS -// ============================================================================ - -#ifndef _VMEVENTTRACE_H_ -#define _VMEVENTTRACE_H_ - -#include "eventtracebase.h" -#include "gcinterface.h" - -#if defined(GC_PROFILING) || defined(FEATURE_EVENT_TRACE) -struct ProfilingScanContext : ScanContext -{ - BOOL fProfilerPinned; - void * pvEtwContext; - void *pHeapId; - - ProfilingScanContext(BOOL fProfilerPinnedParam) : ScanContext() - { - LIMITED_METHOD_CONTRACT; - - pHeapId = NULL; - fProfilerPinned = fProfilerPinnedParam; - pvEtwContext = NULL; -#ifdef FEATURE_CONSERVATIVE_GC - // To not confuse GCScan::GcScanRoots - promotion = g_pConfig->GetGCConservative(); -#endif - } -}; -#endif // defined(GC_PROFILING) || defined(FEATURE_EVENT_TRACE) - -#ifndef FEATURE_REDHAWK - -namespace ETW -{ - class LoggedTypesFromModule; - - // We keep a hash of these to keep track of: - // * Which types have been logged through ETW (so we can avoid logging dupe Type - // events), and - // * GCSampledObjectAllocation stats to help with "smart sampling" which - // dynamically adjusts sampling rate of objects by type. - // See code:LoggedTypesFromModuleTraits - struct TypeLoggingInfo - { - public: - TypeLoggingInfo(TypeHandle thParam) - { - Init(thParam); - } - - TypeLoggingInfo() - { - Init(TypeHandle()); - } - - void Init(TypeHandle thParam) - { - th = thParam; - dwTickOfCurrentTimeBucket = 0; - dwAllocCountInCurrentBucket = 0; - flAllocPerMSec = 0; - - dwAllocsToSkipPerSample = 0; - dwAllocsSkippedForSample = 0; - cbIgnoredSizeForSample = 0; - }; - - // The type this TypeLoggingInfo represents - TypeHandle th; - - // Smart sampling - - // These bucket values remember stats of a particular time slice that are used to - // help adjust the sampling rate - DWORD dwTickOfCurrentTimeBucket; - DWORD dwAllocCountInCurrentBucket; - float flAllocPerMSec; - - // The number of data points to ignore before taking a "sample" (i.e., logging a - // GCSampledObjectAllocation ETW event for this type) - DWORD dwAllocsToSkipPerSample; - - // The current number of data points actually ignored for the current sample - DWORD dwAllocsSkippedForSample; - - // The current count of bytes of objects of this type actually allocated (and - // ignored) for the current sample - SIZE_T cbIgnoredSizeForSample; - }; - - // Class to wrap all type system logic for ETW - class TypeSystemLog - { - private: - // Global type hash - static AllLoggedTypes *s_pAllLoggedTypes; - - // An unsigned value that gets incremented whenever a global change is made. - // When this occurs, threads must synchronize themselves with the global state. - // Examples include unloading of modules and disabling of allocation sampling. - static unsigned int s_nEpoch; - - // See code:ETW::TypeSystemLog::PostRegistrationInit - static BOOL s_fHeapAllocEventEnabledOnStartup; - static BOOL s_fHeapAllocHighEventEnabledNow; - static BOOL s_fHeapAllocLowEventEnabledNow; - - // If COMPLUS_UNSUPPORTED_ETW_ObjectAllocationEventsPerTypePerSec is set, then - // this is used to determine the event frequency, overriding - // s_nDefaultMsBetweenEvents above (regardless of which - // GCSampledObjectAllocation*Keyword was used) - static int s_nCustomMsBetweenEvents; - - public: - // This customizes the type logging behavior in LogTypeAndParametersIfNecessary - enum TypeLogBehavior - { - // Take lock, and consult hash table to see if this is the first time we've - // encountered the type, in which case, log it - kTypeLogBehaviorTakeLockAndLogIfFirstTime, - - // Don't take lock, don't consult hash table. Just log the type. (This is - // used in cases when checking for dupe type logging isn't worth it, such as - // when logging the finalization of an object.) - kTypeLogBehaviorAlwaysLog, - - // When logging the type for GCSampledObjectAllocation events, - // we already know we need to log the type (since we already - // looked it up in the hash). But we would still need to consult the hash - // for any type parameters, so kTypeLogBehaviorAlwaysLog isn't appropriate, - // and this is used instead. - kTypeLogBehaviorAlwaysLogTopLevelType, - }; - - static HRESULT PreRegistrationInit(); - static void PostRegistrationInit(); - static BOOL IsHeapAllocEventEnabled(); - static void SendObjectAllocatedEvent(Object * pObject); - static CrstBase * GetHashCrst(); - static VOID LogTypeAndParametersIfNecessary(BulkTypeEventLogger * pBulkTypeEventLogger, ULONGLONG thAsAddr, TypeLogBehavior typeLogBehavior); - static VOID OnModuleUnload(Module * pModule); - static void OnKeywordsChanged(); - static void Cleanup(); - static VOID DeleteTypeHashNoLock(AllLoggedTypes **ppAllLoggedTypes); - static VOID FlushObjectAllocationEvents(); - - private: - static BOOL ShouldLogType(TypeHandle th); - static TypeLoggingInfo LookupOrCreateTypeLoggingInfo(TypeHandle th, BOOL * pfCreatedNew, LoggedTypesFromModule ** ppLoggedTypesFromModule = NULL); - static BOOL AddTypeToGlobalCacheIfNotExists(TypeHandle th, BOOL * pfCreatedNew); - static BOOL AddOrReplaceTypeLoggingInfo(ETW::LoggedTypesFromModule * pLoggedTypesFromModule, const ETW::TypeLoggingInfo * pTypeLoggingInfo); - static int GetDefaultMsBetweenEvents(); - static VOID OnTypesKeywordTurnedOff(); - }; - -#endif // FEATURE_REDHAWK - - - // Class to wrap all GC logic for ETW - class GCLog - { - private: - // When WPA triggers a GC, it gives us this unique number to append to our - // GCStart event so WPA can correlate the CLR's GC with the JScript GC they - // triggered at the same time. - // - // We set this value when the GC is triggered, and then retrieve the value on the - // first subsequent FireGcStart() method call for a full, induced GC, assuming - // that that's the GC that WPA triggered. This is imperfect, and if we were in - // the act of beginning another full, induced GC (for some other reason), then - // we'll attach this sequence number to that GC instead of to the WPA-induced GC, - // but who cares? When parsing ETW logs later on, it's indistinguishable if both - // GCs really were induced at around the same time. -#ifdef FEATURE_REDHAWK - static volatile LONGLONG s_l64LastClientSequenceNumber; -#else // FEATURE_REDHAWK - static Volatile s_l64LastClientSequenceNumber; -#endif // FEATURE_REDHAWK - - public: - typedef union st_GCEventInfo { - typedef struct _GenerationInfo { - ULONGLONG GenerationSize; - ULONGLONG TotalPromotedSize; - } GenerationInfo; - - struct { - GenerationInfo GenInfo[4]; // the heap info on gen0, gen1, gen2 and the large object heap. - ULONGLONG FinalizationPromotedSize; //not available per generation - ULONGLONG FinalizationPromotedCount; //not available per generation - ULONG PinnedObjectCount; - ULONG SinkBlockCount; - ULONG GCHandleCount; - } HeapStats; - - typedef enum _HeapType { - SMALL_OBJECT_HEAP, LARGE_OBJECT_HEAP, READ_ONLY_HEAP - } HeapType; - struct { - ULONGLONG Address; - ULONGLONG Size; - HeapType Type; - } GCCreateSegment; - - struct { - ULONGLONG Address; - } GCFreeSegment; - struct { - ULONG Count; - ULONG Depth; - } GCEnd; - - typedef enum _AllocationKind { - AllocationSmall = 0, - AllocationLarge - }AllocationKind; - struct { - ULONG Allocation; - AllocationKind Kind; - } AllocationTick; - - // These values are gotten from the gc_reason - // in gcimpl.h - typedef enum _GC_REASON { - GC_ALLOC_SOH = 0, - GC_INDUCED = 1, - GC_LOWMEMORY = 2, - GC_EMPTY = 3, - GC_ALLOC_LOH = 4, - GC_OOS_SOH = 5, - GC_OOS_LOH = 6, - GC_INDUCED_NOFORCE = 7, - GC_GCSTRESS = 8, - GC_LOWMEMORY_BLOCKING = 9, - GC_INDUCED_COMPACTING = 10, - GC_LOWMEMORY_HOST = 11 - } GC_REASON; - typedef enum _GC_TYPE { - GC_NGC = 0, - GC_BGC = 1, - GC_FGC = 2 - } GC_TYPE; - typedef enum _GC_ROOT_KIND { - GC_ROOT_STACK = 0, - GC_ROOT_FQ = 1, - GC_ROOT_HANDLES = 2, - GC_ROOT_OLDER = 3, - GC_ROOT_SIZEDREF = 4, - GC_ROOT_OVERFLOW = 5 - } GC_ROOT_KIND; - struct { - ULONG Count; - ULONG Depth; - GC_REASON Reason; - GC_TYPE Type; - } GCStart; - - struct { - ULONG Count; // how many finalizers we called. - } GCFinalizers; - - struct { - ULONG Reason; - // This is only valid when SuspendEE is called by GC (ie, Reason is either - // SUSPEND_FOR_GC or SUSPEND_FOR_GC_PREP. - ULONG GcCount; - } SuspendEE; - - struct { - ULONG HeapNum; - } GCMark; - - struct { - ULONGLONG SegmentSize; - ULONGLONG LargeObjectSegmentSize; - BOOL ServerGC; // TRUE means it's server GC; FALSE means it's workstation. - } GCSettings; - - struct { - // The generation that triggered this notification. - ULONG Count; - // 1 means the notification was due to allocation; 0 means it was due to other factors. - ULONG Alloc; - } GCFullNotify; - } ETW_GC_INFO, *PETW_GC_INFO; - -#ifdef FEATURE_EVENT_TRACE - static VOID GCSettingsEvent(); -#else - static VOID GCSettingsEvent() {}; -#endif // FEATURE_EVENT_TRACE - - static BOOL ShouldWalkHeapObjectsForEtw(); - static BOOL ShouldWalkHeapRootsForEtw(); - static BOOL ShouldTrackMovementForEtw(); - static HRESULT ForceGCForDiagnostics(); - static VOID ForceGC(LONGLONG l64ClientSequenceNumber); - static VOID FireGcStart(ETW_GC_INFO * pGcInfo); - static VOID RootReference( - LPVOID pvHandle, - Object * pRootedNode, - Object * pSecondaryNodeForDependentHandle, - BOOL fDependentHandle, - ProfilingScanContext * profilingScanContext, - DWORD dwGCFlags, - DWORD rootFlags); - static VOID ObjectReference( - ProfilerWalkHeapContext * profilerWalkHeapContext, - Object * pObjReferenceSource, - ULONGLONG typeID, - ULONGLONG cRefs, - Object ** rgObjReferenceTargets); - static BOOL ShouldWalkStaticsAndCOMForEtw(); - static VOID WalkStaticsAndCOMForETW(); - static VOID EndHeapDump(ProfilerWalkHeapContext * profilerWalkHeapContext); -#ifdef FEATURE_EVENT_TRACE - static VOID BeginMovedReferences(size_t * pProfilingContext); - static VOID MovedReference(BYTE * pbMemBlockStart, BYTE * pbMemBlockEnd, ptrdiff_t cbRelocDistance, size_t profilingContext, BOOL fCompacting, BOOL fAllowProfApiNotification = TRUE); - static VOID EndMovedReferences(size_t profilingContext, BOOL fAllowProfApiNotification = TRUE); -#else - // TODO: Need to be implemented for PROFILING_SUPPORTED. - static VOID BeginMovedReferences(size_t * pProfilingContext) {}; - static VOID MovedReference(BYTE * pbMemBlockStart, BYTE * pbMemBlockEnd, ptrdiff_t cbRelocDistance, size_t profilingContext, BOOL fCompacting, BOOL fAllowProfApiNotification = TRUE) {}; - static VOID EndMovedReferences(size_t profilingContext, BOOL fAllowProfApiNotification = TRUE) {}; -#endif // FEATURE_EVENT_TRACE - static VOID SendFinalizeObjectEvent(MethodTable * pMT, Object * pObj); - }; -}; - - -#endif //_VMEVENTTRACE_H_ diff --git a/src/inc/eventtracebase.h b/src/inc/eventtracebase.h deleted file mode 100644 index 7c0ee78b8..000000000 --- a/src/inc/eventtracebase.h +++ /dev/null @@ -1,1120 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -// -// File: eventtracebase.h -// Abstract: This module implements base Event Tracing support (excluding some of the -// CLR VM-specific ETW helpers). -// - -// - -// -// -// #EventTracing -// Windows -// ETW (Event Tracing for Windows) is a high-performance, low overhead and highly scalable -// tracing facility provided by the Windows Operating System. ETW is available on Win2K and above. There are -// four main types of components in ETW: event providers, controllers, consumers, and event trace sessions. -// An event provider is a logical entity that writes events to ETW sessions. The event provider must register -// a provider ID with ETW through the registration API. A provider first registers with ETW and writes events -// from various points in the code by invoking the ETW logging API. When a provider is enabled dynamically by -// the ETW controller application, calls to the logging API sends events to a specific trace session -// designated by the controller. Each event sent by the event provider to the trace session consists of a -// fixed header that includes event metadata and additional variable user-context data. CLR is an event -// provider. -// ============================================================================ - -#ifndef _ETWTRACER_HXX_ -#define _ETWTRACER_HXX_ - -struct EventStructTypeData; -void InitializeEventTracing(); - -// !!!!!!! NOTE !!!!!!!! -// The flags must match those in the ETW manifest exactly -// !!!!!!! NOTE !!!!!!!! - -// These flags need to be defined either when FEATURE_EVENT_TRACE is enabled or the -// PROFILING_SUPPORTED is set, since they are used both by event tracing and profiling. - -enum EtwTypeFlags -{ - kEtwTypeFlagsDelegate = 0x1, - kEtwTypeFlagsFinalizable = 0x2, - kEtwTypeFlagsExternallyImplementedCOMObject = 0x4, - kEtwTypeFlagsArray = 0x8, -}; - -enum EtwThreadFlags -{ - kEtwThreadFlagGCSpecial = 0x00000001, - kEtwThreadFlagFinalizer = 0x00000002, - kEtwThreadFlagThreadPoolWorker = 0x00000004, -}; - -#ifndef FEATURE_REDHAWK - -#if defined(FEATURE_EVENT_TRACE) - -#if defined(FEATURE_PERFTRACING) -#define EVENT_PIPE_ENABLED() (EventPipeHelper::Enabled()) -#else -#define EVENT_PIPE_ENABLED() (FALSE) -#endif - -#if !defined(FEATURE_PAL) - -// -// Use this macro at the least before calling the Event Macros -// - -#define ETW_TRACING_INITIALIZED(RegHandle) \ - ((g_pEtwTracer && RegHandle) || EVENT_PIPE_ENABLED()) - -// -// Use this macro to check if an event is enabled -// if the fields in the event are not cheap to calculate -// -#define ETW_EVENT_ENABLED(Context, EventDescriptor) \ - ((MCGEN_ENABLE_CHECK(Context, EventDescriptor)) || EVENT_PIPE_ENABLED()) - -// -// Use this macro to check if a category of events is enabled -// - -#define ETW_CATEGORY_ENABLED(Context, Level, Keyword) \ - ((Context.IsEnabled && McGenEventProviderEnabled(&Context, Level, Keyword)) || EVENT_PIPE_ENABLED()) - - -// This macro only checks if a provider is enabled -// It does not check the flags and keywords for which it is enabled -#define ETW_PROVIDER_ENABLED(ProviderSymbol) \ - ((ProviderSymbol##_Context.IsEnabled) || EVENT_PIPE_ENABLED()) - - -#else //defined(FEATURE_PAL) -#if defined(FEATURE_PERFTRACING) -#define ETW_INLINE -#define ETWOnStartup(StartEventName, EndEventName) -#define ETWFireEvent(EventName) - -#define ETW_TRACING_INITIALIZED(RegHandle) (TRUE) -#define ETW_EVENT_ENABLED(Context, EventDescriptor) (EventPipeHelper::Enabled() || XplatEventLogger::IsEventLoggingEnabled()) -#define ETW_CATEGORY_ENABLED(Context, Level, Keyword) (EventPipeHelper::Enabled() || XplatEventLogger::IsEventLoggingEnabled()) -#define ETW_TRACING_ENABLED(Context, EventDescriptor) (EventEnabled##EventDescriptor()) -#define ETW_TRACING_CATEGORY_ENABLED(Context, Level, Keyword) (EventPipeHelper::Enabled() || XplatEventLogger::IsEventLoggingEnabled()) -#define ETW_PROVIDER_ENABLED(ProviderSymbol) (TRUE) -#else //defined(FEATURE_PERFTRACING) -#define ETW_INLINE -#define ETWOnStartup(StartEventName, EndEventName) -#define ETWFireEvent(EventName) - -#define ETW_TRACING_INITIALIZED(RegHandle) (TRUE) -#define ETW_EVENT_ENABLED(Context, EventDescriptor) (XplatEventLogger::IsEventLoggingEnabled()) -#define ETW_CATEGORY_ENABLED(Context, Level, Keyword) (XplatEventLogger::IsEventLoggingEnabled()) -#define ETW_TRACING_ENABLED(Context, EventDescriptor) (EventEnabled##EventDescriptor()) -#define ETW_TRACING_CATEGORY_ENABLED(Context, Level, Keyword) (XplatEventLogger::IsEventLoggingEnabled()) -#define ETW_PROVIDER_ENABLED(ProviderSymbol) (TRUE) -#endif // defined(FEATURE_PERFTRACING) -#endif // !defined(FEATURE_PAL) - -#else // FEATURE_EVENT_TRACE - -#define ETWOnStartup(StartEventName, EndEventName) -#define ETWFireEvent(EventName) - -#define ETW_TRACING_INITIALIZED(RegHandle) (FALSE) -#define ETW_EVENT_ENABLED(Context, EventDescriptor) (FALSE) -#define ETW_CATEGORY_ENABLED(Context, Level, Keyword) (FALSE) -#define ETW_TRACING_ENABLED(Context, EventDescriptor) (FALSE) -#define ETW_TRACING_CATEGORY_ENABLED(Context, Level, Keyword) (FALSE) -#define ETW_PROVIDER_ENABLED(ProviderSymbol) (TRUE) - -#endif // FEATURE_EVENT_TRACE - -#endif // FEATURE_REDHAWK - -// During a heap walk, this is the storage for keeping track of all the nodes and edges -// being batched up by ETW, and for remembering whether we're also supposed to call into -// a profapi profiler. This is allocated toward the end of a GC and passed to us by the -// GC heap walker. -struct ProfilerWalkHeapContext -{ -public: - ProfilerWalkHeapContext(BOOL fProfilerPinnedParam, LPVOID pvEtwContextParam) - { - fProfilerPinned = fProfilerPinnedParam; - pvEtwContext = pvEtwContextParam; - } - - BOOL fProfilerPinned; - LPVOID pvEtwContext; -}; - -#ifdef FEATURE_EVENT_TRACE - -class Object; -#if !defined(FEATURE_PAL) - -/***************************************/ -/* Tracing levels supported by CLR ETW */ -/***************************************/ -#define ETWMAX_TRACE_LEVEL 6 // Maximum Number of Trace Levels supported -#define TRACE_LEVEL_NONE 0 // Tracing is not on -#define TRACE_LEVEL_FATAL 1 // Abnormal exit or termination -#define TRACE_LEVEL_ERROR 2 // Severe errors that need logging -#define TRACE_LEVEL_WARNING 3 // Warnings such as allocation failure -#define TRACE_LEVEL_INFORMATION 4 // Includes non-error cases such as Entry-Exit -#define TRACE_LEVEL_VERBOSE 5 // Detailed traces from intermediate steps - -struct ProfilingScanContext; - -// -// Use this macro to check if ETW is initialized and the event is enabled -// -#define ETW_TRACING_ENABLED(Context, EventDescriptor) \ - ((Context.IsEnabled && ETW_TRACING_INITIALIZED(Context.RegistrationHandle) && ETW_EVENT_ENABLED(Context, EventDescriptor)) || EVENT_PIPE_ENABLED()) - -// -// Using KEYWORDZERO means when checking the events category ignore the keyword -// -#define KEYWORDZERO 0x0 - -// -// Use this macro to check if ETW is initialized and the category is enabled -// -#define ETW_TRACING_CATEGORY_ENABLED(Context, Level, Keyword) \ - ((ETW_TRACING_INITIALIZED(Context.RegistrationHandle) && ETW_CATEGORY_ENABLED(Context, Level, Keyword)) || EVENT_PIPE_ENABLED()) - - #define ETWOnStartup(StartEventName, EndEventName) \ - ETWTraceStartup trace##StartEventName##(Microsoft_Windows_DotNETRuntimePrivateHandle, &StartEventName, &StartupId, &EndEventName, &StartupId); - #define ETWFireEvent(EventName) \ - ETWTraceStartup::StartupTraceEvent(Microsoft_Windows_DotNETRuntimePrivateHandle, &EventName, &StartupId); - -#ifndef FEATURE_REDHAWK -// Headers -#include -#include -#include -#include -#endif //!FEATURE_REDHAWK -#endif //!defined(FEATURE_PAL) - - -#else // FEATURE_EVENT_TRACE - -#include "etmdummy.h" -#endif // FEATURE_EVENT_TRACE - -#ifndef FEATURE_REDHAWK - -#include "corprof.h" - -// g_nClrInstanceId is defined in Utilcode\Util.cpp. The definition goes into Utilcode.lib. -// This enables both the VM and Utilcode to raise ETW events. -extern UINT32 g_nClrInstanceId; - -#define GetClrInstanceId() (static_cast(g_nClrInstanceId)) - -#if defined(FEATURE_PERFTRACING) -class EventPipeHelper -{ -public: - static bool Enabled(); -}; -#endif // defined(FEATURE_PERFTRACING) - -#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) - -VOID EventPipeEtwCallbackDotNETRuntimeStress( - _In_ LPCGUID SourceId, - _In_ ULONG ControlCode, - _In_ UCHAR Level, - _In_ ULONGLONG MatchAnyKeyword, - _In_ ULONGLONG MatchAllKeyword, - _In_opt_ PVOID FilterData, - _Inout_opt_ PVOID CallbackContext); - -VOID EventPipeEtwCallbackDotNETRuntime( - _In_ LPCGUID SourceId, - _In_ ULONG ControlCode, - _In_ UCHAR Level, - _In_ ULONGLONG MatchAnyKeyword, - _In_ ULONGLONG MatchAllKeyword, - _In_opt_ PVOID FilterData, - _Inout_opt_ PVOID CallbackContext); - -VOID EventPipeEtwCallbackDotNETRuntimeRundown( - _In_ LPCGUID SourceId, - _In_ ULONG ControlCode, - _In_ UCHAR Level, - _In_ ULONGLONG MatchAnyKeyword, - _In_ ULONGLONG MatchAllKeyword, - _In_opt_ PVOID FilterData, - _Inout_opt_ PVOID CallbackContext); - -VOID EventPipeEtwCallbackDotNETRuntimePrivate( - _In_ LPCGUID SourceId, - _In_ ULONG ControlCode, - _In_ UCHAR Level, - _In_ ULONGLONG MatchAnyKeyword, - _In_ ULONGLONG MatchAllKeyword, - _In_opt_ PVOID FilterData, - _Inout_opt_ PVOID CallbackContext); - -#ifndef FEATURE_PAL -// Callback and stack support -#if !defined(DONOT_DEFINE_ETW_CALLBACK) && !defined(DACCESS_COMPILE) -extern "C" { - /* ETW control callback - * Desc: This function handles the ETW control - * callback. - * Ret: success or failure - ***********************************************/ - VOID EtwCallback( - _In_ LPCGUID SourceId, - _In_ ULONG ControlCode, - _In_ UCHAR Level, - _In_ ULONGLONG MatchAnyKeyword, - _In_ ULONGLONG MatchAllKeyword, - _In_opt_ PEVENT_FILTER_DESCRIPTOR FilterData, - _Inout_opt_ PVOID CallbackContext); -} - -// -// User defined callback -// -#define MCGEN_PRIVATE_ENABLE_CALLBACK(RequestCode, Context, InOutBufferSize, Buffer) \ - EtwCallback(NULL /* SourceId */, (RequestCode==WMI_ENABLE_EVENTS) ? EVENT_CONTROL_CODE_ENABLE_PROVIDER : EVENT_CONTROL_CODE_DISABLE_PROVIDER, 0 /* Level */, 0 /* MatchAnyKeyword */, 0 /* MatchAllKeyword */, NULL /* FilterData */, Context) - -// -// User defined callback2 -// -#define MCGEN_PRIVATE_ENABLE_CALLBACK_V2(SourceId, ControlCode, Level, MatchAnyKeyword, MatchAllKeyword, FilterData, CallbackContext) \ - EtwCallback(SourceId, ControlCode, Level, MatchAnyKeyword, MatchAllKeyword, FilterData, CallbackContext) - -extern "C" { - /* ETW callout - * Desc: This function handles the ETW callout - * Ret: success or failure - ***********************************************/ - VOID EtwCallout( - REGHANDLE RegHandle, - PCEVENT_DESCRIPTOR Descriptor, - ULONG ArgumentCount, - PEVENT_DATA_DESCRIPTOR EventData); -} - -// -// Call user defined callout -// -#define MCGEN_CALLOUT(RegHandle, Descriptor, NumberOfArguments, EventData) \ - EtwCallout(RegHandle, Descriptor, NumberOfArguments, EventData) -#endif //!DONOT_DEFINE_ETW_CALLBACK && !DACCESS_COMPILE - -#endif //!FEATURE_PAL - -#include "clretwallmain.h" - -#endif // FEATURE_EVENT_TRACE - -/**************************/ -/* CLR ETW infrastructure */ -/**************************/ -// #CEtwTracer -// On Windows Vista, ETW has gone through a major upgrade, and one of the most significant changes is the -// introduction of the unified event provider model and APIs. The older architecture used the classic ETW -// events. The new ETW architecture uses the manifest based events. To support both types of events at the -// same time, we use the manpp tool for generating event macros that can be directly used to fire ETW events -// from various components within the CLR. -// (http://diagnostics/sites/etw/Lists/Announcements/DispForm.aspx?ID=10&Source=http%3A%2F%2Fdiagnostics%2Fsites%2Fetw%2Fdefault%2Easpx) -// Every ETW provider has to Register itself to the system, so that when enabled, it is capable of firing -// ETW events. file:../VM/eventtrace.cpp#Registration is where the actual Provider Registration takes place. -// At process shutdown, a registered provider need to be unregistered. -// file:../VM/eventtrace.cpp#Unregistration. Since ETW can also be enabled at any instant after the process -// has started, one may want to do something useful when that happens (e.g enumerate all the loaded modules -// in the system). To enable this, we have to implement a callback routine. -// file:../VM/eventtrace.cpp#EtwCallback is CLR's implementation of the callback. -// - -#include "daccess.h" -class Module; -class Assembly; -class MethodDesc; -class MethodTable; -class BaseDomain; -class AppDomain; -class SString; -class CrawlFrame; -class LoaderAllocator; -class AssemblyLoaderAllocator; -struct AllLoggedTypes; -class CrstBase; -class BulkTypeEventLogger; -class TypeHandle; -class Thread; - - -// All ETW helpers must be a part of this namespace -// We have auto-generated macros to directly fire the events -// but in some cases, gathering the event payload information involves some work -// and it can be done in a relevant helper class like the one's in this namespace -namespace ETW -{ - // Class to wrap the ETW infrastructure logic -#if !defined(FEATURE_PAL) - class CEtwTracer - { -#if defined(FEATURE_EVENT_TRACE) - ULONG RegGuids(LPCGUID ProviderId, PENABLECALLBACK EnableCallback, PVOID CallbackContext, PREGHANDLE RegHandle); -#endif - - public: -#ifdef FEATURE_EVENT_TRACE - // Registers all the Event Tracing providers - HRESULT Register(); - - // Unregisters all the Event Tracing providers - HRESULT UnRegister(); -#else - HRESULT Register() - { - return S_OK; - } - HRESULT UnRegister() - { - return S_OK; - } -#endif // FEATURE_EVENT_TRACE - }; -#endif // !defined(FEATURE_PAL) - - class LoaderLog; - class MethodLog; - // Class to wrap all the enumeration logic for ETW - class EnumerationLog - { - friend class ETW::LoaderLog; - friend class ETW::MethodLog; -#ifdef FEATURE_EVENT_TRACE - static VOID SendThreadRundownEvent(); - static VOID IterateDomain(BaseDomain *pDomain, DWORD enumerationOptions); - static VOID IterateAppDomain(AppDomain * pAppDomain, DWORD enumerationOptions); - static VOID IterateCollectibleLoaderAllocator(AssemblyLoaderAllocator *pLoaderAllocator, DWORD enumerationOptions); - static VOID IterateAssembly(Assembly *pAssembly, DWORD enumerationOptions); - static VOID IterateModule(Module *pModule, DWORD enumerationOptions); - static VOID EnumerationHelper(Module *moduleFilter, BaseDomain *domainFilter, DWORD enumerationOptions); - static DWORD GetEnumerationOptionsFromRuntimeKeywords(); - public: - typedef union _EnumerationStructs - { - typedef enum _EnumerationOptions - { - None= 0x00000000, - DomainAssemblyModuleLoad= 0x00000001, - DomainAssemblyModuleUnload= 0x00000002, - DomainAssemblyModuleDCStart= 0x00000004, - DomainAssemblyModuleDCEnd= 0x00000008, - JitMethodLoad= 0x00000010, - JitMethodUnload= 0x00000020, - JitMethodDCStart= 0x00000040, - JitMethodDCEnd= 0x00000080, - NgenMethodLoad= 0x00000100, - NgenMethodUnload= 0x00000200, - NgenMethodDCStart= 0x00000400, - NgenMethodDCEnd= 0x00000800, - ModuleRangeLoad= 0x00001000, - ModuleRangeDCStart= 0x00002000, - ModuleRangeDCEnd= 0x00004000, - ModuleRangeLoadPrivate= 0x00008000, - MethodDCStartILToNativeMap= 0x00010000, - MethodDCEndILToNativeMap= 0x00020000, - JitMethodILToNativeMap= 0x00040000, - TypeUnload= 0x00080000, - - // Helpers - ModuleRangeEnabledAny = ModuleRangeLoad | ModuleRangeDCStart | ModuleRangeDCEnd | ModuleRangeLoadPrivate, - JitMethodLoadOrDCStartAny = JitMethodLoad | JitMethodDCStart | MethodDCStartILToNativeMap, - JitMethodUnloadOrDCEndAny = JitMethodUnload | JitMethodDCEnd | MethodDCEndILToNativeMap, - }EnumerationOptions; - }EnumerationStructs; - - static VOID ProcessShutdown(); - static VOID ModuleRangeRundown(); - static VOID StartRundown(); - static VOID EndRundown(); - static VOID EnumerateForCaptureState(); -#else - public: - static VOID ProcessShutdown() {}; - static VOID StartRundown() {}; - static VOID EndRundown() {}; -#endif // FEATURE_EVENT_TRACE - }; - - - // Class to wrap all the sampling logic for ETW - - class SamplingLog - { -#if defined(FEATURE_EVENT_TRACE) && !defined(FEATURE_PAL) - public: - typedef enum _EtwStackWalkStatus - { - Completed = 0, - UnInitialized = 1, - InProgress = 2 - } EtwStackWalkStatus; - private: - static const UINT8 s_MaxStackSize=100; - UINT32 m_FrameCount; - SIZE_T m_EBPStack[SamplingLog::s_MaxStackSize]; - VOID Append(SIZE_T currentFrame); - EtwStackWalkStatus SaveCurrentStack(int skipTopNFrames=1); - public: - static ULONG SendStackTrace(MCGEN_TRACE_CONTEXT TraceContext, PCEVENT_DESCRIPTOR Descriptor, LPCGUID EventGuid); - EtwStackWalkStatus GetCurrentThreadsCallStack(UINT32 *frameCount, PVOID **Stack); -#endif // FEATURE_EVENT_TRACE && !defined(FEATURE_PAL) - }; - - // Class to wrap all Loader logic for ETW - class LoaderLog - { - friend class ETW::EnumerationLog; -#if defined(FEATURE_EVENT_TRACE) - static VOID SendModuleEvent(Module *pModule, DWORD dwEventOptions, BOOL bFireDomainModuleEvents=FALSE); - static ULONG SendModuleRange(__in Module *pModule, __in DWORD dwEventOptions); - static VOID SendAssemblyEvent(Assembly *pAssembly, DWORD dwEventOptions); - static VOID SendDomainEvent(BaseDomain *pBaseDomain, DWORD dwEventOptions, LPCWSTR wszFriendlyName=NULL); - public: - typedef union _LoaderStructs - { - typedef enum _AppDomainFlags - { - DefaultDomain=0x1, - ExecutableDomain=0x2, - SharedDomain=0x4 - }AppDomainFlags; - - typedef enum _AssemblyFlags - { - DomainNeutralAssembly=0x1, - DynamicAssembly=0x2, - NativeAssembly=0x4, - CollectibleAssembly=0x8, - ReadyToRunAssembly=0x10, - }AssemblyFlags; - - typedef enum _ModuleFlags - { - DomainNeutralModule=0x1, - NativeModule=0x2, - DynamicModule=0x4, - ManifestModule=0x8, - IbcOptimized=0x10, - ReadyToRunModule=0x20, - }ModuleFlags; - - typedef enum _RangeFlags - { - HotRange=0x0 - }RangeFlags; - - }LoaderStructs; - - static VOID DomainLoadReal(BaseDomain *pDomain, __in_opt LPWSTR wszFriendlyName=NULL); - - static VOID DomainLoad(BaseDomain *pDomain, __in_opt LPWSTR wszFriendlyName = NULL) - { - if (ETW_PROVIDER_ENABLED(MICROSOFT_WINDOWS_DOTNETRUNTIME_PROVIDER)) - { - DomainLoadReal(pDomain, wszFriendlyName); - } - } - - static VOID DomainUnload(AppDomain *pDomain); - static VOID CollectibleLoaderAllocatorUnload(AssemblyLoaderAllocator *pLoaderAllocator); - static VOID ModuleLoad(Module *pModule, LONG liReportedSharedModule); -#else - public: - static VOID DomainLoad(BaseDomain *pDomain, __in_opt LPWSTR wszFriendlyName=NULL) {}; - static VOID DomainUnload(AppDomain *pDomain) {}; - static VOID CollectibleLoaderAllocatorUnload(AssemblyLoaderAllocator *pLoaderAllocator) {}; - static VOID ModuleLoad(Module *pModule, LONG liReportedSharedModule) {}; -#endif // FEATURE_EVENT_TRACE - }; - - // Class to wrap all Method logic for ETW - class MethodLog - { - friend class ETW::EnumerationLog; -#ifdef FEATURE_EVENT_TRACE - static VOID SendEventsForJitMethods(BaseDomain *pDomainFilter, LoaderAllocator *pLoaderAllocatorFilter, DWORD dwEventOptions); - static VOID SendEventsForJitMethodsHelper(BaseDomain *pDomainFilter, - LoaderAllocator *pLoaderAllocatorFilter, - DWORD dwEventOptions, - BOOL fLoadOrDCStart, - BOOL fUnloadOrDCEnd, - BOOL fSendMethodEvent, - BOOL fSendILToNativeMapEvent, - BOOL fGetReJitIDs); - static VOID SendEventsForNgenMethods(Module *pModule, DWORD dwEventOptions); - static VOID SendMethodJitStartEvent(MethodDesc *pMethodDesc, SString *namespaceOrClassName=NULL, SString *methodName=NULL, SString *methodSignature=NULL); - static VOID SendMethodILToNativeMapEvent(MethodDesc * pMethodDesc, DWORD dwEventOptions, SIZE_T pCode, ReJITID rejitID); - static VOID SendMethodEvent(MethodDesc *pMethodDesc, DWORD dwEventOptions, BOOL bIsJit, SString *namespaceOrClassName=NULL, SString *methodName=NULL, SString *methodSignature=NULL, SIZE_T pCode = 0, ReJITID rejitID = 0, BOOL bProfilerRejectedPrecompiledCode = FALSE, BOOL bReadyToRunRejectedPrecompiledCode = FALSE); - static VOID SendHelperEvent(ULONGLONG ullHelperStartAddress, ULONG ulHelperSize, LPCWSTR pHelperName); - public: - typedef union _MethodStructs - { - typedef enum _MethodFlags - { - DynamicMethod=0x1, - GenericMethod=0x2, - SharedGenericCode=0x4, - JittedMethod=0x8, - JitHelperMethod=0x10, - ProfilerRejectedPrecompiledCode=0x20, - ReadyToRunRejectedPrecompiledCode=0x40, - }MethodFlags; - - typedef enum _MethodExtent - { - HotSection=0x00000000, - ColdSection=0x10000000 - }MethodExtent; - - }MethodStructs; - - static VOID MethodJitting(MethodDesc *pMethodDesc, SString *namespaceOrClassName=NULL, SString *methodName=NULL, SString *methodSignature=NULL); - static VOID MethodJitted(MethodDesc *pMethodDesc, SString *namespaceOrClassName=NULL, SString *methodName=NULL, SString *methodSignature=NULL, SIZE_T pCode = 0, ReJITID rejitID = 0, BOOL bProfilerRejectedPrecompiledCode = FALSE, BOOL bReadyToRunRejectedPrecompiledCode = FALSE); - static VOID StubInitialized(ULONGLONG ullHelperStartAddress, LPCWSTR pHelperName); - static VOID StubsInitialized(PVOID *pHelperStartAddresss, PVOID *pHelperNames, LONG ulNoOfHelpers); - static VOID MethodRestored(MethodDesc * pMethodDesc); - static VOID MethodTableRestored(MethodTable * pMethodTable); - static VOID DynamicMethodDestroyed(MethodDesc *pMethodDesc); -#else // FEATURE_EVENT_TRACE - public: - static VOID MethodJitting(MethodDesc *pMethodDesc, SString *namespaceOrClassName=NULL, SString *methodName=NULL, SString *methodSignature=NULL) {}; - static VOID MethodJitted(MethodDesc *pMethodDesc, SString *namespaceOrClassName=NULL, SString *methodName=NULL, SString *methodSignature=NULL, SIZE_T pCode = 0, ReJITID rejitID = 0, BOOL bProfilerRejectedPrecompiledCode = FALSE, BOOL bReadyToRunRejectedPrecompiledCode = FALSE) {}; - static VOID StubInitialized(ULONGLONG ullHelperStartAddress, LPCWSTR pHelperName) {}; - static VOID StubsInitialized(PVOID *pHelperStartAddresss, PVOID *pHelperNames, LONG ulNoOfHelpers) {}; - static VOID MethodRestored(MethodDesc * pMethodDesc) {}; - static VOID MethodTableRestored(MethodTable * pMethodTable) {}; - static VOID DynamicMethodDestroyed(MethodDesc *pMethodDesc) {}; -#endif // FEATURE_EVENT_TRACE - }; - - // Class to wrap all Security logic for ETW - class SecurityLog - { -#ifdef FEATURE_EVENT_TRACE - public: - static VOID StrongNameVerificationStart(DWORD dwInFlags, __in LPWSTR strFullyQualifiedAssemblyName); - static VOID StrongNameVerificationStop(DWORD dwInFlags,ULONG result, __in LPWSTR strFullyQualifiedAssemblyName); - - static void FireFieldTransparencyComputationStart(LPCWSTR wszFieldName, - LPCWSTR wszModuleName, - DWORD dwAppDomain); - static void FireFieldTransparencyComputationEnd(LPCWSTR wszFieldName, - LPCWSTR wszModuleName, - DWORD dwAppDomain, - BOOL fIsCritical, - BOOL fIsTreatAsSafe); - - static void FireMethodTransparencyComputationStart(LPCWSTR wszMethodName, - LPCWSTR wszModuleName, - DWORD dwAppDomain); - static void FireMethodTransparencyComputationEnd(LPCWSTR wszMethodName, - LPCWSTR wszModuleName, - DWORD dwAppDomain, - BOOL fIsCritical, - BOOL fIsTreatAsSafe); - - static void FireModuleTransparencyComputationStart(LPCWSTR wszModuleName, DWORD dwAppDomain); - static void FireModuleTransparencyComputationEnd(LPCWSTR wszModuleName, - DWORD dwAppDomain, - BOOL fIsAllCritical, - BOOL fIsAllTransparent, - BOOL fIsTreatAsSafe, - BOOL fIsOpportunisticallyCritical, - DWORD dwSecurityRuleSet); - - static void FireTokenTransparencyComputationStart(DWORD dwToken, - LPCWSTR wszModuleName, - DWORD dwAppDomain); - static void FireTokenTransparencyComputationEnd(DWORD dwToken, - LPCWSTR wszModuleName, - DWORD dwAppDomain, - BOOL fIsCritical, - BOOL fIsTreatAsSafe); - - static void FireTypeTransparencyComputationStart(LPCWSTR wszTypeName, - LPCWSTR wszModuleName, - DWORD dwAppDomain); - static void FireTypeTransparencyComputationEnd(LPCWSTR wszTypeName, - LPCWSTR wszModuleName, - DWORD dwAppDomain, - BOOL fIsAllCritical, - BOOL fIsAllTransparent, - BOOL fIsCritical, - BOOL fIsTreatAsSafe); -#else - public: - static VOID StrongNameVerificationStart(DWORD dwInFlags, _In_z_ LPWSTR strFullyQualifiedAssemblyName) {}; - static VOID StrongNameVerificationStop(DWORD dwInFlags,ULONG result, _In_z_ LPWSTR strFullyQualifiedAssemblyName) {}; - - static void FireFieldTransparencyComputationStart(LPCWSTR wszFieldName, - LPCWSTR wszModuleName, - DWORD dwAppDomain) {}; - static void FireFieldTransparencyComputationEnd(LPCWSTR wszFieldName, - LPCWSTR wszModuleName, - DWORD dwAppDomain, - BOOL fIsCritical, - BOOL fIsTreatAsSafe) {}; - - static void FireMethodTransparencyComputationStart(LPCWSTR wszMethodName, - LPCWSTR wszModuleName, - DWORD dwAppDomain) {}; - static void FireMethodTransparencyComputationEnd(LPCWSTR wszMethodName, - LPCWSTR wszModuleName, - DWORD dwAppDomain, - BOOL fIsCritical, - BOOL fIsTreatAsSafe) {}; - - static void FireModuleTransparencyComputationStart(LPCWSTR wszModuleName, DWORD dwAppDomain) {}; - static void FireModuleTransparencyComputationEnd(LPCWSTR wszModuleName, - DWORD dwAppDomain, - BOOL fIsAllCritical, - BOOL fIsAllTransparent, - BOOL fIsTreatAsSafe, - BOOL fIsOpportunisticallyCritical, - DWORD dwSecurityRuleSet) {}; - - static void FireTokenTransparencyComputationStart(DWORD dwToken, - LPCWSTR wszModuleName, - DWORD dwAppDomain) {}; - static void FireTokenTransparencyComputationEnd(DWORD dwToken, - LPCWSTR wszModuleName, - DWORD dwAppDomain, - BOOL fIsCritical, - BOOL fIsTreatAsSafe) {}; - - static void FireTypeTransparencyComputationStart(LPCWSTR wszTypeName, - LPCWSTR wszModuleName, - DWORD dwAppDomain) {}; - static void FireTypeTransparencyComputationEnd(LPCWSTR wszTypeName, - LPCWSTR wszModuleName, - DWORD dwAppDomain, - BOOL fIsAllCritical, - BOOL fIsAllTransparent, - BOOL fIsCritical, - BOOL fIsTreatAsSafe) {}; -#endif // FEATURE_EVENT_TRACE - }; - - // Class to wrap all Binder logic for ETW - class BinderLog - { - public: - typedef union _BinderStructs { - typedef enum _NGENBINDREJECT_REASON { - NGEN_BIND_START_BIND = 0, - NGEN_BIND_NO_INDEX = 1, - NGEN_BIND_SYSTEM_ASSEMBLY_NOT_AVAILABLE = 2, - NGEN_BIND_NO_NATIVE_IMAGE = 3, - NGEN_BIND_REJECT_CONFIG_MASK = 4, - NGEN_BIND_FAIL = 5, - NGEN_BIND_INDEX_CORRUPTION = 6, - NGEN_BIND_REJECT_TIMESTAMP = 7, - NGEN_BIND_REJECT_NATIVEIMAGE_NOT_FOUND = 8, - NGEN_BIND_REJECT_IL_SIG = 9, - NGEN_BIND_REJECT_LOADER_EVAL_FAIL = 10, - NGEN_BIND_MISSING_FOUND = 11, - NGEN_BIND_REJECT_HOSTASM = 12, - NGEN_BIND_REJECT_IL_NOT_FOUND = 13, - NGEN_BIND_REJECT_APPBASE_NOT_FILE = 14, - NGEN_BIND_BIND_DEPEND_REJECT_REF_DEF_MISMATCH = 15, - NGEN_BIND_BIND_DEPEND_REJECT_NGEN_SIG = 16, - NGEN_BIND_APPLY_EXTERNAL_RELOCS_FAILED = 17, - NGEN_BIND_SYSTEM_ASSEMBLY_NATIVEIMAGE_NOT_AVAILABLE = 18, - NGEN_BIND_ASSEMBLY_HAS_DIFFERENT_GRANT = 19, - NGEN_BIND_ASSEMBLY_NOT_DOMAIN_NEUTRAL = 20, - NGEN_BIND_NATIVEIMAGE_VERSION_MISMATCH = 21, - NGEN_BIND_LOADFROM_NOT_ALLOWED = 22, - NGEN_BIND_DEPENDENCY_HAS_DIFFERENT_IDENTITY = 23 - } NGENBINDREJECT_REASON; - } BinderStructs; - }; - - // Class to wrap all Exception logic for ETW - class ExceptionLog - { - public: -#ifdef FEATURE_EVENT_TRACE - static VOID ExceptionThrown(CrawlFrame *pCf, BOOL bIsReThrownException, BOOL bIsNewException); - static VOID ExceptionThrownEnd(); - static VOID ExceptionCatchBegin(MethodDesc * pMethodDesc, PVOID pEntryEIP); - static VOID ExceptionCatchEnd(); - static VOID ExceptionFinallyBegin(MethodDesc * pMethodDesc, PVOID pEntryEIP); - static VOID ExceptionFinallyEnd(); - static VOID ExceptionFilterBegin(MethodDesc * pMethodDesc, PVOID pEntryEIP); - static VOID ExceptionFilterEnd(); - -#else - static VOID ExceptionThrown(CrawlFrame *pCf, BOOL bIsReThrownException, BOOL bIsNewException) {}; - static VOID ExceptionThrownEnd() {}; - static VOID ExceptionCatchBegin(MethodDesc * pMethodDesc, PVOID pEntryEIP) {}; - static VOID ExceptionCatchEnd() {}; - static VOID ExceptionFinallyBegin(MethodDesc * pMethodDesc, PVOID pEntryEIP) {}; - static VOID ExceptionFinallyEnd() {}; - static VOID ExceptionFilterBegin(MethodDesc * pMethodDesc, PVOID pEntryEIP) {}; - static VOID ExceptionFilterEnd() {}; -#endif // FEATURE_EVENT_TRACE - typedef union _ExceptionStructs - { - typedef enum _ExceptionThrownFlags - { - HasInnerException=0x1, - IsNestedException=0x2, - IsReThrownException=0x4, - IsCSE=0x8, - IsCLSCompliant=0x10 - }ExceptionThrownFlags; - }ExceptionStructs; - }; - // Class to wrap all Contention logic for ETW - class ContentionLog - { - public: - typedef union _ContentionStructs - { - typedef enum _ContentionFlags { - ManagedContention=0, - NativeContention=1 - } ContentionFlags; - } ContentionStructs; - }; - // Class to wrap all Interop logic for ETW - class InteropLog - { - public: - }; - - // Class to wrap all Information logic for ETW - class InfoLog - { - public: - typedef union _InfoStructs - { - typedef enum _StartupMode - { - ManagedExe=0x1, - HostedCLR=0x2, - IJW=0x4, - COMActivated=0x8, - Other=0x10 - }StartupMode; - - typedef enum _Sku - { - DesktopCLR=0x1, - CoreCLR=0x2 - }Sku; - - typedef enum _EtwMode - { - Normal=0x0, - Callback=0x1 - }EtwMode; - }InfoStructs; - -#ifdef FEATURE_EVENT_TRACE - static VOID RuntimeInformation(INT32 type); -#else - static VOID RuntimeInformation(INT32 type) {}; -#endif // FEATURE_EVENT_TRACE - }; - - class CodeSymbolLog - { - public: -#ifdef FEATURE_EVENT_TRACE - static VOID EmitCodeSymbols(Module* pModule); - static HRESULT GetInMemorySymbolsLength(Module* pModule, DWORD* pCountSymbolBytes); - static HRESULT ReadInMemorySymbols(Module* pmodule, DWORD symbolsReadOffset, BYTE* pSymbolBytes, - DWORD countSymbolBytes, DWORD* pCountSymbolBytesRead); -#else - static VOID EmitCodeSymbols(Module* pModule) {} - static HRESULT GetInMemorySymbolsLength(Module* pModule, DWORD* pCountSymbolBytes) { return S_OK; } - static HRESULT ReadInMemorySymbols(Module* pmodule, DWORD symbolsReadOffset, BYTE* pSymbolBytes, - DWORD countSymbolBytes, DWORD* pCountSymbolBytesRead) { return S_OK; } -#endif // FEATURE_EVENT_TRACE - }; -}; - - -#define ETW_IS_TRACE_ON(level) ( FALSE ) // for fusion which is eventually going to get removed -#define ETW_IS_FLAG_ON(flag) ( FALSE ) // for fusion which is eventually going to get removed - -// Commonly used constats for ETW Assembly Loader and Assembly Binder events. -#define ETWLoadContextNotAvailable (LOADCTX_TYPE_HOSTED + 1) -#define ETWAppDomainIdNotAvailable 0 // Valid AppDomain IDs start from 1 - -#define ETWFieldUnused 0 // Indicates that a particular field in the ETW event payload template is currently unused. - -#define ETWLoaderLoadTypeNotAvailable 0 // Static or Dynamic Load is only valid at LoaderPhaseStart and LoaderPhaseEnd events - for other events, 0 indicates "not available" -#define ETWLoaderStaticLoad 0 // Static reference load -#define ETWLoaderDynamicLoad 1 // Dynamic assembly load - -#if defined(FEATURE_EVENT_TRACE) && !defined(FEATURE_PAL) -// -// The ONE and only ONE global instantiation of this class -// -extern ETW::CEtwTracer * g_pEtwTracer; - -// -// Special Handling of Startup events -// - -// "mc.exe -MOF" already generates this block for XP-suported builds inside ClrEtwAll.h; -// on Vista+ builds, mc is run without -MOF, and we still have code that depends on it, so -// we manually place it here. -ETW_INLINE -ULONG -CoMofTemplate_h( - __in REGHANDLE RegHandle, - __in PCEVENT_DESCRIPTOR Descriptor, - __in_opt LPCGUID EventGuid, - __in const unsigned short ClrInstanceID - ) -{ -#define ARGUMENT_COUNT_h 1 - ULONG Error = ERROR_SUCCESS; -typedef struct _MCGEN_TRACE_BUFFER { - EVENT_TRACE_HEADER Header; - EVENT_DATA_DESCRIPTOR EventData[ARGUMENT_COUNT_h]; -} MCGEN_TRACE_BUFFER; - - MCGEN_TRACE_BUFFER TraceBuf; - PEVENT_DATA_DESCRIPTOR EventData = TraceBuf.EventData; - - EventDataDescCreate(&EventData[0], &ClrInstanceID, sizeof(const unsigned short) ); - - - { - Error = EventWrite(RegHandle, Descriptor, ARGUMENT_COUNT_h, EventData); - - } - -#ifdef MCGEN_CALLOUT -MCGEN_CALLOUT(RegHandle, - Descriptor, - ARGUMENT_COUNT_h, - EventData); -#endif - - return Error; -} - -class ETWTraceStartup { - REGHANDLE TraceHandle; - PCEVENT_DESCRIPTOR EventStartDescriptor; - LPCGUID EventStartGuid; - PCEVENT_DESCRIPTOR EventEndDescriptor; - LPCGUID EventEndGuid; -public: - ETWTraceStartup(REGHANDLE _TraceHandle, PCEVENT_DESCRIPTOR _EventStartDescriptor, LPCGUID _EventStartGuid, PCEVENT_DESCRIPTOR _EventEndDescriptor, LPCGUID _EventEndGuid) { - TraceHandle = _TraceHandle; - EventStartDescriptor = _EventStartDescriptor; - EventEndDescriptor = _EventEndDescriptor; - EventStartGuid = _EventStartGuid; - EventEndGuid = _EventEndGuid; - StartupTraceEvent(TraceHandle, EventStartDescriptor, EventStartGuid); - } - ~ETWTraceStartup() { - StartupTraceEvent(TraceHandle, EventEndDescriptor, EventEndGuid); - } - static void StartupTraceEvent(REGHANDLE _TraceHandle, PCEVENT_DESCRIPTOR _EventDescriptor, LPCGUID _EventGuid) { - EVENT_DESCRIPTOR desc = *_EventDescriptor; - if(ETW_TRACING_ENABLED(MICROSOFT_WINDOWS_DOTNETRUNTIME_PRIVATE_PROVIDER_Context, desc)) - { - CoMofTemplate_h(MICROSOFT_WINDOWS_DOTNETRUNTIME_PRIVATE_PROVIDER_Context.RegistrationHandle, _EventDescriptor, _EventGuid, GetClrInstanceId()); - } - } -}; -// "mc.exe -MOF" already generates this block for XP-suported builds inside ClrEtwAll.h; -// on Vista+ builds, mc is run without -MOF, and we still have code that depends on it, so -// we manually place it here. -FORCEINLINE -BOOLEAN __stdcall -McGenEventTracingEnabled( - __in PMCGEN_TRACE_CONTEXT EnableInfo, - __in PCEVENT_DESCRIPTOR EventDescriptor - ) -{ - - if(!EnableInfo){ - return FALSE; - } - - - // - // Check if the event Level is lower than the level at which - // the channel is enabled. - // If the event Level is 0 or the channel is enabled at level 0, - // all levels are enabled. - // - - if ((EventDescriptor->Level <= EnableInfo->Level) || // This also covers the case of Level == 0. - (EnableInfo->Level == 0)) { - - // - // Check if Keyword is enabled - // - - if ((EventDescriptor->Keyword == (ULONGLONG)0) || - ((EventDescriptor->Keyword & EnableInfo->MatchAnyKeyword) && - ((EventDescriptor->Keyword & EnableInfo->MatchAllKeyword) == EnableInfo->MatchAllKeyword))) { - return TRUE; - } - } - - return FALSE; -} - - -ETW_INLINE -ULONG -ETW::SamplingLog::SendStackTrace( - MCGEN_TRACE_CONTEXT TraceContext, - PCEVENT_DESCRIPTOR Descriptor, - LPCGUID EventGuid) -{ -#define ARGUMENT_COUNT_CLRStackWalk 5 - ULONG Result = ERROR_SUCCESS; -typedef struct _MCGEN_TRACE_BUFFER { - EVENT_TRACE_HEADER Header; - EVENT_DATA_DESCRIPTOR EventData[ARGUMENT_COUNT_CLRStackWalk]; -} MCGEN_TRACE_BUFFER; - - REGHANDLE RegHandle = TraceContext.RegistrationHandle; - if(!TraceContext.IsEnabled || !McGenEventTracingEnabled(&TraceContext, Descriptor)) - { - return Result; - } - - PVOID *Stack = NULL; - UINT32 FrameCount = 0; - ETW::SamplingLog stackObj; - if(stackObj.GetCurrentThreadsCallStack(&FrameCount, &Stack) == ETW::SamplingLog::Completed) - { - UCHAR Reserved1=0, Reserved2=0; - UINT16 ClrInstanceId = GetClrInstanceId(); - MCGEN_TRACE_BUFFER TraceBuf; - PEVENT_DATA_DESCRIPTOR EventData = TraceBuf.EventData; - - EventDataDescCreate(&EventData[0], &ClrInstanceId, sizeof(const UINT16) ); - - EventDataDescCreate(&EventData[1], &Reserved1, sizeof(const UCHAR) ); - - EventDataDescCreate(&EventData[2], &Reserved2, sizeof(const UCHAR) ); - - EventDataDescCreate(&EventData[3], &FrameCount, sizeof(const unsigned int) ); - - EventDataDescCreate(&EventData[4], Stack, sizeof(PVOID) * FrameCount ); - - return EventWrite(RegHandle, Descriptor, ARGUMENT_COUNT_CLRStackWalk, EventData); - } - return Result; -}; - -#endif // FEATURE_EVENT_TRACE && !defined(FEATURE_PAL) -#ifdef FEATURE_EVENT_TRACE -#ifdef _TARGET_X86_ -struct CallStackFrame -{ - struct CallStackFrame* m_Next; - SIZE_T m_ReturnAddress; -}; -#endif // _TARGET_X86_ -#endif // FEATURE_EVENT_TRACE - -#if defined(FEATURE_EVENT_TRACE) && !defined(FEATURE_PAL) -FORCEINLINE -BOOLEAN __stdcall -McGenEventProviderEnabled( - __in PMCGEN_TRACE_CONTEXT Context, - __in UCHAR Level, - __in ULONGLONG Keyword - ) -{ - if(!Context) { - return FALSE; - } - - // - // Check if the event Level is lower than the level at which - // the channel is enabled. - // If the event Level is 0 or the channel is enabled at level 0, - // all levels are enabled. - // - - if ((Level <= Context->Level) || // This also covers the case of Level == 0. - (Context->Level == 0)) { - - // - // Check if Keyword is enabled - // - - if ((Keyword == (ULONGLONG)0) || - ((Keyword & Context->MatchAnyKeyword) && - ((Keyword & Context->MatchAllKeyword) == Context->MatchAllKeyword))) { - return TRUE; - } - } - return FALSE; -} -#endif // FEATURE_EVENT_TRACE && !defined(FEATURE_PAL) - - -#endif // !FEATURE_REDHAWK - -// These parts of the ETW namespace are common for both FEATURE_REDHAWK and -// !FEATURE_REDHAWK builds. - - -struct ProfilingScanContext; -class Object; - -namespace ETW -{ - // Class to wrap the logging of threads (runtime and rundown providers) - class ThreadLog - { - private: - static DWORD GetEtwThreadFlags(Thread * pThread); - - public: - static VOID FireThreadCreated(Thread * pThread); - static VOID FireThreadDC(Thread * pThread); - }; -}; - - -#endif //_ETWTRACER_HXX_ diff --git a/src/inc/ex.h b/src/inc/ex.h deleted file mode 100644 index 6497da027..000000000 --- a/src/inc/ex.h +++ /dev/null @@ -1,1492 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - - -#if !defined(_EX_H_) -#define _EX_H_ - -#ifdef FEATURE_PAL -#define EX_TRY_HOLDER \ - HardwareExceptionHolder \ - NativeExceptionHolderCatchAll __exceptionHolder; \ - __exceptionHolder.Push(); \ - -#else // FEATURE_PAL -#define EX_TRY_HOLDER -#endif // FEATURE_PAL - -#include "sstring.h" -#include "crtwrap.h" -#include "winwrap.h" -#include "corerror.h" -#include "stresslog.h" -#include "genericstackprobe.h" -#include "staticcontract.h" -#include "entrypoints.h" - -#if !defined(_DEBUG_IMPL) && defined(_DEBUG) && !defined(DACCESS_COMPILE) -#define _DEBUG_IMPL 1 -#endif - - -//=========================================================================================== -// These abstractions hide the difference between legacy desktop CLR's (that don't support -// side-by-side-inproc and rely on a fixed SEH code to identify managed exceptions) and -// new CLR's that support side-by-side inproc. -// -// The new CLR's use a different set of SEH codes to avoid conflicting with the legacy CLR's. -// In addition, to distinguish between EH's raised by different inproc instances of the CLR, -// the module handle of the owning CLR is stored in ExceptionRecord.ExceptionInformation[4]. -// -// (Note: all existing SEH's use either only slot [0] or no slots at all. We are leaving -// slots [1] thru [3] open for future expansion.) -//=========================================================================================== - -// Is this exception code one of the special CLR-specific SEH codes that participate in the -// instance-tagging scheme? -BOOL IsInstanceTaggedSEHCode(DWORD dwExceptionCode); - - -// This set of overloads generates the NumberParameters and ExceptionInformation[] array to -// pass to RaiseException(). -// -// Parameters: -// exceptionArgs: a fixed-size array of size INSTANCE_TAGGED_SEH_PARAM_ARRAY_SIZE. -// This will get filled in by this function. (The module handle goes -// in the last slot if this is a side-by-side-inproc enabled build.) -// -// exceptionArg1... up to four arguments that go in slots [0]..[3]. These depends -// the specific requirements of your exception code. -// -// Returns: -// The NumberParameters to pass to RaiseException(). -// -// Basically, this is either INSTANCE_TAGGED_SEH_PARAM_ARRAY_SIZE or the count of your -// fixed arguments depending on whether this tagged-SEH-enabled build. -// -// This function is not permitted to fail. - -#define INSTANCE_TAGGED_SEH_PARAM_ARRAY_SIZE 5 -DWORD MarkAsThrownByUs(/*out*/ ULONG_PTR exceptionArgs[INSTANCE_TAGGED_SEH_PARAM_ARRAY_SIZE]); -DWORD MarkAsThrownByUs(/*out*/ ULONG_PTR exceptionArgs[INSTANCE_TAGGED_SEH_PARAM_ARRAY_SIZE], ULONG_PTR arg0); -// (the existing system can support more overloads up to 4 fixed arguments but we don't need them at this time.) - - -// Given an exception record, checks if it's exception code matches a specific exception code -// *and* whether it was tagged by the calling instance of the CLR. -// -// If this is a non-tagged-SEH-enabled build, it is blindly assumed to be tagged by the -// calling instance of the CLR. -BOOL WasThrownByUs(const EXCEPTION_RECORD *pcER, DWORD dwExceptionCode); - - -//----------------------------------------------------------------------------------- -// The following group wraps the basic abstracts specifically for EXCEPTION_COMPLUS. -//----------------------------------------------------------------------------------- -BOOL IsComPlusException(const EXCEPTION_RECORD *pcER); -VOID RaiseComPlusException(); - - -//=========================================================================================== -//=========================================================================================== - - -//------------------------------------------------------------------------------------------- -// This routine will generate the most descriptive possible error message for an hresult. -// It will generate at minimum the hex value. It will also try to generate the symbolic name -// (E_POINTER) and the friendly description (from the message tables.) -// -// bNoGeekStuff suppresses hex HR codes. Use this sparingly as most error strings generated by the -// CLR are aimed at developers, not end-users. -//------------------------------------------------------------------------------------------- -void GetHRMsg(HRESULT hresult, SString &result, BOOL bNoGeekStuff = FALSE); - - -//------------------------------------------------------------------------------------------- -// Similar to GetHRMsg but phrased for top-level exception message. -//------------------------------------------------------------------------------------------- -void GenerateTopLevelHRExceptionMessage(HRESULT hresult, SString &result); - - -// --------------------------------------------------------------------------- -// We save current ExceptionPointers using VectoredExceptionHandler. The save data is only valid -// duing exception handling. GetCurrentExceptionPointers returns the saved data. -// --------------------------------------------------------------------------- -void GetCurrentExceptionPointers(PEXCEPTION_POINTERS pExceptionInfo); - -// --------------------------------------------------------------------------- -// We save current ExceptionPointers using VectoredExceptionHandler. The save data is only valid -// duing exception handling. GetCurrentExceptionCode returns the current exception code. -// --------------------------------------------------------------------------- -DWORD GetCurrentExceptionCode(); - -// --------------------------------------------------------------------------- -// We save current ExceptionPointers using VectoredExceptionHandler. The save data is only valid -// duing exception handling. Return TRUE if the current exception is hard or soft SO. -// --------------------------------------------------------------------------- -bool IsCurrentExceptionSO(); - -// --------------------------------------------------------------------------- -// Return TRUE if the current exception is hard( or soft) SO. Soft SO -// is defined when the stack probing code is enabled (FEATURE_STACK_PROBE) -// --------------------------------------------------------------------------- -bool IsSOExceptionCode(DWORD exceptionCode); - -// --------------------------------------------------------------------------- -// Standard exception hierarchy & infrastructure for library code & EE -// --------------------------------------------------------------------------- - -// --------------------------------------------------------------------------- -// Exception class. Abstract root exception of our hierarchy. -// --------------------------------------------------------------------------- - -class Exception; -class SEHException; - - -// Exception hierarchy: -/* GetInstanceType -Exception - | - |-> HRException Y - | | - | |-> HRMsgException - | |-> COMException - | - |-> SEHException Y - | - |-> DelegatingException Y - | - |-> StackOverflowException Y - | - |-> OutOfMemoryException Y - | - |-> CLRException Y - | - |-> EEException Y - | | - | |-> EEMessageException - | | - | |-> EEResourceException - | | - | |-> EECOMException - | | - | |-> EEFieldException - | | - | |-> EEMethodException - | | - | |-> EEArgumentException - | | - | |-> EETypeLoadException - | | - | |-> EEFileLoadException - | - |-> ObjrefException Y - | - |-> CLRLastThrownObjectException Y -*/ - -class Exception -{ - friend bool DebugIsEECxxExceptionPointer(void* pv); - - private: - static const int c_type = 0x524f4f54; // 'ROOT' - static Exception * g_OOMException; - static Exception * g_SOException; - - protected: - Exception *m_innerException; - - public: - Exception() {LIMITED_METHOD_DAC_CONTRACT; m_innerException = NULL;} - virtual ~Exception() {LIMITED_METHOD_DAC_CONTRACT; if (m_innerException != NULL) Exception::Delete(m_innerException); } - virtual BOOL IsDomainBound() {return m_innerException!=NULL && m_innerException->IsDomainBound();} ; - virtual HRESULT GetHR() = 0; - virtual void GetMessage(SString &s); - virtual IErrorInfo *GetErrorInfo() { LIMITED_METHOD_CONTRACT; return NULL; } - virtual HRESULT SetErrorInfo() { LIMITED_METHOD_CONTRACT; return S_OK; } - void SetInnerException(Exception * pInnerException) { LIMITED_METHOD_CONTRACT; m_innerException = pInnerException; } - - // Dynamic type query for catchers - static int GetType() { LIMITED_METHOD_CONTRACT; return c_type; } - // !!! If GetInstanceType is implemented, IsSameInstanceType should be implemented - virtual int GetInstanceType() = 0; - virtual BOOL IsType(int type) {LIMITED_METHOD_CONTRACT; return type == c_type; } - - // This is used in CLRException::GetThrowable to detect if we are in a recursive situation. - virtual BOOL IsSameInstanceType(Exception *pException) = 0; - - // Will create a new instance of the Exception. Note that this will - // be free of app domain or thread affinity. Not every type of exception - // can be cloned with full fidelity. - virtual Exception *Clone(); - - // DomainBoundClone is a specialized form of cloning which is guaranteed - // to provide full fidelity. However, the result is bound to the current - // app domain and should not be leaked. - Exception *DomainBoundClone(); - - class HandlerState - { - enum CaughtFlags - { - Caught = 1, - CaughtSO = 2, - CaughtCxx = 4, - }; - - DWORD m_dwFlags; - public: - Exception* m_pExceptionPtr; - - HandlerState(); - - void CleanupTry(); - void SetupCatch(INDEBUG_COMMA(__in_z const char * szFile) int lineNum, bool fVMInitialized = true); - void SucceedCatch(); - - BOOL DidCatch() { return (m_dwFlags & Caught); } - void SetCaught() { m_dwFlags |= Caught; } - - BOOL DidCatchSO() { return (m_dwFlags & CaughtSO); } - void SetCaughtSO() { m_dwFlags |= CaughtSO; } - - BOOL DidCatchCxx() { return (m_dwFlags & CaughtCxx); } - void SetCaughtCxx() { m_dwFlags |= CaughtCxx; } - }; - - // Is this exception type considered "uncatchable"? - BOOL IsTerminal(); - - // Is this exception type considered "transient" (would a retry possibly succeed)? - BOOL IsTransient(); - static BOOL IsTransient(HRESULT hr); - - // Get an HRESULT's source representation, if known - static LPCSTR GetHRSymbolicName(HRESULT hr); - - static Exception* GetOOMException(); - - // Preallocated exceptions: If there is a preallocated instance of some - // subclass of Exception, override this function and return a correct - // value. The default implementation returns constant FALSE - virtual BOOL IsPreallocatedException(); - BOOL IsPreallocatedOOMException(); - - static void Delete(Exception* pvMemory); - -protected: - - // This virtual method must be implemented by any non abstract Exception - // derived class. It must allocate a NEW exception of the identical type and - // copy all the relevant fields from the current exception to the new one. - // It is NOT responsible however for copying the inner exception. This - // will be handled by the base Exception class. - virtual Exception *CloneHelper(); - - // This virtual method must be implemented by Exception subclasses whose - // DomainBoundClone behavior is different than their normal clone behavior. - // It must allocate a NEW exception of the identical type and - // copy all the relevant fields from the current exception to the new one. - // It is NOT responsible however for copying the inner exception. This - // will be handled by the base Exception class. - virtual Exception *DomainBoundCloneHelper() { return CloneHelper(); } -}; - -#if 1 -template -inline void Exception__Delete(T* pvMemory); - -template <> -inline void Exception__Delete(Exception* pvMemory) -{ - Exception::Delete(pvMemory); -} - -NEW_WRAPPER_TEMPLATE1(ExceptionHolderTemplate, Exception__Delete<_TYPE>); -typedef ExceptionHolderTemplate ExceptionHolder; -#else - -//------------------------------------------------------------------------------ -// class ExceptionHolder -// -// This is a very lightweight holder class for use inside the EX_TRY family -// of macros. It is based on the standard Holder classes, but has been -// highly specialized for this one function, so that extra code can be -// removed, and the resulting code can be simple enough for all of the -// non-exceptional-case code to be inlined. -class ExceptionHolder -{ -private: - Exception *m_value; - BOOL m_acquired; - -public: - FORCEINLINE ExceptionHolder(Exception *pException = NULL, BOOL take = TRUE) - : m_value(pException) - { - m_acquired = pException && take; - } - - FORCEINLINE ~ExceptionHolder() - { - if (m_acquired) - { - Exception::Delete(m_value); - } - } - - Exception* operator->() { return m_value; } - - void operator=(Exception *p) - { - Release(); - m_value = p; - Acquire(); - } - - BOOL IsNull() { return m_value == NULL; } - - operator Exception*() { return m_value; } - - Exception* GetValue() { return m_value; } - - void SuppressRelease() { m_acquired = FALSE; } - -private: - void Acquire() - { - _ASSERTE(!m_acquired); - - if (!IsNull()) - { - m_acquired = TRUE; - } - } - void Release() - { - if (m_acquired) - { - _ASSERTE(!IsNull()); - Exception::Delete(m_value); - m_acquired = FALSE; - } - } - -}; - -#endif - -// --------------------------------------------------------------------------- -// HRException class. Implements exception API for exceptions generated from HRESULTs -// --------------------------------------------------------------------------- - -class HRException : public Exception -{ - friend bool DebugIsEECxxExceptionPointer(void* pv); - - protected: - HRESULT m_hr; - - public: - HRException(); - HRException(HRESULT hr); - - static const int c_type = 0x48522020; // 'HR ' - - // Dynamic type query for catchers - static int GetType() {LIMITED_METHOD_DAC_CONTRACT; return c_type; } - virtual int GetInstanceType() { LIMITED_METHOD_CONTRACT; return c_type; } - virtual BOOL IsType(int type) { WRAPPER_NO_CONTRACT; return type == c_type || Exception::IsType(type); } - // Virtual overrides - HRESULT GetHR(); - - BOOL IsSameInstanceType(Exception *pException) - { - WRAPPER_NO_CONTRACT; - return pException->GetInstanceType() == GetType() && pException->GetHR() == m_hr; - } - - protected: - virtual Exception *CloneHelper() - { - WRAPPER_NO_CONTRACT; - return new HRException(m_hr); - } -}; - -// --------------------------------------------------------------------------- -// HRMessageException class. Implements exception API for exceptions -// generated from HRESULTs, and includes in info message. -// --------------------------------------------------------------------------- - -class HRMsgException : public HRException -{ - friend bool DebugIsEECxxExceptionPointer(void* pv); - - protected: - SString m_msg; - - public: - HRMsgException(); - HRMsgException(HRESULT hr, SString const &msg); - - // Virtual overrides - void GetMessage(SString &s); - - protected: - virtual Exception *CloneHelper() - { - WRAPPER_NO_CONTRACT; - return new HRMsgException(m_hr, m_msg); - } -}; - -// --------------------------------------------------------------------------- -// COMException class. Implements exception API for standard COM-based error info -// --------------------------------------------------------------------------- - -class COMException : public HRException -{ - friend bool DebugIsEECxxExceptionPointer(void* pv); - - private: - IErrorInfo *m_pErrorInfo; - - public: - COMException(); - COMException(HRESULT hr) ; - COMException(HRESULT hr, IErrorInfo *pErrorInfo); - ~COMException(); - - // Virtual overrides - IErrorInfo *GetErrorInfo(); - void GetMessage(SString &result); - - protected: - virtual Exception *CloneHelper() - { - WRAPPER_NO_CONTRACT; - return new COMException(m_hr, m_pErrorInfo); - } -}; - -// --------------------------------------------------------------------------- -// SEHException class. Implements exception API for SEH exception info -// --------------------------------------------------------------------------- - -class SEHException : public Exception -{ - friend bool DebugIsEECxxExceptionPointer(void* pv); - - public: - EXCEPTION_RECORD m_exception; - - SEHException(); - SEHException(EXCEPTION_RECORD *pRecord, T_CONTEXT *pContext = NULL); - - static const int c_type = 0x53454820; // 'SEH ' - - // Dynamic type query for catchers - static int GetType() {LIMITED_METHOD_CONTRACT; return c_type; } - virtual int GetInstanceType() { LIMITED_METHOD_CONTRACT; return c_type; } - virtual BOOL IsType(int type) { WRAPPER_NO_CONTRACT; return type == c_type || Exception::IsType(type); } - - BOOL IsSameInstanceType(Exception *pException) - { - WRAPPER_NO_CONTRACT; - return pException->GetInstanceType() == GetType() && pException->GetHR() == GetHR(); - } - - // Virtual overrides - HRESULT GetHR(); - IErrorInfo *GetErrorInfo(); - void GetMessage(SString &result); - - protected: - virtual Exception *CloneHelper() - { - WRAPPER_NO_CONTRACT; - return new SEHException(&m_exception); - } -}; - -// --------------------------------------------------------------------------- -// DelegatingException class. Implements exception API for "foreign" exceptions. -// --------------------------------------------------------------------------- - -class DelegatingException : public Exception -{ - Exception *m_delegatedException; - Exception* GetDelegate(); - - enum {DELEGATE_NOT_YET_SET = -1}; - bool IsDelegateSet() {LIMITED_METHOD_DAC_CONTRACT; return m_delegatedException != (Exception*)DELEGATE_NOT_YET_SET; } - bool IsDelegateValid() {LIMITED_METHOD_DAC_CONTRACT; return IsDelegateSet() && m_delegatedException != NULL; } - - public: - - DelegatingException(); - ~DelegatingException(); - - static const int c_type = 0x44454C20; // 'DEL ' - - // Dynamic type query for catchers - static int GetType() {LIMITED_METHOD_CONTRACT; return c_type; } - virtual int GetInstanceType() { LIMITED_METHOD_CONTRACT; return c_type; } - virtual BOOL IsType(int type) { WRAPPER_NO_CONTRACT; return type == c_type || Exception::IsType(type); } - - BOOL IsSameInstanceType(Exception *pException) - { - WRAPPER_NO_CONTRACT; - return pException->GetInstanceType() == GetType() && pException->GetHR() == GetHR(); - } - - // Virtual overrides - virtual BOOL IsDomainBound() {return Exception::IsDomainBound() ||(m_delegatedException!=NULL && m_delegatedException->IsDomainBound());} ; - HRESULT GetHR(); - IErrorInfo *GetErrorInfo(); - void GetMessage(SString &result); - virtual Exception *Clone(); - - protected: - virtual Exception *CloneHelper() - { - WRAPPER_NO_CONTRACT; - return new DelegatingException(); - } -}; - -//------------------------------------------------------------------------------ -// class OutOfMemoryException -// -// While there could be any number of instances of this class, there is one -// special instance, the pre-allocated OOM exception. Storage for that -// instance is allocated in the image, so we can always obtain it, even -// in low memory situations. -// Note that, in fact, there is only one instance. -//------------------------------------------------------------------------------ -class OutOfMemoryException : public Exception -{ - private: - static const int c_type = 0x4F4F4D20; // 'OOM ' - BOOL bIsPreallocated; - - public: - OutOfMemoryException() : bIsPreallocated(FALSE) {} - OutOfMemoryException(BOOL b) : bIsPreallocated(b) {} - - // Dynamic type query for catchers - static int GetType() {LIMITED_METHOD_CONTRACT; return c_type; } - virtual int GetInstanceType() { LIMITED_METHOD_CONTRACT; return c_type; } - BOOL IsType(int type) { WRAPPER_NO_CONTRACT; return type == c_type || Exception::IsType(type); } - - BOOL IsSameInstanceType(Exception *pException) - { - WRAPPER_NO_CONTRACT; - return pException->GetInstanceType() == GetType(); - } - - HRESULT GetHR() {LIMITED_METHOD_DAC_CONTRACT; return E_OUTOFMEMORY; } - void GetMessage(SString &result) { WRAPPER_NO_CONTRACT; result.SetASCII("Out Of Memory"); } - - virtual Exception *Clone(); - - virtual BOOL IsPreallocatedException() { return bIsPreallocated; } -}; - -template -class CAutoTryCleanup -{ -public: - DEBUG_NOINLINE CAutoTryCleanup(STATETYPE& refState) : - m_refState(refState) - { - SCAN_SCOPE_BEGIN; - STATIC_CONTRACT_THROWS; - STATIC_CONTRACT_SUPPORTS_DAC; - -#ifdef ENABLE_CONTRACTS_IMPL - // This is similar to ClrTryMarkerHolder. We're marking that its okay to throw on this thread now because - // we're within a try block. We fold this into here strictly for performance reasons... we have one - // stack-allocated object do the work. - m_pClrDebugState = GetClrDebugState(); - m_oldOkayToThrowValue = m_pClrDebugState->IsOkToThrow(); - m_pClrDebugState->SetOkToThrow(); -#endif - } - - DEBUG_NOINLINE ~CAutoTryCleanup() - { - SCAN_SCOPE_END; - WRAPPER_NO_CONTRACT; - - m_refState.CleanupTry(); - -#ifdef ENABLE_CONTRACTS_IMPL - // Restore the original OkayToThrow value since we're leaving the try block. - - m_pClrDebugState->SetOkToThrow( m_oldOkayToThrowValue ); -#endif // ENABLE_CONTRACTS_IMPL - } - -protected: - STATETYPE& m_refState; - -#ifdef ENABLE_CONTRACTS_DATA -private: - BOOL m_oldOkayToThrowValue; - ClrDebugState *m_pClrDebugState; -#endif -}; - -// --------------------------------------------------------------------------- -// Throw/Catch macros -// -// Usage: -// -// EX_TRY -// { -// EX_THROW(HRException, (E_FAIL)); -// } -// EX_CATCH -// { -// Exception *e = GET_EXCEPTION(); -// EX_RETHROW; -// } -// EX_END_CATCH(RethrowTerminalExceptions, RethrowTransientExceptions or SwallowAllExceptions) -// -// --------------------------------------------------------------------------- - -// --------------------------------------------------------------------------- -// #NO_HOST_CPP_EH_ONLY -// -// The EX_CATCH* macros defined below can work one of two ways: -// 1. They catch all exceptions, both C++ and SEH exceptions. -// 2. They catch only C++ exceptions. -// -// Which way they are defined depends on what sort of handling of SEH -// exceptions, like AV's, you wish to have in your DLL. In general we -// do not typically want to catch and swallow AV's. -// -// By default, the macros catch all exceptions. This is how they work when -// compiled into the primary runtime DLL (clr.dll). This is reasonable for -// the CLR becuase it needs to also catch managed exceptions, which are SEH -// exceptions, and because that DLL also includes a vectored exception -// handler that will take down the process on any AV within clr.dll. -// -// But for uses of these macros outside of the CLR DLL there are other -// possibilities. If a DLL only uses facilities in Utilcode that throw the -// C++ exceptions defined above, and never needs to catch a managed exception, -// then that DLL should setup the macros to only catch C++ exceptions. That -// way, AV's are not accidentally swallowed and hidden. -// -// On the other hand, if a DLL needs to catch managed exceptions, then it has -// no choice but to also catch all SEH exceptions, including AV's. In that case -// the DLL should also include a vectored handler, like CLR.dll, to take the -// process down on an AV. -// -// The behavior difference is controled by NO_HOST_CPP_EH_ONLY. When defined, -// the EX_CATCH* macros only catch C++ exceptions. When not defined, they catch -// C++ and SEH exceptions. -// -// Note: use of NO_HOST_CPP_EH_ONLY is only valid outside the primary CLR DLLs. -// Thus it is an error to attempt to define it without also defining SELF_NO_HOST. -// --------------------------------------------------------------------------- - -#if defined(NO_HOST_CPP_EH_ONLY) && !defined(SELF_NO_HOST) -#error It is incorrect to attempt to have C++-only EH macros when hosted. This is only valid for components outside the runtime DLLs. -#endif - -//----------------------------------------------------------------------- -// EX_END_CATCH has a mandatory argument which is one of "RethrowTerminalExceptions", -// "RethrowTransientExceptions", or "SwallowAllExceptions". -// -// If an exception is considered "terminal" (e->IsTerminal()), it should normally -// be allowed to proceed. Hence, most of the time, you should use RethrowTerminalExceptions. -// -// In some cases you will want transient exceptions (terminal plus things like -// resource exhaustion) to proceed as well. Use RethrowTransientExceptions for this cas. -// -// If you have a good reason to use SwallowAllExceptions, (e.g. a hard COM interop boundary) -// use one of the higher level macros for this if available, or consider developing one. -// Otherwise, clearly document why you're swallowing terminal exceptions. Raw uses of -// SwallowAllExceptions will cause the cleanup police to come knocking on your door -// at some point. -// -// A lot of existing TRY's swallow terminals right now simply because there is -// backout code following the END_CATCH that has to be executed. The solution is -// to replace that backout code with holder objects. - - -// This is a rotten way to define an enum but as long as we're treating -// "if (optimizabletoconstant)" warnings as fatal errors, we have little choice. - -//----------------------------------------------------------------------- - -#define RethrowTransientExceptions \ - if (GET_EXCEPTION()->IsTransient()) \ - { \ - EX_RETHROW; \ - } \ - -#define RethrowSOExceptions \ - if (__state.DidCatchSO()) \ - { \ - STATIC_CONTRACT_THROWS_TERMINAL; \ - EX_RETHROW; \ - } \ - - -// Don't use this - use RethrowCorruptingExceptions (see below) instead. -#define SwallowAllExceptions ; - -////////////////////////////////////////////////////////////////////// -// -// Corrupted State Exception Support -// -///////////////////////////////////////////////////////////////////// - -#ifdef FEATURE_CORRUPTING_EXCEPTIONS - -#define CORRUPTING_EXCEPTIONS_ONLY(expr) expr -#define COMMA_CORRUPTING_EXCEPTIONS_ONLY(expr) ,expr - -// EX_END_CATCH has been modified to not swallow Corrupting Exceptions (CE) when one of the -// following arguments are passed to it: -// -// 1) RethrowTerminalExceptions - rethrows both terminal and corrupting exceptions -// 2) RethrowCorruptingExceptions - swallows all exceptions exception corrupting exceptions. This SHOULD BE USED instead of SwallowAllExceptions. -// 3) RethrowTerminalExceptionsEx - same as (1) but rethrow of CE can be controlled via a condition. -// 4) RethrowCorruptingExceptionsEx - same as (2) but rethrow of CE can be controlled via a condition. -// -// By default, if a CE is encountered when one of the above policies are applied, the runtime will -// ensure that the CE propagates up the stack and not get swallowed unless the developer chooses to override the behaviour. -// This can be done by using the "Ex" versions above that take a conditional which evaluates to a BOOL. In such a case, -// the CE will *only* be rethrown if the conditional evalutes to TRUE. For examples, refer to COMToCLRWorker or -// DispatchInfo::InvokeMember implementations. -// -// SET_CE_RETHROW_FLAG_FOR_EX_CATCH macros helps evaluate if the CE is to be rethrown or not. This has been redefined in -// Clrex.h to add the condition of evaluating the throwable as well (which is not available outside the VM folder). -// -// Typically, SET_CE_RETHROW_FLAG_FOR_EX_CATCH would rethrow a Corrupted State Exception. However, SO needs to be dealt -// with specially and this work is done during EX_CATCH, by calling SetupCatch against the handler state, and by EX_ENDTRY -// by calling HANDLE_STACKOVERFLOW_AFTER_CATCH. -// -// Passing FALSE as the second argument to IsProcessCorruptedStateException implies that SET_CE_RETHROW_FLAG_FOR_EX_CATCH -// will ensure that we dont rethrow SO and allow EX_ENDTRY to SO specific processing. If none is done, then EX_ENDTRY will -// rethrow SO. By that time stack has been reclaimed and thus, throwing SO will be safe. -// -// We also check the global override flag incase it has been set to force pre-V4 beahviour. "0" implies it has not -// been overriden. -#define SET_CE_RETHROW_FLAG_FOR_EX_CATCH(expr) (((expr == TRUE) && \ - (CLRConfig::GetConfigValue(CLRConfig::UNSUPPORTED_legacyCorruptedStateExceptionsPolicy) == 0) && \ - IsProcessCorruptedStateException(GetCurrentExceptionCode(), FALSE))) - -// This rethrow policy can be used in EX_END_CATCH to swallow all exceptions except the corrupting ones. -// This macro can be used to rethrow the CE based upon a BOOL condition. -#define RethrowCorruptingExceptionsEx(expr) \ - if (SET_CE_RETHROW_FLAG_FOR_EX_CATCH(expr)) \ - { \ - STATIC_CONTRACT_THROWS_TERMINAL; \ - EX_RETHROW; \ - } - -#define RethrowCorruptingExceptionsExAndHookRethrow(shouldRethrowExpr, aboutToRethrowExpr) \ - if (SET_CE_RETHROW_FLAG_FOR_EX_CATCH(shouldRethrowExpr)) \ - { \ - STATIC_CONTRACT_THROWS_TERMINAL; \ - aboutToRethrowExpr; \ - EX_RETHROW; \ - } - -#else // !FEATURE_CORRUPTING_EXCEPTIONS - -#define CORRUPTING_EXCEPTIONS_ONLY(expr) -#define COMMA_CORRUPTING_EXCEPTIONS_ONLY(expr) - -// When we dont have support for CE, just map it to SwallowAllExceptions -#define RethrowCorruptingExceptionsEx(expr) SwallowAllExceptions -#define RethrowCorruptingExceptionsExAndHookRethrow(shouldRethrowExpr, aboutToRethrowExpr) SwallowAllExceptions -#define SET_CE_RETHROW_FLAG_FOR_EX_CATCH(expr) !TRUE -#endif // FEATURE_CORRUPTING_EXCEPTIONS - -// Map to RethrowCorruptingExceptionsEx so that it does the "right" thing -#define RethrowCorruptingExceptions RethrowCorruptingExceptionsEx(TRUE) - -// This macro can be used to rethrow the CE based upon a BOOL condition. It will continue to rethrow terminal -// exceptions unconditionally. -#define RethrowTerminalExceptionsEx(expr) \ - if (GET_EXCEPTION()->IsTerminal() || \ - SET_CE_RETHROW_FLAG_FOR_EX_CATCH(expr)) \ - { \ - STATIC_CONTRACT_THROWS_TERMINAL; \ - EX_RETHROW; \ - } \ - - -// When applied to EX_END_CATCH, this policy will always rethrow Terminal and Corrupting exceptions if they are -// encountered. -#define RethrowTerminalExceptions RethrowTerminalExceptionsEx(TRUE) - -// Special define to be used in EEStartup that will also check for VM initialization before -// commencing on a path that may use the managed thread object. -#define RethrowTerminalExceptionsWithInitCheck \ - if ((g_fEEStarted == TRUE) && (GetThread() != NULL)) \ - { \ - RethrowTerminalExceptions \ - } - -#ifdef _DEBUG - -void ExThrowTrap(const char *fcn, const char *file, int line, const char *szType, HRESULT hr, const char *args); - -#define EX_THROW_DEBUG_TRAP(fcn, file, line, szType, hr, args) ExThrowTrap(fcn, file, line, szType, hr, args) - -#else - -#define EX_THROW_DEBUG_TRAP(fcn, file, line, szType, hr, args) - -#endif - -#define HANDLE_SO_TOLERANCE_FOR_THROW - -#define EX_THROW(_type, _args) \ - { \ - FAULT_NOT_FATAL(); \ - \ - HANDLE_SO_TOLERANCE_FOR_THROW; \ - _type * ___pExForExThrow = new _type _args ; \ - /* don't embed file names in retail to save space and avoid IP */ \ - /* a findstr /n will allow you to locate it in a pinch */ \ - STRESS_LOG3(LF_EH, LL_INFO100, "EX_THROW Type = 0x%x HR = 0x%x, " \ - INDEBUG(__FILE__) " line %d\n", _type::GetType(), \ - ___pExForExThrow->GetHR(), __LINE__); \ - EX_THROW_DEBUG_TRAP(__FUNCTION__, __FILE__, __LINE__, #_type, ___pExForExThrow->GetHR(), #_args); \ - PAL_CPP_THROW(_type *, ___pExForExThrow); \ - } - -//-------------------------------------------------------------------------------- -// Clones an exception into the current domain. Also handles special cases for -// OOM and other stuff. Making this a function so we don't inline all this logic -// every place we call EX_THROW_WITH_INNER. -//-------------------------------------------------------------------------------- -Exception *ExThrowWithInnerHelper(Exception *inner); - -// This macro will set the m_innerException into the newly created exception -// The passed in _type has to be derived from CLRException. You cannot put OOM -// as the inner exception. If we are throwing in OOM case, allocate more memory (this macro will clone) -// does not make any sense. -// -#define EX_THROW_WITH_INNER(_type, _args, _inner) \ - { \ - FAULT_NOT_FATAL(); \ - \ - HANDLE_SO_TOLERANCE_FOR_THROW; \ - Exception *_inner2 = ExThrowWithInnerHelper(_inner); \ - _type *___pExForExThrow = new _type _args ; \ - ___pExForExThrow->SetInnerException(_inner2); \ - STRESS_LOG3(LF_EH, LL_INFO100, "EX_THROW_WITH_INNER Type = 0x%x HR = 0x%x, " \ - INDEBUG(__FILE__) " line %d\n", _type::GetType(), \ - ___pExForExThrow->GetHR(), __LINE__); \ - EX_THROW_DEBUG_TRAP(__FUNCTION__, __FILE__, __LINE__, #_type, ___pExForExThrow->GetHR(), #_args); \ - PAL_CPP_THROW(_type *, ___pExForExThrow); \ - } - -//#define IsCLRException(ex) ((ex !=NULL) && ex->IsType(CLRException::GetType()) - -#define EX_TRY_IMPL EX_TRY_CUSTOM(Exception::HandlerState, , DelegatingException /* was SEHException*/) - -#define EX_TRY_CPP_ONLY EX_TRY_CUSTOM_CPP_ONLY(Exception::HandlerState, , DelegatingException /* was SEHException*/) - -#ifndef INCONTRACT -#ifdef ENABLE_CONTRACTS -#define INCONTRACT(x) x -#else -#define INCONTRACT(x) -#endif -#endif - -#define EX_TRY_CUSTOM(STATETYPE, STATEARG, DEFAULT_EXCEPTION_TYPE) \ - { \ - STATETYPE __state STATEARG; \ - typedef DEFAULT_EXCEPTION_TYPE __defaultException_t; \ - SCAN_EHMARKER(); \ - PAL_CPP_TRY \ - { \ - SCAN_EHMARKER_TRY(); \ - SCAN_EHMARKER(); \ - PAL_CPP_TRY \ - { \ - SCAN_EHMARKER_TRY(); \ - CAutoTryCleanup __autoCleanupTry(__state); \ - /* prevent annotations from being dropped by optimizations in debug */ \ - INDEBUG(static bool __alwayszero;) \ - INDEBUG(VolatileLoad(&__alwayszero);) \ - { \ - /* this is necessary for Rotor exception handling to work */ \ - DEBUG_ASSURE_NO_RETURN_BEGIN(EX_TRY) \ - EX_TRY_HOLDER \ - - -#define EX_CATCH_IMPL_EX(DerivedExceptionClass) \ - DEBUG_ASSURE_NO_RETURN_END(EX_TRY) \ - } \ - SCAN_EHMARKER_END_TRY(); \ - } \ - PAL_CPP_CATCH_DERIVED (DerivedExceptionClass, __pExceptionRaw) \ - { \ - SCAN_EHMARKER_CATCH(); \ - __state.SetCaughtCxx(); \ - __state.m_pExceptionPtr = __pExceptionRaw; \ - SCAN_EHMARKER_END_CATCH(); \ - SCAN_IGNORE_THROW_MARKER; \ - PAL_CPP_RETHROW; \ - } \ - PAL_CPP_ENDTRY \ - SCAN_EHMARKER_END_TRY(); \ - } \ - PAL_CPP_CATCH_ALL \ - { \ - SCAN_EHMARKER_CATCH(); \ - VALIDATE_BACKOUT_STACK_CONSUMPTION; \ - __defaultException_t __defaultException; \ - CHECK::ResetAssert(); \ - ExceptionHolder __pException(__state.m_pExceptionPtr); \ - /* work around unreachable code warning */ \ - if (true) { \ - DEBUG_ASSURE_NO_RETURN_BEGIN(EX_CATCH) \ - /* don't embed file names in retail to save space and avoid IP */ \ - /* a findstr /n will allow you to locate it in a pinch */ \ - __state.SetupCatch(INDEBUG_COMMA(__FILE__) __LINE__); \ - -#define EX_CATCH_IMPL EX_CATCH_IMPL_EX(Exception) - -#define EX_TRY_CUSTOM_CPP_ONLY(STATETYPE, STATEARG, DEFAULT_EXCEPTION_TYPE) \ - { \ - STATETYPE __state STATEARG; \ - typedef DEFAULT_EXCEPTION_TYPE __defaultException_t; \ - SCAN_EHMARKER(); \ - PAL_CPP_TRY \ - { \ - SCAN_EHMARKER_TRY(); \ - CAutoTryCleanup __autoCleanupTry(__state); \ - /* prevent annotations from being dropped by optimizations in debug */ \ - INDEBUG(static bool __alwayszero;) \ - INDEBUG(VolatileLoad(&__alwayszero);) \ - { \ - /* this is necessary for Rotor exception handling to work */ \ - DEBUG_ASSURE_NO_RETURN_BEGIN(EX_TRY) \ - -#define EX_CATCH_IMPL_CPP_ONLY \ - DEBUG_ASSURE_NO_RETURN_END(EX_TRY) \ - } \ - SCAN_EHMARKER_END_TRY(); \ - } \ - PAL_CPP_CATCH_DERIVED (Exception, __pExceptionRaw) \ - { \ - SCAN_EHMARKER_CATCH(); \ - __state.SetCaughtCxx(); \ - __state.m_pExceptionPtr = __pExceptionRaw; \ - SCAN_EHMARKER_END_CATCH(); \ - SCAN_IGNORE_THROW_MARKER; \ - VALIDATE_BACKOUT_STACK_CONSUMPTION; \ - __defaultException_t __defaultException; \ - CHECK::ResetAssert(); \ - ExceptionHolder __pException(__state.m_pExceptionPtr); \ - /* work around unreachable code warning */ \ - if (true) { \ - DEBUG_ASSURE_NO_RETURN_BEGIN(EX_CATCH) \ - /* don't embed file names in retail to save space and avoid IP */ \ - /* a findstr /n will allow you to locate it in a pinch */ \ - __state.SetupCatch(INDEBUG_COMMA(__FILE__) __LINE__); \ - - -// Here we finally define the EX_CATCH* macros that will be used throughout the system. -// These can catch C++ and SEH exceptions, or just C++ exceptions. -// See code:NO_HOST_CPP_EH_ONLY for more details. -// -// Note: we make it illegal to use forms that are redundant with the basic EX_CATCH -// version. I.e., in the C++ & SEH version, EX_CATCH_CPP_AND_SEH is the same as EX_CATCH. -// Likewise, in the C++ only version, EX_CATCH_CPP_ONLY is redundant with EX_CATCH. - -#ifndef NO_HOST_CPP_EH_ONLY -#define EX_TRY EX_TRY_IMPL -#define EX_CATCH EX_CATCH_IMPL -#define EX_CATCH_EX EX_CATCH_IMPL_EX -#define EX_CATCH_CPP_ONLY EX_CATCH_IMPL_CPP_ONLY -#define EX_CATCH_CPP_AND_SEH Dont_Use_EX_CATCH_CPP_AND_SEH -#else -#define EX_TRY EX_TRY_CPP_ONLY -#define EX_CATCH EX_CATCH_IMPL_CPP_ONLY -#define EX_CATCH_CPP_ONLY Dont_Use_EX_CATCH_CPP_ONLY -#define EX_CATCH_CPP_AND_SEH EX_CATCH_IMPL - -// Note: at this time we don't have a use case for EX_CATCH_EX, and we do not have -// the C++-only version of the implementation available. Thus we disallow its use at this time. -// If a real use case arises then we should go ahead and enable this. -#define EX_CATCH_EX Dont_Use_EX_CATCH_EX -#endif - -#define EX_END_CATCH_UNREACHABLE \ - DEBUG_ASSURE_NO_RETURN_END(EX_CATCH) \ - } \ - SCAN_EHMARKER_END_CATCH(); \ - UNREACHABLE(); \ - } \ - PAL_CPP_ENDTRY \ - } \ - - -// "terminalexceptionpolicy" must be one of "RethrowTerminalExceptions", -// "RethrowTransientExceptions", or "SwallowAllExceptions" - -#define EX_END_CATCH(terminalexceptionpolicy) \ - terminalexceptionpolicy; \ - __state.SucceedCatch(); \ - DEBUG_ASSURE_NO_RETURN_END(EX_CATCH) \ - } \ - SCAN_EHMARKER_END_CATCH(); \ - } \ - EX_ENDTRY \ - } \ - - -#define EX_END_CATCH_FOR_HOOK \ - __state.SucceedCatch(); \ - DEBUG_ASSURE_NO_RETURN_END(EX_CATCH) \ - ANNOTATION_HANDLER_END; \ - } \ - SCAN_EHMARKER_END_CATCH(); \ - } \ - EX_ENDTRY \ - -#define EX_ENDTRY \ - PAL_CPP_ENDTRY \ - if (__state.DidCatch()) \ - { \ - RESTORE_SO_TOLERANCE_STATE; \ - } \ - if (__state.DidCatchSO()) \ - { \ - HANDLE_STACKOVERFLOW_AFTER_CATCH; \ - } - -#define EX_RETHROW \ - { \ - __pException.SuppressRelease(); \ - PAL_CPP_RETHROW; \ - } \ - - // Define a copy of GET_EXCEPTION() that will not be redefined by clrex.h -#define GET_EXCEPTION() (__pException == NULL ? &__defaultException : __pException.GetValue()) -#define EXTRACT_EXCEPTION() (__pException.Extract()) - - -//============================================================================== -// High-level macros for common uses of EX_TRY. Try using these rather -// than the raw EX_TRY constructs. -//============================================================================== - -//=================================================================================== -// Macro for converting exceptions into HR internally. Unlike EX_CATCH_HRESULT, -// it does not set up IErrorInfo on the current thread. -// -// Usage: -// -// HRESULT hr = S_OK; -// EX_TRY -// -// EX_CATCH_HRESULT_NO_ERRORINFO(hr); -// return hr; -// -// Comments: -// Since IErrorInfo is not set up, this does not require COM interop to be started. -//=================================================================================== - -#define EX_CATCH_HRESULT_NO_ERRORINFO(_hr) \ - EX_CATCH \ - { \ - (_hr) = GET_EXCEPTION()->GetHR(); \ - _ASSERTE(FAILED(_hr)); \ - } \ - EX_END_CATCH(SwallowAllExceptions) - - -//=================================================================================== -// Macro for catching managed exception object. -// -// Usage: -// -// OBJECTREF pThrowable = NULL; -// EX_TRY -// -// EX_CATCH_THROWABLE(&pThrowable); -// -//=================================================================================== - -#define EX_CATCH_THROWABLE(ppThrowable) \ - EX_CATCH \ - { \ - if (NULL != ppThrowable) \ - { \ - *ppThrowable = GET_THROWABLE(); \ - } \ - } \ - EX_END_CATCH(SwallowAllExceptions) - - -#ifdef FEATURE_COMINTEROP - -//=================================================================================== -// Macro for defining external entrypoints such as COM interop boundaries. -// The boundary will catch all exceptions (including terminals) and convert -// them into HR/IErrorInfo pairs as appropriate. -// -// Usage: -// -// HRESULT hr = S_OK; -// EX_TRY -// -// EX_CATCH_HRESULT(hr); -// return hr; -// -// Comments: -// Note that IErrorInfo will automatically be set up on the thread if appropriate. -//=================================================================================== - -#define EX_CATCH_HRESULT(_hr) \ - EX_CATCH \ - { \ - (_hr) = GET_EXCEPTION()->GetHR(); \ - _ASSERTE(FAILED(_hr)); \ - IErrorInfo *pErr = GET_EXCEPTION()->GetErrorInfo(); \ - if (pErr != NULL) \ - { \ - SetErrorInfo(0, pErr); \ - pErr->Release(); \ - } \ - } \ - EX_END_CATCH(SwallowAllExceptions) - -//=================================================================================== -// Macro to make conditional catching more succinct. -// -// Usage: -// -// EX_TRY -// ... -// EX_CATCH_HRESULT_IF(IsHRESULTForExceptionKind(GET_EXCEPTION()->GetHR(), kFileNotFoundException)); -//=================================================================================== - -#define EX_CATCH_HRESULT_IF(HR, ...) \ - EX_CATCH \ - { \ - (HR) = GET_EXCEPTION()->GetHR(); \ - \ - /* Rethrow if condition is false. */ \ - if (!(__VA_ARGS__)) \ - EX_RETHROW; \ - \ - _ASSERTE(FAILED(HR)); \ - IErrorInfo *pErr = GET_EXCEPTION()->GetErrorInfo(); \ - if (pErr != NULL) \ - { \ - SetErrorInfo(0, pErr); \ - pErr->Release(); \ - } \ - } \ - EX_END_CATCH(SwallowAllExceptions) - -#else // FEATURE_COMINTEROP - -#define EX_CATCH_HRESULT(_hr) EX_CATCH_HRESULT_NO_ERRORINFO(_hr) - -#endif // FEATURE_COMINTEROP - -//=================================================================================== -// Macro for containing normal exceptions but letting terminal exceptions continue to propagate. -// -// Usage: -// -// EX_TRY -// { -// ...your stuff... -// } -// EX_SWALLOW_NONTERMINAL -// -// Remember, terminal exceptions (such as ThreadAbort) will still throw out of this -// block. So don't use this as a substitute for exception-safe cleanup! -//=================================================================================== - -#define EX_SWALLOW_NONTERMINAL \ - EX_CATCH \ - { \ - } \ - EX_END_CATCH(RethrowTerminalExceptions) \ - - -//=================================================================================== -// Macro for containing normal exceptions but letting transient exceptions continue to propagate. -// -// Usage: -// -// EX_TRY -// { -// ...your stuff... -// } -// EX_SWALLOW_NONTRANSIENT -// -// Terminal exceptions (such as ThreadAbort and OutOfMemory) will still throw out of this -// block. So don't use this as a substitute for exception-safe cleanup! -//=================================================================================== - -#define EX_SWALLOW_NONTRANSIENT \ - EX_CATCH \ - { \ - } \ - EX_END_CATCH(RethrowTransientExceptions) \ - - -//=================================================================================== -// Macro for observing or wrapping exceptions in flight. -// -// Usage: -// -// EX_TRY -// { -// ... your stuff ... -// } -// EX_HOOK -// { -// ... your stuff ... -// } -// EX_END_HOOK -// ... control will never get here ... -// -// -// EX_HOOK is like EX_CATCH except that you can't prevent the -// exception from being rethrown. You can throw a new exception inside the hook -// (for example, if you want to wrap the exception in flight with your own). -// But if control reaches the end of the hook, the original exception gets rethrown. -// -// Avoid using EX_HOOK for conditional backout if a destructor-based holder -// will suffice. Because these macros are implemented on top of SEH, using them will -// prevent the use of holders anywhere else inside the same function. That is, instead -// of saying this: -// -// EX_TRY // DON'T DO THIS -// { -// thing = new Thing(); -// blah -// } -// EX_HOOK -// { -// delete thing; // if it failed, we don't want to keep the Thing. -// } -// EX_END_HOOK -// -// do this: -// -// Holder thing = new Thing(); //DO THIS INSTEAD -// blah -// // If we got here, we succeeded. So tell holder we want to keep the thing. -// thing.SuppressRelease(); -// -// We won't rethrow the exception if it is a Stack Overflow exception. Instead, we'll throw a new -// exception. This will allow the stack to unwind point, and so we won't be jeopardizing a -// second stack overflow. -//=================================================================================== -#define EX_HOOK \ - EX_CATCH \ - { \ - -#define EX_END_HOOK \ - } \ - ANNOTATION_HANDLER_END; \ - if (IsCurrentExceptionSO()) \ - __state.SetCaughtSO(); \ - VM_NO_SO_INFRASTRUCTURE_CODE(_ASSERTE(!__state.DidCatchSO());) \ - if (!__state.DidCatchSO()) \ - EX_RETHROW; \ - EX_END_CATCH_FOR_HOOK; \ - SO_INFRASTRUCTURE_CODE(if (__state.DidCatchSO())) \ - SO_INFRASTRUCTURE_CODE(ThrowStackOverflow();) \ - } \ - -// --------------------------------------------------------------------------- -// Inline implementations. Pay no attention to that man behind the curtain. -// --------------------------------------------------------------------------- - -inline Exception::HandlerState::HandlerState() -{ - STATIC_CONTRACT_NOTHROW; - STATIC_CONTRACT_SO_TOLERANT; - STATIC_CONTRACT_CANNOT_TAKE_LOCK; - STATIC_CONTRACT_SUPPORTS_DAC; - - m_dwFlags = 0; - m_pExceptionPtr = NULL; - -#if defined(STACK_GUARDS_DEBUG) && defined(ENABLE_CONTRACTS_IMPL) - // If we have a debug state, use its setting for SO tolerance. The default - // is SO-tolerant if we have no debug state. Can't probe w/o debug state and - // can't enter SO-interolant mode w/o probing. - GetClrDebugState(); -#endif -} - -inline void Exception::HandlerState::CleanupTry() -{ - LIMITED_METHOD_DAC_CONTRACT; -} - -inline void Exception::HandlerState::SetupCatch(INDEBUG_COMMA(__in_z const char * szFile) int lineNum, bool fVMInitialized /* = true */) -{ - WRAPPER_NO_CONTRACT; - - if (fVMInitialized) - { - // Calling into IsCurrentExceptionSO will end up using various VM support entities (e.g. TLS slots, accessing CExecutionEngine - // implementation that accesses other VM specific data, etc) that may not be ready/initialized - // until the VM is initialized. - // - // This is particularly important when we have exceptions thrown/triggerred during runtime's initialization - // and accessing such data can result in possible recursive AV's in the runtime. - if (IsCurrentExceptionSO()) - SetCaughtSO(); - } - - /* don't embed file names in retail to save space and avoid IP */ - /* a findstr /n will allow you to locate it in a pinch */ -#ifdef _DEBUG - STRESS_LOG2(LF_EH, LL_INFO100, "EX_CATCH %s line %d\n", szFile, lineNum); -#else - STRESS_LOG1(LF_EH, LL_INFO100, "EX_CATCH line %d\n", lineNum); -#endif - - SetCaught(); -} - -inline void Exception::HandlerState::SucceedCatch() -{ - LIMITED_METHOD_DAC_CONTRACT; -} - -inline HRException::HRException() - : m_hr(E_UNEXPECTED) -{ - LIMITED_METHOD_CONTRACT; - SUPPORTS_DAC; -} - -inline HRException::HRException(HRESULT hr) - : m_hr(hr) -{ - LIMITED_METHOD_CONTRACT; - SUPPORTS_DAC; - - // Catchers assume only failing hresults - _ASSERTE(FAILED(hr)); -} - -inline HRMsgException::HRMsgException() - : HRException() -{ - LIMITED_METHOD_CONTRACT; -} - -inline HRMsgException::HRMsgException(HRESULT hr, SString const &s) - : HRException(hr), m_msg(s) -{ - WRAPPER_NO_CONTRACT; -} - -inline COMException::COMException() - : HRException(), - m_pErrorInfo(NULL) -{ - WRAPPER_NO_CONTRACT; -} - -inline COMException::COMException(HRESULT hr) - : HRException(hr), - m_pErrorInfo(NULL) -{ - LIMITED_METHOD_CONTRACT; -} - -inline COMException::COMException(HRESULT hr, IErrorInfo *pErrorInfo) - : HRException(hr), - m_pErrorInfo(pErrorInfo) -{ - LIMITED_METHOD_CONTRACT; -} - -inline SEHException::SEHException() -{ - LIMITED_METHOD_CONTRACT; - memset(&m_exception, 0, sizeof(EXCEPTION_RECORD)); -} - -inline SEHException::SEHException(EXCEPTION_RECORD *pointers, T_CONTEXT *pContext) -{ - LIMITED_METHOD_CONTRACT; - memcpy(&m_exception, pointers, sizeof(EXCEPTION_RECORD)); -} - -// The exception throwing helpers are intentionally not inlined -// Exception throwing is a rare slow codepath that should be optimized for code size - -void DECLSPEC_NORETURN ThrowHR(HRESULT hr); -void DECLSPEC_NORETURN ThrowHR(HRESULT hr, SString const &msg); -void DECLSPEC_NORETURN ThrowHR(HRESULT hr, UINT uText); -void DECLSPEC_NORETURN ThrowWin32(DWORD err); -void DECLSPEC_NORETURN ThrowLastError(); -void DECLSPEC_NORETURN ThrowOutOfMemory(); -void DECLSPEC_NORETURN ThrowStackOverflow(); -void DECLSPEC_NORETURN ThrowMessage(LPCSTR message, ...); - -#undef IfFailThrow -inline HRESULT IfFailThrow(HRESULT hr) -{ - WRAPPER_NO_CONTRACT; - - if (FAILED(hr)) - { - ThrowHR(hr); - } - - return hr; -} - -inline HRESULT IfFailThrow(HRESULT hr, SString &msg) -{ - WRAPPER_NO_CONTRACT; - - if (FAILED(hr)) - { - ThrowHR(hr, msg); - } - - return hr; -} - -inline HRESULT IfTransientFailThrow(HRESULT hr) -{ - WRAPPER_NO_CONTRACT; - - if (FAILED(hr) && Exception::IsTransient(hr)) - { - ThrowHR(hr); - } - - return hr; -} - -// Set if fatal error (like stack overflow or out of memory) occurred in this process. -GVAL_DECL(HRESULT, g_hrFatalError); - -#endif // _EX_H_ diff --git a/src/inc/factory.h b/src/inc/factory.h deleted file mode 100644 index ae618fe2d..000000000 --- a/src/inc/factory.h +++ /dev/null @@ -1,49 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - - -#ifndef _FACTORY_H_ -#define _FACTORY_H_ - -template -class Factory -{ -public: - virtual PRODUCT* Create() = 0; - virtual ~Factory() {} -}; - -template -class InlineFactory : public Factory -{ -public: - InlineFactory() : m_next(NULL), m_cProduct(0) { WRAPPER_NO_CONTRACT; } - ~InlineFactory() { WRAPPER_NO_CONTRACT; if (m_next) delete m_next; } - PRODUCT* Create(); - -private: - InlineFactory* GetNext() - { - CONTRACTL { - NOTHROW; - GC_NOTRIGGER; - } CONTRACTL_END; - - if (m_next == NULL) - { - m_next = new (nothrow) InlineFactory(); - } - - return m_next; - } - - InlineFactory* m_next; - PRODUCT m_product[MAX_FACTORY_PRODUCT]; - INT32 m_cProduct; -}; - -#include "factory.inl" - -#endif - diff --git a/src/inc/factory.inl b/src/inc/factory.inl deleted file mode 100644 index b49b90a74..000000000 --- a/src/inc/factory.inl +++ /dev/null @@ -1,32 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#ifndef _FACTORY_INL_ -#define _FACTORY_INL_ - -#include "factory.h" - -template -PRODUCT* InlineFactory::Create() -{ - WRAPPER_NO_CONTRACT; - - if (m_cProduct == MAX_FACTORY_PRODUCT) - { - InlineFactory* pNext = GetNext(); - if (pNext) - { - return pNext->Create(); - } - else - { - return NULL; - } - } - - return &m_product[m_cProduct++]; -} - -#endif - diff --git a/src/inc/fixuppointer.h b/src/inc/fixuppointer.h deleted file mode 100644 index 5a897e44e..000000000 --- a/src/inc/fixuppointer.h +++ /dev/null @@ -1,1049 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -/*****************************************************************************\ -* * -* FixupPointer.h - Fixup pointer holder types * -* * -\*****************************************************************************/ - -#ifndef _FIXUPPOINTER_H -#define _FIXUPPOINTER_H - -#include "daccess.h" - -#ifdef FEATURE_PREJIT - -//---------------------------------------------------------------------------- -// RelativePointer is pointer encoded as relative offset. It is used to reduce size of -// relocation section in NGen images. Conversion from/to RelativePointer needs -// address of the pointer ("this") converted to TADDR passed in from outside. -// Converting "this" to TADDR is not possible in the DAC transparently because -// DAC is based on exact pointers, not ranges. -// There are several flavors of conversions from/to RelativePointer: -// - GetValue/SetValue: The most common version. Assumes that the pointer is not NULL. -// - GetValueMaybeNull/SetValueMaybeNull: Pointer can be NULL. -// - GetValueAtPtr: Static version of GetValue. It is -// meant to simplify access to arrays of RelativePointers. -// - GetValueMaybeNullAtPtr -template -class RelativePointer -{ -public: - - static constexpr bool isRelative = true; - typedef PTR_TYPE type; - -#ifndef DACCESS_COMPILE - RelativePointer() - { - m_delta = (TADDR)NULL; - - _ASSERTE (IsNull()); - } -#else // DACCESS_COMPILE - RelativePointer() =delete; -#endif // DACCESS_COMPILE - - // Implicit copy/move is not allowed - // Bitwise copy is implemented by BitwiseCopyTo method - RelativePointer(const RelativePointer &) =delete; - RelativePointer(RelativePointer &&) =delete; - RelativePointer& operator = (const RelativePointer &) =delete; - RelativePointer& operator = (RelativePointer &&) =delete; - - // Returns whether the encoded pointer is NULL. - BOOL IsNull() const - { - LIMITED_METHOD_DAC_CONTRACT; - // Pointer pointing to itself is treated as NULL - return m_delta == (TADDR)NULL; - } - - // Returns value of the encoded pointer. Assumes that the pointer is not NULL. - PTR_TYPE GetValue(TADDR base) const - { - LIMITED_METHOD_DAC_CONTRACT; - PRECONDITION(!IsNull()); - return dac_cast(base + m_delta); - } - -#ifndef DACCESS_COMPILE - // Returns value of the encoded pointer. Assumes that the pointer is not NULL. - // Does not need explicit base and thus can be used in non-DAC builds only. - FORCEINLINE PTR_TYPE GetValue() const - { - LIMITED_METHOD_CONTRACT; - return GetValue((TADDR)this); - } -#endif - - // Static version of GetValue. It is meant to simplify access to arrays of pointers. - FORCEINLINE static PTR_TYPE GetValueAtPtr(TADDR base) - { - LIMITED_METHOD_DAC_CONTRACT; - return dac_cast)>(base)->GetValue(base); - } - - // Returns value of the encoded pointer. The pointer can be NULL. - PTR_TYPE GetValueMaybeNull(TADDR base) const - { - LIMITED_METHOD_DAC_CONTRACT; - - // Cache local copy of delta to avoid races when the value is changing under us. - TADDR delta = m_delta; - - if (delta == 0) - return NULL; - - return dac_cast(base + delta); - } - -#ifndef DACCESS_COMPILE - // Returns value of the encoded pointer. The pointer can be NULL. - // Does not need explicit base and thus can be used in non-DAC builds only. - FORCEINLINE PTR_TYPE GetValueMaybeNull() const - { - LIMITED_METHOD_CONTRACT; - return GetValueMaybeNull((TADDR)this); - } -#endif - - // Static version of GetValueMaybeNull. It is meant to simplify access to arrays of pointers. - FORCEINLINE static PTR_TYPE GetValueMaybeNullAtPtr(TADDR base) - { - LIMITED_METHOD_DAC_CONTRACT; - return dac_cast)>(base)->GetValueMaybeNull(base); - } - -#ifndef DACCESS_COMPILE - // Set encoded value of the pointer. Assumes that the value is not NULL. - FORCEINLINE void SetValue(PTR_TYPE addr) - { - LIMITED_METHOD_CONTRACT; - PRECONDITION(addr != NULL); - m_delta = (TADDR)addr - (TADDR)this; - } - - // Set encoded value of the pointer. The value can be NULL. - void SetValueMaybeNull(TADDR base, PTR_TYPE addr) - { - LIMITED_METHOD_CONTRACT; - if (addr == NULL) - m_delta = NULL; - else - m_delta = (TADDR)addr - (TADDR)base; - } - - // Set encoded value of the pointer. The value can be NULL. - FORCEINLINE void SetValueMaybeNull(PTR_TYPE addr) - { - LIMITED_METHOD_CONTRACT; - SetValueMaybeNull((TADDR)this, addr); - } - - FORCEINLINE void SetValueVolatile(PTR_TYPE addr) - { - LIMITED_METHOD_CONTRACT; - SetValue(addr); - } -#endif - -#ifndef DACCESS_COMPILE - void BitwiseCopyTo(RelativePointer &dest) const - { - dest.m_delta = m_delta; - } -#endif // DACCESS_COMPILE - -private: -#ifndef DACCESS_COMPILE - Volatile m_delta; -#else - TADDR m_delta; -#endif -}; - -//---------------------------------------------------------------------------- -// FixupPointer is pointer with optional indirection. It is used to reduce number -// of private pages in NGen images - cross-module pointers that written to at runtime -// are packed together and accessed via indirection. -// -// The direct flavor (lowest bit of m_addr is cleared) is user for intra-module pointers -// in NGen images, and in datastructuters allocated at runtime. -// -// The indirect mode (lowest bit of m_addr is set) is used for cross-module pointers -// in NGen images. -// - -// Friendly name for lowest bit that marks the indirection -#define FIXUP_POINTER_INDIRECTION 1 - -template -class FixupPointer -{ -public: - - static constexpr bool isRelative = false; - typedef PTR_TYPE type; - - // Returns whether the encoded pointer is NULL. - BOOL IsNull() const - { - LIMITED_METHOD_DAC_CONTRACT; - return m_addr == 0; - } - - // Returns whether the indirection cell contain fixup that has not been converted to real pointer yet. - FORCEINLINE BOOL IsTagged() const - { - LIMITED_METHOD_DAC_CONTRACT; - TADDR addr = m_addr; - if ((addr & FIXUP_POINTER_INDIRECTION) != 0) - return (*PTR_TADDR(addr - FIXUP_POINTER_INDIRECTION) & 1) != 0; - return FALSE; - } - - // Returns value of the encoded pointer. - FORCEINLINE PTR_TYPE GetValue() const - { - LIMITED_METHOD_DAC_CONTRACT; - TADDR addr = m_addr; - if ((addr & FIXUP_POINTER_INDIRECTION) != 0) - addr = *PTR_TADDR(addr - FIXUP_POINTER_INDIRECTION); - return dac_cast(addr); - } - - // Returns value of the encoded pointer. - FORCEINLINE PTR_TYPE GetValueMaybeNull() const - { - LIMITED_METHOD_DAC_CONTRACT; - return GetValue(); - } - -#ifndef DACCESS_COMPILE - // Returns the pointer to the indirection cell. - PTR_TYPE * GetValuePtr() const - { - LIMITED_METHOD_CONTRACT; - TADDR addr = m_addr; - if ((addr & FIXUP_POINTER_INDIRECTION) != 0) - return (PTR_TYPE *)(addr - FIXUP_POINTER_INDIRECTION); - return (PTR_TYPE *)&m_addr; - } -#endif // !DACCESS_COMPILE - - // Static version of GetValue. It is meant to simplify access to arrays of pointers. - FORCEINLINE static PTR_TYPE GetValueAtPtr(TADDR base) - { - LIMITED_METHOD_DAC_CONTRACT; - return dac_cast)>(base)->GetValue(); - } - - // Static version of GetValueMaybeNull. It is meant to simplify access to arrays of pointers. - FORCEINLINE static PTR_TYPE GetValueMaybeNullAtPtr(TADDR base) - { - LIMITED_METHOD_DAC_CONTRACT; - return dac_cast)>(base)->GetValueMaybeNull(); - } - - // Returns value of the encoded pointer. - // Allows the value to be tagged. - FORCEINLINE TADDR GetValueMaybeTagged() const - { - LIMITED_METHOD_DAC_CONTRACT; - TADDR addr = m_addr; - if ((addr & FIXUP_POINTER_INDIRECTION) != 0) - addr = *PTR_TADDR(addr - FIXUP_POINTER_INDIRECTION); - return addr; - } - -#ifndef DACCESS_COMPILE - void SetValue(PTR_TYPE addr) - { - LIMITED_METHOD_CONTRACT; - m_addr = dac_cast(addr); - } - - void SetValueMaybeNull(PTR_TYPE addr) - { - LIMITED_METHOD_CONTRACT; - SetValue(addr); - } -#endif // !DACCESS_COMPILE - -private: - TADDR m_addr; -}; - -//---------------------------------------------------------------------------- -// RelativeFixupPointer is combination of RelativePointer and FixupPointer -template -class RelativeFixupPointer -{ -public: - - static constexpr bool isRelative = true; - typedef PTR_TYPE type; - -#ifndef DACCESS_COMPILE - RelativeFixupPointer() - { - SetValueMaybeNull(NULL); - } -#else // DACCESS_COMPILE - RelativeFixupPointer() =delete; -#endif // DACCESS_COMPILE - - // Implicit copy/move is not allowed - RelativeFixupPointer(const RelativeFixupPointer &) =delete; - RelativeFixupPointer(RelativeFixupPointer &&) =delete; - RelativeFixupPointer& operator = (const RelativeFixupPointer &) =delete; - RelativeFixupPointer& operator = (RelativeFixupPointer &&) =delete; - - // Returns whether the encoded pointer is NULL. - BOOL IsNull() const - { - LIMITED_METHOD_DAC_CONTRACT; - // Pointer pointing to itself is treated as NULL - return m_delta == (TADDR)NULL; - } - - // Returns whether the indirection cell contain fixup that has not been converted to real pointer yet. - FORCEINLINE BOOL IsTagged(TADDR base) const - { - LIMITED_METHOD_DAC_CONTRACT; - TADDR addr = base + m_delta; - if ((addr & FIXUP_POINTER_INDIRECTION) != 0) - return (*PTR_TADDR(addr - FIXUP_POINTER_INDIRECTION) & 1) != 0; - return FALSE; - } - - // Returns whether the indirection cell contain fixup that has not been converted to real pointer yet. - // Ignores isIndirect and offset values. - FORCEINLINE BOOL IsTaggedIndirect(TADDR base, bool isIndirect, intptr_t offset) const - { - LIMITED_METHOD_DAC_CONTRACT; - return IsTagged(base); - } - -#ifndef DACCESS_COMPILE - // Returns whether the indirection cell contain fixup that has not been converted to real pointer yet. - // Does not need explicit base and thus can be used in non-DAC builds only. - FORCEINLINE BOOL IsTagged() const - { - LIMITED_METHOD_CONTRACT; - return IsTagged((TADDR)this); - } -#endif // !DACCESS_COMPILE - - // Returns value of the encoded pointer. Assumes that the pointer is not NULL. - FORCEINLINE PTR_TYPE GetValue(TADDR base) const - { - LIMITED_METHOD_DAC_CONTRACT; - PRECONDITION(!IsNull()); - PRECONDITION(!IsTagged(base)); - TADDR addr = base + m_delta; - if ((addr & FIXUP_POINTER_INDIRECTION) != 0) - addr = *PTR_TADDR(addr - FIXUP_POINTER_INDIRECTION); - return dac_cast(addr); - } - -#ifndef DACCESS_COMPILE - // Returns value of the encoded pointer. Assumes that the pointer is not NULL. - // Does not need explicit base and thus can be used in non-DAC builds only. - FORCEINLINE PTR_TYPE GetValue() const - { - LIMITED_METHOD_CONTRACT; - return GetValue((TADDR)this); - } -#endif - - // Static version of GetValue. It is meant to simplify access to arrays of pointers. - FORCEINLINE static PTR_TYPE GetValueAtPtr(TADDR base) - { - LIMITED_METHOD_DAC_CONTRACT; - return dac_cast)>(base)->GetValue(base); - } - - // Static version of GetValue. It is meant to simplify access to arrays of pointers. - // Ignores isIndirect and offset values. - FORCEINLINE static PTR_TYPE GetValueAtPtrIndirect(TADDR base, bool isIndirect, intptr_t offset) - { - LIMITED_METHOD_DAC_CONTRACT; - return GetValueAtPtr(base); - } - - // Returns value of the encoded pointer. The pointer can be NULL. - PTR_TYPE GetValueMaybeNull(TADDR base) const - { - LIMITED_METHOD_DAC_CONTRACT; - PRECONDITION(!IsTagged(base)); - - // Cache local copy of delta to avoid races when the value is changing under us. - TADDR delta = m_delta; - - if (delta == 0) - return NULL; - - TADDR addr = base + delta; - if ((addr & FIXUP_POINTER_INDIRECTION) != 0) - addr = *PTR_TADDR(addr - FIXUP_POINTER_INDIRECTION); - return dac_cast(addr); - } - -#ifndef DACCESS_COMPILE - // Returns value of the encoded pointer. The pointer can be NULL. - // Does not need explicit base and thus can be used in non-DAC builds only. - FORCEINLINE PTR_TYPE GetValueMaybeNull() const - { - LIMITED_METHOD_CONTRACT; - return GetValueMaybeNull((TADDR)this); - } -#endif - - // Static version of GetValueMaybeNull. It is meant to simplify access to arrays of pointers. - FORCEINLINE static PTR_TYPE GetValueMaybeNullAtPtr(TADDR base) - { - LIMITED_METHOD_DAC_CONTRACT; - return dac_cast)>(base)->GetValueMaybeNull(base); - } - - // Static version of GetValueMaybeNull. It is meant to simplify access to arrays of pointers. - // Ignores isIndirect and offset values. - FORCEINLINE static PTR_TYPE GetValueMaybeNullAtPtrIndirect(TADDR base, bool isIndirect, intptr_t offset) - { - LIMITED_METHOD_DAC_CONTRACT; - return GetValueMaybeNullAtPtr(base); - } - -#ifndef DACCESS_COMPILE - // Set encoded value of the pointer. Assumes that the value is not NULL. - FORCEINLINE void SetValue(PTR_TYPE addr) - { - LIMITED_METHOD_CONTRACT; - PRECONDITION(addr != NULL); - m_delta = dac_cast(addr) - (TADDR)this; - } - - // Set encoded value of the pointer. The value can be NULL. - void SetValueMaybeNull(TADDR base, PTR_TYPE addr) - { - LIMITED_METHOD_CONTRACT; - if (addr == NULL) - m_delta = NULL; - else - m_delta = dac_cast(addr) - (TADDR)base; - } - - // Set encoded value of the pointer. The value can be NULL. - FORCEINLINE void SetValueMaybeNull(PTR_TYPE addr) - { - LIMITED_METHOD_CONTRACT; - SetValueMaybeNull((TADDR)this, addr); - } -#endif - -#ifndef DACCESS_COMPILE - // Returns the pointer to the indirection cell. - PTR_TYPE * GetValuePtr() const - { - LIMITED_METHOD_CONTRACT; - TADDR addr = ((TADDR)this) + m_delta; - _ASSERTE((addr & FIXUP_POINTER_INDIRECTION) != 0); - return (PTR_TYPE *)(addr - FIXUP_POINTER_INDIRECTION); - } - - // Returns the pointer to the indirection cell. - // Ignores isIndirect and offset values. - PTR_TYPE * GetValuePtrIndirect(bool isIndirect, intptr_t offset) const - { - LIMITED_METHOD_CONTRACT; - return GetValuePtr(); - } -#endif // !DACCESS_COMPILE - - // Returns value of the encoded pointer. Assumes that the pointer is not NULL. - // Allows the value to be tagged. - FORCEINLINE TADDR GetValueMaybeTagged(TADDR base) const - { - LIMITED_METHOD_DAC_CONTRACT; - PRECONDITION(!IsNull()); - TADDR addr = base + m_delta; - if ((addr & FIXUP_POINTER_INDIRECTION) != 0) - addr = *PTR_TADDR(addr - FIXUP_POINTER_INDIRECTION); - return addr; - } - - // Returns whether pointer is indirect. Assumes that the value is not NULL. - bool IsIndirectPtr(TADDR base) const - { - LIMITED_METHOD_DAC_CONTRACT; - PRECONDITION(!IsNull()); - - TADDR addr = base + m_delta; - - return (addr & FIXUP_POINTER_INDIRECTION) != 0; - } - -#ifndef DACCESS_COMPILE - // Returns whether pointer is indirect. Assumes that the value is not NULL. - // Does not need explicit base and thus can be used in non-DAC builds only. - bool IsIndirectPtr() const - { - LIMITED_METHOD_CONTRACT; - return IsIndirectPtr((TADDR)this); - } - - // Returns whether pointer is indirect. Assumes that the value is not NULL. - // Ignores isIndirect and offset values. - bool IsIndirectPtrIndirect(bool isIndirect, intptr_t offset) const - { - LIMITED_METHOD_DAC_CONTRACT; - return IsIndirectPtr(); - } -#endif - - // Returns whether pointer is indirect. The value can be NULL. - bool IsIndirectPtrMaybeNull(TADDR base) const - { - LIMITED_METHOD_DAC_CONTRACT; - - if (m_delta == 0) - return false; - - return IsIndirectPtr(base); - } - -#ifndef DACCESS_COMPILE - // Returns whether pointer is indirect. The value can be NULL. - // Does not need explicit base and thus can be used in non-DAC builds only. - bool IsIndirectPtrMaybeNull() const - { - LIMITED_METHOD_CONTRACT; - return IsIndirectPtrMaybeNull((TADDR)this); - } - - // Returns whether pointer is indirect. The value can be NULL. - // Ignores isIndirect and offset values. - bool IsIndirectPtrMaybeNullIndirect(bool isIndirect, intptr_t offset) const - { - LIMITED_METHOD_DAC_CONTRACT; - return IsIndirectPtrMaybeNull(); - } -#endif - -private: -#ifndef DACCESS_COMPILE - Volatile m_delta; -#else - TADDR m_delta; -#endif -}; - -// Fixup used for RelativePointer -#define IMAGE_REL_BASED_RelativePointer IMAGE_REL_BASED_RELPTR - -#endif // FEATURE_PREJIT - -//---------------------------------------------------------------------------- -// PlainPointer is simple pointer wrapper to support compilation without indirections -// This is useful for building size-constrained runtime without NGen support. -template -class PlainPointer -{ -public: - - static constexpr bool isRelative = false; - typedef PTR_TYPE type; - - // Returns whether the encoded pointer is NULL. - BOOL IsNull() const - { - LIMITED_METHOD_DAC_CONTRACT; - return m_ptr == NULL; - } - - // Returns whether the indirection cell contain fixup that has not been converted to real pointer yet. - BOOL IsTagged(TADDR base) const - { - LIMITED_METHOD_DAC_CONTRACT; - return IsTagged(); - } - - // Returns whether the indirection cell contain fixup that has not been converted to real pointer yet. - BOOL IsTagged() const - { - LIMITED_METHOD_DAC_CONTRACT; - TADDR addr = m_ptr; - if ((addr & FIXUP_POINTER_INDIRECTION) != 0) - return (*PTR_TADDR(addr - FIXUP_POINTER_INDIRECTION) & 1) != 0; - return FALSE; - } - - // Returns value of the encoded pointer. - PTR_TYPE GetValue() const - { - LIMITED_METHOD_DAC_CONTRACT; - return dac_cast(m_ptr); - } - -#ifndef DACCESS_COMPILE - // Returns the pointer to the indirection cell. - PTR_TYPE * GetValuePtr() const - { - LIMITED_METHOD_CONTRACT; - TADDR addr = m_ptr; - if ((addr & FIXUP_POINTER_INDIRECTION) != 0) - return (PTR_TYPE *)(addr - FIXUP_POINTER_INDIRECTION); - return (PTR_TYPE *)&m_ptr; - } -#endif // !DACCESS_COMPILE - - // Returns value of the encoded pointer. Assumes that the pointer is not NULL. - PTR_TYPE GetValue(TADDR base) const - { - LIMITED_METHOD_DAC_CONTRACT; - return dac_cast(m_ptr); - } - - // Static version of GetValue. It is meant to simplify access to arrays of pointers. - FORCEINLINE static PTR_TYPE GetValueAtPtr(TADDR base) - { - LIMITED_METHOD_DAC_CONTRACT; - return dac_cast)>(base)->GetValue(base); - } - - // Returns value of the encoded pointer. The pointer can be NULL. - PTR_TYPE GetValueMaybeNull() const - { - LIMITED_METHOD_DAC_CONTRACT; - return dac_cast(m_ptr); - } - - // Returns value of the encoded pointer. The pointer can be NULL. - PTR_TYPE GetValueMaybeNull(TADDR base) const - { - LIMITED_METHOD_DAC_CONTRACT; - return dac_cast(m_ptr); - } - - // Static version of GetValueMaybeNull. It is meant to simplify access to arrays of pointers. - FORCEINLINE static PTR_TYPE GetValueMaybeNullAtPtr(TADDR base) - { - LIMITED_METHOD_DAC_CONTRACT; - return dac_cast)>(base)->GetValueMaybeNull(base); - } - - // Returns whether pointer is indirect. Assumes that the value is not NULL. - bool IsIndirectPtr(TADDR base) const - { - LIMITED_METHOD_DAC_CONTRACT; - - return (m_ptr & FIXUP_POINTER_INDIRECTION) != 0; - } - -#ifndef DACCESS_COMPILE - // Returns whether pointer is indirect. Assumes that the value is not NULL. - // Does not need explicit base and thus can be used in non-DAC builds only. - bool IsIndirectPtr() const - { - LIMITED_METHOD_CONTRACT; - return IsIndirectPtr((TADDR)this); - } -#endif - - // Returns whether pointer is indirect. The value can be NULL. - bool IsIndirectPtrMaybeNull(TADDR base) const - { - LIMITED_METHOD_DAC_CONTRACT; - - return IsIndirectPtr(base); - } - -#ifndef DACCESS_COMPILE - // Returns whether pointer is indirect. The value can be NULL. - // Does not need explicit base and thus can be used in non-DAC builds only. - bool IsIndirectPtrMaybeNull() const - { - LIMITED_METHOD_CONTRACT; - return IsIndirectPtrMaybeNull((TADDR)this); - } -#endif - -#ifndef DACCESS_COMPILE - void SetValue(PTR_TYPE addr) - { - LIMITED_METHOD_CONTRACT; - m_ptr = dac_cast(addr); - } - - // Set encoded value of the pointer. Assumes that the value is not NULL. - void SetValue(TADDR base, PTR_TYPE addr) - { - LIMITED_METHOD_CONTRACT; - m_ptr = dac_cast(addr); - } - - // Static version of SetValue. It is meant to simplify access to arrays of pointers. - FORCEINLINE static void SetValueAtPtr(TADDR base, PTR_TYPE addr) - { - LIMITED_METHOD_CONTRACT; - dac_cast)>(base)->SetValue(base, addr); - } - - // Set encoded value of the pointer. The value can be NULL. - void SetValueMaybeNull(TADDR base, PTR_TYPE addr) - { - LIMITED_METHOD_CONTRACT; - m_ptr = dac_cast(addr); - } - - // Set encoded value of the pointer. The value can be NULL. - // Does not need explicit base and thus can be used in non-DAC builds only. - FORCEINLINE void SetValueMaybeNull(PTR_TYPE addr) - { - LIMITED_METHOD_CONTRACT; - return SetValueMaybeNull((TADDR)this, addr); - } - - // Static version of SetValueMaybeNull. It is meant to simplify access to arrays of pointers. - FORCEINLINE static void SetValueMaybeNullAtPtr(TADDR base, PTR_TYPE addr) - { - LIMITED_METHOD_CONTRACT; - dac_cast)>(base)->SetValueMaybeNull(base, addr); - } - - FORCEINLINE void SetValueVolatile(PTR_TYPE addr) - { - LIMITED_METHOD_CONTRACT; - VolatileStore((PTR_TYPE *)(&m_ptr), addr); - } -#endif - -private: - TADDR m_ptr; -}; - -#ifndef FEATURE_PREJIT - -#define FixupPointer PlainPointer -#define RelativePointer PlainPointer -#define RelativeFixupPointer PlainPointer - -#endif // !FEATURE_PREJIT - -//---------------------------------------------------------------------------- -// RelativePointer32 is pointer encoded as relative 32-bit offset. It is used -// to reduce both the size of the pointer itself as well as size of relocation -// section for pointers that live exlusively in NGen images. -template -class RelativePointer32 -{ -public: - - static constexpr bool isRelative = true; - typedef PTR_TYPE type; - - // Returns whether the encoded pointer is NULL. - BOOL IsNull() const - { - LIMITED_METHOD_DAC_CONTRACT; - // Pointer pointing to itself is treated as NULL - return m_delta == 0; - } - - // Returns value of the encoded pointer. Assumes that the pointer is not NULL. - PTR_TYPE GetValue(TADDR base) const - { - LIMITED_METHOD_DAC_CONTRACT; - PRECONDITION(!IsNull()); - return dac_cast(base + m_delta); - } - -#ifndef DACCESS_COMPILE - // Returns value of the encoded pointer. Assumes that the pointer is not NULL. - // Does not need explicit base and thus can be used in non-DAC builds only. - FORCEINLINE PTR_TYPE GetValue() const - { - LIMITED_METHOD_CONTRACT; - return GetValue((TADDR)this); - } -#endif - - // Static version of GetValue. It is meant to simplify access to arrays of pointers. - FORCEINLINE static PTR_TYPE GetValueAtPtr(TADDR base) - { - LIMITED_METHOD_DAC_CONTRACT; - return dac_cast)>(base)->GetValue(base); - } - - // Returns value of the encoded pointer. The pointer can be NULL. - PTR_TYPE GetValueMaybeNull(TADDR base) const - { - LIMITED_METHOD_DAC_CONTRACT; - - // Cache local copy of delta to avoid races when the value is changing under us. - TADDR delta = m_delta; - - if (delta == 0) - return NULL; - - return dac_cast(base + delta); - } - -#ifndef DACCESS_COMPILE - // Returns value of the encoded pointer. The pointer can be NULL. - // Does not need explicit base and thus can be used in non-DAC builds only. - FORCEINLINE PTR_TYPE GetValueMaybeNull() const - { - LIMITED_METHOD_CONTRACT; - return GetValueMaybeNull((TADDR)this); - } -#endif - - // Static version of GetValueMaybeNull. It is meant to simplify access to arrays of pointers. - FORCEINLINE static PTR_TYPE GetValueMaybeNullAtPtr(TADDR base) - { - LIMITED_METHOD_DAC_CONTRACT; - return dac_cast)>(base)->GetValueMaybeNull(base); - } - -private: - INT32 m_delta; -}; - -//---------------------------------------------------------------------------- -// IndirectPointer is pointer with optional indirection, similar to FixupPointer and RelativeFixupPointer. -// -// In comparison to FixupPointer, IndirectPointer's indirection is handled from outside by isIndirect flag. -// In comparison to RelativeFixupPointer, IndirectPointer's offset is a constant, -// while RelativeFixupPointer's offset is an address. -// -// IndirectPointer can contain NULL only if it is not indirect. -// -template -class IndirectPointer -{ -public: - - static constexpr bool isRelative = false; - typedef PTR_TYPE type; - - // Returns whether the encoded pointer is NULL. - BOOL IsNull() const - { - LIMITED_METHOD_DAC_CONTRACT; - return m_addr == (TADDR)NULL; - } - - // Returns whether the indirection cell contain fixup that has not been converted to real pointer yet. - // Uses isIndirect to identify, whether pointer is indirect or not. If it is, uses offset. - FORCEINLINE BOOL IsTaggedIndirect(TADDR base, bool isIndirect, intptr_t offset) const - { - LIMITED_METHOD_DAC_CONTRACT; - TADDR addr = m_addr; - if (isIndirect) - { - _ASSERTE(!IsNull()); - return (*PTR_TADDR(addr + offset) & 1) != 0; - } - return FALSE; - } - - // Returns value of the encoded pointer. - // Uses isIndirect to identify, whether pointer is indirect or not. If it is, uses offset. - FORCEINLINE PTR_TYPE GetValueIndirect(bool isIndirect, intptr_t offset) const - { - LIMITED_METHOD_DAC_CONTRACT; - TADDR addr = m_addr; - if (isIndirect) - { - _ASSERTE(!IsNull()); - addr = *PTR_TADDR(addr + offset); - } - return dac_cast(addr); - } - -#ifndef DACCESS_COMPILE - // Returns the pointer to the indirection cell. - // Uses isIndirect to identify, whether pointer is indirect or not. If it is, uses offset. - PTR_TYPE * GetValuePtrIndirect(bool isIndirect, intptr_t offset) const - { - LIMITED_METHOD_CONTRACT; - TADDR addr = m_addr; - if (isIndirect) - { - _ASSERTE(!IsNull()); - return (PTR_TYPE *)(addr + offset); - } - return (PTR_TYPE *)&m_addr; - } -#endif // !DACCESS_COMPILE - - // Static version of GetValue. It is meant to simplify access to arrays of pointers. - // Uses isIndirect to identify, whether pointer is indirect or not. If it is, uses offset. - FORCEINLINE static PTR_TYPE GetValueAtPtrIndirect(TADDR base, bool isIndirect, intptr_t offset) - { - LIMITED_METHOD_DAC_CONTRACT; - return dac_cast)>(base)->GetValueIndirect(isIndirect, offset); - } - - // Static version of GetValueMaybeNull. It is meant to simplify access to arrays of pointers. - // Uses isIndirect to identify, whether pointer is indirect or not. If it is, uses offset. - FORCEINLINE static PTR_TYPE GetValueMaybeNullAtPtrIndirect(TADDR base, bool isIndirect, intptr_t offset) - { - LIMITED_METHOD_DAC_CONTRACT; - return GetValueAtPtrIndirect(base, isIndirect, offset); - } - -#ifndef DACCESS_COMPILE - // Returns whether pointer is indirect. Assumes that the value is not NULL. - // Uses isIndirect to identify, whether pointer is indirect or not. If it is, uses offset. - bool IsIndirectPtrIndirect(bool isIndirect, intptr_t offset) const - { - LIMITED_METHOD_CONTRACT; - if (isIndirect) - _ASSERTE(!IsNull()); - return isIndirect; - } - - // Returns whether pointer is indirect. The value can be NULL. - // Uses isIndirect to identify, whether pointer is indirect or not. If it is, uses offset. - bool IsIndirectPtrMaybeNullIndirect(bool isIndirect, intptr_t offset) const - { - LIMITED_METHOD_CONTRACT; - return IsIndirectPtrIndirect(isIndirect, offset); - } -#endif // !DACCESS_COMPILE - -#ifndef DACCESS_COMPILE - // Set encoded value of the pointer. Assumes that the value is not NULL. - void SetValue(PTR_TYPE addr) - { - LIMITED_METHOD_CONTRACT; - m_addr = dac_cast(addr); - } - - // Set encoded value of the pointer. The value can be NULL. - void SetValueMaybeNull(PTR_TYPE addr) - { - LIMITED_METHOD_CONTRACT; - SetValue(addr); - } -#endif // !DACCESS_COMPILE - -private: - TADDR m_addr; -}; - -template -typename PT::type -ReadPointer(const T *base, const PT T::* pPointerFieldMember) -{ - LIMITED_METHOD_DAC_CONTRACT; - - uintptr_t offset = (uintptr_t) &(base->*pPointerFieldMember) - (uintptr_t) base; - - if (isMaybeNull) - { - return PT::GetValueMaybeNullAtPtr(dac_cast(base) + offset); - } - else - { - return PT::GetValueAtPtr(dac_cast(base) + offset); - } -} - -template -typename PT::type -ReadPointer(const T *base, const PT T::* pPointerFieldMember, bool isIndirect) -{ - LIMITED_METHOD_DAC_CONTRACT; - - uintptr_t offset = (uintptr_t) &(base->*pPointerFieldMember) - (uintptr_t) base; - - if (isMaybeNull) - { - return PT::GetValueMaybeNullAtPtrIndirect(dac_cast(base) + offset, isIndirect, offset); - } - else - { - return PT::GetValueAtPtrIndirect(dac_cast(base) + offset, isIndirect, offset); - } -} - -template -typename PT::type -ReadPointerMaybeNull(const T *base, const PT T::* pPointerFieldMember) -{ - LIMITED_METHOD_DAC_CONTRACT; - - return ReadPointer(base, pPointerFieldMember); -} - -template -typename PT::type -ReadPointerMaybeNull(const T *base, const PT T::* pPointerFieldMember, bool isIndirect) -{ - LIMITED_METHOD_DAC_CONTRACT; - - return ReadPointer(base, pPointerFieldMember, isIndirect); -} - -template -typename PT::type -ReadPointer(const T *base, const PT T::* pPointerFieldMember) -{ - LIMITED_METHOD_DAC_CONTRACT; - - return ReadPointer(base, pPointerFieldMember); -} - -template -typename PT::type -ReadPointer(const T *base, const PT T::* pPointerFieldMember, bool isIndirect) -{ - LIMITED_METHOD_DAC_CONTRACT; - - return ReadPointer(base, pPointerFieldMember, isIndirect); -} - -template -typename PT::type -ReadPointer(const T *base, const C T::* pFirstPointerFieldMember, const PT C::* pSecondPointerFieldMember) -{ - LIMITED_METHOD_DAC_CONTRACT; - - const PT *ptr = &(base->*pFirstPointerFieldMember.*pSecondPointerFieldMember); - uintptr_t offset = (uintptr_t) ptr - (uintptr_t) base; - - if (isMaybeNull) - { - return PT::GetValueMaybeNullAtPtr(dac_cast(base) + offset); - } - else - { - return PT::GetValueAtPtr(dac_cast(base) + offset); - } -} - -template -typename PT::type -ReadPointerMaybeNull(const T *base, const C T::* pFirstPointerFieldMember, const PT C::* pSecondPointerFieldMember) -{ - LIMITED_METHOD_DAC_CONTRACT; - - return ReadPointer(base, pFirstPointerFieldMember, pSecondPointerFieldMember); -} - -template -typename PT::type -ReadPointer(const T *base, const C T::* pFirstPointerFieldMember, const PT C::* pSecondPointerFieldMember) -{ - LIMITED_METHOD_DAC_CONTRACT; - - return ReadPointer(base, pFirstPointerFieldMember, pSecondPointerFieldMember); -} - -#endif //_FIXUPPOINTER_H diff --git a/src/inc/formattype.cpp b/src/inc/formattype.cpp deleted file mode 100644 index 8a7965cb4..000000000 --- a/src/inc/formattype.cpp +++ /dev/null @@ -1,1574 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -// - -// -/******************************************************************************/ -/* formatType.cpp */ -/******************************************************************************/ -#include "formattype.h" - -/******************************************************************************/ -char* asString(CQuickBytes *out) { - CONTRACTL - { - THROWS; - GC_NOTRIGGER; - } - CONTRACTL_END; - - SIZE_T oldSize = out->Size(); - out->ReSizeThrows(oldSize + 1); - char* cur = &((char*) out->Ptr())[oldSize]; - *cur = 0; - out->ReSizeThrows(oldSize); // Don't count the null character - return((char*) out->Ptr()); -} - -void appendStr(CQuickBytes *out, const char* str, unsigned len) { - CONTRACTL - { - THROWS; - GC_NOTRIGGER; - } - CONTRACTL_END; - - if(len == (unsigned)(-1)) len = (unsigned)strlen(str); - SIZE_T oldSize = out->Size(); - out->ReSizeThrows(oldSize + len); - char* cur = &((char*) out->Ptr())[oldSize]; - memcpy(cur, str, len); - // Note no trailing null! -} - -void appendChar(CQuickBytes *out, char chr) { - CONTRACTL - { - THROWS; - GC_NOTRIGGER; - } - CONTRACTL_END; - - SIZE_T oldSize = out->Size(); - out->ReSizeThrows(oldSize + 1); - ((char*) out->Ptr())[oldSize] = chr; - // Note no trailing null! -} - -void insertStr(CQuickBytes *out, const char* str) { - CONTRACTL - { - THROWS; - GC_NOTRIGGER; - } - CONTRACTL_END; - - unsigned len = (unsigned)strlen(str); - SIZE_T oldSize = out->Size(); - out->ReSizeThrows(oldSize + len); - char* cur = &((char*) out->Ptr())[len]; - memmove(cur,out->Ptr(),oldSize); - memcpy(out->Ptr(), str, len); - // Note no trailing null! -} - -static void appendStrNum(CQuickBytes *out, int num) { - CONTRACTL - { - THROWS; - GC_NOTRIGGER; - } - CONTRACTL_END; - - char buff[16]; - sprintf_s(buff, COUNTOF(buff), "%d", num); - appendStr(out, buff); -} - -const PCCOR_SIGNATURE PrettyPrintSignature( - PCCOR_SIGNATURE typePtr, // type to convert, - unsigned typeLen, // the lenght of 'typePtr' - const char* name, // can be "", the name of the method for this sig 0 means local var sig - CQuickBytes *out, // where to put the pretty printed string - IMDInternalImport *pIMDI, // ptr to IMDInternalImport class with ComSig - _In_opt_z_ const char* inlabel, // prefix for names (NULL if no names required) - BOOL printTyArity=FALSE); - - -PCCOR_SIGNATURE PrettyPrintTypeOrDef( - PCCOR_SIGNATURE typePtr, // type to convert, - CQuickBytes *out, // where to put the pretty printed string - IMDInternalImport *pIMDI); // ptr to IMDInternal class with ComSig - -//***************************************************************************** -// Parse a length, return the length, size of the length. -//***************************************************************************** -ULONG GetLength( // Length or -1 on error. - void const *pData, // First byte of length. - int *pSizeLen) // Put size of length here, if not 0. -{ - LIMITED_METHOD_CONTRACT; - - BYTE const *pBytes = reinterpret_cast(pData); - - if(pBytes) - { - if ((*pBytes & 0x80) == 0x00) // 0??? ???? - { - if (pSizeLen) *pSizeLen = 1; - return (*pBytes & 0x7f); - } - - if ((*pBytes & 0xC0) == 0x80) // 10?? ???? - { - if (pSizeLen) *pSizeLen = 2; - return ((*pBytes & 0x3f) << 8 | *(pBytes+1)); - } - - if ((*pBytes & 0xE0) == 0xC0) // 110? ???? - { - if (pSizeLen) *pSizeLen = 4; - return ((*pBytes & 0x1f) << 24 | *(pBytes+1) << 16 | *(pBytes+2) << 8 | *(pBytes+3)); - } - } - if(pSizeLen) *pSizeLen = 0; - return 0; -} - - -/******************************************************************************/ -const char* PrettyPrintSig( - PCCOR_SIGNATURE typePtr, // type to convert, - unsigned typeLen, // the length of 'typePtr' - const char* name, // can be "", the name of the method for this sig 0 means local var sig - CQuickBytes *out, // where to put the pretty printed string - IMDInternalImport *pIMDI, // ptr to IMDInternalImport class with ComSig - const char* inlabel, // prefix for names (NULL if no names required) - BOOL printTyArity) -{ - STATIC_CONTRACT_THROWS; - - // This had a _try/__except handler earlier that would swallow exceptions like - // SO and breakpoint. Obviously, swallowing any of them is not the right thing to do. - // - // Thus, we replace it with EX_TRY/EX_CATCH that automatically kicks in with SO - // handling if it sees any SO going past it. Also, C++ catch will not swallow - // the breakpoint exception (which is what we want). - EX_TRY - { - PrettyPrintSignature(typePtr, - typeLen, - name, - out, - pIMDI, - inlabel, - printTyArity); - } - EX_CATCH - { - out->Shrink(0); - appendStr(out,"ERROR PARSING THE SIGNATURE"); - } -#if defined(__ILDASM__) - // Dont allow ildasm to swallow bad SEH exceptions - EX_END_CATCH(RethrowCorruptingExceptions); -#else // __ILDASM__ - EX_END_CATCH(SwallowAllExceptions); -#endif // __ILDASM__ - - return(asString(out)); -} - -/********************************************************************************/ -// Converts a com signature to a printable signature. -// Note that return value is pointing at the CQuickBytes buffer, - -const PCCOR_SIGNATURE PrettyPrintSignature( - PCCOR_SIGNATURE typePtr, // type to convert, - unsigned typeLen, // the lenght of 'typePtr' - const char* name, // can be "", the name of the method for this sig 0 means local var sig - CQuickBytes *out, // where to put the pretty printed string - IMDInternalImport *pIMDI, // ptr to IMDInternalImport class with ComSig - const char* inlabel, // prefix for names (NULL if no names required) - BOOL printTyArity) -{ - CONTRACTL - { - THROWS; - GC_NOTRIGGER; - } - CONTRACTL_END; - - unsigned numArgs; - unsigned numTyArgs = 0; - PCCOR_SIGNATURE typeEnd = typePtr + typeLen; - unsigned ixArg= 0; //arg index - char argname[1024]; - char label[MAX_PREFIX_SIZE]; - const char* openpar = "("; - const char* closepar = ")"; - ParamDescriptor* pszArgName = NULL; // ptr to array of names (if provided by debug info) - - if(inlabel && *inlabel) // check for *inlabel is totally unnecessary, added to pacify the PREFIX - { - strcpy_s(label,MAX_PREFIX_SIZE,inlabel); - ixArg = label[strlen(label)-1] - '0'; - label[strlen(label)-1] = 0; - if(label[0] == '@') // it's pointer! - { -#ifdef _WIN64 - pszArgName = (ParamDescriptor*)_atoi64(&label[1]); -#else // !_WIN64 - pszArgName = (ParamDescriptor*)(size_t)atoi(&label[1]); -#endif // _WIN64 - } - } - - // 0 means a local var sig - if (name != 0) - { - // get the calling convention out - unsigned callConv = CorSigUncompressData(typePtr); - - // should not be a local var sig - _ASSERTE(!isCallConv(callConv, IMAGE_CEE_CS_CALLCONV_LOCAL_SIG)); - - if (isCallConv(callConv, IMAGE_CEE_CS_CALLCONV_FIELD)) - { - typePtr = PrettyPrintTypeOrDef(typePtr, out, pIMDI); - if (*name) - { - appendChar(out, ' '); - appendStr(out, name); - } - return(typePtr); - } - - if (callConv & IMAGE_CEE_CS_CALLCONV_EXPLICITTHIS) - appendStr(out, KEYWORD("explicit ")); - - if (callConv & IMAGE_CEE_CS_CALLCONV_HASTHIS) - appendStr(out, KEYWORD("instance ")); - - if (isCallConv(callConv, IMAGE_CEE_CS_CALLCONV_GENERICINST)) - { - openpar = LTN(); - closepar = GTN(); - } - else - { - static const char* const callConvNames[8] = { - "", - "unmanaged cdecl ", - "unmanaged stdcall ", - "unmanaged thiscall ", - "unmanaged fastcall ", - "vararg ", - " ", - " " - }; - appendStr(out, KEYWORD(callConvNames[callConv & 7])); - } - - if (callConv & IMAGE_CEE_CS_CALLCONV_GENERIC) - { - numTyArgs = CorSigUncompressData(typePtr); - } - numArgs = CorSigUncompressData(typePtr); - if (!isCallConv(callConv, IMAGE_CEE_CS_CALLCONV_GENERICINST)) - { - // do return type - if(pszArgName) - { - argname[0] = 0; - DumpParamAttr(argname,COUNTOF(argname),pszArgName[ixArg+numArgs].attr); - appendStr(out,argname); - } - typePtr = PrettyPrintTypeOrDef(typePtr, out, pIMDI); - if(pszArgName) - { - argname[0] = ' '; argname[1] = 0; - DumpMarshaling(pIMDI,argname,COUNTOF(argname),pszArgName[ixArg+numArgs].tok); - appendStr(out,argname); - } - if(*name != 0) - { - appendChar(out, ' '); - appendStr(out, name); - } - if((numTyArgs != 0)&&printTyArity) - { - appendStr(out,LTN()); - appendChar(out,'['); - appendStrNum(out,numTyArgs); - appendChar(out,']'); - appendStr(out,GTN()); - } - } - } - else - { - // get the calling convention out -#ifdef _DEBUG - unsigned callConv = -#endif - CorSigUncompressData(typePtr); -#ifdef _DEBUG - (void)callConv; //prevent "unused variable" warning from GCC - // should be a local var sig - _ASSERTE(callConv == IMAGE_CEE_CS_CALLCONV_LOCAL_SIG); -#endif - - numArgs = CorSigUncompressData(typePtr); - } - - appendStr(out, openpar); - - bool needComma = false; - while(typePtr < typeEnd) - { - if(name) // printing the arguments - { - PREFIX_ASSUME(typePtr != NULL); - if (*typePtr == ELEMENT_TYPE_SENTINEL) - { - if (needComma) - appendChar(out, ','); - appendStr(out, "..."); - typePtr++; - } - else - { - if (numArgs <= 0) - break; - if (needComma) - appendChar(out, ','); - if(pszArgName) - { - argname[0] = 0; - DumpParamAttr(argname,COUNTOF(argname),pszArgName[ixArg].attr); - appendStr(out,argname); - } - typePtr = PrettyPrintTypeOrDef(typePtr, out, pIMDI); - if(inlabel) - { - if(pszArgName) - { - argname[0] = ' '; argname[1] = 0; - DumpMarshaling(pIMDI,argname,COUNTOF(argname),pszArgName[ixArg].tok); - strcat_s(argname, COUNTOF(argname), ProperName(pszArgName[ixArg++].name)); - } - else sprintf_s(argname,COUNTOF(argname)," %s_%d",label,ixArg++); - appendStr(out,argname); - } - --numArgs; - } - } - else // printing local vars - { - if (numArgs <= 0) - break; - if(pszArgName) - { - if(pszArgName[ixArg].attr == 0xFFFFFFFF) - { - CQuickBytes fake_out; - typePtr = PrettyPrintTypeOrDef(typePtr, &fake_out, pIMDI); - ixArg++; - numArgs--; - continue; - } - } - if (needComma) - appendChar(out, ','); - if(pszArgName) - { - sprintf_s(argname,COUNTOF(argname),"[%d] ",pszArgName[ixArg].attr); - appendStr(out,argname); - } - typePtr = PrettyPrintTypeOrDef(typePtr, out, pIMDI); - if(inlabel) - { - if(pszArgName) - { - sprintf_s(argname,COUNTOF(argname)," %s",ProperLocalName(pszArgName[ixArg++].name)); - } - else sprintf_s(argname,COUNTOF(argname)," %s_%d",label,ixArg++); - appendStr(out,argname); - } - --numArgs; - } - needComma = true; - } - // Have we finished printing all the arguments? - if (numArgs > 0) { - appendStr(out, ERRORMSG(" [SIGNATURE ENDED PREMATURELY]")); - } - - appendStr(out, closepar); - return(typePtr); -} - - -/******************************************************************************/ -// pretty prints 'type' or its 'typedef' to the buffer 'out' returns a pointer to the next type, -// or 0 on a format failure; outside ILDASM -- simple wrapper for PrettyPrintType - -PCCOR_SIGNATURE PrettyPrintTypeOrDef( - PCCOR_SIGNATURE typePtr, // type to convert, - CQuickBytes *out, // where to put the pretty printed string - IMDInternalImport *pIMDI) // ptr to IMDInternal class with ComSig -{ - CONTRACTL - { - THROWS; - SO_TOLERANT; - GC_NOTRIGGER; - } - CONTRACTL_END; - - PCCOR_SIGNATURE pBegin, pEnd=NULL; - - BEGIN_SO_INTOLERANT_CODE_NO_THROW_CHECK_THREAD(ThrowStackOverflow()); - -#ifdef __ILDASM__ - ULONG L = (ULONG)(out->Size()); -#endif - pBegin = typePtr; - pEnd = PrettyPrintType(typePtr,out,pIMDI); -#ifdef __ILDASM__ - if(pEnd > pBegin) // PrettyPrintType can return NULL - { - DWORD i; - ULONG l = (ULONG)(pEnd - pBegin); - for(i=0; i < g_NumTypedefs; i++) - { - if(((*g_typedefs)[i].cb == l) - && (memcmp((*g_typedefs)[i].psig,pBegin,l)==0)) - { - out->Shrink(L); // discard output of PrettyPrintType - appendStr(out, JUMPPT(ProperName((*g_typedefs)[i].szName),(*g_typedefs)[i].tkSelf)); - break; - } - } - } -#endif - END_SO_INTOLERANT_CODE; - return pEnd; -} - -/******************************************************************************/ -// pretty prints 'type' to the buffer 'out' returns a pointer to the next type, -// or 0 on a format failure - -PCCOR_SIGNATURE PrettyPrintType( - PCCOR_SIGNATURE typePtr, // type to convert, - CQuickBytes *out, // where to put the pretty printed string - IMDInternalImport *pIMDI) // ptr to IMDInternal class with ComSig -{ - CONTRACTL - { - THROWS; - GC_NOTRIGGER; - } - CONTRACTL_END; - - mdToken tk; - const char* str; - int typ; - CQuickBytes tmp; - CQuickBytes Appendix; - BOOL Reiterate; - int n; - - do { - Reiterate = FALSE; - switch(typ = *typePtr++) { - case ELEMENT_TYPE_VOID : - str = "void"; goto APPEND; - case ELEMENT_TYPE_BOOLEAN : - str = "bool"; goto APPEND; - case ELEMENT_TYPE_CHAR : - str = "char"; goto APPEND; - case ELEMENT_TYPE_I1 : - str = "int8"; goto APPEND; - case ELEMENT_TYPE_U1 : - str = "uint8"; goto APPEND; - case ELEMENT_TYPE_I2 : - str = "int16"; goto APPEND; - case ELEMENT_TYPE_U2 : - str = "uint16"; goto APPEND; - case ELEMENT_TYPE_I4 : - str = "int32"; goto APPEND; - case ELEMENT_TYPE_U4 : - str = "uint32"; goto APPEND; - case ELEMENT_TYPE_I8 : - str = "int64"; goto APPEND; - case ELEMENT_TYPE_U8 : - str = "uint64"; goto APPEND; - case ELEMENT_TYPE_R4 : - str = "float32"; goto APPEND; - case ELEMENT_TYPE_R8 : - str = "float64"; goto APPEND; - case ELEMENT_TYPE_U : - str = "native uint"; goto APPEND; - case ELEMENT_TYPE_I : - str = "native int"; goto APPEND; - case ELEMENT_TYPE_OBJECT : - str = "object"; goto APPEND; - case ELEMENT_TYPE_STRING : - str = "string"; goto APPEND; - case ELEMENT_TYPE_TYPEDBYREF : - str = "typedref"; goto APPEND; - APPEND: - appendStr(out, KEYWORD((char*)str)); - break; - - case ELEMENT_TYPE_VALUETYPE : - str = "valuetype "; - goto DO_CLASS; - case ELEMENT_TYPE_CLASS : - str = "class "; - goto DO_CLASS; - - DO_CLASS: - appendStr(out, KEYWORD((char*)str)); - typePtr += CorSigUncompressToken(typePtr, &tk); - if(IsNilToken(tk)) - { - appendStr(out, "[ERROR! NIL TOKEN]"); - } - else PrettyPrintClass(out, tk, pIMDI); - REGISTER_REF(g_tkRefUser,tk) - break; - - case ELEMENT_TYPE_SZARRAY : - insertStr(&Appendix,"[]"); - Reiterate = TRUE; - break; - - case ELEMENT_TYPE_ARRAY : - { - typePtr = PrettyPrintTypeOrDef(typePtr, out, pIMDI); - PREFIX_ASSUME(typePtr != NULL); - unsigned rank = CorSigUncompressData(typePtr); - // what is the syntax for the rank 0 case? - if (rank == 0) { - appendStr(out, ERRORMSG("[BAD: RANK == 0!]")); - } - else { - _ASSERTE(rank != 0); - -#ifdef _PREFAST_ -#pragma prefast(push) -#pragma prefast(disable:22009 "Suppress PREFAST warnings about integer overflow") -#endif - int* lowerBounds = (int*) _alloca(sizeof(int)*2*rank); - int* sizes = &lowerBounds[rank]; - memset(lowerBounds, 0, sizeof(int)*2*rank); - - unsigned numSizes = CorSigUncompressData(typePtr); - _ASSERTE(numSizes <= rank); - unsigned i; - for(i =0; i < numSizes; i++) - sizes[i] = CorSigUncompressData(typePtr); - - unsigned numLowBounds = CorSigUncompressData(typePtr); - _ASSERTE(numLowBounds <= rank); - for(i = 0; i < numLowBounds; i++) - typePtr+=CorSigUncompressSignedInt(typePtr,&lowerBounds[i]); - - appendChar(out, '['); - if (rank == 1 && numSizes == 0 && numLowBounds == 0) - appendStr(out, "..."); - else { - for(i = 0; i < rank; i++) - { - //if (sizes[i] != 0 || lowerBounds[i] != 0) - { - if (lowerBounds[i] == 0 && i < numSizes) - appendStrNum(out, sizes[i]); - else - { - if(i < numLowBounds) - { - appendStrNum(out, lowerBounds[i]); - appendStr(out, "..."); - if (/*sizes[i] != 0 && */i < numSizes) - appendStrNum(out, lowerBounds[i] + sizes[i] - 1); - } - } - } - if (i < rank-1) - appendChar(out, ','); - } - } - appendChar(out, ']'); -#ifdef _PREFAST_ -#pragma prefast(pop) -#endif - } - } break; - - case ELEMENT_TYPE_VAR : - appendChar(out, '!'); - n = CorSigUncompressData(typePtr); -#ifdef __ILDASM__ - if(!PrettyPrintGP(g_tkVarOwner,out,n)) -#endif - appendStrNum(out, n); - break; - - case ELEMENT_TYPE_MVAR : - appendChar(out, '!'); - appendChar(out, '!'); - n = CorSigUncompressData(typePtr); -#ifdef __ILDASM__ - if(!PrettyPrintGP(g_tkMVarOwner,out,n)) -#endif - appendStrNum(out, n); - break; - - case ELEMENT_TYPE_FNPTR : - appendStr(out, KEYWORD("method ")); - typePtr = PrettyPrintSignature(typePtr, 0x7FFF, "*", out, pIMDI, NULL); - break; - - case ELEMENT_TYPE_GENERICINST : - { - typePtr = PrettyPrintTypeOrDef(typePtr, out, pIMDI); - appendStr(out, LTN()); - unsigned numArgs = CorSigUncompressData(typePtr); - bool needComma = false; - while(numArgs--) - { - if (needComma) - appendChar(out, ','); - typePtr = PrettyPrintTypeOrDef(typePtr, out, pIMDI); - needComma = true; - } - appendStr(out, GTN()); - break; - } - -#ifndef __ILDASM__ - case ELEMENT_TYPE_INTERNAL : - { - // ELEMENT_TYPE_INTERNAL - _ASSERTE(sizeof(TypeHandle) == sizeof(void *)); - TypeHandle typeHandle; - typePtr += CorSigUncompressPointer(typePtr, (void **)&typeHandle); - - MethodTable *pMT = NULL; - if (typeHandle.IsTypeDesc()) - { - pMT = typeHandle.AsTypeDesc()->GetMethodTable(); - if (pMT) - { - PrettyPrintClass(out, pMT->GetCl(), pMT->GetMDImport()); - - // It could be a "native version" of the managed type used in interop - if (typeHandle.AsTypeDesc()->IsNativeValueType()) - appendStr(out, "_NativeValueType"); - } - else - appendStr(out, "(null)"); - } - else - { - pMT = typeHandle.AsMethodTable(); - if (pMT) - PrettyPrintClass(out, pMT->GetCl(), pMT->GetMDImport()); - else - appendStr(out, "(null)"); - } - - char sz[32]; - if(IsCompilationProcess()) - { - sprintf_s(sz, COUNTOF(sz), " /* TOKEN: 0x%x */", pMT != NULL ? pMT->GetCl() : 0); - } - else - { - sprintf_s(sz, COUNTOF(sz), " /* MT: 0x%p */", pMT); - } - appendStr(out, sz); - break; - } -#endif - - - // Modifiers or depedent types - case ELEMENT_TYPE_CMOD_OPT : - str = " modopt("; goto ADDCLASSTOCMOD; - case ELEMENT_TYPE_CMOD_REQD : - str = " modreq("; - ADDCLASSTOCMOD: - typePtr += CorSigUncompressToken(typePtr, &tk); - if (IsNilToken(tk)) - { - Debug_ReportError("Nil token in custom modifier"); - } - tmp.Shrink(0); - appendStr(&tmp, KEYWORD((char*)str)); - PrettyPrintClass(&tmp, tk, pIMDI); - appendChar(&tmp,')'); - str = (const char *) asString(&tmp); - goto MODIFIER; - case ELEMENT_TYPE_PINNED : - str = " pinned"; goto MODIFIER; - case ELEMENT_TYPE_PTR : - str = "*"; goto MODIFIER; - case ELEMENT_TYPE_BYREF : - str = AMP(); goto MODIFIER; - MODIFIER: - insertStr(&Appendix, str); - Reiterate = TRUE; - break; - - default: - case ELEMENT_TYPE_SENTINEL : - case ELEMENT_TYPE_END : - //_ASSERTE(!"Unknown Type"); - if(typ) - { - char sz[64]; - sprintf_s(sz,COUNTOF(sz),"/* UNKNOWN TYPE (0x%X)*/",typ); - appendStr(out, ERRORMSG(sz)); - } - break; - } // end switch - } while(Reiterate); - appendStr(out,asString(&Appendix)); - return(typePtr); -} - -/******************************************************************/ -const char* PrettyPrintClass( - CQuickBytes *out, // where to put the pretty printed string - mdToken tk, // The class token to look up - IMDInternalImport *pIMDI) // ptr to IMDInternalImport class with ComSig -{ - CONTRACTL - { - THROWS; - GC_NOTRIGGER; - } - CONTRACTL_END; - - if(tk == mdTokenNil) // Zero resolution scope for "somewhere here" TypeRefs - { - appendStr(out,"[*]"); - return(asString(out)); - } - if(!pIMDI->IsValidToken(tk)) - { - char str[1024]; - sprintf_s(str,COUNTOF(str)," [ERROR: INVALID TOKEN 0x%8.8X] ",tk); - appendStr(out,ERRORMSG(str)); - return(asString(out)); - } - switch(TypeFromToken(tk)) - { - case mdtTypeRef: - case mdtTypeDef: -#ifdef __ILDASM__ - DWORD ix; - for(ix = 0; ix < g_NumTypedefs; ix++) - { - if((*g_typedefs)[ix].tkTypeSpec == tk) break; - } - if(ix < g_NumTypedefs) - { - appendStr(out,JUMPPT(ProperName((*g_typedefs)[ix].szName),(*g_typedefs)[ix].tkSelf)); - } - else -#endif - { - const char *nameSpace = 0; - const char *name = 0; - mdToken tkEncloser; - - if (TypeFromToken(tk) == mdtTypeRef) - { - if (FAILED(pIMDI->GetResolutionScopeOfTypeRef(tk, &tkEncloser))) - { - tkEncloser = mdTypeDefNil; - } - if (FAILED(pIMDI->GetNameOfTypeRef(tk, &nameSpace, &name))) - { - nameSpace = name = "Invalid TypeRef record"; - } - } - else - { - if (FAILED(pIMDI->GetNestedClassProps(tk,&tkEncloser))) - { - tkEncloser = mdTypeDefNil; - } - if (FAILED(pIMDI->GetNameOfTypeDef(tk, &name, &nameSpace))) - { - nameSpace = name = "Invalid TypeDef record"; - } - } - MAKE_NAME_IF_NONE(name,tk); - if((tkEncloser == mdTokenNil) || RidFromToken(tkEncloser)) - { - PrettyPrintClass(out,tkEncloser,pIMDI); - if (TypeFromToken(tkEncloser) == mdtTypeRef || TypeFromToken(tkEncloser) == mdtTypeDef) - { - appendChar(out, '/'); - //nameSpace = ""; //don't print namespaces for nested classes! - } - } - if(TypeFromToken(tk)==mdtTypeDef) - { - unsigned L = (unsigned)strlen(ProperName(name))+1; - char* szFN = NULL; - if(nameSpace && *nameSpace) - { - const char* sz = ProperName(nameSpace); - L+= (unsigned)strlen(sz)+1; - szFN = new char[L]; - sprintf_s(szFN,L,"%s.",sz); - } - else - { - szFN = new char[L]; - *szFN = 0; - } - strcat_s(szFN,L, ProperName(name)); - appendStr(out,JUMPPT(szFN,tk)); - VDELETE(szFN); - } - else - { - if (nameSpace && *nameSpace) { - appendStr(out, ProperName(nameSpace)); - appendChar(out, '.'); - } - - appendStr(out, ProperName(name)); - } - if(g_fDumpTokens) - { - char tmp[16]; - sprintf_s(tmp,COUNTOF(tmp),"/*%08X*/",tk); - appendStr(out,COMMENT(tmp)); - } - } - break; - - case mdtAssemblyRef: - { - LPCSTR szName = NULL; -#ifdef __ILDASM__ - if (rAsmRefName && (RidFromToken(tk) <= ulNumAsmRefs)) - { - szName = rAsmRefName[RidFromToken(tk)-1]; - } - else -#endif - { - if (FAILED(pIMDI->GetAssemblyRefProps(tk,NULL,NULL,&szName,NULL,NULL,NULL,NULL))) - { - szName = NULL; - } - } - if ((szName != NULL) && ((*szName) != 0 )) - { - appendChar(out, '['); - appendStr(out,JUMPPT(ProperName(szName),tk)); - if(g_fDumpTokens) - { - char tmp[16]; - sprintf_s(tmp,COUNTOF(tmp),"/*%08X*/",tk); - appendStr(out,COMMENT(tmp)); - } - appendChar(out, ']'); - } - } - break; - case mdtAssembly: - { - LPCSTR szName; - if (FAILED(pIMDI->GetAssemblyProps(tk,NULL,NULL,NULL,&szName,NULL,NULL))) - { - szName = NULL; - } - if ((szName != NULL) && ((*szName) != 0)) - { - appendChar(out, '['); - appendStr(out,JUMPPT(ProperName(szName),tk)); - if(g_fDumpTokens) - { - char tmp[16]; - sprintf_s(tmp,COUNTOF(tmp),"/* %08X */",tk); - appendStr(out,COMMENT(tmp)); - } - appendChar(out, ']'); - } - } - break; - case mdtModuleRef: - { - LPCSTR szName; - if (FAILED(pIMDI->GetModuleRefProps(tk, &szName))) - { - szName = NULL; - } - if ((szName != NULL) && ((*szName) != 0)) - { - appendChar(out, '['); - appendStr(out,KEYWORD(".module ")); - appendStr(out,JUMPPT(ProperName(szName),tk)); - if(g_fDumpTokens) - { - char tmp[16]; - sprintf_s(tmp,COUNTOF(tmp),"/*%08X*/",tk); - appendStr(out,COMMENT(tmp)); - } - appendChar(out, ']'); - } - } - break; - - case mdtTypeSpec: - { -#ifdef __ILDASM__ - DWORD ix; - for(ix = 0; ix < g_NumTypedefs; ix++) - { - if((*g_typedefs)[ix].tkTypeSpec == tk) break; - } - if(ix < g_NumTypedefs) - { - appendStr(out,JUMPPT(ProperName((*g_typedefs)[ix].szName),(*g_typedefs)[ix].tkSelf)); - } - else -#endif - { - ULONG cSig; - PCCOR_SIGNATURE sig; - if (FAILED(pIMDI->GetSigFromToken(tk, &cSig, &sig))) - { - char tmp[64]; - sprintf_s(tmp, COUNTOF(tmp), "/*Invalid %08X record*/", tk); - appendStr(out, COMMENT(tmp)); - } - else - { - PrettyPrintType(sig, out, pIMDI); - } - } - if(g_fDumpTokens) - { - char tmp[16]; - sprintf_s(tmp,COUNTOF(tmp),"/*%08X*/",tk); - appendStr(out,COMMENT(tmp)); - } - } - break; - - case mdtModule: - break; - - default: - { - char str[128]; - sprintf_s(str,COUNTOF(str)," [ERROR: INVALID TOKEN TYPE 0x%8.8X] ",tk); - appendStr(out,ERRORMSG(str)); - } - } - return(asString(out)); -} - -const char* TrySigUncompressAndDumpSimpleNativeType( - PCCOR_SIGNATURE pData, // [IN] compressed data - ULONG *pDataOut, // [OUT] the expanded *pData - ULONG &cbCur, - SString &buf) -{ - const char* sz = NULL; - ULONG ulSize = CorSigUncompressData(pData, pDataOut); - if (ulSize != (ULONG)-1) - { - switch (*pDataOut) - { - case NATIVE_TYPE_VOID: sz = " void"; break; - case NATIVE_TYPE_BOOLEAN: sz = " bool"; break; - case NATIVE_TYPE_I1: sz = " int8"; break; - case NATIVE_TYPE_U1: sz = " unsigned int8"; break; - case NATIVE_TYPE_I2: sz = " int16"; break; - case NATIVE_TYPE_U2: sz = " unsigned int16"; break; - case NATIVE_TYPE_I4: sz = " int32"; break; - case NATIVE_TYPE_U4: sz = " unsigned int32"; break; - case NATIVE_TYPE_I8: sz = " int64"; break; - case NATIVE_TYPE_U8: sz = " unsigned int64"; break; - case NATIVE_TYPE_R4: sz = " float32"; break; - case NATIVE_TYPE_R8: sz = " float64"; break; - case NATIVE_TYPE_SYSCHAR: sz = " syschar"; break; - case NATIVE_TYPE_VARIANT: sz = " variant"; break; - case NATIVE_TYPE_CURRENCY: sz = " currency"; break; - case NATIVE_TYPE_DECIMAL: sz = " decimal"; break; - case NATIVE_TYPE_DATE: sz = " date"; break; - case NATIVE_TYPE_BSTR: sz = " bstr"; break; - case NATIVE_TYPE_LPSTR: sz = " lpstr"; break; - case NATIVE_TYPE_LPWSTR: sz = " lpwstr"; break; - case NATIVE_TYPE_LPTSTR: sz = " lptstr"; break; - case NATIVE_TYPE_OBJECTREF: sz = " objectref"; break; - case NATIVE_TYPE_STRUCT: sz = " struct"; break; - case NATIVE_TYPE_ERROR: sz = " error"; break; - case NATIVE_TYPE_INT: sz = " int"; break; - case NATIVE_TYPE_UINT: sz = " uint"; break; - case NATIVE_TYPE_NESTEDSTRUCT: sz = " nested struct"; break; - case NATIVE_TYPE_BYVALSTR: sz = " byvalstr"; break; - case NATIVE_TYPE_ANSIBSTR: sz = " ansi bstr"; break; - case NATIVE_TYPE_TBSTR: sz = " tbstr"; break; - case NATIVE_TYPE_VARIANTBOOL: sz = " variant bool"; break; - case NATIVE_TYPE_FUNC: sz = " method"; break; - case NATIVE_TYPE_ASANY: sz = " as any"; break; - case NATIVE_TYPE_LPSTRUCT: sz = " lpstruct"; break; - case NATIVE_TYPE_PTR: - case NATIVE_TYPE_SAFEARRAY: - case NATIVE_TYPE_ARRAY: - case NATIVE_TYPE_FIXEDSYSSTRING: - case NATIVE_TYPE_FIXEDARRAY: - case NATIVE_TYPE_INTF: - case NATIVE_TYPE_IUNKNOWN: - case NATIVE_TYPE_IDISPATCH: - case NATIVE_TYPE_CUSTOMMARSHALER: - case NATIVE_TYPE_END: - case NATIVE_TYPE_MAX: - sz = ""; break; - default: sz = NULL; - } - } - if (sz) - cbCur += ulSize; - else - buf.Clear(); - - return sz; -} - -bool TrySigUncompress(PCCOR_SIGNATURE pData, // [IN] compressed data - ULONG *pDataOut, // [OUT] the expanded *pData - ULONG &cbCur, - SString &buf) -{ - ULONG ulSize = CorSigUncompressData(pData, pDataOut); - if (ulSize == (ULONG)-1) - { - buf.Clear(); - return false; - } else - { - cbCur += ulSize; - return true; - } -} - - -#ifdef _PREFAST_ -#pragma warning(push) -#pragma warning(disable:21000) // Suppress PREFast warning about overly large function -#endif -char* DumpMarshaling(IMDInternalImport* pImport, - __inout_ecount(cchszString) char* szString, - DWORD cchszString, - mdToken tok) -{ - CONTRACTL - { - THROWS; - GC_NOTRIGGER; - } - CONTRACTL_END; - - PCCOR_SIGNATURE pSigNativeType = NULL; - ULONG cbNativeType = 0; - SString buf; - if (RidFromToken(tok) && - SUCCEEDED(pImport->GetFieldMarshal( // return error if no native type associate with the token - tok, // [IN] given fielddef - &pSigNativeType, // [OUT] the native type signature - &cbNativeType))) // [OUT] the count of bytes of *ppvNativeType - { - ULONG cbCur = 0; - ULONG ulData; - const char *sz = NULL; - BOOL fAddAsterisk = FALSE, fAddBrackets = FALSE; - buf.AppendPrintf(" %s(", KEYWORD("marshal")); - while (cbCur < cbNativeType) - { - ulData = NATIVE_TYPE_MAX; - sz = TrySigUncompressAndDumpSimpleNativeType(&pSigNativeType[cbCur], &ulData, cbCur, buf); - if (!sz) - goto error; - if(*sz == 0) - { - switch (ulData) - { - case NATIVE_TYPE_PTR: - sz = ""; - fAddAsterisk = TRUE; - break; - case NATIVE_TYPE_SAFEARRAY: - sz = ""; - buf.AppendASCII(KEYWORD(" safearray")); - ulData = VT_EMPTY; - if (cbCur < cbNativeType) - { - if (!TrySigUncompress(&pSigNativeType[cbCur], &ulData, cbCur, buf)) - goto error; - } - switch(ulData & VT_TYPEMASK) - { - case VT_EMPTY: sz=""; break; - case VT_NULL: sz=" null"; break; - case VT_VARIANT: sz=" variant"; break; - case VT_CY: sz=" currency"; break; - case VT_VOID: sz=" void"; break; - case VT_BOOL: sz=" bool"; break; - case VT_I1: sz=" int8"; break; - case VT_I2: sz=" int16"; break; - case VT_I4: sz=" int32"; break; - case VT_I8: sz=" int64"; break; - case VT_R4: sz=" float32"; break; - case VT_R8: sz=" float64"; break; - case VT_UI1: sz=" unsigned int8"; break; - case VT_UI2: sz=" unsigned int16"; break; - case VT_UI4: sz=" unsigned int32"; break; - case VT_UI8: sz=" unsigned int64"; break; - case VT_PTR: sz=" *"; break; - case VT_DECIMAL: sz=" decimal"; break; - case VT_DATE: sz=" date"; break; - case VT_BSTR: sz=" bstr"; break; - case VT_LPSTR: sz=" lpstr"; break; - case VT_LPWSTR: sz=" lpwstr"; break; - case VT_UNKNOWN: sz=" iunknown"; break; - case VT_DISPATCH: sz=" idispatch"; break; - case VT_SAFEARRAY: sz=" safearray"; break; - case VT_INT: sz=" int"; break; - case VT_UINT: sz=" unsigned int"; break; - case VT_ERROR: sz=" error"; break; - case VT_HRESULT: sz=" hresult"; break; - case VT_CARRAY: sz=" carray"; break; - case VT_USERDEFINED: sz=" userdefined"; break; - case VT_RECORD: sz=" record"; break; - case VT_FILETIME: sz=" filetime"; break; - case VT_BLOB: sz=" blob"; break; - case VT_STREAM: sz=" stream"; break; - case VT_STORAGE: sz=" storage"; break; - case VT_STREAMED_OBJECT: sz=" streamed_object"; break; - case VT_STORED_OBJECT: sz=" stored_object"; break; - case VT_BLOB_OBJECT: sz=" blob_object"; break; - case VT_CF: sz=" cf"; break; - case VT_CLSID: sz=" clsid"; break; - default: sz=NULL; break; - } - if(sz) buf.AppendASCII(KEYWORD(sz)); - else - { - // buf.AppendPrintf(ERRORMSG(" [ILLEGAL VARIANT TYPE 0x%X]"),ulData & VT_TYPEMASK); - buf.Clear(); - goto error; - } - sz=""; - switch(ulData & (~VT_TYPEMASK)) - { - case VT_ARRAY: sz = "[]"; break; - case VT_VECTOR: sz = " vector"; break; - case VT_BYREF: sz = "&"; break; - case VT_BYREF|VT_ARRAY: sz = "&[]"; break; - case VT_BYREF|VT_VECTOR: sz = "& vector"; break; - case VT_ARRAY|VT_VECTOR: sz = "[] vector"; break; - case VT_BYREF|VT_ARRAY|VT_VECTOR: sz = "&[] vector"; break; - } - buf.AppendASCII(KEYWORD(sz)); - sz=""; - - // Extract the user defined sub type name. - if (cbCur < cbNativeType) - { - LPUTF8 strTemp = NULL; - int strLen = 0; - int ByteCountLength = 0; - strLen = GetLength(&pSigNativeType[cbCur], &ByteCountLength); - cbCur += ByteCountLength; - if(strLen) - { -#ifdef _PREFAST_ -#pragma prefast(push) -#pragma prefast(disable:22009 "Suppress PREFAST warnings about integer overflow") -#endif - strTemp = (LPUTF8)_alloca(strLen + 1); - memcpy(strTemp, (LPUTF8)&pSigNativeType[cbCur], strLen); - strTemp[strLen] = 0; - buf.AppendPrintf(", \"%s\"", UnquotedProperName(strTemp)); - cbCur += strLen; -#ifdef _PREFAST_ -#pragma prefast(pop) -#endif - } - } - break; - - case NATIVE_TYPE_ARRAY: - sz = ""; - fAddBrackets = TRUE; - break; - case NATIVE_TYPE_FIXEDSYSSTRING: - { - sz = ""; - buf.AppendASCII(KEYWORD(" fixed sysstring")); - buf.AppendASCII(" ["); - if (cbCur < cbNativeType) - { - if (!TrySigUncompress(&pSigNativeType[cbCur], &ulData, cbCur, buf)) - goto error; - buf.AppendPrintf("%d",ulData); - } - buf.AppendASCII("]"); - } - break; - case NATIVE_TYPE_FIXEDARRAY: - { - sz = ""; - buf.AppendASCII(KEYWORD(" fixed array")); - buf.AppendASCII(" ["); - if (cbCur < cbNativeType) - { - if (!TrySigUncompress(&pSigNativeType[cbCur], &ulData, cbCur, buf)) - goto error; - buf.AppendPrintf("%d",ulData); - } - buf.AppendASCII("]"); - if (cbCur < cbNativeType) - { - sz = TrySigUncompressAndDumpSimpleNativeType(&pSigNativeType[cbCur], &ulData, cbCur, buf); - if (!sz) - goto error; - } - } - break; - - case NATIVE_TYPE_INTF: - buf.AppendASCII(KEYWORD(" interface")); - goto DumpIidParamIndex; - case NATIVE_TYPE_IUNKNOWN: - buf.AppendASCII(KEYWORD(" iunknown")); - goto DumpIidParamIndex; - case NATIVE_TYPE_IDISPATCH: - buf.AppendASCII(KEYWORD(" idispatch")); - DumpIidParamIndex: - sz = " "; - if (cbCur < cbNativeType) - { - if (!TrySigUncompress(&pSigNativeType[cbCur], &ulData, cbCur, buf)) - goto error; - buf.AppendPrintf("(%s = %d)",KEYWORD("iidparam"),ulData); - } - break; - - case NATIVE_TYPE_CUSTOMMARSHALER: - { - LPUTF8 strTemp = NULL; - int strLen = 0; - int ByteCountLength = 0; - BOOL fFourStrings = FALSE; - - sz = ""; - buf.AppendASCII(KEYWORD(" custom")); - buf.AppendASCII(" ("); - // Extract the typelib GUID. - strLen = GetLength(&pSigNativeType[cbCur], &ByteCountLength); - cbCur += ByteCountLength; - if(strLen) - { - fFourStrings = TRUE; - strTemp = (LPUTF8)(new char[strLen + 1]); - if(strTemp) - { - memcpy(strTemp, (LPUTF8)&pSigNativeType[cbCur], strLen); - strTemp[strLen] = 0; - buf.AppendPrintf("\"%s\",",UnquotedProperName(strTemp)); - cbCur += strLen; - VDELETE(strTemp); - } - } - if(cbCur >= cbNativeType) - { - // buf.AppendASCII(ERRORMSG("/* INCOMPLETE MARSHALER INFO */")); - buf.Clear(); - goto error; - } - else - { - //_ASSERTE(cbCur < cbNativeType); - - // Extract the name of the native type. - strLen = GetLength(&pSigNativeType[cbCur], &ByteCountLength); - cbCur += ByteCountLength; - if(fFourStrings) - { - if(strLen) - { - strTemp = (LPUTF8)(new char[strLen + 1]); - if(strTemp) - { - memcpy(strTemp, (LPUTF8)&pSigNativeType[cbCur], strLen); - strTemp[strLen] = 0; - buf.AppendPrintf("\"%s\",",UnquotedProperName(strTemp)); - cbCur += strLen; - VDELETE(strTemp); - } - } - else buf.AppendASCII("\"\","); - } - if(cbCur >= cbNativeType) - { - // buf.AppendASCII(ERRORMSG("/* INCOMPLETE MARSHALER INFO */")); - buf.Clear(); - goto error; - } - else - { - //_ASSERTE(cbCur < cbNativeType); - - // Extract the name of the custom marshaler. - strLen = GetLength(&pSigNativeType[cbCur], &ByteCountLength); - cbCur += ByteCountLength; - if(strLen) - { - strTemp = (LPUTF8)(new char[strLen + 1]); - if(strTemp) - { - memcpy(strTemp, (LPUTF8)&pSigNativeType[cbCur], strLen); - strTemp[strLen] = 0; - buf.AppendPrintf("\"%s\",",UnquotedProperName(strTemp)); - cbCur += strLen; - VDELETE(strTemp); - } - } - else buf.AppendASCII("\"\","); - if(cbCur >= cbNativeType) - { - // buf.AppendASCII(ERRORMSG("/* INCOMPLETE MARSHALER INFO */")); - buf.Clear(); - goto error; - } - else - { - // Extract the cookie string. - strLen = GetLength(&pSigNativeType[cbCur], &ByteCountLength); - cbCur += ByteCountLength; - - if(cbCur+strLen > cbNativeType) - { - // buf.AppendASCII(ERRORMSG("/* INCOMPLETE MARSHALER INFO */")); - buf.Clear(); - goto error; - } - else - { - if(strLen) - { - strTemp = (LPUTF8)(new (nothrow) char[strLen + 1]); - if(strTemp) - { - memcpy(strTemp, (LPUTF8)&pSigNativeType[cbCur], strLen); - strTemp[strLen] = 0; - - buf.AppendASCII("\""); - // Copy the cookie string and transform the embedded nulls into \0's. - for (int i = 0; i < strLen - 1; i++, cbCur++) - { - if (strTemp[i] == 0) - buf.AppendASCII("\\0"); - else - { - buf.AppendPrintf("%c", strTemp[i]); - } - } - buf.AppendPrintf("%c\"", strTemp[strLen - 1]); - cbCur++; - VDELETE(strTemp); - } - } - else - buf.AppendASCII("\"\""); - //_ASSERTE(cbCur <= cbNativeType); - } - } - } - } - buf.AppendASCII(")"); - } - break; - default: - { - sz = ""; - } - } // end switch - } - if(*sz) - { - buf.AppendASCII(KEYWORD(sz)); - if(fAddAsterisk) - { - buf.AppendASCII("*"); - fAddAsterisk = FALSE; - } - if(fAddBrackets) - { - ULONG ulSizeParam=(ULONG)-1,ulSizeConst=(ULONG)-1; - buf.AppendASCII("["); - fAddBrackets = FALSE; - if (cbCur < cbNativeType) - { - if (!TrySigUncompress(&pSigNativeType[cbCur], &ulData, cbCur, buf)) - goto error; - ulSizeParam = ulData; - if (cbCur < cbNativeType) - { - if (!TrySigUncompress(&pSigNativeType[cbCur], &ulData, cbCur, buf)) - goto error; - ulSizeConst = ulData; - if (cbCur < cbNativeType) - { - // retrieve flags - if (!TrySigUncompress(&pSigNativeType[cbCur], &ulData, cbCur, buf)) - goto error; - if((ulData & 1) == 0) ulSizeParam = 0xFFFFFFFF; - } - } - } - if(ulSizeConst != 0xFFFFFFFF) - { - buf.AppendPrintf("%d",ulSizeConst); - // if(ulSizeParam == 0) ulSizeParam = 0xFFFFFFFF; // don't need +0 - } - if(ulSizeParam != 0xFFFFFFFF) - { - buf.AppendPrintf(" + %d",ulSizeParam); - } - buf.AppendASCII("]"); - } - - } - - if (ulData >= NATIVE_TYPE_MAX) - break; - } // end while (cbCur < cbNativeType) - // still can have outstanding asterisk or brackets - if(fAddAsterisk) - { - buf.AppendASCII("*"); - fAddAsterisk = FALSE; - } - if(fAddBrackets) - { - ULONG ulSizeParam=(ULONG)-1,ulSizeConst=(ULONG)-1; - buf.AppendASCII("["); - fAddBrackets = FALSE; - if (cbCur < cbNativeType) - { - if (!TrySigUncompress(&pSigNativeType[cbCur], &ulData, cbCur, buf)) - goto error; - ulSizeParam = ulData; - if (cbCur < cbNativeType) - { - if (!TrySigUncompress(&pSigNativeType[cbCur], &ulData, cbCur, buf)) - goto error; - ulSizeConst = ulData; - } - } - if(ulSizeConst != 0xFFFFFFFF) - { - buf.AppendPrintf("%d",ulSizeConst); - // if(ulSizeParam == 0) ulSizeParam = 0xFFFFFFFF; // don't need +0 - } - if(ulSizeParam != 0xFFFFFFFF) - { - buf.AppendPrintf(" + %d",ulSizeParam); - } - buf.AppendASCII("]"); - } - buf.AppendASCII(") "); - }// end if(SUCCEEDED -error: - if (buf.IsEmpty() && cbNativeType != 0) - { - // There was something that we didn't grok in the signature. - // Just dump out the blob as hex - buf.AppendPrintf(" %s({", KEYWORD("marshal")); - while (cbNativeType--) - buf.AppendPrintf(" %2.2X", *pSigNativeType++); - buf.AppendASCII(" }) "); - - char * tgt = szString + strlen(szString); - int sprintf_ret = sprintf_s(tgt, cchszString - (tgt - szString), "%S", buf.GetUnicode()); - if (sprintf_ret == -1) - { - // Hit an error. Oh well, nothing to do... - return tgt; - } - else - { - return tgt + sprintf_ret; - } - } - else - { - char * tgt = szString + strlen(szString); - int sprintf_ret = sprintf_s(tgt, cchszString - (tgt - szString), "%S", buf.GetUnicode()); - if (sprintf_ret == -1) - { - // There was an error, possibly with converting the Unicode characters. - buf.Clear(); - if (cbNativeType != 0) - goto error; - return tgt; // Oh well, nothing to do... - } - else - { - return tgt + sprintf_ret; - } - } -} -#ifdef _PREFAST_ -#pragma warning(pop) -#endif - -char* DumpParamAttr(__inout_ecount(cchszString) char* szString, DWORD cchszString, DWORD dwAttr) -{ - CONTRACTL - { - THROWS; - GC_NOTRIGGER; - } - CONTRACTL_END; - - char *szptr = &szString[strlen(szString)]; - char *was_szptr = szptr; - if(IsPdIn(dwAttr)) - { - szptr+=sprintf_s(szptr,cchszString - (szptr - was_szptr), KEYWORD("[in]")); - } - if(IsPdOut(dwAttr)) - { - szptr+=sprintf_s(szptr,cchszString - (szptr - was_szptr),KEYWORD("[out]")); - } - if(IsPdOptional(dwAttr)) - { - szptr+=sprintf_s(szptr,cchszString - (szptr - was_szptr),KEYWORD("[opt]")); - } - if(szptr != was_szptr) - { - szptr+=sprintf_s(szptr,cchszString - (szptr - was_szptr)," "); - } - return szptr; -} diff --git a/src/inc/formattype.h b/src/inc/formattype.h deleted file mode 100644 index 31a17e06f..000000000 --- a/src/inc/formattype.h +++ /dev/null @@ -1,181 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#ifndef _formatType_h -#define _formatType_h - -#include "corpriv.h" // for IMDInternalImport - -// ILDASM code doesn't memcpy on gc pointers, so it prefers the real -// memcpy rather than GCSafeMemCpy. -#if defined(_DEBUG) && !defined(DACCESS_COMPILE) -#ifdef memcpy -#undef memcpy -#endif -#endif - -#define MAX_PREFIX_SIZE 32 - -struct ParamDescriptor -{ - char* name; - mdToken tok; - DWORD attr; -}; - -char* DumpMarshaling(IMDInternalImport* pImport, - __inout_ecount(cchszString) char* szString, - DWORD cchszString, - mdToken tok); -char* DumpParamAttr(__inout_ecount(cchszString) char* szString, - DWORD cchszString, - DWORD dwAttr); - -void appendStr(CQuickBytes *out, const char* str, unsigned len=(unsigned)-1); -void insertStr(CQuickBytes *out, const char* str); -char* asString(CQuickBytes *out); - -const char* PrettyPrintSig( - PCCOR_SIGNATURE typePtr, // type to convert, - unsigned typeLen, // the lenght of 'typePtr' - const char* name, // can be "", the name of the method for this sig 0 means local var sig - CQuickBytes *out, // where to put the pretty printed string - IMDInternalImport *pIMDI, // ptr to IMDInternalImport class with ComSig - __in_opt const char* inlabel, // prefix for names (NULL if no names required) - BOOL printTyArity=FALSE); // flag to print Type Param number (MemberRefs only) - -PCCOR_SIGNATURE PrettyPrintType( - PCCOR_SIGNATURE typePtr, // type to convert, - CQuickBytes *out, // where to put the pretty printed string - IMDInternalImport *pIMDI); // ptr to IMDInternal class with ComSig - -PCCOR_SIGNATURE PrettyPrintTypeOrDef( // outside ILDASM - simple wrapper of PrettyPrintType - PCCOR_SIGNATURE typePtr, // type to convert, - CQuickBytes *out, // where to put the pretty printed string - IMDInternalImport *pIMDI); // ptr to IMDInternal class with ComSig - - -const char* PrettyPrintClass( - CQuickBytes *out, // where to put the pretty printed string - mdToken tk, // The class token to look up - IMDInternalImport *pIMDI); // ptr to IMDInternalImport class with ComSig - -//================= ILDASM-specific ================================================================== - -#ifdef __ILDASM__ - -#include "../ildasm/dynamicarray.h" - -bool IsNameToQuote(const char *name); -bool IsLocalToQuote(const char *name); -const char* UnquotedProperName(__in __nullterminated const char* name, unsigned len=(unsigned)-1); -const char* ProperName(__in __nullterminated const char* name, bool isLocalName = false); -#define ProperLocalName(x) ProperName(x, true) -const char* KEYWORD(__in_opt __nullterminated const char* szOrig); -const char* COMMENT(__in_opt __nullterminated const char* szOrig); -const char* ERRORMSG(__in_opt __nullterminated const char* szOrig); -const char* ANCHORPT(__in __nullterminated const char* szOrig, mdToken tk); -const char* JUMPPT(__in __nullterminated const char* szOrig, mdToken tk); -const char* SCOPE(void); -const char* UNSCOPE(void); -const char* LTN(void); -const char* GTN(void); -const char* AMP(void); - -extern BOOL g_fDumpRTF,g_fDumpHTML; // declared in FormatType.cpp -//------------------------------------------------------------------------------- -// Protection against null names -extern const char* const szStdNamePrefix[]; //declared in formatType.cpp - -extern DynamicArray *g_dups; -extern DWORD g_NumDups; -inline BOOL IsDup(mdToken tk) -{ - if(g_NumDups) - { - mdToken tktype = TypeFromToken(tk); - if((tktype==mdtTypeDef)||(tktype==mdtMethodDef)||(tktype==mdtFieldDef)) - { - for (unsigned i=0; i>24],tk&0x00FFFFFF); psz = sz; } } - - -struct TypeDefDescr -{ - char* szName; - mdToken tkTypeSpec; - mdToken tkSelf; - PCCOR_SIGNATURE psig; - ULONG cb; -}; -extern DynamicArray *g_typedefs; -extern DWORD g_NumTypedefs; - - -//------------------------------------------------------------------------------- -// Reference analysis (ILDASM) -struct TokPair -{ - mdToken tkUser; - mdToken tkRef; - TokPair() { tkUser = tkRef = 0; }; -}; -extern DynamicArray *g_refs; -extern DWORD g_NumRefs; -extern mdToken g_tkRefUser; // for PrettyPrintSig -#define REGISTER_REF(x,y) if(g_refs && (x)){ (*g_refs)[g_NumRefs].tkUser = x; (*g_refs)[g_NumRefs++].tkRef = y;} - -//-------------------------------------------------------------------------------- -// No-throw deallocators - -#define SDELETE(x) {PAL_CPP_TRY{ delete (x); } PAL_CPP_CATCH_ALL { _ASSERTE(!"AV in scalar deallocator");} PAL_CPP_ENDTRY; (x)=NULL; } -#define VDELETE(x) {PAL_CPP_TRY{ delete [] (x); } PAL_CPP_CATCH_ALL { _ASSERTE(!"AV in vector deallocator");}; PAL_CPP_ENDTRY; (x)=NULL; } - -//-------------------------------------------------------------------------------- -// Generic param names -extern mdToken g_tkVarOwner; -extern mdToken g_tkMVarOwner; -//void SetVarOwner(mdToken tk) { g_tkVarOwner = tk; } -//void SetMVarOwner(mdToken tk) { g_tkMVarOwner = tk; } -BOOL PrettyPrintGP( // defined in dasm.cpp - mdToken tkOwner, // Class, method or 0 - CQuickBytes *out, // where to put the pretty printed generic param - int n); // Index of generic param - -//============== End of ILDASM-specific ================================================================ - -#else - -#define IsNameToQuote(x) false -#define IsLocalToQuote(x) false -#define UnquotedProperName(x) x -#define ProperName(x) x -#define ProperLocalName(x) x -#define KEYWORD(x) x -#define COMMENT(x) x -#define ERRORMSG(x) x -#define ANCHORPT(x,y) x -#define JUMPPT(x,y) x -#define SCOPE() "{" -#define UNSCOPE() "}" -#define LTN() "<" -#define GTN() ">" -#define AMP() "&" -#define REGISTER_REF(x,y) {} -#define MAKE_NAME_IF_NONE(x,y) { } -#define g_fDumpTokens false -#define SDELETE(x) delete (x) -#define VDELETE(x) delete [] (x) - -#endif - -#endif diff --git a/src/inc/fstream.h b/src/inc/fstream.h deleted file mode 100644 index aa81ec8cf..000000000 --- a/src/inc/fstream.h +++ /dev/null @@ -1,50 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - - -#ifndef __FSTREAM_H_INCLUDED__ -#define __FSTREAM_H_INCLUDED__ - -#include - -class CFileStream : public IStream -{ - public: - CFileStream(); - virtual ~CFileStream(); - - HRESULT OpenForRead(LPCWSTR wzFilePath); - HRESULT OpenForWrite(LPCWSTR wzFilePath); - - // IUnknown methods: - STDMETHODIMP_(ULONG) AddRef(); - STDMETHODIMP_(ULONG) Release(); - STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppvObj); - - // ISequentialStream methods: - STDMETHODIMP Read(void *pv, ULONG cb, ULONG *pcbRead); - STDMETHODIMP Write(void const *pv, ULONG cb, ULONG *pcbWritten); - - // IStream methods: - STDMETHODIMP Seek(LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition); - STDMETHODIMP SetSize(ULARGE_INTEGER libNewSize); - STDMETHODIMP CopyTo(IStream *pstm, ULARGE_INTEGER cb, ULARGE_INTEGER *pcbRead, ULARGE_INTEGER *pcbWritten); - STDMETHODIMP Commit(DWORD grfCommitFlags); - STDMETHODIMP Revert(); - STDMETHODIMP LockRegion(ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType); - STDMETHODIMP UnlockRegion(ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType); - STDMETHODIMP Stat(STATSTG *pstatstg, DWORD grfStatFlag); - STDMETHODIMP Clone(IStream **ppIStream); - - private: - BOOL Close(); - - private: - LONG _cRef; - HANDLE _hFile; - -}; - -#endif - diff --git a/src/inc/fstring.h b/src/inc/fstring.h deleted file mode 100644 index 924588589..000000000 --- a/src/inc/fstring.h +++ /dev/null @@ -1,45 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -// --------------------------------------------------------------------------- -// FString.h (Fast String) -// - -// --------------------------------------------------------------------------- - -// ------------------------------------------------------------------------------------------ -// FString is fast string handling namespace - - -// 1) Simple -// 2) No C++ exception -// 3) Optimized for speed - - -#ifndef _FSTRING_H_ -#define _FSTRING_H_ - -namespace FString -{ - // Note: All "length" parameters do not count the space for the null terminator. - // Caller of Unicode_Utf8 and Utf8_Unicode must pass in a buffer of size at least length + 1. - - // Scan for ASCII only string, calculate result UTF8 string length - HRESULT Unicode_Utf8_Length(__in_z LPCWSTR pString, __out bool * pAllAscii, __out DWORD * pLength); - - // Convert UNICODE string to UTF8 string. Direct/fast conversion if ASCII - HRESULT Unicode_Utf8(__in_z LPCWSTR pString, bool allAscii, __out_z LPSTR pBuffer, DWORD length); - - // Scan for ASCII string, calculate result UNICODE string length - HRESULT Utf8_Unicode_Length(__in_z LPCSTR pString, __out bool * pAllAscii, __out DWORD * pLength); - - // Convert UTF8 string to UNICODE. Direct/fast conversion if ASCII - HRESULT Utf8_Unicode(__in_z LPCSTR pString, bool allAscii, __out_z LPWSTR pBuffer, DWORD length); - - HRESULT ConvertUnicode_Utf8(__in_z LPCWSTR pString, __out_z LPSTR * pBuffer); - - HRESULT ConvertUtf8_Unicode(__in_z LPCSTR pString, __out_z LPWSTR * pBuffer); - -} // namespace FString - -#endif // _FSTRING_H_ diff --git a/src/inc/fusionsetup.h b/src/inc/fusionsetup.h deleted file mode 100644 index 87b3e443e..000000000 --- a/src/inc/fusionsetup.h +++ /dev/null @@ -1,63 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - - - -/*============================================================ -** -** Header: FusionSetup.h -** -** Purpose: Defines that are used in both managed and unmanged -** code -** -** -===========================================================*/ -#ifndef _FUSIONSETUP_H -#define _FUSIONSETUP_H - -#define DYNAMIC_DIRECTORY L"DYNAMIC_DIRECTORY" -#define LOADER_OPTIMIZATION L"LOADER_OPTIMIZATION" -#define LICENSE_FILE L"LICENSE_FILE" -#define APPENV_BASE L"APPBASE" -#define APPENV_RELATIVEPATH L"RELPATH" -#define APPENV_GLOBALPATH L"CORPATH" -#define APPENV_DEVPATH L"DEVPATH" -#define APPENV_RUNFROMSOURCE L"__FUSION_RUN_FROM_SOURCE__" -#define CONFIGURATION_EXTENSION L".config" -#define MACHINE_CONFIGURATION_FILE L"config\\machine.config" -#define MANIFEST_FILE_PATH L"MANIFEST_FILE_PATH" -#define VERSIONING_MANIFEST_BASE L"VERSIONING_MANIFEST_BASE" - -#ifndef ACTAG_HOST_CONFIG_FILE -#define ACTAG_HOST_CONFIG_FILE L"HOST_CONFIG" -#endif - -// These are defines instead of enums because they are -// used to change FusionSetup.cs as well as being used in -// unmanaged code. -// If you add a new value, add the corresponding enum value -// to AppDomainSetup+LoaderInformation, and add the corresponding -// property value to AppDomain.GetData() and SetData()'s switch -// statements. -#define LOADER_APPLICATION_BASE 0 -#define LOADER_CONFIGURATION_BASE 1 -#define LOADER_DYNAMIC_BASE 2 -#define LOADER_DEVPATH 3 -#define LOADER_APPLICATION_NAME 4 -#define LOADER_PRIVATE_PATH 5 -#define LOADER_PRIVATE_BIN_PATH_PROBE 6 -#define LOADER_SHADOW_COPY_DIRECTORIES 7 -#define LOADER_SHADOW_COPY_FILES 8 -#define LOADER_CACHE_PATH 9 -#define LOADER_LICENSE_FILE 10 -#define LOADER_DISALLOW_PUBLISHER_POLICY 11 -#define LOADER_DISALLOW_CODE_DOWNLOAD 12 -#define LOADER_DISALLOW_BINDING_REDIRECTS 13 -#define LOADER_DISALLOW_APPBASE_PROBING 14 -#define LOADER_CONFIGURATION_BYTES 15 -#define LOADER_MANIFEST_FILE_PATH 16 -#define LOADER_VERSIONING_MANIFEST_BASE 17 -#define LOADER_MAXIMUM 18 - -#endif diff --git a/src/inc/gcdesc.h b/src/inc/gcdesc.h new file mode 100644 index 000000000..7cc132a64 --- /dev/null +++ b/src/inc/gcdesc.h @@ -0,0 +1,263 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. +// +// +// GC Object Pointer Location Series Stuff +// + + + +#ifndef _GCDESC_H_ +#define _GCDESC_H_ + +#ifdef BIT64 +typedef uint32_t HALF_SIZE_T; +#else // BIT64 +typedef uint16_t HALF_SIZE_T; +#endif + + +typedef size_t *JSlot; + + +// +// These two classes make up the apparatus with which the object references +// within an object can be found. +// +// CGCDescSeries: +// +// The CGCDescSeries class describes a series of object references within an +// object by describing the size of the series (which has an adjustment which +// will be explained later) and the starting point of the series. +// +// The series size is adjusted when the map is created by subtracting the +// GetBaseSize() of the object. On retieval of the size the total size +// of the object is added back. For non-array objects the total object +// size is equal to the base size, so this returns the same value. For +// array objects this will yield the size of the data portion of the array. +// Since arrays containing object references will contain ONLY object references +// this is a fast way of handling arrays and normal objects without a +// conditional test +// +// +// +// CGCDesc: +// +// The CGCDesc is a collection of CGCDescSeries objects to describe all the +// different runs of pointers in a particular object. [add more on the strange +// way the CGCDesc grows backwards in memory behind the MethodTable] +// + +struct val_serie_item +{ + HALF_SIZE_T nptrs; + HALF_SIZE_T skip; + void set_val_serie_item (HALF_SIZE_T nptrs, HALF_SIZE_T skip) + { + this->nptrs = nptrs; + this->skip = skip; + } +}; + +struct val_array_series +{ + val_serie_item items[1]; + size_t m_startOffset; + size_t m_count; +}; + +typedef DPTR(class CGCDescSeries) PTR_CGCDescSeries; +typedef DPTR(class MethodTable) PTR_MethodTable; +class CGCDescSeries +{ +public: + union + { + size_t seriessize; // adjusted length of series (see above) in bytes + val_serie_item val_serie[1]; //coded serie for value class array + }; + + size_t startoffset; + + size_t GetSeriesCount () + { + return seriessize/sizeof(JSlot); + } + + void SetSeriesCount (size_t newcount) + { + seriessize = newcount * sizeof(JSlot); + } + + void IncSeriesCount (size_t increment = 1) + { + seriessize += increment * sizeof(JSlot); + } + + size_t GetSeriesSize () + { + return seriessize; + } + + void SetSeriesSize (size_t newsize) + { + seriessize = newsize; + } + + void SetSeriesValItem (val_serie_item item, int index) + { + val_serie [index] = item; + } + + void SetSeriesOffset (size_t newoffset) + { + startoffset = newoffset; + } + + size_t GetSeriesOffset () + { + return startoffset; + } +}; + + + + + +typedef DPTR(class CGCDesc) PTR_CGCDesc; +class CGCDesc +{ + // Don't construct me, you have to hand me a ptr to the *top* of my storage in Init. + CGCDesc () {} + + // + // NOTE: for alignment reasons, NumSeries is stored as a size_t. + // This makes everything nicely 8-byte aligned on IA64. + // +public: + static size_t ComputeSize (size_t NumSeries) + { + _ASSERTE (ptrdiff_t(NumSeries) > 0); + + return sizeof(size_t) + NumSeries*sizeof(CGCDescSeries); + } + + // For value type array + static size_t ComputeSizeRepeating (size_t NumSeries) + { + _ASSERTE (ptrdiff_t(NumSeries) > 0); + + return sizeof(size_t) + sizeof(CGCDescSeries) + + (NumSeries-1)*sizeof(val_serie_item); + } + +#ifndef DACCESS_COMPILE + static void Init (void* mem, size_t NumSeries) + { + *((size_t*)mem-1) = NumSeries; + } + + static void InitValueClassSeries (void* mem, size_t NumSeries) + { + *((ptrdiff_t*)mem-1) = -((ptrdiff_t)NumSeries); + } +#endif + + static PTR_CGCDesc GetCGCDescFromMT (MethodTable * pMT) + { + // If it doesn't contain pointers, there isn't a GCDesc + PTR_MethodTable mt(pMT); + + _ASSERTE(mt->ContainsPointersOrCollectible()); + + return PTR_CGCDesc(mt); + } + + size_t GetNumSeries () + { + return *(PTR_size_t(PTR_CGCDesc(this))-1); + } + + // Returns lowest series in memory. + // Cannot be used for valuetype arrays + PTR_CGCDescSeries GetLowestSeries () + { + _ASSERTE (ptrdiff_t(GetNumSeries()) > 0); + return PTR_CGCDescSeries(PTR_uint8_t(PTR_CGCDesc(this)) + - ComputeSize(GetNumSeries())); + } + + // Returns highest series in memory. + PTR_CGCDescSeries GetHighestSeries () + { + return PTR_CGCDescSeries(PTR_size_t(PTR_CGCDesc(this))-1)-1; + } + + // Returns number of immediate pointers this object has. + // size is only used if you have an array of value types. +#ifndef DACCESS_COMPILE + static size_t GetNumPointers (MethodTable* pMT, size_t ObjectSize, size_t NumComponents) + { + size_t NumOfPointers = 0; + CGCDesc* map = GetCGCDescFromMT(pMT); + CGCDescSeries* cur = map->GetHighestSeries(); + ptrdiff_t cnt = (ptrdiff_t) map->GetNumSeries(); + + if (cnt > 0) + { + CGCDescSeries* last = map->GetLowestSeries(); + while (cur >= last) + { + NumOfPointers += (cur->GetSeriesSize() + ObjectSize) / sizeof(JSlot); + cur--; + } + } + else + { + /* Handle the repeating case - array of valuetypes */ + for (ptrdiff_t __i = 0; __i > cnt; __i--) + { + NumOfPointers += cur->val_serie[__i].nptrs; + } + + NumOfPointers *= NumComponents; + } + + return NumOfPointers; + } +#endif + + // Size of the entire slot map. + size_t GetSize () + { + ptrdiff_t numSeries = (ptrdiff_t) GetNumSeries(); + if (numSeries < 0) + { + return ComputeSizeRepeating(-numSeries); + } + else + { + return ComputeSize(numSeries); + } + } + + uint8_t *GetStartOfGCData() + { + return ((uint8_t *)this) - GetSize(); + } + +private: + + BOOL IsValueClassSeries() + { + return ((ptrdiff_t) GetNumSeries()) < 0; + } + +}; + +#define MAX_SIZE_FOR_VALUECLASS_IN_ARRAY 0xffff +#define MAX_PTRS_FOR_VALUECLASSS_IN_ARRAY 0xffff + + +#endif // _GCDESC_H_ diff --git a/src/inc/gcinfoarraylist.h b/src/inc/gcinfoarraylist.h deleted file mode 100644 index c19f00d42..000000000 --- a/src/inc/gcinfoarraylist.h +++ /dev/null @@ -1,114 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#ifndef _GCINFOARRAYLIST_H_ -#define _GCINFOARRAYLIST_H_ - -// GCInfoArrayList is basically a more efficient linked list--it's useful for accumulating -// lots of small fixed-size allocations into larger chunks which in a typical linked list -// would incur an unnecessarily high amount of overhead. - -class GcInfoArrayListBase -{ -private: - static const size_t GrowthFactor = 2; - -protected: - friend class IteratorBase; - - struct ChunkBase - { - ChunkBase* m_next; // actually GcInfoArrayListChunk* - }; - - class IteratorBase - { - protected: - IteratorBase(GcInfoArrayListBase* list, size_t firstChunkCapacity); - ChunkBase* GetNextChunk(size_t& elementCount); - - private: - GcInfoArrayListBase* m_list; - ChunkBase* m_currentChunk; - size_t m_currentChunkCount; - }; - - GcInfoArrayListBase(IAllocator* allocator); - virtual ~GcInfoArrayListBase(); - - void AppendNewChunk(size_t firstChunkCapacity, size_t elementSize, size_t chunkAlignment); - -public: - size_t Count() - { - return m_itemCount; - } - -protected: - IAllocator* m_allocator; - ChunkBase* m_firstChunk; // actually GcInfoArrayListChunk* - ChunkBase* m_lastChunk; // actually GcInfoArrayListChunk* - size_t m_lastChunkCount; - size_t m_lastChunkCapacity; - size_t m_itemCount; -}; - -template -class GcInfoArrayList : public GcInfoArrayListBase -{ -private: - struct Chunk : public ChunkBase - { - ElementType m_items[]; - }; - -public: - friend class Iterator; - - struct Iterator : IteratorBase - { - Iterator(GcInfoArrayList* list) - : IteratorBase(list, FirstChunkCapacity) - { - } - - ElementType* GetNext(size_t* elementCount) - { - Chunk* chunk = reinterpret_cast(GetNextChunk(*elementCount)); - return chunk == nullptr ? nullptr : &chunk->m_items[0]; - } - }; - - GcInfoArrayList(IAllocator* allocator) - : GcInfoArrayListBase(allocator) - { - } - - ElementType* Append() - { - if (m_lastChunk == nullptr || m_lastChunkCount == m_lastChunkCapacity) - { - AppendNewChunk(FirstChunkCapacity, sizeof(ElementType), __alignof(ElementType)); - } - - m_itemCount++; - m_lastChunkCount++; - return &reinterpret_cast(m_lastChunk)->m_items[m_lastChunkCount - 1]; - } - - void CopyTo(ElementType* dest) - { - Iterator iter(this); - ElementType* source; - size_t elementCount; - - while (source = iter.GetNext(&elementCount), source != nullptr) - { - memcpy(dest, source, elementCount * sizeof(ElementType)); - dest += elementCount; - } - } -}; - -#endif diff --git a/src/inc/gcinfoencoder.h b/src/inc/gcinfoencoder.h deleted file mode 100644 index b1236ffee..000000000 --- a/src/inc/gcinfoencoder.h +++ /dev/null @@ -1,568 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -/***************************************************************** - * - * GC Information Encoding API - * - *****************************************************************/ - -/***************************************************************** - - ENCODING LAYOUT - - 1. Header - - Slim Header for simple and common cases: - - EncodingType[Slim] - - ReturnKind (Fat: 2 bits) - - CodeLength - - NumCallSites (#ifdef PARTIALLY_INTERRUPTIBLE_GC_SUPPORTED) - - Fat Header for other cases: - - EncodingType[Fat] - - Flag: isVarArg, - hasSecurityObject, - hasGSCookie, - hasPSPSymStackSlot, - hasGenericsInstContextStackSlot, - hasStackBaseregister, - wantsReportOnlyLeaf (AMD64 use only), - hasTailCalls (ARM/ARM64 only) - hasSizeOfEditAndContinuePreservedArea - hasReversePInvokeFrame, - - ReturnKind (Fat: 4 bits) - - CodeLength - - Prolog (if hasSecurityObject || hasGenericsInstContextStackSlot || hasGSCookie) - - Epilog (if hasGSCookie) - - SecurityObjectStackSlot (if any) - - GSCookieStackSlot (if any) - - PSPSymStackSlot (if any) - - GenericsInstContextStackSlot (if any) - - StackBaseRegister (if any) - - SizeOfEditAndContinuePreservedArea (if any) - - ReversePInvokeFrameSlot (if any) - - SizeOfStackOutgoingAndScratchArea (#ifdef FIXED_STACK_PARAMETER_SCRATCH_AREA) - - NumCallSites (#ifdef PARTIALLY_INTERRUPTIBLE_GC_SUPPORTED) - - NumInterruptibleRanges - - 2. Call sites offsets (#ifdef PARTIALLY_INTERRUPTIBLE_GC_SUPPORTED) - 3. Fully-interruptible ranges - 4. Slot table - 5. GC state at call sites (#ifdef PARTIALLY_INTERRUPTIBLE_GC_SUPPORTED) - 6. GC state at try clauses (#ifdef PARTIALLY_INTERRUPTIBLE_GC_SUPPORTED) - 7. Chunk pointers - 8. Chunk encodings - - - STANDALONE_BUILD - - The STANDALONE_BUILD switch can be used to build the GcInfoEncoder library - independently by clients outside the CoreClr tree. - - The GcInfo library uses some custom data-structures (ex: ArrayList, SimplerHashTable) - and includes some utility libraries (ex: UtilCode) which pull in several other - headers with considerable unrelated content. Rather than porting all the - utility code to suite other clients, the STANDALONE_BUILD switch can be used - to include only the minimal set of headers specific to GcInfo encodings. - - Clients of STANDALONE_BUILD will likely use standard library - implementations of data-structures like ArrayList, HashMap etc., in place - of the custom implementation currently used by GcInfoEncoder. - - Rather than spew the GcInfoEnoder code with - #ifdef STANDALONE_BUILD ... #else .. #endif blocks, we include a special - header GcInfoUtil.h in STANDALONE_BUILD mode. GcInfoUtil.h is expected to - supply the interface/implementation for the data-structures and utilities - used by GcInfoEncoder. This header should be provided by the clients doing - the standalone build in their source tree. - -*****************************************************************/ - - -#ifndef __GCINFOENCODER_H__ -#define __GCINFOENCODER_H__ - -#ifdef STANDALONE_BUILD -#include -#include -#include "GcInfoUtil.h" -#include "corjit.h" -#else -#include -#include -#include -#include "corjit.h" -#include "iallocator.h" -#include "gcinfoarraylist.h" -#include "stdmacros.h" -#include "eexcp.h" -#endif - -#include "gcinfotypes.h" - -// As stated in issue #6008, GcInfoSize should be incorporated into debug builds. -#ifdef _DEBUG -#define MEASURE_GCINFO -#endif - -#ifdef MEASURE_GCINFO -struct GcInfoSize -{ - size_t TotalSize; - - size_t NumMethods; - size_t NumCallSites; - size_t NumRanges; - size_t NumRegs; - size_t NumStack; - size_t NumUntracked; - size_t NumTransitions; - size_t SizeOfCode; - size_t EncPreservedSlots; - - size_t UntrackedSlotSize; - size_t NumUntrackedSize; - size_t FlagsSize; - size_t RetKindSize; - size_t CodeLengthSize; - size_t ProEpilogSize; - size_t SecObjSize; - size_t GsCookieSize; - size_t PspSymSize; - size_t GenericsCtxSize; - size_t StackBaseSize; - size_t ReversePInvokeFrameSize; - size_t FixedAreaSize; - size_t NumCallSitesSize; - size_t NumRangesSize; - size_t CallSitePosSize; - size_t RangeSize; - size_t NumRegsSize; - size_t NumStackSize; - size_t RegSlotSize; - size_t StackSlotSize; - size_t CallSiteStateSize; - size_t EhPosSize; - size_t EhStateSize; - size_t ChunkPtrSize; - size_t ChunkMaskSize; - size_t ChunkFinalStateSize; - size_t ChunkTransitionSize; - - GcInfoSize(); - GcInfoSize& operator+=(const GcInfoSize& other); - void Log(DWORD level, const char * header); -}; -#endif - -struct GcSlotDesc -{ - union - { - UINT32 RegisterNumber; - GcStackSlot Stack; - } Slot; - GcSlotFlags Flags; - - BOOL IsRegister() const - { - return (Flags & GC_SLOT_IS_REGISTER); - } - BOOL IsInterior() const - { - return (Flags & GC_SLOT_INTERIOR); - } - BOOL IsPinned() const - { - return (Flags & GC_SLOT_PINNED); - } - BOOL IsUntracked() const - { - return (Flags & GC_SLOT_UNTRACKED); - } - BOOL IsDeleted() const - { - return (Flags & GC_SLOT_IS_DELETED); - } - void MarkDeleted() - { - Flags = (GcSlotFlags) (Flags | GC_SLOT_IS_DELETED); - } -}; - -class BitArray; -class BitStreamWriter -{ -public: - BitStreamWriter( IAllocator* pAllocator ); - - // bit 0 is the least significative bit - void Write( size_t data, UINT32 count ); - void Write( BitArray& a, UINT32 count ); - - inline size_t GetBitCount() - { - return m_BitCount; - } - - inline size_t GetByteCount() - { - return ( m_BitCount + 7 ) / 8; - } - - - void CopyTo( BYTE* buffer ); - void Dispose(); - - //-------------------------------------------------------- - // Compute the number of bits used to encode variable length numbers - // Uses base+1 bits at minimum - // Bits 0..(base-1) represent the encoded quantity - // If it doesn't fit, set bit #base to 1 and use base+1 more bits - //-------------------------------------------------------- - static int SizeofVarLengthUnsigned( size_t n, UINT32 base ); - - //-------------------------------------------------------- - // Encode variable length numbers - // Uses base+1 bits at minimum - // Bits 0..(base-1) represent the encoded quantity - // If it doesn't fit, set bit #base to 1 and use base+1 more bits - //-------------------------------------------------------- - int EncodeVarLengthUnsigned( size_t n, UINT32 base ); - - //-------------------------------------------------------- - // Signed quantities are encoded the same as unsigned - // The most relevant difference is that a number is considered - // to fit in base bits if the topmost bit of a base-long chunk - // matches the sign of the whole number - //-------------------------------------------------------- - int EncodeVarLengthSigned( SSIZE_T n, UINT32 base ); - -private: - class MemoryBlockList; - class MemoryBlock - { - friend class MemoryBlockList; - MemoryBlock* m_next; - - public: - size_t Contents[]; - - inline MemoryBlock* Next() - { - return m_next; - } - }; - - class MemoryBlockList - { - MemoryBlock* m_head; - MemoryBlock* m_tail; - - public: - MemoryBlockList(); - - inline MemoryBlock* Head() - { - return m_head; - } - - MemoryBlock* AppendNew(IAllocator* allocator, size_t bytes); - void Dispose(IAllocator* allocator); - }; - - IAllocator* m_pAllocator; - size_t m_BitCount; - UINT32 m_FreeBitsInCurrentSlot; - MemoryBlockList m_MemoryBlocks; - const static int m_MemoryBlockSize = 128; // must be a multiple of the pointer size - size_t* m_pCurrentSlot; // bits are written through this pointer - size_t* m_OutOfBlockSlot; // sentinel value to determine when the block is full -#ifdef _DEBUG - int m_MemoryBlocksCount; -#endif - -private: - // Writes bits knowing that they will all fit in the current memory slot - inline void WriteInCurrentSlot( size_t data, UINT32 count ) - { - data &= SAFE_SHIFT_LEFT(1, count) - 1; - data <<= (BITS_PER_SIZE_T - m_FreeBitsInCurrentSlot); - *m_pCurrentSlot |= data; - } - - inline void AllocMemoryBlock() - { - _ASSERTE( IS_ALIGNED( m_MemoryBlockSize, sizeof( size_t ) ) ); - MemoryBlock* pMemBlock = m_MemoryBlocks.AppendNew(m_pAllocator, m_MemoryBlockSize); - - m_pCurrentSlot = pMemBlock->Contents; - m_OutOfBlockSlot = m_pCurrentSlot + m_MemoryBlockSize / sizeof( size_t ); - -#ifdef _DEBUG - m_MemoryBlocksCount++; -#endif - - } - - inline void InitCurrentSlot() - { - m_FreeBitsInCurrentSlot = BITS_PER_SIZE_T; - *m_pCurrentSlot = 0; - } -}; - - -typedef UINT32 GcSlotId; - - -inline UINT32 GetNormCodeOffsetChunk(UINT32 normCodeOffset) -{ - return normCodeOffset / NUM_NORM_CODE_OFFSETS_PER_CHUNK; -} - -inline UINT32 GetCodeOffsetChunk(UINT32 codeOffset) -{ - return (NORMALIZE_CODE_OFFSET(codeOffset)) / NUM_NORM_CODE_OFFSETS_PER_CHUNK; -} - -enum GENERIC_CONTEXTPARAM_TYPE -{ - GENERIC_CONTEXTPARAM_NONE = 0, - GENERIC_CONTEXTPARAM_MT = 1, - GENERIC_CONTEXTPARAM_MD = 2, - GENERIC_CONTEXTPARAM_THIS = 3, -}; - -extern void DECLSPEC_NORETURN ThrowOutOfMemory(); - -class GcInfoEncoder -{ -public: - typedef void (*NoMemoryFunction)(void); - - GcInfoEncoder( - ICorJitInfo* pCorJitInfo, - CORINFO_METHOD_INFO* pMethodInfo, - IAllocator* pJitAllocator, - NoMemoryFunction pNoMem = ::ThrowOutOfMemory - ); - - struct LifetimeTransition - { - UINT32 CodeOffset; - GcSlotId SlotId; - BYTE BecomesLive; - BYTE IsDeleted; - }; - - -#ifdef PARTIALLY_INTERRUPTIBLE_GC_SUPPORTED - void DefineCallSites(UINT32* pCallSites, BYTE* pCallSiteSizes, UINT32 numCallSites); -#endif - - //------------------------------------------------------------------------ - // Interruptibility - //------------------------------------------------------------------------ - - // An instruction at offset x will be interruptible - // if-and-only-if startInstructionOffset <= x < startInstructionOffset+length - void DefineInterruptibleRange( UINT32 startInstructionOffset, UINT32 length ); - - - //------------------------------------------------------------------------ - // Slot information - //------------------------------------------------------------------------ - - // - // If spOffset is relative to the current SP, spOffset must be non-negative. - // If spOffset is relative to the SP of the caller (same as SP at the method entry and exit) - // Negative offsets describe GC refs in the local and outgoing areas. - // Positive offsets describe GC refs in the scratch area - // Note that if the dynamic allocation area is resized, the outgoing area will not be valid anymore - // Old slots must be declared dead and new ones can be defined. - // It's up to the JIT to do the right thing. We don't enforce this. - - GcSlotId GetRegisterSlotId( UINT32 regNum, GcSlotFlags flags ); - GcSlotId GetStackSlotId( INT32 spOffset, GcSlotFlags flags, GcStackSlotBase spBase = GC_CALLER_SP_REL ); - - // - // After a FinalizeSlotIds is called, no more slot definitions can be made. - // FinalizeSlotIds must be called once and only once before calling Build() - // - void FinalizeSlotIds(); - - - //------------------------------------------------------------------------ - // Fully-interruptible information - //------------------------------------------------------------------------ - - // - // For inputs, pass zero as offset - // - - // Indicates that the GC state of slot "slotId" becomes (and remains, until another transition) - // "slotState" after the instruction preceding "instructionOffset" (so it is first in this state when - // the IP of a suspended thread is at this instruction offset). - - void SetSlotState( UINT32 instructionOffset, - GcSlotId slotId, - GcSlotState slotState - ); - - - //------------------------------------------------------------------------ - // ReturnKind - //------------------------------------------------------------------------ - - void SetReturnKind(ReturnKind returnKind); - - //------------------------------------------------------------------------ - // Miscellaneous method information - //------------------------------------------------------------------------ - - void SetSecurityObjectStackSlot( INT32 spOffset ); - void SetPrologSize( UINT32 prologSize ); - void SetGSCookieStackSlot( INT32 spOffsetGSCookie, UINT32 validRangeStart, UINT32 validRangeEnd ); - void SetPSPSymStackSlot( INT32 spOffsetPSPSym ); - void SetGenericsInstContextStackSlot( INT32 spOffsetGenericsContext, GENERIC_CONTEXTPARAM_TYPE type); - void SetReversePInvokeFrameSlot(INT32 spOffset); - void SetIsVarArg(); - void SetCodeLength( UINT32 length ); - - // Optional in the general case. Required if the method uses GC_FRAMEREG_REL stack slots - void SetStackBaseRegister( UINT32 registerNumber ); - - // Number of slots preserved during EnC remap - void SetSizeOfEditAndContinuePreservedArea( UINT32 size ); - -#ifdef _TARGET_AMD64_ - // Used to only report a frame once for the leaf function/funclet - // instead of once for each live function/funclet on the stack. - // Called only by RyuJIT (not JIT64) - void SetWantsReportOnlyLeaf(); -#elif defined(_TARGET_ARM_) || defined(_TARGET_ARM64_) - void SetHasTailCalls(); -#endif // _TARGET_AMD64_ - -#ifdef FIXED_STACK_PARAMETER_SCRATCH_AREA - void SetSizeOfStackOutgoingAndScratchArea( UINT32 size ); -#endif // FIXED_STACK_PARAMETER_SCRATCH_AREA - - - //------------------------------------------------------------------------ - // Encoding - //------------------------------------------------------------------------ - - // - // Build() encodes GC information into temporary buffers. - // The method description cannot change after Build is called - // - void Build(); - - // - // Write encoded information to its final destination and frees temporary buffers. - // The encoder shouldn't be used anymore after calling this method. - // It returns a pointer to the destination buffer, which address is byte-aligned - // - BYTE* Emit(); - -private: - - friend int __cdecl CompareLifetimeTransitionsByOffsetThenSlot(const void*, const void*); - friend int CompareLifetimeTransitionsByChunk(const void*, const void*); - - - struct InterruptibleRange - { - UINT32 NormStartOffset; - UINT32 NormStopOffset; - }; - - ICorJitInfo* m_pCorJitInfo; - CORINFO_METHOD_INFO* m_pMethodInfo; - IAllocator* m_pAllocator; - NoMemoryFunction m_pNoMem; - -#ifdef _DEBUG - const char *m_MethodName, *m_ModuleName; -#endif - - BitStreamWriter m_Info1; // Used for everything except for chunk encodings - BitStreamWriter m_Info2; // Used for chunk encodings - - GcInfoArrayList m_InterruptibleRanges; - GcInfoArrayList m_LifetimeTransitions; - - bool m_IsVarArg; -#if defined(_TARGET_AMD64_) - bool m_WantsReportOnlyLeaf; -#elif defined(_TARGET_ARM_) || defined(_TARGET_ARM64_) - bool m_HasTailCalls; -#endif // _TARGET_AMD64_ - INT32 m_SecurityObjectStackSlot; - INT32 m_GSCookieStackSlot; - UINT32 m_GSCookieValidRangeStart; - UINT32 m_GSCookieValidRangeEnd; - INT32 m_PSPSymStackSlot; - INT32 m_GenericsInstContextStackSlot; - GENERIC_CONTEXTPARAM_TYPE m_contextParamType; - ReturnKind m_ReturnKind; - UINT32 m_CodeLength; - UINT32 m_StackBaseRegister; - UINT32 m_SizeOfEditAndContinuePreservedArea; - INT32 m_ReversePInvokeFrameSlot; - InterruptibleRange* m_pLastInterruptibleRange; - -#ifdef FIXED_STACK_PARAMETER_SCRATCH_AREA - UINT32 m_SizeOfStackOutgoingAndScratchArea; -#endif // FIXED_STACK_PARAMETER_SCRATCH_AREA - - void * eeAllocGCInfo (size_t blockSize); - -private: - - friend class EncoderCheckState; - - static const UINT32 m_SlotTableInitialSize = 32; - UINT32 m_SlotTableSize; - UINT32 m_NumSlots; - GcSlotDesc *m_SlotTable; - -#ifdef PARTIALLY_INTERRUPTIBLE_GC_SUPPORTED - UINT32* m_pCallSites; - BYTE* m_pCallSiteSizes; - UINT32 m_NumCallSites; -#endif // PARTIALLY_INTERRUPTIBLE_GC_SUPPORTED - - void GrowSlotTable(); - - void WriteSlotStateVector(BitStreamWriter &writer, const BitArray& vector); - - UINT32 SizeofSlotStateVarLengthVector(const BitArray& vector, UINT32 baseSkip, UINT32 baseRun); - void SizeofSlotStateVarLengthVector(const BitArray& vector, UINT32 baseSkip, UINT32 baseRun, UINT32 * pSizeofSimple, UINT32 * pSizeofRLE, UINT32 * pSizeofRLENeg); - UINT32 WriteSlotStateVarLengthVector(BitStreamWriter &writer, const BitArray& vector, UINT32 baseSkip, UINT32 baseRun); - - bool IsAlwaysScratch(GcSlotDesc &slot); - - // Assumes that "*ppTransitions" is has size "numTransitions", is sorted by CodeOffset then by SlotId, - // and that "*ppEndTransitions" points one beyond the end of the array. If "*ppTransitions" contains - // any dead/live transitions pairs for the same CodeOffset and SlotID, removes those, by allocating a - // new array, and copying the non-removed elements into it. If it does this, sets "*ppTransitions" to - // point to the new array, "*pNumTransitions" to its shorted length, and "*ppEndTransitions" to - // point one beyond the used portion of this array. - void EliminateRedundantLiveDeadPairs(LifetimeTransition** ppTransitions, - size_t* pNumTransitions, - LifetimeTransition** ppEndTransitions); - -#ifdef _DEBUG - bool m_IsSlotTableFrozen; -#endif - -#ifdef MEASURE_GCINFO - GcInfoSize m_CurrentMethodSize; -#endif -}; - -#endif // !__GCINFOENCODER_H__ diff --git a/src/inc/gcrefmap.h b/src/inc/gcrefmap.h deleted file mode 100644 index 0e07074cd..000000000 --- a/src/inc/gcrefmap.h +++ /dev/null @@ -1,247 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - - -#ifndef _GCREFMAP_H_ -#define _GCREFMAP_H_ - -#include "sigbuilder.h" - -// -// The GCRef map is used to encode GC type of arguments for callsites. Logically, it is sequence where pos is -// position of the reference in the stack frame and token is type of GC reference (one of GCREFMAP_XXX values). -// -// - The encoding always starts at the byte boundary. The high order bit of each byte is used to signal end of the encoding -// stream. The last byte has the high order bit zero. It means that there are 7 useful bits in each byte. -// - "pos" is always encoded as delta from previous pos. -// - The basic encoding unit is two bits. Values 0, 1 and 2 are the common constructs (skip single slot, GC reference, interior -// pointer). Value 3 means that extended encoding follows. -// - The extended information is integer encoded in one or more four bit blocks. The high order bit of the four bit block is -// used to signal the end. -// - For x86, the encoding starts by size of the callee poped stack. The size is encoded using the same mechanism as above (two bit -// basic encoding, with extended encoding for large values). - -///////////////////////////////////////////////////////////////////////////////////// -// A utility class to encode sequence of GC summaries for a callsite - -class GCRefMapBuilder -{ - int m_PendingByte; // Pending value, not yet written out - - int m_Bits; // Number of bits in pending byte. Note that the trailing zero bits are not written out, - // so this can be more than 7. - - int m_Pos; // Current position - - SigBuilder m_SigBuilder; - - // Append single bit to the stream - void AppendBit(int bit) - { - if (bit != 0) - { - while (m_Bits >= 7) - { - m_SigBuilder.AppendByte((BYTE)(m_PendingByte | 0x80)); - m_PendingByte = 0; - m_Bits -= 7; - } - - m_PendingByte |= (1 << m_Bits); - } - - m_Bits++; - } - - void AppendTwoBit(int bits) - { - AppendBit(bits & 1); - AppendBit(bits >> 1); - } - - void AppendInt(int val) - { - do { - AppendBit(val & 1); - AppendBit((val >> 1) & 1); - AppendBit((val >> 2) & 1); - - val >>= 3; - - AppendBit((val != 0) ? 1 : 0); - } - while (val != 0); - } - -public: - GCRefMapBuilder() - : m_PendingByte(0), m_Bits(0), m_Pos(0) - { - } - -#ifdef _TARGET_X86_ - void WriteStackPop(int stackPop) - { - if (stackPop < 3) - { - AppendTwoBit(stackPop); - } - else - { - AppendTwoBit(3); - AppendInt(stackPop - 3); - } - } -#endif - - void WriteToken(int pos, int gcRefMapToken) - { - int posDelta = pos - m_Pos; - m_Pos = pos + 1; - - if (posDelta != 0) - { - if (posDelta < 4) - { - // Skipping by one slot at a time for small deltas produces smaller encoding. - while (posDelta > 0) - { - AppendTwoBit(0); - posDelta--; - } - } - else - { - AppendTwoBit(3); - AppendInt((posDelta - 4) << 1); - } - } - - if (gcRefMapToken < 3) - { - AppendTwoBit(gcRefMapToken); - } - else - { - AppendTwoBit(3); - AppendInt(((gcRefMapToken - 3) << 1) | 1); - } - } - - void Flush() - { - if ((m_PendingByte & 0x7F) != 0 || m_Pos == 0) - m_SigBuilder.AppendByte((BYTE)(m_PendingByte & 0x7F)); - - m_PendingByte = 0; - m_Bits = 0; - - m_Pos = 0; - } - - PVOID GetBlob(DWORD * pdwLength) - { - return m_SigBuilder.GetSignature(pdwLength); - } - - DWORD GetBlobLength() - { - return m_SigBuilder.GetSignatureLength(); - } -}; - -///////////////////////////////////////////////////////////////////////////////////// -// A utility class to decode a GC summary for a callsite - -class GCRefMapDecoder -{ - PTR_BYTE m_pCurrentByte; - int m_PendingByte; - int m_Pos; - - FORCEINLINE int GetBit() - { - int x = m_PendingByte; - if (x & 0x80) - { - x = *m_pCurrentByte++; - x |= ((x & 0x80) << 7); - } - m_PendingByte = x >> 1; - return x & 1; - } - - FORCEINLINE int GetTwoBit() - { - int result = GetBit(); - result |= GetBit() << 1; - return result; - } - - int GetInt() - { - int result = 0; - - int bit = 0; - do { - result |= GetBit() << (bit++); - result |= GetBit() << (bit++); - result |= GetBit() << (bit++); - } - while (GetBit() != 0); - - return result; - } - -public: - GCRefMapDecoder(PTR_BYTE pBlob) - : m_pCurrentByte(pBlob), m_PendingByte(0x80), m_Pos(0) - { - } - - BOOL AtEnd() - { - return m_PendingByte == 0; - } - -#ifdef _TARGET_X86_ - UINT ReadStackPop() - { - int x = GetTwoBit(); - - if (x == 3) - x = GetInt() + 3; - - return x; - } -#endif - - int CurrentPos() - { - return m_Pos; - } - - int ReadToken() - { - int val = GetTwoBit(); - if (val == 3) - { - int ext = GetInt(); - if ((ext & 1) == 0) - { - m_Pos += (ext >> 1) + 4; - return GCREFMAP_SKIP; - } - else - { - m_Pos++; - return (ext >> 1) + 3; - } - } - m_Pos++; - return val; - } -}; - -#endif // _GCREFMAP_H_ diff --git a/src/inc/genericstackprobe.inl b/src/inc/genericstackprobe.inl deleted file mode 100644 index 9b8dd410b..000000000 --- a/src/inc/genericstackprobe.inl +++ /dev/null @@ -1,15 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -// - -// - - -#ifndef _GENERICSTACKPROBE_INL_ -#define _GENERICSTACKPROBE_INL_ - -#include "genericstackprobe.h" - - -#endif // _GENERICSTACKPROBE_INL_ diff --git a/src/inc/genheaders.cs b/src/inc/genheaders.cs deleted file mode 100644 index af33b1d17..000000000 --- a/src/inc/genheaders.cs +++ /dev/null @@ -1,222 +0,0 @@ -using System; -using System.Xml; -using System.Xml.Schema; -using System.IO; - -public class GenerateHeaders { - - public static void Main(string[] args) { - - if (args.Length != 3) { - Console.WriteLine("Usage:genheaders XML-file header-file resorce-file"); - return; - } - - ValidateXML(args[0]); - String Message=null; - String SymbolicName=null; - String NumericValue=null; - String tempheaderfile = "temp.h"; - String temprcfile = "temp.rc"; - - StreamWriter HSW=File.CreateText(tempheaderfile); - StreamWriter RSW=File.CreateText(temprcfile); - - int FaciltyUrt=0x13; - int SeveritySuccess=0; - int SeverityError=1; - - int minSR = MakeHresult(SeveritySuccess,FaciltyUrt,0); - int maxSR = MakeHresult(SeveritySuccess,FaciltyUrt,0xffff); - int minHR = MakeHresult(SeverityError,FaciltyUrt,0); - int maxHR = MakeHresult(SeverityError,FaciltyUrt,0xffff); - - - PrintHeader(HSW); - PrintResourceHeader(RSW); - - XmlTextReader rdr = new XmlTextReader(args[0]); - rdr.WhitespaceHandling = WhitespaceHandling.None; - - while (rdr.Read()) { - - switch (rdr.NodeType) { - - case XmlNodeType.Element: - - if (rdr.Name.ToString() == "HRESULT") { - NumericValue=rdr.GetAttribute("NumericValue"); - } - if (rdr.Name.ToString() == "Message") { - Message = rdr.ReadString(); - } - if (rdr.Name.ToString() == "SymbolicName") { - SymbolicName = rdr.ReadString(); - } - - break; - - case XmlNodeType.EndElement: - if(rdr.Name.ToString() == "HRESULT"){ - - // For CLR Hresult's we take the last 4 digits as the resource strings. - - if ( (NumericValue.StartsWith("0x")) || (NumericValue.StartsWith("0X")) ) { - - String HexResult = NumericValue.Substring(2); - int num = int.Parse(HexResult, System.Globalization.NumberStyles.HexNumber); - - if ((num>minSR) && (num <= maxSR)) { - num = num & 0xffff; - HSW.WriteLine("#define " + SymbolicName + " SMAKEHR(0x" + num.ToString("x") + ")"); - } else if ((num>minHR) && (num <= maxHR)) { - num = num & 0xffff; - HSW.WriteLine("#define " + SymbolicName + " EMAKEHR(0x" + num.ToString("x") + ")"); - } else { - HSW.WriteLine("#define " + SymbolicName + " " + NumericValue ); - } - - - - } else { - HSW.WriteLine("#define " + SymbolicName + " " + NumericValue ); - } - - if (Message != null) { - RSW.Write("\tMSG_FOR_URT_HR(" + SymbolicName + ") "); - RSW.WriteLine(Message); - } - - SymbolicName = null; - NumericValue = null; - Message = null; - } - break; - - } - } - - PrintFooter(HSW); - PrintResourceFooter(RSW); - - HSW.Close(); - RSW.Close(); - - bool AreFilesEqual = false; - - if (File.Exists(args[1])) { - StreamReader sr1 = new StreamReader(tempheaderfile); - StreamReader sr2 = new StreamReader(args[1]); - AreFilesEqual = CompareFiles(sr1, sr2); - sr1.Close(); - sr2.Close(); - } - - if (!AreFilesEqual) { - File.Copy(tempheaderfile, args[1], true); - File.Copy(temprcfile, args[2], true); - } - - if (!File.Exists(args[2])) { - File.Copy(temprcfile, args[2], true); - } - - File.Delete(tempheaderfile); - File.Delete(temprcfile); - } - - private static void ValidateXML (String XMLFile) { - - // Set the validation settings on the XmlReaderSettings object. - XmlReaderSettings settings = new XmlReaderSettings(); - - settings.ValidationType = ValidationType.Schema; - settings.ValidationFlags |= XmlSchemaValidationFlags.ProcessInlineSchema; - - settings.ValidationEventHandler += new ValidationEventHandler (ValidationCallBack); - - // Create the XmlReader object. - XmlReader reader = XmlReader.Create(XMLFile, settings); - - // Parse the file. - - while (reader.Read()) { - } - } - - // Display any validation errors. - private static void ValidationCallBack(object sender, ValidationEventArgs e) { - Console.WriteLine("Validation Error: {0}", e.Message); - Environment.Exit(-1); - } - - - private static void PrintHeader(StreamWriter SW) { - - SW.WriteLine("#ifndef __COMMON_LANGUAGE_RUNTIME_HRESULTS__"); - SW.WriteLine("#define __COMMON_LANGUAGE_RUNTIME_HRESULTS__"); - SW.WriteLine(); - SW.WriteLine("#include "); - SW.WriteLine(); - SW.WriteLine(); - SW.WriteLine("//"); - SW.WriteLine("//This file is AutoGenerated -- Do Not Edit by hand!!!"); - SW.WriteLine("//"); - SW.WriteLine("//Add new HRESULTS along with their corresponding error messages to"); - SW.WriteLine("//corerror.xml"); - SW.WriteLine("//"); - SW.WriteLine(); - SW.WriteLine("#ifndef FACILITY_URT"); - SW.WriteLine("#define FACILITY_URT 0x13"); - SW.WriteLine("#endif"); - SW.WriteLine("#ifndef EMAKEHR"); - SW.WriteLine("#define SMAKEHR(val) MAKE_HRESULT(SEVERITY_SUCCESS, FACILITY_URT, val)"); - SW.WriteLine("#define EMAKEHR(val) MAKE_HRESULT(SEVERITY_ERROR, FACILITY_URT, val)"); - SW.WriteLine("#endif"); - SW.WriteLine(); - } - - private static void PrintFooter(StreamWriter SW) { - SW.WriteLine(); - SW.WriteLine(); - SW.WriteLine("#endif // __COMMON_LANGUAGE_RUNTIME_HRESULTS__"); - } - - private static void PrintResourceHeader(StreamWriter SW) { - SW.WriteLine("STRINGTABLE DISCARDABLE"); - SW.WriteLine("BEGIN"); - } - - private static void PrintResourceFooter(StreamWriter SW) { - SW.WriteLine("END"); - } - - private static bool CompareFiles(StreamReader sr1, StreamReader sr2) { - String line1,line2; - - while (true) { - line1 = sr1.ReadLine(); - line2 = sr2.ReadLine(); - - if ( (line1 == null) && (line2 == null) ) { - return true; - } - - if (line1 != line2) { - return false; - } - - } - - } - - private static int MakeHresult(int sev, int fac, int code) { - return ((sev<<31) | (fac<<16) | (code)); - } -} - - - - - - diff --git a/src/inc/genrops.pl b/src/inc/genrops.pl deleted file mode 100644 index 415eea731..000000000 --- a/src/inc/genrops.pl +++ /dev/null @@ -1,91 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. -# -# GENREFOPS.PL -# -# PERL script used to generate the numbering of the reference opcodes -# -#use strict 'vars'; -#use strict 'subs'; -#use strict 'refs'; - -print "Reference opcodes\n"; -print "This file is presently only for human consumption\n"; -print "This file is generated from opcode.def using the genrops.pl script\n\n"; -print "Name String Name refop encode\n"; -print "-----------------------------------------------------------------\n"; - -my $ret = 0; -my %oneByte; -my %twoByte; -$count = 0; -while (<>) -{ - # Process only OPDEF(....) lines - if (/OPDEF\(\s*/) - { - chop; # Strip off trailing CR - s/^OPDEF\(\s*//; # Strip off "OP(" - s/\)$//; # Strip off ")" at end - s/,\s*/,/g; # Remove whitespace - - # Split the line up into its basic parts - ($enumname, $stringname, $pop, $push, $operand, $type, $size, $s1, $s2, $ctrl) = split(/,/); - $s1 =~ s/0x//; - $s1 = hex($s1); - $s2 =~ s/0x//; - $s2 = hex($s2); - - - my $line = sprintf("%-24s %-24s 0x%03x", - $enumname, $stringname, $count); - if ($size == 1) { - $line .= sprintf(" 0x%02x\n", $s2); - if ($oneByte{$s2}) { - printf("Error opcode 0x%x already defined!\n", $s2); - print " Old = $oneByte{$s2}"; - print " New = $line"; - $ret = -1; - } - $oneByte{$s2} = $line; - } - elsif ($size == 2) { - if ($twoByte{$s2}) { - printf("Error opcode 0x%x 0x%x already defined!\n", $s1, $s2); - print " Old = $twoByte{$s2}"; - print " New = $line"; - $ret = -1; - } - $line .= sprintf(" 0x%02x 0x%02x\n", $s1, $s2); - $twoByte{$s2 + 256 * $s1} = $line; - } - else { - $line .= "\n"; - push(@deprecated, $line); - } - $count++; - } -} - -my $opcode; -my $lastOp = -1; -foreach $opcode (sort {$a <=> $b} keys(%oneByte)) { - printf("***** GAP %d instrs ****\n", $opcode - $lastOp) if ($lastOp + 1 != $opcode && $lastOp > 0); - print $oneByte{$opcode}; - $lastOp = $opcode; -} - -$lastOp = -1; -foreach $opcode (sort {$a <=> $b} keys(%twoByte)) { - printf("***** GAP %d instrs ****\n", $opcode - $lastOp) if ($lastOp + 1 != $opcode && $lastOp > 0); - print $twoByte{$opcode}; - $lastOp = $opcode; -} - -print @deprecated; - -exit($ret); - - - diff --git a/src/inc/getproductversionnumber.h b/src/inc/getproductversionnumber.h deleted file mode 100644 index 81367fa3e..000000000 --- a/src/inc/getproductversionnumber.h +++ /dev/null @@ -1,77 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -// -// GetProductVersionNumber.h -// -// Helper function to retrieve the file version number of a file. -// -// ====================================================================================== - - - -#ifndef __GetProductVersionNumber_h__ -#define __GetProductVersionNumber_h__ - -#include "contract.h" -#include "sstring.h" -#include "holder.h" -#include "ex.h" - -//--------------------------------------------------------------------------------------- -// -// Given the full path to an image, return the product version number. -// -// Arguments: -// szFullPath - full path to the image -// pdwVersionMS - out parameter; return the most significant 4 bytes of the version number according to -// the VS_FIXEDFILEINFO convention -// pdwVersionLS - out parameter; return the least significant 4 bytes of the version number according to -// the VS_FIXEDFILEINFO convention -// -// Notes: -// Throws on error - -void inline GetProductVersionNumber(SString &szFullPath, DWORD * pdwVersionMS, DWORD * pdwVersionLS) -{ - WRAPPER_NO_CONTRACT; -#ifndef FEATURE_PAL - - DWORD dwDummy = 0; - DWORD dwFileInfoSize = 0; - - // Get the size of all of the file version information. - dwFileInfoSize = GetFileVersionInfoSize(szFullPath, &dwDummy); - if (dwFileInfoSize == 0) - { - ThrowLastError(); - } - - // Create the buffer to store the file information. - NewHolder pbFileInfo(new BYTE[dwFileInfoSize]); - - // Actually retrieve the file version information. - if (!GetFileVersionInfo(szFullPath, NULL, dwFileInfoSize, pbFileInfo)) - { - ThrowLastError(); - } - - // Now retrieve only the relevant version information, which will be returned in a VS_FIXEDFILEINFO. - UINT uVersionInfoSize = 0; - VS_FIXEDFILEINFO * pVersionInfo = NULL; - - if (!VerQueryValue(pbFileInfo, W("\\"), reinterpret_cast(&pVersionInfo), &uVersionInfoSize)) - { - ThrowLastError(); - } - _ASSERTE(uVersionInfoSize == sizeof(VS_FIXEDFILEINFO)); - - *pdwVersionMS = pVersionInfo->dwProductVersionMS; - *pdwVersionLS = pVersionInfo->dwProductVersionLS; -#else - *pdwVersionMS = 0; - *pdwVersionLS = 0; -#endif // FEATURE_PAL -} - -#endif // __GetProductVersionNumber_h__ diff --git a/src/inc/guidfromname.h b/src/inc/guidfromname.h deleted file mode 100644 index 2974de44a..000000000 --- a/src/inc/guidfromname.h +++ /dev/null @@ -1,19 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - - -#ifndef GUIDFROMNAME_H_ -#define GUIDFROMNAME_H_ - -// GuidFromName.h - function prototype - -void CorGuidFromNameW -( - GUID * pGuidResult, // resulting GUID - LPCWSTR wzName, // the unicode name from which to generate a GUID - SIZE_T cchName // name length in count of unicode character. - // -1 if lstrlen(wzName)+1 should be used -); - -#endif // GUIDFROMNAME_H_ diff --git a/src/inc/hillclimbing.h b/src/inc/hillclimbing.h new file mode 100644 index 000000000..722f4a39c --- /dev/null +++ b/src/inc/hillclimbing.h @@ -0,0 +1,45 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +//========================================================================= + +// +// HillClimbing.h +// +// Defines classes for the ThreadPool's HillClimbing concurrency-optimization +// algorithm. +// + +//========================================================================= + +#ifndef _HILLCLIMBING_H +#define _HILLCLIMBING_H + +enum HillClimbingStateTransition +{ + Warmup, + Initializing, + RandomMove, + ClimbingMove, + ChangePoint, + Stabilizing, + Starvation, //used by ThreadpoolMgr + ThreadTimedOut, //used by ThreadpoolMgr + Undefined, +}; + +#define HillClimbingLogCapacity 200 + +struct HillClimbingLogEntry +{ + DWORD TickCount; + HillClimbingStateTransition Transition; + int NewControlSetting; + int LastHistoryCount; + float LastHistoryMean; +}; + +typedef DPTR(HillClimbingLogEntry) PTR_HillClimbingLogEntry; + +#endif diff --git a/src/inc/holderinst.h b/src/inc/holderinst.h deleted file mode 100644 index ee59da084..000000000 --- a/src/inc/holderinst.h +++ /dev/null @@ -1,33 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - - -#ifndef __HOLDERINST_H_ -#define __HOLDERINST_H_ - -// This file contains holder instantiations which we can't put in holder.h because -// the instantiations require _ASSERTE to be defined, which is not always the case -// for placed that include holder.h. - -FORCEINLINE void SafeArrayRelease(SAFEARRAY* p) -{ - SafeArrayDestroy(p); -} - - -class SafeArrayHolder : public Wrapper -{ -public: - SafeArrayHolder(SAFEARRAY* p = NULL) - : Wrapper(p) - { - } - - FORCEINLINE void operator=(SAFEARRAY* p) - { - Wrapper::operator=(p); - } -}; - -#endif // __HOLDERINST_H_ diff --git a/src/inc/iappdomainsetup.h b/src/inc/iappdomainsetup.h deleted file mode 100644 index ef8d9a3cf..000000000 --- a/src/inc/iappdomainsetup.h +++ /dev/null @@ -1,612 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -// - -// ******************************************************** -// ******************************************************** -// ******************************************************** -// -// !!!! DON'T USE THIS FILE, IT WILL BE OBSOLETE SOON !!!! -// -// ******************************************************** -// ******************************************************** -// ******************************************************** - - - - -#ifndef FEATURE_COMINTEROP -#error FEATURE_COMINTEROP is required for this file -#endif // FEATURE_COMINTEROP - - - -#ifdef _MSC_VER -#pragma warning( disable: 4049 ) /* more than 64k source lines */ -#endif - -/* this ALWAYS GENERATED file contains the definitions for the interfaces */ - - - /* File created by MIDL compiler version 6.00.0338 */ -/* at Wed Jan 17 16:59:41 2001 - */ -/* Compiler settings for IAppDomainSetup.idl: - Os, W1, Zp8, env=Win32 (32b run) - protocol : dce , ms_ext, c_ext - error checks: allocation ref bounds_check enum stub_data - VC __declspec() decoration level: - __declspec(uuid()), __declspec(selectany), __declspec(novtable) - DECLSPEC_UUID(), MIDL_INTERFACE() -*/ -//@@MIDL_FILE_HEADING( ) - - -/* verify that the version is high enough to compile this file*/ -#ifndef __REQUIRED_RPCNDR_H_VERSION__ -#define __REQUIRED_RPCNDR_H_VERSION__ 440 -#endif - -#include "rpc.h" -#include "rpcndr.h" - -#ifndef __RPCNDR_H_VERSION__ -#error this stub requires an updated version of -#endif // __RPCNDR_H_VERSION__ - -#ifndef COM_NO_WINDOWS_H -#include "windows.h" -#include "ole2.h" -#endif /*COM_NO_WINDOWS_H*/ - -#ifndef __IAppDomainSetup_h__ -#define __IAppDomainSetup_h__ - -#if defined(_MSC_VER) && (_MSC_VER >= 1020) -#pragma once -#endif - -/* Forward Declarations */ - -#ifndef __IAppDomainSetup_FWD_DEFINED__ -#define __IAppDomainSetup_FWD_DEFINED__ -typedef interface IAppDomainSetup IAppDomainSetup; -#endif /* __IAppDomainSetup_FWD_DEFINED__ */ - - -/* header files for imported files */ -#include "unknwn.h" - -#ifdef __cplusplus -extern "C"{ -#endif - -void * __RPC_USER MIDL_user_allocate(size_t); -void __RPC_USER MIDL_user_free( void * ); - -#ifndef __IAppDomainSetup_INTERFACE_DEFINED__ -#define __IAppDomainSetup_INTERFACE_DEFINED__ - -/* interface IAppDomainSetup */ -/* [object][oleautomation][version][uuid] */ - - -EXTERN_C const IID IID_IAppDomainSetup; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("27FFF232-A7A8-40DD-8D4A-734AD59FCD41") - IAppDomainSetup : public IUnknown - { - public: - virtual /* [propget] */ HRESULT __stdcall get_ApplicationBase( - /* [retval][out] */ BSTR *pRetVal) = 0; - - virtual /* [propput] */ HRESULT __stdcall put_ApplicationBase( - /* [in] */ BSTR pRetVal) = 0; - - virtual /* [propget] */ HRESULT __stdcall get_ApplicationName( - /* [retval][out] */ BSTR *pRetVal) = 0; - - virtual /* [propput] */ HRESULT __stdcall put_ApplicationName( - /* [in] */ BSTR pRetVal) = 0; - - virtual /* [propget] */ HRESULT __stdcall get_CachePath( - /* [retval][out] */ BSTR *pRetVal) = 0; - - virtual /* [propput] */ HRESULT __stdcall put_CachePath( - /* [in] */ BSTR pRetVal) = 0; - - virtual /* [propget] */ HRESULT __stdcall get_ConfigurationFile( - /* [retval][out] */ BSTR *pRetVal) = 0; - - virtual /* [propput] */ HRESULT __stdcall put_ConfigurationFile( - /* [in] */ BSTR pRetVal) = 0; - - virtual /* [propget] */ HRESULT __stdcall get_DynamicBase( - /* [retval][out] */ BSTR *pRetVal) = 0; - - virtual /* [propput] */ HRESULT __stdcall put_DynamicBase( - /* [in] */ BSTR pRetVal) = 0; - - virtual /* [propget] */ HRESULT __stdcall get_LicenseFile( - /* [retval][out] */ BSTR *pRetVal) = 0; - - virtual /* [propput] */ HRESULT __stdcall put_LicenseFile( - /* [in] */ BSTR pRetVal) = 0; - - virtual /* [propget] */ HRESULT __stdcall get_PrivateBinPath( - /* [retval][out] */ BSTR *pRetVal) = 0; - - virtual /* [propput] */ HRESULT __stdcall put_PrivateBinPath( - /* [in] */ BSTR pRetVal) = 0; - - virtual /* [propget] */ HRESULT __stdcall get_PrivateBinPathProbe( - /* [retval][out] */ BSTR *pRetVal) = 0; - - virtual /* [propput] */ HRESULT __stdcall put_PrivateBinPathProbe( - /* [in] */ BSTR pRetVal) = 0; - - virtual /* [propget] */ HRESULT __stdcall get_ShadowCopyDirectories( - /* [retval][out] */ BSTR *pRetVal) = 0; - - virtual /* [propput] */ HRESULT __stdcall put_ShadowCopyDirectories( - /* [in] */ BSTR pRetVal) = 0; - - virtual /* [propget] */ HRESULT __stdcall get_ShadowCopyFiles( - /* [retval][out] */ BSTR *pRetVal) = 0; - - virtual /* [propput] */ HRESULT __stdcall put_ShadowCopyFiles( - /* [in] */ BSTR pRetVal) = 0; - - }; - -#else /* C style interface */ - - typedef struct IAppDomainSetupVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - IAppDomainSetup * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - IAppDomainSetup * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - IAppDomainSetup * This); - - /* [propget] */ HRESULT ( __stdcall *get_ApplicationBase )( - IAppDomainSetup * This, - /* [retval][out] */ BSTR *pRetVal); - - /* [propput] */ HRESULT ( __stdcall *put_ApplicationBase )( - IAppDomainSetup * This, - /* [in] */ BSTR pRetVal); - - /* [propget] */ HRESULT ( __stdcall *get_ApplicationName )( - IAppDomainSetup * This, - /* [retval][out] */ BSTR *pRetVal); - - /* [propput] */ HRESULT ( __stdcall *put_ApplicationName )( - IAppDomainSetup * This, - /* [in] */ BSTR pRetVal); - - /* [propget] */ HRESULT ( __stdcall *get_CachePath )( - IAppDomainSetup * This, - /* [retval][out] */ BSTR *pRetVal); - - /* [propput] */ HRESULT ( __stdcall *put_CachePath )( - IAppDomainSetup * This, - /* [in] */ BSTR pRetVal); - - /* [propget] */ HRESULT ( __stdcall *get_ConfigurationFile )( - IAppDomainSetup * This, - /* [retval][out] */ BSTR *pRetVal); - - /* [propput] */ HRESULT ( __stdcall *put_ConfigurationFile )( - IAppDomainSetup * This, - /* [in] */ BSTR pRetVal); - - /* [propget] */ HRESULT ( __stdcall *get_DynamicBase )( - IAppDomainSetup * This, - /* [retval][out] */ BSTR *pRetVal); - - /* [propput] */ HRESULT ( __stdcall *put_DynamicBase )( - IAppDomainSetup * This, - /* [in] */ BSTR pRetVal); - - /* [propget] */ HRESULT ( __stdcall *get_LicenseFile )( - IAppDomainSetup * This, - /* [retval][out] */ BSTR *pRetVal); - - /* [propput] */ HRESULT ( __stdcall *put_LicenseFile )( - IAppDomainSetup * This, - /* [in] */ BSTR pRetVal); - - /* [propget] */ HRESULT ( __stdcall *get_PrivateBinPath )( - IAppDomainSetup * This, - /* [retval][out] */ BSTR *pRetVal); - - /* [propput] */ HRESULT ( __stdcall *put_PrivateBinPath )( - IAppDomainSetup * This, - /* [in] */ BSTR pRetVal); - - /* [propget] */ HRESULT ( __stdcall *get_PrivateBinPathProbe )( - IAppDomainSetup * This, - /* [retval][out] */ BSTR *pRetVal); - - /* [propput] */ HRESULT ( __stdcall *put_PrivateBinPathProbe )( - IAppDomainSetup * This, - /* [in] */ BSTR pRetVal); - - /* [propget] */ HRESULT ( __stdcall *get_ShadowCopyDirectories )( - IAppDomainSetup * This, - /* [retval][out] */ BSTR *pRetVal); - - /* [propput] */ HRESULT ( __stdcall *put_ShadowCopyDirectories )( - IAppDomainSetup * This, - /* [in] */ BSTR pRetVal); - - /* [propget] */ HRESULT ( __stdcall *get_ShadowCopyFiles )( - IAppDomainSetup * This, - /* [retval][out] */ BSTR *pRetVal); - - /* [propput] */ HRESULT ( __stdcall *put_ShadowCopyFiles )( - IAppDomainSetup * This, - /* [in] */ BSTR pRetVal); - - END_INTERFACE - } IAppDomainSetupVtbl; - - interface IAppDomainSetup - { - CONST_VTBL struct IAppDomainSetupVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define IAppDomainSetup_QueryInterface(This,riid,ppvObject) \ - (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) - -#define IAppDomainSetup_AddRef(This) \ - (This)->lpVtbl -> AddRef(This) - -#define IAppDomainSetup_Release(This) \ - (This)->lpVtbl -> Release(This) - - -#define IAppDomainSetup_get_ApplicationBase(This,pRetVal) \ - (This)->lpVtbl -> get_ApplicationBase(This,pRetVal) - -#define IAppDomainSetup_put_ApplicationBase(This,pRetVal) \ - (This)->lpVtbl -> put_ApplicationBase(This,pRetVal) - -#define IAppDomainSetup_get_ApplicationName(This,pRetVal) \ - (This)->lpVtbl -> get_ApplicationName(This,pRetVal) - -#define IAppDomainSetup_put_ApplicationName(This,pRetVal) \ - (This)->lpVtbl -> put_ApplicationName(This,pRetVal) - -#define IAppDomainSetup_get_CachePath(This,pRetVal) \ - (This)->lpVtbl -> get_CachePath(This,pRetVal) - -#define IAppDomainSetup_put_CachePath(This,pRetVal) \ - (This)->lpVtbl -> put_CachePath(This,pRetVal) - -#define IAppDomainSetup_get_ConfigurationFile(This,pRetVal) \ - (This)->lpVtbl -> get_ConfigurationFile(This,pRetVal) - -#define IAppDomainSetup_put_ConfigurationFile(This,pRetVal) \ - (This)->lpVtbl -> put_ConfigurationFile(This,pRetVal) - -#define IAppDomainSetup_get_DynamicBase(This,pRetVal) \ - (This)->lpVtbl -> get_DynamicBase(This,pRetVal) - -#define IAppDomainSetup_put_DynamicBase(This,pRetVal) \ - (This)->lpVtbl -> put_DynamicBase(This,pRetVal) - -#define IAppDomainSetup_get_LicenseFile(This,pRetVal) \ - (This)->lpVtbl -> get_LicenseFile(This,pRetVal) - -#define IAppDomainSetup_put_LicenseFile(This,pRetVal) \ - (This)->lpVtbl -> put_LicenseFile(This,pRetVal) - -#define IAppDomainSetup_get_PrivateBinPath(This,pRetVal) \ - (This)->lpVtbl -> get_PrivateBinPath(This,pRetVal) - -#define IAppDomainSetup_put_PrivateBinPath(This,pRetVal) \ - (This)->lpVtbl -> put_PrivateBinPath(This,pRetVal) - -#define IAppDomainSetup_get_PrivateBinPathProbe(This,pRetVal) \ - (This)->lpVtbl -> get_PrivateBinPathProbe(This,pRetVal) - -#define IAppDomainSetup_put_PrivateBinPathProbe(This,pRetVal) \ - (This)->lpVtbl -> put_PrivateBinPathProbe(This,pRetVal) - -#define IAppDomainSetup_get_ShadowCopyDirectories(This,pRetVal) \ - (This)->lpVtbl -> get_ShadowCopyDirectories(This,pRetVal) - -#define IAppDomainSetup_put_ShadowCopyDirectories(This,pRetVal) \ - (This)->lpVtbl -> put_ShadowCopyDirectories(This,pRetVal) - -#define IAppDomainSetup_get_ShadowCopyFiles(This,pRetVal) \ - (This)->lpVtbl -> get_ShadowCopyFiles(This,pRetVal) - -#define IAppDomainSetup_put_ShadowCopyFiles(This,pRetVal) \ - (This)->lpVtbl -> put_ShadowCopyFiles(This,pRetVal) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - -/* [propget] */ HRESULT __stdcall IAppDomainSetup_get_ApplicationBase_Proxy( - IAppDomainSetup * This, - /* [retval][out] */ BSTR *pRetVal); - - -void __RPC_STUB IAppDomainSetup_get_ApplicationBase_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [propput] */ HRESULT __stdcall IAppDomainSetup_put_ApplicationBase_Proxy( - IAppDomainSetup * This, - /* [in] */ BSTR pRetVal); - - -void __RPC_STUB IAppDomainSetup_put_ApplicationBase_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [propget] */ HRESULT __stdcall IAppDomainSetup_get_ApplicationName_Proxy( - IAppDomainSetup * This, - /* [retval][out] */ BSTR *pRetVal); - - -void __RPC_STUB IAppDomainSetup_get_ApplicationName_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [propput] */ HRESULT __stdcall IAppDomainSetup_put_ApplicationName_Proxy( - IAppDomainSetup * This, - /* [in] */ BSTR pRetVal); - - -void __RPC_STUB IAppDomainSetup_put_ApplicationName_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [propget] */ HRESULT __stdcall IAppDomainSetup_get_CachePath_Proxy( - IAppDomainSetup * This, - /* [retval][out] */ BSTR *pRetVal); - - -void __RPC_STUB IAppDomainSetup_get_CachePath_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [propput] */ HRESULT __stdcall IAppDomainSetup_put_CachePath_Proxy( - IAppDomainSetup * This, - /* [in] */ BSTR pRetVal); - - -void __RPC_STUB IAppDomainSetup_put_CachePath_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [propget] */ HRESULT __stdcall IAppDomainSetup_get_ConfigurationFile_Proxy( - IAppDomainSetup * This, - /* [retval][out] */ BSTR *pRetVal); - - -void __RPC_STUB IAppDomainSetup_get_ConfigurationFile_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [propput] */ HRESULT __stdcall IAppDomainSetup_put_ConfigurationFile_Proxy( - IAppDomainSetup * This, - /* [in] */ BSTR pRetVal); - - -void __RPC_STUB IAppDomainSetup_put_ConfigurationFile_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [propget] */ HRESULT __stdcall IAppDomainSetup_get_DynamicBase_Proxy( - IAppDomainSetup * This, - /* [retval][out] */ BSTR *pRetVal); - - -void __RPC_STUB IAppDomainSetup_get_DynamicBase_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [propput] */ HRESULT __stdcall IAppDomainSetup_put_DynamicBase_Proxy( - IAppDomainSetup * This, - /* [in] */ BSTR pRetVal); - - -void __RPC_STUB IAppDomainSetup_put_DynamicBase_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [propget] */ HRESULT __stdcall IAppDomainSetup_get_LicenseFile_Proxy( - IAppDomainSetup * This, - /* [retval][out] */ BSTR *pRetVal); - - -void __RPC_STUB IAppDomainSetup_get_LicenseFile_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [propput] */ HRESULT __stdcall IAppDomainSetup_put_LicenseFile_Proxy( - IAppDomainSetup * This, - /* [in] */ BSTR pRetVal); - - -void __RPC_STUB IAppDomainSetup_put_LicenseFile_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [propget] */ HRESULT __stdcall IAppDomainSetup_get_PrivateBinPath_Proxy( - IAppDomainSetup * This, - /* [retval][out] */ BSTR *pRetVal); - - -void __RPC_STUB IAppDomainSetup_get_PrivateBinPath_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [propput] */ HRESULT __stdcall IAppDomainSetup_put_PrivateBinPath_Proxy( - IAppDomainSetup * This, - /* [in] */ BSTR pRetVal); - - -void __RPC_STUB IAppDomainSetup_put_PrivateBinPath_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [propget] */ HRESULT __stdcall IAppDomainSetup_get_PrivateBinPathProbe_Proxy( - IAppDomainSetup * This, - /* [retval][out] */ BSTR *pRetVal); - - -void __RPC_STUB IAppDomainSetup_get_PrivateBinPathProbe_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [propput] */ HRESULT __stdcall IAppDomainSetup_put_PrivateBinPathProbe_Proxy( - IAppDomainSetup * This, - /* [in] */ BSTR pRetVal); - - -void __RPC_STUB IAppDomainSetup_put_PrivateBinPathProbe_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [propget] */ HRESULT __stdcall IAppDomainSetup_get_ShadowCopyDirectories_Proxy( - IAppDomainSetup * This, - /* [retval][out] */ BSTR *pRetVal); - - -void __RPC_STUB IAppDomainSetup_get_ShadowCopyDirectories_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [propput] */ HRESULT __stdcall IAppDomainSetup_put_ShadowCopyDirectories_Proxy( - IAppDomainSetup * This, - /* [in] */ BSTR pRetVal); - - -void __RPC_STUB IAppDomainSetup_put_ShadowCopyDirectories_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [propget] */ HRESULT __stdcall IAppDomainSetup_get_ShadowCopyFiles_Proxy( - IAppDomainSetup * This, - /* [retval][out] */ BSTR *pRetVal); - - -void __RPC_STUB IAppDomainSetup_get_ShadowCopyFiles_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [propput] */ HRESULT __stdcall IAppDomainSetup_put_ShadowCopyFiles_Proxy( - IAppDomainSetup * This, - /* [in] */ BSTR pRetVal); - - -void __RPC_STUB IAppDomainSetup_put_ShadowCopyFiles_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - - -#endif /* __IAppDomainSetup_INTERFACE_DEFINED__ */ - - -/* Additional Prototypes for ALL interfaces */ - -unsigned long __RPC_USER BSTR_UserSize( unsigned long *, unsigned long , BSTR * ); -unsigned char * __RPC_USER BSTR_UserMarshal( unsigned long *, unsigned char *, BSTR * ); -unsigned char * __RPC_USER BSTR_UserUnmarshal(unsigned long *, unsigned char *, BSTR * ); -void __RPC_USER BSTR_UserFree( unsigned long *, BSTR * ); - -/* end of Additional Prototypes */ - -#ifdef __cplusplus -} -#endif - -#endif - - diff --git a/src/inc/iceefilegen.h b/src/inc/iceefilegen.h deleted file mode 100644 index c33a7b12e..000000000 --- a/src/inc/iceefilegen.h +++ /dev/null @@ -1,234 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/***************************************************************************** - ** ** - ** ICeeFileGen.h - code generator interface. ** - ** ** - ** This interface provides functionality to create a CLR PE executable. ** - ** This will typically be used by compilers to generate their compiled ** - ** output executable. ** - ** ** - *****************************************************************************/ - -/* - This is how this is typically used: - - // Step #1 ... Get CLR hosting API: - #include - #include - - ICLRMetaHost * pMetaHost; - CLRCreateInstance(CLSID_CLRMetaHost, IID_ICLRMetaHost, &pMetaHost); // defined in mscoree.h - - ICLRRuntimeInfo * pCLRRuntimeInfo; - pMetaHost->GetRuntime(wszClrVersion, IID_ICLRRuntimeInfo, &pCLRRuntimeInfo); - - // Step #2 ... use mscorpe APIs to create a file generator - CreateICeeFileGen(...); // Get a ICeeFileGen - - CreateCeeFile(...); // Get a HCEEFILE (called for every output file needed) - SetOutputFileName(...); // Set the name for the output file - pEmit = IMetaDataEmit object; // Get a metadata emitter - GetSectionBlock(...);, AddSectionReloc(...); ... // Get blocks, write non-metadata information, and add necessary relocation - EmitMetaDataEx(pEmit); // Write out the metadata - GenerateCeeFile(...); // Write out the file. Implicitly calls LinkCeeFile and FixupCeeFile - - DestroyICeeFileGen(...); // Release the ICeeFileGen object -*/ - - -#ifndef _ICEEFILEGEN_H_ -#define _ICEEFILEGEN_H_ - -#include -#include "cor.h" - -class ICeeFileGen; - -typedef void *HCEEFILE; - -EXTERN_C HRESULT __stdcall CreateICeeFileGen(ICeeFileGen** pCeeFileGen); -EXTERN_C HRESULT __stdcall DestroyICeeFileGen(ICeeFileGen ** ppCeeFileGen); - -typedef HRESULT (__stdcall * PFN_CreateICeeFileGen)(ICeeFileGen ** ceeFileGen); // call this to instantiate an ICeeFileGen interface -typedef HRESULT (__stdcall * PFN_DestroyICeeFileGen)(ICeeFileGen ** ceeFileGen); // call this to delete an ICeeFileGen - -#define ICEE_CREATE_FILE_PE32 0x00000001 // Create a PE (32-bit) -#define ICEE_CREATE_FILE_PE64 0x00000002 // Create a PE+ (64-bit) -#define ICEE_CREATE_FILE_CORMAIN_STUB 0x00000004 // add a mscoree!_Cor___Main call stub -#define ICEE_CREATE_FILE_STRIP_RELOCS 0x00000008 // strip the .reloc section -#define ICEE_CREATE_FILE_EMIT_FIXUPS 0x00000010 // emit fixups for use by Vulcan - -#define ICEE_CREATE_MACHINE_MASK 0x0000FF00 // space for up to 256 machine targets -#define ICEE_CREATE_MACHINE_ILLEGAL 0x00000000 // An illegal machine name -#define ICEE_CREATE_MACHINE_I386 0x00000100 // Create a IMAGE_FILE_MACHINE_I386 -#define ICEE_CREATE_MACHINE_IA64 0x00000200 // Create a IMAGE_FILE_MACHINE_IA64 -#define ICEE_CREATE_MACHINE_AMD64 0x00000400 // Create a IMAGE_FILE_MACHINE_AMD64 -#define ICEE_CREATE_MACHINE_ARM 0x00000800 // Create a IMAGE_FILE_MACHINE_ARMNT - - // Pass this to CreateCeeFileEx to create a pure IL Exe or DLL -#define ICEE_CREATE_FILE_PURE_IL ICEE_CREATE_FILE_PE32 | \ - ICEE_CREATE_FILE_CORMAIN_STUB | \ - ICEE_CREATE_MACHINE_I386 - -class ICeeFileGen { - public: - virtual HRESULT CreateCeeFile(HCEEFILE *ceeFile); // call this to instantiate a file handle - - // @FUTURE: remove this function. We no longer support mdScope. - virtual HRESULT EmitMetaData (HCEEFILE ceeFile, IMetaDataEmit *emitter, mdScope scope); - virtual HRESULT EmitLibraryName (HCEEFILE ceeFile, IMetaDataEmit *emitter, mdScope scope); - virtual HRESULT EmitMethod (); // @FUTURE: remove - virtual HRESULT GetMethodRVA (HCEEFILE ceeFile, ULONG codeOffset, ULONG *codeRVA); - virtual HRESULT EmitSignature (); // @FUTURE: remove - - virtual HRESULT EmitString (HCEEFILE ceeFile,_In_ LPWSTR strValue, ULONG *strRef); - virtual HRESULT GenerateCeeFile (HCEEFILE ceeFile); - - virtual HRESULT SetOutputFileName (HCEEFILE ceeFile, _In_ LPWSTR outputFileName); - _Return_type_success_(return == S_OK) - virtual HRESULT GetOutputFileName (HCEEFILE ceeFile, _Out_ LPWSTR *outputFileName); - - virtual HRESULT SetResourceFileName (HCEEFILE ceeFile, _In_ LPWSTR resourceFileName); - - _Return_type_success_(return == S_OK) - virtual HRESULT GetResourceFileName (HCEEFILE ceeFile, _Out_ LPWSTR *resourceFileName); - - virtual HRESULT SetImageBase(HCEEFILE ceeFile, size_t imageBase); - - virtual HRESULT SetSubsystem(HCEEFILE ceeFile, DWORD subsystem, DWORD major, DWORD minor); - - virtual HRESULT SetEntryClassToken (); //@FUTURE: remove - virtual HRESULT GetEntryClassToken (); //@FUTURE: remove - - virtual HRESULT SetEntryPointDescr (); //@FUTURE: remove - virtual HRESULT GetEntryPointDescr (); //@FUTURE: remove - - virtual HRESULT SetEntryPointFlags (); //@FUTURE: remove - virtual HRESULT GetEntryPointFlags (); //@FUTURE: remove - - virtual HRESULT SetDllSwitch (HCEEFILE ceeFile, BOOL dllSwitch); - virtual HRESULT GetDllSwitch (HCEEFILE ceeFile, BOOL *dllSwitch); - - virtual HRESULT SetLibraryName (HCEEFILE ceeFile, _In_ LPWSTR LibraryName); - _Return_type_success_( return == S_OK ) - virtual HRESULT GetLibraryName (HCEEFILE ceeFile, _Out_ LPWSTR *LibraryName); - - virtual HRESULT SetLibraryGuid (HCEEFILE ceeFile, _In_ LPWSTR LibraryGuid); - - virtual HRESULT DestroyCeeFile(HCEEFILE *ceeFile); // call this to delete a file handle - - virtual HRESULT GetSectionCreate (HCEEFILE ceeFile, const char *name, DWORD flags, HCEESECTION *section); - virtual HRESULT GetIlSection (HCEEFILE ceeFile, HCEESECTION *section); - virtual HRESULT GetRdataSection (HCEEFILE ceeFile, HCEESECTION *section); - - virtual HRESULT GetSectionDataLen (HCEESECTION section, ULONG *dataLen); - virtual HRESULT GetSectionBlock (HCEESECTION section, ULONG len, ULONG align=1, void **ppBytes=0); - virtual HRESULT TruncateSection (HCEESECTION section, ULONG len); - virtual HRESULT AddSectionReloc (HCEESECTION section, ULONG offset, HCEESECTION relativeTo, CeeSectionRelocType relocType); - - // deprecated: use SetDirectoryEntry instead - virtual HRESULT SetSectionDirectoryEntry (HCEESECTION section, ULONG num); - - virtual HRESULT CreateSig (); //@FUTURE: Remove - virtual HRESULT AddSigArg (); //@FUTURE: Remove - virtual HRESULT SetSigReturnType (); //@FUTURE: Remove - virtual HRESULT SetSigCallingConvention (); //@FUTURE: Remove - virtual HRESULT DeleteSig (); //@FUTURE: Remove - - virtual HRESULT SetEntryPoint (HCEEFILE ceeFile, mdMethodDef method); - virtual HRESULT GetEntryPoint (HCEEFILE ceeFile, mdMethodDef *method); - - virtual HRESULT SetComImageFlags (HCEEFILE ceeFile, DWORD mask); - virtual HRESULT GetComImageFlags (HCEEFILE ceeFile, DWORD *mask); - - // get IMapToken interface for tracking mapped tokens - virtual HRESULT GetIMapTokenIface(HCEEFILE ceeFile, IMetaDataEmit *emitter, IUnknown **pIMapToken); - virtual HRESULT SetDirectoryEntry (HCEEFILE ceeFile, HCEESECTION section, ULONG num, ULONG size, ULONG offset = 0); - - // Write out the metadata in "emitter" to the metadata section in "ceeFile" - // Use EmitMetaDataAt() for more control - virtual HRESULT EmitMetaDataEx (HCEEFILE ceeFile, IMetaDataEmit *emitter); - - virtual HRESULT EmitLibraryNameEx (HCEEFILE ceeFile, IMetaDataEmit *emitter); - virtual HRESULT GetIMapTokenIfaceEx(HCEEFILE ceeFile, IMetaDataEmit *emitter, IUnknown **pIMapToken); - - virtual HRESULT EmitMacroDefinitions(HCEEFILE ceeFile, void *pData, DWORD cData); - virtual HRESULT CreateCeeFileFromICeeGen( - ICeeGen *pFromICeeGen, HCEEFILE *ceeFile, DWORD createFlags = ICEE_CREATE_FILE_PURE_IL); // call this to instantiate a file handle - - virtual HRESULT SetManifestEntry(HCEEFILE ceeFile, ULONG size, ULONG offset); - - virtual HRESULT SetEnCRVABase(HCEEFILE ceeFile, ULONG dataBase, ULONG rdataBase); - virtual HRESULT GenerateCeeMemoryImage (HCEEFILE ceeFile, void **ppImage); - - virtual HRESULT ComputeSectionOffset(HCEESECTION section, _In_ char *ptr, - unsigned *offset); - - virtual HRESULT ComputeOffset(HCEEFILE file, _In_ char *ptr, - HCEESECTION *pSection, unsigned *offset); - - virtual HRESULT GetCorHeader(HCEEFILE ceeFile, - IMAGE_COR20_HEADER **header); - - // Layout the sections and assign their starting addresses - virtual HRESULT LinkCeeFile (HCEEFILE ceeFile); - - // Apply relocations to any pointer data. Also generate PE base relocs - virtual HRESULT FixupCeeFile (HCEEFILE ceeFile); - - // Base RVA assinged to the section. To be called only after LinkCeeFile() - virtual HRESULT GetSectionRVA (HCEESECTION section, ULONG *rva); - - _Return_type_success_(return == S_OK) - virtual HRESULT ComputeSectionPointer(HCEESECTION section, ULONG offset, - _Out_ char **ptr); - - virtual HRESULT SetObjSwitch (HCEEFILE ceeFile, BOOL objSwitch); - virtual HRESULT GetObjSwitch (HCEEFILE ceeFile, BOOL *objSwitch); - virtual HRESULT SetVTableEntry(HCEEFILE ceeFile, ULONG size, ULONG offset); - // See the end of interface for another overload of AetVTableEntry - - virtual HRESULT SetStrongNameEntry(HCEEFILE ceeFile, ULONG size, ULONG offset); - - // Emit the metadata from "emitter". - // If 'section != 0, it will put the data in 'buffer'. This - // buffer is assumed to be in 'section' at 'offset' and of size 'buffLen' - // (should use GetSaveSize to insure that buffer is big enough - virtual HRESULT EmitMetaDataAt (HCEEFILE ceeFile, IMetaDataEmit *emitter, - HCEESECTION section, DWORD offset, - BYTE* buffer, unsigned buffLen); - - virtual HRESULT GetFileTimeStamp (HCEEFILE ceeFile, DWORD *pTimeStamp); - - // Add a notification handler. If it implements an interface that - // the ICeeFileGen understands, S_OK is returned. Otherwise, - // E_NOINTERFACE. - virtual HRESULT AddNotificationHandler(HCEEFILE ceeFile, - IUnknown *pHandler); - - virtual HRESULT SetFileAlignment(HCEEFILE ceeFile, ULONG fileAlignment); - - virtual HRESULT ClearComImageFlags (HCEEFILE ceeFile, DWORD mask); - - // call this to instantiate a PE+ (64-bit PE file) - virtual HRESULT CreateCeeFileEx(HCEEFILE *ceeFile, ULONG createFlags); - virtual HRESULT SetImageBase64(HCEEFILE ceeFile, ULONGLONG imageBase); - - virtual HRESULT GetHeaderInfo (HCEEFILE ceeFile, PIMAGE_NT_HEADERS *ppNtHeaders, - PIMAGE_SECTION_HEADER *ppSections, - ULONG *pNumSections); - - // Seed file is a base file which is copied over into the output file - // Note that there are restrictions on the seed file (the sections - // cannot be relocated), and that the copy is not complete as the new - // headers overwrite the seed file headers. - virtual HRESULT CreateCeeFileEx2(HCEEFILE *ceeFile, ULONG createFlags, - LPCWSTR seedFileName = NULL); - - virtual HRESULT SetVTableEntry64(HCEEFILE ceeFile, ULONG size, void* ptr); -}; - -#endif diff --git a/src/inc/il_kywd.h b/src/inc/il_kywd.h deleted file mode 100644 index e16d7c7b9..000000000 --- a/src/inc/il_kywd.h +++ /dev/null @@ -1,303 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -// -// -// COM+ IL keywords, symbols and values -// -// This is the master table used in ILASM (asmparse.y) -// and ILDASM (dis.cpp) -// symbols and values are defined in asmparse.y -// and not used in dis.cpp -// - -#ifndef __IL_KYWD_H_ -#define __IL_KYWD_H_ - - KYWD( "void", VOID_, NO_VALUE ) - KYWD( "bool", BOOL_, NO_VALUE ) - KYWD( "char", CHAR_, NO_VALUE ) - KYWD( "wchar", CHAR_, NO_VALUE ) - KYWD( "int", INT_, NO_VALUE ) - KYWD( "int8", INT8_, NO_VALUE ) - KYWD( "int16", INT16_, NO_VALUE ) - KYWD( "int32", INT32_, NO_VALUE ) - KYWD( "int64", INT64_, NO_VALUE ) - KYWD( "uint", UINT_, NO_VALUE ) - KYWD( "uint8", UINT8_, NO_VALUE ) - KYWD( "uint16", UINT16_, NO_VALUE ) - KYWD( "uint32", UINT32_, NO_VALUE ) - KYWD( "uint64", UINT64_, NO_VALUE ) - KYWD( "float", FLOAT_, NO_VALUE ) - KYWD( "float32", FLOAT32_, NO_VALUE ) - KYWD( "float64", FLOAT64_, NO_VALUE ) - KYWD( "refany", TYPEDREF_, NO_VALUE ) - KYWD( "typedref", TYPEDREF_, NO_VALUE ) - KYWD( "object", OBJECT_, NO_VALUE ) - KYWD( "string", STRING_, NO_VALUE ) - KYWD( "native", NATIVE_, NO_VALUE ) - KYWD( "unsigned", UNSIGNED_, NO_VALUE ) - KYWD( "value", VALUE_, NO_VALUE ) - KYWD( "valuetype", VALUETYPE_, NO_VALUE ) - KYWD( "class", CLASS_, NO_VALUE ) - KYWD( "vararg", VARARG_, NO_VALUE ) - KYWD( "default", DEFAULT_, NO_VALUE ) - KYWD( "stdcall", STDCALL_, NO_VALUE ) - KYWD( "thiscall", THISCALL_, NO_VALUE ) - KYWD( "fastcall", FASTCALL_, NO_VALUE ) - KYWD( "unmanaged", UNMANAGED_, NO_VALUE ) - KYWD( "beforefieldinit",BEFOREFIELDINIT_, NO_VALUE ) - KYWD( "instance", INSTANCE_, NO_VALUE ) - KYWD( "filter", FILTER_, NO_VALUE ) - KYWD( "catch", CATCH_, NO_VALUE ) - KYWD( "static", STATIC_ , NO_VALUE ) - KYWD( "public", PUBLIC_, NO_VALUE ) - KYWD( "private", PRIVATE_, NO_VALUE ) - KYWD( "forwarder", FORWARDER_, NO_VALUE ) - KYWD( "synchronized", SYNCHRONIZED_, NO_VALUE ) - KYWD( "interface", INTERFACE_, NO_VALUE ) - KYWD( "extends", EXTENDS_, NO_VALUE ) - KYWD( "implements", IMPLEMENTS_, NO_VALUE ) - KYWD( "handler", HANDLER_, NO_VALUE ) - KYWD( "finally", FINALLY_, NO_VALUE ) - KYWD( "fault", FAULT_, NO_VALUE ) - KYWD( "to", TO_, NO_VALUE ) - KYWD( "abstract", ABSTRACT_, NO_VALUE ) - KYWD( "auto", AUTO_, NO_VALUE ) - KYWD( "sequential", SEQUENTIAL_, NO_VALUE ) - KYWD( "explicit", EXPLICIT_, NO_VALUE ) - KYWD( "ansi", ANSI_, NO_VALUE ) - KYWD( "unicode", UNICODE_, NO_VALUE ) - KYWD( "autochar", AUTOCHAR_, NO_VALUE ) - KYWD( "import", IMPORT_, NO_VALUE ) - KYWD( "enum", ENUM_, NO_VALUE ) - KYWD( "virtual", VIRTUAL_, NO_VALUE ) - KYWD( "strict", STRICT_, NO_VALUE ) - KYWD( "il", CIL_, NO_VALUE ) - KYWD( "cil", CIL_, NO_VALUE ) - KYWD( "optil", OPTIL_, NO_VALUE ) - KYWD( "managed", MANAGED_, NO_VALUE ) - KYWD( "preservesig", PRESERVESIG_, NO_VALUE ) - KYWD( "runtime", RUNTIME_, NO_VALUE ) - KYWD( "method", METHOD_, NO_VALUE ) - KYWD( "field", FIELD_, NO_VALUE ) - KYWD( "property", PROPERTY_, NO_VALUE ) - KYWD( "bytearray", BYTEARRAY_, NO_VALUE ) - KYWD( "final", FINAL_, NO_VALUE ) - KYWD( "sealed", SEALED_, NO_VALUE ) - KYWD( "specialname", SPECIALNAME_, NO_VALUE ) - KYWD( "family", FAMILY_, NO_VALUE ) - KYWD( "assembly", ASSEMBLY_, NO_VALUE ) - KYWD( "famandassem", FAMANDASSEM_, NO_VALUE ) - KYWD( "famorassem", FAMORASSEM_, NO_VALUE ) - KYWD( "privatescope", PRIVATESCOPE_, NO_VALUE ) - KYWD( "nested", NESTED_, NO_VALUE ) - KYWD( "hidebysig", HIDEBYSIG_, NO_VALUE ) - KYWD( "newslot", NEWSLOT_, NO_VALUE ) - KYWD( "aggressiveinlining",AGGRESSIVEINLINING_,NO_VALUE ) - KYWD( "rtspecialname", RTSPECIALNAME_, NO_VALUE ) - KYWD( "pinvokeimpl", PINVOKEIMPL_, NO_VALUE ) - KYWD( "unmanagedexp", UNMANAGEDEXP_, NO_VALUE ) - KYWD( "reqsecobj", REQSECOBJ_, NO_VALUE ) - KYWD( ".ctor", _CTOR, NO_VALUE ) - KYWD( ".cctor", _CCTOR, NO_VALUE ) - KYWD( "initonly", INITONLY_, NO_VALUE ) - KYWD( "literal", LITERAL_, NO_VALUE ) - KYWD( "notserialized", NOTSERIALIZED_, NO_VALUE ) - KYWD( "forwardref", FORWARDREF_, NO_VALUE ) - KYWD( "internalcall", INTERNALCALL_, NO_VALUE ) - KYWD( "noinlining", NOINLINING_, NO_VALUE ) - KYWD( "nooptimization", NOOPTIMIZATION_, NO_VALUE ) - KYWD( "nomangle", NOMANGLE_, NO_VALUE ) - KYWD( "lasterr", LASTERR_, NO_VALUE ) - KYWD( "winapi", WINAPI_, NO_VALUE ) - KYWD( "cdecl", CDECL_, NO_VALUE ) - KYWD( "as", AS_, NO_VALUE ) - KYWD( "pinned", PINNED_, NO_VALUE ) - KYWD( "modreq", MODREQ_, NO_VALUE ) - KYWD( "modopt", MODOPT_, NO_VALUE ) - KYWD( "serializable", SERIALIZABLE_, NO_VALUE ) - KYWD( "at", AT_, NO_VALUE ) - KYWD( "tls", TLS_, NO_VALUE ) - KYWD( "true", TRUE_, NO_VALUE ) - KYWD( "false", FALSE_, NO_VALUE ) - KYWD( "on", ON_, NO_VALUE ) - KYWD( "off", OFF_, NO_VALUE ) - KYWD( "bestfit", BESTFIT_, NO_VALUE ) - KYWD( "charmaperror", CHARMAPERROR_, NO_VALUE ) - - /* assembler directives */ - KYWD( ".class", _CLASS, NO_VALUE ) - KYWD( ".this", _THIS, NO_VALUE ) - KYWD( ".base", _BASE, NO_VALUE ) - KYWD( ".nester", _NESTER, NO_VALUE ) - KYWD( ".namespace", _NAMESPACE, NO_VALUE ) - KYWD( ".method", _METHOD, NO_VALUE ) - KYWD( ".field", _FIELD, NO_VALUE ) - KYWD( ".emitbyte", _EMITBYTE, NO_VALUE ) - KYWD( ".try", _TRY, NO_VALUE ) - KYWD( ".maxstack", _MAXSTACK, NO_VALUE ) - KYWD( ".locals", _LOCALS, NO_VALUE ) - KYWD( ".entrypoint", _ENTRYPOINT, NO_VALUE ) - KYWD( ".zeroinit", _ZEROINIT, NO_VALUE ) - KYWD( ".data", _DATA, NO_VALUE ) - - KYWD( ".event", _EVENT, NO_VALUE ) - KYWD( ".addon", _ADDON, NO_VALUE ) - KYWD( ".removeon", _REMOVEON, NO_VALUE ) - KYWD( ".fire", _FIRE, NO_VALUE ) - KYWD( ".other", _OTHER, NO_VALUE ) - - KYWD( ".property", _PROPERTY, NO_VALUE ) - KYWD( ".set", _SET, NO_VALUE ) - KYWD( ".get", _GET, NO_VALUE ) - - KYWD( ".permission", _PERMISSION, NO_VALUE ) - KYWD( ".permissionset", _PERMISSIONSET, NO_VALUE ) - - /* security actions */ - KYWD( "request", REQUEST_, NO_VALUE ) - KYWD( "demand", DEMAND_, NO_VALUE ) - KYWD( "assert", ASSERT_, NO_VALUE ) - KYWD( "deny", DENY_, NO_VALUE ) - KYWD( "permitonly", PERMITONLY_, NO_VALUE ) - KYWD( "linkcheck", LINKCHECK_, NO_VALUE ) - KYWD( "inheritcheck", INHERITCHECK_, NO_VALUE ) - KYWD( "reqmin", REQMIN_, NO_VALUE ) - KYWD( "reqopt", REQOPT_, NO_VALUE ) - KYWD( "reqrefuse", REQREFUSE_, NO_VALUE ) - KYWD( "prejitgrant", PREJITGRANT_, NO_VALUE ) - KYWD( "prejitdeny", PREJITDENY_, NO_VALUE ) - KYWD( "noncasdemand", NONCASDEMAND_, NO_VALUE ) - KYWD( "noncaslinkdemand",NONCASLINKDEMAND_, NO_VALUE ) - KYWD( "noncasinheritance",NONCASINHERITANCE_,NO_VALUE ) - - /* extern debug data specifier */ - KYWD( ".line", _LINE, NO_VALUE ) - KYWD( ".language", _LANGUAGE, NO_VALUE ) - KYWD( "#line", P_LINE, NO_VALUE ) - /* custom value specifier */ - KYWD( ".custom", _CUSTOM, NO_VALUE ) - /* IL method attribute */ - KYWD( "init", INIT_, NO_VALUE ) - /* Class layout directives */ - KYWD( ".size", _SIZE, NO_VALUE ) - KYWD( ".pack", _PACK, NO_VALUE ) - /* Manifest-related keywords */ - KYWD( ".file", _FILE, NO_VALUE ) - KYWD( "nometadata", NOMETADATA_, NO_VALUE ) - KYWD( ".hash", _HASH, NO_VALUE ) - KYWD( ".assembly", _ASSEMBLY, NO_VALUE ) - KYWD( "retargetable", RETARGETABLE_, NO_VALUE ) - KYWD( "windowsruntime", WINDOWSRUNTIME_, NO_VALUE ) - KYWD( "noplatform", NOPLATFORM_, NO_VALUE ) - KYWD( "legacy", LEGACY_, NO_VALUE ) - KYWD( "library", LIBRARY_, NO_VALUE ) - KYWD( "x86", X86_, NO_VALUE ) - KYWD( "ia64", IA64_, NO_VALUE ) - KYWD( "amd64", AMD64_, NO_VALUE ) - KYWD( "arm", ARM_, NO_VALUE ) - KYWD( ".publickey", _PUBLICKEY, NO_VALUE ) - KYWD( ".publickeytoken",_PUBLICKEYTOKEN, NO_VALUE ) - KYWD( "algorithm", ALGORITHM_, NO_VALUE ) - KYWD( ".ver", _VER, NO_VALUE ) - KYWD( ".locale", _LOCALE, NO_VALUE ) - KYWD( "extern", EXTERN_, NO_VALUE ) - KYWD( ".export", _EXPORT, NO_VALUE ) - KYWD( ".manifestres", _MRESOURCE, NO_VALUE ) - KYWD( ".mresource", _MRESOURCE, NO_VALUE ) - KYWD( ".module", _MODULE, NO_VALUE ) - /* Field marshaling keywords */ - KYWD( "marshal", MARSHAL_, NO_VALUE ) - KYWD( "custom", CUSTOM_, NO_VALUE ) - KYWD( "sysstring", SYSSTRING_, NO_VALUE ) - KYWD( "fixed", FIXED_, NO_VALUE ) - KYWD( "variant", VARIANT_, NO_VALUE ) - KYWD( "currency", CURRENCY_, NO_VALUE ) - KYWD( "syschar", SYSCHAR_, NO_VALUE ) - KYWD( "decimal", DECIMAL_, NO_VALUE ) - KYWD( "date", DATE_, NO_VALUE ) - KYWD( "bstr", BSTR_, NO_VALUE ) - KYWD( "tbstr", TBSTR_, NO_VALUE ) - KYWD( "lpstr", LPSTR_, NO_VALUE ) - KYWD( "lpwstr", LPWSTR_, NO_VALUE ) - KYWD( "lptstr", LPTSTR_, NO_VALUE ) - KYWD( "objectref", OBJECTREF_, NO_VALUE ) - KYWD( "iunknown", IUNKNOWN_, NO_VALUE ) - KYWD( "idispatch", IDISPATCH_, NO_VALUE ) - KYWD( "iidparam", IIDPARAM_, NO_VALUE ) - KYWD( "struct", STRUCT_, NO_VALUE ) - KYWD( "safearray", SAFEARRAY_, NO_VALUE ) - KYWD( "byvalstr", BYVALSTR_, NO_VALUE ) - KYWD( "lpvoid", LPVOID_, NO_VALUE ) - KYWD( "any", ANY_, NO_VALUE ) - KYWD( "array", ARRAY_, NO_VALUE ) - KYWD( "lpstruct", LPSTRUCT_, NO_VALUE ) - /* VTable fixup keywords */ - KYWD( ".vtfixup", _VTFIXUP, NO_VALUE ) - KYWD( "fromunmanaged", FROMUNMANAGED_, NO_VALUE ) - KYWD( "retainappdomain",RETAINAPPDOMAIN_, NO_VALUE ) - KYWD( "callmostderived",CALLMOSTDERIVED_, NO_VALUE ) - KYWD( ".vtentry", _VTENTRY, NO_VALUE ) - /* Parameter attributes */ - KYWD( "in", IN_, NO_VALUE ) - KYWD( "out", OUT_, NO_VALUE ) - KYWD( "opt", OPT_, NO_VALUE ) - KYWD( ".param", PARAM_, NO_VALUE ) - /* Method implementations */ - KYWD( ".override", _OVERRIDE, NO_VALUE ) - KYWD( "with", WITH_, NO_VALUE ) - /* VariantType keywords */ - KYWD( "null", NULL_, NO_VALUE ) - KYWD( "error", ERROR_, NO_VALUE ) - KYWD( "hresult", HRESULT_, NO_VALUE ) - KYWD( "carray", CARRAY_, NO_VALUE ) - KYWD( "userdefined", USERDEFINED_, NO_VALUE ) - KYWD( "record", RECORD_, NO_VALUE ) - KYWD( "filetime", FILETIME_, NO_VALUE ) - KYWD( "blob", BLOB_, NO_VALUE ) - KYWD( "stream", STREAM_, NO_VALUE ) - KYWD( "storage", STORAGE_, NO_VALUE ) - KYWD( "streamed_object",STREAMED_OBJECT_, NO_VALUE ) - KYWD( "stored_object", STORED_OBJECT_, NO_VALUE ) - KYWD( "blob_object", BLOB_OBJECT_, NO_VALUE ) - KYWD( "cf", CF_, NO_VALUE ) - KYWD( "clsid", CLSID_, NO_VALUE ) - KYWD( "vector", VECTOR_, NO_VALUE ) - /* Null reference keyword for InitOpt */ - KYWD( "nullref", NULLREF_, NO_VALUE ) - KYWD( "type", TYPE_, NO_VALUE ) - KYWD( ".interfaceimpl", _INTERFACEIMPL, NO_VALUE ) - /* Header flags keywords */ - KYWD( ".subsystem", _SUBSYSTEM, NO_VALUE ) - KYWD( ".corflags", _CORFLAGS, NO_VALUE ) - KYWD( "alignment", ALIGNMENT_, NO_VALUE ) - KYWD( ".imagebase", _IMAGEBASE, NO_VALUE ) - KYWD( ".stackreserve", _STACKRESERVE, NO_VALUE ) - /* Explicit binary flag specification keywords */ - KYWD( "flags", FLAGS_, NO_VALUE ) - KYWD( "callconv", CALLCONV_, NO_VALUE ) - KYWD( "mdtoken", MDTOKEN_, NO_VALUE ) - - /* Some ILASM-specific syntactic sugar */ - KYWD( ".typedef", _TYPEDEF, NO_VALUE ) - KYWD( ".template", _TEMPLATE, NO_VALUE ) - KYWD( ".typelist", _TYPELIST, NO_VALUE ) - KYWD( ".mscorlib", _MSCORLIB, NO_VALUE ) - - /* Compilation control keywords */ - KYWD( "#define", P_DEFINE, NO_VALUE ) - KYWD( "#undef", P_UNDEF, NO_VALUE ) - KYWD( "#ifdef", P_IFDEF, NO_VALUE ) - KYWD( "#ifndef", P_IFNDEF, NO_VALUE ) - KYWD( "#else", P_ELSE, NO_VALUE ) - KYWD( "#endif", P_ENDIF, NO_VALUE ) - KYWD( "#include", P_INCLUDE, NO_VALUE ) - - - /* Deprecated keywords */ - KYWD( ".vtable", _VTABLE, NO_VALUE ) - - - KYWD( "^THE_END^", 0, NO_VALUE ) -#endif diff --git a/src/inc/ildbsymlib.h b/src/inc/ildbsymlib.h deleted file mode 100644 index 6c2d4d0ed..000000000 --- a/src/inc/ildbsymlib.h +++ /dev/null @@ -1,21 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -//***************************************************************************** -// IldbSymLib.h -// -// ILDB debug symbols functions implemented in IldbSymLib.lib -// Provides support for ILDB-format debug symbols using the same interfaces -// that diasymreader.dll exposes for PDB symbols. -// -//***************************************************************************** -#ifndef __IldbSymLib_h__ -#define __IldbSymLib_h__ - -// Get the IClassFactory for one of the ILDB symbols CLSIDs -STDAPI IldbSymbolsGetClassObject(REFCLSID rclsid, REFIID riid, void** ppvObject); - -// Create an inststance of an ILDB ISymUnmanagedReader, ISymUnmanagedWriter or ISymUnmanagedBinder -STDAPI IldbSymbolsCreateInstance(REFCLSID rclsid, REFIID riid, void** ppvIUnknown); - -#endif // __IldbSymLib_h__ diff --git a/src/inc/ilformatter.h b/src/inc/ilformatter.h deleted file mode 100644 index 7593aa65b..000000000 --- a/src/inc/ilformatter.h +++ /dev/null @@ -1,76 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - - -/***************************************************************************/ -/* ILFormatter.h */ -/***************************************************************************/ - -#ifndef ILFormatter_h -#define ILFormatter_h - -#include "opinfo.h" -#include "outstring.h" - -struct IMetaDataImport; - -#define INVALID_IL_OFFSET 0x80000000 - -/***************************************************************************/ -class ILFormatter { -public: - ILFormatter() : start(0), targetStart(0), stackStart(0) {} - - ILFormatter(IMetaDataImport* aMeta, const BYTE* aStart, - const BYTE* aLimit, unsigned maxStack, const COR_ILMETHOD_SECT_EH* eh) - : targetStart(0), stackStart(0) { - init(aMeta, aStart, aLimit, maxStack, eh); - } - ~ILFormatter() { delete [] stackStart; delete [] targetStart; } - - void init(IMetaDataImport* aMeta, const BYTE* aStart, - const BYTE* aLimit, unsigned maxStack, const COR_ILMETHOD_SECT_EH* eh); - const BYTE* formatStatement(const BYTE* stmtIL, OutString* out); - const BYTE* formatInstr(const BYTE* instrIL, OutString* out); -private: - - void formatInstrArgs(OpInfo op, OpArgsVal arg, OutString* out, size_t curIP=INVALID_IL_OFFSET); - void formatArgs(unsigned numArgs, OutString* out); - void spillStack(OutString* out); - void setStackAsTarget(size_t ilOffset); - void setTarget(size_t ilOffset, size_t depth); - -private: - const BYTE* start; // keeps us sane - const BYTE* limit; - IMetaDataImport* meta; // used to parse tokens etc - - struct StackEntry { - OutString val; - int prec; - }; - - struct Target { - size_t ilOffset; - size_t stackDepth; - }; - - Target* targetStart; - Target* targetEnd; - Target* targetCur; - - size_t stackDepth(); - void pushAndClear(OutString* val, int prec); - OutString* pop(int prec = 0); - OutString* top(); - void popN(size_t num); - - StackEntry* stackStart; - StackEntry* stackEnd; - StackEntry* stackCur; // points at the next slot to fill - -}; - -#endif - diff --git a/src/inc/internalunknownimpl.h b/src/inc/internalunknownimpl.h deleted file mode 100644 index 9b561fad6..000000000 --- a/src/inc/internalunknownimpl.h +++ /dev/null @@ -1,494 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -//***************************************************************************** -// -// InternalUnknownImpl.h -// -// Defines utility class ComUtil::IUnknownCommon, which provides default -// implementations for IUnknown's AddRef, Release, and QueryInterface methods. -// -// Use: a class that implements one or more interfaces should derive from -// ComUtil::IUnknownCommon with a template parameter list consisting of the -// list of implemented interfaces. -// -// Example: -// class MyInterfacesImpl : -// public IUnknownCommon -// { ... }; -// -// IUnknownCommon will provide base AddRef and Release semantics, and will -// also provide an implementation of QueryInterface that will evaluate the -// arguments against the set of supported interfaces and return the -// appropriate result. -// -// If you need to specify multiple interfaces where one is a base interface -// of another and implementing all of them would result in a compiler error, -// you can use the NoDerive wrapper to tell IUnknownCommon to not derive from -// this interface but just use it for QueryInterface calls. -// -// Example: -// interface A -// { ... }; -// interface B : public A -// { ... }; -// class MyInterfacesImpl : public IUnknownCommon > -// { ... }; -// -// If a base type also implements IUnknownCommon, then you must override -// QueryInterface with a method that delegates to your type's -// IUnknownCommon::QueryInterface and then to BaseType::QueryInterface. -// - - -// -//***************************************************************************** - -#ifndef __InternalUnknownImpl_h__ -#define __InternalUnknownImpl_h__ - -#include -#include "winwrap.h" -#include "contract.h" -#include "ex.h" -#include "volatile.h" -#include "mpl/type_list" -#include "debugmacros.h" - -#define COMUTIL_IIDOF(x) __uuidof(x) - -namespace ComUtil -{ - //--------------------------------------------------------------------------------------------- - template - struct TypeWrapper - { typedef T wrapped_type; }; - - namespace detail - { - typedef char (&_Yes)[1]; - typedef char (&_No)[2]; - - static inline _No _IsTypeWrapper(...); - - template - static _Yes _IsTypeWrapper(T *, typename T::wrapped_type * = nullptr); - } - - //--------------------------------------------------------------------------------------------- - template - struct IsTypeWrapper - { - static const bool value = std::integral_constant< - bool, - sizeof(detail::_IsTypeWrapper((T*)0)) == sizeof(detail::_Yes)>::value; - }; - - //----------------------------------------------------------------------------------------- - // Utility to remove marker type wrappers. - template ::value> - struct UnwrapOne - { typedef T type; }; - - template - struct UnwrapOne - { typedef typename T::wrapped_type type; }; - - template ::value> - struct Unwrap - { typedef T type; }; - - template - struct Unwrap - { typedef typename Unwrap< typename UnwrapOne::type >::type type; }; - - //--------------------------------------------------------------------------------------------- - // Used as a flag to indicate that an interface should not be used as a base class. - // See DeriveTypeList below. - template - struct NoDerive : public TypeWrapper - { }; - - //--------------------------------------------------------------------------------------------- - // Used to indicate that a base class contributes implemented interfaces. - template - struct ItfBase : public TypeWrapper - { }; - - namespace detail - { - using namespace mpl; - - //----------------------------------------------------------------------------------------- - // Exposes a type that derives every type in the given type list, except for those marked - // with NoDerive. - template - struct DeriveTypeList; - - // Common case. Derive from list head and recursively on list tail. - template - struct DeriveTypeList< type_list > : - public Unwrap::type, - public DeriveTypeList - {}; - - // Non-derived case. Skip this type, continue with tail. - template - struct DeriveTypeList< type_list< NoDerive< HeadT >, TailT> > : - public DeriveTypeList - {}; - - // Termination case. - template <> - struct DeriveTypeList - {}; - - //----------------------------------------------------------------------------------------- - template - struct GetFirstInterface; - - template - struct GetFirstInterface< type_list > - { typedef HeadT type; }; - - template - struct GetFirstInterface< type_list< ItfBase< HeadT >, TailT> > - { typedef typename GetFirstInterface::type type; }; - - template <> - struct GetFirstInterface< null_type > - { typedef IUnknown type; }; - - //----------------------------------------------------------------------------------------- - // Uses type lists to implement the helper. Type lists are implemented - // through templates, and can be best understood if compared to Scheme - // cdr and cons: each list type has a head type and a tail type. The - // head type is typically a concrete type, and the tail type is - // typically another list containing the remainder of the list. Type - // lists are terminated with a head type of null_type. - // - // QueryInterface is implemented using QIHelper, which uses type_lists - // and partial specialization to recursively walk the type list and - // look to see if the requested interface is supported. If not, then - // the termination case is reached and a final test against IUknown - // is made before returning a failure. - //----------------------------------------------------------------------------------------- - template - struct QIHelper; - - template - struct QIHelper< type_list< HeadT, TailT > > - { - template - static inline HRESULT QI( - REFIID riid, - void **ppvObject, - IUnknownCommonT *pThis) - { - STATIC_CONTRACT_NOTHROW; - STATIC_CONTRACT_GC_NOTRIGGER; - STATIC_CONTRACT_ENTRY_POINT; - - HRESULT hr = S_OK; - - typedef typename Unwrap::type ItfT; - - // If the interface type matches that of the head of the list, - // then cast to it and return success. - if (riid == COMUTIL_IIDOF(ItfT)) - { - ItfT *pItf = static_cast(pThis); - pItf->AddRef(); - *ppvObject = pItf; - } - // If not, recurse on the tail of the list. - else - hr = QIHelper::QI(riid, ppvObject, pThis); - - return hr; - } - }; - - template - struct QIHelper< type_list< ItfBase< HeadT >, TailT> > - { - template - static inline HRESULT QI( - REFIID riid, - void **ppvObject, - IUnknownCommonT *pThis) - { - STATIC_CONTRACT_NOTHROW; - STATIC_CONTRACT_GC_NOTRIGGER; - STATIC_CONTRACT_ENTRY_POINT; - - HRESULT hr = S_OK; - - hr = pThis->HeadT::QueryInterface(riid, ppvObject); - - if (hr == E_NOINTERFACE) - hr = QIHelper::QI(riid, ppvObject, pThis); - - return hr; - } - }; - - // This is the termination case. In this case, we check if the - // requested interface is IUnknown (which is common to all interfaces). - template <> - struct QIHelper< null_type > - { - template - static inline HRESULT QI( - REFIID riid, - void **ppvObject, - IUnknownCommonT *pThis) - { - STATIC_CONTRACT_NOTHROW; - STATIC_CONTRACT_GC_NOTRIGGER; - STATIC_CONTRACT_ENTRY_POINT; - - HRESULT hr = S_OK; - - // If the request was for IUnknown, cast and return success. - if (riid == COMUTIL_IIDOF(IUnknown)) - { - typedef typename detail::GetFirstInterface< - typename IUnknownCommonT::InterfaceListT>::type IUnknownCastHelper; - - // Cast to first interface type to then cast to IUnknown unambiguously. - IUnknown *pItf = static_cast( - static_cast(pThis)); - pItf->AddRef(); - *ppvObject = pItf; - } - // Otherwise none of the interfaces match the requested IID, - // so return E_NOINTERFACE. - else - { - *ppvObject = nullptr; - hr = E_NOINTERFACE; - } - - return hr; - } - }; - - //----------------------------------------------------------------------------------------- - // Is used as a virtual base to ensure that there is a single reference count field. - struct IUnknownCommonRef - { - inline - IUnknownCommonRef() - : m_cRef(0) - {} - - Volatile m_cRef; - }; - } - - //--------------------------------------------------------------------------------------------- - // IUnknownCommon - // - // T0-T9 - the list of interfaces to implement. - template - < - typename T0 = mpl::null_type, - typename T1 = mpl::null_type, - typename T2 = mpl::null_type, - typename T3 = mpl::null_type, - typename T4 = mpl::null_type, - typename T5 = mpl::null_type, - typename T6 = mpl::null_type, - typename T7 = mpl::null_type, - typename T8 = mpl::null_type, - typename T9 = mpl::null_type - > - class IUnknownCommon : - virtual protected detail::IUnknownCommonRef, - public detail::DeriveTypeList< typename mpl::make_type_list< - T0, T1, T2, T3, T4, T5, T6, T7, T8, T9>::type > - { - public: - typedef typename mpl::make_type_list< - T0, T1, T2, T3, T4, T5, T6, T7, T8, T9>::type InterfaceListT; - - // Add a virtual destructor to force derived types to also have virtual destructors. - virtual ~IUnknownCommon() - { - WRAPPER_NO_CONTRACT; - clr::dbg::PoisonMem(*this); - } - - // Standard AddRef implementation - STDMETHOD_(ULONG, AddRef()) - { - STATIC_CONTRACT_LIMITED_METHOD; - STATIC_CONTRACT_ENTRY_POINT; - - return InterlockedIncrement(&m_cRef); - } - - // Standard Release implementation. - STDMETHOD_(ULONG, Release()) - { - STATIC_CONTRACT_LIMITED_METHOD; - STATIC_CONTRACT_ENTRY_POINT; - - _ASSERTE(m_cRef > 0); - - ULONG cRef = InterlockedDecrement(&m_cRef); - - if (cRef == 0) - delete this; // Relies on virtual dtor to work properly. - - return cRef; - } - - // Uses detail::QIHelper for implementation. - STDMETHOD(QueryInterface(REFIID riid, void **ppvObject)) - { - STATIC_CONTRACT_LIMITED_METHOD; - STATIC_CONTRACT_ENTRY_POINT; - - if (ppvObject == nullptr) - return E_INVALIDARG; - - *ppvObject = nullptr; - - return detail::QIHelper::QI( - riid, ppvObject, this); - } - - template - HRESULT QueryInterface(ItfT **ppItf) - { - return QueryInterface(__uuidof(ItfT), reinterpret_cast(ppItf)); - } - - protected: - // May only be constructed as a base type. - inline IUnknownCommon() : - IUnknownCommonRef() - { WRAPPER_NO_CONTRACT; } - }; - - //--------------------------------------------------------------------------------------------- - // IUnknownCommonExternal - // - // T0-T9 - the list of interfaces to implement. - template - < - typename T0 = mpl::null_type, - typename T1 = mpl::null_type, - typename T2 = mpl::null_type, - typename T3 = mpl::null_type, - typename T4 = mpl::null_type, - typename T5 = mpl::null_type, - typename T6 = mpl::null_type, - typename T7 = mpl::null_type, - typename T8 = mpl::null_type, - typename T9 = mpl::null_type - > - class IUnknownCommonExternal : - virtual protected detail::IUnknownCommonRef, - public detail::DeriveTypeList< typename mpl::make_type_list< - T0, T1, T2, T3, T4, T5, T6, T7, T8, T9>::type > - { - public: - typedef typename mpl::make_type_list< - T0, T1, T2, T3, T4, T5, T6, T7, T8, T9>::type InterfaceListT; - - // Standard AddRef implementation - STDMETHOD_(ULONG, AddRef()) - { - STATIC_CONTRACT_LIMITED_METHOD; - STATIC_CONTRACT_ENTRY_POINT; - - return InterlockedIncrement(&m_cRef); - } - - // Standard Release implementation. - // Should be called outside VM only - STDMETHOD_(ULONG, Release()) - { - STATIC_CONTRACT_LIMITED_METHOD; - STATIC_CONTRACT_ENTRY_POINT; - - _ASSERTE(m_cRef > 0); - - ULONG cRef = InterlockedDecrement(&m_cRef); - - if (cRef == 0) - { - Cleanup(); // Cleans up the object - delete this; - } - - return cRef; - } - - // Internal release - // Should be called inside VM only - STDMETHOD_(ULONG, InternalRelease()) - { - LIMITED_METHOD_CONTRACT; - - _ASSERTE(m_cRef > 0); - - ULONG cRef = InterlockedDecrement(&m_cRef); - - if (cRef == 0) - { - InternalCleanup(); // Cleans up the object, internal version - delete this; - } - - return cRef; - } - - // Uses detail::QIHelper for implementation. - STDMETHOD(QueryInterface(REFIID riid, void **ppvObject)) - { - STATIC_CONTRACT_LIMITED_METHOD; - STATIC_CONTRACT_ENTRY_POINT; - - if (ppvObject == nullptr) - return E_INVALIDARG; - - *ppvObject = nullptr; - - return detail::QIHelper::QI( - riid, ppvObject, this); - } - - template - HRESULT QueryInterface(ItfT **ppItf) - { - return QueryInterface(__uuidof(ItfT), reinterpret_cast(ppItf)); - } - - protected: - // May only be constructed as a base type. - inline IUnknownCommonExternal() : - IUnknownCommonRef() - { WRAPPER_NO_CONTRACT; } - - // Internal version of cleanup - virtual void InternalCleanup() = 0; - - // External version of cleanup - // Not surprisingly, this should call InternalCleanup to avoid duplicate code - // Not implemented here to avoid bringing too much into this header file - virtual void Cleanup() = 0; - }; -} - -#undef COMUTIL_IIDOF - -using ComUtil::NoDerive; -using ComUtil::ItfBase; -using ComUtil::IUnknownCommon; -using ComUtil::IUnknownCommonExternal; - -#endif // __InternalUnknownImpl_h__ diff --git a/src/inc/intrinsic.h b/src/inc/intrinsic.h deleted file mode 100644 index 50bcd52b2..000000000 --- a/src/inc/intrinsic.h +++ /dev/null @@ -1,25 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -//***************************************************************************** -// Intrinsic.h -// -// Force several very useful functions to be intrinsic, which means that the -// compiler will generate code inline for the functions instead of generating -// a call to the function. -// -//***************************************************************************** - -#ifndef __intrinsic_h__ -#define __intrinsic_h__ - -#ifdef _MSC_VER -#pragma intrinsic(memcmp) -#pragma intrinsic(memcpy) -#pragma intrinsic(memset) -#pragma intrinsic(strcmp) -#pragma intrinsic(strcpy) -#pragma intrinsic(strlen) -#endif // defined(_MSC_VER) - -#endif // __intrinsic_h__ diff --git a/src/inc/ipcfunccall.h b/src/inc/ipcfunccall.h deleted file mode 100644 index 15034e09f..000000000 --- a/src/inc/ipcfunccall.h +++ /dev/null @@ -1,117 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -//***************************************************************************** -// File: IPCFuncCall.h -// -// Define class to support a cross process function call. -// -//***************************************************************************** - - -#ifndef _IPCFUNCCALLIMPL_H_ -#define _IPCFUNCCALLIMPL_H_ - -//----------------------------------------------------------------------------- -// 1. Handler creates a IPCFuncCallHandler object and inits it with -// a callback function. -// 2. Source calls IPCFuncCallSource::DoThreadSafeCall(). This will pause the -// thread and trigger the callback on the handlers side. -// -// This mechanism is very robust. See the error return codes on -// DoThreadSafeCall() for more details. -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -// Send the call -//----------------------------------------------------------------------------- -class IPCFuncCallSource -{ -public: -//............................................................................. -// Error return codes for members. -// Our biggest error concerns are timeouts and no handlers. HRESULTS won't -// help us with these, so we'll have to use our own codes. -//............................................................................. - enum EError - { - // (Common) the function was called, and we waited for the full duration. - Ok, - - // (Common) The function MAY have been called, but we timed out before it - // finished This means either: The function was called, but took too long - // to finish or The handler died on us right after we hooked up to it and - // so the function never even got called. - Fail_Timeout_Call, - - // (Common) There was no handler for us to call - Fail_NoHandler, - - // (rare) The function was never called. We successfully connected to the handler, - // but we timed out waiting for the mutex. - Fail_Timeout_Lock, - - // (very rare) We were unable to create the mutex to serialize - Fail_CreateMutex, - - // (very rare) Catch-all General Failure. - Failed - - }; - - -// Make a call, wrapped in a mutex - static EError DoThreadSafeCall(); - - -protected: - -}; - - -//----------------------------------------------------------------------------- -// AuxThread Callback -//----------------------------------------------------------------------------- -DWORD WINAPI HandlerAuxThreadProc(LPVOID lpParameter); - - -//----------------------------------------------------------------------------- -// Callback for handler. AuxThread will call this. -//----------------------------------------------------------------------------- -typedef void (*HANDLER_CALLBACK)(); - -//----------------------------------------------------------------------------- -// Receieves the call. This should be in a different process than the source -//----------------------------------------------------------------------------- -class IPCFuncCallHandler -{ -public: - HRESULT InitFCHandler(HANDLER_CALLBACK pfnCallback, HANDLER_CALLBACK pfnCleanupCallback); - void TerminateFCHandler(); - void WaitForShutdown(); - - IPCFuncCallHandler(); - ~IPCFuncCallHandler(); - -protected: - BOOL IsShutdownComplete(); - void SafeCleanup(); - HANDLE m_hStartEnum; // event to notify start call - HANDLE m_hDoneEnum; // event to notify end call - - Volatile m_hAuxThread; // thread to listen for m_hStartEnum - - HANDLER_CALLBACK m_pfnCallback; - HANDLER_CALLBACK m_pfnCleanupCallback; - - Volatile m_fShutdownAuxThread; // flag the Aux thread to finish up gracefully - HANDLE m_hShutdownThread; // Event to signal the Aux thread to finish up gracefully - - HMODULE m_hCallbackModule; // Hold the module's ref to make sure that the - // aux thread's code doesn't get unmapped. -// Make auxthread our friend so he can access all our eventing objects - friend DWORD WINAPI HandlerAuxThreadProc(LPVOID); -}; - - -#endif // _IPCFUNCCALLIMPL_H_ diff --git a/src/inc/ipcmanagerinterface.h b/src/inc/ipcmanagerinterface.h deleted file mode 100644 index ef7137127..000000000 --- a/src/inc/ipcmanagerinterface.h +++ /dev/null @@ -1,204 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -//***************************************************************************** -// File: IPCManagerInterface.h -// -// Interface for InterProcess Communication with a COM+ process. -// -//***************************************************************************** - - -#ifndef _IPCMANAGERINTERFACE_H_ -#define _IPCMANAGERINTERFACE_H_ - -#include "../ipcman/ipcheader.h" - -struct PerfCounterIPCControlBlock; -struct AppDomainEnumerationIPCBlock; - -#include "../ipcman/ipcmanagerimpl.h" - -// These are the right that we will give to the global section and global events used -// in communicating between debugger and debugee -// -// SECTION_ALL_ACCESS is needed for the IPC block. Unfortunately, we DACL our events and -// IPC block identically. Or this particular right does not need to bleed into here. -// -#define CLR_IPC_GENERIC_RIGHT (GENERIC_READ | GENERIC_WRITE | GENERIC_EXECUTE | STANDARD_RIGHTS_ALL | SECTION_ALL_ACCESS) - -//----------------------------------------------------------------------------- -// Writer - create a COM+ IPC Block with security attributes. -//----------------------------------------------------------------------------- -class IPCWriterInterface : public IPCWriterImpl -{ -public: - - BOOL TryAllocBlock(DWORD numRetries); - BOOL TryFreeBlock(); - - //............................................................................. - // Creation / Destruction only on implementation - //............................................................................. - HRESULT Init(); - void Terminate(); - - //............................................................................. - // Marks the data in the IPC block as initialized - //............................................................................. - void Publish(); - - //............................................................................. - // Accessor for the Perf block - //............................................................................. - PerfCounterIPCControlBlock * GetPerfBlock(); - - void DestroySecurityAttributes(SECURITY_ATTRIBUTES *pSA); - -#ifndef DACCESS_COMPILE - - //............................................................................. - // Create the SxS Public IPC block. - //............................................................................. - HRESULT CreateSxSPublicBlockOnPid(DWORD PID); - - //............................................................................. - // Open the SxS Public IPC block that has alread been created. - //............................................................................. - HRESULT OpenSxSPublicBlockOnPid(DWORD PID); - - HRESULT GetSxSPublicSecurityAttributes(DWORD pid, SECURITY_ATTRIBUTES **ppSA); - -#endif - - DWORD GetBlockTableSize(); - PTR_VOID GetBlockTableStart(); - - /*********************************** LEGACY FUNCTIONS *********************************** - * - * Though newer versions of the runtime do not open the LegacyPrivate block or the LegacyPublic - * block, we need functionality in the reader to inspect the LegacyPrivate block and LegacyPublic - * block so reading data from older runtimes. - * - ****************************************************************************************/ - - //............................................................................. - // The AppDomain block resides within the LegacyPrivate IPC block. - //............................................................................. - AppDomainEnumerationIPCBlock * GetAppDomainBlock(); - - //............................................................................. - // Create the LegacyPrivate IPC block. If this fails because the IPC block has already been - // created by another module then the phInstIPCBlockOwner argument will be set to the - // HINSTANCE of the module that created the IPC block. - // Set inService to TRUE if creating from within a service on behalf of a process. - //............................................................................. - HRESULT CreateLegacyPrivateBlockTempV4OnPid(DWORD PID, BOOL inService, HINSTANCE *phInstIPCBlockOwner); - - //............................................................................. - // Open the LegacyPrivate IPC block that has alread been created. - //............................................................................. - HRESULT OpenLegacyPrivateBlockOnPid(DWORD PID); - - //............................................................................. - // ReDacl our LegacyPrivate block after it has been created. - //............................................................................. - HRESULT ReDaclLegacyPrivateBlock(PSECURITY_DESCRIPTOR pSecurityDescriptor); - - //............................................................................. - // Accessors - return info from header - - // These functions work on LegacyPrivate Block - //............................................................................. - DWORD GetBlockSize(); - PTR_VOID GetBlockStart(); - PCWSTR GetInstancePath(); -}; - -//----------------------------------------------------------------------------- -// IPCReader class connects to a COM+ IPC block and reads from it -// @FUTURE - make global & private readers -//----------------------------------------------------------------------------- -class IPCReaderInterface : public IPCReaderImpl -{ -public: - - void MakeInstanceName(const WCHAR * szProcessName, DWORD pid, DWORD runtimeId, SString & sName); - void MakeInstanceNameWhidbey(const WCHAR * szProcessName, DWORD pid, SString & sName); - - BOOL TryOpenBlock(IPCHeaderReadHelper & readHelper, DWORD blockIndex); - - //............................................................................. - // Create & Destroy - //............................................................................. - ~IPCReaderInterface(); - - HRESULT OpenLegacyPrivateBlockTempV4OnPid(DWORD pid); - HRESULT OpenLegacyPrivateBlockTempV4OnPid(DWORD pid, DWORD dwDesiredAccess); - - HRESULT OpenLegacyPrivateBlockOnPid(DWORD pid); - HRESULT OpenLegacyPrivateBlockOnPid(DWORD pid, DWORD dwDesiredAccess); - HRESULT OpenLegacyPrivateBlockOnPidReadWrite(DWORD pid); - HRESULT OpenLegacyPrivateBlockOnPidReadOnly(DWORD pid); - void CloseLegacyPrivateBlock(); - -#ifndef DACCESS_COMPILE - HRESULT OpenLegacyPublicBlockOnPid(DWORD pid); - HRESULT OpenLegacyPublicBlockOnPid(DWORD pid, DWORD dwDesiredAccess); - HRESULT OpenLegacyPublicBlockOnPidReadOnly(DWORD pid); - void CloseLegacyPublicBlock(); - - HRESULT OpenBlockTableOnPid(DWORD pid); - HRESULT OpenBlockTableOnPid(DWORD pid, DWORD dwDesiredAccess); - HRESULT OpenBlockTableOnPidReadOnly(DWORD pid); - void CloseBlockTable(); -#endif - - //............................................................................. - // Accessors - return info from header - // @FUTURE - factor this into IPCWriterInterface as well. - //............................................................................. - USHORT GetBlockVersion(); - USHORT GetLegacyPublicBlockVersion(); - HINSTANCE GetInstance(); - USHORT GetBuildYear(); - USHORT GetBuildNumber(); - PVOID GetBlockStart(); - PCWSTR GetInstancePath(); - - //........................................ - // Check the block to see if its valid - //........................................ - BOOL IsValidLegacy(BOOL fIsLegacyPublicBlock); - -#ifndef DACCESS_COMPILE - //BOOL IsValidForSxSPublic(IPCControlBlock * pBlock); -#endif - - //............................................................................. - // Get different sections of the IPC - //............................................................................. - void * GetLegacyPrivateBlock(ELegacyPrivateIPCClient eClient); - void * GetLegacyPublicBlock(ELegacyPublicIPCClient eClient); -#ifndef DACCESS_COMPILE - //void * GetSxSPublicBlock(DWORD chunkIndex, EIPCClient eClient); -#endif - - void * GetPerfBlockLegacyPrivate(); - void * GetPerfBlockLegacyPublic(); -#ifndef DACCESS_COMPILE - //PerfCounterIPCControlBlock * GetPerfBlockSxSPublic(DWORD chunkIndex); -#endif - AppDomainEnumerationIPCBlock * GetAppDomainBlock(); - - //............................................................................. - // Return true if we're connected to a memory-mapped file, else false. - //............................................................................. - bool IsLegacyPrivateBlockOpen() const; - bool IsLegacyPublicBlockOpen() const; - bool IsBlockTableOpen() const; - - HRESULT IsCompatablePlatformForDebuggerAndDebuggee(DWORD pid, BOOL * pfCompatible); -}; - -#endif - diff --git a/src/inc/iterator.h b/src/inc/iterator.h deleted file mode 100644 index 98cf6185e..000000000 --- a/src/inc/iterator.h +++ /dev/null @@ -1,639 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -// --------------------------------------------------------------------------- -// Iterator.h -// --------------------------------------------------------------------------- - -// ================================================================================ -// Iterator pattern: -// -// This pattern is similar to the STL iterator pattern. It basically consists of -// wrapping an "iteration variable" in an object, and providing pointer-like operators -// on the iterator. Example usage: -// -// for (Iterator start = foo->Begin(), end = foo->End(); start != end; start++) -// { -// // use foo, start -// } -// -// There are 3 levels of iterator functionality -// 1. Enumerator (STL forward) - only go forward one at a time -// Enumerators have the following operations: -// operator * : access current element as ref -// operator -> : access current element as ptr -// operator++ : go to the next element -// operator==, operator!= : compare to another enumerator -// -// -// 2. Scanner (STL bidirectional) - backward or forward one at a time -// Scanners have all the functionality of enumerators, plus: -// operator-- : go backward one element -// -// 3. Indexer (STL random access) - skip around arbitrarily -// Indexers have all the functionality of scanners, plus: -// operator[] : access the element at index from iterator as ref -// operator+= : advance iterator by index -// operator+ : return new iterator at index from iterator -// operator-= : rewind iterator by index -// operator- : return new iterator at index back from iterator -// operator <, operator <=, operator >, operator>= : -// range comparison on two indexers -// -// The object being iterated should define the following methods: -// Begin() return an iterator starting at the first element -// End() return an iterator just past the last element -// -// Iterator types are normally defined as member types named "Iterator", no matter -// what their functionality level is. -// ================================================================================ - - -#ifndef ITERATOR_H_ -#define ITERATOR_H_ - -#include "contract.h" - -namespace HIDDEN { -// These prototypes are not for direct use - they are only here to illustrate the -// iterator pattern - -template -class ScannerPrototype -{ - public: - - typedef ScannerPrototype Iterator; - - ELEMENT &operator*(); - ELEMENT *operator->(); - - Iterator &operator++(); - Iterator operator++(int); - Iterator &operator--(); - Iterator operator--(int); - - bool operator==(const Iterator &i); - bool operator!=(const Iterator &i); -}; - -template -class EnumeratorPrototype -{ - public: - - typedef EnumeratorPrototype Iterator; - - ELEMENT &operator*(); - ELEMENT *operator->(); - - Iterator &operator++(); - Iterator operator++(int); - - bool operator==(const Iterator &i); - bool operator!=(const Iterator &i); -}; - -template -class IndexerPrototype -{ - public: - typedef IndexerPrototype Iterator; - - ELEMENT &operator*(); - ELEMENT *operator->(); - ELEMENT &operator[](int index); - - Iterator &operator++(); - Iterator operator++(int); - Iterator &operator--(); - Iterator operator--(int); - - Iterator &operator+=(SCOUNT_T index); - Iterator &operator-=(SCOUNT_T index); - - Iterator operator+(SCOUNT_T index); - Iterator operator-(SCOUNT_T index); - - SCOUNT_T operator-(Iterator &i); - - bool operator==(const Iterator &i); - bool operator!=(const Iterator &i); - bool operator<(const Iterator &i); - bool operator<=(const Iterator &i); - bool operator>(const Iterator &i); - bool operator>=(const Iterator &i); -}; - -template -class EnumerablePrototype -{ - typedef EnumeratorPrototype Iterator; - - Iterator Begin(); - Iterator End(); -}; - -template -class ScannablePrototype -{ - typedef ScannerPrototype Iterator; - - Iterator Begin(); - Iterator End(); -}; - -template -class IndexablePrototype -{ - typedef IndexerPrototype Iterator; - - Iterator Begin(); - Iterator End(); -}; - -}; - -// -------------------------------------------------------------------------------- -// EnumeratorBase, ScannerBase, and IndexerBase are abstract classes -// describing basic operations for iterator functionality at the different levels. -// -// You -// 1. Use the classes as a pattern (don't derive from them), and plug in your own -// class into the Enumerator/Scanner/Indexer templates below. -// 2. Subclass the AbstractEnumerator/AbstractScanner/AbstractIndexer classes -// -------------------------------------------------------------------------------- - -namespace HIDDEN -{ -// These prototypes are not for direct use - they are only here to illustrate the -// pattern of the BASE class for the Iterator templates - -template -class EnumeratorBasePrototype -{ - protected: - EnumeratorBasePrototype(CONTAINER *container, BOOL begin); - ELEMENT &Get() const; - void Next(); - BOOL Equal(const EnumeratorBasePrototype &i) const; - CHECK DoCheck() const; -}; - -template -class ScannerBasePrototype -{ - protected: - ScannerBasePrototype(CONTAINER *container, BOOL begin); - ELEMENT &Get() const; - void Next(); - void Previous(); - BOOL Equal(const ScannerBasePrototype &i) const; - CHECK DoCheck() const; -}; - -template -class IndexerBasePrototype -{ - protected: - IndexerBasePrototype(CONTAINER *container, SCOUNT_T delta); - ELEMENT &GetAt(SCOUNT_T delta) const; - void Skip(SCOUNT_T delta); - SCOUNT_T Subtract(const IndexerBasePrototype &i) const; - CHECK DoCheck(SCOUNT_T delta) const; -}; - -}; - - -template -class CheckedIteratorBase -{ - protected: -#if defined(_DEBUG) - const CONTAINER *m_container; - int m_revision; -#endif - - CHECK CheckRevision() const - { - LIMITED_METHOD_CONTRACT; - SUPPORTS_DAC; -#if defined(_DEBUG) - __if_exists(CONTAINER::m_revision) - { - CHECK_MSG(m_revision == m_container->m_revision, - "Use of Iterator after container has been modified"); - } -#endif - CHECK_OK; - } - - CheckedIteratorBase() - { - LIMITED_METHOD_DAC_CONTRACT; -#if defined(_DEBUG) - m_container = NULL; -#endif - } - - CheckedIteratorBase(const CONTAINER *container) - { - LIMITED_METHOD_CONTRACT; -#if defined(_DEBUG) - m_container = container; - __if_exists(CONTAINER::m_revision) - { - m_revision = m_container->m_revision; - } -#endif - } - - void Resync(const CONTAINER *container) - { - LIMITED_METHOD_DAC_CONTRACT; - -#if defined(_DEBUG) - __if_exists(CONTAINER::m_revision) - { - m_revision = m_container->m_revision; - } -#endif - } - -#if defined(_DEBUG) - const CONTAINER *GetContainerDebug() const - { - LIMITED_METHOD_CONTRACT; - return m_container; - } -#endif - - public: - CHECK Check() const - { - WRAPPER_NO_CONTRACT; - SUPPORTS_DAC; - CHECK(CheckRevision()); - CHECK_OK; - } - - CHECK CheckContainer(const CONTAINER *container) const - { - WRAPPER_NO_CONTRACT; -#if defined(_DEBUG) - CHECK(container == m_container); -#endif - CHECK_OK; - } - -}; - - -// -------------------------------------------------------------------------------- -// Enumerator, Scanner, and Indexer provide a template to produce an iterator -// on an existing class with a single iteration variable. -// -// The template takes 3 type parameters: -// CONTAINER - type of object being interated on -// ELEMENT - type of iteration -// BASE - base type of the iteration. This type must follow the pattern described -// by the above Prototypes -// -------------------------------------------------------------------------------- - -template -class Enumerator -{ - private: - const SUBTYPE *This() const - { - return (const SUBTYPE *) this; - } - - SUBTYPE *This() - { - return (SUBTYPE *)this; - } - - public: - - Enumerator() - { - } - - CHECK CheckIndex() const - { -#if defined(_DEBUG) - CHECK(This()->DoCheck()); -#endif - CHECK_OK; - } - - ELEMENT &operator*() const - { - PRECONDITION(CheckPointer(This())); - PRECONDITION(This()->CheckIndex()); - - return This()->Get(); - } - ELEMENT *operator->() const - { - PRECONDITION(CheckPointer(This())); - PRECONDITION(This()->CheckIndex()); - - return &(This()->Get()); - } - SUBTYPE &operator++() - { - PRECONDITION(CheckPointer(This())); - - This()->Next(); - return *This(); - } - SUBTYPE operator++(int) - { - PRECONDITION(CheckPointer(This())); - - SUBTYPE i = *This(); - This()->Next(); - return i; - } - bool operator==(const SUBTYPE &i) const - { - PRECONDITION(CheckPointer(This())); - PRECONDITION(i.Check()); - - return This()->Equal(i); - } - bool operator!=(const SUBTYPE &i) const - { - PRECONDITION(CheckPointer(This())); - PRECONDITION(i.Check()); - - return !This()->Equal(i); - } -}; - -template -class Scanner -{ - private: - const SUBTYPE *This() const - { - return (const SUBTYPE *)this; - } - - SUBTYPE *This() - { - return (SUBTYPE *)this; - } - - public: - - Scanner() - { - } - - CHECK CheckIndex() const - { -#if defined(_DEBUG) - CHECK(This()->DoCheck()); -#endif - CHECK_OK; - } - - ELEMENT &operator*() const - { - PRECONDITION(CheckPointer(This())); - PRECONDITION(This()->CheckIndex()); - - return This()->Get(); - } - ELEMENT *operator->() const - { - PRECONDITION(CheckPointer(This())); - PRECONDITION(This()->CheckIndex()); - - return &This()->Get(); - } - SUBTYPE &operator++() - { - PRECONDITION(CheckPointer(This())); - - This()->Next(); - return *This(); - } - SUBTYPE operator++(int) - { - PRECONDITION(CheckPointer(This())); - - SUBTYPE i = *This(); - This()->Next(); - return i; - } - SUBTYPE &operator--() - { - PRECONDITION(CheckPointer(This())); - - This()->Previous(); - return *This(); - } - SUBTYPE operator--(int) - { - PRECONDITION(CheckPointer(this)); - - SUBTYPE i = *This(); - This()->Previous(); - return i; - } - bool operator==(const SUBTYPE &i) const - { - PRECONDITION(CheckPointer(This())); - PRECONDITION(i.Check()); - - return This()->Equal(i); - } - bool operator!=(const SUBTYPE &i) const - { - PRECONDITION(CheckPointer(This())); - PRECONDITION(i.Check()); - - return !This()->Equal(i); - } -}; - -template -class Indexer -{ - private: - const SUBTYPE *This() const - { - return (const SUBTYPE *)this; - } - - SUBTYPE *This() - { - return (SUBTYPE *)this; - } - - public: - - Indexer() - { - LIMITED_METHOD_DAC_CONTRACT; - } - - CHECK CheckIndex() const - { -#if defined(_DEBUG) - CHECK(This()->DoCheck(0)); -#endif - CHECK_OK; - } - - CHECK CheckIndex(int index) const - { -#if defined(_DEBUG) - CHECK(This()->DoCheck(index)); -#endif - CHECK_OK; - } - - ELEMENT &operator*() const - { - WRAPPER_NO_CONTRACT; - PRECONDITION(CheckPointer(This())); - PRECONDITION(This()->CheckIndex(0)); - - return *(ELEMENT*)&This()->GetAt(0); - } - ELEMENT *operator->() const - { - WRAPPER_NO_CONTRACT; - PRECONDITION(CheckPointer(This())); - PRECONDITION(This()->CheckIndex(0)); - - return &This()->GetAt(0); - } - ELEMENT &operator[](int index) const - { - WRAPPER_NO_CONTRACT; - PRECONDITION(CheckPointer(This())); - PRECONDITION(This()->CheckIndex(index)); - return *(ELEMENT*)&This()->GetAt(index); - } - SUBTYPE &operator++() - { - WRAPPER_NO_CONTRACT; - PRECONDITION(CheckPointer(This())); - This()->Skip(1); - return *This(); - } - SUBTYPE operator++(int) - { - WRAPPER_NO_CONTRACT; - PRECONDITION(CheckPointer(This())); - SUBTYPE i = *This(); - This()->Skip(1); - return i; - } - SUBTYPE &operator--() - { - WRAPPER_NO_CONTRACT; - PRECONDITION(CheckPointer(This())); - This()->Skip(-1); - return *This(); - } - SUBTYPE operator--(int) - { - WRAPPER_NO_CONTRACT; - PRECONDITION(CheckPointer(This())); - SUBTYPE i = *This(); - This()->Skip(-1); - return i; - } - SUBTYPE &operator+=(SCOUNT_T index) - { - WRAPPER_NO_CONTRACT; - PRECONDITION(CheckPointer(This())); - This()->Skip(index); - return *This(); - } - SUBTYPE operator+(SCOUNT_T index) const - { - WRAPPER_NO_CONTRACT; - PRECONDITION(CheckPointer(This())); - SUBTYPE i = *This(); - i.Skip(index); - return i; - } - SUBTYPE &operator-=(SCOUNT_T index) - { - WRAPPER_NO_CONTRACT; - PRECONDITION(CheckPointer(This())); - This()->Skip(-index); - return *This(); - } - SUBTYPE operator-(SCOUNT_T index) const - { - WRAPPER_NO_CONTRACT; - PRECONDITION(CheckPointer(This())); - SUBTYPE i = *This(); - i.Skip(-index); - return i; - } - SCOUNT_T operator-(const SUBTYPE &i) const - { - WRAPPER_NO_CONTRACT; - PRECONDITION(CheckPointer(This())); - PRECONDITION(i.Check()); - - return This()->Subtract(i); - } - bool operator==(const SUBTYPE &i) const - { - WRAPPER_NO_CONTRACT; - PRECONDITION(CheckPointer(This())); - PRECONDITION(i.Check()); - - return This()->Subtract(i) == 0; - } - bool operator!=(const SUBTYPE &i) const - { - WRAPPER_NO_CONTRACT; - PRECONDITION(CheckPointer(This())); - PRECONDITION(i.Check()); - - return This()->Subtract(i) != 0; - } - bool operator<(const SUBTYPE &i) const - { - WRAPPER_NO_CONTRACT; - PRECONDITION(CheckPointer(This())); - PRECONDITION(i.Check()); - return This()->Subtract(i) < 0; - } - bool operator<=(const SUBTYPE &i) const - { - WRAPPER_NO_CONTRACT; - PRECONDITION(CheckPointer(This())); - PRECONDITION(i.Check()); - return This()->Subtract(i) <= 0; - } - bool operator>(const SUBTYPE &i) const - { - WRAPPER_NO_CONTRACT; - PRECONDITION(CheckPointer(This())); - PRECONDITION(i.Check()); - return This()->Subtract(i) > 0; - } - bool operator>=(const SUBTYPE &i) const - { - WRAPPER_NO_CONTRACT; - PRECONDITION(CheckPointer(This())); - PRECONDITION(i.Check()); - return This()->Subtract(i) >= 0; - } -}; - -#endif // ITERATOR_H_ diff --git a/src/inc/jithelpers.h b/src/inc/jithelpers.h deleted file mode 100644 index 140badfbb..000000000 --- a/src/inc/jithelpers.h +++ /dev/null @@ -1,363 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -// -// Allow multiple inclusion. - -////////////////////////////////////////////////////////////////////////////////////////////////////////// -// -// NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE -// -// The JIT/EE interface is versioned. By "interface", we mean mean any and all communication between the -// JIT and the EE. Any time a change is made to the interface, the JIT/EE interface version identifier -// must be updated. See code:JITEEVersionIdentifier for more information. -// -// THIS FILE IS PART OF THE JIT-EE INTERFACE. -// -// NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE -// -////////////////////////////////////////////////////////////////////////////////////////////////////////// - - -#ifndef DYNAMICJITHELPER -//I should never try to generate an alignment stub for a dynamic helper -#define DYNAMICJITHELPER(code,fn,sig) JITHELPER(code,fn,sig) -#endif - - -// pfnHelper is set to NULL if it is a stubbed helper. -// It will be set in InitJITHelpers2 - - JITHELPER(CORINFO_HELP_UNDEF, NULL, CORINFO_HELP_SIG_CANNOT_USE_ALIGN_STUB) - - // Arithmetic - JITHELPER(CORINFO_HELP_DIV, JIT_Div, CORINFO_HELP_SIG_8_STACK) - JITHELPER(CORINFO_HELP_MOD, JIT_Mod, CORINFO_HELP_SIG_8_STACK) - JITHELPER(CORINFO_HELP_UDIV, JIT_UDiv, CORINFO_HELP_SIG_8_STACK) - JITHELPER(CORINFO_HELP_UMOD, JIT_UMod, CORINFO_HELP_SIG_8_STACK) - - // CORINFO_HELP_DBL2INT, CORINFO_HELP_DBL2UINT, and CORINFO_HELP_DBL2LONG get - // patched for CPUs that support SSE2 (P4 and above). -#ifndef _TARGET_64BIT_ - JITHELPER(CORINFO_HELP_LLSH, JIT_LLsh, CORINFO_HELP_SIG_REG_ONLY) - JITHELPER(CORINFO_HELP_LRSH, JIT_LRsh, CORINFO_HELP_SIG_REG_ONLY) - JITHELPER(CORINFO_HELP_LRSZ, JIT_LRsz, CORINFO_HELP_SIG_REG_ONLY) -#else // !_TARGET_64BIT_ - JITHELPER(CORINFO_HELP_LLSH, NULL, CORINFO_HELP_SIG_CANNOT_USE_ALIGN_STUB) - JITHELPER(CORINFO_HELP_LRSH, NULL, CORINFO_HELP_SIG_CANNOT_USE_ALIGN_STUB) - JITHELPER(CORINFO_HELP_LRSZ, NULL, CORINFO_HELP_SIG_CANNOT_USE_ALIGN_STUB) -#endif // _TARGET_64BIT_ - JITHELPER(CORINFO_HELP_LMUL, JIT_LMul, CORINFO_HELP_SIG_16_STACK) - JITHELPER(CORINFO_HELP_LMUL_OVF, JIT_LMulOvf, CORINFO_HELP_SIG_16_STACK) - JITHELPER(CORINFO_HELP_ULMUL_OVF, JIT_ULMulOvf, CORINFO_HELP_SIG_16_STACK) - JITHELPER(CORINFO_HELP_LDIV, JIT_LDiv, CORINFO_HELP_SIG_16_STACK) - JITHELPER(CORINFO_HELP_LMOD, JIT_LMod, CORINFO_HELP_SIG_16_STACK) - JITHELPER(CORINFO_HELP_ULDIV, JIT_ULDiv, CORINFO_HELP_SIG_16_STACK) - JITHELPER(CORINFO_HELP_ULMOD, JIT_ULMod, CORINFO_HELP_SIG_16_STACK) - JITHELPER(CORINFO_HELP_LNG2DBL, JIT_Lng2Dbl, CORINFO_HELP_SIG_8_STACK) - JITHELPER(CORINFO_HELP_ULNG2DBL, JIT_ULng2Dbl, CORINFO_HELP_SIG_8_STACK) - DYNAMICJITHELPER(CORINFO_HELP_DBL2INT, JIT_Dbl2Lng, CORINFO_HELP_SIG_8_STACK) - JITHELPER(CORINFO_HELP_DBL2INT_OVF, JIT_Dbl2IntOvf, CORINFO_HELP_SIG_8_STACK) - DYNAMICJITHELPER(CORINFO_HELP_DBL2LNG, JIT_Dbl2Lng, CORINFO_HELP_SIG_8_STACK) - JITHELPER(CORINFO_HELP_DBL2LNG_OVF, JIT_Dbl2LngOvf, CORINFO_HELP_SIG_8_STACK) - DYNAMICJITHELPER(CORINFO_HELP_DBL2UINT, JIT_Dbl2Lng, CORINFO_HELP_SIG_8_STACK) - JITHELPER(CORINFO_HELP_DBL2UINT_OVF, JIT_Dbl2UIntOvf, CORINFO_HELP_SIG_8_STACK) - JITHELPER(CORINFO_HELP_DBL2ULNG, JIT_Dbl2ULng, CORINFO_HELP_SIG_8_STACK) - JITHELPER(CORINFO_HELP_DBL2ULNG_OVF, JIT_Dbl2ULngOvf, CORINFO_HELP_SIG_8_STACK) - JITHELPER(CORINFO_HELP_FLTREM, JIT_FltRem, CORINFO_HELP_SIG_8_STACK) - JITHELPER(CORINFO_HELP_DBLREM, JIT_DblRem, CORINFO_HELP_SIG_16_STACK) - JITHELPER(CORINFO_HELP_FLTROUND, JIT_FloatRound, CORINFO_HELP_SIG_8_STACK) - JITHELPER(CORINFO_HELP_DBLROUND, JIT_DoubleRound, CORINFO_HELP_SIG_16_STACK) - - // Allocating a new object - JITHELPER(CORINFO_HELP_NEW_CROSSCONTEXT, NULL, CORINFO_HELP_SIG_CANNOT_USE_ALIGN_STUB) - JITHELPER(CORINFO_HELP_NEWFAST, JIT_New, CORINFO_HELP_SIG_REG_ONLY) - DYNAMICJITHELPER(CORINFO_HELP_NEWSFAST, JIT_New, CORINFO_HELP_SIG_REG_ONLY) - DYNAMICJITHELPER(CORINFO_HELP_NEWSFAST_ALIGN8, JIT_New, CORINFO_HELP_SIG_REG_ONLY) - JITHELPER(CORINFO_HELP_NEW_MDARR, JIT_NewMDArr,CORINFO_HELP_SIG_8_VA) - JITHELPER(CORINFO_HELP_NEW_MDARR_NONVARARG, JIT_NewMDArrNonVarArg,CORINFO_HELP_SIG_4_STACK) - JITHELPER(CORINFO_HELP_NEWARR_1_DIRECT, JIT_NewArr1,CORINFO_HELP_SIG_REG_ONLY) - JITHELPER(CORINFO_HELP_NEWARR_1_R2R_DIRECT, JIT_NewArr1_R2R,CORINFO_HELP_SIG_REG_ONLY) - DYNAMICJITHELPER(CORINFO_HELP_NEWARR_1_OBJ, JIT_NewArr1,CORINFO_HELP_SIG_REG_ONLY) - DYNAMICJITHELPER(CORINFO_HELP_NEWARR_1_VC, JIT_NewArr1,CORINFO_HELP_SIG_REG_ONLY) - DYNAMICJITHELPER(CORINFO_HELP_NEWARR_1_ALIGN8, JIT_NewArr1,CORINFO_HELP_SIG_REG_ONLY) - - JITHELPER(CORINFO_HELP_STRCNS, JIT_StrCns, CORINFO_HELP_SIG_REG_ONLY) - JITHELPER(CORINFO_HELP_STRCNS_CURRENT_MODULE, NULL, CORINFO_HELP_SIG_REG_ONLY) - - // Object model - JITHELPER(CORINFO_HELP_INITCLASS, JIT_InitClass, CORINFO_HELP_SIG_REG_ONLY) - JITHELPER(CORINFO_HELP_INITINSTCLASS, JIT_InitInstantiatedClass, CORINFO_HELP_SIG_REG_ONLY) - - JITHELPER(CORINFO_HELP_ISINSTANCEOFINTERFACE,JIT_IsInstanceOfInterface, CORINFO_HELP_SIG_REG_ONLY) - JITHELPER(CORINFO_HELP_ISINSTANCEOFARRAY, JIT_IsInstanceOfArray,CORINFO_HELP_SIG_REG_ONLY) - JITHELPER(CORINFO_HELP_ISINSTANCEOFCLASS, JIT_IsInstanceOfClass,CORINFO_HELP_SIG_REG_ONLY) - JITHELPER(CORINFO_HELP_ISINSTANCEOFANY, JIT_IsInstanceOfAny,CORINFO_HELP_SIG_REG_ONLY) - - JITHELPER(CORINFO_HELP_CHKCASTINTERFACE, JIT_ChkCastInterface,CORINFO_HELP_SIG_REG_ONLY) - JITHELPER(CORINFO_HELP_CHKCASTARRAY, JIT_ChkCastArray, CORINFO_HELP_SIG_REG_ONLY) - JITHELPER(CORINFO_HELP_CHKCASTCLASS, JIT_ChkCastClass, CORINFO_HELP_SIG_REG_ONLY) - JITHELPER(CORINFO_HELP_CHKCASTANY, JIT_ChkCastAny, CORINFO_HELP_SIG_REG_ONLY) - - JITHELPER(CORINFO_HELP_CHKCASTCLASS_SPECIAL,JIT_ChkCastClassSpecial,CORINFO_HELP_SIG_REG_ONLY) - DYNAMICJITHELPER(CORINFO_HELP_BOX, JIT_Box, CORINFO_HELP_SIG_REG_ONLY) - JITHELPER(CORINFO_HELP_BOX_NULLABLE, JIT_Box, CORINFO_HELP_SIG_REG_ONLY) - JITHELPER(CORINFO_HELP_UNBOX, JIT_Unbox, CORINFO_HELP_SIG_REG_ONLY) - JITHELPER(CORINFO_HELP_UNBOX_NULLABLE, JIT_Unbox_Nullable, CORINFO_HELP_SIG_4_STACK) - JITHELPER(CORINFO_HELP_GETREFANY, JIT_GetRefAny, CORINFO_HELP_SIG_8_STACK) -#if defined(_TARGET_ARM_) - DYNAMICJITHELPER(CORINFO_HELP_ARRADDR_ST, JIT_Stelem_Ref, CORINFO_HELP_SIG_4_STACK) -#else - JITHELPER(CORINFO_HELP_ARRADDR_ST, JIT_Stelem_Ref, CORINFO_HELP_SIG_4_STACK) -#endif // _TARGET_ARM_ - JITHELPER(CORINFO_HELP_LDELEMA_REF, JIT_Ldelema_Ref, CORINFO_HELP_SIG_4_STACK) - - // Exceptions - JITHELPER(CORINFO_HELP_THROW, IL_Throw, CORINFO_HELP_SIG_REG_ONLY) - JITHELPER(CORINFO_HELP_RETHROW, IL_Rethrow, CORINFO_HELP_SIG_REG_ONLY) - JITHELPER(CORINFO_HELP_USER_BREAKPOINT, JIT_UserBreakpoint, CORINFO_HELP_SIG_REG_ONLY) - JITHELPER(CORINFO_HELP_RNGCHKFAIL, JIT_RngChkFail, CORINFO_HELP_SIG_REG_ONLY) - JITHELPER(CORINFO_HELP_OVERFLOW, JIT_Overflow, CORINFO_HELP_SIG_REG_ONLY) - JITHELPER(CORINFO_HELP_THROWDIVZERO, JIT_ThrowDivZero, CORINFO_HELP_SIG_REG_ONLY) - JITHELPER(CORINFO_HELP_THROWNULLREF, JIT_ThrowNullRef, CORINFO_HELP_SIG_REG_ONLY) - JITHELPER(CORINFO_HELP_INTERNALTHROW, JIT_InternalThrow, CORINFO_HELP_SIG_REG_ONLY) - JITHELPER(CORINFO_HELP_VERIFICATION, IL_VerificationError,CORINFO_HELP_SIG_REG_ONLY) - JITHELPER(CORINFO_HELP_SEC_UNMGDCODE_EXCPT, JIT_SecurityUnmanagedCodeException, CORINFO_HELP_SIG_REG_ONLY) - JITHELPER(CORINFO_HELP_FAIL_FAST, JIT_FailFast, CORINFO_HELP_SIG_REG_ONLY) - JITHELPER(CORINFO_HELP_METHOD_ACCESS_EXCEPTION,JIT_ThrowMethodAccessException, CORINFO_HELP_SIG_REG_ONLY) - JITHELPER(CORINFO_HELP_FIELD_ACCESS_EXCEPTION,JIT_ThrowFieldAccessException, CORINFO_HELP_SIG_REG_ONLY) - JITHELPER(CORINFO_HELP_CLASS_ACCESS_EXCEPTION,JIT_ThrowClassAccessException, CORINFO_HELP_SIG_REG_ONLY) - -#ifdef WIN64EXCEPTIONS - JITHELPER(CORINFO_HELP_ENDCATCH, NULL, CORINFO_HELP_SIG_CANNOT_USE_ALIGN_STUB) -#else - JITHELPER(CORINFO_HELP_ENDCATCH, JIT_EndCatch, CORINFO_HELP_SIG_CANNOT_USE_ALIGN_STUB) -#endif - - JITHELPER(CORINFO_HELP_MON_ENTER, JIT_MonEnterWorker, CORINFO_HELP_SIG_REG_ONLY) - JITHELPER(CORINFO_HELP_MON_EXIT, JIT_MonExitWorker, CORINFO_HELP_SIG_REG_ONLY) - JITHELPER(CORINFO_HELP_MON_ENTER_STATIC, JIT_MonEnterStatic,CORINFO_HELP_SIG_REG_ONLY) - JITHELPER(CORINFO_HELP_MON_EXIT_STATIC, JIT_MonExitStatic,CORINFO_HELP_SIG_REG_ONLY) - - JITHELPER(CORINFO_HELP_GETCLASSFROMMETHODPARAM, JIT_GetClassFromMethodParam, CORINFO_HELP_SIG_REG_ONLY) - JITHELPER(CORINFO_HELP_GETSYNCFROMCLASSHANDLE, JIT_GetSyncFromClassHandle, CORINFO_HELP_SIG_REG_ONLY) - - // Security callout support - JITHELPER(CORINFO_HELP_SECURITY_PROLOG, JIT_Security_Prolog,CORINFO_HELP_SIG_REG_ONLY) - JITHELPER(CORINFO_HELP_SECURITY_PROLOG_FRAMED, JIT_Security_Prolog_Framed,CORINFO_HELP_SIG_REG_ONLY) - - JITHELPER(CORINFO_HELP_METHOD_ACCESS_CHECK, JIT_MethodAccessCheck,CORINFO_HELP_SIG_8_STACK) - JITHELPER(CORINFO_HELP_FIELD_ACCESS_CHECK, JIT_FieldAccessCheck,CORINFO_HELP_SIG_4_STACK) - JITHELPER(CORINFO_HELP_CLASS_ACCESS_CHECK, JIT_ClassAccessCheck,CORINFO_HELP_SIG_4_STACK) - - JITHELPER(CORINFO_HELP_DELEGATE_SECURITY_CHECK, JIT_DelegateSecurityCheck,CORINFO_HELP_SIG_REG_ONLY) - - // Verification runtime callout support - JITHELPER(CORINFO_HELP_VERIFICATION_RUNTIME_CHECK, JIT_VerificationRuntimeCheck,CORINFO_HELP_SIG_REG_ONLY) - - // GC support - DYNAMICJITHELPER(CORINFO_HELP_STOP_FOR_GC, JIT_RareDisableHelper,CORINFO_HELP_SIG_REG_ONLY) -#ifdef ENABLE_FAST_GCPOLL_HELPER - DYNAMICJITHELPER(CORINFO_HELP_POLL_GC, JIT_PollGC, CORINFO_HELP_SIG_REG_ONLY) -#else - JITHELPER(CORINFO_HELP_POLL_GC, JIT_PollGC, CORINFO_HELP_SIG_REG_ONLY) -#endif - JITHELPER(CORINFO_HELP_STRESS_GC, JIT_StressGC, CORINFO_HELP_SIG_REG_ONLY) - - JITHELPER(CORINFO_HELP_CHECK_OBJ, JIT_CheckObj, CORINFO_HELP_SIG_REG_ONLY) - - // GC Write barrier support - DYNAMICJITHELPER(CORINFO_HELP_ASSIGN_REF, JIT_WriteBarrier, CORINFO_HELP_SIG_NO_ALIGN_STUB) - DYNAMICJITHELPER(CORINFO_HELP_CHECKED_ASSIGN_REF, JIT_CheckedWriteBarrier,CORINFO_HELP_SIG_NO_ALIGN_STUB) - JITHELPER(CORINFO_HELP_ASSIGN_REF_ENSURE_NONHEAP, JIT_WriteBarrierEnsureNonHeapTarget,CORINFO_HELP_SIG_REG_ONLY) - - DYNAMICJITHELPER(CORINFO_HELP_ASSIGN_BYREF, JIT_ByRefWriteBarrier,CORINFO_HELP_SIG_NO_ALIGN_STUB) - - JITHELPER(CORINFO_HELP_ASSIGN_STRUCT, JIT_StructWriteBarrier,CORINFO_HELP_SIG_4_STACK) - - // Accessing fields - JITHELPER(CORINFO_HELP_GETFIELD8, JIT_GetField8,CORINFO_HELP_SIG_REG_ONLY) - JITHELPER(CORINFO_HELP_SETFIELD8, JIT_SetField8,CORINFO_HELP_SIG_4_STACK) - JITHELPER(CORINFO_HELP_GETFIELD16, JIT_GetField16,CORINFO_HELP_SIG_REG_ONLY) - JITHELPER(CORINFO_HELP_SETFIELD16, JIT_SetField16,CORINFO_HELP_SIG_4_STACK) - JITHELPER(CORINFO_HELP_GETFIELD32, JIT_GetField32,CORINFO_HELP_SIG_REG_ONLY) - JITHELPER(CORINFO_HELP_SETFIELD32, JIT_SetField32,CORINFO_HELP_SIG_4_STACK) - JITHELPER(CORINFO_HELP_GETFIELD64, JIT_GetField64,CORINFO_HELP_SIG_REG_ONLY) - JITHELPER(CORINFO_HELP_SETFIELD64, JIT_SetField64,CORINFO_HELP_SIG_8_STACK) - JITHELPER(CORINFO_HELP_GETFIELDOBJ, JIT_GetFieldObj,CORINFO_HELP_SIG_REG_ONLY) - JITHELPER(CORINFO_HELP_SETFIELDOBJ, JIT_SetFieldObj,CORINFO_HELP_SIG_4_STACK) - JITHELPER(CORINFO_HELP_GETFIELDSTRUCT, JIT_GetFieldStruct,CORINFO_HELP_SIG_8_STACK) - JITHELPER(CORINFO_HELP_SETFIELDSTRUCT, JIT_SetFieldStruct,CORINFO_HELP_SIG_8_STACK) - JITHELPER(CORINFO_HELP_GETFIELDFLOAT, JIT_GetFieldFloat,CORINFO_HELP_SIG_REG_ONLY) - JITHELPER(CORINFO_HELP_SETFIELDFLOAT, JIT_SetFieldFloat,CORINFO_HELP_SIG_4_STACK) - JITHELPER(CORINFO_HELP_GETFIELDDOUBLE, JIT_GetFieldDouble,CORINFO_HELP_SIG_REG_ONLY) - JITHELPER(CORINFO_HELP_SETFIELDDOUBLE, JIT_SetFieldDouble,CORINFO_HELP_SIG_8_STACK) - - JITHELPER(CORINFO_HELP_GETFIELDADDR, JIT_GetFieldAddr,CORINFO_HELP_SIG_REG_ONLY) - - JITHELPER(CORINFO_HELP_GETSTATICFIELDADDR_CONTEXT, NULL, CORINFO_HELP_SIG_CANNOT_USE_ALIGN_STUB) - JITHELPER(CORINFO_HELP_GETSTATICFIELDADDR_TLS, NULL, CORINFO_HELP_SIG_CANNOT_USE_ALIGN_STUB) - - JITHELPER(CORINFO_HELP_GETGENERICS_GCSTATIC_BASE, JIT_GetGenericsGCStaticBase,CORINFO_HELP_SIG_REG_ONLY) - JITHELPER(CORINFO_HELP_GETGENERICS_NONGCSTATIC_BASE, JIT_GetGenericsNonGCStaticBase,CORINFO_HELP_SIG_REG_ONLY) - -#ifdef _TARGET_X86_ - DYNAMICJITHELPER(CORINFO_HELP_GETSHARED_GCSTATIC_BASE, NULL, CORINFO_HELP_SIG_REG_ONLY) - DYNAMICJITHELPER(CORINFO_HELP_GETSHARED_NONGCSTATIC_BASE, NULL, CORINFO_HELP_SIG_REG_ONLY) - DYNAMICJITHELPER(CORINFO_HELP_GETSHARED_GCSTATIC_BASE_NOCTOR, NULL, CORINFO_HELP_SIG_REG_ONLY) - DYNAMICJITHELPER(CORINFO_HELP_GETSHARED_NONGCSTATIC_BASE_NOCTOR,NULL, CORINFO_HELP_SIG_REG_ONLY) -#else - DYNAMICJITHELPER(CORINFO_HELP_GETSHARED_GCSTATIC_BASE, JIT_GetSharedGCStaticBase, CORINFO_HELP_SIG_CANNOT_USE_ALIGN_STUB) - DYNAMICJITHELPER(CORINFO_HELP_GETSHARED_NONGCSTATIC_BASE, JIT_GetSharedNonGCStaticBase, CORINFO_HELP_SIG_CANNOT_USE_ALIGN_STUB) - DYNAMICJITHELPER(CORINFO_HELP_GETSHARED_GCSTATIC_BASE_NOCTOR, JIT_GetSharedGCStaticBaseNoCtor, CORINFO_HELP_SIG_CANNOT_USE_ALIGN_STUB) - DYNAMICJITHELPER(CORINFO_HELP_GETSHARED_NONGCSTATIC_BASE_NOCTOR,JIT_GetSharedNonGCStaticBaseNoCtor, CORINFO_HELP_SIG_CANNOT_USE_ALIGN_STUB) -#endif - JITHELPER(CORINFO_HELP_GETSHARED_GCSTATIC_BASE_DYNAMICCLASS, JIT_GetSharedGCStaticBaseDynamicClass,CORINFO_HELP_SIG_REG_ONLY) - JITHELPER(CORINFO_HELP_GETSHARED_NONGCSTATIC_BASE_DYNAMICCLASS, JIT_GetSharedNonGCStaticBaseDynamicClass,CORINFO_HELP_SIG_REG_ONLY) - JITHELPER(CORINFO_HELP_CLASSINIT_SHARED_DYNAMICCLASS, JIT_ClassInitDynamicClass,CORINFO_HELP_SIG_REG_ONLY) - - // Thread statics - JITHELPER(CORINFO_HELP_GETGENERICS_GCTHREADSTATIC_BASE, JIT_GetGenericsGCThreadStaticBase,CORINFO_HELP_SIG_REG_ONLY) - JITHELPER(CORINFO_HELP_GETGENERICS_NONGCTHREADSTATIC_BASE, JIT_GetGenericsNonGCThreadStaticBase,CORINFO_HELP_SIG_REG_ONLY) - JITHELPER(CORINFO_HELP_GETSHARED_GCTHREADSTATIC_BASE, JIT_GetSharedGCThreadStaticBase, CORINFO_HELP_SIG_REG_ONLY) - JITHELPER(CORINFO_HELP_GETSHARED_NONGCTHREADSTATIC_BASE, JIT_GetSharedNonGCThreadStaticBase, CORINFO_HELP_SIG_REG_ONLY) - JITHELPER(CORINFO_HELP_GETSHARED_GCTHREADSTATIC_BASE_NOCTOR, JIT_GetSharedGCThreadStaticBase, CORINFO_HELP_SIG_REG_ONLY) - JITHELPER(CORINFO_HELP_GETSHARED_NONGCTHREADSTATIC_BASE_NOCTOR, JIT_GetSharedNonGCThreadStaticBase, CORINFO_HELP_SIG_REG_ONLY) - JITHELPER(CORINFO_HELP_GETSHARED_GCTHREADSTATIC_BASE_DYNAMICCLASS, JIT_GetSharedGCThreadStaticBaseDynamicClass, CORINFO_HELP_SIG_REG_ONLY) - JITHELPER(CORINFO_HELP_GETSHARED_NONGCTHREADSTATIC_BASE_DYNAMICCLASS, JIT_GetSharedNonGCThreadStaticBaseDynamicClass, CORINFO_HELP_SIG_REG_ONLY) - - // Debugger - JITHELPER(CORINFO_HELP_DBG_IS_JUST_MY_CODE, JIT_DbgIsJustMyCode,CORINFO_HELP_SIG_REG_ONLY) - - /* Profiling enter/leave probe addresses */ - DYNAMICJITHELPER(CORINFO_HELP_PROF_FCN_ENTER, JIT_ProfilerEnterLeaveTailcallStub, CORINFO_HELP_SIG_4_STACK) - DYNAMICJITHELPER(CORINFO_HELP_PROF_FCN_LEAVE, JIT_ProfilerEnterLeaveTailcallStub, CORINFO_HELP_SIG_4_STACK) - DYNAMICJITHELPER(CORINFO_HELP_PROF_FCN_TAILCALL, JIT_ProfilerEnterLeaveTailcallStub, CORINFO_HELP_SIG_4_STACK) - - // Miscellaneous - JITHELPER(CORINFO_HELP_BBT_FCN_ENTER, JIT_LogMethodEnter,CORINFO_HELP_SIG_REG_ONLY) - - JITHELPER(CORINFO_HELP_PINVOKE_CALLI, GenericPInvokeCalliHelper, CORINFO_HELP_SIG_NO_ALIGN_STUB) - - JITHELPER(CORINFO_HELP_TAILCALL, JIT_TailCall, CORINFO_HELP_SIG_CANNOT_USE_ALIGN_STUB) - - JITHELPER(CORINFO_HELP_GETCURRENTMANAGEDTHREADID, JIT_GetCurrentManagedThreadId, CORINFO_HELP_SIG_REG_ONLY) - -#ifdef _WIN64 - // On Windows X64, the last argument is ignored. - JITHELPER(CORINFO_HELP_INIT_PINVOKE_FRAME, JIT_InitPInvokeFrame, CORINFO_HELP_SIG_REG_ONLY) -#else - DYNAMICJITHELPER(CORINFO_HELP_INIT_PINVOKE_FRAME, NULL, CORINFO_HELP_SIG_REG_ONLY) -#endif - -#ifdef _TARGET_X86_ - JITHELPER(CORINFO_HELP_MEMSET, NULL, CORINFO_HELP_SIG_CANNOT_USE_ALIGN_STUB) - JITHELPER(CORINFO_HELP_MEMCPY, NULL, CORINFO_HELP_SIG_CANNOT_USE_ALIGN_STUB) -#else - JITHELPER(CORINFO_HELP_MEMSET, JIT_MemSet, CORINFO_HELP_SIG_REG_ONLY) - JITHELPER(CORINFO_HELP_MEMCPY, JIT_MemCpy, CORINFO_HELP_SIG_REG_ONLY) -#endif - - // Generics - JITHELPER(CORINFO_HELP_RUNTIMEHANDLE_METHOD, JIT_GenericHandleMethod, CORINFO_HELP_SIG_REG_ONLY) - JITHELPER(CORINFO_HELP_RUNTIMEHANDLE_METHOD_LOG,JIT_GenericHandleMethodLogging, CORINFO_HELP_SIG_REG_ONLY) - JITHELPER(CORINFO_HELP_RUNTIMEHANDLE_CLASS, JIT_GenericHandleClass, CORINFO_HELP_SIG_REG_ONLY) - JITHELPER(CORINFO_HELP_RUNTIMEHANDLE_CLASS_LOG, JIT_GenericHandleClassLogging, CORINFO_HELP_SIG_REG_ONLY) - JITHELPER(CORINFO_HELP_TYPEHANDLE_TO_RUNTIMETYPEHANDLE_OBSOLETE, NULL, CORINFO_HELP_SIG_CANNOT_USE_ALIGN_STUB) - JITHELPER(CORINFO_HELP_METHODDESC_TO_RUNTIMEMETHODHANDLE_OBSOLETE, NULL, CORINFO_HELP_SIG_CANNOT_USE_ALIGN_STUB) - JITHELPER(CORINFO_HELP_FIELDDESC_TO_RUNTIMEFIELDHANDLE_OBSOLETE, NULL, CORINFO_HELP_SIG_CANNOT_USE_ALIGN_STUB) - JITHELPER(CORINFO_HELP_TYPEHANDLE_TO_RUNTIMETYPE, JIT_GetRuntimeType, CORINFO_HELP_SIG_REG_ONLY) - JITHELPER(CORINFO_HELP_TYPEHANDLE_TO_RUNTIMETYPE_MAYBENULL, JIT_GetRuntimeType_MaybeNull, CORINFO_HELP_SIG_REG_ONLY) - JITHELPER(CORINFO_HELP_METHODDESC_TO_STUBRUNTIMEMETHOD, JIT_GetRuntimeMethodStub,CORINFO_HELP_SIG_REG_ONLY) - JITHELPER(CORINFO_HELP_FIELDDESC_TO_STUBRUNTIMEFIELD, JIT_GetRuntimeFieldStub, CORINFO_HELP_SIG_REG_ONLY) - - JITHELPER(CORINFO_HELP_VIRTUAL_FUNC_PTR, JIT_VirtualFunctionPointer, CORINFO_HELP_SIG_4_STACK) - //JITHELPER(CORINFO_HELP_VIRTUAL_FUNC_PTR_LOG,JIT_VirtualFunctionPointerLogging) - - JITHELPER(CORINFO_HELP_READYTORUN_NEW, NULL, CORINFO_HELP_SIG_NO_ALIGN_STUB) - JITHELPER(CORINFO_HELP_READYTORUN_NEWARR_1, NULL, CORINFO_HELP_SIG_NO_ALIGN_STUB) - JITHELPER(CORINFO_HELP_READYTORUN_ISINSTANCEOF, NULL, CORINFO_HELP_SIG_NO_ALIGN_STUB) - JITHELPER(CORINFO_HELP_READYTORUN_CHKCAST, NULL, CORINFO_HELP_SIG_NO_ALIGN_STUB) - JITHELPER(CORINFO_HELP_READYTORUN_STATIC_BASE, NULL, CORINFO_HELP_SIG_NO_ALIGN_STUB) - JITHELPER(CORINFO_HELP_READYTORUN_VIRTUAL_FUNC_PTR, NULL, CORINFO_HELP_SIG_NO_ALIGN_STUB) - JITHELPER(CORINFO_HELP_READYTORUN_GENERIC_HANDLE, NULL, CORINFO_HELP_SIG_NO_ALIGN_STUB) - JITHELPER(CORINFO_HELP_READYTORUN_DELEGATE_CTOR, NULL, CORINFO_HELP_SIG_NO_ALIGN_STUB) - JITHELPER(CORINFO_HELP_READYTORUN_GENERIC_STATIC_BASE, NULL, CORINFO_HELP_SIG_NO_ALIGN_STUB) - - JITHELPER(CORINFO_HELP_EE_PRESTUB, ThePreStub, CORINFO_HELP_SIG_NO_ALIGN_STUB) - -#if defined(HAS_FIXUP_PRECODE) - JITHELPER(CORINFO_HELP_EE_PRECODE_FIXUP, PrecodeFixupThunk, CORINFO_HELP_SIG_NO_ALIGN_STUB) -#else - JITHELPER(CORINFO_HELP_EE_PRECODE_FIXUP, NULL, CORINFO_HELP_SIG_NO_ALIGN_STUB) -#endif - - JITHELPER(CORINFO_HELP_EE_PINVOKE_FIXUP, NDirectImportThunk, CORINFO_HELP_SIG_NO_ALIGN_STUB) - - JITHELPER(CORINFO_HELP_EE_VSD_FIXUP, StubDispatchFixupStub, CORINFO_HELP_SIG_NO_ALIGN_STUB) - JITHELPER(CORINFO_HELP_EE_EXTERNAL_FIXUP, ExternalMethodFixupStub, CORINFO_HELP_SIG_NO_ALIGN_STUB) - JITHELPER(CORINFO_HELP_EE_VTABLE_FIXUP, VirtualMethodFixupStub, CORINFO_HELP_SIG_NO_ALIGN_STUB) - - JITHELPER(CORINFO_HELP_EE_REMOTING_THUNK, NULL, CORINFO_HELP_SIG_UNDEF) - -// We do not need this to be saved in ngen images on Mac64 since the exception dispatch -// is not done via the OS and thus, there wont be any need to know this information -// by anyone. -#ifdef WIN64EXCEPTIONS - JITHELPER(CORINFO_HELP_EE_PERSONALITY_ROUTINE, ProcessCLRException, CORINFO_HELP_SIG_UNDEF) - JITHELPER(CORINFO_HELP_EE_PERSONALITY_ROUTINE_FILTER_FUNCLET, ProcessCLRException,CORINFO_HELP_SIG_UNDEF) -#else // WIN64EXCEPTIONS - JITHELPER(CORINFO_HELP_EE_PERSONALITY_ROUTINE, NULL, CORINFO_HELP_SIG_UNDEF) - JITHELPER(CORINFO_HELP_EE_PERSONALITY_ROUTINE_FILTER_FUNCLET, NULL, CORINFO_HELP_SIG_UNDEF) -#endif // !WIN64EXCEPTIONS - -#ifdef _TARGET_X86_ - JITHELPER(CORINFO_HELP_ASSIGN_REF_EAX, JIT_WriteBarrierEAX, CORINFO_HELP_SIG_NO_ALIGN_STUB) - JITHELPER(CORINFO_HELP_ASSIGN_REF_EBX, JIT_WriteBarrierEBX, CORINFO_HELP_SIG_NO_ALIGN_STUB) - JITHELPER(CORINFO_HELP_ASSIGN_REF_ECX, JIT_WriteBarrierECX, CORINFO_HELP_SIG_NO_ALIGN_STUB) - JITHELPER(CORINFO_HELP_ASSIGN_REF_ESI, JIT_WriteBarrierESI, CORINFO_HELP_SIG_NO_ALIGN_STUB) - JITHELPER(CORINFO_HELP_ASSIGN_REF_EDI, JIT_WriteBarrierEDI, CORINFO_HELP_SIG_NO_ALIGN_STUB) - JITHELPER(CORINFO_HELP_ASSIGN_REF_EBP, JIT_WriteBarrierEBP, CORINFO_HELP_SIG_NO_ALIGN_STUB) - - JITHELPER(CORINFO_HELP_CHECKED_ASSIGN_REF_EAX, JIT_CheckedWriteBarrierEAX, CORINFO_HELP_SIG_NO_ALIGN_STUB) - JITHELPER(CORINFO_HELP_CHECKED_ASSIGN_REF_EBX, JIT_CheckedWriteBarrierEBX, CORINFO_HELP_SIG_NO_ALIGN_STUB) - JITHELPER(CORINFO_HELP_CHECKED_ASSIGN_REF_ECX, JIT_CheckedWriteBarrierECX, CORINFO_HELP_SIG_NO_ALIGN_STUB) - JITHELPER(CORINFO_HELP_CHECKED_ASSIGN_REF_ESI, JIT_CheckedWriteBarrierESI, CORINFO_HELP_SIG_NO_ALIGN_STUB) - JITHELPER(CORINFO_HELP_CHECKED_ASSIGN_REF_EDI, JIT_CheckedWriteBarrierEDI, CORINFO_HELP_SIG_NO_ALIGN_STUB) - JITHELPER(CORINFO_HELP_CHECKED_ASSIGN_REF_EBP, JIT_CheckedWriteBarrierEBP, CORINFO_HELP_SIG_NO_ALIGN_STUB) -#else - JITHELPER(CORINFO_HELP_ASSIGN_REF_EAX, NULL, CORINFO_HELP_SIG_UNDEF) - JITHELPER(CORINFO_HELP_ASSIGN_REF_EBX, NULL, CORINFO_HELP_SIG_UNDEF) - JITHELPER(CORINFO_HELP_ASSIGN_REF_ECX, NULL, CORINFO_HELP_SIG_UNDEF) - JITHELPER(CORINFO_HELP_ASSIGN_REF_ESI, NULL, CORINFO_HELP_SIG_UNDEF) - JITHELPER(CORINFO_HELP_ASSIGN_REF_EDI, NULL, CORINFO_HELP_SIG_UNDEF) - JITHELPER(CORINFO_HELP_ASSIGN_REF_EBP, NULL, CORINFO_HELP_SIG_UNDEF) - - JITHELPER(CORINFO_HELP_CHECKED_ASSIGN_REF_EAX, NULL, CORINFO_HELP_SIG_UNDEF) - JITHELPER(CORINFO_HELP_CHECKED_ASSIGN_REF_EBX, NULL, CORINFO_HELP_SIG_UNDEF) - JITHELPER(CORINFO_HELP_CHECKED_ASSIGN_REF_ECX, NULL, CORINFO_HELP_SIG_UNDEF) - JITHELPER(CORINFO_HELP_CHECKED_ASSIGN_REF_ESI, NULL, CORINFO_HELP_SIG_UNDEF) - JITHELPER(CORINFO_HELP_CHECKED_ASSIGN_REF_EDI, NULL, CORINFO_HELP_SIG_UNDEF) - JITHELPER(CORINFO_HELP_CHECKED_ASSIGN_REF_EBP, NULL, CORINFO_HELP_SIG_UNDEF) -#endif - - JITHELPER(CORINFO_HELP_LOOP_CLONE_CHOICE_ADDR, JIT_LoopCloneChoiceAddr, CORINFO_HELP_SIG_REG_ONLY) - JITHELPER(CORINFO_HELP_DEBUG_LOG_LOOP_CLONING, JIT_DebugLogLoopCloning, CORINFO_HELP_SIG_REG_ONLY) - - JITHELPER(CORINFO_HELP_THROW_ARGUMENTEXCEPTION, JIT_ThrowArgumentException, CORINFO_HELP_SIG_REG_ONLY) - JITHELPER(CORINFO_HELP_THROW_ARGUMENTOUTOFRANGEEXCEPTION, JIT_ThrowArgumentOutOfRangeException, CORINFO_HELP_SIG_REG_ONLY) - JITHELPER(CORINFO_HELP_THROW_PLATFORM_NOT_SUPPORTED, JIT_ThrowPlatformNotSupportedException, CORINFO_HELP_SIG_REG_ONLY) - JITHELPER(CORINFO_HELP_THROW_TYPE_NOT_SUPPORTED, JIT_ThrowTypeNotSupportedException, CORINFO_HELP_SIG_REG_ONLY) - - JITHELPER(CORINFO_HELP_JIT_PINVOKE_BEGIN, NULL, CORINFO_HELP_SIG_UNDEF) - JITHELPER(CORINFO_HELP_JIT_PINVOKE_END, NULL, CORINFO_HELP_SIG_UNDEF) - - JITHELPER(CORINFO_HELP_JIT_REVERSE_PINVOKE_ENTER, NULL, CORINFO_HELP_SIG_UNDEF) - JITHELPER(CORINFO_HELP_JIT_REVERSE_PINVOKE_EXIT, NULL, CORINFO_HELP_SIG_UNDEF) - - JITHELPER(CORINFO_HELP_GVMLOOKUP_FOR_SLOT, NULL, CORINFO_HELP_SIG_NO_ALIGN_STUB) - -#undef JITHELPER -#undef DYNAMICJITHELPER -#undef JITHELPER -#undef DYNAMICJITHELPER diff --git a/src/inc/jithost.h b/src/inc/jithost.h deleted file mode 100644 index 73ad3343b..000000000 --- a/src/inc/jithost.h +++ /dev/null @@ -1,28 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#ifndef __JITHOST_H__ -#define __JITHOST_H__ - -// Common implementation of ICorJitHost that respects CLR host policies. -class JitHost : public ICorJitHost -{ -private: - static JitHost theJitHost; - - JitHost() {} - JitHost(const JitHost& other) = delete; - JitHost& operator=(const JitHost& other) = delete; - -public: - virtual void* allocateMemory(size_t size, bool usePageAllocator); - virtual void freeMemory(void* block, bool usePageAllocator); - virtual int getIntConfigValue(const wchar_t* name, int defaultValue); - virtual const wchar_t* getStringConfigValue(const wchar_t* name); - virtual void freeStringConfigValue(const wchar_t* value); - - static ICorJitHost* getJitHost(); -}; - -#endif // __JITHOST_H__ diff --git a/src/inc/jitperf.h b/src/inc/jitperf.h deleted file mode 100644 index 022cfd216..000000000 --- a/src/inc/jitperf.h +++ /dev/null @@ -1,97 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -//----------------------------------------------------------------------------- -// JitPerf.h -// Internal interface for gathering JIT perfmormance stats. These stats are -// logged (or displayed) in two ways. If PERF_COUNTERS are enabled the -// perfmon etc. would display the jit stats. If ENABLE_PERF_LOG is enabled -// and PERF_OUTPUT env var is defined then the jit stats are displayed on the -// stdout. (The jit stats are outputted in a specific format to a file for -// automated perf tests.) -// - -//----------------------------------------------------------------------------- - - -#ifndef __JITPERF_H__ -#define __JITPERF_H__ - -#include "mscoree.h" -#include "clrinternal.h" - -// ENABLE_JIT_PERF tag used to activate JIT specific profiling. -#define ENABLE_JIT_PERF - -#if defined(ENABLE_JIT_PERF) - -extern __int64 g_JitCycles; -extern size_t g_NonJitCycles; -extern CRITSEC_COOKIE g_csJit; -extern __int64 g_tlsJitCycles; -extern int g_fJitPerfOn; - -extern size_t g_dwTlsx86CodeSize; -extern size_t g_TotalILCodeSize; -extern size_t g_Totalx86CodeSize; -extern size_t g_TotalMethodsJitted; - -// Public interface to initialize jit stats data structs -void InitJitPerf(void); -// Public interface to deallocate datastruct and output the stats. -void DoneJitPerfStats(void); - -// Start/StopNonJITPerf macros are used many times. Factor out the payload -// into helper method to reduce code size. -void StartNonJITPerfWorker(LARGE_INTEGER * pCycleStart); -void StopNonJITPerfWorker(LARGE_INTEGER * pCycleStart); - -// Use the callee's stack frame (so START & STOP functions can share variables) -#define START_JIT_PERF() \ - if (g_fJitPerfOn) { \ - ClrFlsSetValue (TlsIdx_JitPerf, (LPVOID)0); \ - g_dwTlsx86CodeSize = 0; \ - ClrFlsSetValue (TlsIdx_JitX86Perf, (LPVOID)g_dwTlsx86CodeSize); \ - } - - -#define STOP_JIT_PERF() \ - if (g_fJitPerfOn) { \ - size_t dwTlsNonJitCycles = (size_t)ClrFlsGetValue (TlsIdx_JitPerf); \ - size_t dwx86CodeSize = (size_t)ClrFlsGetValue (TlsIdx_JitX86Perf); \ - CRITSEC_Holder csh (g_csJit); \ - g_JitCycles += static_cast(CycleStop.QuadPart - CycleStart.QuadPart); \ - g_NonJitCycles += dwTlsNonJitCycles; \ - g_TotalILCodeSize += methodInfo.ILCodeSize; \ - g_Totalx86CodeSize += dwx86CodeSize; \ - g_TotalMethodsJitted ++; \ - } - -#define START_NON_JIT_PERF() \ - LARGE_INTEGER CycleStart; \ - if(g_fJitPerfOn) { \ - StartNonJITPerfWorker(&CycleStart); \ - } - -#define STOP_NON_JIT_PERF() \ - if(g_fJitPerfOn) { \ - StopNonJITPerfWorker(&CycleStart); \ - } - -#define JIT_PERF_UPDATE_X86_CODE_SIZE(size) \ - if(g_fJitPerfOn) { \ - size_t dwx86CodeSize = (size_t)ClrFlsGetValue (TlsIdx_JitX86Perf); \ - dwx86CodeSize += (size); \ - ClrFlsSetValue (TlsIdx_JitX86Perf, (LPVOID)dwx86CodeSize); \ - } - - -#else //ENABLE_JIT_PERF -#define START_JIT_PERF() -#define STOP_JIT_PERF() -#define START_NON_JIT_PERF() -#define STOP_NON_JIT_PERF() -#define JIT_PERF_UPDATE_X86_CODE_SIZE(size) -#endif //ENABLE_JIT_PERF - -#endif //__JITPERF_H__ diff --git a/src/inc/lazycow.h b/src/inc/lazycow.h deleted file mode 100644 index c4605b6e0..000000000 --- a/src/inc/lazycow.h +++ /dev/null @@ -1,99 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -// -------------------------------------------------------------------------------- -// LazyCOW.h -// - -// -// Provides support for "lazy copy-on-write" pages. -// -// NGEN images contain a large amount of writable data. At runtime, we typically only actually write to a small portion of this data. -// When we write to a writable page in an image, the OS must create a process-local copy of that page, so that other proceses -// cannot see the written data. To prevent this copy from failing, the OS pre-commits space in the pagefile for all writable -// pages when the image is loaded. Thus we get charged for every writable page, even if we only write to a few of them. -// -// FEATURE_LAZY_COW_PAGES enables "lazy copy-on-write." We mark the pages in the image file as read-only, and thus the OS -// does not pre-commit pagefile for these pages. At runtime, prior to writing to any page, we update it to be writable. -// This may fail, and thus is not appropriate for scenarios where strong reliability guarantees must be met. But for -// devices with small memory this is still worth it. -// -// -------------------------------------------------------------------------------- - -#ifndef LAZY_COW_H -#define LAZY_COW_H - -#ifdef FEATURE_LAZY_COW_PAGES - -#ifdef _WIN64 // due to the way we track pages, we cannot currently support 64-bit. -#error FEATURE_LAZY_COW_PAGES is only supported on 32-bit platforms. -#endif - -class PEDecoder; - -// If hModule is a native image, establishes copy-on-write tracking for the image. -// FreeLazyCOWPages must be called immediately before the module is unloaded. -void AllocateLazyCOWPages(PEDecoder * pImage); - -// If hModule is a native image, disestablishes copy-on-write tracking for the image. -// The image must be immediately unloaded following this call. -void FreeLazyCOWPages(PEDecoder * pImage); - -bool IsInReadOnlyLazyCOWPage(void* p); - - -// Forces the page(s) covered by the given address range to be made writable, -// if they are being tracked as copy-on-write pages. Otherwise does nothing. -// Returns false if we could not allocate the necessary memory. -bool EnsureWritablePagesNoThrow(void* p, size_t len); - -// Version for executable pages -bool EnsureWritableExecutablePagesNoThrow(void* p, size_t len); - -// Throwing version of EnsureWritablePagesNoThrow -void EnsureWritablePages(void* p, size_t len); - -// Version for executable pages -void EnsureWritableExecutablePages(void* p, size_t len); - -#else //FEATURE_LAZY_COW_PAGES - -inline bool EnsureWritablePagesNoThrow(void* p, size_t len) -{ - return true; -} - -inline bool EnsureWritableExecutablePagesNoThrow(void* p, size_t len) -{ - return true; -} - -inline void EnsureWritablePages(void* p, size_t len) -{ -} - -inline void EnsureWritableExecutablePages(void* p, size_t len) -{ -} - -#endif //FEATURE_LAZY_COW_PAGES - -// Typed version of EnsureWritable. Returns p, so this can be inserted in expressions. -// Ignores any failure to allocate. In typical cases this means that the write will AV. -// In the CLR that's OK; we handle the AV, try EnsureWritable(void*,size_t), and -// fail-fast when it fails. -template -inline T* EnsureWritablePages(T* p) -{ - EnsureWritablePages(p, sizeof(T)); - return p; -} - -template -inline T* EnsureWritableExecutablePages(T* p) -{ - EnsureWritableExecutablePages(p, sizeof(T)); - return p; -} - -#endif // LAZY_COW_H diff --git a/src/inc/legacyactivationshimutil.h b/src/inc/legacyactivationshimutil.h deleted file mode 100644 index 4e6cdf0d2..000000000 --- a/src/inc/legacyactivationshimutil.h +++ /dev/null @@ -1,1116 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -// -// LegacyActivationShim.h -// -// This file allows simple migration from .NET Runtime v2 Host Activation APIs -// to the .NET Runtime v4 Host Activation APIs through simple shim functions. - -#ifndef __LEGACYACTIVATIONSHIMUTIL_H__ -#define __LEGACYACTIVATIONSHIMUTIL_H__ - -// To minimize how much we perturb sources that we are included in, we make sure that -// all macros we define/redefine are restored at the end of the header. -#pragma push_macro("SELECTANY") -#pragma push_macro("_TEXT_ENCODE") -#pragma push_macro("countof") -#pragma push_macro("UNUSED") - -#ifndef _MSC_VER -#error "LegacyActivationShim.h cannot be used on non-MS compilers" -#endif - -// ---SELECTANY------------------------------------------------------------------------------------ -#undef SELECTANY -#define SELECTANY extern __declspec(selectany) - -// Allow users of these headers to provide custom 'LoadLibrary' implementation (e.g. WszLoadLibrary). -// Example of usage is in ndp\clr\src\fusion\tools\viewer. -#ifndef LEGACY_ACTIVATION_SHIM_LOAD_LIBRARY -#define LEGACY_ACTIVATION_SHIM_LOAD_LIBRARY ::LoadLibrary -#endif - -// _T macro alternative to make strings ASCII/UNICODE -#undef _TEXT_ENCODE -#ifdef UNICODE -#define _TEXT_ENCODE(str) L ## str -#else //!UNICODE -#define _TEXT_ENCODE(str) str -#endif //!UNICODE - -// countof ... number of items in an array -#ifndef countof -#define countof(x) (sizeof(x) / sizeof(x[0])) -#endif countof - -#ifndef UNUSED -#define UNUSED(var) ((void)(var)) -#endif //UNUSED - -#ifndef __LEGACYACTIVATIONSHIM_H__ - #error Error: Include LegacyActivationShim.h or LegacyActivationShimDelayLoad.h instead of directly including LegacyActivationShimUtil.h -#endif // __LEGACYACTIVATIONSHIM_H__ - -// ---PLACEMENT NEW-------------------------------------------------------------------------------- -#ifndef __PLACEMENT_NEW_INLINE -#define __PLACEMENT_NEW_INLINE -// Inline placement new -inline void* operator new(size_t, void *_Where) -{ // construct array with placement at _Where - return (_Where); -} - -// delete if placement new fails -inline void operator delete(void *, void *) -{ -} -#endif __PLACEMENT_NEW_INLINE - -// ---LEGACYACTIVATON NAMESPACE-------------------------------------------------------------------- -namespace LegacyActivationShim -{ - // ---UTIL NAMESPACE--------------------------------------------------------------------------- - namespace Util - { - // ---INTERLOCKEDCOMPAREEXCHANGEPOINTERT--------------------------------------------------- - // Variation on InterlockedCompareExchangePointer that adds some type safety. - // Added 'T' to end of name because an identical name to the original function - // confuses GCC - template - inline - T InterlockedCompareExchangePointerT( - T volatile* destination, - T exchange, - T comparand) - { -#ifdef __UtilCode_h__ - // Utilcode has redefined InterlockedCompareExchangePointer - return ::InterlockedCompareExchangeT(destination, exchange, comparand); -#else // __UtilCode_h__ - return reinterpret_cast(InterlockedCompareExchangePointer( - (PVOID volatile *)(destination), - (PVOID)(exchange), - (PVOID)(comparand))); -#endif // __UtilCode_h__ else - } - - // ---PlacementNewDeleteHelper------------------------------------------------------------- - template - class PlacementNewDeleteHelper; - - template - class PlacementNewDeleteHelper - { - public: - // Some environments #define New and Delete, so name these functions - // Construct and Destruct to keep them unique. - static void Construct(TYPE const & value, void *pvWhere) - { new (pvWhere) TYPE(value); } - - static void Destruct(TYPE & value) - { value.~TYPE(); } - }; - - template - class PlacementNewDeleteHelper - { - public: - static void Construct(TYPE const & value, void *pvWhere) - { *reinterpret_cast(pvWhere) = value; } - - static void Destruct(TYPE &) - { } - }; - - // ---HOLDERBASE--------------------------------------------------------------------------- - template - class HolderBase - { - public: - // Relies on implicit default constructor, which permits zero-init static - // object declaration. Do not define one. - // HolderBase() {} - - protected: - char m_value[sizeof(TYPE)]; - - inline - TYPE & GetRef() - { return *reinterpret_cast(&m_value[0]); } - - inline - TYPE & GetPtr() - { return reinterpret_cast(&m_value[0]); } - - inline - void Construct(TYPE const & value) - { PlacementNewDeleteHelper::Construct(value, (void *)&m_value[0]); } - - inline - void Destruct() - { PlacementNewDeleteHelper::Destruct(GetRef()); } - }; - - // ---HOLDER------------------------------------------------------------------------------- - template - class Holder : public HolderBase - { - protected: - bool m_assigned; - bool m_suppressed; - - public: - inline - Holder() : m_assigned(false), m_suppressed(false) - {} - - inline - Holder(TYPE const & value) : m_assigned(false), m_suppressed(false) - { Assign(value); } - - inline - ~Holder() - { Release(); } - - inline - void Assign(TYPE const & value) - { - Release(); - Construct(value); - m_assigned = true; - (*ASSIGNF)(GetValue()); - } - - inline - void Release() - { - if (m_assigned) - { - if (!m_suppressed) - { - (*RELEASEF)(GetValue()); - } - m_assigned = false; - m_suppressed = false; - Destruct(); - } - } - - inline - void SuppressRelease() - { - m_suppressed = m_assigned; - } - - inline - TYPE & GetValue() - { - // _ASSERTE(m_assigned); - return GetRef(); - } - - inline - bool IsAssigned() - { return m_assigned; } - }; - - // ---ZEROINITGLOBALHOLDER----------------------------------------------------------------- - // This class should ONLY be used for global (file scope) variables. It relies on zero - // initialized data in the image. This will fail miserably for other scenarios, as the - // memory used for the object may not be zero-initialized, which will result in incorrect - // behaviour. - template - class ZeroInitGlobalHolder : public HolderBase - { - protected: - bool m_assigned; - - public: - // Relies on implicit default constructor, which permits zero-init static - // field declaration. Do not define an explicit constructor. - // ZeroInitGlobalHolder() {} - - inline - ~ZeroInitGlobalHolder() - { Release(); } - - inline - void Assign(TYPE const & value) - { - Release(); - Construct(value); - m_assigned = true; - (*ASSIGNF)(GetValue()); - } - - inline - void Release() - { - if (m_assigned) - { - (*RELEASEF)(GetValue()); - m_assigned = false; - Destruct(); - } - } - - inline - TYPE & GetValue() - { - // _ASSERTE(m_assigned); - return GetRef(); - } - - inline - bool IsAssigned() - { return m_assigned; } - - inline - void ClearUnsafe() - { m_assigned = false; } - }; - - // ---DONOTHINGHELPER---------------------------------------------------------------------- - template - inline - void DoNothingHelper(TYPE & value) - { UNUSED(value); } - - // ---RELEASEHELPER------------------------------------------------------------------------ - template - inline - void ReleaseHelper(TYPE & value) - { value->Release(); } - - // ---RELEASEHOLDER------------------------------------------------------------------------ - template - class ReleaseHolder - : public Holder< TYPE, &DoNothingHelper, &ReleaseHelper > - { - public: - inline - ReleaseHolder(TYPE & value) - : Holder< TYPE, &DoNothingHelper, &ReleaseHelper >(value) - {} - - ReleaseHolder() - : Holder< TYPE, &DoNothingHelper, &ReleaseHelper >() - {} - }; - - // ---ZEROINITGLOBALRELEASEHOLDER---------------------------------------------------------- - template - class ZeroInitGlobalReleaseHolder - : public ZeroInitGlobalHolder< TYPE, &DoNothingHelper, &ReleaseHelper > - { - }; - - // ---FREELIBRARYHELPER-------------------------------------------------------------------- - inline - void FreeLibraryHelper(HMODULE & hMod) - { - FreeLibrary(hMod); - } - - // ---HMODULEHOLDER------------------------------------------------------------------------ - class HMODULEHolder - : public Holder< HMODULE, &DoNothingHelper, &FreeLibraryHelper > - { - public: - inline - HMODULEHolder(HMODULE value) - : Holder< HMODULE, &DoNothingHelper, &FreeLibraryHelper >(value) - {} - - HMODULEHolder() - : Holder< HMODULE, &DoNothingHelper, &FreeLibraryHelper >() - {} - }; - - // ---ZEROINITHMODULEHOLDER---------------------------------------------------------------- - class ZeroInitGlobalHMODULEHolder - : public ZeroInitGlobalHolder< HMODULE, &DoNothingHelper, &FreeLibraryHelper > - { - }; - - // ---DELAYLOADFUNCTOR--------------------------------------------------------------------- - // T must be a function typedef. - // For example, "typedef int X(short i); DelayLoadFunctor pfnX;" - template - class DelayLoadFunctor - { - private: - HMODULEHolder m_hModHolder; - T * m_proc; - - public: - HRESULT Init(LPCTSTR wzDllName, LPCSTR szProcName) - { - // Load module - HMODULE hMod = LEGACY_ACTIVATION_SHIM_LOAD_LIBRARY(wzDllName); - if (hMod == NULL) - return HRESULT_FROM_WIN32(::GetLastError()); - HMODULEHolder hModHolder(hMod); - - // Load proc address - T * proc = reinterpret_cast(::GetProcAddress(hMod, szProcName)); - if (proc == NULL) - return HRESULT_FROM_WIN32(::GetLastError()); - - // Store results - hModHolder.SuppressRelease(); - m_hModHolder.Assign(hMod); - m_proc = proc; - - return S_OK; - } - - HRESULT Init(HMODULE hMod, LPCSTR szProcName) - { - // Load proc address - T * proc = reinterpret_cast(::GetProcAddress(hMod, szProcName)); - if (proc == NULL) - return HRESULT_FROM_WIN32(::GetLastError()); - - // Store result - m_proc = proc; - - // Success - return S_OK; - } - - T& operator()() - { - return *m_proc; - } - }; - - // ---ZEROINITGLOBALSPINLOCK---------------------------------------------------------------- - class ZeroInitGlobalSpinLock - { - private: - enum LOCK_STATE - { - UNLOCKED = 0, - LOCKED = 1 - }; - - LONG volatile m_lock; - - static inline void Lock(ZeroInitGlobalSpinLock*& lock) - { - while (InterlockedExchange(&lock->m_lock, LOCKED) == LOCKED) - { - ::SwitchToThread(); - } - } - - static inline void Unlock(ZeroInitGlobalSpinLock*& lock) - { InterlockedExchange(&lock->m_lock, UNLOCKED); } - - public: - typedef LegacyActivationShim::Util::Holder - Holder; - }; - - // ---MSCOREEDATA-------------------------------------------------------------------------- - SELECTANY HMODULE g_hModMscoree = NULL; - SELECTANY ZeroInitGlobalHMODULEHolder g_hModMscoreeHolder; - - // ---GETMSCOREE--------------------------------------------------------------------------- - inline - HRESULT GetMSCOREE(HMODULE *pMscoree) - { - if (g_hModMscoree == NULL) - { - HMODULE hModMscoree = LEGACY_ACTIVATION_SHIM_LOAD_LIBRARY(_TEXT_ENCODE("mscoree.dll")); - if (hModMscoree == NULL) - return HRESULT_FROM_WIN32(GetLastError()); - HMODULEHolder hModMscoreeHolder(hModMscoree); - - if (LegacyActivationShim::Util::InterlockedCompareExchangePointerT( - &g_hModMscoree, hModMscoree, NULL) == NULL) - { - g_hModMscoreeHolder.ClearUnsafe(); - g_hModMscoreeHolder.Assign(g_hModMscoree); - hModMscoreeHolder.SuppressRelease(); - } - } - - *pMscoree = g_hModMscoree; - return S_OK; - } - - // ---MSCOREEFUNCTOR----------------------------------------------------------------------- - template - class MscoreeFunctor : public DelayLoadFunctor - { - public: - HRESULT Init(LPCSTR szProcName) - { - HRESULT hr = S_OK; - HMODULE hModMscoree = NULL; - IfHrFailRet(GetMSCOREE(&hModMscoree)); - - return DelayLoadFunctor::Init(hModMscoree, szProcName); - } - }; - - // ---CALLCLRCREATEINSTANCE------------------------------------------------------------------ - inline - HRESULT CallCLRCreateInstance( - REFCLSID clsid, - REFIID riid, - LPVOID *ppInterface) - { - HRESULT hr = S_OK; - HMODULE hMscoree = NULL; - IfHrFailRet(GetMSCOREE(&hMscoree)); - - typedef HRESULT (__stdcall *CLRCreateInstance_pfn) ( - REFCLSID clsid, - REFIID riid, - LPVOID *ppInterface); - - CLRCreateInstance_pfn pfnCLRCreateInstance = - reinterpret_cast(GetProcAddress(hMscoree, "CLRCreateInstance")); - - if (pfnCLRCreateInstance == NULL) - return HRESULT_FROM_WIN32(GetLastError()); - - return (*pfnCLRCreateInstance)( - clsid, - riid, - ppInterface); - } - - // ---CLRMETAHOST INTERFACE DATA----------------------------------------------------------- - SELECTANY ICLRMetaHost* g_pCLRMetaHost = NULL; - SELECTANY ZeroInitGlobalReleaseHolder g_hCLRMetaHost; - - // ---GETCLRMETAHOST----------------------------------------------------------------------- - // NOTE: Does not AddRef returned interface pointer. - inline - HRESULT GetCLRMetaHost( - /*out*/ ICLRMetaHost **ppCLRMetaHost) - { - HRESULT hr = S_OK; - - if (g_pCLRMetaHost == NULL) - { - ICLRMetaHost *pMetaHost = NULL; - IfHrFailRet(CallCLRCreateInstance(CLSID_CLRMetaHost, - IID_ICLRMetaHost, - reinterpret_cast(&pMetaHost))); - ReleaseHolder hMetaHost(pMetaHost); - - // - // Great - we got an ICLRMetaHost. Now publish this to - // g_pCLRMetaHost in a thread-safe way. - // - - if (LegacyActivationShim::Util::InterlockedCompareExchangePointerT( - &g_pCLRMetaHost, pMetaHost, NULL) == NULL) - { - // Successful publish. In this case, we also assign to the - // holder to ensure that the interface is released when the - // image is unloaded. - g_hCLRMetaHost.ClearUnsafe(); - g_hCLRMetaHost.Assign(g_pCLRMetaHost); - hMetaHost.SuppressRelease(); // Keep it AddRef'ed for the g_hCLRMetaHost - } - } - - *ppCLRMetaHost = g_pCLRMetaHost; - - return hr; - } - - // ---HasNewActivationAPIs----------------------------------------------------------------- - SELECTANY ULONG g_fHasNewActivationAPIs = ULONG(-1); - - inline - bool HasNewActivationAPIs() - { - if (g_fHasNewActivationAPIs == ULONG(-1)) - { - ICLRMetaHost *pMetaHost = NULL; - HRESULT hr = GetCLRMetaHost(&pMetaHost); - InterlockedCompareExchange((LONG volatile *)&g_fHasNewActivationAPIs, (LONG)(SUCCEEDED(hr)), ULONG(-1)); - } - - return g_fHasNewActivationAPIs != 0; - } - - // ---CLRMETAHOSTPOLICY INTERFACE DATA----------------------------------------------------- - SELECTANY ICLRMetaHostPolicy* g_pCLRMetaHostPolicy = NULL; - SELECTANY ZeroInitGlobalReleaseHolder g_hCLRMetaHostPolicy; - - // ---GETCLRMETAHOSTPOLICY----------------------------------------------------------------- - // NOTE: Does not AddRef returned interface pointer. - inline - HRESULT GetCLRMetaHostPolicy( - /*out*/ ICLRMetaHostPolicy **ppICLRMetaHostPolicy) - { - HRESULT hr = S_OK; - - if (g_pCLRMetaHostPolicy == NULL) - { - ICLRMetaHostPolicy *pMetaHostPolicy = NULL; - IfHrFailRet(CallCLRCreateInstance(CLSID_CLRMetaHostPolicy, - IID_ICLRMetaHostPolicy, - reinterpret_cast(&pMetaHostPolicy))); - ReleaseHolder hMetaHostPolicy(pMetaHostPolicy); - - // - // Great - we got an ICLRMetaHostPolicy. Now publish this to - // g_pCLRMetaHostPolicy in a thread-safe way. - // - - if (LegacyActivationShim::Util::InterlockedCompareExchangePointerT( - &g_pCLRMetaHostPolicy, pMetaHostPolicy, NULL) == NULL) - { - // Successful publish. In this case, we also assign to the - // holder to ensure that the interface is released when the - // image is unloaded. - g_hCLRMetaHostPolicy.ClearUnsafe(); - g_hCLRMetaHostPolicy.Assign(g_pCLRMetaHostPolicy); - hMetaHostPolicy.SuppressRelease(); - } - } - - *ppICLRMetaHostPolicy = g_pCLRMetaHostPolicy; - - return hr; - } - - // ---RUNTIMEINFO DATA--------------------------------------------------------------------- - struct RuntimeInfo - { - ICLRRuntimeInfo *m_pRuntimeInfo; - - DWORD m_cchImageVersion; - WCHAR m_wszImageVersion[512]; - - inline - void Init() - { - m_pRuntimeInfo = NULL; - m_cchImageVersion = countof(m_wszImageVersion); - m_wszImageVersion[0] = L'\0'; - } - - inline - void Release() - { - if (m_pRuntimeInfo != NULL) - { - m_pRuntimeInfo->Release(); - m_pRuntimeInfo = NULL; - } - } - }; - - SELECTANY LONG g_runtimeInfoIsInitialized = FALSE; - SELECTANY RuntimeInfo g_runtimeInfo; - SELECTANY ZeroInitGlobalSpinLock g_runtimeInfoLock; - SELECTANY ZeroInitGlobalReleaseHolder g_hRuntimeInfo; - - // ---GETCLRRUNTIMEINFOHELPER-------------------------------------------------------------- - // Logic: - // 1. Try to bind using ICLRMetaHostPolicy::GetRequestedRuntime and incoming arguments. - // 2. Try to bind using ICLRMetaHostPolicy::GetRequestedRuntime and "v4.0.0" and - // upgrade policy. - // 3. Try to bind to latest using GetRequestedRuntimeInfo. - - inline - HRESULT GetCLRRuntimeInfoHelper( - /*out*/ ICLRRuntimeInfo **ppCLRRuntimeInfo, - LPCWSTR pEXE = NULL, - IStream *pIStream = NULL, - __inout_ecount_opt(*pcchVersion) LPWSTR wszVersion = NULL, - DWORD *pcchVersion = NULL, - __out_ecount_opt(*pcchImageVersion) LPWSTR wszImageVersion = NULL, - DWORD *pcchImageVersion = NULL) - { - HRESULT hr = S_OK; - - // - // 1. Try policy-based binding first, which will incorporate config files and such. - // - - ICLRMetaHostPolicy *pMetaHostPolicy = NULL; - IfHrFailRet(GetCLRMetaHostPolicy(&pMetaHostPolicy)); - - DWORD dwConfigFlags = 0; - - hr = pMetaHostPolicy->GetRequestedRuntime( - METAHOST_POLICY_USE_PROCESS_IMAGE_PATH, - pEXE, - pIStream, - wszVersion, - pcchVersion, - wszImageVersion, - pcchImageVersion, - &dwConfigFlags, - IID_ICLRRuntimeInfo, - reinterpret_cast(ppCLRRuntimeInfo)); - - if (hr != S_OK && - pEXE == NULL && - pIStream == NULL && - wszVersion == NULL) - { // - // 2. Try to bind using ICLRMetaHostPolicy::GetRequestedRuntime and "v4.0.0" and upgrade policy. - // - - WCHAR _wszVersion[256]; // We can't use new in this header, so just pick an obscenely long version string length of 256 - DWORD _cchVersion = countof(_wszVersion); - wcscpy_s(_wszVersion, _cchVersion, L"v4.0.0"); - hr = pMetaHostPolicy->GetRequestedRuntime( - static_cast(METAHOST_POLICY_USE_PROCESS_IMAGE_PATH | - METAHOST_POLICY_APPLY_UPGRADE_POLICY), - pEXE, - pIStream, // (is NULL) - _wszVersion, - &_cchVersion, - wszImageVersion, - pcchImageVersion, - &dwConfigFlags, - IID_ICLRRuntimeInfo, - reinterpret_cast(ppCLRRuntimeInfo)); - } - - if (hr != S_OK && - pEXE == NULL && - pIStream == NULL && - wszVersion == NULL) - { // - // 3. Try to bind using GetRequestedRuntimeInfo(NULL) - // - - typedef HRESULT __stdcall GetRequestedRuntimeInfo_t( - LPCWSTR pExe, - LPCWSTR pwszVersion, - LPCWSTR pConfigurationFile, - DWORD startupFlags, - DWORD runtimeInfoFlags, - LPWSTR pDirectory, - DWORD dwDirectory, - DWORD *dwDirectoryLength, - LPWSTR pVersion, - DWORD cchBuffer, - DWORD* dwlength); - - HMODULE hMscoree = NULL; - IfHrFailRet(GetMSCOREE(&hMscoree)); - - // We're using GetRequestedRuntimeInfo here because it is the only remaining API - // that will not be Whidbey-capped and will allow "bind to latest" semantics. This - // is cheating a bit, but should work for now. The alternative is to use - // ICLRMetaHost::EnumerateRuntimes to achieve the same result. - DelayLoadFunctor GetRequestedRuntimeInfoFN; - IfHrFailRet(GetRequestedRuntimeInfoFN.Init(hMscoree, "GetRequestedRuntimeInfo")); - - WCHAR szDir_[_MAX_PATH]; - DWORD cchDir_ = countof(szDir_); - WCHAR szVersion_[_MAX_PATH]; - DWORD cchVersion_ = countof(szVersion_); - DWORD dwInfoFlags_ = RUNTIME_INFO_UPGRADE_VERSION - | RUNTIME_INFO_DONT_SHOW_ERROR_DIALOG; - - IfHrFailRet(GetRequestedRuntimeInfoFN()( - NULL, - NULL, - NULL, - 0, - dwInfoFlags_, - szDir_, - cchDir_, - &cchDir_, - szVersion_, - cchVersion_, - &cchVersion_)); - - // Unable to get a version to try to load. - if (hr != S_OK) - { - return CLR_E_SHIM_RUNTIMELOAD; - } - - ICLRMetaHost *pMetaHost = NULL; - IfHrFailRet(GetCLRMetaHost(&pMetaHost)); - - hr = pMetaHost->GetRuntime(szVersion_, - IID_ICLRRuntimeInfo, - reinterpret_cast(ppCLRRuntimeInfo)); - - if (hr != S_OK) - { - return CLR_E_SHIM_RUNTIMELOAD; - } - - if (wszImageVersion != NULL) - { - wcsncpy_s(wszImageVersion, *pcchImageVersion, szVersion_, cchVersion_); - *pcchImageVersion = cchVersion_; - } - } - - if (hr == S_OK && - (dwConfigFlags & METAHOST_CONFIG_FLAGS_LEGACY_V2_ACTIVATION_POLICY_MASK) == - METAHOST_CONFIG_FLAGS_LEGACY_V2_ACTIVATION_POLICY_TRUE) - { // If the config requested that the runtime be bound as the legacy runtime. - IfHrFailRet((*ppCLRRuntimeInfo)->BindAsLegacyV2Runtime()); - } - - return hr; - } - - // ---GETRUNTIMEINFO----------------------------------------------------------------------- - inline - HRESULT GetRuntimeInfo( - /*out*/ RuntimeInfo **ppRuntimeInfo, - LPCWSTR pEXE = NULL, - IStream *pIStream = NULL, - __inout_ecount_opt(*pcchVersion) LPWSTR wszVersion = NULL, - DWORD *pcchVersion = NULL) - { - HRESULT hr = S_OK; - - if (!g_runtimeInfoIsInitialized) - { - ZeroInitGlobalSpinLock::Holder lock(&g_runtimeInfoLock); - if (!g_runtimeInfoIsInitialized) - { - g_runtimeInfo.Init(); - - IfHrFailRet(GetCLRRuntimeInfoHelper( - &g_runtimeInfo.m_pRuntimeInfo, - pEXE, - pIStream, - wszVersion, - pcchVersion, - g_runtimeInfo.m_wszImageVersion, - &g_runtimeInfo.m_cchImageVersion)); - - // - // Initialized - now publish. - // - - g_hRuntimeInfo.ClearUnsafe(); - g_hRuntimeInfo.Assign(&g_runtimeInfo); - InterlockedExchange(&g_runtimeInfoIsInitialized, TRUE); - } - } - - // - // Return the struct - // - - *ppRuntimeInfo = &g_runtimeInfo; - return hr; - } - - // --------BINDTOV4------------------------------------------------------------------------ - // Used by hosted DLLs that require the use of v4 for all their - // LegacyActivationShim calls. Can (and should) be called from DllMain, - // provided the DLL has a static (non-delayload) dependency on mscoree.dll. - inline - HRESULT BindToV4() - { - HRESULT hr = E_FAIL; - - if (!g_runtimeInfoIsInitialized) - { - ZeroInitGlobalSpinLock::Holder lock(&g_runtimeInfoLock); - if (!g_runtimeInfoIsInitialized) - { - ICLRMetaHostPolicy *pMetaHostPolicy = NULL; - IfHrFailRet(GetCLRMetaHostPolicy(&pMetaHostPolicy)); - - g_runtimeInfo.Init(); - - // - // Try to bind using ICLRMetaHostPolicy::GetRequestedRuntime and "v4.0.0" and upgrade policy. - // - - WCHAR _wszVersion[256]; // We can't use new in this header, so just pick an obscenely long version string length of 256 - DWORD _cchVersion = countof(_wszVersion); - wcscpy_s(_wszVersion, _cchVersion, L"v4.0.0"); - - IfHrFailRet(pMetaHostPolicy->GetRequestedRuntime( - METAHOST_POLICY_APPLY_UPGRADE_POLICY, - NULL, // image path - NULL, // config stream - _wszVersion, - &_cchVersion, - g_runtimeInfo.m_wszImageVersion, - &g_runtimeInfo.m_cchImageVersion, - NULL, // config flags - IID_ICLRRuntimeInfo, - reinterpret_cast(&g_runtimeInfo.m_pRuntimeInfo))); - - // - // Initialized - now publish. - // - - g_hRuntimeInfo.ClearUnsafe(); - g_hRuntimeInfo.Assign(&g_runtimeInfo); - InterlockedExchange(&g_runtimeInfoIsInitialized, TRUE); - - hr = S_OK; - } - } - - return hr; - } - - // ---GETCLRRUNTIMEINFO-------------------------------------------------------------------- - inline - HRESULT GetCLRRuntimeInfo( - /*out*/ ICLRRuntimeInfo **ppCLRRuntimeInfo, - LPCWSTR pEXE = NULL, - IStream *pIStream = NULL, - __inout_ecount_opt(*pcchVersion) LPWSTR wszVersion = NULL, - DWORD *pcchVersion = NULL) - { - HRESULT hr = S_OK; - - RuntimeInfo *pRuntimeInfo = NULL; - IfHrFailRet(GetRuntimeInfo(&pRuntimeInfo, pEXE, pIStream, wszVersion, pcchVersion)); - - *ppCLRRuntimeInfo = pRuntimeInfo->m_pRuntimeInfo; - return hr; - } - - // ---GetConfigImageVersion---------------------------------------------------------------- - inline - HRESULT GetConfigImageVersion( - __out_ecount(*pcchBuffer) LPWSTR wzBuffer, - DWORD *pcchBuffer) - { - HRESULT hr = S_OK; - - RuntimeInfo *pRuntimeInfo = NULL; - IfHrFailRet(GetRuntimeInfo(&pRuntimeInfo)); - - DWORD cchBuffer = *pcchBuffer; - *pcchBuffer = pRuntimeInfo->m_cchImageVersion; - - if (cchBuffer <= pRuntimeInfo->m_cchImageVersion) - { - wcsncpy_s( - wzBuffer, - cchBuffer, - pRuntimeInfo->m_wszImageVersion, - pRuntimeInfo->m_cchImageVersion); - } - else - { - IfHrFailRet(HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER)); - } - - return hr; - } - - // ---ICLRSTRONGNAME INTERFACE DATA-------------------------------------------------------- - SELECTANY ICLRStrongName* g_pCLRStrongName = NULL; - SELECTANY ZeroInitGlobalReleaseHolder g_hCLRStrongName; - - // ---GETCLRSTRONGNAME--------------------------------------------------------------------- - // NOTE: Does not AddRef returned interface pointer. - inline - HRESULT GetCLRStrongName( - /*out*/ ICLRStrongName **ppCLRStrongName) - { - HRESULT hr = S_OK; - - if (g_pCLRStrongName == NULL) - { - ICLRRuntimeInfo *pInfo = NULL; - IfHrFailRet(GetCLRRuntimeInfo(&pInfo)); - - ICLRStrongName *pStrongName; - - IfHrFailRet(pInfo->GetInterface( - CLSID_CLRStrongName, - IID_ICLRStrongName, - reinterpret_cast(&pStrongName))); - - // - // Great - we got an ICLRStrongName. Now publish this to - // g_pCLRStrongName in a thread-safe way. - // - - if (LegacyActivationShim::Util::InterlockedCompareExchangePointerT( - &g_pCLRStrongName, pStrongName, NULL) == NULL) - { - // Successful publish. In this case, we also assign to the - // holder to ensure that the interface is released when the - // image is unloaded. - g_hCLRStrongName.ClearUnsafe(); - g_hCLRStrongName.Assign(g_pCLRStrongName); - } - else - { - // We were beat to the punch, don't publish this interface - // and make sure we use the published value for consistency. - pStrongName->Release(); - } - } - - *ppCLRStrongName = g_pCLRStrongName; - return hr; - } - - // ---ICLRSTRONGNAME2 INTERFACE DATA-------------------------------------------------------- - SELECTANY ICLRStrongName2* g_pCLRStrongName2 = NULL; - SELECTANY ZeroInitGlobalReleaseHolder g_hCLRStrongName2; - - // ---GETCLRSTRONGNAME2--------------------------------------------------------------------- - // NOTE: Does not AddRef returned interface pointer. - inline - HRESULT GetCLRStrongName2( - /*out*/ ICLRStrongName2 **ppCLRStrongName2) - { - HRESULT hr = S_OK; - - if (g_pCLRStrongName2 == NULL) - { - ICLRRuntimeInfo *pInfo = NULL; - IfHrFailRet(GetCLRRuntimeInfo(&pInfo)); - - ICLRStrongName2 *pStrongName; - - IfHrFailRet(pInfo->GetInterface( - CLSID_CLRStrongName, - IID_ICLRStrongName2, - reinterpret_cast(&pStrongName))); - - // - // Great - we got an ICLRStrongName2. Now publish this to - // g_pCLRStrongName2 in a thread-safe way. - // - - if (LegacyActivationShim::Util::InterlockedCompareExchangePointerT( - &g_pCLRStrongName2, pStrongName, NULL) == NULL) - { - // Successful publish. In this case, we also assign to the - // holder to ensure that the interface is released when the - // image is unloaded. - g_hCLRStrongName2.ClearUnsafe(); - g_hCLRStrongName2.Assign(g_pCLRStrongName2); - } - else - { - // We were beat to the punch, don't publish this interface - // and make sure we use the published value for consistency. - pStrongName->Release(); - } - } - - *ppCLRStrongName2 = g_pCLRStrongName2; - return hr; - } - - // ---AddStartupFlags------------------------------------------------------------------------------ - inline - HRESULT AddStartupFlags( - ICLRRuntimeInfo *pInfo, - LPCWSTR wszBuildFlavor, - DWORD dwStartupFlags, - LPCWSTR wszHostConfigFile) - { - if (wszBuildFlavor != NULL && - (wszBuildFlavor[0] == L's' || wszBuildFlavor[0] == L'S') && - (wszBuildFlavor[1] == L'v' || wszBuildFlavor[1] == L'V') && - (wszBuildFlavor[2] == L'r' || wszBuildFlavor[2] == L'R') && - wszBuildFlavor[3] == 0) - { - dwStartupFlags |= STARTUP_SERVER_GC; - } - - HRESULT hr = S_OK; - - DWORD dwEffectiveStartupFlags = 0; - IfHrFailRet(pInfo->GetDefaultStartupFlags(&dwEffectiveStartupFlags, NULL, NULL)); - - // Startup flags at this point are either default (i.e. STARTUP_CONCURRENT_GC) - // or have been set based on a config file. We want to clear the concurrent - // GC flag because we are supplying non-defaults, and combine them with the - // user supplied flags. Note that STARTUP_CONCURRENT_GC is never set as part - // of reading a config so we are not losing any information here. - - dwEffectiveStartupFlags &= ~STARTUP_CONCURRENT_GC; - dwEffectiveStartupFlags |= dwStartupFlags; - - return pInfo->SetDefaultStartupFlags(dwEffectiveStartupFlags, wszHostConfigFile); - } - - // ------------------------------------------------------------------------------------------------ - SELECTANY HMODULE g_hShlwapi = NULL; - SELECTANY ZeroInitGlobalHMODULEHolder g_hShlwapiHolder; - - // ------------------------------------------------------------------------------------------------ - inline - HRESULT CreateIStreamFromFile( - LPCWSTR wszFilePath, - IStream **ppIStream) - { - HRESULT hr = S_OK; - *ppIStream = NULL; - - if (g_hShlwapi == NULL) - { - HMODULE hShlwapi = LEGACY_ACTIVATION_SHIM_LOAD_LIBRARY(_TEXT_ENCODE("shlwapi.dll")); - if (hShlwapi == NULL) - return HRESULT_FROM_WIN32(GetLastError()); - HMODULEHolder hShlwapiHolder(hShlwapi); - - if (LegacyActivationShim::Util::InterlockedCompareExchangePointerT( - &g_hShlwapi, hShlwapi, NULL) == NULL) - { - g_hShlwapiHolder.ClearUnsafe(); - g_hShlwapiHolder.Assign(hShlwapi); - hShlwapiHolder.SuppressRelease(); - } - } - - typedef HRESULT (__stdcall * SHCreateStreamOnFile_pfn)( - LPCWSTR wszFile, - DWORD grfMode, - IStream **ppstm); - - SHCreateStreamOnFile_pfn pCreateStreamOnFile = - reinterpret_cast(GetProcAddress(g_hShlwapi, "SHCreateStreamOnFileW")); - - if (pCreateStreamOnFile == NULL) - return HRESULT_FROM_WIN32(GetLastError()); - - //_ASSERTE(pCreateStreamOnFile != NULL); - - // Create IStream - IStream* pStream(NULL); - IfHrFailRet((*pCreateStreamOnFile)(wszFilePath, 0 /*STGM_READ*/, &pStream)); - ReleaseHolder hStream(pStream); - - // Success, prevent release and assign IStream to out parameter - *ppIStream = pStream; - hStream.SuppressRelease(); - - return S_OK; - } - }; // namespace Util -}; // namespace LegacyActivationShim - -#pragma pop_macro("UNUSED") -#pragma pop_macro("countof") -#pragma pop_macro("_TEXT_ENCODE") -#pragma pop_macro("SELECTANY") - -#endif // __LEGACYACTIVATIONSHIMUTIL_H__ - diff --git a/src/inc/loaderheap.h b/src/inc/loaderheap.h deleted file mode 100644 index a2dec9cc2..000000000 --- a/src/inc/loaderheap.h +++ /dev/null @@ -1,1081 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -//***************************************************************************** -// LoaderHeap.h -// - -// -// Utility functions for managing memory allocations that typically do not -// need releasing. -// -//***************************************************************************** - - -#ifndef __LoaderHeap_h__ -#define __LoaderHeap_h__ - -#include "utilcode.h" -#include "ex.h" - -//============================================================================== -// Interface used to back out loader heap allocations. -//============================================================================== -class ILoaderHeapBackout -{ -#ifdef _DEBUG -#define BackoutMem(pMem, dwSize) RealBackoutMem( (pMem), (dwSize), __FILE__, __LINE__, "UNKNOWN", -1 ) -#else -#define BackoutMem(pMem, dwSize) RealBackoutMem( (pMem), (dwSize) ) -#endif - -public: - virtual void RealBackoutMem(void *pMem - , size_t dwSize -#ifdef _DEBUG - , __in __in_z const char *szFile - , int lineNum - , __in __in_z const char *szAllocFile - , int allocLineNum -#endif - ) = 0; -}; - -//============================================================================== -// This structure packages up all the data needed to back out an AllocMem. -// It's mainly a short term parking place to get the data from the AllocMem -// to the AllocMemHolder while preserving the illusion that AllocMem() still -// returns just a pointer as it did in V1. -//============================================================================== -struct TaggedMemAllocPtr -{ - // Note: For AllocAlignedMem blocks, m_pMem and m_dwRequestedSize are the actual values to pass - // to BackoutMem. Do not add "m_dwExtra" - void *m_pMem; //Pointer to AllocMem'd block (needed to pass back to BackoutMem) - size_t m_dwRequestedSize; //Requested allocation size (needed to pass back to BackoutMem) - - ILoaderHeapBackout *m_pHeap; //The heap that alloc'd the block (needed to know who to call BackoutMem on) - - //For AllocMem'd blocks, this is always 0. - //For AllocAlignedMem blocks, you have to add m_dwExtra to m_pMem to arrive - // at the actual aligned pointer. - size_t m_dwExtra; - -#ifdef _DEBUG - const char *m_szFile; //File that called AllocMem - int m_lineNum; //Line # of AllocMem callsite -#endif - -//! Note: this structure is copied around using bitwise copy ("="). -//! Don't get too fancy putting stuff in here. It's really just a temporary -//! holding place to get stuff from RealAllocMem() to the MemAllocHolder. - - - public: - - // - // This makes "void *ptr = pLoaderHeap->AllocMem()" work as in V1. - // - operator void*() const - { - LIMITED_METHOD_CONTRACT; - return (void*)(m_dwExtra + (BYTE*)m_pMem); - } - - template < typename T > - T cast() const - { - LIMITED_METHOD_CONTRACT; - return reinterpret_cast< T >( operator void *() ); - } -}; - - - -// # bytes to leave between allocations in debug mode -// Set to a > 0 boundary to debug problems - I've made this zero, otherwise a 1 byte allocation becomes -// a (1 + LOADER_HEAP_DEBUG_BOUNDARY) allocation -#define LOADER_HEAP_DEBUG_BOUNDARY 0 - -#define VIRTUAL_ALLOC_RESERVE_GRANULARITY (64*1024) // 0x10000 (64 KB) - -typedef DPTR(struct LoaderHeapBlock) PTR_LoaderHeapBlock; - -struct LoaderHeapBlock -{ - PTR_LoaderHeapBlock pNext; - PTR_VOID pVirtualAddress; - size_t dwVirtualSize; - BOOL m_fReleaseMemory; - -#ifndef DACCESS_COMPILE - // pVirtualMemory - the start address of the virtual memory - // cbVirtualMemory - the length in bytes of the virtual memory - // fReleaseMemory - should LoaderHeap be responsible for releasing this memory - void Init(void *pVirtualMemory, - size_t cbVirtualMemory, - BOOL fReleaseMemory) - { - LIMITED_METHOD_CONTRACT; - this->pNext = NULL; - this->pVirtualAddress = pVirtualMemory; - this->dwVirtualSize = cbVirtualMemory; - this->m_fReleaseMemory = fReleaseMemory; - } - - // Just calls LoaderHeapBlock::Init - LoaderHeapBlock(void *pVirtualMemory, - size_t cbVirtualMemory, - BOOL fReleaseMemory) - { - WRAPPER_NO_CONTRACT; - Init(pVirtualMemory, cbVirtualMemory, fReleaseMemory); - } - - LoaderHeapBlock() - { - WRAPPER_NO_CONTRACT; - Init(NULL, 0, FALSE); - } -#else - // No ctors in DAC builds - LoaderHeapBlock() {} -#endif -}; - -struct LoaderHeapFreeBlock; - -// Collection of methods for helping in debugging heap corruptions -#ifdef _DEBUG -class LoaderHeapSniffer; -struct LoaderHeapEvent; -#endif - - - - - - - - -//=============================================================================== -// This is the base class for LoaderHeap and ExplicitControlLoaderHeap. Unfortunately, -// this class has become schizophrenic. Sometimes, it's used as a simple -// allocator that's semantically (but not perfwise!) equivalent to a blackbox -// alloc/free heap. Othertimes, it's used by callers who are actually aware -// of how it reserves addresses and want direct control over the range over which -// this thing allocates. These two types of allocations are handed out -// from two independent pools inside the heap. -// -// The backout strategy we use for the simple heap probably isn't -// directly applicable to the more advanced uses. -// -// We don't have time to refactor this so as a second-best measure, -// we make most of UnlockedLoaderHeap's methods protected and force everyone -// to use it them through two public derived classes that are mutual siblings. -// -// The LoaderHeap is the black-box heap and has a Backout() method but none -// of the advanced features that let you control address ranges. -// -// The ExplicitControlLoaderHeap exposes all the advanced features but -// has no Backout() feature. (If someone wants a backout feature, they need -// to design an appropriate one into this class.) -//=============================================================================== -class UnlockedLoaderHeap -{ -#ifdef _DEBUG - friend class LoaderHeapSniffer; -#endif - -#ifdef DACCESS_COMPILE - friend class ClrDataAccess; -#endif - -private: - // Linked list of ClrVirtualAlloc'd pages - PTR_LoaderHeapBlock m_pFirstBlock; - - // Allocation pointer in current block - PTR_BYTE m_pAllocPtr; - - // Points to the end of the committed region in the current block - PTR_BYTE m_pPtrToEndOfCommittedRegion; - PTR_BYTE m_pEndReservedRegion; - - PTR_LoaderHeapBlock m_pCurBlock; - - // When we need to ClrVirtualAlloc() MEM_RESERVE a new set of pages, number of bytes to reserve - DWORD m_dwReserveBlockSize; - - // When we need to commit pages from our reserved list, number of bytes to commit at a time - DWORD m_dwCommitBlockSize; - - // Range list to record memory ranges in - RangeList * m_pRangeList; - - size_t m_dwTotalAlloc; - - size_t * m_pPrivatePerfCounter_LoaderBytes; - - DWORD m_Options; - - LoaderHeapFreeBlock *m_pFirstFreeBlock; - - // This is used to hold on to a block of reserved memory provided to the - // constructor. We do this instead of adding it as the first block because - // that requires comitting the first page of the reserved block, and for - // startup working set reasons we want to delay that as long as possible. - LoaderHeapBlock m_reservedBlock; - -public: - -#ifdef _DEBUG - enum - { - kCallTracing = 0x00000001, // Keep a permanent log of all callers - - kEncounteredOOM = 0x80000000, // One time flag to record that an OOM interrupted call tracing - } - LoaderHeapDebugFlags; - - DWORD m_dwDebugFlags; - - LoaderHeapEvent *m_pEventList; // Linked list of events (in reverse time order) -#endif - - - -#ifdef _DEBUG - size_t m_dwDebugWastedBytes; - static DWORD s_dwNumInstancesOfLoaderHeaps; -#endif - -#ifdef _DEBUG - size_t DebugGetWastedBytes() - { - WRAPPER_NO_CONTRACT; - return m_dwDebugWastedBytes + GetBytesAvailCommittedRegion(); - } -#endif - -#ifdef _DEBUG - // Stubs allocated from a LoaderHeap will have unwind info registered with NT. - // The info must be unregistered when the heap is destroyed. - BOOL m_fPermitStubsWithUnwindInfo; - BOOL m_fStubUnwindInfoUnregistered; -#endif - -public: - BOOL m_fExplicitControl; // Am I a LoaderHeap or an ExplicitControlLoaderHeap? - -#ifdef DACCESS_COMPILE -public: - void EnumMemoryRegions(enum CLRDataEnumMemoryFlags flags); -#endif - -public: - typedef void EnumPageRegionsCallback (PTR_VOID pvAllocationBase, SIZE_T cbReserved); - void EnumPageRegions (EnumPageRegionsCallback *pCallback); - -#ifndef DACCESS_COMPILE -protected: - // Use this version if dwReservedRegionAddress already points to a - // blob of reserved memory. This will set up internal data structures, - // using the provided, reserved memory. - UnlockedLoaderHeap(DWORD dwReserveBlockSize, - DWORD dwCommitBlockSize, - const BYTE* dwReservedRegionAddress, - SIZE_T dwReservedRegionSize, - size_t *pPrivatePerfCounter_LoaderBytes = NULL, - RangeList *pRangeList = NULL, - BOOL fMakeExecutable = FALSE); - - ~UnlockedLoaderHeap(); -#endif - -private: - size_t GetBytesAvailCommittedRegion(); - size_t GetBytesAvailReservedRegion(); - -protected: - // number of bytes available in region - size_t UnlockedGetReservedBytesFree() - { - LIMITED_METHOD_CONTRACT; - return m_pEndReservedRegion - m_pAllocPtr; - } - -private: - // Get some more committed pages - either commit some more in the current reserved region, or, if it - // has run out, reserve another set of pages - BOOL GetMoreCommittedPages(size_t dwMinSize); - -protected: - // Reserve some pages at any address - BOOL UnlockedReservePages(size_t dwCommitBlockSize); - -protected: - // In debug mode, allocate an extra LOADER_HEAP_DEBUG_BOUNDARY bytes and fill it with invalid data. The reason we - // do this is that when we're allocating vtables out of the heap, it is very easy for code to - // get careless, and end up reading from memory that it doesn't own - but since it will be - // reading some other allocation's vtable, no crash will occur. By keeping a gap between - // allocations, it is more likely that these errors will be encountered. - void *UnlockedAllocMem(size_t dwSize -#ifdef _DEBUG - ,__in __in_z const char *szFile - ,int lineNum -#endif - ); - void *UnlockedAllocMem_NoThrow(size_t dwSize -#ifdef _DEBUG - ,__in __in_z const char *szFile - ,int lineNum -#endif - ); - - - - - -protected: - // Allocates memory aligned on power-of-2 boundary. - // - // The return value is a pointer that's guaranteed to be aligned. - // - // FREEING THIS BLOCK: Underneath, the actual block allocated may - // be larger and start at an address prior to the one you got back. - // It is this adjusted size and pointer that you pass to BackoutMem. - // The required adjustment is passed back thru the pdwExtra pointer. - // - // Here is how to properly backout the memory: - // - // size_t dwExtra; - // void *pMem = UnlockedAllocAlignedMem(dwRequestedSize, alignment, &dwExtra); - // _ASSERTE( 0 == (pMem & (alignment - 1)) ); - // UnlockedBackoutMem( ((BYTE*)pMem) - dExtra, dwRequestedSize + dwExtra ); - // - // If you use the AllocMemHolder or AllocMemTracker, all this is taken care of - // behind the scenes. - // - // - void *UnlockedAllocAlignedMem(size_t dwRequestedSize - ,size_t dwAlignment - ,size_t *pdwExtra -#ifdef _DEBUG - ,__in __in_z const char *szFile - ,int lineNum -#endif - ); - - void *UnlockedAllocAlignedMem_NoThrow(size_t dwRequestedSize - ,size_t dwAlignment - ,size_t *pdwExtra -#ifdef _DEBUG - ,__in __in_z const char *szFile - ,int lineNum -#endif - ); - -protected: - // This frees memory allocated by UnlockAllocMem. It's given this horrible name to emphasize - // that it's purpose is for error path leak prevention purposes. You shouldn't - // use LoaderHeap's as general-purpose alloc-free heaps. - void UnlockedBackoutMem(void *pMem - , size_t dwSize -#ifdef _DEBUG - , __in __in_z const char *szFile - , int lineNum - , __in __in_z const char *szAllocFile - , int AllocLineNum -#endif - ); - -public: - // Perf Counter reports the size of the heap - size_t GetSize () - { - LIMITED_METHOD_CONTRACT; - return m_dwTotalAlloc; - } - - BOOL IsExecutable(); - -public: -#ifdef _DEBUG - void DumpFreeList(); -#endif - -public: -// Extra CallTracing support -#ifdef _DEBUG - void UnlockedClearEvents(); //Discard saved events - void UnlockedCompactEvents(); //Discard matching alloc/free events - void UnlockedPrintEvents(); //Print event list -#endif - -protected: - void *UnlockedAllocMemForCode_NoThrow(size_t dwHeaderSize, size_t dwCodeSize, DWORD dwCodeAlignment, size_t dwReserveForJumpStubs); - - void UnlockedSetReservedRegion(BYTE* dwReservedRegionAddress, SIZE_T dwReservedRegionSize, BOOL fReleaseMemory); -}; - -//=============================================================================== -// Create the LoaderHeap lock. It's the same lock for several different Heaps. -//=============================================================================== -inline CRITSEC_COOKIE CreateLoaderHeapLock() -{ - return ClrCreateCriticalSection(CrstLoaderHeap,CrstFlags(CRST_UNSAFE_ANYMODE | CRST_DEBUGGER_THREAD)); -} - -//=============================================================================== -// The LoaderHeap is the black-box heap and has a Backout() method but none -// of the advanced features that let you control address ranges. -//=============================================================================== -typedef DPTR(class LoaderHeap) PTR_LoaderHeap; -class LoaderHeap : public UnlockedLoaderHeap, public ILoaderHeapBackout -{ -private: - CRITSEC_COOKIE m_CriticalSection; - -#ifndef DACCESS_COMPILE -public: - LoaderHeap(DWORD dwReserveBlockSize, - DWORD dwCommitBlockSize, - size_t *pPrivatePerfCounter_LoaderBytes = NULL, - RangeList *pRangeList = NULL, - BOOL fMakeExecutable = FALSE - ) - : UnlockedLoaderHeap(dwReserveBlockSize, - dwCommitBlockSize, - NULL, 0, - pPrivatePerfCounter_LoaderBytes, - pRangeList, - fMakeExecutable) - { - WRAPPER_NO_CONTRACT; - m_CriticalSection = NULL; - m_CriticalSection = CreateLoaderHeapLock(); - m_fExplicitControl = FALSE; - } - -public: - LoaderHeap(DWORD dwReserveBlockSize, - DWORD dwCommitBlockSize, - const BYTE* dwReservedRegionAddress, - SIZE_T dwReservedRegionSize, - size_t *pPrivatePerfCounter_LoaderBytes = NULL, - RangeList *pRangeList = NULL, - BOOL fMakeExecutable = FALSE - ) - : UnlockedLoaderHeap(dwReserveBlockSize, - dwCommitBlockSize, - dwReservedRegionAddress, - dwReservedRegionSize, - pPrivatePerfCounter_LoaderBytes, - pRangeList, - fMakeExecutable) - { - WRAPPER_NO_CONTRACT; - m_CriticalSection = NULL; - m_CriticalSection = CreateLoaderHeapLock(); - m_fExplicitControl = FALSE; - } - -#endif // DACCESS_COMPILE - - virtual ~LoaderHeap() - { - WRAPPER_NO_CONTRACT; - -#ifndef DACCESS_COMPILE - if (m_CriticalSection != NULL) - { - ClrDeleteCriticalSection(m_CriticalSection); - } -#endif // DACCESS_COMPILE - } - - - -#ifdef _DEBUG -#define AllocMem(dwSize) RealAllocMem( (dwSize), __FILE__, __LINE__ ) -#define AllocMem_NoThrow(dwSize) RealAllocMem_NoThrow( (dwSize), __FILE__, __LINE__ ) -#else -#define AllocMem(dwSize) RealAllocMem( (dwSize) ) -#define AllocMem_NoThrow(dwSize) RealAllocMem_NoThrow( (dwSize) ) -#endif - -public: - FORCEINLINE TaggedMemAllocPtr RealAllocMem(S_SIZE_T dwSize -#ifdef _DEBUG - ,__in __in_z const char *szFile - ,int lineNum -#endif - ) - { - WRAPPER_NO_CONTRACT; - - if(dwSize.IsOverflow()) ThrowOutOfMemory(); - - return RealAllocMemUnsafe(dwSize.Value() COMMA_INDEBUG(szFile) COMMA_INDEBUG(lineNum)); - - } - - FORCEINLINE TaggedMemAllocPtr RealAllocMem_NoThrow(S_SIZE_T dwSize -#ifdef _DEBUG - ,__in __in_z const char *szFile - ,int lineNum -#endif - ) - { - WRAPPER_NO_CONTRACT; - - if(dwSize.IsOverflow()) { - TaggedMemAllocPtr tmap; - tmap.m_pMem = NULL; - tmap.m_dwRequestedSize = dwSize.Value(); - tmap.m_pHeap = this; - tmap.m_dwExtra = 0; -#ifdef _DEBUG - tmap.m_szFile = szFile; - tmap.m_lineNum = lineNum; -#endif - - return tmap; - } - - return RealAllocMemUnsafe_NoThrow(dwSize.Value() COMMA_INDEBUG(szFile) COMMA_INDEBUG(lineNum)); - } -private: - - TaggedMemAllocPtr RealAllocMemUnsafe(size_t dwSize -#ifdef _DEBUG - ,__in __in_z const char *szFile - ,int lineNum -#endif - ) - { - WRAPPER_NO_CONTRACT; - - - void *pResult; - TaggedMemAllocPtr tmap; - - CRITSEC_Holder csh(m_CriticalSection); - pResult = UnlockedAllocMem(dwSize -#ifdef _DEBUG - , szFile - , lineNum -#endif - ); - tmap.m_pMem = pResult; - tmap.m_dwRequestedSize = dwSize; - tmap.m_pHeap = this; - tmap.m_dwExtra = 0; -#ifdef _DEBUG - tmap.m_szFile = szFile; - tmap.m_lineNum = lineNum; -#endif - return tmap; - } - - TaggedMemAllocPtr RealAllocMemUnsafe_NoThrow(size_t dwSize -#ifdef _DEBUG - ,__in __in_z const char *szFile - ,int lineNum -#endif - ) - { - WRAPPER_NO_CONTRACT; - - void *pResult; - TaggedMemAllocPtr tmap; - - CRITSEC_Holder csh(m_CriticalSection); - - pResult = UnlockedAllocMem_NoThrow(dwSize -#ifdef _DEBUG - , szFile - , lineNum -#endif - ); - - tmap.m_pMem = pResult; - tmap.m_dwRequestedSize = dwSize; - tmap.m_pHeap = this; - tmap.m_dwExtra = 0; -#ifdef _DEBUG - tmap.m_szFile = szFile; - tmap.m_lineNum = lineNum; -#endif - - return tmap; - } - - - -#ifdef _DEBUG -#define AllocAlignedMem(dwSize, dwAlign) RealAllocAlignedMem( (dwSize), (dwAlign), __FILE__, __LINE__) -#define AllocAlignedMem_NoThrow(dwSize, dwAlign) RealAllocAlignedMem_NoThrow( (dwSize), (dwAlign), __FILE__, __LINE__) -#else -#define AllocAlignedMem(dwSize, dwAlign) RealAllocAlignedMem( (dwSize), (dwAlign) ) -#define AllocAlignedMem_NoThrow(dwSize, dwAlign) RealAllocAlignedMem_NoThrow( (dwSize), (dwAlign) ) -#endif - -public: - TaggedMemAllocPtr RealAllocAlignedMem(size_t dwRequestedSize - ,size_t dwAlignment -#ifdef _DEBUG - ,__in __in_z const char *szFile - ,int lineNum -#endif - ) - { - WRAPPER_NO_CONTRACT; - - CRITSEC_Holder csh(m_CriticalSection); - - - TaggedMemAllocPtr tmap; - void *pResult; - size_t dwExtra; - - pResult = UnlockedAllocAlignedMem(dwRequestedSize - ,dwAlignment - ,&dwExtra -#ifdef _DEBUG - ,szFile - ,lineNum -#endif - ); - - tmap.m_pMem = (void*)(((BYTE*)pResult) - dwExtra); - tmap.m_dwRequestedSize = dwRequestedSize + dwExtra; - tmap.m_pHeap = this; - tmap.m_dwExtra = dwExtra; -#ifdef _DEBUG - tmap.m_szFile = szFile; - tmap.m_lineNum = lineNum; -#endif - - return tmap; - } - - - TaggedMemAllocPtr RealAllocAlignedMem_NoThrow(size_t dwRequestedSize - ,size_t dwAlignment -#ifdef _DEBUG - ,__in __in_z const char *szFile - ,int lineNum -#endif - ) - { - WRAPPER_NO_CONTRACT; - - CRITSEC_Holder csh(m_CriticalSection); - - - TaggedMemAllocPtr tmap; - void *pResult; - size_t dwExtra; - - pResult = UnlockedAllocAlignedMem_NoThrow(dwRequestedSize - ,dwAlignment - ,&dwExtra -#ifdef _DEBUG - ,szFile - ,lineNum -#endif - ); - - _ASSERTE(!(pResult == NULL && dwExtra != 0)); - - tmap.m_pMem = (void*)(((BYTE*)pResult) - dwExtra); - tmap.m_dwRequestedSize = dwRequestedSize + dwExtra; - tmap.m_pHeap = this; - tmap.m_dwExtra = dwExtra; -#ifdef _DEBUG - tmap.m_szFile = szFile; - tmap.m_lineNum = lineNum; -#endif - - return tmap; - } - - -public: - // This frees memory allocated by AllocMem. It's given this horrible name to emphasize - // that it's purpose is for error path leak prevention purposes. You shouldn't - // use LoaderHeap's as general-purpose alloc-free heaps. - void RealBackoutMem(void *pMem - , size_t dwSize -#ifdef _DEBUG - , __in __in_z const char *szFile - , int lineNum - , __in __in_z const char *szAllocFile - , int allocLineNum -#endif - ) - { - WRAPPER_NO_CONTRACT; - CRITSEC_Holder csh(m_CriticalSection); - UnlockedBackoutMem(pMem - , dwSize -#ifdef _DEBUG - , szFile - , lineNum - , szAllocFile - , allocLineNum -#endif - ); - } - -public: -// Extra CallTracing support -#ifdef _DEBUG - void ClearEvents() - { - WRAPPER_NO_CONTRACT; - CRITSEC_Holder csh(m_CriticalSection); - UnlockedClearEvents(); - } - - void CompactEvents() - { - WRAPPER_NO_CONTRACT; - CRITSEC_Holder csh(m_CriticalSection); - UnlockedCompactEvents(); - } - - void PrintEvents() - { - WRAPPER_NO_CONTRACT; - CRITSEC_Holder csh(m_CriticalSection); - UnlockedPrintEvents(); - } -#endif - -}; - - - - - -//=============================================================================== -// The ExplicitControlLoaderHeap exposes all the advanced features but -// has no Backout() feature. (If someone wants a backout feature, they need -// to design an appropriate one into this class.) -// -// Caller is responsible for synchronization. ExplicitControlLoaderHeap is -// not multithread safe. -//=============================================================================== -typedef DPTR(class ExplicitControlLoaderHeap) PTR_ExplicitControlLoaderHeap; -class ExplicitControlLoaderHeap : public UnlockedLoaderHeap -{ -#ifndef DACCESS_COMPILE -public: - ExplicitControlLoaderHeap(size_t *pPrivatePerfCounter_LoaderBytes = NULL, - RangeList *pRangeList = NULL, - BOOL fMakeExecutable = FALSE - ) - : UnlockedLoaderHeap(0, 0, NULL, 0, - pPrivatePerfCounter_LoaderBytes, - pRangeList, - fMakeExecutable) - { - WRAPPER_NO_CONTRACT; - m_fExplicitControl = TRUE; - } -#endif // DACCESS_COMPILE - -public: - void *RealAllocMem(size_t dwSize -#ifdef _DEBUG - ,__in __in_z const char *szFile - ,int lineNum -#endif - ) - { - WRAPPER_NO_CONTRACT; - - void *pResult; - - pResult = UnlockedAllocMem(dwSize -#ifdef _DEBUG - , szFile - , lineNum -#endif - ); - return pResult; - } - - void *RealAllocMem_NoThrow(size_t dwSize -#ifdef _DEBUG - ,__in __in_z const char *szFile - ,int lineNum -#endif - ) - { - WRAPPER_NO_CONTRACT; - - void *pResult; - - pResult = UnlockedAllocMem_NoThrow(dwSize -#ifdef _DEBUG - , szFile - , lineNum -#endif - ); - return pResult; - } - - -public: - void *AllocMemForCode_NoThrow(size_t dwHeaderSize, size_t dwCodeSize, DWORD dwCodeAlignment, size_t dwReserveForJumpStubs) - { - WRAPPER_NO_CONTRACT; - return UnlockedAllocMemForCode_NoThrow(dwHeaderSize, dwCodeSize, dwCodeAlignment, dwReserveForJumpStubs); - } - - void SetReservedRegion(BYTE* dwReservedRegionAddress, SIZE_T dwReservedRegionSize, BOOL fReleaseMemory) - { - WRAPPER_NO_CONTRACT; - return UnlockedSetReservedRegion(dwReservedRegionAddress, dwReservedRegionSize, fReleaseMemory); - } - -public: - // number of bytes available in region - size_t GetReservedBytesFree() - { - WRAPPER_NO_CONTRACT; - return UnlockedGetReservedBytesFree(); - } -}; - - - -//============================================================================== -// AllocMemHolder : Allocated memory from LoaderHeap -// -// Old: -// -// Foo* pFoo = (Foo*)pLoaderHeap->AllocMem(size); -// pFoo->BackoutMem(pFoo, size) -// -// -// New: -// -// { -// AllocMemHolder pfoo = pLoaderHeap->AllocMem(); -// } // BackoutMem on out of scope -// -//============================================================================== -template -class AllocMemHolder -{ - private: - TaggedMemAllocPtr m_value; - BOOL m_fAcquired; - - - //-------------------------------------------------------------------- - // All allowed (and disallowed) ctors here. - //-------------------------------------------------------------------- - public: - // Allow the construction "Holder h;" - AllocMemHolder() - { - LIMITED_METHOD_CONTRACT; - - m_value.m_pMem = NULL; - m_value.m_dwRequestedSize = 0; - m_value.m_pHeap = 0; - m_value.m_dwExtra = 0; -#ifdef _DEBUG - m_value.m_szFile = NULL; - m_value.m_lineNum = 0; -#endif - m_fAcquired = FALSE; - } - - public: - // Allow the construction "Holder h = pHeap->AllocMem()" - AllocMemHolder(const TaggedMemAllocPtr value) - { - LIMITED_METHOD_CONTRACT; - m_value = value; - m_fAcquired = TRUE; - } - - private: - // Disallow "Holder holder1 = holder2" - AllocMemHolder(const AllocMemHolder &); - - - private: - // Disallow "Holder holder1 = void*" - AllocMemHolder(const LPVOID &); - - //-------------------------------------------------------------------- - // Destructor (and the whole point of AllocMemHolder) - //-------------------------------------------------------------------- - public: - ~AllocMemHolder() - { - WRAPPER_NO_CONTRACT; - if (m_fAcquired && m_value.m_pMem) - { - m_value.m_pHeap->RealBackoutMem(m_value.m_pMem, - m_value.m_dwRequestedSize -#ifdef _DEBUG - ,__FILE__ - ,__LINE__ - ,m_value.m_szFile - ,m_value.m_lineNum -#endif - ); - } - } - - - //-------------------------------------------------------------------- - // All allowed (and disallowed) assignment operators here. - //-------------------------------------------------------------------- - public: - // Reluctantly allow "AllocMemHolder h; ... h = pheap->AllocMem()" - void operator=(const TaggedMemAllocPtr & value) - { - WRAPPER_NO_CONTRACT; - // However, prevent repeated assignments as that would leak. - _ASSERTE(m_value.m_pMem == NULL && !m_fAcquired); - m_value = value; - m_fAcquired = TRUE; - } - - private: - // Disallow "holder == holder2" - const AllocMemHolder & operator=(const AllocMemHolder &); - - private: - // Disallow "holder = void*" - const AllocMemHolder & operator=(const LPVOID &); - - - //-------------------------------------------------------------------- - // Operations on the holder itself - //-------------------------------------------------------------------- - public: - // Call this when you're ready to take ownership away from the holder. - void SuppressRelease() - { - LIMITED_METHOD_CONTRACT; - m_fAcquired = FALSE; - } - - - - //-------------------------------------------------------------------- - // ... And the smart-pointer stuff so we can drop holders on top - // of former pointer variables (mostly) - //-------------------------------------------------------------------- - public: - // Allow holder to be treated as the underlying pointer type - operator TYPE* () - { - LIMITED_METHOD_CONTRACT; - return (TYPE*)(void*)m_value; - } - - public: - // Allow holder to be treated as the underlying pointer type - TYPE* operator->() - { - LIMITED_METHOD_CONTRACT; - return (TYPE*)(void*)m_value; - } - public: - int operator==(TYPE* value) - { - LIMITED_METHOD_CONTRACT; - return ((void*)m_value) == ((void*)value); - } - - public: - int operator!=(TYPE* value) - { - LIMITED_METHOD_CONTRACT; - return ((void*)m_value) != ((void*)value); - } - - public: - int operator!() const - { - LIMITED_METHOD_CONTRACT; - return m_value.m_pMem == NULL; - } - - -}; - - - -// This utility helps track loaderheap allocations. Its main purpose -// is to backout allocations in case of an exception. -class AllocMemTracker -{ - public: - AllocMemTracker(); - ~AllocMemTracker(); - - // Tells tracker to store an allocated loaderheap block. - // - // Returns the pointer address of block for convenience. - // - // Ok to call on failed loaderheap allocation (will just do nothing and propagate the OOM as apropos). - // - // If Track fails due to an OOM allocating node space, it will backout the loaderheap block before returning. - void *Track(TaggedMemAllocPtr tmap); - void *Track_NoThrow(TaggedMemAllocPtr tmap); - - void SuppressRelease(); - - private: - struct AllocMemTrackerNode - { - ILoaderHeapBackout *m_pHeap; - void *m_pMem; - size_t m_dwRequestedSize; -#ifdef _DEBUG - const char *m_szAllocFile; - int m_allocLineNum; -#endif - }; - - enum - { - kAllocMemTrackerBlockSize = -#ifdef _DEBUG - 3 -#else - 20 -#endif - }; - - struct AllocMemTrackerBlock - { - AllocMemTrackerBlock *m_pNext; - int m_nextFree; - AllocMemTrackerNode m_Node[kAllocMemTrackerBlockSize]; - }; - - - AllocMemTrackerBlock *m_pFirstBlock; - AllocMemTrackerBlock m_FirstBlock; // Stack-allocate the first block - "new" the rest. - - protected: - BOOL m_fReleased; - -}; - -#endif // __LoaderHeap_h__ - diff --git a/src/inc/md5.h b/src/inc/md5.h deleted file mode 100644 index b3684718e..000000000 --- a/src/inc/md5.h +++ /dev/null @@ -1,134 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -// -// md5.h -// - -// -// A pretty fast implementation of MD5 -// - - -#ifndef __MD5_H__ -#define __MD5_H__ - -///////////////////////////////////////////////////////////////////////////////////// -// -// Declaration of the central transform function -// -void __stdcall MD5Transform(ULONG state[4], const ULONG* data); - -///////////////////////////////////////////////////////////////////////////////////// - -#include - - -// This structure is used to return the final resulting hash. -// -struct MD5HASHDATA - { - union - { - BYTE rgb[16]; - struct - { - ULONGLONG ullLow; - ULONGLONG ullHigh; - } u; - struct - { - ULONG u0; - ULONG u1; - ULONG u2; - ULONG u3; - } v; - }; - }; - -inline BOOL operator==(const MD5HASHDATA& me, const MD5HASHDATA& him) - { - return memcmp(&me, &him, sizeof(MD5HASHDATA)) == 0; - } - -inline BOOL operator!=(const MD5HASHDATA& me, const MD5HASHDATA& him) - { - return memcmp(&me, &him, sizeof(MD5HASHDATA)) != 0; - } - - -// The engine that carries out the hash -// -class MD5 - { - // These four values must be contiguous, and in this order - union - { - ULONG m_state[4]; - struct - { - ULONG m_a; // state - ULONG m_b; // ... variables - ULONG m_c; // ... as found in - ULONG m_d; // ... RFC1321 - } u; - }; - - BYTE m_data[64]; // where to accumulate the data as we are passed it - ULONGLONG m_cbitHashed; // amount of data that we've hashed - ULONG m_cbData; // number of bytes presently in data - - BYTE m_padding[64]; // padding data, used if length data not = 0 mod 64 - -public: - - ///////////////////////////////////////////////////////////////////////////////////// - - void Hash(const BYTE* pbData, ULONG cbData, MD5HASHDATA* phash, BOOL fConstructed = FALSE) - { - Init(fConstructed); - HashMore(pbData, cbData); - GetHashValue(phash); - } - - ///////////////////////////////////////////////////////////////////////////////////// - - void Hash(const BYTE* pbData, ULONGLONG cbData, MD5HASHDATA* phash, BOOL fConstructed = FALSE) - { - Init(fConstructed); - - ULARGE_INTEGER ul; - ul.QuadPart = cbData; - - while (ul.u.HighPart) - { - ULONG cbHash = 0xFFFFFFFF; // Hash as much as we can at once - HashMore(pbData, cbHash); - pbData += cbHash; - ul.QuadPart -= cbHash; - } - - HashMore(pbData, ul.u.LowPart); // Hash whatever is left - - GetHashValue(phash); - } - - ///////////////////////////////////////////////////////////////////////////////////// - - void Init(BOOL fConstructed = FALSE); - - ///////////////////////////////////////////////////////////////////////////////////// - - void HashMore(const void* pvInput, ULONG cbInput); - - ///////////////////////////////////////////////////////////////////////////////////// - - void GetHashValue(MD5HASHDATA* phash); - - ///////////////////////////////////////////////////////////////////////////////////// - - }; - -#include - -#endif diff --git a/src/inc/mdcommon.h b/src/inc/mdcommon.h deleted file mode 100644 index 7aeb710aa..000000000 --- a/src/inc/mdcommon.h +++ /dev/null @@ -1,54 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -//***************************************************************************** -// MDCommon.h -// -// Common header file for both MD and COMPLIB subdirectories -// -//***************************************************************************** - -#ifndef __MDCommon_h__ -#define __MDCommon_h__ - -// File types for the database. -enum FILETYPE -{ - FILETYPE_UNKNOWN, // Unknown or undefined type. - FILETYPE_CLB, // Native .clb file format. - FILETYPE_CLX, // An obsolete file format. - FILETYPE_NTPE, // Windows PE executable. - FILETYPE_NTOBJ, // .obj file format (with .clb embedded). - FILETYPE_TLB // Typelib format. -}; - -enum MAPPINGTYPE -{ - MTYPE_NOMAPPING, // No mapped file - MTYPE_FLAT, // Mapped as a flat file - MTYPE_IMAGE // Mapped with the SEC_IMAGE flag -}; - - -#define SCHEMA_STREAM_A "#Schema" -#define STRING_POOL_STREAM_A "#Strings" -#define BLOB_POOL_STREAM_A "#Blob" -#define US_BLOB_POOL_STREAM_A "#US" -#define GUID_POOL_STREAM_A "#GUID" -#define COMPRESSED_MODEL_STREAM_A "#~" -#define ENC_MODEL_STREAM_A "#-" -#define MINIMAL_MD_STREAM_A "#JTD" -#define HOT_MODEL_STREAM_A "#!" - - -#define SCHEMA_STREAM W("#Schema") -#define STRING_POOL_STREAM W("#Strings") -#define BLOB_POOL_STREAM W("#Blob") -#define US_BLOB_POOL_STREAM W("#US") -#define GUID_POOL_STREAM W("#GUID") -#define COMPRESSED_MODEL_STREAM W("#~") -#define ENC_MODEL_STREAM W("#-") -#define MINIMAL_MD_STREAM W("#JTD") -#define HOT_MODEL_STREAM W("#!") - -#endif // __MDCommon_h__ diff --git a/src/inc/memorypool.h b/src/inc/memorypool.h deleted file mode 100644 index 9ea524f1f..000000000 --- a/src/inc/memorypool.h +++ /dev/null @@ -1,143 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - - -#ifndef _MEMORYPOOL_ -#define _MEMORYPOOL_ - -#include "daccess.h" -#include "contract.h" - -// -// A MemoryPool is an allocator for a fixed size elements. -// Allocating and freeing elements from the pool is very cheap compared -// to a general allocator like new. However, a MemoryPool is slightly -// more greedy - it preallocates a bunch of elements at a time, and NEVER -// RELEASES MEMORY FROM THE POOL ONCE IT IS ALLOCATED, (unless you call -// FreeAllElements.) -// -// It also has several additional features: -// * you can free the entire pool of objects cheaply. -// * you can test an object to see if it's an element of the pool. -// - -class MemoryPool -{ - public: - -#ifndef DACCESS_COMPILE - MemoryPool(SIZE_T elementSize, SIZE_T initGrowth = 20, SIZE_T initCount = 0); -#else - MemoryPool() {} -#endif - ~MemoryPool() DAC_EMPTY(); - - BOOL IsElement(void *element); - BOOL IsAllocatedElement(void *element); - void *AllocateElement(); - void *AllocateElementNoThrow(); - void FreeElement(void *element); - void FreeAllElements(); - size_t GetSize(); - private: - - struct Element - { - Element *next; -#if _DEBUG - int deadBeef; -#endif - }; - - struct Block - { - Block *next; - Element *elementsEnd; -#ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable:4200) -#endif - Element elements[0]; -#ifdef _MSC_VER -#pragma warning(pop) -#endif - }; - - SIZE_T m_elementSize; - SIZE_T m_growCount; - Block *m_blocks; - Element *m_freeList; - - BOOL AddBlock(SIZE_T elementCount); - void DeadBeef(Element *element); - - public: - - // - // NOTE: You can currently only iterate the elements - // if none have been freed. - // - - class Iterator - { - private: - Block *m_next; - BYTE *m_e, *m_eEnd; - BYTE *m_end; - SIZE_T m_size; - - public: - Iterator(MemoryPool *pool); - - BOOL Next(); - - void *GetElement() {LIMITED_METHOD_CONTRACT; return (void *) (m_e-m_size); } - }; - - friend class Iterator; -}; - -class MemoryPoolElementHolder -{ - protected: - MemoryPool* m_pool; - void* m_element; - BOOL bRelease; - public: - void SuppressRelease() - { - LIMITED_METHOD_CONTRACT; - _ASSERTE(bRelease); - bRelease=false; - } - void Release() - { - LIMITED_METHOD_CONTRACT; - _ASSERTE(bRelease); - m_pool->FreeElement(m_element); - bRelease=false; - } - MemoryPoolElementHolder(MemoryPool* pool, void* element) - { - LIMITED_METHOD_CONTRACT; - m_pool=pool; - m_element=element; - bRelease=true; - } - - ~MemoryPoolElementHolder() - { - LIMITED_METHOD_CONTRACT; - if (bRelease) - Release(); - } - - operator void* () - { - LIMITED_METHOD_CONTRACT; - return m_element; - } -}; - -#endif // _MEMORYPOOL_ diff --git a/src/inc/memoryrange.h b/src/inc/memoryrange.h deleted file mode 100644 index d558d6b84..000000000 --- a/src/inc/memoryrange.h +++ /dev/null @@ -1,98 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -//***************************************************************************** -// MemoryRange.h -// -// defines the code:MemoryRange class. -//***************************************************************************** - -#ifndef _memory_range_h -#define _memory_range_h - -#include "daccess.h" - -// MemoryRange is a descriptor of a memory range. This groups (pointer + size). -// -// Some key qualities: -// - simple! -// - Not mutable -// - blitabble descriptor which can be useful for out-of-process tools like the debugger. -// - no ownership semantics. -// - no manipulation, growing semantics. -// - no memory marshalling, allocation, copying. etc. -// - can be efficiently passed / copied / returned by value -// -// This class has general value as an abstraction to group pointer and size together. It also has significant -// value to the debugger. An expected design pattern is that other mutable complex data structures (eg, -// code:SBuffer, code:CGrowableStream) will provide an accessor to expose their underlying storage as a -// MemoryRange to debugger. This mirrors the Debugger's code:TargetBuffer data structure, but as a -// general-purpose VM utility versus a debugger right-side data structure. - -// -class MemoryRange -{ -public: - // Constructor to create a memory range around a (start address, size) pair. - MemoryRange() : - m_pStartAddress(NULL), - m_cbBytes(0) - { - SUPPORTS_DAC; - } - - MemoryRange(PTR_VOID pStartAddress, SIZE_T cbBytes) : - m_pStartAddress(pStartAddress), - m_cbBytes(cbBytes) - { - SUPPORTS_DAC; - } - - // Note: use compiler-default copy ctor and assignment operator - - - - // Check whether a pointer is in the memory range represented by this instance. - BOOL IsInRange(PTR_VOID pAddress) const - { - LIMITED_METHOD_DAC_CONTRACT; - - return (dac_cast(pAddress) - dac_cast(m_pStartAddress)) < m_cbBytes; - } - - // Check whether a pointer is in the memory range represented by this instance. - BOOL IsInRange(TADDR pAddress) const - { - LIMITED_METHOD_DAC_CONTRACT; - - return (pAddress - dac_cast(m_pStartAddress)) < m_cbBytes; - } - - // Get the starting address. - PTR_VOID StartAddress() const - { - SUPPORTS_DAC; - return m_pStartAddress; - } - - // Get the size of the range in bytes - SIZE_T Size() const - { - SUPPORTS_DAC; - return m_cbBytes; - } - -private: - // The start of the memory range. - PTR_VOID const m_pStartAddress; - - // The size of the memory range in bytes. - // This is s SIZE_T so that it can describe any memory range in the process (for example, larger than 4gb on 64-bit machines) - const SIZE_T m_cbBytes; - -}; - -typedef ArrayDPTR(MemoryRange) ARRAY_PTR_MemoryRange; - -#endif // _memory_range_h - diff --git a/src/inc/metadata.h b/src/inc/metadata.h deleted file mode 100644 index 8fcf493a2..000000000 --- a/src/inc/metadata.h +++ /dev/null @@ -1,1557 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -//**************************************************************************** -// File: metadata.h -// - -// -// Notes: -// Common includes for EE & metadata internal. This file contains -// definition of CorMetaDataScope -//**************************************************************************** - -#ifndef _METADATA_H_ -#define _METADATA_H_ - -#include "../md/inc/metamodelro.h" -#include "../md/inc/liteweightstgdb.h" - -class UTSemReadWrite; - -inline int IsGlobalMethodParentTk(mdTypeDef td) -{ - LIMITED_METHOD_CONTRACT; - - return (td == mdTypeDefNil || td == mdTokenNil); -} - -typedef enum CorInternalStates -{ - tdNoTypes = 0x00000000, - tdAllAssemblies = 0x00000001, - tdAllTypes = 0xffffffff, -} CorInternalStates; - -// -// MetaData custom value names. -// -enum CorIfaceAttr -{ - ifDual = 0, // Interface derives from IDispatch. - ifVtable = 1, // Interface derives from IUnknown. - ifDispatch = 2, // Interface is a dispinterface. - ifInspectable = 3, // Interface derives from IInspectable. - ifLast = 4, // The last member of the enum. -}; - -inline BOOL IsDispatchBasedItf(CorIfaceAttr ifaceAttr) -{ - return (ifaceAttr == ifDual || ifaceAttr == ifDispatch); -} - -enum CorClassIfaceAttr -{ - clsIfNone = 0, // No class interface is generated. - clsIfAutoDisp = 1, // A dispatch only class interface is generated. - clsIfAutoDual = 2, // A dual class interface is generated. - clsIfLast = 3, // The last member of the enum. -}; - -// -// The default values for the COM interface and class interface types. -// -#define DEFAULT_COM_INTERFACE_TYPE ifDual -#define DEFAULT_CLASS_INTERFACE_TYPE clsIfAutoDisp - -#define HANDLE_UNCOMPRESSED(func) (E_FAIL) -#define HANDLE_UNCOMPRESSED_BOOL(func) (false) - -class TOKENLIST : public CDynArray -{ -}; - - -typedef enum tagEnumType -{ - MDSimpleEnum = 0x0, // simple enumerator that doesn't allocate memory - - // You could get this kind of enum if you perform a non-simple query (such as EnumMethodWithName). - // - MDDynamicArrayEnum = 0x2, // dynamic array that holds tokens - - MDCustomEnum = 0x3, // Custom enumerator that doesnt work with the enum functions -} EnumType; - -//***************************************** -// Enumerator used by MetaDataInternal -//***************************************** -struct HENUMInternal -{ - DWORD m_tkKind; // kind of tables that the enum is holding the result - ULONG m_ulCount; // count of total entries holding by the enumerator - - EnumType m_EnumType; - - struct { - ULONG m_ulStart; - ULONG m_ulEnd; - ULONG m_ulCur; - } u; - - // m_cursor will go away when we no longer support running EE with uncompressed - // format. WHEN WE REMOVE THIS, REMOVE ITS VESTIAGES FROM ZeroEnum as well - // - union { - void* m_alignpad; // The first item is m_cursor[] is a pointer - char m_cursor[32]; // cursor holding query result for read/write mode - }; - - // TOKENLIST daTKList; // dynamic arrays of token list - HENUMInternal() : m_EnumType(MDSimpleEnum) { LIMITED_METHOD_DAC_CONTRACT; } - - // in-place initialization - static void InitDynamicArrayEnum( - HENUMInternal *pEnum); // HENUMInternal to be initialized - - static void InitSimpleEnum( - DWORD tkKind, // kind of token that we are iterating - ULONG ridStart, // starting rid - ULONG ridEnd, // end rid - HENUMInternal *pEnum); // HENUMInternal to be initialized - - // Specialized helper which should be better than always calling memset - inline - static void ZeroEnum( - HENUMInternal *pEnum) - { - // we use this to avoid the memset that will happen otherwise. - // this should be inlined in its caller. we are seeing a large - // number of calls to memset from MDInternalRO::EnumPermissionSetsInit - // on x64 which we can eliminate with this code. - pEnum->m_tkKind = 0; - pEnum->m_ulCount = 0; - pEnum->m_EnumType = MDSimpleEnum; - pEnum->u.m_ulStart = 0; - pEnum->u.m_ulEnd = 0; - pEnum->u.m_ulCur = 0; - - // TODO: remove this when we remove m_cursor from the HENUMInternal structure - _ASSERTE(IS_ALIGNED(pEnum->m_cursor, sizeof(DWORD))); - _ASSERTE((sizeof(HENUMInternal) - offsetof(HENUMInternal, m_cursor)) == (8 * sizeof(DWORD))); - - DWORD* pBuffer = (DWORD*)pEnum->m_cursor; - pBuffer[0] = 0; - pBuffer[1] = 0; - pBuffer[2] = 0; - pBuffer[3] = 0; - pBuffer[4] = 0; - pBuffer[5] = 0; - pBuffer[6] = 0; - pBuffer[7] = 0; - } - - // This will only clear the content of enum and will not free the memory of enum - static void ClearEnum( - HENUMInternal *pmdEnum); - - // create a HENUMInternal. This will allocate the memory - __checkReturn - static HRESULT CreateSimpleEnum( - DWORD tkKind, // kind of token that we are iterating - ULONG ridStart, // starting rid - ULONG ridEnd, // end rid - HENUMInternal **ppEnum); // return the created HENUMInternal - - __checkReturn - static HRESULT CreateDynamicArrayEnum( - DWORD tkKind, // kind of token that we are iterating - HENUMInternal **ppEnum); // return the created HENUMInternal - - // Destory Enum. This will free the memory - static void DestroyEnum( - HENUMInternal *pmdEnum); - - static void DestroyEnumIfEmpty( - HENUMInternal **ppEnum); // reset the enumerator pointer to NULL if empty - - __checkReturn - static HRESULT EnumWithCount( - HENUMInternal *pEnum, // enumerator - ULONG cMax, // max tokens that caller wants - mdToken rTokens[], // output buffer to fill the tokens - ULONG *pcTokens); // number of tokens fill to the buffer upon return - - __checkReturn - static HRESULT EnumWithCount( - HENUMInternal *pEnum, // enumerator - ULONG cMax, // max tokens that caller wants - mdToken rTokens1[], // first output buffer to fill the tokens - mdToken rTokens2[], // second output buffer to fill the tokens - ULONG *pcTokens); // number of tokens fill to the buffer upon return - - __checkReturn - static HRESULT AddElementToEnum( - HENUMInternal *pEnum, // return the created HENUMInternal - mdToken tk); // token to fill - - //***************************************** - // Get next value contained in the enumerator - //***************************************** - static bool EnumNext( - HENUMInternal *phEnum, // [IN] the enumerator to retrieve information - mdToken *ptk); // [OUT] token to scope the search - - __checkReturn - static HRESULT GetCount( - HENUMInternal *phEnum, // [IN] the enumerator to retrieve information - ULONG *pCount); // ]OUT] the index of the desired item - - __checkReturn - static HRESULT GetElement( - HENUMInternal *phEnum, // [IN] the enumerator to retrieve information - ULONG ix, // ]IN] the index of the desired item - mdToken *ptk); // [OUT] token to fill - -}; - - - -//***************************************** -// Default Value for field, param or property. Returned by GetDefaultValue -//***************************************** -typedef struct _MDDefaultValue -{ -#if BIGENDIAN - _MDDefaultValue(void) - { - m_bType = ELEMENT_TYPE_END; - } - ~_MDDefaultValue(void) - { - if (m_bType == ELEMENT_TYPE_STRING) - { - delete[] m_wzValue; - } - } -#endif - - // type of default value - BYTE m_bType; // CorElementType for the default value - - // the default value - union - { - BOOL m_bValue; // ELEMENT_TYPE_BOOLEAN - CHAR m_cValue; // ELEMENT_TYPE_I1 - BYTE m_byteValue; // ELEMENT_TYPE_UI1 - SHORT m_sValue; // ELEMENT_TYPE_I2 - USHORT m_usValue; // ELEMENT_TYPE_UI2 - LONG m_lValue; // ELEMENT_TYPE_I4 - ULONG m_ulValue; // ELEMENT_TYPE_UI4 - LONGLONG m_llValue; // ELEMENT_TYPE_I8 - ULONGLONG m_ullValue; // ELEMENT_TYPE_UI8 - FLOAT m_fltValue; // ELEMENT_TYPE_R4 - DOUBLE m_dblValue; // ELEMENT_TYPE_R8 - LPCWSTR m_wzValue; // ELEMENT_TYPE_STRING - IUnknown *m_unkValue; // ELEMENT_TYPE_CLASS - }; - ULONG m_cbSize; // default value size (for blob) - -} MDDefaultValue; - - - -//***************************************** -// structure use to in GetAllEventAssociates and GetAllPropertyAssociates -//***************************************** -typedef struct -{ - mdMethodDef m_memberdef; - DWORD m_dwSemantics; -} ASSOCIATE_RECORD; - - -// -// structure use to retrieve class layout informaiton -// -typedef struct -{ - RID m_ridFieldCur; // indexing to the field table - RID m_ridFieldEnd; // end index to field table -} MD_CLASS_LAYOUT; - - -// Structure for describing the Assembly MetaData. -typedef struct -{ - USHORT usMajorVersion; // Major Version. - USHORT usMinorVersion; // Minor Version. - USHORT usBuildNumber; // Build Number. - USHORT usRevisionNumber; // Revision Number. - LPCSTR szLocale; // Locale. - DWORD *rProcessor; // Processor array. - ULONG ulProcessor; // [IN/OUT] Size of the processor array/Actual # of entries filled in. - OSINFO *rOS; // OSINFO array. - ULONG ulOS; // [IN/OUT]Size of the OSINFO array/Actual # of entries filled in. -} AssemblyMetaDataInternal; - - - -// Callback definition for comparing signatures. -// (*PSIGCOMPARE) (BYTE ScopeSignature[], DWORD ScopeSignatureLength, -// BYTE ExternalSignature[], DWORD ExternalSignatureLength, -// void* SignatureData); -typedef BOOL (*PSIGCOMPARE)(PCCOR_SIGNATURE, DWORD, PCCOR_SIGNATURE, DWORD, void*); - - - -// {CE0F34ED-BBC6-11d2-941E-0000F8083460} -EXTERN_GUID(IID_IMDInternalImport, 0xce0f34ed, 0xbbc6, 0x11d2, 0x94, 0x1e, 0x0, 0x0, 0xf8, 0x8, 0x34, 0x60); - -#undef INTERFACE -#define INTERFACE IMDInternalImport -DECLARE_INTERFACE_(IMDInternalImport, IUnknown) -{ - //---------------------------------------------------------------------------------------- - // !!! READ THIS !!! - // - // New methods have to be added at the end. The order and signatures of the existing methods - // have to be preserved. We need to maintain a backward compatibility for this interface to - // allow ildasm to work on SingleCLR. - // - //---------------------------------------------------------------------------------------- - - //***************************************************************************** - // return the count of entries of a given kind in a scope - // For example, pass in mdtMethodDef will tell you how many MethodDef - // contained in a scope - //***************************************************************************** - STDMETHOD_(ULONG, GetCountWithTokenKind)(// return hresult - DWORD tkKind) PURE; // [IN] pass in the kind of token. - - //***************************************************************************** - // enumerator for typedef - //***************************************************************************** - __checkReturn - STDMETHOD(EnumTypeDefInit)( // return hresult - HENUMInternal *phEnum) PURE; // [OUT] buffer to fill for enumerator data - - STDMETHOD_(ULONG, EnumTypeDefGetCount)( - HENUMInternal *phEnum) PURE; // [IN] the enumerator to retrieve information - - STDMETHOD_(void, EnumTypeDefReset)( - HENUMInternal *phEnum) PURE; // [IN] the enumerator to retrieve information - - STDMETHOD_(bool, EnumTypeDefNext)( // return hresult - HENUMInternal *phEnum, // [IN] input enum - mdTypeDef *ptd) PURE; // [OUT] return token - - STDMETHOD_(void, EnumTypeDefClose)( - HENUMInternal *phEnum) PURE; // [IN] the enumerator to retrieve information - - //***************************************************************************** - // enumerator for MethodImpl - //***************************************************************************** - __checkReturn - STDMETHOD(EnumMethodImplInit)( // return hresult - mdTypeDef td, // [IN] TypeDef over which to scope the enumeration. - HENUMInternal *phEnumBody, // [OUT] buffer to fill for enumerator data for MethodBody tokens. - HENUMInternal *phEnumDecl) PURE; // [OUT] buffer to fill for enumerator data for MethodDecl tokens. - - STDMETHOD_(ULONG, EnumMethodImplGetCount)( - HENUMInternal *phEnumBody, // [IN] MethodBody enumerator. - HENUMInternal *phEnumDecl) PURE; // [IN] MethodDecl enumerator. - - STDMETHOD_(void, EnumMethodImplReset)( - HENUMInternal *phEnumBody, // [IN] MethodBody enumerator. - HENUMInternal *phEnumDecl) PURE; // [IN] MethodDecl enumerator. - - __checkReturn - STDMETHOD(EnumMethodImplNext)( // return hresult (S_OK = TRUE, S_FALSE = FALSE or error code) - HENUMInternal *phEnumBody, // [IN] input enum for MethodBody - HENUMInternal *phEnumDecl, // [IN] input enum for MethodDecl - mdToken *ptkBody, // [OUT] return token for MethodBody - mdToken *ptkDecl) PURE; // [OUT] return token for MethodDecl - - STDMETHOD_(void, EnumMethodImplClose)( - HENUMInternal *phEnumBody, // [IN] MethodBody enumerator. - HENUMInternal *phEnumDecl) PURE; // [IN] MethodDecl enumerator. - - //***************************************** - // Enumerator helpers for memberdef, memberref, interfaceimp, - // event, property, exception, param - //***************************************** - - __checkReturn - STDMETHOD(EnumGlobalFunctionsInit)( // return hresult - HENUMInternal *phEnum) PURE; // [OUT] buffer to fill for enumerator data - - __checkReturn - STDMETHOD(EnumGlobalFieldsInit)( // return hresult - HENUMInternal *phEnum) PURE; // [OUT] buffer to fill for enumerator data - - __checkReturn - STDMETHOD(EnumInit)( // return S_FALSE if record not found - DWORD tkKind, // [IN] which table to work on - mdToken tkParent, // [IN] token to scope the search - HENUMInternal *phEnum) PURE; // [OUT] the enumerator to fill - - __checkReturn - STDMETHOD(EnumAllInit)( // return S_FALSE if record not found - DWORD tkKind, // [IN] which table to work on - HENUMInternal *phEnum) PURE; // [OUT] the enumerator to fill - - STDMETHOD_(bool, EnumNext)( - HENUMInternal *phEnum, // [IN] the enumerator to retrieve information - mdToken *ptk) PURE; // [OUT] token to scope the search - - STDMETHOD_(ULONG, EnumGetCount)( - HENUMInternal *phEnum) PURE; // [IN] the enumerator to retrieve information - - STDMETHOD_(void, EnumReset)( - HENUMInternal *phEnum) PURE; // [IN] the enumerator to be reset - - STDMETHOD_(void, EnumClose)( - HENUMInternal *phEnum) PURE; // [IN] the enumerator to be closed - - //***************************************** - // Enumerator helpers for declsecurity. - //***************************************** - __checkReturn - STDMETHOD(EnumPermissionSetsInit)( // return S_FALSE if record not found - mdToken tkParent, // [IN] token to scope the search - CorDeclSecurity Action, // [IN] Action to scope the search - HENUMInternal *phEnum) PURE; // [OUT] the enumerator to fill - - //***************************************** - // Enumerator helpers for CustomAttribute - //***************************************** - __checkReturn - STDMETHOD(EnumCustomAttributeByNameInit)(// return S_FALSE if record not found - mdToken tkParent, // [IN] token to scope the search - LPCSTR szName, // [IN] CustomAttribute's name to scope the search - HENUMInternal *phEnum) PURE; // [OUT] the enumerator to fill - - //***************************************** - // Nagivator helper to navigate back to the parent token given a token. - // For example, given a memberdef token, it will return the containing typedef. - // - // the mapping is as following: - // ---given child type---------parent type - // mdMethodDef mdTypeDef - // mdFieldDef mdTypeDef - // mdInterfaceImpl mdTypeDef - // mdParam mdMethodDef - // mdProperty mdTypeDef - // mdEvent mdTypeDef - // - //***************************************** - __checkReturn - STDMETHOD(GetParentToken)( - mdToken tkChild, // [IN] given child token - mdToken *ptkParent) PURE; // [OUT] returning parent - - //***************************************** - // Custom value helpers - //***************************************** - __checkReturn - STDMETHOD(GetCustomAttributeProps)( // S_OK or error. - mdCustomAttribute at, // [IN] The attribute. - mdToken *ptkType) PURE; // [OUT] Put attribute type here. - - __checkReturn - STDMETHOD(GetCustomAttributeAsBlob)( - mdCustomAttribute cv, // [IN] given custom value token - void const **ppBlob, // [OUT] return the pointer to internal blob - ULONG *pcbSize) PURE; // [OUT] return the size of the blob - - // returned void in v1.0/v1.1 - __checkReturn - STDMETHOD (GetScopeProps)( - LPCSTR *pszName, // [OUT] scope name - GUID *pmvid) PURE; // [OUT] version id - - // finding a particular method - __checkReturn - STDMETHOD(FindMethodDef)( - mdTypeDef classdef, // [IN] given typedef - LPCSTR szName, // [IN] member name - PCCOR_SIGNATURE pvSigBlob, // [IN] point to a blob value of CLR signature - ULONG cbSigBlob, // [IN] count of bytes in the signature blob - mdMethodDef *pmd) PURE; // [OUT] matching memberdef - - // return a iSeq's param given a MethodDef - __checkReturn - STDMETHOD(FindParamOfMethod)( // S_OK or error. - mdMethodDef md, // [IN] The owning method of the param. - ULONG iSeq, // [IN] The sequence # of the param. - mdParamDef *pparamdef) PURE; // [OUT] Put ParamDef token here. - - //***************************************** - // - // GetName* functions - // - //***************************************** - - // return the name and namespace of typedef - __checkReturn - STDMETHOD(GetNameOfTypeDef)( - mdTypeDef classdef, // given classdef - LPCSTR *pszname, // return class name(unqualified) - LPCSTR *psznamespace) PURE; // return the name space name - - __checkReturn - STDMETHOD(GetIsDualOfTypeDef)( - mdTypeDef classdef, // [IN] given classdef. - ULONG *pDual) PURE; // [OUT] return dual flag here. - - __checkReturn - STDMETHOD(GetIfaceTypeOfTypeDef)( - mdTypeDef classdef, // [IN] given classdef. - ULONG *pIface) PURE; // [OUT] 0=dual, 1=vtable, 2=dispinterface - - // get the name of either methoddef - __checkReturn - STDMETHOD(GetNameOfMethodDef)( // return the name of the memberdef in UTF8 - mdMethodDef md, // given memberdef - LPCSTR *pszName) PURE; - - __checkReturn - STDMETHOD(GetNameAndSigOfMethodDef)( - mdMethodDef methoddef, // [IN] given memberdef - PCCOR_SIGNATURE *ppvSigBlob, // [OUT] point to a blob value of CLR signature - ULONG *pcbSigBlob, // [OUT] count of bytes in the signature blob - LPCSTR *pszName) PURE; - - // return the name of a FieldDef - __checkReturn - STDMETHOD(GetNameOfFieldDef)( - mdFieldDef fd, // given memberdef - LPCSTR *pszName) PURE; - - // return the name of typeref - __checkReturn - STDMETHOD(GetNameOfTypeRef)( - mdTypeRef classref, // [IN] given typeref - LPCSTR *psznamespace, // [OUT] return typeref name - LPCSTR *pszname) PURE; // [OUT] return typeref namespace - - // return the resolutionscope of typeref - __checkReturn - STDMETHOD(GetResolutionScopeOfTypeRef)( - mdTypeRef classref, // given classref - mdToken *ptkResolutionScope) PURE; - - // Find the type token given the name. - __checkReturn - STDMETHOD(FindTypeRefByName)( - LPCSTR szNamespace, // [IN] Namespace for the TypeRef. - LPCSTR szName, // [IN] Name of the TypeRef. - mdToken tkResolutionScope, // [IN] Resolution Scope fo the TypeRef. - mdTypeRef *ptk) PURE; // [OUT] TypeRef token returned. - - // return the TypeDef properties - // returned void in v1.0/v1.1 - __checkReturn - STDMETHOD(GetTypeDefProps)( - mdTypeDef classdef, // given classdef - DWORD *pdwAttr, // return flags on class, tdPublic, tdAbstract - mdToken *ptkExtends) PURE; // [OUT] Put base class TypeDef/TypeRef here - - // return the item's guid - __checkReturn - STDMETHOD(GetItemGuid)( - mdToken tkObj, // [IN] given item. - CLSID *pGuid) PURE; // [out[ put guid here. - - // Get enclosing class of the NestedClass. - __checkReturn - STDMETHOD(GetNestedClassProps)( // S_OK or error - mdTypeDef tkNestedClass, // [IN] NestedClass token. - mdTypeDef *ptkEnclosingClass) PURE; // [OUT] EnclosingClass token. - - // Get count of Nested classes given the enclosing class. - __checkReturn - STDMETHOD(GetCountNestedClasses)( // return count of Nested classes. - mdTypeDef tkEnclosingClass, // Enclosing class. - ULONG *pcNestedClassesCount) PURE; - - // Return array of Nested classes given the enclosing class. - __checkReturn - STDMETHOD(GetNestedClasses)( // Return actual count. - mdTypeDef tkEnclosingClass, // [IN] Enclosing class. - mdTypeDef *rNestedClasses, // [OUT] Array of nested class tokens. - ULONG ulNestedClasses, // [IN] Size of array. - ULONG *pcNestedClasses) PURE; - - // return the ModuleRef properties - // returned void in v1.0/v1.1 - __checkReturn - STDMETHOD(GetModuleRefProps)( - mdModuleRef mur, // [IN] moduleref token - LPCSTR *pszName) PURE; // [OUT] buffer to fill with the moduleref name - - //***************************************** - // - // GetSig* functions - // - //***************************************** - __checkReturn - STDMETHOD(GetSigOfMethodDef)( - mdMethodDef tkMethodDef, // [IN] given MethodDef - ULONG * pcbSigBlob, // [OUT] count of bytes in the signature blob - PCCOR_SIGNATURE * ppSig) PURE; - - __checkReturn - STDMETHOD(GetSigOfFieldDef)( - mdFieldDef tkFieldDef, // [IN] given FieldDef - ULONG * pcbSigBlob, // [OUT] count of bytes in the signature blob - PCCOR_SIGNATURE * ppSig) PURE; - - __checkReturn - STDMETHOD(GetSigFromToken)( - mdToken tk, // FieldDef, MethodDef, Signature or TypeSpec token - ULONG * pcbSig, - PCCOR_SIGNATURE * ppSig) PURE; - - - - //***************************************** - // get method property - //***************************************** - __checkReturn - STDMETHOD(GetMethodDefProps)( - mdMethodDef md, // The method for which to get props. - DWORD *pdwFlags) PURE; - - //***************************************** - // return method implementation informaiton, like RVA and implflags - //***************************************** - // returned void in v1.0/v1.1 - __checkReturn - STDMETHOD(GetMethodImplProps)( - mdToken tk, // [IN] MethodDef - ULONG *pulCodeRVA, // [OUT] CodeRVA - DWORD *pdwImplFlags) PURE; // [OUT] Impl. Flags - - //***************************************** - // return method implementation informaiton, like RVA and implflags - //***************************************** - __checkReturn - STDMETHOD(GetFieldRVA)( - mdFieldDef fd, // [IN] fielddef - ULONG *pulCodeRVA) PURE; // [OUT] CodeRVA - - //***************************************** - // get field property - //***************************************** - __checkReturn - STDMETHOD(GetFieldDefProps)( - mdFieldDef fd, // [IN] given fielddef - DWORD *pdwFlags) PURE; // [OUT] return fdPublic, fdPrive, etc flags - - //***************************************************************************** - // return default value of a token(could be paramdef, fielddef, or property - //***************************************************************************** - __checkReturn - STDMETHOD(GetDefaultValue)( - mdToken tk, // [IN] given FieldDef, ParamDef, or Property - MDDefaultValue *pDefaultValue) PURE;// [OUT] default value to fill - - - //***************************************** - // get dispid of a MethodDef or a FieldDef - //***************************************** - __checkReturn - STDMETHOD(GetDispIdOfMemberDef)( // return hresult - mdToken tk, // [IN] given methoddef or fielddef - ULONG *pDispid) PURE; // [OUT] Put the dispid here. - - //***************************************** - // return TypeRef/TypeDef given an InterfaceImpl token - //***************************************** - __checkReturn - STDMETHOD(GetTypeOfInterfaceImpl)( // return the TypeRef/typedef token for the interfaceimpl - mdInterfaceImpl iiImpl, // given a interfaceimpl - mdToken *ptkType) PURE; - - //***************************************** - // look up function for TypeDef - //***************************************** - __checkReturn - STDMETHOD(FindTypeDef)( - LPCSTR szNamespace, // [IN] Namespace for the TypeDef. - LPCSTR szName, // [IN] Name of the TypeDef. - mdToken tkEnclosingClass, // [IN] TypeRef/TypeDef Token for the enclosing class. - mdTypeDef *ptypedef) PURE; // [IN] return typedef - - //***************************************** - // return name and sig of a memberref - //***************************************** - __checkReturn - STDMETHOD(GetNameAndSigOfMemberRef)( // return name here - mdMemberRef memberref, // given memberref - PCCOR_SIGNATURE *ppvSigBlob, // [OUT] point to a blob value of CLR signature - ULONG *pcbSigBlob, // [OUT] count of bytes in the signature blob - LPCSTR *pszName) PURE; - - //***************************************************************************** - // Given memberref, return the parent. It can be TypeRef, ModuleRef, MethodDef - //***************************************************************************** - __checkReturn - STDMETHOD(GetParentOfMemberRef)( - mdMemberRef memberref, // given memberref - mdToken *ptkParent) PURE; // return the parent token - - __checkReturn - STDMETHOD(GetParamDefProps)( - mdParamDef paramdef, // given a paramdef - USHORT *pusSequence, // [OUT] slot number for this parameter - DWORD *pdwAttr, // [OUT] flags - LPCSTR *pszName) PURE; // [OUT] return the name of the parameter - - __checkReturn - STDMETHOD(GetPropertyInfoForMethodDef)( // Result. - mdMethodDef md, // [IN] memberdef - mdProperty *ppd, // [OUT] put property token here - LPCSTR *pName, // [OUT] put pointer to name here - ULONG *pSemantic) PURE; // [OUT] put semantic here - - //***************************************** - // class layout/sequence information - //***************************************** - __checkReturn - STDMETHOD(GetClassPackSize)( // return error if class doesn't have packsize - mdTypeDef td, // [IN] give typedef - ULONG *pdwPackSize) PURE; // [OUT] 1, 2, 4, 8, or 16 - - __checkReturn - STDMETHOD(GetClassTotalSize)( // return error if class doesn't have total size info - mdTypeDef td, // [IN] give typedef - ULONG *pdwClassSize) PURE; // [OUT] return the total size of the class - - __checkReturn - STDMETHOD(GetClassLayoutInit)( - mdTypeDef td, // [IN] give typedef - MD_CLASS_LAYOUT *pLayout) PURE; // [OUT] set up the status of query here - - __checkReturn - STDMETHOD(GetClassLayoutNext)( - MD_CLASS_LAYOUT *pLayout, // [IN|OUT] set up the status of query here - mdFieldDef *pfd, // [OUT] return the fielddef - ULONG *pulOffset) PURE; // [OUT] return the offset/ulSequence associate with it - - //***************************************** - // marshal information of a field - //***************************************** - __checkReturn - STDMETHOD(GetFieldMarshal)( // return error if no native type associate with the token - mdFieldDef fd, // [IN] given fielddef - PCCOR_SIGNATURE *pSigNativeType, // [OUT] the native type signature - ULONG *pcbNativeType) PURE; // [OUT] the count of bytes of *ppvNativeType - - - //***************************************** - // property APIs - //***************************************** - // find a property by name - __checkReturn - STDMETHOD(FindProperty)( - mdTypeDef td, // [IN] given a typdef - LPCSTR szPropName, // [IN] property name - mdProperty *pProp) PURE; // [OUT] return property token - - // returned void in v1.0/v1.1 - __checkReturn - STDMETHOD(GetPropertyProps)( - mdProperty prop, // [IN] property token - LPCSTR *szProperty, // [OUT] property name - DWORD *pdwPropFlags, // [OUT] property flags. - PCCOR_SIGNATURE *ppvSig, // [OUT] property type. pointing to meta data internal blob - ULONG *pcbSig) PURE; // [OUT] count of bytes in *ppvSig - - //********************************** - // Event APIs - //********************************** - __checkReturn - STDMETHOD(FindEvent)( - mdTypeDef td, // [IN] given a typdef - LPCSTR szEventName, // [IN] event name - mdEvent *pEvent) PURE; // [OUT] return event token - - // returned void in v1.0/v1.1 - __checkReturn - STDMETHOD(GetEventProps)( - mdEvent ev, // [IN] event token - LPCSTR *pszEvent, // [OUT] Event name - DWORD *pdwEventFlags, // [OUT] Event flags. - mdToken *ptkEventType) PURE; // [OUT] EventType class - - - //********************************** - // find a particular associate of a property or an event - //********************************** - __checkReturn - STDMETHOD(FindAssociate)( - mdToken evprop, // [IN] given a property or event token - DWORD associate, // [IN] given a associate semantics(setter, getter, testdefault, reset, AddOn, RemoveOn, Fire) - mdMethodDef *pmd) PURE; // [OUT] return method def token - - // Note, void function in v1.0/v1.1 - __checkReturn - STDMETHOD(EnumAssociateInit)( - mdToken evprop, // [IN] given a property or an event token - HENUMInternal *phEnum) PURE; // [OUT] cursor to hold the query result - - // returned void in v1.0/v1.1 - __checkReturn - STDMETHOD(GetAllAssociates)( - HENUMInternal *phEnum, // [IN] query result form GetPropertyAssociateCounts - ASSOCIATE_RECORD *pAssociateRec, // [OUT] struct to fill for output - ULONG cAssociateRec) PURE; // [IN] size of the buffer - - - //********************************** - // Get info about a PermissionSet. - //********************************** - // returned void in v1.0/v1.1 - __checkReturn - STDMETHOD(GetPermissionSetProps)( - mdPermission pm, // [IN] the permission token. - DWORD *pdwAction, // [OUT] CorDeclSecurity. - void const **ppvPermission, // [OUT] permission blob. - ULONG *pcbPermission) PURE; // [OUT] count of bytes of pvPermission. - - //**************************************** - // Get the String given the String token. - // Returns a pointer to the string, or NULL in case of error. - //**************************************** - __checkReturn - STDMETHOD(GetUserString)( - mdString stk, // [IN] the string token. - ULONG *pchString, // [OUT] count of characters in the string. - BOOL *pbIs80Plus, // [OUT] specifies where there are extended characters >= 0x80. - LPCWSTR *pwszUserString) PURE; - - //***************************************************************************** - // p-invoke APIs. - //***************************************************************************** - __checkReturn - STDMETHOD(GetPinvokeMap)( - mdToken tk, // [IN] FieldDef, MethodDef. - DWORD *pdwMappingFlags, // [OUT] Flags used for mapping. - LPCSTR *pszImportName, // [OUT] Import name. - mdModuleRef *pmrImportDLL) PURE; // [OUT] ModuleRef token for the target DLL. - - //***************************************************************************** - // helpers to convert a text signature to a com format - //***************************************************************************** - __checkReturn - STDMETHOD(ConvertTextSigToComSig)( // Return hresult. - BOOL fCreateTrIfNotFound, // [IN] create typeref if not found - LPCSTR pSignature, // [IN] class file format signature - CQuickBytes *pqbNewSig, // [OUT] place holder for CLR signature - ULONG *pcbCount) PURE; // [OUT] the result size of signature - - //***************************************************************************** - // Assembly MetaData APIs. - //***************************************************************************** - // returned void in v1.0/v1.1 - __checkReturn - STDMETHOD(GetAssemblyProps)( - mdAssembly mda, // [IN] The Assembly for which to get the properties. - const void **ppbPublicKey, // [OUT] Pointer to the public key. - ULONG *pcbPublicKey, // [OUT] Count of bytes in the public key. - ULONG *pulHashAlgId, // [OUT] Hash Algorithm. - LPCSTR *pszName, // [OUT] Buffer to fill with name. - AssemblyMetaDataInternal *pMetaData,// [OUT] Assembly MetaData. - DWORD *pdwAssemblyFlags) PURE;// [OUT] Flags. - - // returned void in v1.0/v1.1 - __checkReturn - STDMETHOD(GetAssemblyRefProps)( - mdAssemblyRef mdar, // [IN] The AssemblyRef for which to get the properties. - const void **ppbPublicKeyOrToken, // [OUT] Pointer to the public key or token. - ULONG *pcbPublicKeyOrToken, // [OUT] Count of bytes in the public key or token. - LPCSTR *pszName, // [OUT] Buffer to fill with name. - AssemblyMetaDataInternal *pMetaData,// [OUT] Assembly MetaData. - const void **ppbHashValue, // [OUT] Hash blob. - ULONG *pcbHashValue, // [OUT] Count of bytes in the hash blob. - DWORD *pdwAssemblyRefFlags) PURE; // [OUT] Flags. - - // returned void in v1.0/v1.1 - __checkReturn - STDMETHOD(GetFileProps)( - mdFile mdf, // [IN] The File for which to get the properties. - LPCSTR *pszName, // [OUT] Buffer to fill with name. - const void **ppbHashValue, // [OUT] Pointer to the Hash Value Blob. - ULONG *pcbHashValue, // [OUT] Count of bytes in the Hash Value Blob. - DWORD *pdwFileFlags) PURE; // [OUT] Flags. - - // returned void in v1.0/v1.1 - __checkReturn - STDMETHOD(GetExportedTypeProps)( - mdExportedType mdct, // [IN] The ExportedType for which to get the properties. - LPCSTR *pszNamespace, // [OUT] Namespace. - LPCSTR *pszName, // [OUT] Name. - mdToken *ptkImplementation, // [OUT] mdFile or mdAssemblyRef that provides the ExportedType. - mdTypeDef *ptkTypeDef, // [OUT] TypeDef token within the file. - DWORD *pdwExportedTypeFlags) PURE; // [OUT] Flags. - - // returned void in v1.0/v1.1 - __checkReturn - STDMETHOD(GetManifestResourceProps)( - mdManifestResource mdmr, // [IN] The ManifestResource for which to get the properties. - LPCSTR *pszName, // [OUT] Buffer to fill with name. - mdToken *ptkImplementation, // [OUT] mdFile or mdAssemblyRef that provides the ExportedType. - DWORD *pdwOffset, // [OUT] Offset to the beginning of the resource within the file. - DWORD *pdwResourceFlags) PURE;// [OUT] Flags. - - __checkReturn - STDMETHOD(FindExportedTypeByName)( // S_OK or error - LPCSTR szNamespace, // [IN] Namespace of the ExportedType. - LPCSTR szName, // [IN] Name of the ExportedType. - mdExportedType tkEnclosingType, // [IN] ExportedType for the enclosing class. - mdExportedType *pmct) PURE; // [OUT] Put ExportedType token here. - - __checkReturn - STDMETHOD(FindManifestResourceByName)( // S_OK or error - LPCSTR szName, // [IN] Name of the ManifestResource. - mdManifestResource *pmmr) PURE; // [OUT] Put ManifestResource token here. - - __checkReturn - STDMETHOD(GetAssemblyFromScope)( // S_OK or error - mdAssembly *ptkAssembly) PURE; // [OUT] Put token here. - - __checkReturn - STDMETHOD(GetCustomAttributeByName)( // S_OK or error - mdToken tkObj, // [IN] Object with Custom Attribute. - LPCUTF8 szName, // [IN] Name of desired Custom Attribute. - const void **ppData, // [OUT] Put pointer to data here. - ULONG *pcbData) PURE; // [OUT] Put size of data here. - - // Note: The return type of this method was void in v1 - __checkReturn - STDMETHOD(GetTypeSpecFromToken)( // S_OK or error. - mdTypeSpec typespec, // [IN] Signature token. - PCCOR_SIGNATURE *ppvSig, // [OUT] return pointer to token. - ULONG *pcbSig) PURE; // [OUT] return size of signature. - - __checkReturn - STDMETHOD(SetUserContextData)( // S_OK or E_NOTIMPL - IUnknown *pIUnk) PURE; // The user context. - - __checkReturn - STDMETHOD_(BOOL, IsValidToken)( // True or False. - mdToken tk) PURE; // [IN] Given token. - - __checkReturn - STDMETHOD(TranslateSigWithScope)( - IMDInternalImport *pAssemImport, // [IN] import assembly scope. - const void *pbHashValue, // [IN] hash value for the import assembly. - ULONG cbHashValue, // [IN] count of bytes in the hash value. - PCCOR_SIGNATURE pbSigBlob, // [IN] signature in the importing scope - ULONG cbSigBlob, // [IN] count of bytes of signature - IMetaDataAssemblyEmit *pAssemEmit, // [IN] assembly emit scope. - IMetaDataEmit *emit, // [IN] emit interface - CQuickBytes *pqkSigEmit, // [OUT] buffer to hold translated signature - ULONG *pcbSig) PURE; // [OUT] count of bytes in the translated signature - - STDMETHOD_(IMetaModelCommon*, GetMetaModelCommon)( // Return MetaModelCommon interface. - ) PURE; - - STDMETHOD_(IUnknown *, GetCachedPublicInterface)(BOOL fWithLock) PURE; // return the cached public interface - __checkReturn - STDMETHOD(SetCachedPublicInterface)(IUnknown *pUnk) PURE; // no return value - STDMETHOD_(UTSemReadWrite*, GetReaderWriterLock)() PURE; // return the reader writer lock - __checkReturn - STDMETHOD(SetReaderWriterLock)(UTSemReadWrite * pSem) PURE; - - STDMETHOD_(mdModule, GetModuleFromScope)() PURE; // [OUT] Put mdModule token here. - - - //----------------------------------------------------------------- - // Additional custom methods - - // finding a particular method - __checkReturn - STDMETHOD(FindMethodDefUsingCompare)( - mdTypeDef classdef, // [IN] given typedef - LPCSTR szName, // [IN] member name - PCCOR_SIGNATURE pvSigBlob, // [IN] point to a blob value of CLR signature - ULONG cbSigBlob, // [IN] count of bytes in the signature blob - PSIGCOMPARE pSignatureCompare, // [IN] Routine to compare signatures - void* pSignatureArgs, // [IN] Additional info to supply the compare function - mdMethodDef *pmd) PURE; // [OUT] matching memberdef - - // Additional v2 methods. - - //***************************************** - // return a field offset for a given field - //***************************************** - __checkReturn - STDMETHOD(GetFieldOffset)( - mdFieldDef fd, // [IN] fielddef - ULONG *pulOffset) PURE; // [OUT] FieldOffset - - __checkReturn - STDMETHOD(GetMethodSpecProps)( - mdMethodSpec ms, // [IN] The method instantiation - mdToken *tkParent, // [OUT] MethodDef or MemberRef - PCCOR_SIGNATURE *ppvSigBlob, // [OUT] point to the blob value of meta data - ULONG *pcbSigBlob) PURE; // [OUT] actual size of signature blob - - __checkReturn - STDMETHOD(GetTableInfoWithIndex)( - ULONG index, // [IN] pass in the table index - void **pTable, // [OUT] pointer to table at index - void **pTableSize) PURE; // [OUT] size of table at index - - __checkReturn - STDMETHOD(ApplyEditAndContinue)( - void *pDeltaMD, // [IN] the delta metadata - ULONG cbDeltaMD, // [IN] length of pData - IMDInternalImport **ppv) PURE; // [OUT] the resulting metadata interface - - //********************************** - // Generics APIs - //********************************** - __checkReturn - STDMETHOD(GetGenericParamProps)( // S_OK or error. - mdGenericParam rd, // [IN] The type parameter - ULONG* pulSequence, // [OUT] Parameter sequence number - DWORD* pdwAttr, // [OUT] Type parameter flags (for future use) - mdToken *ptOwner, // [OUT] The owner (TypeDef or MethodDef) - DWORD *reserved, // [OUT] The kind (TypeDef/Ref/Spec, for future use) - LPCSTR *szName) PURE; // [OUT] The name - - __checkReturn - STDMETHOD(GetGenericParamConstraintProps)( // S_OK or error. - mdGenericParamConstraint rd, // [IN] The constraint token - mdGenericParam *ptGenericParam, // [OUT] GenericParam that is constrained - mdToken *ptkConstraintType) PURE; // [OUT] TypeDef/Ref/Spec constraint - - //***************************************************************************** - // This function gets the "built for" version of a metadata scope. - // NOTE: if the scope has never been saved, it will not have a built-for - // version, and an empty string will be returned. - //***************************************************************************** - __checkReturn - STDMETHOD(GetVersionString)( // S_OK or error. - LPCSTR *pVer) PURE; // [OUT] Put version string here. - - - __checkReturn - STDMETHOD(SafeAndSlowEnumCustomAttributeByNameInit)(// return S_FALSE if record not found - mdToken tkParent, // [IN] token to scope the search - LPCSTR szName, // [IN] CustomAttribute's name to scope the search - HENUMInternal *phEnum) PURE; // [OUT] The enumerator - - __checkReturn - STDMETHOD(SafeAndSlowEnumCustomAttributeByNameNext)(// return S_FALSE if record not found - mdToken tkParent, // [IN] token to scope the search - LPCSTR szName, // [IN] CustomAttribute's name to scope the search - HENUMInternal *phEnum, // [IN] The enumerator - mdCustomAttribute *mdAttribute) PURE; // [OUT] The custom attribute that was found - - - __checkReturn - STDMETHOD(GetTypeDefRefTokenInTypeSpec)(// return S_FALSE if enclosing type does not have a token - mdTypeSpec tkTypeSpec, // [IN] TypeSpec token to look at - mdToken *tkEnclosedToken) PURE; // [OUT] The enclosed type token - -#define MD_STREAM_VER_1X 0x10000 -#define MD_STREAM_VER_2_B1 0x10001 -#define MD_STREAM_VER_2 0x20000 - STDMETHOD_(DWORD, GetMetadataStreamVersion)() PURE; //returns DWORD with major version of - // MD stream in senior word and minor version--in junior word - - __checkReturn - STDMETHOD(GetNameOfCustomAttribute)(// S_OK or error - mdCustomAttribute mdAttribute, // [IN] The Custom Attribute - LPCUTF8 *pszNamespace, // [OUT] Namespace of Custom Attribute. - LPCUTF8 *pszName) PURE; // [OUT] Name of Custom Attribute. - - STDMETHOD(SetOptimizeAccessForSpeed)(// S_OK or error - BOOL fOptSpeed) PURE; - - STDMETHOD(SetVerifiedByTrustedSource)(// S_OK or error - BOOL fVerified) PURE; - - STDMETHOD(GetRvaOffsetData)( - DWORD *pFirstMethodRvaOffset, // [OUT] Offset (from start of metadata) to the first RVA field in MethodDef table. - DWORD *pMethodDefRecordSize, // [OUT] Size of each record in MethodDef table. - DWORD *pMethodDefCount, // [OUT] Number of records in MethodDef table. - DWORD *pFirstFieldRvaOffset, // [OUT] Offset (from start of metadata) to the first RVA field in FieldRVA table. - DWORD *pFieldRvaRecordSize, // [OUT] Size of each record in FieldRVA table. - DWORD *pFieldRvaCount // [OUT] Number of records in FieldRVA table. - ) PURE; - - //---------------------------------------------------------------------------------------- - // !!! READ THIS !!! - // - // New methods have to be added at the end. The order and signatures of the existing methods - // have to be preserved. We need to maintain a backward compatibility for this interface to - // allow ildasm to work on SingleCLR. - // - //---------------------------------------------------------------------------------------- - -}; // IMDInternalImport - - -// {E03D7730-D7E3-11d2-8C0D-00C04FF7431A} -EXTERN_GUID(IID_IMDInternalImportENC, 0xe03d7730, 0xd7e3, 0x11d2, 0x8c, 0xd, 0x0, 0xc0, 0x4f, 0xf7, 0x43, 0x1a); - -#undef INTERFACE -#define INTERFACE IMDInternalImportENC -DECLARE_INTERFACE_(IMDInternalImportENC, IMDInternalImport) -{ -private: - using IMDInternalImport::ApplyEditAndContinue; -public: - // ENC only methods here. - STDMETHOD(ApplyEditAndContinue)( // S_OK or error. - MDInternalRW *pDelta) PURE; // Interface to MD with the ENC delta. - - STDMETHOD(EnumDeltaTokensInit)( // return hresult - HENUMInternal *phEnum) PURE; // [OUT] buffer to fill for enumerator data - -}; // IMDInternalImportENC - -// {F102C526-38CB-49ed-9B5F-498816AE36E0} -EXTERN_GUID(IID_IMDInternalEmit, 0xf102c526, 0x38cb, 0x49ed, 0x9b, 0x5f, 0x49, 0x88, 0x16, 0xae, 0x36, 0xe0); - -#undef INTERFACE -#define INTERFACE IMDInternalEmit -DECLARE_INTERFACE_(IMDInternalEmit, IUnknown) -{ - STDMETHOD(ChangeMvid)( // S_OK or error. - REFGUID newMvid) PURE; // GUID to use as the MVID - - STDMETHOD(SetMDUpdateMode)( - ULONG updateMode, ULONG *pPreviousUpdateMode) PURE; - -}; // IMDInternalEmit - -#ifdef FEATURE_METADATA_CUSTOM_DATA_SOURCE - -struct IMDCustomDataSource; - -#include "../md/inc/metamodel.h" - -// {CC0C8F7A-A00B-493D-80B6-CE0C92491670} -EXTERN_GUID(IID_IMDCustomDataSource, 0xcc0c8f7a, 0xa00b, 0x493d, 0x80, 0xb6, 0xce, 0xc, 0x92, 0x49, 0x16, 0x70); - -#undef INTERFACE -#define INTERFACE IMDCustomDataSource -DECLARE_INTERFACE_(IMDCustomDataSource, IUnknown) -{ - STDMETHOD(GetSchema)(CMiniMdSchema* pSchema) PURE; - STDMETHOD(GetTableDef)(ULONG32 tableIndex, CMiniTableDef* pTableDef) PURE; - STDMETHOD(GetBlobHeap)(MetaData::DataBlob* pBlobHeapData) PURE; - STDMETHOD(GetGuidHeap)(MetaData::DataBlob* pGuidHeapData) PURE; - STDMETHOD(GetStringHeap)(MetaData::DataBlob* pStringHeapData) PURE; - STDMETHOD(GetUserStringHeap)(MetaData::DataBlob* pUserStringHeapData) PURE; - STDMETHOD(GetTableRecords)(ULONG32 tableIndex, MetaData::DataBlob* pTableRecordData) PURE; - STDMETHOD(GetTableSortable)(ULONG32 tableIndex, BOOL* pSortable) PURE; - STDMETHOD(GetStorageSignature)(MetaData::DataBlob* pStorageSignature) PURE; - -}; // IMDCustomDataSource - -// {503F79FB-7AAE-4364-BDA6-8E235D173AEC} -EXTERN_GUID(IID_IMetaDataDispenserCustom, - 0x503f79fb, 0x7aae, 0x4364, 0xbd, 0xa6, 0x8e, 0x23, 0x5d, 0x17, 0x3a, 0xec); - -#undef INTERFACE -#define INTERFACE IMetaDataDispenserCustom -DECLARE_INTERFACE_(IMetaDataDispenserCustom, IUnknown) -{ - STDMETHOD(OpenScopeOnCustomDataSource)( // Return code. - IMDCustomDataSource *pCustomSource, // [in] The scope to open. - DWORD dwOpenFlags, // [in] Open mode flags. - REFIID riid, // [in] The interface desired. - IUnknown **ppIUnk) PURE; // [out] Return interface on success. - -}; // IMetaDataDispenserCustom - -#endif // FEATURE_METADATA_CUSTOM_DATA_SOURCE - -#ifdef FEATURE_METADATA_DEBUGGEE_DATA_SOURCE -struct ICorDebugDataTarget; -HRESULT CreateRemoteMDInternalRWSource(TADDR mdInternalRWRemoteAddress, ICorDebugDataTarget* pDataTarget, DWORD defines, DWORD dataStructureVersion, IMDCustomDataSource** ppDataSource); -#endif - -#ifdef __HOLDER_H_ - -void DECLSPEC_NORETURN ThrowHR(HRESULT hr); - -// This wrapper class ensures that the HENUMInternal is EnumTypeDefClose'd no matter how the scope is exited. -class HENUMTypeDefInternalHolder -{ -public: - FORCEINLINE HENUMTypeDefInternalHolder(IMDInternalImport *pInternalImport) - { - WRAPPER_NO_CONTRACT; - - m_pInternalImport = pInternalImport; - m_fAcquired = FALSE; - } - - FORCEINLINE VOID EnumTypeDefInit() - { - CONTRACTL { - THROWS; - } CONTRACTL_END; - - _ASSERTE(!m_fAcquired); - HRESULT hr = m_pInternalImport->EnumTypeDefInit(&m_hEnum); - if (FAILED(hr)) - { - ThrowHR(hr); - } - m_fAcquired = TRUE; - - } - - FORCEINLINE HRESULT EnumTypeDefInitNoThrow() - { - WRAPPER_NO_CONTRACT; - - _ASSERTE(!m_fAcquired); - HRESULT hr = m_pInternalImport->EnumTypeDefInit(&m_hEnum); - if (FAILED(hr)) - { - return hr; - } - m_fAcquired = TRUE; - - return hr; - } - - FORCEINLINE ~HENUMTypeDefInternalHolder() - { - WRAPPER_NO_CONTRACT; - - if (m_fAcquired) - { - m_pInternalImport->EnumTypeDefClose(&m_hEnum); - } - } - - FORCEINLINE HENUMInternal* operator& () - { - LIMITED_METHOD_CONTRACT; - - _ASSERTE(m_fAcquired); - return &m_hEnum; - } - -private: - FORCEINLINE HENUMTypeDefInternalHolder(const HENUMTypeDefInternalHolder &) - { - LIMITED_METHOD_CONTRACT; - - _ASSERTE(!"Don't try to assign this class."); - } - -private: - IMDInternalImport *m_pInternalImport; - HENUMInternal m_hEnum; - BOOL m_fAcquired; -}; - - -// This wrapper class ensures that the HENUMInternal is EnumClose'd no matter how the scope is exited. -class HENUMInternalHolder -{ -public: - FORCEINLINE HENUMInternalHolder(IMDInternalImport *pInternalImport) - { - WRAPPER_NO_CONTRACT; - - m_pInternalImport = pInternalImport; - m_fAcquired = FALSE; - } - - FORCEINLINE BOOL EnumPermissionSetsInit(mdToken tkToken, CorDeclSecurity action) - { - CONTRACTL { - THROWS; - } CONTRACTL_END; - - _ASSERTE(!m_fAcquired); - HRESULT hr = m_pInternalImport->EnumPermissionSetsInit(tkToken, action, &m_hEnum); - - if (hr == CLDB_E_RECORD_NOTFOUND) - return FALSE; - - if (FAILED(hr) ) - { - ThrowHR(hr); - } - - m_fAcquired = TRUE; - - return TRUE; - } - - FORCEINLINE VOID EnumGlobalFunctionsInit() - { - CONTRACTL { - THROWS; - } CONTRACTL_END; - - _ASSERTE(!m_fAcquired); - HRESULT hr = m_pInternalImport->EnumGlobalFunctionsInit(&m_hEnum); - if (FAILED(hr)) - { - ThrowHR(hr); - } - m_fAcquired = TRUE; - - } - - - FORCEINLINE VOID EnumGlobalFieldsInit() - { - CONTRACTL { - THROWS; - } CONTRACTL_END; - - _ASSERTE(!m_fAcquired); - HRESULT hr = m_pInternalImport->EnumGlobalFieldsInit(&m_hEnum); - if (FAILED(hr)) - { - ThrowHR(hr); - } - m_fAcquired = TRUE; - - } - - FORCEINLINE VOID EnumTypeDefInit() - { - CONTRACTL { - THROWS; - } CONTRACTL_END; - - _ASSERTE(!m_fAcquired); - HRESULT hr = m_pInternalImport->EnumTypeDefInit(&m_hEnum); - if (FAILED(hr)) - { - ThrowHR(hr); - } - m_fAcquired = TRUE; - } - - FORCEINLINE VOID EnumAssociateInit(mdToken tkParent) // [IN] token to scope the search - { - CONTRACTL { - THROWS; - } CONTRACTL_END; - - _ASSERTE(!m_fAcquired); - IfFailThrow(m_pInternalImport->EnumAssociateInit(tkParent, &m_hEnum)); - m_fAcquired = TRUE; - } - - FORCEINLINE VOID EnumInit(DWORD tkKind, // [IN] which table to work on - mdToken tkParent // [IN] token to scope the search - ) - { - CONTRACTL { - THROWS; - } CONTRACTL_END; - - HRESULT hr = EnumInitNoThrow(tkKind, tkParent); - if (FAILED(hr)) - { - ThrowHR(hr); - } - } - - __checkReturn - FORCEINLINE HRESULT EnumInitNoThrow(DWORD tkKind, // [IN] which table to work on - mdToken tkParent // [IN] token to scope the search - ) - { - CONTRACTL { - NOTHROW; - } CONTRACTL_END; - - _ASSERTE(!m_fAcquired); - HRESULT hr = m_pInternalImport->EnumInit(tkKind, tkParent, &m_hEnum); - if (SUCCEEDED(hr)) - { - m_fAcquired = TRUE; - } - return hr; - } - - FORCEINLINE VOID EnumAllInit(DWORD tkKind // [IN] which table to work on - ) - { - CONTRACTL { - THROWS; - } CONTRACTL_END; - - _ASSERTE(!m_fAcquired); - HRESULT hr = m_pInternalImport->EnumAllInit(tkKind, &m_hEnum); - if (FAILED(hr)) - { - ThrowHR(hr); - } - m_fAcquired = TRUE; - - } - - FORCEINLINE ULONG EnumGetCount() - { - CONTRACTL { - NOTHROW; - GC_NOTRIGGER; - CONSISTENCY_CHECK(m_fAcquired); - } CONTRACTL_END; - - return m_pInternalImport->EnumGetCount(&m_hEnum); - } - - FORCEINLINE bool EnumNext(mdToken * pTok) - { - CONTRACTL { - NOTHROW; - GC_NOTRIGGER; - CONSISTENCY_CHECK(m_fAcquired); - } CONTRACTL_END; - - return m_pInternalImport->EnumNext(&m_hEnum, pTok); - } - - FORCEINLINE void EnumReset() - { - CONTRACTL { - NOTHROW; - GC_NOTRIGGER; - CONSISTENCY_CHECK(m_fAcquired); - } CONTRACTL_END; - - return m_pInternalImport->EnumReset(&m_hEnum); - } - - FORCEINLINE ~HENUMInternalHolder() - { - WRAPPER_NO_CONTRACT; - - if (m_fAcquired) - { - // Ignore the error - (void)m_pInternalImport->EnumClose(&m_hEnum); - } - } - - FORCEINLINE HENUMInternal* operator& () - { - LIMITED_METHOD_CONTRACT; - - _ASSERTE(m_fAcquired); - return &m_hEnum; - } - -private: - FORCEINLINE HENUMInternalHolder(const HENUMInternalHolder &) - { - WRAPPER_NO_CONTRACT; - - _ASSERTE(!"Don't try to assign this class."); - } - - -protected: - IMDInternalImport *m_pInternalImport; - HENUMInternal m_hEnum; - BOOL m_fAcquired; -}; - -class HENUMInternalMethodImplHolder : protected HENUMInternalHolder -{ - public: - FORCEINLINE HENUMInternalMethodImplHolder(IMDInternalImport *pInternalImport) - : HENUMInternalHolder(pInternalImport) - { - WRAPPER_NO_CONTRACT; - } - - FORCEINLINE ~HENUMInternalMethodImplHolder() - { - WRAPPER_NO_CONTRACT; - - if (m_fAcquired) - { - // Ignore the error - (void)m_pInternalImport->EnumClose(&m_hEnum2); - } - } - - FORCEINLINE void EnumMethodImplInit(mdToken tkParent // [IN] token to scope the search - ) - { - CONTRACTL { - THROWS; - } CONTRACTL_END; - - HRESULT hr = EnumMethodImplInitNoThrow(tkParent); - if (FAILED(hr)) - { - ThrowHR(hr); - } - } - - __checkReturn - FORCEINLINE HRESULT EnumMethodImplInitNoThrow(mdToken tkParent // [IN] token to scope the search - ) - { - CONTRACTL { - NOTHROW; - } CONTRACTL_END; - - _ASSERTE(!m_fAcquired); - HRESULT hr = m_pInternalImport->EnumMethodImplInit(tkParent, &m_hEnum, &m_hEnum2); - if (SUCCEEDED(hr)) - { - m_fAcquired = TRUE; - } - return hr; - } - - __checkReturn - FORCEINLINE HRESULT EnumMethodImplNext( - mdToken *ptkImpl, - mdToken *ptkDecl) - { - CONTRACTL { - NOTHROW; - GC_NOTRIGGER; - CONSISTENCY_CHECK(m_fAcquired); - } CONTRACTL_END; - - return m_pInternalImport->EnumMethodImplNext(&m_hEnum, &m_hEnum2, ptkImpl, ptkDecl); - } - - FORCEINLINE ULONG EnumMethodImplGetCount() - { - CONTRACTL { - NOTHROW; - GC_NOTRIGGER; - CONSISTENCY_CHECK(m_fAcquired); - } CONTRACTL_END; - - return m_pInternalImport->EnumMethodImplGetCount(&m_hEnum, &m_hEnum2); - } - - protected: - HENUMInternal m_hEnum2; -}; - -#endif //__HOLDER_H_ - -#endif // _METADATA_H_ diff --git a/src/inc/metadataexports.h b/src/inc/metadataexports.h deleted file mode 100644 index 159af69fb..000000000 --- a/src/inc/metadataexports.h +++ /dev/null @@ -1,57 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -//***************************************************************************** -// MDCommon.h -// - -// -// Header for functions exported by metadata. These are consumed 2 ways: -// 1. Mscoree provides public exports that plumb to some of these functions to invoke these dynamically. -// 2. Standalone metadata (statically linked) -// -//***************************************************************************** - - -#ifndef _METADATA_EXPORTS_ -#define _METADATA_EXPORTS_ - - - -// General creation function for ClassFactory semantics. -STDAPI MetaDataDllGetClassObject(REFCLSID rclsid, REFIID riid, void ** ppv); - -// Specific creation function to get IMetaDataDispenser(Ex) interface. -HRESULT InternalCreateMetaDataDispenser(REFIID riid, void ** pMetaDataDispenserOut); - -STDAPI GetMDInternalInterface( - LPVOID pData, - ULONG cbData, - DWORD flags, // [IN] MDInternal_OpenForRead or MDInternal_OpenForENC - REFIID riid, // [in] The interface desired. - void **ppIUnk); // [out] Return interface on success. - -STDAPI GetMDInternalInterfaceFromPublic( - IUnknown *pIUnkPublic, // [IN] Given scope. - REFIID riid, // [in] The interface desired. - void **ppIUnkInternal); // [out] Return interface on success. - -STDAPI GetMDPublicInterfaceFromInternal( - void *pIUnkPublic, // [IN] Given scope. - REFIID riid, // [in] The interface desired. - void **ppIUnkInternal); // [out] Return interface on success. - -STDAPI MDReOpenMetaDataWithMemory( - void *pImport, // [IN] Given scope. public interfaces - LPCVOID pData, // [in] Location of scope data. - ULONG cbData); // [in] Size of the data pointed to by pData. - -STDAPI MDReOpenMetaDataWithMemoryEx( - void *pImport, // [IN] Given scope. public interfaces - LPCVOID pData, // [in] Location of scope data. - ULONG cbData, // [in] Size of the data pointed to by pData. - DWORD dwReOpenFlags); // [in] ReOpen flags - - - -#endif // _METADATA_EXPORTS_ diff --git a/src/inc/metadatatracker.h b/src/inc/metadatatracker.h deleted file mode 100644 index 00aa56afa..000000000 --- a/src/inc/metadatatracker.h +++ /dev/null @@ -1,367 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#ifndef _METADATATRACKER_H_ -#define _METADATATRACKER_H_ - -#if defined(FEATURE_PREJIT) && defined(FEATURE_WINDOWSPHONE) - -#define METADATATRACKER_DATA 1 -#if !defined(DACCESS_COMPILE) -#define METADATATRACKER_ENABLED 1 -#endif - -#endif - -#if METADATATRACKER_ENABLED - -#define METADATATRACKER_ONLY(s) (s) - -#include "winbase.h" -#include "winwrap.h" -#include "holder.h" -#include "contract.h" -#include -#include -#include -#include "stdmacros.h" - -#include "metamodelpub.h" - -#define NUM_MD_SECTIONS (TBL_COUNT + MDPoolCount) - -#define STRING_POOL (TBL_COUNT + MDPoolStrings) -#define GUID_POOL (TBL_COUNT + MDPoolGuids) -#define BLOB_POOL (TBL_COUNT + MDPoolBlobs) -#define USERSTRING_POOL (TBL_COUNT + MDPoolUSBlobs) - -class MetaDataTracker -{ - LPWSTR m_ModuleName; - BYTE *m_MetadataBase; - SIZE_T m_MetadataSize; - MetaDataTracker *m_next; - - BYTE *m_mdSections[NUM_MD_SECTIONS]; - SIZE_T m_mdSectionSize[NUM_MD_SECTIONS]; - SIZE_T m_mdSectionRowSize[NUM_MD_SECTIONS]; - BOOL m_bActivated; - - static BOOL s_bEnabled; - - static MetaDataTracker *m_MDTrackers; - -public: - // callback into IBCLogger.cpp. Done this crummy way because we can't include IBCLogger.h here nor link - // to IBCLogger.cpp - static void (*s_IBCLogMetaDataAccess)(const void *addr); - static void (*s_IBCLogMetaDataSearch)(const void *result); - - MetaDataTracker(BYTE *baseAddress, DWORD mdSize, LPCWSTR modName) - { - CONTRACTL - { - CONSTRUCTOR_CHECK; - THROWS; - GC_NOTRIGGER; - INJECT_FAULT(ThrowOutOfMemory()); - SO_INTOLERANT; - } - CONTRACTL_END; - - m_ModuleName = NULL; - - DWORD len = (DWORD)wcslen(modName); - _ASSERTE(len + 1 != 0); // Prevent Overflow - m_ModuleName = new wchar_t[len + 1]; - NewArrayHolder moduleNameHolder(m_ModuleName); - wcscpy_s((wchar_t *)m_ModuleName, len + 1, (wchar_t *)modName); - - m_MetadataBase = baseAddress; - m_MetadataSize = mdSize; - - m_next = m_MDTrackers; - m_MDTrackers = this; - - memset (m_mdSections, 0, NUM_MD_SECTIONS*sizeof(BYTE*)); - memset (m_mdSectionSize, 0, NUM_MD_SECTIONS*sizeof(SIZE_T)); - - moduleNameHolder.SuppressRelease(); - } - - ~MetaDataTracker() - { - CONTRACTL - { - DESTRUCTOR_CHECK; - NOTHROW; - GC_NOTRIGGER; - FORBID_FAULT; - SO_INTOLERANT; - } - CONTRACTL_END; - - // Surely if we are dying, we are being deactivated as well - Deactivate(); - - if (m_ModuleName) - delete m_ModuleName; - - // Remove this tracker from the global list of trackers - - MetaDataTracker *mdMod = m_MDTrackers; - - _ASSERTE (mdMod && "Trying to delete metadata tracker where none exist"); - - // If ours is the first tracker - if (mdMod == this) - { - m_MDTrackers = mdMod->m_next; - mdMod->m_next = NULL; - } - else - { - // Now traverse thru the list and maintain the prev ptr. - MetaDataTracker *mdModPrev = mdMod; - mdMod = mdMod->m_next; - while(mdMod) - { - if (mdMod == this) - { - mdModPrev->m_next = mdMod->m_next; - mdMod->m_next = NULL; - break; - } - mdModPrev = mdMod; - mdMod = mdMod->m_next; - } - } - } - - static void Enable() - { LIMITED_METHOD_CONTRACT; - s_bEnabled = TRUE; - } - - static void Disable() - { LIMITED_METHOD_CONTRACT; - s_bEnabled = FALSE; - } - - static BOOL Enabled() - { LIMITED_METHOD_CONTRACT; - return s_bEnabled; - } - - static void NoteSection(DWORD secNum, void *address, size_t size, size_t rowSize) - { - STATIC_CONTRACT_NOTHROW; - STATIC_CONTRACT_GC_NOTRIGGER; - STATIC_CONTRACT_SO_NOT_MAINLINE; - - if (!Enabled()) - return; - - MetaDataTracker *mdMod = m_MDTrackers; - while( mdMod) - { - if (mdMod->NoteSectionInModule(secNum, address, size, rowSize)) - return; - - mdMod = mdMod->m_next; - } - } - - // With logging disabled this quickly returns the address that was passed in - // this allows us to inline a smaller amount of code at callsites. - __forceinline static void* NoteAccess(void *address) - { - WRAPPER_NO_CONTRACT; - - if (!Enabled()) - return address; - - return NoteAccessWorker(address); - } - - __declspec(noinline) static void* NoteAccessWorker(void *address) - { - STATIC_CONTRACT_NOTHROW; - STATIC_CONTRACT_GC_NOTRIGGER; - STATIC_CONTRACT_SO_NOT_MAINLINE; - - if (s_IBCLogMetaDataAccess != NULL) - s_IBCLogMetaDataAccess(address); - - return address; - } - - // See the comment above CMiniMdRW::GetHotMetadataTokensSearchAware - __forceinline static void NoteSearch(void *result) - { - WRAPPER_NO_CONTRACT; - - if (!Enabled()) - return; - - NoteSearchWorker(result); - } - - __declspec(noinline) static void NoteSearchWorker(void *result) - { - STATIC_CONTRACT_NOTHROW; - STATIC_CONTRACT_GC_NOTRIGGER; - STATIC_CONTRACT_SO_NOT_MAINLINE; - - if (s_IBCLogMetaDataSearch != NULL && result != NULL) - s_IBCLogMetaDataSearch(result); - } - - static MetaDataTracker * FindTracker(BYTE *_MDBaseAddress) - { - LIMITED_METHOD_CONTRACT; - - if (!Enabled()) - return NULL; - - MetaDataTracker *mdMod = m_MDTrackers; - while( mdMod) - { - if (mdMod->m_MetadataBase == _MDBaseAddress) - return mdMod; - - mdMod = mdMod->m_next; - } - - return NULL; - } - - void Activate() - { - LIMITED_METHOD_CONTRACT; - - m_bActivated = TRUE; - } - - void Deactivate() - { - LIMITED_METHOD_CONTRACT; - - m_bActivated = FALSE; - } - - BOOL IsActivated() - { - LIMITED_METHOD_CONTRACT; - - return m_bActivated; - } - - static MetaDataTracker *GetOrCreateMetaDataTracker (BYTE *baseAddress, DWORD mdSize, LPCWSTR modName) - { - CONTRACT(MetaDataTracker *) - { - THROWS; - GC_NOTRIGGER; - INJECT_FAULT(ThrowOutOfMemory()); - POSTCONDITION(CheckPointer(RETVAL, NULL_OK)); - SO_INTOLERANT; - } - CONTRACT_END; - - MetaDataTracker *pTracker = NULL; - - if (MetaDataTracker::Enabled()) - { - pTracker = MetaDataTracker::FindTracker(baseAddress); - if (!pTracker) - { - FAULT_NOT_FATAL(); // It's ok - an OOM here is nonfatal - pTracker = new MetaDataTracker(baseAddress, mdSize, modName); - } - pTracker->Activate(); - } - - RETURN pTracker; - } - - // Map a metadata address to a token for the purposes of the IBCLogger - static mdToken MapAddrToToken(const void *addr) - { - WRAPPER_NO_CONTRACT; - - mdToken token = 0; - for (MetaDataTracker *mdMod = m_MDTrackers; mdMod; mdMod = mdMod->m_next) - { - token = mdMod->MapAddrToTokenInModule(addr); - if (token != 0) - break; - } - return token; - } - - -private: - - // *************************************************************************** - // Helper functions - // *************************************************************************** - - BOOL NoteSectionInModule(DWORD secNum, void *address, size_t size, size_t rowSize) - { - WRAPPER_NO_CONTRACT; - - PREFAST_ASSUME(secNum < NUM_MD_SECTIONS); - - if (address < m_MetadataBase || address >= (m_MetadataBase + m_MetadataSize)) - return FALSE; - - // This address range belongs to us but the tracker is not activated. - if (!IsActivated()) - { - // _ASSERTE (!"Metadata Tracker not active but trying to access metadata"); - return TRUE; - } - - m_mdSections[secNum] = (BYTE *)address; - m_mdSectionSize[secNum] = size; - m_mdSectionRowSize[secNum] = rowSize; - - return TRUE; - } - - // Map a metadata address to a fake token for the purposes of the IBCLogger - mdToken MapAddrToTokenInModule(const void *addr) - { - LIMITED_METHOD_CONTRACT; - - if (!IsActivated()) - return 0; - - BYTE *address = (BYTE *)addr; - - if (address < m_MetadataBase || address >= (m_MetadataBase + m_MetadataSize)) - return 0; - - for (DWORD secNum = 0; secNum < NUM_MD_SECTIONS; secNum++) - { - if ((address >= m_mdSections[secNum]) && (address < m_mdSections[secNum] + m_mdSectionSize[secNum])) - { - DWORD rid = (DWORD)((address - m_mdSections[secNum])/m_mdSectionRowSize[secNum]); - if (secNum < TBL_COUNT) - rid++; - return TokenFromRid(rid, (secNum<<24)); - } - } - return 0; - } -}; - -#else // METADATATRACKER_ENABLED - -#define METADATATRACKER_ONLY(s) - -#endif // METADATATRACKER_ENABLED - -#endif // _METADATATRACKER_H_ diff --git a/src/inc/metamodelpub.h b/src/inc/metamodelpub.h deleted file mode 100644 index ba68ae0c3..000000000 --- a/src/inc/metamodelpub.h +++ /dev/null @@ -1,1672 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -//***************************************************************************** -// MetaModelPub.h -- header file for Common Language Runtime metadata. -// - -// -//***************************************************************************** - -#ifndef _METAMODELPUB_H_ -#define _METAMODELPUB_H_ - -#if _MSC_VER >= 1100 -# pragma once -#endif - -#include -#include - -#ifndef lengthof -# define lengthof(x) (sizeof(x)/sizeof((x)[0])) -#endif - -template inline T Align4(T p) -{ - LIMITED_METHOD_CONTRACT; - - INT_PTR i = (INT_PTR)p; - i = (i+(3)) & ~3; - return (T)i; -} - -typedef ULONG RID; - -// check if a rid is valid or not -#define InvalidRid(rid) ((rid) == 0) - -#ifndef METADATA_FIELDS_PROTECTION -#define METADATA_FIELDS_PROTECTION public -#endif - -//***************************************************************************** -// Record definitions. Records have some combination of fixed size fields and -// variable sized fields (actually, constant across a database, but variable -// between databases). -// -// In this section we define record definitions which include the fixed size -// fields and an enumeration of the variable sized fields. -// -// Naming is as follows: -// Given some table "Xyz": -// class XyzRec { public: -// SOMETYPE m_SomeField; -// // rest of the fixed fields. -// enum { COL_Xyz_SomeOtherField, -// // rest of the fields, enumerated. -// COL_Xyz_COUNT }; -// }; -// -// The important features are the class name (XyzRec), the enumerations -// (COL_Xyz_FieldName), and the enumeration count (COL_Xyz_COUNT). -// -// THESE NAMING CONVENTIONS ARE CARVED IN STONE! DON'T TRY TO BE CREATIVE! -// -//***************************************************************************** -// Have the compiler generate two byte alignment. Be careful to manually lay -// out the fields for proper alignment. The alignment for variable-sized -// fields will be computed at save time. -#include - -// Non-sparse tables. -class ModuleRec -{ -METADATA_FIELDS_PROTECTION: - USHORT m_Generation; // ENC generation. -public: - enum { - COL_Generation, - - COL_Name, - COL_Mvid, - COL_EncId, - COL_EncBaseId, - COL_COUNT, - COL_KEY - }; - USHORT GetGeneration() - { - LIMITED_METHOD_CONTRACT; - - return GET_UNALIGNED_VAL16(&m_Generation); - } - void SetGeneration(USHORT Generation) - { - LIMITED_METHOD_CONTRACT; - - m_Generation = VAL16(Generation); - } -}; - -class TypeRefRec -{ -public: - enum { - COL_ResolutionScope, // mdModuleRef or mdAssemblyRef. - COL_Name, - COL_Namespace, - COL_COUNT, - COL_KEY - }; -}; - -class TypeDefRec -{ -METADATA_FIELDS_PROTECTION: - ULONG m_Flags; // Flags for this TypeDef -public: - enum { - COL_Flags, - - COL_Name, // offset into string pool. - COL_Namespace, - COL_Extends, // coded token to typedef/typeref. - COL_FieldList, // rid of first field. - COL_MethodList, // rid of first method. - COL_COUNT, - COL_KEY - }; - ULONG GetFlags() - { - LIMITED_METHOD_CONTRACT; - - return GET_UNALIGNED_VAL32(&m_Flags); - } - void SetFlags(ULONG Flags) - { - LIMITED_METHOD_CONTRACT; - - m_Flags = VAL32(Flags); - } - void AddFlags(ULONG Flags) - { - LIMITED_METHOD_CONTRACT; - - m_Flags |= VAL32(Flags); - } - void RemoveFlags(ULONG Flags) - { - LIMITED_METHOD_CONTRACT; - - m_Flags &= ~VAL32(Flags); - } - -}; - -class FieldPtrRec -{ -public: - enum { - COL_Field, - COL_COUNT, - COL_KEY - }; -}; - -class FieldRec -{ -METADATA_FIELDS_PROTECTION: - USHORT m_Flags; // Flags for the field. -public: - enum { - COL_Flags, - - COL_Name, - COL_Signature, - COL_COUNT, - COL_KEY - }; - USHORT GetFlags() - { - LIMITED_METHOD_CONTRACT; - - return GET_UNALIGNED_VAL16(&m_Flags); - } - void SetFlags(ULONG Flags) - { - LIMITED_METHOD_CONTRACT; - - m_Flags = (USHORT)VAL16(Flags); - } - void AddFlags(ULONG Flags) - { - LIMITED_METHOD_CONTRACT; - - m_Flags |= (USHORT)VAL16(Flags); - } - void RemoveFlags(ULONG Flags) - { - LIMITED_METHOD_CONTRACT; - - m_Flags &= (USHORT)~VAL16(Flags); - } - - -}; - -class MethodPtrRec -{ -public: - enum { - COL_Method, - COL_COUNT, - COL_KEY - }; -}; - -class MethodRec -{ -METADATA_FIELDS_PROTECTION: - ULONG m_RVA; // RVA of the Method. - USHORT m_ImplFlags; // Descr flags of the Method. - USHORT m_Flags; // Flags for the Method. -public: - enum { - COL_RVA, - COL_ImplFlags, - COL_Flags, - - COL_Name, - COL_Signature, - COL_ParamList, // Rid of first param. - COL_COUNT, - COL_KEY - }; - - void Copy(MethodRec *pFrom) - { - LIMITED_METHOD_CONTRACT; - - m_RVA = pFrom->m_RVA; - m_ImplFlags = pFrom->m_ImplFlags; - m_Flags = pFrom->m_Flags; - } - - ULONG GetRVA() - { - LIMITED_METHOD_CONTRACT; - - return GET_UNALIGNED_VAL32(&m_RVA); - } - void SetRVA(ULONG RVA) - { - LIMITED_METHOD_CONTRACT; - - m_RVA = VAL32(RVA); - } - - USHORT GetImplFlags() - { - LIMITED_METHOD_CONTRACT; - - return GET_UNALIGNED_VAL16(&m_ImplFlags); - } - void SetImplFlags(USHORT ImplFlags) - { - LIMITED_METHOD_CONTRACT; - - m_ImplFlags = VAL16(ImplFlags); - } - void AddImplFlags(USHORT ImplFlags) - { - LIMITED_METHOD_CONTRACT; - - m_ImplFlags |= VAL16(ImplFlags); - } - void RemoveImplFlags(USHORT ImplFlags) - { - LIMITED_METHOD_CONTRACT; - - m_ImplFlags &= ~VAL16(ImplFlags); - } - - - USHORT GetFlags() - { - LIMITED_METHOD_CONTRACT; - - return GET_UNALIGNED_VAL16(&m_Flags); - } - void SetFlags(ULONG Flags) - { - LIMITED_METHOD_CONTRACT; - - m_Flags = (USHORT)VAL16(Flags); - } - void AddFlags(ULONG Flags) - { - LIMITED_METHOD_CONTRACT; - - m_Flags |= (USHORT)VAL16(Flags); - } - void RemoveFlags(ULONG Flags) - { - LIMITED_METHOD_CONTRACT; - - m_Flags &= (USHORT)~VAL16(Flags); - } -}; - -class ParamPtrRec -{ -public: - enum { - COL_Param, - COL_COUNT, - COL_KEY - }; -}; - -class ParamRec -{ -METADATA_FIELDS_PROTECTION: - USHORT m_Flags; // Flags for this Param. - USHORT m_Sequence; // Sequence # of param. 0 - return value. -public: - enum { - COL_Flags, - COL_Sequence, - - COL_Name, // Name of the param. - COL_COUNT, - COL_KEY - }; - - void Copy(ParamRec *pFrom) - { - LIMITED_METHOD_CONTRACT; - - m_Flags = pFrom->m_Flags; - m_Sequence = pFrom->m_Sequence; - } - - USHORT GetFlags() - { - LIMITED_METHOD_CONTRACT; - - return GET_UNALIGNED_VAL16(&m_Flags); - } - void SetFlags(ULONG Flags) - { - LIMITED_METHOD_CONTRACT; - - m_Flags = (USHORT)VAL16(Flags); - } - void AddFlags(ULONG Flags) - { - LIMITED_METHOD_CONTRACT; - - m_Flags |= (USHORT)VAL16(Flags); - } - void RemoveFlags(ULONG Flags) - { - LIMITED_METHOD_CONTRACT; - - m_Flags &= (USHORT)~VAL16(Flags); - } - - USHORT GetSequence() - { - LIMITED_METHOD_CONTRACT; - - return GET_UNALIGNED_VAL16(&m_Sequence); - } - void SetSequence(USHORT Sequence) - { - LIMITED_METHOD_CONTRACT; - - m_Sequence = VAL16(Sequence); - } - -}; - -class InterfaceImplRec -{ -public: - enum { - COL_Class, // Rid of class' TypeDef. - COL_Interface, // Coded rid of implemented interface. - COL_COUNT, - COL_KEY = COL_Class - }; -}; - -class MemberRefRec -{ -public: - enum { - COL_Class, // Rid of TypeDef. - COL_Name, - COL_Signature, - COL_COUNT, - COL_KEY - }; -}; - -class StandAloneSigRec -{ -public: - enum { - COL_Signature, - COL_COUNT, - COL_KEY - }; -}; - -// Sparse tables. These contain modifiers for tables above. -class ConstantRec -{ -METADATA_FIELDS_PROTECTION: - BYTE m_Type; // Type of the constant. - BYTE m_PAD1; -public: - enum { - COL_Type, - - COL_Parent, // Coded rid of object (param, field). - COL_Value, // Index into blob pool. - COL_COUNT, - COL_KEY = COL_Parent - }; - BYTE GetType() - { - LIMITED_METHOD_CONTRACT; - - return m_Type; - } - void SetType(BYTE Type) - { - LIMITED_METHOD_CONTRACT; - - m_Type = Type; - } -}; - -class CustomAttributeRec -{ -public: - enum { - COL_Parent, // Coded rid of any object. - COL_Type, // TypeDef or TypeRef. - COL_Value, // Blob. - COL_COUNT, - COL_KEY = COL_Parent - }; -}; - -class FieldMarshalRec -{ -public: - enum { - COL_Parent, // Coded rid of field or param. - COL_NativeType, - COL_COUNT, - COL_KEY = COL_Parent - }; -}; - -class DeclSecurityRec -{ -METADATA_FIELDS_PROTECTION: - USHORT m_Action; -public: - enum { - COL_Action, - - COL_Parent, - COL_PermissionSet, - COL_COUNT, - COL_KEY = COL_Parent - }; - - void Copy(DeclSecurityRec *pFrom) - { - LIMITED_METHOD_CONTRACT; - - m_Action = pFrom->m_Action; - } - USHORT GetAction() - { - LIMITED_METHOD_CONTRACT; - - return GET_UNALIGNED_VAL16(&m_Action); - } - void SetAction(USHORT Action) - { - LIMITED_METHOD_CONTRACT; - - m_Action = VAL16(Action); - } -}; - - -class ClassLayoutRec -{ -METADATA_FIELDS_PROTECTION: - USHORT m_PackingSize; - ULONG m_ClassSize; -public: - enum { - COL_PackingSize, - COL_ClassSize, - - COL_Parent, // Rid of TypeDef. - COL_COUNT, - COL_KEY = COL_Parent - }; - - void Copy(ClassLayoutRec *pFrom) - { - LIMITED_METHOD_CONTRACT; - - m_PackingSize = pFrom->m_PackingSize; - m_ClassSize = pFrom->m_ClassSize; - } - USHORT GetPackingSize() - { - LIMITED_METHOD_CONTRACT; - - return GET_UNALIGNED_VAL16(&m_PackingSize); - } - void SetPackingSize(USHORT PackingSize) - { - LIMITED_METHOD_CONTRACT; - - m_PackingSize = VAL16(PackingSize); - } - - ULONG GetClassSize() - { - LIMITED_METHOD_CONTRACT; - - return GET_UNALIGNED_VAL32(&m_ClassSize); - } - void SetClassSize(ULONG ClassSize) - { - LIMITED_METHOD_CONTRACT; - - m_ClassSize = VAL32(ClassSize); - } -}; - -class FieldLayoutRec -{ -METADATA_FIELDS_PROTECTION: - ULONG m_OffSet; -public: - enum { - COL_OffSet, - - COL_Field, - COL_COUNT, - COL_KEY = COL_Field - }; - - void Copy(FieldLayoutRec *pFrom) - { - LIMITED_METHOD_CONTRACT; - - m_OffSet = pFrom->m_OffSet; - } - ULONG GetOffSet() - { - LIMITED_METHOD_CONTRACT; - - return GET_UNALIGNED_VAL32(&m_OffSet); - } - void SetOffSet(ULONG Offset) - { - LIMITED_METHOD_CONTRACT; - - m_OffSet = VAL32(Offset); - } -}; - -class EventMapRec -{ -public: - enum { - COL_Parent, - COL_EventList, // rid of first event. - COL_COUNT, - COL_KEY - }; -}; - -class EventPtrRec -{ -public: - enum { - COL_Event, - COL_COUNT, - COL_KEY - }; -}; - -class EventRec -{ -METADATA_FIELDS_PROTECTION: - USHORT m_EventFlags; -public: - enum { - COL_EventFlags, - - COL_Name, - COL_EventType, - COL_COUNT, - COL_KEY - }; - USHORT GetEventFlags() - { - LIMITED_METHOD_CONTRACT; - - return GET_UNALIGNED_VAL16(&m_EventFlags); - } - void SetEventFlags(USHORT EventFlags) - { - LIMITED_METHOD_CONTRACT; - - m_EventFlags = VAL16(EventFlags); - } - void AddEventFlags(USHORT EventFlags) - { - LIMITED_METHOD_CONTRACT; - - m_EventFlags |= VAL16(EventFlags); - } -}; - -class PropertyMapRec -{ -public: - enum { - COL_Parent, - COL_PropertyList, // rid of first property. - COL_COUNT, - COL_KEY - }; -}; - -class PropertyPtrRec -{ -public: - enum { - COL_Property, - COL_COUNT, - COL_KEY - }; -}; - -class PropertyRec -{ -METADATA_FIELDS_PROTECTION: - USHORT m_PropFlags; -public: - enum { - COL_PropFlags, - - COL_Name, - COL_Type, - COL_COUNT, - COL_KEY - }; - USHORT GetPropFlags() - { - LIMITED_METHOD_CONTRACT; - - return GET_UNALIGNED_VAL16(&m_PropFlags); - } - void SetPropFlags(USHORT PropFlags) - { - LIMITED_METHOD_CONTRACT; - - m_PropFlags = VAL16(PropFlags); - } - void AddPropFlags(USHORT PropFlags) - { - LIMITED_METHOD_CONTRACT; - - m_PropFlags |= VAL16(PropFlags); - } -}; - -class MethodSemanticsRec -{ -METADATA_FIELDS_PROTECTION: - USHORT m_Semantic; -public: - enum { - COL_Semantic, - - COL_Method, - COL_Association, - COL_COUNT, - COL_KEY = COL_Association - }; - USHORT GetSemantic() - { - LIMITED_METHOD_CONTRACT; - - return GET_UNALIGNED_VAL16(&m_Semantic); - } - void SetSemantic(USHORT Semantic) - { - LIMITED_METHOD_CONTRACT; - - m_Semantic = VAL16(Semantic); - } -}; - -class MethodImplRec -{ -public: - enum { - COL_Class, // TypeDef where the MethodBody lives. - COL_MethodBody, // MethodDef or MemberRef. - COL_MethodDeclaration, // MethodDef or MemberRef. - COL_COUNT, - COL_KEY = COL_Class - }; -}; - -class ModuleRefRec -{ -public: - enum { - COL_Name, - COL_COUNT, - COL_KEY - }; -}; - -class TypeSpecRec -{ -public: - enum { - COL_Signature, - COL_COUNT, - COL_KEY - }; -}; - -class ImplMapRec -{ -METADATA_FIELDS_PROTECTION: - USHORT m_MappingFlags; -public: - enum { - COL_MappingFlags, - - COL_MemberForwarded, // mdField or mdMethod. - COL_ImportName, - COL_ImportScope, // mdModuleRef. - COL_COUNT, - COL_KEY = COL_MemberForwarded - }; - USHORT GetMappingFlags() - { - LIMITED_METHOD_CONTRACT; - - return GET_UNALIGNED_VAL16(&m_MappingFlags); - } - void SetMappingFlags(USHORT MappingFlags) - { - LIMITED_METHOD_CONTRACT; - - m_MappingFlags = VAL16(MappingFlags); - } - -}; - -class FieldRVARec -{ -METADATA_FIELDS_PROTECTION: - ULONG m_RVA; -public: - enum{ - COL_RVA, - - COL_Field, - COL_COUNT, - COL_KEY = COL_Field - }; - - void Copy(FieldRVARec *pFrom) - { - LIMITED_METHOD_CONTRACT; - - m_RVA = pFrom->m_RVA; - } - ULONG GetRVA() - { - LIMITED_METHOD_CONTRACT; - - return GET_UNALIGNED_VAL32(&m_RVA); - } - void SetRVA(ULONG RVA) - { - LIMITED_METHOD_CONTRACT; - - m_RVA = VAL32(RVA); - } -}; - -class ENCLogRec -{ -METADATA_FIELDS_PROTECTION: - ULONG m_Token; // Token, or like a token, but with (ixTbl|0x80) instead of token type. - ULONG m_FuncCode; // Function code describing the nature of ENC change. -public: - enum { - COL_Token, - COL_FuncCode, - COL_COUNT, - COL_KEY - }; - ULONG GetToken() - { - LIMITED_METHOD_CONTRACT; - - return GET_UNALIGNED_VAL32(&m_Token); - } - void SetToken(ULONG Token) - { - LIMITED_METHOD_CONTRACT; - - m_Token = VAL32(Token); - } - - ULONG GetFuncCode() - { - LIMITED_METHOD_CONTRACT; - - return GET_UNALIGNED_VAL32(&m_FuncCode); - } - void SetFuncCode(ULONG FuncCode) - { - LIMITED_METHOD_CONTRACT; - - m_FuncCode = VAL32(FuncCode); - } -}; - -class ENCMapRec -{ -METADATA_FIELDS_PROTECTION: - ULONG m_Token; // Token, or like a token, but with (ixTbl|0x80) instead of token type. -public: - enum { - COL_Token, - COL_COUNT, - COL_KEY - }; - ULONG GetToken() - { - LIMITED_METHOD_CONTRACT; - - return GET_UNALIGNED_VAL32(&m_Token); - } - void SetToken(ULONG Token) - { - LIMITED_METHOD_CONTRACT; - - m_Token = VAL32(Token); - } -}; - -// Assembly tables. - -class AssemblyRec -{ -METADATA_FIELDS_PROTECTION: - ULONG m_HashAlgId; - USHORT m_MajorVersion; - USHORT m_MinorVersion; - USHORT m_BuildNumber; - USHORT m_RevisionNumber; - ULONG m_Flags; -public: - enum { - COL_HashAlgId, - COL_MajorVersion, - COL_MinorVersion, - COL_BuildNumber, - COL_RevisionNumber, - COL_Flags, - - COL_PublicKey, // Public key identifying the publisher - COL_Name, - COL_Locale, - COL_COUNT, - COL_KEY - }; - - void Copy(AssemblyRec *pFrom) - { - LIMITED_METHOD_CONTRACT; - - m_HashAlgId = pFrom->m_HashAlgId; - m_MajorVersion = pFrom->m_MajorVersion; - m_MinorVersion = pFrom->m_MinorVersion; - m_BuildNumber = pFrom->m_BuildNumber; - m_RevisionNumber = pFrom->m_RevisionNumber; - m_Flags = pFrom->m_Flags; - } - - ULONG GetHashAlgId() - { - LIMITED_METHOD_CONTRACT; - - return GET_UNALIGNED_VAL32(&m_HashAlgId); - } - void SetHashAlgId (ULONG HashAlgId) - { - LIMITED_METHOD_CONTRACT; - - m_HashAlgId = VAL32(HashAlgId); - } - - USHORT GetMajorVersion() - { - LIMITED_METHOD_CONTRACT; - - return GET_UNALIGNED_VAL16(&m_MajorVersion); - } - void SetMajorVersion (USHORT MajorVersion) - { - LIMITED_METHOD_CONTRACT; - - m_MajorVersion = VAL16(MajorVersion); - } - - USHORT GetMinorVersion() - { - LIMITED_METHOD_CONTRACT; - - return GET_UNALIGNED_VAL16(&m_MinorVersion); - } - void SetMinorVersion (USHORT MinorVersion) - { - LIMITED_METHOD_CONTRACT; - - m_MinorVersion = VAL16(MinorVersion); - } - - USHORT GetBuildNumber() - { - LIMITED_METHOD_CONTRACT; - - return GET_UNALIGNED_VAL16(&m_BuildNumber); - } - void SetBuildNumber (USHORT BuildNumber) - { - LIMITED_METHOD_CONTRACT; - - m_BuildNumber = VAL16(BuildNumber); - } - - USHORT GetRevisionNumber() - { - LIMITED_METHOD_CONTRACT; - - return GET_UNALIGNED_VAL16(&m_RevisionNumber); - } - void SetRevisionNumber (USHORT RevisionNumber) - { - LIMITED_METHOD_CONTRACT; - - m_RevisionNumber = VAL16(RevisionNumber); - } - - ULONG GetFlags() - { - LIMITED_METHOD_CONTRACT; - - return GET_UNALIGNED_VAL32(&m_Flags); - } - void SetFlags (ULONG Flags) - { - LIMITED_METHOD_CONTRACT; - - m_Flags = VAL32(Flags); - } - -}; - -class AssemblyProcessorRec -{ -METADATA_FIELDS_PROTECTION: - ULONG m_Processor; -public: - enum { - COL_Processor, - - COL_COUNT, - COL_KEY - }; - ULONG GetProcessor() - { - LIMITED_METHOD_CONTRACT; - - return GET_UNALIGNED_VAL32(&m_Processor); - } - void SetProcessor(ULONG Processor) - { - LIMITED_METHOD_CONTRACT; - - m_Processor = VAL32(Processor); - } -}; - -class AssemblyOSRec -{ -METADATA_FIELDS_PROTECTION: - ULONG m_OSPlatformId; - ULONG m_OSMajorVersion; - ULONG m_OSMinorVersion; -public: - enum { - COL_OSPlatformId, - COL_OSMajorVersion, - COL_OSMinorVersion, - - COL_COUNT, - COL_KEY - }; - ULONG GetOSPlatformId() - { - LIMITED_METHOD_CONTRACT; - - return GET_UNALIGNED_VAL32(&m_OSPlatformId); - } - void SetOSPlatformId(ULONG OSPlatformId) - { - LIMITED_METHOD_CONTRACT; - - m_OSPlatformId = VAL32(OSPlatformId); - } - - ULONG GetOSMajorVersion() - { - LIMITED_METHOD_CONTRACT; - - return GET_UNALIGNED_VAL32(&m_OSMajorVersion); - } - void SetOSMajorVersion(ULONG OSMajorVersion) - { - LIMITED_METHOD_CONTRACT; - - m_OSMajorVersion = VAL32(OSMajorVersion); - } - - ULONG GetOSMinorVersion() - { - LIMITED_METHOD_CONTRACT; - - return GET_UNALIGNED_VAL32(&m_OSMinorVersion); - } - void SetOSMinorVersion(ULONG OSMinorVersion) - { - LIMITED_METHOD_CONTRACT; - - m_OSMinorVersion = VAL32(OSMinorVersion); - } - -}; - -class AssemblyRefRec -{ -METADATA_FIELDS_PROTECTION: - USHORT m_MajorVersion; - USHORT m_MinorVersion; - USHORT m_BuildNumber; - USHORT m_RevisionNumber; - ULONG m_Flags; -public: - enum { - COL_MajorVersion, - COL_MinorVersion, - COL_BuildNumber, - COL_RevisionNumber, - COL_Flags, - - COL_PublicKeyOrToken, // The public key or token identifying the publisher of the Assembly. - COL_Name, - COL_Locale, - COL_HashValue, - COL_COUNT, - COL_KEY - }; - void Copy(AssemblyRefRec *pFrom) - { - LIMITED_METHOD_CONTRACT; - - m_MajorVersion = pFrom->m_MajorVersion; - m_MinorVersion = pFrom->m_MinorVersion; - m_BuildNumber = pFrom->m_BuildNumber; - m_RevisionNumber = pFrom->m_RevisionNumber; - m_Flags = pFrom->m_Flags; - } - USHORT GetMajorVersion() - { - LIMITED_METHOD_CONTRACT; - - return GET_UNALIGNED_VAL16(&m_MajorVersion); - } - void SetMajorVersion(USHORT MajorVersion) - { - LIMITED_METHOD_CONTRACT; - - m_MajorVersion = VAL16(MajorVersion); - } - - USHORT GetMinorVersion() - { - LIMITED_METHOD_CONTRACT; - - return GET_UNALIGNED_VAL16(&m_MinorVersion); - } - void SetMinorVersion(USHORT MinorVersion) - { - LIMITED_METHOD_CONTRACT; - - m_MinorVersion = VAL16(MinorVersion); - } - - USHORT GetBuildNumber() - { - LIMITED_METHOD_CONTRACT; - - return GET_UNALIGNED_VAL16(&m_BuildNumber); - } - void SetBuildNumber(USHORT BuildNumber) - { - LIMITED_METHOD_CONTRACT; - - m_BuildNumber = VAL16(BuildNumber); - } - - USHORT GetRevisionNumber() - { - LIMITED_METHOD_CONTRACT; - - return GET_UNALIGNED_VAL16(&m_RevisionNumber); - } - void SetRevisionNumber(USHORT RevisionNumber) - { - LIMITED_METHOD_CONTRACT; - - m_RevisionNumber = RevisionNumber; - } - - ULONG GetFlags() - { - LIMITED_METHOD_CONTRACT; - - return GET_UNALIGNED_VAL32(&m_Flags); - } - void SetFlags(ULONG Flags) - { - LIMITED_METHOD_CONTRACT; - - m_Flags = VAL32(Flags); - } - -}; - -class AssemblyRefProcessorRec -{ -METADATA_FIELDS_PROTECTION: - ULONG m_Processor; -public: - enum { - COL_Processor, - - COL_AssemblyRef, // mdtAssemblyRef - COL_COUNT, - COL_KEY - }; - ULONG GetProcessor() - { - LIMITED_METHOD_CONTRACT; - - return GET_UNALIGNED_VAL32(&m_Processor); - } - void SetProcessor(ULONG Processor) - { - LIMITED_METHOD_CONTRACT; - - m_Processor = VAL32(Processor); - } -}; - -class AssemblyRefOSRec -{ -METADATA_FIELDS_PROTECTION: - ULONG m_OSPlatformId; - ULONG m_OSMajorVersion; - ULONG m_OSMinorVersion; -public: - enum { - COL_OSPlatformId, - COL_OSMajorVersion, - COL_OSMinorVersion, - - COL_AssemblyRef, // mdtAssemblyRef. - COL_COUNT, - COL_KEY - }; - ULONG GetOSPlatformId() - { - LIMITED_METHOD_CONTRACT; - - return GET_UNALIGNED_VAL32(&m_OSPlatformId); - } - void SetOSPlatformId(ULONG OSPlatformId) - { - LIMITED_METHOD_CONTRACT; - - m_OSPlatformId = VAL32(OSPlatformId); - } - - ULONG GetOSMajorVersion() - { - LIMITED_METHOD_CONTRACT; - - return GET_UNALIGNED_VAL32(&m_OSMajorVersion); - } - void SetOSMajorVersion(ULONG OSMajorVersion) - { - LIMITED_METHOD_CONTRACT; - - m_OSMajorVersion = VAL32(OSMajorVersion); - } - - ULONG GetOSMinorVersion() - { - LIMITED_METHOD_CONTRACT; - - return GET_UNALIGNED_VAL32(&m_OSMinorVersion); - } - void SetOSMinorVersion(ULONG OSMinorVersion) - { - LIMITED_METHOD_CONTRACT; - - m_OSMinorVersion = VAL32(OSMinorVersion); - } -}; - -class FileRec -{ -METADATA_FIELDS_PROTECTION: - ULONG m_Flags; -public: - enum { - COL_Flags, - - COL_Name, - COL_HashValue, - COL_COUNT, - COL_KEY - }; - void Copy(FileRec *pFrom) - { - LIMITED_METHOD_CONTRACT; - - m_Flags = pFrom->m_Flags; - } - ULONG GetFlags() - { - LIMITED_METHOD_CONTRACT; - - return GET_UNALIGNED_VAL32(&m_Flags); - } - void SetFlags(ULONG Flags) - { - LIMITED_METHOD_CONTRACT; - - m_Flags = VAL32(Flags); - } -}; - -class ExportedTypeRec -{ -METADATA_FIELDS_PROTECTION: - ULONG m_Flags; - ULONG m_TypeDefId; -public: - enum { - COL_Flags, - COL_TypeDefId, - - COL_TypeName, - COL_TypeNamespace, - COL_Implementation, // mdFile or mdAssemblyRef. - COL_COUNT, - COL_KEY - }; - void Copy(ExportedTypeRec *pFrom) - { - LIMITED_METHOD_CONTRACT; - - m_Flags = pFrom->m_Flags; - m_TypeDefId = pFrom->m_TypeDefId; - } - ULONG GetFlags() - { - LIMITED_METHOD_CONTRACT; - - return GET_UNALIGNED_VAL32(&m_Flags); - } - void SetFlags(ULONG Flags) - { - LIMITED_METHOD_CONTRACT; - - m_Flags = VAL32(Flags); - } - - ULONG GetTypeDefId() - { - LIMITED_METHOD_CONTRACT; - - return GET_UNALIGNED_VAL32(&m_TypeDefId); - } - void SetTypeDefId(ULONG TypeDefId) - { - LIMITED_METHOD_CONTRACT; - - m_TypeDefId = VAL32(TypeDefId); - } -}; - -class ManifestResourceRec -{ -METADATA_FIELDS_PROTECTION: - ULONG m_Offset; - ULONG m_Flags; -public: - enum { - COL_Offset, - COL_Flags, - - COL_Name, - COL_Implementation, // mdFile or mdAssemblyRef. - COL_COUNT, - COL_KEY - }; - void Copy(ManifestResourceRec *pFrom) - { - LIMITED_METHOD_CONTRACT; - - m_Flags = pFrom->m_Flags; - m_Offset = pFrom->m_Offset; - } - - ULONG GetOffset() - { - LIMITED_METHOD_CONTRACT; - - return GET_UNALIGNED_VAL32(&m_Offset); - } - void SetOffset(ULONG Offset) - { - LIMITED_METHOD_CONTRACT; - - m_Offset = VAL32(Offset); - } - - ULONG GetFlags() - { - LIMITED_METHOD_CONTRACT; - - return GET_UNALIGNED_VAL32(&m_Flags); - } - void SetFlags(ULONG Flags) - { - LIMITED_METHOD_CONTRACT; - - m_Flags = VAL32(Flags); - } - -}; - -// End Assembly Tables. - -class NestedClassRec -{ -public: - enum { - COL_NestedClass, - COL_EnclosingClass, - COL_COUNT, - COL_KEY = COL_NestedClass - }; -}; - -// Generics - - -class GenericParamRec -{ -METADATA_FIELDS_PROTECTION: - USHORT m_Number; // index; zero = first var - USHORT m_Flags; // index; zero = first var -public: - enum { - - COL_Number, // index; zero = first var - COL_Flags, // flags, for future use - COL_Owner, // typeDef/methodDef - COL_Name, // Purely descriptive, not used for binding purposes - COL_COUNT, - COL_KEY = COL_Owner - }; - - USHORT GetNumber() - { - LIMITED_METHOD_CONTRACT; - - return GET_UNALIGNED_VAL16(&m_Number); - } - void SetNumber(USHORT Number) - { - LIMITED_METHOD_CONTRACT; - - m_Number = VAL16(Number); - } - - USHORT GetFlags() - { - LIMITED_METHOD_CONTRACT; - - return GET_UNALIGNED_VAL16(&m_Flags); - } - void SetFlags(USHORT Flags) - { - LIMITED_METHOD_CONTRACT; - - m_Flags = VAL16(Flags); - } -}; - -// @todo: this definition is for reading the old (and wrong) GenericParamRec from a -// Beta1 assembly. -class GenericParamV1_1Rec -{ -METADATA_FIELDS_PROTECTION: - USHORT m_Number; // index; zero = first var - USHORT m_Flags; // index; zero = first var -public: - enum { - - COL_Number, // index; zero = first var - COL_Flags, // flags, for future use - COL_Owner, // typeDef/methodDef - COL_Name, // Purely descriptive, not used for binding purposes - COL_Kind, // typeDef/Ref/Spec, reserved for future use - COL_COUNT, - COL_KEY = COL_Owner - }; - - USHORT GetNumber() - { - LIMITED_METHOD_CONTRACT; - - return GET_UNALIGNED_VAL16(&m_Number); - } - void SetNumber(USHORT Number) - { - LIMITED_METHOD_CONTRACT; - - m_Number = VAL16(Number); - } - - USHORT GetFlags() - { - LIMITED_METHOD_CONTRACT; - - return GET_UNALIGNED_VAL16(&m_Flags); - } - void SetFlags(USHORT Flags) - { - LIMITED_METHOD_CONTRACT; - - m_Flags = VAL16(Flags); - } -}; - -class MethodSpecRec -{ -public: - enum { - COL_Method, // methodDef/memberRef - COL_Instantiation, // signature - COL_COUNT, - COL_KEY - }; -}; - - -class GenericParamConstraintRec -{ -public: - enum { - - COL_Owner, // GenericParam - COL_Constraint, // typeDef/Ref/Spec - COL_COUNT, - COL_KEY = COL_Owner - }; -}; - -#include - -// List of MiniMd tables. - -#define MiniMdTables() \ - MiniMdTable(Module) \ - MiniMdTable(TypeRef) \ - MiniMdTable(TypeDef) \ - MiniMdTable(FieldPtr) \ - MiniMdTable(Field) \ - MiniMdTable(MethodPtr) \ - MiniMdTable(Method) \ - MiniMdTable(ParamPtr) \ - MiniMdTable(Param) \ - MiniMdTable(InterfaceImpl) \ - MiniMdTable(MemberRef) \ - MiniMdTable(Constant) \ - MiniMdTable(CustomAttribute)\ - MiniMdTable(FieldMarshal) \ - MiniMdTable(DeclSecurity) \ - MiniMdTable(ClassLayout) \ - MiniMdTable(FieldLayout) \ - MiniMdTable(StandAloneSig) \ - MiniMdTable(EventMap) \ - MiniMdTable(EventPtr) \ - MiniMdTable(Event) \ - MiniMdTable(PropertyMap) \ - MiniMdTable(PropertyPtr) \ - MiniMdTable(Property) \ - MiniMdTable(MethodSemantics)\ - MiniMdTable(MethodImpl) \ - MiniMdTable(ModuleRef) \ - MiniMdTable(TypeSpec) \ - MiniMdTable(ImplMap) \ - MiniMdTable(FieldRVA) \ - MiniMdTable(ENCLog) \ - MiniMdTable(ENCMap) \ - MiniMdTable(Assembly) \ - MiniMdTable(AssemblyProcessor) \ - MiniMdTable(AssemblyOS) \ - MiniMdTable(AssemblyRef) \ - MiniMdTable(AssemblyRefProcessor) \ - MiniMdTable(AssemblyRefOS) \ - MiniMdTable(File) \ - MiniMdTable(ExportedType) \ - MiniMdTable(ManifestResource) \ - MiniMdTable(NestedClass) \ - MiniMdTable(GenericParam) \ - MiniMdTable(MethodSpec) \ - MiniMdTable(GenericParamConstraint) \ - -#undef MiniMdTable -#define MiniMdTable(x) TBL_##x, -enum { - MiniMdTables() - TBL_COUNT, // Highest table. - TBL_COUNT_V1 = TBL_NestedClass + 1, // Highest table in v1.0 database - TBL_COUNT_V2 = TBL_GenericParamConstraint + 1 // Highest in v2.0 database -}; -#undef MiniMdTable - -// List of MiniMd coded token types. -#define MiniMdCodedTokens() \ - MiniMdCodedToken(TypeDefOrRef) \ - MiniMdCodedToken(HasConstant) \ - MiniMdCodedToken(HasCustomAttribute) \ - MiniMdCodedToken(HasFieldMarshal) \ - MiniMdCodedToken(HasDeclSecurity) \ - MiniMdCodedToken(MemberRefParent) \ - MiniMdCodedToken(HasSemantic) \ - MiniMdCodedToken(MethodDefOrRef) \ - MiniMdCodedToken(MemberForwarded) \ - MiniMdCodedToken(Implementation) \ - MiniMdCodedToken(CustomAttributeType) \ - MiniMdCodedToken(ResolutionScope) \ - MiniMdCodedToken(TypeOrMethodDef) \ - -#undef MiniMdCodedToken -#define MiniMdCodedToken(x) CDTKN_##x, -enum { - MiniMdCodedTokens() - CDTKN_COUNT -}; -#undef MiniMdCodedToken - -//***************************************************************************** -// Meta-meta data. Constant across all MiniMds. -//***************************************************************************** -#ifndef _META_DATA_META_CONSTANTS_DEFINED -#define _META_DATA_META_CONSTANTS_DEFINED -const unsigned int iRidMax = 63; -const unsigned int iCodedToken = 64; // base of coded tokens. -const unsigned int iCodedTokenMax = 95; -const unsigned int iSHORT = 96; // fixed types. -const unsigned int iUSHORT = 97; -const unsigned int iLONG = 98; -const unsigned int iULONG = 99; -const unsigned int iBYTE = 100; -const unsigned int iSTRING = 101; // pool types. -const unsigned int iGUID = 102; -const unsigned int iBLOB = 103; - -inline int IsRidType(ULONG ix) {LIMITED_METHOD_CONTRACT; return ix <= iRidMax; } -inline int IsCodedTokenType(ULONG ix) {LIMITED_METHOD_CONTRACT; return (ix >= iCodedToken) && (ix <= iCodedTokenMax); } -inline int IsRidOrToken(ULONG ix) {LIMITED_METHOD_CONTRACT; return ix <= iCodedTokenMax; } -inline int IsHeapType(ULONG ix) {LIMITED_METHOD_CONTRACT; return ix >= iSTRING; } -inline int IsFixedType(ULONG ix) {LIMITED_METHOD_CONTRACT; return (ix < iSTRING) && (ix > iCodedTokenMax); } -#endif - - -enum MDPools { - MDPoolStrings, // Id for the string pool. - MDPoolGuids, // ...the GUID pool. - MDPoolBlobs, // ...the blob pool. - MDPoolUSBlobs, // ...the user string pool. - - MDPoolCount, // Count of pools, for array sizing. -}; // enum MDPools - - -struct CCodedTokenDef -{ - ULONG m_cTokens; // Count of tokens. - const mdToken *m_pTokens; // Array of tokens. - const char *m_pName; // Name of the coded-token type. -}; - -struct CMiniColDef -{ - BYTE m_Type; // Type of the column. - BYTE m_oColumn; // Offset of the column. - BYTE m_cbColumn; // Size of the column. -}; - -struct CMiniTableDef -{ - CMiniColDef *m_pColDefs; // Array of field defs. - BYTE m_cCols; // Count of columns in the table. - BYTE m_iKey; // Column which is the key, if any. - USHORT m_cbRec; // Size of the records. -}; -struct CMiniTableDefEx -{ - CMiniTableDef m_Def; // Table definition. - const char * const *m_pColNames; // Array of column names. - const char *m_pName; // Name of the table. -}; - -#endif // _METAMODELPUB_H_ -// eof ------------------------------------------------------------------------ diff --git a/src/inc/mscoreepriv.h b/src/inc/mscoreepriv.h deleted file mode 100644 index df0761201..000000000 --- a/src/inc/mscoreepriv.h +++ /dev/null @@ -1,21 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -// - -#ifndef __MSCOREEPRIV_H__ -#define __MSCOREEPRIV_H__ - - -typedef enum -{ - RUNTIME_INFO_CONSIDER_POST_2_0 = 0x80, // consider v4.0+ versions - RUNTIME_INFO_EMULATE_EXE_LAUNCH = 0x100, // Binds as if the provided information were being use in a new process - RUNTIME_INFO_APPEND_FORCE_PERFORMANCE_COUNTER_UNIQUE_SHARED_MEMORY_READS_SETTING_TO_VERSION // appends either !0 (false), !1 (true) or !2 (unset) depending on the value of forcePerformanceCounterUniqueSharedMemoryReads in the runtime section of the config - = 0x200, -} RUNTIME_INFO_FLAGS_FOR_SHARED_COMPONENTS; - - - -#endif //__MSCOREEPRIV_H__ - diff --git a/src/inc/msodwwrap.h b/src/inc/msodwwrap.h deleted file mode 100644 index 28c724750..000000000 --- a/src/inc/msodwwrap.h +++ /dev/null @@ -1,11 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -#ifndef __msodwwrap_h__ -#define __msodwwrap_h__ - -#ifndef MSODW_H -#include "msodw.h" -#endif // MSODW_H - -#endif // __msodwwrap_h__ diff --git a/src/inc/nativevaraccessors.h b/src/inc/nativevaraccessors.h deleted file mode 100644 index b3ee7bba0..000000000 --- a/src/inc/nativevaraccessors.h +++ /dev/null @@ -1,48 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -//***************************************************************************** -// The following are used to read and write data given NativeVarInfo -// for primitive types. Don't use these for VALUECLASSes. -//***************************************************************************** - - -#ifndef _NATIVE_VAR_ACCESSORS_H_ -#define _NATIVE_VAR_ACCESSORS_H_ - -#include "corjit.h" - -bool operator ==(const ICorDebugInfo::VarLoc &varLoc1, - const ICorDebugInfo::VarLoc &varLoc2); - -#define MAX_NATIVE_VAR_LOCS 2 - -SIZE_T GetRegOffsInCONTEXT(ICorDebugInfo::RegNum regNum); - -struct NativeVarLocation -{ - ULONG64 addr; - TADDR size; - bool contextReg; -}; - -ULONG NativeVarLocations(const ICorDebugInfo::VarLoc & varLoc, - PT_CONTEXT pCtx, - ULONG numLocs, - NativeVarLocation* locs); - -SIZE_T *NativeVarStackAddr(const ICorDebugInfo::VarLoc & varLoc, - PT_CONTEXT pCtx); - -bool GetNativeVarVal(const ICorDebugInfo::VarLoc & varLoc, - PT_CONTEXT pCtx, - SIZE_T * pVal1, - SIZE_T * pVal2 - WIN64_ARG(SIZE_T cbSize)); - -bool SetNativeVarVal(const ICorDebugInfo::VarLoc & varLoc, - PT_CONTEXT pCtx, - SIZE_T val1, - SIZE_T val2 - WIN64_ARG(SIZE_T cbSize)); -#endif // #ifndef _NATIVE_VAR_ACCESSORS_H_ diff --git a/src/inc/ngen.h b/src/inc/ngen.h deleted file mode 100644 index fa0b9829d..000000000 --- a/src/inc/ngen.h +++ /dev/null @@ -1,153 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -// -// This file is the interface to NGen (*N*ative code *G*eneration), -// which compiles IL modules to machine code ahead-of-time. -// This avoids the need for JIT compiling the code at program startup. -// - - -#ifndef _NGEN_H_ -#define _NGEN_H_ - -#include "mscorsvc.h" - -// Log size default of 10 MB. -#define DEFAULT_SERVICE_LOG_SIZE (10 * 1024 * 1024) -// NGEN.log is smaller 1MB -#define DEFAULT_MACHINE_WIDE_LOG_SIZE (1 * 1024 * 1024) -// User specific log is yet smaller 200KB -#define DEFAULT_USER_WIDE_LOG_SIZE (200 * 1024) -// Log size default of 100 KB. This should be big enough to hold some log info from roughly 100 -// ngen events. (Roughly 200KB of space including secondary log file.) -#define DEFAULT_APPLOCAL_WIDE_LOG_SIZE (100*1024) - -#define NGEN_LOG_HEADER_TEXT W("To learn about increasing the verbosity of the NGen log files please see http://go.microsoft.com/fwlink/?linkid=210113\r\n") - -// supported debug info types -enum DebugType -{ - DT_NIL, - DT_PDB -}; - -// -// IMPORTANT * IMPORTANT * IMPORTANT * IMPORTANT * IMPORTANT * IMPORTANT -// -// This structure cannot have any fields removed from it!!! -// -// IMPORTANT * IMPORTANT * IMPORTANT * IMPORTANT * IMPORTANT * IMPORTANT -// -// NGening a module invokes the runtime against which the module was built. -// Thus this structure needs to be backwards-compatible. -// -// If additional options need to be added to this structure, -// add them to the end of the structure and make sure you update -// logic throughout the runtime to look at a different size in the dwSize -// field. This is how we'll 'version' this structure. -// -// If you are adding a code-generation flag (like debug or prof), use -// fInstrument as a template (but be sure to add your new flag as the -// last element in the struct). - -typedef struct _NGenOptions -{ - DWORD dwSize; // Size of the structure. Used to version the structure - - // V1 - - bool fDebug; // Generate debuggable code and debug information - bool fDebugOpt; // Generate debugging information, but optimized code - bool fProf; // Generate instrumented code for profiling (call graphs) - - bool fSilent; // Dont spew text output - LPCWSTR lpszExecutableFileName; // Name of the module to ngen - - // V2 (Whidbey) - - bool fInstrument; // Generate instrumented code for basic-block profiling - - // No longer supported - bool fWholeProgram; // Do cross function optimizations (whole program) - - // No longer supported - bool fProfInfo; // Embed working set profiling data into the image - - LPCWSTR lpszRepositoryDir; // Directory for repository of native images - RepositoryFlags repositoryFlags; - - // No longer supported - DebugType dtRequested; // the requested debug type - LPCWSTR lpszDebugDir; // the name of the output debug dir for the above - - // No longer supported - bool fNoInstall; // Creates stand alone ngen-images that can be installed in the NIC later - - // No longer supported - bool fEmitFixups; // Support for Vulcan - bool fFatHeaders; - - // Diagnostic flags - bool fVerbose; // print verbose descriptions of native images - unsigned uStats; // image stats mask - -#define LAST_WHIDBEY_NGENOPTION uStats - - // V4 - bool fNgenLastRetry; // Ngen has previously failed and this is the last retry - - // V4.5 - bool fAutoNGen; // This is an automatically generated NGen request - - // Blue - bool fRepositoryOnly;// Install from repository only, no real NGen - -} NGenOptions; - -// Function pointer types that we use to dynamically bind to the appropriate runtime version -extern "C" typedef HRESULT STDAPICALLTYPE - NGenCreateZapperAPI( - HANDLE* hZapper, - NGenOptions *options); -typedef NGenCreateZapperAPI *PNGenCreateZapper; - -extern "C" typedef HRESULT STDAPICALLTYPE - NGenTryEnumerateFusionCacheAPI( - HANDLE hZapper, - LPCWSTR assemblyName, - bool fPrint, - bool fDelete); -typedef NGenTryEnumerateFusionCacheAPI *PNGenTryEnumerateFusionCache; - -// The return type should really be HRESULT. -// However, it is BOOL for backwards-compatibility -extern "C" typedef BOOL STDAPICALLTYPE - NGenCompileAPI( - HANDLE hZapper, - LPCWSTR path); -typedef NGenCompileAPI *PNGenCompile; - -extern "C" typedef HRESULT STDAPICALLTYPE - NGenFreeZapperAPI( - HANDLE hZapper); -typedef NGenFreeZapperAPI *PNGenFreeZapper; - -class ILocalServerLifetime -{ -public: - virtual void AddRefServerProcess() = 0; - virtual void ReleaseServerProcess() = 0; -}; - -struct ICorSvcLogger; - -extern "C" typedef HRESULT STDAPICALLTYPE - NGenCreateNGenWorkerAPI( - ICorSvcWorker **pCorSvcWorker, - ILocalServerLifetime *pLocalServerLifetime, - ICorSvcLogger *pCorSvcLogger - ); -typedef NGenCreateNGenWorkerAPI *PNGenCreateNGenWorker; - -#endif diff --git a/src/inc/nibblemapmacros.h b/src/inc/nibblemapmacros.h deleted file mode 100644 index 42ea90a2b..000000000 --- a/src/inc/nibblemapmacros.h +++ /dev/null @@ -1,56 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#ifndef NIBBLEMAPMACROS_H_ -#define NIBBLEMAPMACROS_H_ - -/////////////////////////////////////////////////////////////////////// -//// some mmgr stuff for JIT, especially for jit code blocks -/////////////////////////////////////////////////////////////////////// -// -// In order to quickly find the start of a jit code block -// we keep track of all those positions via a map. -// Each entry in this map represents 32 byte (a bucket) of the code heap. -// We make the assumption that no two code-blocks can start in -// the same 32byte bucket; -// Additionally we assume that every code header is DWORD aligned. -// Because we cannot guarantee that jitblocks always start at -// multiples of 32 bytes we cannot use a simple bitmap; instead we -// use a nibble (4 bit) per bucket and encode the offset of the header -// inside the bucket (in DWORDS). In order to make initialization -// easier we add one to the real offset, a nibble-value of zero -// means that there is no header start in the resp. bucket. -// In order to speed up "backwards scanning" we start numbering -// nibbles inside a DWORD from the highest bits (28..31). Because -// of that we can scan backwards inside the DWORD with right shifts. - -#if defined(_WIN64) -// TODO: bump up the windows CODE_ALIGN to 16 and iron out any nibble map bugs that exist. -// TODO: there is something wrong with USE_INDIRECT_CODEHEADER with CODE_ALIGN=16 -# define CODE_ALIGN 4 -# define LOG2_CODE_ALIGN 2 -#else -# define CODE_ALIGN sizeof(DWORD) // 4 byte boundry -# define LOG2_CODE_ALIGN 2 -#endif -#define NIBBLE_MASK 0xf -#define NIBBLE_SIZE 4 // 4 bits -#define LOG2_NIBBLE_SIZE 2 -#define NIBBLES_PER_DWORD ((8*sizeof(DWORD)) >> LOG2_NIBBLE_SIZE) // 8 (4-bit) nibbles per dword -#define NIBBLES_PER_DWORD_MASK (NIBBLES_PER_DWORD - 1) // 7 -#define LOG2_NIBBLES_PER_DWORD 3 -#define BYTES_PER_BUCKET (NIBBLES_PER_DWORD * CODE_ALIGN) // 32 bytes per bucket -#define LOG2_BYTES_PER_BUCKET (LOG2_CODE_ALIGN + LOG2_NIBBLES_PER_DWORD) // 5 bits per bucket -#define MASK_BYTES_PER_BUCKET (BYTES_PER_BUCKET - 1) // 31 -#define HIGHEST_NIBBLE_BIT (32 - NIBBLE_SIZE) // 28 (i.e 32 - 4) -#define HIGHEST_NIBBLE_MASK (NIBBLE_MASK << HIGHEST_NIBBLE_BIT) // 0xf0000000 - -#define ADDR2POS(x) ((x) >> LOG2_BYTES_PER_BUCKET) -#define ADDR2OFFS(x) (DWORD) ((((x) & MASK_BYTES_PER_BUCKET) >> LOG2_CODE_ALIGN) + 1) -#define POSOFF2ADDR(pos, of) (size_t) (((pos) << LOG2_BYTES_PER_BUCKET) + (((of) - 1) << LOG2_CODE_ALIGN)) -#define HEAP2MAPSIZE(x) (((x) / (BYTES_PER_BUCKET * NIBBLES_PER_DWORD)) * CODE_ALIGN) -#define POS2SHIFTCOUNT(x) (DWORD) (HIGHEST_NIBBLE_BIT - (((x) & NIBBLES_PER_DWORD_MASK) << LOG2_NIBBLE_SIZE)) -#define POS2MASK(x) (DWORD) ~(HIGHEST_NIBBLE_MASK >> (((x) & NIBBLES_PER_DWORD_MASK) << LOG2_NIBBLE_SIZE)) - -#endif // NIBBLEMAPMACROS_H_ diff --git a/src/inc/nibblestream.h b/src/inc/nibblestream.h deleted file mode 100644 index 1b92bd06e..000000000 --- a/src/inc/nibblestream.h +++ /dev/null @@ -1,300 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -// NibbleStream reader and writer. - - -#ifndef _NIBBLESTREAM_H_ -#define _NIBBLESTREAM_H_ - -#include "contract.h" -#include "sigbuilder.h" - -typedef BYTE NIBBLE; - -//----------------------------------------------------------------------------- -// Helpers for compression routines. -//----------------------------------------------------------------------------- -// This class allows variable-length compression of DWORDs. -// -// A value can be stored using one or more nibbles. 3 bits of a nibble are used -// to store 3 bits of the value, and the top bit indicates if the following nibble -// contains rest of the value. If the top bit is not set, then this -// nibble is the last part of the value. -// The higher bits of the value are written out first, and the lowest 3 bits -// are written out last. -// -// In the encoded stream of bytes, the lower nibble of a byte is used before -// the high nibble. -// -// A binary value ABCDEFGHI (where A is the highest bit) is encoded as -// the follow two bytes : 1DEF1ABC XXXX0GHI -// -// Examples : -// 0 => X0 -// 1 => X1 -// -// 7 => X7 -// 8 => 09 -// 9 => 19 -// -// 0x3F (63) => 7F -// 0x40 (64) => F9 X0 -// 0x41 (65) => F9 X1 -// -// 0x1FF (511) => FF X7 -// 0x200 (512) => 89 08 -// 0x201 (513) => 89 18 - -class NibbleWriter -{ -public: - NibbleWriter() - { - LIMITED_METHOD_CONTRACT; - - m_fPending = false; - } - - void Flush() - { - if (m_fPending) - m_SigBuilder.AppendByte(m_PendingNibble); - } - - PVOID GetBlob(DWORD * pdwLength) - { - return m_SigBuilder.GetSignature(pdwLength); - } - - DWORD GetBlobLength() - { - return m_SigBuilder.GetSignatureLength(); - } - -//............................................................................. -// Writer methods -//............................................................................. - - - // Write a single nibble to the stream. - void WriteNibble(NIBBLE i) - { - CONTRACTL - { - THROWS; - GC_NOTRIGGER; - } - CONTRACTL_END; - - _ASSERTE(i <= 0xF); - - if (m_fPending) - { - // Use the high nibble after the low nibble is used - m_SigBuilder.AppendByte(m_PendingNibble | (i << 4)); - m_fPending = false; - } - else - { - // Use the low nibble first - m_PendingNibble = i; - m_fPending = true; - } - } - - // Write an unsigned int via variable length nibble encoding. - // We use the bit scheme: - // 0ABC (if 0 <= dw <= 0x7) - // 1ABC 0DEF (if 0 <= dw <= 0x7f) - // 1ABC 1DEF 0GHI (if 0 <= dw <= 0x7FF) - // etc.. - - void WriteEncodedU32(DWORD dw) - { - CONTRACTL - { - THROWS; - GC_NOTRIGGER; - } - CONTRACTL_END; - - // Fast path for common small inputs - if (dw <= 63) - { - if (dw > 7) - { - WriteNibble((NIBBLE) ((dw >> 3) | 8)); - } - - WriteNibble((NIBBLE) (dw & 7)); - return; - } - - // Note we must write this out with the low terminating nibble (0ABC) last b/c the - // reader gets nibbles in the same order we write them. - int i = 0; - while ((dw >> i) > 7) - { - i+= 3; - } - while(i > 0) - { - WriteNibble((NIBBLE) ((dw >> i) & 0x7) | 0x8); - i -= 3; - } - WriteNibble((NIBBLE) dw & 0x7); - } - - // Write a signed 32 bit value. - void WriteEncodedI32(int x) - { - CONTRACTL - { - THROWS; - GC_NOTRIGGER; - } - CONTRACTL_END; - - DWORD dw = (x < 0) ? (((-x) << 1) + 1) : (x << 1); - WriteEncodedU32(dw); - }; - -protected: - NIBBLE m_PendingNibble; // Pending value, not yet written out. - bool m_fPending; - - // SigBuilder is a convenient helper class for writing out small blobs - SigBuilder m_SigBuilder; -}; - -//----------------------------------------------------------------------------- - -class NibbleReader -{ -public: - NibbleReader(PTR_BYTE pBuffer, size_t size) - { - LIMITED_METHOD_CONTRACT; - SUPPORTS_DAC; - _ASSERTE(pBuffer != NULL); - - m_pBuffer = pBuffer; - m_cBytes = size; - m_cNibble = 0; - } - - // Get the index of the next Byte. - // This tells us how many bytes (rounding up to whole bytes) have been read. - // This is can be used to extract raw byte data that may be embedded on a byte boundary in the nibble stream. - size_t GetNextByteIndex() - { - LIMITED_METHOD_CONTRACT; - SUPPORTS_DAC; - - return (m_cNibble + 1) / 2; - } - - NIBBLE ReadNibble() - { - CONTRACTL - { - THROWS; - GC_NOTRIGGER; - SUPPORTS_DAC; - } - CONTRACTL_END; - - NIBBLE i = 0; - // Bufer should have been allocated large enough to hold data. - if (!(m_cNibble / 2 < m_cBytes)) - { - // We should never get here in a normal retail scenario. - // We could wind up here if somebody provided us invalid data (maybe by corrupting an ngenned image). - EX_THROW(HRException, (E_INVALIDARG)); - } - - BYTE p = m_pBuffer[m_cNibble / 2]; - if ((m_cNibble & 1) == 0) - { - // Read the low nibble first - i = (NIBBLE) (p & 0xF); - } - else - { - // Read the high nibble after the low nibble has been read - i = (NIBBLE) (p >> 4) & 0xF; - } - m_cNibble++; - - return i; - } - - // Read an unsigned int that was encoded via variable length nibble encoding - // from NibbleWriter::WriteEncodedU32. - DWORD ReadEncodedU32() - { - CONTRACTL - { - THROWS; - GC_NOTRIGGER; - SUPPORTS_DAC; - } - CONTRACTL_END; - - DWORD dw =0; - -#if defined(_DEBUG) || defined(DACCESS_COMPILE) - int dwCount = 0; -#endif - - // The encoding is variably lengthed, with the high-bit of every nibble indicating whether - // there is another nibble in the value. Each nibble contributes 3 bits to the value. - NIBBLE n; - do - { -#if defined(_DEBUG) || defined(DACCESS_COMPILE) - // If we've already read 11 nibbles (with 3 bits of usable data each), then we - // should be done reading a 32-bit integer. - // Avoid working with corrupted data and potentially long loops by failing - if(dwCount > 11) - { - _ASSERTE_MSG(false, "Corrupt nibble stream - value exceeded 32-bits in size"); -#ifdef DACCESS_COMPILE - DacError(CORDBG_E_TARGET_INCONSISTENT); -#endif - } - dwCount++; -#endif - - n = ReadNibble(); - dw = (dw << 3) + (n & 0x7); - } while((n & 0x8) > 0); - - return dw; - } - - int ReadEncodedI32() - { - CONTRACTL - { - THROWS; - GC_NOTRIGGER; - SUPPORTS_DAC; - } - CONTRACTL_END; - - DWORD dw = ReadEncodedU32(); - int x = dw >> 1; - return (dw & 1) ? (-x) : (x); - } - -protected: - PTR_BYTE m_pBuffer; - size_t m_cBytes; // size of buffer. - size_t m_cNibble; // Which nibble are we at? -}; - - - -#endif // _NIBBLESTREAM_H_ diff --git a/src/inc/nsutilpriv.h b/src/inc/nsutilpriv.h deleted file mode 100644 index ede064c6f..000000000 --- a/src/inc/nsutilpriv.h +++ /dev/null @@ -1,266 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -//***************************************************************************** -// NSUtilPriv.h -// -// Helpers for converting namespace separators. -// -//***************************************************************************** - -#ifndef __NSUTILPRIV_H__ -#define __NSUTILPRIV_H__ - -template class CQuickArray; -class SString; - -struct ns -{ - -//***************************************************************************** -// Determine how many chars large a fully qualified name would be given the -// two parts of the name. The return value includes room for every character -// in both names, as well as room for the separator and a final terminator. -//***************************************************************************** -static -int GetFullLength( // Number of chars in full name. - const WCHAR *szNameSpace, // Namspace for value. - const WCHAR *szName); // Name of value. - -static -int GetFullLength( // Number of chars in full name. - LPCUTF8 szNameSpace, // Namspace for value. - LPCUTF8 szName); // Name of value. - -//***************************************************************************** -// Scan the given string to see if the name contains any invalid characters -// that are not allowed. -//***************************************************************************** -static -int IsValidName( // true if valid, false invalid. - const WCHAR *szName); // Name to parse. - -static -int IsValidName( // true if valid, false invalid. - LPCUTF8 szName); // Name to parse. - - -//***************************************************************************** -// Scan the string from the rear looking for the first valid separator. If -// found, return a pointer to it. Else return null. This code is smart enough -// to skip over special sequences, such as: -// a.b..ctor -// ^ -// | -// The ".ctor" is considered one token. -//***************************************************************************** -static -WCHAR *FindSep( // Pointer to separator or null. - const WCHAR *szPath); // The path to look in. - -static -LPUTF8 FindSep( // Pointer to separator or null. - LPCUTF8 szPath); // The path to look in. - - -//***************************************************************************** -// Take a path and find the last separator (nsFindSep), and then replace the -// separator with a '\0' and return a pointer to the name. So for example: -// a.b.c -// becomes two strings "a.b" and "c" and the return value points to "c". -//***************************************************************************** -static -WCHAR *SplitInline( // Pointer to name portion. - __inout __inout_z WCHAR *szPath); // The path to split. - -static -LPUTF8 SplitInline( // Pointer to name portion. - __inout __inout_z LPUTF8 szPath); // The path to split. - -static -void SplitInline( - __inout __inout_z LPWSTR szPath, // Path to split. - LPCWSTR &szNameSpace, // Return pointer to namespace. - LPCWSTR &szName); // Return pointer to name. - -static -void SplitInline( - __inout __inout_z LPUTF8 szPath, // Path to split. - LPCUTF8 &szNameSpace, // Return pointer to namespace. - LPCUTF8 &szName); // Return pointer to name. - - -//***************************************************************************** -// Split the last parsable element from the end of the string as the name, -// the first part as the namespace. -//***************************************************************************** -static -int SplitPath( // true ok, false trunction. - const WCHAR *szPath, // Path to split. - __out_ecount_opt (cchNameSpace) WCHAR *szNameSpace, // Output for namespace value. - int cchNameSpace, // Max chars for output. - __out_ecount_opt (cchName) WCHAR *szName, // Output for name. - int cchName); // Max chars for output. - -static -int SplitPath( // true ok, false trunction. - LPCUTF8 szPath, // Path to split. - __out_ecount_opt (cchNameSpace) LPUTF8 szNameSpace, // Output for namespace value. - int cchNameSpace, // Max chars for output. - __out_ecount_opt (cchName) LPUTF8 szName, // Output for name. - int cchName); // Max chars for output. - - -//***************************************************************************** -// Take two values and put them together in a fully qualified path using the -// correct separator. -//***************************************************************************** -static -int MakePath( // true ok, false truncation. - __out_ecount(cchChars) WCHAR *szOut, // output path for name. - int cchChars, // max chars for output path. - const WCHAR *szNameSpace, // Namespace. - const WCHAR *szName); // Name. - -static -int MakePath( // true ok, false truncation. - __out_ecount(cchChars) LPUTF8 szOut, // output path for name. - int cchChars, // max chars for output path. - LPCUTF8 szNameSpace, // Namespace. - LPCUTF8 szName); // Name. - -static -int MakePath( // true ok, false truncation. - __out_ecount(cchChars) WCHAR *szOut, // output path for name. - int cchChars, // max chars for output path. - LPCUTF8 szNameSpace, // Namespace. - LPCUTF8 szName); // Name. - -static -int MakePath( // true ok, false out of memory - CQuickBytes &qb, // Where to put results. - LPCUTF8 szNameSpace, // Namespace for name. - LPCUTF8 szName); // Final part of name. - -static -int MakePath( // true ok, false out of memory - CQuickArray &qa, // Where to put results. - LPCUTF8 szNameSpace, // Namespace for name. - LPCUTF8 szName); // Final part of name. - -static -int MakePath( // true ok, false out of memory - CQuickBytes &qb, // Where to put results. - const WCHAR *szNameSpace, // Namespace for name. - const WCHAR *szName); // Final part of name. - -static -void MakePath( // throws on out of memory - SString &ssBuf, // Where to put results. - const SString &ssNameSpace, // Namespace for name. - const SString &ssName); // Final part of name. - -//***************************************************************************** -// Concatinate type names to assembly names -//***************************************************************************** -static -bool MakeAssemblyQualifiedName( // true if ok, false if out of memory - CQuickBytes &qb, // location to put result - const WCHAR *szTypeName, // Type name - const WCHAR *szAssemblyName); // Assembly Name - -static -bool MakeAssemblyQualifiedName( // true ok, false truncation - __out_ecount (dwBuffer) WCHAR* pBuffer, // Buffer to recieve the results - int dwBuffer, // Number of characters total in buffer - const WCHAR *szTypeName, // Namespace for name. - int dwTypeName, // Number of characters (not including null) - const WCHAR *szAssemblyName, // Final part of name. - int dwAssemblyName); // Number of characters (not including null) - -static -int MakeNestedTypeName( // true ok, false out of memory - CQuickBytes &qb, // Where to put results. - LPCUTF8 szEnclosingName, // Full name for enclosing type - LPCUTF8 szNestedName); // Full name for nested type - -static -int MakeNestedTypeName( // true ok, false truncation. - __out_ecount (cchChars) LPUTF8 szOut, // output path for name. - int cchChars, // max chars for output path. - LPCUTF8 szEnclosingName, // Full name for enclosing type - LPCUTF8 szNestedName); // Full name for nested type - -static -void MakeNestedTypeName( // throws on out of memory - SString &ssBuf, // output path for name. - const SString &ssEnclosingName, // Full name for enclosing type - const SString &ssNestedName); // Full name for nested type -}; // struct ns - -#ifndef NAMESPACE_SEPARATOR_CHAR -#define NAMESPACE_SEPARATOR_CHAR '.' -#define NAMESPACE_SEPARATOR_WCHAR W('.') -#define NAMESPACE_SEPARATOR_STR "." -#define NAMESPACE_SEPARATOR_WSTR W(".") -#define NAMESPACE_SEPARATOR_LEN 1 -#define ASSEMBLY_SEPARATOR_CHAR ',' -#define ASSEMBLY_SEPARATOR_WCHAR W(',') -#define ASSEMBLY_SEPARATOR_STR ", " -#define ASSEMBLY_SEPARATOR_WSTR W(", ") -#define ASSEMBLY_SEPARATOR_LEN 2 -#define BACKSLASH_CHAR '\\' -#define BACKSLASH_WCHAR W('\\') -#define NESTED_SEPARATOR_CHAR '+' -#define NESTED_SEPARATOR_WCHAR W('+') -#define NESTED_SEPARATOR_STR "+" -#define NESTED_SEPARATOR_WSTR W("+") -#endif - -#define EMPTY_STR "" -#define EMPTY_WSTR W("") - -#define MAKE_FULL_PATH_ON_STACK_UTF8(toptr, pnamespace, pname) \ -{ \ - int __i##toptr = ns::GetFullLength(pnamespace, pname); \ - toptr = (char *) alloca(__i##toptr); \ - ns::MakePath(toptr, __i##toptr, pnamespace, pname); \ -} - -#define MAKE_FULL_PATH_ON_STACK_UNICODE(toptr, pnamespace, pname) \ -{ \ - int __i##toptr = ns::GetFullLength(pnamespace, pname); \ - toptr = (WCHAR *) alloca(__i##toptr * sizeof(WCHAR)); \ - ns::MakePath(toptr, __i##toptr, pnamespace, pname); \ -} - -#define MAKE_FULLY_QUALIFIED_NAME(pszFullyQualifiedName, pszNameSpace, pszName) MAKE_FULL_PATH_ON_STACK_UTF8(pszFullyQualifiedName, pszNameSpace, pszName) - -#define MAKE_FULLY_QUALIFIED_MEMBER_NAME(ptr, pszNameSpace, pszClassName, pszMemberName, pszSig) \ -{ \ - int __i##ptr = ns::GetFullLength(pszNameSpace, pszClassName); \ - __i##ptr += (pszMemberName ? (int) strlen(pszMemberName) : 0); \ - __i##ptr += (NAMESPACE_SEPARATOR_LEN * 2); \ - __i##ptr += (pszSig ? (int) strlen(pszSig) : 0); \ - ptr = (LPUTF8) alloca(__i##ptr); \ - ns::MakePath(ptr, __i##ptr, pszNameSpace, pszClassName); \ - if (pszMemberName) { \ - strcat_s(ptr, __i##ptr, NAMESPACE_SEPARATOR_STR); \ - strcat_s(ptr, __i##ptr, pszMemberName); \ - } \ - if (pszSig) { \ - if (! pszMemberName) \ - strcat_s(ptr, __i##ptr, NAMESPACE_SEPARATOR_STR); \ - strcat_s(ptr, __i##ptr, pszSig); \ - } \ -} - -#ifdef _PREFAST_ -// need to eliminate the expansion of MAKE_FULLY_QUALIFIED_MEMBER_NAME in prefast -// builds to prevent it complaining about the potential for NULLs to strlen and strcat -#undef MAKE_FULLY_QUALIFIED_MEMBER_NAME -// need to set ptr=NULL so we don't get a build error because ptr isn't inited in a couple cases -#define MAKE_FULLY_QUALIFIED_MEMBER_NAME(ptr, pszNameSpace, pszClassName, pszMemberName, pszSig) ptr=NULL; -#endif - -#endif diff --git a/src/inc/opinfo.h b/src/inc/opinfo.h deleted file mode 100644 index d98c006ec..000000000 --- a/src/inc/opinfo.h +++ /dev/null @@ -1,83 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - - -/***************************************************************************/ -/* OpInfo.h */ -/***************************************************************************/ - -/* contains OpInfo, a wrapper that allows you to get useful information - about IL opcodes, and how to decode them */ - -/***************************************************************************/ - -#ifndef OpInfo_h -#define OpInfo_h - -#include "openum.h" - - // Decribes the flow of control properties of the instruction -enum OpFlow { - FLOW_META, // not a real instuction - FLOW_CALL, // a call instruction - FLOW_BRANCH, // unconditional branch, does not fall through - FLOW_COND_BRANCH, // may fall through - FLOW_PHI, - FLOW_THROW, - FLOW_BREAK, - FLOW_RETURN, - FLOW_NEXT, // flows into next instruction (none of the above) -}; - - // These are all the possible arguments for the instruction -/****************************************************************************/ -union OpArgsVal { - __int32 i; - __int64 i8; - double r; - struct { - unsigned count; - int* targets; // targets are pcrelative displacements (little-endian) - } switch_; - struct { - unsigned count; - unsigned short* vars; - } phi; -}; - -/***************************************************************************/ - - // OpInfo parses a il instrution into an opcode, and a arg and updates the IP -class OpInfo { -public: - OpInfo() { data = 0; } - OpInfo(OPCODE opCode) { _ASSERTE(opCode < CEE_COUNT); data = &table[opCode]; } - - // fetch instruction at 'instrPtr, fills in 'args' returns pointer - // to next instruction - const unsigned char* fetch(const unsigned char* instrPtr, OpArgsVal* args); - - const char* getName() { return(data->name); } - OPCODE_FORMAT getArgsInfo() { return(OPCODE_FORMAT(data->format & PrimaryMask)); } - OpFlow getFlow() { return(data->flow); } - OPCODE getOpcode() { return((OPCODE) (data-table)); } - int getNumPop() { return(data->numPop); } - int getNumPush() { return(data->numPush); } - -private: - struct OpInfoData { - const char* name; - OPCODE_FORMAT format : 8; - OpFlow flow : 8; - int numPop : 3; // < 0 means depends on instr args - int numPush : 3; // < 0 means depends on instr args - OPCODE opcode : 10; // This is the same as the index into the table - }; - - static OpInfoData table[]; -private: - OpInfoData* data; -}; - -#endif diff --git a/src/inc/optdefault.h b/src/inc/optdefault.h deleted file mode 100644 index dd0bd44c0..000000000 --- a/src/inc/optdefault.h +++ /dev/null @@ -1,12 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -// -// Revert optimizations back to default -// -#undef FPO_ON - -#ifdef _MSC_VER -#pragma optimize("",on) -#endif diff --git a/src/inc/optsmallperfcritical.h b/src/inc/optsmallperfcritical.h deleted file mode 100644 index 68c80884e..000000000 --- a/src/inc/optsmallperfcritical.h +++ /dev/null @@ -1,21 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -// -// Set optimizations settings for small performance critical methods -// - -#ifdef FPO_ON -#error Recursive use of FPO_ON not supported -#endif - -#define FPO_ON 1 - - -#if defined(_MSC_VER) && !defined(_DEBUG) - #pragma optimize("t", on) // optimize for speed - #if !defined(_AMD64_) // 'y' isn't an option on amd64 - #pragma optimize("y", on) // omit frame pointer - #endif // !defined(_TARGET_AMD64_) -#endif diff --git a/src/inc/ostype.h b/src/inc/ostype.h deleted file mode 100644 index f17afb1d6..000000000 --- a/src/inc/ostype.h +++ /dev/null @@ -1,105 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - - -#include "staticcontract.h" - -#ifndef WRAPPER_NO_CONTRACT -#define WRAPPER_NO_CONTRACT ANNOTATION_WRAPPER -#endif - -#ifndef LIMITED_METHOD_CONTRACT -#define LIMITED_METHOD_CONTRACT ANNOTATION_FN_LEAF -#endif - -//***************************************************************************** -// Enum to track which version of the OS we are running -// Note that NT5 (Win2k) is the minimum supported platform. Any code using -// utilcode (which includes the CLR's execution engine) will fail to start -// on a pre-Win2k platform. This is enforced by InitRunningOnVersionStatus. -// -// Note: The value is used for data mining from links clicked by user in shim dialog - see code:FWLinkTemplateFromTextID -// Please do not modify existing values, adding new ones is fine. -//***************************************************************************** -typedef enum { - RUNNING_ON_STATUS_UNINITED = 0, - RUNNING_ON_WIN7 = 1, - RUNNING_ON_WIN8 = 2 -} RunningOnStatusEnum; - -extern RunningOnStatusEnum gRunningOnStatus; - -void InitRunningOnVersionStatus(); - -#if defined(FEATURE_COMINTEROP) && !defined(FEATURE_CORESYSTEM) -typedef enum -{ - WINRT_STATUS_UNINITED = 0, - WINRT_STATUS_UNSUPPORTED, - WINRT_STATUS_SUPPORTED -} -WinRTStatusEnum; - -extern WinRTStatusEnum gWinRTStatus; - -void InitWinRTStatus(); -#endif // FEATURE_COMINTEROP && !FEATURE_CORESYSTEM - -//***************************************************************************** -// Returns true if you are running on Windows 8 or newer. -//***************************************************************************** -inline BOOL RunningOnWin8() -{ - WRAPPER_NO_CONTRACT; -#if (!defined(_X86_) && !defined(_AMD64_)) || defined(CROSSGEN_COMPILE) - return TRUE; -#else - if (gRunningOnStatus == RUNNING_ON_STATUS_UNINITED) - { - InitRunningOnVersionStatus(); - } - - return (gRunningOnStatus >= RUNNING_ON_WIN8) ? TRUE : FALSE; -#endif -} - -#ifdef FEATURE_COMINTEROP - -#ifdef FEATURE_CORESYSTEM - -inline BOOL WinRTSupported() -{ - return RunningOnWin8(); -} -#else -inline BOOL WinRTSupported() -{ - STATIC_CONTRACT_NOTHROW; - STATIC_CONTRACT_GC_NOTRIGGER; - STATIC_CONTRACT_CANNOT_TAKE_LOCK; - STATIC_CONTRACT_SO_TOLERANT; - -#ifdef CROSSGEN_COMPILE - return TRUE; -#endif - - if (gWinRTStatus == WINRT_STATUS_UNINITED) - { - InitWinRTStatus(); - } - - return gWinRTStatus == WINRT_STATUS_SUPPORTED; -} -#endif // FEATURE_CORESYSTEM - -#endif // FEATURE_COMINTEROP - -#ifdef _WIN64 -inline BOOL RunningInWow64() -{ - return FALSE; -} -#else -BOOL RunningInWow64(); -#endif diff --git a/src/inc/outstring.h b/src/inc/outstring.h deleted file mode 100644 index 5cf023635..000000000 --- a/src/inc/outstring.h +++ /dev/null @@ -1,157 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - - -/*****************************************************************/ -/* OutString.h */ -/*****************************************************************/ -/* A simple, lightweight, character output stream, with very few - external dependancies (like sprintf ... ) */ - -/* - Date : 2/1/99 */ -/*****************************************************************/ - -#ifndef _OutString_h -#define _OutString_h 1 - -#include "utilcode.h" // for overloaded new -#include // for strlen, strcpy - -/*****************************************************************/ - // a light weight character 'output' stream -class OutString { -public: - enum FormatFlags { // used to control printing of numbers - none = 0, - put0x = 1, // put leading 0x on hexidecimal - zeroFill = 2, // zero fill (instead of space fill) - }; - - OutString() : start(0), end(0), cur(0) {} - - OutString(unsigned initialAlloc) { - cur = start = new char[initialAlloc+1]; // for null termination - end = &start[initialAlloc]; - } - - ~OutString() { delete start; } - - // shortcut for printing decimal - OutString& operator<<(int i) { return(dec(i)); } - - OutString& operator<<(double d); - - // FIX make this really unsigned - OutString& operator<<(unsigned i) { return(dec(i)); } - - // prints out the hexidecimal representation - OutString& dec(int i, size_t minWidth = 0); - - // prints out the hexidecimal representation - OutString& hex(unsigned i, int minWidth = 0, unsigned flags = none); - - OutString& hex(unsigned __int64 i, int minWidth = 0, unsigned flags = none); - - OutString& hex(int i, int minWidth = 0, unsigned flags = none) { - return hex(unsigned(i), minWidth, flags); - } - - OutString& hex(__int64 i, int minWidth = 0, unsigned flags = none) { - return hex((unsigned __int64) i, minWidth, flags); - } - - // print out 'count' instances of the character 'c' - OutString& pad(size_t count, char c); - - OutString& operator<<(char c) { - if (cur >= end) - Realloc(1); - *cur++ = c; - _ASSERTE(start <= cur && cur <= end); - return(*this); - } - - OutString& operator<<(const wchar_t* str) { - size_t len = wcslen(str); - if (cur+len > end) - Realloc(len); - while(str != 0) - *cur++ = (char) *str++; - _ASSERTE(start <= cur && cur <= end); - return(*this); - } - - OutString& prepend(const char c) { - char buff[2]; buff[0] = c; buff[1] = 0; - return(prepend(buff)); - } - - OutString& prepend(const char* str) { - size_t len = strlen(str); - if (cur+len > end) - Realloc(len); - memmove(start+len, start, cur-start); - memcpy(start, str, len); - cur = cur + len; - _ASSERTE(start <= cur && cur <= end); - return(*this); - } - - OutString& operator=(const OutString& str) { - clear(); - *this << str; - return(*this); - } - - OutString& operator<<(const OutString& str) { - write(str.start, str.cur-str.start); - return(*this); - } - - OutString& operator<<(const char* str) { - write(str, strlen(str)); - return(*this); - } - - void write(const char* str, size_t len) { - if (cur+len > end) - Realloc(len); - memcpy(cur, str, len); - cur = cur + len; - _ASSERTE(start <= cur && cur <= end); - } - - void swap(OutString& str) { - char* tmp = start; - start = str.start; - str.start = tmp; - tmp = end; - end = str.end; - str.end = tmp; - tmp = cur; - cur = str.cur; - str.cur = tmp; - _ASSERTE(start <= cur && cur <= end); - } - - void clear() { cur = start; } - size_t length() const { return(cur-start); } - - // return the null terminated string, OutString keeps ownership - const char* val() const { *cur = 0; return(start); } - - // grab string (caller must now delete) OutString is cleared - char* grab() { char* ret = start; *cur = 0; end = cur = start = 0; return(ret); } - -private: - void Realloc(size_t neededSpace); - - char *start; // start of the buffer - char *end; // points at the last place null terminator can go - char *cur; // points at a null terminator -}; - -#endif // _OutString_h - diff --git a/src/inc/pedecoder.h b/src/inc/pedecoder.h deleted file mode 100644 index 8163ffff3..000000000 --- a/src/inc/pedecoder.h +++ /dev/null @@ -1,480 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -// -------------------------------------------------------------------------------- -// PEDecoder.h -// - -// -------------------------------------------------------------------------------- - -// -------------------------------------------------------------------------------- -// PEDecoder - Utility class for reading and verifying PE files. -// -// Note that the Check step is optional if you are willing to trust the -// integrity of the image. -// (Or at any rate can be factored into an initial verification step.) -// -// Functions which access the memory of the PE file take a "flat" flag - this -// indicates whether the PE images data has been loaded flat the way it resides in the file, -// or if the sections have been mapped into memory at the proper base addresses. -// -// Finally, some functions take an optional "size" argument, which can be used for -// range verification. This is an optional parameter, but if you omit it be sure -// you verify the size in some other way. -// -------------------------------------------------------------------------------- - - -#ifndef PEDECODER_H_ -#define PEDECODER_H_ - -// -------------------------------------------------------------------------------- -// Required headers -// -------------------------------------------------------------------------------- - -#include "windows.h" -#include "clrtypes.h" -#include "check.h" -#include "contract.h" -#include "cor.h" -#include "corhdr.h" - -#ifdef FEATURE_PREJIT -#include "corcompile.h" -#else // FEATURE_PREJIT -typedef DPTR(struct COR_ILMETHOD) PTR_COR_ILMETHOD; -struct CORCOMPILE_HEADER { int dummy_field; }; -typedef DPTR(struct CORCOMPILE_HEADER) PTR_CORCOMPILE_HEADER; -#define CORCOMPILE_IS_POINTER_TAGGED(fixup) (false) -#endif // FEATURE_PREJIT - -#include "readytorun.h" -typedef DPTR(struct READYTORUN_HEADER) PTR_READYTORUN_HEADER; - -typedef DPTR(IMAGE_COR20_HEADER) PTR_IMAGE_COR20_HEADER; - -// -------------------------------------------------------------------------------- -// Forward declared types -// -------------------------------------------------------------------------------- - -class Module; - -// -------------------------------------------------------------------------------- -// RVA definition -// -------------------------------------------------------------------------------- - -// Needs to be DWORD to avoid conflict with -typedef DWORD RVA; - -#ifdef _MSC_VER -// Wrapper to suppress ambigous overload problems with MSVC. -inline CHECK CheckOverflow(RVA value1, COUNT_T value2) -{ - WRAPPER_NO_CONTRACT; - CHECK(CheckOverflow((UINT32) value1, (UINT32) value2)); - CHECK_OK; -} -#endif // _MSC_VER - -// -------------------------------------------------------------------------------- -// IMAGE_FILE_MACHINE_NATIVE -// -------------------------------------------------------------------------------- - -#if defined(_TARGET_X86_) -#define IMAGE_FILE_MACHINE_NATIVE IMAGE_FILE_MACHINE_I386 -#elif defined(_TARGET_AMD64_) -#define IMAGE_FILE_MACHINE_NATIVE IMAGE_FILE_MACHINE_AMD64 -#elif defined(_TARGET_ARM_) -#define IMAGE_FILE_MACHINE_NATIVE IMAGE_FILE_MACHINE_ARMNT -#elif defined(_TARGET_ARM64_) -#define IMAGE_FILE_MACHINE_NATIVE IMAGE_FILE_MACHINE_ARM64 -#else -#error "port me" -#endif - -// Machine code for native images -#if defined(__APPLE__) -#define IMAGE_FILE_MACHINE_NATIVE_OS_OVERRIDE 0x4644 -#elif defined(__FreeBSD__) -#define IMAGE_FILE_MACHINE_NATIVE_OS_OVERRIDE 0xADC4 -#elif defined(__linux__) -#define IMAGE_FILE_MACHINE_NATIVE_OS_OVERRIDE 0x7B79 -#elif defined(__NetBSD__) -#define IMAGE_FILE_MACHINE_NATIVE_OS_OVERRIDE 0x1993 -#else -#define IMAGE_FILE_MACHINE_NATIVE_OS_OVERRIDE 0 -#endif - -#define IMAGE_FILE_MACHINE_NATIVE_NI (IMAGE_FILE_MACHINE_NATIVE ^ IMAGE_FILE_MACHINE_NATIVE_OS_OVERRIDE) - -// -------------------------------------------------------------------------------- -// Types -// -------------------------------------------------------------------------------- - -typedef DPTR(class PEDecoder) PTR_PEDecoder; - -class PEDecoder -{ - public: - - // ------------------------------------------------------------ - // Public API - // ------------------------------------------------------------ - - // Access functions are divided into 3 categories: - // Has - check if the element is present - // Check - Do consistency checks on the element (requires Has). - // This step is optional if you are willing to trust the integrity of the - // image. (It is asserted in a checked build.) - // Get - Access the element (requires Has and Check) - - PEDecoder(); - PEDecoder(void *flatBase, COUNT_T size); // flatBase is the raw disk layout data (using MapViewOfFile) - PEDecoder(PTR_VOID mappedBase, bool relocated = FALSE); // mappedBase is the mapped/expanded file (using LoadLibrary) - - void Init(void *flatBase, COUNT_T size); - HRESULT Init(void *mappedBase, bool relocated = FALSE); - void Reset(); //make sure you don't have a thread race - - PTR_VOID GetBase() const; // Currently loaded base, as opposed to GetPreferredBase() - BOOL IsMapped() const; - BOOL IsRelocated() const; - BOOL IsFlat() const; - BOOL HasContents() const; - COUNT_T GetSize() const; // size of file on disk, as opposed to GetVirtualSize() - - // High level image checks: - - CHECK CheckFormat() const; // Check whatever is present - CHECK CheckNTFormat() const; // Check a PE file image - CHECK CheckCORFormat() const; // Check a COR image (IL or native) - CHECK CheckILFormat() const; // Check a managed image - CHECK CheckILOnlyFormat() const; // Check an IL only image - CHECK CheckNativeFormat() const; // Check a native image - - // NT header access - - BOOL HasNTHeaders() const; - CHECK CheckNTHeaders() const; - - IMAGE_NT_HEADERS32 *GetNTHeaders32() const; - IMAGE_NT_HEADERS64 *GetNTHeaders64() const; - BOOL Has32BitNTHeaders() const; - - const void *GetHeaders(COUNT_T *pSize = NULL) const; - - BOOL IsDll() const; - BOOL HasBaseRelocations() const; - const void *GetPreferredBase() const; // OptionalHeaders.ImageBase - COUNT_T GetVirtualSize() const; // OptionalHeaders.SizeOfImage - size of mapped/expanded image in memory - WORD GetSubsystem() const; - WORD GetDllCharacteristics() const; - DWORD GetTimeDateStamp() const; - DWORD GetCheckSum() const; - WORD GetMachine() const; - WORD GetCharacteristics() const; - DWORD GetFileAlignment() const; - DWORD GetSectionAlignment() const; - SIZE_T GetSizeOfStackReserve() const; - SIZE_T GetSizeOfStackCommit() const; - SIZE_T GetSizeOfHeapReserve() const; - SIZE_T GetSizeOfHeapCommit() const; - UINT32 GetLoaderFlags() const; - UINT32 GetWin32VersionValue() const; - COUNT_T GetNumberOfRvaAndSizes() const; - COUNT_T GetNumberOfSections() const; - PTR_IMAGE_SECTION_HEADER FindFirstSection() const; - IMAGE_SECTION_HEADER *FindSection(LPCSTR sectionName) const; - - DWORD GetImageIdentity() const; - - BOOL HasWriteableSections() const; - - // Directory entry access - - BOOL HasDirectoryEntry(int entry) const; - CHECK CheckDirectoryEntry(int entry, int forbiddenFlags = 0, IsNullOK ok = NULL_NOT_OK) const; - IMAGE_DATA_DIRECTORY *GetDirectoryEntry(int entry) const; - TADDR GetDirectoryEntryData(int entry, COUNT_T *pSize = NULL) const; - - // IMAGE_DATA_DIRECTORY access - - CHECK CheckDirectory(IMAGE_DATA_DIRECTORY *pDir, int forbiddenFlags = 0, IsNullOK ok = NULL_NOT_OK) const; - TADDR GetDirectoryData(IMAGE_DATA_DIRECTORY *pDir) const; - TADDR GetDirectoryData(IMAGE_DATA_DIRECTORY *pDir, COUNT_T *pSize) const; - - // Basic RVA access - - CHECK CheckRva(RVA rva, IsNullOK ok = NULL_NOT_OK) const; - CHECK CheckRva(RVA rva, COUNT_T size, int forbiddenFlags=0, IsNullOK ok = NULL_NOT_OK) const; - TADDR GetRvaData(RVA rva, IsNullOK ok = NULL_NOT_OK) const; - // Called with ok=NULL_OK only for mapped fields (RVA statics) - - CHECK CheckData(const void *data, IsNullOK ok = NULL_NOT_OK) const; - CHECK CheckData(const void *data, COUNT_T size, IsNullOK ok = NULL_NOT_OK) const; - RVA GetDataRva(const TADDR data) const; - BOOL PointerInPE(PTR_CVOID data) const; - - // Flat mapping utilities - using PointerToRawData instead of (Relative)VirtualAddress - CHECK CheckOffset(COUNT_T fileOffset, IsNullOK ok = NULL_NOT_OK) const; - CHECK CheckOffset(COUNT_T fileOffset, COUNT_T size, IsNullOK ok = NULL_NOT_OK) const; - TADDR GetOffsetData(COUNT_T fileOffset, IsNullOK ok = NULL_NOT_OK) const; - // Called with ok=NULL_OK only for mapped fields (RVA statics) - - // Mapping between RVA and file offsets - COUNT_T RvaToOffset(RVA rva) const; - RVA OffsetToRva(COUNT_T fileOffset) const; - - // Base intra-image pointer access - // (These are for pointers retrieved out of the PE image) - - CHECK CheckInternalAddress(SIZE_T address, IsNullOK ok = NULL_NOT_OK) const; - CHECK CheckInternalAddress(SIZE_T address, COUNT_T size, IsNullOK ok = NULL_NOT_OK) const; - TADDR GetInternalAddressData(SIZE_T address) const; - - // CLR loader IL Image verification - these checks apply to IL_ONLY images. - - BOOL IsILOnly() const; - CHECK CheckILOnly() const; - - void LayoutILOnly(void *base, BOOL allowFullPE = FALSE) const; - - // Strong name & hashing support - - BOOL HasStrongNameSignature() const; - CHECK CheckStrongNameSignature() const; - PTR_CVOID GetStrongNameSignature(COUNT_T *pSize = NULL) const; - - // CorHeader flag support - - // IsStrongNameSigned indicates whether the signature has been filled in. - // (otherwise if it has a signature it is delay signed.) - BOOL IsStrongNameSigned() const; // TRUE if the COMIMAGE_FLAGS_STRONGNAMESIGNED flag is set - - // TLS - - BOOL HasTls() const; - CHECK CheckTls() const; - PTR_VOID GetTlsRange(COUNT_T *pSize = NULL) const; - UINT32 GetTlsIndex() const; - -#ifndef FEATURE_PAL - // Win32 resources - void *GetWin32Resource(LPCWSTR lpName, LPCWSTR lpType, COUNT_T *pSize = NULL) const; -#endif // FEATURE_PAL - - // COR header fields - - BOOL HasCorHeader() const; - CHECK CheckCorHeader() const; - IMAGE_COR20_HEADER *GetCorHeader() const; - - PTR_CVOID GetMetadata(COUNT_T *pSize = NULL) const; - - const void *GetResources(COUNT_T *pSize = NULL) const; - CHECK CheckResource(COUNT_T offset) const; - const void *GetResource(COUNT_T offset, COUNT_T *pSize = NULL) const; - - BOOL HasManagedEntryPoint() const; - ULONG GetEntryPointToken() const; - IMAGE_COR_VTABLEFIXUP *GetVTableFixups(COUNT_T *pCount = NULL) const; - - // Native header access - BOOL HasNativeHeader() const; - CHECK CheckNativeHeader() const; - CORCOMPILE_HEADER *GetNativeHeader() const; - BOOL IsNativeMachineFormat() const; - BOOL IsI386() const; - - void GetPEKindAndMachine(DWORD * pdwPEKind, DWORD *pdwMachine); // Returns CorPEKind flags - BOOL IsPlatformNeutral(); // Returns TRUE for IL-only platform neutral images - - // - // Verifies that the IL is within the bounds of the image. - // - CHECK CheckILMethod(RVA rva); - - // - // Compute size of IL blob. Assumes that the IL is within the bounds of the image - make sure - // to call CheckILMethod before calling this method. - // - static SIZE_T ComputeILMethodSize(TADDR pIL); - - // Debug directory access, returns NULL if no such entry - PTR_IMAGE_DEBUG_DIRECTORY GetDebugDirectoryEntry(UINT index) const; - -#ifdef FEATURE_PREJIT - CHECK CheckNativeHeaderVersion() const; - - // ManagedNative fields - CORCOMPILE_CODE_MANAGER_ENTRY *GetNativeCodeManagerTable() const; - CORCOMPILE_EE_INFO_TABLE *GetNativeEEInfoTable() const; - void *GetNativeHelperTable(COUNT_T *pSize = NULL) const; - CORCOMPILE_VERSION_INFO *GetNativeVersionInfo() const; - CORCOMPILE_VERSION_INFO *GetNativeVersionInfoMaybeNull(bool skipCheckNativeHeader = false) const; - BOOL HasNativeDebugMap() const; - TADDR GetNativeDebugMap(COUNT_T *pSize = NULL) const; - Module *GetPersistedModuleImage(COUNT_T *pSize = NULL) const; - PCODE GetNativeHotCode(COUNT_T * pSize = NULL) const; - PCODE GetNativeCode(COUNT_T * pSize = NULL) const; - PCODE GetNativeColdCode(COUNT_T * pSize = NULL) const; - - CORCOMPILE_METHOD_PROFILE_LIST *GetNativeProfileDataList(COUNT_T *pSize = NULL) const; - PTR_CVOID GetNativeManifestMetadata(COUNT_T *pSize = NULL) const; - const void *GetNativePreferredBase() const; - BOOL GetNativeILHasSecurityDirectory() const; - BOOL GetNativeILIsIbcOptimized() const; - BOOL GetNativeILHasReadyToRunHeader() const; - BOOL IsNativeILILOnly() const; - BOOL IsNativeILDll() const; - void GetNativeILPEKindAndMachine(DWORD* pdwKind, DWORD* pdwMachine) const; - CORCOMPILE_DEPENDENCY * GetNativeDependencies(COUNT_T *pCount = NULL) const; - - COUNT_T GetNativeImportTableCount() const; - CORCOMPILE_IMPORT_TABLE_ENTRY *GetNativeImportFromIndex(COUNT_T index) const; - CHECK CheckNativeImportFromIndex(COUNT_T index) const; - - PTR_CORCOMPILE_IMPORT_SECTION GetNativeImportSections(COUNT_T *pCount = NULL) const; - PTR_CORCOMPILE_IMPORT_SECTION GetNativeImportSectionFromIndex(COUNT_T index) const; - PTR_CORCOMPILE_IMPORT_SECTION GetNativeImportSectionForRVA(RVA rva) const; - - TADDR GetStubsTable(COUNT_T *pSize = NULL) const; - TADDR GetVirtualSectionsTable(COUNT_T *pSize = NULL) const; -#endif // FEATURE_PREJIT - - BOOL HasReadyToRunHeader() const; - READYTORUN_HEADER *GetReadyToRunHeader() const; - - void GetEXEStackSizes(SIZE_T *PE_SizeOfStackReserve, SIZE_T *PE_SizeOfStackCommit) const; - - CHECK CheckWillCreateGuardPage() const; - - // Native DLLMain Entrypoint - BOOL HasNativeEntryPoint() const; - void *GetNativeEntryPoint() const; - -#ifdef _DEBUG - // Stress mode for relocations - static BOOL GetForceRelocs(); - static BOOL ForceRelocForDLL(LPCWSTR lpFileName); -#endif - -#ifdef DACCESS_COMPILE - void EnumMemoryRegions(CLRDataEnumMemoryFlags flags, bool enumThis); -#endif - - protected: - - // ------------------------------------------------------------ - // Protected API for subclass use - // ------------------------------------------------------------ - - // Checking utilites - static CHECK CheckBounds(RVA rangeBase, COUNT_T rangeSize, RVA rva); - static CHECK CheckBounds(RVA rangeBase, COUNT_T rangeSize, RVA rva, COUNT_T size); - - static CHECK CheckBounds(const void *rangeBase, COUNT_T rangeSize, const void *pointer); - static CHECK CheckBounds(PTR_CVOID rangeBase, COUNT_T rangeSize, PTR_CVOID pointer, COUNT_T size); - - protected: - - // Flat mapping utilities - using PointerToRawData instead of (Relative)VirtualAddress - IMAGE_SECTION_HEADER *RvaToSection(RVA rva) const; - IMAGE_SECTION_HEADER *OffsetToSection(COUNT_T fileOffset) const; - - void SetRelocated(); - - private: - - // ------------------------------------------------------------ - // Internal functions - // ------------------------------------------------------------ - - enum METADATA_SECTION_TYPE - { - METADATA_SECTION_FULL, -#ifdef FEATURE_PREJIT - METADATA_SECTION_MANIFEST -#endif - }; - - IMAGE_DATA_DIRECTORY *GetMetaDataHelper(METADATA_SECTION_TYPE type) const; - - static PTR_IMAGE_SECTION_HEADER FindFirstSection(IMAGE_NT_HEADERS * pNTHeaders); - - IMAGE_NT_HEADERS *FindNTHeaders() const; - IMAGE_COR20_HEADER *FindCorHeader() const; - CORCOMPILE_HEADER *FindNativeHeader() const; - READYTORUN_HEADER *FindReadyToRunHeader() const; - - // Flat mapping utilities - RVA InternalAddressToRva(SIZE_T address) const; - - // NT header subchecks - CHECK CheckSection(COUNT_T previousAddressEnd, COUNT_T addressStart, COUNT_T addressSize, - COUNT_T previousOffsetEnd, COUNT_T offsetStart, COUNT_T offsetSize) const; - - // Pure managed subchecks - CHECK CheckILOnlyImportDlls() const; - CHECK CheckILOnlyImportByNameTable(RVA rva) const; - CHECK CheckILOnlyBaseRelocations() const; - CHECK CheckILOnlyEntryPoint() const; - - // ------------------------------------------------------------ - // Instance members - // ------------------------------------------------------------ - - enum - { - FLAG_MAPPED = 0x01, // the file is mapped/hydrated (vs. the raw disk layout) - FLAG_CONTENTS = 0x02, // the file has contents - FLAG_RELOCATED = 0x04, // relocs have been applied - FLAG_NT_CHECKED = 0x10, - FLAG_COR_CHECKED = 0x20, - FLAG_IL_ONLY_CHECKED = 0x40, - FLAG_NATIVE_CHECKED = 0x80, - - FLAG_HAS_NO_READYTORUN_HEADER = 0x100, - }; - - TADDR m_base; - COUNT_T m_size; // size of file on disk, as opposed to OptionalHeaders.SizeOfImage - ULONG m_flags; - - PTR_IMAGE_NT_HEADERS m_pNTHeaders; - PTR_IMAGE_COR20_HEADER m_pCorHeader; - PTR_CORCOMPILE_HEADER m_pNativeHeader; - PTR_READYTORUN_HEADER m_pReadyToRunHeader; -}; - -// -// MethodSectionIterator class is used to iterate hot (or) cold method section in an ngen image. -// It can also iterate nibble maps generated by the JIT in a regular HeapList. -// -class MethodSectionIterator -{ - private: - PTR_DWORD m_codeTableStart; - PTR_DWORD m_codeTable; - PTR_DWORD m_codeTableEnd; - - BYTE *m_code; - - DWORD m_dword; - DWORD m_index; - - BYTE *m_current; - - public: - - //If code is a target pointer, then GetMethodCode and FindMethodCode return - //target pointers. codeTable may be a pointer of either type, since it is - //converted internally into a host pointer. - MethodSectionIterator(const void *code, SIZE_T codeSize, - const void *codeTable, SIZE_T codeTableSize); - BOOL Next(); - BYTE *GetMethodCode() { return m_current; } // Get the start of method code of the current method in the iterator -}; - -#include "pedecoder.inl" - -#endif // PEDECODER_H_ diff --git a/src/inc/pedecoder.inl b/src/inc/pedecoder.inl deleted file mode 100644 index c8400af46..000000000 --- a/src/inc/pedecoder.inl +++ /dev/null @@ -1,1429 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -// -------------------------------------------------------------------------------- -// PEDecoder.inl -// - -// -------------------------------------------------------------------------------- - -#ifndef _PEDECODER_INL_ -#define _PEDECODER_INL_ - -#include "pedecoder.h" -#include "ex.h" - -#ifndef DACCESS_COMPILE - -inline PEDecoder::PEDecoder() - : m_base(0), - m_size(0), - m_flags(0), - m_pNTHeaders(nullptr), - m_pCorHeader(nullptr), - m_pNativeHeader(nullptr), - m_pReadyToRunHeader(nullptr) -{ - CONTRACTL - { - CONSTRUCTOR_CHECK; - NOTHROW; - CANNOT_TAKE_LOCK; - GC_NOTRIGGER; - } - CONTRACTL_END; -} -#else -inline PEDecoder::PEDecoder() -{ - LIMITED_METHOD_CONTRACT; -} -#endif // #ifndef DACCESS_COMPILE - -inline PTR_VOID PEDecoder::GetBase() const -{ - LIMITED_METHOD_CONTRACT; - SUPPORTS_DAC; - - return PTR_VOID(m_base); -} - -inline BOOL PEDecoder::IsMapped() const -{ - LIMITED_METHOD_CONTRACT; - SUPPORTS_DAC; - - return (m_flags & FLAG_MAPPED) != 0; -} - -inline BOOL PEDecoder::IsRelocated() const -{ - LIMITED_METHOD_CONTRACT; - - return (m_flags & FLAG_RELOCATED) != 0; -} - -inline void PEDecoder::SetRelocated() -{ - m_flags |= FLAG_RELOCATED; -} - -inline BOOL PEDecoder::IsFlat() const -{ - LIMITED_METHOD_CONTRACT; - - return HasContents() && !IsMapped(); -} - -inline BOOL PEDecoder::HasContents() const -{ - LIMITED_METHOD_CONTRACT; - SUPPORTS_DAC; - - return (m_flags & FLAG_CONTENTS) != 0; -} - -inline COUNT_T PEDecoder::GetSize() const -{ - LIMITED_METHOD_DAC_CONTRACT; - - return m_size; -} - -inline PEDecoder::PEDecoder(PTR_VOID mappedBase, bool fixedUp /*= FALSE*/) - : m_base(dac_cast(mappedBase)), - m_size(0), - m_flags(FLAG_MAPPED | FLAG_CONTENTS | FLAG_NT_CHECKED | (fixedUp ? FLAG_RELOCATED : 0)), - m_pNTHeaders(nullptr), - m_pCorHeader(nullptr), - m_pNativeHeader(nullptr), - m_pReadyToRunHeader(nullptr) -{ - CONTRACTL - { - CONSTRUCTOR_CHECK; - PRECONDITION(CheckPointer(mappedBase)); - PRECONDITION(CheckAligned(mappedBase, GetOsPageSize())); - PRECONDITION(PEDecoder(mappedBase,fixedUp).CheckNTHeaders()); - THROWS; - GC_NOTRIGGER; - SO_TOLERANT; - SUPPORTS_DAC; - } - CONTRACTL_END; - - // Temporarily set the size to 2 pages, so we can get the headers. - m_size = GetOsPageSize()*2; - - m_pNTHeaders = PTR_IMAGE_NT_HEADERS(FindNTHeaders()); - if (!m_pNTHeaders) - ThrowHR(COR_E_BADIMAGEFORMAT); - - m_size = VAL32(m_pNTHeaders->OptionalHeader.SizeOfImage); -} - -#ifndef DACCESS_COMPILE - -//REM -//what's the right way to do this? -//we want to use some against TADDR, but also want to do -//some against what's just in the current process. -//m_base is a TADDR in DAC all the time, though. -//Have to implement separate fn to do the lookup?? -inline PEDecoder::PEDecoder(void *flatBase, COUNT_T size) - : m_base((TADDR)flatBase), - m_size(size), - m_flags(FLAG_CONTENTS), - m_pNTHeaders(NULL), - m_pCorHeader(NULL), - m_pNativeHeader(NULL), - m_pReadyToRunHeader(NULL) -{ - CONTRACTL - { - CONSTRUCTOR_CHECK; - PRECONDITION(CheckPointer(flatBase)); - NOTHROW; - GC_NOTRIGGER; - CANNOT_TAKE_LOCK; - } - CONTRACTL_END; -} - -inline void PEDecoder::Init(void *flatBase, COUNT_T size) -{ - CONTRACTL - { - INSTANCE_CHECK; - PRECONDITION((size == 0) || CheckPointer(flatBase)); - PRECONDITION(!HasContents()); - NOTHROW; - GC_NOTRIGGER; - } - CONTRACTL_END; - - m_base = (TADDR)flatBase; - m_size = size; - m_flags = FLAG_CONTENTS; -} - - - -inline HRESULT PEDecoder::Init(void *mappedBase, bool fixedUp /*= FALSE*/) -{ - CONTRACTL - { - INSTANCE_CHECK; - NOTHROW; - GC_NOTRIGGER; - PRECONDITION(CheckPointer(mappedBase)); - PRECONDITION(CheckAligned(mappedBase, GetOsPageSize())); - PRECONDITION(!HasContents()); - } - CONTRACTL_END; - - m_base = (TADDR)mappedBase; - m_flags = FLAG_MAPPED | FLAG_CONTENTS; - if (fixedUp) - m_flags |= FLAG_RELOCATED; - - // Temporarily set the size to 2 pages, so we can get the headers. - m_size = GetOsPageSize()*2; - - m_pNTHeaders = FindNTHeaders(); - if (!m_pNTHeaders) - return COR_E_BADIMAGEFORMAT; - - m_size = VAL32(m_pNTHeaders->OptionalHeader.SizeOfImage); - return S_OK; -} - -inline void PEDecoder::Reset() -{ - CONTRACTL - { - INSTANCE_CHECK; - NOTHROW; - GC_NOTRIGGER; - } - CONTRACTL_END; - m_base=NULL; - m_flags=NULL; - m_size=NULL; - m_pNTHeaders=NULL; - m_pCorHeader=NULL; - m_pNativeHeader=NULL; - m_pReadyToRunHeader=NULL; -} -#endif // #ifndef DACCESS_COMPILE - - -inline IMAGE_NT_HEADERS32 *PEDecoder::GetNTHeaders32() const -{ - WRAPPER_NO_CONTRACT; - SUPPORTS_DAC; - return dac_cast(FindNTHeaders()); -} - -inline IMAGE_NT_HEADERS64 *PEDecoder::GetNTHeaders64() const -{ - WRAPPER_NO_CONTRACT; - SUPPORTS_DAC; - return dac_cast(FindNTHeaders()); -} - -inline BOOL PEDecoder::Has32BitNTHeaders() const -{ - CONTRACTL - { - INSTANCE_CHECK; - PRECONDITION(HasNTHeaders()); - NOTHROW; - GC_NOTRIGGER; - SO_TOLERANT; - SUPPORTS_DAC; - CANNOT_TAKE_LOCK; - SUPPORTS_DAC; - } - CONTRACTL_END; - - return (FindNTHeaders()->OptionalHeader.Magic == VAL16(IMAGE_NT_OPTIONAL_HDR32_MAGIC)); -} - -inline const void *PEDecoder::GetHeaders(COUNT_T *pSize) const -{ - CONTRACT(const void *) - { - INSTANCE_CHECK; - PRECONDITION(CheckNTHeaders()); - NOTHROW; - GC_NOTRIGGER; - POSTCONDITION(CheckPointer(RETVAL)); - } - CONTRACT_END; - - //even though some data in OptionalHeader is different for 32 and 64, this field is the same - if (pSize != NULL) - *pSize = VAL32(FindNTHeaders()->OptionalHeader.SizeOfHeaders); - - RETURN (const void *) m_base; -} - -inline BOOL PEDecoder::IsDll() const -{ - CONTRACTL - { - INSTANCE_CHECK; - PRECONDITION(CheckNTHeaders()); - NOTHROW; - GC_NOTRIGGER; - SUPPORTS_DAC; - } - CONTRACTL_END; - - return ((FindNTHeaders()->FileHeader.Characteristics & VAL16(IMAGE_FILE_DLL)) != 0); -} - -inline BOOL PEDecoder::HasBaseRelocations() const -{ - CONTRACTL - { - INSTANCE_CHECK; - PRECONDITION(CheckNTHeaders()); - NOTHROW; - GC_NOTRIGGER; - } - CONTRACTL_END; - - return ((FindNTHeaders()->FileHeader.Characteristics & VAL16(IMAGE_FILE_RELOCS_STRIPPED)) == 0); -} - -inline const void *PEDecoder::GetPreferredBase() const -{ - CONTRACT(const void *) - { - INSTANCE_CHECK; - PRECONDITION(CheckNTHeaders()); - NOTHROW; - GC_NOTRIGGER; - SO_TOLERANT; - POSTCONDITION(CheckPointer(RETVAL, NULL_OK)); - } - CONTRACT_END; - - if (Has32BitNTHeaders()) - RETURN (const void *) (SIZE_T) VAL32(GetNTHeaders32()->OptionalHeader.ImageBase); - else - RETURN (const void *) (SIZE_T) VAL64(GetNTHeaders64()->OptionalHeader.ImageBase); -} - -inline COUNT_T PEDecoder::GetVirtualSize() const -{ - CONTRACTL - { - INSTANCE_CHECK; - PRECONDITION(CheckNTHeaders()); - NOTHROW; - GC_NOTRIGGER; - SUPPORTS_DAC; - SO_TOLERANT; - } - CONTRACTL_END; - - //even though some data in OptionalHeader is different for 32 and 64, this field is the same - return VAL32(FindNTHeaders()->OptionalHeader.SizeOfImage); -} - -inline WORD PEDecoder::GetSubsystem() const -{ - CONTRACTL - { - INSTANCE_CHECK; - PRECONDITION(CheckNTHeaders()); - NOTHROW; - GC_NOTRIGGER; - SUPPORTS_DAC; - SO_TOLERANT; - } - CONTRACTL_END; - - //even though some data in OptionalHeader is different for 32 and 64, this field is the same - return VAL16(FindNTHeaders()->OptionalHeader.Subsystem); -} - -inline WORD PEDecoder::GetDllCharacteristics() const -{ - CONTRACTL - { - INSTANCE_CHECK; - PRECONDITION(CheckNTHeaders()); - NOTHROW; - GC_NOTRIGGER; - SO_TOLERANT; - } - CONTRACTL_END; - - //even though some data in OptionalHeader is different for 32 and 64, this field is the same - return VAL16(FindNTHeaders()->OptionalHeader.DllCharacteristics); -} - -inline DWORD PEDecoder::GetTimeDateStamp() const -{ - CONTRACTL - { - INSTANCE_CHECK; - PRECONDITION(CheckNTHeaders()); - NOTHROW; - GC_NOTRIGGER; - } - CONTRACTL_END; - - return VAL32(FindNTHeaders()->FileHeader.TimeDateStamp); -} - -inline DWORD PEDecoder::GetCheckSum() const -{ - CONTRACTL - { - INSTANCE_CHECK; - PRECONDITION(CheckNTHeaders()); - NOTHROW; - GC_NOTRIGGER; - } - CONTRACTL_END; - - //even though some data in OptionalHeader is different for 32 and 64, this field is the same - return VAL32(FindNTHeaders()->OptionalHeader.CheckSum); -} - -inline DWORD PEDecoder::GetFileAlignment() const -{ - CONTRACTL - { - INSTANCE_CHECK; - PRECONDITION(CheckNTHeaders()); - NOTHROW; - GC_NOTRIGGER; - } - CONTRACTL_END; - - //even though some data in OptionalHeader is different for 32 and 64, this field is the same - return VAL32(FindNTHeaders()->OptionalHeader.FileAlignment); -} - -inline DWORD PEDecoder::GetSectionAlignment() const -{ - CONTRACTL - { - INSTANCE_CHECK; - PRECONDITION(CheckNTHeaders()); - NOTHROW; - GC_NOTRIGGER; - } - CONTRACTL_END; - - //even though some data in OptionalHeader is different for 32 and 64, this field is the same - return VAL32(FindNTHeaders()->OptionalHeader.SectionAlignment); -} - -inline WORD PEDecoder::GetMachine() const -{ - CONTRACTL - { - INSTANCE_CHECK; - PRECONDITION(CheckNTHeaders()); - NOTHROW; - GC_NOTRIGGER; - } - CONTRACTL_END; - - return VAL16(FindNTHeaders()->FileHeader.Machine); -} - -inline WORD PEDecoder::GetCharacteristics() const -{ - CONTRACTL - { - INSTANCE_CHECK; - PRECONDITION(CheckNTHeaders()); - NOTHROW; - GC_NOTRIGGER; - } - CONTRACTL_END; - - return VAL16(FindNTHeaders()->FileHeader.Characteristics); -} - -inline SIZE_T PEDecoder::GetSizeOfStackReserve() const -{ - CONTRACTL - { - INSTANCE_CHECK; - PRECONDITION(CheckNTHeaders()); - NOTHROW; - GC_NOTRIGGER; - } - CONTRACTL_END; - - if (Has32BitNTHeaders()) - return (SIZE_T) VAL32(GetNTHeaders32()->OptionalHeader.SizeOfStackReserve); - else - return (SIZE_T) VAL64(GetNTHeaders64()->OptionalHeader.SizeOfStackReserve); -} - - -inline SIZE_T PEDecoder::GetSizeOfStackCommit() const -{ - CONTRACTL - { - INSTANCE_CHECK; - PRECONDITION(CheckNTHeaders()); - NOTHROW; - GC_NOTRIGGER; - } - CONTRACTL_END; - - if (Has32BitNTHeaders()) - return (SIZE_T) VAL32(GetNTHeaders32()->OptionalHeader.SizeOfStackCommit); - else - return (SIZE_T) VAL64(GetNTHeaders64()->OptionalHeader.SizeOfStackCommit); -} - - -inline SIZE_T PEDecoder::GetSizeOfHeapReserve() const -{ - CONTRACTL - { - INSTANCE_CHECK; - PRECONDITION(CheckNTHeaders()); - NOTHROW; - GC_NOTRIGGER; - } - CONTRACTL_END; - - if (Has32BitNTHeaders()) - return (SIZE_T) VAL32(GetNTHeaders32()->OptionalHeader.SizeOfHeapReserve); - else - return (SIZE_T) VAL64(GetNTHeaders64()->OptionalHeader.SizeOfHeapReserve); -} - - -inline SIZE_T PEDecoder::GetSizeOfHeapCommit() const -{ - CONTRACTL - { - INSTANCE_CHECK; - PRECONDITION(CheckNTHeaders()); - NOTHROW; - GC_NOTRIGGER; - } - CONTRACTL_END; - - if (Has32BitNTHeaders()) - return (SIZE_T) VAL32(GetNTHeaders32()->OptionalHeader.SizeOfHeapCommit); - else - return (SIZE_T) VAL64(GetNTHeaders64()->OptionalHeader.SizeOfHeapCommit); -} - -inline UINT32 PEDecoder::GetLoaderFlags() const -{ - CONTRACTL - { - INSTANCE_CHECK; - PRECONDITION(CheckNTHeaders()); - NOTHROW; - GC_NOTRIGGER; - } - CONTRACTL_END; - - if (Has32BitNTHeaders()) - return VAL32(GetNTHeaders32()->OptionalHeader.LoaderFlags); - else - return VAL32(GetNTHeaders64()->OptionalHeader.LoaderFlags); -} - -inline UINT32 PEDecoder::GetWin32VersionValue() const -{ - CONTRACTL - { - INSTANCE_CHECK; - PRECONDITION(CheckNTHeaders()); - NOTHROW; - GC_NOTRIGGER; - } - CONTRACTL_END; - - if (Has32BitNTHeaders()) - return VAL32(GetNTHeaders32()->OptionalHeader.Win32VersionValue); - else - return VAL32(GetNTHeaders64()->OptionalHeader.Win32VersionValue); -} - -inline COUNT_T PEDecoder::GetNumberOfRvaAndSizes() const -{ - CONTRACTL - { - INSTANCE_CHECK; - PRECONDITION(CheckNTHeaders()); - NOTHROW; - GC_NOTRIGGER; - } - CONTRACTL_END; - - if (Has32BitNTHeaders()) - return VAL32(GetNTHeaders32()->OptionalHeader.NumberOfRvaAndSizes); - else - return VAL32(GetNTHeaders64()->OptionalHeader.NumberOfRvaAndSizes); -} - -inline BOOL PEDecoder::HasDirectoryEntry(int entry) const -{ - CONTRACTL - { - INSTANCE_CHECK; - PRECONDITION(CheckNTHeaders()); - NOTHROW; - GC_NOTRIGGER; - SUPPORTS_DAC; - SO_TOLERANT; - } - CONTRACTL_END; - - if (Has32BitNTHeaders()) - return (GetNTHeaders32()->OptionalHeader.DataDirectory[entry].VirtualAddress != 0); - else - return (GetNTHeaders64()->OptionalHeader.DataDirectory[entry].VirtualAddress != 0); -} - -inline IMAGE_DATA_DIRECTORY *PEDecoder::GetDirectoryEntry(int entry) const -{ - CONTRACT(IMAGE_DATA_DIRECTORY *) - { - INSTANCE_CHECK; - PRECONDITION(CheckNTHeaders()); - NOTHROW; - GC_NOTRIGGER; - POSTCONDITION(CheckPointer(RETVAL)); - SO_TOLERANT; - CANNOT_TAKE_LOCK; - SUPPORTS_DAC; - } - CONTRACT_END; - - if (Has32BitNTHeaders()) - RETURN dac_cast( - dac_cast(GetNTHeaders32()) + - offsetof(IMAGE_NT_HEADERS32, OptionalHeader.DataDirectory) + - entry * sizeof(IMAGE_DATA_DIRECTORY)); - else - RETURN dac_cast( - dac_cast(GetNTHeaders64()) + - offsetof(IMAGE_NT_HEADERS64, OptionalHeader.DataDirectory) + - entry * sizeof(IMAGE_DATA_DIRECTORY)); -} - -inline TADDR PEDecoder::GetDirectoryEntryData(int entry, COUNT_T *pSize) const -{ - CONTRACT(TADDR) - { - INSTANCE_CHECK; - PRECONDITION(CheckNTHeaders()); - PRECONDITION(CheckDirectoryEntry(entry, 0, NULL_OK)); - PRECONDITION(CheckPointer(pSize, NULL_OK)); - NOTHROW; - GC_NOTRIGGER; - POSTCONDITION(CheckPointer((void *)RETVAL, NULL_OK)); - SO_TOLERANT; - CANNOT_TAKE_LOCK; - SUPPORTS_DAC; - } - CONTRACT_END; - - IMAGE_DATA_DIRECTORY *pDir = GetDirectoryEntry(entry); - - if (pSize != NULL) - *pSize = VAL32(pDir->Size); - - RETURN GetDirectoryData(pDir); -} - -inline TADDR PEDecoder::GetDirectoryData(IMAGE_DATA_DIRECTORY *pDir) const -{ - CONTRACT(TADDR) - { - INSTANCE_CHECK; - PRECONDITION(CheckNTHeaders()); - PRECONDITION(CheckDirectory(pDir, 0, NULL_OK)); - NOTHROW; - GC_NOTRIGGER; - SO_TOLERANT; - SUPPORTS_DAC; - POSTCONDITION(CheckPointer((void *)RETVAL, NULL_OK)); - CANNOT_TAKE_LOCK; - } - CONTRACT_END; - - RETURN GetRvaData(VAL32(pDir->VirtualAddress)); -} - -inline TADDR PEDecoder::GetDirectoryData(IMAGE_DATA_DIRECTORY *pDir, COUNT_T *pSize) const -{ - CONTRACT(TADDR) - { - INSTANCE_CHECK; - PRECONDITION(CheckNTHeaders()); - PRECONDITION(CheckDirectory(pDir, 0, NULL_OK)); - PRECONDITION(CheckPointer(pSize)); - NOTHROW; - GC_NOTRIGGER; - SO_TOLERANT; - SUPPORTS_DAC; - POSTCONDITION(CheckPointer((void *)RETVAL, NULL_OK)); - CANNOT_TAKE_LOCK; - } - CONTRACT_END; - - *pSize = VAL32(pDir->Size); - - RETURN GetRvaData(VAL32(pDir->VirtualAddress)); -} - -inline TADDR PEDecoder::GetInternalAddressData(SIZE_T address) const -{ - CONTRACT(TADDR) - { - INSTANCE_CHECK; - PRECONDITION(CheckNTHeaders()); - PRECONDITION(CheckInternalAddress(address, NULL_OK)); - NOTHROW; - GC_NOTRIGGER; - POSTCONDITION(CheckPointer((void *)RETVAL)); - SO_TOLERANT; - } - CONTRACT_END; - - RETURN GetRvaData(InternalAddressToRva(address)); -} - -inline BOOL PEDecoder::HasCorHeader() const -{ - CONTRACTL - { - INSTANCE_CHECK; - PRECONDITION(CheckNTHeaders()); - NOTHROW; - SUPPORTS_DAC; - GC_NOTRIGGER; - SO_TOLERANT; - } - CONTRACTL_END; - - return HasDirectoryEntry(IMAGE_DIRECTORY_ENTRY_COMHEADER); -} - -inline BOOL PEDecoder::IsILOnly() const -{ - CONTRACTL - { - INSTANCE_CHECK; - PRECONDITION(HasCorHeader()); - NOTHROW; - GC_NOTRIGGER; - SO_TOLERANT; - SUPPORTS_DAC; - } - CONTRACTL_END; - - // Pretend that ready-to-run images are IL-only - return((GetCorHeader()->Flags & VAL32(COMIMAGE_FLAGS_ILONLY)) != 0) || HasReadyToRunHeader(); -} - -inline COUNT_T PEDecoder::RvaToOffset(RVA rva) const -{ - CONTRACTL - { - INSTANCE_CHECK; - PRECONDITION(CheckNTHeaders()); - PRECONDITION(CheckRva(rva,NULL_OK)); - NOTHROW; - CANNOT_TAKE_LOCK; - GC_NOTRIGGER; - SUPPORTS_DAC; - } - CONTRACTL_END; - if(rva > 0) - { - IMAGE_SECTION_HEADER *section = RvaToSection(rva); - if (section == NULL) - return rva; - - return rva - VAL32(section->VirtualAddress) + VAL32(section->PointerToRawData); - } - else return 0; -} - -inline RVA PEDecoder::OffsetToRva(COUNT_T fileOffset) const -{ - CONTRACTL - { - INSTANCE_CHECK; - PRECONDITION(CheckNTHeaders()); - PRECONDITION(CheckOffset(fileOffset,NULL_OK)); - NOTHROW; - GC_NOTRIGGER; - SUPPORTS_DAC; - } - CONTRACTL_END; - if(fileOffset > 0) - { - IMAGE_SECTION_HEADER *section = OffsetToSection(fileOffset); - PREFIX_ASSUME (section!=NULL); //TODO: actually it is possible that it si null we need to rethink how we handle this cases and do better there - - return fileOffset - VAL32(section->PointerToRawData) + VAL32(section->VirtualAddress); - } - else return 0; -} - - -inline BOOL PEDecoder::IsStrongNameSigned() const -{ - CONTRACTL - { - INSTANCE_CHECK; - PRECONDITION(HasCorHeader()); - NOTHROW; - GC_NOTRIGGER; - SUPPORTS_DAC; - SO_TOLERANT; - } - CONTRACTL_END; - - return ((GetCorHeader()->Flags & VAL32(COMIMAGE_FLAGS_STRONGNAMESIGNED)) != 0); -} - - -inline BOOL PEDecoder::HasStrongNameSignature() const -{ - CONTRACTL - { - INSTANCE_CHECK; - PRECONDITION(HasCorHeader()); - NOTHROW; - GC_NOTRIGGER; - SUPPORTS_DAC; - SO_TOLERANT; - } - CONTRACTL_END; - - return (GetCorHeader()->StrongNameSignature.VirtualAddress != 0); -} - -inline CHECK PEDecoder::CheckStrongNameSignature() const -{ - CONTRACT_CHECK - { - INSTANCE_CHECK; - PRECONDITION(CheckNTHeaders()); - PRECONDITION(HasCorHeader()); - PRECONDITION(HasStrongNameSignature()); - NOTHROW; - GC_NOTRIGGER; - } - CONTRACT_CHECK_END; - - return CheckDirectory(&GetCorHeader()->StrongNameSignature, IMAGE_SCN_MEM_WRITE, NULL_OK); -} - -inline PTR_CVOID PEDecoder::GetStrongNameSignature(COUNT_T *pSize) const -{ - CONTRACT(PTR_CVOID) - { - INSTANCE_CHECK; - PRECONDITION(HasCorHeader()); - PRECONDITION(HasStrongNameSignature()); - PRECONDITION(CheckStrongNameSignature()); - PRECONDITION(CheckPointer(pSize, NULL_OK)); - NOTHROW; - GC_NOTRIGGER; - POSTCONDITION(CheckPointer(RETVAL)); - } - CONTRACT_END; - - IMAGE_DATA_DIRECTORY *pDir = &GetCorHeader()->StrongNameSignature; - - if (pSize != NULL) - *pSize = VAL32(pDir->Size); - - RETURN dac_cast(GetDirectoryData(pDir)); -} - -inline BOOL PEDecoder::HasTls() const -{ - CONTRACTL - { - INSTANCE_CHECK; - PRECONDITION(CheckNTHeaders()); - NOTHROW; - GC_NOTRIGGER; - SO_TOLERANT; - } - CONTRACTL_END; - - return HasDirectoryEntry(IMAGE_DIRECTORY_ENTRY_TLS); -} - -inline CHECK PEDecoder::CheckTls() const -{ - CONTRACT_CHECK - { - INSTANCE_CHECK; - PRECONDITION(CheckNTHeaders()); - NOTHROW; - GC_NOTRIGGER; - SO_TOLERANT; - } - CONTRACT_CHECK_END; - - CHECK(CheckDirectoryEntry(IMAGE_DIRECTORY_ENTRY_TLS, 0, NULL_OK)); - - IMAGE_TLS_DIRECTORY *pTlsHeader = (IMAGE_TLS_DIRECTORY *) GetDirectoryEntryData(IMAGE_DIRECTORY_ENTRY_TLS); - - CHECK(CheckUnderflow(VALPTR(pTlsHeader->EndAddressOfRawData), VALPTR(pTlsHeader->StartAddressOfRawData))); - CHECK(VALPTR(pTlsHeader->EndAddressOfRawData) - VALPTR(pTlsHeader->StartAddressOfRawData) <= COUNT_T_MAX); - - CHECK(CheckInternalAddress(VALPTR(pTlsHeader->StartAddressOfRawData), - (COUNT_T) (VALPTR(pTlsHeader->EndAddressOfRawData) - VALPTR(pTlsHeader->StartAddressOfRawData)))); - - CHECK_OK; -} - -inline PTR_VOID PEDecoder::GetTlsRange(COUNT_T * pSize) const -{ - CONTRACT(void *) - { - INSTANCE_CHECK; - PRECONDITION(CheckNTHeaders()); - PRECONDITION(HasTls()); - PRECONDITION(CheckTls()); - NOTHROW; - GC_NOTRIGGER; - POSTCONDITION(CheckPointer(RETVAL)); - } - CONTRACT_END; - - IMAGE_TLS_DIRECTORY *pTlsHeader = - PTR_IMAGE_TLS_DIRECTORY(GetDirectoryEntryData(IMAGE_DIRECTORY_ENTRY_TLS)); - - if (pSize != 0) - *pSize = (COUNT_T) (VALPTR(pTlsHeader->EndAddressOfRawData) - VALPTR(pTlsHeader->StartAddressOfRawData)); - PREFIX_ASSUME (pTlsHeader!=NULL); - RETURN PTR_VOID(GetInternalAddressData(pTlsHeader->StartAddressOfRawData)); -} - -inline UINT32 PEDecoder::GetTlsIndex() const -{ - CONTRACTL - { - INSTANCE_CHECK; - PRECONDITION(CheckNTHeaders()); - PRECONDITION(HasTls()); - PRECONDITION(CheckTls()); - NOTHROW; - GC_NOTRIGGER; - } - CONTRACTL_END; - - IMAGE_TLS_DIRECTORY *pTlsHeader = (IMAGE_TLS_DIRECTORY *) GetDirectoryEntryData(IMAGE_DIRECTORY_ENTRY_TLS); - - return (UINT32)*PTR_UINT32(GetInternalAddressData((SIZE_T)VALPTR(pTlsHeader->AddressOfIndex))); -} - -inline IMAGE_COR20_HEADER *PEDecoder::GetCorHeader() const -{ - CONTRACT(IMAGE_COR20_HEADER *) - { - INSTANCE_CHECK; - PRECONDITION(CheckNTHeaders()); - PRECONDITION(HasCorHeader()); - NOTHROW; - GC_NOTRIGGER; - SO_TOLERANT; - POSTCONDITION(CheckPointer(RETVAL)); - CANNOT_TAKE_LOCK; - SUPPORTS_DAC; - } - CONTRACT_END; - - if (m_pCorHeader == NULL) - const_cast(this)->m_pCorHeader = - dac_cast(FindCorHeader()); - - RETURN m_pCorHeader; -} - -inline BOOL PEDecoder::IsNativeMachineFormat() const -{ - if (!HasContents() || !HasNTHeaders() ) - return FALSE; - _ASSERTE(m_pNTHeaders); - WORD expectedFormat = HasCorHeader() && (HasNativeHeader() || HasReadyToRunHeader()) ? - IMAGE_FILE_MACHINE_NATIVE_NI : - IMAGE_FILE_MACHINE_NATIVE; - //do not call GetNTHeaders as we do not want to bother with PE32->PE32+ conversion - return m_pNTHeaders->FileHeader.Machine==expectedFormat; -} - -inline BOOL PEDecoder::IsI386() const -{ - if (!HasContents() || !HasNTHeaders() ) - return FALSE; - _ASSERTE(m_pNTHeaders); - //do not call GetNTHeaders as we do not want to bother with PE32->PE32+ conversion - return m_pNTHeaders->FileHeader.Machine==IMAGE_FILE_MACHINE_I386; -} - -inline CORCOMPILE_HEADER *PEDecoder::GetNativeHeader() const -{ - CONTRACT(CORCOMPILE_HEADER *) - { - INSTANCE_CHECK; - PRECONDITION(CheckNTHeaders()); - PRECONDITION(HasCorHeader()); - PRECONDITION(HasNativeHeader()); - NOTHROW; - GC_NOTRIGGER; - POSTCONDITION(CheckPointer(RETVAL)); - SO_TOLERANT; - SUPPORTS_DAC; - CANNOT_TAKE_LOCK; - SO_TOLERANT; - } - CONTRACT_END; - - if (m_pNativeHeader == NULL) - const_cast(this)->m_pNativeHeader = - dac_cast(FindNativeHeader()); - - RETURN m_pNativeHeader; -} - -#ifdef FEATURE_PREJIT -inline const void * PEDecoder::GetNativePreferredBase() const -{ - CONTRACTL - { - INSTANCE_CHECK; - PRECONDITION(CheckNativeHeader()); - NOTHROW; - GC_NOTRIGGER; - } - CONTRACTL_END; - - PREFIX_ASSUME (GetNativeHeader()!=NULL); - return (const void *) GetNativeHeader()->ImageBase; -} - -inline BOOL PEDecoder::GetNativeILHasSecurityDirectory() const -{ - CONTRACTL - { - INSTANCE_CHECK; - PRECONDITION(CheckNativeHeader()); - NOTHROW; - GC_NOTRIGGER; - } - CONTRACTL_END; - - PREFIX_ASSUME (GetNativeHeader()!=NULL); - return (GetNativeHeader()->Flags & CORCOMPILE_HEADER_HAS_SECURITY_DIRECTORY) != 0; -} - -inline BOOL PEDecoder::GetNativeILIsIbcOptimized() const -{ - CONTRACTL - { - INSTANCE_CHECK; - PRECONDITION(CheckNativeHeader()); - NOTHROW; - GC_NOTRIGGER; - } - CONTRACTL_END; - - PREFIX_ASSUME (GetNativeHeader()!=NULL); - return (GetNativeHeader()->Flags & CORCOMPILE_HEADER_IS_IBC_OPTIMIZED) != 0; -} - -inline BOOL PEDecoder::GetNativeILHasReadyToRunHeader() const -{ - CONTRACTL - { - INSTANCE_CHECK; - PRECONDITION(CheckNativeHeader()); - NOTHROW; - GC_NOTRIGGER; - } - CONTRACTL_END; - - PREFIX_ASSUME (GetNativeHeader()!=NULL); - return (GetNativeHeader()->Flags & CORCOMPILE_HEADER_IS_READY_TO_RUN) != 0; -} - -inline BOOL PEDecoder::IsNativeILILOnly() const -{ - CONTRACTL - { - INSTANCE_CHECK; - PRECONDITION(CheckNativeHeader()); - NOTHROW; - GC_NOTRIGGER; - SO_TOLERANT; - CANNOT_TAKE_LOCK; - SUPPORTS_DAC; - } - CONTRACTL_END; - - PREFIX_ASSUME (GetNativeHeader()!=NULL); - return((GetNativeHeader()->COR20Flags & VAL32(COMIMAGE_FLAGS_ILONLY)) != 0); -} - -inline BOOL PEDecoder::IsNativeILDll() const -{ - CONTRACTL - { - INSTANCE_CHECK; - PRECONDITION(CheckNativeHeader()); - NOTHROW; - GC_NOTRIGGER; - } - CONTRACTL_END; - - PREFIX_ASSUME (GetNativeHeader()!=NULL); - return((GetNativeHeader()->Characteristics & VAL16(IMAGE_FILE_DLL)) != 0); -} - - -inline void PEDecoder::GetNativeILPEKindAndMachine(DWORD* pdwKind, DWORD* pdwMachine) const -{ - CONTRACTL - { - INSTANCE_CHECK; - PRECONDITION(CheckNativeHeader()); - NOTHROW; - GC_NOTRIGGER; - } - CONTRACTL_END; - - CORCOMPILE_HEADER * pNativeHeader = GetNativeHeader(); - PREFIX_ASSUME (pNativeHeader!=NULL); - - if (pdwKind != NULL) - *pdwKind = pNativeHeader->PEKind; - if (pdwMachine != NULL) - *pdwMachine = pNativeHeader->Machine; -} - -inline CORCOMPILE_DEPENDENCY * PEDecoder::GetNativeDependencies(COUNT_T *pCount) const -{ - CONTRACTL - { - INSTANCE_CHECK; - PRECONDITION(CheckNativeHeader()); - NOTHROW; - GC_NOTRIGGER; - } - CONTRACTL_END; - - IMAGE_DATA_DIRECTORY *pDir = &GetNativeHeader()->Dependencies; - - if (pCount != NULL) - *pCount = VAL32(pDir->Size)/sizeof(CORCOMPILE_DEPENDENCY); - - return (CORCOMPILE_DEPENDENCY *) GetDirectoryData(pDir); -} - -#endif // FEATURE_PREJIT - -// static -inline PTR_IMAGE_SECTION_HEADER PEDecoder::FindFirstSection(IMAGE_NT_HEADERS * pNTHeaders) -{ - LIMITED_METHOD_CONTRACT; - SUPPORTS_DAC; - - return dac_cast( - dac_cast(pNTHeaders) + - FIELD_OFFSET(IMAGE_NT_HEADERS, OptionalHeader) + - VAL16(pNTHeaders->FileHeader.SizeOfOptionalHeader)); -} - -inline COUNT_T PEDecoder::GetNumberOfSections() const -{ - CONTRACTL - { - INSTANCE_CHECK; - PRECONDITION(CheckNTHeaders()); - NOTHROW; - GC_NOTRIGGER; - SUPPORTS_DAC; - } - CONTRACTL_END; - - return VAL16(FindNTHeaders()->FileHeader.NumberOfSections); -} - - -inline DWORD PEDecoder::GetImageIdentity() const -{ - WRAPPER_NO_CONTRACT; - return GetTimeDateStamp() ^ GetCheckSum() ^ DWORD( GetVirtualSize() ); -} - - -inline PTR_IMAGE_SECTION_HEADER PEDecoder::FindFirstSection() const -{ - CONTRACT(IMAGE_SECTION_HEADER *) - { - INSTANCE_CHECK; - PRECONDITION(CheckNTHeaders()); - NOTHROW; - GC_NOTRIGGER; - POSTCONDITION(CheckPointer(RETVAL)); - SUPPORTS_DAC; - } - CONTRACT_END; - - RETURN FindFirstSection(FindNTHeaders()); -} - -inline IMAGE_NT_HEADERS *PEDecoder::FindNTHeaders() const -{ - CONTRACT(IMAGE_NT_HEADERS *) - { - INSTANCE_CHECK; - NOTHROW; - GC_NOTRIGGER; - POSTCONDITION(CheckPointer(RETVAL)); - SO_TOLERANT; - CANNOT_TAKE_LOCK; - SUPPORTS_DAC; - } - CONTRACT_END; - - RETURN PTR_IMAGE_NT_HEADERS(m_base + VAL32(PTR_IMAGE_DOS_HEADER(m_base)->e_lfanew)); -} - -inline IMAGE_COR20_HEADER *PEDecoder::FindCorHeader() const -{ - CONTRACT(IMAGE_COR20_HEADER *) - { - INSTANCE_CHECK; - PRECONDITION(HasCorHeader()); - NOTHROW; - GC_NOTRIGGER; - POSTCONDITION(CheckPointer(RETVAL)); - CANNOT_TAKE_LOCK; - SO_TOLERANT; - SUPPORTS_DAC; - } - CONTRACT_END; - - const IMAGE_COR20_HEADER * pCor=PTR_IMAGE_COR20_HEADER(GetDirectoryEntryData(IMAGE_DIRECTORY_ENTRY_COMHEADER)); - RETURN ((IMAGE_COR20_HEADER*)pCor); -} - -inline CORCOMPILE_HEADER *PEDecoder::FindNativeHeader() const -{ - CONTRACT(CORCOMPILE_HEADER *) - { - INSTANCE_CHECK; - PRECONDITION(HasNativeHeader()); - NOTHROW; - GC_NOTRIGGER; - POSTCONDITION(CheckPointer(RETVAL)); - SO_TOLERANT; - CANNOT_TAKE_LOCK; - SUPPORTS_DAC; - } - CONTRACT_END; - - RETURN PTR_CORCOMPILE_HEADER(GetDirectoryData(&GetCorHeader()->ManagedNativeHeader)); -} - -inline CHECK PEDecoder::CheckBounds(RVA rangeBase, COUNT_T rangeSize, RVA rva) -{ - WRAPPER_NO_CONTRACT; - SUPPORTS_DAC; - CHECK(CheckOverflow(rangeBase, rangeSize)); - CHECK(rva >= rangeBase); - CHECK(rva <= rangeBase + rangeSize); - CHECK_OK; -} - -inline CHECK PEDecoder::CheckBounds(RVA rangeBase, COUNT_T rangeSize, RVA rva, COUNT_T size) -{ - WRAPPER_NO_CONTRACT; - SUPPORTS_DAC; - CHECK(CheckOverflow(rangeBase, rangeSize)); - CHECK(CheckOverflow(rva, size)); - CHECK(rva >= rangeBase); - CHECK(rva + size <= rangeBase + rangeSize); - CHECK_OK; -} - -inline CHECK PEDecoder::CheckBounds(const void *rangeBase, COUNT_T rangeSize, const void *pointer) -{ - WRAPPER_NO_CONTRACT; - SUPPORTS_DAC; - CHECK(CheckOverflow(dac_cast(rangeBase), rangeSize)); - CHECK(dac_cast(pointer) >= dac_cast(rangeBase)); - CHECK(dac_cast(pointer) <= dac_cast(rangeBase) + rangeSize); - CHECK_OK; -} - -inline CHECK PEDecoder::CheckBounds(PTR_CVOID rangeBase, COUNT_T rangeSize, PTR_CVOID pointer, COUNT_T size) -{ - WRAPPER_NO_CONTRACT; - SUPPORTS_DAC; - CHECK(CheckOverflow(rangeBase, rangeSize)); - CHECK(CheckOverflow(pointer, size)); - CHECK(dac_cast(pointer) >= dac_cast(rangeBase)); - CHECK(dac_cast(pointer) + size <= dac_cast(rangeBase) + rangeSize); - CHECK_OK; -} - -inline void PEDecoder::GetPEKindAndMachine(DWORD * pdwPEKind, DWORD *pdwMachine) -{ - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - } - CONTRACTL_END; - - DWORD dwKind=0,dwMachine=0; - if(HasContents() && HasNTHeaders()) - { - dwMachine = GetMachine(); - - BOOL fIsPE32Plus = !Has32BitNTHeaders(); - - if (fIsPE32Plus) - dwKind |= (DWORD)pe32Plus; - - if (HasCorHeader()) - { - IMAGE_COR20_HEADER * pCorHdr = GetCorHeader(); - if(pCorHdr != NULL) - { - DWORD dwCorFlags = pCorHdr->Flags; - - if (dwCorFlags & VAL32(COMIMAGE_FLAGS_ILONLY)) - { - dwKind |= (DWORD)peILonly; -#ifdef _WIN64 - // compensate for shim promotion of PE32/ILONLY headers to PE32+ on WIN64 - if (fIsPE32Plus && (GetMachine() == IMAGE_FILE_MACHINE_I386)) - dwKind &= ~((DWORD)pe32Plus); -#endif - } - - if (COR_IS_32BIT_REQUIRED(dwCorFlags)) - dwKind |= (DWORD)pe32BitRequired; - else if (COR_IS_32BIT_PREFERRED(dwCorFlags)) - dwKind |= (DWORD)pe32BitPreferred; - - // compensate for MC++ peculiarity - if(dwKind == 0) - dwKind = (DWORD)pe32BitRequired; - } - else - { - dwKind |= (DWORD)pe32Unmanaged; - } - - if (HasReadyToRunHeader()) - { - if (dwMachine == IMAGE_FILE_MACHINE_NATIVE_NI) - { - // Supply the original machine type to the assembly binder - dwMachine = IMAGE_FILE_MACHINE_NATIVE; - } - - if ((GetReadyToRunHeader()->Flags & READYTORUN_FLAG_PLATFORM_NEUTRAL_SOURCE) != 0) - { - // Supply the original PEKind/Machine to the assembly binder to make the full assembly name look like the original - dwKind = peILonly; - dwMachine = IMAGE_FILE_MACHINE_I386; - } - } - } - else - { - dwKind |= (DWORD)pe32Unmanaged; - } - } - - *pdwPEKind = dwKind; - *pdwMachine = dwMachine; -} - -inline BOOL PEDecoder::IsPlatformNeutral() -{ - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - } - CONTRACTL_END; - - DWORD dwKind, dwMachine; - GetPEKindAndMachine(&dwKind, &dwMachine); - return ((dwKind & (peILonly | pe32Plus | pe32BitRequired)) == peILonly) && (dwMachine == IMAGE_FILE_MACHINE_I386); -} - -inline BOOL PEDecoder::HasReadyToRunHeader() const -{ - CONTRACTL - { - INSTANCE_CHECK; - NOTHROW; - GC_NOTRIGGER; - CANNOT_TAKE_LOCK; - SO_TOLERANT; - SUPPORTS_DAC; - } - CONTRACTL_END; - - if (m_flags & FLAG_HAS_NO_READYTORUN_HEADER) - return FALSE; - - if (m_pReadyToRunHeader != NULL) - return TRUE; - - return FindReadyToRunHeader() != NULL; -} - -inline READYTORUN_HEADER * PEDecoder::GetReadyToRunHeader() const -{ - CONTRACT(READYTORUN_HEADER *) - { - INSTANCE_CHECK; - PRECONDITION(CheckNTHeaders()); - PRECONDITION(HasCorHeader()); - PRECONDITION(HasReadyToRunHeader()); - NOTHROW; - GC_NOTRIGGER; - POSTCONDITION(CheckPointer(RETVAL)); - SO_TOLERANT; - SUPPORTS_DAC; - CANNOT_TAKE_LOCK; - SO_TOLERANT; - } - CONTRACT_END; - - if (m_pReadyToRunHeader != NULL) - RETURN m_pReadyToRunHeader; - - RETURN FindReadyToRunHeader(); -} - -#endif // _PEDECODER_INL_ diff --git a/src/inc/peinformation.h b/src/inc/peinformation.h deleted file mode 100644 index f24d7bcdc..000000000 --- a/src/inc/peinformation.h +++ /dev/null @@ -1,75 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -// -------------------------------------------------------------------------------- -// PEInformation.h -// - -// -------------------------------------------------------------------------------- - -#ifndef PEINFORMATION_H -#define PEINFORMATION_H - -#ifndef PEKIND_ENUM_DEFINED -#define PEKIND_ENUM_DEFINED -// This must match the definition of pekind in fusion.idl -typedef enum _tagPEKIND -{ - peNone = 0x00000000, - peMSIL = 0x00000001, - peI386 = 0x00000002, - peIA64 = 0x00000003, - peAMD64 = 0x00000004, - peARM = 0x00000005, - peARM64 = 0x00000006, - peInvalid = 0xffffffff -} PEKIND; - -#endif - - -inline bool IsPE64(PEKIND x) -{ - return ( (x == peIA64) || (x == peAMD64) ); -} - -inline bool IsPE32(PEKIND x) -{ - return ( (x == peI386) || (x == peARM) ); -} - -inline bool IsPEMSIL(PEKIND x) -{ - return ( (x == peMSIL) ); -} - -#ifdef _WIN64 -inline bool IsProcess32() { return false; } -#else -inline bool IsProcess32() { return true; } -#endif - -#if defined(_TARGET_X86_) -inline PEKIND TargetNativePEKIND() { return peI386; } -#elif defined(_TARGET_AMD64_) -inline PEKIND TargetNativePEKIND() { return peAMD64; } -#elif defined(_TARGET_ARM_) -inline PEKIND TargetNativePEKIND() { return peARM; } -#elif defined(_TARGET_ARM64_) -inline PEKIND TargetNativePEKIND() { return peARM64; } -#else -#error Need to define valid TargetNativePEKIND() -#endif - -STDAPI RuntimeIsValidAssemblyOnThisPlatform_CheckProcessorArchitecture(PEKIND processorArchitecture, BOOL bForInstall); - -//***************************************************************************** -// Intreprets CLRPeKind and dwImageType to get PeKind as per the CLRBitness -// API, CLRPeKind and dwImageType can be recoved from GetPEKind() if you -// have the metadata, or retrieved directly from the headers as per the -// implementation in shim.cpp:_CorValidateImage. -//***************************************************************************** -HRESULT TranslatePEToArchitectureType(CorPEKind CLRPeKind, DWORD dwImageType, PEKIND * PeKind); -HRESULT TranslatePEToArchitectureType(CorPEKind CLRPeKind, DWORD dwImageType, DWORD dwAssemblyFlags, PEKIND * PeKind); - -#endif // PEINFORMATION_H diff --git a/src/inc/perfcounterdefs.h b/src/inc/perfcounterdefs.h deleted file mode 100644 index 83fe7b1d5..000000000 --- a/src/inc/perfcounterdefs.h +++ /dev/null @@ -1,495 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -//----------------------------------------------------------------------------- -// PerfCounterDefs.h -// -// Internal Interface for CLR to use Performance counters -//----------------------------------------------------------------------------- - - -#ifndef _PerfCounterDefs_h_ -#define _PerfCounterDefs_h_ - -#include "contract.h" - -//----------------------------------------------------------------------------- -// PerfCounters are only enabled if ENABLE_PERF_COUNTERS is defined. -// If we know we want them (such as in the impl or perfmon, then define this -// in before we include this header, else define this from the sources file. -// -// Note that some platforms don't use perfcounters, so to avoid a build -// break, you must wrap PerfCounter code (such as instrumenting in either -// #ifdef or use the COUNTER_ONLY(x) macro (defined below) -// - -//----------------------------------------------------------------------------- -// Name of global IPC block -#define SHARED_PERF_IPC_NAME W("SharedPerfIPCBlock") - - -//----------------------------------------------------------------------------- -// Attributes for the IPC block -//----------------------------------------------------------------------------- -const int PERF_ATTR_ON = 0x0001; // Are we even updating any counters? -const int PERF_ATTR_GLOBAL = 0x0002; // Is this a global or private block? - - - - - -//............................................................................. -// Tri Counter. Support for the common trio of counters (Total, Current, and -// Instantaneous). This compiles to the same thing if we had them all separate, -// but it's a lot cleaner this way. -//............................................................................. -struct TRICOUNT -{ - DWORD Cur; // Current, has +, - - DWORD Total; // Total, has only + - inline void operator++(int) { - LIMITED_METHOD_CONTRACT; - Cur ++; Total ++; - } - inline void operator--(int) { - LIMITED_METHOD_CONTRACT; - Cur --; - } - inline void operator+=(int delta) { - LIMITED_METHOD_CONTRACT; - Cur += delta; Total += delta; - } - inline void operator-=(int delta) { - LIMITED_METHOD_CONTRACT; - Cur -= delta; - } - inline void operator=(int delta) { - LIMITED_METHOD_CONTRACT; - Cur = delta; - Total = delta; - } - inline void operator+=(TRICOUNT delta) { - LIMITED_METHOD_CONTRACT; - Cur += delta.Cur; Total += delta.Total; - } - -}; - -//............................................................................. -// Interlocked Tri Counter. Support for the common trio of counters (Total, Current, -// and Instantaneous). This compiles to the same thing if we had them all separate, -// but it's a lot cleaner this way. -//............................................................................. -struct TRICOUNT_IL -{ - DWORD Cur; // Current, has +, - - DWORD Total; // Total, has only + - inline void operator++(int) { - LIMITED_METHOD_CONTRACT; - InterlockedIncrement((LPLONG)&Cur); InterlockedIncrement((LPLONG)&Total); - } - inline void operator--(int) { - LIMITED_METHOD_CONTRACT; - InterlockedDecrement((LPLONG)&Cur); - } - inline void operator+=(int delta) { - LIMITED_METHOD_CONTRACT; - while (TRUE) - { - LONG old_Cur = Cur; - if (InterlockedCompareExchange((LPLONG)&Cur, Cur+delta, old_Cur) == old_Cur) - break; - } - while (TRUE) - { - LONG old_Total = Total; - if (InterlockedCompareExchange((LPLONG)&Total, Total+delta, old_Total) == old_Total) - break; - } - } - inline void operator-=(int delta) { - LIMITED_METHOD_CONTRACT; - while (TRUE) - { - LONG old_Cur = Cur; - if (InterlockedCompareExchange((LPLONG)&Cur, Cur-delta, old_Cur) == old_Cur) - break; - } - } - inline void operator=(int delta) { - LIMITED_METHOD_CONTRACT; - while (TRUE) - { - LONG old_Cur = Cur; - if (InterlockedCompareExchange((LPLONG)&Cur, delta, old_Cur) == old_Cur) - break; - } - - while (TRUE) - { - LONG old_Total = Total; - if (InterlockedCompareExchange((LPLONG)&Total, delta, old_Total) == old_Total) - break; - } - } - inline void operator+=(TRICOUNT_IL delta) { - LIMITED_METHOD_CONTRACT; - while (TRUE) - { - LONG old_Cur = Cur; - if (InterlockedCompareExchange((LPLONG)&Cur, Cur+delta.Cur, old_Cur) == old_Cur) - break; - } - while (TRUE) - { - LONG old_Total = Total; - if (InterlockedCompareExchange((LPLONG)&Total, Total+delta.Total, old_Total) == old_Total) - break; - } - } - -}; - - -//............................................................................. -// Dual Counter. Support for the (Total and Instantaneous (rate)). Helpful in cases -// where the current value is always same as the total value. ie. the counter is never -// decremented. -// This compiles to the same thing if we had them separate, but it's a lot cleaner -// this way. -//............................................................................. -struct DUALCOUNT -{ - DWORD Total; - inline void operator++(int) { - LIMITED_METHOD_CONTRACT; - Total ++; - } - - inline void operator+=(int delta) { - LIMITED_METHOD_CONTRACT; - Total += delta; - } - - inline void operator+=(DUALCOUNT delta) { - LIMITED_METHOD_CONTRACT; - Total += delta.Total; - } - - -}; - -//----------------------------------------------------------------------------- -// Format for the Perf Counter IPC Block -// IPC block is broken up into sections. This marks it easier to marshall -// into different perfmon objects -// -//............................................................................. -// Naming convention (by prefix): -// c - Raw count of something. -// cb- count of bytes -// time - time value. -// depth - stack depth -//----------------------------------------------------------------------------- - -const int MAX_TRACKED_GENS = 3; // number of generations we track - -// -// Perf_GC_Wow64 mimics in a 64 bit process, the layout of Perf_GC in a 32 bit process -// It does this by replacing all size_t by DWORD -// -// *** Keep contents of Perf_GC_Wow64 and Perf_GC in sync *** - -struct Perf_GC_Wow64 -{ -public: - DWORD cGenCollections[MAX_TRACKED_GENS];// count of collects per gen - DWORD cbPromotedMem[MAX_TRACKED_GENS-1]; // count of promoted memory - DWORD cbPromotedFinalizationMem; // count of memory promoted due to finalization - DWORD cProcessID; // process ID - DWORD cGenHeapSize[MAX_TRACKED_GENS]; // size of heaps per gen - DWORD cTotalCommittedBytes; // total number of committed bytes. - DWORD cTotalReservedBytes; // bytes reserved via VirtualAlloc - DWORD cLrgObjSize; // size of Large Object Heap - DWORD cSurviveFinalize; // count of instances surviving from finalizing - DWORD cHandles; // count of GC handles - DWORD cbAlloc; // bytes allocated - DWORD cbLargeAlloc; // bytes allocated for Large Objects - DWORD cInducedGCs; // number of explicit GCs - DWORD timeInGC; // Time in GC - DWORD timeInGCBase; // must follow time in GC counter - - DWORD cPinnedObj; // # of Pinned Objects - DWORD cSinkBlocks; // # of sink blocks -}; - -// *** Keep contents of Perf_GC_Wow64 and Perf_GC in sync *** -#ifndef _WIN64 -#include -#endif //#ifndef _WIN64 -struct Perf_GC -{ -public: - size_t cGenCollections[MAX_TRACKED_GENS];// count of collects per gen - size_t cbPromotedMem[MAX_TRACKED_GENS-1]; // count of promoted memory - size_t cbPromotedFinalizationMem; // count of memory promoted due to finalization - size_t cProcessID; // process ID - size_t cGenHeapSize[MAX_TRACKED_GENS]; // size of heaps per gen - size_t cTotalCommittedBytes; // total number of committed bytes. - size_t cTotalReservedBytes; // bytes reserved via VirtualAlloc - size_t cLrgObjSize; // size of Large Object Heap - size_t cSurviveFinalize; // count of instances surviving from finalizing - size_t cHandles; // count of GC handles - size_t cbAlloc; // bytes allocated - size_t cbLargeAlloc; // bytes allocated for Large Objects - size_t cInducedGCs; // number of explicit GCs - DWORD timeInGC; // Time in GC - DWORD timeInGCBase; // must follow time in GC counter - - size_t cPinnedObj; // # of Pinned Objects - size_t cSinkBlocks; // # of sink blocks - - Perf_GC(); - Perf_GC(Perf_GC_Wow64& copyFrom); -}; -#ifndef _WIN64 -#include -#endif //#ifndef _WIN64 - -// -// Perf_Loading_Wow64 mimics in a 64 bit process, the layout of Perf_Loading -// in a 32 bit process. It does this by replacing all size_t by DWORD -// -// *** Keep contents of Perf_Loading_Wow64 and Perf_Loading in sync *** -struct Perf_Loading_Wow64 -{ -// Loading -public: - TRICOUNT cClassesLoaded; - TRICOUNT_IL cAppDomains; // Current # of AppDomains - TRICOUNT cAssemblies; // Current # of Assemblies. - UNALIGNED LONGLONG timeLoading; // % time loading - DWORD cAsmSearchLen; // Avg search length for assemblies - DUALCOUNT cLoadFailures; // Classes Failed to load - DWORD cbLoaderHeapSize; // Total size of heap used by the loader - DUALCOUNT cAppDomainsUnloaded; // Rate at which app domains are unloaded -}; - -// *** Keep contents of Perf_Loading_Wow64 and Perf_Loading in sync *** -#ifndef _WIN64 -#include -#endif //#ifndef _WIN64 -struct Perf_Loading -{ -// Loading -public: - TRICOUNT cClassesLoaded; - TRICOUNT_IL cAppDomains; // Current # of AppDomains - TRICOUNT cAssemblies; // Current # of Assemblies. - UNALIGNED LONGLONG timeLoading; // % time loading - DWORD cAsmSearchLen; // Avg search length for assemblies - DUALCOUNT cLoadFailures; // Classes Failed to load - size_t cbLoaderHeapSize; // Total size of heap used by the loader - DUALCOUNT cAppDomainsUnloaded; // Rate at which app domains are unloaded - - Perf_Loading(); - Perf_Loading(Perf_Loading_Wow64& copyFrom); -}; -#ifndef _WIN64 -#include -#endif //#ifndef _WIN64 - -#ifndef _WIN64 -#include -#endif //#ifndef _WIN64 -struct Perf_Jit -{ -// Jitting - DWORD cMethodsJitted; // number of methods jitted - TRICOUNT cbILJitted; // IL jitted stats -// DUALCOUNT cbPitched; // Total bytes pitched - DWORD cJitFailures; // # of standard Jit failures - DWORD timeInJit; // Time in JIT since last sample - DWORD timeInJitBase; // Time in JIT base counter -}; -#ifndef _WIN64 -#include -#endif //#ifndef _WIN64 - -#ifndef _WIN64 -#include -#endif //#ifndef _WIN64 -struct Perf_Excep -{ -// Exceptions - DUALCOUNT cThrown; // Number of Exceptions thrown - DWORD cFiltersExecuted; // Number of Filters executed - DWORD cFinallysExecuted; // Number of Finallys executed - DWORD cThrowToCatchStackDepth; // Delta from throw to catch site on stack -}; -#ifndef _WIN64 -#include -#endif //#ifndef _WIN64 - -#ifndef _WIN64 -#include -#endif //#ifndef _WIN64 -struct Perf_Interop -{ -// Interop - DWORD cCCW; // Number of CCWs - DWORD cStubs; // Number of stubs - DWORD cMarshalling; // # of time marshalling args and return values. - DWORD cTLBImports; // Number of tlbs we import - DWORD cTLBExports; // Number of tlbs we export -}; -#ifndef _WIN64 -#include -#endif //#ifndef _WIN64 - -#ifndef _WIN64 -#include -#endif //#ifndef _WIN64 -struct Perf_LocksAndThreads -{ -// Locks - DUALCOUNT cContention; // # of times in AwareLock::EnterEpilogue() - TRICOUNT cQueueLength; // Lenght of queue -// Threads - DWORD cCurrentThreadsLogical; // Number (created - destroyed) of logical threads - DWORD cCurrentThreadsPhysical; // Number (created - destroyed) of OS threads - TRICOUNT cRecognizedThreads; // # of Threads execute in runtime's control -}; -#ifndef _WIN64 -#include -#endif //#ifndef _WIN64 - - -// IMPORTANT!!!!!!!: The first two fields in the struct have to be together -// and be the first two fields in the struct. The managed code in ChannelServices.cs -// depends on this. -#ifndef _WIN64 -#include -#endif //#ifndef _WIN64 -struct Perf_Contexts -{ -// Contexts & Remoting - DUALCOUNT cRemoteCalls; // # of remote calls - DWORD cChannels; // Number of current channels - DWORD cProxies; // Number of context proxies. - DWORD cClasses; // # of Context-bound classes - DWORD cObjAlloc; // # of context bound objects allocated - DWORD cContexts; // The current number of contexts. -}; -#ifndef _WIN64 -#include -#endif //#ifndef _WIN64 - -// -// Perf_Security_Wow64 mimics in a 64 bit process, the layout of Perf_Security -// in a 32 bit process. It does this by packing all members on 4 byte boundary -// ("timeAuthorize" field which is 8 bytes in size, will get 8 byte aligned -// on 64 bit by default) -// -// *** Keep contents of Perf_Security_Wow64 and Perf_Security in sync *** -#include -struct Perf_Security_Wow64 -{ -// Security -public: - DWORD cTotalRTChecks; // Total runtime checks - UNALIGNED LONGLONG timeAuthorize; // % time authenticating - DWORD cLinkChecks; // link time checks - DWORD timeRTchecks; // % time in Runtime checks - DWORD timeRTchecksBase; // % time in Runtime checks base counter - DWORD stackWalkDepth; // depth of stack for security checks -}; -#include - -#ifndef _WIN64 -#include -#endif //#ifndef _WIN64 -struct Perf_Security -{ -// Security -public: - DWORD cTotalRTChecks; // Total runtime checks - UNALIGNED LONGLONG timeAuthorize; // % time authenticating - DWORD cLinkChecks; // link time checks - DWORD timeRTchecks; // % time in Runtime checks - DWORD timeRTchecksBase; // % time in Runtime checks base counter - DWORD stackWalkDepth; // depth of stack for security checks - - Perf_Security(); - Perf_Security(Perf_Security_Wow64& copyFrom); -}; -#ifndef _WIN64 -#include -#endif //#ifndef _WIN64 - - -// -// PerfCounterWow64IPCControlBlock mimics in a 64 bit process, the layout of -// PerfCounterIPCControlBlock in a 32 bit process. -// -// *** Keep contents of PerfCounterWow64IPCControlBlock and PerfCounterIPCControlBlock in sync *** -#include -struct PerfCounterWow64IPCControlBlock -{ -public: -// Versioning info - WORD m_cBytes; // size of this entire block - WORD m_wAttrs; // attributes for this block - -// Counter Sections - Perf_GC_Wow64 m_GC; - Perf_Contexts m_Context; - Perf_Interop m_Interop; - Perf_Loading_Wow64 m_Loading; - Perf_Excep m_Excep; - Perf_LocksAndThreads m_LocksAndThreads; - Perf_Jit m_Jit; - Perf_Security_Wow64 m_Security; -}; -#include - -// Note: PerfMonDll marshalls data out of here by copying a continous block of memory. -// We can still add new members to the subsections above, but if we change their -// placement in the structure below, we may break PerfMon's marshalling - -// *** Keep contents of PerfCounterWow64IPCControlBlock and PerfCounterIPCControlBlock in sync *** -#ifndef _WIN64 -#include -#endif //#ifndef _WIN64 -struct PerfCounterIPCControlBlock -{ -public: -// Versioning info - WORD m_cBytes; // size of this entire block - WORD m_wAttrs; // attributes for this block - -// Counter Sections - Perf_GC m_GC; - Perf_Contexts m_Context; - Perf_Interop m_Interop; - Perf_Loading m_Loading; - Perf_Excep m_Excep; - Perf_LocksAndThreads m_LocksAndThreads; - Perf_Jit m_Jit; - Perf_Security m_Security; - - PerfCounterIPCControlBlock(); - PerfCounterIPCControlBlock(PerfCounterWow64IPCControlBlock& copyFrom); -}; - -#ifndef _WIN64 -#include -#endif //#ifndef _WIN64 - -// -// Inline definitions -// - -#include "perfcounterdefs.inl" - -#endif // _PerfCounterDefs_h_ diff --git a/src/inc/perfcounterdefs.inl b/src/inc/perfcounterdefs.inl deleted file mode 100644 index ab8f73d6d..000000000 --- a/src/inc/perfcounterdefs.inl +++ /dev/null @@ -1,89 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -//----------------------------------------------------------------------------- -// PerfCounterDefs.inl -// -// Internal Interface for CLR to use Performance counters -//----------------------------------------------------------------------------- - -#ifndef _PerfCounterDefs_inl_ -#define _PerfCounterDefs_inl_ - -#include "perfcounterdefs.h" - -inline Perf_GC::Perf_GC() {} - -inline Perf_GC::Perf_GC(Perf_GC_Wow64& copyFrom) -{ - for (int index = 0; index < MAX_TRACKED_GENS; index++) - { - cGenCollections[index] = (size_t)copyFrom.cGenCollections[index]; - cGenHeapSize[index] = (size_t)copyFrom.cGenHeapSize[index]; - } - for (int index = 0; index < MAX_TRACKED_GENS - 1; index++) - { - cbPromotedMem[index] = (size_t)copyFrom.cbPromotedMem[index]; - } - - cbPromotedFinalizationMem = (size_t) copyFrom.cbPromotedFinalizationMem; - cProcessID = (size_t) copyFrom.cProcessID; - cTotalCommittedBytes = (size_t) copyFrom.cTotalCommittedBytes; - cTotalReservedBytes = (size_t) copyFrom.cTotalReservedBytes; - cLrgObjSize = (size_t) copyFrom.cLrgObjSize; - cSurviveFinalize = (size_t) copyFrom.cSurviveFinalize; - cHandles = (size_t) copyFrom.cHandles; - cbAlloc = (size_t) copyFrom.cbAlloc; - cbLargeAlloc = (size_t) copyFrom.cbLargeAlloc; - cInducedGCs = (size_t) copyFrom.cInducedGCs; - timeInGC = copyFrom.timeInGC; - timeInGCBase = copyFrom.timeInGCBase; - cPinnedObj = (size_t) copyFrom.cPinnedObj; - cSinkBlocks = (size_t) copyFrom.cSinkBlocks; -} - -inline Perf_Loading::Perf_Loading() {} - -inline Perf_Loading::Perf_Loading(Perf_Loading_Wow64& copyFrom) -: cClassesLoaded(copyFrom.cClassesLoaded), - cAppDomains(copyFrom.cAppDomains), - cAssemblies(copyFrom.cAssemblies), - timeLoading(copyFrom.timeLoading), - cAsmSearchLen(copyFrom.cAsmSearchLen), - cLoadFailures (copyFrom.cLoadFailures), - cbLoaderHeapSize ((size_t) copyFrom.cbLoaderHeapSize), - cAppDomainsUnloaded (copyFrom.cAppDomainsUnloaded) -{ -} - -inline Perf_Security::Perf_Security() {}; - -inline Perf_Security::Perf_Security(Perf_Security_Wow64& copyFrom) -: cTotalRTChecks(copyFrom.cTotalRTChecks), - timeAuthorize(0), // Unused "reserved" field - cLinkChecks(copyFrom.cLinkChecks), - timeRTchecks(copyFrom.timeRTchecks), - timeRTchecksBase(copyFrom.timeRTchecksBase), - stackWalkDepth (copyFrom.stackWalkDepth) -{ -} - -inline PerfCounterIPCControlBlock::PerfCounterIPCControlBlock() {} - -inline PerfCounterIPCControlBlock::PerfCounterIPCControlBlock(PerfCounterWow64IPCControlBlock& copyFrom) -: m_cBytes (copyFrom.m_cBytes), - m_wAttrs (copyFrom.m_wAttrs), - m_GC (copyFrom.m_GC), - m_Context (copyFrom.m_Context), - m_Interop (copyFrom.m_Interop), - m_Loading (copyFrom.m_Loading), - m_Excep (copyFrom.m_Excep), - m_LocksAndThreads (copyFrom.m_LocksAndThreads), - m_Jit (copyFrom.m_Jit), - m_Security (copyFrom.m_Security) -{ - _ASSERTE((size_t)m_cBytes == sizeof(PerfCounterWow64IPCControlBlock)); -} - -#endif // _PerfCounterDefs_inl_ - diff --git a/src/inc/perfcounters.h b/src/inc/perfcounters.h deleted file mode 100644 index 29fc767d6..000000000 --- a/src/inc/perfcounters.h +++ /dev/null @@ -1,122 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -//----------------------------------------------------------------------------- -// PerfCounters.h -// -// Internal Interface for CLR to use Performance counters -//----------------------------------------------------------------------------- - - -#ifndef _PerfCounters_h_ -#define _PerfCounters_h_ - -#include "perfcounterdefs.h" - -#ifdef ENABLE_PERF_COUNTERS -//----------------------------------------------------------------------------- -//----------------------------------------------------------------------------- -// This code section active iff we're using Perf Counters -//----------------------------------------------------------------------------- -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -// PerfCounter class serves as namespace with data protection. -// Enforce this by making constructor private -//----------------------------------------------------------------------------- -class PerfCounters -{ -private: - PerfCounters(); - -public: - static HRESULT Init(); - static void Terminate(); - - static PerfCounterIPCControlBlock * GetPrivatePerfCounterPtr(); - -private: - static HANDLE m_hPrivateMapPerf; - - static PerfCounterIPCControlBlock * m_pPrivatePerf; - - static BOOL m_fInit; - -// Set pointers to garbage so they're never null. - static PerfCounterIPCControlBlock m_garbage; - - friend PerfCounterIPCControlBlock & GetPerfCounters(); -}; - -//----------------------------------------------------------------------------- -// Utility functions -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -// Get the perf counters specific to our process -//----------------------------------------------------------------------------- -inline PerfCounterIPCControlBlock & GetPerfCounters() -{ - LIMITED_METHOD_CONTRACT; - - return *PerfCounters::m_pPrivatePerf; -} - -inline PerfCounterIPCControlBlock *PerfCounters::GetPrivatePerfCounterPtr() -{ - LIMITED_METHOD_CONTRACT; - - return m_pPrivatePerf; -}; - -#define COUNTER_ONLY(x) x - -#define PERF_COUNTER_NUM_OF_ITERATIONS 10 - -#if defined(_X86_) && defined(_MSC_VER) - -inline UINT64 GetCycleCount_UINT64() -{ - LIMITED_METHOD_CONTRACT; - return __rdtsc(); -} - -#else // defined(_X86_) && defined(_MSC_VER) -inline UINT64 GetCycleCount_UINT64() -{ - LIMITED_METHOD_CONTRACT; - - LARGE_INTEGER qwTmp; - QueryPerformanceCounter(&qwTmp); - return qwTmp.QuadPart; -} -#endif // defined(_X86_) && defined(_MSC_VER) - -#define PERF_COUNTER_TIMER_PRECISION UINT64 -#define GET_CYCLE_COUNT GetCycleCount_UINT64 - -#define PERF_COUNTER_TIMER_START() \ -PERF_COUNTER_TIMER_PRECISION _startPerfCounterTimer = GET_CYCLE_COUNT(); - -#define PERF_COUNTER_TIMER_STOP(global) \ -global = (GET_CYCLE_COUNT() - _startPerfCounterTimer); - - - - -#else // ENABLE_PERF_COUNTERS -//----------------------------------------------------------------------------- -//----------------------------------------------------------------------------- -// This code section active iff we're NOT using Perf Counters -// Note, not even a class definition, so all usages of PerfCounters in client -// should be in #ifdef or COUNTER_ONLY(). -//----------------------------------------------------------------------------- -//----------------------------------------------------------------------------- - -#define COUNTER_ONLY(x) - - -#endif // ENABLE_PERF_COUNTERS - - -#endif // _PerfCounters_h_ diff --git a/src/inc/perflog.h b/src/inc/perflog.h deleted file mode 100644 index 84578d36a..000000000 --- a/src/inc/perflog.h +++ /dev/null @@ -1,142 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -//----------------------------------------------------------------------------- -// PerfLog.h - -// Internal interface for logging perfromance data. Currently, two types of logging -// formats are supported, Pretty print for stdout and perf automation friendly -// format. -// The logging code is compiled in for retail builds but logs are generated only if -// PERF_OUTPUT environment variable is set. (This can be changed to a registry entry -// if we want perf logs on CE or other platforms that don't supprt env vars.)) -//----------------------------------------------------------------------------- - -#include "contract.h" - -#ifndef _PERFLOG_H_ -#define _PERFLOG_H_ - -#if !defined(_WIN64) && !defined(DACCESS_COMPILE) -#define ENABLE_PERF_LOG -#else -#undef ENABLE_PERF_LOG -#endif - -// Also disable Perf logging code if there's a explicite define to do so in SOURCES -// file or another hdr file. This provides one point where all perf log related baggage -// can be avoided in the build. -#if defined(DISABLE_PERF_LOG) -#undef ENABLE_PERF_LOG -#endif - - -//----------------------------------------------------------------------------- -// PERFLOG is the public interface that should be used from EE source to log perf data. -// If -#if !defined (ENABLE_PERF_LOG) -#define PERFLOG(x) -#else -#define PERFLOG(x) do {if (PerfLog::PerfLoggingEnabled()) PerfLog::Log x;} while (0) -#endif - -//============================================================================= -// ALL THE PERF LOG CODE IS COMPILED ONLY IF THE ENABLE_PERF_LOG WAS DEFINED. -#if defined (ENABLE_PERF_LOG) -//============================================================================= -//----------------------------------------------------------------------------- -// Static allocation of logging related memory, avoid dynamic allocation to -// skew perf numbers. -#define PRINT_STR_LEN 256 // Temp work space -#define MAX_CHARS_UNIT 20 -#define MAX_CHARS_DIRECTION 6 - -//----------------------------------------------------------------------------- -// ENUM of units for all kinds of perf data the we might get. Grow this as needed. -// **keep in sync *** with the array of strings defined in PerfLog.cpp -typedef enum -{ - COUNT = 0, - SECONDS, - BYTES, - KBYTES, - KBYTES_PER_SEC, - CYCLES, - MAX_UNITS_OF_MEASURE -} UnitOfMeasure; - -//----------------------------------------------------------------------------- -// Widechar strings representing the above units. *** Keep in sync *** with the -// array defined in PerfLog.cpp -extern const wchar_t * const wszUnitOfMeasureDescr[MAX_UNITS_OF_MEASURE]; - -//----------------------------------------------------------------------------- -// Widechar strings representing the "direction" property of above units. -// *** Keep in sync *** with the array defined in PerfLog.cpp -// "Direction" property is false if an increase in the value of the counter indicates -// a degrade. -// "Direction" property is true if an increase in the value of the counter indicates -// an improvement. -extern const wchar_t * const wszIDirection[MAX_UNITS_OF_MEASURE]; - -//----------------------------------------------------------------------------- -// Namespace for perf log. Don't create perf log objects (private ctor). -class PerfLog -{ -public: - - // Called during EEStartup - static void PerfLogInitialize(); - - // Called during EEShutdown - static void PerfLogDone(); - - // Perf logging is enabled if the env var PERF_LOG is set. - static int PerfLoggingEnabled () { LIMITED_METHOD_CONTRACT; return m_fLogPerfData; } - - // Perf automation format is desired. - static bool PerfAutomationFormat () { LIMITED_METHOD_CONTRACT; return m_perfAutomationFormat; } - - // CSV format is desired. - static bool CommaSeparatedFormat () { LIMITED_METHOD_CONTRACT; return m_commaSeparatedFormat; } - - // Overloaded member functions to print different data types. Grow as needed. - // wszName is the name of thet perf counter, val is the perf counter value, - static void Log(__in_z wchar_t const *wszName, UINT val, UnitOfMeasure unit, __in_opt const wchar_t *wszDescr = 0); - static void Log(__in_z wchar_t const *wszName, UINT64 val, UnitOfMeasure unit, __in_opt const wchar_t *wszDescr = 0); - static void Log(__in_z wchar_t const *wszName, double val, UnitOfMeasure unit, __in_opt const wchar_t *wszDescr = 0); - -private: - PerfLog(); - ~PerfLog(); - - // Helper routine to hide some details of the perf automation - static void OutToPerfFile(__in_z const wchar_t *wszName, UnitOfMeasure unit, __in_opt const wchar_t *wszDescr = 0); - - // Helper routine to hide some details of output to stdout - static void OutToStdout(__in_z const wchar_t *wszName, UnitOfMeasure unit, __in_opt const wchar_t *wszDescr = 0); - - // Perf log initialized ? - static bool m_perfLogInit; - - // Output in perf automation format ? - static bool m_perfAutomationFormat; - - // Output in csv format ? - static bool m_commaSeparatedFormat; - - // Temp storage to convert wide char to multibyte for file IO. - static wchar_t m_wszOutStr_1[PRINT_STR_LEN]; - static DWORD m_dwWriteByte; - - // State of the env var PERF_OUTPUT - static int m_fLogPerfData; - - // Open handle of the file which is used by the perf auotmation. (Currently - // its at C:\PerfData.data - static HANDLE m_hPerfLogFileHandle; -}; - -#endif // ENABLE_PERF_LOG - -#endif //_PERFLOG_H_ diff --git a/src/inc/pesectionman.h b/src/inc/pesectionman.h deleted file mode 100644 index f031ca34b..000000000 --- a/src/inc/pesectionman.h +++ /dev/null @@ -1,213 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -// Section Manager for portable executables -// Common to both Memory Only and Static (EXE making) code - - -#ifndef PESectionMan_H -#define PESectionMan_H - -#include "windef.h" - -#include "ceegen.h" -#include "blobfetcher.h" - -class PESection; -struct PESectionReloc; - -struct _IMAGE_SECTION_HEADER; - -class PESectionMan -{ -public: - - virtual ~PESectionMan() {} - - HRESULT Init(); - HRESULT Cleanup(); - - // Finds section with given name, or creates a new one - HRESULT getSectionCreate( - const char *name, - unsigned flags, // IMAGE_SCN_* flags. eg. IMAGE_SCN_CNT_INITIALIZED_DATA - PESection **section); - - // Since we allocate, we must delete (Bug in VC, see knowledge base Q122675) - void sectionDestroy(PESection **section); - - // Apply all the relocs for in memory conversion - HRESULT applyRelocs(CeeGenTokenMapper *pTokenMapper); - - HRESULT cloneInstance(PESectionMan *destination); - -protected: - - // Finds section with given name. returns 0 if not found - virtual PESection *getSection(const char *name); - - // Create a new section - virtual HRESULT newSection( - const char *name, - PESection **section, - unsigned flags = sdNone, - unsigned estSize = 0x10000, - unsigned estRelocs = 1); - - // Keep proctected & no accessors, so that derived class PEWriter - // is the ONLY one with access - - PESection **sectStart; - PESection **sectCur; - PESection **sectEnd; -}; // class PESectionMan - -/*************************************************************** - * This represents a section of a ICeeFileGen. Multiple sections - * can be created with pointers to one another. These will - * automatically get fixed up when the ICeeFileGen is "baked". - * - * It is implemented using CBlobFetcher as a list of blobs. - * Thus it can grow arbitrarily. At the same time, it can appear - * as a flat consecutive piece of memory which can be indexed into - * using offsets. - */ - -class PESection : public CeeSectionImpl { - public: - // bytes in this section at present - unsigned dataLen(); - - // Apply all the relocs for in memory conversion - HRESULT applyRelocs(CeeGenTokenMapper *pTokenMapper); - - // get a block to write on (use instead of write to avoid copy) - char* getBlock(unsigned len, unsigned align=1); - - // writes 'val' (which is offset into section 'relativeTo') - // and adds a relocation fixup for that section - void writeSectReloc(unsigned val, CeeSection& relativeTo, - CeeSectionRelocType reloc = srRelocHighLow, - CeeSectionRelocExtra *extra=0); - - // Indicates that the DWORD at 'offset' in the current section should - // have the base of section 'relativeTo' added to it - HRESULT addSectReloc(unsigned offset, CeeSection& relativeTo, - CeeSectionRelocType reloc = srRelocHighLow, - CeeSectionRelocExtra *extra=0); - - // If relativeTo is NULL, it is treated as a base reloc. - // ie. the value only needs to be fixed at load time if the module gets rebased. - HRESULT addSectReloc(unsigned offset, PESection *relativeTo, - CeeSectionRelocType reloc = srRelocHighLow, - CeeSectionRelocExtra *extra=0); - - // Add a base reloc for the given offset in the current section - HRESULT addBaseReloc(unsigned offset, CeeSectionRelocType reloc = srRelocHighLow, - CeeSectionRelocExtra *extra = 0); - - // section name - unsigned char *name() { - LIMITED_METHOD_CONTRACT; - return (unsigned char *) m_name; - } - - // section flags - unsigned flags() { - LIMITED_METHOD_CONTRACT; - return m_flags; - } - - // virtual base - unsigned getBaseRVA() { - LIMITED_METHOD_CONTRACT; - return m_baseRVA; - } - - // return the dir entry for this section - int getDirEntry() { - LIMITED_METHOD_CONTRACT; - return dirEntry; - } - // this section will be directory entry 'num' - HRESULT directoryEntry(unsigned num); - - // Indexes offset as if this were an array - // Returns a pointer into the correct blob - virtual char * computePointer(unsigned offset) const; - - // Checks to see if pointer is in section - virtual BOOL containsPointer(__in char *ptr) const; - - // Given a pointer pointing into this section, - // computes an offset as if this were an array - virtual unsigned computeOffset(__in char *ptr) const; - - // Make 'destination' a copy of the current PESection - HRESULT cloneInstance(PESection *destination); - - // Cause the section to allocate memory in smaller chunks - void SetInitialGrowth(unsigned growth); - - virtual ~PESection(); -private: - - // purposely not defined, - PESection(); - - // purposely not defined, - PESection(const PESection&); - - // purposely not defined, - PESection& operator=(const PESection& x); - - // this dir entry points to this section - int dirEntry; - -protected: - friend class PEWriter; - friend class PEWriterSection; - friend class PESectionMan; - - PESection(const char* name, unsigned flags, - unsigned estSize, unsigned estRelocs); - - // Blob fetcher handles getBlock() and fetching binary chunks. - CBlobFetcher m_blobFetcher; - - PESectionReloc* m_relocStart; - PESectionReloc* m_relocCur; - PESectionReloc* m_relocEnd; - - // These will be set while baking (finalizing) the file - unsigned m_baseRVA; // RVA into the file of this section. - unsigned m_filePos; // Start offset into the file (treated as a data image) - unsigned m_filePad; // Padding added to the end of the section for alignment - - char m_name[8+6]; // extra room for digits - unsigned m_flags; - - struct _IMAGE_SECTION_HEADER* m_header; // Corresponding header. Assigned after link() -}; - -/***************************************************************/ -/* implementation section */ - -inline HRESULT PESection::directoryEntry(unsigned num) { - WRAPPER_NO_CONTRACT; - TESTANDRETURN(num < 16, E_INVALIDARG); - dirEntry = num; - return S_OK; -} - -// This remembers the location where a reloc needs to be applied. -// It is relative to the contents of a PESection - -struct PESectionReloc { - CeeSectionRelocType type; // type of reloc - unsigned offset; // offset within the current PESection where the reloc is to be applied - CeeSectionRelocExtra extra; - PESection* section; // target PESection. NULL implies that the target is a fixed address outside the module -}; - -#endif // #define PESectionMan_H diff --git a/src/inc/posterror.h b/src/inc/posterror.h deleted file mode 100644 index 816d14e09..000000000 --- a/src/inc/posterror.h +++ /dev/null @@ -1,50 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -//***************************************************************************** -// UtilCode.h -// -// Utility functions implemented in UtilCode.lib. -// - -//***************************************************************************** - -#ifndef __PostError_h__ -#define __PostError_h__ - -#include "switches.h" - -//***************************************************************************** -// This function will post an error for the client. If the LOWORD(hrRpt) can -// be found as a valid error message, then it is loaded and formatted with -// the arguments passed in. If it cannot be found, then the error is checked -// against FormatMessage to see if it is a system error. System errors are -// not formatted so no add'l parameters are required. If any errors in this -// process occur, hrRpt is returned for the client with no error posted. -//***************************************************************************** -extern "C" -HRESULT __cdecl PostError( // Returned error. - HRESULT hrRpt, // Reported error. - ...); // Error arguments. - -extern "C" -HRESULT __cdecl PostErrorVA( // Returned error. - HRESULT hrRpt, // Reported error. - va_list marker); // Error arguments. - -//***************************************************************************** -// This function formats an error message, but doesn't fill the IErrorInfo. -//***************************************************************************** -HRESULT __cdecl FormatRuntimeErrorVa( - __out_ecount(cchMsg) WCHAR *rcMsg, // Buffer into which to format. - ULONG cchMsg, // Size of buffer, characters. - HRESULT hrRpt, // The HR to report. - va_list marker); // Optional args. - -HRESULT __cdecl FormatRuntimeError( - __out_ecount(cchMsg) WCHAR *rcMsg, // Buffer into which to format. - ULONG cchMsg, // Size of buffer, characters. - HRESULT hrRpt, // The HR to report. - ...); // Optional args. - -#endif // __PostError_h__ diff --git a/src/inc/prettyprintsig.h b/src/inc/prettyprintsig.h deleted file mode 100644 index adab46ee0..000000000 --- a/src/inc/prettyprintsig.h +++ /dev/null @@ -1,91 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -//***************************************************************************** -// This code supports formatting a method and it's signature in a friendly -// and consistent format. -// -//***************************************************************************** - -#ifndef __PrettyPrintSig_h__ -#define __PrettyPrintSig_h__ - -#include - -class CQuickBytes; - -// -// The return value is either NULL or a null-terminated ASCII string -// - -//--------------------------------------------------------------------------------------- -// -// Prints a signature in a human readable format. -// No one should use this function. This exists strictly for backwards compatibility with external formats. -// -// Arguments: -// sigPtr - Method/field sig to convert -// sigLen - length of sig -// name - the name of the method for this sig. Can be L"" -// scratch - scratch buffer to use -// pIMDI - Import api to use. -// -// Return Value: -// The formatted string. -// -// Assumptions: -// None -// -// Notes: -// Dev's SHOULD NOT create new callers to this function. Use -// code:PrettyPrintSig in formatype.h instead. This function exists for -// legacy support in the CLR. There are places that depend on the format -// of this string. -// - -LPCWSTR PrettyPrintSigLegacy( - PCCOR_SIGNATURE sigPtr, // Method/field sig to convert - unsigned sigLen, // length of sig - LPCWSTR name, // the name of the method for this sig. Can be L"" - CQuickBytes *scratch, // scratch buffer to use - IMetaDataImport *pIMDI); // Import api to use. - -struct IMDInternalImport; - -//--------------------------------------------------------------------------------------- -// -// Prints a signature in a human readable format. -// No one should use this function. This exists strictly for backwards compatibility with external formats. -// -// Arguments: -// sigPtr - Method/field sig to convert -// sigLen - length of sig -// name - the name of the method for this sig. Can be L"" -// out - The buffer in which to write the pretty printed string. -// pIMDI - Import api to use. -// -// Return Value: -// An HRESULT and the formatted string is in out as a unicode string. -// -// Assumptions: -// None -// -// Notes: -// Dev's SHOULD NOT create new callers to this function. Use -// code:PrettyPrintSig in formattype.h instead. This function exists for -// legacy support in the CLR. There are places that depend on the format -// of this string. -// -HRESULT PrettyPrintSigInternalLegacy( // S_OK or error. - PCCOR_SIGNATURE sigPtr, // sig to convert, - unsigned sigLen, // length of sig - LPCSTR name, // can be "", the name of the method for this sig - CQuickBytes *out, // where to put the pretty printed string - IMDInternalImport *pIMDI); // Import api to use. - -// -// On success, the null-terminated ASCII string is in "out.Ptr()" -// - -#endif // __PrettyPrintSig_h__ diff --git a/src/inc/profilepriv.h b/src/inc/profilepriv.h deleted file mode 100644 index ae7b225f8..000000000 --- a/src/inc/profilepriv.h +++ /dev/null @@ -1,156 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -// -// ProfilePriv.h -// - -// -// Structures, etc. used by the Profiling API and throughout the EE -// - -// ====================================================================================== - -#ifndef _ProfilePriv_h_ -#define _ProfilePriv_h_ - - -// Forward declarations -class EEToProfInterfaceImpl; -class Object; -struct ScanContext; - -#if defined (PROFILING_SUPPORTED_DATA) || defined(PROFILING_SUPPORTED) -#ifndef PROFILING_SUPPORTED_DATA -#define PROFILING_SUPPORTED_DATA 1 -#endif // PROFILING_SUPPORTED_DATA - -#include "corprof.h" - -//--------------------------------------------------------------------------------------- -// Enumerates the various init states of profiling. -// -// *** NOTE: The order is important here, as some of the status checks (e.g., -// CORProfilerPresentOrInitializing) use ">" with these enum values. *** - -enum ProfilerStatus -{ - kProfStatusNone = 0, // No profiler running. - kProfStatusDetaching = 1, // Prof was running, is now detaching, but still loaded - kProfStatusInitializingForStartupLoad = 2, // Prof ready for (or in) its Initialize callback - kProfStatusInitializingForAttachLoad = 3, // Prof ready for (or in) its InitializeForAttach callback - kProfStatusActive = 4, // Prof completed initialization and is actively running -}; - -class CurrentProfilerStatus -{ -private: - // Why volatile? - // See code:ProfilingAPIUtility::InitializeProfiling#LoadUnloadCallbackSynchronization - Volatile m_profStatus; - -public: - void Init(); - ProfilerStatus Get(); - void Set(ProfilerStatus profStatus); -}; - -// --------------------------------------------------------------------------------------- -// Global struct that lets the EE see the load status of the profiler, and provides a -// pointer (pProfInterface) through which profiler calls can be made -// -// When you are adding new session, please refer to -// code:ProfControlBlock::ResetPerSessionStatus#ProfileResetSessionStatus for more details. -struct ProfControlBlock -{ - // **** IMPORTANT!! **** - // All uses of pProfInterface must be properly synchronized to avoid the profiler - // from detaching while the EE attempts to call into it. The recommended way to do - // this is to use the (lockless) BEGIN_PIN_PROFILER / END_PIN_PROFILER macros. See - // code:BEGIN_PIN_PROFILER for instructions. For full details on how the - // synchronization works, see - // code:ProfilingAPIUtility::InitializeProfiling#LoadUnloadCallbackSynchronization - VolatilePtr pProfInterface; - // **** IMPORTANT!! **** - - DWORD dwEventMask; // Original low event mask bits - DWORD dwEventMaskHigh; // New high event mask bits - CurrentProfilerStatus curProfStatus; - BOOL fGCInProgress; - BOOL fBaseSystemClassesLoaded; - -#ifdef PROF_TEST_ONLY_FORCE_ELT_DATA - // #TestOnlyELT This implements a test-only (and debug-only) hook that allows a test - // profiler to ensure enter/leave/tailcall is enabled on startup even though no - // profiler is loaded on startup. This allows an attach profiler to use ELT to build - // shadow stacks for the sole purpose of verifying OTHER areas of the profiling API - // (e.g., stack walking). When this BOOL is TRUE, the JIT will insert calls to the - // slow-path profiling API enter/leave/tailcall hooks, which will forward the call to - // a profiler if one is loaded (and do nothing otherwise). - // - // See code:AreCallbackStateFlagsSet#P2CLRRestrictionsOverview for general information - // on how the test hooks lift restrictions normally in place for the Info functions. - BOOL fTestOnlyForceEnterLeave; -#endif - -#ifdef PROF_TEST_ONLY_FORCE_OBJECT_ALLOCATED_DATA - // #TestOnlyObjectAllocated This implements a test-only (and debug-only) hook that allows - // a test profiler to ensure ObjectAllocated callback is enabled on startup even though no - // profiler is loaded on startup. This allows an attach profiler to use ObjectAllocated - // callback for the sole purpose of verifying OTHER GC areas of the profiling API - // (e.g., constructing a object graph). When this BOOL is TRUE, the JIT will use special - // version of new allocators that issue object allocation notifications, which will forward - // the notifications to a profiler if one is loaded (and do nothing otherwise). - // - // See code:AreCallbackStateFlagsSet#P2CLRRestrictionsOverview for general information - // on how the test hooks lift restrictions normally in place for the Info functions. - BOOL fTestOnlyForceObjectAllocated; -#endif - -#ifdef _DEBUG - // Test-only, debug-only code to allow attaching profilers to call ICorProfilerInfo inteface, - // which would otherwise be disallowed for attaching profilers - BOOL fTestOnlyEnableICorProfilerInfo; -#endif // _DEBUG - - // Whether we've turned off concurrent GC during attach - BOOL fConcurrentGCDisabledForAttach; - - void Init(); - void ResetPerSessionStatus(); -}; - - -GVAL_DECL(ProfControlBlock, g_profControlBlock); - -// Provides definitions of the CORProfilerTrack* functions that test whether a profiler -// is active and responding to various callbacks -#include "profilepriv.inl" - -//--------------------------------------------------------------- -// Bit flags used to track profiler callback execution state, such as which -// ICorProfilerCallback method we're currently executing. These help us enforce the -// invariants of which calls a profiler is allowed to make at given times. These flags -// are stored in Thread::m_profilerCallbackState. -// -// For now, we ensure: -// * Only asynchronous-safe calls are made asynchronously (i.e., are made from -// outside of profiler callbacks). -// * GC_TRIGGERS info methods are not called from GC_NOTRIGGER callbacks -// -// Later, we may choose to enforce even more refined call trees and add more flags. -#define COR_PRF_CALLBACKSTATE_INCALLBACK 0x1 -#define COR_PRF_CALLBACKSTATE_IN_TRIGGERS_SCOPE 0x2 -#define COR_PRF_CALLBACKSTATE_FORCEGC_WAS_CALLED 0x4 -// -//--------------------------------------------------------------- - -#endif // defined(PROFILING_SUPPORTED_DATA) || defined(PROFILING_SUPPORTED) - -// This is the helper callback that the gc uses when walking the heap. -bool HeapWalkHelper(Object* pBO, void* pv); -void ScanRootsHelper(Object* pObj, Object** ppRoot, ScanContext *pSC, uint32_t dwUnused); -bool AllocByClassHelper(Object* pBO, void* pv); - -#endif // _ProfilePriv_h_ - diff --git a/src/inc/profilepriv.inl b/src/inc/profilepriv.inl deleted file mode 100644 index 1af291433..000000000 --- a/src/inc/profilepriv.inl +++ /dev/null @@ -1,857 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -// -// ProfilePriv.inl -// - -// -// Inlined functions used by the Profiling API and throughout the EE. Most notably are -// the CORProfilerTrack* functions that test whether a profiler is active and responding -// to various callbacks -// - -// ====================================================================================== -#ifndef _ProfilePriv_inl_ -#define _ProfilePriv_inl_ - -#include "eetoprofinterfaceimpl.h" -#ifdef PROFILING_SUPPORTED -#include "profilinghelper.h" -BOOL CORProfilerBypassSecurityChecks(); -#endif // PROFILING_SUPPORTED - -//--------------------------------------------------------------------------------------- -// CurrentProfilerStatus -//--------------------------------------------------------------------------------------- - -inline void CurrentProfilerStatus::Init() -{ - LIMITED_METHOD_CONTRACT; - m_profStatus = kProfStatusNone; -} - -inline ProfilerStatus CurrentProfilerStatus::Get() -{ - LIMITED_METHOD_DAC_CONTRACT; - return m_profStatus; -} - -//--------------------------------------------------------------------------------------- -// ProfControlBlock -//--------------------------------------------------------------------------------------- - -inline void ProfControlBlock::Init() -{ - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - CANNOT_TAKE_LOCK; - } - CONTRACTL_END; - - curProfStatus.Init(); - - fGCInProgress = FALSE; - fBaseSystemClassesLoaded = FALSE; -#ifdef PROF_TEST_ONLY_FORCE_ELT - fTestOnlyForceEnterLeave = FALSE; -#endif - -#ifdef PROF_TEST_ONLY_FORCE_OBJECT_ALLOCATED - fTestOnlyForceObjectAllocated = FALSE; -#endif - -#ifdef _DEBUG - fTestOnlyEnableICorProfilerInfo = FALSE; -#endif // _DEBUG - - fConcurrentGCDisabledForAttach = FALSE; - - ResetPerSessionStatus(); -} - -// Reset those variables that is only for the current attach session -inline void ProfControlBlock::ResetPerSessionStatus() -{ - LIMITED_METHOD_CONTRACT; - - pProfInterface = NULL; - dwEventMask = COR_PRF_MONITOR_NONE; - dwEventMaskHigh = COR_PRF_HIGH_MONITOR_NONE; -} - -//--------------------------------------------------------------------------------------- -// Inlined helpers used throughout the runtime to check for the profiler's load status -// and what features it enabled callbacks for. -//--------------------------------------------------------------------------------------- - - -// CORProfilerPresent() returns whether or not a CLR Profiler is actively loaded -// (meaning it's initialized and ready to receive callbacks). -inline BOOL CORProfilerPresent() -{ - LIMITED_METHOD_DAC_CONTRACT; - - return ((&g_profControlBlock)->curProfStatus.Get() == kProfStatusActive); -} - -// These return whether a CLR Profiler is actively loaded AND has requested the -// specified callback or functionality - -inline BOOL CORProfilerFunctionIDMapperEnabled() -{ - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - CANNOT_TAKE_LOCK; - SO_NOT_MAINLINE; - } - CONTRACTL_END; - - return (CORProfilerPresent() && - ( - ((&g_profControlBlock)->pProfInterface->GetFunctionIDMapper() != NULL) || - ((&g_profControlBlock)->pProfInterface->GetFunctionIDMapper2() != NULL) - )); -} - -inline BOOL CORProfilerTrackJITInfo() -{ - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - CANNOT_TAKE_LOCK; - SO_NOT_MAINLINE; - } - CONTRACTL_END; - - return (CORProfilerPresent() && - ((&g_profControlBlock)->dwEventMask & COR_PRF_MONITOR_JIT_COMPILATION)); -} - -inline BOOL CORProfilerTrackCacheSearches() -{ - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - CANNOT_TAKE_LOCK; - SO_NOT_MAINLINE; - } - CONTRACTL_END; - - return (CORProfilerPresent() && - ((&g_profControlBlock)->dwEventMask & COR_PRF_MONITOR_CACHE_SEARCHES)); -} - -inline BOOL CORProfilerTrackModuleLoads() -{ - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - CANNOT_TAKE_LOCK; - SO_NOT_MAINLINE; - } - CONTRACTL_END; - - return (CORProfilerPresent() && - ((&g_profControlBlock)->dwEventMask & COR_PRF_MONITOR_MODULE_LOADS)); -} - -inline BOOL CORProfilerTrackAssemblyLoads() -{ - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - CANNOT_TAKE_LOCK; - SO_NOT_MAINLINE; - } - CONTRACTL_END; - - return (CORProfilerPresent() && - ((&g_profControlBlock)->dwEventMask & COR_PRF_MONITOR_ASSEMBLY_LOADS)); -} - -inline BOOL CORProfilerTrackAppDomainLoads() -{ - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - CANNOT_TAKE_LOCK; - SO_NOT_MAINLINE; - } - CONTRACTL_END; - - return (CORProfilerPresent() && - ((&g_profControlBlock)->dwEventMask & COR_PRF_MONITOR_APPDOMAIN_LOADS)); -} - -inline BOOL CORProfilerTrackThreads() -{ - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - CANNOT_TAKE_LOCK; - SO_NOT_MAINLINE; - } - CONTRACTL_END; - - return (CORProfilerPresent() && - ((&g_profControlBlock)->dwEventMask & COR_PRF_MONITOR_THREADS)); -} - -inline BOOL CORProfilerTrackClasses() -{ - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - CANNOT_TAKE_LOCK; - SO_NOT_MAINLINE; - } - CONTRACTL_END; - - return (CORProfilerPresent() && - ((&g_profControlBlock)->dwEventMask & COR_PRF_MONITOR_CLASS_LOADS)); -} - -inline BOOL CORProfilerTrackGC() -{ - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - CANNOT_TAKE_LOCK; - SO_NOT_MAINLINE; - } - CONTRACTL_END; - - return (CORProfilerPresent() && - ((&g_profControlBlock)->dwEventMask & COR_PRF_MONITOR_GC)); -} - -inline BOOL CORProfilerTrackAllocationsEnabled() -{ - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - CANNOT_TAKE_LOCK; - SO_NOT_MAINLINE; - } - CONTRACTL_END; - - return - ( -#ifdef PROF_TEST_ONLY_FORCE_OBJECT_ALLOCATED - (&g_profControlBlock)->fTestOnlyForceObjectAllocated || -#endif - (CORProfilerPresent() && - ((&g_profControlBlock)->dwEventMask & COR_PRF_ENABLE_OBJECT_ALLOCATED)) - ); -} - -inline BOOL CORProfilerTrackAllocations() -{ - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - CANNOT_TAKE_LOCK; - SO_NOT_MAINLINE; - } - CONTRACTL_END; - - return - (CORProfilerTrackAllocationsEnabled() && - ((&g_profControlBlock)->dwEventMask & COR_PRF_MONITOR_OBJECT_ALLOCATED)); -} - -inline BOOL CORProfilerEnableRejit() -{ - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - CANNOT_TAKE_LOCK; - SO_NOT_MAINLINE; - } - CONTRACTL_END; - - return (CORProfilerPresent() && - ((&g_profControlBlock)->dwEventMask & COR_PRF_ENABLE_REJIT)); -} - -inline BOOL CORProfilerTrackExceptions() -{ - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - CANNOT_TAKE_LOCK; - SO_NOT_MAINLINE; - } - CONTRACTL_END; - - return (CORProfilerPresent() && - ((&g_profControlBlock)->dwEventMask & COR_PRF_MONITOR_EXCEPTIONS)); -} - -inline BOOL CORProfilerTrackCLRExceptions() -{ - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - CANNOT_TAKE_LOCK; - SO_NOT_MAINLINE; - } - CONTRACTL_END; - - return (CORProfilerPresent() && - ((&g_profControlBlock)->dwEventMask & COR_PRF_MONITOR_CLR_EXCEPTIONS)); -} - -inline BOOL CORProfilerTrackTransitions() -{ - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - CANNOT_TAKE_LOCK; - SO_NOT_MAINLINE; - } - CONTRACTL_END; - - return (CORProfilerPresent() && - ((&g_profControlBlock)->dwEventMask & COR_PRF_MONITOR_CODE_TRANSITIONS)); -} - -inline BOOL CORProfilerTrackEnterLeave() -{ - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - CANNOT_TAKE_LOCK; - SO_NOT_MAINLINE; - } - CONTRACTL_END; - -#ifdef PROF_TEST_ONLY_FORCE_ELT - if ((&g_profControlBlock)->fTestOnlyForceEnterLeave) - return TRUE; -#endif // PROF_TEST_ONLY_FORCE_ELT - - return (CORProfilerPresent() && - ((&g_profControlBlock)->dwEventMask & COR_PRF_MONITOR_ENTERLEAVE)); -} - -inline BOOL CORProfilerTrackCCW() -{ - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - CANNOT_TAKE_LOCK; - SO_NOT_MAINLINE; - } - CONTRACTL_END; - - return (CORProfilerPresent() && - ((&g_profControlBlock)->dwEventMask & COR_PRF_MONITOR_CCW)); -} - -inline BOOL CORProfilerTrackRemoting() -{ - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - CANNOT_TAKE_LOCK; - SO_NOT_MAINLINE; - } - CONTRACTL_END; - - return (CORProfilerPresent() && - ((&g_profControlBlock)->dwEventMask & COR_PRF_MONITOR_REMOTING)); -} - -inline BOOL CORProfilerTrackRemotingCookie() -{ - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - CANNOT_TAKE_LOCK; - SO_NOT_MAINLINE; - } - CONTRACTL_END; - - return - (CORProfilerPresent() && - (((&g_profControlBlock)->dwEventMask & COR_PRF_MONITOR_REMOTING_COOKIE) - == COR_PRF_MONITOR_REMOTING_COOKIE)); -} - -inline BOOL CORProfilerTrackRemotingAsync() -{ - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - CANNOT_TAKE_LOCK; - SO_NOT_MAINLINE; - } - CONTRACTL_END; - - return - (CORProfilerPresent() && - (((&g_profControlBlock)->dwEventMask & COR_PRF_MONITOR_REMOTING_ASYNC) - == COR_PRF_MONITOR_REMOTING_ASYNC)); -} - -inline BOOL CORProfilerTrackSuspends() -{ - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - CANNOT_TAKE_LOCK; - SO_NOT_MAINLINE; - } - CONTRACTL_END; - - return (CORProfilerPresent() && - ((&g_profControlBlock)->dwEventMask & COR_PRF_MONITOR_SUSPENDS)); -} - -inline BOOL CORProfilerDisableInlining() -{ - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - CANNOT_TAKE_LOCK; - SO_NOT_MAINLINE; - } - CONTRACTL_END; - - return (CORProfilerPresent() && - ((&g_profControlBlock)->dwEventMask & COR_PRF_DISABLE_INLINING)); -} - -inline BOOL CORProfilerJITMapEnabled() -{ - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - CANNOT_TAKE_LOCK; - SO_NOT_MAINLINE; - } - CONTRACTL_END; - - return (CORProfilerPresent() && - ((&g_profControlBlock)->dwEventMask & COR_PRF_ENABLE_JIT_MAPS)); -} - -inline BOOL CORProfilerDisableOptimizations() -{ - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - CANNOT_TAKE_LOCK; - SO_NOT_MAINLINE; - SUPPORTS_DAC; - } - CONTRACTL_END; - - return (CORProfilerPresent() && - ((&g_profControlBlock)->dwEventMask & COR_PRF_DISABLE_OPTIMIZATIONS)); -} - -inline BOOL CORProfilerUseProfileImages() -{ - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - CANNOT_TAKE_LOCK; - SO_NOT_MAINLINE; - } - CONTRACTL_END; - -#ifdef PROF_TEST_ONLY_FORCE_ELT - if ((&g_profControlBlock)->fTestOnlyForceEnterLeave) - return TRUE; -#endif // PROF_TEST_ONLY_FORCE_ELT - - if (!CORProfilerPresent()) - return FALSE; - - if (((&g_profControlBlock)->dwEventMask & - COR_PRF_REQUIRE_PROFILE_IMAGE) == 0) - return FALSE; - - return TRUE; -} - -inline BOOL CORProfilerDisableAllNGenImages() -{ - LIMITED_METHOD_DAC_CONTRACT; - - return (CORProfilerPresent() && - ((&g_profControlBlock)->dwEventMask & COR_PRF_DISABLE_ALL_NGEN_IMAGES)); -} - -inline BOOL CORProfilerTrackConditionalWeakTableElements() -{ - LIMITED_METHOD_DAC_CONTRACT; - - return CORProfilerTrackGC() && (&g_profControlBlock)->pProfInterface->IsCallback5Supported(); -} - -// CORProfilerPresentOrInitializing() returns nonzero iff a CLR Profiler is actively -// loaded and ready to receive callbacks OR a CLR Profiler has loaded just enough that it -// is ready to receive (or is currently executing inside) its Initialize() callback. -// Typically, you'll want to use code:CORProfilerPresent instead of this. But there is -// some internal profiling API code that wants to test for event flags for a profiler -// that may still be initializing, and this function is appropriate for that code. -inline BOOL CORProfilerPresentOrInitializing() -{ - LIMITED_METHOD_DAC_CONTRACT; - return ((&g_profControlBlock)->curProfStatus.Get() > kProfStatusDetaching); -} - -// These return whether a CLR Profiler has requested the specified functionality. -// -// Note that, unlike the above functions, a profiler that's not done loading (and is -// still somewhere in the initialization phase) still counts. This is only safe because -// these functions are not used to determine whether to issue a callback. These functions -// are used primarily during the initialization path to choose between slow / fast-path -// ELT hooks (and later on as part of asserts). - -inline BOOL CORProfilerELT3SlowPathEnabled() -{ - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - CANNOT_TAKE_LOCK; - SO_NOT_MAINLINE; - } - CONTRACTL_END; - - return (CORProfilerPresentOrInitializing() && - ((&g_profControlBlock)->dwEventMask & (COR_PRF_ENABLE_FUNCTION_ARGS | COR_PRF_ENABLE_FUNCTION_RETVAL | COR_PRF_ENABLE_FRAME_INFO))); -} - -inline BOOL CORProfilerELT3SlowPathEnterEnabled() -{ - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - CANNOT_TAKE_LOCK; - SO_NOT_MAINLINE; - } - CONTRACTL_END; - - return (CORProfilerPresentOrInitializing() && - ((&g_profControlBlock)->dwEventMask & (COR_PRF_ENABLE_FUNCTION_ARGS | COR_PRF_ENABLE_FRAME_INFO))); -} - -inline BOOL CORProfilerELT3SlowPathLeaveEnabled() -{ - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - CANNOT_TAKE_LOCK; - SO_NOT_MAINLINE; - } - CONTRACTL_END; - - return (CORProfilerPresentOrInitializing() && - ((&g_profControlBlock)->dwEventMask & (COR_PRF_ENABLE_FUNCTION_RETVAL | COR_PRF_ENABLE_FRAME_INFO))); -} - -inline BOOL CORProfilerELT3SlowPathTailcallEnabled() -{ - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - CANNOT_TAKE_LOCK; - SO_NOT_MAINLINE; - } - CONTRACTL_END; - - return (CORProfilerPresentOrInitializing() && - ((&g_profControlBlock)->dwEventMask & (COR_PRF_ENABLE_FRAME_INFO))); -} - -inline BOOL CORProfilerELT2FastPathEnterEnabled() -{ - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - CANNOT_TAKE_LOCK; - SO_NOT_MAINLINE; - } - CONTRACTL_END; - - return (CORProfilerPresentOrInitializing() && - (!((&g_profControlBlock)->dwEventMask & (COR_PRF_ENABLE_STACK_SNAPSHOT | COR_PRF_ENABLE_FUNCTION_ARGS | COR_PRF_ENABLE_FRAME_INFO)))); -} - -inline BOOL CORProfilerELT2FastPathLeaveEnabled() -{ - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - CANNOT_TAKE_LOCK; - SO_NOT_MAINLINE; - } - CONTRACTL_END; - - return (CORProfilerPresentOrInitializing() && - (!((&g_profControlBlock)->dwEventMask & (COR_PRF_ENABLE_STACK_SNAPSHOT | COR_PRF_ENABLE_FUNCTION_RETVAL | COR_PRF_ENABLE_FRAME_INFO)))); -} - -inline BOOL CORProfilerELT2FastPathTailcallEnabled() -{ - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - CANNOT_TAKE_LOCK; - SO_NOT_MAINLINE; - } - CONTRACTL_END; - - return (CORProfilerPresentOrInitializing() && - (!((&g_profControlBlock)->dwEventMask & (COR_PRF_ENABLE_STACK_SNAPSHOT | COR_PRF_ENABLE_FRAME_INFO)))); -} - -inline BOOL CORProfilerFunctionArgsEnabled() -{ - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - CANNOT_TAKE_LOCK; - SO_NOT_MAINLINE; - } - CONTRACTL_END; - - return (CORProfilerPresentOrInitializing() && - ((&g_profControlBlock)->dwEventMask & COR_PRF_ENABLE_FUNCTION_ARGS)); -} - -inline BOOL CORProfilerFunctionReturnValueEnabled() -{ - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - CANNOT_TAKE_LOCK; - SO_NOT_MAINLINE; - } - CONTRACTL_END; - - return (CORProfilerPresentOrInitializing() && - ((&g_profControlBlock)->dwEventMask & COR_PRF_ENABLE_FUNCTION_RETVAL)); -} - -inline BOOL CORProfilerFrameInfoEnabled() -{ - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - CANNOT_TAKE_LOCK; - SO_NOT_MAINLINE; - } - CONTRACTL_END; - - return (CORProfilerPresentOrInitializing() && - ((&g_profControlBlock)->dwEventMask & COR_PRF_ENABLE_FRAME_INFO)); -} - -inline BOOL CORProfilerStackSnapshotEnabled() -{ - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - CANNOT_TAKE_LOCK; - SO_NOT_MAINLINE; - } - CONTRACTL_END; - - return (CORProfilerPresentOrInitializing() && - ((&g_profControlBlock)->dwEventMask & COR_PRF_ENABLE_STACK_SNAPSHOT)); -} - -inline BOOL CORProfilerAddsAssemblyReferences() -{ - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - CANNOT_TAKE_LOCK; - SO_NOT_MAINLINE; - } - CONTRACTL_END; - - return (CORProfilerPresent() && - ((&g_profControlBlock)->dwEventMaskHigh & COR_PRF_HIGH_ADD_ASSEMBLY_REFERENCES)); -} - -inline BOOL CORProfilerInMemorySymbolsUpdatesEnabled() -{ - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - CANNOT_TAKE_LOCK; - SO_NOT_MAINLINE; - } - CONTRACTL_END; - - return (CORProfilerPresent() && - ((&g_profControlBlock)->dwEventMaskHigh & COR_PRF_HIGH_IN_MEMORY_SYMBOLS_UPDATED)); -} - -inline BOOL CORProfilerIsMonitoringDynamicFunctionUnloads() -{ - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - CANNOT_TAKE_LOCK; - SO_NOT_MAINLINE; - } - CONTRACTL_END; - - return (CORProfilerPresent() && - ((&g_profControlBlock)->dwEventMaskHigh & COR_PRF_HIGH_MONITOR_DYNAMIC_FUNCTION_UNLOADS)); -} - -inline BOOL CORProfilerDisableTieredCompilation() -{ - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - CANNOT_TAKE_LOCK; - SO_NOT_MAINLINE; - } - CONTRACTL_END; - - - return (CORProfilerPresent() && - ((&g_profControlBlock)->dwEventMaskHigh & COR_PRF_HIGH_DISABLE_TIERED_COMPILATION)); -} - -#if defined(PROFILING_SUPPORTED) && !defined(CROSSGEN_COMPILE) - -#if defined(FEATURE_PROFAPI_ATTACH_DETACH) - -//--------------------------------------------------------------------------------------- -// When EE calls into the profiler, an EvacuationCounterHolder object is instantiated on -// the stack to increment the evacuation counter inside the EE Thread. Upon returning to -// EE, this EvacuationCounterHolder object when being destroyed decreases the evacuation -// counter by one. -// -// Do not use this object directly. Use BEGIN_PIN_PROFILER / END_PIN_PROFILER defined -// below. -// -// See code:ProfilingAPIUtility::InitializeProfiling#LoadUnloadCallbackSynchronization. -// -typedef Wrapper, HSV_NoValidation> EvacuationCounterHolder; - - -//--------------------------------------------------------------------------------------- -// These macros must be placed around any access to g_profControlBlock.pProfInterface by -// the EE. Example: -// { -// BEGIN_PIN_PROFILER(CORProfilerTrackAppDomainLoads()); -// g_profControlBlock.pProfInterface->AppDomainCreationStarted(MyAppDomainID); -// END_PIN_PROFILER(); -// } -// The parameter to the BEGIN_PIN_PROFILER is the condition you want to check for, to -// determine whether the profiler is loaded and requesting the callback you're about to -// issue. Typically, this will be a call to one of the inline functions in -// profilepriv.inl. If the condition is true, the macro will increment an evacuation -// counter that effectively pins the profiler, recheck the condition, and (if still -// true), execute whatever code you place inside the BEGIN/END_PIN_PROFILER block. If -// your condition is more complex than a simple profiler status check, then place the -// profiler status check as parameter to the macro, and add a separate if inside the -// block. Example: -// -// { -// BEGIN_PIN_PROFILER(CORProfilerTrackTransitions()); -// if (!pNSL->pMD->IsQCall()) -// { -// g_profControlBlock.pProfInterface-> -// ManagedToUnmanagedTransition((FunctionID) pNSL->pMD, -// COR_PRF_TRANSITION_CALL); -// } -// END_PIN_PROFILER(); -// } -// -// This ensures that the extra condition check (in this case "if -// (!pNSL->pMD->IsQCall())") is only evaluated if the profiler is loaded. That way, we're -// not executing extra, unnecessary instructions when no profiler is present. -// -// See code:ProfilingAPIUtility::InitializeProfiling#LoadUnloadCallbackSynchronization -// for more details about how the synchronization works. -#define BEGIN_PIN_PROFILER(condition) \ - /* Do a cheap check of the condition (dirty-read) */ \ - if (condition) \ - { \ - EvacuationCounterHolder __evacuationCounter(GetThreadNULLOk()); \ - /* Now that the evacuation counter is incremented, the condition re-check */ \ - /* below is a clean read. There's no MemoryBarrier() here, but that's ok */ \ - /* as writes to the profiler status force a FlushStoreBuffers(). */ \ - if (condition) \ - { -#define END_PIN_PROFILER() } } - -#else // FEATURE_PROFAPI_ATTACH_DETACH - -// For builds that include profiling but not attach / detach (e.g., Silverlight 2), the -// *PIN_PROFILER macros should just check the condition without using the evacuation -// counters. - -#define BEGIN_PIN_PROFILER(condition) if (condition) { -#define END_PIN_PROFILER() } - -#endif // FEATURE_PROFAPI_ATTACH_DETACH - -#else // PROFILING_SUPPORTED && !CROSSGEN_COMPILE - -// Profiling feature not supported - -#define BEGIN_PIN_PROFILER(condition) if (false) { -#define END_PIN_PROFILER() } - -#endif // PROFILING_SUPPORTED && !CROSSGEN_COMPILE - -#endif // _ProfilePriv_inl_ - diff --git a/src/inc/rangetree.h b/src/inc/rangetree.h deleted file mode 100644 index 7124d2105..000000000 --- a/src/inc/rangetree.h +++ /dev/null @@ -1,141 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - - -#ifndef _RANGETREE_ -#define _RANGETREE_ - -#include "utilcode.h" -#include "memorypool.h" - -// -// A RangeTree is a self-balancing binary tree of non-overlapping -// ranges [start-end), which provides log N operation time for -// lookup, insertion, and deletion of nodes. -// -// The tree is always balanced in the sense that the left and right -// sides of a node have the same amount of address space allocated to -// them - (for worst case data, the nodes of the tree might actually -// not be balanced). -// -// This address-space balancing means that if all the ranges cover a -// contiguous range of memory, and if lookup occur uniformly throughout -// the overall range covered, the tree provides optimal lookup -// structure. -// -// Another interesting property is that the same set of -// ranges always produces the same tree layout, regardless of -// the order the nodes are added in. -// -// Each node represents a range of the address space (in binary) -// from m0...0 to m1...1, where m is any number of 31 bits or -// less. -// -// Each node has 3 components: -// * a range -// * a 0-child, -// * a 1-child -// -// The range is the numeric range [start,end), -// represented by the node. A range is always assigned to the -// widest possible node (i.e. most bits in m) possible. Thus the -// bits of start and end share the same prefix string m, and -// differ in the next bit after m: the start bound will have a 0 -// and the end bound will have a 1 in that position. -// -// Note that any other range which is represented by the same node -// must necessarily intersect the node. Thus, if no overlaps are -// possible, each node can only contain a single range. (To help -// see why this must be, it helps to realize that the node -// represents the transition from m01...1 to m10...0, which any -// range represented by this node must contain.) -// -// All range nodes represented by the form m0... are contained in -// the 0-child subtree, and all nodes represented by the form -// m1... are contained in the 1-child subtree. Either child can -// of course be null. -// - -class RangeTree -{ - public: - - // - // Imbed the RangeTreeNode structure in your data structure - // in order to place it into a RangeTree. - // - - struct Node - { - friend class RangeTree; - - private: - // start & end (exclusive) of range - SIZE_T start; - SIZE_T end; - // mask of high-order bits which are the same in start & end - SIZE_T mask; - // We could steal a bit from mask or children[] for isIntermediate - BOOL isIntermediate; -#ifdef _DEBUG - // ordinal of when this node was created - DWORD ordinal; -#endif - - Node *children[2]; - - void Init (SIZE_T rangeStart, SIZE_T rangeEnd - DEBUGARG(DWORD ord)); - - Node** Child(SIZE_T address) - { - LIMITED_METHOD_CONTRACT; - - return &children[ ! ! (address & ((~mask>>1)+1))]; - } - - public: - BOOL IsIntermediate() { return isIntermediate; } - void IsIntermediate(BOOL value) { isIntermediate = value; } - SIZE_T GetStart() { return start; } - SIZE_T GetEnd() { return end; } - }; - - friend struct Node; - - RangeTree(); - - Node *Lookup(SIZE_T address) const; - Node *LookupEndInclusive(SIZE_T nonStartingAddress); - BOOL Overlaps(SIZE_T start, SIZE_T end); - HRESULT AddNode(Node *addNode, SIZE_T start, SIZE_T end); - HRESULT RemoveNode(Node *removeNode); - void RemoveRange(SIZE_T start, SIZE_T end); - - typedef void (*IterationCallback)(Node *next, void *context); - - void Iterate(IterationCallback pCallback, void *context = NULL); - void IterateRange(SIZE_T start, SIZE_T end, IterationCallback pCallback, void *context = NULL); - - private: - - Node * m_root; - MemoryPool m_pool; -#ifdef _DEBUG - DWORD m_nodeCount; -#endif - - Node *AddIntermediateNode(Node *node0, Node *node1); - Node *AllocateIntermediate(); - void FreeIntermediate(Node *node); - - void IterateNode(Node *node, IterationCallback pCallback, void *context); - void IterateRangeNode(Node *node, SIZE_T start, SIZE_T end, SIZE_T mask, IterationCallback pCallback, void *context); - BOOL OverlapsNode(Node *node, SIZE_T start, SIZE_T end, SIZE_T mask); - void RemoveRangeNode(Node **nodePtr, SIZE_T start, SIZE_T end, SIZE_T mask); - - static SIZE_T GetRangeCommonMask(SIZE_T start, SIZE_T end); -}; - -#endif // _RANGETREE_ diff --git a/src/inc/readytorun.h b/src/inc/readytorun.h deleted file mode 100644 index 0f5183ff3..000000000 --- a/src/inc/readytorun.h +++ /dev/null @@ -1,346 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -// -// readytorun.h -// - -// -// Contains definitions for the Ready to Run file format -// - -#ifndef __READYTORUN_H__ -#define __READYTORUN_H__ - -#define READYTORUN_SIGNATURE 0x00525452 // 'RTR' - -#define READYTORUN_MAJOR_VERSION 0x0002 -#define READYTORUN_MINOR_VERSION 0x0002 -// R2R Version 2.1 adds the READYTORUN_SECTION_INLINING_INFO section -// R2R Version 2.2 adds the READYTORUN_SECTION_PROFILEDATA_INFO section - -struct READYTORUN_HEADER -{ - DWORD Signature; // READYTORUN_SIGNATURE - USHORT MajorVersion; // READYTORUN_VERSION_XXX - USHORT MinorVersion; - - DWORD Flags; // READYTORUN_FLAG_XXX - - DWORD NumberOfSections; - - // Array of sections follows. The array entries are sorted by Type - // READYTORUN_SECTION Sections[]; -}; - -struct READYTORUN_SECTION -{ - DWORD Type; // READYTORUN_SECTION_XXX - IMAGE_DATA_DIRECTORY Section; -}; - -enum ReadyToRunFlag -{ - // Set if the original IL assembly was platform-neutral - READYTORUN_FLAG_PLATFORM_NEUTRAL_SOURCE = 0x00000001, - READYTORUN_FLAG_SKIP_TYPE_VALIDATION = 0x00000002, -}; - -enum ReadyToRunSectionType -{ - READYTORUN_SECTION_COMPILER_IDENTIFIER = 100, - READYTORUN_SECTION_IMPORT_SECTIONS = 101, - READYTORUN_SECTION_RUNTIME_FUNCTIONS = 102, - READYTORUN_SECTION_METHODDEF_ENTRYPOINTS = 103, - READYTORUN_SECTION_EXCEPTION_INFO = 104, - READYTORUN_SECTION_DEBUG_INFO = 105, - READYTORUN_SECTION_DELAYLOAD_METHODCALL_THUNKS = 106, - // 107 used by an older format of READYTORUN_SECTION_AVAILABLE_TYPES - READYTORUN_SECTION_AVAILABLE_TYPES = 108, - READYTORUN_SECTION_INSTANCE_METHOD_ENTRYPOINTS = 109, - READYTORUN_SECTION_INLINING_INFO = 110, // Added in V2.1 - READYTORUN_SECTION_PROFILEDATA_INFO = 111 // Added in V2.2 - - // If you add a new section consider whether it is a breaking or non-breaking change. - // Usually it is non-breaking, but if it is preferable to have older runtimes fail - // to load the image vs. ignoring the new section it could be marked breaking. - // Increment the READYTORUN_MINOR_VERSION (non-breaking) or READYTORUN_MAJOR_VERSION - // (breaking) as appropriate. -}; - -// -// READYTORUN_IMPORT_SECTION describes image range with references to code or runtime data structures -// -// There is number of different types of these ranges: eagerly initialized at image load vs. lazily initialized at method entry -// vs. lazily initialized on first use; handles vs. code pointers, etc. -// -struct READYTORUN_IMPORT_SECTION -{ - IMAGE_DATA_DIRECTORY Section; // Section containing values to be fixed up - USHORT Flags; // One or more of ReadyToRunImportSectionFlags - BYTE Type; // One of ReadyToRunImportSectionType - BYTE EntrySize; - DWORD Signatures; // RVA of optional signature descriptors - DWORD AuxiliaryData; // RVA of optional auxiliary data (typically GC info) -}; - -enum ReadyToRunImportSectionType -{ - READYTORUN_IMPORT_SECTION_TYPE_UNKNOWN = 0, -}; - -enum ReadyToRunImportSectionFlags -{ - READYTORUN_IMPORT_SECTION_FLAGS_EAGER = 0x0001, -}; - -// -// Constants for method and field encoding -// - -enum ReadyToRunMethodSigFlags -{ - READYTORUN_METHOD_SIG_UnboxingStub = 0x01, - READYTORUN_METHOD_SIG_InstantiatingStub = 0x02, - READYTORUN_METHOD_SIG_MethodInstantiation = 0x04, - READYTORUN_METHOD_SIG_SlotInsteadOfToken = 0x08, - READYTORUN_METHOD_SIG_MemberRefToken = 0x10, - READYTORUN_METHOD_SIG_Constrained = 0x20, - READYTORUN_METHOD_SIG_OwnerType = 0x40, -}; - -enum ReadyToRunFieldSigFlags -{ - READYTORUN_FIELD_SIG_IndexInsteadOfToken = 0x08, - READYTORUN_FIELD_SIG_MemberRefToken = 0x10, - READYTORUN_FIELD_SIG_OwnerType = 0x40, -}; - -enum ReadyToRunTypeLayoutFlags -{ - READYTORUN_LAYOUT_HFA = 0x01, - READYTORUN_LAYOUT_Alignment = 0x02, - READYTORUN_LAYOUT_Alignment_Native = 0x04, - READYTORUN_LAYOUT_GCLayout = 0x08, - READYTORUN_LAYOUT_GCLayout_Empty = 0x10, -}; - -// -// Constants for fixup signature encoding -// - -enum ReadyToRunFixupKind -{ - READYTORUN_FIXUP_ThisObjDictionaryLookup = 0x07, - READYTORUN_FIXUP_TypeDictionaryLookup = 0x08, - READYTORUN_FIXUP_MethodDictionaryLookup = 0x09, - - READYTORUN_FIXUP_TypeHandle = 0x10, - READYTORUN_FIXUP_MethodHandle = 0x11, - READYTORUN_FIXUP_FieldHandle = 0x12, - - READYTORUN_FIXUP_MethodEntry = 0x13, /* For calling a method entry point */ - READYTORUN_FIXUP_MethodEntry_DefToken = 0x14, /* Smaller version of MethodEntry - method is def token */ - READYTORUN_FIXUP_MethodEntry_RefToken = 0x15, /* Smaller version of MethodEntry - method is ref token */ - - READYTORUN_FIXUP_VirtualEntry = 0x16, /* For invoking a virtual method */ - READYTORUN_FIXUP_VirtualEntry_DefToken = 0x17, /* Smaller version of VirtualEntry - method is def token */ - READYTORUN_FIXUP_VirtualEntry_RefToken = 0x18, /* Smaller version of VirtualEntry - method is ref token */ - READYTORUN_FIXUP_VirtualEntry_Slot = 0x19, /* Smaller version of VirtualEntry - type & slot */ - - READYTORUN_FIXUP_Helper = 0x1A, /* Helper */ - READYTORUN_FIXUP_StringHandle = 0x1B, /* String handle */ - - READYTORUN_FIXUP_NewObject = 0x1C, /* Dynamically created new helper */ - READYTORUN_FIXUP_NewArray = 0x1D, - - READYTORUN_FIXUP_IsInstanceOf = 0x1E, /* Dynamically created casting helper */ - READYTORUN_FIXUP_ChkCast = 0x1F, - - READYTORUN_FIXUP_FieldAddress = 0x20, /* For accessing a cross-module static fields */ - READYTORUN_FIXUP_CctorTrigger = 0x21, /* Static constructor trigger */ - - READYTORUN_FIXUP_StaticBaseNonGC = 0x22, /* Dynamically created static base helpers */ - READYTORUN_FIXUP_StaticBaseGC = 0x23, - READYTORUN_FIXUP_ThreadStaticBaseNonGC = 0x24, - READYTORUN_FIXUP_ThreadStaticBaseGC = 0x25, - - READYTORUN_FIXUP_FieldBaseOffset = 0x26, /* Field base offset */ - READYTORUN_FIXUP_FieldOffset = 0x27, /* Field offset */ - - READYTORUN_FIXUP_TypeDictionary = 0x28, - READYTORUN_FIXUP_MethodDictionary = 0x29, - - READYTORUN_FIXUP_Check_TypeLayout = 0x2A, /* size, alignment, HFA, reference map */ - READYTORUN_FIXUP_Check_FieldOffset = 0x2B, - - READYTORUN_FIXUP_DelegateCtor = 0x2C, /* optimized delegate ctor */ - READYTORUN_FIXUP_DeclaringTypeHandle = 0x2D, -}; - -// -// Intrinsics and helpers -// - -enum ReadyToRunHelper -{ - READYTORUN_HELPER_Invalid = 0x00, - - // Not a real helper - handle to current module passed to delay load helpers. - READYTORUN_HELPER_Module = 0x01, - READYTORUN_HELPER_GSCookie = 0x02, - - // - // Delay load helpers - // - - // All delay load helpers use custom calling convention: - // - scratch register - address of indirection cell. 0 = address is inferred from callsite. - // - stack - section index, module handle - READYTORUN_HELPER_DelayLoad_MethodCall = 0x08, - - READYTORUN_HELPER_DelayLoad_Helper = 0x10, - READYTORUN_HELPER_DelayLoad_Helper_Obj = 0x11, - READYTORUN_HELPER_DelayLoad_Helper_ObjObj = 0x12, - - // JIT helpers - - // Exception handling helpers - READYTORUN_HELPER_Throw = 0x20, - READYTORUN_HELPER_Rethrow = 0x21, - READYTORUN_HELPER_Overflow = 0x22, - READYTORUN_HELPER_RngChkFail = 0x23, - READYTORUN_HELPER_FailFast = 0x24, - READYTORUN_HELPER_ThrowNullRef = 0x25, - READYTORUN_HELPER_ThrowDivZero = 0x26, - - // Write barriers - READYTORUN_HELPER_WriteBarrier = 0x30, - READYTORUN_HELPER_CheckedWriteBarrier = 0x31, - READYTORUN_HELPER_ByRefWriteBarrier = 0x32, - - // Array helpers - READYTORUN_HELPER_Stelem_Ref = 0x38, - READYTORUN_HELPER_Ldelema_Ref = 0x39, - - READYTORUN_HELPER_MemSet = 0x40, - READYTORUN_HELPER_MemCpy = 0x41, - - // Get string handle lazily - READYTORUN_HELPER_GetString = 0x50, - - // Used by /Tuning for Profile optimizations - READYTORUN_HELPER_LogMethodEnter = 0x51, - - // Reflection helpers - READYTORUN_HELPER_GetRuntimeTypeHandle = 0x54, - READYTORUN_HELPER_GetRuntimeMethodHandle = 0x55, - READYTORUN_HELPER_GetRuntimeFieldHandle = 0x56, - - READYTORUN_HELPER_Box = 0x58, - READYTORUN_HELPER_Box_Nullable = 0x59, - READYTORUN_HELPER_Unbox = 0x5A, - READYTORUN_HELPER_Unbox_Nullable = 0x5B, - READYTORUN_HELPER_NewMultiDimArr = 0x5C, - READYTORUN_HELPER_NewMultiDimArr_NonVarArg = 0x5D, - - // Helpers used with generic handle lookup cases - READYTORUN_HELPER_NewObject = 0x60, - READYTORUN_HELPER_NewArray = 0x61, - READYTORUN_HELPER_CheckCastAny = 0x62, - READYTORUN_HELPER_CheckInstanceAny = 0x63, - READYTORUN_HELPER_GenericGcStaticBase = 0x64, - READYTORUN_HELPER_GenericNonGcStaticBase = 0x65, - READYTORUN_HELPER_GenericGcTlsBase = 0x66, - READYTORUN_HELPER_GenericNonGcTlsBase = 0x67, - READYTORUN_HELPER_VirtualFuncPtr = 0x68, - - // Long mul/div/shift ops - READYTORUN_HELPER_LMul = 0xC0, - READYTORUN_HELPER_LMulOfv = 0xC1, - READYTORUN_HELPER_ULMulOvf = 0xC2, - READYTORUN_HELPER_LDiv = 0xC3, - READYTORUN_HELPER_LMod = 0xC4, - READYTORUN_HELPER_ULDiv = 0xC5, - READYTORUN_HELPER_ULMod = 0xC6, - READYTORUN_HELPER_LLsh = 0xC7, - READYTORUN_HELPER_LRsh = 0xC8, - READYTORUN_HELPER_LRsz = 0xC9, - READYTORUN_HELPER_Lng2Dbl = 0xCA, - READYTORUN_HELPER_ULng2Dbl = 0xCB, - - // 32-bit division helpers - READYTORUN_HELPER_Div = 0xCC, - READYTORUN_HELPER_Mod = 0xCD, - READYTORUN_HELPER_UDiv = 0xCE, - READYTORUN_HELPER_UMod = 0xCF, - - // Floating point conversions - READYTORUN_HELPER_Dbl2Int = 0xD0, - READYTORUN_HELPER_Dbl2IntOvf = 0xD1, - READYTORUN_HELPER_Dbl2Lng = 0xD2, - READYTORUN_HELPER_Dbl2LngOvf = 0xD3, - READYTORUN_HELPER_Dbl2UInt = 0xD4, - READYTORUN_HELPER_Dbl2UIntOvf = 0xD5, - READYTORUN_HELPER_Dbl2ULng = 0xD6, - READYTORUN_HELPER_Dbl2ULngOvf = 0xD7, - - // Floating point ops - READYTORUN_HELPER_DblRem = 0xE0, - READYTORUN_HELPER_FltRem = 0xE1, - READYTORUN_HELPER_DblRound = 0xE2, - READYTORUN_HELPER_FltRound = 0xE3, - -#ifdef WIN64EXCEPTIONS - // Personality rountines - READYTORUN_HELPER_PersonalityRoutine = 0xF0, - READYTORUN_HELPER_PersonalityRoutineFilterFunclet = 0xF1, -#endif - - // - // Deprecated/legacy - // - - // JIT32 x86-specific write barriers - READYTORUN_HELPER_WriteBarrier_EAX = 0x100, - READYTORUN_HELPER_WriteBarrier_EBX = 0x101, - READYTORUN_HELPER_WriteBarrier_ECX = 0x102, - READYTORUN_HELPER_WriteBarrier_ESI = 0x103, - READYTORUN_HELPER_WriteBarrier_EDI = 0x104, - READYTORUN_HELPER_WriteBarrier_EBP = 0x105, - READYTORUN_HELPER_CheckedWriteBarrier_EAX = 0x106, - READYTORUN_HELPER_CheckedWriteBarrier_EBX = 0x107, - READYTORUN_HELPER_CheckedWriteBarrier_ECX = 0x108, - READYTORUN_HELPER_CheckedWriteBarrier_ESI = 0x109, - READYTORUN_HELPER_CheckedWriteBarrier_EDI = 0x10A, - READYTORUN_HELPER_CheckedWriteBarrier_EBP = 0x10B, - - // JIT32 x86-specific exception handling - READYTORUN_HELPER_EndCatch = 0x110, -}; - -// -// Exception info -// - -struct READYTORUN_EXCEPTION_LOOKUP_TABLE_ENTRY -{ - DWORD MethodStart; - DWORD ExceptionInfo; -}; - -struct READYTORUN_EXCEPTION_CLAUSE -{ - CorExceptionFlag Flags; - DWORD TryStartPC; - DWORD TryEndPC; - DWORD HandlerStartPC; - DWORD HandlerEndPC; - union { - mdToken ClassToken; - DWORD FilterOffset; - }; -}; - -#endif // __READYTORUN_H__ diff --git a/src/inc/readytorunhelpers.h b/src/inc/readytorunhelpers.h deleted file mode 100644 index 7a1245c3b..000000000 --- a/src/inc/readytorunhelpers.h +++ /dev/null @@ -1,115 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -// -// ReadyToRunHelpers.h -// - -// -// Mapping between regular JIT helpers and ready to run helpers -// - -#ifndef OPTIMIZEFORSPEED -#define OPTIMIZEFORSPEED -#endif - -HELPER(READYTORUN_HELPER_Throw, CORINFO_HELP_THROW, OPTIMIZEFORSIZE) -HELPER(READYTORUN_HELPER_Rethrow, CORINFO_HELP_RETHROW, OPTIMIZEFORSIZE) -HELPER(READYTORUN_HELPER_Overflow, CORINFO_HELP_OVERFLOW, OPTIMIZEFORSIZE) -HELPER(READYTORUN_HELPER_RngChkFail, CORINFO_HELP_RNGCHKFAIL, OPTIMIZEFORSIZE) -HELPER(READYTORUN_HELPER_FailFast, CORINFO_HELP_FAIL_FAST, OPTIMIZEFORSIZE) -HELPER(READYTORUN_HELPER_ThrowNullRef, CORINFO_HELP_THROWNULLREF, OPTIMIZEFORSIZE) -HELPER(READYTORUN_HELPER_ThrowDivZero, CORINFO_HELP_THROWDIVZERO, OPTIMIZEFORSIZE) - -HELPER(READYTORUN_HELPER_WriteBarrier, CORINFO_HELP_ASSIGN_REF, ) -HELPER(READYTORUN_HELPER_CheckedWriteBarrier, CORINFO_HELP_CHECKED_ASSIGN_REF, ) -HELPER(READYTORUN_HELPER_ByRefWriteBarrier, CORINFO_HELP_ASSIGN_BYREF, ) - -HELPER(READYTORUN_HELPER_Stelem_Ref, CORINFO_HELP_ARRADDR_ST, ) -HELPER(READYTORUN_HELPER_Ldelema_Ref, CORINFO_HELP_LDELEMA_REF, ) - -HELPER(READYTORUN_HELPER_MemSet, CORINFO_HELP_MEMSET, ) -HELPER(READYTORUN_HELPER_MemCpy, CORINFO_HELP_MEMCPY, ) - -HELPER(READYTORUN_HELPER_LogMethodEnter, CORINFO_HELP_BBT_FCN_ENTER, ) - -HELPER(READYTORUN_HELPER_GetRuntimeTypeHandle, CORINFO_HELP_TYPEHANDLE_TO_RUNTIMETYPE, ) -HELPER(READYTORUN_HELPER_GetRuntimeMethodHandle, CORINFO_HELP_METHODDESC_TO_STUBRUNTIMEMETHOD, ) -HELPER(READYTORUN_HELPER_GetRuntimeFieldHandle, CORINFO_HELP_FIELDDESC_TO_STUBRUNTIMEFIELD, ) - -HELPER(READYTORUN_HELPER_Box, CORINFO_HELP_BOX, ) -HELPER(READYTORUN_HELPER_Box_Nullable, CORINFO_HELP_BOX_NULLABLE, ) -HELPER(READYTORUN_HELPER_Unbox, CORINFO_HELP_UNBOX, ) -HELPER(READYTORUN_HELPER_Unbox_Nullable, CORINFO_HELP_UNBOX_NULLABLE, ) -HELPER(READYTORUN_HELPER_NewMultiDimArr, CORINFO_HELP_NEW_MDARR, ) -HELPER(READYTORUN_HELPER_NewMultiDimArr_NonVarArg, CORINFO_HELP_NEW_MDARR_NONVARARG, ) - -HELPER(READYTORUN_HELPER_NewObject, CORINFO_HELP_NEWFAST, ) -HELPER(READYTORUN_HELPER_NewArray, CORINFO_HELP_NEWARR_1_R2R_DIRECT, ) -HELPER(READYTORUN_HELPER_CheckCastAny, CORINFO_HELP_CHKCASTANY, ) -HELPER(READYTORUN_HELPER_CheckInstanceAny, CORINFO_HELP_ISINSTANCEOFANY, ) - -HELPER(READYTORUN_HELPER_GenericGcStaticBase, CORINFO_HELP_GETGENERICS_GCSTATIC_BASE, ) -HELPER(READYTORUN_HELPER_GenericNonGcStaticBase, CORINFO_HELP_GETGENERICS_NONGCSTATIC_BASE, ) -HELPER(READYTORUN_HELPER_GenericGcTlsBase, CORINFO_HELP_GETGENERICS_GCTHREADSTATIC_BASE, ) -HELPER(READYTORUN_HELPER_GenericNonGcTlsBase, CORINFO_HELP_GETGENERICS_NONGCTHREADSTATIC_BASE,) - -HELPER(READYTORUN_HELPER_VirtualFuncPtr, CORINFO_HELP_VIRTUAL_FUNC_PTR, ) - -HELPER(READYTORUN_HELPER_LMul, CORINFO_HELP_LMUL, ) -HELPER(READYTORUN_HELPER_LMulOfv, CORINFO_HELP_LMUL_OVF, ) -HELPER(READYTORUN_HELPER_ULMulOvf, CORINFO_HELP_ULMUL_OVF, ) -HELPER(READYTORUN_HELPER_LDiv, CORINFO_HELP_LDIV, ) -HELPER(READYTORUN_HELPER_LMod, CORINFO_HELP_LMOD, ) -HELPER(READYTORUN_HELPER_ULDiv, CORINFO_HELP_ULDIV, ) -HELPER(READYTORUN_HELPER_ULMod, CORINFO_HELP_ULMOD, ) -HELPER(READYTORUN_HELPER_LLsh, CORINFO_HELP_LLSH, ) -HELPER(READYTORUN_HELPER_LRsh, CORINFO_HELP_LRSH, ) -HELPER(READYTORUN_HELPER_LRsz, CORINFO_HELP_LRSZ, ) -HELPER(READYTORUN_HELPER_Lng2Dbl, CORINFO_HELP_LNG2DBL, ) -HELPER(READYTORUN_HELPER_ULng2Dbl, CORINFO_HELP_ULNG2DBL, ) - -HELPER(READYTORUN_HELPER_Div, CORINFO_HELP_DIV, ) -HELPER(READYTORUN_HELPER_Mod, CORINFO_HELP_MOD, ) -HELPER(READYTORUN_HELPER_UDiv, CORINFO_HELP_UDIV, ) -HELPER(READYTORUN_HELPER_UMod, CORINFO_HELP_UMOD, ) - -HELPER(READYTORUN_HELPER_Dbl2Int, CORINFO_HELP_DBL2INT, ) -HELPER(READYTORUN_HELPER_Dbl2IntOvf, CORINFO_HELP_DBL2INT_OVF, ) -HELPER(READYTORUN_HELPER_Dbl2Lng, CORINFO_HELP_DBL2LNG, ) -HELPER(READYTORUN_HELPER_Dbl2LngOvf, CORINFO_HELP_DBL2LNG_OVF, ) -HELPER(READYTORUN_HELPER_Dbl2UInt, CORINFO_HELP_DBL2UINT, ) -HELPER(READYTORUN_HELPER_Dbl2UIntOvf, CORINFO_HELP_DBL2UINT_OVF, ) -HELPER(READYTORUN_HELPER_Dbl2ULng, CORINFO_HELP_DBL2ULNG, ) -HELPER(READYTORUN_HELPER_Dbl2ULngOvf, CORINFO_HELP_DBL2ULNG_OVF, ) - -HELPER(READYTORUN_HELPER_DblRem, CORINFO_HELP_FLTREM, ) -HELPER(READYTORUN_HELPER_FltRem, CORINFO_HELP_DBLREM, ) -HELPER(READYTORUN_HELPER_DblRound, CORINFO_HELP_FLTROUND, ) -HELPER(READYTORUN_HELPER_FltRound, CORINFO_HELP_DBLROUND, ) - -#ifndef _TARGET_X86_ -HELPER(READYTORUN_HELPER_PersonalityRoutine, CORINFO_HELP_EE_PERSONALITY_ROUTINE, OPTIMIZEFORSIZE) -HELPER(READYTORUN_HELPER_PersonalityRoutineFilterFunclet, CORINFO_HELP_EE_PERSONALITY_ROUTINE_FILTER_FUNCLET, OPTIMIZEFORSIZE) -#endif - -#ifdef _TARGET_X86_ -HELPER(READYTORUN_HELPER_WriteBarrier_EAX, CORINFO_HELP_ASSIGN_REF_EAX, ) -HELPER(READYTORUN_HELPER_WriteBarrier_EBX, CORINFO_HELP_ASSIGN_REF_EBX, ) -HELPER(READYTORUN_HELPER_WriteBarrier_ECX, CORINFO_HELP_ASSIGN_REF_ECX, ) -HELPER(READYTORUN_HELPER_WriteBarrier_ESI, CORINFO_HELP_ASSIGN_REF_ESI, ) -HELPER(READYTORUN_HELPER_WriteBarrier_EDI, CORINFO_HELP_ASSIGN_REF_EDI, ) -HELPER(READYTORUN_HELPER_WriteBarrier_EBP, CORINFO_HELP_ASSIGN_REF_EBP, ) -HELPER(READYTORUN_HELPER_CheckedWriteBarrier_EAX, CORINFO_HELP_CHECKED_ASSIGN_REF_EAX, ) -HELPER(READYTORUN_HELPER_CheckedWriteBarrier_EBX, CORINFO_HELP_CHECKED_ASSIGN_REF_EBX, ) -HELPER(READYTORUN_HELPER_CheckedWriteBarrier_ECX, CORINFO_HELP_CHECKED_ASSIGN_REF_ECX, ) -HELPER(READYTORUN_HELPER_CheckedWriteBarrier_ESI, CORINFO_HELP_CHECKED_ASSIGN_REF_ESI, ) -HELPER(READYTORUN_HELPER_CheckedWriteBarrier_EDI, CORINFO_HELP_CHECKED_ASSIGN_REF_EDI, ) -HELPER(READYTORUN_HELPER_CheckedWriteBarrier_EBP, CORINFO_HELP_CHECKED_ASSIGN_REF_EBP, ) - -HELPER(READYTORUN_HELPER_EndCatch, CORINFO_HELP_ENDCATCH, OPTIMIZEFORSIZE) -#endif - -#undef HELPER -#undef OPTIMIZEFORSPEED diff --git a/src/inc/regex_base.h b/src/inc/regex_base.h deleted file mode 100644 index 28097b2e2..000000000 --- a/src/inc/regex_base.h +++ /dev/null @@ -1,973 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -// -// Provides basic interpreted regular expression matching. This is meant as a debugging tool, -// and if regular expressions become necessary in a non-debug scenario great care should be -// used to ensure that performance is not impaired, and a more thorough review of this could -// would also be a good thing. This file does not include any concrete instantiations but -// instead provides the basic building blocks. Some concrete instantiations can be found in -// regex_util.h. -// -// NOTE: See code:clr::regex::RegExBase (below) for description of supported regex language. -// -// NOTE: we had to forego standard options such as tr1::regex -// (http://en.wikipedia.org/wiki/Technical_Report_1#Regular_Expressions) and Microsoft's -// internal GRETA regular expressions (http://toolbox/sites/987/default.aspx) because they -// both rely heavily on the STL, which can not currently be used within the CLR. -// -// NOTE: If this becomes non-debug-only, then read the comment on WCHARItemTraits for what -// what needs fixing. -// - -// - -#ifndef _REGEX_BASE_H_ -#define _REGEX_BASE_H_ - -// Forward declare namespace so that it is not debug-only (even if currently there is nothing -// but debug-only code in the namespace). This enables a "using namespace clr;" line in a -// header file without having to worry about whether or not it's in a debug-only block. -namespace clr {} - -#ifdef _DEBUG - -#include "utilcode.h" // for string hash functions -#include "sstring.h" - -namespace clr { -namespace regex { - -// Implementation details. Code contained in any "imp" namespace should never be directly used -// by clients of RegEx. -namespace imp { - - //=================================================================================================== - // Helper for clr::regex::RegExBase. See class definition for clr::regex::RegExBase below for more - // information. - - template - class RegExBaseHelper : protected ITEM_TRAITS - { - public: - typedef typename ITEM_TRAITS::RegexIterator RegexIterator; - typedef typename ITEM_TRAITS::InputIterator InputIterator; - - typedef typename ITEM_TRAITS::MatchFlags MatchFlags; - static const MatchFlags DefaultMatchFlags = ITEM_TRAITS::DefaultMatchFlags; - - // Arguments: - // regex : marks the start of the regular expression string. - // regexEnd : marks the end of the regular expression string. - // input : marks the start of the input string against which regex will be matched. - // inputEnd : marks the end of the input string. - // groups : recipient of regular expression groups. - // - // Returns true if the regular expression was successfully matched against the input string; - // otherwise false. - - RegExBaseHelper(const RegexIterator& regex, - const RegexIterator& regexEnd, - const InputIterator& input, - const InputIterator& inputEnd, - GROUP_CONTAINER& groups, - const MatchFlags flags = DefaultMatchFlags); - - // The main entrypoint to RegExBaseHelper, Match will attempt to match the regular expression - // defined by [regex,regexEnd) against the input defined by [input,inputEnd). - bool Match() - { WRAPPER_NO_CONTRACT; return DoMatch(m_regex, m_input); } - - protected: - typedef typename ITEM_TRAITS::Item Item; - typedef typename ITEM_TRAITS::ItemType ItemType; - - // Try to match regex at any point within input, starting with the first character and moving - // along one at a time until a match is found or the end of the input is encountered, whichever - // comes first. - bool DoMatch( - const RegexIterator& regex, - InputIterator input); - - // Try to match regex starting exactly at input. - bool DoMatchHere( - const RegexIterator& regex, - const InputIterator& input); - - // The function returns true if a match is found consisting of zero or more items c followed by a - // successful match of regex on the remaining input; otherwise false is returned. This is a - // conservative match, so it starts with trying to match zero items followed by regex, - // and will then try to match one item followed by regex. - bool DoMatchStar( - const Item& c, - const RegexIterator& regex, - InputIterator input); - - // The function returns true if a match is found consisting of zero or more items c followed by a - // successful match of regex on the remaining input; otherwise false is returned. This is a - // greedy match, so it starts with trying to match as many items as it can followed by regex, - // and on failure will try again with one less items matched. - bool DoMatchStarEagerly( - const Item& c, - const RegexIterator& regex, - InputIterator input); - - // Convenience method. - Item GetItem( - const RegexIterator ®ex) - { WRAPPER_NO_CONTRACT; return ITEM_TRAITS::GetItem(regex, m_regexEnd, m_flags); } - - // Convenience method. - bool MatchItem( - const Item& c, - const InputIterator& input) - { WRAPPER_NO_CONTRACT; return ITEM_TRAITS::MatchItem(c, input, m_inputEnd, m_flags); } - - // Declared as protected to prevent direct instantiation. - RegExBaseHelper() - {} - - RegexIterator m_regex; - RegexIterator m_regexEnd; - InputIterator m_input; - InputIterator m_inputEnd; - GROUP_CONTAINER& m_groups; - MatchFlags m_flags; - }; - - //--------------------------------------------------------------------------------------------------- - // This method simply stores the end iterators for the regular expression and the input strings, as - // well as the group collection object and flags, and forwards the call to DoMatch. - - template - RegExBaseHelper::RegExBaseHelper( - const RegexIterator& regex, - const RegexIterator& regexEnd, - const InputIterator& input, - const InputIterator& inputEnd, - GROUP_CONTAINER& groups, - const MatchFlags flags) - : m_regex(regex), - m_regexEnd(regexEnd), - m_input(input), - m_inputEnd(inputEnd), - m_groups(groups), - m_flags(flags) - { WRAPPER_NO_CONTRACT; } - - //--------------------------------------------------------------------------------------------------- - // This method checks if the regular expression starts with a caret, indicating that any match must - // be anchored at the start of the input string. If such a caret exists, one match attempt is made - // on the input starting with the first character and the result is returned. If the regex does not - // start with a caret, the method attempts to match against the input string, starting at the first - // character and moving one character over for each successive attempt, until a match is found or - // the end of the input is encountered, whichever comes first. - - template - inline bool - RegExBaseHelper::DoMatch( - const RegexIterator& regex, - InputIterator input) - { - WRAPPER_NO_CONTRACT; - - if (GetItem(regex).GetType() == ITEM_TRAITS::CARET) - { // Match must occur from the beginning of the line - m_groups.OpenGroup(input, m_inputEnd); - bool res = DoMatchHere(regex+1, input); - if (!res) - m_groups.CancelGroup(); - return res; - } - else - { // Match can happen anywhere in the string - do - { // Attempt to match against each substring [x,inputEnd) for x = 0...inputEnd - - // Begin the group that contains the entire match. - m_groups.OpenGroup(input, m_inputEnd); - - if (DoMatchHere(regex, input)) - { // Success. Note that the entire match group is closed elsewhere on a - // successful match. - return true; - } - - // On failure, cancel the group so that it can be reopened on the new substring - m_groups.CancelGroup(); - } while (input++ != m_inputEnd); - } - - // No successful match found. - return false; - } - - //------------------------------------------------------------------------------------------------------- - // This is the main loop, which handles grouping constructs, repetition directives (*, *?, +, +?), and - // EOL matches ($), delegating all character matching to ITEM_TRAITS::MatchItem - // The general algorithm is: - // 1. Get the next item. - // 2. If the item is a DOLLAR type, check to see if we're at the end of the retular expression and - // the input string, and if so return success. - // 3. If the item is a grouping construct, open or close the appropriate group and continue matching. - // On failure, roll back the grouping change so that subsequent attemts will have correct state. - // 4. Check to see if the item following the current is a repetition directive, and if so take the - // appropriate action. - // 5. Otherwise defer to ITEM_TRAITS::MatchItem and if successful continue to match the remaining - // regular expression and input string; otherwise return failure. - - template - inline bool - RegExBaseHelper::DoMatchHere( - const RegexIterator& regex, - const InputIterator& input) - { - WRAPPER_NO_CONTRACT; - - if (regex == m_regexEnd) - { // Reached the end of the regular expression without ever returning false, - // implying a successful match. Close the overall match group and return. - m_groups.CloseGroup(input); - return true; - } - - Item c0 = GetItem(regex); - if (c0.GetType() == ITEM_TRAITS::DOLLAR && (c0.GetNext() == m_regexEnd)) - { // Matches EOL if a '$' is encountered at the end of the input. - m_groups.CloseGroup(input); - // Success only if we're actually at the end of the input string. - return input == m_inputEnd; - } - if (c0.GetType() == ITEM_TRAITS::PAREN_OPEN) - { // Encountered an open parenthesis ('('); open a new grouping. - m_groups.OpenGroup(input, m_inputEnd); - bool res = DoMatchHere(c0.GetNext(), input); - if (!res) - { // If a match fails, there could be further attempts (such as if - // there is an active repetition matching frame beneath us), so - // need to cancel the group we just opened so that the grouping - // structure remains consistent. - m_groups.CancelGroup(); - } - return res; - } - if (c0.GetType() == ITEM_TRAITS::PAREN_CLOSE) - { // Close the most recent open grouping. - COUNT_T i = m_groups.CloseGroup(input); - bool res = DoMatchHere(c0.GetNext(), input); - if (!res) - { // For the same reasons as the need to cancel an opened group - // explained above, we need to reopen the closed group if a - // match fails. - m_groups.ReopenGroup(i, m_inputEnd); - } - return res; - } - - if (c0.GetNext() != m_regexEnd) - { // If there is another item in the regex string following the current one, get - // it to see if it is a repetition matching directive. - Item c1 = GetItem(c0.GetNext()); - if (c1.GetType() == ITEM_TRAITS::STAR) - { // '*' matching directive encountered - if (c1.GetNext() != m_regexEnd) - { - Item c2 = GetItem(c1.GetNext()); - if (c2.GetType() == ITEM_TRAITS::QUESTION_MARK) - { // conservative matching semantics requested - return DoMatchStar(c0, c2.GetNext(), input); - } - } - // Eager matching - return DoMatchStarEagerly(c0, c1.GetNext(), input); - } - if (c1.GetType() == ITEM_TRAITS::PLUS) - { // '+' matching directive encountered. - if (c1.GetNext() != m_regexEnd) - { - Item c2 = GetItem(c1.GetNext()); - if (c2.GetType() == ITEM_TRAITS::QUESTION_MARK) - { // conservative matching semantics requested - return MatchItem(c0, input) && DoMatchStar(c0, c2.GetNext(), input+1); - } - } - // Eager matching - return MatchItem(c0, input) && DoMatchStarEagerly(c0, c1.GetNext(), input+1); - } - if (c1.GetType() == ITEM_TRAITS::QUESTION_MARK) - { // '?' matching directive encountered - return (MatchItem(c0, input) && DoMatchHere(c1.GetNext(), input+1)) || DoMatchHere(c1.GetNext(), input); - } - } - - // No special matching semantics encountered, delegate the matching to ITEM_TRAITS::MatchItem - return MatchItem(c0, input) && DoMatchHere(c0.GetNext(), input+1); - } - - //------------------------------------------------------------------------------------------------------- - // Conservative '*' repetition matching. This attempts to match zero items c followed by a match of - // regex. If this fails, attempt to match one item c followed by a match of regex. Repeat until item c - // does not match or a successful match is found. - - template - inline bool - RegExBaseHelper::DoMatchStar( - const Item& c, - const RegexIterator& regex, - InputIterator input) - { - WRAPPER_NO_CONTRACT; - CONSISTENCY_CHECK(input != m_inputEnd); - - do { - if (DoMatchHere(regex, input)) - { // A successful match is found! - return true; - } - // No successful match, so try to match one more item and then attempt to match regex on the - // remaining input. - } while (input != m_inputEnd && MatchItem(c, input++)); - return false; - } - - //------------------------------------------------------------------------------------------------------- - // Similar to DoMatchStar above, except this algorithm matches as many items c as possible first followed - // by regex on the remaining input, and on failure tries again with a match against one less item c - // followed by regex on the remaining input, and repeats until there are no items c remaining to match - // and the zero item match followed by a match of regex on the entire remaining input fails. If any of - // the match attempts succeed, return success. - - template - inline bool - RegExBaseHelper::DoMatchStarEagerly( - const Item& c, - const RegexIterator& regex, - InputIterator input) - { - WRAPPER_NO_CONTRACT; - - // Make sure we keep a hold of how far back we can unwind. - InputIterator inputOrig = input; - - // First, determine the maximum number of matches against item c. - while (input != m_inputEnd && MatchItem(c, input)) - { - ++input; - } - - do - { // Work backwards from the maximum number of matches of item c until a match is found - // or until we have backed right up to the starting value of input (saved in inputOrig), - // at which time we admit failure. - if (DoMatchHere(regex, input)) - return true; - } while (inputOrig != input--); - return false; - } - -} // namespace imp - -//======================================================================================================= -// Represents a matched group using iterators to denote the string contained by [Begin(),End()). - -template -class Group -{ -public: - typedef INPUT_ITERATOR InputIterator; - - // - // Functions for accessing group properties - // - - // Returns the iterator indicating the start of the group - const InputIterator& Begin() const - { LIMITED_METHOD_CONTRACT; return m_begin; } - - // Returns the iterator indicating the first non-member of the group - const InputIterator& End() const - { LIMITED_METHOD_CONTRACT; return m_end; } - - // It is possible that m_end - m_begin could be greater than the maximum of COUNT_T. m_end and - // m_begin are the end and start of a string, so is entirely unlikely to overflow a COUNT_T. - // Conbined with the fact that this is debug-only code, opting not to replace all COUNT_T - // uses with SIZE_T. - COUNT_T Length() const - { WRAPPER_NO_CONTRACT; return static_cast(m_end - m_begin); } - - // - // Functions used by RegExBaseHelper to create grouping constructs. - // - - Group() - : m_isClosed(false), m_begin(), m_end() - { WRAPPER_NO_CONTRACT; } - - Group(const InputIterator& start, const InputIterator& end, bool isClosed = false) - : m_isClosed(isClosed), m_begin(start), m_end(end) - { WRAPPER_NO_CONTRACT; } - - void SetBegin(const InputIterator& start) - { WRAPPER_NO_CONTRACT; m_begin = start; } - - void SetEnd(const InputIterator& end) - { WRAPPER_NO_CONTRACT; m_end = end; } - - bool IsClosed() const - { LIMITED_METHOD_CONTRACT; return m_isClosed; } - - void SetIsClosed(bool isClosed) - { WRAPPER_NO_CONTRACT; m_isClosed = isClosed; } - -protected: - bool m_isClosed; - InputIterator m_begin; - InputIterator m_end; -}; - -//======================================================================================================= -// Represents a generic container of groups, defaulting to using Group as its element -// type. This container satisfies the method requrements of RegExBase. When a match is successful, the -// match groups may be accessed using the index operator or the iterators definin the matched groups -// [Begin(), End()). - -template > -class GroupContainer -{ -public: - typedef typename SArray::Iterator Iterator; - - // - // Functions for enumerating groups - // - - GROUP_TYPE & operator[](COUNT_T idx) - { - WRAPPER_NO_CONTRACT; - CONSISTENCY_CHECK(((COUNT_T)(COUNT_T)idx) == idx); - return m_array[idx]; - } - - // Returns an iterator to the first matched group (which is always the string for the - // entire successfully matched string. Specific groups start at Begin()+1 and continue - // to End()-1. - Iterator Begin() - { WRAPPER_NO_CONTRACT; return m_array.Begin(); } - - // Returns the first invalid iterator value. - Iterator End() - { WRAPPER_NO_CONTRACT; return m_array.End(); } - - // - COUNT_T Count() const - { WRAPPER_NO_CONTRACT; return m_array.GetCount(); } - - // - // Functions used by RegExBaseHelper to create grouping constructs. - // - - // Note: OpenGroup takes an end iterator so that the group will have a valid (if possibly - // incorrect) endpoint in the case that the regular expression has unbalanced grouping - // parentheses. - void OpenGroup(const INPUT_ITERATOR& start, const INPUT_ITERATOR& end) - { WRAPPER_NO_CONTRACT; m_array.Append(GROUP_TYPE(start, end, false)); } - - COUNT_T CloseGroup(const INPUT_ITERATOR& end); - - void ReopenGroup(COUNT_T i, const INPUT_ITERATOR& end); - - void CancelGroup() - { WRAPPER_NO_CONTRACT; m_array.Delete(m_array.End() - 1); } - -private: - SArray m_array; -}; - -//------------------------------------------------------------------------------------------------------- -// Works backwards from the most recently created group looking for an open group to close. Returns -// the index of the group that was closed, which is used in the event that a group needs to be -// reopened. - -template -COUNT_T -GroupContainer::CloseGroup( - const INPUT_ITERATOR& end) -{ - WRAPPER_NO_CONTRACT; - - for (COUNT_T i = (COUNT_T)Count(); i > 0; --i) - { - if (!m_array[i-1].IsClosed()) - { - m_array[i-1].SetEnd(end); - m_array[i-1].SetIsClosed(true); - return i-1; - } - } - - _ASSERTE(!"Unmatched grouping constructs!"); - return 0; -} - -//------------------------------------------------------------------------------------------------------- -// Reopen a group at the given index, using 'end' to overwrite the current end. - -template -void -GroupContainer::ReopenGroup( - COUNT_T i, - const INPUT_ITERATOR& end) -{ - WRAPPER_NO_CONTRACT; - CONSISTENCY_CHECK(i > 0 && i < Count()); - - if (i > 0 && i < Count()) - { - m_array[i].SetEnd(end); - m_array[i].SetIsClosed(false); - } -} - -//======================================================================================================= -// Empty group container that satisfies the method requirements of RegExBase but has empty bodies. This -// allows for non-allocating matches when grouping is not required. - -template -class NullGroupContainer -{ -public: - void OpenGroup(INPUT_ITERATOR, INPUT_ITERATOR) {} - COUNT_T CloseGroup(INPUT_ITERATOR) { return 0; } - void ReopenGroup(COUNT_T, INPUT_ITERATOR) {} - void CancelGroup() {} -}; - -//======================================================================================================= -// This mini-implementation of regular expression matching supports the -// following constructs: -// ^ matches the beginning of the input string -// $ matches the end of the input string -// * matches zero or more occurrences of the previous item eagerly -// *? matches zero or more occurrences of the previous item conservatively -// + matches 1 or more occurrences of the previous item eagerly -// +? matches 1 or more occurrences of the previous item conservatively -// ? matches 0 or 1 occurences of the previous item -// ( starts a grouping -// ) ends a grouping -// -// IMPORTANT: These are just anchoring and grouping constructs. See the definition for ItemTraitsBase -// below for information on the default character classes that are supported. (The intent of -// this separation is to allow customization of the character classes where required.) - -// ITEM_TRAITS provides traits for individual tokens in a regular expression, as well as a mechanism for -// matching said individual components with the target string. RegexBase derives from ITEM_TRAITS in a -// protected fashion, and is responsible for providing the following: -// 1. "RegexIterator" typedef -// Used as an iterator into the regular expression, and used as arguments to indicate the start -// and the end of the regular expression string. -// 2. "InputIterator" typedef -// Used as an iterator into the input string, and used as arguments to indicate the start -// and the end of the input string. -// (NOTE: RegexIterator and InputIterator are often typedef'ed to be the same thing.) -// 3. "Item" typedef. -// This will be used with methods GetItem and MatchItem (see below). Item must -// define the the following methods: -// ItemType GetType() : returns the type of the item. See below for explanation of ItemType -// const RegexIterator& GetNext() : iterator pointing to the start of the next item. -// 4. "MatchFlags" typedef, and "static const DefaultMatchFlags" value. -// Provided for calls to "Match" and "Matches", and passed on to calls "GetItem" and "MatchItem". -// 5. enum ItemType -// Defines the following minimum values: -// DOT -// CARET -// DOLLAR -// STAR -// QUESTION_MARK -// PLUS -// PAREN_OPEN -// PAREN_CLOSE -// ItemType may include more values, and may even choose to ignore the above enum types, all of -// which must be recognized by GetItem and MatchItem (see below). -// 6. static Item GetItem(const RegexIterator& regex, -// const RegexIterator& regexEnd, -// const MatchFlags& flags) -// This method takes a regular expression iterator and returns the next regular expression -// element (Item) pointed to by the iterator. -// 7. static bool MatchItem(const Item& c, -// const InputIterator& input, -// const InputIterator& inputEnd, -// const MatchFlags &flags) - -// GROUP_CONTAINER provides functionality for keeping track of regular expression groups. This is a generic -// argument to Match, and the type of the object must support the following methods: -// 1. void OpenGroup(const InputIterator& start, const InputIterator& end); -// Called when a PAREN_OPEN item is encountered. -// 2. COUNT_T CloseGroup(const InputIterator& end); -// Called when a PAREN_CLOSE item is encountered. Returns the index of the group that was closed. -// 3. void ReopenGroup(COUNT_T i, const InputIterator& end); -// Called when a match following a call to CloseGroup fails, essentially requesting a rollback -// of the call to CloseGroup. -// 4. void CancelGroup(); -// Called when a match following a call to OpenGroup fails, essentially requesting a rollback -// of the call to OpenGroup. - -template -class RegExBase : public ITEM_TRAITS -{ -public: - typedef typename ITEM_TRAITS::RegexIterator RegexIterator; - typedef typename ITEM_TRAITS::InputIterator InputIterator; - - // This is a convenience typedef that allows a caller to easily declare a grouping container - // to be passed to a call to Match. An example would be (see regex_util.h for a definition of - // SStringRegEx): - // - // SString input(SL"Simmons"); - // SStringRegEx::GroupingContainer container; - // if (SStringRegEx::Match(SL"(Sim+on)", input, container)) { - // printf("%S", container[1].GetSString(input).GetUnicode()); - // } - // - typedef GroupContainer > GroupingContainer; - - // Pulls down the typedef for MatchFlags and initialized a static representing the default flags. - typedef typename ITEM_TRAITS::MatchFlags MatchFlags; - static const MatchFlags DefaultMatchFlags = ITEM_TRAITS::DefaultMatchFlags; - - template - static bool Match(RegexIterator regex, - RegexIterator regexEnd, - InputIterator input, - InputIterator inputEnd, - GROUP_CONTAINER& groups, - MatchFlags flags = DefaultMatchFlags) - { - imp::RegExBaseHelper - re(regex, regexEnd, input, inputEnd, groups, flags); - return re.Match(); - } - - static bool Matches(RegexIterator regex, - RegexIterator regexEnd, - InputIterator input, - InputIterator inputEnd, - MatchFlags flags = DefaultMatchFlags) - { - NullGroupContainer ngc; - return Match(regex, regexEnd, input, inputEnd, ngc, flags); - } -}; - -//======================================================================================================= -// In addition to requirements specified on RegExBase, StandardItemTraits provides the following -// additinal regular expression item types. -// c matches any literal character c -// . matches any single character -// \d any literal digit character -// \w any alpha character -// \s any whitespace character -// -// Child types of ItemTraitsBase must implement GetItem and MatchItem (see below for full -// signature requirements). Current child type implementations permit a backslash ('\') to escape -// special characters ('.', '$', '*', etc.) and allow them to be interpreted as literal characters. -// -// This type describes a particular behaviour, but must be subtyped for the particular target character -// needed, and GetItem and MatchItem must be implemented. -// - -template -class ItemTraitsBase -{ -public: - typedef ITERATOR_TYPE RegexIterator; - typedef ITERATOR_TYPE InputIterator; - - enum MatchFlags - { - MF_NONE = 0x00, - MF_CASE_INSENSITIVE = 0x01 // Match character literals as case insensitive. - }; - - static const MatchFlags DefaultMatchFlags = MF_NONE; - -protected: - ItemTraitsBase() - {} - - enum ItemType - { - // REQUIRED, as described in RegExBase - CARET, - DOLLAR, - STAR, - QUESTION_MARK, - PLUS, - PAREN_OPEN, - PAREN_CLOSE, - // ADDITIONAL - DOT, // any literal character - DIGIT, // any digit - ALPHA, // any alpha character, upper or lower case - WHITESPACE, // any whitespace character - NON_WHITESPACE, // any non-whitespace character - CHARACTER, // a specific literal character - }; - - class Item - { - public: - Item(ItemType type, CHAR_TYPE val, const RegexIterator& next) - : m_type(type), m_val(val), m_next(next) - { WRAPPER_NO_CONTRACT; } - - Item(ItemType type, const RegexIterator& next) - : m_type(type), m_val(0), m_next(next) - { WRAPPER_NO_CONTRACT; } - - ItemType GetType() const - { LIMITED_METHOD_CONTRACT; return m_type; } - - const RegexIterator& GetNext() const - { LIMITED_METHOD_CONTRACT; return m_next; } - - CHAR_TYPE GetValue() const - { LIMITED_METHOD_CONTRACT; return m_val; } - - protected: - ItemType m_type; - CHAR_TYPE m_val; - RegexIterator m_next; - }; - - // All deriving types must add the following methods: - // static Item GetItem(const RegexIterator& regex, const RegexIterator& regexEnd); - // static bool MatchItem(const Item& c, const InputIterator& input, const InputIterator& inputEnd); -}; - -//======================================================================================================= -// Implements ItemTraitsBase, provides matching for UNICODE characters. -// -// !!!IMPORTANT!!! -// This is not a complete unicode implementation - only the equivalent of ASCII alpha characters are -// consider to be part of the alpha set, and this is also the only set on which case insensitive -// operations will correctly work. If RegEx is moved out of DEBUG ONLY, then this will have to be fixed -// to properly address these issues. -// !!!IMPORTANT!!! - -template -class WCHARItemTraits : public ItemTraitsBase -{ -public: - typedef ItemTraitsBase PARENT_TYPE; - typedef typename PARENT_TYPE::RegexIterator RegexIterator; - typedef typename PARENT_TYPE::InputIterator InputIterator; - typedef typename PARENT_TYPE::Item Item; - typedef typename PARENT_TYPE::MatchFlags MatchFlags; - - static Item GetItem(const RegexIterator& regex, const RegexIterator& regexEnd, MatchFlags flags); - static bool MatchItem(const Item& c, const InputIterator& input, const InputIterator& inputEnd, MatchFlags flags); - -protected: - WCHARItemTraits() - {} - -private: - static inline bool IS_UPPER_A_TO_Z(WCHAR x) - { WRAPPER_NO_CONTRACT; return (((x) >= W('A')) && ((x) <= W('Z'))); } - - static inline bool IS_LOWER_A_TO_Z(WCHAR x) - { WRAPPER_NO_CONTRACT; return (((x) >= W('a')) && ((x) <= W('z'))); } - - static inline WCHAR UPCASE(WCHAR x) - { WRAPPER_NO_CONTRACT; return (IS_LOWER_A_TO_Z(x) ? ((x) - W('a') + W('A')) : (x)); } - - static inline WCHAR DOWNCASE(WCHAR x) - { WRAPPER_NO_CONTRACT; return (IS_UPPER_A_TO_Z(x) ? ((x) - W('A') + W('a')) : (x)); } - - static bool MatchCharacter(WCHAR c1, WCHAR c2, MatchFlags flags) - { WRAPPER_NO_CONTRACT; return (flags & PARENT_TYPE::MF_CASE_INSENSITIVE) ? (DOWNCASE(c1) == DOWNCASE(c2)) : (c1 == c2); } -}; - -//------------------------------------------------------------------------------------------------------- -// Reads the next item from regex, recognizing special characters outlined in ItemTraitsBase. - -template -typename WCHARItemTraits::Item -WCHARItemTraits::GetItem( - const RegexIterator& regex, - const RegexIterator& regexEnd, - MatchFlags flags) -{ - WRAPPER_NO_CONTRACT; - - if (*regex == W('\\')) - { - const RegexIterator regexNext = regex+1; - if (regexNext == regexEnd) - return Item(PARENT_TYPE::CHARACTER, W('\\'), regexNext); - if (*regexNext == W('d')) - return Item(PARENT_TYPE::DIGIT, regexNext+1); - if (*regexNext == W('w')) - return Item(PARENT_TYPE::ALPHA, regexNext+1); - if (*regexNext == W('s')) - return Item(PARENT_TYPE::WHITESPACE, regexNext+1); - if (*regexNext == W('S')) - return Item(PARENT_TYPE::NON_WHITESPACE, regexNext+1); - return Item(PARENT_TYPE::CHARACTER, *regexNext, regexNext+1); - } - else if (*regex == W('.')) - return Item(PARENT_TYPE::DOT, W('.'), regex+1); - else if (*regex == W('^')) - return Item(PARENT_TYPE::CARET, W('^'), regex+1); - else if (*regex == W('$')) - return Item(PARENT_TYPE::DOLLAR, W('$'), regex+1); - else if (*regex == W('*')) - return Item(PARENT_TYPE::STAR, W('*'), regex+1); - else if (*regex == W('?')) - return Item(PARENT_TYPE::QUESTION_MARK, W('?'), regex+1); - else if (*regex == W('+')) - return Item(PARENT_TYPE::PLUS, W('+'), regex+1); - else if (*regex == W('(')) - return Item(PARENT_TYPE::PAREN_OPEN, W('('), regex+1); - else if (*regex == W(')')) - return Item(PARENT_TYPE::PAREN_CLOSE, W(')'), regex+1); - else - return Item(PARENT_TYPE::CHARACTER, *regex, regex + 1); -} - -//------------------------------------------------------------------------------------------------------- -// Returns true if the next character point to by input matches the character class described by c. - -template -bool -WCHARItemTraits::MatchItem( - const Item& c, - const InputIterator& input, - const InputIterator& inputEnd, - MatchFlags flags) -{ - WRAPPER_NO_CONTRACT; - - if (c.GetType() == PARENT_TYPE::DIGIT) - return *input >= W('0') && *input <= W('9'); - else if (c.GetType() == PARENT_TYPE::ALPHA) - return (*input >= W('a') && *input <= W('z')) || (*input >= W('A') && *input <= W('Z')); - else if (c.GetType() == PARENT_TYPE::WHITESPACE) - return *input == W(' ') || *input == W('\t'); - else if (c.GetType() == PARENT_TYPE::NON_WHITESPACE) - return !(*input == W(' ') || *input == W('\t')); - else - return c.GetType() == PARENT_TYPE::DOT || MatchCharacter(c.GetValue(), *input, flags); -} - -//======================================================================================================= -// Implements ItemTraitsBase, provides matching for ASCII (*not* UTF8) characters. - -template -class CHARItemTraits : public ItemTraitsBase -{ -public: - typedef ItemTraitsBase PARENT_TYPE; - typedef typename PARENT_TYPE::RegexIterator RegexIterator; - typedef typename PARENT_TYPE::InputIterator InputIterator; - typedef typename PARENT_TYPE::Item Item; - typedef typename PARENT_TYPE::MatchFlags MatchFlags; - - static Item GetItem(const RegexIterator& regex, const RegexIterator& regexEnd, MatchFlags flags); - static bool MatchItem(const Item& c, const InputIterator& input, const InputIterator& inputEnd, MatchFlags flags); - -protected: - CHARItemTraits() - {} - -private: - static inline bool IS_UPPER_A_TO_Z(CHAR x) - { WRAPPER_NO_CONTRACT; return (((x) >= 'A') && ((x) <= 'Z')); } - - static inline bool IS_LOWER_A_TO_Z(CHAR x) - { WRAPPER_NO_CONTRACT; return (((x) >= 'a') && ((x) <= 'z')); } - - static inline CHAR UPCASE(CHAR x) - { WRAPPER_NO_CONTRACT; return (IS_LOWER_A_TO_Z(x) ? ((x) - 'a' + 'A') : (x)); } - - static inline CHAR DOWNCASE(CHAR x) - { WRAPPER_NO_CONTRACT; return (IS_UPPER_A_TO_Z(x) ? ((x) - 'A' + 'a') : (x)); } - - static bool MatchCharacter(CHAR c1, CHAR c2, MatchFlags flags) - { WRAPPER_NO_CONTRACT; return (flags & PARENT_TYPE::MF_CASE_INSENSITIVE) ? (DOWNCASE(c1) == DOWNCASE(c2)) : (c1 == c2); } -}; - -//------------------------------------------------------------------------------------------------------- -// Reads the next item from regex, recognizing special characters outlined in ItemTraitsBase. - -template -typename CHARItemTraits::Item -CHARItemTraits::GetItem( - const RegexIterator& regex, - const RegexIterator& regexEnd, - MatchFlags flags) -{ - WRAPPER_NO_CONTRACT; - - if (*regex == '\\') - { - const RegexIterator regexNext = regex+1; - if (regexNext == regexEnd) - return Item(PARENT_TYPE::CHARACTER, W('\\'), regexNext); - if (*regexNext == 'd') - return Item(PARENT_TYPE::DIGIT, regexNext+1); - if (*regexNext == 'w') - return Item(PARENT_TYPE::ALPHA, regexNext+1); - if (*regexNext == 's') - return Item(PARENT_TYPE::WHITESPACE, regexNext+1); - return Item(PARENT_TYPE::CHARACTER, *regexNext, regexNext+1); - } - else if (*regex == '.') - return Item(PARENT_TYPE::DOT, '.', regex+1); - else if (*regex == '^') - return Item(PARENT_TYPE::CARET, '^', regex+1); - else if (*regex == '$') - return Item(PARENT_TYPE::DOLLAR, '$', regex+1); - else if (*regex == '*') - return Item(PARENT_TYPE::STAR, '*', regex+1); - else if (*regex == '?') - return Item(PARENT_TYPE::QUESTION_MARK, '?', regex+1); - else if (*regex == '+') - return Item(PARENT_TYPE::PLUS, '+', regex+1); - else if (*regex == '(') - return Item(PARENT_TYPE::PAREN_OPEN, '(', regex+1); - else if (*regex == ')') - return Item(PARENT_TYPE::PAREN_CLOSE, ')', regex+1); - else - return Item(PARENT_TYPE::CHARACTER, *regex, regex + 1); -} - -//------------------------------------------------------------------------------------------------------- -// Returns true if the next character point to by input matches the character class described by c. - -template -bool -CHARItemTraits::MatchItem( - const Item& c, - const InputIterator& input, - const InputIterator& inputEnd, - MatchFlags flags) -{ - WRAPPER_NO_CONTRACT; - - if (c.GetType() == PARENT_TYPE::DIGIT) - return *input >= W('0') && *input <= W('9'); - else if (c.GetType() == PARENT_TYPE::ALPHA) - return (*input >= W('a') && *input <= W('z')) || (*input >= W('A') && *input <= W('Z')); - else if (c.GetType() == PARENT_TYPE::WHITESPACE) - return *input == W(' ') || *input == W('\t'); - else - return c.GetType() == PARENT_TYPE::DOT || MatchCharacter(c.GetValue(), *input, flags); -} - -} /* namespace regex */ -} /* namespace clr */ - -#endif // _DEBUG - -#endif // _REGEX_BASE_H_ diff --git a/src/inc/regex_util.h b/src/inc/regex_util.h deleted file mode 100644 index 438c8b133..000000000 --- a/src/inc/regex_util.h +++ /dev/null @@ -1,209 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -// See regex_base.h for more information. -// -// This header creates some concrete instantiations of RegExBase for commonly used scenarios. In -// particular, basic regular expression matching base on the regular expression language described in -// clr::regex::ItemTraitsBase (found in regex_base.h) is instantiated for use with SString, ASCII and -// UNICODE strings (clr::regex::SStringRegex, clr::regex::WSTRRegEx, and clr::regex::STRRegEx -// respectively). Each type definition includes an example of its use. -// - -// - -#ifndef _REGEX_UTIL_H_ -#define _REGEX_UTIL_H_ - -#ifndef MODE_ANY -#define MODE_ANY -#endif - -#include "regex_base.h" - -#ifdef _DEBUG - -namespace clr -{ -namespace regex -{ - -//======================================================================================================= -// Derives from Group to provide two additional convenience methods (GetSString variants). - -class SStringGroup : public Group -{ -public: - SStringGroup() - : Group() - { WRAPPER_NO_CONTRACT; } - - SStringGroup(const InputIterator& _start, const InputIterator& _end, bool _isClosed = false) - : Group(_start, _end, _isClosed) - { WRAPPER_NO_CONTRACT; } - - // Since SStrings constructed from ranges require the original source string, this is a required - // input argument. Returns the input substring that matches the corresponding grouping. - SString GetSString(const SString& src) - { WRAPPER_NO_CONTRACT; return SString(src, Begin(), End()); } - - // Since SStrings constructed from ranges require the original source string, this is a required - // input argument. This version takes a target SString as a buffer, and also returns this buffer - // as a reference. Returns the input substring that matches the corresponding grouping. - SString& GetSString(const SString& src, SString& tgt) - { WRAPPER_NO_CONTRACT; tgt.Set(src, Begin(), End()); return tgt; } -}; - -//======================================================================================================= -typedef WCHARItemTraits SStringItemTraits; - -//======================================================================================================= -// Regular expression matching with SStrings. -// -// Here is an example of how to use SStringRegEx with grouping enabled. -// -// using namespace clr::regex; -// SString input(SL"Simmons"); // usually this is derived from some variable source -// SStringRegEx::GroupingContainer container; -// if (SStringRegEx::Match(SL"(Sim+on)", input, container)) { -// printf("%S", container[1].GetSString(input).GetUnicode()); -// } -// -// This sample should result in "Simmon" being printed. - - -class SStringRegEx : public RegExBase -{ - typedef RegExBase PARENT_TYPE; - -public: - using PARENT_TYPE::Match; - using PARENT_TYPE::Matches; - - typedef PARENT_TYPE::InputIterator InputIterator; - - typedef GroupContainer GroupingContainer; - - static bool Match( - const SString& regex, - const SString& input, - GroupingContainer& groups, - MatchFlags flags = DefaultMatchFlags) - { - WRAPPER_NO_CONTRACT; - return Match(regex.Begin(), regex.End(), input.Begin(), input.End(), groups, flags); - } - - static bool Matches( - const SString& regex, - const SString& input, - MatchFlags flags = DefaultMatchFlags) - { - WRAPPER_NO_CONTRACT; - return Matches(regex.Begin(), regex.End(), input.Begin(), input.End(), flags); - } - -}; - -//======================================================================================================= -// Regular expression matching with UNICODE strings. -// -// Here is an example of how to use WSTRRegEx to match against a null-terminated string without grouping. -// -// using namespace clr::regex; -// LPCWSTR input = L"Simmons"; -// if (WSTRRegEx::Matches(L"Sim+on", input)) -// printf("Match succeeded"); -// else -// printf("Match failed"); -// -// This sample should result in "Match succeeded" being printed. - -class WSTRRegEx : public RegExBase > -{ - typedef RegExBase > PARENT_TYPE; - -public: - using PARENT_TYPE::Match; - using PARENT_TYPE::Matches; - - static bool Match( - LPCWSTR regex, - LPCWSTR input, - GroupingContainer& groups, - MatchFlags flags = DefaultMatchFlags) - { - WRAPPER_NO_CONTRACT; - return Match(regex, regex + wcslen(regex), input, input + wcslen(input), groups, flags); - } - - static bool Matches( - LPCWSTR regex, - LPCWSTR input, - MatchFlags flags = DefaultMatchFlags) - { - CONTRACTL { - NOTHROW; - GC_NOTRIGGER; - MODE_ANY; - } CONTRACTL_END; - - return Matches(regex, regex + wcslen(regex), input, input + wcslen(input), flags); - } -}; - -//======================================================================================================= -// Regular expression matching with ASCII strings. -// -// Here is an example of how to use STRRegEx to match against a substring based on begin and end range -// pointers, with grouping disabled and case insensitivity enabled. -// -// using namespace clr::regex; -// LPCSTR input = "123Simmons456"; -// if (STRRegEx::Matches("Sim+on", input+3, input+10, STRRegEx::MF_CASE_INSENSITIVE)) -// printf("Match succeeded"); -// else -// printf("Match failed"); -// -// This sample should result in "Match succeeded" being printed. - -class STRRegEx : public RegExBase > -{ - typedef RegExBase > PARENT_TYPE; - -public: - using PARENT_TYPE::Match; - using PARENT_TYPE::Matches; - - static bool Match( - LPCSTR regex, - LPCSTR input, - GroupingContainer& groups, - MatchFlags flags = DefaultMatchFlags) - { - WRAPPER_NO_CONTRACT; - return Match(regex, regex + strlen(regex), input, input + strlen(input), groups, flags); - } - - static bool Matches( - LPCSTR regex, - LPCSTR input, - MatchFlags flags = DefaultMatchFlags) - { - CONTRACTL { - NOTHROW; - GC_NOTRIGGER; - MODE_ANY; - } CONTRACTL_END; - - return Matches(regex, regex + strlen(regex), input, input + strlen(input), flags); - } -}; - -} // namespace regex -} // namespace clr - -#endif // _DEBUG - -#endif // _REGEX_UTIL_H_ diff --git a/src/inc/registrywrapper.h b/src/inc/registrywrapper.h deleted file mode 100644 index 6b284506b..000000000 --- a/src/inc/registrywrapper.h +++ /dev/null @@ -1,20 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -//***************************************************************************** -// File: registrywrapper.h -// -// Wrapper around Win32 Registry Functions allowing redirection of .Net -// Framework root registry location -// -//***************************************************************************** -#ifndef __REGISTRYWRAPPER_H -#define __REGISTRYWRAPPER_H - - -#define ClrRegCreateKeyEx RegCreateKeyExW -#define ClrRegOpenKeyEx RegOpenKeyExW -#define IsNgenOffline() false - - -#endif // __REGISTRYWRAPPER_H diff --git a/src/inc/releaseholder.h b/src/inc/releaseholder.h deleted file mode 100644 index b2c42e392..000000000 --- a/src/inc/releaseholder.h +++ /dev/null @@ -1,77 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -// This class acts a smart pointer which calls the Release method on any object -// you place in it when the ReleaseHolder class falls out of scope. You may use it -// just like you would a standard pointer to a COM object (including if (foo), -// if (!foo), if (foo == 0), etc) except for two caveats: -// 1. This class never calls AddRef and it always calls Release when it -// goes out of scope. -// 2. You should never use & to try to get a pointer to a pointer unless -// you call Release first, or you will leak whatever this object contains -// prior to updating its internal pointer. -template -class ReleaseHolder -{ -public: - ReleaseHolder() - : m_ptr(NULL) - {} - - ReleaseHolder(T* ptr) - : m_ptr(ptr) - {} - - ~ReleaseHolder() - { - Release(); - } - - void operator=(T *ptr) - { - Release(); - - m_ptr = ptr; - } - - T* operator->() - { - return m_ptr; - } - - operator T*() - { - return m_ptr; - } - - T** operator&() - { - return &m_ptr; - } - - T* GetPtr() const - { - return m_ptr; - } - - T* Detach() - { - T* pT = m_ptr; - m_ptr = NULL; - return pT; - } - - void Release() - { - if (m_ptr != NULL) - { - m_ptr->Release(); - m_ptr = NULL; - } - } - -private: - T* m_ptr; -}; - diff --git a/src/inc/safewrap.h b/src/inc/safewrap.h deleted file mode 100644 index f489999f6..000000000 --- a/src/inc/safewrap.h +++ /dev/null @@ -1,171 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -//***************************************************************************** -// SafeWrap.h -// - -// -// This file contains wrapper functions for Win32 API's that take SStrings -// and use CLR-safe holders. -//***************************************************************************** - - -/* - Guidelines for SafeWrapper APIs: -Most of these are 'common-sense', plus a few arbitrary decisions thrown in for -consistency's sake. - -- THROWING: Throw on oom, but return all other failure codes. - The rationale here is that SString operations already throw, so to make these APIs - non-throwing would require an extra EX_TRY/EX_CATCH. Most callees will want to throw - on OOM anyways. So making these APIs non-throwing would mean an extra try/catch in - the caller + an extra check at the callee. We can eliminate that overhead and just make - it throwing. - - Return non-oom failure codes because callees actually freqeuntly expect an API to fail. - For example, the callee will have special handling for file-not-found. - - For convenience, you could add a no-throwing wrapper version of the API: - ClrGetEnvironmentVariable <-- default throws on oom. - ClrGetEnvironmentVariableNoThrow <-- never throws. - -- NAMING: Prefix the name with 'Clr', just like we do for win32 APIs going through hosting. - -- DON'T FORGET CONTRACTS: Most of these APIs will likely be Throws/GC_Notrigger. - Also use PRECONDITIONs + POSTCONDITIONS when possible. - -- SIGNATURES: Keep the method signture as close the the original win32 API as possible. - - Preserve the return type + value. (except allow it to throw on oom). If the return value - should be a holder, then use that as an out-parameter at the end of the argument list. - We don't want to return holders because that will cause the dtors to be called. - - For input strings use 'const SString &' instead of 'LPCWSTR'. - - Change ('out' string, length) pairs to 'SString &' (this is the convention the rest of the CLR uses for SStrings) - - Use Holders where appropriate. - - Preserve other parameters. - -- USE SSTRINGS TO AVOID BUFFER OVERRUN ISSUES: Repeated here for emphasis. Use SStrings when - applicable to make it very easy to verify the code does not have buffer overruns. - This will also simplify callsites from having to figure out the length of the output string. - -- USE YOUR BEST JUDGEMENT: The primary goal of these API wrappers is to embrace 'security-safe' practices. - Certainly take any additional steps to that goal. For example, it may make sense to eliminate - corner case inputs for a given API or to break a single confusing API up into several discrete and - move obvious APIs. - -*/ -#ifndef _safewrap_h_ -#define _safewrap_h_ - -#include "holder.h" - -class SString; -bool ClrGetEnvironmentVariable(LPCSTR szEnvVarName, SString & value); -bool ClrGetEnvironmentVariableNoThrow(LPCSTR szEnvVarName, SString & value); -void ClrGetModuleFileName(HMODULE hModule, SString & value); -bool ClrGetModuleFileNameNoThrow(HMODULE hModule, SString & value); - -void ClrGetCurrentDirectory(SString & value); -bool ClrGetCurrentDirectoryNoThrow(SString & value); - - -/* --------------------------------------------------------------------------- * - * Simple wrapper around WszFindFirstFile/WszFindNextFile - * --------------------------------------------------------------------------- */ -class ClrDirectoryEnumerator -{ - WIN32_FIND_DATAW data; - FindHandleHolder dirHandle; - BOOL fFindNext; // Skip FindNextFile first time around - -public: - ClrDirectoryEnumerator(LPCWSTR pBaseDirectory, LPCWSTR pMask = W("*")); - bool Next(); - - LPCWSTR GetFileName() - { - return data.cFileName; - } - - DWORD GetFileAttributes() - { - return data.dwFileAttributes; - } - - void Close() - { - dirHandle.Clear(); - } -}; - -// Read a REG_SZ (null-terminated string) value from the registry. Throws. -void ClrRegReadString(HKEY hKey, const SString & szValueName, SString & value); - -/* --------------------------------------------------------------------------- * - * Simple wrapper around RegisterEventSource/ReportEvent/DeregisterEventSource - * --------------------------------------------------------------------------- */ -// Returns ERROR_SUCCESS if succeessful in reporting to event log, or -// Windows error code to indicate the specific error. -DWORD ClrReportEvent( - LPCWSTR pEventSource, - WORD wType, - WORD wCategory, - DWORD dwEventID, - PSID lpUserSid, - WORD wNumStrings, - LPCWSTR *lpStrings, - DWORD dwDataSize = 0, - LPVOID lpRawData = NULL); - -DWORD ClrReportEvent( - LPCWSTR pEventSource, - WORD wType, - WORD wCategory, - DWORD dwEventID, - PSID lpUserSid, - LPCWSTR pMessage); - -//***************************************************************************** -// This provides a wrapper around GetFileSize() that forces it to fail -// if the file is >4g and pdwHigh is NULL. Other than that, it acts like -// the genuine GetFileSize(). -// -// -//***************************************************************************** -DWORD inline SafeGetFileSize(HANDLE hFile, DWORD *pdwHigh) -{ - if (pdwHigh != NULL) - { - return ::GetFileSize(hFile, pdwHigh); - } - else - { - DWORD hi; - DWORD lo = ::GetFileSize(hFile, &hi); - if (lo == 0xffffffff && GetLastError() != NO_ERROR) - { - return lo; - } - // api succeeded. is the file too large? - if (hi != 0) - { - // there isn't really a good error to set here... - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - return 0xffffffff; - } - - if (lo == 0xffffffff) - { - // note that a success return of (hi=0,lo=0xffffffff) will be - // treated as an error by the caller. Again, that's part of the - // price of being a slacker and not handling the high dword. - // We'll set a lasterror for him to pick up. - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - } - - return lo; - } - -} - -#endif // _safewrap_h_ diff --git a/src/inc/sarray.h b/src/inc/sarray.h deleted file mode 100644 index ac361cf40..000000000 --- a/src/inc/sarray.h +++ /dev/null @@ -1,229 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -// -------------------------------------------------------------------------------- -// SArray.h -// -------------------------------------------------------------------------------- - - -#ifndef _SARRAY_H_ -#define _SARRAY_H_ - -#include "sbuffer.h" - -// -------------------------------------------------------------------------------- -// SArray is a typed array wrapper around an SBuffer. It manages individual -// constructors and destructors of array elements if avaiable, as well as providing -// typed access. -// -------------------------------------------------------------------------------- - -template -class SArray -{ - private: - - SBuffer m_buffer; - - static COUNT_T VerifySizeRange(ELEMENT * begin, ELEMENT * end); - - public: - - class Iterator; - friend class Iterator; - - SArray(); - SArray(COUNT_T count); - SArray(ELEMENT * begin, ELEMENT * end); - ~SArray(); - - void Clear(); - void Set(const SArray &array); - - COUNT_T GetCount() const; - BOOL IsEmpty() const; - - void SetCount(COUNT_T count); - - COUNT_T GetAllocation() const; - - void Preallocate(int count) const; - void Trim() const; - - void Copy(const Iterator &to, const Iterator &from, COUNT_T size); - void Move(const Iterator &to, const Iterator &from, COUNT_T size); - - void Copy(const Iterator &i, const ELEMENT *source, COUNT_T size); - void Copy(void *dest, const Iterator &i, COUNT_T size); - - Iterator Append() - { - WRAPPER_NO_CONTRACT; - - COUNT_T count = GetCount(); - if ( GetAllocation() == count ) - Preallocate( 2 * count ); - - Iterator i = End(); - Insert(i); - return i; - } - - void Append(ELEMENT elem) - { - WRAPPER_NO_CONTRACT; - *Append() = elem; - } - - ELEMENT AppendEx(ELEMENT elem) - { - WRAPPER_NO_CONTRACT; - - *Append() = elem; - return elem; - } - - void Insert(const Iterator &i); - void Delete(const Iterator &i); - - void Insert(const Iterator &i, COUNT_T count); - void Delete(const Iterator &i, COUNT_T count); - - void Replace(const Iterator &i, COUNT_T deleteCount, COUNT_T insertCount); - - ELEMENT *OpenRawBuffer(COUNT_T maxElementCount); - ELEMENT *OpenRawBuffer(); - void CloseRawBuffer(COUNT_T actualElementCount); - void CloseRawBuffer(); - - Iterator Begin() - { - WRAPPER_NO_CONTRACT; - return Iterator(this, 0); - } - - Iterator End() - { - WRAPPER_NO_CONTRACT; - return Iterator(this, GetCount()); - } - - Iterator operator+(COUNT_T index) - { - return Iterator(this, index); - } - - ELEMENT & operator[] (int index); - const ELEMENT & operator[] (int index) const; - - ELEMENT & operator[] (COUNT_T index); - const ELEMENT & operator[] (COUNT_T index) const; - - protected: - SArray(void *prealloc, COUNT_T size); - - public: - - class Iterator : public CheckedIteratorBase >, - public Indexer - { - friend class SArray; - friend class Indexer; - - SBuffer::Iterator m_i; - - public: - - Iterator(SArray *array, SCOUNT_T index) - : CheckedIteratorBase >(array) - { - WRAPPER_NO_CONTRACT; - m_i = array->m_buffer.Begin() + index*sizeof(ELEMENT); - } - - protected: - - ELEMENT &GetAt(SCOUNT_T delta) const - { - LIMITED_METHOD_CONTRACT; - return * (ELEMENT *) &m_i[delta*sizeof(ELEMENT)]; - } - - void Skip(SCOUNT_T delta) - { - LIMITED_METHOD_CONTRACT; - m_i += delta*sizeof(ELEMENT); - } - - COUNT_T Subtract(const Iterator &i) const - { - LIMITED_METHOD_CONTRACT; - return (m_i - i.m_i)/sizeof(ELEMENT); - } - - CHECK DoCheck(SCOUNT_T delta) const - { - WRAPPER_NO_CONTRACT; - return m_i.CheckIndex(delta*sizeof(ELEMENT)); - } - - public: - - CHECK Check() const - { - WRAPPER_NO_CONTRACT; - return m_i.Check(); - } - }; - - ELEMENT *GetElements() const; - - private: - - //-------------------------------------------------------------------- - // Routines for managing the buffer content. - //-------------------------------------------------------------------- - - void ConstructBuffer(const Iterator &i, COUNT_T size); - void CopyConstructBuffer(const Iterator &i, COUNT_T size, const ELEMENT *from); - void DestructBuffer(const Iterator &i, COUNT_T size); -}; - -// ================================================================================ -// InlineSArray : Tempate for an SArray with preallocated element space -// ================================================================================ - -template -class InlineSArray : public SArray -{ - private: -#ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable:4200) // zero sized array -#pragma warning(disable:4324) // don't complain if DECLSPEC_ALIGN actually pads - DECLSPEC_ALIGN(BUFFER_ALIGNMENT) BYTE m_prealloc[SIZE*sizeof(ELEMENT)]; -#pragma warning(pop) -#else - // use UINT64 to get maximum alignment of the memory - UINT64 m_prealloc[ALIGN(SIZE*sizeof(ELEMENT),sizeof(UINT64))/sizeof(UINT64)]; -#endif // _MSC_VER - - public: - InlineSArray(); -}; - -// ================================================================================ -// StackSArray : SArray with relatively large preallocated buffer for stack use -// ================================================================================ - -template -class StackSArray : public InlineSArray -{ -}; - -// ================================================================================ -// Inline definitions -// ================================================================================ - -#include "sarray.inl" - -#endif // _SARRAY_H_ diff --git a/src/inc/sarray.inl b/src/inc/sarray.inl deleted file mode 100644 index d7e396c9b..000000000 --- a/src/inc/sarray.inl +++ /dev/null @@ -1,377 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -// -------------------------------------------------------------------------------- -// SArray.inl -// -------------------------------------------------------------------------------- - -#ifndef _SARRAY_INL_ -#define _SARRAY_INL_ - -#include "sarray.h" - -template -inline SArray::SArray() - : m_buffer() -{ - LIMITED_METHOD_CONTRACT; -} - -template -inline SArray::SArray(COUNT_T count) - : m_buffer(count * sizeof(ELEMENT)) -{ - WRAPPER_NO_CONTRACT; - ConstructBuffer(Begin(), count); -} - -template -inline COUNT_T SArray::VerifySizeRange(ELEMENT * begin, ELEMENT *end) -{ - WRAPPER_NO_CONTRACT; - - if (end < begin) - ThrowHR(COR_E_OVERFLOW); - - SIZE_T bufferSize = (end - begin) * sizeof(ELEMENT); - if (!FitsIn(bufferSize)) - ThrowHR(COR_E_OVERFLOW); - - return static_cast(bufferSize); -} - -template -inline SArray::SArray(ELEMENT * begin, ELEMENT * end) - : m_buffer(VerifySizeRange(begin, end)) -{ - WRAPPER_NO_CONTRACT; - - CopyConstructBuffer(Begin(), static_cast(end - begin), begin); -} - -template -inline SArray::SArray(void *prealloc, COUNT_T count) - : m_buffer(SBuffer::Prealloc, prealloc, count*sizeof(ELEMENT)) -{ - LIMITED_METHOD_CONTRACT; -} - -template -SArray::~SArray() -{ - CONTRACTL - { - NOTHROW; - SO_TOLERANT; - GC_NOTRIGGER; - } - CONTRACTL_END; - - // Cannot call Clear because DestructBuffer has THROWS in its contract - if (!BITWISE_COPY) - { - COUNT_T elementCount = GetCount(); - for (COUNT_T i = 0; i < elementCount; i++) - { - (&((*this)[i]))->~ELEMENT(); - } - } -} - -template -inline void SArray::Clear() -{ - WRAPPER_NO_CONTRACT; - DestructBuffer(Begin(), GetCount()); - m_buffer.Clear(); -} - -template -inline ELEMENT* SArray::OpenRawBuffer(COUNT_T elementCount) -{ - WRAPPER_NO_CONTRACT; - return (ELEMENT*)m_buffer.OpenRawBuffer(elementCount * sizeof(ELEMENT)); -} - -template -inline ELEMENT* SArray::OpenRawBuffer() -{ - WRAPPER_NO_CONTRACT; - return (ELEMENT*)m_buffer.OpenRawBuffer(GetCount() * sizeof(ELEMENT)); -} - -template -inline void SArray::CloseRawBuffer(COUNT_T finalElementCount) -{ - WRAPPER_NO_CONTRACT; - m_buffer.CloseRawBuffer(finalElementCount * sizeof(ELEMENT)); -} - -template -inline void SArray::CloseRawBuffer() -{ - WRAPPER_NO_CONTRACT; - m_buffer.CloseRawBuffer(); -} - -template -inline void SArray::Set(const SArray &array) -{ - WRAPPER_NO_CONTRACT; - if (BITWISE_COPY) - { - m_buffer.Set(array.m_buffer); - } - else - { - DestructBuffer(Begin(), GetCount()); - m_buffer.SetSize(0); - m_buffer.SetSize(array.m_buffer.GetSize()); - CopyConstructBuffer(Begin(), GetCount(), array.GetElements()); - } -} - -template -inline COUNT_T SArray::GetCount() const -{ - WRAPPER_NO_CONTRACT; - return m_buffer.GetSize()/sizeof(ELEMENT); -} - -template -inline BOOL SArray::IsEmpty() const -{ - WRAPPER_NO_CONTRACT; - return GetCount() == 0; -} - -template -inline void SArray::SetCount(COUNT_T count) -{ - WRAPPER_NO_CONTRACT; - COUNT_T oldCount = GetCount(); - if (count > oldCount) - ConstructBuffer(Begin() + oldCount, count - oldCount); - - m_buffer.SetSize(count*sizeof(ELEMENT)); - - if (oldCount > count) - DestructBuffer(Begin() + count, oldCount - count); -} - -template -inline COUNT_T SArray::GetAllocation() const -{ - WRAPPER_NO_CONTRACT; - return m_buffer.GetAllocation() / sizeof(ELEMENT); -} - -template -inline void SArray::Preallocate(int count) const -{ - WRAPPER_NO_CONTRACT; - m_buffer.Preallocate(count * sizeof(ELEMENT)); -} - -template -inline void SArray::Trim() const -{ - WRAPPER_NO_CONTRACT; - m_buffer.Trim(); -} - -template -inline void SArray::Copy(const Iterator &to, const Iterator &from, COUNT_T size) -{ - WRAPPER_NO_CONTRACT; - // @todo: destruction/construction semantics are broken on overlapping copies - - DestructBuffer(to, size); - - CopyConstructBuffer(to, size, from); -} - -template -inline void SArray::Move(const Iterator &to, const Iterator &from, COUNT_T size) -{ - // @todo: destruction/construction semantics are broken on overlapping moves - - DestructBuffer(to, size); - - m_buffer.Move(to, from, size*sizeof(ELEMENT)); - - ConstructBuffer(from, size); -} - -template -inline void SArray::Copy(const Iterator &i, const ELEMENT *source, COUNT_T size) -{ - WRAPPER_NO_CONTRACT; - DestructBuffer(i, size); - - CopyConstructBuffer(i, size, source); -} - -template -inline void SArray::Copy(void *dest, const Iterator &i, COUNT_T size) -{ - WRAPPER_NO_CONTRACT; - // @todo: destruction/construction semantics are unclear - - m_buffer.Copy(dest, i.m_i, size*sizeof(ELEMENT)); -} - -template -inline void SArray::Insert(const Iterator &i) -{ - WRAPPER_NO_CONTRACT; - Replace(i, 0, 1); -} - -template -inline void SArray::Delete(const Iterator &i) -{ - WRAPPER_NO_CONTRACT; - Replace(i, 1, 0); -} - -template -inline void SArray::Insert(const Iterator &i, COUNT_T count) -{ - WRAPPER_NO_CONTRACT; - Replace(i, 0, count); -} - -template -inline void SArray::Delete(const Iterator &i, COUNT_T count) -{ - Delete(i, 0, count); -} - -template -inline void SArray:: Replace(const Iterator &i, COUNT_T deleteCount, COUNT_T insertCount) -{ - WRAPPER_NO_CONTRACT; - DestructBuffer(i, deleteCount); - - m_buffer.Replace(i.m_i, deleteCount*sizeof(ELEMENT), insertCount*sizeof(ELEMENT)); - - ConstructBuffer(i, insertCount); -} - -template -inline ELEMENT &SArray::operator[](int index) -{ - WRAPPER_NO_CONTRACT; - return *(GetElements() + index); -} - -template -inline const ELEMENT &SArray::operator[](int index) const -{ - WRAPPER_NO_CONTRACT; - return *(GetElements() + index); -} - -template -inline ELEMENT &SArray::operator[](COUNT_T index) -{ - WRAPPER_NO_CONTRACT; - return *(GetElements() + index); -} - -template -inline const ELEMENT &SArray::operator[](COUNT_T index) const -{ - return *(GetElements() + index); -} - -template -inline ELEMENT *SArray::GetElements() const -{ - LIMITED_METHOD_CONTRACT; - return (ELEMENT *) (const BYTE *) m_buffer; -} - -template -inline void SArray::ConstructBuffer(const Iterator &i, COUNT_T size) -{ - CONTRACTL - { - THROWS; - GC_NOTRIGGER; - } - CONTRACTL_END; - - if (!BITWISE_COPY) - { - ELEMENT *start = GetElements() + (i - Begin()); - ELEMENT *end = start + size; - - while (start < end) - { - new (start) ELEMENT(); - start++; - } - } -} - -template -inline void SArray::CopyConstructBuffer(const Iterator &i, COUNT_T size, const ELEMENT *from) -{ - ptrdiff_t start_offset = i - Begin(); - ELEMENT *p = (ELEMENT *) m_buffer.OpenRawBuffer(m_buffer.GetSize()) + start_offset; - - if (BITWISE_COPY) - { - memmove(p, from, size * sizeof(ELEMENT)); - } - else - { - ELEMENT *start = (ELEMENT *) p; - ELEMENT *end = (ELEMENT *) (p + size); - - while (start < end) - { - new (start) ELEMENT(*from); - - start++; - from++; - } - } - - m_buffer.CloseRawBuffer(); -} - -template -inline void SArray::DestructBuffer(const Iterator &i, COUNT_T size) -{ - CONTRACTL - { - THROWS; - GC_NOTRIGGER; - } - CONTRACTL_END; - - if (!BITWISE_COPY) - { - ELEMENT *start = GetElements() + (i - Begin()); - ELEMENT *end = start + size; - - while (start < end) - { - start->ELEMENT::~ELEMENT(); - - start++; - } - } -} - -template -inline InlineSArray::InlineSArray() - : SArray((void*)m_prealloc, SIZE) -{ - LIMITED_METHOD_CONTRACT; -} - -#endif // _SARRAY_INL_ diff --git a/src/inc/sbuffer.h b/src/inc/sbuffer.h deleted file mode 100644 index e56322ac8..000000000 --- a/src/inc/sbuffer.h +++ /dev/null @@ -1,575 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -// -------------------------------------------------------------------------------- -// SBuffer.h (Safe Buffer) -// - -// -------------------------------------------------------------------------------- - -// -------------------------------------------------------------------------------- -// SBuffer is a relatively safe way to manipulate a dynamically -// allocated data buffer. An SBuffer is conceptually a simple array -// of bytes. It maintains both a conceptual size and an actual allocated size. -// -// SBuffer provides safe access to the data buffer by providing rich high -// level functionality (like insertion, deleteion, copying, comparison, and -// iteration) without exposing direct pointers to its buffers. -// -// For interoperability, SBuffers can expose their buffers - either as readonly -// by BYTE * or void * cases, or as writable by the OpenRawBuffer/CloseRawBuffer -// entry points. Use of these should be limited wherever possible though; as there -// is always a possibilility of buffer overrun. -// -// To mimimize heap allocations, the InlineSBuffer template will preallocate a fixed -// size buffer inline with the SBuffer object itself. It will use this buffer unless -// it needs a bigger one, in which case it transparently moves on to using the heap. -// The StackSBuffer class instatiates the InlineSBuffer with a standard heuristic -// stack preallocation size. -// -// SBuffer is "subclassable" to add content typeing to the buffer. See SArray and -// SString for examples. -// -------------------------------------------------------------------------------- - - -#ifndef _SBUFFER_H_ -#define _SBUFFER_H_ - -#include "clrtypes.h" -#include "iterator.h" -#include "check.h" -#include "daccess.h" -#include "memoryrange.h" - -// ================================================================================ -// Macros for computing padding -// ================================================================================ - -#define ALIGNMENT(size) \ - (( (size^(size-1)) >> 1) +1) - -#define ALIGN(size, align) \ - (((size)+((align)-1)) & ~((align)-1)) - -#define PAD(size, align) \ - (ALIGN((size), (align)) - (size)) - -// ================================================================================ -// SBuffer : base class for safe buffers -// ================================================================================ - -typedef DPTR(class SBuffer) PTR_SBuffer; - -class SBuffer -{ - public: - //-------------------------------------------------------------------- - // Flags and constants - //-------------------------------------------------------------------- - - enum ImmutableFlag - { - Immutable - }; - - enum PreallocFlag - { - Prealloc - }; - - //-------------------------------------------------------------------- - // Types - //-------------------------------------------------------------------- - - public: - class CIterator; - friend class CIterator; - - class Iterator; - friend class Iterator; - - //-------------------------------------------------------------------- - // Initializers and constructors - //-------------------------------------------------------------------- - - public: - // Constructors - SBuffer(); - SBuffer(COUNT_T size); - SBuffer(const BYTE *buffer, COUNT_T size); - explicit SBuffer(const SBuffer &buffer); - - // Immutable constructor should ONLY be used if buffer will - // NEVER BE FREED OR MODIFIED. PERIOD. . - SBuffer(ImmutableFlag immutable, const BYTE *buffer, COUNT_T size); - - // Prealloc should be allocated inline with SBuffer - it must have the same - // lifetime as SBuffer's memory. - SBuffer(PreallocFlag prealloc, void *buffer, COUNT_T size); - - ~SBuffer(); - - void Clear(); - - void Set(const SBuffer &buffer); - void Set(const BYTE *buffer, COUNT_T size); - void SetImmutable(const BYTE *buffer, COUNT_T size); - - //-------------------------------------------------------------------- - // Buffer size routines. A buffer has an externally visible size, but - // it also has an internal allocation size which may be larger. - //-------------------------------------------------------------------- - - // Get and set size of buffer. Note that the actual size of the - // internally allocated memory block may be bigger. - COUNT_T GetSize() const; - void SetSize(COUNT_T count); - - // Grow size of buffer to maximum amount without reallocating. - void MaximizeSize(); - - //-------------------------------------------------------------------- - // Buffer allocation routines - //-------------------------------------------------------------------- - - // Return the current available allocation space of the buffer. - COUNT_T GetAllocation() const; - - // Preallocate some memory you expect to use. This can prevent - // multiple reallocations. Note this does not change the visible - // size of the buffer. - void Preallocate(COUNT_T allocation) const; - - // Shrink memory usage of buffer to minimal amount. Note that - // this does not change the visible size of the buffer. - void Trim() const; - - //-------------------------------------------------------------------- - // Content manipulation routines - //-------------------------------------------------------------------- - - void Zero(); - void Fill(BYTE value); - void Fill(const Iterator &to, BYTE value, COUNT_T size); - - // Internal copy. "Copy" leaves from range as is; "Move" - // leaves from range in uninitialized state. - // (This distinction is more important when using from a - // typed wrapper than in the base SBuffer class.) - // - // NOTE: Copy vs Move is NOT based on whether ranges overlap - // or not. Ranges may overlap in either case. - // - // Note that both Iterators must be on THIS buffer. - void Copy(const Iterator &to, const CIterator &from, COUNT_T size); - void Move(const Iterator &to, const CIterator &from, COUNT_T size); - - // External copy. - void Copy(const Iterator &i, const SBuffer &source); - void Copy(const Iterator &i, const void *source, COUNT_T size); - void Copy(void *dest, const CIterator &i, COUNT_T size); - - // Insert bytes at the given iterator location. - void Insert(const Iterator &i, const SBuffer &source); - void Insert(const Iterator &i, COUNT_T size); - - // Delete bytes at the given iterator location - void Delete(const Iterator &i, COUNT_T size); - - // Replace bytes at the given iterator location - void Replace(const Iterator &i, COUNT_T deleteSize, const SBuffer &insert); - void Replace(const Iterator &i, COUNT_T deleteSize, COUNT_T insertSize); - - // Compare entire buffer; return -1, 0, 1 - int Compare(const SBuffer &compare) const; - int Compare(const BYTE *match, COUNT_T size) const; - - // Compare entire buffer; return TRUE or FALSE - BOOL Equals(const SBuffer &compare) const; - BOOL Equals(const BYTE *match, COUNT_T size) const; - - // Match portion of this buffer to given bytes; return TRUE or FALSE - BOOL Match(const CIterator &i, const SBuffer &match) const; - BOOL Match(const CIterator &i, const BYTE *match, COUNT_T size) const; - - //-------------------------------------------------------------------- - // Iterators - // - // Note that any iterator returned is not - // valid after any operation which may resize the buffer, unless - // the operation was performed on that particular iterator. - //-------------------------------------------------------------------- - - CIterator Begin() const; - CIterator End() const; - - Iterator Begin(); - Iterator End(); - - BYTE & operator[] (int index); - const BYTE & operator[] (int index) const; - - //-------------------------------------------------------------------- - // Raw buffer access - // - // Accessing a raw buffer via pointer is inherently more dangerous than - // other uses of this API, and should be avoided if at all possible. - // It is primarily provided for compatibility with existing APIs. - // - // Note that any buffer pointer returned is not - // valid after any operation which may resize the buffer. - //-------------------------------------------------------------------- - - // Casting operators return the existing buffer as - // a raw const pointer. Note that the pointer is valid only - // until the buffer is modified via an API. - operator const void *() const; - operator const BYTE *() const; - - // To write directly to the SString's underlying buffer: - // 1) Call OpenRawBuffer() and pass it the count of bytes - // you need. - // 2) That returns a pointer to the raw buffer which you can write to. - // 3) When you are done writing to the pointer, call CloseBuffer() - // and pass it the count of bytes you actually wrote. - // The pointer from step 1 is now invalid. - - // example usage: - // void GetInfo(SBuffer &buf) - // { - // BYTE *p = buf.OpenRawBuffer(3); - // OSGetSomeInfo(p, 3); - // buf.CloseRawBuffer(); - // } - - // You should open the buffer, write the data, and immediately close it. - // No sbuffer operations are valid while the buffer is opened. - // - // In a debug build, Open/Close will do lots of little checks to make sure - // you don't buffer overflow while it's opened. In a retail build, this - // is a very streamlined action. - - // Open the raw buffer for writing count bytes - BYTE *OpenRawBuffer(COUNT_T maxCount); - - // Call after OpenRawBuffer(). - - // Provide the count of bytes actually used. This will make sure the - // SBuffer's size is correct. - void CloseRawBuffer(COUNT_T actualCount); - - // Close the buffer. Assumes that we completely filled the buffer - // that OpenRawBuffer() gave back. - void CloseRawBuffer(); - - //-------------------------------------------------------------------- - // Check routines. These are typically used internally, but may be - // called externally if desired. - //-------------------------------------------------------------------- - - CHECK CheckBufferClosed() const; - static CHECK CheckSize(COUNT_T size); - static CHECK CheckAllocation(COUNT_T allocation); - CHECK CheckIteratorRange(const CIterator &i) const; - CHECK CheckIteratorRange(const CIterator &i, COUNT_T size) const; - - CHECK Check() const; - CHECK Invariant() const; - CHECK InternalInvariant() const; - - protected: - - //-------------------------------------------------------------------- - // Internal helper routines - //-------------------------------------------------------------------- - - // Preserve = preserve contents while reallocating - typedef enum - { - DONT_PRESERVE = 0, - PRESERVE = 1, - } Preserve; - - void Resize(COUNT_T size, Preserve preserve = PRESERVE); - void ResizePadded(COUNT_T size, Preserve preserve = PRESERVE); - void TweakSize(COUNT_T size); - void ReallocateBuffer(COUNT_T allocation, Preserve preserve); - void EnsureMutable() const; - - //-------------------------------------------------------------------- - // We define some extra flags and fields for subclasses (these are specifically - // designed for SString, but use otherwise if desired.) - //-------------------------------------------------------------------- - - BOOL IsFlag1() const; - void SetFlag1(); - void ClearFlag1(); - - BOOL IsFlag2() const; - void SetFlag2(); - void ClearFlag2(); - - BOOL IsFlag3() const; - void SetFlag3(); - void ClearFlag3(); - - INT GetRepresentationField() const; - void SetRepresentationField(int value); - - protected: - - //-------------------------------------------------------------------- - // Flag access - //-------------------------------------------------------------------- - - BOOL IsAllocated() const; - void SetAllocated(); - void ClearAllocated(); - - BOOL IsImmutable() const; - void SetImmutable(); - void ClearImmutable(); - -#if _DEBUG - BOOL IsOpened() const; - void SetOpened(); - void ClearOpened(); -#endif - - //-------------------------------------------------------------------- - // Buffer management routines - //-------------------------------------------------------------------- - - // Allocate and free a memory buffer - BYTE *NewBuffer(COUNT_T allocation); - void DeleteBuffer(BYTE *buffer, COUNT_T allocation); - - // Use existing buffer - BYTE *UseBuffer(BYTE *buffer, COUNT_T *allocation); - - CHECK CheckBuffer(const BYTE* buffer, COUNT_T allocation) const; - - // Manipulates contents of the buffer via the plugins below, but - // adds some debugging checks. Should always call through here rather - // than directly calling the extensibility points. - void DebugMoveBuffer(__out_bcount(size) BYTE *to, BYTE *from, COUNT_T size); - void DebugCopyConstructBuffer(__out_bcount(size) BYTE *to, const BYTE *from, COUNT_T size); - void DebugConstructBuffer(BYTE *buffer, COUNT_T size); - void DebugDestructBuffer(BYTE *buffer, COUNT_T size); - - void DebugStompUnusedBuffer(BYTE *buffer, COUNT_T size); -#ifdef _DEBUG - static BOOL EnsureGarbageCharOnly(const BYTE *buffer, COUNT_T size); -#endif - CHECK CheckUnusedBuffer(const BYTE *buffer, COUNT_T size) const; - -#ifdef DACCESS_COMPILE -public: - - // Expose the raw Target address of the buffer to DAC. - // This does not do any marshalling. This can be useful if the caller wants to allocate the buffer on - // its own heap so that it can survive Flush calls. - MemoryRange DacGetRawBuffer() const - { - SUPPORTS_DAC; - PTR_VOID p = dac_cast((TADDR) m_buffer); - return MemoryRange(p, GetSize()); - } - -protected: - - // Return a host copy of the buffer, allocated on the DAC heap (and thus invalidated at the next call to Flush). - void* DacGetRawContent(void) const - { - SUPPORTS_DAC; - - // SBuffers are used in DAC in two ways - buffers in the host, and marshalled buffers from the target. - // This is a problem - we can't reason about the address space of the buffer statically, and instead rely on - // the dynamic usage (i.e. the methods are basically bifurcated into those you can use on host instances, - // and those you can use on marshalled copies). - // Ideally we'll have two versions of the SBuffer code - one that's marshalled (normal DACization) and one - // that isn't (host-only utility). This is the "dual-mode DAC problem". - // But this only affects a couple classes, and so for now we'll ignore the problem - causing a bunch of DacCop - // violations. - DACCOP_IGNORE(CastBetweenAddressSpaces, "SBuffer has the dual-mode DAC problem"); - DACCOP_IGNORE(FieldAccess, "SBuffer has the dual-mode DAC problem"); - TADDR bufAddr = (TADDR)m_buffer; - - return DacInstantiateTypeByAddress(bufAddr, m_size, true); - } - - void EnumMemoryRegions(CLRDataEnumMemoryFlags flags) const - { - SUPPORTS_DAC; - - if (flags != CLRDATA_ENUM_MEM_TRIAGE) - { - DacEnumMemoryRegion((TADDR)m_buffer, m_size); - } - } -#endif - - //---------------------------------------------------------------------------- - // Iterator base class - //---------------------------------------------------------------------------- - - friend class CheckedIteratorBase; - - class Index : public CheckedIteratorBase - { - friend class SBuffer; - - friend class CIterator; - friend class Indexer; - - friend class Iterator; - friend class Indexer; - - protected: - BYTE* m_ptr; - - Index(); - Index(SBuffer *container, SCOUNT_T index); - BYTE &GetAt(SCOUNT_T delta) const; - void Skip(SCOUNT_T delta); - SCOUNT_T Subtract(const Index &i) const; - - CHECK DoCheck(SCOUNT_T delta) const; - - void Resync(const SBuffer *container, BYTE *value) const; - }; - - public: - - class CIterator : public Index, public Indexer - { - friend class SBuffer; - - public: - CIterator() - { - } - - CIterator(const SBuffer *buffer, int index) - : Index(const_cast(buffer), index) - { - } - }; - - class Iterator : public Index, public Indexer - { - friend class SBuffer; - - public: - operator const CIterator &() const - { - return *(const CIterator *)this; - } - - operator CIterator &() - { - return *(CIterator *)this; - } - - Iterator() - { - } - - Iterator(SBuffer *buffer, int index) - : Index(buffer, index) - { - } - - }; - - - //---------------------------------------------------------------------------- - // Member and data declarations - //---------------------------------------------------------------------------- - - private: - enum - { - REPRESENTATION_MASK = 0x07, - ALLOCATED = 0x08, - IMMUTABLE = 0x10, - OPENED = 0x20, - FLAG1 = 0x40, - FLAG2 = 0x80, - FLAG3 = 0x100, - }; - - COUNT_T m_size; // externally visible size - COUNT_T m_allocation; // actual allocated size - UINT32 m_flags; // @todo: steal flags from sizes - - protected: - union { - BYTE *m_buffer; - wchar_t *m_asStr; // For debugging, view as a unicode string - }; - -#if _DEBUG - protected: - // We will update the "revision" of the buffer every time it is potentially reallocation, - // so we can tell when iterators are no longer valid. - int m_revision; -#endif -}; - -// ================================================================================ -// InlineSBuffer : Tlempate for an SBuffer with preallocated buffer space -// ================================================================================ - -#define BUFFER_ALIGNMENT 4 - -template -class InlineSBuffer : public SBuffer -{ - private: -#ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable:4200) // zero sized array -#pragma warning(disable:4324) // don't complain if DECLSPEC_ALIGN actually pads - DECLSPEC_ALIGN(BUFFER_ALIGNMENT) BYTE m_prealloc[size]; -#pragma warning(pop) -#else - // use UINT64 to get maximum alignment of the memory - UINT64 m_prealloc[ALIGN(size,sizeof(UINT64))/sizeof(UINT64)]; -#endif // _MSC_VER - - public: - InlineSBuffer() - : SBuffer(Prealloc, (BYTE*)m_prealloc, size) - { - WRAPPER_NO_CONTRACT; - } -}; - - -// a 1K sized buffer filled with $ that we'll use in debug builds for verification -#define GARBAGE_FILL_DWORD 0x24242424 // $$$$ -#define GARBAGE_FILL_BUFFER_ITEMS 16 -#define GARBAGE_FILL_BUFFER_SIZE GARBAGE_FILL_BUFFER_ITEMS*sizeof(DWORD) -// ================================================================================ -// StackSBuffer : SBuffer with relatively large preallocated buffer for stack use -// ================================================================================ - -#define STACK_ALLOC 256 - -typedef InlineSBuffer StackSBuffer; - -// ================================================================================ -// Inline definitions -// ================================================================================ - -/// a wrapper for templates and such, that use "==". -/// more expensive than a typical "==", though -inline BOOL operator == (const SBuffer& b1,const SBuffer& b2) -{ - return b1.Equals(b2); -}; - -#include - -#endif // _SBUFFER_H_ diff --git a/src/inc/sbuffer.inl b/src/inc/sbuffer.inl deleted file mode 100644 index 96be7a566..000000000 --- a/src/inc/sbuffer.inl +++ /dev/null @@ -1,1711 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -// - -#ifndef _SBUFFER_INL_ -#define _SBUFFER_INL_ - -#include "sbuffer.h" - -#if defined(_MSC_VER) -#pragma inline_depth (20) -#endif - -#ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable:4702) // Disable bogus unreachable code warning -#endif // _MSC_VER - -inline SBuffer::SBuffer(PreallocFlag flag, void *buffer, COUNT_T size) - : m_size(0), - m_allocation(NULL), - m_flags(0), - m_buffer(NULL) -{ - CONTRACT_VOID - { - CONSTRUCTOR_CHECK; - PRECONDITION(CheckPointer(buffer)); - PRECONDITION(CheckSize(size)); - NOTHROW; - GC_NOTRIGGER; - SUPPORTS_DAC_HOST_ONLY; - } - CONTRACT_END; - - m_buffer = UseBuffer((BYTE *) buffer, &size); - m_allocation = size; - -#ifdef _DEBUG - m_revision = 0; -#endif - - RETURN; -} - -inline SBuffer::SBuffer() - : m_size(0), - m_allocation(0), - m_flags(0), - m_buffer(NULL) -{ - CONTRACT_VOID - { - CONSTRUCTOR_CHECK; - NOTHROW; - GC_NOTRIGGER; - } - CONTRACT_END; - -#ifdef _DEBUG - m_revision = 0; -#endif - - RETURN; -} - -inline SBuffer::SBuffer(COUNT_T size) - : m_size(0), - m_allocation(0), - m_flags(0), - m_buffer(NULL) -{ - CONTRACT_VOID - {; - CONSTRUCTOR_CHECK; - PRECONDITION(CheckSize(size)); - THROWS; - GC_NOTRIGGER; - } - CONTRACT_END; - - Resize(size); - -#ifdef _DEBUG - m_revision = 0; -#endif - - RETURN; -} - -inline SBuffer::SBuffer(const SBuffer &buffer) - : m_size(0), - m_allocation(0), - m_flags(0), - m_buffer(NULL) -{ - CONTRACT_VOID - { - CONSTRUCTOR_CHECK; - PRECONDITION(buffer.Check()); - POSTCONDITION(Equals(buffer)); - THROWS; - GC_NOTRIGGER; - } - CONTRACT_END; - - Set(buffer); - -#ifdef _DEBUG - m_revision = 0; -#endif - - RETURN; -} - -inline SBuffer::SBuffer(const BYTE *buffer, COUNT_T size) - : m_size(0), - m_allocation(0), - m_flags(0), - m_buffer(NULL) -{ - CONTRACT_VOID - { - CONSTRUCTOR_CHECK; - PRECONDITION(CheckPointer(buffer)); - PRECONDITION(CheckSize(size)); - POSTCONDITION(Equals(buffer, size)); - THROWS; - GC_NOTRIGGER; - } - CONTRACT_END; - - Set(buffer, size); - -#ifdef _DEBUG - m_revision = 0; -#endif - - RETURN; -} - - -inline SBuffer::SBuffer(ImmutableFlag immutable, const BYTE *buffer, COUNT_T size) - : m_size(size), - m_allocation(size), - m_flags(IMMUTABLE), - m_buffer(const_cast(buffer)) -{ - CONTRACT_VOID - { - CONSTRUCTOR_CHECK; - PRECONDITION(CheckPointer(buffer)); - PRECONDITION(CheckSize(size)); - POSTCONDITION(Equals(buffer, size)); - NOTHROW; - GC_NOTRIGGER; - SO_TOLERANT; - SUPPORTS_DAC_HOST_ONLY; - } - CONTRACT_END; - -#ifdef _DEBUG - m_revision = 0; -#endif - - RETURN; -} - -inline SBuffer::~SBuffer() -{ - CONTRACT_VOID - { - NOTHROW; - DESTRUCTOR_CHECK; - SO_TOLERANT; - GC_NOTRIGGER; - SO_TOLERANT; - SUPPORTS_DAC_HOST_ONLY; - } - CONTRACT_END; - VALIDATE_BACKOUT_STACK_CONSUMPTION; - - if (IsAllocated()) - { - DeleteBuffer(m_buffer, m_allocation); - } - - RETURN; -} - -inline void SBuffer::Set(const SBuffer &buffer) -{ - CONTRACT_VOID - { - INSTANCE_CHECK; - PRECONDITION(buffer.Check()); - POSTCONDITION(Equals(buffer)); - THROWS; - GC_NOTRIGGER; - SUPPORTS_DAC_HOST_ONLY; - } - CONTRACT_END; - - if (buffer.IsImmutable() - && (IsImmutable() || m_allocation < buffer.GetSize())) - { - // Share immutable block rather than reallocate and copy - // (Note that we prefer to copy to our buffer if we - // don't have to reallocate it.) - - if (IsAllocated()) - DeleteBuffer(m_buffer, m_allocation); - - m_size = buffer.m_size; - m_allocation = buffer.m_allocation; - m_buffer = buffer.m_buffer; - m_flags = buffer.m_flags; - -#if _DEBUG - // Increment our revision to invalidate iterators - m_revision++; -#endif - - } - else - { - Resize(buffer.m_size, DONT_PRESERVE); - EnsureMutable(); - - // PreFix seems to think it can choose m_allocation==0 and buffer.m_size > 0 here. - // From the code for Resize and EnsureMutable, this is clearly impossible. - PREFIX_ASSUME( (this->m_buffer != NULL) || (buffer.m_size == 0) ); - - MoveMemory(m_buffer, buffer.m_buffer, buffer.m_size); - } - - RETURN; -} - -inline void SBuffer::Set(const BYTE *buffer, COUNT_T size) -{ - CONTRACT_VOID - { - INSTANCE_CHECK; - PRECONDITION(CheckPointer(buffer, size == 0 ? NULL_OK : NULL_NOT_OK)); - PRECONDITION(CheckSize(size)); - POSTCONDITION(Equals(buffer, size)); - THROWS; - GC_NOTRIGGER; - } - CONTRACT_END; - - Resize(size); - EnsureMutable(); - - // PreFix seems to think it can choose m_allocation==0 and size > 0 here. - // From the code for Resize, this is clearly impossible. - PREFIX_ASSUME( (this->m_buffer != NULL) || (size == 0) ); - - MoveMemory(m_buffer, buffer, size); - - RETURN; -} - -inline void SBuffer::SetImmutable(const BYTE *buffer, COUNT_T size) -{ - CONTRACT_VOID - { - INSTANCE_CHECK; - PRECONDITION(CheckPointer(buffer, size == 0 ? NULL_OK : NULL_NOT_OK)); - PRECONDITION(CheckSize(size)); - POSTCONDITION(Equals(buffer, size)); - NOTHROW; - GC_NOTRIGGER; - SUPPORTS_DAC_HOST_ONLY; - - } - CONTRACT_END; - - SBuffer temp(Immutable, buffer, size); - - { - // This can't really throw - CONTRACT_VIOLATION(ThrowsViolation); - Set(temp); - } - - RETURN; -} - -inline COUNT_T SBuffer::GetSize() const -{ - LIMITED_METHOD_CONTRACT; - SUPPORTS_DAC; - - return m_size; -} - -inline void SBuffer::SetSize(COUNT_T size) -{ - CONTRACT_VOID - { - INSTANCE_CHECK; - PRECONDITION(CheckSize(size)); - THROWS; - GC_NOTRIGGER; - } - CONTRACT_END; - - Resize(size); - - RETURN; -} - -inline void SBuffer::MaximizeSize() -{ - CONTRACT_VOID - { - INSTANCE_CHECK; - THROWS; - GC_NOTRIGGER; - } - CONTRACT_END; - - if (!IsImmutable()) - Resize(m_allocation); - - RETURN; -} - -inline COUNT_T SBuffer::GetAllocation() const -{ - CONTRACT(COUNT_T) - { - INSTANCE_CHECK; - NOTHROW; - GC_NOTRIGGER; - SO_TOLERANT; - SUPPORTS_DAC; - } - CONTRACT_END; - - RETURN m_allocation; -} - -inline void SBuffer::Preallocate(COUNT_T allocation) const -{ - CONTRACT_VOID - { - if (allocation) THROWS; else NOTHROW; - INSTANCE_CHECK; - PRECONDITION(CheckAllocation(allocation)); - THROWS; - GC_NOTRIGGER; - SUPPORTS_DAC_HOST_ONLY; - } - CONTRACT_END; - - if (allocation > m_allocation) - const_cast(this)->ReallocateBuffer(allocation, PRESERVE); - - RETURN; -} - -inline void SBuffer::Trim() const -{ - CONTRACT_VOID - { - INSTANCE_CHECK; - THROWS; - GC_NOTRIGGER; - } - CONTRACT_END; - - if (!IsImmutable()) - const_cast(this)->ReallocateBuffer(m_size, PRESERVE); - - RETURN; -} - -inline void SBuffer::Zero() -{ - CONTRACT_VOID - { - INSTANCE_CHECK; - NOTHROW; - GC_NOTRIGGER; - } - CONTRACT_END; - - ZeroMemory(m_buffer, m_size); - - RETURN; -} - -inline void SBuffer::Fill(BYTE value) -{ - CONTRACT_VOID - { - INSTANCE_CHECK; - NOTHROW; - GC_NOTRIGGER; - } - CONTRACT_END; - - memset(m_buffer, value, m_size); - - RETURN; -} - -inline void SBuffer::Fill(const Iterator &i, BYTE value, COUNT_T size) -{ - CONTRACT_VOID - { - INSTANCE_CHECK; - PRECONDITION(CheckIteratorRange(i, size)); - NOTHROW; - GC_NOTRIGGER; - } - CONTRACT_END; - - memset(i.m_ptr, value, size); - - RETURN; -} - -inline void SBuffer::Copy(const Iterator &to, const CIterator &from, COUNT_T size) -{ - CONTRACT_VOID - { - INSTANCE_CHECK; - PRECONDITION(CheckIteratorRange(to, size)); - PRECONDITION(CheckIteratorRange(from, size)); - NOTHROW; - GC_NOTRIGGER; - } - CONTRACT_END; - - DebugDestructBuffer(to.m_ptr, size); - - DebugCopyConstructBuffer(to.m_ptr, from.m_ptr, size); - - RETURN; -} - -inline void SBuffer::Move(const Iterator &to, const CIterator &from, COUNT_T size) -{ - CONTRACT_VOID - { - INSTANCE_CHECK; - PRECONDITION(CheckIteratorRange(to, size)); - PRECONDITION(CheckIteratorRange(from, size)); - NOTHROW; - GC_NOTRIGGER; - } - CONTRACT_END; - - DebugDestructBuffer(to.m_ptr, size); - - DebugMoveBuffer(to.m_ptr, from.m_ptr, size); - - DebugConstructBuffer(from.m_ptr, size); - - RETURN; -} - -inline void SBuffer::Copy(const Iterator &i, const SBuffer &source) -{ - CONTRACT_VOID - { - INSTANCE_CHECK; - PRECONDITION(CheckIteratorRange(i, source.GetSize())); - PRECONDITION(source.Check()); - NOTHROW; - GC_NOTRIGGER; - } - CONTRACT_END; - - DebugDestructBuffer(i.m_ptr, source.m_size); - - DebugCopyConstructBuffer(i.m_ptr, source.m_buffer, source.m_size); - - RETURN; -} - -inline void SBuffer::Copy(const Iterator &i, const void *source, COUNT_T size) -{ - CONTRACT_VOID - { - PRECONDITION(CheckPointer(this)); - PRECONDITION(CheckSize(size)); - PRECONDITION(CheckIteratorRange(i, size)); - PRECONDITION(CheckPointer(source, size == 0 ? NULL_OK : NULL_NOT_OK)); - NOTHROW; - GC_NOTRIGGER; - SUPPORTS_DAC; - } - CONTRACT_END; - - DebugDestructBuffer(i.m_ptr, size); - - DebugCopyConstructBuffer(i.m_ptr, (const BYTE *) source, size); - - RETURN; -} - -inline void SBuffer::Copy(void *dest, const CIterator &i, COUNT_T size) -{ - CONTRACT_VOID - { - PRECONDITION(CheckPointer(this)); - PRECONDITION(CheckSize(size)); - PRECONDITION(CheckIteratorRange(i, size)); - PRECONDITION(CheckPointer(dest, size == 0 ? NULL_OK : NULL_NOT_OK)); - NOTHROW; - GC_NOTRIGGER; - } - CONTRACT_END; - - memcpy(dest, i.m_ptr, size); - - RETURN; -} - -inline void SBuffer::Insert(const Iterator &i, const SBuffer &source) -{ - CONTRACT_VOID - { - INSTANCE_CHECK; - THROWS; - PRECONDITION(CheckIteratorRange(i,0)); - GC_NOTRIGGER; - } - CONTRACT_END; - - Replace(i, 0, source.GetSize()); - Copy(i, source, source.GetSize()); - - RETURN; -} - -inline void SBuffer::Insert(const Iterator &i, COUNT_T size) -{ - CONTRACT_VOID - { - INSTANCE_CHECK; - THROWS; - PRECONDITION(CheckIteratorRange(i,0)); - GC_NOTRIGGER; - } - CONTRACT_END; - - Replace(i, 0, size); - - RETURN; -} - -inline void SBuffer::Clear() -{ - CONTRACT_VOID - { - INSTANCE_CHECK; - THROWS; - GC_NOTRIGGER; - } - CONTRACT_END; - - Delete(Begin(), GetSize()); - - RETURN; -} - -inline void SBuffer::Delete(const Iterator &i, COUNT_T size) -{ - CONTRACT_VOID - { - INSTANCE_CHECK; - PRECONDITION(CheckIteratorRange(i, size)); - THROWS; - GC_NOTRIGGER; - } - CONTRACT_END; - - Replace(i, size, 0); - - RETURN; -} - -inline void SBuffer::Replace(const Iterator &i, COUNT_T deleteSize, const SBuffer &insert) -{ - CONTRACT_VOID - { - INSTANCE_CHECK; - PRECONDITION(CheckIteratorRange(i, deleteSize)); - THROWS; - GC_NOTRIGGER; - } - CONTRACT_END; - - Replace(i, deleteSize, insert.GetSize()); - Copy(i, insert, insert.GetSize()); - - RETURN; -} - -inline int SBuffer::Compare(const SBuffer &compare) const -{ - CONTRACT(int) - { - INSTANCE_CHECK; - PRECONDITION(compare.Check()); - POSTCONDITION(RETVAL == -1 || RETVAL == 0 || RETVAL == 1); - NOTHROW; - GC_NOTRIGGER; - } - CONTRACT_END; - - RETURN Compare(compare.m_buffer, compare.m_size); -} - -inline int SBuffer::Compare(const BYTE *compare, COUNT_T size) const -{ - CONTRACT(int) - { - INSTANCE_CHECK; - PRECONDITION(CheckPointer(compare)); - PRECONDITION(CheckSize(size)); - POSTCONDITION(RETVAL == -1 || RETVAL == 0 || RETVAL == 1); - NOTHROW; - GC_NOTRIGGER; - } - CONTRACT_END; - - COUNT_T smaller; - int equals; - int result; - - if (m_size < size) - { - smaller = m_size; - equals = -1; - } - else if (m_size > size) - { - smaller = size; - equals = 1; - } - else - { - smaller = size; - equals = 0; - } - - result = memcmp(m_buffer, compare, size); - - if (result == 0) - RETURN equals; - else - RETURN result; -} - -inline BOOL SBuffer::Equals(const SBuffer &compare) const -{ - CONTRACT(int) - { - INSTANCE_CHECK; - PRECONDITION(compare.Check()); - NOTHROW; - GC_NOTRIGGER; - SO_TOLERANT; - } - CONTRACT_END; - - RETURN Equals(compare.m_buffer, compare.m_size); -} - -inline BOOL SBuffer::Equals(const BYTE *compare, COUNT_T size) const -{ - CONTRACT(int) - { - INSTANCE_CHECK; - PRECONDITION(CheckPointer(compare)); - PRECONDITION(CheckSize(size)); - NOTHROW; - GC_NOTRIGGER; - SO_TOLERANT; - } - CONTRACT_END; - - if (m_size != size) - RETURN FALSE; - else - RETURN (memcmp(m_buffer, compare, size) == 0); -} - -inline BOOL SBuffer::Match(const CIterator &i, const SBuffer &match) const -{ - CONTRACT(int) - { - INSTANCE_CHECK; - PRECONDITION(CheckIteratorRange(i)); - PRECONDITION(match.Check()); - NOTHROW; - GC_NOTRIGGER; - } - CONTRACT_END; - - RETURN Match(i, match.m_buffer, match.m_size); -} - -inline BOOL SBuffer::Match(const CIterator &i, const BYTE *match, COUNT_T size) const -{ - CONTRACT(int) - { - INSTANCE_CHECK; - PRECONDITION(CheckIteratorRange(i)); - PRECONDITION(CheckPointer(match)); - PRECONDITION(CheckSize(size)); - NOTHROW; - GC_NOTRIGGER; - } - CONTRACT_END; - - COUNT_T remaining = (COUNT_T) (m_buffer + m_size - i.m_ptr); - - if (remaining < size) - RETURN FALSE; - - RETURN (memcmp(i.m_ptr, match, size) == 0); -} - -//---------------------------------------------------------------------------- -// EnsureMutable -// Ensures that the buffer is mutable -//---------------------------------------------------------------------------- -inline void SBuffer::EnsureMutable() const -{ - CONTRACT_VOID - { - PRECONDITION(CheckPointer(this)); - PRECONDITION(CheckBufferClosed()); - THROWS; - GC_NOTRIGGER; - SUPPORTS_DAC_HOST_ONLY; - } - CONTRACT_END; - - if (IsImmutable()) - const_cast(this)->ReallocateBuffer(m_allocation, PRESERVE); - - RETURN; -} - -//---------------------------------------------------------------------------- -// Resize -// Change the visible size of the buffer; realloc if necessary -//---------------------------------------------------------------------------- -FORCEINLINE void SBuffer::Resize(COUNT_T size, Preserve preserve) -{ - CONTRACT_VOID - { - PRECONDITION(CheckPointer(this)); - PRECONDITION(CheckSize(size)); - POSTCONDITION(GetSize() == size); - POSTCONDITION(m_allocation >= GetSize()); - POSTCONDITION(CheckInvariant(*this)); - if (size > 0) THROWS; else NOTHROW; - GC_NOTRIGGER; - SUPPORTS_DAC_HOST_ONLY; - } - CONTRACT_END; - -#ifdef _DEBUG - // Change our revision - m_revision++; -#endif - - SCOUNT_T delta = size - m_size; - - if (delta < 0) - DebugDestructBuffer(m_buffer + size, -delta); - - // Only actually allocate if we are growing - if (size > m_allocation) - ReallocateBuffer(size, preserve); - - if (delta > 0) - DebugConstructBuffer(m_buffer + m_size, delta); - - m_size = size; - - RETURN; -} - -//---------------------------------------------------------------------------- -// ResizePadded -// Change the visible size of the buffer; realloc if necessary -// add extra space to minimize further growth -//---------------------------------------------------------------------------- -inline void SBuffer::ResizePadded(COUNT_T size, Preserve preserve) -{ - CONTRACT_VOID - { - PRECONDITION(CheckPointer(this)); - PRECONDITION(CheckSize(size)); - POSTCONDITION(GetSize() == size); - POSTCONDITION(m_allocation >= GetSize()); - POSTCONDITION(CheckInvariant(*this)); - if (size > 0) THROWS; else NOTHROW; - GC_NOTRIGGER; - SUPPORTS_DAC_HOST_ONLY; - } - CONTRACT_END; - -#ifdef _DEBUG - // Change our revision - m_revision++; -#endif - - SCOUNT_T delta = size - m_size; - - if (delta < 0) - DebugDestructBuffer(m_buffer + size, -delta); - - // Only actually allocate if we are growing - if (size > m_allocation) - { - COUNT_T padded = (size*3)/2; - - ReallocateBuffer(padded, preserve); - } - - if (delta > 0) - DebugConstructBuffer(m_buffer + m_size, delta); - - m_size = size; - - RETURN; -} - -//---------------------------------------------------------------------------- -// TweakSize -// An optimized form of Resize, which can only adjust the size within the -// currently allocated range, and never reallocates -//---------------------------------------------------------------------------- -inline void SBuffer::TweakSize(COUNT_T size) -{ - CONTRACT_VOID - { - PRECONDITION(CheckPointer(this)); - PRECONDITION(CheckSize(size)); - PRECONDITION(size <= GetAllocation()); - POSTCONDITION(GetSize() == size); - POSTCONDITION(CheckInvariant(*this)); - NOTHROW; - SO_TOLERANT; - GC_NOTRIGGER; - SUPPORTS_DAC_HOST_ONLY; - } - CONTRACT_END; - -#ifdef _DEBUG - // Change our revision - m_revision++; -#endif - - SCOUNT_T delta = size - m_size; - - if (delta < 0) - DebugDestructBuffer(m_buffer + size, -delta); - else - DebugConstructBuffer(m_buffer + m_size, delta); - - m_size = size; - - RETURN; -} - -//----------------------------------------------------------------------------- -// SBuffer allocates all memory via NewBuffer & DeleteBuffer members. -// If SBUFFER_CANARY_CHECKS is defined, NewBuffer will place Canaries at the start -// and end of the buffer to detect overflows. -//----------------------------------------------------------------------------- - -#ifdef _DEBUG -#define SBUFFER_CANARY_CHECKS 1 -#endif - -#ifdef SBUFFER_CANARY_CHECKS - -// The value we place at the start/end of the buffer, -static const UINT64 SBUFFER_CANARY_VALUE = UI64(0xD00BED00BED00BAA); - -// Expose the quantity of padding needed when providing a prealloced -// buffer. This is an unrolled version of the actualAllocation calculated -// below for use as a constant value for InlineSString to use. It is -// padded with one additional sizeof(SBUFFER_CANARY_VALUE) to account for -// possible alignment problems issues (pre- and post-padding). -#define SBUFFER_PADDED_SIZE(desiredUsefulSize) \ - ((((SIZE_T)(desiredUsefulSize) + sizeof(SBUFFER_CANARY_VALUE) - 1) & \ - ~(sizeof(SBUFFER_CANARY_VALUE)-1)) + 3 * sizeof(SBUFFER_CANARY_VALUE)) - -#else // SBUFFER_CANARY_CHECKS - -#define SBUFFER_PADDED_SIZE(desiredUsefulSize) (desiredUsefulSize) - -#endif // SBUFFER_CANARY_CHECKS else - -// Must match expected guaranteed alignment of new [] -#ifdef ALIGN_ACCESS -static const int SBUFFER_ALIGNMENT = ALIGN_ACCESS; -#else -// This is only 4 bytes on win98 and below -static const int SBUFFER_ALIGNMENT = 4; -#endif - -//---------------------------------------------------------------------------- -// Allocate memory, use canaries. -//---------------------------------------------------------------------------- -inline BYTE *SBuffer::NewBuffer(COUNT_T allocation) -{ - CONTRACT(BYTE*) - { - PRECONDITION(CheckSize(allocation)); - PRECONDITION(allocation > 0); - POSTCONDITION(CheckPointer(RETVAL)); - THROWS; - GC_NOTRIGGER; - SUPPORTS_DAC_HOST_ONLY; - } - CONTRACT_END; - -#ifdef SBUFFER_CANARY_CHECKS - - COUNT_T alignPadding = AlignmentPad(allocation, sizeof(SBUFFER_CANARY_VALUE)); - COUNT_T actualAllocation= sizeof(SBUFFER_CANARY_VALUE) + allocation + alignPadding + sizeof(SBUFFER_CANARY_VALUE); - BYTE *raw = new BYTE [actualAllocation]; - - *(UINT64*) raw = SBUFFER_CANARY_VALUE; - *(UINT64*) (raw + sizeof(SBUFFER_CANARY_VALUE) + allocation + alignPadding) = SBUFFER_CANARY_VALUE; - - BYTE *buffer = raw + sizeof(SBUFFER_CANARY_VALUE); - -#else - - BYTE *buffer = new BYTE [allocation]; - -#endif - - DebugStompUnusedBuffer(buffer, allocation); - - CONSISTENCY_CHECK(CheckBuffer(buffer, allocation)); - - RETURN buffer; -} - -//---------------------------------------------------------------------------- -// Use existing memory, use canaries. -//---------------------------------------------------------------------------- -inline BYTE *SBuffer::UseBuffer(BYTE *buffer, COUNT_T *allocation) -{ - CONTRACT(BYTE*) - { - NOTHROW; - GC_NOTRIGGER; - CANNOT_TAKE_LOCK; - SUPPORTS_DAC_HOST_ONLY; - PRECONDITION(CheckPointer(buffer)); - PRECONDITION(CheckSize(*allocation)); -// POSTCONDITION(CheckPointer(RETVAL)); - POSTCONDITION(CheckSize(*allocation)); - } - CONTRACT_END; - -#ifdef SBUFFER_CANARY_CHECKS - - COUNT_T prepad = AlignmentPad((SIZE_T) buffer, sizeof(SBUFFER_CANARY_VALUE)); - COUNT_T postpad = AlignmentTrim((SIZE_T) buffer+*allocation, sizeof(SBUFFER_CANARY_VALUE)); - - SCOUNT_T usableAllocation = *allocation - prepad - sizeof(SBUFFER_CANARY_VALUE) - sizeof(SBUFFER_CANARY_VALUE) - postpad; - if (usableAllocation <= 0) - { - buffer = NULL; - *allocation = 0; - } - else - { - BYTE *result = buffer + prepad + sizeof(SBUFFER_CANARY_VALUE); - - *(UINT64*) (buffer + prepad) = SBUFFER_CANARY_VALUE; - *(UINT64*) (buffer + prepad + sizeof(SBUFFER_CANARY_VALUE) + usableAllocation) = SBUFFER_CANARY_VALUE; - - buffer = result; - *allocation = usableAllocation; - } - -#endif - - DebugStompUnusedBuffer(buffer, *allocation); - - CONSISTENCY_CHECK(CheckBuffer(buffer, *allocation)); - - RETURN buffer; -} - -//---------------------------------------------------------------------------- -// Free memory allocated by NewHelper -//---------------------------------------------------------------------------- -inline void SBuffer::DeleteBuffer(BYTE *buffer, COUNT_T allocation) -{ - CONTRACT_VOID - { - PRECONDITION(CheckSize(allocation)); - POSTCONDITION(CheckPointer(buffer)); - SO_TOLERANT; - NOTHROW; - GC_NOTRIGGER; - SO_TOLERANT; - SUPPORTS_DAC_HOST_ONLY; - } - CONTRACT_END; - VALIDATE_BACKOUT_STACK_CONSUMPTION; - - CONSISTENCY_CHECK(CheckBuffer(buffer, allocation)); - -#ifdef SBUFFER_CANARY_CHECKS - - delete [] (buffer - sizeof(SBUFFER_CANARY_VALUE)); - -#else - - delete [] buffer; - -#endif - - RETURN; -} - -//---------------------------------------------------------------------------- -// Check the buffer at the given address. The memory must have been a pointer -// returned by NewHelper. -//---------------------------------------------------------------------------- -inline CHECK SBuffer::CheckBuffer(const BYTE *buffer, COUNT_T allocation) const -{ - CONTRACT_CHECK - { - NOTHROW; - GC_NOTRIGGER; - SO_TOLERANT; - CANNOT_TAKE_LOCK; - PRECONDITION(CheckPointer(buffer)); - } - CONTRACT_CHECK_END; - - if (allocation > 0) - { -#ifdef SBUFFER_CANARY_CHECKS - const BYTE *raw = buffer - sizeof(SBUFFER_CANARY_VALUE); - - COUNT_T alignPadding = ((allocation + (sizeof(SBUFFER_CANARY_VALUE) - 1)) & ~((sizeof(SBUFFER_CANARY_VALUE) - 1))) - allocation; - - CHECK_MSG(*(UINT64*) raw == SBUFFER_CANARY_VALUE, "SBuffer underflow"); - CHECK_MSG(*(UINT64*) (raw + sizeof(SBUFFER_CANARY_VALUE) + allocation + alignPadding) == SBUFFER_CANARY_VALUE, "SBuffer overflow"); - -#endif - - CHECK_MSG((((SIZE_T)buffer) & (SBUFFER_ALIGNMENT-1)) == 0, "SBuffer not properly aligned"); - } - - CHECK_OK; -} - - -inline BYTE *SBuffer::OpenRawBuffer(COUNT_T size) -{ - CONTRACT(BYTE*) - { -#if _DEBUG - PRECONDITION_MSG(!IsOpened(), "Can't nest calls to OpenBuffer()"); -#endif - PRECONDITION(CheckSize(size)); - POSTCONDITION(GetSize() == size); - THROWS; - GC_NOTRIGGER; - } - CONTRACT_END; - - Resize(size); - EnsureMutable(); - -#if _DEBUG - SetOpened(); -#endif - - RETURN m_buffer; -} - -//---------------------------------------------------------------------------- -// Close an open buffer. Assumes that we wrote exactly number of characters -// we requested in OpenBuffer. -//---------------------------------------------------------------------------- -inline void SBuffer::CloseRawBuffer() -{ - CONTRACT_VOID - { -#if _DEBUG - PRECONDITION(IsOpened()); -#endif - THROWS; - GC_NOTRIGGER; - } - CONTRACT_END; - - CloseRawBuffer(m_size); - - RETURN; -} - -//---------------------------------------------------------------------------- -// CloseBuffer() tells the SBuffer that we're done using the unsafe buffer. -// finalSize is the count of bytes actually used (so we can set m_count). -// This is important if we request a buffer larger than what we actually -// used. -//---------------------------------------------------------------------------- -inline void SBuffer::CloseRawBuffer(COUNT_T finalSize) -{ - CONTRACT_VOID - { -#if _DEBUG - PRECONDITION_MSG(IsOpened(), "Can only CloseRawBuffer() after a call to OpenRawBuffer()"); -#endif - PRECONDITION(CheckSize(finalSize)); - PRECONDITION_MSG(finalSize <= GetSize(), "Can't use more characters than requested via OpenRawBuffer()"); - THROWS; - GC_NOTRIGGER; - } - CONTRACT_END; - -#if _DEBUG - ClearOpened(); -#endif - - TweakSize(finalSize); - - CONSISTENCY_CHECK(CheckBuffer(m_buffer, m_allocation)); - - RETURN; -} - -inline SBuffer::operator const void *() const -{ - LIMITED_METHOD_CONTRACT; - - return (void *) m_buffer; -} - -inline SBuffer::operator const BYTE *() const -{ - LIMITED_METHOD_DAC_CONTRACT; - - return m_buffer; -} - -inline BYTE &SBuffer::operator[](int index) -{ - LIMITED_METHOD_CONTRACT; - - return m_buffer[index]; -} - -inline const BYTE &SBuffer::operator[](int index) const -{ - LIMITED_METHOD_CONTRACT; - - return m_buffer[index]; -} - -inline SBuffer::Iterator SBuffer::Begin() -{ - CONTRACT(SBuffer::Iterator) - { - INSTANCE_CHECK; - THROWS; - GC_NOTRIGGER; - SUPPORTS_DAC_HOST_ONLY; - } - CONTRACT_END; - - // This is a bit unfortunate to have to do here, but it's our - // last opportunity before possibly doing a *i= with the iterator - EnsureMutable(); - - RETURN Iterator(this, 0); -} - -inline SBuffer::Iterator SBuffer::End() -{ - CONTRACT(SBuffer::Iterator) - { - INSTANCE_CHECK; - THROWS; - GC_NOTRIGGER; - } - CONTRACT_END; - - // This is a bit unfortunate to have to do here, but it's our - // last opportunity before possibly doing a *i= with the iterator - EnsureMutable(); - - RETURN Iterator(this, m_size); -} - -inline SBuffer::CIterator SBuffer::Begin() const -{ - CONTRACT(SBuffer::CIterator) - { - INSTANCE_CHECK; - NOTHROW; - GC_NOTRIGGER; - } - CONTRACT_END; - - RETURN SBuffer::CIterator(this, 0); -} - -inline SBuffer::CIterator SBuffer::End() const -{ - CONTRACT(SBuffer::CIterator) - { - INSTANCE_CHECK; - NOTHROW; - GC_NOTRIGGER; - } - CONTRACT_END; - - RETURN CIterator(const_cast(this), m_size); -} - -inline BOOL SBuffer::IsAllocated() const -{ - LIMITED_METHOD_DAC_CONTRACT; - - return (m_flags & ALLOCATED) != 0; -} - -inline void SBuffer::SetAllocated() -{ - LIMITED_METHOD_CONTRACT; - SUPPORTS_DAC_HOST_ONLY; - - m_flags |= ALLOCATED; -} - -inline void SBuffer::ClearAllocated() -{ - LIMITED_METHOD_CONTRACT; - SUPPORTS_DAC_HOST_ONLY; - - m_flags &= ~ALLOCATED; -} - -inline BOOL SBuffer::IsImmutable() const -{ - LIMITED_METHOD_DAC_CONTRACT; - - return (m_flags & IMMUTABLE) != 0; -} - -inline void SBuffer::SetImmutable() -{ - LIMITED_METHOD_CONTRACT; - SUPPORTS_DAC_HOST_ONLY; - - m_flags |= IMMUTABLE; -} - -inline void SBuffer::ClearImmutable() -{ - LIMITED_METHOD_CONTRACT; - SUPPORTS_DAC_HOST_ONLY; - - m_flags &= ~IMMUTABLE; -} - -inline BOOL SBuffer::IsFlag1() const -{ - LIMITED_METHOD_DAC_CONTRACT; - - return (m_flags & FLAG1) != 0; -} - -inline void SBuffer::SetFlag1() -{ - LIMITED_METHOD_DAC_CONTRACT; - - m_flags |= FLAG1; -} - -inline void SBuffer::ClearFlag1() -{ - LIMITED_METHOD_CONTRACT; - - m_flags &= ~FLAG1; -} - -inline BOOL SBuffer::IsFlag2() const -{ - LIMITED_METHOD_CONTRACT; - - return (m_flags & FLAG2) != 0; -} - -inline void SBuffer::SetFlag2() -{ - LIMITED_METHOD_CONTRACT; - - m_flags |= FLAG2; -} - -inline void SBuffer::ClearFlag2() -{ - LIMITED_METHOD_CONTRACT; - - m_flags &= ~FLAG2; -} - -inline BOOL SBuffer::IsFlag3() const -{ - LIMITED_METHOD_DAC_CONTRACT; - - return (m_flags & FLAG3) != 0; -} - -inline void SBuffer::SetFlag3() -{ - LIMITED_METHOD_CONTRACT; - - m_flags |= FLAG3; -} - -inline void SBuffer::ClearFlag3() -{ - LIMITED_METHOD_DAC_CONTRACT; - - m_flags &= ~FLAG3; -} - -inline int SBuffer::GetRepresentationField() const -{ - LIMITED_METHOD_CONTRACT; - SUPPORTS_DAC; - - return (m_flags & REPRESENTATION_MASK); -} - -inline void SBuffer::SetRepresentationField(int value) -{ - CONTRACT_VOID - { - PRECONDITION((value & ~REPRESENTATION_MASK) == 0); - NOTHROW; - GC_NOTRIGGER; - SO_TOLERANT; - SUPPORTS_DAC_HOST_ONLY; - } - CONTRACT_END; - - m_flags &= ~REPRESENTATION_MASK; - m_flags |= value; - - RETURN; -} - -#if _DEBUG -inline BOOL SBuffer::IsOpened() const -{ - LIMITED_METHOD_CONTRACT; - - return (m_flags & OPENED) != 0; -} - -inline void SBuffer::SetOpened() -{ - LIMITED_METHOD_CONTRACT; - - m_flags |= OPENED; -} - -inline void SBuffer::ClearOpened() -{ - LIMITED_METHOD_CONTRACT; - - m_flags &= ~OPENED; -} -#endif - -inline void SBuffer::DebugMoveBuffer(__out_bcount(size) BYTE *to, BYTE *from, COUNT_T size) -{ - CONTRACT_VOID - { - INSTANCE_CHECK; - PRECONDITION(CheckPointer(to, size == 0 ? NULL_OK : NULL_NOT_OK)); - PRECONDITION(CheckPointer(from, size == 0 ? NULL_OK : NULL_NOT_OK)); - PRECONDITION(CheckSize(size)); - NOTHROW; - GC_NOTRIGGER; - SUPPORTS_DAC_HOST_ONLY; - } - CONTRACT_END; - - if (size == 0) // special case - RETURN; - - // Handle overlapping ranges - if (to > from && to < from + size) - CONSISTENCY_CHECK(CheckUnusedBuffer(from + size, (COUNT_T) (to - from))); - else if (to < from && to + size > from) - CONSISTENCY_CHECK(CheckUnusedBuffer(to, (COUNT_T) (from - to))); - else - CONSISTENCY_CHECK(CheckUnusedBuffer(to, size)); - - memmove(to, from, size); - - // Handle overlapping ranges - if (to > from && to < from + size) - DebugStompUnusedBuffer(from, (COUNT_T) (to - from)); - else if (to < from && to + size > from) - DebugStompUnusedBuffer(to + size, (COUNT_T) (from - to)); - else - DebugStompUnusedBuffer(from, size); - - RETURN; -} - -inline void SBuffer::DebugCopyConstructBuffer(__out_bcount(size) BYTE *to, const BYTE *from, COUNT_T size) -{ - CONTRACT_VOID - { - INSTANCE_CHECK; - PRECONDITION(CheckPointer(to, size == 0 ? NULL_OK : NULL_NOT_OK)); - PRECONDITION(CheckPointer(from, size == 0 ? NULL_OK : NULL_NOT_OK)); - PRECONDITION(CheckSize(size)); - NOTHROW; - GC_NOTRIGGER; - SUPPORTS_DAC_HOST_ONLY; - } - CONTRACT_END; - - if (size != 0) { - CONSISTENCY_CHECK(CheckUnusedBuffer(to, size)); - memmove(to, from, size); - } - - RETURN; -} - -inline void SBuffer::DebugConstructBuffer(BYTE *buffer, COUNT_T size) -{ - CONTRACT_VOID - { - INSTANCE_CHECK; - PRECONDITION(CheckPointer(buffer, size == 0 ? NULL_OK : NULL_NOT_OK)); - PRECONDITION(CheckSize(size)); - NOTHROW; - GC_NOTRIGGER; - SUPPORTS_DAC; - DEBUG_ONLY; - } - CONTRACT_END; - - if (size != 0) { - CONSISTENCY_CHECK(CheckUnusedBuffer(buffer, size)); - } - - RETURN; -} - -inline void SBuffer::DebugDestructBuffer(BYTE *buffer, COUNT_T size) -{ - CONTRACT_VOID - { - INSTANCE_CHECK; - PRECONDITION(CheckPointer(buffer, size == 0 ? NULL_OK : NULL_NOT_OK)); - PRECONDITION(CheckSize(size)); - NOTHROW; - GC_NOTRIGGER; - DEBUG_ONLY; - SUPPORTS_DAC_HOST_ONLY; - } - CONTRACT_END; - - if (size != 0) - { - DebugStompUnusedBuffer(buffer, size); - } - - RETURN; -} - -static const BYTE GARBAGE_FILL_CHARACTER = '$'; - -extern const DWORD g_garbageFillBuffer[]; - -inline void SBuffer::DebugStompUnusedBuffer(BYTE *buffer, COUNT_T size) -{ - CONTRACT_VOID - { - INSTANCE_CHECK; - PRECONDITION(CheckPointer(buffer, size == 0 ? NULL_OK : NULL_NOT_OK)); - PRECONDITION(CheckSize(size)); - NOTHROW; - GC_NOTRIGGER; - CANNOT_TAKE_LOCK; - DEBUG_ONLY; - SUPPORTS_DAC_HOST_ONLY; - } - CONTRACT_END; - -#if _DEBUG - if (!IsImmutable() - || buffer < m_buffer || buffer > m_buffer + m_allocation) // Allocating a new buffer - { - // Whack the memory - if (size > GARBAGE_FILL_BUFFER_SIZE) size = GARBAGE_FILL_BUFFER_SIZE; - memset(buffer, GARBAGE_FILL_CHARACTER, size); - } -#endif - - RETURN; -} - -#if _DEBUG -inline BOOL SBuffer::EnsureGarbageCharOnly(const BYTE *buffer, COUNT_T size) -{ - LIMITED_METHOD_CONTRACT; - BOOL bRet = TRUE; - if (size > GARBAGE_FILL_BUFFER_SIZE) - { - size = GARBAGE_FILL_BUFFER_SIZE; - } - if (bRet && size > 0) - { - bRet &= (memcmp(buffer, g_garbageFillBuffer, size) == 0); - } - return bRet; -} -#endif - -inline CHECK SBuffer::CheckUnusedBuffer(const BYTE *buffer, COUNT_T size) const -{ - WRAPPER_NO_CONTRACT; - // This check is too expensive. -#if 0 // _DEBUG - if (!IsImmutable() - || buffer < m_buffer || buffer > m_buffer + m_allocation) // Allocating a new buffer - { - if (!SBuffer::EnsureGarbageCharOnly(buffer, size)) - { - CHECK_FAIL("Overwrite of unused buffer region found"); - } - } -#endif - CHECK_OK; -} - -inline CHECK SBuffer::Check() const -{ - WRAPPER_NO_CONTRACT; - CHECK(CheckBufferClosed()); - CHECK_OK; -} - -inline CHECK SBuffer::Invariant() const -{ - LIMITED_METHOD_CONTRACT; - - CHECK_OK; -} - -inline CHECK SBuffer::InternalInvariant() const -{ - WRAPPER_NO_CONTRACT; - CHECK(m_size <= m_allocation); - - CHECK(CheckUnusedBuffer(m_buffer + m_size, m_allocation - m_size)); - - if (IsAllocated()) - CHECK(CheckBuffer(m_buffer, m_allocation)); - - CHECK_OK; -} - -inline CHECK SBuffer::CheckBufferClosed() const -{ - WRAPPER_NO_CONTRACT; -#if _DEBUG - CHECK_MSG(!IsOpened(), "Cannot use buffer API while raw open is in progress"); -#endif - CHECK_OK; -} - -inline CHECK SBuffer::CheckSize(COUNT_T size) -{ - LIMITED_METHOD_CONTRACT; - // !todo: add any range checking here - CHECK_OK; -} - -inline CHECK SBuffer::CheckAllocation(COUNT_T size) -{ - LIMITED_METHOD_CONTRACT; - - // !todo: add any range checking here - CHECK_OK; -} - -inline CHECK SBuffer::CheckIteratorRange(const CIterator &i) const -{ - WRAPPER_NO_CONTRACT; - CHECK(i.Check()); - CHECK(i.CheckContainer(this)); - CHECK(i >= Begin()); - CHECK(i < End()); - CHECK_OK; -} - -inline CHECK SBuffer::CheckIteratorRange(const CIterator &i, COUNT_T size) const -{ - WRAPPER_NO_CONTRACT; - CHECK(i.Check()); - CHECK(i.CheckContainer(this)); - CHECK(i >= Begin()); - CHECK(i + size <= End()); - CHECK_OK; -} - -inline SBuffer::Index::Index() -{ - LIMITED_METHOD_DAC_CONTRACT; - - m_ptr = NULL; -} - -inline SBuffer::Index::Index(SBuffer *container, SCOUNT_T index) - : CheckedIteratorBase(container) -{ - LIMITED_METHOD_CONTRACT; - SUPPORTS_DAC_HOST_ONLY; - - m_ptr = container->m_buffer + index; -} - -inline BYTE &SBuffer::Index::GetAt(SCOUNT_T delta) const -{ - LIMITED_METHOD_DAC_CONTRACT; - - return m_ptr[delta]; -} - -inline void SBuffer::Index::Skip(SCOUNT_T delta) -{ - LIMITED_METHOD_CONTRACT; - SUPPORTS_DAC_HOST_ONLY; - - m_ptr += delta; -} - -inline SCOUNT_T SBuffer::Index::Subtract(const Index &i) const -{ - LIMITED_METHOD_CONTRACT; - SUPPORTS_DAC_HOST_ONLY; - - return (SCOUNT_T) (m_ptr - i.m_ptr); -} - -inline CHECK SBuffer::Index::DoCheck(SCOUNT_T delta) const -{ - WRAPPER_NO_CONTRACT; -#if _DEBUG - CHECK(m_ptr + delta >= GetContainerDebug()->m_buffer); - CHECK(m_ptr + delta < GetContainerDebug()->m_buffer + GetContainerDebug()->m_size); -#endif - CHECK_OK; -} - -inline void SBuffer::Index::Resync(const SBuffer *buffer, BYTE *value) const -{ - CONTRACT_VOID - { - // INSTANCE_CHECK - Iterator is out of sync with its object now by definition - POSTCONDITION(CheckPointer(this)); - PRECONDITION(CheckPointer(buffer)); - NOTHROW; - GC_NOTRIGGER; - SUPPORTS_DAC_HOST_ONLY; - } - CONTRACT_END; - - const_cast(this)->CheckedIteratorBase::Resync(const_cast(buffer)); - const_cast(this)->m_ptr = value; - - RETURN; -} - -#ifdef _MSC_VER -#pragma warning(pop) -#endif // _MSC_VER - -#endif // _SBUFFER_INL_ diff --git a/src/inc/securityutil.h b/src/inc/securityutil.h deleted file mode 100644 index 2278495bc..000000000 --- a/src/inc/securityutil.h +++ /dev/null @@ -1,53 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - - -#ifndef SECURITYUTIL_H -#define SECURITYUTIL_H - -#include "winnt.h" - -// Security utility class. This is currently used by the debugger right-side and dbgshim to figure out the -// SECURITY_ATTRIBUTES to use on various IPC objects (named events, etc.). -// This is pretty debugger specific, and so perhaps doesn't actually belong in utilcode (that's just the most -// convenient way to share it between mscordbi and dbgshim.dll). This is also a pretty big mess. All of -// this ACL craziness is already gone in Arrowhead, so it's not a high priority to clean this up. -class SecurityUtil -{ -public: - - // - // This will generate ACL containing the current process and - // an allowed ACE on the target process of the given pid. - // - // Host should free returned *ppACL by calling FreeACL - // - static HRESULT GetACLOfPid(DWORD pid, PACL *ppACL); - - static void FreeACL(PACL pACL); - - static HRESULT GetMandatoryLabelFromProcess(HANDLE hProcess, LPBYTE * ppbLabel); - static DWORD * GetIntegrityLevelFromMandatorySID(PSID psidIntegrityLevelLabel); - - // instance functions. SecurityUtil is used to minimized memory allocation when converting - // pACL to SECURITY_ATTRIBUTES - // The needed memory to hold SECURITY_ATTRIBUTES and SECURITY_DESCRIPTOR are embedded - // in the SecurityUtil instance. - // - SecurityUtil(PACL pACL); - ~SecurityUtil(); - HRESULT Init(); - HRESULT Init(HANDLE pid); - HRESULT GetSA(SECURITY_ATTRIBUTES **PPSA); -private: - HRESULT SetSecurityDescriptorMandatoryLabel(PSID psidIntegrityLevelLabel); - SECURITY_ATTRIBUTES m_SA; - SECURITY_DESCRIPTOR m_SD; - PACL m_pACL; - // Saved by SetSecurityDescriptorMandatoryLabel so that the memory can be deleted properly - PACL m_pSacl; - bool m_fInitialized; -}; - -#endif // !SECURITYUTIL_H diff --git a/src/inc/securitywrapper.h b/src/inc/securitywrapper.h deleted file mode 100644 index a14d90a92..000000000 --- a/src/inc/securitywrapper.h +++ /dev/null @@ -1,111 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -//***************************************************************************** -// File: SecurityWrapper.h -// -// Wrapper around Win32 Security functions -// -//***************************************************************************** - - -#ifndef _SECURITY_WRAPPER_H -#define _SECURITY_WRAPPER_H - -// This file should not even be included on Rotor. - -//----------------------------------------------------------------------------- -// Wrapper around a PSID. -// This class does not own the memory. -//----------------------------------------------------------------------------- -class Sid -{ -public: - // Initial the Sid wrapper around an existing SID. - Sid(PSID pSid); - static bool Equals(const Sid & a, const Sid & b) { return Equals(a.m_pSid, b.m_pSid); } - static bool Equals(const Sid & a, PSID b) { return Equals(a.m_pSid, b); } - static bool Equals(PSID a, const Sid & b) { return Equals(a, b.m_pSid); } - static bool Equals(PSID a, PSID b); - - PSID RawSid() { return m_pSid; } -protected: - // Pointer to Sid buffer. We don't owner the data. - PSID m_pSid; -}; - -//----------------------------------------------------------------------------- -// Wrapper around a PSID with buffer. -//----------------------------------------------------------------------------- -class SidBuffer -{ -public: - SidBuffer(); - ~SidBuffer(); - - // Get the underlying sid - Sid GetSid(); - - // Do we not have a sid? This will be true if init fails. - bool IsNull() { return m_pBuffer == NULL; } - - // Go to definitions to see detailed comments - HRESULT InitFromProcessNoThrow(DWORD pid); - void InitFromProcess(DWORD pid); // throws - HRESULT InitFromProcessUserNoThrow(DWORD pid); - void InitFromProcessUser(DWORD pid); // throws - HRESULT InitFromProcessAppContainerSidNoThrow(DWORD pid); - -protected: - BYTE * m_pBuffer; -}; - -#ifndef FEATURE_PAL - -//----------------------------------------------------------------------------- -// Access Control List. -//----------------------------------------------------------------------------- -class Dacl -{ -public: - Dacl(PACL pAcl); - - SIZE_T GetAceCount(); - ACE_HEADER * GetAce(SIZE_T dwAceIndex); -protected: - PACL m_acl; -}; - -//----------------------------------------------------------------------------- -// Represent a win32 SECURITY_DESCRIPTOR object. -// (Note there's a "SecurityDescriptor" class in the VM for managed goo, -// so we prefix this with "Win32" to avoid a naming collision.) -//----------------------------------------------------------------------------- -class Win32SecurityDescriptor -{ -public: - Win32SecurityDescriptor(); - ~Win32SecurityDescriptor(); - - HRESULT InitFromHandleNoThrow(HANDLE h); - void InitFromHandle(HANDLE h); // throws - - // Gets the owner SID from this SecurityDescriptor. - HRESULT GetOwnerNoThrow( PSID* ppSid ); - Sid GetOwner(); // throws - Dacl GetDacl(); // throws - -protected: - PSECURITY_DESCRIPTOR m_pDesc; -}; - -#endif // FEATURE_PAL - -//----------------------------------------------------------------------------- -// Check if the handle owner belongs to either the process specified by the pid -// or the current process. This lets us know if the handle is spoofed. -//----------------------------------------------------------------------------- -bool IsHandleSpoofed(HANDLE handle, DWORD pid); - - -#endif // _SECURITY_WRAPPER_H diff --git a/src/inc/shash.h b/src/inc/shash.h deleted file mode 100644 index 1650ca15b..000000000 --- a/src/inc/shash.h +++ /dev/null @@ -1,1106 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - - -#ifndef _SHASH_H_ -#define _SHASH_H_ - -#include "utilcode.h" // for string hash functions -#include "clrtypes.h" -#include "check.h" -#include "iterator.h" - -// SHash is a templated closed chaining hash table of pointers. It provides -// for multiple entries under the same key, and also for deleting elements. - -// Synchronization: -// Synchronization requirements depend on use. There are several properties to take into account: -// -// - Lookups may be asynchronous with each other -// - Lookups must be exclusive with Add operations -// (@todo: this can be remedied by delaying destruction of old tables during reallocation, e.g. during GC) -// - Remove operations may be asynchronous with Lookup/Add, unless elements are also deallocated. (In which -// case full synchronization is required) - -// Common "gotchas": -// - The Add method never replaces an element. The new element will be added even if an element with the same -// key is already present. If you don't want this, use AddOrReplace. -// - You need special sentinel values for the element to represent Null and Deleted. 0 and -1 are the default -// choices but you will need something else if elements can legally have any of these two values. -// - Deriving directly from the general purpose classes (such as SHash itself) requires implementing a -// TRAITS class which can be daunting. Consider using one of the specialized classes (e.g. WStringSHash) first. - -// A SHash is templated by a class of TRAITS. These traits define the various specifics of the -// particular hash table. -// The required traits are: -// -// element_t Type of elements in the hash table. These elements are stored -// by value in the hash table. Elements must look more or less -// like primitives - they must support assignment relatively -// efficiently. There are 2 required sentinel values: -// Null and Deleted (described below). (Note that element_t is -// very commonly a pointer type.) -// -// The key must be derivable from the element; if your -// table's keys are independent of the stored values, element_t -// should be a key/value pair. -// -// key_t Type of the lookup key. The key is used for identity -// comparison between elements, and also as a key for lookup. -// This is also used by value and should support -// efficient assignment. -// -// count_t integral type for counts. Typically inherited by default -// Traits (COUNT_T). -// -// static key_t GetKey(const element_t &e) Get key from element. Should be stable for a given e. -// static BOOL Equals(key_t k1, key_t k2) Compare 2 keys for equality. Again, should be stable. -// static count_t Hash(key_t k) Compute hash from a key. For efficient operation, the hashes -// for a set of elements should have random uniform distribution. -// -// static const bool s_NoThrow TRUE if GetKey, Equals, and hash are NOTHROW functions. -// Affects the THROWS clauses of several SHash functions. -// (Note that the Null- and Deleted-related functions below -// are not affected by this and must always be NOTHROW.) -// -// static element_t Null() Return the Null sentinal value. May be inherited from -// default traits if it can be assigned from 0. -// static element_t Deleted() Return the Deleted sentinal value. May be inherited from the -// default traits if it can be assigned from -1. -// static const bool IsNull(const ELEMENT &e) Compare element with Null sentinal value. May be inherited from -// default traits if it can be assigned from 0. -// static const bool IsDeleted(const ELEMENT &e) Compare element with Deleted sentinal value. May be inherited from the -// default traits if it can be assigned from -1. -// -// static void OnDestructPerEntryCleanupAction(ELEMENT& e) Called on every element when in hashtable destructor. -// s_DestructPerEntryCleanupAction must be set to true if implemented. -// -// s_growth_factor_numerator -// s_growth_factor_denominator Factor to grow allocation (numerator/denominator). -// Typically inherited from default traits (3/2) -// -// s_density_factor_numerator -// s_density_factor_denominator Maxium occupied density of table before growth -// occurs (num/denom). Typically inherited (3/4). -// -// s_minimum_allocation Minimum table allocation count (size on first growth.) It is -// probably preferable to call Reallocate on initialization rather -// than override his from the default traits. (7) -// -// s_supports_remove Set to false for a slightly faster implementation that does not -// support deletes. There is a downside to the s_supports_remove flag, -// in that there may be more copies of the template instantiated through -// the system as different variants are used. -// -// s_DestructPerEntryCleanupAction Set to true if OnDestructPerEntryCleanupAction has non-empty implementation. -// -// DefaultHashTraits provides defaults for seldomly customized values in traits classes. - -template < typename ELEMENT > -class DefaultSHashTraits -{ - public: - typedef COUNT_T count_t; - typedef ELEMENT element_t; - typedef DPTR(element_t) PTR_element_t; // by default SHash is DAC-aware. For RS - // only SHash use NonDacAwareSHashTraits - // (which typedefs element_t* PTR_element_t) - - static const COUNT_T s_growth_factor_numerator = 3; - static const COUNT_T s_growth_factor_denominator = 2; - - static const COUNT_T s_density_factor_numerator = 3; - static const COUNT_T s_density_factor_denominator = 4; - - static const COUNT_T s_minimum_allocation = 7; - - static const bool s_supports_remove = true; - - static const ELEMENT Null() { return (const ELEMENT) 0; } - static const ELEMENT Deleted() { return (const ELEMENT) -1; } - static bool IsNull(const ELEMENT &e) { return e == (const ELEMENT) 0; } - static bool IsDeleted(const ELEMENT &e) { return e == (const ELEMENT) -1; } - - static inline void OnDestructPerEntryCleanupAction(const ELEMENT& e) { /* Do nothing */ } - static const bool s_DestructPerEntryCleanupAction = false; - - static const bool s_NoThrow = true; - - // No defaults - must specify: - // - // typedef key_t; - // static key_t GetKey(const element_t &i); - // static BOOL Equals(key_t k1, key_t k2); - // static count_t Hash(key_t k); -}; - -// Hash table class definition - -template -class SHash : public TRAITS - , private noncopyable -{ - friend class VerifyLayoutsMD; // verifies class layout doesn't accidentally change - - public: - // explicitly declare local typedefs for these traits types, otherwise - // the compiler may get confused - typedef typename TRAITS::element_t element_t; - typedef typename TRAITS::PTR_element_t PTR_element_t; - typedef typename TRAITS::key_t key_t; - typedef typename TRAITS::count_t count_t; - - class Index; - friend class Index; - class Iterator; - - class KeyIndex; - friend class KeyIndex; - class KeyIterator; - - // Constructor/destructor. SHash tables always start out empty, with no - // allocation overhead. Call Reallocate to prime with an initial size if - // desired. - - SHash(); - - ~SHash(); - - // Lookup an element in the table by key. Returns NULL if no element in the table - // has the given key. Note that multiple entries for the same key may be stored - - // this will return the first element added. Use KeyIterator to find all elements - // with a given key. - - element_t Lookup(key_t key) const; - - // Pointer-based flavor of Lookup (allows efficient access to tables of structures) - - const element_t* LookupPtr(key_t key) const; - - // Add an element to the hash table. This will never replace an element; multiple - // elements may be stored with the same key. - - void Add(const element_t &element); - - // Add a new element to the hash table, if no element with the same key is already - // there. Otherwise, it will replace the existing element. This has the effect of - // updating an element rather than adding a duplicate. - void AddOrReplace(const element_t & element); - - // Remove the first element matching the key from the hash table. - - void Remove(key_t key); - - // Remove the specific element. - - void Remove(Iterator& i); - void Remove(KeyIterator& i); - - // Pointer-based flavor of Remove (allows efficient access to tables of structures) - - void RemovePtr(element_t * element); - - // Remove all elements in the hashtable - - void RemoveAll(); - - // Begin and End pointers for iteration over entire table. - - Iterator Begin() const; - Iterator End() const; - - // Begin and End pointers for iteration over all elements with a given key. - - KeyIterator Begin(key_t key) const; - KeyIterator End(key_t key) const; - - // Return the number of elements currently stored in the table - - count_t GetCount() const; - - // Resizes a hash table for growth. The new size is computed based - // on the current population, growth factor, and maximum density factor. - - void Grow(); - - // Reallocates a hash table to a specific size. The size must be big enough - // to hold all elements in the table appropriately. - // - // Note that the actual table size must always be a prime number; the number - // passed in will be upward adjusted if necessary. - - void Reallocate(count_t newTableSize); - - // Makes a call on the Functor for each element in the hash table, passing - // the element as an argument. Functor is expected to look like this: - // - // class Functor - // { - // public: - // void operator() (element_t &element) { ... } - // } - - template void ForEach(Functor &functor); - - private: - - // See if it is OK to grow the hash table by one element. If not, reallocate - // the hash table. - BOOL CheckGrowth(); - - // See if it is OK to grow the hash table by one element. If not, allocate new - // hash table and return it together with its size *pcNewSize (used by code:AddPhases). - // Returns NULL if there already is space for one element. - element_t * CheckGrowth_OnlyAllocateNewTable(count_t * pcNewSize); - - // Allocates new resized hash table for growth. Does not update the hash table on the object. - // The new size is computed based on the current population, growth factor, and maximum density factor. - element_t * Grow_OnlyAllocateNewTable(count_t * pcNewSize); - - // Utility function to allocate new table (does not copy the values into it yet). Returns the size of new table in - // *pcNewTableSize (finds next prime). - // Phase 1 of code:Reallocate - it is split to support code:AddPhases. - element_t * AllocateNewTable(count_t requestedSize, count_t * pcNewTableSize); - - // Utility function to replace old table with newly allocated table (as allocated by - // code:AllocateNewTable). Copies all 'old' values into the new table first. - // Returns the old table. Caller is expected to delete it (via code:DeleteOldTable). - // Phase 2 of code:Reallocate - it is split to support code:AddPhases. - element_t * ReplaceTable(element_t * newTable, count_t newTableSize); - - // Utility function to delete old table (as returned by code:ReplaceTable). - // Phase 3 of code:Reallocate - it is split to support code:AddPhases. - void DeleteOldTable(element_t * oldTable); - - // Utility function that does not call code:CheckGrowth. - // Add an element to the hash table. This will never replace an element; multiple - // elements may be stored with the same key. - void Add_GrowthChecked(const element_t & element); - - // Utility function to add a new element to the hash table. Note that - // it is perfectly fine for the element to be a duplicate - if so it - // is added an additional time. Returns TRUE if a new empty spot was used; - // FALSE if an existing deleted slot. - static BOOL Add(element_t *table, count_t tableSize, const element_t &element); - - // Utility function to add a new element to the hash table, if no element with the same key - // is already there. Otherwise, it will replace the existing element. This has the effect of - // updating an element rather than adding a duplicate. - void AddOrReplace(element_t *table, count_t tableSize, const element_t &element); - - // Utility function to find the first element with the given key in - // the hash table. - - static const element_t* Lookup(PTR_element_t table, count_t tableSize, key_t key); - - // Utility function to remove the first element with the given key - // in the hash table. - - void Remove(element_t *table, count_t tableSize, key_t key); - - // Utility function to remove the specific element. - - void RemoveElement(element_t *table, count_t tableSize, element_t *element); - - // Index for whole table iterator. This is also the base for the keyed iterator. - - public: - - class Index -#ifdef _DEBUG - // CheckedIteratorBase is a no-op in RET builds. having it as an empty base-class - // causes differences in the sizeof(SHash::Iterator) in DAC vs. non-DAC builds. - // avoid the issue by not specifying it as a base class in RET builds - : public CheckedIteratorBase< SHash > -#endif - { - friend class SHash; - friend class Iterator; - friend class Enumerator; - - // The methods implementation has to be here for portability - // Some compilers won't compile the separate implementation in shash.inl - protected: - - PTR_element_t m_table; - count_t m_tableSize; - count_t m_index; - - - Index(const SHash *hash, BOOL begin) - : m_table(hash->m_table), - m_tableSize(hash->m_tableSize), - m_index(begin ? 0 : m_tableSize) - { - LIMITED_METHOD_CONTRACT; - } - - const element_t &Get() const - { - LIMITED_METHOD_CONTRACT; - - return m_table[m_index]; - } - - void First() - { - LIMITED_METHOD_CONTRACT; - - if (m_index < m_tableSize) - if (TRAITS::IsNull(m_table[m_index]) || TRAITS::IsDeleted(m_table[m_index])) - Next(); - } - - void Next() - { - LIMITED_METHOD_CONTRACT; - - if (m_index >= m_tableSize) - return; - - for (;;) - { - m_index++; - if (m_index >= m_tableSize) - break; - if (!TRAITS::IsNull(m_table[m_index]) && !TRAITS::IsDeleted(m_table[m_index])) - break; - } - } - - bool Equal(const Index &i) const - { - LIMITED_METHOD_CONTRACT; - - return i.m_index == m_index; - } - - CHECK DoCheck() const - { - CHECK_OK; - } - }; - - class Iterator : public Index, public Enumerator - { - friend class SHash; - - public: - Iterator(const SHash *hash, BOOL begin) - : Index(hash, begin) - { - } - }; - - // Index for iterating elements with a given key. - // - // Note that the m_index field - // is artificially bumped to m_tableSize when the end of iteration is reached. - // This allows a canonical End iterator to be used. - - class KeyIndex : public Index - { - friend class SHash; - friend class KeyIterator; - friend class Enumerator; - - // The methods implementation has to be here for portability - // Some compilers won't compile the separate implementation in shash.inl - protected: - key_t m_key; - count_t m_increment; - - KeyIndex(const SHash *hash, BOOL begin) - : Index(hash, begin), - m_increment(0) - { - LIMITED_METHOD_CONTRACT; - } - - void SetKey(key_t key) - { - LIMITED_METHOD_CONTRACT; - - if (Index::m_tableSize > 0) - { - m_key = key; - count_t hash = TRAITS::Hash(key); - - this->m_index = hash % this->m_tableSize; - m_increment = (hash % (this->m_tableSize-1)) + 1; - - // Find first valid element - if (TRAITS::IsNull(this->m_table[this->m_index])) - this->m_index = this->m_tableSize; - else if (TRAITS::IsDeleted(this->m_table[this->m_index]) - || !TRAITS::Equals(m_key, TRAITS::GetKey(this->m_table[this->m_index]))) - Next(); - } - } - - void Next() - { - LIMITED_METHOD_CONTRACT; - - while (TRUE) - { - this->m_index += m_increment; - if (this->m_index >= this->m_tableSize) - this->m_index -= this->m_tableSize; - - if (TRAITS::IsNull(this->m_table[this->m_index])) - { - this->m_index = this->m_tableSize; - break; - } - - if (!TRAITS::IsDeleted(this->m_table[this->m_index]) - && TRAITS::Equals(m_key, TRAITS::GetKey(this->m_table[this->m_index]))) - { - break; - } - } - } - }; - - class KeyIterator : public KeyIndex, public Enumerator - { - friend class SHash; - - public: - - operator Iterator &() - { - return *(Iterator*)this; - } - - operator const Iterator &() - { - return *(const Iterator*)this; - } - - KeyIterator(const SHash *hash, BOOL begin) - : KeyIndex(hash, begin) - { - } - }; - - // Wrapper and holder for adding an element to the hash table. Useful for Add operations that have to happen - // under a rare lock that does not allow call out into host. - // There are 3 phases: - // 1. code:PreallocateForAdd ... Can allocate memory (calls into host). - // 2. code:Add ... Adds one element (does NOT call into host). - // or code:AddNothing_PublishPreallocatedTable ... Publishes the pre-allocated memory from step #1 (if any). - // 3. code:DeleteOldTable (or destructor) ... Can delete the old memory (calls into host). - // Example: - // CrstHolder lockAdd(&crstLockForAdd); // Serialize all Add operations. - // HostAssemblyMap::AddPhases addCall; - // addCall.PreallocateForAdd(&shash); // 1. Allocates memory for one Add call (if needed). addCall serves as holder for the allocated memory. - // { - // // We cannot call out into host from ForbidSuspend region (i.e. no allocations/deallocations). - // ForbidSuspendThreadHolder suspend; // Required by the 'special' read-lock - // { - // CrstHolder lock(&crstLock); - // if (some_condition) - // { // 2a. Add item. This may replace SHash inner table with the one pre-allocated in step 1. - // addCall.Add(shashItem); - // } - // else - // { // 2b. Skip adding item. This may replace SHash inner table with the one pre-allocated in step 1. - // addCall.AddNothing_PublishPreallocatedTable(); - // } - // } - // } - // addCall.DeleteOldTable(); // 3. Cleanup old table memory from shash (if it was replaced by pre-allocated table in step 2). - // // Note: addCall destructor would take care of deleting the memory as well. - class AddPhases - { - public: - AddPhases(); - ~AddPhases(); - - // Prepares object for one call to code:Add. Pre-allocates new table memory if needed, does not publish - // the table yet (it is kept ready only in this holder for call to code:Add). - // Calls out into host. - void PreallocateForAdd(SHash * pHash); - - // Add an element to the hash table. This will never replace an element; multiple elements may be stored - // with the same key. - // Will use/publish pre-allocated memory from code:PreallocateForAdd. - // Does not call out into host. - // Only one Add* method can be called once per object! (Create a new object for each call) - void Add(const element_t & element); - - // Element will not be added to the hash table. - // Will use/publish pre-allocated memory from code:PreallocateForAdd. - // Does not call out into host. - // Only one Add* method can be called once per object! (Create a new object for each call) - void AddNothing_PublishPreallocatedTable(); - - // Deletes old table if it was replaced by call to code:Add or code:AddNothing_PublishPreallocatedTable. - // Calls out into host. - void DeleteOldTable(); - - private: - SHash * m_pHash; - element_t * m_newTable; - count_t m_newTableSize; - element_t * m_oldTable; - - #ifdef _DEBUG - PTR_element_t dbg_m_table; - count_t dbg_m_tableSize; - count_t dbg_m_tableCount; - count_t dbg_m_tableOccupied; - count_t dbg_m_tableMax; - BOOL dbg_m_fAddCalled; - #endif //_DEBUG - }; // class SHash::AddPhases - - // Adds an entry to the hash table according to the guidelines above for - // avoiding a callout to the host while the read lock is held. - // Returns true if elem was added to the map, otherwise false. - // When elem was not added (false is returned), and if ppStoredElem is non-null, - // then it is set to point to the value in the map. - template - bool CheckAddInPhases( - element_t const & elem, - LockT & lock, - AddLockT & addLock, - IUnknown * addRefObject = nullptr); - - private: - - // Test for prime number. - static BOOL IsPrime(COUNT_T number); - - // Find the next prime number >= the given value. - - static COUNT_T NextPrime(COUNT_T number); - - // Instance members - - PTR_element_t m_table; // pointer to table - count_t m_tableSize; // allocated size of table - count_t m_tableCount; // number of elements in table - count_t m_tableOccupied; // number, includes deleted slots - count_t m_tableMax; // maximum occupied count before reallocating -}; // class SHash - -// disables support for DAC marshaling. Useful for defining right-side only SHashes -template -class NonDacAwareSHashTraits : public PARENT -{ -public: - typedef typename PARENT::element_t element_t; - typedef element_t * PTR_element_t; -}; - -// disables support for removing elements - produces slightly faster implementation - -template -class NoRemoveSHashTraits : public PARENT -{ -public: - // explicitly declare local typedefs for these traits types, otherwise - // the compiler may get confused - typedef typename PARENT::element_t element_t; - typedef typename PARENT::count_t count_t; - - static const bool s_supports_remove = false; - static const element_t Deleted() { UNREACHABLE(); } - static bool IsDeleted(const element_t &e) { LIMITED_METHOD_DAC_CONTRACT; return false; } -}; - -// PtrHashTraits is a template to provides useful defaults for pointer hash tables -// It relies on methods GetKey and Hash defined on ELEMENT - -template -class PtrSHashTraits : public DefaultSHashTraits -{ - public: - - // explicitly declare local typedefs for these traits types, otherwise - // the compiler may get confused - typedef DefaultSHashTraits PARENT; - typedef typename PARENT::element_t element_t; - typedef typename PARENT::count_t count_t; - - typedef KEY key_t; - - static key_t GetKey(const element_t &e) - { - WRAPPER_NO_CONTRACT; - return e->GetKey(); - } - static BOOL Equals(key_t k1, key_t k2) - { - LIMITED_METHOD_CONTRACT; - return k1 == k2; - } - static count_t Hash(key_t k) - { - WRAPPER_NO_CONTRACT; - return ELEMENT::Hash(k); - } -}; - -template -class PtrSHash : public SHash< PtrSHashTraits > -{ -}; - -template -class PtrSHashWithCleanupTraits - : public PtrSHashTraits -{ -public: - void OnDestructPerEntryCleanupAction(ELEMENT * elem) - { - delete elem; - } - static const bool s_DestructPerEntryCleanupAction = true; -}; - -// a class that automatically deletes data referenced by the pointers (so effectively it takes ownership of the data) -// since I was too lazy to implement Remove() APIs properly, removing entries is disallowed -template -class PtrSHashWithCleanup : public SHash< NoRemoveSHashTraits< PtrSHashWithCleanupTraits > > -{ -}; - -// Provides case-sensitive comparison and hashing functionality through static -// and functor object methods. Can be instantiated with CHAR or WCHAR. -template -struct CaseSensitiveStringCompareHash -{ -private: - typedef CharT const * str_t; - - static size_t _strcmp(CHAR const *left, CHAR const *right) - { - return ::strcmp(left, right); - } - - static size_t _strcmp(WCHAR const *left, WCHAR const *right) - { - return ::wcscmp(left, right); - } - - static size_t _hash(CHAR const *str) - { - return HashStringA(str); - } - - static size_t _hash(WCHAR const *str) - { - return HashString(str); - } - -public: - static size_t compare(str_t left, str_t right) - { - return _strcmp(left, right); - } - - size_t operator()(str_t left, str_t right) - { - return compare(left, right); - } - - static size_t hash(str_t str) - { - return _hash(str); - } - - size_t operator()(str_t str) - { - return hash(str); - } -}; - -// Provides case-insensitive comparison and hashing functionality through static -// and functor object methods. Can be instantiated with CHAR or WCHAR. -template -struct CaseInsensitiveStringCompareHash -{ -private: - typedef CharT const * str_t; - - static size_t _strcmp(str_t left, str_t right) - { - return ::SString::_tstricmp(left, right); - } - - static size_t _hash(CHAR const *str) - { - return HashiStringA(str); - } - - static size_t _hash(WCHAR const *str) - { - return HashiString(str); - } - -public: - static size_t compare(str_t left, str_t right) - { - return _strcmp(left, right); - } - - size_t operator()(str_t left, str_t right) - { - return compare(left, right); - } - - static size_t hash(str_t str) - { - return _hash(str); - } - - size_t operator()(str_t str) - { - return hash(str); - } -}; - -// StringSHashTraits is a traits class useful for string-keyed -// pointer hash tables. - -template > -class StringSHashTraits : public PtrSHashTraits -{ -public: - // explicitly declare local typedefs for these traits types, otherwise - // the compiler may get confused - typedef PtrSHashTraits PARENT; - typedef typename PARENT::element_t element_t; - typedef typename PARENT::key_t key_t; - typedef typename PARENT::count_t count_t; - - static BOOL Equals(key_t k1, key_t k2) - { - LIMITED_METHOD_CONTRACT; - - if (k1 == NULL && k2 == NULL) - return TRUE; - if (k1 == NULL || k2 == NULL) - return FALSE; - return ComparerT::compare(k1, k2) == 0; - } - static count_t Hash(key_t k) - { - LIMITED_METHOD_CONTRACT; - - if (k == NULL) - return 0; - else - return (count_t)ComparerT::hash(k); - } -}; - -template // Could use IUnknown but would rather take advantage of C++ type checking -struct StringHashElement -{ - const CharT *GetKey() - { - return String; - } - - COMINTERFACE *Object; - CharT *String; -}; - -template > -class StringHashWithCleanupTraits : public StringSHashTraits, CharT, ComparerT> -{ -public: - void OnDestructPerEntryCleanupAction(StringHashElement * e) - { - if (e->String != NULL) - { - delete[] e->String; - } - - if (e->Object != NULL) - { - e->Object->Release(); - } - } - static const bool s_DestructPerEntryCleanupAction = true; -}; - -template > -class StringSHashWithCleanup : public SHash< StringHashWithCleanupTraits > -{ -}; - -template -class StringSHash : public SHash< StringSHashTraits > -{ -}; - -template -class WStringSHash : public SHash< StringSHashTraits > -{ -}; - -template -class SStringSHashTraits : public PtrSHashTraits -{ - public: - typedef PtrSHashTraits PARENT; - typedef typename PARENT::element_t element_t; - typedef typename PARENT::key_t key_t; - typedef typename PARENT::count_t count_t; - - static const bool s_NoThrow = false; - - static BOOL Equals(const key_t &k1, const key_t &k2) - { - WRAPPER_NO_CONTRACT; - return k1.Equals(k2); - } - static count_t Hash(const key_t &k) - { - WRAPPER_NO_CONTRACT; - return k.Hash(); - } -}; - -template -class SStringSHash : public SHash< SStringSHashTraits > -{ -}; - -template -class SetSHashTraits : public DefaultSHashTraits -{ -public: - // explicitly declare local typedefs for these traits types, otherwise - // the compiler may get confused - typedef typename DefaultSHashTraits::element_t element_t; - typedef typename DefaultSHashTraits::count_t count_t; - - typedef ELEMENT key_t; - - static key_t GetKey(element_t e) - { - LIMITED_METHOD_CONTRACT; - return e; - } - static BOOL Equals(key_t k1, key_t k2) - { - LIMITED_METHOD_CONTRACT; - return k1 == k2; - } - static count_t Hash(key_t k) - { - LIMITED_METHOD_CONTRACT; - return (count_t)(size_t)k; - } -}; - -template > > -class SetSHash : public SHash< TRAITS > -{ - typedef SHash PARENT; - -public: - BOOL Contains(ELEMENT key) const - { - return PARENT::LookupPtr(key) != NULL; - } -}; - -template -class PtrSetSHashTraits : public SetSHashTraits -{ - public: - - // explicitly declare local typedefs for these traits types, otherwise - // the compiler may get confused - typedef SetSHashTraits PARENT; - typedef typename PARENT::element_t element_t; - typedef typename PARENT::key_t key_t; - typedef typename PARENT::count_t count_t; - - static count_t Hash(key_t k) - { - WRAPPER_NO_CONTRACT; - return (count_t)(size_t)k >> 2; - } -}; - -template -class DeleteElementsOnDestructSHashTraits : public PARENT_TRAITS -{ -public: - static inline void OnDestructPerEntryCleanupAction(typename PARENT_TRAITS::element_t e) - { - delete e; - } - static const bool s_DestructPerEntryCleanupAction = true; -}; - -#if !defined(CC_JIT) // workaround: Key is redefined in JIT64 - -template -class KeyValuePair { - KEY key; - VALUE value; - -public: - KeyValuePair() - { - } - - KeyValuePair(const KEY& k, const VALUE& v) - : key(k), value(v) - { - } - - KEY const & Key() const - { - LIMITED_METHOD_CONTRACT; - return key; - } - - VALUE const & Value() const - { - LIMITED_METHOD_CONTRACT; - return value; - } -}; - -template -class MapSHashTraits : public DefaultSHashTraits< KeyValuePair > -{ -public: - // explicitly declare local typedefs for these traits types, otherwise - // the compiler may get confused - typedef typename DefaultSHashTraits< KeyValuePair >::element_t element_t; - typedef typename DefaultSHashTraits< KeyValuePair >::count_t count_t; - - typedef KEY key_t; - - static key_t GetKey(element_t e) - { - LIMITED_METHOD_CONTRACT; - return e.Key(); - } - static BOOL Equals(key_t k1, key_t k2) - { - LIMITED_METHOD_CONTRACT; - return k1 == k2; - } - static count_t Hash(key_t k) - { - LIMITED_METHOD_CONTRACT; - return (count_t)(size_t)k; - } - - static const element_t Null() { LIMITED_METHOD_CONTRACT; return element_t(KEY(),VALUE()); } - static const element_t Deleted() { LIMITED_METHOD_CONTRACT; return element_t(KEY(-1), VALUE()); } - static bool IsNull(const element_t &e) { LIMITED_METHOD_CONTRACT; return e.Key() == KEY(); } - static bool IsDeleted(const element_t &e) { return e.Key() == KEY(-1); } -}; - -template > > -class MapSHash : public SHash< TRAITS > -{ - typedef SHash< TRAITS > PARENT; - -public: - void Add(KEY key, VALUE value) - { - CONTRACTL - { - THROWS; - GC_NOTRIGGER; - PRECONDITION(key != (KEY)0); - } - CONTRACTL_END; - - PARENT::Add(KeyValuePair(key, value)); - } - - BOOL Lookup(KEY key, VALUE* pValue) const - { - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - PRECONDITION(key != (KEY)0); - } - CONTRACTL_END; - - const KeyValuePair *pRet = PARENT::LookupPtr(key); - if (pRet == NULL) - return FALSE; - - *pValue = pRet->Value(); - return TRUE; - } -}; - -template -class MapSHashWithRemove : public SHash< MapSHashTraits > -{ - typedef SHash< MapSHashTraits > PARENT; - -public: - void Add(KEY key, VALUE value) - { - CONTRACTL - { - THROWS; - GC_NOTRIGGER; - PRECONDITION(key != (KEY)0 && key != (KEY)-1); - } - CONTRACTL_END; - - PARENT::Add(KeyValuePair(key, value)); - } - - BOOL Lookup(KEY key, VALUE* pValue) const - { - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - PRECONDITION(key != (KEY)0 && key != (KEY)-1); - } - CONTRACTL_END; - - const KeyValuePair *pRet = PARENT::LookupPtr(key); - if (pRet == NULL) - return FALSE; - - *pValue = pRet->Value(); - return TRUE; - } - - void Remove(KEY key) - { - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - PRECONDITION(key != (KEY)0 && key != (KEY)-1); - } - CONTRACTL_END; - - PARENT::Remove(key); - } -}; - -#endif // CC_JIT - -#include "shash.inl" - -#endif // _SHASH_H_ diff --git a/src/inc/shash.inl b/src/inc/shash.inl deleted file mode 100644 index f48899a58..000000000 --- a/src/inc/shash.inl +++ /dev/null @@ -1,935 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#ifndef _SHASH_INL_ -#define _SHASH_INL_ - -// Many SHash functions do not throw on their own, but may propagate an exception -// from Hash, Equals, or GetKey. -#define NOTHROW_UNLESS_TRAITS_THROWS if (TRAITS::s_NoThrow) NOTHROW; else THROWS - -void DECLSPEC_NORETURN ThrowOutOfMemory(); - -template -SHash::SHash() - : m_table(nullptr), - m_tableSize(0), - m_tableCount(0), - m_tableOccupied(0), - m_tableMax(0) -{ - LIMITED_METHOD_CONTRACT; - -#ifndef __GNUC__ // these crash GCC - static_assert_no_msg(SHash::s_growth_factor_numerator > SHash::s_growth_factor_denominator); - static_assert_no_msg(SHash::s_density_factor_numerator < SHash::s_density_factor_denominator); -#endif -} - -template -SHash::~SHash() -{ - LIMITED_METHOD_CONTRACT; - - if (TRAITS::s_DestructPerEntryCleanupAction) - { - for (Iterator i = Begin(); i != End(); i++) - { - TRAITS::OnDestructPerEntryCleanupAction(*i); - } - } - - delete [] m_table; -} - -template -typename SHash::count_t SHash::GetCount() const -{ - LIMITED_METHOD_CONTRACT; - - return m_tableCount; -} - -template -typename SHash::element_t SHash::Lookup(key_t key) const -{ - CONTRACT(element_t) - { - NOTHROW_UNLESS_TRAITS_THROWS; - GC_NOTRIGGER; - INSTANCE_CHECK; - POSTCONDITION(TRAITS::IsNull(RETVAL) || TRAITS::Equals(key, TRAITS::GetKey(RETVAL))); - SUPPORTS_DAC_WRAPPER; - } - CONTRACT_END; - - const element_t *pRet = Lookup(m_table, m_tableSize, key); - RETURN ((pRet != NULL) ? (*pRet) : TRAITS::Null()); -} - -template -const typename SHash::element_t * SHash::LookupPtr(key_t key) const -{ - CONTRACT(const element_t *) - { - NOTHROW_UNLESS_TRAITS_THROWS; - GC_NOTRIGGER; - INSTANCE_CHECK; - POSTCONDITION(RETVAL == NULL || TRAITS::Equals(key, TRAITS::GetKey(*RETVAL))); - } - CONTRACT_END; - - RETURN Lookup(m_table, m_tableSize, key); -} - -template -void SHash::Add(const element_t & element) -{ - CONTRACT_VOID - { - THROWS; - GC_NOTRIGGER; - INSTANCE_CHECK; - POSTCONDITION(TRAITS::Equals(TRAITS::GetKey(element), TRAITS::GetKey(*LookupPtr(TRAITS::GetKey(element))))); - } - CONTRACT_END; - - CheckGrowth(); - - Add_GrowthChecked(element); - - RETURN; -} - -template -void SHash::Add_GrowthChecked(const element_t & element) -{ - CONTRACT_VOID - { - NOTHROW_UNLESS_TRAITS_THROWS; - GC_NOTRIGGER; - INSTANCE_CHECK; - POSTCONDITION(TRAITS::Equals(TRAITS::GetKey(element), TRAITS::GetKey(*LookupPtr(TRAITS::GetKey(element))))); - } - CONTRACT_END; - - if (Add(m_table, m_tableSize, element)) - m_tableOccupied++; - m_tableCount++; - - RETURN; -} - -template -void SHash::AddOrReplace(const element_t &element) -{ - CONTRACT_VOID - { - THROWS; - GC_NOTRIGGER; - INSTANCE_CHECK; - static_assert(!TRAITS::s_supports_remove, "SHash::AddOrReplace is not implemented for SHash with support for remove operations."); - POSTCONDITION(TRAITS::Equals(TRAITS::GetKey(element), TRAITS::GetKey(*LookupPtr(TRAITS::GetKey(element))))); - } - CONTRACT_END; - - CheckGrowth(); - - AddOrReplace(m_table, m_tableSize, element); - - RETURN; -} - -template -void SHash::Remove(key_t key) -{ - CONTRACT_VOID - { - NOTHROW_UNLESS_TRAITS_THROWS; - GC_NOTRIGGER; - INSTANCE_CHECK; - static_assert(TRAITS::s_supports_remove, "This SHash does not support remove operations."); - PRECONDITION(!(TRAITS::IsNull(Lookup(key)))); - } - CONTRACT_END; - - Remove(m_table, m_tableSize, key); - - RETURN; -} - -template -void SHash::Remove(Iterator& i) -{ - CONTRACT_VOID - { - NOTHROW; - GC_NOTRIGGER; - INSTANCE_CHECK; - static_assert(TRAITS::s_supports_remove, "This SHash does not support remove operations."); - PRECONDITION(!(TRAITS::IsNull(*i))); - PRECONDITION(!(TRAITS::IsDeleted(*i))); - } - CONTRACT_END; - - RemoveElement(m_table, m_tableSize, (element_t*)&(*i)); - - RETURN; -} - -template -void SHash::Remove(KeyIterator& i) -{ - CONTRACT_VOID - { - NOTHROW; - GC_NOTRIGGER; - INSTANCE_CHECK; - static_assert(TRAITS::s_supports_remove, "This SHash does not support remove operations."); - PRECONDITION(!(TRAITS::IsNull(*i))); - PRECONDITION(!(TRAITS::IsDeleted(*i))); - } - CONTRACT_END; - - RemoveElement(m_table, m_tableSize, (element_t*)&(*i)); - - RETURN; -} - -template -void SHash::RemovePtr(element_t * p) -{ - CONTRACT_VOID - { - NOTHROW; - GC_NOTRIGGER; - INSTANCE_CHECK; - static_assert(TRAITS::s_supports_remove, "This SHash does not support remove operations."); - PRECONDITION(!(TRAITS::IsNull(*p))); - PRECONDITION(!(TRAITS::IsDeleted(*p))); - } - CONTRACT_END; - - RemoveElement(m_table, m_tableSize, p); - - RETURN; -} - -template -void SHash::RemoveAll() -{ - CONTRACT_VOID - { - NOTHROW; - GC_NOTRIGGER; - INSTANCE_CHECK; - } - CONTRACT_END; - - delete [] m_table; - - m_table = NULL; - m_tableSize = 0; - m_tableCount = 0; - m_tableOccupied = 0; - m_tableMax = 0; - - RETURN; -} - -template -typename SHash::Iterator SHash::Begin() const -{ - LIMITED_METHOD_CONTRACT; - - Iterator i(this, TRUE); - i.First(); - return i; -} - -template -typename SHash::Iterator SHash::End() const -{ - LIMITED_METHOD_CONTRACT; - - return Iterator(this, FALSE); -} - -template -typename SHash::KeyIterator SHash::Begin(key_t key) const -{ - LIMITED_METHOD_CONTRACT; - - KeyIterator k(this, TRUE); - k.SetKey(key); - return k; -} - -template -typename SHash::KeyIterator SHash::End(key_t key) const -{ - LIMITED_METHOD_CONTRACT; - - return KeyIterator(this, FALSE); -} - -template -BOOL SHash::CheckGrowth() -{ - CONTRACT(BOOL) - { - THROWS; - GC_NOTRIGGER; - INSTANCE_CHECK; - } - CONTRACT_END; - - if (m_tableOccupied == m_tableMax) - { - Grow(); - RETURN TRUE; - } - - RETURN FALSE; -} - -template -typename SHash::element_t * -SHash::CheckGrowth_OnlyAllocateNewTable(count_t * pcNewSize) -{ - CONTRACT(element_t *) - { - THROWS; - GC_NOTRIGGER; - INSTANCE_CHECK; - } - CONTRACT_END; - - if (m_tableOccupied == m_tableMax) - { - RETURN Grow_OnlyAllocateNewTable(pcNewSize); - } - - RETURN NULL; -} - -template -void SHash::Grow() -{ - CONTRACT_VOID - { - THROWS; - GC_NOTRIGGER; - INSTANCE_CHECK; - } - CONTRACT_END; - - count_t newSize; - element_t * newTable = Grow_OnlyAllocateNewTable(&newSize); - element_t * oldTable = ReplaceTable(newTable, newSize); - DeleteOldTable(oldTable); - - RETURN; -} - -template -typename SHash::element_t * -SHash::Grow_OnlyAllocateNewTable(count_t * pcNewSize) -{ - CONTRACT(element_t *) - { - THROWS; - GC_NOTRIGGER; - INSTANCE_CHECK; - } - CONTRACT_END; - - count_t newSize = (count_t) (m_tableCount - * TRAITS::s_growth_factor_numerator / TRAITS::s_growth_factor_denominator - * TRAITS::s_density_factor_denominator / TRAITS::s_density_factor_numerator); - if (newSize < TRAITS::s_minimum_allocation) - newSize = TRAITS::s_minimum_allocation; - - // handle potential overflow - if (newSize < m_tableCount) - ThrowOutOfMemory(); - - RETURN AllocateNewTable(newSize, pcNewSize); -} - -template -void SHash::Reallocate(count_t requestedSize) -{ - CONTRACT_VOID - { - THROWS; - GC_NOTRIGGER; - INSTANCE_CHECK; - } - CONTRACT_END; - - count_t newTableSize; - element_t * newTable = AllocateNewTable(requestedSize, &newTableSize); - element_t * oldTable = ReplaceTable(newTable, newTableSize); - DeleteOldTable(oldTable); - - RETURN; -} - -template -template -void SHash::ForEach(Functor &functor) -{ - WRAPPER_NO_CONTRACT; // LIMITED_METHOD_CONTRACT + Functor - - for (count_t i = 0; i < m_tableSize; i++) - { - element_t element = m_table[i]; - if (!TRAITS::IsNull(element) && !TRAITS::IsDeleted(element)) - { - functor(element); - } - } -} - -template -typename SHash::element_t * -SHash::AllocateNewTable(count_t requestedSize, count_t * pcNewTableSize) -{ - CONTRACT(element_t *) - { - THROWS; - GC_NOTRIGGER; - INSTANCE_CHECK; - PRECONDITION(requestedSize >= - (count_t) (GetCount() * s_density_factor_denominator / s_density_factor_numerator)); - } - CONTRACT_END; - - // Allocation size must be a prime number. This is necessary so that hashes uniformly - // distribute to all indices, and so that chaining will visit all indices in the hash table. - *pcNewTableSize = NextPrime(requestedSize); - - element_t * newTable = new element_t [*pcNewTableSize]; - - element_t * p = newTable; - element_t * pEnd = newTable + *pcNewTableSize; - while (p < pEnd) - { - *p = TRAITS::Null(); - p++; - } - - RETURN newTable; -} - -template -typename SHash::element_t * -SHash::ReplaceTable(element_t * newTable, count_t newTableSize) -{ - CONTRACT(element_t *) - { - NOTHROW_UNLESS_TRAITS_THROWS; - GC_NOTRIGGER; - INSTANCE_CHECK; - PRECONDITION(newTableSize >= - (count_t) (GetCount() * s_density_factor_denominator / s_density_factor_numerator)); - } - CONTRACT_END; - - element_t * oldTable = m_table; - - // Move all entries over to new table. - for (Iterator i = Begin(), end = End(); i != end; i++) - { - const element_t & cur = (*i); - if (!TRAITS::IsNull(cur) && !TRAITS::IsDeleted(cur)) - Add(newTable, newTableSize, cur); - } - - m_table = PTR_element_t(newTable); - m_tableSize = newTableSize; - m_tableMax = (count_t) (newTableSize * TRAITS::s_density_factor_numerator / TRAITS::s_density_factor_denominator); - m_tableOccupied = m_tableCount; - - RETURN oldTable; -} - -template -void -SHash::DeleteOldTable(element_t * oldTable) -{ - CONTRACT_VOID - { - NOTHROW; - GC_NOTRIGGER; - } - CONTRACT_END; - - // @todo: - // We might want to try to delay this cleanup to allow asynchronous readers - if (oldTable != NULL) - delete [] oldTable; - - RETURN; -} - -template -const typename SHash::element_t * SHash::Lookup(PTR_element_t table, count_t tableSize, key_t key) -{ - CONTRACT(const element_t *) - { - NOTHROW_UNLESS_TRAITS_THROWS; - GC_NOTRIGGER; - POSTCONDITION(RETVAL == NULL || TRAITS::Equals(key, TRAITS::GetKey(*RETVAL))); - SUPPORTS_DAC_WRAPPER; // supports DAC only if the traits class does - } - CONTRACT_END; - - if (tableSize == 0) - RETURN NULL; - - count_t hash = TRAITS::Hash(key); - count_t index = hash % tableSize; - count_t increment = 0; // delay computation - - while (TRUE) - { - element_t& current = table[index]; - - if (TRAITS::IsNull(current)) - RETURN NULL; - - if (!TRAITS::IsDeleted(current) - && TRAITS::Equals(key, TRAITS::GetKey(current))) - { - RETURN ¤t; - } - - if (increment == 0) - increment = (hash % (tableSize-1)) + 1; - - index += increment; - if (index >= tableSize) - index -= tableSize; - } -} - -template -BOOL SHash::Add(element_t * table, count_t tableSize, const element_t & element) -{ - CONTRACT(BOOL) - { - NOTHROW_UNLESS_TRAITS_THROWS; - GC_NOTRIGGER; - POSTCONDITION(TRAITS::Equals(TRAITS::GetKey(element), TRAITS::GetKey(*Lookup(table, tableSize, TRAITS::GetKey(element))))); - } - CONTRACT_END; - - key_t key = TRAITS::GetKey(element); - - count_t hash = TRAITS::Hash(key); - count_t index = hash % tableSize; - count_t increment = 0; // delay computation - - while (TRUE) - { - element_t & current = table[index]; - - if (TRAITS::IsNull(current)) - { - table[index] = element; - RETURN TRUE; - } - - if (TRAITS::IsDeleted(current)) - { - table[index] = element; - RETURN FALSE; - } - - if (increment == 0) - increment = (hash % (tableSize-1)) + 1; - - index += increment; - if (index >= tableSize) - index -= tableSize; - } -} - -template -void SHash::AddOrReplace(element_t *table, count_t tableSize, const element_t &element) -{ - CONTRACT_VOID - { - NOTHROW_UNLESS_TRAITS_THROWS; - GC_NOTRIGGER; - static_assert(!TRAITS::s_supports_remove, "SHash::AddOrReplace is not implemented for SHash with support for remove operations."); - POSTCONDITION(TRAITS::Equals(TRAITS::GetKey(element), TRAITS::GetKey(*Lookup(table, tableSize, TRAITS::GetKey(element))))); - } - CONTRACT_END; - - key_t key = TRAITS::GetKey(element); - - count_t hash = TRAITS::Hash(key); - count_t index = hash % tableSize; - count_t increment = 0; // delay computation - - while (TRUE) - { - element_t& current = table[index]; - _ASSERTE(!TRAITS::IsDeleted(current)); - - if (TRAITS::IsNull(current)) - { - table[index] = element; - m_tableCount++; - m_tableOccupied++; - RETURN; - } - else if (TRAITS::Equals(key, TRAITS::GetKey(current))) - { - table[index] = element; - RETURN; - } - - if (increment == 0) - increment = (hash % (tableSize-1)) + 1; - - index += increment; - if (index >= tableSize) - index -= tableSize; - } -} - -template -void SHash::Remove(element_t *table, count_t tableSize, key_t key) -{ - CONTRACT_VOID - { - NOTHROW_UNLESS_TRAITS_THROWS; - GC_NOTRIGGER; - static_assert(TRAITS::s_supports_remove, "This SHash does not support remove operations."); - PRECONDITION(Lookup(table, tableSize, key) != NULL); - } - CONTRACT_END; - - count_t hash = TRAITS::Hash(key); - count_t index = hash % tableSize; - count_t increment = 0; // delay computation - - while (TRUE) - { - element_t& current = table[index]; - - if (TRAITS::IsNull(current)) - RETURN; - - if (!TRAITS::IsDeleted(current) - && TRAITS::Equals(key, TRAITS::GetKey(current))) - { - table[index] = TRAITS::Deleted(); - m_tableCount--; - RETURN; - } - - if (increment == 0) - increment = (hash % (tableSize-1)) + 1; - - index += increment; - if (index >= tableSize) - index -= tableSize; - } -} - -template -void SHash::RemoveElement(element_t *table, count_t tableSize, element_t *element) -{ - CONTRACT_VOID - { - NOTHROW; - GC_NOTRIGGER; - static_assert(TRAITS::s_supports_remove, "This SHash does not support remove operations."); - PRECONDITION(table <= element && element < table + tableSize); - PRECONDITION(!TRAITS::IsNull(*element) && !TRAITS::IsDeleted(*element)); - } - CONTRACT_END; - - *element = TRAITS::Deleted(); - m_tableCount--; - RETURN; -} - -template -BOOL SHash::IsPrime(COUNT_T number) -{ - CONTRACT(BOOL) - { - NOTHROW; - GC_NOTRIGGER; - } - CONTRACT_END; - - // This is a very low-tech check for primality, which doesn't scale very well. - // There are more efficient tests if this proves to be burdensome for larger - // tables. - - if ((number & 1) == 0) - RETURN FALSE; - - COUNT_T factor = 3; - while (factor * factor <= number) - { - if ((number % factor) == 0) - RETURN FALSE; - factor += 2; - } - - RETURN TRUE; -} - -// allow coexistence with simplerhash.inl -#ifndef _HASH_PRIMES_DEFINED -#define _HASH_PRIMES_DEFINED - -namespace -{ - const COUNT_T g_shash_primes[] = { - 11,17,23,29,37,47,59,71,89,107,131,163,197,239,293,353,431,521,631,761,919, - 1103,1327,1597,1931,2333,2801,3371,4049,4861,5839,7013,8419,10103,12143,14591, - 17519,21023,25229,30293,36353,43627,52361,62851,75431,90523, 108631, 130363, - 156437, 187751, 225307, 270371, 324449, 389357, 467237, 560689, 672827, 807403, - 968897, 1162687, 1395263, 1674319, 2009191, 2411033, 2893249, 3471899, 4166287, - 4999559, 5999471, 7199369 }; -} - -#endif //_HASH_PRIMES_DEFINED - -template -COUNT_T SHash::NextPrime(COUNT_T number) -{ - CONTRACT(COUNT_T) - { - NOTHROW; - GC_NOTRIGGER; - POSTCONDITION(IsPrime(RETVAL)); - } - CONTRACT_END; - - for (int i = 0; i < (int) (sizeof(g_shash_primes) / sizeof(g_shash_primes[0])); i++) { - if (g_shash_primes[i] >= number) - RETURN g_shash_primes[i]; - } - - if ((number&1) == 0) - number++; - - while (number != 1) { - if (IsPrime(number)) - RETURN number; - number +=2; - } - - // overflow - ThrowOutOfMemory(); -} - -template -SHash::AddPhases::AddPhases() -{ - LIMITED_METHOD_CONTRACT; - - m_pHash = NULL; - m_newTable = NULL; - m_newTableSize = 0; - m_oldTable = NULL; - - INDEBUG(dbg_m_fAddCalled = FALSE;) -} - -template -SHash::AddPhases::~AddPhases() -{ - LIMITED_METHOD_CONTRACT; - - if (m_newTable != NULL) - { // The new table was not applied to the hash yet - _ASSERTE((m_pHash != NULL) && (m_newTableSize != 0) && (m_oldTable == NULL)); - - delete [] m_newTable; - } - DeleteOldTable(); -} - -template -void SHash::AddPhases::PreallocateForAdd(SHash * pHash) -{ - CONTRACT_VOID - { - THROWS; - GC_NOTRIGGER; - } - CONTRACT_END; - - _ASSERTE((m_pHash == NULL) && (m_newTable == NULL) && (m_newTableSize == 0) && (m_oldTable == NULL)); - - m_pHash = pHash; - // May return NULL if the allocation was not needed - m_newTable = m_pHash->CheckGrowth_OnlyAllocateNewTable(&m_newTableSize); - -#ifdef _DEBUG - dbg_m_table = pHash->m_table; - dbg_m_tableSize = pHash->m_tableSize; - dbg_m_tableCount = pHash->m_tableCount; - dbg_m_tableOccupied = pHash->m_tableOccupied; - dbg_m_tableMax = pHash->m_tableMax; -#endif //_DEBUG - - RETURN; -} - -template -void SHash::AddPhases::Add(const element_t & element) -{ - CONTRACT_VOID - { - NOTHROW_UNLESS_TRAITS_THROWS; - GC_NOTRIGGER; - } - CONTRACT_END; - - _ASSERTE((m_pHash != NULL) && (m_oldTable == NULL)); - // Add can be called only once on this object - _ASSERTE(!dbg_m_fAddCalled); - - // Check that the hash table didn't change since call to code:PreallocateForAdd - _ASSERTE(dbg_m_table == m_pHash->m_table); - _ASSERTE(dbg_m_tableSize == m_pHash->m_tableSize); - _ASSERTE(dbg_m_tableCount >= m_pHash->m_tableCount); // Remove operation might have removed elements - _ASSERTE(dbg_m_tableOccupied == m_pHash->m_tableOccupied); - _ASSERTE(dbg_m_tableMax == m_pHash->m_tableMax); - - if (m_newTable != NULL) - { // We have pre-allocated table from code:PreallocateForAdd, use it. - _ASSERTE(m_newTableSize != 0); - - // May return NULL if there was not table allocated yet - m_oldTable = m_pHash->ReplaceTable(m_newTable, m_newTableSize); - - m_newTable = NULL; - m_newTableSize = 0; - } - // We know that we have enough space, direcly add the element - m_pHash->Add_GrowthChecked(element); - - INDEBUG(dbg_m_fAddCalled = TRUE;) - - RETURN; -} - -template -void SHash::AddPhases::AddNothing_PublishPreallocatedTable() -{ - CONTRACT_VOID - { - NOTHROW_UNLESS_TRAITS_THROWS; - GC_NOTRIGGER; - } - CONTRACT_END; - - _ASSERTE((m_pHash != NULL) && (m_oldTable == NULL)); - // Add can be called only once on this object - _ASSERTE(!dbg_m_fAddCalled); - - // Check that the hash table didn't change since call to code:PreallocateForAdd - _ASSERTE(dbg_m_table == m_pHash->m_table); - _ASSERTE(dbg_m_tableSize == m_pHash->m_tableSize); - _ASSERTE(dbg_m_tableCount >= m_pHash->m_tableCount); // Remove operation might have removed elements - _ASSERTE(dbg_m_tableOccupied == m_pHash->m_tableOccupied); - _ASSERTE(dbg_m_tableMax == m_pHash->m_tableMax); - - if (m_newTable != NULL) - { // We have pre-allocated table from code:PreallocateForAdd, use it. - _ASSERTE(m_newTableSize != 0); - - // May return NULL if there was not table allocated yet - m_oldTable = m_pHash->ReplaceTable(m_newTable, m_newTableSize); - - m_newTable = NULL; - m_newTableSize = 0; - } - - INDEBUG(dbg_m_fAddCalled = TRUE;) - - RETURN; -} - -template -void SHash::AddPhases::DeleteOldTable() -{ - LIMITED_METHOD_CONTRACT; - - if (m_oldTable != NULL) - { - _ASSERTE((m_pHash != NULL) && (m_newTable == NULL) && (m_newTableSize == 0)); - - delete [] m_oldTable; - m_oldTable = NULL; - } -} - -template -template -bool SHash::CheckAddInPhases( - element_t const & elem, - LockT & lock, - AddLockT & addLock, - IUnknown * addRefObject) -{ - CONTRACTL - { - THROWS; - GC_NOTRIGGER; - INSTANCE_CHECK; - } - CONTRACTL_END; - - AddLockHolderT hAddLock(&addLock); - AddPhases addCall; - - // 1. Preallocate one element - addCall.PreallocateForAdd(this); - { - // 2. Take the reader lock. Host callouts now forbidden. - LockHolderT hLock(&lock); - - element_t const * pEntry = LookupPtr(TRAITS::GetKey(elem)); - if (pEntry != nullptr) - { - // 3a. Use the newly allocated table (if any) to avoid later redundant allocation. - addCall.AddNothing_PublishPreallocatedTable(); - return false; - } - else - { - // 3b. Add the element to the hash table. - addCall.Add(elem); - - if (addRefObject != nullptr) - { - clr::SafeAddRef(addRefObject); - } - - return true; - } - } - - // 4. addCall's destructor will take care of any required cleanup. -} - - -#endif // _SHASH_INL_ diff --git a/src/inc/shimload.h b/src/inc/shimload.h deleted file mode 100644 index a2651d1af..000000000 --- a/src/inc/shimload.h +++ /dev/null @@ -1,27 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Header: ShimLoad.hpp -** -** Purpose: Delay load hook used to images to bind to -** dll's shim shipped with the EE -** -** -===========================================================*/ -#ifndef _SHIMLOAD_H -#define _SHIMLOAD_H - - -//***************************************************************************** -// Sets/Gets the directory based on the location of the module. This routine -// is called at COR setup time. Set is called during EEStartup and by the -// MetaData dispenser. -//***************************************************************************** -HRESULT SetInternalSystemDirectory(); -HRESULT GetInternalSystemDirectory(__out_ecount_opt(*pdwLength) LPWSTR buffer, __inout DWORD* pdwLength); - -#endif - diff --git a/src/inc/sigbuilder.h b/src/inc/sigbuilder.h deleted file mode 100644 index 6d7cbf27b..000000000 --- a/src/inc/sigbuilder.h +++ /dev/null @@ -1,79 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - - -#ifndef _SIGBUILDER_H_ -#define _SIGBUILDER_H_ - -#include "contract.h" - -// -// Simple signature builder -// - -class SigBuilder -{ - PBYTE m_pBuffer; - DWORD m_dwLength; - DWORD m_dwAllocation; - - // Preallocate space for small signatures - BYTE m_prealloc[64]; - - // Grow the buffer to get at least cbMin of free space - void Grow(SIZE_T cbMin); - - // Ensure that the buffer has at least cbMin of free space - FORCEINLINE void Ensure(SIZE_T cb) - { - if (m_dwAllocation - m_dwLength < cb) - Grow(cb); - } - -public: - SigBuilder() - : m_pBuffer(m_prealloc), m_dwLength(0), m_dwAllocation(sizeof(m_prealloc)) - { - LIMITED_METHOD_CONTRACT; - } - - ~SigBuilder(); - - SigBuilder(DWORD cbPreallocationSize); - - PVOID GetSignature(DWORD * pdwLength) - { - LIMITED_METHOD_CONTRACT; - *pdwLength = m_dwLength; - return m_pBuffer; - } - - DWORD GetSignatureLength() - { - LIMITED_METHOD_CONTRACT; - return m_dwLength; - } - - void AppendByte(BYTE b); - - void AppendData(ULONG data); - - void AppendElementType(CorElementType etype) - { - WRAPPER_NO_CONTRACT; - AppendByte(static_cast(etype)); - } - - void AppendToken(mdToken tk); - - void AppendPointer(void * ptr) - { - WRAPPER_NO_CONTRACT; - AppendBlob(&ptr, sizeof(ptr)); - } - - void AppendBlob(const PVOID pBlob, SIZE_T cbBlob); -}; - -#endif // _SIGBUILDER_H_ diff --git a/src/inc/sigparser.h b/src/inc/sigparser.h deleted file mode 100644 index 2c8cf8b16..000000000 --- a/src/inc/sigparser.h +++ /dev/null @@ -1,985 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -// -// sigparser.h -// - -// - -#ifndef _H_SIGPARSER -#define _H_SIGPARSER - -#include "utilcode.h" -#include "corhdr.h" -#include "corinfo.h" -#include "corpriv.h" - -//--------------------------------------------------------------------------------------- -// These macros define how arguments are mapped to the stack in the managed calling convention. -// We assume to be walking a method's signature left-to-right, in the virtual calling convention. -// See MethodDesc::Call for details on this virtual calling convention. -// These macros tell us whether the arguments we see as we proceed with the signature walk are mapped -// to increasing or decreasing stack addresses. This is valid only for arguments that go on the stack. -//--------------------------------------------------------------------------------------- -#if defined(_TARGET_X86_) -#define STACK_GROWS_DOWN_ON_ARGS_WALK -#else -#define STACK_GROWS_UP_ON_ARGS_WALK -#endif - - -//------------------------------------------------------------------------ -// Encapsulates how compressed integers and typeref tokens are encoded into -// a bytestream. -// -// As you use this class please understand the implicit normalizations -// on the CorElementType's returned by the various methods, especially -// for variable types (e.g. !0 in generic signatures), string types -// (i.e. E_T_STRING), object types (E_T_OBJECT), constructed types -// (e.g. List) and enums. -//------------------------------------------------------------------------ -class SigParser -{ - protected: - // This type is performance critical - do not add fields to it. - // (If you must, check for managed types that may use a SigParser or SigPointer inline, like ArgIterator.) - PCCOR_SIGNATURE m_ptr; - DWORD m_dwLen; - - //------------------------------------------------------------------------ - // Skips specified number of bytes WITHOUT VALIDATION. Only to be used - // when it is known that it won't overflow the signature buffer. - //------------------------------------------------------------------------ - FORCEINLINE void SkipBytes(ULONG cb) - { - SUPPORTS_DAC; - _ASSERT(cb <= m_dwLen); - m_ptr += cb; - m_dwLen -= cb; - } - - public: - //------------------------------------------------------------------------ - // Constructor. - //------------------------------------------------------------------------ - SigParser() { - LIMITED_METHOD_DAC_CONTRACT; - m_ptr = NULL; - m_dwLen = 0; - } - - SigParser(const SigParser &sig); - - //------------------------------------------------------------------------ - // Initialize - //------------------------------------------------------------------------ - FORCEINLINE SigParser(PCCOR_SIGNATURE ptr) - { - LIMITED_METHOD_CONTRACT; - - m_ptr = ptr; - // We don't know the size of the signature, so we'll say it's "big enough" - m_dwLen = 0xffffffff; - } - - FORCEINLINE SigParser(PCCOR_SIGNATURE ptr, DWORD len) - { - LIMITED_METHOD_CONTRACT; - - m_ptr = ptr; - m_dwLen = len; - } - - inline void SetSig(PCCOR_SIGNATURE ptr) - { - LIMITED_METHOD_CONTRACT; - - m_ptr = ptr; - // We don't know the size of the signature, so we'll say it's "big enough" - m_dwLen = 0xffffffff; - } - - inline void SetSig(PCCOR_SIGNATURE ptr, DWORD len) - { - LIMITED_METHOD_CONTRACT; - - m_ptr = ptr; - m_dwLen = len; - } - - - inline BOOL IsNull() const - { - LIMITED_METHOD_CONTRACT; - - return (m_ptr == NULL); - } - - // Returns represented signature as pointer and size. - void - GetSignature( - PCCOR_SIGNATURE * pSig, - DWORD * pcbSigSize) - { - *pSig = m_ptr; - *pcbSigSize = m_dwLen; - } - - - //========================================================================= - // The RAW interface for reading signatures. You see exactly the signature, - // apart from custom modifiers which for historical reasons tend to get eaten. - // - // DO NOT USE THESE METHODS UNLESS YOU'RE TOTALLY SURE YOU WANT - // THE RAW signature. You nearly always want GetElemTypeClosed() or - // PeekElemTypeClosed() or one of the MetaSig functions. See the notes above. - // These functions will return E_T_INTERNAL, E_T_VAR, E_T_MVAR and such - // so the caller must be able to deal with those - //========================================================================= - - //------------------------------------------------------------------------ - // Remove one compressed integer (using CorSigUncompressData) from - // the head of the stream and return it. - //------------------------------------------------------------------------ - __checkReturn - FORCEINLINE HRESULT GetData(ULONG* data) - { - WRAPPER_NO_CONTRACT; - SUPPORTS_DAC; - - ULONG sizeOfData = 0; - ULONG tempData; - - if (data == NULL) - data = &tempData; - - HRESULT hr = CorSigUncompressData(m_ptr, m_dwLen, data, &sizeOfData); - - if (SUCCEEDED(hr)) - { - SkipBytes(sizeOfData); - } - - return hr; - } - - - //------------------------------------------------------------------------- - // Remove one byte and return it. - //------------------------------------------------------------------------- - __checkReturn - FORCEINLINE HRESULT GetByte(BYTE *data) - { - LIMITED_METHOD_CONTRACT; - - if (m_dwLen > 0) - { - if (data != NULL) - *data = *m_ptr; - - SkipBytes(1); - - return S_OK; - } - - if (data != NULL) - *data = 0; - return META_E_BAD_SIGNATURE; - } - - //------------------------------------------------------------------------- - // Peek at value of one byte and return it. - //------------------------------------------------------------------------- - __checkReturn - FORCEINLINE HRESULT PeekByte(BYTE *data) - { - LIMITED_METHOD_CONTRACT; - - if (m_dwLen > 0) - { - if (data != NULL) - *data = *m_ptr; - - return S_OK; - } - - if (data != NULL) - *data = 0; - return META_E_BAD_SIGNATURE; - } - - //------------------------------------------------------------------------- - // The element type as defined in CorElementType. No normalization for - // generics (E_T_VAR, E_T_MVAR,..) or dynamic methods (E_T_INTERNAL occurs) - //------------------------------------------------------------------------- - __checkReturn - HRESULT GetElemTypeSlow(CorElementType * etype) - { - WRAPPER_NO_CONTRACT; - SUPPORTS_DAC; - - CorElementType tmpEType; - - if (etype == NULL) - etype = &tmpEType; - - SigParser sigTemp(*this); - - HRESULT hr = sigTemp.SkipCustomModifiers(); - - if (SUCCEEDED(hr)) - { - BYTE bElemType = 0; - hr = sigTemp.GetByte(&bElemType); - *etype = (CorElementType)bElemType; - - if (SUCCEEDED(hr)) - { - *this = sigTemp; - return S_OK; - } - } - - *etype = ELEMENT_TYPE_END; - - return META_E_BAD_SIGNATURE; - } - - // Inlined version - __checkReturn - FORCEINLINE HRESULT GetElemType(CorElementType * etype) - { - WRAPPER_NO_CONTRACT; - SUPPORTS_DAC; - - if (m_dwLen > 0) - { - CorElementType typ = (CorElementType) * m_ptr; - - if (typ < ELEMENT_TYPE_CMOD_REQD) // fast path with no modifiers: single byte - { - if (etype != NULL) - { - * etype = typ; - } - - SkipBytes(1); - - return S_OK; - } - } - - // Slower/normal path - return GetElemTypeSlow(etype); - } - - // Note: Calling convention is always one byte, not four bytes - __checkReturn - HRESULT GetCallingConvInfo(ULONG * data) - { - WRAPPER_NO_CONTRACT; - SUPPORTS_DAC; - - ULONG tmpData; - - if (data == NULL) - data = &tmpData; - - HRESULT hr = CorSigUncompressCallingConv(m_ptr, m_dwLen, data); - if (SUCCEEDED(hr)) - { - SkipBytes(1); - } - - return hr; - } - - __checkReturn - HRESULT GetCallingConv(ULONG* data) // @REVISIT_TODO: Calling convention is one byte, not four. - { - WRAPPER_NO_CONTRACT; - ULONG info; - HRESULT hr = GetCallingConvInfo(&info); - - if (SUCCEEDED(hr) && data != NULL) - { - *data = IMAGE_CEE_CS_CALLCONV_MASK & info; - } - - return hr; - } - - //------------------------------------------------------------------------ - // Non-destructive read of compressed integer. - //------------------------------------------------------------------------ - __checkReturn - HRESULT PeekData(ULONG *data) const - { - WRAPPER_NO_CONTRACT; - _ASSERTE(data != NULL); - - ULONG sizeOfData = 0; - return CorSigUncompressData(m_ptr, m_dwLen, data, &sizeOfData); - } - - - //------------------------------------------------------------------------ - // Non-destructive read of element type. - // - // This routine makes it look as if the String type is encoded - // via ELEMENT_TYPE_CLASS followed by a token for the String class, - // rather than the ELEMENT_TYPE_STRING. This is partially to avoid - // rewriting client code which depended on this behavior previously. - // But it also seems like the right thing to do generally. - // No normalization for generics (E_T_VAR, E_T_MVAR,..) or - // dynamic methods (E_T_INTERNAL occurs) - //------------------------------------------------------------------------ - __checkReturn - HRESULT PeekElemTypeSlow(CorElementType *etype) const - { - WRAPPER_NO_CONTRACT; - SUPPORTS_DAC; - - _ASSERTE(etype != NULL); - - SigParser sigTemp(*this); - HRESULT hr = sigTemp.GetElemType(etype); - if (SUCCEEDED(hr) && (*etype == ELEMENT_TYPE_STRING || *etype == ELEMENT_TYPE_OBJECT)) - *etype = ELEMENT_TYPE_CLASS; - - return hr; - } - - // inline version - __checkReturn - FORCEINLINE HRESULT PeekElemType(CorElementType *etype) const - { - WRAPPER_NO_CONTRACT; - SUPPORTS_DAC; - - _ASSERTE(etype != NULL); - - if (m_dwLen > 0) - { - CorElementType typ = (CorElementType) * m_ptr; - - if (typ < ELEMENT_TYPE_CMOD_REQD) // fast path with no modifiers: single byte - { - if ((typ == ELEMENT_TYPE_STRING) || (typ == ELEMENT_TYPE_OBJECT)) - { - *etype = ELEMENT_TYPE_CLASS; - } - else - { - *etype = typ; - } - - return S_OK; - } - } - - return PeekElemTypeSlow(etype); - } - - //------------------------------------------------------------------------- - // Returns the raw size of the type next in the signature, or returns - // E_INVALIDARG for base types that have variables sizes. - //------------------------------------------------------------------------- - __checkReturn - HRESULT PeekElemTypeSize(ULONG *pSize) - { - WRAPPER_NO_CONTRACT; - HRESULT hr = S_OK; - - DWORD dwSize = 0; - - if (pSize == NULL) - { - pSize = &dwSize; - } - - SigParser sigTemp(*this); - - hr = sigTemp.SkipAnyVASentinel(); - - if (FAILED(hr)) - { - return hr; - } - - *pSize = 0; - - BYTE bElementType = 0; - hr = sigTemp.GetByte(&bElementType); - - if (FAILED(hr)) - { - return hr; - } - - switch (bElementType) - { - case ELEMENT_TYPE_I8: - case ELEMENT_TYPE_U8: - case ELEMENT_TYPE_R8: - #ifdef _WIN64 - case ELEMENT_TYPE_I: - case ELEMENT_TYPE_U: - #endif // WIN64 - - *pSize = 8; - break; - - case ELEMENT_TYPE_I4: - case ELEMENT_TYPE_U4: - case ELEMENT_TYPE_R4: - #ifndef _WIN64 - case ELEMENT_TYPE_I: - case ELEMENT_TYPE_U: - #endif // _WIN64 - - *pSize = 4; - break; - - case ELEMENT_TYPE_I2: - case ELEMENT_TYPE_U2: - case ELEMENT_TYPE_CHAR: - *pSize = 2; - break; - - case ELEMENT_TYPE_I1: - case ELEMENT_TYPE_U1: - case ELEMENT_TYPE_BOOLEAN: - *pSize = 1; - break; - - case ELEMENT_TYPE_STRING: - case ELEMENT_TYPE_PTR: - case ELEMENT_TYPE_BYREF: - case ELEMENT_TYPE_CLASS: - case ELEMENT_TYPE_OBJECT: - case ELEMENT_TYPE_FNPTR: - case ELEMENT_TYPE_TYPEDBYREF: - case ELEMENT_TYPE_ARRAY: - case ELEMENT_TYPE_SZARRAY: - *pSize = sizeof(void *); - break; - - case ELEMENT_TYPE_VOID: - break; - - case ELEMENT_TYPE_END: - case ELEMENT_TYPE_CMOD_REQD: - case ELEMENT_TYPE_CMOD_OPT: - _ASSERTE(!"Asked for the size of an element that doesn't have a size!"); - return E_INVALIDARG; - - case ELEMENT_TYPE_VALUETYPE: - _ASSERTE(!"Asked for the size of an element that doesn't have a size!"); - return E_INVALIDARG; - - default: - - _ASSERTE( !"CorSigGetElementTypeSize given invalid signature to size!" ); - return META_E_BAD_SIGNATURE; - } - - return hr; - } - - //------------------------------------------------------------------------ - // Is this at the Sentinal (the ... in a varargs signature) that marks - // the begining of varguments that are not decared at the target - - bool AtSentinel() const - { - if (m_dwLen > 0) - return *m_ptr == ELEMENT_TYPE_SENTINEL; - else - return false; - } - - //------------------------------------------------------------------------ - // Removes a compressed metadata token and returns it. - // WARNING: dynamic methods do not have tokens so this api is completely - // broken in that case. Make sure you call this function if - // you are absolutely sure E_T_INTERNAL was not in the sig - //------------------------------------------------------------------------ - __checkReturn - FORCEINLINE - HRESULT GetToken(mdToken * token) - { - WRAPPER_NO_CONTRACT; - DWORD dwLen; - mdToken tempToken; - - if (token == NULL) - token = &tempToken; - - HRESULT hr = CorSigUncompressToken(m_ptr, m_dwLen, token, &dwLen); - - if (SUCCEEDED(hr)) - { - SkipBytes(dwLen); - } - - return hr; - } - - //------------------------------------------------------------------------ - // Removes a pointer value and returns it. Used for ELEMENT_TYPE_INTERNAL. - __checkReturn - FORCEINLINE - HRESULT GetPointer(void ** pPtr) - { - WRAPPER_NO_CONTRACT; - - if (m_dwLen < sizeof(void *)) - { // Not enough data to read a pointer - if (pPtr != NULL) - { - *pPtr = NULL; - } - return META_E_BAD_SIGNATURE; - } - if (pPtr != NULL) - { - *pPtr = *(void * UNALIGNED *)m_ptr; - } - SkipBytes(sizeof(void *)); - - return S_OK; - } - - //------------------------------------------------------------------------ - // Tests if two SigParsers point to the same location in the stream. - //------------------------------------------------------------------------ - FORCEINLINE BOOL Equals(SigParser sp) const - { - LIMITED_METHOD_CONTRACT; - - return m_ptr == sp.m_ptr; - } - - __checkReturn - HRESULT SkipCustomModifiers() - { - WRAPPER_NO_CONTRACT; - SUPPORTS_DAC; - - HRESULT hr = S_OK; - - SigParser sigTemp(*this); - - hr = sigTemp.SkipAnyVASentinel(); - - if (FAILED(hr)) - { - return hr; - } - - BYTE bElementType = 0; - - hr = sigTemp.PeekByte(&bElementType); - if (FAILED(hr)) - return hr; - - while ((ELEMENT_TYPE_CMOD_REQD == bElementType) || - (ELEMENT_TYPE_CMOD_OPT == bElementType)) - { - sigTemp.SkipBytes(1); - - mdToken token; - - hr = sigTemp.GetToken(&token); - - if (FAILED(hr)) - return hr; - - hr = sigTemp.PeekByte(&bElementType); - if (FAILED(hr)) - return hr; - } - - // Following custom modifiers must be an element type value which is less than ELEMENT_TYPE_MAX, or one of the other element types - // that we support while parsing various signatures - if (bElementType >= ELEMENT_TYPE_MAX) - { - switch (bElementType) - { - case ELEMENT_TYPE_VAR_ZAPSIG: - case ELEMENT_TYPE_NATIVE_ARRAY_TEMPLATE_ZAPSIG: - case ELEMENT_TYPE_NATIVE_VALUETYPE_ZAPSIG: - case ELEMENT_TYPE_CANON_ZAPSIG: - case ELEMENT_TYPE_MODULE_ZAPSIG: - case ELEMENT_TYPE_PINNED: - break; - default: - return META_E_BAD_SIGNATURE; - } - } - - *this = sigTemp; - return hr; - }// SkipCustomModifiers - - __checkReturn - HRESULT SkipFunkyAndCustomModifiers() - { - WRAPPER_NO_CONTRACT; - SUPPORTS_DAC; - - SigParser sigTemp(*this); - HRESULT hr = S_OK; - hr = sigTemp.SkipAnyVASentinel(); - - if (FAILED(hr)) - { - return hr; - } - - BYTE bElementType = 0; - - hr = sigTemp.PeekByte(&bElementType); - if (FAILED(hr)) - return hr; - - while (ELEMENT_TYPE_CMOD_REQD == bElementType || - ELEMENT_TYPE_CMOD_OPT == bElementType || - ELEMENT_TYPE_MODIFIER == bElementType || - ELEMENT_TYPE_PINNED == bElementType) - { - sigTemp.SkipBytes(1); - - mdToken token; - - hr = sigTemp.GetToken(&token); - - if (FAILED(hr)) - return hr; - - hr = sigTemp.PeekByte(&bElementType); - if (FAILED(hr)) - return hr; - } - - // Following custom modifiers must be an element type value which is less than ELEMENT_TYPE_MAX, or one of the other element types - // that we support while parsing various signatures - if (bElementType >= ELEMENT_TYPE_MAX) - { - switch (bElementType) - { - case ELEMENT_TYPE_NATIVE_ARRAY_TEMPLATE_ZAPSIG: - case ELEMENT_TYPE_NATIVE_VALUETYPE_ZAPSIG: - case ELEMENT_TYPE_CANON_ZAPSIG: - case ELEMENT_TYPE_MODULE_ZAPSIG: - case ELEMENT_TYPE_PINNED: - break; - default: - return META_E_BAD_SIGNATURE; - } - } - - *this = sigTemp; - return hr; - }// SkipFunkyAndCustomModifiers - - - __checkReturn - HRESULT SkipAnyVASentinel() - { - WRAPPER_NO_CONTRACT; - - HRESULT hr = S_OK; - BYTE bElementType = 0; - - hr = PeekByte(&bElementType); - if (FAILED(hr)) - return hr; - - if (bElementType == ELEMENT_TYPE_SENTINEL) - { - SkipBytes(1); - } - - return hr; - }// SkipAnyVASentinel - - //------------------------------------------------------------------------ - // Assumes that the SigParser points to the start of an element type - // (i.e. function parameter, function return type or field type.) - // Advances the pointer to the first data after the element type. - //------------------------------------------------------------------------ - __checkReturn - HRESULT SkipExactlyOne(); - - //------------------------------------------------------------------------ - // Skip only the method header of the signature, not the signature of - // the arguments. - //------------------------------------------------------------------------ - __checkReturn - HRESULT SkipMethodHeaderSignature(ULONG *pcArgs); - - //------------------------------------------------------------------------ - // Skip a sub signature (as immediately follows an ELEMENT_TYPE_FNPTR). - //------------------------------------------------------------------------ - __checkReturn - HRESULT SkipSignature(); - -public: - - //------------------------------------------------------------------------ - // Return pointer - // PLEASE DON'T USE THIS. - // - // Return the internal pointer. It's hard to resist, but please try - // not to use this. Certainly don't use it if there's any chance of the - // signature containing generic type variables. - // - // It's currently only used for working on the - // signatures stored in TypeSpec tokens (we should add a new abstraction, - // i.e. on MetaSig for this) and a couple of places to do with COM - // and native interop signature parsing. - // We should try to get rid of these uses as well. - //------------------------------------------------------------------------ - PCCOR_SIGNATURE GetPtr() const - { - LIMITED_METHOD_DAC_CONTRACT; - return m_ptr; - } - -}; // class SigParser - -//------------------------------------------------------------------------ -FORCEINLINE -SigParser::SigParser( - const SigParser &sig) - : m_ptr(sig.m_ptr), m_dwLen(sig.m_dwLen) -{ - LIMITED_METHOD_DAC_CONTRACT; -} - -/*****************************************************************/ -/* CorTypeInfo is a single global table that you can hang information - about ELEMENT_TYPE_* */ - -class CorTypeInfo -{ -protected: - struct CorTypeInfoEntry - { - LPCUTF8 nameSpace; - LPCUTF8 className; - CorElementType type : 8; - unsigned size : 8; - CorInfoGCType gcType : 3; - unsigned isArray : 1; - unsigned isPrim : 1; - unsigned isFloat : 1; - unsigned isModifier : 1; - unsigned isGenVar : 1; - // 1 more byte here to use for 32-bit - }; - -protected: - FORCEINLINE static const CorTypeInfoEntry &GetTypeInfo(CorElementType type) - { - CONTRACTL - { - THROWS; - GC_NOTRIGGER; - SUPPORTS_DAC; -#ifdef MODE_ANY - MODE_ANY; -#endif - } - CONTRACTL_END; - - if (type >= (CorElementType)_countof(info)) - { - ThrowHR(COR_E_BADIMAGEFORMAT); - } - return info[type]; - } - FORCEINLINE static const CorTypeInfoEntry &GetTypeInfo_NoThrow(CorElementType type) - { - LIMITED_METHOD_DAC_CONTRACT; - - if (type >= (CorElementType)_countof(info)) - { - return info[ELEMENT_TYPE_END]; - } - return info[type]; - } - -public: - - FORCEINLINE static LPCUTF8 GetName(CorElementType type) - { - WRAPPER_NO_CONTRACT; - - return GetTypeInfo(type).className; - } - - FORCEINLINE static LPCUTF8 GetNamespace(CorElementType type) - { - WRAPPER_NO_CONTRACT; - - return GetTypeInfo(type).nameSpace; - } - - static void CheckConsistency() - { - LIMITED_METHOD_CONTRACT; - - for (int i = 0; i < (int)_countof(info); i++) - { - _ASSERTE(info[i].type == i); - } - } - - FORCEINLINE static CorInfoGCType GetGCType(CorElementType type) - { - WRAPPER_NO_CONTRACT; - - return GetTypeInfo(type).gcType; - } - FORCEINLINE static CorInfoGCType GetGCType_NoThrow(CorElementType type) - { - LIMITED_METHOD_DAC_CONTRACT; - - return GetTypeInfo_NoThrow(type).gcType; - } - - static BOOL IsObjRef(CorElementType type) - { - WRAPPER_NO_CONTRACT; - SUPPORTS_DAC; - - return (GetGCType(type) == TYPE_GC_REF); - } - static BOOL IsObjRef_NoThrow(CorElementType type) - { - WRAPPER_NO_CONTRACT; - SUPPORTS_DAC; - - return (GetGCType_NoThrow(type) == TYPE_GC_REF); - } - - FORCEINLINE static BOOL IsGenericVariable(CorElementType type) - { - WRAPPER_NO_CONTRACT; - - return GetTypeInfo(type).isGenVar; - } - FORCEINLINE static BOOL IsGenericVariable_NoThrow(CorElementType type) - { - WRAPPER_NO_CONTRACT; - - return GetTypeInfo_NoThrow(type).isGenVar; - } - - FORCEINLINE static BOOL IsArray(CorElementType type) - { - WRAPPER_NO_CONTRACT; - - return GetTypeInfo(type).isArray; - } - FORCEINLINE static BOOL IsArray_NoThrow(CorElementType type) - { - WRAPPER_NO_CONTRACT; - - return GetTypeInfo_NoThrow(type).isArray; - } - - FORCEINLINE static BOOL IsFloat(CorElementType type) - { - WRAPPER_NO_CONTRACT; - - return GetTypeInfo(type).isFloat; - } - FORCEINLINE static BOOL IsFloat_NoThrow(CorElementType type) - { - WRAPPER_NO_CONTRACT; - - return GetTypeInfo_NoThrow(type).isFloat; - } - - FORCEINLINE static BOOL IsModifier(CorElementType type) - { - WRAPPER_NO_CONTRACT; - - return GetTypeInfo(type).isModifier; - } - FORCEINLINE static BOOL IsModifier_NoThrow(CorElementType type) - { - WRAPPER_NO_CONTRACT; - - return GetTypeInfo_NoThrow(type).isModifier; - } - - FORCEINLINE static BOOL IsPrimitiveType(CorElementType type) - { - WRAPPER_NO_CONTRACT; - - return GetTypeInfo(type).isPrim; - } - FORCEINLINE static BOOL IsPrimitiveType_NoThrow(CorElementType type) - { - WRAPPER_NO_CONTRACT; - - return GetTypeInfo_NoThrow(type).isPrim; - } - - FORCEINLINE static unsigned Size(CorElementType type) - { - WRAPPER_NO_CONTRACT; - - return GetTypeInfo(type).size; - } - FORCEINLINE static unsigned Size_NoThrow(CorElementType type) - { - WRAPPER_NO_CONTRACT; - - return GetTypeInfo_NoThrow(type).size; - } - - static CorElementType FindPrimitiveType(LPCUTF8 name); - -protected: - static const CorTypeInfoEntry info[ELEMENT_TYPE_MAX]; - -}; // class CorTypeInfo - - -// Returns the address of the payload inside the stackelem -inline void* StackElemEndianessFixup(void* pStackElem, UINT cbSize) { - LIMITED_METHOD_CONTRACT; - - BYTE *pRetVal = (BYTE*)pStackElem; - -#if BIGENDIAN - switch (cbSize) - { - case 1: - pRetVal += sizeof(void*)-1; - break; - case 2: - pRetVal += sizeof(void*)-2; - break; -#ifdef _WIN64 - case 4: - pRetVal += sizeof(void*)-4; - break; -#endif - default: - // nothing to do - break; - } -#endif - - return pRetVal; -} - -#endif /* _H_SIGINFOBASE */ diff --git a/src/inc/simplerhash.h b/src/inc/simplerhash.h deleted file mode 100644 index eb0f80d01..000000000 --- a/src/inc/simplerhash.h +++ /dev/null @@ -1,423 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#ifndef _SIMPLERHASHTABLE_H_ -#define _SIMPLERHASHTABLE_H_ - -#include "iallocator.h" - -// SimplerHashTable implements a mapping from a Key type to a Value type, -// via a hash table. - -// Synchronization is the responsibility of the caller: if a -// SimplerHash is used in a multithreaded context, the table should be -// associated with a lock. - -// SimplerHashTable actually takes four template arguments: Key, -// KeyFuncs, Value, and Behavior. We don't assume that Key has hash or equality -// functions specific names; rather, we assume that KeyFuncs has -// statics methods -// int GetHashCode(Key) -// and -// bool Equals(Key, Key) -// and use those. An -// instantiator can thus make a small "adaptor class" to invoke -// existing instance method hash and/or equality functions. If the -// implementor of a candidate Key class K understands this convention, -// these static methods can be implemented by K, so that K can be used -// as the actual arguments for the both Key and KeyTrait classes. -// -// The "Behavior" argument provides the following static members: -// -// s_growth_factor_numerator -// s_growth_factor_denominator Factor to grow allocation (numerator/denominator). -// Typically inherited from default traits (3/2) -// -// s_density_factor_numerator -// s_density_factor_denominator Maxium occupied density of table before growth -// occurs (num/denom). Typically inherited (3/4). -// -// s_minimum_allocation Minimum table allocation count (size on first growth.) It is -// probably preferable to call Reallocate on initialization rather -// than override his from the default traits. (7) -// -// NoMemory() Called when the hash table is unable to grow due to potential -// overflow or the lack of a sufficiently large prime. - -void DECLSPEC_NORETURN ThrowOutOfMemory(); - -class DefaultSimplerHashBehavior -{ -public: - static const unsigned s_growth_factor_numerator = 3; - static const unsigned s_growth_factor_denominator = 2; - - static const unsigned s_density_factor_numerator = 3; - static const unsigned s_density_factor_denominator = 4; - - static const unsigned s_minimum_allocation = 7; - - inline static void DECLSPEC_NORETURN NoMemory() - { - ::ThrowOutOfMemory(); - } -}; - -// Stores info about primes, including the magic number and shift amount needed -// to implement a divide without using the divide instruction -class PrimeInfo -{ -public: - PrimeInfo() : prime(0), magic(0), shift(0) {} - PrimeInfo(unsigned p, unsigned m, unsigned s) : prime(p), magic(m), shift(s) {} - unsigned prime; - unsigned magic; - unsigned shift; -}; - - -// Hash table class definition - -template -class SimplerHashTable -{ -public: - // Forward declaration. - class KeyIterator; - - // Constructor/destructor. SHash tables always start out empty, with no - // allocation overhead. Call Reallocate to prime with an initial size if - // desired. Pass NULL as the IAllocator* if you want to use DefaultAllocator - // (basically, operator new/delete). - - SimplerHashTable(IAllocator* alloc); - ~SimplerHashTable(); - - // operators new/delete when an IAllocator is to be used. - void * operator new(size_t sz, IAllocator * alloc); - void * operator new[](size_t sz, IAllocator * alloc); - void operator delete(void * p, IAllocator * alloc); - void operator delete[](void * p, IAllocator * alloc); - - // If the table contains a mapping for "key", returns "true" and - // sets "*pVal" to the value to which "key" maps. Otherwise, - // returns false, and does not modify "*pVal". - bool Lookup(Key k, Value* pVal = NULL) const; - - Value *LookupPointer(Key k) const; - - // Causes the table to map "key" to "val". Returns "true" if - // "key" had already been mapped by the table, "false" otherwise. - bool Set(Key k, Value val); - - // Ensures that "key" is not mapped to a value by the "table." - // Returns "true" iff it had been mapped. - bool Remove(Key k); - - // Remove all mappings in the table. - void RemoveAll(); - - // Begin and End pointers for iteration over entire table. - KeyIterator Begin() const; - KeyIterator End() const; - - // Return the number of elements currently stored in the table - unsigned GetCount() const; - -private: - // Forward declaration of the linked-list node class. - struct Node; - - unsigned GetIndexForKey(Key k) const; - - // If the table has a mapping for "k", return the node containing - // that mapping, else "NULL". - Node* FindNode(Key k) const; - - // Resizes a hash table for growth. The new size is computed based - // on the current population, growth factor, and maximum density factor. - void Grow(); - - // See if it is OK to grow the hash table by one element. If not, reallocate - // the hash table. - void CheckGrowth(); - -public: - // Reallocates a hash table to a specific size. The size must be big enough - // to hold all elements in the table appropriately. - // - // Note that the actual table size must always be a prime number; the number - // passed in will be upward adjusted if necessary. - void Reallocate(unsigned newTableSize); - - // For iteration, we use a pattern similar to the STL "forward - // iterator" pattern. It basically consists of wrapping an - // "iteration variable" in an object, and providing pointer-like - // operators on the iterator. Example usage: - // - // for (SimplerHashTable::KeyIterator iter = foo->Begin(), end = foo->End(); !iter.Equal(end); iter++) - // { - // // use foo, iter. - // } - // iter.Get() will yield (a reference to) the - // current key. It will assert the equivalent of "iter != end." - class KeyIterator - { - private: - friend class SimplerHashTable; - - // The method implementations have to be here for portability. - // Some compilers won't compile the separate implementation in shash.inl - - Node** m_table; - Node* m_node; - unsigned m_tableSize; - unsigned m_index; - - public: - KeyIterator(const SimplerHashTable *hash, BOOL begin) - : m_table(hash->m_table), - m_node(NULL), - m_tableSize(hash->m_tableSizeInfo.prime), - m_index(begin ? 0 : m_tableSize) - { - if (begin && hash->m_tableCount > 0) - { - assert(m_table != NULL); - while (m_index < m_tableSize && m_table[m_index] == NULL) - m_index++; - - if (m_index >= m_tableSize) - { - return; - } - else - { - m_node = m_table[m_index]; - } - assert(m_node != NULL); - } - } - - const Key& Get() const - { - assert(m_node != NULL); - - return m_node->m_key; - } - - const Value& GetValue() const - { - assert(m_node != NULL); - - return m_node->m_val; - } - - void SetValue(const Value & value) const - { - assert(m_node != NULL); - - m_node->m_val = value; - } - - void Next() - { - if (m_node != NULL) - { - m_node = m_node->m_next; - if (m_node != NULL) - { - return; - } - - // Otherwise... - m_index++; - } - while (m_index < m_tableSize && m_table[m_index] == NULL) - m_index++; - - if (m_index >= m_tableSize) - { - m_node = NULL; - return; - } - else - { - m_node = m_table[m_index]; - } - assert(m_node != NULL); - } - - bool Equal(const KeyIterator &i) const - { - return i.m_node == m_node; - } - - void operator++() { - Next(); - } - - void operator++(int) { - Next(); - } - }; - - // HashTableRef only exists to support operator[] - // operator[] returns a HashTableRef which enables operator[] to support reading and writing - // in a normal array, it just returns a ref an actual element, which is not possible here. - class HashTableRef - { - public: - // this is really the getter for the array. - operator Value() - { - - Value result; - table->Lookup(key, &result); - return result; - } - - void operator =(const Value v) - { - table->Set(key, v); - } - - friend class SimplerHashTable; - - protected: - HashTableRef(SimplerHashTable *t, Key k) - { - table = t; - key = k; - } - - SimplerHashTable *table; - Key key; - }; - - Value &operator[](Key k) const - { - Value* p = LookupPointer(k); - assert(p); - return *p; - } - - private: - // Find the next prime number >= the given value. - static PrimeInfo NextPrime(unsigned number); - - // Instance members - IAllocator* m_alloc; // IAllocator to use in this - // table. - // The node type. - struct Node { - Node* m_next; // Assume that the alignment requirement of Key and Value are no greater than Node*, so put m_next to avoid unnecessary padding. - Key m_key; - Value m_val; - - Node(Key k, Value v, Node* next) : m_next(next), m_key(k), m_val(v) {} - - void* operator new(size_t sz, IAllocator* alloc) - { - return alloc->Alloc(sz); - } - - void operator delete(void* p, IAllocator* alloc) - { - alloc->Free(p); - } - }; - - Node** m_table; // pointer to table - PrimeInfo m_tableSizeInfo; // size of table (a prime) and information about it - unsigned m_tableCount; // number of elements in table - unsigned m_tableMax; // maximum occupied count -}; - -#include "simplerhash.inl" - -// A few simple KeyFuncs types... - -// Base class for types whose equality function is the same as their "==". -template -struct KeyFuncsDefEquals -{ - static bool Equals(const T& x, const T& y) - { - return x == y; - } -}; - -template -struct PtrKeyFuncs: public KeyFuncsDefEquals -{ -public: - static unsigned GetHashCode(const T* ptr) - { - // Hmm. Maybe (unsigned) ought to be "ssize_t" -- or this ought to be ifdef'd by size. - return static_cast(reinterpret_cast(ptr)); - } -}; - -template // Must be coercable to "unsigned" with no loss of information. -struct SmallPrimitiveKeyFuncs: public KeyFuncsDefEquals -{ - static unsigned GetHashCode(const T& val) - { - return static_cast(val); - } -}; - -template // Assumed to be of size sizeof(UINT64). -struct LargePrimitiveKeyFuncs: public KeyFuncsDefEquals -{ - static unsigned GetHashCode(const T val) - { - // A static cast when T is a float or a double converts the value (i.e. 0.25 converts to 0) - // - // Instead we want to use all of the bits of a float to create the hash value - // So we cast the address of val to a pointer to an equivalent sized unsigned int - // This allows us to read the actual bit representation of a float type - // - // We can't read beyond the end of val, so we use sizeof(T) to determine - // exactly how many bytes to read - // - if (sizeof(T) == 8) - { - // cast &val to (UINT64 *) then deref to get the bits - UINT64 asUINT64 = *(reinterpret_cast(&val)); - - // Get the upper and lower 32-bit values from the 64-bit value - UINT32 upper32 = static_cast (asUINT64 >> 32); - UINT32 lower32 = static_cast (asUINT64 & 0xFFFFFFFF); - - // Exclusive-Or the upper32 and the lower32 values - return static_cast(upper32 ^ lower32); - - } - else if (sizeof(T) == 4) - { - // cast &val to (UINT32 *) then deref to get the bits - UINT32 asUINT32 = *(reinterpret_cast(&val)); - - // Just return the 32-bit value - return static_cast(asUINT32); - } - else if ((sizeof(T) == 2) || (sizeof(T) == 1)) - { - // For small sizes we must have an integer type - // so we can just use the static_cast. - // - return static_cast(val); - } - else - { - // Only support Hashing for types that are 8,4,2 or 1 bytes in size - assert(!"Unsupported size"); - return static_cast(val); // compile-time error here when we have a illegal size - } - } -}; - -#endif // _SIMPLERHASHTABLE_H_ diff --git a/src/inc/simplerhash.inl b/src/inc/simplerhash.inl deleted file mode 100644 index dc72acba2..000000000 --- a/src/inc/simplerhash.inl +++ /dev/null @@ -1,350 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#ifndef _SIMPLERHASHTABLE_INL_ -#define _SIMPLERHASHTABLE_INL_ - -// To implement magic-number divide with a 32-bit magic number, -// multiply by the magic number, take the top 64 bits, and shift that -// by the amount given in the table. - -inline -unsigned magicNumberDivide(unsigned numerator, const PrimeInfo &p) -{ - unsigned __int64 num = numerator; - unsigned __int64 mag = p.magic; - unsigned __int64 product = (num * mag) >> (32 + p.shift); - return (unsigned) product; -} - -inline -unsigned magicNumberRem(unsigned numerator, const PrimeInfo &p) -{ - unsigned div = magicNumberDivide(numerator, p); - unsigned result = numerator - (div * p.prime); - assert(result == numerator % p.prime); - return result; -} - -template -SimplerHashTable::SimplerHashTable(IAllocator* alloc) - : m_alloc(alloc), - m_table(NULL), - m_tableSizeInfo(), - m_tableCount(0), - m_tableMax(0) -{ - assert(m_alloc != nullptr); - -#ifndef __GNUC__ // these crash GCC - static_assert_no_msg(Behavior::s_growth_factor_numerator > Behavior::s_growth_factor_denominator); - static_assert_no_msg(Behavior::s_density_factor_numerator < Behavior::s_density_factor_denominator); -#endif -} - -template -SimplerHashTable::~SimplerHashTable() -{ - RemoveAll(); -} - -template -void * SimplerHashTable::operator new(size_t sz, IAllocator * alloc) -{ - return alloc->Alloc(sz); -} - -template -void * SimplerHashTable::operator new[](size_t sz, IAllocator * alloc) -{ - return alloc->Alloc(sz); -} - -template -void SimplerHashTable::operator delete(void * p, IAllocator * alloc) -{ - alloc->Free(p); -} - -template -void SimplerHashTable::operator delete[](void * p, IAllocator * alloc) -{ - alloc->Free(p); -} - -template -unsigned SimplerHashTable::GetCount() const -{ - return m_tableCount; -} - -template -bool SimplerHashTable::Lookup(Key key, Value* pVal) const -{ - Node* pN = FindNode(key); - - if (pN != NULL) - { - if (pVal != NULL) - { - *pVal = pN->m_val; - } - return true; - } - else - { - return false; - } -} - -template -Value *SimplerHashTable::LookupPointer(Key key) const -{ - Node* pN = FindNode(key); - - if (pN != NULL) - return &(pN->m_val); - else - return NULL; -} - -template -typename SimplerHashTable::Node* -SimplerHashTable::FindNode(Key k) const -{ - if (m_tableSizeInfo.prime == 0) - return NULL; - - unsigned index = GetIndexForKey(k); - - Node* pN = m_table[index]; - if (pN == NULL) - return NULL; - - // Otherwise... - while (pN != NULL && !KeyFuncs::Equals(k, pN->m_key)) - pN = pN->m_next; - - assert(pN == NULL || KeyFuncs::Equals(k, pN->m_key)); - - // If pN != NULL, it's the node for the key, else the key isn't mapped. - return pN; -} - -template -unsigned SimplerHashTable::GetIndexForKey(Key k) const -{ - unsigned hash = KeyFuncs::GetHashCode(k); - - unsigned index = magicNumberRem(hash, m_tableSizeInfo); - - return index; -} - -template -bool SimplerHashTable::Set(Key k, Value v) -{ - CheckGrowth(); - - assert(m_tableSizeInfo.prime != 0); - - unsigned index = GetIndexForKey(k); - - Node* pN = m_table[index]; - while (pN != NULL && !KeyFuncs::Equals(k, pN->m_key)) - { - pN = pN->m_next; - } - if (pN != NULL) - { - pN->m_val = v; - return true; - } - else - { - Node* pNewNode = new (m_alloc) Node(k, v, m_table[index]); - m_table[index] = pNewNode; - m_tableCount++; - return false; - } -} - -template -bool SimplerHashTable::Remove(Key k) -{ - unsigned index = GetIndexForKey(k); - - Node* pN = m_table[index]; - Node** ppN = &m_table[index]; - while (pN != NULL && !KeyFuncs::Equals(k, pN->m_key)) - { - ppN = &pN->m_next; - pN = pN->m_next; - } - if (pN != NULL) - { - *ppN = pN->m_next; - m_tableCount--; - Node::operator delete(pN, m_alloc); - return true; - } - else - { - return false; - } -} - -template -void SimplerHashTable::RemoveAll() -{ - for (unsigned i = 0; i < m_tableSizeInfo.prime; i++) - { - for (Node* pN = m_table[i]; pN != NULL; ) - { - Node* pNext = pN->m_next; - Node::operator delete(pN, m_alloc); - pN = pNext; - } - } - m_alloc->Free(m_table); - - m_table = NULL; - m_tableSizeInfo = PrimeInfo(); - m_tableCount = 0; - m_tableMax = 0; - - return; -} - -template -typename SimplerHashTable::KeyIterator SimplerHashTable::Begin() const -{ - KeyIterator i(this, TRUE); - return i; -} - -template -typename SimplerHashTable::KeyIterator SimplerHashTable::End() const -{ - return KeyIterator(this, FALSE); -} - -template -void SimplerHashTable::CheckGrowth() -{ - if (m_tableCount == m_tableMax) - { - Grow(); - } -} - -template -void SimplerHashTable::Grow() -{ - unsigned newSize = (unsigned) (m_tableCount - * Behavior::s_growth_factor_numerator / Behavior::s_growth_factor_denominator - * Behavior::s_density_factor_denominator / Behavior::s_density_factor_numerator); - if (newSize < Behavior::s_minimum_allocation) - newSize = Behavior::s_minimum_allocation; - - // handle potential overflow - if (newSize < m_tableCount) - Behavior::NoMemory(); - - Reallocate(newSize); -} - -template -void SimplerHashTable::Reallocate(unsigned newTableSize) -{ - assert(newTableSize >= (GetCount() * Behavior::s_density_factor_denominator / Behavior::s_density_factor_numerator)); - - // Allocation size must be a prime number. This is necessary so that hashes uniformly - // distribute to all indices, and so that chaining will visit all indices in the hash table. - PrimeInfo newPrime = NextPrime(newTableSize); - newTableSize = newPrime.prime; - - Node** newTable = (Node**)m_alloc->ArrayAlloc(newTableSize, sizeof(Node*)); - - for (unsigned i = 0; i < newTableSize; i++) { - newTable[i] = NULL; - } - - // Move all entries over to new table (re-using the Node structures.) - - for (unsigned i = 0; i < m_tableSizeInfo.prime; i++) - { - Node* pN = m_table[i]; - while (pN != NULL) - { - Node* pNext = pN->m_next; - - unsigned newIndex = magicNumberRem(KeyFuncs::GetHashCode(pN->m_key), newPrime); - pN->m_next = newTable[newIndex]; - newTable[newIndex] = pN; - - pN = pNext; - } - } - - // @todo: - // We might want to try to delay this cleanup to allow asynchronous readers - if (m_table != NULL) - m_alloc->Free(m_table); - - m_table = newTable; - m_tableSizeInfo = newPrime; - m_tableMax = (unsigned) (newTableSize * Behavior::s_density_factor_numerator / Behavior::s_density_factor_denominator); -} - -// Table of primes and their magic-number-divide constant. -// For more info see the book "Hacker's Delight" chapter 10.9 "Unsigned Division by Divisors >= 1" -// These were selected by looking for primes, each roughly twice as big as the next, having -// 32-bit magic numbers, (because the algorithm for using 33-bit magic numbers is slightly slower). -// - -SELECTANY const PrimeInfo primeInfo[] = -{ - PrimeInfo(9, 0x38e38e39, 1), - PrimeInfo(23, 0xb21642c9, 4), - PrimeInfo(59, 0x22b63cbf, 3), - PrimeInfo(131, 0xfa232cf3, 7), - PrimeInfo(239, 0x891ac73b, 7), - PrimeInfo(433, 0x975a751, 4), - PrimeInfo(761, 0x561e46a5, 8), - PrimeInfo(1399, 0xbb612aa3, 10), - PrimeInfo(2473, 0x6a009f01, 10), - PrimeInfo(4327, 0xf2555049, 12), - PrimeInfo(7499, 0x45ea155f, 11), - PrimeInfo(12973, 0x1434f6d3, 10), - PrimeInfo(22433, 0x2ebe18db, 12), - PrimeInfo(46559, 0xb42bebd5, 15), - PrimeInfo(96581, 0xadb61b1b, 16), - PrimeInfo(200341, 0x29df2461, 15), - PrimeInfo(415517, 0xa181c46d, 18), - PrimeInfo(861719, 0x4de0bde5, 18), - PrimeInfo(1787021, 0x9636c46f, 20), - PrimeInfo(3705617, 0x4870adc1, 20), - PrimeInfo(7684087, 0x8bbc5b83, 22), - PrimeInfo(15933877, 0x86c65361, 23), - PrimeInfo(33040633, 0x40fec79b, 23), - PrimeInfo(68513161, 0x7d605cd1, 25), - PrimeInfo(142069021, 0xf1da390b, 27), - PrimeInfo(294594427, 0x74a2507d, 27), - PrimeInfo(733045421, 0x5dbec447, 28), -}; - -template -PrimeInfo SimplerHashTable::NextPrime(unsigned number) -{ - for (int i = 0; i < (int) (sizeof(primeInfo) / sizeof(primeInfo[0])); i++) { - if (primeInfo[i].prime >= number) - return primeInfo[i]; - } - - // overflow - Behavior::NoMemory(); -} - -#endif // _SIMPLERHASHTABLE_INL_ diff --git a/src/inc/slist.h b/src/inc/slist.h deleted file mode 100644 index 2b81f9ba9..000000000 --- a/src/inc/slist.h +++ /dev/null @@ -1,387 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -//----------------------------------------------------------------------------- -// @File: slist.h -// - -// -// @commn: Bunch of utility classes -// -// HISTORY: -// 02/03/98: created helper classes -// SLink, link node for singly linked list, every class that is intrusively -// linked should have a data member of this type -// SList, template linked list class, contains only inline -// methods for fast list operations, with proper type checking -// -// see below for futher info. on how to use these template classes -// -//----------------------------------------------------------------------------- - -//#ifndef _H_UTIL -//#error I am a part of util.hpp Please don't include me alone ! -//#endif - - -#ifndef _H_SLIST_ -#define _H_SLIST_ - -//------------------------------------------------------------------ -// struct SLink, to use a singly linked list -// have a data member m_Link of type SLink in your class -// and instantiate the template SList class -//-------------------------------------------------------------------- - -struct SLink; -typedef DPTR(struct SLink) PTR_SLink; - -struct SLink -{ - PTR_SLink m_pNext; - SLink() - { - LIMITED_METHOD_CONTRACT; - - m_pNext = NULL; - } - - void InsertAfter(SLink* pLinkToInsert) - { - LIMITED_METHOD_CONTRACT; - PRECONDITION_MSG(NULL == pLinkToInsert->m_pNext, "This method does not support inserting lists"); - - PTR_SLink pTemp = m_pNext; - - m_pNext = PTR_SLink(pLinkToInsert); - pLinkToInsert->m_pNext = pTemp; - } - - // find pLink within the list starting at pHead - // if found remove the link from the list and return the link - // otherwise return NULL - static SLink* FindAndRemove(SLink *pHead, SLink* pLink, SLink ** ppPrior) - { - LIMITED_METHOD_CONTRACT; - - _ASSERTE(pHead != NULL); - _ASSERTE(pLink != NULL); - - SLink* pFreeLink = NULL; - *ppPrior = NULL; - - while (pHead->m_pNext != NULL) - { - if (pHead->m_pNext == pLink) - { - pFreeLink = pLink; - pHead->m_pNext = pLink->m_pNext; - *ppPrior = pHead; - break; - } - pHead = pHead->m_pNext; - } - - return pFreeLink; - } -}; - -//------------------------------------------------------------------ -// class SList. Intrusive singly linked list. -// -// To use SList with the default instantiation, your class should -// define a data member of type SLink and named 'm_Link'. To use a -// different field name, you need to provide an explicit LinkPtr -// template argument. For example: -// 'SList' -// -// SList has two different behaviours depending on boolean -// fHead variable, -// -// if fHead is true, then the list allows only InsertHead operations -// if fHead is false, then the list allows only InsertTail operations -// the code is optimized to perform these operations -// all methods are inline, and conditional compiled based on template -// argument 'fHead' -// so there is no actual code size increase -//-------------------------------------------------------------- -template -class SList -{ -public: - // typedef used by the Queue class below - typedef T ENTRY_TYPE; - -protected: - - // used as sentinel - SLink m_link; // slink.m_pNext == Null - PTR_SLink m_pHead; - PTR_SLink m_pTail; - - // get the list node within the object - static SLink* GetLink (T* pLink) - { - LIMITED_METHOD_DAC_CONTRACT; - return &(pLink->*LinkPtr); - } - - // move to the beginning of the object given the pointer within the object - static T* GetObject (SLink* pLink) - { - LIMITED_METHOD_DAC_CONTRACT; - if (pLink == NULL) - { - return NULL; - } - else - { -#ifdef __GNUC__ - // GCC defines offsetof to be __builtin_offsetof, which doesn't use the - // old-school memory model trick to determine offset. - const UINT_PTR offset = (((UINT_PTR)&(((T *)0x1000)->*LinkPtr))-0x1000); - return (T*)__PTR(dac_cast(pLink) - offset); -#else - return (T*)__PTR(dac_cast(pLink) - offsetof(T, *LinkPtr)); -#endif // __GNUC__ - } - } - -public: - - SList() - { - WRAPPER_NO_CONTRACT; -#ifndef DACCESS_COMPILE - Init(); -#endif // !defined(DACCESS_COMPILE) - } - - void Init() - { - LIMITED_METHOD_CONTRACT; - m_pHead = &m_link; - // NOTE :: fHead variable is template argument - // the following code is a compiled in, only if the fHead flag - // is set to false, - if (!fHead) - { - m_pTail = &m_link; - } - } - - bool IsEmpty() - { - LIMITED_METHOD_CONTRACT; - return m_pHead->m_pNext == NULL; - } - -#ifndef DACCESS_COMPILE - - void InsertTail(T *pObj) - { - LIMITED_METHOD_CONTRACT; - // NOTE : conditional compilation on fHead template variable - if (!fHead) - { - _ASSERTE(pObj != NULL); - SLink *pLink = GetLink(pObj); - - m_pTail->m_pNext = pLink; - m_pTail = pLink; - } - else - {// you instantiated this class asking only for InsertHead operations - _ASSERTE(0); - } - } - - void InsertHead(T *pObj) - { - LIMITED_METHOD_CONTRACT; - // NOTE : conditional compilation on fHead template variable - if (fHead) - { - _ASSERTE(pObj != NULL); - SLink *pLink = GetLink(pObj); - - pLink->m_pNext = m_pHead->m_pNext; - m_pHead->m_pNext = pLink; - } - else - {// you instantiated this class asking only for InsertTail operations - _ASSERTE(0); - } - } - - T* RemoveHead() - { - LIMITED_METHOD_CONTRACT; - SLink* pLink = m_pHead->m_pNext; - if (pLink != NULL) - { - m_pHead->m_pNext = pLink->m_pNext; - } - // conditionally compiled, if the instantiated class - // uses Insert Tail operations - if (!fHead) - { - if(m_pTail == pLink) - { - m_pTail = m_pHead; - } - } - - return GetObject(pLink); - } - -#endif // !DACCESS_COMPILE - - T* GetHead() - { - WRAPPER_NO_CONTRACT; - return GetObject(m_pHead->m_pNext); - } - - T* GetTail() - { - WRAPPER_NO_CONTRACT; - - // conditional compile - if (fHead) - { // you instantiated this class asking only for InsertHead operations - // you need to walk the list yourself to find the tail - _ASSERTE(0); - } - return (m_pHead != m_pTail) ? GetObject(m_pTail) : NULL; - } - - static T *GetNext(T *pObj) - { - WRAPPER_NO_CONTRACT; - - _ASSERTE(pObj != NULL); - return GetObject(GetLink(pObj)->m_pNext); - } - - T* FindAndRemove(T *pObj) - { - WRAPPER_NO_CONTRACT; - - _ASSERTE(pObj != NULL); - - SLink *prior; - SLink *ret = SLink::FindAndRemove(m_pHead, GetLink(pObj), &prior); - - if (ret == m_pTail) - m_pTail = prior; - - return GetObject(ret); - } - - class Iterator - { - friend class SList; - - public: - Iterator & operator++() - { _ASSERTE(m_cur != NULL); m_cur = SList::GetNext(m_cur); return *this; } - - Iterator operator++(int) - { Iterator it(m_cur); ++(*this); return it; } - - bool operator==(Iterator const & other) const - { - return m_cur == other.m_cur || - (m_cur != NULL && other.m_cur != NULL && *m_cur == *other.m_cur); - } - - bool operator!=(Iterator const & other) const - { return !(*this == other); } - - T & operator*() - { _ASSERTE(m_cur != NULL); return *m_cur; } - - T * operator->() const - { return m_cur; } - - private: - Iterator(SList * pList) - : m_cur(pList->GetHead()) - { } - - Iterator(T* pObj) - : m_cur(pObj) - { } - - Iterator() - : m_cur(NULL) - { } - - T* m_cur; - }; - - Iterator begin() - { return Iterator(GetHead()); } - - Iterator end() - { return Iterator(); } -}; - -template -struct SListElem -{ - SLink m_Link; - ElemT m_Value; - - operator ElemT const &() const - { return m_Value; } - - operator ElemT &() - { return m_Value; } - - ElemT const & operator*() const - { return m_Value; } - - ElemT & operator*() - { return m_Value; } - - ElemT const & GetValue() const - { return m_Value; } - - ElemT & GetValue() - { return m_Value; } - - SListElem() - : m_Link() - , m_Value() - { } - - template - SListElem(T1&& val) - : m_Link() - , m_Value(std::forward(val)) - { } - - template - SListElem(T1&& val1, T2&& val2) - : m_Link() - , m_Value(std::forward(val1), std::forward(val2)) - { } - - template - SListElem(T1&& val1, T2&& val2, T3&& val3) - : m_Link() - , m_Value(std::forward(val1), std::forward(val2), std::forward(val3)) - { } - - template - SListElem(T1&& val1, T2&& val2, T3&& val3, T4&& val4) - : m_Link() - , m_Value(std::forward(val1), std::forward(val2), std::forward(val3), std::forward(val4)) - { } -}; - -#endif // _H_SLIST_ - -// End of file: list.h diff --git a/src/inc/sstring.h b/src/inc/sstring.h deleted file mode 100644 index bfbaa8142..000000000 --- a/src/inc/sstring.h +++ /dev/null @@ -1,1084 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -// --------------------------------------------------------------------------- -// SString.h (Safe String) -// - -// --------------------------------------------------------------------------- - -// ------------------------------------------------------------------------------------------ -// SString is the "standard" string representation for the EE. Its has two purposes. -// (1) it provides an easy-to-use, relatively efficient, string class for APIs to standardize -// on. -// (2) it completely encapsulates all "unsafe" string operations - that is, string operations -// which yield possible buffer overrun bugs. Typesafe use of this API should help guarantee -// safety. -// -// A SString is conceptually unicode, although the internal conversion might be delayed as long as possible -// Basically it's up to the implementation whether conversion takes place immediately or is delayed, and if -// delayed, what operations trigger the conversion. -// -// Note that anywhere you express a "position" in a string, it is in terms of the Unicode representation of the -// string. -// -// If you need a direct non-unicode representation, you will have to provide a fresh SString which can -// recieve a conversion operation if necessary. -// -// The alternate encodings available are: -// 1. ASCII - string consisting entirely of ASCII (7 bit) characters. This is the only 1 byte encoding -// guaranteed to be fixed width. Such a string is also a valid instance of all the other 1 byte string -// representations, and we take advantage of this fact. -// 2. UTF-8 - standard multibyte unicode encoding. -// 3. ANSI - Potentially multibyte encoding using the ANSI page determined by GetACP(). -// -// @todo: Note that we could also provide support for several other cases (but currently do not.) -// - Page specified by GetOEMCP() (OEM page) -// - Arbitrary page support -// -// @todo: argument & overflow/underflow checking needs to be added -// ------------------------------------------------------------------------------------------ - - -#ifndef _SSTRING_H_ -#define _SSTRING_H_ - -#include "utilcode.h" -#include "sbuffer.h" - -// ========================================================================================== -// Documentational typedefs: use these to indicate specific representations of 8 bit strings: -// ========================================================================================== - -// Note that LPCSTR means ASCII (7-bit) only! - -typedef CHAR ASCII; -typedef ASCII *LPASCII; -typedef const ASCII *LPCASCII; - -typedef CHAR ANSI; -typedef ANSI *LPANSI; -typedef const ANSI *LPCANSI; - -typedef CHAR UTF8; -typedef UTF8 *LPUTF8; -typedef const UTF8 *LPCUTF8; - -// ========================================================================================== -// SString is the base class for safe strings. -// ========================================================================================== - - -typedef DPTR(class SString) PTR_SString; -class SString : private SBuffer -{ - friend struct _DacGlobals; - -private: - enum Representation - { - // Note: bits are meaningful: xVS V == Variable? S == Single byte width? - REPRESENTATION_EMPTY = 0x00, // 000 - REPRESENTATION_UNICODE = 0x04, // 100 - REPRESENTATION_ASCII = 0x01, // 001 - REPRESENTATION_UTF8 = 0x03, // 011 - REPRESENTATION_ANSI = 0x07, // 111 - - REPRESENTATION_VARIABLE_MASK = 0x02, - REPRESENTATION_SINGLE_MASK = 0x01, - REPRESENTATION_MASK = 0x07, - }; - - // Minimum guess for Printf buffer size - const static COUNT_T MINIMUM_GUESS = 20; - - -#ifdef _DEBUG - // Used to have a public ctor of this form - made it too easy to lose - // utf8 info by accident. Now you have to specify the representation type - // explicitly - this privator ctor prevents reinsertion of this ctor. - explicit SString(const ASCII *) - { - _ASSERTE(!"Don't call this."); - } -#endif - - protected: - class Index; - class UIndex; - - friend class Index; - friend class UIndex; - - public: - - // UIterator is character-level assignable. - class UIterator; - - // CIterators/Iterator'string must be modified by SString APIs. - class CIterator; - class Iterator; - - // Tokens for constructor overloads - enum tagUTF8Literal { Utf8Literal }; - enum tagLiteral { Literal }; - enum tagUTF8 { Utf8 }; - enum tagANSI { Ansi }; - enum tagASCII {Ascii }; -#ifdef SSTRING_CONSOLECODEPAGE - enum tagCONSOLE { Console }; -#endif - - static void Startup(); - static CHECK CheckStartup(); - - static const SString &Empty(); - - SString(); - - explicit SString(const SString &s); - - SString(const SString &s1, const SString &s2); - SString(const SString &s1, const SString &s2, const SString &s3); - SString(const SString &s1, const SString &s2, const SString &s3, const SString &s4); - SString(const SString &s, const CIterator &i, COUNT_T length); - SString(const SString &s, const CIterator &start, const CIterator &end); - SString(const WCHAR *string); - SString(const WCHAR *string, COUNT_T count); - SString(enum tagASCII dummyTag, const ASCII *string); - SString(enum tagASCII dummyTag, const ASCII *string, COUNT_T count); - SString(enum tagUTF8 dummytag, const UTF8 *string); - SString(enum tagUTF8 dummytag, const UTF8 *string, COUNT_T count); - SString(enum tagANSI dummytag, const ANSI *string); - SString(enum tagANSI dummytag, const ANSI *string, COUNT_T count); -#ifdef SSTRING_CONSOLECODEPAGE - SString(enum tagCONSOLE dummytag, const CONSOLE *string); - SString(enum tagCONSOLE dummytag, const CONSOLE *string, COUNT_T count); -#endif - SString(WCHAR character); - - // NOTE: Literals MUST be read-only never-freed strings. - SString(enum tagLiteral dummytag, const CHAR *literal); - SString(enum tagUTF8Literal dummytag, const UTF8 *literal); - SString(enum tagLiteral dummytag, const WCHAR *literal); - SString(enum tagLiteral dummytag, const WCHAR *literal, COUNT_T count); - - // Set this string to the concatenation of s1,s2,s3,s4 - void Set(const SString &s); - void Set(const SString &s1, const SString &s2); - void Set(const SString &s1, const SString &s2, const SString &s3); - void Set(const SString &s1, const SString &s2, const SString &s3, const SString &s4); - - // Set this string to the substring of s, starting at i, of length characters. - void Set(const SString &s, const CIterator &i, COUNT_T length); - - // Set this string to the substring of s, starting at start and ending at end (exclusive) - void Set(const SString &s, const CIterator &start, const CIterator &end); - - // Set this string to a copy of the given string - void Set(const WCHAR *string); - void SetASCII(const ASCII *string); - void SetUTF8(const UTF8 *string); - void SetANSI(const ANSI *string); -#ifdef SSTRING_CONSOLECODEPAGE - void SetConsole(const CONSOLE *string); -#endif - - // Set this string to a copy of the first count chars of the given string - void Set(const WCHAR *string, COUNT_T count); - - // Set this string to a prellocated copy of a given string. - // The caller is the owner of the bufffer and has to coordinate its lifetime. - void SetPreallocated(const WCHAR *string, COUNT_T count); - - void SetASCII(const ASCII *string, COUNT_T count); - - void SetUTF8(const UTF8 *string, COUNT_T count); - void SetANSI(const ANSI *string, COUNT_T count); -#ifdef SSTRING_CONSOLECODEPAGE - void SetConsole(const CONSOLE *string, COUNT_T count); -#endif - - // Set this string to the unicode character - void Set(WCHAR character); - - // Set this string to the UTF8 character - void SetUTF8(CHAR character); - - // This this string to the given literal. We share the mem and don't make a copy. - void SetLiteral(const CHAR *literal); - void SetLiteral(const WCHAR *literal); - - // ------------------------------------------------------------------ - // Public operations - // ------------------------------------------------------------------ - - // Normalizes the string representation to unicode. This can be used to - // make basic read-only operations non-failing. - void Normalize() const; - - // Return the number of characters in the string (excluding the terminating NULL). - COUNT_T GetCount() const; - BOOL IsEmpty() const; - - // Return whether a single byte string has all characters which fit in the ASCII set. - // (Note that this will return FALSE if the string has been converted to unicode for any - // reason.) - BOOL IsASCII() const; - - // !!!!!!!!!!!!!! WARNING about case insensitive operations !!!!!!!!!!!!!!! - // - // THIS IS NOT SUPPORTED FULLY ON WIN9x - // SString case-insensitive comparison is based off LCMapString, - // which does not work on characters outside the current OS code page. - // - // Case insensitive code in SString is primarily targeted at - // supporting path comparisons, which is supported correctly on 9x, - // since file system names are limited to the OS code page. - // - // !!!!!!!!!!!!!! WARNING about case insensitive operations !!!!!!!!!!!!!!! - - // Compute a content-based hash value - ULONG Hash() const; - ULONG HashCaseInsensitive() const; - ULONG HashCaseInsensitive(LocaleID locale) const; - - // Do a string comparison. Return 0 if the strings - // have the same value, -1 if this is "less than" s, or 1 if - // this is "greater than" s. - int Compare(const SString &s) const; - int CompareCaseInsensitive(const SString &s) const; // invariant locale - int CompareCaseInsensitive(const SString &s, LocaleID locale) const; - - // Do a case sensitive string comparison. Return TRUE if the strings - // have the same value FALSE if not. - BOOL Equals(const SString &s) const; - BOOL EqualsCaseInsensitive(const SString &s) const; // invariant locale - BOOL EqualsCaseInsensitive(const SString &s, LocaleID locale) const; - - // Match s to a portion of the string starting at the position. - // Return TRUE if the strings have the same value - // (regardless of representation), FALSE if not. - BOOL Match(const CIterator &i, const SString &s) const; - BOOL MatchCaseInsensitive(const CIterator &i, const SString &s) const; // invariant locale - BOOL MatchCaseInsensitive(const CIterator &i, const SString &s, LocaleID locale) const; - - BOOL Match(const CIterator &i, WCHAR c) const; - BOOL MatchCaseInsensitive(const CIterator &i, WCHAR c) const; // invariant locale - BOOL MatchCaseInsensitive(const CIterator &i, WCHAR c, LocaleID locale) const; - - // Like match, but advances the iterator past the match - // if successful - BOOL Skip(CIterator &i, const SString &s) const; - BOOL Skip(CIterator &i, WCHAR c) const; - - // Start searching for a match of the given string, starting at - // the given iterator point. - // If a match exists, move the iterator to point to the nearest - // occurence of s in the string and return TRUE. - // If no match exists, return FALSE and leave the iterator unchanged. - BOOL Find(CIterator &i, const SString &s) const; - BOOL Find(CIterator &i, const WCHAR *s) const; - BOOL FindASCII(CIterator &i, const ASCII *s) const; - BOOL FindUTF8(CIterator &i, const UTF8 *s) const; - BOOL Find(CIterator &i, WCHAR c) const; - - BOOL FindBack(CIterator &i, const SString &s) const; - BOOL FindBack(CIterator &i, const WCHAR *s) const; - BOOL FindBackASCII(CIterator &i, const ASCII *s) const; - BOOL FindBackUTF8(CIterator &i, const UTF8 *s) const; - BOOL FindBack(CIterator &i, WCHAR c) const; - - // Returns TRUE if this string begins with the contents of s - BOOL BeginsWith(const SString &s) const; - BOOL BeginsWithCaseInsensitive(const SString &s) const; // invariant locale - BOOL BeginsWithCaseInsensitive(const SString &s, LocaleID locale) const; - - // Returns TRUE if this string ends with the contents of s - BOOL EndsWith(const SString &s) const; - BOOL EndsWithCaseInsensitive(const SString &s) const; // invariant locale - BOOL EndsWithCaseInsensitive(const SString &s, LocaleID locale) const; - - // Sets this string to an empty string "". - void Clear(); - - // Truncate the string to the iterator position - void Truncate(const Iterator &i); - - // Append s to the end of this string. - void Append(const SString &s); - void Append(const WCHAR *s); - void AppendASCII(const CHAR *s); - void AppendUTF8(const CHAR *s); - - // Append char c to the end of this string. - void Append(const WCHAR c); - void AppendUTF8(const CHAR c); - - // Insert s into this string at the 'position'th character. - void Insert(const Iterator &i, const SString &s); - void Insert(const Iterator &i, const WCHAR *s); - void InsertASCII(const Iterator &i, const CHAR *s); - void InsertUTF8(const Iterator &i, const CHAR *s); - - // Delete substring position + length - void Delete(const Iterator &i, COUNT_T length); - - // Replace character at i with c - void Replace(const Iterator &i, WCHAR c); - - // Replace substring at (i,i+length) with s - void Replace(const Iterator &i, COUNT_T length, const SString &s); - - // Make sure that string buffer has room to grow - void Preallocate(COUNT_T characters) const; - - // Shrink buffer size as much as possible (reallocate if necessary.) - void Trim() const; - - // ------------------------------------------------------------------ - // Iterators: - // ------------------------------------------------------------------ - - // SString splits iterators into two categories. - // - // CIterator and Iterator are cheap to create, but allow only read-only - // access to the string. - // - // UIterator forces a unicode conversion, but allows - // assignment to individual string characters. They are also a bit more - // efficient once created. - - // ------------------------------------------------------------------ - // UIterator: - // ------------------------------------------------------------------ - - protected: - - class UIndex : public SBuffer::Index - { - friend class SString; - friend class Indexer; - - protected: - - UIndex(); - UIndex(SString *string, SCOUNT_T index); - WCHAR &GetAt(SCOUNT_T delta) const; - void Skip(SCOUNT_T delta); - SCOUNT_T Subtract(const UIndex &i) const; - CHECK DoCheck(SCOUNT_T delta) const; - - WCHAR *GetUnicode() const; - }; - - public: - - class UIterator : public UIndex, public Indexer - { - friend class SString; - - public: - UIterator() - { - } - - UIterator(SString *string, int index) - : UIndex(string, index) - { - } - }; - - UIterator BeginUnicode(); - UIterator EndUnicode(); - - // For CIterator & Iterator, we try our best to iterate the string without - // modifying it. (Currently, we do require an ASCII or Unicode string - // for simple WCHAR retrival, but you could imagine being more flexible - // going forward - perhaps even supporting iterating multibyte encodings - // directly.) - // - // Because of the runtime-changable nature of the string, CIterators - // require an extra member to record the character size. They also - // are unable to properly implement GetAt as required by the template - // (since there may not be a direct WCHAR pointer), so they provide - // further customization in a subclass. - // - // Normally the user expects to cast Iterators to CIterators transparently, so - // we provide a constructor on CIterator to support this. - - protected: - - class Index : public SBuffer::Index - { - friend class SString; - - friend class Indexer; - friend class Indexer; - - protected: - int m_characterSizeShift; - - Index(); - Index(SString *string, SCOUNT_T index); - BYTE &GetAt(SCOUNT_T delta) const; - void Skip(SCOUNT_T delta); - SCOUNT_T Subtract(const Index &i) const; - CHECK DoCheck(SCOUNT_T delta) const; - - void Resync(const SString *string, BYTE *ptr) const; - - const WCHAR *GetUnicode() const; - const CHAR *GetASCII() const; - - public: - // Note these should supercede the Indexer versions - // since this class comes first in the inheritence list - WCHAR operator*() const; - void operator->() const; - WCHAR operator[](int index) const; - }; - - public: - - class CIterator : public Index, public Indexer - { - friend class SString; - - public: - const Iterator &ConstCast() const - { - return *(const Iterator *)this; - } - - Iterator &ConstCast() - { - return *(Iterator *)this; - } - - operator const SBuffer::CIterator &() const - { - return *(const SBuffer::CIterator *)this; - } - - operator SBuffer::CIterator &() - { - return *(SBuffer::CIterator *)this; - } - - CIterator() - { - } - - CIterator(const SString *string, int index) - : Index(const_cast(string), index) - { - } - - // explicitly resolve these for gcc - WCHAR operator*() const { return Index::operator*(); } - void operator->() const { Index::operator->(); } - WCHAR operator[](int index) const { return Index::operator[](index); } - }; - - class Iterator : public Index, public Indexer - { - friend class SString; - - public: - operator const CIterator &() const - { - return *(const CIterator *)this; - } - - operator CIterator &() - { - return *(CIterator *)this; - } - - operator const SBuffer::Iterator &() const - { - return *(const SBuffer::Iterator *)this; - } - - operator SBuffer::Iterator &() - { - return *(SBuffer::Iterator *)this; - } - - Iterator() - { - } - - Iterator(SString *string, int index) - : Index(string, index) - { - SUPPORTS_DAC; - } - - // explicitly resolve these for gcc - WCHAR operator*() const { return Index::operator*(); } - void operator->() const { Index::operator->(); } - WCHAR operator[](int index) const { return Index::operator[](index); } - }; - - CIterator Begin() const; - CIterator End() const; - - Iterator Begin(); - Iterator End(); - - // ------------------------------------------------------------------ - // Conversion: - // ------------------------------------------------------------------ - - // Get a const pointer to the string in the current representation. - // This pointer can not be cached because it will become invalid if - // the SString changes representation or reallocates its buffer. - - // You can always get a unicode string. This will force a conversion - // if necessary. - const WCHAR *GetUnicode() const; - const WCHAR *GetUnicode(const CIterator &i) const; - - void LowerCase(); - void UpperCase(); - - // Helper function to convert string in-place to lower-case (no allocation overhead for SString instance) - static void LowerCase(__inout_z LPWSTR wszString); - - // These routines will use the given scratch string if necessary - // to perform a conversion to the desired representation - - // Use a local declaration of InlineScratchBuffer or StackScratchBuffer for parameters of - // AbstractScratchBuffer. - class AbstractScratchBuffer; - - // These routines will use the given scratch buffer if necessary - // to perform a conversion to the desired representation. Note that - // the lifetime of the pointer return is limited by BOTH the - // scratch string and the source (this) string. - // - // Typical usage: - // - // SString *s = ...; - // { - // StackScratchBuffer buffer; - // const UTF8 *utf8 = s->GetUTF8(buffer); - // CallFoo(utf8); - // } - // // No more pointers to returned buffer allowed. - - const UTF8 *GetUTF8(AbstractScratchBuffer &scratch) const; - const UTF8 *GetUTF8(AbstractScratchBuffer &scratch, COUNT_T *pcbUtf8) const; - const ANSI *GetANSI(AbstractScratchBuffer &scratch) const; -#ifdef SSTRING_CONSOLECODEPAGE - const CONSOLE *GetConsole(AbstractScratchBuffer &scratch) const; -#endif - - // Used when the representation is known, throws if the representation doesn't match - const UTF8 *GetUTF8NoConvert() const; - - // Converts/copies into the given output string - void ConvertToUnicode(SString &dest) const; - void ConvertToANSI(SString &dest) const; - COUNT_T ConvertToUTF8(SString &dest) const; -#ifdef SSTRING_CONSOLECODEPAGE - void ConvertToConsole(SString &dest) const; -#endif - - //------------------------------------------------------------------- - // Accessing the string contents directly - //------------------------------------------------------------------- - - // To write directly to the SString's underlying buffer: - // 1) Call OpenXXXBuffer() and pass it the count of characters - // you need. (Not including the null-terminator). - // 2) That returns a pointer to the raw buffer which you can write to. - // 3) When you are done writing to the pointer, call CloseBuffer() - // and pass it the count of characters you actually wrote (not including - // the null). The pointer from step 1 is now invalid. - - // example usage: - // void GetName(SString & str) { - // char * p = str.OpenANSIBuffer(3); - // strcpy(p, "Cat"); - // str.CloseBuffer(); - // } - - // Regarding the null-terminator: - // 1) Note that we wrote 4 characters (3 + a null). That's ok. OpenBuffer - // allocates 1 extra byte for the null. - // 2) If we only wrote 3 characters and no null, that's ok too. CloseBuffer() - // will add a null-terminator. - - // You should open the buffer, write the data, and immediately close it. - // No sstring operations are valid while the buffer is opened. - // - // In a debug build, Open/Close will do lots of little checks to make sure - // you don't buffer overflow while it's opened. In a retail build, this - // is a very streamlined action. - - - // Open the raw buffer for writing countChars characters (not including the null). - WCHAR *OpenUnicodeBuffer(COUNT_T maxCharCount); - UTF8 *OpenUTF8Buffer(COUNT_T maxSingleCharCount); - ANSI *OpenANSIBuffer(COUNT_T maxSingleCharCount); - - //Returns the unicode string, the caller is reponsible for lifetime of the string - WCHAR *GetCopyOfUnicodeString(); - - // Get the max size that can be passed to OpenUnicodeBuffer without causing allocations. - COUNT_T GetUnicodeAllocation(); - - // Call after OpenXXXBuffer(). - - // Provide the count of characters actually used (not including the - // null terminator). This will make sure the SString's size is correct - // and that we have a null-terminator. - void CloseBuffer(COUNT_T finalCount); - - // Close the buffer. Assumes that we completely filled the buffer - // that OpenBuffer() gave back. If we didn't write all the characters, - // call CloseBuffer(int) instead. - void CloseBuffer(); - -#ifdef DACCESS_COMPILE - // DAC access to string functions. - // Note that other accessors above are not DAC-safe and will return TARGET pointers into - // the string instead of copying the string over to the host. - // @dbgtodo dac support: Prevent usage of such DAC-unsafe SString APIs in DAC code - - // Instantiate a copy of the raw buffer in the host and return a pointer to it - void * DacGetRawContent() const; - - // Instantiate a copy of the raw buffer in the host. Requires that the underlying - // representation is already unicode. - const WCHAR * DacGetRawUnicode() const; - - // Copy the string from the target into the provided buffer, converting to unicode if necessary - bool DacGetUnicode(COUNT_T bufChars, - __out_z __inout_ecount(bufChars) WCHAR * buffer, - COUNT_T * needChars) const; - - void EnumMemoryRegions(CLRDataEnumMemoryFlags flags) const - { - SUPPORTS_DAC; - SBuffer::EnumMemoryRegions(flags); - } -#endif - - //--------------------------------------------------------------------- - // Utilities - //--------------------------------------------------------------------- - - // WARNING: The MBCS version of printf function are factory for globalization - // issues when used to format Unicode strings (%S). The Unicode versions are - // preffered in this case. - void Printf(const CHAR *format, ...); - void VPrintf(const CHAR *format, va_list args); - - void Printf(const WCHAR *format, ...); - void PPrintf(const WCHAR *format, ...); - void VPrintf(const WCHAR *format, va_list args); - - void PVPrintf(const WCHAR *format, va_list args); - - void AppendPrintf(const CHAR *format, ...); - void AppendVPrintf(const CHAR *format, va_list args); - - void AppendPrintf(const WCHAR *format, ...); - void AppendVPrintf(const WCHAR *format, va_list args); - - BOOL LoadResource(CCompRC::ResourceCategory eCategory, int resourceID); - HRESULT LoadResourceAndReturnHR(CCompRC::ResourceCategory eCategory, int resourceID); - HRESULT LoadResourceAndReturnHR(CCompRC* pResourceDLL, CCompRC::ResourceCategory eCategory, int resourceID); - BOOL FormatMessage(DWORD dwFlags, LPCVOID lpSource, DWORD dwMessageId, DWORD dwLanguageId, - const SString &arg1 = Empty(), const SString &arg2 = Empty(), - const SString &arg3 = Empty(), const SString &arg4 = Empty(), - const SString &arg5 = Empty(), const SString &arg6 = Empty(), - const SString &arg7 = Empty(), const SString &arg8 = Empty(), - const SString &arg9 = Empty(), const SString &arg10 = Empty()); - -#if 1 - // @todo - get rid of this and move it outside of SString - void MakeFullNamespacePath(const SString &nameSpace, const SString &name); -#endif - - //-------------------------------------------------------------------- - // Operators - //-------------------------------------------------------------------- - - operator const WCHAR * () const { WRAPPER_NO_CONTRACT; return GetUnicode(); } - - WCHAR operator[](int index) { WRAPPER_NO_CONTRACT; return Begin()[index]; } - WCHAR operator[](int index) const { WRAPPER_NO_CONTRACT; return Begin()[index]; } - - SString &operator= (const SString &s) { WRAPPER_NO_CONTRACT; Set(s); return *this; } - SString &operator+= (const SString &s) { WRAPPER_NO_CONTRACT; Append(s); return *this; } - - // ------------------------------------------------------------------- - // Check functions - // ------------------------------------------------------------------- - - CHECK CheckIteratorRange(const CIterator &i) const; - CHECK CheckIteratorRange(const CIterator &i, COUNT_T length) const; - CHECK CheckEmpty() const; - - static CHECK CheckCount(COUNT_T count); - static CHECK CheckRepresentation(int representation); - -#if CHECK_INVARIANTS - static CHECK CheckASCIIString(const ASCII *string); - static CHECK CheckASCIIString(const ASCII *string, COUNT_T count); - - CHECK Check() const; - CHECK Invariant() const; - CHECK InternalInvariant() const; -#endif // CHECK_INVARIANTS - - // Helpers for CRT function equivalance. - static int __cdecl _stricmp(const CHAR *buffer1, const CHAR *buffer2); - static int __cdecl _strnicmp(const CHAR *buffer1, const CHAR *buffer2, COUNT_T count); - - static int __cdecl _wcsicmp(const WCHAR *buffer1, const WCHAR *buffer2); - static int __cdecl _wcsnicmp(const WCHAR *buffer1, const WCHAR *buffer2, COUNT_T count); - - // C++ convenience overloads - static int _tstricmp(const CHAR *buffer1, const CHAR *buffer2); - static int _tstricmp(const WCHAR *buffer1, const WCHAR *buffer2); - - static int _tstrnicmp(const CHAR *buffer1, const CHAR *buffer2, COUNT_T count); - static int _tstrnicmp(const WCHAR *buffer1, const WCHAR *buffer2, COUNT_T count); - - // ------------------------------------------------------------------- - // Internal routines - // ------------------------------------------------------------------- - - - protected: - // Use this via InlineSString - SString(void *buffer, COUNT_T size); - - private: - static int CaseCompareHelperA(const CHAR *buffer1, const CHAR *buffer2, COUNT_T count, LocaleID lcid, BOOL stopOnNull, BOOL stopOnCount); - static int CaseCompareHelper(const WCHAR *buffer1, const WCHAR *buffer2, COUNT_T count, LocaleID lcid, BOOL stopOnNull, BOOL stopOnCount); - - // Internal helpers: - - static const BYTE s_EmptyBuffer[2]; - - static UINT s_ACP; - SVAL_DECL(BOOL, s_IsANSIMultibyte); - -#ifdef SSTRING_CONSOLECODEPAGE - static UINT s_ConsoleCP; - static BOOL s_IsConsoleMultibyte; -#endif - - const static LocaleID s_defaultLCID; - - SPTR_DECL(SString,s_Empty); - - COUNT_T GetRawCount() const; - - // Get buffer as appropriate string rep - ASCII *GetRawASCII() const; - UTF8 *GetRawUTF8() const; - ANSI *GetRawANSI() const; - WCHAR *GetRawUnicode() const; -#ifdef SSTRING_CONSOLECODEPAGE - CONSOLE *GetRawConsole() const; -#endif - - void InitEmpty(); - - Representation GetRepresentation() const; - void SetRepresentation(Representation representation); - BOOL IsRepresentation(Representation representation) const; - BOOL IsFixedSize() const; - BOOL IsIteratable() const; - BOOL IsSingleByte() const; - - int GetCharacterSizeShift() const; - - COUNT_T SizeToCount(COUNT_T size) const; - COUNT_T CountToSize(COUNT_T count) const; - - COUNT_T GetBufferSizeInCharIncludeNullChar() const; - - BOOL IsLiteral() const; - BOOL IsAllocated() const; - BOOL IsBufferOpen() const; - BOOL IsASCIIScanned() const; - void SetASCIIScanned() const; - void SetNormalized() const; - BOOL IsNormalized() const; - void ClearNormalized() const; - - void EnsureWritable() const; - void ConvertToFixed() const; - void ConvertToIteratable() const; - - void ConvertASCIIToUnicode(SString &dest) const; - void ConvertToUnicode() const; - void ConvertToUnicode(const CIterator &i) const; - - const SString &GetCompatibleString(const SString &s, SString &scratch) const; - const SString &GetCompatibleString(const SString &s, SString &scratch, const CIterator &i) const; - BOOL ScanASCII() const; - void NullTerminate(); - - void Resize(COUNT_T count, Representation representation, - Preserve preserve = DONT_PRESERVE); - - void OpenBuffer(Representation representation, COUNT_T countChars); -}; - -// =========================================================================== -// InlineSString is used for stack allocation of strings, or when the string contents -// are expected or known to be small. Note that it still supports expandability via -// heap allocation if necessary. -// =========================================================================== - -template -class InlineSString : public SString -{ -private: - BYTE m_inline[SBUFFER_PADDED_SIZE(MEMSIZE)]; - -public: - FORCEINLINE InlineSString() - : SString(m_inline, SBUFFER_PADDED_SIZE(MEMSIZE)) - { - WRAPPER_NO_CONTRACT; - } - - FORCEINLINE InlineSString(const SString &s) - : SString(m_inline, SBUFFER_PADDED_SIZE(MEMSIZE)) - { - WRAPPER_NO_CONTRACT; - Set(s); - } - - FORCEINLINE InlineSString(const SString &s1, const SString &s2) - : SString(m_inline, SBUFFER_PADDED_SIZE(MEMSIZE)) - { - WRAPPER_NO_CONTRACT; - Set(s1, s2); - } - - FORCEINLINE InlineSString(const SString &s1, const SString &s2, const SString &s3) - : SString(m_inline, SBUFFER_PADDED_SIZE(MEMSIZE)) - { - WRAPPER_NO_CONTRACT; - Set(s1, s2, s3); - } - - FORCEINLINE InlineSString(const SString &s1, const SString &s2, const SString &s3, const SString &s4) - : SString(m_inline, SBUFFER_PADDED_SIZE(MEMSIZE)) - { - WRAPPER_NO_CONTRACT; - Set(s1, s2, s3, s4); - } - - FORCEINLINE InlineSString(const SString &s, const CIterator &start, const CIterator &end) - : SString(m_inline, SBUFFER_PADDED_SIZE(MEMSIZE)) - { - WRAPPER_NO_CONTRACT; - Set(s, start, end); - } - - FORCEINLINE InlineSString(const SString &s, const CIterator &i, COUNT_T length) - : SString(m_inline, SBUFFER_PADDED_SIZE(MEMSIZE)) - { - WRAPPER_NO_CONTRACT; - Set(s, i, length); - } - - FORCEINLINE InlineSString(const WCHAR *string) - : SString(m_inline, SBUFFER_PADDED_SIZE(MEMSIZE)) - { - WRAPPER_NO_CONTRACT; - Set(string); - } - - FORCEINLINE InlineSString(const WCHAR *string, COUNT_T count) - : SString(m_inline, SBUFFER_PADDED_SIZE(MEMSIZE)) - { - WRAPPER_NO_CONTRACT; - Set(string, count); - } - - FORCEINLINE InlineSString(enum tagASCII, const CHAR *string) - : SString(m_inline, SBUFFER_PADDED_SIZE(MEMSIZE)) - { - WRAPPER_NO_CONTRACT; - SetASCII(string); - } - - FORCEINLINE InlineSString(enum tagASCII, const CHAR *string, COUNT_T count) - : SString(m_inline, SBUFFER_PADDED_SIZE(MEMSIZE)) - { - WRAPPER_NO_CONTRACT; - SetASCII(string, count); - } - - FORCEINLINE InlineSString(tagUTF8 dummytag, const UTF8 *string) - : SString(m_inline, SBUFFER_PADDED_SIZE(MEMSIZE)) - { - WRAPPER_NO_CONTRACT; - SetUTF8(string); - } - - FORCEINLINE InlineSString(tagUTF8 dummytag, const UTF8 *string, COUNT_T count) - : SString(m_inline, SBUFFER_PADDED_SIZE(MEMSIZE)) - { - WRAPPER_NO_CONTRACT; - SetUTF8(string, count); - } - - FORCEINLINE InlineSString(enum tagANSI dummytag, const ANSI *string) - : SString(m_inline, SBUFFER_PADDED_SIZE(MEMSIZE)) - { - WRAPPER_NO_CONTRACT; - SetANSI(string); - } - - FORCEINLINE InlineSString(enum tagANSI dummytag, const ANSI *string, COUNT_T count) - : SString(m_inline, SBUFFER_PADDED_SIZE(MEMSIZE)) - { - WRAPPER_NO_CONTRACT; - SetANSI(string, count); - } - -#ifdef SSTRING_CONSOLECODEPAGE - FORCEINLINE InlineSString(enum tagCONSOLE dummytag, const CONSOLE *string) - : SString(m_inline, SBUFFER_PADDED_SIZE(MEMSIZE)) - { - WRAPPER_NO_CONTRACT; - SetCONSOLE(string); - } - - FORCEINLINE InlineSString(enum tagCONSOLE dummytag, const CONSOLE *string, COUNT_T count) - : SString(m_inline, SBUFFER_PADDED_SIZE(MEMSIZE)) - { - WRAPPER_NO_CONTRACT; - SetCONSOLE(string, count); - } -#endif - - FORCEINLINE InlineSString(WCHAR character) - : SString(m_inline, SBUFFER_PADDED_SIZE(MEMSIZE)) - { - WRAPPER_NO_CONTRACT; - Set(character); - } - - FORCEINLINE InlineSString(tagUTF8 dummytag, const UTF8 character) - : SString(m_inline, SBUFFER_PADDED_SIZE(MEMSIZE)) - { - WRAPPER_NO_CONTRACT; - SetUTF8(character); - } - - FORCEINLINE InlineSString &operator= (const SString &s) - { - WRAPPER_NO_CONTRACT; - Set(s); - return *this; - } - - FORCEINLINE InlineSString &operator= (const InlineSString &s) - { - WRAPPER_NO_CONTRACT; - Set(s); - return *this; - } -}; - -// ================================================================================ -// StackSString is a lot like CQuickBytes. Use it to create an SString object -// using some stack space as a preallocated buffer. -// ================================================================================ - -typedef InlineSString<512> StackSString; - -// This is a smaller version for when it is known that the string that's going to -// be needed is small and it's preferable not to take up the stack space. -typedef InlineSString<32> SmallStackSString; - -// To be used specifically for path strings. -#ifdef _DEBUG -// This is a smaller version for debug builds to exercise the buffer allocation path -typedef InlineSString<32> PathString; -typedef InlineSString<2 * 32> LongPathString; -#else -// Set it to the current MAX_PATH -typedef InlineSString<260> PathString; -typedef InlineSString<2 * 260> LongPathString; -#endif - -// ================================================================================ -// Quick macro to create an SString around a literal string. -// usage: -// s = SL("My literal String"); -// ================================================================================ - -#define SL(_literal) SString(SString::Literal, _literal) - -// ================================================================================ -// ScratchBuffer classes are used by the GetXXX() routines to allocate scratch space in. -// ================================================================================ - -class SString::AbstractScratchBuffer : private SString -{ - protected: - // Do not use this class directly - use - // ScratchBuffer or StackScratchBuffer. - AbstractScratchBuffer(void *buffer, COUNT_T size); -}; - -template -class ScratchBuffer : public SString::AbstractScratchBuffer -{ - private: - BYTE m_inline[MEMSIZE]; - - public: - ScratchBuffer() - : AbstractScratchBuffer((void *)m_inline, MEMSIZE) - { - WRAPPER_NO_CONTRACT; - } -}; - -typedef ScratchBuffer<256> StackScratchBuffer; - -// ================================================================================ -// Special contract definition - THROWS_UNLESS_NORMALIZED -// this is used for operations which might fail for generalized strings but -// not if the string has already been converted to unicode. Rather than just -// setting this on all conversions to unicode, we only set it when explicitly -// asked. This should expose more potential problems. -// ================================================================================ - -#define THROWS_UNLESS_NORMALIZED \ - if (IsNormalized()) NOTHROW; else THROWS - -#define THROWS_UNLESS_BOTH_NORMALIZED(s) \ - if (IsNormalized() && s.IsNormalized()) NOTHROW; else THROWS - -#define FAULTS_UNLESS_NORMALIZED(stmt) \ - if (IsNormalized()) FORBID_FAULT; else INJECT_FAULT(stmt) - -#define FAULTS_UNLESS_BOTH_NORMALIZED(s, stmt) \ - if (IsNormalized() && s.IsNormalized()) FORBID_FAULT; else INJECT_FAULT(stmt) - -// ================================================================================ -// Inline definitions -// ================================================================================ - -#include - -#endif // _SSTRING_H_ diff --git a/src/inc/sstring.inl b/src/inc/sstring.inl deleted file mode 100644 index 88139ad0c..000000000 --- a/src/inc/sstring.inl +++ /dev/null @@ -1,2279 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -// - -#ifndef _SSTRING_INL_ -#define _SSTRING_INL_ - -#include "sstring.h" - -#if defined(_MSC_VER) -#pragma inline_depth (20) -#endif - -#ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable:4702) // Disable bogus unreachable code warning -#endif // _MSC_VER - -//#define SSTRING_EXTRA_CHECKS -#ifdef SSTRING_EXTRA_CHECKS -#define SS_CONTRACT CONTRACT -#define SS_CONTRACT_VOID CONTRACT_VOID -#define SS_CONTRACT_END CONTRACT_END -#define SS_RETURN RETURN -#define SS_CONSTRUCTOR_CHECK CONSTRUCTOR_CHECK -#define SS_PRECONDITION PRECONDITION -#define SS_POSTCONDITION POSTCONDITION - -#else //SSTRING_EXTRA_CHECKS - -#define SS_CONTRACT(x) CONTRACTL -#define SS_CONTRACT_VOID CONTRACTL -#define SS_CONTRACT_END CONTRACTL_END -#define SS_RETURN return -#define SS_CONSTRUCTOR_CHECK -#define SS_PRECONDITION(x) -#define SS_POSTCONDITION(x) -//Do I need this instance check at all? - -#endif - - -// --------------------------------------------------------------------------- -// Inline implementations. Pay no attention to that man behind the curtain. -// --------------------------------------------------------------------------- - -//---------------------------------------------------------------------------- -// Default constructor. Sets the string to the empty string. -//---------------------------------------------------------------------------- -inline SString::SString() - : SBuffer(Immutable, s_EmptyBuffer, sizeof(s_EmptyBuffer)) -{ -#ifdef SSTRING_EXTRA_CHECKS - CONTRACT_VOID - { - CONSTRUCTOR_CHECK; - POSTCONDITION(IsEmpty()); - NOTHROW; - SO_TOLERANT; - GC_NOTRIGGER; - } - CONTRACT_END; - - RETURN; -#else - STATIC_CONTRACT_NOTHROW; - STATIC_CONTRACT_SO_TOLERANT; - STATIC_CONTRACT_GC_NOTRIGGER; - STATIC_CONTRACT_SUPPORTS_DAC_HOST_ONLY; -#endif -} - -inline SString::SString(void *buffer, COUNT_T size) - : SBuffer(Prealloc, buffer, size) -{ - SS_CONTRACT_VOID - { - SS_CONSTRUCTOR_CHECK; - PRECONDITION(CheckPointer(buffer)); - PRECONDITION(CheckSize(size)); - SS_POSTCONDITION(IsEmpty()); - NOTHROW; - GC_NOTRIGGER; - SUPPORTS_DAC_HOST_ONLY; - } - SS_CONTRACT_END; - - if (size < sizeof(WCHAR)) - { - // Ignore the useless buffer - SetImmutable(s_EmptyBuffer, sizeof(s_EmptyBuffer)); - } - else - { - SBuffer::TweakSize(sizeof(WCHAR)); - GetRawUnicode()[0] = 0; - } - - SS_RETURN; -} - -inline SString::SString(const SString &s) - : SBuffer(Immutable, s_EmptyBuffer, sizeof(s_EmptyBuffer)) -{ - SS_CONTRACT_VOID - { - SS_CONSTRUCTOR_CHECK; - PRECONDITION(s.Check()); - SS_POSTCONDITION(Equals(s)); - THROWS; - GC_NOTRIGGER; - } - SS_CONTRACT_END; - - Set(s); - - SS_RETURN; -} - -inline SString::SString(const SString &s1, const SString &s2) - : SBuffer(Immutable, s_EmptyBuffer, sizeof(s_EmptyBuffer)) -{ - SS_CONTRACT_VOID - { - SS_CONSTRUCTOR_CHECK; - PRECONDITION(s1.Check()); - PRECONDITION(s2.Check()); - THROWS; - GC_NOTRIGGER; - } - SS_CONTRACT_END; - - Set(s1, s2); - - SS_RETURN; -} - -inline SString::SString(const SString &s1, const SString &s2, const SString &s3) - : SBuffer(Immutable, s_EmptyBuffer, sizeof(s_EmptyBuffer)) -{ - SS_CONTRACT_VOID - { - SS_CONSTRUCTOR_CHECK; - PRECONDITION(s1.Check()); - PRECONDITION(s2.Check()); - PRECONDITION(s3.Check()); - THROWS; - GC_NOTRIGGER; - } - SS_CONTRACT_END; - - Set(s1, s2, s3); - - SS_RETURN; -} - -inline SString::SString(const SString &s1, const SString &s2, const SString &s3, const SString &s4) - : SBuffer(Immutable, s_EmptyBuffer, sizeof(s_EmptyBuffer)) -{ - SS_CONTRACT_VOID - { - SS_CONSTRUCTOR_CHECK; - PRECONDITION(s1.Check()); - PRECONDITION(s2.Check()); - PRECONDITION(s3.Check()); - PRECONDITION(s4.Check()); - THROWS; - } - SS_CONTRACT_END; - - Set(s1, s2, s3, s4); - - SS_RETURN; -} - -inline SString::SString(const SString &s, const CIterator &i, COUNT_T count) - : SBuffer(Immutable, s_EmptyBuffer, sizeof(s_EmptyBuffer)) -{ - SS_CONTRACT_VOID - { - SS_CONSTRUCTOR_CHECK; - PRECONDITION(s.Check()); - PRECONDITION(i.Check()); - PRECONDITION(CheckCount(count)); - SS_POSTCONDITION(s.Match(i, *this)); - SS_POSTCONDITION(GetRawCount() == count); - THROWS; - GC_NOTRIGGER; - } - SS_CONTRACT_END; - - Set(s, i, count); - - SS_RETURN; -} - -inline SString::SString(const SString &s, const CIterator &start, const CIterator &end) - : SBuffer(Immutable, s_EmptyBuffer, sizeof(s_EmptyBuffer)) -{ - SS_CONTRACT_VOID - { - SS_CONSTRUCTOR_CHECK; - PRECONDITION(s.Check()); - PRECONDITION(start.Check()); - PRECONDITION(s.CheckIteratorRange(start)); - PRECONDITION(end.Check()); - PRECONDITION(s.CheckIteratorRange(end)); - PRECONDITION(start <= end); - SS_POSTCONDITION(s.Match(start, *this)); - SS_POSTCONDITION(GetRawCount() == (COUNT_T) (end - start)); - THROWS; - GC_NOTRIGGER; - } - SS_CONTRACT_END; - - Set(s, start, end); - - SS_RETURN; -} - -inline SString::SString(const WCHAR *string) - : SBuffer(Immutable, s_EmptyBuffer, sizeof(s_EmptyBuffer)) -{ - SS_CONTRACT_VOID - { - SS_CONSTRUCTOR_CHECK; - PRECONDITION(CheckPointer(string, NULL_OK)); - THROWS; - GC_NOTRIGGER; - } - SS_CONTRACT_END; - - Set(string); - - SS_RETURN; -} - -inline SString::SString(const WCHAR *string, COUNT_T count) - : SBuffer(Immutable, s_EmptyBuffer, sizeof(s_EmptyBuffer)) -{ - SS_CONTRACT_VOID - { - SS_CONSTRUCTOR_CHECK; - PRECONDITION(CheckPointer(string, NULL_OK)); - PRECONDITION(CheckCount(count)); - THROWS; - GC_NOTRIGGER; - } - SS_CONTRACT_END; - - Set(string, count); - - SS_RETURN; -} - -inline SString::SString(enum tagASCII, const ASCII *string) - : SBuffer(Immutable, s_EmptyBuffer, sizeof(s_EmptyBuffer)) -{ - SS_CONTRACT_VOID - { - SS_CONSTRUCTOR_CHECK; - PRECONDITION(CheckPointer(string, NULL_OK)); - PRECONDITION(CheckASCIIString(string)); - THROWS; - GC_NOTRIGGER; - } - SS_CONTRACT_END; - - SetASCII(string); - - SS_RETURN; -} - -inline SString::SString(enum tagASCII, const ASCII *string, COUNT_T count) - : SBuffer(Immutable, s_EmptyBuffer, sizeof(s_EmptyBuffer)) -{ - SS_CONTRACT_VOID - { - SS_CONSTRUCTOR_CHECK; - PRECONDITION(CheckPointer(string, NULL_OK)); - PRECONDITION(CheckASCIIString(string, count)); - PRECONDITION(CheckCount(count)); - THROWS; - GC_NOTRIGGER; - } - SS_CONTRACT_END; - - SetASCII(string, count); - - SS_RETURN; -} - -inline SString::SString(tagUTF8 dummytag, const UTF8 *string) - : SBuffer(Immutable, s_EmptyBuffer, sizeof(s_EmptyBuffer)) -{ - SS_CONTRACT_VOID - { - SS_CONSTRUCTOR_CHECK; - // !!! Check for illegal UTF8 encoding? - PRECONDITION(CheckPointer(string, NULL_OK)); - THROWS; - GC_NOTRIGGER; - SUPPORTS_DAC; - } - SS_CONTRACT_END; - - SetUTF8(string); - - SS_RETURN; -} - -inline SString::SString(tagUTF8 dummytag, const UTF8 *string, COUNT_T count) - : SBuffer(Immutable, s_EmptyBuffer, sizeof(s_EmptyBuffer)) -{ - SS_CONTRACT_VOID - { - SS_CONSTRUCTOR_CHECK; - // !!! Check for illegal UTF8 encoding? - PRECONDITION(CheckPointer(string, NULL_OK)); - PRECONDITION(CheckCount(count)); - THROWS; - GC_NOTRIGGER; - } - SS_CONTRACT_END; - - SetUTF8(string, count); - - SS_RETURN; -} - -inline SString::SString(tagANSI dummytag, const ANSI *string) - : SBuffer(Immutable, s_EmptyBuffer, sizeof(s_EmptyBuffer)) -{ - SS_CONTRACT_VOID - { - SS_CONSTRUCTOR_CHECK; - PRECONDITION(CheckPointer(string, NULL_OK)); - THROWS; - GC_NOTRIGGER; - } - SS_CONTRACT_END; - - SetANSI(string); - - SS_RETURN; -} - -inline SString::SString(tagANSI dummytag, const ANSI *string, COUNT_T count) - : SBuffer(Immutable, s_EmptyBuffer, sizeof(s_EmptyBuffer)) -{ - SS_CONTRACT_VOID - { - SS_CONSTRUCTOR_CHECK; - PRECONDITION(CheckPointer(string, NULL_OK)); - PRECONDITION(CheckCount(count)); - THROWS; - GC_NOTRIGGER; - } - SS_CONTRACT_END; - - SetANSI(string, count); - - SS_RETURN; -} - -inline SString::SString(WCHAR character) - : SBuffer(Immutable, s_EmptyBuffer, sizeof(s_EmptyBuffer)) -{ - SS_CONTRACT_VOID - { - SS_CONSTRUCTOR_CHECK; - THROWS; - GC_NOTRIGGER; - } - SS_CONTRACT_END; - - Set(character); - - SS_RETURN; -} - -inline SString::SString(tagLiteral dummytag, const ASCII *literal) - : SBuffer(Immutable, (const BYTE *) literal, (COUNT_T) (strlen(literal)+1)*sizeof(CHAR)) -{ - SS_CONTRACT_VOID - { - SS_CONSTRUCTOR_CHECK; - PRECONDITION(CheckPointer(literal)); - PRECONDITION(CheckASCIIString(literal)); - NOTHROW; - GC_NOTRIGGER; - SUPPORTS_DAC_HOST_ONLY; - } - SS_CONTRACT_END; - - SetRepresentation(REPRESENTATION_ASCII); - - SS_RETURN; -} - -inline SString::SString(tagUTF8Literal dummytag, const UTF8 *literal) - : SBuffer(Immutable, (const BYTE *) literal, (COUNT_T) (strlen(literal)+1)*sizeof(CHAR)) -{ - SS_CONTRACT_VOID - { - SS_CONSTRUCTOR_CHECK; - PRECONDITION(CheckPointer(literal)); - NOTHROW; - GC_NOTRIGGER; - } - SS_CONTRACT_END; - - SetRepresentation(REPRESENTATION_UTF8); - - SS_RETURN; -} - -inline SString::SString(tagLiteral dummytag, const WCHAR *literal) - : SBuffer(Immutable, (const BYTE *) literal, (COUNT_T) (wcslen(literal)+1)*sizeof(WCHAR)) -{ - SS_CONTRACT_VOID - { - SS_CONSTRUCTOR_CHECK; - PRECONDITION(CheckPointer(literal)); - NOTHROW; - GC_NOTRIGGER; - } - SS_CONTRACT_END; - - SetRepresentation(REPRESENTATION_UNICODE); - SetNormalized(); - - SS_RETURN; -} - -inline SString::SString(tagLiteral dummytag, const WCHAR *literal, COUNT_T count) - : SBuffer(Immutable, (const BYTE *) literal, (count + 1) * sizeof(WCHAR)) -{ - SS_CONTRACT_VOID - { - SS_CONSTRUCTOR_CHECK; - PRECONDITION(CheckPointer(literal)); - NOTHROW; - GC_NOTRIGGER; - } - SS_CONTRACT_END; - - SetRepresentation(REPRESENTATION_UNICODE); - SetNormalized(); - - SS_RETURN; -} - -//----------------------------------------------------------------------------- -// Set this string to s -// s - source string -//----------------------------------------------------------------------------- -inline void SString::Set(const SString &s) -{ - SS_CONTRACT_VOID - { - INSTANCE_CHECK; - PRECONDITION(s.Check()); - SS_POSTCONDITION(Equals(s)); - THROWS; - GC_NOTRIGGER; - SUPPORTS_DAC; - } - SS_CONTRACT_END; - - SBuffer::Set(s); - SetRepresentation(s.GetRepresentation()); - ClearNormalized(); - - SS_RETURN; -} - -//----------------------------------------------------------------------------- -// Set this string to concatenation of s1 and s2 -//----------------------------------------------------------------------------- -inline void SString::Set(const SString &s1, const SString &s2) -{ - SS_CONTRACT_VOID - { - INSTANCE_CHECK; - PRECONDITION(s1.Check()); - PRECONDITION(s2.Check()); - THROWS; - GC_NOTRIGGER; - } - SS_CONTRACT_END; - - Preallocate(s1.GetCount() + s2.GetCount()); - - Set(s1); - Append(s2); - - SS_RETURN; -} - -//----------------------------------------------------------------------------- -// Set this string to concatenation of s1, s2, and s3 -//----------------------------------------------------------------------------- -inline void SString::Set(const SString &s1, const SString &s2, const SString &s3) -{ - SS_CONTRACT_VOID - { - INSTANCE_CHECK; - PRECONDITION(s1.Check()); - PRECONDITION(s2.Check()); - PRECONDITION(s3.Check()); - THROWS; - GC_NOTRIGGER; - } - SS_CONTRACT_END; - - Preallocate(s1.GetCount() + s2.GetCount() + s3.GetCount()); - - Set(s1); - Append(s2); - Append(s3); - - SS_RETURN; -} - -//----------------------------------------------------------------------------- -// Set this string to concatenation of s1, s2, s3, and s4 -//----------------------------------------------------------------------------- -inline void SString::Set(const SString &s1, const SString &s2, const SString &s3, const SString &s4) -{ - SS_CONTRACT_VOID - { - INSTANCE_CHECK; - PRECONDITION(s1.Check()); - PRECONDITION(s2.Check()); - PRECONDITION(s3.Check()); - PRECONDITION(s4.Check()); - THROWS; - GC_NOTRIGGER; - } - SS_CONTRACT_END; - - Preallocate(s1.GetCount() + s2.GetCount() + s3.GetCount() + s4.GetCount()); - - Set(s1); - Append(s2); - Append(s3); - Append(s4); - - SS_RETURN; -} - -//----------------------------------------------------------------------------- -// Set this string to the substring from s. -// s - the source string -// start - the character to start at -// length - number of characters to copy from s. -//----------------------------------------------------------------------------- -inline void SString::Set(const SString &s, const CIterator &i, COUNT_T count) -{ - SS_CONTRACT_VOID - { - INSTANCE_CHECK; - PRECONDITION(s.Check()); - PRECONDITION(i.Check()); - PRECONDITION(CheckCount(count)); - SS_POSTCONDITION(s.Match(i, *this)); - SS_POSTCONDITION(GetRawCount() == count); - THROWS; - GC_NOTRIGGER; - } - SS_CONTRACT_END; - - // @todo: detect case where we can reuse literal? - Resize(count, s.GetRepresentation()); - SBuffer::Copy(SBuffer::Begin(), i.m_ptr, count<= start); - SS_POSTCONDITION(s.Match(start, *this)); - SS_POSTCONDITION(GetRawCount() == (COUNT_T) (end - start)); - THROWS; - GC_NOTRIGGER; - } - SS_CONTRACT_END; - - Set(s, start, end - start); - - SS_RETURN; -} - -// Return a global empty string -inline const SString &SString::Empty() -{ -#ifdef SSTRING_EXTRA_CHECKS - CONTRACTL - { - // POSTCONDITION(RETVAL.IsEmpty()); - PRECONDITION(CheckStartup()); - NOTHROW; - GC_NOTRIGGER; - CANNOT_TAKE_LOCK; - SO_TOLERANT; - SUPPORTS_DAC; - } - CONTRACTL_END; -#else - STATIC_CONTRACT_NOTHROW; - STATIC_CONTRACT_GC_NOTRIGGER; - STATIC_CONTRACT_CANNOT_TAKE_LOCK; - STATIC_CONTRACT_SO_TOLERANT; - STATIC_CONTRACT_SUPPORTS_DAC; -#endif - - _ASSERTE(s_Empty != NULL); // Did you call SString::Startup()? - return *s_Empty; -} - -// Get a const pointer to the internal buffer as a unicode string. -inline const WCHAR *SString::GetUnicode() const -{ - SS_CONTRACT(const WCHAR *) - { - GC_NOTRIGGER; - PRECONDITION(CheckPointer(this)); - SS_POSTCONDITION(CheckPointer(RETVAL)); - if (IsRepresentation(REPRESENTATION_UNICODE)) NOTHROW; else THROWS; - GC_NOTRIGGER; - SUPPORTS_DAC; - } - SS_CONTRACT_END; - - if (this == NULL) - SS_RETURN NULL; - - ConvertToUnicode(); - - SS_RETURN GetRawUnicode(); -} - -// Normalize the string to unicode. This will make many operations nonfailing. -inline void SString::Normalize() const -{ - SS_CONTRACT_VOID - { - INSTANCE_CHECK; - SS_POSTCONDITION(IsNormalized()); - THROWS_UNLESS_NORMALIZED; - GC_NOTRIGGER; - } - SS_CONTRACT_END; - - ConvertToUnicode(); - SetNormalized(); - - SS_RETURN; -} - -// Get a const pointer to the internal buffer as a unicode string. -inline const WCHAR *SString::GetUnicode(const CIterator &i) const -{ - SS_CONTRACT(const WCHAR *) - { - INSTANCE_CHECK; - PRECONDITION(CheckIteratorRange(i)); - THROWS_UNLESS_NORMALIZED; - GC_NOTRIGGER; - } - SS_CONTRACT_END; - - PRECONDITION(CheckPointer(this)); - - ConvertToUnicode(i); - - SS_RETURN i.GetUnicode(); -} - -// Append s to the end of this string. -inline void SString::Append(const SString &s) -{ - SS_CONTRACT_VOID - { - GC_NOTRIGGER; - PRECONDITION(CheckPointer(this)); - PRECONDITION(s.Check()); - THROWS; - SUPPORTS_DAC_HOST_ONLY; - } - SS_CONTRACT_END; - - Insert(End(), s); - - SS_RETURN; -} - -inline void SString::Append(const WCHAR *string) -{ - SS_CONTRACT_VOID - { - GC_NOTRIGGER; - PRECONDITION(CheckPointer(this)); - PRECONDITION(CheckPointer(string)); - THROWS; - SUPPORTS_DAC_HOST_ONLY; - } - SS_CONTRACT_END; - - // Wrap the string in temporary SString without copying it - SString s(SString::Literal, string); - s.ClearImmutable(); - Append(s); - - SS_RETURN; -} - -inline void SString::AppendASCII(const CHAR *string) -{ - SS_CONTRACT_VOID - { - GC_NOTRIGGER; - PRECONDITION(CheckPointer(this)); - PRECONDITION(CheckPointer(string)); - THROWS; - } - SS_CONTRACT_END; - - StackSString s(SString::Ascii, string); - Append(s); - - SS_RETURN; -} - -inline void SString::AppendUTF8(const CHAR *string) -{ - SS_CONTRACT_VOID - { - GC_NOTRIGGER; - PRECONDITION(CheckPointer(this)); - PRECONDITION(CheckPointer(string)); - THROWS; - } - SS_CONTRACT_END; - - StackSString s(SString::Utf8, string); - Append(s); - - SS_RETURN; -} - -inline void SString::Append(const WCHAR c) -{ - SS_CONTRACT_VOID - { - GC_NOTRIGGER; - PRECONDITION(CheckPointer(this)); - THROWS; - } - SS_CONTRACT_END; - - InlineSString<2 * sizeof(c)> s(c); - Append(s); - - SS_RETURN; -} - -inline void SString::AppendUTF8(const CHAR c) -{ - SS_CONTRACT_VOID - { - GC_NOTRIGGER; - PRECONDITION(CheckPointer(this)); - THROWS; - SUPPORTS_DAC_HOST_ONLY; - } - SS_CONTRACT_END; - - InlineSString<2 * sizeof(c)> s(SString::Utf8, c); - Append(s); - - SS_RETURN; -} - -// Turn this on to test that these if you are testing common scenarios dealing with -// ASCII strings that do not touch the cases where this family of function differs -// in behavior for expected reasons. -//#define VERIFY_CRT_EQUIVALNCE 1 - -// Helpers for CRT function equivalance. -/* static */ -inline int __cdecl SString::_stricmp(const CHAR *buffer1, const CHAR *buffer2) { - WRAPPER_NO_CONTRACT; - int returnValue = CaseCompareHelperA(buffer1, buffer2, 0, s_defaultLCID, TRUE, FALSE); -#ifdef VERIFY_CRT_EQUIVALNCE - _ASSERTE((returnValue == 0) == (::_stricmp(buffer1, buffer2) == 0)); -#endif - return returnValue; - -} - -/* static */ -inline int __cdecl SString::_strnicmp(const CHAR *buffer1, const CHAR *buffer2, COUNT_T count) { - WRAPPER_NO_CONTRACT; - int returnValue = CaseCompareHelperA(buffer1, buffer2, count, s_defaultLCID, TRUE, TRUE); -#ifdef VERIFY_CRT_EQUIVALNCE - _ASSERTE((returnValue == 0) == (::_strnicmp(buffer1, buffer2, count) == 0)); -#endif - return returnValue; -} - -/* static */ -inline int __cdecl SString::_wcsicmp(const WCHAR *buffer1, const WCHAR *buffer2) { - WRAPPER_NO_CONTRACT; - int returnValue = CaseCompareHelper(buffer1, buffer2, 0, s_defaultLCID, TRUE, FALSE); -#ifdef VERIFY_CRT_EQUIVALNCE - _ASSERTE((returnValue == 0) == (::_wcsicmp(buffer1, buffer2) == 0)); -#endif - return returnValue; - -} - -/* static */ -inline int __cdecl SString::_wcsnicmp(const WCHAR *buffer1, const WCHAR *buffer2, COUNT_T count) { - WRAPPER_NO_CONTRACT; - int returnValue = CaseCompareHelper(buffer1, buffer2, count, s_defaultLCID, TRUE, TRUE); -#ifdef VERIFY_CRT_EQUIVALNCE - _ASSERTE((returnValue == 0) == (::_wcsnicmp(buffer1, buffer2, count) == 0)); -#endif - return returnValue; -} - -inline int SString::_tstricmp(const CHAR *buffer1, const CHAR *buffer2) -{ - return _stricmp(buffer1, buffer2); -} - -inline int SString::_tstricmp(const WCHAR *buffer1, const WCHAR *buffer2) -{ - return _wcsicmp(buffer1, buffer2); -} - -inline int SString::_tstrnicmp(const CHAR *buffer1, const CHAR *buffer2, COUNT_T count) -{ - return _strnicmp(buffer1, buffer2, count); -} - -inline int SString::_tstrnicmp(const WCHAR *buffer1, const WCHAR *buffer2, COUNT_T count) -{ - return _wcsnicmp(buffer1, buffer2, count); -} - -inline ULONG SString::HashCaseInsensitive() const -{ - WRAPPER_NO_CONTRACT; - return HashCaseInsensitive(s_defaultLCID); -} - -inline int SString::CompareCaseInsensitive(const SString &s) const -{ - WRAPPER_NO_CONTRACT; - return CompareCaseInsensitive(s, s_defaultLCID); -} - -inline BOOL SString::EqualsCaseInsensitive(const SString &s) const -{ - WRAPPER_NO_CONTRACT; - return EqualsCaseInsensitive(s, s_defaultLCID); -} - -inline BOOL SString::MatchCaseInsensitive(const CIterator &i, const SString &s) const -{ - WRAPPER_NO_CONTRACT; - return MatchCaseInsensitive(i, s, s_defaultLCID); -} - -inline BOOL SString::MatchCaseInsensitive(const CIterator &i, WCHAR c) const -{ - WRAPPER_NO_CONTRACT; - return MatchCaseInsensitive(i, c, s_defaultLCID); -} - -inline BOOL SString::Match(const CIterator &i, WCHAR c) const -{ - SS_CONTRACT(BOOL) - { - GC_NOTRIGGER; - INSTANCE_CHECK; - PRECONDITION(CheckIteratorRange(i)); - NOTHROW; - } - SS_CONTRACT_END; - - // End() will not throw here - CONTRACT_VIOLATION(ThrowsViolation); - SS_RETURN (i < End() && i[0] == c); -} - -inline BOOL SString::Skip(CIterator &i, const SString &s) const -{ - SS_CONTRACT(BOOL) - { - GC_NOTRIGGER; - INSTANCE_CHECK; - PRECONDITION(CheckIteratorRange(i)); - PRECONDITION(s.Check()); - THROWS_UNLESS_BOTH_NORMALIZED(s); - } - SS_CONTRACT_END; - - if (Match(i, s)) - { - i += s.GetRawCount(); - SS_RETURN TRUE; - } - else - SS_RETURN FALSE; -} - -inline BOOL SString::Skip(CIterator &i, WCHAR c) const -{ - SS_CONTRACT(BOOL) - { - GC_NOTRIGGER; - INSTANCE_CHECK; - PRECONDITION(CheckIteratorRange(i)); - NOTHROW; - } - SS_CONTRACT_END; - - if (Match(i, c)) - { - i++; - SS_RETURN TRUE; - } - else - SS_RETURN FALSE; -} - -// Find string within this string. Return TRUE and update iterator if found -inline BOOL SString::Find(CIterator &i, const WCHAR *string) const -{ - SS_CONTRACT(BOOL) - { - GC_NOTRIGGER; - PRECONDITION(CheckPointer(this)); - PRECONDITION(CheckIteratorRange(i)); - PRECONDITION(CheckPointer(string)); - SS_POSTCONDITION(RETVAL == Match(i, SString(string))); - THROWS; - } - SS_CONTRACT_END; - - StackSString s(string); - SS_RETURN Find(i, s); -} - -inline BOOL SString::FindASCII(CIterator &i, const CHAR *string) const -{ - SS_CONTRACT(BOOL) - { - GC_NOTRIGGER; - PRECONDITION(CheckPointer(this)); - PRECONDITION(CheckIteratorRange(i)); - PRECONDITION(CheckPointer(string)); - SS_POSTCONDITION(RETVAL == Match(i, SString(SString::Ascii, string))); - THROWS; - } - SS_CONTRACT_END; - - StackSString s(SString::Ascii, string); - SS_RETURN Find(i, s); -} - -inline BOOL SString::FindUTF8(CIterator &i, const CHAR *string) const -{ - SS_CONTRACT(BOOL) - { - GC_NOTRIGGER; - PRECONDITION(CheckPointer(this)); - PRECONDITION(CheckIteratorRange(i)); - PRECONDITION(CheckPointer(string)); - SS_POSTCONDITION(RETVAL == Match(i, SString(SString::Ascii, string))); - THROWS; - } - SS_CONTRACT_END; - - StackSString s(SString::Utf8, string); - SS_RETURN Find(i, s); -} - -inline BOOL SString::FindBack(CIterator &i, const WCHAR *string) const -{ - SS_CONTRACT(BOOL) - { - GC_NOTRIGGER; - PRECONDITION(CheckPointer(this)); - PRECONDITION(CheckIteratorRange(i)); - PRECONDITION(CheckPointer(string)); - SS_POSTCONDITION(RETVAL == Match(i, SString(string))); - THROWS; - } - SS_CONTRACT_END; - - StackSString s(string); - SS_RETURN FindBack(i, s); -} - -inline BOOL SString::FindBackASCII(CIterator &i, const CHAR *string) const -{ - SS_CONTRACT(BOOL) - { - GC_NOTRIGGER; - PRECONDITION(CheckPointer(this)); - PRECONDITION(CheckIteratorRange(i)); - PRECONDITION(CheckPointer(string)); - SS_POSTCONDITION(RETVAL == Match(i, SString(SString::Ascii, string))); - THROWS; - } - SS_CONTRACT_END; - - StackSString s(SString::Ascii, string); - SS_RETURN FindBack(i, s); -} - -inline BOOL SString::FindBackUTF8(CIterator &i, const CHAR *string) const -{ - SS_CONTRACT(BOOL) - { - GC_NOTRIGGER; - PRECONDITION(CheckPointer(this)); - PRECONDITION(CheckIteratorRange(i)); - PRECONDITION(CheckPointer(string)); - SS_POSTCONDITION(RETVAL == Match(i, SString(SString::Ascii, string))); - THROWS; - } - SS_CONTRACT_END; - - StackSString s(SString::Utf8, string); - SS_RETURN FindBack(i, s); -} - -// Insert string at iterator position -inline void SString::Insert(const Iterator &i, const SString &s) -{ - SS_CONTRACT_VOID - { - GC_NOTRIGGER; - PRECONDITION(CheckPointer(this)); - PRECONDITION(CheckIteratorRange(i)); - PRECONDITION(s.Check()); - THROWS; - SUPPORTS_DAC_HOST_ONLY; - } - SS_CONTRACT_END; - - Replace(i, 0, s); - - SS_RETURN; -} - -inline void SString::Insert(const Iterator &i, const WCHAR *string) -{ - SS_CONTRACT_VOID - { - GC_NOTRIGGER; - PRECONDITION(CheckPointer(this)); - PRECONDITION(CheckIteratorRange(i)); - PRECONDITION(CheckPointer(string)); - THROWS; - } - SS_CONTRACT_END; - - StackSString s(string); - Replace(i, 0, s); - - SS_RETURN; -} - -inline void SString::InsertASCII(const Iterator &i, const CHAR *string) -{ - SS_CONTRACT_VOID - { - GC_NOTRIGGER; - PRECONDITION(CheckPointer(this)); - PRECONDITION(CheckIteratorRange(i)); - PRECONDITION(CheckPointer(string)); - THROWS; - } - SS_CONTRACT_END; - - StackSString s(SString::Ascii, string); - Replace(i, 0, s); - - SS_RETURN; -} - -inline void SString::InsertUTF8(const Iterator &i, const CHAR *string) -{ - SS_CONTRACT_VOID - { - GC_NOTRIGGER; - PRECONDITION(CheckPointer(this)); - PRECONDITION(CheckIteratorRange(i)); - PRECONDITION(CheckPointer(string)); - THROWS; - } - SS_CONTRACT_END; - - StackSString s(SString::Utf8, string); - Replace(i, 0, s); - - SS_RETURN; -} - -// Delete string at iterator position -inline void SString::Delete(const Iterator &i, COUNT_T length) -{ - SS_CONTRACT_VOID - { - GC_NOTRIGGER; - PRECONDITION(CheckPointer(this)); - PRECONDITION(CheckIteratorRange(i, length)); - THROWS; - SUPPORTS_DAC_HOST_ONLY; - } - SS_CONTRACT_END; - - Replace(i, length, Empty()); - - SS_RETURN; -} - -// Preallocate some space for the string buffer -inline void SString::Preallocate(COUNT_T characters) const -{ - WRAPPER_NO_CONTRACT; - - // Assume unicode since we may get converted - SBuffer::Preallocate(characters * sizeof(WCHAR)); -} - -// Trim unused space from the buffer -inline void SString::Trim() const -{ - WRAPPER_NO_CONTRACT; - - if (GetRawCount() == 0) - { - // Share the global empty string buffer. - const_cast(this)->SBuffer::SetImmutable(s_EmptyBuffer, sizeof(s_EmptyBuffer)); - } - else - { - SBuffer::Trim(); - } -} - -// RETURN true if the string is empty. -inline BOOL SString::IsEmpty() const -{ - SS_CONTRACT(BOOL) - { - GC_NOTRIGGER; - PRECONDITION(CheckPointer(this)); - NOTHROW; - SO_TOLERANT; - SUPPORTS_DAC; - } - SS_CONTRACT_END; - - SS_RETURN (GetRawCount() == 0); -} - -// RETURN true if the string rep is ASCII. -inline BOOL SString::IsASCII() const -{ - SS_CONTRACT(BOOL) - { - GC_NOTRIGGER; - PRECONDITION(CheckPointer(this)); - NOTHROW; - SO_TOLERANT; - } - SS_CONTRACT_END; - - SS_RETURN IsRepresentation(REPRESENTATION_ASCII); -} - -// Get the number of characters in the string (excluding the terminating NULL) -inline COUNT_T SString::GetCount() const -{ - SS_CONTRACT(COUNT_T) - { - GC_NOTRIGGER; - PRECONDITION(CheckPointer(this)); - SS_POSTCONDITION(CheckCount(RETVAL)); - THROWS_UNLESS_NORMALIZED; - SUPPORTS_DAC; - } - SS_CONTRACT_END; - - ConvertToFixed(); - - SS_RETURN SizeToCount(GetSize()); -} - -// Private helpers: -// Return the current size of the string (even if it is multibyte) -inline COUNT_T SString::GetRawCount() const -{ - WRAPPER_NO_CONTRACT; - - return SizeToCount(GetSize()); -} - -// Private helpers: -// get string contents as a particular character set: - -inline ASCII *SString::GetRawASCII() const -{ - LIMITED_METHOD_DAC_CONTRACT; - - return (ASCII *) m_buffer; -} - -inline UTF8 *SString::GetRawUTF8() const -{ - LIMITED_METHOD_DAC_CONTRACT; - - return (UTF8 *) m_buffer; -} - -inline ANSI *SString::GetRawANSI() const -{ - LIMITED_METHOD_DAC_CONTRACT; - - return (ANSI *) m_buffer; -} - -inline WCHAR *SString::GetRawUnicode() const -{ - LIMITED_METHOD_CONTRACT; - SUPPORTS_DAC_HOST_ONLY; - - return (WCHAR *)m_buffer; -} - -// Private helper: -// get the representation (ansi, unicode, utf8) -inline SString::Representation SString::GetRepresentation() const -{ - WRAPPER_NO_CONTRACT; - - return (Representation) SBuffer::GetRepresentationField(); -} - -// Private helper. -// Set the representation. -inline void SString::SetRepresentation(SString::Representation representation) -{ -#ifdef SSTRING_EXTRA_CHECKS - CONTRACT_VOID - { - GC_NOTRIGGER; - NOTHROW; - PRECONDITION(CheckPointer(this)); - PRECONDITION(CheckRepresentation(representation)); - POSTCONDITION(GetRepresentation() == representation); - } - CONTRACT_END; -#else //SSTRING_EXTRA_CHECKS - STATIC_CONTRACT_NOTHROW; - STATIC_CONTRACT_GC_NOTRIGGER; - STATIC_CONTRACT_SUPPORTS_DAC_HOST_ONLY; -#endif //SSTRING_EXTRA_CHECKS - - SBuffer::SetRepresentationField((int) representation); - - SS_RETURN; -} - -// Private helper: -// Get the amount to shift the byte size to get a character count -inline int SString::GetCharacterSizeShift() const -{ - WRAPPER_NO_CONTRACT; - - // Note that the flag is backwards; we want the default - // value to match the default representation (empty) - return (GetRepresentation()&REPRESENTATION_SINGLE_MASK) == 0; -} - -//---------------------------------------------------------------------------- -// Private helper. -// We know the buffer should be m_count characters. Place a null terminator -// in the buffer to make our internal string null-terminated at that length. -//---------------------------------------------------------------------------- -FORCEINLINE void SString::NullTerminate() -{ - SUPPORTS_DAC_HOST_ONLY; -#ifdef SSTRING_EXTRA_CHECKS - CONTRACT_VOID - { - POSTCONDITION(CheckPointer(this)); - NOTHROW; - GC_NOTRIGGER; - } - CONTRACT_END; -#else //SSTRING_EXTRA_CHECKS - STATIC_CONTRACT_NOTHROW; - STATIC_CONTRACT_GC_NOTRIGGER; -#endif //SSTRING_EXTRA_CHECKS - - BYTE *end = m_buffer + GetSize(); - - if (GetRepresentation()&REPRESENTATION_SINGLE_MASK) - { - ((CHAR *)end)[-1] = 0; - } - else - { - ((WCHAR *)end)[-1] = 0; - } - - SS_RETURN; -} - -//---------------------------------------------------------------------------- -// private helper -// Return true if the string is a literal. -// A literal string has immutable memory. -//---------------------------------------------------------------------------- -inline BOOL SString::IsLiteral() const -{ - WRAPPER_NO_CONTRACT; - - return SBuffer::IsImmutable() && (m_buffer != s_EmptyBuffer); -} - -//---------------------------------------------------------------------------- -// private helper: -// RETURN true if the string allocated (and should delete) its buffer. -// IsAllocated() will RETURN false for Literal strings and -// stack-based strings (the buffer is on the stack) -//---------------------------------------------------------------------------- -inline BOOL SString::IsAllocated() const -{ - WRAPPER_NO_CONTRACT; - - return SBuffer::IsAllocated(); -} - -//---------------------------------------------------------------------------- -// Return true after we call OpenBuffer(), but before we close it. -// All SString operations are illegal while the buffer is open. -//---------------------------------------------------------------------------- -#if _DEBUG -inline BOOL SString::IsBufferOpen() const -{ - WRAPPER_NO_CONTRACT; - - return SBuffer::IsOpened(); -} -#endif - -//---------------------------------------------------------------------------- -// Return true if we've scanned the string to see if it is in the ASCII subset. -//---------------------------------------------------------------------------- -inline BOOL SString::IsASCIIScanned() const -{ - WRAPPER_NO_CONTRACT; - SUPPORTS_DAC; - - return SBuffer::IsFlag1(); -} - -//---------------------------------------------------------------------------- -// Set that we've scanned the string to see if it is in the ASCII subset. -//---------------------------------------------------------------------------- -inline void SString::SetASCIIScanned() const -{ - WRAPPER_NO_CONTRACT; - SUPPORTS_DAC_HOST_ONLY; - - const_cast(this)->SBuffer::SetFlag1(); -} - -//---------------------------------------------------------------------------- -// Return true if we've normalized the string to unicode -//---------------------------------------------------------------------------- -inline BOOL SString::IsNormalized() const -{ - WRAPPER_NO_CONTRACT; - SUPPORTS_DAC; - - return SBuffer::IsFlag3(); -} - -//---------------------------------------------------------------------------- -// Set that we've normalized the string to unicode -//---------------------------------------------------------------------------- -inline void SString::SetNormalized() const -{ - WRAPPER_NO_CONTRACT; - - const_cast(this)->SBuffer::SetFlag3(); -} - -//---------------------------------------------------------------------------- -// Clear normalization -//---------------------------------------------------------------------------- -inline void SString::ClearNormalized() const -{ - WRAPPER_NO_CONTRACT; - SUPPORTS_DAC_HOST_ONLY; - - const_cast(this)->SBuffer::ClearFlag3(); -} - -//---------------------------------------------------------------------------- -// Private helper. -// Check to see if the string representation has single byte size -//---------------------------------------------------------------------------- -inline BOOL SString::IsSingleByte() const -{ - STATIC_CONTRACT_NOTHROW; - STATIC_CONTRACT_GC_NOTRIGGER; - - return ((GetRepresentation()&REPRESENTATION_SINGLE_MASK) != 0); -} - -//---------------------------------------------------------------------------- -// Private helper. -// Check to see if the string representation has fixed size characters -//---------------------------------------------------------------------------- -inline BOOL SString::IsFixedSize() const -{ - STATIC_CONTRACT_NOTHROW; - STATIC_CONTRACT_GC_NOTRIGGER; - STATIC_CONTRACT_SUPPORTS_DAC; - - if (GetRepresentation()&REPRESENTATION_VARIABLE_MASK) - return ((GetRepresentation() == REPRESENTATION_ANSI) && !s_IsANSIMultibyte); - else - return TRUE; -} - -//---------------------------------------------------------------------------- -// Private helper. -// Check to see if the string representation is appropriate for iteration -//---------------------------------------------------------------------------- -inline BOOL SString::IsIteratable() const -{ - STATIC_CONTRACT_NOTHROW; - STATIC_CONTRACT_GC_NOTRIGGER; - STATIC_CONTRACT_SUPPORTS_DAC; - - // Note that in many cases ANSI may be fixed width. However we - // currently still do not allow iterating on them, because we would have to - // do character-by-character conversion on a character dereference (which must - // go to unicode) . We may want to adjust this going forward to - // depending on perf in the non-ASCII but fixed width ANSI case. - - return ((GetRepresentation()&REPRESENTATION_VARIABLE_MASK) == 0); -} - -//---------------------------------------------------------------------------- -// Private helper -// Return the size of the given string in bytes -// in the given representation. -// count does not include the null-terminator, but the RETURN value does. -//---------------------------------------------------------------------------- -inline COUNT_T SString::CountToSize(COUNT_T count) const -{ - SS_CONTRACT(COUNT_T) - { - GC_NOTRIGGER; - PRECONDITION(CheckCount(count)); - SS_POSTCONDITION(SizeToCount(RETVAL) == count); - NOTHROW; - SUPPORTS_DAC; - } - SS_CONTRACT_END; - - SS_RETURN (count+1) << GetCharacterSizeShift(); -} - -//---------------------------------------------------------------------------- -// Private helper. -// Return the maxmimum count of characters that could fit in a buffer of -// 'size' bytes in the given representation. -// 'size' includes the null terminator, but the RETURN value does not. -//---------------------------------------------------------------------------- -inline COUNT_T SString::SizeToCount(COUNT_T size) const -{ - SS_CONTRACT(COUNT_T) - { - GC_NOTRIGGER; - PRECONDITION(CheckSize(size)); - SS_POSTCONDITION(CountToSize(RETVAL) == size); - NOTHROW; - SO_TOLERANT; - SUPPORTS_DAC; - } - SS_CONTRACT_END; - - SS_RETURN (size >> GetCharacterSizeShift()) - 1; -} - -//---------------------------------------------------------------------------- -// Private helper. -// Return the maxmimum count of characters that could fit in the current -// buffer including NULL terminator. -//---------------------------------------------------------------------------- -inline COUNT_T SString::GetBufferSizeInCharIncludeNullChar() const -{ - STATIC_CONTRACT_GC_NOTRIGGER; - STATIC_CONTRACT_NOTHROW; - STATIC_CONTRACT_SO_TOLERANT; - STATIC_CONTRACT_SUPPORTS_DAC; - - return (GetSize() >> GetCharacterSizeShift()); -} - - - -//---------------------------------------------------------------------------- -// Assert helper -// Asser that the iterator is within the given string. -//---------------------------------------------------------------------------- -inline CHECK SString::CheckIteratorRange(const CIterator &i) const -{ - CANNOT_HAVE_CONTRACT; - CHECK(i >= Begin()); - CHECK(i <= End()); // Note that it's OK to look at the terminating null - CHECK_OK; -} - -//---------------------------------------------------------------------------- -// Assert helper -// Asser that the iterator is within the given string. -//---------------------------------------------------------------------------- -inline CHECK SString::CheckIteratorRange(const CIterator &i, COUNT_T length) const -{ - CANNOT_HAVE_CONTRACT; - CHECK(i >= Begin()); - CHECK(i + length <= End()); // Note that it's OK to look at the terminating null - CHECK_OK; -} - -//---------------------------------------------------------------------------- -// Assert that the string is empty -//---------------------------------------------------------------------------- -inline CHECK SString::CheckEmpty() const -{ - CANNOT_HAVE_CONTRACT; - CHECK(IsEmpty()); - CHECK_OK; -} - -//---------------------------------------------------------------------------- -// Check the range of a count -//---------------------------------------------------------------------------- -inline CHECK SString::CheckCount(COUNT_T count) -{ - CANNOT_HAVE_CONTRACT; - CHECK(CheckSize(count*sizeof(WCHAR))); - CHECK_OK; -} - -//---------------------------------------------------------------------------- -// Check the representation field -//---------------------------------------------------------------------------- -inline CHECK SString::CheckRepresentation(int representation) -{ - CANNOT_HAVE_CONTRACT; -#ifdef SSTRING_CONSOLECODEPAGE - CHECK(representation == REPRESENTATION_EMPTY - || representation == REPRESENTATION_UNICODE - || representation == REPRESENTATION_ASCII - || representation == REPRESENTATION_UTF8 - || representation == REPRESENTATION_ANSI - || representation == REPRESENTATION_CONSOLE); -#else - CHECK(representation == REPRESENTATION_EMPTY - || representation == REPRESENTATION_UNICODE - || representation == REPRESENTATION_ASCII - || representation == REPRESENTATION_UTF8 - || representation == REPRESENTATION_ANSI); -#endif - CHECK((representation & REPRESENTATION_MASK) == representation); - - CHECK_OK; -} - -#if CHECK_INVARIANTS -//---------------------------------------------------------------------------- -// Assert helper. Check that the string only uses the ASCII subset of -// codes. -//---------------------------------------------------------------------------- -inline CHECK SString::CheckASCIIString(const CHAR *string) -{ - CANNOT_HAVE_CONTRACT; - if (string != NULL) - CHECK(CheckASCIIString(string, (int) strlen(string))); - CHECK_OK; -} - -inline CHECK SString::CheckASCIIString(const CHAR *string, COUNT_T count) -{ - CANNOT_HAVE_CONTRACT; -#if _DEBUG - const CHAR *sEnd = string + count; - while (string < sEnd) - { - CHECK_MSG((*string & 0x80) == 0x00, "Found non-ASCII character in string."); - string++; - } -#endif - CHECK_OK; -} - -//---------------------------------------------------------------------------- -// Check routine and invariants. -//---------------------------------------------------------------------------- - -inline CHECK SString::Check() const -{ - CANNOT_HAVE_CONTRACT; - CHECK(SBuffer::Check()); - CHECK_OK; -} - -inline CHECK SString::Invariant() const -{ - CANNOT_HAVE_CONTRACT; - CHECK(SBuffer::Invariant()); - CHECK_OK; -} - -inline CHECK SString::InternalInvariant() const -{ - CANNOT_HAVE_CONTRACT; - CHECK(SBuffer::InternalInvariant()); - CHECK(SBuffer::GetSize() >= 2); - if (IsNormalized()) - CHECK(IsRepresentation(REPRESENTATION_UNICODE)); - CHECK_OK; -} -#endif // CHECK_INVARIANTS - -//---------------------------------------------------------------------------- -// Return a writeable buffer that can store 'countChars'+1 unicode characters. -// Call CloseBuffer when done. -//---------------------------------------------------------------------------- -inline WCHAR *SString::OpenUnicodeBuffer(COUNT_T countChars) -{ - SS_CONTRACT(WCHAR*) - { - GC_NOTRIGGER; - PRECONDITION(CheckPointer(this)); - PRECONDITION(CheckCount(countChars)); -#if _DEBUG - SS_POSTCONDITION(IsBufferOpen()); -#endif - SS_POSTCONDITION(GetRawCount() == countChars); - SS_POSTCONDITION(GetRepresentation() == REPRESENTATION_UNICODE || countChars == 0); - SS_POSTCONDITION(CheckPointer(RETVAL)); - THROWS; - } - SS_CONTRACT_END; - - OpenBuffer(REPRESENTATION_UNICODE, countChars); - SS_RETURN GetRawUnicode(); -} - -//---------------------------------------------------------------------------- -// Return a copy of the underlying buffer, the caller is responsible for managing -// the returned memory -//---------------------------------------------------------------------------- -inline WCHAR *SString::GetCopyOfUnicodeString() -{ - SS_CONTRACT(WCHAR*) - { - GC_NOTRIGGER; - PRECONDITION(CheckPointer(this)); - SS_POSTCONDITION(CheckPointer(buffer)); - THROWS; - } - SS_CONTRACT_END; - NewArrayHolder buffer = NULL; - - buffer = new WCHAR[GetCount() +1]; - wcscpy_s(buffer, GetCount() + 1, GetUnicode()); - - SS_RETURN buffer.Extract(); -} - -//---------------------------------------------------------------------------- -// Return a writeable buffer that can store 'countChars'+1 ansi characters. -// Call CloseBuffer when done. -//---------------------------------------------------------------------------- -inline ANSI *SString::OpenANSIBuffer(COUNT_T countChars) -{ - SS_CONTRACT(ANSI*) - { - GC_NOTRIGGER; - PRECONDITION(CheckPointer(this)); - PRECONDITION(CheckCount(countChars)); -#if _DEBUG - SS_POSTCONDITION(IsBufferOpen()); -#endif - SS_POSTCONDITION(GetRawCount() == countChars); - SS_POSTCONDITION(GetRepresentation() == REPRESENTATION_ANSI || countChars == 0); - SS_POSTCONDITION(CheckPointer(RETVAL)); - THROWS; - } - SS_CONTRACT_END; - - OpenBuffer(REPRESENTATION_ANSI, countChars); - SS_RETURN GetRawANSI(); -} - -//---------------------------------------------------------------------------- -// Return a writeable buffer that can store 'countChars'+1 ansi characters. -// Call CloseBuffer when done. -//---------------------------------------------------------------------------- -inline UTF8 *SString::OpenUTF8Buffer(COUNT_T countBytes) -{ - SS_CONTRACT(UTF8*) - { - GC_NOTRIGGER; - PRECONDITION(CheckPointer(this)); - PRECONDITION(CheckCount(countBytes)); -#if _DEBUG - SS_POSTCONDITION(IsBufferOpen()); -#endif - SS_POSTCONDITION(GetRawCount() == countBytes); - SS_POSTCONDITION(GetRepresentation() == REPRESENTATION_UTF8 || countBytes == 0); - SS_POSTCONDITION(CheckPointer(RETVAL)); - THROWS; - } - SS_CONTRACT_END; - - OpenBuffer(REPRESENTATION_UTF8, countBytes); - SS_RETURN GetRawUTF8(); -} - -//---------------------------------------------------------------------------- -// Private helper to open a raw buffer. -// Called by public functions to open the buffer in the specific -// representation. -// While the buffer is opened, all other operations are illegal. Call -// CloseBuffer() when done. -//---------------------------------------------------------------------------- -inline void SString::OpenBuffer(SString::Representation representation, COUNT_T countChars) -{ -#ifdef SSTRING_EXTRA_CHECKS - CONTRACT_VOID - { - GC_NOTRIGGER; - PRECONDITION(CheckPointer(this)); - PRECONDITION_MSG(!IsBufferOpen(), "Can't nest calls to OpenBuffer()"); - PRECONDITION(CheckRepresentation(representation)); - PRECONDITION(CheckSize(countChars)); -#if _DEBUG - POSTCONDITION(IsBufferOpen()); -#endif - POSTCONDITION(GetRawCount() == countChars); - POSTCONDITION(GetRepresentation() == representation || countChars == 0); - THROWS; - } - CONTRACT_END; -#else - STATIC_CONTRACT_GC_NOTRIGGER; - STATIC_CONTRACT_THROWS; -#endif - - Resize(countChars, representation); - - SBuffer::OpenRawBuffer(CountToSize(countChars)); - - SS_RETURN; -} - -//---------------------------------------------------------------------------- -// Get the max size that can be passed to OpenUnicodeBuffer without causing -// allocations. -//---------------------------------------------------------------------------- -inline COUNT_T SString::GetUnicodeAllocation() -{ - CONTRACTL - { - INSTANCE_CHECK; - NOTHROW; - GC_NOTRIGGER; - } - CONTRACTL_END; - - COUNT_T allocation = GetAllocation(); - return ( (allocation > sizeof(WCHAR)) - ? (allocation - sizeof(WCHAR)) / sizeof(WCHAR) : 0 ); -} - -//---------------------------------------------------------------------------- -// Close an open buffer. Assumes that we wrote exactly number of characters -// we requested in OpenBuffer. -//---------------------------------------------------------------------------- -inline void SString::CloseBuffer() -{ - SS_CONTRACT_VOID - { - GC_NOTRIGGER; -#if _DEBUG - PRECONDITION_MSG(IsBufferOpen(), "Can only CloseBuffer() after a call to OpenBuffer()"); -#endif - SS_POSTCONDITION(CheckPointer(this)); - THROWS; - } - SS_CONTRACT_END; - - SBuffer::CloseRawBuffer(); - NullTerminate(); - - SS_RETURN; -} - -//---------------------------------------------------------------------------- -// CloseBuffer() tells the SString that we're done using the unsafe buffer. -// countChars is the count of characters actually used (so we can set m_count). -// This is important if we request a buffer larger than what we actually -// used. -//---------------------------------------------------------------------------- -inline void SString::CloseBuffer(COUNT_T finalCount) -{ - SS_CONTRACT_VOID - { - GC_NOTRIGGER; -#if _DEBUG - PRECONDITION_MSG(IsBufferOpen(), "Can only CloseBuffer() after a call to OpenBuffer()"); -#endif - PRECONDITION(CheckSize(finalCount)); - SS_POSTCONDITION(CheckPointer(this)); - SS_POSTCONDITION(GetRawCount() == finalCount); - THROWS; - } - SS_CONTRACT_END; - - SBuffer::CloseRawBuffer(CountToSize(finalCount)); - NullTerminate(); - - SS_RETURN; -} - -//---------------------------------------------------------------------------- -// EnsureWritable -// Ensures that the buffer is writable -//---------------------------------------------------------------------------- -inline void SString::EnsureWritable() const -{ -#ifdef SSTRING_EXTRA_CHECKS - CONTRACT_VOID - { - GC_NOTRIGGER; - PRECONDITION(CheckPointer(this)); - POSTCONDITION(!IsLiteral()); - THROWS; - } - CONTRACT_END; -#else //SSTRING_EXTRA_CHECKS - STATIC_CONTRACT_GC_NOTRIGGER; - STATIC_CONTRACT_THROWS; -#endif //SSTRING_EXTRA_CHECKS - - if (IsLiteral()) - const_cast(this)->Resize(GetRawCount(), GetRepresentation(), PRESERVE); - - SS_RETURN; -} - -//----------------------------------------------------------------------------- -// Convert the internal representation to be a fixed size -//----------------------------------------------------------------------------- -inline void SString::ConvertToFixed() const -{ - SS_CONTRACT_VOID - { - GC_NOTRIGGER; - SS_PRECONDITION(CheckPointer(this)); - SS_POSTCONDITION(IsFixedSize()); - THROWS_UNLESS_NORMALIZED; - SUPPORTS_DAC; - } - SS_CONTRACT_END; - - // If we're already fixed size, great. - if (IsFixedSize()) - SS_RETURN; - - // See if we can coerce it to ASCII. - if (ScanASCII()) - SS_RETURN; - - // Convert to unicode then. - ConvertToUnicode(); - - SS_RETURN; -} - -//----------------------------------------------------------------------------- -// Convert the internal representation to be an iteratable one (current -// requirements here are that it be trivially convertable to unicode chars.) -//----------------------------------------------------------------------------- -inline void SString::ConvertToIteratable() const -{ - SS_CONTRACT_VOID - { - GC_NOTRIGGER; - SS_PRECONDITION(CheckPointer(this)); - SS_POSTCONDITION(IsIteratable()); - THROWS_UNLESS_NORMALIZED; - SUPPORTS_DAC; - } - SS_CONTRACT_END; - - // If we're already iteratable, great. - if (IsIteratable()) - SS_RETURN; - - // See if we can coerce it to ASCII. - if (ScanASCII()) - SS_RETURN; - - // Convert to unicode then. - ConvertToUnicode(); - - SS_RETURN; -} - -//----------------------------------------------------------------------------- -// Create iterators on the string. -//----------------------------------------------------------------------------- - -inline SString::UIterator SString::BeginUnicode() -{ - SS_CONTRACT(SString::UIterator) - { - GC_NOTRIGGER; - PRECONDITION(CheckPointer(this)); - SS_POSTCONDITION(CheckValue(RETVAL)); - THROWS; - } - SS_CONTRACT_END; - - ConvertToUnicode(); - EnsureWritable(); - - SS_RETURN UIterator(this, 0); -} - -inline SString::UIterator SString::EndUnicode() -{ - SS_CONTRACT(SString::UIterator) - { - GC_NOTRIGGER; - PRECONDITION(CheckPointer(this)); - SS_POSTCONDITION(CheckValue(RETVAL)); - THROWS; - } - SS_CONTRACT_END; - - ConvertToUnicode(); - EnsureWritable(); - - SS_RETURN UIterator(this, GetCount()); -} - -//----------------------------------------------------------------------------- -// Create CIterators on the string. -//----------------------------------------------------------------------------- - -FORCEINLINE SString::CIterator SString::Begin() const -{ - SS_CONTRACT(SString::CIterator) - { - GC_NOTRIGGER; - PRECONDITION(CheckPointer(this)); - SS_POSTCONDITION(CheckValue(RETVAL)); - THROWS_UNLESS_NORMALIZED; - } - SS_CONTRACT_END; - - ConvertToIteratable(); - - SS_RETURN CIterator(this, 0); -} - -FORCEINLINE SString::CIterator SString::End() const -{ - SS_CONTRACT(SString::CIterator) - { - GC_NOTRIGGER; - PRECONDITION(CheckPointer(this)); - SS_POSTCONDITION(CheckValue(RETVAL)); - THROWS_UNLESS_NORMALIZED; - } - SS_CONTRACT_END; - - ConvertToIteratable(); - - SS_RETURN CIterator(this, GetCount()); -} - -//----------------------------------------------------------------------------- -// Create Iterators on the string. -//----------------------------------------------------------------------------- - -FORCEINLINE SString::Iterator SString::Begin() -{ - SS_CONTRACT(SString::Iterator) - { - GC_NOTRIGGER; - PRECONDITION(CheckPointer(this)); - SS_POSTCONDITION(CheckValue(RETVAL)); - THROWS; // EnsureMutable always throws - SUPPORTS_DAC; - } - SS_CONTRACT_END; - - ConvertToIteratable(); - EnsureMutable(); - - SS_RETURN Iterator(this, 0); -} - -FORCEINLINE SString::Iterator SString::End() -{ - SS_CONTRACT(SString::Iterator) - { - GC_NOTRIGGER; - PRECONDITION(CheckPointer(this)); - SS_POSTCONDITION(CheckValue(RETVAL)); - THROWS; // EnsureMutable always Throws - SUPPORTS_DAC; - } - SS_CONTRACT_END; - - ConvertToIteratable(); - EnsureMutable(); - - SS_RETURN Iterator(this, GetCount()); -} - -//----------------------------------------------------------------------------- -// CIterator support routines -//----------------------------------------------------------------------------- - -inline SString::Index::Index() -{ - LIMITED_METHOD_CONTRACT; -} - -inline SString::Index::Index(SString *string, SCOUNT_T index) - : SBuffer::Index(string, index<GetCharacterSizeShift()) -{ - SS_CONTRACT_VOID - { - GC_NOTRIGGER; - PRECONDITION(CheckPointer(string)); - PRECONDITION(string->IsIteratable()); - PRECONDITION(DoCheck(0)); - SS_POSTCONDITION(CheckPointer(this)); - // POSTCONDITION(Subtract(string->Begin()) == index); contract violation - fix later - NOTHROW; - CANNOT_TAKE_LOCK; - SUPPORTS_DAC; - } - SS_CONTRACT_END; - - m_characterSizeShift = string->GetCharacterSizeShift(); - - SS_RETURN; -} - -inline BYTE &SString::Index::GetAt(SCOUNT_T delta) const -{ - LIMITED_METHOD_DAC_CONTRACT; - - return m_ptr[delta<>m_characterSizeShift); -} - -inline CHECK SString::Index::DoCheck(SCOUNT_T delta) const -{ - CANNOT_HAVE_CONTRACT; -#if _DEBUG - const SString *string = (const SString *) GetContainerDebug(); - - CHECK(m_ptr + (delta<= string->m_buffer); - CHECK(m_ptr + (delta<m_buffer + string->GetSize()); -#endif - CHECK_OK; -} - -inline void SString::Index::Resync(const SString *string, BYTE *ptr) const -{ - WRAPPER_NO_CONTRACT; - SUPPORTS_DAC; - - SBuffer::Index::Resync(string, ptr); - - const_cast(this)->m_characterSizeShift = string->GetCharacterSizeShift(); -} - - -inline const WCHAR *SString::Index::GetUnicode() const -{ - LIMITED_METHOD_CONTRACT; - - return (const WCHAR *) m_ptr; -} - -inline const CHAR *SString::Index::GetASCII() const -{ - LIMITED_METHOD_CONTRACT; - - return (const CHAR *) m_ptr; -} - -inline WCHAR SString::Index::operator*() const -{ - WRAPPER_NO_CONTRACT; - SUPPORTS_DAC; - - if (m_characterSizeShift == 0) - return *(CHAR*)&GetAt(0); - else - return *(WCHAR*)&GetAt(0); -} - -inline void SString::Index::operator->() const -{ - LIMITED_METHOD_CONTRACT; -} - -inline WCHAR SString::Index::operator[](int index) const -{ - WRAPPER_NO_CONTRACT; - - if (m_characterSizeShift == 0) - return *(CHAR*)&GetAt(index); - else - return *(WCHAR*)&GetAt(index); -} - -//----------------------------------------------------------------------------- -// Iterator support routines -//----------------------------------------------------------------------------- - -inline SString::UIndex::UIndex() -{ - LIMITED_METHOD_CONTRACT; -} - -inline SString::UIndex::UIndex(SString *string, SCOUNT_T index) - : SBuffer::Index(string, index*sizeof(WCHAR)) -{ - SS_CONTRACT_VOID - { - GC_NOTRIGGER; - PRECONDITION(CheckPointer(string)); - PRECONDITION(string->IsRepresentation(REPRESENTATION_UNICODE)); - PRECONDITION(DoCheck(0)); - SS_POSTCONDITION(CheckPointer(this)); - NOTHROW; - CANNOT_TAKE_LOCK; - } - SS_CONTRACT_END; - - SS_RETURN; -} - -inline WCHAR &SString::UIndex::GetAt(SCOUNT_T delta) const -{ - LIMITED_METHOD_CONTRACT; - - return ((WCHAR*)m_ptr)[delta]; -} - -inline void SString::UIndex::Skip(SCOUNT_T delta) -{ - LIMITED_METHOD_CONTRACT; - - m_ptr += delta * sizeof(WCHAR); -} - -inline SCOUNT_T SString::UIndex::Subtract(const UIndex &i) const -{ - WRAPPER_NO_CONTRACT; - - return (SCOUNT_T) (GetUnicode() - i.GetUnicode()); -} - -inline CHECK SString::UIndex::DoCheck(SCOUNT_T delta) const -{ - CANNOT_HAVE_CONTRACT; -#if _DEBUG - const SString *string = (const SString *) GetContainerDebug(); - - CHECK(GetUnicode() + delta >= string->GetRawUnicode()); - CHECK(GetUnicode() + delta <= string->GetRawUnicode() + string->GetCount()); -#endif - - CHECK_OK; -} - -inline WCHAR *SString::UIndex::GetUnicode() const -{ - LIMITED_METHOD_CONTRACT; - - return (WCHAR*) m_ptr; -} - -//----------------------------------------------------------------------------- -// Opaque scratch buffer class routines -//----------------------------------------------------------------------------- -inline SString::AbstractScratchBuffer::AbstractScratchBuffer(void *buffer, COUNT_T size) - : SString(buffer, size) -{ - SS_CONTRACT_VOID - { - GC_NOTRIGGER; - PRECONDITION(CheckPointer(buffer)); - PRECONDITION(CheckCount(size)); - NOTHROW; - } - SS_CONTRACT_END; - - SS_RETURN; -} - -#ifdef _MSC_VER -#pragma warning(pop) -#endif // _MSC_VER - -#endif // _SSTRING_INL_ diff --git a/src/inc/stack.h b/src/inc/stack.h deleted file mode 100644 index 589f8f776..000000000 --- a/src/inc/stack.h +++ /dev/null @@ -1,87 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -// This is a generic growable stack of T. - -#ifndef GENERIC_STACK_H -#define GENERIC_STACK_H 1 - -#include - -template -class Stack -{ - T* m_elems; - unsigned m_elemsSize; - unsigned m_elemsCount; - - static const unsigned InitSize = 8; - - void GrowForPush() - { - if (m_elemsCount == m_elemsSize) - { - m_elemsSize = max(InitSize, 2*m_elemsSize); - T* newElems = new T[m_elemsSize]; - if (m_elemsCount != 0) - { - _ASSERTE(m_elems != NULL); - for (unsigned k = 0; k < m_elemsCount; k++) newElems[k] = m_elems[k]; - delete[] m_elems; - } - m_elems = newElems; - } - } - - public: - Stack(unsigned sz = 0) : m_elems(NULL), m_elemsSize(sz), m_elemsCount(0) - { - if (sz > 0) - { - m_elems = new T[sz]; - } - } - - ~Stack() - { - if (m_elems != NULL) delete[] m_elems; - } - - void Push(T t) - { - GrowForPush(); - m_elems[m_elemsCount] = t; - m_elemsCount++; - } - - bool IsEmpty() - { - return m_elemsCount == 0; - } - - T Pop() - { - _ASSERTE(m_elemsCount > 0); - m_elemsCount--; - return m_elems[m_elemsCount]; - } - - T Peek() - { - _ASSERTE(m_elemsCount > 0); - return m_elems[m_elemsCount-1]; - } - - // Caller should take care to only side-effect the return reference if he/she is *sure* - // that the stack will not be popped in the interim! - T& PeekRef() - { - _ASSERTE(m_elemsCount > 0); - return m_elems[m_elemsCount-1]; - } -}; - -#endif // GENERIC_STACK_H diff --git a/src/inc/stackframe.h b/src/inc/stackframe.h deleted file mode 100644 index 940951de3..000000000 --- a/src/inc/stackframe.h +++ /dev/null @@ -1,127 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#ifndef __STACKFRAME_H -#define __STACKFRAME_H - -#include "regdisp.h" - - -struct StackFrame -{ - const static UINT_PTR maxVal = (UINT_PTR)(INT_PTR)-1; - StackFrame() : SP(NULL) - { - } - - StackFrame(UINT_PTR sp) - { - SP = sp; - } - - void Clear() - { - SP = NULL; - } - - void SetMaxVal() - { - SP = maxVal; - } - - bool IsNull() - { - return (SP == NULL); - } - - bool IsMaxVal() - { - return (SP == maxVal); - } - - bool operator==(StackFrame sf) - { - return (SP == sf.SP); - } - - bool operator!=(StackFrame sf) - { - return (SP != sf.SP); - } - - bool operator<(StackFrame sf) - { - return (SP < sf.SP); - } - - bool operator<=(StackFrame sf) - { - return (SP <= sf.SP); - } - - bool operator>(StackFrame sf) - { - return (SP > sf.SP); - } - - bool operator>=(StackFrame sf) - { - return (SP >= sf.SP); - } - - static inline StackFrame FromEstablisherFrame(UINT_PTR EstablisherFrame) - { - return StackFrame(EstablisherFrame); - } - - static inline StackFrame FromRegDisplay(REGDISPLAY* pRD) - { - return StackFrame(GetRegdisplaySP(pRD)); - } - - UINT_PTR SP; -}; - - -//--------------------------------------------------------------------------------------- -// -// On WIN64, all the stack range tracking done by the Exception Handling (EH) subsystem is based on the -// establisher frame given by the OS. On IA64, the establisher frame is the caller SP and the current BSP. -// On X64, it is the initial SP before any dynamic stack allocation, i.e. it is the SP when a function exits -// the prolog. The EH subsystem uses the same format. -// -// The stackwalker needs to get information from the EH subsystem in order to skip funclets. Unfortunately, -// stackwalking is based on the current SP, i.e. the SP when the control flow leaves a function via a -// function call. Thus, for stack frames with dynamic stack allocations on X64, the SP values used by the -// stackwalker and the EH subsystem don't match. -// -// To work around this problem, we need to somehow bridge the different SP values. We do so by using the -// caller SP instead of the current SP for comparisons during a stackwalk on X64. Creating a new type -// explicitly spells out the important distinction that this is NOT in the same format as the -// OS establisher frame. -// -// Notes: -// In the long term, we should look at merging the two SP formats and have one consistent abstraction. -// - -struct CallerStackFrame : StackFrame -{ - CallerStackFrame() : StackFrame() - { - } - - CallerStackFrame(UINT_PTR sp) : StackFrame(sp) - { - } - -#ifdef WIN64EXCEPTIONS - static inline CallerStackFrame FromRegDisplay(REGDISPLAY* pRD) - { - _ASSERTE(pRD->IsCallerSPValid || pRD->IsCallerContextValid); - return CallerStackFrame(GetSP(pRD->pCallerContext)); - } -#endif // WIN64EXCEPTIONS -}; - -#endif // __STACKFRAME_H diff --git a/src/inc/stdmacros.h b/src/inc/stdmacros.h deleted file mode 100644 index 3ec8bec6f..000000000 --- a/src/inc/stdmacros.h +++ /dev/null @@ -1,356 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -// - -// -// common.h - precompiled headers include for the COM+ Execution Engine -// - -// -// Make sure _ASSERTE is defined before including this header file -// Other than that, please keep this header self-contained so that it can be included in -// all dlls -// - - -#ifndef _stdmacros_h_ -#define _stdmacros_h_ - -#include "specstrings.h" -#include "contract.h" - -#ifndef _ASSERTE -#error Please define _ASSERTE before including StdMacros.h -#endif - -#ifdef _DEBUG -#define DEBUG_ARG(x) , x -#define DEBUG_ARG1(x) x -#else -#define DEBUG_ARG(x) -#define DEBUG_ARG1(x) -#endif - -#ifdef DACCESS_COMPILE -#define DAC_ARG(x) , x -#else -#define DAC_ARG(x) -#endif - - -/********************************************/ -/* Portability macros */ -/********************************************/ - -#ifdef _TARGET_AMD64_ -#define AMD64_FIRST_ARG(x) x , -#define AMD64_ARG(x) , x -#define AMD64_ONLY(x) x -#define NOT_AMD64(x) -#define NOT_AMD64_ARG(x) -#else -#define AMD64_FIRST_ARG(x) -#define AMD64_ARG(x) -#define AMD64_ONLY(x) -#define NOT_AMD64(x) x -#define NOT_AMD64_ARG(x) , x -#endif - -#ifdef _TARGET_X86_ -#define X86_FIRST_ARG(x) x , -#define X86_ARG(x) , x -#define X86_ONLY(x) x -#define NOT_X86(x) -#define NOT_X86_ARG(x) -#else -#define X86_FIRST_ARG(x) -#define X86_ARG(x) -#define X86_ONLY(x) -#define NOT_X86(x) x -#define NOT_X86_ARG(x) , x -#endif - -#ifdef _WIN64 -#define WIN64_ARG(x) , x -#define WIN64_ONLY(x) x -#define NOT_WIN64(x) -#define NOT_WIN64_ARG(x) -#else -#define WIN64_ARG(x) -#define WIN64_ONLY(x) -#define NOT_WIN64(x) x -#define NOT_WIN64_ARG(x) , x -#endif // _WIN64 - -#ifdef _TARGET_ARM_ -#define ARM_FIRST_ARG(x) x , -#define ARM_ARG(x) , x -#define ARM_ONLY(x) x -#define NOT_ARM(x) -#define NOT_ARM_ARG(x) -#else -#define ARM_FIRST_ARG(x) -#define ARM_ARG(x) -#define ARM_ONLY(x) -#define NOT_ARM(x) x -#define NOT_ARM_ARG(x) , x -#endif - -#ifdef _TARGET_ARM64_ -#define ARM64_FIRST_ARG(x) x , -#define ARM64_ARG(x) , x -#define ARM64_ONLY(x) x -#define NOT_ARM64(x) -#define NOT_ARM64_ARG(x) -#else -#define ARM64_FIRST_ARG(x) -#define ARM64_ARG(x) -#define ARM64_ONLY(x) -#define NOT_ARM64(x) x -#define NOT_ARM64_ARG(x) , x -#endif - -#ifdef _WIN64 - #define LOG2_PTRSIZE 3 - #define INVALID_POINTER_CC 0xcccccccccccccccc - #define INVALID_POINTER_CD 0xcdcdcdcdcdcdcdcd - #define FMT_ADDR " %08x`%08x " - #define LFMT_ADDR W(" %08x`%08x ") - #define DBG_ADDR(ptr) (((UINT_PTR) (ptr)) >> 32), (((UINT_PTR) (ptr)) & 0xffffffff) -#else // _WIN64 - #define LOG2_PTRSIZE 2 - #define INVALID_POINTER_CC 0xcccccccc - #define INVALID_POINTER_CD 0xcdcdcdcd - #define FMT_ADDR " %08x " - #define LFMT_ADDR W(" %08x ") - #define DBG_ADDR(ptr) ((UINT_PTR)(ptr)) -#endif // _WIN64 - -#ifdef _TARGET_ARM_ - #define ALIGN_ACCESS ((1<= val ); // check for overflow - return result; -} -inline void* ALIGN_UP( void* val, size_t alignment ) -{ - WRAPPER_NO_CONTRACT; - - return (void*) ALIGN_UP( (size_t)val, alignment ); -} -inline uint8_t* ALIGN_UP( uint8_t* val, size_t alignment ) -{ - WRAPPER_NO_CONTRACT; - - return (uint8_t*) ALIGN_UP( (size_t)val, alignment ); -} - -inline size_t ALIGN_DOWN( size_t val, size_t alignment ) -{ - LIMITED_METHOD_CONTRACT; - - // alignment must be a power of 2 for this implementation to work (need modulo otherwise) - _ASSERTE( 0 == (alignment & (alignment - 1)) ); - size_t result = val & ~(alignment - 1); - return result; -} -inline void* ALIGN_DOWN( void* val, size_t alignment ) -{ - WRAPPER_NO_CONTRACT; - return (void*) ALIGN_DOWN( (size_t)val, alignment ); -} -inline uint8_t* ALIGN_DOWN( uint8_t* val, size_t alignment ) -{ - WRAPPER_NO_CONTRACT; - return (uint8_t*) ALIGN_DOWN( (size_t)val, alignment ); -} - -inline BOOL IS_ALIGNED( size_t val, size_t alignment ) -{ - LIMITED_METHOD_CONTRACT; - SUPPORTS_DAC; - - // alignment must be a power of 2 for this implementation to work (need modulo otherwise) - _ASSERTE( 0 == (alignment & (alignment - 1)) ); - return 0 == (val & (alignment - 1)); -} -inline BOOL IS_ALIGNED( const void* val, size_t alignment ) -{ - WRAPPER_NO_CONTRACT; - return IS_ALIGNED( (size_t) val, alignment ); -} - -// Rounds a ULONG up to the nearest power of two number. -inline ULONG RoundUpToPower2(ULONG x) -{ - if (x == 0) return 1; - - x = x - 1; - x = x | (x >> 1); - x = x | (x >> 2); - x = x | (x >> 4); - x = x | (x >> 8); - x = x | (x >> 16); - return x + 1; -} - -#ifdef ALIGN_ACCESS - -// NOTE: pSrc is evaluated three times!!! -#define MAYBE_UNALIGNED_READ(pSrc, bits) (IS_ALIGNED((size_t)(pSrc), sizeof(UINT##bits)) ? \ - (*(UINT##bits*) (pSrc)) : \ - (GET_UNALIGNED_##bits(pSrc)) ) - -#define MAYBE_UNALIGNED_WRITE(pDst, bits, expr) do { if (IS_ALIGNED((size_t)(pDst), sizeof(UINT##bits))) \ - *(UINT##bits*)(pDst) = (UINT##bits)(expr); else \ - SET_UNALIGNED_##bits(pDst, (UINT##bits)(expr)); } while (0) - -// these are necessary for MAYBE_UNALIGNED_XXX to work with UINT_PTR -#define GET_UNALIGNED__PTR(x) GET_UNALIGNED_PTR(x) -#define SET_UNALIGNED__PTR(p,x) SET_UNALIGNED_PTR(p,x) - -#else // ALIGN_ACCESS -#define MAYBE_UNALIGNED_READ(pSrc, bits) (*(UINT##bits*)(pSrc)) -#define MAYBE_UNALIGNED_WRITE(pDst, bits, expr) do { *(UINT##bits*)(pDst) = (UINT##bits)(expr); } while(0) -#endif // ALIGN_ACCESS - -// -// define some useful macros for logging object -// - -#define FMT_OBJECT "object" FMT_ADDR -#define FMT_HANDLE "handle" FMT_ADDR -#define FMT_CLASS "%s" -#define FMT_REG "r%d " -#define FMT_STK "sp%s0x%02x " -#define FMT_PIPTR "%s%s pointer " - - -#define DBG_GET_CLASS_NAME(pMT) \ - (((pMT) == NULL) ? NULL : (pMT)->GetClass()->GetDebugClassName()) - -#define DBG_CLASS_NAME_MT(pMT) \ - (DBG_GET_CLASS_NAME(pMT) == NULL) ? "" : DBG_GET_CLASS_NAME(pMT) - -#define DBG_GET_MT_FROM_OBJ(obj) \ - (MethodTable*)((size_t)((Object*) (obj))->GetGCSafeMethodTable()) - -#define DBG_CLASS_NAME_OBJ(obj) \ - ((obj) == NULL) ? "null" : DBG_CLASS_NAME_MT(DBG_GET_MT_FROM_OBJ(obj)) - -#define DBG_CLASS_NAME_IPTR2(obj,iptr) \ - ((iptr) != 0) ? "" : DBG_CLASS_NAME_MT(DBG_GET_MT_FROM_OBJ(obj)) - -#define DBG_CLASS_NAME_IPTR(obj,iptr) \ - ((obj) == NULL) ? "null" : DBG_CLASS_NAME_IPTR2(obj,iptr) - -#define DBG_STK(off) \ - (off >= 0) ? "+" : "-", \ - (off >= 0) ? off : -off - -#define DBG_PIN_NAME(pin) \ - (pin) ? "pinned " : "" - -#define DBG_IPTR_NAME(iptr) \ - (iptr) ? "interior" : "base" - -#define LOG_HANDLE_OBJECT_CLASS(str1, hnd, str2, obj) \ - str1 FMT_HANDLE str2 FMT_OBJECT FMT_CLASS "\n", \ - DBG_ADDR(hnd), DBG_ADDR(obj), DBG_CLASS_NAME_OBJ(obj) - -#define LOG_OBJECT_CLASS(obj) \ - FMT_OBJECT FMT_CLASS "\n", \ - DBG_ADDR(obj), DBG_CLASS_NAME_OBJ(obj) - -#define LOG_PIPTR_OBJECT_CLASS(obj, pin, iptr) \ - FMT_PIPTR FMT_ADDR FMT_CLASS "\n", \ - DBG_PIN_NAME(pin), DBG_IPTR_NAME(iptr), \ - DBG_ADDR(obj), DBG_CLASS_NAME_IPTR(obj,iptr) - -#define LOG_HANDLE_OBJECT(str1, hnd, str2, obj) \ - str1 FMT_HANDLE str2 FMT_OBJECT "\n", \ - DBG_ADDR(hnd), DBG_ADDR(obj) - -#define LOG_PIPTR_OBJECT(obj, pin, iptr) \ - FMT_PIPTR FMT_ADDR "\n", \ - DBG_PIN_NAME(pin), DBG_IPTR_NAME(iptr), \ - DBG_ADDR(obj) - -#define UNIQUE_LABEL_DEF(a,x) a##x -#define UNIQUE_LABEL_DEF_X(a,x) UNIQUE_LABEL_DEF(a,x) -#ifdef _MSC_VER -#define UNIQUE_LABEL(a) UNIQUE_LABEL_DEF_X(_unique_label_##a##_, __COUNTER__) -#else -#define UNIQUE_LABEL(a) UNIQUE_LABEL_DEF_X(_unique_label_##a##_, __LINE__) -#endif - - -#ifndef _countof -#define _countof(_array) (sizeof(_array)/sizeof(_array[0])) -#endif - - -// This is temporary. LKG should provide these macros and we should then -// remove STRUNCATE and _TRUNCATE from here. - -/* error codes */ -#if !defined(STRUNCATE) -#define STRUNCATE 80 -#endif - -/* _TRUNCATE */ -#if !defined(_TRUNCATE) -#define _TRUNCATE ((size_t)-1) -#endif - -#endif //_stdmacros_h_ diff --git a/src/inc/stgpool.h b/src/inc/stgpool.h deleted file mode 100644 index 448669550..000000000 --- a/src/inc/stgpool.h +++ /dev/null @@ -1,1512 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -//***************************************************************************** -// StgPool.h -// - -// -// Pools are used to reduce the amount of data actually required in the database. -// This allows for duplicate string and binary values to be folded into one -// copy shared by the rest of the database. Strings are tracked in a hash -// table when insert/changing data to find duplicates quickly. The strings -// are then persisted consecutively in a stream in the database format. -// -//***************************************************************************** - -#ifndef __StgPool_h__ -#define __StgPool_h__ - -#ifdef _MSC_VER -#pragma warning (disable : 4355) // warning C4355: 'this' : used in base member initializer list -#endif - -#include "stgpooli.h" // Internal helpers. -#include "corerror.h" // Error codes. -#include "metadatatracker.h" -#include "metamodelpub.h" -#include "ex.h" -#include "sarray.h" -#include "memoryrange.h" -#include "../md/hotdata/hotheap.h" - -#include "../md/debug_metadata.h" - -//***************************************************************************** -// NOTE: -// One limitation with the pools, we have no way to removing strings from -// the pool. To remove, you need to know the ref count on the string, and -// need the ability to compact the pool and reset all references. -//***************************************************************************** - -//********** Constants ******************************************************** -const int DFT_STRING_HEAP_SIZE = 1024; -const int DFT_GUID_HEAP_SIZE = 32; -const int DFT_BLOB_HEAP_SIZE = 1024; -const int DFT_VARIANT_HEAP_SIZE = 512; -const int DFT_CODE_HEAP_SIZE = 8192; - - - -// Forwards. -class StgStringPool; -class StgBlobPool; -class StgCodePool; -class CorProfileData; - -// Perform binary search on index table. -// -class RIDBinarySearch : public CBinarySearch -{ -public: - RIDBinarySearch(const UINT32 *pBase, int iCount) : CBinarySearch(pBase, iCount) - { - LIMITED_METHOD_CONTRACT; - } // RIDBinarySearch::RIDBinarySearch - - int Compare(UINT32 const *pFirst, UINT32 const *pSecond) - { - LIMITED_METHOD_CONTRACT; - - if (*pFirst < *pSecond) - return -1; - - if (*pFirst > *pSecond) - return 1; - - return 0; - } // RIDBinarySearch::Compare - -}; // class RIDBinarySearch - -//***************************************************************************** -// This class provides common definitions for heap segments. It is both the -// base class for the heap, and the class for heap extensions (additional -// memory that must be allocated to grow the heap). -//***************************************************************************** -class StgPoolSeg -{ - friend class VerifyLayoutsMD; -public: - StgPoolSeg() : - m_pSegData((BYTE*)m_zeros), - m_pNextSeg(NULL), - m_cbSegSize(0), - m_cbSegNext(0) - {LIMITED_METHOD_CONTRACT; } - ~StgPoolSeg() - { LIMITED_METHOD_CONTRACT; _ASSERTE(m_pSegData == m_zeros);_ASSERTE(m_pNextSeg == NULL); } -protected: - BYTE *m_pSegData; // Pointer to the data. - StgPoolSeg *m_pNextSeg; // Pointer to next segment, or NULL. - // Size of the segment buffer. If this is last segment (code:m_pNextSeg is NULL), then it's the - // allocation size. If this is not the last segment, then this is shrinked to segment data size - // (code:m_cbSegNext). - ULONG m_cbSegSize; - ULONG m_cbSegNext; // Offset of next available byte in segment. - // Segment relative. - - friend class StgPool; - friend class StgStringPool; - friend class StgGuidPool; - friend class StgBlobPool; - friend class RecordPool; - -public: - const BYTE *GetSegData() const { LIMITED_METHOD_CONTRACT; return m_pSegData; } - const StgPoolSeg* GetNextSeg() const { LIMITED_METHOD_CONTRACT; return m_pNextSeg; } - // Returns size of the segment. It can be bigger than the size of represented data by this segment if - // this is the last segment. - ULONG GetSegSize() const { LIMITED_METHOD_CONTRACT; return m_cbSegSize; } - // Returns size of represented data in this segment. - ULONG GetDataSize() const { LIMITED_METHOD_CONTRACT; return m_cbSegNext; } - - static const BYTE m_zeros[64]; // array of zeros for "0" indices. - // The size should be at least maximum of all MD table record sizes - // (MD\Runtime\MDColumnDescriptors.cpp) which is currently 28 B. -}; // class StgPoolSeg - -namespace MetaData -{ - // Forward declarations - class StringHeapRO; - class StringHeapRW; - class BlobHeapRO; -}; // namespace MetaData - -// -// -// StgPoolReadOnly -// -// -//***************************************************************************** -// This is the read only StgPool class -//***************************************************************************** -class StgPoolReadOnly : public StgPoolSeg -{ -friend class CBlobPoolHash; -friend class MetaData::StringHeapRO; -friend class MetaData::StringHeapRW; -friend class MetaData::BlobHeapRO; -friend class VerifyLayoutsMD; - -public: - StgPoolReadOnly() - { LIMITED_METHOD_CONTRACT; }; - - ~StgPoolReadOnly(); - - -//***************************************************************************** -// Init the pool from existing data. -//***************************************************************************** - __checkReturn - HRESULT InitOnMemReadOnly( // Return code. - void *pData, // Predefined data. - ULONG iSize); // Size of data. - -//***************************************************************************** -// Prepare to shut down or reinitialize. -//***************************************************************************** - virtual void Uninit(); - -//***************************************************************************** -// Return the size of the pool. -//***************************************************************************** - virtual UINT32 GetPoolSize() const - { LIMITED_METHOD_CONTRACT; return m_cbSegSize; } - -//***************************************************************************** -// Indicate if heap is empty. -//***************************************************************************** - virtual int IsEmpty() // true if empty. - { LIMITED_METHOD_CONTRACT; _ASSERTE(!"This implementation should never be called!!!"); return FALSE; } - -//***************************************************************************** -// true if the heap is read only. -//***************************************************************************** - virtual int IsReadOnly() { LIMITED_METHOD_CONTRACT; return true ;}; - -//***************************************************************************** -// Is the given cookie a valid offset, index, etc? -//***************************************************************************** - virtual int IsValidCookie(UINT32 nCookie) - { WRAPPER_NO_CONTRACT; return (IsValidOffset(nCookie)); } - - -#ifdef _PREFAST_ -#pragma warning(push) -#pragma warning(disable:6387) // Suppress PREFast warning: '*pszString' might be '0': this does not adhere to the specification for the function - // *pszString may be NULL only if method fails, but warning 6387 doesn't respect __success(SUCCEEDED(return)) which is part of HRESULT definition -#endif -//***************************************************************************** -// Return a pointer to a null terminated string given an offset previously -// handed out by AddString or FindString. -//***************************************************************************** - __checkReturn - inline HRESULT GetString( - UINT32 nIndex, - __deref_out LPCSTR *pszString) - { - HRESULT hr; - - // Size of the data in the heap will be ignored, because we have verified during creation of the string - // heap (code:Initialize) and when adding new strings (e.g. code:AddString, - // code:AddTemporaryStringBuffer), that the heap is null-terminated, therefore we don't have to check it - // for each string in the heap - MetaData::DataBlob stringData; - - // Get data from the heap (clears stringData on error) - IfFailGo(GetData( - nIndex, - &stringData)); - _ASSERTE(hr == S_OK); - // Raw data are always at least 1 byte long, otherwise it would be invalid offset and hr != S_OK - PREFAST_ASSUME(stringData.GetDataPointer() != NULL); - // Fills output string - *pszString = reinterpret_cast(stringData.GetDataPointer()); - //_ASSERTE(stringData.GetSize() > strlen(*pszString)); - - return hr; - ErrExit: - // Clears output string on error - *pszString = NULL; - - return hr; - } -#ifdef _PREFAST_ -#pragma warning(pop) -#endif - -//***************************************************************************** -// Convert a string to UNICODE into the caller's buffer. -//***************************************************************************** - __checkReturn - virtual HRESULT GetStringW( // Return code. - ULONG iOffset, // Offset of string in pool. - __out_ecount(cchBuffer) LPWSTR szOut, // Output buffer for string. - int cchBuffer); // Size of output buffer. - -//***************************************************************************** -// Copy a GUID into the caller's buffer. -//***************************************************************************** - __checkReturn - HRESULT GetGuid( - UINT32 nIndex, // 1-based index of Guid in pool. - GUID UNALIGNED **ppGuid) // Output buffer for Guid. - { - STATIC_CONTRACT_NOTHROW; - STATIC_CONTRACT_FORBID_FAULT; - - HRESULT hr; - MetaData::DataBlob heapData; - - if (nIndex == 0) - { - *ppGuid = (GUID *)m_zeros; - return S_OK; - } - - S_UINT32 nOffset = S_UINT32(nIndex - 1) * S_UINT32(sizeof(GUID)); - if (nOffset.IsOverflow() || !IsValidOffset(nOffset.Value())) - { - Debug_ReportError("Invalid index passed - integer overflow."); - IfFailGo(CLDB_E_INDEX_NOTFOUND); - } - if (FAILED(GetData(nOffset.Value(), &heapData))) - { - if (nOffset.Value() == 0) - { - Debug_ReportError("Invalid index 0 passed."); - IfFailGo(CLDB_E_INDEX_NOTFOUND); - } - Debug_ReportInternalError("Invalid index passed."); - IfFailGo(CLDB_E_INTERNALERROR); - } - _ASSERTE(heapData.GetSize() >= sizeof(GUID)); - - *ppGuid = (GUID UNALIGNED *)heapData.GetDataPointer(); - return S_OK; - - ErrExit: - *ppGuid = (GUID *)m_zeros; - return hr; - } // StgPoolReadOnly::GetGuid - -//***************************************************************************** -// Return a pointer to a null terminated blob given an offset previously -// handed out by Addblob or Findblob. -//***************************************************************************** - __checkReturn - virtual HRESULT GetBlob( - UINT32 nOffset, // Offset of blob in pool. - MetaData::DataBlob *pData); - -#ifdef FEATURE_PREJIT - // Initialize hot data structures. - // Method can be called multiple time, e.g. to disable usage of hot data structures in certain scenarios - // (see code:CMiniMd::DisableHotDataUsage). - void InitHotData(MetaData::HotHeap hotHeap) - { - LIMITED_METHOD_CONTRACT; - -#if !defined(FEATURE_UTILCODE_NO_DEPENDENCIES) - m_HotHeap = hotHeap; -#else - _ASSERTE(!"InitHotData(): Not supposed to exist in RoMetaData.dll"); -#endif //!(defined(FEATURE_UTILCODE_NO_DEPENDENCIES)) - } -#endif //FEATURE_PREJIT - -protected: - -//***************************************************************************** -// Check whether a given offset is valid in the pool. -//***************************************************************************** - virtual int IsValidOffset(UINT32 nOffset) - {LIMITED_METHOD_CONTRACT; return (nOffset == 0) || ((m_pSegData != m_zeros) && (nOffset < m_cbSegSize)); } - -//***************************************************************************** -// Get a pointer to an offset within the heap. Inline for base segment, -// helper for extension segments. -//***************************************************************************** - __checkReturn - FORCEINLINE HRESULT GetDataReadOnly(UINT32 nOffset, __inout MetaData::DataBlob *pData) - { - LIMITED_METHOD_CONTRACT; - _ASSERTE(IsReadOnly()); - - // If off the end of the heap, return the 'nul' item from the beginning. - if (nOffset >= m_cbSegSize) - { - Debug_ReportError("Invalid offset passed."); - pData->Clear(); - return CLDB_E_INDEX_NOTFOUND; - } - -#if !defined(FEATURE_UTILCODE_NO_DEPENDENCIES) -#ifdef FEATURE_PREJIT - // try hot data first - if (!m_HotHeap.IsEmpty()) - { - HRESULT hr = m_HotHeap.GetData(nOffset, pData); - if ((hr == S_OK) || FAILED(hr)) - { - return hr; - } - _ASSERTE(hr == S_FALSE); - } -#endif //FEATURE_PREJIT -#endif //!(defined(FEATURE_UTILCODE_NO_DEPENDENCIES)) - - - pData->Init(m_pSegData + nOffset, m_cbSegSize - nOffset); - - METADATATRACKER_ONLY(MetaDataTracker::NoteAccess((void *)pData->GetDataPointer())); - - return S_OK; - } // StgPoolReadOnly::GetDataReadOnly - -//***************************************************************************** -// Get a pointer to an offset within the heap. Inline for base segment, -// helper for extension segments. -//***************************************************************************** - __checkReturn - virtual HRESULT GetData(UINT32 nOffset, __inout MetaData::DataBlob *pData) - { - WRAPPER_NO_CONTRACT; - return GetDataReadOnly(nOffset, pData); - } // StgPoolReadOnly::GetData - -private: -#if !defined(FEATURE_UTILCODE_NO_DEPENDENCIES) - // hot pool data - MetaData::HotHeap m_HotHeap; -#endif //!(defined(FEATURE_UTILCODE_NO_DEPENDENCIES)) - -}; // class StgPoolReadOnly - -// -// -// StgBlobPoolReadOnly -// -// -//***************************************************************************** -// This is the read only StgBlobPool class -//***************************************************************************** -class StgBlobPoolReadOnly : public StgPoolReadOnly -{ -public: -//***************************************************************************** -// Return a pointer to a null terminated blob given an offset -//***************************************************************************** - __checkReturn - virtual HRESULT GetBlob( - UINT32 nOffset, // Offset of blob in pool. - MetaData::DataBlob *pData); - -protected: - -//***************************************************************************** -// Check whether a given offset is valid in the pool. -//***************************************************************************** - virtual int IsValidOffset(UINT32 nOffset) - { - STATIC_CONTRACT_NOTHROW; - STATIC_CONTRACT_FORBID_FAULT; - - MetaData::DataBlob data; - return (StgBlobPoolReadOnly::GetBlob(nOffset, &data) == S_OK); - } - -}; // class StgBlobPoolReadOnly - -// -// -// StgPool -// -// - -//***************************************************************************** -// This base class provides common pool management code, such as allocation -// of dynamic memory. -//***************************************************************************** -class StgPool : public StgPoolReadOnly -{ -friend class StgStringPool; -friend class StgBlobPool; -friend class RecordPool; -friend class CBlobPoolHash; -friend class VerifyLayoutsMD; - -public: - StgPool(ULONG ulGrowInc=512, UINT32 nAlignment=4) : - m_ulGrowInc(ulGrowInc), - m_pCurSeg(this), - m_cbCurSegOffset(0), - m_bFree(true), - m_bReadOnly(false), - m_nVariableAlignmentMask(nAlignment-1), - m_cbStartOffsetOfEdit(0), - m_fValidOffsetOfEdit(0) - { LIMITED_METHOD_CONTRACT; } - - virtual ~StgPool(); - -protected: - HRESULT Align(UINT32 nValue, UINT32 *pnAlignedValue) const - { - LIMITED_METHOD_CONTRACT; - - *pnAlignedValue = (nValue + m_nVariableAlignmentMask) & ~m_nVariableAlignmentMask; - if (*pnAlignedValue < nValue) - { - return COR_E_OVERFLOW; - } - return S_OK; - } - -public: -//***************************************************************************** -// Init the pool for use. This is called for the create empty case. -//***************************************************************************** - __checkReturn - virtual HRESULT InitNew( // Return code. - ULONG cbSize=0, // Estimated size. - ULONG cItems=0); // Estimated item count. - -//***************************************************************************** -// Init the pool from existing data. -//***************************************************************************** - __checkReturn - virtual HRESULT InitOnMem( // Return code. - void *pData, // Predefined data. - ULONG iSize, // Size of data. - int bReadOnly); // true if append is forbidden. - -//***************************************************************************** -// Called when the pool must stop accessing memory passed to InitOnMem(). -//***************************************************************************** - __checkReturn - virtual HRESULT TakeOwnershipOfInitMem(); - -//***************************************************************************** -// Clear out this pool. Cannot use until you call InitNew. -//***************************************************************************** - virtual void Uninit(); - -//***************************************************************************** -// Called to copy the pool to writable memory, reset the r/o bit. -//***************************************************************************** - __checkReturn - virtual HRESULT ConvertToRW(); - -//***************************************************************************** -// Turn hashing off or on. Implemented as required in subclass. -//***************************************************************************** - __checkReturn - virtual HRESULT SetHash(int bHash); - -//***************************************************************************** -// Allocate memory if we don't have any, or grow what we have. If successful, -// then at least iRequired bytes will be allocated. -//***************************************************************************** - bool Grow( // true if successful. - ULONG iRequired); // Min required bytes to allocate. - -//***************************************************************************** -// Add a segment to the chain of segments. -//***************************************************************************** - __checkReturn - virtual HRESULT AddSegment( // S_OK or error. - const void *pData, // The data. - ULONG cbData, // Size of the data. - bool bCopy); // If true, make a copy of the data. - -//***************************************************************************** -// Trim any empty final segment. -//***************************************************************************** - void Trim(); // - -//***************************************************************************** -// Return the size in bytes of the persistent version of this pool. If -// PersistToStream were the next call, the amount of bytes written to pIStream -// has to be same as the return value from this function. -//***************************************************************************** - __checkReturn - virtual HRESULT GetSaveSize( - UINT32 *pcbSaveSize) const - { - STATIC_CONTRACT_NOTHROW; - STATIC_CONTRACT_FORBID_FAULT; - - _ASSERTE(pcbSaveSize != NULL); - // Size is offset of last seg + size of last seg. - UINT32 cbSize = m_pCurSeg->m_cbSegNext + m_cbCurSegOffset; - - if (FAILED(Align(cbSize, pcbSaveSize))) - { - *pcbSaveSize = 0; - Debug_ReportInternalError("Aligned size of string heap overflows - we should prevent creating such heaps."); - return CLDB_E_INTERNALERROR; - } - return S_OK; - } - -//***************************************************************************** -// Return the size in bytes of the edits contained in the persistent version of this pool. -//***************************************************************************** - __checkReturn - HRESULT GetEditSaveSize( - UINT32 *pcbSaveSize) const // Return save size of this pool. - { - STATIC_CONTRACT_NOTHROW; - STATIC_CONTRACT_FORBID_FAULT; - - _ASSERTE(pcbSaveSize != NULL); - UINT32 cbSize = 0; - - if (HaveEdits()) - { - // Size is offset of last seg + size of last seg. - - // An offset of zero in the pool will give us a zero length blob. The first - // "real" user string is at offset 1. Wherever this delta gets applied, it will - // already have this zero length blob. Let's make sure we don't sent it another one. -#ifdef _DEBUG - MetaData::DataBlob debug_data; - HRESULT hr = const_cast(this)->GetData(0, &debug_data); - _ASSERTE(hr == S_OK); - _ASSERTE(debug_data.ContainsData(1)); - _ASSERTE(*(debug_data.GetDataPointer()) == 0); -#endif //_DEBUG - UINT32 nOffsetOfEdit = GetOffsetOfEdit(); - - if (nOffsetOfEdit == 0) - nOffsetOfEdit = 1; - - cbSize = m_pCurSeg->m_cbSegNext + m_cbCurSegOffset - nOffsetOfEdit; - } - - if (FAILED(Align(cbSize, pcbSaveSize))) - { - *pcbSaveSize = 0; - Debug_ReportInternalError("Aligned size of string heap overflows - we should prevent creating such heaps."); - return CLDB_E_INTERNALERROR; - } - return S_OK; - } // StgPool::GetEditSaveSize - -//***************************************************************************** -// The entire pool is written to the given stream. The stream is aligned -// to a 4 byte boundary. -//***************************************************************************** - __checkReturn - virtual HRESULT PersistToStream( // Return code. - IStream *pIStream) // The stream to write to. - DAC_UNEXPECTED(); - -//***************************************************************************** -// A portion of the pool is written to the stream. Must not be optimized. -//***************************************************************************** - __checkReturn - virtual HRESULT PersistPartialToStream( // Return code. - IStream *pIStream, // The stream to write to. - ULONG iOffset); // Starting byte. - -//***************************************************************************** -// Get the size of the data block obtained from the pool. -// Needed for generic persisting of data blocks. -// Override in concrete pool classes to return the correct size. -//***************************************************************************** - virtual ULONG GetSizeOfData( void const * data ) - { - LIMITED_METHOD_CONTRACT; - return 0; - } - -//***************************************************************************** -// Return the size of the pool. -//***************************************************************************** - virtual UINT32 GetPoolSize() const - {LIMITED_METHOD_CONTRACT; return m_pCurSeg->m_cbSegNext + m_cbCurSegOffset; } - -//***************************************************************************** -// Indicate if heap is empty. -//***************************************************************************** - virtual int IsEmpty() // true if empty. - {LIMITED_METHOD_CONTRACT; return (m_pSegData == m_zeros); } - -//***************************************************************************** -// true if the heap is read only. -//***************************************************************************** - int IsReadOnly() - {LIMITED_METHOD_CONTRACT; return (m_bReadOnly == false); } - -//***************************************************************************** -// Is the given cookie a valid offset, index, etc? -//***************************************************************************** - virtual int IsValidCookie(UINT32 nCookie) - { WRAPPER_NO_CONTRACT; return (IsValidOffset(nCookie)); } - -//***************************************************************************** -// Get a pointer to an offset within the heap. Inline for base segment, -// helper for extension segments. -//***************************************************************************** - __checkReturn - FORCEINLINE HRESULT GetData(UINT32 nOffset, MetaData::DataBlob *pData) - { - WRAPPER_NO_CONTRACT; - if (nOffset < m_cbSegNext) - { - pData->Init(m_pSegData + nOffset, m_cbSegNext - nOffset); - return S_OK; - } - else - { - return GetData_i(nOffset, pData); - } - } // StgPool::GetData - - // Copies data from pSourcePool starting at index nStartSourceIndex. - __checkReturn - HRESULT CopyPool( - UINT32 nStartSourceIndex, - const StgPool *pSourcePool); - -//***************************************************************************** -// Copies data from the pool into a buffer. It will correctly walk the different -// segments for the copy -//***************************************************************************** -private: - __checkReturn - HRESULT CopyData( - UINT32 nOffset, - BYTE *pBuffer, - UINT32 cbBuffer, - UINT32 *pcbWritten) const; - -public: -//***************************************************************************** -// Helpers for dump utilities. -//***************************************************************************** - UINT32 GetRawSize() const - { - LIMITED_METHOD_CONTRACT; - - // Size is offset of last seg + size of last seg. - return m_pCurSeg->m_cbSegNext + m_cbCurSegOffset; - } - - BOOL HaveEdits() const {LIMITED_METHOD_CONTRACT; return m_fValidOffsetOfEdit;} - UINT32 GetOffsetOfEdit() const {LIMITED_METHOD_CONTRACT; return m_cbStartOffsetOfEdit;} - void ResetOffsetOfEdit() {LIMITED_METHOD_CONTRACT; m_fValidOffsetOfEdit=FALSE;} - -protected: - -//***************************************************************************** -// Check whether a given offset is valid in the pool. -//***************************************************************************** - virtual int IsValidOffset(UINT32 nOffset) - { WRAPPER_NO_CONTRACT; return (nOffset == 0) || ((m_pSegData != m_zeros) && (nOffset < GetNextOffset())); } - - // Following virtual because a) this header included outside the project, and - // non-virtual function call (in non-expanded inline function!!) generates - // an external def, which causes linkage errors. - __checkReturn - virtual HRESULT GetData_i(UINT32 nOffset, MetaData::DataBlob *pData); - - // Get pointer to next location to which to write. - BYTE *GetNextLocation() - {LIMITED_METHOD_CONTRACT; return (m_pCurSeg->m_pSegData + m_pCurSeg->m_cbSegNext); } - - // Get pool-relative offset of next location to which to write. - ULONG GetNextOffset() - {LIMITED_METHOD_CONTRACT; return (m_cbCurSegOffset + m_pCurSeg->m_cbSegNext); } - - // Get count of bytes available in tail segment of pool. - ULONG GetCbSegAvailable() - {LIMITED_METHOD_CONTRACT; return (m_pCurSeg->m_cbSegSize - m_pCurSeg->m_cbSegNext); } - - // Allocate space from the segment. - - void SegAllocate(ULONG cb) - { - LIMITED_METHOD_CONTRACT; - _ASSERTE(cb <= GetCbSegAvailable()); - - if (!m_fValidOffsetOfEdit) - { - m_cbStartOffsetOfEdit = GetNextOffset(); - m_fValidOffsetOfEdit = TRUE; - } - - m_pCurSeg->m_cbSegNext += cb; - }// SegAllocate - - - - ULONG m_ulGrowInc; // How many bytes at a time. - StgPoolSeg *m_pCurSeg; // Current seg for append -- end of chain. - ULONG m_cbCurSegOffset; // Base offset of current seg. - - unsigned m_bFree : 1; // True if we should free base data. - // Extension data is always freed. - unsigned m_bReadOnly : 1; // True if we shouldn't append. - - UINT32 m_nVariableAlignmentMask; // Alignment mask (variable 0, 1 or 3). - UINT32 m_cbStartOffsetOfEdit; // Place in the pool where edits started - BOOL m_fValidOffsetOfEdit; // Is the pool edit offset valid - -}; - - -// -// -// StgStringPool -// -// - - - -//***************************************************************************** -// This string pool class collects user strings into a big consecutive heap. -// Internally it manages this data in a hash table at run time to help throw -// out duplicates. The list of strings is kept in memory while adding, and -// finally flushed to a stream at the caller's request. -//***************************************************************************** -class StgStringPool : public StgPool -{ - friend class VerifyLayoutsMD; -public: - StgStringPool() : - StgPool(DFT_STRING_HEAP_SIZE), - m_Hash(this), - m_bHash(true) - { - LIMITED_METHOD_CONTRACT; - // force some code in debug. - _ASSERTE(m_bHash); - } - -//***************************************************************************** -// Create a new, empty string pool. -//***************************************************************************** - __checkReturn - HRESULT InitNew( // Return code. - ULONG cbSize=0, // Estimated size. - ULONG cItems=0); // Estimated item count. - -//***************************************************************************** -// Load a string heap from persisted memory. If a copy of the data is made -// (so that it may be updated), then a new hash table is generated which can -// be used to elminate duplicates with new strings. -//***************************************************************************** - __checkReturn - HRESULT InitOnMem( // Return code. - void *pData, // Predefined data. - ULONG iSize, // Size of data. - int bReadOnly); // true if append is forbidden. - -//***************************************************************************** -// Clears the hash table then calls the base class. -//***************************************************************************** - void Uninit(); - -//***************************************************************************** -// Turn hashing off or on. If you turn hashing on, then any existing data is -// thrown away and all data is rehashed during this call. -//***************************************************************************** - __checkReturn - virtual HRESULT SetHash(int bHash); - -//***************************************************************************** -// The string will be added to the pool. The offset of the string in the pool -// is returned in *piOffset. If the string is already in the pool, then the -// offset will be to the existing copy of the string. -// -// The first version essentially adds a zero-terminated sequence of bytes -// to the pool. MBCS pairs will not be converted to the appropriate UTF8 -// sequence. The second version converts from Unicode. -//***************************************************************************** - __checkReturn - HRESULT AddString( - LPCSTR szString, // The string to add to pool. - UINT32 *pnOffset); // Return offset of string here. - - __checkReturn - HRESULT AddStringW( - LPCWSTR szString, // The string to add to pool. - UINT32 *pnOffset); // Return offset of string here. - -//***************************************************************************** -// Look for the string and return its offset if found. -//***************************************************************************** - __checkReturn - HRESULT FindString( // S_OK, S_FALSE. - LPCSTR szString, // The string to find in pool. - ULONG *piOffset) // Return offset of string here. - { - WRAPPER_NO_CONTRACT; - - STRINGHASH *pHash; // Hash item for lookup. - if ((pHash = m_Hash.Find(szString)) == 0) - return (S_FALSE); - *piOffset = pHash->iOffset; - return (S_OK); - } - -//***************************************************************************** -// How many objects are there in the pool? If the count is 0, you don't need -// to persist anything at all to disk. -//***************************************************************************** - int Count() - { - WRAPPER_NO_CONTRACT; - _ASSERTE(m_bHash); - return (m_Hash.Count()); } - -//***************************************************************************** -// String heap is considered empty if the only thing it has is the initial -// empty string, or if after organization, there are no strings. -//***************************************************************************** - int IsEmpty() // true if empty. - { - WRAPPER_NO_CONTRACT; - - return (GetNextOffset() <= 1); - } - -//***************************************************************************** -// Return the size in bytes of the persistent version of this pool. If -// PersistToStream were the next call, the amount of bytes written to pIStream -// has to be same as the return value from this function. -//***************************************************************************** - __checkReturn - virtual HRESULT GetSaveSize( - UINT32 *pcbSaveSize) const - { - LIMITED_METHOD_CONTRACT; - - _ASSERTE(pcbSaveSize != NULL); - - // Size is offset of last seg + size of last seg. - S_UINT32 cbSize = S_UINT32(m_pCurSeg->m_cbSegNext + m_cbCurSegOffset); - - cbSize.AlignUp(4); - - if (cbSize.IsOverflow()) - { - *pcbSaveSize = 0; - Debug_ReportInternalError("Aligned size of string heap overflows - we should prevent creating such heaps."); - return CLDB_E_INTERNALERROR; - } - *pcbSaveSize = cbSize.Value(); - return S_OK; - } - -//***************************************************************************** -// Get the size of the string obtained from the pool. -// Needed for generic persisting of data blocks. -//***************************************************************************** - virtual ULONG GetSizeOfData( void const * data ) - { - LIMITED_METHOD_CONTRACT; - return ULONG( strlen( reinterpret_cast< LPCSTR >( data ) ) + 1 ); // using strlen since the string is UTF8 - } - -private: - __checkReturn - HRESULT RehashStrings(); - -private: - CStringPoolHash m_Hash; // Hash table for lookups. - int m_bHash; // true to keep hash table. -}; // class StgStringPool - -// -// -// StgGuidPool -// -// - -//***************************************************************************** -// This Guid pool class collects user Guids into a big consecutive heap. -// Internally it manages this data in a hash table at run time to help throw -// out duplicates. The list of Guids is kept in memory while adding, and -// finally flushed to a stream at the caller's request. -//***************************************************************************** -class StgGuidPool : public StgPool -{ - friend class VerifyLayoutsMD; -public: - StgGuidPool() : - StgPool(DFT_GUID_HEAP_SIZE), - m_Hash(this), - m_bHash(true) - { LIMITED_METHOD_CONTRACT; } - -//***************************************************************************** -// Init the pool for use. This is called for the create empty case. -//***************************************************************************** - __checkReturn - HRESULT InitNew( // Return code. - ULONG cbSize=0, // Estimated size. - ULONG cItems=0); // Estimated item count. - -//***************************************************************************** -// Load a Guid heap from persisted memory. If a copy of the data is made -// (so that it may be updated), then a new hash table is generated which can -// be used to elminate duplicates with new Guids. -//***************************************************************************** - __checkReturn - HRESULT InitOnMem( // Return code. - void *pData, // Predefined data. - ULONG iSize, // Size of data. - int bReadOnly); // true if append is forbidden. - -//***************************************************************************** -// Clears the hash table then calls the base class. -//***************************************************************************** - void Uninit(); - -//***************************************************************************** -// Add a segment to the chain of segments. -//***************************************************************************** - __checkReturn - virtual HRESULT AddSegment( // S_OK or error. - const void *pData, // The data. - ULONG cbData, // Size of the data. - bool bCopy); // If true, make a copy of the data. - -//***************************************************************************** -// Turn hashing off or on. If you turn hashing on, then any existing data is -// thrown away and all data is rehashed during this call. -//***************************************************************************** - __checkReturn - virtual HRESULT SetHash(int bHash); - -//***************************************************************************** -// The Guid will be added to the pool. The index of the Guid in the pool -// is returned in *piIndex. If the Guid is already in the pool, then the -// index will be to the existing copy of the Guid. -//***************************************************************************** - __checkReturn - HRESULT AddGuid( - const GUID *pGuid, // The Guid to add to pool. - UINT32 *pnIndex); // Return index of Guid here. - -//***************************************************************************** -// Get the size of the GUID obtained from the pool. -// Needed for generic persisting of data blocks. -//***************************************************************************** - virtual ULONG GetSizeOfData( void const * data ) - { - LIMITED_METHOD_CONTRACT; - return sizeof( GUID ); - } - -//***************************************************************************** -// How many objects are there in the pool? If the count is 0, you don't need -// to persist anything at all to disk. -//***************************************************************************** - int Count() - { - WRAPPER_NO_CONTRACT; - _ASSERTE(m_bHash); - return (m_Hash.Count()); } - -//***************************************************************************** -// Indicate if heap is empty. This has to be based on the size of the data -// we are keeping. If you open in r/o mode on memory, there is no hash -// table. -//***************************************************************************** - virtual int IsEmpty() // true if empty. - { - WRAPPER_NO_CONTRACT; - - return (GetNextOffset() == 0); - } - -//***************************************************************************** -// Is the index valid for the GUID? -//***************************************************************************** - virtual int IsValidCookie(UINT32 nCookie) - { WRAPPER_NO_CONTRACT; return ((nCookie == 0) || IsValidOffset((nCookie - 1) * sizeof(GUID))); } - -//***************************************************************************** -// Return the size of the heap. -//***************************************************************************** - ULONG GetNextIndex() - { LIMITED_METHOD_CONTRACT; return (GetNextOffset() / sizeof(GUID)); } - -//***************************************************************************** -// Return the size in bytes of the persistent version of this pool. If -// PersistToStream were the next call, the amount of bytes written to pIStream -// has to be same as the return value from this function. -//***************************************************************************** - __checkReturn - virtual HRESULT GetSaveSize( - UINT32 *pcbSaveSize) const - { - STATIC_CONTRACT_NOTHROW; - STATIC_CONTRACT_FORBID_FAULT; - - _ASSERTE(pcbSaveSize != NULL); - - // Size is offset of last seg + size of last seg. - *pcbSaveSize = m_pCurSeg->m_cbSegNext + m_cbCurSegOffset; - - // Should be aligned. - _ASSERTE(*pcbSaveSize == ALIGN4BYTE(*pcbSaveSize)); - return S_OK; - } - -private: - - __checkReturn - HRESULT RehashGuids(); - - -private: - CGuidPoolHash m_Hash; // Hash table for lookups. - int m_bHash; // true to keep hash table. -}; // class StgGuidPool - -// -// -// StgBlobPool -// -// - -//***************************************************************************** -// Just like the string pool, this pool manages a list of items, throws out -// duplicates using a hash table, and can be persisted to a stream. The only -// difference is that instead of saving null terminated strings, this code -// manages binary values of up to 64K in size. Any data you have larger than -// this should be stored someplace else with a pointer in the record to the -// external source. -//***************************************************************************** -class StgBlobPool : public StgPool -{ - friend class VerifyLayoutsMD; - - using StgPool::InitNew; - using StgPool::InitOnMem; - -public: - StgBlobPool(ULONG ulGrowInc=DFT_BLOB_HEAP_SIZE) : - StgPool(ulGrowInc), - m_Hash(this) - { LIMITED_METHOD_CONTRACT; } - -//***************************************************************************** -// Init the pool for use. This is called for the create empty case. -//***************************************************************************** - __checkReturn - HRESULT InitNew( // Return code. - ULONG cbSize=0, // Estimated size. - ULONG cItems=0, // Estimated item count. - BOOL fAddEmptryItem=TRUE); // Should we add an empty item at offset 0 - -//***************************************************************************** -// Init the blob pool for use. This is called for both create and read case. -// If there is existing data and bCopyData is true, then the data is rehashed -// to eliminate dupes in future adds. -//***************************************************************************** - __checkReturn - HRESULT InitOnMem( // Return code. - void *pData, // Predefined data. - ULONG iSize, // Size of data. - int bReadOnly); // true if append is forbidden. - -//***************************************************************************** -// Clears the hash table then calls the base class. -//***************************************************************************** - void Uninit(); - -//***************************************************************************** -// The blob will be added to the pool. The offset of the blob in the pool -// is returned in *piOffset. If the blob is already in the pool, then the -// offset will be to the existing copy of the blob. -//***************************************************************************** - __checkReturn - HRESULT AddBlob( - const MetaData::DataBlob *pData, - UINT32 *pnOffset); - -//***************************************************************************** -// Return a pointer to a null terminated blob given an offset previously -// handed out by Addblob or Findblob. -//***************************************************************************** - __checkReturn - virtual HRESULT GetBlob( - UINT32 nOffset, // Offset of blob in pool. - MetaData::DataBlob *pData); - - __checkReturn - HRESULT GetBlobWithSizePrefix( - UINT32 nOffset, // Offset of blob in pool. - MetaData::DataBlob *pData); - -//***************************************************************************** -// Turn hashing off or on. If you turn hashing on, then any existing data is -// thrown away and all data is rehashed during this call. -//***************************************************************************** - __checkReturn - virtual HRESULT SetHash(int bHash); - -//***************************************************************************** -// Get the size of the blob obtained from the pool. -// Needed for generic persisting of data blocks. -//***************************************************************************** - virtual ULONG GetSizeOfData( void const * data ) - { - WRAPPER_NO_CONTRACT; - - void const * blobdata = 0; - ULONG blobsize = CPackedLen::GetLength( data, & blobdata ); // the size is encoded at the beginning of the block - return blobsize + static_cast< ULONG >( reinterpret_cast< BYTE const * >( blobdata ) - reinterpret_cast< BYTE const * >( data ) ); - } - -//***************************************************************************** -// How many objects are there in the pool? If the count is 0, you don't need -// to persist anything at all to disk. -//***************************************************************************** - int Count() - { WRAPPER_NO_CONTRACT; return (m_Hash.Count()); } - -//***************************************************************************** -// String heap is considered empty if the only thing it has is the initial -// empty string, or if after organization, there are no strings. -//***************************************************************************** - virtual int IsEmpty() // true if empty. - { - STATIC_CONTRACT_NOTHROW; - STATIC_CONTRACT_FORBID_FAULT; - - return (GetNextOffset() <= 1); - } - -//***************************************************************************** -// Return the size in bytes of the persistent version of this pool. If -// PersistToStream were the next call, the amount of bytes written to pIStream -// has to be same as the return value from this function. -//***************************************************************************** - __checkReturn - virtual HRESULT GetSaveSize( - UINT32 *pcbSaveSize) const - { - STATIC_CONTRACT_NOTHROW; - STATIC_CONTRACT_FORBID_FAULT; - - return StgPool::GetSaveSize(pcbSaveSize); - } - -protected: - -//***************************************************************************** -// Check whether a given offset is valid in the pool. -//***************************************************************************** - virtual int IsValidOffset(UINT32 nOffset) - { - STATIC_CONTRACT_NOTHROW; - STATIC_CONTRACT_FORBID_FAULT; - - MetaData::DataBlob data; - return (StgBlobPool::GetBlob(nOffset, &data) == S_OK); - } - -private: - __checkReturn - HRESULT RehashBlobs(); - - CBlobPoolHash m_Hash; // Hash table for lookups. -}; // class StgBlobPool - -#ifdef _MSC_VER -#pragma warning (default : 4355) -#endif - -//***************************************************************************** -// Unfortunately the CreateStreamOnHGlobal is a little too smart in that -// it gets its size from GlobalSize. This means that even if you give it the -// memory for the stream, it has to be globally allocated. We don't want this -// because we have the stream read only in the middle of a memory mapped file. -// CreateStreamOnMemory and the corresponding, internal only stream object solves -// that problem. -//***************************************************************************** -class CInMemoryStream : public IStream -{ -public: - CInMemoryStream() : - m_pMem(0), - m_cbSize(0), - m_cbCurrent(0), - m_cRef(1), - m_dataCopy(NULL) - { LIMITED_METHOD_CONTRACT; } - - virtual ~CInMemoryStream() {} - - void InitNew( - void *pMem, - ULONG cbSize) - { - LIMITED_METHOD_CONTRACT; - - m_pMem = pMem; - m_cbSize = cbSize; - m_cbCurrent = 0; - } - - ULONG STDMETHODCALLTYPE AddRef() { - LIMITED_METHOD_CONTRACT; - return InterlockedIncrement(&m_cRef); - } - - - ULONG STDMETHODCALLTYPE Release(); - - __checkReturn - HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, PVOID *ppOut); - - __checkReturn - HRESULT STDMETHODCALLTYPE Read(void *pv, ULONG cb, ULONG *pcbRead); - - __checkReturn - HRESULT STDMETHODCALLTYPE Write(const void *pv, ULONG cb, ULONG *pcbWritten); - - __checkReturn - HRESULT STDMETHODCALLTYPE Seek(LARGE_INTEGER dlibMove,DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition); - - __checkReturn - HRESULT STDMETHODCALLTYPE SetSize(ULARGE_INTEGER libNewSize) - { - STATIC_CONTRACT_NOTHROW; - STATIC_CONTRACT_FAULT; //E_OUTOFMEMORY; - - return (BadError(E_NOTIMPL)); - } - - __checkReturn - HRESULT STDMETHODCALLTYPE CopyTo( - IStream *pstm, - ULARGE_INTEGER cb, - ULARGE_INTEGER *pcbRead, - ULARGE_INTEGER *pcbWritten); - - __checkReturn - HRESULT STDMETHODCALLTYPE Commit( - DWORD grfCommitFlags) - { - STATIC_CONTRACT_NOTHROW; - STATIC_CONTRACT_FAULT; //E_OUTOFMEMORY; - - return (BadError(E_NOTIMPL)); - } - - __checkReturn - HRESULT STDMETHODCALLTYPE Revert() - { - STATIC_CONTRACT_NOTHROW; - STATIC_CONTRACT_FAULT; //E_OUTOFMEMORY; - - return (BadError(E_NOTIMPL)); - } - - __checkReturn - HRESULT STDMETHODCALLTYPE LockRegion( - ULARGE_INTEGER libOffset, - ULARGE_INTEGER cb, - DWORD dwLockType) - { - STATIC_CONTRACT_NOTHROW; - STATIC_CONTRACT_FAULT; //E_OUTOFMEMORY; - - return (BadError(E_NOTIMPL)); - } - - __checkReturn - HRESULT STDMETHODCALLTYPE UnlockRegion( - ULARGE_INTEGER libOffset, - ULARGE_INTEGER cb, - DWORD dwLockType) - { - STATIC_CONTRACT_NOTHROW; - STATIC_CONTRACT_FAULT; //E_OUTOFMEMORY; - - return (BadError(E_NOTIMPL)); - } - - __checkReturn - HRESULT STDMETHODCALLTYPE Stat( - STATSTG *pstatstg, - DWORD grfStatFlag) - { - STATIC_CONTRACT_NOTHROW; - STATIC_CONTRACT_FAULT; //E_OUTOFMEMORY; - - pstatstg->cbSize.QuadPart = m_cbSize; - return (S_OK); - } - - __checkReturn - HRESULT STDMETHODCALLTYPE Clone( - IStream **ppstm) - { - STATIC_CONTRACT_NOTHROW; - STATIC_CONTRACT_FAULT; //E_OUTOFMEMORY; - - return (BadError(E_NOTIMPL)); - } - - __checkReturn - static HRESULT CreateStreamOnMemory( // Return code. - void *pMem, // Memory to create stream on. - ULONG cbSize, // Size of data. - IStream **ppIStream, // Return stream object here. - BOOL fDeleteMemoryOnRelease = FALSE - ); - - __checkReturn - static HRESULT CreateStreamOnMemoryCopy( - void *pMem, - ULONG cbSize, - IStream **ppIStream); - -private: - void *m_pMem; // Memory for the read. - ULONG m_cbSize; // Size of the memory. - ULONG m_cbCurrent; // Current offset. - LONG m_cRef; // Ref count. - BYTE *m_dataCopy; // Optional copy of the data. -}; // class CInMemoryStream - -//***************************************************************************** -// CGrowableStream is a simple IStream implementation that grows as -// its written to. All the memory is contigious, so read access is -// fast. A grow does a realloc, so be aware of that if you're going to -// use this. -//***************************************************************************** - -// DPTR instead of VPTR because we don't actually call any of the virtuals. -typedef DPTR(class CGrowableStream) PTR_CGrowableStream; - -class CGrowableStream : public IStream -{ -public: - //Constructs a new GrowableStream - // multiplicativeGrowthRate - when the stream grows it will be at least this - // multiple of its old size. Values greater than 1 ensure O(N) amortized - // performance growing the stream to size N, 1 ensures O(N^2) amortized perf - // but gives the tightest memory usage. Valid range is [1.0, 2.0]. - // additiveGrowthRate - when the stream grows it will increase in size by at least - // this number of bytes. Larger numbers cause fewer re-allocations at the cost of - // increased memory usage. - CGrowableStream(float multiplicativeGrowthRate = 2.0, DWORD additiveGrowthRate = 4096); - -#ifndef DACCESS_COMPILE - virtual ~CGrowableStream(); -#endif - - // Expose the total raw buffer. - // This can be used by DAC to get the raw contents. - // This becomes potentiallyinvalid on the next call on the class, because the underlying storage can be - // reallocated. - MemoryRange GetRawBuffer() const - { - SUPPORTS_DAC; - PTR_VOID p = m_swBuffer; - return MemoryRange(p, m_dwBufferSize); - } - -private: - // Raw pointer to buffer. This may change as the buffer grows and gets reallocated. - PTR_BYTE m_swBuffer; - - // Total size of the buffer in bytes. - DWORD m_dwBufferSize; - - // Current index in the buffer. This can be moved around by Seek. - DWORD m_dwBufferIndex; - - // Logical length of the stream - DWORD m_dwStreamLength; - - // Reference count - LONG m_cRef; - - // growth rate parameters determine new stream size when it must grow - float m_multiplicativeGrowthRate; - int m_additiveGrowthRate; - - // Ensures the stream is physically and logically at least newLogicalSize - // in size - HRESULT EnsureCapacity(DWORD newLogicalSize); - - // IStream methods -public: - -#ifndef DACCESS_COMPILE - ULONG STDMETHODCALLTYPE AddRef() { - LIMITED_METHOD_CONTRACT; - return InterlockedIncrement(&m_cRef); - } - - - ULONG STDMETHODCALLTYPE Release(); - - __checkReturn - HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, PVOID *ppOut); - - STDMETHOD(Read)( - void * pv, - ULONG cb, - ULONG * pcbRead); - - STDMETHOD(Write)( - const void * pv, - ULONG cb, - ULONG * pcbWritten); - - STDMETHOD(Seek)( - LARGE_INTEGER dlibMove, - DWORD dwOrigin, - ULARGE_INTEGER * plibNewPosition); - - STDMETHOD(SetSize)(ULARGE_INTEGER libNewSize); - - STDMETHOD(CopyTo)( - IStream * pstm, - ULARGE_INTEGER cb, - ULARGE_INTEGER * pcbRead, - ULARGE_INTEGER * pcbWritten) { STATIC_CONTRACT_NOTHROW; STATIC_CONTRACT_FAULT; return E_NOTIMPL; } - - STDMETHOD(Commit)( - DWORD grfCommitFlags) { STATIC_CONTRACT_NOTHROW; STATIC_CONTRACT_FAULT; return NOERROR; } - - STDMETHOD(Revert)( void) {STATIC_CONTRACT_NOTHROW; STATIC_CONTRACT_FAULT; return E_NOTIMPL; } - - STDMETHOD(LockRegion)( - ULARGE_INTEGER libOffset, - ULARGE_INTEGER cb, - DWORD dwLockType) { STATIC_CONTRACT_NOTHROW; STATIC_CONTRACT_FAULT; return E_NOTIMPL; } - - STDMETHOD(UnlockRegion)( - ULARGE_INTEGER libOffset, - ULARGE_INTEGER cb, - DWORD dwLockType) {STATIC_CONTRACT_NOTHROW; STATIC_CONTRACT_FAULT; return E_NOTIMPL; } - - STDMETHOD(Stat)( - STATSTG * pstatstg, - DWORD grfStatFlag); - - // Make a deep copy of the stream into a new CGrowableStream instance - STDMETHOD(Clone)( - IStream ** ppstm); - -#endif // DACCESS_COMPILE -}; // class CGrowableStream - -#endif // __StgPool_h__ diff --git a/src/inc/stgpooli.h b/src/inc/stgpooli.h deleted file mode 100644 index a29fa01e7..000000000 --- a/src/inc/stgpooli.h +++ /dev/null @@ -1,256 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -//***************************************************************************** -// StgPooli.h -// - -// -// This is helper code for the string and blob pools. It is here because it is -// secondary to the pooling interface and reduces clutter in the main file. -// -//***************************************************************************** - -#ifndef __StgPooli_h__ -#define __StgPooli_h__ - -#include "utilcode.h" // Base hashing code. - - - -// -// -// CPackedLen -// -// - -//***************************************************************************** -// Helper class to pack and unpack lengths. -//***************************************************************************** -struct CPackedLen -{ - enum {MAX_LEN = 0x1fffffff}; - static int Size(ULONG len) - { - LIMITED_METHOD_CONTRACT; - // Smallest. - if (len <= 0x7F) - return 1; - // Medium. - if (len <= 0x3FFF) - return 2; - // Large (too large?). - _ASSERTE(len <= MAX_LEN); - return 4; - } - - // Get a pointer to the data, and store the length. - static void const *GetData(void const *pData, ULONG *pLength); - - // Get the length value encoded at *pData. Update ppData to point past data. - static ULONG GetLength(void const *pData, void const **ppData=0); - - // Get the length value encoded at *pData, and the size of that encoded value. - static ULONG GetLength(void const *pData, int *pSizeOfLength); - - // Pack a length at *pData; return a pointer to the next byte. - static void* PutLength(void *pData, ULONG len); - - // This is used for just getting an encoded length, and verifies that - // there is no buffer or integer overflow. - static HRESULT SafeGetLength( // S_OK, or error - void const *pDataSource, // First byte of length. - void const *pDataSourceEnd, // End of valid source data memory - ULONG *pLength, // Encoded value - void const **ppDataNext); // Pointer immediately following encoded length - - static HRESULT SafeGetLength( // S_OK, or error - BYTE const *pDataSource, // First byte of length. - BYTE const *pDataSourceEnd, // End of valid source data memory - ULONG *pLength, // Encoded value - BYTE const **ppDataNext) // Pointer immediately following encoded length - { - return SafeGetLength( - reinterpret_cast(pDataSource), - reinterpret_cast(pDataSourceEnd), - pLength, - reinterpret_cast(ppDataNext)); - } - - // This performs the same tasks as GetLength above in addition to checking - // that the value in *pcbData does not extend *ppData beyond pDataSourceEnd - // and does not cause an integer overflow. - static HRESULT SafeGetData( - void const *pDataSource, // First byte of length. - void const *pDataSourceEnd, // End of valid source data memory - ULONG *pcbData, // Length of data - void const **ppData); // Start of data - - static HRESULT SafeGetData( - BYTE const *pDataSource, // First byte of length. - BYTE const *pDataSourceEnd, // End of valid source data memory - ULONG *pcbData, // Length of data - BYTE const **ppData) // Start of data - { - return SafeGetData( - reinterpret_cast(pDataSource), - reinterpret_cast(pDataSourceEnd), - pcbData, - reinterpret_cast(ppData)); - } - - // This is the same as GetData above except it takes a byte count instead - // of pointer to determine the source data length. - static HRESULT SafeGetData( // S_OK, or error - void const *pDataSource, // First byte of data - ULONG cbDataSource, // Count of valid bytes in data source - ULONG *pcbData, // Length of data - void const **ppData); // Start of data - - static HRESULT SafeGetData( - BYTE const *pDataSource, // First byte of length. - ULONG cbDataSource, // Count of valid bytes in data source - ULONG *pcbData, // Length of data - BYTE const **ppData) // Start of data - { - return SafeGetData( - reinterpret_cast(pDataSource), - cbDataSource, - pcbData, - reinterpret_cast(ppData)); - } -}; - - -class StgPoolReadOnly; - -//***************************************************************************** -// This hash class will handle strings inside of a chunk of the pool. -//***************************************************************************** -struct STRINGHASH : HASHLINK -{ - ULONG iOffset; // Offset of this item. -}; - -class CStringPoolHash : public CChainedHash -{ - friend class VerifyLayoutsMD; -public: - CStringPoolHash(StgPoolReadOnly *pool) : m_Pool(pool) - { - LIMITED_METHOD_CONTRACT; - } - - virtual bool InUse(STRINGHASH *pItem) - { - LIMITED_METHOD_CONTRACT; - return (pItem->iOffset != 0xffffffff); - } - - virtual void SetFree(STRINGHASH *pItem) - { - LIMITED_METHOD_CONTRACT; - pItem->iOffset = 0xffffffff; - } - - virtual ULONG Hash(const void *pData) - { - WRAPPER_NO_CONTRACT; - return (HashStringA(reinterpret_cast(pData))); - } - - virtual int Cmp(const void *pData, void *pItem); - -private: - StgPoolReadOnly *m_Pool; // String pool which this hashes. -}; - - -//***************************************************************************** -// This version is for byte streams with a 2 byte WORD giving the length of -// the data. -//***************************************************************************** -typedef STRINGHASH BLOBHASH; - -class CBlobPoolHash : public CChainedHash -{ - friend class VerifyLayoutsMD; -public: - CBlobPoolHash(StgPoolReadOnly *pool) : m_Pool(pool) - { - LIMITED_METHOD_CONTRACT; - } - - virtual bool InUse(BLOBHASH *pItem) - { - LIMITED_METHOD_CONTRACT; - return (pItem->iOffset != 0xffffffff); - } - - virtual void SetFree(BLOBHASH *pItem) - { - LIMITED_METHOD_CONTRACT; - pItem->iOffset = 0xffffffff; - } - - virtual ULONG Hash(const void *pData) - { - STATIC_CONTRACT_NOTHROW; - STATIC_CONTRACT_GC_NOTRIGGER; - STATIC_CONTRACT_FORBID_FAULT; - - ULONG ulSize; - ulSize = CPackedLen::GetLength(pData); - ulSize += CPackedLen::Size(ulSize); - return (HashBytes(reinterpret_cast(pData), ulSize)); - } - - virtual int Cmp(const void *pData, void *pItem); - -private: - StgPoolReadOnly *m_Pool; // Blob pool which this hashes. -}; - -//***************************************************************************** -// This hash class will handle guids inside of a chunk of the pool. -//***************************************************************************** -struct GUIDHASH : HASHLINK -{ - ULONG iIndex; // Index of this item. -}; - -class CGuidPoolHash : public CChainedHash -{ - friend class VerifyLayoutsMD; -public: - CGuidPoolHash(StgPoolReadOnly *pool) : m_Pool(pool) - { - LIMITED_METHOD_CONTRACT; - } - - virtual bool InUse(GUIDHASH *pItem) - { - LIMITED_METHOD_CONTRACT; - return (pItem->iIndex != 0xffffffff); - } - - virtual void SetFree(GUIDHASH *pItem) - { - LIMITED_METHOD_CONTRACT; - pItem->iIndex = 0xffffffff; - } - - virtual ULONG Hash(const void *pData) - { - WRAPPER_NO_CONTRACT; - return (HashBytes(reinterpret_cast(pData), sizeof(GUID))); - } - - virtual int Cmp(const void *pData, void *pItem); - -private: - StgPoolReadOnly *m_Pool; // The GUID pool which this hashes. -}; - - -#endif // __StgPooli_h__ diff --git a/src/inc/stringarraylist.h b/src/inc/stringarraylist.h deleted file mode 100644 index 10401ac31..000000000 --- a/src/inc/stringarraylist.h +++ /dev/null @@ -1,31 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#ifndef STRINGARRAYLIST_H_ -#define STRINGARRAYLIST_H_ - - -// -// StringArrayList is a simple class which is used to contain a growable -// list of Strings, stored in chunks. Based on top of ArrayList -#include "arraylist.h" - - -class StringArrayList -{ - ArrayList m_Elements; -public: - DWORD GetCount() const; - SString& operator[] (DWORD idx) const; - SString& Get (DWORD idx) const; -#ifndef DACCESS_COMPILE - void Append(const SString& string); - void AppendIfNotThere(const SString& string); -#endif - ~StringArrayList(); -}; - - -#include "stringarraylist.inl" -#endif diff --git a/src/inc/stringarraylist.inl b/src/inc/stringarraylist.inl deleted file mode 100644 index 73ca40553..000000000 --- a/src/inc/stringarraylist.inl +++ /dev/null @@ -1,76 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#include "ex.h" - -inline SString& StringArrayList::operator[] (DWORD idx) const -{ - WRAPPER_NO_CONTRACT; - return Get(idx); -} - -inline SString& StringArrayList::Get (DWORD idx) const -{ - WRAPPER_NO_CONTRACT; - PTR_SString ppRet=(PTR_SString)m_Elements.Get(idx); - return *ppRet; -} - -inline DWORD StringArrayList::GetCount() const -{ - WRAPPER_NO_CONTRACT; - return m_Elements.GetCount(); -} - -#ifndef DACCESS_COMPILE -inline void StringArrayList::Append(const SString& string) -{ - CONTRACTL - { - THROWS; - GC_NOTRIGGER; - } - CONTRACTL_END; - NewHolder pAdd=new SString(string); - pAdd->Normalize(); - IfFailThrow(m_Elements.Append(pAdd)); - pAdd.SuppressRelease(); -} - -inline void StringArrayList::AppendIfNotThere(const SString& string) -{ - CONTRACTL - { - THROWS; - GC_NOTRIGGER; - } - CONTRACTL_END; - for (DWORD i=0;i(this); - return S_OK; - } - else - { - *ppv = NULL; - return E_NOINTERFACE; - } - }; -}; - -typedef void CALLBACK CLRTESTHOOKPROC(ICLRTestHookManager*); - -#endif diff --git a/src/inc/unsafe.h b/src/inc/unsafe.h deleted file mode 100644 index ba4a166fb..000000000 --- a/src/inc/unsafe.h +++ /dev/null @@ -1,102 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - - - - -#ifndef __UNSAFE_H__ -#define __UNSAFE_H__ - -// should we just check proper inclusion? -#include - -#include "staticcontract.h" - -inline VOID UnsafeEnterCriticalSection(LPCRITICAL_SECTION lpCriticalSection) -{ - STATIC_CONTRACT_LEAF; - EnterCriticalSection(lpCriticalSection); -} - -inline VOID UnsafeLeaveCriticalSection(LPCRITICAL_SECTION lpCriticalSection) -{ - STATIC_CONTRACT_LEAF; - LeaveCriticalSection(lpCriticalSection); -} - -inline BOOL UnsafeTryEnterCriticalSection(LPCRITICAL_SECTION lpCriticalSection) -{ - STATIC_CONTRACT_LEAF; - return TryEnterCriticalSection(lpCriticalSection); -} - -inline VOID UnsafeInitializeCriticalSection(LPCRITICAL_SECTION lpCriticalSection) -{ - STATIC_CONTRACT_LEAF; - InitializeCriticalSection(lpCriticalSection); -} - -inline VOID UnsafeDeleteCriticalSection(LPCRITICAL_SECTION lpCriticalSection) -{ - STATIC_CONTRACT_LEAF; - DeleteCriticalSection(lpCriticalSection); -} - -inline HANDLE UnsafeCreateEvent(LPSECURITY_ATTRIBUTES lpEventAttributes, BOOL bManualReset, BOOL bInitialState, LPCWSTR lpName) -{ - STATIC_CONTRACT_WRAPPER; - return WszCreateEvent(lpEventAttributes, bManualReset, bInitialState, lpName); -} - -inline BOOL UnsafeSetEvent(HANDLE hEvent) -{ - STATIC_CONTRACT_LEAF; - return SetEvent(hEvent); -} - -inline BOOL UnsafeResetEvent(HANDLE hEvent) -{ - STATIC_CONTRACT_LEAF; - return ResetEvent(hEvent); -} - -inline HANDLE UnsafeCreateSemaphore(LPSECURITY_ATTRIBUTES lpSemaphoreAttributes, LONG lInitialCount, LONG lMaximumCount, LPCWSTR lpName) -{ - STATIC_CONTRACT_WRAPPER; - return WszCreateSemaphore(lpSemaphoreAttributes, lInitialCount, lMaximumCount, lpName); -} - -inline BOOL UnsafeReleaseSemaphore(HANDLE hSemaphore, LONG lReleaseCount, LPLONG lpPreviousCount) -{ - STATIC_CONTRACT_LEAF; - return ReleaseSemaphore(hSemaphore, lReleaseCount, lpPreviousCount); -} - -inline LPVOID UnsafeTlsGetValue(DWORD dwTlsIndex) -{ - STATIC_CONTRACT_LEAF; - return TlsGetValue(dwTlsIndex); -} - -inline BOOL UnsafeTlsSetValue(DWORD dwTlsIndex, LPVOID lpTlsValue) -{ - STATIC_CONTRACT_LEAF; - return TlsSetValue(dwTlsIndex, lpTlsValue); -} - -inline DWORD UnsafeTlsAlloc(void) -{ - STATIC_CONTRACT_LEAF; - return TlsAlloc(); -} - -inline BOOL UnsafeTlsFree(DWORD dwTlsIndex) -{ - STATIC_CONTRACT_LEAF; - return TlsFree(dwTlsIndex); -} - -#endif - - diff --git a/src/inc/utilcode.h b/src/inc/utilcode.h deleted file mode 100644 index de9ba01ad..000000000 --- a/src/inc/utilcode.h +++ /dev/null @@ -1,5527 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -//***************************************************************************** -// UtilCode.h -// -// Utility functions implemented in UtilCode.lib. -// -//***************************************************************************** - -#ifndef __UtilCode_h__ -#define __UtilCode_h__ - -#include "crtwrap.h" -#include "winwrap.h" -#include -#include -#include -#include -#include -#include -#include "clrtypes.h" -#include "safewrap.h" -#include "volatile.h" -#include -#include "clrhost.h" -#include "debugmacros.h" -#include "corhlprpriv.h" -#include "winnls.h" -#include "check.h" -#include "safemath.h" -#include "new.hpp" - -#ifdef PAL_STDCPP_COMPAT -#include -#else -#include "clr_std/type_traits" -#endif - -#include "contract.h" -#include "entrypoints.h" - -#include "clrnt.h" - -// Values for the names of Watson -const WCHAR kWatsonName1[] = W("drwatson"); -const WCHAR kWatsonName2[] = W("drwtsn32"); - -#include "random.h" - -#define WINDOWS_KERNEL32_DLLNAME_A "kernel32" -#define WINDOWS_KERNEL32_DLLNAME_W W("kernel32") - -#define CoreLibName_W W("System.Private.CoreLib") -#define CoreLibName_IL_W W("System.Private.CoreLib.dll") -#define CoreLibName_NI_W W("System.Private.CoreLib.ni.dll") -#define CoreLibName_TLB_W W("System.Private.CoreLib.tlb") -#define CoreLibName_A "System.Private.CoreLib" -#define CoreLibName_IL_A "System.Private.CoreLib.dll" -#define CoreLibName_NI_A "System.Private.CoreLib.ni.dll" -#define CoreLibName_TLB_A "System.Private.CoreLib.tlb" -#define CoreLibNameLen 22 -#define CoreLibSatelliteName_A "System.Private.CoreLib.resources" -#define CoreLibSatelliteNameLen 32 -#define LegacyCoreLibName_A "mscorlib" - -class StringArrayList; - -#if !defined(_DEBUG_IMPL) && defined(_DEBUG) && !defined(DACCESS_COMPILE) -#define _DEBUG_IMPL 1 -#endif - -#ifdef _TARGET_ARM_ - -// Under ARM we generate code only with Thumb encoding. In order to ensure we execute such code in the correct -// mode we must ensure the low-order bit is set in any code address we'll call as a sub-routine. In C++ this -// is handled automatically for us by the compiler. When generating and working with code generated -// dynamically we have to be careful to set or mask-out this bit as appropriate. -#ifndef THUMB_CODE -#define THUMB_CODE 1 -#endif - -// Given a WORD extract the bitfield [lowbit, highbit] (i.e. BitExtract(0xffff, 15, 0) == 0xffff). -inline WORD BitExtract(WORD wValue, DWORD highbit, DWORD lowbit) -{ - _ASSERTE((highbit < 16) && (lowbit < 16) && (highbit >= lowbit)); - return (wValue >> lowbit) & ((1 << ((highbit - lowbit) + 1)) - 1); -} - -// Determine whether an ARM Thumb mode instruction is 32-bit or 16-bit based on the first WORD of the -// instruction. -inline bool Is32BitInstruction(WORD opcode) -{ - return BitExtract(opcode, 15, 11) >= 0x1d; -} - -template -inline ResultType DataPointerToThumbCode(SourceType pCode) -{ - return (ResultType)(((UINT_PTR)pCode) | THUMB_CODE); -} - -template -inline ResultType ThumbCodeToDataPointer(SourceType pCode) -{ - return (ResultType)(((UINT_PTR)pCode) & ~THUMB_CODE); -} - -#endif // _TARGET_ARM_ - -// Convert from a PCODE to the corresponding PINSTR. On many architectures this will be the identity function; -// on ARM, this will mask off the THUMB bit. -inline TADDR PCODEToPINSTR(PCODE pc) -{ -#ifdef _TARGET_ARM_ - return ThumbCodeToDataPointer(pc); -#else - return dac_cast(pc); -#endif -} - -// Convert from a PINSTR to the corresponding PCODE. On many architectures this will be the identity function; -// on ARM, this will raise the THUMB bit. -inline PCODE PINSTRToPCODE(TADDR addr) -{ -#ifdef _TARGET_ARM_ - return DataPointerToThumbCode(addr); -#else - return dac_cast(addr); -#endif -} - -typedef LPCSTR LPCUTF8; -typedef LPSTR LPUTF8; - -#include "nsutilpriv.h" - -#include "stdmacros.h" - -/* -// This is for WinCE -#ifdef VERIFY -#undef VERIFY -#endif - -#ifdef _ASSERTE -#undef _ASSERTE -#endif -*/ - -//********** Macros. ********************************************************** -#ifndef FORCEINLINE - #if _MSC_VER < 1200 - #define FORCEINLINE inline - #else - #define FORCEINLINE __forceinline - #endif -#endif - -#ifndef DEBUG_NOINLINE -#if defined(_DEBUG) -#define DEBUG_NOINLINE __declspec(noinline) -#else -#define DEBUG_NOINLINE -#endif -#endif - -#ifndef DBG_NOINLINE_X86__RET_INLINE -#if defined(_DEBUG) && defined(_TARGET_X86_) -// this exists to make scan work on x86. -#define DBG_NOINLINE_X86__RET_INLINE __declspec(noinline) -#else -#define DBG_NOINLINE_X86__RET_INLINE FORCEINLINE -#endif -#endif - -#include // for offsetof - -#ifndef NumItems -// Number of elements in a fixed-size array -#define NumItems(s) (sizeof(s) / sizeof(s[0])) -#endif - -#ifndef StrLen -// Number of characters in a string literal. Excludes terminating NULL. -#define StrLen(str) (NumItems(str) - 1) -#endif - - -#define IS_DIGIT(ch) ((ch >= W('0')) && (ch <= W('9'))) -#define DIGIT_TO_INT(ch) (ch - W('0')) -#define INT_TO_DIGIT(i) ((WCHAR)(W('0') + i)) - -#define IS_HEXDIGIT(ch) (((ch >= W('a')) && (ch <= W('f'))) || \ - ((ch >= W('A')) && (ch <= W('F')))) -#define HEXDIGIT_TO_INT(ch) ((towlower(ch) - W('a')) + 10) -#define INT_TO_HEXDIGIT(i) ((WCHAR)(W('a') + (i - 10))) - - -// Helper will 4 byte align a value, rounding up. -#define ALIGN4BYTE(val) (((val) + 3) & ~0x3) - -#ifdef _DEBUG -#define DEBUGARG(x) , x -#else -#define DEBUGARG(x) -#endif - -#ifndef sizeofmember -// Returns the size of a class or struct member. -#define sizeofmember(c,m) (sizeof(((c*)0)->m)) -#endif - -//=--------------------------------------------------------------------------= -// Prefast helpers. -// - -#include "safemath.h" - - -//=--------------------------------------------------------------------------= -// string helpers. - -// -// given and ANSI String, copy it into a wide buffer. -// be careful about scoping when using this macro! -// -// how to use the below two macros: -// -// ... -// LPSTR pszA; -// pszA = MyGetAnsiStringRoutine(); -// MAKE_WIDEPTR_FROMANSI(pwsz, pszA); -// MyUseWideStringRoutine(pwsz); -// ... -// -// similarily for MAKE_ANSIPTR_FROMWIDE. note that the first param does not -// have to be declared, and no clean up must be done. -// - -// We'll define an upper limit that allows multiplication by 4 (the max -// bytes/char in UTF-8) but still remains positive, and allows some room for pad. -// Under normal circumstances, we should never get anywhere near this limit. -#define MAKE_MAX_LENGTH 0x1fffff00 - -#ifndef MAKE_TOOLONGACTION -#define MAKE_TOOLONGACTION ThrowHR(COR_E_OVERFLOW) -#endif - -#ifndef MAKE_TRANSLATIONFAILED -#define MAKE_TRANSLATIONFAILED ThrowWin32(ERROR_NO_UNICODE_TRANSLATION) -#endif - -// This version throws on conversion errors (ie, no best fit character -// mapping to characters that look similar, and no use of the default char -// ('?') when printing out unrepresentable characters. Use this method for -// most development in the EE, especially anything like metadata or class -// names. See the BESTFIT version if you're printing out info to the console. -#define MAKE_MULTIBYTE_FROMWIDE(ptrname, widestr, codepage) \ - int __l##ptrname = (int)wcslen(widestr); \ - if (__l##ptrname > MAKE_MAX_LENGTH) \ - MAKE_TOOLONGACTION; \ - __l##ptrname = (int)((__l##ptrname + 1) * 2 * sizeof(char)); \ - CQuickBytes __CQuickBytes##ptrname; \ - __CQuickBytes##ptrname.AllocThrows(__l##ptrname); \ - BOOL __b##ptrname; \ - DWORD __cBytes##ptrname = WszWideCharToMultiByte(codepage, WC_NO_BEST_FIT_CHARS, widestr, -1, (LPSTR)__CQuickBytes##ptrname.Ptr(), __l##ptrname, NULL, &__b##ptrname); \ - if (__b##ptrname || (__cBytes##ptrname == 0 && (widestr[0] != W('\0')))) { \ - MAKE_TRANSLATIONFAILED; \ - } \ - LPSTR ptrname = (LPSTR)__CQuickBytes##ptrname.Ptr() - -// This version does best fit character mapping and also allows the use -// of the default char ('?') for any Unicode character that isn't -// representable. This is reasonable for writing to the console, but -// shouldn't be used for most string conversions. -#define MAKE_MULTIBYTE_FROMWIDE_BESTFIT(ptrname, widestr, codepage) \ - int __l##ptrname = (int)wcslen(widestr); \ - if (__l##ptrname > MAKE_MAX_LENGTH) \ - MAKE_TOOLONGACTION; \ - __l##ptrname = (int)((__l##ptrname + 1) * 2 * sizeof(char)); \ - CQuickBytes __CQuickBytes##ptrname; \ - __CQuickBytes##ptrname.AllocThrows(__l##ptrname); \ - DWORD __cBytes##ptrname = WszWideCharToMultiByte(codepage, 0, widestr, -1, (LPSTR)__CQuickBytes##ptrname.Ptr(), __l##ptrname, NULL, NULL); \ - if (__cBytes##ptrname == 0 && __l##ptrname != 0) { \ - MAKE_TRANSLATIONFAILED; \ - } \ - LPSTR ptrname = (LPSTR)__CQuickBytes##ptrname.Ptr() - -// Use for anything critical other than output to console, where weird -// character mappings are unacceptable. -#define MAKE_ANSIPTR_FROMWIDE(ptrname, widestr) MAKE_MULTIBYTE_FROMWIDE(ptrname, widestr, CP_ACP) - -// Use for output to the console. -#define MAKE_ANSIPTR_FROMWIDE_BESTFIT(ptrname, widestr) MAKE_MULTIBYTE_FROMWIDE_BESTFIT(ptrname, widestr, CP_ACP) - -#define MAKE_WIDEPTR_FROMANSI(ptrname, ansistr) \ - CQuickBytes __qb##ptrname; \ - int __l##ptrname; \ - __l##ptrname = WszMultiByteToWideChar(CP_ACP, 0, ansistr, -1, 0, 0); \ - if (__l##ptrname > MAKE_MAX_LENGTH) \ - MAKE_TOOLONGACTION; \ - LPWSTR ptrname = (LPWSTR) __qb##ptrname.AllocThrows((__l##ptrname+1)*sizeof(WCHAR)); \ - if (WszMultiByteToWideChar(CP_ACP, MB_ERR_INVALID_CHARS, ansistr, -1, ptrname, __l##ptrname) == 0) { \ - MAKE_TRANSLATIONFAILED; \ - } - -#define MAKE_WIDEPTR_FROMANSI_NOTHROW(ptrname, ansistr) \ - CQuickBytes __qb##ptrname; \ - LPWSTR ptrname = 0; \ - int __l##ptrname; \ - __l##ptrname = WszMultiByteToWideChar(CP_ACP, 0, ansistr, -1, 0, 0); \ - if (__l##ptrname <= MAKE_MAX_LENGTH) { \ - ptrname = (LPWSTR) __qb##ptrname.AllocNoThrow((__l##ptrname+1)*sizeof(WCHAR)); \ - if (ptrname) { \ - if (WszMultiByteToWideChar(CP_ACP, MB_ERR_INVALID_CHARS, ansistr, -1, ptrname, __l##ptrname) != 0) { \ - ptrname[__l##ptrname] = 0; \ - } else { \ - ptrname = 0; \ - } \ - } \ - } - -#define MAKE_UTF8PTR_FROMWIDE(ptrname, widestr) CQuickBytes _##ptrname; _##ptrname.ConvertUnicode_Utf8(widestr); LPSTR ptrname = (LPSTR) _##ptrname.Ptr(); - -#define MAKE_UTF8PTR_FROMWIDE_NOTHROW(ptrname, widestr) \ - CQuickBytes __qb##ptrname; \ - int __l##ptrname = (int)wcslen(widestr); \ - LPUTF8 ptrname = 0; \ - if (__l##ptrname <= MAKE_MAX_LENGTH) { \ - __l##ptrname = (int)((__l##ptrname + 1) * 2 * sizeof(char)); \ - ptrname = (LPUTF8) __qb##ptrname.AllocNoThrow(__l##ptrname); \ - } \ - if (ptrname) { \ - INT32 __lresult##ptrname=WszWideCharToMultiByte(CP_UTF8, 0, widestr, -1, ptrname, __l##ptrname-1, NULL, NULL); \ - DWORD __dwCaptureLastError##ptrname = ::GetLastError(); \ - if ((__lresult##ptrname==0) && (((LPCWSTR)widestr)[0] != W('\0'))) { \ - if (__dwCaptureLastError##ptrname==ERROR_INSUFFICIENT_BUFFER) { \ - INT32 __lsize##ptrname=WszWideCharToMultiByte(CP_UTF8, 0, widestr, -1, NULL, 0, NULL, NULL); \ - ptrname = (LPSTR) __qb##ptrname .AllocNoThrow(__lsize##ptrname); \ - if (ptrname) { \ - if (WszWideCharToMultiByte(CP_UTF8, 0, widestr, -1, ptrname, __lsize##ptrname, NULL, NULL) != 0) { \ - ptrname[__l##ptrname] = 0; \ - } else { \ - ptrname = 0; \ - } \ - } \ - } \ - else { \ - ptrname = 0; \ - } \ - } \ - } \ - -#define MAKE_WIDEPTR_FROMUTF8N(ptrname, utf8str, n8chrs) \ - CQuickBytes __qb##ptrname; \ - int __l##ptrname; \ - __l##ptrname = WszMultiByteToWideChar(CP_UTF8, 0, utf8str, n8chrs, 0, 0); \ - if (__l##ptrname > MAKE_MAX_LENGTH) \ - MAKE_TOOLONGACTION; \ - LPWSTR ptrname = (LPWSTR) __qb##ptrname .AllocThrows((__l##ptrname+1)*sizeof(WCHAR)); \ - if (0==WszMultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, utf8str, n8chrs, ptrname, __l##ptrname)) { \ - MAKE_TRANSLATIONFAILED; \ - } \ - ptrname[__l##ptrname] = 0; - - -#define MAKE_WIDEPTR_FROMUTF8(ptrname, utf8str) CQuickBytes _##ptrname; _##ptrname.ConvertUtf8_Unicode(utf8str); LPCWSTR ptrname = (LPCWSTR) _##ptrname.Ptr(); - - -#define MAKE_WIDEPTR_FROMUTF8N_NOTHROW(ptrname, utf8str, n8chrs) \ - CQuickBytes __qb##ptrname; \ - int __l##ptrname; \ - LPWSTR ptrname = 0; \ - __l##ptrname = WszMultiByteToWideChar(CP_UTF8, 0, utf8str, n8chrs, 0, 0); \ - if (__l##ptrname <= MAKE_MAX_LENGTH) { \ - ptrname = (LPWSTR) __qb##ptrname.AllocNoThrow((__l##ptrname+1)*sizeof(WCHAR)); \ - if (ptrname) { \ - if (WszMultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, utf8str, n8chrs, ptrname, __l##ptrname) != 0) { \ - ptrname[__l##ptrname] = 0; \ - } else { \ - ptrname = 0; \ - } \ - } \ - } - -#define MAKE_WIDEPTR_FROMUTF8_NOTHROW(ptrname, utf8str) MAKE_WIDEPTR_FROMUTF8N_NOTHROW(ptrname, utf8str, -1) - -// This method takes the number of characters -#define MAKE_MULTIBYTE_FROMWIDEN(ptrname, widestr, _nCharacters, _pCnt, codepage) \ - CQuickBytes __qb##ptrname; \ - int __l##ptrname; \ - __l##ptrname = WszWideCharToMultiByte(codepage, WC_NO_BEST_FIT_CHARS, widestr, _nCharacters, NULL, 0, NULL, NULL); \ - if (__l##ptrname > MAKE_MAX_LENGTH) \ - MAKE_TOOLONGACTION; \ - ptrname = (LPUTF8) __qb##ptrname .AllocThrows(__l##ptrname+1); \ - BOOL __b##ptrname; \ - DWORD _pCnt = WszWideCharToMultiByte(codepage, WC_NO_BEST_FIT_CHARS, widestr, _nCharacters, ptrname, __l##ptrname, NULL, &__b##ptrname); \ - if (__b##ptrname || (_pCnt == 0 && _nCharacters > 0)) { \ - MAKE_TRANSLATIONFAILED; \ - } \ - ptrname[__l##ptrname] = 0; - -#define MAKE_MULTIBYTE_FROMWIDEN_BESTFIT(ptrname, widestr, _nCharacters, _pCnt, codepage) \ - CQuickBytes __qb##ptrname; \ - int __l##ptrname; \ - __l##ptrname = WszWideCharToMultiByte(codepage, 0, widestr, _nCharacters, NULL, 0, NULL, NULL); \ - if (__l##ptrname > MAKE_MAX_LENGTH) \ - MAKE_TOOLONGACTION; \ - ptrname = (LPUTF8) __qb##ptrname .AllocThrows(__l##ptrname+1); \ - DWORD _pCnt = WszWideCharToMultiByte(codepage, 0, widestr, _nCharacters, ptrname, __l##ptrname, NULL, NULL); \ - if (_pCnt == 0 && _nCharacters > 0) { \ - MAKE_TRANSLATIONFAILED; \ - } \ - ptrname[__l##ptrname] = 0; - -#define MAKE_ANSIPTR_FROMWIDEN(ptrname, widestr, _nCharacters, _pCnt) \ - MAKE_MULTIBYTE_FROMWIDEN(ptrname, widestr, _nCharacters, _pCnt, CP_ACP) - - -inline -LPWSTR DuplicateString( - LPCWSTR wszString, - size_t cchString) -{ - STATIC_CONTRACT_NOTHROW; - - LPWSTR wszDup = NULL; - if (wszString != NULL) - { - wszDup = new (nothrow) WCHAR[cchString + 1]; - if (wszDup != NULL) - { - wcscpy_s(wszDup, cchString + 1, wszString); - } - } - return wszDup; -} - -inline -LPWSTR DuplicateString( - LPCWSTR wszString) -{ - STATIC_CONTRACT_NOTHROW; - - if (wszString != NULL) - { - return DuplicateString(wszString, wcslen(wszString)); - } - else - { - return NULL; - } -} - -void DECLSPEC_NORETURN ThrowOutOfMemory(); - -inline -LPWSTR DuplicateStringThrowing( - LPCWSTR wszString, - size_t cchString) -{ - STATIC_CONTRACT_THROWS; - - if (wszString == NULL) - return NULL; - - LPWSTR wszDup = DuplicateString(wszString, cchString); - if (wszDup == NULL) - ThrowOutOfMemory(); - - return wszDup; -} - -inline -LPWSTR DuplicateStringThrowing( - LPCWSTR wszString) -{ - STATIC_CONTRACT_THROWS; - - if (wszString == NULL) - return NULL; - - LPWSTR wszDup = DuplicateString(wszString); - if (wszDup == NULL) - ThrowOutOfMemory(); - - return wszDup; -} - - -//***************************************************************************** -// Placement new is used to new and object at an exact location. The pointer -// is simply returned to the caller without actually using the heap. The -// advantage here is that you cause the ctor() code for the object to be run. -// This is ideal for heaps of C++ objects that need to get init'd multiple times. -// Example: -// void *pMem = GetMemFromSomePlace(); -// Foo *p = new (pMem) Foo; -// DoSomething(p); -// p->~Foo(); -//***************************************************************************** -#ifndef __PLACEMENT_NEW_INLINE -#define __PLACEMENT_NEW_INLINE -inline void *__cdecl operator new(size_t, void *_P) -{ - LIMITED_METHOD_DAC_CONTRACT; - - return (_P); -} -#endif // __PLACEMENT_NEW_INLINE - - -/********************************************************************************/ -/* portability helpers */ -#ifdef _WIN64 -#define IN_WIN64(x) x -#define IN_WIN32(x) -#else -#define IN_WIN64(x) -#define IN_WIN32(x) x -#endif - -void * __cdecl -operator new(size_t n); - -_Ret_bytecap_(n) void * __cdecl -operator new[](size_t n); - -void __cdecl -operator delete(void *p) NOEXCEPT; - -void __cdecl -operator delete[](void *p) NOEXCEPT; - -#ifdef _DEBUG_IMPL -HRESULT _OutOfMemory(LPCSTR szFile, int iLine); -#define OutOfMemory() _OutOfMemory(__FILE__, __LINE__) -#else -inline HRESULT OutOfMemory() -{ - LIMITED_METHOD_CONTRACT; - return (E_OUTOFMEMORY); -} -#endif - -//***************************************************************************** -// Handle accessing localizable resource strings -//***************************************************************************** -// NOTE: Should use locale names as much as possible. LCIDs don't support -// custom cultures on Vista+. -// TODO: This should always use the names -#ifdef FEATURE_USE_LCID -typedef LCID LocaleID; -typedef LCID LocaleIDValue; -#else -typedef LPCWSTR LocaleID; -typedef WCHAR LocaleIDValue[LOCALE_NAME_MAX_LENGTH]; -#endif - -// Notes about the culture callbacks: -// - The language we're operating in can change at *runtime*! -// - A process may operate in *multiple* languages. -// (ex: Each thread may have it's own language) -// - If we don't care what language we're in (or have no way of knowing), -// then return a 0-length name and UICULTUREID_DONTCARE for the culture ID. -// - GetCultureName() and the GetCultureId() must be in sync (refer to the -// same language). -// - We have two functions separate functions for better performance. -// - The name is used to resolve a directory for MsCorRC.dll. -// - The id is used as a key to map to a dll hinstance. - -// Callback to obtain both the culture name and the culture's parent culture name -typedef HRESULT (*FPGETTHREADUICULTURENAMES)(__inout StringArrayList* pCultureNames); -#ifdef FEATURE_USE_LCID -// Callback to return the culture ID. -const LCID UICULTUREID_DONTCARE = (LCID)-1; -#else -const LPCWSTR UICULTUREID_DONTCARE = NULL; -#endif - -typedef int (*FPGETTHREADUICULTUREID)(LocaleIDValue*); - -HMODULE CLRLoadLibrary(LPCWSTR lpLibFileName); - -HMODULE CLRLoadLibraryEx(LPCWSTR lpLibFileName, HANDLE hFile, DWORD dwFlags); - -BOOL CLRFreeLibrary(HMODULE hModule); - -// Prevent people from using LoadStringRC & LoadStringRCEx from inside the product since it -// causes issues with having the wrong version picked up inside the shim. -#define LoadStringRC __error("From inside the CLR, use UtilLoadStringRC; LoadStringRC is only meant to be exported.") -#define LoadStringRCEx __error("From inside the CLR, use UtilLoadStringRCEx; LoadStringRC is only meant to be exported.") - -// Load a string using the resources for the current module. -STDAPI UtilLoadStringRC(UINT iResouceID, __out_ecount (iMax) LPWSTR szBuffer, int iMax, int bQuiet=FALSE); - -#ifdef FEATURE_USE_LCID -STDAPI UtilLoadStringRCEx(LCID lcid, UINT iResourceID, __out_ecount (iMax) LPWSTR szBuffer, int iMax, int bQuiet, int *pcwchUsed); -#endif - -// Specify callbacks so that UtilLoadStringRC can find out which language we're in. -// If no callbacks specified (or both parameters are NULL), we default to the -// resource dll in the root (which is probably english). -void SetResourceCultureCallbacks( - FPGETTHREADUICULTURENAMES fpGetThreadUICultureNames, - FPGETTHREADUICULTUREID fpGetThreadUICultureId -); - -void GetResourceCultureCallbacks( - FPGETTHREADUICULTURENAMES* fpGetThreadUICultureNames, - FPGETTHREADUICULTUREID* fpGetThreadUICultureId -); - -#if !defined(DACCESS_COMPILE) -// Get the MUI ID, on downlevel platforms where MUI is not supported it -// returns the default system ID. -extern int GetMUILanguageID(LocaleIDValue* pResult); -extern HRESULT GetMUILanguageNames(__inout StringArrayList* pCultureNames); - -#endif // !defined(DACCESS_COMPILE) - -//***************************************************************************** -// Use this class by privately deriving from noncopyable to disallow copying of -// your class. -//***************************************************************************** -class noncopyable -{ -protected: - noncopyable() - {} - ~noncopyable() - {} - -private: - noncopyable(const noncopyable&); - const noncopyable& operator=(const noncopyable&); -}; - -//***************************************************************************** -// Must associate each handle to an instance of a resource dll with the int -// that it represents -//***************************************************************************** -typedef HINSTANCE HRESOURCEDLL; - - -class CCulturedHInstance -{ - LocaleIDValue m_LangId; - HRESOURCEDLL m_hInst; - BOOL m_fMissing; - -public: - CCulturedHInstance() - { - LIMITED_METHOD_CONTRACT; - m_hInst = NULL; - m_fMissing = FALSE; - } - - BOOL HasID(LocaleID id) - { - _ASSERTE(m_hInst != NULL || m_fMissing); - if (id == UICULTUREID_DONTCARE) - return FALSE; - -#ifdef FEATURE_USE_LCID - return id == m_LangId; -#else - return wcscmp(id, m_LangId) == 0; -#endif - } - - HRESOURCEDLL GetLibraryHandle() - { - return m_hInst; - } - - BOOL IsSet() - { - return m_hInst != NULL; - } - - BOOL IsMissing() - { - return m_fMissing; - } - - void SetMissing(LocaleID id) - { - _ASSERTE(m_hInst == NULL); - SetId(id); - m_fMissing = TRUE; - } - - void Set(LocaleID id, HRESOURCEDLL hInst) - { - _ASSERTE(m_hInst == NULL); - _ASSERTE(m_fMissing == FALSE); - SetId(id); - m_hInst = hInst; - } - private: - void SetId(LocaleID id) - { -#ifdef FEATURE_USE_LCID - m_LangId = id; -#else - if (id != UICULTUREID_DONTCARE) - { - wcsncpy_s(m_LangId, NumItems(m_LangId), id, NumItems(m_LangId)); - m_LangId[NumItems(m_LangId)-1] = W('\0'); - } - else - { - m_LangId[0] = W('\0'); - } -#endif - } - }; - -#ifndef DACCESS_COMPILE -void AddThreadPreferredUILanguages(StringArrayList* pArray); -#endif -//***************************************************************************** -// CCompRC manages string Resource access for COM+. This includes loading -// the MsCorRC.dll for resources as well allowing each thread to use a -// a different localized version. -//***************************************************************************** -class CCompRC -{ -public: - - enum ResourceCategory - { - // must be present - Required, - - // present in Desktop CLR and Core CLR + debug pack, an error - // If missing, get a generic error message instead - Error, - - // present in Desktop CLR and Core CLR + debug pack, normal operation (e.g tracing) - // if missing, get a generic "resource not found" message instead - Debugging, - - // present in Desktop CLR, optional for CoreCLR - DesktopCLR, - - // might not be present, non essential - Optional - }; - - CCompRC() - { - // This constructor will be fired up on startup. Make sure it doesn't - // do anything besides zero-out out values. - m_bUseFallback = FALSE; - - m_fpGetThreadUICultureId = NULL; - m_fpGetThreadUICultureNames = NULL; - - - m_pHash = NULL; - m_nHashSize = 0; - m_csMap = NULL; - m_pResourceFile = NULL; -#ifdef FEATURE_PAL - m_pResourceDomain = NULL; -#endif // FEATURE_PAL - - }// CCompRC - - HRESULT Init(LPCWSTR pResourceFile, BOOL bUseFallback = FALSE); - void Destroy(); - - BOOL ShouldUseFallback() - { - LIMITED_METHOD_CONTRACT; - return m_bUseFallback; - }; - - static void SetIsMscoree() {s_bIsMscoree = TRUE;} - - HRESULT LoadString(ResourceCategory eCategory, UINT iResourceID, __out_ecount (iMax) LPWSTR szBuffer, int iMax , int *pcwchUsed=NULL); - HRESULT LoadString(ResourceCategory eCategory, LocaleID langId, UINT iResourceID, __out_ecount (iMax) LPWSTR szBuffer, int iMax, int *pcwchUsed); - - void SetResourceCultureCallbacks( - FPGETTHREADUICULTURENAMES fpGetThreadUICultureNames, - FPGETTHREADUICULTUREID fpGetThreadUICultureId - ); - - void GetResourceCultureCallbacks( - FPGETTHREADUICULTURENAMES* fpGetThreadUICultureNames, - FPGETTHREADUICULTUREID* fpGetThreadUICultureId - ); - - HRESULT LoadMUILibrary(HRESOURCEDLL * pHInst); - - // Get the default resource location (mscorrc.dll for desktop, mscorrc.debug.dll for CoreCLR) - static CCompRC* GetDefaultResourceDll(); - // Get the generic messages dll (Silverlight only, mscorrc.dll) - static CCompRC* GetFallbackResourceDll(); - static void ShutdownDefaultResourceDll(); - static void GetDefaultCallbacks( - FPGETTHREADUICULTURENAMES* fpGetThreadUICultureNames, - FPGETTHREADUICULTUREID* fpGetThreadUICultureId) - { - WRAPPER_NO_CONTRACT; - m_DefaultResourceDll.GetResourceCultureCallbacks( - fpGetThreadUICultureNames, - fpGetThreadUICultureId); - } - - static void SetDefaultCallbacks( - FPGETTHREADUICULTURENAMES fpGetThreadUICultureNames, - FPGETTHREADUICULTUREID fpGetThreadUICultureId) - { - WRAPPER_NO_CONTRACT; - // Either both are NULL or neither are NULL - _ASSERTE((fpGetThreadUICultureNames != NULL) == - (fpGetThreadUICultureId != NULL)); - - m_DefaultResourceDll.SetResourceCultureCallbacks( - fpGetThreadUICultureNames, - fpGetThreadUICultureId); - - m_FallbackResourceDll.SetResourceCultureCallbacks( - fpGetThreadUICultureNames, - fpGetThreadUICultureId); - - } - -#ifdef USE_FORMATMESSAGE_WRAPPER - -DWORD -PALAPI -static -FormatMessage( - IN DWORD dwFlags, - IN LPCVOID lpSource, - IN DWORD dwMessageId, - IN DWORD dwLanguageId, - OUT LPWSTR lpBuffer, - IN DWORD nSize, - IN va_list *Arguments); -#endif // USE_FORMATMESSAGE_WRAPPER - - -private: - HRESULT GetLibrary(LocaleID langId, HRESOURCEDLL* phInst); -#ifndef DACCESS_COMPILE - HRESULT LoadLibraryHelper(HRESOURCEDLL *pHInst, - SString& rcPath); - HRESULT LoadLibraryThrows(HRESOURCEDLL * pHInst); - HRESULT LoadLibrary(HRESOURCEDLL * pHInst); - HRESULT LoadResourceFile(HRESOURCEDLL * pHInst, LPCWSTR lpFileName); -#endif - - // We do not have global constructors any more - static LONG m_dwDefaultInitialized; - static CCompRC m_DefaultResourceDll; - static LPCWSTR m_pDefaultResource; - - // fallback resources if debug pack is not installed - static LONG m_dwFallbackInitialized; - static CCompRC m_FallbackResourceDll; - static LPCWSTR m_pFallbackResource; - - // We must map between a thread's int and a dll instance. - // Since we only expect 1 language almost all of the time, we'll special case - // that and then use a variable size map for everything else. - CCulturedHInstance m_Primary; - CCulturedHInstance * m_pHash; - int m_nHashSize; - - CRITSEC_COOKIE m_csMap; - - LPCWSTR m_pResourceFile; -#ifdef FEATURE_PAL - // Resource domain is an ANSI string identifying a native resources file - static LPCSTR m_pDefaultResourceDomain; - static LPCSTR m_pFallbackResourceDomain; - LPCSTR m_pResourceDomain; -#endif // FEATURE_PAL - - // Main accessors for hash - HRESOURCEDLL LookupNode(LocaleID langId, BOOL &fMissing); - HRESULT AddMapNode(LocaleID langId, HRESOURCEDLL hInst, BOOL fMissing = FALSE); - - FPGETTHREADUICULTUREID m_fpGetThreadUICultureId; - FPGETTHREADUICULTURENAMES m_fpGetThreadUICultureNames; - - BOOL m_bUseFallback; - static BOOL s_bIsMscoree; -}; - -HRESULT UtilLoadResourceString(CCompRC::ResourceCategory eCategory, UINT iResouceID, __out_ecount (iMax) LPWSTR szBuffer, int iMax); - - -int UtilMessageBox( - HWND hWnd, // Handle to Owner Window - UINT uText, // Resource Identifier for Text message - UINT uCaption, // Resource Identifier for Caption - UINT uType, // Style of MessageBox - BOOL displayForNonInteractive, // Display even if the process is running non interactive - BOOL ShowFileNameInTitle, // Flag to show FileName in Caption - ...); // Additional Arguments - -int UtilMessageBoxNonLocalized( - HWND hWnd, // Handle to Owner Window - LPCWSTR lpText, // Resource Identifier for Text message - LPCWSTR lpTitle, // Resource Identifier for Caption - UINT uType, // Style of MessageBox - BOOL displayForNonInteractive, // Display even if the process is running non interactive - BOOL ShowFileNameInTitle, // Flag to show FileName in Caption - ...); // Additional Arguments - -int UtilMessageBoxVA( - HWND hWnd, // Handle to Owner Window - UINT uText, // Resource Identifier for Text message - UINT uCaption, // Resource Identifier for Caption - UINT uType, // Style of MessageBox - BOOL displayForNonInteractive, // Display even if the process is running non interactive - BOOL ShowFileNameInTitle, // Flag to show FileName in Caption - va_list args); // Additional Arguments - -int UtilMessageBoxNonLocalizedVA( - HWND hWnd, // Handle to Owner Window - LPCWSTR lpText, // Text message - LPCWSTR lpCaption, // Caption - UINT uType, // Style of MessageBox - BOOL displayForNonInteractive, // Display even if the process is running non interactive - BOOL ShowFileNameInTitle, // Flag to show FileName in Caption - BOOL * pInputFromUser, // To distinguish between user pressing abort vs. assuming abort. - va_list args); // Additional Arguments - -int UtilMessageBoxNonLocalizedVA( - HWND hWnd, // Handle to Owner Window - LPCWSTR lpText, // Text message - LPCWSTR lpCaption, // Caption - LPCWSTR lpDetails, // Details that may be shown in a collapsed extended area of the dialog (Vista or higher). - UINT uType, // Style of MessageBox - BOOL displayForNonInteractive, // Display even if the process is running non interactive - BOOL ShowFileNameInTitle, // Flag to show FileName in Caption - BOOL * pInputFromUser, // To distinguish between user pressing abort vs. assuming abort. - va_list args); // Additional Arguments - -int UtilMessageBoxCatastrophic( - UINT uText, // Text for MessageBox - UINT uTitle, // Title for MessageBox - UINT uType, // Style of MessageBox - BOOL ShowFileNameInTitle, // Flag to show FileName in Caption - ...); - -int UtilMessageBoxCatastrophicNonLocalized( - LPCWSTR lpText, // Text for MessageBox - LPCWSTR lpTitle, // Title for MessageBox - UINT uType, // Style of MessageBox - BOOL ShowFileNameInTitle, // Flag to show FileName in Caption - ...); - -int UtilMessageBoxCatastrophicVA( - UINT uText, // Text for MessageBox - UINT uTitle, // Title for MessageBox - UINT uType, // Style of MessageBox - BOOL ShowFileNameInTitle, // Flag to show FileName in Caption - va_list args); // Additional Arguments - -int UtilMessageBoxCatastrophicNonLocalizedVA( - LPCWSTR lpText, // Text for MessageBox - LPCWSTR lpTitle, // Title for MessageBox - UINT uType, // Style of MessageBox - BOOL ShowFileNameInTitle, // Flag to show FileName in Caption - va_list args); // Additional Arguments - - -// The HRESULT_FROM_WIN32 macro evaluates its arguments three times. -// TODO: All HRESULT_FROM_WIN32(GetLastError()) should be replaced by calls to -// this helper function avoid code bloat -inline HRESULT HRESULT_FROM_GetLastError() -{ - WRAPPER_NO_CONTRACT; - DWORD dw = GetLastError(); - // Make sure we return a failure - if (dw == ERROR_SUCCESS) - { - _ASSERTE(!"We were expecting to get an error code, but a success code is being returned. Check this code path for Everett!"); - return E_FAIL; - } - else - return HRESULT_FROM_WIN32(dw); -} - -inline HRESULT HRESULT_FROM_GetLastErrorNA() -{ - WRAPPER_NO_CONTRACT; - DWORD dw = GetLastError(); - // Make sure we return a failure - if (dw == ERROR_SUCCESS) - return E_FAIL; - else - return HRESULT_FROM_WIN32(dw); -} - -inline HRESULT BadError(HRESULT hr) -{ - LIMITED_METHOD_CONTRACT; - _ASSERTE(!"Serious Error"); - return (hr); -} - -#define TESTANDRETURN(test, hrVal) \ -{ \ - int ___test = (int)(test); \ - if (! ___test) \ - return hrVal; \ -} - -#define TESTANDRETURNPOINTER(pointer) \ - TESTANDRETURN(pointer!=NULL, E_POINTER) - -#define TESTANDRETURNMEMORY(pointer) \ - TESTANDRETURN(pointer!=NULL, E_OUTOFMEMORY) - -#define TESTANDRETURNHR(hr) \ - TESTANDRETURN(SUCCEEDED(hr), hr) - -#define TESTANDRETURNARG(argtest) \ - TESTANDRETURN(argtest, E_INVALIDARG) - -// Quick validity check for HANDLEs that are returned by Win32 APIs that -// use INVALID_HANDLE_VALUE instead of NULL to indicate an error -inline BOOL IsValidHandle(HANDLE h) -{ - LIMITED_METHOD_CONTRACT; - return ((h != NULL) && (h != INVALID_HANDLE_VALUE)); -} - -// Count the bits in a value in order iBits time. -inline int CountBits(int iNum) -{ - LIMITED_METHOD_CONTRACT; - int iBits; - for (iBits=0; iNum; iBits++) - iNum = iNum & (iNum - 1); - return (iBits); -} - -#include "bitposition.h" - -// Used to remove trailing zeros from Decimal types. -// NOTE: Assumes hi32 bits are empty (used for conversions from Cy->Dec) -inline HRESULT DecimalCanonicalize(DECIMAL* dec) -{ - WRAPPER_NO_CONTRACT; - - // Clear the VARENUM field - (*(USHORT*)dec) = 0; - - // Remove trailing zeros: - DECIMAL temp; - DECIMAL templast; - temp = templast = *dec; - - // Ensure the hi 32 bits are empty (should be if we came from a currency) - if ((DECIMAL_HI32(temp) != 0) || (DECIMAL_SCALE(temp) > 4)) - return DISP_E_OVERFLOW; - - // Return immediately if dec represents a zero. - if (DECIMAL_LO32(temp) == 0 && DECIMAL_MID32(temp) == 0) - return S_OK; - - // Compare to the original to see if we've - // lost non-zero digits (and make sure we don't overflow the scale BYTE) - -#ifdef _PREFAST_ -#pragma warning(push) -#pragma warning(disable:6219) // "Suppress PREFast warning about Implicit cast between semantically different integer types" -#endif - while ((DECIMAL_SCALE(temp) <= 4) && (VARCMP_EQ == VarDecCmp(dec, &temp))) - { - -#ifdef _PREFAST_ -#pragma warning(pop) -#endif - templast = temp; - - // Remove the last digit and normalize. Ignore temp.Hi32 - // as Currency values will have a max of 64 bits of data. - DECIMAL_SCALE(temp)--; - UINT64 temp64 = (((UINT64) DECIMAL_MID32(temp)) << 32) + DECIMAL_LO32(temp); - temp64 /= 10; - - DECIMAL_MID32(temp) = (ULONG)(temp64 >> 32); - DECIMAL_LO32(temp) = (ULONG)temp64; - } - *dec = templast; - - return S_OK; -} - -//***************************************************************************** -// -// Paths functions. Use these instead of the CRT. -// -//***************************************************************************** -// secure version! Specify the size of the each buffer in count of elements -void SplitPath(const WCHAR *path, - __inout_z __inout_ecount_opt(driveSizeInWords) WCHAR *drive, int driveSizeInWords, - __inout_z __inout_ecount_opt(dirSizeInWords) WCHAR *dir, int dirSizeInWords, - __inout_z __inout_ecount_opt(fnameSizeInWords) WCHAR *fname, size_t fnameSizeInWords, - __inout_z __inout_ecount_opt(extSizeInWords) WCHAR *ext, size_t extSizeInWords); - -//******************************************************************************* -// A much more sensible version that just points to each section of the string. -//******************************************************************************* -void SplitPathInterior( - __in LPCWSTR wszPath, - __out_opt LPCWSTR *pwszDrive, __out_opt size_t *pcchDrive, - __out_opt LPCWSTR *pwszDir, __out_opt size_t *pcchDir, - __out_opt LPCWSTR *pwszFileName, __out_opt size_t *pcchFileName, - __out_opt LPCWSTR *pwszExt, __out_opt size_t *pcchExt); - - -void MakePath(__out CQuickWSTR &path, - __in LPCWSTR drive, - __in LPCWSTR dir, - __in LPCWSTR fname, - __in LPCWSTR ext); - -WCHAR * FullPath(__out_ecount (maxlen) WCHAR *UserBuf, const WCHAR *path, size_t maxlen); - -//***************************************************************************** -// -// SString version of the path functions. -// -//***************************************************************************** -void SplitPath(__in SString const &path, - __inout_opt SString *drive, - __inout_opt SString *dir, - __inout_opt SString *fname, - __inout_opt SString *ext); - -#if !defined(NO_CLRCONFIG) - -//***************************************************************************** -// -// **** REGUTIL - Static helper functions for reading/writing to Windows registry. -// -//***************************************************************************** - - -class REGUTIL -{ -public: -//***************************************************************************** - - enum CORConfigLevel - { - COR_CONFIG_ENV = 0x01, - COR_CONFIG_USER = 0x02, - COR_CONFIG_MACHINE = 0x04, - COR_CONFIG_FUSION = 0x08, - - COR_CONFIG_REGISTRY = (COR_CONFIG_USER|COR_CONFIG_MACHINE|COR_CONFIG_FUSION), - COR_CONFIG_ALL = (COR_CONFIG_ENV|COR_CONFIG_USER|COR_CONFIG_MACHINE), - }; - - // - // NOTE: The following function is deprecated; use the CLRConfig class instead. - // To access a configuration value through CLRConfig, add an entry in file:../inc/CLRConfigValues.h. - // - static DWORD GetConfigDWORD_DontUse_( - LPCWSTR name, - DWORD defValue, - CORConfigLevel level = COR_CONFIG_ALL, - BOOL fPrependCOMPLUS = TRUE); - - // - // NOTE: The following function is deprecated; use the CLRConfig class instead. - // To access a configuration value through CLRConfig, add an entry in file:../inc/CLRConfigValues.h. - // - static HRESULT GetConfigDWORD_DontUse_( - LPCWSTR name, - DWORD defValue, - __out DWORD * result, - CORConfigLevel level = COR_CONFIG_ALL, - BOOL fPrependCOMPLUS = TRUE); - - static ULONGLONG GetConfigULONGLONG_DontUse_( - LPCWSTR name, - ULONGLONG defValue, - CORConfigLevel level = COR_CONFIG_ALL, - BOOL fPrependCOMPLUS = TRUE); - - // - // NOTE: The following function is deprecated; use the CLRConfig class instead. - // To access a configuration value through CLRConfig, add an entry in file:../inc/CLRConfigValues.h. - // - static DWORD GetConfigFlag_DontUse_( - LPCWSTR name, - DWORD bitToSet, - BOOL defValue = FALSE); - - // - // NOTE: The following function is deprecated; use the CLRConfig class instead. - // To access a configuration value through CLRConfig, add an entry in file:../inc/CLRConfigValues.h. - // - static LPWSTR GetConfigString_DontUse_( - LPCWSTR name, - BOOL fPrependCOMPLUS = TRUE, - CORConfigLevel level = COR_CONFIG_ALL, - BOOL fUsePerfCache = TRUE); - - static void FreeConfigString(__in __in_z LPWSTR name); - -private: - static LPWSTR EnvGetString(LPCWSTR name, BOOL fPrependCOMPLUS); -public: - - static BOOL UseRegistry(); - -private: -//***************************************************************************** -// Get either a DWORD or ULONGLONG. Always puts the result in a ULONGLONG that -// you can safely cast to a DWORD if fGetDWORD is TRUE. -//***************************************************************************** - static HRESULT GetConfigInteger( - LPCWSTR name, - ULONGLONG defValue, - __out ULONGLONG * result, - BOOL fGetDWORD = TRUE, - CORConfigLevel level = COR_CONFIG_ALL, - BOOL fPrependCOMPLUS = TRUE); -public: - - -//***************************************************************************** -// (Optional) Initialize the config registry cache -// (see ConfigCacheValueNameSeenPerhaps, below.) -//***************************************************************************** - static void InitOptionalConfigCache(); - -private: - - -//***************************************************************************** -// Return TRUE if the registry value name might have been seen in the registry -// at startup; -// return FALSE if the value was definitely not seen at startup. -// -// Perf Optimization for VSWhidbey:113373. -//***************************************************************************** - static BOOL RegCacheValueNameSeenPerhaps( - LPCWSTR name); -//***************************************************************************** -// Return TRUE if the environment variable name might have been seen at startup; -// return FALSE if the value was definitely not seen at startup. -//***************************************************************************** - static BOOL EnvCacheValueNameSeenPerhaps( - LPCWSTR name); - - static BOOL s_fUseRegCache; // Enable registry cache; if FALSE, CCVNSP - // always returns TRUE. - static BOOL s_fUseEnvCache; // Enable env cache. - - static BOOL s_fUseRegistry; // Allow lookups in the registry - - // Open the .NetFramework keys once and cache the handles - static HKEY s_hMachineFrameworkKey; - static HKEY s_hUserFrameworkKey; -}; - -// need this here because CLRConfig depends on REGUTIL, and ConfigStringHolder depends on CLRConfig -#include "clrconfig.h" - -//----------------------------------------------------------------------------- -// Wrapper for configuration strings. -// This serves as a holder to call FreeConfigString. -class ConfigStringHolder -{ -public: - ConfigStringHolder() { m_wszString = NULL; } - ~ConfigStringHolder() - { - Clear(); - } - - // - // NOTE: The following function is deprecated; use the CLRConfig class instead. - // To access a configuration value through CLRConfig, add an entry in file:../inc/CLRConfigValues.h. - // - void Init_DontUse_(LPCWSTR wszName) - { - Clear(); - m_wszString = REGUTIL::GetConfigString_DontUse_(wszName); - } - - // Free resources. - void Clear() - { - if (m_wszString != NULL) - { - REGUTIL::FreeConfigString(m_wszString); - m_wszString = NULL; - } - } - - // Get the string value. NULL if not set. - LPCWSTR Value() - { - return m_wszString; - } - -private: - LPWSTR m_wszString; -}; - -#endif // defined(NO_CLRCONFIG) - -#include "ostype.h" - -#define CLRGetTickCount64() GetTickCount64() - -// -// Use this function to initialize the s_CodeAllocHint -// during startup. base is runtime .dll base address, -// size is runtime .dll virtual size. -// -void InitCodeAllocHint(SIZE_T base, SIZE_T size, int randomPageOffset); - - -// -// Use this function to reset the s_CodeAllocHint -// after unloading an AppDomain -// -void ResetCodeAllocHint(); - -// -// Returns TRUE if p is located in near clr.dll that allows us -// to use rel32 IP-relative addressing modes. -// -BOOL IsPreferredExecutableRange(void * p); - -// -// Allocate free memory that will be used for executable code -// Handles the special requirements that we have on 64-bit platforms -// where we want the executable memory to be located near mscorwks -// -BYTE * ClrVirtualAllocExecutable(SIZE_T dwSize, - DWORD flAllocationType, - DWORD flProtect); - -// -// Allocate free memory within the range [pMinAddr..pMaxAddr] using -// ClrVirtualQuery to find free memory and ClrVirtualAlloc to allocate it. -// -BYTE * ClrVirtualAllocWithinRange(const BYTE *pMinAddr, - const BYTE *pMaxAddr, - SIZE_T dwSize, - DWORD flAllocationType, - DWORD flProtect); - -// -// Allocate free memory with specific alignment -// -LPVOID ClrVirtualAllocAligned(LPVOID lpAddress, SIZE_T dwSize, DWORD flAllocationType, DWORD flProtect, SIZE_T alignment); - -//****************************************************************************** -// Returns the number of processors that a process has been configured to run on -//****************************************************************************** -class NumaNodeInfo -{ -private: - static BOOL m_enableGCNumaAware; - static BOOL InitNumaNodeInfoAPI(); - -public: - static BOOL CanEnableGCNumaAware(); - static void InitNumaNodeInfo(); - -#if !defined(FEATURE_REDHAWK) -private: // apis types - - //GetNumaHighestNodeNumber() - typedef BOOL - (WINAPI *PGNHNN)(PULONG); - //VirtualAllocExNuma() - typedef LPVOID - (WINAPI *PVAExN)(HANDLE,LPVOID,SIZE_T,DWORD,DWORD,DWORD); - - // api pfns and members - static PGNHNN m_pGetNumaHighestNodeNumber; - static PVAExN m_pVirtualAllocExNuma; - -public: // functions - - static LPVOID VirtualAllocExNuma(HANDLE hProc, LPVOID lpAddr, SIZE_T size, - DWORD allocType, DWORD prot, DWORD node); - -private: - //GetNumaProcessorNodeEx() - typedef BOOL - (WINAPI *PGNPNEx)(PPROCESSOR_NUMBER, PUSHORT); - static PGNPNEx m_pGetNumaProcessorNodeEx; - -public: - static BOOL GetNumaProcessorNodeEx(PPROCESSOR_NUMBER proc_no, PUSHORT node_no); -#endif -}; - -struct CPU_Group_Info -{ - WORD nr_active; // at most 64 - WORD reserved[1]; - WORD begin; - WORD end; - DWORD_PTR active_mask; - DWORD groupWeight; - DWORD activeThreadWeight; -}; - -class CPUGroupInfo -{ -private: - static LONG m_initialization; - static WORD m_nGroups; - static WORD m_nProcessors; - static BOOL m_enableGCCPUGroups; - static BOOL m_threadUseAllCpuGroups; - static WORD m_initialGroup; - static CPU_Group_Info *m_CPUGroupInfoArray; - - static BOOL InitCPUGroupInfoAPI(); - static BOOL InitCPUGroupInfoArray(); - static BOOL InitCPUGroupInfoRange(); - static void InitCPUGroupInfo(); - static BOOL IsInitialized(); - -public: - static void EnsureInitialized(); - static BOOL CanEnableGCCPUGroups(); - static BOOL CanEnableThreadUseAllCpuGroups(); - static WORD GetNumActiveProcessors(); - static void GetGroupForProcessor(WORD processor_number, - WORD *group_number, WORD *group_processor_number); - static DWORD CalculateCurrentProcessorNumber(); - //static void PopulateCPUUsageArray(void * infoBuffer, ULONG infoSize); - -#if !defined(FEATURE_REDHAWK) -private: - //GetLogicalProcessorInforomationEx() - typedef BOOL - (WINAPI *PGLPIEx)(DWORD, SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX *, PDWORD); - //SetThreadGroupAffinity() - typedef BOOL - (WINAPI *PSTGA)(HANDLE, GROUP_AFFINITY *, GROUP_AFFINITY *); - //GetThreadGroupAffinity() - typedef BOOL - (WINAPI *PGTGA)(HANDLE, GROUP_AFFINITY *); - //GetCurrentProcessorNumberEx() - typedef void - (WINAPI *PGCPNEx)(PROCESSOR_NUMBER *); - //GetSystemTimes() - typedef BOOL - (WINAPI *PGST)(FILETIME *, FILETIME *, FILETIME *); - //NtQuerySystemInformationEx() - //typedef int - //(WINAPI *PNTQSIEx)(SYSTEM_INFORMATION_CLASS, PULONG, ULONG, PVOID, ULONG, PULONG); - static PGLPIEx m_pGetLogicalProcessorInformationEx; - static PSTGA m_pSetThreadGroupAffinity; - static PGTGA m_pGetThreadGroupAffinity; - static PGCPNEx m_pGetCurrentProcessorNumberEx; - static PGST m_pGetSystemTimes; - //static PNTQSIEx m_pNtQuerySystemInformationEx; - -public: - static BOOL GetLogicalProcessorInformationEx(DWORD relationship, - SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX *slpiex, PDWORD count); - static BOOL SetThreadGroupAffinity(HANDLE h, - GROUP_AFFINITY *groupAffinity, GROUP_AFFINITY *previousGroupAffinity); - static BOOL GetThreadGroupAffinity(HANDLE h, GROUP_AFFINITY *groupAffinity); - static BOOL GetSystemTimes(FILETIME *idleTime, FILETIME *kernelTime, FILETIME *userTime); - static void ChooseCPUGroupAffinity(GROUP_AFFINITY *gf); - static void ClearCPUGroupAffinity(GROUP_AFFINITY *gf); -#endif -}; - -int GetCurrentProcessCpuCount(); -DWORD_PTR GetCurrentProcessCpuMask(); - -uint32_t GetOsPageSize(); - - -//***************************************************************************** -// Return != 0 if the bit at the specified index in the array is on and 0 if -// it is off. -//***************************************************************************** -inline int GetBit(PTR_BYTE pcBits,int iBit) -{ - LIMITED_METHOD_CONTRACT; - return (pcBits[iBit>>3] & (1 << (iBit & 0x7))); -} - -#ifdef DACCESS_COMPILE -inline int GetBit(BYTE const * pcBits,int iBit) -{ - WRAPPER_NO_CONTRACT; - return GetBit(dac_cast(pcBits), iBit); -} -#endif - -//***************************************************************************** -// Set the state of the bit at the specified index based on the value of bOn. -//***************************************************************************** -inline void SetBit(PTR_BYTE pcBits,int iBit,int bOn) -{ - LIMITED_METHOD_CONTRACT; - if (bOn) - pcBits[iBit>>3] |= (1 << (iBit & 0x7)); - else - pcBits[iBit>>3] &= ~(1 << (iBit & 0x7)); -} - -#ifdef DACCESS_COMPILE -inline void SetBit(BYTE * pcBits,int iBit,int bOn) -{ - WRAPPER_NO_CONTRACT; - SetBit(dac_cast(pcBits), iBit, bOn); -} -#endif - -template -class SimpleListNode -{ -public: - SimpleListNode(const T& _t) - { - data = _t; - next = 0; - } - - T data; - SimpleListNode* next; -}; - -template -class SimpleList -{ -public: - typedef SimpleListNode NodeType; - - SimpleList() - { - head = NULL; - } - - void LinkHead(NodeType* pNode) - { - pNode->next = head; - head = pNode; - } - - NodeType* UnlinkHead() - { - NodeType* ret = head; - - if (head) - { - head = head->next; - } - return ret; - } - - NodeType* Head() - { - return head; - } - -protected: - - NodeType* head; -}; - - -template < typename T, typename U > -struct Pair -{ -public: - typedef Pair< T, U > this_type; - typedef T first_type; - typedef U second_type; - - Pair() - {} - - Pair( T const & t, U const & u ) - : m_first( t ) - , m_second( u ) - { SUPPORTS_DAC; } - - Pair( this_type const & obj ) - : m_first( obj.m_first ) - , m_second( obj.m_second ) - {} - - this_type & operator=( this_type const & obj ) - { - m_first = obj.m_first; - m_second = obj.m_second; - return *this; - } - - T & First() - { - return m_first; - } - - T const & First() const - { - return m_first; - } - - U & Second() - { - return m_second; - } - - U const & Second() const - { - return m_second; - } - - bool operator==(const Pair& rhs) const - { - return ((this->First() == rhs.First()) && - (this->Second() == rhs.Second())); - } - - bool operator!=(const Pair& rhs) const - { - return !(*this == rhs); - } - -private: - first_type m_first; - second_type m_second; -}; - - -template < typename T, typename U > -Pair< T, U > MakePair( T const & t, U const & u ) -{ - SUPPORTS_DAC; - return Pair< T, U >( t, u ); -} - - -//***************************************************************************** -// This class implements a dynamic array of structures for which the order of -// the elements is unimportant. This means that any item placed in the list -// may be swapped to any other location in the list at any time. If the order -// of the items you place in the array is important, then use the CStructArray -// class. -//***************************************************************************** - -template -class CUnorderedArrayWithAllocator -{ - int m_iCount; // # of elements used in the list. - int m_iSize; // # of elements allocated in the list. -public: -#ifndef DACCESS_COMPILE - T *m_pTable; // Pointer to the list of elements. -#else - TADDR m_pTable; // Pointer to the list of elements. -#endif - -public: - -#ifndef DACCESS_COMPILE - - CUnorderedArrayWithAllocator() : - m_iCount(0), - m_iSize(0), - m_pTable(NULL) - { - LIMITED_METHOD_CONTRACT; - } - ~CUnorderedArrayWithAllocator() - { - LIMITED_METHOD_CONTRACT; - // Free the chunk of memory. - if (m_pTable != NULL) - ALLOCATOR::Free(this, m_pTable); - } - - void Clear() - { - WRAPPER_NO_CONTRACT; - m_iCount = 0; - if (m_iSize > iGrowInc) - { - T* tmp = ALLOCATOR::AllocNoThrow(this, iGrowInc); - if (tmp) { - ALLOCATOR::Free(this, m_pTable); - m_pTable = tmp; - m_iSize = iGrowInc; - } - } - } - - void Clear(int iFirst, int iCount) - { - WRAPPER_NO_CONTRACT; - int iSize; - - if (iFirst + iCount < m_iCount) - memmove(&m_pTable[iFirst], &m_pTable[iFirst + iCount], sizeof(T) * (m_iCount - (iFirst + iCount))); - - m_iCount -= iCount; - - iSize = ((m_iCount / iGrowInc) * iGrowInc) + ((m_iCount % iGrowInc != 0) ? iGrowInc : 0); - if (m_iSize > iGrowInc && iSize < m_iSize) - { - T *tmp = ALLOCATOR::AllocNoThrow(this, iSize); - if (tmp) { - memcpy (tmp, m_pTable, iSize * sizeof(T)); - delete [] m_pTable; - m_pTable = tmp; - m_iSize = iSize; - } - } - _ASSERTE(m_iCount <= m_iSize); - } - - T *Table() - { - LIMITED_METHOD_CONTRACT; - return (m_pTable); - } - - T *Append() - { - CONTRACTL { - NOTHROW; - } CONTRACTL_END; - - // The array should grow, if we can't fit one more element into the array. - if (m_iSize <= m_iCount && GrowNoThrow() == NULL) - return (NULL); - return (&m_pTable[m_iCount++]); - } - - T *AppendThrowing() - { - CONTRACTL { - THROWS; - } CONTRACTL_END; - - // The array should grow, if we can't fit one more element into the array. - if (m_iSize <= m_iCount) - Grow(); - return (&m_pTable[m_iCount++]); - } - - void Delete(const T &Entry) - { - LIMITED_METHOD_CONTRACT; - --m_iCount; - for (int i=0; i <= m_iCount; ++i) - if (m_pTable[i] == Entry) - { - m_pTable[i] = m_pTable[m_iCount]; - return; - } - - // Just in case we didn't find it. - ++m_iCount; - } - - void DeleteByIndex(int i) - { - LIMITED_METHOD_CONTRACT; - --m_iCount; - m_pTable[i] = m_pTable[m_iCount]; - } - - void Swap(int i,int j) - { - LIMITED_METHOD_CONTRACT; - T tmp; - - if (i == j) - return; - tmp = m_pTable[i]; - m_pTable[i] = m_pTable[j]; - m_pTable[j] = tmp; - } - -#else - - TADDR Table() - { - LIMITED_METHOD_CONTRACT; - SUPPORTS_DAC; - return (m_pTable); - } - - void EnumMemoryRegions(void) - { - SUPPORTS_DAC; - DacEnumMemoryRegion(m_pTable, m_iCount * sizeof(T)); - } - -#endif // #ifndef DACCESS_COMPILE - - USHORT Count() - { - LIMITED_METHOD_CONTRACT; - SUPPORTS_DAC; - _ASSERTE(FitsIn(m_iCount)); - return static_cast(m_iCount); - } - -private: - T *Grow(); - T *GrowNoThrow(); -}; - - -#ifndef DACCESS_COMPILE - -//***************************************************************************** -// Increase the size of the array. -//***************************************************************************** -template -T *CUnorderedArrayWithAllocator::GrowNoThrow() // NULL if can't grow. -{ - WRAPPER_NO_CONTRACT; - T *pTemp; - - // try to allocate memory for reallocation. - if ((pTemp = ALLOCATOR::AllocNoThrow(this, m_iSize+iGrowInc)) == NULL) - return (NULL); - memcpy (pTemp, m_pTable, m_iSize*sizeof(T)); - ALLOCATOR::Free(this, m_pTable); - m_pTable = pTemp; - m_iSize += iGrowInc; - _ASSERTE(m_iSize > 0); - return (pTemp); -} - -template -T *CUnorderedArrayWithAllocator::Grow() // exception if can't grow. -{ - WRAPPER_NO_CONTRACT; - T *pTemp; - - // try to allocate memory for reallocation. - pTemp = ALLOCATOR::AllocThrowing(this, m_iSize+iGrowInc); - memcpy (pTemp, m_pTable, m_iSize*sizeof(T)); - ALLOCATOR::Free(this, m_pTable); - m_pTable = pTemp; - m_iSize += iGrowInc; - _ASSERTE(m_iSize > 0); - return (pTemp); -} - -#endif // #ifndef DACCESS_COMPILE - - -template -class CUnorderedArray__Allocator -{ -public: - - static T *AllocThrowing (void*, int nElements) - { - return new T[nElements]; - } - - static T *AllocNoThrow (void*, int nElements) - { - return new (nothrow) T[nElements]; - } - - static void Free (void*, T *pTable) - { - delete [] pTable; - } -}; - - -template -class CUnorderedArray : public CUnorderedArrayWithAllocator > -{ -public: - - CUnorderedArray () - { - LIMITED_METHOD_CONTRACT; - } -}; - - -//Used by the debugger. Included here in hopes somebody else might, too -typedef CUnorderedArray SIZE_T_UNORDERED_ARRAY; - - -//***************************************************************************** -// This class implements a dynamic array of structures for which the insert -// order is important. Inserts will slide all elements after the location -// down, deletes slide all values over the deleted item. If the order of the -// items in the array is unimportant to you, then CUnorderedArray may provide -// the same feature set at lower cost. -//***************************************************************************** -class CStructArray -{ - BYTE *m_pList; // Pointer to the list of elements. - int m_iCount; // # of elements used in the list. - int m_iSize; // # of elements allocated in the list. - int m_iGrowInc; // Growth increment. - short m_iElemSize; // Size of an array element. - bool m_bFree; // true if data is automatically maintained. - -public: - CStructArray(short iElemSize, short iGrowInc = 1) : - m_pList(NULL), - m_iCount(0), - m_iSize(0), - m_iGrowInc(iGrowInc), - m_iElemSize(iElemSize), - m_bFree(true) - { - LIMITED_METHOD_CONTRACT; - } - ~CStructArray() - { - WRAPPER_NO_CONTRACT; - Clear(); - } - - void *Insert(int iIndex); - void *InsertThrowing(int iIndex); - void *Append(); - void *AppendThrowing(); - int AllocateBlock(int iCount); - void AllocateBlockThrowing(int iCount); - void Delete(int iIndex); - void *Ptr() - { - LIMITED_METHOD_CONTRACT; - return (m_pList); - } - void *Get(int iIndex) - { - WRAPPER_NO_CONTRACT; - _ASSERTE(iIndex < m_iCount); - return ((void *) ((size_t) Ptr() + (iIndex * m_iElemSize))); - } - int Size() - { - LIMITED_METHOD_CONTRACT; - return (m_iCount * m_iElemSize); - } - int Count() - { - LIMITED_METHOD_CONTRACT; - return (m_iCount); - } - void Clear(); - void ClearCount() - { - LIMITED_METHOD_CONTRACT; - m_iCount = 0; - } - - void InitOnMem(short iElemSize, void *pList, int iCount, int iSize, int iGrowInc=1) - { - LIMITED_METHOD_CONTRACT; - m_iElemSize = iElemSize; - m_iGrowInc = (short) iGrowInc; - m_pList = (BYTE*)pList; - m_iCount = iCount; - m_iSize = iSize; - m_bFree = false; - } - -private: - void Grow(int iCount); -}; - - -//***************************************************************************** -// This template simplifies access to a CStructArray by removing void * and -// adding some operator overloads. -//***************************************************************************** -template -class CDynArray : public CStructArray -{ -public: - CDynArray(short iGrowInc=16) : - CStructArray(sizeof(T), iGrowInc) - { - LIMITED_METHOD_CONTRACT; - } - - T *Insert(int iIndex) - { - WRAPPER_NO_CONTRACT; - return ((T *)CStructArray::Insert((int)iIndex)); - } - - T *InsertThrowing(int iIndex) - { - WRAPPER_NO_CONTRACT; - return ((T *)CStructArray::InsertThrowing((int)iIndex)); - } - - T *Append() - { - WRAPPER_NO_CONTRACT; - return ((T *)CStructArray::Append()); - } - - T *AppendThrowing() - { - WRAPPER_NO_CONTRACT; - return ((T *)CStructArray::AppendThrowing()); - } - - T *Ptr() - { - WRAPPER_NO_CONTRACT; - return ((T *)CStructArray::Ptr()); - } - - T *Get(int iIndex) - { - WRAPPER_NO_CONTRACT; - return (Ptr() + iIndex); - } - T &operator[](int iIndex) - { - WRAPPER_NO_CONTRACT; - return (*(Ptr() + iIndex)); - } - int ItemIndex(T *p) - { - WRAPPER_NO_CONTRACT; - return (((int)(LONG_PTR)p - (int)(LONG_PTR)Ptr()) / sizeof(T)); - } - void Move(int iFrom, int iTo) - { - WRAPPER_NO_CONTRACT; - T tmp; - - _ASSERTE(iFrom >= 0 && iFrom < Count() && - iTo >= 0 && iTo < Count()); - - tmp = *(Ptr() + iFrom); - if (iTo > iFrom) - memmove(Ptr() + iFrom, Ptr() + iFrom + 1, (iTo - iFrom) * sizeof(T)); - else - memmove(Ptr() + iTo + 1, Ptr() + iTo, (iFrom - iTo) * sizeof(T)); - *(Ptr() + iTo) = tmp; - } -}; - -// Some common arrays. -typedef CDynArray INTARRAY; -typedef CDynArray SHORTARRAY; -typedef CDynArray LONGARRAY; -typedef CDynArray USHORTARRAY; -typedef CDynArray ULONGARRAY; -typedef CDynArray BYTEARRAY; -typedef CDynArray TOKENARRAY; - -template class CStackArray : public CStructArray -{ -public: - CStackArray(short iGrowInc=4) : - CStructArray(sizeof(T), iGrowInc), - m_curPos(0) - { - LIMITED_METHOD_CONTRACT; - } - - void Push(T p) - { - WRAPPER_NO_CONTRACT; - // We should only inc m_curPos after we grow the array. - T *pT = (T *)CStructArray::InsertThrowing(m_curPos); - m_curPos ++; - *pT = p; - } - - T * Pop() - { - WRAPPER_NO_CONTRACT; - T * retPtr; - - _ASSERTE(m_curPos > 0); - - retPtr = (T *)CStructArray::Get(m_curPos-1); - CStructArray::Delete(m_curPos--); - - return (retPtr); - } - - int Count() - { - LIMITED_METHOD_CONTRACT; - return(m_curPos); - } - -private: - int m_curPos; -}; - - -//***************************************************************************** -// This template manages a list of free entries by their 0 based offset. By -// making it a template, you can use whatever size free chain will match your -// maximum count of items. -1 is reserved. -//***************************************************************************** -template class TFreeList -{ -public: - void Init( - T *rgList, - int iCount) - { - LIMITED_METHOD_CONTRACT; - // Save off values. - m_rgList = rgList; - m_iCount = iCount; - m_iNext = 0; - - // Init free list. - int i; - for (i=0; i class CQuickSort -{ -protected: - T *m_pBase; // Base of array to sort. -private: - SSIZE_T m_iCount; // How many items in array. - SSIZE_T m_iElemSize; // Size of one element. -public: - CQuickSort( - T *pBase, // Address of first element. - SSIZE_T iCount) : // How many there are. - m_pBase(pBase), - m_iCount(iCount), - m_iElemSize(sizeof(T)) - { - LIMITED_METHOD_DAC_CONTRACT; - } - -//***************************************************************************** -// Call to sort the array. -//***************************************************************************** - inline void Sort() - { - WRAPPER_NO_CONTRACT; - SortRange(0, m_iCount - 1); - } - -protected: -//***************************************************************************** -// Override this function to do the comparison. -//***************************************************************************** - virtual FORCEINLINE int Compare( // -1, 0, or 1 - T *psFirst, // First item to compare. - T *psSecond) // Second item to compare. - { - LIMITED_METHOD_DAC_CONTRACT; - return (memcmp(psFirst, psSecond, sizeof(T))); -// return (::Compare(*psFirst, *psSecond)); - } - - virtual FORCEINLINE void Swap( - SSIZE_T iFirst, - SSIZE_T iSecond) - { - LIMITED_METHOD_DAC_CONTRACT; - if (iFirst == iSecond) return; - T sTemp( m_pBase[iFirst] ); - m_pBase[iFirst] = m_pBase[iSecond]; - m_pBase[iSecond] = sTemp; - } - -private: - inline void SortRange( - SSIZE_T iLeft, - SSIZE_T iRight) - { - WRAPPER_NO_CONTRACT; - SSIZE_T iLast; - SSIZE_T i; // loop variable. - - for (;;) - { - // if less than two elements you're done. - if (iLeft >= iRight) - return; - - // ASSERT that we now have valid indicies. This is statically provable - // since this private function is only called with valid indicies, - // and iLeft and iRight only converge towards eachother. However, - // PreFast can't detect this because it doesn't know about our callers. - COMPILER_ASSUME(iLeft >= 0 && iLeft < m_iCount); - COMPILER_ASSUME(iRight >= 0 && iRight < m_iCount); - - // The mid-element is the pivot, move it to the left. - Swap(iLeft, (iLeft + iRight) / 2); - iLast = iLeft; - - // move everything that is smaller than the pivot to the left. - for (i = iLeft + 1; i <= iRight; i++) - { - if (Compare(&m_pBase[i], &m_pBase[iLeft]) < 0) - { - Swap(i, ++iLast); - } - } - - // Put the pivot to the point where it is in between smaller and larger elements. - Swap(iLeft, iLast); - - // Sort each partition. - SSIZE_T iLeftLast = iLast - 1; - SSIZE_T iRightFirst = iLast + 1; - if (iLeftLast - iLeft < iRight - iRightFirst) - { // Left partition is smaller, sort it recursively - SortRange(iLeft, iLeftLast); - // Tail call to sort the right (bigger) partition - iLeft = iRightFirst; - //iRight = iRight; - continue; - } - else - { // Right partition is smaller, sort it recursively - SortRange(iRightFirst, iRight); - // Tail call to sort the left (bigger) partition - //iLeft = iLeft; - iRight = iLeftLast; - continue; - } - } - } -}; - -//***************************************************************************** -// Faster and simpler version of the binary search below. -//***************************************************************************** -template -const T * BinarySearch(const T * pBase, int iCount, const T & find) -{ - WRAPPER_NO_CONTRACT; - - int iFirst = 0; - int iLast = iCount - 1; - - // It is faster to use linear search once we get down to a small number of elements. - while (iLast - iFirst > 10) - { - int iMid = (iLast + iFirst) / 2; - - if (find < pBase[iMid]) - iLast = iMid - 1; - else - iFirst = iMid; - } - - for (int i = iFirst; i <= iLast; i++) - { - if (find == pBase[i]) - return &pBase[i]; - - if (find < pBase[i]) - break; - } - - return NULL; -} - -//***************************************************************************** -// This template encapsulates a binary search algorithm on the given type -// of data. -//***************************************************************************** -template class CBinarySearch -{ -private: - const T *m_pBase; // Base of array to sort. - int m_iCount; // How many items in array. - -public: - CBinarySearch( - const T *pBase, // Address of first element. - int iCount) : // Value to find. - m_pBase(pBase), - m_iCount(iCount) - { - LIMITED_METHOD_CONTRACT; - } - -//***************************************************************************** -// Searches for the item passed to ctor. -//***************************************************************************** - const T *Find( // Pointer to found item in array. - const T *psFind, // The key to find. - int *piInsert = NULL) // Index to insert at. - { - WRAPPER_NO_CONTRACT; - int iMid, iFirst, iLast; // Loop control. - int iCmp; // Comparison. - - iFirst = 0; - iLast = m_iCount - 1; - while (iFirst <= iLast) - { - iMid = (iLast + iFirst) / 2; - iCmp = Compare(psFind, &m_pBase[iMid]); - if (iCmp == 0) - { - if (piInsert != NULL) - *piInsert = iMid; - return (&m_pBase[iMid]); - } - else if (iCmp < 0) - iLast = iMid - 1; - else - iFirst = iMid + 1; - } - if (piInsert != NULL) - *piInsert = iFirst; - return (NULL); - } - -//***************************************************************************** -// Override this function to do the comparison if a comparison operator is -// not valid for your data type (such as a struct). -//***************************************************************************** - virtual int Compare( // -1, 0, or 1 - const T *psFirst, // Key you are looking for. - const T *psSecond) // Item to compare to. - { - LIMITED_METHOD_CONTRACT; - return (memcmp(psFirst, psSecond, sizeof(T))); -// return (::Compare(*psFirst, *psSecond)); - } -}; - -//***************************************************************************** -// The information that the hash table implementation stores at the beginning -// of every record that can be but in the hash table. -//***************************************************************************** -typedef DPTR(struct HASHENTRY) PTR_HASHENTRY; -struct HASHENTRY -{ - ULONG iPrev; // Previous bucket in the chain. - ULONG iNext; // Next bucket in the chain. -}; - -typedef DPTR(struct FREEHASHENTRY) PTR_FREEHASHENTRY; -struct FREEHASHENTRY : HASHENTRY -{ - ULONG iFree; -}; - -//***************************************************************************** -// Used by the FindFirst/FindNextEntry functions. These api's allow you to -// do a sequential scan of all entries. -//***************************************************************************** -struct HASHFIND -{ - ULONG iBucket; // The next bucket to look in. - ULONG iNext; -}; - - -//***************************************************************************** -// IMPORTANT: This data structure is deprecated, please do not add any new uses. -// The hashtable implementation that should be used instead is code:SHash. -// If code:SHash does not work for you, talk to mailto:clrdeag. -//***************************************************************************** -// This is a class that implements a chain and bucket hash table. -// -// The data is actually supplied as an array of structures by the user of this class. -// This allows the buckets to use small indices to point to the chain, instead of pointers. -// -// Each entry in the array contains a HASHENTRY structure immediately -// followed by the key used to hash the structure. -// -// The HASHENTRY part of every structure is used to implement the chain of -// entries in a single bucket. -// -// This implementation does not support rehashing the buckets if the table grows -// to big. -// @TODO: Fix this by adding an abstract function Hash() which must be implemented -// by all clients. -// -//***************************************************************************** -class CHashTable -{ - friend class DebuggerRCThread; //RCthread actually needs access to - //fields of derrived class DebuggerPatchTable - -protected: - TADDR m_pcEntries; // Pointer to the array of structs. - ULONG m_iEntrySize; // Size of the structs. - - ULONG m_iBuckets; // # of chains we are hashing into. - PTR_ULONG m_piBuckets; // Ptr to the array of bucket chains. - - INDEBUG(unsigned m_maxSearch;) // For evaluating perf characteristics - - HASHENTRY *EntryPtr(ULONG iEntry) - { - LIMITED_METHOD_DAC_CONTRACT; - return (PTR_HASHENTRY(m_pcEntries + (iEntry * m_iEntrySize))); - } - - ULONG ItemIndex(HASHENTRY *p) - { - SUPPORTS_DAC; - LIMITED_METHOD_CONTRACT; - return (ULONG)((dac_cast(p) - m_pcEntries) / m_iEntrySize); - } - - -public: - - CHashTable( - ULONG iBuckets) : // # of chains we are hashing into. - m_pcEntries((TADDR)NULL), - m_iBuckets(iBuckets) - { - LIMITED_METHOD_CONTRACT; - - m_piBuckets = NULL; - - INDEBUG(m_maxSearch = 0;) - } - - CHashTable() : // # of chains we are hashing into. - m_pcEntries((TADDR)NULL), - m_iBuckets(5) - { - LIMITED_METHOD_CONTRACT; - - m_piBuckets = NULL; - - INDEBUG(m_maxSearch = 0;) - } - -#ifndef DACCESS_COMPILE - - ~CHashTable() - { - LIMITED_METHOD_CONTRACT; - if (m_piBuckets != NULL) - { - delete [] m_piBuckets; - m_piBuckets = NULL; - } - } - -//***************************************************************************** -// This is the second part of construction where we do all of the work that -// can fail. We also take the array of structs here because the calling class -// presumably needs to allocate it in its NewInit. -//***************************************************************************** - HRESULT NewInit( // Return status. - BYTE *pcEntries, // Array of structs we are managing. - ULONG iEntrySize); // Size of the entries. - -//***************************************************************************** -// This can be called to change the pointer to the table that the hash table -// is managing. You might call this if (for example) you realloc the size -// of the table and its pointer is different. -//***************************************************************************** - void SetTable( - BYTE *pcEntries) // Array of structs we are managing. - { - LIMITED_METHOD_CONTRACT; - m_pcEntries = (TADDR)pcEntries; - } - -//***************************************************************************** -// Clear the hash table as if there were nothing in it. -//***************************************************************************** - void Clear() - { - LIMITED_METHOD_CONTRACT; - _ASSERTE(m_piBuckets != NULL); - memset(m_piBuckets, 0xff, m_iBuckets * sizeof(ULONG)); - } - -//***************************************************************************** -// Add the struct at the specified index in m_pcEntries to the hash chains. -//***************************************************************************** - BYTE *Add( // New entry. - ULONG iHash, // Hash value of entry to add. - ULONG iIndex); // Index of struct in m_pcEntries. - -//***************************************************************************** -// Delete the struct at the specified index in m_pcEntries from the hash chains. -//***************************************************************************** - void Delete( - ULONG iHash, // Hash value of entry to delete. - ULONG iIndex); // Index of struct in m_pcEntries. - - void Delete( - ULONG iHash, // Hash value of entry to delete. - HASHENTRY *psEntry); // The struct to delete. - -//***************************************************************************** -// The item at the specified index has been moved, update the previous and -// next item. -//***************************************************************************** - void Move( - ULONG iHash, // Hash value for the item. - ULONG iNew); // New location. - -#endif // #ifndef DACCESS_COMPILE - -//***************************************************************************** -// Return a boolean indicating whether or not this hash table has been inited. -//***************************************************************************** - int IsInited() - { - LIMITED_METHOD_CONTRACT; - return (m_piBuckets != NULL); - } - -//***************************************************************************** -// Search the hash table for an entry with the specified key value. -//***************************************************************************** - BYTE *Find( // Index of struct in m_pcEntries. - ULONG iHash, // Hash value of the item. - SIZE_T key); // The key to match. - -//***************************************************************************** -// Search the hash table for the next entry with the specified key value. -//***************************************************************************** - ULONG FindNext( // Index of struct in m_pcEntries. - SIZE_T key, // The key to match. - ULONG iIndex); // Index of previous match. - -//***************************************************************************** -// Returns the first entry in the first hash bucket and inits the search -// struct. Use the FindNextEntry function to continue walking the list. The -// return order is not gauranteed. -//***************************************************************************** - BYTE *FindFirstEntry( // First entry found, or 0. - HASHFIND *psSrch) // Search object. - { - WRAPPER_NO_CONTRACT; - if (m_piBuckets == 0) - return (0); - psSrch->iBucket = 1; - psSrch->iNext = m_piBuckets[0]; - return (FindNextEntry(psSrch)); - } - -//***************************************************************************** -// Returns the next entry in the list. -//***************************************************************************** - BYTE *FindNextEntry( // The next entry, or0 for end of list. - HASHFIND *psSrch); // Search object. - -#ifdef DACCESS_COMPILE - void EnumMemoryRegions(CLRDataEnumMemoryFlags flags, - ULONG numEntries); -#endif - -protected: - virtual BOOL Cmp(SIZE_T key1, const HASHENTRY * pc2) = 0; -}; - - -class CNewData -{ -public: - static BYTE *Alloc(int iSize, int iMaxSize) - { - WRAPPER_NO_CONTRACT; - return (new BYTE[iSize]); - } - static void Free(BYTE *pPtr, int iSize) - { - LIMITED_METHOD_CONTRACT; - delete [] pPtr; - } - static BYTE *Grow(BYTE *&pPtr, int iCurSize) - { - WRAPPER_NO_CONTRACT; - BYTE *p; - S_SIZE_T newSize = S_SIZE_T(iCurSize) + S_SIZE_T(GrowSize(iCurSize)); - //check for overflow - if(newSize.IsOverflow()) - p = NULL; - else - p = new (nothrow) BYTE[newSize.Value()]; - if (p == 0) return (0); - memcpy (p, pPtr, iCurSize); - delete [] pPtr; - pPtr = p; - return pPtr; - } - static void Clean(BYTE * pData, int iSize) - { - } - static int RoundSize(int iSize) - { - LIMITED_METHOD_CONTRACT; - return (iSize); - } - static int GrowSize(int iCurSize) - { - LIMITED_METHOD_CONTRACT; - int newSize = (3 * iCurSize) / 2; - return (newSize < 256) ? 256 : newSize; - } -}; - -class CNewDataNoThrow -{ -public: - static BYTE *Alloc(int iSize, int iMaxSize) - { - WRAPPER_NO_CONTRACT; - return (new (nothrow) BYTE[iSize]); - } - static void Free(BYTE *pPtr, int iSize) - { - LIMITED_METHOD_CONTRACT; - delete [] pPtr; - } - static BYTE *Grow(BYTE *&pPtr, int iCurSize) - { - WRAPPER_NO_CONTRACT; - BYTE *p; - S_SIZE_T newSize = S_SIZE_T(iCurSize) + S_SIZE_T(GrowSize(iCurSize)); - //check for overflow - if(newSize.IsOverflow()) - p = NULL; - else - p = new (nothrow) BYTE[newSize.Value()]; - if (p == 0) return (0); - memcpy (p, pPtr, iCurSize); - delete [] pPtr; - pPtr = p; - return pPtr; - } - static void Clean(BYTE * pData, int iSize) - { - } - static int RoundSize(int iSize) - { - LIMITED_METHOD_CONTRACT; - return (iSize); - } - static int GrowSize(int iCurSize) - { - LIMITED_METHOD_CONTRACT; - int newSize = (3 * iCurSize) / 2; - return (newSize < 256) ? 256 : newSize; - } -}; - - -//***************************************************************************** -// IMPORTANT: This data structure is deprecated, please do not add any new uses. -// The hashtable implementation that should be used instead is code:SHash. -// If code:SHash does not work for you, talk to mailto:clrdeag. -//***************************************************************************** -// CHashTable expects the data to be in a single array - this is provided by -// CHashTableAndData. -// The array is allocated using the MemMgr type. CNewData and -// CNewDataNoThrow can be used for this. -//***************************************************************************** -template -class CHashTableAndData : public CHashTable -{ -public: - ULONG m_iFree; // Index into m_pcEntries[] of next available slot - ULONG m_iEntries; // size of m_pcEntries[] - -public: - - CHashTableAndData() : - CHashTable() - { - LIMITED_METHOD_CONTRACT; - } - - CHashTableAndData( - ULONG iBuckets) : // # of chains we are hashing into. - CHashTable(iBuckets) - { - LIMITED_METHOD_CONTRACT; - } - -#ifndef DACCESS_COMPILE - - ~CHashTableAndData() - { - WRAPPER_NO_CONTRACT; - if (m_pcEntries != NULL) - MemMgr::Free((BYTE*)m_pcEntries, MemMgr::RoundSize(m_iEntries * m_iEntrySize)); - } - -//***************************************************************************** -// This is the second part of construction where we do all of the work that -// can fail. We also take the array of structs here because the calling class -// presumably needs to allocate it in its NewInit. -//***************************************************************************** - HRESULT NewInit( // Return status. - ULONG iEntries, // # of entries. - ULONG iEntrySize, // Size of the entries. - int iMaxSize); // Max size of data. - -//***************************************************************************** -// Clear the hash table as if there were nothing in it. -//***************************************************************************** - void Clear() - { - WRAPPER_NO_CONTRACT; - m_iFree = 0; - InitFreeChain(0, m_iEntries); - CHashTable::Clear(); - } - -//***************************************************************************** -// Grabs a slot for the new entry to be added. -// The caller should fill in the non-HASHENTRY part of the returned slot -//***************************************************************************** - BYTE *Add( - ULONG iHash) // Hash value of entry to add. - { - WRAPPER_NO_CONTRACT; - FREEHASHENTRY *psEntry; - - // Make the table bigger if necessary. - if (m_iFree == UINT32_MAX && !Grow()) - return (NULL); - - // Add the first entry from the free list to the hash chain. - psEntry = (FREEHASHENTRY *) CHashTable::Add(iHash, m_iFree); - m_iFree = psEntry->iFree; - - // If we're recycling memory, give our memory-allocator a chance to re-init it. - - // Each entry is prefixed with a header - we don't want to trash that. - SIZE_T cbHeader = sizeof(FREEHASHENTRY); - MemMgr::Clean((BYTE*) psEntry + cbHeader, (int) (m_iEntrySize - cbHeader)); - - return ((BYTE *) psEntry); - } - -//***************************************************************************** -// Delete the struct at the specified index in m_pcEntries from the hash chains. -//***************************************************************************** - void Delete( - ULONG iHash, // Hash value of entry to delete. - ULONG iIndex) // Index of struct in m_pcEntries. - { - WRAPPER_NO_CONTRACT; - CHashTable::Delete(iHash, iIndex); - ((FREEHASHENTRY *) EntryPtr(iIndex))->iFree = m_iFree; - m_iFree = iIndex; - } - - void Delete( - ULONG iHash, // Hash value of entry to delete. - HASHENTRY *psEntry) // The struct to delete. - { - WRAPPER_NO_CONTRACT; - CHashTable::Delete(iHash, psEntry); - ((FREEHASHENTRY *) psEntry)->iFree = m_iFree; - m_iFree = ItemIndex(psEntry); - } - -#endif // #ifndef DACCESS_COMPILE - - // This is a sad legacy workaround. The debugger's patch table (implemented as this - // class) is shared across process. We publish the runtime offsets of - // some key fields. Since those fields are private, we have to provide - // accessors here. So if you're not using these functions, don't start. - // We can hopefully remove them. - // Note that we can't just make RCThread a friend of this class (we tried - // originally) because the inheritence chain has a private modifier, - // so DebuggerPatchTable::m_pcEntries is illegal. - static SIZE_T helper_GetOffsetOfEntries() - { - LIMITED_METHOD_CONTRACT; - return offsetof(CHashTableAndData, m_pcEntries); - } - - static SIZE_T helper_GetOffsetOfCount() - { - LIMITED_METHOD_CONTRACT; - return offsetof(CHashTableAndData, m_iEntries); - } - -#ifdef DACCESS_COMPILE - void EnumMemoryRegions(CLRDataEnumMemoryFlags flags) - { - SUPPORTS_DAC; - CHashTable::EnumMemoryRegions(flags, m_iEntries); - } -#endif - -private: - void InitFreeChain(ULONG iStart,ULONG iEnd); - int Grow(); -}; - -#ifndef DACCESS_COMPILE - -//***************************************************************************** -// This is the second part of construction where we do all of the work that -// can fail. We also take the array of structs here because the calling class -// presumably needs to allocate it in its NewInit. -//***************************************************************************** -template -HRESULT CHashTableAndData::NewInit(// Return status. - ULONG iEntries, // # of entries. - ULONG iEntrySize, // Size of the entries. - int iMaxSize) // Max size of data. -{ - WRAPPER_NO_CONTRACT; - BYTE *pcEntries; - HRESULT hr; - - - // note that this function can throw because it depends on the ::Alloc - - // Allocate the memory for the entries. - if ((pcEntries = MemMgr::Alloc(MemMgr::RoundSize(iEntries * iEntrySize), - MemMgr::RoundSize(iMaxSize))) == 0) - return (E_OUTOFMEMORY); - m_iEntries = iEntries; - - // Init the base table. - if (FAILED(hr = CHashTable::NewInit(pcEntries, iEntrySize))) - MemMgr::Free(pcEntries, MemMgr::RoundSize(iEntries * iEntrySize)); - else - { - // Init the free chain. - m_iFree = 0; - InitFreeChain(0, iEntries); - } - return (hr); -} - -//***************************************************************************** -// Initialize a range of records such that they are linked together to be put -// on the free chain. -//***************************************************************************** -template -void CHashTableAndData::InitFreeChain( - ULONG iStart, // Index to start initializing. - ULONG iEnd) // Index to stop initializing -{ - LIMITED_METHOD_CONTRACT; - BYTE* pcPtr; - _ASSERTE(iEnd > iStart); - - pcPtr = (BYTE*)m_pcEntries + iStart * m_iEntrySize; - for (++iStart; iStart < iEnd; ++iStart) - { - ((FREEHASHENTRY *) pcPtr)->iFree = iStart; - pcPtr += m_iEntrySize; - } - ((FREEHASHENTRY *) pcPtr)->iFree = UINT32_MAX; -} - -//***************************************************************************** -// Attempt to increase the amount of space available for the record heap. -//***************************************************************************** -template -int CHashTableAndData::Grow() // 1 if successful, 0 if not. -{ - WRAPPER_NO_CONTRACT; - int iCurSize; // Current size in bytes. - int iEntries; // New # of entries. - - _ASSERTE(m_pcEntries != NULL); - _ASSERTE(m_iFree == UINT32_MAX); - - // Compute the current size and new # of entries. - S_UINT32 iTotEntrySize = S_UINT32(m_iEntries) * S_UINT32(m_iEntrySize); - if( iTotEntrySize.IsOverflow() ) - { - _ASSERTE( !"CHashTableAndData overflow!" ); - return (0); - } - iCurSize = MemMgr::RoundSize( iTotEntrySize.Value() ); - iEntries = (iCurSize + MemMgr::GrowSize(iCurSize)) / m_iEntrySize; - - if ( (iEntries < 0) || ((ULONG)iEntries <= m_iEntries) ) - { - _ASSERTE( !"CHashTableAndData overflow!" ); - return (0); - } - - // Try to expand the array. - if (MemMgr::Grow(*(BYTE**)&m_pcEntries, iCurSize) == 0) - return (0); - - // Init the newly allocated space. - InitFreeChain(m_iEntries, iEntries); - m_iFree = m_iEntries; - m_iEntries = iEntries; - return (1); -} - -#endif // #ifndef DACCESS_COMPILE - -//***************************************************************************** -//***************************************************************************** - -inline COUNT_T HashCOUNT_T(COUNT_T currentHash, COUNT_T data) -{ - LIMITED_METHOD_DAC_CONTRACT; - return ((currentHash << 5) + currentHash) ^ data; -} - -inline COUNT_T HashPtr(COUNT_T currentHash, PTR_VOID ptr) -{ - WRAPPER_NO_CONTRACT; - SUPPORTS_DAC; - return HashCOUNT_T(currentHash, COUNT_T(SIZE_T(dac_cast(ptr)))); -} - -inline DWORD HashThreeToOne(DWORD a, DWORD b, DWORD c) -{ - LIMITED_METHOD_DAC_CONTRACT; - - /* - 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); - b ^= a; b -= rot32(a,25); - c ^= b; c -= rot32(b,16); - a ^= c; a -= rot32(c,4); - b ^= a; b -= rot32(a,14); - c ^= b; c -= rot32(b,24); - - return c; -} - -inline ULONG HashBytes(BYTE const *pbData, size_t iSize) -{ - LIMITED_METHOD_CONTRACT; - ULONG hash = 5381; - - BYTE const *pbDataEnd = pbData + iSize; - - for (/**/ ; pbData < pbDataEnd; pbData++) - { - hash = ((hash << 5) + hash) ^ *pbData; - } - return hash; -} - -// Helper function for hashing a string char by char. -inline ULONG HashStringA(LPCSTR szStr) -{ - LIMITED_METHOD_CONTRACT; - ULONG hash = 5381; - int c; - - while ((c = *szStr) != 0) - { - hash = ((hash << 5) + hash) ^ c; - ++szStr; - } - return hash; -} - -inline ULONG HashString(LPCWSTR szStr) -{ - LIMITED_METHOD_CONTRACT; - ULONG hash = 5381; - int c; - - while ((c = *szStr) != 0) - { - hash = ((hash << 5) + hash) ^ c; - ++szStr; - } - return hash; -} - -inline ULONG HashStringN(LPCWSTR szStr, SIZE_T cchStr) -{ - LIMITED_METHOD_CONTRACT; - ULONG hash = 5381; - - // hash the string two characters at a time - ULONG *ptr = (ULONG *)szStr; - - // we assume that szStr is null-terminated - _ASSERTE(cchStr <= wcslen(szStr)); - SIZE_T cDwordCount = (cchStr + 1) / 2; - - for (SIZE_T i = 0; i < cDwordCount; i++) - { - hash = ((hash << 5) + hash) ^ ptr[i]; - } - - return hash; -} - -// Case-insensitive string hash function. -inline ULONG HashiStringA(LPCSTR szStr) -{ - LIMITED_METHOD_CONTRACT; - ULONG hash = 5381; - while (*szStr != 0) - { - hash = ((hash << 5) + hash) ^ toupper(*szStr); - szStr++; - } - return hash; -} - -// Case-insensitive string hash function. -inline ULONG HashiString(LPCWSTR szStr) -{ - LIMITED_METHOD_CONTRACT; - ULONG hash = 5381; - while (*szStr != 0) - { - hash = ((hash << 5) + hash) ^ towupper(*szStr); - szStr++; - } - return hash; -} - -// Case-insensitive string hash function. -inline ULONG HashiStringN(LPCWSTR szStr, DWORD count) -{ - LIMITED_METHOD_CONTRACT; - ULONG hash = 5381; - while (*szStr != 0 && count--) - { - hash = ((hash << 5) + hash) ^ towupper(*szStr); - szStr++; - } - return hash; -} - -// Case-insensitive string hash function when all of the -// characters in the string are known to be below 0x80. -// Knowing this is much more efficient than calling -// towupper above. -inline ULONG HashiStringKnownLower80(LPCWSTR szStr) { - LIMITED_METHOD_CONTRACT; - ULONG hash = 5381; - int c; - int mask = ~0x20; - while ((c = *szStr)!=0) { - //If we have a lowercase character, ANDing off 0x20 - //(mask) will make it an uppercase character. - if (c>='a' && c<='z') { - c&=mask; - } - hash = ((hash << 5) + hash) ^ c; - ++szStr; - } - return hash; -} - -inline ULONG HashiStringNKnownLower80(LPCWSTR szStr, DWORD count) { - LIMITED_METHOD_CONTRACT; - ULONG hash = 5381; - int c; - int mask = ~0x20; - while ((c = *szStr) !=0 && count--) { - //If we have a lowercase character, ANDing off 0x20 - //(mask) will make it an uppercase character. - if (c>='a' && c<='z') { - c&=mask; - } - hash = ((hash << 5) + hash) ^ c; - ++szStr; - } - return hash; -} - -//***************************************************************************** -// IMPORTANT: This data structure is deprecated, please do not add any new uses. -// The hashtable implementation that should be used instead is code:SHash. -// If code:SHash does not work for you, talk to mailto:clrdeag. -//***************************************************************************** -// This class implements a closed hashing table. Values are hashed to a bucket, -// and if that bucket is full already, then the value is placed in the next -// free bucket starting after the desired target (with wrap around). If the -// table becomes 75% full, it is grown and rehashed to reduce lookups. This -// class is best used in a reltively small lookup table where hashing is -// not going to cause many collisions. By not having the collision chain -// logic, a lot of memory is saved. -// -// The user of the template is required to supply several methods which decide -// how each element can be marked as free, deleted, or used. It would have -// been possible to write this with more internal logic, but that would require -// either (a) more overhead to add status on top of elements, or (b) hard -// coded types like one for strings, one for ints, etc... This gives you the -// flexibility of adding logic to your type. -//***************************************************************************** -class CClosedHashBase -{ - BYTE *EntryPtr(int iEntry) - { - LIMITED_METHOD_CONTRACT; - return (m_rgData + (iEntry * m_iEntrySize)); - } - - BYTE *EntryPtr(int iEntry, BYTE *rgData) - { - LIMITED_METHOD_CONTRACT; - return (rgData + (iEntry * m_iEntrySize)); - } - -public: - enum ELEMENTSTATUS - { - FREE, // Item is not in use right now. - DELETED, // Item is deleted. - USED // Item is in use. - }; - - CClosedHashBase( - int iBuckets, // How many buckets should we start with. - int iEntrySize, // Size of an entry. - bool bPerfect) : // true if bucket size will hash with no collisions. - m_bPerfect(bPerfect), - m_iBuckets(iBuckets), - m_iEntrySize(iEntrySize), - m_iCount(0), - m_iCollisions(0), - m_rgData(0) - { - LIMITED_METHOD_CONTRACT; - m_iSize = iBuckets + 7; - } - - virtual ~CClosedHashBase() - { - WRAPPER_NO_CONTRACT; - Clear(); - } - - virtual void Clear() - { - LIMITED_METHOD_CONTRACT; - delete [] m_rgData; - m_iCount = 0; - m_iCollisions = 0; - m_rgData = 0; - } - -//***************************************************************************** -// Accessors for getting at the underlying data. Be careful to use Count() -// only when you want the number of buckets actually used. -//***************************************************************************** - - int Count() - { - LIMITED_METHOD_CONTRACT; - return (m_iCount); - } - - int Collisions() - { - LIMITED_METHOD_CONTRACT; - return (m_iCollisions); - } - - int Buckets() - { - LIMITED_METHOD_CONTRACT; - return (m_iBuckets); - } - - void SetBuckets(int iBuckets, bool bPerfect=false) - { - LIMITED_METHOD_CONTRACT; - _ASSERTE(m_rgData == 0); - m_iBuckets = iBuckets; - m_iSize = m_iBuckets + 7; - m_bPerfect = bPerfect; - } - - BYTE *Data() - { - LIMITED_METHOD_CONTRACT; - return (m_rgData); - } - -//***************************************************************************** -// Add a new item to hash table given the key value. If this new entry -// exceeds maximum size, then the table will grow and be re-hashed, which -// may cause a memory error. -//***************************************************************************** - BYTE *Add( // New item to fill out on success. - void *pData) // The value to hash on. - { - WRAPPER_NO_CONTRACT; - // If we haven't allocated any memory, or it is too small, fix it. - if (!m_rgData || ((m_iCount + 1) > (m_iSize * 3 / 4) && !m_bPerfect)) - { - if (!ReHash()) - return (0); - } - - return (DoAdd(pData, m_rgData, m_iBuckets, m_iSize, m_iCollisions, m_iCount)); - } - -//***************************************************************************** -// Delete the given value. This will simply mark the entry as deleted (in -// order to keep the collision chain intact). There is an optimization that -// consecutive deleted entries leading up to a free entry are themselves freed -// to reduce collisions later on. -//***************************************************************************** - void Delete( - void *pData); // Key value to delete. - - -//***************************************************************************** -// Callback function passed to DeleteLoop. -//***************************************************************************** - typedef BOOL (* DELETELOOPFUNC)( // Delete current item? - BYTE *pEntry, // Bucket entry to evaluate - void *pCustomizer); // User-defined value - -//***************************************************************************** -// Iterates over all active values, passing each one to pDeleteLoopFunc. -// If pDeleteLoopFunc returns TRUE, the entry is deleted. This is safer -// and faster than using FindNext() and Delete(). -//***************************************************************************** - void DeleteLoop( - DELETELOOPFUNC pDeleteLoopFunc, // Decides whether to delete item - void *pCustomizer); // Extra value passed to deletefunc. - - -//***************************************************************************** -// Lookup a key value and return a pointer to the element if found. -//***************************************************************************** - BYTE *Find( // The item if found, 0 if not. - void *pData); // The key to lookup. - -//***************************************************************************** -// Look for an item in the table. If it isn't found, then create a new one and -// return that. -//***************************************************************************** - BYTE *FindOrAdd( // The item if found, 0 if not. - void *pData, // The key to lookup. - bool &bNew); // true if created. - -//***************************************************************************** -// The following functions are used to traverse each used entry. This code -// will skip over deleted and free entries freeing the caller up from such -// logic. -//***************************************************************************** - BYTE *GetFirst() // The first entry, 0 if none. - { - WRAPPER_NO_CONTRACT; - int i; // Loop control. - - // If we've never allocated the table there can't be any to get. - if (m_rgData == 0) - return (0); - - // Find the first one. - for (i=0; i class CClosedHash : public CClosedHashBase -{ -public: - CClosedHash( - int iBuckets, // How many buckets should we start with. - bool bPerfect=false) : // true if bucket size will hash with no collisions. - CClosedHashBase(iBuckets, sizeof(T), bPerfect) - { - WRAPPER_NO_CONTRACT; - } - - T &operator[](int iIndex) - { - WRAPPER_NO_CONTRACT; - return ((T &) *(Data() + (iIndex * sizeof(T)))); - } - - -//***************************************************************************** -// Add a new item to hash table given the key value. If this new entry -// exceeds maximum size, then the table will grow and be re-hashed, which -// may cause a memory error. -//***************************************************************************** - T *Add( // New item to fill out on success. - void *pData) // The value to hash on. - { - WRAPPER_NO_CONTRACT; - return ((T *) CClosedHashBase::Add(pData)); - } - -//***************************************************************************** -// Lookup a key value and return a pointer to the element if found. -//***************************************************************************** - T *Find( // The item if found, 0 if not. - void *pData) // The key to lookup. - { - WRAPPER_NO_CONTRACT; - return ((T *) CClosedHashBase::Find(pData)); - } - -//***************************************************************************** -// Look for an item in the table. If it isn't found, then create a new one and -// return that. -//***************************************************************************** - T *FindOrAdd( // The item if found, 0 if not. - void *pData, // The key to lookup. - bool &bNew) // true if created. - { - WRAPPER_NO_CONTRACT; - return ((T *) CClosedHashBase::FindOrAdd(pData, bNew)); - } - - -//***************************************************************************** -// The following functions are used to traverse each used entry. This code -// will skip over deleted and free entries freeing the caller up from such -// logic. -//***************************************************************************** - T *GetFirst() // The first entry, 0 if none. - { - WRAPPER_NO_CONTRACT; - return ((T *) CClosedHashBase::GetFirst()); - } - - T *GetNext(T *Prev) // The next entry, 0 if done. - { - WRAPPER_NO_CONTRACT; - return ((T *) CClosedHashBase::GetNext((BYTE *) Prev)); - } -}; - - -//***************************************************************************** -// IMPORTANT: This data structure is deprecated, please do not add any new uses. -// The hashtable implementation that should be used instead is code:SHash. -// If code:SHash does not work for you, talk to mailto:clrdeag. -//***************************************************************************** -// Closed hash with typed parameters. The derived class is the second -// parameter to the template. The derived class must implement: -// unsigned long Hash(const T *pData); -// unsigned long Compare(const T *p1, T *p2); -// ELEMENTSTATUS Status(T *pEntry); -// void SetStatus(T *pEntry, ELEMENTSTATUS s); -// void* GetKey(T *pEntry); -//***************************************************************************** -templateclass CClosedHashEx : public CClosedHash -{ -public: - CClosedHashEx( - int iBuckets, // How many buckets should we start with. - bool bPerfect=false) : // true if bucket size will hash with no collisions. - CClosedHash (iBuckets, bPerfect) - { - WRAPPER_NO_CONTRACT; - } - - unsigned int Hash(const void *pData) - { - WRAPPER_NO_CONTRACT; - return static_cast(this)->Hash((const T*)pData); - } - - unsigned int Compare(const void *p1, BYTE *p2) - { - WRAPPER_NO_CONTRACT; - return static_cast(this)->Compare((const T*)p1, (T*)p2); - } - - typename CClosedHash::ELEMENTSTATUS Status(BYTE *p) - { - WRAPPER_NO_CONTRACT; - return static_cast(this)->Status((T*)p); - } - - void SetStatus(BYTE *p, typename CClosedHash::ELEMENTSTATUS s) - { - WRAPPER_NO_CONTRACT; - static_cast(this)->SetStatus((T*)p, s); - } - - void* GetKey(BYTE *p) - { - WRAPPER_NO_CONTRACT; - return static_cast(this)->GetKey((T*)p); - } -}; - - -//***************************************************************************** -// IMPORTANT: This data structure is deprecated, please do not add any new uses. -// The hashtable implementation that should be used instead is code:SHash. -// If code:SHash does not work for you, talk to mailto:clrdeag. -//***************************************************************************** -// This template is another form of a closed hash table. It handles collisions -// through a linked chain. To use it, derive your hashed item from HASHLINK -// and implement the virtual functions required. 1.5 * ibuckets will be -// allocated, with the extra .5 used for collisions. If you add to the point -// where no free nodes are available, the entire table is grown to make room. -// The advantage to this system is that collisions are always directly known, -// there either is one or there isn't. -//***************************************************************************** -struct HASHLINK -{ - ULONG iNext; // Offset for next entry. -}; - -template class CChainedHash -{ - friend class VerifyLayoutsMD; -public: - CChainedHash(int iBuckets=32) : - m_rgData(0), - m_iBuckets(iBuckets), - m_iCount(0), - m_iMaxChain(0), - m_iFree(0) - { - LIMITED_METHOD_CONTRACT; - m_iSize = iBuckets + (iBuckets / 2); - } - - ~CChainedHash() - { - LIMITED_METHOD_CONTRACT; - if (m_rgData) - delete [] m_rgData; - } - - void SetBuckets(int iBuckets) - { - LIMITED_METHOD_CONTRACT; - _ASSERTE(m_rgData == 0); - // if iBuckets==0, then we'll allocate a zero size array and AV on dereference. - _ASSERTE(iBuckets > 0); - m_iBuckets = iBuckets; - m_iSize = iBuckets + (iBuckets / 2); - } - - T *Add(void const *pData) - { - WRAPPER_NO_CONTRACT; - ULONG iHash; - int iBucket; - T *pItem; - - // Build the list if required. - if (m_rgData == 0 || m_iFree == 0xffffffff) - { - if (!ReHash()) - return (0); - } - - // Hash the item and pick a bucket. - iHash = Hash(pData); - iBucket = iHash % m_iBuckets; - - // Use the bucket if it is free. - if (InUse(&m_rgData[iBucket]) == false) - { - pItem = &m_rgData[iBucket]; - pItem->iNext = 0xffffffff; - } - // Else take one off of the free list for use. - else - { - ULONG iEntry; - - // Pull an item from the free list. - iEntry = m_iFree; - pItem = &m_rgData[m_iFree]; - m_iFree = pItem->iNext; - - // Link the new node in after the bucket. - pItem->iNext = m_rgData[iBucket].iNext; - m_rgData[iBucket].iNext = iEntry; - } - ++m_iCount; - return (pItem); - } - - T *Find(void const *pData, bool bAddIfNew=false) - { - WRAPPER_NO_CONTRACT; - ULONG iHash; - int iBucket; - T *pItem; - - // Check states for lookup. - if (m_rgData == 0) - { - // If we won't be adding, then we are through. - if (bAddIfNew == false) - return (0); - - // Otherwise, create the table. - if (!ReHash()) - return (0); - } - - // Hash the item and pick a bucket. - iHash = Hash(pData); - iBucket = iHash % m_iBuckets; - - // If it isn't in use, then there it wasn't found. - if (!InUse(&m_rgData[iBucket])) - { - if (bAddIfNew == false) - pItem = 0; - else - { - pItem = &m_rgData[iBucket]; - pItem->iNext = 0xffffffff; - ++m_iCount; - } - } - // Scan the list for the one we want. - else - { - ULONG iChain = 0; - for (pItem=(T *) &m_rgData[iBucket]; pItem; pItem=GetNext(pItem)) - { - if (Cmp(pData, pItem) == 0) - break; - ++iChain; - } - - if (!pItem && bAddIfNew) - { - ULONG iEntry; - - // Record maximum chain length. - if (iChain > m_iMaxChain) - m_iMaxChain = iChain; - - // Now need more room. - if (m_iFree == 0xffffffff) - { - if (!ReHash()) - return (0); - } - - // Pull an item from the free list. - iEntry = m_iFree; - pItem = &m_rgData[m_iFree]; - m_iFree = pItem->iNext; - - // Link the new node in after the bucket. - pItem->iNext = m_rgData[iBucket].iNext; - m_rgData[iBucket].iNext = iEntry; - ++m_iCount; - } - } - return (pItem); - } - - int Count() - { - LIMITED_METHOD_CONTRACT; - return (m_iCount); - } - - int Buckets() - { - LIMITED_METHOD_CONTRACT; - return (m_iBuckets); - } - - ULONG MaxChainLength() - { - LIMITED_METHOD_CONTRACT; - return (m_iMaxChain); - } - - virtual void Clear() - { - LIMITED_METHOD_CONTRACT; - // Free up the memory. - if (m_rgData) - { - delete [] m_rgData; - m_rgData = 0; - } - - m_rgData = 0; - m_iFree = 0; - m_iCount = 0; - m_iMaxChain = 0; - } - - virtual bool InUse(T *pItem)=0; - virtual void SetFree(T *pItem)=0; - virtual ULONG Hash(void const *pData)=0; - virtual int Cmp(void const *pData, void *pItem)=0; -private: - inline T *GetNext(T *pItem) - { - LIMITED_METHOD_CONTRACT; - if (pItem->iNext != 0xffffffff) - return ((T *) &m_rgData[pItem->iNext]); - return (0); - } - - bool ReHash() - { - WRAPPER_NO_CONTRACT; - T *rgTemp; - int iNewSize; - - // If this is a first time allocation, then just malloc it. - if (!m_rgData) - { - if ((m_rgData = new (nothrow) T[m_iSize]) == 0) - return (false); - - int i; - for (i=0; iiNext = i + 1; - ((T *) &m_rgData[m_iSize - 1])->iNext = 0xffffffff; - return (true); - } - - // Otherwise we need more room on the free chain, so allocate some. - iNewSize = m_iSize + (m_iSize / 2); - - // Allocate/realloc memory. - if ((rgTemp = new (nothrow) T[iNewSize]) == 0) - return (false); - - memcpy (rgTemp,m_rgData,m_iSize*sizeof(T)); - delete [] m_rgData; - - // Init new entries, save the new free chain, and reset internals. - m_iFree = m_iSize; - for (int i=m_iFree; iiNext = i + 1; - } - ((T *) &rgTemp[iNewSize - 1])->iNext = 0xffffffff; - - m_rgData = rgTemp; - m_iSize = iNewSize; - return (true); - } - -private: - T *m_rgData; // Data to store items in. - int m_iBuckets; // How many buckets we want. - int m_iSize; // How many are allocated. - int m_iCount; // How many are we using. - ULONG m_iMaxChain; // Max chain length. - ULONG m_iFree; // Free chain. -}; - - -//***************************************************************************** -// -//********** String helper functions. -// -//***************************************************************************** - -//***************************************************************************** -// Checks if string length exceeds the specified limit -//***************************************************************************** -inline BOOL IsStrLongerThan(__in __in_z char* pstr, unsigned N) -{ - LIMITED_METHOD_CONTRACT; - unsigned i = 0; - if(pstr) - { - for(i=0; (i < N)&&(pstr[i]); i++); - } - return (i >= N); -} - - -//***************************************************************************** -// Class to parse a list of simple assembly names and then find a match -//***************************************************************************** - -class AssemblyNamesList -{ - struct AssemblyName - { - LPUTF8 m_assemblyName; - AssemblyName *m_next; // Next name - }; - - AssemblyName *m_pNames; // List of names - -public: - - bool IsInList(LPCUTF8 assemblyName); - - bool IsEmpty() - { - LIMITED_METHOD_CONTRACT; - return m_pNames == 0; - } - - AssemblyNamesList(__in LPWSTR list); - ~AssemblyNamesList(); -}; - -//***************************************************************************** -// Class to parse a list of method names and then find a match -//***************************************************************************** - -struct CORINFO_SIG_INFO; - -class MethodNamesListBase -{ - struct MethodName - { - LPUTF8 methodName; // NULL means wildcard - LPUTF8 className; // NULL means wildcard - int numArgs; // number of args for the method, -1 is wildcard - MethodName *next; // Next name - }; - - MethodName *pNames; // List of names - - bool IsInList(LPCUTF8 methodName, LPCUTF8 className, int numArgs); - -public: - void Init() - { - LIMITED_METHOD_CONTRACT; - pNames = 0; - } - - void Init(__in __in_z LPWSTR list) - { - WRAPPER_NO_CONTRACT; - pNames = 0; - Insert(list); - } - - void Destroy(); - - void Insert(__in __in_z LPWSTR list); - - bool IsInList(LPCUTF8 methodName, LPCUTF8 className, PCCOR_SIGNATURE sig = NULL); - bool IsInList(LPCUTF8 methodName, LPCUTF8 className, CORINFO_SIG_INFO* pSigInfo); - bool IsEmpty() - { - LIMITED_METHOD_CONTRACT; - return pNames == 0; - } -}; - -class MethodNamesList : public MethodNamesListBase -{ -public: - MethodNamesList() - { - WRAPPER_NO_CONTRACT; - Init(); - } - - MethodNamesList(__in LPWSTR list) - { - WRAPPER_NO_CONTRACT; - Init(list); - } - - ~MethodNamesList() - { - WRAPPER_NO_CONTRACT; - Destroy(); - } -}; - -#if !defined(NO_CLRCONFIG) - -/**************************************************************************/ -/* simple wrappers around the REGUTIL and MethodNameList routines that make - the lookup lazy */ - -/* to be used as static variable - no constructor/destructor, assumes zero - initialized memory */ - -class ConfigDWORD -{ -public: - // - // NOTE: The following function is deprecated; use the CLRConfig class instead. - // To access a configuration value through CLRConfig, add an entry in file:../inc/CLRConfigValues.h. - // - inline DWORD val_DontUse_(__in __in_z LPCWSTR keyName, DWORD defaultVal=0) - { - WRAPPER_NO_CONTRACT; - // make sure that the memory was zero initialized - _ASSERTE(m_inited == 0 || m_inited == 1); - - if (!m_inited) init_DontUse_(keyName, defaultVal); - return m_value; - } - inline DWORD val(const CLRConfig::ConfigDWORDInfo & info) - { - WRAPPER_NO_CONTRACT; - // make sure that the memory was zero initialized - _ASSERTE(m_inited == 0 || m_inited == 1); - - if (!m_inited) init(info); - return m_value; - } - -private: - void init_DontUse_(__in __in_z LPCWSTR keyName, DWORD defaultVal=0); - void init(const CLRConfig::ConfigDWORDInfo & info); - -private: - DWORD m_value; - BYTE m_inited; -}; - -/**************************************************************************/ -class ConfigString -{ -public: - inline LPWSTR val(const CLRConfig::ConfigStringInfo & info) - { - WRAPPER_NO_CONTRACT; - // make sure that the memory was zero initialized - _ASSERTE(m_inited == 0 || m_inited == 1); - - if (!m_inited) init(info); - return m_value; - } - - bool isInitialized() - { - WRAPPER_NO_CONTRACT; - - // make sure that the memory was zero initialized - _ASSERTE(m_inited == 0 || m_inited == 1); - - return m_inited == 1; - } - -private: - void init(const CLRConfig::ConfigStringInfo & info); - -private: - LPWSTR m_value; - BYTE m_inited; -}; - -/**************************************************************************/ -class ConfigMethodSet -{ -public: - bool isEmpty() - { - WRAPPER_NO_CONTRACT; - _ASSERTE(m_inited == 1); - return m_list.IsEmpty(); - } - - bool contains(LPCUTF8 methodName, LPCUTF8 className, PCCOR_SIGNATURE sig = NULL); - bool contains(LPCUTF8 methodName, LPCUTF8 className, CORINFO_SIG_INFO* pSigInfo); - - inline void ensureInit(const CLRConfig::ConfigStringInfo & info) - { - WRAPPER_NO_CONTRACT; - // make sure that the memory was zero initialized - _ASSERTE(m_inited == 0 || m_inited == 1); - - if (!m_inited) init(info); - } - -private: - void init(const CLRConfig::ConfigStringInfo & info); - -private: - MethodNamesListBase m_list; - - BYTE m_inited; -}; - -#endif // !defined(NO_CLRCONFIG) - -//***************************************************************************** -// Convert a pointer to a string into a GUID. -//***************************************************************************** -HRESULT LPCSTRToGuid( // Return status. - LPCSTR szGuid, // String to convert. - GUID *psGuid); // Buffer for converted GUID. - -//***************************************************************************** -// Convert a GUID into a pointer to a string -//***************************************************************************** -int GuidToLPWSTR( // Return status. - GUID Guid, // [IN] The GUID to convert. - __out_ecount (cchGuid) LPWSTR szGuid, // [OUT] String into which the GUID is stored - DWORD cchGuid); // [IN] Size in wide chars of szGuid - -//***************************************************************************** -// Parse a Wide char string into a GUID -//***************************************************************************** -BOOL LPWSTRToGuid( - GUID * Guid, // [OUT] The GUID to fill in - __in_ecount(cchGuid) LPCWSTR szGuid, // [IN] String to parse - DWORD cchGuid); // [IN] Count in wchars in string - -typedef VPTR(class RangeList) PTR_RangeList; - -class RangeList -{ - public: - VPTR_BASE_CONCRETE_VTABLE_CLASS(RangeList) - -#ifndef DACCESS_COMPILE - RangeList(); - ~RangeList(); -#else - RangeList() - { - LIMITED_METHOD_CONTRACT; - } -#endif - - // Wrappers to make the virtual calls DAC-safe. - BOOL AddRange(const BYTE *start, const BYTE *end, void *id) - { - return this->AddRangeWorker(start, end, id); - } - - void RemoveRanges(void *id, const BYTE *start = NULL, const BYTE *end = NULL) - { - return this->RemoveRangesWorker(id, start, end); - } - - BOOL IsInRange(TADDR address, TADDR *pID = NULL) - { - SUPPORTS_DAC; - - return this->IsInRangeWorker(address, pID); - } - -#ifndef DACCESS_COMPILE - - // You can overload these two for synchronization (as LockedRangeList does) - virtual BOOL AddRangeWorker(const BYTE *start, const BYTE *end, void *id); - // If both "start" and "end" are NULL, then this method deletes all ranges with - // the given id (i.e. the original behaviour). Otherwise, it ignores the given - // id and deletes all ranges falling in the region [start, end). - virtual void RemoveRangesWorker(void *id, const BYTE *start = NULL, const BYTE *end = NULL); -#else - virtual BOOL AddRangeWorker(const BYTE *start, const BYTE *end, void *id) - { - return TRUE; - } - virtual void RemoveRangesWorker(void *id, const BYTE *start = NULL, const BYTE *end = NULL) { } -#endif // !DACCESS_COMPILE - - virtual BOOL IsInRangeWorker(TADDR address, TADDR *pID = NULL); - -#ifdef DACCESS_COMPILE - void EnumMemoryRegions(enum CLRDataEnumMemoryFlags flags); -#endif - - enum - { - RANGE_COUNT = 10 - }; - - - private: - struct Range - { - TADDR start; - TADDR end; - TADDR id; - }; - - struct RangeListBlock - { - Range ranges[RANGE_COUNT]; - DPTR(RangeListBlock) next; - -#ifdef DACCESS_COMPILE - void EnumMemoryRegions(enum CLRDataEnumMemoryFlags flags); -#endif - - }; - - void InitBlock(RangeListBlock *block); - - RangeListBlock m_starterBlock; - DPTR(RangeListBlock) m_firstEmptyBlock; - TADDR m_firstEmptyRange; -}; - - -// -// A private function to do the equavilent of a CoCreateInstance in -// cases where we can't make the real call. Use this when, for -// instance, you need to create a symbol reader in the Runtime but -// we're not CoInitialized. Obviously, this is only good for COM -// objects for which CoCreateInstance is just a glorified -// find-and-load-me operation. -// - -HRESULT FakeCoCreateInstanceEx(REFCLSID rclsid, - LPCWSTR wszDllPath, - REFIID riid, - void ** ppv, - HMODULE * phmodDll); - -// Provided for backward compatibility and for code that doesn't need the HMODULE of the -// DLL that was loaded to create the COM object. See comment at implementation of -// code:FakeCoCreateInstanceEx for more details. -inline HRESULT FakeCoCreateInstance(REFCLSID rclsid, - REFIID riid, - void ** ppv) -{ - CONTRACTL - { - NOTHROW; - } - CONTRACTL_END; - - return FakeCoCreateInstanceEx(rclsid, NULL, riid, ppv, NULL); -}; - -HRESULT FakeCoCallDllGetClassObject(REFCLSID rclsid, - LPCWSTR wszDllPath, - REFIID riid, - void ** ppv, - HMODULE * phmodDll); - -//***************************************************************************** -// Gets the directory based on the location of the module. This routine -// is called at COR setup time. Set is called during EEStartup and by the -// MetaData dispenser. -//***************************************************************************** -HRESULT GetInternalSystemDirectory(__out_ecount_part_opt(*pdwLength,*pdwLength) LPWSTR buffer, __inout DWORD* pdwLength); -LPCWSTR GetInternalSystemDirectory(__out_opt DWORD * pdwLength = NULL); - -//***************************************************************************** -// This function validates the given Method/Field/Standalone signature. (util.cpp) -//***************************************************************************** -struct IMDInternalImport; -HRESULT validateTokenSig( - mdToken tk, // [IN] Token whose signature needs to be validated. - PCCOR_SIGNATURE pbSig, // [IN] Signature. - ULONG cbSig, // [IN] Size in bytes of the signature. - DWORD dwFlags, // [IN] Method flags. - IMDInternalImport* pImport); // [IN] Internal MD Import interface ptr - -//***************************************************************************** -// Determine the version number of the runtime that was used to build the -// specified image. The pMetadata pointer passed in is the pointer to the -// metadata contained in the image. -//***************************************************************************** -HRESULT GetImageRuntimeVersionString(PVOID pMetaData, LPCSTR* pString); -void AdjustImageRuntimeVersion (SString* pVersion); - -//***************************************************************************** -// The registry keys and values that contain the information regarding -// the default registered unmanaged debugger. -//***************************************************************************** -SELECTANY const WCHAR kDebugApplicationsPoliciesKey[] = W("SOFTWARE\\Policies\\Microsoft\\Windows\\Windows Error Reporting\\DebugApplications"); -SELECTANY const WCHAR kDebugApplicationsKey[] = W("SOFTWARE\\Microsoft\\Windows\\Windows Error Reporting\\DebugApplications"); - -SELECTANY const WCHAR kUnmanagedDebuggerKey[] = W("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AeDebug"); -SELECTANY const WCHAR kUnmanagedDebuggerValue[] = W("Debugger"); -SELECTANY const WCHAR kUnmanagedDebuggerAutoValue[] = W("Auto"); -SELECTANY const WCHAR kUnmanagedDebuggerAutoExclusionListKey[] = W("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AeDebug\\AutoExclusionList"); - -BOOL GetRegistryLongValue(HKEY hKeyParent, // Parent key. - LPCWSTR szKey, // Key name to look at. - LPCWSTR szName, // Name of value to get. - long *pValue, // Put value here, if found. - BOOL fReadNonVirtualizedKey); // Whether to read 64-bit hive on WOW64 - -HRESULT GetCurrentModuleFileName(SString& pBuffer); - -//***************************************************************************** -// Retrieve information regarding what registered default debugger -//***************************************************************************** -void GetDebuggerSettingInfo(SString &debuggerKeyValue, BOOL *pfAuto); -HRESULT GetDebuggerSettingInfoWorker(__out_ecount_part_opt(*pcchDebuggerString, *pcchDebuggerString) LPWSTR wszDebuggerString, DWORD * pcchDebuggerString, BOOL * pfAuto); - -void TrimWhiteSpace(__inout_ecount(*pcch) LPCWSTR *pwsz, __inout LPDWORD pcch); - - -//***************************************************************************** -// Convert a UTF8 string to Unicode, into a CQuickArray. -//***************************************************************************** -HRESULT Utf2Quick( - LPCUTF8 pStr, // The string to convert. - CQuickArray &rStr, // The QuickArray to convert it into. - int iCurLen); // Inital characters in the array to leave (default 0). - -//***************************************************************************** -// Extract the movl 64-bit unsigned immediate from an IA64 bundle -// (Format X2) -//***************************************************************************** -UINT64 GetIA64Imm64(UINT64 * pBundle); -UINT64 GetIA64Imm64(UINT64 qword0, UINT64 qword1); - -//***************************************************************************** -// Deposit the movl 64-bit unsigned immediate into an IA64 bundle -// (Format X2) -//***************************************************************************** -void PutIA64Imm64(UINT64 * pBundle, UINT64 imm64); - -//***************************************************************************** -// Extract the IP-Relative signed 25-bit immediate from an IA64 bundle -// (Formats B1, B2 or B3) -// Note that due to branch target alignment requirements -// the lowest four bits in the result will always be zero. -//***************************************************************************** -INT32 GetIA64Rel25(UINT64 * pBundle, UINT32 slot); -INT32 GetIA64Rel25(UINT64 qword0, UINT64 qword1, UINT32 slot); - -//***************************************************************************** -// Deposit the IP-Relative signed 25-bit immediate into an IA64 bundle -// (Formats B1, B2 or B3) -// Note that due to branch target alignment requirements -// the lowest four bits are required to be zero. -//***************************************************************************** -void PutIA64Rel25(UINT64 * pBundle, UINT32 slot, INT32 imm25); - -//***************************************************************************** -// Extract the IP-Relative signed 64-bit immediate from an IA64 bundle -// (Formats X3 or X4) -//***************************************************************************** -INT64 GetIA64Rel64(UINT64 * pBundle); -INT64 GetIA64Rel64(UINT64 qword0, UINT64 qword1); - -//***************************************************************************** -// Deposit the IP-Relative signed 64-bit immediate into a IA64 bundle -// (Formats X3 or X4) -//***************************************************************************** -void PutIA64Rel64(UINT64 * pBundle, INT64 imm64); - -//***************************************************************************** -// Extract the 32-bit immediate from movw/movt Thumb2 sequence -//***************************************************************************** -UINT32 GetThumb2Mov32(UINT16 * p); - -//***************************************************************************** -// Deposit the 32-bit immediate into movw/movt Thumb2 sequence -//***************************************************************************** -void PutThumb2Mov32(UINT16 * p, UINT32 imm32); - -//***************************************************************************** -// Extract the 24-bit rel offset from bl instruction -//***************************************************************************** -INT32 GetThumb2BlRel24(UINT16 * p); - -//***************************************************************************** -// Extract the 24-bit rel offset from bl instruction -//***************************************************************************** -void PutThumb2BlRel24(UINT16 * p, INT32 imm24); - -//***************************************************************************** -// Extract the PC-Relative offset from a b or bl instruction -//***************************************************************************** -INT32 GetArm64Rel28(UINT32 * pCode); - -//***************************************************************************** -// Extract the PC-Relative page address from an adrp instruction -//***************************************************************************** -INT32 GetArm64Rel21(UINT32 * pCode); - -//***************************************************************************** -// Extract the page offset from an add instruction -//***************************************************************************** -INT32 GetArm64Rel12(UINT32 * pCode); - -//***************************************************************************** -// Deposit the PC-Relative offset 'imm28' into a b or bl instruction -//***************************************************************************** -void PutArm64Rel28(UINT32 * pCode, INT32 imm28); - -//***************************************************************************** -// Deposit the PC-Relative page address 'imm21' into an adrp instruction -//***************************************************************************** -void PutArm64Rel21(UINT32 * pCode, INT32 imm21); - -//***************************************************************************** -// Deposit the page offset 'imm12' into an add instruction -//***************************************************************************** -void PutArm64Rel12(UINT32 * pCode, INT32 imm12); - -//***************************************************************************** -// Returns whether the offset fits into bl instruction -//***************************************************************************** -inline bool FitsInThumb2BlRel24(INT32 imm24) -{ - return ((imm24 << 7) >> 7) == imm24; -} - -//***************************************************************************** -// Returns whether the offset fits into an Arm64 b or bl instruction -//***************************************************************************** -inline bool FitsInRel28(INT32 val32) -{ - return (val32 >= -0x08000000) && (val32 < 0x08000000); -} - -//***************************************************************************** -// Returns whether the offset fits into an Arm64 adrp instruction -//***************************************************************************** -inline bool FitsInRel21(INT32 val32) -{ - return (val32 >= 0) && (val32 <= 0x001FFFFF); -} - -//***************************************************************************** -// Returns whether the offset fits into an Arm64 add instruction -//***************************************************************************** -inline bool FitsInRel12(INT32 val32) -{ - return (val32 >= 0) && (val32 <= 0x00000FFF); -} - -//***************************************************************************** -// Returns whether the offset fits into an Arm64 b or bl instruction -//***************************************************************************** -inline bool FitsInRel28(INT64 val64) -{ - return (val64 >= -0x08000000LL) && (val64 < 0x08000000LL); -} - -//***************************************************************************** -// Splits a command line into argc/argv lists, using the VC7 parsing rules. -// This functions interface mimics the CommandLineToArgvW api. -// If function fails, returns NULL. -// If function suceeds, call delete [] on return pointer when done. -//***************************************************************************** -LPWSTR *SegmentCommandLine(LPCWSTR lpCmdLine, DWORD *pNumArgs); - -// -// TEB access can be dangerous when using fibers because a fiber may -// run on multiple threads. If the TEB pointer is retrieved and saved -// and then a fiber is moved to a different thread, when it accesses -// the saved TEB pointer, it will be looking at the TEB state for a -// different fiber. -// -// These accessors serve the purpose of retrieving information from the -// TEB in a manner that ensures that the current fiber will not switch -// threads while the access is occuring. -// -class ClrTeb -{ -public: -#if defined(FEATURE_PAL) - - // returns pointer that uniquely identifies the fiber - static void* GetFiberPtrId() - { - LIMITED_METHOD_CONTRACT; - // not fiber for FEATURE_PAL - use the regular thread ID - return (void *)(size_t)GetCurrentThreadId(); - } - - static void* InvalidFiberPtrId() - { - return NULL; - } - - static void* GetStackBase() - { - return PAL_GetStackBase(); - } - - static void* GetStackLimit() - { - return PAL_GetStackLimit(); - } - -#else // !FEATURE_PAL - - // returns pointer that uniquely identifies the fiber - static void* GetFiberPtrId() - { - LIMITED_METHOD_CONTRACT; - // stackbase is the unique fiber identifier - return NtCurrentTeb()->NtTib.StackBase; - } - - static void* GetStackBase() - { - LIMITED_METHOD_CONTRACT; - return NtCurrentTeb()->NtTib.StackBase; - } - - static void* GetStackLimit() - { - LIMITED_METHOD_CONTRACT; - return NtCurrentTeb()->NtTib.StackLimit; - } - - // Please don't start to use this method unless you absolutely have to. - // The reason why this is added is for WIN64 to support LEGACY PE-style TLS - // variables. On X86 it is supported by the JIT compilers themselves. On - // WIN64 we build more logic into the JIT helper for accessing fields. - static void* GetLegacyThreadLocalStoragePointer() - { - LIMITED_METHOD_CONTRACT; - return NtCurrentTeb()->ThreadLocalStoragePointer; - } - - static void* GetOleReservedPtr() - { - LIMITED_METHOD_CONTRACT; - return NtCurrentTeb()->ReservedForOle; - } - - static void* GetProcessEnvironmentBlock() - { - LIMITED_METHOD_CONTRACT; - return NtCurrentTeb()->ProcessEnvironmentBlock; - } - - - static void* InvalidFiberPtrId() - { - return (void*) 1; - } -#endif // !FEATURE_PAL -}; - -#if !defined(DACCESS_COMPILE) - -// check if current thread is a GC thread (concurrent or server) -inline BOOL IsGCSpecialThread () -{ - STATIC_CONTRACT_NOTHROW; - STATIC_CONTRACT_GC_NOTRIGGER; - STATIC_CONTRACT_MODE_ANY; - STATIC_CONTRACT_CANNOT_TAKE_LOCK; - - return !!(((size_t)ClrFlsGetValue (TlsIdx_ThreadType)) & ThreadType_GC); -} - -// check if current thread is a Gate thread -inline BOOL IsGateSpecialThread () -{ - STATIC_CONTRACT_NOTHROW; - STATIC_CONTRACT_GC_NOTRIGGER; - STATIC_CONTRACT_MODE_ANY; - - return !!(((size_t)ClrFlsGetValue (TlsIdx_ThreadType)) & ThreadType_Gate); -} - -// check if current thread is a Timer thread -inline BOOL IsTimerSpecialThread () -{ - STATIC_CONTRACT_NOTHROW; - STATIC_CONTRACT_GC_NOTRIGGER; - STATIC_CONTRACT_MODE_ANY; - - return !!(((size_t)ClrFlsGetValue (TlsIdx_ThreadType)) & ThreadType_Timer); -} - -// check if current thread is a debugger helper thread -inline BOOL IsDbgHelperSpecialThread () -{ - STATIC_CONTRACT_NOTHROW; - STATIC_CONTRACT_GC_NOTRIGGER; - STATIC_CONTRACT_MODE_ANY; - - return !!(((size_t)ClrFlsGetValue (TlsIdx_ThreadType)) & ThreadType_DbgHelper); -} - -// check if current thread is a debugger helper thread -inline BOOL IsETWRundownSpecialThread () -{ - STATIC_CONTRACT_NOTHROW; - STATIC_CONTRACT_GC_NOTRIGGER; - STATIC_CONTRACT_MODE_ANY; - - return !!(((size_t)ClrFlsGetValue (TlsIdx_ThreadType)) & ThreadType_ETWRundownThread); -} - -// check if current thread is a generic instantiation lookup compare thread -inline BOOL IsGenericInstantiationLookupCompareThread () -{ - STATIC_CONTRACT_NOTHROW; - STATIC_CONTRACT_GC_NOTRIGGER; - STATIC_CONTRACT_MODE_ANY; - - return !!(((size_t)ClrFlsGetValue (TlsIdx_ThreadType)) & ThreadType_GenericInstantiationCompare); -} - -// check if current thread is a thread which is performing shutdown -inline BOOL IsShutdownSpecialThread () -{ - STATIC_CONTRACT_NOTHROW; - STATIC_CONTRACT_GC_NOTRIGGER; - STATIC_CONTRACT_MODE_ANY; - - return !!(((size_t)ClrFlsGetValue (TlsIdx_ThreadType)) & ThreadType_Shutdown); -} - -inline BOOL IsThreadPoolIOCompletionSpecialThread () -{ - STATIC_CONTRACT_NOTHROW; - STATIC_CONTRACT_GC_NOTRIGGER; - STATIC_CONTRACT_MODE_ANY; - - return !!(((size_t)ClrFlsGetValue (TlsIdx_ThreadType)) & ThreadType_Threadpool_IOCompletion); -} - -inline BOOL IsThreadPoolWorkerSpecialThread () -{ - STATIC_CONTRACT_NOTHROW; - STATIC_CONTRACT_GC_NOTRIGGER; - STATIC_CONTRACT_MODE_ANY; - - return !!(((size_t)ClrFlsGetValue (TlsIdx_ThreadType)) & ThreadType_Threadpool_Worker); -} - -inline BOOL IsWaitSpecialThread () -{ - STATIC_CONTRACT_NOTHROW; - STATIC_CONTRACT_GC_NOTRIGGER; - STATIC_CONTRACT_MODE_ANY; - - return !!(((size_t)ClrFlsGetValue (TlsIdx_ThreadType)) & ThreadType_Wait); -} - -// check if current thread is a thread which is performing shutdown -inline BOOL IsSuspendEEThread () -{ - STATIC_CONTRACT_NOTHROW; - STATIC_CONTRACT_GC_NOTRIGGER; - STATIC_CONTRACT_MODE_ANY; - - return !!(((size_t)ClrFlsGetValue (TlsIdx_ThreadType)) & ThreadType_DynamicSuspendEE); -} - -inline BOOL IsFinalizerThread () -{ - STATIC_CONTRACT_NOTHROW; - STATIC_CONTRACT_GC_NOTRIGGER; - STATIC_CONTRACT_MODE_ANY; - - return !!(((size_t)ClrFlsGetValue (TlsIdx_ThreadType)) & ThreadType_Finalizer); -} - -inline BOOL IsADUnloadHelperThread () -{ - STATIC_CONTRACT_NOTHROW; - STATIC_CONTRACT_GC_NOTRIGGER; - STATIC_CONTRACT_MODE_ANY; - - return !!(((size_t)ClrFlsGetValue (TlsIdx_ThreadType)) & ThreadType_ADUnloadHelper); -} - -inline BOOL IsShutdownHelperThread () -{ - STATIC_CONTRACT_NOTHROW; - STATIC_CONTRACT_GC_NOTRIGGER; - STATIC_CONTRACT_MODE_ANY; - - return !!(((size_t)ClrFlsGetValue (TlsIdx_ThreadType)) & ThreadType_ShutdownHelper); -} - -inline BOOL IsProfilerAttachThread () -{ - STATIC_CONTRACT_NOTHROW; - STATIC_CONTRACT_GC_NOTRIGGER; - STATIC_CONTRACT_MODE_ANY; - - return !!(((size_t)ClrFlsGetValue (TlsIdx_ThreadType)) & ThreadType_ProfAPI_Attach); -} - -// set specical type for current thread -inline void ClrFlsSetThreadType (TlsThreadTypeFlag flag) -{ - STATIC_CONTRACT_NOTHROW; - STATIC_CONTRACT_GC_NOTRIGGER; - STATIC_CONTRACT_MODE_ANY; - STATIC_CONTRACT_SO_TOLERANT; - - ClrFlsSetValue (TlsIdx_ThreadType, (LPVOID)(((size_t)ClrFlsGetValue (TlsIdx_ThreadType)) |flag)); -} - -// clear specical type for current thread -inline void ClrFlsClearThreadType (TlsThreadTypeFlag flag) -{ - STATIC_CONTRACT_NOTHROW; - STATIC_CONTRACT_GC_NOTRIGGER; - STATIC_CONTRACT_MODE_ANY; - - ClrFlsSetValue (TlsIdx_ThreadType, (LPVOID)(((size_t)ClrFlsGetValue (TlsIdx_ThreadType)) & ~flag)); -} - -#endif //!DACCESS_COMPILE - -#ifdef DACCESS_COMPILE -#define SET_THREAD_TYPE_STACKWALKER(pThread) -#define CLEAR_THREAD_TYPE_STACKWALKER() -#else // DACCESS_COMPILE -#define SET_THREAD_TYPE_STACKWALKER(pThread) ClrFlsSetValue(TlsIdx_StackWalkerWalkingThread, pThread) -#define CLEAR_THREAD_TYPE_STACKWALKER() ClrFlsSetValue(TlsIdx_StackWalkerWalkingThread, NULL) -#endif // DACCESS_COMPILE - -HRESULT SetThreadName(HANDLE hThread, PCWSTR lpThreadDescription); - -inline BOOL IsStackWalkerThread() -{ - STATIC_CONTRACT_NOTHROW; - STATIC_CONTRACT_GC_NOTRIGGER; - STATIC_CONTRACT_MODE_ANY; - STATIC_CONTRACT_CANNOT_TAKE_LOCK; - -#if defined(DACCESS_COMPILE) - return FALSE; -#else - return ClrFlsGetValue (TlsIdx_StackWalkerWalkingThread) != NULL; -#endif -} - -inline BOOL IsGCThread () -{ - STATIC_CONTRACT_NOTHROW; - STATIC_CONTRACT_GC_NOTRIGGER; - STATIC_CONTRACT_MODE_ANY; - STATIC_CONTRACT_SUPPORTS_DAC; - STATIC_CONTRACT_SO_TOLERANT; - -#if !defined(DACCESS_COMPILE) - return IsGCSpecialThread () || IsSuspendEEThread (); -#else - return FALSE; -#endif -} - -class ClrFlsThreadTypeSwitch -{ -public: - ClrFlsThreadTypeSwitch (TlsThreadTypeFlag flag) - { - STATIC_CONTRACT_NOTHROW; - STATIC_CONTRACT_GC_NOTRIGGER; - STATIC_CONTRACT_MODE_ANY; - -#ifndef DACCESS_COMPILE - m_flag = flag; - m_fPreviouslySet = (((size_t)ClrFlsGetValue (TlsIdx_ThreadType)) & flag); - - // In debug builds, remember the full group of flags that were set at the time - // the constructor was called. This will be used in ASSERTs in the destructor - INDEBUG(m_nPreviousFlagGroup = (size_t)ClrFlsGetValue (TlsIdx_ThreadType)); - - if (!m_fPreviouslySet) - { - ClrFlsSetThreadType(flag); - } -#endif // DACCESS_COMPILE - } - - ~ClrFlsThreadTypeSwitch () - { - STATIC_CONTRACT_NOTHROW; - STATIC_CONTRACT_GC_NOTRIGGER; - STATIC_CONTRACT_MODE_ANY; - -#ifndef DACCESS_COMPILE - // This holder should only be used to set (and thus restore) ONE thread type flag - // at a time. If more than that one flag was modified since this holder was - // instantiated, then this holder still restores only the flag it knows about. To - // prevent confusion, assert if some other flag was modified, so the user doesn't - // expect the holder to restore the entire original set of flags. - // - // The expression below says that the only difference between the previous flag - // group and the current flag group should be m_flag (or no difference at all, if - // m_flag's state didn't actually change). - _ASSERTE(((m_nPreviousFlagGroup ^ (size_t) ClrFlsGetValue(TlsIdx_ThreadType)) | (size_t) m_flag) == (size_t) m_flag); - - if (m_fPreviouslySet) - { - ClrFlsSetThreadType(m_flag); - } - else - { - ClrFlsClearThreadType(m_flag); - } -#endif // DACCESS_COMPILE - } - -private: - TlsThreadTypeFlag m_flag; - BOOL m_fPreviouslySet; - INDEBUG(size_t m_nPreviousFlagGroup); -}; - -class ClrFlsValueSwitch -{ -public: - ClrFlsValueSwitch (PredefinedTlsSlots slot, PVOID value) - { - STATIC_CONTRACT_NOTHROW; - STATIC_CONTRACT_GC_NOTRIGGER; - STATIC_CONTRACT_MODE_ANY; - -#ifndef DACCESS_COMPILE - m_slot = slot; - m_PreviousValue = ClrFlsGetValue(slot); - ClrFlsSetValue(slot, value); -#endif // DACCESS_COMPILE - } - - ~ClrFlsValueSwitch () - { - STATIC_CONTRACT_NOTHROW; - STATIC_CONTRACT_GC_NOTRIGGER; - STATIC_CONTRACT_MODE_ANY; - -#ifndef DACCESS_COMPILE - ClrFlsSetValue(m_slot, m_PreviousValue); -#endif // DACCESS_COMPILE - } - -private: - PVOID m_PreviousValue; - PredefinedTlsSlots m_slot; -}; - -//********************************************************************************* - -// When we're hosted, operations called by the host (such as Thread::YieldTask) -// may not cause calls back into the host, as the host needs not be reentrant. -// Use the following holder for code in which calls into the host are forbidden. -// (If a call into the host is attempted nevertheless, an assert will fire.) - -class ForbidCallsIntoHostOnThisThread -{ -private: - static Volatile s_pvOwningFiber; - - FORCEINLINE static BOOL Enter(BOOL) - { - WRAPPER_NO_CONTRACT; - return InterlockedCompareExchangePointer( - &s_pvOwningFiber, ClrTeb::GetFiberPtrId(), NULL) == NULL; - } - - FORCEINLINE static void Leave(BOOL) - { - LIMITED_METHOD_CONTRACT; - s_pvOwningFiber = NULL; - } - -public: - typedef ConditionalStateHolder Holder; - - FORCEINLINE static BOOL CanThisThreadCallIntoHost() - { - WRAPPER_NO_CONTRACT; - return s_pvOwningFiber != ClrTeb::GetFiberPtrId(); - } -}; - -typedef ForbidCallsIntoHostOnThisThread::Holder ForbidCallsIntoHostOnThisThreadHolder; - -FORCEINLINE BOOL CanThisThreadCallIntoHost() -{ - WRAPPER_NO_CONTRACT; - return ForbidCallsIntoHostOnThisThread::CanThisThreadCallIntoHost(); -} - -//********************************************************************************* - -#include "contract.inl" - -namespace util -{ - // compare adapters - // - - template < typename T > - struct less - { - bool operator()( T const & first, T const & second ) const - { - return first < second; - } - }; - - template < typename T > - struct greater - { - bool operator()( T const & first, T const & second ) const - { - return first > second; - } - }; - - - // sort adapters - // - - template< typename Iter, typename Pred > - void sort( Iter begin, Iter end, Pred pred ); - - template< typename T, typename Pred > - void sort( T * begin, T * end, Pred pred ) - { - struct sort_helper : CQuickSort< T > - { - sort_helper( T * begin, T * end, Pred pred ) - : CQuickSort< T >( begin, end - begin ) - , m_pred( pred ) - {} - - virtual int Compare( T * first, T * second ) - { - return m_pred( *first, *second ) ? -1 - : ( m_pred( *second, *first ) ? 1 : 0 ); - } - - Pred m_pred; - }; - - sort_helper sort_obj( begin, end, pred ); - sort_obj.Sort(); - } - - - template < typename Iter > - void sort( Iter begin, Iter end ); - - template < typename T > - void sort( T * begin, T * end ) - { - util::sort( begin, end, util::less< T >() ); - } - - - // binary search adapters - // - - template < typename Iter, typename T, typename Pred > - Iter lower_bound( Iter begin, Iter end, T const & val, Pred pred ); - - template < typename T, typename Pred > - T * lower_bound( T * begin, T * end, T const & val, Pred pred ) - { - for (; begin != end; ) - { - T * mid = begin + ( end - begin ) / 2; - if ( pred( *mid, val ) ) - begin = ++mid; - else - end = mid; - } - - return begin; - } - - - template < typename Iter, typename T > - Iter lower_bound( Iter begin, Iter end, T const & val ); - - template < typename T > - T * lower_bound( T * begin, T * end, T const & val ) - { - return util::lower_bound( begin, end, val, util::less< T >() ); - } -} - - -/* ------------------------------------------------------------------------ * - * Overloaded operators for the executable heap - * ------------------------------------------------------------------------ */ - -#ifndef FEATURE_PAL - -struct CExecutable { int x; }; -extern const CExecutable executable; - -void * __cdecl operator new(size_t n, const CExecutable&); -void * __cdecl operator new[](size_t n, const CExecutable&); -void * __cdecl operator new(size_t n, const CExecutable&, const NoThrow&); -void * __cdecl operator new[](size_t n, const CExecutable&, const NoThrow&); - - -// -// Executable heap delete to match the executable heap new above. -// -template void DeleteExecutable(T *p) -{ - if (p != NULL) - { - p->T::~T(); - - ClrHeapFree(ClrGetProcessExecutableHeap(), 0, p); - } -} - -#endif // FEATURE_PAL - -INDEBUG(BOOL DbgIsExecutable(LPVOID lpMem, SIZE_T length);) - -BOOL NoGuiOnAssert(); -#ifdef _DEBUG -VOID TerminateOnAssert(); -#endif // _DEBUG - -class HighCharHelper { -public: - static inline BOOL IsHighChar(int c) { - return (BOOL)HighCharTable[c]; - } - -private: - static const BYTE HighCharTable[]; -}; - - -BOOL ThreadWillCreateGuardPage(SIZE_T sizeReservedStack, SIZE_T sizeCommitedStack); - -FORCEINLINE void HolderSysFreeString(BSTR str) { CONTRACT_VIOLATION(ThrowsViolation); SysFreeString(str); } - -typedef Wrapper BSTRHolder; - -BOOL FileExists(LPCWSTR filename); - - -// a class for general x.x version info -class MajorMinorVersionInfo -{ -protected: - WORD version[2]; - BOOL bInitialized; -public: - //cctors - MajorMinorVersionInfo() - { - LIMITED_METHOD_CONTRACT; - bInitialized = FALSE; - ZeroMemory(version,sizeof(version)); - }; - - MajorMinorVersionInfo(WORD wMajor, WORD wMinor) - { - WRAPPER_NO_CONTRACT; - Init(wMajor,wMinor); - }; - - // getters - BOOL IsInitialized() const - { - LIMITED_METHOD_CONTRACT; - return bInitialized; - }; - - WORD Major() const - { - LIMITED_METHOD_CONTRACT; - return version[0]; - }; - - WORD Minor() const - { - LIMITED_METHOD_CONTRACT; - return version[1]; - }; - - // setters - void Init(WORD wMajor, WORD wMinor) - { - LIMITED_METHOD_CONTRACT; - version[0]=wMajor; - version[1]=wMinor; - bInitialized=TRUE; - }; -}; - -// CLR runtime version info in Major/Minor form -class RUNTIMEVERSIONINFO : public MajorMinorVersionInfo -{ - static RUNTIMEVERSIONINFO notDefined; -public: - // cctors - RUNTIMEVERSIONINFO() {}; - - RUNTIMEVERSIONINFO(WORD wMajor, WORD wMinor) : - MajorMinorVersionInfo(wMajor,wMinor){}; - - // CLR version specific helpers - BOOL IsPreWhidbey() const - { - WRAPPER_NO_CONTRACT; - return (Major() == 1) && (Minor() <= 1); - } - - static const RUNTIMEVERSIONINFO& NotApplicable() - { - LIMITED_METHOD_CONTRACT; - return notDefined; - } -}; - - -// HMODULE_TGT represents a handle to a module in the target process. In non-DAC builds this is identical -// to HMODULE (HINSTANCE), which is the base address of the module. In DAC builds this must be a target address, -// and so is represented by TADDR. - -#ifdef DACCESS_COMPILE -typedef TADDR HMODULE_TGT; -#else -typedef HMODULE HMODULE_TGT; -#endif - -BOOL IsIPInModule(HMODULE_TGT hModule, PCODE ip); - -//---------------------------------------------------------------------------------------- -// The runtime invokes InitUtilcode() in its dllmain and passes along all of the critical -// callback pointers. For the desktop CLR, all DLLs loaded by the runtime must also call -// InitUtilcode with the same callbacks as the runtime used. To achieve this, the runtime -// calls a special initialization routine exposed by the loaded module with the callbacks, -// which in turn calls InitUtilcode. -// -// This structure collects all of the critical callback info passed in InitUtilcode(). -// Note that one of them is GetCLRFunction() which is itself a gofer for many other -// callbacks. If a callback fetch be safely deferred until we have TLS and stack probe -// functionality running, it should be added to that function rather than this structure. -// Things like IEE are here because that callback has to be set up before GetCLRFunction() -// can be safely called. -//---------------------------------------------------------------------------------------- -struct CoreClrCallbacks -{ - typedef IExecutionEngine* (* pfnIEE_t)(); - typedef HRESULT (* pfnGetCORSystemDirectory_t)(SString& pbuffer); - typedef void* (* pfnGetCLRFunction_t)(LPCSTR functionName); - - HINSTANCE m_hmodCoreCLR; - pfnIEE_t m_pfnIEE; - pfnGetCORSystemDirectory_t m_pfnGetCORSystemDirectory; - pfnGetCLRFunction_t m_pfnGetCLRFunction; -}; - - -// For DAC, we include this functionality only when EH SxS is enabled. - -//---------------------------------------------------------------------------------------- -// CoreCLR must invoke this before CRT initialization to ensure utilcode has all the callback -// pointers it needs. -//---------------------------------------------------------------------------------------- -VOID InitUtilcode(const CoreClrCallbacks &cccallbacks); -CoreClrCallbacks const & GetClrCallbacks(); - -//---------------------------------------------------------------------------------------- -// Stuff below is for utilcode.lib eyes only. -//---------------------------------------------------------------------------------------- - -// Stores callback pointers provided by InitUtilcode(). -extern CoreClrCallbacks g_CoreClrCallbacks; - -// Throws up a helpful dialog if InitUtilcode() wasn't called. -#ifdef _DEBUG -void OnUninitializedCoreClrCallbacks(); -#define VALIDATECORECLRCALLBACKS() if (g_CoreClrCallbacks.m_hmodCoreCLR == NULL) OnUninitializedCoreClrCallbacks() -#else //_DEBUG -#define VALIDATECORECLRCALLBACKS() -#endif //_DEBUG - - -#ifdef FEATURE_CORRUPTING_EXCEPTIONS - -// Corrupting Exception limited support for outside the VM folder -BOOL IsProcessCorruptedStateException(DWORD dwExceptionCode, BOOL fCheckForSO = TRUE); - -#endif // FEATURE_CORRUPTING_EXCEPTIONS - - -BOOL IsV2RuntimeLoaded(void); - -namespace UtilCode -{ - // These are type-safe versions of Interlocked[Compare]Exchange - // They avoid invoking struct cast operations via reinterpreting - // the struct's address as a LONG* or LONGLONG* and dereferencing it. - // - // If we had a global ::operator & (unary), we would love to use that - // to ensure we were not also accidentally getting a structs's provided - // operator &. TODO: probe with a static_assert? - - template - struct InterlockedCompareExchangeHelper; - - template - struct InterlockedCompareExchangeHelper - { - static inline T InterlockedExchange( - T volatile * target, - T value) - { - static_assert_no_msg(sizeof(T) == sizeof(LONG)); - LONG res = ::InterlockedExchange( - reinterpret_cast(target), - *reinterpret_cast(/*::operator*/&(value))); - return *reinterpret_cast(&res); - } - - static inline T InterlockedCompareExchange( - T volatile * destination, - T exchange, - T comparand) - { - static_assert_no_msg(sizeof(T) == sizeof(LONG)); - LONG res = ::InterlockedCompareExchange( - reinterpret_cast(destination), - *reinterpret_cast(/*::operator*/&(exchange)), - *reinterpret_cast(/*::operator*/&(comparand))); - return *reinterpret_cast(&res); - } - }; - - template - struct InterlockedCompareExchangeHelper - { - static inline T InterlockedExchange( - T volatile * target, - T value) - { - static_assert_no_msg(sizeof(T) == sizeof(LONGLONG)); - LONGLONG res = ::InterlockedExchange64( - reinterpret_cast(target), - *reinterpret_cast(/*::operator*/&(value))); - return *reinterpret_cast(&res); - } - - static inline T InterlockedCompareExchange( - T volatile * destination, - T exchange, - T comparand) - { - static_assert_no_msg(sizeof(T) == sizeof(LONGLONG)); - LONGLONG res = ::InterlockedCompareExchange64( - reinterpret_cast(destination), - *reinterpret_cast(/*::operator*/&(exchange)), - *reinterpret_cast(/*::operator*/&(comparand))); - return *reinterpret_cast(&res); - } - }; -} - -template -inline T InterlockedExchangeT( - T volatile * target, - T value) -{ - return ::UtilCode::InterlockedCompareExchangeHelper::InterlockedExchange( - target, value); -} - -template -inline T InterlockedCompareExchangeT( - T volatile * destination, - T exchange, - T comparand) -{ - return ::UtilCode::InterlockedCompareExchangeHelper::InterlockedCompareExchange( - destination, exchange, comparand); -} - -// Pointer variants for Interlocked[Compare]ExchangePointer -// If the underlying type is a const type, we have to remove its constness -// since Interlocked[Compare]ExchangePointer doesn't take const void * arguments. -template -inline T* InterlockedExchangeT( - T* volatile * target, - T* value) -{ - //STATIC_ASSERT(value == 0); - typedef typename std::remove_const::type * non_const_ptr_t; - return reinterpret_cast(InterlockedExchangePointer( - reinterpret_cast(const_cast(target)), - reinterpret_cast(const_cast(value)))); -} - -template -inline T* InterlockedCompareExchangeT( - T* volatile * destination, - T* exchange, - T* comparand) -{ - //STATIC_ASSERT(exchange == 0); - typedef typename std::remove_const::type * non_const_ptr_t; - return reinterpret_cast(InterlockedCompareExchangePointer( - reinterpret_cast(const_cast(destination)), - reinterpret_cast(const_cast(exchange)), - reinterpret_cast(const_cast(comparand)))); -} - -// NULL pointer variants of the above to avoid having to cast NULL -// to the appropriate pointer type. -template -inline T* InterlockedExchangeT( - T* volatile * target, - int value) // When NULL is provided as argument. -{ - //STATIC_ASSERT(value == 0); - return InterlockedExchangeT(target, reinterpret_cast(value)); -} - -template -inline T* InterlockedCompareExchangeT( - T* volatile * destination, - int exchange, // When NULL is provided as argument. - T* comparand) -{ - //STATIC_ASSERT(exchange == 0); - return InterlockedCompareExchangeT(destination, reinterpret_cast(exchange), comparand); -} - -template -inline T* InterlockedCompareExchangeT( - T* volatile * destination, - T* exchange, - int comparand) // When NULL is provided as argument. -{ - //STATIC_ASSERT(comparand == 0); - return InterlockedCompareExchangeT(destination, exchange, reinterpret_cast(comparand)); -} - -// NULL pointer variants of the above to avoid having to cast NULL -// to the appropriate pointer type. -template -inline T* InterlockedExchangeT( - T* volatile * target, - std::nullptr_t value) // When nullptr is provided as argument. -{ - //STATIC_ASSERT(value == 0); - return InterlockedExchangeT(target, static_cast(value)); -} - -template -inline T* InterlockedCompareExchangeT( - T* volatile * destination, - std::nullptr_t exchange, // When nullptr is provided as argument. - T* comparand) -{ - //STATIC_ASSERT(exchange == 0); - return InterlockedCompareExchangeT(destination, static_cast(exchange), comparand); -} - -template -inline T* InterlockedCompareExchangeT( - T* volatile * destination, - T* exchange, - std::nullptr_t comparand) // When nullptr is provided as argument. -{ - //STATIC_ASSERT(comparand == 0); - return InterlockedCompareExchangeT(destination, exchange, static_cast(comparand)); -} - -#undef InterlockedExchangePointer -#define InterlockedExchangePointer Use_InterlockedExchangeT -#undef InterlockedCompareExchangePointer -#define InterlockedCompareExchangePointer Use_InterlockedCompareExchangeT - -// Returns the directory for HMODULE. So, if HMODULE was for "C:\Dir1\Dir2\Filename.DLL", -// then this would return "C:\Dir1\Dir2\" (note the trailing backslash). -HRESULT GetHModuleDirectory(HMODULE hMod, SString& wszPath); -HRESULT CopySystemDirectory(const SString& pPathString, SString& pbuffer); - -HMODULE LoadLocalizedResourceDLLForSDK(_In_z_ LPCWSTR wzResourceDllName, _In_opt_z_ LPCWSTR modulePath=NULL, bool trySelf=true); -// This is a slight variation that can be used for anything else -typedef void* (__cdecl *LocalizedFileHandler)(LPCWSTR); -void* FindLocalizedFile(_In_z_ LPCWSTR wzResourceDllName, LocalizedFileHandler lfh, _In_opt_z_ LPCWSTR modulePath=NULL); - -BOOL IsClrHostedLegacyComObject(REFCLSID rclsid); - - - - -// Helper to support termination due to heap corruption -// It's not supported on Win2K, so we have to manually delay load it -void EnableTerminationOnHeapCorruption(); - - - -namespace Clr { namespace Util -{ - // This api returns a pointer to a null-terminated string that contains the local appdata directory - // or it returns NULL in the case that the directory could not be found. The return value from this function - // is not actually checked for existence. - HRESULT GetLocalAppDataDirectory(LPCWSTR *ppwzLocalAppDataDirectory); - HRESULT SetLocalAppDataDirectory(LPCWSTR pwzLocalAppDataDirectory); - -namespace Reg -{ - HRESULT ReadStringValue(HKEY hKey, LPCWSTR wszSubKey, LPCWSTR wszName, SString & ssValue); - __success(return == S_OK) - HRESULT ReadStringValue(HKEY hKey, LPCWSTR wszSubKey, LPCWSTR wszName, __deref_out __deref_out_z LPWSTR* pwszValue); -} - -#ifdef FEATURE_COMINTEROP -namespace Com -{ - HRESULT FindServerUsingCLSID(REFCLSID rclsid, SString & ssServerName); - HRESULT FindServerUsingCLSID(REFCLSID rclsid, __deref_out __deref_out_z LPWSTR* pwszServerName); - HRESULT FindInprocServer32UsingCLSID(REFCLSID rclsid, SString & ssInprocServer32Name); - HRESULT FindInprocServer32UsingCLSID(REFCLSID rclsid, __deref_out __deref_out_z LPWSTR* pwszInprocServer32Name); - BOOL IsMscoreeInprocServer32(const SString & ssInprocServer32Name); - BOOL CLSIDHasMscoreeAsInprocServer32(REFCLSID rclsid); -} -#endif // FEATURE_COMINTEROP - -namespace Win32 -{ - static const WCHAR LONG_FILENAME_PREFIX_W[] = W("\\\\?\\"); - static const CHAR LONG_FILENAME_PREFIX_A[] = "\\\\?\\"; - - void GetModuleFileName( - HMODULE hModule, - SString & ssFileName, - bool fAllowLongFileNames = false); - - __success(return == S_OK) - HRESULT GetModuleFileName( - HMODULE hModule, - __deref_out_z LPWSTR * pwszFileName, - bool fAllowLongFileNames = false); - - void GetFullPathName( - SString const & ssFileName, - SString & ssPathName, - DWORD * pdwFilePartIdx, - bool fAllowLongFileNames = false); -} - -}} - -#if defined(FEATURE_APPX) && !defined(DACCESS_COMPILE) - // Forward declaration of AppX::IsAppXProcess - namespace AppX { bool IsAppXProcess(); } - - // LOAD_WITH_ALTERED_SEARCH_PATH is unsupported in AppX processes. - inline DWORD GetLoadWithAlteredSearchPathFlag() - { - WRAPPER_NO_CONTRACT; - return AppX::IsAppXProcess() ? 0 : LOAD_WITH_ALTERED_SEARCH_PATH; - } -#else // FEATURE_APPX && !DACCESS_COMPILE - // LOAD_WITH_ALTERED_SEARCH_PATH can be used unconditionally. - inline DWORD GetLoadWithAlteredSearchPathFlag() - { - LIMITED_METHOD_CONTRACT; - #ifdef LOAD_WITH_ALTERED_SEARCH_PATH - return LOAD_WITH_ALTERED_SEARCH_PATH; - #else - return 0; - #endif - } -#endif // FEATURE_APPX && !DACCESS_COMPILE - -// clr::SafeAddRef and clr::SafeRelease helpers. -namespace clr -{ - //================================================================================================================= - template - static inline - typename std::enable_if< std::is_pointer::value, ItfT >::type - SafeAddRef(ItfT pItf) - { - STATIC_CONTRACT_LIMITED_METHOD; - if (pItf != nullptr) - { - pItf->AddRef(); - } - return pItf; - } - - //================================================================================================================= - template - typename std::enable_if< std::is_pointer::value && std::is_reference::value, ULONG >::type - SafeRelease(ItfT pItf) - { - STATIC_CONTRACT_LIMITED_METHOD; - ULONG res = 0; - if (pItf != nullptr) - { - res = pItf->Release(); - pItf = nullptr; - } - return res; - } - - //================================================================================================================= - template - typename std::enable_if< std::is_pointer::value && !std::is_reference::value, ULONG >::type - SafeRelease(ItfT pItf) - { - STATIC_CONTRACT_LIMITED_METHOD; - ULONG res = 0; - if (pItf != nullptr) - { - res = pItf->Release(); - } - return res; - } -} - -// clr::SafeDelete -namespace clr -{ - //================================================================================================================= - template - static inline - typename std::enable_if< std::is_pointer::value, PtrT >::type - SafeDelete(PtrT & ptr) - { - STATIC_CONTRACT_LIMITED_METHOD; - if (ptr != nullptr) - { - delete ptr; - ptr = nullptr; - } - } -} - -// ====================================================================================== -// Spinning support (used by VM and by MetaData via file:..\Utilcode\UTSem.cpp) - -struct SpinConstants -{ - DWORD dwInitialDuration; - DWORD dwMaximumDuration; - DWORD dwBackoffFactor; - DWORD dwRepetitions; - DWORD dwMonitorSpinCount; -}; - -extern SpinConstants g_SpinConstants; - -// ====================================================================================== - -void* GetCLRFunction(LPCSTR FunctionName); - -#endif // __UtilCode_h__ diff --git a/src/inc/utsem.h b/src/inc/utsem.h deleted file mode 100644 index 91036db89..000000000 --- a/src/inc/utsem.h +++ /dev/null @@ -1,63 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - - -/* ---------------------------------------------------------------------------- - ----------------------------------------------------------------------------- */ -#ifndef __UTSEM_H__ -#define __UTSEM_H__ - - -// ------------------------------------------------------------- -// INCLUDES -// ------------------------------------------------------------- -#include "utilcode.h" - -/* ---------------------------------------------------------------------------- -@class UTSemReadWrite - - An instance of class UTSemReadWrite provides multi-read XOR single-write - (a.k.a. shared vs. exclusive) lock capabilities, with protection against - writer starvation. - - A thread MUST NOT call any of the Lock methods if it already holds a Lock. - (Doing so may result in a deadlock.) - - ----------------------------------------------------------------------------- */ -class UTSemReadWrite -{ -public: - UTSemReadWrite(); // Constructor - ~UTSemReadWrite(); // Destructor - - HRESULT Init(); - - HRESULT LockRead(); // Lock the object for reading - HRESULT LockWrite(); // Lock the object for writing - void UnlockRead(); // Unlock the object for reading - void UnlockWrite(); // Unlock the object for writing - -#ifdef _DEBUG - BOOL Debug_IsLockedForRead(); - BOOL Debug_IsLockedForWrite(); -#endif //_DEBUG - -private: - Semaphore * GetReadWaiterSemaphore() - { - return m_pReadWaiterSemaphore; - } - Event * GetWriteWaiterEvent() - { - return m_pWriteWaiterEvent; - } - - Volatile m_dwFlag; // internal state, see implementation - Semaphore * m_pReadWaiterSemaphore; // semaphore for awakening read waiters - Event * m_pWriteWaiterEvent; // event for awakening write waiters -}; // class UTSemReadWrite - -#endif // __UTSEM_H__ diff --git a/src/inc/vererror.h b/src/inc/vererror.h deleted file mode 100644 index 2299b8e08..000000000 --- a/src/inc/vererror.h +++ /dev/null @@ -1,137 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/************************************************************************************** - ** ** - ** Vererror.h - definitions of data structures, needed to report verifier errors. ** - ** ** - **************************************************************************************/ - -#ifndef __VERERROR_h__ -#define __VERERROR_h__ - -#ifndef _VER_RAW_STRUCT_FOR_IDL_ -#ifndef _JIT64_PEV_ -#include "corhdr.h" -#include "openum.h" -#include "corerror.h" -#endif // !_JIT64_PEV_ - -// Set these flags if the error info fields are valid. - -#define VER_ERR_FATAL 0x80000000L // Cannot Continue -#define VER_ERR_OFFSET 0x00000001L -#define VER_ERR_OPCODE 0x00000002L -#define VER_ERR_OPERAND 0x00000004L -#define VER_ERR_TOKEN 0x00000008L -#define VER_ERR_EXCEP_NUM_1 0x00000010L -#define VER_ERR_EXCEP_NUM_2 0x00000020L -#define VER_ERR_STACK_SLOT 0x00000040L -#define VER_ERR_ITEM_1 0x00000080L -#define VER_ERR_ITEM_2 0x00000100L -#define VER_ERR_ITEM_F 0x00000200L -#define VER_ERR_ITEM_E 0x00000400L -#define VER_ERR_TYPE_1 0x00000800L -#define VER_ERR_TYPE_2 0x00001000L -#define VER_ERR_TYPE_F 0x00002000L -#define VER_ERR_TYPE_E 0x00004000L -#define VER_ERR_ADDL_MSG 0x00008000L - -#define VER_ERR_SIG_MASK 0x07000000L // Enum -#define VER_ERR_METHOD_SIG 0x01000000L -#define VER_ERR_LOCAL_SIG 0x02000000L -#define VER_ERR_FIELD_SIG 0x03000000L -#define VER_ERR_CALL_SIG 0x04000000L - -#define VER_ERR_OPCODE_OFFSET (VER_ERR_OPCODE|VER_ERR_OFFSET) - -#define VER_ERR_LOCAL_VAR VER_ERR_LOCAL_SIG -#define VER_ERR_ARGUMENT VER_ERR_METHOD_SIG - -#define VER_ERR_ARG_RET 0xFFFFFFFEL // The Argument # is return -#define VER_ERR_NO_ARG 0xFFFFFFFFL // Argument # is not valid -#define VER_ERR_NO_LOC VER_ERR_NO_ARG // Local # is not valid - -typedef struct -{ - DWORD dwFlags; // BYREF / BOXED etc.. see veritem.hpp - void* pv; // TypeHandle / MethodDesc * etc. -} _VerItem; - -// This structure is used to fully define a verification error. -// Verification error codes are found in CorError.h -// The error resource strings are found in src/dlls/mscorrc/mscor.rc - -typedef struct VerErrorStruct -{ - DWORD dwFlags; // VER_ERR_XXX - - union { -#ifndef _JIT64_PEV_ - OPCODE opcode; -#endif // !_JIT64_PEV_ - unsigned long padding1; // to match with idl generated struct size - }; - - union { - DWORD dwOffset; // #of bytes from start of method - long uOffset; // for backward compat with Metadata validator - }; - - union { - mdToken token; - mdToken Token; // for backward compat with metadata validator - BYTE bCallConv; - CorElementType elem; - DWORD dwStackSlot; // positon in the Stack - unsigned long padding2; // to match with idl generated struct size - }; - - union { - _VerItem sItem1; - _VerItem sItemFound; - WCHAR* wszType1; - WCHAR* wszTypeFound; - DWORD dwException1; // Exception Record # - DWORD dwVarNumber; // Variable # - DWORD dwArgNumber; // Argument # - DWORD dwOperand; // Operand for the opcode - WCHAR* wszAdditionalMessage; // message from getlasterror - }; - - union { - _VerItem sItem2; - _VerItem sItemExpected; - WCHAR* wszType2; - WCHAR* wszTypeExpected; - DWORD dwException2; // Exception Record # - }; - -} VerError; - -#else - -// Assert that sizeof(_VerError) == sizeof(VerError) in Verifier.cpp -typedef struct tag_VerError -{ - unsigned long flags; // DWORD - unsigned long opcode; // OPCODE, padded to ulong - unsigned long uOffset; // DWORD - unsigned long Token; // mdToken - unsigned long item1_flags; // _VerItem.DWORD - int *item1_data; // _VerItem.PVOID - unsigned long item2_flags; // _VerItem.DWORD - int *item2_data; // _VerItem.PVOID -} _VerError; -#endif - -#endif // __VERERROR_h__ - - - - - - - - diff --git a/src/inc/vptr_list.h b/src/inc/vptr_list.h deleted file mode 100644 index 7b7b5f0eb..000000000 --- a/src/inc/vptr_list.h +++ /dev/null @@ -1,123 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -// Any class with a vtable that needs to be instantiated -// during debugging data access must be listed here. - -VPTR_CLASS(Thread) - -VPTR_CLASS(EEJitManager) - -#ifdef FEATURE_PREJIT -VPTR_CLASS(NativeImageJitManager) -#endif // FEATURE_PREJIT -#ifdef FEATURE_READYTORUN -VPTR_CLASS(ReadyToRunJitManager) -#endif -VPTR_CLASS(EECodeManager) - -VPTR_CLASS(RangeList) -VPTR_CLASS(LockedRangeList) - -#ifdef EnC_SUPPORTED -VPTR_CLASS(EditAndContinueModule) -#endif -VPTR_CLASS(Module) -VPTR_CLASS(ReflectionModule) - -VPTR_CLASS(AppDomain) -VPTR_CLASS(SharedDomain) -VPTR_CLASS(SystemDomain) - -VPTR_CLASS(DomainAssembly) -VPTR_CLASS(PrecodeStubManager) -VPTR_CLASS(StubLinkStubManager) -VPTR_CLASS(ThePreStubManager) -VPTR_CLASS(ThunkHeapStubManager) -VPTR_CLASS(VirtualCallStubManager) -VPTR_CLASS(VirtualCallStubManagerManager) -VPTR_CLASS(JumpStubStubManager) -VPTR_CLASS(RangeSectionStubManager) -VPTR_CLASS(ILStubManager) -VPTR_CLASS(InteropDispatchStubManager) -VPTR_CLASS(DelegateInvokeStubManager) -VPTR_CLASS(TailCallStubManager) -VPTR_CLASS(PEFile) -VPTR_CLASS(PEAssembly) -VPTR_CLASS(PEImageLayout) -VPTR_CLASS(RawImageLayout) -VPTR_CLASS(ConvertedImageLayout) -VPTR_CLASS(MappedImageLayout) -#if !defined(CROSSGEN_COMPILE) && !defined(FEATURE_PAL) -VPTR_CLASS(LoadedImageLayout) -#endif // !CROSSGEN_COMPILE && !FEATURE_PAL -VPTR_CLASS(FlatImageLayout) -#ifdef FEATURE_COMINTEROP -VPTR_CLASS(ComMethodFrame) -VPTR_CLASS(ComPlusMethodFrame) -VPTR_CLASS(ComPrestubMethodFrame) -#endif // FEATURE_COMINTEROP -VPTR_CLASS(ContextTransitionFrame) -#ifdef FEATURE_INTERPRETER -VPTR_CLASS(InterpreterFrame) -#endif // FEATURE_INTERPRETER -VPTR_CLASS(DebuggerClassInitMarkFrame) -VPTR_CLASS(DebuggerSecurityCodeMarkFrame) -VPTR_CLASS(DebuggerExitFrame) -VPTR_CLASS(DebuggerU2MCatchHandlerFrame) -VPTR_CLASS(FaultingExceptionFrame) -VPTR_CLASS(FuncEvalFrame) -VPTR_CLASS(GCFrame) -VPTR_CLASS(HelperMethodFrame) -VPTR_CLASS(HelperMethodFrame_1OBJ) -VPTR_CLASS(HelperMethodFrame_2OBJ) -VPTR_CLASS(HelperMethodFrame_3OBJ) -VPTR_CLASS(HelperMethodFrame_PROTECTOBJ) -#ifdef FEATURE_HIJACK -VPTR_CLASS(HijackFrame) -#endif -VPTR_CLASS(InlinedCallFrame) -VPTR_CLASS(SecureDelegateFrame) -VPTR_CLASS(MulticastFrame) -VPTR_CLASS(PInvokeCalliFrame) -VPTR_CLASS(PrestubMethodFrame) -VPTR_CLASS(ProtectByRefsFrame) -VPTR_CLASS(ProtectValueClassFrame) -#ifdef FEATURE_HIJACK -VPTR_CLASS(ResumableFrame) -VPTR_CLASS(RedirectedThreadFrame) -#endif -VPTR_CLASS(StubDispatchFrame) -VPTR_CLASS(ExternalMethodFrame) -#ifdef FEATURE_READYTORUN -VPTR_CLASS(DynamicHelperFrame) -#endif -#if !defined(_TARGET_X86_) -VPTR_CLASS(StubHelperFrame) -#endif -#if defined(_TARGET_X86_) -VPTR_CLASS(UMThkCallFrame) -#endif -VPTR_CLASS(TailCallFrame) -VPTR_CLASS(ExceptionFilterFrame) - -#ifdef _DEBUG -VPTR_CLASS(AssumeByrefFromJITStack) -#endif - -#ifdef DEBUGGING_SUPPORTED -VPTR_CLASS(Debugger) -VPTR_CLASS(EEDbgInterfaceImpl) -#endif // DEBUGGING_SUPPORTED - -VPTR_CLASS(DebuggerController) -VPTR_CLASS(DebuggerMethodInfoTable) -VPTR_CLASS(DebuggerPatchTable) - -VPTR_CLASS(LoaderCodeHeap) -VPTR_CLASS(HostCodeHeap) - -VPTR_CLASS(GlobalLoaderAllocator) -VPTR_CLASS(AppDomainLoaderAllocator) -VPTR_CLASS(AssemblyLoaderAllocator) diff --git a/src/inc/win64unwind.h b/src/inc/win64unwind.h deleted file mode 100644 index e4cea023b..000000000 --- a/src/inc/win64unwind.h +++ /dev/null @@ -1,126 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#ifndef _WIN64UNWIND_H_ -#define _WIN64UNWIND_H_ - -// -// Define AMD64 exception handling structures and function prototypes. -// -// Define unwind operation codes. -// - -typedef enum _UNWIND_OP_CODES { - UWOP_PUSH_NONVOL = 0, - UWOP_ALLOC_LARGE, - UWOP_ALLOC_SMALL, - UWOP_SET_FPREG, - UWOP_SAVE_NONVOL, - UWOP_SAVE_NONVOL_FAR, - UWOP_EPILOG, - UWOP_SPARE_CODE, - UWOP_SAVE_XMM128, - UWOP_SAVE_XMM128_FAR, - UWOP_PUSH_MACHFRAME, - -#ifdef PLATFORM_UNIX - // UWOP_SET_FPREG_LARGE is a CLR Unix-only extension to the Windows AMD64 unwind codes. - // It is not part of the standard Windows AMD64 unwind codes specification. - // UWOP_SET_FPREG allows for a maximum of a 240 byte offset between RSP and the - // frame pointer, when the frame pointer is established. UWOP_SET_FPREG_LARGE - // has a 32-bit range scaled by 16. When UWOP_SET_FPREG_LARGE is used, - // UNWIND_INFO.FrameRegister must be set to the frame pointer register, and - // UNWIND_INFO.FrameOffset must be set to 15 (its maximum value). UWOP_SET_FPREG_LARGE - // is followed by two UNWIND_CODEs that are combined to form a 32-bit offset (the same - // as UWOP_SAVE_NONVOL_FAR). This offset is then scaled by 16. The result must be less - // than 2^32 (that is, the top 4 bits of the unscaled 32-bit number must be zero). This - // result is used as the frame pointer register offset from RSP at the time the frame pointer - // is established. Either UWOP_SET_FPREG or UWOP_SET_FPREG_LARGE can be used, but not both. - - UWOP_SET_FPREG_LARGE, -#endif // PLATFORM_UNIX -} UNWIND_OP_CODES, *PUNWIND_OP_CODES; - -static const UCHAR UnwindOpExtraSlotTable[] = { - 0, // UWOP_PUSH_NONVOL - 1, // UWOP_ALLOC_LARGE (or 3, special cased in lookup code) - 0, // UWOP_ALLOC_SMALL - 0, // UWOP_SET_FPREG - 1, // UWOP_SAVE_NONVOL - 2, // UWOP_SAVE_NONVOL_FAR - 1, // UWOP_EPILOG - 2, // UWOP_SPARE_CODE // previously 64-bit UWOP_SAVE_XMM_FAR - 1, // UWOP_SAVE_XMM128 - 2, // UWOP_SAVE_XMM128_FAR - 0, // UWOP_PUSH_MACHFRAME - -#ifdef PLATFORM_UNIX - 2, // UWOP_SET_FPREG_LARGE -#endif // PLATFORM_UNIX -}; - -// -// Define unwind code structure. -// - -typedef union _UNWIND_CODE { - struct { - UCHAR CodeOffset; - UCHAR UnwindOp : 4; - UCHAR OpInfo : 4; - }; - - struct { - UCHAR OffsetLow; - UCHAR UnwindOp : 4; - UCHAR OffsetHigh : 4; - } EpilogueCode; - - USHORT FrameOffset; -} UNWIND_CODE, *PUNWIND_CODE; - -// -// Define unwind information flags. -// - -#define UNW_FLAG_NHANDLER 0x0 -#define UNW_FLAG_EHANDLER 0x1 -#define UNW_FLAG_UHANDLER 0x2 -#define UNW_FLAG_CHAININFO 0x4 - -#ifdef _TARGET_X86_ - -typedef struct _UNWIND_INFO { - ULONG FunctionLength; -} UNWIND_INFO, *PUNWIND_INFO; - -#else // _TARGET_X86_ - -typedef struct _UNWIND_INFO { - UCHAR Version : 3; - UCHAR Flags : 5; - UCHAR SizeOfProlog; - UCHAR CountOfUnwindCodes; - UCHAR FrameRegister : 4; - UCHAR FrameOffset : 4; - UNWIND_CODE UnwindCode[1]; - -// -// The unwind codes are followed by an optional DWORD aligned field that -// contains the exception handler address or the address of chained unwind -// information. If an exception handler address is specified, then it is -// followed by the language specified exception handler data. -// -// union { -// ULONG ExceptionHandler; -// ULONG FunctionEntry; -// }; -// -// ULONG ExceptionData[]; -// - -} UNWIND_INFO, *PUNWIND_INFO; - -#endif // _TARGET_X86_ -#endif // _WIN64UNWIND_H_ diff --git a/src/inc/winrtprojectedtypes.h b/src/inc/winrtprojectedtypes.h deleted file mode 100644 index 503e0305d..000000000 --- a/src/inc/winrtprojectedtypes.h +++ /dev/null @@ -1,271 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -// -// This header defines the list of types that are redirected in the CLR projection of WinRT. -// - -// -// The DEFINE_PROJECTED_TYPE macro takes the following parameters: -// * An ASCII string representing the namespace in winmd which contains the type being projected from -// * An ASCII string representing the name in winmd of the type being projected from -// * An ASCII string representing the namespace in .NET which contains the type being projected to -// * An ASCII string representing the name in .NET of the type being projected to -// * A symbol which is used to represent the assembly the .NET type is defined in -// * A symbol which is used to represent the contract assembly the .NET type is defined in -// * A symbol which is used to represent the WinRT type -// * A symbol which is used to represent the .NET type -// * A symbol which indicates what kind of type this is (struct, runtimeclassclass, etc) - -// -// Optionally, the DEFINE_PROJECTED_RUNTIMECLASS, DEFINE_PROJECTED_STRUCT, DEFINE_PROJECTED_ENUM, DEFINE_PROJECTED_PINTERFACE, -// DEFINE_PROJECTED_INTERFACE, and DEFINE_PROJECTED_ATTRIBUTE macros can be defined by the consumer of this header file, in -// order to get extra information about the projected types. -// -// Note that the input to these macros is in terms of the original winmd - so HResult is a DEFINE_PROJECTED_STRUCT even though it -// projects to the class Exception. If you are adding a projection where the WinRT and CLR views differ upon if the type is a -// value type or not, you'll need to update the signature rewriting code in md\winmd\adapter.cpp as well as the export code in -// toolbox\winmdexp\projectedtypes.cspp. -// -// If these extra macros are not defined, then the DEFINE_PROJECTED_TYPE macro is used to register the type -// -// Additionally, the DEFINE_HIDDEN_WINRT_TYPE macro can be defined by the consumer of this file to get information about WinRT -// types that are not projected but should be hidden from the developer, for instance because they are not intended to be used -// by 3rd party components. -// -// - -// DEFINE_PROJECTED_RUNTIMECLASS adds the following parameters: -// * A ASCII string representing the namespace qualified default interface name -// * The IID of the default interface -#ifndef DEFINE_PROJECTED_RUNTIMECLASS -#define DEFINE_PROJECTED_RUNTIMECLASS(szWinRTNamespace, szWinRTName, szClrNamespace, szClrName, nClrAssemblyIndex, nContractAsmIdx, WinRTRedirectedTypeIndex, ClrRedirectedTypeIndex, szDefaultInterfaceName, DefaultInterfaceIID) \ - DEFINE_PROJECTED_TYPE(szWinRTNamespace, szWinRTName, szClrNamespace, szClrName, nClrAssemblyIndex, nContractAsmIdx, WinRTRedirectedTypeIndex, ClrRedirectedTypeIndex, Runtimeclass) -#define __LOCAL_DEFINE_PROJECTED_RUNTIMECLASS -#endif // !DEFINE_PROJECTED_RUNTIMECLASS - -// DEFINE_PROJECTED_STRUCT adds the following parameters: -// * An array of Unicode strings representing the types of those fields -// -// Note that if a field is of a non-primitive type, it must be represented in WinRTGuidGenerator::MetaDataLocator::Locate -#ifndef DEFINE_PROJECTED_STRUCT -#define DEFINE_PROJECTED_STRUCT(szWinRTNamespace, szWinRTName, szClrNamespace, szClrName, nClrAssemblyIndex, nContractAsmIdx, WinRTRedirectedTypeIndex, ClrRedirectedTypeIndex, fieldSizes) \ - DEFINE_PROJECTED_TYPE(szWinRTNamespace, szWinRTName, szClrNamespace, szClrName, nClrAssemblyIndex, nContractAsmIdx, WinRTRedirectedTypeIndex, ClrRedirectedTypeIndex, Struct) -#define __LOCAL_DEFINE_PROJECTED_STRUCT -#endif // !DEFINE_PROJECTED_STRUCT - -#ifndef DEFINE_PROJECTED_JUPITER_STRUCT -#define DEFINE_PROJECTED_JUPITER_STRUCT(szWinRTNamespace, szWinRTName, szClrNamespace, szClrName, nClrAssemblyIndex, nContractAsmIdx, WinRTRedirectedTypeIndex, ClrRedirectedTypeIndex, fieldSizes) \ - DEFINE_PROJECTED_TYPE(szWinRTNamespace, szWinRTName, szClrNamespace, szClrName, nClrAssemblyIndex, nContractAsmIdx, WinRTRedirectedTypeIndex, ClrRedirectedTypeIndex, Struct) -#define __LOCAL_DEFINE_PROJECTED_JUPITER_STRUCT -#endif // !DEFINE_PROJECTED_JUPITER_STRUCT - -#ifndef STRUCT_FIELDS -#define STRUCT_FIELDS(...) __VA_ARGS__ -#endif // !STRUCT_FIELDS - -// DEFINE_PROJECTED_ENUM adds the following parameters: -// * An ASCII string defining the size of the backing field of the enumeration -#ifndef DEFINE_PROJECTED_ENUM -#define DEFINE_PROJECTED_ENUM(szWinRTNamespace, szWinRTName, szClrNamespace, szClrName, nClrAssemblyIndex, nContractAsmIdx, WinRTRedirectedTypeIndex, ClrRedirectedTypeIndex, szBackingFieldSize) \ - DEFINE_PROJECTED_TYPE(szWinRTNamespace, szWinRTName, szClrNamespace, szClrName, nClrAssemblyIndex, nContractAsmIdx, WinRTRedirectedTypeIndex, ClrRedirectedTypeIndex, Enum) -#define __LOCAL_DEFINE_PROJECTED_ENUM -#endif // !DEFINE_PROJECTED_ENUM - -// DEFINE_PROJECTED_INTERFACE adds the following extra parameters: -// * The IID of the interface -#ifndef DEFINE_PROJECTED_INTERFACE -#define DEFINE_PROJECTED_INTERFACE(szWinRTNamespace, szWinRTName, szClrNamespace, szClrName, nClrAssemblyIndex, nContractAsmIdx, WinRTRedirectedTypeIndex, ClrRedirectedTypeIndex, PIID) \ - DEFINE_PROJECTED_TYPE(szWinRTNamespace, szWinRTName, szClrNamespace, szClrName, nClrAssemblyIndex, nContractAsmIdx, WinRTRedirectedTypeIndex, ClrRedirectedTypeIndex, Interface) -#define __LOCAL_DEFINE_PROJECTED_INTERFACE -#endif // !DEFINE_PROJECTED_INTERFACE - -// DEFINE_PROJECTED_PINTERFACE adds the following extra parameters: -// * The number of generic type parameters on the interface -// * The PIID of the interface -#ifndef DEFINE_PROJECTED_PINTERFACE -#define DEFINE_PROJECTED_PINTERFACE(szWinRTNamespace, szWinRTName, szClrNamespace, szClrName, nClrAssemblyIndex, nContractAsmIdx, WinRTRedirectedTypeIndex, ClrRedirectedTypeIndex, GenericTypeParameterCount, PIID) \ - DEFINE_PROJECTED_TYPE(szWinRTNamespace, szWinRTName, szClrNamespace, szClrName, nClrAssemblyIndex, nContractAsmIdx, WinRTRedirectedTypeIndex, ClrRedirectedTypeIndex, PInterface) -#define __LOCAL_DEFINE_PROJECTED_PINTERFACE -#endif // !DEFINE_PROJECTED_PINTERFACE - -// DEFINE_PROJECTED_DELEGATE adds the following extra parameters: -// * The IID of the delegate -#ifndef DEFINE_PROJECTED_DELEGATE -#define DEFINE_PROJECTED_DELEGATE(szWinRTNamespace, szWinRTName, szClrNamespace, szClrName, nClrAssemblyIndex, nContractAsmIdx, WinRTRedirectedTypeIndex, ClrRedirectedTypeIndex, PIID) \ - DEFINE_PROJECTED_TYPE(szWinRTNamespace, szWinRTName, szClrNamespace, szClrName, nClrAssemblyIndex, nContractAsmIdx, WinRTRedirectedTypeIndex, ClrRedirectedTypeIndex, Delegate) -#define __LOCAL_DEFINE_PROJECTED_DELEGATE -#endif // !DEFINE_PROJECTED_DELEGATE - -// DEFINE_PROJECTED_PDELEGATE adds the following extra parameters: -// * The number of generic type parameters on the interface -// * The PIID of the delegate -#ifndef DEFINE_PROJECTED_PDELEGATE -#define DEFINE_PROJECTED_PDELEGATE(szWinRTNamespace, szWinRTName, szClrNamespace, szClrName, nClrAssemblyIndex, nContractAsmIdx, WinRTRedirectedTypeIndex, ClrRedirectedTypeIndex, GenericTypeParameterCount, PIID) \ - DEFINE_PROJECTED_TYPE(szWinRTNamespace, szWinRTName, szClrNamespace, szClrName, nClrAssemblyIndex, nContractAsmIdx, WinRTRedirectedTypeIndex, ClrRedirectedTypeIndex, PDelegate) -#define __LOCAL_DEFINE_PROJECTED_PDELEGATE -#endif // !DEFINE_PROJECTED_PDELEGATE - -#ifndef PIID -#define PIID(...) { __VA_ARGS__ } -#endif // !PIID - -// DEFINE_PROJECTED_ATTRIBUTE adds no additional parameters -#ifndef DEFINE_PROJECTED_ATTRIBUTE -#define DEFINE_PROJECTED_ATTRIBUTE(szWinRTNamespace, szWinRTName, szClrNamespace, szClrName, nClrAssemblyIndex, nContractAsmIdx, WinRTRedirectedTypeIndex, ClrRedirectedTypeIndex) \ - DEFINE_PROJECTED_TYPE(szWinRTNamespace, szWinRTName, szClrNamespace, szClrName, nClrAssemblyIndex, nContractAsmIdx, WinRTRedirectedTypeIndex, ClrRedirectedTypeIndex, Attribute) -#define __LOCAL_DEFINE_PROJECTED_ATTRIBUTE -#endif // !DEFINE_PROJECTED_ATTRIBUTE - -#ifndef DEFINE_HIDDEN_WINRT_TYPE -#define DEFINE_HIDDEN_WINRT_TYPE(szWinRTNamespace, szWinRTName) -#define __LOCAL_DEFINE_HIDDEN_WINRT_TYPE -#endif // !DEFINE_HIDDEN_WINRT_TYPE - -// szWinRTNamespace szWinRTName szClrNamespace szClrName nClrAssemblyIndex nContractAsmIdx WinRTRedirectedTypeIndex ClrRedirectedTypeIndex Extra parameters -// ---------------- ----------- -------------- --------- ----------------- --------------- --------------------- ---------------------- ---------------- -DEFINE_PROJECTED_ATTRIBUTE ("Windows.Foundation.Metadata", "AttributeUsageAttribute", "System", "AttributeUsageAttribute", Mscorlib, SystemRuntime, Windows_Foundation_Metadata_AttributeUsageAttribute, System_AttributeUsage) -DEFINE_PROJECTED_ENUM ("Windows.Foundation.Metadata", "AttributeTargets", "System", "AttributeTargets", Mscorlib, SystemRuntime, Windows_Foundation_Metadata_AttributeTargets, System_AttributeTargets, "Int32") - -DEFINE_PROJECTED_STRUCT ("Windows.UI", "Color", "Windows.UI", "Color", SystemRuntimeWindowsRuntime, SystemRuntimeWindowsRuntime, Windows_UI_Color, System_Windows_Color, STRUCT_FIELDS(W("UInt8"), W("UInt8"), W("UInt8"), W("UInt8"))) - -DEFINE_PROJECTED_STRUCT ("Windows.Foundation", "DateTime", "System", "DateTimeOffset", Mscorlib, SystemRuntime, Windows_Foundation_DateTime, System_DateTimeOffset, STRUCT_FIELDS(W("Int64"))) -DEFINE_PROJECTED_PDELEGATE ("Windows.Foundation", "EventHandler`1", "System", "EventHandler`1", Mscorlib, SystemRuntime, Windows_Foundation_EventHandlerGeneric, System_EventHandlerGeneric, 1, PIID(0x9de1c535, 0x6ae1, 0x11e0, {0x84, 0xe1, 0x18, 0xa9, 0x05, 0xbc, 0xc5, 0x3f})) -DEFINE_PROJECTED_STRUCT ("Windows.Foundation", "EventRegistrationToken", "System.Runtime.InteropServices.WindowsRuntime", "EventRegistrationToken", Mscorlib, SystemRuntimeInteropServicesWindowsRuntime, Windows_Foundation_EventRegistrationToken, System_Runtime_InteropServices_WindowsRuntime_EventRegistrationToken, STRUCT_FIELDS(W("Int64"))) -DEFINE_PROJECTED_STRUCT ("Windows.Foundation", "HResult", "System", "Exception", Mscorlib, SystemRuntime, Windows_Foundation_HResult, System_Exception, STRUCT_FIELDS(W("Int32"))) -DEFINE_PROJECTED_PINTERFACE ("Windows.Foundation", "IReference`1", "System", "Nullable`1", Mscorlib, SystemRuntime, Windows_Foundation_IReference, System_Nullable, 1, PIID(0x61c17706, 0x2d65, 0x11e0, {0x9a, 0xe8, 0xd4, 0x85, 0x64, 0x01, 0x54, 0x72})) -DEFINE_PROJECTED_STRUCT ("Windows.Foundation", "Point", "Windows.Foundation", "Point", SystemRuntimeWindowsRuntime, SystemRuntimeWindowsRuntime, Windows_Foundation_Point, Windows_Foundation_Point_clr, STRUCT_FIELDS(W("Single"), W("Single"))) -DEFINE_PROJECTED_STRUCT ("Windows.Foundation", "Rect", "Windows.Foundation", "Rect", SystemRuntimeWindowsRuntime, SystemRuntimeWindowsRuntime, Windows_Foundation_Rect, Windows_Foundation_Rect_clr, STRUCT_FIELDS(W("Single"), W("Single"), W("Single"), W("Single"))) -DEFINE_PROJECTED_STRUCT ("Windows.Foundation", "Size", "Windows.Foundation", "Size", SystemRuntimeWindowsRuntime, SystemRuntimeWindowsRuntime, Windows_Foundation_Size, Windows_Foundation_Size_clr, STRUCT_FIELDS(W("Single"), W("Single"))) -DEFINE_PROJECTED_STRUCT ("Windows.Foundation", "TimeSpan", "System", "TimeSpan", Mscorlib, SystemRuntime, Windows_Foundation_TimeSpan, System_TimeSpan, STRUCT_FIELDS(W("Int64"))) -DEFINE_PROJECTED_RUNTIMECLASS("Windows.Foundation", "Uri", "System", "Uri", SystemRuntime, SystemRuntime, Windows_Foundation_Uri, System_Uri, "Windows.Foundation.IUriRuntimeClass", __uuidof(ABI::Windows::Foundation::IUriRuntimeClass)) - -DEFINE_PROJECTED_INTERFACE ("Windows.Foundation", "IClosable", "System", "IDisposable", Mscorlib, SystemRuntime, Windows_Foundation_IClosable, System_IDisposable, PIID(0x30d5a829, 0x7fa4, 0x4026, {0x83, 0xbb, 0xd7, 0x5b, 0xae, 0x4e, 0xa9, 0x9e})) - -DEFINE_PROJECTED_PINTERFACE ("Windows.Foundation.Collections", "IIterable`1", "System.Collections.Generic", "IEnumerable`1", Mscorlib, SystemRuntime, Windows_Foundation_Collections_IIterable, System_Collections_Generic_IEnumerable, 1, PIID(0xfaa585ea, 0x6214, 0x4217, {0xaf, 0xda, 0x7f, 0x46, 0xde, 0x58, 0x69, 0xb3})) -DEFINE_PROJECTED_PINTERFACE ("Windows.Foundation.Collections", "IVector`1", "System.Collections.Generic", "IList`1", Mscorlib, SystemRuntime, Windows_Foundation_Collections_IVector, System_Collections_Generic_IList, 1, PIID(0x913337e9, 0x11a1, 0x4345, {0xa3, 0xa2, 0x4e, 0x7f, 0x95, 0x6e, 0x22, 0x2d})) -DEFINE_PROJECTED_PINTERFACE ("Windows.Foundation.Collections", "IVectorView`1", "System.Collections.Generic", "IReadOnlyList`1", Mscorlib, SystemRuntime, Windows_Foundation_Collections_IVectorView, System_Collections_Generic_IReadOnlyList, 1, PIID(0xbbe1fa4c, 0xb0e3, 0x4583, {0xba, 0xef, 0x1f, 0x1b, 0x2e, 0x48, 0x3e, 0x56})) -DEFINE_PROJECTED_PINTERFACE ("Windows.Foundation.Collections", "IMap`2", "System.Collections.Generic", "IDictionary`2", Mscorlib, SystemRuntime, Windows_Foundation_Collections_IMap, System_Collections_Generic_IDictionary, 2, PIID(0x3c2925fe, 0x8519, 0x45c1, {0xaa, 0x79, 0x19, 0x7b, 0x67, 0x18, 0xc1, 0xc1})) -DEFINE_PROJECTED_PINTERFACE ("Windows.Foundation.Collections", "IMapView`2", "System.Collections.Generic", "IReadOnlyDictionary`2", Mscorlib, SystemRuntime, Windows_Foundation_Collections_IMapView, System_Collections_Generic_IReadOnlyDictionary, 2, PIID(0xe480ce40, 0xa338, 0x4ada, {0xad, 0xcf, 0x27, 0x22, 0x72, 0xe4, 0x8c, 0xb9})) -DEFINE_PROJECTED_PINTERFACE ("Windows.Foundation.Collections", "IKeyValuePair`2", "System.Collections.Generic", "KeyValuePair`2", Mscorlib, SystemRuntime, Windows_Foundation_Collections_IKeyValuePair, System_Collections_Generic_KeyValuePair, 2, PIID(0x02b51929, 0xc1c4, 0x4a7e, {0x89, 0x40, 0x03, 0x12, 0xb5, 0xc1, 0x85, 0x00})) - -DEFINE_PROJECTED_INTERFACE ("Windows.UI.Xaml.Input", "ICommand", "System.Windows.Input", "ICommand", SystemObjectModel, SystemObjectModel, Windows_UI_Xaml_Input_ICommand, System_Windows_Input_ICommand, PIID(0xE5AF3542, 0xCA67, 0x4081, {0x99, 0x5B, 0x70, 0x9D, 0xD1, 0x37, 0x92, 0xDF})) - -DEFINE_PROJECTED_INTERFACE ("Windows.UI.Xaml.Interop", "IBindableIterable", "System.Collections", "IEnumerable", Mscorlib, SystemRuntime, Windows_UI_Xaml_Interop_IBindableIterable, System_Collections_IEnumerable, PIID(0x036d2c08, 0xdf29, 0x41af, {0x8a, 0xa2, 0xd7, 0x74, 0xbe, 0x62, 0xba, 0x6f})) -DEFINE_PROJECTED_INTERFACE ("Windows.UI.Xaml.Interop", "IBindableVector", "System.Collections", "IList", Mscorlib, SystemRuntime, Windows_UI_Xaml_Interop_IBindableVector, System_Collections_IList, PIID(0x393de7de, 0x6fd0, 0x4c0d, {0xbb, 0x71, 0x47, 0x24, 0x4a, 0x11, 0x3e, 0x93})) - -DEFINE_PROJECTED_INTERFACE ("Windows.UI.Xaml.Interop", "INotifyCollectionChanged", "System.Collections.Specialized", "INotifyCollectionChanged", SystemObjectModel, SystemObjectModel, Windows_UI_Xaml_Interop_INotifyCollectionChanged, System_Collections_Specialized_INotifyCollectionChanged, PIID(0x28b167d5, 0x1a31, 0x465b, {0x9b, 0x25, 0xd5, 0xc3, 0xae, 0x68, 0x6c, 0x40})) -DEFINE_PROJECTED_DELEGATE ("Windows.UI.Xaml.Interop", "NotifyCollectionChangedEventHandler", "System.Collections.Specialized", "NotifyCollectionChangedEventHandler", SystemObjectModel, SystemObjectModel, Windows_UI_Xaml_Interop_NotifyCollectionChangedEventHandler, System_Collections_Specialized_NotifyCollectionChangedEventHandler, PIID(0xca10b37c, 0xf382, 0x4591, {0x85, 0x57, 0x5e, 0x24, 0x96, 0x52, 0x79, 0xb0})) -DEFINE_PROJECTED_RUNTIMECLASS("Windows.UI.Xaml.Interop", "NotifyCollectionChangedEventArgs", "System.Collections.Specialized", "NotifyCollectionChangedEventArgs", SystemObjectModel, SystemObjectModel, Windows_UI_Xaml_Interop_NotifyCollectionChangedEventArgs, System_Collections_Specialized_NotifyCollectionChangedEventArgs, "Windows.UI.Xaml.Interop.INotifyCollectionChangedEventArgs", PIID(0x4cf68d33, 0xe3f2, 0x4964, {0xb8, 0x5e, 0x94, 0x5b, 0x4f, 0x7e, 0x2f, 0x21})) -DEFINE_PROJECTED_ENUM ("Windows.UI.Xaml.Interop", "NotifyCollectionChangedAction", "System.Collections.Specialized", "NotifyCollectionChangedAction", SystemObjectModel, SystemObjectModel, Windows_UI_Xaml_Interop_NotifyCollectionChangedAction, System_Collections_Specialized_NotifyCollectionChangedAction, "Int32") - -DEFINE_PROJECTED_INTERFACE ("Windows.UI.Xaml.Data", "INotifyPropertyChanged", "System.ComponentModel", "INotifyPropertyChanged", SystemObjectModel, SystemObjectModel, Windows_UI_Xaml_Data_INotifyPropertyChanged, System_ComponentModel_INotifyPropertyChanged, PIID(0xcf75d69c, 0xf2f4, 0x486b, {0xb3, 0x02, 0xbb, 0x4c, 0x09, 0xba, 0xeb, 0xfa})) -DEFINE_PROJECTED_DELEGATE ("Windows.UI.Xaml.Data", "PropertyChangedEventHandler", "System.ComponentModel", "PropertyChangedEventHandler", SystemObjectModel, SystemObjectModel, Windows_UI_Xaml_Data_PropertyChangedEventHandler, System_ComponentModel_PropertyChangedEventHandler, PIID(0x50f19c16, 0x0a22, 0x4d8e, {0xa0, 0x89, 0x1e, 0xa9, 0x95, 0x16, 0x57, 0xd2})) -DEFINE_PROJECTED_RUNTIMECLASS("Windows.UI.Xaml.Data", "PropertyChangedEventArgs", "System.ComponentModel", "PropertyChangedEventArgs", SystemObjectModel, SystemObjectModel, Windows_UI_Xaml_Data_PropertyChangedEventArgs, System_ComponentModel_PropertyChangedEventArgs, "Windows.UI.Xaml.Data.IPropertyChangedEventArgs", PIID(0x4f33a9a0, 0x5cf4, 0x47a4, {0xb1, 0x6f, 0xd7, 0xfa, 0xaf, 0x17, 0x45, 0x7e})) - -DEFINE_PROJECTED_JUPITER_STRUCT("Windows.UI.Xaml", "CornerRadius", "Windows.UI.Xaml", "CornerRadius", SystemRuntimeWindowsRuntimeUIXaml, SystemRuntimeWindowsRuntimeUIXaml, Windows_UI_Xaml_CornerRadius, Windows_UI_Xaml_CornerRadius_clr, STRUCT_FIELDS(W("Double"), W("Double"), W("Double"), W("Double"))) -DEFINE_PROJECTED_JUPITER_STRUCT("Windows.UI.Xaml", "Duration", "Windows.UI.Xaml", "Duration", SystemRuntimeWindowsRuntimeUIXaml, SystemRuntimeWindowsRuntimeUIXaml, Windows_UI_Xaml_Duration, Windows_UI_Xaml_Duration_clr, STRUCT_FIELDS(W("Windows.Foundation.TimeSpan"), W("Windows.UI.Xaml.DurationType"))) -DEFINE_PROJECTED_ENUM ("Windows.UI.Xaml", "DurationType", "Windows.UI.Xaml", "DurationType", SystemRuntimeWindowsRuntimeUIXaml, SystemRuntimeWindowsRuntimeUIXaml, Windows_UI_Xaml_DurationType, Windows_UI_Xaml_DurationType_clr, "Int32") -DEFINE_PROJECTED_JUPITER_STRUCT("Windows.UI.Xaml", "GridLength", "Windows.UI.Xaml", "GridLength", SystemRuntimeWindowsRuntimeUIXaml, SystemRuntimeWindowsRuntimeUIXaml, Windows_UI_Xaml_GridLength, Windows_UI_Xaml_GridLength_clr, STRUCT_FIELDS(W("Double"), W("Windows.UI.Xaml.GridUnitType"))) -DEFINE_PROJECTED_ENUM ("Windows.UI.Xaml", "GridUnitType", "Windows.UI.Xaml", "GridUnitType", SystemRuntimeWindowsRuntimeUIXaml, SystemRuntimeWindowsRuntimeUIXaml, Windows_UI_Xaml_GridUnitType, Windows_UI_Xaml_GridUnitType_clr, "Int32") -DEFINE_PROJECTED_JUPITER_STRUCT("Windows.UI.Xaml", "Thickness", "Windows.UI.Xaml", "Thickness", SystemRuntimeWindowsRuntimeUIXaml, SystemRuntimeWindowsRuntimeUIXaml, Windows_UI_Xaml_Thickness, Windows_UI_Xaml_Thickness_clr, STRUCT_FIELDS(W("Double"), W("Double"), W("Double"), W("Double"))) - -DEFINE_PROJECTED_JUPITER_STRUCT("Windows.UI.Xaml.Interop", "TypeName", "System", "Type", Mscorlib, SystemRuntime, Windows_UI_Xaml_Interop_TypeName, System_Type, STRUCT_FIELDS(W("String"), W("Windows.UI.Xaml.Interop.TypeKind"))) - -DEFINE_PROJECTED_JUPITER_STRUCT("Windows.UI.Xaml.Controls.Primitives", "GeneratorPosition", "Windows.UI.Xaml.Controls.Primitives", "GeneratorPosition", SystemRuntimeWindowsRuntimeUIXaml, SystemRuntimeWindowsRuntimeUIXaml, Windows_UI_Xaml_Controls_Primitives_GeneratorPosition, Windows_UI_Xaml_Controls_Primitives_GeneratorPosition_clr, STRUCT_FIELDS(W("Int32"), W("Int32"))) - -DEFINE_PROJECTED_JUPITER_STRUCT("Windows.UI.Xaml.Media", "Matrix", "Windows.UI.Xaml.Media", "Matrix", SystemRuntimeWindowsRuntimeUIXaml, SystemRuntimeWindowsRuntimeUIXaml, Windows_UI_Xaml_Media_Matrix, Windows_UI_Xaml_Media_Matrix_clr, STRUCT_FIELDS(W("Double"), W("Double"), W("Double"), W("Double"), W("Double"), W("Double"))) - -DEFINE_PROJECTED_JUPITER_STRUCT("Windows.UI.Xaml.Media.Animation", "KeyTime", "Windows.UI.Xaml.Media.Animation", "KeyTime", SystemRuntimeWindowsRuntimeUIXaml, SystemRuntimeWindowsRuntimeUIXaml, Windows_UI_Xaml_Media_Animation_KeyTime, Windows_UI_Xaml_Media_Animation_KeyTime_clr, STRUCT_FIELDS(W("Windows.Foundation.TimeSpan"))) -DEFINE_PROJECTED_JUPITER_STRUCT("Windows.UI.Xaml.Media.Animation", "RepeatBehavior", "Windows.UI.Xaml.Media.Animation", "RepeatBehavior", SystemRuntimeWindowsRuntimeUIXaml, SystemRuntimeWindowsRuntimeUIXaml, Windows_UI_Xaml_Media_Animation_RepeatBehavior, Windows_UI_Xaml_Media_Animation_RepeatBehavior_clr, STRUCT_FIELDS(W("Double"), W("Windows.Foundation.TimeSpan"), W("Windows.UI.Xaml.Media.Animation.RepeatBehaviorType"))) -DEFINE_PROJECTED_ENUM ("Windows.UI.Xaml.Media.Animation", "RepeatBehaviorType", "Windows.UI.Xaml.Media.Animation", "RepeatBehaviorType", SystemRuntimeWindowsRuntimeUIXaml, SystemRuntimeWindowsRuntimeUIXaml, Windows_UI_Xaml_Media_Animation_RepeatBehaviorType, Windows_UI_Xaml_Media_Animation_RepeatBehaviorType_clr, "Int32") - -DEFINE_PROJECTED_JUPITER_STRUCT("Windows.UI.Xaml.Media.Media3D", "Matrix3D", "Windows.UI.Xaml.Media.Media3D", "Matrix3D", SystemRuntimeWindowsRuntimeUIXaml, SystemRuntimeWindowsRuntimeUIXaml, Windows_UI_Xaml_Media_Media3D_Matrix3D, Windows_UI_Xaml_Media_Media3D_Matrix3D_clr, STRUCT_FIELDS(W("Double"), W("Double"), W("Double"), W("Double"), W("Double"), W("Double"), W("Double"), W("Double"), W("Double"), W("Double"), W("Double"), W("Double"), W("Double"), W("Double"), W("Double"), W("Double"))) - -DEFINE_PROJECTED_STRUCT ("Windows.Foundation.Numerics", "Vector2", "System.Numerics", "Vector2", SystemNumericsVectors, SystemNumericsVectors, Windows_Foundation_Numerics_Vector2, System_Numerics_Vector2, STRUCT_FIELDS(L"Single", L"Single")) -DEFINE_PROJECTED_STRUCT ("Windows.Foundation.Numerics", "Vector3", "System.Numerics", "Vector3", SystemNumericsVectors, SystemNumericsVectors, Windows_Foundation_Numerics_Vector3, System_Numerics_Vector3, STRUCT_FIELDS(L"Single", L"Single", L"Single")) -DEFINE_PROJECTED_STRUCT ("Windows.Foundation.Numerics", "Vector4", "System.Numerics", "Vector4", SystemNumericsVectors, SystemNumericsVectors, Windows_Foundation_Numerics_Vector4, System_Numerics_Vector4, STRUCT_FIELDS(L"Single", L"Single", L"Single", L"Single")) -DEFINE_PROJECTED_STRUCT ("Windows.Foundation.Numerics", "Matrix3x2", "System.Numerics", "Matrix3x2", SystemNumericsVectors, SystemNumericsVectors, Windows_Foundation_Numerics_Matrix3x2, System_Numerics_Matrix3x2, STRUCT_FIELDS(L"Single", L"Single", L"Single", L"Single", L"Single", L"Single")) -DEFINE_PROJECTED_STRUCT ("Windows.Foundation.Numerics", "Matrix4x4", "System.Numerics", "Matrix4x4", SystemNumericsVectors, SystemNumericsVectors, Windows_Foundation_Numerics_Matrix4x4, System_Numerics_Matrix4x4, STRUCT_FIELDS(L"Single", L"Single", L"Single", L"Single", L"Single", L"Single", L"Single", L"Single", L"Single", L"Single", L"Single", L"Single", L"Single", L"Single", L"Single", L"Single")) -DEFINE_PROJECTED_STRUCT ("Windows.Foundation.Numerics", "Plane", "System.Numerics", "Plane", SystemNumericsVectors, SystemNumericsVectors, Windows_Foundation_Numerics_Plane, System_Numerics_Plane, STRUCT_FIELDS(L"Windows.Foundation.Numerics.Vector3", L"Single")) -DEFINE_PROJECTED_STRUCT ("Windows.Foundation.Numerics", "Quaternion", "System.Numerics", "Quaternion", SystemNumericsVectors, SystemNumericsVectors, Windows_Foundation_Numerics_Quaternion, System_Numerics_Quaternion, STRUCT_FIELDS(L"Single", L"Single", L"Single", L"Single")) - -#ifdef DEFINE_PROJECTED_ATTRIBUTETARGETS_VALUE - -// Windows.Foundation.Metadata.AttributeTarget and System.AttributeTarget enum -// define different bits for everything (@todo: Be nice to change that before we ship.) -// -// This table encapsulates the correspondence. NOTE: Some rows in the CLR column store a 0 -// to indicate that the CLR has no corresponding bit for the WinRT value. -// -// WinRT CLR -DEFINE_PROJECTED_ATTRIBUTETARGETS_VALUE(0x00000001, 0x00001000) // AttributeTargets.Delegate -DEFINE_PROJECTED_ATTRIBUTETARGETS_VALUE(0x00000002, 0x00000010) // AttributeTargets.Enum -DEFINE_PROJECTED_ATTRIBUTETARGETS_VALUE(0x00000004, 0x00000200) // AttributeTargets.Event -DEFINE_PROJECTED_ATTRIBUTETARGETS_VALUE(0x00000008, 0x00000100) // AttributeTargets.Field -DEFINE_PROJECTED_ATTRIBUTETARGETS_VALUE(0x00000010, 0x00000400) // AttributeTargets.Interface -DEFINE_PROJECTED_ATTRIBUTETARGETS_VALUE(0x00000020, 0x00000000) // AttributeTargets.InterfaceGroup (no equivalent in CLR) -DEFINE_PROJECTED_ATTRIBUTETARGETS_VALUE(0x00000040, 0x00000040) // AttributeTargets.Method -DEFINE_PROJECTED_ATTRIBUTETARGETS_VALUE(0x00000080, 0x00000800) // AttributeTargets.Parameter -DEFINE_PROJECTED_ATTRIBUTETARGETS_VALUE(0x00000100, 0x00000080) // AttributeTargets.Property -DEFINE_PROJECTED_ATTRIBUTETARGETS_VALUE(0x00000200, 0x00000004) // AttributeTargets.RuntimeClass <--> Class -DEFINE_PROJECTED_ATTRIBUTETARGETS_VALUE(0x00000400, 0x00000008) // AttributeTargets.Struct -DEFINE_PROJECTED_ATTRIBUTETARGETS_VALUE(0x00000800, 0x00000000) // AttributeTargets.InterfaceImpl (no equivalent in CLR) - -#endif // #ifdef DEFINE_PROJECTED_ATTRIBUTETARGETS_VALUES - - -DEFINE_HIDDEN_WINRT_TYPE("Windows.Foundation.Metadata", "GCPressureAttribute") -DEFINE_HIDDEN_WINRT_TYPE("Windows.Foundation.Metadata", "GCPressureAmount") - -DEFINE_HIDDEN_WINRT_TYPE("Windows.Foundation", "IPropertyValue") -DEFINE_HIDDEN_WINRT_TYPE("Windows.Foundation", "IReferenceArray`1") - - -#ifdef __LOCAL_DEFINE_PROJECTED_RUNTIMECLASS -#undef DEFINE_PROJECTED_RUNTIMECLASS -#endif // __LOCAL_DEFINE_PROJECTED_RUNTIMECLASS - -#ifdef __LOCAL_DEFINE_PROJECTED_STRUCT -#undef DEFINE_PROJECTED_STRUCT -#endif // __LOCAL_DEFINE_PROJECTED_STRUCT - -#ifdef __LOCAL_DEFINE_PROJECTED_JUPITER_STRUCT -#undef DEFINE_PROJECTED_JUPITER_STRUCT -#endif // __LOCAL_DEFINE_PROJECTED_JUPITER_STRUCT - -#ifdef __LOCAL_DEFINE_PROJECTED_ENUM -#undef DEFINE_PROJECTED_ENUM -#endif // __LOCAL_DEFINE_PROJECTED_ENUM - -#ifdef __LOCAL_DEFINE_PROJECTED_INTERFACE -#undef DEFINE_PROJECTED_INTERFACE -#endif // __LOCAL_DEFINE_PROJECTED_INTERFACE - -#ifdef __LOCAL_DEFINE_PROJECTED_PINTERFACE -#undef DEFINE_PROJECTED_PINTERFACE -#endif // __LOCAL_DEFINE_PROJECTED_PINTERFACE - -#ifdef __LOCAL_DEFINE_PROJECTED_DELEGATE -#undef DEFINE_PROJECTED_DELEGATE -#endif // __LOCAL_DEFINE_PROJECTED_DELEGATE - -#ifdef __LOCAL_DEFINE_PROJECTED_PDELEGATE -#undef DEFINE_PROJECTED_PDELEGATE -#endif // __LOCAL_DEFINE_PROJECTED_PDELEGATE - -#ifdef __LOCAL_DEFINE_PROJECTED_ATTRIBUTE -#undef DEFINE_PROJECTED_ATTRIBUTE -#endif // __LOCAL_DEFINE_PROJECTED_ATTRIBUTE - -#ifdef __LOCAL_DEFINE_HIDDEN_WINRT_TYPE -#undef DEFINE_HIDDEN_WINRT_TYPE -#endif // __LOCAL_DEFINE_HIDDEN_WINRT_TYPE - -#undef JUPITER_PROJECTION_NS -#undef JUPITER_PROJECTION_CONTROLS_PRIMITIVES_NS -#undef JUPITER_PROJECTION_MEDIA_NS -#undef JUPITER_PROJECTION_MEDIA_ANIMATION_NS -#undef JUPITER_PROJECTION_MEDIA_3D_NS -#undef JUPITER_FOUNDATION_PROJECTION_NS diff --git a/src/inc/winwrap.h b/src/inc/winwrap.h deleted file mode 100644 index acd70d52d..000000000 --- a/src/inc/winwrap.h +++ /dev/null @@ -1,556 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -//***************************************************************************** -// WinWrap.h -// -// This file contains wrapper functions for Win32 API's that take strings. -// -// The Common Language Runtime internally uses UNICODE as the internal state -// and string format. This file will undef the mapping macros so that one -// cannot mistakingly call a method that isn't going to work. Instead, you -// have to call the correct wrapper API. -// -//***************************************************************************** - -#ifndef __WIN_WRAP_H__ -#define __WIN_WRAP_H__ - -//********** Macros. ********************************************************** -#if !defined(WIN32_LEAN_AND_MEAN) -#define WIN32_LEAN_AND_MEAN -#endif - -// -// WinCE uniformly uses cdecl calling convention on x86. __stdcall is defined as __cdecl in SDK. -// STDCALL macro is meant to be used where we have hard dependency on __stdcall calling convention -// - the unification with __cdecl does not apply to STDCALL. -// -#define STDCALL _stdcall - -//********** Includes. ******************************************************** - -#include -#include -#include -#include - -#include "registrywrapper.h" -#include "longfilepathwrappers.h" - -#if defined(_PREFAST_) || defined(SOURCE_FORMATTING) -// -// For PREFAST we don't want the C_ASSERT to be expanded since it always -// involves the comparison of two constants which causes PREfast warning 326 -// -#undef C_ASSERT -#define C_ASSERT(expr) -#endif - -#include "palclr.h" - -#if !defined(__TODO_PORT_TO_WRAPPERS__) -//***************************************************************************** -// Undefine all of the windows wrappers so you can't use them. -//***************************************************************************** - -// wincrypt.h -#undef CryptAcquireContext -#undef CryptSignHash -#undef CryptVerifySignature - -// winbase.h -#undef GetBinaryType -#undef GetShortPathName -#undef GetLongPathName -#undef GetEnvironmentStrings -#undef FreeEnvironmentStrings -#undef FormatMessage -#undef lstrcmp -#undef lstrcmpi -#undef lstrcpyn -#undef lstrlen -#undef CreateMutex -#undef OpenMutex -#undef CreateEvent -#undef OpenEvent -#undef CreateSemaphore -#undef OpenSemaphore -#undef CreateWaitableTimer -#undef CreateFileMapping -#undef OpenFileMapping -#undef LoadLibrary -#undef LoadLibraryEx -#undef GetModuleFileName -#undef GetModuleHandle -#undef GetModuleHandleEx -#undef CreateProcess -#undef GetCommandLine -#undef GetEnvironmentVariable -#undef SetEnvironmentVariable -#undef ExpandEnvironmentStrings -#undef OutputDebugString -#undef FindResource -#undef FindResourceEx -#undef BeginUpdateResource -#undef UpdateResource -#undef EndUpdateResource -#undef GetPrivateProfileInt -#undef GetSystemDirectory -#undef GetTempPath -#undef GetTempFileName -#undef SetCurrentDirectory -#undef GetCurrentDirectory -#undef CreateDirectory -#undef RemoveDirectory -#undef GetFullPathName -#undef CreateFile -#undef SetFileAttributes -#undef GetFileAttributes -#undef GetFileAttributesEx -#undef DeleteFile -#undef FindFirstFileEx -#undef FindFirstFile -#undef FindNextFile -#undef SearchPath -#undef CopyFile -#undef CopyFileEx -#undef MoveFile -#undef MoveFileEx -#undef CreateHardLink -#undef CreateNamedPipe -#undef WaitNamedPipe -#undef LookupPrivilegeValue -#undef GetVersionEx - -// winuser.h -#undef MAKEINTRESOURCE -#undef GetUserObjectInformation -#undef GetMessage - -#undef SendMessage -#undef CharLower -#undef CharNext -#undef MessageBox -#undef GetClassName -#undef LoadString -#undef GetCalendarInfo -#undef GetDateFormat -#undef GetTimeFormat -#undef LCMapString - -// winnetwk.h -#undef WNetGetConnection - -// Win32 Fusion API's -#undef QueryActCtxW - -#endif // !defined(__TODO_PORT_TO_WRAPPERS__) - -// -// NT supports the wide entry points. So we redefine the wrappers right back -// to the *W entry points as macros. This way no client code needs a wrapper on NT. -// - -// wincrypt.h -#define WszCryptAcquireContext CryptAcquireContextW -#define WszCryptSignHash CryptSignHashW -#define WszCryptVerifySignature CryptVerifySignatureW - -// winbase.h -#define WszGetEnvironmentStrings GetEnvironmentStringsW -#define WszFreeEnvironmentStrings FreeEnvironmentStringsW -#ifndef USE_FORMATMESSAGE_WRAPPER -#define WszFormatMessage FormatMessageW -#else -#define WszFormatMessage CCompRC::FormatMessage -#endif -#define Wszlstrcmp lstrcmpW -#define Wszlstrcmpi lstrcmpiW -#define WszCreateMutex CreateMutexW -#define WszOpenMutex OpenMutexW -#define WszCreateEvent CreateEventW -#define WszOpenEvent OpenEventW -#define WszCreateWaitableTimer CreateWaitableTimerW -#define WszCreateFileMapping CreateFileMappingW -#define WszOpenFileMapping OpenFileMappingW -#define WszGetModuleHandle GetModuleHandleW -#define WszGetModuleHandleEx GetModuleHandleExW -#define WszGetCommandLine GetCommandLineW -#define WszSetEnvironmentVariable SetEnvironmentVariableW -#define WszExpandEnvironmentStrings ExpandEnvironmentStringsW -#define WszOutputDebugString OutputDebugStringW -#define WszFindResource FindResourceW -#define WszFindResourceEx FindResourceExW -#define WszBeginUpdateResource BeginUpdateResourceW -#define WszUpdateResource UpdateResourceW -#define WszEndUpdateResource EndUpdateResourceW -#define WszGetPrivateProfileInt GetPrivateProfileIntW -#define WszGetSystemDirectory GetSystemDirectoryW -#define WszCreateNamedPipe CreateNamedPipeW -#define WszWaitNamedPipe WaitNamedPipeW -#define WszLookupPrivilegeValue LookupPrivilegeValueW - -// winuser.h -#define WszMAKEINTRESOURCE MAKEINTRESOURCEW -#define WszGetUserObjectInformation GetUserObjectInformationW -#define WszGetMessage GetMessageW -#define WszSendMessage SendMessageW -#define WszCharLower CharLowerW -#define WszCharNext CharNextW -#define WszMessageBox LateboundMessageBoxW -#define WszGetClassName GetClassNameW -#define WszLoadString LoadStringW -#define WszRegOpenKeyEx ClrRegOpenKeyEx -#define WszRegOpenKey(hKey, wszSubKey, phkRes) ClrRegOpenKeyEx(hKey, wszSubKey, 0, KEY_ALL_ACCESS, phkRes) -#define WszRegQueryValue RegQueryValueW -#define WszRegQueryValueEx RegQueryValueExW -#define WszRegQueryValueExTrue RegQueryValueExW -#define WszRegQueryStringValueEx RegQueryValueExW - - -#define WszRegQueryInfoKey RegQueryInfoKeyW -#define WszRegEnumValue RegEnumValueW -#define WszRegEnumKeyEx RegEnumKeyExW -#define WszGetCalendarInfo GetCalendarInfoW -#define WszGetDateFormat GetDateFormatW -#define WszGetTimeFormat GetTimeFormatW -#define WszLCMapString LCMapStringW -#define WszMultiByteToWideChar MultiByteToWideChar -#define WszWideCharToMultiByte WideCharToMultiByte -#define WszCreateSemaphore CreateSemaphoreW -#define WszQueryActCtxW QueryActCtxW - - -#ifdef FEATURE_CORESYSTEM - -// CoreSystem has CreateSemaphoreExW but not CreateSemaphoreW. -#undef WszCreateSemaphore -#define WszCreateSemaphore(_secattr, _count, _maxcount, _name) CreateSemaphoreExW((_secattr), (_count), (_maxcount), (_name), 0, MAXIMUM_ALLOWED | SYNCHRONIZE | SEMAPHORE_MODIFY_STATE) - -// Same deal as above for GetFileVersionInfo/GetFileVersionInfoSize. -#undef GetFileVersionInfo -#define GetFileVersionInfo(_filename, _handle, _len, _data) GetFileVersionInfoEx(0, (_filename), (_handle), (_len), (_data)) -#undef GetFileVersionInfoSize -#define GetFileVersionInfoSize(_filename, _handle) GetFileVersionInfoSizeEx(0, (_filename), (_handle)) - -#endif // FEATURE_CORESYSTEM - -#ifndef _T -#define _T(str) W(str) -#endif - -//File and Directory Functions which need special handling for LongFile Names -//Note only the functions which are currently used are defined -#define WszLoadLibrary LoadLibraryExWrapper -#define WszLoadLibraryEx LoadLibraryExWrapper -#define WszCreateFile CreateFileWrapper -#define WszSetFileAttributes SetFileAttributesWrapper -#define WszGetFileAttributes GetFileAttributesWrapper -#define WszGetFileAttributesEx GetFileAttributesExWrapper -#define WszDeleteFile DeleteFileWrapper -#define WszFindFirstFileEx FindFirstFileExWrapper -#define WszFindNextFile FindNextFileW -#define WszCopyFile CopyFileWrapper -#define WszCopyFileEx CopyFileExWrapper -#define WszMoveFileEx MoveFileExWrapper -#define WszMoveFile(lpExistingFileName, lpNewFileName) WszMoveFileEx(lpExistingFileName, lpNewFileName, 0) -#define WszCreateDirectory CreateDirectoryWrapper -#define WszRemoveDirectory RemoveDirectoryWrapper -#define WszCreateHardLink CreateHardLinkWrapper - -//Can not use extended syntax -#define WszGetFullPathName GetFullPathNameW - -//Long Files will not work on these till redstone -#define WszGetCurrentDirectory GetCurrentDirectoryWrapper -#define WszGetTempFileName GetTempFileNameWrapper -#define WszGetTempPath GetTempPathWrapper - -//APIS which have a buffer as an out parameter -#define WszGetEnvironmentVariable GetEnvironmentVariableWrapper -#define WszSearchPath SearchPathWrapper -#define WszGetShortPathName GetShortPathNameWrapper -#define WszGetLongPathName GetLongPathNameWrapper -#define WszGetModuleFileName GetModuleFileNameWrapper - -//NOTE: IF the following API's are enabled ensure that they can work with LongFile Names -//See the usage and implementation of above API's -// -//#define WszSetCurrentDirectory SetCurrentDirectoryW -//#define WszGetBinaryType GetBinaryTypeWrapper //Coresys does not seem to have this API - -#if FEATURE_PAL -#define WszFindFirstFile FindFirstFileW -#else -#define WszFindFirstFile(_lpFileName_, _lpFindData_) FindFirstFileExWrapper(_lpFileName_, FindExInfoStandard, _lpFindData_, FindExSearchNameMatch, NULL, 0) -#endif //FEATURE_PAL -//***************************************************************************** -// Prototypes for API's. -//***************************************************************************** - -extern DWORD g_dwMaxDBCSCharByteSize; - -void EnsureCharSetInfoInitialized(); - -inline DWORD GetMaxDBCSCharByteSize() -{ - // contract.h not visible here - __annotation(W("WRAPPER ") W("GetMaxDBCSCharByteSize")); -#ifndef FEATURE_PAL - EnsureCharSetInfoInitialized(); - - _ASSERTE(g_dwMaxDBCSCharByteSize != 0); - return (g_dwMaxDBCSCharByteSize); -#else // FEATURE_PAL - return 3; -#endif // FEATURE_PAL -} - -#ifndef FEATURE_PAL -BOOL RunningInteractive(); -#else // !FEATURE_PAL -#define RunningInteractive() FALSE -#endif // !FEATURE_PAL - -// Determines if the process is running as Local System or as a service. Note that this function uses the -// process' identity and not the thread's (if the thread is impersonating). -// -// If the function succeeds, it returns ERROR_SUCCESS, else it returns the error code returned by GetLastError() -DWORD RunningAsLocalSystemOrService(OUT BOOL& fIsLocalSystemOrService); - -#ifndef Wsz_mbstowcs -#define Wsz_mbstowcs(szOut, szIn, iSize) WszMultiByteToWideChar(CP_ACP, 0, szIn, -1, szOut, iSize) -#endif - -#ifndef Wsz_wcstombs -#define Wsz_wcstombs(szOut, szIn, iSize) WszWideCharToMultiByte(CP_ACP, 0, szIn, -1, szOut, iSize, 0, 0) -#endif - -// For all platforms: - -BOOL -WszCreateProcess( - LPCWSTR lpApplicationName, - LPCWSTR lpCommandLine, - LPSECURITY_ATTRIBUTES lpProcessAttributes, - LPSECURITY_ATTRIBUTES lpThreadAttributes, - BOOL bInheritHandles, - DWORD dwCreationFlags, - LPVOID lpEnvironment, - LPCWSTR lpCurrentDirectory, - LPSTARTUPINFOW lpStartupInfo, - LPPROCESS_INFORMATION lpProcessInformation - ); - -#if defined(_X86_) && defined(_MSC_VER) - -// -// Windows SDK does not use intrinsics on x86. Redefine the interlocked operations to use intrinsics. -// - -#include "intrin.h" - -#define InterlockedIncrement _InterlockedIncrement -#define InterlockedDecrement _InterlockedDecrement -#define InterlockedExchange _InterlockedExchange -#define InterlockedCompareExchange _InterlockedCompareExchange -#define InterlockedExchangeAdd _InterlockedExchangeAdd -#define InterlockedCompareExchange64 _InterlockedCompareExchange64 -#define InterlockedAnd _InterlockedAnd -#define InterlockedOr _InterlockedOr - -// -// There is no _InterlockedCompareExchangePointer intrinsic in VC++ for x86. -// winbase.h #defines InterlockedCompareExchangePointer as __InlineInterlockedCompareExchangePointer, -// which calls the Win32 InterlockedCompareExchange, not the intrinsic _InterlockedCompareExchange. -// We want the intrinsic, so we #undef the Windows version of this API, and define our own. -// -#ifdef InterlockedCompareExchangePointer -#undef InterlockedCompareExchangePointer -#endif - -FORCEINLINE -PVOID -InterlockedCompareExchangePointer ( - __inout PVOID volatile *Destination, - __in_opt PVOID ExChange, - __in_opt PVOID Comperand - ) -{ - return((PVOID)(LONG_PTR)_InterlockedCompareExchange((LONG volatile *)Destination, (LONG)(LONG_PTR)ExChange, (LONG)(LONG_PTR)Comperand)); -} - -#endif // _X86_ && _MSC_VER - -#if defined(_ARM_) & !defined(FEATURE_PAL) -// -// InterlockedCompareExchangeAcquire/InterlockedCompareExchangeRelease is not mapped in SDK to the correct intrinsics. Remove once -// the SDK definition is fixed (OS Bug #516255) -// -#undef InterlockedCompareExchangeAcquire -#define InterlockedCompareExchangeAcquire _InterlockedCompareExchange_acq -#undef InterlockedCompareExchangeRelease -#define InterlockedCompareExchangeRelease _InterlockedCompareExchange_rel -#endif - -#if defined(_X86_) & !defined(InterlockedIncrement64) - -// Interlockedxxx64 that do not have intrinsics are only supported on Windows Server 2003 -// or higher for X86 so define our own portable implementation - -#undef InterlockedIncrement64 -#define InterlockedIncrement64 __InterlockedIncrement64 -#undef InterlockedDecrement64 -#define InterlockedDecrement64 __InterlockedDecrement64 -#undef InterlockedExchange64 -#define InterlockedExchange64 __InterlockedExchange64 -#undef InterlockedExchangeAdd64 -#define InterlockedExchangeAdd64 __InterlockedExchangeAdd64 - -__forceinline LONGLONG __InterlockedIncrement64(LONGLONG volatile *Addend) -{ - LONGLONG Old; - - do { - Old = *Addend; - } while (InterlockedCompareExchange64(Addend, - Old + 1, - Old) != Old); - - return Old + 1; -} - -__forceinline LONGLONG __InterlockedDecrement64(LONGLONG volatile *Addend) -{ - LONGLONG Old; - - do { - Old = *Addend; - } while (InterlockedCompareExchange64(Addend, - Old - 1, - Old) != Old); - - return Old - 1; -} - -__forceinline LONGLONG __InterlockedExchange64(LONGLONG volatile * Target, LONGLONG Value) -{ - LONGLONG Old; - - do { - Old = *Target; - } while (InterlockedCompareExchange64(Target, - Value, - Old) != Old); - - return Old; -} - -__forceinline LONGLONG __InterlockedExchangeAdd64(LONGLONG volatile * Addend, LONGLONG Value) -{ - LONGLONG Old; - - do { - Old = *Addend; - } while (InterlockedCompareExchange64(Addend, - Old + Value, - Old) != Old); - - return Old; -} - -#endif // _X86_ - -// Output printf-style formatted text to the debugger if it's present or stdout otherwise. -inline void DbgWPrintf(const LPCWSTR wszFormat, ...) -{ - WCHAR wszBuffer[4096]; - - va_list args; - va_start(args, wszFormat); - - _vsnwprintf_s(wszBuffer, sizeof(wszBuffer) / sizeof(WCHAR), _TRUNCATE, wszFormat, args); - - va_end(args); - - if (IsDebuggerPresent()) - { - OutputDebugStringW(wszBuffer); - } - else - { - fwprintf(stdout, W("%s"), wszBuffer); - fflush(stdout); - } -} - -typedef int (*MessageBoxWFnPtr)(HWND hWnd, - LPCWSTR lpText, - LPCWSTR lpCaption, - UINT uType); - -inline int LateboundMessageBoxW(HWND hWnd, - LPCWSTR lpText, - LPCWSTR lpCaption, - UINT uType) -{ -#ifndef FEATURE_PAL - // User32 should exist on all systems where displaying a message box makes sense. - HMODULE hGuiExtModule = WszLoadLibrary(W("user32")); - if (hGuiExtModule) - { - int result = IDCANCEL; - MessageBoxWFnPtr fnptr = (MessageBoxWFnPtr)GetProcAddress(hGuiExtModule, "MessageBoxW"); - if (fnptr) - result = fnptr(hWnd, lpText, lpCaption, uType); - - FreeLibrary(hGuiExtModule); - return result; - } -#endif // !FEATURE_PAL - - // No luck. Output the caption and text to the debugger if present or stdout otherwise. - if (lpText == NULL) - lpText = W(""); - if (lpCaption == NULL) - lpCaption = W(""); - DbgWPrintf(W("**** MessageBox invoked, title '%s' ****\n"), lpCaption); - DbgWPrintf(W(" %s\n"), lpText); - DbgWPrintf(W("********\n")); - DbgWPrintf(W("\n")); - - // Indicate to the caller that message box was not actually displayed - SetLastError(ERROR_NOT_SUPPORTED); - return 0; -} - -inline int LateboundMessageBoxA(HWND hWnd, - LPCSTR lpText, - LPCSTR lpCaption, - UINT uType) -{ - if (lpText == NULL) - lpText = ""; - if (lpCaption == NULL) - lpCaption = ""; - - SIZE_T cchText = strlen(lpText) + 1; - LPWSTR wszText = (LPWSTR)_alloca(cchText * sizeof(WCHAR)); - swprintf_s(wszText, cchText, W("%S"), lpText); - - SIZE_T cchCaption = strlen(lpCaption) + 1; - LPWSTR wszCaption = (LPWSTR)_alloca(cchCaption * sizeof(WCHAR)); - swprintf_s(wszCaption, cchCaption, W("%S"), lpCaption); - - return LateboundMessageBoxW(hWnd, wszText, wszCaption, uType); -} - -#if defined(FEATURE_CORESYSTEM) && !defined(CROSSGEN_COMPILE) - -#define MessageBoxW LateboundMessageBoxW -#define MessageBoxA LateboundMessageBoxA - -#endif // FEATURE_CORESYSTEM - -#endif // __WIN_WRAP_H__ diff --git a/src/inc/zapper.h b/src/inc/zapper.h deleted file mode 100644 index 8160b52f2..000000000 --- a/src/inc/zapper.h +++ /dev/null @@ -1,451 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#ifndef ZAPPER_H_ -#define ZAPPER_H_ - -#include -#include -#include -#include -#include -#include -#include - -#include "sarray.h" -#include "sstring.h" -#include "shash.h" -#include "utilcode.h" -#include "corjit.h" -#include "corcompile.h" -#include "corhlprpriv.h" -#include "ngen.h" -#include "corbbtprof.h" -#include "pedecoder.h" -#include "mscorsvc.h" -#include "holderinst.h" -#include "corpriv.h" - -// For side by side issues, it's best to use the exported API calls to generate a -// Zapper Object instead of creating one on your own. - -STDAPI NGenCreateNGenWorker(ICorSvcWorker **pCorSvcWorker, ILocalServerLifetime *pLocalServerLifetime, ICorSvcLogger *pCorSvcLogger); -STDAPI NGenCreateZapper(HANDLE* hZapper, NGenOptions* opt); -STDAPI NGenFreeZapper(HANDLE hZapper); -STDAPI NGenTryEnumerateFusionCache(HANDLE hZapper, LPCWSTR assemblyName, bool fPrint, bool fDelete); -STDAPI_(BOOL) NGenCompile(HANDLE hZapper, LPCWSTR path); - - -/* --------------------------------------------------------------------------- * - * Zapper classes - * --------------------------------------------------------------------------- */ - -class ZapperOptions; -class ZapperAttributionStats; -class ZapImage; -class ZapInfo; - -typedef enum CorZapLogLevel -{ - CORZAP_LOGLEVEL_ERROR, - CORZAP_LOGLEVEL_WARNING, - CORZAP_LOGLEVEL_SUCCESS, - CORZAP_LOGLEVEL_INFO, -} CorZapLogLevel; - -class Zapper -{ - friend class ZapImage; - friend class ZapInfo; - friend class ZapILMetaData; - - private: - - // - // Interfaces - // - - ICorDynamicInfo *m_pEEJitInfo; - ICorCompileInfo *m_pEECompileInfo; - ICorJitCompiler *m_pJitCompiler; - IMetaDataDispenserEx *m_pMetaDataDispenser; - HMODULE m_hJitLib; -#ifdef _TARGET_AMD64_ - HMODULE m_hJitLegacy; -#endif - -#ifdef ALLOW_SXS_JIT_NGEN - ICorJitCompiler *m_alternateJit; - HMODULE m_hAltJITCompiler; -#endif // ALLOW_SXS_JIT_NGEN - - // - // Options - // - - ZapperOptions * m_pOpt; - BOOL m_fFreeZapperOptions; - - SString m_exeName; // If an EXE is specified - - bool m_fromDllHost; - - // - // Current assembly info - // - - ICorCompilationDomain *m_pDomain; - CORINFO_ASSEMBLY_HANDLE m_hAssembly; - IMDInternalImport *m_pAssemblyImport; - - SString m_outputPath; // Temp folder for creating the output file - - IMetaDataAssemblyEmit *m_pAssemblyEmit; - IMetaDataAssemblyEmit *CreateAssemblyEmitter(); - - // - // - // Status info - // - - BOOL m_failed; - CorInfoRegionKind m_currentRegionKind; - - SString m_platformAssembliesPaths; - SString m_trustedPlatformAssemblies; - SString m_platformResourceRoots; - SString m_appPaths; - SString m_appNiPaths; - SString m_platformWinmdPaths; - -#if !defined(FEATURE_MERGE_JIT_AND_ENGINE) - SString m_CLRJITPath; - bool m_fDontLoadJit; -#endif // !defined(FEATURE_MERGE_JIT_AND_ENGINE) -#if !defined(NO_NGENPDB) - SString m_DiasymreaderPath; -#endif // !defined(NO_NGENPDB) - - SString m_outputFilename; - - public: - - struct assemblyDependencies - { - struct DependencyEntry - { - BSTR bstr; - LoadHintEnum loadHint; - NGenHintEnum ngenHint; - }; - - SArray dependencyArray; - NGenHintEnum ngenHint; - SString displayName; - - assemblyDependencies() - { - Initialize(); - ngenHint = NGenDefault; - } - - ~assemblyDependencies() - { - Cleanup(); - } - - void Reinitialize() - { - Cleanup(); - Initialize(); - } - - void SetNGenHint(NGenHintEnum ngenHint) - { - this->ngenHint = ngenHint; - } - - NGenHintEnum GetNGenHint() - { - return ngenHint; - } - - void SetDisplayName(const WCHAR *pStr) - { - displayName.Set(pStr); - } - - const WCHAR *GetDisplayName() - { - return displayName.GetUnicode(); - } - - void Append(const WCHAR *pStr, LoadHintEnum loadHint = LoadDefault, NGenHintEnum ngenHint = NGenDefault) - { - // Don't append string if it's a duplicate - for (COUNT_T i = 0; i < dependencyArray.GetCount(); i++) - { - if (wcscmp(dependencyArray[i].bstr, pStr) == 0) - return; - } - - BSTRHolder bstr(::SysAllocString(pStr)); - DependencyEntry dependencyEntry; - dependencyEntry.bstr = bstr.GetValue(); - dependencyEntry.loadHint = loadHint; - dependencyEntry.ngenHint = ngenHint; - - dependencyArray.Append(dependencyEntry); - bstr.SuppressRelease(); - } - - SAFEARRAY *GetSAFEARRAY() - { - SafeArrayHolder pDependencies(SafeArrayCreateVector(VT_BSTR, 0, dependencyArray.GetCount())); - if (pDependencies.GetValue() == NULL) ThrowLastError(); - - for (COUNT_T i = 0; i < dependencyArray.GetCount(); i++) - { - LONG indices[1]; - indices[0] = (LONG) i; - IfFailThrow(SafeArrayPutElement(pDependencies, indices, this->dependencyArray[i].bstr)); - } - - pDependencies.SuppressRelease(); - return pDependencies.GetValue(); - } - - SAFEARRAY *GetLoadHintSAFEARRAY() - { - SafeArrayHolder pSettings(SafeArrayCreateVector(VT_UI4, 0, dependencyArray.GetCount())); - if (pSettings.GetValue() == NULL) ThrowLastError(); - - for (COUNT_T i = 0; i < dependencyArray.GetCount(); i++) - { - LONG indices[1]; - indices[0] = (LONG) i; - IfFailThrow(SafeArrayPutElement(pSettings, indices, &this->dependencyArray[i].loadHint)); - } - - pSettings.SuppressRelease(); - return pSettings.GetValue(); - } - - SAFEARRAY *GetNGenHintSAFEARRAY() - { - SafeArrayHolder pSettings(SafeArrayCreateVector(VT_UI4, 0, dependencyArray.GetCount())); - if (pSettings.GetValue() == NULL) ThrowLastError(); - - for (COUNT_T i = 0; i < dependencyArray.GetCount(); i++) - { - LONG indices[1]; - indices[0] = (LONG) i; - IfFailThrow(SafeArrayPutElement(pSettings, indices, &this->dependencyArray[i].ngenHint)); - } - - pSettings.SuppressRelease(); - return pSettings.GetValue(); - } - - private: - void Initialize() - { - dependencyArray.SetCount(0); - // Should we reinitialize ngenHint to the default value as well? - } - - void Cleanup() - { - for (COUNT_T i = 0; i < dependencyArray.GetCount(); i++) - { - ::SysFreeString(dependencyArray[i].bstr); - } - } - } m_assemblyDependencies; - - - public: - - Zapper(ZapperOptions *pOpt); - Zapper(NGenOptions *pOpt, bool fromDllHost = false); - - void Init(ZapperOptions *pOpt, bool fFreeZapperOptions= false); - - static Zapper *NewZapper(NGenOptions *pOpt, bool fromDllHost = false) - { - CONTRACTL - { - THROWS; - GC_NOTRIGGER; - } - CONTRACTL_END; - return new Zapper(pOpt, fromDllHost); - } - - ~Zapper(); - - // The arguments control which native image of mscorlib to use. - // This matters for hardbinding. - void InitEE(BOOL fForceDebug, BOOL fForceProfile, BOOL fForceInstrument); - void LoadAndInitializeJITForNgen(LPCWSTR pwzJitName, OUT HINSTANCE* phJit, OUT ICorJitCompiler** ppICorJitCompiler); - - - BOOL IsAssembly(LPCWSTR path); - - void CreateDependenciesLookupDomain(); - void ComputeDependencies(LPCWSTR pAssemblyName, CORCOMPILE_NGEN_SIGNATURE * pNativeImageSig); - void ComputeAssemblyDependencies(CORINFO_ASSEMBLY_HANDLE hAssembly); - - void CreatePdb(BSTR pAssemblyPathOrName, BSTR pNativeImagePath, BSTR pPdbPath, BOOL pdbLines, BSTR pManagedPdbSearchPath); - void CreatePdbInCurrentDomain(BSTR pAssemblyPathOrName, BSTR pNativeImagePath, BSTR pPdbPath, BOOL pdbLines, BSTR pManagedPdbSearchPath); - - void DefineOutputAssembly(SString& strAssemblyName, ULONG * pHashAlgId); - - HRESULT Compile(LPCWSTR path, CORCOMPILE_NGEN_SIGNATURE * pNativeImageSig = NULL); - void DontUseProfileData(); - bool HasProfileData(); - - void CompileAssembly(CORCOMPILE_NGEN_SIGNATURE * pNativeImageSig); - ZapImage * CompileModule(CORINFO_MODULE_HANDLE hModule, - IMetaDataAssemblyEmit *pEmit); - void InstallCompiledAssembly(LPCWSTR szAssemblyName, LPCWSTR szNativeImagePath, HANDLE hFile, SArray &hFiles); - - HRESULT GetExceptionHR(); - - void Success(LPCWSTR format, ...); - void Error(LPCWSTR format, ...); - void Warning(LPCWSTR format, ...); - void Info(LPCWSTR format, ...); - void Print(CorZapLogLevel level, LPCWSTR format, ...); - void Print(CorZapLogLevel level, LPCWSTR format, va_list args); - void PrintErrorMessage(CorZapLogLevel level, Exception *ex); - void PrintErrorMessage(CorZapLogLevel level, HRESULT hr); - - BOOL CheckAssemblyUpToDate(CORINFO_ASSEMBLY_HANDLE hAssembly, CORCOMPILE_NGEN_SIGNATURE * pNativeImageSig); - BOOL TryToInstallFromRepository(CORINFO_ASSEMBLY_HANDLE hAssembly, CORCOMPILE_NGEN_SIGNATURE * pNativeImageSig); - BOOL TryToInstallFromRepositoryDir(SString &strNativeImageDir, - SString &strSimpleName, - CORCOMPILE_NGEN_SIGNATURE *pNativeImageSig, - BOOL *pfHitMismatchedVersion, - BOOL *pfHitMismatchedDependencies, - BOOL useHardLink = FALSE); - void CopyAndInstallFromRepository(LPCWSTR lpszNativeImageDir, - LPCWSTR lpszNativeImageName, - CORCOMPILE_NGEN_SIGNATURE * pNativeImageSig, - BOOL useHardLink = FALSE); - void InstallFromRepository(LPCWSTR lpszNativeImage, - CORCOMPILE_NGEN_SIGNATURE * pNativeImageSig); - - void CopyDirectory(LPCWSTR srcPath, LPCWSTR dstPath); - void CleanDirectory(LPCWSTR path); - void TryCleanDirectory(LPCWSTR path); - static void TryCleanDirectory(Zapper * pZapper); - - void GetOutputFolder(); - - void SetPlatformAssembliesPaths(LPCWSTR pwzPlatformAssembliesPaths); - void SetTrustedPlatformAssemblies(LPCWSTR pwzTrustedPlatformAssemblies); - void SetPlatformResourceRoots(LPCWSTR pwzPlatformResourceRoots); - void SetAppPaths(LPCWSTR pwzAppPaths); - void SetAppNiPaths(LPCWSTR pwzAppNiPaths); - void SetPlatformWinmdPaths(LPCWSTR pwzPlatformWinmdPaths); - -#if !defined(FEATURE_MERGE_JIT_AND_ENGINE) - void SetCLRJITPath(LPCWSTR pwszCLRJITPath); - void SetDontLoadJit(); -#endif // !defined(FEATURE_MERGE_JIT_AND_ENGINE) - -#if !defined(NO_NGENPDB) - void SetDiasymreaderPath(LPCWSTR pwzDiasymreaderPath); -#endif // !defined(NO_NGENPDB) - - void SetOutputFilename(LPCWSTR pwszOutputFilename); - SString GetOutputFileName(); - - private: - - void DestroyDomain(); - void CleanupAssembly(); - - void CreateCompilationDomain(); - void SetContextInfo(LPCWSTR assemblyName = NULL); - - void InitializeCompilerFlags(CORCOMPILE_VERSION_INFO * pVersionInfo); - - // DomainCallback is subclassed by each method that would like to compile in a given domain - class DomainCallback - { - public: - virtual void doCallback() = NULL; - }; - - static HRESULT __stdcall GenericDomainCallback(LPVOID pvArgs); - void InvokeDomainCallback(DomainCallback *callback); - - void CompileInCurrentDomain(__in LPCWSTR path, CORCOMPILE_NGEN_SIGNATURE * pNativeImageSig); - void ComputeDependenciesInCurrentDomain(LPCWSTR pAssemblyName, CORCOMPILE_NGEN_SIGNATURE * pNativeImageSig); - void CreateDependenciesLookupDomainInCurrentDomain(); - - void HangWorker(LPCWSTR hangKey, LPCWSTR insideHangKey); -}; - -class ZapperOptions -{ - public: - enum StatOptions - { - NO_STATS = 0, - DEFAULT_STATS = 1, - FIXUP_STATS = DEFAULT_STATS << 1, - CALL_STATS = FIXUP_STATS << 1, - ATTRIB_STATS = CALL_STATS << 1, - ALL_STATS = ~NO_STATS, - }; - - LPWSTR m_zapSet; // Add to zap string. Use to get a private scope of ngen images, for debugging/testing - - LPCWSTR m_repositoryDir; // Directory with prebuilt native images - RepositoryFlags m_repositoryFlags; // Copy the native images back to NativeImagesDir - - bool m_autodebug; // Use the debug setting specified by the IL module - - MethodNamesList* m_onlyMethods; // only methods to process - MethodNamesList* m_excludeMethods; // excluded these methods - mdToken m_onlyOneMethod; // only compile method with matching token - - bool m_silent; // Dont spew any text output - bool m_verbose; // Spew extra text ouput - bool m_ignoreErrors; // Continue in the face of errors - unsigned m_statOptions; // print statisitcs on number of methods, size of code ... - bool m_ngenProfileImage; // ngening with "/prof" - - // Which optimizations should be done - bool m_ignoreProfileData; // Don't use profile data - bool m_noProcedureSplitting; // Don't do procedure splitting - - bool m_fHasAnyProfileData; // true if we successfully loaded and used - // any profile data when compiling this assembly - - bool m_fPartialNGen; // Generate partial NGen images using IBC data - - bool m_fPartialNGenSet; // m_fPartialNGen has been set through the environment - - bool m_fAutoNGen; // This is an automatic NGen request - - bool m_fRepositoryOnly; // Install from repository only, no real NGen - - bool m_fNGenLastRetry; // This is retry of the compilation - - CORJIT_FLAGS m_compilerFlags; - - bool m_fNoMetaData; // Do not copy metadata and IL to native image - - void SetCompilerFlags(void); - - ZapperOptions(); - ~ZapperOptions(); -}; - -#endif // ZAPPER_H_ - diff --git a/src/pal/CMakeLists.txt b/src/pal/CMakeLists.txt index a510d2508..8c505e760 100644 --- a/src/pal/CMakeLists.txt +++ b/src/pal/CMakeLists.txt @@ -2,18 +2,10 @@ cmake_minimum_required(VERSION 2.8.12.2) project(COREPAL) -include(../../clrfeatures.cmake) - include_directories(${COREPAL_SOURCE_DIR}/inc) include_directories(${COREPAL_SOURCE_DIR}/src) -include_directories(${COREPAL_SOURCE_DIR}/../inc) add_compile_options(-fexceptions) add_definitions(-DUSE_STL) add_subdirectory(src) - -if(CLR_CMAKE_BUILD_TESTS) - add_subdirectory(tests) -endif(CLR_CMAKE_BUILD_TESTS) - diff --git a/src/pal/automation/automation.py b/src/pal/automation/automation.py deleted file mode 100644 index d8ddaa911..000000000 --- a/src/pal/automation/automation.py +++ /dev/null @@ -1,78 +0,0 @@ -import logging as log -import sys -import getopt -import os -import subprocess -import shutil -import compile -import tests -import util - -target = "" -arch = "" -platform = "" -workspace = "" -fullbuilddirpath = "" -cleanUp = True - -def ParseArgs(argv): - global target - global platform - global arch - global cleanUp - - returncode,target,platform,arch,cleanUp = util.ParseArgs(argv) - return returncode - -def Initialize(): - global workspace - workspace = util.Initialize(platform) - return 0 - -def SetupDirectories(): - global fullbuilddirpath - fullbuilddirpath = util.SetupDirectories(target, arch, platform) - - return 0 - -def CopyBinaries(): - print "\n==================================================\n" - print "Stub for copying binaries" - print "\n==================================================\n" - - return 0 - -def main(argv): - returncode = ParseArgs(argv) - if returncode != 0: - return returncode - - returncode += Initialize() - if returncode != 0: - return returncode - - returncode += SetupDirectories() - if returncode != 0: - return returncode - - returncode += compile.Compile(workspace, target, platform, arch) - if returncode != 0: - return returncode - - returncode += CopyBinaries() - if returncode != 0: - return returncode - - returncode += tests.RunTests(platform, fullbuilddirpath, workspace) - if returncode != 0: - return returncode - - return returncode - -if __name__ == "__main__": - returncode = main(sys.argv[1:]) - - util.Cleanup(cleanUp,workspace) - - sys.exit(returncode) - diff --git a/src/pal/automation/compile.py b/src/pal/automation/compile.py deleted file mode 100644 index bb9d1b88a..000000000 --- a/src/pal/automation/compile.py +++ /dev/null @@ -1,70 +0,0 @@ -import logging as log -import sys -import getopt -import os -import subprocess -import shutil - -def RunCMake(workspace, target, platform): - # run CMake - print "\n==================================================\n" - - returncode = 0 - if platform == "windows": - print "Running: vcvarsall.bat x86_amd64 && " + workspace + "\ProjectK\NDP\clr\src\pal\\tools\gen-buildsys-win.bat " + workspace + "\ProjectK\NDP\clr" - print "\n==================================================\n" - sys.stdout.flush() - returncode = subprocess.call(["vcvarsall.bat", "x86_amd64", "&&", workspace + "\ProjectK\NDP\clr\src\pal\\tools\gen-buildsys-win.bat", workspace + "\ProjectK\NDP\clr"]) - elif platform == "linux": - print "Running: " + workspace + "/ProjectK/NDP/clr/src/pal/tools/gen-buildsys-clang.sh " + workspace + "/ProjectK/NDP/clr DEBUG" - print "\n==================================================\n" - sys.stdout.flush() - returncode = subprocess.call(workspace + "/ProjectK/NDP/clr/src/pal/tools/gen-buildsys-clang.sh " + workspace + "/ProjectK/NDP/clr " + target, shell=True) - - if returncode != 0: - print "ERROR: cmake failed with exit code " + str(returncode) - - return returncode - -def RunBuild(target, platform, arch): - if platform == "windows": - return RunMsBuild(target, arch) - elif platform == "linux": - return RunMake() - -def RunMsBuild(target, arch): - # run MsBuild - print "\n==================================================\n" - print "Running: vcvarsall.bat x86_amd64 && msbuild CoreCLR.sln /p:Configuration=" + target + " /p:Platform=" + arch - print "\n==================================================\n" - sys.stdout.flush() - - returncode = subprocess.call(["vcvarsall.bat","x86_amd64","&&","msbuild","CoreCLR.sln","/p:Configuration=" + target,"/p:Platform=" + arch]) - - if returncode != 0: - print "ERROR: vcvarsall.bat failed with exit code " + str(returncode) - - return returncode - -def RunMake(): - print "\n==================================================\n" - print "Running: make" - print "\n==================================================\n" - sys.stdout.flush() - returncode = subprocess.call(["make"]) - - if returncode != 0: - print "ERROR: make failed with exit code " + str(returncode) - - return returncode - -def Compile(workspace, target, platform, arch): - returncode = RunCMake(workspace, target, platform) - if returncode != 0: - return returncode - - returncode += RunBuild(target, platform, arch) - if returncode != 0: - return returncode - - return returncode diff --git a/src/pal/automation/tests.py b/src/pal/automation/tests.py deleted file mode 100644 index e48e84fd1..000000000 --- a/src/pal/automation/tests.py +++ /dev/null @@ -1,33 +0,0 @@ -import sys -import getopt -import os -import subprocess -import shutil -import logging as log - -def RunPalTests(fullbuilddirpath, workspace): - print "\n==================================================\n" - print "Running PAL Tests." - print "\n==================================================\n" - - print "Running: " + workspace + "/ProjectK/NDP/clr/src/pal/tests/palsuite/runpaltests.sh " + fullbuilddirpath + " " + fullbuilddirpath + "/PalTestOutput" - print "\n==================================================\n" - sys.stdout.flush() - returncode = subprocess.call(workspace + "/ProjectK/NDP/clr/src/pal/tests/palsuite/runpaltests.sh " + fullbuilddirpath + " " + fullbuilddirpath + "/PalTestOutput", shell=True) - - if returncode != 0: - print "ERROR: there were errors failed with exit code " + str(returncode) - - return returncode - - -def RunTests(platform, fullbuilddirpath, workspace): - returncode = 0 - - if platform == "linux": - # Execute PAL tests - returncode = RunPalTests(fullbuilddirpath, workspace) - - return returncode - - diff --git a/src/pal/automation/util.py b/src/pal/automation/util.py deleted file mode 100644 index 790cbc4db..000000000 --- a/src/pal/automation/util.py +++ /dev/null @@ -1,97 +0,0 @@ -import sys -import getopt -import os -import subprocess -import shutil -import logging as log - -def Initialize(platform): - print "Initializing Workspace" - global workspace - workspace = os.environ['WORKSPACE'] - if platform == "windows": - # Jenkins puts quotes in the path, which is wrong. Remove quotes. - os.environ['PATH'] = os.environ['PATH'].replace('"','') - - return workspace - -def ParseArgs(argv): - print "Parsing arguments for compile" - try: - opts, args = getopt.getopt(argv, "t:p:a:v", ["target=", "platform=", "arch=", "verbose","noclean"]) - except getopt.GetoptError: - print "ERROR: \n\t usage: python compile.py --target --platform --arch [--verbose] [--noclean]" - return 2,"","","",True - - verbose = False - cleanUp = True - - acceptedPlatforms = ['windows','linux'] - - for opt, arg in opts: - if opt in ("-t", "--target"): - target = arg - elif opt in ("-p", "--platform"): - if arg.lower() not in acceptedPlatforms: - print "ERROR: " + arg + "not an accepted platform. Use windows or linux." - sys.exit(2) - platform = arg.lower() - elif opt in ("-a", "--arch"): - arch = arg - elif opt in ("-v", "--verbose"): - verbose = True - elif opt in ("-c", "--noclean"): - cleanUp = False - - if verbose: - log.basicConfig(format="%(levelname)s: %(message)s", level=log.DEBUG) - log.info("In verbose mode.") - else: - log.basicConfig(format="%(levelname)s: %(message)s") - - if target == "" or platform == "" or arch == "": - # must specify target, project and arch - log.error("Must specify target, project and arch") - return 2,"","","",True - - return 0,target,platform,arch,cleanUp - -def SetupDirectories(target, arch, platform): - log.info("Setting up directories") - - global rootdir - global builddir - global fullBuildDirPath - - rootdir = "build" - if not os.path.isdir(rootdir): - os.mkdir(rootdir) - os.chdir(rootdir) - - builddir = "build-" + platform - - if platform == "windows": - builddir = builddir + "-" + arch + "-" + target - - if os.path.isdir(builddir): - shutil.rmtree(builddir) - os.mkdir(builddir) - os.chdir(builddir) - - fullbuilddirpath = workspace + "/" + rootdir + "/" + builddir - - return fullbuilddirpath - -def Cleanup(cleanUp,workspace): - print "\n==================================================\n" - print "Cleaning Up." - print "\n==================================================\n" - - if cleanUp: - os.chdir(workspace + "/" + rootdir) - shutil.rmtree(builddir) - os.chdir("..") - shutil.rmtree(rootdir) - - log.shutdown() - return 0 diff --git a/src/pal/inc/pal.h b/src/pal/inc/pal.h index f89798cea..6dbc80566 100644 --- a/src/pal/inc/pal.h +++ b/src/pal/inc/pal.h @@ -138,15 +138,6 @@ extern "C" { /******************* Compiler-specific glue *******************************/ -#ifndef _MSC_VER -#if defined(CORECLR) -// Define this if the underlying platform supports true 2-pass EH. -// At the same time, this enables running several PAL instances -// side-by-side. -#define FEATURE_PAL_SXS 1 -#endif // CORECLR -#endif // !_MSC_VER - #if defined(_MSC_VER) || defined(__llvm__) #define DECLSPEC_ALIGN(x) __declspec(align(x)) #else @@ -336,113 +327,11 @@ typedef PTHREAD_START_ROUTINE LPTHREAD_START_ROUTINE; /******************* PAL-Specific Entrypoints *****************************/ -PALIMPORT -int -PALAPI -PAL_Initialize( - int argc, - const char * const argv[]); - PALIMPORT int PALAPI PAL_InitializeDLL(VOID); -PALIMPORT -DWORD -PALAPI -PAL_InitializeCoreCLR( - const char *szExePath); - -PALIMPORT -DWORD_PTR -PALAPI -PAL_EntryPoint( - IN LPTHREAD_START_ROUTINE lpStartAddress, - IN LPVOID lpParameter); - -/// -/// This function shuts down PAL WITHOUT exiting the current process. -/// -PALIMPORT -void -PALAPI -PAL_Shutdown( - void); - -/// -/// This function shuts down PAL and exits the current process. -/// -PALIMPORT -void -PALAPI -PAL_Terminate( - void); - -/// -/// This function shuts down PAL and exits the current process with -/// the specified exit code. -/// -PALIMPORT -void -PALAPI -PAL_TerminateEx( - int exitCode); - -typedef VOID (*PSHUTDOWN_CALLBACK)(void); - -PALIMPORT -VOID -PALAPI -PAL_SetShutdownCallback( - IN PSHUTDOWN_CALLBACK callback); - -typedef VOID (*PPAL_STARTUP_CALLBACK)( - char *modulePath, - HMODULE hModule, - PVOID parameter); - -PALIMPORT -DWORD -PALAPI -PAL_RegisterForRuntimeStartup( - IN DWORD dwProcessId, - IN PPAL_STARTUP_CALLBACK pfnCallback, - IN PVOID parameter, - OUT PVOID *ppUnregisterToken); - -PALIMPORT -DWORD -PALAPI -PAL_UnregisterForRuntimeStartup( - IN PVOID pUnregisterToken); - -PALIMPORT -BOOL -PALAPI -PAL_NotifyRuntimeStarted(VOID); - -static const int MAX_DEBUGGER_TRANSPORT_PIPE_NAME_LENGTH = MAX_PATH; - -PALIMPORT -VOID -PALAPI -PAL_GetTransportPipeName( - OUT char *name, - IN DWORD id, - IN const char *suffix); - -PALIMPORT -void -PALAPI -PAL_InitializeDebug( - void); - -PALIMPORT -void -PALAPI -PAL_IgnoreProfileSignal(int signalNum); - PALIMPORT HINSTANCE PALAPI @@ -461,6 +350,14 @@ PALAPI PAL_GetPALDirectoryW( OUT LPWSTR lpDirectoryName, IN OUT UINT* cchDirectoryName); + +PALIMPORT +BOOL +PALAPI +PAL_GetPALDirectoryA( + OUT LPSTR lpDirectoryName, + IN OUT UINT* cchDirectoryName); + #ifdef UNICODE #define PAL_GetPALDirectory PAL_GetPALDirectoryW #else @@ -1094,149 +991,6 @@ SetCurrentDirectoryW( #define SetCurrentDirectory SetCurrentDirectoryA #endif -PALIMPORT -HANDLE -PALAPI -CreateSemaphoreW( - IN LPSECURITY_ATTRIBUTES lpSemaphoreAttributes, - IN LONG lInitialCount, - IN LONG lMaximumCount, - IN LPCWSTR lpName); - -PALIMPORT -HANDLE -PALAPI -CreateSemaphoreExW( - IN LPSECURITY_ATTRIBUTES lpSemaphoreAttributes, - IN LONG lInitialCount, - IN LONG lMaximumCount, - IN LPCWSTR lpName, - IN /*_Reserved_*/ DWORD dwFlags, - IN DWORD dwDesiredAccess); - -PALIMPORT -HANDLE -PALAPI -OpenSemaphoreW( - IN DWORD dwDesiredAccess, - IN BOOL bInheritHandle, - IN LPCWSTR lpName); - -#ifdef UNICODE -#define CreateSemaphore CreateSemaphoreW -#define CreateSemaphoreEx CreateSemaphoreExW -#else -#define CreateSemaphore CreateSemaphoreA -#define CreateSemaphoreEx CreateSemaphoreExA -#endif - -PALIMPORT -BOOL -PALAPI -ReleaseSemaphore( - IN HANDLE hSemaphore, - IN LONG lReleaseCount, - OUT LPLONG lpPreviousCount); - -PALIMPORT -HANDLE -PALAPI -CreateEventW( - IN LPSECURITY_ATTRIBUTES lpEventAttributes, - IN BOOL bManualReset, - IN BOOL bInitialState, - IN LPCWSTR lpName); - -PALIMPORT -HANDLE -PALAPI -CreateEventExW( - IN LPSECURITY_ATTRIBUTES lpEventAttributes, - IN LPCWSTR lpName, - IN DWORD dwFlags, - IN DWORD dwDesiredAccess); - -// CreateEventExW: dwFlags -#define CREATE_EVENT_MANUAL_RESET ((DWORD)0x1) -#define CREATE_EVENT_INITIAL_SET ((DWORD)0x2) - -#ifdef UNICODE -#define CreateEvent CreateEventW -#else -#define CreateEvent CreateEventA -#endif - -PALIMPORT -BOOL -PALAPI -SetEvent( - IN HANDLE hEvent); - -PALIMPORT -BOOL -PALAPI -ResetEvent( - IN HANDLE hEvent); - -PALIMPORT -HANDLE -PALAPI -OpenEventW( - IN DWORD dwDesiredAccess, - IN BOOL bInheritHandle, - IN LPCWSTR lpName); - -#ifdef UNICODE -#define OpenEvent OpenEventW -#endif - -PALIMPORT -HANDLE -PALAPI -CreateMutexW( - IN LPSECURITY_ATTRIBUTES lpMutexAttributes, - IN BOOL bInitialOwner, - IN LPCWSTR lpName); - -PALIMPORT -HANDLE -PALAPI -CreateMutexExW( - IN LPSECURITY_ATTRIBUTES lpMutexAttributes, - IN LPCWSTR lpName, - IN DWORD dwFlags, - IN DWORD dwDesiredAccess); - -// CreateMutexExW: dwFlags -#define CREATE_MUTEX_INITIAL_OWNER ((DWORD)0x1) - -#ifdef UNICODE -#define CreateMutex CreateMutexW -#else -#define CreateMutex CreateMutexA -#endif - -PALIMPORT -HANDLE -PALAPI -OpenMutexW( - IN DWORD dwDesiredAccess, - IN BOOL bInheritHandle, - IN LPCWSTR lpName); - - -#ifdef UNICODE -#define OpenMutex OpenMutexW -#else -#define OpenMutex OpenMutexA -#endif // UNICODE - -PALIMPORT -BOOL -PALAPI -ReleaseMutex( - IN HANDLE hMutex); - PALIMPORT DWORD PALAPI @@ -1249,27 +1003,12 @@ PALAPI GetCurrentSessionId( VOID); -PALIMPORT -HANDLE -PALAPI -GetCurrentProcess( - VOID); - PALIMPORT DWORD PALAPI GetCurrentThreadId( VOID); -// To work around multiply-defined symbols in the Carbon framework. -#define GetCurrentThread PAL_GetCurrentThread -PALIMPORT -HANDLE -PALAPI -GetCurrentThread( - VOID); - - #define STARTF_USESTDHANDLES 0x00000100 typedef struct _STARTUPINFOW { @@ -1333,190 +1072,6 @@ typedef struct _PROCESS_INFORMATION { DWORD dwThreadId_PAL_Undefined; } PROCESS_INFORMATION, *PPROCESS_INFORMATION, *LPPROCESS_INFORMATION; -PALIMPORT -BOOL -PALAPI -CreateProcessW( - IN LPCWSTR lpApplicationName, - IN LPWSTR lpCommandLine, - IN LPSECURITY_ATTRIBUTES lpProcessAttributes, - IN LPSECURITY_ATTRIBUTES lpThreadAttributes, - IN BOOL bInheritHandles, - IN DWORD dwCreationFlags, - IN LPVOID lpEnvironment, - IN LPCWSTR lpCurrentDirectory, - IN LPSTARTUPINFOW lpStartupInfo, - OUT LPPROCESS_INFORMATION lpProcessInformation); - -#ifdef UNICODE -#define CreateProcess CreateProcessW -#else -#define CreateProcess CreateProcessA -#endif - -PALIMPORT -PAL_NORETURN -VOID -PALAPI -ExitProcess( - IN UINT uExitCode); - -PALIMPORT -BOOL -PALAPI -TerminateProcess( - IN HANDLE hProcess, - IN UINT uExitCode); - -PALIMPORT -BOOL -PALAPI -GetExitCodeProcess( - IN HANDLE hProcess, - IN LPDWORD lpExitCode); - -PALIMPORT -BOOL -PALAPI -GetProcessTimes( - IN HANDLE hProcess, - OUT LPFILETIME lpCreationTime, - OUT LPFILETIME lpExitTime, - OUT LPFILETIME lpKernelTime, - OUT LPFILETIME lpUserTime); - -#define MAXIMUM_WAIT_OBJECTS 64 -#define WAIT_OBJECT_0 0 -#define WAIT_ABANDONED 0x00000080 -#define WAIT_ABANDONED_0 0x00000080 -#define WAIT_TIMEOUT 258 -#define WAIT_FAILED ((DWORD)0xFFFFFFFF) - -#define INFINITE 0xFFFFFFFF // Infinite timeout - -PALIMPORT -DWORD -PALAPI -WaitForSingleObject( - IN HANDLE hHandle, - IN DWORD dwMilliseconds); - -PALIMPORT -DWORD -PALAPI -PAL_WaitForSingleObjectPrioritized( - IN HANDLE hHandle, - IN DWORD dwMilliseconds); - -PALIMPORT -DWORD -PALAPI -WaitForSingleObjectEx( - IN HANDLE hHandle, - IN DWORD dwMilliseconds, - IN BOOL bAlertable); - -PALIMPORT -DWORD -PALAPI -WaitForMultipleObjects( - IN DWORD nCount, - IN CONST HANDLE *lpHandles, - IN BOOL bWaitAll, - IN DWORD dwMilliseconds); - -PALIMPORT -DWORD -PALAPI -WaitForMultipleObjectsEx( - IN DWORD nCount, - IN CONST HANDLE *lpHandles, - IN BOOL bWaitAll, - IN DWORD dwMilliseconds, - IN BOOL bAlertable); - -PALIMPORT -DWORD -PALAPI -SignalObjectAndWait( - IN HANDLE hObjectToSignal, - IN HANDLE hObjectToWaitOn, - IN DWORD dwMilliseconds, - IN BOOL bAlertable); - -#define DUPLICATE_CLOSE_SOURCE 0x00000001 -#define DUPLICATE_SAME_ACCESS 0x00000002 - -PALIMPORT -BOOL -PALAPI -DuplicateHandle( - IN HANDLE hSourceProcessHandle, - IN HANDLE hSourceHandle, - IN HANDLE hTargetProcessHandle, - OUT LPHANDLE lpTargetHandle, - IN DWORD dwDesiredAccess, - IN BOOL bInheritHandle, - IN DWORD dwOptions); - -PALIMPORT -VOID -PALAPI -Sleep( - IN DWORD dwMilliseconds); - -PALIMPORT -DWORD -PALAPI -SleepEx( - IN DWORD dwMilliseconds, - IN BOOL bAlertable); - -PALIMPORT -BOOL -PALAPI -SwitchToThread( - VOID); - -#define DEBUG_PROCESS 0x00000001 -#define DEBUG_ONLY_THIS_PROCESS 0x00000002 -#define CREATE_SUSPENDED 0x00000004 -#define STACK_SIZE_PARAM_IS_A_RESERVATION 0x00010000 - -PALIMPORT -HANDLE -PALAPI -CreateThread( - IN LPSECURITY_ATTRIBUTES lpThreadAttributes, - IN DWORD dwStackSize, - IN LPTHREAD_START_ROUTINE lpStartAddress, - IN LPVOID lpParameter, - IN DWORD dwCreationFlags, - OUT LPDWORD lpThreadId); - -PALIMPORT -PAL_NORETURN -VOID -PALAPI -ExitThread( - IN DWORD dwExitCode); - -PALIMPORT -DWORD -PALAPI -ResumeThread( - IN HANDLE hThread); - -typedef VOID (PALAPI *PAPCFUNC)(ULONG_PTR dwParam); - -PALIMPORT -DWORD -PALAPI -QueueUserAPC( - IN PAPCFUNC pfnAPC, - IN HANDLE hThread, - IN ULONG_PTR dwData); - #ifdef _X86_ // @@ -2261,49 +1816,6 @@ typedef struct _KNONVOLATILE_CONTEXT_POINTERS { #error Unknown architecture for defining CONTEXT. #endif - -PALIMPORT -BOOL -PALAPI -GetThreadContext( - IN HANDLE hThread, - IN OUT LPCONTEXT lpContext); - -PALIMPORT -BOOL -PALAPI -SetThreadContext( - IN HANDLE hThread, - IN CONST CONTEXT *lpContext); - -#define THREAD_BASE_PRIORITY_LOWRT 15 -#define THREAD_BASE_PRIORITY_MAX 2 -#define THREAD_BASE_PRIORITY_MIN (-2) -#define THREAD_BASE_PRIORITY_IDLE (-15) - -#define THREAD_PRIORITY_LOWEST THREAD_BASE_PRIORITY_MIN -#define THREAD_PRIORITY_BELOW_NORMAL (THREAD_PRIORITY_LOWEST+1) -#define THREAD_PRIORITY_NORMAL 0 -#define THREAD_PRIORITY_HIGHEST THREAD_BASE_PRIORITY_MAX -#define THREAD_PRIORITY_ABOVE_NORMAL (THREAD_PRIORITY_HIGHEST-1) -#define THREAD_PRIORITY_ERROR_RETURN (MAXLONG) - -#define THREAD_PRIORITY_TIME_CRITICAL THREAD_BASE_PRIORITY_LOWRT -#define THREAD_PRIORITY_IDLE THREAD_BASE_PRIORITY_IDLE - -PALIMPORT -int -PALAPI -GetThreadPriority( - IN HANDLE hThread); - -PALIMPORT -BOOL -PALAPI -SetThreadPriority( - IN HANDLE hThread, - IN int nPriority); - PALIMPORT BOOL PALAPI @@ -2314,76 +1826,6 @@ GetThreadTimes( OUT LPFILETIME lpKernelTime, OUT LPFILETIME lpUserTime); -#define TLS_OUT_OF_INDEXES ((DWORD)0xFFFFFFFF) - -PALIMPORT -DWORD -PALAPI -TlsAlloc( - VOID); - -PALIMPORT -LPVOID -PALAPI -TlsGetValue( - IN DWORD dwTlsIndex); - -PALIMPORT -BOOL -PALAPI -TlsSetValue( - IN DWORD dwTlsIndex, - IN LPVOID lpTlsValue); - -PALIMPORT -BOOL -PALAPI -TlsFree( - IN DWORD dwTlsIndex); - -PALIMPORT -void * -PALAPI -PAL_GetStackBase(VOID); - -PALIMPORT -void * -PALAPI -PAL_GetStackLimit(VOID); - -PALIMPORT -DWORD -PALAPI -PAL_GetLogicalCpuCountFromOS(VOID); - -PALIMPORT -size_t -PALAPI -PAL_GetRestrictedPhysicalMemoryLimit(VOID); - -PALIMPORT -BOOL -PALAPI -PAL_GetWorkingSetSize(size_t* val); - -PALIMPORT -BOOL -PALAPI -PAL_GetCpuLimit(UINT* val); - -PALIMPORT -size_t -PALAPI -PAL_GetLogicalProcessorCacheSizeFromOS(VOID); - -typedef BOOL(*UnwindReadMemoryCallback)(PVOID address, PVOID buffer, SIZE_T size); - -PALIMPORT BOOL PALAPI PAL_VirtualUnwind(CONTEXT *context, KNONVOLATILE_CONTEXT_POINTERS *contextPointers); - -PALIMPORT BOOL PALAPI PAL_VirtualUnwindOutOfProc(CONTEXT *context, KNONVOLATILE_CONTEXT_POINTERS *contextPointers, SIZE_T baseAddress, UnwindReadMemoryCallback readMemoryCallback); - -#define GetLogicalProcessorCacheSizeFromOS PAL_GetLogicalProcessorCacheSizeFromOS - /* PAL_CS_NATIVE_DATA_SIZE is defined as sizeof(PAL_CRITICAL_SECTION_NATIVE_DATA) */ #if defined(__APPLE__) && defined(__i386__) @@ -2535,7 +1977,6 @@ PALAPI UnmapViewOfFile( IN LPCVOID lpBaseAddress); - PALIMPORT HMODULE PALAPI @@ -2550,54 +1991,6 @@ LoadLibraryExW( IN /*Reserved*/ HANDLE hFile, IN DWORD dwFlags); -PALIMPORT -void * -PALAPI -PAL_LoadLibraryDirect( - IN LPCWSTR lpLibFileName); - -PALIMPORT -HMODULE -PALAPI -PAL_RegisterLibraryDirect( - IN void *dl_handle, - IN LPCWSTR lpLibFileName); - -/*++ -Function: - PAL_LOADLoadPEFile - -Abstract - Loads a PE file into memory. Properly maps all of the sections in the PE file. Returns a pointer to the - loaded base. - -Parameters: - IN hFile - The file to load - -Return value: - A valid base address if successful. - 0 if failure ---*/ -void * -PALAPI -PAL_LOADLoadPEFile(HANDLE hFile); - -/*++ - PAL_LOADUnloadPEFile - - Unload a PE file that was loaded by PAL_LOADLoadPEFile(). - -Parameters: - IN ptr - the file pointer returned by PAL_LOADLoadPEFile() - -Return value: - TRUE - success - FALSE - failure (incorrect ptr, etc.) ---*/ -BOOL -PALAPI -PAL_LOADUnloadPEFile(void * ptr); - #ifdef UNICODE #define LoadLibrary LoadLibraryW #define LoadLibraryEx LoadLibraryExW @@ -2621,14 +2014,6 @@ PALAPI FreeLibrary( IN OUT HMODULE hLibModule); -PALIMPORT -PAL_NORETURN -VOID -PALAPI -FreeLibraryAndExitThread( - IN HMODULE hLibModule, - IN DWORD dwExitCode); - PALIMPORT BOOL PALAPI @@ -2673,14 +2058,6 @@ LPCSTR PALAPI PAL_GetLoadLibraryError(); -PALIMPORT -LPVOID -PALAPI -PAL_VirtualReserveFromExecutableMemoryAllocatorWithinRange( - IN LPCVOID lpBeginAddress, - IN LPCVOID lpEndAddress, - IN SIZE_T dwSize); - PALIMPORT LPVOID PALAPI @@ -2839,14 +2216,6 @@ PALAPI LocalFree( IN HLOCAL hMem); -PALIMPORT -BOOL -PALAPI -FlushInstructionCache( - IN HANDLE hProcess, - IN LPCVOID lpBaseAddress, - IN SIZE_T dwSize); - #define MAX_LEADBYTES 12 #define MAX_DEFAULTCHAR 2 @@ -2917,20 +2286,6 @@ WideCharToMultiByte( IN LPCSTR lpDefaultChar, OUT LPBOOL lpUsedDefaultChar); -PALIMPORT -int -PALAPI -PAL_GetResourceString( - IN LPCSTR lpDomain, - IN LPCSTR lpResourceStr, - OUT LPWSTR lpWideCharStr, - IN int cchWideChar); - -PALIMPORT -BOOL -PALAPI -PAL_BindResources(IN LPCSTR lpDomain); - #define EXCEPTION_NONCONTINUABLE 0x1 #define EXCEPTION_UNWINDING 0x2 @@ -2974,19 +2329,6 @@ typedef struct _EXCEPTION_POINTERS { PCONTEXT ContextRecord; } EXCEPTION_POINTERS, *PEXCEPTION_POINTERS, *LPEXCEPTION_POINTERS; -#ifdef FEATURE_PAL_SXS - -typedef LONG EXCEPTION_DISPOSITION; - -enum { - ExceptionContinueExecution, - ExceptionContinueSearch, - ExceptionNestedException, - ExceptionCollidedUnwind, -}; - -#endif // FEATURE_PAL_SXS - // // A function table entry is generated for each frame function. // @@ -3028,15 +2370,6 @@ typedef struct _RUNTIME_FUNCTION { #define PROCESS_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | \ 0xFFF) -PALIMPORT -HANDLE -PALAPI -OpenProcess( - IN DWORD dwDesiredAccess, /* PROCESS_DUP_HANDLE or PROCESS_ALL_ACCESS */ - IN BOOL bInheritHandle, - IN DWORD dwProcessId - ); - PALIMPORT BOOL PALAPI @@ -3146,24 +2479,6 @@ PALAPI CloseHandle( IN OUT HANDLE hObject); -PALIMPORT -VOID -PALAPI -RaiseException( - IN DWORD dwExceptionCode, - IN DWORD dwExceptionFlags, - IN DWORD nNumberOfArguments, - IN CONST ULONG_PTR *lpArguments); - -#ifdef FEATURE_PAL_SXS -PALIMPORT -PAL_NORETURN -VOID -PALAPI -PAL_RaiseException( - IN PEXCEPTION_POINTERS ExceptionPointers); -#endif // FEATURE_PAL_SXS - PALIMPORT DWORD PALAPI @@ -3189,13 +2504,6 @@ QueryPerformanceFrequency( OUT LARGE_INTEGER *lpFrequency ); -PALIMPORT -BOOL -PALAPI -QueryThreadCycleTime( - IN HANDLE ThreadHandle, - OUT PULONG64 CycleTime); - PALIMPORT INT PALAPI @@ -3691,23 +2999,6 @@ YieldProcessor( #endif } -PALIMPORT -DWORD -PALAPI -GetCurrentProcessorNumber(VOID); - -/*++ -Function: -PAL_HasGetCurrentProcessorNumber - -Checks if GetCurrentProcessorNumber is available in the current environment - ---*/ -PALIMPORT -BOOL -PALAPI -PAL_HasGetCurrentProcessorNumber(VOID); - #define FORMAT_MESSAGE_ALLOCATE_BUFFER 0x00000100 #define FORMAT_MESSAGE_IGNORE_INSERTS 0x00000200 #define FORMAT_MESSAGE_FROM_STRING 0x00000400 @@ -3744,73 +3035,6 @@ PALAPI SetLastError( IN DWORD dwErrCode); -PALIMPORT -LPWSTR -PALAPI -GetCommandLineW( - VOID); - -#ifdef UNICODE -#define GetCommandLine GetCommandLineW -#endif - -PALIMPORT -VOID -PALAPI -RtlRestoreContext( - IN PCONTEXT ContextRecord, - IN PEXCEPTION_RECORD ExceptionRecord -); - -PALIMPORT -VOID -PALAPI -RtlCaptureContext( - OUT PCONTEXT ContextRecord -); - -PALIMPORT -UINT -PALAPI -GetWriteWatch( - IN DWORD dwFlags, - IN PVOID lpBaseAddress, - IN SIZE_T dwRegionSize, - OUT PVOID *lpAddresses, - IN OUT PULONG_PTR lpdwCount, - OUT PULONG lpdwGranularity -); - -PALIMPORT -UINT -PALAPI -ResetWriteWatch( - IN LPVOID lpBaseAddress, - IN SIZE_T dwRegionSize -); - -PALIMPORT -VOID -PALAPI -FlushProcessWriteBuffers(VOID); - -typedef void (*PAL_ActivationFunction)(CONTEXT *context); -typedef BOOL (*PAL_SafeActivationCheckFunction)(SIZE_T ip, BOOL checkingCurrentThread); - -PALIMPORT -VOID -PALAPI -PAL_SetActivationFunction( - IN PAL_ActivationFunction pActivationFunction, - IN PAL_SafeActivationCheckFunction pSafeActivationCheckFunction); - -PALIMPORT -BOOL -PALAPI -PAL_InjectActivation( - IN HANDLE hThread -); - #define VER_PLATFORM_WIN32_WINDOWS 1 #define VER_PLATFORM_WIN32_NT 2 #define VER_PLATFORM_UNIX 10 @@ -3915,198 +3139,16 @@ CreatePipe( IN DWORD nSize ); -// -// NUMA related APIs -// - -typedef enum _PROCESSOR_CACHE_TYPE { - CacheUnified, - CacheInstruction, - CacheData, - CacheTrace -} PROCESSOR_CACHE_TYPE; - -typedef struct _PROCESSOR_NUMBER { - WORD Group; - BYTE Number; - BYTE Reserved; -} PROCESSOR_NUMBER, *PPROCESSOR_NUMBER; - -typedef enum _LOGICAL_PROCESSOR_RELATIONSHIP { - RelationProcessorCore, - RelationNumaNode, - RelationCache, - RelationProcessorPackage, - RelationGroup, - RelationAll = 0xffff -} LOGICAL_PROCESSOR_RELATIONSHIP; - -typedef ULONG_PTR KAFFINITY; - -#define ANYSIZE_ARRAY 1 - -typedef struct _GROUP_AFFINITY { - KAFFINITY Mask; - WORD Group; - WORD Reserved[3]; -} GROUP_AFFINITY, *PGROUP_AFFINITY; - -typedef struct _PROCESSOR_GROUP_INFO { - BYTE MaximumProcessorCount; - BYTE ActiveProcessorCount; - BYTE Reserved[38]; - KAFFINITY ActiveProcessorMask; -} PROCESSOR_GROUP_INFO, *PPROCESSOR_GROUP_INFO; - -typedef struct _PROCESSOR_RELATIONSHIP { - BYTE Flags; - BYTE EfficiencyClass; - BYTE Reserved[21]; - WORD GroupCount; - GROUP_AFFINITY GroupMask[ANYSIZE_ARRAY]; -} PROCESSOR_RELATIONSHIP, *PPROCESSOR_RELATIONSHIP; - -typedef struct _GROUP_RELATIONSHIP { - WORD MaximumGroupCount; - WORD ActiveGroupCount; - BYTE Reserved[20]; - PROCESSOR_GROUP_INFO GroupInfo[ANYSIZE_ARRAY]; -} GROUP_RELATIONSHIP, *PGROUP_RELATIONSHIP; - -typedef struct _NUMA_NODE_RELATIONSHIP { - DWORD NodeNumber; - BYTE Reserved[20]; - GROUP_AFFINITY GroupMask; -} NUMA_NODE_RELATIONSHIP, *PNUMA_NODE_RELATIONSHIP; - -typedef struct _CACHE_RELATIONSHIP { - BYTE Level; - BYTE Associativity; - WORD LineSize; - DWORD CacheSize; - PROCESSOR_CACHE_TYPE Type; - BYTE Reserved[20]; - GROUP_AFFINITY GroupMask; -} CACHE_RELATIONSHIP, *PCACHE_RELATIONSHIP; - -typedef struct _SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX { - LOGICAL_PROCESSOR_RELATIONSHIP Relationship; - DWORD Size; - union { - PROCESSOR_RELATIONSHIP Processor; - NUMA_NODE_RELATIONSHIP NumaNode; - CACHE_RELATIONSHIP Cache; - GROUP_RELATIONSHIP Group; - }; -} SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX, *PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX; - - -PALIMPORT -BOOL -PALAPI -GetNumaHighestNodeNumber( - OUT PULONG HighestNodeNumber -); - -PALIMPORT -BOOL -PALAPI -GetNumaProcessorNodeEx( - IN PPROCESSOR_NUMBER Processor, - OUT PUSHORT NodeNumber -); - -PALIMPORT -LPVOID -PALAPI -VirtualAllocExNuma( - IN HANDLE hProcess, - IN OPTIONAL LPVOID lpAddress, - IN SIZE_T dwSize, - IN DWORD flAllocationType, - IN DWORD flProtect, - IN DWORD nndPreferred -); - -PALIMPORT -BOOL -PALAPI -GetLogicalProcessorInformationEx( - IN LOGICAL_PROCESSOR_RELATIONSHIP RelationshipType, - OUT OPTIONAL PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX Buffer, - IN OUT PDWORD ReturnedLength -); - -PALIMPORT -DWORD_PTR -PALAPI -SetThreadAffinityMask( - IN HANDLE hThread, - IN DWORD_PTR dwThreadAffinityMask -); - -PALIMPORT -BOOL -PALAPI -SetThreadGroupAffinity( - IN HANDLE hThread, - IN const GROUP_AFFINITY *GroupAffinity, - OUT OPTIONAL PGROUP_AFFINITY PreviousGroupAffinity -); - -PALIMPORT -BOOL -PALAPI -GetThreadGroupAffinity( - IN HANDLE hThread, - OUT PGROUP_AFFINITY GroupAffinity -); - -PALIMPORT -VOID -PALAPI -GetCurrentProcessorNumberEx( - OUT PPROCESSOR_NUMBER ProcNumber -); - -PALIMPORT -BOOL -PALAPI -GetProcessAffinityMask( - IN HANDLE hProcess, - OUT PDWORD_PTR lpProcessAffinityMask, - OUT PDWORD_PTR lpSystemAffinityMask -); - -PALIMPORT -BOOL -PALAPI -SetThreadIdealProcessorEx( - IN HANDLE hThread, - IN PPROCESSOR_NUMBER lpIdealProcessor, - OUT PPROCESSOR_NUMBER lpPreviousIdealProcessor -); - -// -// The types of events that can be logged. -// -#define EVENTLOG_SUCCESS 0x0000 -#define EVENTLOG_ERROR_TYPE 0x0001 -#define EVENTLOG_WARNING_TYPE 0x0002 -#define EVENTLOG_INFORMATION_TYPE 0x0004 -#define EVENTLOG_AUDIT_SUCCESS 0x0008 -#define EVENTLOG_AUDIT_FAILURE 0x0010 - #if defined FEATURE_PAL_ANSI #include "palprivate.h" #endif //FEATURE_PAL_ANSI + /******************* C Runtime Entrypoints *******************************/ /* Some C runtime functions needs to be reimplemented by the PAL. To avoid name collisions, those functions have been renamed using defines */ #ifndef PAL_STDCPP_COMPAT -#define exit PAL_exit #define atexit PAL_atexit #define printf PAL_printf #define vprintf PAL_vprintf @@ -4197,7 +3239,6 @@ SetThreadIdealProcessorEx( #define free PAL_free #define mkstemp PAL_mkstemp #define rename PAL_rename -#define _strdup PAL__strdup #define _getcwd PAL__getcwd #define _open PAL__open #define _close PAL__close @@ -4213,6 +3254,8 @@ SetThreadIdealProcessorEx( #endif // !PAL_STDCPP_COMPAT +#define _strdup strdup + #ifndef _CONST_RETURN #ifdef __cplusplus #define _CONST_RETURN const @@ -4494,12 +3537,11 @@ inline __int64 abs(__int64 _X) { } } -#endif +#endif // __cplusplus PALIMPORT void * __cdecl malloc(size_t); PALIMPORT void __cdecl free(void *); PALIMPORT void * __cdecl realloc(void *, size_t); -PALIMPORT char * __cdecl _strdup(const char *); #if defined(_MSC_VER) #define alloca _alloca @@ -4647,46 +3689,6 @@ PALIMPORT int __cdecl _putenv(const char *); #define ERANGE 34 -/******************* PAL-specific I/O completion port *****************/ - -typedef struct _PAL_IOCP_CPU_INFORMATION { - union { - FILETIME ftLastRecordedIdleTime; - FILETIME ftLastRecordedCurrentTime; - } LastRecordedTime; - FILETIME ftLastRecordedKernelTime; - FILETIME ftLastRecordedUserTime; -} PAL_IOCP_CPU_INFORMATION; - -PALIMPORT -INT -PALAPI -PAL_GetCPUBusyTime( - IN OUT PAL_IOCP_CPU_INFORMATION *lpPrevCPUInfo); - -/****************PAL Perf functions for PInvoke*********************/ -#if PAL_PERF -PALIMPORT -VOID -PALAPI -PAL_EnableProcessProfile(VOID); - -PALIMPORT -VOID -PALAPI -PAL_DisableProcessProfile(VOID); - -PALIMPORT -BOOL -PALAPI -PAL_IsProcessProfileEnabled(VOID); - -PALIMPORT -INT64 -PALAPI -PAL_GetCpuTickCount(VOID); -#endif // PAL_PERF - /******************* PAL functions for SIMD extensions *****************/ PALIMPORT @@ -4697,559 +3699,17 @@ void _mm_setcsr(unsigned int i); /******************* PAL functions for CPU capability detection *******/ -#ifdef __cplusplus - -class CORJIT_FLAGS; - -PALIMPORT -VOID -PALAPI -PAL_GetJitCpuCapabilityFlags(CORJIT_FLAGS *flags); - -#endif - -/******************* PAL side-by-side support ************************/ - -#ifdef FEATURE_PAL_SXS -// -// Some versions of the PAL support several PALs side-by-side -// in the process. To avoid those PALs interfering with one -// another, they need to be told by clients when they are active -// and when they are not. -// - -// To avoid performance problems incurred by swapping thread -// exception ports every time we leave the PAL, there's also -// the concept of entering/leaving the PAL at its top boundary -// (entering down/leaving up) or at the bottom boundary -// (leaving down/entering up). - -typedef enum _PAL_Boundary { - PAL_BoundaryTop, // closer to main() - PAL_BoundaryBottom, // closer to execution - PAL_BoundaryEH, // out-of-band during EH - - PAL_BoundaryMax = PAL_BoundaryEH -} PAL_Boundary; - -// This function needs to be called on a thread when it enters -// a region of code that depends on this instance of the PAL -// in the process, and the current thread may or may not be -// known to the PAL. This function can fail (for something else -// than an internal error) if this is the first time that the -// current thread entered this PAL. Note that PAL_Initialize -// implies a call to this function. Does not modify LastError. -PALIMPORT -DWORD -PALAPI -PAL_Enter(PAL_Boundary boundary); - -// Returns TRUE if we this thread has already entered the PAL, -// returns FALSE if we have not entered the PAL. -PALIMPORT -BOOL -PALAPI -PAL_HasEntered(VOID); - -// Equivalent to PAL_Enter(PAL_BoundaryTop) and is for stub -// code generation use. -PALIMPORT -DWORD -PALAPI -PAL_EnterTop(VOID); - -// This function needs to be called on a thread when it enters -// a region of code that depends on this instance of the PAL -// in the process, and the current thread is already known to -// the PAL. Does not modify LastError. -PALIMPORT -VOID -PALAPI -PAL_Reenter(PAL_Boundary boundary); - -// This function needs to be called on a thread when it enters -// a region of code that depends on this instance of the PAL -// in the process, and it is unknown whether the current thread -// is already running in the PAL. Returns TRUE if and only if -// the thread was not running in the PAL previously. Does not -// modify LastError. -PALIMPORT -BOOL -PALAPI -PAL_ReenterForEH(VOID); - -// This function needs to be called on a thread when it leaves -// a region of code that depends on this instance of the PAL -// in the process. Does not modify LastError. -PALIMPORT -VOID -PALAPI -PAL_Leave(PAL_Boundary boundary); - -// This function is equivalent to PAL_Leave(PAL_BoundaryBottom) -// and is available to limit the creation of stub code. -PALIMPORT -VOID -PALAPI -PAL_LeaveBottom(VOID); - -// This function is equivalent to PAL_Leave(PAL_BoundaryTop) -// and is available to limit the creation of stub code. -PALIMPORT -VOID -PALAPI -PAL_LeaveTop(VOID); - -#ifdef __cplusplus -// -// A holder to enter the PAL for a specific region of code. -// Previously, we must have been executing outside the PAL -// (unless fEnter is set to FALSE). -// -class PAL_EnterHolder -{ -private: - BOOL m_fEntered; - DWORD m_palError; -public: - PAL_EnterHolder(BOOL fEnter = TRUE) : m_palError(ERROR_SUCCESS) - { - if (fEnter) - { - m_palError = PAL_Enter(PAL_BoundaryTop); - m_fEntered = m_palError == ERROR_SUCCESS; - } - else - { - m_fEntered = FALSE; - } - } - - ~PAL_EnterHolder() - { - if (m_fEntered) - { - PAL_Leave(PAL_BoundaryTop); - } - } - - DWORD GetError() - { - return m_palError; - } - - void SuppressRelease() - { - // Used to avoid calling PAL_Leave() when - // another code path will explicitly do so. - m_fEntered = FALSE; - } -}; - -class PAL_LeaveHolder -{ -public: - PAL_LeaveHolder() - { - PAL_Leave(PAL_BoundaryBottom); - } - - ~PAL_LeaveHolder() - { - PAL_Reenter(PAL_BoundaryBottom); - } -}; -#endif // __cplusplus - -#else // FEATURE_PAL_SXS - -#define PAL_Enter(boundary) ERROR_SUCCESS -#define PAL_Reenter(boundary) -#define PAL_Leave(boundary) - #ifdef __cplusplus -class PAL_EnterHolder { -public: - // using constructor to suppress the "unused variable" warnings - PAL_EnterHolder() {} -}; -class PAL_LeaveHolder { -public: - // using constructor to suppress the "unused variable" warnings - PAL_LeaveHolder() {} -}; -#endif // __cplusplus - -#endif // FEATURE_PAL_SXS - -#ifdef __cplusplus - -#include "pal_unwind.h" - -PALIMPORT -VOID -PALAPI -PAL_FreeExceptionRecords( - IN EXCEPTION_RECORD *exceptionRecord, - IN CONTEXT *contextRecord); - -#define EXCEPTION_CONTINUE_SEARCH 0 -#define EXCEPTION_EXECUTE_HANDLER 1 -#define EXCEPTION_CONTINUE_EXECUTION -1 - -struct PAL_SEHException -{ -private: - static const SIZE_T NoTargetFrameSp = SIZE_MAX; - - void Move(PAL_SEHException& ex) - { - ExceptionPointers.ExceptionRecord = ex.ExceptionPointers.ExceptionRecord; - ExceptionPointers.ContextRecord = ex.ExceptionPointers.ContextRecord; - TargetFrameSp = ex.TargetFrameSp; - RecordsOnStack = ex.RecordsOnStack; - - ex.Clear(); - } - - void FreeRecords() - { - if (ExceptionPointers.ExceptionRecord != NULL && !RecordsOnStack ) - { - PAL_FreeExceptionRecords(ExceptionPointers.ExceptionRecord, ExceptionPointers.ContextRecord); - ExceptionPointers.ExceptionRecord = NULL; - ExceptionPointers.ContextRecord = NULL; - } - } - -public: - EXCEPTION_POINTERS ExceptionPointers; - // Target frame stack pointer set before the 2nd pass. - SIZE_T TargetFrameSp; - bool RecordsOnStack; - - PAL_SEHException(EXCEPTION_RECORD *pExceptionRecord, CONTEXT *pContextRecord, bool onStack = false) - { - ExceptionPointers.ExceptionRecord = pExceptionRecord; - ExceptionPointers.ContextRecord = pContextRecord; - TargetFrameSp = NoTargetFrameSp; - RecordsOnStack = onStack; - } - - PAL_SEHException() - { - Clear(); - } - - // The copy constructor and copy assignment operators are deleted so that the PAL_SEHException - // can never be copied, only moved. This enables simple lifetime management of the exception and - // context records, since there is always just one PAL_SEHException instance referring to the same records. - PAL_SEHException(const PAL_SEHException& ex) = delete; - PAL_SEHException& operator=(const PAL_SEHException& ex) = delete; - - PAL_SEHException(PAL_SEHException&& ex) - { - Move(ex); - } - - PAL_SEHException& operator=(PAL_SEHException&& ex) - { - FreeRecords(); - Move(ex); - return *this; - } - - ~PAL_SEHException() - { - FreeRecords(); - } - - void Clear() - { - ExceptionPointers.ExceptionRecord = NULL; - ExceptionPointers.ContextRecord = NULL; - TargetFrameSp = NoTargetFrameSp; - RecordsOnStack = false; - } - - CONTEXT* GetContextRecord() - { - return ExceptionPointers.ContextRecord; - } - - EXCEPTION_RECORD* GetExceptionRecord() - { - return ExceptionPointers.ExceptionRecord; - } - - bool IsFirstPass() - { - return (TargetFrameSp == NoTargetFrameSp); - } - - void SecondPassDone() - { - TargetFrameSp = NoTargetFrameSp; - } -}; - -typedef BOOL (*PHARDWARE_EXCEPTION_HANDLER)(PAL_SEHException* ex); -typedef BOOL (*PHARDWARE_EXCEPTION_SAFETY_CHECK_FUNCTION)(PCONTEXT contextRecord, PEXCEPTION_RECORD exceptionRecord); -typedef VOID (*PTERMINATION_REQUEST_HANDLER)(); -typedef DWORD (*PGET_GCMARKER_EXCEPTION_CODE)(LPVOID ip); - -PALIMPORT -VOID -PALAPI -PAL_SetHardwareExceptionHandler( - IN PHARDWARE_EXCEPTION_HANDLER exceptionHandler, - IN PHARDWARE_EXCEPTION_SAFETY_CHECK_FUNCTION exceptionCheckFunction); - -PALIMPORT -VOID -PALAPI -PAL_SetGetGcMarkerExceptionCode( - IN PGET_GCMARKER_EXCEPTION_CODE getGcMarkerExceptionCode); - -PALIMPORT -VOID -PALAPI -PAL_ThrowExceptionFromContext( - IN CONTEXT* context, - IN PAL_SEHException* ex); - -PALIMPORT -VOID -PALAPI -PAL_SetTerminationRequestHandler( - IN PTERMINATION_REQUEST_HANDLER terminationRequestHandler); - -// -// This holder is used to indicate that a hardware -// exception should be raised as a C++ exception -// to better emulate SEH on the xplat platforms. -// -class CatchHardwareExceptionHolder -{ -public: - CatchHardwareExceptionHolder(); - - ~CatchHardwareExceptionHolder(); - - static bool IsEnabled(); -}; - -// -// NOTE: Catching hardware exceptions are only enabled in the DAC and SOS -// builds. A hardware exception in coreclr code will fail fast/terminate -// the process. -// -#ifdef FEATURE_ENABLE_HARDWARE_EXCEPTIONS -#define HardwareExceptionHolder CatchHardwareExceptionHolder __catchHardwareException; -#else -#define HardwareExceptionHolder -#endif // FEATURE_ENABLE_HARDWARE_EXCEPTIONS - -#ifdef FEATURE_PAL_SXS - -extern "C++" { - -// -// This is the base class of native exception holder used to provide -// the filter function to the exception dispatcher. This allows the -// filter to be called during the first pass to better emulate SEH -// the xplat platforms that only have C++ exception support. -// -class NativeExceptionHolderBase -{ - // Save the address of the holder head so the destructor - // doesn't have access the slow (on Linux) TLS value again. - NativeExceptionHolderBase **m_head; - - // The next holder on the stack - NativeExceptionHolderBase *m_next; - -protected: - NativeExceptionHolderBase(); - - ~NativeExceptionHolderBase(); - -public: - // Calls the holder's filter handler. - virtual EXCEPTION_DISPOSITION InvokeFilter(PAL_SEHException& ex) = 0; - - // Adds the holder to the "stack" of holders. This is done explicitly instead - // of in the constructor was to avoid the mess of move constructors combined - // with return value optimization (in CreateHolder). - void Push(); - - // Given the currentHolder and locals stack range find the next holder starting with this one - // To find the first holder, pass nullptr as the currentHolder. - static NativeExceptionHolderBase *FindNextHolder(NativeExceptionHolderBase *currentHolder, void *frameLowAddress, void *frameHighAddress); -}; - -// -// This is the second part of the native exception filter holder. It is -// templated because the lambda used to wrap the exception filter is a -// unknown type. -// -template -class NativeExceptionHolder : public NativeExceptionHolderBase -{ - FilterType* m_exceptionFilter; - -public: - NativeExceptionHolder(FilterType* exceptionFilter) - : NativeExceptionHolderBase() - { - m_exceptionFilter = exceptionFilter; - } - - virtual EXCEPTION_DISPOSITION InvokeFilter(PAL_SEHException& ex) - { - return (*m_exceptionFilter)(ex); - } -}; - -// -// This is a native exception holder that is used when the catch catches -// all exceptions. -// -class NativeExceptionHolderCatchAll : public NativeExceptionHolderBase -{ - -public: - NativeExceptionHolderCatchAll() - : NativeExceptionHolderBase() - { - } - - virtual EXCEPTION_DISPOSITION InvokeFilter(PAL_SEHException& ex) - { - return EXCEPTION_EXECUTE_HANDLER; - } -}; - -// This is a native exception holder that doesn't catch any exceptions. -class NativeExceptionHolderNoCatch : public NativeExceptionHolderBase -{ - -public: - NativeExceptionHolderNoCatch() - : NativeExceptionHolderBase() - { - } - - virtual EXCEPTION_DISPOSITION InvokeFilter(PAL_SEHException& ex) - { - return EXCEPTION_CONTINUE_SEARCH; - } -}; - -// -// This factory class for the native exception holder is necessary because -// templated functions don't need the explicit type parameter and can infer -// the template type from the parameter. -// -class NativeExceptionHolderFactory -{ -public: - template - static NativeExceptionHolder CreateHolder(FilterType* exceptionFilter) - { - return NativeExceptionHolder(exceptionFilter); - } -}; - -// Start of a try block for exceptions raised by RaiseException -#define PAL_TRY(__ParamType, __paramDef, __paramRef) \ -{ \ - __ParamType __param = __paramRef; \ - auto tryBlock = [](__ParamType __paramDef) \ - { - -// Start of an exception handler. If an exception raised by the RaiseException -// occurs in the try block and the disposition is EXCEPTION_EXECUTE_HANDLER, -// the handler code is executed. If the disposition is EXCEPTION_CONTINUE_SEARCH, -// the exception is rethrown. The EXCEPTION_CONTINUE_EXECUTION disposition is -// not supported. -#define PAL_EXCEPT(dispositionExpression) \ - }; \ - const bool isFinally = false; \ - auto finallyBlock = []() {}; \ - EXCEPTION_DISPOSITION disposition = EXCEPTION_CONTINUE_EXECUTION; \ - auto exceptionFilter = [&disposition, &__param](PAL_SEHException& ex) \ - { \ - (void)__param; \ - disposition = dispositionExpression; \ - _ASSERTE(disposition != EXCEPTION_CONTINUE_EXECUTION); \ - return disposition; \ - }; \ - try \ - { \ - HardwareExceptionHolder \ - auto __exceptionHolder = NativeExceptionHolderFactory::CreateHolder(&exceptionFilter); \ - __exceptionHolder.Push(); \ - tryBlock(__param); \ - } \ - catch (PAL_SEHException& ex) \ - { \ - if (disposition == EXCEPTION_CONTINUE_EXECUTION) \ - { \ - exceptionFilter(ex); \ - } \ - if (disposition == EXCEPTION_CONTINUE_SEARCH) \ - { \ - throw; \ - } \ - ex.SecondPassDone(); - -// Start of an exception handler. It works the same way as the PAL_EXCEPT except -// that the disposition is obtained by calling the specified filter. -#define PAL_EXCEPT_FILTER(filter) PAL_EXCEPT(filter(&ex.ExceptionPointers, __param)) - -// Start of a finally block. The finally block is executed both when the try block -// finishes or when an exception is raised using the RaiseException in it. -#define PAL_FINALLY \ - }; \ - const bool isFinally = true; \ - auto finallyBlock = [&]() \ - { - -// End of an except or a finally block. -#define PAL_ENDTRY \ - }; \ - if (isFinally) \ - { \ - try \ - { \ - tryBlock(__param); \ - } \ - catch (...) \ - { \ - finallyBlock(); \ - throw; \ - } \ - finallyBlock(); \ - } \ -} - -} // extern "C++" - -#endif // FEATURE_PAL_SXS #define PAL_CPP_THROW(type, obj) { throw obj; } #define PAL_CPP_RETHROW { throw; } -#define PAL_CPP_TRY try { HardwareExceptionHolder -#define PAL_CPP_CATCH_EXCEPTION(ident) } catch (Exception *ident) { PAL_Reenter(PAL_BoundaryBottom); -#define PAL_CPP_CATCH_EXCEPTION_NOARG } catch (Exception *) { PAL_Reenter(PAL_BoundaryBottom); -#define PAL_CPP_CATCH_DERIVED(type, ident) } catch (type *ident) { PAL_Reenter(PAL_BoundaryBottom); +#define PAL_CPP_TRY try { +#define PAL_CPP_CATCH_EXCEPTION(ident) } catch (Exception *ident) { +#define PAL_CPP_CATCH_EXCEPTION_NOARG } catch (Exception *) { +#define PAL_CPP_CATCH_DERIVED(type, ident) } catch (type *ident) { #define PAL_CPP_CATCH_ALL } catch (...) { \ - PAL_Reenter(PAL_BoundaryBottom); \ try { throw; } \ - catch (PAL_SEHException& ex) { ex.SecondPassDone(); } \ catch (...) {} - #define PAL_CPP_ENDTRY } #ifdef _MSC_VER diff --git a/src/pal/inc/pal_unwind.h b/src/pal/inc/pal_unwind.h deleted file mode 100644 index 2931488e3..000000000 --- a/src/pal/inc/pal_unwind.h +++ /dev/null @@ -1,91 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -// -// Definition of the Unwind API functions. -// Taken from the ABI documentation. -// - - - -#ifndef __PAL_UNWIND_H__ -#define __PAL_UNWIND_H__ - -#if FEATURE_PAL_SXS - -#ifdef __cplusplus -extern "C" -{ -#endif // __cplusplus - - // - // Exception Handling ABI Level I: Base ABI - // - - typedef enum - { - _URC_NO_REASON = 0, - _URC_FOREIGN_EXCEPTION_CAUGHT = 1, - _URC_FATAL_PHASE2_ERROR = 2, - _URC_FATAL_PHASE1_ERROR = 3, - _URC_NORMAL_STOP = 4, - _URC_END_OF_STACK = 5, - _URC_HANDLER_FOUND = 6, - _URC_INSTALL_CONTEXT = 7, - _URC_CONTINUE_UNWIND = 8, - } _Unwind_Reason_Code; - - typedef enum - { - _UA_SEARCH_PHASE = 1, - _UA_CLEANUP_PHASE = 2, - _UA_HANDLER_FRAME = 4, - _UA_FORCE_UNWIND = 8, - } _Unwind_Action; - #define _UA_PHASE_MASK (_UA_SEARCH_PHASE|_UA_CLEANUP_PHASE) - - struct _Unwind_Context; - - void *_Unwind_GetIP(struct _Unwind_Context *context); - void _Unwind_SetIP(struct _Unwind_Context *context, void *new_value); - void *_Unwind_GetCFA(struct _Unwind_Context *context); - void *_Unwind_GetGR(struct _Unwind_Context *context, int index); - void _Unwind_SetGR(struct _Unwind_Context *context, int index, void *new_value); - - struct _Unwind_Exception; - - typedef void (*_Unwind_Exception_Cleanup_Fn)( - _Unwind_Reason_Code urc, - struct _Unwind_Exception *exception_object); - - struct _Unwind_Exception - { - ULONG64 exception_class; - _Unwind_Exception_Cleanup_Fn exception_cleanup; - UINT_PTR private_1; - UINT_PTR private_2; - } __attribute__((aligned)); - - void _Unwind_DeleteException(struct _Unwind_Exception *exception_object); - - typedef _Unwind_Reason_Code (*_Unwind_Trace_Fn)(struct _Unwind_Context *context, void *pvParam); - _Unwind_Reason_Code _Unwind_Backtrace(_Unwind_Trace_Fn pfnTrace, void *pvParam); - - _Unwind_Reason_Code _Unwind_RaiseException(struct _Unwind_Exception *exception_object); - __attribute__((noreturn)) void _Unwind_Resume(struct _Unwind_Exception *exception_object); - - // - // Exception Handling ABI Level II: C++ ABI - // - - void *__cxa_begin_catch(void *exceptionObject); - void __cxa_end_catch(); - -#ifdef __cplusplus -}; -#endif // __cplusplus - -#endif // FEATURE_PAL_SXS - -#endif // __PAL_UNWIND_H__ diff --git a/src/pal/inc/palprivate.h b/src/pal/inc/palprivate.h index b9c9d08a2..be79f8c16 100644 --- a/src/pal/inc/palprivate.h +++ b/src/pal/inc/palprivate.h @@ -138,66 +138,6 @@ PALAPI SetCurrentDirectoryA( IN LPCSTR lpPathName); -PALIMPORT -HANDLE -PALAPI -CreateSemaphoreA( - IN LPSECURITY_ATTRIBUTES lpSemaphoreAttributes, - IN LONG lInitialCount, - IN LONG lMaximumCount, - IN LPCSTR lpName); - -PALIMPORT -HANDLE -PALAPI -CreateSemaphoreExA( - IN LPSECURITY_ATTRIBUTES lpSemaphoreAttributes, - IN LONG lInitialCount, - IN LONG lMaximumCount, - IN LPCSTR lpName, - IN /*_Reserved_*/ DWORD dwFlags, - IN DWORD dwDesiredAccess); - -PALIMPORT -HANDLE -PALAPI -CreateEventA( - IN LPSECURITY_ATTRIBUTES lpEventAttributes, - IN BOOL bManualReset, - IN BOOL bInitialState, - IN LPCSTR lpName); - -PALIMPORT -HANDLE -PALAPI -CreateMutexA( - IN LPSECURITY_ATTRIBUTES lpMutexAttributes, - IN BOOL bInitialOwner, - IN LPCSTR lpName); - -PALIMPORT -HANDLE -PALAPI -OpenMutexA( - IN DWORD dwDesiredAccess, - IN BOOL bInheritHandle, - IN LPCSTR lpName); - -PALIMPORT -BOOL -PALAPI -CreateProcessA( - IN LPCSTR lpApplicationName, - IN LPSTR lpCommandLine, - IN LPSECURITY_ATTRIBUTES lpProcessAttributes, - IN LPSECURITY_ATTRIBUTES lpThreadAttributes, - IN BOOL bInheritHandles, - IN DWORD dwCreationFlags, - IN LPVOID lpEnvironment, - IN LPCSTR lpCurrentDirectory, - IN LPSTARTUPINFOA lpStartupInfo, - OUT LPPROCESS_INFORMATION lpProcessInformation); - PALIMPORT HANDLE PALAPI @@ -273,13 +213,6 @@ PALAPI RemoveDirectoryA( IN LPCSTR lpPathName); -PALIMPORT -BOOL -PALAPI -PAL_GetPALDirectoryA( - OUT LPSTR lpDirectoryName, - IN UINT* cchDirectoryName); - #ifdef __cplusplus } #endif diff --git a/src/pal/inc/rt/cpp/ccombstr.h b/src/pal/inc/rt/cpp/ccombstr.h deleted file mode 100644 index 999be9e70..000000000 --- a/src/pal/inc/rt/cpp/ccombstr.h +++ /dev/null @@ -1,263 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -// - -// -// =========================================================================== -// File: CComBSTR.h -// -// =========================================================================== - -/*++ - -Abstract: - - Stripped down and modified version of CComBSTR - ---*/ - -#ifndef __CCOMBSTR_H__ -#define __CCOMBSTR_H__ - -#ifdef __cplusplus - -#ifndef AtlThrow -#define AtlThrow(a) RaiseException(STATUS_NO_MEMORY,EXCEPTION_NONCONTINUABLE,0,nullptr); -#endif -#ifndef ATLASSERT -#define ATLASSERT(a) _ASSERTE(a) -#endif -#define MAX_SATELLITESTRING 1024 - -#include - -class CComBSTR -{ -public: - BSTR m_str; - CComBSTR() - { - m_str = nullptr; - } - CComBSTR(int nSize) - { - if (nSize == 0) - m_str = nullptr; - else - { - m_str = ::SysAllocStringLen(nullptr, nSize); - if (m_str == nullptr) - AtlThrow(E_OUTOFMEMORY); - } - } - CComBSTR(int nSize, LPCOLESTR sz) - { - if (nSize == 0) - m_str = nullptr; - else - { - m_str = ::SysAllocStringLen(sz, nSize); - if (m_str == nullptr) - AtlThrow(E_OUTOFMEMORY); - } - } - CComBSTR(LPCOLESTR pSrc) - { - if (pSrc == nullptr) - m_str = nullptr; - else - { - m_str = ::SysAllocString(pSrc); - if (m_str == nullptr) - AtlThrow(E_OUTOFMEMORY); - } - } - - CComBSTR(const CComBSTR& src) - { - m_str = src.Copy(); - if (!!src && m_str == nullptr) - AtlThrow(E_OUTOFMEMORY); - - } - - CComBSTR& operator=(const CComBSTR& src) - { - if (m_str != src.m_str) - { - ::SysFreeString(m_str); - m_str = src.Copy(); - if (!!src && m_str == nullptr) - AtlThrow(E_OUTOFMEMORY); - } - return *this; - } - - CComBSTR& operator=(LPCOLESTR pSrc) - { - if (pSrc != m_str) - { - ::SysFreeString(m_str); - if (pSrc != nullptr) - { - m_str = ::SysAllocString(pSrc); - if (m_str == nullptr) - AtlThrow(E_OUTOFMEMORY); - } - else - m_str = nullptr; - } - return *this; - } - - ~CComBSTR() - { - ::SysFreeString(m_str); - } - unsigned int ByteLength() const - { - return (m_str == nullptr)? 0 : SysStringByteLen(m_str); - } - unsigned int Length() const - { - return (m_str == nullptr)? 0 : SysStringLen(m_str); - } - operator BSTR() const - { - return m_str; - } - BSTR* operator&() - { - return &m_str; - } - BSTR Copy() const - { - if (m_str == nullptr) - return nullptr; - return ::SysAllocStringLen(m_str, SysStringLen(m_str)); - } - HRESULT CopyTo(BSTR* pbstr) - { - ATLASSERT(pbstr != nullptr); - if (pbstr == nullptr) - return E_POINTER; - *pbstr = Copy(); - if ((*pbstr == nullptr) && (m_str != nullptr)) - return E_OUTOFMEMORY; - return S_OK; - } - // copy BSTR to VARIANT - HRESULT CopyTo(VARIANT *pvarDest) - { - ATLASSERT(pvarDest != nullptr); - HRESULT hRes = E_POINTER; - if (pvarDest != nullptr) - { - V_VT (pvarDest) = VT_BSTR; - V_BSTR (pvarDest) = Copy(); - if (V_BSTR (pvarDest) == nullptr && m_str != nullptr) - hRes = E_OUTOFMEMORY; - else - hRes = S_OK; - } - return hRes; - } - - void Attach(BSTR src) - { - if (m_str != src) - { - ::SysFreeString(m_str); - m_str = src; - } - } - BSTR Detach() - { - BSTR s = m_str; - m_str = nullptr; - return s; - } - void Empty() - { - ::SysFreeString(m_str); - m_str = nullptr; - } - HRESULT Append(LPCOLESTR lpsz) - { - return Append(lpsz, UINT(lstrlenW(lpsz))); - } - - HRESULT Append(LPCOLESTR lpsz, int nLen) - { - if (lpsz == nullptr || (m_str != nullptr && nLen == 0)) - return S_OK; - if (nLen < 0) - return E_INVALIDARG; - int n1 = Length(); - - // Check for overflow - size_t newSize; - if (!ClrSafeInt::addition(n1, nLen, newSize)) - return E_INVALIDARG; - - BSTR b; - b = ::SysAllocStringLen(nullptr, newSize); - if (b == nullptr) - return E_OUTOFMEMORY; - memcpy(b, m_str, n1*sizeof(OLECHAR)); - memcpy(b+n1, lpsz, nLen*sizeof(OLECHAR)); - b[n1+nLen] = 0; - SysFreeString(m_str); - m_str = b; - return S_OK; - } - - HRESULT AssignBSTR(const BSTR bstrSrc) - { - HRESULT hr = S_OK; - if (m_str != bstrSrc) - { - ::SysFreeString(m_str); - if (bstrSrc != nullptr) - { - m_str = SysAllocStringLen(bstrSrc, SysStringLen(bstrSrc)); - if (m_str == nullptr) - hr = E_OUTOFMEMORY; - } - else - m_str = nullptr; - } - - return hr; - } - - bool LoadString(HSATELLITE hInst, UINT nID) - { - ::SysFreeString(m_str); - m_str = nullptr; - WCHAR SatelliteString[MAX_SATELLITESTRING]; - if (PAL_LoadSatelliteStringW(hInst, nID, SatelliteString, MAX_SATELLITESTRING)) - { - m_str = SysAllocString(SatelliteString); - } - return m_str != nullptr; - } - - bool LoadString(PVOID hInst, UINT nID) - { - return LoadString ((HSATELLITE)hInst, nID); - } - - CComBSTR& operator+=(LPCOLESTR pszSrc) - { - HRESULT hr; - hr = Append(pszSrc); - if (FAILED(hr)) - AtlThrow(hr); - return *this; - } - -}; -#endif // __cplusplus -#endif // __CCOMBSTR_H__ diff --git a/src/pal/inc/rt/cpp/cstring.h b/src/pal/inc/rt/cpp/cstring.h deleted file mode 100644 index 483a005ca..000000000 --- a/src/pal/inc/rt/cpp/cstring.h +++ /dev/null @@ -1,77 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -// - -// - -#ifndef __CSTRING_H__ -#define __CSTRING_H__ - -#ifdef __cplusplus - -#ifndef AtlThrow -#define AtlThrow(a) RaiseException(STATUS_NO_MEMORY,EXCEPTION_NONCONTINUABLE,0,nullptr); -#endif -#ifndef ATLASSERT -#define ATLASSERT(a) _ASSERTE(a) -#endif - -#include "ccombstr.h" - -class CStringW : public CComBSTR -{ -public: - CStringW() { - } - - CStringW(int nSize, LPCOLESTR sz) : - CComBSTR (nSize, sz) - { - } - - - CStringW(LPCOLESTR pSrc) : - CComBSTR(pSrc) - { - } - - CStringW(const CStringW& src) : - CComBSTR(src) - { - } - - CStringW (LPCSTR pSrc) : - CComBSTR() - { - // Intentionaly create us as empty string, later - // we will overwrite ourselves with the - // converted string. - int cchSize; - cchSize = MultiByteToWideChar(CP_ACP, 0, pSrc, -1, nullptr, 0); - if (cchSize == 0) - { - AtlThrow(E_OUTOFMEMORY); - } - - CComBSTR bstr(cchSize); - // No convert the string - // (Note that (BSTR)bstr will return a pointer to the - // allocated WCHAR buffer - done by the CComBSTR constructor) - if (MultiByteToWideChar(CP_ACP, 0, pSrc, -1, (WCHAR *)((BSTR)bstr), cchSize) == 0) - { - AtlThrow(E_OUTOFMEMORY); - } - - // And now assign this new bstr to us - // The following is a trick how to avoid copying the string - Attach(bstr.Detach()); - } - - ~CStringW() { - } -}; - -#endif // __cplusplus - -#endif // __CSTRING_H__ diff --git a/src/pal/inc/rt/palrt.h b/src/pal/inc/rt/palrt.h index 1360a81c4..ebc30e6d2 100644 --- a/src/pal/inc/rt/palrt.h +++ b/src/pal/inc/rt/palrt.h @@ -1615,10 +1615,6 @@ typedef struct tagVS_FIXEDFILEINFO /******************** external includes *************************/ #include "ntimage.h" -#ifndef PAL_STDCPP_COMPAT -#include "cpp/ccombstr.h" -#include "cpp/cstring.h" -#endif // !PAL_STDCPP_COMPAT #endif // RC_INVOKED diff --git a/src/pal/inc/rt/safecrt.h b/src/pal/inc/rt/safecrt.h index 92366dfc3..1ddb68bfc 100644 --- a/src/pal/inc/rt/safecrt.h +++ b/src/pal/inc/rt/safecrt.h @@ -383,7 +383,7 @@ void __cdecl _invalid_parameter(const WCHAR *_Message, const WCHAR *_FunctionNam (_Reserved); #endif /* invoke Watson */ - RaiseException((DWORD)STATUS_INVALID_PARAMETER, 0, 0, nullptr); + throw "safecrt: invalid parameter"; } #endif diff --git a/src/pal/prebuilt/corerror/makecorerror.bat b/src/pal/prebuilt/corerror/makecorerror.bat deleted file mode 100644 index f9b964f56..000000000 --- a/src/pal/prebuilt/corerror/makecorerror.bat +++ /dev/null @@ -1,27 +0,0 @@ -@if "%_echo%"=="" echo off -REM Licensed to the .NET Foundation under one or more agreements. -REM The .NET Foundation licenses this file to you under the MIT license. -REM See the LICENSE file in the project root for more information. -setlocal - -if "%_NTROOT%" == "" goto LUsage - -set MANAGED_TOOLS_PATH=%MANAGED_TOOLS_ROOT%\%MANAGED_TOOLS_VERSION% -set CORERROR_PATH=%_NTROOT%\ndp\clr\src\inc - -%MANAGED_TOOLS_PATH%\genheaders.exe %CORERROR_PATH%\corerror.xml ..\inc\corerror.h mscorurt.rc - -goto LExit - -:LUsage - -echo. -echo makecorerror.bat -echo. -echo Builds corerror.h for PALRT -echo. -echo Should be run inside razzle environment, depends on %%_NTROOT%% environment variable. -echo. - -:LExit - diff --git a/src/pal/prebuilt/corerror/mscorurt.rc b/src/pal/prebuilt/corerror/mscorurt.rc deleted file mode 100644 index 28da8f91c..000000000 --- a/src/pal/prebuilt/corerror/mscorurt.rc +++ /dev/null @@ -1,1083 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -STRINGTABLE DISCARDABLE -BEGIN - MSG_FOR_URT_HR(CORDBG_S_AT_END_OF_STACK) "The stack walk has reached the end of the stack. There are no more frames to walk." - MSG_FOR_URT_HR(CEE_E_ENTRYPOINT) "Invalid entrypoint information." - MSG_FOR_URT_HR(CEE_E_CVTRES_NOT_FOUND) "cvtres.exe not found." - MSG_FOR_URT_HR(MSEE_E_LOADLIBFAILED) "Failed to delayload a library." - MSG_FOR_URT_HR(MSEE_E_GETPROCFAILED) "Failed to get dll entrypoint." - MSG_FOR_URT_HR(MSEE_E_MULTCOPIESLOADED) "Multiple copies of mscoree.dll have been loaded into the same process." - MSG_FOR_URT_HR(COR_E_TYPEUNLOADED) "Type has been unloaded." - MSG_FOR_URT_HR(COR_E_APPDOMAINUNLOADED) "Attempted to access an unloaded appdomain." - MSG_FOR_URT_HR(COR_E_CANNOTUNLOADAPPDOMAIN) "Error while unloading appdomain." - MSG_FOR_URT_HR(MSEE_E_ASSEMBLYLOADINPROGRESS) "Assembly is still being loaded." - MSG_FOR_URT_HR(MSEE_E_CANNOTCREATEAPPDOMAIN) "Attempt to create appdomain failed." - MSG_FOR_URT_HR(COR_E_ASSEMBLYEXPECTED) "The module was expected to contain an assembly manifest." - MSG_FOR_URT_HR(COR_E_FIXUPSINEXE) "Attempt to load an unverifiable executable with fixups (IAT with more than 2 sections or a TLS section.)" - MSG_FOR_URT_HR(COR_E_NO_LOADLIBRARY_ALLOWED) "Attempt to LoadLibrary a managed image in an improper way (only assemblies with EAT area allowed)." - MSG_FOR_URT_HR(COR_E_NEWER_RUNTIME) "This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded." - MSG_FOR_URT_HR(COR_E_CANNOT_SET_POLICY) "Cannot set security policy under MultiDomain after non-GAC assemblies have been loaded in appdomain." - MSG_FOR_URT_HR(COR_E_CANNOT_SPECIFY_EVIDENCE) "Cannot specify assembly evidence under MultiDomain after non-GAC assemblies with default evidence have been loaded in appdomain." - MSG_FOR_URT_HR(COR_E_MULTIMODULEASSEMBLIESDIALLOWED) "The module cannot be loaded because only single file assemblies are supported." - MSG_FOR_URT_HR(HOST_E_DEADLOCK) "Host detected a deadlock on a blocking operation." - MSG_FOR_URT_HR(HOST_E_INTERRUPTED) "Host interrupted a wait." - MSG_FOR_URT_HR(HOST_E_INVALIDOPERATION) "Invalid operation." - MSG_FOR_URT_HR(HOST_E_CLRNOTAVAILABLE) "CLR has been disabled due to unrecoverable error." - MSG_FOR_URT_HR(HOST_E_TIMEOUT) "A wait has timed out." - MSG_FOR_URT_HR(HOST_E_NOT_OWNER) "The leave operation has been attempted on a synchronization primitive that is not owned by the current thread." - MSG_FOR_URT_HR(HOST_E_ABANDONED) "An event has been abandoned." - MSG_FOR_URT_HR(HOST_E_EXITPROCESS_THREADABORT) "Process exited due to ThreadAbort escalation." - MSG_FOR_URT_HR(HOST_E_EXITPROCESS_ADUNLOAD) "Process exited due to AD Unload escalation." - MSG_FOR_URT_HR(HOST_E_EXITPROCESS_TIMEOUT) "Process exited due to Timeout escalation." - MSG_FOR_URT_HR(HOST_E_EXITPROCESS_OUTOFMEMORY) "Process exited due to OutOfMemory escalation." - MSG_FOR_URT_HR(HOST_E_EXITPROCESS_STACKOVERFLOW) "Process exited due to StackOverflow escalation." - MSG_FOR_URT_HR(COR_E_MODULE_HASH_CHECK_FAILED) "The check of the module's hash failed." - MSG_FOR_URT_HR(FUSION_E_REF_DEF_MISMATCH) "The located assembly's manifest definition does not match the assembly reference." - MSG_FOR_URT_HR(FUSION_E_INVALID_PRIVATE_ASM_LOCATION) "The private assembly was located outside the appbase directory." - MSG_FOR_URT_HR(FUSION_E_ASM_MODULE_MISSING) "A module specified in the manifest was not found." - MSG_FOR_URT_HR(FUSION_E_UNEXPECTED_MODULE_FOUND) "Modules which are not in the manifest were streamed in." - MSG_FOR_URT_HR(FUSION_E_PRIVATE_ASM_DISALLOWED) "A strongly-named assembly is required." - MSG_FOR_URT_HR(FUSION_E_SIGNATURE_CHECK_FAILED) "Strong name signature could not be verified. The assembly may have been tampered with, or it was delay signed but not fully signed with the correct private key." - MSG_FOR_URT_HR(FUSION_E_DATABASE_ERROR) "An unexpected error was encountered in the Assembly Cache database." - MSG_FOR_URT_HR(FUSION_E_INVALID_NAME) "The given assembly name or codebase was invalid." - MSG_FOR_URT_HR(FUSION_E_CODE_DOWNLOAD_DISABLED) "HTTP download of assemblies has been disabled for this appdomain." - MSG_FOR_URT_HR(FUSION_E_UNINSTALL_DISALLOWED) "Uninstall of given assembly is not allowed." - MSG_FOR_URT_HR(CLR_E_APP_CONFIG_NOT_ALLOWED_IN_APPX_PROCESS) "Application configuration file not allowed in AppX process." - MSG_FOR_URT_HR(FUSION_E_HOST_GAC_ASM_MISMATCH) "Assembly in host store has a different signature than assembly in GAC." - MSG_FOR_URT_HR(FUSION_E_LOADFROM_BLOCKED) "LoadFrom(), LoadFile(), Load(byte[]) and LoadModule() have been disabled by the host." - MSG_FOR_URT_HR(FUSION_E_CACHEFILE_FAILED) "Failed to add file to AppDomain cache." - MSG_FOR_URT_HR(FUSION_E_APP_DOMAIN_LOCKED) "The requested assembly version conflicts with what is already bound in the app domain or specified in the manifest." - MSG_FOR_URT_HR(FUSION_E_CONFIGURATION_ERROR) "The requested assembly name was neither found in the GAC nor in the manifest or the manifest's specified location is wrong." - MSG_FOR_URT_HR(FUSION_E_MANIFEST_PARSE_ERROR) "Unexpected error while parsing the specified manifest." - MSG_FOR_URT_HR(FUSION_E_INVALID_ASSEMBLY_REFERENCE) "The given assembly name is invalid because a processor architecture is specified." - MSG_FOR_URT_HR(COR_E_ASSEMBLY_NOT_EXPECTED) "The module was expected to not contain an assembly manifest." - MSG_FOR_URT_HR(COR_E_LOADING_REFERENCE_ASSEMBLY) "Reference assemblies should not be loaded for execution. They can only be loaded in the Reflection-only loader context." - MSG_FOR_URT_HR(COR_E_NI_AND_RUNTIME_VERSION_MISMATCH) "The native image could not be loaded, because it was generated for use by a different version of the runtime." - MSG_FOR_URT_HR(COR_E_LOADING_WINMD_REFERENCE_ASSEMBLY) "Contract Windows Runtime assemblies cannot be loaded for execution. Make sure your application only contains non-contract Windows Runtime assemblies." - MSG_FOR_URT_HR(CLDB_E_FILE_BADREAD) "Error occurred during a read." - MSG_FOR_URT_HR(CLDB_E_FILE_BADWRITE) "Error occurred during a write." - MSG_FOR_URT_HR(CLDB_E_FILE_READONLY) "File is read only." - MSG_FOR_URT_HR(CLDB_E_NAME_ERROR) "Ill-formed name." - MSG_FOR_URT_HR(CLDB_E_TRUNCATION) "Data value was truncated." - MSG_FOR_URT_HR(CLDB_E_FILE_OLDVER) "Old version error." - MSG_FOR_URT_HR(CLDB_E_RELOCATED) "A shared memory open failed to open at the originally assigned memory address." - MSG_FOR_URT_HR(CLDB_E_SMDUPLICATE) "Create of shared memory failed. A memory mapping of the same name already exists." - MSG_FOR_URT_HR(CLDB_E_NO_DATA) "No .CLB data in the memory or stream." - MSG_FOR_URT_HR(CLDB_E_READONLY) "Database is read only." - MSG_FOR_URT_HR(CLDB_E_INCOMPATIBLE) "Importing scope is not compatible with the emitting scope." - MSG_FOR_URT_HR(CLDB_E_FILE_CORRUPT) "File is corrupt." - MSG_FOR_URT_HR(CLDB_E_SCHEMA_VERNOTFOUND) "Required version of schema not found." - MSG_FOR_URT_HR(CLDB_E_BADUPDATEMODE) "Cannot open a incrementally build scope for full update." - MSG_FOR_URT_HR(CLDB_E_INDEX_NONULLKEYS) "Null value not allowed in unique index or primary key." - MSG_FOR_URT_HR(CLDB_E_INDEX_DUPLICATE) "Index has been duplicated." - MSG_FOR_URT_HR(CLDB_E_INDEX_BADTYPE) "The columns data type is not allowed in an index." - MSG_FOR_URT_HR(CLDB_E_INDEX_NOTFOUND) "Index not found." - MSG_FOR_URT_HR(CLDB_E_RECORD_NOTFOUND) "Record not found on lookup." - MSG_FOR_URT_HR(CLDB_E_RECORD_OVERFLOW) "Too many records were returned for criteria." - MSG_FOR_URT_HR(CLDB_E_RECORD_DUPLICATE) "Record is a duplicate." - MSG_FOR_URT_HR(CLDB_E_RECORD_PKREQUIRED) "Primary key value is required." - MSG_FOR_URT_HR(CLDB_E_RECORD_DELETED) "Record is valid but deleted." - MSG_FOR_URT_HR(CLDB_E_RECORD_OUTOFORDER) "Record is emitted out of order." - MSG_FOR_URT_HR(CLDB_E_COLUMN_OVERFLOW) "Data too large." - MSG_FOR_URT_HR(CLDB_E_COLUMN_READONLY) "Column cannot be changed." - MSG_FOR_URT_HR(CLDB_E_COLUMN_SPECIALCOL) "Too many RID or primary key columns, 1 is max." - MSG_FOR_URT_HR(CLDB_E_COLUMN_PKNONULLS) "Primary key column may not allow the null value." - MSG_FOR_URT_HR(CLDB_E_TABLE_CANTDROP) "Attempted auto-drop of table while open." - MSG_FOR_URT_HR(CLDB_E_OBJECT_NOTFOUND) "Object not found in the database." - MSG_FOR_URT_HR(CLDB_E_OBJECT_COLNOTFOUND) "Column not found." - MSG_FOR_URT_HR(CLDB_E_VECTOR_BADINDEX) "Invalid index." - MSG_FOR_URT_HR(CLDB_E_TOO_BIG) "A blob or string was too big." - MSG_FOR_URT_HR(META_E_INVALID_TOKEN_TYPE) "A token of the wrong type passed to a metadata function." - MSG_FOR_URT_HR(TLBX_E_INVALID_TYPEINFO) "Typelib import: Invalid type, not converted." - MSG_FOR_URT_HR(TLBX_E_INVALID_TYPEINFO_UNNAMED) "Typelib import: Invalid type, not converted - name unknown." - MSG_FOR_URT_HR(TLBX_E_CTX_NESTED) "Typelib export: TLBX_E_CTX_NESTED" - MSG_FOR_URT_HR(TLBX_E_ERROR_MESSAGE) "Typelib export: General error. See IError info for more information." - MSG_FOR_URT_HR(TLBX_E_CANT_SAVE) "Typelib export: SaveAllChanges() failed." - MSG_FOR_URT_HR(TLBX_W_LIBNOTREGISTERED) "Typelib export: Type library is not registered." - MSG_FOR_URT_HR(TLBX_E_CANTLOADLIBRARY) "Typelib export: Type library could not be loaded." - MSG_FOR_URT_HR(TLBX_E_BAD_VT_TYPE) "Typelib import: Invalid vartype, not converted." - MSG_FOR_URT_HR(TLBX_E_NO_MSCOREE_TLB) "Typelib export: Could not load mscoree.tlb." - MSG_FOR_URT_HR(TLBX_E_BAD_MSCOREE_TLB) "Typelib export: Could not get a required typeinfo from mscoree.tlb." - MSG_FOR_URT_HR(TLBX_E_TLB_EXCEPTION) "Typelib import: Fault reading a typelib." - MSG_FOR_URT_HR(TLBX_E_MULTIPLE_LCIDS) "Typelib import: Multiple [lcid] parameters on a method." - MSG_FOR_URT_HR(TLBX_E_AMBIGUOUS_RETURN) "Typelib import: Duplicate or ambiguous return types." - MSG_FOR_URT_HR(TLBX_E_DUPLICATE_TYPE_NAME) "Typelib import: Duplicate name (due to user-defined name)." - MSG_FOR_URT_HR(TLBX_I_NONSEQUENTIALSTRUCT) "Typelib export: Cannot convert non-sequential structs." - MSG_FOR_URT_HR(TLBX_I_RESOLVEREFFAILED) "Typelib import: The resolve ref call failed." - MSG_FOR_URT_HR(TLBX_E_ASANY) "Typelib export: Encountered AsAny - ignored." - MSG_FOR_URT_HR(TLBX_E_INVALIDLCIDPARAM) "Typelib export: Encountered an [lcid] attribute set to an invalid parameter." - MSG_FOR_URT_HR(TLBX_E_LCIDONDISPONLYITF) "Typelib export: Encountered an [lcid] attribute on a pure dispatch interface." - MSG_FOR_URT_HR(TLBX_E_NONPUBLIC_FIELD) "Typelib export: Non-public field in public struct." - MSG_FOR_URT_HR(TLBX_E_BAD_NAMES) "Typelib export: Bad names list." - MSG_FOR_URT_HR(TLBX_E_GENERICINST_SIGNATURE) "TypeLib export: generic type instance in signature." - MSG_FOR_URT_HR(TLBX_E_GENERICPAR_SIGNATURE) "TypeLib export: generic type parameter in signature." - MSG_FOR_URT_HR(META_E_DUPLICATE) "Attempted to define an object that already exists." - MSG_FOR_URT_HR(META_E_GUID_REQUIRED) "A guid was not provided where one was required." - MSG_FOR_URT_HR(META_E_TYPEDEF_MISMATCH) "Merge: an import typedef matched ns.name, but not version and guid." - MSG_FOR_URT_HR(META_E_MERGE_COLLISION) "Merge: conflict between import and emit." - MSG_FOR_URT_HR(TLBX_E_NO_SAFEHANDLE_ARRAYS) "TypeLib export: Detected array of SafeHandles." - MSG_FOR_URT_HR(META_E_METHD_NOT_FOUND) "Merge: Class already in emit scope, but member not found." - MSG_FOR_URT_HR(META_E_FIELD_NOT_FOUND) "Merge: Class already in emit scope, but member not found." - MSG_FOR_URT_HR(META_E_PARAM_MISMATCH) "Merge: Parameter information mismatched." - MSG_FOR_URT_HR(META_E_BADMETADATA) "Merge: Inconsistency in meta data import scope." - MSG_FOR_URT_HR(META_E_INTFCEIMPL_NOT_FOUND) "Merge: Class already in emit scope, but interfaceimpl not found." - MSG_FOR_URT_HR(TLBX_E_NO_CRITICALHANDLE_ARRAYS) "TypeLib export: Detected array of CriticalHandles." - MSG_FOR_URT_HR(META_E_CLASS_LAYOUT_INCONSISTENT) "Merge: Duplicate classes have inconsistent class layout information." - MSG_FOR_URT_HR(META_E_FIELD_MARSHAL_NOT_FOUND) "Merge: Field is duplicated but no matching FieldMarshal information." - MSG_FOR_URT_HR(META_E_EVENT_NOT_FOUND) "Merge: Method is duplicated but no matching event info." - MSG_FOR_URT_HR(META_E_PROP_NOT_FOUND) "Merge: Method is duplicated but no matching property info." - MSG_FOR_URT_HR(META_E_BAD_SIGNATURE) "Bad binary signature." - MSG_FOR_URT_HR(META_E_BAD_INPUT_PARAMETER) "Bad input parameters." - MSG_FOR_URT_HR(META_E_METHDIMPL_INCONSISTENT) "Merge: duplicated methods have inconsistent ImplFlags." - MSG_FOR_URT_HR(META_E_MD_INCONSISTENCY) "Merge: Inconsistency in meta data." - MSG_FOR_URT_HR(META_E_CANNOTRESOLVETYPEREF) "Cannot resolve typeref." - MSG_FOR_URT_HR(META_E_STRINGSPACE_FULL) "No logical space left to create more user strings." - MSG_FOR_URT_HR(META_E_UNEXPECTED_REMAP) "Unexpected TokenRemap." - MSG_FOR_URT_HR(META_E_HAS_UNMARKALL) "Unmark all has been called already." - MSG_FOR_URT_HR(META_E_MUST_CALL_UNMARKALL) "Must call UnmarkAll first before marking." - MSG_FOR_URT_HR(META_E_GENERICPARAM_INCONSISTENT) "Merge: duplicated types or methods have inconsistent GenericParams." - MSG_FOR_URT_HR(META_E_EVENT_COUNTS) "Merge: different event counts in import and emit scopes." - MSG_FOR_URT_HR(META_E_PROPERTY_COUNTS) "Merge: different property counts in import and emit scopes." - MSG_FOR_URT_HR(META_E_TYPEDEF_MISSING) "Merge: An input scope has a TypeRef which does not have a matching TypeDef." - MSG_FOR_URT_HR(TLBX_E_CANT_LOAD_MODULE) "TypeLib export: cannot open the module to export." - MSG_FOR_URT_HR(TLBX_E_CANT_LOAD_CLASS) "TypeLib export: cannot load a class." - MSG_FOR_URT_HR(TLBX_E_NULL_MODULE) "TypeLib export: the hModule of a loaded class is 0; cannot export it." - MSG_FOR_URT_HR(TLBX_E_NO_CLSID_KEY) "TypeLib export: no CLSID or Interface subkey to HKCR." - MSG_FOR_URT_HR(TLBX_E_CIRCULAR_EXPORT) "TypeLib export: attempted to export an Assembly imported from a TLB." - MSG_FOR_URT_HR(TLBX_E_CIRCULAR_IMPORT) "TypeLib import: attempted to import a TLB exported from an Assembly." - MSG_FOR_URT_HR(TLBX_E_BAD_NATIVETYPE) "TypeLib export: bad Native type in method signature." - MSG_FOR_URT_HR(TLBX_E_BAD_VTABLE) "TypeLib import: non-increasing vtable (duplicate slots)." - MSG_FOR_URT_HR(TLBX_E_CRM_NON_STATIC) "TypeLib export: the COM register method is non static." - MSG_FOR_URT_HR(TLBX_E_CRM_INVALID_SIG) "TypeLib export: the specified COM register method does not have the correct signature." - MSG_FOR_URT_HR(TLBX_E_CLASS_LOAD_EXCEPTION) "TypeLib export: cannot load CLR type." - MSG_FOR_URT_HR(TLBX_E_UNKNOWN_SIGNATURE) "TypeLib export: unknown element in signature." - MSG_FOR_URT_HR(TLBX_E_REFERENCED_TYPELIB) "TypeLib import: reference to an external typelib." - MSG_FOR_URT_HR(TLBX_E_INVALID_NAMESPACE) "TypeLib import: an imported typelib has an invalid namespace name." - MSG_FOR_URT_HR(TLBX_E_LAYOUT_ERROR) "Typelib export: an error on Layout()" - MSG_FOR_URT_HR(TLBX_E_NOTIUNKNOWN) "Typelib import: Interface not derived from IUnknown." - MSG_FOR_URT_HR(TLBX_E_NONVISIBLEVALUECLASS) "Typelib export: Non COM visible value type in method signature." - MSG_FOR_URT_HR(TLBX_E_LPTSTR_NOT_ALLOWED) "Typelib export: Types which contain the native type NATIVE_TYPE_LPTSTR are not allowed to be exported to COM." - MSG_FOR_URT_HR(TLBX_E_AUTO_CS_NOT_ALLOWED) "Typelib export: Types with a charset of auto are not allowed to be exported to COM." - MSG_FOR_URT_HR(TLBX_E_ENUM_VALUE_INVALID) "Typelib export: The enum value is not legal for a typelib." - MSG_FOR_URT_HR(TLBX_E_DUPLICATE_IID) "Typelib export: Duplicate IID." - MSG_FOR_URT_HR(TLBX_E_NO_NESTED_ARRAYS) "Typelib export: detected nested arrays." - MSG_FOR_URT_HR(TLBX_E_PARAM_ERROR_NAMED) "Typelib import: parameter type could not be converted." - MSG_FOR_URT_HR(TLBX_E_PARAM_ERROR_UNNAMED) "Typelib import: parameter type could not be converted - parameter name unknown." - MSG_FOR_URT_HR(TLBX_E_AGNOST_SIGNATURE) "TypeLib export: size agnostic element in signature." - MSG_FOR_URT_HR(TLBX_E_CONVERT_FAIL) "TypeLib export: exporter failed." - MSG_FOR_URT_HR(TLBX_W_DUAL_NOT_DISPATCH) "Typelib import: [dual] interface not derived from IDispatch." - MSG_FOR_URT_HR(TLBX_E_BAD_SIGNATURE) "Typelib export: bad signature." - MSG_FOR_URT_HR(TLBX_E_ARRAY_NEEDS_NT_FIXED) "Typelib export: non-fixed or non-safearray array in struct." - MSG_FOR_URT_HR(TLBX_E_CLASS_NEEDS_NT_INTF) "Typelib export: non-interface class in struct." - MSG_FOR_URT_HR(META_E_CA_INVALID_TARGET) "Known custom attribute on invalid target." - MSG_FOR_URT_HR(META_E_CA_INVALID_VALUE) "Known custom attribute had invalid value." - MSG_FOR_URT_HR(META_E_CA_INVALID_BLOB) "Known custom attribute blob has bad format." - MSG_FOR_URT_HR(META_E_CA_REPEATED_ARG) "Known custom attribute blob has repeated named argument." - MSG_FOR_URT_HR(META_E_CA_UNKNOWN_ARGUMENT) "Known custom attribute named argument not recognized." - MSG_FOR_URT_HR(META_E_CA_VARIANT_NYI) "Known attribute named argument does not support variant." - MSG_FOR_URT_HR(META_E_CA_ARRAY_NYI) "Known attribute named argument does not support array." - MSG_FOR_URT_HR(META_E_CA_UNEXPECTED_TYPE) "Known attribute parser found unexpected type." - MSG_FOR_URT_HR(META_E_CA_INVALID_ARGTYPE) "Known attribute parser only handles fields, not properties." - MSG_FOR_URT_HR(META_E_CA_INVALID_ARG_FOR_TYPE) "Known attribute parser found an argument that is invalid for the object it is applied to." - MSG_FOR_URT_HR(META_E_CA_INVALID_UUID) "The format of the UUID was invalid." - MSG_FOR_URT_HR(META_E_CA_INVALID_MARSHALAS_FIELDS) "The MarshalAs attribute has fields set that are not valid for the specified unmanaged type." - MSG_FOR_URT_HR(META_E_CA_NT_FIELDONLY) "The specified unmanaged type is only valid on fields." - MSG_FOR_URT_HR(META_E_CA_NEGATIVE_PARAMINDEX) "The parameter index cannot be negative." - MSG_FOR_URT_HR(META_E_CA_NEGATIVE_MULTIPLIER) "The multiplier cannot be negative." - MSG_FOR_URT_HR(META_E_CA_NEGATIVE_CONSTSIZE) "The constant size cannot be negative." - MSG_FOR_URT_HR(META_E_CA_FIXEDSTR_SIZE_REQUIRED) "A fixed string requires a size." - MSG_FOR_URT_HR(META_E_CA_CUSTMARSH_TYPE_REQUIRED) "A custom marshaler requires the custom marshaler type." - MSG_FOR_URT_HR(META_E_CA_FILENAME_REQUIRED) "A DllImport attribute requires a filename." - MSG_FOR_URT_HR(TLBX_W_NO_PROPS_IN_EVENTS) "TypeLib import: Detected properties in a source dispinterface." - MSG_FOR_URT_HR(META_E_NOT_IN_ENC_MODE) "SaveDelta was called without being in EnC mode." - MSG_FOR_URT_HR(META_E_METHOD_COUNTS) "Merge: different method counts in import and emit scopes." - MSG_FOR_URT_HR(META_E_FIELD_COUNTS) "Merge: different field counts in import and emit scopes." - MSG_FOR_URT_HR(META_E_PARAM_COUNTS) "Merge: different parameter counts in import and emit scopes." - MSG_FOR_URT_HR(TLBX_E_TYPED_REF) "TypeLib export: Exporting a TypedReference." - MSG_FOR_URT_HR(TLBX_E_BITNESS_MISMATCH) "TypeLib export: bitness of assembly does not match bitness of output type library." - MSG_FOR_URT_HR(META_E_CA_BAD_FRIENDS_ARGS) "InternalsVisibleTo can't have a version, culture, or processor architecture." - MSG_FOR_URT_HR(VLDTR_E_RID_OUTOFRANGE) "Rid is out of range." - MSG_FOR_URT_HR(VLDTR_E_CDTKN_OUTOFRANGE) "Coded token type is out of range." - MSG_FOR_URT_HR(VLDTR_E_CDRID_OUTOFRANGE) "Coded rid is out of range." - MSG_FOR_URT_HR(VLDTR_E_STRING_INVALID) "String offset is invalid." - MSG_FOR_URT_HR(VLDTR_E_GUID_INVALID) "GUID offset is invalid." - MSG_FOR_URT_HR(VLDTR_E_BLOB_INVALID) "Blob offset if invalid." - MSG_FOR_URT_HR(VLDTR_E_MOD_MULTI) "Multiple module records found." - MSG_FOR_URT_HR(VLDTR_E_MOD_NULLMVID) "Module has null MVID." - MSG_FOR_URT_HR(VLDTR_E_TR_NAMENULL) "TypeRef name is NULL." - MSG_FOR_URT_HR(VLDTR_E_TR_DUP) "TypeRef has a duplicate." - MSG_FOR_URT_HR(VLDTR_E_TD_NAMENULL) "TypeDef name is NULL." - MSG_FOR_URT_HR(VLDTR_E_TD_DUPNAME) "TypeDef has a duplicate based on name+namespace." - MSG_FOR_URT_HR(VLDTR_E_TD_DUPGUID) "TypeDef has a duplicate based on GUID." - MSG_FOR_URT_HR(VLDTR_E_TD_NOTIFACEOBJEXTNULL) "TypeDef that is not an Interface and not System.Object extends nil parent." - MSG_FOR_URT_HR(VLDTR_E_TD_OBJEXTENDSNONNULL) "System.Object extends a non-nil parent." - MSG_FOR_URT_HR(VLDTR_E_TD_EXTENDSSEALED) "TypeDef extends sealed class." - MSG_FOR_URT_HR(VLDTR_E_TD_DLTNORTSPCL) "TypeDef is Deleted but not marked with RTSpecialName." - MSG_FOR_URT_HR(VLDTR_E_TD_RTSPCLNOTDLT) "TypeDef is marked RTSpecialName, but is not a Deleted record." - MSG_FOR_URT_HR(VLDTR_E_MI_DECLPRIV) "MethodImpl's Decl is private." - MSG_FOR_URT_HR(VLDTR_E_AS_BADNAME) "Assembly [Ref] name has path and/or extension." - MSG_FOR_URT_HR(VLDTR_E_FILE_SYSNAME) "File has a system name (con, com, aux, etc.)." - MSG_FOR_URT_HR(VLDTR_E_MI_BODYSTATIC) "MethodImpl's body is static." - MSG_FOR_URT_HR(VLDTR_E_TD_IFACENOTABS) "TypeDef is marked Interface but not Abstract." - MSG_FOR_URT_HR(VLDTR_E_TD_IFACEPARNOTNIL) "TypeDef is marked Interface but parent is not Nil." - MSG_FOR_URT_HR(VLDTR_E_TD_IFACEGUIDNULL) "TypeDef is marked Interface but GUID is NULL." - MSG_FOR_URT_HR(VLDTR_E_MI_DECLFINAL) "TMethodImpl's Decl is final." - MSG_FOR_URT_HR(VLDTR_E_TD_VTNOTSEAL) "TypeDef is marked ValueType but not marked Sealed." - MSG_FOR_URT_HR(VLDTR_E_PD_BADFLAGS) "Parameter has extra bits in flags." - MSG_FOR_URT_HR(VLDTR_E_IFACE_DUP) "InterfaceImpl has a duplicate." - MSG_FOR_URT_HR(VLDTR_E_MR_NAMENULL) "MemberRef name is NULL." - MSG_FOR_URT_HR(VLDTR_E_MR_VTBLNAME) "MemberRef has an invalid name, _VtblGap*." - MSG_FOR_URT_HR(VLDTR_E_MR_DELNAME) "MemberRef has an invalid name, _Deleted*." - MSG_FOR_URT_HR(VLDTR_E_MR_PARNIL) "MemberRef parent Nil in a PE file." - MSG_FOR_URT_HR(VLDTR_E_MR_BADCALLINGCONV) "MemberRef has invalid calling convention." - MSG_FOR_URT_HR(VLDTR_E_MR_NOTVARARG) "MemberRef has Method parent but calling convention is not VARARG." - MSG_FOR_URT_HR(VLDTR_E_MR_NAMEDIFF) "MemberRef name different from parent MethodDef." - MSG_FOR_URT_HR(VLDTR_E_MR_SIGDIFF) "MemberRef signature different from parent MethodDef." - MSG_FOR_URT_HR(VLDTR_E_MR_DUP) "MemberRef has a duplicate." - MSG_FOR_URT_HR(VLDTR_E_CL_TDAUTO) "ClassLayout parent TypeDef is marked AutoLayout." - MSG_FOR_URT_HR(VLDTR_E_CL_BADPCKSZ) "ClassLayout has bad PackingSize." - MSG_FOR_URT_HR(VLDTR_E_CL_DUP) "ClassLayout has a duplicate." - MSG_FOR_URT_HR(VLDTR_E_FL_BADOFFSET) "FieldLayout2 has bad offset." - MSG_FOR_URT_HR(VLDTR_E_FL_TDNIL) "FieldLayout2 has field with nil parent." - MSG_FOR_URT_HR(VLDTR_E_FL_NOCL) "FieldLayout2 has no ClassLayout record." - MSG_FOR_URT_HR(VLDTR_E_FL_TDNOTEXPLCT) "FieldLayout2 parent TypeDef is not marked with ExplicitLayout." - MSG_FOR_URT_HR(VLDTR_E_FL_FLDSTATIC) "FieldLayout2 has field marked Static." - MSG_FOR_URT_HR(VLDTR_E_FL_DUP) "FieldLayout2 has a duplicate." - MSG_FOR_URT_HR(VLDTR_E_MODREF_NAMENULL) "ModuleRef name is NULL." - MSG_FOR_URT_HR(VLDTR_E_MODREF_DUP) "ModuleRef has a duplicate." - MSG_FOR_URT_HR(VLDTR_E_TR_BADSCOPE) "TypeRef has a bad resolution scope." - MSG_FOR_URT_HR(VLDTR_E_TD_NESTEDNOENCL) "TypeDef marked nested has no encloser." - MSG_FOR_URT_HR(VLDTR_E_TD_EXTTRRES) "TypeDef extends a TypeRef which resolves to a TypeDef in the same module." - MSG_FOR_URT_HR(VLDTR_E_SIGNULL) "Signature specified is zero-sized." - MSG_FOR_URT_HR(VLDTR_E_SIGNODATA) "Signature does not have enough data at specified byte." - MSG_FOR_URT_HR(VLDTR_E_MD_BADCALLINGCONV) "Method signature has invalid calling convention." - MSG_FOR_URT_HR(VLDTR_E_MD_THISSTATIC) "Method is marked static but has HASTHIS/EXPLICITTHIS set on the calling convention." - MSG_FOR_URT_HR(VLDTR_E_MD_NOTTHISNOTSTATIC) "Method is not marked static but is not HASTHIS or EXPLICITTHIS." - MSG_FOR_URT_HR(VLDTR_E_MD_NOARGCNT) "Method signature is missing the argument count." - MSG_FOR_URT_HR(VLDTR_E_SIG_MISSELTYPE) "Signature missing element type." - MSG_FOR_URT_HR(VLDTR_E_SIG_MISSTKN) "Signature missing token." - MSG_FOR_URT_HR(VLDTR_E_SIG_TKNBAD) "Signature has bad token." - MSG_FOR_URT_HR(VLDTR_E_SIG_MISSFPTR) "Signature is missing function pointer." - MSG_FOR_URT_HR(VLDTR_E_SIG_MISSFPTRARGCNT) "Signature has function pointer missing argument count." - MSG_FOR_URT_HR(VLDTR_E_SIG_MISSRANK) "Signature is missing rank specification." - MSG_FOR_URT_HR(VLDTR_E_SIG_MISSNSIZE) "Signature is missing count of sized dimensions." - MSG_FOR_URT_HR(VLDTR_E_SIG_MISSSIZE) "Signature is missing size of dimension." - MSG_FOR_URT_HR(VLDTR_E_SIG_MISSNLBND) "Signature is missing count of lower bounds." - MSG_FOR_URT_HR(VLDTR_E_SIG_MISSLBND) "Signature is missing a lower bound." - MSG_FOR_URT_HR(VLDTR_E_SIG_BADELTYPE) "Signature has bad element type." - MSG_FOR_URT_HR(VLDTR_E_SIG_MISSVASIZE) "Signature has value array missing size." - MSG_FOR_URT_HR(VLDTR_E_FD_BADCALLINGCONV) "Field signature has invalid calling convention." - MSG_FOR_URT_HR(VLDTR_E_MD_NAMENULL) "Method name is NULL." - MSG_FOR_URT_HR(VLDTR_E_MD_PARNIL) "Method has parent NIL." - MSG_FOR_URT_HR(VLDTR_E_MD_DUP) "Method has a duplicate." - MSG_FOR_URT_HR(VLDTR_E_FD_NAMENULL) "Field name is NULL." - MSG_FOR_URT_HR(VLDTR_E_FD_PARNIL) "Field parent is Nil." - MSG_FOR_URT_HR(VLDTR_E_FD_DUP) "Field has a duplicate." - MSG_FOR_URT_HR(VLDTR_E_AS_MULTI) "Multiple Assembly records found." - MSG_FOR_URT_HR(VLDTR_E_AS_NAMENULL) "Assembly name is NULL." - MSG_FOR_URT_HR(VLDTR_E_SIG_TOKTYPEMISMATCH) "E_T_VALUETYPE or E_T_CLASS." - MSG_FOR_URT_HR(VLDTR_E_CL_TDINTF) "Class layout on an Interface." - MSG_FOR_URT_HR(VLDTR_E_ASOS_OSPLTFRMIDINVAL) "AssemblyOS platform ID invalid." - MSG_FOR_URT_HR(VLDTR_E_AR_NAMENULL) "AssemblyRef name is NULL." - MSG_FOR_URT_HR(VLDTR_E_TD_ENCLNOTNESTED) "TypeDef not nested has encloser." - MSG_FOR_URT_HR(VLDTR_E_AROS_OSPLTFRMIDINVAL) "AssemblyRefOS has invalid platform ID." - MSG_FOR_URT_HR(VLDTR_E_FILE_NAMENULL) "File name is NULL." - MSG_FOR_URT_HR(VLDTR_E_CT_NAMENULL) "ExportedType name is NULL." - MSG_FOR_URT_HR(VLDTR_E_TD_EXTENDSCHILD) "TypeDef extends its own child." - MSG_FOR_URT_HR(VLDTR_E_MAR_NAMENULL) "ManifestResource name is NULL." - MSG_FOR_URT_HR(VLDTR_E_FILE_DUP) "File has a duplicate." - MSG_FOR_URT_HR(VLDTR_E_FILE_NAMEFULLQLFD) "File name is fully qualified." - MSG_FOR_URT_HR(VLDTR_E_CT_DUP) "ExportedType has a duplicate." - MSG_FOR_URT_HR(VLDTR_E_MAR_DUP) "ManifestResource has a duplicate." - MSG_FOR_URT_HR(VLDTR_E_MAR_NOTPUBPRIV) "ManifestResource is neither Public nor Private." - MSG_FOR_URT_HR(VLDTR_E_TD_ENUMNOVALUE) "Enum has no value__ field." - MSG_FOR_URT_HR(VLDTR_E_TD_ENUMVALSTATIC) "Enum's value__ field is static." - MSG_FOR_URT_HR(VLDTR_E_TD_ENUMVALNOTSN) "Enum's value__ field is not SpecialName." - MSG_FOR_URT_HR(VLDTR_E_TD_ENUMFLDNOTST) "Enum's field is not static." - MSG_FOR_URT_HR(VLDTR_E_TD_ENUMFLDNOTLIT) "Enum's field is not literal." - MSG_FOR_URT_HR(VLDTR_E_TD_ENUMNOLITFLDS) "Enum has no literal fields." - MSG_FOR_URT_HR(VLDTR_E_TD_ENUMFLDSIGMISMATCH) "Enum's field signature does not match value__ signature." - MSG_FOR_URT_HR(VLDTR_E_TD_ENUMVALNOT1ST) "Enum's value__ field is not first." - MSG_FOR_URT_HR(VLDTR_E_FD_NOTVALUERTSN) "Field is RTSpecialName but name is not value__." - MSG_FOR_URT_HR(VLDTR_E_FD_VALUEPARNOTENUM) "Field value__ in not Enum class." - MSG_FOR_URT_HR(VLDTR_E_FD_INSTINIFACE) "Instance field in interface." - MSG_FOR_URT_HR(VLDTR_E_FD_NOTPUBINIFACE) "Non-public field in interface." - MSG_FOR_URT_HR(VLDTR_E_FMD_GLOBALNOTPUBPRIVSC) "Global field or method is neither Public nor PrivateScope." - MSG_FOR_URT_HR(VLDTR_E_FMD_GLOBALNOTSTATIC) "Global field or method is not static." - MSG_FOR_URT_HR(VLDTR_E_FD_GLOBALNORVA) "Global field has no RVA." - MSG_FOR_URT_HR(VLDTR_E_MD_CTORZERORVA) ".ctor or .cctor has zero RVA." - MSG_FOR_URT_HR(VLDTR_E_FD_MARKEDNOMARSHAL) "Field is marked marshaled but has no marshaling record." - MSG_FOR_URT_HR(VLDTR_E_FD_MARSHALNOTMARKED) "Field has marshaling record but is not marked marshaled." - MSG_FOR_URT_HR(VLDTR_E_FD_MARKEDNODEFLT) "Field is marked HasDefault but has no const value." - MSG_FOR_URT_HR(VLDTR_E_FD_DEFLTNOTMARKED) "Field has const value record but is not marked HasDefault." - MSG_FOR_URT_HR(VLDTR_E_FMD_MARKEDNOSECUR) "Field or method is marked HasSecurity but has no security record." - MSG_FOR_URT_HR(VLDTR_E_FMD_SECURNOTMARKED) "Field or method has security record but is not marked HasSecurity." - MSG_FOR_URT_HR(VLDTR_E_FMD_PINVOKENOTSTATIC) "Field or method is PInvoke but is not marked Static." - MSG_FOR_URT_HR(VLDTR_E_FMD_MARKEDNOPINVOKE) "Field or method is marked PInvoke but has no ImplMap." - MSG_FOR_URT_HR(VLDTR_E_FMD_PINVOKENOTMARKED) "Field or method has ImplMap but is not marked PInvoke." - MSG_FOR_URT_HR(VLDTR_E_FMD_BADIMPLMAP) "Field or method has invalid ImplMap." - MSG_FOR_URT_HR(VLDTR_E_IMAP_BADMODREF) "ImplMap has invalid ModuleRef." - MSG_FOR_URT_HR(VLDTR_E_IMAP_BADMEMBER) "ImplMap has invalid MemberForwarded." - MSG_FOR_URT_HR(VLDTR_E_IMAP_BADIMPORTNAME) "ImplMap has invalid ImportName." - MSG_FOR_URT_HR(VLDTR_E_IMAP_BADCALLCONV) "ImplMap has invalid call conv." - MSG_FOR_URT_HR(VLDTR_E_FMD_BADACCESSFLAG) "Field or method has invalid access flag." - MSG_FOR_URT_HR(VLDTR_E_FD_INITONLYANDLITERAL) "Field is InitOnly and Literal." - MSG_FOR_URT_HR(VLDTR_E_FD_LITERALNOTSTATIC) "Field is Literal but not Static." - MSG_FOR_URT_HR(VLDTR_E_FMD_RTSNNOTSN) "Field or method is RTSpec.Name but not Spec.Name." - MSG_FOR_URT_HR(VLDTR_E_MD_ABSTPARNOTABST) "Method is abstract, parent is not." - MSG_FOR_URT_HR(VLDTR_E_MD_NOTSTATABSTININTF) "Method not static or abstract in interface." - MSG_FOR_URT_HR(VLDTR_E_MD_NOTPUBININTF) "Method not public in interface." - MSG_FOR_URT_HR(VLDTR_E_MD_CTORININTF) ".ctor in interface." - MSG_FOR_URT_HR(VLDTR_E_MD_GLOBALCTORCCTOR) "global .ctor or .cctor." - MSG_FOR_URT_HR(VLDTR_E_MD_CTORSTATIC) "static .ctor." - MSG_FOR_URT_HR(VLDTR_E_MD_CTORNOTSNRTSN) ".ctor or .cctor not marked SpecialName or RTSpecialName." - MSG_FOR_URT_HR(VLDTR_E_MD_CTORVIRT) "virtual .ctor or .cctor." - MSG_FOR_URT_HR(VLDTR_E_MD_CTORABST) "abstract .ctor or .cctor." - MSG_FOR_URT_HR(VLDTR_E_MD_CCTORNOTSTATIC) "instance .cctor." - MSG_FOR_URT_HR(VLDTR_E_MD_ZERORVA) "RVA set to zero, but method not abstract or pinvoke or runtime, or reverse." - MSG_FOR_URT_HR(VLDTR_E_MD_FINNOTVIRT) "Method is final and not virtual." - MSG_FOR_URT_HR(VLDTR_E_MD_STATANDFINORVIRT) "Method is static and final or virtual." - MSG_FOR_URT_HR(VLDTR_E_MD_ABSTANDFINAL) "Method is abstract and final." - MSG_FOR_URT_HR(VLDTR_E_MD_ABSTANDIMPL) "Method is abstract and implemented." - MSG_FOR_URT_HR(VLDTR_E_MD_ABSTANDPINVOKE) "Method is abstract and pinvoke." - MSG_FOR_URT_HR(VLDTR_E_MD_ABSTNOTVIRT) "Method is abstract and not virtual." - MSG_FOR_URT_HR(VLDTR_E_MD_NOTABSTNOTIMPL) "Method is not abstract and not implemented." - MSG_FOR_URT_HR(VLDTR_E_MD_NOTABSTBADFLAGSRVA) "Method is not abstract and not (non-zero RVA or PInvoke or runtime)." - MSG_FOR_URT_HR(VLDTR_E_MD_PRIVSCOPENORVA) "Method is PrivateScope and has RVA set to zero." - MSG_FOR_URT_HR(VLDTR_E_MD_GLOBALABSTORVIRT) "Global method is abstract or virtual." - MSG_FOR_URT_HR(VLDTR_E_SIG_LONGFORM) "Signature uses long form." - MSG_FOR_URT_HR(VLDTR_E_MD_MULTIPLESEMANTICS) "Method has multiple semantics (warning)." - MSG_FOR_URT_HR(VLDTR_E_MD_INVALIDSEMANTICS) "Method has invalid semantics (not event or property.)" - MSG_FOR_URT_HR(VLDTR_E_MD_SEMANTICSNOTEXIST) "Method has semantics association that does not exist." - MSG_FOR_URT_HR(VLDTR_E_MI_DECLNOTVIRT) "MethodImpl's Decl is not virtual." - MSG_FOR_URT_HR(VLDTR_E_FMD_GLOBALITEM) "Global field or method (warning, CLS)." - MSG_FOR_URT_HR(VLDTR_E_MD_MULTSEMANTICFLAGS) "Method has multiple semantic flags set." - MSG_FOR_URT_HR(VLDTR_E_MD_NOSEMANTICFLAGS) "Method has no semantic flags set." - MSG_FOR_URT_HR(VLDTR_E_FD_FLDINIFACE) "Field in Interface (warning, CLS)." - MSG_FOR_URT_HR(VLDTR_E_AS_HASHALGID) "Unrecognized Hash Alg ID (warning)." - MSG_FOR_URT_HR(VLDTR_E_AS_PROCID) "Unrecognized Processor ID in Assembly(warning)." - MSG_FOR_URT_HR(VLDTR_E_AR_PROCID) "Unrecognized Processor ID in AssemblyRef(warning)." - MSG_FOR_URT_HR(VLDTR_E_CN_PARENTRANGE) "Constant: parent token out of range." - MSG_FOR_URT_HR(VLDTR_E_AS_BADFLAGS) "Invalid flags in Assembly." - MSG_FOR_URT_HR(VLDTR_E_TR_HASTYPEDEF) "There is TypeDef with same name as TypeRef (warning)." - MSG_FOR_URT_HR(VLDTR_E_IFACE_BADIMPL) "In InterfaceImpl, the implementing token is not TypeDef." - MSG_FOR_URT_HR(VLDTR_E_IFACE_BADIFACE) "In InterfaceImpl, the implemented token is not TypeDef or TypeRef." - MSG_FOR_URT_HR(VLDTR_E_TD_SECURNOTMARKED) "TypeDef has security record but it is not marked HasSecurity." - MSG_FOR_URT_HR(VLDTR_E_TD_MARKEDNOSECUR) "TypeDef marked HasSecurity but has no security record." - MSG_FOR_URT_HR(VLDTR_E_MD_CCTORHASARGS) ".cctor has arguments." - MSG_FOR_URT_HR(VLDTR_E_CT_BADIMPL) "ExportedType has invalid Implementation." - MSG_FOR_URT_HR(VLDTR_E_MI_ALIENBODY) "MethodImpl has body from other class." - MSG_FOR_URT_HR(VLDTR_E_MD_CCTORCALLCONV) ".cctor has invalid calling convention." - MSG_FOR_URT_HR(VLDTR_E_MI_BADCLASS) "MethodImpl has invalid Class token." - MSG_FOR_URT_HR(VLDTR_E_MI_CLASSISINTF) "MethodImpl declared in Interface." - MSG_FOR_URT_HR(VLDTR_E_MI_BADDECL) "MethodImpl has invalid MethodDeclaration token." - MSG_FOR_URT_HR(VLDTR_E_MI_BADBODY) "MethodImpl has invalid MethodBody token." - MSG_FOR_URT_HR(VLDTR_E_MI_DUP) "MethodImpl has duplicate." - MSG_FOR_URT_HR(VLDTR_E_FD_BADPARENT) "Bad field parent." - MSG_FOR_URT_HR(VLDTR_E_MD_PARAMOUTOFSEQ) "Parameter out of sequence (warning)." - MSG_FOR_URT_HR(VLDTR_E_MD_PARASEQTOOBIG) "Parameter's sequence number exceeds number of arguments." - MSG_FOR_URT_HR(VLDTR_E_MD_PARMMARKEDNOMARSHAL) "Parameter marked HasMarshal, has no marshaling info." - MSG_FOR_URT_HR(VLDTR_E_MD_PARMMARSHALNOTMARKED) "Parameter has marshaling info, not marked HasMarshal." - MSG_FOR_URT_HR(VLDTR_E_MD_PARMMARKEDNODEFLT) "Parameter marked HasDefault, has no const value." - MSG_FOR_URT_HR(VLDTR_E_MD_PARMDEFLTNOTMARKED) "Parameter has const value, not marked HasDefault." - MSG_FOR_URT_HR(VLDTR_E_PR_BADSCOPE) "Property has invalid scope." - MSG_FOR_URT_HR(VLDTR_E_PR_NONAME) "Property has no name." - MSG_FOR_URT_HR(VLDTR_E_PR_NOSIG) "Property has no signature." - MSG_FOR_URT_HR(VLDTR_E_PR_DUP) "Property has a duplicate." - MSG_FOR_URT_HR(VLDTR_E_PR_BADCALLINGCONV) "Property has bad calling convention." - MSG_FOR_URT_HR(VLDTR_E_PR_MARKEDNODEFLT) "Property marked HasDefault, has no const value." - MSG_FOR_URT_HR(VLDTR_E_PR_DEFLTNOTMARKED) "Property has const value, not marked HasDefault." - MSG_FOR_URT_HR(VLDTR_E_PR_BADSEMANTICS) "Property has method that is neither a Setter nor a Getter." - MSG_FOR_URT_HR(VLDTR_E_PR_BADMETHOD) "Property has method with invalid token." - MSG_FOR_URT_HR(VLDTR_E_PR_ALIENMETHOD) "Property has method from another class." - MSG_FOR_URT_HR(VLDTR_E_CN_BLOBNOTNULL) "Const has non-null blob when it should not." - MSG_FOR_URT_HR(VLDTR_E_CN_BLOBNULL) "Const has null value blob." - MSG_FOR_URT_HR(VLDTR_E_EV_BADSCOPE) "Event has invalid scope." - MSG_FOR_URT_HR(VLDTR_E_EV_NONAME) "Event has no name." - MSG_FOR_URT_HR(VLDTR_E_EV_DUP) "Event has a duplicate." - MSG_FOR_URT_HR(VLDTR_E_EV_BADEVTYPE) "Event has invalid EventType." - MSG_FOR_URT_HR(VLDTR_E_EV_EVTYPENOTCLASS) "Event's EventType is not a class." - MSG_FOR_URT_HR(VLDTR_E_EV_BADSEMANTICS) "Event has method not (AddOn,RemoveOn,Fire,Other)." - MSG_FOR_URT_HR(VLDTR_E_EV_BADMETHOD) "Event has method with invalid token." - MSG_FOR_URT_HR(VLDTR_E_EV_ALIENMETHOD) "Event has method from another class." - MSG_FOR_URT_HR(VLDTR_E_EV_NOADDON) "Event has no AddOn method." - MSG_FOR_URT_HR(VLDTR_E_EV_NOREMOVEON) "Event has no RemoveOn method." - MSG_FOR_URT_HR(VLDTR_E_CT_DUPTDNAME) "ExportedType has same name as TypeDef." - MSG_FOR_URT_HR(VLDTR_E_MAR_BADOFFSET) "MRes refers to non-PE file with non-zero offset." - MSG_FOR_URT_HR(VLDTR_E_DS_BADOWNER) "Declarative security has invalid owner token." - MSG_FOR_URT_HR(VLDTR_E_DS_BADFLAGS) "Declarative security has invalid action flags." - MSG_FOR_URT_HR(VLDTR_E_DS_NOBLOB) "Declarative security has no permission blob." - MSG_FOR_URT_HR(VLDTR_E_MAR_BADIMPL) "Manifest resource has invalid Implementation." - MSG_FOR_URT_HR(VLDTR_E_MR_VARARGCALLINGCONV) "MemberRef has VARARG calling conv. (CLS warning)." - MSG_FOR_URT_HR(VLDTR_E_MD_CTORNOTVOID) ".ctor or .cctor returns something other than void." - MSG_FOR_URT_HR(VLDTR_E_EV_FIRENOTVOID) "Fire method returns something other than void." - MSG_FOR_URT_HR(VLDTR_E_AS_BADLOCALE) "Invalid locale." - MSG_FOR_URT_HR(VLDTR_E_CN_PARENTTYPE) "Constant has parent of invalid type." - MSG_FOR_URT_HR(VLDTR_E_SIG_SENTINMETHODDEF) "E_T_SENTINEL in MethodDef signature." - MSG_FOR_URT_HR(VLDTR_E_SIG_SENTMUSTVARARG) "E_T_SENTINEL <=> VARARG." - MSG_FOR_URT_HR(VLDTR_E_SIG_MULTSENTINELS) "Multiple E_T_SENTINELs." - MSG_FOR_URT_HR(VLDTR_E_SIG_LASTSENTINEL) "E_T_SENTINEL not followed by type." - MSG_FOR_URT_HR(VLDTR_E_SIG_MISSARG) "Signature missing argument." - MSG_FOR_URT_HR(VLDTR_E_SIG_BYREFINFIELD) "Field of ByRef type." - MSG_FOR_URT_HR(VLDTR_E_MD_SYNCMETHODINVTYPE) "Synchronized method in value class." - MSG_FOR_URT_HR(VLDTR_E_TD_NAMETOOLONG) "TypeDef name too long." - MSG_FOR_URT_HR(VLDTR_E_AS_PROCDUP) "Duplicate Assembly Processor." - MSG_FOR_URT_HR(VLDTR_E_ASOS_DUP) "Duplicate Assembly OS (ID+ver.major+ver.minor)." - MSG_FOR_URT_HR(VLDTR_E_MAR_BADFLAGS) "Manifest Resource has bad flags." - MSG_FOR_URT_HR(VLDTR_E_CT_NOTYPEDEFID) "ExportedType has nil TypeDefId." - MSG_FOR_URT_HR(VLDTR_E_FILE_BADFLAGS) "File has bad flags." - MSG_FOR_URT_HR(VLDTR_E_FILE_NULLHASH) "File has no hash blob." - MSG_FOR_URT_HR(VLDTR_E_MOD_NONAME) "Module has no name." - MSG_FOR_URT_HR(VLDTR_E_MOD_NAMEFULLQLFD) "Module has fully-qualified name." - MSG_FOR_URT_HR(VLDTR_E_TD_RTSPCLNOTSPCL) "TypeDef is tdRTSpecialName but not tdSpecialName." - MSG_FOR_URT_HR(VLDTR_E_TD_EXTENDSIFACE) "TypeDef extends interface." - MSG_FOR_URT_HR(VLDTR_E_MD_CTORPINVOKE) ".ctor or .cctor is PInvokeImpl." - MSG_FOR_URT_HR(VLDTR_E_TD_SYSENUMNOTCLASS) "System.Enum is not a class." - MSG_FOR_URT_HR(VLDTR_E_TD_SYSENUMNOTEXTVTYPE) "System.Enum extends not System.ValueType." - MSG_FOR_URT_HR(VLDTR_E_MI_SIGMISMATCH) "MethodImpl's Decl and Body signatures mismatch." - MSG_FOR_URT_HR(VLDTR_E_TD_ENUMHASMETHODS) "TypeDef extends System.Enum but has methods." - MSG_FOR_URT_HR(VLDTR_E_TD_ENUMIMPLIFACE) "TypeDef extends System.Enum but implements an interface." - MSG_FOR_URT_HR(VLDTR_E_TD_ENUMHASPROP) "TypeDef extends System.Enum but has a property." - MSG_FOR_URT_HR(VLDTR_E_TD_ENUMHASEVENT) "TypeDef extends System.Enum but has an event." - MSG_FOR_URT_HR(VLDTR_E_TD_BADMETHODLST) "TypeDef has MethodList > Nmethods+1." - MSG_FOR_URT_HR(VLDTR_E_TD_BADFIELDLST) "TypeDef has FieldList > Nfields+1." - MSG_FOR_URT_HR(VLDTR_E_CN_BADTYPE) "Constant has wrong type." - MSG_FOR_URT_HR(VLDTR_E_TD_ENUMNOINSTFLD) "Enum has no instance fields." - MSG_FOR_URT_HR(VLDTR_E_TD_ENUMMULINSTFLD) "Enum has multiple instance fields." - MSG_FOR_URT_HR(VLDTR_E_INTERRUPTED) "Validator has been interrupted by the VEHandler." - MSG_FOR_URT_HR(VLDTR_E_NOTINIT) "Validator failed to initialize correctly." - MSG_FOR_URT_HR(CORDBG_E_UNRECOVERABLE_ERROR) "Unrecoverable API error." - MSG_FOR_URT_HR(CORDBG_E_PROCESS_TERMINATED) "Process was terminated." - MSG_FOR_URT_HR(CORDBG_E_PROCESS_NOT_SYNCHRONIZED) "Process not synchronized." - MSG_FOR_URT_HR(CORDBG_E_CLASS_NOT_LOADED) "A class is not loaded." - MSG_FOR_URT_HR(CORDBG_E_IL_VAR_NOT_AVAILABLE) "An IL variable is not available at the current native IP." - MSG_FOR_URT_HR(CORDBG_E_BAD_REFERENCE_VALUE) "A reference value was found to be bad during dereferencing." - MSG_FOR_URT_HR(CORDBG_E_FIELD_NOT_AVAILABLE) "A field in a class is not available, because the runtime optimized it away." - MSG_FOR_URT_HR(CORDBG_E_NON_NATIVE_FRAME) "'Native-frame-only' operation on non-native frame." - MSG_FOR_URT_HR(CORDBG_E_NONCONTINUABLE_EXCEPTION) "Cannot Continue on non-continuable exception." - MSG_FOR_URT_HR(CORDBG_E_CODE_NOT_AVAILABLE) "The code is currently unavailable." - MSG_FOR_URT_HR(CORDBG_E_FUNCTION_NOT_IL) "Attempt to get a ICorDebugFunction for a function that is not IL." - MSG_FOR_URT_HR(CORDBG_E_CANT_SET_IP_INTO_FINALLY) "SetIP is not possible because SetIP would move EIP from outside of an exception handling finally clause to a point inside of one." - MSG_FOR_URT_HR(CORDBG_E_CANT_SET_IP_OUT_OF_FINALLY) "SetIP is not possible because it would move EIP from within an exception handling finally clause to a point outside of one." - MSG_FOR_URT_HR(CORDBG_E_CANT_SET_IP_INTO_CATCH) "SetIP is not possible, because SetIP would move EIP from outside of an exception handling catch clause to a point inside of one." - MSG_FOR_URT_HR(CORDBG_E_SET_IP_NOT_ALLOWED_ON_NONLEAF_FRAME) "SetIP cannot be done on any frame except the leaf frame." - MSG_FOR_URT_HR(CORDBG_E_SET_IP_IMPOSSIBLE) "SetIP is not allowed." - MSG_FOR_URT_HR(CORDBG_E_FUNC_EVAL_BAD_START_POINT) "Func eval cannot work. Bad starting point." - MSG_FOR_URT_HR(CORDBG_E_INVALID_OBJECT) "This object value is no longer valid." - MSG_FOR_URT_HR(CORDBG_E_FUNC_EVAL_NOT_COMPLETE) "CordbEval::GetResult called before func eval has finished." - MSG_FOR_URT_HR(CORDBG_E_INPROC_NOT_IMPL) "The in-process version of the debugging API does not support this function." - MSG_FOR_URT_HR(CORDBG_E_STATIC_VAR_NOT_AVAILABLE) "A static variable is not available because it has not been initialized yet." - MSG_FOR_URT_HR(CORDBG_E_OBJECT_IS_NOT_COPYABLE_VALUE_CLASS) "Cannot copy a VC with object refs in it." - MSG_FOR_URT_HR(CORDBG_E_CANT_SETIP_INTO_OR_OUT_OF_FILTER) "SetIP cannot leave or enter a filter." - MSG_FOR_URT_HR(CORDBG_E_CANT_CHANGE_JIT_SETTING_FOR_ZAP_MODULE) "JIT settings for ZAP modules cannot be changed." - MSG_FOR_URT_HR(CORDBG_E_CANT_SET_IP_OUT_OF_FINALLY_ON_WIN64) "SetIP is not possible because it would move EIP from within a finally clause to a point outside of one on WIN64 platforms." - MSG_FOR_URT_HR(CORDBG_E_CANT_SET_IP_OUT_OF_CATCH_ON_WIN64) "SetIP is not possible because it would move EIP from within a catch clause to a point outside of one on WIN64 platforms." - MSG_FOR_URT_HR(CORDBG_E_REMOTE_CONNECTION_CONN_RESET) "The remote device closed the connection." - MSG_FOR_URT_HR(CORDBG_E_REMOTE_CONNECTION_KEEP_ALIVE) "The connection was closed due to a keep-alive failure." - MSG_FOR_URT_HR(CORDBG_E_REMOTE_CONNECTION_FATAL_ERROR) "Generic error that the device connection has been broken with no chance for recovery." - MSG_FOR_URT_HR(CORDBG_E_CANT_SET_TO_JMC) "Cannot use JMC on this code (likely wrong JIT settings)." - MSG_FOR_URT_HR(CORDBG_E_NO_CONTEXT_FOR_INTERNAL_FRAME) "Internal frame markers have no associated context." - MSG_FOR_URT_HR(CORDBG_E_NOT_CHILD_FRAME) "The current frame is not a child frame." - MSG_FOR_URT_HR(CORDBG_E_NON_MATCHING_CONTEXT) "The provided CONTEXT does not match the specified thread." - MSG_FOR_URT_HR(CORDBG_E_PAST_END_OF_STACK) "The stackwalker is now past the end of stack. No information is available." - MSG_FOR_URT_HR(CORDBG_E_FUNC_EVAL_CANNOT_UPDATE_REGISTER_IN_NONLEAF_FRAME) "Func eval cannot update a variable stored in a register on a non-leaf frame. The most likely cause is that such a variable is passed as a ref/out argument." - MSG_FOR_URT_HR(CORDBG_E_BAD_THREAD_STATE) "The state of the thread is invalid." - MSG_FOR_URT_HR(CORDBG_E_DEBUGGER_ALREADY_ATTACHED) "This process has already been attached." - MSG_FOR_URT_HR(CORDBG_E_SUPERFLOUS_CONTINUE) "Returned from a call to Continue that was not matched with a stopping event." - MSG_FOR_URT_HR(CORDBG_E_SET_VALUE_NOT_ALLOWED_ON_NONLEAF_FRAME) "Cannot perfrom SetValue on non-leaf frames." - MSG_FOR_URT_HR(CORDBG_E_ENC_EH_MAX_NESTING_LEVEL_CANT_INCREASE) "When doing Edit and Continue, some JITs do not allow increasing the maximum level to which exception handling can be nested." - MSG_FOR_URT_HR(CORDBG_E_ENC_MODULE_NOT_ENC_ENABLED) "Tried to do Edit and Continue on a module that was not started in Edit and Continue mode." - MSG_FOR_URT_HR(CORDBG_E_SET_IP_NOT_ALLOWED_ON_EXCEPTION) "SetIP cannot be done on any exception." - MSG_FOR_URT_HR(CORDBG_E_VARIABLE_IS_ACTUALLY_LITERAL) "The 'variable' does not exist because it is a literal optimized away by the compiler." - MSG_FOR_URT_HR(CORDBG_E_PROCESS_DETACHED) "Process has been detached." - MSG_FOR_URT_HR(CORDBG_E_ENC_METHOD_SIG_CHANGED) "Not allowed to change the signature of an existing method." - MSG_FOR_URT_HR(CORDBG_E_ENC_METHOD_NO_LOCAL_SIG) "Cannot get the local signature for the method." - MSG_FOR_URT_HR(CORDBG_E_ENC_CANT_ADD_FIELD_TO_VALUE_OR_LAYOUT_CLASS) "Adding a field to a value or layout class is prohibited." - MSG_FOR_URT_HR(CORDBG_E_ENC_CANT_CHANGE_FIELD) "Cannot change field after adding." - MSG_FOR_URT_HR(CORDBG_E_ENC_CANT_ADD_NON_PRIVATE_MEMBER) "Only support addition of private members." - MSG_FOR_URT_HR(CORDBG_E_FIELD_NOT_STATIC) "GetStaticFieldValue called on a non-static field." - MSG_FOR_URT_HR(CORDBG_E_FIELD_NOT_INSTANCE) "Returned if someone tries to call GetStaticFieldValue on a non-instance field." - MSG_FOR_URT_HR(CORDBG_E_ENC_ZAPPED_WITHOUT_ENC) "If a zap file was created without the Edit and Continue flag set, then we cannot do Edit and Continue on it, no matter what." - MSG_FOR_URT_HR(CORDBG_E_ENC_BAD_METHOD_INFO) "Lacking information about method." - MSG_FOR_URT_HR(CORDBG_E_ENC_JIT_CANT_UPDATE) "The JIT is unable to update the method." - MSG_FOR_URT_HR(CORDBG_E_ENC_MISSING_CLASS) "An internal structure about the class is missing." - MSG_FOR_URT_HR(CORDBG_E_ENC_INTERNAL_ERROR) "Internal Runtime Error while doing Edit-and-Continue." - MSG_FOR_URT_HR(CORDBG_E_ENC_HANGING_FIELD) "The field was added via Edit and Continue after the class was loaded." - MSG_FOR_URT_HR(CORDBG_E_MODULE_NOT_LOADED) "Module not loaded." - MSG_FOR_URT_HR(CORDBG_E_ENC_CANT_CHANGE_SUPERCLASS) "Not allowed to change base class." - MSG_FOR_URT_HR(CORDBG_E_UNABLE_TO_SET_BREAKPOINT) "Cannot set a breakpoint here." - MSG_FOR_URT_HR(CORDBG_E_DEBUGGING_NOT_POSSIBLE) "Debugging is not possible due to an incompatibility within the CLR implementation." - MSG_FOR_URT_HR(CORDBG_E_KERNEL_DEBUGGER_ENABLED) "A kernel debugger is enabled on the system. User-mode debugging will trap to the kernel debugger." - MSG_FOR_URT_HR(CORDBG_E_KERNEL_DEBUGGER_PRESENT) "A kernel debugger is present on the system. User-mode debugging will trap to the kernel debugger." - MSG_FOR_URT_HR(CORDBG_E_HELPER_THREAD_DEAD) "The debugger's internal helper thread is dead." - MSG_FOR_URT_HR(CORDBG_E_INTERFACE_INHERITANCE_CANT_CHANGE) "Not allowed to change interface inheritance." - MSG_FOR_URT_HR(CORDBG_E_INCOMPATIBLE_PROTOCOL) "The debugger's protocol is incompatible with the debuggee." - MSG_FOR_URT_HR(CORDBG_E_TOO_MANY_PROCESSES) "The debugger can only handle a finite number of debuggees." - MSG_FOR_URT_HR(CORDBG_E_INTEROP_NOT_SUPPORTED) "Interop debugging is not supported." - MSG_FOR_URT_HR(CORDBG_E_NO_REMAP_BREAKPIONT) "Cannot call RemapFunction until have received RemapBreakpoint." - MSG_FOR_URT_HR(CORDBG_E_OBJECT_NEUTERED) "Object is in a zombie state." - MSG_FOR_URT_HR(CORPROF_E_FUNCTION_NOT_COMPILED) "Function not yet compiled." - MSG_FOR_URT_HR(CORPROF_E_DATAINCOMPLETE) "The ID is not fully loaded/defined yet." - MSG_FOR_URT_HR(CORPROF_E_NOT_REJITABLE_METHODS) "The Module is not configured for updateable methods." - MSG_FOR_URT_HR(CORPROF_E_CANNOT_UPDATE_METHOD) "The Method could not be updated for re-JIT." - MSG_FOR_URT_HR(CORPROF_E_FUNCTION_NOT_IL) "The Method has no associated IL." - MSG_FOR_URT_HR(CORPROF_E_NOT_MANAGED_THREAD) "The thread has never run managed code before." - MSG_FOR_URT_HR(CORPROF_E_CALL_ONLY_FROM_INIT) "The function may only be called during profiler initialization." - MSG_FOR_URT_HR(CORPROF_E_INPROC_NOT_ENABLED) "In-process debugging must be enabled during initialization." - MSG_FOR_URT_HR(CORPROF_E_JITMAPS_NOT_ENABLED) "Cannot get a JIT map becuase they are not enabled." - MSG_FOR_URT_HR(CORPROF_E_INPROC_ALREADY_BEGUN) "BeginInprocDebugging already called." - MSG_FOR_URT_HR(CORPROF_E_INPROC_NOT_AVAILABLE) "In-process debugging not allowed at this point." - MSG_FOR_URT_HR(CORPROF_E_NOT_YET_AVAILABLE) "Requested information is not yet available." - MSG_FOR_URT_HR(CORPROF_E_TYPE_IS_PARAMETERIZED) "The given type is a generic and cannot be used with this method." - MSG_FOR_URT_HR(CORPROF_E_FUNCTION_IS_PARAMETERIZED) "The given function is a generic and cannot be used with this method." - MSG_FOR_URT_HR(SECURITY_E_XML_TO_ASN_ENCODING) "Failed to convert XML to ASN." - MSG_FOR_URT_HR(SECURITY_E_INCOMPATIBLE_SHARE) "Loading this assembly would produce a different grant set from other instances." - MSG_FOR_URT_HR(SECURITY_E_UNVERIFIABLE) "Unverifiable code failed policy check." - MSG_FOR_URT_HR(SECURITY_E_INCOMPATIBLE_EVIDENCE) "Assembly already loaded without additional security evidence." - MSG_FOR_URT_HR(CORSEC_E_DECODE_SET) "Failure decoding permission set." - MSG_FOR_URT_HR(CORSEC_E_ENCODE_SET) "Failure encoding permission set." - MSG_FOR_URT_HR(CORSEC_E_UNSUPPORTED_FORMAT) "Unrecognized encoding format." - MSG_FOR_URT_HR(CORSEC_E_CRYPTOAPI_CALL_FAILED) "StrongName APIs not supported on system." - MSG_FOR_URT_HR(CORSEC_E_NO_SUITABLE_CSP) "StrongName APIs could not locate a matching CSP." - MSG_FOR_URT_HR(CORSEC_E_INVALID_ATTR) "Invalid security custom attribute." - MSG_FOR_URT_HR(CORSEC_E_POLICY_EXCEPTION) "PolicyException thrown." - MSG_FOR_URT_HR(CORSEC_E_MIN_GRANT_FAIL) "Failed to grant minimum permission requests." - MSG_FOR_URT_HR(CORSEC_E_NO_EXEC_PERM) "Failed to grant permission to execute." - MSG_FOR_URT_HR(CORSEC_E_XMLSYNTAX) "XML Syntax error." - MSG_FOR_URT_HR(CORSEC_E_INVALID_STRONGNAME) "Strong name validation failed." - MSG_FOR_URT_HR(CORSEC_E_MISSING_STRONGNAME) "Assembly is not strong named." - MSG_FOR_URT_HR(CORSEC_E_CONTAINER_NOT_FOUND) "Strong name key container not found." - MSG_FOR_URT_HR(CORSEC_E_INVALID_IMAGE_FORMAT) "Invalid assembly file format." - MSG_FOR_URT_HR(CORSEC_E_INVALID_PUBLICKEY) "Invalid assembly public key." - MSG_FOR_URT_HR(CORSEC_E_SIGNATURE_MISMATCH) "Signature size mismatch." - MSG_FOR_URT_HR(SN_E_PUBLICKEY_MISMATCH) "Public key of assembly did not match signing public key." - MSG_FOR_URT_HR(CORSEC_E_INVALID_SIGNATUREKEY) "Invalid signature public key specified in AssemblySignatureKeyAttribute." - MSG_FOR_URT_HR(CORSEC_E_INVALID_COUNTERSIGNATURE) "Invalid countersignature specified in AssemblySignatureKeyAttribute." - MSG_FOR_URT_HR(CORSEC_E_CRYPTO) "Failure during Cryptographic operation." - MSG_FOR_URT_HR(CORSEC_E_CRYPTO_UNEX_OPER) "Unexpected Cryptographic operation." - MSG_FOR_URT_HR(CORSECATTR_E_BAD_ATTRIBUTE) "Generic problem with a custom attribute." - MSG_FOR_URT_HR(CORSECATTR_E_MISSING_CONSTRUCTOR) "Missing a required constructor." - MSG_FOR_URT_HR(CORSECATTR_E_FAILED_TO_CREATE_PERM) "Unable to create a permission for this attribute." - MSG_FOR_URT_HR(CORSECATTR_E_BAD_ACTION_ASM) "SecurityAction type invalid on assembly." - MSG_FOR_URT_HR(CORSECATTR_E_BAD_ACTION_OTHER) "SecurityAction type invalid on types and methods." - MSG_FOR_URT_HR(CORSECATTR_E_BAD_PARENT) "Security custom attribute attached to invalid parent." - MSG_FOR_URT_HR(CORSECATTR_E_TRUNCATED) "Bad custom attribute serialized blob." - MSG_FOR_URT_HR(CORSECATTR_E_BAD_VERSION) "Bad custom attribute serialized blob version." - MSG_FOR_URT_HR(CORSECATTR_E_BAD_ACTION) "Invalid security action code." - MSG_FOR_URT_HR(CORSECATTR_E_NO_SELF_REF) "CA reference to CA definition in same assembly." - MSG_FOR_URT_HR(CORSECATTR_E_BAD_NONCAS) "Use of non-CAS permission with invalid action." - MSG_FOR_URT_HR(CORSECATTR_E_ASSEMBLY_LOAD_FAILED) "Failed to load assembly containing CA (or required CA type)." - MSG_FOR_URT_HR(CORSECATTR_E_ASSEMBLY_LOAD_FAILED_EX) "Failed to load assembly containing CA (or required CA type)." - MSG_FOR_URT_HR(CORSECATTR_E_TYPE_LOAD_FAILED) "Failed to load CA type (or required CA type)." - MSG_FOR_URT_HR(CORSECATTR_E_TYPE_LOAD_FAILED_EX) "Failed to load CA type (or required CA type)." - MSG_FOR_URT_HR(CORSECATTR_E_ABSTRACT) "CA type is abstract." - MSG_FOR_URT_HR(CORSECATTR_E_UNSUPPORTED_TYPE) "Security custom attributes do not support array or Type fields and properties." - MSG_FOR_URT_HR(CORSECATTR_E_UNSUPPORTED_ENUM_TYPE) "Unsupported base type for enum field or property." - MSG_FOR_URT_HR(CORSECATTR_E_NO_FIELD) "Could not find a CA field." - MSG_FOR_URT_HR(CORSECATTR_E_NO_PROPERTY) "Could not find a CA property." - MSG_FOR_URT_HR(CORSECATTR_E_EXCEPTION) "Unexpected exception." - MSG_FOR_URT_HR(CORSECATTR_E_EXCEPTION_HR) "Unexpected exception." - MSG_FOR_URT_HR(ISS_E_ISOSTORE) "IsolatedStorage operation failed." - MSG_FOR_URT_HR(ISS_E_OPEN_STORE_FILE) "Unable to open the store." - MSG_FOR_URT_HR(ISS_E_OPEN_FILE_MAPPING) "Unable to create store file mapping." - MSG_FOR_URT_HR(ISS_E_MAP_VIEW_OF_FILE) "Unable to map the store file." - MSG_FOR_URT_HR(ISS_E_GET_FILE_SIZE) "Unable to determine store file size." - MSG_FOR_URT_HR(ISS_E_CREATE_MUTEX) "Unable to create mutex." - MSG_FOR_URT_HR(ISS_E_LOCK_FAILED) "Unable to lock the store." - MSG_FOR_URT_HR(ISS_E_FILE_WRITE) "File Write failed." - MSG_FOR_URT_HR(ISS_E_SET_FILE_POINTER) "Cannot set file pointer." - MSG_FOR_URT_HR(ISS_E_CREATE_DIR) "Unable to create the store directory." - MSG_FOR_URT_HR(ISS_E_STORE_NOT_OPEN) "Store must be open for this operation." - MSG_FOR_URT_HR(ISS_E_CORRUPTED_STORE_FILE) "Store file is corrupt." - MSG_FOR_URT_HR(ISS_E_STORE_VERSION) "Store version is not supported." - MSG_FOR_URT_HR(ISS_E_FILE_NOT_MAPPED) "Store file is not mapped." - MSG_FOR_URT_HR(ISS_E_BLOCK_SIZE_TOO_SMALL) "Block size is too small." - MSG_FOR_URT_HR(ISS_E_ALLOC_TOO_LARGE) "Allocation size is too large." - MSG_FOR_URT_HR(ISS_E_USAGE_WILL_EXCEED_QUOTA) "Allowed quota is fully used." - MSG_FOR_URT_HR(ISS_E_TABLE_ROW_NOT_FOUND) "Row not found." - MSG_FOR_URT_HR(ISS_E_DEPRECATE) "Unable to deprecate old store." - MSG_FOR_URT_HR(ISS_E_CALLER) "Unable to determine the caller." - MSG_FOR_URT_HR(ISS_E_PATH_LENGTH) "Path length is too long." - MSG_FOR_URT_HR(ISS_E_MACHINE) "Machine Store is not supported." - MSG_FOR_URT_HR(ISS_E_MACHINE_DACL) "The DACL for the machine store is incorrect or could not be created." - MSG_FOR_URT_HR(COR_E_EXCEPTION) "General Exception" - MSG_FOR_URT_HR(COR_E_SYSTEM) "System.Exception" - MSG_FOR_URT_HR(COR_E_ARGUMENTOUTOFRANGE) "An argument was out of its legal range." - MSG_FOR_URT_HR(COR_E_ARRAYTYPEMISMATCH) "Attempted to store an object of the wrong type in an array." - MSG_FOR_URT_HR(COR_E_CONTEXTMARSHAL) "Attempted to marshal an object across a context boundary." - MSG_FOR_URT_HR(COR_E_TIMEOUT) "Operation timed out." - MSG_FOR_URT_HR(COR_E_EXECUTIONENGINE) "Internal CLR error." - MSG_FOR_URT_HR(COR_E_FIELDACCESS) "Access to this field is denied." - MSG_FOR_URT_HR(COR_E_INDEXOUTOFRANGE) "Array subscript out of range." - MSG_FOR_URT_HR(COR_E_INVALIDOPERATION) "An operation is not legal in the current state." - MSG_FOR_URT_HR(COR_E_SECURITY) "An error relating to security occurred." - MSG_FOR_URT_HR(COR_E_REMOTING) "An error relating to remoting occurred." - MSG_FOR_URT_HR(COR_E_SERIALIZATION) "An error relating to serialization occurred." - MSG_FOR_URT_HR(COR_E_VERIFICATION) "A verification failure has occurred." - MSG_FOR_URT_HR(COR_E_SERVER) "An error relating to remoting occurred." - MSG_FOR_URT_HR(COR_E_SERVICEDCOMPONENT) "An error relating to ServicedComponent occurred." - MSG_FOR_URT_HR(COR_E_METHODACCESS) "Access to this method is denied." - MSG_FOR_URT_HR(COR_E_MISSINGFIELD) "Field does not exist." - MSG_FOR_URT_HR(COR_E_MISSINGMEMBER) "Member does not exist." - MSG_FOR_URT_HR(COR_E_MISSINGMETHOD) "Method does not exist." - MSG_FOR_URT_HR(COR_E_MULTICASTNOTSUPPORTED) "Attempt to combine delegates that are not multicast." - MSG_FOR_URT_HR(COR_E_NOTSUPPORTED) "Operation is not supported." - MSG_FOR_URT_HR(COR_E_OVERFLOW) "Arithmetic, casting or conversion operation overflowed or underflowed." - MSG_FOR_URT_HR(COR_E_RANK) "An array has the wrong number of dimensions for a particular operation." - MSG_FOR_URT_HR(COR_E_SYNCHRONIZATIONLOCK) "This operation must be called from a synchronized block." - MSG_FOR_URT_HR(COR_E_THREADINTERRUPTED) "Thread was interrupted from a waiting state." - MSG_FOR_URT_HR(COR_E_MEMBERACCESS) "Access to this member is denied." - MSG_FOR_URT_HR(COR_E_THREADSTATE) "Thread is in an invalid state for this operation." - MSG_FOR_URT_HR(COR_E_THREADSTOP) "Thread is stopping." - MSG_FOR_URT_HR(COR_E_TYPELOAD) "Could not find or load a type." - MSG_FOR_URT_HR(COR_E_ENTRYPOINTNOTFOUND) "Could not find the specified DllImport entrypoint." - MSG_FOR_URT_HR(COR_E_DLLNOTFOUND) "Could not find the specified DllImport Dll." - MSG_FOR_URT_HR(COR_E_INVALIDCOMOBJECT) "An invalid __ComObject has been used." - MSG_FOR_URT_HR(COR_E_NOTFINITENUMBER) "Not a Number." - MSG_FOR_URT_HR(COR_E_DUPLICATEWAITOBJECT) "An object appears more than once in the wait objects array." - MSG_FOR_URT_HR(COR_E_SEMAPHOREFULL) "Reached maximum count for semaphore." - MSG_FOR_URT_HR(COR_E_WAITHANDLECANNOTBEOPENED) "No semaphore of the given name exists." - MSG_FOR_URT_HR(COR_E_ABANDONEDMUTEX) "The wait completed due to an abandoned mutex." - MSG_FOR_URT_HR(COR_E_THREADABORTED) "Thread has aborted." - MSG_FOR_URT_HR(COR_E_INVALIDOLEVARIANTTYPE) "OLE Variant has an invalid type." - MSG_FOR_URT_HR(COR_E_MISSINGMANIFESTRESOURCE) "An expected resource in the assembly manifest was missing." - MSG_FOR_URT_HR(COR_E_SAFEARRAYTYPEMISMATCH) "A mismatch has occurred between the runtime type of the array and the sub type recorded in the metadata." - MSG_FOR_URT_HR(COR_E_TYPEINITIALIZATION) "Uncaught exception during type initialization." - MSG_FOR_URT_HR(COR_E_MARSHALDIRECTIVE) "Invalid marshaling directives." - MSG_FOR_URT_HR(COR_E_MISSINGSATELLITEASSEMBLY) "An expected satellite assembly containing the ultimate fallback resources for a given culture was not found or could not be loaded." - MSG_FOR_URT_HR(COR_E_FORMAT) "The format of one argument does not meet the contract of the method." - MSG_FOR_URT_HR(COR_E_SAFEARRAYRANKMISMATCH) "A mismatch has occurred between the runtime rank of the array and the rank recorded in the metadata." - MSG_FOR_URT_HR(COR_E_PLATFORMNOTSUPPORTED) "Operation is not supported on this platform." - MSG_FOR_URT_HR(COR_E_INVALIDPROGRAM) "Invalid IL or CLR metadata." - MSG_FOR_URT_HR(COR_E_OPERATIONCANCELED) "The operation was cancelled." - MSG_FOR_URT_HR(COR_E_DEVICESNOTSUPPORTED) "Devices not supported." - MSG_FOR_URT_HR(COR_E_DATAMISALIGNED) "A datatype misalignment was detected in a load or store instruction." - MSG_FOR_URT_HR(COR_E_CODECONTRACTFAILED) "A managed code contract (ie, precondition, postcondition, invariant, or assert) failed." - MSG_FOR_URT_HR(COR_E_TYPEACCESS) "Access to this type is denied." - MSG_FOR_URT_HR(COR_E_ACCESSING_CCW) "Fail to access a CCW because the corresponding managed object is already collected." - MSG_FOR_URT_HR(COR_E_MAXMETHODSIZE) "A method in this assembly is greater than the maximum allowed method size." - MSG_FOR_URT_HR(COR_E_KEYNOTFOUND) "The given key was not present in the dictionary." - MSG_FOR_URT_HR(COR_E_INSUFFICIENTEXECUTIONSTACK) "Insufficient stack to continue executing the program safely. This can happen from having too many functions on the call stack or function on the stack using too much stack space." - MSG_FOR_URT_HR(COR_E_APPLICATION) "Application exception" - MSG_FOR_URT_HR(COR_E_INVALIDFILTERCRITERIA) "The given filter criteria does not match the filter content." - MSG_FOR_URT_HR(COR_E_REFLECTIONTYPELOAD) "Could not find or load a specific class that was requested through Reflection." - MSG_FOR_URT_HR(COR_E_TARGET) "Attempt to invoke non-static method with a null Object." - MSG_FOR_URT_HR(COR_E_TARGETINVOCATION) "Uncaught exception thrown by method called through Reflection." - MSG_FOR_URT_HR(COR_E_CUSTOMATTRIBUTEFORMAT) "Custom attribute has invalid format." - MSG_FOR_URT_HR(COR_E_IO) "Error during managed I/O." - MSG_FOR_URT_HR(COR_E_FILELOAD) "Could not find or load a specific file." - MSG_FOR_URT_HR(COR_E_OBJECTDISPOSED) "The object has already been disposed." - MSG_FOR_URT_HR(COR_E_FAILFAST) "Runtime operation halted by call to System.Environment.FailFast()." - MSG_FOR_URT_HR(COR_E_HOSTPROTECTION) "The host has forbidden this operation." - MSG_FOR_URT_HR(COR_E_ILLEGAL_REENTRANCY) "Attempted to call into managed code when executing inside a low level extensibility point." - MSG_FOR_URT_HR(CLR_E_SHIM_RUNTIMELOAD) "Failed to load the runtime." - MSG_FOR_URT_HR(CLR_E_SHIM_RUNTIMEEXPORT) "Failed to find a required export in the runtime." - MSG_FOR_URT_HR(CLR_E_SHIM_INSTALLROOT) "Install root is not defined." - MSG_FOR_URT_HR(CLR_E_SHIM_INSTALLCOMP) "Expected component of the runtime is not available." - MSG_FOR_URT_HR(CLR_E_SHIM_LEGACYRUNTIMEALREADYBOUND) "A runtime has already been bound for legacy activation policy use." - MSG_FOR_URT_HR(CLR_E_SHIM_SHUTDOWNINPROGRESS) "The operation is invalid because the process may be shutting down." - MSG_FOR_URT_HR(VER_E_UNKNOWN_OPCODE) "Unknown opcode." - MSG_FOR_URT_HR(VER_E_SIG_CALLCONV) "Unknown calling convention." - MSG_FOR_URT_HR(VER_E_SIG_ELEMTYPE) "Unknown ELEMENT_TYPE." - MSG_FOR_URT_HR(VER_E_RET_SIG) "[return sig]" - MSG_FOR_URT_HR(VER_E_FIELD_SIG) "[field sig]" - MSG_FOR_URT_HR(VER_E_OPEN_DLGT_PROT_ACC) "Protected method access through an open instance delegate is not verifiable." - MSG_FOR_URT_HR(VER_E_INTERNAL) "Internal error." - MSG_FOR_URT_HR(VER_E_STACK_TOO_LARGE) "Stack is too large." - MSG_FOR_URT_HR(VER_E_ARRAY_NAME_LONG) "Array name is too long." - MSG_FOR_URT_HR(VER_E_FALLTHRU) "fall through end of the method without returning" - MSG_FOR_URT_HR(VER_E_TRY_GTEQ_END) "try start >= try end" - MSG_FOR_URT_HR(VER_E_TRYEND_GT_CS) "try end > code size" - MSG_FOR_URT_HR(VER_E_HND_GTEQ_END) "handler start >= handler end" - MSG_FOR_URT_HR(VER_E_HNDEND_GT_CS) "handler end > code size" - MSG_FOR_URT_HR(VER_E_TRY_START) "Try starts in the middle of an instruction." - MSG_FOR_URT_HR(VER_E_HND_START) "Handler starts in the middle of an instruction." - MSG_FOR_URT_HR(VER_E_TRY_OVERLAP) "Try block overlap with another block." - MSG_FOR_URT_HR(VER_E_TRY_EQ_HND_FIL) "Try and filter/handler blocks are equivalent." - MSG_FOR_URT_HR(VER_E_TRY_SHARE_FIN_FAL) "Shared try has finally or fault handler." - MSG_FOR_URT_HR(VER_E_HND_OVERLAP) "Handler block overlaps with another block." - MSG_FOR_URT_HR(VER_E_HND_EQ) "Handler block is the same as another block." - MSG_FOR_URT_HR(VER_E_FIL_OVERLAP) "Filter block overlaps with another block." - MSG_FOR_URT_HR(VER_E_FIL_EQ) "Filter block is the same as another block." - MSG_FOR_URT_HR(VER_E_FIL_CONT_TRY) "Filter contains try." - MSG_FOR_URT_HR(VER_E_FIL_CONT_HND) "Filter contains handler." - MSG_FOR_URT_HR(VER_E_FIL_CONT_FIL) "Nested filters." - MSG_FOR_URT_HR(VER_E_FIL_GTEQ_CS) "filter >= code size" - MSG_FOR_URT_HR(VER_E_FIL_START) "Filter starts in the middle of an instruction." - MSG_FOR_URT_HR(VER_E_FALLTHRU_EXCEP) "fallthru the end of an exception block" - MSG_FOR_URT_HR(VER_E_FALLTHRU_INTO_HND) "fallthru into an exception handler" - MSG_FOR_URT_HR(VER_E_FALLTHRU_INTO_FIL) "fallthru into an exception filter" - MSG_FOR_URT_HR(VER_E_LEAVE) "Leave from outside a try or catch block." - MSG_FOR_URT_HR(VER_E_RETHROW) "Rethrow from outside a catch handler." - MSG_FOR_URT_HR(VER_E_ENDFINALLY) "Endfinally from outside a finally handler" - MSG_FOR_URT_HR(VER_E_ENDFILTER) "Endfilter from outside an exception filter block" - MSG_FOR_URT_HR(VER_E_ENDFILTER_MISSING) "Missing Endfilter." - MSG_FOR_URT_HR(VER_E_BR_INTO_TRY) "Branch into try block." - MSG_FOR_URT_HR(VER_E_BR_INTO_HND) "Branch into exception handler block." - MSG_FOR_URT_HR(VER_E_BR_INTO_FIL) "Branch into exception filter block." - MSG_FOR_URT_HR(VER_E_BR_OUTOF_TRY) "Branch out of try block." - MSG_FOR_URT_HR(VER_E_BR_OUTOF_HND) "Branch out of exception handler block." - MSG_FOR_URT_HR(VER_E_BR_OUTOF_FIL) "Branch out of exception filter block." - MSG_FOR_URT_HR(VER_E_BR_OUTOF_FIN) "Branch out of finally block." - MSG_FOR_URT_HR(VER_E_RET_FROM_TRY) "Return out of try block." - MSG_FOR_URT_HR(VER_E_RET_FROM_HND) "Return out of exception handler block." - MSG_FOR_URT_HR(VER_E_RET_FROM_FIL) "Return out of exception filter block." - MSG_FOR_URT_HR(VER_E_BAD_JMP_TARGET) "jmp / exception into the middle of an instruction." - MSG_FOR_URT_HR(VER_E_PATH_LOC) "Non-compatible types depending on path." - MSG_FOR_URT_HR(VER_E_PATH_THIS) "Init state for this differs depending on path." - MSG_FOR_URT_HR(VER_E_PATH_STACK) "Non-compatible types on stack depending on path." - MSG_FOR_URT_HR(VER_E_PATH_STACK_DEPTH) "Stack depth differs depending on path." - MSG_FOR_URT_HR(VER_E_THIS) "Instance variable (this) missing." - MSG_FOR_URT_HR(VER_E_THIS_UNINIT_EXCEP) "Uninitialized this on entering a try block." - MSG_FOR_URT_HR(VER_E_THIS_UNINIT_STORE) "Store into this when it is uninitialized." - MSG_FOR_URT_HR(VER_E_THIS_UNINIT_RET) "Return from .ctor when this is uninitialized." - MSG_FOR_URT_HR(VER_E_THIS_UNINIT_V_RET) "Return from .ctor before all fields are initialized." - MSG_FOR_URT_HR(VER_E_THIS_UNINIT_BR) "Branch back when this is uninitialized." - MSG_FOR_URT_HR(VER_E_LDFTN_CTOR) "ldftn and ldvirtftn not allowed on .ctor." - MSG_FOR_URT_HR(VER_E_STACK_NOT_EQ) "Non-compatible types on the stack." - MSG_FOR_URT_HR(VER_E_STACK_UNEXPECTED) "Unexpected type on the stack." - MSG_FOR_URT_HR(VER_E_STACK_EXCEPTION) "Missing stack slot for exception." - MSG_FOR_URT_HR(VER_E_STACK_OVERFLOW) "Stack overflow." - MSG_FOR_URT_HR(VER_E_STACK_UNDERFLOW) "Stack underflow." - MSG_FOR_URT_HR(VER_E_STACK_EMPTY) "Stack empty." - MSG_FOR_URT_HR(VER_E_STACK_UNINIT) "Uninitialized item on stack." - MSG_FOR_URT_HR(VER_E_STACK_I_I4_I8) "Expected I, I4, or I8 on the stack." - MSG_FOR_URT_HR(VER_E_STACK_R_R4_R8) "Expected R, R4, or R8 on the stack." - MSG_FOR_URT_HR(VER_E_STACK_NO_R_I8) "unexpected R, R4, R8, or I8 on the stack." - MSG_FOR_URT_HR(VER_E_STACK_NUMERIC) "Expected numeric type on the stack." - MSG_FOR_URT_HR(VER_E_STACK_OBJREF) "Expected an ObjRef on the stack." - MSG_FOR_URT_HR(VER_E_STACK_P_OBJREF) "Expected address of an ObjRef on the stack." - MSG_FOR_URT_HR(VER_E_STACK_BYREF) "Expected ByRef on the stack." - MSG_FOR_URT_HR(VER_E_STACK_METHOD) "Expected pointer to function on the stack." - MSG_FOR_URT_HR(VER_E_STACK_ARRAY_SD) "Expected single dimension array on the stack." - MSG_FOR_URT_HR(VER_E_STACK_VALCLASS) "Expected value type instance on the stack." - MSG_FOR_URT_HR(VER_E_STACK_P_VALCLASS) "Expected address of value type on the stack." - MSG_FOR_URT_HR(VER_E_STACK_NO_VALCLASS) "Unexpected value type instance on the stack." - MSG_FOR_URT_HR(VER_E_LOC_DEAD) "Local variable is unusable at this point." - MSG_FOR_URT_HR(VER_E_LOC_NUM) "Unrecognized local variable number." - MSG_FOR_URT_HR(VER_E_ARG_NUM) "Unrecognized argument number." - MSG_FOR_URT_HR(VER_E_TOKEN_RESOLVE) "Unable to resolve token." - MSG_FOR_URT_HR(VER_E_TOKEN_TYPE) "Unable to resolve type of the token." - MSG_FOR_URT_HR(VER_E_TOKEN_TYPE_MEMBER) "Expected memberRef, memberDef or methodSpec token." - MSG_FOR_URT_HR(VER_E_TOKEN_TYPE_FIELD) "Expected memberRef or fieldDef token." - MSG_FOR_URT_HR(VER_E_TOKEN_TYPE_SIG) "Expected signature token." - MSG_FOR_URT_HR(VER_E_UNVERIFIABLE) "Instruction cannot be verified." - MSG_FOR_URT_HR(VER_E_LDSTR_OPERAND) "Operand does not point to a valid string ref." - MSG_FOR_URT_HR(VER_E_RET_PTR_TO_STACK) "Return type is ByRef, TypedReference, ArgHandle, or ArgIterator." - MSG_FOR_URT_HR(VER_E_RET_VOID) "Stack must be empty on return from a void function." - MSG_FOR_URT_HR(VER_E_RET_MISSING) "Return value missing on the stack." - MSG_FOR_URT_HR(VER_E_RET_EMPTY) "Stack must contain only the return value." - MSG_FOR_URT_HR(VER_E_RET_UNINIT) "Return uninitialized data." - MSG_FOR_URT_HR(VER_E_ARRAY_ACCESS) "Illegal array access." - MSG_FOR_URT_HR(VER_E_ARRAY_V_STORE) "Store non Object type into Object array." - MSG_FOR_URT_HR(VER_E_ARRAY_SD) "Expected single dimension array." - MSG_FOR_URT_HR(VER_E_ARRAY_SD_PTR) "Expected single dimension array of pointer types." - MSG_FOR_URT_HR(VER_E_ARRAY_FIELD) "Array field access is denied." - MSG_FOR_URT_HR(VER_E_ARGLIST) "Allowed only in vararg methods." - MSG_FOR_URT_HR(VER_E_VALCLASS) "Value type expected." - MSG_FOR_URT_HR(VER_E_METHOD_ACCESS) "Method is not visible." - MSG_FOR_URT_HR(VER_E_FIELD_ACCESS) "Field is not visible." - MSG_FOR_URT_HR(VER_E_DEAD) "Item is unusable at this point." - MSG_FOR_URT_HR(VER_E_FIELD_STATIC) "Expected static field." - MSG_FOR_URT_HR(VER_E_FIELD_NO_STATIC) "Expected non-static field." - MSG_FOR_URT_HR(VER_E_ADDR) "Address of not allowed for this item." - MSG_FOR_URT_HR(VER_E_ADDR_BYREF) "Address of not allowed for ByRef." - MSG_FOR_URT_HR(VER_E_ADDR_LITERAL) "Address of not allowed for literal field." - MSG_FOR_URT_HR(VER_E_INITONLY) "Cannot change initonly field outside its .ctor." - MSG_FOR_URT_HR(VER_E_THROW) "Cannot throw this object." - MSG_FOR_URT_HR(VER_E_CALLVIRT_VALCLASS) "Callvirt on a value type method." - MSG_FOR_URT_HR(VER_E_CALL_SIG) "Call signature mismatch." - MSG_FOR_URT_HR(VER_E_CALL_STATIC) "Static function expected." - MSG_FOR_URT_HR(VER_E_CTOR) ".ctor expected." - MSG_FOR_URT_HR(VER_E_CTOR_VIRT) "Cannot use callvirt on .ctor." - MSG_FOR_URT_HR(VER_E_CTOR_OR_SUPER) "Only super::ctor or typeof(this)::ctor allowed here." - MSG_FOR_URT_HR(VER_E_CTOR_MUL_INIT) "Possible call to .ctor more than once." - MSG_FOR_URT_HR(VER_E_SIG) "Unrecognized signature." - MSG_FOR_URT_HR(VER_E_SIG_ARRAY) "Cannot resolve Array type." - MSG_FOR_URT_HR(VER_E_SIG_ARRAY_PTR) "Array of ELEMENT_TYPE_PTR." - MSG_FOR_URT_HR(VER_E_SIG_ARRAY_BYREF) "Array of ELEMENT_TYPE_BYREF or ELEMENT_TYPE_TYPEDBYREF." - MSG_FOR_URT_HR(VER_E_SIG_ELEM_PTR) "ELEMENT_TYPE_PTR cannot be verified." - MSG_FOR_URT_HR(VER_E_SIG_VARARG) "Unexpected vararg." - MSG_FOR_URT_HR(VER_E_SIG_VOID) "Unexpected Void." - MSG_FOR_URT_HR(VER_E_SIG_BYREF_BYREF) "ByRef of ByRef" - MSG_FOR_URT_HR(VER_E_CODE_SIZE_ZERO) "Code size is zero." - MSG_FOR_URT_HR(VER_E_BAD_VARARG) "Unrecognized use of vararg." - MSG_FOR_URT_HR(VER_E_TAIL_CALL) "Missing call, callvirt or calli." - MSG_FOR_URT_HR(VER_E_TAIL_BYREF) "Cannot pass ByRef to a tail call." - MSG_FOR_URT_HR(VER_E_TAIL_RET) "Missing ret." - MSG_FOR_URT_HR(VER_E_TAIL_RET_VOID) "Void ret type expected for tail call." - MSG_FOR_URT_HR(VER_E_TAIL_RET_TYPE) "Tail call return type not compatible." - MSG_FOR_URT_HR(VER_E_TAIL_STACK_EMPTY) "Stack not empty after tail call." - MSG_FOR_URT_HR(VER_E_METHOD_END) "Method ends in the middle of an instruction." - MSG_FOR_URT_HR(VER_E_BAD_BRANCH) "Branch out of the method." - MSG_FOR_URT_HR(VER_E_FIN_OVERLAP) "Finally handler blocks overlap." - MSG_FOR_URT_HR(VER_E_LEXICAL_NESTING) "Lexical nesting." - MSG_FOR_URT_HR(VER_E_VOLATILE) "Missing ldsfld, stsfld, ldind, stind, ldfld, stfld, ldobj, stobj, initblk or cpblk." - MSG_FOR_URT_HR(VER_E_UNALIGNED) "Missing ldind, stind, ldfld, stfld, ldobj, stobj, initblk or cpblk." - MSG_FOR_URT_HR(VER_E_INNERMOST_FIRST) "Innermost exception blocks should be declared first." - MSG_FOR_URT_HR(VER_E_CALLI_VIRTUAL) "Calli not allowed on virtual methods." - MSG_FOR_URT_HR(VER_E_CALL_ABSTRACT) "Call not allowed on abstract methods." - MSG_FOR_URT_HR(VER_E_STACK_UNEXP_ARRAY) "Unexpected array type on the stack." - MSG_FOR_URT_HR(VER_E_NOT_IN_GC_HEAP) "Value type with NotInGCHeap attribute being created on the GC heap." - MSG_FOR_URT_HR(VER_E_TRY_N_EMPTY_STACK) "Attempt to enter a try block with nonempty stack." - MSG_FOR_URT_HR(VER_E_DLGT_CTOR) "Unrecognized arguments for delegate .ctor." - MSG_FOR_URT_HR(VER_E_DLGT_BB) "Delegate .ctor not allowed at the start of a basic block when the function pointer argument is a virtual method." - MSG_FOR_URT_HR(VER_E_DLGT_PATTERN) "Dup, ldvirtftn, newobj delegate::.ctor() pattern expected (in the same basic block)." - MSG_FOR_URT_HR(VER_E_DLGT_LDFTN) "Ldftn or ldvirtftn instruction required before call to a delegate .ctor." - MSG_FOR_URT_HR(VER_E_FTN_ABSTRACT) "Attempt to load address of an abstract method." - MSG_FOR_URT_HR(VER_E_SIG_C_VC) "ELEMENT_TYPE_CLASS ValueClass in signature." - MSG_FOR_URT_HR(VER_E_SIG_VC_C) "ELEMENT_TYPE_VALUETYPE non-ValueClass in signature." - MSG_FOR_URT_HR(VER_E_BOX_PTR_TO_STACK) "Box operation on TypedReference, ArgHandle, or ArgIterator." - MSG_FOR_URT_HR(VER_E_SIG_BYREF_TB_AH) "ByRef of TypedReference, ArgHandle, or ArgIterator." - MSG_FOR_URT_HR(VER_E_SIG_ARRAY_TB_AH) "Array of TypedReference, ArgHandle, or ArgIterator." - MSG_FOR_URT_HR(VER_E_ENDFILTER_STACK) "Stack not empty when leaving an exception filter." - MSG_FOR_URT_HR(VER_E_DLGT_SIG_I) "Unrecognized delegate .ctor signature; expected I." - MSG_FOR_URT_HR(VER_E_DLGT_SIG_O) "Unrecognized delegate .ctor signature; expected Object." - MSG_FOR_URT_HR(VER_E_RA_PTR_TO_STACK) "Mkrefany on TypedReference, ArgHandle, or ArgIterator." - MSG_FOR_URT_HR(VER_E_CATCH_VALUE_TYPE) "Value type not allowed as catch type." - MSG_FOR_URT_HR(VER_E_CATCH_BYREF) "ByRef not allowed as catch type." - MSG_FOR_URT_HR(VER_E_FIL_PRECEED_HND) "filter block should immediately precede handler block" - MSG_FOR_URT_HR(VER_E_LDVIRTFTN_STATIC) "ldvirtftn on static" - MSG_FOR_URT_HR(VER_E_CALLVIRT_STATIC) "callvirt on static" - MSG_FOR_URT_HR(VER_E_INITLOCALS) "initlocals must be set for verifiable methods with one or more local variables." - MSG_FOR_URT_HR(VER_E_BR_TO_EXCEPTION) "branch or leave to the beginning of a catch/filter handler" - MSG_FOR_URT_HR(VER_E_CALL_CTOR) "Call to .ctor only allowed to initialize this pointer from within a .ctor. Try newobj." - MSG_FOR_URT_HR(VER_E_VALCLASS_OBJREF_VAR) "Value type, ObjRef type or variable type expected." - MSG_FOR_URT_HR(VER_E_STACK_P_VALCLASS_OBJREF_VAR) "Expected address of value type, ObjRef type or variable type on the stack." - MSG_FOR_URT_HR(VER_E_SIG_VAR_PARAM) "Unrecognized type parameter of enclosing class." - MSG_FOR_URT_HR(VER_E_SIG_MVAR_PARAM) "Unrecognized type parameter of enclosing method." - MSG_FOR_URT_HR(VER_E_SIG_VAR_ARG) "Unrecognized type argument of referenced class instantiation." - MSG_FOR_URT_HR(VER_E_SIG_MVAR_ARG) "Unrecognized type argument of referenced method instantiation." - MSG_FOR_URT_HR(VER_E_SIG_GENERICINST) "Cannot resolve generic type." - MSG_FOR_URT_HR(VER_E_SIG_METHOD_INST) "Method instantiation contains non boxable type arguments." - MSG_FOR_URT_HR(VER_E_SIG_METHOD_PARENT_INST) "Method parent instantiation contains non boxable type arguments." - MSG_FOR_URT_HR(VER_E_SIG_FIELD_PARENT_INST) "Field parent instantiation contains non boxable type arguments." - MSG_FOR_URT_HR(VER_E_CALLCONV_NOT_GENERICINST) "Unrecognized calling convention for an instantiated generic method." - MSG_FOR_URT_HR(VER_E_TOKEN_BAD_METHOD_SPEC) "Unrecognized generic method in method instantiation." - MSG_FOR_URT_HR(VER_E_BAD_READONLY_PREFIX) "Missing ldelema or call following readonly. prefix." - MSG_FOR_URT_HR(VER_E_BAD_CONSTRAINED_PREFIX) "Missing callvirt following constrained. prefix." - MSG_FOR_URT_HR(VER_E_CIRCULAR_VAR_CONSTRAINTS) "Method parent has circular class type parameter constraints." - MSG_FOR_URT_HR(VER_E_CIRCULAR_MVAR_CONSTRAINTS) "Method has circular method type parameter constraints." - MSG_FOR_URT_HR(VER_E_UNSATISFIED_METHOD_INST) "Method instantiation has unsatisfied method type parameter constraints." - MSG_FOR_URT_HR(VER_E_UNSATISFIED_METHOD_PARENT_INST) "Method parent instantiation has unsatisfied class type parameter constraints." - MSG_FOR_URT_HR(VER_E_UNSATISFIED_FIELD_PARENT_INST) "Field parent instantiation has unsatisfied class type parameter constraints." - MSG_FOR_URT_HR(VER_E_UNSATISFIED_BOX_OPERAND) "Type operand of box instruction has unsatisfied class type parameter constraints." - MSG_FOR_URT_HR(VER_E_CONSTRAINED_CALL_WITH_NON_BYREF_THIS) "The 'this' argument to a constrained call must have ByRef type." - MSG_FOR_URT_HR(VER_E_CONSTRAINED_OF_NON_VARIABLE_TYPE) "The operand to a constrained prefix instruction must be a type parameter." - MSG_FOR_URT_HR(VER_E_READONLY_UNEXPECTED_CALLEE) "The readonly prefix may only be applied to calls to array methods returning ByRefs." - MSG_FOR_URT_HR(VER_E_READONLY_ILLEGAL_WRITE) "Illegal write to readonly ByRef." - MSG_FOR_URT_HR(VER_E_READONLY_IN_MKREFANY) "A readonly ByRef cannot be used with mkrefany." - MSG_FOR_URT_HR(VER_E_UNALIGNED_ALIGNMENT) "Alignment specified for 'unaligned' prefix must be 1, 2, or 4." - MSG_FOR_URT_HR(VER_E_TAILCALL_INSIDE_EH) "The tail.call (or calli or callvirt) instruction cannot be used to transfer control out of a try, filter, catch, or finally block." - MSG_FOR_URT_HR(VER_E_BACKWARD_BRANCH) "Stack height at all points must be determinable in a single forward scan of IL." - MSG_FOR_URT_HR(VER_E_CALL_TO_VTYPE_BASE) "Call to base type of valuetype." - MSG_FOR_URT_HR(VER_E_NEWOBJ_OF_ABSTRACT_CLASS) "Cannot construct an instance of abstract class." - MSG_FOR_URT_HR(VER_E_UNMANAGED_POINTER) "Unmanaged pointers are not a verifiable type." - MSG_FOR_URT_HR(VER_E_LDFTN_NON_FINAL_VIRTUAL) "Cannot LDFTN a non-final virtual method." - MSG_FOR_URT_HR(VER_E_FIELD_OVERLAP) "Accessing type with overlapping fields." - MSG_FOR_URT_HR(VER_E_THIS_MISMATCH) "The 'this' parameter to the call must be the calling method's 'this' parameter." - MSG_FOR_URT_HR(VER_E_STACK_I_I4) "Expected I4 on the stack." - MSG_FOR_URT_HR(VER_E_BAD_PE) "Unverifiable PE Header/native stub." - MSG_FOR_URT_HR(VER_E_BAD_MD) "Unrecognized metadata, unable to verify IL." - MSG_FOR_URT_HR(VER_E_BAD_APPDOMAIN) "Unrecognized appdomain pointer." - MSG_FOR_URT_HR(VER_E_TYPELOAD) "Type load failed." - MSG_FOR_URT_HR(VER_E_PE_LOAD) "Module load failed." - MSG_FOR_URT_HR(VER_E_WRITE_RVA_STATIC) "Cannot modify an imaged based (RVA) static" - MSG_FOR_URT_HR(VER_E_INITIALIZE_ARRAY_MISSING_TOKEN) "Ldtoken instruction required before call to System.Runtime.CompilerServices.InitializeArray." - MSG_FOR_URT_HR(VLDTR_E_IFACE_NOTIFACE) "Interface in InterfaceImpl is not marked tdInterface." - MSG_FOR_URT_HR(VLDTR_E_FD_RVAHASNORVA) "Field marked fdHasFieldRVA but has no RVA record." - MSG_FOR_URT_HR(VLDTR_E_FD_RVAHASZERORVA) "Field marked fdHasFieldRVA has RVA set to zero." - MSG_FOR_URT_HR(VLDTR_E_MD_RVAANDIMPLMAP) "Method has both non-zero RVA and ImplMap." - MSG_FOR_URT_HR(VLDTR_E_TD_EXTRAFLAGS) "TypeDef has extraneous bits in flags." - MSG_FOR_URT_HR(VLDTR_E_TD_EXTENDSITSELF) "TypeDef extends itself." - MSG_FOR_URT_HR(VLDTR_E_TD_SYSVTNOTEXTOBJ) "System.ValueType does not extend System.Object." - MSG_FOR_URT_HR(VLDTR_E_TD_EXTTYPESPEC) "Class extends TypeSpec (warning)." - MSG_FOR_URT_HR(VLDTR_E_TD_VTNOSIZE) "Value Class has zero size." - MSG_FOR_URT_HR(VLDTR_E_TD_IFACESEALED) "Interface is sealed." - MSG_FOR_URT_HR(VLDTR_E_NC_BADNESTED) "Bad 'nested' token in NestedClass." - MSG_FOR_URT_HR(VLDTR_E_NC_BADENCLOSER) "Bad 'enclosing' token in NestedClass." - MSG_FOR_URT_HR(VLDTR_E_NC_DUP) "Duplicate NestedClass record." - MSG_FOR_URT_HR(VLDTR_E_NC_DUPENCLOSER) "Duplicate NestedClass with different encloser." - MSG_FOR_URT_HR(VLDTR_E_FRVA_ZERORVA) "RVA set to zero in FieldRVA record." - MSG_FOR_URT_HR(VLDTR_E_FRVA_BADFIELD) "Invalid field token in FieldRVA record." - MSG_FOR_URT_HR(VLDTR_E_FRVA_DUPRVA) "Duplicate RVA in FieldRVA record." - MSG_FOR_URT_HR(VLDTR_E_FRVA_DUPFIELD) "Duplicate field in FieldRVA record." - MSG_FOR_URT_HR(VLDTR_E_EP_BADTOKEN) "Bad token as entry point in CLR header." - MSG_FOR_URT_HR(VLDTR_E_EP_INSTANCE) "Entry point in CLR header is a token of instance method." - MSG_FOR_URT_HR(VLDTR_E_TD_ENUMFLDBADTYPE) "Enum has non-integral underlying type." - MSG_FOR_URT_HR(VLDTR_E_MD_BADRVA) "Method has bogus RVA." - MSG_FOR_URT_HR(VLDTR_E_FD_LITERALNODEFAULT) "Literal field has no const value." - MSG_FOR_URT_HR(VLDTR_E_IFACE_METHNOTIMPL) "Class implementing an interface does not implement one of methods." - MSG_FOR_URT_HR(VLDTR_E_CA_BADPARENT) "CA has invalid owner." - MSG_FOR_URT_HR(VLDTR_E_CA_BADTYPE) "CA has invalid type." - MSG_FOR_URT_HR(VLDTR_E_CA_NOTCTOR) "CA type is not .ctor." - MSG_FOR_URT_HR(VLDTR_E_CA_BADSIG) "CA type has bad signature." - MSG_FOR_URT_HR(VLDTR_E_CA_NOSIG) "CA type has no signature." - MSG_FOR_URT_HR(VLDTR_E_CA_BADPROLOG) "CA blob has bad prolog (not 0x01 0x00)." - MSG_FOR_URT_HR(VLDTR_E_MD_BADLOCALSIGTOK) "Method has invalid LocalSig token." - MSG_FOR_URT_HR(VLDTR_E_MD_BADHEADER) "Method has invalid header." - MSG_FOR_URT_HR(VLDTR_E_EP_TOOMANYARGS) "Entry point has more than one argument." - MSG_FOR_URT_HR(VLDTR_E_EP_BADRET) "Entry point has bad return type." - MSG_FOR_URT_HR(VLDTR_E_EP_BADARG) "Entry point has bad argument." - MSG_FOR_URT_HR(VLDTR_E_SIG_BADVOID) "Illegal 'void' in signature." - MSG_FOR_URT_HR(VLDTR_E_IFACE_METHMULTIMPL) "Multiple implementation of method." - MSG_FOR_URT_HR(VLDTR_E_GP_NAMENULL) "GenericParam name is NULL." - MSG_FOR_URT_HR(VLDTR_E_GP_OWNERNIL) "GenericParam has nil owner." - MSG_FOR_URT_HR(VLDTR_E_GP_DUPNAME) "GenericParam has duplicate by owner and name." - MSG_FOR_URT_HR(VLDTR_E_GP_DUPNUMBER) "GenericParam has duplicate by owner and number." - MSG_FOR_URT_HR(VLDTR_E_GP_NONSEQ_BY_OWNER) "GenericParam is non sequential by owner." - MSG_FOR_URT_HR(VLDTR_E_GP_NONSEQ_BY_NUMBER) "GenericParam is non sequential by number." - MSG_FOR_URT_HR(VLDTR_E_GP_UNEXPECTED_OWNER_FOR_VARIANT_VAR) "GenericParam has variance but its owner is not an interface or delegate." - MSG_FOR_URT_HR(VLDTR_E_GP_ILLEGAL_VARIANT_MVAR) "GenericParam is a method type parameter and must be non-variant." - MSG_FOR_URT_HR(VLDTR_E_GP_ILLEGAL_VARIANCE_FLAGS) "GenericParam has illegal value for variance flags." - MSG_FOR_URT_HR(VLDTR_E_GP_REFANDVALUETYPE) "GenericParam has incompatible special constraints reference type and valuetype." - MSG_FOR_URT_HR(VLDTR_E_GPC_OWNERNIL) "GenericParamConstraint has nil owner." - MSG_FOR_URT_HR(VLDTR_E_GPC_DUP) "GenericParamConstraint has duplicate by owner and constraint." - MSG_FOR_URT_HR(VLDTR_E_GPC_NONCONTIGUOUS) "GenericParamConstraint is non-contiguous with preceeding constraints for same owner." - MSG_FOR_URT_HR(VLDTR_E_MS_METHODNIL) "MethodSpec has nil method." - MSG_FOR_URT_HR(VLDTR_E_MS_DUP) "MethodSpec has duplicate based on method and instantiation." - MSG_FOR_URT_HR(VLDTR_E_MS_BADCALLINGCONV) "MethodSpec signature has invalid calling convention." - MSG_FOR_URT_HR(VLDTR_E_MS_MISSARITY) "MethodSpec signature is missing arity specification." - MSG_FOR_URT_HR(VLDTR_E_MS_MISSARG) "MethodSpec signature is missing type argument." - MSG_FOR_URT_HR(VLDTR_E_MS_ARITYMISMATCH) "MethodSpec arity of generic method and instantiation do not match." - MSG_FOR_URT_HR(VLDTR_E_MS_METHODNOTGENERIC) "MethodSpec method is not generic." - MSG_FOR_URT_HR(VLDTR_E_SIG_MISSARITY) "Signature missing arity of instantiated generic type." - MSG_FOR_URT_HR(VLDTR_E_SIG_ARITYMISMATCH) "Signature has generic type of arity instantiated at different arity." - MSG_FOR_URT_HR(VLDTR_E_MD_GENERIC_CCTOR) "Method cannot be both generic and a class constructor." - MSG_FOR_URT_HR(VLDTR_E_MD_GENERIC_CTOR) "Method cannot be both generic and an instance constructor." - MSG_FOR_URT_HR(VLDTR_E_MD_GENERIC_IMPORT) "Method cannot be both generic and defined on an imported type." - MSG_FOR_URT_HR(VLDTR_E_MD_GENERIC_BADCALLCONV) "Method cannot be both generic and have non-default calling convention." - MSG_FOR_URT_HR(VLDTR_E_EP_GENERIC_METHOD) "Entry point in CLR header is the token for a generic method." - MSG_FOR_URT_HR(VLDTR_E_MD_MISSARITY) "Method signature is generic but is missing its arity." - MSG_FOR_URT_HR(VLDTR_E_MD_ARITYZERO) "Method signature is generic but its arity is zero." - MSG_FOR_URT_HR(VLDTR_E_SIG_ARITYZERO) "Signature has generic type instantiated at arity 0." - MSG_FOR_URT_HR(VLDTR_E_MS_ARITYZERO) "MethodSpec signature has arity 0." - MSG_FOR_URT_HR(VLDTR_E_MD_GPMISMATCH) "MethodDef signature has arity n but owns m GenericParams." - MSG_FOR_URT_HR(VLDTR_E_EP_GENERIC_TYPE) "Entry point in CLR header is the token for a method in a generic type." - MSG_FOR_URT_HR(VLDTR_E_MI_DECLNOTGENERIC) "MethodImpl overrides non-generic method with generic method." - MSG_FOR_URT_HR(VLDTR_E_MI_IMPLNOTGENERIC) "MethodImpl overrides non-generic method with generic method." - MSG_FOR_URT_HR(VLDTR_E_MI_ARITYMISMATCH) "MethodImpl overrides generic method of arity n with generic method of arity m." - MSG_FOR_URT_HR(VLDTR_E_TD_EXTBADTYPESPEC) "TypeDef extends a TypeSpec that is not an instantiated type." - MSG_FOR_URT_HR(VLDTR_E_SIG_BYREFINST) "Signature has type instantiated at ByRef at offset i." - MSG_FOR_URT_HR(VLDTR_E_MS_BYREFINST) "Signature has type instantiated at ByRef at offset i." - MSG_FOR_URT_HR(VLDTR_E_TS_EMPTY) "TypeSpec has empty signature." - MSG_FOR_URT_HR(VLDTR_E_TS_HASSENTINALS) "TypeSpec has signature containing one or more sentinels." - MSG_FOR_URT_HR(VLDTR_E_TD_GENERICHASEXPLAYOUT) "TypeDef is generic but has explicit layout." - MSG_FOR_URT_HR(VLDTR_E_SIG_BADTOKTYPE) "Signature has token following ELEMENT_TYPE_CLASS (_VALUETYPE) that is not a TypeDef or TypeRef." - MSG_FOR_URT_HR(VLDTR_E_IFACE_METHNOTIMPLTHISMOD) "Warning: Class does not implement interface method in this module." - MSG_FOR_URT_HR(TLBX_E_CIRCULAR_EXPORT2) "TypeLib export: attempted to export an Assembly imported from a TLB." - MSG_FOR_URT_HR(CORDBG_E_THREAD_NOT_SCHEDULED) "Thread is not scheduled. Thus we may not have OSThreadId, handle, or context." - MSG_FOR_URT_HR(CORDBG_E_HANDLE_HAS_BEEN_DISPOSED) "Handle has been disposed." - MSG_FOR_URT_HR(CORDBG_E_NONINTERCEPTABLE_EXCEPTION) "Cannot intercept this exception." - MSG_FOR_URT_HR(CORDBG_E_CANT_UNWIND_ABOVE_CALLBACK) "When intercepting an exception, cannot intercept above the current frame." - MSG_FOR_URT_HR(CORDBG_E_INTERCEPT_FRAME_ALREADY_SET) "The intercept frame for this exception has already been set." - MSG_FOR_URT_HR(CORDBG_E_NO_NATIVE_PATCH_AT_ADDR) "There is no native patch at the given address." - MSG_FOR_URT_HR(CORDBG_E_MUST_BE_INTEROP_DEBUGGING) "This API is only allowed when interop debugging." - MSG_FOR_URT_HR(CORDBG_E_NATIVE_PATCH_ALREADY_AT_ADDR) "There is already a native patch at the address." - MSG_FOR_URT_HR(CORDBG_E_TIMEOUT) "A wait timed out, likely an indication of deadlock." - MSG_FOR_URT_HR(CORDBG_E_CANT_CALL_ON_THIS_THREAD) "Cannot use the API on this thread." - MSG_FOR_URT_HR(CORDBG_E_ENC_INFOLESS_METHOD) "Method was not JIT'd in EnC mode." - MSG_FOR_URT_HR(CORDBG_E_ENC_NESTED_HANLDERS) "Frame cannot be updated due to change in max nesting of handlers." - MSG_FOR_URT_HR(CORDBG_E_ENC_IN_FUNCLET) "Method is in a callable handler/filter. Cannot increase stack." - MSG_FOR_URT_HR(CORDBG_E_ENC_LOCALLOC) "Frame cannot be updated due to localloc." - MSG_FOR_URT_HR(CORDBG_E_ENC_EDIT_NOT_SUPPORTED) "Attempt to perform unsupported edit." - MSG_FOR_URT_HR(CORDBG_E_FEABORT_DELAYED_UNTIL_THREAD_RESUMED) "Attempt to func eval abort on a suspended thread." - MSG_FOR_URT_HR(CORDBG_E_NOTREADY) "The LS is not in a good spot to perform the requested operation." - MSG_FOR_URT_HR(CORDBG_E_CANNOT_RESOLVE_ASSEMBLY) "We failed to resolve assembly given an AssemblyRef token. Assembly may be not loaded yet or not a valid token." - MSG_FOR_URT_HR(CORDBG_E_MUST_BE_IN_LOAD_MODULE) "Must be in context of LoadModule callback to perform requested operation." - MSG_FOR_URT_HR(CORDBG_E_CANNOT_BE_ON_ATTACH) "Requested operation cannot be performed during an attach operation." - MSG_FOR_URT_HR(CORDBG_E_NGEN_NOT_SUPPORTED) "NGEN must be supported to perform the requested operation." - MSG_FOR_URT_HR(CORDBG_E_ILLEGAL_SHUTDOWN_ORDER) "Trying to shutdown out of order." - MSG_FOR_URT_HR(CORDBG_E_CANNOT_DEBUG_FIBER_PROCESS) "Debugging fiber mode managed process is not supported." - MSG_FOR_URT_HR(CORDBG_E_MUST_BE_IN_CREATE_PROCESS) "Must be in context of CreateProcess callback to perform requested operation." - MSG_FOR_URT_HR(CORDBG_E_DETACH_FAILED_OUTSTANDING_EVALS) "All outstanding func-evals have not completed, detaching is not allowed at this time." - MSG_FOR_URT_HR(CORDBG_E_DETACH_FAILED_OUTSTANDING_STEPPERS) "All outstanding steppers have not been closed, detaching is not allowed at this time." - MSG_FOR_URT_HR(CORDBG_E_CANT_INTEROP_STEP_OUT) "Cannot have an ICorDebugStepper do a native step-out." - MSG_FOR_URT_HR(CORDBG_E_DETACH_FAILED_OUTSTANDING_BREAKPOINTS) "All outstanding breakpoints have not been closed, detaching is not allowed at this time." - MSG_FOR_URT_HR(CORDBG_E_ILLEGAL_IN_STACK_OVERFLOW) "The operation is illegal because of a stack overflow." - MSG_FOR_URT_HR(CORDBG_E_ILLEGAL_AT_GC_UNSAFE_POINT) "The operation failed because it is a GC unsafe point." - MSG_FOR_URT_HR(CORDBG_E_ILLEGAL_IN_PROLOG) "The operation failed because the thread is in the prolog." - MSG_FOR_URT_HR(CORDBG_E_ILLEGAL_IN_NATIVE_CODE) "The operation failed because the thread is in native code." - MSG_FOR_URT_HR(CORDBG_E_ILLEGAL_IN_OPTIMIZED_CODE) "The operation failed because the thread is in optimized code." - MSG_FOR_URT_HR(CORDBG_E_MINIDUMP_UNSUPPORTED) "The information requested is not supported by minidumps." - MSG_FOR_URT_HR(CORDBG_E_APPDOMAIN_MISMATCH) "A supplied object or type belongs to the wrong AppDomain." - MSG_FOR_URT_HR(CORDBG_E_CONTEXT_UNVAILABLE) "The thread's context is not available." - MSG_FOR_URT_HR(CORDBG_E_UNCOMPATIBLE_PLATFORMS) "The operation failed because debuggee and debugger are on incompatible platforms." - MSG_FOR_URT_HR(CORDBG_E_DEBUGGING_DISABLED) "The operation failed because the debugging has been disabled" - MSG_FOR_URT_HR(CORDBG_E_DETACH_FAILED_ON_ENC) "Detach is illegal after an Edit and Continue on a module." - MSG_FOR_URT_HR(CORDBG_E_CURRENT_EXCEPTION_IS_OUTSIDE_CURRENT_EXECUTION_SCOPE) "Cannot intercept the current exception at the specified frame." - MSG_FOR_URT_HR(CORDBG_E_HELPER_MAY_DEADLOCK) "The debugger helper thread cannot obtain the locks it needs to perform this operation." - MSG_FOR_URT_HR(CORDBG_E_MISSING_METADATA) "The operation failed because the debugger could not get the metadata." - MSG_FOR_URT_HR(CORDBG_E_TARGET_INCONSISTENT) "The debuggee is in a corrupt state." - MSG_FOR_URT_HR(CORDBG_E_DETACH_FAILED_OUTSTANDING_TARGET_RESOURCES) "Detach failed because there are outstanding resources in the target." - MSG_FOR_URT_HR(CORDBG_E_TARGET_READONLY) "The debuggee is read-only." - MSG_FOR_URT_HR(CORDBG_E_MISMATCHED_CORWKS_AND_DACWKS_DLLS) "The version of clr.dll in the target does not match the one mscordacwks.dll was built for." - MSG_FOR_URT_HR(CORDBG_E_MODULE_LOADED_FROM_DISK) "Symbols are not supplied for modules loaded from disk." - MSG_FOR_URT_HR(CORDBG_E_SYMBOLS_NOT_AVAILABLE) "The application did not supply symbols when it loaded or created this module, or they are not yet available." - MSG_FOR_URT_HR(CORDBG_E_DEBUG_COMPONENT_MISSING) "A debug component is not installed." - MSG_FOR_URT_HR(CORDBG_E_REMOTE_MISMATCHED_CERTS) "Connection authentication failed due to mismatched certificates." - MSG_FOR_URT_HR(CORDBG_E_REMOTE_NETWORK_FAILURE) "Connection failed due to a miscellaneous network error." - MSG_FOR_URT_HR(CORDBG_E_REMOTE_NO_LISTENER) "Connection failed due to no endpoint at remote machine (no proxy configured?)." - MSG_FOR_URT_HR(CORDBG_E_REMOTE_UNKNOWN_TARGET) "Connection failed due to inability to locate remote machine." - MSG_FOR_URT_HR(CORDBG_E_REMOTE_INVALID_CONFIG) "Local debugger configuration was missing or invalid." - MSG_FOR_URT_HR(CORDBG_E_REMOTE_MISMATCHED_PROTOCOLS) "Connection failed due to protocol version mismatch between local and remote components." - MSG_FOR_URT_HR(CORDBG_E_LIBRARY_PROVIDER_ERROR) "The ICLRDebuggingLibraryProvider callback returned an error or did not provide a valid handle." - MSG_FOR_URT_HR(CORDBG_E_NOT_CLR) "The module at the base address indicated was not recognized as a CLR" - MSG_FOR_URT_HR(CORDBG_E_MISSING_DATA_TARGET_INTERFACE) "The provided data target does not implement the required interfaces for this version of the runtime" - MSG_FOR_URT_HR(CORDBG_E_UNSUPPORTED_DEBUGGING_MODEL) "This debugging model is unsupported by the specified runtime" - MSG_FOR_URT_HR(CORDBG_E_UNSUPPORTED_FORWARD_COMPAT) "The debugger is not designed to support the version of the CLR the debuggee is using." - MSG_FOR_URT_HR(CORDBG_E_UNSUPPORTED_VERSION_STRUCT) "The version struct has an unrecognized value for wStructVersion" - MSG_FOR_URT_HR(CORDBG_E_READVIRTUAL_FAILURE) "A call into a ReadVirtual implementation returned failure" - MSG_FOR_URT_HR(CORDBG_E_VALUE_POINTS_TO_FUNCTION) "The Debugging API doesn't support dereferencing function pointers." - MSG_FOR_URT_HR(CORDBG_E_CORRUPT_OBJECT) "The address provided does not point to a valid managed object." - MSG_FOR_URT_HR(CORDBG_E_GC_STRUCTURES_INVALID) "The GC heap structures are not in a valid state for traversal." - MSG_FOR_URT_HR(CORDBG_E_INVALID_OPCODE) "The specified IL offset or opcode is not supported for this operation." - MSG_FOR_URT_HR(CORDBG_E_UNSUPPORTED) "The specified action is unsupported by this version of the runtime." - MSG_FOR_URT_HR(CORDBG_E_MISSING_DEBUGGER_EXPORTS) "The debuggee memory space does not have the expected debugging export table." - MSG_FOR_URT_HR(CORDBG_E_DATA_TARGET_ERROR) "Failure when calling a data target method." - MSG_FOR_URT_HR(CORDBG_E_CODE_HAS_NO_METADATA) "Couldn't find metadata for the given executable code." - MSG_FOR_URT_HR(CORDBG_E_CODE_UNRECOGNIZED) "Given executable code is not managed." - MSG_FOR_URT_HR(CORDBG_E_NO_IMAGE_AVAILABLE) "Couldn't find a native image." - MSG_FOR_URT_HR(CORDBG_E_TYPE_NOT_FOUND) "The type doesn't exist in the given module." - MSG_FOR_URT_HR(CORDBG_E_VTABLE_HAS_NO_METADATA) "Couldn't find metadata for the given vtable." - MSG_FOR_URT_HR(CORDBG_E_NO_GENERIC_INFO) "Couldn't find any generics information." - MSG_FOR_URT_HR(PEFMT_E_NO_CONTENTS) "File is empty." - MSG_FOR_URT_HR(PEFMT_E_NO_NTHEADERS) "File has no NT headers." - MSG_FOR_URT_HR(PEFMT_E_64BIT) "File is PE32+." - MSG_FOR_URT_HR(PEFMT_E_NO_CORHEADER) "File has no COR header." - MSG_FOR_URT_HR(PEFMT_E_NOT_ILONLY) "Flag IL_ONLY not set." - MSG_FOR_URT_HR(PEFMT_E_IMPORT_DLLS) "Bad import DLLs." - MSG_FOR_URT_HR(PEFMT_E_EXE_NOENTRYPOINT) "EXE file has no mgd entry point." - MSG_FOR_URT_HR(PEFMT_E_BASE_RELOCS) "Bad base relocations." - MSG_FOR_URT_HR(PEFMT_E_ENTRYPOINT) "Bad managed entry point." - MSG_FOR_URT_HR(PEFMT_E_ZERO_SIZEOFCODE) "OptHeader.SizeOfCode is set to zero." - MSG_FOR_URT_HR(PEFMT_E_BAD_CORHEADER) "File has invalid COR header." - MSG_FOR_URT_HR(PEFMT_E_32BIT) "File is PE32" - MSG_FOR_URT_HR(CLR_OPTSVC_E_CONTROLLER_INTERRUPT) "The operation was interrupted by the CLR Optimization Service controller." - MSG_FOR_URT_HR(NGEN_FAILED_GET_DEPENDENCIES) "Failed to get dependencies for assembly." - MSG_FOR_URT_HR(NGEN_FAILED_NATIVE_IMAGE_DELETE) "Failed to delete native image." - MSG_FOR_URT_HR(NGEN_E_TOO_MANY_INTERFACES) "Module contains too many interfaces to successfully compile all methods." - MSG_FOR_URT_HR(NGEN_E_OLDER_RUNTIME) "Requested runtime does not support side-by-side NGen." - MSG_FOR_URT_HR(NGEN_E_WORKER_UNEXPECTED_EXIT) "Worker exited unexpectedly during startup" - MSG_FOR_URT_HR(NGEN_E_WORKER_UNEXPECTED_SYNC) "Failed to synchronize with worker during startup" - MSG_FOR_URT_HR(NGEN_E_SYS_ASM_NI_MISSING) "NGen cannot proceed because Mscorlib.dll does not have a native image" - MSG_FOR_URT_HR(NGEN_E_EXE_MACHINE_TYPE_MISMATCH) "The image file is not compatible with the version of Ngen you're running. Use 32bit Ngen for 32bit assemblies, and 64bit Ngen for 64bit assemblies." - MSG_FOR_URT_HR(NGEN_E_ASSEMBLY_EXCLUSION_FILE_PARSE_ERROR) "There was an error parsing the NGen assembly exclusion Xml file." - MSG_FOR_URT_HR(NGEN_E_HARDBOUND_DEPENDENCY_MISSING) "A hardbound dependent native image is missing." - MSG_FOR_URT_HR(NGEN_E_NOT_RUNNING_IN_EXPECTED_PACKAGE) "NGen is not running in expected package." - MSG_FOR_URT_HR(NGEN_E_FILE_NOT_ASSEMBLY) "The image being compiled is not a .NET assembly" - MSG_FOR_URT_HR(CLR_E_BIND_ASSEMBLY_VERSION_TOO_LOW) "The bound assembly has a version that is lower than that of the request." - MSG_FOR_URT_HR(CLR_E_BIND_ASSEMBLY_PUBLIC_KEY_MISMATCH) "The assembly version has a public key token that does not match that of the request." - MSG_FOR_URT_HR(CLR_E_BIND_IMAGE_UNAVAILABLE) "The requested image was not found or is unavailable." - MSG_FOR_URT_HR(CLR_E_BIND_UNRECOGNIZED_IDENTITY_FORMAT) "The provided identity format is not recognized." - MSG_FOR_URT_HR(CLR_E_BIND_ASSEMBLY_NOT_FOUND) "A binding for the specified assembly name was not found." - MSG_FOR_URT_HR(CLR_E_BIND_TYPE_NOT_FOUND) "A binding for the specified type name was not found." - MSG_FOR_URT_HR(CLR_E_BIND_SYS_ASM_NI_MISSING) "Could not use native image because Mscorlib.dll is missing a native image" - MSG_FOR_URT_HR(CLR_E_BIND_NI_SECURITY_FAILURE) "Native image was generated in a different trust level than present at runtime" - MSG_FOR_URT_HR(CLR_E_BIND_NI_DEP_IDENTITY_MISMATCH) "Native image identity mismatch with respect to its dependencies" - MSG_FOR_URT_HR(CLR_E_GC_OOM) "Failfast due to an OOM during a GC" - MSG_FOR_URT_HR(COR_E_BADIMAGEFORMAT) "The format of a DLL or executable being loaded is invalid." -END diff --git a/src/pal/prebuilt/corerror/readme.txt b/src/pal/prebuilt/corerror/readme.txt deleted file mode 100644 index a21a72490..000000000 --- a/src/pal/prebuilt/corerror/readme.txt +++ /dev/null @@ -1,7 +0,0 @@ -Steps to generate corerror.h for the Unix: - -Open Razzle window -tf edit ..\inc\corerror.h -tf edit mscorurt.rc -makecorerror.bat -tf undo any files that didn't get modified \ No newline at end of file diff --git a/src/pal/src/CMakeLists.txt b/src/pal/src/CMakeLists.txt index dbff63dc0..a866bf8dc 100644 --- a/src/pal/src/CMakeLists.txt +++ b/src/pal/src/CMakeLists.txt @@ -1,27 +1,13 @@ cmake_minimum_required(VERSION 2.8.12.2) -if(CMAKE_SYSTEM_NAME STREQUAL Darwin) - # On OSX, we use the libunwind that's part of the OS - set(CLR_CMAKE_USE_SYSTEM_LIBUNWIND 1) -endif(CMAKE_SYSTEM_NAME STREQUAL Darwin) +project(coreclrpal) include_directories(SYSTEM /usr/local/include) add_compile_options(-fPIC) -if(NOT CLR_CMAKE_USE_SYSTEM_LIBUNWIND) - include_directories(libunwind/include) - include_directories(libunwind/include/tdep) - include_directories(${CMAKE_CURRENT_BINARY_DIR}/libunwind/include) - include_directories(${CMAKE_CURRENT_BINARY_DIR}/libunwind/include/tdep) - - add_subdirectory(libunwind) -endif(NOT CLR_CMAKE_USE_SYSTEM_LIBUNWIND) - include(configure.cmake) -project(coreclrpal) - set(CMAKE_INCLUDE_CURRENT_DIR ON) if(CORECLR_SET_RPATH) @@ -79,11 +65,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL Darwin) add_definitions(-D_TARGET_MAC64) add_definitions(-DXSTATE_SUPPORTED) set(PLATFORM_SOURCES - arch/amd64/activationhandlerwrapper.S arch/amd64/context.S - arch/amd64/dispatchexceptionwrapper.S - exception/machexception.cpp - exception/machmessage.cpp ) endif(CMAKE_SYSTEM_NAME STREQUAL Darwin) @@ -126,23 +108,10 @@ endif(CLR_CMAKE_PLATFORM_ALPINE_LINUX) set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} -Wl,--no-gc-sections") set(ARCH_SOURCES - arch/${PAL_ARCH_SOURCES_DIR}/context2.S arch/${PAL_ARCH_SOURCES_DIR}/debugbreak.S - arch/${PAL_ARCH_SOURCES_DIR}/exceptionhelper.S arch/${PAL_ARCH_SOURCES_DIR}/processor.cpp ) -if(NOT CMAKE_SYSTEM_NAME STREQUAL Darwin) - list(APPEND PLATFORM_SOURCES - arch/${PAL_ARCH_SOURCES_DIR}/callsignalhandlerwrapper.S - arch/${PAL_ARCH_SOURCES_DIR}/signalhandlerhelper.cpp - ) -endif(NOT CMAKE_SYSTEM_NAME STREQUAL Darwin) - -if(PAL_CMAKE_PLATFORM_ARCH_ARM) - set_source_files_properties(exception/seh.cpp PROPERTIES COMPILE_FLAGS -Wno-error=inline-asm) -endif(PAL_CMAKE_PLATFORM_ARCH_ARM) - set(SOURCES cruntime/file.cpp cruntime/filecrt.cpp @@ -162,9 +131,6 @@ set(SOURCES cruntime/wchar.cpp cruntime/wchartls.cpp debug/debug.cpp - exception/seh.cpp - exception/signal.cpp - exception/remote-unwind.cpp file/directory.cpp file/file.cpp file/filetime.cpp @@ -173,7 +139,6 @@ set(SOURCES handlemgr/handleapi.cpp handlemgr/handlemgr.cpp init/pal.cpp - init/sxs.cpp loader/module.cpp loader/modulename.cpp locale/unicode.cpp @@ -190,15 +155,12 @@ set(SOURCES misc/error.cpp misc/errorstrings.cpp misc/fmtmessage.cpp - misc/jitsupport.cpp misc/miscpalapi.cpp misc/msgbox.cpp misc/strutil.cpp misc/sysinfo.cpp misc/time.cpp - misc/tracepointprovider.cpp misc/utils.cpp - numa/numa.cpp objmgr/palobjbase.cpp objmgr/shmobject.cpp objmgr/shmobjectmanager.cpp @@ -233,32 +195,16 @@ set(SOURCES safecrt/wsplitpath_s.cpp safecrt/xtoa_s.cpp safecrt/xtow_s.cpp - sharedmemory/sharedmemory.cpp shmemory/shmemory.cpp sync/cs.cpp - synchobj/event.cpp - synchobj/semaphore.cpp - synchobj/mutex.cpp - synchmgr/synchcontrollers.cpp - synchmgr/synchmanager.cpp - synchmgr/wait.cpp - thread/context.cpp - thread/process.cpp thread/thread.cpp - thread/threadsusp.cpp - thread/tls.cpp ) -if(NOT CLR_CMAKE_USE_SYSTEM_LIBUNWIND) - set(LIBUNWIND_OBJECTS $) -endif(NOT CLR_CMAKE_USE_SYSTEM_LIBUNWIND) - add_library(coreclrpal STATIC ${SOURCES} ${ARCH_SOURCES} ${PLATFORM_SOURCES} - ${LIBUNWIND_OBJECTS} ) if(CMAKE_SYSTEM_NAME STREQUAL Darwin) @@ -275,14 +221,10 @@ if(CMAKE_SYSTEM_NAME STREQUAL Darwin) endif(CMAKE_SYSTEM_NAME STREQUAL Darwin) if(CMAKE_SYSTEM_NAME STREQUAL FreeBSD) - if(CLR_CMAKE_USE_SYSTEM_LIBUNWIND) - find_library(UNWIND unwind) - endif() find_library(INTL intl) target_link_libraries(coreclrpal pthread rt - ${UNWIND} ${INTL} ) endif(CMAKE_SYSTEM_NAME STREQUAL FreeBSD) @@ -341,62 +283,16 @@ if(CMAKE_SYSTEM_NAME STREQUAL Linux) target_link_libraries(coreclrpal ${INTL}) endif(NOT INTL STREQUAL INTL-NOTFOUND) - if(CLR_CMAKE_USE_SYSTEM_LIBUNWIND) - if(PAL_CMAKE_PLATFORM_ARCH_ARM) - find_library(UNWIND_ARCH NAMES unwind-arm) - endif() - - if(PAL_CMAKE_PLATFORM_ARCH_ARM64) - find_library(UNWIND_ARCH NAMES unwind-aarch64) - endif() - - if(PAL_CMAKE_PLATFORM_ARCH_AMD64) - find_library(UNWIND_ARCH NAMES unwind-x86_64) - endif() - - if(NOT UNWIND_ARCH STREQUAL UNWIND_ARCH-NOTFOUND) - target_link_libraries(coreclrpal ${UNWIND_ARCH}) - endif() - - find_library(UNWIND_GENERIC NAMES unwind-generic) - - if(NOT UNWIND_GENERIC STREQUAL UNWIND_GENERIC-NOTFOUND) - target_link_libraries(coreclrpal ${UNWIND_GENERIC}) - endif() - - find_library(UNWIND NAMES unwind) - - if(UNWIND STREQUAL UNWIND-NOTFOUND) - message(FATAL_ERROR "Cannot find libunwind. Try installing libunwind8-dev or libunwind-devel.") - endif() - - target_link_libraries(coreclrpal ${UNWIND}) - - endif(CLR_CMAKE_USE_SYSTEM_LIBUNWIND) - endif(CMAKE_SYSTEM_NAME STREQUAL Linux) if(CMAKE_SYSTEM_NAME STREQUAL NetBSD) - if (CLR_CMAKE_USE_SYSTEM_LIBUNWIND) - find_library(UNWIND unwind) - endif() add_definitions(-D_KMEMUSER) find_library(INTL intl) find_library(KVM kvm) target_link_libraries(coreclrpal pthread rt - ${UNWIND} ${INTL} ${KVM} ) endif(CMAKE_SYSTEM_NAME STREQUAL NetBSD) - -add_subdirectory(examples) - -if(FEATURE_EVENT_TRACE) - add_subdirectory(${GENERATED_EVENTING_DIR}/eventprovider ${CMAKE_CURRENT_BINARY_DIR}/eventprovider) -endif(FEATURE_EVENT_TRACE) - -# Install the static PAL library for VS -install (TARGETS coreclrpal DESTINATION lib) diff --git a/src/pal/src/arch/amd64/activationhandlerwrapper.S b/src/pal/src/arch/amd64/activationhandlerwrapper.S deleted file mode 100644 index 63f718e81..000000000 --- a/src/pal/src/arch/amd64/activationhandlerwrapper.S +++ /dev/null @@ -1,30 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -.intel_syntax noprefix -#include "unixasmmacros.inc" -#include "asmconstants.h" - -#ifdef BIT64 -// Offset of the return address from the ActivationHandler in the ActivationHandlerWrapper -.globl C_FUNC(ActivationHandlerReturnOffset) -C_FUNC(ActivationHandlerReturnOffset): - .int LOCAL_LABEL(ActivationHandlerReturn)-C_FUNC(ActivationHandlerWrapper) - -NESTED_ENTRY ActivationHandlerWrapper, _TEXT, NoHandler - push_nonvol_reg rbp - mov rbp, rsp - alloc_stack (CONTEXT_Size) - set_cfa_register rbp, (2*8) - mov rdi, rsp - int3 - call C_FUNC(ActivationHandler) -LOCAL_LABEL(ActivationHandlerReturn): - int3 - free_stack (CONTEXT_Size) - pop_nonvol_reg rbp - ret -NESTED_END ActivationHandlerWrapper, _TEXT - -#endif // BIT64 diff --git a/src/pal/src/arch/amd64/callsignalhandlerwrapper.S b/src/pal/src/arch/amd64/callsignalhandlerwrapper.S deleted file mode 100644 index 8260591c3..000000000 --- a/src/pal/src/arch/amd64/callsignalhandlerwrapper.S +++ /dev/null @@ -1,31 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -.intel_syntax noprefix -#include "unixasmmacros.inc" -#include "asmconstants.h" - -.macro CALL_SIGNAL_HANDLER_WRAPPER Alignment - -.globl C_FUNC(SignalHandlerWorkerReturnOffset\Alignment) -C_FUNC(SignalHandlerWorkerReturnOffset\Alignment): - .int LOCAL_LABEL(SignalHandlerWorkerReturn\Alignment)-C_FUNC(CallSignalHandlerWrapper\Alignment) - -// This function is never called, only a fake stack frame will be setup to have a return -// address set to SignalHandlerWorkerReturn during SIGSEGV handling. -// It enables the unwinder to unwind stack from the handling code to the actual failure site. -NESTED_ENTRY CallSignalHandlerWrapper\Alignment, _TEXT, NoHandler - .cfi_def_cfa_offset (128 + 8 + \Alignment) // red zone + return address + alignment - .cfi_offset rip, -(128 + 8 + \Alignment) - push_nonvol_reg rbp - call EXTERNAL_C_FUNC(signal_handler_worker) -LOCAL_LABEL(SignalHandlerWorkerReturn\Alignment): - pop rbp - ret -NESTED_END CallSignalHandlerWrapper\Alignment, _TEXT - -.endm - -CALL_SIGNAL_HANDLER_WRAPPER 0 -CALL_SIGNAL_HANDLER_WRAPPER 8 diff --git a/src/pal/src/arch/amd64/context2.S b/src/pal/src/arch/amd64/context2.S deleted file mode 100644 index 46c941f2a..000000000 --- a/src/pal/src/arch/amd64/context2.S +++ /dev/null @@ -1,270 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -// -// Implementation of _CONTEXT_CaptureContext for the Intel x86 platform. -// This function is processor dependent. It is used by exception handling, -// and is always apply to the current thread. -// - -.intel_syntax noprefix -#include "unixasmmacros.inc" -#include "asmconstants.h" - -#ifdef BIT64 - -#define IRETFRAME_Rip 0 -#define IRETFRAME_SegCs IRETFRAME_Rip+8 -#define IRETFRAME_EFlags IRETFRAME_SegCs+8 -#define IRETFRAME_Rsp IRETFRAME_EFlags+8 -#define IRETFRAME_SegSs IRETFRAME_Rsp+8 -#define IRetFrameLength IRETFRAME_SegSs+8 -#define IRetFrameLengthAligned 16*((IRetFrameLength+8)/16) - -// Incoming: -// RDI: Context* -// -LEAF_ENTRY CONTEXT_CaptureContext, _TEXT - // Save processor flags before calling any of the following 'test' instructions - // because they will modify state of some flags - push_eflags - END_PROLOGUE - - test BYTE PTR [rdi + CONTEXT_ContextFlags], CONTEXT_INTEGER - je LOCAL_LABEL(Done_CONTEXT_INTEGER) - mov [rdi + CONTEXT_Rdi], rdi - mov [rdi + CONTEXT_Rsi], rsi - mov [rdi + CONTEXT_Rbx], rbx - mov [rdi + CONTEXT_Rdx], rdx - mov [rdi + CONTEXT_Rcx], rcx - mov [rdi + CONTEXT_Rax], rax - mov [rdi + CONTEXT_Rbp], rbp - mov [rdi + CONTEXT_R8], r8 - mov [rdi + CONTEXT_R9], r9 - mov [rdi + CONTEXT_R10], r10 - mov [rdi + CONTEXT_R11], r11 - mov [rdi + CONTEXT_R12], r12 - mov [rdi + CONTEXT_R13], r13 - mov [rdi + CONTEXT_R14], r14 - mov [rdi + CONTEXT_R15], r15 -LOCAL_LABEL(Done_CONTEXT_INTEGER): - - test BYTE PTR [rdi + CONTEXT_ContextFlags], CONTEXT_CONTROL - je LOCAL_LABEL(Done_CONTEXT_CONTROL) - - // Return address is @ (RSP + 8) - mov rdx, [rsp + 8] - mov [rdi + CONTEXT_Rip], rdx -.att_syntax - mov %cs, CONTEXT_SegCs(%rdi) -.intel_syntax noprefix - // Get the value of EFlags that was pushed on stack at the beginning of the function - mov rdx, [rsp] - mov [rdi + CONTEXT_EFlags], edx - lea rdx, [rsp + 16] - mov [rdi + CONTEXT_Rsp], rdx -.att_syntax - mov %ss, CONTEXT_SegSs(%rdi) -.intel_syntax noprefix -LOCAL_LABEL(Done_CONTEXT_CONTROL): - - // Need to double check this is producing the right result - // also that FFSXR (fast save/restore) is not turned on - // otherwise it omits the xmm registers. - test BYTE PTR [rdi + CONTEXT_ContextFlags], CONTEXT_FLOATING_POINT - je LOCAL_LABEL(Done_CONTEXT_FLOATING_POINT) - fxsave [rdi + CONTEXT_FltSave] -LOCAL_LABEL(Done_CONTEXT_FLOATING_POINT): - - test BYTE PTR [rdi + CONTEXT_ContextFlags], CONTEXT_DEBUG_REGISTERS - je LOCAL_LABEL(Done_CONTEXT_DEBUG_REGISTERS) - mov rdx, dr0 - mov [rdi + CONTEXT_Dr0], rdx - mov rdx, dr1 - mov [rdi + CONTEXT_Dr1], rdx - mov rdx, dr2 - mov [rdi + CONTEXT_Dr2], rdx - mov rdx, dr3 - mov [rdi + CONTEXT_Dr3], rdx - mov rdx, dr6 - mov [rdi + CONTEXT_Dr6], rdx - mov rdx, dr7 - mov [rdi + CONTEXT_Dr7], rdx -LOCAL_LABEL(Done_CONTEXT_DEBUG_REGISTERS): - - free_stack 8 - ret -LEAF_END CONTEXT_CaptureContext, _TEXT - -LEAF_ENTRY RtlCaptureContext, _TEXT - mov DWORD PTR [rdi + CONTEXT_ContextFlags], (CONTEXT_AMD64 | CONTEXT_FULL | CONTEXT_SEGMENTS) - jmp C_FUNC(CONTEXT_CaptureContext) -LEAF_END RtlCaptureContext, _TEXT - -LEAF_ENTRY RtlRestoreContext, _TEXT - push_nonvol_reg rbp - alloc_stack (IRetFrameLengthAligned) - -#ifdef HAS_ASAN - test BYTE PTR [rdi + CONTEXT_ContextFlags], CONTEXT_CONTROL - je LOCAL_LABEL(Restore_CONTEXT_DEBUG_REGISTERS) - - push_nonvol_reg rdi - push_nonvol_reg rsi - call EXTERNAL_C_FUNC(__asan_handle_no_return) - pop_nonvol_reg rsi - pop_nonvol_reg rdi -LOCAL_LABEL(Restore_CONTEXT_DEBUG_REGISTERS): -#endif - test BYTE PTR [rdi + CONTEXT_ContextFlags], CONTEXT_DEBUG_REGISTERS - je LOCAL_LABEL(Done_Restore_CONTEXT_DEBUG_REGISTERS) - mov rdx, [rdi + CONTEXT_Dr0] - mov dr0, rdx - mov rdx, [rdi + CONTEXT_Dr1] - mov dr1, rdx - mov rdx, [rdi + CONTEXT_Dr2] - mov dr2, rdx - mov rdx, [rdi + CONTEXT_Dr3] - mov dr3, rdx - mov rdx, [rdi + CONTEXT_Dr6] - mov dr6, rdx - mov rdx, [rdi + CONTEXT_Dr7] - mov dr7, rdx -LOCAL_LABEL(Done_Restore_CONTEXT_DEBUG_REGISTERS): - - test BYTE PTR [rdi + CONTEXT_ContextFlags], CONTEXT_FLOATING_POINT - je LOCAL_LABEL(Done_Restore_CONTEXT_FLOATING_POINT) - fxrstor [rdi + CONTEXT_FltSave] -LOCAL_LABEL(Done_Restore_CONTEXT_FLOATING_POINT): - - test BYTE PTR [rdi + CONTEXT_ContextFlags], CONTEXT_XSTATE - je LOCAL_LABEL(Done_Restore_CONTEXT_XSTATE) - - // Restore the extended state (for now, this is just the upper halves of YMM registers) - vinsertf128 ymm0, ymm0, xmmword ptr [rdi + (CONTEXT_VectorRegister + 0 * 16)], 1 - vinsertf128 ymm1, ymm1, xmmword ptr [rdi + (CONTEXT_VectorRegister + 1 * 16)], 1 - vinsertf128 ymm2, ymm2, xmmword ptr [rdi + (CONTEXT_VectorRegister + 2 * 16)], 1 - vinsertf128 ymm3, ymm3, xmmword ptr [rdi + (CONTEXT_VectorRegister + 3 * 16)], 1 - vinsertf128 ymm4, ymm4, xmmword ptr [rdi + (CONTEXT_VectorRegister + 4 * 16)], 1 - vinsertf128 ymm5, ymm5, xmmword ptr [rdi + (CONTEXT_VectorRegister + 5 * 16)], 1 - vinsertf128 ymm6, ymm6, xmmword ptr [rdi + (CONTEXT_VectorRegister + 6 * 16)], 1 - vinsertf128 ymm7, ymm7, xmmword ptr [rdi + (CONTEXT_VectorRegister + 7 * 16)], 1 - vinsertf128 ymm8, ymm8, xmmword ptr [rdi + (CONTEXT_VectorRegister + 8 * 16)], 1 - vinsertf128 ymm9, ymm9, xmmword ptr [rdi + (CONTEXT_VectorRegister + 9 * 16)], 1 - vinsertf128 ymm10, ymm10, xmmword ptr [rdi + (CONTEXT_VectorRegister + 10 * 16)], 1 - vinsertf128 ymm11, ymm11, xmmword ptr [rdi + (CONTEXT_VectorRegister + 11 * 16)], 1 - vinsertf128 ymm12, ymm12, xmmword ptr [rdi + (CONTEXT_VectorRegister + 12 * 16)], 1 - vinsertf128 ymm13, ymm13, xmmword ptr [rdi + (CONTEXT_VectorRegister + 13 * 16)], 1 - vinsertf128 ymm14, ymm14, xmmword ptr [rdi + (CONTEXT_VectorRegister + 14 * 16)], 1 - vinsertf128 ymm15, ymm15, xmmword ptr [rdi + (CONTEXT_VectorRegister + 15 * 16)], 1 -LOCAL_LABEL(Done_Restore_CONTEXT_XSTATE): - - test BYTE PTR [rdi + CONTEXT_ContextFlags], CONTEXT_CONTROL - je LOCAL_LABEL(Done_Restore_CONTEXT_CONTROL) - - // The control registers are restored via the iret instruction - // so we build the frame for the iret on the stack. -#ifdef __APPLE__ -.att_syntax - // On OSX, we cannot read SS via the thread_get_context and RtlRestoreContext - // needs to be used on context extracted by thread_get_context. So we - // don't change the SS. - mov %ss, %ax -.intel_syntax noprefix -#else - mov ax, [rdi + CONTEXT_SegSs] -#endif - mov [rsp + IRETFRAME_SegSs], ax - mov rax, [rdi + CONTEXT_Rsp] - mov [rsp + IRETFRAME_Rsp], rax - mov eax, [rdi + CONTEXT_EFlags] - mov [rsp + IRETFRAME_EFlags], eax - mov ax, [rdi + CONTEXT_SegCs] - mov [rsp + IRETFRAME_SegCs], ax - mov rax, [rdi + CONTEXT_Rip] - mov [rsp + IRETFRAME_Rip], rax - -LOCAL_LABEL(Done_Restore_CONTEXT_CONTROL): - // Remember the result of the test for the CONTEXT_CONTROL - push_eflags - test BYTE PTR [rdi + CONTEXT_ContextFlags], CONTEXT_INTEGER - je LOCAL_LABEL(Done_Restore_CONTEXT_INTEGER) - mov rsi, [rdi + CONTEXT_Rsi] - mov rbx, [rdi + CONTEXT_Rbx] - mov rdx, [rdi + CONTEXT_Rdx] - mov rcx, [rdi + CONTEXT_Rcx] - mov rax, [rdi + CONTEXT_Rax] - mov rbp, [rdi + CONTEXT_Rbp] - mov r8, [rdi + CONTEXT_R8] - mov r9, [rdi + CONTEXT_R9] - mov r10, [rdi + CONTEXT_R10] - mov r11, [rdi + CONTEXT_R11] - mov r12, [rdi + CONTEXT_R12] - mov r13, [rdi + CONTEXT_R13] - mov r14, [rdi + CONTEXT_R14] - mov r15, [rdi + CONTEXT_R15] - mov rdi, [rdi + CONTEXT_Rdi] -LOCAL_LABEL(Done_Restore_CONTEXT_INTEGER): - - // Restore the result of the test for the CONTEXT_CONTROL - pop_eflags - je LOCAL_LABEL(No_Restore_CONTEXT_CONTROL) - // The function was asked to restore the control registers, so - // we perform iretq that restores them all. - // We don't return to the caller in this case. - iretq -LOCAL_LABEL(No_Restore_CONTEXT_CONTROL): - - // The function was not asked to restore the control registers - // so we return back to the caller. - free_stack (IRetFrameLengthAligned) - pop_nonvol_reg rbp - ret -LEAF_END RtlRestoreContext, _TEXT - -#else - - .globl C_FUNC(CONTEXT_CaptureContext) -C_FUNC(CONTEXT_CaptureContext): - push %eax - mov 8(%esp), %eax - mov %edi, CONTEXT_Edi(%eax) - mov %esi, CONTEXT_Esi(%eax) - mov %ebx, CONTEXT_Ebx(%eax) - mov %edx, CONTEXT_Edx(%eax) - mov %ecx, CONTEXT_Ecx(%eax) - pop %ecx - mov %ecx, CONTEXT_Eax(%eax) - mov %ebp, CONTEXT_Ebp(%eax) - mov (%esp), %edx - mov %edx, CONTEXT_Eip(%eax) - push %cs - pop %edx - mov %edx, CONTEXT_SegCs(%eax) - pushf - pop %edx - mov %edx, CONTEXT_EFlags(%eax) - lea 4(%esp), %edx - mov %edx, CONTEXT_Esp(%eax) - push %ss - pop %edx - mov %edx, CONTEXT_SegSs(%eax) - testb $CONTEXT_FLOATING_POINT, CONTEXT_ContextFlags(%eax) - je 0f - fnsave CONTEXT_FloatSave(%eax) - frstor CONTEXT_FloatSave(%eax) -0: - testb $CONTEXT_EXTENDED_REGISTERS, CONTEXT_ContextFlags(%eax) - je 2f - movdqu %xmm0, CONTEXT_Xmm0(%eax) - movdqu %xmm1, CONTEXT_Xmm1(%eax) - movdqu %xmm2, CONTEXT_Xmm2(%eax) - movdqu %xmm3, CONTEXT_Xmm3(%eax) - movdqu %xmm4, CONTEXT_Xmm4(%eax) - movdqu %xmm5, CONTEXT_Xmm5(%eax) - movdqu %xmm6, CONTEXT_Xmm6(%eax) - movdqu %xmm7, CONTEXT_Xmm7(%eax) -2: - ret - -#endif diff --git a/src/pal/src/arch/amd64/dispatchexceptionwrapper.S b/src/pal/src/arch/amd64/dispatchexceptionwrapper.S deleted file mode 100644 index ee5ff468d..000000000 --- a/src/pal/src/arch/amd64/dispatchexceptionwrapper.S +++ /dev/null @@ -1,51 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -// ==++== -// - -// ==--== -// -// Implementation of the PAL_DispatchExceptionWrapper that is -// interposed between a function that caused a hardware fault -// and PAL_DispatchException that throws an SEH exception for -// the fault, to make the stack unwindable. -// - -.intel_syntax noprefix -#include "unixasmmacros.inc" - -// Offset of the return address from the PAL_DispatchException in the PAL_DispatchExceptionWrapper -.globl C_FUNC(PAL_DispatchExceptionReturnOffset) -C_FUNC(PAL_DispatchExceptionReturnOffset): - .int LOCAL_LABEL(PAL_DispatchExceptionReturn) - C_FUNC(PAL_DispatchExceptionWrapper) - -// -// PAL_DispatchExceptionWrapper will never be called; it only serves -// to be referenced from a stack frame on the faulting thread. Its -// unwinding behavior is equivalent to any standard function having -// an ebp frame. It is analogous to the following source file. -// -// extern "C" void PAL_DispatchException(CONTEXT *pContext, EXCEPTION_RECORD *pExceptionRecord, MachExceptionInfo *pMachExceptionInfo); -// -// extern "C" void PAL_DispatchExceptionWrapper() -// { -// CONTEXT Context; -// EXCEPTION_RECORD ExceptionRecord; -// MachExceptionInfo MachExceptionInfo; -// PAL_DispatchException(&Context, &ExceptionRecord, &MachExceptionInfo); -// } -// - -NESTED_ENTRY PAL_DispatchExceptionWrapper, _TEXT, NoHandler - push_nonvol_reg rbp - mov rbp, rsp - set_cfa_register rbp, (2*8) - int3 - call C_FUNC(PAL_DispatchException) -LOCAL_LABEL(PAL_DispatchExceptionReturn): - int3 - pop_nonvol_reg rbp - ret -NESTED_END PAL_DispatchExceptionWrapper, _TEXT diff --git a/src/pal/src/arch/amd64/exceptionhelper.S b/src/pal/src/arch/amd64/exceptionhelper.S deleted file mode 100644 index cb9a545d2..000000000 --- a/src/pal/src/arch/amd64/exceptionhelper.S +++ /dev/null @@ -1,52 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -.intel_syntax noprefix -#include "unixasmmacros.inc" -#include "asmconstants.h" - -////////////////////////////////////////////////////////////////////////// -// -// This function creates a stack frame right below the target frame, restores all callee -// saved registers from the passed in context, sets the RSP to that frame and sets the -// return address to the target frame's RIP. -// Then it uses the ThrowExceptionHelper to throw the passed in exception from that context. -// EXTERN_C void ThrowExceptionFromContextInternal(CONTEXT* context, PAL_SEHException* ex); -LEAF_ENTRY ThrowExceptionFromContextInternal, _TEXT -#ifdef HAS_ASAN - // Need to call __asan_handle_no_return explicitly here because we re-intialize RSP before - // throwing exception in ThrowExceptionHelper - push_nonvol_reg rdi - push_nonvol_reg rsi - call EXTERNAL_C_FUNC(__asan_handle_no_return) - pop_nonvol_reg rsi - pop_nonvol_reg rdi -#endif - - // Save the RBP to the stack so that the unwind can work at the instruction after - // loading the RBP from the context, but before loading the RSP from the context. - push_nonvol_reg rbp - mov r12, [rdi + CONTEXT_R12] - mov r13, [rdi + CONTEXT_R13] - mov r14, [rdi + CONTEXT_R14] - mov r15, [rdi + CONTEXT_R15] - mov rbx, [rdi + CONTEXT_Rbx] - mov rbp, [rdi + CONTEXT_Rbp] - mov rsp, [rdi + CONTEXT_Rsp] - // The RSP was set to the target frame's value, so the current function's - // CFA is now right at the RSP. - .cfi_def_cfa_offset 0 - - // Indicate that now that we have moved the RSP to the target address, - // the RBP is no longer saved in the current stack frame. - .cfi_restore rbp - - mov rax, [rdi + CONTEXT_Rip] - - // Store return address to the stack - push_register rax - // The PAL_SEHException pointer - mov rdi, rsi - jmp EXTERNAL_C_FUNC(ThrowExceptionHelper) -LEAF_END ThrowExceptionFromContextInternal, _TEXT diff --git a/src/pal/src/arch/amd64/signalhandlerhelper.cpp b/src/pal/src/arch/amd64/signalhandlerhelper.cpp deleted file mode 100644 index 8789f5a62..000000000 --- a/src/pal/src/arch/amd64/signalhandlerhelper.cpp +++ /dev/null @@ -1,70 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#include "pal/dbgmsg.h" -SET_DEFAULT_DEBUG_CHANNEL(EXCEPT); // some headers have code with asserts, so do this first - -#include "pal/palinternal.h" -#include "pal/context.h" -#include "pal/signal.hpp" -#include "pal/utils.h" -#include - -/*++ -Function : - signal_handler_worker - - Handles signal on the original stack where the signal occured. - Invoked via setcontext. - -Parameters : - POSIX signal handler parameter list ("man sigaction" for details) - returnPoint - context to which the function returns if the common_signal_handler returns - - (no return value) ---*/ -void ExecuteHandlerOnOriginalStack(int code, siginfo_t *siginfo, void *context, SignalHandlerWorkerReturnPoint* returnPoint) -{ - ucontext_t *ucontext = (ucontext_t *)context; - size_t faultSp = (size_t)MCREG_Rsp(ucontext->uc_mcontext); - - _ASSERTE(IS_ALIGNED(faultSp, 8)); - - size_t fakeFrameReturnAddress; - - if (IS_ALIGNED(faultSp, 16)) - { - fakeFrameReturnAddress = (size_t)SignalHandlerWorkerReturnOffset0 + (size_t)CallSignalHandlerWrapper0; - } - else - { - fakeFrameReturnAddress = (size_t)SignalHandlerWorkerReturnOffset8 + (size_t)CallSignalHandlerWrapper8; - } - - // preserve 128 bytes long red zone and align stack pointer - size_t* sp = (size_t*)ALIGN_DOWN(faultSp - 128, 16); - - // Build fake stack frame to enable the stack unwinder to unwind from signal_handler_worker to the faulting instruction - *--sp = (size_t)MCREG_Rip(ucontext->uc_mcontext); - *--sp = (size_t)MCREG_Rbp(ucontext->uc_mcontext); - size_t fp = (size_t)sp; - *--sp = fakeFrameReturnAddress; - - // Switch the current context to the signal_handler_worker and the original stack - CONTEXT context2; - RtlCaptureContext(&context2); - - // We don't care about the other registers state since the stack unwinding restores - // them for the target frame directly from the signal context. - context2.Rsp = (size_t)sp; - context2.Rbx = (size_t)faultSp; - context2.Rbp = (size_t)fp; - context2.Rip = (size_t)signal_handler_worker; - context2.Rdi = code; - context2.Rsi = (size_t)siginfo; - context2.Rdx = (size_t)context; - context2.Rcx = (size_t)returnPoint; - - RtlRestoreContext(&context2, NULL); -} diff --git a/src/pal/src/arch/arm/callsignalhandlerwrapper.S b/src/pal/src/arch/arm/callsignalhandlerwrapper.S deleted file mode 100644 index b9398d6d6..000000000 --- a/src/pal/src/arch/arm/callsignalhandlerwrapper.S +++ /dev/null @@ -1,47 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#include "unixasmmacros.inc" -#include "asmconstants.h" - -.syntax unified -.thumb - -.macro CALL_SIGNAL_HANDLER_WRAPPER Alignment - -.globl C_FUNC(SignalHandlerWorkerReturnOffset\Alignment) -C_FUNC(SignalHandlerWorkerReturnOffset\Alignment): - .int LOCAL_LABEL(SignalHandlerWorkerReturn\Alignment)-C_FUNC(CallSignalHandlerWrapper\Alignment) - -// This function is never called, only a fake stack frame will be setup to have a return -// address set to SignalHandlerWorkerReturn during SIGSEGV handling. -// It enables the unwinder to unwind stack from the handling code to the actual failure site. -NESTED_ENTRY CallSignalHandlerWrapper\Alignment, _TEXT, NoHandler -#ifndef __linux__ -__StackAllocationSize = (8 + 4 + \Alignment) // red zone + alignment - alloc_stack __StackAllocationSize - PROLOG_PUSH "{r7, r11, lr}" - bl EXTERNAL_C_FUNC(signal_handler_worker) -LOCAL_LABEL(SignalHandlerWorkerReturn\Alignment): - EPILOG_POP "{r7, r11, lr}" - free_stack __StackAllocationSize - bx lr -#else - // This unwind information is needed for lldb gdb doesn't use it and tries - // to read all registers from $sp + 12 - .save {r0-r15} - .pad #12 - bl EXTERNAL_C_FUNC(signal_handler_worker) -LOCAL_LABEL(SignalHandlerWorkerReturn\Alignment): - // Following instruction are needed to say gdb that this frame is SIGTRAMP_FRAME - // and it can restore all registers from stack - mov.w r7, #119 - svc 0 -#endif -NESTED_END CallSignalHandlerWrapper\Alignment, _TEXT - -.endm - -CALL_SIGNAL_HANDLER_WRAPPER 0 -CALL_SIGNAL_HANDLER_WRAPPER 4 diff --git a/src/pal/src/arch/arm/context2.S b/src/pal/src/arch/arm/context2.S deleted file mode 100644 index 42f50c9aa..000000000 --- a/src/pal/src/arch/arm/context2.S +++ /dev/null @@ -1,185 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -// -// Implementation of _CONTEXT_CaptureContext for the ARM platform. -// This function is processor dependent. It is used by exception handling, -// and is always apply to the current thread. -// - -#include "unixasmmacros.inc" -#include "asmconstants.h" - -.syntax unified -.thumb - -#define CONTEXT_ARM 0x00200000 - -#define CONTEXT_CONTROL 1 // Sp, Lr, Pc, Cpsr -#define CONTEXT_INTEGER 2 // R0-R12 -#define CONTEXT_SEGMENTS 4 // -#define CONTEXT_FLOATING_POINT 8 -#define CONTEXT_DEBUG_REGISTERS 16 // - -#define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_FLOATING_POINT) - - -// Incoming: -// r0: Context* -// -LEAF_ENTRY CONTEXT_CaptureContext, _TEXT - // Ensure we save these registers - push {r4-r11} - // Save processor flags before calling any of the following 'test' instructions - // because they will modify state of some flags - push {r1} - mrs r1, apsr // Get APSR - equivalent to eflags - push {r1} // Save APSR - END_PROLOGUE - - push {r2} - ldr r2, [r0, #(CONTEXT_ContextFlags)] - tst r2, #(CONTEXT_INTEGER) - pop {r2} - - // Add 4 to stack so we point at R1, pop, then sub 8 to point at APSR - add sp, sp, #4 - pop {r1} - sub sp, sp, #8 - - itttt ne - strne r0, [r0, #(CONTEXT_R0)] - addne r0, CONTEXT_R1 - stmiane r0, {r1-r12} - subne r0, CONTEXT_R1 - - ldr r2, [r0, #(CONTEXT_ContextFlags)] - tst r2, #(CONTEXT_CONTROL) - - ittt ne - addne sp, sp, #(10*4) // This needs to put the stack in the same state as it started - strne sp, [r0, #(CONTEXT_Sp)] - subne sp, sp, #(10*4) - - itt ne - strne lr, [r0, #(CONTEXT_Lr)] - strne lr, [r0, #(CONTEXT_Pc)] - - // Get the APSR pushed onto the stack at the start - pop {r1} - it ne - strne r1, [r0, #(CONTEXT_Cpsr)] - - ldr r2, [r0, #(CONTEXT_ContextFlags)] - tst r2, #(CONTEXT_FLOATING_POINT) - - itt ne - vmrsne r3, fpscr - strne r3, [r0, #(CONTEXT_Fpscr)] - - itttt ne - addne r0, CONTEXT_D0 - vstmiane r0!, {d0-d15} - vstmiane r0!, {d16-d31} - subne r0, CONTEXT_D31 - - // Make sure sp is restored - add sp, sp, #4 - - // Restore callee saved registers - pop {r4-r11} - bx lr -LEAF_END CONTEXT_CaptureContext, _TEXT - -// Incoming: -// R0: Context* -// -LEAF_ENTRY RtlCaptureContext, _TEXT - push {r1} - mov r1, #0 - orr r1, r1, #CONTEXT_ARM - orr r1, r1, #CONTEXT_INTEGER - orr r1, r1, #CONTEXT_CONTROL - orr r1, r1, #CONTEXT_FLOATING_POINT - str r1, [r0, #(CONTEXT_ContextFlags)] - pop {r1} - b C_FUNC(CONTEXT_CaptureContext) -LEAF_END RtlCaptureContext, _TEXT - -// Incoming: -// r0: Context* -// r1: Exception* -// -LEAF_ENTRY RtlRestoreContext, _TEXT - END_PROLOGUE - -#ifdef HAS_ASAN - ldr r2, [r0, #(CONTEXT_ContextFlags)] - tst r2, #(CONTEXT_CONTROL) - beq LOCAL_LABEL(Restore_CONTEXT_FLOATING_POINT) - - push {r0, r1} - bl EXTERNAL_C_FUNC(__asan_handle_no_return) - pop {r0, r1} - -LOCAL_LABEL(Restore_CONTEXT_FLOATING_POINT): -#endif - ldr r2, [r0, #(CONTEXT_ContextFlags)] - tst r2, #(CONTEXT_FLOATING_POINT) - - itttt ne - addne r0, CONTEXT_D0 - vldmiane r0!, {d0-d15} - vldmiane r0, {d16-d31} - subne r0, CONTEXT_D16 - - itt ne - ldrne r3, [r0, #(CONTEXT_Fpscr)] - vmrsne r3, FPSCR - - ldr r2, [r0, #(CONTEXT_ContextFlags)] - tst r2, #(CONTEXT_CONTROL) - - it eq - beq LOCAL_LABEL(No_Restore_CONTEXT_CONTROL) - - ldr r2, [r0, #(CONTEXT_ContextFlags)] - tst r2, #(CONTEXT_INTEGER) - - it eq - beq LOCAL_LABEL(No_Restore_CONTEXT_INTEGER) - - ldr R2, [r0, #(CONTEXT_Cpsr)] - msr APSR, r2 - - // Ideally, we would like to use `ldmia r0, {r0-r12, sp, lr, pc}` here, - // but clang 3.6 and later, as per ARM recommendation, disallows using - // Sp in the register list, and Pc and Lr simultaneously. - // So we are going to use the IPC register r12 to copy Sp, Lr and Pc - // which should be ok -- TODO: Is this really ok? - add r12, r0, CONTEXT_R0 - ldm r12, {r0-r11} - ldr sp, [r12, #(CONTEXT_Sp - (CONTEXT_R0))] - ldr lr, [r12, #(CONTEXT_Lr - (CONTEXT_R0))] - ldr pc, [r12, #(CONTEXT_Pc - (CONTEXT_R0))] - -LOCAL_LABEL(No_Restore_CONTEXT_INTEGER): - - ldr r2, [r0, #(CONTEXT_Cpsr)] - msr APSR, r2 - - ldr sp, [r0, #(CONTEXT_Sp)] - ldr lr, [r0, #(CONTEXT_Lr)] - ldr pc, [r0, #(CONTEXT_Pc)] - -LOCAL_LABEL(No_Restore_CONTEXT_CONTROL): - ldr r2, [r0, #(CONTEXT_ContextFlags)] - tst r2, #(CONTEXT_INTEGER) - - itt ne - addne r0, CONTEXT_R0 - ldmiane r0, {r0-r12} - - sub sp, sp, #4 - bx lr -LEAF_END RtlRestoreContext, _TEXT diff --git a/src/pal/src/arch/arm/exceptionhelper.S b/src/pal/src/arch/arm/exceptionhelper.S deleted file mode 100644 index 4e324ce3b..000000000 --- a/src/pal/src/arch/arm/exceptionhelper.S +++ /dev/null @@ -1,38 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#include "unixasmmacros.inc" -#include "asmconstants.h" - -.syntax unified -.thumb - -// EXTERN_C void ThrowExceptionFromContextInternal(CONTEXT* context, PAL_SEHException* ex); -LEAF_ENTRY ThrowExceptionFromContextInternal, _TEXT - // Ported from src/pal/src/arch/amd64/exceptionhelper.S -#ifdef HAS_ASAN - // Need to call __asan_handle_no_return explicitly here because we re-intialize SP before - // throwing exception in ThrowExceptionHelper - push_nonvol_reg "{r0, r1}" - bl EXTERNAL_C_FUNC(__asan_handle_no_return) - pop_nonvol_reg "{r0, r1}" -#endif - - push_nonvol_reg {r7} /* FP. x64-RBP */ - - ldr r4, [r0, #(CONTEXT_R4)] - ldr r5, [r0, #(CONTEXT_R5)] - ldr r6, [r0, #(CONTEXT_R6)] - ldr r7, [r0, #(CONTEXT_R7)] - ldr r8, [r0, #(CONTEXT_R8)] - ldr r9, [r0, #(CONTEXT_R9)] - ldr r10, [r0, #(CONTEXT_R10)] - ldr r11, [r0, #(CONTEXT_R11)] - ldr sp, [r0, #(CONTEXT_Sp)] - ldr lr, [r0, #(CONTEXT_Pc)] - - // The PAL_SEHException pointer - mov r0, r1 - b EXTERNAL_C_FUNC(ThrowExceptionHelper) -LEAF_END ThrowExceptionFromContextInternal, _TEXT diff --git a/src/pal/src/arch/arm/signalhandlerhelper.cpp b/src/pal/src/arch/arm/signalhandlerhelper.cpp deleted file mode 100644 index 4efecfc1c..000000000 --- a/src/pal/src/arch/arm/signalhandlerhelper.cpp +++ /dev/null @@ -1,81 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#include "pal/dbgmsg.h" -SET_DEFAULT_DEBUG_CHANNEL(EXCEPT); // some headers have code with asserts, so do this first - -#include "pal/palinternal.h" -#include "pal/context.h" -#include "pal/signal.hpp" -#include "pal/utils.h" -#include - -/*++ -Function : - signal_handler_worker - - Handles signal on the original stack where the signal occured. - Invoked via setcontext. - -Parameters : - POSIX signal handler parameter list ("man sigaction" for details) - returnPoint - context to which the function returns if the common_signal_handler returns - - (no return value) ---*/ -void ExecuteHandlerOnOriginalStack(int code, siginfo_t *siginfo, void *context, SignalHandlerWorkerReturnPoint* returnPoint) -{ - ucontext_t *ucontext = (ucontext_t *)context; - size_t faultSp = (size_t)MCREG_Sp(ucontext->uc_mcontext); - - _ASSERTE(IS_ALIGNED(faultSp, 4)); - - size_t fakeFrameReturnAddress; - - if (IS_ALIGNED(faultSp, 8)) - { - fakeFrameReturnAddress = (size_t)SignalHandlerWorkerReturnOffset0 + (size_t)CallSignalHandlerWrapper0; - } - else - { - fakeFrameReturnAddress = (size_t)SignalHandlerWorkerReturnOffset4 + (size_t)CallSignalHandlerWrapper4; - } - - // preserve 8 bytes long red zone and align stack pointer - size_t* sp = (size_t*)ALIGN_DOWN(faultSp - 8, 8); - -#ifndef __linux__ - size_t cpsr = (size_t)MCREG_Cpsr(ucontext->uc_mcontext); - - // Build fake stack frame to enable the stack unwinder to unwind from signal_handler_worker to the faulting instruction - // align - --sp; - // pushed LR with correct mode bit - *--sp = (size_t)MCREG_Pc(ucontext->uc_mcontext) | ((cpsr & (1 << 5)) >> 5); - // pushed frame pointer - *--sp = (size_t)MCREG_R11(ucontext->uc_mcontext); - *--sp = (size_t)MCREG_R7(ucontext->uc_mcontext); -#else - size_t size = ALIGN_UP(sizeof(ucontext->uc_mcontext), 8); - sp -= size / sizeof(size_t); - *(sigcontext *)sp = ucontext->uc_mcontext; -#endif - - // Switch the current context to the signal_handler_worker and the original stack - CONTEXT context2; - RtlCaptureContext(&context2); - - // We don't care about the other registers state since the stack unwinding restores - // them for the target frame directly from the signal context. - context2.Sp = (size_t)sp; - context2.R7 = (size_t)sp; // Fp and Sp are the same - context2.Lr = fakeFrameReturnAddress; - context2.Pc = (size_t)signal_handler_worker; - context2.R0 = code; - context2.R1 = (size_t)siginfo; - context2.R2 = (size_t)context; - context2.R3 = (size_t)returnPoint; - - RtlRestoreContext(&context2, NULL); -} diff --git a/src/pal/src/arch/arm64/callsignalhandlerwrapper.S b/src/pal/src/arch/arm64/callsignalhandlerwrapper.S deleted file mode 100644 index 90fb60247..000000000 --- a/src/pal/src/arch/arm64/callsignalhandlerwrapper.S +++ /dev/null @@ -1,32 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#include "unixasmmacros.inc" -#include "asmconstants.h" - -.macro CALL_SIGNAL_HANDLER_WRAPPER Alignment - -.globl C_FUNC(SignalHandlerWorkerReturnOffset\Alignment) -C_FUNC(SignalHandlerWorkerReturnOffset\Alignment): - .int LOCAL_LABEL(SignalHandlerWorkerReturn\Alignment)-C_FUNC(CallSignalHandlerWrapper\Alignment) - -// This function is never called, only a fake stack frame will be setup to have a return -// address set to SignalHandlerWorkerReturn during SIGSEGV handling. -// It enables the unwinder to unwind stack from the handling code to the actual failure site. -NESTED_ENTRY CallSignalHandlerWrapper\Alignment, _TEXT, NoHandler -__StackAllocationSize = (128 + 8 + 8 + \Alignment) // red zone + fp + lr + alignment - PROLOG_STACK_ALLOC __StackAllocationSize - .cfi_adjust_cfa_offset __StackAllocationSize - PROLOG_SAVE_REG_PAIR fp, lr, 0 - bl EXTERNAL_C_FUNC(signal_handler_worker) -LOCAL_LABEL(SignalHandlerWorkerReturn\Alignment): - EPILOG_RESTORE_REG_PAIR fp, lr, 0 - EPILOG_STACK_FREE __StackAllocationSize - ret -NESTED_END CallSignalHandlerWrapper\Alignment, _TEXT - -.endm - -CALL_SIGNAL_HANDLER_WRAPPER 0 -CALL_SIGNAL_HANDLER_WRAPPER 8 diff --git a/src/pal/src/arch/arm64/context2.S b/src/pal/src/arch/arm64/context2.S deleted file mode 100644 index 64a19c9df..000000000 --- a/src/pal/src/arch/arm64/context2.S +++ /dev/null @@ -1,213 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -// -// Implementation of _CONTEXT_CaptureContext for the ARM platform. -// This function is processor dependent. It is used by exception handling, -// and is always apply to the current thread. -// - -#include "unixasmmacros.inc" -#include "asmconstants.h" - -// Incoming: -// x0: Context* -// -LEAF_ENTRY CONTEXT_CaptureContext, _TEXT - sub sp, sp, #32 - // save x1, x2 and x3 on stack so we can use them as scratch - stp x1, x2, [sp] - str x3, [sp, 16] - // save the current flags on the stack - mrs x1, nzcv - str x1, [sp, 24] - - ldr w1, [x0, CONTEXT_ContextFlags] - // clangs assembler doesn't seem to support the mov Wx, imm32 yet - movz w2, #0x40, lsl #16 - movk w2, #0x1 - mov w3, w2 - and w2, w1, w2 - cmp w2, w3 - b.ne LOCAL_LABEL(Done_CONTEXT_CONTROL) - - // save the cpsr - ldr x2, [sp, 24] - str w2, [x0, CONTEXT_Cpsr] - stp fp, lr, [x0, CONTEXT_Fp] - add x2, sp, #32 - stp x2, lr, [x0, CONTEXT_Sp] - -LOCAL_LABEL(Done_CONTEXT_CONTROL): - // we dont clobber x1 in the CONTEXT_CONTROL case - // ldr w1, [x0, CONTEXT_ContextFlags] - // clangs assembler doesn't seem to support the mov Wx, imm32 yet - movz w2, #0x40, lsl #16 - movk w2, #0x2 - mov w3, w2 - and w2, w1, w2 - cmp w2, w3 - b.ne LOCAL_LABEL(Done_CONTEXT_INTEGER) - - ldp x1, x2, [sp] - ldr x3, [sp, 16] - - stp x0, x1, [x0, CONTEXT_X0] - stp x2, x3, [x0, CONTEXT_X2] - stp x4, x5, [x0, CONTEXT_X4] - stp x6, x7, [x0, CONTEXT_X6] - stp x8, x9, [x0, CONTEXT_X8] - stp x10, x11, [x0, CONTEXT_X10] - stp x12, x13, [x0, CONTEXT_X12] - stp x14, x15, [x0, CONTEXT_X14] - stp x16, x17, [x0, CONTEXT_X16] - stp x18, x19, [x0, CONTEXT_X18] - stp x20, x21, [x0, CONTEXT_X20] - stp x22, x23, [x0, CONTEXT_X22] - stp x24, x25, [x0, CONTEXT_X24] - stp x26, x27, [x0, CONTEXT_X26] - str x28, [x0, CONTEXT_X28] - - -LOCAL_LABEL(Done_CONTEXT_INTEGER): - ldr w1, [x0, CONTEXT_ContextFlags] - // clangs assembler doesn't seem to support the mov Wx, imm32 yet - movz w2, #0x40, lsl #16 - movk w2, #0x4 - mov w3, w2 - and w2, w1, w2 - cmp w2, w3 - b.ne LOCAL_LABEL(Done_CONTEXT_FLOATING_POINT) - - add x0, x0, CONTEXT_NEON_OFFSET - stp q0, q1, [x0, CONTEXT_V0] - stp q2, q3, [x0, CONTEXT_V2] - stp q4, q5, [x0, CONTEXT_V4] - stp q6, q7, [x0, CONTEXT_V6] - stp q8, q9, [x0, CONTEXT_V8] - stp q10, q11, [x0, CONTEXT_V10] - stp q12, q13, [x0, CONTEXT_V12] - stp q14, q15, [x0, CONTEXT_V14] - stp q16, q17, [x0, CONTEXT_V16] - stp q18, q19, [x0, CONTEXT_V18] - stp q20, q21, [x0, CONTEXT_V20] - stp q22, q23, [x0, CONTEXT_V22] - stp q24, q25, [x0, CONTEXT_V24] - stp q26, q27, [x0, CONTEXT_V26] - stp q28, q29, [x0, CONTEXT_V28] - stp q30, q31, [x0, CONTEXT_V30] - add x0, x0, CONTEXT_FLOAT_CONTROL_OFFSET - mrs x1, fpcr - mrs x2, fpsr - sub x0, x0, CONTEXT_FLOAT_CONTROL_OFFSET - stp x1, x2, [x0, CONTEXT_Fpcr] - sub x0, x0, CONTEXT_NEON_OFFSET - -LOCAL_LABEL(Done_CONTEXT_FLOATING_POINT): - - add sp, sp, #32 - ret -LEAF_END CONTEXT_CaptureContext, _TEXT - -// Incoming: -// x0: Context* - -LEAF_ENTRY RtlCaptureContext, _TEXT - sub sp, sp, #16 - str x1, [sp] - // same as above, clang doesn't like mov with #imm32 - // keep this in sync if CONTEXT_FULL changes - movz w1, #0x40, lsl #16 - orr w1, w1, #0x1 - orr w1, w1, #0x2 - orr w1, w1, #0x4 - orr w1, w1, #0x8 - str w1, [x0, CONTEXT_ContextFlags] - ldr x1, [sp] - add sp, sp, #16 - b C_FUNC(CONTEXT_CaptureContext) -LEAF_END RtlCaptureContext, _TEXT - -// Incoming: -// x0: Context* -// x1: Exception* -// -LEAF_ENTRY RtlRestoreContext, _TEXT - -#ifdef HAS_ASAN - ldr w17, [x0, #(CONTEXT_ContextFlags)] - tbz w17, #CONTEXT_CONTROL_BIT, LOCAL_LABEL(Restore_CONTEXT_FLOATING_POINT) - - stp x0, x1, [sp, -16]! - bl EXTERNAL_C_FUNC(__asan_handle_no_return) - ldp x0, x1, [sp], 16 - -LOCAL_LABEL(Restore_CONTEXT_FLOATING_POINT): -#endif - // aarch64 specifies: - // IP0 and IP1, the Intra-Procedure Call temporary registers, - // are available for use by e.g. veneers or branch islands during a procedure call. - // They are otherwise corruptible. - // Since we cannot control $pc directly, we're going to corrupt x16 and x17 - // so that we can restore control - // since we potentially clobber x0 below, we'll bank it in x16 - mov x16, x0 - - ldr w17, [x16, CONTEXT_ContextFlags] - tbz w17, #CONTEXT_FLOATING_POINT_BIT, LOCAL_LABEL(No_Restore_CONTEXT_FLOATING_POINT) - - add x16, x16, CONTEXT_NEON_OFFSET - ldp q0, q1, [x16, CONTEXT_V0] - ldp q2, q3, [x16, CONTEXT_V2] - ldp q4, q5, [x16, CONTEXT_V4] - ldp q6, q7, [x16, CONTEXT_V6] - ldp q8, q9, [x16, CONTEXT_V8] - ldp q10, q11, [x16, CONTEXT_V10] - ldp q12, q13, [x16, CONTEXT_V12] - ldp q14, q15, [x16, CONTEXT_V14] - ldp q16, q17, [x16, CONTEXT_V16] - ldp q18, q19, [x16, CONTEXT_V18] - ldp q20, q21, [x16, CONTEXT_V20] - ldp q22, q23, [x16, CONTEXT_V22] - ldp q24, q25, [x16, CONTEXT_V24] - ldp q26, q27, [x16, CONTEXT_V26] - ldp q28, q29, [x16, CONTEXT_V28] - ldp q30, q31, [x16, CONTEXT_V30] - ldp x1, x2, [x16, CONTEXT_Fpcr] - msr fpcr, x1 - msr fpsr, x2 - sub x16, x16, CONTEXT_NEON_OFFSET - -LOCAL_LABEL(No_Restore_CONTEXT_FLOATING_POINT): - tbz w17, #CONTEXT_INTEGER_BIT, LOCAL_LABEL(No_Restore_CONTEXT_INTEGER) - - ldp x0, x1, [x16, CONTEXT_X0] - ldp x2, x3, [x16, CONTEXT_X2] - ldp x4, x5, [x16, CONTEXT_X4] - ldp x6, x7, [x16, CONTEXT_X6] - ldp x8, x9, [x16, CONTEXT_X8] - ldp x10, x11, [x16, CONTEXT_X10] - ldp x12, x13, [x16, CONTEXT_X12] - ldp x14, x15, [x16, CONTEXT_X14] - ldp x18, x19, [x16, CONTEXT_X18] - ldp x20, x21, [x16, CONTEXT_X20] - ldp x22, x23, [x16, CONTEXT_X22] - ldp x24, x25, [x16, CONTEXT_X24] - ldp x26, x27, [x16, CONTEXT_X26] - ldr x28, [x16, CONTEXT_X28] - -LOCAL_LABEL(No_Restore_CONTEXT_INTEGER): - tbz w17, #CONTEXT_CONTROL_BIT, LOCAL_LABEL(No_Restore_CONTEXT_CONTROL) - - ldr w17, [x16, CONTEXT_Cpsr] - msr nzcv, x17 - ldp fp, lr, [x16, CONTEXT_Fp] - ldr x17, [x16, CONTEXT_Sp] - mov sp, x17 - ldr x17, [x16, CONTEXT_Pc] - br x17 - -LOCAL_LABEL(No_Restore_CONTEXT_CONTROL): - ret - -LEAF_END RtlRestoreContext, _TEXT diff --git a/src/pal/src/arch/arm64/exceptionhelper.S b/src/pal/src/arch/arm64/exceptionhelper.S deleted file mode 100644 index c4499fb93..000000000 --- a/src/pal/src/arch/arm64/exceptionhelper.S +++ /dev/null @@ -1,40 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#include "unixasmmacros.inc" -#include "asmconstants.h" - -////////////////////////////////////////////////////////////////////////// -// -// This function creates a stack frame right below the target frame, restores all callee -// saved registers, SP, and LR from the passed in context. -// Then it uses the ThrowExceptionHelper to throw the passed in exception from that context. -// EXTERN_C void ThrowExceptionFromContextInternal(CONTEXT* context, PAL_SEHException* ex); -LEAF_ENTRY ThrowExceptionFromContextInternal, _TEXT -#ifdef HAS_ASAN - // Need to call __asan_handle_no_return explicitly here because we re-intialize SP before - // throwing exception in ThrowExceptionHelper - stp x0, x1, [sp, -16]! - bl EXTERNAL_C_FUNC(__asan_handle_no_return) - ldp x0, x1, [sp], 16 -#endif - - // Save the FP & LR to the stack so that the unwind can work at the instruction after - // loading the FP from the context, but before loading the SP from the context. - stp fp, lr, [sp, -16]! - - ldp x19,x20, [x0, #(CONTEXT_X19)] - ldp x21,x22, [x0, #(CONTEXT_X21)] - ldp x23,x24, [x0, #(CONTEXT_X23)] - ldp x24,x25, [x0, #(CONTEXT_X24)] - ldp x26,x27, [x0, #(CONTEXT_X26)] - ldp x28,fp, [x0, #(CONTEXT_X28)] - ldr lr, [x0, #(CONTEXT_Pc)] - ldr x2, [x0, #(CONTEXT_Sp)] - mov sp, x2 - - // The PAL_SEHException pointer - mov x0, x1 - b EXTERNAL_C_FUNC(ThrowExceptionHelper) -LEAF_END ThrowExceptionFromContextInternal, _TEXT diff --git a/src/pal/src/arch/arm64/signalhandlerhelper.cpp b/src/pal/src/arch/arm64/signalhandlerhelper.cpp deleted file mode 100644 index c35c629ab..000000000 --- a/src/pal/src/arch/arm64/signalhandlerhelper.cpp +++ /dev/null @@ -1,67 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#include "pal/dbgmsg.h" -SET_DEFAULT_DEBUG_CHANNEL(EXCEPT); // some headers have code with asserts, so do this first - -#include "pal/palinternal.h" -#include "pal/context.h" -#include "pal/signal.hpp" -#include "pal/utils.h" -#include - -/*++ -Function : - signal_handler_worker - - Handles signal on the original stack where the signal occured. - Invoked via setcontext. - -Parameters : - POSIX signal handler parameter list ("man sigaction" for details) - returnPoint - context to which the function returns if the common_signal_handler returns - - (no return value) ---*/ -void ExecuteHandlerOnOriginalStack(int code, siginfo_t *siginfo, void *context, SignalHandlerWorkerReturnPoint* returnPoint) -{ - ucontext_t *ucontext = (ucontext_t *)context; - size_t faultSp = (size_t)MCREG_Sp(ucontext->uc_mcontext); - _ASSERTE(IS_ALIGNED(faultSp, 8)); - - size_t fakeFrameReturnAddress; - - if (IS_ALIGNED(faultSp, 16)) - { - fakeFrameReturnAddress = (size_t)SignalHandlerWorkerReturnOffset0 + (size_t)CallSignalHandlerWrapper0; - } - else - { - fakeFrameReturnAddress = (size_t)SignalHandlerWorkerReturnOffset8 + (size_t)CallSignalHandlerWrapper8; - } - - // preserve 128 bytes long red zone and align stack pointer - size_t* sp = (size_t*)ALIGN_DOWN(faultSp - 128, 16); - - // Build fake stack frame to enable the stack unwinder to unwind from signal_handler_worker to the faulting instruction - // pushed LR - *--sp = (size_t)MCREG_Pc(ucontext->uc_mcontext); - // pushed frame pointer - *--sp = (size_t)MCREG_Fp(ucontext->uc_mcontext); - - // Switch the current context to the signal_handler_worker and the original stack - CONTEXT context2; - RtlCaptureContext(&context2); - - context2.Sp = (size_t)sp; - context2.Fp = (size_t)sp; - context2.Lr = fakeFrameReturnAddress; - context2.Pc = (size_t)signal_handler_worker; - context2.X0 = code; - context2.X1 = (size_t)siginfo; - context2.X2 = (size_t)context; - context2.X3 = (size_t)returnPoint; - - RtlRestoreContext(&context2, NULL); -} diff --git a/src/pal/src/arch/i386/callsignalhandlerwrapper.S b/src/pal/src/arch/i386/callsignalhandlerwrapper.S deleted file mode 100644 index 26f06d988..000000000 --- a/src/pal/src/arch/i386/callsignalhandlerwrapper.S +++ /dev/null @@ -1,47 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -.intel_syntax noprefix -#include "unixasmmacros.inc" -#include "asmconstants.h" - -.macro CALL_SIGNAL_HANDLER_WRAPPER Alignment - -.globl C_FUNC(SignalHandlerWorkerReturnOffset\Alignment) -C_FUNC(SignalHandlerWorkerReturnOffset\Alignment): - .int LOCAL_LABEL(SignalHandlerWorkerReturn\Alignment)-C_FUNC(CallSignalHandlerWrapper\Alignment) - -// This function is never called, only a fake stack frame will be setup to have a return -// address set to SignalHandlerWorkerReturn during SIGSEGV handling. -// It enables the unwinder to unwind stack from the handling code to the actual failure site. -NESTED_ENTRY CallSignalHandlerWrapper\Alignment, _TEXT, NoHandler - - .cfi_def_cfa_offset (4 + \Alignment) // return address + stack alignment - .cfi_offset eip, -(4 + \Alignment) - push ebp - .cfi_adjust_cfa_offset 4 - .cfi_rel_offset ebp, 0 - mov ebp, esp - .cfi_def_cfa_register ebp - // Align stack - sub esp, 8 - // Simulate arguments pushing - push eax - push eax - push eax - push eax - call EXTERNAL_C_FUNC(signal_handler_worker) -LOCAL_LABEL(SignalHandlerWorkerReturn\Alignment): - add esp, 4 * 4 + 8 - pop ebp - ret - -NESTED_END CallSignalHandlerWrapper\Alignment, _TEXT - -.endm - -CALL_SIGNAL_HANDLER_WRAPPER 0 -CALL_SIGNAL_HANDLER_WRAPPER 4 -CALL_SIGNAL_HANDLER_WRAPPER 8 -CALL_SIGNAL_HANDLER_WRAPPER 12 diff --git a/src/pal/src/arch/i386/context2.S b/src/pal/src/arch/i386/context2.S deleted file mode 100644 index 8c5db2030..000000000 --- a/src/pal/src/arch/i386/context2.S +++ /dev/null @@ -1,137 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -.intel_syntax noprefix -#include "unixasmmacros.inc" -#include "asmconstants.h" - -// -// Implementation of CONTEXT_CaptureContext for the Intel x86 platform. -// -// extern void CONTEXT_CaptureContext(LPCONTEXT lpContext); -// -// This function is processor-dependent. It is used by exception handling, -// and is always apply to the current thread. -// -LEAF_ENTRY CONTEXT_CaptureContext, _TEXT - // Store - push eax - push ebx - - // The stack will contain the following elements on the top of - // the caller's stack - // [ebx] / esp + 00 - // [eax] / esp + 04 - // [ret] / esp + 08 - // [arg0: lpContext] / esp + 12 - - mov eax, [esp + 12] // eax will point to lpContext - - // Capture INTEGER registers - mov ebx, [esp + 4] - mov [eax + CONTEXT_Eax], ebx - mov ebx, [esp] - mov [eax + CONTEXT_Ebx], ebx - mov [eax + CONTEXT_Ecx], ecx - mov [eax + CONTEXT_Edx], edx - mov [eax + CONTEXT_Esi], esi - mov [eax + CONTEXT_Edi], edi - - // Capture CONTROL registers - mov [eax + CONTEXT_Ebp], ebp - lea ebx, [esp + 12] - mov [eax + CONTEXT_Esp], ebx - mov ebx, [esp + 8] - mov [eax + CONTEXT_Eip], ebx - - push cs - xor ebx, ebx - pop bx - mov [eax + CONTEXT_SegCs], ebx - - push ss - xor ebx, ebx - pop bx - mov [eax + CONTEXT_SegSs], ebx - - pushf - xor ebx, ebx - pop bx - mov [eax + CONTEXT_EFlags], ebx - - test BYTE PTR [eax + CONTEXT_ContextFlags], CONTEXT_FLOATING_POINT - je LOCAL_LABEL(Done_CONTEXT_FLOATING_POINT) - // Capture FPU status - fnsave [eax + CONTEXT_FloatSave] - frstor [eax + CONTEXT_FloatSave] -LOCAL_LABEL(Done_CONTEXT_FLOATING_POINT): - - test BYTE PTR [eax + CONTEXT_ContextFlags], CONTEXT_EXTENDED_REGISTERS - je LOCAL_LABEL(Done_CONTEXT_EXTENDED_REGISTERS) - movdqu [eax + CONTEXT_Xmm0], xmm0 - movdqu [eax + CONTEXT_Xmm1], xmm1 - movdqu [eax + CONTEXT_Xmm2], xmm2 - movdqu [eax + CONTEXT_Xmm3], xmm3 - movdqu [eax + CONTEXT_Xmm4], xmm4 - movdqu [eax + CONTEXT_Xmm5], xmm5 - movdqu [eax + CONTEXT_Xmm6], xmm6 - movdqu [eax + CONTEXT_Xmm7], xmm7 -LOCAL_LABEL(Done_CONTEXT_EXTENDED_REGISTERS): - - // Restore - pop ebx - pop eax - ret -LEAF_END CONTEXT_CaptureContext, _TEXT - -LEAF_ENTRY RtlCaptureContext, _TEXT - push eax - mov eax, [esp + 8] - mov DWORD PTR [eax + CONTEXT_ContextFlags], (CONTEXT_FLOATING_POINT) - pop eax - jmp C_FUNC(CONTEXT_CaptureContext) -LEAF_END RtlCaptureContext, _TEXT - -LEAF_ENTRY RtlRestoreContext, _TEXT - -#ifdef HAS_ASAN - call EXTERNAL_C_FUNC(__asan_handle_no_return) -#endif - mov eax, [esp + 4] - test BYTE PTR [eax + CONTEXT_ContextFlags], CONTEXT_FLOATING_POINT - je LOCAL_LABEL(Done_Restore_CONTEXT_FLOATING_POINT) - frstor [eax + CONTEXT_FloatSave] -LOCAL_LABEL(Done_Restore_CONTEXT_FLOATING_POINT): - - test BYTE PTR [eax + CONTEXT_ContextFlags], CONTEXT_EXTENDED_REGISTERS - je LOCAL_LABEL(Done_Restore_CONTEXT_EXTENDED_REGISTERS) - movdqu xmm0, [eax + CONTEXT_Xmm0] - movdqu xmm1, [eax + CONTEXT_Xmm1] - movdqu xmm2, [eax + CONTEXT_Xmm2] - movdqu xmm3, [eax + CONTEXT_Xmm3] - movdqu xmm4, [eax + CONTEXT_Xmm4] - movdqu xmm5, [eax + CONTEXT_Xmm5] - movdqu xmm6, [eax + CONTEXT_Xmm6] - movdqu xmm7, [eax + CONTEXT_Xmm7] -LOCAL_LABEL(Done_Restore_CONTEXT_EXTENDED_REGISTERS): - - // Restore Stack - mov esp, [eax + CONTEXT_Esp] - - // Create a minimal frame - push DWORD PTR [eax + CONTEXT_Eip] - - // Restore register(s) - mov ebp, [eax + CONTEXT_Ebp] - mov edi, [eax + CONTEXT_Edi] - mov esi, [eax + CONTEXT_Esi] - mov edx, [eax + CONTEXT_Edx] - mov ecx, [eax + CONTEXT_Ecx] - mov ebx, [eax + CONTEXT_Ebx] - mov eax, [eax + CONTEXT_Eax] - - // Resume - ret -LEAF_END RtlRestoreContext, _TEXT - diff --git a/src/pal/src/arch/i386/exceptionhelper.S b/src/pal/src/arch/i386/exceptionhelper.S deleted file mode 100644 index 609efcff7..000000000 --- a/src/pal/src/arch/i386/exceptionhelper.S +++ /dev/null @@ -1,50 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -.intel_syntax noprefix -#include "unixasmmacros.inc" -#include "asmconstants.h" - -////////////////////////////////////////////////////////////////////////// -// -// EXTERN_C void ThrowExceptionFromContextInternal(CONTEXT* context, PAL_SEHException* ex); -// -// This function creates a stack frame right below the target frame, restores all callee -// saved registers from the passed in context, sets the SP to that frame and sets the -// return address to the target frame's IP. -// Then it uses the ThrowExceptionHelper to throw the passed in exception from that context. -// -////////////////////////////////////////////////////////////////////////// - -LEAF_ENTRY ThrowExceptionFromContextInternal, _TEXT -#ifdef HAS_ASAN - // Need to call __asan_handle_no_return explicitly here because we re-intialize ESP before - // throwing exception in ThrowExceptionHelper - call EXTERNAL_C_FUNC(__asan_handle_no_return) -#endif - - push ebp - mov ecx, [esp + 12] // ecx: PAL_SEHException * (first argument for ThrowExceptionHelper) - mov eax, [esp + 8] // ebx: CONTEXT * - - mov ebp, [eax + CONTEXT_Ebp] - mov esp, [eax + CONTEXT_Esp] - mov ebx, [eax + CONTEXT_Ebx] - mov esi, [eax + CONTEXT_Esi] - mov edi, [eax + CONTEXT_Edi] - - // The ESP is re-initialized as the target frame's value, so the current function's - // CFA is now right at the ESP. - .cfi_def_cfa_offset 0 - - // Indicate that now that we have moved the RSP to the target address, - // the EBP is no longer saved in the current stack frame. - .cfi_restore ebp - - // Store return address to the stack - mov eax, [eax + CONTEXT_Eip] - push eax - jmp EXTERNAL_C_FUNC(ThrowExceptionHelper) - -LEAF_END ThrowExceptionFromContextInternal, _TEXT diff --git a/src/pal/src/arch/i386/signalhandlerhelper.cpp b/src/pal/src/arch/i386/signalhandlerhelper.cpp deleted file mode 100644 index a7d418a78..000000000 --- a/src/pal/src/arch/i386/signalhandlerhelper.cpp +++ /dev/null @@ -1,77 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#include "pal/dbgmsg.h" -SET_DEFAULT_DEBUG_CHANNEL(EXCEPT); // some headers have code with asserts, so do this first - -#include "pal/palinternal.h" -#include "pal/context.h" -#include "pal/signal.hpp" -#include "pal/utils.h" -#include - -/*++ -Function : - signal_handler_worker - - Handles signal on the original stack where the signal occured. - Invoked via setcontext. - -Parameters : - POSIX signal handler parameter list ("man sigaction" for details) - returnPoint - context to which the function returns if the common_signal_handler returns - - (no return value) ---*/ -void ExecuteHandlerOnOriginalStack(int code, siginfo_t *siginfo, void *context, SignalHandlerWorkerReturnPoint* returnPoint) -{ - ucontext_t *ucontext = (ucontext_t *)context; - size_t faultSp = (size_t)MCREG_Esp(ucontext->uc_mcontext); - - _ASSERTE(IS_ALIGNED(faultSp, 4)); - - size_t fakeFrameReturnAddress; - - switch (faultSp & 0xc) - { - case 0x0: - fakeFrameReturnAddress = (size_t)SignalHandlerWorkerReturnOffset0 + (size_t)CallSignalHandlerWrapper0; - break; - case 0x4: - fakeFrameReturnAddress = (size_t)SignalHandlerWorkerReturnOffset4 + (size_t)CallSignalHandlerWrapper4; - break; - case 0x8: - fakeFrameReturnAddress = (size_t)SignalHandlerWorkerReturnOffset8 + (size_t)CallSignalHandlerWrapper8; - break; - case 0xc: - fakeFrameReturnAddress = (size_t)SignalHandlerWorkerReturnOffset12 + (size_t)CallSignalHandlerWrapper12; - break; - } - - size_t* sp = (size_t*)ALIGN_DOWN(faultSp, 16); - - // Build fake stack frame to enable the stack unwinder to unwind from signal_handler_worker to the faulting instruction - *--sp = (size_t)MCREG_Eip(ucontext->uc_mcontext); - *--sp = (size_t)MCREG_Ebp(ucontext->uc_mcontext); - size_t fp = (size_t)sp; - // Align stack - sp -= 2; - *--sp = (size_t)returnPoint; - *--sp = (size_t)context; - *--sp = (size_t)siginfo; - *--sp = code; - *--sp = fakeFrameReturnAddress; - - // Switch the current context to the signal_handler_worker and the original stack - CONTEXT context2; - RtlCaptureContext(&context2); - - // We don't care about the other registers state since the stack unwinding restores - // them for the target frame directly from the signal context. - context2.Esp = (size_t)sp; - context2.Ebp = (size_t)fp; - context2.Eip = (size_t)signal_handler_worker; - - RtlRestoreContext(&context2, NULL); -} diff --git a/src/pal/src/build_tools/mdtool_dummy b/src/pal/src/build_tools/mdtool_dummy deleted file mode 100644 index 1005a3496..000000000 --- a/src/pal/src/build_tools/mdtool_dummy +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh - -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -echo mdtool_dummy : not generating any dependencies diff --git a/src/pal/src/build_tools/mdtool_gcc.in b/src/pal/src/build_tools/mdtool_gcc.in deleted file mode 100644 index bef95d5cc..000000000 --- a/src/pal/src/build_tools/mdtool_gcc.in +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/sh - -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. -# -# mdtool_gcc -# -#Abstract: -# Generates dependencies for a makefile -# (for gcc compilers) -# - -str=`grep -n '#mdtool output goes here>' obj${BUILD_ALT_DIR}/${_BUILDARCH}/makefile` -if [ "$str" = "" ] ; then -#didn't find our placeholder string : don't change file - echo mdtool_gcc : makefile not setup for mdtool : ignoring - exit 0 -fi - -#truncate makefile to remove old dependencies -sed /'#mdtool output goes here>'/q obj${BUILD_ALT_DIR}/${_BUILDARCH}/makefile > obj${BUILD_ALT_DIR}/${_BUILDARCH}/makefile.final - -echo '#dependencies generated by mdtool_gcc :' >> obj${BUILD_ALT_DIR}/${_BUILDARCH}/makefile.final -echo >> obj${BUILD_ALT_DIR}/${_BUILDARCH}/makefile.final -# gcc -M generates make-friendly dependencies; -# -MM ignores system includes (#include ) -@CC@ @MDTOOL_CFLAGS@ $@ >> obj${BUILD_ALT_DIR}/${_BUILDARCH}/makefile.depfromgcc -#Prepend ../.. to the source's filename -#with some sed magic, since gcc doesn't do it for us. -sed 's#: \(.*\)$#: ../../\1#g' obj${BUILD_ALT_DIR}/${_BUILDARCH}/makefile.depfromgcc > obj${BUILD_ALT_DIR}/${_BUILDARCH}/makefile.aftersed -cat obj${BUILD_ALT_DIR}/${_BUILDARCH}/makefile.aftersed >> obj${BUILD_ALT_DIR}/${_BUILDARCH}/makefile.final - -if [ "$?" = "0" ] ; then - echo mdtool_gcc : dependencies generated - # replace old makefile by new one. - mv -f obj${BUILD_ALT_DIR}/${_BUILDARCH}/makefile.final obj${BUILD_ALT_DIR}/${_BUILDARCH}/makefile - rm -f obj${BUILD_ALT_DIR}/${_BUILDARCH}/makefile.aftersed - rm -f obj${BUILD_ALT_DIR}/${_BUILDARCH}/makefile.depfromgcc - exit 0 -fi -exit 1 - diff --git a/src/pal/src/cruntime/file.cpp b/src/pal/src/cruntime/file.cpp index 0eb2cea15..319c75550 100644 --- a/src/pal/src/cruntime/file.cpp +++ b/src/pal/src/cruntime/file.cpp @@ -23,9 +23,7 @@ Abstract: #include "pal/dbgmsg.h" #include "pal/file.h" #include "pal/cruntime.h" - #include "pal/thread.hpp" -#include "pal/threadsusp.hpp" #include #include @@ -284,10 +282,10 @@ PAL_fopen(const char * fileName, const char * mode) goto done; } - UnixFileName = PAL__strdup(fileName); + UnixFileName = strdup(fileName); if (UnixFileName == NULL ) { - ERROR("PAL__strdup() failed\n"); + ERROR("strdup() failed\n"); SetLastError(ERROR_NOT_ENOUGH_MEMORY); goto done; } diff --git a/src/pal/src/cruntime/malloc.cpp b/src/pal/src/cruntime/malloc.cpp index 3083a2005..922b8625a 100644 --- a/src/pal/src/cruntime/malloc.cpp +++ b/src/pal/src/cruntime/malloc.cpp @@ -105,12 +105,3 @@ CorUnix::InternalMalloc( pvMem = (void*)malloc(szSize); return pvMem; } - -char * -__cdecl -PAL__strdup( - const char *c_szStr - ) -{ - return strdup(c_szStr); -} \ No newline at end of file diff --git a/src/pal/src/cruntime/misc.cpp b/src/pal/src/cruntime/misc.cpp index 9e5acf65f..f2c9caeea 100644 --- a/src/pal/src/cruntime/misc.cpp +++ b/src/pal/src/cruntime/misc.cpp @@ -19,7 +19,6 @@ Abstract: --*/ #include "pal/thread.hpp" -#include "pal/threadsusp.hpp" #include "pal/palinternal.h" #include "pal/dbgmsg.h" #include "pal/misc.h" diff --git a/src/pal/src/cruntime/printf.cpp b/src/pal/src/cruntime/printf.cpp index 6ae6263b7..fb77a190e 100644 --- a/src/pal/src/cruntime/printf.cpp +++ b/src/pal/src/cruntime/printf.cpp @@ -24,7 +24,6 @@ Revision History: #include "pal/dbgmsg.h" #include "pal/cruntime.h" #include "pal/thread.hpp" -#include "pal/threadsusp.hpp" #include "pal/printfcpp.hpp" /* needs to be included after "palinternal.h" to avoid name diff --git a/src/pal/src/cruntime/thread.cpp b/src/pal/src/cruntime/thread.cpp index 6c96b1b51..bc88e16d1 100644 --- a/src/pal/src/cruntime/thread.cpp +++ b/src/pal/src/cruntime/thread.cpp @@ -25,19 +25,6 @@ Abstract: SET_DEFAULT_DEBUG_CHANNEL(CRT); -void -PAL_exit(int status) -{ - PERF_ENTRY(exit); - ENTRY ("exit(status=%d)\n", status); - - /* should also clean up any resources allocated by pal/cruntime, if any */ - ExitProcess(status); - - LOGEXIT ("exit returns void"); - PERF_EXIT(exit); -} - int PAL_atexit(void (__cdecl *function)(void)) { diff --git a/src/pal/src/cruntime/wchar.cpp b/src/pal/src/cruntime/wchar.cpp index c93a3d5ed..2e8724754 100644 --- a/src/pal/src/cruntime/wchar.cpp +++ b/src/pal/src/cruntime/wchar.cpp @@ -23,10 +23,7 @@ Abstract: #include "pal/cruntime.h" #include "pal/dbgmsg.h" #include "pal/unicode_data.h" - #include "pal/thread.hpp" -#include "pal/threadsusp.hpp" - #if HAVE_CONFIG_H #include "config.h" diff --git a/src/pal/src/debug/debug.cpp b/src/pal/src/debug/debug.cpp new file mode 100644 index 000000000..067086c80 --- /dev/null +++ b/src/pal/src/debug/debug.cpp @@ -0,0 +1,239 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +/*++ + + + +Module Name: + + debug.c + +Abstract: + + Implementation of Win32 debugging API functions. + +Revision History: + + + +--*/ + +#ifndef BIT64 +#undef _LARGEFILE64_SOURCE +#undef _FILE_OFFSET_BITS +#endif + +#include "pal/dbgmsg.h" +SET_DEFAULT_DEBUG_CHANNEL(DEBUG); // some headers have code with asserts, so do this first + +#include "pal/thread.hpp" +#include "pal/file.hpp" +#include "pal/palinternal.h" +#include "pal/process.h" +#include "pal/debug.h" +#include "pal/environ.h" +#include "pal/malloc.hpp" +#include "pal/module.h" +#include "pal/stackstring.hpp" +#include "pal/virtual.h" +#include "pal/utils.h" + +#include +#include +#include +#include +#include + +using namespace CorUnix; + +static const char PAL_OUTPUTDEBUGSTRING[] = "PAL_OUTPUTDEBUGSTRING"; + +extern "C" { + +/*++ +Function: + OutputDebugStringA + +See MSDN doc. +--*/ +VOID +PALAPI +OutputDebugStringA( + IN LPCSTR lpOutputString) +{ + PERF_ENTRY(OutputDebugStringA); + ENTRY("OutputDebugStringA (lpOutputString=%p (%s))\n", + lpOutputString ? lpOutputString : "NULL", + lpOutputString ? lpOutputString : "NULL"); + + // As we don't support debug events, we are going to output the debug string + // to stderr instead of generating OUT_DEBUG_STRING_EVENT. It's safe to tell + // EnvironGetenv not to make a copy of the value here since we only want to + // check whether it exists, not actually use it. + if ((lpOutputString != NULL) && + (NULL != EnvironGetenv(PAL_OUTPUTDEBUGSTRING, /* copyValue */ FALSE))) + { + fprintf(stderr, "%s", lpOutputString); + } + + LOGEXIT("OutputDebugStringA returns\n"); + PERF_EXIT(OutputDebugStringA); +} + +/*++ +Function: + OutputDebugStringW + +See MSDN doc. +--*/ +VOID +PALAPI +OutputDebugStringW( + IN LPCWSTR lpOutputString) +{ + CHAR *lpOutputStringA; + int strLen; + + PERF_ENTRY(OutputDebugStringW); + ENTRY("OutputDebugStringW (lpOutputString=%p (%S))\n", + lpOutputString ? lpOutputString: W16_NULLSTRING, + lpOutputString ? lpOutputString: W16_NULLSTRING); + + if (lpOutputString == NULL) + { + OutputDebugStringA(""); + goto EXIT; + } + + if ((strLen = WideCharToMultiByte(CP_ACP, 0, lpOutputString, -1, NULL, 0, + NULL, NULL)) + == 0) + { + ASSERT("failed to get wide chars length\n"); + SetLastError(ERROR_INTERNAL_ERROR); + goto EXIT; + } + + /* strLen includes the null terminator */ + if ((lpOutputStringA = (LPSTR) InternalMalloc((strLen * sizeof(CHAR)))) == NULL) + { + ERROR("Insufficient memory available !\n"); + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + goto EXIT; + } + + if(! WideCharToMultiByte(CP_ACP, 0, lpOutputString, -1, + lpOutputStringA, strLen, NULL, NULL)) + { + ASSERT("failed to convert wide chars to multibytes\n"); + SetLastError(ERROR_INTERNAL_ERROR); + free(lpOutputStringA); + goto EXIT; + } + + OutputDebugStringA(lpOutputStringA); + free(lpOutputStringA); + +EXIT: + LOGEXIT("OutputDebugStringW returns\n"); + PERF_EXIT(OutputDebugStringW); +} + +/*++ +Function: + DebugBreak + +See MSDN doc. +--*/ +VOID +PALAPI +DebugBreak( + VOID) +{ + PERF_ENTRY(DebugBreak); + ENTRY("DebugBreak()\n"); + + DBG_DebugBreak(); + + LOGEXIT("DebugBreak returns\n"); + PERF_EXIT(DebugBreak); +} + +/*++ +Function: + PAL_ProbeMemory + +Abstract + +Parameter + pBuffer : address of memory to validate + cbBuffer : size of memory region to validate + fWriteAccess : if true, validate writable access, else just readable. + +Return + true if memory is valid, false if not. +--*/ +BOOL +PALAPI +PAL_ProbeMemory( + PVOID pBuffer, + DWORD cbBuffer, + BOOL fWriteAccess) +{ + int fds[2]; + + if (pipe(fds) != 0) + { + ASSERT("pipe failed: errno is %d (%s)\n", errno, strerror(errno)); + return FALSE; + } + + fcntl(fds[0], O_NONBLOCK); + fcntl(fds[1], O_NONBLOCK); + + PVOID pEnd = (PBYTE)pBuffer + cbBuffer; + BOOL result = TRUE; + + // Validate the first byte in the buffer, then validate the first byte on each page after that. + while (pBuffer < pEnd) + { + int written = write(fds[1], pBuffer, 1); + if (written == -1) + { + if (errno != EFAULT) + { + ASSERT("write failed: errno is %d (%s)\n", errno, strerror(errno)); + } + result = FALSE; + break; + } + else + { + if (fWriteAccess) + { + int rd = read(fds[0], pBuffer, 1); + if (rd == -1) + { + if (errno != EFAULT) + { + ASSERT("read failed: errno is %d (%s)\n", errno, strerror(errno)); + } + result = FALSE; + break; + } + } + } + + // Round to the beginning of the next page + pBuffer = PVOID(ALIGN_DOWN((SIZE_T)pBuffer, GetVirtualPageSize()) + GetVirtualPageSize()); + } + + close(fds[0]); + close(fds[1]); + + return result; +} + +} // extern "C" diff --git a/src/pal/src/examples/CMakeLists.txt b/src/pal/src/examples/CMakeLists.txt deleted file mode 100644 index 3797d89b6..000000000 --- a/src/pal/src/examples/CMakeLists.txt +++ /dev/null @@ -1,18 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) -project(palexmpl) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - example1.cpp -) - -add_executable(palexmpl - ${SOURCES} -) - -add_dependencies(palexmpl coreclrpal) - -target_link_libraries(palexmpl - coreclrpal -) diff --git a/src/pal/src/examples/example1.cpp b/src/pal/src/examples/example1.cpp deleted file mode 100644 index 071f42e4f..000000000 --- a/src/pal/src/examples/example1.cpp +++ /dev/null @@ -1,49 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/* - - * - * Example of minimal program running under PAL. - * - * Run it using: - * export PAL_DBG_CHANNELS="+all.all" - * export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:.. - * ./example1 - * - * With the PAL_DEBUG_CHANNELS environment variable set as above you - * should see a trace output when the program runs. Setting - * LD_LIBRARY_PATH is necessary unless you have installed librotor_pal.so in - * a standard location. - * - * Build notes : - * Since the PAL uses pthreads, some options must be passed to gcc to tell it - * to link against thread-safe versions of the standard libraries. - * On FreeBSD, use gcc -pthread - * - */ - -#include -extern void *dlopen(const char *file, int mode); - -int main(int argc, char *argv[]) -{ - WCHAR src[4] = {'f', 'o', 'o', '\0'}; - WCHAR dest[4] = {'b', 'a', 'r', '\0'}; - WCHAR dir[5] = {'/', 't', 'm', 'p', '\0'}; - HANDLE h; - unsigned int b; - - PAL_Initialize(argc, (const char**)argv); - SetCurrentDirectoryW(dir); - SetCurrentDirectoryW(dir); - h = CreateFileW(src, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_NEW, 0, NULL); - WriteFile(h, "Testing\n", 8, &b, FALSE); - CloseHandle(h); - CopyFileW(src, dest, FALSE); - DeleteFileW(src); - PAL_Terminate(); - return 0; -} - diff --git a/src/pal/src/exception/machexception.cpp b/src/pal/src/exception/machexception.cpp deleted file mode 100644 index 5328e1f32..000000000 --- a/src/pal/src/exception/machexception.cpp +++ /dev/null @@ -1,1619 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*++ - -Module Name: - - machexception.cpp - -Abstract: - - Implementation of MACH exception API functions. - ---*/ - -#include "pal/dbgmsg.h" -SET_DEFAULT_DEBUG_CHANNEL(EXCEPT); // some headers have code with asserts, so do this first - -#include "pal/thread.hpp" -#include "pal/seh.hpp" -#include "pal/palinternal.h" -#if HAVE_MACH_EXCEPTIONS -#include "machexception.h" -#include "pal/critsect.h" -#include "pal/debug.h" -#include "pal/init.h" -#include "pal/utils.h" -#include "pal/context.h" -#include "pal/malloc.hpp" -#include "pal/process.h" -#include "pal/virtual.h" -#include "pal/map.hpp" -#include "pal/environ.h" - -#include "machmessage.h" - -#include -#include -#include -#include -#include -#include - -using namespace CorUnix; - -// The port we use to handle exceptions and to set the thread context -mach_port_t s_ExceptionPort; - -static BOOL s_DebugInitialized = FALSE; - -static DWORD s_PalInitializeFlags = 0; - -static const char * PAL_MACH_EXCEPTION_MODE = "PAL_MachExceptionMode"; - -// This struct is used to track the threads that need to have an exception forwarded -// to the next thread level port in the chain (if exists). An entry is added by the -// faulting sending a special message to the exception thread which saves it on an -// list that is searched when the restarted exception notification is received again. -struct ForwardedException -{ - ForwardedException *m_next; - thread_act_t Thread; - exception_type_t ExceptionType; - CPalThread *PalThread; -}; - -// The singly linked list and enumerator for the ForwardException struct -struct ForwardedExceptionList -{ -private: - ForwardedException *m_head; - ForwardedException *m_previous; - -public: - ForwardedException *Current; - - ForwardedExceptionList() - { - m_head = NULL; - MoveFirst(); - } - - void MoveFirst() - { - Current = m_head; - m_previous = NULL; - } - - bool IsEOL() - { - return Current == NULL; - } - - void MoveNext() - { - m_previous = Current; - Current = Current->m_next; - } - - void Add(ForwardedException *item) - { - item->m_next = m_head; - m_head = item; - } - - void Delete() - { - if (m_previous == NULL) - { - m_head = Current->m_next; - } - else - { - m_previous->m_next = Current->m_next; - } - free(Current); - - Current = m_head; - m_previous = NULL; - } -}; - -enum MachExceptionMode -{ - // special value to indicate we've not initialized yet - MachException_Uninitialized = -1, - - // These can be combined with bitwise OR to incrementally turn off - // functionality for diagnostics purposes. - // - // In practice, the following values are probably useful: - // 1: Don't turn illegal instructions into SEH exceptions. - // On Intel, stack misalignment usually shows up as an - // illegal instruction. PAL client code shouldn't - // expect to see any of these, so this option should - // always be safe to set. - // 2: Don't listen for breakpoint exceptions. This makes an - // SEH-based debugger (i.e., managed debugger) unusable, - // but you may need this option if you find that native - // breakpoints you set in PAL-dependent code don't work - // (causing hangs or crashes in the native debugger). - // 3: Combination of the above. - // This is the typical setting for development - // (unless you're working on the managed debugger). - // 7: In addition to the above, don't turn bad accesses and - // arithmetic exceptions into SEH. - // This is the typical setting for stress. - MachException_SuppressIllegal = 1, - MachException_SuppressDebugging = 2, - MachException_SuppressManaged = 4, - - // Default value to use if environment variable not set. - MachException_Default = 0, -}; - -/*++ -Function : - GetExceptionMask() - - Returns the mach exception mask for the exceptions to hook for a thread. - -Return value : - mach exception mask ---*/ -static -exception_mask_t -GetExceptionMask() -{ - static MachExceptionMode exMode = MachException_Uninitialized; - - if (exMode == MachException_Uninitialized) - { - exMode = MachException_Default; - - char* exceptionSettings = EnvironGetenv(PAL_MACH_EXCEPTION_MODE); - if (exceptionSettings) - { - exMode = (MachExceptionMode)atoi(exceptionSettings); - free(exceptionSettings); - } - else - { - if (PAL_IsDebuggerPresent()) - { - exMode = MachException_SuppressDebugging; - } - } - } - - exception_mask_t machExceptionMask = 0; - if (!(exMode & MachException_SuppressIllegal)) - { - machExceptionMask |= PAL_EXC_ILLEGAL_MASK; - } - if (!(exMode & MachException_SuppressDebugging) && (s_PalInitializeFlags & PAL_INITIALIZE_DEBUGGER_EXCEPTIONS)) - { -#ifdef FEATURE_PAL_SXS - // Always hook exception ports for breakpoint exceptions. - // The reason is that we don't know when a managed debugger - // will attach, so we have to be prepared. We don't want - // to later go through the thread list and hook exception - // ports for exactly those threads that currently are in - // this PAL. - machExceptionMask |= PAL_EXC_DEBUGGING_MASK; -#else // FEATURE_PAL_SXS - if (s_DebugInitialized) - { - machExceptionMask |= PAL_EXC_DEBUGGING_MASK; - } -#endif // FEATURE_PAL_SXS - } - if (!(exMode & MachException_SuppressManaged)) - { - machExceptionMask |= PAL_EXC_MANAGED_MASK; - } - - return machExceptionMask; -} - -#ifdef FEATURE_PAL_SXS - -/*++ -Function : - CPalThread::EnableMachExceptions - - Hook Mach exceptions, i.e., call thread_swap_exception_ports - to replace the thread's current exception ports with our own. - The previously active exception ports are saved. Called when - this thread enters a region of code that depends on this PAL. - -Return value : - ERROR_SUCCESS, if enabling succeeded - an error code, otherwise ---*/ -PAL_ERROR CorUnix::CPalThread::EnableMachExceptions() -{ - TRACE("%08X: Enter()\n", (unsigned int)(size_t)this); - - exception_mask_t machExceptionMask = GetExceptionMask(); - if (machExceptionMask != 0) - { -#ifdef _DEBUG - // verify that the arrays we've allocated to hold saved exception ports - // are the right size. - exception_mask_t countBits = PAL_EXC_ALL_MASK; - countBits = ((countBits & 0xAAAAAAAA) >> 1) + (countBits & 0x55555555); - countBits = ((countBits & 0xCCCCCCCC) >> 2) + (countBits & 0x33333333); - countBits = ((countBits & 0xF0F0F0F0) >> 4) + (countBits & 0x0F0F0F0F); - countBits = ((countBits & 0xFF00FF00) >> 8) + (countBits & 0x00FF00FF); - countBits = ((countBits & 0xFFFF0000) >> 16) + (countBits & 0x0000FFFF); - if (countBits != static_cast(CThreadMachExceptionHandlers::s_nPortsMax)) - { - ASSERT("s_nPortsMax is %u, but needs to be %u\n", - CThreadMachExceptionHandlers::s_nPortsMax, countBits); - } -#endif // _DEBUG - - NONPAL_TRACE("Enabling handlers for thread %08x exception mask %08x exception port %08x\n", - GetMachPortSelf(), machExceptionMask, s_ExceptionPort); - - CThreadMachExceptionHandlers *pSavedHandlers = GetSavedMachHandlers(); - - // Swap current handlers into temporary storage first. That's because it's possible (even likely) that - // some or all of the handlers might still be ours. In those cases we don't want to overwrite the - // chain-back entries with these useless self-references. - kern_return_t machret; - kern_return_t machretDeallocate; - thread_port_t thread = mach_thread_self(); - - machret = thread_swap_exception_ports( - thread, - machExceptionMask, - s_ExceptionPort, - EXCEPTION_DEFAULT | MACH_EXCEPTION_CODES, - THREAD_STATE_NONE, - pSavedHandlers->m_masks, - &pSavedHandlers->m_nPorts, - pSavedHandlers->m_handlers, - pSavedHandlers->m_behaviors, - pSavedHandlers->m_flavors); - - machretDeallocate = mach_port_deallocate(mach_task_self(), thread); - CHECK_MACH("mach_port_deallocate", machretDeallocate); - - if (machret != KERN_SUCCESS) - { - ASSERT("thread_swap_exception_ports failed: %d %s\n", machret, mach_error_string(machret)); - return UTIL_MachErrorToPalError(machret); - } - -#ifdef _DEBUG - NONPAL_TRACE("EnableMachExceptions: THREAD PORT count %d\n", pSavedHandlers->m_nPorts); - for (mach_msg_type_number_t i = 0; i < pSavedHandlers->m_nPorts; i++) - { - _ASSERTE(pSavedHandlers->m_handlers[i] != s_ExceptionPort); - NONPAL_TRACE("EnableMachExceptions: THREAD PORT mask %08x handler: %08x behavior %08x flavor %u\n", - pSavedHandlers->m_masks[i], - pSavedHandlers->m_handlers[i], - pSavedHandlers->m_behaviors[i], - pSavedHandlers->m_flavors[i]); - } -#endif // _DEBUG - } - return ERROR_SUCCESS; -} - -/*++ -Function : - CPalThread::DisableMachExceptions - - Unhook Mach exceptions, i.e., call thread_set_exception_ports - to restore the thread's exception ports with those we saved - in EnableMachExceptions. Called when this thread leaves a - region of code that depends on this PAL. - -Return value : - ERROR_SUCCESS, if disabling succeeded - an error code, otherwise ---*/ -PAL_ERROR CorUnix::CPalThread::DisableMachExceptions() -{ - TRACE("%08X: Leave()\n", (unsigned int)(size_t)this); - - PAL_ERROR palError = NO_ERROR; - - // We only store exceptions when we're installing exceptions. - if (0 == GetExceptionMask()) - return palError; - - // Get the handlers to restore. - CThreadMachExceptionHandlers *savedPorts = GetSavedMachHandlers(); - - kern_return_t MachRet = KERN_SUCCESS; - for (int i = 0; i < savedPorts->m_nPorts; i++) - { - // If no handler was ever set, thread_swap_exception_ports returns - // MACH_PORT_NULL for the handler and zero values for behavior - // and flavor. Unfortunately, the latter are invalid even for - // MACH_PORT_NULL when you use thread_set_exception_ports. - exception_behavior_t behavior = savedPorts->m_behaviors[i] ? savedPorts->m_behaviors[i] : EXCEPTION_DEFAULT; - thread_state_flavor_t flavor = savedPorts->m_flavors[i] ? savedPorts->m_flavors[i] : MACHINE_THREAD_STATE; - thread_port_t thread = mach_thread_self(); - MachRet = thread_set_exception_ports(thread, - savedPorts->m_masks[i], - savedPorts->m_handlers[i], - behavior, - flavor); - - kern_return_t MachRetDeallocate = mach_port_deallocate(mach_task_self(), thread); - CHECK_MACH("mach_port_deallocate", MachRetDeallocate); - - if (MachRet != KERN_SUCCESS) - break; - } - - if (MachRet != KERN_SUCCESS) - { - ASSERT("thread_set_exception_ports failed: %d\n", MachRet); - palError = UTIL_MachErrorToPalError(MachRet); - } - - return palError; -} - -#else // FEATURE_PAL_SXS - -/*++ -Function : - SEHEnableMachExceptions - - Enable SEH-related stuff related to mach exceptions - - (no parameters) - -Return value : - TRUE if enabling succeeded - FALSE otherwise ---*/ -BOOL SEHEnableMachExceptions() -{ - exception_mask_t machExceptionMask = GetExceptionMask(); - if (machExceptionMask != 0) - { - kern_return_t MachRet; - MachRet = task_set_exception_ports(mach_task_self(), - machExceptionMask, - s_ExceptionPort, - EXCEPTION_DEFAULT, - MACHINE_THREAD_STATE); - - if (MachRet != KERN_SUCCESS) - { - ASSERT("task_set_exception_ports failed: %d\n", MachRet); - UTIL_SetLastErrorFromMach(MachRet); - return FALSE; - } - } - return TRUE; -} - -/*++ -Function : - SEHDisableMachExceptions - - Disable SEH-related stuff related to mach exceptions - - (no parameters) - -Return value : - TRUE if enabling succeeded - FALSE otherwise ---*/ -BOOL SEHDisableMachExceptions() -{ - exception_mask_t machExceptionMask = GetExceptionMask(); - if (machExceptionMask != 0) - { - kern_return_t MachRet; - MachRet = task_set_exception_ports(mach_task_self(), - machExceptionMask, - MACH_PORT_NULL, - EXCEPTION_DEFAULT, - MACHINE_THREAD_STATE); - - if (MachRet != KERN_SUCCESS) - { - ASSERT("task_set_exception_ports failed: %d\n", MachRet); - UTIL_SetLastErrorFromMach(MachRet); - return FALSE; - } - } - return TRUE; -} - -#endif // FEATURE_PAL_SXS - -#if !defined(_AMD64_) -extern "C" -void PAL_DispatchException(PCONTEXT pContext, PEXCEPTION_RECORD pExRecord, MachExceptionInfo *pMachExceptionInfo) -#else // defined(_AMD64_) - -// Since HijackFaultingThread pushed the context, exception record and info on the stack, we need to adjust the -// signature of PAL_DispatchException such that the corresponding arguments are considered to be on the stack -// per GCC64 calling convention rules. Hence, the first 6 dummy arguments (corresponding to RDI, RSI, RDX,RCX, R8, R9). -extern "C" -void PAL_DispatchException(DWORD64 dwRDI, DWORD64 dwRSI, DWORD64 dwRDX, DWORD64 dwRCX, DWORD64 dwR8, DWORD64 dwR9, PCONTEXT pContext, PEXCEPTION_RECORD pExRecord, MachExceptionInfo *pMachExceptionInfo) -#endif // !defined(_AMD64_) -{ - CPalThread *pThread = InternalGetCurrentThread(); - -#if FEATURE_PAL_SXS - if (!pThread->IsInPal()) - { - // It's now possible to observe system exceptions in code running outside the PAL (as the result of a - // p/invoke since we no longer revert our Mach exception ports in this case). In that scenario we need - // to re-enter the PAL now as the exception signals the end of the p/invoke. - PAL_Reenter(PAL_BoundaryBottom); - } -#endif // FEATURE_PAL_SXS - - CONTEXT *contextRecord; - EXCEPTION_RECORD *exceptionRecord; - AllocateExceptionRecords(&exceptionRecord, &contextRecord); - - *contextRecord = *pContext; - *exceptionRecord = *pExRecord; - - contextRecord->ContextFlags |= CONTEXT_EXCEPTION_ACTIVE; - bool continueExecution; - - { - // The exception object takes ownership of the exceptionRecord and contextRecord - PAL_SEHException exception(exceptionRecord, contextRecord); - - TRACE("PAL_DispatchException(EC %08x EA %p)\n", pExRecord->ExceptionCode, pExRecord->ExceptionAddress); - - continueExecution = SEHProcessException(&exception); - if (continueExecution) - { - // Make a copy of the exception records so that we can free them before restoring the context - *pContext = *contextRecord; - *pExRecord = *exceptionRecord; - } - - // The exception records are destroyed by the PAL_SEHException destructor now. - } - - if (continueExecution) - { - RtlRestoreContext(pContext, pExRecord); - } - - // Send the forward request to the exception thread to process - MachMessage sSendMessage; - sSendMessage.SendForwardException(s_ExceptionPort, pMachExceptionInfo, pThread); - - // Spin wait until this thread is hijacked by the exception thread - while (TRUE) - { - sched_yield(); - } -} - -#if defined(_X86_) || defined(_AMD64_) -extern "C" void PAL_DispatchExceptionWrapper(); -extern "C" int PAL_DispatchExceptionReturnOffset; -#endif // _X86_ || _AMD64_ - -/*++ -Function : - BuildExceptionRecord - - Sets up up an ExceptionRecord from an exception message - -Parameters : - exceptionInfo - exception info to build the exception record - pExceptionRecord - exception record to setup -*/ -static -void -BuildExceptionRecord( - MachExceptionInfo& exceptionInfo, // [in] exception info - EXCEPTION_RECORD *pExceptionRecord) // [out] Used to return exception parameters -{ - memset(pExceptionRecord, 0, sizeof(EXCEPTION_RECORD)); - - DWORD exceptionCode = EXCEPTION_ILLEGAL_INSTRUCTION; - - switch(exceptionInfo.ExceptionType) - { - // Could not access memory. subcode contains the bad memory address. - case EXC_BAD_ACCESS: - if (exceptionInfo.SubcodeCount != 2) - { - NONPAL_RETAIL_ASSERT("Got an unexpected subcode"); - exceptionCode = EXCEPTION_ILLEGAL_INSTRUCTION; - } - else - { - exceptionCode = EXCEPTION_ACCESS_VIOLATION; - - pExceptionRecord->NumberParameters = 2; - pExceptionRecord->ExceptionInformation[0] = 0; - pExceptionRecord->ExceptionInformation[1] = exceptionInfo.Subcodes[1]; - NONPAL_TRACE("subcodes[1] = %llx\n", exceptionInfo.Subcodes[1]); - } - break; - - // Instruction failed. Illegal or undefined instruction or operand. - case EXC_BAD_INSTRUCTION : - // TODO: Identify privileged instruction. Need to get the thread state and read the machine code. May - // be better to do this in the place that calls SEHProcessException, similar to how it's done on Linux. - exceptionCode = EXCEPTION_ILLEGAL_INSTRUCTION; - break; - - // Arithmetic exception; exact nature of exception is in subcode field. - case EXC_ARITHMETIC: - if (exceptionInfo.SubcodeCount != 2) - { - NONPAL_RETAIL_ASSERT("Got an unexpected subcode"); - exceptionCode = EXCEPTION_ILLEGAL_INSTRUCTION; - } - else - { - switch (exceptionInfo.Subcodes[0]) - { -#if defined(_X86_) || defined(_AMD64_) - case EXC_I386_DIV: - exceptionCode = EXCEPTION_INT_DIVIDE_BY_ZERO; - break; - case EXC_I386_INTO: - exceptionCode = EXCEPTION_INT_OVERFLOW; - break; - case EXC_I386_EXTOVR: - exceptionCode = EXCEPTION_FLT_OVERFLOW; - break; - case EXC_I386_BOUND: - exceptionCode = EXCEPTION_ARRAY_BOUNDS_EXCEEDED; - break; -#else -#error Trap code to exception mapping not defined for this architecture -#endif - default: - exceptionCode = EXCEPTION_ILLEGAL_INSTRUCTION; - break; - } - } - break; - - case EXC_SOFTWARE: -#if defined(_X86_) || defined(_AMD64_) - exceptionCode = EXCEPTION_ILLEGAL_INSTRUCTION; - break; -#else -#error Trap code to exception mapping not defined for this architecture -#endif - - // Trace, breakpoint, etc. Details in subcode field. - case EXC_BREAKPOINT: -#if defined(_X86_) || defined(_AMD64_) - if (exceptionInfo.Subcodes[0] == EXC_I386_SGL) - { - exceptionCode = EXCEPTION_SINGLE_STEP; - } - else if (exceptionInfo.Subcodes[0] == EXC_I386_BPT) - { - exceptionCode = EXCEPTION_BREAKPOINT; - } -#else -#error Trap code to exception mapping not defined for this architecture -#endif - else - { - WARN("unexpected subcode %d for EXC_BREAKPOINT", exceptionInfo.Subcodes[0]); - exceptionCode = EXCEPTION_BREAKPOINT; - } - break; - - - // System call requested. Details in subcode field. - case EXC_SYSCALL: - exceptionCode = EXCEPTION_ILLEGAL_INSTRUCTION; - break; - - // System call with a number in the Mach call range requested. Details in subcode field. - case EXC_MACH_SYSCALL: - exceptionCode = EXCEPTION_ILLEGAL_INSTRUCTION; - break; - - default: - NONPAL_ASSERT("Got unknown trap code %d\n", exceptionInfo.ExceptionType); - break; - } - - pExceptionRecord->ExceptionCode = exceptionCode; -} - -#ifdef _DEBUG -const char * -GetExceptionString( - exception_type_t exception -) -{ - switch(exception) - { - case EXC_BAD_ACCESS: - return "EXC_BAD_ACCESS"; - - case EXC_BAD_INSTRUCTION: - return "EXC_BAD_INSTRUCTION"; - - case EXC_ARITHMETIC: - return "EXC_ARITHMETIC"; - - case EXC_SOFTWARE: - return "EXC_SOFTWARE"; - - case EXC_BREAKPOINT: - return "EXC_BREAKPOINT"; - - case EXC_SYSCALL: - return "EXC_SYSCALL"; - - case EXC_MACH_SYSCALL: - return "EXC_MACH_SYSCALL"; - - default: - NONPAL_ASSERT("Got unknown trap code %d\n", exception); - break; - } - return "INVALID CODE"; -} -#endif // _DEBUG - -/*++ -Function : - HijackFaultingThread - - Sets the faulting thread up to return to PAL_DispatchException with an - ExceptionRecord and thread CONTEXT. - -Parameters: - thread - thread the exception happened - task - task the exception happened - message - exception message - -Return value : - None ---*/ -static -void -HijackFaultingThread( - mach_port_t thread, // [in] thread the exception happened on - mach_port_t task, // [in] task the exception happened on - MachMessage& message) // [in] exception message -{ - MachExceptionInfo exceptionInfo(thread, message); - EXCEPTION_RECORD exceptionRecord; - CONTEXT threadContext; - kern_return_t machret; - - // Fill in the exception record from the exception info - BuildExceptionRecord(exceptionInfo, &exceptionRecord); - -#ifdef _X86_ - threadContext.ContextFlags = CONTEXT_FLOATING_POINT | CONTEXT_EXTENDED_REGISTERS; -#else - threadContext.ContextFlags = CONTEXT_FLOATING_POINT; -#endif - CONTEXT_GetThreadContextFromThreadState(x86_FLOAT_STATE, (thread_state_t)&exceptionInfo.FloatState, &threadContext); - - threadContext.ContextFlags |= CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS; - CONTEXT_GetThreadContextFromThreadState(x86_THREAD_STATE, (thread_state_t)&exceptionInfo.ThreadState, &threadContext); - -#if defined(CORECLR) && (defined(_X86_) || defined(_AMD64_)) - // For CoreCLR we look more deeply at access violations to determine whether they're the result of a stack - // overflow. If so we'll terminate the process immediately (the current default policy of the CoreCLR EE). - // Otherwise we'll either A/V ourselves trying to set up the SEH exception record and context on the - // target thread's stack (unlike Windows there's no extra stack reservation to guarantee this can be done) - // or, and this the case we're trying to avoid, it's possible we'll succeed and the runtime will go ahead - // and process the SO like it was a simple AV. Since the runtime doesn't currently implement stack probing - // on non-Windows platforms, this could lead to data corruption (we have SO intolerant code in the runtime - // which manipulates global state under the assumption that an SO cannot occur due to a prior stack - // probe). - - // Determining whether an AV is really an SO is not quite straightforward. We can get stack bounds - // information from pthreads but (a) we only have the target Mach thread port and no way to map to a - // pthread easily and (b) the pthread functions lie about the bounds on the main thread. - - // Instead we inspect the target thread SP we just retrieved above and compare it with the AV address. If - // they both lie in the same page or the SP is at a higher address than the AV but in the same VM region, - // then we'll consider the AV to be an SO. Note that we can't assume that SP will be in the same page as - // the AV on an SO, even though we force GCC to generate stack probes on stack extension (-fstack-check). - // That's because GCC currently generates the probe *before* altering SP. Since a given stack extension can - // involve multiple pages and GCC generates all the required probes before updating SP in a single - // operation, the faulting probe can be at an address that is far removed from the thread's current value - // of SP. - - // In the case where the AV and SP aren't in the same or adjacent pages we check if the first page - // following the faulting address belongs in the same VM region as the current value of SP. Since all pages - // in a VM region have the same attributes this check eliminates the possibility that there's another guard - // page in the range between the fault and the SP, effectively establishing that the AV occurred in the - // guard page associated with the stack associated with the SP. - - // We are assuming here that thread stacks are always allocated in a single VM region. I've seen no - // evidence thus far that this is not the case (and the mere fact we rely on Mach apis already puts us on - // brittle ground anyway). - - // (a) SP always marks the current limit of the stack (in that all valid stack accesses will be of - // the form [SP + delta]). The Mac x86 ABI appears to guarantee this (or rather it does not - // guarantee that stack slots below SP will not be invalidated by asynchronous events such as - // interrupts, which mostly amounts to the same thing for user mode code). Note that the Mac PPC - // ABI does allow some (constrained) access below SP, but we're not currently supporting this - // platform. - // (b) All code will extend the stack "carefully" (by which we mean that stack extensions of more - // than one page in size will touch at least one byte in each intervening page (in decreasing - // address order), to guarantee that the guard page is hit before memory beyond the guard page is - // corrupted). Our managed jits always generate code which does this as does MSVC. GCC, however, - // does not do this by default. We have to explicitly provide the -fstack-check compiler option - // to enable the behavior. -#if (defined(_X86_) || defined(_AMD64_)) && defined(__APPLE__) - if (exceptionRecord.ExceptionCode == EXCEPTION_ACCESS_VIOLATION) - { - // Assume this AV isn't an SO to begin with. - bool fIsStackOverflow = false; - - // Calculate the page base addresses for the fault and the faulting thread's SP. - int cbPage = getpagesize(); - char *pFaultPage = (char*)(exceptionRecord.ExceptionInformation[1] & ~(cbPage - 1)); -#ifdef _X86_ - char *pStackTopPage = (char*)(threadContext.Esp & ~(cbPage - 1)); -#elif defined(_AMD64_) - char *pStackTopPage = (char*)(threadContext.Rsp & ~(cbPage - 1)); -#endif - - if (pFaultPage == pStackTopPage || pFaultPage == (pStackTopPage - cbPage)) - { - // The easy case is when the AV occurred in the same or adjacent page as the stack pointer. - fIsStackOverflow = true; - } - else if (pFaultPage < pStackTopPage) - { - // Calculate the address of the page immediately following the fault and check that it - // lies in the same VM region as the stack pointer. - vm_address_t vm_address; - vm_size_t vm_size; - vm_region_flavor_t vm_flavor; - mach_msg_type_number_t infoCnt; -#ifdef BIT64 - vm_region_basic_info_data_64_t info; - infoCnt = VM_REGION_BASIC_INFO_COUNT_64; - vm_flavor = VM_REGION_BASIC_INFO_64; -#else - vm_region_basic_info_data_t info; - infoCnt = VM_REGION_BASIC_INFO_COUNT; - vm_flavor = VM_REGION_BASIC_INFO; -#endif - mach_port_t object_name; - - vm_address = (vm_address_t)(pFaultPage + cbPage); - -#ifdef BIT64 - machret = vm_region_64( -#else - machret = vm_region( -#endif - mach_task_self(), - &vm_address, - &vm_size, - vm_flavor, - (vm_region_info_t)&info, - &infoCnt, - &object_name); -#ifdef _X86_ - CHECK_MACH("vm_region", machret); -#elif defined(_AMD64_) - CHECK_MACH("vm_region_64", machret); -#endif - - // If vm_region updated the address we gave it then that address was not part of a region at all - // (and so this cannot be an SO). Otherwise check that the ESP lies in the region returned. - char *pRegionStart = (char*)vm_address; - char *pRegionEnd = (char*)vm_address + vm_size; - if (pRegionStart == (pFaultPage + cbPage) && pStackTopPage < pRegionEnd) - fIsStackOverflow = true; - } - -#if defined(_AMD64_) - if (!fIsStackOverflow) - { - // Check if we can read pointer sizeD bytes below the target thread's stack pointer. - // If we are unable to, then it implies we have run into SO. - void **targetSP = (void **)threadContext.Rsp; - vm_address_t targetAddr = (mach_vm_address_t)(targetSP); - targetAddr -= sizeof(void *); - vm_size_t vm_size = sizeof(void *); - char arr[8]; - vm_size_t data_count = 8; - machret = vm_read_overwrite(mach_task_self(), targetAddr, vm_size, (pointer_t)arr, &data_count); - if (machret == KERN_INVALID_ADDRESS) - { - fIsStackOverflow = true; - } - } -#endif // _AMD64_ - - if (fIsStackOverflow) - { - // We have a stack overflow. Abort the process immediately. It would be nice to let the VM do this - // but the Windows mechanism (where a stack overflow SEH exception is delivered on the faulting - // thread) will not work most of the time since non-Windows OSs don't keep a reserve stack - // extension allocated for this purpose. - - // TODO: Once our event reporting story is further along we probably want to report something - // here. If our runtime policy for SO ever changes (the most likely candidate being "unload - // appdomain on SO) then we'll have to do something more complex here, probably involving a - // handshake with the runtime in order to report the SO without attempting to extend the faulting - // thread's stack any further. Note that we cannot call most PAL functions from the context of - // this thread since we're not a PAL thread. - - write(STDERR_FILENO, StackOverflowMessage, sizeof(StackOverflowMessage) - 1); - abort(); - } - } -#else // (_X86_ || _AMD64_) && __APPLE__ -#error Platform not supported for correct stack overflow handling -#endif // (_X86_ || _AMD64_) && __APPLE__ -#endif // CORECLR && _X86_ - -#if defined(_X86_) - NONPAL_ASSERTE(exceptionInfo.ThreadState.tsh.flavor == x86_THREAD_STATE32); - - // Make a copy of the thread state because the one in exceptionInfo needs to be preserved to restore - // the state if the exception is forwarded. - x86_thread_state32_t ts32 = exceptionInfo.ThreadState.uts.ts32; - - // If we're in single step mode, disable it since we're going to call PAL_DispatchException - if (exceptionRecord.ExceptionCode == EXCEPTION_SINGLE_STEP) - { - ts32.eflags &= ~EFL_TF; - } - - exceptionRecord.ExceptionFlags = EXCEPTION_IS_SIGNAL; - exceptionRecord.ExceptionRecord = NULL; - exceptionRecord.ExceptionAddress = (void *)ts32.eip; - - void **FramePointer = (void **)ts32.esp; - - *--FramePointer = (void *)ts32.eip; - - // Construct a stack frame for a pretend activation of the function - // PAL_DispatchExceptionWrapper that serves only to make the stack - // correctly unwindable by the system exception unwinder. - // PAL_DispatchExceptionWrapper has an ebp frame, its local variables - // are the context and exception record, and it has just "called" - // PAL_DispatchException. - *--FramePointer = (void *)ts32.ebp; - ts32.ebp = (unsigned)FramePointer; - - // Put the context on the stack - FramePointer = (void **)((ULONG_PTR)FramePointer - sizeof(CONTEXT)); - // Make sure it's aligned - CONTEXT has 8-byte alignment - FramePointer = (void **)((ULONG_PTR)FramePointer - ((ULONG_PTR)FramePointer % 8)); - CONTEXT *pContext = (CONTEXT *)FramePointer; - *pContext = threadContext; - - // Put the exception record on the stack - FramePointer = (void **)((ULONG_PTR)FramePointer - sizeof(EXCEPTION_RECORD)); - EXCEPTION_RECORD *pExceptionRecord = (EXCEPTION_RECORD *)FramePointer; - *pExceptionRecord = exceptionRecord; - - FramePointer = (void **)((ULONG_PTR)FramePointer - sizeof(MachExceptionInfo)); - MachExceptionInfo *pMachExceptionInfo = (MachExceptionInfo *)FramePointer; - *pMachExceptionInfo = exceptionInfo; - - // Push arguments to PAL_DispatchException - FramePointer = (void **)((ULONG_PTR)FramePointer - 3 * sizeof(void *)); - - // Make sure it's aligned - ABI requires 16-byte alignment - FramePointer = (void **)((ULONG_PTR)FramePointer - ((ULONG_PTR)FramePointer % 16)); - FramePointer[0] = pContext; - FramePointer[1] = pExceptionRecord; - FramePointer[2] = pMachExceptionInfo; - - // Place the return address to right after the fake call in PAL_DispatchExceptionWrapper - FramePointer[-1] = (void *)((ULONG_PTR)PAL_DispatchExceptionWrapper + PAL_DispatchExceptionReturnOffset); - - // Make the instruction register point to DispatchException - ts32.eip = (unsigned)PAL_DispatchException; - ts32.esp = (unsigned)&FramePointer[-1]; // skip return address - - // Now set the thread state for the faulting thread so that PAL_DispatchException executes next - machret = thread_set_state(thread, x86_THREAD_STATE32, (thread_state_t)&ts32, x86_THREAD_STATE32_COUNT); - CHECK_MACH("thread_set_state(thread)", machret); -#elif defined(_AMD64_) - NONPAL_ASSERTE(exceptionInfo.ThreadState.tsh.flavor == x86_THREAD_STATE64); - - // Make a copy of the thread state because the one in exceptionInfo needs to be preserved to restore - // the state if the exception is forwarded. - x86_thread_state64_t ts64 = exceptionInfo.ThreadState.uts.ts64; - - // If we're in single step mode, disable it since we're going to call PAL_DispatchException - if (exceptionRecord.ExceptionCode == EXCEPTION_SINGLE_STEP) - { - ts64.__rflags &= ~EFL_TF; - } - - exceptionRecord.ExceptionFlags = EXCEPTION_IS_SIGNAL; - exceptionRecord.ExceptionRecord = NULL; - exceptionRecord.ExceptionAddress = (void *)ts64.__rip; - - void **FramePointer = (void **)ts64.__rsp; - - *--FramePointer = (void *)ts64.__rip; - - // Construct a stack frame for a pretend activation of the function - // PAL_DispatchExceptionWrapper that serves only to make the stack - // correctly unwindable by the system exception unwinder. - // PAL_DispatchExceptionWrapper has an ebp frame, its local variables - // are the context and exception record, and it has just "called" - // PAL_DispatchException. - *--FramePointer = (void *)ts64.__rbp; - ts64.__rbp = (SIZE_T)FramePointer; - - // Put the context on the stack - FramePointer = (void **)((ULONG_PTR)FramePointer - sizeof(CONTEXT)); - // Make sure it's aligned - CONTEXT has 16-byte alignment - FramePointer = (void **)((ULONG_PTR)FramePointer - ((ULONG_PTR)FramePointer % 16)); - CONTEXT *pContext = (CONTEXT *)FramePointer; - *pContext = threadContext; - - // Put the exception record on the stack - FramePointer = (void **)((ULONG_PTR)FramePointer - sizeof(EXCEPTION_RECORD)); - EXCEPTION_RECORD *pExceptionRecord = (EXCEPTION_RECORD *)FramePointer; - *pExceptionRecord = exceptionRecord; - - FramePointer = (void **)((ULONG_PTR)FramePointer - sizeof(MachExceptionInfo)); - MachExceptionInfo *pMachExceptionInfo = (MachExceptionInfo *)FramePointer; - *pMachExceptionInfo = exceptionInfo; - - // Push arguments to PAL_DispatchException - FramePointer = (void **)((ULONG_PTR)FramePointer - 3 * sizeof(void *)); - - // Make sure it's aligned - ABI requires 16-byte alignment - FramePointer = (void **)((ULONG_PTR)FramePointer - ((ULONG_PTR)FramePointer % 16)); - FramePointer[0] = pContext; - FramePointer[1] = pExceptionRecord; - FramePointer[2] = pMachExceptionInfo; - - // Place the return address to right after the fake call in PAL_DispatchExceptionWrapper - FramePointer[-1] = (void *)((ULONG_PTR)PAL_DispatchExceptionWrapper + PAL_DispatchExceptionReturnOffset); - - // Make the instruction register point to DispatchException - ts64.__rip = (SIZE_T)PAL_DispatchException; - ts64.__rsp = (SIZE_T)&FramePointer[-1]; // skip return address - - // Now set the thread state for the faulting thread so that PAL_DispatchException executes next - machret = thread_set_state(thread, x86_THREAD_STATE64, (thread_state_t)&ts64, x86_THREAD_STATE64_COUNT); - CHECK_MACH("thread_set_state(thread)", machret); -#else -#error HijackFaultingThread not defined for this architecture -#endif -} - -/*++ -Function : - SuspendMachThread - - Suspend the specified thread. - -Parameters: - thread - mach thread port - -Return value : - None ---*/ -static -void -SuspendMachThread(thread_act_t thread) -{ - kern_return_t machret; - - while (true) - { - machret = thread_suspend(thread); - CHECK_MACH("thread_suspend", machret); - - // Ensure that if the thread was running in the kernel, the kernel operation - // is safely aborted so that it can be restarted later. - machret = thread_abort_safely(thread); - if (machret == KERN_SUCCESS) - { - break; - } - - // The thread was running in the kernel executing a non-atomic operation - // that cannot be restarted, so we need to resume the thread and retry - machret = thread_resume(thread); - CHECK_MACH("thread_resume", machret); - } -} - -/*++ -Function : - SEHExceptionThread - - Entry point for the thread that will listen for exception in any other thread. - -#ifdef FEATURE_PAL_SXS - NOTE: This thread is not a PAL thread, and it must not be one. If it was, - exceptions on this thread would be delivered to the port this thread itself - is listening on. - - In particular, if another thread overflows its stack, the exception handling - thread receives a message. It will try to create a PAL_DispatchException - frame on the faulting thread, which will likely fault. If the exception - processing thread is not a PAL thread, the process gets terminated with a - bus error; if the exception processing thread was a PAL thread, we would see - a hang (since no thread is listening for the exception message that gets sent). - Of the two ugly behaviors, the bus error is definitely favorable. - - This means: no printf, no TRACE, no PAL allocation, no ExitProcess, - no LastError in this function and its helpers. To report fatal failure, - use NONPAL_RETAIL_ASSERT. -#endif // FEATURE_PAL_SXS - -Parameters : - void *args - not used - -Return value : - Never returns ---*/ -void * -SEHExceptionThread(void *args) -{ - ForwardedExceptionList feList; - MachMessage sReplyOrForward; - MachMessage sMessage; - kern_return_t machret; - thread_act_t thread; - - // Loop processing incoming messages forever. - while (true) - { - // Receive the next message. - sMessage.Receive(s_ExceptionPort); - - NONPAL_TRACE("Received message %s (%08x) from (remote) %08x to (local) %08x\n", - sMessage.GetMessageTypeName(), - sMessage.GetMessageType(), - sMessage.GetRemotePort(), - sMessage.GetLocalPort()); - - if (sMessage.IsSetThreadRequest()) - { - // Handle a request to set the thread context for the specified target thread. - CONTEXT sContext; - thread = sMessage.GetThreadContext(&sContext); - - // Suspend the target thread - SuspendMachThread(thread); - - machret = CONTEXT_SetThreadContextOnPort(thread, &sContext); - CHECK_MACH("CONTEXT_SetThreadContextOnPort", machret); - - machret = thread_resume(thread); - CHECK_MACH("thread_resume", machret); - } - else if (sMessage.IsExceptionNotification()) - { - // This is a notification of an exception occurring on another thread. - exception_type_t exceptionType = sMessage.GetException(); - thread = sMessage.GetThread(); - -#ifdef _DEBUG - if (NONPAL_TRACE_ENABLED) - { - NONPAL_TRACE("ExceptionNotification %s (%u) thread %08x flavor %u\n", - GetExceptionString(exceptionType), - exceptionType, - thread, - sMessage.GetThreadStateFlavor()); - - int subcode_count = sMessage.GetExceptionCodeCount(); - for (int i = 0; i < subcode_count; i++) - NONPAL_TRACE("ExceptionNotification subcode[%d] = %llx\n", i, sMessage.GetExceptionCode(i)); - - x86_thread_state64_t threadStateActual; - unsigned int count = sizeof(threadStateActual) / sizeof(unsigned); - machret = thread_get_state(thread, x86_THREAD_STATE64, (thread_state_t)&threadStateActual, &count); - CHECK_MACH("thread_get_state", machret); - - NONPAL_TRACE("ExceptionNotification actual rip %016llx rsp %016llx rbp %016llx rax %016llx r15 %016llx eflags %08llx\n", - threadStateActual.__rip, - threadStateActual.__rsp, - threadStateActual.__rbp, - threadStateActual.__rax, - threadStateActual.__r15, - threadStateActual.__rflags); - - x86_exception_state64_t threadExceptionState; - unsigned int ehStateCount = sizeof(threadExceptionState) / sizeof(unsigned); - machret = thread_get_state(thread, x86_EXCEPTION_STATE64, (thread_state_t)&threadExceptionState, &ehStateCount); - CHECK_MACH("thread_get_state", machret); - - NONPAL_TRACE("ExceptionNotification trapno %04x cpu %04x err %08x faultAddr %016llx\n", - threadExceptionState.__trapno, - threadExceptionState.__cpu, - threadExceptionState.__err, - threadExceptionState.__faultvaddr); - } -#endif // _DEBUG - - bool feFound = false; - feList.MoveFirst(); - - while (!feList.IsEOL()) - { - mach_port_type_t ePortType; - if (mach_port_type(mach_task_self(), feList.Current->Thread, &ePortType) != KERN_SUCCESS || (ePortType & MACH_PORT_TYPE_DEAD_NAME)) - { - NONPAL_TRACE("Forwarded exception: invalid thread port %08x\n", feList.Current->Thread); - - // Unlink and delete the forwarded exception instance - feList.Delete(); - } - else - { - if (feList.Current->Thread == thread) - { - bool isSameException = feList.Current->ExceptionType == exceptionType; - feFound = true; - - // Locate the record of previously installed handlers that the target thread keeps. - CThreadMachExceptionHandlers *pHandlers = feList.Current->PalThread->GetSavedMachHandlers(); - - // Unlink and delete the forwarded exception instance - feList.Delete(); - - // Check if the current exception type matches the forwarded one and whether - // there's a handler for the particular exception we've been handed. - MachExceptionHandler sHandler; - if (isSameException && pHandlers->GetHandler(exceptionType, &sHandler)) - { - NONPAL_TRACE("ForwardNotification thread %08x to handler %08x\n", thread, sHandler.m_handler); - sReplyOrForward.ForwardNotification(&sHandler, sMessage); - } - else - { - NONPAL_TRACE("ReplyToNotification KERN_FAILURE thread %08x port %08x sameException %d\n", - thread, sMessage.GetRemotePort(), isSameException); - sReplyOrForward.ReplyToNotification(sMessage, KERN_FAILURE); - } - break; - } - - feList.MoveNext(); - } - } - - if (!feFound) - { - NONPAL_TRACE("HijackFaultingThread thread %08x\n", thread); - HijackFaultingThread(thread, mach_task_self(), sMessage); - - // Send the result of handling the exception back in a reply. - NONPAL_TRACE("ReplyToNotification KERN_SUCCESS thread %08x port %08x\n", thread, sMessage.GetRemotePort()); - sReplyOrForward.ReplyToNotification(sMessage, KERN_SUCCESS); - } - } - else if (sMessage.IsForwardExceptionRequest()) - { - thread = sMessage.GetThread(); - - NONPAL_TRACE("ForwardExceptionRequest for thread %08x\n", thread); - - // Suspend the faulting thread. - SuspendMachThread(thread); - - // Set the context back to the original faulting state. - MachExceptionInfo *pExceptionInfo = sMessage.GetExceptionInfo(); - pExceptionInfo->RestoreState(thread); - - // Allocate an forwarded exception entry - ForwardedException *pfe = (ForwardedException *)malloc(sizeof(ForwardedException)); - if (pfe == NULL) - { - NONPAL_RETAIL_ASSERT("Exception thread ran out of memory to track forwarded exception notifications"); - } - - // Save the forwarded exception entry away for the restarted exception message - pfe->Thread = thread; - pfe->ExceptionType = pExceptionInfo->ExceptionType; - pfe->PalThread = sMessage.GetPalThread(); - feList.Add(pfe); - - // Now let the thread run at the original exception context to restart the exception - NONPAL_TRACE("ForwardExceptionRequest resuming thread %08x exception type %08x\n", thread, pfe->ExceptionType); - machret = thread_resume(thread); - CHECK_MACH("thread_resume", machret); - } - else - { - NONPAL_RETAIL_ASSERT("Unknown message type: %u", sMessage.GetMessageType()); - } - } -} - -/*++ -Function : - MachExceptionInfo constructor - - Saves the exception info from the exception notification message and - the current thread state. - -Parameters: - thread - thread port to restore - message - exception message - -Return value : - none ---*/ -MachExceptionInfo::MachExceptionInfo(mach_port_t thread, MachMessage& message) -{ - kern_return_t machret; - - ExceptionType = message.GetException(); - SubcodeCount = message.GetExceptionCodeCount(); - NONPAL_RETAIL_ASSERTE(SubcodeCount >= 0 && SubcodeCount <= 2); - - for (int i = 0; i < SubcodeCount; i++) - Subcodes[i] = message.GetExceptionCode(i); - - mach_msg_type_number_t count = x86_THREAD_STATE_COUNT; - machret = thread_get_state(thread, x86_THREAD_STATE, (thread_state_t)&ThreadState, &count); - CHECK_MACH("thread_get_state", machret); - - count = x86_FLOAT_STATE_COUNT; - machret = thread_get_state(thread, x86_FLOAT_STATE, (thread_state_t)&FloatState, &count); - CHECK_MACH("thread_get_state(float)", machret); - - count = x86_DEBUG_STATE_COUNT; - machret = thread_get_state(thread, x86_DEBUG_STATE, (thread_state_t)&DebugState, &count); - CHECK_MACH("thread_get_state(debug)", machret); -} - -/*++ -Function : - MachExceptionInfo::RestoreState - - Restore the thread to the saved exception info state. - -Parameters: - thread - thread port to restore - -Return value : - none ---*/ -void MachExceptionInfo::RestoreState(mach_port_t thread) -{ - // If we are restarting a breakpoint, we need to bump the IP back one to - // point at the actual int 3 instructions. - if (ExceptionType == EXC_BREAKPOINT) - { - if (Subcodes[0] == EXC_I386_BPT) - { -#ifdef _X86_ - ThreadState.uts.ts32.eip--; -#elif defined(_AMD64_) - ThreadState.uts.ts64.__rip--; -#else -#error Platform not supported -#endif - } - } - kern_return_t machret = thread_set_state(thread, x86_THREAD_STATE, (thread_state_t)&ThreadState, x86_THREAD_STATE_COUNT); - CHECK_MACH("thread_set_state(thread)", machret); - - machret = thread_set_state(thread, x86_FLOAT_STATE, (thread_state_t)&FloatState, x86_FLOAT_STATE_COUNT); - CHECK_MACH("thread_set_state(float)", machret); - - machret = thread_set_state(thread, x86_DEBUG_STATE, (thread_state_t)&DebugState, x86_DEBUG_STATE_COUNT); - CHECK_MACH("thread_set_state(debug)", machret); -} - -/*++ -Function : - MachSetThreadContext - - Sets the context of the current thread by sending a notification - to the exception thread. - -Parameters: - lpContext - the CONTEXT to set the current thread - -Return value : - Doesn't return ---*/ -PAL_NORETURN -void -MachSetThreadContext(CONTEXT *lpContext) -{ - // We need to send a message to the worker thread so that it can set our thread context. - MachMessage sRequest; - sRequest.SendSetThread(s_ExceptionPort, lpContext); - - // Make sure we don't do anything - while (TRUE) - { - sched_yield(); - } -} - - -/*++ -Function : - SEHInitializeMachExceptions - - Initialize all SEH-related stuff related to mach exceptions - - flags - PAL_INITIALIZE flags - -Return value : - TRUE if SEH support initialization succeeded - FALSE otherwise ---*/ -BOOL -SEHInitializeMachExceptions(DWORD flags) -{ - pthread_t exception_thread; - kern_return_t machret; - - s_PalInitializeFlags = flags; - - // Allocate a mach port that will listen in on exceptions - machret = mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, &s_ExceptionPort); - if (machret != KERN_SUCCESS) - { - ASSERT("mach_port_allocate failed: %d\n", machret); - UTIL_SetLastErrorFromMach(machret); - return FALSE; - } - - // Insert the send right into the task - machret = mach_port_insert_right(mach_task_self(), s_ExceptionPort, s_ExceptionPort, MACH_MSG_TYPE_MAKE_SEND); - if (machret != KERN_SUCCESS) - { - ASSERT("mach_port_insert_right failed: %d\n", machret); - UTIL_SetLastErrorFromMach(machret); - return FALSE; - } - - // Create the thread that will listen to the exception for all threads - int createret = pthread_create(&exception_thread, NULL, SEHExceptionThread, NULL); - if (createret != 0) - { - ERROR("pthread_create failed, error is %d (%s)\n", createret, strerror(createret)); - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - return FALSE; - } - -#ifdef _DEBUG - if (NONPAL_TRACE_ENABLED) - { - CThreadMachExceptionHandlers taskHandlers; - machret = task_get_exception_ports(mach_task_self(), - PAL_EXC_ALL_MASK, - taskHandlers.m_masks, - &taskHandlers.m_nPorts, - taskHandlers.m_handlers, - taskHandlers.m_behaviors, - taskHandlers.m_flavors); - - if (machret == KERN_SUCCESS) - { - NONPAL_TRACE("SEHInitializeMachExceptions: TASK PORT count %d\n", taskHandlers.m_nPorts); - for (mach_msg_type_number_t i = 0; i < taskHandlers.m_nPorts; i++) - { - NONPAL_TRACE("SEHInitializeMachExceptions: TASK PORT mask %08x handler: %08x behavior %08x flavor %u\n", - taskHandlers.m_masks[i], - taskHandlers.m_handlers[i], - taskHandlers.m_behaviors[i], - taskHandlers.m_flavors[i]); - } - } - else - { - NONPAL_TRACE("SEHInitializeMachExceptions: task_get_exception_ports FAILED %d %s\n", machret, mach_error_string(machret)); - } - } -#endif // _DEBUG - -#ifndef FEATURE_PAL_SXS - if (!SEHEnableMachExceptions()) - { - return FALSE; - } -#endif // !FEATURE_PAL_SXS - - // Tell the system to ignore SIGPIPE signals rather than use the default - // behavior of terminating the process. Ignoring SIGPIPE will cause - // calls that would otherwise raise that signal to return EPIPE instead. - // The PAL expects EPIPE from those functions and won't handle a - // SIGPIPE signal. - signal(SIGPIPE, SIG_IGN); - - // We're done - return TRUE; -} - -/*++ -Function : - MachExceptionInitializeDebug - - Initialize the mach exception handlers necessary for a managed debugger - to work - -Return value : - None ---*/ -void MachExceptionInitializeDebug(void) -{ - if (s_DebugInitialized == FALSE) - { -#ifndef FEATURE_PAL_SXS - kern_return_t MachRet; - MachRet = task_set_exception_ports(mach_task_self(), - PAL_EXC_DEBUGGING_MASK, - s_ExceptionPort, - EXCEPTION_DEFAULT, - MACHINE_THREAD_STATE); - if (MachRet != KERN_SUCCESS) - { - ASSERT("task_set_exception_ports failed: %d\n", MachRet); - TerminateProcess(GetCurrentProcess(), (UINT)(-1)); - } -#endif // !FEATURE_PAL_SXS - s_DebugInitialized = TRUE; - } -} - -/*++ -Function : - SEHCleanupExceptionPort - - Restore default exception port handler - - (no parameters, no return value) - -Note : -During PAL_Terminate, we reach a point where SEH isn't possible any more -(handle manager is off, etc). Past that point, we can't avoid crashing on -an exception. ---*/ -void -SEHCleanupExceptionPort(void) -{ - TRACE("Restoring default exception ports\n"); -#ifndef FEATURE_PAL_SXS - SEHDisableMachExceptions(); -#endif // !FEATURE_PAL_SXS - s_DebugInitialized = FALSE; -} - -extern "C" -void -ActivationHandler(CONTEXT* context) -{ - if (g_activationFunction != NULL) - { - g_activationFunction(context); - } - - RtlRestoreContext(context, NULL); - DebugBreak(); -} - -extern "C" void ActivationHandlerWrapper(); -extern "C" int ActivationHandlerReturnOffset; -extern "C" unsigned int XmmYmmStateSupport(); - -/*++ -Function : - InjectActivationInternal - - Sets up the specified thread to call the ActivationHandler. - -Parameters: - pThread - PAL thread instance - -Return value : - PAL_ERROR ---*/ -PAL_ERROR -InjectActivationInternal(CPalThread* pThread) -{ - PAL_ERROR palError; - - mach_port_t threadPort = pThread->GetMachPortSelf(); - kern_return_t MachRet = thread_suspend(threadPort); - palError = (MachRet == KERN_SUCCESS) ? NO_ERROR : ERROR_GEN_FAILURE; - - if (palError == NO_ERROR) - { - mach_msg_type_number_t count; - - x86_exception_state64_t ExceptionState; - count = x86_EXCEPTION_STATE64_COUNT; - MachRet = thread_get_state(threadPort, - x86_EXCEPTION_STATE64, - (thread_state_t)&ExceptionState, - &count); - _ASSERT_MSG(MachRet == KERN_SUCCESS, "thread_get_state for x86_EXCEPTION_STATE64\n"); - - // Inject the activation only if the thread doesn't have a pending hardware exception - static const int MaxHardwareExceptionVector = 31; - if (ExceptionState.__trapno > MaxHardwareExceptionVector) - { - x86_thread_state64_t ThreadState; - count = x86_THREAD_STATE64_COUNT; - MachRet = thread_get_state(threadPort, - x86_THREAD_STATE64, - (thread_state_t)&ThreadState, - &count); - _ASSERT_MSG(MachRet == KERN_SUCCESS, "thread_get_state for x86_THREAD_STATE64\n"); - - if ((g_safeActivationCheckFunction != NULL) && g_safeActivationCheckFunction(ThreadState.__rip, /* checkingCurrentThread */ FALSE)) - { - // TODO: it would be nice to preserve the red zone in case a jitter would want to use it - // Do we really care about unwinding through the wrapper? - size_t* sp = (size_t*)ThreadState.__rsp; - *(--sp) = ThreadState.__rip; - *(--sp) = ThreadState.__rbp; - size_t rbpAddress = (size_t)sp; - size_t contextAddress = (((size_t)sp) - sizeof(CONTEXT)) & ~15; - size_t returnAddressAddress = contextAddress - sizeof(size_t); - *(size_t*)(returnAddressAddress) = ActivationHandlerReturnOffset + (size_t)ActivationHandlerWrapper; - - // Fill in the context in the helper frame with the full context of the suspended thread. - // The ActivationHandler will use the context to resume the execution of the thread - // after the activation function returns. - CONTEXT *pContext = (CONTEXT *)contextAddress; - pContext->ContextFlags = CONTEXT_FULL | CONTEXT_SEGMENTS; -#ifdef XSTATE_SUPPORTED - if (XmmYmmStateSupport() == 1) - { - pContext->ContextFlags |= CONTEXT_XSTATE; - } -#endif - MachRet = CONTEXT_GetThreadContextFromPort(threadPort, pContext); - _ASSERT_MSG(MachRet == KERN_SUCCESS, "CONTEXT_GetThreadContextFromPort\n"); - - // Make the instruction register point to ActivationHandler - ThreadState.__rip = (size_t)ActivationHandler; - ThreadState.__rsp = returnAddressAddress; - ThreadState.__rbp = rbpAddress; - ThreadState.__rdi = contextAddress; - - MachRet = thread_set_state(threadPort, - x86_THREAD_STATE64, - (thread_state_t)&ThreadState, - count); - _ASSERT_MSG(MachRet == KERN_SUCCESS, "thread_set_state\n"); - } - } - - MachRet = thread_resume(threadPort); - palError = (MachRet == ERROR_SUCCESS) ? NO_ERROR : ERROR_GEN_FAILURE; - } - else - { - printf("Suspension failed with error 0x%x\n", palError); - } - - return palError; -} - -#endif // HAVE_MACH_EXCEPTIONS diff --git a/src/pal/src/exception/machexception.h b/src/pal/src/exception/machexception.h deleted file mode 100644 index e2f8ee7a8..000000000 --- a/src/pal/src/exception/machexception.h +++ /dev/null @@ -1,46 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*++ - -Module Name: - - machexception.h - -Abstract: - Private mach exception handling utilities for SEH - ---*/ - -#ifndef _MACHEXCEPTION_H_ -#define _MACHEXCEPTION_H_ - -#include -#include -#include - -#ifdef __cplusplus -extern "C" -{ -#endif // __cplusplus - -// List of exception types we will be watching for -// NOTE: if you change any of these, you need to adapt s_nMachExceptionPortsMax in thread.hpp -#define PAL_EXC_ILLEGAL_MASK (EXC_MASK_BAD_INSTRUCTION | EXC_MASK_EMULATION) -#define PAL_EXC_DEBUGGING_MASK (EXC_MASK_BREAKPOINT | EXC_MASK_SOFTWARE) -#define PAL_EXC_MANAGED_MASK (EXC_MASK_BAD_ACCESS | EXC_MASK_ARITHMETIC) -#define PAL_EXC_ALL_MASK (PAL_EXC_ILLEGAL_MASK | PAL_EXC_DEBUGGING_MASK | PAL_EXC_MANAGED_MASK) - -// Process and thread initialization/cleanup/context routines -BOOL SEHInitializeMachExceptions(DWORD flags); -void SEHCleanupExceptionPort (void); -void MachExceptionInitializeDebug(void); -PAL_NORETURN void MachSetThreadContext(CONTEXT *lpContext); - -#ifdef __cplusplus -} -#endif // __cplusplus - -#endif /* _MACHEXCEPTION_H_ */ - diff --git a/src/pal/src/exception/machmessage.cpp b/src/pal/src/exception/machmessage.cpp deleted file mode 100644 index b78696078..000000000 --- a/src/pal/src/exception/machmessage.cpp +++ /dev/null @@ -1,1383 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*++ - -Module Name: - - machmessage.cpp - -Abstract: - - Abstraction over Mach messages used during exception handling. - ---*/ - -#include "config.h" -#include "pal/dbgmsg.h" -#include "pal/environ.h" -#include "pal/malloc.hpp" -#include "pal/thread.hpp" -#include "machmessage.h" - -#if HAVE_MACH_EXCEPTIONS - -// Construct an empty message. Use Receive() to form a message that can be inspected or SendSetThread(), -// ForwardNotification(), ReplyToNotification() or ForwardReply() to construct a message and sent it. -MachMessage::MachMessage() -{ - m_fPortsOwned = false; - ResetMessage(); -} - -// Listen for the next message on the given port and initialize this class with the contents. The message type -// must match one of the MessageTypes indicated above (or the process will be aborted). -void MachMessage::Receive(mach_port_t hPort) -{ - kern_return_t machret; - - // Erase any stale data. - ResetMessage(); - - // Pull the next Mach message into the buffer. - machret = mach_msg((mach_msg_header_t*)m_rgMessageBuffer, - MACH_RCV_MSG | MACH_RCV_LARGE | MACH_RCV_NOTIFY, - 0, - kcbMaxMessageSize, - hPort, - MACH_MSG_TIMEOUT_NONE, - MACH_PORT_NULL); - CHECK_MACH("mach_msg()", machret); - - // Check it's one of the messages we're expecting. - switch (m_pMessage->header.msgh_id) - { - case SET_THREAD_MESSAGE_ID: - case FORWARD_EXCEPTION_MESSAGE_ID: - case EXCEPTION_RAISE_MESSAGE_ID: - case EXCEPTION_RAISE_STATE_MESSAGE_ID: - case EXCEPTION_RAISE_STATE_IDENTITY_MESSAGE_ID: - case EXCEPTION_RAISE_REPLY_MESSAGE_ID: - case EXCEPTION_RAISE_STATE_REPLY_MESSAGE_ID: - case EXCEPTION_RAISE_STATE_IDENTITY_REPLY_MESSAGE_ID: - case EXCEPTION_RAISE_64_MESSAGE_ID: - case EXCEPTION_RAISE_STATE_64_MESSAGE_ID: - case EXCEPTION_RAISE_STATE_IDENTITY_64_MESSAGE_ID: - case EXCEPTION_RAISE_REPLY_64_MESSAGE_ID: - case EXCEPTION_RAISE_STATE_REPLY_64_MESSAGE_ID: - case EXCEPTION_RAISE_STATE_IDENTITY_REPLY_64_MESSAGE_ID: - case NOTIFY_SEND_ONCE_MESSAGE_ID: - break; - default: - NONPAL_RETAIL_ASSERT("Unsupported message type: %u", m_pMessage->header.msgh_id); - } - - m_fPortsOwned = true; -} - -// Indicates whether the message is a request to set the context of a thread. -bool MachMessage::IsSetThreadRequest() -{ - return m_pMessage->header.msgh_id == SET_THREAD_MESSAGE_ID; -} - -// Indicates whether the message is a request to forward the exception -bool MachMessage::IsForwardExceptionRequest() -{ - return m_pMessage->header.msgh_id == FORWARD_EXCEPTION_MESSAGE_ID; -} - -// Indicates whether the message is a notification that a send-once message was destroyed by the receiver. -bool MachMessage::IsSendOnceDestroyedNotify() -{ - return m_pMessage->header.msgh_id == NOTIFY_SEND_ONCE_MESSAGE_ID; -} - -// Indicates whether the message is a notification of an exception. -bool MachMessage::IsExceptionNotification() -{ - switch (m_pMessage->header.msgh_id) - { - case EXCEPTION_RAISE_MESSAGE_ID: - case EXCEPTION_RAISE_STATE_MESSAGE_ID: - case EXCEPTION_RAISE_STATE_IDENTITY_MESSAGE_ID: - case EXCEPTION_RAISE_64_MESSAGE_ID: - case EXCEPTION_RAISE_STATE_64_MESSAGE_ID: - case EXCEPTION_RAISE_STATE_IDENTITY_64_MESSAGE_ID: - return true; - default: - return false; - } -} - -// Indicates whether the message is a reply to a notification of an exception. -bool MachMessage::IsExceptionReply() -{ - switch (m_pMessage->header.msgh_id) - { - case EXCEPTION_RAISE_REPLY_MESSAGE_ID: - case EXCEPTION_RAISE_STATE_REPLY_MESSAGE_ID: - case EXCEPTION_RAISE_STATE_IDENTITY_REPLY_MESSAGE_ID: - case EXCEPTION_RAISE_REPLY_64_MESSAGE_ID: - case EXCEPTION_RAISE_STATE_REPLY_64_MESSAGE_ID: - case EXCEPTION_RAISE_STATE_IDENTITY_REPLY_64_MESSAGE_ID: - return true; - default: - return false; - } -} - -// Returns the type code for a received message. -MachMessage::MessageType MachMessage::GetMessageType() -{ - return (MessageType)m_pMessage->header.msgh_id; -} - -// Returns a textual form of the type of a received message. Useful for logging. -const char *MachMessage::GetMessageTypeName() -{ - switch (GetMessageType()) - { - case SET_THREAD_MESSAGE_ID: - return "SET_THREAD"; - case FORWARD_EXCEPTION_MESSAGE_ID: - return "FORWARD_EXCEPTION"; - case EXCEPTION_RAISE_MESSAGE_ID: - return "EXCEPTION_RAISE"; - case EXCEPTION_RAISE_REPLY_MESSAGE_ID: - return "EXCEPTION_RAISE_REPLY"; - case EXCEPTION_RAISE_STATE_MESSAGE_ID: - return "EXCEPTION_RAISE_STATE"; - case EXCEPTION_RAISE_STATE_REPLY_MESSAGE_ID: - return "EXCEPTION_RAISE_STATE_REPLY"; - case EXCEPTION_RAISE_STATE_IDENTITY_MESSAGE_ID: - return "EXCEPTION_RAISE_STATE_IDENTITY"; - case EXCEPTION_RAISE_STATE_IDENTITY_REPLY_MESSAGE_ID: - return "EXCEPTION_RAISE_STATE_IDENTITY_REPLY"; - case EXCEPTION_RAISE_64_MESSAGE_ID: - return "EXCEPTION_RAISE_64"; - case EXCEPTION_RAISE_REPLY_64_MESSAGE_ID: - return "EXCEPTION_RAISE_REPLY_64"; - case EXCEPTION_RAISE_STATE_64_MESSAGE_ID: - return "EXCEPTION_RAISE_STATE_64"; - case EXCEPTION_RAISE_STATE_REPLY_64_MESSAGE_ID: - return "EXCEPTION_RAISE_STATE_REPLY_64"; - case EXCEPTION_RAISE_STATE_IDENTITY_64_MESSAGE_ID: - return "EXCEPTION_RAISE_STATE_IDENTITY_64"; - case EXCEPTION_RAISE_STATE_IDENTITY_REPLY_64_MESSAGE_ID: - return "EXCEPTION_RAISE_STATE_IDENTITY_REPLY_64"; - case NOTIFY_SEND_ONCE_MESSAGE_ID: - return "NOTIFY_SEND_ONCE"; - default: - return ""; - } -} - -// Returns the destination port (i.e. the port we listened on to receive this message). -mach_port_t MachMessage::GetLocalPort() -{ - return m_pMessage->header.msgh_local_port; -} - -// Returns the source port (the port sending the message) unless no reply is expected, in which case -// MACH_PORT_NULL is returned instead. -mach_port_t MachMessage::GetRemotePort() -{ - return m_pMessage->header.msgh_remote_port; -} - -// Do the work of getting ports from the message. -// * fCalculate -- calculate the thread port if the message did not contain it. -// * fValidate -- failfast if the message was not one expected to have a (calculable) thread port. -void MachMessage::GetPorts(bool fCalculate, bool fValidThread) -{ - switch (m_pMessage->header.msgh_id) - { - case SET_THREAD_MESSAGE_ID: - m_hThread = m_pMessage->data.set_thread.thread; - break; - - case FORWARD_EXCEPTION_MESSAGE_ID: - m_hThread = m_pMessage->data.forward_exception.thread; - break; - - case EXCEPTION_RAISE_MESSAGE_ID: - m_hThread = m_pMessage->data.raise.thread_port.name; - m_hTask = m_pMessage->data.raise.task_port.name; - break; - - case EXCEPTION_RAISE_64_MESSAGE_ID: - m_hThread = m_pMessage->data.raise_64.thread_port.name; - m_hTask = m_pMessage->data.raise_64.task_port.name; - break; - - case EXCEPTION_RAISE_STATE_MESSAGE_ID: - if (fCalculate && m_hThread == MACH_PORT_NULL) - { - // This is a tricky case since the message itself doesn't contain the target thread. - m_hThread = GetThreadFromState(m_pMessage->data.raise_state.flavor, - m_pMessage->data.raise_state.old_state); - } - break; - - case EXCEPTION_RAISE_STATE_64_MESSAGE_ID: - if (fCalculate && m_hThread == MACH_PORT_NULL) - { - // This is a tricky case since the message itself doesn't contain the target thread. - m_hThread = GetThreadFromState(m_pMessage->data.raise_state_64.flavor, - m_pMessage->data.raise_state_64.old_state); - } - break; - - case EXCEPTION_RAISE_STATE_IDENTITY_MESSAGE_ID: - m_hThread = m_pMessage->data.raise_state_identity.thread_port.name; - m_hTask = m_pMessage->data.raise_state_identity.task_port.name; - break; - - case EXCEPTION_RAISE_STATE_IDENTITY_64_MESSAGE_ID: - m_hThread = m_pMessage->data.raise_state_identity_64.thread_port.name; - m_hTask = m_pMessage->data.raise_state_identity_64.task_port.name; - break; - - default: - if (fValidThread) - { - NONPAL_RETAIL_ASSERT("Can only get thread from notification message."); - } - break; - } -} - -// Get the properties of a set thread or forward exception request. Fills in the provided -// context structure with the context from the message and returns the target thread to -// which the context should be applied. -thread_act_t MachMessage::GetThreadContext(CONTEXT *pContext) -{ - NONPAL_ASSERTE(IsSetThreadRequest()); - - memcpy(pContext, &m_pMessage->data.set_thread.new_context, sizeof(CONTEXT)); - m_hThread = m_pMessage->data.set_thread.thread; - return m_hThread; -} - -// Get the target thread for an exception notification message. -thread_act_t MachMessage::GetThread() -{ - GetPorts(true /* fCalculate */, true /* fValidThread */); - return m_hThread; -} - -// Get the exception type for an exception notification message. -exception_type_t MachMessage::GetException() -{ - switch (m_pMessage->header.msgh_id) - { - case EXCEPTION_RAISE_MESSAGE_ID: - return m_pMessage->data.raise.exception; - - case EXCEPTION_RAISE_64_MESSAGE_ID: - return m_pMessage->data.raise_64.exception; - - case EXCEPTION_RAISE_STATE_MESSAGE_ID: - return m_pMessage->data.raise_state.exception; - - case EXCEPTION_RAISE_STATE_64_MESSAGE_ID: - return m_pMessage->data.raise_state_64.exception; - - case EXCEPTION_RAISE_STATE_IDENTITY_MESSAGE_ID: - return m_pMessage->data.raise_state_identity.exception; - - case EXCEPTION_RAISE_STATE_IDENTITY_64_MESSAGE_ID: - return m_pMessage->data.raise_state_identity_64.exception; - - default: - NONPAL_RETAIL_ASSERT("Can only get exception from notification message."); - } -} - -// Get the count of sub-codes for an exception notification message. -int MachMessage::GetExceptionCodeCount() -{ - switch (m_pMessage->header.msgh_id) - { - case EXCEPTION_RAISE_MESSAGE_ID: - return m_pMessage->data.raise.code_count; - - case EXCEPTION_RAISE_64_MESSAGE_ID: - return m_pMessage->data.raise_64.code_count; - - case EXCEPTION_RAISE_STATE_MESSAGE_ID: - return m_pMessage->data.raise_state.code_count; - - case EXCEPTION_RAISE_STATE_64_MESSAGE_ID: - return m_pMessage->data.raise_state_64.code_count; - - case EXCEPTION_RAISE_STATE_IDENTITY_MESSAGE_ID: - return m_pMessage->data.raise_state_identity.code_count; - - case EXCEPTION_RAISE_STATE_IDENTITY_64_MESSAGE_ID: - return m_pMessage->data.raise_state_identity_64.code_count; - - default: - NONPAL_RETAIL_ASSERT("Can only get exception code count from notification message."); - } -} - -// Get the exception sub-code at the specified zero-based index for an exception notification message. -MACH_EH_TYPE(exception_data_type_t) MachMessage::GetExceptionCode(int iIndex) -{ - if (iIndex < 0 || iIndex >= GetExceptionCodeCount()) - { - NONPAL_RETAIL_ASSERT("GetExceptionCode() index out of range."); - } - - switch (m_pMessage->header.msgh_id) - { - case EXCEPTION_RAISE_MESSAGE_ID: - return (MACH_EH_TYPE(exception_data_type_t))m_pMessage->data.raise.code[iIndex]; - - case EXCEPTION_RAISE_64_MESSAGE_ID: - return m_pMessage->data.raise_64.code[iIndex]; - - case EXCEPTION_RAISE_STATE_MESSAGE_ID: - return (MACH_EH_TYPE(exception_data_type_t))m_pMessage->data.raise_state.code[iIndex]; - - case EXCEPTION_RAISE_STATE_64_MESSAGE_ID: - return m_pMessage->data.raise_state_64.code[iIndex]; - - case EXCEPTION_RAISE_STATE_IDENTITY_MESSAGE_ID: - return (MACH_EH_TYPE(exception_data_type_t))m_pMessage->data.raise_state_identity.code[iIndex]; - - case EXCEPTION_RAISE_STATE_IDENTITY_64_MESSAGE_ID: - return m_pMessage->data.raise_state_identity_64.code[iIndex]; - - default: - NONPAL_RETAIL_ASSERT("Can only get exception code from notification message."); - } -} - -// Fetch the thread state flavor from a notification or reply message (return THREAD_STATE_NONE for the -// messages that don't contain a thread state). -thread_state_flavor_t MachMessage::GetThreadStateFlavor() -{ - switch (m_pMessage->header.msgh_id) - { - case EXCEPTION_RAISE_MESSAGE_ID: - case EXCEPTION_RAISE_REPLY_MESSAGE_ID: - case EXCEPTION_RAISE_64_MESSAGE_ID: - case EXCEPTION_RAISE_REPLY_64_MESSAGE_ID: - return THREAD_STATE_NONE; - - case EXCEPTION_RAISE_STATE_MESSAGE_ID: - return m_pMessage->data.raise_state.flavor; - - case EXCEPTION_RAISE_STATE_64_MESSAGE_ID: - return m_pMessage->data.raise_state_64.flavor; - - case EXCEPTION_RAISE_STATE_IDENTITY_MESSAGE_ID: - return m_pMessage->data.raise_state_identity.flavor; - - case EXCEPTION_RAISE_STATE_IDENTITY_64_MESSAGE_ID: - return m_pMessage->data.raise_state_identity_64.flavor; - - case EXCEPTION_RAISE_STATE_REPLY_MESSAGE_ID: - return m_pMessage->data.raise_state_reply.flavor; - - case EXCEPTION_RAISE_STATE_REPLY_64_MESSAGE_ID: - return m_pMessage->data.raise_state_reply_64.flavor; - - case EXCEPTION_RAISE_STATE_IDENTITY_REPLY_MESSAGE_ID: - return m_pMessage->data.raise_state_identity_reply.flavor; - - case EXCEPTION_RAISE_STATE_IDENTITY_REPLY_64_MESSAGE_ID: - return m_pMessage->data.raise_state_identity_reply_64.flavor; - - default: - NONPAL_RETAIL_ASSERT("Unsupported message type: %u", m_pMessage->header.msgh_id); - } -} - -// Get the thread state with the given flavor from the exception or exception reply message. If the message -// doesn't contain a thread state or the flavor of the state in the message doesn't match, the state will be -// fetched directly from the target thread instead (which can be computed implicitly for exception messages or -// passed explicitly for reply messages). -mach_msg_type_number_t MachMessage::GetThreadState(thread_state_flavor_t eFlavor, thread_state_t pState, thread_act_t thread) -{ - mach_msg_type_number_t count; - kern_return_t machret; - - switch (m_pMessage->header.msgh_id) - { - case EXCEPTION_RAISE_MESSAGE_ID: - case EXCEPTION_RAISE_REPLY_MESSAGE_ID: - case EXCEPTION_RAISE_64_MESSAGE_ID: - case EXCEPTION_RAISE_REPLY_64_MESSAGE_ID: - // No state in the message, fall through to get it directly from the thread. - break; - - case EXCEPTION_RAISE_STATE_MESSAGE_ID: - { - // There's a state in the message, but we need to check that the flavor matches what the caller's - // after (if not we'll fall through and get the correct flavor below). - if (m_pMessage->data.raise_state.flavor == eFlavor) - { - count = m_pMessage->data.raise_state.old_state_count; - memcpy(pState, m_pMessage->data.raise_state.old_state, count * sizeof(natural_t)); - return count; - } - break; - } - - case EXCEPTION_RAISE_STATE_64_MESSAGE_ID: - { - // There's a state in the message, but we need to check that the flavor matches what the caller's - // after (if not we'll fall through and get the correct flavor below). - if (m_pMessage->data.raise_state_64.flavor == eFlavor) - { - count = m_pMessage->data.raise_state_64.old_state_count; - memcpy(pState, m_pMessage->data.raise_state_64.old_state, count * sizeof(natural_t)); - return count; - } - break; - } - - case EXCEPTION_RAISE_STATE_IDENTITY_MESSAGE_ID: - { - // There's a state in the message, but we need to check that the flavor matches what the caller's - // after (if not we'll fall through and get the correct flavor below). - if (m_pMessage->data.raise_state_identity.flavor == eFlavor) - { - count = m_pMessage->data.raise_state_identity.old_state_count; - memcpy(pState, m_pMessage->data.raise_state_identity.old_state, count * sizeof(natural_t)); - return count; - } - break; - } - - case EXCEPTION_RAISE_STATE_IDENTITY_64_MESSAGE_ID: - { - // There's a state in the message, but we need to check that the flavor matches what the caller's - // after (if not we'll fall through and get the correct flavor below). - if (m_pMessage->data.raise_state_identity_64.flavor == eFlavor) - { - count = m_pMessage->data.raise_state_identity_64.old_state_count; - memcpy(pState, m_pMessage->data.raise_state_identity_64.old_state, count * sizeof(natural_t)); - return count; - } - break; - } - - case EXCEPTION_RAISE_STATE_REPLY_MESSAGE_ID: - { - // There's a state in the message, but we need to check that the flavor matches what the caller's - // after (if not we'll fall through and get the correct flavor below). - if (m_pMessage->data.raise_state_reply.flavor == eFlavor) - { - count = m_pMessage->data.raise_state_reply.new_state_count; - memcpy(pState, m_pMessage->data.raise_state_reply.new_state, count * sizeof(natural_t)); - return count; - } - break; - } - - case EXCEPTION_RAISE_STATE_REPLY_64_MESSAGE_ID: - { - // There's a state in the message, but we need to check that the flavor matches what the caller's - // after (if not we'll fall through and get the correct flavor below). - if (m_pMessage->data.raise_state_reply_64.flavor == eFlavor) - { - count = m_pMessage->data.raise_state_reply_64.new_state_count; - memcpy(pState, m_pMessage->data.raise_state_reply_64.new_state, count * sizeof(natural_t)); - return count; - } - break; - } - - case EXCEPTION_RAISE_STATE_IDENTITY_REPLY_MESSAGE_ID: - { - // There's a state in the message, but we need to check that the flavor matches what the caller's - // after (if not we'll fall through and get the correct flavor below). - if (m_pMessage->data.raise_state_identity_reply.flavor == eFlavor) - { - count = m_pMessage->data.raise_state_identity_reply.new_state_count; - memcpy(pState, m_pMessage->data.raise_state_identity_reply.new_state, count * sizeof(natural_t)); - return count; - } - break; - } - - case EXCEPTION_RAISE_STATE_IDENTITY_REPLY_64_MESSAGE_ID: - { - // There's a state in the message, but we need to check that the flavor matches what the caller's - // after (if not we'll fall through and get the correct flavor below). - if (m_pMessage->data.raise_state_identity_reply_64.flavor == eFlavor) - { - count = m_pMessage->data.raise_state_identity_reply_64.new_state_count; - memcpy(pState, m_pMessage->data.raise_state_identity_reply_64.new_state, count * sizeof(natural_t)); - return count; - } - break; - } - - default: - NONPAL_RETAIL_ASSERT("Unsupported message type for requesting thread state."); - } - - // No state in the message or the flavor didn't match. Get the requested flavor of state directly from the - // thread instead. - count = THREAD_STATE_MAX; - machret = thread_get_state(thread ? thread : GetThread(), eFlavor, (thread_state_t)pState, &count); - CHECK_MACH("thread_get_state()", machret); - - return count; -} - -// Fetch the return code from a reply type message. -kern_return_t MachMessage::GetReturnCode() -{ - switch (m_pMessage->header.msgh_id) - { - case EXCEPTION_RAISE_REPLY_MESSAGE_ID: - return m_pMessage->data.raise_reply.ret; - - case EXCEPTION_RAISE_REPLY_64_MESSAGE_ID: - return m_pMessage->data.raise_reply_64.ret; - - case EXCEPTION_RAISE_STATE_REPLY_MESSAGE_ID: - return m_pMessage->data.raise_state_reply.ret; - - case EXCEPTION_RAISE_STATE_REPLY_64_MESSAGE_ID: - return m_pMessage->data.raise_state_reply_64.ret; - - case EXCEPTION_RAISE_STATE_IDENTITY_REPLY_MESSAGE_ID: - return m_pMessage->data.raise_state_identity_reply.ret; - - case EXCEPTION_RAISE_STATE_IDENTITY_REPLY_64_MESSAGE_ID: - return m_pMessage->data.raise_state_identity_reply_64.ret; - - default: - NONPAL_RETAIL_ASSERT("Unsupported message type: %u", m_pMessage->header.msgh_id); - } -} - -// Initialize and send a request to set the register context of a particular thread. -void MachMessage::SendSetThread(mach_port_t hServerPort, CONTEXT *pContext) -{ - kern_return_t machret; - - // Set the message type. - m_pMessage->header.msgh_id = SET_THREAD_MESSAGE_ID; - - // Initialize the fields that don't need any further input (this depends on the message type having been - // set above). - InitFixedFields(); - - // Initialize type-specific fields. The receiving end is responsible for deallocating the thread port. - m_pMessage->data.set_thread.thread = mach_thread_self(); - memcpy(&m_pMessage->data.set_thread.new_context, pContext, sizeof(CONTEXT)); - - // Initialize header fields. - m_pMessage->header.msgh_bits = MACH_MSGH_BITS(MACH_MSG_TYPE_COPY_SEND, 0); - m_pMessage->header.msgh_remote_port = hServerPort; // Destination port - m_pMessage->header.msgh_local_port = MACH_PORT_NULL; // We expect no reply - - // Set the message header size field based on the contents of the message (call this function after all - // other fields have been initialized). - InitMessageSize(); - - // Send the formatted message. - machret = mach_msg((mach_msg_header_t*)m_pMessage, - MACH_SEND_MSG | MACH_MSG_OPTION_NONE, - m_pMessage->header.msgh_size, - 0, - MACH_PORT_NULL, - MACH_MSG_TIMEOUT_NONE, - MACH_PORT_NULL); - CHECK_MACH("mach_msg()", machret); - - // Erase any stale data. (This may not finish executing; nothing is needed to be freed here.) - ResetMessage(); -} - -void MachMessage::SendForwardException(mach_port_t hServerPort, MachExceptionInfo *pExceptionInfo, CPalThread *ppalThread) -{ - kern_return_t machret; - - // Set the message type. - m_pMessage->header.msgh_id = FORWARD_EXCEPTION_MESSAGE_ID; - - // Initialize the fields that don't need any further input (this depends on the message type having been - // set above). - InitFixedFields(); - - // Initialize type-specific fields. The receiving end is responsible for deallocating the thread port. - m_pMessage->data.forward_exception.thread = mach_thread_self(); - m_pMessage->data.forward_exception.ppalThread = ppalThread; - memcpy(&m_pMessage->data.forward_exception.exception_info, pExceptionInfo, sizeof(MachExceptionInfo)); - - // Initialize header fields. - m_pMessage->header.msgh_bits = MACH_MSGH_BITS(MACH_MSG_TYPE_COPY_SEND, 0); - m_pMessage->header.msgh_remote_port = hServerPort; // Destination port - m_pMessage->header.msgh_local_port = MACH_PORT_NULL; // We expect no reply - - // Set the message header size field based on the contents of the message (call this function after all - // other fields have been initialized). - InitMessageSize(); - - // Send the formatted message. - machret = mach_msg((mach_msg_header_t*)m_pMessage, - MACH_SEND_MSG | MACH_MSG_OPTION_NONE, - m_pMessage->header.msgh_size, - 0, - MACH_PORT_NULL, - MACH_MSG_TIMEOUT_NONE, - MACH_PORT_NULL); - CHECK_MACH("mach_msg()", machret); - - // Erase any stale data. - ResetMessage(); -} - -// Returns the pal thread instance for the forward exception message -CPalThread *MachMessage::GetPalThread() -{ - NONPAL_ASSERTE(IsForwardExceptionRequest()); - return m_pMessage->data.forward_exception.ppalThread; -} - -MachExceptionInfo *MachMessage::GetExceptionInfo() -{ - NONPAL_ASSERTE(IsForwardExceptionRequest()); - return &m_pMessage->data.forward_exception.exception_info; -} - -// Initialize the message to represent a forwarded version of the given exception notification message and -// send that message to the chain-back handler previously registered for the exception type being notified. -// The new message takes account of the fact that the target handler may not have requested the same notification -// behavior or flavor as our handler. A new Mach port is created to receive the reply, and this port is returned -// to the caller. Clean up the message afterwards. -void MachMessage::ForwardNotification(MachExceptionHandler *pHandler, MachMessage& message) -{ - kern_return_t machret; - - // Set the message type. - m_pMessage->header.msgh_id = MapBehaviorToNotificationType(pHandler->m_behavior); - - // Initialize the fields that don't need any further input (this depends on the message type having been - // set above). - InitFixedFields(); - - // Copy data from the incoming message. Use the getter and setter abstractions to simplify the act that - // the two messages may be in different formats (e.g. RAISE vs RAISE_STATE). We silently drop data that is - // not needed in the outgoing message and synthesize any required data that is not present in the incoming - // message. - SetThread(message.GetThread()); - SetException(message.GetException()); - - int cCodes = message.GetExceptionCodeCount(); - SetExceptionCodeCount(cCodes); - for (int i = 0; i < cCodes; i++) - SetExceptionCode(i, message.GetExceptionCode(i)); - - // Don't bother fetching thread state unless the destination actually requires it. - if (pHandler->m_flavor != THREAD_STATE_NONE) - { - thread_state_data_t threadState; - mach_msg_type_number_t count = message.GetThreadState(pHandler->m_flavor, (thread_state_t)&threadState); - SetThreadState(pHandler->m_flavor, (thread_state_t)&threadState, count); - } - - // Initialize header fields. - m_pMessage->header.msgh_bits = MACH_MSGH_BITS(MACH_MSG_TYPE_COPY_SEND, MACH_MSG_TYPE_MOVE_SEND_ONCE); - m_pMessage->header.msgh_remote_port = pHandler->m_handler; // Forward to here - m_pMessage->header.msgh_local_port = message.GetRemotePort(); // The reply will come here - - // Set the message header size field based on the contents of the message (call this function after all - // other fields have been initialized). - InitMessageSize(); - - // Send the formatted message. - machret = mach_msg((mach_msg_header_t*)m_pMessage, - MACH_SEND_MSG | MACH_MSG_OPTION_NONE, - m_pMessage->header.msgh_size, - 0, - MACH_PORT_NULL, - MACH_MSG_TIMEOUT_NONE, - MACH_PORT_NULL); - CHECK_MACH("mach_msg()", machret); - - // Erase any stale data. - ResetMessage(); -} - -// Initialize the message to represent a reply to the given exception notification message -// and send that reply back to the original sender of the notification. This is used when -// our handler handles the exception rather than forwarding it to a chain-back handler. -// Clean up the message afterwards. -void MachMessage::ReplyToNotification(MachMessage& message, kern_return_t eResult) -{ - kern_return_t machret; - - // Set the message type. - m_pMessage->header.msgh_id = MapNotificationToReplyType(message.m_pMessage->header.msgh_id); - - // Initialize the fields that don't need any further input (this depends on the message type having been - // set above). - InitFixedFields(); - - SetReturnCode(eResult); - - thread_state_flavor_t eNotificationFlavor = message.GetThreadStateFlavor(); - if (eNotificationFlavor != THREAD_STATE_NONE) - { - // If the reply requires a thread state be sure to get it from the thread directly rather than the - // notification message (handling the exception is likely to have changed the thread state). - thread_state_data_t threadState; - mach_msg_type_number_t count = THREAD_STATE_MAX; - machret = thread_get_state(message.GetThread(), eNotificationFlavor, (thread_state_t)&threadState, &count); - - SetThreadState(eNotificationFlavor, (thread_state_t)&threadState, count); - } - - // Initialize header fields. - m_pMessage->header.msgh_bits = MACH_MSGH_BITS(MACH_MSG_TYPE_MOVE_SEND_ONCE, 0); - m_pMessage->header.msgh_remote_port = message.GetRemotePort(); // Reply goes back to sender - m_pMessage->header.msgh_local_port = 0; // No reply to this expected - - // Set the message header size field based on the contents of the message (call this function after all - // other fields have been initialized). - InitMessageSize(); - - // Send the formatted message. - machret = mach_msg((mach_msg_header_t*)m_pMessage, - MACH_SEND_MSG | MACH_MSG_OPTION_NONE, - m_pMessage->header.msgh_size, - 0, - MACH_PORT_NULL, - MACH_MSG_TIMEOUT_NONE, - MACH_PORT_NULL); - CHECK_MACH("mach_msg()", machret); - - // Erase any stale data. - ResetMessage(); -} - -// Re-initializes this data structure (to the same state as default construction, containing no message). -void MachMessage::ResetMessage() -{ - // Clean up ports if we own them. - if (m_fPortsOwned) - { - kern_return_t machret; - - GetPorts(false /* fCalculate */, false /* fValidThread */); - if (m_hThread != MACH_PORT_NULL) - { - machret = mach_port_deallocate(mach_task_self(), m_hThread); - CHECK_MACH("mach_port_deallocate(m_hThread)", machret); - } - - if (m_hTask != MACH_PORT_NULL) - { - machret = mach_port_deallocate(mach_task_self(), m_hTask); - CHECK_MACH("mach_port_deallocate(m_hTask)", machret); - } - } - -#ifdef _DEBUG - memset(this, 0xcc, sizeof(*this)); -#endif - - m_pMessage = (mach_message_t*)m_rgMessageBuffer; - m_hThread = MACH_PORT_NULL; - m_hTask = MACH_PORT_NULL; - m_fPortsOwned = false; -} - -// Initialize those fields of a message that are invariant. This method expects that the msgh_id field has -// been filled in prior to the call so it can determine which non-header fields to initialize. -void MachMessage::InitFixedFields() -{ - switch (m_pMessage->header.msgh_id) - { - case SET_THREAD_MESSAGE_ID: - break; - - case FORWARD_EXCEPTION_MESSAGE_ID: - break; - - case EXCEPTION_RAISE_MESSAGE_ID: - m_pMessage->data.raise.msgh_body.msgh_descriptor_count = 0; - m_pMessage->data.raise.ndr = NDR_record; - m_pMessage->data.raise.task_port.name = mach_task_self(); - m_pMessage->data.raise.task_port.pad1 = 0; - m_pMessage->data.raise.task_port.pad2 = 0; - m_pMessage->data.raise.task_port.disposition = MACH_MSG_TYPE_COPY_SEND; - m_pMessage->data.raise.task_port.type = MACH_MSG_PORT_DESCRIPTOR; - m_hTask = mach_task_self(); - break; - - case EXCEPTION_RAISE_64_MESSAGE_ID: - m_pMessage->data.raise_64.msgh_body.msgh_descriptor_count = 0; - m_pMessage->data.raise_64.ndr = NDR_record; - m_pMessage->data.raise_64.task_port.name = mach_task_self(); - m_pMessage->data.raise_64.task_port.pad1 = 0; - m_pMessage->data.raise_64.task_port.pad2 = 0; - m_pMessage->data.raise_64.task_port.disposition = MACH_MSG_TYPE_COPY_SEND; - m_pMessage->data.raise_64.task_port.type = MACH_MSG_PORT_DESCRIPTOR; - m_hTask = mach_task_self(); - break; - - case EXCEPTION_RAISE_STATE_MESSAGE_ID: - m_pMessage->data.raise_state.ndr = NDR_record; - break; - - case EXCEPTION_RAISE_STATE_64_MESSAGE_ID: - m_pMessage->data.raise_state_64.ndr = NDR_record; - break; - - case EXCEPTION_RAISE_STATE_IDENTITY_MESSAGE_ID: - m_pMessage->data.raise_state_identity.msgh_body.msgh_descriptor_count = 0; - m_pMessage->data.raise_state_identity.ndr = NDR_record; - m_pMessage->data.raise_state_identity.task_port.name = mach_task_self(); - m_pMessage->data.raise_state_identity.task_port.pad1 = 0; - m_pMessage->data.raise_state_identity.task_port.pad2 = 0; - m_pMessage->data.raise_state_identity.task_port.disposition = MACH_MSG_TYPE_COPY_SEND; - m_pMessage->data.raise_state_identity.task_port.type = MACH_MSG_PORT_DESCRIPTOR; - m_hTask = mach_task_self(); - break; - - case EXCEPTION_RAISE_STATE_IDENTITY_64_MESSAGE_ID: - m_pMessage->data.raise_state_identity_64.msgh_body.msgh_descriptor_count = 0; - m_pMessage->data.raise_state_identity_64.ndr = NDR_record; - m_pMessage->data.raise_state_identity_64.task_port.name = mach_task_self(); - m_pMessage->data.raise_state_identity_64.task_port.pad1 = 0; - m_pMessage->data.raise_state_identity_64.task_port.pad2 = 0; - m_pMessage->data.raise_state_identity_64.task_port.disposition = MACH_MSG_TYPE_COPY_SEND; - m_pMessage->data.raise_state_identity_64.task_port.type = MACH_MSG_PORT_DESCRIPTOR; - m_hTask = mach_task_self(); - break; - - case EXCEPTION_RAISE_REPLY_MESSAGE_ID: - m_pMessage->data.raise_reply.ndr = NDR_record; - break; - - case EXCEPTION_RAISE_REPLY_64_MESSAGE_ID: - m_pMessage->data.raise_reply_64.ndr = NDR_record; - break; - - case EXCEPTION_RAISE_STATE_REPLY_MESSAGE_ID: - m_pMessage->data.raise_state_reply.ndr = NDR_record; - break; - - case EXCEPTION_RAISE_STATE_REPLY_64_MESSAGE_ID: - m_pMessage->data.raise_state_reply_64.ndr = NDR_record; - break; - - case EXCEPTION_RAISE_STATE_IDENTITY_REPLY_MESSAGE_ID: - m_pMessage->data.raise_state_identity_reply.ndr = NDR_record; - break; - - case EXCEPTION_RAISE_STATE_IDENTITY_REPLY_64_MESSAGE_ID: - m_pMessage->data.raise_state_identity_reply_64.ndr = NDR_record; - break; - - default: - NONPAL_RETAIL_ASSERT("Unhandled message type: %u", m_pMessage->header.msgh_id); - } - - m_pMessage->header.msgh_reserved = 0; - - if (m_hTask) - { - kern_return_t machret; - // Addref the task, because the receiver will expect it to own it. (or, if we - // free it unsent, we'll expect to deallocate it). - machret = mach_port_mod_refs(mach_task_self(), m_hTask, MACH_PORT_RIGHT_SEND, 1); - } -} - -// Initialize the size field of the message header (msgh_size) based on the message type and other fields. -// This should be called after all other fields have been initialized. -void MachMessage::InitMessageSize() -{ - // Note that in particular the kernel is very particular about the size of messages with embedded thread - // states. The size of the message must reflect the exact size of the state flavor contained, not the - // maximum size of a thread state that the message format implies. - - switch (m_pMessage->header.msgh_id) - { - case SET_THREAD_MESSAGE_ID: - m_pMessage->header.msgh_size = sizeof(mach_msg_header_t) + sizeof(set_thread_request_t); - break; - - case FORWARD_EXCEPTION_MESSAGE_ID: - m_pMessage->header.msgh_size = sizeof(mach_msg_header_t) + sizeof(forward_exception_request_t); - break; - - case EXCEPTION_RAISE_MESSAGE_ID: - m_pMessage->header.msgh_size = sizeof(mach_msg_header_t) + sizeof(exception_raise_notification_t); - break; - - case EXCEPTION_RAISE_64_MESSAGE_ID: - m_pMessage->header.msgh_size = sizeof(mach_msg_header_t) + sizeof(exception_raise_notification_64_t); - break; - - case EXCEPTION_RAISE_STATE_MESSAGE_ID: - m_pMessage->header.msgh_size = sizeof(mach_msg_header_t) + - offsetof(exception_raise_state_notification_t, old_state) + - (m_pMessage->data.raise_state.old_state_count * sizeof(natural_t)); - break; - - case EXCEPTION_RAISE_STATE_64_MESSAGE_ID: - m_pMessage->header.msgh_size = sizeof(mach_msg_header_t) + - offsetof(exception_raise_state_notification_64_t, old_state) + - (m_pMessage->data.raise_state_64.old_state_count * sizeof(natural_t)); - break; - - case EXCEPTION_RAISE_STATE_IDENTITY_MESSAGE_ID: - m_pMessage->header.msgh_size = sizeof(mach_msg_header_t) + - offsetof(exception_raise_state_identity_notification_t, old_state) + - (m_pMessage->data.raise_state_identity.old_state_count * sizeof(natural_t)); - break; - - case EXCEPTION_RAISE_STATE_IDENTITY_64_MESSAGE_ID: - m_pMessage->header.msgh_size = sizeof(mach_msg_header_t) + - offsetof(exception_raise_state_identity_notification_64_t, old_state) + - (m_pMessage->data.raise_state_identity_64.old_state_count * sizeof(natural_t)); - break; - - case EXCEPTION_RAISE_REPLY_MESSAGE_ID: - m_pMessage->header.msgh_size = sizeof(mach_msg_header_t) + sizeof(exception_raise_reply_t); - break; - - case EXCEPTION_RAISE_REPLY_64_MESSAGE_ID: - m_pMessage->header.msgh_size = sizeof(mach_msg_header_t) + sizeof(exception_raise_reply_64_t); - break; - - case EXCEPTION_RAISE_STATE_REPLY_MESSAGE_ID: - m_pMessage->header.msgh_size = sizeof(mach_msg_header_t) + - offsetof(exception_raise_state_reply_t, new_state) + - (m_pMessage->data.raise_state_reply.new_state_count * sizeof(natural_t)); - break; - - case EXCEPTION_RAISE_STATE_REPLY_64_MESSAGE_ID: - m_pMessage->header.msgh_size = sizeof(mach_msg_header_t) + - offsetof(exception_raise_state_reply_64_t, new_state) + - (m_pMessage->data.raise_state_reply_64.new_state_count * sizeof(natural_t)); - break; - - case EXCEPTION_RAISE_STATE_IDENTITY_REPLY_MESSAGE_ID: - m_pMessage->header.msgh_size = sizeof(mach_msg_header_t) + - offsetof(exception_raise_state_identity_reply_t, new_state) + - (m_pMessage->data.raise_state_identity_reply.new_state_count * sizeof(natural_t)); - break; - - case EXCEPTION_RAISE_STATE_IDENTITY_REPLY_64_MESSAGE_ID: - m_pMessage->header.msgh_size = sizeof(mach_msg_header_t) + - offsetof(exception_raise_state_identity_reply_64_t, new_state) + - (m_pMessage->data.raise_state_identity_reply_64.new_state_count * sizeof(natural_t)); - break; - - default: - NONPAL_RETAIL_ASSERT("Unhandled message type: %u", m_pMessage->header.msgh_id); - } -} - -// Given a thread's register context, locate and return the Mach port representing that thread. Only the -// x86_THREAD_STATE and x86_THREAD_STATE32 state flavors are supported for 32-bit. -thread_act_t MachMessage::GetThreadFromState(thread_state_flavor_t eFlavor, thread_state_t pState) -{ - SIZE_T targetSP; - - // Determine SP from the state provided based on its flavor (this algorithm only works with SP, so - // flavors that don't report this register can't be used). However, hosts that use RAISE_STATE and a - // flavor of state that don't contain SP should be very, very rare indeed (it's hard to imagine many - // useful exception handlers that receive neither the exception thread or the general registers of that - // thread). - switch (eFlavor) - { -#ifdef _X86_ - case x86_THREAD_STATE: - targetSP = ((x86_thread_state_t*)pState)->uts.ts32.esp; - break; - - case x86_THREAD_STATE32: - targetSP = ((x86_thread_state32_t*)pState)->esp; - break; -#elif defined(_AMD64_) - case x86_THREAD_STATE: - targetSP = ((x86_thread_state_t*)pState)->uts.ts64.__rsp; - break; - - case x86_THREAD_STATE64: - targetSP = ((x86_thread_state64_t*)pState)->__rsp; - break; -#else -#error Unexpected architecture. -#endif - default: - NONPAL_RETAIL_ASSERT("Unhandled thread state flavor: %u", eFlavor); - } - - // Capture the list of threads in the current task. Obviously this changes asynchronously to us, but that - // doesn't matter since we know the thread we're after is suspended in the kernel and can't go anywhere. - mach_msg_type_number_t cThreads; - thread_act_t *pThreads; - kern_return_t machret = task_threads(mach_task_self(), &pThreads, &cThreads); - CHECK_MACH("task_threads()", machret); - - // Iterate through each of the threads in the list. - for (mach_msg_type_number_t i = 0; i < cThreads; i++) - { - // Get the general register state of each thread. - x86_thread_state_t threadState; - mach_msg_type_number_t count = x86_THREAD_STATE_COUNT; - machret = thread_get_state(pThreads[i], x86_THREAD_STATE, (thread_state_t)&threadState, &count); - if (machret == KERN_SUCCESS) - { - // If a thread has the same SP as our target it should be the same thread (otherwise we have two - // threads sharing the same stack which is very bad). Conversely the thread we're looking for is - // suspended in the kernel so its SP should not change. We should always be able to find an exact - // match as a result. -#ifdef _X86_ - if (threadState.uts.ts32.esp == targetSP) -#elif defined(_AMD64_) - if (threadState.uts.ts64.__rsp == targetSP) -#else -#error Unexpected architecture. -#endif - { - thread_act_t thread = pThreads[i]; - - // Increment the refcount; the thread is a "send" right. - machret = mach_port_mod_refs(mach_task_self(), thread, MACH_PORT_RIGHT_SEND, 1); - CHECK_MACH("mach_port_mod_refs()", machret); - - // Deallocate the thread list now we're done with it. - machret = vm_deallocate(mach_task_self(), (vm_address_t)pThreads, cThreads * sizeof(thread_act_t)); - CHECK_MACH("vm_deallocate()", machret); - - // Return the thread we found. - return thread; - } - } - } - - // If we got here no thread matched. That shouldn't be possible. - NONPAL_RETAIL_ASSERT("Failed to locate thread from state."); -} - -// Transform an exception handler behavior type into the corresponding Mach message ID for the notification. -mach_msg_id_t MachMessage::MapBehaviorToNotificationType(exception_behavior_t eBehavior) -{ - switch ((uint)eBehavior) - { - case EXCEPTION_DEFAULT: - return EXCEPTION_RAISE_MESSAGE_ID; - case EXCEPTION_STATE: - return EXCEPTION_RAISE_STATE_MESSAGE_ID; - case EXCEPTION_STATE_IDENTITY: - return EXCEPTION_RAISE_STATE_IDENTITY_MESSAGE_ID; - case MACH_EXCEPTION_CODES|EXCEPTION_DEFAULT: - return EXCEPTION_RAISE_64_MESSAGE_ID; - case MACH_EXCEPTION_CODES|EXCEPTION_STATE: - return EXCEPTION_RAISE_STATE_64_MESSAGE_ID; - case MACH_EXCEPTION_CODES|EXCEPTION_STATE_IDENTITY: - return EXCEPTION_RAISE_STATE_IDENTITY_64_MESSAGE_ID; - default: - NONPAL_RETAIL_ASSERT("Unsupported exception behavior type: %u", eBehavior); - } -} - -// Transform a Mach message ID for an exception notification into the corresponding ID for the reply. -mach_msg_id_t MachMessage::MapNotificationToReplyType(mach_msg_id_t eNotificationType) -{ - switch (eNotificationType) - { - case EXCEPTION_RAISE_MESSAGE_ID: - return EXCEPTION_RAISE_REPLY_MESSAGE_ID; - case EXCEPTION_RAISE_STATE_MESSAGE_ID: - return EXCEPTION_RAISE_STATE_REPLY_MESSAGE_ID; - case EXCEPTION_RAISE_STATE_IDENTITY_MESSAGE_ID: - return EXCEPTION_RAISE_STATE_IDENTITY_REPLY_MESSAGE_ID; - case EXCEPTION_RAISE_64_MESSAGE_ID: - return EXCEPTION_RAISE_REPLY_64_MESSAGE_ID; - case EXCEPTION_RAISE_STATE_64_MESSAGE_ID: - return EXCEPTION_RAISE_STATE_REPLY_64_MESSAGE_ID; - case EXCEPTION_RAISE_STATE_IDENTITY_64_MESSAGE_ID: - return EXCEPTION_RAISE_STATE_IDENTITY_REPLY_64_MESSAGE_ID; - default: - NONPAL_RETAIL_ASSERT("Unsupported message type: %u", eNotificationType); - } -} - -// Set faulting thread in an exception notification message. -void MachMessage::SetThread(thread_act_t thread) -{ - bool fSet = false; - - switch (m_pMessage->header.msgh_id) - { - case EXCEPTION_RAISE_MESSAGE_ID: - m_pMessage->data.raise.thread_port.name = thread; - m_pMessage->data.raise.thread_port.pad1 = 0; - m_pMessage->data.raise.thread_port.pad2 = 0; - m_pMessage->data.raise.thread_port.disposition = MACH_MSG_TYPE_COPY_SEND; - m_pMessage->data.raise.thread_port.type = MACH_MSG_PORT_DESCRIPTOR; - fSet = true; - break; - - case EXCEPTION_RAISE_64_MESSAGE_ID: - m_pMessage->data.raise_64.thread_port.name = thread; - m_pMessage->data.raise_64.thread_port.pad1 = 0; - m_pMessage->data.raise_64.thread_port.pad2 = 0; - m_pMessage->data.raise_64.thread_port.disposition = MACH_MSG_TYPE_COPY_SEND; - m_pMessage->data.raise_64.thread_port.type = MACH_MSG_PORT_DESCRIPTOR; - fSet = true; - break; - - case EXCEPTION_RAISE_STATE_MESSAGE_ID: - case EXCEPTION_RAISE_STATE_64_MESSAGE_ID: - // No thread field in RAISE_STATE messages. - break; - - case EXCEPTION_RAISE_STATE_IDENTITY_MESSAGE_ID: - m_pMessage->data.raise_state_identity.thread_port.name = thread; - m_pMessage->data.raise_state_identity.thread_port.pad1 = 0; - m_pMessage->data.raise_state_identity.thread_port.pad2 = 0; - m_pMessage->data.raise_state_identity.thread_port.disposition = MACH_MSG_TYPE_COPY_SEND; - m_pMessage->data.raise_state_identity.thread_port.type = MACH_MSG_PORT_DESCRIPTOR; - fSet = true; - break; - - case EXCEPTION_RAISE_STATE_IDENTITY_64_MESSAGE_ID: - m_pMessage->data.raise_state_identity_64.thread_port.name = thread; - m_pMessage->data.raise_state_identity_64.thread_port.pad1 = 0; - m_pMessage->data.raise_state_identity_64.thread_port.pad2 = 0; - m_pMessage->data.raise_state_identity_64.thread_port.disposition = MACH_MSG_TYPE_COPY_SEND; - m_pMessage->data.raise_state_identity_64.thread_port.type = MACH_MSG_PORT_DESCRIPTOR; - fSet = true; - break; - - default: - NONPAL_RETAIL_ASSERT("Unsupported message type: %u", m_pMessage->header.msgh_id); - } - - if (fSet) - { - // Addref the thread port. - kern_return_t machret; - machret = mach_port_mod_refs(mach_task_self(), thread, MACH_PORT_RIGHT_SEND, 1); - } -} - -// Set exception type in an exception notification message. -void MachMessage::SetException(exception_type_t eException) -{ - switch (m_pMessage->header.msgh_id) - { - case EXCEPTION_RAISE_MESSAGE_ID: - m_pMessage->data.raise.exception = eException; - break; - - case EXCEPTION_RAISE_64_MESSAGE_ID: - m_pMessage->data.raise_64.exception = eException; - break; - - case EXCEPTION_RAISE_STATE_MESSAGE_ID: - m_pMessage->data.raise_state.exception = eException; - break; - - case EXCEPTION_RAISE_STATE_64_MESSAGE_ID: - m_pMessage->data.raise_state_64.exception = eException; - break; - - case EXCEPTION_RAISE_STATE_IDENTITY_MESSAGE_ID: - m_pMessage->data.raise_state_identity.exception = eException; - break; - - case EXCEPTION_RAISE_STATE_IDENTITY_64_MESSAGE_ID: - m_pMessage->data.raise_state_identity_64.exception = eException; - break; - - default: - NONPAL_RETAIL_ASSERT("Unsupported message type: %u", m_pMessage->header.msgh_id); - } -} - -// Set exception sub-code count in an exception notification message. -void MachMessage::SetExceptionCodeCount(int cCodes) -{ - switch (m_pMessage->header.msgh_id) - { - case EXCEPTION_RAISE_MESSAGE_ID: - m_pMessage->data.raise.code_count = cCodes; - break; - - case EXCEPTION_RAISE_64_MESSAGE_ID: - m_pMessage->data.raise_64.code_count = cCodes; - break; - - case EXCEPTION_RAISE_STATE_MESSAGE_ID: - m_pMessage->data.raise_state.code_count = cCodes; - break; - - case EXCEPTION_RAISE_STATE_64_MESSAGE_ID: - m_pMessage->data.raise_state_64.code_count = cCodes; - break; - - case EXCEPTION_RAISE_STATE_IDENTITY_MESSAGE_ID: - m_pMessage->data.raise_state_identity.code_count = cCodes; - break; - - case EXCEPTION_RAISE_STATE_IDENTITY_64_MESSAGE_ID: - m_pMessage->data.raise_state_identity_64.code_count = cCodes; - break; - - default: - NONPAL_RETAIL_ASSERT("Unsupported message type: %u", m_pMessage->header.msgh_id); - } -} - -// Set exception sub-code in an exception notification message. -void MachMessage::SetExceptionCode(int iIndex, MACH_EH_TYPE(exception_data_type_t) iCode) -{ - if (iIndex < 0 || iIndex > 1) - NONPAL_RETAIL_ASSERT("Exception code index out of range"); - - // Note that although the 64-bit message variants support 64-bit exception sub-codes the CoreCLR only - // supports 32-bit processes. We should never see the upper 32-bits containing a non-zero value therefore. - - switch (m_pMessage->header.msgh_id) - { - case EXCEPTION_RAISE_MESSAGE_ID: - m_pMessage->data.raise.code[iIndex] = (int)iCode; - break; - - case EXCEPTION_RAISE_64_MESSAGE_ID: - m_pMessage->data.raise_64.code[iIndex] = iCode; - break; - - case EXCEPTION_RAISE_STATE_MESSAGE_ID: - m_pMessage->data.raise_state.code[iIndex] = (int)iCode; - break; - - case EXCEPTION_RAISE_STATE_64_MESSAGE_ID: - m_pMessage->data.raise_state_64.code[iIndex] = iCode; - break; - - case EXCEPTION_RAISE_STATE_IDENTITY_MESSAGE_ID: - m_pMessage->data.raise_state_identity.code[iIndex] = (int)iCode; - break; - - case EXCEPTION_RAISE_STATE_IDENTITY_64_MESSAGE_ID: - m_pMessage->data.raise_state_identity_64.code[iIndex] = iCode; - break; - - default: - NONPAL_RETAIL_ASSERT("Unsupported message type: %u", m_pMessage->header.msgh_id); - } -} - -// Set return code in a reply message. -void MachMessage::SetReturnCode(kern_return_t eReturnCode) -{ - switch (m_pMessage->header.msgh_id) - { - case EXCEPTION_RAISE_REPLY_MESSAGE_ID: - m_pMessage->data.raise_reply.ret = eReturnCode; - break; - - case EXCEPTION_RAISE_REPLY_64_MESSAGE_ID: - m_pMessage->data.raise_reply_64.ret = eReturnCode; - break; - - case EXCEPTION_RAISE_STATE_REPLY_MESSAGE_ID: - m_pMessage->data.raise_state_reply.ret = eReturnCode; - break; - - case EXCEPTION_RAISE_STATE_REPLY_64_MESSAGE_ID: - m_pMessage->data.raise_state_reply_64.ret = eReturnCode; - break; - - case EXCEPTION_RAISE_STATE_IDENTITY_REPLY_MESSAGE_ID: - m_pMessage->data.raise_state_identity_reply.ret = eReturnCode; - break; - - case EXCEPTION_RAISE_STATE_IDENTITY_REPLY_64_MESSAGE_ID: - m_pMessage->data.raise_state_identity_reply_64.ret = eReturnCode; - break; - - default: - NONPAL_RETAIL_ASSERT("Unsupported message type: %u", m_pMessage->header.msgh_id); - } -} - -// Set faulting thread register state in an exception notification or reply message. -void MachMessage::SetThreadState(thread_state_flavor_t eFlavor, thread_state_t pState, mach_msg_type_number_t count) -{ - switch (m_pMessage->header.msgh_id) - { - case EXCEPTION_RAISE_MESSAGE_ID: - case EXCEPTION_RAISE_REPLY_MESSAGE_ID: - case EXCEPTION_RAISE_64_MESSAGE_ID: - case EXCEPTION_RAISE_REPLY_64_MESSAGE_ID: - // No thread state in RAISE or RAISE_REPLY messages. - break; - - case EXCEPTION_RAISE_STATE_MESSAGE_ID: - m_pMessage->data.raise_state.flavor = eFlavor; - m_pMessage->data.raise_state.old_state_count = count; - memcpy(m_pMessage->data.raise_state.old_state, pState, count * sizeof(natural_t)); - break; - - case EXCEPTION_RAISE_STATE_64_MESSAGE_ID: - m_pMessage->data.raise_state_64.flavor = eFlavor; - m_pMessage->data.raise_state_64.old_state_count = count; - memcpy(m_pMessage->data.raise_state_64.old_state, pState, count * sizeof(natural_t)); - break; - - case EXCEPTION_RAISE_STATE_IDENTITY_MESSAGE_ID: - m_pMessage->data.raise_state_identity.flavor = eFlavor; - m_pMessage->data.raise_state_identity.old_state_count = count; - memcpy(m_pMessage->data.raise_state_identity.old_state, pState, count * sizeof(natural_t)); - break; - - case EXCEPTION_RAISE_STATE_IDENTITY_64_MESSAGE_ID: - m_pMessage->data.raise_state_identity_64.flavor = eFlavor; - m_pMessage->data.raise_state_identity_64.old_state_count = count; - memcpy(m_pMessage->data.raise_state_identity_64.old_state, pState, count * sizeof(natural_t)); - break; - - case EXCEPTION_RAISE_STATE_REPLY_MESSAGE_ID: - m_pMessage->data.raise_state_reply.flavor = eFlavor; - m_pMessage->data.raise_state_reply.new_state_count = count; - memcpy(m_pMessage->data.raise_state_reply.new_state, pState, count * sizeof(natural_t)); - break; - - case EXCEPTION_RAISE_STATE_REPLY_64_MESSAGE_ID: - m_pMessage->data.raise_state_reply_64.flavor = eFlavor; - m_pMessage->data.raise_state_reply_64.new_state_count = count; - memcpy(m_pMessage->data.raise_state_reply_64.new_state, pState, count * sizeof(natural_t)); - break; - - case EXCEPTION_RAISE_STATE_IDENTITY_REPLY_MESSAGE_ID: - m_pMessage->data.raise_state_identity_reply.flavor = eFlavor; - m_pMessage->data.raise_state_identity_reply.new_state_count = count; - memcpy(m_pMessage->data.raise_state_identity_reply.new_state, pState, count * sizeof(natural_t)); - break; - - case EXCEPTION_RAISE_STATE_IDENTITY_REPLY_64_MESSAGE_ID: - m_pMessage->data.raise_state_identity_reply_64.flavor = eFlavor; - m_pMessage->data.raise_state_identity_reply_64.new_state_count = count; - memcpy(m_pMessage->data.raise_state_identity_reply_64.new_state, pState, count * sizeof(natural_t)); - break; - - default: - NONPAL_RETAIL_ASSERT("Unsupported message type: %u", m_pMessage->header.msgh_id); - } -} - -#endif // HAVE_MACH_EXCEPTIONS diff --git a/src/pal/src/exception/machmessage.h b/src/pal/src/exception/machmessage.h deleted file mode 100644 index abc583f6c..000000000 --- a/src/pal/src/exception/machmessage.h +++ /dev/null @@ -1,441 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*++ - -Module Name: - - machmessage.h - -Abstract: - - Abstraction over Mach messages used during exception handling. - ---*/ - -#include -#include -#include - -using namespace CorUnix; - -#if HAVE_MACH_EXCEPTIONS - -#if defined(_AMD64_) -#define MACH_EH_TYPE(x) mach_##x -#else -#define MACH_EH_TYPE(x) x -#endif // defined(_AMD64_) - -// The vast majority of Mach calls we make in this module are critical: we cannot recover from failures of -// these methods (principally because we're handling hardware exceptions in the context of a single dedicated -// handler thread). The following macro encapsulates checking the return code from Mach methods and emitting -// some useful data and aborting the process on failure. -#define CHECK_MACH(_msg, machret) do { \ - if (machret != KERN_SUCCESS) \ - { \ - char _szError[1024]; \ - snprintf(_szError, _countof(_szError), "%s: %u: %s", __FUNCTION__, __LINE__, _msg); \ - mach_error(_szError, machret); \ - abort(); \ - } \ - } while (false) - -// This macro terminates the process with some useful debug info as above, but for the general failure points -// that have nothing to do with Mach. -#define NONPAL_RETAIL_ASSERT(_msg, ...) do { \ - printf("%s: %u: " _msg "\n", __FUNCTION__, __LINE__, ## __VA_ARGS__); \ - abort(); \ - } while (false) - -#define NONPAL_RETAIL_ASSERTE(_expr) do { \ - if (!(_expr)) \ - NONPAL_RETAIL_ASSERT("ASSERT: %s\n", #_expr); \ - } while (false) - -#ifdef _DEBUG - -#define NONPAL_TRACE_ENABLED EnvironGetenv("NONPAL_TRACING", /* copyValue */ false) - -#define NONPAL_ASSERT(_msg, ...) NONPAL_RETAIL_ASSERT(_msg, __VA_ARGS__) - -// Assert macro that doesn't rely on the PAL. -#define NONPAL_ASSERTE(_expr) do { \ - if (!(_expr)) \ - NONPAL_RETAIL_ASSERT("ASSERT: %s\n", #_expr); \ - } while (false) - -// Debug-only output with printf-style formatting. -#define NONPAL_TRACE(_format, ...) do { \ - if (NONPAL_TRACE_ENABLED) printf("NONPAL_TRACE: " _format, ## __VA_ARGS__); \ - } while (false) - -#else // _DEBUG - -#define NONPAL_TRACE_ENABLED false -#define NONPAL_ASSERT(_msg, ...) -#define NONPAL_ASSERTE(_expr) -#define NONPAL_TRACE(_format, ...) - -#endif // _DEBUG - -class MachMessage; - -// Contains all the exception and thread state information needed to forward the exception. -struct MachExceptionInfo -{ - exception_type_t ExceptionType; - mach_msg_type_number_t SubcodeCount; - MACH_EH_TYPE(exception_data_type_t) Subcodes[2]; - x86_thread_state_t ThreadState; - x86_float_state_t FloatState; - x86_debug_state_t DebugState; - - MachExceptionInfo(mach_port_t thread, MachMessage& message); - void RestoreState(mach_port_t thread); -}; - -// Abstraction of a subset of Mach message types. Provides accessors that hide the subtle differences in the -// message layout of similar message types. -class MachMessage -{ -public: - // The message types handled by this class. The values are the actual type codes set in the Mach message - // header. - enum MessageType - { - SET_THREAD_MESSAGE_ID = 1, - FORWARD_EXCEPTION_MESSAGE_ID = 2, - NOTIFY_SEND_ONCE_MESSAGE_ID = 71, - EXCEPTION_RAISE_MESSAGE_ID = 2401, - EXCEPTION_RAISE_STATE_MESSAGE_ID = 2402, - EXCEPTION_RAISE_STATE_IDENTITY_MESSAGE_ID = 2403, - EXCEPTION_RAISE_64_MESSAGE_ID = 2405, - EXCEPTION_RAISE_STATE_64_MESSAGE_ID = 2406, - EXCEPTION_RAISE_STATE_IDENTITY_64_MESSAGE_ID = 2407, - EXCEPTION_RAISE_REPLY_MESSAGE_ID = 2501, - EXCEPTION_RAISE_STATE_REPLY_MESSAGE_ID = 2502, - EXCEPTION_RAISE_STATE_IDENTITY_REPLY_MESSAGE_ID = 2503, - EXCEPTION_RAISE_REPLY_64_MESSAGE_ID = 2505, - EXCEPTION_RAISE_STATE_REPLY_64_MESSAGE_ID = 2506, - EXCEPTION_RAISE_STATE_IDENTITY_REPLY_64_MESSAGE_ID = 2507 - }; - - // Construct an empty message. Use Receive() to form a message that can be inspected or SendSetThread(), - // ForwardNotification() or ReplyToNotification() to construct a message and sent it. - MachMessage(); - - // Listen for the next message on the given port and initialize this class with the contents. The message - // type must match one of the MessageTypes indicated above (or the process will be aborted). - void Receive(mach_port_t hPort); - - // Indicate whether a received message belongs to a particular semantic class. - bool IsSetThreadRequest(); // Message is a request to set the context of a particular thread - bool IsForwardExceptionRequest(); // Message is a request to forward the exception - bool IsSendOnceDestroyedNotify(); // Message is a notification that a send-once message was destroyed by the receiver - bool IsExceptionNotification(); // Message is a notification of an exception - bool IsExceptionReply(); // Message is a reply to the notification of an exception - - // Get properties of a received message header. - MessageType GetMessageType(); // The message type - const char *GetMessageTypeName(); // An ASCII representation of the message type for logging purposes - mach_port_t GetLocalPort(); // The destination port the message was sent to - mach_port_t GetRemotePort(); // The source port the message came from (if a reply is expected) - - // Get the properties of a set thread request. Fills in the provided context structure with the context - // from the message and returns the target thread to which the context should be applied. - thread_act_t GetThreadContext(CONTEXT *pContext); - - // Returns the pal thread instance for the forward exception message - CPalThread *GetPalThread(); - - // Returns the exception info from the forward exception message - MachExceptionInfo *GetExceptionInfo(); - - // Get properties of the type-specific portion of the message. The following properties are supported by - // exception notification messages only. - thread_act_t GetThread(); // Get the faulting thread - exception_type_t GetException(); // Get the exception type (e.g. EXC_BAD_ACCESS) - int GetExceptionCodeCount(); // Get the number of exception sub-codes - MACH_EH_TYPE(exception_data_type_t) GetExceptionCode(int iIndex); // Get the exception sub-code at the given index - - // Fetch the thread state flavor from a notification or reply message (return THREAD_STATE_NONE for the - // messages that don't contain a thread state). - thread_state_flavor_t GetThreadStateFlavor(); - - // Get the thread state with the given flavor from the exception or exception reply message. If the - // message doesn't contain a thread state or the flavor of the state in the message doesn't match, the - // state will be fetched directly from the target thread instead (which can be computed implicitly for - // exception messages or passed explicitly for reply messages). - mach_msg_type_number_t GetThreadState(thread_state_flavor_t eFlavor, thread_state_t pState, thread_act_t thread = NULL); - - // Fetch the return code from a reply type message. - kern_return_t GetReturnCode(); - - // Initialize and send a request to set the register context of a particular thread. - void SendSetThread(mach_port_t hServerPort, CONTEXT *pContext); - - // Initialize and send a request to forward the exception message to the notification thread - void SendForwardException(mach_port_t hServerPort, MachExceptionInfo *pExceptionInfo, CPalThread *ppalThread); - - // Initialize the message (overwriting any previous content) to represent a forwarded version of the given - // exception notification message and send that message to the chain-back handler previously registered - // for the exception type being notified. The new message takes account of the fact that the target - // handler may not have requested the same notification behavior or flavor as our handler. - void ForwardNotification(MachExceptionHandler *pHandler, MachMessage& message); - - // Initialize the message (overwriting any previous content) to represent a reply to the given exception - // notification and send that reply back to the original sender of the notification. This is used when our - // handler handles the exception rather than forwarding it to a chain-back handler. - void ReplyToNotification(MachMessage& message, kern_return_t eResult); - -private: - // The maximum size in bytes of any Mach message we can send or receive. Calculating an exact size for - // this is non trivial (basically because of the security trailers that Mach appends) but the current - // value has proven to be more than enough so far. - static const size_t kcbMaxMessageSize = 1500; - - // The following are structures describing the formats of the Mach messages we understand. - - // Request to set the register context on a particular thread. - // SET_THREAD_MESSAGE_ID - struct set_thread_request_t - { - thread_act_t thread; - CONTEXT new_context; - }; - - // Request to forward the exception notification - // FORWARD_EXCEPTION_MESSAGE_ID - struct forward_exception_request_t - { - thread_act_t thread; - CPalThread *ppalThread; - MachExceptionInfo exception_info; - }; - -#pragma pack(4) - - // EXCEPTION_RAISE_MESSAGE_ID - struct exception_raise_notification_t - { - mach_msg_body_t msgh_body; - mach_msg_port_descriptor_t thread_port; - mach_msg_port_descriptor_t task_port; - NDR_record_t ndr; - exception_type_t exception; - mach_msg_type_number_t code_count; - exception_data_type_t code[2]; - }; - - // EXCEPTION_RAISE_REPLY_MESSAGE_ID - struct exception_raise_reply_t - { - NDR_record_t ndr; - kern_return_t ret; - }; - - // EXCEPTION_RAISE_64_MESSAGE_ID - struct exception_raise_notification_64_t - { - mach_msg_body_t msgh_body; - mach_msg_port_descriptor_t thread_port; - mach_msg_port_descriptor_t task_port; - NDR_record_t ndr; - exception_type_t exception; - mach_msg_type_number_t code_count; - mach_exception_data_type_t code[2]; - }; - - // EXCEPTION_RAISE_REPLY_64_MESSAGE_ID - struct exception_raise_reply_64_t - { - NDR_record_t ndr; - kern_return_t ret; - }; - - // EXCEPTION_RAISE_STATE_MESSAGE_ID - struct exception_raise_state_notification_t - { - NDR_record_t ndr; - exception_type_t exception; - mach_msg_type_number_t code_count; - exception_data_type_t code[2]; - thread_state_flavor_t flavor; - mach_msg_type_number_t old_state_count; - natural_t old_state[THREAD_STATE_MAX]; - }; - - // EXCEPTION_RAISE_STATE_REPLY_MESSAGE_ID - struct exception_raise_state_reply_t - { - NDR_record_t ndr; - kern_return_t ret; - thread_state_flavor_t flavor; - mach_msg_type_number_t new_state_count; - natural_t new_state[THREAD_STATE_MAX]; - }; - - // EXCEPTION_RAISE_STATE_64_MESSAGE_ID - struct exception_raise_state_notification_64_t - { - NDR_record_t ndr; - exception_type_t exception; - mach_msg_type_number_t code_count; - mach_exception_data_type_t code[2]; - thread_state_flavor_t flavor; - mach_msg_type_number_t old_state_count; - natural_t old_state[THREAD_STATE_MAX]; - }; - - // EXCEPTION_RAISE_STATE_REPLY_64_MESSAGE_ID - struct exception_raise_state_reply_64_t - { - NDR_record_t ndr; - kern_return_t ret; - thread_state_flavor_t flavor; - mach_msg_type_number_t new_state_count; - natural_t new_state[THREAD_STATE_MAX]; - }; - - // EXCEPTION_RAISE_STATE_IDENTITY_MESSAGE_ID - struct exception_raise_state_identity_notification_t - { - mach_msg_body_t msgh_body; - mach_msg_port_descriptor_t thread_port; - mach_msg_port_descriptor_t task_port; - NDR_record_t ndr; - exception_type_t exception; - mach_msg_type_number_t code_count; - exception_data_type_t code[2]; - thread_state_flavor_t flavor; - mach_msg_type_number_t old_state_count; - natural_t old_state[THREAD_STATE_MAX]; - }; - - // EXCEPTION_RAISE_STATE_IDENTITY_REPLY_MESSAGE_ID - struct exception_raise_state_identity_reply_t - { - NDR_record_t ndr; - kern_return_t ret; - thread_state_flavor_t flavor; - mach_msg_type_number_t new_state_count; - natural_t new_state[THREAD_STATE_MAX]; - }; - - // EXCEPTION_RAISE_STATE_IDENTITY_64_MESSAGE_ID - struct exception_raise_state_identity_notification_64_t - { - mach_msg_body_t msgh_body; - mach_msg_port_descriptor_t thread_port; - mach_msg_port_descriptor_t task_port; - NDR_record_t ndr; - exception_type_t exception; - mach_msg_type_number_t code_count; - mach_exception_data_type_t code[2]; - thread_state_flavor_t flavor; - mach_msg_type_number_t old_state_count; - natural_t old_state[THREAD_STATE_MAX]; - }; - - // EXCEPTION_RAISE_STATE_IDENTITY_REPLY_64_MESSAGE_ID - struct exception_raise_state_identity_reply_64_t - { - NDR_record_t ndr; - kern_return_t ret; - thread_state_flavor_t flavor; - mach_msg_type_number_t new_state_count; - natural_t new_state[THREAD_STATE_MAX]; - }; - -#pragma pack() - - // All the above messages are sent with a standard Mach header prepended. This structure unifies the - // message formats. - struct mach_message_t - { - mach_msg_header_t header; - union - { - set_thread_request_t set_thread; - forward_exception_request_t forward_exception; - exception_raise_notification_t raise; - exception_raise_state_notification_t raise_state; - exception_raise_state_identity_notification_t raise_state_identity; - exception_raise_notification_64_t raise_64; - exception_raise_state_notification_64_t raise_state_64; - exception_raise_state_identity_notification_64_t raise_state_identity_64; - exception_raise_reply_t raise_reply; - exception_raise_state_reply_t raise_state_reply; - exception_raise_state_identity_reply_t raise_state_identity_reply; - exception_raise_reply_64_t raise_reply_64; - exception_raise_state_reply_64_t raise_state_reply_64; - exception_raise_state_identity_reply_64_t raise_state_identity_reply_64; - } data; - } __attribute__((packed));; - - // Re-initializes this data structure (to the same state as default construction, containing no message). - void ResetMessage(); - - // Initialize those fields of a message that are invariant. This method expects that the msgh_id field has - // been filled in prior to the call so it can determine which non-header fields to initialize. - void InitFixedFields(); - - // Initialize the size field of the message header (msgh_size) based on the message type and other fields. - // This should be called after all other fields have been initialized. - void InitMessageSize(); - - // Do the work of getting ports from the message. - // * fCalculate -- calculate the thread port if the message did not contain it. - // * fValidate -- failfast if the message was not one expected to have a (calculable) thread port. - void GetPorts(bool fCalculate, bool fValidThread); - - // Given a thread's register context, locate and return the Mach port representing that thread. Only the - // x86_THREAD_STATE and x86_THREAD_STATE32 state flavors are supported. - thread_act_t GetThreadFromState(thread_state_flavor_t eFlavor, thread_state_t pState); - - // Transform an exception handler behavior type into the corresponding Mach message ID for the - // notification. - mach_msg_id_t MapBehaviorToNotificationType(exception_behavior_t eBehavior); - - // Transform a Mach message ID for an exception notification into the corresponding ID for the reply. - mach_msg_id_t MapNotificationToReplyType(mach_msg_id_t eNotificationType); - - // The following methods initialize fields on the message prior to transmission. Each is valid for either - // notification, replies or both. If a particular setter is defined for replies, say, then it will be a - // no-op for any replies which don't contain that field. This makes transforming between notifications and - // replies of different types simpler (we can copy a super-set of all fields between the two, but only - // those operations that make sense will do any work). - - // Defined for notifications: - void SetThread(thread_act_t thread); - void SetException(exception_type_t eException); - void SetExceptionCodeCount(int cCodes); - void SetExceptionCode(int iIndex, MACH_EH_TYPE(exception_data_type_t) iCode); - - // Defined for replies: - void SetReturnCode(kern_return_t eReturnCode); - - // Defined for both notifications and replies. - void SetThreadState(thread_state_flavor_t eFlavor, thread_state_t pState, mach_msg_type_number_t count); - - // Maximally sized buffer for the message to be received into or transmitted out of this class. - unsigned char m_rgMessageBuffer[kcbMaxMessageSize]; - - // Initialized by ResetMessage() to point to the buffer above. Gives a typed view of the encapsulated Mach - // message. - mach_message_t *m_pMessage; - - // Cached value of GetThread() or MACH_PORT_NULL if that has not been computed yet. - thread_act_t m_hThread; - - // Cached value of the task port or MACH_PORT_NULL if the message doesn't have one. - mach_port_t m_hTask; - - // Considered whether we are responsible for the deallocation of the ports in - // this message. It is true for messages we receive, and false for messages we send. - bool m_fPortsOwned; -}; - -#endif // HAVE_MACH_EXCEPTIONS diff --git a/src/pal/src/exception/remote-unwind.cpp b/src/pal/src/exception/remote-unwind.cpp deleted file mode 100644 index 4934e7711..000000000 --- a/src/pal/src/exception/remote-unwind.cpp +++ /dev/null @@ -1,1090 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*++ - -Module Name: - - remote-unwind.cpp - -Abstract: - - Implementation of out of context unwind using libunwind8 - remote unwind API. - -This file contains code based on libunwind8 - -Copyright (c) 2003-2005 Hewlett-Packard Development Company, L.P. - Contributed by David Mosberger-Tang - -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. - ---*/ - -#include "config.h" -#include "pal/palinternal.h" -#include "pal/dbgmsg.h" -#include "pal/critsect.h" -#include "pal/debug.h" -#include "pal_endian.h" -#include "pal.h" -#include - -// Sub-headers included from the libunwind.h contain an empty struct -// and clang issues a warning. Until the libunwind is fixed, disable -// the warning. -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wextern-c-compat" -#include -#pragma clang diagnostic pop - -SET_DEFAULT_DEBUG_CHANNEL(EXCEPT); - -// Only used on the AMD64 build -#if defined(_AMD64_) && defined(HAVE_UNW_GET_ACCESSORS) - -#include -#include - -#ifndef ElfW -#define ElfW(foo) Elf_ ## foo -#endif -#define Ehdr ElfW(Ehdr) -#define Phdr ElfW(Phdr) -#define Shdr ElfW(Shdr) -#define Nhdr ElfW(Nhdr) -#define Dyn ElfW(Dyn) - -extern void UnwindContextToWinContext(unw_cursor_t *cursor, CONTEXT *winContext); -extern void GetContextPointers(unw_cursor_t *cursor, unw_context_t *unwContext, KNONVOLATILE_CONTEXT_POINTERS *contextPointers); - -typedef struct _libunwindInfo -{ - SIZE_T BaseAddress; - CONTEXT *Context; - UnwindReadMemoryCallback ReadMemory; -} libunwindInfo; - -#define DW_EH_VERSION 1 - -// DWARF Pointer-Encoding (PEs). -// -// Pointer-Encodings were invented for the GCC exception-handling -// support for C++, but they represent a rather generic way of -// describing the format in which an address/pointer is stored. -// The Pointer-Encoding format is partially documented in Linux Base -// Spec v1.3 (http://www.linuxbase.org/spec/). - -#define DW_EH_PE_FORMAT_MASK 0x0f // format of the encoded value -#define DW_EH_PE_APPL_MASK 0x70 // how the value is to be applied -#define DW_EH_PE_indirect 0x80 // Flag bit. If set, the resulting pointer is the - // address of the word that contains the final address -// Pointer-encoding formats -#define DW_EH_PE_omit 0xff -#define DW_EH_PE_ptr 0x00 // pointer-sized unsigned value -#define DW_EH_PE_uleb128 0x01 // unsigned LE base-128 value -#define DW_EH_PE_udata2 0x02 // unsigned 16-bit value -#define DW_EH_PE_udata4 0x03 // unsigned 32-bit value -#define DW_EH_PE_udata8 0x04 // unsigned 64-bit value -#define DW_EH_PE_sleb128 0x09 // signed LE base-128 value -#define DW_EH_PE_sdata2 0x0a // signed 16-bit value -#define DW_EH_PE_sdata4 0x0b // signed 32-bit value -#define DW_EH_PE_sdata8 0x0c // signed 64-bit value - -// Pointer-encoding application -#define DW_EH_PE_absptr 0x00 // absolute value -#define DW_EH_PE_pcrel 0x10 // rel. to addr. of encoded value -#define DW_EH_PE_textrel 0x20 // text-relative (GCC-specific???) -#define DW_EH_PE_datarel 0x30 // data-relative - -// The following are not documented by LSB v1.3, yet they are used by -// GCC, presumably they aren't documented by LSB since they aren't -// used on Linux -#define DW_EH_PE_funcrel 0x40 // start-of-procedure-relative -#define DW_EH_PE_aligned 0x50 // aligned pointer - -#define DWARF_CIE_VERSION 3 // GCC emits version 1??? - -// DWARF frame header -typedef struct _eh_frame_hdr -{ - unsigned char version; - unsigned char eh_frame_ptr_enc; - unsigned char fde_count_enc; - unsigned char table_enc; - // The rest of the header is variable-length and consists of the - // following members: - // - // encoded_t eh_frame_ptr; - // encoded_t fde_count; - // struct - // { - // encoded_t start_ip; // first address covered by this FDE - // encoded_t fde_offset; // offset of the FDE - // } binary_search_table[fde_count]; -} eh_frame_hdr; - -// "DW_EH_PE_datarel|DW_EH_PE_sdata4" encoded fde table entry -typedef struct _table_entry -{ - int32_t start_ip; - int32_t fde_offset; -} table_entry; - -// DWARF unwind info -typedef struct dwarf_cie_info -{ - unw_word_t cie_instr_start; // start addr. of CIE "initial_instructions" - unw_word_t cie_instr_end; // end addr. of CIE "initial_instructions" - unw_word_t fde_instr_start; // start addr. of FDE "instructions" - unw_word_t fde_instr_end; // end addr. of FDE "instructions" - unw_word_t code_align; // code-alignment factor - unw_word_t data_align; // data-alignment factor - unw_word_t ret_addr_column; // column of return-address register - unw_word_t handler; // address of personality-routine - uint16_t abi; - uint16_t tag; - uint8_t fde_encoding; - uint8_t lsda_encoding; - unsigned int sized_augmentation : 1; - unsigned int have_abi_marker : 1; - unsigned int signal_frame : 1; -} dwarf_cie_info_t; - -static bool -ReadValue8(const libunwindInfo* info, unw_word_t* addr, uint8_t* valp) -{ - uint8_t value; - if (!info->ReadMemory((PVOID)*addr, &value, sizeof(value))) { - return false; - } - *addr += sizeof(value); - *valp = value; - return true; -} - -static bool -ReadValue16(const libunwindInfo* info, unw_word_t* addr, uint16_t* valp) -{ - uint16_t value; - if (!info->ReadMemory((PVOID)*addr, &value, sizeof(value))) { - return false; - } - *addr += sizeof(value); - *valp = VAL16(value); - return true; -} - -static bool -ReadValue32(const libunwindInfo* info, unw_word_t* addr, uint32_t* valp) -{ - uint32_t value; - if (!info->ReadMemory((PVOID)*addr, &value, sizeof(value))) { - return false; - } - *addr += sizeof(value); - *valp = VAL32(value); - return true; -} - -static bool -ReadValue64(const libunwindInfo* info, unw_word_t* addr, uint64_t* valp) -{ - uint64_t value; - if (!info->ReadMemory((PVOID)*addr, &value, sizeof(value))) { - return false; - } - *addr += sizeof(value); - *valp = VAL64(value); - return true; -} - -static bool -ReadPointer(const libunwindInfo* info, unw_word_t* addr, unw_word_t* valp) -{ -#ifdef BIT64 - uint64_t val64; - if (ReadValue64(info, addr, &val64)) { - *valp = val64; - return true; - } -#else - uint32_t val32; - if (ReadValue32(info, addr, &val32)) { - *valp = val32; - return true; - } -#endif - return false; -} - -// Read a unsigned "little-endian base 128" value. See Chapter 7.6 of DWARF spec v3. -static bool -ReadULEB128(const libunwindInfo* info, unw_word_t* addr, unw_word_t* valp) -{ - unw_word_t value = 0; - unsigned char byte; - int shift = 0; - - do - { - if (!ReadValue8(info, addr, &byte)) { - return false; - } - value |= ((unw_word_t)byte & 0x7f) << shift; - shift += 7; - } while (byte & 0x80); - - *valp = value; - return true; -} - -// Read a signed "little-endian base 128" value. See Chapter 7.6 of DWARF spec v3. -static bool -ReadSLEB128(const libunwindInfo* info, unw_word_t* addr, unw_word_t* valp) -{ - unw_word_t value = 0; - unsigned char byte; - int shift = 0; - - do - { - if (!ReadValue8(info, addr, &byte)) { - return false; - } - value |= ((unw_word_t)byte & 0x7f) << shift; - shift += 7; - } while (byte & 0x80); - - if ((shift < (8 * sizeof(unw_word_t))) && ((byte & 0x40) != 0)) { - value |= ((unw_word_t)-1) << shift; - } - - *valp = value; - return true; -} - -static bool -ReadEncodedPointer(const libunwindInfo* info, unw_word_t* addr, unsigned char encoding, unw_word_t funcRel, unw_word_t* valp) -{ - unw_word_t initialAddr = *addr; - uint16_t value16; - uint32_t value32; - uint64_t value64; - unw_word_t value; - - if (encoding == DW_EH_PE_omit) - { - *valp = 0; - return true; - } - else if (encoding == DW_EH_PE_aligned) - { - int size = sizeof(unw_word_t); - *addr = (initialAddr + size - 1) & -size; - return ReadPointer(info, addr, valp); - } - - switch (encoding & DW_EH_PE_FORMAT_MASK) - { - case DW_EH_PE_ptr: - if (!ReadPointer(info, addr, &value)) { - return false; - } - break; - - case DW_EH_PE_uleb128: - if (!ReadULEB128(info, addr, &value)) { - return false; - } - break; - - case DW_EH_PE_sleb128: - if (!ReadSLEB128(info, addr, &value)) { - return false; - } - break; - - case DW_EH_PE_udata2: - if (!ReadValue16(info, addr, &value16)) { - return false; - } - value = value16; - break; - - case DW_EH_PE_udata4: - if (!ReadValue32(info, addr, &value32)) { - return false; - } - value = value32; - break; - - case DW_EH_PE_udata8: - if (!ReadValue64(info, addr, &value64)) { - return false; - } - value = value64; - break; - - case DW_EH_PE_sdata2: - if (!ReadValue16(info, addr, &value16)) { - return false; - } - value = (int16_t)value16; - break; - - case DW_EH_PE_sdata4: - if (!ReadValue32(info, addr, &value32)) { - return false; - } - value = (int32_t)value32; - break; - - case DW_EH_PE_sdata8: - if (!ReadValue64(info, addr, &value64)) { - return false; - } - value = (int64_t)value64; - break; - - default: - ASSERT("ReadEncodedPointer: invalid encoding format %x\n", encoding); - return false; - } - - // 0 is a special value and always absolute - if (value == 0) { - *valp = 0; - return true; - } - - switch (encoding & DW_EH_PE_APPL_MASK) - { - case DW_EH_PE_absptr: - break; - - case DW_EH_PE_pcrel: - value += initialAddr; - break; - - case DW_EH_PE_funcrel: - _ASSERTE(funcRel != UINTPTR_MAX); - value += funcRel; - break; - - case DW_EH_PE_textrel: - case DW_EH_PE_datarel: - default: - ASSERT("ReadEncodedPointer: invalid application type %x\n", encoding); - return false; - } - - if (encoding & DW_EH_PE_indirect) - { - unw_word_t indirect_addr = value; - if (!ReadPointer(info, &indirect_addr, &value)) { - return false; - } - } - - *valp = value; - return true; -} - -static bool -LookupTableEntry(const libunwindInfo* info, int32_t ip, unw_word_t tableAddr, size_t tableCount, table_entry* entry, bool* found) -{ - size_t low, high, mid; - unw_word_t addr; - int32_t start_ip; - - *found = false; - - // do a binary search on table - for (low = 0, high = tableCount; low < high;) - { - mid = (low + high) / 2; - addr = tableAddr + (mid * sizeof(table_entry)); - - if (!ReadValue32(info, &addr, (uint32_t*)&start_ip)) { - return false; - } - if (ip < start_ip) { - high = mid; - } - else { - low = mid + 1; - } - } - - if (high > 0) { - addr = tableAddr + ((high - 1) * sizeof(table_entry)); - // Assumes that the table_entry is two 32 bit values - _ASSERTE(sizeof(*entry) == sizeof(uint64_t)); - if (!ReadValue64(info, &addr, (uint64_t*)entry)) { - return false; - } - *found = true; - } - - return true; -} - -static bool -ParseCie(const libunwindInfo* info, unw_word_t addr, dwarf_cie_info_t* dci) -{ - uint8_t ch, version, fdeEncoding, handlerEncoding; - unw_word_t cieLength, cieEndAddr; - uint32_t value32; - uint64_t value64; - - memset(dci, 0, sizeof (*dci)); - - // Pick appropriate default for FDE-encoding. DWARF spec says - // start-IP (initial_location) and the code-size (address_range) are - // "address-unit sized constants". The `R' augmentation can be used - // to override this, but by default, we pick an address-sized unit - // for fde_encoding. -#if BIT64 - fdeEncoding = DW_EH_PE_udata8; -#else - fdeEncoding = DW_EH_PE_udata4; -#endif - - dci->lsda_encoding = DW_EH_PE_omit; - dci->handler = 0; - - if (!ReadValue32(info, &addr, &value32)) { - return false; - } - - if (value32 != 0xffffffff) - { - // The CIE is in the 32-bit DWARF format - uint32_t cieId; - - // DWARF says CIE id should be 0xffffffff, but in .eh_frame, it's 0 - const uint32_t expectedId = 0; - - cieLength = value32; - cieEndAddr = addr + cieLength; - - if (!ReadValue32(info, &addr, &cieId)) { - return false; - } - if (cieId != expectedId) { - ASSERT("ParseCie: unexpected cie id %x\n", cieId); - return false; - } - } - else - { - // The CIE is in the 64-bit DWARF format - uint64_t cieId; - - // DWARF says CIE id should be 0xffffffffffffffff, but in .eh_frame, it's 0 - const uint64_t expectedId = 0; - - if (!ReadValue64(info, &addr, &value64)) { - return false; - } - cieLength = value64; - cieEndAddr = addr + cieLength; - - if (!ReadValue64(info, &addr, &cieId)) { - return false; - } - if (cieId != expectedId) { - ASSERT("ParseCie: unexpected cie id %lx\n", cieId); - return false; - } - } - dci->cie_instr_end = cieEndAddr; - - if (!ReadValue8(info, &addr, &version)) { - return false; - } - if (version != 1 && version != DWARF_CIE_VERSION) { - ASSERT("ParseCie: invalid cie version %x\n", version); - return false; - } - - // Read the augmentation string - uint8_t augmentationString[8]; - memset(augmentationString, 0, sizeof(augmentationString)); - - for (int i = 0; i < sizeof(augmentationString); i++) - { - if (!ReadValue8(info, &addr, &ch)) { - return false; - } - if (ch == 0) { - break; - } - augmentationString[i] = ch; - } - - // Read the code and data alignment - if (!ReadULEB128(info, &addr, &dci->code_align)) { - return false; - } - if (!ReadSLEB128(info, &addr, &dci->data_align)) { - return false; - } - - // Read the return-address column either as a u8 or as a uleb128 - if (version == 1) - { - if (!ReadValue8(info, &addr, &ch)) { - return false; - } - dci->ret_addr_column = ch; - } - else - { - if (!ReadULEB128(info, &addr, &dci->ret_addr_column)) { - return false; - } - } - - // Parse the augmentation string - for (int i = 0; i < sizeof(augmentationString); i++) - { - bool done = false; - unw_word_t augmentationSize; - - switch (augmentationString[i]) - { - case '\0': - done = true; - break; - - case 'z': - dci->sized_augmentation = 1; - if (!ReadULEB128(info, &addr, &augmentationSize)) { - return false; - } - break; - - case 'L': - // read the LSDA pointer-encoding format - if (!ReadValue8(info, &addr, &ch)) { - return false; - } - dci->lsda_encoding = ch; - break; - - case 'R': - // read the FDE pointer-encoding format - if (!ReadValue8(info, &addr, &fdeEncoding)) { - return false; - } - break; - - case 'P': - // read the personality-routine pointer-encoding format - if (!ReadValue8(info, &addr, &handlerEncoding)) { - return false; - } - if (!ReadEncodedPointer(info, &addr, handlerEncoding, UINTPTR_MAX, &dci->handler)) { - return false; - } - break; - - case 'S': - // This is a signal frame - dci->signal_frame = 1; - - // Temporarily set it to one so dwarf_parse_fde() knows that - // it should fetch the actual ABI/TAG pair from the FDE. - dci->have_abi_marker = 1; - break; - - default: - if (dci->sized_augmentation) { - // If we have the size of the augmentation body, we can skip - // over the parts that we don't understand, so we're OK - done = true; - break; - } - ASSERT("ParseCie: unexpected argumentation string '%s'\n", augmentationString[i]); - return false; - } - - if (done) { - break; - } - } - dci->fde_encoding = fdeEncoding; - dci->cie_instr_start = addr; - return true; -} - -static bool -ExtractProcInfoFromFde(const libunwindInfo* info, unw_word_t* addrp, unw_proc_info_t *pip, int need_unwind_info) -{ - unw_word_t addr = *addrp, fdeEndAddr, cieOffsetAddr, cieAddr; - uint32_t value32; - uint64_t value64; - - if (!ReadValue32(info, &addr, &value32)) { - return false; - } - if (value32 != 0xffffffff) - { - int32_t cieOffset = 0; - - // In some configurations, an FDE with a 0 length indicates the end of the FDE-table - if (value32 == 0) { - return false; - } - // the FDE is in the 32-bit DWARF format */ - *addrp = fdeEndAddr = addr + value32; - cieOffsetAddr = addr; - - if (!ReadValue32(info, &addr, (uint32_t*)&cieOffset)) { - return false; - } - // Ignore CIEs (happens during linear search) - if (cieOffset == 0) { - return true; - } - // DWARF says that the CIE_pointer in the FDE is a .debug_frame-relative offset, - // but the GCC-generated .eh_frame sections instead store a "pcrelative" offset, - // which is just as fine as it's self-contained - cieAddr = cieOffsetAddr - cieOffset; - } - else - { - int64_t cieOffset = 0; - - // the FDE is in the 64-bit DWARF format */ - if (!ReadValue64(info, &addr, (uint64_t*)&value64)) { - return false; - } - *addrp = fdeEndAddr = addr + value64; - cieOffsetAddr = addr; - - if (!ReadValue64(info, &addr, (uint64_t*)&cieOffset)) { - return false; - } - // Ignore CIEs (happens during linear search) - if (cieOffset == 0) { - return true; - } - // DWARF says that the CIE_pointer in the FDE is a .debug_frame-relative offset, - // but the GCC-generated .eh_frame sections instead store a "pcrelative" offset, - // which is just as fine as it's self-contained - cieAddr = (unw_word_t)((uint64_t)cieOffsetAddr - cieOffset); - } - - dwarf_cie_info_t dci; - if (!ParseCie(info, cieAddr, &dci)) { - return false; - } - - unw_word_t ipStart, ipRange; - if (!ReadEncodedPointer(info, &addr, dci.fde_encoding, UINTPTR_MAX, &ipStart)) { - return false; - } - - // IP-range has same encoding as FDE pointers, except that it's always an absolute value - uint8_t ipRangeEncoding = dci.fde_encoding & DW_EH_PE_FORMAT_MASK; - if (!ReadEncodedPointer(info, &addr, ipRangeEncoding, UINTPTR_MAX, &ipRange)) { - return false; - } - pip->start_ip = ipStart; - pip->end_ip = ipStart + ipRange; - pip->handler = dci.handler; - - unw_word_t augmentationSize, augmentationEndAddr; - if (dci.sized_augmentation) { - if (!ReadULEB128(info, &addr, &augmentationSize)) { - return false; - } - augmentationEndAddr = addr + augmentationSize; - } - - // Read language specific data area address - if (!ReadEncodedPointer(info, &addr, dci.lsda_encoding, pip->start_ip, &pip->lsda)) { - return false; - } - - // Now fill out the proc info if requested - if (need_unwind_info) - { - if (dci.have_abi_marker) - { - if (!ReadValue16(info, &addr, &dci.abi)) { - return false; - } - if (!ReadValue16(info, &addr, &dci.tag)) { - return false; - } - } - if (dci.sized_augmentation) { - dci.fde_instr_start = augmentationEndAddr; - } - else { - dci.fde_instr_start = addr; - } - dci.fde_instr_end = fdeEndAddr; - - pip->format = UNW_INFO_FORMAT_TABLE; - pip->unwind_info_size = sizeof(dci); - pip->unwind_info = malloc(sizeof(dci)); - if (pip->unwind_info == nullptr) { - return -UNW_ENOMEM; - } - memcpy(pip->unwind_info, &dci, sizeof(dci)); - } - - return true; -} - - -static int -get_dyn_info_list_addr(unw_addr_space_t as, unw_word_t *dilap, void *arg) -{ - return -UNW_ENOINFO; -} - -static int -access_mem(unw_addr_space_t as, unw_word_t addr, unw_word_t *valp, int write, void *arg) -{ - if (write) - { - ASSERT("Memory write must never be called by libunwind during stackwalk\n"); - return -UNW_EINVAL; - } - const auto *info = (libunwindInfo*)arg; - - if (info->ReadMemory((PVOID)addr, valp, sizeof(*valp))) - { - return UNW_ESUCCESS; - } - else - { - return -UNW_EUNSPEC; - } -} - -static int -access_reg(unw_addr_space_t as, unw_regnum_t regnum, unw_word_t *valp, int write, void *arg) -{ - if (write) - { - ASSERT("Register write must never be called by libunwind during stackwalk\n"); - return -UNW_EREADONLYREG; - } - - const auto *info = (libunwindInfo*)arg; - CONTEXT *winContext = info->Context; - - switch (regnum) - { -#if defined(_AMD64_) - case UNW_REG_IP: *valp = (unw_word_t)winContext->Rip; break; - case UNW_REG_SP: *valp = (unw_word_t)winContext->Rsp; break; - case UNW_X86_64_RBP: *valp = (unw_word_t)winContext->Rbp; break; - case UNW_X86_64_RBX: *valp = (unw_word_t)winContext->Rbx; break; - case UNW_X86_64_R12: *valp = (unw_word_t)winContext->R12; break; - case UNW_X86_64_R13: *valp = (unw_word_t)winContext->R13; break; - case UNW_X86_64_R14: *valp = (unw_word_t)winContext->R14; break; - case UNW_X86_64_R15: *valp = (unw_word_t)winContext->R15; break; -#elif defined(_ARM_) - case UNW_ARM_R13: *valp = (unw_word_t)winContext->Sp; break; - case UNW_ARM_R14: *valp = (unw_word_t)winContext->Lr; break; - case UNW_ARM_R15: *valp = (unw_word_t)winContext->Pc; break; - case UNW_ARM_R4: *valp = (unw_word_t)winContext->R4; break; - case UNW_ARM_R5: *valp = (unw_word_t)winContext->R5; break; - case UNW_ARM_R6: *valp = (unw_word_t)winContext->R6; break; - case UNW_ARM_R7: *valp = (unw_word_t)winContext->R7; break; - case UNW_ARM_R8: *valp = (unw_word_t)winContext->R8; break; - case UNW_ARM_R9: *valp = (unw_word_t)winContext->R9; break; - case UNW_ARM_R10: *valp = (unw_word_t)winContext->R10; break; - case UNW_ARM_R11: *valp = (unw_word_t)winContext->R11; break; -#elif defined(_ARM64_) - case UNW_REG_IP: *valp = (unw_word_t)winContext->Pc; break; - case UNW_REG_SP: *valp = (unw_word_t)winContext->Sp; break; - case UNW_AARCH64_X29: *valp = (unw_word_t)winContext->Fp; break; - case UNW_AARCH64_X30: *valp = (unw_word_t)winContext->Lr; break; - case UNW_AARCH64_X19: *valp = (unw_word_t)winContext->X19; break; - case UNW_AARCH64_X20: *valp = (unw_word_t)winContext->X20; break; - case UNW_AARCH64_X21: *valp = (unw_word_t)winContext->X21; break; - case UNW_AARCH64_X22: *valp = (unw_word_t)winContext->X22; break; - case UNW_AARCH64_X23: *valp = (unw_word_t)winContext->X23; break; - case UNW_AARCH64_X24: *valp = (unw_word_t)winContext->X24; break; - case UNW_AARCH64_X25: *valp = (unw_word_t)winContext->X25; break; - case UNW_AARCH64_X26: *valp = (unw_word_t)winContext->X26; break; - case UNW_AARCH64_X27: *valp = (unw_word_t)winContext->X27; break; - case UNW_AARCH64_X28: *valp = (unw_word_t)winContext->X28; break; -#else -#error unsupported architecture -#endif - default: - ASSERT("Attempt to read an unknown register\n"); - return -UNW_EBADREG; - } - return UNW_ESUCCESS; -} - -static int -access_fpreg(unw_addr_space_t as, unw_regnum_t regnum, unw_fpreg_t *fpvalp, int write, void *arg) -{ - ASSERT("Not supposed to be ever called\n"); - return -UNW_EINVAL; -} - -static int -resume(unw_addr_space_t as, unw_cursor_t *cp, void *arg) -{ - ASSERT("Not supposed to be ever called\n"); - return -UNW_EINVAL; -} - -static int -get_proc_name(unw_addr_space_t as, unw_word_t addr, char *bufp, size_t buf_len, unw_word_t *offp, void *arg) -{ - ASSERT("Not supposed to be ever called\n"); - return -UNW_EINVAL; -} - -static int -find_proc_info(unw_addr_space_t as, unw_word_t ip, unw_proc_info_t *pip, int need_unwind_info, void *arg) -{ - const auto *info = (libunwindInfo*)arg; - memset(pip, 0, sizeof(*pip)); - - Ehdr ehdr; - if (!info->ReadMemory((void*)info->BaseAddress, &ehdr, sizeof(ehdr))) { - ERROR("ELF: reading ehdr %p\n", info->BaseAddress); - return -UNW_EINVAL; - } - Phdr* phdrAddr = reinterpret_cast(info->BaseAddress + ehdr.e_phoff); - int phnum = ehdr.e_phnum; - TRACE("ELF: base %p ip %p e_type %d e_phnum %d e_phoff %p\n", info->BaseAddress, ip, ehdr.e_type, ehdr.e_phnum, ehdr.e_phoff); - - // The eh_frame header - Phdr ehPhdr; - memset(&ehPhdr, 0, sizeof(ehPhdr)); - - // Search for the module's dynamic header and unwind frames - Dyn* dynamicAddr = nullptr; - - for (int i = 0; i < phnum; i++, phdrAddr++) - { - Phdr ph; - if (!info->ReadMemory(phdrAddr, &ph, sizeof(ph))) { - ERROR("ELF: reading phdrAddr %p\n", phdrAddr); - return -UNW_EINVAL; - } - TRACE("ELF: phdr %p type %d (%x) vaddr %p memsz %016llx paddr %p filesz %016llx offset %p align %016llx\n", - phdrAddr, ph.p_type, ph.p_type, ph.p_vaddr, ph.p_memsz, ph.p_paddr, ph.p_filesz, ph.p_offset, ph.p_align); - - switch (ph.p_type) - { - case PT_DYNAMIC: - if (ehdr.e_type == ET_EXEC) { - dynamicAddr = reinterpret_cast(ph.p_vaddr); - } - if (ehdr.e_type == ET_DYN) { - dynamicAddr = reinterpret_cast(ph.p_vaddr + info->BaseAddress); - } - break; - - case PT_GNU_EH_FRAME: - ehPhdr = ph; - break; - } - } - - if (dynamicAddr != nullptr) - { - for (;;) - { - Dyn dyn; - if (!info->ReadMemory(dynamicAddr, &dyn, sizeof(dyn))) { - ERROR("ELF: reading dynamicAddr %p\n", dynamicAddr); - return -UNW_EINVAL; - } - if (dyn.d_tag == DT_PLTGOT) { - TRACE("ELF: dyn %p tag %d (%x) d_ptr %p\n", dynamicAddr, dyn.d_tag, dyn.d_tag, dyn.d_un.d_ptr); - pip->gp = dyn.d_un.d_ptr; - break; - } - else if (dyn.d_tag == DT_NULL) { - break; - } - dynamicAddr++; - } - } - unw_word_t ehFrameHdrAddr = ehPhdr.p_offset + info->BaseAddress; - eh_frame_hdr ehFrameHdr; - - if (!info->ReadMemory((PVOID)ehFrameHdrAddr, &ehFrameHdr, sizeof(eh_frame_hdr))) { - ERROR("ELF: reading ehFrameHdrAddr %p\n", ehFrameHdrAddr); - return -UNW_EINVAL; - } - TRACE("ehFrameHdrAddr %p version %d eh_frame_ptr_enc %d fde_count_enc %d table_enc %d\n", - ehFrameHdrAddr, ehFrameHdr.version, ehFrameHdr.eh_frame_ptr_enc, ehFrameHdr.fde_count_enc, ehFrameHdr.table_enc); - - if (ehFrameHdr.version != DW_EH_VERSION) { - ASSERT("ehFrameHdr version %x not supported\n", ehFrameHdr.version); - return -UNW_EBADVERSION; - } - unw_word_t addr = ehFrameHdrAddr + sizeof(eh_frame_hdr); - unw_word_t ehFrameStart; - unw_word_t fdeCount; - - // Decode the eh_frame_hdr info - if (!ReadEncodedPointer(info, &addr, ehFrameHdr.eh_frame_ptr_enc, UINTPTR_MAX, &ehFrameStart)) { - ERROR("decoding eh_frame_ptr\n"); - return -UNW_EINVAL; - } - if (!ReadEncodedPointer(info, &addr, ehFrameHdr.fde_count_enc, UINTPTR_MAX, &fdeCount)) { - ERROR("decoding fde_count_enc\n"); - return -UNW_EINVAL; - } - TRACE("ehFrameStart %p fdeCount %p ip offset %08x\n", ehFrameStart, fdeCount, (int32_t)(ip - ehFrameHdrAddr)); - - // LookupTableEntry assumes this encoding - if (ehFrameHdr.table_enc != (DW_EH_PE_datarel | DW_EH_PE_sdata4)) { - ASSERT("Table encoding not supported %x\n", ehFrameHdr.table_enc); - return -UNW_EINVAL; - } - // Find the fde using a binary search on the frame table - table_entry entry; - bool found; - if (!LookupTableEntry(info, ip - ehFrameHdrAddr, addr, fdeCount, &entry, &found)) { - ERROR("LookupTableEntry\n"); - return -UNW_EINVAL; - } - unw_word_t fdeAddr = entry.fde_offset + ehFrameHdrAddr; - TRACE("start_ip %08x fde_offset %08x fdeAddr %p found %d\n", entry.start_ip, entry.fde_offset, fdeAddr, found); - - // Unwind info not found - if (!found) { - return -UNW_ENOINFO; - } - - // Now get the unwind info - if (!ExtractProcInfoFromFde(info, &fdeAddr, pip, need_unwind_info)) { - ERROR("ExtractProcInfoFromFde\n"); - return -UNW_EINVAL; - } - - _ASSERTE(ip >= pip->start_ip && ip <= pip->end_ip); - return UNW_ESUCCESS; -} - -static void -put_unwind_info(unw_addr_space_t as, unw_proc_info_t *pip, void *arg) -{ - if (pip->unwind_info != nullptr) { - free(pip->unwind_info); - pip->unwind_info = nullptr; - } -} - -static unw_accessors_t unwind_accessors = -{ - .find_proc_info = find_proc_info, - .put_unwind_info = put_unwind_info, - .get_dyn_info_list_addr = get_dyn_info_list_addr, - .access_mem = access_mem, - .access_reg = access_reg, - .access_fpreg = access_fpreg, - .resume = resume, - .get_proc_name = get_proc_name -}; - -/*++ -Function: - PAL_VirtualUnwindOutOfProc - - Unwind the stack given the context for a "remote" target using the - provided read memory callback. - - Assumes the IP is in the module of the base address provided (coreclr). - -Parameters: - context - the start context in the target - contextPointers - the context of the next frame - baseAddress - base address of the module to find the unwind info - readMemoryCallback - reads memory from the target ---*/ -BOOL -PALAPI -PAL_VirtualUnwindOutOfProc(CONTEXT *context, KNONVOLATILE_CONTEXT_POINTERS *contextPointers, SIZE_T baseAddress, UnwindReadMemoryCallback readMemoryCallback) -{ - unw_addr_space_t addrSpace = 0; - unw_cursor_t cursor; - libunwindInfo info; - BOOL result = FALSE; - int st; - - info.BaseAddress = baseAddress; - info.Context = context; - info.ReadMemory = readMemoryCallback; - - addrSpace = unw_create_addr_space(&unwind_accessors, 0); - - st = unw_init_remote(&cursor, addrSpace, &info); - if (st < 0) - { - result = FALSE; - goto exit; - } - - st = unw_step(&cursor); - if (st < 0) - { - result = FALSE; - goto exit; - } - - UnwindContextToWinContext(&cursor, context); - - if (contextPointers != NULL) - { - GetContextPointers(&cursor, NULL, contextPointers); - } - result = TRUE; - -exit: - if (addrSpace != 0) - { - unw_destroy_addr_space(addrSpace); - } - return result; -} - -#else - -BOOL -PALAPI -PAL_VirtualUnwindOutOfProc(CONTEXT *context, KNONVOLATILE_CONTEXT_POINTERS *contextPointers, SIZE_T baseAddress, UnwindReadMemoryCallback readMemoryCallback) -{ - return FALSE; -} - -#endif // defined(_AMD64_) && defined(HAVE_UNW_GET_ACCESSORS) diff --git a/src/pal/src/exception/seh-unwind.cpp b/src/pal/src/exception/seh-unwind.cpp deleted file mode 100644 index 2b7c9360a..000000000 --- a/src/pal/src/exception/seh-unwind.cpp +++ /dev/null @@ -1,522 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*++ - - - -Module Name: - - seh-unwind.cpp - -Abstract: - - Implementation of exception API functions based on - the Unwind API. - - - ---*/ - -#ifndef FEATURE_PAL_SXS -#error FEATURE_PAL_SXS needs to be defined for this file. -#endif // !FEATURE_PAL_SXS - -#include "pal/context.h" -#include "pal.h" -#include - -#define UNW_LOCAL_ONLY -// Sub-headers included from the libunwind.h contain an empty struct -// and clang issues a warning. Until the libunwind is fixed, disable -// the warning. -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wextern-c-compat" -#include -#pragma clang diagnostic pop - -//---------------------------------------------------------------------- -// Virtual Unwinding -//---------------------------------------------------------------------- - -#if UNWIND_CONTEXT_IS_UCONTEXT_T - -#if defined(_AMD64_) -#define ASSIGN_UNWIND_REGS \ - ASSIGN_REG(Rip) \ - ASSIGN_REG(Rsp) \ - ASSIGN_REG(Rbp) \ - ASSIGN_REG(Rbx) \ - ASSIGN_REG(R12) \ - ASSIGN_REG(R13) \ - ASSIGN_REG(R14) \ - ASSIGN_REG(R15) -#elif defined(_ARM64_) -#define ASSIGN_UNWIND_REGS \ - ASSIGN_REG(Pc) \ - ASSIGN_REG(Sp) \ - ASSIGN_REG(Fp) \ - ASSIGN_REG(Lr) \ - ASSIGN_REG(X19) \ - ASSIGN_REG(X20) \ - ASSIGN_REG(X21) \ - ASSIGN_REG(X22) \ - ASSIGN_REG(X23) \ - ASSIGN_REG(X24) \ - ASSIGN_REG(X25) \ - ASSIGN_REG(X26) \ - ASSIGN_REG(X27) \ - ASSIGN_REG(X28) -#elif defined(_X86_) -#define ASSIGN_UNWIND_REGS \ - ASSIGN_REG(Eip) \ - ASSIGN_REG(Esp) \ - ASSIGN_REG(Ebp) \ - ASSIGN_REG(Ebx) \ - ASSIGN_REG(Esi) \ - ASSIGN_REG(Edi) -#else -#error unsupported architecture -#endif - -static void WinContextToUnwindContext(CONTEXT *winContext, unw_context_t *unwContext) -{ -#define ASSIGN_REG(reg) MCREG_##reg(unwContext->uc_mcontext) = winContext->reg; - ASSIGN_UNWIND_REGS -#undef ASSIGN_REG -} -#else -static void WinContextToUnwindContext(CONTEXT *winContext, unw_context_t *unwContext) -{ -#if defined(_ARM_) - // Assuming that unw_set_reg() on cursor will point the cursor to the - // supposed stack frame is dangerous for libunwind-arm in Linux. - // It is because libunwind's unw_cursor_t has other data structure - // initialized by unw_init_local(), which are not updated by - // unw_set_reg(). - unwContext->regs[0] = 0; - unwContext->regs[1] = 0; - unwContext->regs[2] = 0; - unwContext->regs[3] = 0; - unwContext->regs[4] = winContext->R4; - unwContext->regs[5] = winContext->R5; - unwContext->regs[6] = winContext->R6; - unwContext->regs[7] = winContext->R7; - unwContext->regs[8] = winContext->R8; - unwContext->regs[9] = winContext->R9; - unwContext->regs[10] = winContext->R10; - unwContext->regs[11] = winContext->R11; - unwContext->regs[12] = 0; - unwContext->regs[13] = winContext->Sp; - unwContext->regs[14] = winContext->Lr; - unwContext->regs[15] = winContext->Pc; -#endif -} - -static void WinContextToUnwindCursor(CONTEXT *winContext, unw_cursor_t *cursor) -{ -#if defined(_AMD64_) - unw_set_reg(cursor, UNW_REG_IP, winContext->Rip); - unw_set_reg(cursor, UNW_REG_SP, winContext->Rsp); - unw_set_reg(cursor, UNW_X86_64_RBP, winContext->Rbp); - unw_set_reg(cursor, UNW_X86_64_RBX, winContext->Rbx); - unw_set_reg(cursor, UNW_X86_64_R12, winContext->R12); - unw_set_reg(cursor, UNW_X86_64_R13, winContext->R13); - unw_set_reg(cursor, UNW_X86_64_R14, winContext->R14); - unw_set_reg(cursor, UNW_X86_64_R15, winContext->R15); -#elif defined(_X86_) - unw_set_reg(cursor, UNW_REG_IP, winContext->Eip); - unw_set_reg(cursor, UNW_REG_SP, winContext->Esp); - unw_set_reg(cursor, UNW_X86_EBP, winContext->Ebp); - unw_set_reg(cursor, UNW_X86_EBX, winContext->Ebx); - unw_set_reg(cursor, UNW_X86_ESI, winContext->Esi); - unw_set_reg(cursor, UNW_X86_EDI, winContext->Edi); -#endif -} -#endif - -void UnwindContextToWinContext(unw_cursor_t *cursor, CONTEXT *winContext) -{ -#if defined(_AMD64_) - unw_get_reg(cursor, UNW_REG_IP, (unw_word_t *) &winContext->Rip); - unw_get_reg(cursor, UNW_REG_SP, (unw_word_t *) &winContext->Rsp); - unw_get_reg(cursor, UNW_X86_64_RBP, (unw_word_t *) &winContext->Rbp); - unw_get_reg(cursor, UNW_X86_64_RBX, (unw_word_t *) &winContext->Rbx); - unw_get_reg(cursor, UNW_X86_64_R12, (unw_word_t *) &winContext->R12); - unw_get_reg(cursor, UNW_X86_64_R13, (unw_word_t *) &winContext->R13); - unw_get_reg(cursor, UNW_X86_64_R14, (unw_word_t *) &winContext->R14); - unw_get_reg(cursor, UNW_X86_64_R15, (unw_word_t *) &winContext->R15); -#elif defined(_X86_) - unw_get_reg(cursor, UNW_REG_IP, (unw_word_t *) &winContext->Eip); - unw_get_reg(cursor, UNW_REG_SP, (unw_word_t *) &winContext->Esp); - unw_get_reg(cursor, UNW_X86_EBP, (unw_word_t *) &winContext->Ebp); - unw_get_reg(cursor, UNW_X86_EBX, (unw_word_t *) &winContext->Ebx); - unw_get_reg(cursor, UNW_X86_ESI, (unw_word_t *) &winContext->Esi); - unw_get_reg(cursor, UNW_X86_EDI, (unw_word_t *) &winContext->Edi); -#elif defined(_ARM_) - unw_get_reg(cursor, UNW_REG_SP, (unw_word_t *) &winContext->Sp); - unw_get_reg(cursor, UNW_REG_IP, (unw_word_t *) &winContext->Pc); - unw_get_reg(cursor, UNW_ARM_R14, (unw_word_t *) &winContext->Lr); - unw_get_reg(cursor, UNW_ARM_R4, (unw_word_t *) &winContext->R4); - unw_get_reg(cursor, UNW_ARM_R5, (unw_word_t *) &winContext->R5); - unw_get_reg(cursor, UNW_ARM_R6, (unw_word_t *) &winContext->R6); - unw_get_reg(cursor, UNW_ARM_R7, (unw_word_t *) &winContext->R7); - unw_get_reg(cursor, UNW_ARM_R8, (unw_word_t *) &winContext->R8); - unw_get_reg(cursor, UNW_ARM_R9, (unw_word_t *) &winContext->R9); - unw_get_reg(cursor, UNW_ARM_R10, (unw_word_t *) &winContext->R10); - unw_get_reg(cursor, UNW_ARM_R11, (unw_word_t *) &winContext->R11); -#elif defined(_ARM64_) - unw_get_reg(cursor, UNW_REG_IP, (unw_word_t *) &winContext->Pc); - unw_get_reg(cursor, UNW_REG_SP, (unw_word_t *) &winContext->Sp); - unw_get_reg(cursor, UNW_AARCH64_X29, (unw_word_t *) &winContext->Fp); - unw_get_reg(cursor, UNW_AARCH64_X30, (unw_word_t *) &winContext->Lr); - unw_get_reg(cursor, UNW_AARCH64_X19, (unw_word_t *) &winContext->X19); - unw_get_reg(cursor, UNW_AARCH64_X20, (unw_word_t *) &winContext->X20); - unw_get_reg(cursor, UNW_AARCH64_X21, (unw_word_t *) &winContext->X21); - unw_get_reg(cursor, UNW_AARCH64_X22, (unw_word_t *) &winContext->X22); - unw_get_reg(cursor, UNW_AARCH64_X23, (unw_word_t *) &winContext->X23); - unw_get_reg(cursor, UNW_AARCH64_X24, (unw_word_t *) &winContext->X24); - unw_get_reg(cursor, UNW_AARCH64_X25, (unw_word_t *) &winContext->X25); - unw_get_reg(cursor, UNW_AARCH64_X26, (unw_word_t *) &winContext->X26); - unw_get_reg(cursor, UNW_AARCH64_X27, (unw_word_t *) &winContext->X27); - unw_get_reg(cursor, UNW_AARCH64_X28, (unw_word_t *) &winContext->X28); -#else -#error unsupported architecture -#endif -} - -static void GetContextPointer(unw_cursor_t *cursor, unw_context_t *unwContext, int reg, SIZE_T **contextPointer) -{ -#if defined(HAVE_UNW_GET_SAVE_LOC) - unw_save_loc_t saveLoc; - unw_get_save_loc(cursor, reg, &saveLoc); - if (saveLoc.type == UNW_SLT_MEMORY) - { - SIZE_T *pLoc = (SIZE_T *)saveLoc.u.addr; - // Filter out fake save locations that point to unwContext - if (unwContext == NULL || (pLoc < (SIZE_T *)unwContext) || ((SIZE_T *)(unwContext + 1) <= pLoc)) - *contextPointer = (SIZE_T *)saveLoc.u.addr; - } -#else - // Returning NULL indicates that we don't have context pointers available - *contextPointer = NULL; -#endif -} - -void GetContextPointers(unw_cursor_t *cursor, unw_context_t *unwContext, KNONVOLATILE_CONTEXT_POINTERS *contextPointers) -{ -#if defined(_AMD64_) - GetContextPointer(cursor, unwContext, UNW_X86_64_RBP, &contextPointers->Rbp); - GetContextPointer(cursor, unwContext, UNW_X86_64_RBX, &contextPointers->Rbx); - GetContextPointer(cursor, unwContext, UNW_X86_64_R12, &contextPointers->R12); - GetContextPointer(cursor, unwContext, UNW_X86_64_R13, &contextPointers->R13); - GetContextPointer(cursor, unwContext, UNW_X86_64_R14, &contextPointers->R14); - GetContextPointer(cursor, unwContext, UNW_X86_64_R15, &contextPointers->R15); -#elif defined(_X86_) - GetContextPointer(cursor, unwContext, UNW_X86_EBX, &contextPointers->Ebx); - GetContextPointer(cursor, unwContext, UNW_X86_EBP, &contextPointers->Ebp); - GetContextPointer(cursor, unwContext, UNW_X86_ESI, &contextPointers->Esi); - GetContextPointer(cursor, unwContext, UNW_X86_EDI, &contextPointers->Edi); -#elif defined(_ARM_) - GetContextPointer(cursor, unwContext, UNW_ARM_R4, &contextPointers->R4); - GetContextPointer(cursor, unwContext, UNW_ARM_R5, &contextPointers->R5); - GetContextPointer(cursor, unwContext, UNW_ARM_R6, &contextPointers->R6); - GetContextPointer(cursor, unwContext, UNW_ARM_R7, &contextPointers->R7); - GetContextPointer(cursor, unwContext, UNW_ARM_R8, &contextPointers->R8); - GetContextPointer(cursor, unwContext, UNW_ARM_R9, &contextPointers->R9); - GetContextPointer(cursor, unwContext, UNW_ARM_R10, &contextPointers->R10); - GetContextPointer(cursor, unwContext, UNW_ARM_R11, &contextPointers->R11); -#elif defined(_ARM64_) - GetContextPointer(cursor, unwContext, UNW_AARCH64_X19, &contextPointers->X19); - GetContextPointer(cursor, unwContext, UNW_AARCH64_X20, &contextPointers->X20); - GetContextPointer(cursor, unwContext, UNW_AARCH64_X21, &contextPointers->X21); - GetContextPointer(cursor, unwContext, UNW_AARCH64_X22, &contextPointers->X22); - GetContextPointer(cursor, unwContext, UNW_AARCH64_X23, &contextPointers->X23); - GetContextPointer(cursor, unwContext, UNW_AARCH64_X24, &contextPointers->X24); - GetContextPointer(cursor, unwContext, UNW_AARCH64_X25, &contextPointers->X25); - GetContextPointer(cursor, unwContext, UNW_AARCH64_X26, &contextPointers->X26); - GetContextPointer(cursor, unwContext, UNW_AARCH64_X27, &contextPointers->X27); - GetContextPointer(cursor, unwContext, UNW_AARCH64_X28, &contextPointers->X28); - GetContextPointer(cursor, unwContext, UNW_AARCH64_X29, &contextPointers->Fp); -#else -#error unsupported architecture -#endif -} - -extern int g_common_signal_handler_context_locvar_offset; - -BOOL PAL_VirtualUnwind(CONTEXT *context, KNONVOLATILE_CONTEXT_POINTERS *contextPointers) -{ - int st; - unw_context_t unwContext; - unw_cursor_t cursor; - - DWORD64 curPc = CONTEXTGetPC(context); - -#ifndef __APPLE__ - // Check if the PC is the return address from the SEHProcessException in the common_signal_handler. - // If that's the case, extract its local variable containing the windows style context of the hardware - // exception and return that. This skips the hardware signal handler trampoline that the libunwind - // cannot cross on some systems. - if ((void*)curPc == g_SEHProcessExceptionReturnAddress) - { - CONTEXT* signalContext = (CONTEXT*)(CONTEXTGetFP(context) + g_common_signal_handler_context_locvar_offset); - memcpy_s(context, sizeof(CONTEXT), signalContext, sizeof(CONTEXT)); - - return TRUE; - } -#endif - - if ((context->ContextFlags & CONTEXT_EXCEPTION_ACTIVE) != 0) - { - // The current frame is a source of hardware exception. Due to the fact that - // we use the low level unwinder to unwind just one frame a time, the - // unwinder doesn't have the signal_frame flag set. So it doesn't - // know that it should not decrement the PC before looking up the unwind info. - // So we compensate it by incrementing the PC before passing it to the unwinder. - // Without it, the unwinder would not find unwind info if the hardware exception - // happened in the first instruction of a function. - CONTEXTSetPC(context, curPc + 1); - } - -#if !UNWIND_CONTEXT_IS_UCONTEXT_T - st = unw_getcontext(&unwContext); - if (st < 0) - { - return FALSE; - } -#endif - - WinContextToUnwindContext(context, &unwContext); - - st = unw_init_local(&cursor, &unwContext); - if (st < 0) - { - return FALSE; - } - -#if !UNWIND_CONTEXT_IS_UCONTEXT_T - // Set the unwind context to the specified windows context - WinContextToUnwindCursor(context, &cursor); -#endif - - st = unw_step(&cursor); - if (st < 0) - { - return FALSE; - } - - // Check if the frame we have unwound to is a frame that caused - // synchronous signal, like a hardware exception and record it - // in the context flags. - if (unw_is_signal_frame(&cursor) > 0) - { - context->ContextFlags |= CONTEXT_EXCEPTION_ACTIVE; -#if defined(_ARM_) || defined(_ARM64_) || defined(_X86_) - context->ContextFlags &= ~CONTEXT_UNWOUND_TO_CALL; -#endif // _ARM_ || _ARM64_ - } - else - { - context->ContextFlags &= ~CONTEXT_EXCEPTION_ACTIVE; -#if defined(_ARM_) || defined(_ARM64_) || defined(_X86_) - context->ContextFlags |= CONTEXT_UNWOUND_TO_CALL; -#endif // _ARM_ || _ARM64_ - } - - // Update the passed in windows context to reflect the unwind - // - UnwindContextToWinContext(&cursor, context); - - // FreeBSD, NetBSD, OSX and Alpine appear to do two different things when unwinding - // 1: If it reaches where it cannot unwind anymore, say a - // managed frame. It will return 0, but also update the $pc - // 2: If it unwinds all the way to _start it will return - // 0 from the step, but $pc will stay the same. - // So we detect that here and set the $pc to NULL in that case. - // This is the default behavior of the libunwind on Linux. - if (st == 0 && CONTEXTGetPC(context) == curPc) - { - CONTEXTSetPC(context, 0); - } - - if (contextPointers != NULL) - { - GetContextPointers(&cursor, &unwContext, contextPointers); - } - return TRUE; -} - -struct ExceptionRecords -{ - CONTEXT ContextRecord; - EXCEPTION_RECORD ExceptionRecord; -}; - -// Max number of fallback contexts that are used when malloc fails to allocate ExceptionRecords structure -static const int MaxFallbackContexts = sizeof(size_t) * 8; -// Array of fallback contexts -static ExceptionRecords s_fallbackContexts[MaxFallbackContexts]; -// Bitmap used for allocating fallback contexts - bits set to 1 represent already allocated context. -static volatile size_t s_allocatedContextsBitmap = 0; - -/*++ -Function: - AllocateExceptionRecords - - Allocate EXCEPTION_RECORD and CONTEXT structures for an exception. -Parameters: - exceptionRecord - output pointer to the allocated exception record - contextRecord - output pointer to the allocated context record ---*/ -VOID -AllocateExceptionRecords(EXCEPTION_RECORD** exceptionRecord, CONTEXT** contextRecord) -{ - ExceptionRecords* records; - if (posix_memalign((void**)&records, alignof(ExceptionRecords), sizeof(ExceptionRecords)) != 0) - { - size_t bitmap; - size_t newBitmap; - int index; - - do - { - bitmap = s_allocatedContextsBitmap; - index = __builtin_ffsl(~bitmap) - 1; - if (index < 0) - { - PROCAbort(); - } - - newBitmap = bitmap | ((size_t)1 << index); - } - while (__sync_val_compare_and_swap(&s_allocatedContextsBitmap, bitmap, newBitmap) != bitmap); - - records = &s_fallbackContexts[index]; - } - - *contextRecord = &records->ContextRecord; - *exceptionRecord = &records->ExceptionRecord; -} - -/*++ -Function: - PAL_FreeExceptionRecords - - Free EXCEPTION_RECORD and CONTEXT structures of an exception that were allocated by the - AllocateExceptionRecords. -Parameters: - exceptionRecord - exception record - contextRecord - context record ---*/ -VOID -PALAPI -PAL_FreeExceptionRecords(IN EXCEPTION_RECORD *exceptionRecord, IN CONTEXT *contextRecord) -{ - // Both records are allocated at once and the allocated memory starts at the contextRecord - ExceptionRecords* records = (ExceptionRecords*)contextRecord; - if ((records >= &s_fallbackContexts[0]) && (records < &s_fallbackContexts[MaxFallbackContexts])) - { - int index = records - &s_fallbackContexts[0]; - __sync_fetch_and_and(&s_allocatedContextsBitmap, ~((size_t)1 << index)); - } - else - { - free(contextRecord); - } -} - -/*++ -Function: - RtlpRaiseException - -Parameters: - ExceptionRecord - the Windows exception record to throw - -Note: - The name of this function and the name of the ExceptionRecord - parameter is used in the sos lldb plugin code to read the exception - record. See coreclr\src\ToolBox\SOS\lldbplugin\services.cpp. - - This function must not be inlined or optimized so the below PAL_VirtualUnwind - calls end up with RaiseException caller's context and so the above debugger - code finds the function and ExceptionRecord parameter. ---*/ -PAL_NORETURN -__attribute__((noinline)) -__attribute__((optnone)) -static void -RtlpRaiseException(EXCEPTION_RECORD *ExceptionRecord, CONTEXT *ContextRecord) -{ - throw PAL_SEHException(ExceptionRecord, ContextRecord); -} - -/*++ -Function: - RaiseException - -See MSDN doc. ---*/ -// no PAL_NORETURN, as callers must assume this can return for continuable exceptions. -__attribute__((noinline)) -VOID -PALAPI -RaiseException(IN DWORD dwExceptionCode, - IN DWORD dwExceptionFlags, - IN DWORD nNumberOfArguments, - IN CONST ULONG_PTR *lpArguments) -{ - // PERF_ENTRY_ONLY is used here because RaiseException may or may not - // return. We can not get latency data without PERF_EXIT. For this reason, - // PERF_ENTRY_ONLY is used to profile frequency only. - PERF_ENTRY_ONLY(RaiseException); - ENTRY("RaiseException(dwCode=%#x, dwFlags=%#x, nArgs=%u, lpArguments=%p)\n", - dwExceptionCode, dwExceptionFlags, nNumberOfArguments, lpArguments); - - /* Validate parameters */ - if (dwExceptionCode & RESERVED_SEH_BIT) - { - WARN("Exception code %08x has bit 28 set; clearing it.\n", dwExceptionCode); - dwExceptionCode ^= RESERVED_SEH_BIT; - } - - if (nNumberOfArguments > EXCEPTION_MAXIMUM_PARAMETERS) - { - WARN("Number of arguments (%d) exceeds the limit " - "EXCEPTION_MAXIMUM_PARAMETERS (%d); ignoring extra parameters.\n", - nNumberOfArguments, EXCEPTION_MAXIMUM_PARAMETERS); - nNumberOfArguments = EXCEPTION_MAXIMUM_PARAMETERS; - } - - CONTEXT *contextRecord; - EXCEPTION_RECORD *exceptionRecord; - AllocateExceptionRecords(&exceptionRecord, &contextRecord); - - ZeroMemory(exceptionRecord, sizeof(EXCEPTION_RECORD)); - - exceptionRecord->ExceptionCode = dwExceptionCode; - exceptionRecord->ExceptionFlags = dwExceptionFlags; - exceptionRecord->ExceptionRecord = NULL; - exceptionRecord->ExceptionAddress = NULL; // will be set by RtlpRaiseException - exceptionRecord->NumberParameters = nNumberOfArguments; - if (nNumberOfArguments) - { - CopyMemory(exceptionRecord->ExceptionInformation, lpArguments, - nNumberOfArguments * sizeof(ULONG_PTR)); - } - - // Capture the context of RaiseException. - ZeroMemory(contextRecord, sizeof(CONTEXT)); - contextRecord->ContextFlags = CONTEXT_FULL; - CONTEXT_CaptureContext(contextRecord); - - // We have to unwind one level to get the actual context user code could be resumed at. - PAL_VirtualUnwind(contextRecord, NULL); - - exceptionRecord->ExceptionAddress = (void *)CONTEXTGetPC(contextRecord); - - RtlpRaiseException(exceptionRecord, contextRecord); - - LOGEXIT("RaiseException returns\n"); -} diff --git a/src/pal/src/exception/seh.cpp b/src/pal/src/exception/seh.cpp deleted file mode 100644 index b05707076..000000000 --- a/src/pal/src/exception/seh.cpp +++ /dev/null @@ -1,442 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*++ - - - -Module Name: - - seh.cpp - -Abstract: - - Implementation of exception API functions. - - - ---*/ - -#include "pal/thread.hpp" -#include "pal/handleapi.hpp" -#include "pal/seh.hpp" -#include "pal/dbgmsg.h" -#include "pal/critsect.h" -#include "pal/debug.h" -#include "pal/init.h" -#include "pal/process.h" -#include "pal/malloc.hpp" -#include "pal/signal.hpp" - -#if HAVE_MACH_EXCEPTIONS -#include "machexception.h" -#else -#include -#endif - -#include -#include -#include -#include -#include - -using namespace CorUnix; - -SET_DEFAULT_DEBUG_CHANNEL(EXCEPT); - -/* Constant and type definitions **********************************************/ - -/* Bit 28 of exception codes is reserved. */ -const UINT RESERVED_SEH_BIT = 0x800000; - -/* Internal variables definitions **********************************************/ - -PHARDWARE_EXCEPTION_HANDLER g_hardwareExceptionHandler = NULL; -// Function to check if an activation can be safely injected at a specified context -PHARDWARE_EXCEPTION_SAFETY_CHECK_FUNCTION g_safeExceptionCheckFunction = NULL; - -PGET_GCMARKER_EXCEPTION_CODE g_getGcMarkerExceptionCode = NULL; - -// Return address of the SEHProcessException, which is used to enable walking over -// the signal handler trampoline on some Unixes where the libunwind cannot do that. -void* g_SEHProcessExceptionReturnAddress = NULL; - -/* Internal function definitions **********************************************/ - -/*++ -Function : - SEHInitialize - - Initialize all SEH-related stuff (signals, etc) - -Parameters : - CPalThread * pthrCurrent : reference to the current thread. - PAL initialize flags - -Return value : - TRUE if SEH support initialization succeeded - FALSE otherwise ---*/ -BOOL -SEHInitialize (CPalThread *pthrCurrent, DWORD flags) -{ - if (!SEHInitializeSignals(flags)) - { - ERROR("SEHInitializeSignals failed!\n"); - SEHCleanup(); - return FALSE; - } - - return TRUE; -} - -/*++ -Function : - SEHCleanup - - Undo work done by SEHInitialize - -Parameters : - None - - (no return value) - ---*/ -VOID -SEHCleanup() -{ - TRACE("Cleaning up SEH\n"); - -#if HAVE_MACH_EXCEPTIONS - SEHCleanupExceptionPort(); -#endif - SEHCleanupSignals(); -} - -/*++ -Function: - PAL_SetHardwareExceptionHandler - - Register a hardware exception handler. - -Parameters: - handler - exception handler - -Return value: - None ---*/ -VOID -PALAPI -PAL_SetHardwareExceptionHandler( - IN PHARDWARE_EXCEPTION_HANDLER exceptionHandler, - IN PHARDWARE_EXCEPTION_SAFETY_CHECK_FUNCTION exceptionCheckFunction) -{ - g_hardwareExceptionHandler = exceptionHandler; - g_safeExceptionCheckFunction = exceptionCheckFunction; -} - -/*++ -Function: - PAL_SetGetGcMarkerExceptionCode - - Register a function that determines if the specified IP has code that is a GC marker for GCCover. - -Parameters: - getGcMarkerExceptionCode - the function to register - -Return value: - None ---*/ -VOID -PALAPI -PAL_SetGetGcMarkerExceptionCode( - IN PGET_GCMARKER_EXCEPTION_CODE getGcMarkerExceptionCode) -{ - g_getGcMarkerExceptionCode = getGcMarkerExceptionCode; -} - -EXTERN_C void ThrowExceptionFromContextInternal(CONTEXT* context, PAL_SEHException* ex); - -/*++ -Function: - PAL_ThrowExceptionFromContext - - This function creates a stack frame right below the target frame, restores all callee - saved registers from the passed in context, sets the RSP to that frame and sets the - return address to the target frame's RIP. - Then it uses the ThrowExceptionHelper to throw the passed in exception from that context. - -Parameters: - CONTEXT* context - context from which the exception will be thrown - PAL_SEHException* ex - the exception to throw. ---*/ -VOID -PALAPI -PAL_ThrowExceptionFromContext(CONTEXT* context, PAL_SEHException* ex) -{ - // We need to make a copy of the exception off stack, since the "ex" is located in one of the stack - // frames that will become obsolete by the ThrowExceptionFromContextInternal and the ThrowExceptionHelper - // could overwrite the "ex" object by stack e.g. when allocating the low level exception object for "throw". - static __thread BYTE threadLocalExceptionStorage[sizeof(PAL_SEHException)]; - ThrowExceptionFromContextInternal(context, new (threadLocalExceptionStorage) PAL_SEHException(std::move(*ex))); -} - -/*++ -Function: - ThrowExceptionHelper - - Helper function to throw the passed in exception. - It is called from the assembler function ThrowExceptionFromContextInternal - -Parameters: - PAL_SEHException* ex - the exception to throw. ---*/ -extern "C" -#ifdef _X86_ -void __fastcall ThrowExceptionHelper(PAL_SEHException* ex) -#else // _X86_ -void ThrowExceptionHelper(PAL_SEHException* ex) -#endif // !_X86_ -{ - throw std::move(*ex); -} - -/*++ -Function: - EnsureExceptionRecordsOnHeap - - Helper function to move records from stack to heap. - -Parameters: - PAL_SEHException* exception ---*/ -static void EnsureExceptionRecordsOnHeap(PAL_SEHException* exception) -{ - if( !exception->RecordsOnStack || - exception->ExceptionPointers.ExceptionRecord == NULL ) - { - return; - } - - CONTEXT* contextRecord = exception->ExceptionPointers.ContextRecord; - EXCEPTION_RECORD* exceptionRecord = exception->ExceptionPointers.ExceptionRecord; - - CONTEXT* contextRecordCopy; - EXCEPTION_RECORD* exceptionRecordCopy; - AllocateExceptionRecords(&exceptionRecordCopy, &contextRecordCopy); - - *exceptionRecordCopy = *exceptionRecord; - *contextRecordCopy = *contextRecord; - - exception->ExceptionPointers.ExceptionRecord = exceptionRecordCopy; - exception->ExceptionPointers.ContextRecord = contextRecordCopy; - exception->RecordsOnStack = false; -} - -/*++ -Function: - SEHProcessException - - Send the PAL exception to any handler registered. - -Parameters: - PAL_SEHException* exception - -Return value: - Returns TRUE if the exception happened in managed code and the execution should - continue (with possibly modified context). - Returns FALSE if the exception happened in managed code and it was not handled. - In case the exception was handled by calling a catch handler, it doesn't return at all. ---*/ -BOOL -SEHProcessException(PAL_SEHException* exception) -{ - g_SEHProcessExceptionReturnAddress = __builtin_return_address(0); - - CONTEXT* contextRecord = exception->GetContextRecord(); - EXCEPTION_RECORD* exceptionRecord = exception->GetExceptionRecord(); - - if (!IsInDebugBreak(exceptionRecord->ExceptionAddress)) - { - if (g_hardwareExceptionHandler != NULL) - { - _ASSERTE(g_safeExceptionCheckFunction != NULL); - // Check if it is safe to handle the hardware exception (the exception happened in managed code - // or in a jitter helper or it is a debugger breakpoint) - if (g_safeExceptionCheckFunction(contextRecord, exceptionRecord)) - { - if (exceptionRecord->ExceptionCode == EXCEPTION_ACCESS_VIOLATION) - { - // Check if the failed access has hit a stack guard page. In such case, it - // was a stack probe that detected that there is not enough stack left. - void* stackLimit = CPalThread::GetStackLimit(); - void* stackGuard = (void*)((size_t)stackLimit - getpagesize()); - void* violationAddr = (void*)exceptionRecord->ExceptionInformation[1]; - if ((violationAddr >= stackGuard) && (violationAddr < stackLimit)) - { - // The exception happened in the page right below the stack limit, - // so it is a stack overflow - (void)write(STDERR_FILENO, StackOverflowMessage, sizeof(StackOverflowMessage) - 1); - PROCAbort(); - } - } - - EnsureExceptionRecordsOnHeap(exception); - if (g_hardwareExceptionHandler(exception)) - { - // The exception happened in managed code and the execution should continue. - return TRUE; - } - - // The exception was a single step or a breakpoint and it was not handled by the debugger. - } - } - - if (CatchHardwareExceptionHolder::IsEnabled()) - { - EnsureExceptionRecordsOnHeap(exception); - PAL_ThrowExceptionFromContext(exception->GetContextRecord(), exception); - } - } - - // Unhandled hardware exception pointers->ExceptionRecord->ExceptionCode at pointers->ExceptionRecord->ExceptionAddress - return FALSE; -} - -/*++ -Function : - SEHEnable - - Enable SEH-related stuff on this thread - -Parameters: - CPalThread * pthrCurrent : reference to the current thread. - -Return value : - TRUE if enabling succeeded - FALSE otherwise ---*/ -extern "C" -PAL_ERROR SEHEnable(CPalThread *pthrCurrent) -{ -#if HAVE_MACH_EXCEPTIONS - return pthrCurrent->EnableMachExceptions(); -#elif defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) - // TODO: This needs to be implemented. Cannot put an ASSERT here - // because it will make other parts of PAL fail. - return NO_ERROR; -#else// HAVE_MACH_EXCEPTIONS -#error not yet implemented -#endif // HAVE_MACH_EXCEPTIONS -} - -/*++ -Function : - SEHDisable - - Disable SEH-related stuff on this thread - -Parameters: - CPalThread * pthrCurrent : reference to the current thread. - -Return value : - TRUE if enabling succeeded - FALSE otherwise ---*/ -extern "C" -PAL_ERROR SEHDisable(CPalThread *pthrCurrent) -{ -#if HAVE_MACH_EXCEPTIONS - return pthrCurrent->DisableMachExceptions(); - // TODO: This needs to be implemented. Cannot put an ASSERT here - // because it will make other parts of PAL fail. -#elif defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) - return NO_ERROR; -#else // HAVE_MACH_EXCEPTIONS -#error not yet implemented -#endif // HAVE_MACH_EXCEPTIONS -} - -/*++ - - CatchHardwareExceptionHolder implementation - ---*/ - -CatchHardwareExceptionHolder::CatchHardwareExceptionHolder() -{ - CPalThread *pThread = InternalGetCurrentThread(); - ++pThread->m_hardwareExceptionHolderCount; -} - -CatchHardwareExceptionHolder::~CatchHardwareExceptionHolder() -{ - CPalThread *pThread = InternalGetCurrentThread(); - --pThread->m_hardwareExceptionHolderCount; -} - -bool CatchHardwareExceptionHolder::IsEnabled() -{ - CPalThread *pThread = GetCurrentPalThread(); - return pThread ? pThread->IsHardwareExceptionsEnabled() : false; -} - -/*++ - - NativeExceptionHolderBase implementation - ---*/ - -#ifdef __llvm__ -__thread -#else // __llvm__ -__declspec(thread) -#endif // !__llvm__ -static NativeExceptionHolderBase *t_nativeExceptionHolderHead = nullptr; - -NativeExceptionHolderBase::NativeExceptionHolderBase() -{ - m_head = nullptr; - m_next = nullptr; -} - -NativeExceptionHolderBase::~NativeExceptionHolderBase() -{ - // Only destroy if Push was called - if (m_head != nullptr) - { - *m_head = m_next; - m_head = nullptr; - m_next = nullptr; - } -} - -void -NativeExceptionHolderBase::Push() -{ - NativeExceptionHolderBase **head = &t_nativeExceptionHolderHead; - m_head = head; - m_next = *head; - *head = this; -} - -NativeExceptionHolderBase * -NativeExceptionHolderBase::FindNextHolder(NativeExceptionHolderBase *currentHolder, void *stackLowAddress, void *stackHighAddress) -{ - NativeExceptionHolderBase *holder = (currentHolder == nullptr) ? t_nativeExceptionHolderHead : currentHolder->m_next; - - while (holder != nullptr) - { - if (((void *)holder >= stackLowAddress) && ((void *)holder < stackHighAddress)) - { - return holder; - } - // Get next holder - holder = holder->m_next; - } - - return nullptr; -} - -#include "seh-unwind.cpp" diff --git a/src/pal/src/exception/signal.cpp b/src/pal/src/exception/signal.cpp deleted file mode 100644 index 0a3840a47..000000000 --- a/src/pal/src/exception/signal.cpp +++ /dev/null @@ -1,986 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*++ - - - -Module Name: - - exception/signal.cpp - -Abstract: - - Signal handler implementation (map signals to exceptions) - - - ---*/ - -#include "pal/dbgmsg.h" -SET_DEFAULT_DEBUG_CHANNEL(EXCEPT); // some headers have code with asserts, so do this first - -#include "pal/corunix.hpp" -#include "pal/handleapi.hpp" -#include "pal/thread.hpp" -#include "pal/threadinfo.hpp" -#include "pal/threadsusp.hpp" -#include "pal/seh.hpp" -#include "pal/signal.hpp" - -#include "pal/palinternal.h" - -#include -#include - -#if !HAVE_MACH_EXCEPTIONS -#include "pal/init.h" -#include "pal/process.h" -#include "pal/debug.h" -#include "pal/virtual.h" -#include "pal/utils.h" - -#include -#include -#include -#include -#include - -#include "pal/context.h" - -#ifdef SIGRTMIN -#define INJECT_ACTIVATION_SIGNAL SIGRTMIN -#endif - -#if !defined(INJECT_ACTIVATION_SIGNAL) && defined(FEATURE_HIJACK) -#error FEATURE_HIJACK requires INJECT_ACTIVATION_SIGNAL to be defined -#endif -#endif // !HAVE_MACH_EXCEPTIONS - -using namespace CorUnix; - -/* local type definitions *****************************************************/ - -#if !HAVE_SIGINFO_T -/* This allows us to compile on platforms that don't have siginfo_t. - * Exceptions will work poorly on those platforms. */ -#warning Exceptions will work poorly on this platform -typedef void *siginfo_t; -#endif /* !HAVE_SIGINFO_T */ -typedef void (*SIGFUNC)(int, siginfo_t *, void *); - -#if !HAVE_MACH_EXCEPTIONS -// Return context and status for the signal_handler_worker. -struct SignalHandlerWorkerReturnPoint -{ - bool returnFromHandler; - CONTEXT context; -}; -#endif // !HAVE_MACH_EXCEPTIONS - -/* internal function declarations *********************************************/ - -static void sigterm_handler(int code, siginfo_t *siginfo, void *context); -#if !HAVE_MACH_EXCEPTIONS -static void sigill_handler(int code, siginfo_t *siginfo, void *context); -static void sigfpe_handler(int code, siginfo_t *siginfo, void *context); -static void sigsegv_handler(int code, siginfo_t *siginfo, void *context); -static void sigtrap_handler(int code, siginfo_t *siginfo, void *context); -static void sigbus_handler(int code, siginfo_t *siginfo, void *context); -static void sigint_handler(int code, siginfo_t *siginfo, void *context); -static void sigquit_handler(int code, siginfo_t *siginfo, void *context); - -static bool common_signal_handler(int code, siginfo_t *siginfo, void *sigcontext, int numParams, ...); - -#ifdef INJECT_ACTIVATION_SIGNAL -static void inject_activation_handler(int code, siginfo_t *siginfo, void *context); -#endif -#endif // !HAVE_MACH_EXCEPTIONS - -static void handle_signal(int signal_id, SIGFUNC sigfunc, struct sigaction *previousAction, int additionalFlags = 0, bool skipIgnored = false); -static void restore_signal(int signal_id, struct sigaction *previousAction); - -/* internal data declarations *********************************************/ - -static bool registered_sigterm_handler = false; - -struct sigaction g_previous_sigterm; -#if !HAVE_MACH_EXCEPTIONS -struct sigaction g_previous_sigill; -struct sigaction g_previous_sigtrap; -struct sigaction g_previous_sigfpe; -struct sigaction g_previous_sigbus; -struct sigaction g_previous_sigsegv; -struct sigaction g_previous_sigint; -struct sigaction g_previous_sigquit; - -#ifdef INJECT_ACTIVATION_SIGNAL -struct sigaction g_previous_activation; -#endif - -// Offset of the local variable containing pointer to windows style context in the common_signal_handler function. -// This offset is relative to the frame pointer. -int g_common_signal_handler_context_locvar_offset = 0; -#endif // !HAVE_MACH_EXCEPTIONS - -/* public function definitions ************************************************/ - -#if !HAVE_MACH_EXCEPTIONS -/*++ -Function : - EnsureSignalAlternateStack - - Ensure that alternate stack for signal handling is allocated for the current thread - -Parameters : - None - -Return : - TRUE in case of a success, FALSE otherwise ---*/ -BOOL EnsureSignalAlternateStack() -{ - stack_t oss; - - // Query the current alternate signal stack - int st = sigaltstack(NULL, &oss); - - if ((st == 0) && (oss.ss_flags == SS_DISABLE)) - { - // There is no alternate stack for SIGSEGV handling installed yet so allocate one - - // We include the size of the SignalHandlerWorkerReturnPoint in the alternate stack size since the - // context contained in it is large and the SIGSTKSZ was not sufficient on ARM64 during testing. - int altStackSize = SIGSTKSZ + ALIGN_UP(sizeof(SignalHandlerWorkerReturnPoint), 16) + GetVirtualPageSize(); -#ifdef HAS_ASAN - // Asan also uses alternate stack so we increase its size on the SIGSTKSZ * 4 that enough for asan - // (see kAltStackSize in compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cc) - altStackSize += SIGSTKSZ * 4; -#endif - void* altStack; - int st = posix_memalign(&altStack, GetVirtualPageSize(), altStackSize); - if (st == 0) - { - // create a guard page for the alternate stack - st = mprotect(altStack, GetVirtualPageSize(), PROT_NONE); - if (st == 0) - { - stack_t ss; - ss.ss_sp = (char*)altStack; - ss.ss_size = altStackSize; - ss.ss_flags = 0; - st = sigaltstack(&ss, NULL); - if (st != 0) - { - // Installation of the alternate stack failed, so revert the guard page protection - int st2 = mprotect(altStack, GetVirtualPageSize(), PROT_READ | PROT_WRITE); - _ASSERTE(st2 == 0); - } - } - - if (st != 0) - { - free(altStack); - } - } - } - - return (st == 0); -} - -/*++ -Function : - FreeSignalAlternateStack - - Free alternate stack for signal handling - -Parameters : - None - -Return : - None ---*/ -void FreeSignalAlternateStack() -{ - stack_t ss, oss; - ss.ss_flags = SS_DISABLE; - int st = sigaltstack(&ss, &oss); - if ((st == 0) && (oss.ss_flags != SS_DISABLE)) - { - int st = mprotect(oss.ss_sp, GetVirtualPageSize(), PROT_READ | PROT_WRITE); - _ASSERTE(st == 0); - free(oss.ss_sp); - } -} -#endif // !HAVE_MACH_EXCEPTIONS - -/*++ -Function : - SEHInitializeSignals - - Set up signal handlers to catch signals and translate them to exceptions - -Parameters : - None - -Return : - TRUE in case of a success, FALSE otherwise ---*/ -BOOL SEHInitializeSignals(DWORD flags) -{ - TRACE("Initializing signal handlers\n"); - -#if !HAVE_MACH_EXCEPTIONS - /* we call handle_signal for every possible signal, even - if we don't provide a signal handler. - - handle_signal will set SA_RESTART flag for specified signal. - Therefore, all signals will have SA_RESTART flag set, preventing - slow Unix system calls from being interrupted. On systems without - siginfo_t, SIGKILL and SIGSTOP can't be restarted, so we don't - handle those signals. Both the Darwin and FreeBSD man pages say - that SIGKILL and SIGSTOP can't be handled, but FreeBSD allows us - to register a handler for them anyway. We don't do that. - - see sigaction man page for more details - */ - handle_signal(SIGILL, sigill_handler, &g_previous_sigill); - handle_signal(SIGTRAP, sigtrap_handler, &g_previous_sigtrap); - handle_signal(SIGFPE, sigfpe_handler, &g_previous_sigfpe); - handle_signal(SIGBUS, sigbus_handler, &g_previous_sigbus); - // SIGSEGV handler runs on a separate stack so that we can handle stack overflow - handle_signal(SIGSEGV, sigsegv_handler, &g_previous_sigsegv, SA_ONSTACK); - // We don't setup a handler for SIGINT/SIGQUIT when those signals are ignored. - // Otherwise our child processes would reset to the default on exec causing them - // to terminate on these signals. - handle_signal(SIGINT, sigint_handler, &g_previous_sigint , 0 /* additionalFlags */, true /* skipIgnored */); - handle_signal(SIGQUIT, sigquit_handler, &g_previous_sigquit, 0 /* additionalFlags */, true /* skipIgnored */); - - if (!EnsureSignalAlternateStack()) - { - return FALSE; - } -#endif // !HAVE_MACH_EXCEPTIONS - - if (flags & PAL_INITIALIZE_REGISTER_SIGTERM_HANDLER) - { - handle_signal(SIGTERM, sigterm_handler, &g_previous_sigterm); - registered_sigterm_handler = true; - } - -#if !HAVE_MACH_EXCEPTIONS -#ifdef INJECT_ACTIVATION_SIGNAL - handle_signal(INJECT_ACTIVATION_SIGNAL, inject_activation_handler, &g_previous_activation); -#endif - - /* The default action for SIGPIPE is process termination. - Since SIGPIPE can be signaled when trying to write on a socket for which - the connection has been dropped, we need to tell the system we want - to ignore this signal. - - Instead of terminating the process, the system call which would had - issued a SIGPIPE will, instead, report an error and set errno to EPIPE. - */ - signal(SIGPIPE, SIG_IGN); -#endif // !HAVE_MACH_EXCEPTIONS - - return TRUE; -} - -/*++ -Function : - SEHCleanupSignals - - Restore default signal handlers - -Parameters : - None - - (no return value) - -note : -reason for this function is that during PAL_Terminate, we reach a point where -SEH isn't possible anymore (handle manager is off, etc). Past that point, -we can't avoid crashing on a signal. ---*/ -void SEHCleanupSignals() -{ - TRACE("Restoring default signal handlers\n"); - -#if !HAVE_MACH_EXCEPTIONS - restore_signal(SIGILL, &g_previous_sigill); - restore_signal(SIGTRAP, &g_previous_sigtrap); - restore_signal(SIGFPE, &g_previous_sigfpe); - restore_signal(SIGBUS, &g_previous_sigbus); - restore_signal(SIGSEGV, &g_previous_sigsegv); - restore_signal(SIGINT, &g_previous_sigint); - restore_signal(SIGQUIT, &g_previous_sigquit); -#endif // !HAVE_MACH_EXCEPTIONS - - if (registered_sigterm_handler) - { - restore_signal(SIGTERM, &g_previous_sigterm); - } - -#if !HAVE_MACH_EXCEPTIONS -#ifdef INJECT_ACTIVATION_SIGNAL - restore_signal(INJECT_ACTIVATION_SIGNAL, &g_previous_activation); -#endif -#endif // !HAVE_MACH_EXCEPTIONS -} - -/* internal function definitions **********************************************/ - -#if !HAVE_MACH_EXCEPTIONS -/*++ -Function : - sigill_handler - - handle SIGILL signal (EXCEPTION_ILLEGAL_INSTRUCTION, others?) - -Parameters : - POSIX signal handler parameter list ("man sigaction" for details) - - (no return value) ---*/ -static void sigill_handler(int code, siginfo_t *siginfo, void *context) -{ - if (PALIsInitialized()) - { - if (common_signal_handler(code, siginfo, context, 0)) - { - return; - } - } - - if (g_previous_sigill.sa_sigaction != NULL) - { - g_previous_sigill.sa_sigaction(code, siginfo, context); - } - else - { - // Restore the original or default handler and restart h/w exception - restore_signal(code, &g_previous_sigill); - } - - PROCNotifyProcessShutdown(); - PROCCreateCrashDumpIfEnabled(); -} - -/*++ -Function : - sigfpe_handler - - handle SIGFPE signal (division by zero, floating point exception) - -Parameters : - POSIX signal handler parameter list ("man sigaction" for details) - - (no return value) ---*/ -static void sigfpe_handler(int code, siginfo_t *siginfo, void *context) -{ - if (PALIsInitialized()) - { - if (common_signal_handler(code, siginfo, context, 0)) - { - return; - } - } - - if (g_previous_sigfpe.sa_sigaction != NULL) - { - g_previous_sigfpe.sa_sigaction(code, siginfo, context); - } - else - { - // Restore the original or default handler and restart h/w exception - restore_signal(code, &g_previous_sigfpe); - } - - PROCNotifyProcessShutdown(); - PROCCreateCrashDumpIfEnabled(); -} - -/*++ -Function : - signal_handler_worker - - Handles signal on the original stack where the signal occured. - Invoked via setcontext. - -Parameters : - POSIX signal handler parameter list ("man sigaction" for details) - returnPoint - context to which the function returns if the common_signal_handler returns - - (no return value) ---*/ -extern "C" void signal_handler_worker(int code, siginfo_t *siginfo, void *context, SignalHandlerWorkerReturnPoint* returnPoint) -{ - // TODO: First variable parameter says whether a read (0) or write (non-0) caused the - // fault. We must disassemble the instruction at record.ExceptionAddress - // to correctly fill in this value. - - // Unmask the activation signal now that we are running on the original stack of the thread - sigset_t signal_set; - sigemptyset(&signal_set); - sigaddset(&signal_set, INJECT_ACTIVATION_SIGNAL); - - int sigmaskRet = pthread_sigmask(SIG_UNBLOCK, &signal_set, NULL); - if (sigmaskRet != 0) - { - ASSERT("pthread_sigmask failed; error number is %d\n", sigmaskRet); - } - - returnPoint->returnFromHandler = common_signal_handler(code, siginfo, context, 2, (size_t)0, (size_t)siginfo->si_addr); - - // We are going to return to the alternate stack, so block the activation signal again - sigmaskRet = pthread_sigmask(SIG_BLOCK, &signal_set, NULL); - if (sigmaskRet != 0) - { - ASSERT("pthread_sigmask failed; error number is %d\n", sigmaskRet); - } - - RtlRestoreContext(&returnPoint->context, NULL); -} - -/*++ -Function : - sigsegv_handler - - handle SIGSEGV signal (EXCEPTION_ACCESS_VIOLATION, others) - -Parameters : - POSIX signal handler parameter list ("man sigaction" for details) - - (no return value) ---*/ -static void sigsegv_handler(int code, siginfo_t *siginfo, void *context) -{ - if (PALIsInitialized()) - { - // First check if we have a stack overflow - size_t sp = (size_t)GetNativeContextSP((native_context_t *)context); - size_t failureAddress = (size_t)siginfo->si_addr; - - // If the failure address is at most one page above or below the stack pointer, - // we have a stack overflow. - if ((failureAddress - (sp - GetVirtualPageSize())) < 2 * GetVirtualPageSize()) - { - (void)write(STDERR_FILENO, StackOverflowMessage, sizeof(StackOverflowMessage) - 1); - PROCAbort(); - } - - // Now that we know the SIGSEGV didn't happen due to a stack overflow, execute the common - // hardware signal handler on the original stack. - - // Establish a return point in case the common_signal_handler returns - - if (GetCurrentPalThread()) - { - volatile bool contextInitialization = true; - - void *ptr = alloca(sizeof(SignalHandlerWorkerReturnPoint) + alignof(SignalHandlerWorkerReturnPoint) - 1); - SignalHandlerWorkerReturnPoint *pReturnPoint = (SignalHandlerWorkerReturnPoint *)ALIGN_UP(ptr, alignof(SignalHandlerWorkerReturnPoint)); - RtlCaptureContext(&pReturnPoint->context); - - // When the signal handler worker completes, it uses setcontext to return to this point - - if (contextInitialization) - { - contextInitialization = false; - ExecuteHandlerOnOriginalStack(code, siginfo, context, pReturnPoint); - _ASSERTE(FALSE); // The ExecuteHandlerOnOriginalStack should never return - } - - if (pReturnPoint->returnFromHandler) - { - return; - } - } - else - { - // If thread isn't created by coreclr and has alternate signal stack GetCurrentPalThread() will return NULL too. - // But since in this case we don't handle hardware exceptions (IsSafeToHandleHardwareException returns false) - // we can call common_signal_handler on the alternate stack. - if (common_signal_handler(code, siginfo, context, 2, (size_t)0, (size_t)siginfo->si_addr)) - { - return; - } - } - } - - if (g_previous_sigsegv.sa_sigaction != NULL) - { - g_previous_sigsegv.sa_sigaction(code, siginfo, context); - } - else - { - // Restore the original or default handler and restart h/w exception - restore_signal(code, &g_previous_sigsegv); - } - - PROCNotifyProcessShutdown(); - PROCCreateCrashDumpIfEnabled(); -} - -/*++ -Function : - sigtrap_handler - - handle SIGTRAP signal (EXCEPTION_SINGLE_STEP, EXCEPTION_BREAKPOINT) - -Parameters : - POSIX signal handler parameter list ("man sigaction" for details) - - (no return value) ---*/ -static void sigtrap_handler(int code, siginfo_t *siginfo, void *context) -{ - if (PALIsInitialized()) - { - if (common_signal_handler(code, siginfo, context, 0)) - { - return; - } - } - - if (g_previous_sigtrap.sa_sigaction != NULL) - { - g_previous_sigtrap.sa_sigaction(code, siginfo, context); - } - else - { - // We abort instead of restore the original or default handler and returning - // because returning from a SIGTRAP handler continues execution past the trap. - PROCAbort(); - } - - PROCNotifyProcessShutdown(); - PROCCreateCrashDumpIfEnabled(); -} - -/*++ -Function : - sigbus_handler - - handle SIGBUS signal (EXCEPTION_ACCESS_VIOLATION?) - -Parameters : - POSIX signal handler parameter list ("man sigaction" for details) - - (no return value) ---*/ -static void sigbus_handler(int code, siginfo_t *siginfo, void *context) -{ - if (PALIsInitialized()) - { - // TODO: First variable parameter says whether a read (0) or write (non-0) caused the - // fault. We must disassemble the instruction at record.ExceptionAddress - // to correctly fill in this value. - if (common_signal_handler(code, siginfo, context, 2, (size_t)0, (size_t)siginfo->si_addr)) - { - return; - } - } - - if (g_previous_sigbus.sa_sigaction != NULL) - { - g_previous_sigbus.sa_sigaction(code, siginfo, context); - } - else - { - // Restore the original or default handler and restart h/w exception - restore_signal(code, &g_previous_sigbus); - } - - PROCNotifyProcessShutdown(); - PROCCreateCrashDumpIfEnabled(); -} - -/*++ -Function : - sigint_handler - - handle SIGINT signal - -Parameters : - POSIX signal handler parameter list ("man sigaction" for details) - - (no return value) ---*/ -static void sigint_handler(int code, siginfo_t *siginfo, void *context) -{ - PROCNotifyProcessShutdown(); - - // Restore the original or default handler and resend signal - restore_signal(code, &g_previous_sigint); - kill(gPID, code); -} - -/*++ -Function : - sigquit_handler - - handle SIGQUIT signal - -Parameters : - POSIX signal handler parameter list ("man sigaction" for details) - - (no return value) ---*/ -static void sigquit_handler(int code, siginfo_t *siginfo, void *context) -{ - PROCNotifyProcessShutdown(); - - // Restore the original or default handler and resend signal - restore_signal(code, &g_previous_sigquit); - kill(gPID, code); -} -#endif // !HAVE_MACH_EXCEPTIONS - -/*++ -Function : - sigterm_handler - - handle SIGTERM signal - -Parameters : - POSIX signal handler parameter list ("man sigaction" for details) - - (no return value) ---*/ -static void sigterm_handler(int code, siginfo_t *siginfo, void *context) -{ - if (PALIsInitialized()) - { - // g_pSynchronizationManager shouldn't be null if PAL is initialized. - _ASSERTE(g_pSynchronizationManager != nullptr); - - g_pSynchronizationManager->SendTerminationRequestToWorkerThread(); - } - else - { - if (g_previous_sigterm.sa_sigaction != NULL) - { - g_previous_sigterm.sa_sigaction(code, siginfo, context); - } - } -} - -#if !HAVE_MACH_EXCEPTIONS -#ifdef INJECT_ACTIVATION_SIGNAL -/*++ -Function : - inject_activation_handler - - Handle the INJECT_ACTIVATION_SIGNAL signal. This signal interrupts a running thread - so it can call the activation function that was specified when sending the signal. - -Parameters : - POSIX signal handler parameter list ("man sigaction" for details) - -(no return value) ---*/ -static void inject_activation_handler(int code, siginfo_t *siginfo, void *context) -{ - // Only accept activations from the current process - if (g_activationFunction != NULL && siginfo->si_pid == getpid()) - { - _ASSERTE(g_safeActivationCheckFunction != NULL); - - native_context_t *ucontext = (native_context_t *)context; - - CONTEXT winContext; - CONTEXTFromNativeContext( - ucontext, - &winContext, - CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_FLOATING_POINT); - - if (g_safeActivationCheckFunction(CONTEXTGetPC(&winContext), /* checkingCurrentThread */ TRUE)) - { - g_activationFunction(&winContext); - // Activation function may have modified the context, so update it. - CONTEXTToNativeContext(&winContext, ucontext); - } - } - else if (g_previous_activation.sa_sigaction != NULL) - { - g_previous_activation.sa_sigaction(code, siginfo, context); - } -} -#endif - -/*++ -Function : - InjectActivationInternal - - Interrupt the specified thread and have it call the activationFunction passed in - -Parameters : - pThread - target PAL thread - activationFunction - function to call - -(no return value) ---*/ -PAL_ERROR InjectActivationInternal(CorUnix::CPalThread* pThread) -{ -#ifdef INJECT_ACTIVATION_SIGNAL - int status = pthread_kill(pThread->GetPThreadSelf(), INJECT_ACTIVATION_SIGNAL); - if (status != 0) - { - // Failure to send the signal is fatal. There are only two cases when sending - // the signal can fail. First, if the signal ID is invalid and second, - // if the thread doesn't exist anymore. - PROCAbort(); - } - - return NO_ERROR; -#else - return ERROR_CANCELLED; -#endif -} - -/*++ -Function : - signal_ignore_handler - - Simple signal handler which does nothing - -Parameters : - POSIX signal handler parameter list ("man sigaction" for details) - -(no return value) ---*/ -static void signal_ignore_handler(int code, siginfo_t *siginfo, void *context) -{ -} - - -void PAL_IgnoreProfileSignal(int signalNum) -{ -#if !HAVE_MACH_EXCEPTIONS - // Add a signal handler which will ignore signals - // This will allow signal to be used as a marker in perf recording. - // This will be used as an aid to synchronize recorded profile with - // test cases - // - // signal(signalNum, SGN_IGN) can not be used here. It will ignore - // the signal in kernel space and therefore generate no recordable - // event for profiling. Preventing it being used for profile - // synchronization - // - // Since this is only used in rare circumstances no attempt to - // restore the old handler will be made - handle_signal(signalNum, signal_ignore_handler, 0); -#endif -} - - -/*++ -Function : - SEHSetSafeState - - specify whether the current thread is in a state where exception handling - of signals can be done safely - -Parameters: - BOOL state : TRUE if the thread is safe, FALSE otherwise - -(no return value) ---*/ -void SEHSetSafeState(CPalThread *pthrCurrent, BOOL state) -{ - if (NULL == pthrCurrent) - { - ASSERT( "Unable to get the thread object.\n" ); - return; - } - pthrCurrent->sehInfo.safe_state = state; -} - -/*++ -Function : - SEHGetSafeState - - determine whether the current thread is in a state where exception handling - of signals can be done safely - - (no parameters) - -Return value : - TRUE if the thread is in a safe state, FALSE otherwise ---*/ -BOOL SEHGetSafeState(CPalThread *pthrCurrent) -{ - if (NULL == pthrCurrent) - { - ASSERT( "Unable to get the thread object.\n" ); - return FALSE; - } - return pthrCurrent->sehInfo.safe_state; -} - -/*++ -Function : - common_signal_handler - - common code for all signal handlers - -Parameters : - int code : signal received - siginfo_t *siginfo : siginfo passed to the signal handler - void *context : context structure passed to the signal handler - int numParams : number of variable parameters of the exception - ... : variable parameters of the exception (each of size_t type) - - Returns true if the execution should continue or false if the exception was unhandled -Note: - the "pointers" parameter should contain a valid exception record pointer, - but the ContextRecord pointer will be overwritten. ---*/ -__attribute__((noinline)) -static bool common_signal_handler(int code, siginfo_t *siginfo, void *sigcontext, int numParams, ...) -{ - sigset_t signal_set; - CONTEXT signalContextRecord; - EXCEPTION_RECORD exceptionRecord; - native_context_t *ucontext; - - ucontext = (native_context_t *)sigcontext; - g_common_signal_handler_context_locvar_offset = (int)((char*)&signalContextRecord - (char*)__builtin_frame_address(0)); - - exceptionRecord.ExceptionCode = CONTEXTGetExceptionCodeForSignal(siginfo, ucontext); - exceptionRecord.ExceptionFlags = EXCEPTION_IS_SIGNAL; - exceptionRecord.ExceptionRecord = NULL; - exceptionRecord.ExceptionAddress = GetNativeContextPC(ucontext); - exceptionRecord.NumberParameters = numParams; - - va_list params; - va_start(params, numParams); - - for (int i = 0; i < numParams; i++) - { - exceptionRecord.ExceptionInformation[i] = va_arg(params, size_t); - } - - // Pre-populate context with data from current frame, because ucontext doesn't have some data (e.g. SS register) - // which is required for restoring context - RtlCaptureContext(&signalContextRecord); - - ULONG contextFlags = CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_FLOATING_POINT; - -#if defined(_AMD64_) - contextFlags |= CONTEXT_XSTATE; -#endif - - // Fill context record with required information. from pal.h: - // On non-Win32 platforms, the CONTEXT pointer in the - // PEXCEPTION_POINTERS will contain at least the CONTEXT_CONTROL registers. - CONTEXTFromNativeContext(ucontext, &signalContextRecord, contextFlags); - - /* Unmask signal so we can receive it again */ - sigemptyset(&signal_set); - sigaddset(&signal_set, code); - int sigmaskRet = pthread_sigmask(SIG_UNBLOCK, &signal_set, NULL); - if (sigmaskRet != 0) - { - ASSERT("pthread_sigmask failed; error number is %d\n", sigmaskRet); - } - - signalContextRecord.ContextFlags |= CONTEXT_EXCEPTION_ACTIVE; - - // The exception object takes ownership of the exceptionRecord and contextRecord - PAL_SEHException exception(&exceptionRecord, &signalContextRecord, true); - - if (SEHProcessException(&exception)) - { - // Exception handling may have modified the context, so update it. - CONTEXTToNativeContext(exception.ExceptionPointers.ContextRecord, ucontext); - return true; - } - - return false; -} -#endif // !HAVE_MACH_EXCEPTIONS - -/*++ -Function : - handle_signal - - register handler for specified signal - -Parameters : - int signal_id : signal to handle - SIGFUNC sigfunc : signal handler - previousAction : previous sigaction struct - - (no return value) - -note : if sigfunc is NULL, the default signal handler is restored ---*/ -void handle_signal(int signal_id, SIGFUNC sigfunc, struct sigaction *previousAction, int additionalFlags, bool skipIgnored) -{ - struct sigaction newAction; - - newAction.sa_flags = SA_RESTART | additionalFlags; -#if HAVE_SIGINFO_T - newAction.sa_handler = NULL; - newAction.sa_sigaction = sigfunc; - newAction.sa_flags |= SA_SIGINFO; -#else /* HAVE_SIGINFO_T */ - newAction.sa_handler = SIG_DFL; -#endif /* HAVE_SIGINFO_T */ - sigemptyset(&newAction.sa_mask); - -#ifdef INJECT_ACTIVATION_SIGNAL - if ((additionalFlags & SA_ONSTACK) != 0) - { - // A handler that runs on a separate stack should not be interrupted by the activation signal - // until it switches back to the regular stack, since that signal's handler would run on the - // limited separate stack and likely run into a stack overflow. - sigaddset(&newAction.sa_mask, INJECT_ACTIVATION_SIGNAL); - } -#endif - - if (skipIgnored) - { - if (-1 == sigaction(signal_id, NULL, previousAction)) - { - ASSERT("handle_signal: sigaction() call failed with error code %d (%s)\n", - errno, strerror(errno)); - } - else if (previousAction->sa_handler == SIG_IGN) - { - return; - } - } - - if (-1 == sigaction(signal_id, &newAction, previousAction)) - { - ASSERT("handle_signal: sigaction() call failed with error code %d (%s)\n", - errno, strerror(errno)); - } -} - -/*++ -Function : - restore_signal - - restore handler for specified signal - -Parameters : - int signal_id : signal to handle - previousAction : previous sigaction struct to restore - - (no return value) ---*/ -void restore_signal(int signal_id, struct sigaction *previousAction) -{ - if (-1 == sigaction(signal_id, previousAction, NULL)) - { - ASSERT("restore_signal: sigaction() call failed with error code %d (%s)\n", - errno, strerror(errno)); - } -} diff --git a/src/pal/src/file/directory.cpp b/src/pal/src/file/directory.cpp index 8e54f94d6..690e31555 100644 --- a/src/pal/src/file/directory.cpp +++ b/src/pal/src/file/directory.cpp @@ -549,10 +549,10 @@ CreateDirectoryA( goto done; } - unixPathName = PAL__strdup(lpPathName); + unixPathName = strdup(lpPathName); if (unixPathName == NULL ) { - ERROR("PAL__strdup() failed\n"); + ERROR("strdup() failed\n"); dwLastError = ERROR_NOT_ENOUGH_MEMORY; goto done; } @@ -666,10 +666,10 @@ SetCurrentDirectoryA( goto done; } - unixPathName = PAL__strdup(lpPathName); + unixPathName = strdup(lpPathName); if (unixPathName == NULL ) { - ERROR("PAL__strdup() failed\n"); + ERROR("strdup() failed\n"); dwLastError = ERROR_NOT_ENOUGH_MEMORY; goto done; } diff --git a/src/pal/src/handlemgr/handleapi.cpp b/src/pal/src/handlemgr/handleapi.cpp index 6b99a85cf..0eaae5be7 100644 --- a/src/pal/src/handlemgr/handleapi.cpp +++ b/src/pal/src/handlemgr/handleapi.cpp @@ -21,7 +21,6 @@ Abstract: #include "pal/handleapi.hpp" #include "pal/handlemgr.hpp" #include "pal/thread.hpp" -#include "pal/procobj.hpp" #include "pal/dbgmsg.h" #include "pal/process.h" @@ -29,237 +28,11 @@ using namespace CorUnix; SET_DEFAULT_DEBUG_CHANNEL(HANDLE); -CAllowedObjectTypes aotDuplicateHandle(TRUE); - PAL_ERROR CloseSpecialHandle( HANDLE hObject ); -/*++ -Function: - DuplicateHandle - -See MSDN doc. - -PAL-specific behavior : - -Source and Target process needs to be the current process. - -lpTargetHandle must be non-NULL - -dwDesiredAccess is ignored - -bInheritHandle must be FALSE - -dwOptions must be a combo of DUPLICATE_SAME_ACCESS and - DUPLICATE_CLOSE_SOURCE - ---*/ -BOOL -PALAPI -DuplicateHandle( - IN HANDLE hSourceProcessHandle, - IN HANDLE hSourceHandle, - IN HANDLE hTargetProcessHandle, - OUT LPHANDLE lpTargetHandle, - IN DWORD dwDesiredAccess, - IN BOOL bInheritHandle, - IN DWORD dwOptions) -{ - PAL_ERROR palError; - CPalThread *pThread; - - PERF_ENTRY(DuplicateHandle); - ENTRY("DuplicateHandle( hSrcProcHandle=%p, hSrcHandle=%p, " - "hTargetProcHandle=%p, lpTargetHandle=%p, dwAccess=%#x, " - "bInheritHandle=%d, dwOptions=%#x) \n", hSourceProcessHandle, - hSourceHandle, hTargetProcessHandle, lpTargetHandle, - dwDesiredAccess, bInheritHandle, dwOptions); - - pThread = InternalGetCurrentThread(); - - palError = InternalDuplicateHandle( - pThread, - hSourceProcessHandle, - hSourceHandle, - hTargetProcessHandle, - lpTargetHandle, - dwDesiredAccess, - bInheritHandle, - dwOptions - ); - - if (NO_ERROR != palError) - { - pThread->SetLastError(palError); - } - - LOGEXIT("DuplicateHandle returns BOOL %d\n", (NO_ERROR == palError)); - PERF_EXIT(DuplicateHandle); - return (NO_ERROR == palError); -} - -PAL_ERROR -CorUnix::InternalDuplicateHandle( - CPalThread *pThread, - HANDLE hSourceProcess, - HANDLE hSource, - HANDLE hTargetProcess, - LPHANDLE phDuplicate, - DWORD dwDesiredAccess, - BOOL bInheritHandle, - DWORD dwOptions - ) -{ - PAL_ERROR palError = NO_ERROR; - IPalObject *pobjSource = NULL; - - DWORD source_process_id; - DWORD target_process_id; - DWORD cur_process_id; - - cur_process_id = GetCurrentProcessId(); - source_process_id = PROCGetProcessIDFromHandle(hSourceProcess); - target_process_id = PROCGetProcessIDFromHandle(hTargetProcess); - - /* Check validity of process handles */ - if (0 == source_process_id || 0 == target_process_id) - { - ASSERT("Can't duplicate handle: invalid source or destination process"); - palError = ERROR_INVALID_PARAMETER; - goto InternalDuplicateHandleExit; - } - - /* At least source or target process should be the current process. */ - if (source_process_id != cur_process_id - && target_process_id != cur_process_id) - { - ASSERT("Can't duplicate handle : neither source or destination" - "processes are from current process"); - palError = ERROR_INVALID_PARAMETER; - goto InternalDuplicateHandleExit; - } - - if (FALSE != bInheritHandle) - { - ASSERT("Can't duplicate handle : bInheritHandle is not FALSE.\n"); - palError = ERROR_INVALID_PARAMETER; - goto InternalDuplicateHandleExit; - } - - if (dwOptions & ~(DUPLICATE_SAME_ACCESS | DUPLICATE_CLOSE_SOURCE)) - { - ASSERT( - "Can't duplicate handle : dwOptions is %#x which is not " - "a subset of (DUPLICATE_SAME_ACCESS|DUPLICATE_CLOSE_SOURCE) " - "(%#x).\n", - dwOptions, - DUPLICATE_SAME_ACCESS | DUPLICATE_CLOSE_SOURCE); - palError = ERROR_INVALID_PARAMETER; - goto InternalDuplicateHandleExit; - } - - if (0 == (dwOptions & DUPLICATE_SAME_ACCESS)) - { - ASSERT( - "Can't duplicate handle : dwOptions is %#x which does not " - "include DUPLICATE_SAME_ACCESS (%#x).\n", - dwOptions, - DUPLICATE_SAME_ACCESS); - palError = ERROR_INVALID_PARAMETER; - goto InternalDuplicateHandleExit; - } - - if (NULL == phDuplicate) - { - ASSERT("Can't duplicate handle : lpTargetHandle is NULL.\n"); - goto InternalDuplicateHandleExit; - } - - /* Since handles can be remoted to others processes using PAL_LocalHsndleToRemote - and PAL_RemoteHandleToLocal, DuplicateHandle needs some special handling - when this scenario occurs. - - if hSourceProcessHandle is from another process OR - hTargetProcessHandle is from another process but both aren't - ( handled above ) return hSourceHandle. - */ - if (source_process_id != cur_process_id - || target_process_id != cur_process_id) - { - *phDuplicate = hSource; - palError = NO_ERROR; - goto InternalDuplicateHandleExit; - } - - // - // Obtain the source IPalObject - // - - if (!HandleIsSpecial(hSource)) - { - palError = g_pObjectManager->ReferenceObjectByHandle( - pThread, - hSource, - &aotDuplicateHandle, - dwDesiredAccess, - &pobjSource - ); - - if (NO_ERROR != palError) - { - ERROR("Unable to get object for source handle %p (%i)\n", hSource, palError); - goto InternalDuplicateHandleExit; - } - } - else if (hPseudoCurrentProcess == hSource) - { - TRACE("Duplicating process pseudo handle(%p)\n", hSource); - - pobjSource = g_pobjProcess; - pobjSource->AddReference(); - } - else if (hPseudoCurrentThread == hSource) - { - TRACE("Duplicating thread pseudo handle(%p)\n", hSource); - - pobjSource = pThread->GetThreadObject(); - pobjSource->AddReference(); - } - else - { - ASSERT("Duplication not supported for this special handle (%p)\n", hSource); - palError = ERROR_INVALID_HANDLE; - goto InternalDuplicateHandleExit; - } - - palError = g_pObjectManager->ObtainHandleForObject( - pThread, - pobjSource, - dwDesiredAccess, - bInheritHandle, - NULL, - phDuplicate - ); - -InternalDuplicateHandleExit: - - if (NULL != pobjSource) - { - pobjSource->ReleaseReference(pThread); - } - - if (dwOptions & DUPLICATE_CLOSE_SOURCE) - { - // - // Since DUPLICATE_CLOSE_SOURCE was specified the source handle - // MUST be closed, even if an error occurred during the duplication - // process - // - - TRACE("DuplicateHandle closing source handle %p\n", hSource); - InternalCloseHandle(pThread, hSource); - } - - return palError; -} - /*++ Function: CloseHandle diff --git a/src/pal/src/include/pal/context.h b/src/pal/src/include/pal/context.h deleted file mode 100644 index a488e0af0..000000000 --- a/src/pal/src/include/pal/context.h +++ /dev/null @@ -1,707 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*++ - - - -Module Name: - - include/pal/context.h - -Abstract: - - Header file for thread context utility functions. - - - ---*/ - -#ifndef _PAL_CONTEXT_H_ -#define _PAL_CONTEXT_H_ - -#ifdef __cplusplus -extern "C" -{ -#endif // __cplusplus - -#include -#include - -#if !HAVE_MACH_EXCEPTIONS -/* A type to wrap the native context type, which is ucontext_t on some - * platforms and another type elsewhere. */ -#if HAVE_UCONTEXT_T -#include - -typedef ucontext_t native_context_t; -#else // HAVE_UCONTEXT_T -#error Native context type is not known on this platform! -#endif // HAVE_UCONTEXT_T - -#if defined(XSTATE_SUPPORTED) && !HAVE_PUBLIC_XSTATE_STRUCT -namespace asm_sigcontext -{ -#include -}; -using asm_sigcontext::_fpx_sw_bytes; -using asm_sigcontext::_xstate; -#endif // defined(XSTATE_SUPPORTED) && !HAVE_PUBLIC_XSTATE_STRUCT - -#else // !HAVE_MACH_EXCEPTIONS -#include -#include -#endif // !HAVE_MACH_EXCEPTIONS else - -#if HAVE___GREGSET_T - -#ifdef BIT64 -#define MCREG_Rbx(mc) ((mc).__gregs[_REG_RBX]) -#define MCREG_Rcx(mc) ((mc).__gregs[_REG_RCX]) -#define MCREG_Rdx(mc) ((mc).__gregs[_REG_RDX]) -#define MCREG_Rsi(mc) ((mc).__gregs[_REG_RSI]) -#define MCREG_Rdi(mc) ((mc).__gregs[_REG_RDI]) -#define MCREG_Rbp(mc) ((mc).__gregs[_REG_RBP]) -#define MCREG_Rax(mc) ((mc).__gregs[_REG_RAX]) -#define MCREG_Rip(mc) ((mc).__gregs[_REG_RIP]) -#define MCREG_Rsp(mc) ((mc).__gregs[_REG_RSP]) -#define MCREG_SegCs(mc) ((mc).__gregs[_REG_CS]) -#define MCREG_SegSs(mc) ((mc).__gregs[_REG_SS]) -#define MCREG_R8(mc) ((mc).__gregs[_REG_R8]) -#define MCREG_R9(mc) ((mc).__gregs[_REG_R9]) -#define MCREG_R10(mc) ((mc).__gregs[_REG_R10]) -#define MCREG_R11(mc) ((mc).__gregs[_REG_R11]) -#define MCREG_R12(mc) ((mc).__gregs[_REG_R12]) -#define MCREG_R13(mc) ((mc).__gregs[_REG_R13]) -#define MCREG_R14(mc) ((mc).__gregs[_REG_R14]) -#define MCREG_R15(mc) ((mc).__gregs[_REG_R15]) -#define MCREG_EFlags(mc) ((mc).__gregs[_REG_RFLAGS]) - -#define FPREG_Xmm(uc, index) *(M128A*)&(((struct fxsave*)(&(uc)->uc_mcontext.__fpregs))->fx_xmm[index]) - -#define FPREG_St(uc, index) *(M128A*)&(((struct fxsave*)(&(uc)->uc_mcontext.__fpregs))->fx_87_ac[index]) - -#define FPREG_ControlWord(uc) (((struct fxsave*)(&(uc)->uc_mcontext.__fpregs))->fx_cw) -#define FPREG_StatusWord(uc) (((struct fxsave*)(&(uc)->uc_mcontext.__fpregs))->fx_sw) -#define FPREG_TagWord(uc) (((struct fxsave*)(&(uc)->uc_mcontext.__fpregs))->fx_tw) -#define FPREG_ErrorOffset(uc) (*(DWORD*) &(((struct fxsave*)(&(uc)->uc_mcontext.__fpregs))->fx_ip)) -#define FPREG_ErrorSelector(uc) *((WORD*) &(((struct fxsave*)(&(uc)->uc_mcontext.__fpregs))->fx_ip) + 2) -#define FPREG_DataOffset(uc) (*(DWORD*) &(((struct fxsave*)(&(uc)->uc_mcontext.__fpregs))->fx_dp)) -#define FPREG_DataSelector(uc) *((WORD*) &(((struct fxsave*)(&(uc)->uc_mcontext.__fpregs))->fx_dp) + 2) -#define FPREG_MxCsr(uc) (((struct fxsave*)(&(uc)->uc_mcontext.__fpregs))->fx_mxcsr) -#define FPREG_MxCsr_Mask(uc) (((struct fxsave*)(&(uc)->uc_mcontext.__fpregs))->fx_mxcsr_mask) - -#else // BIT64 - -#define MCREG_Ebx(mc) ((mc).__gregs[_REG_EBX]) -#define MCREG_Ecx(mc) ((mc).__gregs[_REG_ECX]) -#define MCREG_Edx(mc) ((mc).__gregs[_REG_EDX]) -#define MCREG_Esi(mc) ((mc).__gregs[_REG_ESI]) -#define MCREG_Edi(mc) ((mc).__gregs[_REG_EDI]) -#define MCREG_Ebp(mc) ((mc).__gregs[_REG_EBP]) -#define MCREG_Eax(mc) ((mc).__gregs[_REG_EAX]) -#define MCREG_Eip(mc) ((mc).__gregs[_REG_EIP]) -#define MCREG_Esp(mc) ((mc).__gregs[_REG_ESP]) -#define MCREG_SegCs(mc) ((mc).__gregs[_REG_CS]) -#define MCREG_SegSs(mc) ((mc).__gregs[_REG_SS]) -#define MCREG_EFlags(mc) ((mc).__gregs[_REG_RFLAGS]) - -#endif // BIT64 - -#elif HAVE_GREGSET_T - -#ifdef BIT64 -#define MCREG_Rbx(mc) ((mc).gregs[REG_RBX]) -#define MCREG_Rcx(mc) ((mc).gregs[REG_RCX]) -#define MCREG_Rdx(mc) ((mc).gregs[REG_RDX]) -#define MCREG_Rsi(mc) ((mc).gregs[REG_RSI]) -#define MCREG_Rdi(mc) ((mc).gregs[REG_RDI]) -#define MCREG_Rbp(mc) ((mc).gregs[REG_RBP]) -#define MCREG_Rax(mc) ((mc).gregs[REG_RAX]) -#define MCREG_Rip(mc) ((mc).gregs[REG_RIP]) -#define MCREG_Rsp(mc) ((mc).gregs[REG_RSP]) -#define MCREG_SegCs(mc) (*(WORD*)&((mc).gregs[REG_CSGSFS])) -#define MCREG_R8(mc) ((mc).gregs[REG_R8]) -#define MCREG_R9(mc) ((mc).gregs[REG_R9]) -#define MCREG_R10(mc) ((mc).gregs[REG_R10]) -#define MCREG_R11(mc) ((mc).gregs[REG_R11]) -#define MCREG_R12(mc) ((mc).gregs[REG_R12]) -#define MCREG_R13(mc) ((mc).gregs[REG_R13]) -#define MCREG_R14(mc) ((mc).gregs[REG_R14]) -#define MCREG_R15(mc) ((mc).gregs[REG_R15]) - -#define FPREG_Fpstate(uc) ((uc)->uc_mcontext.fpregs) -#define FPREG_Xmm(uc, index) *(M128A*)&(FPREG_Fpstate(uc)->_xmm[index]) - -#define FPREG_St(uc, index) *(M128A*)&(FPREG_Fpstate(uc)->_st[index]) - -#define FPREG_ControlWord(uc) (FPREG_Fpstate(uc)->cwd) -#define FPREG_StatusWord(uc) (FPREG_Fpstate(uc)->swd) -#define FPREG_TagWord(uc) (FPREG_Fpstate(uc)->ftw) -#define FPREG_ErrorOffset(uc) *(DWORD*)&(FPREG_Fpstate(uc)->rip) -#define FPREG_ErrorSelector(uc) *(((WORD*)&(FPREG_Fpstate(uc)->rip)) + 2) -#define FPREG_DataOffset(uc) *(DWORD*)&(FPREG_Fpstate(uc)->rdp) -#define FPREG_DataSelector(uc) *(((WORD*)&(FPREG_Fpstate(uc)->rdp)) + 2) -#define FPREG_MxCsr(uc) (FPREG_Fpstate(uc)->mxcsr) -#define FPREG_MxCsr_Mask(uc) (FPREG_Fpstate(uc)->mxcr_mask) - -///////////////////// -// Extended state - -#ifdef XSTATE_SUPPORTED - -#if HAVE_FPSTATE_GLIBC_RESERVED1 -#define FPSTATE_RESERVED __glibc_reserved1 -#else -#define FPSTATE_RESERVED padding -#endif - -// The mask for YMM registers presence flag stored in the xstate_bv. On current Linuxes, this definition is -// only in internal headers, so we define it here. The xstate_bv is extracted from the processor xstate bit -// vector register, so the value is OS independent. -#ifndef XSTATE_YMM -#define XSTATE_YMM 4 -#endif - -inline _fpx_sw_bytes *FPREG_FpxSwBytes(const ucontext_t *uc) -{ - // Bytes 464..511 in the FXSAVE format are available for software to use for any purpose. In this case, they are used to - // indicate information about extended state. - _ASSERTE(reinterpret_cast(&FPREG_Fpstate(uc)->FPSTATE_RESERVED[12]) - reinterpret_cast(FPREG_Fpstate(uc)) == 464); - - _ASSERTE(FPREG_Fpstate(uc) != nullptr); - - return reinterpret_cast<_fpx_sw_bytes *>(&FPREG_Fpstate(uc)->FPSTATE_RESERVED[12]); -} - -inline UINT32 FPREG_ExtendedSize(const ucontext_t *uc) -{ - _ASSERTE(FPREG_FpxSwBytes(uc)->magic1 == FP_XSTATE_MAGIC1); - return FPREG_FpxSwBytes(uc)->extended_size; -} - -inline bool FPREG_HasYmmRegisters(const ucontext_t *uc) -{ - // See comments in /usr/include/x86_64-linux-gnu/asm/sigcontext.h for info on how to detect if extended state is present - static_assert_no_msg(FP_XSTATE_MAGIC2_SIZE == sizeof(UINT32)); - - if (FPREG_FpxSwBytes(uc)->magic1 != FP_XSTATE_MAGIC1) - { - return false; - } - - UINT32 extendedSize = FPREG_ExtendedSize(uc); - if (extendedSize < sizeof(_xstate)) - { - return false; - } - - _ASSERTE(extendedSize >= FP_XSTATE_MAGIC2_SIZE); - if (*reinterpret_cast(reinterpret_cast(FPREG_Fpstate(uc)) + (extendedSize - FP_XSTATE_MAGIC2_SIZE)) - != FP_XSTATE_MAGIC2) - { - return false; - } - - return (FPREG_FpxSwBytes(uc)->xstate_bv & XSTATE_YMM) != 0; -} - -inline void *FPREG_Xstate_Ymmh(const ucontext_t *uc) -{ - static_assert_no_msg(sizeof(reinterpret_cast<_xstate *>(FPREG_Fpstate(uc))->ymmh.ymmh_space) == 16 * 16); - _ASSERTE(FPREG_HasYmmRegisters(uc)); - - return reinterpret_cast<_xstate *>(FPREG_Fpstate(uc))->ymmh.ymmh_space; -} - -#endif // XSTATE_SUPPORTED - -///////////////////// - -#else // BIT64 - -#define MCREG_Ebx(mc) ((mc).gregs[REG_EBX]) -#define MCREG_Ecx(mc) ((mc).gregs[REG_ECX]) -#define MCREG_Edx(mc) ((mc).gregs[REG_EDX]) -#define MCREG_Esi(mc) ((mc).gregs[REG_ESI]) -#define MCREG_Edi(mc) ((mc).gregs[REG_EDI]) -#define MCREG_Ebp(mc) ((mc).gregs[REG_EBP]) -#define MCREG_Eax(mc) ((mc).gregs[REG_EAX]) -#define MCREG_Eip(mc) ((mc).gregs[REG_EIP]) -#define MCREG_Esp(mc) ((mc).gregs[REG_ESP]) -#define MCREG_SegCs(mc) ((mc).gregs[REG_CS]) -#define MCREG_SegSs(mc) ((mc).gregs[REG_SS]) - -#endif // BIT64 - -#define MCREG_EFlags(mc) ((mc).gregs[REG_EFL]) - -#else // HAVE_GREGSET_T - -#ifdef BIT64 - -#if defined(_ARM64_) -#define MCREG_X0(mc) ((mc).regs[0]) -#define MCREG_X1(mc) ((mc).regs[1]) -#define MCREG_X2(mc) ((mc).regs[2]) -#define MCREG_X3(mc) ((mc).regs[3]) -#define MCREG_X4(mc) ((mc).regs[4]) -#define MCREG_X5(mc) ((mc).regs[5]) -#define MCREG_X6(mc) ((mc).regs[6]) -#define MCREG_X7(mc) ((mc).regs[7]) -#define MCREG_X8(mc) ((mc).regs[8]) -#define MCREG_X9(mc) ((mc).regs[9]) -#define MCREG_X10(mc) ((mc).regs[10]) -#define MCREG_X11(mc) ((mc).regs[11]) -#define MCREG_X12(mc) ((mc).regs[12]) -#define MCREG_X13(mc) ((mc).regs[13]) -#define MCREG_X14(mc) ((mc).regs[14]) -#define MCREG_X15(mc) ((mc).regs[15]) -#define MCREG_X16(mc) ((mc).regs[16]) -#define MCREG_X17(mc) ((mc).regs[17]) -#define MCREG_X18(mc) ((mc).regs[18]) -#define MCREG_X19(mc) ((mc).regs[19]) -#define MCREG_X20(mc) ((mc).regs[20]) -#define MCREG_X21(mc) ((mc).regs[21]) -#define MCREG_X22(mc) ((mc).regs[22]) -#define MCREG_X23(mc) ((mc).regs[23]) -#define MCREG_X24(mc) ((mc).regs[24]) -#define MCREG_X25(mc) ((mc).regs[25]) -#define MCREG_X26(mc) ((mc).regs[26]) -#define MCREG_X27(mc) ((mc).regs[27]) -#define MCREG_X28(mc) ((mc).regs[28]) -#define MCREG_Fp(mc) ((mc).regs[29]) -#define MCREG_Lr(mc) ((mc).regs[30]) - -#define MCREG_Sp(mc) ((mc).sp) -#define MCREG_Pc(mc) ((mc).pc) -#define MCREG_Cpsr(mc) ((mc).pstate) -#else - // For FreeBSD, as found in x86/ucontext.h -#define MCREG_Rbp(mc) ((mc).mc_rbp) -#define MCREG_Rip(mc) ((mc).mc_rip) -#define MCREG_Rsp(mc) ((mc).mc_rsp) -#define MCREG_Rsi(mc) ((mc).mc_rsi) -#define MCREG_Rdi(mc) ((mc).mc_rdi) -#define MCREG_Rbx(mc) ((mc).mc_rbx) -#define MCREG_Rdx(mc) ((mc).mc_rdx) -#define MCREG_Rcx(mc) ((mc).mc_rcx) -#define MCREG_Rax(mc) ((mc).mc_rax) -#define MCREG_R8(mc) ((mc).mc_r8) -#define MCREG_R9(mc) ((mc).mc_r9) -#define MCREG_R10(mc) ((mc).mc_r10) -#define MCREG_R11(mc) ((mc).mc_r11) -#define MCREG_R12(mc) ((mc).mc_r12) -#define MCREG_R13(mc) ((mc).mc_r13) -#define MCREG_R14(mc) ((mc).mc_r14) -#define MCREG_R15(mc) ((mc).mc_r15) -#define MCREG_EFlags(mc) ((mc).mc_rflags) -#define MCREG_SegCs(mc) ((mc).mc_cs) - - // from x86/fpu.h: struct __envxmm64 -#define FPSTATE(uc) ((savefpu*)((uc)->uc_mcontext.mc_fpstate)) -#define FPREG_ControlWord(uc) FPSTATE(uc)->sv_env.en_cw -#define FPREG_StatusWord(uc) FPSTATE(uc)->sv_env.en_sw -#define FPREG_TagWord(uc) FPSTATE(uc)->sv_env.en_tw -#define FPREG_MxCsr(uc) FPSTATE(uc)->sv_env.en_mxcsr -#define FPREG_MxCsr_Mask(uc) FPSTATE(uc)->sv_env.en_mxcsr_mask -#define FPREG_ErrorOffset(uc) *(DWORD*) &(FPSTATE(uc)->sv_env.en_rip) -#define FPREG_ErrorSelector(uc) *((WORD*) &(FPSTATE(uc)->sv_env.en_rip) + 2) -#define FPREG_DataOffset(uc) *(DWORD*) &(FPSTATE(uc)->sv_env.en_rdp) -#define FPREG_DataSelector(uc) *((WORD*) &(FPSTATE(uc)->sv_env.en_rdp) + 2) - -#define FPREG_Xmm(uc, index) *(M128A*) &(FPSTATE(uc)->sv_xmm[index]) -#define FPREG_St(uc, index) *(M128A*) &(FPSTATE(uc)->sv_fp[index].fp_acc) -#endif - -#else // BIT64 - -#if defined(_ARM_) - -#define MCREG_R0(mc) ((mc).arm_r0) -#define MCREG_R1(mc) ((mc).arm_r1) -#define MCREG_R2(mc) ((mc).arm_r2) -#define MCREG_R3(mc) ((mc).arm_r3) -#define MCREG_R4(mc) ((mc).arm_r4) -#define MCREG_R5(mc) ((mc).arm_r5) -#define MCREG_R6(mc) ((mc).arm_r6) -#define MCREG_R7(mc) ((mc).arm_r7) -#define MCREG_R8(mc) ((mc).arm_r8) -#define MCREG_R9(mc) ((mc).arm_r9) -#define MCREG_R10(mc) ((mc).arm_r10) -#define MCREG_R11(mc) ((mc).arm_fp) -#define MCREG_R12(mc) ((mc).arm_ip) -#define MCREG_Sp(mc) ((mc).arm_sp) -#define MCREG_Lr(mc) ((mc).arm_lr) -#define MCREG_Pc(mc) ((mc).arm_pc) -#define MCREG_Cpsr(mc) ((mc).arm_cpsr) - -#elif defined(_X86_) - -#define MCREG_Ebx(mc) ((mc).mc_ebx) -#define MCREG_Ecx(mc) ((mc).mc_ecx) -#define MCREG_Edx(mc) ((mc).mc_edx) -#define MCREG_Esi(mc) ((mc).mc_esi) -#define MCREG_Edi(mc) ((mc).mc_edi) -#define MCREG_Ebp(mc) ((mc).mc_ebp) -#define MCREG_Eax(mc) ((mc).mc_eax) -#define MCREG_Eip(mc) ((mc).mc_eip) -#define MCREG_SegCs(mc) ((mc).mc_cs) -#define MCREG_EFlags(mc) ((mc).mc_eflags) -#define MCREG_Esp(mc) ((mc).mc_esp) -#define MCREG_SegSs(mc) ((mc).mc_ss) - -#else -#error "Unsupported arch" -#endif - -#endif // BIT64 - -#endif // HAVE_GREGSET_T - - -#if HAVE_PT_REGS - -#ifdef BIT64 -#define PTREG_Rbx(ptreg) ((ptreg).rbx) -#define PTREG_Rcx(ptreg) ((ptreg).rcx) -#define PTREG_Rdx(ptreg) ((ptreg).rdx) -#define PTREG_Rsi(ptreg) ((ptreg).rsi) -#define PTREG_Rdi(ptreg) ((ptreg).rdi) -#define PTREG_Rbp(ptreg) ((ptreg).rbp) -#define PTREG_Rax(ptreg) ((ptreg).rax) -#define PTREG_Rip(ptreg) ((ptreg).rip) -#define PTREG_SegCs(ptreg) ((ptreg).cs) -#define PTREG_SegSs(ptreg) ((ptreg).ss) -#define PTREG_Rsp(ptreg) ((ptreg).rsp) -#define PTREG_R8(ptreg) ((ptreg).r8) -#define PTREG_R9(ptreg) ((ptreg).r9) -#define PTREG_R10(ptreg) ((ptreg).r10) -#define PTREG_R11(ptreg) ((ptreg).r11) -#define PTREG_R12(ptreg) ((ptreg).r12) -#define PTREG_R13(ptreg) ((ptreg).r13) -#define PTREG_R14(ptreg) ((ptreg).r14) -#define PTREG_R15(ptreg) ((ptreg).r15) - -#else // BIT64 - -#if defined(_ARM_) -#define PTREG_R0(ptreg) ((ptreg).uregs[0]) -#define PTREG_R1(ptreg) ((ptreg).uregs[1]) -#define PTREG_R2(ptreg) ((ptreg).uregs[2]) -#define PTREG_R3(ptreg) ((ptreg).uregs[3]) -#define PTREG_R4(ptreg) ((ptreg).uregs[4]) -#define PTREG_R5(ptreg) ((ptreg).uregs[5]) -#define PTREG_R6(ptreg) ((ptreg).uregs[6]) -#define PTREG_R7(ptreg) ((ptreg).uregs[7]) -#define PTREG_R8(ptreg) ((ptreg).uregs[8]) -#define PTREG_R9(ptreg) ((ptreg).uregs[9]) -#define PTREG_R10(ptreg) ((ptreg).uregs[10]) -#define PTREG_R11(ptreg) ((ptreg).uregs[11]) -#define PTREG_R12(ptreg) ((ptreg).uregs[12]) -#define PTREG_Sp(ptreg) ((ptreg).uregs[13]) -#define PTREG_Lr(ptreg) ((ptreg).uregs[14]) -#define PTREG_Pc(ptreg) ((ptreg).uregs[15]) -#define PTREG_Cpsr(ptreg) ((ptreg).uregs[16]) -#elif defined(_X86_) -#define PTREG_Ebx(ptreg) ((ptreg).ebx) -#define PTREG_Ecx(ptreg) ((ptreg).ecx) -#define PTREG_Edx(ptreg) ((ptreg).edx) -#define PTREG_Esi(ptreg) ((ptreg).esi) -#define PTREG_Edi(ptreg) ((ptreg).edi) -#define PTREG_Ebp(ptreg) ((ptreg).ebp) -#define PTREG_Eax(ptreg) ((ptreg).eax) -#define PTREG_Eip(ptreg) ((ptreg).eip) -#define PTREG_SegCs(ptreg) ((ptreg).xcs) -#define PTREG_SegSs(ptreg) ((ptreg).xss) -#define PTREG_Esp(ptreg) ((ptreg).esp) -#else -#error "Unsupported arch" -#endif - -#endif // BIT64 - - -#define PTREG_EFlags(ptreg) ((ptreg).eflags) - -#endif // HAVE_PT_REGS - - - -#if HAVE_BSD_REGS_T - -#ifndef BSD_REGS_STYLE -#error "struct reg" has unrecognized format -#endif - -#ifdef BIT64 - -#define BSDREG_Rbx(reg) BSD_REGS_STYLE(reg,RBX,rbx) -#define BSDREG_Rcx(reg) BSD_REGS_STYLE(reg,RCX,rcx) -#define BSDREG_Rdx(reg) BSD_REGS_STYLE(reg,RDX,rdx) -#define BSDREG_Rsi(reg) BSD_REGS_STYLE(reg,RSI,rsi) -#define BSDREG_Rdi(reg) BSD_REGS_STYLE(reg,RDI,rdi) -#define BSDREG_Rbp(reg) BSD_REGS_STYLE(reg,RBP,rbp) -#define BSDREG_Rax(reg) BSD_REGS_STYLE(reg,RAX,rax) -#define BSDREG_Rip(reg) BSD_REGS_STYLE(reg,RIP,rip) -#define BSDREG_SegCs(reg) BSD_REGS_STYLE(reg,CS,cs) -#define BSDREG_SegSs(reg) BSD_REGS_STYLE(reg,SS,ss) -#define BSDREG_Rsp(reg) BSD_REGS_STYLE(reg,RSP,rsp) -#define BSDREG_R8(reg) BSD_REGS_STYLE(reg,R8,r8) -#define BSDREG_R9(reg) BSD_REGS_STYLE(reg,R9,r9) -#define BSDREG_R10(reg) BSD_REGS_STYLE(reg,R10,r10) -#define BSDREG_R11(reg) BSD_REGS_STYLE(reg,R11,r11) -#define BSDREG_R12(reg) BSD_REGS_STYLE(reg,R12,r12) -#define BSDREG_R13(reg) BSD_REGS_STYLE(reg,R13,r13) -#define BSDREG_R14(reg) BSD_REGS_STYLE(reg,R14,r14) -#define BSDREG_R15(reg) BSD_REGS_STYLE(reg,R15,r15) -#define BSDREG_EFlags(reg) BSD_REGS_STYLE(reg,RFLAGS,rflags) - -#else // BIT64 - -#define BSDREG_Ebx(reg) BSD_REGS_STYLE(reg,EBX,ebx) -#define BSDREG_Ecx(reg) BSD_REGS_STYLE(reg,ECX,ecx) -#define BSDREG_Edx(reg) BSD_REGS_STYLE(reg,EDX,edx) -#define BSDREG_Esi(reg) BSD_REGS_STYLE(reg,ESI,esi) -#define BSDREG_Edi(reg) BSD_REGS_STYLE(reg,EDI,edi) -#define BSDREG_Ebp(reg) BSD_REGS_STYLE(reg,EDP,ebp) -#define BSDREG_Eax(reg) BSD_REGS_STYLE(reg,EAX,eax) -#define BSDREG_Eip(reg) BSD_REGS_STYLE(reg,EIP,eip) -#define BSDREG_SegCs(reg) BSD_REGS_STYLE(reg,CS,cs) -#define BSDREG_EFlags(reg) BSD_REGS_STYLE(reg,EFLAGS,eflags) -#define BSDREG_Esp(reg) BSD_REGS_STYLE(reg,ESP,esp) -#define BSDREG_SegSs(reg) BSD_REGS_STYLE(reg,SS,ss) - -#endif // BIT64 - -#endif // HAVE_BSD_REGS_T - -inline static DWORD64 CONTEXTGetPC(LPCONTEXT pContext) -{ -#if defined(_AMD64_) - return pContext->Rip; -#elif defined(_X86_) - return pContext->Eip; -#elif defined(_ARM64_) || defined(_ARM_) - return pContext->Pc; -#else -#error don't know how to get the program counter for this architecture -#endif -} - -inline static void CONTEXTSetPC(LPCONTEXT pContext, DWORD64 pc) -{ -#if defined(_AMD64_) - pContext->Rip = pc; -#elif defined(_X86_) - pContext->Eip = pc; -#elif defined(_ARM64_) || defined(_ARM_) - pContext->Pc = pc; -#else -#error don't know how to set the program counter for this architecture -#endif -} - -inline static DWORD64 CONTEXTGetFP(LPCONTEXT pContext) -{ -#if defined(_AMD64_) - return pContext->Rbp; -#elif defined(_X86_) - return pContext->Ebp; -#elif defined(_ARM_) - return pContext->R7; -#elif defined(_ARM64_) - return pContext->Fp; -#else -#error don't know how to get the frame pointer for this architecture -#endif -} - -/*++ -Function : - CONTEXT_CaptureContext - - Captures the context of the caller. - The returned context is suitable for performing - a virtual unwind. - -Parameters : - LPCONTEXT lpContext : new context - ---*/ -void -PALAPI -CONTEXT_CaptureContext( - LPCONTEXT lpContext - ); - -/*++ -Function : - CONTEXT_SetThreadContext - - Processor-dependent implementation of SetThreadContext - -Parameters : - HANDLE hThread : thread whose context is to be set - CONTEXT *lpContext : new context - -Return value : - TRUE on success, FALSE on failure - ---*/ -BOOL -CONTEXT_SetThreadContext( - DWORD dwProcessId, - pthread_t self, - CONST CONTEXT *lpContext - ); - -/*++ -Function : - CONTEXT_GetThreadContext - - Processor-dependent implementation of GetThreadContext - -Parameters : - HANDLE hThread : thread whose context is to retrieved - LPCONTEXT lpContext : destination for thread's context - -Return value : - TRUE on success, FALSE on failure - ---*/ -BOOL -CONTEXT_GetThreadContext( - DWORD dwProcessId, - pthread_t self, - LPCONTEXT lpContext); - -#if HAVE_MACH_EXCEPTIONS -/*++ -Function: - CONTEXT_GetThreadContextFromPort - - Helper for GetThreadContext that uses a mach_port ---*/ -kern_return_t -CONTEXT_GetThreadContextFromPort( - mach_port_t Port, - LPCONTEXT lpContext); - -/*++ -Function: - SetThreadContextOnPort - - Helper for CONTEXT_SetThreadContext ---*/ -kern_return_t -CONTEXT_SetThreadContextOnPort( - mach_port_t Port, - IN CONST CONTEXT *lpContext); - -/*++ -Function: - GetThreadContextFromThreadState - - Helper for mach exception support ---*/ -void -CONTEXT_GetThreadContextFromThreadState( - thread_state_flavor_t stateFlavor, - thread_state_t threadState, - LPCONTEXT lpContext); - -#else // HAVE_MACH_EXCEPTIONS -/*++ -Function : - CONTEXTToNativeContext - - Converts a CONTEXT record to a native context. - -Parameters : - CONST CONTEXT *lpContext : CONTEXT to convert, including - flags that determine which registers are valid in - lpContext and which ones to set in native - native_context_t *native : native context to fill in - -Return value : - None - ---*/ -void CONTEXTToNativeContext(CONST CONTEXT *lpContext, native_context_t *native); - -/*++ -Function : - CONTEXTFromNativeContext - - Converts a native context to a CONTEXT record. - -Parameters : - const native_context_t *native : native context to convert - LPCONTEXT lpContext : CONTEXT to fill in - ULONG contextFlags : flags that determine which registers are valid in - native and which ones to set in lpContext - -Return value : - None - ---*/ -void CONTEXTFromNativeContext(const native_context_t *native, LPCONTEXT lpContext, - ULONG contextFlags); - -/*++ -Function : - GetNativeContextPC - - Returns the program counter from the native context. - -Parameters : - const native_context_t *context : native context - -Return value : - The program counter from the native context. - ---*/ -LPVOID GetNativeContextPC(const native_context_t *context); - -/*++ -Function : - GetNativeContextSP - - Returns the stack pointer from the native context. - -Parameters : - const native_context_t *native : native context - -Return value : - The stack pointer from the native context. - ---*/ -LPVOID GetNativeContextSP(const native_context_t *context); - -/*++ -Function : - CONTEXTGetExceptionCodeForSignal - - Translates signal and context information to a Win32 exception code. - -Parameters : - const siginfo_t *siginfo : signal information from a signal handler - const native_context_t *context : context information - -Return value : - The Win32 exception code that corresponds to the signal and context - information. - ---*/ -DWORD CONTEXTGetExceptionCodeForSignal(const siginfo_t *siginfo, - const native_context_t *context); - -#endif // HAVE_MACH_EXCEPTIONS else - -#ifdef __cplusplus -} -#endif // __cplusplus - -#endif // _PAL_CONTEXT_H_ diff --git a/src/pal/src/include/pal/corunix.hpp b/src/pal/src/include/pal/corunix.hpp index c3a37cb45..7a14e0d36 100644 --- a/src/pal/src/include/pal/corunix.hpp +++ b/src/pal/src/include/pal/corunix.hpp @@ -23,6 +23,14 @@ Abstract: #include "palinternal.h" +#ifndef static_assert_no_msg +#define static_assert_no_msg( cond ) static_assert( cond, #cond ) +#endif // !static_assert_no_msg + +#ifndef _countof +#define _countof(a) (sizeof(a) / sizeof(a[0])) +#endif // !_countof + namespace CorUnix { typedef DWORD PAL_ERROR; @@ -1120,174 +1128,6 @@ namespace CorUnix }; extern IPalObjectManager *g_pObjectManager; - - enum ThreadWakeupReason - { - WaitSucceeded, - Alerted, - MutexAbondoned, - WaitTimeout, - WaitFailed - }; - - class IPalSynchronizationManager - { - public: - - // - // A thread calls BlockThread to put itself to sleep after it has - // registered itself with the objects it is to wait on. A thread - // need not have registered with any objects, as would occur in - // the implementation of Sleep[Ex]. - // - // Needless to say a thread must not be holding any PAL locks - // directly or implicitly (e.g., by holding a reference to a - // synchronization controller) when it calls this method. - // - - virtual - PAL_ERROR - BlockThread( - CPalThread *pCurrentThread, - DWORD dwTimeout, - bool fAlertable, - bool fIsSleep, - ThreadWakeupReason *peWakeupReason, // OUT - DWORD *pdwSignaledObject // OUT - ) = 0; - - virtual - PAL_ERROR - AbandonObjectsOwnedByThread( - CPalThread *pCallingThread, - CPalThread *pTargetThread - ) = 0; - - virtual - PAL_ERROR - QueueUserAPC( - CPalThread *pThread, - CPalThread *pTargetThread, - PAPCFUNC pfnAPC, - ULONG_PTR dwData - ) = 0; - - virtual - bool - AreAPCsPending( - CPalThread *pThread - ) = 0; - - virtual - PAL_ERROR - DispatchPendingAPCs( - CPalThread *pThread - ) = 0; - - virtual - PAL_ERROR - SendTerminationRequestToWorkerThread() = 0; - - // - // This routine is primarily meant for use by WaitForMultipleObjects[Ex]. - // The caller must individually release each of the returned controller - // interfaces. - // - - virtual - PAL_ERROR - GetSynchWaitControllersForObjects( - CPalThread *pThread, - IPalObject *rgObjects[], - DWORD dwObjectCount, - ISynchWaitController *rgControllers[] - ) = 0; - - virtual - PAL_ERROR - GetSynchStateControllersForObjects( - CPalThread *pThread, - IPalObject *rgObjects[], - DWORD dwObjectCount, - ISynchStateController *rgControllers[] - ) = 0; - - // - // These following routines are meant for use only by IPalObject - // implementations. The first two routines are used to - // allocate and free an object's synchronization state; the third - // is called during object promotion. - // - - virtual - PAL_ERROR - AllocateObjectSynchData( - CObjectType *pObjectType, - ObjectDomain eObjectDomain, - VOID **ppvSynchData // OUT - ) = 0; - - virtual - void - FreeObjectSynchData( - CObjectType *pObjectType, - ObjectDomain eObjectDomain, - VOID *pvSynchData - ) = 0; - - virtual - PAL_ERROR - PromoteObjectSynchData( - CPalThread *pThread, - VOID *pvLocalSynchData, - VOID **ppvSharedSynchData // OUT - ) = 0; - - // - // The next two routines provide access to the process-wide - // synchronization lock - // - - virtual - void - AcquireProcessLock( - CPalThread *pThread - ) = 0; - - virtual - void - ReleaseProcessLock( - CPalThread *pThread - ) = 0; - - // - // The final routines are used by IPalObject::GetSynchStateController - // and IPalObject::GetSynchWaitController - // - - virtual - PAL_ERROR - CreateSynchStateController( - CPalThread *pThread, // IN, OPTIONAL - CObjectType *pObjectType, - VOID *pvSynchData, - ObjectDomain eObjectDomain, - ISynchStateController **ppStateController // OUT - ) = 0; - - virtual - PAL_ERROR - CreateSynchWaitController( - CPalThread *pThread, // IN, OPTIONAL - CObjectType *pObjectType, - VOID *pvSynchData, - ObjectDomain eObjectDomain, - ISynchWaitController **ppWaitController // OUT - ) = 0; - }; - - extern IPalSynchronizationManager *g_pSynchronizationManager; - } #endif // _CORUNIX_H diff --git a/src/pal/src/include/pal/dbgmsg.h b/src/pal/src/include/pal/dbgmsg.h index 052c6fa77..3c4cb8d16 100644 --- a/src/pal/src/include/pal/dbgmsg.h +++ b/src/pal/src/include/pal/dbgmsg.h @@ -158,7 +158,6 @@ Using Debug channels at Run Time #include "pal/perftrace.h" #include "pal/debug.h" #include "pal/thread.hpp" -#include "pal/tls.hpp" #ifdef __cplusplus extern "C" diff --git a/src/pal/src/include/pal/debug.h b/src/pal/src/include/pal/debug.h index 78cdeff0c..85b268f08 100644 --- a/src/pal/src/include/pal/debug.h +++ b/src/pal/src/include/pal/debug.h @@ -37,35 +37,6 @@ Function : extern "C" VOID DBG_DebugBreak(); -/*++ -Function: - IsInDebugBreak(addr) - - Returns true if the address is in DBG_DebugBreak. - ---*/ -BOOL -IsInDebugBreak(void *addr); - -/*++ -Function : - DBG_FlushInstructionCache - - Processor-dependent implementation of FlushInstructionCache - -Parameters : - LPCVOID lpBaseAddress: start of region to flush - SIZE_T dwSize : length of region to flush - -Return value : - TRUE on success, FALSE on failure - ---*/ -BOOL -DBG_FlushInstructionCache( - IN LPCVOID lpBaseAddress, - IN SIZE_T dwSize); - #if defined(__APPLE__) /*++ Function: diff --git a/src/pal/src/include/pal/malloc.hpp b/src/pal/src/include/pal/malloc.hpp index 9faf4273d..9b11f5802 100644 --- a/src/pal/src/include/pal/malloc.hpp +++ b/src/pal/src/include/pal/malloc.hpp @@ -47,12 +47,6 @@ extern "C" PAL_free( void *pvMem ); - - char * - __cdecl - PAL__strdup( - const char *c_szStr - ); } namespace CorUnix{ diff --git a/src/pal/src/include/pal/map.hpp b/src/pal/src/include/pal/map.hpp index 7bcb20a40..7166038dc 100644 --- a/src/pal/src/include/pal/map.hpp +++ b/src/pal/src/include/pal/map.hpp @@ -70,30 +70,6 @@ extern "C" --*/ BOOL MAPGetRegionInfo(LPVOID lpAddress, PMEMORY_BASIC_INFORMATION lpBuffer); - - /*++ - MAPMapPEFile - - - Map a PE format file into memory like Windows LoadLibrary() would do. - Doesn't apply base relocations if the function is relocated. - - Parameters: - IN hFile - file to map - - Return value: - non-NULL - the base address of the mapped image - NULL - error, with last error set. - --*/ - - void * MAPMapPEFile(HANDLE hFile); - - /*++ - Function : - MAPUnmapPEFile - unmap a PE file, and remove it from the recorded list of PE files mapped - - returns TRUE if successful, FALSE otherwise - --*/ - BOOL MAPUnmapPEFile(LPCVOID lpAddress); } namespace CorUnix diff --git a/src/pal/src/include/pal/module.h b/src/pal/src/include/pal/module.h index 72df268d3..aa15ff3ec 100644 --- a/src/pal/src/include/pal/module.h +++ b/src/pal/src/include/pal/module.h @@ -135,51 +135,6 @@ Return --*/ void UnlockModuleList(); -/*++ -Function: - PAL_LOADLoadPEFile - -Abstract - Loads a PE file into memory. Properly maps all of the sections in the PE file. Returns a pointer to the - loaded base. - -Parameters: - IN hFile - The file to load - -Return value: - A valid base address if successful. - 0 if failure ---*/ -void * PAL_LOADLoadPEFile(HANDLE hFile); - -/*++ - PAL_LOADUnloadPEFile - - Unload a PE file that was loaded by PAL_LOADLoadPEFile(). - -Parameters: - IN ptr - the file pointer returned by PAL_LOADLoadPEFile() - -Return value: - TRUE - success - FALSE - failure (incorrect ptr, etc.) ---*/ -BOOL PAL_LOADUnloadPEFile(void * ptr); - -/*++ - LOADInitializeCoreCLRModule - - Run the initialization methods for CoreCLR module. - -Parameters: - None - -Return value: - TRUE if successful - FALSE if failure ---*/ -BOOL LOADInitializeCoreCLRModule(); - /*++ Function : LOADGetPalLibrary diff --git a/src/pal/src/include/pal/mutex.hpp b/src/pal/src/include/pal/mutex.hpp deleted file mode 100644 index 6a46689d7..000000000 --- a/src/pal/src/include/pal/mutex.hpp +++ /dev/null @@ -1,191 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*++ - - - -Module Name: - - mutex.hpp - -Abstract: - - Mutex object structure definition. - - - ---*/ - -#ifndef _PAL_MUTEX_H_ -#define _PAL_MUTEX_H_ - -#include "corunix.hpp" -#include "sharedmemory.h" - -#include - -namespace CorUnix -{ - extern CObjectType otMutex; - extern CObjectType otNamedMutex; - - PAL_ERROR - InternalCreateMutex( - CPalThread *pThread, - LPSECURITY_ATTRIBUTES lpMutexAttributes, - BOOL bInitialOwner, - LPCSTR lpName, - HANDLE *phMutex - ); - - PAL_ERROR - InternalReleaseMutex( - CPalThread *pThread, - HANDLE hMutex - ); - - PAL_ERROR - InternalOpenMutex( - CPalThread *pThread, - DWORD dwDesiredAccess, - BOOL bInheritHandle, - LPCSTR lpName, - HANDLE *phMutex - ); - -} - -#define SYNCSPINLOCK_F_ASYMMETRIC 1 - -#define SPINLOCKInit(lock) (*(lock) = 0) -#define SPINLOCKDestroy SPINLOCKInit - -void SPINLOCKAcquire (LONG * lock, unsigned int flags); -void SPINLOCKRelease (LONG * lock); -DWORD SPINLOCKTryAcquire (LONG * lock); - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// Named mutex - -// Temporarily disabling usage of pthread process-shared mutexes on ARM/ARM64 due to functional issues that cannot easily be -// detected with code due to hangs. See https://github.com/dotnet/coreclr/issues/5456. -#if HAVE_FULLY_FEATURED_PTHREAD_MUTEXES && HAVE_FUNCTIONAL_PTHREAD_ROBUST_MUTEXES && !(defined(_ARM_) || defined(_ARM64_)) - #define NAMED_MUTEX_USE_PTHREAD_MUTEX 1 -#else - #define NAMED_MUTEX_USE_PTHREAD_MUTEX 0 -#endif - -enum class NamedMutexError : DWORD -{ - MaximumRecursiveLocksReached = ERROR_NOT_ENOUGH_MEMORY, - ThreadHasNotAcquiredMutex = ERROR_NOT_OWNER, - Unknown = ERROR_NOT_ENOUGH_MEMORY -}; - -enum class MutexTryAcquireLockResult -{ - AcquiredLock, - AcquiredLockButMutexWasAbandoned, - TimedOut -}; - -#if NAMED_MUTEX_USE_PTHREAD_MUTEX -class MutexHelpers -{ -public: - static void InitializeProcessSharedRobustRecursiveMutex(pthread_mutex_t *mutex); - static void DestroyMutex(pthread_mutex_t *mutex); - - static MutexTryAcquireLockResult TryAcquireLock(pthread_mutex_t *mutex, DWORD timeoutMilliseconds); - static void ReleaseLock(pthread_mutex_t *mutex); -}; -#endif // NAMED_MUTEX_USE_PTHREAD_MUTEX - -class NamedMutexSharedData -{ -private: -#if NAMED_MUTEX_USE_PTHREAD_MUTEX - pthread_mutex_t m_lock; -#else // !NAMED_MUTEX_USE_PTHREAD_MUTEX - UINT32 m_timedWaiterCount; -#endif // NAMED_MUTEX_USE_PTHREAD_MUTEX - UINT32 m_lockOwnerProcessId; - UINT64 m_lockOwnerThreadId; - bool m_isAbandoned; - -public: - NamedMutexSharedData(); - ~NamedMutexSharedData(); - -#if NAMED_MUTEX_USE_PTHREAD_MUTEX -public: - pthread_mutex_t *GetLock(); -#else // !NAMED_MUTEX_USE_PTHREAD_MUTEX -public: - bool HasAnyTimedWaiters() const; - void IncTimedWaiterCount(); - void DecTimedWaiterCount(); -#endif // NAMED_MUTEX_USE_PTHREAD_MUTEX - -public: - bool IsAbandoned() const; - void SetIsAbandoned(bool isAbandoned); - -public: - bool IsLockOwnedByAnyThread() const; - bool IsLockOwnedByCurrentThread() const; - void SetLockOwnerToCurrentThread(); - void ClearLockOwner(); -}; - -class NamedMutexProcessData : public SharedMemoryProcessDataBase -{ -private: - static const UINT8 SyncSystemVersion; - static const DWORD PollLoopMaximumSleepMilliseconds; - -private: - SharedMemoryProcessDataHeader *m_processDataHeader; - NamedMutexSharedData *m_sharedData; - SIZE_T m_lockCount; -#if !NAMED_MUTEX_USE_PTHREAD_MUTEX - HANDLE m_processLockHandle; - int m_sharedLockFileDescriptor; -#endif // !NAMED_MUTEX_USE_PTHREAD_MUTEX - CorUnix::CPalThread *m_lockOwnerThread; - NamedMutexProcessData *m_nextInThreadOwnedNamedMutexList; - -public: - static SharedMemoryProcessDataHeader *CreateOrOpen(LPCSTR name, bool acquireLockIfCreated, bool *createdRef); - static SharedMemoryProcessDataHeader *Open(LPCSTR name); -private: - static SharedMemoryProcessDataHeader *CreateOrOpen(LPCSTR name, bool createIfNotExist, bool acquireLockIfCreated, bool *createdRef); - -public: - NamedMutexProcessData( - SharedMemoryProcessDataHeader *processDataHeader - #if !NAMED_MUTEX_USE_PTHREAD_MUTEX - , - int sharedLockFileDescriptor - #endif // !NAMED_MUTEX_USE_PTHREAD_MUTEX - ); - virtual void Close(bool isAbruptShutdown, bool releaseSharedData) override; - -private: - NamedMutexSharedData *GetSharedData() const; - void SetLockOwnerThread(CorUnix::CPalThread *lockOwnerThread); -public: - NamedMutexProcessData *GetNextInThreadOwnedNamedMutexList() const; - void SetNextInThreadOwnedNamedMutexList(NamedMutexProcessData *next); - -public: - MutexTryAcquireLockResult TryAcquireLock(DWORD timeoutMilliseconds); - void ReleaseLock(); - void Abandon(); -private: - void ActuallyReleaseLock(); -}; - -#endif //_PAL_MUTEX_H_ diff --git a/src/pal/src/include/pal/numa.h b/src/pal/src/include/pal/numa.h deleted file mode 100644 index 4fb2308a7..000000000 --- a/src/pal/src/include/pal/numa.h +++ /dev/null @@ -1,39 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*++ - - - -Module Name: - - include/pal/numa.h - -Abstract: - - Header file for the NUMA functions. - - - ---*/ - -#ifndef _PAL_NUMA_H_ -#define _PAL_NUMA_H_ - -#ifdef __cplusplus -extern "C" -{ -#endif // __cplusplus - -BOOL -NUMASupportInitialize(); - -VOID -NUMASupportCleanup(); - -#ifdef __cplusplus -} -#endif // __cplusplus - -#endif /* _PAL_CRITSECT_H_ */ diff --git a/src/pal/src/include/pal/process.h b/src/pal/src/include/pal/process.h index f5d8b46de..8572041f9 100644 --- a/src/pal/src/include/pal/process.h +++ b/src/pal/src/include/pal/process.h @@ -35,151 +35,23 @@ extern "C" calls to CreateThread from succeeding once shutdown has started [defined in process.c] */ -extern Volatile terminator; // The process and session ID of this process, so we can avoid excessive calls to getpid() and getsid(). extern DWORD gPID; extern DWORD gSID; -extern LPWSTR pAppDir; - -/*++ -Function: - PROCGetProcessIDFromHandle - -Abstract - Return the process ID from a process handle ---*/ -DWORD PROCGetProcessIDFromHandle(HANDLE hProcess); - -/*++ -Function: - PROCCreateInitialProcess - -Abstract - Initialize all the structures for the initial process. - -Parameter - lpwstrCmdLine: Command line. - lpwstrFullPath : Full path to executable - -Return - TRUE: if successful - FALSE: otherwise - -Notes : - This function takes ownership of lpwstrCmdLine, but not of lpwstrFullPath ---*/ -BOOL PROCCreateInitialProcess(LPWSTR lpwstrCmdLine, LPWSTR lpwstrFullPath); - -/*++ -Function: - PROCCleanupInitialProcess - -Abstract - Cleanup all the structures for the initial process. - -Parameter - VOID - -Return - VOID - ---*/ -VOID PROCCleanupInitialProcess(VOID); - -#if USE_SYSV_SEMAPHORES -/*++ -Function: - PROCCleanupThreadSemIds(VOID); - -Abstract - Cleanup SysV semaphore ids for all threads. - -(no parameters, no return value) ---*/ -VOID PROCCleanupThreadSemIds(VOID); -#endif - -/*++ -Function: - PROCProcessLock - -Abstract - Enter the critical section associated to the current process ---*/ -VOID PROCProcessLock(VOID); - - -/*++ -Function: - PROCProcessUnlock - -Abstract - Leave the critical section associated to the current process ---*/ -VOID PROCProcessUnlock(VOID); - -/*++ -Function - PROCAbortInitialize() - -Abstract - Initialize the process abort crash dump program file path and - name. Doing all of this ahead of time so nothing is allocated - or copied in PROCAbort/signal handler. - -Return - TRUE - succeeds, FALSE - fails - ---*/ -BOOL PROCAbortInitialize(); - /*++ Function: PROCAbort() Aborts the process after calling the shutdown cleanup handler. This function should be called instead of calling abort() directly. - + Does not return --*/ -PAL_NORETURN +PAL_NORETURN VOID PROCAbort(); -/*++ -Function: - PROCNotifyProcessShutdown - - Calls the abort handler to do any shutdown cleanup. Call be - called from the unhandled native exception handler. - -(no return value) ---*/ -VOID PROCNotifyProcessShutdown(); - -/*++ -Function: - PROCCreateCrashDumpIfEnabled - - Creates crash dump of the process (if enabled). Can be - called from the unhandled native exception handler. - -(no return value) ---*/ -VOID PROCCreateCrashDumpIfEnabled(); - -/*++ -Function: - InitializeFlushProcessWriteBuffers - -Abstract - This function initializes data structures needed for the FlushProcessWriteBuffers -Return - TRUE if it succeeded, FALSE otherwise ---*/ -BOOL InitializeFlushProcessWriteBuffers(); - #ifdef __cplusplus } #endif // __cplusplus diff --git a/src/pal/src/include/pal/procobj.hpp b/src/pal/src/include/pal/procobj.hpp deleted file mode 100644 index a75c76424..000000000 --- a/src/pal/src/include/pal/procobj.hpp +++ /dev/null @@ -1,125 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*++ - - - -Module Name: - - include/pal/procobj.hpp - -Abstract: - Header file for process structures - - - ---*/ - -#ifndef _PAL_PROCOBJ_HPP_ -#define _PAL_PROCOBJ_HPP_ - -#include "corunix.hpp" - -namespace CorUnix -{ - extern CObjectType otProcess; - - typedef enum - { - PS_IDLE, - PS_STARTING, - PS_RUNNING, - PS_DONE - } PROCESS_STATE; - - // - // Struct for process module list (EnumProcessModules) - // - struct ProcessModules - { - ProcessModules *Next; - PVOID BaseAddress; - CHAR Name[0]; - }; - - // - // Ideally dwProcessId would be part of the process object's immutable - // data. Doing so, though, creates complications in CreateProcess. The - // contents of the immutable data for a new object must be set before - // that object is registered with the object manager (as the object - // manager may make a copy of the immutable data). The PID for a new - // process, though, is not known until after creation. Registering the - // process object after process creation creates an undesirable error path - // -- if we are not able to register the process object (say, because of - // a low resource condition) we would be forced to return an error to - // the caller of CreateProcess, even though the new process was actually - // created... - // - // Note: we could work around this by effectively always going down - // the create suspended path. That is, the new process would not exec until - // the parent process released it. It's unclear how much benefit this would - // provide us. - // - - class CProcProcessLocalData - { - public: - CProcProcessLocalData() - : - dwProcessId(0), - ps(PS_IDLE), - dwExitCode(0), - lAttachCount(0), - pProcessModules(NULL), - cProcessModules(0) - { - }; - - ~CProcProcessLocalData(); - - DWORD dwProcessId; - PROCESS_STATE ps; - DWORD dwExitCode; - LONG lAttachCount; - ProcessModules *pProcessModules; - DWORD cProcessModules; - }; - - PAL_ERROR - InternalCreateProcess( - CPalThread *pThread, - LPCWSTR lpApplicationName, - LPWSTR lpCommandLine, - LPSECURITY_ATTRIBUTES lpProcessAttributes, - LPSECURITY_ATTRIBUTES lpThreadAttributes, - BOOL bInheritHandles, - DWORD dwCreationFlags, - LPVOID lpEnvironment, - LPCWSTR lpCurrentDirectory, - LPSTARTUPINFOW lpStartupInfo, - LPPROCESS_INFORMATION lpProcessInformation - ); - - PAL_ERROR - InitializeProcessData( - void - ); - - PAL_ERROR - InitializeProcessCommandLine( - LPWSTR lpwstrCmdLine, - LPWSTR lpwstrFullPath - ); - - PAL_ERROR - CreateInitialProcessAndThreadObjects( - CPalThread *pThread - ); - - extern IPalObject *g_pobjProcess; -} - -#endif // _PAL_PROCOBJ_HPP_ - diff --git a/src/pal/src/include/pal/seh.hpp b/src/pal/src/include/pal/seh.hpp deleted file mode 100644 index 3ac93d655..000000000 --- a/src/pal/src/include/pal/seh.hpp +++ /dev/null @@ -1,185 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*++ - - - -Module Name: - - include/pal/seh.hpp - -Abstract: - Header file for public Structured Exception Handling stuff - - - ---*/ - -#ifndef _PAL_SEH_HPP_ -#define _PAL_SEH_HPP_ - -#include "config.h" -#include "pal/palinternal.h" -#include "pal/corunix.hpp" - -// Uncomment this define to turn off the signal handling thread. -// #define DO_NOT_USE_SIGNAL_HANDLING_THREAD - -/*++ -Function : - SEHInitialize - - Initialize all SEH-related stuff (signals, etc) - -Parameters: - CPalThread * pthrCurrent : reference to the current thread. - flags : PAL initialize flags - -Return value: - TRUE if SEH support initialization succeeded, - FALSE otherwise - ---*/ -BOOL -SEHInitialize(CorUnix::CPalThread *pthrCurrent, DWORD flags); - -/*++ -Function : - SEHCleanup - - Clean up SEH-related stuff(signals, etc) - -Parameters: - None - - (no return value) ---*/ -VOID -SEHCleanup(); - -/*++ -Function: - SEHProcessException - - Send the PAL exception to any handler registered. - -Parameters: - PAL_SEHException* exception - -Return value: - Returns TRUE if the exception happened in managed code and the execution should - continue (with possibly modified context). - Returns FALSE if the exception happened in managed code and it was not handled. - In case the exception was handled by calling a catch handler, it doesn't return at all. ---*/ -BOOL -SEHProcessException(PAL_SEHException* exception); - -/*++ -Function: - AllocateExceptionRecords - -Parameters: - exceptionRecord - output pointer to the allocated Windows exception record - contextRecord - output pointer to the allocated Windows context record ---*/ -VOID -AllocateExceptionRecords(EXCEPTION_RECORD** exceptionRecord, CONTEXT** contextRecord); - -#if !HAVE_MACH_EXCEPTIONS -// TODO: Implement for Mach exceptions. Not in CoreCLR surface area. -/*++ -Function : - SEHHandleControlEvent - - handle Control-C and Control-Break events (call handler routines, - notify debugger) - -Parameters : - DWORD event : event that occurred - LPVOID eip : instruction pointer when exception occurred - -(no return value) - -Notes : - Handlers are called on a last-installed, first called basis, until a - handler returns TRUE. If no handler returns TRUE (or no hanlder is - installed), the default behavior is to call ExitProcess ---*/ -void SEHHandleControlEvent(DWORD event, LPVOID eip); -#endif // !HAVE_MACH_EXCEPTIONS - -#if !HAVE_MACH_EXCEPTIONS -/*++ -Function : - SEHSetSafeState - - specify whether the current thread is in a state where exception handling - of signals can be done safely - -Parameters: - CPalThread * pthrCurrent : reference to the current thread. - BOOL state : TRUE if the thread is safe, FALSE otherwise - -(no return value) ---*/ -void SEHSetSafeState(CorUnix::CPalThread *pthrCurrent, BOOL state); - -/*++ -Function : - SEHGetSafeState - - determine whether the current thread is in a state where exception handling - of signals can be done safely - -Parameters: - CPalThread * pthrCurrent : reference to the current thread. - -Return value : - TRUE if the thread is in a safe state, FALSE otherwise ---*/ -BOOL SEHGetSafeState(CorUnix::CPalThread *pthrCurrent); -#endif // !HAVE_MACH_EXCEPTIONS - -extern "C" -{ - -#ifdef FEATURE_PAL_SXS -/*++ -Function : - SEHEnable - - Enable SEH-related stuff on this thread - -Parameters: - CPalThread * pthrCurrent : reference to the current thread. - -Return value : - ERROR_SUCCESS, if enabling succeeded - an error code, otherwise ---*/ -CorUnix::PAL_ERROR SEHEnable(CorUnix::CPalThread *pthrCurrent); - -/*++ -Function : - SEHDisable - - Disable SEH-related stuff on this thread - -Parameters: - CPalThread * pthrCurrent : reference to the current thread. - -Return value : - ERROR_SUCCESS, if enabling succeeded - an error code, otherwise ---*/ -CorUnix::PAL_ERROR SEHDisable(CorUnix::CPalThread *pthrCurrent); - -#endif // FEATURE_PAL_SXS - -} - -#endif /* _PAL_SEH_HPP_ */ - diff --git a/src/pal/src/include/pal/semaphore.hpp b/src/pal/src/include/pal/semaphore.hpp deleted file mode 100644 index 33cf35bc2..000000000 --- a/src/pal/src/include/pal/semaphore.hpp +++ /dev/null @@ -1,65 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*++ - - - -Module Name: - - semaphore.hpp - -Abstract: - - Semaphore object structure definition. - - - ---*/ - -#ifndef _PAL_SEMAPHORE_H_ -#define _PAL_SEMAPHORE_H_ - -#include "corunix.hpp" - -namespace CorUnix -{ - extern CObjectType otSemaphore; - - typedef struct - { - LONG lMaximumCount; - } SemaphoreImmutableData; - - PAL_ERROR - InternalCreateSemaphore( - CPalThread *pThread, - LPSECURITY_ATTRIBUTES lpSemaphoreAttributes, - LONG lInitialCount, - LONG lMaximumCount, - LPCWSTR lpName, - HANDLE *phSemaphore - ); - - PAL_ERROR - InternalReleaseSemaphore( - CPalThread *pThread, - HANDLE hSemaphore, - LONG lReleaseCount, - LPLONG lpPreviousCount - ); - -} - -#endif //_PAL_SEMAPHORE_H_ - - - - - - - - - - diff --git a/src/pal/src/include/pal/sharedmemory.h b/src/pal/src/include/pal/sharedmemory.h deleted file mode 100644 index fdc395e3c..000000000 --- a/src/pal/src/include/pal/sharedmemory.h +++ /dev/null @@ -1,272 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#ifndef _PAL_SHARED_MEMORY_H_ -#define _PAL_SHARED_MEMORY_H_ - -#include "corunix.hpp" - -#ifndef static_assert_no_msg -#define static_assert_no_msg( cond ) static_assert( cond, #cond ) -#endif // !static_assert_no_msg - -#ifndef _countof -#define _countof(a) (sizeof(a) / sizeof(a[0])) -#endif // !_countof - -// The temporary folder is used for storing shared memory files and their lock files. -// The location of the temporary folder varies (e.g. /data/local/tmp on Android) -// and is set in TEMP_DIRECTORY_PATH. TEMP_DIRECTORY_PATH ends with '/' -// - Global shared memory files go in: -// {tmp}/.dotnet/shm/global/ -// - Session-scoped shared memory files go in: -// {tmp}/.dotnet/shm/session/ -// - Lock files associated with global shared memory files go in: -// {tmp}/.dotnet/lockfiles/global/ -// - Lock files associated with session-scoped shared memory files go in: -// {tmp}/.dotnet/lockfiles/session/ - -#define SHARED_MEMORY_MAX_FILE_NAME_CHAR_COUNT (_MAX_FNAME - 1) -#define SHARED_MEMORY_MAX_NAME_CHAR_COUNT (_countof("Global\\") - 1 + SHARED_MEMORY_MAX_FILE_NAME_CHAR_COUNT) - -#define SHARED_MEMORY_TEMP_DIRECTORY_PATH TEMP_DIRECTORY_PATH -#define SHARED_MEMORY_RUNTIME_TEMP_DIRECTORY_PATH TEMP_DIRECTORY_PATH ".dotnet" - -#define SHARED_MEMORY_SHARED_MEMORY_DIRECTORY_PATH TEMP_DIRECTORY_PATH ".dotnet/shm" -#define SHARED_MEMORY_LOCK_FILES_DIRECTORY_PATH TEMP_DIRECTORY_PATH ".dotnet/lockfiles" -static_assert_no_msg(_countof(SHARED_MEMORY_LOCK_FILES_DIRECTORY_PATH) >= _countof(SHARED_MEMORY_SHARED_MEMORY_DIRECTORY_PATH)); - -#define SHARED_MEMORY_GLOBAL_DIRECTORY_NAME "global" -#define SHARED_MEMORY_SESSION_DIRECTORY_NAME_PREFIX "session" -static_assert_no_msg(_countof(SHARED_MEMORY_SESSION_DIRECTORY_NAME_PREFIX) >= _countof(SHARED_MEMORY_GLOBAL_DIRECTORY_NAME)); - -#define SHARED_MEMORY_UNIQUE_TEMP_NAME_TEMPLATE TEMP_DIRECTORY_PATH ".coreclr.XXXXXX" - -#define SHARED_MEMORY_MAX_SESSION_ID_CHAR_COUNT (10) - -#define SHARED_MEMORY_MAX_FILE_PATH_CHAR_COUNT \ - ( \ - _countof(SHARED_MEMORY_LOCK_FILES_DIRECTORY_PATH) - 1 + \ - 1 /* path separator */ + \ - _countof(SHARED_MEMORY_SESSION_DIRECTORY_NAME_PREFIX) - 1 + \ - SHARED_MEMORY_MAX_SESSION_ID_CHAR_COUNT + \ - 1 /* path separator */ + \ - SHARED_MEMORY_MAX_FILE_NAME_CHAR_COUNT \ - ) -static_assert_no_msg(SHARED_MEMORY_MAX_FILE_PATH_CHAR_COUNT + 1 /* null terminator */ <= MAX_LONGPATH); - -class AutoFreeBuffer -{ -private: - void *m_buffer; - bool m_cancel; - -public: - AutoFreeBuffer(void *buffer); - ~AutoFreeBuffer(); - -public: - void Cancel(); -}; - -enum class SharedMemoryError : DWORD -{ - NameEmpty = ERROR_INVALID_PARAMETER, - NameTooLong = ERROR_FILENAME_EXCED_RANGE, - NameInvalid = ERROR_INVALID_NAME, - HeaderMismatch = ERROR_INVALID_HANDLE, - OutOfMemory = ERROR_NOT_ENOUGH_MEMORY, - IO = ERROR_OPEN_FAILED -}; - -class SharedMemoryException -{ -private: - DWORD m_errorCode; - -public: - SharedMemoryException(DWORD errorCode); - DWORD GetErrorCode() const; -}; - -class SharedMemoryHelpers -{ -private: - static const mode_t PermissionsMask_CurrentUser_ReadWriteExecute; - static const mode_t PermissionsMask_AllUsers_ReadWrite; - static const mode_t PermissionsMask_AllUsers_ReadWriteExecute; -public: - static const UINT32 InvalidProcessId; - static const SIZE_T InvalidThreadId; - static const UINT64 InvalidSharedThreadId; - -public: - static SIZE_T AlignDown(SIZE_T value, SIZE_T alignment); - static SIZE_T AlignUp(SIZE_T value, SIZE_T alignment); - - static void *Alloc(SIZE_T byteCount); - - template static SIZE_T CopyString(char (&destination)[DestinationByteCount], SIZE_T destinationStartOffset, const char (&source)[SourceByteCount]); - template static SIZE_T CopyString(char (&destination)[DestinationByteCount], SIZE_T destinationStartOffset, LPCSTR source, SIZE_T sourceCharCount); - template static SIZE_T AppendUInt32String(char (&destination)[DestinationByteCount], SIZE_T destinationStartOffset, UINT32 value); - - static bool EnsureDirectoryExists(const char *path, bool isGlobalLockAcquired, bool createIfNotExist = true, bool isSystemDirectory = false); -private: - static int Open(LPCSTR path, int flags, mode_t mode = static_cast(0)); -public: - static int OpenDirectory(LPCSTR path); - static int CreateOrOpenFile(LPCSTR path, bool createIfNotExist = true, bool *createdRef = nullptr); - static void CloseFile(int fileDescriptor); - - static SIZE_T GetFileSize(int fileDescriptor); - static void SetFileSize(int fileDescriptor, SIZE_T byteCount); - - static void *MemoryMapFile(int fileDescriptor, SIZE_T byteCount); - - static bool TryAcquireFileLock(int fileDescriptor, int operation); - static void ReleaseFileLock(int fileDescriptor); -}; - -class SharedMemoryId -{ -private: - LPCSTR m_name; - SIZE_T m_nameCharCount; - bool m_isSessionScope; // false indicates global scope - -public: - SharedMemoryId(); - SharedMemoryId(LPCSTR name, SIZE_T nameCharCount, bool isSessionScope); - SharedMemoryId(LPCSTR name); - -public: - LPCSTR GetName() const; - SIZE_T GetNameCharCount() const; - bool IsSessionScope() const; - bool Equals(SharedMemoryId *other) const; - -public: - SIZE_T AppendSessionDirectoryName(char (&path)[SHARED_MEMORY_MAX_FILE_PATH_CHAR_COUNT + 1], SIZE_T pathCharCount) const; -}; - -enum class SharedMemoryType : UINT8 -{ - Mutex -}; - -class SharedMemorySharedDataHeader -{ -private: - union - { - struct - { - SharedMemoryType m_type; - UINT8 m_version; - }; - UINT64 _raw; // use the same size for the header on all archs, and align the data to a pointer - }; - -public: - static SIZE_T DetermineTotalByteCount(SIZE_T dataByteCount); - -public: - SharedMemorySharedDataHeader(SharedMemoryType type, UINT8 version); - -public: - SharedMemoryType GetType() const; - UINT8 GetVersion() const; - void *GetData(); -}; - -class SharedMemoryProcessDataBase -{ -public: - virtual void Close(bool isAbruptShutdown, bool releaseSharedData) - { - } - - virtual ~SharedMemoryProcessDataBase() - { - } -}; - -class SharedMemoryProcessDataHeader -{ -private: - SIZE_T m_refCount; - SharedMemoryId m_id; - SharedMemoryProcessDataBase *m_data; - int m_fileDescriptor; - SharedMemorySharedDataHeader *m_sharedDataHeader; - SIZE_T m_sharedDataTotalByteCount; - SharedMemoryProcessDataHeader *m_nextInProcessDataHeaderList; - -public: - static SharedMemoryProcessDataHeader *CreateOrOpen(LPCSTR name, SharedMemorySharedDataHeader requiredSharedDataHeader, SIZE_T sharedDataByteCount, bool createIfNotExist, bool *createdRef); - -public: - static SharedMemoryProcessDataHeader *PalObject_GetProcessDataHeader(CorUnix::IPalObject *object); - static void PalObject_SetProcessDataHeader(CorUnix::IPalObject *object, SharedMemoryProcessDataHeader *processDataHeader); - static void PalObject_Close(CorUnix::CPalThread *thread, CorUnix::IPalObject *object, bool isShuttingDown, bool cleanUpPalSharedState); - -private: - SharedMemoryProcessDataHeader(SharedMemoryId *id, int fileDescriptor, SharedMemorySharedDataHeader *sharedDataHeader, SIZE_T sharedDataTotalByteCount); -public: - static SharedMemoryProcessDataHeader *New(SharedMemoryId *id, int fileDescriptor, SharedMemorySharedDataHeader *sharedDataHeader, SIZE_T sharedDataTotalByteCount); - ~SharedMemoryProcessDataHeader(); - void Close(); - -public: - SharedMemoryId *GetId(); - SharedMemoryProcessDataBase *GetData() const; - void SetData(SharedMemoryProcessDataBase *data); - SharedMemorySharedDataHeader *GetSharedDataHeader() const; - SIZE_T GetSharedDataTotalByteCount() const; - SharedMemoryProcessDataHeader *GetNextInProcessDataHeaderList() const; - void SetNextInProcessDataHeaderList(SharedMemoryProcessDataHeader *next); - -public: - void IncRefCount(); - void DecRefCount(); -}; - -class SharedMemoryManager -{ -private: - static CRITICAL_SECTION s_creationDeletionProcessLock; - static int s_creationDeletionLockFileDescriptor; - -private: - static SharedMemoryProcessDataHeader *s_processDataHeaderListHead; - -#ifdef _DEBUG -private: - static SIZE_T s_creationDeletionProcessLockOwnerThreadId; - static SIZE_T s_creationDeletionFileLockOwnerThreadId; -#endif // _DEBUG - -public: - static void StaticInitialize(); - static void StaticClose(); - -public: - static void AcquireCreationDeletionProcessLock(); - static void ReleaseCreationDeletionProcessLock(); - static void AcquireCreationDeletionFileLock(); - static void ReleaseCreationDeletionFileLock(); - -#ifdef _DEBUG -public: - static bool IsCreationDeletionProcessLockAcquired(); - static bool IsCreationDeletionFileLockAcquired(); -#endif // _DEBUG - -public: - static void AddProcessDataHeader(SharedMemoryProcessDataHeader *processDataHeader); - static void RemoveProcessDataHeader(SharedMemoryProcessDataHeader *processDataHeader); - static SharedMemoryProcessDataHeader *FindProcessDataHeader(SharedMemoryId *id); -}; - -#endif // !_PAL_SHARED_MEMORY_H_ diff --git a/src/pal/src/include/pal/sharedmemory.inl b/src/pal/src/include/pal/sharedmemory.inl deleted file mode 100644 index 69b8704b6..000000000 --- a/src/pal/src/include/pal/sharedmemory.inl +++ /dev/null @@ -1,53 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#ifndef _PAL_SHARED_MEMORY_INL_ -#define _PAL_SHARED_MEMORY_INL_ - -#include "sharedmemory.h" - -#include "dbgmsg.h" - -#include - -template -SIZE_T SharedMemoryHelpers::CopyString( - char (&destination)[DestinationByteCount], - SIZE_T destinationStartOffset, - const char(&source)[SourceByteCount]) -{ - return CopyString(destination, destinationStartOffset, source, SourceByteCount - 1); -} - -template -SIZE_T SharedMemoryHelpers::CopyString( - char (&destination)[DestinationByteCount], - SIZE_T destinationStartOffset, - LPCSTR source, - SIZE_T sourceCharCount) -{ - _ASSERTE(destinationStartOffset < DestinationByteCount); - _ASSERTE(sourceCharCount < DestinationByteCount - destinationStartOffset); - _ASSERTE(strlen(source) == sourceCharCount); - - memcpy_s(&destination[destinationStartOffset], DestinationByteCount - destinationStartOffset, source, sourceCharCount + 1); - return destinationStartOffset + sourceCharCount; -} - -template -SIZE_T SharedMemoryHelpers::AppendUInt32String( - char (&destination)[DestinationByteCount], - SIZE_T destinationStartOffset, - UINT32 value) -{ - _ASSERTE(destination != nullptr); - _ASSERTE(destinationStartOffset < DestinationByteCount); - - int valueCharCount = - sprintf_s(&destination[destinationStartOffset], DestinationByteCount - destinationStartOffset, "%u", value); - _ASSERTE(valueCharCount > 0); - return destinationStartOffset + valueCharCount; -} - -#endif // !_PAL_SHARED_MEMORY_INL_ diff --git a/src/pal/src/include/pal/signal.hpp b/src/pal/src/include/pal/signal.hpp deleted file mode 100644 index dfe21f10f..000000000 --- a/src/pal/src/include/pal/signal.hpp +++ /dev/null @@ -1,140 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*++ - - - -Module Name: - - include/pal/signal.hpp - -Abstract: - Private signal handling utilities for SEH - - - ---*/ - -#ifndef _PAL_SIGNAL_HPP_ -#define _PAL_SIGNAL_HPP_ - -#if !HAVE_MACH_EXCEPTIONS - -struct SignalHandlerWorkerReturnPoint; - -/*++ -Function : - CallSignalHandlerWrapperX - - These functions are never called, only a fake stack frame will be setup to have a return - address set to SignalHandlerWorkerReturnX during SIGSEGV handling. - It enables the unwinder to unwind stack from the handling code to the actual failure site. - - There are four variants of this function based on what stack alignment needs to be done - to ensure properly aligned stack pointer at the call site of the signal_handler_worker. - -Parameters : - none - - (no return value) ---*/ -extern "C" void CallSignalHandlerWrapper0(); -extern "C" void CallSignalHandlerWrapper4(); -extern "C" void CallSignalHandlerWrapper8(); -extern "C" void CallSignalHandlerWrapper12(); - -// Offset of the return address from the signal_handler_worker in the CallSignalHandlerWrapperX -// relative to the start of the function. -// There are four offsets matching the stack alignments as described in the function header above. -extern "C" int SignalHandlerWorkerReturnOffset0; -extern "C" int SignalHandlerWorkerReturnOffset4; -extern "C" int SignalHandlerWorkerReturnOffset8; -extern "C" int SignalHandlerWorkerReturnOffset12; - -/*++ -Function : - signal_handler_worker - - Handles signal on the original stack where the signal occured. - Invoked via setcontext. - -Parameters : - POSIX signal handler parameter list ("man sigaction" for details) - returnPoint - context to which the function returns if the common_signal_handler returns - - (no return value) ---*/ -extern "C" void signal_handler_worker(int code, siginfo_t *siginfo, void *context, SignalHandlerWorkerReturnPoint* returnPoint); - -/*++ -Function : - ExecuteHandlerOnOriginalStack - - Executes signal_handler_worker on the original stack where the signal occured. - It installs fake stack frame to enable stack unwinding to the signal source location. - -Parameters : - POSIX signal handler parameter list ("man sigaction" for details) - returnPoint - context to which the function returns if the common_signal_handler returns - - (no return value) ---*/ -void ExecuteHandlerOnOriginalStack(int code, siginfo_t *siginfo, void *context, SignalHandlerWorkerReturnPoint* returnPoint); - -/*++ -Function : - EnsureSignalAlternateStack - - Ensure that alternate stack for signal handling is allocated for the current thread - -Parameters : - None - -Return : - TRUE in case of a success, FALSE otherwise ---*/ -BOOL EnsureSignalAlternateStack(); - -/*++ -Function : - FreeSignalAlternateStack - - Free alternate stack for signal handling - -Parameters : - None - -Return : - None ---*/ -void FreeSignalAlternateStack(); - -#endif // !HAVE_MACH_EXCEPTIONS - -/*++ -Function : - SEHInitializeSignals - - Set-up signal handlers to catch signals and translate them to exceptions - -Parameters : - flags: PAL initialization flags - -Return : - TRUE in case of a success, FALSE otherwise ---*/ -BOOL SEHInitializeSignals(DWORD flags); - -/*++ -Function : - SEHCleanupSignals - - Restore default signal handlers - - (no parameters, no return value) ---*/ -void SEHCleanupSignals(); - -#endif /* _PAL_SIGNAL_HPP_ */ diff --git a/src/pal/src/include/pal/synchcache.hpp b/src/pal/src/include/pal/synchcache.hpp deleted file mode 100644 index 0abc7ddcd..000000000 --- a/src/pal/src/include/pal/synchcache.hpp +++ /dev/null @@ -1,397 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*++ - - - -Module Name: - - include/pal/synchcache.hpp - -Abstract: - Simple look-aside cache for unused objects with default - constructor or no constructor - - - ---*/ - -#ifndef _SYNCH_CACHE_H_ -#define _SYNCH_CACHE_H_ - -#include "pal/thread.hpp" -#include "pal/malloc.hpp" - -namespace CorUnix -{ - template class CSynchCache - { - typedef union _USynchCacheStackNode - { - union _USynchCacheStackNode * next; - BYTE objraw[sizeof(T)]; - } USynchCacheStackNode; - - static const int MaxDepth = 256; - - Volatile m_pHead; - CRITICAL_SECTION m_cs; - Volatile m_iDepth; - int m_iMaxDepth; -#ifdef _DEBUG - int m_iMaxTrackedDepth; -#endif - - void Lock(CPalThread * pthrCurrent) - { InternalEnterCriticalSection(pthrCurrent, &m_cs); } - void Unlock(CPalThread * pthrCurrent) - { InternalLeaveCriticalSection(pthrCurrent, &m_cs); } - - public: - CSynchCache(int iMaxDepth = MaxDepth) : - m_pHead(NULL), - m_iDepth(0), - m_iMaxDepth(iMaxDepth) -#ifdef _DEBUG - ,m_iMaxTrackedDepth(0) -#endif - { - InternalInitializeCriticalSection(&m_cs); - if (m_iMaxDepth < 0) - { - m_iMaxDepth = 0; - } - } - - ~CSynchCache() - { - Flush(NULL, true); - InternalDeleteCriticalSection(&m_cs); - } - -#ifdef _DEBUG - int GetMaxTrackedDepth() { return m_iMaxTrackedDepth; } -#endif - - T * Get(CPalThread * pthrCurrent) - { - T * pObj = NULL; - - Get(pthrCurrent, 1, &pObj); - return pObj; - } - - int Get(CPalThread * pthrCurrent, int n, T ** ppObjs) - { - void * pvObjRaw; - USynchCacheStackNode * pNode; - int i = 0,j; - - Lock(pthrCurrent); - pNode = m_pHead; - while (pNode && i < n) - { - ppObjs[i] = (T *)pNode; - pNode = pNode->next; - i++; - } - m_pHead = pNode; - m_iDepth -= i; - -#ifdef _DEBUG - if (NULL == m_pHead && m_iDepth != 0) - { - // Can't use ASSERT here, since this is header - // is included by other headers with inline methods - // which causes template instatiation in the header - // where the DEBUG CHANNEL is not defined and cannot - // be defined - fprintf(stderr,"SYNCCACHE: Invalid cache depth value"); - DebugBreak(); - } -#endif // _DEBUG - - Unlock(pthrCurrent); - - for (j=i;j(); - if (NULL == pvObjRaw) - break; -#ifdef _DEBUG - memset(pvObjRaw, 0, sizeof(USynchCacheStackNode)); -#endif - ppObjs[j] = reinterpret_cast(pvObjRaw); - } - - for (i=0;i(pobj); - - if (NULL == pobj) - { - return; - } - - pobj->~T(); - - Lock(pthrCurrent); - if (m_iDepth < m_iMaxDepth) - { -#ifdef _DEBUG - if (m_iDepth > m_iMaxTrackedDepth) - { - m_iMaxTrackedDepth = m_iDepth; - } -#endif - pNode->next = m_pHead; - m_pHead = pNode; - m_iDepth++; - } - else - { - InternalDelete((char *)pNode); - } - Unlock(pthrCurrent); - } - - void Flush(CPalThread * pthrCurrent, bool fDontLock = false) - { - USynchCacheStackNode * pNode, * pTemp; - - if (!fDontLock) - { - Lock(pthrCurrent); - } - pNode = m_pHead; - m_pHead = NULL; - m_iDepth = 0; - if (!fDontLock) - { - Unlock(pthrCurrent); - } - - while (pNode) - { - pTemp = pNode; - pNode = pNode->next; - InternalDelete((char *)pTemp); - } - } - }; - - template class CSHRSynchCache - { - union _USHRSynchCacheStackNode; // fwd declaration - typedef struct _SHRCachePTRs - { - union _USHRSynchCacheStackNode * pNext; - SharedID shrid; - } SHRCachePTRs; - typedef union _USHRSynchCacheStackNode - { - SHRCachePTRs pointers; - BYTE objraw[sizeof(T)]; - } USHRSynchCacheStackNode; - - static const int MaxDepth = 256; - static const int PreAllocFactor = 10; // Everytime a Get finds no available - // cached raw intances, it preallocates - // MaxDepth/PreAllocFactor new raw - // instances and store them into the - // cache before continuing - - Volatile m_pHead; - CRITICAL_SECTION m_cs; - Volatile m_iDepth; - int m_iMaxDepth; -#ifdef _DEBUG - int m_iMaxTrackedDepth; -#endif - - void Lock(CPalThread * pthrCurrent) - { InternalEnterCriticalSection(pthrCurrent, &m_cs); } - void Unlock(CPalThread * pthrCurrent) - { InternalLeaveCriticalSection(pthrCurrent, &m_cs); } - - public: - CSHRSynchCache(int iMaxDepth = MaxDepth) : - m_pHead(NULL), - m_iDepth(0), - m_iMaxDepth(iMaxDepth) -#ifdef _DEBUG - ,m_iMaxTrackedDepth(0) -#endif - { - InternalInitializeCriticalSection(&m_cs); - if (m_iMaxDepth < 0) - { - m_iMaxDepth = 0; - } - } - - ~CSHRSynchCache() - { - Flush(NULL, true); - InternalDeleteCriticalSection(&m_cs); - } - -#ifdef _DEBUG - int GetMaxTrackedDepth() { return m_iMaxTrackedDepth; } -#endif - - SharedID Get(CPalThread * pthrCurrent) - { - SharedID shridObj = NULL; - - Get(pthrCurrent, 1, &shridObj); - return shridObj; - } - - int Get(CPalThread * pthrCurrent, int n, SharedID * shridpObjs) - { - SharedID shridObj; - void * pvObjRaw = NULL; - USHRSynchCacheStackNode * pNode; - int i = 0, j, k; - - Lock(pthrCurrent); - pNode = m_pHead; - while (pNode && i < n) - { - shridpObjs[i] = pNode->pointers.shrid; - pvObjRaw = (void *)pNode; - pNode = pNode->pointers.pNext; - i++; - } - m_pHead = pNode; - m_iDepth -= i; - -#ifdef _DEBUG - if (NULL == m_pHead && m_iDepth != 0) - { - // Can't use ASSERT here, since this is header - // (see comment above) - fprintf(stderr,"SYNCCACHE: Invalid cache depth value"); - DebugBreak(); - } -#endif // _DEBUG - - if (0 == m_iDepth) - { - for (k=0; k(pNode), 0, sizeof(USHRSynchCacheStackNode)); -#endif - pNode->pointers.shrid = shridObj; - pNode->pointers.pNext = m_pHead; - m_pHead = pNode; - m_iDepth++; - } - } - - Unlock(pthrCurrent); - - for (j=i;j(pNode); - - pObj->~T(); - - pNode->pointers.shrid = shridObj; - - Lock(pthrCurrent); - if (m_iDepth < m_iMaxDepth) - { - m_iDepth++; -#ifdef _DEBUG - if (m_iDepth > m_iMaxTrackedDepth) - { - m_iMaxTrackedDepth = m_iDepth; - } -#endif - pNode->pointers.pNext = m_pHead; - m_pHead = pNode; - } - else - { - free(shridObj); - } - Unlock(pthrCurrent); - } - - void Flush(CPalThread * pthrCurrent, bool fDontLock = false) - { - USHRSynchCacheStackNode * pNode, * pTemp; - SharedID shridTemp; - - if (!fDontLock) - { - Lock(pthrCurrent); - } - pNode = m_pHead; - m_pHead = NULL; - m_iDepth = 0; - if (!fDontLock) - { - Unlock(pthrCurrent); - } - - while (pNode) - { - pTemp = pNode; - pNode = pNode->pointers.pNext; - shridTemp = pTemp->pointers.shrid; - free(shridTemp); - } - } - }; -} - -#endif // _SYNCH_CACHE_H_ - diff --git a/src/pal/src/include/pal/synchobjects.hpp b/src/pal/src/include/pal/synchobjects.hpp deleted file mode 100644 index 06758cf8f..000000000 --- a/src/pal/src/include/pal/synchobjects.hpp +++ /dev/null @@ -1,219 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*++ - - - -Module Name: - - include/pal/synchobjects.hpp - -Abstract: - Header file for synchronization manager and controllers - - - ---*/ - -#ifndef _SINCHOBJECTS_HPP_ -#define _SINCHOBJECTS_HPP_ - -#include "corunix.hpp" -#include "threadinfo.hpp" -#include "mutex.hpp" -#include "shm.hpp" -#include "list.h" - -#include - -#define SharedID SHMPTR -#define SharedIDToPointer(shID) SHMPTR_TO_TYPED_PTR(PVOID, shID) -#define SharedIDToTypePointer(TYPE,shID) SHMPTR_TO_TYPED_PTR(TYPE, shID) - -namespace CorUnix -{ - DWORD InternalWaitForMultipleObjectsEx( - CPalThread * pthrCurrent, - DWORD nCount, - CONST HANDLE *lpHandles, - BOOL bWaitAll, - DWORD dwMilliseconds, - BOOL bAlertable, - BOOL bPrioritize = FALSE); - - DWORD InternalSignalObjectAndWait( - CPalThread *thread, - HANDLE hObjectToSignal, - HANDLE hObjectToWaitOn, - DWORD dwMilliseconds, - BOOL bAlertable); - - PAL_ERROR InternalSleepEx( - CPalThread * pthrCurrent, - DWORD dwMilliseconds, - BOOL bAlertable); - - enum THREAD_STATE - { - TS_IDLE, - TS_STARTING, - TS_RUNNING, - TS_FAILED, - TS_DONE, - }; - - // forward declarations - struct _ThreadWaitInfo; - struct _WaitingThreadsListNode; - class CSynchData; - - typedef struct _WaitingThreadsListNode * PWaitingThreadsListNode; - typedef struct _OwnedObjectsListNode * POwnedObjectsListNode; - typedef struct _ThreadApcInfoNode * PThreadApcInfoNode; - - typedef struct _ThreadWaitInfo - { - WaitType wtWaitType; - WaitDomain wdWaitDomain; - LONG lObjCount; - LONG lSharedObjCount; - CPalThread * pthrOwner; - PWaitingThreadsListNode rgpWTLNodes[MAXIMUM_WAIT_OBJECTS]; - - _ThreadWaitInfo() : wtWaitType(SingleObject), wdWaitDomain(LocalWait), - lObjCount(0), lSharedObjCount(0), - pthrOwner(NULL) {} - } ThreadWaitInfo; - - typedef struct _ThreadNativeWaitData - { - pthread_mutex_t mutex; - pthread_cond_t cond; - int iPred; - DWORD dwObjectIndex; - ThreadWakeupReason twrWakeupReason; - bool fInitialized; - - _ThreadNativeWaitData() : - iPred(0), - dwObjectIndex(0), - twrWakeupReason(WaitSucceeded), - fInitialized(false) - { - } - - ~_ThreadNativeWaitData(); - } ThreadNativeWaitData; - - class CThreadSynchronizationInfo : public CThreadInfoInitializer - { - friend class CPalSynchronizationManager; - friend class CSynchWaitController; - - THREAD_STATE m_tsThreadState; - SharedID m_shridWaitAwakened; - Volatile m_lLocalSynchLockCount; - Volatile m_lSharedSynchLockCount; - LIST_ENTRY m_leOwnedObjsList; - - CRITICAL_SECTION m_ownedNamedMutexListLock; - NamedMutexProcessData *m_ownedNamedMutexListHead; - - ThreadNativeWaitData m_tnwdNativeData; - ThreadWaitInfo m_twiWaitInfo; - -#ifdef SYNCHMGR_SUSPENSION_SAFE_CONDITION_SIGNALING - static const int PendingSignalingsArraySize = 10; - LONG m_lPendingSignalingCount; - CPalThread * m_rgpthrPendingSignalings[PendingSignalingsArraySize]; - LIST_ENTRY m_lePendingSignalingsOverflowList; -#endif // SYNCHMGR_SUSPENSION_SAFE_CONDITION_SIGNALING - - public: - - CThreadSynchronizationInfo(); - virtual ~CThreadSynchronizationInfo(); - - // - // CThreadInfoInitializer methods - // - virtual PAL_ERROR InitializePreCreate(void); - - virtual PAL_ERROR InitializePostCreate( - CPalThread *pthrCurrent, - SIZE_T threadId, - DWORD dwLwpId - ); - - THREAD_STATE GetThreadState(void) - { - return m_tsThreadState; - }; - - void SetThreadState(THREAD_STATE tsThreadState) - { - m_tsThreadState = tsThreadState; - }; - - ThreadNativeWaitData * GetNativeData() - { - return &m_tnwdNativeData; - } - -#if SYNCHMGR_SUSPENSION_SAFE_CONDITION_SIGNALING - PAL_ERROR RunDeferredThreadConditionSignalings(); -#endif // SYNCHMGR_SUSPENSION_SAFE_CONDITION_SIGNALING - - // NOTE: the following methods provide non-synchronized access to - // the list of owned objects for this thread. Any thread - // accessing this list MUST own the appropriate - // synchronization lock(s). - void AddObjectToOwnedList(POwnedObjectsListNode pooln); - void RemoveObjectFromOwnedList(POwnedObjectsListNode pooln); - POwnedObjectsListNode RemoveFirstObjectFromOwnedList(void); - - void AddOwnedNamedMutex(NamedMutexProcessData *processData); - void RemoveOwnedNamedMutex(NamedMutexProcessData *processData); - NamedMutexProcessData *RemoveFirstOwnedNamedMutex(); - bool OwnsNamedMutex(NamedMutexProcessData *processData); - - // The following methods provide access to the native wait lock for - // those implementations that need a lock to protect the support for - // native thread blocking (e.g.: pthread conditions) - void AcquireNativeWaitLock(void); - void ReleaseNativeWaitLock(void); - bool TryAcquireNativeWaitLock(void); - }; - - class CThreadApcInfo : public CThreadInfoInitializer - { - friend class CPalSynchronizationManager; - - PThreadApcInfoNode m_ptainHead; - PThreadApcInfoNode m_ptainTail; - - public: - CThreadApcInfo() : - m_ptainHead(NULL), - m_ptainTail(NULL) - { - } - }; - - class CPalSynchMgrController - { - public: - static IPalSynchronizationManager * CreatePalSynchronizationManager(); - - static PAL_ERROR StartWorker(CPalThread * pthrCurrent); - - static PAL_ERROR PrepareForShutdown(void); - - static PAL_ERROR Shutdown(CPalThread *pthrCurrent, bool fFullCleanup); - }; -} - -#endif // _SINCHOBJECTS_HPP_ - diff --git a/src/pal/src/include/pal/thread.hpp b/src/pal/src/include/pal/thread.hpp index ddacfb903..e5ba6f9dd 100644 --- a/src/pal/src/include/pal/thread.hpp +++ b/src/pal/src/include/pal/thread.hpp @@ -23,20 +23,16 @@ Abstract: #include "corunix.hpp" #include "shm.hpp" #include "cs.hpp" +#include "pal/threadinfo.hpp" #include #include -#if HAVE_MACH_EXCEPTIONS -#include -#endif // HAVE_MACH_EXCEPTIONS - -#include "threadsusp.hpp" -#include "tls.hpp" -#include "synchobjects.hpp" #include namespace CorUnix { + extern pthread_key_t thObjKey; + enum PalThreadType { UserCreatedThread, @@ -44,136 +40,11 @@ namespace CorUnix SignalHandlerThread }; - PAL_ERROR - InternalCreateThread( - CPalThread *pThread, - LPSECURITY_ATTRIBUTES lpThreadAttributes, - DWORD dwStackSize, - LPTHREAD_START_ROUTINE lpStartAddress, - LPVOID lpParameter, - DWORD dwCreationFlags, - PalThreadType eThreadType, - LPDWORD lpThreadId, - HANDLE *phThread - ); - - PAL_ERROR - InternalGetThreadPriority( - CPalThread *pThread, - HANDLE hTargetThread, - int *piNewPriority - ); - - PAL_ERROR - InternalSetThreadPriority( - CPalThread *pThread, - HANDLE hTargetThread, - int iNewPriority - ); - - PAL_ERROR - InternalGetThreadDataFromHandle( - CPalThread *pThread, - HANDLE hThread, - DWORD dwRightsRequired, - CPalThread **ppTargetThread, - IPalObject **ppobjThread - ); - - VOID - InternalEndCurrentThread( - CPalThread *pThread - ); - - PAL_ERROR - InternalCreateDummyThread( - CPalThread *pThread, - LPSECURITY_ATTRIBUTES lpThreadAttributes, - CPalThread **ppDummyThread, - HANDLE *phThread - ); - PAL_ERROR CreateThreadData( CPalThread **ppThread ); - PAL_ERROR - CreateThreadObject( - CPalThread *pThread, - CPalThread *pNewThread, - HANDLE *phThread - ); - - PAL_ERROR - InitializeEndingThreadsData( - void - ); - - BOOL - GetThreadTimesInternal( - IN HANDLE hThread, - OUT LPFILETIME lpKernelTime, - OUT LPFILETIME lpUserTime); - -#ifdef FEATURE_PAL_SXS -#if HAVE_MACH_EXCEPTIONS - - // Structure used to return data about a single handler to a caller. - struct MachExceptionHandler - { - exception_mask_t m_mask; - exception_handler_t m_handler; - exception_behavior_t m_behavior; - thread_state_flavor_t m_flavor; - }; - - // Class abstracting previously registered Mach exception handlers for a thread. - struct CThreadMachExceptionHandlers - { - public: - // Maximum number of exception ports we hook. Must be the count - // of all bits set in the exception masks defined in machexception.h. - static const int s_nPortsMax = 6; - - // Saved exception ports, exactly as returned by - // thread_swap_exception_ports. - mach_msg_type_number_t m_nPorts; - exception_mask_t m_masks[s_nPortsMax]; - exception_handler_t m_handlers[s_nPortsMax]; - exception_behavior_t m_behaviors[s_nPortsMax]; - thread_state_flavor_t m_flavors[s_nPortsMax]; - - CThreadMachExceptionHandlers() : - m_nPorts(-1) - { - } - - // Get handler details for a given type of exception. If successful the structure pointed at by - // pHandler is filled in and true is returned. Otherwise false is returned. - bool GetHandler(exception_type_t eException, MachExceptionHandler *pHandler); - - private: - // Look for a handler for the given exception within the given handler node. Return its index if - // successful or -1 otherwise. - int GetIndexOfHandler(exception_mask_t bmExceptionMask); - }; -#endif // HAVE_MACH_EXCEPTIONS -#endif // FEATURE_PAL_SXS - - class CThreadSEHInfo : public CThreadInfoInitializer - { - public: -#if !HAVE_MACH_EXCEPTIONS - BOOL safe_state; - int signal_code; -#endif // !HAVE_MACH_EXCEPTIONSG - - CThreadSEHInfo() - { - }; - }; - /* In the windows CRT there is a constant defined for the max width of a _ecvt conversion. That constant is 348. 348 for the value, plus the exponent value, decimal, and sign if required. */ @@ -205,58 +76,15 @@ namespace CorUnix class CPalThread { - friend - PAL_ERROR - CorUnix::InternalCreateThread( - CPalThread *, - LPSECURITY_ATTRIBUTES, - DWORD, - LPTHREAD_START_ROUTINE, - LPVOID, - DWORD, - PalThreadType, - LPDWORD, - HANDLE* - ); - - friend - PAL_ERROR - InternalCreateDummyThread( - CPalThread *pThread, - LPSECURITY_ATTRIBUTES lpThreadAttributes, - CPalThread **ppDummyThread, - HANDLE *phThread - ); - - friend - PAL_ERROR - InternalSetThreadPriority( - CPalThread *, - HANDLE, - int - ); - friend PAL_ERROR CreateThreadData( CPalThread **ppThread ); - friend - PAL_ERROR - CreateThreadObject( - CPalThread *pThread, - CPalThread *pNewThread, - HANDLE *phThread - ); - - friend CatchHardwareExceptionHolder; - private: CPalThread *m_pNext; - DWORD m_dwExitCode; - BOOL m_fExitCodeSet; CRITICAL_SECTION m_csLock; bool m_fLockInitialized; bool m_fIsDummy; @@ -275,13 +103,6 @@ namespace CorUnix LONG m_lRefCount; - // - // The IPalObject for this thread. The thread will release its reference - // to this object when it exits. - // - - IPalObject *m_pThreadObject; - // // Thread ID info // @@ -290,109 +111,22 @@ namespace CorUnix DWORD m_dwLwpId; pthread_t m_pthreadSelf; -#if HAVE_MACH_THREADS - mach_port_t m_machPortSelf; -#endif - - // > 0 when there is an exception holder which causes h/w - // exceptions to be sent down the C++ exception chain. - int m_hardwareExceptionHolderCount; - - // - // Start info - // - - LPTHREAD_START_ROUTINE m_lpStartAddress; - LPVOID m_lpStartParameter; - BOOL m_bCreateSuspended; - - int m_iThreadPriority; - PalThreadType m_eThreadType; - - // - // pthread mutex / condition variable for gating thread startup. - // InternalCreateThread waits on the condition variable to determine - // when the new thread has reached passed all failure points in - // the entry routine - // - - pthread_mutex_t m_startMutex; - pthread_cond_t m_startCond; - bool m_fStartItemsInitialized; - bool m_fStartStatus; - bool m_fStartStatusSet; - - // Base address of the stack of this thread - void* m_stackBase; - // Limit address of the stack of this thread - void* m_stackLimit; - - // - // The thread entry routine (called from InternalCreateThread) - // - - static void* ThreadEntry(void * pvParam); - -#ifdef FEATURE_PAL_SXS - // - // Data for PAL side-by-side support - // - - private: - // This is set whenever this thread is currently executing within - // a region of code that depends on this instance of the PAL - // in the process. - bool m_fInPal; - -#if HAVE_MACH_EXCEPTIONS - // Record of Mach exception handlers that were already registered when we register our own CoreCLR - // specific handlers. - CThreadMachExceptionHandlers m_sMachExceptionHandlers; -#endif // HAVE_MACH_EXCEPTIONS -#endif // FEATURE_PAL_SXS - public: // // Embedded information for areas owned by other subsystems // - CThreadSynchronizationInfo synchronizationInfo; - CThreadSuspensionInfo suspensionInfo; - CThreadSEHInfo sehInfo; - CThreadTLSInfo tlsInfo; - CThreadApcInfo apcInfo; CThreadCRTInfo crtInfo; CPalThread() : m_pNext(NULL), - m_dwExitCode(STILL_ACTIVE), - m_fExitCodeSet(FALSE), m_fLockInitialized(FALSE), - m_fIsDummy(FALSE), m_lRefCount(1), - m_pThreadObject(NULL), m_threadId(0), m_dwLwpId(0), - m_pthreadSelf(0), -#if HAVE_MACH_THREADS - m_machPortSelf(0), -#endif - m_hardwareExceptionHolderCount(0), - m_lpStartAddress(NULL), - m_lpStartParameter(NULL), - m_bCreateSuspended(FALSE), - m_iThreadPriority(THREAD_PRIORITY_NORMAL), - m_eThreadType(UserCreatedThread), - m_fStartItemsInitialized(FALSE), - m_fStartStatus(FALSE), - m_fStartStatusSet(FALSE), - m_stackBase(NULL), - m_stackLimit(NULL) -#ifdef FEATURE_PAL_SXS - , m_fInPal(TRUE) -#endif // FEATURE_PAL_SXS + m_pthreadSelf(0) { }; @@ -413,24 +147,6 @@ namespace CorUnix void ); - // - // SetStartStatus is called by THREADEntry or InternalSuspendNewThread - // to inform InternalCreateThread of the results of the thread's - // initialization. InternalCreateThread calls WaitForStartStatus to - // obtain this information (and will not return to its caller until - // the info is available). - // - - void - SetStartStatus( - bool fStartSucceeded - ); - - bool - WaitForStartStatus( - void - ); - void Lock( CPalThread *pThread @@ -447,35 +163,6 @@ namespace CorUnix InternalLeaveCriticalSection(pThread, &m_csLock); }; - // - // The following three methods provide access to the - // native lock used to protect thread native wait data. - // - - void - AcquireNativeWaitLock( - void - ) - { - synchronizationInfo.AcquireNativeWaitLock(); - } - - void - ReleaseNativeWaitLock( - void - ) - { - synchronizationInfo.ReleaseNativeWaitLock(); - } - - bool - TryAcquireNativeWaitLock( - void - ) - { - return synchronizationInfo.TryAcquireNativeWaitLock(); - } - static void SetLastError( DWORD dwLastError @@ -494,24 +181,6 @@ namespace CorUnix return errno; }; - void - SetExitCode( - DWORD dwExitCode - ) - { - m_dwExitCode = dwExitCode; - m_fExitCodeSet = TRUE; - }; - - BOOL - GetExitCode( - DWORD *pdwExitCode - ) - { - *pdwExitCode = m_dwExitCode; - return m_fExitCodeSet; - }; - SIZE_T GetThreadId( void @@ -536,78 +205,6 @@ namespace CorUnix return m_pthreadSelf; }; -#if HAVE_MACH_THREADS - mach_port_t - GetMachPortSelf( - void - ) - { - return m_machPortSelf; - }; -#endif - - bool - IsHardwareExceptionsEnabled() - { - return m_hardwareExceptionHolderCount > 0; - } - - LPTHREAD_START_ROUTINE - GetStartAddress( - void - ) - { - return m_lpStartAddress; - }; - - LPVOID - GetStartParameter( - void - ) - { - return m_lpStartParameter; - }; - - BOOL - GetCreateSuspended( - void - ) - { - return m_bCreateSuspended; - }; - - PalThreadType - GetThreadType( - void - ) - { - return m_eThreadType; - }; - - int - GetThreadPriority( - void - ) - { - return m_iThreadPriority; - }; - - IPalObject * - GetThreadObject( - void - ) - { - return m_pThreadObject; - } - - BOOL - IsDummy( - void - ) - { - return m_fIsDummy; - }; - CPalThread* GetNext( void @@ -633,86 +230,9 @@ namespace CorUnix ReleaseThreadReference( void ); - - // Get base address of the current thread's stack - static - void * - GetStackBase( - void - ); - - // Get cached base address of this thread's stack - // Can be called only for the current thread. - void * - GetCachedStackBase( - void - ); - - // Get limit address of the current thread's stack - static - void * - GetStackLimit( - void - ); - - // Get cached limit address of this thread's stack - // Can be called only for the current thread. - void * - GetCachedStackLimit( - void - ); - -#ifdef FEATURE_PAL_SXS - // - // Functions for PAL side-by-side support - // - - // This function needs to be called on a thread when it enters - // a region of code that depends on this instance of the PAL - // in the process. - PAL_ERROR Enter(PAL_Boundary boundary); - - // This function needs to be called on a thread when it leaves - // a region of code that depends on this instance of the PAL - // in the process. - PAL_ERROR Leave(PAL_Boundary boundary); - - // Returns TRUE whenever this thread is executing in a region - // of code that depends on this instance of the PAL in the process. - BOOL IsInPal() - { - return m_fInPal; - }; - -#if HAVE_MACH_EXCEPTIONS - // Hook Mach exceptions, i.e., call thread_swap_exception_ports - // to replace the thread's current exception ports with our own. - // The previously active exception ports are saved. Called when - // this thread enters a region of code that depends on this PAL. - // Should only fail on internal errors. - PAL_ERROR EnableMachExceptions(); - - // Unhook Mach exceptions, i.e., call thread_set_exception_ports - // to restore the thread's exception ports with those we saved - // in EnableMachExceptions. Called when this thread leaves a - // region of code that depends on this PAL. Should only fail - // on internal errors. - PAL_ERROR DisableMachExceptions(); - - // The exception handling thread needs to be able to get at the list of handlers that installing our - // own handler on a thread has displaced (in case we need to forward an exception that we don't want - // to handle). - CThreadMachExceptionHandlers *GetSavedMachHandlers() - { - return &m_sMachExceptionHandlers; - } -#endif // HAVE_MACH_EXCEPTIONS -#endif // FEATURE_PAL_SXS }; -#if defined(FEATURE_PAL_SXS) extern "C" CPalThread *CreateCurrentThreadData(); -#endif // FEATURE_PAL_SXS inline CPalThread *GetCurrentPalThread() { @@ -722,43 +242,10 @@ namespace CorUnix inline CPalThread *InternalGetCurrentThread() { CPalThread *pThread = GetCurrentPalThread(); -#if defined(FEATURE_PAL_SXS) if (pThread == nullptr) pThread = CreateCurrentThreadData(); -#endif // FEATURE_PAL_SXS return pThread; } - -/*** - - $$TODO: These are needed only to support cross-process thread duplication - - class CThreadImmutableData - { - public: - DWORD dwProcessId; - }; - - class CThreadSharedData - { - public: - DWORD dwThreadId; - DWORD dwExitCode; - }; -***/ - - // - // The process local information for a thread is just a pointer - // to the underlying CPalThread object. - // - - class CThreadProcessLocalData - { - public: - CPalThread *pThread; - }; - - extern CObjectType otThread; } BOOL @@ -771,15 +258,16 @@ TLSCleanup( void ); -VOID -WaitForEndingThreads( - void - ); - extern int free_threads_spinlock; -extern PAL_ActivationFunction g_activationFunction; -extern PAL_SafeActivationCheckFunction g_safeActivationCheckFunction; +#define SYNCSPINLOCK_F_ASYMMETRIC 1 + +#define SPINLOCKInit(lock) (*(lock) = 0) +#define SPINLOCKDestroy SPINLOCKInit + +void SPINLOCKAcquire (LONG * lock, unsigned int flags); +void SPINLOCKRelease (LONG * lock); +DWORD SPINLOCKTryAcquire (LONG * lock); /*++ Macro: diff --git a/src/pal/src/include/pal/threadsusp.hpp b/src/pal/src/include/pal/threadsusp.hpp deleted file mode 100644 index dfd65d0f8..000000000 --- a/src/pal/src/include/pal/threadsusp.hpp +++ /dev/null @@ -1,384 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*++ - - - -Module Name: - - include/pal/threadsusp.hpp - -Abstract: - Declarations for thread suspension - - - ---*/ - -#ifndef _PAL_THREADSUSP_HPP -#define _PAL_THREADSUSP_HPP - -// Need this ifdef since this header is included by .c files so they can use the diagnostic function. -#ifdef __cplusplus - -// Note: do not include malloc.hpp from this header. The template InternalDelete -// needs to know the layout of class CPalThread, which includes a member of type -// CThreadSuspensionInfo, which is defined later in this header, and it is not -// yet known at this point. -// If any future change should bring this issue back, the circular dependency can -// be further broken by making the InternalDelete's CPalThread argument a -// templatized argument, so that type checking on it takes place only at -// instantiation time. -#include "pal/threadinfo.hpp" -#include "pal/thread.hpp" -#include "pal/printfcpp.hpp" -#include "pal/mutex.hpp" -#include "pal/init.h" -#if !HAVE_MACH_EXCEPTIONS -#include -#endif // !HAVE_MACH_EXCEPTIONS -#include -#include - -// We have a variety of options for synchronizing thread suspensions and resumptions between the requestor and -// target threads. Analyze the various capabilities given to us by configure and define one of three macros -// here for simplicity: -// USE_POSIX_SEMAPHORES -// USE_SYSV_SEMAPHORES -// USE_PTHREAD_CONDVARS -#if HAS_POSIX_SEMAPHORES - -// Favor posix semaphores. -#define USE_POSIX_SEMAPHORES 1 - -#if HAVE_SYS_SEMAPHORE_H -#include -#elif HAVE_SEMAPHORE_H -#include -#endif // HAVE_SYS_SEMAPHORE_H - -#elif HAS_PTHREAD_MUTEXES && HAVE_MACH_EXCEPTIONS - -// Can only use the pthread solution if we're not using signals since pthread mutexes are not signal safe. -#define USE_PTHREAD_CONDVARS 1 - -#include - -#elif HAS_SYSV_SEMAPHORES - -// SYSV semaphores are our last choice since they're shared across processes so it's possible to leak them -// on abnormal process termination. -#define USE_SYSV_SEMAPHORES 1 - -#include -#include - -#else -#error "Don't know how to synchronize thread suspends and resumes on this platform" -#endif // HAS_POSIX_SEMAPHORES - -#include - -namespace CorUnix -{ -#ifdef _DEBUG -#define MAX_TRACKED_CRITSECS 8 -#endif - - PAL_ERROR - InternalResumeThread( - CPalThread *pthrResumer, - HANDLE hTarget, - DWORD *pdwSuspendCount - ); - - class CThreadSuspensionInfo : public CThreadInfoInitializer - { - private: - BOOL m_fPending; // TRUE if a suspension is pending on a thread (because the thread is in an unsafe region) - BOOL m_fSelfsusp; // TRUE if thread is self suspending and while thread is self suspended - BOOL m_fSuspendedForShutdown; // TRUE once the thread is suspended during PAL cleanup - int m_nBlockingPipe; // blocking pipe used for a process that was created suspended -#ifdef _DEBUG - Volatile m_lNumThreadsSuspendedByThisThread; // number of threads that this thread has suspended; used for suspension diagnostics -#endif -#if DEADLOCK_WHEN_THREAD_IS_SUSPENDED_WHILE_BLOCKED_ON_MUTEX - int m_nSpinlock; // thread's suspension spinlock, which is used to synchronize suspension and resumption attempts -#else // DEADLOCK_WHEN_THREAD_IS_SUSPENDED_WHILE_BLOCKED_ON_MUTEX - pthread_mutex_t m_ptmSuspmutex; // thread's suspension mutex, which is used to synchronize suspension and resumption attempts - BOOL m_fSuspmutexInitialized; -#endif // DEADLOCK_WHEN_THREAD_IS_SUSPENDED_WHILE_BLOCKED_ON_MUTEX -#if USE_POSIX_SEMAPHORES - sem_t m_semSusp; // suspension semaphore - sem_t m_semResume; // resumption semaphore - BOOL m_fSemaphoresInitialized; -#elif USE_SYSV_SEMAPHORES - // necessary id's and sembuf structures for SysV semaphores - int m_nSemsuspid; // id for the suspend semaphore - int m_nSemrespid; // id for the resume semaphore - struct sembuf m_sbSemwait; // struct representing a wait operation - struct sembuf m_sbSempost; // struct representing a post operation -#elif USE_PTHREAD_CONDVARS - pthread_cond_t m_condSusp; // suspension condition variable - pthread_mutex_t m_mutexSusp; // mutex associated with the condition above - BOOL m_fSuspended; // set to true once the suspend has been acknowledged - - pthread_cond_t m_condResume; // resumption condition variable - pthread_mutex_t m_mutexResume; // mutex associated with the condition above - BOOL m_fResumed; // set to true once the resume has been acknowledged - - BOOL m_fSemaphoresInitialized; -#endif // USE_POSIX_SEMAPHORES - - /* Most of the variables above are either accessed by a thread - holding the appropriate suspension mutex(es) or are only - accessed by their own threads (and thus don't require - synchronization). - - m_fPending, m_fSuspendedForShutdown, - m_fSuspendSignalSent, and m_fResumeSignalSent - may be set by a different thread than the owner and thus - require synchronization. - - m_fSelfsusp is set to TRUE only by its own thread but may be later - accessed by other threads. - - m_lNumThreadsSuspendedByThisThread is accessed by its owning - thread and therefore does not require synchronization. */ - -#ifdef _DEBUG - VOID - IncrNumThreadsSuspendedByThisThread( - ) - { - InterlockedIncrement(&m_lNumThreadsSuspendedByThisThread); - }; - - VOID - DecrNumThreadsSuspendedByThisThread( - ) - { - InterlockedDecrement(&m_lNumThreadsSuspendedByThisThread); - }; -#endif - - VOID - AcquireSuspensionLocks( - CPalThread *pthrSuspender, - CPalThread *pthrTarget - ); - - VOID - ReleaseSuspensionLocks( - CPalThread *pthrSuspender, - CPalThread *pthrTarget - ); - -#if USE_POSIX_SEMAPHORES - sem_t* - GetSuspendSemaphore( - void - ) - { - return &m_semSusp; - }; - - sem_t* - GetResumeSemaphore( - void - ) - { - return &m_semResume; - }; -#elif USE_SYSV_SEMAPHORES - int - GetSuspendSemaphoreId( - void - ) - { - return m_nSemsuspid; - }; - - sembuf* - GetSemaphorePostBuffer( - void - ) - { - return &m_sbSempost; - }; -#endif // USE_POSIX_SEMAPHORES - -#if DEADLOCK_WHEN_THREAD_IS_SUSPENDED_WHILE_BLOCKED_ON_MUTEX - LONG* - GetSuspensionSpinlock( - void - ) - { - return &m_nSpinlock; - } -#else // DEADLOCK_WHEN_THREAD_IS_SUSPENDED_WHILE_BLOCKED_ON_MUTEX - pthread_mutex_t* - GetSuspensionMutex( - void - ) - { - return &m_ptmSuspmutex; - } -#endif // DEADLOCK_WHEN_THREAD_IS_SUSPENDED_WHILE_BLOCKED_ON_MUTEX - - void - SetSuspPending( - BOOL fPending - ) - { - m_fPending = fPending; - }; - - BOOL - GetSuspPending( - void - ) - { - return m_fPending; - }; - - void - SetSelfSusp( - BOOL fSelfsusp - ) - { - m_fSelfsusp = fSelfsusp; - }; - - BOOL - GetSelfSusp( - void - ) - { - return m_fSelfsusp; - }; - - void - PostOnSuspendSemaphore(); - - void - WaitOnSuspendSemaphore(); - - void - PostOnResumeSemaphore(); - - void - WaitOnResumeSemaphore(); - - static - BOOL - TryAcquireSuspensionLock( - CPalThread* pthrTarget - ); - - int GetBlockingPipe( - void - ) - { - return m_nBlockingPipe; - }; - - public: - virtual PAL_ERROR InitializePreCreate(); - - CThreadSuspensionInfo() - : m_fPending(FALSE) - , m_fSelfsusp(FALSE) - , m_fSuspendedForShutdown(FALSE) - , m_nBlockingPipe(-1) -#ifdef _DEBUG - , m_lNumThreadsSuspendedByThisThread(0) -#endif // _DEBUG -#if !DEADLOCK_WHEN_THREAD_IS_SUSPENDED_WHILE_BLOCKED_ON_MUTEX - , m_fSuspmutexInitialized(FALSE) -#endif -#if USE_POSIX_SEMAPHORES || USE_PTHREAD_CONDVARS - , m_fSemaphoresInitialized(FALSE) -#endif - { - InitializeSuspensionLock(); - }; - - virtual ~CThreadSuspensionInfo(); - -#ifdef _DEBUG - LONG - GetNumThreadsSuspendedByThisThread( - void - ) - { - return m_lNumThreadsSuspendedByThisThread; - }; -#endif // _DEBUG - -#if USE_SYSV_SEMAPHORES - void - DestroySemaphoreIds( - void - ); -#endif - void - SetSuspendedForShutdown( - BOOL fSuspendedForShutdown - ) - { - m_fSuspendedForShutdown = fSuspendedForShutdown; - }; - - BOOL - GetSuspendedForShutdown( - void - ) - { - return m_fSuspendedForShutdown; - }; - - void - AcquireSuspensionLock( - CPalThread *pthrCurrent - ); - - void - ReleaseSuspensionLock( - CPalThread *pthrCurrent - ); - - PAL_ERROR - InternalSuspendNewThreadFromData( - CPalThread *pThread - ); - - PAL_ERROR - InternalResumeThreadFromData( - CPalThread *pthrResumer, - CPalThread *pthrTarget, - DWORD *pdwSuspendCount - ); - - VOID InitializeSuspensionLock(); - - void SetBlockingPipe( - int nBlockingPipe - ) - { - m_nBlockingPipe = nBlockingPipe; - }; - }; -} //end CorUnix - -extern const BYTE WAKEUPCODE; // use for pipe reads during self suspend. -#endif // __cplusplus - -#ifdef USE_GLOBAL_LOCK_FOR_SUSPENSION -extern LONG g_ssSuspensionLock; -#endif - -#endif // _PAL_THREADSUSP_HPP - diff --git a/src/pal/src/include/pal/tls.hpp b/src/pal/src/include/pal/tls.hpp deleted file mode 100644 index a4d9926c4..000000000 --- a/src/pal/src/include/pal/tls.hpp +++ /dev/null @@ -1,65 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*++ - - - -Module Name: - - include/pal/tls.hpp - -Abstract: - Header file for thread local storage - - - ---*/ - -#ifndef _PAL_TLS_HPP -#define _PAL_TLS_HPP - -#include "threadinfo.hpp" - -namespace CorUnix -{ - /* This is the number of slots available for use in TlsAlloc(). - sTlsSlotFields in thread/localstorage.c must be this number - of bits. */ -#define TLS_SLOT_SIZE 64 - - class CThreadTLSInfo : public CThreadInfoInitializer - { - public: - LPVOID tlsSlots[TLS_SLOT_SIZE]; - - virtual - PAL_ERROR - InitializePostCreate( - CPalThread *pThread, - SIZE_T threadId, - DWORD dwLwpId - ); - - CThreadTLSInfo() - { - ZeroMemory(tlsSlots, sizeof(tlsSlots)); - }; - }; - - // - // InternalGetCurrentThread obtains the CPalThread instance for the - // calling thread. That instance should only be used by the calling - // thread. If another thread will at some point need access to this - // thread information it should be given a referenced pointer to - // the IPalObject stored within the CPalThread. - // - - extern pthread_key_t thObjKey; - - CPalThread *InternalGetCurrentThread(); -} - -#endif // _PAL_TLS_HPP - diff --git a/src/pal/src/init/pal.cpp b/src/pal/src/init/pal.cpp index 005fadaed..a38d525cd 100644 --- a/src/pal/src/init/pal.cpp +++ b/src/pal/src/init/pal.cpp @@ -22,33 +22,20 @@ Abstract: SET_DEFAULT_DEBUG_CHANNEL(PAL); // some headers have code with asserts, so do this first #include "pal/thread.hpp" -#include "pal/synchobjects.hpp" -#include "pal/procobj.hpp" -#include "pal/cs.hpp" #include "pal/file.hpp" #include "pal/map.hpp" #include "../objmgr/shmobjectmanager.hpp" -#include "pal/seh.hpp" #include "pal/palinternal.h" -#include "pal/sharedmemory.h" -#include "pal/shmemory.h" #include "pal/process.h" -#include "../thread/procprivate.hpp" #include "pal/module.h" #include "pal/virtual.h" #include "pal/misc.h" #include "pal/environ.h" #include "pal/utils.h" -#include "pal/debug.h" #include "pal/locale.h" #include "pal/init.h" -#include "pal/numa.h" #include "pal/stackstring.hpp" -#if HAVE_MACH_EXCEPTIONS -#include "../exception/machexception.h" -#endif - #include #include #include @@ -94,10 +81,7 @@ using namespace CorUnix; extern "C" BOOL CRTInitStdStreams( void ); - Volatile init_count = 0; -Volatile shutdown_intent = 0; -Volatile g_coreclrInitialized = 0; static BOOL g_fThreadDataAvailable = FALSE; static pthread_mutex_t init_critsec_mutex = PTHREAD_MUTEX_INITIALIZER; @@ -110,12 +94,16 @@ static PCRITICAL_SECTION init_critsec = NULL; static int Initialize(int argc, const char *const argv[], DWORD flags); static BOOL INIT_IncreaseDescriptorLimit(void); -static LPWSTR INIT_FormatCommandLine (int argc, const char * const *argv); -static LPWSTR INIT_ConvertEXEPath(LPCSTR exe_name); -#ifdef _DEBUG -extern void PROCDumpThreadList(void); -#endif +// Process and session ID of this process. +DWORD gPID = (DWORD) -1; +DWORD gSID = (DWORD) -1; + +// +// Key used for associating CPalThread's with the underlying pthread +// (through pthread_setspecific) +// +pthread_key_t CorUnix::thObjKey; #if defined(__APPLE__) static bool RunningNatively() @@ -132,29 +120,6 @@ static bool RunningNatively() } #endif // __APPLE__ -/*++ -Function: - PAL_Initialize - -Abstract: - This function is the first function of the PAL to be called. - Internal structure initialization is done here. It could be called - several time by the same process, a reference count is kept. - -Return: - 0 if successful - -1 if it failed - ---*/ -int -PALAPI -PAL_Initialize( - int argc, - const char *const argv[]) -{ - return Initialize(argc, argv, PAL_INITIALIZE); -} - /*++ Function: PAL_InitializeDLL @@ -255,10 +220,8 @@ Initialize( PAL_ERROR palError = ERROR_GEN_FAILURE; CPalThread *pThread = NULL; CSharedMemoryObjectManager *pshmom = NULL; - LPWSTR command_line = NULL; - LPWSTR exe_path = NULL; - int retval = -1; bool fFirstTimeInit = false; + int retval = -1; /* the first ENTRY within the first call to PAL_Initialize is a special case, since debug channels are not initialized yet. So in that case the @@ -346,37 +309,6 @@ Initialize( // we use large numbers of threads or have many open files. } - SharedMemoryManager::StaticInitialize(); - - /* initialize the shared memory infrastructure */ - if (!SHMInitialize()) - { - ERROR("Shared memory initialization failed!\n"); - goto CLEANUP0; - } - - // - // Initialize global process data - // - - palError = InitializeProcessData(); - if (NO_ERROR != palError) - { - ERROR("Unable to initialize process data\n"); - goto CLEANUP1; - } - -#if HAVE_MACH_EXCEPTIONS - // Mach exception port needs to be set up before the thread - // data or threads are set up. - if (!SEHInitializeMachExceptions(flags)) - { - ERROR("SEHInitializeMachExceptions failed!\n"); - palError = ERROR_GEN_FAILURE; - goto CLEANUP1; - } -#endif // HAVE_MACH_EXCEPTIONS - // // Allocate the initial thread data // @@ -385,20 +317,7 @@ Initialize( if (NO_ERROR != palError) { ERROR("Unable to create initial thread data\n"); - goto CLEANUP1a; - } - - PROCAddThread(pThread, pThread); - - // - // Initialize mutex and condition variable used to synchronize the ending threads count - // - - palError = InitializeEndingThreadsData(); - if (NO_ERROR != palError) - { - ERROR("Unable to create ending threads data\n"); - goto CLEANUP1b; + goto CLEANUP2; } // @@ -414,7 +333,7 @@ Initialize( { ERROR("Unable to initialize module manager\n"); palError = ERROR_INTERNAL_ERROR; - goto CLEANUP1b; + goto CLEANUP2; } // @@ -426,7 +345,7 @@ Initialize( { ERROR("Unable to allocate new object manager\n"); palError = ERROR_OUTOFMEMORY; - goto CLEANUP1b; + goto CLEANUP2; } palError = pshmom->Initialize(); @@ -434,23 +353,10 @@ Initialize( { ERROR("object manager initialization failed!\n"); InternalDelete(pshmom); - goto CLEANUP1b; + goto CLEANUP2; } g_pObjectManager = pshmom; - - // - // Initialize the synchronization manager - // - g_pSynchronizationManager = - CPalSynchMgrController::CreatePalSynchronizationManager(); - - if (NULL == g_pSynchronizationManager) - { - palError = ERROR_NOT_ENOUGH_MEMORY; - ERROR("Failure creating synchronization manager\n"); - goto CLEANUP1c; - } } else { @@ -459,88 +365,21 @@ Initialize( palError = ERROR_GEN_FAILURE; - if (argc > 0 && argv != NULL) - { - /* build the command line */ - command_line = INIT_FormatCommandLine(argc, argv); - if (NULL == command_line) - { - ERROR("Error building command line\n"); - goto CLEANUP1d; - } - - /* find out the application's full path */ - exe_path = INIT_ConvertEXEPath(argv[0]); - if (NULL == exe_path) - { - ERROR("Unable to find exe path\n"); - goto CLEANUP1e; - } - - if (NULL == command_line || NULL == exe_path) - { - ERROR("Failed to process command-line parameters!\n"); - goto CLEANUP2; - } - - palError = InitializeProcessCommandLine( - command_line, - exe_path); - - if (NO_ERROR != palError) - { - ERROR("Unable to initialize command line\n"); - goto CLEANUP2; - } - - // InitializeProcessCommandLine took ownership of this memory. - command_line = NULL; - -#ifdef PAL_PERF - // Initialize the Profiling structure - if(FALSE == PERFInitialize(command_line, exe_path)) - { - ERROR("Performance profiling initial failed\n"); - goto CLEANUP2; - } - PERFAllocThreadInfo(); -#endif - - if (!LOADSetExeName(exe_path)) - { - ERROR("Unable to set exe name\n"); - goto CLEANUP2; - } - - // LOADSetExeName took ownership of this memory. - exe_path = NULL; - } - if (init_count == 0) { - // - // Create the initial process and thread objects - // - palError = CreateInitialProcessAndThreadObjects(pThread); - if (NO_ERROR != palError) - { - ERROR("Unable to create initial process and thread objects\n"); - goto CLEANUP2; - } - palError = ERROR_GEN_FAILURE; if (FALSE == TIMEInitialize()) { ERROR("Unable to initialize TIME support\n"); - goto CLEANUP6; + goto CLEANUP2; } /* Initialize the File mapping critical section. */ if (FALSE == MAPInitialize()) { ERROR("Unable to initialize file mapping support\n"); - goto CLEANUP6; + goto CLEANUP2; } /* Initialize the Virtual* functions. */ @@ -551,26 +390,6 @@ Initialize( goto CLEANUP10; } - if (flags & PAL_INITIALIZE_SYNC_THREAD) - { - // - // Tell the synchronization manager to start its worker thread - // - palError = CPalSynchMgrController::StartWorker(pThread); - if (NO_ERROR != palError) - { - ERROR("Synch manager failed to start worker thread\n"); - goto CLEANUP13; - } - } - - /* initialize structured exception handling stuff (signals, etc) */ - if (FALSE == SEHInitialize(pThread, flags)) - { - ERROR("Unable to initialize SEH support\n"); - goto CLEANUP13; - } - if (flags & PAL_INITIALIZE_STD_HANDLES) { /* create file objects for standard handles */ @@ -587,12 +406,6 @@ Initialize( goto CLEANUP15; } - if (FALSE == NUMASupportInitialize()) - { - ERROR("Unable to initialize NUMA support\n"); - goto CLEANUP15; - } - TRACE("First-time PAL initialization complete.\n"); init_count++; @@ -605,12 +418,6 @@ Initialize( { init_count++; - // Behave the same wrt entering the PAL independent of whether this - // is the first call to PAL_Initialize or not. The first call implied - // PAL_Enter by virtue of creating the CPalThread for the current - // thread, and its starting state is to be in the PAL. - (void)PAL_Enter(PAL_BoundaryTop); - TRACE("Initialization count increases to %d\n", init_count.Load()); SetLastError(NO_ERROR); @@ -618,31 +425,14 @@ Initialize( } goto done; - NUMASupportCleanup(); /* No cleanup required for CRTInitStdStreams */ CLEANUP15: FILECleanupStdHandles(); CLEANUP14: - SEHCleanup(); -CLEANUP13: VIRTUALCleanup(); CLEANUP10: MAPCleanup(); -CLEANUP6: - PROCCleanupInitialProcess(); CLEANUP2: - free(exe_path); -CLEANUP1e: - free(command_line); -CLEANUP1d: - // Cleanup synchronization manager -CLEANUP1c: - // Cleanup object manager -CLEANUP1b: - // Cleanup initial thread data -CLEANUP1a: - // Cleanup global process data -CLEANUP1: SHMCleanup(); CLEANUP0: TLSCleanup(); @@ -677,64 +467,6 @@ exit : return retval; } - -/*++ -Function: - PAL_InitializeCoreCLR - -Abstract: - A replacement for PAL_Initialize when loading CoreCLR. Instead of taking a command line (which CoreCLR - instances aren't given anyway) the path into which the CoreCLR is installed is supplied instead. This is - cached so that PAL_GetPALDirectoryW can return it later. - - This routine also makes sure the psuedo dynamic libraries PALRT and mscorwks have their initialization - methods called. - -Return: - ERROR_SUCCESS if successful - An error code, if it failed - ---*/ -PAL_ERROR -PALAPI -PAL_InitializeCoreCLR(const char *szExePath) -{ - // Fake up a command line to call PAL initialization with. - int result = Initialize(1, &szExePath, PAL_INITIALIZE_CORECLR); - if (result != 0) - { - return GetLastError(); - } - - // Check for a repeated call (this is a no-op). - if (InterlockedIncrement(&g_coreclrInitialized) > 1) - { - PAL_Enter(PAL_BoundaryTop); - return ERROR_SUCCESS; - } - - // Now that the PAL is initialized it's safe to call the initialization methods for the code that used to - // be dynamically loaded libraries but is now statically linked into CoreCLR just like the PAL, i.e. the - // PAL RT and mscorwks. - if (!LOADInitializeCoreCLRModule()) - { - return ERROR_DLL_INIT_FAILED; - } - - if (!PROCAbortInitialize()) - { - printf("PROCAbortInitialize FAILED %d (%s)\n", errno, strerror(errno)); - return ERROR_GEN_FAILURE; - } - - if (!InitializeFlushProcessWriteBuffers()) - { - return ERROR_GEN_FAILURE; - } - - return ERROR_SUCCESS; -} - /*++ Function: PAL_IsDebuggerPresent @@ -814,123 +546,6 @@ PAL_IsDebuggerPresent() #endif } -/*++ -Function: - PAL_EntryPoint - -Abstract: - This function should be used to wrap code that uses PAL library on thread that was not created by PAL. ---*/ -PALIMPORT -DWORD_PTR -PALAPI -PAL_EntryPoint( - IN LPTHREAD_START_ROUTINE lpStartAddress, - IN LPVOID lpParameter) -{ - CPalThread *pThread; - DWORD_PTR retval = (DWORD) -1; - - ENTRY("PAL_EntryPoint(lpStartAddress=%p, lpParameter=%p)\n", lpStartAddress, lpParameter); - - pThread = InternalGetCurrentThread(); - if (NULL == pThread) - { - /* This function works only for thread that called PAL_Initialize for now. */ - ERROR( "Unable to get the thread object.\n" ); - goto done; - } - - retval = (*lpStartAddress)(lpParameter); - -done: - LOGEXIT("PAL_EntryPoint returns int %d\n", retval); - return retval; -} - -/*++ -Function: - PAL_Shutdown - -Abstract: - This function shuts down the PAL WITHOUT exiting the current process. ---*/ -void -PALAPI -PAL_Shutdown( - void) -{ - TerminateCurrentProcessNoExit(FALSE /* bTerminateUnconditionally */); -} - -/*++ -Function: - PAL_Terminate - -Abstract: - This function is the called when a thread has finished using the PAL - library. It shuts down PAL and exits the current process. ---*/ -void -PALAPI -PAL_Terminate( - void) -{ - PAL_TerminateEx(0); -} - -/*++ -Function: -PAL_TerminateEx - -Abstract: -This function is the called when a thread has finished using the PAL -library. It shuts down PAL and exits the current process with -the specified exit code. ---*/ -void -PALAPI -PAL_TerminateEx( - int exitCode) -{ - ENTRY_EXTERNAL("PAL_TerminateEx()\n"); - - if (NULL == init_critsec) - { - /* note that these macros probably won't output anything, since the - debug channels haven't been initialized yet */ - ASSERT("PAL_Initialize has never been called!\n"); - LOGEXIT("PAL_Terminate returns.\n"); - } - - // Declare the beginning of shutdown - PALSetShutdownIntent(); - - LOGEXIT("PAL_TerminateEx is exiting the current process.\n"); - exit(exitCode); -} - -/*++ -Function: - PAL_InitializeDebug - -Abstract: - This function is the called when cordbg attaches to the process. ---*/ -void -PALAPI -PAL_InitializeDebug( - void) -{ - PERF_ENTRY(PAL_InitializeDebug); - ENTRY("PAL_InitializeDebug()\n"); -#if HAVE_MACH_EXCEPTIONS - MachExceptionInitializeDebug(); -#endif - LOGEXIT("PAL_InitializeDebug returns\n"); - PERF_EXIT(PAL_InitializeDebug); -} - /*++ Function: PALIsThreadDataInitialized @@ -942,59 +557,6 @@ BOOL PALIsThreadDataInitialized() return g_fThreadDataAvailable; } -/*++ -Function: - PALCommonCleanup - - Utility function to prepare for shutdown. - ---*/ -void -PALCommonCleanup() -{ - static bool cleanupDone = false; - - // Declare the beginning of shutdown - PALSetShutdownIntent(); - - if (!cleanupDone) - { - cleanupDone = true; - - // - // Let the synchronization manager know we're about to shutdown - // - CPalSynchMgrController::PrepareForShutdown(); - - SharedMemoryManager::StaticClose(); - -#ifdef _DEBUG - PROCDumpThreadList(); -#endif - } - - // Mark that the PAL is uninitialized - init_count = 0; -} - -BOOL PALIsShuttingDown() -{ - /* ROTORTODO: This function may be used to provide a reader/writer-like - mechanism (or a ref counting one) to prevent PAL APIs that need to access - PAL runtime data, from working when PAL is shutting down. Each of those API - should acquire a read access while executing. The shutting down code would - acquire a write lock, i.e. suspending any new incoming reader, and waiting - for the current readers to be done. That would allow us to get rid of the - dangerous suspend-all-other-threads at shutdown time */ - return shutdown_intent; -} - -void PALSetShutdownIntent() -{ - /* ROTORTODO: See comment in PALIsShuttingDown */ - shutdown_intent = TRUE; -} - /*++ Function: PALInitLock @@ -1089,199 +651,57 @@ static BOOL INIT_IncreaseDescriptorLimit(void) /*++ Function: - INIT_FormatCommandLine [Internal] + PROCAbort() -Abstract: - This function converts an array of arguments (argv) into a Unicode - command-line for use by GetCommandLineW - -Parameters : - int argc : number of arguments in argv - char **argv : argument list in an array of NULL-terminated strings - -Return value : - pointer to Unicode command line. This is a buffer allocated with malloc; - caller is responsible for freeing it with free() - -Note : not all peculiarities of Windows command-line processing are supported; - --what is supported : - -arguments with white-space must be double quoted (we'll just double-quote - all arguments to simplify things) - -some characters must be escaped with \ : particularly, the double-quote, - to avoid confusion with the double-quotes at the start and end of - arguments, and \ itself, to avoid confusion with escape sequences. --what is not supported: - -under Windows, \\ is interpreted as an escaped \ ONLY if it's followed by - an escaped double-quote \". \\\" is passed to argv as \", but \\a is - passed to argv as \\a... there may be other similar cases - -there may be other characters which must be escaped + Aborts the process after calling the shutdown cleanup handler. This function + should be called instead of calling abort() directly. + + Does not return --*/ -static LPWSTR INIT_FormatCommandLine (int argc, const char * const *argv) +PAL_NORETURN +VOID +PROCAbort() { - LPWSTR retval; - LPSTR command_line=NULL, command_ptr; - LPCSTR arg_ptr; - INT length, i,j; - BOOL bQuoted = FALSE; - - /* list of characters that need no be escaped with \ when building the - command line. currently " and \ */ - LPCSTR ESCAPE_CHARS="\"\\"; - - /* allocate temporary memory for the string. Play it safe : - double the length of each argument (in case they're composed - exclusively of escaped characters), and add 3 (for the double-quotes - and separating space). This is temporary anyway, we return a LPWSTR */ - length=0; - for(i=0; i(InternalMalloc(length)); - - if(!command_line) - { - ERROR("couldn't allocate memory for command line!\n"); - return NULL; - } - - command_ptr=command_line; - for(i=0; i(InternalMalloc((sizeof(WCHAR)*i))); - if(retval == NULL) - { - ERROR("can't allocate memory for Unicode command line!\n"); - free(command_line); - return NULL; - } - - if(!MultiByteToWideChar(CP_ACP, 0,command_line, i, retval, i)) - { - ASSERT("MultiByteToWideChar failure\n"); - free(retval); - retval = NULL; - } - else - TRACE("Command line is %s\n", command_line); - - free(command_line); - return retval; + // Abort the process after waiting for the core dump to complete + abort(); } /*++ Function: - INIT_ConvertEXEPath + GetCurrentProcessId -Abstract: - Check whether the executable path is valid, and convert its type (LPCSTR -> LPWSTR) - -Parameters: - LPCSTR exe_name : full path of the current executable - -Return: - pointer to buffer containing the full path. This buffer must be released - by the caller using free() - -Notes : - this function assumes that "exe_name" is in Unix style (no \) +See MSDN doc. --*/ -static LPWSTR INIT_ConvertEXEPath(LPCSTR exe_path) +DWORD +PALAPI +GetCurrentProcessId( + VOID) { - PathCharString real_path; - LPWSTR return_value; - INT return_size; - struct stat theStats; + PERF_ENTRY(GetCurrentProcessId); + ENTRY("GetCurrentProcessId()\n" ); - if (!strchr(exe_path, '/')) - { - ERROR( "The exe path is not fully specified\n" ); - return NULL; - } - - if (-1 == stat(exe_path, &theStats)) - { - ERROR( "The file does not exist\n" ); - return NULL; - } - - if (!CorUnix::RealPathHelper(exe_path, real_path)) - { - ERROR("realpath() failed!\n"); - return NULL; - } - - return_size = MultiByteToWideChar(CP_ACP, 0, real_path, -1, NULL, 0); - if (0 == return_size) - { - ASSERT("MultiByteToWideChar failure\n"); - return NULL; - } - - return_value = reinterpret_cast(InternalMalloc((return_size*sizeof(WCHAR)))); - if (NULL == return_value) - { - ERROR("Not enough memory to create full path\n"); - return NULL; - } - else - { - if (!MultiByteToWideChar(CP_ACP, 0, real_path, -1, - return_value, return_size)) - { - ASSERT("MultiByteToWideChar failure\n"); - free(return_value); - return_value = NULL; - } - else - { - TRACE("full path to executable is %s\n", real_path.GetString()); - } - } - - return return_value; + LOGEXIT("GetCurrentProcessId returns DWORD %#x\n", gPID); + PERF_EXIT(GetCurrentProcessId); + return gPID; } + + +/*++ +Function: + GetCurrentSessionId + +See MSDN doc. +--*/ +DWORD +PALAPI +GetCurrentSessionId( + VOID) +{ + PERF_ENTRY(GetCurrentSessionId); + ENTRY("GetCurrentSessionId()\n" ); + + LOGEXIT("GetCurrentSessionId returns DWORD %#x\n", gSID); + PERF_EXIT(GetCurrentSessionId); + return gSID; +} + diff --git a/src/pal/src/init/sxs.cpp b/src/pal/src/init/sxs.cpp deleted file mode 100644 index 3f323c6a6..000000000 --- a/src/pal/src/init/sxs.cpp +++ /dev/null @@ -1,335 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*++ - - - - - ---*/ - -#include "pal/dbgmsg.h" -#include "pal/thread.hpp" -#include "../thread/procprivate.hpp" -#include "pal/module.h" -#include "pal/process.h" -#include "pal/seh.hpp" -#include "pal/signal.hpp" - -using namespace CorUnix; - -#ifdef FEATURE_PAL_SXS - -SET_DEFAULT_DEBUG_CHANNEL(SXS); - -PAL_ERROR AllocatePalThread(CPalThread **ppThread); - -/************************* Enter *************************/ - -/*++ -Function: - PAL_Enter - -Abstract: - This function needs to be called on a thread when it enters - a region of code that depends on this instance of the PAL - in the process, and the current thread may or may not be - known to the PAL. This function can fail (for something else - than an internal error) if this is the first time that the - current thread entered this PAL. Note that PAL_Initialize - implies a call to this function. - - NOTE: This function must not modify LastError. ---*/ -PAL_ERROR -PALAPI -PAL_Enter(PAL_Boundary boundary) -{ - ENTRY_EXTERNAL("PAL_Enter(boundary=%u)\n", boundary); - - PAL_ERROR palError = ERROR_SUCCESS; - CPalThread *pThread = GetCurrentPalThread(); - if (pThread != NULL) - { - palError = pThread->Enter(boundary); - } - else - { - // If this assert fires, we'll have to pipe this information so that - // CPalThread's RunPostCreateInitializers call to SEHEnable - // can know what direction. - _ASSERT_MSG(PAL_BoundaryTop == boundary, "How are we entering a PAL " - "thread for the first time not from the top? (boundary=%u)", boundary); - - palError = AllocatePalThread(&pThread); - if (NO_ERROR != palError) - { - ERROR("Unable to allocate pal thread: error %d\n", palError); - } - } - - LOGEXIT("PAL_Enter returns %d\n", palError); - return palError; -} - -/*++ -Function: - CreateCurrentThreadData - -Abstract: - This function is called by the InternalGetOrCreateCurrentThread inlined - function to create the thread data when it is null meaning the thread has - never been in this PAL. - -Warning: - If the allocation fails, this function asserts and exits the process. ---*/ -extern "C" CPalThread * -CreateCurrentThreadData() -{ - CPalThread *pThread = NULL; - - if (PALIsThreadDataInitialized()) { - PAL_ERROR palError = AllocatePalThread(&pThread); - if (NO_ERROR != palError) - { - ASSERT("Unable to allocate pal thread: error %d - aborting\n", palError); - PROCAbort(); - } - } - - return pThread; -} - -PAL_ERROR -AllocatePalThread(CPalThread **ppThread) -{ - CPalThread *pThread = NULL; - PAL_ERROR palError; - -#if !HAVE_MACH_EXCEPTIONS - // Ensure alternate stack for SIGSEGV handling. Our SIGSEGV handler is set to - // run on an alternate stack and the stack needs to be allocated per thread. - if (!EnsureSignalAlternateStack()) - { - ERROR("Cannot allocate alternate stack for SIGSEGV handler!\n"); - palError = ERROR_NOT_ENOUGH_MEMORY; - goto exit; - } -#endif // !HAVE_MACH_EXCEPTIONS - - palError = CreateThreadData(&pThread); - if (NO_ERROR != palError) - { - goto exit; - } - - HANDLE hThread; - palError = CreateThreadObject(pThread, pThread, &hThread); - if (NO_ERROR != palError) - { - pthread_setspecific(thObjKey, NULL); - pThread->ReleaseThreadReference(); - goto exit; - } - - // Like CreateInitialProcessAndThreadObjects, we do not need this - // thread handle, since we're not returning it to anyone who will - // possibly release it. - (void)g_pObjectManager->RevokeHandle(pThread, hThread); - - PROCAddThread(pThread, pThread); - -exit: - *ppThread = pThread; - return palError; -} - -PALIMPORT -DWORD -PALAPI -PAL_EnterTop() -{ - return PAL_Enter(PAL_BoundaryTop); -} - - -/*++ -Function: - PAL_Reenter - -Abstract: - This function needs to be called on a thread when it enters - a region of code that depends on this instance of the PAL - in the process, and the current thread is already known to - the PAL. - - NOTE: This function must not modify LastError. ---*/ -VOID -PALAPI -PAL_Reenter(PAL_Boundary boundary) -{ - ENTRY_EXTERNAL("PAL_Reenter(boundary=%u)\n", boundary); - - CPalThread *pThread = GetCurrentPalThread(); - if (pThread == NULL) - { - ASSERT("PAL_Reenter called on a thread unknown to this PAL\n"); - } - - // We ignore the return code. This call should only fail on internal - // error, and we assert at the actual failure. - pThread->Enter(boundary); - - LOGEXIT("PAL_Reenter returns\n"); -} - -/*++ -Function: - PAL_HasEntered - -Abstract: - This function can be called to determine if the thread has entered the - PAL through PAL_Enter or related calls. ---*/ -BOOL -PALAPI -PAL_HasEntered() -{ - ENTRY_EXTERNAL("PAL_HasEntered()\n"); - - CPalThread *pThread = GetCurrentPalThread(); - if (pThread == NULL) - { - ASSERT("PAL_Reenter called on a thread unknown to this PAL\n"); - } - - LOGEXIT("PAL_HasEntered returned\n"); - - return pThread->IsInPal(); -} - -/*++ -Function: - PAL_ReenterForEH - -Abstract: - This function needs to be called on a thread when it enters - a region of code that depends on this instance of the PAL - in the process, and it is unknown whether the current thread - is already running in the PAL. Returns TRUE if and only if - the thread was not running in the PAL previously. - - NOTE: This function must not modify LastError. ---*/ -BOOL -PALAPI -PAL_ReenterForEH() -{ - // Only trace if we actually reenter (otherwise, too verbose) - // ENTRY_EXTERNAL("PAL_ReenterForEH()\n"); - // Thus we have to split up what ENTRY_EXTERNAL does. - CHECK_STACK_ALIGN; - - BOOL fEntered = FALSE; - - CPalThread *pThread = GetCurrentPalThread(); - if (pThread == NULL) - { - ASSERT("PAL_ReenterForEH called on a thread unknown to this PAL\n"); - } - else if (!pThread->IsInPal()) - { -#if _ENABLE_DEBUG_MESSAGES_ - DBG_PRINTF(DLI_ENTRY, defdbgchan, TRUE)("PAL_ReenterForEH()\n"); -#endif - - // We ignore the return code. This call should only fail on internal - // error, and we assert at the actual failure. - pThread->Enter(PAL_BoundaryEH); - fEntered = TRUE; - LOGEXIT("PAL_ReenterForEH returns TRUE\n"); - } - else - { - // LOGEXIT("PAL_ReenterForEH returns FALSE\n"); - } - - return fEntered; -} - -PAL_ERROR CPalThread::Enter(PAL_Boundary /* boundary */) -{ - if (m_fInPal) - { - WARN("Enter called on a thread that already runs in this PAL\n"); - return NO_ERROR; - } - m_fInPal = TRUE; - - return ERROR_SUCCESS; -} - - -/************************* Leave *************************/ - -/*++ -Function: - PAL_Leave - -Abstract: - This function needs to be called on a thread when it leaves a region - of code that depends on this instance of the PAL in the process. - - NOTE: This function must not modify LastError. ---*/ -VOID -PALAPI -PAL_Leave(PAL_Boundary boundary) -{ - ENTRY("PAL_Leave(boundary=%u)\n", boundary); - - CPalThread *pThread = GetCurrentPalThread(); - // We ignore the return code. This call should only fail on internal - // error, and we assert at the actual failure. - pThread->Leave(boundary); - - LOGEXIT("PAL_Leave returns\n"); -} - -PALIMPORT -VOID -PALAPI -PAL_LeaveBottom() -{ - PAL_Leave(PAL_BoundaryBottom); -} - -PALIMPORT -VOID -PALAPI -PAL_LeaveTop() -{ - PAL_Leave(PAL_BoundaryTop); -} - - -PAL_ERROR CPalThread::Leave(PAL_Boundary /* boundary */) -{ - if (!m_fInPal) - { - WARN("Leave called on a thread that is not running in this PAL\n"); - return ERROR_NOT_SUPPORTED; - } - - PAL_ERROR palError = ERROR_SUCCESS; - - m_fInPal = FALSE; - - return palError; -} - -#endif // FEATURE_PAL_SXS diff --git a/src/pal/src/libunwind/.gitignore b/src/pal/src/libunwind/.gitignore deleted file mode 100644 index 7b7905f0d..000000000 --- a/src/pal/src/libunwind/.gitignore +++ /dev/null @@ -1,79 +0,0 @@ -*.la -*.a -*.o -*.lo -*~ -*.pc - -.libs/ -.deps/ - -.dirstamp -Makefile -Makefile.in - -INSTALL -aclocal.m4 -autom4te.cache/ -config.log -config.status -config/ -configure -libtool - -doc/common.tex - -src/[GL]cursor_i.h -src/mk_[GL]cursor_i.s - -include/config.h -include/config.h.in -include/libunwind-common.h -include/stamp-h1 -include/libunwind.h -include/tdep/libunwind_i.h - -tests/[GL]test-bt -tests/[GL]test-concurrent -tests/[GL]test-dyn1 -tests/[GL]test-exc -tests/[GL]test-init -tests/[GL]test-resume-sig -tests/[GL]test-resume-sig-rt -tests/[GL]perf-simple -tests/Ltest-nomalloc -tests/Ltest-nocalloc -tests/Lperf-simple -tests/Lrs-race -tests/Ltest-varargs -tests/check-namespace.sh -tests/crasher -tests/forker -tests/mapper -tests/rs-race -tests/test-async-sig -tests/test-coredump-unwind -tests/test-flush-cache -tests/test-init-remote -tests/test-mem -tests/test-ptrace -tests/test-setjmp -tests/test-strerror -tests/test-proc-info -tests/test-ptrace-misc -tests/test-reg-state -tests/test-varargs -tests/test-static-link -tests/[GL]test-trace -tests/[GL]perf-trace -tests/Ltest-cxx-exceptions -tests/Ltest-init-local-signal -tests/Ltest-mem-validate -tests/[GL]ia64-test-nat -tests/[GL]ia64-test-rbs -tests/[GL]ia64-test-readonly -tests/[GL]ia64-test-stack -tests/ia64-test-dyn1 -tests/ia64-test-sig -tests/*.log -tests/*.trs diff --git a/src/pal/src/libunwind/.travis.yml b/src/pal/src/libunwind/.travis.yml deleted file mode 100644 index 4a74b4a1b..000000000 --- a/src/pal/src/libunwind/.travis.yml +++ /dev/null @@ -1,18 +0,0 @@ -sudo: required -language: c -compiler: gcc -env: -- TARGET=x86_64-linux-gnu -- TARGET=x86-linux-gnu -- TARGET=arm-linux-gnueabihf -- TARGET=aarch64-linux-gnu -- TARGET=mipsel-unknown-linux-gnu -# Currently experiencing build failures here -#- TARGET=powerpc64-linux-gnu -script: -- ./autogen.sh -- ./configure --target=$TARGET --host=$HOST -- make -j32 -- sudo bash -c 'echo core.%p.%p > /proc/sys/kernel/core_pattern' -- ulimit -c unlimited -- if [ $TARGET == 'x86_64-linux-gnu' ]; then make check -j32; fi diff --git a/src/pal/src/libunwind/AUTHORS b/src/pal/src/libunwind/AUTHORS deleted file mode 100644 index 719eee5c8..000000000 --- a/src/pal/src/libunwind/AUTHORS +++ /dev/null @@ -1 +0,0 @@ -David Mosberger diff --git a/src/pal/src/libunwind/CMakeLists.txt b/src/pal/src/libunwind/CMakeLists.txt deleted file mode 100644 index b33c0ae44..000000000 --- a/src/pal/src/libunwind/CMakeLists.txt +++ /dev/null @@ -1,22 +0,0 @@ -add_subdirectory(src) - -# define variables for the configure_file below - -if (CLR_CMAKE_PLATFORM_ARCH_AMD64) - set(arch x86_64) -elseif(CLR_CMAKE_PLATFORM_ARCH_ARM64) - set(arch aarch64) -elseif(CLR_CMAKE_PLATFROM_ARCH_ARM) - set(arch arm) -elseif(CLR_CMAKE_PLATFORM_ARCH_I386) - set(arch x86) -endif() - -set(PKG_MAJOR "1") -set(PKG_MINOR "3") -set(PKG_EXTRA "-rc1") - -configure_file(include/libunwind-common.h.in ${CMAKE_CURRENT_BINARY_DIR}/include/libunwind-common.h) -configure_file(include/libunwind.h.in ${CMAKE_CURRENT_BINARY_DIR}/include/libunwind.h) -configure_file(include/tdep/libunwind_i.h.in ${CMAKE_CURRENT_BINARY_DIR}/include/tdep/libunwind_i.h) - diff --git a/src/pal/src/libunwind/COPYING b/src/pal/src/libunwind/COPYING deleted file mode 100644 index 41e7d8a6f..000000000 --- a/src/pal/src/libunwind/COPYING +++ /dev/null @@ -1,20 +0,0 @@ -Copyright (c) 2002 Hewlett-Packard Co. - -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. diff --git a/src/pal/src/libunwind/ChangeLog b/src/pal/src/libunwind/ChangeLog deleted file mode 100644 index dfa24b957..000000000 --- a/src/pal/src/libunwind/ChangeLog +++ /dev/null @@ -1,55 +0,0 @@ -*********************************************************** - - Discontinued. See git log instead at - - http://www.kernel.org/git/gitweb.cgi?p=libs/libunwind/libunwind.git;a=log - -*********************************************************** - -2002-11-08 David Mosberger-Tang - - * src/ia64/unwind_i.h (ia64_getfp): Change from macro to inline - function. Check "loc" argument for being NULL before dereferencing it. - (ia64_putfp): Ditto. - (ia64_get): Ditto. - (ia64_put): Ditto. - -2002-01-18 David Mosberger-Tang - - * src/ia64/parser.c (__ia64_unw_create_state_record): Set - IA64_FLAG_HAS_HANDLER if the unwind info descriptors indicate that - there a handler. - - * src/ia64/regs.c (__ia64_access_reg): Return zero for UNW_REG_HANDLER - in frames that don't have a personality routine. - - * src/ia64/unwind_i.h (IA64_FLAG_HAS_HANDLER): New flag. - - * src/ia64/regs.c (__ia64_access_reg): When reading UNW_REG_HANDLER, - account for the fact that the personality address is gp-relative. - - * src/ia64/parser.c (__ia64_unw_create_state_record): Fix - initialization of segbase and len. - -2002-01-17 David Mosberger-Tang - - * include/unwind-ia64.h: Include via "unwind.h" to ensure - the file is picked up from same directory. - -2002-01-16 David Mosberger-Tang - - * include/unwind.h: Define UNW_ESTOPUNWIND. This error code may - be returned by acquire_unwind_info() to force termination of - unwinding. An application may want to do this when encountering a - call frame for dynamically generated code, for example. - - * unwind.h: Pass opaque argument pointer to acquire_unwind_info() - and release_unwind_info() like we do for access_mem() etc. - -2002-01-14 David Mosberger-Tang - - * Version 0.0 released. - -2002-01-11 David Mosberger-Tang - - * ChangeLog created. diff --git a/src/pal/src/libunwind/LICENSE b/src/pal/src/libunwind/LICENSE deleted file mode 100644 index c9b44cb8a..000000000 --- a/src/pal/src/libunwind/LICENSE +++ /dev/null @@ -1,18 +0,0 @@ -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. diff --git a/src/pal/src/libunwind/Makefile.am b/src/pal/src/libunwind/Makefile.am deleted file mode 100644 index 711d9100c..000000000 --- a/src/pal/src/libunwind/Makefile.am +++ /dev/null @@ -1,106 +0,0 @@ -include_HEADERS = include/libunwind-dynamic.h - -if BUILD_PTRACE -include_HEADERS += include/libunwind-ptrace.h -endif BUILD_PTRACE - -if BUILD_COREDUMP -include_HEADERS += include/libunwind-coredump.h -endif BUILD_COREDUMP - -if ARCH_AARCH64 -include_HEADERS += include/libunwind-aarch64.h -endif -if ARCH_ARM -include_HEADERS += include/libunwind-arm.h -endif -if ARCH_IA64 -include_HEADERS += include/libunwind-ia64.h -endif -if ARCH_HPPA -include_HEADERS += include/libunwind-hppa.h -endif -if ARCH_MIPS -include_HEADERS += include/libunwind-mips.h -endif -if ARCH_TILEGX -include_HEADERS += include/libunwind-tilegx.h -endif -if ARCH_X86 -include_HEADERS += include/libunwind-x86.h -endif -if ARCH_X86_64 -include_HEADERS += include/libunwind-x86_64.h -endif -if ARCH_PPC32 -include_HEADERS += include/libunwind-ppc32.h -endif -if ARCH_PPC64 -include_HEADERS += include/libunwind-ppc64.h -endif -if ARCH_SH -include_HEADERS += include/libunwind-sh.h -endif - -if !REMOTE_ONLY -include_HEADERS += include/libunwind.h include/unwind.h -endif - -nodist_include_HEADERS = include/libunwind-common.h - -SUBDIRS = src - -if CONFIG_TESTS -SUBDIRS += tests -endif - -if CONFIG_DOCS -SUBDIRS += doc -endif - -noinst_HEADERS = include/dwarf.h include/dwarf_i.h include/dwarf-eh.h \ - include/compiler.h include/libunwind_i.h include/mempool.h \ - include/remote.h \ - include/tdep-aarch64/dwarf-config.h \ - include/tdep-aarch64/jmpbuf.h \ - include/tdep-aarch64/libunwind_i.h \ - include/tdep-arm/dwarf-config.h include/tdep-arm/ex_tables.h \ - include/tdep-arm/jmpbuf.h include/tdep-arm/libunwind_i.h \ - include/tdep-ia64/jmpbuf.h include/tdep-ia64/rse.h \ - include/tdep-ia64/libunwind_i.h include/tdep-ia64/script.h \ - include/tdep-hppa/libunwind_i.h \ - include/tdep-hppa/jmpbuf.h include/tdep-hppa/dwarf-config.h \ - include/tdep-mips/libunwind_i.h \ - include/tdep-mips/jmpbuf.h include/tdep-mips/dwarf-config.h \ - include/tdep-tilegx/libunwind_i.h \ - include/tdep-tilegx/jmpbuf.h include/tdep-tilegx/dwarf-config.h \ - include/tdep-x86/libunwind_i.h \ - include/tdep-x86/jmpbuf.h include/tdep-x86/dwarf-config.h \ - include/tdep-x86_64/libunwind_i.h \ - include/tdep-x86_64/jmpbuf.h include/tdep-x86_64/dwarf-config.h \ - include/tdep-ppc32/dwarf-config.h \ - include/tdep-ppc32/jmpbuf.h include/tdep-ppc32/libunwind_i.h \ - include/tdep-ppc64/dwarf-config.h \ - include/tdep-ppc64/jmpbuf.h include/tdep-ppc64/libunwind_i.h \ - include/tdep-sh/dwarf-config.h \ - include/tdep-sh/jmpbuf.h include/tdep-sh/libunwind_i.h \ - include/tdep/libunwind_i.h \ - include/tdep/jmpbuf.h include/tdep/dwarf-config.h - -EXTRA_DIST = include/libunwind-common.h.in - -MAINTAINERCLEANFILES = \ - Makefile.in \ - INSTALL \ - aclocal.m4 \ - configure \ - config/compile \ - config/config.guess \ - config/config.sub \ - config/depcomp \ - config/install-sh \ - config/ltmain.sh \ - config/missing \ - include/config.h.in \ - include/config.h.in~ - diff --git a/src/pal/src/libunwind/NEWS b/src/pal/src/libunwind/NEWS deleted file mode 100644 index ae6cbcfb0..000000000 --- a/src/pal/src/libunwind/NEWS +++ /dev/null @@ -1,247 +0,0 @@ --*-Mode: outline-*- - -* News for v1.3: - -** Iteration of unwind register states support - Doug Moore -** Freebsd/Armv6 support - Konstantin Belousov -** Many, many dwarf bugfixes -** Mips remote unwind support -** aarch64 ptrace support - -* News for v1.2: - -** aarch64 port -** dwarf parsing improvements -** Fast stacktraces for aarch64 & arm -** tilegx port -** powerpc64 port - -* News for v1.1: - -** coredump unwind support -** New arch: SuperH -** Improved support for PowerPC, ARM -** Lots of cleanups, perf tweaks -** pkg-config support - -* News for v1.0: - -** Fast unwind (rbp, rsp, rip only) on x86_64 with a fallback to - slow code path (Lassi Tuura) -** Improved local and remote unwinding on ARM (Ken Werner) -** Testing, stability and many fixes on x86 (Paul Pluzhnikov) -** FreeBSD port and clean separation of OS specific bits - (Konstantin Belousov) -** Thanks for all the bug reports, contributions and testing! - -* News for v0.99: - -** Greatly improved x86-64 support thanks to Arun Sharma. -** Support for PPC64 added by Jose Flavio Aguilar Paulino. - -* News for v0.98.6: - -** Fix address-leak triggered by invalid byte-order. Fixed by Andreas Schwab. -** On ia64, get_static_proc_name() no longer uses a weak reference to - _Uelf64_get_proc_name(), since that was causing problems with archive - libraries and no longer served any apparent purpose. Fixed by - Curt Wohlgemuth. - -* News for v0.98.5: - -** Fix a typo in the man-page of unw_create_addr_space(). -** Fix an off-by-1 bug in the handling of the dynamic ALIAS directive - for ia64. Reported by Todd L. Miller. -** Fix a bug in libunwind-ptrace which could cause crash due to extraneous - munmap() calls. - -* News for v0.98.4: - -** Fix a typo in _ReadSLEB.c which caused hangs when throwing exceptions - from Intel ICC-compiled programs. Reported by Tommy Hoffner. - -* News for v0.98.3: - -** Make it possible to link against libunwind-ia64.a only (i.e., without - requiring libunwind.a as well). This keeps apps which need only - remote unwinding cleaner, since they logically have no dependency - on libunwind.a. -** Dont link against libatomic_ops for now. Due to a packaging bug on - Debian, linking against this library causes libunwind.so to get - a dependency on libatomic_ops.so, which is not at all what we want. - Fortunately, we don't have to link against that library on x86 or - ia64 since the library is strictly needed only for platforms with - poor atomic operation support. Once the libatomic_ops package is fixed, - we can re-enable linking against libatomic_ops. - -* News for v0.98.2: - -** Fixed bug which caused _UPT_get_dyn_info_list_addr() to sometimes fail - needlessly. Found by Todd L. Miller. - -** When using GCC to build libunwind on ia64, libunwind.so had an - unresolved reference to __divdi3. This is undesirable since it - creates an implicit dependency on libgcc. This problem has been - fixed in the 0.98.2 release by explicitly linking against libgcc.a - when building libunwind. - -* News for v0.98.1: - -** Fixed a bug which caused "make install" to install libunwind-common.h.in - instead of libunwind-common.h. -** Fixed a bug in the ia64 {sig,}longjmp() which showed on - SuSE Linux 9 because it's using a newer compiler & the EPC-based system - call stubs. -** Fixed incorrect offsets in tests/ia64-test-nat-asm.S. - Warning: you'll need a GNU assembler dated later than 21-Sep-2004 to - get this file translated correctly. With an old assembler, "make check" - will get lots of failures when running Gia64-test-nat or Lia64-test-nat! -** Convert tests/bt into a full-blown test-case. It's designed to - trigger a (rarely-encountered) bug in the GNU assembler on ia64. - The assembler has been fixed and once the libraries (libc etc) - have been rebuilt, this test will pass. -** Added test-case tests/run-ptrace-misc which, on ia64, triggers a bug in - current GCC (including v3.4.2) which causes bad unwind info. - -* News for v0.98: - -** Update libunwind to be compliant with the updated/expanded - ia64 unwind specificiation by HJ Lu [1]. This is needed for - GCC 3.4 compatibility. - - [1] http://www.kernel.org/pub/linux/devel/gcc/unwind/ - -** Initial support for x86-64 has been added courtesy of Max Asbock. - Along with this came a bunch of DWARF2 unwinder fixes. - -** A new rountine unw_strerror() has been added courtesy of - Thomas Hallgren. - -** Including now defines 4 macros that can be used - to determine the version number of libunwind. Specifically, - UNW_VERSION_MAJOR, UNW_VERSION_MINOR, UNW_VERSION, and - UNW_VERSION_CODE are defined by the header now. - -** Bug fixes -*** Fix a memory-leak in _UPT_get_dyn_info_list_addr() courtesy of Ed Connell. -*** Fix a crash in libunwind-ptrace courtesy of Mark Young. -*** Fix a bug in ia64-version of unw_init_remote() which prevented - it from working correctly for the local address space. Reported by - Troy Heber. -*** Many other small and not so small fixes. - -* News for v0.97: - -** unw_get_proc_name() may now be called from signal-handler. - -** The ptrace-helper routines are now declared in libunwind-ptrace.h. - Applications which use ptrace-based unwinding should include - to get the _UPT_*() routines declared. - -** libunwind has been split into a "local-only" and a "generic" versions. - The former is optimized for local unwinding (within a process) and - is called libunwind.so (shared version) or libunwind.a (archive - version). The generic version is not limited to unwinding within a - process and is called libunwind-generic.so (shared version) - libunwind-generic.a (archive version). Similarly, the ptrace() - support has been separated out into a convenience library called - libunwind-ptrace.a. For the most part, backwards-compatibility - is retained. However, when building an application which uses - libunwind, it may be necessary to change the linker command-line - as shown in the table below: - - Application which does: Before v0.97: With v0.97: - ----------------------- ------------- ----------- - local unwinding only: -lunwind -lunwind - remote unwinding: -lunwind -lunwind-generic - cross unwinding: -lunwind-PLAT -lunwind-PLAT - ptrace-based unwinding: -lunwind -lunwind-ptrace -lunwind-generic - - The motivation for this splitting is to keep libunwind.so as minimal - as possible. This library will eventually be loaded by most (if not - all) executables and hence it is important to ensure that it can - be loaded as quickly as possible. - -** unw_getcontext() tuned on IA-64. - - The unw_getcontext() routine used to be provided by (GNU) libc - (getcontext()). This caused unnecessary overhead (e.g., an - unnecessary system-call to sigprocmask()). The new - unw_getcontext() only does the work really needed for libunwind and - hence performs much better. However, this change implies that - programs linked against libunwind v0.97 won't be - backwards-compatible with earlier versions (there would be an - unresolved symbol for _Uia64_getcontext()). - -** Fix NaT-bit handling on IA-64. - - New test-cases have been added to test the handling of the NaT bit - (and floating-point NaT values) and all discovered/known bugs have - been fixed. - -** Initial DWARF-based unwinder for x86. - - There is a beginning for a DWARF-based unwinder for x86. Work for - x86-64-support based on this DWARF unwinder is currently underway - at IBM and it is expected that this support will be merged into the - official tree soon. - - -* News for v0.96: - -** _Unwind_*() routines defined by the C++ ABI are now included in - libunwind. - - -* News for v0.95: - -** Bigger, better, faster, or so the theory goes. - - -* News for v0.93: - -** More bug-fixes & improved HP-UX support. - - -* News for v0.92: - -** Bug-fix release. IA-64 unwinder can now be built with Intel compiler (ECC). - - -* News for v0.91: - -** Lots of documentation updates -** Some portability fixes. - - -* News for v0.9: - -** The libunwind API is mostly feature-complete at this point (hence the - version jump from v0.2 to v0.9). - - -* News for v0.2: - -** Automated configuration/build with autoconf and automake. -** Added support for building libunwind as a shared library. -** Added support for remote unwinding. -** Added support for cross-building. -** Added two new routines to the API: - - unw_is_fpreg() - - unw_get_save_loc() -** Added multi-architecture supports (lets a single application use - the unwind libraries for multiple target architectures; this is useful, - e.g., useful for building a debugger that can support multiple targets - such as x86, ia64, etc.) - - -* News for v0.1: - -** Added support for exception handling. - - -* News for v0.0: - -** It's a brand new package. diff --git a/src/pal/src/libunwind/README b/src/pal/src/libunwind/README deleted file mode 100644 index 694f600b0..000000000 --- a/src/pal/src/libunwind/README +++ /dev/null @@ -1,207 +0,0 @@ --*- mode: Outline -*- - -[![Build Status](https://travis-ci.org/libunwind/libunwind.svg?branch=master)](https://travis-ci.org/libunwind/libunwind) - -This is version 1.3 of the unwind library. This library supports -several architecture/operating-system combinations: - - Linux/x86-64: Works well. - Linux/x86: Works well. - Linux/ARM: Works well. - Linux/IA-64: Works well. - Linux/PARISC: Works well, but C library missing unwind-info. - HP-UX/IA-64: Mostly works but known to have some serious limitations. - MIPS: Newly added. - Linux/AArch64: Works well. - Linux/PPC64: Newly added. - Linux/SuperH: Newly added. - FreeBSD/i386: Works well. - FreeBSD/x86-64: Newly added (FreeBSD architecture is known as amd64). - Linux/Tilegx: Newly added (64-bit mode only). - -* General Build Instructions - -In general, this library can be built and installed with the following -commands: - - $ ./autogen.sh # Needed only for building from git. Depends on libtool. - $ ./configure - $ make - $ make install prefix=PREFIX - -where PREFIX is the installation prefix. By default, a prefix of -/usr/local is used, such that libunwind.a is installed in -/usr/local/lib and unwind.h is installed in /usr/local/include. For -testing, you may want to use a prefix of /usr/local instead. - - -* Building with Intel compiler - -** Version 8 and later - -Starting with version 8, the preferred name for the IA-64 Intel -compiler is "icc" (same name as on x86). Thus, the configure-line -should look like this: - - $ ./configure CC=icc CFLAGS="-g -O3 -ip" CXX=icc CCAS=gcc CCASFLAGS=-g \ - LDFLAGS="-L$PWD/src/.libs" - - -* Building on HP-UX - -For the time being, libunwind must be built with GCC on HP-UX. - -libunwind should be configured and installed on HP-UX like this: - - $ ./configure CFLAGS="-g -O2 -mlp64" CXXFLAGS="-g -O2 -mlp64" - -Caveat: Unwinding of 32-bit (ILP32) binaries is not supported - at the moment. - -** Workaround for older versions of GCC - -GCC v3.0 and GCC v3.2 ship with a bad version of sys/types.h. The -workaround is to issue the following commands before running -"configure": - - $ mkdir $top_dir/include/sys - $ cp /usr/include/sys/types.h $top_dir/include/sys - -GCC v3.3.2 or later have been fixed and do not require this -workaround. - -* Building for PowerPC64 / Linux - -For building for power64 you should use: - - $ ./configure CFLAGS="-g -O2 -m64" CXXFLAGS="-g -O2 -m64" - -If your power support altivec registers: - $ ./configure CFLAGS="-g -O2 -m64 -maltivec" CXXFLAGS="-g -O2 -m64 -maltivec" - -To check if your processor has support for vector registers (altivec): - cat /proc/cpuinfo | grep altivec -and should have something like this: - cpu : PPC970, altivec supported - -If libunwind seems to not work (backtracing failing), try to compile -it with -O0, without optimizations. There are some compiler problems -depending on the version of your gcc. - -* Building on FreeBSD - -General building instructions apply. To build and execute several tests, -you need libexecinfo library available in ports as devel/libexecinfo. - -Development of the port was done of FreeBSD 8.0-STABLE. The library -was build with the system compiler that is modified version of gcc 4.2.1, -as well as the gcc 4.4.3. - -* Regression Testing - -After building the library, you can run a set of regression tests with: - - $ make check - -** Expected results on IA-64 Linux - -Unless you have a very recent C library and compiler installed, it is -currently expected to have the following tests fail on IA-64 Linux: - - Gtest-init (should pass starting with glibc-2.3.x/gcc-3.4) - Ltest-init (should pass starting with glibc-2.3.x/gcc-3.4) - test-ptrace (should pass starting with glibc-2.3.x/gcc-3.4) - run-ia64-test-dyn1 (should pass starting with glibc-2.3.x) - -This does not mean that libunwind cannot be used with older compilers -or C libraries, it just means that for certain corner cases, unwinding -will fail. Since they're corner cases, it is not likely for -applications to trigger them. - -Note: If you get lots of errors in Gia64-test-nat and Lia64-test-nat, it's - almost certainly a sign of an old assembler. The GNU assembler used - to encode previous-stack-pointer-relative offsets incorrectly. - This bug was fixed on 21-Sep-2004 so any later assembler will be - fine. - -** Expected results on x86 Linux - -The following tests are expected to fail on x86 Linux: - - test-ptrace - -** Expected results on x86-64 Linux - -The following tests are expected to fail on x86-64 Linux: - - run-ptrace-misc (see http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18748 - and http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18749) - -** Expected results on PARISC Linux - -Caveat: GCC v3.4 or newer is needed on PA-RISC Linux. Earlier -versions of the compiler failed to generate the exception-handling -program header (GNU_EH_FRAME) needed for unwinding. - -The following tests are expected to fail on x86-64 Linux: - - Gtest-bt (backtrace truncated at kill() due to lack of unwind-info) - Ltest-bt (likewise) - Gtest-resume-sig (Gresume.c:my_rt_sigreturn() is wrong somehow) - Ltest-resume-sig (likewise) - Gtest-init (likewise) - Ltest-init (likewise) - Gtest-dyn1 (no dynamic unwind info support yet) - Ltest-dyn1 (no dynamic unwind info support yet) - test-setjmp (longjmp() not implemented yet) - run-check-namespace (toolchain doesn't support HIDDEN yet) - -** Expected results on HP-UX - -"make check" is currently unsupported for HP-UX. You can try to run -it, but most tests will fail (and some may fail to terminate). The -only test programs that are known to work at this time are: - - tests/bt - tests/Gperf-simple - tests/test-proc-info - tests/test-static-link - tests/Gtest-init - tests/Ltest-init - tests/Gtest-resume-sig - tests/Ltest-resume-sig - -** Expected results on PPC64 Linux - -"make check" should run with no more than 10 out of 24 tests failed. - - -* Performance Testing - -This distribution includes a few simple performance tests which give -some idea of the basic cost of various libunwind operations. After -building the library, you can run these tests with the following -commands: - - $ cd tests - $ make perf - -* Contacting the Developers - -Please direct all questions regarding this library to: - - libunwind-devel@nongnu.org - -You can do this by sending a mail to libunwind-request@nongnu.org with -a body of: - - subscribe libunwind-devel - -or you can subscribe and manage your subscription via the -web-interface at: - - https://savannah.nongnu.org/mail/?group=libunwind - -Or interact at the gihub page: - - https://github.com/libunwind/libunwind diff --git a/src/pal/src/libunwind/README.md b/src/pal/src/libunwind/README.md deleted file mode 100644 index 100b93820..000000000 --- a/src/pal/src/libunwind/README.md +++ /dev/null @@ -1 +0,0 @@ -README \ No newline at end of file diff --git a/src/pal/src/libunwind/TODO b/src/pal/src/libunwind/TODO deleted file mode 100644 index 8b2e0262b..000000000 --- a/src/pal/src/libunwind/TODO +++ /dev/null @@ -1,97 +0,0 @@ -- Update the libunwind man page for the new/fixed cache-flushing behavior. - Effectively, that unw_flush_cache() doesn't have to be called by - applications except for extraordinary circumstances (e.g., if application - implements its own runtime loader). -- document split local-only/generic libraries and separate libunwind-ptrace.a - convenience-library -- document new "tdep" member in unw_proc_info_t structure -- for DWARF 2, use a dummy CIE entry with an augmentation that - provides the dyn-info-list-address - -=== taken care of: - -Testing: - + ensure that saving r4-r7 in a stacked register properly preserves - the NaT bit, even in the face of register-rotation - + ensure that IA64_INSN_MOVE_STACKED works correctly in the face of - register rotation - + on Linux, test access to f32-f127 in a signal handler (e.g., verify - that fph partition gets initialized properly) -+ According to Nicholas S. Wourms , adding this to the - Makefile.am: - AUTOMAKE_OPTIONS = 1.6 subdir-objects - ensures that object-files are build in separate subdirectories and that - in turn makes it possible for source files in different directories to - have the same filename, thus avoiding the need for those ugly -x86, -ia64, - etc., postfixes. -+ Switch ia64 (and rest over) to using Debug() instead of debug() -+ implement non-local versions of dwarf_readXX() -+ consolidate mostly architecture-independent code such as - unw_get_accessors() into shared files -+ caching is pretty fundamentally broken, what should happen is this: - o On unw_init_local()/unw_init_remote(), libunwind should validate - that the cached information is still valid and, if not, flush the - cache on its own. Rationale: once unw_init_local() has been - called, it is clear that the unwind info for the calling thread - cannot change (otherwise the program would be buggy anyhow) and - hence it is sufficient to validate the cache at this point. - Similarly, once unw_init_remote() has been called, the target - address space must have been stopped, because the unwinding would - otherwise be unreliable anyhow. - o glibc currently lacks a feature for dl_iterate_phdr() to support - safe caching; I proposed on 12/16/2003 that glibc maintain two - atomic counters which get inremented whenever something is added - to/removed from the dl_iterate_phdr-list. Once we have such counters, - we can use them in libunwind to implement an efficient version of a - cache-validation routine. - Once this has been fixed, update the libunwind man page accordingly. - Effectively, what this means is that unw_flush_cache() doesn't have - to be called by applications except for extraordinary circumstances - (e.g., if application implements its own runtime loader). -+ man-page for unw_is_fpreg() -+ man-page for _U_dyn_cancel() -+ man-page for _U_dyn_register() -+ global data is not protected by a lock; causes problems if two threads - call ia64_init() at almost the same time -+ cache the value of *cfm_loc; each rotate_FOO() call needs it! -+ implement the remote-lookup of the dynamic registration list -+ when doing sigreturn, must restore fp regs (and perhaps other regs) the same - way as the (user-level) gate.S sigreturn path does! -+ unw_resume() must at least restore gp (r1)! consider restoring all - scratch regs (but what's the performance impact on exception handling?); - alternative: restore scratch regs that may be used during procedure - call/return (e.g., r8-r11, f8-f11) -+ implement unw_resume() for the case where the current register frame is split - across multiple backing stores -+ document restricions on using unw_resume(): -+ implement remote cases of unw_resume() -+ test both with UNW_LOCAL_ONLY and without where this makes sense -+ allow region-length (insn_count) in unw_dyn_region_info_t to be negative - to indicate counting from the end of the procedure (to make it possible - for differently-sized procedures to share the same region list if they - share the same prologue/epilogue). -+ it appears that it is currently not possible to read register UNW_IA64_TP; - fix that => no, attempts to access r13 will result in access_reg() callbacks, - as desired; for local-case, access to r13 will fail though (since - getcontext() doesn't, and shouldn't, capture r13) -+ document the special nature of UNW_IA64_GP: read-only, but adjusted - automatically if the IP is changed -+ use pthread-mutexes where necessary, atomic ops where possible -+ man-page for unw_init_local() -+ man-page for unw_init_remote() -+ man-page for unw_create_addr_space() -+ man-page for unw_destroy_addr_space() -+ man-page for unw_get_proc_info() -+ man-page for unw_get_proc_name() -+ man-page for unw_get_accessors() -+ man-page for unw_regname() -+ man-page for unw_flush_cache() -+ man-page for unw_set_caching_policy() -+ man-page for unw_getcontext() -+ man-page for unw_is_signal_frame() -+ man-page for unw_step() -+ man-page for unw_get_reg() -+ man-page for unw_set_reg() -+ man-page for unw_get_fpreg() -+ man-page for unw_set_fpreg() -+ test with Intel compiler diff --git a/src/pal/src/libunwind/acinclude.m4 b/src/pal/src/libunwind/acinclude.m4 deleted file mode 100644 index 497f7c2f2..000000000 --- a/src/pal/src/libunwind/acinclude.m4 +++ /dev/null @@ -1,32 +0,0 @@ -AC_DEFUN([LIBUNWIND___THREAD], -[dnl Check whether the compiler supports the __thread keyword. -if test "x$enable___thread" != xno; then - AC_CACHE_CHECK([for __thread], libc_cv_gcc___thread, - [cat > conftest.c <<\EOF - __thread int a = 42; -EOF - if AC_TRY_COMMAND([${CC-cc} $CFLAGS -c conftest.c >&AS_MESSAGE_LOG_FD]); then - libc_cv_gcc___thread=yes - else - libc_cv_gcc___thread=no - fi - rm -f conftest*]) - if test "$libc_cv_gcc___thread" = yes; then - AC_DEFINE(HAVE___THREAD, 1, - [Define to 1 if __thread keyword is supported by the C compiler.]) - fi -else - libc_cv_gcc___thread=no -fi]) - -AC_DEFUN([CHECK_ATOMIC_OPS], -[dnl Check whether the system has the atomic_ops package installed. - AC_CHECK_HEADERS(atomic_ops.h) -# -# Don't link against libatomic_ops for now. We don't want libunwind -# to depend on libatomic_ops.so. Fortunately, none of the platforms -# we care about so far need libatomic_ops.a (everything is done via -# inline macros). -# -# AC_CHECK_LIB(atomic_ops, main) -]) diff --git a/src/pal/src/libunwind/autogen.sh b/src/pal/src/libunwind/autogen.sh deleted file mode 100644 index b08bc831f..000000000 --- a/src/pal/src/libunwind/autogen.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh - -test -n "$srcdir" || srcdir=`dirname "$0"` -test -n "$srcdir" || srcdir=. -( - cd "$srcdir" && - autoreconf --force -v --install -) || exit -test -n "$NOCONFIGURE" || "$srcdir/configure" "$@" diff --git a/src/pal/src/libunwind/aux_/config.guess b/src/pal/src/libunwind/aux_/config.guess deleted file mode 100644 index ed2e03b7f..000000000 --- a/src/pal/src/libunwind/aux_/config.guess +++ /dev/null @@ -1,1321 +0,0 @@ -#! /bin/sh -# Attempt to guess a canonical system name. -# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, -# 2000, 2001, 2002 Free Software Foundation, Inc. - -timestamp='2002-03-20' - -# This file is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -# Originally written by Per Bothner . -# Please send patches to . Submit a context -# diff and a properly formatted ChangeLog entry. -# -# This script attempts to guess a canonical system name similar to -# config.sub. If it succeeds, it prints the system name on stdout, and -# exits with 0. Otherwise, it exits with 1. -# -# The plan is that this can be called by configure scripts if you -# don't specify an explicit build system type. - -me=`echo "$0" | sed -e 's,.*/,,'` - -usage="\ -Usage: $0 [OPTION] - -Output the configuration name of the system \`$me' is run on. - -Operation modes: - -h, --help print this help, then exit - -t, --time-stamp print date of last modification, then exit - -v, --version print version number, then exit - -Report bugs and patches to ." - -version="\ -GNU config.guess ($timestamp) - -Originally written by Per Bothner. -Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 -Free Software Foundation, Inc. - -This is free software; see the source for copying conditions. There is NO -warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." - -help=" -Try \`$me --help' for more information." - -# Parse command line -while test $# -gt 0 ; do - case $1 in - --time-stamp | --time* | -t ) - echo "$timestamp" ; exit 0 ;; - --version | -v ) - echo "$version" ; exit 0 ;; - --help | --h* | -h ) - echo "$usage"; exit 0 ;; - -- ) # Stop option processing - shift; break ;; - - ) # Use stdin as input. - break ;; - -* ) - echo "$me: invalid option $1$help" >&2 - exit 1 ;; - * ) - break ;; - esac -done - -if test $# != 0; then - echo "$me: too many arguments$help" >&2 - exit 1 -fi - - -dummy=dummy-$$ -trap 'rm -f $dummy.c $dummy.o $dummy.rel $dummy; exit 1' 1 2 15 - -# CC_FOR_BUILD -- compiler used by this script. -# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still -# use `HOST_CC' if defined, but it is deprecated. - -set_cc_for_build='case $CC_FOR_BUILD,$HOST_CC,$CC in - ,,) echo "int dummy(){}" > $dummy.c ; - for c in cc gcc c89 c99 ; do - ($c $dummy.c -c -o $dummy.o) >/dev/null 2>&1 ; - if test $? = 0 ; then - CC_FOR_BUILD="$c"; break ; - fi ; - done ; - rm -f $dummy.c $dummy.o $dummy.rel ; - if test x"$CC_FOR_BUILD" = x ; then - CC_FOR_BUILD=no_compiler_found ; - fi - ;; - ,,*) CC_FOR_BUILD=$CC ;; - ,*,*) CC_FOR_BUILD=$HOST_CC ;; -esac' - -# This is needed to find uname on a Pyramid OSx when run in the BSD universe. -# (ghazi@noc.rutgers.edu 1994-08-24) -if (test -f /.attbin/uname) >/dev/null 2>&1 ; then - PATH=$PATH:/.attbin ; export PATH -fi - -UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown -UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown -UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown -UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown - -# Note: order is significant - the case branches are not exclusive. - -case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in - *:NetBSD:*:*) - # NetBSD (nbsd) targets should (where applicable) match one or - # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, - # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently - # switched to ELF, *-*-netbsd* would select the old - # object file format. This provides both forward - # compatibility and a consistent mechanism for selecting the - # object file format. - # - # Note: NetBSD doesn't particularly care about the vendor - # portion of the name. We always set it to "unknown". - sysctl="sysctl -n hw.machine_arch" - UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ - /usr/sbin/$sysctl 2>/dev/null || echo unknown)` - case "${UNAME_MACHINE_ARCH}" in - arm*) machine=arm-unknown ;; - sh3el) machine=shl-unknown ;; - sh3eb) machine=sh-unknown ;; - *) machine=${UNAME_MACHINE_ARCH}-unknown ;; - esac - # The Operating System including object format, if it has switched - # to ELF recently, or will in the future. - case "${UNAME_MACHINE_ARCH}" in - arm*|i386|m68k|ns32k|sh3*|sparc|vax) - eval $set_cc_for_build - if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ - | grep __ELF__ >/dev/null - then - # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). - # Return netbsd for either. FIX? - os=netbsd - else - os=netbsdelf - fi - ;; - *) - os=netbsd - ;; - esac - # The OS release - release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` - # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: - # contains redundant information, the shorter form: - # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. - echo "${machine}-${os}${release}" - exit 0 ;; - amiga:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - arc:OpenBSD:*:*) - echo mipsel-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - hp300:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - mac68k:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - macppc:OpenBSD:*:*) - echo powerpc-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - mvme68k:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - mvme88k:OpenBSD:*:*) - echo m88k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - mvmeppc:OpenBSD:*:*) - echo powerpc-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - pmax:OpenBSD:*:*) - echo mipsel-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - sgi:OpenBSD:*:*) - echo mipseb-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - sun3:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - wgrisc:OpenBSD:*:*) - echo mipsel-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - *:OpenBSD:*:*) - echo ${UNAME_MACHINE}-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - alpha:OSF1:*:*) - if test $UNAME_RELEASE = "V4.0"; then - UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` - fi - # A Vn.n version is a released version. - # A Tn.n version is a released field test version. - # A Xn.n version is an unreleased experimental baselevel. - # 1.2 uses "1.2" for uname -r. - cat <$dummy.s - .data -\$Lformat: - .byte 37,100,45,37,120,10,0 # "%d-%x\n" - - .text - .globl main - .align 4 - .ent main -main: - .frame \$30,16,\$26,0 - ldgp \$29,0(\$27) - .prologue 1 - .long 0x47e03d80 # implver \$0 - lda \$2,-1 - .long 0x47e20c21 # amask \$2,\$1 - lda \$16,\$Lformat - mov \$0,\$17 - not \$1,\$18 - jsr \$26,printf - ldgp \$29,0(\$26) - mov 0,\$16 - jsr \$26,exit - .end main -EOF - eval $set_cc_for_build - $CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null - if test "$?" = 0 ; then - case `./$dummy` in - 0-0) - UNAME_MACHINE="alpha" - ;; - 1-0) - UNAME_MACHINE="alphaev5" - ;; - 1-1) - UNAME_MACHINE="alphaev56" - ;; - 1-101) - UNAME_MACHINE="alphapca56" - ;; - 2-303) - UNAME_MACHINE="alphaev6" - ;; - 2-307) - UNAME_MACHINE="alphaev67" - ;; - 2-1307) - UNAME_MACHINE="alphaev68" - ;; - esac - fi - rm -f $dummy.s $dummy - echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` - exit 0 ;; - Alpha\ *:Windows_NT*:*) - # How do we know it's Interix rather than the generic POSIX subsystem? - # Should we change UNAME_MACHINE based on the output of uname instead - # of the specific Alpha model? - echo alpha-pc-interix - exit 0 ;; - 21064:Windows_NT:50:3) - echo alpha-dec-winnt3.5 - exit 0 ;; - Amiga*:UNIX_System_V:4.0:*) - echo m68k-unknown-sysv4 - exit 0;; - *:[Aa]miga[Oo][Ss]:*:*) - echo ${UNAME_MACHINE}-unknown-amigaos - exit 0 ;; - *:[Mm]orph[Oo][Ss]:*:*) - echo ${UNAME_MACHINE}-unknown-morphos - exit 0 ;; - *:OS/390:*:*) - echo i370-ibm-openedition - exit 0 ;; - arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) - echo arm-acorn-riscix${UNAME_RELEASE} - exit 0;; - SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) - echo hppa1.1-hitachi-hiuxmpp - exit 0;; - Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) - # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. - if test "`(/bin/universe) 2>/dev/null`" = att ; then - echo pyramid-pyramid-sysv3 - else - echo pyramid-pyramid-bsd - fi - exit 0 ;; - NILE*:*:*:dcosx) - echo pyramid-pyramid-svr4 - exit 0 ;; - sun4H:SunOS:5.*:*) - echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit 0 ;; - sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) - echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit 0 ;; - i86pc:SunOS:5.*:*) - echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit 0 ;; - sun4*:SunOS:6*:*) - # According to config.sub, this is the proper way to canonicalize - # SunOS6. Hard to guess exactly what SunOS6 will be like, but - # it's likely to be more like Solaris than SunOS4. - echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit 0 ;; - sun4*:SunOS:*:*) - case "`/usr/bin/arch -k`" in - Series*|S4*) - UNAME_RELEASE=`uname -v` - ;; - esac - # Japanese Language versions have a version number like `4.1.3-JL'. - echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` - exit 0 ;; - sun3*:SunOS:*:*) - echo m68k-sun-sunos${UNAME_RELEASE} - exit 0 ;; - sun*:*:4.2BSD:*) - UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` - test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 - case "`/bin/arch`" in - sun3) - echo m68k-sun-sunos${UNAME_RELEASE} - ;; - sun4) - echo sparc-sun-sunos${UNAME_RELEASE} - ;; - esac - exit 0 ;; - aushp:SunOS:*:*) - echo sparc-auspex-sunos${UNAME_RELEASE} - exit 0 ;; - # The situation for MiNT is a little confusing. The machine name - # can be virtually everything (everything which is not - # "atarist" or "atariste" at least should have a processor - # > m68000). The system name ranges from "MiNT" over "FreeMiNT" - # to the lowercase version "mint" (or "freemint"). Finally - # the system name "TOS" denotes a system which is actually not - # MiNT. But MiNT is downward compatible to TOS, so this should - # be no problem. - atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit 0 ;; - atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit 0 ;; - *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit 0 ;; - milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) - echo m68k-milan-mint${UNAME_RELEASE} - exit 0 ;; - hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) - echo m68k-hades-mint${UNAME_RELEASE} - exit 0 ;; - *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) - echo m68k-unknown-mint${UNAME_RELEASE} - exit 0 ;; - powerpc:machten:*:*) - echo powerpc-apple-machten${UNAME_RELEASE} - exit 0 ;; - RISC*:Mach:*:*) - echo mips-dec-mach_bsd4.3 - exit 0 ;; - RISC*:ULTRIX:*:*) - echo mips-dec-ultrix${UNAME_RELEASE} - exit 0 ;; - VAX*:ULTRIX*:*:*) - echo vax-dec-ultrix${UNAME_RELEASE} - exit 0 ;; - 2020:CLIX:*:* | 2430:CLIX:*:*) - echo clipper-intergraph-clix${UNAME_RELEASE} - exit 0 ;; - mips:*:*:UMIPS | mips:*:*:RISCos) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c -#ifdef __cplusplus -#include /* for printf() prototype */ - int main (int argc, char *argv[]) { -#else - int main (argc, argv) int argc; char *argv[]; { -#endif - #if defined (host_mips) && defined (MIPSEB) - #if defined (SYSTYPE_SYSV) - printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); - #endif - #if defined (SYSTYPE_SVR4) - printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); - #endif - #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) - printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); - #endif - #endif - exit (-1); - } -EOF - $CC_FOR_BUILD $dummy.c -o $dummy \ - && ./$dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \ - && rm -f $dummy.c $dummy && exit 0 - rm -f $dummy.c $dummy - echo mips-mips-riscos${UNAME_RELEASE} - exit 0 ;; - Motorola:PowerMAX_OS:*:*) - echo powerpc-motorola-powermax - exit 0 ;; - Night_Hawk:Power_UNIX:*:*) - echo powerpc-harris-powerunix - exit 0 ;; - m88k:CX/UX:7*:*) - echo m88k-harris-cxux7 - exit 0 ;; - m88k:*:4*:R4*) - echo m88k-motorola-sysv4 - exit 0 ;; - m88k:*:3*:R3*) - echo m88k-motorola-sysv3 - exit 0 ;; - AViiON:dgux:*:*) - # DG/UX returns AViiON for all architectures - UNAME_PROCESSOR=`/usr/bin/uname -p` - if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] - then - if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ - [ ${TARGET_BINARY_INTERFACE}x = x ] - then - echo m88k-dg-dgux${UNAME_RELEASE} - else - echo m88k-dg-dguxbcs${UNAME_RELEASE} - fi - else - echo i586-dg-dgux${UNAME_RELEASE} - fi - exit 0 ;; - M88*:DolphinOS:*:*) # DolphinOS (SVR3) - echo m88k-dolphin-sysv3 - exit 0 ;; - M88*:*:R3*:*) - # Delta 88k system running SVR3 - echo m88k-motorola-sysv3 - exit 0 ;; - XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) - echo m88k-tektronix-sysv3 - exit 0 ;; - Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) - echo m68k-tektronix-bsd - exit 0 ;; - *:IRIX*:*:*) - echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` - exit 0 ;; - ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. - echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id - exit 0 ;; # Note that: echo "'`uname -s`'" gives 'AIX ' - i*86:AIX:*:*) - echo i386-ibm-aix - exit 0 ;; - ia64:AIX:*:*) - if [ -x /usr/bin/oslevel ] ; then - IBM_REV=`/usr/bin/oslevel` - else - IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} - fi - echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} - exit 0 ;; - *:AIX:2:3) - if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #include - - main() - { - if (!__power_pc()) - exit(1); - puts("powerpc-ibm-aix3.2.5"); - exit(0); - } -EOF - $CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm -f $dummy.c $dummy && exit 0 - rm -f $dummy.c $dummy - echo rs6000-ibm-aix3.2.5 - elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then - echo rs6000-ibm-aix3.2.4 - else - echo rs6000-ibm-aix3.2 - fi - exit 0 ;; - *:AIX:*:[45]) - IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` - if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then - IBM_ARCH=rs6000 - else - IBM_ARCH=powerpc - fi - if [ -x /usr/bin/oslevel ] ; then - IBM_REV=`/usr/bin/oslevel` - else - IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} - fi - echo ${IBM_ARCH}-ibm-aix${IBM_REV} - exit 0 ;; - *:AIX:*:*) - echo rs6000-ibm-aix - exit 0 ;; - ibmrt:4.4BSD:*|romp-ibm:BSD:*) - echo romp-ibm-bsd4.4 - exit 0 ;; - ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and - echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to - exit 0 ;; # report: romp-ibm BSD 4.3 - *:BOSX:*:*) - echo rs6000-bull-bosx - exit 0 ;; - DPX/2?00:B.O.S.:*:*) - echo m68k-bull-sysv3 - exit 0 ;; - 9000/[34]??:4.3bsd:1.*:*) - echo m68k-hp-bsd - exit 0 ;; - hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) - echo m68k-hp-bsd4.4 - exit 0 ;; - 9000/[34678]??:HP-UX:*:*) - HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` - case "${UNAME_MACHINE}" in - 9000/31? ) HP_ARCH=m68000 ;; - 9000/[34]?? ) HP_ARCH=m68k ;; - 9000/[678][0-9][0-9]) - if [ -x /usr/bin/getconf ]; then - sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` - sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` - case "${sc_cpu_version}" in - 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 - 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 - 532) # CPU_PA_RISC2_0 - case "${sc_kernel_bits}" in - 32) HP_ARCH="hppa2.0n" ;; - 64) HP_ARCH="hppa2.0w" ;; - '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 - esac ;; - esac - fi - if [ "${HP_ARCH}" = "" ]; then - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - - #define _HPUX_SOURCE - #include - #include - - int main () - { - #if defined(_SC_KERNEL_BITS) - long bits = sysconf(_SC_KERNEL_BITS); - #endif - long cpu = sysconf (_SC_CPU_VERSION); - - switch (cpu) - { - case CPU_PA_RISC1_0: puts ("hppa1.0"); break; - case CPU_PA_RISC1_1: puts ("hppa1.1"); break; - case CPU_PA_RISC2_0: - #if defined(_SC_KERNEL_BITS) - switch (bits) - { - case 64: puts ("hppa2.0w"); break; - case 32: puts ("hppa2.0n"); break; - default: puts ("hppa2.0"); break; - } break; - #else /* !defined(_SC_KERNEL_BITS) */ - puts ("hppa2.0"); break; - #endif - default: puts ("hppa1.0"); break; - } - exit (0); - } -EOF - (CCOPTS= $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null) && HP_ARCH=`./$dummy` - if test -z "$HP_ARCH"; then HP_ARCH=hppa; fi - rm -f $dummy.c $dummy - fi ;; - esac - echo ${HP_ARCH}-hp-hpux${HPUX_REV} - exit 0 ;; - ia64:HP-UX:*:*) - HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` - echo ia64-hp-hpux${HPUX_REV} - exit 0 ;; - 3050*:HI-UX:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #include - int - main () - { - long cpu = sysconf (_SC_CPU_VERSION); - /* The order matters, because CPU_IS_HP_MC68K erroneously returns - true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct - results, however. */ - if (CPU_IS_PA_RISC (cpu)) - { - switch (cpu) - { - case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; - case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; - case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; - default: puts ("hppa-hitachi-hiuxwe2"); break; - } - } - else if (CPU_IS_HP_MC68K (cpu)) - puts ("m68k-hitachi-hiuxwe2"); - else puts ("unknown-hitachi-hiuxwe2"); - exit (0); - } -EOF - $CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm -f $dummy.c $dummy && exit 0 - rm -f $dummy.c $dummy - echo unknown-hitachi-hiuxwe2 - exit 0 ;; - 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) - echo hppa1.1-hp-bsd - exit 0 ;; - 9000/8??:4.3bsd:*:*) - echo hppa1.0-hp-bsd - exit 0 ;; - *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) - echo hppa1.0-hp-mpeix - exit 0 ;; - hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) - echo hppa1.1-hp-osf - exit 0 ;; - hp8??:OSF1:*:*) - echo hppa1.0-hp-osf - exit 0 ;; - i*86:OSF1:*:*) - if [ -x /usr/sbin/sysversion ] ; then - echo ${UNAME_MACHINE}-unknown-osf1mk - else - echo ${UNAME_MACHINE}-unknown-osf1 - fi - exit 0 ;; - parisc*:Lites*:*:*) - echo hppa1.1-hp-lites - exit 0 ;; - C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) - echo c1-convex-bsd - exit 0 ;; - C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) - if getsysinfo -f scalar_acc - then echo c32-convex-bsd - else echo c2-convex-bsd - fi - exit 0 ;; - C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) - echo c34-convex-bsd - exit 0 ;; - C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) - echo c38-convex-bsd - exit 0 ;; - C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) - echo c4-convex-bsd - exit 0 ;; - CRAY*Y-MP:*:*:*) - echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit 0 ;; - CRAY*[A-Z]90:*:*:*) - echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ - | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ - -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ - -e 's/\.[^.]*$/.X/' - exit 0 ;; - CRAY*TS:*:*:*) - echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit 0 ;; - CRAY*T3D:*:*:*) - echo alpha-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit 0 ;; - CRAY*T3E:*:*:*) - echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit 0 ;; - CRAY*SV1:*:*:*) - echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit 0 ;; - F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) - FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` - FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` - echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" - exit 0 ;; - i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) - echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} - exit 0 ;; - sparc*:BSD/OS:*:*) - echo sparc-unknown-bsdi${UNAME_RELEASE} - exit 0 ;; - *:BSD/OS:*:*) - echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} - exit 0 ;; - *:FreeBSD:*:*) - echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` - exit 0 ;; - i*:CYGWIN*:*) - echo ${UNAME_MACHINE}-pc-cygwin - exit 0 ;; - i*:MINGW*:*) - echo ${UNAME_MACHINE}-pc-mingw32 - exit 0 ;; - i*:PW*:*) - echo ${UNAME_MACHINE}-pc-pw32 - exit 0 ;; - x86:Interix*:3*) - echo i386-pc-interix3 - exit 0 ;; - i*:Windows_NT*:* | Pentium*:Windows_NT*:*) - # How do we know it's Interix rather than the generic POSIX subsystem? - # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we - # UNAME_MACHINE based on the output of uname instead of i386? - echo i386-pc-interix - exit 0 ;; - i*:UWIN*:*) - echo ${UNAME_MACHINE}-pc-uwin - exit 0 ;; - p*:CYGWIN*:*) - echo powerpcle-unknown-cygwin - exit 0 ;; - prep*:SunOS:5.*:*) - echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit 0 ;; - *:GNU:*:*) - echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` - exit 0 ;; - i*86:Minix:*:*) - echo ${UNAME_MACHINE}-pc-minix - exit 0 ;; - arm*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit 0 ;; - ia64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit 0 ;; - m68*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit 0 ;; - mips:Linux:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #undef CPU - #undef mips - #undef mipsel - #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) - CPU=mipsel - #else - #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) - CPU=mips - #else - CPU= - #endif - #endif -EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=` - rm -f $dummy.c - test x"${CPU}" != x && echo "${CPU}-pc-linux-gnu" && exit 0 - ;; - ppc:Linux:*:*) - echo powerpc-unknown-linux-gnu - exit 0 ;; - ppc64:Linux:*:*) - echo powerpc64-unknown-linux-gnu - exit 0 ;; - alpha:Linux:*:*) - case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in - EV5) UNAME_MACHINE=alphaev5 ;; - EV56) UNAME_MACHINE=alphaev56 ;; - PCA56) UNAME_MACHINE=alphapca56 ;; - PCA57) UNAME_MACHINE=alphapca56 ;; - EV6) UNAME_MACHINE=alphaev6 ;; - EV67) UNAME_MACHINE=alphaev67 ;; - EV68*) UNAME_MACHINE=alphaev68 ;; - esac - objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null - if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi - echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} - exit 0 ;; - parisc:Linux:*:* | hppa:Linux:*:*) - # Look for CPU level - case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in - PA7*) echo hppa1.1-unknown-linux-gnu ;; - PA8*) echo hppa2.0-unknown-linux-gnu ;; - *) echo hppa-unknown-linux-gnu ;; - esac - exit 0 ;; - parisc64:Linux:*:* | hppa64:Linux:*:*) - echo hppa64-unknown-linux-gnu - exit 0 ;; - s390:Linux:*:* | s390x:Linux:*:*) - echo ${UNAME_MACHINE}-ibm-linux - exit 0 ;; - sh*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit 0 ;; - sparc:Linux:*:* | sparc64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit 0 ;; - x86_64:Linux:*:*) - echo x86_64-unknown-linux-gnu - exit 0 ;; - i*86:Linux:*:*) - # The BFD linker knows what the default object file format is, so - # first see if it will tell us. cd to the root directory to prevent - # problems with other programs or directories called `ld' in the path. - # Set LC_ALL=C to ensure ld outputs messages in English. - ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \ - | sed -ne '/supported targets:/!d - s/[ ][ ]*/ /g - s/.*supported targets: *// - s/ .*// - p'` - case "$ld_supported_targets" in - elf32-i386) - TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu" - ;; - a.out-i386-linux) - echo "${UNAME_MACHINE}-pc-linux-gnuaout" - exit 0 ;; - coff-i386) - echo "${UNAME_MACHINE}-pc-linux-gnucoff" - exit 0 ;; - "") - # Either a pre-BFD a.out linker (linux-gnuoldld) or - # one that does not give us useful --help. - echo "${UNAME_MACHINE}-pc-linux-gnuoldld" - exit 0 ;; - esac - # Determine whether the default compiler is a.out or elf - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #include - #ifdef __ELF__ - # ifdef __GLIBC__ - # if __GLIBC__ >= 2 - LIBC=gnu - # else - LIBC=gnulibc1 - # endif - # else - LIBC=gnulibc1 - # endif - #else - #ifdef __INTEL_COMPILER - LIBC=gnu - #else - LIBC=gnuaout - #endif - #endif -EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=` - rm -f $dummy.c - test x"${LIBC}" != x && echo "${UNAME_MACHINE}-pc-linux-${LIBC}" && exit 0 - test x"${TENTATIVE}" != x && echo "${TENTATIVE}" && exit 0 - ;; - i*86:DYNIX/ptx:4*:*) - # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. - # earlier versions are messed up and put the nodename in both - # sysname and nodename. - echo i386-sequent-sysv4 - exit 0 ;; - i*86:UNIX_SV:4.2MP:2.*) - # Unixware is an offshoot of SVR4, but it has its own version - # number series starting with 2... - # I am not positive that other SVR4 systems won't match this, - # I just have to hope. -- rms. - # Use sysv4.2uw... so that sysv4* matches it. - echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} - exit 0 ;; - i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) - UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` - if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then - echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} - else - echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} - fi - exit 0 ;; - i*86:*:5:[78]*) - case `/bin/uname -X | grep "^Machine"` in - *486*) UNAME_MACHINE=i486 ;; - *Pentium) UNAME_MACHINE=i586 ;; - *Pent*|*Celeron) UNAME_MACHINE=i686 ;; - esac - echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} - exit 0 ;; - i*86:*:3.2:*) - if test -f /usr/options/cb.name; then - UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then - UNAME_REL=`(/bin/uname -X|egrep Release|sed -e 's/.*= //')` - (/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486 - (/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) \ - && UNAME_MACHINE=i586 - (/bin/uname -X|egrep '^Machine.*Pent ?II' >/dev/null) \ - && UNAME_MACHINE=i686 - (/bin/uname -X|egrep '^Machine.*Pentium Pro' >/dev/null) \ - && UNAME_MACHINE=i686 - echo ${UNAME_MACHINE}-pc-sco$UNAME_REL - else - echo ${UNAME_MACHINE}-pc-sysv32 - fi - exit 0 ;; - i*86:*DOS:*:*) - echo ${UNAME_MACHINE}-pc-msdosdjgpp - exit 0 ;; - pc:*:*:*) - # Left here for compatibility: - # uname -m prints for DJGPP always 'pc', but it prints nothing about - # the processor, so we play safe by assuming i386. - echo i386-pc-msdosdjgpp - exit 0 ;; - Intel:Mach:3*:*) - echo i386-pc-mach3 - exit 0 ;; - paragon:*:*:*) - echo i860-intel-osf1 - exit 0 ;; - i860:*:4.*:*) # i860-SVR4 - if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then - echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 - else # Add other i860-SVR4 vendors below as they are discovered. - echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 - fi - exit 0 ;; - mini*:CTIX:SYS*5:*) - # "miniframe" - echo m68010-convergent-sysv - exit 0 ;; - M68*:*:R3V[567]*:*) - test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;; - 3[34]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0) - OS_REL='' - test -r /etc/.relid \ - && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` - /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && echo i486-ncr-sysv4.3${OS_REL} && exit 0 - /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ - && echo i586-ncr-sysv4.3${OS_REL} && exit 0 ;; - 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) - /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && echo i486-ncr-sysv4 && exit 0 ;; - m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) - echo m68k-unknown-lynxos${UNAME_RELEASE} - exit 0 ;; - mc68030:UNIX_System_V:4.*:*) - echo m68k-atari-sysv4 - exit 0 ;; - i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*) - echo i386-unknown-lynxos${UNAME_RELEASE} - exit 0 ;; - TSUNAMI:LynxOS:2.*:*) - echo sparc-unknown-lynxos${UNAME_RELEASE} - exit 0 ;; - rs6000:LynxOS:2.*:*) - echo rs6000-unknown-lynxos${UNAME_RELEASE} - exit 0 ;; - PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*) - echo powerpc-unknown-lynxos${UNAME_RELEASE} - exit 0 ;; - SM[BE]S:UNIX_SV:*:*) - echo mips-dde-sysv${UNAME_RELEASE} - exit 0 ;; - RM*:ReliantUNIX-*:*:*) - echo mips-sni-sysv4 - exit 0 ;; - RM*:SINIX-*:*:*) - echo mips-sni-sysv4 - exit 0 ;; - *:SINIX-*:*:*) - if uname -p 2>/dev/null >/dev/null ; then - UNAME_MACHINE=`(uname -p) 2>/dev/null` - echo ${UNAME_MACHINE}-sni-sysv4 - else - echo ns32k-sni-sysv - fi - exit 0 ;; - PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort - # says - echo i586-unisys-sysv4 - exit 0 ;; - *:UNIX_System_V:4*:FTX*) - # From Gerald Hewes . - # How about differentiating between stratus architectures? -djm - echo hppa1.1-stratus-sysv4 - exit 0 ;; - *:*:*:FTX*) - # From seanf@swdc.stratus.com. - echo i860-stratus-sysv4 - exit 0 ;; - *:VOS:*:*) - # From Paul.Green@stratus.com. - echo hppa1.1-stratus-vos - exit 0 ;; - mc68*:A/UX:*:*) - echo m68k-apple-aux${UNAME_RELEASE} - exit 0 ;; - news*:NEWS-OS:6*:*) - echo mips-sony-newsos6 - exit 0 ;; - R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) - if [ -d /usr/nec ]; then - echo mips-nec-sysv${UNAME_RELEASE} - else - echo mips-unknown-sysv${UNAME_RELEASE} - fi - exit 0 ;; - BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. - echo powerpc-be-beos - exit 0 ;; - BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. - echo powerpc-apple-beos - exit 0 ;; - BePC:BeOS:*:*) # BeOS running on Intel PC compatible. - echo i586-pc-beos - exit 0 ;; - SX-4:SUPER-UX:*:*) - echo sx4-nec-superux${UNAME_RELEASE} - exit 0 ;; - SX-5:SUPER-UX:*:*) - echo sx5-nec-superux${UNAME_RELEASE} - exit 0 ;; - Power*:Rhapsody:*:*) - echo powerpc-apple-rhapsody${UNAME_RELEASE} - exit 0 ;; - *:Rhapsody:*:*) - echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} - exit 0 ;; - *:Darwin:*:*) - echo `uname -p`-apple-darwin${UNAME_RELEASE} - exit 0 ;; - *:procnto*:*:* | *:QNX:[0123456789]*:*) - UNAME_PROCESSOR=`uname -p` - if test "$UNAME_PROCESSOR" = "x86"; then - UNAME_PROCESSOR=i386 - UNAME_MACHINE=pc - fi - echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} - exit 0 ;; - *:QNX:*:4*) - echo i386-pc-qnx - exit 0 ;; - NSR-[GKLNPTVW]:NONSTOP_KERNEL:*:*) - echo nsr-tandem-nsk${UNAME_RELEASE} - exit 0 ;; - *:NonStop-UX:*:*) - echo mips-compaq-nonstopux - exit 0 ;; - BS2000:POSIX*:*:*) - echo bs2000-siemens-sysv - exit 0 ;; - DS/*:UNIX_System_V:*:*) - echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} - exit 0 ;; - *:Plan9:*:*) - # "uname -m" is not consistent, so use $cputype instead. 386 - # is converted to i386 for consistency with other x86 - # operating systems. - if test "$cputype" = "386"; then - UNAME_MACHINE=i386 - else - UNAME_MACHINE="$cputype" - fi - echo ${UNAME_MACHINE}-unknown-plan9 - exit 0 ;; - i*86:OS/2:*:*) - # If we were able to find `uname', then EMX Unix compatibility - # is probably installed. - echo ${UNAME_MACHINE}-pc-os2-emx - exit 0 ;; - *:TOPS-10:*:*) - echo pdp10-unknown-tops10 - exit 0 ;; - *:TENEX:*:*) - echo pdp10-unknown-tenex - exit 0 ;; - KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) - echo pdp10-dec-tops20 - exit 0 ;; - XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) - echo pdp10-xkl-tops20 - exit 0 ;; - *:TOPS-20:*:*) - echo pdp10-unknown-tops20 - exit 0 ;; - *:ITS:*:*) - echo pdp10-unknown-its - exit 0 ;; - i*86:XTS-300:*:STOP) - echo ${UNAME_MACHINE}-unknown-stop - exit 0 ;; - i*86:atheos:*:*) - echo ${UNAME_MACHINE}-unknown-atheos - exit 0 ;; -esac - -#echo '(No uname command or uname output not recognized.)' 1>&2 -#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 - -eval $set_cc_for_build -cat >$dummy.c < -# include -#endif -main () -{ -#if defined (sony) -#if defined (MIPSEB) - /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, - I don't know.... */ - printf ("mips-sony-bsd\n"); exit (0); -#else -#include - printf ("m68k-sony-newsos%s\n", -#ifdef NEWSOS4 - "4" -#else - "" -#endif - ); exit (0); -#endif -#endif - -#if defined (__arm) && defined (__acorn) && defined (__unix) - printf ("arm-acorn-riscix"); exit (0); -#endif - -#if defined (hp300) && !defined (hpux) - printf ("m68k-hp-bsd\n"); exit (0); -#endif - -#if defined (NeXT) -#if !defined (__ARCHITECTURE__) -#define __ARCHITECTURE__ "m68k" -#endif - int version; - version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; - if (version < 4) - printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); - else - printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); - exit (0); -#endif - -#if defined (MULTIMAX) || defined (n16) -#if defined (UMAXV) - printf ("ns32k-encore-sysv\n"); exit (0); -#else -#if defined (CMU) - printf ("ns32k-encore-mach\n"); exit (0); -#else - printf ("ns32k-encore-bsd\n"); exit (0); -#endif -#endif -#endif - -#if defined (__386BSD__) - printf ("i386-pc-bsd\n"); exit (0); -#endif - -#if defined (sequent) -#if defined (i386) - printf ("i386-sequent-dynix\n"); exit (0); -#endif -#if defined (ns32000) - printf ("ns32k-sequent-dynix\n"); exit (0); -#endif -#endif - -#if defined (_SEQUENT_) - struct utsname un; - - uname(&un); - - if (strncmp(un.version, "V2", 2) == 0) { - printf ("i386-sequent-ptx2\n"); exit (0); - } - if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ - printf ("i386-sequent-ptx1\n"); exit (0); - } - printf ("i386-sequent-ptx\n"); exit (0); - -#endif - -#if defined (vax) -# if !defined (ultrix) -# include -# if defined (BSD) -# if BSD == 43 - printf ("vax-dec-bsd4.3\n"); exit (0); -# else -# if BSD == 199006 - printf ("vax-dec-bsd4.3reno\n"); exit (0); -# else - printf ("vax-dec-bsd\n"); exit (0); -# endif -# endif -# else - printf ("vax-dec-bsd\n"); exit (0); -# endif -# else - printf ("vax-dec-ultrix\n"); exit (0); -# endif -#endif - -#if defined (alliant) && defined (i860) - printf ("i860-alliant-bsd\n"); exit (0); -#endif - - exit (1); -} -EOF - -$CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy && rm -f $dummy.c $dummy && exit 0 -rm -f $dummy.c $dummy - -# Apollos put the system type in the environment. - -test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; } - -# Convex versions that predate uname can use getsysinfo(1) - -if [ -x /usr/convex/getsysinfo ] -then - case `getsysinfo -f cpu_type` in - c1*) - echo c1-convex-bsd - exit 0 ;; - c2*) - if getsysinfo -f scalar_acc - then echo c32-convex-bsd - else echo c2-convex-bsd - fi - exit 0 ;; - c34*) - echo c34-convex-bsd - exit 0 ;; - c38*) - echo c38-convex-bsd - exit 0 ;; - c4*) - echo c4-convex-bsd - exit 0 ;; - esac -fi - -cat >&2 < in order to provide the needed -information to handle your system. - -config.guess timestamp = $timestamp - -uname -m = `(uname -m) 2>/dev/null || echo unknown` -uname -r = `(uname -r) 2>/dev/null || echo unknown` -uname -s = `(uname -s) 2>/dev/null || echo unknown` -uname -v = `(uname -v) 2>/dev/null || echo unknown` - -/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` -/bin/uname -X = `(/bin/uname -X) 2>/dev/null` - -hostinfo = `(hostinfo) 2>/dev/null` -/bin/universe = `(/bin/universe) 2>/dev/null` -/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` -/bin/arch = `(/bin/arch) 2>/dev/null` -/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` -/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` - -UNAME_MACHINE = ${UNAME_MACHINE} -UNAME_RELEASE = ${UNAME_RELEASE} -UNAME_SYSTEM = ${UNAME_SYSTEM} -UNAME_VERSION = ${UNAME_VERSION} -EOF - -exit 1 - -# Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "timestamp='" -# time-stamp-format: "%:y-%02m-%02d" -# time-stamp-end: "'" -# End: diff --git a/src/pal/src/libunwind/aux_/config.sub b/src/pal/src/libunwind/aux_/config.sub deleted file mode 100644 index f3657978c..000000000 --- a/src/pal/src/libunwind/aux_/config.sub +++ /dev/null @@ -1,1443 +0,0 @@ -#! /bin/sh -# Configuration validation subroutine script. -# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, -# 2000, 2001, 2002 Free Software Foundation, Inc. - -timestamp='2002-03-07' - -# This file is (in principle) common to ALL GNU software. -# The presence of a machine in this file suggests that SOME GNU software -# can handle that machine. It does not imply ALL GNU software can. -# -# This file is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, -# Boston, MA 02111-1307, USA. - -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -# Please send patches to . Submit a context -# diff and a properly formatted ChangeLog entry. -# -# Configuration subroutine to validate and canonicalize a configuration type. -# Supply the specified configuration type as an argument. -# If it is invalid, we print an error message on stderr and exit with code 1. -# Otherwise, we print the canonical config type on stdout and succeed. - -# This file is supposed to be the same for all GNU packages -# and recognize all the CPU types, system types and aliases -# that are meaningful with *any* GNU software. -# Each package is responsible for reporting which valid configurations -# it does not support. The user should be able to distinguish -# a failure to support a valid configuration from a meaningless -# configuration. - -# The goal of this file is to map all the various variations of a given -# machine specification into a single specification in the form: -# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM -# or in some cases, the newer four-part form: -# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM -# It is wrong to echo any other type of specification. - -me=`echo "$0" | sed -e 's,.*/,,'` - -usage="\ -Usage: $0 [OPTION] CPU-MFR-OPSYS - $0 [OPTION] ALIAS - -Canonicalize a configuration name. - -Operation modes: - -h, --help print this help, then exit - -t, --time-stamp print date of last modification, then exit - -v, --version print version number, then exit - -Report bugs and patches to ." - -version="\ -GNU config.sub ($timestamp) - -Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 -Free Software Foundation, Inc. - -This is free software; see the source for copying conditions. There is NO -warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." - -help=" -Try \`$me --help' for more information." - -# Parse command line -while test $# -gt 0 ; do - case $1 in - --time-stamp | --time* | -t ) - echo "$timestamp" ; exit 0 ;; - --version | -v ) - echo "$version" ; exit 0 ;; - --help | --h* | -h ) - echo "$usage"; exit 0 ;; - -- ) # Stop option processing - shift; break ;; - - ) # Use stdin as input. - break ;; - -* ) - echo "$me: invalid option $1$help" - exit 1 ;; - - *local*) - # First pass through any local machine types. - echo $1 - exit 0;; - - * ) - break ;; - esac -done - -case $# in - 0) echo "$me: missing argument$help" >&2 - exit 1;; - 1) ;; - *) echo "$me: too many arguments$help" >&2 - exit 1;; -esac - -# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). -# Here we must recognize all the valid KERNEL-OS combinations. -maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` -case $maybe_os in - nto-qnx* | linux-gnu* | storm-chaos* | os2-emx* | windows32-* | rtmk-nova*) - os=-$maybe_os - basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` - ;; - *) - basic_machine=`echo $1 | sed 's/-[^-]*$//'` - if [ $basic_machine != $1 ] - then os=`echo $1 | sed 's/.*-/-/'` - else os=; fi - ;; -esac - -### Let's recognize common machines as not being operating systems so -### that things like config.sub decstation-3100 work. We also -### recognize some manufacturers as not being operating systems, so we -### can provide default operating systems below. -case $os in - -sun*os*) - # Prevent following clause from handling this invalid input. - ;; - -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ - -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ - -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ - -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ - -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ - -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ - -apple | -axis) - os= - basic_machine=$1 - ;; - -sim | -cisco | -oki | -wec | -winbond) - os= - basic_machine=$1 - ;; - -scout) - ;; - -wrs) - os=-vxworks - basic_machine=$1 - ;; - -chorusos*) - os=-chorusos - basic_machine=$1 - ;; - -chorusrdb) - os=-chorusrdb - basic_machine=$1 - ;; - -hiux*) - os=-hiuxwe2 - ;; - -sco5) - os=-sco3.2v5 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco4) - os=-sco3.2v4 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco3.2.[4-9]*) - os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco3.2v[4-9]*) - # Don't forget version if it is 3.2v4 or newer. - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco*) - os=-sco3.2v2 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -udk*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -isc) - os=-isc2.2 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -clix*) - basic_machine=clipper-intergraph - ;; - -isc*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -lynx*) - os=-lynxos - ;; - -ptx*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` - ;; - -windowsnt*) - os=`echo $os | sed -e 's/windowsnt/winnt/'` - ;; - -psos*) - os=-psos - ;; - -mint | -mint[0-9]*) - basic_machine=m68k-atari - os=-mint - ;; -esac - -# Decode aliases for certain CPU-COMPANY combinations. -case $basic_machine in - # Recognize the basic CPU types without company name. - # Some are omitted here because they have special meanings below. - 1750a | 580 \ - | a29k \ - | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ - | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ - | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \ - | c4x | clipper \ - | d10v | d30v | dsp16xx \ - | fr30 \ - | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ - | i370 | i860 | i960 | ia64 \ - | m32r | m68000 | m68k | m88k | mcore \ - | mips | mips16 | mips64 | mips64el | mips64orion | mips64orionel \ - | mips64vr4100 | mips64vr4100el | mips64vr4300 \ - | mips64vr4300el | mips64vr5000 | mips64vr5000el \ - | mipsbe | mipseb | mipsel | mipsle | mipstx39 | mipstx39el \ - | mipsisa32 | mipsisa64 \ - | mn10200 | mn10300 \ - | ns16k | ns32k \ - | openrisc | or32 \ - | pdp10 | pdp11 | pj | pjl \ - | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ - | pyramid \ - | sh | sh[34] | sh[34]eb | shbe | shle | sh64 \ - | sparc | sparc64 | sparc86x | sparclet | sparclite | sparcv9 | sparcv9b \ - | strongarm \ - | tahoe | thumb | tic80 | tron \ - | v850 | v850e \ - | we32k \ - | x86 | xscale | xstormy16 | xtensa \ - | z8k) - basic_machine=$basic_machine-unknown - ;; - m6811 | m68hc11 | m6812 | m68hc12) - # Motorola 68HC11/12. - basic_machine=$basic_machine-unknown - os=-none - ;; - m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) - ;; - - # We use `pc' rather than `unknown' - # because (1) that's what they normally are, and - # (2) the word "unknown" tends to confuse beginning users. - i*86 | x86_64) - basic_machine=$basic_machine-pc - ;; - # Object if more than one company name word. - *-*-*) - echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 - exit 1 - ;; - # Recognize the basic CPU types with company name. - 580-* \ - | a29k-* \ - | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ - | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ - | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ - | arm-* | armbe-* | armle-* | armv*-* \ - | avr-* \ - | bs2000-* \ - | c[123]* | c30-* | [cjt]90-* | c54x-* \ - | clipper-* | cydra-* \ - | d10v-* | d30v-* \ - | elxsi-* \ - | f30[01]-* | f700-* | fr30-* | fx80-* \ - | h8300-* | h8500-* \ - | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ - | i*86-* | i860-* | i960-* | ia64-* \ - | m32r-* \ - | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ - | m88110-* | m88k-* | mcore-* \ - | mips-* | mips16-* | mips64-* | mips64el-* | mips64orion-* \ - | mips64orionel-* | mips64vr4100-* | mips64vr4100el-* \ - | mips64vr4300-* | mips64vr4300el-* | mipsbe-* | mipseb-* \ - | mipsle-* | mipsel-* | mipstx39-* | mipstx39el-* \ - | none-* | np1-* | ns16k-* | ns32k-* \ - | orion-* \ - | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ - | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ - | pyramid-* \ - | romp-* | rs6000-* \ - | sh-* | sh[34]-* | sh[34]eb-* | shbe-* | shle-* | sh64-* \ - | sparc-* | sparc64-* | sparc86x-* | sparclet-* | sparclite-* \ - | sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \ - | tahoe-* | thumb-* | tic30-* | tic54x-* | tic80-* | tron-* \ - | v850-* | v850e-* | vax-* \ - | we32k-* \ - | x86-* | x86_64-* | xps100-* | xscale-* | xstormy16-* \ - | xtensa-* \ - | ymp-* \ - | z8k-*) - ;; - # Recognize the various machine names and aliases which stand - # for a CPU type and a company and sometimes even an OS. - 386bsd) - basic_machine=i386-unknown - os=-bsd - ;; - 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) - basic_machine=m68000-att - ;; - 3b*) - basic_machine=we32k-att - ;; - a29khif) - basic_machine=a29k-amd - os=-udi - ;; - adobe68k) - basic_machine=m68010-adobe - os=-scout - ;; - alliant | fx80) - basic_machine=fx80-alliant - ;; - altos | altos3068) - basic_machine=m68k-altos - ;; - am29k) - basic_machine=a29k-none - os=-bsd - ;; - amdahl) - basic_machine=580-amdahl - os=-sysv - ;; - amiga | amiga-*) - basic_machine=m68k-unknown - ;; - amigaos | amigados) - basic_machine=m68k-unknown - os=-amigaos - ;; - amigaunix | amix) - basic_machine=m68k-unknown - os=-sysv4 - ;; - apollo68) - basic_machine=m68k-apollo - os=-sysv - ;; - apollo68bsd) - basic_machine=m68k-apollo - os=-bsd - ;; - aux) - basic_machine=m68k-apple - os=-aux - ;; - balance) - basic_machine=ns32k-sequent - os=-dynix - ;; - c90) - basic_machine=c90-cray - os=-unicos - ;; - convex-c1) - basic_machine=c1-convex - os=-bsd - ;; - convex-c2) - basic_machine=c2-convex - os=-bsd - ;; - convex-c32) - basic_machine=c32-convex - os=-bsd - ;; - convex-c34) - basic_machine=c34-convex - os=-bsd - ;; - convex-c38) - basic_machine=c38-convex - os=-bsd - ;; - cray | j90) - basic_machine=j90-cray - os=-unicos - ;; - crds | unos) - basic_machine=m68k-crds - ;; - cris | cris-* | etrax*) - basic_machine=cris-axis - ;; - da30 | da30-*) - basic_machine=m68k-da30 - ;; - decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) - basic_machine=mips-dec - ;; - decsystem10* | dec10*) - basic_machine=pdp10-dec - os=-tops10 - ;; - decsystem20* | dec20*) - basic_machine=pdp10-dec - os=-tops20 - ;; - delta | 3300 | motorola-3300 | motorola-delta \ - | 3300-motorola | delta-motorola) - basic_machine=m68k-motorola - ;; - delta88) - basic_machine=m88k-motorola - os=-sysv3 - ;; - dpx20 | dpx20-*) - basic_machine=rs6000-bull - os=-bosx - ;; - dpx2* | dpx2*-bull) - basic_machine=m68k-bull - os=-sysv3 - ;; - ebmon29k) - basic_machine=a29k-amd - os=-ebmon - ;; - elxsi) - basic_machine=elxsi-elxsi - os=-bsd - ;; - encore | umax | mmax) - basic_machine=ns32k-encore - ;; - es1800 | OSE68k | ose68k | ose | OSE) - basic_machine=m68k-ericsson - os=-ose - ;; - fx2800) - basic_machine=i860-alliant - ;; - genix) - basic_machine=ns32k-ns - ;; - gmicro) - basic_machine=tron-gmicro - os=-sysv - ;; - go32) - basic_machine=i386-pc - os=-go32 - ;; - h3050r* | hiux*) - basic_machine=hppa1.1-hitachi - os=-hiuxwe2 - ;; - h8300hms) - basic_machine=h8300-hitachi - os=-hms - ;; - h8300xray) - basic_machine=h8300-hitachi - os=-xray - ;; - h8500hms) - basic_machine=h8500-hitachi - os=-hms - ;; - harris) - basic_machine=m88k-harris - os=-sysv3 - ;; - hp300-*) - basic_machine=m68k-hp - ;; - hp300bsd) - basic_machine=m68k-hp - os=-bsd - ;; - hp300hpux) - basic_machine=m68k-hp - os=-hpux - ;; - hp3k9[0-9][0-9] | hp9[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - hp9k2[0-9][0-9] | hp9k31[0-9]) - basic_machine=m68000-hp - ;; - hp9k3[2-9][0-9]) - basic_machine=m68k-hp - ;; - hp9k6[0-9][0-9] | hp6[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - hp9k7[0-79][0-9] | hp7[0-79][0-9]) - basic_machine=hppa1.1-hp - ;; - hp9k78[0-9] | hp78[0-9]) - # FIXME: really hppa2.0-hp - basic_machine=hppa1.1-hp - ;; - hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) - # FIXME: really hppa2.0-hp - basic_machine=hppa1.1-hp - ;; - hp9k8[0-9][13679] | hp8[0-9][13679]) - basic_machine=hppa1.1-hp - ;; - hp9k8[0-9][0-9] | hp8[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - hppa-next) - os=-nextstep3 - ;; - hppaosf) - basic_machine=hppa1.1-hp - os=-osf - ;; - hppro) - basic_machine=hppa1.1-hp - os=-proelf - ;; - i370-ibm* | ibm*) - basic_machine=i370-ibm - ;; -# I'm not sure what "Sysv32" means. Should this be sysv3.2? - i*86v32) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv32 - ;; - i*86v4*) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv4 - ;; - i*86v) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv - ;; - i*86sol2) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-solaris2 - ;; - i386mach) - basic_machine=i386-mach - os=-mach - ;; - i386-vsta | vsta) - basic_machine=i386-unknown - os=-vsta - ;; - iris | iris4d) - basic_machine=mips-sgi - case $os in - -irix*) - ;; - *) - os=-irix4 - ;; - esac - ;; - isi68 | isi) - basic_machine=m68k-isi - os=-sysv - ;; - m88k-omron*) - basic_machine=m88k-omron - ;; - magnum | m3230) - basic_machine=mips-mips - os=-sysv - ;; - merlin) - basic_machine=ns32k-utek - os=-sysv - ;; - mingw32) - basic_machine=i386-pc - os=-mingw32 - ;; - miniframe) - basic_machine=m68000-convergent - ;; - *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) - basic_machine=m68k-atari - os=-mint - ;; - mips3*-*) - basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` - ;; - mips3*) - basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown - ;; - mmix*) - basic_machine=mmix-knuth - os=-mmixware - ;; - monitor) - basic_machine=m68k-rom68k - os=-coff - ;; - morphos) - basic_machine=powerpc-unknown - os=-morphos - ;; - msdos) - basic_machine=i386-pc - os=-msdos - ;; - mvs) - basic_machine=i370-ibm - os=-mvs - ;; - ncr3000) - basic_machine=i486-ncr - os=-sysv4 - ;; - netbsd386) - basic_machine=i386-unknown - os=-netbsd - ;; - netwinder) - basic_machine=armv4l-rebel - os=-linux - ;; - news | news700 | news800 | news900) - basic_machine=m68k-sony - os=-newsos - ;; - news1000) - basic_machine=m68030-sony - os=-newsos - ;; - news-3600 | risc-news) - basic_machine=mips-sony - os=-newsos - ;; - necv70) - basic_machine=v70-nec - os=-sysv - ;; - next | m*-next ) - basic_machine=m68k-next - case $os in - -nextstep* ) - ;; - -ns2*) - os=-nextstep2 - ;; - *) - os=-nextstep3 - ;; - esac - ;; - nh3000) - basic_machine=m68k-harris - os=-cxux - ;; - nh[45]000) - basic_machine=m88k-harris - os=-cxux - ;; - nindy960) - basic_machine=i960-intel - os=-nindy - ;; - mon960) - basic_machine=i960-intel - os=-mon960 - ;; - nonstopux) - basic_machine=mips-compaq - os=-nonstopux - ;; - np1) - basic_machine=np1-gould - ;; - nsr-tandem) - basic_machine=nsr-tandem - ;; - op50n-* | op60c-*) - basic_machine=hppa1.1-oki - os=-proelf - ;; - or32 | or32-*) - basic_machine=or32-unknown - os=-coff - ;; - OSE68000 | ose68000) - basic_machine=m68000-ericsson - os=-ose - ;; - os68k) - basic_machine=m68k-none - os=-os68k - ;; - pa-hitachi) - basic_machine=hppa1.1-hitachi - os=-hiuxwe2 - ;; - paragon) - basic_machine=i860-intel - os=-osf - ;; - pbd) - basic_machine=sparc-tti - ;; - pbb) - basic_machine=m68k-tti - ;; - pc532 | pc532-*) - basic_machine=ns32k-pc532 - ;; - pentium | p5 | k5 | k6 | nexgen | viac3) - basic_machine=i586-pc - ;; - pentiumpro | p6 | 6x86 | athlon) - basic_machine=i686-pc - ;; - pentiumii | pentium2) - basic_machine=i686-pc - ;; - pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) - basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentiumpro-* | p6-* | 6x86-* | athlon-*) - basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentiumii-* | pentium2-*) - basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pn) - basic_machine=pn-gould - ;; - power) basic_machine=power-ibm - ;; - ppc) basic_machine=powerpc-unknown - ;; - ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppcle | powerpclittle | ppc-le | powerpc-little) - basic_machine=powerpcle-unknown - ;; - ppcle-* | powerpclittle-*) - basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppc64) basic_machine=powerpc64-unknown - ;; - ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppc64le | powerpc64little | ppc64-le | powerpc64-little) - basic_machine=powerpc64le-unknown - ;; - ppc64le-* | powerpc64little-*) - basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ps2) - basic_machine=i386-ibm - ;; - pw32) - basic_machine=i586-unknown - os=-pw32 - ;; - rom68k) - basic_machine=m68k-rom68k - os=-coff - ;; - rm[46]00) - basic_machine=mips-siemens - ;; - rtpc | rtpc-*) - basic_machine=romp-ibm - ;; - s390 | s390-*) - basic_machine=s390-ibm - ;; - s390x | s390x-*) - basic_machine=s390x-ibm - ;; - sa29200) - basic_machine=a29k-amd - os=-udi - ;; - sequent) - basic_machine=i386-sequent - ;; - sh) - basic_machine=sh-hitachi - os=-hms - ;; - sparclite-wrs | simso-wrs) - basic_machine=sparclite-wrs - os=-vxworks - ;; - sps7) - basic_machine=m68k-bull - os=-sysv2 - ;; - spur) - basic_machine=spur-unknown - ;; - st2000) - basic_machine=m68k-tandem - ;; - stratus) - basic_machine=i860-stratus - os=-sysv4 - ;; - sun2) - basic_machine=m68000-sun - ;; - sun2os3) - basic_machine=m68000-sun - os=-sunos3 - ;; - sun2os4) - basic_machine=m68000-sun - os=-sunos4 - ;; - sun3os3) - basic_machine=m68k-sun - os=-sunos3 - ;; - sun3os4) - basic_machine=m68k-sun - os=-sunos4 - ;; - sun4os3) - basic_machine=sparc-sun - os=-sunos3 - ;; - sun4os4) - basic_machine=sparc-sun - os=-sunos4 - ;; - sun4sol2) - basic_machine=sparc-sun - os=-solaris2 - ;; - sun3 | sun3-*) - basic_machine=m68k-sun - ;; - sun4) - basic_machine=sparc-sun - ;; - sun386 | sun386i | roadrunner) - basic_machine=i386-sun - ;; - sv1) - basic_machine=sv1-cray - os=-unicos - ;; - symmetry) - basic_machine=i386-sequent - os=-dynix - ;; - t3d) - basic_machine=alpha-cray - os=-unicos - ;; - t3e) - basic_machine=alphaev5-cray - os=-unicos - ;; - t90) - basic_machine=t90-cray - os=-unicos - ;; - tic54x | c54x*) - basic_machine=tic54x-unknown - os=-coff - ;; - tx39) - basic_machine=mipstx39-unknown - ;; - tx39el) - basic_machine=mipstx39el-unknown - ;; - toad1) - basic_machine=pdp10-xkl - os=-tops20 - ;; - tower | tower-32) - basic_machine=m68k-ncr - ;; - udi29k) - basic_machine=a29k-amd - os=-udi - ;; - ultra3) - basic_machine=a29k-nyu - os=-sym1 - ;; - v810 | necv810) - basic_machine=v810-nec - os=-none - ;; - vaxv) - basic_machine=vax-dec - os=-sysv - ;; - vms) - basic_machine=vax-dec - os=-vms - ;; - vpp*|vx|vx-*) - basic_machine=f301-fujitsu - ;; - vxworks960) - basic_machine=i960-wrs - os=-vxworks - ;; - vxworks68) - basic_machine=m68k-wrs - os=-vxworks - ;; - vxworks29k) - basic_machine=a29k-wrs - os=-vxworks - ;; - w65*) - basic_machine=w65-wdc - os=-none - ;; - w89k-*) - basic_machine=hppa1.1-winbond - os=-proelf - ;; - windows32) - basic_machine=i386-pc - os=-windows32-msvcrt - ;; - xps | xps100) - basic_machine=xps100-honeywell - ;; - ymp) - basic_machine=ymp-cray - os=-unicos - ;; - z8k-*-coff) - basic_machine=z8k-unknown - os=-sim - ;; - none) - basic_machine=none-none - os=-none - ;; - -# Here we handle the default manufacturer of certain CPU types. It is in -# some cases the only manufacturer, in others, it is the most popular. - w89k) - basic_machine=hppa1.1-winbond - ;; - op50n) - basic_machine=hppa1.1-oki - ;; - op60c) - basic_machine=hppa1.1-oki - ;; - romp) - basic_machine=romp-ibm - ;; - rs6000) - basic_machine=rs6000-ibm - ;; - vax) - basic_machine=vax-dec - ;; - pdp10) - # there are many clones, so DEC is not a safe bet - basic_machine=pdp10-unknown - ;; - pdp11) - basic_machine=pdp11-dec - ;; - we32k) - basic_machine=we32k-att - ;; - sh3 | sh4 | sh3eb | sh4eb) - basic_machine=sh-unknown - ;; - sh64) - basic_machine=sh64-unknown - ;; - sparc | sparcv9 | sparcv9b) - basic_machine=sparc-sun - ;; - cydra) - basic_machine=cydra-cydrome - ;; - orion) - basic_machine=orion-highlevel - ;; - orion105) - basic_machine=clipper-highlevel - ;; - mac | mpw | mac-mpw) - basic_machine=m68k-apple - ;; - pmac | pmac-mpw) - basic_machine=powerpc-apple - ;; - c4x*) - basic_machine=c4x-none - os=-coff - ;; - *-unknown) - # Make sure to match an already-canonicalized machine name. - ;; - *) - echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 - exit 1 - ;; -esac - -# Here we canonicalize certain aliases for manufacturers. -case $basic_machine in - *-digital*) - basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` - ;; - *-commodore*) - basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` - ;; - *) - ;; -esac - -# Decode manufacturer-specific aliases for certain operating systems. - -if [ x"$os" != x"" ] -then -case $os in - # First match some system type aliases - # that might get confused with valid system types. - # -solaris* is a basic system type, with this one exception. - -solaris1 | -solaris1.*) - os=`echo $os | sed -e 's|solaris1|sunos4|'` - ;; - -solaris) - os=-solaris2 - ;; - -svr4*) - os=-sysv4 - ;; - -unixware*) - os=-sysv4.2uw - ;; - -gnu/linux*) - os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` - ;; - # First accept the basic system types. - # The portable systems comes first. - # Each alternative MUST END IN A *, to match a version number. - # -sysv* is not here because it comes later, after sysvr4. - -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ - | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\ - | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ - | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ - | -aos* \ - | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ - | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ - | -hiux* | -386bsd* | -netbsd* | -openbsd* | -freebsd* | -riscix* \ - | -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ - | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ - | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ - | -chorusos* | -chorusrdb* \ - | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ - | -mingw32* | -linux-gnu* | -uxpv* | -beos* | -mpeix* | -udk* \ - | -interix* | -uwin* | -rhapsody* | -darwin* | -opened* \ - | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ - | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ - | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ - | -morphos* | -superux* | -rtmk* | -rtmk-nova*) - # Remember, each alternative MUST END IN *, to match a version number. - ;; - -qnx*) - case $basic_machine in - x86-* | i*86-*) - ;; - *) - os=-nto$os - ;; - esac - ;; - -nto*) - os=-nto-qnx - ;; - -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ - | -windows* | -osx | -abug | -netware* | -os9* | -beos* \ - | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) - ;; - -mac*) - os=`echo $os | sed -e 's|mac|macos|'` - ;; - -linux*) - os=`echo $os | sed -e 's|linux|linux-gnu|'` - ;; - -sunos5*) - os=`echo $os | sed -e 's|sunos5|solaris2|'` - ;; - -sunos6*) - os=`echo $os | sed -e 's|sunos6|solaris3|'` - ;; - -opened*) - os=-openedition - ;; - -wince*) - os=-wince - ;; - -osfrose*) - os=-osfrose - ;; - -osf*) - os=-osf - ;; - -utek*) - os=-bsd - ;; - -dynix*) - os=-bsd - ;; - -acis*) - os=-aos - ;; - -atheos*) - os=-atheos - ;; - -386bsd) - os=-bsd - ;; - -ctix* | -uts*) - os=-sysv - ;; - -nova*) - os=-rtmk-nova - ;; - -ns2 ) - os=-nextstep2 - ;; - -nsk*) - os=-nsk - ;; - # Preserve the version number of sinix5. - -sinix5.*) - os=`echo $os | sed -e 's|sinix|sysv|'` - ;; - -sinix*) - os=-sysv4 - ;; - -triton*) - os=-sysv3 - ;; - -oss*) - os=-sysv3 - ;; - -svr4) - os=-sysv4 - ;; - -svr3) - os=-sysv3 - ;; - -sysvr4) - os=-sysv4 - ;; - # This must come after -sysvr4. - -sysv*) - ;; - -ose*) - os=-ose - ;; - -es1800*) - os=-ose - ;; - -xenix) - os=-xenix - ;; - -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) - os=-mint - ;; - -none) - ;; - *) - # Get rid of the `-' at the beginning of $os. - os=`echo $os | sed 's/[^-]*-//'` - echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 - exit 1 - ;; -esac -else - -# Here we handle the default operating systems that come with various machines. -# The value should be what the vendor currently ships out the door with their -# machine or put another way, the most popular os provided with the machine. - -# Note that if you're going to try to match "-MANUFACTURER" here (say, -# "-sun"), then you have to tell the case statement up towards the top -# that MANUFACTURER isn't an operating system. Otherwise, code above -# will signal an error saying that MANUFACTURER isn't an operating -# system, and we'll never get to this point. - -case $basic_machine in - *-acorn) - os=-riscix1.2 - ;; - arm*-rebel) - os=-linux - ;; - arm*-semi) - os=-aout - ;; - # This must come before the *-dec entry. - pdp10-*) - os=-tops20 - ;; - pdp11-*) - os=-none - ;; - *-dec | vax-*) - os=-ultrix4.2 - ;; - m68*-apollo) - os=-domain - ;; - i386-sun) - os=-sunos4.0.2 - ;; - m68000-sun) - os=-sunos3 - # This also exists in the configure program, but was not the - # default. - # os=-sunos4 - ;; - m68*-cisco) - os=-aout - ;; - mips*-cisco) - os=-elf - ;; - mips*-*) - os=-elf - ;; - or32-*) - os=-coff - ;; - *-tti) # must be before sparc entry or we get the wrong os. - os=-sysv3 - ;; - sparc-* | *-sun) - os=-sunos4.1.1 - ;; - *-be) - os=-beos - ;; - *-ibm) - os=-aix - ;; - *-wec) - os=-proelf - ;; - *-winbond) - os=-proelf - ;; - *-oki) - os=-proelf - ;; - *-hp) - os=-hpux - ;; - *-hitachi) - os=-hiux - ;; - i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) - os=-sysv - ;; - *-cbm) - os=-amigaos - ;; - *-dg) - os=-dgux - ;; - *-dolphin) - os=-sysv3 - ;; - m68k-ccur) - os=-rtu - ;; - m88k-omron*) - os=-luna - ;; - *-next ) - os=-nextstep - ;; - *-sequent) - os=-ptx - ;; - *-crds) - os=-unos - ;; - *-ns) - os=-genix - ;; - i370-*) - os=-mvs - ;; - *-next) - os=-nextstep3 - ;; - *-gould) - os=-sysv - ;; - *-highlevel) - os=-bsd - ;; - *-encore) - os=-bsd - ;; - *-sgi) - os=-irix - ;; - *-siemens) - os=-sysv4 - ;; - *-masscomp) - os=-rtu - ;; - f30[01]-fujitsu | f700-fujitsu) - os=-uxpv - ;; - *-rom68k) - os=-coff - ;; - *-*bug) - os=-coff - ;; - *-apple) - os=-macos - ;; - *-atari*) - os=-mint - ;; - *) - os=-none - ;; -esac -fi - -# Here we handle the case where we know the os, and the CPU type, but not the -# manufacturer. We pick the logical manufacturer. -vendor=unknown -case $basic_machine in - *-unknown) - case $os in - -riscix*) - vendor=acorn - ;; - -sunos*) - vendor=sun - ;; - -aix*) - vendor=ibm - ;; - -beos*) - vendor=be - ;; - -hpux*) - vendor=hp - ;; - -mpeix*) - vendor=hp - ;; - -hiux*) - vendor=hitachi - ;; - -unos*) - vendor=crds - ;; - -dgux*) - vendor=dg - ;; - -luna*) - vendor=omron - ;; - -genix*) - vendor=ns - ;; - -mvs* | -opened*) - vendor=ibm - ;; - -ptx*) - vendor=sequent - ;; - -vxsim* | -vxworks*) - vendor=wrs - ;; - -aux*) - vendor=apple - ;; - -hms*) - vendor=hitachi - ;; - -mpw* | -macos*) - vendor=apple - ;; - -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) - vendor=atari - ;; - -vos*) - vendor=stratus - ;; - esac - basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` - ;; -esac - -echo $basic_machine$os -exit 0 - -# Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "timestamp='" -# time-stamp-format: "%:y-%02m-%02d" -# time-stamp-end: "'" -# End: diff --git a/src/pal/src/libunwind/aux_/ltmain.sh b/src/pal/src/libunwind/aux_/ltmain.sh deleted file mode 100644 index 6fc690018..000000000 --- a/src/pal/src/libunwind/aux_/ltmain.sh +++ /dev/null @@ -1,5107 +0,0 @@ -# ltmain.sh - Provide generalized library-building support services. -# NOTE: Changing this file will not affect anything until you rerun configure. -# -# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001 -# Free Software Foundation, Inc. -# Originally by Gordon Matzigkeit , 1996 -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -# Check that we have a working $echo. -if test "X$1" = X--no-reexec; then - # Discard the --no-reexec flag, and continue. - shift -elif test "X$1" = X--fallback-echo; then - # Avoid inline document here, it may be left over - : -elif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then - # Yippee, $echo works! - : -else - # Restart under the correct shell, and then maybe $echo will work. - exec $SHELL "$0" --no-reexec ${1+"$@"} -fi - -if test "X$1" = X--fallback-echo; then - # used as fallback echo - shift - cat <&2 - echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2 - exit 1 -fi - -# Global variables. -mode=$default_mode -nonopt= -prev= -prevopt= -run= -show="$echo" -show_help= -execute_dlfiles= -lo2o="s/\\.lo\$/.${objext}/" -o2lo="s/\\.${objext}\$/.lo/" - -# Parse our command line options once, thoroughly. -while test $# -gt 0 -do - arg="$1" - shift - - case $arg in - -*=*) optarg=`$echo "X$arg" | $Xsed -e 's/[-_a-zA-Z0-9]*=//'` ;; - *) optarg= ;; - esac - - # If the previous option needs an argument, assign it. - if test -n "$prev"; then - case $prev in - execute_dlfiles) - execute_dlfiles="$execute_dlfiles $arg" - ;; - *) - eval "$prev=\$arg" - ;; - esac - - prev= - prevopt= - continue - fi - - # Have we seen a non-optional argument yet? - case $arg in - --help) - show_help=yes - ;; - - --version) - echo "$PROGRAM (GNU $PACKAGE) $VERSION$TIMESTAMP" - exit 0 - ;; - - --config) - ${SED} -e '1,/^# ### BEGIN LIBTOOL CONFIG/d' -e '/^# ### END LIBTOOL CONFIG/,$d' $0 - exit 0 - ;; - - --debug) - echo "$progname: enabling shell trace mode" - set -x - ;; - - --dry-run | -n) - run=: - ;; - - --features) - echo "host: $host" - if test "$build_libtool_libs" = yes; then - echo "enable shared libraries" - else - echo "disable shared libraries" - fi - if test "$build_old_libs" = yes; then - echo "enable static libraries" - else - echo "disable static libraries" - fi - exit 0 - ;; - - --finish) mode="finish" ;; - - --mode) prevopt="--mode" prev=mode ;; - --mode=*) mode="$optarg" ;; - - --preserve-dup-deps) duplicate_deps="yes" ;; - - --quiet | --silent) - show=: - ;; - - -dlopen) - prevopt="-dlopen" - prev=execute_dlfiles - ;; - - -*) - $echo "$modename: unrecognized option \`$arg'" 1>&2 - $echo "$help" 1>&2 - exit 1 - ;; - - *) - nonopt="$arg" - break - ;; - esac -done - -if test -n "$prevopt"; then - $echo "$modename: option \`$prevopt' requires an argument" 1>&2 - $echo "$help" 1>&2 - exit 1 -fi - -# If this variable is set in any of the actions, the command in it -# will be execed at the end. This prevents here-documents from being -# left over by shells. -exec_cmd= - -if test -z "$show_help"; then - - # Infer the operation mode. - if test -z "$mode"; then - case $nonopt in - *cc | *++ | gcc* | *-gcc* | g++* | xlc*) - mode=link - for arg - do - case $arg in - -c) - mode=compile - break - ;; - esac - done - ;; - *db | *dbx | *strace | *truss) - mode=execute - ;; - *install*|cp|mv) - mode=install - ;; - *rm) - mode=uninstall - ;; - *) - # If we have no mode, but dlfiles were specified, then do execute mode. - test -n "$execute_dlfiles" && mode=execute - - # Just use the default operation mode. - if test -z "$mode"; then - if test -n "$nonopt"; then - $echo "$modename: warning: cannot infer operation mode from \`$nonopt'" 1>&2 - else - $echo "$modename: warning: cannot infer operation mode without MODE-ARGS" 1>&2 - fi - fi - ;; - esac - fi - - # Only execute mode is allowed to have -dlopen flags. - if test -n "$execute_dlfiles" && test "$mode" != execute; then - $echo "$modename: unrecognized option \`-dlopen'" 1>&2 - $echo "$help" 1>&2 - exit 1 - fi - - # Change the help message to a mode-specific one. - generic_help="$help" - help="Try \`$modename --help --mode=$mode' for more information." - - # These modes are in order of execution frequency so that they run quickly. - case $mode in - # libtool compile mode - compile) - modename="$modename: compile" - # Get the compilation command and the source file. - base_compile= - prev= - lastarg= - srcfile="$nonopt" - suppress_output= - - user_target=no - for arg - do - case $prev in - "") ;; - xcompiler) - # Aesthetically quote the previous argument. - prev= - lastarg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` - - case $arg in - # Double-quote args containing other shell metacharacters. - # Many Bourne shells cannot handle close brackets correctly - # in scan sets, so we specify it separately. - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") - arg="\"$arg\"" - ;; - esac - - # Add the previous argument to base_compile. - if test -z "$base_compile"; then - base_compile="$lastarg" - else - base_compile="$base_compile $lastarg" - fi - continue - ;; - esac - - # Accept any command-line options. - case $arg in - -o) - if test "$user_target" != "no"; then - $echo "$modename: you cannot specify \`-o' more than once" 1>&2 - exit 1 - fi - user_target=next - ;; - - -static) - build_old_libs=yes - continue - ;; - - -prefer-pic) - pic_mode=yes - continue - ;; - - -prefer-non-pic) - pic_mode=no - continue - ;; - - -Xcompiler) - prev=xcompiler - continue - ;; - - -Wc,*) - args=`$echo "X$arg" | $Xsed -e "s/^-Wc,//"` - lastarg= - save_ifs="$IFS"; IFS=',' - for arg in $args; do - IFS="$save_ifs" - - # Double-quote args containing other shell metacharacters. - # Many Bourne shells cannot handle close brackets correctly - # in scan sets, so we specify it separately. - case $arg in - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") - arg="\"$arg\"" - ;; - esac - lastarg="$lastarg $arg" - done - IFS="$save_ifs" - lastarg=`$echo "X$lastarg" | $Xsed -e "s/^ //"` - - # Add the arguments to base_compile. - if test -z "$base_compile"; then - base_compile="$lastarg" - else - base_compile="$base_compile $lastarg" - fi - continue - ;; - esac - - case $user_target in - next) - # The next one is the -o target name - user_target=yes - continue - ;; - yes) - # We got the output file - user_target=set - libobj="$arg" - continue - ;; - esac - - # Accept the current argument as the source file. - lastarg="$srcfile" - srcfile="$arg" - - # Aesthetically quote the previous argument. - - # Backslashify any backslashes, double quotes, and dollar signs. - # These are the only characters that are still specially - # interpreted inside of double-quoted scrings. - lastarg=`$echo "X$lastarg" | $Xsed -e "$sed_quote_subst"` - - # Double-quote args containing other shell metacharacters. - # Many Bourne shells cannot handle close brackets correctly - # in scan sets, so we specify it separately. - case $lastarg in - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") - lastarg="\"$lastarg\"" - ;; - esac - - # Add the previous argument to base_compile. - if test -z "$base_compile"; then - base_compile="$lastarg" - else - base_compile="$base_compile $lastarg" - fi - done - - case $user_target in - set) - ;; - no) - # Get the name of the library object. - libobj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%'` - ;; - *) - $echo "$modename: you must specify a target with \`-o'" 1>&2 - exit 1 - ;; - esac - - # Recognize several different file suffixes. - # If the user specifies -o file.o, it is replaced with file.lo - xform='[cCFSfmso]' - case $libobj in - *.ada) xform=ada ;; - *.adb) xform=adb ;; - *.ads) xform=ads ;; - *.asm) xform=asm ;; - *.c++) xform=c++ ;; - *.cc) xform=cc ;; - *.cpp) xform=cpp ;; - *.cxx) xform=cxx ;; - *.f90) xform=f90 ;; - *.for) xform=for ;; - esac - - libobj=`$echo "X$libobj" | $Xsed -e "s/\.$xform$/.lo/"` - - case $libobj in - *.lo) obj=`$echo "X$libobj" | $Xsed -e "$lo2o"` ;; - *) - $echo "$modename: cannot determine name of library object from \`$libobj'" 1>&2 - exit 1 - ;; - esac - - if test -z "$base_compile"; then - $echo "$modename: you must specify a compilation command" 1>&2 - $echo "$help" 1>&2 - exit 1 - fi - - # Delete any leftover library objects. - if test "$build_old_libs" = yes; then - removelist="$obj $libobj" - else - removelist="$libobj" - fi - - $run $rm $removelist - trap "$run $rm $removelist; exit 1" 1 2 15 - - # On Cygwin there's no "real" PIC flag so we must build both object types - case $host_os in - cygwin* | mingw* | pw32* | os2*) - pic_mode=default - ;; - esac - if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then - # non-PIC code in shared libraries is not supported - pic_mode=default - fi - - # Calculate the filename of the output object if compiler does - # not support -o with -c - if test "$compiler_c_o" = no; then - output_obj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\.[^.]*$%%'`.${objext} - lockfile="$output_obj.lock" - removelist="$removelist $output_obj $lockfile" - trap "$run $rm $removelist; exit 1" 1 2 15 - else - need_locks=no - lockfile= - fi - - # Lock this critical section if it is needed - # We use this script file to make the link, it avoids creating a new file - if test "$need_locks" = yes; then - until $run ln "$0" "$lockfile" 2>/dev/null; do - $show "Waiting for $lockfile to be removed" - sleep 2 - done - elif test "$need_locks" = warn; then - if test -f "$lockfile"; then - echo "\ -*** ERROR, $lockfile exists and contains: -`cat $lockfile 2>/dev/null` - -This indicates that another process is trying to use the same -temporary object file, and libtool could not work around it because -your compiler does not support \`-c' and \`-o' together. If you -repeat this compilation, it may succeed, by chance, but you had better -avoid parallel builds (make -j) in this platform, or get a better -compiler." - - $run $rm $removelist - exit 1 - fi - echo $srcfile > "$lockfile" - fi - - if test -n "$fix_srcfile_path"; then - eval srcfile=\"$fix_srcfile_path\" - fi - - # Only build a PIC object if we are building libtool libraries. - if test "$build_libtool_libs" = yes; then - # Without this assignment, base_compile gets emptied. - fbsd_hideous_sh_bug=$base_compile - - if test "$pic_mode" != no; then - # All platforms use -DPIC, to notify preprocessed assembler code. - command="$base_compile $srcfile $pic_flag -DPIC" - else - # Don't build PIC code - command="$base_compile $srcfile" - fi - if test "$build_old_libs" = yes; then - lo_libobj="$libobj" - dir=`$echo "X$libobj" | $Xsed -e 's%/[^/]*$%%'` - if test "X$dir" = "X$libobj"; then - dir="$objdir" - else - dir="$dir/$objdir" - fi - libobj="$dir/"`$echo "X$libobj" | $Xsed -e 's%^.*/%%'` - - if test -d "$dir"; then - $show "$rm $libobj" - $run $rm $libobj - else - $show "$mkdir $dir" - $run $mkdir $dir - status=$? - if test $status -ne 0 && test ! -d $dir; then - exit $status - fi - fi - fi - if test "$compiler_o_lo" = yes; then - output_obj="$libobj" - command="$command -o $output_obj" - elif test "$compiler_c_o" = yes; then - output_obj="$obj" - command="$command -o $output_obj" - fi - - $run $rm "$output_obj" - $show "$command" - if $run eval "$command"; then : - else - test -n "$output_obj" && $run $rm $removelist - exit 1 - fi - - if test "$need_locks" = warn && - test x"`cat $lockfile 2>/dev/null`" != x"$srcfile"; then - echo "\ -*** ERROR, $lockfile contains: -`cat $lockfile 2>/dev/null` - -but it should contain: -$srcfile - -This indicates that another process is trying to use the same -temporary object file, and libtool could not work around it because -your compiler does not support \`-c' and \`-o' together. If you -repeat this compilation, it may succeed, by chance, but you had better -avoid parallel builds (make -j) in this platform, or get a better -compiler." - - $run $rm $removelist - exit 1 - fi - - # Just move the object if needed, then go on to compile the next one - if test x"$output_obj" != x"$libobj"; then - $show "$mv $output_obj $libobj" - if $run $mv $output_obj $libobj; then : - else - error=$? - $run $rm $removelist - exit $error - fi - fi - - # If we have no pic_flag, then copy the object into place and finish. - if (test -z "$pic_flag" || test "$pic_mode" != default) && - test "$build_old_libs" = yes; then - # Rename the .lo from within objdir to obj - if test -f $obj; then - $show $rm $obj - $run $rm $obj - fi - - $show "$mv $libobj $obj" - if $run $mv $libobj $obj; then : - else - error=$? - $run $rm $removelist - exit $error - fi - - xdir=`$echo "X$obj" | $Xsed -e 's%/[^/]*$%%'` - if test "X$xdir" = "X$obj"; then - xdir="." - else - xdir="$xdir" - fi - baseobj=`$echo "X$obj" | $Xsed -e "s%.*/%%"` - libobj=`$echo "X$baseobj" | $Xsed -e "$o2lo"` - # Now arrange that obj and lo_libobj become the same file - $show "(cd $xdir && $LN_S $baseobj $libobj)" - if $run eval '(cd $xdir && $LN_S $baseobj $libobj)'; then - # Unlock the critical section if it was locked - if test "$need_locks" != no; then - $run $rm "$lockfile" - fi - exit 0 - else - error=$? - $run $rm $removelist - exit $error - fi - fi - - # Allow error messages only from the first compilation. - suppress_output=' >/dev/null 2>&1' - fi - - # Only build a position-dependent object if we build old libraries. - if test "$build_old_libs" = yes; then - if test "$pic_mode" != yes; then - # Don't build PIC code - command="$base_compile $srcfile" - else - # All platforms use -DPIC, to notify preprocessed assembler code. - command="$base_compile $srcfile $pic_flag -DPIC" - fi - if test "$compiler_c_o" = yes; then - command="$command -o $obj" - output_obj="$obj" - fi - - # Suppress compiler output if we already did a PIC compilation. - command="$command$suppress_output" - $run $rm "$output_obj" - $show "$command" - if $run eval "$command"; then : - else - $run $rm $removelist - exit 1 - fi - - if test "$need_locks" = warn && - test x"`cat $lockfile 2>/dev/null`" != x"$srcfile"; then - echo "\ -*** ERROR, $lockfile contains: -`cat $lockfile 2>/dev/null` - -but it should contain: -$srcfile - -This indicates that another process is trying to use the same -temporary object file, and libtool could not work around it because -your compiler does not support \`-c' and \`-o' together. If you -repeat this compilation, it may succeed, by chance, but you had better -avoid parallel builds (make -j) in this platform, or get a better -compiler." - - $run $rm $removelist - exit 1 - fi - - # Just move the object if needed - if test x"$output_obj" != x"$obj"; then - $show "$mv $output_obj $obj" - if $run $mv $output_obj $obj; then : - else - error=$? - $run $rm $removelist - exit $error - fi - fi - - # Create an invalid libtool object if no PIC, so that we do not - # accidentally link it into a program. - if test "$build_libtool_libs" != yes; then - $show "echo timestamp > $libobj" - $run eval "echo timestamp > \$libobj" || exit $? - else - # Move the .lo from within objdir - $show "$mv $libobj $lo_libobj" - if $run $mv $libobj $lo_libobj; then : - else - error=$? - $run $rm $removelist - exit $error - fi - fi - fi - - # Unlock the critical section if it was locked - if test "$need_locks" != no; then - $run $rm "$lockfile" - fi - - exit 0 - ;; - - # libtool link mode - link | relink) - modename="$modename: link" - case $host in - *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*) - # It is impossible to link a dll without this setting, and - # we shouldn't force the makefile maintainer to figure out - # which system we are compiling for in order to pass an extra - # flag for every libtool invokation. - # allow_undefined=no - - # FIXME: Unfortunately, there are problems with the above when trying - # to make a dll which has undefined symbols, in which case not - # even a static library is built. For now, we need to specify - # -no-undefined on the libtool link line when we can be certain - # that all symbols are satisfied, otherwise we get a static library. - allow_undefined=yes - ;; - *) - allow_undefined=yes - ;; - esac - libtool_args="$nonopt" - compile_command="$nonopt" - finalize_command="$nonopt" - - compile_rpath= - finalize_rpath= - compile_shlibpath= - finalize_shlibpath= - convenience= - old_convenience= - deplibs= - old_deplibs= - compiler_flags= - linker_flags= - dllsearchpath= - lib_search_path=`pwd` - inst_prefix_dir= - - avoid_version=no - dlfiles= - dlprefiles= - dlself=no - export_dynamic=no - export_symbols= - export_symbols_regex= - generated= - libobjs= - ltlibs= - module=no - no_install=no - objs= - prefer_static_libs=no - preload=no - prev= - prevarg= - release= - rpath= - xrpath= - perm_rpath= - temp_rpath= - thread_safe=no - vinfo= - - # We need to know -static, to get the right output filenames. - for arg - do - case $arg in - -all-static | -static) - if test "X$arg" = "X-all-static"; then - if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then - $echo "$modename: warning: complete static linking is impossible in this configuration" 1>&2 - fi - if test -n "$link_static_flag"; then - dlopen_self=$dlopen_self_static - fi - else - if test -z "$pic_flag" && test -n "$link_static_flag"; then - dlopen_self=$dlopen_self_static - fi - fi - build_libtool_libs=no - build_old_libs=yes - prefer_static_libs=yes - break - ;; - esac - done - - # See if our shared archives depend on static archives. - test -n "$old_archive_from_new_cmds" && build_old_libs=yes - - # Go through the arguments, transforming them on the way. - while test $# -gt 0; do - arg="$1" - shift - case $arg in - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") - qarg=\"`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`\" ### testsuite: skip nested quoting test - ;; - *) qarg=$arg ;; - esac - libtool_args="$libtool_args $qarg" - - # If the previous option needs an argument, assign it. - if test -n "$prev"; then - case $prev in - output) - compile_command="$compile_command @OUTPUT@" - finalize_command="$finalize_command @OUTPUT@" - ;; - esac - - case $prev in - dlfiles|dlprefiles) - if test "$preload" = no; then - # Add the symbol object into the linking commands. - compile_command="$compile_command @SYMFILE@" - finalize_command="$finalize_command @SYMFILE@" - preload=yes - fi - case $arg in - *.la | *.lo) ;; # We handle these cases below. - force) - if test "$dlself" = no; then - dlself=needless - export_dynamic=yes - fi - prev= - continue - ;; - self) - if test "$prev" = dlprefiles; then - dlself=yes - elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then - dlself=yes - else - dlself=needless - export_dynamic=yes - fi - prev= - continue - ;; - *) - if test "$prev" = dlfiles; then - dlfiles="$dlfiles $arg" - else - dlprefiles="$dlprefiles $arg" - fi - prev= - continue - ;; - esac - ;; - expsyms) - export_symbols="$arg" - if test ! -f "$arg"; then - $echo "$modename: symbol file \`$arg' does not exist" - exit 1 - fi - prev= - continue - ;; - expsyms_regex) - export_symbols_regex="$arg" - prev= - continue - ;; - inst_prefix) - inst_prefix_dir="$arg" - prev= - continue - ;; - release) - release="-$arg" - prev= - continue - ;; - rpath | xrpath) - # We need an absolute path. - case $arg in - [\\/]* | [A-Za-z]:[\\/]*) ;; - *) - $echo "$modename: only absolute run-paths are allowed" 1>&2 - exit 1 - ;; - esac - if test "$prev" = rpath; then - case "$rpath " in - *" $arg "*) ;; - *) rpath="$rpath $arg" ;; - esac - else - case "$xrpath " in - *" $arg "*) ;; - *) xrpath="$xrpath $arg" ;; - esac - fi - prev= - continue - ;; - xcompiler) - compiler_flags="$compiler_flags $qarg" - prev= - compile_command="$compile_command $qarg" - finalize_command="$finalize_command $qarg" - continue - ;; - xlinker) - linker_flags="$linker_flags $qarg" - compiler_flags="$compiler_flags $wl$qarg" - prev= - compile_command="$compile_command $wl$qarg" - finalize_command="$finalize_command $wl$qarg" - continue - ;; - *) - eval "$prev=\"\$arg\"" - prev= - continue - ;; - esac - fi # test -n $prev - - prevarg="$arg" - - case $arg in - -all-static) - if test -n "$link_static_flag"; then - compile_command="$compile_command $link_static_flag" - finalize_command="$finalize_command $link_static_flag" - fi - continue - ;; - - -allow-undefined) - # FIXME: remove this flag sometime in the future. - $echo "$modename: \`-allow-undefined' is deprecated because it is the default" 1>&2 - continue - ;; - - -avoid-version) - avoid_version=yes - continue - ;; - - -dlopen) - prev=dlfiles - continue - ;; - - -dlpreopen) - prev=dlprefiles - continue - ;; - - -export-dynamic) - export_dynamic=yes - continue - ;; - - -export-symbols | -export-symbols-regex) - if test -n "$export_symbols" || test -n "$export_symbols_regex"; then - $echo "$modename: more than one -exported-symbols argument is not allowed" - exit 1 - fi - if test "X$arg" = "X-export-symbols"; then - prev=expsyms - else - prev=expsyms_regex - fi - continue - ;; - - -inst-prefix-dir) - prev=inst_prefix - continue - ;; - - # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* - # so, if we see these flags be careful not to treat them like -L - -L[A-Z][A-Z]*:*) - case $with_gcc/$host in - no/*-*-irix* | no/*-*-nonstopux*) - compile_command="$compile_command $arg" - finalize_command="$finalize_command $arg" - ;; - esac - continue - ;; - - -L*) - dir=`$echo "X$arg" | $Xsed -e 's/^-L//'` - # We need an absolute path. - case $dir in - [\\/]* | [A-Za-z]:[\\/]*) ;; - *) - absdir=`cd "$dir" && pwd` - if test -z "$absdir"; then - $echo "$modename: cannot determine absolute directory name of \`$dir'" 1>&2 - exit 1 - fi - dir="$absdir" - ;; - esac - case "$deplibs " in - *" -L$dir "*) ;; - *) - deplibs="$deplibs -L$dir" - lib_search_path="$lib_search_path $dir" - ;; - esac - case $host in - *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*) - case :$dllsearchpath: in - *":$dir:"*) ;; - *) dllsearchpath="$dllsearchpath:$dir";; - esac - ;; - esac - continue - ;; - - -l*) - if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then - case $host in - *-*-cygwin* | *-*-pw32* | *-*-beos*) - # These systems don't actually have a C or math library (as such) - continue - ;; - *-*-mingw* | *-*-os2*) - # These systems don't actually have a C library (as such) - test "X$arg" = "X-lc" && continue - ;; - *-*-openbsd* | *-*-freebsd*) - # Do not include libc due to us having libc/libc_r. - test "X$arg" = "X-lc" && continue - ;; - esac - elif test "X$arg" = "X-lc_r"; then - case $host in - *-*-openbsd* | *-*-freebsd*) - # Do not include libc_r directly, use -pthread flag. - continue - ;; - esac - fi - deplibs="$deplibs $arg" - continue - ;; - - -module) - module=yes - continue - ;; - - -no-fast-install) - fast_install=no - continue - ;; - - -no-install) - case $host in - *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*) - # The PATH hackery in wrapper scripts is required on Windows - # in order for the loader to find any dlls it needs. - $echo "$modename: warning: \`-no-install' is ignored for $host" 1>&2 - $echo "$modename: warning: assuming \`-no-fast-install' instead" 1>&2 - fast_install=no - ;; - *) no_install=yes ;; - esac - continue - ;; - - -no-undefined) - allow_undefined=no - continue - ;; - - -o) prev=output ;; - - -release) - prev=release - continue - ;; - - -rpath) - prev=rpath - continue - ;; - - -R) - prev=xrpath - continue - ;; - - -R*) - dir=`$echo "X$arg" | $Xsed -e 's/^-R//'` - # We need an absolute path. - case $dir in - [\\/]* | [A-Za-z]:[\\/]*) ;; - *) - $echo "$modename: only absolute run-paths are allowed" 1>&2 - exit 1 - ;; - esac - case "$xrpath " in - *" $dir "*) ;; - *) xrpath="$xrpath $dir" ;; - esac - continue - ;; - - -static) - # The effects of -static are defined in a previous loop. - # We used to do the same as -all-static on platforms that - # didn't have a PIC flag, but the assumption that the effects - # would be equivalent was wrong. It would break on at least - # Digital Unix and AIX. - continue - ;; - - -thread-safe) - thread_safe=yes - continue - ;; - - -version-info) - prev=vinfo - continue - ;; - - -Wc,*) - args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wc,//'` - arg= - save_ifs="$IFS"; IFS=',' - for flag in $args; do - IFS="$save_ifs" - case $flag in - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") - flag="\"$flag\"" - ;; - esac - arg="$arg $wl$flag" - compiler_flags="$compiler_flags $flag" - done - IFS="$save_ifs" - arg=`$echo "X$arg" | $Xsed -e "s/^ //"` - ;; - - -Wl,*) - args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wl,//'` - arg= - save_ifs="$IFS"; IFS=',' - for flag in $args; do - IFS="$save_ifs" - case $flag in - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") - flag="\"$flag\"" - ;; - esac - arg="$arg $wl$flag" - compiler_flags="$compiler_flags $wl$flag" - linker_flags="$linker_flags $flag" - done - IFS="$save_ifs" - arg=`$echo "X$arg" | $Xsed -e "s/^ //"` - ;; - - -Xcompiler) - prev=xcompiler - continue - ;; - - -Xlinker) - prev=xlinker - continue - ;; - - # Some other compiler flag. - -* | +*) - # Unknown arguments in both finalize_command and compile_command need - # to be aesthetically quoted because they are evaled later. - arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` - case $arg in - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") - arg="\"$arg\"" - ;; - esac - ;; - - *.lo | *.$objext) - # A library or standard object. - if test "$prev" = dlfiles; then - # This file was specified with -dlopen. - if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then - dlfiles="$dlfiles $arg" - prev= - continue - else - # If libtool objects are unsupported, then we need to preload. - prev=dlprefiles - fi - fi - - if test "$prev" = dlprefiles; then - # Preload the old-style object. - dlprefiles="$dlprefiles "`$echo "X$arg" | $Xsed -e "$lo2o"` - prev= - else - case $arg in - *.lo) libobjs="$libobjs $arg" ;; - *) objs="$objs $arg" ;; - esac - fi - ;; - - *.$libext) - # An archive. - deplibs="$deplibs $arg" - old_deplibs="$old_deplibs $arg" - continue - ;; - - *.la) - # A libtool-controlled library. - - if test "$prev" = dlfiles; then - # This library was specified with -dlopen. - dlfiles="$dlfiles $arg" - prev= - elif test "$prev" = dlprefiles; then - # The library was specified with -dlpreopen. - dlprefiles="$dlprefiles $arg" - prev= - else - deplibs="$deplibs $arg" - fi - continue - ;; - - # Some other compiler argument. - *) - # Unknown arguments in both finalize_command and compile_command need - # to be aesthetically quoted because they are evaled later. - arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` - case $arg in - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") - arg="\"$arg\"" - ;; - esac - ;; - esac # arg - - # Now actually substitute the argument into the commands. - if test -n "$arg"; then - compile_command="$compile_command $arg" - finalize_command="$finalize_command $arg" - fi - done # argument parsing loop - - if test -n "$prev"; then - $echo "$modename: the \`$prevarg' option requires an argument" 1>&2 - $echo "$help" 1>&2 - exit 1 - fi - - if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then - eval arg=\"$export_dynamic_flag_spec\" - compile_command="$compile_command $arg" - finalize_command="$finalize_command $arg" - fi - - # calculate the name of the file, without its directory - outputname=`$echo "X$output" | $Xsed -e 's%^.*/%%'` - libobjs_save="$libobjs" - - if test -n "$shlibpath_var"; then - # get the directories listed in $shlibpath_var - eval shlib_search_path=\`\$echo \"X\${$shlibpath_var}\" \| \$Xsed -e \'s/:/ /g\'\` - else - shlib_search_path= - fi - eval sys_lib_search_path=\"$sys_lib_search_path_spec\" - eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" - - output_objdir=`$echo "X$output" | $Xsed -e 's%/[^/]*$%%'` - if test "X$output_objdir" = "X$output"; then - output_objdir="$objdir" - else - output_objdir="$output_objdir/$objdir" - fi - # Create the object directory. - if test ! -d $output_objdir; then - $show "$mkdir $output_objdir" - $run $mkdir $output_objdir - status=$? - if test $status -ne 0 && test ! -d $output_objdir; then - exit $status - fi - fi - - # Determine the type of output - case $output in - "") - $echo "$modename: you must specify an output file" 1>&2 - $echo "$help" 1>&2 - exit 1 - ;; - *.$libext) linkmode=oldlib ;; - *.lo | *.$objext) linkmode=obj ;; - *.la) linkmode=lib ;; - *) linkmode=prog ;; # Anything else should be a program. - esac - - specialdeplibs= - libs= - # Find all interdependent deplibs by searching for libraries - # that are linked more than once (e.g. -la -lb -la) - for deplib in $deplibs; do - if test "X$duplicate_deps" = "Xyes" ; then - case "$libs " in - *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; - esac - fi - libs="$libs $deplib" - done - deplibs= - newdependency_libs= - newlib_search_path= - need_relink=no # whether we're linking any uninstalled libtool libraries - notinst_deplibs= # not-installed libtool libraries - notinst_path= # paths that contain not-installed libtool libraries - case $linkmode in - lib) - passes="conv link" - for file in $dlfiles $dlprefiles; do - case $file in - *.la) ;; - *) - $echo "$modename: libraries can \`-dlopen' only libtool libraries: $file" 1>&2 - exit 1 - ;; - esac - done - ;; - prog) - compile_deplibs= - finalize_deplibs= - alldeplibs=no - newdlfiles= - newdlprefiles= - passes="conv scan dlopen dlpreopen link" - ;; - *) passes="conv" - ;; - esac - for pass in $passes; do - if test $linkmode = prog; then - # Determine which files to process - case $pass in - dlopen) - libs="$dlfiles" - save_deplibs="$deplibs" # Collect dlpreopened libraries - deplibs= - ;; - dlpreopen) libs="$dlprefiles" ;; - link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; - esac - fi - for deplib in $libs; do - lib= - found=no - case $deplib in - -l*) - if test $linkmode = oldlib && test $linkmode = obj; then - $echo "$modename: warning: \`-l' is ignored for archives/objects: $deplib" 1>&2 - continue - fi - if test $pass = conv; then - deplibs="$deplib $deplibs" - continue - fi - name=`$echo "X$deplib" | $Xsed -e 's/^-l//'` - for searchdir in $newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path; do - # Search the libtool library - lib="$searchdir/lib${name}.la" - if test -f "$lib"; then - found=yes - break - fi - done - if test "$found" != yes; then - # deplib doesn't seem to be a libtool library - if test "$linkmode,$pass" = "prog,link"; then - compile_deplibs="$deplib $compile_deplibs" - finalize_deplibs="$deplib $finalize_deplibs" - else - deplibs="$deplib $deplibs" - test $linkmode = lib && newdependency_libs="$deplib $newdependency_libs" - fi - continue - fi - ;; # -l - -L*) - case $linkmode in - lib) - deplibs="$deplib $deplibs" - test $pass = conv && continue - newdependency_libs="$deplib $newdependency_libs" - newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'` - ;; - prog) - if test $pass = conv; then - deplibs="$deplib $deplibs" - continue - fi - if test $pass = scan; then - deplibs="$deplib $deplibs" - newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'` - else - compile_deplibs="$deplib $compile_deplibs" - finalize_deplibs="$deplib $finalize_deplibs" - fi - ;; - *) - $echo "$modename: warning: \`-L' is ignored for archives/objects: $deplib" 1>&2 - ;; - esac # linkmode - continue - ;; # -L - -R*) - if test $pass = link; then - dir=`$echo "X$deplib" | $Xsed -e 's/^-R//'` - # Make sure the xrpath contains only unique directories. - case "$xrpath " in - *" $dir "*) ;; - *) xrpath="$xrpath $dir" ;; - esac - fi - deplibs="$deplib $deplibs" - continue - ;; - *.la) lib="$deplib" ;; - *.$libext) - if test $pass = conv; then - deplibs="$deplib $deplibs" - continue - fi - case $linkmode in - lib) - if test "$deplibs_check_method" != pass_all; then - echo - echo "*** Warning: Trying to link with static lib archive $deplib." - echo "*** I have the capability to make that library automatically link in when" - echo "*** you link to this library. But I can only do this if you have a" - echo "*** shared version of the library, which you do not appear to have" - echo "*** because the file extensions .$libext of this argument makes me believe" - echo "*** that it is just a static archive that I should not used here." - else - echo - echo "*** Warning: Linking the shared library $output against the" - echo "*** static library $deplib is not portable!" - deplibs="$deplib $deplibs" - fi - continue - ;; - prog) - if test $pass != link; then - deplibs="$deplib $deplibs" - else - compile_deplibs="$deplib $compile_deplibs" - finalize_deplibs="$deplib $finalize_deplibs" - fi - continue - ;; - esac # linkmode - ;; # *.$libext - *.lo | *.$objext) - if test $pass = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then - # If there is no dlopen support or we're linking statically, - # we need to preload. - newdlprefiles="$newdlprefiles $deplib" - compile_deplibs="$deplib $compile_deplibs" - finalize_deplibs="$deplib $finalize_deplibs" - else - newdlfiles="$newdlfiles $deplib" - fi - continue - ;; - %DEPLIBS%) - alldeplibs=yes - continue - ;; - esac # case $deplib - if test $found = yes || test -f "$lib"; then : - else - $echo "$modename: cannot find the library \`$lib'" 1>&2 - exit 1 - fi - - # Check to see that this really is a libtool archive. - if (${SED} -e '2q' $lib | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : - else - $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 - exit 1 - fi - - ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'` - test "X$ladir" = "X$lib" && ladir="." - - dlname= - dlopen= - dlpreopen= - libdir= - library_names= - old_library= - # If the library was installed with an old release of libtool, - # it will not redefine variable installed. - installed=yes - - # Read the .la file - case $lib in - */* | *\\*) . $lib ;; - *) . ./$lib ;; - esac - - if test "$linkmode,$pass" = "lib,link" || - test "$linkmode,$pass" = "prog,scan" || - { test $linkmode = oldlib && test $linkmode = obj; }; then - # Add dl[pre]opened files of deplib - test -n "$dlopen" && dlfiles="$dlfiles $dlopen" - test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen" - fi - - if test $pass = conv; then - # Only check for convenience libraries - deplibs="$lib $deplibs" - if test -z "$libdir"; then - if test -z "$old_library"; then - $echo "$modename: cannot find name of link library for \`$lib'" 1>&2 - exit 1 - fi - # It is a libtool convenience library, so add in its objects. - convenience="$convenience $ladir/$objdir/$old_library" - old_convenience="$old_convenience $ladir/$objdir/$old_library" - tmp_libs= - for deplib in $dependency_libs; do - deplibs="$deplib $deplibs" - if test "X$duplicate_deps" = "Xyes" ; then - case "$tmp_libs " in - *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; - esac - fi - tmp_libs="$tmp_libs $deplib" - done - elif test $linkmode != prog && test $linkmode != lib; then - $echo "$modename: \`$lib' is not a convenience library" 1>&2 - exit 1 - fi - continue - fi # $pass = conv - - # Get the name of the library we link against. - linklib= - for l in $old_library $library_names; do - linklib="$l" - done - if test -z "$linklib"; then - $echo "$modename: cannot find name of link library for \`$lib'" 1>&2 - exit 1 - fi - - # This library was specified with -dlopen. - if test $pass = dlopen; then - if test -z "$libdir"; then - $echo "$modename: cannot -dlopen a convenience library: \`$lib'" 1>&2 - exit 1 - fi - if test -z "$dlname" || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then - # If there is no dlname, no dlopen support or we're linking - # statically, we need to preload. - dlprefiles="$dlprefiles $lib" - else - newdlfiles="$newdlfiles $lib" - fi - continue - fi # $pass = dlopen - - # We need an absolute path. - case $ladir in - [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;; - *) - abs_ladir=`cd "$ladir" && pwd` - if test -z "$abs_ladir"; then - $echo "$modename: warning: cannot determine absolute directory name of \`$ladir'" 1>&2 - $echo "$modename: passing it literally to the linker, although it might fail" 1>&2 - abs_ladir="$ladir" - fi - ;; - esac - laname=`$echo "X$lib" | $Xsed -e 's%^.*/%%'` - - # Find the relevant object directory and library name. - if test "X$installed" = Xyes; then - if test ! -f "$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then - $echo "$modename: warning: library \`$lib' was moved." 1>&2 - dir="$ladir" - absdir="$abs_ladir" - libdir="$abs_ladir" - else - dir="$libdir" - absdir="$libdir" - fi - else - dir="$ladir/$objdir" - absdir="$abs_ladir/$objdir" - # Remove this search path later - notinst_path="$notinst_path $abs_ladir" - fi # $installed = yes - name=`$echo "X$laname" | $Xsed -e 's/\.la$//' -e 's/^lib//'` - - # This library was specified with -dlpreopen. - if test $pass = dlpreopen; then - if test -z "$libdir"; then - $echo "$modename: cannot -dlpreopen a convenience library: \`$lib'" 1>&2 - exit 1 - fi - # Prefer using a static library (so that no silly _DYNAMIC symbols - # are required to link). - if test -n "$old_library"; then - newdlprefiles="$newdlprefiles $dir/$old_library" - # Otherwise, use the dlname, so that lt_dlopen finds it. - elif test -n "$dlname"; then - newdlprefiles="$newdlprefiles $dir/$dlname" - else - newdlprefiles="$newdlprefiles $dir/$linklib" - fi - fi # $pass = dlpreopen - - if test -z "$libdir"; then - # Link the convenience library - if test $linkmode = lib; then - deplibs="$dir/$old_library $deplibs" - elif test "$linkmode,$pass" = "prog,link"; then - compile_deplibs="$dir/$old_library $compile_deplibs" - finalize_deplibs="$dir/$old_library $finalize_deplibs" - else - deplibs="$lib $deplibs" - fi - continue - fi - - if test $linkmode = prog && test $pass != link; then - newlib_search_path="$newlib_search_path $ladir" - deplibs="$lib $deplibs" - - linkalldeplibs=no - if test "$link_all_deplibs" != no || test -z "$library_names" || - test "$build_libtool_libs" = no; then - linkalldeplibs=yes - fi - - tmp_libs= - for deplib in $dependency_libs; do - case $deplib in - -L*) newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`;; ### testsuite: skip nested quoting test - esac - # Need to link against all dependency_libs? - if test $linkalldeplibs = yes; then - deplibs="$deplib $deplibs" - else - # Need to hardcode shared library paths - # or/and link against static libraries - newdependency_libs="$deplib $newdependency_libs" - fi - if test "X$duplicate_deps" = "Xyes" ; then - case "$tmp_libs " in - *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; - esac - fi - tmp_libs="$tmp_libs $deplib" - done # for deplib - continue - fi # $linkmode = prog... - - link_static=no # Whether the deplib will be linked statically - if test -n "$library_names" && - { test "$prefer_static_libs" = no || test -z "$old_library"; }; then - # Link against this shared library - - if test "$linkmode,$pass" = "prog,link" || - { test $linkmode = lib && test $hardcode_into_libs = yes; }; then - # Hardcode the library path. - # Skip directories that are in the system default run-time - # search path. - case " $sys_lib_dlsearch_path " in - *" $absdir "*) ;; - *) - case "$compile_rpath " in - *" $absdir "*) ;; - *) compile_rpath="$compile_rpath $absdir" - esac - ;; - esac - case " $sys_lib_dlsearch_path " in - *" $libdir "*) ;; - *) - case "$finalize_rpath " in - *" $libdir "*) ;; - *) finalize_rpath="$finalize_rpath $libdir" - esac - ;; - esac - if test $linkmode = prog; then - # We need to hardcode the library path - if test -n "$shlibpath_var"; then - # Make sure the rpath contains only unique directories. - case "$temp_rpath " in - *" $dir "*) ;; - *" $absdir "*) ;; - *) temp_rpath="$temp_rpath $dir" ;; - esac - fi - fi - fi # $linkmode,$pass = prog,link... - - if test "$alldeplibs" = yes && - { test "$deplibs_check_method" = pass_all || - { test "$build_libtool_libs" = yes && - test -n "$library_names"; }; }; then - # We only need to search for static libraries - continue - fi - - if test "$installed" = no; then - notinst_deplibs="$notinst_deplibs $lib" - need_relink=yes - fi - - if test -n "$old_archive_from_expsyms_cmds"; then - # figure out the soname - set dummy $library_names - realname="$2" - shift; shift - libname=`eval \\$echo \"$libname_spec\"` - # use dlname if we got it. it's perfectly good, no? - if test -n "$dlname"; then - soname="$dlname" - elif test -n "$soname_spec"; then - # bleh windows - case $host in - *cygwin*) - major=`expr $current - $age` - versuffix="-$major" - ;; - esac - eval soname=\"$soname_spec\" - else - soname="$realname" - fi - - # Make a new name for the extract_expsyms_cmds to use - soroot="$soname" - soname=`echo $soroot | ${SED} -e 's/^.*\///'` - newlib="libimp-`echo $soname | ${SED} 's/^lib//;s/\.dll$//'`.a" - - # If the library has no export list, then create one now - if test -f "$output_objdir/$soname-def"; then : - else - $show "extracting exported symbol list from \`$soname'" - save_ifs="$IFS"; IFS='~' - eval cmds=\"$extract_expsyms_cmds\" - for cmd in $cmds; do - IFS="$save_ifs" - $show "$cmd" - $run eval "$cmd" || exit $? - done - IFS="$save_ifs" - fi - - # Create $newlib - if test -f "$output_objdir/$newlib"; then :; else - $show "generating import library for \`$soname'" - save_ifs="$IFS"; IFS='~' - eval cmds=\"$old_archive_from_expsyms_cmds\" - for cmd in $cmds; do - IFS="$save_ifs" - $show "$cmd" - $run eval "$cmd" || exit $? - done - IFS="$save_ifs" - fi - # make sure the library variables are pointing to the new library - dir=$output_objdir - linklib=$newlib - fi # test -n $old_archive_from_expsyms_cmds - - if test $linkmode = prog || test "$mode" != relink; then - add_shlibpath= - add_dir= - add= - lib_linked=yes - case $hardcode_action in - immediate | unsupported) - if test "$hardcode_direct" = no; then - add="$dir/$linklib" - elif test "$hardcode_minus_L" = no; then - case $host in - *-*-sunos*) add_shlibpath="$dir" ;; - esac - add_dir="-L$dir" - add="-l$name" - elif test "$hardcode_shlibpath_var" = no; then - add_shlibpath="$dir" - add="-l$name" - else - lib_linked=no - fi - ;; - relink) - if test "$hardcode_direct" = yes; then - add="$dir/$linklib" - elif test "$hardcode_minus_L" = yes; then - add_dir="-L$dir" - # Try looking first in the location we're being installed to. - if test -n "$inst_prefix_dir"; then - case "$libdir" in - [\/]*) - add_dir="-L$inst_prefix_dir$libdir $add_dir" - ;; - esac - fi - add="-l$name" - elif test "$hardcode_shlibpath_var" = yes; then - add_shlibpath="$dir" - add="-l$name" - else - lib_linked=no - fi - ;; - *) lib_linked=no ;; - esac - - if test "$lib_linked" != yes; then - $echo "$modename: configuration error: unsupported hardcode properties" - exit 1 - fi - - if test -n "$add_shlibpath"; then - case :$compile_shlibpath: in - *":$add_shlibpath:"*) ;; - *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;; - esac - fi - if test $linkmode = prog; then - test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" - test -n "$add" && compile_deplibs="$add $compile_deplibs" - else - test -n "$add_dir" && deplibs="$add_dir $deplibs" - test -n "$add" && deplibs="$add $deplibs" - if test "$hardcode_direct" != yes && \ - test "$hardcode_minus_L" != yes && \ - test "$hardcode_shlibpath_var" = yes; then - case :$finalize_shlibpath: in - *":$libdir:"*) ;; - *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;; - esac - fi - fi - fi - - if test $linkmode = prog || test "$mode" = relink; then - add_shlibpath= - add_dir= - add= - # Finalize command for both is simple: just hardcode it. - if test "$hardcode_direct" = yes; then - add="$libdir/$linklib" - elif test "$hardcode_minus_L" = yes; then - add_dir="-L$libdir" - add="-l$name" - elif test "$hardcode_shlibpath_var" = yes; then - case :$finalize_shlibpath: in - *":$libdir:"*) ;; - *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;; - esac - add="-l$name" - else - # We cannot seem to hardcode it, guess we'll fake it. - add_dir="-L$libdir" - # Try looking first in the location we're being installed to. - if test -n "$inst_prefix_dir"; then - case "$libdir" in - [\/]*) - add_dir="-L$inst_prefix_dir$libdir $add_dir" - ;; - esac - fi - add="-l$name" - fi - - if test $linkmode = prog; then - test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" - test -n "$add" && finalize_deplibs="$add $finalize_deplibs" - else - test -n "$add_dir" && deplibs="$add_dir $deplibs" - test -n "$add" && deplibs="$add $deplibs" - fi - fi - elif test $linkmode = prog; then - if test "$alldeplibs" = yes && - { test "$deplibs_check_method" = pass_all || - { test "$build_libtool_libs" = yes && - test -n "$library_names"; }; }; then - # We only need to search for static libraries - continue - fi - - # Try to link the static library - # Here we assume that one of hardcode_direct or hardcode_minus_L - # is not unsupported. This is valid on all known static and - # shared platforms. - if test "$hardcode_direct" != unsupported; then - test -n "$old_library" && linklib="$old_library" - compile_deplibs="$dir/$linklib $compile_deplibs" - finalize_deplibs="$dir/$linklib $finalize_deplibs" - else - compile_deplibs="-l$name -L$dir $compile_deplibs" - finalize_deplibs="-l$name -L$dir $finalize_deplibs" - fi - elif test "$build_libtool_libs" = yes; then - # Not a shared library - if test "$deplibs_check_method" != pass_all; then - # We're trying link a shared library against a static one - # but the system doesn't support it. - - # Just print a warning and add the library to dependency_libs so - # that the program can be linked against the static library. - echo - echo "*** Warning: This system can not link to static lib archive $lib." - echo "*** I have the capability to make that library automatically link in when" - echo "*** you link to this library. But I can only do this if you have a" - echo "*** shared version of the library, which you do not appear to have." - if test "$module" = yes; then - echo "*** But as you try to build a module library, libtool will still create " - echo "*** a static module, that should work as long as the dlopening application" - echo "*** is linked with the -dlopen flag to resolve symbols at runtime." - if test -z "$global_symbol_pipe"; then - echo - echo "*** However, this would only work if libtool was able to extract symbol" - echo "*** lists from a program, using \`nm' or equivalent, but libtool could" - echo "*** not find such a program. So, this module is probably useless." - echo "*** \`nm' from GNU binutils and a full rebuild may help." - fi - if test "$build_old_libs" = no; then - build_libtool_libs=module - build_old_libs=yes - else - build_libtool_libs=no - fi - fi - else - convenience="$convenience $dir/$old_library" - old_convenience="$old_convenience $dir/$old_library" - deplibs="$dir/$old_library $deplibs" - link_static=yes - fi - fi # link shared/static library? - - if test $linkmode = lib; then - if test -n "$dependency_libs" && - { test $hardcode_into_libs != yes || test $build_old_libs = yes || - test $link_static = yes; }; then - # Extract -R from dependency_libs - temp_deplibs= - for libdir in $dependency_libs; do - case $libdir in - -R*) temp_xrpath=`$echo "X$libdir" | $Xsed -e 's/^-R//'` - case " $xrpath " in - *" $temp_xrpath "*) ;; - *) xrpath="$xrpath $temp_xrpath";; - esac;; - *) temp_deplibs="$temp_deplibs $libdir";; - esac - done - dependency_libs="$temp_deplibs" - fi - - newlib_search_path="$newlib_search_path $absdir" - # Link against this library - test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs" - # ... and its dependency_libs - tmp_libs= - for deplib in $dependency_libs; do - newdependency_libs="$deplib $newdependency_libs" - if test "X$duplicate_deps" = "Xyes" ; then - case "$tmp_libs " in - *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; - esac - fi - tmp_libs="$tmp_libs $deplib" - done - - if test $link_all_deplibs != no; then - # Add the search paths of all dependency libraries - for deplib in $dependency_libs; do - case $deplib in - -L*) path="$deplib" ;; - *.la) - dir=`$echo "X$deplib" | $Xsed -e 's%/[^/]*$%%'` - test "X$dir" = "X$deplib" && dir="." - # We need an absolute path. - case $dir in - [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;; - *) - absdir=`cd "$dir" && pwd` - if test -z "$absdir"; then - $echo "$modename: warning: cannot determine absolute directory name of \`$dir'" 1>&2 - absdir="$dir" - fi - ;; - esac - if grep "^installed=no" $deplib > /dev/null; then - path="-L$absdir/$objdir" - else - eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` - if test -z "$libdir"; then - $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2 - exit 1 - fi - if test "$absdir" != "$libdir"; then - $echo "$modename: warning: \`$deplib' seems to be moved" 1>&2 - fi - path="-L$absdir" - fi - ;; - *) continue ;; - esac - case " $deplibs " in - *" $path "*) ;; - *) deplibs="$deplibs $path" ;; - esac - done - fi # link_all_deplibs != no - fi # linkmode = lib - done # for deplib in $libs - if test $pass = dlpreopen; then - # Link the dlpreopened libraries before other libraries - for deplib in $save_deplibs; do - deplibs="$deplib $deplibs" - done - fi - if test $pass != dlopen; then - test $pass != scan && dependency_libs="$newdependency_libs" - if test $pass != conv; then - # Make sure lib_search_path contains only unique directories. - lib_search_path= - for dir in $newlib_search_path; do - case "$lib_search_path " in - *" $dir "*) ;; - *) lib_search_path="$lib_search_path $dir" ;; - esac - done - newlib_search_path= - fi - - if test "$linkmode,$pass" != "prog,link"; then - vars="deplibs" - else - vars="compile_deplibs finalize_deplibs" - fi - for var in $vars dependency_libs; do - # Add libraries to $var in reverse order - eval tmp_libs=\"\$$var\" - new_libs= - for deplib in $tmp_libs; do - case $deplib in - -L*) new_libs="$deplib $new_libs" ;; - *) - case " $specialdeplibs " in - *" $deplib "*) new_libs="$deplib $new_libs" ;; - *) - case " $new_libs " in - *" $deplib "*) ;; - *) new_libs="$deplib $new_libs" ;; - esac - ;; - esac - ;; - esac - done - tmp_libs= - for deplib in $new_libs; do - case $deplib in - -L*) - case " $tmp_libs " in - *" $deplib "*) ;; - *) tmp_libs="$tmp_libs $deplib" ;; - esac - ;; - *) tmp_libs="$tmp_libs $deplib" ;; - esac - done - eval $var=\"$tmp_libs\" - done # for var - fi - if test "$pass" = "conv" && - { test "$linkmode" = "lib" || test "$linkmode" = "prog"; }; then - libs="$deplibs" # reset libs - deplibs= - fi - done # for pass - if test $linkmode = prog; then - dlfiles="$newdlfiles" - dlprefiles="$newdlprefiles" - fi - - case $linkmode in - oldlib) - if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then - $echo "$modename: warning: \`-dlopen' is ignored for archives" 1>&2 - fi - - if test -n "$rpath"; then - $echo "$modename: warning: \`-rpath' is ignored for archives" 1>&2 - fi - - if test -n "$xrpath"; then - $echo "$modename: warning: \`-R' is ignored for archives" 1>&2 - fi - - if test -n "$vinfo"; then - $echo "$modename: warning: \`-version-info' is ignored for archives" 1>&2 - fi - - if test -n "$release"; then - $echo "$modename: warning: \`-release' is ignored for archives" 1>&2 - fi - - if test -n "$export_symbols" || test -n "$export_symbols_regex"; then - $echo "$modename: warning: \`-export-symbols' is ignored for archives" 1>&2 - fi - - # Now set the variables for building old libraries. - build_libtool_libs=no - oldlibs="$output" - objs="$objs$old_deplibs" - ;; - - lib) - # Make sure we only generate libraries of the form `libNAME.la'. - case $outputname in - lib*) - name=`$echo "X$outputname" | $Xsed -e 's/\.la$//' -e 's/^lib//'` - eval libname=\"$libname_spec\" - ;; - *) - if test "$module" = no; then - $echo "$modename: libtool library \`$output' must begin with \`lib'" 1>&2 - $echo "$help" 1>&2 - exit 1 - fi - if test "$need_lib_prefix" != no; then - # Add the "lib" prefix for modules if required - name=`$echo "X$outputname" | $Xsed -e 's/\.la$//'` - eval libname=\"$libname_spec\" - else - libname=`$echo "X$outputname" | $Xsed -e 's/\.la$//'` - fi - ;; - esac - - if test -n "$objs"; then - if test "$deplibs_check_method" != pass_all; then - $echo "$modename: cannot build libtool library \`$output' from non-libtool objects on this host:$objs" 2>&1 - exit 1 - else - echo - echo "*** Warning: Linking the shared library $output against the non-libtool" - echo "*** objects $objs is not portable!" - libobjs="$libobjs $objs" - fi - fi - - if test "$dlself" != no; then - $echo "$modename: warning: \`-dlopen self' is ignored for libtool libraries" 1>&2 - fi - - set dummy $rpath - if test $# -gt 2; then - $echo "$modename: warning: ignoring multiple \`-rpath's for a libtool library" 1>&2 - fi - install_libdir="$2" - - oldlibs= - if test -z "$rpath"; then - if test "$build_libtool_libs" = yes; then - # Building a libtool convenience library. - libext=al - oldlibs="$output_objdir/$libname.$libext $oldlibs" - build_libtool_libs=convenience - build_old_libs=yes - fi - - if test -n "$vinfo"; then - $echo "$modename: warning: \`-version-info' is ignored for convenience libraries" 1>&2 - fi - - if test -n "$release"; then - $echo "$modename: warning: \`-release' is ignored for convenience libraries" 1>&2 - fi - else - - # Parse the version information argument. - save_ifs="$IFS"; IFS=':' - set dummy $vinfo 0 0 0 - IFS="$save_ifs" - - if test -n "$8"; then - $echo "$modename: too many parameters to \`-version-info'" 1>&2 - $echo "$help" 1>&2 - exit 1 - fi - - current="$2" - revision="$3" - age="$4" - - # Check that each of the things are valid numbers. - case $current in - 0 | [1-9] | [1-9][0-9] | [1-9][0-9][0-9]) ;; - *) - $echo "$modename: CURRENT \`$current' is not a nonnegative integer" 1>&2 - $echo "$modename: \`$vinfo' is not valid version information" 1>&2 - exit 1 - ;; - esac - - case $revision in - 0 | [1-9] | [1-9][0-9] | [1-9][0-9][0-9]) ;; - *) - $echo "$modename: REVISION \`$revision' is not a nonnegative integer" 1>&2 - $echo "$modename: \`$vinfo' is not valid version information" 1>&2 - exit 1 - ;; - esac - - case $age in - 0 | [1-9] | [1-9][0-9] | [1-9][0-9][0-9]) ;; - *) - $echo "$modename: AGE \`$age' is not a nonnegative integer" 1>&2 - $echo "$modename: \`$vinfo' is not valid version information" 1>&2 - exit 1 - ;; - esac - - if test $age -gt $current; then - $echo "$modename: AGE \`$age' is greater than the current interface number \`$current'" 1>&2 - $echo "$modename: \`$vinfo' is not valid version information" 1>&2 - exit 1 - fi - - # Calculate the version variables. - major= - versuffix= - verstring= - case $version_type in - none) ;; - - darwin) - # Like Linux, but with the current version available in - # verstring for coding it into the library header - major=.`expr $current - $age` - versuffix="$major.$age.$revision" - # Darwin ld doesn't like 0 for these options... - minor_current=`expr $current + 1` - verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" - ;; - - freebsd-aout) - major=".$current" - versuffix=".$current.$revision"; - ;; - - freebsd-elf) - major=".$current" - versuffix=".$current"; - ;; - - irix | nonstopux) - major=`expr $current - $age + 1` - - case $version_type in - nonstopux) verstring_prefix=nonstopux ;; - *) verstring_prefix=sgi ;; - esac - verstring="$verstring_prefix$major.$revision" - - # Add in all the interfaces that we are compatible with. - loop=$revision - while test $loop != 0; do - iface=`expr $revision - $loop` - loop=`expr $loop - 1` - verstring="$verstring_prefix$major.$iface:$verstring" - done - - # Before this point, $major must not contain `.'. - major=.$major - versuffix="$major.$revision" - ;; - - linux) - major=.`expr $current - $age` - versuffix="$major.$age.$revision" - ;; - - osf) - major=.`expr $current - $age` - versuffix=".$current.$age.$revision" - verstring="$current.$age.$revision" - - # Add in all the interfaces that we are compatible with. - loop=$age - while test $loop != 0; do - iface=`expr $current - $loop` - loop=`expr $loop - 1` - verstring="$verstring:${iface}.0" - done - - # Make executables depend on our current version. - verstring="$verstring:${current}.0" - ;; - - sunos) - major=".$current" - versuffix=".$current.$revision" - ;; - - windows) - # Use '-' rather than '.', since we only want one - # extension on DOS 8.3 filesystems. - major=`expr $current - $age` - versuffix="-$major" - ;; - - *) - $echo "$modename: unknown library version type \`$version_type'" 1>&2 - echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2 - exit 1 - ;; - esac - - # Clear the version info if we defaulted, and they specified a release. - if test -z "$vinfo" && test -n "$release"; then - major= - verstring="0.0" - case $version_type in - darwin) - # we can't check for "0.0" in archive_cmds due to quoting - # problems, so we reset it completely - verstring="" - ;; - *) - verstring="0.0" - ;; - esac - if test "$need_version" = no; then - versuffix= - else - versuffix=".0.0" - fi - fi - - # Remove version info from name if versioning should be avoided - if test "$avoid_version" = yes && test "$need_version" = no; then - major= - versuffix= - verstring="" - fi - - # Check to see if the archive will have undefined symbols. - if test "$allow_undefined" = yes; then - if test "$allow_undefined_flag" = unsupported; then - $echo "$modename: warning: undefined symbols not allowed in $host shared libraries" 1>&2 - build_libtool_libs=no - build_old_libs=yes - fi - else - # Don't allow undefined symbols. - allow_undefined_flag="$no_undefined_flag" - fi - fi - - if test "$mode" != relink; then - # Remove our outputs. - $show "${rm}r $output_objdir/$outputname $output_objdir/$libname.* $output_objdir/${libname}${release}.*" - $run ${rm}r $output_objdir/$outputname $output_objdir/$libname.* $output_objdir/${libname}${release}.* - fi - - # Now set the variables for building old libraries. - if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then - oldlibs="$oldlibs $output_objdir/$libname.$libext" - - # Transform .lo files to .o files. - oldobjs="$objs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e "$lo2o" | $NL2SP` - fi - - # Eliminate all temporary directories. - for path in $notinst_path; do - lib_search_path=`echo "$lib_search_path " | ${SED} -e 's% $path % %g'` - deplibs=`echo "$deplibs " | ${SED} -e 's% -L$path % %g'` - dependency_libs=`echo "$dependency_libs " | ${SED} -e 's% -L$path % %g'` - done - - if test -n "$xrpath"; then - # If the user specified any rpath flags, then add them. - temp_xrpath= - for libdir in $xrpath; do - temp_xrpath="$temp_xrpath -R$libdir" - case "$finalize_rpath " in - *" $libdir "*) ;; - *) finalize_rpath="$finalize_rpath $libdir" ;; - esac - done - if test $hardcode_into_libs != yes || test $build_old_libs = yes; then - dependency_libs="$temp_xrpath $dependency_libs" - fi - fi - - # Make sure dlfiles contains only unique files that won't be dlpreopened - old_dlfiles="$dlfiles" - dlfiles= - for lib in $old_dlfiles; do - case " $dlprefiles $dlfiles " in - *" $lib "*) ;; - *) dlfiles="$dlfiles $lib" ;; - esac - done - - # Make sure dlprefiles contains only unique files - old_dlprefiles="$dlprefiles" - dlprefiles= - for lib in $old_dlprefiles; do - case "$dlprefiles " in - *" $lib "*) ;; - *) dlprefiles="$dlprefiles $lib" ;; - esac - done - - if test "$build_libtool_libs" = yes; then - if test -n "$rpath"; then - case $host in - *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos*) - # these systems don't actually have a c library (as such)! - ;; - *-*-rhapsody* | *-*-darwin1.[012]) - # Rhapsody C library is in the System framework - deplibs="$deplibs -framework System" - ;; - *-*-netbsd*) - # Don't link with libc until the a.out ld.so is fixed. - ;; - *-*-openbsd* | *-*-freebsd*) - # Do not include libc due to us having libc/libc_r. - ;; - *) - # Add libc to deplibs on all other systems if necessary. - if test $build_libtool_need_lc = "yes"; then - deplibs="$deplibs -lc" - fi - ;; - esac - fi - - # Transform deplibs into only deplibs that can be linked in shared. - name_save=$name - libname_save=$libname - release_save=$release - versuffix_save=$versuffix - major_save=$major - # I'm not sure if I'm treating the release correctly. I think - # release should show up in the -l (ie -lgmp5) so we don't want to - # add it in twice. Is that correct? - release="" - versuffix="" - major="" - newdeplibs= - droppeddeps=no - case $deplibs_check_method in - pass_all) - # Don't check for shared/static. Everything works. - # This might be a little naive. We might want to check - # whether the library exists or not. But this is on - # osf3 & osf4 and I'm not really sure... Just - # implementing what was already the behaviour. - newdeplibs=$deplibs - ;; - test_compile) - # This code stresses the "libraries are programs" paradigm to its - # limits. Maybe even breaks it. We compile a program, linking it - # against the deplibs as a proxy for the library. Then we can check - # whether they linked in statically or dynamically with ldd. - $rm conftest.c - cat > conftest.c </dev/null` - for potent_lib in $potential_libs; do - # Follow soft links. - if ls -lLd "$potent_lib" 2>/dev/null \ - | grep " -> " >/dev/null; then - continue - fi - # The statement above tries to avoid entering an - # endless loop below, in case of cyclic links. - # We might still enter an endless loop, since a link - # loop can be closed while we follow links, - # but so what? - potlib="$potent_lib" - while test -h "$potlib" 2>/dev/null; do - potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'` - case $potliblink in - [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";; - *) potlib=`$echo "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";; - esac - done - if eval $file_magic_cmd \"\$potlib\" 2>/dev/null \ - | ${SED} 10q \ - | egrep "$file_magic_regex" > /dev/null; then - newdeplibs="$newdeplibs $a_deplib" - a_deplib="" - break 2 - fi - done - done - if test -n "$a_deplib" ; then - droppeddeps=yes - echo - echo "*** Warning: linker path does not have real file for library $a_deplib." - echo "*** I have the capability to make that library automatically link in when" - echo "*** you link to this library. But I can only do this if you have a" - echo "*** shared version of the library, which you do not appear to have" - echo "*** because I did check the linker path looking for a file starting" - if test -z "$potlib" ; then - echo "*** with $libname but no candidates were found. (...for file magic test)" - else - echo "*** with $libname and none of the candidates passed a file format test" - echo "*** using a file magic. Last file checked: $potlib" - fi - fi - else - # Add a -L argument. - newdeplibs="$newdeplibs $a_deplib" - fi - done # Gone through all deplibs. - ;; - match_pattern*) - set dummy $deplibs_check_method - match_pattern_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"` - for a_deplib in $deplibs; do - name="`expr $a_deplib : '-l\(.*\)'`" - # If $name is empty we are operating on a -L argument. - if test -n "$name" && test "$name" != "0"; then - libname=`eval \\$echo \"$libname_spec\"` - for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do - potential_libs=`ls $i/$libname[.-]* 2>/dev/null` - for potent_lib in $potential_libs; do - potlib="$potent_lib" # see symlink-check below in file_magic test - if eval echo \"$potent_lib\" 2>/dev/null \ - | ${SED} 10q \ - | egrep "$match_pattern_regex" > /dev/null; then - newdeplibs="$newdeplibs $a_deplib" - a_deplib="" - break 2 - fi - done - done - if test -n "$a_deplib" ; then - droppeddeps=yes - echo - echo "*** Warning: linker path does not have real file for library $a_deplib." - echo "*** I have the capability to make that library automatically link in when" - echo "*** you link to this library. But I can only do this if you have a" - echo "*** shared version of the library, which you do not appear to have" - echo "*** because I did check the linker path looking for a file starting" - if test -z "$potlib" ; then - echo "*** with $libname but no candidates were found. (...for regex pattern test)" - else - echo "*** with $libname and none of the candidates passed a file format test" - echo "*** using a regex pattern. Last file checked: $potlib" - fi - fi - else - # Add a -L argument. - newdeplibs="$newdeplibs $a_deplib" - fi - done # Gone through all deplibs. - ;; - none | unknown | *) - newdeplibs="" - if $echo "X $deplibs" | $Xsed -e 's/ -lc$//' \ - -e 's/ -[LR][^ ]*//g' -e 's/[ ]//g' | - grep . >/dev/null; then - echo - if test "X$deplibs_check_method" = "Xnone"; then - echo "*** Warning: inter-library dependencies are not supported in this platform." - else - echo "*** Warning: inter-library dependencies are not known to be supported." - fi - echo "*** All declared inter-library dependencies are being dropped." - droppeddeps=yes - fi - ;; - esac - versuffix=$versuffix_save - major=$major_save - release=$release_save - libname=$libname_save - name=$name_save - - case $host in - *-*-rhapsody* | *-*-darwin1.[012]) - # On Rhapsody replace the C library is the System framework - newdeplibs=`$echo "X $newdeplibs" | $Xsed -e 's/ -lc / -framework System /'` - ;; - esac - - if test "$droppeddeps" = yes; then - if test "$module" = yes; then - echo - echo "*** Warning: libtool could not satisfy all declared inter-library" - echo "*** dependencies of module $libname. Therefore, libtool will create" - echo "*** a static module, that should work as long as the dlopening" - echo "*** application is linked with the -dlopen flag." - if test -z "$global_symbol_pipe"; then - echo - echo "*** However, this would only work if libtool was able to extract symbol" - echo "*** lists from a program, using \`nm' or equivalent, but libtool could" - echo "*** not find such a program. So, this module is probably useless." - echo "*** \`nm' from GNU binutils and a full rebuild may help." - fi - if test "$build_old_libs" = no; then - oldlibs="$output_objdir/$libname.$libext" - build_libtool_libs=module - build_old_libs=yes - else - build_libtool_libs=no - fi - else - echo "*** The inter-library dependencies that have been dropped here will be" - echo "*** automatically added whenever a program is linked with this library" - echo "*** or is declared to -dlopen it." - - if test $allow_undefined = no; then - echo - echo "*** Since this library must not contain undefined symbols," - echo "*** because either the platform does not support them or" - echo "*** it was explicitly requested with -no-undefined," - echo "*** libtool will only create a static version of it." - if test "$build_old_libs" = no; then - oldlibs="$output_objdir/$libname.$libext" - build_libtool_libs=module - build_old_libs=yes - else - build_libtool_libs=no - fi - fi - fi - fi - # Done checking deplibs! - deplibs=$newdeplibs - fi - - # All the library-specific variables (install_libdir is set above). - library_names= - old_library= - dlname= - - # Test again, we may have decided not to build it any more - if test "$build_libtool_libs" = yes; then - if test $hardcode_into_libs = yes; then - # Hardcode the library paths - hardcode_libdirs= - dep_rpath= - rpath="$finalize_rpath" - test "$mode" != relink && rpath="$compile_rpath$rpath" - for libdir in $rpath; do - if test -n "$hardcode_libdir_flag_spec"; then - if test -n "$hardcode_libdir_separator"; then - if test -z "$hardcode_libdirs"; then - hardcode_libdirs="$libdir" - else - # Just accumulate the unique libdirs. - case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in - *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) - ;; - *) - hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" - ;; - esac - fi - else - eval flag=\"$hardcode_libdir_flag_spec\" - dep_rpath="$dep_rpath $flag" - fi - elif test -n "$runpath_var"; then - case "$perm_rpath " in - *" $libdir "*) ;; - *) perm_rpath="$perm_rpath $libdir" ;; - esac - fi - done - # Substitute the hardcoded libdirs into the rpath. - if test -n "$hardcode_libdir_separator" && - test -n "$hardcode_libdirs"; then - libdir="$hardcode_libdirs" - eval dep_rpath=\"$hardcode_libdir_flag_spec\" - fi - if test -n "$runpath_var" && test -n "$perm_rpath"; then - # We should set the runpath_var. - rpath= - for dir in $perm_rpath; do - rpath="$rpath$dir:" - done - eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" - fi - test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" - fi - - shlibpath="$finalize_shlibpath" - test "$mode" != relink && shlibpath="$compile_shlibpath$shlibpath" - if test -n "$shlibpath"; then - eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" - fi - - # Get the real and link names of the library. - eval library_names=\"$library_names_spec\" - set dummy $library_names - realname="$2" - shift; shift - - if test -n "$soname_spec"; then - eval soname=\"$soname_spec\" - else - soname="$realname" - fi - test -z "$dlname" && dlname=$soname - - lib="$output_objdir/$realname" - for link - do - linknames="$linknames $link" - done - - # Ensure that we have .o objects for linkers which dislike .lo - # (e.g. aix) in case we are running --disable-static - for obj in $libobjs; do - xdir=`$echo "X$obj" | $Xsed -e 's%/[^/]*$%%'` - if test "X$xdir" = "X$obj"; then - xdir="." - else - xdir="$xdir" - fi - baseobj=`$echo "X$obj" | $Xsed -e 's%^.*/%%'` - oldobj=`$echo "X$baseobj" | $Xsed -e "$lo2o"` - if test ! -f $xdir/$oldobj; then - $show "(cd $xdir && ${LN_S} $baseobj $oldobj)" - $run eval '(cd $xdir && ${LN_S} $baseobj $oldobj)' || exit $? - fi - done - - # Use standard objects if they are pic - test -z "$pic_flag" && libobjs=`$echo "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` - - # Prepare the list of exported symbols - if test -z "$export_symbols"; then - if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then - $show "generating symbol list for \`$libname.la'" - export_symbols="$output_objdir/$libname.exp" - $run $rm $export_symbols - eval cmds=\"$export_symbols_cmds\" - save_ifs="$IFS"; IFS='~' - for cmd in $cmds; do - IFS="$save_ifs" - $show "$cmd" - $run eval "$cmd" || exit $? - done - IFS="$save_ifs" - if test -n "$export_symbols_regex"; then - $show "egrep -e \"$export_symbols_regex\" \"$export_symbols\" > \"${export_symbols}T\"" - $run eval 'egrep -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' - $show "$mv \"${export_symbols}T\" \"$export_symbols\"" - $run eval '$mv "${export_symbols}T" "$export_symbols"' - fi - fi - fi - - if test -n "$export_symbols" && test -n "$include_expsyms"; then - $run eval '$echo "X$include_expsyms" | $SP2NL >> "$export_symbols"' - fi - - if test -n "$convenience"; then - if test -n "$whole_archive_flag_spec"; then - eval libobjs=\"\$libobjs $whole_archive_flag_spec\" - else - gentop="$output_objdir/${outputname}x" - $show "${rm}r $gentop" - $run ${rm}r "$gentop" - $show "mkdir $gentop" - $run mkdir "$gentop" - status=$? - if test $status -ne 0 && test ! -d "$gentop"; then - exit $status - fi - generated="$generated $gentop" - - for xlib in $convenience; do - # Extract the objects. - case $xlib in - [\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;; - *) xabs=`pwd`"/$xlib" ;; - esac - xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'` - xdir="$gentop/$xlib" - - $show "${rm}r $xdir" - $run ${rm}r "$xdir" - $show "mkdir $xdir" - $run mkdir "$xdir" - status=$? - if test $status -ne 0 && test ! -d "$xdir"; then - exit $status - fi - $show "(cd $xdir && $AR x $xabs)" - $run eval "(cd \$xdir && $AR x \$xabs)" || exit $? - - libobjs="$libobjs "`find $xdir -name \*.o -print -o -name \*.lo -print | $NL2SP` - done - fi - fi - - if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then - eval flag=\"$thread_safe_flag_spec\" - linker_flags="$linker_flags $flag" - fi - - # Make a backup of the uninstalled library when relinking - if test "$mode" = relink; then - $run eval '(cd $output_objdir && $rm ${realname}U && $mv $realname ${realname}U)' || exit $? - fi - - # Do each of the archive commands. - if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then - eval cmds=\"$archive_expsym_cmds\" - else - save_deplibs="$deplibs" - for conv in $convenience; do - tmp_deplibs= - for test_deplib in $deplibs; do - if test "$test_deplib" != "$conv"; then - tmp_deplibs="$tmp_deplibs $test_deplib" - fi - done - deplibs="$tmp_deplibs" - done - eval cmds=\"$archive_cmds\" - deplibs="$save_deplibs" - fi - save_ifs="$IFS"; IFS='~' - for cmd in $cmds; do - IFS="$save_ifs" - $show "$cmd" - $run eval "$cmd" || exit $? - done - IFS="$save_ifs" - - # Restore the uninstalled library and exit - if test "$mode" = relink; then - $run eval '(cd $output_objdir && $rm ${realname}T && $mv $realname ${realname}T && $mv "$realname"U $realname)' || exit $? - exit 0 - fi - - # Create links to the real library. - for linkname in $linknames; do - if test "$realname" != "$linkname"; then - $show "(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)" - $run eval '(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)' || exit $? - fi - done - - # If -module or -export-dynamic was specified, set the dlname. - if test "$module" = yes || test "$export_dynamic" = yes; then - # On all known operating systems, these are identical. - dlname="$soname" - fi - fi - ;; - - obj) - if test -n "$deplibs"; then - $echo "$modename: warning: \`-l' and \`-L' are ignored for objects" 1>&2 - fi - - if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then - $echo "$modename: warning: \`-dlopen' is ignored for objects" 1>&2 - fi - - if test -n "$rpath"; then - $echo "$modename: warning: \`-rpath' is ignored for objects" 1>&2 - fi - - if test -n "$xrpath"; then - $echo "$modename: warning: \`-R' is ignored for objects" 1>&2 - fi - - if test -n "$vinfo"; then - $echo "$modename: warning: \`-version-info' is ignored for objects" 1>&2 - fi - - if test -n "$release"; then - $echo "$modename: warning: \`-release' is ignored for objects" 1>&2 - fi - - case $output in - *.lo) - if test -n "$objs$old_deplibs"; then - $echo "$modename: cannot build library object \`$output' from non-libtool objects" 1>&2 - exit 1 - fi - libobj="$output" - obj=`$echo "X$output" | $Xsed -e "$lo2o"` - ;; - *) - libobj= - obj="$output" - ;; - esac - - # Delete the old objects. - $run $rm $obj $libobj - - # Objects from convenience libraries. This assumes - # single-version convenience libraries. Whenever we create - # different ones for PIC/non-PIC, this we'll have to duplicate - # the extraction. - reload_conv_objs= - gentop= - # reload_cmds runs $LD directly, so let us get rid of - # -Wl from whole_archive_flag_spec - wl= - - if test -n "$convenience"; then - if test -n "$whole_archive_flag_spec"; then - eval reload_conv_objs=\"\$reload_objs $whole_archive_flag_spec\" - else - gentop="$output_objdir/${obj}x" - $show "${rm}r $gentop" - $run ${rm}r "$gentop" - $show "mkdir $gentop" - $run mkdir "$gentop" - status=$? - if test $status -ne 0 && test ! -d "$gentop"; then - exit $status - fi - generated="$generated $gentop" - - for xlib in $convenience; do - # Extract the objects. - case $xlib in - [\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;; - *) xabs=`pwd`"/$xlib" ;; - esac - xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'` - xdir="$gentop/$xlib" - - $show "${rm}r $xdir" - $run ${rm}r "$xdir" - $show "mkdir $xdir" - $run mkdir "$xdir" - status=$? - if test $status -ne 0 && test ! -d "$xdir"; then - exit $status - fi - $show "(cd $xdir && $AR x $xabs)" - $run eval "(cd \$xdir && $AR x \$xabs)" || exit $? - - reload_conv_objs="$reload_objs "`find $xdir -name \*.o -print -o -name \*.lo -print | $NL2SP` - done - fi - fi - - # Create the old-style object. - reload_objs="$objs$old_deplibs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}$'/d' -e '/\.lib$/d' -e "$lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test - - output="$obj" - eval cmds=\"$reload_cmds\" - save_ifs="$IFS"; IFS='~' - for cmd in $cmds; do - IFS="$save_ifs" - $show "$cmd" - $run eval "$cmd" || exit $? - done - IFS="$save_ifs" - - # Exit if we aren't doing a library object file. - if test -z "$libobj"; then - if test -n "$gentop"; then - $show "${rm}r $gentop" - $run ${rm}r $gentop - fi - - exit 0 - fi - - if test "$build_libtool_libs" != yes; then - if test -n "$gentop"; then - $show "${rm}r $gentop" - $run ${rm}r $gentop - fi - - # Create an invalid libtool object if no PIC, so that we don't - # accidentally link it into a program. - $show "echo timestamp > $libobj" - $run eval "echo timestamp > $libobj" || exit $? - exit 0 - fi - - if test -n "$pic_flag" || test "$pic_mode" != default; then - # Only do commands if we really have different PIC objects. - reload_objs="$libobjs $reload_conv_objs" - output="$libobj" - eval cmds=\"$reload_cmds\" - save_ifs="$IFS"; IFS='~' - for cmd in $cmds; do - IFS="$save_ifs" - $show "$cmd" - $run eval "$cmd" || exit $? - done - IFS="$save_ifs" - else - # Just create a symlink. - $show $rm $libobj - $run $rm $libobj - xdir=`$echo "X$libobj" | $Xsed -e 's%/[^/]*$%%'` - if test "X$xdir" = "X$libobj"; then - xdir="." - else - xdir="$xdir" - fi - baseobj=`$echo "X$libobj" | $Xsed -e 's%^.*/%%'` - oldobj=`$echo "X$baseobj" | $Xsed -e "$lo2o"` - $show "(cd $xdir && $LN_S $oldobj $baseobj)" - $run eval '(cd $xdir && $LN_S $oldobj $baseobj)' || exit $? - fi - - if test -n "$gentop"; then - $show "${rm}r $gentop" - $run ${rm}r $gentop - fi - - exit 0 - ;; - - prog) - case $host in - *cygwin*) output=`echo $output | ${SED} -e 's,.exe$,,;s,$,.exe,'` ;; - esac - if test -n "$vinfo"; then - $echo "$modename: warning: \`-version-info' is ignored for programs" 1>&2 - fi - - if test -n "$release"; then - $echo "$modename: warning: \`-release' is ignored for programs" 1>&2 - fi - - if test "$preload" = yes; then - if test "$dlopen_support" = unknown && test "$dlopen_self" = unknown && - test "$dlopen_self_static" = unknown; then - $echo "$modename: warning: \`AC_LIBTOOL_DLOPEN' not used. Assuming no dlopen support." - fi - fi - - case $host in - *-*-rhapsody* | *-*-darwin1.[012]) - # On Rhapsody replace the C library is the System framework - compile_deplibs=`$echo "X $compile_deplibs" | $Xsed -e 's/ -lc / -framework System /'` - finalize_deplibs=`$echo "X $finalize_deplibs" | $Xsed -e 's/ -lc / -framework System /'` - case $host in - *darwin*) - # Don't allow lazy linking, it breaks C++ global constructors - compile_command="$compile_command ${wl}-bind_at_load" - finalize_command="$finalize_command ${wl}-bind_at_load" - ;; - esac - ;; - esac - - compile_command="$compile_command $compile_deplibs" - finalize_command="$finalize_command $finalize_deplibs" - - if test -n "$rpath$xrpath"; then - # If the user specified any rpath flags, then add them. - for libdir in $rpath $xrpath; do - # This is the magic to use -rpath. - case "$finalize_rpath " in - *" $libdir "*) ;; - *) finalize_rpath="$finalize_rpath $libdir" ;; - esac - done - fi - - # Now hardcode the library paths - rpath= - hardcode_libdirs= - for libdir in $compile_rpath $finalize_rpath; do - if test -n "$hardcode_libdir_flag_spec"; then - if test -n "$hardcode_libdir_separator"; then - if test -z "$hardcode_libdirs"; then - hardcode_libdirs="$libdir" - else - # Just accumulate the unique libdirs. - case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in - *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) - ;; - *) - hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" - ;; - esac - fi - else - eval flag=\"$hardcode_libdir_flag_spec\" - rpath="$rpath $flag" - fi - elif test -n "$runpath_var"; then - case "$perm_rpath " in - *" $libdir "*) ;; - *) perm_rpath="$perm_rpath $libdir" ;; - esac - fi - case $host in - *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*) - case :$dllsearchpath: in - *":$libdir:"*) ;; - *) dllsearchpath="$dllsearchpath:$libdir";; - esac - ;; - esac - done - # Substitute the hardcoded libdirs into the rpath. - if test -n "$hardcode_libdir_separator" && - test -n "$hardcode_libdirs"; then - libdir="$hardcode_libdirs" - eval rpath=\" $hardcode_libdir_flag_spec\" - fi - compile_rpath="$rpath" - - rpath= - hardcode_libdirs= - for libdir in $finalize_rpath; do - if test -n "$hardcode_libdir_flag_spec"; then - if test -n "$hardcode_libdir_separator"; then - if test -z "$hardcode_libdirs"; then - hardcode_libdirs="$libdir" - else - # Just accumulate the unique libdirs. - case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in - *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) - ;; - *) - hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" - ;; - esac - fi - else - eval flag=\"$hardcode_libdir_flag_spec\" - rpath="$rpath $flag" - fi - elif test -n "$runpath_var"; then - case "$finalize_perm_rpath " in - *" $libdir "*) ;; - *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;; - esac - fi - done - # Substitute the hardcoded libdirs into the rpath. - if test -n "$hardcode_libdir_separator" && - test -n "$hardcode_libdirs"; then - libdir="$hardcode_libdirs" - eval rpath=\" $hardcode_libdir_flag_spec\" - fi - finalize_rpath="$rpath" - - if test -n "$libobjs" && test "$build_old_libs" = yes; then - # Transform all the library objects into standard objects. - compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` - finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` - fi - - dlsyms= - if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then - if test -n "$NM" && test -n "$global_symbol_pipe"; then - dlsyms="${outputname}S.c" - else - $echo "$modename: not configured to extract global symbols from dlpreopened files" 1>&2 - fi - fi - - if test -n "$dlsyms"; then - case $dlsyms in - "") ;; - *.c) - # Discover the nlist of each of the dlfiles. - nlist="$output_objdir/${outputname}.nm" - - $show "$rm $nlist ${nlist}S ${nlist}T" - $run $rm "$nlist" "${nlist}S" "${nlist}T" - - # Parse the name list into a source file. - $show "creating $output_objdir/$dlsyms" - - test -z "$run" && $echo > "$output_objdir/$dlsyms" "\ -/* $dlsyms - symbol resolution table for \`$outputname' dlsym emulation. */ -/* Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP */ - -#ifdef __cplusplus -extern \"C\" { -#endif - -/* Prevent the only kind of declaration conflicts we can make. */ -#define lt_preloaded_symbols some_other_symbol - -/* External symbol declarations for the compiler. */\ -" - - if test "$dlself" = yes; then - $show "generating symbol list for \`$output'" - - test -z "$run" && $echo ': @PROGRAM@ ' > "$nlist" - - # Add our own program objects to the symbol list. - progfiles=`$echo "X$objs$old_deplibs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` - for arg in $progfiles; do - $show "extracting global C symbols from \`$arg'" - $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'" - done - - if test -n "$exclude_expsyms"; then - $run eval 'egrep -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' - $run eval '$mv "$nlist"T "$nlist"' - fi - - if test -n "$export_symbols_regex"; then - $run eval 'egrep -e "$export_symbols_regex" "$nlist" > "$nlist"T' - $run eval '$mv "$nlist"T "$nlist"' - fi - - # Prepare the list of exported symbols - if test -z "$export_symbols"; then - export_symbols="$output_objdir/$output.exp" - $run $rm $export_symbols - $run eval "${SED} -n -e '/^: @PROGRAM@$/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' - else - $run eval "${SED} -e 's/\([][.*^$]\)/\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$output.exp"' - $run eval 'grep -f "$output_objdir/$output.exp" < "$nlist" > "$nlist"T' - $run eval 'mv "$nlist"T "$nlist"' - fi - fi - - for arg in $dlprefiles; do - $show "extracting global C symbols from \`$arg'" - name=`echo "$arg" | ${SED} -e 's%^.*/%%'` - $run eval 'echo ": $name " >> "$nlist"' - $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'" - done - - if test -z "$run"; then - # Make sure we have at least an empty file. - test -f "$nlist" || : > "$nlist" - - if test -n "$exclude_expsyms"; then - egrep -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T - $mv "$nlist"T "$nlist" - fi - - # Try sorting and uniquifying the output. - if grep -v "^: " < "$nlist" | - if sort -k 3 /dev/null 2>&1; then - sort -k 3 - else - sort +2 - fi | - uniq > "$nlist"S; then - : - else - grep -v "^: " < "$nlist" > "$nlist"S - fi - - if test -f "$nlist"S; then - eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$dlsyms"' - else - echo '/* NONE */' >> "$output_objdir/$dlsyms" - fi - - $echo >> "$output_objdir/$dlsyms" "\ - -#undef lt_preloaded_symbols - -#if defined (__STDC__) && __STDC__ -# define lt_ptr void * -#else -# define lt_ptr char * -# define const -#endif - -/* The mapping between symbol names and symbols. */ -const struct { - const char *name; - lt_ptr address; -} -lt_preloaded_symbols[] = -{\ -" - - eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$dlsyms" - - $echo >> "$output_objdir/$dlsyms" "\ - {0, (lt_ptr) 0} -}; - -/* This works around a problem in FreeBSD linker */ -#ifdef FREEBSD_WORKAROUND -static const void *lt_preloaded_setup() { - return lt_preloaded_symbols; -} -#endif - -#ifdef __cplusplus -} -#endif\ -" - fi - - pic_flag_for_symtable= - case $host in - # compiling the symbol table file with pic_flag works around - # a FreeBSD bug that causes programs to crash when -lm is - # linked before any other PIC object. But we must not use - # pic_flag when linking with -static. The problem exists in - # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. - *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) - case "$compile_command " in - *" -static "*) ;; - *) pic_flag_for_symtable=" $pic_flag -DPIC -DFREEBSD_WORKAROUND";; - esac;; - *-*-hpux*) - case "$compile_command " in - *" -static "*) ;; - *) pic_flag_for_symtable=" $pic_flag -DPIC";; - esac - esac - - # Now compile the dynamic symbol file. - $show "(cd $output_objdir && $CC -c$no_builtin_flag$pic_flag_for_symtable \"$dlsyms\")" - $run eval '(cd $output_objdir && $CC -c$no_builtin_flag$pic_flag_for_symtable "$dlsyms")' || exit $? - - # Clean up the generated files. - $show "$rm $output_objdir/$dlsyms $nlist ${nlist}S ${nlist}T" - $run $rm "$output_objdir/$dlsyms" "$nlist" "${nlist}S" "${nlist}T" - - # Transform the symbol file into the correct name. - compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"` - finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"` - ;; - *) - $echo "$modename: unknown suffix for \`$dlsyms'" 1>&2 - exit 1 - ;; - esac - else - # We keep going just in case the user didn't refer to - # lt_preloaded_symbols. The linker will fail if global_symbol_pipe - # really was required. - - # Nullify the symbol file. - compile_command=`$echo "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"` - finalize_command=`$echo "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"` - fi - - if test $need_relink = no || test "$build_libtool_libs" != yes; then - # Replace the output file specification. - compile_command=`$echo "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'` - link_command="$compile_command$compile_rpath" - - # We have no uninstalled library dependencies, so finalize right now. - $show "$link_command" - $run eval "$link_command" - status=$? - - # Delete the generated files. - if test -n "$dlsyms"; then - $show "$rm $output_objdir/${outputname}S.${objext}" - $run $rm "$output_objdir/${outputname}S.${objext}" - fi - - exit $status - fi - - if test -n "$shlibpath_var"; then - # We should set the shlibpath_var - rpath= - for dir in $temp_rpath; do - case $dir in - [\\/]* | [A-Za-z]:[\\/]*) - # Absolute path. - rpath="$rpath$dir:" - ;; - *) - # Relative path: add a thisdir entry. - rpath="$rpath\$thisdir/$dir:" - ;; - esac - done - temp_rpath="$rpath" - fi - - if test -n "$compile_shlibpath$finalize_shlibpath"; then - compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" - fi - if test -n "$finalize_shlibpath"; then - finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" - fi - - compile_var= - finalize_var= - if test -n "$runpath_var"; then - if test -n "$perm_rpath"; then - # We should set the runpath_var. - rpath= - for dir in $perm_rpath; do - rpath="$rpath$dir:" - done - compile_var="$runpath_var=\"$rpath\$$runpath_var\" " - fi - if test -n "$finalize_perm_rpath"; then - # We should set the runpath_var. - rpath= - for dir in $finalize_perm_rpath; do - rpath="$rpath$dir:" - done - finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " - fi - fi - - if test "$no_install" = yes; then - # We don't need to create a wrapper script. - link_command="$compile_var$compile_command$compile_rpath" - # Replace the output file specification. - link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'` - # Delete the old output file. - $run $rm $output - # Link the executable and exit - $show "$link_command" - $run eval "$link_command" || exit $? - exit 0 - fi - - if test "$hardcode_action" = relink; then - # Fast installation is not supported - link_command="$compile_var$compile_command$compile_rpath" - relink_command="$finalize_var$finalize_command$finalize_rpath" - - $echo "$modename: warning: this platform does not like uninstalled shared libraries" 1>&2 - $echo "$modename: \`$output' will be relinked during installation" 1>&2 - else - if test "$fast_install" != no; then - link_command="$finalize_var$compile_command$finalize_rpath" - if test "$fast_install" = yes; then - relink_command=`$echo "X$compile_var$compile_command$compile_rpath" | $Xsed -e 's%@OUTPUT@%\$progdir/\$file%g'` - else - # fast_install is set to needless - relink_command= - fi - else - link_command="$compile_var$compile_command$compile_rpath" - relink_command="$finalize_var$finalize_command$finalize_rpath" - fi - fi - - # Replace the output file specification. - link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` - - # Delete the old output files. - $run $rm $output $output_objdir/$outputname $output_objdir/lt-$outputname - - $show "$link_command" - $run eval "$link_command" || exit $? - - # Now create the wrapper script. - $show "creating $output" - - # Quote the relink command for shipping. - if test -n "$relink_command"; then - # Preserve any variables that may affect compiler behavior - for var in $variables_saved_for_relink; do - if eval test -z \"\${$var+set}\"; then - relink_command="{ test -z \"\${$var+set}\" || unset $var || { $var=; export $var; }; }; $relink_command" - elif eval var_value=\$$var; test -z "$var_value"; then - relink_command="$var=; export $var; $relink_command" - else - var_value=`$echo "X$var_value" | $Xsed -e "$sed_quote_subst"` - relink_command="$var=\"$var_value\"; export $var; $relink_command" - fi - done - relink_command="(cd `pwd`; $relink_command)" - relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"` - fi - - # Quote $echo for shipping. - if test "X$echo" = "X$SHELL $0 --fallback-echo"; then - case $0 in - [\\/]* | [A-Za-z]:[\\/]*) qecho="$SHELL $0 --fallback-echo";; - *) qecho="$SHELL `pwd`/$0 --fallback-echo";; - esac - qecho=`$echo "X$qecho" | $Xsed -e "$sed_quote_subst"` - else - qecho=`$echo "X$echo" | $Xsed -e "$sed_quote_subst"` - fi - - # Only actually do things if our run command is non-null. - if test -z "$run"; then - # win32 will think the script is a binary if it has - # a .exe suffix, so we strip it off here. - case $output in - *.exe) output=`echo $output|${SED} 's,.exe$,,'` ;; - esac - # test for cygwin because mv fails w/o .exe extensions - case $host in - *cygwin*) exeext=.exe ;; - *) exeext= ;; - esac - $rm $output - trap "$rm $output; exit 1" 1 2 15 - - $echo > $output "\ -#! $SHELL - -# $output - temporary wrapper script for $objdir/$outputname -# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP -# -# The $output program cannot be directly executed until all the libtool -# libraries that it depends on are installed. -# -# This wrapper script should never be moved out of the build directory. -# If it is, it will not operate correctly. - -# Sed substitution that helps us do robust quoting. It backslashifies -# metacharacters that are still active within double-quoted strings. -Xsed="${SED}"' -e 1s/^X//' -sed_quote_subst='$sed_quote_subst' - -# The HP-UX ksh and POSIX shell print the target directory to stdout -# if CDPATH is set. -if test \"\${CDPATH+set}\" = set; then CDPATH=:; export CDPATH; fi - -relink_command=\"$relink_command\" - -# This environment variable determines our operation mode. -if test \"\$libtool_install_magic\" = \"$magic\"; then - # install mode needs the following variable: - notinst_deplibs='$notinst_deplibs' -else - # When we are sourced in execute mode, \$file and \$echo are already set. - if test \"\$libtool_execute_magic\" != \"$magic\"; then - echo=\"$qecho\" - file=\"\$0\" - # Make sure echo works. - if test \"X\$1\" = X--no-reexec; then - # Discard the --no-reexec flag, and continue. - shift - elif test \"X\`(\$echo '\t') 2>/dev/null\`\" = 'X\t'; then - # Yippee, \$echo works! - : - else - # Restart under the correct shell, and then maybe \$echo will work. - exec $SHELL \"\$0\" --no-reexec \${1+\"\$@\"} - fi - fi\ -" - $echo >> $output "\ - - # Find the directory that this script lives in. - thisdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*$%%'\` - test \"x\$thisdir\" = \"x\$file\" && thisdir=. - - # Follow symbolic links until we get to the real thisdir. - file=\`ls -ld \"\$file\" | ${SED} -n 's/.*-> //p'\` - while test -n \"\$file\"; do - destdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\` - - # If there was a directory component, then change thisdir. - if test \"x\$destdir\" != \"x\$file\"; then - case \"\$destdir\" in - [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; - *) thisdir=\"\$thisdir/\$destdir\" ;; - esac - fi - - file=\`\$echo \"X\$file\" | \$Xsed -e 's%^.*/%%'\` - file=\`ls -ld \"\$thisdir/\$file\" | ${SED} -n 's/.*-> //p'\` - done - - # Try to get the absolute directory name. - absdir=\`cd \"\$thisdir\" && pwd\` - test -n \"\$absdir\" && thisdir=\"\$absdir\" -" - - if test "$fast_install" = yes; then - echo >> $output "\ - program=lt-'$outputname'$exeext - progdir=\"\$thisdir/$objdir\" - - if test ! -f \"\$progdir/\$program\" || \\ - { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\ - test \"X\$file\" != \"X\$progdir/\$program\"; }; then - - file=\"\$\$-\$program\" - - if test ! -d \"\$progdir\"; then - $mkdir \"\$progdir\" - else - $rm \"\$progdir/\$file\" - fi" - - echo >> $output "\ - - # relink executable if necessary - if test -n \"\$relink_command\"; then - if relink_command_output=\`eval \$relink_command 2>&1\`; then : - else - $echo \"\$relink_command_output\" >&2 - $rm \"\$progdir/\$file\" - exit 1 - fi - fi - - $mv \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || - { $rm \"\$progdir/\$program\"; - $mv \"\$progdir/\$file\" \"\$progdir/\$program\"; } - $rm \"\$progdir/\$file\" - fi" - else - echo >> $output "\ - program='$outputname' - progdir=\"\$thisdir/$objdir\" -" - fi - - echo >> $output "\ - - if test -f \"\$progdir/\$program\"; then" - - # Export our shlibpath_var if we have one. - if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then - $echo >> $output "\ - # Add our own library path to $shlibpath_var - $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" - - # Some systems cannot cope with colon-terminated $shlibpath_var - # The second colon is a workaround for a bug in BeOS R4 ${SED} - $shlibpath_var=\`\$echo \"X\$$shlibpath_var\" | \$Xsed -e 's/::*\$//'\` - - export $shlibpath_var -" - fi - - # fixup the dll searchpath if we need to. - if test -n "$dllsearchpath"; then - $echo >> $output "\ - # Add the dll search path components to the executable PATH - PATH=$dllsearchpath:\$PATH -" - fi - - $echo >> $output "\ - if test \"\$libtool_execute_magic\" != \"$magic\"; then - # Run the actual program with our arguments. -" - case $host in - # win32 systems need to use the prog path for dll - # lookup to work - *-*-cygwin* | *-*-pw32*) - $echo >> $output "\ - exec \$progdir/\$program \${1+\"\$@\"} -" - ;; - - # Backslashes separate directories on plain windows - *-*-mingw | *-*-os2*) - $echo >> $output "\ - exec \$progdir\\\\\$program \${1+\"\$@\"} -" - ;; - - *) - $echo >> $output "\ - # Export the path to the program. - PATH=\"\$progdir:\$PATH\" - export PATH - - exec \$program \${1+\"\$@\"} -" - ;; - esac - $echo >> $output "\ - \$echo \"\$0: cannot exec \$program \${1+\"\$@\"}\" - exit 1 - fi - else - # The program doesn't exist. - \$echo \"\$0: error: \$progdir/\$program does not exist\" 1>&2 - \$echo \"This script is just a wrapper for \$program.\" 1>&2 - echo \"See the $PACKAGE documentation for more information.\" 1>&2 - exit 1 - fi -fi\ -" - chmod +x $output - fi - exit 0 - ;; - esac - - # See if we need to build an old-fashioned archive. - for oldlib in $oldlibs; do - - if test "$build_libtool_libs" = convenience; then - oldobjs="$libobjs_save" - addlibs="$convenience" - build_libtool_libs=no - else - if test "$build_libtool_libs" = module; then - oldobjs="$libobjs_save" - build_libtool_libs=no - else - oldobjs="$objs$old_deplibs "`$echo "X$libobjs_save" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e '/\.lib$/d' -e "$lo2o" | $NL2SP` - fi - addlibs="$old_convenience" - fi - - if test -n "$addlibs"; then - gentop="$output_objdir/${outputname}x" - $show "${rm}r $gentop" - $run ${rm}r "$gentop" - $show "mkdir $gentop" - $run mkdir "$gentop" - status=$? - if test $status -ne 0 && test ! -d "$gentop"; then - exit $status - fi - generated="$generated $gentop" - - # Add in members from convenience archives. - for xlib in $addlibs; do - # Extract the objects. - case $xlib in - [\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;; - *) xabs=`pwd`"/$xlib" ;; - esac - xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'` - xdir="$gentop/$xlib" - - $show "${rm}r $xdir" - $run ${rm}r "$xdir" - $show "mkdir $xdir" - $run mkdir "$xdir" - status=$? - if test $status -ne 0 && test ! -d "$xdir"; then - exit $status - fi - $show "(cd $xdir && $AR x $xabs)" - $run eval "(cd \$xdir && $AR x \$xabs)" || exit $? - - oldobjs="$oldobjs "`find $xdir -name \*.${objext} -print -o -name \*.lo -print | $NL2SP` - done - fi - - # Do each command in the archive commands. - if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then - eval cmds=\"$old_archive_from_new_cmds\" - else - # Ensure that we have .o objects in place in case we decided - # not to build a shared library, and have fallen back to building - # static libs even though --disable-static was passed! - for oldobj in $oldobjs; do - if test ! -f $oldobj; then - xdir=`$echo "X$oldobj" | $Xsed -e 's%/[^/]*$%%'` - if test "X$xdir" = "X$oldobj"; then - xdir="." - else - xdir="$xdir" - fi - baseobj=`$echo "X$oldobj" | $Xsed -e 's%^.*/%%'` - obj=`$echo "X$baseobj" | $Xsed -e "$o2lo"` - $show "(cd $xdir && ${LN_S} $obj $baseobj)" - $run eval '(cd $xdir && ${LN_S} $obj $baseobj)' || exit $? - fi - done - - eval cmds=\"$old_archive_cmds\" - fi - save_ifs="$IFS"; IFS='~' - for cmd in $cmds; do - IFS="$save_ifs" - $show "$cmd" - $run eval "$cmd" || exit $? - done - IFS="$save_ifs" - done - - if test -n "$generated"; then - $show "${rm}r$generated" - $run ${rm}r$generated - fi - - # Now create the libtool archive. - case $output in - *.la) - old_library= - test "$build_old_libs" = yes && old_library="$libname.$libext" - $show "creating $output" - - # Preserve any variables that may affect compiler behavior - for var in $variables_saved_for_relink; do - if eval test -z \"\${$var+set}\"; then - relink_command="{ test -z \"\${$var+set}\" || unset $var || { $var=; export $var; }; }; $relink_command" - elif eval var_value=\$$var; test -z "$var_value"; then - relink_command="$var=; export $var; $relink_command" - else - var_value=`$echo "X$var_value" | $Xsed -e "$sed_quote_subst"` - relink_command="$var=\"$var_value\"; export $var; $relink_command" - fi - done - # Quote the link command for shipping. - relink_command="(cd `pwd`; $SHELL $0 --mode=relink $libtool_args @inst_prefix_dir@)" - relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"` - - # Only create the output if not a dry run. - if test -z "$run"; then - for installed in no yes; do - if test "$installed" = yes; then - if test -z "$install_libdir"; then - break - fi - output="$output_objdir/$outputname"i - # Replace all uninstalled libtool libraries with the installed ones - newdependency_libs= - for deplib in $dependency_libs; do - case $deplib in - *.la) - name=`$echo "X$deplib" | $Xsed -e 's%^.*/%%'` - eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` - if test -z "$libdir"; then - $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2 - exit 1 - fi - newdependency_libs="$newdependency_libs $libdir/$name" - ;; - *) newdependency_libs="$newdependency_libs $deplib" ;; - esac - done - dependency_libs="$newdependency_libs" - newdlfiles= - for lib in $dlfiles; do - name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'` - eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` - if test -z "$libdir"; then - $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 - exit 1 - fi - newdlfiles="$newdlfiles $libdir/$name" - done - dlfiles="$newdlfiles" - newdlprefiles= - for lib in $dlprefiles; do - name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'` - eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` - if test -z "$libdir"; then - $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 - exit 1 - fi - newdlprefiles="$newdlprefiles $libdir/$name" - done - dlprefiles="$newdlprefiles" - fi - $rm $output - # place dlname in correct position for cygwin - tdlname=$dlname - case $host,$output,$installed,$module,$dlname in - *cygwin*,*lai,yes,no,*.dll) tdlname=../bin/$dlname ;; - esac - $echo > $output "\ -# $outputname - a libtool library file -# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP -# -# Please DO NOT delete this file! -# It is necessary for linking the library. - -# The name that we can dlopen(3). -dlname='$tdlname' - -# Names of this library. -library_names='$library_names' - -# The name of the static archive. -old_library='$old_library' - -# Libraries that this one depends upon. -dependency_libs='$dependency_libs' - -# Version information for $libname. -current=$current -age=$age -revision=$revision - -# Is this an already installed library? -installed=$installed - -# Files to dlopen/dlpreopen -dlopen='$dlfiles' -dlpreopen='$dlprefiles' - -# Directory that this library needs to be installed in: -libdir='$install_libdir'" - if test "$installed" = no && test $need_relink = yes; then - $echo >> $output "\ -relink_command=\"$relink_command\"" - fi - done - fi - - # Do a symbolic link so that the libtool archive can be found in - # LD_LIBRARY_PATH before the program is installed. - $show "(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)" - $run eval '(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)' || exit $? - ;; - esac - exit 0 - ;; - - # libtool install mode - install) - modename="$modename: install" - - # There may be an optional sh(1) argument at the beginning of - # install_prog (especially on Windows NT). - if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh || - # Allow the use of GNU shtool's install command. - $echo "X$nonopt" | $Xsed | grep shtool > /dev/null; then - # Aesthetically quote it. - arg=`$echo "X$nonopt" | $Xsed -e "$sed_quote_subst"` - case $arg in - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) - arg="\"$arg\"" - ;; - esac - install_prog="$arg " - arg="$1" - shift - else - install_prog= - arg="$nonopt" - fi - - # The real first argument should be the name of the installation program. - # Aesthetically quote it. - arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` - case $arg in - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) - arg="\"$arg\"" - ;; - esac - install_prog="$install_prog$arg" - - # We need to accept at least all the BSD install flags. - dest= - files= - opts= - prev= - install_type= - isdir=no - stripme= - for arg - do - if test -n "$dest"; then - files="$files $dest" - dest="$arg" - continue - fi - - case $arg in - -d) isdir=yes ;; - -f) prev="-f" ;; - -g) prev="-g" ;; - -m) prev="-m" ;; - -o) prev="-o" ;; - -s) - stripme=" -s" - continue - ;; - -*) ;; - - *) - # If the previous option needed an argument, then skip it. - if test -n "$prev"; then - prev= - else - dest="$arg" - continue - fi - ;; - esac - - # Aesthetically quote the argument. - arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` - case $arg in - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) - arg="\"$arg\"" - ;; - esac - install_prog="$install_prog $arg" - done - - if test -z "$install_prog"; then - $echo "$modename: you must specify an install program" 1>&2 - $echo "$help" 1>&2 - exit 1 - fi - - if test -n "$prev"; then - $echo "$modename: the \`$prev' option requires an argument" 1>&2 - $echo "$help" 1>&2 - exit 1 - fi - - if test -z "$files"; then - if test -z "$dest"; then - $echo "$modename: no file or destination specified" 1>&2 - else - $echo "$modename: you must specify a destination" 1>&2 - fi - $echo "$help" 1>&2 - exit 1 - fi - - # Strip any trailing slash from the destination. - dest=`$echo "X$dest" | $Xsed -e 's%/$%%'` - - # Check to see that the destination is a directory. - test -d "$dest" && isdir=yes - if test "$isdir" = yes; then - destdir="$dest" - destname= - else - destdir=`$echo "X$dest" | $Xsed -e 's%/[^/]*$%%'` - test "X$destdir" = "X$dest" && destdir=. - destname=`$echo "X$dest" | $Xsed -e 's%^.*/%%'` - - # Not a directory, so check to see that there is only one file specified. - set dummy $files - if test $# -gt 2; then - $echo "$modename: \`$dest' is not a directory" 1>&2 - $echo "$help" 1>&2 - exit 1 - fi - fi - case $destdir in - [\\/]* | [A-Za-z]:[\\/]*) ;; - *) - for file in $files; do - case $file in - *.lo) ;; - *) - $echo "$modename: \`$destdir' must be an absolute directory name" 1>&2 - $echo "$help" 1>&2 - exit 1 - ;; - esac - done - ;; - esac - - # This variable tells wrapper scripts just to set variables rather - # than running their programs. - libtool_install_magic="$magic" - - staticlibs= - future_libdirs= - current_libdirs= - for file in $files; do - - # Do each installation. - case $file in - *.$libext) - # Do the static libraries later. - staticlibs="$staticlibs $file" - ;; - - *.la) - # Check to see that this really is a libtool archive. - if (${SED} -e '2q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : - else - $echo "$modename: \`$file' is not a valid libtool archive" 1>&2 - $echo "$help" 1>&2 - exit 1 - fi - - library_names= - old_library= - relink_command= - # If there is no directory component, then add one. - case $file in - */* | *\\*) . $file ;; - *) . ./$file ;; - esac - - # Add the libdir to current_libdirs if it is the destination. - if test "X$destdir" = "X$libdir"; then - case "$current_libdirs " in - *" $libdir "*) ;; - *) current_libdirs="$current_libdirs $libdir" ;; - esac - else - # Note the libdir as a future libdir. - case "$future_libdirs " in - *" $libdir "*) ;; - *) future_libdirs="$future_libdirs $libdir" ;; - esac - fi - - dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`/ - test "X$dir" = "X$file/" && dir= - dir="$dir$objdir" - - if test -n "$relink_command"; then - # Determine the prefix the user has applied to our future dir. - inst_prefix_dir=`$echo "$destdir" | sed "s%$libdir\$%%"` - - # Don't allow the user to place us outside of our expected - # location b/c this prevents finding dependent libraries that - # are installed to the same prefix. - if test "$inst_prefix_dir" = "$destdir"; then - $echo "$modename: error: cannot install \`$file' to a directory not ending in $libdir" 1>&2 - exit 1 - fi - - if test -n "$inst_prefix_dir"; then - # Stick the inst_prefix_dir data into the link command. - relink_command=`$echo "$relink_command" | sed "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` - else - relink_command=`$echo "$relink_command" | sed "s%@inst_prefix_dir@%%"` - fi - - $echo "$modename: warning: relinking \`$file'" 1>&2 - $show "$relink_command" - if $run eval "$relink_command"; then : - else - $echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2 - exit 1 - fi - fi - - # See the names of the shared library. - set dummy $library_names - if test -n "$2"; then - realname="$2" - shift - shift - - srcname="$realname" - test -n "$relink_command" && srcname="$realname"T - - # Install the shared library and build the symlinks. - $show "$install_prog $dir/$srcname $destdir/$realname" - $run eval "$install_prog $dir/$srcname $destdir/$realname" || exit $? - if test -n "$stripme" && test -n "$striplib"; then - $show "$striplib $destdir/$realname" - $run eval "$striplib $destdir/$realname" || exit $? - fi - - if test $# -gt 0; then - # Delete the old symlinks, and create new ones. - for linkname - do - if test "$linkname" != "$realname"; then - $show "(cd $destdir && $rm $linkname && $LN_S $realname $linkname)" - $run eval "(cd $destdir && $rm $linkname && $LN_S $realname $linkname)" - fi - done - fi - - # Do each command in the postinstall commands. - lib="$destdir/$realname" - eval cmds=\"$postinstall_cmds\" - save_ifs="$IFS"; IFS='~' - for cmd in $cmds; do - IFS="$save_ifs" - $show "$cmd" - $run eval "$cmd" || exit $? - done - IFS="$save_ifs" - fi - - # Install the pseudo-library for information purposes. - name=`$echo "X$file" | $Xsed -e 's%^.*/%%'` - instname="$dir/$name"i - $show "$install_prog $instname $destdir/$name" - $run eval "$install_prog $instname $destdir/$name" || exit $? - - # Maybe install the static library, too. - test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library" - ;; - - *.lo) - # Install (i.e. copy) a libtool object. - - # Figure out destination file name, if it wasn't already specified. - if test -n "$destname"; then - destfile="$destdir/$destname" - else - destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'` - destfile="$destdir/$destfile" - fi - - # Deduce the name of the destination old-style object file. - case $destfile in - *.lo) - staticdest=`$echo "X$destfile" | $Xsed -e "$lo2o"` - ;; - *.$objext) - staticdest="$destfile" - destfile= - ;; - *) - $echo "$modename: cannot copy a libtool object to \`$destfile'" 1>&2 - $echo "$help" 1>&2 - exit 1 - ;; - esac - - # Install the libtool object if requested. - if test -n "$destfile"; then - $show "$install_prog $file $destfile" - $run eval "$install_prog $file $destfile" || exit $? - fi - - # Install the old object if enabled. - if test "$build_old_libs" = yes; then - # Deduce the name of the old-style object file. - staticobj=`$echo "X$file" | $Xsed -e "$lo2o"` - - $show "$install_prog $staticobj $staticdest" - $run eval "$install_prog \$staticobj \$staticdest" || exit $? - fi - exit 0 - ;; - - *) - # Figure out destination file name, if it wasn't already specified. - if test -n "$destname"; then - destfile="$destdir/$destname" - else - destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'` - destfile="$destdir/$destfile" - fi - - # Do a test to see if this is really a libtool program. - case $host in - *cygwin*|*mingw*) - wrapper=`echo $file | ${SED} -e 's,.exe$,,'` - ;; - *) - wrapper=$file - ;; - esac - if (${SED} -e '4q' $wrapper | egrep "^# Generated by .*$PACKAGE")>/dev/null 2>&1; then - notinst_deplibs= - relink_command= - - # If there is no directory component, then add one. - case $file in - */* | *\\*) . $wrapper ;; - *) . ./$wrapper ;; - esac - - # Check the variables that should have been set. - if test -z "$notinst_deplibs"; then - $echo "$modename: invalid libtool wrapper script \`$wrapper'" 1>&2 - exit 1 - fi - - finalize=yes - for lib in $notinst_deplibs; do - # Check to see that each library is installed. - libdir= - if test -f "$lib"; then - # If there is no directory component, then add one. - case $lib in - */* | *\\*) . $lib ;; - *) . ./$lib ;; - esac - fi - libfile="$libdir/"`$echo "X$lib" | $Xsed -e 's%^.*/%%g'` ### testsuite: skip nested quoting test - if test -n "$libdir" && test ! -f "$libfile"; then - $echo "$modename: warning: \`$lib' has not been installed in \`$libdir'" 1>&2 - finalize=no - fi - done - - relink_command= - # If there is no directory component, then add one. - case $file in - */* | *\\*) . $wrapper ;; - *) . ./$wrapper ;; - esac - - outputname= - if test "$fast_install" = no && test -n "$relink_command"; then - if test "$finalize" = yes && test -z "$run"; then - tmpdir="/tmp" - test -n "$TMPDIR" && tmpdir="$TMPDIR" - tmpdir="$tmpdir/libtool-$$" - if $mkdir -p "$tmpdir" && chmod 700 "$tmpdir"; then : - else - $echo "$modename: error: cannot create temporary directory \`$tmpdir'" 1>&2 - continue - fi - file=`$echo "X$file" | $Xsed -e 's%^.*/%%'` - outputname="$tmpdir/$file" - # Replace the output file specification. - relink_command=`$echo "X$relink_command" | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g'` - - $show "$relink_command" - if $run eval "$relink_command"; then : - else - $echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2 - ${rm}r "$tmpdir" - continue - fi - file="$outputname" - else - $echo "$modename: warning: cannot relink \`$file'" 1>&2 - fi - else - # Install the binary that we compiled earlier. - file=`$echo "X$file" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"` - fi - fi - - # remove .exe since cygwin /usr/bin/install will append another - # one anyways - case $install_prog,$host in - /usr/bin/install*,*cygwin*) - case $file:$destfile in - *.exe:*.exe) - # this is ok - ;; - *.exe:*) - destfile=$destfile.exe - ;; - *:*.exe) - destfile=`echo $destfile | ${SED} -e 's,.exe$,,'` - ;; - esac - ;; - esac - $show "$install_prog$stripme $file $destfile" - $run eval "$install_prog\$stripme \$file \$destfile" || exit $? - test -n "$outputname" && ${rm}r "$tmpdir" - ;; - esac - done - - for file in $staticlibs; do - name=`$echo "X$file" | $Xsed -e 's%^.*/%%'` - - # Set up the ranlib parameters. - oldlib="$destdir/$name" - - $show "$install_prog $file $oldlib" - $run eval "$install_prog \$file \$oldlib" || exit $? - - if test -n "$stripme" && test -n "$striplib"; then - $show "$old_striplib $oldlib" - $run eval "$old_striplib $oldlib" || exit $? - fi - - # Do each command in the postinstall commands. - eval cmds=\"$old_postinstall_cmds\" - save_ifs="$IFS"; IFS='~' - for cmd in $cmds; do - IFS="$save_ifs" - $show "$cmd" - $run eval "$cmd" || exit $? - done - IFS="$save_ifs" - done - - if test -n "$future_libdirs"; then - $echo "$modename: warning: remember to run \`$progname --finish$future_libdirs'" 1>&2 - fi - - if test -n "$current_libdirs"; then - # Maybe just do a dry run. - test -n "$run" && current_libdirs=" -n$current_libdirs" - exec_cmd='$SHELL $0 --finish$current_libdirs' - else - exit 0 - fi - ;; - - # libtool finish mode - finish) - modename="$modename: finish" - libdirs="$nonopt" - admincmds= - - if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then - for dir - do - libdirs="$libdirs $dir" - done - - for libdir in $libdirs; do - if test -n "$finish_cmds"; then - # Do each command in the finish commands. - eval cmds=\"$finish_cmds\" - save_ifs="$IFS"; IFS='~' - for cmd in $cmds; do - IFS="$save_ifs" - $show "$cmd" - $run eval "$cmd" || admincmds="$admincmds - $cmd" - done - IFS="$save_ifs" - fi - if test -n "$finish_eval"; then - # Do the single finish_eval. - eval cmds=\"$finish_eval\" - $run eval "$cmds" || admincmds="$admincmds - $cmds" - fi - done - fi - - # Exit here if they wanted silent mode. - test "$show" = ":" && exit 0 - - echo "----------------------------------------------------------------------" - echo "Libraries have been installed in:" - for libdir in $libdirs; do - echo " $libdir" - done - echo - echo "If you ever happen to want to link against installed libraries" - echo "in a given directory, LIBDIR, you must either use libtool, and" - echo "specify the full pathname of the library, or use the \`-LLIBDIR'" - echo "flag during linking and do at least one of the following:" - if test -n "$shlibpath_var"; then - echo " - add LIBDIR to the \`$shlibpath_var' environment variable" - echo " during execution" - fi - if test -n "$runpath_var"; then - echo " - add LIBDIR to the \`$runpath_var' environment variable" - echo " during linking" - fi - if test -n "$hardcode_libdir_flag_spec"; then - libdir=LIBDIR - eval flag=\"$hardcode_libdir_flag_spec\" - - echo " - use the \`$flag' linker flag" - fi - if test -n "$admincmds"; then - echo " - have your system administrator run these commands:$admincmds" - fi - if test -f /etc/ld.so.conf; then - echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'" - fi - echo - echo "See any operating system documentation about shared libraries for" - echo "more information, such as the ld(1) and ld.so(8) manual pages." - echo "----------------------------------------------------------------------" - exit 0 - ;; - - # libtool execute mode - execute) - modename="$modename: execute" - - # The first argument is the command name. - cmd="$nonopt" - if test -z "$cmd"; then - $echo "$modename: you must specify a COMMAND" 1>&2 - $echo "$help" - exit 1 - fi - - # Handle -dlopen flags immediately. - for file in $execute_dlfiles; do - if test ! -f "$file"; then - $echo "$modename: \`$file' is not a file" 1>&2 - $echo "$help" 1>&2 - exit 1 - fi - - dir= - case $file in - *.la) - # Check to see that this really is a libtool archive. - if (${SED} -e '2q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : - else - $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 - $echo "$help" 1>&2 - exit 1 - fi - - # Read the libtool library. - dlname= - library_names= - - # If there is no directory component, then add one. - case $file in - */* | *\\*) . $file ;; - *) . ./$file ;; - esac - - # Skip this library if it cannot be dlopened. - if test -z "$dlname"; then - # Warn if it was a shared library. - test -n "$library_names" && $echo "$modename: warning: \`$file' was not linked with \`-export-dynamic'" - continue - fi - - dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` - test "X$dir" = "X$file" && dir=. - - if test -f "$dir/$objdir/$dlname"; then - dir="$dir/$objdir" - else - $echo "$modename: cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" 1>&2 - exit 1 - fi - ;; - - *.lo) - # Just add the directory containing the .lo file. - dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` - test "X$dir" = "X$file" && dir=. - ;; - - *) - $echo "$modename: warning \`-dlopen' is ignored for non-libtool libraries and objects" 1>&2 - continue - ;; - esac - - # Get the absolute pathname. - absdir=`cd "$dir" && pwd` - test -n "$absdir" && dir="$absdir" - - # Now add the directory to shlibpath_var. - if eval "test -z \"\$$shlibpath_var\""; then - eval "$shlibpath_var=\"\$dir\"" - else - eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" - fi - done - - # This variable tells wrapper scripts just to set shlibpath_var - # rather than running their programs. - libtool_execute_magic="$magic" - - # Check if any of the arguments is a wrapper script. - args= - for file - do - case $file in - -*) ;; - *) - # Do a test to see if this is really a libtool program. - if (${SED} -e '4q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then - # If there is no directory component, then add one. - case $file in - */* | *\\*) . $file ;; - *) . ./$file ;; - esac - - # Transform arg to wrapped name. - file="$progdir/$program" - fi - ;; - esac - # Quote arguments (to preserve shell metacharacters). - file=`$echo "X$file" | $Xsed -e "$sed_quote_subst"` - args="$args \"$file\"" - done - - if test -z "$run"; then - if test -n "$shlibpath_var"; then - # Export the shlibpath_var. - eval "export $shlibpath_var" - fi - - # Restore saved enviroment variables - if test "${save_LC_ALL+set}" = set; then - LC_ALL="$save_LC_ALL"; export LC_ALL - fi - if test "${save_LANG+set}" = set; then - LANG="$save_LANG"; export LANG - fi - - # Now prepare to actually exec the command. - exec_cmd="\$cmd$args" - else - # Display what would be done. - if test -n "$shlibpath_var"; then - eval "\$echo \"\$shlibpath_var=\$$shlibpath_var\"" - $echo "export $shlibpath_var" - fi - $echo "$cmd$args" - exit 0 - fi - ;; - - # libtool clean and uninstall mode - clean | uninstall) - modename="$modename: $mode" - rm="$nonopt" - files= - rmforce= - exit_status=0 - - # This variable tells wrapper scripts just to set variables rather - # than running their programs. - libtool_install_magic="$magic" - - for arg - do - case $arg in - -f) rm="$rm $arg"; rmforce=yes ;; - -*) rm="$rm $arg" ;; - *) files="$files $arg" ;; - esac - done - - if test -z "$rm"; then - $echo "$modename: you must specify an RM program" 1>&2 - $echo "$help" 1>&2 - exit 1 - fi - - rmdirs= - - for file in $files; do - dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` - if test "X$dir" = "X$file"; then - dir=. - objdir="$objdir" - else - objdir="$dir/$objdir" - fi - name=`$echo "X$file" | $Xsed -e 's%^.*/%%'` - test $mode = uninstall && objdir="$dir" - - # Remember objdir for removal later, being careful to avoid duplicates - if test $mode = clean; then - case " $rmdirs " in - *" $objdir "*) ;; - *) rmdirs="$rmdirs $objdir" ;; - esac - fi - - # Don't error if the file doesn't exist and rm -f was used. - if (test -L "$file") >/dev/null 2>&1 \ - || (test -h "$file") >/dev/null 2>&1 \ - || test -f "$file"; then - : - elif test -d "$file"; then - exit_status=1 - continue - elif test "$rmforce" = yes; then - continue - fi - - rmfiles="$file" - - case $name in - *.la) - # Possibly a libtool archive, so verify it. - if (${SED} -e '2q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then - . $dir/$name - - # Delete the libtool libraries and symlinks. - for n in $library_names; do - rmfiles="$rmfiles $objdir/$n" - done - test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library" - test $mode = clean && rmfiles="$rmfiles $objdir/$name $objdir/${name}i" - - if test $mode = uninstall; then - if test -n "$library_names"; then - # Do each command in the postuninstall commands. - eval cmds=\"$postuninstall_cmds\" - save_ifs="$IFS"; IFS='~' - for cmd in $cmds; do - IFS="$save_ifs" - $show "$cmd" - $run eval "$cmd" - if test $? != 0 && test "$rmforce" != yes; then - exit_status=1 - fi - done - IFS="$save_ifs" - fi - - if test -n "$old_library"; then - # Do each command in the old_postuninstall commands. - eval cmds=\"$old_postuninstall_cmds\" - save_ifs="$IFS"; IFS='~' - for cmd in $cmds; do - IFS="$save_ifs" - $show "$cmd" - $run eval "$cmd" - if test $? != 0 && test "$rmforce" != yes; then - exit_status=1 - fi - done - IFS="$save_ifs" - fi - # FIXME: should reinstall the best remaining shared library. - fi - fi - ;; - - *.lo) - if test "$build_old_libs" = yes; then - oldobj=`$echo "X$name" | $Xsed -e "$lo2o"` - rmfiles="$rmfiles $dir/$oldobj" - fi - ;; - - *) - # Do a test to see if this is a libtool program. - if test $mode = clean && - (${SED} -e '4q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then - relink_command= - . $dir/$file - - rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}" - if test "$fast_install" = yes && test -n "$relink_command"; then - rmfiles="$rmfiles $objdir/lt-$name" - fi - fi - ;; - esac - $show "$rm $rmfiles" - $run $rm $rmfiles || exit_status=1 - done - - # Try to remove the ${objdir}s in the directories where we deleted files - for dir in $rmdirs; do - if test -d "$dir"; then - $show "rmdir $dir" - $run rmdir $dir >/dev/null 2>&1 - fi - done - - exit $exit_status - ;; - - "") - $echo "$modename: you must specify a MODE" 1>&2 - $echo "$generic_help" 1>&2 - exit 1 - ;; - esac - - if test -z "$exec_cmd"; then - $echo "$modename: invalid operation mode \`$mode'" 1>&2 - $echo "$generic_help" 1>&2 - exit 1 - fi -fi # test -z "$show_help" - -if test -n "$exec_cmd"; then - eval exec $exec_cmd - exit 1 -fi - -# We need to display help for each of the modes. -case $mode in -"") $echo \ -"Usage: $modename [OPTION]... [MODE-ARG]... - -Provide generalized library-building support services. - - --config show all configuration variables - --debug enable verbose shell tracing --n, --dry-run display commands without modifying any files - --features display basic configuration information and exit - --finish same as \`--mode=finish' - --help display this help message and exit - --mode=MODE use operation mode MODE [default=inferred from MODE-ARGS] - --quiet same as \`--silent' - --silent don't print informational messages - --version print version information - -MODE must be one of the following: - - clean remove files from the build directory - compile compile a source file into a libtool object - execute automatically set library path, then run a program - finish complete the installation of libtool libraries - install install libraries or executables - link create a library or an executable - uninstall remove libraries from an installed directory - -MODE-ARGS vary depending on the MODE. Try \`$modename --help --mode=MODE' for -a more detailed description of MODE." - exit 0 - ;; - -clean) - $echo \ -"Usage: $modename [OPTION]... --mode=clean RM [RM-OPTION]... FILE... - -Remove files from the build directory. - -RM is the name of the program to use to delete files associated with each FILE -(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed -to RM. - -If FILE is a libtool library, object or program, all the files associated -with it are deleted. Otherwise, only FILE itself is deleted using RM." - ;; - -compile) - $echo \ -"Usage: $modename [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE - -Compile a source file into a libtool library object. - -This mode accepts the following additional options: - - -o OUTPUT-FILE set the output file name to OUTPUT-FILE - -prefer-pic try to building PIC objects only - -prefer-non-pic try to building non-PIC objects only - -static always build a \`.o' file suitable for static linking - -COMPILE-COMMAND is a command to be used in creating a \`standard' object file -from the given SOURCEFILE. - -The output file name is determined by removing the directory component from -SOURCEFILE, then substituting the C source code suffix \`.c' with the -library object suffix, \`.lo'." - ;; - -execute) - $echo \ -"Usage: $modename [OPTION]... --mode=execute COMMAND [ARGS]... - -Automatically set library path, then run a program. - -This mode accepts the following additional options: - - -dlopen FILE add the directory containing FILE to the library path - -This mode sets the library path environment variable according to \`-dlopen' -flags. - -If any of the ARGS are libtool executable wrappers, then they are translated -into their corresponding uninstalled binary, and any of their required library -directories are added to the library path. - -Then, COMMAND is executed, with ARGS as arguments." - ;; - -finish) - $echo \ -"Usage: $modename [OPTION]... --mode=finish [LIBDIR]... - -Complete the installation of libtool libraries. - -Each LIBDIR is a directory that contains libtool libraries. - -The commands that this mode executes may require superuser privileges. Use -the \`--dry-run' option if you just want to see what would be executed." - ;; - -install) - $echo \ -"Usage: $modename [OPTION]... --mode=install INSTALL-COMMAND... - -Install executables or libraries. - -INSTALL-COMMAND is the installation command. The first component should be -either the \`install' or \`cp' program. - -The rest of the components are interpreted as arguments to that command (only -BSD-compatible install options are recognized)." - ;; - -link) - $echo \ -"Usage: $modename [OPTION]... --mode=link LINK-COMMAND... - -Link object files or libraries together to form another library, or to -create an executable program. - -LINK-COMMAND is a command using the C compiler that you would use to create -a program from several object files. - -The following components of LINK-COMMAND are treated specially: - - -all-static do not do any dynamic linking at all - -avoid-version do not add a version suffix if possible - -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime - -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols - -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) - -export-symbols SYMFILE - try to export only the symbols listed in SYMFILE - -export-symbols-regex REGEX - try to export only the symbols matching REGEX - -LLIBDIR search LIBDIR for required installed libraries - -lNAME OUTPUT-FILE requires the installed library libNAME - -module build a library that can dlopened - -no-fast-install disable the fast-install mode - -no-install link a not-installable executable - -no-undefined declare that a library does not refer to external symbols - -o OUTPUT-FILE create OUTPUT-FILE from the specified objects - -release RELEASE specify package release information - -rpath LIBDIR the created library will eventually be installed in LIBDIR - -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries - -static do not do any dynamic linking of libtool libraries - -version-info CURRENT[:REVISION[:AGE]] - specify library version info [each variable defaults to 0] - -All other options (arguments beginning with \`-') are ignored. - -Every other argument is treated as a filename. Files ending in \`.la' are -treated as uninstalled libtool libraries, other files are standard or library -object files. - -If the OUTPUT-FILE ends in \`.la', then a libtool library is created, -only library objects (\`.lo' files) may be specified, and \`-rpath' is -required, except when creating a convenience library. - -If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created -using \`ar' and \`ranlib', or on Windows using \`lib'. - -If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file -is created, otherwise an executable program is created." - ;; - -uninstall) - $echo \ -"Usage: $modename [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... - -Remove libraries from an installation directory. - -RM is the name of the program to use to delete files associated with each FILE -(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed -to RM. - -If FILE is a libtool library, all the files associated with it are deleted. -Otherwise, only FILE itself is deleted using RM." - ;; - -*) - $echo "$modename: invalid operation mode \`$mode'" 1>&2 - $echo "$help" 1>&2 - exit 1 - ;; -esac - -echo -$echo "Try \`$modename --help' for more information about other modes." - -exit 0 - -# Local Variables: -# mode:shell-script -# sh-indentation:2 -# End: diff --git a/src/pal/src/libunwind/configure.ac b/src/pal/src/libunwind/configure.ac deleted file mode 100644 index 0c5125971..000000000 --- a/src/pal/src/libunwind/configure.ac +++ /dev/null @@ -1,445 +0,0 @@ -define(pkg_major, 1) -define(pkg_minor, 3) -define(pkg_extra, -rc1) -define(pkg_maintainer, libunwind-devel@nongnu.org) -define(mkvers, $1.$2$3) -dnl Process this file with autoconf to produce a configure script. -AC_INIT([libunwind],[mkvers(pkg_major, pkg_minor, pkg_extra)],[pkg_maintainer]) -AC_CONFIG_SRCDIR(src/mi/backtrace.c) -AC_CONFIG_AUX_DIR(config) -AC_CANONICAL_TARGET -AM_INIT_AUTOMAKE([1.6 subdir-objects]) -AM_MAINTAINER_MODE -AC_CONFIG_HEADERS([include/config.h]) - -dnl Checks for programs. -AC_PROG_CC -AC_PROG_CXX -AC_PROG_INSTALL -AC_PROG_MAKE_SET -m4_ifdef([AM_PROG_AR], [AM_PROG_AR]) -LT_INIT -AM_PROG_AS -AM_PROG_CC_C_O - -dnl Checks for libraries. -AC_CHECK_LIB(uca, __uc_get_grs) -OLD_LIBS=${LIBS} -AC_SEARCH_LIBS(dlopen, dl) -LIBS=${OLD_LIBS} -case "$ac_cv_search_dlopen" in - -l*) DLLIB=$ac_cv_search_dlopen;; - *) DLLIB="";; -esac - -CHECK_ATOMIC_OPS - -dnl Checks for header files. -AC_HEADER_STDC -AC_CHECK_HEADERS(asm/ptrace_offsets.h endian.h sys/endian.h execinfo.h \ - ia64intrin.h sys/uc_access.h unistd.h signal.h sys/types.h \ - sys/procfs.h sys/ptrace.h byteswap.h elf.h sys/elf.h link.h sys/link.h) - -dnl Checks for typedefs, structures, and compiler characteristics. -AC_C_CONST -AC_C_INLINE -AC_TYPE_SIZE_T -AC_CHECK_SIZEOF(off_t) - -CPPFLAGS="${CPPFLAGS} -D_GNU_SOURCE" - -AC_CHECK_MEMBERS([struct dl_phdr_info.dlpi_subs],,,[#include ]) -AC_CHECK_TYPES([struct elf_prstatus, struct prstatus], [], [], -[$ac_includes_default -#if HAVE_SYS_PROCFS_H -# include -#endif -]) - -AC_CHECK_DECLS([PTRACE_POKEUSER, PTRACE_POKEDATA, PTRACE_SETREGSET, -PTRACE_TRACEME, PTRACE_CONT, PTRACE_SINGLESTEP, -PTRACE_SYSCALL, PT_IO, PT_GETREGS, -PT_GETFPREGS, PT_CONTINUE, PT_TRACE_ME, -PT_STEP, PT_SYSCALL], [], [], -[$ac_includes_default -#if HAVE_SYS_TYPES_H -#include -#endif -#include -]) - -dnl Checks for library functions. -AC_CHECK_FUNCS(dl_iterate_phdr dl_phdr_removals_counter dlmodinfo getunwind \ - ttrace mincore) - -AC_MSG_CHECKING([if building with AltiVec]) -AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ -#ifndef __ALTIVEC__ -# error choke -#endif -]])], [use_altivec=yes],[use_altivec=no]) -AM_CONDITIONAL(USE_ALTIVEC, [test x$use_altivec = xyes]) -AC_MSG_RESULT([$use_altivec]) - -AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ -#ifndef __powerpc64__ -# error choke -#endif -]])], [ppc_bits=64], [ppc_bits=32]) - -AC_DEFUN([SET_ARCH],[ - AS_CASE([$1], - [aarch64*],[$2=aarch64], - [arm*],[$2=arm], - [i?86],[$2=x86], - [hppa*],[$2=hppa], - [mips*],[$2=mips], - [powerpc*],[$2=ppc$ppc_bits], - [sh*],[$2=sh], - [amd64],[$2=x86_64], - [tile*],[$2=tilegx], - [$2=$1]) -]) dnl SET_ARCH - -SET_ARCH([$build_cpu],[build_arch]) -SET_ARCH([$host_cpu],[host_arch]) -SET_ARCH([$target_cpu],[target_arch]) - -# Check for Android -AC_MSG_CHECKING([for Android]) -android="no" -case "$host_os" in - *android*) - android="yes" - AC_MSG_RESULT([yes]) - ;; - *) - AC_MSG_RESULT([no]) - ;; -esac - -AC_ARG_ENABLE(coredump, - AS_HELP_STRING([--enable-coredump],[building libunwind-coredump library]),, - [AS_CASE([$host_arch], [aarch64*|arm*|mips*|sh*|x86*|tile*], [enable_coredump=yes], [enable_coredump=no])] -) - -AC_MSG_CHECKING([if we should build libunwind-coredump]) -AC_MSG_RESULT([$enable_coredump]) - -AC_ARG_ENABLE(ptrace, - AS_HELP_STRING([--enable-ptrace],[building libunwind-ptrace library]),, - [AC_CHECK_HEADER([sys/ptrace.h], [enable_ptrace=yes], [enable_ptrace=no])] -) - -AC_MSG_CHECKING([if we should build libunwind-ptrace]) -AC_MSG_RESULT([$enable_ptrace]) - -AC_ARG_ENABLE(setjmp, - AS_HELP_STRING([--enable-setjmp],[building libunwind-setjmp library]),, - [AS_IF([test x$target_arch == x$host_arch], [enable_setjmp=yes], [enable_setjmp=no])] -) - -AC_ARG_ENABLE(documentation, - AS_HELP_STRING([--disable-documentation],[Disable generating the man pages]),, - [enable_documentation=yes]) - -AC_ARG_ENABLE(tests, - AS_HELP_STRING([--disable-tests],[Disable tests build]),, - [enable_tests=yes]) - -AC_MSG_CHECKING([if we should build libunwind-setjmp]) -AC_MSG_RESULT([$enable_setjmp]) - -AC_MSG_CHECKING([for build architecture]) -AC_MSG_RESULT([$build_arch]) -AC_MSG_CHECKING([for host architecture]) -AC_MSG_RESULT([$host_arch]) -AC_MSG_CHECKING([for target architecture]) -AC_MSG_RESULT([$target_arch]) -AC_MSG_CHECKING([for target operating system]) -AC_MSG_RESULT([$target_os]) - -AM_CONDITIONAL(BUILD_COREDUMP, test x$enable_coredump = xyes) -AM_CONDITIONAL(BUILD_PTRACE, test x$enable_ptrace = xyes) -AM_CONDITIONAL(BUILD_SETJMP, test x$enable_setjmp = xyes) -AM_CONDITIONAL(NO_PTRACE_TEST, test x$build_arch != x$host_arch) -AM_CONDITIONAL(REMOTE_ONLY, test x$target_arch != x$host_arch) -AM_CONDITIONAL(ARCH_AARCH64, test x$target_arch = xaarch64) -AM_CONDITIONAL(ARCH_ARM, test x$target_arch = xarm) -AM_CONDITIONAL(ARCH_IA64, test x$target_arch = xia64) -AM_CONDITIONAL(ARCH_HPPA, test x$target_arch = xhppa) -AM_CONDITIONAL(ARCH_MIPS, test x$target_arch = xmips) -AM_CONDITIONAL(ARCH_X86, test x$target_arch = xx86) -AM_CONDITIONAL(ARCH_X86_64, test x$target_arch = xx86_64) -AM_CONDITIONAL(ARCH_PPC32, test x$target_arch = xppc32) -AM_CONDITIONAL(ARCH_PPC64, test x$target_arch = xppc64) -AM_CONDITIONAL(ARCH_SH, test x$target_arch = xsh) -AM_CONDITIONAL(ARCH_TILEGX, test x$target_arch = xtilegx) -AM_CONDITIONAL(OS_LINUX, expr x$target_os : xlinux >/dev/null) -AM_CONDITIONAL(OS_HPUX, expr x$target_os : xhpux >/dev/null) -AM_CONDITIONAL(OS_FREEBSD, expr x$target_os : xfreebsd >/dev/null) -AM_CONDITIONAL(OS_QNX, expr x$target_os : xnto-qnx >/dev/null) - -AC_MSG_CHECKING([for ELF helper width]) -case "${target_arch}" in -(arm|hppa|ppc32|x86|sh) use_elf32=yes; AC_MSG_RESULT([32]);; -(aarch64|ia64|ppc64|x86_64|tilegx) use_elf64=yes; AC_MSG_RESULT([64]);; -(mips) use_elfxx=yes; AC_MSG_RESULT([xx]);; -*) AC_MSG_ERROR([Unknown ELF target: ${target_arch}]) -esac -AM_CONDITIONAL(USE_ELF32, [test x$use_elf32 = xyes]) -AM_CONDITIONAL(USE_ELF64, [test x$use_elf64 = xyes]) -AM_CONDITIONAL(USE_ELFXX, [test x$use_elfxx = xyes]) - -AC_MSG_CHECKING([whether to include DWARF support]) -if test x$target_arch != xia64; then - use_dwarf=yes -else - use_dwarf=no -fi -AM_CONDITIONAL(USE_DWARF, [test x$use_dwarf = xyes]) -AC_MSG_RESULT([$use_dwarf]) - -if test x$target_arch = xppc64; then - libdir='${exec_prefix}/lib64' - AC_MSG_NOTICE([PowerPC64 detected, lib will be installed ${libdir}]); - AC_SUBST([libdir]) -fi - -AC_MSG_CHECKING([whether to restrict build to remote support]) -if test x$target_arch != x$host_arch; then - CPPFLAGS="${CPPFLAGS} -DUNW_REMOTE_ONLY" - remote_only=yes -else - remote_only=no -fi -AC_MSG_RESULT([$remote_only]) - -AC_MSG_CHECKING([whether to enable debug support]) -AC_ARG_ENABLE(debug, -AS_HELP_STRING([--enable-debug],[turn on debug support (slows down execution)])) -if test x$enable_debug = xyes; then - CPPFLAGS="${CPPFLAGS} -DDEBUG" -else - CPPFLAGS="${CPPFLAGS} -DNDEBUG" -fi -AC_MSG_RESULT([$enable_debug]) - -AC_MSG_CHECKING([whether to enable C++ exception support]) -AC_ARG_ENABLE(cxx_exceptions, -AS_HELP_STRING([--enable-cxx-exceptions],[use libunwind to handle C++ exceptions]),, -[ -# C++ exception handling doesn't work too well on x86 -case $target_arch in - x86*) enable_cxx_exceptions=no;; - aarch64*) enable_cxx_exceptions=no;; - arm*) enable_cxx_exceptions=no;; - mips*) enable_cxx_exceptions=no;; - tile*) enable_cxx_exceptions=no;; - *) enable_cxx_exceptions=yes;; -esac -]) - -AM_CONDITIONAL([SUPPORT_CXX_EXCEPTIONS], [test x$enable_cxx_exceptions = xyes]) -AC_MSG_RESULT([$enable_cxx_exceptions]) - -AC_MSG_CHECKING([whether to load .debug_frame sections]) -AC_ARG_ENABLE(debug_frame, -AS_HELP_STRING([--enable-debug-frame],[Load the ".debug_frame" section if available]),, [ -case "${target_arch}" in - (arm) enable_debug_frame=yes;; - (aarch64) enable_debug_frame=yes;; - (*) enable_debug_frame=no;; -esac]) -if test x$enable_debug_frame = xyes; then - AC_DEFINE([CONFIG_DEBUG_FRAME], [], [Enable Debug Frame]) -fi -AC_MSG_RESULT([$enable_debug_frame]) - -AC_MSG_CHECKING([whether to block signals during mutex ops]) -AC_ARG_ENABLE(block_signals, -AS_HELP_STRING([--enable-block-signals],[Block signals before performing mutex operations]),, -[enable_block_signals=yes]) -if test x$enable_block_signals = xyes; then - AC_DEFINE([CONFIG_BLOCK_SIGNALS], [], [Block signals before mutex operations]) -fi -AC_MSG_RESULT([$enable_block_signals]) - -AC_MSG_CHECKING([whether to validate memory addresses before use]) -AC_ARG_ENABLE(conservative_checks, -AS_HELP_STRING([--enable-conservative-checks],[Validate all memory addresses before use]),, -[enable_conservative_checks=yes]) -if test x$enable_conservative_checks = xyes; then - AC_DEFINE(CONSERVATIVE_CHECKS, 1, - [Define to 1 if you want every memory access validated]) -fi -AC_MSG_RESULT([$enable_conservative_checks]) - -AC_MSG_CHECKING([whether to enable msabi support]) -AC_ARG_ENABLE(msabi_support, -AS_HELP_STRING([--enable-msabi-support],[Enables support for Microsoft ABI extensions])) -if test x$enable_msabi_support = xyes; then - AC_DEFINE([CONFIG_MSABI_SUPPORT], [], [Support for Microsoft ABI extensions]) -fi -AC_MSG_RESULT([$enable_msabi_support]) - -LIBLZMA= -AC_MSG_CHECKING([whether to support LZMA-compressed symbol tables]) -AC_ARG_ENABLE(minidebuginfo, -AS_HELP_STRING([--enable-minidebuginfo], [Enables support for LZMA-compressed symbol tables]),, [enable_minidebuginfo=auto]) -AC_MSG_RESULT([$enable_minidebuginfo]) -if test x$enable_minidebuginfo != xno; then - AC_CHECK_LIB([lzma], [lzma_mf_is_supported], - [LIBLZMA=-llzma - AC_DEFINE([HAVE_LZMA], [1], [Define if you have liblzma]) - enable_minidebuginfo=yes], - [if test x$enable_minidebuginfo = xyes; then - AC_MSG_FAILURE([liblzma not found]) - fi]) -fi -AC_SUBST([LIBLZMA]) -AM_CONDITIONAL(HAVE_LZMA, test x$enable_minidebuginfo = xyes) - -AC_MSG_CHECKING([whether to support UNW_CACHE_PER_THREAD]) -AC_ARG_ENABLE([per-thread-cache], -AS_HELP_STRING([--enable-per-thread-cache], [build with support for UNW_CACHE_PER_THREAD (which imposes a hight TLS memory usage) (default: disabled)])) -AC_MSG_RESULT([$enable_per_thread_cache]) -AS_IF([test x$enable_per_thread_cache = xyes], [ - LIBUNWIND___THREAD - AS_IF([test x$libc_cv_gcc___thread = xno], [ - AC_MSG_FAILURE([UNW_CACHE_PER_THREAD requires __thread]) - ]) -]) - -AC_MSG_CHECKING([for Intel compiler]) -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[#ifndef __INTEL_COMPILER -#error choke me -#endif]])],[intel_compiler=yes],[intel_compiler=no]) - -if test x$GCC = xyes -a x$intel_compiler != xyes; then - CFLAGS="${CFLAGS} -fexceptions -Wall -Wsign-compare" -fi -AC_MSG_RESULT([$intel_compiler]) - -AC_MSG_CHECKING([for QCC compiler]) -AS_CASE([$CC], [qcc*|QCC*], [qcc_compiler=yes], [qcc_compiler=no]) -AC_MSG_RESULT([$qcc_compiler]) - -if test x$intel_compiler = xyes; then - AC_MSG_CHECKING([if linker supports -static-libcxa]) - save_LDFLAGS="$LDFLAGS" - LDFLAGS="$LDFLAGS -static-libcxa" - AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])],[have_static_libcxa=yes],[have_static_libcxa=no]) - LDFLAGS="$save_LDFLAGS" - if test "x$have_static_libcxa" = xyes; then - LDFLAGS_STATIC_LIBCXA="-XCClinker -static-libcxa" - fi - AC_MSG_RESULT([$have_static_libcxa]) -fi - -if test x$qcc_compiler = xyes; then - LDFLAGS_NOSTARTFILES="-XCClinker -Wc,-nostartfiles" -else - LDFLAGS_NOSTARTFILES="-XCClinker -nostartfiles" -fi - -if test x$GCC = xyes -a x$intel_compiler != xyes -a x$qcc_compiler != xyes -a x$android != xyes; then - LIBCRTS="-lgcc_s" -fi - -AC_MSG_CHECKING([for __builtin___clear_cache]) -AC_LINK_IFELSE( - [AC_LANG_PROGRAM([[]], [[__builtin___clear_cache(0, 0)]])], - [have__builtin___clear_cache=yes], - [have__builtin___clear_cache=no]) -if test x$have__builtin___clear_cache = xyes; then - AC_DEFINE([HAVE__BUILTIN___CLEAR_CACHE], [1], - [Defined if __builtin___clear_cache() is available]) -fi -AC_MSG_RESULT([$have__builtin___clear_cache]) - -AC_MSG_CHECKING([for __builtin_unreachable]) -AC_LINK_IFELSE( - [AC_LANG_PROGRAM([[]], [[__builtin_unreachable()]])], - [have__builtin_unreachable=yes], - [have__builtin_unreachable=no]) -if test x$have__builtin_unreachable = xyes; then - AC_DEFINE([HAVE__BUILTIN_UNREACHABLE], [1], - [Defined if __builtin_unreachable() is available]) -fi -AC_MSG_RESULT([$have__builtin_unreachable]) - -AC_MSG_CHECKING([for __sync atomics]) -AC_LINK_IFELSE( - [AC_LANG_PROGRAM([[]], [[ - __sync_bool_compare_and_swap((int *)0, 0, 1); - __sync_fetch_and_add((int *)0, 1); - ]])], - [have_sync_atomics=yes], - [have_sync_atomics=no]) -if test x$have_sync_atomics = xyes; then - AC_DEFINE([HAVE_SYNC_ATOMICS], [1], - [Defined if __sync atomics are available]) -fi -AC_MSG_RESULT([$have_sync_atomics]) - -CCASFLAGS="${CCASFLAGS} ${CPPFLAGS}" - -arch="$target_arch" -ARCH=`echo $target_arch | tr [a-z] [A-Z]` - -dnl create shell variables from the M4 macros: -PKG_MAJOR=pkg_major -PKG_MINOR=pkg_minor -PKG_EXTRA=pkg_extra -PKG_MAINTAINER=pkg_maintainer - -old_LIBS="$LIBS" -LIBS="" -AC_SEARCH_LIBS(backtrace, execinfo) -LIBS="$old_LIBS" -case "$ac_cv_search_backtrace" in - -l*) BACKTRACELIB=$ac_cv_search_backtrace;; - *) BACKTRACELIB="";; -esac - - -AC_SUBST(build_arch) -AC_SUBST(target_os) -AC_SUBST(arch) -AC_SUBST(ARCH) -AC_SUBST(LDFLAGS_STATIC_LIBCXA) -AC_SUBST(LDFLAGS_NOSTARTFILES) -AC_SUBST(LIBCRTS) -AC_SUBST(PKG_MAJOR) -AC_SUBST(PKG_MINOR) -AC_SUBST(PKG_EXTRA) -AC_SUBST(PKG_MAINTAINER) -AC_SUBST(enable_cxx_exceptions) -AC_SUBST(enable_debug_frame) -AC_SUBST(DLLIB) -AC_SUBST(BACKTRACELIB) - -AC_PATH_PROG([LATEX2MAN],[latex2man]) -if test "x$LATEX2MAN" = "x"; then - AC_MSG_WARN([latex2man not found. Install latex2man. Disabling docs.]) - enable_documentation="no"; -fi - -AM_CONDITIONAL([CONFIG_DOCS], [test x$enable_documentation = xyes]) -if test "x$enable_documentation" = "xyes"; then - AC_CONFIG_FILES(doc/Makefile doc/common.tex) -fi - -AM_CONDITIONAL([CONFIG_TESTS], [test x$enable_tests = xyes]) -if test "x$enable_tests" = "xyes"; then - AC_CONFIG_FILES(tests/Makefile tests/check-namespace.sh) -fi - -AC_CONFIG_FILES(Makefile src/Makefile - include/libunwind-common.h - include/libunwind.h include/tdep/libunwind_i.h) -AC_CONFIG_FILES(src/unwind/libunwind.pc src/coredump/libunwind-coredump.pc - src/ptrace/libunwind-ptrace.pc src/setjmp/libunwind-setjmp.pc - src/libunwind-generic.pc) -AC_OUTPUT diff --git a/src/pal/src/libunwind/doc/Makefile.am b/src/pal/src/libunwind/doc/Makefile.am deleted file mode 100644 index bfe466912..000000000 --- a/src/pal/src/libunwind/doc/Makefile.am +++ /dev/null @@ -1,80 +0,0 @@ -# man pages that go into section 3: -man3_MANS = libunwind.man libunwind-dynamic.man libunwind-ia64.man \ - libunwind-ptrace.man libunwind-setjmp.man \ - unw_apply_reg_state.man \ - unw_backtrace.man \ - unw_flush_cache.man \ - unw_get_accessors.man \ - unw_get_proc_info.man \ - unw_get_proc_info_by_ip.man \ - unw_get_proc_name.man \ - unw_get_fpreg.man \ - unw_get_reg.man \ - unw_getcontext.man \ - unw_init_local.man unw_init_remote.man \ - unw_init_local2.man \ - unw_is_fpreg.man \ - unw_is_signal_frame.man \ - unw_create_addr_space.man \ - unw_destroy_addr_space.man \ - unw_regname.man unw_resume.man \ - unw_reg_states_iterate.man \ - unw_set_caching_policy.man \ - unw_set_cache_size.man \ - unw_set_fpreg.man \ - unw_set_reg.man \ - unw_step.man \ - unw_strerror.man \ - _U_dyn_register.man \ - _U_dyn_cancel.man - -EXTRA_DIST = NOTES libunwind.trans \ - libunwind.tex libunwind-dynamic.tex libunwind-ia64.tex \ - libunwind-ptrace.tex libunwind-setjmp.tex \ - unw_apply_reg_state.tex \ - unw_backtrace.tex \ - unw_flush_cache.tex \ - unw_get_accessors.tex \ - unw_get_proc_info.tex \ - unw_get_proc_info_by_ip.tex \ - unw_get_proc_name.tex \ - unw_get_fpreg.tex \ - unw_get_reg.tex \ - unw_getcontext.tex \ - unw_init_local.tex unw_init_remote.tex \ - unw_is_fpreg.tex \ - unw_is_signal_frame.tex \ - unw_create_addr_space.tex unw_destroy_addr_space.tex \ - unw_regname.tex unw_resume.tex unw_set_caching_policy.tex \ - unw_reg_states_iterate.tex \ - unw_set_cache_size.tex \ - unw_set_fpreg.tex \ - unw_set_reg.tex \ - unw_step.tex \ - unw_strerror.tex \ - _U_dyn_register.tex \ - _U_dyn_cancel.tex \ - $(man3_MANS) - -L2M = latex2man -L2P = pdflatex -L2M_CMD = $(L2M) -t $(srcdir)/libunwind.trans -L2H_CMD = $(L2M) -H -t $(srcdir)/libunwind.trans - -.tex.man: - $(L2M_CMD) $< $@ - -cp $@ $(srcdir)/$@ - -html: - for n in $(man3_MANS); do \ - page=`basename $$n .man`; \ - $(L2H_CMD) $(srcdir)/$$page.tex "$$page(3).raw"; \ - done - -pdf: - for n in $(man3_MANS); do \ - page=`basename $$n .man`; \ - $(L2P) $(srcdir)/$$page.tex "$$page(3).pdf"; \ - done - -MAINTAINERCLEANFILES = Makefile.in diff --git a/src/pal/src/libunwind/doc/NOTES b/src/pal/src/libunwind/doc/NOTES deleted file mode 100644 index 3f3caa95b..000000000 --- a/src/pal/src/libunwind/doc/NOTES +++ /dev/null @@ -1,127 +0,0 @@ -The central data structure of the unwind API is the unwind cursor. -This structure tracks the register contents. The unwind API defines a -handful of well-known frame "registers": - - - ip: the instruction pointer (pc) - - rp: the return pointer (rp, aka "return address" or "return link") - - sp: the stack pointer (memory stack pointer, in the case of ia64) - - fp: the frame pointer - - first_ip: the starting address of the current "procedure" - - handler: a pointer to an architecture & language-specific - "personality" routine - - lsda: a pointer to an architecture & language-specific - data-area - -The API defines no well-known preserved registers. Each architecture -can define additional registers as needed. Of course, a portable -application may only rely on well-known registers. The names for -preserved registers are defined in the architecture-specific header -file . For example, to get the IA-64-specific register -names, an application would do: - - #include - -The API is designed to handle two primary cases: unwinding within the -current (local) process and unwinding of another ("remote") process -(e.g., through ptrace()). In the local case, the initial machine -state is captured by an unwind context (currently the same as -ucontext_t). In the remote case, the initial machine state is -captured by an unwind accessor structure, which provides callback -routines for reading/writing memory and registers and for obtaining -unwind information. - -Once a cursor has been initialized, you can step through the call -chain with the unw_step() routine. The frame registers and the -preserved state can then be accessed with unw_get_reg() or modified -with unw_set_reg(). For floating-point registers, there are separate -unw_get_fpreg() and unw_set_fpreg() routines (on some arches, e.g., -Alpha, these could be just aliases for unw_{g,s}et_reg()). The -unw_resume() routine can be used to resume execution at an arbitrary -point in the call-chain (as identified by an unwind cursor). This is -intended for exception handling and, at least for now, the intention -is to support this routine only for the local case. Kevin, if you -feel gdb could benefit from such a routine, I'd be interested to hear -about it. - -Note that it is perfectly legal to make copies of the unwind cursor. -This makes it possible, e.g., to obtain an unwind context, modify the -state in an earlier call frame, and then resume execution at the point -at which the unwind context was captured. - -Here is a quick example of how to use the unwind API to do a simple -stack trace: - - unw_cursor_t cursor; - unw_word_t ip, sp; - unw_context_t uc; - - unw_getcontext(&uc); - unw_init_local(&cursor, &uc); - do - { - unw_get_reg(&cursor, UNW_REG_IP, &ip); - unw_get_reg(&cursor, UNW_REG_SP, &sp); - printf ("ip=%016lx sp=%016lx\n", ip, sp); - } - while (unw_step (&cursor) > 0); - -Note that this particular example should work on pretty much any -architecture, as it doesn't rely on any arch-specific registers. - -* Multiarchitecture support - -If libunwind is configured for a target other than the local (native) -host, the library is installed as libunwind-$ARCH, where $ARCH is -the target architecture name (e.g., ia32, ia64, or alpha). Similarly, -the header file is installed as libunwind-$ARCH. - -With this setup, an application should: - - - include , and - - link against -lunwind - -if the application needs to use the unwinder of the host. An -application wanting to use the unwinder for a different target (e.g., -a cross-debugger) should: - - - include , and - - link against -lunwind-$ARCH - -The global symbols exported by -lunwind-$ARCH are unique such that the -same application can be linked against the separate unwind libraries -of multiple targets. However, a single compilation unit can include -the header file for only one target. For example, foo.c might include - and bar.c might include and the -entire application would have to be linked against both -lunwind and --lunwind-ia64. - -Note: the unwind header files of all targets have a common dependency -on libunwind-common.h. To avoid version conflicts, it is necessary to -ensure that the unwind libraries for all targets were derived from the -same release of libunwind. That is, if the unwind library for one -target is upgraded to a newer version, the libraries for all other -targets also need to be upgraded. - -Note 2: The assumption is that a cross-unwinder can handle all -interesting flavors of a target. For example, the unwinder for the -ia64 target is expected to be able to handle both Linux and HP-UX. - -* IA-64 Specific Information - -Apart from the normal frame-registers, the IA-64 implementation of -libunwind provides the means to access the current value of the -register backing store pointer (bsp). One quirk with this -frame-register is that it corresponds to the address that would be in -register ar.bsp after flushing the current register stack to the -backing store (i.e., as if a "flushrs" instruction had been executed). -Of course, given this value and the contents of the current frame -marker (CFM), it's easy to calculate the original value of ar.bsp: - - unw_word_t cfm, bsp, bsp_after_flushrs, sof; - - unw_get_reg (&cursor, UNW_IA64_BSP, &bsp_after_flushrs); - unw_get_reg (&cursor, UNW_IA64_CFM, &cfm); - bsp = ia64_rse_skip_regs (bsp_after_flushrs, -(cfm & 0x7f)); - -** Dynamic Unwind Info - diff --git a/src/pal/src/libunwind/doc/_U_dyn_cancel.man b/src/pal/src/libunwind/doc/_U_dyn_cancel.man deleted file mode 100644 index a420a6dea..000000000 --- a/src/pal/src/libunwind/doc/_U_dyn_cancel.man +++ /dev/null @@ -1,66 +0,0 @@ -'\" t -.\" Manual page created with latex2man on Thu Aug 16 09:44:45 MDT 2007 -.\" NOTE: This file is generated, DO NOT EDIT. -.de Vb -.ft CW -.nf -.. -.de Ve -.ft R - -.fi -.. -.TH "\\_U\\_DYN\\_CANCEL" "3" "16 August 2007" "Programming Library " "Programming Library " -.SH NAME -_U_dyn_cancel -\-\- cancel unwind\-info for dynamically generated code -.PP -.SH SYNOPSIS - -.PP -#include -.br -.PP -void -_U_dyn_cancel(unw_dyn_info_t *di); -.br -.PP -.SH DESCRIPTION - -.PP -The _U_dyn_cancel() -routine cancels the registration of the -unwind\-info for a dynamically generated procedure. Argument di -is the pointer to the unw_dyn_info_t -structure that -describes the procedure\&'s unwind\-info. -.PP -The _U_dyn_cancel() -routine is guaranteed to execute in -constant time (in the absence of contention from concurrent calls to -_U_dyn_register() -or _U_dyn_cancel()). -.PP -.SH THREAD AND SIGNAL SAFETY - -.PP -_U_dyn_cancel() -is thread\-safe but \fInot\fP -safe to use -from a signal handler. -.PP -.SH SEE ALSO - -.PP -libunwind\-dynamic(3), -_U_dyn_register(3) -.PP -.SH AUTHOR - -.PP -David Mosberger\-Tang -.br -Email: \fBdmosberger@gmail.com\fP -.br -WWW: \fBhttp://www.nongnu.org/libunwind/\fP\&. -.\" NOTE: This file is generated, DO NOT EDIT. diff --git a/src/pal/src/libunwind/doc/_U_dyn_cancel.tex b/src/pal/src/libunwind/doc/_U_dyn_cancel.tex deleted file mode 100644 index ca5a12a76..000000000 --- a/src/pal/src/libunwind/doc/_U_dyn_cancel.tex +++ /dev/null @@ -1,46 +0,0 @@ -\documentclass{article} -\usepackage[fancyhdr,pdf]{latex2man} - -\input{common.tex} - -\begin{document} - -\begin{Name}{3}{\_U\_dyn\_cancel}{David Mosberger-Tang}{Programming Library}{\_U\_dyn\_cancel}\_U\_dyn\_cancel -- cancel unwind-info for dynamically generated code -\end{Name} - -\section{Synopsis} - -\File{\#include $<$libunwind.h$>$}\\ - -\Type{void} \Func{\_U\_dyn\_cancel}(\Type{unw\_dyn\_info\_t~*}\Var{di});\\ - -\section{Description} - -The \Func{\_U\_dyn\_cancel}() routine cancels the registration of the -unwind-info for a dynamically generated procedure. Argument \Var{di} -is the pointer to the \Type{unw\_dyn\_info\_t} structure that -describes the procedure's unwind-info. - -The \Func{\_U\_dyn\_cancel}() routine is guaranteed to execute in -constant time (in the absence of contention from concurrent calls to -\Func{\_U\_dyn\_register}() or \Func{\_U\_dyn\_cancel}()). - - -\section{Thread and Signal Safety} - -\Func{\_U\_dyn\_cancel}() is thread-safe but \emph{not} safe to use -from a signal handler. - -\section{See Also} - -\SeeAlso{libunwind-dynamic(3)}, \SeeAlso{\_U\_dyn\_register(3)} - -\section{Author} - -\noindent -David Mosberger-Tang\\ -Email: \Email{dmosberger@gmail.com}\\ -WWW: \URL{http://www.nongnu.org/libunwind/}. -\LatexManEnd - -\end{document} diff --git a/src/pal/src/libunwind/doc/_U_dyn_register.man b/src/pal/src/libunwind/doc/_U_dyn_register.man deleted file mode 100644 index 107e5fd0e..000000000 --- a/src/pal/src/libunwind/doc/_U_dyn_register.man +++ /dev/null @@ -1,68 +0,0 @@ -'\" t -.\" Manual page created with latex2man on Thu Aug 16 09:44:45 MDT 2007 -.\" NOTE: This file is generated, DO NOT EDIT. -.de Vb -.ft CW -.nf -.. -.de Ve -.ft R - -.fi -.. -.TH "\\_U\\_DYN\\_REGISTER" "3" "16 August 2007" "Programming Library " "Programming Library " -.SH NAME -_U_dyn_register -\-\- register unwind\-info for dynamically generated code -.PP -.SH SYNOPSIS - -.PP -#include -.br -.PP -void -_U_dyn_register(unw_dyn_info_t *di); -.br -.PP -.SH DESCRIPTION - -.PP -The _U_dyn_register() -routine registers unwind\-info for a -dynamically generated procedure. The procedure\&'s unwind\-info is -described by a structure of type unw_dyn_info_t -(see -libunwind\-dynamic(3)). -A pointer to this structure is -passed in argument di\&. -.PP -The _U_dyn_register() -routine is guaranteed to execute in -constant time (in the absence of contention from concurrent calls to -_U_dyn_register() -or _U_dyn_cancel()). -.PP -.SH THREAD AND SIGNAL SAFETY - -.PP -_U_dyn_register() -is thread\-safe but \fInot\fP -safe to use -from a signal handler. -.PP -.SH SEE ALSO - -.PP -libunwind\-dynamic(3), -_U_dyn_cancel(3) -.PP -.SH AUTHOR - -.PP -David Mosberger\-Tang -.br -Email: \fBdmosberger@gmail.com\fP -.br -WWW: \fBhttp://www.nongnu.org/libunwind/\fP\&. -.\" NOTE: This file is generated, DO NOT EDIT. diff --git a/src/pal/src/libunwind/doc/_U_dyn_register.tex b/src/pal/src/libunwind/doc/_U_dyn_register.tex deleted file mode 100644 index ab23b5c62..000000000 --- a/src/pal/src/libunwind/doc/_U_dyn_register.tex +++ /dev/null @@ -1,47 +0,0 @@ -\documentclass{article} -\usepackage[fancyhdr,pdf]{latex2man} - -\input{common.tex} - -\begin{document} - -\begin{Name}{3}{\_U\_dyn\_register}{David Mosberger-Tang}{Programming Library}{\_U\_dyn\_register}\_U\_dyn\_register -- register unwind-info for dynamically generated code -\end{Name} - -\section{Synopsis} - -\File{\#include $<$libunwind.h$>$}\\ - -\Type{void} \Func{\_U\_dyn\_register}(\Type{unw\_dyn\_info\_t~*}\Var{di});\\ - -\section{Description} - -The \Func{\_U\_dyn\_register}() routine registers unwind-info for a -dynamically generated procedure. The procedure's unwind-info is -described by a structure of type \Type{unw\_dyn\_info\_t} (see -\SeeAlso{libunwind-dynamic(3)}). A pointer to this structure is -passed in argument \Var{di}. - -The \Func{\_U\_dyn\_register}() routine is guaranteed to execute in -constant time (in the absence of contention from concurrent calls to -\Func{\_U\_dyn\_register}() or \Func{\_U\_dyn\_cancel}()). - - -\section{Thread and Signal Safety} - -\Func{\_U\_dyn\_register}() is thread-safe but \emph{not} safe to use -from a signal handler. - -\section{See Also} - -\SeeAlso{libunwind-dynamic(3)}, \SeeAlso{\_U\_dyn\_cancel(3)} - -\section{Author} - -\noindent -David Mosberger-Tang\\ -Email: \Email{dmosberger@gmail.com}\\ -WWW: \URL{http://www.nongnu.org/libunwind/}. -\LatexManEnd - -\end{document} diff --git a/src/pal/src/libunwind/doc/common.tex.in b/src/pal/src/libunwind/doc/common.tex.in deleted file mode 100644 index 91c96a9df..000000000 --- a/src/pal/src/libunwind/doc/common.tex.in +++ /dev/null @@ -1,11 +0,0 @@ -\setVersion{@VERSION@} - -\sloppy - -\newcommand{\Lt}{\symbol{"3C}} -\newcommand{\Gt}{\symbol{"3E}} -\newcommand{\Type}[1]{\File{#1}} % see libunwind.trans -\newcommand{\Func}[1]{\Prog{#1}} % see libunwind.trans -\newcommand{\Var}[1]{\Prog{#1}} % see libunwind.trans -\newcommand{\Const}[1]{\File{#1}} % see libunwind.trans -\newcommand{\SeeAlso}[2]{\File{#1}} % see libunwind.trans diff --git a/src/pal/src/libunwind/doc/libunwind-dynamic.man b/src/pal/src/libunwind/doc/libunwind-dynamic.man deleted file mode 100644 index 7c7507cb1..000000000 --- a/src/pal/src/libunwind/doc/libunwind-dynamic.man +++ /dev/null @@ -1,538 +0,0 @@ -'\" t -.\" Manual page created with latex2man on Thu Aug 16 09:44:44 MDT 2007 -.\" NOTE: This file is generated, DO NOT EDIT. -.de Vb -.ft CW -.nf -.. -.de Ve -.ft R - -.fi -.. -.TH "LIBUNWIND\-DYNAMIC" "3" "16 August 2007" "Programming Library " "Programming Library " -.SH NAME -libunwind\-dynamic -\-\- libunwind\-support for runtime\-generated code -.PP -.SH INTRODUCTION - -.PP -For libunwind -to do its job, it needs to be able to reconstruct -the \fIframe state\fP -of each frame in a call\-chain. The frame state -describes the subset of the machine\-state that consists of the -\fIframe registers\fP -(typically the instruction\-pointer and the -stack\-pointer) and all callee\-saved registers (preserved registers). -The frame state describes each register either by providing its -current value (for frame registers) or by providing the location at -which the current value is stored (callee\-saved registers). -.PP -For statically generated code, the compiler normally takes care of -emitting \fIunwind\-info\fP -which provides the minimum amount of -information needed to reconstruct the frame\-state for each instruction -in a procedure. For dynamically generated code, the runtime code -generator must use the dynamic unwind\-info interface provided by -libunwind -to supply the equivalent information. This manual -page describes the format of this information in detail. -.PP -For the purpose of this discussion, a \fIprocedure\fP -is defined to -be an arbitrary piece of \fIcontiguous\fP -code. Normally, each -procedure directly corresponds to a function in the source\-language -but this is not strictly required. For example, a runtime -code\-generator could translate a given function into two separate -(discontiguous) procedures: one for frequently\-executed (hot) code and -one for rarely\-executed (cold) code. Similarly, simple -source\-language functions (usually leaf functions) may get translated -into code for which the default unwind\-conventions apply and for such -code, it is not strictly necessary to register dynamic unwind\-info. -.PP -A procedure logically consists of a sequence of \fIregions\fP\&. -Regions are nested in the sense that the frame state at the end of one -region is, by default, assumed to be the frame state for the next -region. Each region is thought of as being divided into a -\fIprologue\fP, -a \fIbody\fP, -and an \fIepilogue\fP\&. -Each of them -can be empty. If non\-empty, the prologue sets up the frame state for -the body. For example, the prologue may need to allocate some space -on the stack and save certain callee\-saved registers. The body -performs the actual work of the procedure but does not change the -frame state in any way. If non\-empty, the epilogue restores the -previous frame state and as such it undoes or cancels the effect of -the prologue. In fact, a single epilogue may undo the effect of the -prologues of several (nested) regions. -.PP -We should point out that even though the prologue, body, and epilogue -are logically separate entities, optimizing code\-generators will -generally interleave instructions from all three entities. For this -reason, the dynamic unwind\-info interface of libunwind -makes no -distinction whatsoever between prologue and body. Similarly, the -exact set of instructions that make up an epilogue is also irrelevant. -The only point in the epilogue that needs to be described explicitly -by the dynamic unwind\-info is the point at which the stack\-pointer -gets restored. The reason this point needs to be described is that -once the stack\-pointer is restored, all values saved in the -deallocated portion of the stack frame become invalid and hence -libunwind -needs to know about it. The portion of the frame -state not saved on the stack is assume to remain valid through the end -of the region. For this reason, there is usually no need to describe -instructions which restore the contents of callee\-saved registers. -.PP -Within a region, each instruction that affects the frame state in some -fashion needs to be described with an operation descriptor. For this -purpose, each instruction in the region is assigned a unique index. -Exactly how this index is derived depends on the architecture. For -example, on RISC and EPIC\-style architecture, instructions have a -fixed size so it\&'s possible to simply number the instructions. In -contrast, most CISC use variable\-length instruction encodings, so it -is usually necessary to use a byte\-offset as the index. Given the -instruction index, the operation descriptor specifies the effect of -the instruction in an abstract manner. For example, it might express -that the instruction stores calle\-saved register r1 -at offset 16 -in the stack frame. -.PP -.SH PROCEDURES - -.PP -A runtime code\-generator registers the dynamic unwind\-info of a -procedure by setting up a structure of type unw_dyn_info_t -and calling _U_dyn_register(), -passing the address of the -structure as the sole argument. The members of the -unw_dyn_info_t -structure are described below: -.TP -void *next - Private to libunwind\&. -Must not be used -by the application. -.TP -void *prev - Private to libunwind\&. -Must not be used -by the application. -.TP -unw_word_t start_ip - The start\-address of the -instructions of the procedure (remember: procedure are defined to be -contiguous pieces of code, so a single code\-range is sufficient). -.TP -unw_word_t end_ip - The end\-address of the -instructions of the procedure (non\-inclusive, that is, -end_ip\-start_ip -is the size of the procedure in -bytes). -.TP -unw_word_t gp - The global\-pointer value in use -for this procedure. The exact meaing of the global\-pointer is -architecture\-specific and on some architecture, it is not used at -all. -.TP -int32_t format - The format of the unwind\-info. -This member can be one of UNW_INFO_FORMAT_DYNAMIC, -UNW_INFO_FORMAT_TABLE, -or -UNW_INFO_FORMAT_REMOTE_TABLE\&. -.TP -union u - This union contains one sub\-member -structure for every possible unwind\-info format: -.RS -.TP -unw_dyn_proc_info_t pi - This member is used -for format UNW_INFO_FORMAT_DYNAMIC\&. -.TP -unw_dyn_table_info_t ti - This member is used -for format UNW_INFO_FORMAT_TABLE\&. -.TP -unw_dyn_remote_table_info_t rti - This member -is used for format UNW_INFO_FORMAT_REMOTE_TABLE\&. -.RE -.RS -.PP -The format of these sub\-members is described in detail below. -.RE -.PP -.SS PROC\-INFO FORMAT -.PP -This is the preferred dynamic unwind\-info format and it is generally -the one used by full\-blown runtime code\-generators. In this format, -the details of a procedure are described by a structure of type -unw_dyn_proc_info_t\&. -This structure contains the following -members: -.PP -.RE -.TP -unw_word_t name_ptr - The address of a -(human\-readable) name of the procedure or 0 if no such name is -available. If non\-zero, The string stored at this address must be -ASCII NUL terminated. For source languages that use name\-mangling -(such as C++ or Java) the string stored at this address should be -the \fIdemangled\fP -version of the name. -.PP -.TP -unw_word_t handler - The address of the -personality\-routine for this procedure. Personality\-routines are -used in conjunction with exception handling. See the C++ ABI draft -(http://www.codesourcery.com/cxx\-abi/) for an overview and a -description of the personality routine. If the procedure has no -personality routine, handler -must be set to 0. -.PP -.TP -uint32_t flags - A bitmask of flags. At the -moment, no flags have been defined and this member must be -set to 0. -.PP -.TP -unw_dyn_region_info_t *regions - A NULL\-terminated -linked list of region\-descriptors. See section ``Region -descriptors\&'' below for more details. -.PP -.SS TABLE\-INFO FORMAT -.PP -This format is generally used when the dynamically generated code was -derived from static code and the unwind\-info for the dynamic and the -static versions is identical. For example, this format can be useful -when loading statically\-generated code into an address\-space in a -non\-standard fashion (i.e., through some means other than -dlopen()). -In this format, the details of a group of procedures -is described by a structure of type unw_dyn_table_info\&. -This structure contains the following members: -.PP -.TP -unw_word_t name_ptr - The address of a -(human\-readable) name of the procedure or 0 if no such name is -available. If non\-zero, The string stored at this address must be -ASCII NUL terminated. For source languages that use name\-mangling -(such as C++ or Java) the string stored at this address should be -the \fIdemangled\fP -version of the name. -.PP -.TP -unw_word_t segbase - The segment\-base value -that needs to be added to the segment\-relative values stored in the -unwind\-info. The exact meaning of this value is -architecture\-specific. -.PP -.TP -unw_word_t table_len - The length of the -unwind\-info (table_data) -counted in units of words -(unw_word_t). -.PP -.TP -unw_word_t table_data - A pointer to the actual -data encoding the unwind\-info. The exact format is -architecture\-specific (see architecture\-specific sections below). -.PP -.SS REMOTE TABLE\-INFO FORMAT -.PP -The remote table\-info format has the same basic purpose as the regular -table\-info format. The only difference is that when libunwind -uses the unwind\-info, it will keep the table data in the target -address\-space (which may be remote). Consequently, the type of the -table_data -member is unw_word_t -rather than a pointer. -This implies that libunwind -will have to access the table\-data -via the address\-space\&'s access_mem() -call\-back, rather than -through a direct memory reference. -.PP -From the point of view of a runtime\-code generator, the remote -table\-info format offers no advantage and it is expected that such -generators will describe their procedures either with the proc\-info -format or the normal table\-info format. The main reason that the -remote table\-info format exists is to enable the -address\-space\-specific find_proc_info() -callback (see -unw_create_addr_space(3)) -to return unwind tables whose -data remains in remote memory. This can speed up unwinding (e.g., for -a debugger) because it reduces the amount of data that needs to be -loaded from remote memory. -.PP -.SH REGIONS DESCRIPTORS - -.PP -A region descriptor is a variable length structure that describes how -each instruction in the region affects the frame state. Of course, -most instructions in a region usualy do not change the frame state and -for those, nothing needs to be recorded in the region descriptor. A -region descriptor is a structure of type -unw_dyn_region_info_t -and has the following members: -.TP -unw_dyn_region_info_t *next - A pointer to the -next region. If this is the last region, next -is NULL\&. -.TP -int32_t insn_count - The length of the region in -instructions. Each instruction is assumed to have a fixed size (see -architecture\-specific sections for details). The value of -insn_count -may be negative in the last region of a procedure -(i.e., it may be negative only if next -is NULL). -A -negative value indicates that the region covers the last \fIN\fP -instructions of the procedure, where \fIN\fP -is the absolute value -of insn_count\&. -.TP -uint32_t op_count - The (allocated) length of -the op_count -array. -.TP -unw_dyn_op_t op - An array of dynamic unwind -directives. See Section ``Dynamic unwind directives\&'' for a -description of the directives. -.PP -A region descriptor with an insn_count -of zero is an -\fIempty region\fP -and such regions are perfectly legal. In fact, -empty regions can be useful to establish a particular frame state -before the start of another region. -.PP -A single region list can be shared across multiple procedures provided -those procedures share a common prologue and epilogue (their bodies -may differ, of course). Normally, such procedures consist of a canned -prologue, the body, and a canned epilogue. This could be described by -two regions: one covering the prologue and one covering the epilogue. -Since the body length is variable, the latter region would need to -specify a negative value in insn_count -such that -libunwind -knows that the region covers the end of the procedure -(up to the address specified by end_ip). -.PP -The region descriptor is a variable length structure to make it -possible to allocate all the necessary memory with a single -memory\-allocation request. To facilitate the allocation of a region -descriptors libunwind -provides a helper routine with the -following synopsis: -.PP -size_t -_U_dyn_region_size(int -op_count); -.PP -This routine returns the number of bytes needed to hold a region -descriptor with space for op_count -unwind directives. Note -that the length of the op -array does not have to match exactly -with the number of directives in a region. Instead, it is sufficient -if the op -array contains at least as many entries as there are -directives, since the end of the directives can always be indicated -with the UNW_DYN_STOP -directive. -.PP -.SH DYNAMIC UNWIND DIRECTIVES - -.PP -A dynamic unwind directive describes how the frame state changes -at a particular point within a region. The description is in -the form of a structure of type unw_dyn_op_t\&. -This -structure has the following members: -.TP -int8_t tag - The operation tag. Must be one -of the unw_dyn_operation_t -values described below. -.TP -int8_t qp - The qualifying predicate that controls -whether or not this directive is active. This is useful for -predicated architecturs such as IA\-64 or ARM, where the contents of -another (callee\-saved) register determines whether or not an -instruction is executed (takes effect). If the directive is always -active, this member should be set to the manifest constant -_U_QP_TRUE -(this constant is defined for all -architectures, predicated or not). -.TP -int16_t reg - The number of the register affected -by the instruction. -.TP -int32_t when - The region\-relative number of -the instruction to which this directive applies. For example, -a value of 0 means that the effect described by this directive -has taken place once the first instruction in the region has -executed. -.TP -unw_word_t val - The value to be applied by the -operation tag. The exact meaning of this value varies by tag. See -Section ``Operation tags\&'' below. -.PP -It is perfectly legitimate to specify multiple dynamic unwind -directives with the same when -value, if a particular instruction -has a complex effect on the frame state. -.PP -Empty regions by definition contain no actual instructions and as such -the directives are not tied to a particular instruction. By -convention, the when -member should be set to 0, however. -.PP -There is no need for the dynamic unwind directives to appear -in order of increasing when -values. If the directives happen to -be sorted in that order, it may result in slightly faster execution, -but a runtime code\-generator should not go to extra lengths just to -ensure that the directives are sorted. -.PP -IMPLEMENTATION NOTE: should libunwind -implementations for -certain architectures prefer the list of unwind directives to be -sorted, it is recommended that such implementations first check -whether the list happens to be sorted already and, if not, sort the -directives explicitly before the first use. With this approach, the -overhead of explicit sorting is only paid when there is a real benefit -and if the runtime code\-generator happens to generated sorted lists -naturally, the performance penalty is limited to a simple O(N) check. -.PP -.SS OPERATIONS TAGS -.PP -The possible operation tags are defined by enumeration type -unw_dyn_operation_t -which defines the following -values: -.PP -.TP -UNW_DYN_STOP - Marks the end of the dynamic unwind -directive list. All remaining entries in the op -array of the -region\-descriptor are ignored. This tag is guaranteed to have a -value of 0. -.PP -.TP -UNW_DYN_SAVE_REG - Marks an instruction which saves -register reg -to register val\&. -.PP -.TP -UNW_DYN_SPILL_FP_REL - Marks an instruction which -spills register reg -to a frame\-pointer\-relative location. The -frame\-pointer\-relative offset is given by the value stored in member -val\&. -See the architecture\-specific sections for a description -of the stack frame layout. -.PP -.TP -UNW_DYN_SPILL_SP_REL - Marks an instruction which -spills register reg -to a stack\-pointer\-relative location. The -stack\-pointer\-relative offset is given by the value stored in member -val\&. -See the architecture\-specific sections for a description -of the stack frame layout. -.PP -.TP -UNW_DYN_ADD - Marks an instruction which adds -the constant value val -to register reg\&. -To add subtract -a constant value, store the two\&'s\-complement of the value in -val\&. -The set of registers that can be specified for this tag -is described in the architecture\-specific sections below. -.PP -.TP -UNW_DYN_POP_FRAMES - .PP -.TP -UNW_DYN_LABEL_STATE - .PP -.TP -UNW_DYN_COPY_STATE - .PP -.TP -UNW_DYN_ALIAS - .PP -unw_dyn_op_t -.PP -_U_dyn_op_save_reg(); -_U_dyn_op_spill_fp_rel(); -_U_dyn_op_spill_sp_rel(); -_U_dyn_op_add(); -_U_dyn_op_pop_frames(); -_U_dyn_op_label_state(); -_U_dyn_op_copy_state(); -_U_dyn_op_alias(); -_U_dyn_op_stop(); -.PP -.SH IA\-64 SPECIFICS - -.PP -\- meaning of segbase member in table\-info/table\-remote\-info format -\- format of table_data in table\-info/table\-remote\-info format -\- instruction size: each bundle is counted as 3 instructions, regardless -of template (MLX) -\- describe stack\-frame layout, especially with regards to sp\-relative -and fp\-relative addressing -\- UNW_DYN_ADD can only add to ``sp\&'' (always a negative value); use -POP_FRAMES otherwise -.PP -.SH SEE ALSO - -.PP -libunwind(3), -_U_dyn_register(3), -_U_dyn_cancel(3) -.PP -.SH AUTHOR - -.PP -David Mosberger\-Tang -.br -Email: \fBdmosberger@gmail.com\fP -.br -WWW: \fBhttp://www.nongnu.org/libunwind/\fP\&. -.\" NOTE: This file is generated, DO NOT EDIT. diff --git a/src/pal/src/libunwind/doc/libunwind-dynamic.tex b/src/pal/src/libunwind/doc/libunwind-dynamic.tex deleted file mode 100644 index 21e895a34..000000000 --- a/src/pal/src/libunwind/doc/libunwind-dynamic.tex +++ /dev/null @@ -1,401 +0,0 @@ -\documentclass{article} -\usepackage[fancyhdr,pdf]{latex2man} - -\input{common.tex} - -\begin{document} - -\begin{Name}{3}{libunwind-dynamic}{David Mosberger-Tang}{Programming Library}{Introduction to dynamic unwind-info}libunwind-dynamic -- libunwind-support for runtime-generated code -\end{Name} - -\section{Introduction} - -For \Prog{libunwind} to do its job, it needs to be able to reconstruct -the \emph{frame state} of each frame in a call-chain. The frame state -describes the subset of the machine-state that consists of the -\emph{frame registers} (typically the instruction-pointer and the -stack-pointer) and all callee-saved registers (preserved registers). -The frame state describes each register either by providing its -current value (for frame registers) or by providing the location at -which the current value is stored (callee-saved registers). - -For statically generated code, the compiler normally takes care of -emitting \emph{unwind-info} which provides the minimum amount of -information needed to reconstruct the frame-state for each instruction -in a procedure. For dynamically generated code, the runtime code -generator must use the dynamic unwind-info interface provided by -\Prog{libunwind} to supply the equivalent information. This manual -page describes the format of this information in detail. - -For the purpose of this discussion, a \emph{procedure} is defined to -be an arbitrary piece of \emph{contiguous} code. Normally, each -procedure directly corresponds to a function in the source-language -but this is not strictly required. For example, a runtime -code-generator could translate a given function into two separate -(discontiguous) procedures: one for frequently-executed (hot) code and -one for rarely-executed (cold) code. Similarly, simple -source-language functions (usually leaf functions) may get translated -into code for which the default unwind-conventions apply and for such -code, it is not strictly necessary to register dynamic unwind-info. - -A procedure logically consists of a sequence of \emph{regions}. -Regions are nested in the sense that the frame state at the end of one -region is, by default, assumed to be the frame state for the next -region. Each region is thought of as being divided into a -\emph{prologue}, a \emph{body}, and an \emph{epilogue}. Each of them -can be empty. If non-empty, the prologue sets up the frame state for -the body. For example, the prologue may need to allocate some space -on the stack and save certain callee-saved registers. The body -performs the actual work of the procedure but does not change the -frame state in any way. If non-empty, the epilogue restores the -previous frame state and as such it undoes or cancels the effect of -the prologue. In fact, a single epilogue may undo the effect of the -prologues of several (nested) regions. - -We should point out that even though the prologue, body, and epilogue -are logically separate entities, optimizing code-generators will -generally interleave instructions from all three entities. For this -reason, the dynamic unwind-info interface of \Prog{libunwind} makes no -distinction whatsoever between prologue and body. Similarly, the -exact set of instructions that make up an epilogue is also irrelevant. -The only point in the epilogue that needs to be described explicitly -by the dynamic unwind-info is the point at which the stack-pointer -gets restored. The reason this point needs to be described is that -once the stack-pointer is restored, all values saved in the -deallocated portion of the stack frame become invalid and hence -\Prog{libunwind} needs to know about it. The portion of the frame -state not saved on the stack is assume to remain valid through the end -of the region. For this reason, there is usually no need to describe -instructions which restore the contents of callee-saved registers. - -Within a region, each instruction that affects the frame state in some -fashion needs to be described with an operation descriptor. For this -purpose, each instruction in the region is assigned a unique index. -Exactly how this index is derived depends on the architecture. For -example, on RISC and EPIC-style architecture, instructions have a -fixed size so it's possible to simply number the instructions. In -contrast, most CISC use variable-length instruction encodings, so it -is usually necessary to use a byte-offset as the index. Given the -instruction index, the operation descriptor specifies the effect of -the instruction in an abstract manner. For example, it might express -that the instruction stores calle-saved register \Var{r1} at offset 16 -in the stack frame. - -\section{Procedures} - -A runtime code-generator registers the dynamic unwind-info of a -procedure by setting up a structure of type \Type{unw\_dyn\_info\_t} -and calling \Func{\_U\_dyn\_register}(), passing the address of the -structure as the sole argument. The members of the -\Type{unw\_dyn\_info\_t} structure are described below: -\begin{itemize} -\item[\Type{void~*}next] Private to \Prog{libunwind}. Must not be used - by the application. -\item[\Type{void~*}prev] Private to \Prog{libunwind}. Must not be used - by the application. -\item[\Type{unw\_word\_t} \Var{start\_ip}] The start-address of the - instructions of the procedure (remember: procedure are defined to be - contiguous pieces of code, so a single code-range is sufficient). -\item[\Type{unw\_word\_t} \Var{end\_ip}] The end-address of the - instructions of the procedure (non-inclusive, that is, - \Var{end\_ip}-\Var{start\_ip} is the size of the procedure in - bytes). -\item[\Type{unw\_word\_t} \Var{gp}] The global-pointer value in use - for this procedure. The exact meaing of the global-pointer is - architecture-specific and on some architecture, it is not used at - all. -\item[\Type{int32\_t} \Var{format}] The format of the unwind-info. - This member can be one of \Const{UNW\_INFO\_FORMAT\_DYNAMIC}, - \Const{UNW\_INFO\_FORMAT\_TABLE}, or - \Const{UNW\_INFO\_FORMAT\_REMOTE\_TABLE}. -\item[\Type{union} \Var{u}] This union contains one sub-member - structure for every possible unwind-info format: - \begin{description} - \item[\Type{unw\_dyn\_proc\_info\_t} \Var{pi}] This member is used - for format \Const{UNW\_INFO\_FORMAT\_DYNAMIC}. - \item[\Type{unw\_dyn\_table\_info\_t} \Var{ti}] This member is used - for format \Const{UNW\_INFO\_FORMAT\_TABLE}. - \item[\Type{unw\_dyn\_remote\_table\_info\_t} \Var{rti}] This member - is used for format \Const{UNW\_INFO\_FORMAT\_REMOTE\_TABLE}. - \end{description}\ - The format of these sub-members is described in detail below. -\end{itemize} - -\subsection{Proc-info format} - -This is the preferred dynamic unwind-info format and it is generally -the one used by full-blown runtime code-generators. In this format, -the details of a procedure are described by a structure of type -\Type{unw\_dyn\_proc\_info\_t}. This structure contains the following -members: -\begin{description} - -\item[\Type{unw\_word\_t} \Var{name\_ptr}] The address of a - (human-readable) name of the procedure or 0 if no such name is - available. If non-zero, The string stored at this address must be - ASCII NUL terminated. For source languages that use name-mangling - (such as C++ or Java) the string stored at this address should be - the \emph{demangled} version of the name. - -\item[\Type{unw\_word\_t} \Var{handler}] The address of the - personality-routine for this procedure. Personality-routines are - used in conjunction with exception handling. See the C++ ABI draft - (http://www.codesourcery.com/cxx-abi/) for an overview and a - description of the personality routine. If the procedure has no - personality routine, \Var{handler} must be set to 0. - -\item[\Type{uint32\_t} \Var{flags}] A bitmask of flags. At the - moment, no flags have been defined and this member must be - set to 0. - -\item[\Type{unw\_dyn\_region\_info\_t~*}\Var{regions}] A NULL-terminated - linked list of region-descriptors. See section ``Region - descriptors'' below for more details. - -\end{description} - -\subsection{Table-info format} - -This format is generally used when the dynamically generated code was -derived from static code and the unwind-info for the dynamic and the -static versions is identical. For example, this format can be useful -when loading statically-generated code into an address-space in a -non-standard fashion (i.e., through some means other than -\Func{dlopen}()). In this format, the details of a group of procedures -is described by a structure of type \Type{unw\_dyn\_table\_info}. -This structure contains the following members: -\begin{description} - -\item[\Type{unw\_word\_t} \Var{name\_ptr}] The address of a - (human-readable) name of the procedure or 0 if no such name is - available. If non-zero, The string stored at this address must be - ASCII NUL terminated. For source languages that use name-mangling - (such as C++ or Java) the string stored at this address should be - the \emph{demangled} version of the name. - -\item[\Type{unw\_word\_t} \Var{segbase}] The segment-base value - that needs to be added to the segment-relative values stored in the - unwind-info. The exact meaning of this value is - architecture-specific. - -\item[\Type{unw\_word\_t} \Var{table\_len}] The length of the - unwind-info (\Var{table\_data}) counted in units of words - (\Type{unw\_word\_t}). - -\item[\Type{unw\_word\_t} \Var{table\_data}] A pointer to the actual - data encoding the unwind-info. The exact format is - architecture-specific (see architecture-specific sections below). - -\end{description} - -\subsection{Remote table-info format} - -The remote table-info format has the same basic purpose as the regular -table-info format. The only difference is that when \Prog{libunwind} -uses the unwind-info, it will keep the table data in the target -address-space (which may be remote). Consequently, the type of the -\Var{table\_data} member is \Type{unw\_word\_t} rather than a pointer. -This implies that \Prog{libunwind} will have to access the table-data -via the address-space's \Func{access\_mem}() call-back, rather than -through a direct memory reference. - -From the point of view of a runtime-code generator, the remote -table-info format offers no advantage and it is expected that such -generators will describe their procedures either with the proc-info -format or the normal table-info format. The main reason that the -remote table-info format exists is to enable the -address-space-specific \Func{find\_proc\_info}() callback (see -\SeeAlso{unw\_create\_addr\_space}(3)) to return unwind tables whose -data remains in remote memory. This can speed up unwinding (e.g., for -a debugger) because it reduces the amount of data that needs to be -loaded from remote memory. - -\section{Regions descriptors} - -A region descriptor is a variable length structure that describes how -each instruction in the region affects the frame state. Of course, -most instructions in a region usualy do not change the frame state and -for those, nothing needs to be recorded in the region descriptor. A -region descriptor is a structure of type -\Type{unw\_dyn\_region\_info\_t} and has the following members: -\begin{description} -\item[\Type{unw\_dyn\_region\_info\_t~*}\Var{next}] A pointer to the - next region. If this is the last region, \Var{next} is \Const{NULL}. -\item[\Type{int32\_t} \Var{insn\_count}] The length of the region in - instructions. Each instruction is assumed to have a fixed size (see - architecture-specific sections for details). The value of - \Var{insn\_count} may be negative in the last region of a procedure - (i.e., it may be negative only if \Var{next} is \Const{NULL}). A - negative value indicates that the region covers the last \emph{N} - instructions of the procedure, where \emph{N} is the absolute value - of \Var{insn\_count}. -\item[\Type{uint32\_t} \Var{op\_count}] The (allocated) length of - the \Var{op\_count} array. -\item[\Type{unw\_dyn\_op\_t} \Var{op}] An array of dynamic unwind - directives. See Section ``Dynamic unwind directives'' for a - description of the directives. -\end{description} -A region descriptor with an \Var{insn\_count} of zero is an -\emph{empty region} and such regions are perfectly legal. In fact, -empty regions can be useful to establish a particular frame state -before the start of another region. - -A single region list can be shared across multiple procedures provided -those procedures share a common prologue and epilogue (their bodies -may differ, of course). Normally, such procedures consist of a canned -prologue, the body, and a canned epilogue. This could be described by -two regions: one covering the prologue and one covering the epilogue. -Since the body length is variable, the latter region would need to -specify a negative value in \Var{insn\_count} such that -\Prog{libunwind} knows that the region covers the end of the procedure -(up to the address specified by \Var{end\_ip}). - -The region descriptor is a variable length structure to make it -possible to allocate all the necessary memory with a single -memory-allocation request. To facilitate the allocation of a region -descriptors \Prog{libunwind} provides a helper routine with the -following synopsis: - -\noindent -\Type{size\_t} \Func{\_U\_dyn\_region\_size}(\Type{int} \Var{op\_count}); - -This routine returns the number of bytes needed to hold a region -descriptor with space for \Var{op\_count} unwind directives. Note -that the length of the \Var{op} array does not have to match exactly -with the number of directives in a region. Instead, it is sufficient -if the \Var{op} array contains at least as many entries as there are -directives, since the end of the directives can always be indicated -with the \Const{UNW\_DYN\_STOP} directive. - -\section{Dynamic unwind directives} - -A dynamic unwind directive describes how the frame state changes -at a particular point within a region. The description is in -the form of a structure of type \Type{unw\_dyn\_op\_t}. This -structure has the following members: -\begin{description} -\item[\Type{int8\_t} \Var{tag}] The operation tag. Must be one - of the \Type{unw\_dyn\_operation\_t} values described below. -\item[\Type{int8\_t} \Var{qp}] The qualifying predicate that controls - whether or not this directive is active. This is useful for - predicated architecturs such as IA-64 or ARM, where the contents of - another (callee-saved) register determines whether or not an - instruction is executed (takes effect). If the directive is always - active, this member should be set to the manifest constant - \Const{\_U\_QP\_TRUE} (this constant is defined for all - architectures, predicated or not). -\item[\Type{int16\_t} \Var{reg}] The number of the register affected - by the instruction. -\item[\Type{int32\_t} \Var{when}] The region-relative number of - the instruction to which this directive applies. For example, - a value of 0 means that the effect described by this directive - has taken place once the first instruction in the region has - executed. -\item[\Type{unw\_word\_t} \Var{val}] The value to be applied by the - operation tag. The exact meaning of this value varies by tag. See - Section ``Operation tags'' below. -\end{description} -It is perfectly legitimate to specify multiple dynamic unwind -directives with the same \Var{when} value, if a particular instruction -has a complex effect on the frame state. - -Empty regions by definition contain no actual instructions and as such -the directives are not tied to a particular instruction. By -convention, the \Var{when} member should be set to 0, however. - -There is no need for the dynamic unwind directives to appear -in order of increasing \Var{when} values. If the directives happen to -be sorted in that order, it may result in slightly faster execution, -but a runtime code-generator should not go to extra lengths just to -ensure that the directives are sorted. - -IMPLEMENTATION NOTE: should \Prog{libunwind} implementations for -certain architectures prefer the list of unwind directives to be -sorted, it is recommended that such implementations first check -whether the list happens to be sorted already and, if not, sort the -directives explicitly before the first use. With this approach, the -overhead of explicit sorting is only paid when there is a real benefit -and if the runtime code-generator happens to generated sorted lists -naturally, the performance penalty is limited to a simple O(N) check. - -\subsection{Operations tags} - -The possible operation tags are defined by enumeration type -\Type{unw\_dyn\_operation\_t} which defines the following -values: -\begin{description} - -\item[\Const{UNW\_DYN\_STOP}] Marks the end of the dynamic unwind - directive list. All remaining entries in the \Var{op} array of the - region-descriptor are ignored. This tag is guaranteed to have a - value of 0. - -\item[\Const{UNW\_DYN\_SAVE\_REG}] Marks an instruction which saves - register \Var{reg} to register \Var{val}. - -\item[\Const{UNW\_DYN\_SPILL\_FP\_REL}] Marks an instruction which - spills register \Var{reg} to a frame-pointer-relative location. The - frame-pointer-relative offset is given by the value stored in member - \Var{val}. See the architecture-specific sections for a description - of the stack frame layout. - -\item[\Const{UNW\_DYN\_SPILL\_SP\_REL}] Marks an instruction which - spills register \Var{reg} to a stack-pointer-relative location. The - stack-pointer-relative offset is given by the value stored in member - \Var{val}. See the architecture-specific sections for a description - of the stack frame layout. - -\item[\Const{UNW\_DYN\_ADD}] Marks an instruction which adds - the constant value \Var{val} to register \Var{reg}. To add subtract - a constant value, store the two's-complement of the value in - \Var{val}. The set of registers that can be specified for this tag - is described in the architecture-specific sections below. - -\item[\Const{UNW\_DYN\_POP\_FRAMES}] - -\item[\Const{UNW\_DYN\_LABEL\_STATE}] - -\item[\Const{UNW\_DYN\_COPY\_STATE}] - -\item[\Const{UNW\_DYN\_ALIAS}] - -\end{description} - -unw\_dyn\_op\_t - -\_U\_dyn\_op\_save\_reg(); -\_U\_dyn\_op\_spill\_fp\_rel(); -\_U\_dyn\_op\_spill\_sp\_rel(); -\_U\_dyn\_op\_add(); -\_U\_dyn\_op\_pop\_frames(); -\_U\_dyn\_op\_label\_state(); -\_U\_dyn\_op\_copy\_state(); -\_U\_dyn\_op\_alias(); -\_U\_dyn\_op\_stop(); - -\section{IA-64 specifics} - -- meaning of segbase member in table-info/table-remote-info format -- format of table\_data in table-info/table-remote-info format -- instruction size: each bundle is counted as 3 instructions, regardless - of template (MLX) -- describe stack-frame layout, especially with regards to sp-relative - and fp-relative addressing -- UNW\_DYN\_ADD can only add to ``sp'' (always a negative value); use - POP\_FRAMES otherwise - -\section{See Also} - -\SeeAlso{libunwind(3)}, -\SeeAlso{\_U\_dyn\_register(3)}, -\SeeAlso{\_U\_dyn\_cancel(3)} - -\section{Author} - -\noindent -David Mosberger-Tang\\ -Email: \Email{dmosberger@gmail.com}\\ -WWW: \URL{http://www.nongnu.org/libunwind/}. -\LatexManEnd - -\end{document} diff --git a/src/pal/src/libunwind/doc/libunwind-ia64.man b/src/pal/src/libunwind/doc/libunwind-ia64.man deleted file mode 100644 index 06b141eb3..000000000 --- a/src/pal/src/libunwind/doc/libunwind-ia64.man +++ /dev/null @@ -1,314 +0,0 @@ -'\" t -.\" Manual page created with latex2man on Thu Aug 16 09:44:44 MDT 2007 -.\" NOTE: This file is generated, DO NOT EDIT. -.de Vb -.ft CW -.nf -.. -.de Ve -.ft R - -.fi -.. -.TH "LIBUNWIND\-IA64" "3" "16 August 2007" "Programming Library " "Programming Library " -.SH NAME -libunwind\-ia64 -\-\- IA\-64\-specific support in libunwind -.PP -.SH INTRODUCTION - -.PP -The IA\-64 version of libunwind -uses a platform\-string of -ia64 -and, at least in theory, should be able to support all -operating systems adhering to the processor\-specific ABI defined for -the Itanium Processor Family. This includes both little\-endian Linux -and big\-endian HP\-UX. Furthermore, to make it possible for a single -library to unwind both 32\- and 64\-bit targets, the type -unw_word_t -is always defined to be 64 bits wide (independent -of the natural word\-size of the host). Having said that, the current -implementation has been tested only with IA\-64 Linux. -.PP -When targeting IA\-64, the libunwind -header file defines the -macro UNW_TARGET_IA64 -as 1 and the macro UNW_TARGET -as ``ia64\&'' (without the quotation marks). The former makes it -possible for platform\-dependent unwind code to use -conditional\-compilation to select an appropriate implementation. The -latter is useful for stringification purposes and to construct -target\-platform\-specific symbols. -.PP -One special feature of IA\-64 is the use of NaT bits to support -speculative execution. Often, NaT bits are thought of as the ``65\-th -bit\&'' of a general register. However, to make everything fit into -64\-bit wide unw_word_t -values, libunwind -treats the -NaT\-bits like separate boolean registers, whose 64\-bit value is either -TRUE (non\-zero) or FALSE (zero). -.PP -.SH MACHINE\-STATE - -.PP -The machine\-state (set of registers) that is accessible through -libunwind -depends on the type of stack frame that a cursor -points to. For normal frames, all ``preserved\&'' (callee\-saved) -registers are accessible. For signal\-trampoline frames, all registers -(including ``scratch\&'' (caller\-saved) registers) are accessible. Most -applications do not have to worry a\-priori about which registers are -accessible when. In case of doubt, it is always safe to \fItry\fP -to -access a register (via unw_get_reg() -or -unw_get_fpreg()) -and if the register isn\&'t accessible, the -call will fail with a return\-value of \-UNW_EBADREG\&. -.PP -As a special exception to the above general rule, scratch registers -r15\-r18 -are always accessible, even in normal -frames. This makes it possible to pass arguments, e.g., to exception -handlers. -.PP -For a detailed description of the IA\-64 register usage convention, -please see the ``Itanium Software Conventions and Runtime Architecture -Guide\&'', available at: -.ce 100 -\fBhttp://www.intel.com/design/itanium/downloads/245358.htm\fP -.ce 0 - -.PP -.SH REGISTER NAMES - -.PP -The IA\-64\-version of libunwind -defines three kinds of register -name macros: frame\-register macros, normal register macros, and -convenience macros. Below, we describe each kind in turn: -.PP -.SS FRAME\-REGISTER MACROS -.PP -Frame\-registers are special (pseudo) registers because they always -have a valid value, even though sometimes they do not get saved -explicitly (e.g., if a memory stack frame is 16 bytes in size, the -previous stack\-pointer value can be calculated simply as -sp+16, -so there is no need to save the stack\-pointer -explicitly). Moreover, the set of frame register values uniquely -identifies a stack frame. The IA\-64 architecture defines two stacks -(a memory and a register stack). Including the instruction\-pointer -(IP), this means there are three frame registers: -.TP -UNW_IA64_IP: - Contains the instruction pointer (IP, or -``program counter\&'') of the current stack frame. Given this value, -the remaining machine\-state corresponds to the register\-values that -were present in the CPU when it was just about to execute the -instruction pointed to by UNW_IA64_IP\&. -Bits 0 and 1 of -this frame\-register encode the slot number of the instruction. -\fBNote:\fP -Due to the way the call instruction works on IA\-64, -the slot number is usually zero, but can be non\-zero, e.g., in the -stack\-frame of a signal\-handler trampoline. -.TP -UNW_IA64_SP: - Contains the (memory) stack\-pointer -value (SP). -.TP -UNW_IA64_BSP: - Contains the register backing\-store -pointer (BSP). \fBNote:\fP -the value in this register is equal -to the contents of register ar.bsp -at the time the -instruction at UNW_IA64_IP -was about to begin execution. -.PP -.SS NORMAL REGISTER MACROS -.PP -The following normal register name macros are available: -.TP -UNW_IA64_GR: - The base\-index for general (integer) -registers. Add an index in the range from 0..127 to get a -particular general register. For example, to access r4, -the index UNW_IA64_GR+4 -should be used. -Registers r0 -and r1 -(gp) -are read\-only, -and any attempt to write them will result in an error -(\-UNW_EREADONLYREG). -Even though r1 -is -read\-only, libunwind -will automatically adjust its value if -the instruction\-pointer (UNW_IA64_IP) -is modified. For -example, if UNW_IA64_IP -is set to a value inside a -function func(), -then reading -UNW_IA64_GR+1 -will return the global\-pointer -value for this function. -.TP -UNW_IA64_NAT: - The base\-index for the NaT bits of the -general (integer) registers. A non\-zero value in these registers -corresponds to a set NaT\-bit. Add an index in the range from 0..127 -to get a particular NaT\-bit register. For example, to access the -NaT bit of r4, -the index UNW_IA64_NAT+4 -should be used. -.TP -UNW_IA64_FR: - The base\-index for floating\-point -registers. Add an index in the range from 0..127 to get a -particular floating\-point register. For example, to access -f2, -the index UNW_IA64_FR+2 -should be -used. Registers f0 -and f1 -are read\-only, and any -attempt to write to indices UNW_IA64_FR+0 -or -UNW_IA64_FR+1 -will result in an error -(\-UNW_EREADONLYREG). -.TP -UNW_IA64_AR: - The base\-index for application -registers. Add an index in the range from 0..127 to get a -particular application register. For example, to access -ar40, -the index UNW_IA64_AR+40 -should be -used. The IA\-64 architecture defines several application registers -as ``reserved for future use\&''\&. Attempting to access such registers -results in an error (\-UNW_EBADREG). -.TP -UNW_IA64_BR: - The base\-index for branch registers. -Add an index in the range from 0..7 to get a particular branch -register. For example, to access b6, -the index -UNW_IA64_BR+6 -should be used. -.TP -UNW_IA64_PR: - Contains the set of predicate registers. -This 64\-bit wide register contains registers p0 -through -p63 -in the ``broad\-side\&'' format. Just like with the -``move predicates\&'' instruction, the registers are mapped as if -CFM.rrb.pr -were set to 0. Thus, in general the value of -predicate register pN -with N>=16 can be found -in bit 16 + ((N\-16)+CFM.rrb.pr) % 48\&. -.TP -UNW_IA64_CFM: - Contains the current\-frame\-mask -register. -.PP -.SS CONVENIENCE MACROS -.PP -Convenience macros are simply aliases for certain frequently used -registers: -.TP -UNW_IA64_GP: - Alias for UNW_IA64_GR+1, -the global\-pointer register. -.TP -UNW_IA64_TP: - Alias for UNW_IA64_GR+13, -the thread\-pointer register. -.TP -UNW_IA64_AR_RSC: - Alias for UNW_IA64_GR+16, -the register\-stack configuration register. -.TP -UNW_IA64_AR_BSP: - Alias for -UNW_IA64_GR+17\&. -This register index accesses the -value of register ar.bsp -as of the time it was last saved -explicitly. This is rarely what you want. Normally, you\&'ll want to -use UNW_IA64_BSP -instead. -.TP -UNW_IA64_AR_BSPSTORE: - Alias for UNW_IA64_GR+18, -the register\-backing store write pointer. -.TP -UNW_IA64_AR_RNAT: - Alias for UNW_IA64_GR+19, -the register\-backing store NaT\-collection register. -.TP -UNW_IA64_AR_CCV: - Alias for UNW_IA64_GR+32, -the compare\-and\-swap value register. -.TP -UNW_IA64_AR_CSD: - Alias for UNW_IA64_GR+25, -the compare\-and\-swap\-data register (used by 16\-byte atomic operations). -.TP -UNW_IA64_AR_UNAT: - Alias for UNW_IA64_GR+36, -the user NaT\-collection register. -.TP -UNW_IA64_AR_FPSR: - Alias for UNW_IA64_GR+40, -the floating\-point status (and control) register. -.TP -UNW_IA64_AR_PFS: - Alias for UNW_IA64_GR+64, -the previous frame\-state register. -.TP -UNW_IA64_AR_LC: - Alias for UNW_IA64_GR+65 -the loop\-count register. -.TP -UNW_IA64_AR_EC: - Alias for UNW_IA64_GR+66, -the epilogue\-count register. -.PP -.SH THE UNWIND\-CONTEXT TYPE - -.PP -On IA\-64, unw_context_t -is simply an alias for -ucontext_t -(as defined by the Single UNIX Spec). This implies -that it is possible to initialize a value of this type not just with -unw_getcontext(), -but also with getcontext(), -for -example. However, since this is an IA\-64\-specific extension to -libunwind, -portable code should not rely on this equivalence. -.PP -.SH SEE ALSO - -.PP -libunwind(3) -.PP -.SH AUTHOR - -.PP -David Mosberger\-Tang -.br -Email: \fBdmosberger@gmail.com\fP -.br -WWW: \fBhttp://www.nongnu.org/libunwind/\fP\&. -.\" NOTE: This file is generated, DO NOT EDIT. diff --git a/src/pal/src/libunwind/doc/libunwind-ia64.tex b/src/pal/src/libunwind/doc/libunwind-ia64.tex deleted file mode 100644 index c08946dc4..000000000 --- a/src/pal/src/libunwind/doc/libunwind-ia64.tex +++ /dev/null @@ -1,216 +0,0 @@ -\documentclass{article} -\usepackage[fancyhdr,pdf]{latex2man} - -\input{common.tex} - -\begin{document} - -\begin{Name}{3}{libunwind-ia64}{David Mosberger-Tang}{Programming Library}{IA-64-specific support in libunwind}libunwind-ia64 -- IA-64-specific support in libunwind -\end{Name} - - -\section{Introduction} - -The IA-64 version of \Prog{libunwind} uses a platform-string of -\texttt{ia64} and, at least in theory, should be able to support all -operating systems adhering to the processor-specific ABI defined for -the Itanium Processor Family. This includes both little-endian Linux -and big-endian HP-UX. Furthermore, to make it possible for a single -library to unwind both 32- and 64-bit targets, the type -\Type{unw\_word\_t} is always defined to be 64 bits wide (independent -of the natural word-size of the host). Having said that, the current -implementation has been tested only with IA-64 Linux. - -When targeting IA-64, the \Prog{libunwind} header file defines the -macro \Const{UNW\_TARGET\_IA64} as 1 and the macro \Const{UNW\_TARGET} -as ``ia64'' (without the quotation marks). The former makes it -possible for platform-dependent unwind code to use -conditional-compilation to select an appropriate implementation. The -latter is useful for stringification purposes and to construct -target-platform-specific symbols. - -One special feature of IA-64 is the use of NaT bits to support -speculative execution. Often, NaT bits are thought of as the ``65-th -bit'' of a general register. However, to make everything fit into -64-bit wide \Type{unw\_word\_t} values, \Prog{libunwind} treats the -NaT-bits like separate boolean registers, whose 64-bit value is either -TRUE (non-zero) or FALSE (zero). - - -\section{Machine-State} - -The machine-state (set of registers) that is accessible through -\Prog{libunwind} depends on the type of stack frame that a cursor -points to. For normal frames, all ``preserved'' (callee-saved) -registers are accessible. For signal-trampoline frames, all registers -(including ``scratch'' (caller-saved) registers) are accessible. Most -applications do not have to worry a-priori about which registers are -accessible when. In case of doubt, it is always safe to \emph{try} to -access a register (via \Func{unw\_get\_reg}() or -\Func{unw\_get\_fpreg}()) and if the register isn't accessible, the -call will fail with a return-value of \texttt{-}\Const{UNW\_EBADREG}. - -As a special exception to the above general rule, scratch registers -\texttt{r15}-\texttt{r18} are always accessible, even in normal -frames. This makes it possible to pass arguments, e.g., to exception -handlers. - -For a detailed description of the IA-64 register usage convention, -please see the ``Itanium Software Conventions and Runtime Architecture -Guide'', available at: -\begin{center} - \URL{http://www.intel.com/design/itanium/downloads/245358.htm} -\end{center} - - -\section{Register Names} - -The IA-64-version of \Prog{libunwind} defines three kinds of register -name macros: frame-register macros, normal register macros, and -convenience macros. Below, we describe each kind in turn: - - -\subsection{Frame-register Macros} - -Frame-registers are special (pseudo) registers because they always -have a valid value, even though sometimes they do not get saved -explicitly (e.g., if a memory stack frame is 16 bytes in size, the -previous stack-pointer value can be calculated simply as -\texttt{sp+16}, so there is no need to save the stack-pointer -explicitly). Moreover, the set of frame register values uniquely -identifies a stack frame. The IA-64 architecture defines two stacks -(a memory and a register stack). Including the instruction-pointer -(IP), this means there are three frame registers: -\begin{Description} -\item[\Const{UNW\_IA64\_IP}:] Contains the instruction pointer (IP, or - ``program counter'') of the current stack frame. Given this value, - the remaining machine-state corresponds to the register-values that - were present in the CPU when it was just about to execute the - instruction pointed to by \Const{UNW\_IA64\_IP}. Bits 0 and 1 of - this frame-register encode the slot number of the instruction. - \textbf{Note:} Due to the way the call instruction works on IA-64, - the slot number is usually zero, but can be non-zero, e.g., in the - stack-frame of a signal-handler trampoline. -\item[\Const{UNW\_IA64\_SP}:] Contains the (memory) stack-pointer - value (SP). -\item[\Const{UNW\_IA64\_BSP}:] Contains the register backing-store - pointer (BSP). \textbf{Note:} the value in this register is equal - to the contents of register \texttt{ar.bsp} at the time the - instruction at \Const{UNW\_IA64\_IP} was about to begin execution. -\end{Description} - - -\subsection{Normal Register Macros} - -The following normal register name macros are available: -\begin{Description} -\item[\Const{UNW\_IA64\_GR}:] The base-index for general (integer) - registers. Add an index in the range from 0..127 to get a - particular general register. For example, to access \texttt{r4}, - the index \Const{UNW\_IA64\_GR}\texttt{+4} should be used. - Registers \texttt{r0} and \texttt{r1} (\texttt{gp}) are read-only, - and any attempt to write them will result in an error - (\texttt{-}\Const{UNW\_EREADONLYREG}). Even though \texttt{r1} is - read-only, \Prog{libunwind} will automatically adjust its value if - the instruction-pointer (\Const{UNW\_IA64\_IP}) is modified. For - example, if \Const{UNW\_IA64\_IP} is set to a value inside a - function \Func{func}(), then reading - \Const{UNW\_IA64\_GR}\texttt{+1} will return the global-pointer - value for this function. -\item[\Const{UNW\_IA64\_NAT}:] The base-index for the NaT bits of the - general (integer) registers. A non-zero value in these registers - corresponds to a set NaT-bit. Add an index in the range from 0..127 - to get a particular NaT-bit register. For example, to access the - NaT bit of \texttt{r4}, the index \Const{UNW\_IA64\_NAT}\texttt{+4} - should be used. -\item[\Const{UNW\_IA64\_FR}:] The base-index for floating-point - registers. Add an index in the range from 0..127 to get a - particular floating-point register. For example, to access - \texttt{f2}, the index \Const{UNW\_IA64\_FR}\texttt{+2} should be - used. Registers \texttt{f0} and \texttt{f1} are read-only, and any - attempt to write to indices \Const{UNW\_IA64\_FR}\texttt{+0} or - \Const{UNW\_IA64\_FR}\texttt{+1} will result in an error - (\texttt{-}\Const{UNW\_EREADONLYREG}). -\item[\Const{UNW\_IA64\_AR}:] The base-index for application - registers. Add an index in the range from 0..127 to get a - particular application register. For example, to access - \texttt{ar40}, the index \Const{UNW\_IA64\_AR}\texttt{+40} should be - used. The IA-64 architecture defines several application registers - as ``reserved for future use''. Attempting to access such registers - results in an error (\texttt{-}\Const{UNW\_EBADREG}). -\item[\Const{UNW\_IA64\_BR}:] The base-index for branch registers. - Add an index in the range from 0..7 to get a particular branch - register. For example, to access \texttt{b6}, the index - \Const{UNW\_IA64\_BR}\texttt{+6} should be used. -\item[\Const{UNW\_IA64\_PR}:] Contains the set of predicate registers. - This 64-bit wide register contains registers \texttt{p0} through - \texttt{p63} in the ``broad-side'' format. Just like with the - ``move predicates'' instruction, the registers are mapped as if - \texttt{CFM.rrb.pr} were set to 0. Thus, in general the value of - predicate register \texttt{p}$N$ with $N$>=16 can be found - in bit \texttt{16 + (($N$-16)+CFM.rrb.pr) \% 48}. -\item[\Const{UNW\_IA64\_CFM}:] Contains the current-frame-mask - register. -\end{Description} - - -\subsection{Convenience Macros} - -Convenience macros are simply aliases for certain frequently used -registers: -\begin{Description} -\item[\Const{UNW\_IA64\_GP}:] Alias for \Const{UNW\_IA64\_GR}\texttt{+1}, - the global-pointer register. -\item[\Const{UNW\_IA64\_TP}:] Alias for \Const{UNW\_IA64\_GR}\texttt{+13}, - the thread-pointer register. -\item[\Const{UNW\_IA64\_AR\_RSC}:] Alias for \Const{UNW\_IA64\_GR}\texttt{+16}, - the register-stack configuration register. -\item[\Const{UNW\_IA64\_AR\_BSP}:] Alias for - \Const{UNW\_IA64\_GR}\texttt{+17}. This register index accesses the - value of register \texttt{ar.bsp} as of the time it was last saved - explicitly. This is rarely what you want. Normally, you'll want to - use \Const{UNW\_IA64\_BSP} instead. -\item[\Const{UNW\_IA64\_AR\_BSPSTORE}:] Alias for \Const{UNW\_IA64\_GR}\texttt{+18}, - the register-backing store write pointer. -\item[\Const{UNW\_IA64\_AR\_RNAT}:] Alias for \Const{UNW\_IA64\_GR}\texttt{+19}, - the register-backing store NaT-collection register. -\item[\Const{UNW\_IA64\_AR\_CCV}:] Alias for \Const{UNW\_IA64\_GR}\texttt{+32}, - the compare-and-swap value register. -\item[\Const{UNW\_IA64\_AR\_CSD}:] Alias for \Const{UNW\_IA64\_GR}\texttt{+25}, - the compare-and-swap-data register (used by 16-byte atomic operations). -\item[\Const{UNW\_IA64\_AR\_UNAT}:] Alias for \Const{UNW\_IA64\_GR}\texttt{+36}, - the user NaT-collection register. -\item[\Const{UNW\_IA64\_AR\_FPSR}:] Alias for \Const{UNW\_IA64\_GR}\texttt{+40}, - the floating-point status (and control) register. -\item[\Const{UNW\_IA64\_AR\_PFS}:] Alias for \Const{UNW\_IA64\_GR}\texttt{+64}, - the previous frame-state register. -\item[\Const{UNW\_IA64\_AR\_LC}:] Alias for \Const{UNW\_IA64\_GR}\texttt{+65} - the loop-count register. -\item[\Const{UNW\_IA64\_AR\_EC}:] Alias for \Const{UNW\_IA64\_GR}\texttt{+66}, - the epilogue-count register. -\end{Description} - - -\section{The Unwind-Context Type} - -On IA-64, \Type{unw\_context\_t} is simply an alias for -\Type{ucontext\_t} (as defined by the Single UNIX Spec). This implies -that it is possible to initialize a value of this type not just with -\Func{unw\_getcontext}(), but also with \Func{getcontext}(), for -example. However, since this is an IA-64-specific extension to -\Prog{libunwind}, portable code should not rely on this equivalence. - - -\section{See Also} - -\SeeAlso{libunwind(3)} - -\section{Author} - -\noindent -David Mosberger-Tang\\ -Email: \Email{dmosberger@gmail.com}\\ -WWW: \URL{http://www.nongnu.org/libunwind/}. -\LatexManEnd - -\end{document} diff --git a/src/pal/src/libunwind/doc/libunwind-ptrace.man b/src/pal/src/libunwind/doc/libunwind-ptrace.man deleted file mode 100644 index 985fcae27..000000000 --- a/src/pal/src/libunwind/doc/libunwind-ptrace.man +++ /dev/null @@ -1,220 +0,0 @@ -'\" t -.\" Manual page created with latex2man on Thu Aug 16 09:44:44 MDT 2007 -.\" NOTE: This file is generated, DO NOT EDIT. -.de Vb -.ft CW -.nf -.. -.de Ve -.ft R - -.fi -.. -.TH "LIBUNWIND\-PTRACE" "3" "16 August 2007" "Programming Library " "Programming Library " -.SH NAME -libunwind\-ptrace -\-\- ptrace() support in libunwind -.PP -.SH SYNOPSIS - -.PP -#include -.br -.PP -unw_accessors_t -_UPT_accessors; -.br -.PP -void *_UPT_create(pid_t); -.br -void -_UPT_destroy(void *); -.br -.PP -int -_UPT_find_proc_info(unw_addr_space_t, -unw_word_t, -unw_proc_info_t *, -int, -void *); -.br -void -_UPT_put_unwind_info(unw_addr_space_t, -unw_proc_info_t *, -void *); -.br -int -_UPT_get_dyn_info_list_addr(unw_addr_space_t, -unw_word_t *, -void *); -.br -int -_UPT_access_mem(unw_addr_space_t, -unw_word_t, -unw_word_t *, -int, -void *); -.br -int -_UPT_access_reg(unw_addr_space_t, -unw_regnum_t, -unw_word_t *, -int, -void *); -.br -int -_UPT_access_fpreg(unw_addr_space_t, -unw_regnum_t, -unw_fpreg_t *, -int, -void *); -.br -int -_UPT_get_proc_name(unw_addr_space_t, -unw_word_t, -char *, -size_t, -unw_word_t *, -void *); -.br -int -_UPT_resume(unw_addr_space_t, -unw_cursor_t *, -void *); -.br -.PP -.SH DESCRIPTION - -.PP -The ptrace(2) -system\-call makes it possible for a process to -gain access to the machine\-state and virtual memory of \fIanother\fP -process. With the right set of call\-back routines, it is therefore -possible to hook up libunwind -to another process via -ptrace(2). -While it\&'s not very difficult to do so directly, -libunwind -further facilitates this task by providing -ready\-to\-use callbacks for this purpose. The routines and variables -implementing this facility use a name\-prefix of _UPT, -which is -stands for ``unwind\-via\-ptrace\&''\&. -.PP -An application that wants to use the _UPT\-facility -first needs -to create a new libunwind -address\-space that represents the -target process. This is done by calling -unw_create_addr_space(). -In many cases, the application -will simply want to pass the address of _UPT_accessors -as the -first argument to this routine. Doing so will ensure that -libunwind -will be able to properly unwind the target process. -However, in special circumstances, an application may prefer to use -only portions of the _UPT\-facility. -For this reason, the -individual callback routines (_UPT_find_proc_info(), -_UPT_put_unwind_info(), -etc.) are also available for direct -use. Of course, the addresses of these routines could also be picked -up from _UPT_accessors, -but doing so would prevent static -initialization. Also, when using _UPT_accessors, -\fIall\fP -the callback routines will be linked into the application, even if -they are never actually called. -.PP -Next, the application can turn on ptrace\-mode on the target process, -either by forking a new process, invoking PTRACE_TRACEME, -and -then starting the target program (via execve(2)), -or by -directly attaching to an already running process (via -PTRACE_ATTACH). -Either way, once the process\-ID (pid) of the -target process is known, a _UPT\-info\-structure -can be created -by calling _UPT_create(), -passing the pid of the target process -as the only argument. The returned void\-pointer then needs to be -passed as the ``argument\&'' pointer (third argument) to -unw_init_remote(). -.PP -The _UPT_resume() -routine can be used to resume execution of -the target process. It simply invokes ptrace(2) -with a command -value of PTRACE_CONT\&. -.PP -When the application is done using libunwind -on the target -process, _UPT_destroy() -needs to be called, passing it the -void\-pointer that was returned by the corresponding call to -_UPT_create(). -This ensures that all memory and other -resources are freed up. -.PP -.SH AVAILABILITY - -.PP -Since ptrace(2) -works within a single machine only, the -_UPT\-facility -by definition is not available in -libunwind\-versions -configured for cross\-unwinding. -.PP -.SH THREAD SAFETY - -.PP -The _UPT\-facility -assumes that a single _UPT\-info -structure is never shared between threads. Because of this, no -explicit locking is used. As long as only one thread uses -a _UPT\-info -structure at any given time, this facility -is thread\-safe. -.PP -.SH RETURN VALUE - -.PP -_UPT_create() -may return a NULL -pointer if it fails -to create the _UPT\-info\-structure -for any reason. For the -current implementation, the only reason this call may fail is when the -system is out of memory. -.PP -.SH FILES - -.PP -.TP -libunwind\-ptrace.h - Headerfile to include when using the -interface defined by this library. -.TP -\fB\-l\fPunwind\-ptrace \fB\-l\fPunwind\-generic - Linker\-switches to add when building a program that uses the -functions defined by this library. -.PP -.SH SEE ALSO - -.PP -execve(2), -libunwind(3), -ptrace(2) -.PP -.SH AUTHOR - -.PP -David Mosberger\-Tang -.br -Email: \fBdmosberger@gmail.com\fP -.br -WWW: \fBhttp://www.nongnu.org/libunwind/\fP\&. -.\" NOTE: This file is generated, DO NOT EDIT. diff --git a/src/pal/src/libunwind/doc/libunwind-ptrace.tex b/src/pal/src/libunwind/doc/libunwind-ptrace.tex deleted file mode 100644 index fe074d861..000000000 --- a/src/pal/src/libunwind/doc/libunwind-ptrace.tex +++ /dev/null @@ -1,134 +0,0 @@ -\documentclass{article} -\usepackage[fancyhdr,pdf]{latex2man} - -\input{common.tex} - -\begin{document} - -\begin{Name}{3}{libunwind-ptrace}{David Mosberger-Tang}{Programming Library}{ptrace() support in libunwind}libunwind-ptrace -- ptrace() support in libunwind -\end{Name} - -\section{Synopsis} - -\File{\#include $<$libunwind-ptrace.h$>$}\\ - -\noindent -\Type{unw\_accessors\_t} \Var{\_UPT\_accessors};\\ - -\Type{void~*}\Func{\_UPT\_create}(\Type{pid\_t});\\ -\noindent -\Type{void} \Func{\_UPT\_destroy}(\Type{void~*});\\ - -\noindent -\Type{int} \Func{\_UPT\_find\_proc\_info}(\Type{unw\_addr\_space\_t}, \Type{unw\_word\_t}, \Type{unw\_proc\_info\_t~*}, \Type{int}, \Type{void~*});\\ -\noindent -\Type{void} \Func{\_UPT\_put\_unwind\_info}(\Type{unw\_addr\_space\_t}, \Type{unw\_proc\_info\_t~*}, \Type{void~*});\\ -\noindent -\Type{int} \Func{\_UPT\_get\_dyn\_info\_list\_addr}(\Type{unw\_addr\_space\_t}, \Type{unw\_word\_t~*}, \Type{void~*});\\ -\noindent -\Type{int} \Func{\_UPT\_access\_mem}(\Type{unw\_addr\_space\_t}, \Type{unw\_word\_t}, \Type{unw\_word\_t~*}, \Type{int}, \Type{void~*});\\ -\noindent -\Type{int} \Func{\_UPT\_access\_reg}(\Type{unw\_addr\_space\_t}, \Type{unw\_regnum\_t}, \Type{unw\_word\_t~*}, \Type{int}, \Type{void~*});\\ -\noindent -\Type{int} \Func{\_UPT\_access\_fpreg}(\Type{unw\_addr\_space\_t}, \Type{unw\_regnum\_t}, \Type{unw\_fpreg\_t~*}, \Type{int}, \Type{void~*});\\ -\noindent -\Type{int} \Func{\_UPT\_get\_proc\_name}(\Type{unw\_addr\_space\_t}, \Type{unw\_word\_t}, \Type{char~*}, \Type{size\_t}, \Type{unw\_word\_t~*}, \Type{void~*});\\ -\noindent -\Type{int} \Func{\_UPT\_resume}(\Type{unw\_addr\_space\_t}, \Type{unw\_cursor\_t~*}, \Type{void~*});\\ - -\section{Description} - -The \Func{ptrace}(2) system-call makes it possible for a process to -gain access to the machine-state and virtual memory of \emph{another} -process. With the right set of call-back routines, it is therefore -possible to hook up \Prog{libunwind} to another process via -\Func{ptrace}(2). While it's not very difficult to do so directly, -\Prog{libunwind} further facilitates this task by providing -ready-to-use callbacks for this purpose. The routines and variables -implementing this facility use a name-prefix of \Func{\_UPT}, which is -stands for ``unwind-via-ptrace''. - -An application that wants to use the \Func{\_UPT}-facility first needs -to create a new \Prog{libunwind} address-space that represents the -target process. This is done by calling -\Func{unw\_create\_addr\_space}(). In many cases, the application -will simply want to pass the address of \Var{\_UPT\_accessors} as the -first argument to this routine. Doing so will ensure that -\Prog{libunwind} will be able to properly unwind the target process. -However, in special circumstances, an application may prefer to use -only portions of the \Prog{\_UPT}-facility. For this reason, the -individual callback routines (\Func{\_UPT\_find\_proc\_info}(), -\Func{\_UPT\_put\_unwind\_info}(), etc.) are also available for direct -use. Of course, the addresses of these routines could also be picked -up from \Var{\_UPT\_accessors}, but doing so would prevent static -initialization. Also, when using \Var{\_UPT\_accessors}, \emph{all} -the callback routines will be linked into the application, even if -they are never actually called. - -Next, the application can turn on ptrace-mode on the target process, -either by forking a new process, invoking \Const{PTRACE\_TRACEME}, and -then starting the target program (via \Func{execve}(2)), or by -directly attaching to an already running process (via -\Const{PTRACE\_ATTACH}). Either way, once the process-ID (pid) of the -target process is known, a \Prog{\_UPT}-info-structure can be created -by calling \Func{\_UPT\_create}(), passing the pid of the target process -as the only argument. The returned void-pointer then needs to be -passed as the ``argument'' pointer (third argument) to -\Func{unw\_init\_remote}(). - -The \Func{\_UPT\_resume}() routine can be used to resume execution of -the target process. It simply invokes \Func{ptrace}(2) with a command -value of \Const{PTRACE\_CONT}. - -When the application is done using \Prog{libunwind} on the target -process, \Func{\_UPT\_destroy}() needs to be called, passing it the -void-pointer that was returned by the corresponding call to -\Func{\_UPT\_create}(). This ensures that all memory and other -resources are freed up. - -\section{Availability} - -Since \Func{ptrace}(2) works within a single machine only, the -\Prog{\_UPT}-facility by definition is not available in -\Prog{libunwind}-versions configured for cross-unwinding. - -\section{Thread Safety} - -The \Prog{\_UPT}-facility assumes that a single \Prog{\_UPT}-info -structure is never shared between threads. Because of this, no -explicit locking is used. As long as only one thread uses -a \Prog{\_UPT}-info structure at any given time, this facility -is thread-safe. - -\section{Return Value} - -\Func{\_UPT\_create}() may return a \Const{NULL} pointer if it fails -to create the \Prog{\_UPT}-info-structure for any reason. For the -current implementation, the only reason this call may fail is when the -system is out of memory. - -\section{Files} - -\begin{Description} -\item[\File{libunwind-ptrace.h}] Headerfile to include when using the - interface defined by this library. -\item[\Opt{-l}\File{unwind-ptrace} \Opt{-l}\File{unwind-generic}] - Linker-switches to add when building a program that uses the - functions defined by this library. -\end{Description} - -\section{See Also} - -execve(2), -\SeeAlso{libunwind(3)}, -ptrace(2) - -\section{Author} - -\noindent -David Mosberger-Tang\\ -Email: \Email{dmosberger@gmail.com}\\ -WWW: \URL{http://www.nongnu.org/libunwind/}. -\LatexManEnd - -\end{document} diff --git a/src/pal/src/libunwind/doc/libunwind-setjmp.man b/src/pal/src/libunwind/doc/libunwind-setjmp.man deleted file mode 100644 index 1faa38e47..000000000 --- a/src/pal/src/libunwind/doc/libunwind-setjmp.man +++ /dev/null @@ -1,132 +0,0 @@ -'\" t -.\" Manual page created with latex2man on Thu Aug 16 09:44:44 MDT 2007 -.\" NOTE: This file is generated, DO NOT EDIT. -.de Vb -.ft CW -.nf -.. -.de Ve -.ft R - -.fi -.. -.TH "LIBUNWIND\-SETJMP" "3" "16 August 2007" "Programming Library " "Programming Library " -.SH NAME -libunwind\-setjmp -\-\- libunwind\-based non\-local gotos -.PP -.SH SYNOPSIS - -.PP -#include -.br -.PP -int -setjmp(jmp_buf env); -.br -void -longjmp(jmp_buf env, -int val); -.br -int -_setjmp(jmp_buf env); -.br -void -_longjmp(jmp_buf env, -int val); -.br -int -sigsetjmp(sigjmp_buf env, -int savemask); -.br -void -siglongjmp(sigjmp_buf env, -int val); -.br -.PP -.SH DESCRIPTION - -.PP -The unwind\-setjmp -library offers a libunwind\-based -implementation of non\-local gotos. This implementation is intended to -be a drop\-in replacement for the normal, system\-provided routines of -the same name. The main advantage of using the unwind\-setjmp -library is that setting up a non\-local goto via one of the -setjmp() -routines is very fast. Typically, just 2 or 3 words -need to be saved in the jump\-buffer (plus one call to -sigprocmask(2), -in the case of sigsetjmp). -On the -other hand, executing a non\-local goto by calling one of the -longjmp() -routines tends to be much slower than with the -system\-provided routines. In fact, the time spent on a -longjmp() -will be proportional to the number of call frames -that exist between the points where setjmp() -and -longjmp() -were called. For this reason, the -unwind\-setjmp -library is beneficial primarily in applications -that frequently call setjmp() -but only rarely call -longjmp(). -.PP -.SH CAVEATS - -.PP -.TP -.B * -The correct operation of this library depends on the presence of -correct unwind information. On newer platforms, this is rarely an -issue. On older platforms, care needs to be taken to -ensure that each of the functions whose stack frames may have to be -unwound during a longjmp() -have correct unwind information -(on those platforms, there is usually a compiler\-switch, such as -\fB\-funwind\-tables\fP, -to request the generation of unwind -information). -.TP -.B * -The contents of jmp_buf and sigjmp_buf as setup -and used by these routines is completely different from the ones -used by the system\-provided routines. Thus, a jump\-buffer created -by the libunwind\-based setjmp()/_setjmp -may only be -used in a call to the libunwind\-based -longjmp()/_longjmp(). -The analogous applies for -sigjmp_buf -with sigsetjmp() -and siglongjmp(). -.PP -.SH FILES - -.PP -.TP -\fB\-l\fPunwind\-setjmp - The library an application should -be linked against to ensure it uses the libunwind\-based non\-local -goto routines. -.PP -.SH SEE ALSO - -.PP -libunwind(3), -setjmp(3), longjmp(3), -_setjmp(3), _longjmp(3), -sigsetjmp(3), siglongjmp(3) -.PP -.SH AUTHOR - -.PP -David Mosberger\-Tang -.br -Email: \fBdmosberger@gmail.com\fP -.br -WWW: \fBhttp://www.nongnu.org/libunwind/\fP\&. -.\" NOTE: This file is generated, DO NOT EDIT. diff --git a/src/pal/src/libunwind/doc/libunwind-setjmp.tex b/src/pal/src/libunwind/doc/libunwind-setjmp.tex deleted file mode 100644 index 17ce07318..000000000 --- a/src/pal/src/libunwind/doc/libunwind-setjmp.tex +++ /dev/null @@ -1,87 +0,0 @@ -\documentclass{article} -\usepackage[fancyhdr,pdf]{latex2man} - -\input{common.tex} - -\begin{document} - -\begin{Name}{3}{libunwind-setjmp}{David Mosberger-Tang}{Programming Library}{libunwind-based non-local gotos}libunwind-setjmp -- libunwind-based non-local gotos -\end{Name} - -\section{Synopsis} - -\File{\#include $<$setjmp.h$>$}\\ - -\noindent -\Type{int} \Func{setjmp}(\Type{jmp\_buf}~\Var{env});\\ -\Type{void} \Func{longjmp}(\Type{jmp\_buf}~\Var{env}, \Type{int}~\Var{val});\\ -\Type{int} \Func{\_setjmp}(\Type{jmp\_buf}~\Var{env});\\ -\Type{void} \Func{\_longjmp}(\Type{jmp\_buf}~\Var{env}, \Type{int}~\Var{val});\\ -\Type{int} \Func{sigsetjmp}(\Type{sigjmp\_buf}~\Var{env}, \Type{int}~\Var{savemask});\\ -\Type{void} \Func{siglongjmp}(\Type{sigjmp\_buf}~\Var{env}, \Type{int}~\Var{val});\\ - -\section{Description} - -The \Prog{unwind-setjmp} library offers a \Prog{libunwind}-based -implementation of non-local gotos. This implementation is intended to -be a drop-in replacement for the normal, system-provided routines of -the same name. The main advantage of using the \Prog{unwind-setjmp} -library is that setting up a non-local goto via one of the -\Func{setjmp}() routines is very fast. Typically, just 2 or 3 words -need to be saved in the jump-buffer (plus one call to -\Func{sigprocmask}(2), in the case of \Func{sigsetjmp}). On the -other hand, executing a non-local goto by calling one of the -\Func{longjmp}() routines tends to be much slower than with the -system-provided routines. In fact, the time spent on a -\Func{longjmp}() will be proportional to the number of call frames -that exist between the points where \Func{setjmp}() and -\Func{longjmp}() were called. For this reason, the -\Prog{unwind-setjmp} library is beneficial primarily in applications -that frequently call \Func{setjmp}() but only rarely call -\Func{longjmp}(). - -\section{Caveats} - -\begin{itemize} -\item The correct operation of this library depends on the presence of - correct unwind information. On newer platforms, this is rarely an - issue. On older platforms, care needs to be taken to - ensure that each of the functions whose stack frames may have to be - unwound during a \Func{longjmp}() have correct unwind information - (on those platforms, there is usually a compiler-switch, such as - \Opt{-funwind-tables}, to request the generation of unwind - information). -\item The contents of \Type{jmp\_buf} and \Type{sigjmp\_buf} as setup - and used by these routines is completely different from the ones - used by the system-provided routines. Thus, a jump-buffer created - by the libunwind-based \Func{setjmp}()/\Func{\_setjmp} may only be - used in a call to the libunwind-based - \Func{longjmp}()/\Func{\_longjmp}(). The analogous applies for - \Type{sigjmp\_buf} with \Func{sigsetjmp}() and \Func{siglongjmp}(). -\end{itemize} - -\section{Files} - -\begin{Description} -\item[\Opt{-l}\File{unwind-setjmp}] The library an application should - be linked against to ensure it uses the libunwind-based non-local - goto routines. -\end{Description} - - -\section{See Also} - -\SeeAlso{libunwind(3)}, -setjmp(3), longjmp(3), -\_setjmp(3), \_longjmp(3), -sigsetjmp(3), siglongjmp(3) - -\section{Author} - -\noindent -David Mosberger-Tang\\ -Email: \Email{dmosberger@gmail.com}\\ -WWW: \URL{http://www.nongnu.org/libunwind/}. -\LatexManEnd - -\end{document} diff --git a/src/pal/src/libunwind/doc/libunwind.man b/src/pal/src/libunwind/doc/libunwind.man deleted file mode 100644 index 02ab6b893..000000000 --- a/src/pal/src/libunwind/doc/libunwind.man +++ /dev/null @@ -1,508 +0,0 @@ -'\" t -.\" Manual page created with latex2man on Thu Jan 12 06:50:29 PST 2017 -.\" NOTE: This file is generated, DO NOT EDIT. -.de Vb -.ft CW -.nf -.. -.de Ve -.ft R - -.fi -.. -.TH "LIBUNWIND" "3" "12 January 2017" "Programming Library " "Programming Library " -.SH NAME -libunwind -\-\- a (mostly) platform\-independent unwind API -.PP -.SH SYNOPSIS - -.PP -#include -.br -.PP -int -unw_getcontext(unw_context_t *); -.br -int -unw_init_local(unw_cursor_t *, -unw_context_t *); -.br -int -unw_init_remote(unw_cursor_t *, -unw_addr_space_t, -void *); -.br -int -unw_step(unw_cursor_t *); -.br -int -unw_get_reg(unw_cursor_t *, -unw_regnum_t, -unw_word_t *); -.br -int -unw_get_fpreg(unw_cursor_t *, -unw_regnum_t, -unw_fpreg_t *); -.br -int -unw_set_reg(unw_cursor_t *, -unw_regnum_t, -unw_word_t); -.br -int -unw_set_fpreg(unw_cursor_t *, -unw_regnum_t, -unw_fpreg_t); -.br -int -unw_resume(unw_cursor_t *); -.br -.PP -unw_addr_space_t -unw_local_addr_space; -.br -unw_addr_space_t -unw_create_addr_space(unw_accessors_t, -int); -.br -void -unw_destroy_addr_space(unw_addr_space_t); -.br -unw_accessors_t -unw_get_accessors(unw_addr_space_t); -.br -void -unw_flush_cache(unw_addr_space_t, -unw_word_t, -unw_word_t); -.br -int -unw_set_caching_policy(unw_addr_space_t, -unw_caching_policy_t); -.br -int -unw_set_cache_size(unw_addr_space_t, -size_t, -int); -.br -.PP -const char *unw_regname(unw_regnum_t); -.br -int -unw_get_proc_info(unw_cursor_t *, -unw_proc_info_t *); -.br -int -unw_get_save_loc(unw_cursor_t *, -int, -unw_save_loc_t *); -.br -int -unw_is_fpreg(unw_regnum_t); -.br -int -unw_is_signal_frame(unw_cursor_t *); -.br -int -unw_get_proc_name(unw_cursor_t *, -char *, -size_t, -unw_word_t *); -.br -.PP -void -_U_dyn_register(unw_dyn_info_t *); -.br -void -_U_dyn_cancel(unw_dyn_info_t *); -.br -.PP -.SH LOCAL UNWINDING - -.PP -Libunwind -is very easy to use when unwinding a stack from -within a running program. This is called \fIlocal\fP -unwinding. Say -you want to unwind the stack while executing in some function -F(). -In this function, you would call unw_getcontext() -to get a snapshot of the CPU registers (machine\-state). Then you -initialize an \fIunwind cursor\fP -based on this snapshot. This is -done with a call to unw_init_local(). -The cursor now points -to the current frame, that is, the stack frame that corresponds to the -current activation of function F(). -The unwind cursor can then -be moved ``up\&'' (towards earlier stack frames) by calling -unw_step(). -By repeatedly calling this routine, you can -uncover the entire call\-chain that led to the activation of function -F(). -A positive return value from unw_step() -indicates -that there are more frames in the chain, zero indicates that the end -of the chain has been reached, and any negative value indicates that -some sort of error has occurred. -.PP -While it is not possible to directly move the unwind cursor in the -``down\&'' direction (towards newer stack frames), this effect can be -achieved by making copies of an unwind cursor. For example, a program -that sometimes has to move ``down\&'' by one stack frame could maintain -two cursor variables: ``curr\&'' -and ``prev\&''\&. -The former -would be used as the current cursor and prev -would be maintained -as the ``previous frame\&'' cursor by copying the contents of curr -to prev -right before calling unw_step(). -With this -approach, the program could move one step ``down\&'' simply by copying -back prev -to curr -whenever that is necessary. In the most -extreme case, a program could maintain a separate cursor for each call -frame and that way it could move up and down the callframe\-chain at -will. -.PP -Given an unwind cursor, it is possible to read and write the CPU -registers that were preserved for the current stack frame (as -identified by the cursor). Libunwind -provides several routines -for this purpose: unw_get_reg() -reads an integer (general) -register, unw_get_fpreg() -reads a floating\-point register, -unw_set_reg() -writes an integer register, and -unw_set_fpreg() -writes a floating\-point register. Note that, -by definition, only the \fIpreserved\fP -machine state can be accessed -during an unwind operation. Normally, this state consists of the -\fIcallee\-saved\fP -(``preserved\&'') registers. However, in some -special circumstances (e.g., in a signal handler trampoline), even the -\fIcaller\-saved\fP -(``scratch\&'') registers are preserved in the stack -frame and, in those cases, libunwind -will grant access to them -as well. The exact set of registers that can be accessed via the -cursor depends, of course, on the platform. However, there are two -registers that can be read on all platforms: the instruction pointer -(IP), sometimes also known as the ``program counter\&'', and the stack -pointer (SP). In libunwind, -these registers are identified by -the macros UNW_REG_IP -and UNW_REG_SP, -respectively. -.PP -Besides just moving the unwind cursor and reading/writing saved -registers, libunwind -also provides the ability to resume -execution at an arbitrary stack frame. As you might guess, this is -useful for implementing non\-local gotos and the exception handling -needed by some high\-level languages such as Java. Resuming execution -with a particular stack frame simply requires calling -unw_resume() -and passing the cursor identifying the target -frame as the only argument. -.PP -Normally, libunwind -supports both local and remote unwinding -(the latter will be explained in the next section). However, if you -tell libunwind that your program only needs local unwinding, then a -special implementation can be selected which may run much faster than -the generic implementation which supports both kinds of unwinding. To -select this optimized version, simply define the macro -UNW_LOCAL_ONLY -before including the headerfile -\&. -It is perfectly OK for a single program to -employ both local\-only and generic unwinding. That is, whether or not -UNW_LOCAL_ONLY -is defined is a choice that each source\-file -(compilation\-unit) can make on its own. Independent of the setting(s) -of UNW_LOCAL_ONLY, -you\&'ll always link the same library into -the program (normally \fB\-l\fPunwind). -Furthermore, the -portion of libunwind -that manages unwind\-info for dynamically -generated code is not affected by the setting of -UNW_LOCAL_ONLY\&. -.PP -If we put all of the above together, here is how we could use -libunwind -to write a function ``show_backtrace()\&'' -which prints a classic stack trace: -.PP -.Vb -#define UNW_LOCAL_ONLY -#include - -void show_backtrace (void) { - unw_cursor_t cursor; unw_context_t uc; - unw_word_t ip, sp; - - unw_getcontext(&uc); - unw_init_local(&cursor, &uc); - while (unw_step(&cursor) > 0) { - unw_get_reg(&cursor, UNW_REG_IP, &ip); - unw_get_reg(&cursor, UNW_REG_SP, &sp); - printf ("ip = %lx, sp = %lx\\n", (long) ip, (long) sp); - } -} -.Ve -.PP -.SH REMOTE UNWINDING - -.PP -Libunwind -can also be used to unwind a stack in a ``remote\&'' -process. Here, ``remote\&'' may mean another process on the same -machine or even a process on a completely different machine from the -one that is running libunwind\&. -Remote unwinding is typically -used by debuggers and instruction\-set simulators, for example. -.PP -Before you can unwind a remote process, you need to create a new -address\-space object for that process. This is achieved with the -unw_create_addr_space() -routine. The routine takes two -arguments: a pointer to a set of \fIaccessor\fP -routines and an -integer that specifies the byte\-order of the target process. The -accessor routines provide libunwind -with the means to -communicate with the remote process. In particular, there are -callbacks to read and write the process\&'s memory, its registers, and -to access unwind information which may be needed by libunwind\&. -.PP -With the address space created, unwinding can be initiated by a call -to unw_init_remote(). -This routine is very similar to -unw_init_local(), -except that it takes an address\-space -object and an opaque pointer as arguments. The routine uses these -arguments to fetch the initial machine state. Libunwind -never -uses the opaque pointer on its own, but instead just passes it on to -the accessor (callback) routines. Typically, this pointer is used to -select, e.g., the thread within a process that is to be unwound. -.PP -Once a cursor has been initialized with unw_init_remote(), -unwinding works exactly like in the local case. That is, you can use -unw_step() -to move ``up\&'' in the call\-chain, read and write -registers, or resume execution at a particular stack frame by calling -unw_resume\&. -.PP -.SH CROSS\-PLATFORM AND MULTI\-PLATFORM UNWINDING - -.PP -Libunwind -has been designed to enable unwinding across -platforms (architectures). Indeed, a single program can use -libunwind -to unwind an arbitrary number of target platforms, -all at the same time! -.PP -We call the machine that is running libunwind -the \fIhost\fP -and the machine that is running the process being unwound the -\fItarget\fP\&. -If the host and the target platform are the same, we -call it \fInative\fP -unwinding. If they differ, we call it -\fIcross\-platform\fP -unwinding. -.PP -The principle behind supporting native, cross\-platform, and -multi\-platform unwinding is very simple: for native unwinding, a -program includes -and uses the linker switch -\fB\-l\fPunwind\&. -For cross\-platform unwinding, a program -includes -and uses the linker -switch \fB\-l\fPunwind\-PLAT, -where PLAT -is the name -of the target platform (e.g., ia64 -for IA\-64, hppa\-elf -for ELF\-based HP PA\-RISC, or x86 -for 80386). Multi\-platform -unwinding works exactly like cross\-platform unwinding, the only -limitation is that a single source file (compilation unit) can include -at most one libunwind -header file. In other words, the -platform\-specific support for each supported target needs to be -isolated in separate source files\-\-\-a limitation that shouldn\&'t be an -issue in practice. -.PP -Note that, by definition, local unwinding is possible only for the -native case. Attempting to call, e.g., unw_local_init() -when -targeting a cross\-platform will result in a link\-time error -(unresolved references). -.PP -.SH THREAD\- AND SIGNAL\-SAFETY - -.PP -All libunwind -routines are thread\-safe. What this means is -that multiple threads may use libunwind -simulatenously. -However, any given cursor may be accessed by only one thread at -any given time. -.PP -To ensure thread\-safety, some libunwind -routines may have to -use locking. Such routines \fImust not\fP -be called from signal -handlers (directly or indirectly) and are therefore \fInot\fP -signal\-safe. The manual page for each libunwind -routine -identifies whether or not it is signal\-safe, but as a general rule, -any routine that may be needed for \fIlocal\fP -unwinding is -signal\-safe (e.g., unw_step() -for local unwinding is -signal\-safe). For remote\-unwinding, \fInone\fP -of the -libunwind -routines are guaranteed to be signal\-safe. -.PP -.SH UNWINDING THROUGH DYNAMICALLY GENERATED CODE - -.PP -Libunwind -provides the routines _U_dyn_register() -and -_U_dyn_cancel() -to register/cancel the information required to -unwind through code that has been generated at runtime (e.g., by a -just\-in\-time (JIT) compiler). It is important to register the -information for \fIall\fP -dynamically generated code because -otherwise, a debugger may not be able to function properly or -high\-level language exception handling may not work as expected. -.PP -The interface for registering and canceling dynamic unwind info has -been designed for maximum efficiency, so as to minimize the -performance impact on JIT\-compilers. In particular, both routines are -guaranteed to execute in ``constant time\&'' (O(1)) and the -data\-structure encapsulating the dynamic unwind info has been designed -to facilitate sharing, such that similar procedures can share much of -the underlying information. -.PP -For more information on the libunwind -support for dynamically -generated code, see libunwind\-dynamic(3)\&. -.PP -.SH CACHING OF UNWIND INFO - -.PP -To speed up execution, libunwind -may aggressively cache the -information it needs to perform unwinding. If a process changes -during its lifetime, this creates a risk of libunwind -using -stale data. For example, this would happen if libunwind -were -to cache information about a shared library which later on gets -unloaded (e.g., via \fIdlclose\fP(3)). -.PP -To prevent the risk of using stale data, libunwind -provides two -facilities: first, it is possible to flush the cached information -associated with a specific address range in the target process (or the -entire address space, if desired). This functionality is provided by -unw_flush_cache(). -The second facility is provided by -unw_set_caching_policy(), -which lets a program -select the exact caching policy in use for a given address\-space -object. In particular, by selecting the policy -UNW_CACHE_NONE, -it is possible to turn off caching -completely, therefore eliminating the risk of stale data alltogether -(at the cost of slower execution). By default, caching is enabled for -local unwinding only. The cache size can be dynamically changed with -unw_set_cache_size(), -which also fluches the current cache. -.PP -.SH FILES - -.PP -.TP -libunwind.h - Headerfile to include for native (same -platform) unwinding. -.TP -libunwind\-PLAT\&.h - Headerfile to include when -the unwind target runs on platform PLAT\&. -For example, to unwind -an IA\-64 program, the header file libunwind\-ia64.h -should be -included. -.TP -\fB\-l\fPunwind - Linker\-switch to add when building a -program that does native (same platform) unwinding. -.TP -\fB\-l\fPunwind\-PLAT - Linker\-switch to add when -building a program that unwinds a program on platform PLAT\&. -For example, to (cross\-)unwind an IA\-64 program, the linker switch -\-lunwind\-ia64 -should be added. Note: multiple such switches -may need to be specified for programs that can unwind programs on -multiple platforms. -.PP -.SH SEE ALSO - -.PP -libunwind\-dynamic(3), -libunwind\-ia64(3), -libunwind\-ptrace(3), -libunwind\-setjmp(3), -unw_create_addr_space(3), -unw_destroy_addr_space(3), -unw_flush_cache(3), -unw_get_accessors(3), -unw_get_fpreg(3), -unw_get_proc_info(3), -unw_get_proc_name(3), -unw_get_reg(3), -unw_getcontext(3), -unw_init_local(3), -unw_init_remote(3), -unw_is_fpreg(3), -unw_is_signal_frame(3), -unw_regname(3), -unw_resume(3), -unw_set_caching_policy(3), -unw_set_cache_size(3), -unw_set_fpreg(3), -unw_set_reg(3), -unw_step(3), -unw_strerror(3), -_U_dyn_register(3), -_U_dyn_cancel(3) -.PP -.SH AUTHOR - -.PP -David Mosberger\-Tang -.br -Email: \fBdmosberger@gmail.com\fP -.br -WWW: \fBhttp://www.nongnu.org/libunwind/\fP\&. -.\" NOTE: This file is generated, DO NOT EDIT. diff --git a/src/pal/src/libunwind/doc/libunwind.tex b/src/pal/src/libunwind/doc/libunwind.tex deleted file mode 100644 index 6cbb47663..000000000 --- a/src/pal/src/libunwind/doc/libunwind.tex +++ /dev/null @@ -1,359 +0,0 @@ -\documentclass{article} -\usepackage[fancyhdr,pdf]{latex2man} - -\input{common.tex} - -\begin{document} - -\begin{Name}{3}{libunwind}{David Mosberger-Tang}{Programming Library}{Introduction to libunwind}libunwind -- a (mostly) platform-independent unwind API -\end{Name} - -\section{Synopsis} - -\File{\#include $<$libunwind.h$>$}\\ - -\noindent -\Type{int} \Func{unw\_getcontext}(\Type{unw\_context\_t~*});\\ -\noindent -\Type{int} \Func{unw\_init\_local}(\Type{unw\_cursor\_t~*}, \Type{unw\_context\_t~*});\\ -\noindent -\Type{int} \Func{unw\_init\_remote}(\Type{unw\_cursor\_t~*}, \Type{unw\_addr\_space\_t}, \Type{void~*});\\ -\noindent -\Type{int} \Func{unw\_step}(\Type{unw\_cursor\_t~*});\\ -\noindent -\Type{int} \Func{unw\_get\_reg}(\Type{unw\_cursor\_t~*}, \Type{unw\_regnum\_t}, \Type{unw\_word\_t~*});\\ -\noindent -\Type{int} \Func{unw\_get\_fpreg}(\Type{unw\_cursor\_t~*}, \Type{unw\_regnum\_t}, \Type{unw\_fpreg\_t~*});\\ -\noindent -\Type{int} \Func{unw\_set\_reg}(\Type{unw\_cursor\_t~*}, \Type{unw\_regnum\_t}, \Type{unw\_word\_t});\\ -\noindent -\Type{int} \Func{unw\_set\_fpreg}(\Type{unw\_cursor\_t~*}, \Type{unw\_regnum\_t}, \Type{unw\_fpreg\_t});\\ -\noindent -\Type{int} \Func{unw\_resume}(\Type{unw\_cursor\_t~*});\\ - -\noindent -\Type{unw\_addr\_space\_t} \Var{unw\_local\_addr\_space};\\ -\noindent -\Type{unw\_addr\_space\_t} \Func{unw\_create\_addr\_space}(\Type{unw\_accessors\_t}, \Type{int});\\ -\noindent -\Type{void} \Func{unw\_destroy\_addr\_space}(\Type{unw\_addr\_space\_t});\\ -\noindent -\Type{unw\_accessors\_t} \Func{unw\_get\_accessors}(\Type{unw\_addr\_space\_t});\\ -\noindent -\Type{void} \Func{unw\_flush\_cache}(\Type{unw\_addr\_space\_t}, \Type{unw\_word\_t}, \Type{unw\_word\_t});\\ -\noindent -\Type{int} \Func{unw\_set\_caching\_policy}(\Type{unw\_addr\_space\_t}, \Type{unw\_caching\_policy\_t});\\ -\noindent -\Type{int} \Func{unw\_set\_cache\_size}(\Type{unw\_addr\_space\_t}, \Type{size\_t}, \Type{int});\\ - -\noindent -\Type{const char *}\Func{unw\_regname}(\Type{unw\_regnum\_t});\\ -\noindent -\Type{int} \Func{unw\_get\_proc\_info}(\Type{unw\_cursor\_t~*}, \Type{unw\_proc\_info\_t~*});\\ -\noindent -\Type{int} \Func{unw\_get\_save\_loc}(\Type{unw\_cursor\_t~*}, \Type{int}, \Type{unw\_save\_loc\_t~*});\\ -\noindent -\Type{int} \Func{unw\_is\_fpreg}(\Type{unw\_regnum\_t});\\ -\Type{int} \Func{unw\_is\_signal\_frame}(\Type{unw\_cursor\_t~*});\\ -\noindent -\Type{int} \Func{unw\_get\_proc\_name}(\Type{unw\_cursor\_t~*}, \Type{char~*}, \Type{size\_t}, \Type{unw\_word\_t~*});\\ - -\noindent -\Type{void} \Func{\_U\_dyn\_register}(\Type{unw\_dyn\_info\_t~*});\\ -\noindent -\Type{void} \Func{\_U\_dyn\_cancel}(\Type{unw\_dyn\_info\_t~*});\\ - -\section{Local Unwinding} - -\Prog{Libunwind} is very easy to use when unwinding a stack from -within a running program. This is called \emph{local} unwinding. Say -you want to unwind the stack while executing in some function -\Func{F}(). In this function, you would call \Func{unw\_getcontext}() -to get a snapshot of the CPU registers (machine-state). Then you -initialize an \emph{unwind~cursor} based on this snapshot. This is -done with a call to \Func{unw\_init\_local}(). The cursor now points -to the current frame, that is, the stack frame that corresponds to the -current activation of function \Func{F}(). The unwind cursor can then -be moved ``up'' (towards earlier stack frames) by calling -\Func{unw\_step}(). By repeatedly calling this routine, you can -uncover the entire call-chain that led to the activation of function -\Func{F}(). A positive return value from \Func{unw\_step}() indicates -that there are more frames in the chain, zero indicates that the end -of the chain has been reached, and any negative value indicates that -some sort of error has occurred. - -While it is not possible to directly move the unwind cursor in the -``down'' direction (towards newer stack frames), this effect can be -achieved by making copies of an unwind cursor. For example, a program -that sometimes has to move ``down'' by one stack frame could maintain -two cursor variables: ``\Var{curr}'' and ``\Var{prev}''. The former -would be used as the current cursor and \Var{prev} would be maintained -as the ``previous frame'' cursor by copying the contents of \Var{curr} -to \Var{prev} right before calling \Func{unw\_step}(). With this -approach, the program could move one step ``down'' simply by copying -back \Var{prev} to \Var{curr} whenever that is necessary. In the most -extreme case, a program could maintain a separate cursor for each call -frame and that way it could move up and down the callframe-chain at -will. - -Given an unwind cursor, it is possible to read and write the CPU -registers that were preserved for the current stack frame (as -identified by the cursor). \Prog{Libunwind} provides several routines -for this purpose: \Func{unw\_get\_reg}() reads an integer (general) -register, \Func{unw\_get\_fpreg}() reads a floating-point register, -\Func{unw\_set\_reg}() writes an integer register, and -\Func{unw\_set\_fpreg}() writes a floating-point register. Note that, -by definition, only the \emph{preserved} machine state can be accessed -during an unwind operation. Normally, this state consists of the -\emph{callee-saved} (``preserved'') registers. However, in some -special circumstances (e.g., in a signal handler trampoline), even the -\emph{caller-saved} (``scratch'') registers are preserved in the stack -frame and, in those cases, \Prog{libunwind} will grant access to them -as well. The exact set of registers that can be accessed via the -cursor depends, of course, on the platform. However, there are two -registers that can be read on all platforms: the instruction pointer -(IP), sometimes also known as the ``program counter'', and the stack -pointer (SP). In \Prog{libunwind}, these registers are identified by -the macros \Const{UNW\_REG\_IP} and \Const{UNW\_REG\_SP}, -respectively. - -Besides just moving the unwind cursor and reading/writing saved -registers, \Prog{libunwind} also provides the ability to resume -execution at an arbitrary stack frame. As you might guess, this is -useful for implementing non-local gotos and the exception handling -needed by some high-level languages such as Java. Resuming execution -with a particular stack frame simply requires calling -\Func{unw\_resume}() and passing the cursor identifying the target -frame as the only argument. - -Normally, \Prog{libunwind} supports both local and remote unwinding -(the latter will be explained in the next section). However, if you -tell libunwind that your program only needs local unwinding, then a -special implementation can be selected which may run much faster than -the generic implementation which supports both kinds of unwinding. To -select this optimized version, simply define the macro -\Const{UNW\_LOCAL\_ONLY} before including the headerfile -\File{$<$libunwind.h$>$}. It is perfectly OK for a single program to -employ both local-only and generic unwinding. That is, whether or not -\Const{UNW\_LOCAL\_ONLY} is defined is a choice that each source-file -(compilation-unit) can make on its own. Independent of the setting(s) -of \Const{UNW\_LOCAL\_ONLY}, you'll always link the same library into -the program (normally \Opt{-l}\File{unwind}). Furthermore, the -portion of \Prog{libunwind} that manages unwind-info for dynamically -generated code is not affected by the setting of -\Const{UNW\_LOCAL\_ONLY}. - -If we put all of the above together, here is how we could use -\Prog{libunwind} to write a function ``\Func{show\_backtrace}()'' -which prints a classic stack trace: - -\begin{verbatim} -#define UNW_LOCAL_ONLY -#include - -void show_backtrace (void) { - unw_cursor_t cursor; unw_context_t uc; - unw_word_t ip, sp; - - unw_getcontext(&uc); - unw_init_local(&cursor, &uc); - while (unw_step(&cursor) > 0) { - unw_get_reg(&cursor, UNW_REG_IP, &ip); - unw_get_reg(&cursor, UNW_REG_SP, &sp); - printf ("ip = %lx, sp = %lx\n", (long) ip, (long) sp); - } -} -\end{verbatim} - - -\section{Remote Unwinding} - -\Prog{Libunwind} can also be used to unwind a stack in a ``remote'' -process. Here, ``remote'' may mean another process on the same -machine or even a process on a completely different machine from the -one that is running \Prog{libunwind}. Remote unwinding is typically -used by debuggers and instruction-set simulators, for example. - -Before you can unwind a remote process, you need to create a new -address-space object for that process. This is achieved with the -\Func{unw\_create\_addr\_space}() routine. The routine takes two -arguments: a pointer to a set of \emph{accessor} routines and an -integer that specifies the byte-order of the target process. The -accessor routines provide \Func{libunwind} with the means to -communicate with the remote process. In particular, there are -callbacks to read and write the process's memory, its registers, and -to access unwind information which may be needed by \Func{libunwind}. - -With the address space created, unwinding can be initiated by a call -to \Func{unw\_init\_remote}(). This routine is very similar to -\Func{unw\_init\_local}(), except that it takes an address-space -object and an opaque pointer as arguments. The routine uses these -arguments to fetch the initial machine state. \Prog{Libunwind} never -uses the opaque pointer on its own, but instead just passes it on to -the accessor (callback) routines. Typically, this pointer is used to -select, e.g., the thread within a process that is to be unwound. - -Once a cursor has been initialized with \Func{unw\_init\_remote}(), -unwinding works exactly like in the local case. That is, you can use -\Func{unw\_step}() to move ``up'' in the call-chain, read and write -registers, or resume execution at a particular stack frame by calling -\Func{unw\_resume}. - - -\section{Cross-platform and Multi-platform Unwinding} - -\Prog{Libunwind} has been designed to enable unwinding across -platforms (architectures). Indeed, a single program can use -\Prog{libunwind} to unwind an arbitrary number of target platforms, -all at the same time! - -We call the machine that is running \Prog{libunwind} the \emph{host} -and the machine that is running the process being unwound the -\emph{target}. If the host and the target platform are the same, we -call it \emph{native} unwinding. If they differ, we call it -\emph{cross-platform} unwinding. - -The principle behind supporting native, cross-platform, and -multi-platform unwinding is very simple: for native unwinding, a -program includes \File{$<$libunwind.h$>$} and uses the linker switch -\Opt{-l}\File{unwind}. For cross-platform unwinding, a program -includes \File{$<$libunwind-}\Var{PLAT}\File{.h$>$} and uses the linker -switch \Opt{-l}\File{unwind-}\Var{PLAT}, where \Var{PLAT} is the name -of the target platform (e.g., \File{ia64} for IA-64, \File{hppa-elf} -for ELF-based HP PA-RISC, or \File{x86} for 80386). Multi-platform -unwinding works exactly like cross-platform unwinding, the only -limitation is that a single source file (compilation unit) can include -at most one \Prog{libunwind} header file. In other words, the -platform-specific support for each supported target needs to be -isolated in separate source files---a limitation that shouldn't be an -issue in practice. - -Note that, by definition, local unwinding is possible only for the -native case. Attempting to call, e.g., \Func{unw\_local\_init}() when -targeting a cross-platform will result in a link-time error -(unresolved references). - - -\section{Thread- and Signal-Safety} - - -All \Prog{libunwind} routines are thread-safe. What this means is -that multiple threads may use \Prog{libunwind} simulatenously. -However, any given cursor may be accessed by only one thread at -any given time. - -To ensure thread-safety, some \Prog{libunwind} routines may have to -use locking. Such routines \emph{must~not} be called from signal -handlers (directly or indirectly) and are therefore \emph{not} -signal-safe. The manual page for each \Prog{libunwind} routine -identifies whether or not it is signal-safe, but as a general rule, -any routine that may be needed for \emph{local} unwinding is -signal-safe (e.g., \Func{unw\_step}() for local unwinding is -signal-safe). For remote-unwinding, \emph{none} of the -\Prog{libunwind} routines are guaranteed to be signal-safe. - - -\section{Unwinding Through Dynamically Generated Code} - -\Func{Libunwind} provides the routines \Func{\_U\_dyn\_register}() and -\Func{\_U\_dyn\_cancel}() to register/cancel the information required to -unwind through code that has been generated at runtime (e.g., by a -just-in-time (JIT) compiler). It is important to register the -information for \emph{all} dynamically generated code because -otherwise, a debugger may not be able to function properly or -high-level language exception handling may not work as expected. - -The interface for registering and canceling dynamic unwind info has -been designed for maximum efficiency, so as to minimize the -performance impact on JIT-compilers. In particular, both routines are -guaranteed to execute in ``constant time'' (O(1)) and the -data-structure encapsulating the dynamic unwind info has been designed -to facilitate sharing, such that similar procedures can share much of -the underlying information. - -For more information on the \Prog{libunwind} support for dynamically -generated code, see \SeeAlso{libunwind-dynamic(3)}. - - -\section{Caching of Unwind Info} - -To speed up execution, \Prog{libunwind} may aggressively cache the -information it needs to perform unwinding. If a process changes -during its lifetime, this creates a risk of \Prog{libunwind} using -stale data. For example, this would happen if \Prog{libunwind} were -to cache information about a shared library which later on gets -unloaded (e.g., via \Cmd{dlclose}{3}). - -To prevent the risk of using stale data, \Prog{libunwind} provides two -facilities: first, it is possible to flush the cached information -associated with a specific address range in the target process (or the -entire address space, if desired). This functionality is provided by -\Func{unw\_flush\_cache}(). The second facility is provided by -\Func{unw\_set\_caching\_policy}(), which lets a program -select the exact caching policy in use for a given address-space -object. In particular, by selecting the policy -\Const{UNW\_CACHE\_NONE}, it is possible to turn off caching -completely, therefore eliminating the risk of stale data alltogether -(at the cost of slower execution). By default, caching is enabled for -local unwinding only. The cache size can be dynamically changed with -\Func{unw\_set\_cache\_size}(), which also fluches the current cache. - - -\section{Files} - -\begin{Description} -\item[\File{libunwind.h}] Headerfile to include for native (same - platform) unwinding. -\item[\File{libunwind-}\Var{PLAT}\File{.h}] Headerfile to include when - the unwind target runs on platform \Var{PLAT}. For example, to unwind - an IA-64 program, the header file \File{libunwind-ia64.h} should be - included. -\item[\Opt{-l}\File{unwind}] Linker-switch to add when building a - program that does native (same platform) unwinding. -\item[\Opt{-l}\File{unwind-}\Var{PLAT}] Linker-switch to add when - building a program that unwinds a program on platform \Var{PLAT}. - For example, to (cross-)unwind an IA-64 program, the linker switch - \File{-lunwind-ia64} should be added. Note: multiple such switches - may need to be specified for programs that can unwind programs on - multiple platforms. -\end{Description} - -\section{See Also} - -\SeeAlso{libunwind-dynamic(3)}, -\SeeAlso{libunwind-ia64(3)}, -\SeeAlso{libunwind-ptrace(3)}, -\SeeAlso{libunwind-setjmp(3)}, -\SeeAlso{unw\_create\_addr\_space(3)}, -\SeeAlso{unw\_destroy\_addr\_space(3)}, -\SeeAlso{unw\_flush\_cache(3)}, -\SeeAlso{unw\_get\_accessors(3)}, -\SeeAlso{unw\_get\_fpreg(3)}, -\SeeAlso{unw\_get\_proc\_info(3)}, -\SeeAlso{unw\_get\_proc\_name(3)}, -\SeeAlso{unw\_get\_reg(3)}, -\SeeAlso{unw\_getcontext(3)}, -\SeeAlso{unw\_init\_local(3)}, -\SeeAlso{unw\_init\_remote(3)}, -\SeeAlso{unw\_is\_fpreg(3)}, -\SeeAlso{unw\_is\_signal\_frame(3)}, -\SeeAlso{unw\_regname(3)}, -\SeeAlso{unw\_resume(3)}, -\SeeAlso{unw\_set\_caching\_policy(3)}, -\SeeAlso{unw\_set\_cache\_size(3)}, -\SeeAlso{unw\_set\_fpreg(3)}, -\SeeAlso{unw\_set\_reg(3)}, -\SeeAlso{unw\_step(3)}, -\SeeAlso{unw\_strerror(3)}, -\SeeAlso{\_U\_dyn\_register(3)}, -\SeeAlso{\_U\_dyn\_cancel(3)} - -\section{Author} - -\noindent -David Mosberger-Tang\\ -Email: \Email{dmosberger@gmail.com}\\ -WWW: \URL{http://www.nongnu.org/libunwind/}. -\LatexManEnd - -\end{document} diff --git a/src/pal/src/libunwind/doc/libunwind.trans b/src/pal/src/libunwind/doc/libunwind.trans deleted file mode 100644 index a514e5a08..000000000 --- a/src/pal/src/libunwind/doc/libunwind.trans +++ /dev/null @@ -1,34 +0,0 @@ -$manMacro1a{'Type'} = $manMacro1a{File}; - $manMacro1b{'Type'} = $manMacro1b{File}; -$htmlMacro1a{'Type'} = $htmlMacro1a{File}; - $htmlMacro1b{'Type'} = $htmlMacro1b{File}; -$texiMacro1a{'Type'} = $texiMacro1a{File}; - $texiMacro1b{'Type'} = $texiMacro1b{File}; -$manMacro1a{'Func'} = $manMacro1a{Prog}; - $manMacro1b{'Func'} = $manMacro1b{Prog}; -$htmlMacro1a{'Func'} = $htmlMacro1a{Arg}; - $htmlMacro1b{'Func'} = $htmlMacro1b{Arg}; -$texiMacro1a{'Func'} = $texiMacro1a{Prog}; - $texiMacro1b{'Func'} = $texiMacro1b{Prog}; -$manMacro1a{'Var'} = $manMacro1a{Prog}; - $manMacro1b{'Var'} = $manMacro1b{Prog}; -$htmlMacro1a{'Var'} = $htmlMacro1a{Prog}; - $htmlMacro1b{'Var'} = $htmlMacro1b{Prog}; -$texiMacro1a{'Var'} = $texiMacro1a{Prog}; - $texiMacro1b{'Var'} = $texiMacro1b{Prog}; -$manMacro1a{'Const'} = $manMacro1a{File}; - $manMacro1b{'Const'} = $manMacro1b{File}; -$htmlMacro1a{'Const'} = $htmlMacro1a{File}; - $htmlMacro1b{'Const'} = $htmlMacro1b{File}; -$texiMacro1a{'Const'} = $texiMacro1a{File}; - $texiMacro1b{'Const'} = $texiMacro1b{File}; - -$manMacro1a{'SeeAlso'} = $manMacro1a{File}; - $manMacro1b{'SeeAlso'} = $manMacro1b{File}; -# special handling of SeeAlso in latex2man, so that argument gets doubled: -$htmlMacro2a{'SeeAlso'} = "$htmlMacro1a{File}"; - $htmlMacro2c{'SeeAlso'} = "$htmlMacro1b{File}"; -$texiMacro1a{'SeeAlso'} = $texiMacro1a{File}; - $texiMacro1b{'SeeAlso'} = $texiMacro1b{File}; - diff --git a/src/pal/src/libunwind/doc/unw_apply_reg_state.man b/src/pal/src/libunwind/doc/unw_apply_reg_state.man deleted file mode 100644 index 457f0c4dd..000000000 --- a/src/pal/src/libunwind/doc/unw_apply_reg_state.man +++ /dev/null @@ -1,90 +0,0 @@ -'\" t -.\" Manual page created with latex2man on Wed Aug 16 11:09:44 PDT 2017 -.\" NOTE: This file is generated, DO NOT EDIT. -.de Vb -.ft CW -.nf -.. -.de Ve -.ft R - -.fi -.. -.TH "UNW\\_APPLY\\_REG\\_STATE" "3" "16 August 2017" "Programming Library " "Programming Library " -.SH NAME -unw_apply_reg_state -\-\- apply a register state update to a cursor -.PP -.SH SYNOPSIS - -.PP -#include -.br -.PP -int -unw_apply_reg_state(unw_cursor_t *cp, -void *reg_states_data); -.br -.PP -.SH DESCRIPTION - -.PP -The unw_apply_reg_state() -routine updates the register values -of a cursor according to the instructions in reg_states_data, -which have been obtained by calling unw_reg_states_iterate\&. -.PP -.SH RETURN VALUE - -.PP -On successful completion, unw_apply_reg_state() -returns 0. -Otherwise the negative value of one of the error\-codes below is -returned. -.PP -.SH THREAD AND SIGNAL SAFETY - -.PP -unw_apply_reg_state() -is thread\-safe. If cursor cp -is -in the local address\-space, this routine is also safe to use from a -signal handler. -.PP -.SH ERRORS - -.PP -.TP -UNW_EUNSPEC - An unspecified error occurred. -.TP -UNW_ENOINFO - Libunwind -was unable to locate -unwind\-info for the procedure. -.TP -UNW_EBADVERSION - The unwind\-info for the procedure has -version or format that is not understood by libunwind\&. -.PP -In addition, unw_apply_reg_state() -may return any error -returned by the access_mem() -call\-back (see -unw_create_addr_space(3)). -.PP -.SH SEE ALSO - -.PP -libunwind(3), -unw_reg_states_iterate(3) -.PP -.SH AUTHOR - -.PP -David Mosberger\-Tang -.br -Email: \fBdmosberger@gmail.com\fP -.br -WWW: \fBhttp://www.nongnu.org/libunwind/\fP\&. -.\" NOTE: This file is generated, DO NOT EDIT. diff --git a/src/pal/src/libunwind/doc/unw_apply_reg_state.tex b/src/pal/src/libunwind/doc/unw_apply_reg_state.tex deleted file mode 100644 index c67cc3ebf..000000000 --- a/src/pal/src/libunwind/doc/unw_apply_reg_state.tex +++ /dev/null @@ -1,63 +0,0 @@ -\documentclass{article} -\usepackage[fancyhdr,pdf]{latex2man} - -\input{common.tex} - -\begin{document} - -\begin{Name}{3}{unw\_apply\_reg\_state}{David Mosberger-Tang}{Programming Library}{unw\_apply\_reg\_state}unw\_apply\_reg\_state -- apply a register state update to a cursor -\end{Name} - -\section{Synopsis} - -\File{\#include $<$libunwind.h$>$}\\ - -\Type{int} -\Func{unw\_apply\_reg\_state}(\Type{unw\_cursor\_t~*}\Var{cp}, -\Type{void~*}\Var{reg\_states\_data});\\ - -\section{Description} - -The \Func{unw\_apply\_reg\_state}() routine updates the register values -of a cursor according to the instructions in \Var{reg\_states\_data}, -which have been obtained by calling \Var{unw\_reg\_states\_iterate}. - -\section{Return Value} - -On successful completion, \Func{unw\_apply\_reg\_state}() returns 0. -Otherwise the negative value of one of the error-codes below is -returned. - -\section{Thread and Signal Safety} - -\Func{unw\_apply\_reg\_state}() is thread-safe. If cursor \Var{cp} is -in the local address-space, this routine is also safe to use from a -signal handler. - -\section{Errors} - -\begin{Description} -\item[\Const{UNW\_EUNSPEC}] An unspecified error occurred. -\item[\Const{UNW\_ENOINFO}] \Prog{Libunwind} was unable to locate - unwind-info for the procedure. -\item[\Const{UNW\_EBADVERSION}] The unwind-info for the procedure has - version or format that is not understood by \Prog{libunwind}. -\end{Description} -In addition, \Func{unw\_apply\_reg\_state}() may return any error -returned by the \Func{access\_mem}() call-back (see -\Func{unw\_create\_addr\_space}(3)). - -\section{See Also} - -\SeeAlso{libunwind(3)}, -\SeeAlso{unw\_reg\_states\_iterate(3)} - -\section{Author} - -\noindent -David Mosberger-Tang\\ -Email: \Email{dmosberger@gmail.com}\\ -WWW: \URL{http://www.nongnu.org/libunwind/}. -\LatexManEnd - -\end{document} diff --git a/src/pal/src/libunwind/doc/unw_backtrace.man b/src/pal/src/libunwind/doc/unw_backtrace.man deleted file mode 100644 index 5699bbfe2..000000000 --- a/src/pal/src/libunwind/doc/unw_backtrace.man +++ /dev/null @@ -1,86 +0,0 @@ -'\" t -.\" Manual page created with latex2man on Fri Aug 31 13:39:04 EEST 2012 -.\" NOTE: This file is generated, DO NOT EDIT. -.de Vb -.ft CW -.nf -.. -.de Ve -.ft R - -.fi -.. -.TH "UNW\\_BACKTRACE" "3" "31 August 2012" "Programming Library " "Programming Library " -.SH NAME -unw_backtrace -\-\- return backtrace for the calling program -.PP -.SH SYNOPSIS - -.PP -#include -.br -.PP -int -unw_backtrace(void **buffer, -int size); -.br -.PP -#include -.br -.PP -int -backtrace(void **buffer, -int size); -.br -.PP -.SH DESCRIPTION - -.PP -unw_backtrace() -is a convenient routine for obtaining the backtrace for -the calling program. The routine fills up to size -addresses in the array -pointed by buffer\&. -The routine is only available for local unwinding. -.PP -Note that many (but not all) systems provide practically identical function -called backtrace(). -The prototype for this function is usually obtained -by including the -header file \-\- a prototype for -backtrace() -is not provided by libunwind\&. -libunwind -weakly -aliases backtrace() -to unw_backtrace(), -so when a program -calling backtrace() -is linked against libunwind, -it may end up -calling unw_backtrace(). -.PP -.SH RETURN VALUE - -.PP -The routine returns the number of addresses stored in the array pointed by -buffer\&. -The return value may be zero to indicate that no addresses were -stored. -.PP -.SH SEE ALSO - -.PP -libunwind(3), -unw_step(3) -.PP -.SH AUTHOR - -.PP -David Mosberger\-Tang -.br -Email: \fBdmosberger@gmail.com\fP -.br -WWW: \fBhttp://www.nongnu.org/libunwind/\fP\&. -.\" NOTE: This file is generated, DO NOT EDIT. diff --git a/src/pal/src/libunwind/doc/unw_backtrace.tex b/src/pal/src/libunwind/doc/unw_backtrace.tex deleted file mode 100644 index c383eeb37..000000000 --- a/src/pal/src/libunwind/doc/unw_backtrace.tex +++ /dev/null @@ -1,54 +0,0 @@ -\documentclass{article} -\usepackage[fancyhdr,pdf]{latex2man} - -\input{common.tex} - -\begin{document} - -\begin{Name}{3}{unw\_backtrace}{David Mosberger-Tang}{Programming Library}{unw\_backtrace}unw\_backtrace -- return backtrace for the calling program -\end{Name} - -\section{Synopsis} - -\File{\#include $<$libunwind.h$>$}\\ - -\Type{int} \Func{unw\_backtrace}(\Type{void~**}\Var{buffer}, \Type{int}~\Var{size});\\ - -\File{\#include $<$execinfo.h$>$}\\ - -\Type{int} \Func{backtrace}(\Type{void~**}\Var{buffer}, \Type{int}~\Var{size});\\ - -\section{Description} - -\Func{unw\_backtrace}() is a convenient routine for obtaining the backtrace for -the calling program. The routine fills up to \Var{size} addresses in the array -pointed by \Var{buffer}. The routine is only available for local unwinding. - -Note that many (but not all) systems provide practically identical function -called \Func{backtrace}(). The prototype for this function is usually obtained -by including the \File{$<$execinfo.h$>$} header file -- a prototype for -\Func{backtrace}() is not provided by \Prog{libunwind}. \Prog{libunwind} weakly -aliases \Func{backtrace}() to \Func{unw\_backtrace}(), so when a program -calling \Func{backtrace}() is linked against \Prog{libunwind}, it may end up -calling \Func{unw\_backtrace}(). - -\section{Return Value} - -The routine returns the number of addresses stored in the array pointed by -\Var{buffer}. The return value may be zero to indicate that no addresses were -stored. - -\section{See Also} - -\SeeAlso{libunwind(3)}, -\SeeAlso{unw\_step(3)} - -\section{Author} - -\noindent -David Mosberger-Tang\\ -Email: \Email{dmosberger@gmail.com}\\ -WWW: \URL{http://www.nongnu.org/libunwind/}. -\LatexManEnd - -\end{document} diff --git a/src/pal/src/libunwind/doc/unw_create_addr_space.man b/src/pal/src/libunwind/doc/unw_create_addr_space.man deleted file mode 100644 index 4aca13ecd..000000000 --- a/src/pal/src/libunwind/doc/unw_create_addr_space.man +++ /dev/null @@ -1,457 +0,0 @@ -'\" t -.\" Manual page created with latex2man on Thu Aug 16 09:44:45 MDT 2007 -.\" NOTE: This file is generated, DO NOT EDIT. -.de Vb -.ft CW -.nf -.. -.de Ve -.ft R - -.fi -.. -.TH "UNW\\_CREATE\\_ADDR\\_SPACE" "3" "16 August 2007" "Programming Library " "Programming Library " -.SH NAME -unw_create_addr_space -\-\- create address space for remote unwinding -.PP -.SH SYNOPSIS - -.PP -#include -.br -.PP -unw_addr_space_t -unw_create_addr_space(unw_accessors_t *ap, -int -byteorder); -.br -.PP -.SH DESCRIPTION - -.PP -The unw_create_addr_space() -routine creates a new unwind -address\-space and initializes it based on the call\-back routines -passed via the ap -pointer and the specified byteorder\&. -The call\-back routines are described in detail below. The -byteorder -can be set to 0 to request the default byte\-order of -the unwind target. To request a particular byte\-order, -byteorder -can be set to any constant defined by -\&. -In particular, __LITTLE_ENDIAN -would -request little\-endian byte\-order and __BIG_ENDIAN -would -request big\-endian byte\-order. Whether or not a particular byte\-order -is supported depends on the target platform. -.PP -.SH CALL\-BACK ROUTINES - -.PP -Libunwind -uses a set of call\-back routines to access the -information it needs to unwind a chain of stack\-frames. These -routines are specified via the ap -argument, which points to a -variable of type unw_accessors_t\&. -The contents of this -variable is copied into the newly\-created address space, so the -variable must remain valid only for the duration of the call to -unw_create_addr_space(). -.PP -The first argument to every call\-back routine is an address\-space -identifier (as) -and the last argument is an arbitrary, -application\-specified void\-pointer (arg). -When invoking a -call\-back routine, libunwind -sets the as -argument to the -address\-space on whose behalf the invocation is made and the arg -argument to the value that was specified when -unw_init_remote(3) -was called. -.PP -The synopsis and a detailed description of every call\-back routine -follows below. -.PP -.SS CALL\-BACK ROUTINE SYNOPSIS -.PP -int -find_proc_info(unw_addr_space_t -as, -.br -\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fPunw_word_t -ip, -unw_proc_info_t *pip, -.br -\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fPint -need_unwind_info, -void *arg); -.br -void -put_unwind_info(unw_addr_space_t -as, -.br -\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fPunw_proc_info_t *pip, -void *arg); -.br -int -get_dyn_info_list_addr(unw_addr_space_t -as, -.br -\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fPunw_word_t *dilap, -void *arg); -.br -int -access_mem(unw_addr_space_t -as, -.br -\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fPunw_word_t -addr, -unw_word_t *valp, -.br -\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fPint -write, -void *arg); -.br -int -access_reg(unw_addr_space_t -as, -.br -\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fPunw_regnum_t -regnum, -unw_word_t *valp, -.br -\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fPint -write, -void *arg); -.br -int -access_fpreg(unw_addr_space_t -as, -.br -\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fPunw_regnum_t -regnum, -unw_fpreg_t *fpvalp, -.br -\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fPint -write, -void *arg); -.br -int -resume(unw_addr_space_t -as, -.br -\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fPunw_cursor_t *cp, -void *arg); -.br -int -get_proc_name(unw_addr_space_t -as, -.br -\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fPunw_word_t -addr, -char *bufp, -.br -\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fPsize_t -buf_len, -unw_word_t *offp, -.br -\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fP\fB \fPvoid *arg); -.br -.PP -.SS FIND_PROC_INFO -.PP -Libunwind -invokes the find_proc_info() -call\-back to -locate the information need to unwind a particular procedure. The -ip -argument is an instruction\-address inside the procedure whose -information is needed. The pip -argument is a pointer to the -variable used to return the desired information. The type of this -variable is unw_proc_info_t\&. -See -unw_get_proc_info(3) -for details. Argument -need_unwind_info -is zero if the call\-back does not need to -provide values for the following members in the -unw_proc_info_t -structure: format, -unwind_info_size, -and unwind_info\&. -If -need_unwind_info -is non\-zero, valid values need to be returned -in these members. Furthermore, the contents of the memory addressed -by the unwind_info -member must remain valid until the info is -released via the put_unwind_info -call\-back (see below). -.PP -On successful completion, the find_proc_info() -call\-back must -return zero. Otherwise, the negative value of one of the -unw_error_t -error\-codes may be returned. In particular, this -call\-back may return \-UNW_ESTOPUNWIND -to signal the end of -the frame\-chain. -.PP -.SS PUT_UNWIND_INFO -.PP -Libunwind -invokes the put_unwind_info() -call\-back to -release the resources (such as memory) allocated by a previous call to -find_proc_info() -with the need_unwind_info -argument -set to a non\-zero value. The pip -argument has the same value as -the argument of the same name in the previous matching call to -find_proc_info(). -Note that libunwind -does \fInot\fP -invoke put_unwind_info -for calls to find_proc_info() -with a zero need_unwind_info -argument. -.PP -.SS GET_DYN_INFO_LIST_ADDR -.PP -Libunwind -invokes the get_dyn_info_list_addr() -call\-back to obtain the address of the head of the dynamic unwind\-info -registration list. The variable stored at the returned address must -have a type of unw_dyn_info_list_t -(see -_U_dyn_register(3)). -The dliap -argument is a pointer -to a variable of type unw_word_t -which is used to return the -address of the dynamic unwind\-info registration list. If no dynamic -unwind\-info registration list exist, the value pointed to by -dliap -must be cleared to zero. Libunwind -will cache the -value returned by get_dyn_info_list_addr() -if caching is -enabled for the given address\-space. The cache can be cleared with a -call to unw_flush_cache(). -.PP -On successful completion, the get_dyn_info_list_addr() -call\-back must return zero. Otherwise, the negative value of one of -the unw_error_t -error\-codes may be returned. -.PP -.SS ACCESS_MEM -.PP -Libunwind -invokes the access_mem() -call\-back to read -from or write to a word of memory in the target address\-space. The -address of the word to be accessed is passed in argument addr\&. -To read memory, libunwind -sets argument write -to zero and -valp -to point to the word that receives the read value. To -write memory, libunwind -sets argument write -to a non\-zero -value and valp -to point to the word that contains the value to -be written. The word that valp -points to is always in the -byte\-order of the host\-platform, regardless of the byte\-order of the -target. In other words, it is the responsibility of the call\-back -routine to convert between the target\&'s and the host\&'s byte\-order, if -necessary. -.PP -On successful completion, the access_mem() -call\-back must return zero. Otherwise, the negative value of one of -the unw_error_t -error\-codes may be returned. -.PP -.SS ACCESS_REG -.PP -Libunwind -invokes the access_reg() -call\-back to read -from or write to a scalar (non\-floating\-point) CPU register. The -index of the register to be accessed is passed in argument -regnum\&. -To read a register, libunwind -sets argument -write -to zero and valp -to point to the word that receives -the read value. To write a register, libunwind -sets argument -write -to a non\-zero value and valp -to point to the word -that contains the value to be written. The word that valp -points to is always in the byte\-order of the host\-platform, regardless -of the byte\-order of the target. In other words, it is the -responsibility of the call\-back routine to convert between the -target\&'s and the host\&'s byte\-order, if necessary. -.PP -On successful completion, the access_reg() -call\-back must -return zero. Otherwise, the negative value of one of the -unw_error_t -error\-codes may be returned. -.PP -.SS ACCESS_FPREG -.PP -Libunwind -invokes the access_fpreg() -call\-back to read -from or write to a floating\-point CPU register. The index of the -register to be accessed is passed in argument regnum\&. -To read a -register, libunwind -sets argument write -to zero and -fpvalp -to point to a variable of type unw_fpreg_t -that -receives the read value. To write a register, libunwind -sets -argument write -to a non\-zero value and fpvalp -to point to -the variable of type unw_fpreg_t -that contains the value to -be written. The word that fpvalp -points to is always in the -byte\-order of the host\-platform, regardless of the byte\-order of the -target. In other words, it is the responsibility of the call\-back -routine to convert between the target\&'s and the host\&'s byte\-order, if -necessary. -.PP -On successful completion, the access_fpreg() -call\-back must -return zero. Otherwise, the negative value of one of the -unw_error_t -error\-codes may be returned. -.PP -.SS RESUME -.PP -Libunwind -invokes the resume() -call\-back to resume -execution in the target address space. Argument cp -is the -unwind\-cursor that identifies the stack\-frame in which execution -should resume. By the time libunwind -invokes the resume -call\-back, it has already established the desired machine\- and -memory\-state via calls to the access_reg(), -access_fpreg, -and access_mem() -call\-backs. Thus, all -the call\-back needs to do is perform whatever action is needed to -actually resume execution. -.PP -The resume -call\-back is invoked only in response to a call to -unw_resume(3), -so applications which never invoke -unw_resume(3) -need not define the resume -callback. -.PP -On successful completion, the resume() -call\-back must return -zero. Otherwise, the negative value of one of the -unw_error_t -error\-codes may be returned. As a special case, -when resuming execution in the local address space, the call\-back will -not return on success. -.PP -.SS GET_PROC_NAME -.PP -Libunwind -invokes the get_proc_name() -call\-back to -obtain the procedure\-name of a static (not dynamically generated) -procedure. Argument addr -is an instruction\-address within the -procedure whose name is to be obtained. The bufp -argument is a -pointer to a character\-buffer used to return the procedure name. The -size of this buffer is specified in argument buf_len\&. -The -returned name must be terminated by a NUL character. If the -procedure\&'s name is longer than buf_len -bytes, it must be -truncated to buf_len\-1 -bytes, with the last byte in the -buffer set to the NUL character and \-UNW_ENOMEM -must be -returned. Argument offp -is a pointer to a word which is used to -return the byte\-offset relative to the start of the procedure whose -name is being returned. For example, if procedure foo() -starts -at address 0x40003000, then invoking get_proc_name() -with -addr -set to 0x40003080 should return a value of 0x80 in the word -pointed to by offp -(assuming the procedure is at least 0x80 -bytes long). -.PP -On successful completion, the get_proc_name() -call\-back must -return zero. Otherwise, the negative value of one of the -unw_error_t -error\-codes may be returned. -.PP -.SH RETURN VALUE - -.PP -On successful completion, unw_create_addr_space() -returns a -non\-NULL -value that represents the newly created -address\-space. Otherwise, NULL -is returned. -.PP -.SH THREAD AND SIGNAL SAFETY - -.PP -unw_create_addr_space() -is thread\-safe but \fInot\fP -safe to use from a signal handler. -.PP -.SH SEE ALSO - -.PP -_U_dyn_register(3), -libunwind(3), -unw_destroy_addr_space(3), -unw_get_proc_info(3), -unw_init_remote(3), -unw_resume(3) -.PP -.SH AUTHOR - -.PP -David Mosberger\-Tang -.br -Email: \fBdmosberger@gmail.com\fP -.br -WWW: \fBhttp://www.nongnu.org/libunwind/\fP\&. -.\" NOTE: This file is generated, DO NOT EDIT. diff --git a/src/pal/src/libunwind/doc/unw_create_addr_space.tex b/src/pal/src/libunwind/doc/unw_create_addr_space.tex deleted file mode 100644 index 8de0691f3..000000000 --- a/src/pal/src/libunwind/doc/unw_create_addr_space.tex +++ /dev/null @@ -1,265 +0,0 @@ -\documentclass{article} -\usepackage[fancyhdr,pdf]{latex2man} - -\input{common.tex} - -\begin{document} - -\begin{Name}{3}{unw\_create\_addr\_space}{David Mosberger-Tang}{Programming Library}{unw\_create\_addr\_space}unw\_create\_addr\_space -- create address space for remote unwinding -\end{Name} - -\section{Synopsis} - -\File{\#include $<$libunwind.h$>$}\\ - -\Type{unw\_addr\_space\_t} \Func{unw\_create\_addr\_space}(\Type{unw\_accessors\_t~*}\Var{ap}, \Type{int} \Var{byteorder});\\ - -\section{Description} - -The \Func{unw\_create\_addr\_space}() routine creates a new unwind -address-space and initializes it based on the call-back routines -passed via the \Var{ap} pointer and the specified \Var{byteorder}. -The call-back routines are described in detail below. The -\Var{byteorder} can be set to 0 to request the default byte-order of -the unwind target. To request a particular byte-order, -\Var{byteorder} can be set to any constant defined by -\File{$<$endian.h$>$}. In particular, \Const{\_\_LITTLE\_ENDIAN} would -request little-endian byte-order and \Const{\_\_BIG\_ENDIAN} would -request big-endian byte-order. Whether or not a particular byte-order -is supported depends on the target platform. - -\section{Call-back Routines} - -\Prog{Libunwind} uses a set of call-back routines to access the -information it needs to unwind a chain of stack-frames. These -routines are specified via the \Var{ap} argument, which points to a -variable of type \Type{unw\_accessors\_t}. The contents of this -variable is copied into the newly-created address space, so the -variable must remain valid only for the duration of the call to -\Func{unw\_create\_addr\_space}(). - -The first argument to every call-back routine is an address-space -identifier (\Var{as}) and the last argument is an arbitrary, -application-specified void-pointer (\Var{arg}). When invoking a -call-back routine, \Prog{libunwind} sets the \Var{as} argument to the -address-space on whose behalf the invocation is made and the \Var{arg} -argument to the value that was specified when -\Func{unw\_init\_remote}(3) was called. - -The synopsis and a detailed description of every call-back routine -follows below. - -\subsection{Call-back Routine Synopsis} - -\Type{int} \Func{find\_proc\_info}(\Type{unw\_addr\_space\_t} \Var{as},\\ -\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\Type{unw\_word\_t} \Var{ip}, \Type{unw\_proc\_info\_t~*}\Var{pip},\\ -\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\Type{int} \Var{need\_unwind\_info}, \Type{void~*}arg);\\ -\Type{void} \Func{put\_unwind\_info}(\Type{unw\_addr\_space\_t} \Var{as},\\ -\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\Type{unw\_proc\_info\_t~*}pip, \Type{void~*}\Var{arg});\\ -\Type{int} \Func{get\_dyn\_info\_list\_addr}(\Type{unw\_addr\_space\_t} \Var{as},\\ -\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\Type{unw\_word\_t~*}\Var{dilap}, \Type{void~*}\Var{arg});\\ -\Type{int} \Func{access\_mem}(\Var{unw\_addr\_space\_t} \Var{as},\\ -\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\Type{unw\_word\_t} \Var{addr}, \Type{unw\_word\_t~*}\Var{valp},\\ -\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\Type{int} \Var{write}, \Type{void~*}\Var{arg});\\ -\Type{int} \Func{access\_reg}(\Var{unw\_addr\_space\_t} \Var{as},\\ -\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\Type{unw\_regnum\_t} \Var{regnum}, \Type{unw\_word\_t~*}\Var{valp},\\ -\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\Type{int} \Var{write}, \Type{void~*}\Var{arg});\\ -\Type{int} \Func{access\_fpreg}(\Var{unw\_addr\_space\_t} \Var{as},\\ -\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\Type{unw\_regnum\_t} \Var{regnum}, \Type{unw\_fpreg\_t~*}\Var{fpvalp},\\ -\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\Type{int} \Var{write}, \Type{void~*}\Var{arg});\\ -\Type{int} \Func{resume}(\Var{unw\_addr\_space\_t} \Var{as},\\ -\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\Type{unw\_cursor\_t~*}\Var{cp}, \Type{void~*}\Var{arg});\\ -\Type{int} \Func{get\_proc\_name}(\Type{unw\_addr\_space\_t} \Var{as},\\ -\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\Type{unw\_word\_t} \Var{addr}, \Type{char~*}\Var{bufp},\\ -\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\Type{size\_t} \Var{buf\_len}, \Type{unw\_word\_t~*}\Var{offp},\\ -\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\SP\Type{void~*}\Var{arg});\\ - -\subsection{find\_proc\_info} - -\Prog{Libunwind} invokes the \Func{find\_proc\_info}() call-back to -locate the information need to unwind a particular procedure. The -\Var{ip} argument is an instruction-address inside the procedure whose -information is needed. The \Var{pip} argument is a pointer to the -variable used to return the desired information. The type of this -variable is \Type{unw\_proc\_info\_t}. See -\Func{unw\_get\_proc\_info(3)} for details. Argument -\Var{need\_unwind\_info} is zero if the call-back does not need to -provide values for the following members in the -\Type{unw\_proc\_info\_t} structure: \Var{format}, -\Var{unwind\_info\_size}, and \Var{unwind\_info}. If -\Var{need\_unwind\_info} is non-zero, valid values need to be returned -in these members. Furthermore, the contents of the memory addressed -by the \Var{unwind\_info} member must remain valid until the info is -released via the \Func{put\_unwind\_info} call-back (see below). - -On successful completion, the \Func{find\_proc\_info}() call-back must -return zero. Otherwise, the negative value of one of the -\Type{unw\_error\_t} error-codes may be returned. In particular, this -call-back may return -\Const{UNW\_ESTOPUNWIND} to signal the end of -the frame-chain. - -\subsection{put\_unwind\_info} - -\Prog{Libunwind} invokes the \Func{put\_unwind\_info}() call-back to -release the resources (such as memory) allocated by a previous call to -\Func{find\_proc\_info}() with the \Var{need\_unwind\_info} argument -set to a non-zero value. The \Var{pip} argument has the same value as -the argument of the same name in the previous matching call to -\Func{find\_proc\_info}(). Note that \Prog{libunwind} does \emph{not} -invoke \Func{put\_unwind\_info} for calls to \Func{find\_proc\_info}() -with a zero \Var{need\_unwind\_info} argument. - - -\subsection{get\_dyn\_info\_list\_addr} - -\Prog{Libunwind} invokes the \Func{get\_dyn\_info\_list\_addr}() -call-back to obtain the address of the head of the dynamic unwind-info -registration list. The variable stored at the returned address must -have a type of \Type{unw\_dyn\_info\_list\_t} (see -\Func{\_U\_dyn\_register}(3)). The \Var{dliap} argument is a pointer -to a variable of type \Type{unw\_word\_t} which is used to return the -address of the dynamic unwind-info registration list. If no dynamic -unwind-info registration list exist, the value pointed to by -\Var{dliap} must be cleared to zero. \Prog{Libunwind} will cache the -value returned by \Func{get\_dyn\_info\_list\_addr}() if caching is -enabled for the given address-space. The cache can be cleared with a -call to \Func{unw\_flush\_cache}(). - -On successful completion, the \Func{get\_dyn\_info\_list\_addr}() -call-back must return zero. Otherwise, the negative value of one of -the \Type{unw\_error\_t} error-codes may be returned. - -\subsection{access\_mem} - -\Prog{Libunwind} invokes the \Func{access\_mem}() call-back to read -from or write to a word of memory in the target address-space. The -address of the word to be accessed is passed in argument \Var{addr}. -To read memory, \Prog{libunwind} sets argument \Var{write} to zero and -\Var{valp} to point to the word that receives the read value. To -write memory, \Prog{libunwind} sets argument \Var{write} to a non-zero -value and \Var{valp} to point to the word that contains the value to -be written. The word that \Var{valp} points to is always in the -byte-order of the host-platform, regardless of the byte-order of the -target. In other words, it is the responsibility of the call-back -routine to convert between the target's and the host's byte-order, if -necessary. - -On successful completion, the \Func{access\_mem}() -call-back must return zero. Otherwise, the negative value of one of -the \Type{unw\_error\_t} error-codes may be returned. - -\subsection{access\_reg} - -\Prog{Libunwind} invokes the \Func{access\_reg}() call-back to read -from or write to a scalar (non-floating-point) CPU register. The -index of the register to be accessed is passed in argument -\Var{regnum}. To read a register, \Prog{libunwind} sets argument -\Var{write} to zero and \Var{valp} to point to the word that receives -the read value. To write a register, \Prog{libunwind} sets argument -\Var{write} to a non-zero value and \Var{valp} to point to the word -that contains the value to be written. The word that \Var{valp} -points to is always in the byte-order of the host-platform, regardless -of the byte-order of the target. In other words, it is the -responsibility of the call-back routine to convert between the -target's and the host's byte-order, if necessary. - -On successful completion, the \Func{access\_reg}() call-back must -return zero. Otherwise, the negative value of one of the -\Type{unw\_error\_t} error-codes may be returned. - -\subsection{access\_fpreg} - -\Prog{Libunwind} invokes the \Func{access\_fpreg}() call-back to read -from or write to a floating-point CPU register. The index of the -register to be accessed is passed in argument \Var{regnum}. To read a -register, \Prog{libunwind} sets argument \Var{write} to zero and -\Var{fpvalp} to point to a variable of type \Type{unw\_fpreg\_t} that -receives the read value. To write a register, \Prog{libunwind} sets -argument \Var{write} to a non-zero value and \Var{fpvalp} to point to -the variable of type \Type{unw\_fpreg\_t} that contains the value to -be written. The word that \Var{fpvalp} points to is always in the -byte-order of the host-platform, regardless of the byte-order of the -target. In other words, it is the responsibility of the call-back -routine to convert between the target's and the host's byte-order, if -necessary. - -On successful completion, the \Func{access\_fpreg}() call-back must -return zero. Otherwise, the negative value of one of the -\Type{unw\_error\_t} error-codes may be returned. - -\subsection{resume} - -\Prog{Libunwind} invokes the \Func{resume}() call-back to resume -execution in the target address space. Argument \Var{cp} is the -unwind-cursor that identifies the stack-frame in which execution -should resume. By the time \Prog{libunwind} invokes the \Func{resume} -call-back, it has already established the desired machine- and -memory-state via calls to the \Func{access\_reg}(), -\Func{access\_fpreg}, and \Func{access\_mem}() call-backs. Thus, all -the call-back needs to do is perform whatever action is needed to -actually resume execution. - -The \Func{resume} call-back is invoked only in response to a call to -\Func{unw\_resume}(3), so applications which never invoke -\Func{unw\_resume}(3) need not define the \Func{resume} callback. - -On successful completion, the \Func{resume}() call-back must return -zero. Otherwise, the negative value of one of the -\Type{unw\_error\_t} error-codes may be returned. As a special case, -when resuming execution in the local address space, the call-back will -not return on success. - -\subsection{get\_proc\_name} - -\Prog{Libunwind} invokes the \Func{get\_proc\_name}() call-back to -obtain the procedure-name of a static (not dynamically generated) -procedure. Argument \Var{addr} is an instruction-address within the -procedure whose name is to be obtained. The \Var{bufp} argument is a -pointer to a character-buffer used to return the procedure name. The -size of this buffer is specified in argument \Var{buf\_len}. The -returned name must be terminated by a NUL character. If the -procedure's name is longer than \Var{buf\_len} bytes, it must be -truncated to \Var{buf\_len}\Prog{-1} bytes, with the last byte in the -buffer set to the NUL character and -\Const{UNW\_ENOMEM} must be -returned. Argument \Var{offp} is a pointer to a word which is used to -return the byte-offset relative to the start of the procedure whose -name is being returned. For example, if procedure \Func{foo}() starts -at address 0x40003000, then invoking \Func{get\_proc\_name}() with -\Var{addr} set to 0x40003080 should return a value of 0x80 in the word -pointed to by \Var{offp} (assuming the procedure is at least 0x80 -bytes long). - -On successful completion, the \Func{get\_proc\_name}() call-back must -return zero. Otherwise, the negative value of one of the -\Type{unw\_error\_t} error-codes may be returned. - - -\section{Return Value} - -On successful completion, \Func{unw\_create\_addr\_space}() returns a -non-\Const{NULL} value that represents the newly created -address-space. Otherwise, \Const{NULL} is returned. - -\section{Thread and Signal Safety} - -\Func{unw\_create\_addr\_space}() is thread-safe but \emph{not} -safe to use from a signal handler. - -\section{See Also} - -\SeeAlso{\_U\_dyn\_register(3)}, -\SeeAlso{libunwind(3)}, -\SeeAlso{unw\_destroy\_addr\_space(3)}, -\SeeAlso{unw\_get\_proc\_info(3)}, -\SeeAlso{unw\_init\_remote(3)}, -\SeeAlso{unw\_resume(3)} - -\section{Author} - -\noindent -David Mosberger-Tang\\ -Email: \Email{dmosberger@gmail.com}\\ -WWW: \URL{http://www.nongnu.org/libunwind/}. -\LatexManEnd - -\end{document} diff --git a/src/pal/src/libunwind/doc/unw_destroy_addr_space.man b/src/pal/src/libunwind/doc/unw_destroy_addr_space.man deleted file mode 100644 index 90c9777ef..000000000 --- a/src/pal/src/libunwind/doc/unw_destroy_addr_space.man +++ /dev/null @@ -1,57 +0,0 @@ -'\" t -.\" Manual page created with latex2man on Thu Aug 16 09:44:45 MDT 2007 -.\" NOTE: This file is generated, DO NOT EDIT. -.de Vb -.ft CW -.nf -.. -.de Ve -.ft R - -.fi -.. -.TH "UNW\\_DESTROY\\_ADDR\\_SPACE" "3" "16 August 2007" "Programming Library " "Programming Library " -.SH NAME -unw_destroy_addr_space -\-\- destroy unwind address space -.PP -.SH SYNOPSIS - -.PP -#include -.br -.PP -void -unw_destroy_addr_space(unw_addr_space_t -as); -.br -.PP -.SH DESCRIPTION - -.PP -The unw_destroy_addr_space() -routine destroys the -address space specified by argument as -and thereby releases -all associated resources (such as memory). -.PP -Applications must not destroy the local address space -unw_local_addr_space\&. -Attempting to do so results in -undefined behavior (e.g., the application may crash). -.PP -.SH SEE ALSO - -.PP -libunwind(3), -unw_create_addr_space(3) -.PP -.SH AUTHOR - -.PP -David Mosberger\-Tang -.br -Email: \fBdmosberger@gmail.com\fP -.br -WWW: \fBhttp://www.nongnu.org/libunwind/\fP\&. -.\" NOTE: This file is generated, DO NOT EDIT. diff --git a/src/pal/src/libunwind/doc/unw_destroy_addr_space.tex b/src/pal/src/libunwind/doc/unw_destroy_addr_space.tex deleted file mode 100644 index a66b10b4b..000000000 --- a/src/pal/src/libunwind/doc/unw_destroy_addr_space.tex +++ /dev/null @@ -1,40 +0,0 @@ -\documentclass{article} -\usepackage[fancyhdr,pdf]{latex2man} - -\input{common.tex} - -\begin{document} - -\begin{Name}{3}{unw\_destroy\_addr\_space}{David Mosberger-Tang}{Programming Library}{unw\_destroy\_addr\_space}unw\_destroy\_addr\_space -- destroy unwind address space -\end{Name} - -\section{Synopsis} - -\File{\#include $<$libunwind.h$>$}\\ - -\Type{void} \Func{unw\_destroy\_addr\_space}(\Type{unw\_addr\_space\_t} \Var{as});\\ - -\section{Description} - -The \Func{unw\_destroy\_addr\_space}() routine destroys the -address space specified by argument \Var{as} and thereby releases -all associated resources (such as memory). - -Applications must not destroy the local address space -\Var{unw\_local\_addr\_space}. Attempting to do so results in -undefined behavior (e.g., the application may crash). - -\section{See Also} - -\SeeAlso{libunwind(3)}, -\SeeAlso{unw\_create\_addr\_space(3)} - -\section{Author} - -\noindent -David Mosberger-Tang\\ -Email: \Email{dmosberger@gmail.com}\\ -WWW: \URL{http://www.nongnu.org/libunwind/}. -\LatexManEnd - -\end{document} diff --git a/src/pal/src/libunwind/doc/unw_flush_cache.man b/src/pal/src/libunwind/doc/unw_flush_cache.man deleted file mode 100644 index 627449eff..000000000 --- a/src/pal/src/libunwind/doc/unw_flush_cache.man +++ /dev/null @@ -1,93 +0,0 @@ -'\" t -.\" Manual page created with latex2man on Fri Dec 2 16:09:33 PST 2016 -.\" NOTE: This file is generated, DO NOT EDIT. -.de Vb -.ft CW -.nf -.. -.de Ve -.ft R - -.fi -.. -.TH "UNW\\_FLUSH\\_CACHE" "3" "02 December 2016" "Programming Library " "Programming Library " -.SH NAME -unw_flush_cache -\-\- flush cached info -.PP -.SH SYNOPSIS - -.PP -#include -.br -.PP -void -unw_flush_cache(unw_addr_space_t -as, -unw_word_t -lo, -unw_word_t -hi); -.br -.PP -.SH DESCRIPTION - -.PP -The unw_flush_cache() -routine flushes all cached info as it -relates to address\-range lo -to hi -(non\-inclusive) in the -target address\-space as\&. -In addition, all info cached for -address\-space as -that is not tied to a particular code\-range is -also flushed. For example, the address of the dynamic registration -list is not tied to a code\-range and its cached value (if any) is -flushed by a call to this routine. The address range specified by -lo -and hi -should be understood as a hint: -unw_flush_cache() -may flush more information than requested, -but \fInever\fP -less. In other words, unw_flush_cache() -may -overflush, but not underflush. -.PP -As a special case, if arguments lo -and hi -are both 0, all -information cached on behalf of address space as -is flushed. -.PP -.SH RETURN VALUE - -.PP -The unw_flush_cache() -routine cannot fail and does not -return a value. -.PP -.SH THREAD AND SIGNAL SAFETY - -.PP -The unw_flush_cache() -routine is thread\-safe as well as safe to -use from a signal handler. -.PP -.SH SEE ALSO - -.PP -libunwind(3), -unw_set_caching_policy(3) -unw_set_cache_size(3) -.PP -.SH AUTHOR - -.PP -David Mosberger\-Tang -.br -Email: \fBdmosberger@gmail.com\fP -.br -WWW: \fBhttp://www.nongnu.org/libunwind/\fP\&. -.\" NOTE: This file is generated, DO NOT EDIT. diff --git a/src/pal/src/libunwind/doc/unw_flush_cache.tex b/src/pal/src/libunwind/doc/unw_flush_cache.tex deleted file mode 100644 index 32319db5d..000000000 --- a/src/pal/src/libunwind/doc/unw_flush_cache.tex +++ /dev/null @@ -1,58 +0,0 @@ -\documentclass{article} -\usepackage[fancyhdr,pdf]{latex2man} - -\input{common.tex} - -\begin{document} - -\begin{Name}{3}{unw\_flush\_cache}{David Mosberger-Tang}{Programming Library}{unw\_flush\_cache}unw\_flush\_cache -- flush cached info -\end{Name} - -\section{Synopsis} - -\File{\#include $<$libunwind.h$>$}\\ - -\Type{void} \Func{unw\_flush\_cache}(\Type{unw\_addr\_space\_t} \Var{as}, \Type{unw\_word\_t} \Var{lo}, \Type{unw\_word\_t} \Var{hi});\\ - -\section{Description} - -The \Func{unw\_flush\_cache}() routine flushes all cached info as it -relates to address-range \Var{lo} to \Var{hi} (non-inclusive) in the -target address-space \Var{as}. In addition, all info cached for -address-space \Var{as} that is not tied to a particular code-range is -also flushed. For example, the address of the dynamic registration -list is not tied to a code-range and its cached value (if any) is -flushed by a call to this routine. The address range specified by -\Var{lo} and \Var{hi} should be understood as a hint: -\Func{unw\_flush\_cache}() may flush more information than requested, -but \emph{never} less. In other words, \Func{unw\_flush\_cache}() may -overflush, but not underflush. - -As a special case, if arguments \Var{lo} and \Var{hi} are both 0, all -information cached on behalf of address space \Var{as} is flushed. - -\section{Return Value} - -The \Func{unw\_flush\_cache}() routine cannot fail and does not -return a value. - -\section{Thread and Signal Safety} - -The \Func{unw\_flush\_cache}() routine is thread-safe as well as safe to -use from a signal handler. - -\section{See Also} - -\SeeAlso{libunwind(3)}, -\SeeAlso{unw\_set\_caching\_policy(3)} -\SeeAlso{unw\_set\_cache\_size(3)} - -\section{Author} - -\noindent -David Mosberger-Tang\\ -Email: \Email{dmosberger@gmail.com}\\ -WWW: \URL{http://www.nongnu.org/libunwind/}. -\LatexManEnd - -\end{document} diff --git a/src/pal/src/libunwind/doc/unw_get_accessors.man b/src/pal/src/libunwind/doc/unw_get_accessors.man deleted file mode 100644 index 83fe4fcea..000000000 --- a/src/pal/src/libunwind/doc/unw_get_accessors.man +++ /dev/null @@ -1,79 +0,0 @@ -'\" t -.\" Manual page created with latex2man on Thu Aug 16 09:44:44 MDT 2007 -.\" NOTE: This file is generated, DO NOT EDIT. -.de Vb -.ft CW -.nf -.. -.de Ve -.ft R - -.fi -.. -.TH "UNW\\_GET\\_ACCESSORS" "3" "16 August 2007" "Programming Library " "Programming Library " -.SH NAME -unw_get_accessors -\-\- get pointer to accessor call\-backs -.PP -.SH SYNOPSIS - -.PP -#include -.br -.PP -unw_accessors_t *unw_get_accessors(unw_addr_space_t as); -.br -.PP -.SH DESCRIPTION - -.PP -The unw_get_accessors() -routine returns a pointer to a -unw_accessors_t -structure, which contains the call\-back -routines that were specified when address space as -was created -(see unw_create_addr_space(3)). -The returned pointer is -guaranteed to remain valid until address space as -is destroyed -by a call to unw_destroy_addr_space(3). -.PP -Note that unw_get_accessors() -can be used to retrieve the -call\-back routines for the local address space -unw_local_addr_space\&. -.PP -.SH RETURN VALUE - -.PP -The unw_get_accessors() -routine cannot fail and always -returns a valid (non\-NULL) -pointer to an -unw_accessors_t -structure. -.PP -.SH THREAD AND SIGNAL SAFETY - -.PP -The unw_get_accessors() -routine is thread\-safe as well as -safe to use from a signal handler. -.PP -.SH SEE ALSO - -.PP -libunwind(3), -unw_create_addr_space(3), -unw_destroy_addr_space(3) -.PP -.SH AUTHOR - -.PP -David Mosberger\-Tang -.br -Email: \fBdmosberger@gmail.com\fP -.br -WWW: \fBhttp://www.nongnu.org/libunwind/\fP\&. -.\" NOTE: This file is generated, DO NOT EDIT. diff --git a/src/pal/src/libunwind/doc/unw_get_accessors.tex b/src/pal/src/libunwind/doc/unw_get_accessors.tex deleted file mode 100644 index bf344a32d..000000000 --- a/src/pal/src/libunwind/doc/unw_get_accessors.tex +++ /dev/null @@ -1,55 +0,0 @@ -\documentclass{article} -\usepackage[fancyhdr,pdf]{latex2man} - -\input{common.tex} - -\begin{document} - -\begin{Name}{3}{unw\_get\_accessors}{David Mosberger-Tang}{Programming Library}{unw\_get\_accessors}unw\_get\_accessors -- get pointer to accessor call-backs -\end{Name} - -\section{Synopsis} - -\File{\#include $<$libunwind.h$>$}\\ - -\Type{unw\_accessors\_t~*}\Func{unw\_get\_accessors}(\Type{unw\_addr\_space\_t~}\Var{as});\\ - -\section{Description} - -The \Func{unw\_get\_accessors}() routine returns a pointer to a -\Type{unw\_accessors\_t} structure, which contains the call-back -routines that were specified when address space \Var{as} was created -(see \Func{unw\_create\_addr\_space}(3)). The returned pointer is -guaranteed to remain valid until address space \Var{as} is destroyed -by a call to \Func{unw\_destroy\_addr\_space}(3). - -Note that \Func{unw\_get\_accessors}() can be used to retrieve the -call-back routines for the local address space -\Var{unw\_local\_addr\_space}. - -\section{Return Value} - -The \Func{unw\_get\_accessors}() routine cannot fail and always -returns a valid (non-\Const{NULL}) pointer to an -\Type{unw\_accessors\_t} structure. - -\section{Thread and Signal Safety} - -The \Func{unw\_get\_accessors}() routine is thread-safe as well as -safe to use from a signal handler. - -\section{See Also} - -\SeeAlso{libunwind(3)}, -\SeeAlso{unw\_create\_addr\_space(3)}, -\SeeAlso{unw\_destroy\_addr\_space(3)} - -\section{Author} - -\noindent -David Mosberger-Tang\\ -Email: \Email{dmosberger@gmail.com}\\ -WWW: \URL{http://www.nongnu.org/libunwind/}. -\LatexManEnd - -\end{document} diff --git a/src/pal/src/libunwind/doc/unw_get_fpreg.man b/src/pal/src/libunwind/doc/unw_get_fpreg.man deleted file mode 100644 index 5e54ca13d..000000000 --- a/src/pal/src/libunwind/doc/unw_get_fpreg.man +++ /dev/null @@ -1,111 +0,0 @@ -'\" t -.\" Manual page created with latex2man on Thu Aug 16 09:44:45 MDT 2007 -.\" NOTE: This file is generated, DO NOT EDIT. -.de Vb -.ft CW -.nf -.. -.de Ve -.ft R - -.fi -.. -.TH "UNW\\_GET\\_FPREG" "3" "16 August 2007" "Programming Library " "Programming Library " -.SH NAME -unw_get_fpreg -\-\- get contents of floating\-point register -.PP -.SH SYNOPSIS - -.PP -#include -.br -.PP -int -unw_get_fpreg(unw_cursor_t *cp, -unw_regnum_t -reg, -unw_fpreg_t *valp); -.br -.PP -.SH DESCRIPTION - -.PP -The unw_get_fpreg() -routine reads the value of floating\-point -register reg -in the stack frame identified by cursor cp -and stores the value in the variable pointed to by valp\&. -.PP -The register numbering is target\-dependent and described in separate -manual pages (e.g., libunwind\-ia64(3) for the IA\-64 target). -Furthermore, the exact set of accessible registers may depend on the -type of frame that cp -is referring to. For ordinary stack -frames, it is normally possible to access only the preserved -(``callee\-saved\&'') registers and frame\-related registers (such as the -stack\-pointer). However, for signal frames (see -unw_is_signal_frame(3)), -it is usually possible to access -all registers. -.PP -Note that unw_get_fpreg() -can only read the contents of -floating\-point registers. See unw_get_fpreg(3) -for a way to -read registers which fit in a single word. -.PP -.SH RETURN VALUE - -.PP -On successful completion, unw_get_fpreg() -returns 0. -Otherwise the negative value of one of the error\-codes below is -returned. -.PP -.SH THREAD AND SIGNAL SAFETY - -.PP -unw_get_fpreg() -is thread\-safe as well as safe to use -from a signal handler. -.PP -.SH ERRORS - -.PP -.TP -UNW_EUNSPEC - An unspecified error occurred. -.TP -UNW_EBADREG - An attempt was made to read a register -that is either invalid or not accessible in the current frame. -.PP -In addition, unw_get_fpreg() -may return any error returned by -the access_mem(), -access_reg(), -and -access_fpreg() -call\-backs (see -unw_create_addr_space(3)). -.PP -.SH SEE ALSO - -.PP -libunwind(3), -libunwind\-ia64(3), -unw_get_reg(3), -unw_is_fpreg(3), -unw_is_signal_frame(3), -unw_set_fpreg(3) -.PP -.SH AUTHOR - -.PP -David Mosberger\-Tang -.br -Email: \fBdmosberger@gmail.com\fP -.br -WWW: \fBhttp://www.nongnu.org/libunwind/\fP\&. -.\" NOTE: This file is generated, DO NOT EDIT. diff --git a/src/pal/src/libunwind/doc/unw_get_fpreg.tex b/src/pal/src/libunwind/doc/unw_get_fpreg.tex deleted file mode 100644 index dd679adc0..000000000 --- a/src/pal/src/libunwind/doc/unw_get_fpreg.tex +++ /dev/null @@ -1,77 +0,0 @@ -\documentclass{article} -\usepackage[fancyhdr,pdf]{latex2man} - -\input{common.tex} - -\begin{document} - -\begin{Name}{3}{unw\_get\_fpreg}{David Mosberger-Tang}{Programming Library}{unw\_get\_fpreg}unw\_get\_fpreg -- get contents of floating-point register -\end{Name} - -\section{Synopsis} - -\File{\#include $<$libunwind.h$>$}\\ - -\Type{int} \Func{unw\_get\_fpreg}(\Type{unw\_cursor\_t~*}\Var{cp}, \Type{unw\_regnum\_t} \Var{reg}, \Type{unw\_fpreg\_t~*}\Var{valp});\\ - -\section{Description} - -The \Func{unw\_get\_fpreg}() routine reads the value of floating-point -register \Var{reg} in the stack frame identified by cursor \Var{cp} -and stores the value in the variable pointed to by \Var{valp}. - -The register numbering is target-dependent and described in separate -manual pages (e.g., libunwind-ia64(3) for the IA-64 target). -Furthermore, the exact set of accessible registers may depend on the -type of frame that \Var{cp} is referring to. For ordinary stack -frames, it is normally possible to access only the preserved -(``callee-saved'') registers and frame-related registers (such as the -stack-pointer). However, for signal frames (see -\Func{unw\_is\_signal\_frame}(3)), it is usually possible to access -all registers. - -Note that \Func{unw\_get\_fpreg}() can only read the contents of -floating-point registers. See \Func{unw\_get\_fpreg}(3) for a way to -read registers which fit in a single word. - -\section{Return Value} - -On successful completion, \Func{unw\_get\_fpreg}() returns 0. -Otherwise the negative value of one of the error-codes below is -returned. - -\section{Thread and Signal Safety} - -\Func{unw\_get\_fpreg}() is thread-safe as well as safe to use -from a signal handler. - -\section{Errors} - -\begin{Description} -\item[\Const{UNW\_EUNSPEC}] An unspecified error occurred. -\item[\Const{UNW\_EBADREG}] An attempt was made to read a register - that is either invalid or not accessible in the current frame. -\end{Description} -In addition, \Func{unw\_get\_fpreg}() may return any error returned by -the \Func{access\_mem}(), \Func{access\_reg}(), and -\Func{access\_fpreg}() call-backs (see -\Func{unw\_create\_addr\_space}(3)). - -\section{See Also} - -\SeeAlso{libunwind(3)}, -\SeeAlso{libunwind-ia64(3)}, -\SeeAlso{unw\_get\_reg(3)}, -\SeeAlso{unw\_is\_fpreg(3)}, -\SeeAlso{unw\_is\_signal\_frame(3)}, -\SeeAlso{unw\_set\_fpreg(3)} - -\section{Author} - -\noindent -David Mosberger-Tang\\ -Email: \Email{dmosberger@gmail.com}\\ -WWW: \URL{http://www.nongnu.org/libunwind/}. -\LatexManEnd - -\end{document} diff --git a/src/pal/src/libunwind/doc/unw_get_proc_info.man b/src/pal/src/libunwind/doc/unw_get_proc_info.man deleted file mode 100644 index 09eadee27..000000000 --- a/src/pal/src/libunwind/doc/unw_get_proc_info.man +++ /dev/null @@ -1,203 +0,0 @@ -'\" t -.\" Manual page created with latex2man on Thu Aug 16 09:44:44 MDT 2007 -.\" NOTE: This file is generated, DO NOT EDIT. -.de Vb -.ft CW -.nf -.. -.de Ve -.ft R - -.fi -.. -.TH "UNW\\_GET\\_PROC\\_INFO" "3" "16 August 2007" "Programming Library " "Programming Library " -.SH NAME -unw_get_proc_info -\-\- get info on current procedure -.PP -.SH SYNOPSIS - -.PP -#include -.br -.PP -int -unw_get_proc_info(unw_cursor_t *cp, -unw_proc_info_t *pip); -.br -.PP -.SH DESCRIPTION - -.PP -The unw_get_proc_info() -routine returns auxiliary -information about the procedure that created the stack frame -identified by argument cp\&. -The pip -argument is a pointer -to a structure of type unw_proc_info_t -which is used to -return the information. The unw_proc_info_t -has the -following members: -.TP -unw_word_t start_ip - The address of the first -instruction of the procedure. If this address cannot be determined -(e.g., due to lack of unwind information), the start_ip -member is cleared to 0. -.br -.TP -unw_word_t end_ip - The address of the first -instruction \fIbeyond\fP -the end of the procedure. If this address -cannot be determined (e.g., due to lack of unwind information), -the end_ip -member is cleared to 0. -.br -.TP -unw_word_t lsda - The address of the -language\-specific data\-area (LSDA). This area normally contains -language\-specific information needed during exception handling. If -the procedure has no such area, this member is cleared to 0. -.br -.TP -unw_word_t handler - The address of the exception -handler routine. This is sometimes called the \fIpersonality\fP -routine. If the procedure does not define -a personality routine, the handler -member is cleared to 0. -.br -.TP -unw_word_t gp - The global\-pointer of the -procedure. On platforms that do not use a global pointer, this -member may contain an undefined value. On all other platforms, it -must be set either to the correct global\-pointer value of the -procedure or to 0 if the proper global\-pointer cannot be -obtained for some reason. -.br -.TP -unw_word_t flags - A set of flags. There are -currently no target\-independent flags. For the IA\-64 target, the -flag UNW_PI_FLAG_IA64_RBS_SWITCH -is set if the -procedure may switch the register\-backing store. -.br -.TP -int format - The format of the unwind\-info for this -procedure. If the unwind\-info consists of dynamic procedure info, -format -is equal to UNW_INFO_FORMAT_DYNAMIC\&. -If the -unwind\-info consists of a (target\-specific) unwind table, it is -equal to to UNW_INFO_FORMAT_TABLE\&. -All other values are -reserved for future use by libunwind\&. -This member exists -for use by the find_proc_info() -call\-back (see -unw_create_addr_space(3)). -The -unw_get_proc_info() -routine -may return an undefined value in this member. -.br -.TP -int unwind_info_size - The size of the unwind\-info -in bytes. This member exists for use by the -find_proc_info() -call\-back (see -unw_create_addr_space(3)). -The -unw_get_proc_info() -routine -may return an undefined value in this member. -.br -.TP -void *unwind_info - The pointer to the unwind\-info. -If no unwind info is available, this member must be set to -NULL\&. -This member exists for use by the -find_proc_info() -call\-back (see -unw_create_addr_space(3)). -The -unw_get_proc_info() -routine -may return an undefined value in this member. -.br -.PP -Note that for the purposes of libunwind, -the code of a -procedure is assumed to occupy a single, contiguous range of -addresses. For this reason, it is alwas possible to describe the -extent of a procedure with the start_ip -and end_ip -members. If a single function/routine is split into multiple, -discontiguous pieces, libunwind -will treat each piece as a -separate procedure. -.PP -.SH RETURN VALUE - -.PP -On successful completion, unw_get_proc_info() -returns 0. -Otherwise the negative value of one of the error\-codes below is -returned. -.PP -.SH THREAD AND SIGNAL SAFETY - -.PP -unw_get_proc_info() -is thread\-safe. If cursor cp -is -in the local address\-space, this routine is also safe to use from a -signal handler. -.PP -.SH ERRORS - -.PP -.TP -UNW_EUNSPEC - An unspecified error occurred. -.TP -UNW_ENOINFO - Libunwind -was unable to locate -unwind\-info for the procedure. -.TP -UNW_EBADVERSION - The unwind\-info for the procedure has -version or format that is not understood by libunwind\&. -.PP -In addition, unw_get_proc_info() -may return any error -returned by the access_mem() -call\-back (see -unw_create_addr_space(3)). -.PP -.SH SEE ALSO - -.PP -libunwind(3), -unw_create_addr_space(3), -unw_get_proc_name(3) -.PP -.SH AUTHOR - -.PP -David Mosberger\-Tang -.br -Email: \fBdmosberger@gmail.com\fP -.br -WWW: \fBhttp://www.nongnu.org/libunwind/\fP\&. -.\" NOTE: This file is generated, DO NOT EDIT. diff --git a/src/pal/src/libunwind/doc/unw_get_proc_info.tex b/src/pal/src/libunwind/doc/unw_get_proc_info.tex deleted file mode 100644 index 72621f1a6..000000000 --- a/src/pal/src/libunwind/doc/unw_get_proc_info.tex +++ /dev/null @@ -1,123 +0,0 @@ -\documentclass{article} -\usepackage[fancyhdr,pdf]{latex2man} - -\input{common.tex} - -\begin{document} - -\begin{Name}{3}{unw\_get\_proc\_info}{David Mosberger-Tang}{Programming Library}{unw\_get\_proc\_info}unw\_get\_proc\_info -- get info on current procedure -\end{Name} - -\section{Synopsis} - -\File{\#include $<$libunwind.h$>$}\\ - -\Type{int} \Func{unw\_get\_proc\_info}(\Type{unw\_cursor\_t~*}\Var{cp}, \Type{unw\_proc\_info\_t~*}\Var{pip});\\ - -\section{Description} - -The \Func{unw\_get\_proc\_info}() routine returns auxiliary -information about the procedure that created the stack frame -identified by argument \Var{cp}. The \Var{pip} argument is a pointer -to a structure of type \Type{unw\_proc\_info\_t} which is used to -return the information. The \Type{unw\_proc\_info\_t} has the -following members: -\begin{description} -\item[\Type{unw\_word\_t} \Var{start\_ip}] The address of the first - instruction of the procedure. If this address cannot be determined - (e.g., due to lack of unwind information), the \Var{start\_ip} - member is cleared to 0. \\ -\item[\Type{unw\_word\_t} \Var{end\_ip}] The address of the first - instruction \emph{beyond} the end of the procedure. If this address - cannot be determined (e.g., due to lack of unwind information), - the \Var{end\_ip} member is cleared to 0. \\ -\item[\Type{unw\_word\_t} \Var{lsda}] The address of the - language-specific data-area (LSDA). This area normally contains - language-specific information needed during exception handling. If - the procedure has no such area, this member is cleared to 0. \\ -\item[\Type{unw\_word\_t} \Var{handler}] The address of the exception - handler routine. This is sometimes called the \emph{personality} - routine. If the procedure does not define - a personality routine, the \Var{handler} member is cleared to 0. \\ -\item[\Type{unw\_word\_t} \Var{gp}] The global-pointer of the - procedure. On platforms that do not use a global pointer, this - member may contain an undefined value. On all other platforms, it - must be set either to the correct global-pointer value of the - procedure or to 0 if the proper global-pointer cannot be - obtained for some reason. \\ -\item[\Type{unw\_word\_t} \Var{flags}] A set of flags. There are - currently no target-independent flags. For the IA-64 target, the - flag \Const{UNW\_PI\_FLAG\_IA64\_RBS\_SWITCH} is set if the - procedure may switch the register-backing store.\\ -\item[\Type{int} \Var{format}] The format of the unwind-info for this - procedure. If the unwind-info consists of dynamic procedure info, - \Var{format} is equal to \Const{UNW\_INFO\_FORMAT\_DYNAMIC}. If the - unwind-info consists of a (target-specific) unwind table, it is - equal to to \Const{UNW\_INFO\_FORMAT\_TABLE}. All other values are - reserved for future use by \Prog{libunwind}. This member exists - for use by the \Func{find\_proc\_info}() call-back (see - \Func{unw\_create\_addr\_space}(3)). The - \Func{unw\_get\_proc\_info}() routine - may return an undefined value in this member. \\ -\item[\Type{int} \Var{unwind\_info\_size}] The size of the unwind-info - in bytes. This member exists for use by the - \Func{find\_proc\_info}() call-back (see - \Func{unw\_create\_addr\_space}(3)). The - \Func{unw\_get\_proc\_info}() routine - may return an undefined value in this member.\\ -\item[\Type{void~*}\Var{unwind\_info}] The pointer to the unwind-info. - If no unwind info is available, this member must be set to - \Const{NULL}. This member exists for use by the - \Func{find\_proc\_info}() call-back (see - \Func{unw\_create\_addr\_space}(3)). The - \Func{unw\_get\_proc\_info}() routine - may return an undefined value in this member.\\ -\end{description} -Note that for the purposes of \Prog{libunwind}, the code of a -procedure is assumed to occupy a single, contiguous range of -addresses. For this reason, it is alwas possible to describe the -extent of a procedure with the \Var{start\_ip} and \Var{end\_ip} -members. If a single function/routine is split into multiple, -discontiguous pieces, \Prog{libunwind} will treat each piece as a -separate procedure. - -\section{Return Value} - -On successful completion, \Func{unw\_get\_proc\_info}() returns 0. -Otherwise the negative value of one of the error-codes below is -returned. - -\section{Thread and Signal Safety} - -\Func{unw\_get\_proc\_info}() is thread-safe. If cursor \Var{cp} is -in the local address-space, this routine is also safe to use from a -signal handler. - -\section{Errors} - -\begin{Description} -\item[\Const{UNW\_EUNSPEC}] An unspecified error occurred. -\item[\Const{UNW\_ENOINFO}] \Prog{Libunwind} was unable to locate - unwind-info for the procedure. -\item[\Const{UNW\_EBADVERSION}] The unwind-info for the procedure has - version or format that is not understood by \Prog{libunwind}. -\end{Description} -In addition, \Func{unw\_get\_proc\_info}() may return any error -returned by the \Func{access\_mem}() call-back (see -\Func{unw\_create\_addr\_space}(3)). - -\section{See Also} - -\SeeAlso{libunwind(3)}, -\SeeAlso{unw\_create\_addr\_space(3)}, -\SeeAlso{unw\_get\_proc\_name(3)} - -\section{Author} - -\noindent -David Mosberger-Tang\\ -Email: \Email{dmosberger@gmail.com}\\ -WWW: \URL{http://www.nongnu.org/libunwind/}. -\LatexManEnd - -\end{document} diff --git a/src/pal/src/libunwind/doc/unw_get_proc_info_by_ip.man b/src/pal/src/libunwind/doc/unw_get_proc_info_by_ip.man deleted file mode 100644 index a347a1d00..000000000 --- a/src/pal/src/libunwind/doc/unw_get_proc_info_by_ip.man +++ /dev/null @@ -1,134 +0,0 @@ -'\" t -.\" Manual page created with latex2man on Thu Aug 16 09:44:45 MDT 2007 -.\" NOTE: This file is generated, DO NOT EDIT. -.de Vb -.ft CW -.nf -.. -.de Ve -.ft R - -.fi -.. -.TH "UNW\\_GET\\_PROC\\_INFO\\_BY\\_IP" "3" "16 August 2007" "Programming Library " "Programming Library " -.SH NAME -unw_get_proc_info_by_ip -\-\- get procedure info by IP -.PP -.SH SYNOPSIS - -.PP -#include -.br -.PP -int -unw_get_proc_info_by_ip(unw_addr_space_t as, -unw_word_t ip, -unw_proc_info_t *pip, -void *arg); -.br -.PP -.SH DESCRIPTION - -.PP -The unw_get_proc_info_by_ip() -routine returns the same -kind of auxiliary information about a procedure as -unw_get_proc_info(), -except that the info is looked up by -instruction\-pointer (IP) instead of a cursor. This is more flexible -because it is possible to look up the info for an arbitrary procedure, -even if it is not part of the current call\-chain. However, since it -is more flexible, it also tends to run slower (and often much slower) -than unw_get_proc_info(). -.PP -The routine expects the followins arguments: as -is the -address\-space in which the instruction\-pointer should be looked up. -For a look\-up in the local address\-space, -unw_local_addr_space -can be passed for this argument. -Argument ip -is the instruction\-pointer for which the procedure -info should be looked up and pip -is a pointer to a structure of -type unw_proc_info_t -which is used to return the info. -Lastly, arg -is the address\-space argument that should be used -when accessing the address\-space. It has the same purpose as the -argument of the same name for unw_init_remote(). -When -accessing the local address\-space (first argument is -unw_local_addr_space), -NULL -must be passed for this -argument. -.PP -Note that for the purposes of libunwind, -the code of a -procedure is assumed to occupy a single, contiguous range of -addresses. For this reason, it is alwas possible to describe the -extent of a procedure with the start_ip -and end_ip -members. If a single function/routine is split into multiple, -discontiguous pieces, libunwind -will treat each piece as a -separate procedure. -.PP -.SH RETURN VALUE - -.PP -On successful completion, unw_get_proc_info_by_ip() -returns 0. Otherwise the negative value of one of the error\-codes -below is returned. -.PP -.SH THREAD AND SIGNAL SAFETY - -.PP -unw_get_proc_info() -is thread\-safe. If the local -address\-space is passed in argument as, -this routine is also -safe to use from a signal handler. -.PP -.SH ERRORS - -.PP -.TP -UNW_EUNSPEC - An unspecified error occurred. -.TP -UNW_ENOINFO - Libunwind -was unable to locate -unwind\-info for the procedure. -.TP -UNW_EBADVERSION - The unwind\-info for the procedure has -version or format that is not understood by libunwind\&. -.PP -In addition, unw_get_proc_info() -may return any error -returned by the access_mem() -call\-back (see -unw_create_addr_space(3)). -.PP -.SH SEE ALSO - -.PP -libunwind(3), -unw_create_addr_space(3), -unw_get_proc_name(3), -unw_get_proc_info(3), -unw_init_remote(3) -.PP -.SH AUTHOR - -.PP -David Mosberger\-Tang -.br -Email: \fBdmosberger@gmail.com\fP -.br -WWW: \fBhttp://www.nongnu.org/libunwind/\fP\&. -.\" NOTE: This file is generated, DO NOT EDIT. diff --git a/src/pal/src/libunwind/doc/unw_get_proc_info_by_ip.tex b/src/pal/src/libunwind/doc/unw_get_proc_info_by_ip.tex deleted file mode 100644 index 5e1d5d247..000000000 --- a/src/pal/src/libunwind/doc/unw_get_proc_info_by_ip.tex +++ /dev/null @@ -1,91 +0,0 @@ -\documentclass{article} -\usepackage[fancyhdr,pdf]{latex2man} - -\input{common.tex} - -\begin{document} - -\begin{Name}{3}{unw\_get\_proc\_info\_by\_ip}{David Mosberger-Tang}{Programming Library}{unw\_get\_proc\_info\_by\_ip}unw\_get\_proc\_info\_by\_ip -- get procedure info by IP -\end{Name} - -\section{Synopsis} - -\File{\#include $<$libunwind.h$>$}\\ - -\Type{int} \Func{unw\_get\_proc\_info\_by\_ip}(\Type{unw\_addr\_space\_t~}\Var{as}, \Type{unw\_word\_t~}\Var{ip}, \Type{unw\_proc\_info\_t~*}\Var{pip}, \Type{void~*}\Var{arg});\\ - -\section{Description} - -The \Func{unw\_get\_proc\_info\_by\_ip}() routine returns the same -kind of auxiliary information about a procedure as -\Func{unw\_get\_proc\_info}(), except that the info is looked up by -instruction-pointer (IP) instead of a cursor. This is more flexible -because it is possible to look up the info for an arbitrary procedure, -even if it is not part of the current call-chain. However, since it -is more flexible, it also tends to run slower (and often much slower) -than \Func{unw\_get\_proc\_info}(). - -The routine expects the followins arguments: \Var{as} is the -address-space in which the instruction-pointer should be looked up. -For a look-up in the local address-space, -\Var{unw\_local\_addr\_space} can be passed for this argument. -Argument \Var{ip} is the instruction-pointer for which the procedure -info should be looked up and \Var{pip} is a pointer to a structure of -type \Type{unw\_proc\_info\_t} which is used to return the info. -Lastly, \Var{arg} is the address-space argument that should be used -when accessing the address-space. It has the same purpose as the -argument of the same name for \Func{unw\_init\_remote}(). When -accessing the local address-space (first argument is -\Var{unw\_local\_addr\_space}), \Const{NULL} must be passed for this -argument. - -Note that for the purposes of \Prog{libunwind}, the code of a -procedure is assumed to occupy a single, contiguous range of -addresses. For this reason, it is alwas possible to describe the -extent of a procedure with the \Var{start\_ip} and \Var{end\_ip} -members. If a single function/routine is split into multiple, -discontiguous pieces, \Prog{libunwind} will treat each piece as a -separate procedure. - -\section{Return Value} - -On successful completion, \Func{unw\_get\_proc\_info\_by\_ip}() -returns 0. Otherwise the negative value of one of the error-codes -below is returned. - -\section{Thread and Signal Safety} - -\Func{unw\_get\_proc\_info}() is thread-safe. If the local -address-space is passed in argument \Var{as}, this routine is also -safe to use from a signal handler. - -\section{Errors} - -\begin{Description} -\item[\Const{UNW\_EUNSPEC}] An unspecified error occurred. -\item[\Const{UNW\_ENOINFO}] \Prog{Libunwind} was unable to locate - unwind-info for the procedure. -\item[\Const{UNW\_EBADVERSION}] The unwind-info for the procedure has - version or format that is not understood by \Prog{libunwind}. -\end{Description} -In addition, \Func{unw\_get\_proc\_info}() may return any error -returned by the \Func{access\_mem}() call-back (see -\Func{unw\_create\_addr\_space}(3)). - -\section{See Also} - -\SeeAlso{libunwind(3)}, -\SeeAlso{unw\_create\_addr\_space(3)}, -\SeeAlso{unw\_get\_proc\_name(3)}, -\SeeAlso{unw\_get\_proc\_info(3)}, -\SeeAlso{unw\_init\_remote(3)} - -\section{Author} - -\noindent -David Mosberger-Tang\\ -Email: \Email{dmosberger@gmail.com}\\ -WWW: \URL{http://www.nongnu.org/libunwind/}. -\LatexManEnd - -\end{document} diff --git a/src/pal/src/libunwind/doc/unw_get_proc_name.man b/src/pal/src/libunwind/doc/unw_get_proc_name.man deleted file mode 100644 index 8b2bd06ea..000000000 --- a/src/pal/src/libunwind/doc/unw_get_proc_name.man +++ /dev/null @@ -1,123 +0,0 @@ -'\" t -.\" Manual page created with latex2man on Thu Aug 16 09:44:45 MDT 2007 -.\" NOTE: This file is generated, DO NOT EDIT. -.de Vb -.ft CW -.nf -.. -.de Ve -.ft R - -.fi -.. -.TH "UNW\\_GET\\_PROC\\_NAME" "3" "16 August 2007" "Programming Library " "Programming Library " -.SH NAME -unw_get_proc_name -\-\- get name of current procedure -.PP -.SH SYNOPSIS - -.PP -#include -.br -.PP -int -unw_get_proc_name(unw_cursor_t *cp, -char *bufp, -size_t -len, -unw_word_t *offp); -.br -.PP -.SH DESCRIPTION - -.PP -The unw_get_proc_name() -routine returns the name of the -procedure that created the stack frame identified by argument -cp\&. -The bufp -argument is a pointer to a character buffer -that is at least len -bytes long. This buffer is used to return -the name of the procedure. The offp -argument is a pointer to a -word that is used to return the byte\-offset of the instruction\-pointer -saved in the stack frame identified by cp, -relative to the start -of the procedure. For example, if procedure foo() -starts at -address 0x40003000, then invoking unw_get_proc_name() -on a -stack frame with an instruction\-pointer value of 0x40003080 would -return a value of 0x80 in the word pointed to by offp -(assuming -the procedure is at least 0x80 bytes long). -.PP -Note that on some platforms there is no reliable way to distinguish -between procedure names and ordinary labels. Furthermore, if symbol -information has been stripped from a program, procedure names may be -completely unavailable or may be limited to those exported via a -dynamic symbol table. In such cases, unw_get_proc_name() -may return the name of a label or a preceeding (nearby) procedure. -However, the offset returned through offp -is always relative to -the returned name, which ensures that the value (address) of the -returned name plus the returned offset will always be equal to the -instruction\-pointer of the stack frame identified by cp\&. -.PP -.SH RETURN VALUE - -.PP -On successful completion, unw_get_proc_name() -returns 0. -Otherwise the negative value of one of the error\-codes below is -returned. -.PP -.SH THREAD AND SIGNAL SAFETY - -.PP -unw_get_proc_name() -is thread\-safe. If cursor cp -is -in the local address\-space, this routine is also safe to use from a -signal handler. -.PP -.SH ERRORS - -.PP -.TP -UNW_EUNSPEC - An unspecified error occurred. -.TP -UNW_ENOINFO - Libunwind -was unable to determine -the name of the procedure. -.TP -UNW_ENOMEM - The procedure name is too long to fit -in the buffer provided. A truncated version of the name has been -returned. -.PP -In addition, unw_get_proc_name() -may return any error -returned by the access_mem() -call\-back (see -unw_create_addr_space(3)). -.PP -.SH SEE ALSO - -.PP -libunwind(3), -unw_get_proc_info(3) -.PP -.SH AUTHOR - -.PP -David Mosberger\-Tang -.br -Email: \fBdmosberger@gmail.com\fP -.br -WWW: \fBhttp://www.nongnu.org/libunwind/\fP\&. -.\" NOTE: This file is generated, DO NOT EDIT. diff --git a/src/pal/src/libunwind/doc/unw_get_proc_name.tex b/src/pal/src/libunwind/doc/unw_get_proc_name.tex deleted file mode 100644 index c41399088..000000000 --- a/src/pal/src/libunwind/doc/unw_get_proc_name.tex +++ /dev/null @@ -1,82 +0,0 @@ -\documentclass{article} -\usepackage[fancyhdr,pdf]{latex2man} - -\input{common.tex} - -\begin{document} - -\begin{Name}{3}{unw\_get\_proc\_name}{David Mosberger-Tang}{Programming Library}{unw\_get\_proc\_name}unw\_get\_proc\_name -- get name of current procedure -\end{Name} - -\section{Synopsis} - -\File{\#include $<$libunwind.h$>$}\\ - -\Type{int} \Func{unw\_get\_proc\_name}(\Type{unw\_cursor\_t~*}\Var{cp}, \Type{char~*}\Var{bufp}, \Type{size\_t} \Var{len}, \Type{unw\_word\_t~*}\Var{offp});\\ - -\section{Description} - -The \Func{unw\_get\_proc\_name}() routine returns the name of the -procedure that created the stack frame identified by argument -\Var{cp}. The \Var{bufp} argument is a pointer to a character buffer -that is at least \Var{len} bytes long. This buffer is used to return -the name of the procedure. The \Var{offp} argument is a pointer to a -word that is used to return the byte-offset of the instruction-pointer -saved in the stack frame identified by \Var{cp}, relative to the start -of the procedure. For example, if procedure \Func{foo}() starts at -address 0x40003000, then invoking \Func{unw\_get\_proc\_name}() on a -stack frame with an instruction-pointer value of 0x40003080 would -return a value of 0x80 in the word pointed to by \Var{offp} (assuming -the procedure is at least 0x80 bytes long). - -Note that on some platforms there is no reliable way to distinguish -between procedure names and ordinary labels. Furthermore, if symbol -information has been stripped from a program, procedure names may be -completely unavailable or may be limited to those exported via a -dynamic symbol table. In such cases, \Func{unw\_get\_proc\_name}() -may return the name of a label or a preceeding (nearby) procedure. -However, the offset returned through \Var{offp} is always relative to -the returned name, which ensures that the value (address) of the -returned name plus the returned offset will always be equal to the -instruction-pointer of the stack frame identified by \Var{cp}. - -\section{Return Value} - -On successful completion, \Func{unw\_get\_proc\_name}() returns 0. -Otherwise the negative value of one of the error-codes below is -returned. - -\section{Thread and Signal Safety} - -\Func{unw\_get\_proc\_name}() is thread-safe. If cursor \Var{cp} is -in the local address-space, this routine is also safe to use from a -signal handler. - -\section{Errors} - -\begin{Description} -\item[\Const{UNW\_EUNSPEC}] An unspecified error occurred. -\item[\Const{UNW\_ENOINFO}] \Prog{Libunwind} was unable to determine - the name of the procedure. -\item[\Const{UNW\_ENOMEM}] The procedure name is too long to fit - in the buffer provided. A truncated version of the name has been - returned. -\end{Description} -In addition, \Func{unw\_get\_proc\_name}() may return any error -returned by the \Func{access\_mem}() call-back (see -\Func{unw\_create\_addr\_space}(3)). - -\section{See Also} - -\SeeAlso{libunwind(3)}, -\SeeAlso{unw\_get\_proc\_info(3)} - -\section{Author} - -\noindent -David Mosberger-Tang\\ -Email: \Email{dmosberger@gmail.com}\\ -WWW: \URL{http://www.nongnu.org/libunwind/}. -\LatexManEnd - -\end{document} diff --git a/src/pal/src/libunwind/doc/unw_get_reg.man b/src/pal/src/libunwind/doc/unw_get_reg.man deleted file mode 100644 index 83e8bb43b..000000000 --- a/src/pal/src/libunwind/doc/unw_get_reg.man +++ /dev/null @@ -1,112 +0,0 @@ -'\" t -.\" Manual page created with latex2man on Thu Aug 16 09:44:45 MDT 2007 -.\" NOTE: This file is generated, DO NOT EDIT. -.de Vb -.ft CW -.nf -.. -.de Ve -.ft R - -.fi -.. -.TH "UNW\\_GET\\_REG" "3" "16 August 2007" "Programming Library " "Programming Library " -.SH NAME -unw_get_reg -\-\- get register contents -.PP -.SH SYNOPSIS - -.PP -#include -.br -.PP -int -unw_get_reg(unw_cursor_t *cp, -unw_regnum_t -reg, -unw_word_t *valp); -.br -.PP -.SH DESCRIPTION - -.PP -The unw_get_reg() -routine reads the value of register -reg -in the stack frame identified by cursor cp -and stores -the value in the word pointed to by valp\&. -.PP -The register numbering is target\-dependent and described in separate -manual pages (e.g., libunwind\-ia64(3) for the IA\-64 target). -Furthermore, the exact set of accessible registers may depend on the -type of frame that cp -is referring to. For ordinary stack -frames, it is normally possible to access only the preserved -(``callee\-saved\&'') registers and frame\-related registers (such as the -stack\-pointer). However, for signal frames (see -unw_is_signal_frame(3)), -it is usually possible to access -all registers. -.PP -Note that unw_get_reg() -can only read the contents of -registers whose values fit in a single word. See -unw_get_fpreg(3) -for a way to read registers which do not fit -this constraint. -.PP -.SH RETURN VALUE - -.PP -On successful completion, unw_get_reg() -returns 0. -Otherwise the negative value of one of the error\-codes below is -returned. -.PP -.SH THREAD AND SIGNAL SAFETY - -.PP -unw_get_reg() -is thread\-safe as well as safe to use -from a signal handler. -.PP -.SH ERRORS - -.PP -.TP -UNW_EUNSPEC - An unspecified error occurred. -.TP -UNW_EBADREG - An attempt was made to read a register -that is either invalid or not accessible in the current frame. -.PP -In addition, unw_get_reg() -may return any error returned by -the access_mem(), -access_reg(), -and -access_fpreg() -call\-backs (see -unw_create_addr_space(3)). -.PP -.SH SEE ALSO - -.PP -libunwind(3), -libunwind\-ia64(3), -unw_get_fpreg(3), -unw_is_signal_frame(3), -unw_set_reg(3) -.PP -.SH AUTHOR - -.PP -David Mosberger\-Tang -.br -Email: \fBdmosberger@gmail.com\fP -.br -WWW: \fBhttp://www.nongnu.org/libunwind/\fP\&. -.\" NOTE: This file is generated, DO NOT EDIT. diff --git a/src/pal/src/libunwind/doc/unw_get_reg.tex b/src/pal/src/libunwind/doc/unw_get_reg.tex deleted file mode 100644 index b66e8c0db..000000000 --- a/src/pal/src/libunwind/doc/unw_get_reg.tex +++ /dev/null @@ -1,77 +0,0 @@ -\documentclass{article} -\usepackage[fancyhdr,pdf]{latex2man} - -\input{common.tex} - -\begin{document} - -\begin{Name}{3}{unw\_get\_reg}{David Mosberger-Tang}{Programming Library}{unw\_get\_reg}unw\_get\_reg -- get register contents -\end{Name} - -\section{Synopsis} - -\File{\#include $<$libunwind.h$>$}\\ - -\Type{int} \Func{unw\_get\_reg}(\Type{unw\_cursor\_t~*}\Var{cp}, \Type{unw\_regnum\_t} \Var{reg}, \Type{unw\_word\_t~*}\Var{valp});\\ - -\section{Description} - -The \Func{unw\_get\_reg}() routine reads the value of register -\Var{reg} in the stack frame identified by cursor \Var{cp} and stores -the value in the word pointed to by \Var{valp}. - -The register numbering is target-dependent and described in separate -manual pages (e.g., libunwind-ia64(3) for the IA-64 target). -Furthermore, the exact set of accessible registers may depend on the -type of frame that \Var{cp} is referring to. For ordinary stack -frames, it is normally possible to access only the preserved -(``callee-saved'') registers and frame-related registers (such as the -stack-pointer). However, for signal frames (see -\Func{unw\_is\_signal\_frame}(3)), it is usually possible to access -all registers. - -Note that \Func{unw\_get\_reg}() can only read the contents of -registers whose values fit in a single word. See -\Func{unw\_get\_fpreg}(3) for a way to read registers which do not fit -this constraint. - -\section{Return Value} - -On successful completion, \Func{unw\_get\_reg}() returns 0. -Otherwise the negative value of one of the error-codes below is -returned. - -\section{Thread and Signal Safety} - -\Func{unw\_get\_reg}() is thread-safe as well as safe to use -from a signal handler. - -\section{Errors} - -\begin{Description} -\item[\Const{UNW\_EUNSPEC}] An unspecified error occurred. -\item[\Const{UNW\_EBADREG}] An attempt was made to read a register - that is either invalid or not accessible in the current frame. -\end{Description} -In addition, \Func{unw\_get\_reg}() may return any error returned by -the \Func{access\_mem}(), \Func{access\_reg}(), and -\Func{access\_fpreg}() call-backs (see -\Func{unw\_create\_addr\_space}(3)). - -\section{See Also} - -\SeeAlso{libunwind(3)}, -\SeeAlso{libunwind-ia64(3)}, -\SeeAlso{unw\_get\_fpreg(3)}, -\SeeAlso{unw\_is\_signal\_frame(3)}, -\SeeAlso{unw\_set\_reg(3)} - -\section{Author} - -\noindent -David Mosberger-Tang\\ -Email: \Email{dmosberger@gmail.com}\\ -WWW: \URL{http://www.nongnu.org/libunwind/}. -\LatexManEnd - -\end{document} diff --git a/src/pal/src/libunwind/doc/unw_getcontext.man b/src/pal/src/libunwind/doc/unw_getcontext.man deleted file mode 100644 index 13725df95..000000000 --- a/src/pal/src/libunwind/doc/unw_getcontext.man +++ /dev/null @@ -1,93 +0,0 @@ -'\" t -.\" Manual page created with latex2man on Thu Aug 16 09:44:45 MDT 2007 -.\" NOTE: This file is generated, DO NOT EDIT. -.de Vb -.ft CW -.nf -.. -.de Ve -.ft R - -.fi -.. -.TH "UNW\\_GETCONTEXT" "3" "16 August 2007" "Programming Library " "Programming Library " -.SH NAME -unw_getcontext -\-\- get initial machine\-state -.PP -.SH SYNOPSIS - -.PP -#include -.br -.PP -int -unw_getcontext(unw_context_t *ucp); -.br -.PP -.SH DESCRIPTION - -.PP -The unw_getcontext() -routine initializes the context structure -pointed to by ucp -with the machine\-state of the call\-site. The -exact set of registers stored by unw_getcontext() -is -platform\-specific, but, in general, at least all preserved -(``callee\-saved\&'') and all frame\-related registers, such as the -stack\-pointer, will be stored. -.PP -This routine is normally implemented as a macro and applications -should not attempt to take its address. -.PP -.SH PLATFORM\-SPECIFIC NOTES - -.PP -On IA\-64, unw_context_t -has a layout that is compatible with -that of ucontext_t -and such structures can be initialized with -getcontext() -instead of unw_getcontext(). -However, the -reverse is \fInot\fP -true and it is \fInot\fP -safe to use structures -initialized by unw_getcontext() -in places where a structure -initialized by getcontext() -is expected. The reason for this -asymmetry is that unw_getcontext() -is optimized for maximum -performance and does not, for example, save the signal mask. -.PP -.SH RETURN VALUE - -.PP -On successful completion, unw_getcontext() -returns 0. -Otherwise, a value of \-1 is returned. -.PP -.SH THREAD AND SIGNAL SAFETY - -.PP -unw_getcontext() -is thread\-safe as well as safe to use -from a signal handler. -.PP -.SH SEE ALSO - -.PP -libunwind(3), -unw_init_local(3) -.PP -.SH AUTHOR - -.PP -David Mosberger\-Tang -.br -Email: \fBdmosberger@gmail.com\fP -.br -WWW: \fBhttp://www.nongnu.org/libunwind/\fP\&. -.\" NOTE: This file is generated, DO NOT EDIT. diff --git a/src/pal/src/libunwind/doc/unw_getcontext.tex b/src/pal/src/libunwind/doc/unw_getcontext.tex deleted file mode 100644 index fa3eb814b..000000000 --- a/src/pal/src/libunwind/doc/unw_getcontext.tex +++ /dev/null @@ -1,63 +0,0 @@ -\documentclass{article} -\usepackage[fancyhdr,pdf]{latex2man} - -\input{common.tex} - -\begin{document} - -\begin{Name}{3}{unw\_getcontext}{David Mosberger-Tang}{Programming Library}{unw\_getcontext}unw\_getcontext -- get initial machine-state -\end{Name} - -\section{Synopsis} - -\File{\#include $<$libunwind.h$>$}\\ - -\Type{int} \Func{unw\_getcontext}(\Type{unw\_context\_t~*}\Var{ucp});\\ - -\section{Description} - -The \Func{unw\_getcontext}() routine initializes the context structure -pointed to by \Var{ucp} with the machine-state of the call-site. The -exact set of registers stored by \Func{unw\_getcontext}() is -platform-specific, but, in general, at least all preserved -(``callee-saved'') and all frame-related registers, such as the -stack-pointer, will be stored. - -This routine is normally implemented as a macro and applications -should not attempt to take its address. - -\section{Platform-specific Notes} - -On IA-64, \Type{unw\_context\_t} has a layout that is compatible with -that of \Type{ucontext\_t} and such structures can be initialized with -\Func{getcontext}() instead of \Func{unw\_getcontext}(). However, the -reverse is \emph{not} true and it is \emph{not} safe to use structures -initialized by \Func{unw\_getcontext()} in places where a structure -initialized by \Func{getcontext()} is expected. The reason for this -asymmetry is that \Func{unw\_getcontext()} is optimized for maximum -performance and does not, for example, save the signal mask. - -\section{Return Value} - -On successful completion, \Func{unw\_getcontext}() returns 0. -Otherwise, a value of -1 is returned. - -\section{Thread and Signal Safety} - -\Func{unw\_getcontext}() is thread-safe as well as safe to use -from a signal handler. - -\section{See Also} - -\SeeAlso{libunwind(3)}, -\SeeAlso{unw\_init\_local(3)} - -\section{Author} - -\noindent -David Mosberger-Tang\\ -Email: \Email{dmosberger@gmail.com}\\ -WWW: \URL{http://www.nongnu.org/libunwind/}. -\LatexManEnd - -\end{document} diff --git a/src/pal/src/libunwind/doc/unw_init_local.man b/src/pal/src/libunwind/doc/unw_init_local.man deleted file mode 100644 index 301dd6f93..000000000 --- a/src/pal/src/libunwind/doc/unw_init_local.man +++ /dev/null @@ -1,124 +0,0 @@ -'\" t -.\" Manual page created with latex2man on Wed Aug 16 12:11:05 PDT 2017 -.\" NOTE: This file is generated, DO NOT EDIT. -.de Vb -.ft CW -.nf -.. -.de Ve -.ft R - -.fi -.. -.TH "UNW\\_INIT\\_LOCAL" "3" "16 August 2017" "Programming Library " "Programming Library " -.SH NAME -unw_init_local -\-\- initialize cursor for local unwinding -.PP -.SH SYNOPSIS - -.PP -#include -.br -.PP -int -unw_init_local(unw_cursor_t *c, -unw_context_t *ctxt); -.br -int -unw_init_local2(unw_cursor_t *c, -unw_context_t *ctxt, -int -flag); -.br -.PP -.SH DESCRIPTION - -.PP -The unw_init_local() -routine initializes the unwind cursor -pointed to by c -with the machine\-state in the context structure -pointed to by ctxt\&. -As such, the machine\-state pointed to by -ctxt -identifies the initial stack frame at which unwinding -starts. The machine\-state is expected to be one provided by a call to -unw_getcontext; as such, the instruction pointer may point to the -instruction after the last instruction of a function, and libunwind -will back\-up the instruction pointer before beginning a walk up the -call stack. The machine\-state must remain valid for the duration for -which the cursor c -is in use. -.PP -The unw_init_local() -routine can be used only for unwinding in -the address space of the current process (i.e., for local unwinding). -For all other cases, unw_init_remote() -must be used instead. -However, unwind performance may be better when using -unw_init_local(). -Also, unw_init_local() -is -available even when UNW_LOCAL_ONLY -has been defined before -including , -whereas unw_init_remote() -is not. -.PP -If the unw_context_t is known to be a signal frame (i.e., from the -third argument in a sigaction handler on linux), -unw_init_local2() -should be used for correct initialization -on some platforms, passing the UNW_INIT_SIGNAL_FRAME flag. -.PP -.SH RETURN VALUE - -.PP -On successful completion, unw_init_local() -returns 0. -Otherwise the negative value of one of the error\-codes below is -returned. -.PP -.SH THREAD AND SIGNAL SAFETY - -.PP -unw_init_local() -is thread\-safe as well as safe to use from a -signal handler. -.PP -.SH ERRORS - -.PP -.TP -UNW_EINVAL - unw_init_local() -was called in a -version of libunwind -which supports remote unwinding only -(this normally happens when calling unw_init_local() -for a -cross\-platform version of libunwind). -.TP -UNW_EUNSPEC - An unspecified error occurred. -.TP -UNW_EBADREG - A register needed by unw_init_local() -wasn\&'t accessible. -.PP -.SH SEE ALSO - -.PP -libunwind(3), -unw_init_remote(3) -.PP -.SH AUTHOR - -.PP -David Mosberger\-Tang -.br -Email: \fBdmosberger@gmail.com\fP -.br -WWW: \fBhttp://www.nongnu.org/libunwind/\fP\&. -.\" NOTE: This file is generated, DO NOT EDIT. diff --git a/src/pal/src/libunwind/doc/unw_init_local.tex b/src/pal/src/libunwind/doc/unw_init_local.tex deleted file mode 100644 index ff0d03bc7..000000000 --- a/src/pal/src/libunwind/doc/unw_init_local.tex +++ /dev/null @@ -1,80 +0,0 @@ -\documentclass{article} -\usepackage[fancyhdr,pdf]{latex2man} - -\input{common.tex} - -\begin{document} - -\begin{Name}{3}{unw\_init\_local}{David Mosberger-Tang}{Programming Library}{unw\_init\_local}unw\_init\_local -- initialize cursor for local unwinding -\end{Name} - -\section{Synopsis} - -\File{\#include $<$libunwind.h$>$}\\ - -\Type{int} \Func{unw\_init\_local}(\Type{unw\_cursor\_t~*}\Var{c}, \Type{unw\_context\_t~*}\Var{ctxt});\\ -\Type{int} \Func{unw\_init\_local2}(\Type{unw\_cursor\_t~*}\Var{c}, \Type{unw\_context\_t~*}\Var{ctxt}, \Type{int} \Var{flag});\\ - -\section{Description} - -The \Func{unw\_init\_local}() routine initializes the unwind cursor -pointed to by \Var{c} with the machine-state in the context structure -pointed to by \Var{ctxt}. As such, the machine-state pointed to by -\Var{ctxt} identifies the initial stack frame at which unwinding -starts. The machine-state is expected to be one provided by a call to -unw_getcontext; as such, the instruction pointer may point to the -instruction after the last instruction of a function, and libunwind -will back-up the instruction pointer before beginning a walk up the -call stack. The machine-state must remain valid for the duration for -which the cursor \Var{c} is in use. - -The \Func{unw\_init\_local}() routine can be used only for unwinding in -the address space of the current process (i.e., for local unwinding). -For all other cases, \Func{unw\_init\_remote}() must be used instead. -However, unwind performance may be better when using -\Func{unw\_init\_local}(). Also, \Func{unw\_init\_local}() is -available even when \Const{UNW\_LOCAL\_ONLY} has been defined before -including \File{$<$libunwind.h$>$}, whereas \Func{unw\_init\_remote}() -is not. - -If the unw_context_t is known to be a signal frame (i.e., from the -third argument in a sigaction handler on linux), -\Func{unw\_init\_local2}() should be used for correct initialization -on some platforms, passing the UNW_INIT_SIGNAL_FRAME flag. - -\section{Return Value} - -On successful completion, \Func{unw\_init\_local}() returns 0. -Otherwise the negative value of one of the error-codes below is -returned. - -\section{Thread and Signal Safety} - -\Func{unw\_init\_local}() is thread-safe as well as safe to use from a -signal handler. - -\section{Errors} - -\begin{Description} -\item[\Const{UNW\_EINVAL}] \Func{unw\_init\_local}() was called in a - version of \Prog{libunwind} which supports remote unwinding only - (this normally happens when calling \Func{unw\_init\_local}() for a - cross-platform version of \Prog{libunwind}). -\item[\Const{UNW\_EUNSPEC}] An unspecified error occurred. -\item[\Const{UNW\_EBADREG}] A register needed by \Func{unw\_init\_local}() - wasn't accessible. -\end{Description} - -\section{See Also} - -\SeeAlso{libunwind(3)}, \SeeAlso{unw\_init\_remote(3)} - -\section{Author} - -\noindent -David Mosberger-Tang\\ -Email: \Email{dmosberger@gmail.com}\\ -WWW: \URL{http://www.nongnu.org/libunwind/}. -\LatexManEnd - -\end{document} diff --git a/src/pal/src/libunwind/doc/unw_init_local2.man b/src/pal/src/libunwind/doc/unw_init_local2.man deleted file mode 100644 index 6cbbf008a..000000000 --- a/src/pal/src/libunwind/doc/unw_init_local2.man +++ /dev/null @@ -1 +0,0 @@ -.so man3/unw_init_local.3 diff --git a/src/pal/src/libunwind/doc/unw_init_remote.man b/src/pal/src/libunwind/doc/unw_init_remote.man deleted file mode 100644 index 0acdac961..000000000 --- a/src/pal/src/libunwind/doc/unw_init_remote.man +++ /dev/null @@ -1,123 +0,0 @@ -'\" t -.\" Manual page created with latex2man on Thu Aug 16 09:44:45 MDT 2007 -.\" NOTE: This file is generated, DO NOT EDIT. -.de Vb -.ft CW -.nf -.. -.de Ve -.ft R - -.fi -.. -.TH "UNW\\_INIT\\_REMOTE" "3" "16 August 2007" "Programming Library " "Programming Library " -.SH NAME -unw_init_remote -\-\- initialize cursor for remote unwinding -.PP -.SH SYNOPSIS - -.PP -#include -.br -.PP -int -unw_init_remote(unw_cursor_t *c, -unw_addr_space_t as, -void *arg); -.br -.PP -.SH DESCRIPTION - -.PP -The unw_init_remote() -routine initializes the unwind cursor -pointed to by c -for unwinding in the address space identified by -as\&. -The as -argument can either be set to -unw_local_addr_space -(local address space) or to an arbitrary -address space created with unw_create_addr_space(). -.PP -The arg -void\-pointer tells the address space exactly what entity -should be unwound. For example, if unw_local_addr_space -is -passed in as, -then arg -needs to be a pointer to a context -structure containing the machine\-state of the initial stack frame. -However, other address\-spaces may instead expect a process\-id, a -thread\-id, or a pointer to an arbitrary structure which identifies the -stack\-frame chain to be unwound. In other words, the interpretation -of arg -is entirely dependent on the address\-space in use; -libunwind -never interprets the argument in any way on its own. -.PP -Note that unw_init_remote() -can be used to initiate unwinding -in \fIany\fP -process, including the local process in which the -unwinder itself is running. However, for local unwinding, it is -generally preferable to use unw_init_local() -instead, because -it is easier to use and because it may perform better. -.PP -.SH RETURN VALUE - -.PP -On successful completion, unw_init_remote() -returns 0. -Otherwise the negative value of one of the error\-codes below is -returned. -.PP -.SH THREAD AND SIGNAL SAFETY - -.PP -unw_init_remote() -is thread\-safe. If the local address\-space -is passed in argument as, -this routine is also safe to use from -a signal handler. -.PP -.SH ERRORS - -.PP -.TP -UNW_EINVAL - unw_init_remote() -was called in a -version of libunwind -which supports local unwinding only -(this normally happens when defining UNW_LOCAL_ONLY -before -including -and then calling -unw_init_remote()). -.TP -UNW_EUNSPEC - An unspecified error occurred. -.TP -UNW_EBADREG - A register needed by unw_init_remote() -wasn\&'t accessible. -.PP -.SH SEE ALSO - -.PP -libunwind(3), -unw_create_addr_space(3), -unw_init_local(3) -.PP -.SH AUTHOR - -.PP -David Mosberger\-Tang -.br -Email: \fBdmosberger@gmail.com\fP -.br -WWW: \fBhttp://www.nongnu.org/libunwind/\fP\&. -.\" NOTE: This file is generated, DO NOT EDIT. diff --git a/src/pal/src/libunwind/doc/unw_init_remote.tex b/src/pal/src/libunwind/doc/unw_init_remote.tex deleted file mode 100644 index 9b4dc7997..000000000 --- a/src/pal/src/libunwind/doc/unw_init_remote.tex +++ /dev/null @@ -1,79 +0,0 @@ -\documentclass{article} -\usepackage[fancyhdr,pdf]{latex2man} - -\input{common.tex} - -\begin{document} - -\begin{Name}{3}{unw\_init\_remote}{David Mosberger-Tang}{Programming Library}{unw\_init\_remote}unw\_init\_remote -- initialize cursor for remote unwinding -\end{Name} - -\section{Synopsis} - -\File{\#include $<$libunwind.h$>$}\\ - -\Type{int} \Func{unw\_init\_remote}(\Type{unw\_cursor\_t~*}\Var{c}, \Type{unw\_addr\_space\_t~}\Var{as}, \Type{void~*}\Var{arg});\\ - -\section{Description} - -The \Func{unw\_init\_remote}() routine initializes the unwind cursor -pointed to by \Var{c} for unwinding in the address space identified by -\Var{as}. The \Var{as} argument can either be set to -\Var{unw\_local\_addr\_space} (local address space) or to an arbitrary -address space created with \Func{unw\_create\_addr\_space}(). - -The \Var{arg} void-pointer tells the address space exactly what entity -should be unwound. For example, if \Var{unw\_local\_addr\_space} is -passed in \Var{as}, then \Var{arg} needs to be a pointer to a context -structure containing the machine-state of the initial stack frame. -However, other address-spaces may instead expect a process-id, a -thread-id, or a pointer to an arbitrary structure which identifies the -stack-frame chain to be unwound. In other words, the interpretation -of \Var{arg} is entirely dependent on the address-space in use; -\Prog{libunwind} never interprets the argument in any way on its own. - -Note that \Func{unw\_init\_remote}() can be used to initiate unwinding -in \emph{any} process, including the local process in which the -unwinder itself is running. However, for local unwinding, it is -generally preferable to use \Func{unw\_init\_local}() instead, because -it is easier to use and because it may perform better. - -\section{Return Value} - -On successful completion, \Func{unw\_init\_remote}() returns 0. -Otherwise the negative value of one of the error-codes below is -returned. - -\section{Thread and Signal Safety} - -\Func{unw\_init\_remote}() is thread-safe. If the local address-space -is passed in argument \Var{as}, this routine is also safe to use from -a signal handler. - -\section{Errors} - -\begin{Description} -\item[\Const{UNW\_EINVAL}] \Func{unw\_init\_remote}() was called in a - version of \Prog{libunwind} which supports local unwinding only - (this normally happens when defining \Const{UNW\_LOCAL\_ONLY} before - including \File{$<$libunwind.h$>$} and then calling - \Func{unw\_init\_remote}()). -\item[\Const{UNW\_EUNSPEC}] An unspecified error occurred. -\item[\Const{UNW\_EBADREG}] A register needed by \Func{unw\_init\_remote}() - wasn't accessible. -\end{Description} - -\section{See Also} - -\SeeAlso{libunwind(3)}, \SeeAlso{unw\_create\_addr\_space(3)}, -\SeeAlso{unw\_init\_local(3)} - -\section{Author} - -\noindent -David Mosberger-Tang\\ -Email: \Email{dmosberger@gmail.com}\\ -WWW: \URL{http://www.nongnu.org/libunwind/}. -\LatexManEnd - -\end{document} diff --git a/src/pal/src/libunwind/doc/unw_is_fpreg.man b/src/pal/src/libunwind/doc/unw_is_fpreg.man deleted file mode 100644 index 0c26ec1bc..000000000 --- a/src/pal/src/libunwind/doc/unw_is_fpreg.man +++ /dev/null @@ -1,73 +0,0 @@ -'\" t -.\" Manual page created with latex2man on Thu Aug 16 09:44:45 MDT 2007 -.\" NOTE: This file is generated, DO NOT EDIT. -.de Vb -.ft CW -.nf -.. -.de Ve -.ft R - -.fi -.. -.TH "UNW\\_IS\\_FPREG" "3" "16 August 2007" "Programming Library " "Programming Library " -.SH NAME -unw_is_fpreg -\-\- check if a register is a floating\-point register -.PP -.SH SYNOPSIS - -.PP -#include -.br -.PP -int -unw_is_fpreg(unw_regnum_t -reg); -.br -.PP -.SH DESCRIPTION - -.PP -The unw_is_fpreg() -routine checks whether register number -reg -is a floating\-point register. -.PP -This routine is normally implemented as a macro and applications -should not attempt to take its address. -.PP -.SH RETURN VALUE - -.PP -The unw_is_fpreg() -routine returns a non\-zero value if -reg -is a floating\-point register. Otherwise, it returns a value -of 0. -.PP -.SH THREAD AND SIGNAL SAFETY - -.PP -unw_is_fpreg() -is thread\-safe as well as safe to use -from a signal handler. -.PP -.SH SEE ALSO - -.PP -libunwind(3), -unw_get_reg(3), -unw_set_reg(3), -unw_get_fpreg(3), -unw_set_fpreg(3) -.PP -.SH AUTHOR - -.PP -David Mosberger\-Tang -.br -Email: \fBdmosberger@gmail.com\fP -.br -WWW: \fBhttp://www.nongnu.org/libunwind/\fP\&. -.\" NOTE: This file is generated, DO NOT EDIT. diff --git a/src/pal/src/libunwind/doc/unw_is_fpreg.tex b/src/pal/src/libunwind/doc/unw_is_fpreg.tex deleted file mode 100644 index c28cdc9be..000000000 --- a/src/pal/src/libunwind/doc/unw_is_fpreg.tex +++ /dev/null @@ -1,52 +0,0 @@ -\documentclass{article} -\usepackage[fancyhdr,pdf]{latex2man} - -\input{common.tex} - -\begin{document} - -\begin{Name}{3}{unw\_is\_fpreg}{David Mosberger-Tang}{Programming Library}{unw\_is\_fpreg}unw\_is\_fpreg -- check if a register is a floating-point register -\end{Name} - -\section{Synopsis} - -\File{\#include $<$libunwind.h$>$}\\ - -\Type{int} \Func{unw\_is\_fpreg}(\Type{unw\_regnum\_t} \Var{reg});\\ - -\section{Description} - -The \Func{unw\_is\_fpreg}() routine checks whether register number -\Var{reg} is a floating-point register. - -This routine is normally implemented as a macro and applications -should not attempt to take its address. - -\section{Return Value} - -The \Func{unw\_is\_fpreg}() routine returns a non-zero value if -\Var{reg} is a floating-point register. Otherwise, it returns a value -of 0. - -\section{Thread and Signal Safety} - -\Func{unw\_is\_fpreg}() is thread-safe as well as safe to use -from a signal handler. - -\section{See Also} - -\SeeAlso{libunwind(3)}, -\SeeAlso{unw\_get\_reg(3)}, -\SeeAlso{unw\_set\_reg(3)}, -\SeeAlso{unw\_get\_fpreg(3)}, -\SeeAlso{unw\_set\_fpreg(3)} - -\section{Author} - -\noindent -David Mosberger-Tang\\ -Email: \Email{dmosberger@gmail.com}\\ -WWW: \URL{http://www.nongnu.org/libunwind/}. -\LatexManEnd - -\end{document} diff --git a/src/pal/src/libunwind/doc/unw_is_signal_frame.man b/src/pal/src/libunwind/doc/unw_is_signal_frame.man deleted file mode 100644 index d9a7cda7b..000000000 --- a/src/pal/src/libunwind/doc/unw_is_signal_frame.man +++ /dev/null @@ -1,88 +0,0 @@ -'\" t -.\" Manual page created with latex2man on Thu Aug 16 09:44:45 MDT 2007 -.\" NOTE: This file is generated, DO NOT EDIT. -.de Vb -.ft CW -.nf -.. -.de Ve -.ft R - -.fi -.. -.TH "UNW\\_IS\\_SIGNAL\\_FRAME" "3" "16 August 2007" "Programming Library " "Programming Library " -.SH NAME -unw_is_signal_frame -\-\- check if current frame is a signal frame -.PP -.SH SYNOPSIS - -.PP -#include -.br -.PP -int -unw_is_signal_frame(unw_cursor_t *cp); -.br -.PP -.SH DESCRIPTION - -.PP -The unw_is_signal_frame() -routine returns a positive value -if the current frame identified by cp -is a signal frame, and a -value of 0 otherwise. For the purpose of this discussion, a signal -frame is a frame that was created in response to a potentially -asynchronous interruption. For UNIX and UNIX\-like platforms, such -frames are normally created by the kernel when delivering a signal. -In a kernel\-environment, a signal frame might, for example, correspond -to a frame created in response to a device interrupt. -.PP -Signal frames are somewhat unusual because the asynchronous nature of -the events that create them require storing the contents of registers -that are normally treated as scratch (``caller\-saved\&'') registers. -.PP -.SH RETURN VALUE - -.PP -On successful completion, unw_is_signal_frame() -returns a -positive value if the current frame is a signal frame, or 0 if it is -not. Otherwise, a negative value of one of the error\-codes below is -returned. -.PP -.SH THREAD AND SIGNAL SAFETY - -.PP -unw_is_signal_frame() -is thread\-safe as well as safe to use -from a signal handler. -.PP -.SH ERRORS - -.PP -.TP -UNW_ENOINFO - Libunwind -is unable to determine -whether or not the current frame is a signal frame. -.PP -.SH SEE ALSO - -.PP -libunwind(3), -unw_get_reg(3), -unw_set_reg(3), -unw_get_fpreg(3), -unw_set_fpreg(3) -.PP -.SH AUTHOR - -.PP -David Mosberger\-Tang -.br -Email: \fBdmosberger@gmail.com\fP -.br -WWW: \fBhttp://www.nongnu.org/libunwind/\fP\&. -.\" NOTE: This file is generated, DO NOT EDIT. diff --git a/src/pal/src/libunwind/doc/unw_is_signal_frame.tex b/src/pal/src/libunwind/doc/unw_is_signal_frame.tex deleted file mode 100644 index f262e5600..000000000 --- a/src/pal/src/libunwind/doc/unw_is_signal_frame.tex +++ /dev/null @@ -1,67 +0,0 @@ -\documentclass{article} -\usepackage[fancyhdr,pdf]{latex2man} - -\input{common.tex} - -\begin{document} - -\begin{Name}{3}{unw\_is\_signal\_frame}{David Mosberger-Tang}{Programming Library}{unw\_is\_signal\_frame}unw\_is\_signal\_frame -- check if current frame is a signal frame -\end{Name} - -\section{Synopsis} - -\File{\#include $<$libunwind.h$>$}\\ - -\Type{int} \Func{unw\_is\_signal\_frame}(\Type{unw\_cursor\_t~*}\Var{cp});\\ - -\section{Description} - -The \Func{unw\_is\_signal\_frame}() routine returns a positive value -if the current frame identified by \Var{cp} is a signal frame, and a -value of 0 otherwise. For the purpose of this discussion, a signal -frame is a frame that was created in response to a potentially -asynchronous interruption. For UNIX and UNIX-like platforms, such -frames are normally created by the kernel when delivering a signal. -In a kernel-environment, a signal frame might, for example, correspond -to a frame created in response to a device interrupt. - -Signal frames are somewhat unusual because the asynchronous nature of -the events that create them require storing the contents of registers -that are normally treated as scratch (``caller-saved'') registers. - -\section{Return Value} - -On successful completion, \Func{unw\_is\_signal\_frame}() returns a -positive value if the current frame is a signal frame, or 0 if it is -not. Otherwise, a negative value of one of the error-codes below is -returned. - -\section{Thread and Signal Safety} - -\Func{unw\_is\_signal\_frame}() is thread-safe as well as safe to use -from a signal handler. - -\section{Errors} - -\begin{Description} -\item[\Const{UNW\_ENOINFO}] \Prog{Libunwind} is unable to determine - whether or not the current frame is a signal frame. -\end{Description} - -\section{See Also} - -\SeeAlso{libunwind(3)}, -\SeeAlso{unw\_get\_reg(3)}, -\SeeAlso{unw\_set\_reg(3)}, -\SeeAlso{unw\_get\_fpreg(3)}, -\SeeAlso{unw\_set\_fpreg(3)} - -\section{Author} - -\noindent -David Mosberger-Tang\\ -Email: \Email{dmosberger@gmail.com}\\ -WWW: \URL{http://www.nongnu.org/libunwind/}. -\LatexManEnd - -\end{document} diff --git a/src/pal/src/libunwind/doc/unw_reg_states_iterate.man b/src/pal/src/libunwind/doc/unw_reg_states_iterate.man deleted file mode 100644 index e328ad2e3..000000000 --- a/src/pal/src/libunwind/doc/unw_reg_states_iterate.man +++ /dev/null @@ -1,137 +0,0 @@ -'\" t -.\" Manual page created with latex2man on Wed Aug 16 11:09:44 PDT 2017 -.\" NOTE: This file is generated, DO NOT EDIT. -.de Vb -.ft CW -.nf -.. -.de Ve -.ft R - -.fi -.. -.TH "UNW\\_REG\\_STATES\\_ITERATE" "3" "16 August 2017" "Programming Library " "Programming Library " -.SH NAME -unw_reg_states_iterate -\-\- get register state info on current procedure -.PP -.SH SYNOPSIS - -.PP -#include -.br -.PP -int -unw_reg_states_iterate(unw_cursor_t *cp, -unw_reg_states_callbackcb, -void *token); -.br -.PP -.SH DESCRIPTION - -.PP -The unw_reg_states_iterate() -routine provides -information about the procedure that created the stack frame -identified by argument cp\&. -The cb -argument is a pointer -to a function of type unw_reg_states_callback -which is used to -return the information. The function unw_reg_states_callback -has the -following definition: -.PP -int -( *unw_reg_states_callback)(void *token, -void *reg_states_data, -size_t -reg_states_data_size, -unw_word_t -start_ip, -unw_word_t -end_ip); -.PP -The callback function may be invoked several times for each call of unw_reg_states_iterate\&. -Each call is associcated with a instruction address range and a set of instructions on how to update register values when returning from the procedure in that address range. For each invocation, the arguments to the callback function are: -.TP -void * token - The token value passed to unw_reg_states_callback\&. -.br -.TP -void * reg_states_data - A pointer to data about -updating register values. This data, or a copy of it, can be passed -to unw_apply_reg_state\&. -.br -.TP -int reg_states_data_size - The size of the register update data. -.br -.TP -unw_word_t start_ip - The address of the first -instruction of the address range. -.br -.TP -unw_word_t end_ip - The address of the first -instruction \fIbeyond\fP -the end of the address range. -.br -.PP -.SH RETURN VALUE - -.PP -On successful completion, unw_reg_states_iterate() -returns -0. If the callback function returns a nonzero value, that indicates -failure and the function returns immediately. Otherwise the negative -value of one of the error\-codes below is returned. -.PP -.SH THREAD AND SIGNAL SAFETY - -.PP -unw_reg_states_iterate() -is thread\-safe. If cursor cp -is -in the local address\-space, this routine is also safe to use from a -signal handler. -.PP -.SH ERRORS - -.PP -.TP -UNW_EUNSPEC - An unspecified error occurred. -.TP -UNW_ENOINFO - Libunwind -was unable to locate -unwind\-info for the procedure. -.TP -UNW_EBADVERSION - The unwind\-info for the procedure has -version or format that is not understood by libunwind\&. -.PP -In addition, unw_reg_states_iterate() -may return any error -returned by the access_mem() -call\-back (see -unw_create_addr_space(3)). -.PP -.SH SEE ALSO - -.PP -libunwind(3), -unw_apply_reg_state(3) -.PP -.SH AUTHOR - -.PP -David Mosberger\-Tang -.br -Email: \fBdmosberger@gmail.com\fP -.br -WWW: \fBhttp://www.nongnu.org/libunwind/\fP\&. -.\" NOTE: This file is generated, DO NOT EDIT. diff --git a/src/pal/src/libunwind/doc/unw_reg_states_iterate.tex b/src/pal/src/libunwind/doc/unw_reg_states_iterate.tex deleted file mode 100644 index 36c9b548a..000000000 --- a/src/pal/src/libunwind/doc/unw_reg_states_iterate.tex +++ /dev/null @@ -1,83 +0,0 @@ -\documentclass{article} -\usepackage[fancyhdr,pdf]{latex2man} - -\input{common.tex} - -\begin{document} - -\begin{Name}{3}{unw\_reg\_states\_iterate}{David Mosberger-Tang}{Programming Library}{unw\_reg\_states\_iterate}unw\_reg\_states\_iterate -- get register state info on current procedure -\end{Name} - -\section{Synopsis} - -\File{\#include $<$libunwind.h$>$}\\ - -\Type{int} \Func{unw\_reg\_states\_iterate}(\Type{unw\_cursor\_t~*}\Var{cp}, \Type{unw\_reg\_states\_callback}\Var{cb}, \Type{void~*}\Var{token});\\ - -\section{Description} - -The \Func{unw\_reg\_states\_iterate}() routine provides -information about the procedure that created the stack frame -identified by argument \Var{cp}. The \Var{cb} argument is a pointer -to a function of type \Type{unw\_reg\_states\_callback} which is used to -return the information. The function \Type{unw\_reg\_states\_callback} has the -following definition: - -\Type{int} (~*\Var{unw\_reg\_states\_callback})(\Type{void~*}\Var{token}, - \Type{void~*}\Var{reg\_states\_data}, - \Type{size\_t} \Var{reg\_states\_data\_size}, - \Type{unw\_word\_t} \Var{start\_ip}, \Type{unw\_word\_t} \Var{end\_ip}); - -The callback function may be invoked several times for each call of \Func{unw\_reg\_states\_iterate}. Each call is associcated with a instruction address range and a set of instructions on how to update register values when returning from the procedure in that address range. For each invocation, the arguments to the callback function are: -\begin{description} -\item[\Type{void~*} \Var{token}] The token value passed to \Var{unw\_reg\_states\_callback}. \\ -\item[\Type{void~*} \Var{reg\_states\_data}] A pointer to data about - updating register values. This data, or a copy of it, can be passed - to \Var{unw\_apply\_reg\_state}.\\ -\item[\Type{int} \Var{reg\_states\_data\_size}] The size of the register update data. \\ -\item[\Type{unw\_word\_t} \Var{start\_ip}] The address of the first - instruction of the address range. \\ -\item[\Type{unw\_word\_t} \Var{end\_ip}] The address of the first - instruction \emph{beyond} the end of the address range. \\ -\end{description} - -\section{Return Value} - -On successful completion, \Func{unw\_reg\_states\_iterate}() returns -0. If the callback function returns a nonzero value, that indicates -failure and the function returns immediately. Otherwise the negative -value of one of the error-codes below is returned. - -\section{Thread and Signal Safety} - -\Func{unw\_reg\_states\_iterate}() is thread-safe. If cursor \Var{cp} is -in the local address-space, this routine is also safe to use from a -signal handler. - -\section{Errors} - -\begin{Description} -\item[\Const{UNW\_EUNSPEC}] An unspecified error occurred. -\item[\Const{UNW\_ENOINFO}] \Prog{Libunwind} was unable to locate - unwind-info for the procedure. -\item[\Const{UNW\_EBADVERSION}] The unwind-info for the procedure has - version or format that is not understood by \Prog{libunwind}. -\end{Description} -In addition, \Func{unw\_reg\_states\_iterate}() may return any error -returned by the \Func{access\_mem}() call-back (see -\Func{unw\_create\_addr\_space}(3)). - -\section{See Also} - -\SeeAlso{libunwind(3)}, -\SeeAlso{unw\_apply\_reg\_state(3)} - -\section{Author} - -\noindent -David Mosberger-Tang\\ -Email: \Email{dmosberger@gmail.com}\\ -WWW: \URL{http://www.nongnu.org/libunwind/}. -\LatexManEnd - -\end{document} diff --git a/src/pal/src/libunwind/doc/unw_regname.man b/src/pal/src/libunwind/doc/unw_regname.man deleted file mode 100644 index 1e3e2dbc6..000000000 --- a/src/pal/src/libunwind/doc/unw_regname.man +++ /dev/null @@ -1,68 +0,0 @@ -'\" t -.\" Manual page created with latex2man on Thu Aug 16 09:44:45 MDT 2007 -.\" NOTE: This file is generated, DO NOT EDIT. -.de Vb -.ft CW -.nf -.. -.de Ve -.ft R - -.fi -.. -.TH "UNW\\_REGNAME" "3" "16 August 2007" "Programming Library " "Programming Library " -.SH NAME -unw_regname -\-\- get register name -.PP -.SH SYNOPSIS - -.PP -#include -.br -.PP -const char *unw_regname(unw_regnum_t -regnum); -.br -.PP -.SH DESCRIPTION - -.PP -The unw_regname() -routine returns a printable name for -register regnum\&. -If regnum -is an invalid or otherwise -unrecognized register number, a string consisting of three question -marks is returned. The returned string is statically allocated and -therefore guaranteed to remain valid until the application terminates. -.PP -.SH RETURN VALUE - -.PP -The unw_regname() -routine cannot fail and always returns a -valid (non\-NULL) -string. -.PP -.SH THREAD AND SIGNAL SAFETY - -.PP -The unw_regname() -routine is thread\-safe as well as safe to -use from a signal handler. -.PP -.SH SEE ALSO - -.PP -libunwind(3) -.PP -.SH AUTHOR - -.PP -David Mosberger\-Tang -.br -Email: \fBdmosberger@gmail.com\fP -.br -WWW: \fBhttp://www.nongnu.org/libunwind/\fP\&. -.\" NOTE: This file is generated, DO NOT EDIT. diff --git a/src/pal/src/libunwind/doc/unw_regname.tex b/src/pal/src/libunwind/doc/unw_regname.tex deleted file mode 100644 index 94b643419..000000000 --- a/src/pal/src/libunwind/doc/unw_regname.tex +++ /dev/null @@ -1,47 +0,0 @@ -\documentclass{article} -\usepackage[fancyhdr,pdf]{latex2man} - -\input{common.tex} - -\begin{document} - -\begin{Name}{3}{unw\_regname}{David Mosberger-Tang}{Programming Library}{unw\_regname}unw\_regname -- get register name -\end{Name} - -\section{Synopsis} - -\File{\#include $<$libunwind.h$>$}\\ - -\Type{const char~*}\Func{unw\_regname}(\Type{unw\_regnum\_t} \Var{regnum});\\ - -\section{Description} - -The \Func{unw\_regname}() routine returns a printable name for -register \Var{regnum}. If \Var{regnum} is an invalid or otherwise -unrecognized register number, a string consisting of three question -marks is returned. The returned string is statically allocated and -therefore guaranteed to remain valid until the application terminates. - -\section{Return Value} - -The \Func{unw\_regname}() routine cannot fail and always returns a -valid (non-\Const{NULL}) string. - -\section{Thread and Signal Safety} - -The \Func{unw\_regname}() routine is thread-safe as well as safe to -use from a signal handler. - -\section{See Also} - -\SeeAlso{libunwind(3)} - -\section{Author} - -\noindent -David Mosberger-Tang\\ -Email: \Email{dmosberger@gmail.com}\\ -WWW: \URL{http://www.nongnu.org/libunwind/}. -\LatexManEnd - -\end{document} diff --git a/src/pal/src/libunwind/doc/unw_resume.man b/src/pal/src/libunwind/doc/unw_resume.man deleted file mode 100644 index 1bf38327b..000000000 --- a/src/pal/src/libunwind/doc/unw_resume.man +++ /dev/null @@ -1,146 +0,0 @@ -'\" t -.\" Manual page created with latex2man on Thu Aug 16 09:44:45 MDT 2007 -.\" NOTE: This file is generated, DO NOT EDIT. -.de Vb -.ft CW -.nf -.. -.de Ve -.ft R - -.fi -.. -.TH "UNW\\_RESUME" "3" "16 August 2007" "Programming Library " "Programming Library " -.SH NAME -unw_resume -\-\- resume execution in a particular stack frame -.PP -.SH SYNOPSIS - -.PP -#include -.br -.PP -int -unw_resume(unw_cursor_t *cp); -.br -.PP -.SH DESCRIPTION - -.PP -The unw_resume() -routine resumes execution at the stack frame -identified by cp\&. -The behavior of this routine differs -slightly for local and remote unwinding. -.PP -For local unwinding, unw_resume() -restores the machine state -and then directly resumes execution in the target stack frame. Thus -unw_resume() -does not return in this case. Restoring the -machine state normally involves restoring the ``preserved\&'' -(callee\-saved) registers. However, if execution in any of the stack -frames younger (more deeply nested) than the one identified by -cp -was interrupted by a signal, then unw_resume() -will -restore all registers as well as the signal mask. Attempting to call -unw_resume() -on a cursor which identifies the stack frame of -another thread results in undefined behavior (e.g., the program may -crash). -.PP -For remote unwinding, unw_resume() -installs the machine state -identified by the cursor by calling the access_reg -and -access_fpreg -accessor callbacks as needed. Once that is -accomplished, the resume -accessor callback is invoked. The -unw_resume -routine then returns normally (that is, unlikely -for local unwinding, unw_resume -will always return for remote -unwinding). -.PP -Most platforms reserve some registers to pass arguments to exception -handlers (e.g., IA\-64 uses r15\-r18 -for this -purpose). These registers are normally treated like ``scratch\&'' -registers. However, if libunwind -is used to set an exception -argument register to a particular value (e.g., via -unw_set_reg()), -then unw_resume() -will install this -value as the contents of the register. In other words, the exception -handling arguments are installed even in cases where normally only the -``preserved\&'' registers are restored. -.PP -Note that unw_resume() -does \fInot\fP -invoke any unwind -handlers (aka, ``personality routines\&''). If a program needs this, it -will have to do so on its own by obtaining the unw_proc_info_t -of each unwound frame and appropriately processing its unwind handler -and language\-specific data area (lsda). These steps are generally -dependent on the target\-platform and are regulated by the -processor\-specific ABI (application\-binary interface). -.PP -.SH RETURN VALUE - -.PP -For local unwinding, unw_resume() -does not return on success. -For remote unwinding, it returns 0 on success. On failure, the -negative value of one of the errors below is returned. -.PP -.SH THREAD AND SIGNAL SAFETY - -.PP -unw_resume() -is thread\-safe. If cursor cp -is in the -local address\-space, this routine is also safe to use from a signal -handler. -.PP -.SH ERRORS - -.PP -.TP -UNW_EUNSPEC - An unspecified error occurred. -.TP -UNW_EBADREG - A register needed by unw_resume() -wasn\&'t -accessible. -.TP -UNW_EINVALIDIP - The instruction pointer identified by -cp -is not valid. -.TP -UNW_BADFRAME - The stack frame identified by -cp -is not valid. -.PP -.SH SEE ALSO - -.PP -libunwind(3), -unw_set_reg(3), -sigprocmask(2) -.PP -.SH AUTHOR - -.PP -David Mosberger\-Tang -.br -Email: \fBdmosberger@gmail.com\fP -.br -WWW: \fBhttp://www.nongnu.org/libunwind/\fP\&. -.\" NOTE: This file is generated, DO NOT EDIT. diff --git a/src/pal/src/libunwind/doc/unw_resume.tex b/src/pal/src/libunwind/doc/unw_resume.tex deleted file mode 100644 index 38b18248a..000000000 --- a/src/pal/src/libunwind/doc/unw_resume.tex +++ /dev/null @@ -1,99 +0,0 @@ -\documentclass{article} -\usepackage[fancyhdr,pdf]{latex2man} - -\input{common.tex} - -\begin{document} - -\begin{Name}{3}{unw\_resume}{David Mosberger-Tang}{Programming Library}{unw\_resume}unw\_resume -- resume execution in a particular stack frame -\end{Name} - -\section{Synopsis} - -\File{\#include $<$libunwind.h$>$}\\ - -\Type{int} \Func{unw\_resume}(\Type{unw\_cursor\_t~*}\Var{cp});\\ - -\section{Description} - -The \Func{unw\_resume}() routine resumes execution at the stack frame -identified by \Var{cp}. The behavior of this routine differs -slightly for local and remote unwinding. - -For local unwinding, \Func{unw\_resume}() restores the machine state -and then directly resumes execution in the target stack frame. Thus -\Func{unw\_resume}() does not return in this case. Restoring the -machine state normally involves restoring the ``preserved'' -(callee-saved) registers. However, if execution in any of the stack -frames younger (more deeply nested) than the one identified by -\Var{cp} was interrupted by a signal, then \Func{unw\_resume}() will -restore all registers as well as the signal mask. Attempting to call -\Func{unw\_resume}() on a cursor which identifies the stack frame of -another thread results in undefined behavior (e.g., the program may -crash). - -For remote unwinding, \Func{unw\_resume}() installs the machine state -identified by the cursor by calling the \Func{access\_reg} and -\Func{access\_fpreg} accessor callbacks as needed. Once that is -accomplished, the \Func{resume} accessor callback is invoked. The -\Func{unw\_resume} routine then returns normally (that is, unlikely -for local unwinding, \Func{unw\_resume} will always return for remote -unwinding). - -Most platforms reserve some registers to pass arguments to exception -handlers (e.g., IA-64 uses \texttt{r15}-\texttt{r18} for this -purpose). These registers are normally treated like ``scratch'' -registers. However, if \Prog{libunwind} is used to set an exception -argument register to a particular value (e.g., via -\Func{unw\_set\_reg}()), then \Func{unw\_resume}() will install this -value as the contents of the register. In other words, the exception -handling arguments are installed even in cases where normally only the -``preserved'' registers are restored. - -Note that \Func{unw\_resume}() does \emph{not} invoke any unwind -handlers (aka, ``personality routines''). If a program needs this, it -will have to do so on its own by obtaining the \Type{unw\_proc\_info\_t} -of each unwound frame and appropriately processing its unwind handler -and language-specific data area (lsda). These steps are generally -dependent on the target-platform and are regulated by the -processor-specific ABI (application-binary interface). - -\section{Return Value} - -For local unwinding, \Func{unw\_resume}() does not return on success. -For remote unwinding, it returns 0 on success. On failure, the -negative value of one of the errors below is returned. - -\section{Thread and Signal Safety} - -\Func{unw\_resume}() is thread-safe. If cursor \Var{cp} is in the -local address-space, this routine is also safe to use from a signal -handler. - -\section{Errors} - -\begin{Description} -\item[\Const{UNW\_EUNSPEC}] An unspecified error occurred. -\item[\Const{UNW\_EBADREG}] A register needed by \Func{unw\_resume}() wasn't - accessible. -\item[\Const{UNW\_EINVALIDIP}] The instruction pointer identified by - \Var{cp} is not valid. -\item[\Const{UNW\_BADFRAME}] The stack frame identified by - \Var{cp} is not valid. -\end{Description} - -\section{See Also} - -\SeeAlso{libunwind(3)}, -\SeeAlso{unw\_set\_reg(3)}, -sigprocmask(2) - -\section{Author} - -\noindent -David Mosberger-Tang\\ -Email: \Email{dmosberger@gmail.com}\\ -WWW: \URL{http://www.nongnu.org/libunwind/}. -\LatexManEnd - -\end{document} diff --git a/src/pal/src/libunwind/doc/unw_set_cache_size.man b/src/pal/src/libunwind/doc/unw_set_cache_size.man deleted file mode 100644 index 34bbc5396..000000000 --- a/src/pal/src/libunwind/doc/unw_set_cache_size.man +++ /dev/null @@ -1,88 +0,0 @@ -'\" t -.\" Manual page created with latex2man on Fri Jan 13 08:33:21 PST 2017 -.\" NOTE: This file is generated, DO NOT EDIT. -.de Vb -.ft CW -.nf -.. -.de Ve -.ft R - -.fi -.. -.TH "UNW\\_SET\\_CACHE\\_SIZE" "3" "13 January 2017" "Programming Library " "Programming Library " -.SH NAME -unw_set_cache_size -\-\- set unwind cache size -.PP -.SH SYNOPSIS - -.PP -#include -.br -.PP -int -unw_set_cache_size(unw_addr_space_t -as, -size_t -size, -int -flag); -.br -.PP -.SH DESCRIPTION - -.PP -The unw_set_cache_size() -routine sets the cache size of -address space as -to hold at least as many items as given by -argument size\&. -It may hold more items as determined by the -implementation. To disable caching, call -unw_set_caching_policy) -with a policy of -UNW_CACHE_NONE\&. -Flag is currently unused and must be 0. -.PP -.SH RETURN VALUE - -.PP -On successful completion, unw_set_cache_size() -returns 0. -Otherwise the negative value of one of the error\-codes below is -returned. -.PP -.SH THREAD AND SIGNAL SAFETY - -.PP -unw_set_cache_size() -is thread\-safe but \fInot\fP -safe -to use from a signal handler. -.PP -.SH ERRORS - -.PP -.TP -UNW_ENOMEM - The desired cache size could not be -established because the application is out of memory. -.PP -.SH SEE ALSO - -.PP -libunwind(3), -unw_create_addr_space(3), -unw_set_caching_policy(3), -unw_flush_cache(3) -.PP -.SH AUTHOR - -.PP -Dave Watson -.br -Email: \fBdade.watson@gmail.com\fP -.br -WWW: \fBhttp://www.nongnu.org/libunwind/\fP\&. -.\" NOTE: This file is generated, DO NOT EDIT. diff --git a/src/pal/src/libunwind/doc/unw_set_cache_size.tex b/src/pal/src/libunwind/doc/unw_set_cache_size.tex deleted file mode 100644 index 1bd7e00df..000000000 --- a/src/pal/src/libunwind/doc/unw_set_cache_size.tex +++ /dev/null @@ -1,59 +0,0 @@ -\documentclass{article} -\usepackage[fancyhdr,pdf]{latex2man} - -\input{common.tex} - -\begin{document} - -\begin{Name}{3}{unw\_set\_cache\_size}{Dave Watson}{Programming Library}{unw\_set\_cache\_size}unw\_set\_cache\_size -- set unwind cache size -\end{Name} - -\section{Synopsis} - -\File{\#include $<$libunwind.h$>$}\\ - -\Type{int} \Func{unw\_set\_cache\_size}(\Type{unw\_addr\_space\_t} \Var{as}, \Type{size\_t} \Var{size}, \Type{int} \Var{flag});\\ - -\section{Description} - -The \Func{unw\_set\_cache\_size}() routine sets the cache size of -address space \Var{as} to hold at least as many items as given by -argument \Var{size}. It may hold more items as determined by the -implementation. To disable caching, call -\Func{unw\_set\_caching\_policy}) with a policy of -\Const{UNW\_CACHE\_NONE}. Flag is currently unused and must be 0. - -\section{Return Value} - -On successful completion, \Func{unw\_set\_cache\_size}() returns 0. -Otherwise the negative value of one of the error-codes below is -returned. - -\section{Thread and Signal Safety} - -\Func{unw\_set\_cache\_size}() is thread-safe but \emph{not} safe -to use from a signal handler. - -\section{Errors} - -\begin{Description} -\item[\Const{UNW\_ENOMEM}] The desired cache size could not be - established because the application is out of memory. -\end{Description} - -\section{See Also} - -\SeeAlso{libunwind(3)}, -\SeeAlso{unw\_create\_addr\_space(3)}, -\SeeAlso{unw\_set\_caching\_policy(3)}, -\SeeAlso{unw\_flush\_cache(3)} - -\section{Author} - -\noindent -Dave Watson\\ -Email: \Email{dade.watson@gmail.com}\\ -WWW: \URL{http://www.nongnu.org/libunwind/}. -\LatexManEnd - -\end{document} diff --git a/src/pal/src/libunwind/doc/unw_set_caching_policy.man b/src/pal/src/libunwind/doc/unw_set_caching_policy.man deleted file mode 100644 index 4862ea545..000000000 --- a/src/pal/src/libunwind/doc/unw_set_caching_policy.man +++ /dev/null @@ -1,119 +0,0 @@ -'\" t -.\" Manual page created with latex2man on Fri Dec 2 16:09:33 PST 2016 -.\" NOTE: This file is generated, DO NOT EDIT. -.de Vb -.ft CW -.nf -.. -.de Ve -.ft R - -.fi -.. -.TH "UNW\\_SET\\_CACHING\\_POLICY" "3" "02 December 2016" "Programming Library " "Programming Library " -.SH NAME -unw_set_caching_policy -\-\- set unwind caching policy -.PP -.SH SYNOPSIS - -.PP -#include -.br -.PP -int -unw_set_caching_policy(unw_addr_space_t -as, -unw_caching_policy_t -policy); -.br -.PP -.SH DESCRIPTION - -.PP -The unw_set_caching_policy() -routine sets the caching policy -of address space as -to the policy specified by argument -policy\&. -The policy -argument can take one of three -possible values: -.TP -UNW_CACHE_NONE - Turns off caching completely. This -also implicitly flushes the contents of all caches as if -unw_flush_cache() -had been called. -.TP -UNW_CACHE_GLOBAL - Enables caching using a global cache -that is shared by all threads. If global caching is unavailable or -unsupported, libunwind -may fall back on using a per\-thread -cache, as if UNW_CACHE_PER_THREAD -had been specified. -.TP -UNW_CACHE_PER_THREAD - Enables caching using -thread\-local caches. If a thread\-local caching are unavailable or -unsupported, libunwind -may fall back on using a global cache, -as if UNW_CACHE_GLOBAL -had been specified. -.PP -If caching is enabled, an application must be prepared to make -appropriate calls to unw_flush_cache() -whenever the target -changes in a way that could affect the validity of cached information. -For example, after unloading (removing) a shared library, -unw_flush_cache() -would have to be called (at least) for the -address\-range that was covered by the shared library. -.PP -For address spaces created via unw_create_addr_space(3), -caching is turned off by default. For the local address space -unw_local_addr_space, -caching is turned on by default. -.PP -.SH RETURN VALUE - -.PP -On successful completion, unw_set_caching_policy() -returns 0. -Otherwise the negative value of one of the error\-codes below is -returned. -.PP -.SH THREAD AND SIGNAL SAFETY - -.PP -unw_set_caching_policy() -is thread\-safe but \fInot\fP -safe -to use from a signal handler. -.PP -.SH ERRORS - -.PP -.TP -UNW_ENOMEM - The desired caching policy could not be -established because the application is out of memory. -.PP -.SH SEE ALSO - -.PP -libunwind(3), -unw_create_addr_space(3), -unw_set_cache_size(3), -unw_flush_cache(3) -.PP -.SH AUTHOR - -.PP -David Mosberger\-Tang -.br -Email: \fBdmosberger@gmail.com\fP -.br -WWW: \fBhttp://www.nongnu.org/libunwind/\fP\&. -.\" NOTE: This file is generated, DO NOT EDIT. diff --git a/src/pal/src/libunwind/doc/unw_set_caching_policy.tex b/src/pal/src/libunwind/doc/unw_set_caching_policy.tex deleted file mode 100644 index 3a4b07e84..000000000 --- a/src/pal/src/libunwind/doc/unw_set_caching_policy.tex +++ /dev/null @@ -1,81 +0,0 @@ -\documentclass{article} -\usepackage[fancyhdr,pdf]{latex2man} - -\input{common.tex} - -\begin{document} - -\begin{Name}{3}{unw\_set\_caching\_policy}{David Mosberger-Tang}{Programming Library}{unw\_set\_caching\_policy}unw\_set\_caching\_policy -- set unwind caching policy -\end{Name} - -\section{Synopsis} - -\File{\#include $<$libunwind.h$>$}\\ - -\Type{int} \Func{unw\_set\_caching\_policy}(\Type{unw\_addr\_space\_t} \Var{as}, \Type{unw\_caching\_policy\_t} \Var{policy});\\ - -\section{Description} - -The \Func{unw\_set\_caching\_policy}() routine sets the caching policy -of address space \Var{as} to the policy specified by argument -\Var{policy}. The \Var{policy} argument can take one of three -possible values: -\begin{description} -\item[\Const{UNW\_CACHE\_NONE}] Turns off caching completely. This - also implicitly flushes the contents of all caches as if - \Func{unw\_flush\_cache}() had been called. -\item[\Const{UNW\_CACHE\_GLOBAL}] Enables caching using a global cache - that is shared by all threads. If global caching is unavailable or - unsupported, \Prog{libunwind} may fall back on using a per-thread - cache, as if \Const{UNW\_CACHE\_PER\_THREAD} had been specified. -\item[\Const{UNW\_CACHE\_PER\_THREAD}] Enables caching using - thread-local caches. If a thread-local caching are unavailable or - unsupported, \Prog{libunwind} may fall back on using a global cache, - as if \Const{UNW\_CACHE\_GLOBAL} had been specified. -\end{description} - -If caching is enabled, an application must be prepared to make -appropriate calls to \Func{unw\_flush\_cache}() whenever the target -changes in a way that could affect the validity of cached information. -For example, after unloading (removing) a shared library, -\Func{unw\_flush\_cache}() would have to be called (at least) for the -address-range that was covered by the shared library. - -For address spaces created via \Func{unw\_create\_addr\_space}(3), -caching is turned off by default. For the local address space -\Func{unw\_local\_addr\_space}, caching is turned on by default. - -\section{Return Value} - -On successful completion, \Func{unw\_set\_caching\_policy}() returns 0. -Otherwise the negative value of one of the error-codes below is -returned. - -\section{Thread and Signal Safety} - -\Func{unw\_set\_caching\_policy}() is thread-safe but \emph{not} safe -to use from a signal handler. - -\section{Errors} - -\begin{Description} -\item[\Const{UNW\_ENOMEM}] The desired caching policy could not be - established because the application is out of memory. -\end{Description} - -\section{See Also} - -\SeeAlso{libunwind(3)}, -\SeeAlso{unw\_create\_addr\_space(3)}, -\SeeAlso{unw\_set\_cache\_size(3)}, -\SeeAlso{unw\_flush\_cache(3)} - -\section{Author} - -\noindent -David Mosberger-Tang\\ -Email: \Email{dmosberger@gmail.com}\\ -WWW: \URL{http://www.nongnu.org/libunwind/}. -\LatexManEnd - -\end{document} diff --git a/src/pal/src/libunwind/doc/unw_set_fpreg.man b/src/pal/src/libunwind/doc/unw_set_fpreg.man deleted file mode 100644 index 6cefa5462..000000000 --- a/src/pal/src/libunwind/doc/unw_set_fpreg.man +++ /dev/null @@ -1,117 +0,0 @@ -'\" t -.\" Manual page created with latex2man on Thu Aug 16 09:44:45 MDT 2007 -.\" NOTE: This file is generated, DO NOT EDIT. -.de Vb -.ft CW -.nf -.. -.de Ve -.ft R - -.fi -.. -.TH "UNW\\_SET\\_FPREG" "3" "16 August 2007" "Programming Library " "Programming Library " -.SH NAME -unw_set_fpreg -\-\- set contents of floating\-point register -.PP -.SH SYNOPSIS - -.PP -#include -.br -.PP -int -unw_set_fpreg(unw_cursor_t *cp, -unw_regnum_t -reg, -unw_fpreg_t -val); -.br -.PP -.SH DESCRIPTION - -.PP -The unw_set_fpreg() -routine sets the value of register -reg -in the stack frame identified by cursor cp -to the -value passed in val\&. -.PP -The register numbering is target\-dependent and described in separate -manual pages (e.g., libunwind\-ia64(3) for the IA\-64 target). -Furthermore, the exact set of accessible registers may depend on the -type of frame that cp -is referring to. For ordinary stack -frames, it is normally possible to access only the preserved -(``callee\-saved\&'') registers and frame\-related registers (such as the -stack\-pointer). However, for signal frames (see -unw_is_signal_frame(3)), -it is usually possible to access -all registers. -.PP -Note that unw_set_fpreg() -can only write the contents of -floating\-point registers. See unw_set_reg(3) -for a way to -write registers which fit in a single word. -.PP -.SH RETURN VALUE - -.PP -On successful completion, unw_set_fpreg() -returns 0. -Otherwise the negative value of one of the error\-codes below is -returned. -.PP -.SH THREAD AND SIGNAL SAFETY - -.PP -unw_set_fpreg() -is thread\-safe as well as safe to use -from a signal handler. -.PP -.SH ERRORS - -.PP -.TP -UNW_EUNSPEC - An unspecified error occurred. -.TP -UNW_EBADREG - An attempt was made to write a register -that is either invalid or not accessible in the current frame. -.TP -UNW_EREADONLY - An attempt was made to write to a -read\-only register. -.PP -In addition, unw_set_fpreg() -may return any error returned by -the access_mem(), -access_reg(), -and -access_fpreg() -call\-backs (see -unw_create_addr_space(3)). -.PP -.SH SEE ALSO - -.PP -libunwind(3), -libunwind\-ia64(3), -unw_get_fpreg(3), -unw_is_fpreg(3), -unw_is_signal_frame(3), -unw_set_reg(3) -.PP -.SH AUTHOR - -.PP -David Mosberger\-Tang -.br -Email: \fBdmosberger@gmail.com\fP -.br -WWW: \fBhttp://www.nongnu.org/libunwind/\fP\&. -.\" NOTE: This file is generated, DO NOT EDIT. diff --git a/src/pal/src/libunwind/doc/unw_set_fpreg.tex b/src/pal/src/libunwind/doc/unw_set_fpreg.tex deleted file mode 100644 index aaf7fb25a..000000000 --- a/src/pal/src/libunwind/doc/unw_set_fpreg.tex +++ /dev/null @@ -1,79 +0,0 @@ -\documentclass{article} -\usepackage[fancyhdr,pdf]{latex2man} - -\input{common.tex} - -\begin{document} - -\begin{Name}{3}{unw\_set\_fpreg}{David Mosberger-Tang}{Programming Library}{unw\_set\_fpreg}unw\_set\_fpreg -- set contents of floating-point register -\end{Name} - -\section{Synopsis} - -\File{\#include $<$libunwind.h$>$}\\ - -\Type{int} \Func{unw\_set\_fpreg}(\Type{unw\_cursor\_t~*}\Var{cp}, \Type{unw\_regnum\_t} \Var{reg}, \Type{unw\_fpreg\_t} \Var{val});\\ - -\section{Description} - -The \Func{unw\_set\_fpreg}() routine sets the value of register -\Var{reg} in the stack frame identified by cursor \Var{cp} to the -value passed in \Var{val}. - -The register numbering is target-dependent and described in separate -manual pages (e.g., libunwind-ia64(3) for the IA-64 target). -Furthermore, the exact set of accessible registers may depend on the -type of frame that \Var{cp} is referring to. For ordinary stack -frames, it is normally possible to access only the preserved -(``callee-saved'') registers and frame-related registers (such as the -stack-pointer). However, for signal frames (see -\Func{unw\_is\_signal\_frame}(3)), it is usually possible to access -all registers. - -Note that \Func{unw\_set\_fpreg}() can only write the contents of -floating-point registers. See \Func{unw\_set\_reg}(3) for a way to -write registers which fit in a single word. - -\section{Return Value} - -On successful completion, \Func{unw\_set\_fpreg}() returns 0. -Otherwise the negative value of one of the error-codes below is -returned. - -\section{Thread and Signal Safety} - -\Func{unw\_set\_fpreg}() is thread-safe as well as safe to use -from a signal handler. - -\section{Errors} - -\begin{Description} -\item[\Const{UNW\_EUNSPEC}] An unspecified error occurred. -\item[\Const{UNW\_EBADREG}] An attempt was made to write a register - that is either invalid or not accessible in the current frame. -\item[\Const{UNW\_EREADONLY}] An attempt was made to write to a - read-only register. -\end{Description} -In addition, \Func{unw\_set\_fpreg}() may return any error returned by -the \Func{access\_mem}(), \Func{access\_reg}(), and -\Func{access\_fpreg}() call-backs (see -\Func{unw\_create\_addr\_space}(3)). - -\section{See Also} - -\SeeAlso{libunwind(3)}, -\SeeAlso{libunwind-ia64(3)}, -\SeeAlso{unw\_get\_fpreg(3)}, -\SeeAlso{unw\_is\_fpreg(3)}, -\SeeAlso{unw\_is\_signal\_frame(3)}, -\SeeAlso{unw\_set\_reg(3)} - -\section{Author} - -\noindent -David Mosberger-Tang\\ -Email: \Email{dmosberger@gmail.com}\\ -WWW: \URL{http://www.nongnu.org/libunwind/}. -\LatexManEnd - -\end{document} diff --git a/src/pal/src/libunwind/doc/unw_set_reg.man b/src/pal/src/libunwind/doc/unw_set_reg.man deleted file mode 100644 index 5d57045f7..000000000 --- a/src/pal/src/libunwind/doc/unw_set_reg.man +++ /dev/null @@ -1,117 +0,0 @@ -'\" t -.\" Manual page created with latex2man on Thu Aug 16 09:44:45 MDT 2007 -.\" NOTE: This file is generated, DO NOT EDIT. -.de Vb -.ft CW -.nf -.. -.de Ve -.ft R - -.fi -.. -.TH "UNW\\_SET\\_REG" "3" "16 August 2007" "Programming Library " "Programming Library " -.SH NAME -unw_set_reg -\-\- set register contents -.PP -.SH SYNOPSIS - -.PP -#include -.br -.PP -int -unw_set_reg(unw_cursor_t *cp, -unw_regnum_t -reg, -unw_word_t -val); -.br -.PP -.SH DESCRIPTION - -.PP -The unw_set_reg() -routine sets the value of register -reg -in the stack frame identified by cursor cp -to the -value passed in val\&. -.PP -The register numbering is target\-dependent and described in separate -manual pages (e.g., libunwind\-ia64(3) for the IA\-64 target). -Furthermore, the exact set of accessible registers may depend on the -type of frame that cp -is referring to. For ordinary stack -frames, it is normally possible to access only the preserved -(``callee\-saved\&'') registers and frame\-related registers (such as the -stack\-pointer). However, for signal frames (see -unw_is_signal_frame(3)), -it is usually possible to access -all registers. -.PP -Note that unw_set_reg() -can only write the contents of -registers whose values fit in a single word. See -unw_set_fpreg(3) -for a way to write registers which do not -fit this constraint. -.PP -.SH RETURN VALUE - -.PP -On successful completion, unw_set_reg() -returns 0. -Otherwise the negative value of one of the error\-codes below is -returned. -.PP -.SH THREAD AND SIGNAL SAFETY - -.PP -unw_set_reg() -is thread\-safe as well as safe to use -from a signal handler. -.PP -.SH ERRORS - -.PP -.TP -UNW_EUNSPEC - An unspecified error occurred. -.TP -UNW_EBADREG - An attempt was made to write a register -that is either invalid or not accessible in the current frame. -.TP -UNW_EREADONLY - An attempt was made to write to a -read\-only register. -.PP -In addition, unw_set_reg() -may return any error returned by -the access_mem(), -access_reg(), -and -access_fpreg() -call\-backs (see -unw_create_addr_space(3)). -.PP -.SH SEE ALSO - -.PP -libunwind(3), -libunwind\-ia64(3), -unw_get_reg(3), -unw_is_signal_frame(3), -unw_set_fpreg(3) -.PP -.SH AUTHOR - -.PP -David Mosberger\-Tang -.br -Email: \fBdmosberger@gmail.com\fP -.br -WWW: \fBhttp://www.nongnu.org/libunwind/\fP\&. -.\" NOTE: This file is generated, DO NOT EDIT. diff --git a/src/pal/src/libunwind/doc/unw_set_reg.tex b/src/pal/src/libunwind/doc/unw_set_reg.tex deleted file mode 100644 index 2421846be..000000000 --- a/src/pal/src/libunwind/doc/unw_set_reg.tex +++ /dev/null @@ -1,79 +0,0 @@ -\documentclass{article} -\usepackage[fancyhdr,pdf]{latex2man} - -\input{common.tex} - -\begin{document} - -\begin{Name}{3}{unw\_set\_reg}{David Mosberger-Tang}{Programming Library}{unw\_set\_reg}unw\_set\_reg -- set register contents -\end{Name} - -\section{Synopsis} - -\File{\#include $<$libunwind.h$>$}\\ - -\Type{int} \Func{unw\_set\_reg}(\Type{unw\_cursor\_t~*}\Var{cp}, \Type{unw\_regnum\_t} \Var{reg}, \Type{unw\_word\_t} \Var{val});\\ - -\section{Description} - -The \Func{unw\_set\_reg}() routine sets the value of register -\Var{reg} in the stack frame identified by cursor \Var{cp} to the -value passed in \Var{val}. - -The register numbering is target-dependent and described in separate -manual pages (e.g., libunwind-ia64(3) for the IA-64 target). -Furthermore, the exact set of accessible registers may depend on the -type of frame that \Var{cp} is referring to. For ordinary stack -frames, it is normally possible to access only the preserved -(``callee-saved'') registers and frame-related registers (such as the -stack-pointer). However, for signal frames (see -\Func{unw\_is\_signal\_frame}(3)), it is usually possible to access -all registers. - -Note that \Func{unw\_set\_reg}() can only write the contents of -registers whose values fit in a single word. See -\Func{unw\_set\_fpreg}(3) for a way to write registers which do not -fit this constraint. - -\section{Return Value} - -On successful completion, \Func{unw\_set\_reg}() returns 0. -Otherwise the negative value of one of the error-codes below is -returned. - -\section{Thread and Signal Safety} - -\Func{unw\_set\_reg}() is thread-safe as well as safe to use -from a signal handler. - -\section{Errors} - -\begin{Description} -\item[\Const{UNW\_EUNSPEC}] An unspecified error occurred. -\item[\Const{UNW\_EBADREG}] An attempt was made to write a register - that is either invalid or not accessible in the current frame. -\item[\Const{UNW\_EREADONLY}] An attempt was made to write to a - read-only register. -\end{Description} -In addition, \Func{unw\_set\_reg}() may return any error returned by -the \Func{access\_mem}(), \Func{access\_reg}(), and -\Func{access\_fpreg}() call-backs (see -\Func{unw\_create\_addr\_space}(3)). - -\section{See Also} - -\SeeAlso{libunwind(3)}, -\SeeAlso{libunwind-ia64(3)}, -\SeeAlso{unw\_get\_reg(3)}, -\SeeAlso{unw\_is\_signal\_frame(3)}, -\SeeAlso{unw\_set\_fpreg(3)} - -\section{Author} - -\noindent -David Mosberger-Tang\\ -Email: \Email{dmosberger@gmail.com}\\ -WWW: \URL{http://www.nongnu.org/libunwind/}. -\LatexManEnd - -\end{document} diff --git a/src/pal/src/libunwind/doc/unw_step.man b/src/pal/src/libunwind/doc/unw_step.man deleted file mode 100644 index 54da1b2f3..000000000 --- a/src/pal/src/libunwind/doc/unw_step.man +++ /dev/null @@ -1,106 +0,0 @@ -'\" t -.\" Manual page created with latex2man on Thu Aug 16 09:44:45 MDT 2007 -.\" NOTE: This file is generated, DO NOT EDIT. -.de Vb -.ft CW -.nf -.. -.de Ve -.ft R - -.fi -.. -.TH "UNW\\_STEP" "3" "16 August 2007" "Programming Library " "Programming Library " -.SH NAME -unw_step -\-\- advance to next stack frame -.PP -.SH SYNOPSIS - -.PP -#include -.br -.PP -int -unw_step(unw_cursor_t *cp); -.br -.PP -.SH DESCRIPTION - -.PP -The unw_step() -routine advances the unwind cursor cp -to -the next older, less deeply nested stack frame. -.PP -.SH RETURN VALUE - -.PP -On successful completion, unw_step() -returns a positive value -if the updated cursor refers to a valid stack frame, or 0 if the -previous stack frame was the last frame in the chain. On error, the -negative value of one of the error\-codes below is returned. -.PP -.SH THREAD AND SIGNAL SAFETY - -.PP -unw_step() -is thread\-safe. If cursor cp -is in the local -address\-space, this routine is also safe to use from a signal handler. -.PP -.SH ERRORS - -.PP -.TP -UNW_EUNSPEC - An unspecified error occurred. -.TP -UNW_ENOINFO - Libunwind -was unable to locate the -unwind\-info needed to complete the operation. -.TP -UNW_EBADVERSION - The unwind\-info needed to complete the -operation has a version or a format that is not understood by -libunwind\&. -.TP -UNW_EINVALIDIP - The instruction\-pointer -(``program\-counter\&'') of the next stack frame is invalid (e.g., not -properly aligned). -.TP -UNW_EBADFRAME - The next stack frame is invalid. -.TP -UNW_ESTOPUNWIND - Returned if a call to -find_proc_info() -returned \-UNW_ESTOPUNWIND\&. -.PP -In addition, unw_step() -may return any error returned by the -find_proc_info(), -get_dyn_info_list_addr(), -access_mem(), -access_reg(), -or access_fpreg() -call\-backs (see unw_create_addr_space(3)). -.PP -.SH SEE ALSO - -.PP -libunwind(3), -unw_create_addr_space(3) -.PP -.SH AUTHOR - -.PP -David Mosberger\-Tang -.br -Email: \fBdmosberger@gmail.com\fP -.br -WWW: \fBhttp://www.nongnu.org/libunwind/\fP\&. -.\" NOTE: This file is generated, DO NOT EDIT. diff --git a/src/pal/src/libunwind/doc/unw_step.tex b/src/pal/src/libunwind/doc/unw_step.tex deleted file mode 100644 index 106bd9ba9..000000000 --- a/src/pal/src/libunwind/doc/unw_step.tex +++ /dev/null @@ -1,68 +0,0 @@ -\documentclass{article} -\usepackage[fancyhdr,pdf]{latex2man} - -\input{common.tex} - -\begin{document} - -\begin{Name}{3}{unw\_step}{David Mosberger-Tang}{Programming Library}{unw\_step}unw\_step -- advance to next stack frame -\end{Name} - -\section{Synopsis} - -\File{\#include $<$libunwind.h$>$}\\ - -\Type{int} \Func{unw\_step}(\Type{unw\_cursor\_t~*}\Var{cp});\\ - -\section{Description} - -The \Func{unw\_step}() routine advances the unwind cursor \Var{cp} to -the next older, less deeply nested stack frame. - -\section{Return Value} - -On successful completion, \Func{unw\_step}() returns a positive value -if the updated cursor refers to a valid stack frame, or 0 if the -previous stack frame was the last frame in the chain. On error, the -negative value of one of the error-codes below is returned. - -\section{Thread and Signal Safety} - -\Func{unw\_step}() is thread-safe. If cursor \Var{cp} is in the local -address-space, this routine is also safe to use from a signal handler. - -\section{Errors} - -\begin{Description} -\item[\Const{UNW\_EUNSPEC}] An unspecified error occurred. -\item[\Const{UNW\_ENOINFO}] \Prog{Libunwind} was unable to locate the - unwind-info needed to complete the operation. -\item[\Const{UNW\_EBADVERSION}] The unwind-info needed to complete the - operation has a version or a format that is not understood by - \Prog{libunwind}. -\item[\Const{UNW\_EINVALIDIP}] The instruction-pointer - (``program-counter'') of the next stack frame is invalid (e.g., not - properly aligned). -\item[\Const{UNW\_EBADFRAME}] The next stack frame is invalid. -\item[\Const{UNW\_ESTOPUNWIND}] Returned if a call to - \Func{find\_proc\_info}() returned -\Const{UNW\_ESTOPUNWIND}. -\end{Description} -In addition, \Func{unw\_step}() may return any error returned by the -\Func{find\_proc\_info}(), \Func{get\_dyn\_info\_list\_addr}(), -\Func{access\_mem}(), \Func{access\_reg}(), or \Func{access\_fpreg}() -call-backs (see \Func{unw\_create\_addr\_space}(3)). - -\section{See Also} - -\SeeAlso{libunwind(3)}, -\SeeAlso{unw\_create\_addr\_space(3)} - -\section{Author} - -\noindent -David Mosberger-Tang\\ -Email: \Email{dmosberger@gmail.com}\\ -WWW: \URL{http://www.nongnu.org/libunwind/}. -\LatexManEnd - -\end{document} diff --git a/src/pal/src/libunwind/doc/unw_strerror.man b/src/pal/src/libunwind/doc/unw_strerror.man deleted file mode 100644 index 467c44d26..000000000 --- a/src/pal/src/libunwind/doc/unw_strerror.man +++ /dev/null @@ -1,63 +0,0 @@ -'\" t -.\" Manual page created with latex2man on Wed Aug 18 16:51:29 CEST 2004 -.\" NOTE: This file is generated, DO NOT EDIT. -.de Vb -.ft CW -.nf -.. -.de Ve -.ft R - -.fi -.. -.TH "UNW\\_STRERROR" "3" "18 August 2004" "Programming Library " "Programming Library " -.SH NAME -unw_strerror -\-\- get text corresponding to error code -.PP -.SH SYNOPSIS - -.PP -#include -.br -.PP -const char * -unw_strerror(int -err_code); -.br -.PP -.SH DESCRIPTION - -.PP -The unw_strerror() -routine maps the (negative) err_code -to a corresponding text message and returns it. -.PP -.SH RETURN VALUE - -.PP -The message that corresponds to err_code -or, if the -err_code -has no corresponding message, the text "invalid error -code". -.PP -.SH THREAD AND SIGNAL SAFETY - -.PP -unw_strerror() -is thread\-safe as well as safe to use -from a signal handler. -.PP -.SH AUTHOR - -.PP -Thomas Hallgren -.br -BEA Systems -.br -Stockholm, Sweden -.br -Email: \fBthallgre@bea.com\fP -.br -.\" NOTE: This file is generated, DO NOT EDIT. diff --git a/src/pal/src/libunwind/doc/unw_strerror.tex b/src/pal/src/libunwind/doc/unw_strerror.tex deleted file mode 100644 index 7cad01176..000000000 --- a/src/pal/src/libunwind/doc/unw_strerror.tex +++ /dev/null @@ -1,42 +0,0 @@ -\documentclass{article} -\usepackage[fancyhdr,pdf]{latex2man} - -\input{common.tex} - -\begin{document} - -\begin{Name}{3}{unw\_strerror}{Thomas Hallgren}{Programming Library}{unw\_strerror}unw\_strerror -- get text corresponding to error code -\end{Name} - -\section{Synopsis} - -\File{\#include $<$libunwind.h$>$}\\ - -\Type{const char *} \Func{unw\_strerror}(\Type{int} \Var{err\_code});\\ - -\section{Description} - -The \Func{unw\_strerror}() routine maps the (negative) \Var{err\_code} -to a corresponding text message and returns it. - -\section{Return Value} - -The message that corresponds to \Var{err\_code} or, if the -\Var{err\_code} has no corresponding message, the text "invalid error -code". - -\section{Thread and Signal Safety} - -\Func{unw\_strerror}() is thread-safe as well as safe to use -from a signal handler. - -\section{Author} - -\noindent -Thomas Hallgren\\ -BEA Systems\\ -Stockholm, Sweden\\ -Email: \Email{thallgre@bea.com}\\ -\LatexManEnd - -\end{document} diff --git a/src/pal/src/libunwind/include/compiler.h b/src/pal/src/libunwind/include/compiler.h deleted file mode 100644 index 2fa59eff7..000000000 --- a/src/pal/src/libunwind/include/compiler.h +++ /dev/null @@ -1,72 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2001-2005 Hewlett-Packard Co - Copyright (C) 2007 David Mosberger-Tang - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -/* Compiler specific useful bits that are used in libunwind, and also in the - * tests. */ - -#ifndef COMPILER_H -#define COMPILER_H - -#ifdef __GNUC__ -# define ALIGNED(x) __attribute__((aligned(x))) -# define CONST_ATTR __attribute__((__const__)) -# define UNUSED __attribute__((unused)) -# define NOINLINE __attribute__((noinline)) -# define NORETURN __attribute__((noreturn)) -# define ALIAS2(name) #name -# define ALIAS(name) __attribute__((alias (ALIAS2(name)))) -# if (__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ > 2) -# define ALWAYS_INLINE inline __attribute__((always_inline)) -# define HIDDEN __attribute__((visibility ("hidden"))) -# else -# define ALWAYS_INLINE -# define HIDDEN -# endif -# define WEAK __attribute__((weak)) -# if (__GNUC__ >= 3) -# define likely(x) __builtin_expect ((x), 1) -# define unlikely(x) __builtin_expect ((x), 0) -# else -# define likely(x) (x) -# define unlikely(x) (x) -# endif -#else -# define ALIGNED(x) -# define ALWAYS_INLINE -# define CONST_ATTR -# define UNUSED -# define NOINLINE -# define NORETURN -# define ALIAS(name) -# define HIDDEN -# define WEAK -# define likely(x) (x) -# define unlikely(x) (x) -#endif - -#define ARRAY_SIZE(a) (sizeof (a) / sizeof ((a)[0])) - -#endif /* COMPILER_H */ diff --git a/src/pal/src/libunwind/include/dwarf-eh.h b/src/pal/src/libunwind/include/dwarf-eh.h deleted file mode 100644 index e03750760..000000000 --- a/src/pal/src/libunwind/include/dwarf-eh.h +++ /dev/null @@ -1,128 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (c) 2003 Hewlett-Packard Development Company, L.P. - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#ifndef dwarf_eh_h -#define dwarf_eh_h - -#include "dwarf.h" - -/* This header file defines the format of a DWARF exception-header - section (.eh_frame_hdr, pointed to by program-header - PT_GNU_EH_FRAME). The exception-header is self-describing in the - sense that the format of the addresses contained in it is expressed - as a one-byte type-descriptor called a "pointer-encoding" (PE). - - The exception header encodes the address of the .eh_frame section - and optionally contains a binary search table for the - Frame Descriptor Entries (FDEs) in the .eh_frame. The contents of - .eh_frame has the format described by the DWARF v3 standard - (http://www.eagercon.com/dwarf/dwarf3std.htm), except that code - addresses may be encoded in different ways. Also, .eh_frame has - augmentations that allow encoding a language-specific data-area - (LSDA) pointer and a pointer to a personality-routine. - - Details: - - The Common Information Entry (CIE) associated with an FDE may - contain an augmentation string. Each character in this string has - a specific meaning and either one or two associated operands. The - operands are stored in an augmentation body which appears right - after the "return_address_register" member and before the - "initial_instructions" member. The operands appear in the order - in which the characters appear in the string. For example, if the - augmentation string is "zL", the operand for 'z' would be first in - the augmentation body and the operand for 'L' would be second. - The following characters are supported for the CIE augmentation - string: - - 'z': The operand for this character is a uleb128 value that gives the - length of the CIE augmentation body, not counting the length - of the uleb128 operand itself. If present, this code must - appear as the first character in the augmentation body. - - 'L': Indicates that the FDE's augmentation body contains an LSDA - pointer. The operand for this character is a single byte - that specifies the pointer-encoding (PE) that is used for - the LSDA pointer. - - 'R': Indicates that the code-pointers (FDE members - "initial_location" and "address_range" and the operand for - DW_CFA_set_loc) in the FDE have a non-default encoding. The - operand for this character is a single byte that specifies - the pointer-encoding (PE) that is used for the - code-pointers. Note: the "address_range" member is always - encoded as an absolute value. Apart from that, the specified - FDE pointer-encoding applies. - - 'P': Indicates the presence of a personality routine (handler). - The first operand for this character specifies the - pointer-encoding (PE) that is used for the second operand, - which specifies the address of the personality routine. - - If the augmentation string contains any other characters, the - remainder of the augmentation string should be ignored. - Furthermore, if the size of the augmentation body is unknown - (i.e., 'z' is not the first character of the augmentation string), - then the entire CIE as well all associated FDEs must be ignored. - - A Frame Descriptor Entries (FDE) may contain an augmentation body - which, if present, appears right after the "address_range" member - and before the "instructions" member. The contents of this body - is implicitly defined by the augmentation string of the associated - CIE. The meaning of the characters in the CIE's augmentation - string as far as FDEs are concerned is as follows: - - 'z': The first operand in the FDE's augmentation body specifies - the total length of the augmentation body as a uleb128 (not - counting the length of the uleb128 operand itself). - - 'L': The operand for this character is an LSDA pointer, encoded - in the format specified by the corresponding operand in the - CIE's augmentation body. - -*/ - -#define DW_EH_VERSION 1 /* The version we're implementing */ - -struct __attribute__((packed)) dwarf_eh_frame_hdr - { - unsigned char version; - unsigned char eh_frame_ptr_enc; - unsigned char fde_count_enc; - unsigned char table_enc; - Elf_W (Addr) eh_frame; - /* The rest of the header is variable-length and consists of the - following members: - - encoded_t fde_count; - struct - { - encoded_t start_ip; // first address covered by this FDE - encoded_t fde_addr; // address of the FDE - } - binary_search_table[fde_count]; */ - }; - -#endif /* dwarf_eh_h */ diff --git a/src/pal/src/libunwind/include/dwarf.h b/src/pal/src/libunwind/include/dwarf.h deleted file mode 100644 index fab93c614..000000000 --- a/src/pal/src/libunwind/include/dwarf.h +++ /dev/null @@ -1,450 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (c) 2003-2005 Hewlett-Packard Development Company, L.P. - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#ifndef dwarf_h -#define dwarf_h - -#include - -struct dwarf_cursor; /* forward-declaration */ -struct elf_dyn_info; - -#include "dwarf-config.h" - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#ifndef UNW_REMOTE_ONLY - #if defined(HAVE_LINK_H) - #include - #elif defined(HAVE_SYS_LINK_H) - #include - #else - #error Could not find - #endif -#endif - -#include - -/* DWARF expression opcodes. */ - -typedef enum - { - DW_OP_addr = 0x03, - DW_OP_deref = 0x06, - DW_OP_const1u = 0x08, - DW_OP_const1s = 0x09, - DW_OP_const2u = 0x0a, - DW_OP_const2s = 0x0b, - DW_OP_const4u = 0x0c, - DW_OP_const4s = 0x0d, - DW_OP_const8u = 0x0e, - DW_OP_const8s = 0x0f, - DW_OP_constu = 0x10, - DW_OP_consts = 0x11, - DW_OP_dup = 0x12, - DW_OP_drop = 0x13, - DW_OP_over = 0x14, - DW_OP_pick = 0x15, - DW_OP_swap = 0x16, - DW_OP_rot = 0x17, - DW_OP_xderef = 0x18, - DW_OP_abs = 0x19, - DW_OP_and = 0x1a, - DW_OP_div = 0x1b, - DW_OP_minus = 0x1c, - DW_OP_mod = 0x1d, - DW_OP_mul = 0x1e, - DW_OP_neg = 0x1f, - DW_OP_not = 0x20, - DW_OP_or = 0x21, - DW_OP_plus = 0x22, - DW_OP_plus_uconst = 0x23, - DW_OP_shl = 0x24, - DW_OP_shr = 0x25, - DW_OP_shra = 0x26, - DW_OP_xor = 0x27, - DW_OP_skip = 0x2f, - DW_OP_bra = 0x28, - DW_OP_eq = 0x29, - DW_OP_ge = 0x2a, - DW_OP_gt = 0x2b, - DW_OP_le = 0x2c, - DW_OP_lt = 0x2d, - DW_OP_ne = 0x2e, - DW_OP_lit0 = 0x30, - DW_OP_lit1, DW_OP_lit2, DW_OP_lit3, DW_OP_lit4, DW_OP_lit5, - DW_OP_lit6, DW_OP_lit7, DW_OP_lit8, DW_OP_lit9, DW_OP_lit10, - DW_OP_lit11, DW_OP_lit12, DW_OP_lit13, DW_OP_lit14, DW_OP_lit15, - DW_OP_lit16, DW_OP_lit17, DW_OP_lit18, DW_OP_lit19, DW_OP_lit20, - DW_OP_lit21, DW_OP_lit22, DW_OP_lit23, DW_OP_lit24, DW_OP_lit25, - DW_OP_lit26, DW_OP_lit27, DW_OP_lit28, DW_OP_lit29, DW_OP_lit30, - DW_OP_lit31, - DW_OP_reg0 = 0x50, - DW_OP_reg1, DW_OP_reg2, DW_OP_reg3, DW_OP_reg4, DW_OP_reg5, - DW_OP_reg6, DW_OP_reg7, DW_OP_reg8, DW_OP_reg9, DW_OP_reg10, - DW_OP_reg11, DW_OP_reg12, DW_OP_reg13, DW_OP_reg14, DW_OP_reg15, - DW_OP_reg16, DW_OP_reg17, DW_OP_reg18, DW_OP_reg19, DW_OP_reg20, - DW_OP_reg21, DW_OP_reg22, DW_OP_reg23, DW_OP_reg24, DW_OP_reg25, - DW_OP_reg26, DW_OP_reg27, DW_OP_reg28, DW_OP_reg29, DW_OP_reg30, - DW_OP_reg31, - DW_OP_breg0 = 0x70, - DW_OP_breg1, DW_OP_breg2, DW_OP_breg3, DW_OP_breg4, DW_OP_breg5, - DW_OP_breg6, DW_OP_breg7, DW_OP_breg8, DW_OP_breg9, DW_OP_breg10, - DW_OP_breg11, DW_OP_breg12, DW_OP_breg13, DW_OP_breg14, DW_OP_breg15, - DW_OP_breg16, DW_OP_breg17, DW_OP_breg18, DW_OP_breg19, DW_OP_breg20, - DW_OP_breg21, DW_OP_breg22, DW_OP_breg23, DW_OP_breg24, DW_OP_breg25, - DW_OP_breg26, DW_OP_breg27, DW_OP_breg28, DW_OP_breg29, DW_OP_breg30, - DW_OP_breg31, - DW_OP_regx = 0x90, - DW_OP_fbreg = 0x91, - DW_OP_bregx = 0x92, - DW_OP_piece = 0x93, - DW_OP_deref_size = 0x94, - DW_OP_xderef_size = 0x95, - DW_OP_nop = 0x96, - DW_OP_push_object_address = 0x97, - DW_OP_call2 = 0x98, - DW_OP_call4 = 0x99, - DW_OP_call_ref = 0x9a, - DW_OP_lo_user = 0xe0, - DW_OP_hi_user = 0xff - } -dwarf_expr_op_t; - -#define DWARF_CIE_VERSION 3 -#define DWARF_CIE_VERSION_MAX 4 - -#define DWARF_CFA_OPCODE_MASK 0xc0 -#define DWARF_CFA_OPERAND_MASK 0x3f - -typedef enum - { - DW_CFA_advance_loc = 0x40, - DW_CFA_offset = 0x80, - DW_CFA_restore = 0xc0, - DW_CFA_nop = 0x00, - DW_CFA_set_loc = 0x01, - DW_CFA_advance_loc1 = 0x02, - DW_CFA_advance_loc2 = 0x03, - DW_CFA_advance_loc4 = 0x04, - DW_CFA_offset_extended = 0x05, - DW_CFA_restore_extended = 0x06, - DW_CFA_undefined = 0x07, - DW_CFA_same_value = 0x08, - DW_CFA_register = 0x09, - DW_CFA_remember_state = 0x0a, - DW_CFA_restore_state = 0x0b, - DW_CFA_def_cfa = 0x0c, - DW_CFA_def_cfa_register = 0x0d, - DW_CFA_def_cfa_offset = 0x0e, - DW_CFA_def_cfa_expression = 0x0f, - DW_CFA_expression = 0x10, - DW_CFA_offset_extended_sf = 0x11, - DW_CFA_def_cfa_sf = 0x12, - DW_CFA_def_cfa_offset_sf = 0x13, - DW_CFA_val_expression = 0x16, - DW_CFA_lo_user = 0x1c, - DW_CFA_MIPS_advance_loc8 = 0x1d, - DW_CFA_GNU_window_save = 0x2d, - DW_CFA_GNU_args_size = 0x2e, - DW_CFA_GNU_negative_offset_extended = 0x2f, - DW_CFA_hi_user = 0x3c - } -dwarf_cfa_t; - -/* DWARF Pointer-Encoding (PEs). - - Pointer-Encodings were invented for the GCC exception-handling - support for C++, but they represent a rather generic way of - describing the format in which an address/pointer is stored and - hence we include the definitions here, in the main dwarf.h file. - The Pointer-Encoding format is partially documented in Linux Base - Spec v1.3 (http://www.linuxbase.org/spec/). The rest is reverse - engineered from GCC. - -*/ -#define DW_EH_PE_FORMAT_MASK 0x0f /* format of the encoded value */ -#define DW_EH_PE_APPL_MASK 0x70 /* how the value is to be applied */ -/* Flag bit. If set, the resulting pointer is the address of the word - that contains the final address. */ -#define DW_EH_PE_indirect 0x80 - -/* Pointer-encoding formats: */ -#define DW_EH_PE_omit 0xff -#define DW_EH_PE_ptr 0x00 /* pointer-sized unsigned value */ -#define DW_EH_PE_uleb128 0x01 /* unsigned LE base-128 value */ -#define DW_EH_PE_udata2 0x02 /* unsigned 16-bit value */ -#define DW_EH_PE_udata4 0x03 /* unsigned 32-bit value */ -#define DW_EH_PE_udata8 0x04 /* unsigned 64-bit value */ -#define DW_EH_PE_sleb128 0x09 /* signed LE base-128 value */ -#define DW_EH_PE_sdata2 0x0a /* signed 16-bit value */ -#define DW_EH_PE_sdata4 0x0b /* signed 32-bit value */ -#define DW_EH_PE_sdata8 0x0c /* signed 64-bit value */ - -/* Pointer-encoding application: */ -#define DW_EH_PE_absptr 0x00 /* absolute value */ -#define DW_EH_PE_pcrel 0x10 /* rel. to addr. of encoded value */ -#define DW_EH_PE_textrel 0x20 /* text-relative (GCC-specific???) */ -#define DW_EH_PE_datarel 0x30 /* data-relative */ -/* The following are not documented by LSB v1.3, yet they are used by - GCC, presumably they aren't documented by LSB since they aren't - used on Linux: */ -#define DW_EH_PE_funcrel 0x40 /* start-of-procedure-relative */ -#define DW_EH_PE_aligned 0x50 /* aligned pointer */ - -extern struct mempool dwarf_reg_state_pool; -extern struct mempool dwarf_cie_info_pool; - -typedef enum - { - DWARF_WHERE_UNDEF, /* register isn't saved at all */ - DWARF_WHERE_SAME, /* register has same value as in prev. frame */ - DWARF_WHERE_CFAREL, /* register saved at CFA-relative address */ - DWARF_WHERE_REG, /* register saved in another register */ - DWARF_WHERE_EXPR, /* register saved */ - DWARF_WHERE_VAL_EXPR, /* register has computed value */ - } -dwarf_where_t; - -/* For uniformity, we'd like to treat the CFA save-location like any - other register save-location, but this doesn't quite work, because - the CFA can be expressed as a (REGISTER,OFFSET) pair. To handle - this, we use two dwarf_save_loc structures to describe the CFA. - The first one (CFA_REG_COLUMN), tells us where the CFA is saved. - In the case of DWARF_WHERE_EXPR, the CFA is defined by a DWARF - location expression whose address is given by member "val". In the - case of DWARF_WHERE_REG, member "val" gives the number of the - base-register and the "val" member of DWARF_CFA_OFF_COLUMN gives - the offset value. */ -#define DWARF_CFA_REG_COLUMN DWARF_NUM_PRESERVED_REGS -#define DWARF_CFA_OFF_COLUMN (DWARF_NUM_PRESERVED_REGS + 1) - -typedef struct dwarf_reg_only_state - { - char where[DWARF_NUM_PRESERVED_REGS + 2]; /* how is the register saved? */ - unw_word_t val[DWARF_NUM_PRESERVED_REGS + 2]; /* where it's saved */ - } -dwarf_reg_only_state_t; - -typedef struct dwarf_reg_state - { - unw_word_t ret_addr_column; /* which column in rule table represents return address */ - dwarf_reg_only_state_t reg; - } -dwarf_reg_state_t; - -typedef struct dwarf_stackable_reg_state - { - struct dwarf_stackable_reg_state *next; /* for rs_stack */ - dwarf_reg_state_t state; - } -dwarf_stackable_reg_state_t; - -typedef struct dwarf_reg_cache_entry - { - unw_word_t ip; /* ip this rs is for */ - unsigned short coll_chain; /* used for hash collisions */ - unsigned short hint; /* hint for next rs to try (or -1) */ - unsigned short valid : 1; /* optional machine-dependent signal info */ - unsigned short signal_frame : 1; /* optional machine-dependent signal info */ - } -dwarf_reg_cache_entry_t; - -typedef struct dwarf_cie_info - { - unw_word_t cie_instr_start; /* start addr. of CIE "initial_instructions" */ - unw_word_t cie_instr_end; /* end addr. of CIE "initial_instructions" */ - unw_word_t fde_instr_start; /* start addr. of FDE "instructions" */ - unw_word_t fde_instr_end; /* end addr. of FDE "instructions" */ - unw_word_t code_align; /* code-alignment factor */ - unw_word_t data_align; /* data-alignment factor */ - unw_word_t ret_addr_column; /* column of return-address register */ - unw_word_t handler; /* address of personality-routine */ - uint16_t abi; - uint16_t tag; - uint8_t fde_encoding; - uint8_t lsda_encoding; - unsigned int sized_augmentation : 1; - unsigned int have_abi_marker : 1; - unsigned int signal_frame : 1; - } -dwarf_cie_info_t; - -typedef struct dwarf_state_record - { - unsigned char fde_encoding; - unw_word_t args_size; - - dwarf_reg_state_t rs_initial; /* reg-state after CIE instructions */ - dwarf_reg_state_t rs_current; /* current reg-state */ - } -dwarf_state_record_t; - -typedef struct dwarf_cursor - { - void *as_arg; /* argument to address-space callbacks */ - unw_addr_space_t as; /* reference to per-address-space info */ - - unw_word_t cfa; /* canonical frame address; aka frame-/stack-pointer */ - unw_word_t ip; /* instruction pointer */ - unw_word_t args_size; /* size of arguments */ - unw_word_t eh_args[UNW_TDEP_NUM_EH_REGS]; - unsigned int eh_valid_mask; - - dwarf_loc_t loc[DWARF_NUM_PRESERVED_REGS]; - - unsigned int stash_frames :1; /* stash frames for fast lookup */ - unsigned int use_prev_instr :1; /* use previous (= call) or current (= signal) instruction? */ - unsigned int pi_valid :1; /* is proc_info valid? */ - unsigned int pi_is_dynamic :1; /* proc_info found via dynamic proc info? */ - unw_proc_info_t pi; /* info about current procedure */ - - short hint; /* faster lookup of the rs cache */ - short prev_rs; - } -dwarf_cursor_t; - -#define DWARF_DEFAULT_LOG_UNW_CACHE_SIZE 7 -#define DWARF_DEFAULT_UNW_CACHE_SIZE (1 << DWARF_DEFAULT_LOG_UNW_CACHE_SIZE) - -#define DWARF_DEFAULT_LOG_UNW_HASH_SIZE (DWARF_DEFAULT_LOG_UNW_CACHE_SIZE + 1) -#define DWARF_DEFAULT_UNW_HASH_SIZE (1 << DWARF_DEFAULT_LOG_UNW_HASH_SIZE) - -typedef unsigned char unw_hash_index_t; - -struct dwarf_rs_cache - { - pthread_mutex_t lock; - unsigned short rr_head; /* index of least-recently allocated rs */ - - unsigned short log_size; - unsigned short prev_log_size; - - /* hash table that maps instruction pointer to rs index: */ - unsigned short *hash; - - uint32_t generation; /* generation number */ - - /* rs cache: */ - dwarf_reg_state_t *buckets; - dwarf_reg_cache_entry_t *links; - - /* default memory, loaded in BSS segment */ - unsigned short default_hash[DWARF_DEFAULT_UNW_HASH_SIZE]; - dwarf_reg_state_t default_buckets[DWARF_DEFAULT_UNW_CACHE_SIZE]; - dwarf_reg_cache_entry_t default_links[DWARF_DEFAULT_UNW_CACHE_SIZE]; - }; - -/* A list of descriptors for loaded .debug_frame sections. */ - -struct unw_debug_frame_list - { - /* The start (inclusive) and end (exclusive) of the described region. */ - unw_word_t start; - unw_word_t end; - /* The debug frame itself. */ - char *debug_frame; - size_t debug_frame_size; - /* Index (for binary search). */ - struct table_entry *index; - size_t index_size; - /* Pointer to next descriptor. */ - struct unw_debug_frame_list *next; - }; - -/* Convenience macros: */ -#define dwarf_init UNW_ARCH_OBJ (dwarf_init) -#define dwarf_callback UNW_OBJ (dwarf_callback) -#define dwarf_find_proc_info UNW_OBJ (dwarf_find_proc_info) -#define dwarf_find_debug_frame UNW_OBJ (dwarf_find_debug_frame) -#define dwarf_search_unwind_table UNW_OBJ (dwarf_search_unwind_table) -#define dwarf_find_unwind_table UNW_OBJ (dwarf_find_unwind_table) -#define dwarf_put_unwind_info UNW_OBJ (dwarf_put_unwind_info) -#define dwarf_put_unwind_info UNW_OBJ (dwarf_put_unwind_info) -#define dwarf_eval_expr UNW_OBJ (dwarf_eval_expr) -#define dwarf_stack_aligned UNW_OBJ (dwarf_stack_aligned) -#define dwarf_extract_proc_info_from_fde \ - UNW_OBJ (dwarf_extract_proc_info_from_fde) -#define dwarf_find_save_locs UNW_OBJ (dwarf_find_save_locs) -#define dwarf_make_proc_info UNW_OBJ (dwarf_make_proc_info) -#define dwarf_apply_reg_state UNW_OBJ (dwarf_apply_reg_state) -#define dwarf_reg_states_iterate UNW_OBJ (dwarf_reg_states_iterate) -#define dwarf_read_encoded_pointer UNW_OBJ (dwarf_read_encoded_pointer) -#define dwarf_step UNW_OBJ (dwarf_step) -#define dwarf_flush_rs_cache UNW_OBJ (dwarf_flush_rs_cache) - -extern int dwarf_init (void); -#ifndef UNW_REMOTE_ONLY -extern int dwarf_callback (struct dl_phdr_info *info, size_t size, void *ptr); -extern int dwarf_find_proc_info (unw_addr_space_t as, unw_word_t ip, - unw_proc_info_t *pi, - int need_unwind_info, void *arg); -#endif /* !UNW_REMOTE_ONLY */ -extern int dwarf_find_debug_frame (int found, unw_dyn_info_t *di_debug, - unw_word_t ip, unw_word_t segbase, - const char* obj_name, unw_word_t start, - unw_word_t end); -extern int dwarf_search_unwind_table (unw_addr_space_t as, - unw_word_t ip, - unw_dyn_info_t *di, - unw_proc_info_t *pi, - int need_unwind_info, void *arg); - -extern int dwarf_find_unwind_table (struct elf_dyn_info *edi, unw_addr_space_t as, - char *path, unw_word_t segbase, unw_word_t mapoff, - unw_word_t ip); -extern void dwarf_put_unwind_info (unw_addr_space_t as, - unw_proc_info_t *pi, void *arg); -extern int dwarf_eval_expr (struct dwarf_cursor *c, unw_word_t *addr, - unw_word_t len, unw_word_t *valp, - int *is_register); -extern int -dwarf_stack_aligned(struct dwarf_cursor *c, unw_word_t cfa_addr, - unw_word_t rbp_addr, unw_word_t *offset); - -extern int dwarf_extract_proc_info_from_fde (unw_addr_space_t as, - unw_accessors_t *a, - unw_word_t *fde_addr, - unw_proc_info_t *pi, - unw_word_t base, - int need_unwind_info, - int is_debug_frame, - void *arg); -extern int dwarf_find_save_locs (struct dwarf_cursor *c); -extern int dwarf_make_proc_info (struct dwarf_cursor *c); -extern int dwarf_apply_reg_state (struct dwarf_cursor *c, struct dwarf_reg_state *rs); -extern int dwarf_reg_states_iterate (struct dwarf_cursor *c, unw_reg_states_callback cb, void *token); -extern int dwarf_read_encoded_pointer (unw_addr_space_t as, - unw_accessors_t *a, - unw_word_t *addr, - unsigned char encoding, - const unw_proc_info_t *pi, - unw_word_t *valp, void *arg); -extern int dwarf_step (struct dwarf_cursor *c); -extern int dwarf_flush_rs_cache (struct dwarf_rs_cache *cache); - -#endif /* dwarf_h */ diff --git a/src/pal/src/libunwind/include/dwarf_i.h b/src/pal/src/libunwind/include/dwarf_i.h deleted file mode 100644 index 983b9f5c2..000000000 --- a/src/pal/src/libunwind/include/dwarf_i.h +++ /dev/null @@ -1,490 +0,0 @@ -#ifndef DWARF_I_H -#define DWARF_I_H - -/* This file contains definitions that cannot be used in code outside - of libunwind. In particular, most inline functions are here - because otherwise they'd generate unresolved references when the - files are compiled with inlining disabled. */ - -#include "dwarf.h" -#include "libunwind_i.h" - -/* Unless we are told otherwise, assume that a "machine address" is - the size of an unw_word_t. */ -#ifndef dwarf_addr_size -# define dwarf_addr_size(as) (sizeof (unw_word_t)) -#endif - -#ifndef dwarf_to_unw_regnum -# define dwarf_to_unw_regnum_map UNW_OBJ (dwarf_to_unw_regnum_map) -extern const uint8_t dwarf_to_unw_regnum_map[DWARF_REGNUM_MAP_LENGTH]; -/* REG is evaluated multiple times; it better be side-effects free! */ -# define dwarf_to_unw_regnum(reg) \ - (((reg) < DWARF_REGNUM_MAP_LENGTH) ? dwarf_to_unw_regnum_map[reg] : 0) -#endif - -#ifdef UNW_LOCAL_ONLY - -/* In the local-only case, we can let the compiler directly access - memory and don't need to worry about differing byte-order. */ - -typedef union __attribute__ ((packed)) - { - int8_t s8; - int16_t s16; - int32_t s32; - int64_t s64; - uint8_t u8; - uint16_t u16; - uint32_t u32; - uint64_t u64; - void *ptr; - } -dwarf_misaligned_value_t; - -static inline int -dwarf_reads8 (unw_addr_space_t as, unw_accessors_t *a, unw_word_t *addr, - int8_t *val, void *arg) -{ - dwarf_misaligned_value_t *mvp = (void *) (uintptr_t) *addr; - - *val = mvp->s8; - *addr += sizeof (mvp->s8); - return 0; -} - -static inline int -dwarf_reads16 (unw_addr_space_t as, unw_accessors_t *a, unw_word_t *addr, - int16_t *val, void *arg) -{ - dwarf_misaligned_value_t *mvp = (void *) (uintptr_t) *addr; - - *val = mvp->s16; - *addr += sizeof (mvp->s16); - return 0; -} - -static inline int -dwarf_reads32 (unw_addr_space_t as, unw_accessors_t *a, unw_word_t *addr, - int32_t *val, void *arg) -{ - dwarf_misaligned_value_t *mvp = (void *) (uintptr_t) *addr; - - *val = mvp->s32; - *addr += sizeof (mvp->s32); - return 0; -} - -static inline int -dwarf_reads64 (unw_addr_space_t as, unw_accessors_t *a, unw_word_t *addr, - int64_t *val, void *arg) -{ - dwarf_misaligned_value_t *mvp = (void *) (uintptr_t) *addr; - - *val = mvp->s64; - *addr += sizeof (mvp->s64); - return 0; -} - -static inline int -dwarf_readu8 (unw_addr_space_t as, unw_accessors_t *a, unw_word_t *addr, - uint8_t *val, void *arg) -{ - dwarf_misaligned_value_t *mvp = (void *) (uintptr_t) *addr; - - *val = mvp->u8; - *addr += sizeof (mvp->u8); - return 0; -} - -static inline int -dwarf_readu16 (unw_addr_space_t as, unw_accessors_t *a, unw_word_t *addr, - uint16_t *val, void *arg) -{ - dwarf_misaligned_value_t *mvp = (void *) (uintptr_t) *addr; - - *val = mvp->u16; - *addr += sizeof (mvp->u16); - return 0; -} - -static inline int -dwarf_readu32 (unw_addr_space_t as, unw_accessors_t *a, unw_word_t *addr, - uint32_t *val, void *arg) -{ - dwarf_misaligned_value_t *mvp = (void *) (uintptr_t) *addr; - - *val = mvp->u32; - *addr += sizeof (mvp->u32); - return 0; -} - -static inline int -dwarf_readu64 (unw_addr_space_t as, unw_accessors_t *a, unw_word_t *addr, - uint64_t *val, void *arg) -{ - dwarf_misaligned_value_t *mvp = (void *) (uintptr_t) *addr; - - *val = mvp->u64; - *addr += sizeof (mvp->u64); - return 0; -} - -#else /* !UNW_LOCAL_ONLY */ - -static inline int -dwarf_readu8 (unw_addr_space_t as, unw_accessors_t *a, unw_word_t *addr, - uint8_t *valp, void *arg) -{ - unw_word_t val, aligned_addr = *addr & -sizeof (unw_word_t); - unw_word_t off = *addr - aligned_addr; - int ret; - - *addr += 1; - ret = (*a->access_mem) (as, aligned_addr, &val, 0, arg); -#if __BYTE_ORDER == __LITTLE_ENDIAN - val >>= 8*off; -#else - val >>= 8*(sizeof (unw_word_t) - 1 - off); -#endif - *valp = (uint8_t) val; - return ret; -} - -static inline int -dwarf_readu16 (unw_addr_space_t as, unw_accessors_t *a, unw_word_t *addr, - uint16_t *val, void *arg) -{ - uint8_t v0, v1; - int ret; - - if ((ret = dwarf_readu8 (as, a, addr, &v0, arg)) < 0 - || (ret = dwarf_readu8 (as, a, addr, &v1, arg)) < 0) - return ret; - - if (tdep_big_endian (as)) - *val = (uint16_t) v0 << 8 | v1; - else - *val = (uint16_t) v1 << 8 | v0; - return 0; -} - -static inline int -dwarf_readu32 (unw_addr_space_t as, unw_accessors_t *a, unw_word_t *addr, - uint32_t *val, void *arg) -{ - uint16_t v0, v1; - int ret; - - if ((ret = dwarf_readu16 (as, a, addr, &v0, arg)) < 0 - || (ret = dwarf_readu16 (as, a, addr, &v1, arg)) < 0) - return ret; - - if (tdep_big_endian (as)) - *val = (uint32_t) v0 << 16 | v1; - else - *val = (uint32_t) v1 << 16 | v0; - return 0; -} - -static inline int -dwarf_readu64 (unw_addr_space_t as, unw_accessors_t *a, unw_word_t *addr, - uint64_t *val, void *arg) -{ - uint32_t v0, v1; - int ret; - - if ((ret = dwarf_readu32 (as, a, addr, &v0, arg)) < 0 - || (ret = dwarf_readu32 (as, a, addr, &v1, arg)) < 0) - return ret; - - if (tdep_big_endian (as)) - *val = (uint64_t) v0 << 32 | v1; - else - *val = (uint64_t) v1 << 32 | v0; - return 0; -} - -static inline int -dwarf_reads8 (unw_addr_space_t as, unw_accessors_t *a, unw_word_t *addr, - int8_t *val, void *arg) -{ - uint8_t uval; - int ret; - - if ((ret = dwarf_readu8 (as, a, addr, &uval, arg)) < 0) - return ret; - *val = (int8_t) uval; - return 0; -} - -static inline int -dwarf_reads16 (unw_addr_space_t as, unw_accessors_t *a, unw_word_t *addr, - int16_t *val, void *arg) -{ - uint16_t uval; - int ret; - - if ((ret = dwarf_readu16 (as, a, addr, &uval, arg)) < 0) - return ret; - *val = (int16_t) uval; - return 0; -} - -static inline int -dwarf_reads32 (unw_addr_space_t as, unw_accessors_t *a, unw_word_t *addr, - int32_t *val, void *arg) -{ - uint32_t uval; - int ret; - - if ((ret = dwarf_readu32 (as, a, addr, &uval, arg)) < 0) - return ret; - *val = (int32_t) uval; - return 0; -} - -static inline int -dwarf_reads64 (unw_addr_space_t as, unw_accessors_t *a, unw_word_t *addr, - int64_t *val, void *arg) -{ - uint64_t uval; - int ret; - - if ((ret = dwarf_readu64 (as, a, addr, &uval, arg)) < 0) - return ret; - *val = (int64_t) uval; - return 0; -} - -#endif /* !UNW_LOCAL_ONLY */ - -static inline int -dwarf_readw (unw_addr_space_t as, unw_accessors_t *a, unw_word_t *addr, - unw_word_t *val, void *arg) -{ - uint32_t u32; - uint64_t u64; - int ret; - - switch (dwarf_addr_size (as)) - { - case 4: - ret = dwarf_readu32 (as, a, addr, &u32, arg); - if (ret < 0) - return ret; - *val = u32; - return ret; - - case 8: - ret = dwarf_readu64 (as, a, addr, &u64, arg); - if (ret < 0) - return ret; - *val = u64; - return ret; - - default: - abort (); - } -} - -/* Read an unsigned "little-endian base 128" value. See Chapter 7.6 - of DWARF spec v3. */ - -static inline int -dwarf_read_uleb128 (unw_addr_space_t as, unw_accessors_t *a, unw_word_t *addr, - unw_word_t *valp, void *arg) -{ - unw_word_t val = 0, shift = 0; - unsigned char byte; - int ret; - - do - { - if ((ret = dwarf_readu8 (as, a, addr, &byte, arg)) < 0) - return ret; - - val |= ((unw_word_t) byte & 0x7f) << shift; - shift += 7; - } - while (byte & 0x80); - - *valp = val; - return 0; -} - -/* Read a signed "little-endian base 128" value. See Chapter 7.6 of - DWARF spec v3. */ - -static inline int -dwarf_read_sleb128 (unw_addr_space_t as, unw_accessors_t *a, unw_word_t *addr, - unw_word_t *valp, void *arg) -{ - unw_word_t val = 0, shift = 0; - unsigned char byte; - int ret; - - do - { - if ((ret = dwarf_readu8 (as, a, addr, &byte, arg)) < 0) - return ret; - - val |= ((unw_word_t) byte & 0x7f) << shift; - shift += 7; - } - while (byte & 0x80); - - if (shift < 8 * sizeof (unw_word_t) && (byte & 0x40) != 0) - /* sign-extend negative value */ - val |= ((unw_word_t) -1) << shift; - - *valp = val; - return 0; -} - -static ALWAYS_INLINE int -dwarf_read_encoded_pointer_inlined (unw_addr_space_t as, unw_accessors_t *a, - unw_word_t *addr, unsigned char encoding, - const unw_proc_info_t *pi, - unw_word_t *valp, void *arg) -{ - unw_word_t val, initial_addr = *addr; - uint16_t uval16; - uint32_t uval32; - uint64_t uval64; - int16_t sval16 = 0; - int32_t sval32 = 0; - int64_t sval64 = 0; - int ret; - - /* DW_EH_PE_omit and DW_EH_PE_aligned don't follow the normal - format/application encoding. Handle them first. */ - if (encoding == DW_EH_PE_omit) - { - *valp = 0; - return 0; - } - else if (encoding == DW_EH_PE_aligned) - { - int size = dwarf_addr_size (as); - *addr = (initial_addr + size - 1) & -size; - return dwarf_readw (as, a, addr, valp, arg); - } - - switch (encoding & DW_EH_PE_FORMAT_MASK) - { - case DW_EH_PE_ptr: - if ((ret = dwarf_readw (as, a, addr, &val, arg)) < 0) - return ret; - break; - - case DW_EH_PE_uleb128: - if ((ret = dwarf_read_uleb128 (as, a, addr, &val, arg)) < 0) - return ret; - break; - - case DW_EH_PE_udata2: - if ((ret = dwarf_readu16 (as, a, addr, &uval16, arg)) < 0) - return ret; - val = uval16; - break; - - case DW_EH_PE_udata4: - if ((ret = dwarf_readu32 (as, a, addr, &uval32, arg)) < 0) - return ret; - val = uval32; - break; - - case DW_EH_PE_udata8: - if ((ret = dwarf_readu64 (as, a, addr, &uval64, arg)) < 0) - return ret; - val = uval64; - break; - - case DW_EH_PE_sleb128: - if ((ret = dwarf_read_uleb128 (as, a, addr, &val, arg)) < 0) - return ret; - break; - - case DW_EH_PE_sdata2: - if ((ret = dwarf_reads16 (as, a, addr, &sval16, arg)) < 0) - return ret; - val = sval16; - break; - - case DW_EH_PE_sdata4: - if ((ret = dwarf_reads32 (as, a, addr, &sval32, arg)) < 0) - return ret; - val = sval32; - break; - - case DW_EH_PE_sdata8: - if ((ret = dwarf_reads64 (as, a, addr, &sval64, arg)) < 0) - return ret; - val = sval64; - break; - - default: - Debug (1, "unexpected encoding format 0x%x\n", - encoding & DW_EH_PE_FORMAT_MASK); - return -UNW_EINVAL; - } - - if (val == 0) - { - /* 0 is a special value and always absolute. */ - *valp = 0; - return 0; - } - - switch (encoding & DW_EH_PE_APPL_MASK) - { - case DW_EH_PE_absptr: - break; - - case DW_EH_PE_pcrel: - val += initial_addr; - break; - - case DW_EH_PE_datarel: - /* XXX For now, assume that data-relative addresses are relative - to the global pointer. */ - val += pi->gp; - break; - - case DW_EH_PE_funcrel: - val += pi->start_ip; - break; - - case DW_EH_PE_textrel: - /* XXX For now we don't support text-rel values. If there is a - platform which needs this, we probably would have to add a - "segbase" member to unw_proc_info_t. */ - default: - Debug (1, "unexpected application type 0x%x\n", - encoding & DW_EH_PE_APPL_MASK); - return -UNW_EINVAL; - } - - /* Trim off any extra bits. Assume that sign extension isn't - required; the only place it is needed is MIPS kernel space - addresses. */ - if (sizeof (val) > dwarf_addr_size (as)) - { - assert (dwarf_addr_size (as) == 4); - val = (uint32_t) val; - } - - if (encoding & DW_EH_PE_indirect) - { - unw_word_t indirect_addr = val; - - if ((ret = dwarf_readw (as, a, &indirect_addr, &val, arg)) < 0) - return ret; - } - - *valp = val; - return 0; -} - -#endif /* DWARF_I_H */ diff --git a/src/pal/src/libunwind/include/libunwind-aarch64.h b/src/pal/src/libunwind/include/libunwind-aarch64.h deleted file mode 100644 index 85812e151..000000000 --- a/src/pal/src/libunwind/include/libunwind-aarch64.h +++ /dev/null @@ -1,210 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2001-2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - Copyright (C) 2013 Linaro Limited - -This file is part of libunwind. - -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. */ - -#ifndef LIBUNWIND_H -#define LIBUNWIND_H - -#if defined(__cplusplus) || defined(c_plusplus) -extern "C" { -#endif - -#include -#include -#include - -#define UNW_TARGET aarch64 -#define UNW_TARGET_AARCH64 1 - -#define _U_TDEP_QP_TRUE 0 /* see libunwind-dynamic.h */ - -/* This needs to be big enough to accommodate "struct cursor", while - leaving some slack for future expansion. Changing this value will - require recompiling all users of this library. Stack allocation is - relatively cheap and unwind-state copying is relatively rare, so we - want to err on making it rather too big than too small. */ - -#define UNW_TDEP_CURSOR_LEN 512 - -typedef uint64_t unw_word_t; -typedef int64_t unw_sword_t; - -typedef long double unw_tdep_fpreg_t; - -typedef struct - { - /* no aarch64-specific auxiliary proc-info */ - } -unw_tdep_proc_info_t; - -typedef enum - { - /* 64-bit general registers. */ - UNW_AARCH64_X0, - UNW_AARCH64_X1, - UNW_AARCH64_X2, - UNW_AARCH64_X3, - UNW_AARCH64_X4, - UNW_AARCH64_X5, - UNW_AARCH64_X6, - UNW_AARCH64_X7, - UNW_AARCH64_X8, - - /* Temporary registers. */ - UNW_AARCH64_X9, - UNW_AARCH64_X10, - UNW_AARCH64_X11, - UNW_AARCH64_X12, - UNW_AARCH64_X13, - UNW_AARCH64_X14, - UNW_AARCH64_X15, - - /* Intra-procedure-call temporary registers. */ - UNW_AARCH64_X16, - UNW_AARCH64_X17, - - /* Callee-saved registers. */ - UNW_AARCH64_X18, - UNW_AARCH64_X19, - UNW_AARCH64_X20, - UNW_AARCH64_X21, - UNW_AARCH64_X22, - UNW_AARCH64_X23, - UNW_AARCH64_X24, - UNW_AARCH64_X25, - UNW_AARCH64_X26, - UNW_AARCH64_X27, - UNW_AARCH64_X28, - - /* 64-bit frame pointer. */ - UNW_AARCH64_X29, - - /* 64-bit link register. */ - UNW_AARCH64_X30, - - /* 64-bit stack pointer. */ - UNW_AARCH64_SP = 31, - UNW_AARCH64_PC, - UNW_AARCH64_PSTATE, - - /* 128-bit FP/Advanced SIMD registers. */ - UNW_AARCH64_V0 = 64, - UNW_AARCH64_V1, - UNW_AARCH64_V2, - UNW_AARCH64_V3, - UNW_AARCH64_V4, - UNW_AARCH64_V5, - UNW_AARCH64_V6, - UNW_AARCH64_V7, - UNW_AARCH64_V8, - UNW_AARCH64_V9, - UNW_AARCH64_V10, - UNW_AARCH64_V11, - UNW_AARCH64_V12, - UNW_AARCH64_V13, - UNW_AARCH64_V14, - UNW_AARCH64_V15, - UNW_AARCH64_V16, - UNW_AARCH64_V17, - UNW_AARCH64_V18, - UNW_AARCH64_V19, - UNW_AARCH64_V20, - UNW_AARCH64_V21, - UNW_AARCH64_V22, - UNW_AARCH64_V23, - UNW_AARCH64_V24, - UNW_AARCH64_V25, - UNW_AARCH64_V26, - UNW_AARCH64_V27, - UNW_AARCH64_V28, - UNW_AARCH64_V29, - UNW_AARCH64_V30, - UNW_AARCH64_V31, - - UNW_AARCH64_FPSR, - UNW_AARCH64_FPCR, - - /* For AArch64, the CFA is the value of SP (x31) at the call site of the - previous frame. */ - UNW_AARCH64_CFA = UNW_AARCH64_SP, - - UNW_TDEP_LAST_REG = UNW_AARCH64_FPCR, - - UNW_TDEP_IP = UNW_AARCH64_X30, - UNW_TDEP_SP = UNW_AARCH64_SP, - UNW_TDEP_EH = UNW_AARCH64_X0, - - } -aarch64_regnum_t; - -/* Use R0 through R3 to pass exception handling information. */ -#define UNW_TDEP_NUM_EH_REGS 4 - -typedef struct unw_tdep_save_loc - { - /* Additional target-dependent info on a save location. */ - } -unw_tdep_save_loc_t; - - -/* On AArch64, we can directly use ucontext_t as the unwind context. */ -typedef ucontext_t unw_tdep_context_t; - -#include "libunwind-common.h" -#include "libunwind-dynamic.h" - -#define unw_tdep_getcontext(uc) (({ \ - unw_tdep_context_t *unw_ctx = (uc); \ - register uint64_t *unw_base asm ("x0") = (uint64_t*) unw_ctx->uc_mcontext.regs; \ - __asm__ __volatile__ ( \ - "stp x0, x1, [%[base], #0]\n" \ - "stp x2, x3, [%[base], #16]\n" \ - "stp x4, x5, [%[base], #32]\n" \ - "stp x6, x7, [%[base], #48]\n" \ - "stp x8, x9, [%[base], #64]\n" \ - "stp x10, x11, [%[base], #80]\n" \ - "stp x12, x13, [%[base], #96]\n" \ - "stp x14, x13, [%[base], #112]\n" \ - "stp x16, x17, [%[base], #128]\n" \ - "stp x18, x19, [%[base], #144]\n" \ - "stp x20, x21, [%[base], #160]\n" \ - "stp x22, x23, [%[base], #176]\n" \ - "stp x24, x25, [%[base], #192]\n" \ - "stp x26, x27, [%[base], #208]\n" \ - "stp x28, x29, [%[base], #224]\n" \ - "str x30, [%[base], #240]\n" \ - "mov x1, sp\n" \ - "stp x1, x30, [%[base], #248]\n" \ - : [base] "+r" (unw_base) : : "x1", "memory"); \ - }), 0) -#define unw_tdep_is_fpreg UNW_ARCH_OBJ(is_fpreg) - -extern int unw_tdep_is_fpreg (int); - -#if defined(__cplusplus) || defined(c_plusplus) -} -#endif - -#endif /* LIBUNWIND_H */ diff --git a/src/pal/src/libunwind/include/libunwind-arm.h b/src/pal/src/libunwind/include/libunwind-arm.h deleted file mode 100644 index 6709b7aba..000000000 --- a/src/pal/src/libunwind/include/libunwind-arm.h +++ /dev/null @@ -1,303 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - -This file is part of libunwind. - -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. */ - -#ifndef LIBUNWIND_H -#define LIBUNWIND_H - -#if defined(__cplusplus) || defined(c_plusplus) -extern "C" { -#endif - -#include -#include - -#define UNW_TARGET arm -#define UNW_TARGET_ARM 1 - -#define _U_TDEP_QP_TRUE 0 /* see libunwind-dynamic.h */ - -/* This needs to be big enough to accommodate "struct cursor", while - leaving some slack for future expansion. Changing this value will - require recompiling all users of this library. Stack allocation is - relatively cheap and unwind-state copying is relatively rare, so we - want to err on making it rather too big than too small. */ - -/* FIXME for ARM. Too big? What do other things use for similar tasks? */ -#define UNW_TDEP_CURSOR_LEN 4096 - -typedef uint32_t unw_word_t; -typedef int32_t unw_sword_t; - -typedef long double unw_tdep_fpreg_t; - -typedef enum - { - UNW_ARM_R0, - UNW_ARM_R1, - UNW_ARM_R2, - UNW_ARM_R3, - UNW_ARM_R4, - UNW_ARM_R5, - UNW_ARM_R6, - UNW_ARM_R7, - UNW_ARM_R8, - UNW_ARM_R9, - UNW_ARM_R10, - UNW_ARM_R11, - UNW_ARM_R12, - UNW_ARM_R13, - UNW_ARM_R14, - UNW_ARM_R15, - - /* VFPv2 s0-s31 (obsolescent numberings). */ - UNW_ARM_S0 = 64, - UNW_ARM_S1, - UNW_ARM_S2, - UNW_ARM_S3, - UNW_ARM_S4, - UNW_ARM_S5, - UNW_ARM_S6, - UNW_ARM_S7, - UNW_ARM_S8, - UNW_ARM_S9, - UNW_ARM_S10, - UNW_ARM_S11, - UNW_ARM_S12, - UNW_ARM_S13, - UNW_ARM_S14, - UNW_ARM_S15, - UNW_ARM_S16, - UNW_ARM_S17, - UNW_ARM_S18, - UNW_ARM_S19, - UNW_ARM_S20, - UNW_ARM_S21, - UNW_ARM_S22, - UNW_ARM_S23, - UNW_ARM_S24, - UNW_ARM_S25, - UNW_ARM_S26, - UNW_ARM_S27, - UNW_ARM_S28, - UNW_ARM_S29, - UNW_ARM_S30, - UNW_ARM_S31, - - /* FPA register numberings. */ - UNW_ARM_F0 = 96, - UNW_ARM_F1, - UNW_ARM_F2, - UNW_ARM_F3, - UNW_ARM_F4, - UNW_ARM_F5, - UNW_ARM_F6, - UNW_ARM_F7, - - /* iWMMXt GR register numberings. */ - UNW_ARM_wCGR0 = 104, - UNW_ARM_wCGR1, - UNW_ARM_wCGR2, - UNW_ARM_wCGR3, - UNW_ARM_wCGR4, - UNW_ARM_wCGR5, - UNW_ARM_wCGR6, - UNW_ARM_wCGR7, - - /* iWMMXt register numberings. */ - UNW_ARM_wR0 = 112, - UNW_ARM_wR1, - UNW_ARM_wR2, - UNW_ARM_wR3, - UNW_ARM_wR4, - UNW_ARM_wR5, - UNW_ARM_wR6, - UNW_ARM_wR7, - UNW_ARM_wR8, - UNW_ARM_wR9, - UNW_ARM_wR10, - UNW_ARM_wR11, - UNW_ARM_wR12, - UNW_ARM_wR13, - UNW_ARM_wR14, - UNW_ARM_wR15, - - /* Two-byte encodings from here on. */ - - /* SPSR. */ - UNW_ARM_SPSR = 128, - UNW_ARM_SPSR_FIQ, - UNW_ARM_SPSR_IRQ, - UNW_ARM_SPSR_ABT, - UNW_ARM_SPSR_UND, - UNW_ARM_SPSR_SVC, - - /* User mode registers. */ - UNW_ARM_R8_USR = 144, - UNW_ARM_R9_USR, - UNW_ARM_R10_USR, - UNW_ARM_R11_USR, - UNW_ARM_R12_USR, - UNW_ARM_R13_USR, - UNW_ARM_R14_USR, - - /* FIQ registers. */ - UNW_ARM_R8_FIQ = 151, - UNW_ARM_R9_FIQ, - UNW_ARM_R10_FIQ, - UNW_ARM_R11_FIQ, - UNW_ARM_R12_FIQ, - UNW_ARM_R13_FIQ, - UNW_ARM_R14_FIQ, - - /* IRQ registers. */ - UNW_ARM_R13_IRQ = 158, - UNW_ARM_R14_IRQ, - - /* ABT registers. */ - UNW_ARM_R13_ABT = 160, - UNW_ARM_R14_ABT, - - /* UND registers. */ - UNW_ARM_R13_UND = 162, - UNW_ARM_R14_UND, - - /* SVC registers. */ - UNW_ARM_R13_SVC = 164, - UNW_ARM_R14_SVC, - - /* iWMMXt control registers. */ - UNW_ARM_wC0 = 192, - UNW_ARM_wC1, - UNW_ARM_wC2, - UNW_ARM_wC3, - UNW_ARM_wC4, - UNW_ARM_wC5, - UNW_ARM_wC6, - UNW_ARM_wC7, - - /* VFPv3/Neon 64-bit registers. */ - UNW_ARM_D0 = 256, - UNW_ARM_D1, - UNW_ARM_D2, - UNW_ARM_D3, - UNW_ARM_D4, - UNW_ARM_D5, - UNW_ARM_D6, - UNW_ARM_D7, - UNW_ARM_D8, - UNW_ARM_D9, - UNW_ARM_D10, - UNW_ARM_D11, - UNW_ARM_D12, - UNW_ARM_D13, - UNW_ARM_D14, - UNW_ARM_D15, - UNW_ARM_D16, - UNW_ARM_D17, - UNW_ARM_D18, - UNW_ARM_D19, - UNW_ARM_D20, - UNW_ARM_D21, - UNW_ARM_D22, - UNW_ARM_D23, - UNW_ARM_D24, - UNW_ARM_D25, - UNW_ARM_D26, - UNW_ARM_D27, - UNW_ARM_D28, - UNW_ARM_D29, - UNW_ARM_D30, - UNW_ARM_D31, - - /* For ARM, the CFA is the value of SP (r13) at the call site in the - previous frame. */ - UNW_ARM_CFA, - - UNW_TDEP_LAST_REG = UNW_ARM_D31, - - UNW_TDEP_IP = UNW_ARM_R14, /* A little white lie. */ - UNW_TDEP_SP = UNW_ARM_R13, - UNW_TDEP_EH = UNW_ARM_R0 /* FIXME. */ - } -arm_regnum_t; - -#define UNW_TDEP_NUM_EH_REGS 2 /* FIXME for ARM. */ - -typedef struct unw_tdep_save_loc - { - /* Additional target-dependent info on a save location. */ - } -unw_tdep_save_loc_t; - -/* On ARM, we define our own unw_tdep_context instead of using ucontext_t. - This allows us to support systems that don't support getcontext and - therefore do not define ucontext_t. */ -typedef struct unw_tdep_context - { - unsigned long regs[16]; - } -unw_tdep_context_t; - -/* There is no getcontext() on ARM. Use a stub version which only saves GP - registers. FIXME: Not ideal, may not be sufficient for all libunwind - use cases. Stores pc+8, which is only approximately correct, really. */ -#ifndef __thumb__ -#define unw_tdep_getcontext(uc) (({ \ - unw_tdep_context_t *unw_ctx = (uc); \ - register unsigned long *unw_base __asm__ ("r0") = unw_ctx->regs; \ - __asm__ __volatile__ ( \ - "stmia %[base], {r0-r15}" \ - : : [base] "r" (unw_base) : "memory"); \ - }), 0) -#else /* __thumb__ */ -#define unw_tdep_getcontext(uc) (({ \ - unw_tdep_context_t *unw_ctx = (uc); \ - register unsigned long *unw_base __asm__ ("r0") = unw_ctx->regs; \ - __asm__ __volatile__ ( \ - ".align 2\nbx pc\nnop\n.code 32\n" \ - "stmia %[base], {r0-r15}\n" \ - "orr %[base], pc, #1\nbx %[base]\n" \ - ".code 16\n" \ - : [base] "+r" (unw_base) : : "memory", "cc"); \ - }), 0) -#endif - -#include "libunwind-dynamic.h" - -typedef struct - { - /* no arm-specific auxiliary proc-info */ - } -unw_tdep_proc_info_t; - -#include "libunwind-common.h" - -#define unw_tdep_is_fpreg UNW_ARCH_OBJ(is_fpreg) -extern int unw_tdep_is_fpreg (int); - -#if defined(__cplusplus) || defined(c_plusplus) -} -#endif - -#endif /* LIBUNWIND_H */ diff --git a/src/pal/src/libunwind/include/libunwind-common.h.in b/src/pal/src/libunwind/include/libunwind-common.h.in deleted file mode 100644 index 8d96ddca2..000000000 --- a/src/pal/src/libunwind/include/libunwind-common.h.in +++ /dev/null @@ -1,281 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2001-2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#define UNW_VERSION_MAJOR @PKG_MAJOR@ -#define UNW_VERSION_MINOR @PKG_MINOR@ -#define UNW_VERSION_EXTRA @PKG_EXTRA@ - -#define UNW_VERSION_CODE(maj,min) (((maj) << 16) | (min)) -#define UNW_VERSION UNW_VERSION_CODE(UNW_VERSION_MAJOR, UNW_VERSION_MINOR) - -#define UNW_PASTE2(x,y) x##y -#define UNW_PASTE(x,y) UNW_PASTE2(x,y) -#define UNW_OBJ(fn) UNW_PASTE(UNW_PREFIX, fn) -#define UNW_ARCH_OBJ(fn) UNW_PASTE(UNW_PASTE(UNW_PASTE(_U,UNW_TARGET),_), fn) - -#ifdef UNW_LOCAL_ONLY -# define UNW_PREFIX UNW_PASTE(UNW_PASTE(_UL,UNW_TARGET),_) -#else /* !UNW_LOCAL_ONLY */ -# define UNW_PREFIX UNW_PASTE(UNW_PASTE(_U,UNW_TARGET),_) -#endif /* !UNW_LOCAL_ONLY */ - -/* Error codes. The unwind routines return the *negated* values of - these error codes on error and a non-negative value on success. */ -typedef enum - { - UNW_ESUCCESS = 0, /* no error */ - UNW_EUNSPEC, /* unspecified (general) error */ - UNW_ENOMEM, /* out of memory */ - UNW_EBADREG, /* bad register number */ - UNW_EREADONLYREG, /* attempt to write read-only register */ - UNW_ESTOPUNWIND, /* stop unwinding */ - UNW_EINVALIDIP, /* invalid IP */ - UNW_EBADFRAME, /* bad frame */ - UNW_EINVAL, /* unsupported operation or bad value */ - UNW_EBADVERSION, /* unwind info has unsupported version */ - UNW_ENOINFO /* no unwind info found */ - } -unw_error_t; - -/* The following enum defines the indices for a couple of - (pseudo-)registers which have the same meaning across all - platforms. (RO) means read-only. (RW) means read-write. General - registers (aka "integer registers") are expected to start with - index 0. The number of such registers is architecture-dependent. - The remaining indices can be used as an architecture sees fit. The - last valid register index is given by UNW_REG_LAST. */ -typedef enum - { - UNW_REG_IP = UNW_TDEP_IP, /* (rw) instruction pointer (pc) */ - UNW_REG_SP = UNW_TDEP_SP, /* (ro) stack pointer */ - UNW_REG_EH = UNW_TDEP_EH, /* (rw) exception-handling reg base */ - UNW_REG_LAST = UNW_TDEP_LAST_REG - } -unw_frame_regnum_t; - -/* Number of exception-handler argument registers: */ -#define UNW_NUM_EH_REGS UNW_TDEP_NUM_EH_REGS - -typedef enum - { - UNW_CACHE_NONE, /* no caching */ - UNW_CACHE_GLOBAL, /* shared global cache */ - UNW_CACHE_PER_THREAD /* per-thread caching */ - } -unw_caching_policy_t; - -typedef enum - { - UNW_INIT_SIGNAL_FRAME = 1, /* We know this is a signal frame */ - } -unw_init_local2_flags_t; - -typedef int unw_regnum_t; - -/* The unwind cursor starts at the youngest (most deeply nested) frame - and is used to track the frame state as the unwinder steps from - frame to frame. It is safe to make (shallow) copies of variables - of this type. */ -typedef struct unw_cursor - { - unw_word_t opaque[UNW_TDEP_CURSOR_LEN]; - } -unw_cursor_t; - -/* This type encapsulates the entire (preserved) machine-state. */ -typedef unw_tdep_context_t unw_context_t; - -/* unw_getcontext() fills the unw_context_t pointed to by UC with the - machine state as it exists at the call-site. For implementation - reasons, this needs to be a target-dependent macro. It's easiest - to think of unw_getcontext() as being identical to getcontext(). */ -#define unw_getcontext(uc) unw_tdep_getcontext(uc) - -/* Return 1 if register number R is a floating-point register, zero - otherwise. - This routine is signal-safe. */ -#define unw_is_fpreg(r) unw_tdep_is_fpreg(r) - -typedef unw_tdep_fpreg_t unw_fpreg_t; - -typedef struct unw_addr_space *unw_addr_space_t; - -/* Each target may define it's own set of flags, but bits 0-15 are - reserved for general libunwind-use. */ -#define UNW_PI_FLAG_FIRST_TDEP_BIT 16 -/* The information comes from a .debug_frame section. */ -#define UNW_PI_FLAG_DEBUG_FRAME 32 - -typedef struct unw_proc_info - { - unw_word_t start_ip; /* first IP covered by this procedure */ - unw_word_t end_ip; /* first IP NOT covered by this procedure */ -#if defined(NEED_LAST_IP) - unw_word_t last_ip; /* first IP that could begin another procedure */ -#endif - unw_word_t lsda; /* address of lang.-spec. data area (if any) */ - unw_word_t handler; /* optional personality routine */ - unw_word_t gp; /* global-pointer value for this procedure */ - unw_word_t flags; /* misc. flags */ - - int format; /* unwind-info format (arch-specific) */ - int unwind_info_size; /* size of the information (if applicable) */ - void *unwind_info; /* unwind-info (arch-specific) */ - unw_tdep_proc_info_t extra; /* target-dependent auxiliary proc-info */ - } -unw_proc_info_t; - -typedef int (*unw_reg_states_callback)(void *token, - void *reg_states_data, - size_t reg_states_data_size, - unw_word_t start_ip, unw_word_t end_ip); - -/* These are backend callback routines that provide access to the - state of a "remote" process. This can be used, for example, to - unwind another process through the ptrace() interface. */ -typedef struct unw_accessors - { - /* Look up the unwind info associated with instruction-pointer IP. - On success, the routine fills in the PROC_INFO structure. */ - int (*find_proc_info) (unw_addr_space_t, unw_word_t, unw_proc_info_t *, - int, void *); - - /* Release any resources (e.g., memory) that were allocated for - the unwind info returned in by a previous call to - find_proc_info() with NEED_UNWIND_INFO set to 1. */ - void (*put_unwind_info) (unw_addr_space_t, unw_proc_info_t *, void *); - - /* Return the list-head of the dynamically registered unwind - info. */ - int (*get_dyn_info_list_addr) (unw_addr_space_t, unw_word_t *, void *); - - /* Access aligned word at address ADDR. The value is returned - according to the endianness of the host (e.g., if the host is - little-endian and the target is big-endian, access_mem() needs - to byte-swap the value before returning it). */ - int (*access_mem) (unw_addr_space_t, unw_word_t, unw_word_t *, int, - void *); - - /* Access register number REG at address ADDR. */ - int (*access_reg) (unw_addr_space_t, unw_regnum_t, unw_word_t *, int, - void *); - - /* Access register number REG at address ADDR. */ - int (*access_fpreg) (unw_addr_space_t, unw_regnum_t, - unw_fpreg_t *, int, void *); - - int (*resume) (unw_addr_space_t, unw_cursor_t *, void *); - - /* Optional call back to obtain the name of a (static) procedure. - Dynamically generated procedures are handled automatically by - libunwind. This callback is optional and may be set to - NULL. */ - int (*get_proc_name) (unw_addr_space_t, unw_word_t, char *, size_t, - unw_word_t *, void *); - } -unw_accessors_t; - -typedef enum unw_save_loc_type - { - UNW_SLT_NONE, /* register is not saved ("not an l-value") */ - UNW_SLT_MEMORY, /* register has been saved in memory */ - UNW_SLT_REG /* register has been saved in (another) register */ - } -unw_save_loc_type_t; - -typedef struct unw_save_loc - { - unw_save_loc_type_t type; - union - { - unw_word_t addr; /* valid if type==UNW_SLT_MEMORY */ - unw_regnum_t regnum; /* valid if type==UNW_SLT_REG */ - } - u; - unw_tdep_save_loc_t extra; /* target-dependent additional information */ - } -unw_save_loc_t; - -/* These routines work both for local and remote unwinding. */ - -#define unw_local_addr_space UNW_OBJ(local_addr_space) -#define unw_create_addr_space UNW_OBJ(create_addr_space) -#define unw_destroy_addr_space UNW_OBJ(destroy_addr_space) -#define unw_get_accessors UNW_ARCH_OBJ(get_accessors) -#define unw_get_accessors_int UNW_ARCH_OBJ(get_accessors_int) -#define unw_init_local UNW_OBJ(init_local) -#define unw_init_local2 UNW_OBJ(init_local2) -#define unw_init_remote UNW_OBJ(init_remote) -#define unw_step UNW_OBJ(step) -#define unw_resume UNW_OBJ(resume) -#define unw_get_proc_info UNW_OBJ(get_proc_info) -#define unw_get_proc_info_by_ip UNW_OBJ(get_proc_info_by_ip) -#define unw_reg_states_iterate UNW_OBJ(reg_states_iterate) -#define unw_apply_reg_state UNW_OBJ(apply_reg_state) -#define unw_get_reg UNW_OBJ(get_reg) -#define unw_set_reg UNW_OBJ(set_reg) -#define unw_get_fpreg UNW_OBJ(get_fpreg) -#define unw_set_fpreg UNW_OBJ(set_fpreg) -#define unw_get_save_loc UNW_OBJ(get_save_loc) -#define unw_is_signal_frame UNW_OBJ(is_signal_frame) -#define unw_handle_signal_frame UNW_OBJ(handle_signal_frame) -#define unw_get_proc_name UNW_OBJ(get_proc_name) -#define unw_set_caching_policy UNW_OBJ(set_caching_policy) -#define unw_set_cache_size UNW_OBJ(set_cache_size) -#define unw_regname UNW_ARCH_OBJ(regname) -#define unw_flush_cache UNW_ARCH_OBJ(flush_cache) -#define unw_strerror UNW_ARCH_OBJ(strerror) - -extern unw_addr_space_t unw_create_addr_space (unw_accessors_t *, int); -extern void unw_destroy_addr_space (unw_addr_space_t); -extern unw_accessors_t *unw_get_accessors (unw_addr_space_t); -extern unw_accessors_t *unw_get_accessors_int (unw_addr_space_t); -extern void unw_flush_cache (unw_addr_space_t, unw_word_t, unw_word_t); -extern int unw_set_caching_policy (unw_addr_space_t, unw_caching_policy_t); -extern int unw_set_cache_size (unw_addr_space_t, size_t, int); -extern const char *unw_regname (unw_regnum_t); - -extern int unw_init_local (unw_cursor_t *, unw_context_t *); -extern int unw_init_local2 (unw_cursor_t *, unw_context_t *, int); -extern int unw_init_remote (unw_cursor_t *, unw_addr_space_t, void *); -extern int unw_step (unw_cursor_t *); -extern int unw_resume (unw_cursor_t *); -extern int unw_get_proc_info (unw_cursor_t *, unw_proc_info_t *); -extern int unw_get_proc_info_by_ip (unw_addr_space_t, unw_word_t, - unw_proc_info_t *, void *); -extern int unw_reg_states_iterate (unw_cursor_t *, unw_reg_states_callback, void *); -extern int unw_apply_reg_state (unw_cursor_t *, void *); -extern int unw_get_reg (unw_cursor_t *, int, unw_word_t *); -extern int unw_set_reg (unw_cursor_t *, int, unw_word_t); -extern int unw_get_fpreg (unw_cursor_t *, int, unw_fpreg_t *); -extern int unw_set_fpreg (unw_cursor_t *, int, unw_fpreg_t); -extern int unw_get_save_loc (unw_cursor_t *, int, unw_save_loc_t *); -extern int unw_is_signal_frame (unw_cursor_t *); -extern int unw_handle_signal_frame (unw_cursor_t *); -extern int unw_get_proc_name (unw_cursor_t *, char *, size_t, unw_word_t *); -extern const char *unw_strerror (int); -extern int unw_backtrace (void **, int); - -extern unw_addr_space_t unw_local_addr_space; diff --git a/src/pal/src/libunwind/include/libunwind-coredump.h b/src/pal/src/libunwind/include/libunwind-coredump.h deleted file mode 100644 index 3c7814140..000000000 --- a/src/pal/src/libunwind/include/libunwind-coredump.h +++ /dev/null @@ -1,73 +0,0 @@ -/* libunwind - a platform-independent unwind library - -This file is part of libunwind. - -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. */ - -#ifndef libunwind_coredump_h -#define libunwind_coredump_h - -#include - -#if defined(__cplusplus) || defined(c_plusplus) -extern "C" { -#endif - -/* Helper routines which make it easy to use libunwind on a coredump. - They're available only if UNW_REMOTE_ONLY is _not_ defined and they - aren't really part of the libunwind API. They are implemented in a - archive library called libunwind-coredump.a. */ - -struct UCD_info; - -extern struct UCD_info *_UCD_create(const char *filename); -extern void _UCD_destroy(struct UCD_info *); - -extern int _UCD_get_num_threads(struct UCD_info *); -extern void _UCD_select_thread(struct UCD_info *, int); -extern pid_t _UCD_get_pid(struct UCD_info *); -extern int _UCD_get_cursig(struct UCD_info *); -extern int _UCD_add_backing_file_at_segment(struct UCD_info *, int phdr_no, const char *filename); -extern int _UCD_add_backing_file_at_vaddr(struct UCD_info *, - unsigned long vaddr, - const char *filename); - -extern int _UCD_find_proc_info (unw_addr_space_t, unw_word_t, - unw_proc_info_t *, int, void *); -extern void _UCD_put_unwind_info (unw_addr_space_t, unw_proc_info_t *, void *); -extern int _UCD_get_dyn_info_list_addr (unw_addr_space_t, unw_word_t *, - void *); -extern int _UCD_access_mem (unw_addr_space_t, unw_word_t, unw_word_t *, int, - void *); -extern int _UCD_access_reg (unw_addr_space_t, unw_regnum_t, unw_word_t *, - int, void *); -extern int _UCD_access_fpreg (unw_addr_space_t, unw_regnum_t, unw_fpreg_t *, - int, void *); -extern int _UCD_get_proc_name (unw_addr_space_t, unw_word_t, char *, size_t, - unw_word_t *, void *); -extern int _UCD_resume (unw_addr_space_t, unw_cursor_t *, void *); -extern unw_accessors_t _UCD_accessors; - - -#if defined(__cplusplus) || defined(c_plusplus) -} -#endif - -#endif /* libunwind_coredump_h */ diff --git a/src/pal/src/libunwind/include/libunwind-dynamic.h b/src/pal/src/libunwind/include/libunwind-dynamic.h deleted file mode 100644 index edb0bbd34..000000000 --- a/src/pal/src/libunwind/include/libunwind-dynamic.h +++ /dev/null @@ -1,214 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2002-2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -/* This file defines the runtime-support routines for dynamically -generated code. Even though it is implemented as part of libunwind, -it is logically separate from the interface to perform the actual -unwinding. In particular, this interface is always used in the -context of the unwind target, whereas the rest of the unwind API is -used in context of the process that is doing the unwind (which may be -a debugger running on another machine, for example). - -Note that the data-structures declared here server a dual purpose: -when a program registers a dynamically generated procedure, it uses -these structures directly. On the other hand, with remote-unwinding, -the data-structures are read from the remote process's memory and -translated into internalized versions. To facilitate remote-access, -the following rules should be followed in declaring these structures: - - (1) Declare a member as a pointer only if the the information the - member points to needs to be internalized as well (e.g., a - string representing a procedure name should be declared as - "const char *", but the instruction pointer should be declared - as unw_word_t). - - (2) Provide sufficient padding to ensure that no implicit padding - will be needed on any of the supported target architectures. For - the time being, padding data structures with the assumption that - sizeof (unw_word_t) == 8 should be sufficient. (Note: it's not - impossible to internalize structures with internal padding, but - it does make the process a bit harder). - - (3) Don't declare members that contain bitfields or floating-point - values. - - (4) Don't declare members with enumeration types. Declare them as - int32_t instead. */ - -typedef enum - { - UNW_DYN_STOP = 0, /* end-of-unwind-info marker */ - UNW_DYN_SAVE_REG, /* save register to another register */ - UNW_DYN_SPILL_FP_REL, /* frame-pointer-relative register spill */ - UNW_DYN_SPILL_SP_REL, /* stack-pointer-relative register spill */ - UNW_DYN_ADD, /* add constant value to a register */ - UNW_DYN_POP_FRAMES, /* drop one or more stack frames */ - UNW_DYN_LABEL_STATE, /* name the current state */ - UNW_DYN_COPY_STATE, /* set the region's entry-state */ - UNW_DYN_ALIAS /* get unwind info from an alias */ - } -unw_dyn_operation_t; - -typedef enum - { - UNW_INFO_FORMAT_DYNAMIC, /* unw_dyn_proc_info_t */ - UNW_INFO_FORMAT_TABLE, /* unw_dyn_table_t */ - UNW_INFO_FORMAT_REMOTE_TABLE, /* unw_dyn_remote_table_t */ - UNW_INFO_FORMAT_ARM_EXIDX, /* ARM specific unwind info */ - UNW_INFO_FORMAT_IP_OFFSET, /* Like UNW_INFO_FORMAT_REMOTE_TABLE, but - table entries are considered - relative to di->start_ip, rather - than di->segbase */ - } -unw_dyn_info_format_t; - -typedef struct unw_dyn_op - { - int8_t tag; /* what operation? */ - int8_t qp; /* qualifying predicate register */ - int16_t reg; /* what register */ - int32_t when; /* when does it take effect? */ - unw_word_t val; /* auxiliary value */ - } -unw_dyn_op_t; - -typedef struct unw_dyn_region_info - { - struct unw_dyn_region_info *next; /* linked list of regions */ - int32_t insn_count; /* region length (# of instructions) */ - uint32_t op_count; /* length of op-array */ - unw_dyn_op_t op[1]; /* variable-length op-array */ - } -unw_dyn_region_info_t; - -typedef struct unw_dyn_proc_info - { - unw_word_t name_ptr; /* address of human-readable procedure name */ - unw_word_t handler; /* address of personality routine */ - uint32_t flags; - int32_t pad0; - unw_dyn_region_info_t *regions; - } -unw_dyn_proc_info_t; - -typedef struct unw_dyn_table_info - { - unw_word_t name_ptr; /* addr. of table name (e.g., library name) */ - unw_word_t segbase; /* segment base */ - unw_word_t table_len; /* must be a multiple of sizeof(unw_word_t)! */ - unw_word_t *table_data; - } -unw_dyn_table_info_t; - -typedef struct unw_dyn_remote_table_info - { - unw_word_t name_ptr; /* addr. of table name (e.g., library name) */ - unw_word_t segbase; /* segment base */ - unw_word_t table_len; /* must be a multiple of sizeof(unw_word_t)! */ - unw_word_t table_data; - } -unw_dyn_remote_table_info_t; - -typedef struct unw_dyn_info - { - /* doubly-linked list of dyn-info structures: */ - struct unw_dyn_info *next; - struct unw_dyn_info *prev; - unw_word_t start_ip; /* first IP covered by this entry */ - unw_word_t end_ip; /* first IP NOT covered by this entry */ - unw_word_t gp; /* global-pointer in effect for this entry */ - int32_t format; /* real type: unw_dyn_info_format_t */ - int32_t pad; - union - { - unw_dyn_proc_info_t pi; - unw_dyn_table_info_t ti; - unw_dyn_remote_table_info_t rti; - } - u; - } -unw_dyn_info_t; - -typedef struct unw_dyn_info_list - { - uint32_t version; - uint32_t generation; - unw_dyn_info_t *first; - } -unw_dyn_info_list_t; - -/* Return the size (in bytes) of an unw_dyn_region_info_t structure that can - hold OP_COUNT ops. */ -#define _U_dyn_region_info_size(op_count) \ - ((char *) (((unw_dyn_region_info_t *) NULL)->op + (op_count)) \ - - (char *) NULL) - -/* Register the unwind info for a single procedure. - This routine is NOT signal-safe. */ -extern void _U_dyn_register (unw_dyn_info_t *); - -/* Cancel the unwind info for a single procedure. - This routine is NOT signal-safe. */ -extern void _U_dyn_cancel (unw_dyn_info_t *); - - -/* Convenience routines. */ - -#define _U_dyn_op(_tag, _qp, _when, _reg, _val) \ - ((unw_dyn_op_t) { (_tag), (_qp), (_reg), (_when), (_val) }) - -#define _U_dyn_op_save_reg(op, qp, when, reg, dst) \ - (*(op) = _U_dyn_op (UNW_DYN_SAVE_REG, (qp), (when), (reg), (dst))) - -#define _U_dyn_op_spill_fp_rel(op, qp, when, reg, offset) \ - (*(op) = _U_dyn_op (UNW_DYN_SPILL_FP_REL, (qp), (when), (reg), \ - (offset))) - -#define _U_dyn_op_spill_sp_rel(op, qp, when, reg, offset) \ - (*(op) = _U_dyn_op (UNW_DYN_SPILL_SP_REL, (qp), (when), (reg), \ - (offset))) - -#define _U_dyn_op_add(op, qp, when, reg, value) \ - (*(op) = _U_dyn_op (UNW_DYN_ADD, (qp), (when), (reg), (value))) - -#define _U_dyn_op_pop_frames(op, qp, when, num_frames) \ - (*(op) = _U_dyn_op (UNW_DYN_POP_FRAMES, (qp), (when), 0, (num_frames))) - -#define _U_dyn_op_label_state(op, label) \ - (*(op) = _U_dyn_op (UNW_DYN_LABEL_STATE, _U_QP_TRUE, -1, 0, (label))) - -#define _U_dyn_op_copy_state(op, label) \ - (*(op) = _U_dyn_op (UNW_DYN_COPY_STATE, _U_QP_TRUE, -1, 0, (label))) - -#define _U_dyn_op_alias(op, qp, when, addr) \ - (*(op) = _U_dyn_op (UNW_DYN_ALIAS, (qp), (when), 0, (addr))) - -#define _U_dyn_op_stop(op) \ - (*(op) = _U_dyn_op (UNW_DYN_STOP, _U_QP_TRUE, -1, 0, 0)) - -/* The target-dependent qualifying predicate which is always TRUE. On - IA-64, that's p0 (0), on non-predicated architectures, the value is - ignored. */ -#define _U_QP_TRUE _U_TDEP_QP_TRUE diff --git a/src/pal/src/libunwind/include/libunwind-hppa.h b/src/pal/src/libunwind/include/libunwind-hppa.h deleted file mode 100644 index 7013aa772..000000000 --- a/src/pal/src/libunwind/include/libunwind-hppa.h +++ /dev/null @@ -1,125 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2003-2004 Hewlett-Packard Co - -This file is part of libunwind. - -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. */ - -#ifndef LIBUNWIND_H -#define LIBUNWIND_H - -#if defined(__cplusplus) || defined(c_plusplus) -extern "C" { -#endif - -#include -#include - -#define UNW_TARGET hppa -#define UNW_TARGET_HPPA 1 - -#define _U_TDEP_QP_TRUE 0 /* see libunwind-dynamic.h */ - -/* This needs to be big enough to accommodate "struct cursor", while - leaving some slack for future expansion. Changing this value will - require recompiling all users of this library. Stack allocation is - relatively cheap and unwind-state copying is relatively rare, so we - want to err on making it rather too big than too small. */ -#define UNW_TDEP_CURSOR_LEN 511 - -typedef uint32_t unw_word_t; -typedef int32_t unw_sword_t; - -typedef union - { - struct { unw_word_t bits[2]; } raw; - double val; - } -unw_tdep_fpreg_t; - -typedef enum - { - /* Note: general registers are expected to start with index 0. - This convention facilitates architecture-independent - implementation of the C++ exception handling ABI. See - _Unwind_SetGR() and _Unwind_GetGR() for details. */ - UNW_HPPA_GR = 0, - UNW_HPPA_RP = 2, /* return pointer */ - UNW_HPPA_FP = 3, /* frame pointer */ - UNW_HPPA_SP = UNW_HPPA_GR + 30, - - UNW_HPPA_FR = UNW_HPPA_GR + 32, - - UNW_HPPA_IP = UNW_HPPA_FR + 32, /* instruction pointer */ - - /* other "preserved" registers (fpsr etc.)... */ - - /* PA-RISC has 4 exception-argument registers but they're not - contiguous. To deal with this, we define 4 pseudo - exception-handling registers which we then alias to the actual - physical register. */ - - UNW_HPPA_EH0 = UNW_HPPA_IP + 1, /* alias for UNW_HPPA_GR + 20 */ - UNW_HPPA_EH1 = UNW_HPPA_EH0 + 1, /* alias for UNW_HPPA_GR + 21 */ - UNW_HPPA_EH2 = UNW_HPPA_EH1 + 1, /* alias for UNW_HPPA_GR + 22 */ - UNW_HPPA_EH3 = UNW_HPPA_EH2 + 1, /* alias for UNW_HPPA_GR + 31 */ - - /* frame info (read-only) */ - UNW_HPPA_CFA, - - UNW_TDEP_LAST_REG = UNW_HPPA_IP, - - UNW_TDEP_IP = UNW_HPPA_IP, - UNW_TDEP_SP = UNW_HPPA_SP, - UNW_TDEP_EH = UNW_HPPA_EH0 - } -hppa_regnum_t; - -#define UNW_TDEP_NUM_EH_REGS 4 - -typedef struct unw_tdep_save_loc - { - /* Additional target-dependent info on a save location. */ - } -unw_tdep_save_loc_t; - -/* On PA-RISC, we can directly use ucontext_t as the unwind context. */ -typedef ucontext_t unw_tdep_context_t; - -#define unw_tdep_is_fpreg(r) ((unsigned) ((r) - UNW_HPPA_FR) < 32) - -#include "libunwind-dynamic.h" - -typedef struct - { - /* no PA-RISC-specific auxiliary proc-info */ - } -unw_tdep_proc_info_t; - -#include "libunwind-common.h" - -#define unw_tdep_getcontext UNW_ARCH_OBJ (getcontext) -extern int unw_tdep_getcontext (unw_tdep_context_t *); - -#if defined(__cplusplus) || defined(c_plusplus) -} -#endif - -#endif /* LIBUNWIND_H */ diff --git a/src/pal/src/libunwind/include/libunwind-ia64.h b/src/pal/src/libunwind/include/libunwind-ia64.h deleted file mode 100644 index 0cc4f39ea..000000000 --- a/src/pal/src/libunwind/include/libunwind-ia64.h +++ /dev/null @@ -1,194 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2001-2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#ifndef LIBUNWIND_H -#define LIBUNWIND_H - -#include -#include - -#if defined(__cplusplus) || defined(c_plusplus) -extern "C" { -#endif - -#ifdef ia64 - /* This works around a bug in Intel's ECC v7.0 which defines "ia64" - as "1". */ -# undef ia64 -#endif - -#ifdef __hpux - /* On HP-UX, there is no hope of supporting UNW_LOCAL_ONLY, because - it's impossible to obtain the address of the members in the - sigcontext structure. */ -# undef UNW_LOCAL_ONLY -# define UNW_GENERIC_ONLY -#endif - -#define UNW_TARGET ia64 -#define UNW_TARGET_IA64 1 - -#define _U_TDEP_QP_TRUE 0 /* see libunwind-dynamic.h */ - -/* This needs to be big enough to accommodate "struct cursor", while - leaving some slack for future expansion. Changing this value will - require recompiling all users of this library. Stack allocation is - relatively cheap and unwind-state copying is relatively rare, so we - want to err on making it rather too big than too small. */ -#define UNW_TDEP_CURSOR_LEN 511 - -/* If this bit is it indicates that the procedure saved all of ar.bsp, - ar.bspstore, and ar.rnat. If, additionally, ar.bsp != saved ar.bsp, - then this procedure has performed a register-backing-store switch. */ -#define UNW_PI_FLAG_IA64_RBS_SWITCH_BIT (UNW_PI_FLAG_FIRST_TDEP_BIT + 0) - -#define UNW_PI_FLAG_IA64_RBS_SWITCH (1 << UNW_PI_FLAG_IA64_RBS_SWITCH_BIT) - -typedef uint64_t unw_word_t; -typedef int64_t unw_sword_t; - -/* On IA-64, we want to access the contents of floating-point - registers as a pair of "words", but to ensure 16-byte alignment, we - make it a union that contains a "long double". This will do the - Right Thing on all known IA-64 platforms, including HP-UX. */ -typedef union - { - struct { unw_word_t bits[2]; } raw; - long double dummy; /* dummy to force 16-byte alignment */ - } -unw_tdep_fpreg_t; - -typedef struct - { - /* no ia64-specific auxiliary proc-info */ - } -unw_tdep_proc_info_t; - -typedef enum - { - /* Note: general registers are excepted to start with index 0. - This convention facilitates architecture-independent - implementation of the C++ exception handling ABI. See - _Unwind_SetGR() and _Unwind_GetGR() for details. */ - UNW_IA64_GR = 0, /* general registers (r0..r127) */ - UNW_IA64_GP = UNW_IA64_GR + 1, - UNW_IA64_TP = UNW_IA64_GR + 13, - - UNW_IA64_NAT = UNW_IA64_GR + 128, /* NaT registers (nat0..nat127) */ - - UNW_IA64_FR = UNW_IA64_NAT + 128, /* fp registers (f0..f127) */ - - UNW_IA64_AR = UNW_IA64_FR + 128, /* application registers (ar0..r127) */ - UNW_IA64_AR_RSC = UNW_IA64_AR + 16, - UNW_IA64_AR_BSP = UNW_IA64_AR + 17, - UNW_IA64_AR_BSPSTORE = UNW_IA64_AR + 18, - UNW_IA64_AR_RNAT = UNW_IA64_AR + 19, - UNW_IA64_AR_CSD = UNW_IA64_AR + 25, - UNW_IA64_AR_26 = UNW_IA64_AR + 26, - UNW_IA64_AR_SSD = UNW_IA64_AR_26, - UNW_IA64_AR_CCV = UNW_IA64_AR + 32, - UNW_IA64_AR_UNAT = UNW_IA64_AR + 36, - UNW_IA64_AR_FPSR = UNW_IA64_AR + 40, - UNW_IA64_AR_PFS = UNW_IA64_AR + 64, - UNW_IA64_AR_LC = UNW_IA64_AR + 65, - UNW_IA64_AR_EC = UNW_IA64_AR + 66, - - UNW_IA64_BR = UNW_IA64_AR + 128, /* branch registers (b0..p7) */ - UNW_IA64_RP = UNW_IA64_BR + 0, /* return pointer (rp) */ - UNW_IA64_PR = UNW_IA64_BR + 8, /* predicate registers (p0..p63) */ - UNW_IA64_CFM, - - /* frame info: */ - UNW_IA64_BSP, - UNW_IA64_IP, - UNW_IA64_SP, - - UNW_TDEP_LAST_REG = UNW_IA64_SP, - - UNW_TDEP_IP = UNW_IA64_IP, - UNW_TDEP_SP = UNW_IA64_SP, - UNW_TDEP_EH = UNW_IA64_GR + 15 - } -ia64_regnum_t; - -#define UNW_TDEP_NUM_EH_REGS 4 /* r15-r18 are exception args */ - -typedef struct unw_tdep_save_loc - { - /* Additional target-dependent info on a save location. On IA-64, - we use this to provide the bit number in which a NaT bit gets - saved. */ - uint8_t nat_bitnr; - - /* Padding reserved for future use. */ - uint8_t reserved[7]; - } -unw_tdep_save_loc_t; - -/* On IA-64, we can directly use ucontext_t as the unwind context. */ -typedef ucontext_t unw_tdep_context_t; - -#define unw_tdep_is_fpreg(r) ((unsigned) ((r) - UNW_IA64_FR) < 128) - -#include "libunwind-dynamic.h" -#include "libunwind-common.h" - -#ifdef __hpux - /* In theory, we could use _Uia64_getcontext() on HP-UX as well, but - the benefit of doing so would be marginal given that it can't - support UNW_LOCAL_ONLY. */ -# define unw_tdep_getcontext getcontext -#else -# define unw_tdep_getcontext UNW_ARCH_OBJ (getcontext) - extern int unw_tdep_getcontext (unw_tdep_context_t *); -#endif - -/* This is a helper routine to search an ia64 unwind table. If the - address-space argument AS points to something other than the local - address-space, the memory for the unwind-info will be allocated - with malloc(), and should be free()d during the put_unwind_info() - callback. This routine is signal-safe for the local-address-space - case ONLY. */ -#define unw_search_ia64_unwind_table UNW_OBJ(search_unwind_table) -extern int unw_search_ia64_unwind_table (unw_addr_space_t, unw_word_t, - unw_dyn_info_t *, unw_proc_info_t *, - int, void *); - -/* This is a helper routine which the get_dyn_info_list_addr() - callback can use to locate the special dynamic-info list entry in - an IA-64 unwind table. If the entry exists in the table, the - list-address is returned. In all other cases, 0 is returned. */ -extern unw_word_t _Uia64_find_dyn_list (unw_addr_space_t, unw_dyn_info_t *, - void *); - -/* This is a helper routine to obtain the kernel-unwind info. It is - signal-safe. */ -extern int _Uia64_get_kernel_table (unw_dyn_info_t *); - -#if defined(__cplusplus) || defined(c_plusplus) -} -#endif - -#endif /* LIBUNWIND_H */ diff --git a/src/pal/src/libunwind/include/libunwind-mips.h b/src/pal/src/libunwind/include/libunwind-mips.h deleted file mode 100644 index 97c95e246..000000000 --- a/src/pal/src/libunwind/include/libunwind-mips.h +++ /dev/null @@ -1,160 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - -This file is part of libunwind. - -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. */ - -#ifndef LIBUNWIND_H -#define LIBUNWIND_H - -#if defined(__cplusplus) || defined(c_plusplus) -extern "C" { -#endif - -#include -#include - -#ifdef mips -# undef mips -#endif - -#define UNW_TARGET mips -#define UNW_TARGET_MIPS 1 - -#define _U_TDEP_QP_TRUE 0 /* see libunwind-dynamic.h */ - -/* This needs to be big enough to accommodate "struct cursor", while - leaving some slack for future expansion. Changing this value will - require recompiling all users of this library. Stack allocation is - relatively cheap and unwind-state copying is relatively rare, so we - want to err on making it rather too big than too small. */ - -/* FIXME for MIPS. Too big? What do other things use for similar tasks? */ -#define UNW_TDEP_CURSOR_LEN 4096 - -/* The size of a "word" varies on MIPS. This type is used for memory - addresses and register values, which are 32-bit wide for O32 and N32 - ABIs, and 64-bit wide for N64 ABI. */ -#if _MIPS_SIM == _ABI64 -typedef uint64_t unw_word_t; -#else -typedef uint32_t unw_word_t; -#endif -typedef int32_t unw_sword_t; - -/* FIXME: MIPS ABIs. */ -typedef long double unw_tdep_fpreg_t; - -typedef enum - { - UNW_MIPS_R0, - UNW_MIPS_R1, - UNW_MIPS_R2, - UNW_MIPS_R3, - UNW_MIPS_R4, - UNW_MIPS_R5, - UNW_MIPS_R6, - UNW_MIPS_R7, - UNW_MIPS_R8, - UNW_MIPS_R9, - UNW_MIPS_R10, - UNW_MIPS_R11, - UNW_MIPS_R12, - UNW_MIPS_R13, - UNW_MIPS_R14, - UNW_MIPS_R15, - UNW_MIPS_R16, - UNW_MIPS_R17, - UNW_MIPS_R18, - UNW_MIPS_R19, - UNW_MIPS_R20, - UNW_MIPS_R21, - UNW_MIPS_R22, - UNW_MIPS_R23, - UNW_MIPS_R24, - UNW_MIPS_R25, - UNW_MIPS_R26, - UNW_MIPS_R27, - UNW_MIPS_R28, - UNW_MIPS_R29, - UNW_MIPS_R30, - UNW_MIPS_R31, - - UNW_MIPS_PC = 34, - - /* FIXME: Other registers! */ - - /* For MIPS, the CFA is the value of SP (r29) at the call site in the - previous frame. */ - UNW_MIPS_CFA, - - UNW_TDEP_LAST_REG = UNW_MIPS_PC, - - UNW_TDEP_IP = UNW_MIPS_R31, - UNW_TDEP_SP = UNW_MIPS_R29, - UNW_TDEP_EH = UNW_MIPS_R0 /* FIXME. */ - } -mips_regnum_t; - -typedef enum - { - UNW_MIPS_ABI_O32, - UNW_MIPS_ABI_N32, - UNW_MIPS_ABI_N64 - } -mips_abi_t; - -#define UNW_TDEP_NUM_EH_REGS 2 /* FIXME for MIPS. */ - -typedef struct unw_tdep_save_loc - { - /* Additional target-dependent info on a save location. */ - } -unw_tdep_save_loc_t; - -/* On x86, we can directly use ucontext_t as the unwind context. FIXME for - MIPS. */ -typedef ucontext_t unw_tdep_context_t; - -#include "libunwind-dynamic.h" - -typedef struct - { - /* no mips-specific auxiliary proc-info */ - } -unw_tdep_proc_info_t; - -#include "libunwind-common.h" - -/* There is no getcontext() on MIPS. Use a stub version which only saves GP - registers. FIXME: Not ideal, may not be sufficient for all libunwind - use cases. */ -#define unw_tdep_getcontext UNW_ARCH_OBJ(getcontext) -extern int unw_tdep_getcontext (ucontext_t *uc); - -#define unw_tdep_is_fpreg UNW_ARCH_OBJ(is_fpreg) -extern int unw_tdep_is_fpreg (int); - -#if defined(__cplusplus) || defined(c_plusplus) -} -#endif - -#endif /* LIBUNWIND_H */ diff --git a/src/pal/src/libunwind/include/libunwind-ppc32.h b/src/pal/src/libunwind/include/libunwind-ppc32.h deleted file mode 100644 index 47ebfde5a..000000000 --- a/src/pal/src/libunwind/include/libunwind-ppc32.h +++ /dev/null @@ -1,207 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2006-2007 IBM - Contributed by - Corey Ashford - Jose Flavio Aguilar Paulino - - Copied from libunwind-x86_64.h, modified slightly for building - frysk successfully on ppc64, by Wu Zhou - Will be replaced when libunwind is ready on ppc64 platform. - -This file is part of libunwind. - -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. */ - -#ifndef LIBUNWIND_H -#define LIBUNWIND_H - -#if defined(__cplusplus) || defined(c_plusplus) -extern "C" { -#endif - -#include -#include - -#define UNW_TARGET ppc32 -#define UNW_TARGET_PPC32 1 - -#define _U_TDEP_QP_TRUE 0 /* see libunwind-dynamic.h */ - -/* - * This needs to be big enough to accommodate "struct cursor", while - * leaving some slack for future expansion. Changing this value will - * require recompiling all users of this library. Stack allocation is - * relatively cheap and unwind-state copying is relatively rare, so we want - * to err on making it rather too big than too small. - * - * To simplify this whole process, we are at least initially taking the - * tack that UNW_PPC32_* map straight across to the .eh_frame column register - * numbers. These register numbers come from gcc's source in - * gcc/config/rs6000/rs6000.h - * - * UNW_TDEP_CURSOR_LEN is in terms of unw_word_t size. Since we have 115 - * elements in the loc array, each sized 2 * unw_word_t, plus the rest of - * the cursor struct, this puts us at about 2 * 115 + 40 = 270. Let's - * round that up to 280. - */ - -#define UNW_TDEP_CURSOR_LEN 280 - -#if __WORDSIZE==32 -typedef uint32_t unw_word_t; -typedef int32_t unw_sword_t; -#else -typedef uint64_t unw_word_t; -typedef int64_t unw_sword_t; -#endif - -typedef long double unw_tdep_fpreg_t; - -typedef enum - { - UNW_PPC32_R0, - UNW_PPC32_R1, /* called STACK_POINTER in gcc */ - UNW_PPC32_R2, - UNW_PPC32_R3, - UNW_PPC32_R4, - UNW_PPC32_R5, - UNW_PPC32_R6, - UNW_PPC32_R7, - UNW_PPC32_R8, - UNW_PPC32_R9, - UNW_PPC32_R10, - UNW_PPC32_R11, /* called STATIC_CHAIN in gcc */ - UNW_PPC32_R12, - UNW_PPC32_R13, - UNW_PPC32_R14, - UNW_PPC32_R15, - UNW_PPC32_R16, - UNW_PPC32_R17, - UNW_PPC32_R18, - UNW_PPC32_R19, - UNW_PPC32_R20, - UNW_PPC32_R21, - UNW_PPC32_R22, - UNW_PPC32_R23, - UNW_PPC32_R24, - UNW_PPC32_R25, - UNW_PPC32_R26, - UNW_PPC32_R27, - UNW_PPC32_R28, - UNW_PPC32_R29, - UNW_PPC32_R30, - UNW_PPC32_R31, /* called HARD_FRAME_POINTER in gcc */ - - /* Count Register */ - UNW_PPC32_CTR = 32, - /* Fixed-Point Status and Control Register */ - UNW_PPC32_XER = 33, - /* Condition Register */ - UNW_PPC32_CCR = 34, - /* Machine State Register */ - //UNW_PPC32_MSR = 35, - /* MQ or SPR0, not part of generic Power, part of MPC601 */ - //UNW_PPC32_MQ = 36, - /* Link Register */ - UNW_PPC32_LR = 36, - /* Floating Pointer Status and Control Register */ - UNW_PPC32_FPSCR = 37, - - UNW_PPC32_F0 = 48, - UNW_PPC32_F1, - UNW_PPC32_F2, - UNW_PPC32_F3, - UNW_PPC32_F4, - UNW_PPC32_F5, - UNW_PPC32_F6, - UNW_PPC32_F7, - UNW_PPC32_F8, - UNW_PPC32_F9, - UNW_PPC32_F10, - UNW_PPC32_F11, - UNW_PPC32_F12, - UNW_PPC32_F13, - UNW_PPC32_F14, - UNW_PPC32_F15, - UNW_PPC32_F16, - UNW_PPC32_F17, - UNW_PPC32_F18, - UNW_PPC32_F19, - UNW_PPC32_F20, - UNW_PPC32_F21, - UNW_PPC32_F22, - UNW_PPC32_F23, - UNW_PPC32_F24, - UNW_PPC32_F25, - UNW_PPC32_F26, - UNW_PPC32_F27, - UNW_PPC32_F28, - UNW_PPC32_F29, - UNW_PPC32_F30, - UNW_PPC32_F31, - - UNW_TDEP_LAST_REG = UNW_PPC32_F31, - - UNW_TDEP_IP = UNW_PPC32_LR, - UNW_TDEP_SP = UNW_PPC32_R1, - UNW_TDEP_EH = UNW_PPC32_R12 - } -ppc32_regnum_t; - -/* - * According to David Edelsohn, GNU gcc uses R3, R4, R5, and maybe R6 for - * passing parameters to exception handlers. - */ - -#define UNW_TDEP_NUM_EH_REGS 4 - -typedef struct unw_tdep_save_loc - { - /* Additional target-dependent info on a save location. */ - } -unw_tdep_save_loc_t; - -/* On ppc, we can directly use ucontext_t as the unwind context. */ -typedef ucontext_t unw_tdep_context_t; - -/* XXX this is not ideal: an application should not be prevented from - using the "getcontext" name just because it's using libunwind. We - can't just use __getcontext() either, because that isn't exported - by glibc... */ -#define unw_tdep_getcontext(uc) (getcontext (uc), 0) - -#include "libunwind-dynamic.h" - -typedef struct - { - /* no ppc32-specific auxiliary proc-info */ - } -unw_tdep_proc_info_t; - -#include "libunwind-common.h" - -#define unw_tdep_is_fpreg UNW_ARCH_OBJ(is_fpreg) -extern int unw_tdep_is_fpreg (int); - -#if defined(__cplusplus) || defined(c_plusplus) -} -#endif - -#endif /* LIBUNWIND_H */ diff --git a/src/pal/src/libunwind/include/libunwind-ppc64.h b/src/pal/src/libunwind/include/libunwind-ppc64.h deleted file mode 100644 index 9944628da..000000000 --- a/src/pal/src/libunwind/include/libunwind-ppc64.h +++ /dev/null @@ -1,271 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2006-2007 IBM - Contributed by - Corey Ashford - Jose Flavio Aguilar Paulino - - Copied from libunwind-x86_64.h, modified slightly for building - frysk successfully on ppc64, by Wu Zhou - Will be replaced when libunwind is ready on ppc64 platform. - -This file is part of libunwind. - -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. */ - -#ifndef LIBUNWIND_H -#define LIBUNWIND_H - -#if defined(__cplusplus) || defined(c_plusplus) -extern "C" { -#endif - -#include -#include - -#define UNW_TARGET ppc64 -#define UNW_TARGET_PPC64 1 - -#define _U_TDEP_QP_TRUE 0 /* see libunwind-dynamic.h */ - -/* - * This needs to be big enough to accommodate "struct cursor", while - * leaving some slack for future expansion. Changing this value will - * require recompiling all users of this library. Stack allocation is - * relatively cheap and unwind-state copying is relatively rare, so we want - * to err on making it rather too big than too small. - * - * To simplify this whole process, we are at least initially taking the - * tack that UNW_PPC64_* map straight across to the .eh_frame column register - * numbers. These register numbers come from gcc's source in - * gcc/config/rs6000/rs6000.h - * - * UNW_TDEP_CURSOR_LEN is in terms of unw_word_t size. Since we have 115 - * elements in the loc array, each sized 2 * unw_word_t, plus the rest of - * the cursor struct, this puts us at about 2 * 115 + 40 = 270. Let's - * round that up to 280. - */ - -#define UNW_TDEP_CURSOR_LEN 280 - -#if __WORDSIZE==32 -typedef uint32_t unw_word_t; -typedef int32_t unw_sword_t; -#else -typedef uint64_t unw_word_t; -typedef int64_t unw_sword_t; -#endif - -typedef long double unw_tdep_fpreg_t; - -/* - * Vector register (in PowerPC64 used for AltiVec registers) - */ -typedef struct { - uint64_t halves[2]; -} unw_tdep_vreg_t; - -typedef enum - { - UNW_PPC64_R0, - UNW_PPC64_R1, /* called STACK_POINTER in gcc */ - UNW_PPC64_R2, - UNW_PPC64_R3, - UNW_PPC64_R4, - UNW_PPC64_R5, - UNW_PPC64_R6, - UNW_PPC64_R7, - UNW_PPC64_R8, - UNW_PPC64_R9, - UNW_PPC64_R10, - UNW_PPC64_R11, /* called STATIC_CHAIN in gcc */ - UNW_PPC64_R12, - UNW_PPC64_R13, - UNW_PPC64_R14, - UNW_PPC64_R15, - UNW_PPC64_R16, - UNW_PPC64_R17, - UNW_PPC64_R18, - UNW_PPC64_R19, - UNW_PPC64_R20, - UNW_PPC64_R21, - UNW_PPC64_R22, - UNW_PPC64_R23, - UNW_PPC64_R24, - UNW_PPC64_R25, - UNW_PPC64_R26, - UNW_PPC64_R27, - UNW_PPC64_R28, - UNW_PPC64_R29, - UNW_PPC64_R30, - UNW_PPC64_R31, /* called HARD_FRAME_POINTER in gcc */ - - UNW_PPC64_F0 = 32, - UNW_PPC64_F1, - UNW_PPC64_F2, - UNW_PPC64_F3, - UNW_PPC64_F4, - UNW_PPC64_F5, - UNW_PPC64_F6, - UNW_PPC64_F7, - UNW_PPC64_F8, - UNW_PPC64_F9, - UNW_PPC64_F10, - UNW_PPC64_F11, - UNW_PPC64_F12, - UNW_PPC64_F13, - UNW_PPC64_F14, - UNW_PPC64_F15, - UNW_PPC64_F16, - UNW_PPC64_F17, - UNW_PPC64_F18, - UNW_PPC64_F19, - UNW_PPC64_F20, - UNW_PPC64_F21, - UNW_PPC64_F22, - UNW_PPC64_F23, - UNW_PPC64_F24, - UNW_PPC64_F25, - UNW_PPC64_F26, - UNW_PPC64_F27, - UNW_PPC64_F28, - UNW_PPC64_F29, - UNW_PPC64_F30, - UNW_PPC64_F31, - /* Note that there doesn't appear to be an .eh_frame register column - for the FPSCR register. I don't know why this is. Since .eh_frame - info is what this implementation uses for unwinding, we have no way - to unwind this register, and so we will not expose an FPSCR register - number in the libunwind API. - */ - - UNW_PPC64_LR = 65, - UNW_PPC64_CTR = 66, - UNW_PPC64_ARG_POINTER = 67, - - UNW_PPC64_CR0 = 68, - UNW_PPC64_CR1, - UNW_PPC64_CR2, - UNW_PPC64_CR3, - UNW_PPC64_CR4, - /* CR5 .. CR7 are currently unused */ - UNW_PPC64_CR5, - UNW_PPC64_CR6, - UNW_PPC64_CR7, - - UNW_PPC64_XER = 76, - - UNW_PPC64_V0 = 77, - UNW_PPC64_V1, - UNW_PPC64_V2, - UNW_PPC64_V3, - UNW_PPC64_V4, - UNW_PPC64_V5, - UNW_PPC64_V6, - UNW_PPC64_V7, - UNW_PPC64_V8, - UNW_PPC64_V9, - UNW_PPC64_V10, - UNW_PPC64_V11, - UNW_PPC64_V12, - UNW_PPC64_V13, - UNW_PPC64_V14, - UNW_PPC64_V15, - UNW_PPC64_V16, - UNW_PPC64_V17, - UNW_PPC64_V18, - UNW_PPC64_V19, - UNW_PPC64_V20, - UNW_PPC64_V21, - UNW_PPC64_V22, - UNW_PPC64_V23, - UNW_PPC64_V24, - UNW_PPC64_V25, - UNW_PPC64_V26, - UNW_PPC64_V27, - UNW_PPC64_V28, - UNW_PPC64_V29, - UNW_PPC64_V30, - UNW_PPC64_V31, - - UNW_PPC64_VRSAVE = 109, - UNW_PPC64_VSCR = 110, - UNW_PPC64_SPE_ACC = 111, - UNW_PPC64_SPEFSCR = 112, - - /* frame info (read-only) */ - UNW_PPC64_FRAME_POINTER, - UNW_PPC64_NIP, - - - UNW_TDEP_LAST_REG = UNW_PPC64_NIP, - - UNW_TDEP_IP = UNW_PPC64_NIP, - UNW_TDEP_SP = UNW_PPC64_R1, - UNW_TDEP_EH = UNW_PPC64_R12 - } -ppc64_regnum_t; - -typedef enum - { - UNW_PPC64_ABI_ELFv1, - UNW_PPC64_ABI_ELFv2 - } -ppc64_abi_t; - -/* - * According to David Edelsohn, GNU gcc uses R3, R4, R5, and maybe R6 for - * passing parameters to exception handlers. - */ - -#define UNW_TDEP_NUM_EH_REGS 4 - -typedef struct unw_tdep_save_loc - { - /* Additional target-dependent info on a save location. */ - } -unw_tdep_save_loc_t; - -/* On ppc64, we can directly use ucontext_t as the unwind context. */ -typedef ucontext_t unw_tdep_context_t; - -/* XXX this is not ideal: an application should not be prevented from - using the "getcontext" name just because it's using libunwind. We - can't just use __getcontext() either, because that isn't exported - by glibc... */ -#define unw_tdep_getcontext(uc) (getcontext (uc), 0) - -#include "libunwind-dynamic.h" - -typedef struct - { - /* no ppc64-specific auxiliary proc-info */ - } -unw_tdep_proc_info_t; - -#include "libunwind-common.h" - -#define unw_tdep_is_fpreg UNW_ARCH_OBJ(is_fpreg) -extern int unw_tdep_is_fpreg (int); - -#if defined(__cplusplus) || defined(c_plusplus) -} -#endif - -#endif /* LIBUNWIND_H */ diff --git a/src/pal/src/libunwind/include/libunwind-ptrace.h b/src/pal/src/libunwind/include/libunwind-ptrace.h deleted file mode 100644 index 801325c4d..000000000 --- a/src/pal/src/libunwind/include/libunwind-ptrace.h +++ /dev/null @@ -1,63 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#ifndef libunwind_ptrace_h -#define libunwind_ptrace_h - -#include - -#if defined(__cplusplus) || defined(c_plusplus) -extern "C" { -#endif - -/* Helper routines which make it easy to use libunwind via ptrace(). - They're available only if UNW_REMOTE_ONLY is _not_ defined and they - aren't really part of the libunwind API. They are implemented in a - archive library called libunwind-ptrace.a. */ - -extern void *_UPT_create (pid_t); -extern void _UPT_destroy (void *); -extern int _UPT_find_proc_info (unw_addr_space_t, unw_word_t, - unw_proc_info_t *, int, void *); -extern void _UPT_put_unwind_info (unw_addr_space_t, unw_proc_info_t *, void *); -extern int _UPT_get_dyn_info_list_addr (unw_addr_space_t, unw_word_t *, - void *); -extern int _UPT_access_mem (unw_addr_space_t, unw_word_t, unw_word_t *, int, - void *); -extern int _UPT_access_reg (unw_addr_space_t, unw_regnum_t, unw_word_t *, - int, void *); -extern int _UPT_access_fpreg (unw_addr_space_t, unw_regnum_t, unw_fpreg_t *, - int, void *); -extern int _UPT_get_proc_name (unw_addr_space_t, unw_word_t, char *, size_t, - unw_word_t *, void *); -extern int _UPT_resume (unw_addr_space_t, unw_cursor_t *, void *); -extern unw_accessors_t _UPT_accessors; - - -#if defined(__cplusplus) || defined(c_plusplus) -} -#endif - -#endif /* libunwind_ptrace_h */ diff --git a/src/pal/src/libunwind/include/libunwind-sh.h b/src/pal/src/libunwind/include/libunwind-sh.h deleted file mode 100644 index 927f61ff4..000000000 --- a/src/pal/src/libunwind/include/libunwind-sh.h +++ /dev/null @@ -1,114 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - Copyright (C) 2012 Tommi Rantala - -This file is part of libunwind. - -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. */ - -#ifndef LIBUNWIND_H -#define LIBUNWIND_H - -#if defined(__cplusplus) || defined(c_plusplus) -extern "C" { -#endif - -#include -#include -#include - -#define UNW_TARGET sh -#define UNW_TARGET_SH 1 - -#define _U_TDEP_QP_TRUE 0 /* see libunwind-dynamic.h */ - -/* This needs to be big enough to accommodate "struct cursor", while - leaving some slack for future expansion. Changing this value will - require recompiling all users of this library. Stack allocation is - relatively cheap and unwind-state copying is relatively rare, so we - want to err on making it rather too big than too small. */ - -#define UNW_TDEP_CURSOR_LEN 4096 - -typedef uint32_t unw_word_t; -typedef int32_t unw_sword_t; - -typedef long double unw_tdep_fpreg_t; - -typedef enum - { - UNW_SH_R0, - UNW_SH_R1, - UNW_SH_R2, - UNW_SH_R3, - UNW_SH_R4, - UNW_SH_R5, - UNW_SH_R6, - UNW_SH_R7, - UNW_SH_R8, - UNW_SH_R9, - UNW_SH_R10, - UNW_SH_R11, - UNW_SH_R12, - UNW_SH_R13, - UNW_SH_R14, - UNW_SH_R15, - - UNW_SH_PC, - UNW_SH_PR, - - UNW_TDEP_LAST_REG = UNW_SH_PR, - - UNW_TDEP_IP = UNW_SH_PR, - UNW_TDEP_SP = UNW_SH_R15, - UNW_TDEP_EH = UNW_SH_R0 - } -sh_regnum_t; - -#define UNW_TDEP_NUM_EH_REGS 2 - -typedef ucontext_t unw_tdep_context_t; - -#define unw_tdep_getcontext(uc) (getcontext (uc), 0) - -typedef struct unw_tdep_save_loc - { - /* Additional target-dependent info on a save location. */ - } -unw_tdep_save_loc_t; - -#include "libunwind-dynamic.h" - -typedef struct - { - /* no sh-specific auxiliary proc-info */ - } -unw_tdep_proc_info_t; - -#include "libunwind-common.h" - -#define unw_tdep_is_fpreg UNW_ARCH_OBJ(is_fpreg) -extern int unw_tdep_is_fpreg (int); - -#if defined(__cplusplus) || defined(c_plusplus) -} -#endif - -#endif /* LIBUNWIND_H */ diff --git a/src/pal/src/libunwind/include/libunwind-tilegx.h b/src/pal/src/libunwind/include/libunwind-tilegx.h deleted file mode 100644 index 0f84ea65e..000000000 --- a/src/pal/src/libunwind/include/libunwind-tilegx.h +++ /dev/null @@ -1,161 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - Copyright (C) 2014 Tilera Corp. - -This file is part of libunwind. - -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. */ - -#ifndef LIBUNWIND_H -#define LIBUNWIND_H - -#if defined(__cplusplus) || defined(c_plusplus) -extern "C" { -#endif - -#include -#include - -#define UNW_TARGET tilegx -#define UNW_TARGET_TILEGX 1 - -#define _U_TDEP_QP_TRUE 0 /* see libunwind-dynamic.h */ - -/* This needs to be big enough to accommodate "struct cursor", while - leaving some slack for future expansion. Changing this value will - require recompiling all users of this library. Stack allocation is - relatively cheap and unwind-state copying is relatively rare, so we - want to err on making it rather too big than too small. */ - -#define UNW_TDEP_CURSOR_LEN 4096 - -/* The size of a "word" varies on TILEGX. This type is used for memory - addresses and register values. */ -typedef uint64_t unw_word_t; -typedef int64_t unw_sword_t; - -typedef long double unw_tdep_fpreg_t; - -typedef enum -{ - UNW_TILEGX_R0, - UNW_TILEGX_R1, - UNW_TILEGX_R2, - UNW_TILEGX_R3, - UNW_TILEGX_R4, - UNW_TILEGX_R5, - UNW_TILEGX_R6, - UNW_TILEGX_R7, - UNW_TILEGX_R8, - UNW_TILEGX_R9, - UNW_TILEGX_R10, - UNW_TILEGX_R11, - UNW_TILEGX_R12, - UNW_TILEGX_R13, - UNW_TILEGX_R14, - UNW_TILEGX_R15, - UNW_TILEGX_R16, - UNW_TILEGX_R17, - UNW_TILEGX_R18, - UNW_TILEGX_R19, - UNW_TILEGX_R20, - UNW_TILEGX_R21, - UNW_TILEGX_R22, - UNW_TILEGX_R23, - UNW_TILEGX_R24, - UNW_TILEGX_R25, - UNW_TILEGX_R26, - UNW_TILEGX_R27, - UNW_TILEGX_R28, - UNW_TILEGX_R29, - UNW_TILEGX_R30, - UNW_TILEGX_R31, - UNW_TILEGX_R32, - UNW_TILEGX_R33, - UNW_TILEGX_R34, - UNW_TILEGX_R35, - UNW_TILEGX_R36, - UNW_TILEGX_R37, - UNW_TILEGX_R38, - UNW_TILEGX_R39, - UNW_TILEGX_R40, - UNW_TILEGX_R41, - UNW_TILEGX_R42, - UNW_TILEGX_R43, - UNW_TILEGX_R44, - UNW_TILEGX_R45, - UNW_TILEGX_R46, - UNW_TILEGX_R47, - UNW_TILEGX_R48, - UNW_TILEGX_R49, - UNW_TILEGX_R50, - UNW_TILEGX_R51, - UNW_TILEGX_R52, - UNW_TILEGX_R53, - UNW_TILEGX_R54, - UNW_TILEGX_R55, - - /* FIXME: Other registers! */ - - UNW_TILEGX_PC, - /* For TILEGX, the CFA is the value of SP (r54) at the call site in the - previous frame. */ - UNW_TILEGX_CFA, - - UNW_TDEP_LAST_REG = UNW_TILEGX_PC, - - UNW_TDEP_IP = UNW_TILEGX_R55, /* R55 is link register for Tilegx */ - UNW_TDEP_SP = UNW_TILEGX_R54, - UNW_TDEP_EH = UNW_TILEGX_R0 /* FIXME. */ -} tilegx_regnum_t; - -typedef enum -{ - UNW_TILEGX_ABI_N64 = 2 -} tilegx_abi_t; - -#define UNW_TDEP_NUM_EH_REGS 2 /* FIXME for TILEGX. */ - -typedef struct unw_tdep_save_loc -{ - /* Additional target-dependent info on a save location. */ -} unw_tdep_save_loc_t; - -typedef ucontext_t unw_tdep_context_t; - -#include "libunwind-dynamic.h" - -typedef struct -{ - /* no tilegx-specific auxiliary proc-info */ -} unw_tdep_proc_info_t; - -#include "libunwind-common.h" - -#define unw_tdep_getcontext getcontext - -#define unw_tdep_is_fpreg UNW_ARCH_OBJ(is_fpreg) -extern int unw_tdep_is_fpreg (int); - -#if defined(__cplusplus) || defined(c_plusplus) -} -#endif - -#endif /* LIBUNWIND_H */ diff --git a/src/pal/src/libunwind/include/libunwind-x86.h b/src/pal/src/libunwind/include/libunwind-x86.h deleted file mode 100644 index 40fe0464f..000000000 --- a/src/pal/src/libunwind/include/libunwind-x86.h +++ /dev/null @@ -1,187 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2002-2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#ifndef LIBUNWIND_H -#define LIBUNWIND_H - -#if defined(__cplusplus) || defined(c_plusplus) -extern "C" { -#endif - -#include -#include -#include - -#define UNW_TARGET x86 -#define UNW_TARGET_X86 1 - -#define _U_TDEP_QP_TRUE 0 /* see libunwind-dynamic.h */ - -/* This needs to be big enough to accommodate "struct cursor", while - leaving some slack for future expansion. Changing this value will - require recompiling all users of this library. Stack allocation is - relatively cheap and unwind-state copying is relatively rare, so we - want to err on making it rather too big than too small. */ -#define UNW_TDEP_CURSOR_LEN 127 - -typedef uint32_t unw_word_t; -typedef int32_t unw_sword_t; - -typedef union { - struct { uint8_t b[4]; } val32; - struct { uint8_t b[10]; } val80; - struct { uint8_t b[16]; } val128; -} unw_tdep_fpreg_t; - -typedef enum - { - /* Note: general registers are expected to start with index 0. - This convention facilitates architecture-independent - implementation of the C++ exception handling ABI. See - _Unwind_SetGR() and _Unwind_GetGR() for details. - - The described register usage convention is based on "System V - Application Binary Interface, Intel386 Architecture Processor - Supplement, Fourth Edition" at - - http://www.linuxbase.org/spec/refspecs/elf/abi386-4.pdf - - It would have been nice to use the same register numbering as - DWARF, but that doesn't work because the libunwind requires - that the exception argument registers be consecutive, which the - wouldn't be with the DWARF numbering. */ - UNW_X86_EAX, /* scratch (exception argument 1) */ - UNW_X86_EDX, /* scratch (exception argument 2) */ - UNW_X86_ECX, /* scratch */ - UNW_X86_EBX, /* preserved */ - UNW_X86_ESI, /* preserved */ - UNW_X86_EDI, /* preserved */ - UNW_X86_EBP, /* (optional) frame-register */ - UNW_X86_ESP, /* (optional) frame-register */ - UNW_X86_EIP, /* frame-register */ - UNW_X86_EFLAGS, /* scratch (except for "direction", which is fixed */ - UNW_X86_TRAPNO, /* scratch */ - - /* MMX/stacked-fp registers */ - UNW_X86_ST0, /* fp return value */ - UNW_X86_ST1, /* scratch */ - UNW_X86_ST2, /* scratch */ - UNW_X86_ST3, /* scratch */ - UNW_X86_ST4, /* scratch */ - UNW_X86_ST5, /* scratch */ - UNW_X86_ST6, /* scratch */ - UNW_X86_ST7, /* scratch */ - - UNW_X86_FCW, /* scratch */ - UNW_X86_FSW, /* scratch */ - UNW_X86_FTW, /* scratch */ - UNW_X86_FOP, /* scratch */ - UNW_X86_FCS, /* scratch */ - UNW_X86_FIP, /* scratch */ - UNW_X86_FEA, /* scratch */ - UNW_X86_FDS, /* scratch */ - - /* SSE registers */ - UNW_X86_XMM0_lo, /* scratch */ - UNW_X86_XMM0_hi, /* scratch */ - UNW_X86_XMM1_lo, /* scratch */ - UNW_X86_XMM1_hi, /* scratch */ - UNW_X86_XMM2_lo, /* scratch */ - UNW_X86_XMM2_hi, /* scratch */ - UNW_X86_XMM3_lo, /* scratch */ - UNW_X86_XMM3_hi, /* scratch */ - UNW_X86_XMM4_lo, /* scratch */ - UNW_X86_XMM4_hi, /* scratch */ - UNW_X86_XMM5_lo, /* scratch */ - UNW_X86_XMM5_hi, /* scratch */ - UNW_X86_XMM6_lo, /* scratch */ - UNW_X86_XMM6_hi, /* scratch */ - UNW_X86_XMM7_lo, /* scratch */ - UNW_X86_XMM7_hi, /* scratch */ - - UNW_X86_MXCSR, /* scratch */ - - /* segment registers */ - UNW_X86_GS, /* special */ - UNW_X86_FS, /* special */ - UNW_X86_ES, /* special */ - UNW_X86_DS, /* special */ - UNW_X86_SS, /* special */ - UNW_X86_CS, /* special */ - UNW_X86_TSS, /* special */ - UNW_X86_LDT, /* special */ - - /* frame info (read-only) */ - UNW_X86_CFA, - - UNW_X86_XMM0, /* scratch */ - UNW_X86_XMM1, /* scratch */ - UNW_X86_XMM2, /* scratch */ - UNW_X86_XMM3, /* scratch */ - UNW_X86_XMM4, /* scratch */ - UNW_X86_XMM5, /* scratch */ - UNW_X86_XMM6, /* scratch */ - UNW_X86_XMM7, /* scratch */ - - UNW_TDEP_LAST_REG = UNW_X86_XMM7, - - UNW_TDEP_IP = UNW_X86_EIP, - UNW_TDEP_SP = UNW_X86_ESP, - UNW_TDEP_EH = UNW_X86_EAX - } -x86_regnum_t; - -#define UNW_TDEP_NUM_EH_REGS 2 /* eax and edx are exception args */ - -typedef struct unw_tdep_save_loc - { - /* Additional target-dependent info on a save location. */ - } -unw_tdep_save_loc_t; - -/* On x86, we can directly use ucontext_t as the unwind context. */ -typedef ucontext_t unw_tdep_context_t; - -#include "libunwind-dynamic.h" - -typedef struct - { - /* no x86-specific auxiliary proc-info */ - } -unw_tdep_proc_info_t; - -#include "libunwind-common.h" - -#define unw_tdep_getcontext UNW_ARCH_OBJ(getcontext) -extern int unw_tdep_getcontext (unw_tdep_context_t *); - -#define unw_tdep_is_fpreg UNW_ARCH_OBJ(is_fpreg) -extern int unw_tdep_is_fpreg (int); - -#if defined(__cplusplus) || defined(c_plusplus) -} -#endif - -#endif /* LIBUNWIND_H */ diff --git a/src/pal/src/libunwind/include/libunwind-x86_64.h b/src/pal/src/libunwind/include/libunwind-x86_64.h deleted file mode 100644 index 78eb541af..000000000 --- a/src/pal/src/libunwind/include/libunwind-x86_64.h +++ /dev/null @@ -1,141 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2002-2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - - Modified for x86_64 by Max Asbock - -This file is part of libunwind. - -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. */ - -#ifndef LIBUNWIND_H -#define LIBUNWIND_H - -#if defined(__cplusplus) || defined(c_plusplus) -extern "C" { -#endif - -#include -#include -#include - -#define UNW_TARGET x86_64 -#define UNW_TARGET_X86_64 1 - -#define _U_TDEP_QP_TRUE 0 /* see libunwind-dynamic.h */ - -/* This needs to be big enough to accommodate "struct cursor", while - leaving some slack for future expansion. Changing this value will - require recompiling all users of this library. Stack allocation is - relatively cheap and unwind-state copying is relatively rare, so we - want to err on making it rather too big than too small. */ -#define UNW_TDEP_CURSOR_LEN 127 - -typedef uint64_t unw_word_t; -typedef int64_t unw_sword_t; - -typedef long double unw_tdep_fpreg_t; - -typedef enum - { - UNW_X86_64_RAX, - UNW_X86_64_RDX, - UNW_X86_64_RCX, - UNW_X86_64_RBX, - UNW_X86_64_RSI, - UNW_X86_64_RDI, - UNW_X86_64_RBP, - UNW_X86_64_RSP, - UNW_X86_64_R8, - UNW_X86_64_R9, - UNW_X86_64_R10, - UNW_X86_64_R11, - UNW_X86_64_R12, - UNW_X86_64_R13, - UNW_X86_64_R14, - UNW_X86_64_R15, - UNW_X86_64_RIP, -#ifdef CONFIG_MSABI_SUPPORT - UNW_X86_64_XMM0, - UNW_X86_64_XMM1, - UNW_X86_64_XMM2, - UNW_X86_64_XMM3, - UNW_X86_64_XMM4, - UNW_X86_64_XMM5, - UNW_X86_64_XMM6, - UNW_X86_64_XMM7, - UNW_X86_64_XMM8, - UNW_X86_64_XMM9, - UNW_X86_64_XMM10, - UNW_X86_64_XMM11, - UNW_X86_64_XMM12, - UNW_X86_64_XMM13, - UNW_X86_64_XMM14, - UNW_X86_64_XMM15, - UNW_TDEP_LAST_REG = UNW_X86_64_XMM15, -#else - UNW_TDEP_LAST_REG = UNW_X86_64_RIP, -#endif - - /* XXX Add other regs here */ - - /* frame info (read-only) */ - UNW_X86_64_CFA, - - UNW_TDEP_IP = UNW_X86_64_RIP, - UNW_TDEP_SP = UNW_X86_64_RSP, - UNW_TDEP_BP = UNW_X86_64_RBP, - UNW_TDEP_EH = UNW_X86_64_RAX - } -x86_64_regnum_t; - -#define UNW_TDEP_NUM_EH_REGS 2 /* XXX Not sure what this means */ - -typedef struct unw_tdep_save_loc - { - /* Additional target-dependent info on a save location. */ - char unused; - } -unw_tdep_save_loc_t; - -/* On x86_64, we can directly use ucontext_t as the unwind context. */ -typedef ucontext_t unw_tdep_context_t; - -typedef struct - { - /* no x86-64-specific auxiliary proc-info */ - char unused; - } -unw_tdep_proc_info_t; - -#include "libunwind-dynamic.h" -#include "libunwind-common.h" - -#define unw_tdep_getcontext UNW_ARCH_OBJ(getcontext) -#define unw_tdep_is_fpreg UNW_ARCH_OBJ(is_fpreg) - -extern int unw_tdep_getcontext (unw_tdep_context_t *); -extern int unw_tdep_is_fpreg (int); - -#if defined(__cplusplus) || defined(c_plusplus) -} -#endif - -#endif /* LIBUNWIND_H */ diff --git a/src/pal/src/libunwind/include/libunwind.h.in b/src/pal/src/libunwind/include/libunwind.h.in deleted file mode 100644 index 7a56168c8..000000000 --- a/src/pal/src/libunwind/include/libunwind.h.in +++ /dev/null @@ -1,36 +0,0 @@ -/* Provide a real file - not a symlink - as it would cause multiarch conflicts - when multiple different arch releases are installed simultaneously. */ - -#ifndef UNW_REMOTE_ONLY - -#if defined __aarch64__ -#include "libunwind-aarch64.h" -#elif defined __arm__ -# include "libunwind-arm.h" -#elif defined __hppa__ -# include "libunwind-hppa.h" -#elif defined __ia64__ -# include "libunwind-ia64.h" -#elif defined __mips__ -# include "libunwind-mips.h" -#elif defined __powerpc__ && !defined __powerpc64__ -# include "libunwind-ppc32.h" -#elif defined __powerpc64__ -# include "libunwind-ppc64.h" -#elif defined __sh__ -# include "libunwind-sh.h" -#elif defined __i386__ -# include "libunwind-x86.h" -#elif defined __x86_64__ -# include "libunwind-x86_64.h" -#elif defined __tilegx__ -# include "libunwind-tilegx.h" -#else -# error "Unsupported arch" -#endif - -#else /* UNW_REMOTE_ONLY */ - -# include "libunwind-@arch@.h" - -#endif /* UNW_REMOTE_ONLY */ diff --git a/src/pal/src/libunwind/include/libunwind_i.h b/src/pal/src/libunwind/include/libunwind_i.h deleted file mode 100644 index 0fcf32695..000000000 --- a/src/pal/src/libunwind/include/libunwind_i.h +++ /dev/null @@ -1,366 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2001-2005 Hewlett-Packard Co - Copyright (C) 2007 David Mosberger-Tang - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -/* This files contains libunwind-internal definitions which are - subject to frequent change and are not to be exposed to - libunwind-users. */ - -#ifndef libunwind_i_h -#define libunwind_i_h - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "compiler.h" - -#if defined(HAVE___THREAD) && HAVE___THREAD -#define UNWI_DEFAULT_CACHING_POLICY UNW_CACHE_PER_THREAD -#else -#define UNWI_DEFAULT_CACHING_POLICY UNW_CACHE_GLOBAL -#endif - -/* Platform-independent libunwind-internal declarations. */ - -#include /* HP-UX needs this before include of pthread.h */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#if defined(HAVE_ELF_H) -# include -#elif defined(HAVE_SYS_ELF_H) -# include -#else -# error Could not locate -#endif - -#if defined(HAVE_ENDIAN_H) -# include -#elif defined(HAVE_SYS_ENDIAN_H) -# include -# if defined(_LITTLE_ENDIAN) && !defined(__LITTLE_ENDIAN) -# define __LITTLE_ENDIAN _LITTLE_ENDIAN -# endif -# if defined(_BIG_ENDIAN) && !defined(__BIG_ENDIAN) -# define __BIG_ENDIAN _BIG_ENDIAN -# endif -# if defined(_BYTE_ORDER) && !defined(__BYTE_ORDER) -# define __BYTE_ORDER _BYTE_ORDER -# endif -#else -# define __LITTLE_ENDIAN 1234 -# define __BIG_ENDIAN 4321 -# if defined(__hpux) -# define __BYTE_ORDER __BIG_ENDIAN -# elif defined(__QNX__) -# if defined(__BIGENDIAN__) -# define __BYTE_ORDER __BIG_ENDIAN -# elif defined(__LITTLEENDIAN__) -# define __BYTE_ORDER __LITTLE_ENDIAN -# else -# error Host has unknown byte-order. -# endif -# else -# error Host has unknown byte-order. -# endif -#endif - -#if defined(HAVE__BUILTIN_UNREACHABLE) -# define unreachable() __builtin_unreachable() -#else -# define unreachable() do { } while (1) -#endif - -#ifdef DEBUG -# define UNW_DEBUG 1 -#else -# define UNW_DEBUG 0 -#endif - -/* Make it easy to write thread-safe code which may or may not be - linked against libpthread. The macros below can be used - unconditionally and if -lpthread is around, they'll call the - corresponding routines otherwise, they do nothing. */ - -#pragma weak pthread_mutex_init -#pragma weak pthread_mutex_lock -#pragma weak pthread_mutex_unlock - -#define mutex_init(l) \ - (pthread_mutex_init != NULL ? pthread_mutex_init ((l), NULL) : 0) -#define mutex_lock(l) \ - (pthread_mutex_lock != NULL ? pthread_mutex_lock (l) : 0) -#define mutex_unlock(l) \ - (pthread_mutex_unlock != NULL ? pthread_mutex_unlock (l) : 0) - -#ifdef HAVE_ATOMIC_OPS_H -# include -static inline int -cmpxchg_ptr (void *addr, void *old, void *new) -{ - union - { - void *vp; - AO_t *aop; - } - u; - - u.vp = addr; - return AO_compare_and_swap(u.aop, (AO_t) old, (AO_t) new); -} -# define fetch_and_add1(_ptr) AO_fetch_and_add1(_ptr) -# define fetch_and_add(_ptr, value) AO_fetch_and_add(_ptr, value) - /* GCC 3.2.0 on HP-UX crashes on cmpxchg_ptr() */ -# if !(defined(__hpux) && __GNUC__ == 3 && __GNUC_MINOR__ == 2) -# define HAVE_CMPXCHG -# endif -# define HAVE_FETCH_AND_ADD -#elif defined(HAVE_SYNC_ATOMICS) || defined(HAVE_IA64INTRIN_H) -# ifdef HAVE_IA64INTRIN_H -# include -# endif -static inline int -cmpxchg_ptr (void *addr, void *old, void *new) -{ - union - { - void *vp; - long *vlp; - } - u; - - u.vp = addr; - return __sync_bool_compare_and_swap(u.vlp, (long) old, (long) new); -} -# define fetch_and_add1(_ptr) __sync_fetch_and_add(_ptr, 1) -# define fetch_and_add(_ptr, value) __sync_fetch_and_add(_ptr, value) -# define HAVE_CMPXCHG -# define HAVE_FETCH_AND_ADD -#endif -#define atomic_read(ptr) (*(ptr)) - -#define UNWI_OBJ(fn) UNW_PASTE(UNW_PREFIX,UNW_PASTE(I,fn)) -#define UNWI_ARCH_OBJ(fn) UNW_PASTE(UNW_PASTE(UNW_PASTE(_UI,UNW_TARGET),_), fn) - -#define unwi_full_mask UNWI_ARCH_OBJ(full_mask) - -/* Type of a mask that can be used to inhibit preemption. At the - userlevel, preemption is caused by signals and hence sigset_t is - appropriate. In constrast, the Linux kernel uses "unsigned long" - to hold the processor "flags" instead. */ -typedef sigset_t intrmask_t; - -extern intrmask_t unwi_full_mask; - -/* Silence compiler warnings about variables which are used only if libunwind - is configured in a certain way */ -static inline void mark_as_used(void *v UNUSED) { -} - -#if defined(CONFIG_BLOCK_SIGNALS) -# define SIGPROCMASK(how, new_mask, old_mask) \ - sigprocmask((how), (new_mask), (old_mask)) -#else -# define SIGPROCMASK(how, new_mask, old_mask) mark_as_used(old_mask) -#endif - -/* Prefer adaptive mutexes if available */ -#ifdef PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP -#define UNW_PTHREAD_MUTEX_INITIALIZER PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP -#else -#define UNW_PTHREAD_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER -#endif - -#define define_lock(name) \ - pthread_mutex_t name = UNW_PTHREAD_MUTEX_INITIALIZER -#define lock_init(l) mutex_init (l) -#define lock_acquire(l,m) \ -do { \ - SIGPROCMASK (SIG_SETMASK, &unwi_full_mask, &(m)); \ - mutex_lock (l); \ -} while (0) -#define lock_release(l,m) \ -do { \ - mutex_unlock (l); \ - SIGPROCMASK (SIG_SETMASK, &(m), NULL); \ -} while (0) - -#define SOS_MEMORY_SIZE 16384 /* see src/mi/mempool.c */ - -#ifndef MAP_ANONYMOUS -# define MAP_ANONYMOUS MAP_ANON -#endif -#define GET_MEMORY(mem, size) \ -do { \ - /* Hopefully, mmap() goes straight through to a system call stub... */ \ - mem = mmap (NULL, size, PROT_READ | PROT_WRITE, \ - MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); \ - if (mem == MAP_FAILED) \ - mem = NULL; \ -} while (0) - -#define unwi_find_dynamic_proc_info UNWI_OBJ(find_dynamic_proc_info) -#define unwi_extract_dynamic_proc_info UNWI_OBJ(extract_dynamic_proc_info) -#define unwi_put_dynamic_unwind_info UNWI_OBJ(put_dynamic_unwind_info) -#define unwi_dyn_remote_find_proc_info UNWI_OBJ(dyn_remote_find_proc_info) -#define unwi_dyn_remote_put_unwind_info UNWI_OBJ(dyn_remote_put_unwind_info) -#define unwi_dyn_validate_cache UNWI_OBJ(dyn_validate_cache) - -extern int unwi_find_dynamic_proc_info (unw_addr_space_t as, - unw_word_t ip, - unw_proc_info_t *pi, - int need_unwind_info, void *arg); -extern int unwi_extract_dynamic_proc_info (unw_addr_space_t as, - unw_word_t ip, - unw_proc_info_t *pi, - unw_dyn_info_t *di, - int need_unwind_info, - void *arg); -extern void unwi_put_dynamic_unwind_info (unw_addr_space_t as, - unw_proc_info_t *pi, void *arg); - -/* These handle the remote (cross-address-space) case of accessing - dynamic unwind info. */ - -extern int unwi_dyn_remote_find_proc_info (unw_addr_space_t as, - unw_word_t ip, - unw_proc_info_t *pi, - int need_unwind_info, - void *arg); -extern void unwi_dyn_remote_put_unwind_info (unw_addr_space_t as, - unw_proc_info_t *pi, - void *arg); -extern int unwi_dyn_validate_cache (unw_addr_space_t as, void *arg); - -extern unw_dyn_info_list_t _U_dyn_info_list; -extern pthread_mutex_t _U_dyn_info_list_lock; - -#if UNW_DEBUG -#define unwi_debug_level UNWI_ARCH_OBJ(debug_level) -extern long unwi_debug_level; - -# include -# define Debug(level,format...) \ -do { \ - if (unwi_debug_level >= level) \ - { \ - int _n = level; \ - if (_n > 16) \ - _n = 16; \ - fprintf (stderr, "%*c>%s: ", _n, ' ', __FUNCTION__); \ - fprintf (stderr, format); \ - } \ -} while (0) -# define Dprintf(format...) fprintf (stderr, format) -#else -# define Debug(level,format...) -# define Dprintf(format...) -#endif - -static ALWAYS_INLINE int -print_error (const char *string) -{ - return write (2, string, strlen (string)); -} - -#define mi_init UNWI_ARCH_OBJ(mi_init) - -extern void mi_init (void); /* machine-independent initializations */ -extern unw_word_t _U_dyn_info_list_addr (void); - -/* This is needed/used by ELF targets only. */ - -struct elf_image - { - void *image; /* pointer to mmap'd image */ - size_t size; /* (file-) size of the image */ - }; - -struct elf_dyn_info - { - struct elf_image ei; - unw_dyn_info_t di_cache; - unw_dyn_info_t di_debug; /* additional table info for .debug_frame */ -#if UNW_TARGET_IA64 - unw_dyn_info_t ktab; -#endif -#if UNW_TARGET_ARM - unw_dyn_info_t di_arm; /* additional table info for .ARM.exidx */ -#endif - }; - -static inline void invalidate_edi (struct elf_dyn_info *edi) -{ - if (edi->ei.image) - munmap (edi->ei.image, edi->ei.size); - memset (edi, 0, sizeof (*edi)); - edi->di_cache.format = -1; - edi->di_debug.format = -1; -#if UNW_TARGET_ARM - edi->di_arm.format = -1; -#endif -} - - -/* Provide a place holder for architecture to override for fast access - to memory when known not to need to validate and know the access - will be local to the process. A suitable override will improve - unw_tdep_trace() performance in particular. */ -#define ACCESS_MEM_FAST(ret,validate,cur,addr,to) \ - do { (ret) = dwarf_get ((cur), DWARF_MEM_LOC ((cur), (addr)), &(to)); } \ - while (0) - -/* Define GNU and processor specific values for the Phdr p_type field in case - they aren't defined by . */ -#ifndef PT_GNU_EH_FRAME -# define PT_GNU_EH_FRAME 0x6474e550 -#endif /* !PT_GNU_EH_FRAME */ -#ifndef PT_ARM_EXIDX -# define PT_ARM_EXIDX 0x70000001 /* ARM unwind segment */ -#endif /* !PT_ARM_EXIDX */ - -#include "tdep/libunwind_i.h" - -#ifndef tdep_get_func_addr -# define tdep_get_func_addr(as,addr,v) (*(v) = addr, 0) -#endif - -#ifndef DWARF_VAL_LOC -# define DWARF_IS_VAL_LOC(l) 0 -# define DWARF_VAL_LOC(c,v) DWARF_NULL_LOC -#endif - -#define UNW_ALIGN(x,a) (((x)+(a)-1UL)&~((a)-1UL)) - -#endif /* libunwind_i_h */ - diff --git a/src/pal/src/libunwind/include/mempool.h b/src/pal/src/libunwind/include/mempool.h deleted file mode 100644 index 1f1c77009..000000000 --- a/src/pal/src/libunwind/include/mempool.h +++ /dev/null @@ -1,89 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2002-2003 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#ifndef mempool_h -#define mempool_h - -/* Memory pools provide simple memory management of fixed-size - objects. Memory pools are used for two purposes: - - o To ensure a stack can be unwound even when a process - is out of memory. - - o To ensure a stack can be unwound at any time in a - multi-threaded process (e.g., even at a time when the normal - malloc-lock is taken, possibly by the very thread that is - being unwind). - - - To achieve the second objective, memory pools allocate memory - directly via mmap() system call (or an equivalent facility). - - The first objective is accomplished by reserving memory ahead of - time. Since the memory requirements of stack unwinding generally - depends on the complexity of the procedures being unwind, there is - no absolute guarantee that unwinding will always work, but in - practice, this should not be a serious problem. */ - -#include - -#include "libunwind_i.h" - -#define sos_alloc(s) UNWI_ARCH_OBJ(_sos_alloc)(s) -#define mempool_init(p,s,r) UNWI_ARCH_OBJ(_mempool_init)(p,s,r) -#define mempool_alloc(p) UNWI_ARCH_OBJ(_mempool_alloc)(p) -#define mempool_free(p,o) UNWI_ARCH_OBJ(_mempool_free)(p,o) - -/* The mempool structure should be treated as an opaque object. It's - declared here only to enable static allocation of mempools. */ -struct mempool - { - pthread_mutex_t lock; - size_t obj_size; /* object size (rounded up for alignment) */ - size_t chunk_size; /* allocation granularity */ - unsigned int reserve; /* minimum (desired) size of the free-list */ - unsigned int num_free; /* number of objects on the free-list */ - struct object - { - struct object *next; - } - *free_list; - }; - -/* Emergency allocation for one-time stuff that doesn't fit the memory - pool model. A limited amount of memory is available in this - fashion and once allocated, there is no way to free it. */ -extern void *sos_alloc (size_t size); - -/* Initialize POOL for an object size of OBJECT_SIZE bytes. RESERVE - is the number of objects that should be reserved for use under - tight memory situations. If it is zero, mempool attempts to pick a - reasonable default value. */ -extern void mempool_init (struct mempool *pool, - size_t obj_size, size_t reserve); -extern void *mempool_alloc (struct mempool *pool); -extern void mempool_free (struct mempool *pool, void *object); - -#endif /* mempool_h */ diff --git a/src/pal/src/libunwind/include/remote.h b/src/pal/src/libunwind/include/remote.h deleted file mode 100644 index 064d6309a..000000000 --- a/src/pal/src/libunwind/include/remote.h +++ /dev/null @@ -1,129 +0,0 @@ -#ifndef REMOTE_H -#define REMOTE_H - -/* Helper functions for accessing (remote) memory. These functions - assume that all addresses are naturally aligned (e.g., 32-bit - quantity is stored at a 32-bit-aligned address. */ - -#ifdef UNW_LOCAL_ONLY - -static inline int -fetch8 (unw_addr_space_t as, unw_accessors_t *a, - unw_word_t *addr, int8_t *valp, void *arg) -{ - *valp = *(int8_t *) (uintptr_t) *addr; - *addr += 1; - return 0; -} - -static inline int -fetch16 (unw_addr_space_t as, unw_accessors_t *a, - unw_word_t *addr, int16_t *valp, void *arg) -{ - *valp = *(int16_t *) (uintptr_t) *addr; - *addr += 2; - return 0; -} - -static inline int -fetch32 (unw_addr_space_t as, unw_accessors_t *a, - unw_word_t *addr, int32_t *valp, void *arg) -{ - *valp = *(int32_t *) (uintptr_t) *addr; - *addr += 4; - return 0; -} - -static inline int -fetchw (unw_addr_space_t as, unw_accessors_t *a, - unw_word_t *addr, unw_word_t *valp, void *arg) -{ - *valp = *(unw_word_t *) (uintptr_t) *addr; - *addr += sizeof (unw_word_t); - return 0; -} - -#else /* !UNW_LOCAL_ONLY */ - -#define WSIZE (sizeof (unw_word_t)) - -static inline int -fetch8 (unw_addr_space_t as, unw_accessors_t *a, - unw_word_t *addr, int8_t *valp, void *arg) -{ - unw_word_t val, aligned_addr = *addr & -WSIZE, off = *addr - aligned_addr; - int ret; - - *addr += 1; - - ret = (*a->access_mem) (as, aligned_addr, &val, 0, arg); - -#if __BYTE_ORDER == __LITTLE_ENDIAN - val >>= 8*off; -#else - val >>= 8*(WSIZE - 1 - off); -#endif - *valp = val & 0xff; - return ret; -} - -static inline int -fetch16 (unw_addr_space_t as, unw_accessors_t *a, - unw_word_t *addr, int16_t *valp, void *arg) -{ - unw_word_t val, aligned_addr = *addr & -WSIZE, off = *addr - aligned_addr; - int ret; - - if ((off & 0x1) != 0) - return -UNW_EINVAL; - - *addr += 2; - - ret = (*a->access_mem) (as, aligned_addr, &val, 0, arg); - -#if __BYTE_ORDER == __LITTLE_ENDIAN - val >>= 8*off; -#else - val >>= 8*(WSIZE - 2 - off); -#endif - *valp = val & 0xffff; - return ret; -} - -static inline int -fetch32 (unw_addr_space_t as, unw_accessors_t *a, - unw_word_t *addr, int32_t *valp, void *arg) -{ - unw_word_t val, aligned_addr = *addr & -WSIZE, off = *addr - aligned_addr; - int ret; - - if ((off & 0x3) != 0) - return -UNW_EINVAL; - - *addr += 4; - - ret = (*a->access_mem) (as, aligned_addr, &val, 0, arg); - -#if __BYTE_ORDER == __LITTLE_ENDIAN - val >>= 8*off; -#else - val >>= 8*(WSIZE - 4 - off); -#endif - *valp = val & 0xffffffff; - return ret; -} - -static inline int -fetchw (unw_addr_space_t as, unw_accessors_t *a, - unw_word_t *addr, unw_word_t *valp, void *arg) -{ - int ret; - - ret = (*a->access_mem) (as, *addr, valp, 0, arg); - *addr += WSIZE; - return ret; -} - -#endif /* !UNW_LOCAL_ONLY */ - -#endif /* REMOTE_H */ diff --git a/src/pal/src/libunwind/include/tdep-aarch64/dwarf-config.h b/src/pal/src/libunwind/include/tdep-aarch64/dwarf-config.h deleted file mode 100644 index f65db17ee..000000000 --- a/src/pal/src/libunwind/include/tdep-aarch64/dwarf-config.h +++ /dev/null @@ -1,52 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - Copyright (C) 2012 Tommi Rantala - Copyright (C) 2013 Linaro Limited - -This file is part of libunwind. - -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. */ - -#ifndef dwarf_config_h -#define dwarf_config_h - -/* This matches the value udes by GCC (see - gcc/config/aarch64/aarch64.h:DWARF_FRAME_REGISTERS. */ -#define DWARF_NUM_PRESERVED_REGS 97 - -/* Return TRUE if the ADDR_SPACE uses big-endian byte-order. */ -#define dwarf_is_big_endian(addr_space) 0 - -#define dwarf_to_unw_regnum(reg) (((reg) <= UNW_AARCH64_V31) ? (reg) : 0) - -/* Convert a pointer to a dwarf_cursor structure to a pointer to - unw_cursor_t. */ -#define dwarf_to_cursor(c) ((unw_cursor_t *) (c)) - -typedef struct dwarf_loc - { - unw_word_t val; -#ifndef UNW_LOCAL_ONLY - unw_word_t type; /* see DWARF_LOC_TYPE_* macros. */ -#endif - } -dwarf_loc_t; - -#endif /* dwarf_config_h */ diff --git a/src/pal/src/libunwind/include/tdep-aarch64/jmpbuf.h b/src/pal/src/libunwind/include/tdep-aarch64/jmpbuf.h deleted file mode 100644 index 3f01a442b..000000000 --- a/src/pal/src/libunwind/include/tdep-aarch64/jmpbuf.h +++ /dev/null @@ -1,33 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - Copyright (C) 2013 Linaro Limited - -This file is part of libunwind. - -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. */ - -/* Use glibc's jump-buffer indices; NPTL peeks at SP: */ - -/* FIXME for AArch64 */ - -#define JB_SP 13 -#define JB_RP 14 -#define JB_MASK_SAVED 15 -#define JB_MASK 16 diff --git a/src/pal/src/libunwind/include/tdep-aarch64/libunwind_i.h b/src/pal/src/libunwind/include/tdep-aarch64/libunwind_i.h deleted file mode 100644 index b91273fa1..000000000 --- a/src/pal/src/libunwind/include/tdep-aarch64/libunwind_i.h +++ /dev/null @@ -1,320 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2001-2005 Hewlett-Packard Co - Contributed by David Mosberger-Tang - Copyright (C) 2013 Linaro Limited - -This file is part of libunwind. - -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. */ - -#ifndef AARCH64_LIBUNWIND_I_H -#define AARCH64_LIBUNWIND_I_H - -/* Target-dependent definitions that are internal to libunwind but need - to be shared with target-independent code. */ - -#include -#include - -#include "elf64.h" -#include "mempool.h" -#include "dwarf.h" - -typedef enum - { - UNW_AARCH64_FRAME_STANDARD = -2, /* regular fp, sp +/- offset */ - UNW_AARCH64_FRAME_SIGRETURN = -1, /* special sigreturn frame */ - UNW_AARCH64_FRAME_OTHER = 0, /* not cacheable (special or unrecognised) */ - UNW_AARCH64_FRAME_GUESSED = 1 /* guessed it was regular, but not known */ - } -unw_tdep_frame_type_t; - -typedef struct - { - uint64_t virtual_address; - int64_t frame_type : 2; /* unw_tdep_frame_type_t classification */ - int64_t last_frame : 1; /* non-zero if last frame in chain */ - int64_t cfa_reg_sp : 1; /* cfa dwarf base register is sp vs. fp */ - int64_t cfa_reg_offset : 30; /* cfa is at this offset from base register value */ - int64_t fp_cfa_offset : 30; /* fp saved at this offset from cfa (-1 = not saved) */ - int64_t lr_cfa_offset : 30; /* lr saved at this offset from cfa (-1 = not saved) */ - int64_t sp_cfa_offset : 30; /* sp saved at this offset from cfa (-1 = not saved) */ - } -unw_tdep_frame_t; - -#ifdef UNW_LOCAL_ONLY - -typedef unw_word_t aarch64_loc_t; - -#else /* !UNW_LOCAL_ONLY */ - -typedef struct aarch64_loc - { - unw_word_t w0, w1; - } -aarch64_loc_t; - -#endif /* !UNW_LOCAL_ONLY */ - -struct unw_addr_space - { - struct unw_accessors acc; - int big_endian; - unw_caching_policy_t caching_policy; -#ifdef HAVE_ATOMIC_OPS_H - AO_t cache_generation; -#else - uint32_t cache_generation; -#endif - unw_word_t dyn_generation; /* see dyn-common.h */ - unw_word_t dyn_info_list_addr; /* (cached) dyn_info_list_addr */ - struct dwarf_rs_cache global_cache; - struct unw_debug_frame_list *debug_frames; - }; - -struct cursor - { - struct dwarf_cursor dwarf; /* must be first */ - - unw_tdep_frame_t frame_info; /* quick tracing assist info */ - - enum - { - AARCH64_SCF_NONE, - AARCH64_SCF_LINUX_RT_SIGFRAME, - } - sigcontext_format; - unw_word_t sigcontext_addr; - unw_word_t sigcontext_sp; - unw_word_t sigcontext_pc; - int validate; - }; - -#define DWARF_GET_LOC(l) ((l).val) - -#ifdef UNW_LOCAL_ONLY -# define DWARF_NULL_LOC DWARF_LOC (0, 0) -# define DWARF_IS_NULL_LOC(l) (DWARF_GET_LOC (l) == 0) -# define DWARF_LOC(r, t) ((dwarf_loc_t) { .val = (r) }) -# define DWARF_IS_REG_LOC(l) 0 -# define DWARF_REG_LOC(c,r) (DWARF_LOC((unw_word_t) \ - tdep_uc_addr((c)->as_arg, (r)), 0)) -# define DWARF_MEM_LOC(c,m) DWARF_LOC ((m), 0) -# define DWARF_FPREG_LOC(c,r) (DWARF_LOC((unw_word_t) \ - tdep_uc_addr((c)->as_arg, (r)), 0)) - -static inline int -dwarf_getfp (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t *val) -{ - if (!DWARF_GET_LOC (loc)) - return -1; - *val = *(unw_fpreg_t *) DWARF_GET_LOC (loc); - return 0; -} - -static inline int -dwarf_putfp (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t val) -{ - if (!DWARF_GET_LOC (loc)) - return -1; - *(unw_fpreg_t *) DWARF_GET_LOC (loc) = val; - return 0; -} - -static inline int -dwarf_get (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t *val) -{ - if (!DWARF_GET_LOC (loc)) - return -1; - *val = *(unw_word_t *) DWARF_GET_LOC (loc); - return 0; -} - -static inline int -dwarf_put (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t val) -{ - if (!DWARF_GET_LOC (loc)) - return -1; - *(unw_word_t *) DWARF_GET_LOC (loc) = val; - return 0; -} - -#else /* !UNW_LOCAL_ONLY */ -# define DWARF_LOC_TYPE_FP (1 << 0) -# define DWARF_LOC_TYPE_REG (1 << 1) -# define DWARF_NULL_LOC DWARF_LOC (0, 0) -# define DWARF_IS_NULL_LOC(l) \ - ({ dwarf_loc_t _l = (l); _l.val == 0 && _l.type == 0; }) -# define DWARF_LOC(r, t) ((dwarf_loc_t) { .val = (r), .type = (t) }) -# define DWARF_IS_REG_LOC(l) (((l).type & DWARF_LOC_TYPE_REG) != 0) -# define DWARF_IS_FP_LOC(l) (((l).type & DWARF_LOC_TYPE_FP) != 0) -# define DWARF_REG_LOC(c,r) DWARF_LOC((r), DWARF_LOC_TYPE_REG) -# define DWARF_MEM_LOC(c,m) DWARF_LOC ((m), 0) -# define DWARF_FPREG_LOC(c,r) DWARF_LOC((r), (DWARF_LOC_TYPE_REG \ - | DWARF_LOC_TYPE_FP)) - -static inline int -dwarf_getfp (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t *val) -{ - char *valp = (char *) &val; - unw_word_t addr; - int ret; - - if (DWARF_IS_NULL_LOC (loc)) - return -UNW_EBADREG; - - if (DWARF_IS_REG_LOC (loc)) - return (*c->as->acc.access_fpreg) (c->as, DWARF_GET_LOC (loc), - val, 0, c->as_arg); - - addr = DWARF_GET_LOC (loc); - if ((ret = (*c->as->acc.access_mem) (c->as, addr + 0, (unw_word_t *) valp, - 0, c->as_arg)) < 0) - return ret; - - return (*c->as->acc.access_mem) (c->as, addr + 4, (unw_word_t *) valp + 1, 0, - c->as_arg); -} - -static inline int -dwarf_putfp (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t val) -{ - char *valp = (char *) &val; - unw_word_t addr; - int ret; - - if (DWARF_IS_NULL_LOC (loc)) - return -UNW_EBADREG; - - if (DWARF_IS_REG_LOC (loc)) - return (*c->as->acc.access_fpreg) (c->as, DWARF_GET_LOC (loc), - &val, 1, c->as_arg); - - addr = DWARF_GET_LOC (loc); - if ((ret = (*c->as->acc.access_mem) (c->as, addr + 0, (unw_word_t *) valp, - 1, c->as_arg)) < 0) - return ret; - - return (*c->as->acc.access_mem) (c->as, addr + 4, (unw_word_t *) valp + 1, - 1, c->as_arg); -} - -static inline int -dwarf_get (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t *val) -{ - if (DWARF_IS_NULL_LOC (loc)) - return -UNW_EBADREG; - - /* If a code-generator were to save a value of type unw_word_t in a - floating-point register, we would have to support this case. I - suppose it could happen with MMX registers, but does it really - happen? */ - assert (!DWARF_IS_FP_LOC (loc)); - - if (DWARF_IS_REG_LOC (loc)) - return (*c->as->acc.access_reg) (c->as, DWARF_GET_LOC (loc), val, - 0, c->as_arg); - else - return (*c->as->acc.access_mem) (c->as, DWARF_GET_LOC (loc), val, - 0, c->as_arg); -} - -static inline int -dwarf_put (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t val) -{ - if (DWARF_IS_NULL_LOC (loc)) - return -UNW_EBADREG; - - /* If a code-generator were to save a value of type unw_word_t in a - floating-point register, we would have to support this case. I - suppose it could happen with MMX registers, but does it really - happen? */ - assert (!DWARF_IS_FP_LOC (loc)); - - if (DWARF_IS_REG_LOC (loc)) - return (*c->as->acc.access_reg) (c->as, DWARF_GET_LOC (loc), &val, - 1, c->as_arg); - else - return (*c->as->acc.access_mem) (c->as, DWARF_GET_LOC (loc), &val, - 1, c->as_arg); -} - -#endif /* !UNW_LOCAL_ONLY */ - - - -#define tdep_getcontext_trace UNW_ARCH_OBJ(getcontext_trace) -#define tdep_init_done UNW_OBJ(init_done) -#define tdep_init UNW_OBJ(init) -/* Platforms that support UNW_INFO_FORMAT_TABLE need to define - tdep_search_unwind_table. */ -#define tdep_search_unwind_table dwarf_search_unwind_table -#define tdep_find_unwind_table dwarf_find_unwind_table -#define tdep_uc_addr UNW_OBJ(uc_addr) -#define tdep_get_elf_image UNW_ARCH_OBJ(get_elf_image) -#define tdep_get_exe_image_path UNW_ARCH_OBJ(get_exe_image_path) -#define tdep_access_reg UNW_OBJ(access_reg) -#define tdep_access_fpreg UNW_OBJ(access_fpreg) -#define tdep_fetch_frame(c,ip,n) do {} while(0) -#define tdep_cache_frame(c) 0 -#define tdep_reuse_frame(c,frame) do {} while(0) -#define tdep_stash_frame UNW_OBJ(tdep_stash_frame) -#define tdep_trace UNW_OBJ(tdep_trace) - -#ifdef UNW_LOCAL_ONLY -# define tdep_find_proc_info(c,ip,n) \ - dwarf_find_proc_info((c)->as, (ip), &(c)->pi, (n), \ - (c)->as_arg) -# define tdep_put_unwind_info(as,pi,arg) \ - dwarf_put_unwind_info((as), (pi), (arg)) -#else -# define tdep_find_proc_info(c,ip,n) \ - (*(c)->as->acc.find_proc_info)((c)->as, (ip), &(c)->pi, (n), \ - (c)->as_arg) -# define tdep_put_unwind_info(as,pi,arg) \ - (*(as)->acc.put_unwind_info)((as), (pi), (arg)) -#endif - -#define tdep_get_as(c) ((c)->dwarf.as) -#define tdep_get_as_arg(c) ((c)->dwarf.as_arg) -#define tdep_get_ip(c) ((c)->dwarf.ip) -#define tdep_big_endian(as) ((as)->big_endian) - -extern int tdep_init_done; - -extern void tdep_init (void); -extern int tdep_search_unwind_table (unw_addr_space_t as, unw_word_t ip, - unw_dyn_info_t *di, unw_proc_info_t *pi, - int need_unwind_info, void *arg); -extern void *tdep_uc_addr (unw_tdep_context_t *uc, int reg); -extern int tdep_get_elf_image (struct elf_image *ei, pid_t pid, unw_word_t ip, - unsigned long *segbase, unsigned long *mapoff, - char *path, size_t pathlen); -extern void tdep_get_exe_image_path (char *path); -extern int tdep_access_reg (struct cursor *c, unw_regnum_t reg, - unw_word_t *valp, int write); -extern int tdep_access_fpreg (struct cursor *c, unw_regnum_t reg, - unw_fpreg_t *valp, int write); -extern int tdep_trace (unw_cursor_t *cursor, void **addresses, int *n); -extern void tdep_stash_frame (struct dwarf_cursor *c, - struct dwarf_reg_state *rs); -extern int tdep_getcontext_trace (unw_tdep_context_t *); - -#endif /* AARCH64_LIBUNWIND_I_H */ diff --git a/src/pal/src/libunwind/include/tdep-arm/dwarf-config.h b/src/pal/src/libunwind/include/tdep-arm/dwarf-config.h deleted file mode 100644 index f50228975..000000000 --- a/src/pal/src/libunwind/include/tdep-arm/dwarf-config.h +++ /dev/null @@ -1,51 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - Copyright (C) 2012 Tommi Rantala - -This file is part of libunwind. - -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. */ - -#ifndef dwarf_config_h -#define dwarf_config_h - -/* This is FIRST_PSEUDO_REGISTER in GCC, since DWARF_FRAME_REGISTERS is not - explicitly defined. */ -#define DWARF_NUM_PRESERVED_REGS 128 - -#define dwarf_to_unw_regnum(reg) (((reg) < 16) ? (reg) : 0) - -/* Return TRUE if the ADDR_SPACE uses big-endian byte-order. */ -#define dwarf_is_big_endian(addr_space) 0 - -/* Convert a pointer to a dwarf_cursor structure to a pointer to - unw_cursor_t. */ -#define dwarf_to_cursor(c) ((unw_cursor_t *) (c)) - -typedef struct dwarf_loc - { - unw_word_t val; -#ifndef UNW_LOCAL_ONLY - unw_word_t type; /* see DWARF_LOC_TYPE_* macros. */ -#endif - } -dwarf_loc_t; - -#endif /* dwarf_config_h */ diff --git a/src/pal/src/libunwind/include/tdep-arm/ex_tables.h b/src/pal/src/libunwind/include/tdep-arm/ex_tables.h deleted file mode 100644 index 9df5e0a9f..000000000 --- a/src/pal/src/libunwind/include/tdep-arm/ex_tables.h +++ /dev/null @@ -1,55 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright 2011 Linaro Limited - -This file is part of libunwind. - -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. */ - -#ifndef ARM_EX_TABLES_H -#define ARM_EX_TABLES_H - -typedef enum arm_exbuf_cmd { - ARM_EXIDX_CMD_FINISH, - ARM_EXIDX_CMD_DATA_PUSH, - ARM_EXIDX_CMD_DATA_POP, - ARM_EXIDX_CMD_REG_POP, - ARM_EXIDX_CMD_REG_TO_SP, - ARM_EXIDX_CMD_VFP_POP, - ARM_EXIDX_CMD_WREG_POP, - ARM_EXIDX_CMD_WCGR_POP, - ARM_EXIDX_CMD_RESERVED, - ARM_EXIDX_CMD_REFUSED, -} arm_exbuf_cmd_t; - -struct arm_exbuf_data -{ - arm_exbuf_cmd_t cmd; - uint32_t data; -}; - -#define arm_exidx_extract UNW_OBJ(arm_exidx_extract) -#define arm_exidx_decode UNW_OBJ(arm_exidx_decode) -#define arm_exidx_apply_cmd UNW_OBJ(arm_exidx_apply_cmd) - -int arm_exidx_extract (struct dwarf_cursor *c, uint8_t *buf); -int arm_exidx_decode (const uint8_t *buf, uint8_t len, struct dwarf_cursor *c); -int arm_exidx_apply_cmd (struct arm_exbuf_data *edata, struct dwarf_cursor *c); - -#endif // ARM_EX_TABLES_H diff --git a/src/pal/src/libunwind/include/tdep-arm/jmpbuf.h b/src/pal/src/libunwind/include/tdep-arm/jmpbuf.h deleted file mode 100644 index 008e77f79..000000000 --- a/src/pal/src/libunwind/include/tdep-arm/jmpbuf.h +++ /dev/null @@ -1,32 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - -This file is part of libunwind. - -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. */ - -/* Use glibc's jump-buffer indices; NPTL peeks at SP: */ - -/* FIXME for ARM! */ - -#define JB_SP 4 -#define JB_RP 5 -#define JB_MASK_SAVED 6 -#define JB_MASK 7 diff --git a/src/pal/src/libunwind/include/tdep-arm/libunwind_i.h b/src/pal/src/libunwind/include/tdep-arm/libunwind_i.h deleted file mode 100644 index 2602f41c4..000000000 --- a/src/pal/src/libunwind/include/tdep-arm/libunwind_i.h +++ /dev/null @@ -1,326 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - -This file is part of libunwind. - -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. */ - -#ifndef ARM_LIBUNWIND_I_H -#define ARM_LIBUNWIND_I_H - -/* Target-dependent definitions that are internal to libunwind but need - to be shared with target-independent code. */ - -#include -#include - -#include "elf32.h" -#include "mempool.h" -#include "dwarf.h" -#include "ex_tables.h" - -typedef enum - { - UNW_ARM_FRAME_SYSCALL = -3, /* r7 saved in r12, sp offset zero */ - UNW_ARM_FRAME_STANDARD = -2, /* regular r7, sp +/- offset */ - UNW_ARM_FRAME_SIGRETURN = -1, /* special sigreturn frame */ - UNW_ARM_FRAME_OTHER = 0, /* not cacheable (special or unrecognised) */ - UNW_ARM_FRAME_GUESSED = 1 /* guessed it was regular, but not known */ - } -unw_tdep_frame_type_t; - -typedef struct - { - uint32_t virtual_address; - int32_t frame_type : 3; /* unw_tdep_frame_type_t classification */ - int32_t last_frame : 1; /* non-zero if last frame in chain */ - int32_t cfa_reg_sp : 1; /* cfa dwarf base register is sp vs. r7 */ - int32_t cfa_reg_offset : 30; /* cfa is at this offset from base register value */ - int32_t r7_cfa_offset : 30; /* r7 saved at this offset from cfa (-1 = not saved) */ - int32_t lr_cfa_offset : 30; /* lr saved at this offset from cfa (-1 = not saved) */ - int32_t sp_cfa_offset : 30; /* sp saved at this offset from cfa (-1 = not saved) */ - } -unw_tdep_frame_t; - -struct unw_addr_space - { - struct unw_accessors acc; - int big_endian; - unw_caching_policy_t caching_policy; -#ifdef HAVE_ATOMIC_OPS_H - AO_t cache_generation; -#else - uint32_t cache_generation; -#endif - unw_word_t dyn_generation; /* see dyn-common.h */ - unw_word_t dyn_info_list_addr; /* (cached) dyn_info_list_addr */ - struct dwarf_rs_cache global_cache; - struct unw_debug_frame_list *debug_frames; - }; - -struct cursor - { - struct dwarf_cursor dwarf; /* must be first */ - - unw_tdep_frame_t frame_info; /* quick tracing assist info */ - - enum - { - ARM_SCF_NONE, /* no signal frame */ - ARM_SCF_LINUX_SIGFRAME, /* non-RT signal frame, kernel >=2.6.18 */ - ARM_SCF_LINUX_RT_SIGFRAME, /* RT signal frame, kernel >=2.6.18 */ - ARM_SCF_LINUX_OLD_SIGFRAME, /* non-RT signal frame, kernel < 2.6.18 */ - ARM_SCF_LINUX_OLD_RT_SIGFRAME, /* RT signal frame, kernel < 2.6.18 */ - ARM_SCF_FREEBSD_SIGFRAME, /* FreeBSD sigframe */ - ARM_SCF_FREEBSD_SYSCALL, /* FreeBSD syscall stub */ - } - sigcontext_format; - unw_word_t sigcontext_addr; - unw_word_t sigcontext_sp; - unw_word_t sigcontext_pc; - int validate; - }; - -#define DWARF_GET_LOC(l) ((l).val) - -#ifdef UNW_LOCAL_ONLY -# define DWARF_NULL_LOC DWARF_LOC (0, 0) -# define DWARF_IS_NULL_LOC(l) (DWARF_GET_LOC (l) == 0) -# define DWARF_LOC(r, t) ((dwarf_loc_t) { .val = (r) }) -# define DWARF_IS_REG_LOC(l) 0 -# define DWARF_REG_LOC(c,r) (DWARF_LOC((unw_word_t) \ - tdep_uc_addr((c)->as_arg, (r)), 0)) -# define DWARF_MEM_LOC(c,m) DWARF_LOC ((m), 0) -# define DWARF_FPREG_LOC(c,r) (DWARF_LOC((unw_word_t) \ - tdep_uc_addr((c)->as_arg, (r)), 0)) - -static inline int -dwarf_getfp (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t *val) -{ - if (!DWARF_GET_LOC (loc)) - return -1; - *val = *(unw_fpreg_t *) DWARF_GET_LOC (loc); - return 0; -} - -static inline int -dwarf_putfp (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t val) -{ - if (!DWARF_GET_LOC (loc)) - return -1; - *(unw_fpreg_t *) DWARF_GET_LOC (loc) = val; - return 0; -} - -static inline int -dwarf_get (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t *val) -{ - if (!DWARF_GET_LOC (loc)) - return -1; - *val = *(unw_word_t *) DWARF_GET_LOC (loc); - return 0; -} - -static inline int -dwarf_put (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t val) -{ - if (!DWARF_GET_LOC (loc)) - return -1; - *(unw_word_t *) DWARF_GET_LOC (loc) = val; - return 0; -} - -#else /* !UNW_LOCAL_ONLY */ -# define DWARF_LOC_TYPE_FP (1 << 0) -# define DWARF_LOC_TYPE_REG (1 << 1) -# define DWARF_NULL_LOC DWARF_LOC (0, 0) -# define DWARF_IS_NULL_LOC(l) \ - ({ dwarf_loc_t _l = (l); _l.val == 0 && _l.type == 0; }) -# define DWARF_LOC(r, t) ((dwarf_loc_t) { .val = (r), .type = (t) }) -# define DWARF_IS_REG_LOC(l) (((l).type & DWARF_LOC_TYPE_REG) != 0) -# define DWARF_IS_FP_LOC(l) (((l).type & DWARF_LOC_TYPE_FP) != 0) -# define DWARF_REG_LOC(c,r) DWARF_LOC((r), DWARF_LOC_TYPE_REG) -# define DWARF_MEM_LOC(c,m) DWARF_LOC ((m), 0) -# define DWARF_FPREG_LOC(c,r) DWARF_LOC((r), (DWARF_LOC_TYPE_REG \ - | DWARF_LOC_TYPE_FP)) - -static inline int -dwarf_getfp (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t *val) -{ - char *valp = (char *) &val; - unw_word_t addr; - int ret; - - if (DWARF_IS_NULL_LOC (loc)) - return -UNW_EBADREG; - - if (DWARF_IS_REG_LOC (loc)) - return (*c->as->acc.access_fpreg) (c->as, DWARF_GET_LOC (loc), - val, 0, c->as_arg); - - addr = DWARF_GET_LOC (loc); - if ((ret = (*c->as->acc.access_mem) (c->as, addr + 0, (unw_word_t *) valp, - 0, c->as_arg)) < 0) - return ret; - - return (*c->as->acc.access_mem) (c->as, addr + 4, (unw_word_t *) valp + 1, 0, - c->as_arg); -} - -static inline int -dwarf_putfp (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t val) -{ - char *valp = (char *) &val; - unw_word_t addr; - int ret; - - if (DWARF_IS_NULL_LOC (loc)) - return -UNW_EBADREG; - - if (DWARF_IS_REG_LOC (loc)) - return (*c->as->acc.access_fpreg) (c->as, DWARF_GET_LOC (loc), - &val, 1, c->as_arg); - - addr = DWARF_GET_LOC (loc); - if ((ret = (*c->as->acc.access_mem) (c->as, addr + 0, (unw_word_t *) valp, - 1, c->as_arg)) < 0) - return ret; - - return (*c->as->acc.access_mem) (c->as, addr + 4, (unw_word_t *) valp + 1, - 1, c->as_arg); -} - -static inline int -dwarf_get (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t *val) -{ - if (DWARF_IS_NULL_LOC (loc)) - return -UNW_EBADREG; - - /* If a code-generator were to save a value of type unw_word_t in a - floating-point register, we would have to support this case. I - suppose it could happen with MMX registers, but does it really - happen? */ - assert (!DWARF_IS_FP_LOC (loc)); - - if (DWARF_IS_REG_LOC (loc)) - return (*c->as->acc.access_reg) (c->as, DWARF_GET_LOC (loc), val, - 0, c->as_arg); - else - return (*c->as->acc.access_mem) (c->as, DWARF_GET_LOC (loc), val, - 0, c->as_arg); -} - -static inline int -dwarf_put (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t val) -{ - if (DWARF_IS_NULL_LOC (loc)) - return -UNW_EBADREG; - - /* If a code-generator were to save a value of type unw_word_t in a - floating-point register, we would have to support this case. I - suppose it could happen with MMX registers, but does it really - happen? */ - assert (!DWARF_IS_FP_LOC (loc)); - - if (DWARF_IS_REG_LOC (loc)) - return (*c->as->acc.access_reg) (c->as, DWARF_GET_LOC (loc), &val, - 1, c->as_arg); - else - return (*c->as->acc.access_mem) (c->as, DWARF_GET_LOC (loc), &val, - 1, c->as_arg); -} - -#endif /* !UNW_LOCAL_ONLY */ - -#define tdep_getcontext_trace unw_getcontext -#define tdep_init_done UNW_OBJ(init_done) -#define tdep_init UNW_OBJ(init) -#define arm_find_proc_info UNW_OBJ(find_proc_info) -#define arm_put_unwind_info UNW_OBJ(put_unwind_info) -/* Platforms that support UNW_INFO_FORMAT_TABLE need to define - tdep_search_unwind_table. */ -#define tdep_search_unwind_table UNW_OBJ(search_unwind_table) -#define tdep_find_unwind_table dwarf_find_unwind_table -#define tdep_uc_addr UNW_ARCH_OBJ(uc_addr) -#define tdep_get_elf_image UNW_ARCH_OBJ(get_elf_image) -#define tdep_get_exe_image_path UNW_ARCH_OBJ(get_exe_image_path) -#define tdep_access_reg UNW_OBJ(access_reg) -#define tdep_access_fpreg UNW_OBJ(access_fpreg) -#define tdep_fetch_frame(c,ip,n) do {} while(0) -#define tdep_cache_frame(c) 0 -#define tdep_reuse_frame(c,frame) do {} while(0) -#define tdep_stash_frame UNW_OBJ(tdep_stash_frame) -#define tdep_trace UNW_OBJ(tdep_trace) - -#ifdef UNW_LOCAL_ONLY -# define tdep_find_proc_info(c,ip,n) \ - arm_find_proc_info((c)->as, (ip), &(c)->pi, (n), \ - (c)->as_arg) -# define tdep_put_unwind_info(as,pi,arg) \ - arm_put_unwind_info((as), (pi), (arg)) -#else -# define tdep_find_proc_info(c,ip,n) \ - (*(c)->as->acc.find_proc_info)((c)->as, (ip), &(c)->pi, (n), \ - (c)->as_arg) -# define tdep_put_unwind_info(as,pi,arg) \ - (*(as)->acc.put_unwind_info)((as), (pi), (arg)) -#endif - -#define tdep_get_as(c) ((c)->dwarf.as) -#define tdep_get_as_arg(c) ((c)->dwarf.as_arg) -#define tdep_get_ip(c) ((c)->dwarf.ip) -#define tdep_big_endian(as) ((as)->big_endian) - -extern int tdep_init_done; - -extern void tdep_init (void); -extern int arm_find_proc_info (unw_addr_space_t as, unw_word_t ip, - unw_proc_info_t *pi, int need_unwind_info, - void *arg); -extern void arm_put_unwind_info (unw_addr_space_t as, - unw_proc_info_t *pi, void *arg); -extern int tdep_search_unwind_table (unw_addr_space_t as, unw_word_t ip, - unw_dyn_info_t *di, unw_proc_info_t *pi, - int need_unwind_info, void *arg); -extern void *tdep_uc_addr (unw_tdep_context_t *uc, int reg); -extern int tdep_get_elf_image (struct elf_image *ei, pid_t pid, unw_word_t ip, - unsigned long *segbase, unsigned long *mapoff, - char *path, size_t pathlen); -extern void tdep_get_exe_image_path (char *path); -extern int tdep_access_reg (struct cursor *c, unw_regnum_t reg, - unw_word_t *valp, int write); -extern int tdep_access_fpreg (struct cursor *c, unw_regnum_t reg, - unw_fpreg_t *valp, int write); -extern int tdep_trace (unw_cursor_t *cursor, void **addresses, int *n); -extern void tdep_stash_frame (struct dwarf_cursor *c, - struct dwarf_reg_state *rs); - -/* unwinding method selection support */ -#define UNW_ARM_METHOD_ALL 0xFF -#define UNW_ARM_METHOD_DWARF 0x01 -#define UNW_ARM_METHOD_FRAME 0x02 -#define UNW_ARM_METHOD_EXIDX 0x04 - -#define unwi_unwind_method UNW_OBJ(unwind_method) -extern int unwi_unwind_method; - -#define UNW_TRY_METHOD(x) (unwi_unwind_method & x) - -#endif /* ARM_LIBUNWIND_I_H */ diff --git a/src/pal/src/libunwind/include/tdep-hppa/dwarf-config.h b/src/pal/src/libunwind/include/tdep-hppa/dwarf-config.h deleted file mode 100644 index fb963c7d3..000000000 --- a/src/pal/src/libunwind/include/tdep-hppa/dwarf-config.h +++ /dev/null @@ -1,54 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (c) 2004 Hewlett-Packard Development Company, L.P. - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#ifndef dwarf_config_h -#define dwarf_config_h - -/* See DWARF_FRAME_REGNUM() macro in gcc/config/pa/pa32-regs.h: */ -#define dwarf_to_unw_regnum(reg) \ - (((reg) < DWARF_NUM_PRESERVED_REGS) ? (reg) : 0) - -/* This matches the value used by GCC (see - gcc/config/pa/pa32-regs.h:FIRST_PSEUDO_REGISTER), which leaves - plenty of room for expansion. */ -#define DWARF_NUM_PRESERVED_REGS 89 - -/* Return TRUE if the ADDR_SPACE uses big-endian byte-order. */ -#define dwarf_is_big_endian(addr_space) 1 - -/* Convert a pointer to a dwarf_cursor structure to a pointer to - unw_cursor_t. */ -#define dwarf_to_cursor(c) ((unw_cursor_t *) (c)) - -typedef struct dwarf_loc - { - unw_word_t val; -#ifndef UNW_LOCAL_ONLY - unw_word_t type; /* see X86_LOC_TYPE_* macros. */ -#endif - } -dwarf_loc_t; - -#endif /* dwarf_config_h */ diff --git a/src/pal/src/libunwind/include/tdep-hppa/jmpbuf.h b/src/pal/src/libunwind/include/tdep-hppa/jmpbuf.h deleted file mode 100644 index 91f062ff7..000000000 --- a/src/pal/src/libunwind/include/tdep-hppa/jmpbuf.h +++ /dev/null @@ -1,33 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -/* Use glibc's jump-buffer indices; NPTL peeks at SP: */ - -#ifndef JB_SP -# define JB_SP 19 -#endif -#define JB_RP 20 -#define JB_MASK_SAVED 21 -#define JB_MASK 22 diff --git a/src/pal/src/libunwind/include/tdep-hppa/libunwind_i.h b/src/pal/src/libunwind/include/tdep-hppa/libunwind_i.h deleted file mode 100644 index 72649aa3e..000000000 --- a/src/pal/src/libunwind/include/tdep-hppa/libunwind_i.h +++ /dev/null @@ -1,279 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2003-2005 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#ifndef HPPA_LIBUNWIND_I_H -#define HPPA_LIBUNWIND_I_H - -/* Target-dependent definitions that are internal to libunwind but need - to be shared with target-independent code. */ - -#include -#include - -#include "elf32.h" -#include "mempool.h" -#include "dwarf.h" - -typedef struct - { - /* no hppa-specific fast trace */ - } -unw_tdep_frame_t; - -struct unw_addr_space - { - struct unw_accessors acc; - unw_caching_policy_t caching_policy; -#ifdef HAVE_ATOMIC_OPS_H - AO_t cache_generation; -#else - uint32_t cache_generation; -#endif - unw_word_t dyn_generation; /* see dyn-common.h */ - unw_word_t dyn_info_list_addr; /* (cached) dyn_info_list_addr */ - struct dwarf_rs_cache global_cache; - struct unw_debug_frame_list *debug_frames; - }; - -struct cursor - { - struct dwarf_cursor dwarf; /* must be first */ - - /* Format of sigcontext structure and address at which it is - stored: */ - enum - { - HPPA_SCF_NONE, /* no signal frame encountered */ - HPPA_SCF_LINUX_RT_SIGFRAME /* POSIX ucontext_t */ - } - sigcontext_format; - unw_word_t sigcontext_addr; - }; - -#define DWARF_GET_LOC(l) ((l).val) - -#ifdef UNW_LOCAL_ONLY -# define DWARF_NULL_LOC DWARF_LOC (0, 0) -# define DWARF_IS_NULL_LOC(l) (DWARF_GET_LOC (l) == 0) -# define DWARF_LOC(r, t) ((dwarf_loc_t) { .val = (r) }) -# define DWARF_IS_REG_LOC(l) 0 -# define DWARF_REG_LOC(c,r) (DWARF_LOC((unw_word_t) \ - tdep_uc_addr((c)->as_arg, (r)), 0)) -# define DWARF_MEM_LOC(c,m) DWARF_LOC ((m), 0) -# define DWARF_FPREG_LOC(c,r) (DWARF_LOC((unw_word_t) \ - tdep_uc_addr((c)->as_arg, (r)), 0)) - -static inline int -dwarf_getfp (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t *val) -{ - if (!DWARF_GET_LOC (loc)) - return -1; - *val = *(unw_fpreg_t *) DWARF_GET_LOC (loc); - return 0; -} - -static inline int -dwarf_putfp (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t val) -{ - if (!DWARF_GET_LOC (loc)) - return -1; - *(unw_fpreg_t *) DWARF_GET_LOC (loc) = val; - return 0; -} - -static inline int -dwarf_get (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t *val) -{ - if (!DWARF_GET_LOC (loc)) - return -1; - *val = *(unw_word_t *) DWARF_GET_LOC (loc); - return 0; -} - -static inline int -dwarf_put (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t val) -{ - if (!DWARF_GET_LOC (loc)) - return -1; - *(unw_word_t *) DWARF_GET_LOC (loc) = val; - return 0; -} - -#else /* !UNW_LOCAL_ONLY */ -# define DWARF_LOC_TYPE_FP (1 << 0) -# define DWARF_LOC_TYPE_REG (1 << 1) -# define DWARF_NULL_LOC DWARF_LOC (0, 0) -# define DWARF_IS_NULL_LOC(l) \ - ({ dwarf_loc_t _l = (l); _l.val == 0 && _l.type == 0; }) -# define DWARF_LOC(r, t) ((dwarf_loc_t) { .val = (r), .type = (t) }) -# define DWARF_IS_REG_LOC(l) (((l).type & DWARF_LOC_TYPE_REG) != 0) -# define DWARF_IS_FP_LOC(l) (((l).type & DWARF_LOC_TYPE_FP) != 0) -# define DWARF_REG_LOC(c,r) DWARF_LOC((r), DWARF_LOC_TYPE_REG) -# define DWARF_MEM_LOC(c,m) DWARF_LOC ((m), 0) -# define DWARF_FPREG_LOC(c,r) DWARF_LOC((r), (DWARF_LOC_TYPE_REG \ - | DWARF_LOC_TYPE_FP)) - -static inline int -dwarf_getfp (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t *val) -{ - char *valp = (char *) &val; - unw_word_t addr; - int ret; - - if (DWARF_IS_NULL_LOC (loc)) - return -UNW_EBADREG; - - if (DWARF_IS_REG_LOC (loc)) - return (*c->as->acc.access_fpreg) (c->as, DWARF_GET_LOC (loc), - val, 0, c->as_arg); - - addr = DWARF_GET_LOC (loc); - if ((ret = (*c->as->acc.access_mem) (c->as, addr + 0, (unw_word_t *) valp, - 0, c->as_arg)) < 0) - return ret; - - return (*c->as->acc.access_mem) (c->as, addr + 4, (unw_word_t *) valp + 1, 0, - c->as_arg); -} - -static inline int -dwarf_putfp (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t val) -{ - char *valp = (char *) &val; - unw_word_t addr; - int ret; - - if (DWARF_IS_NULL_LOC (loc)) - return -UNW_EBADREG; - - if (DWARF_IS_REG_LOC (loc)) - return (*c->as->acc.access_fpreg) (c->as, DWARF_GET_LOC (loc), - &val, 1, c->as_arg); - - addr = DWARF_GET_LOC (loc); - if ((ret = (*c->as->acc.access_mem) (c->as, addr + 0, (unw_word_t *) valp, - 1, c->as_arg)) < 0) - return ret; - - return (*c->as->acc.access_mem) (c->as, addr + 4, (unw_word_t *) valp + 1, - 1, c->as_arg); -} - -static inline int -dwarf_get (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t *val) -{ - if (DWARF_IS_NULL_LOC (loc)) - return -UNW_EBADREG; - - /* If a code-generator were to save a value of type unw_word_t in a - floating-point register, we would have to support this case. I - suppose it could happen with MMX registers, but does it really - happen? */ - assert (!DWARF_IS_FP_LOC (loc)); - - if (DWARF_IS_REG_LOC (loc)) - return (*c->as->acc.access_reg) (c->as, DWARF_GET_LOC (loc), val, - 0, c->as_arg); - else - return (*c->as->acc.access_mem) (c->as, DWARF_GET_LOC (loc), val, - 0, c->as_arg); -} - -static inline int -dwarf_put (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t val) -{ - if (DWARF_IS_NULL_LOC (loc)) - return -UNW_EBADREG; - - /* If a code-generator were to save a value of type unw_word_t in a - floating-point register, we would have to support this case. I - suppose it could happen with MMX registers, but does it really - happen? */ - assert (!DWARF_IS_FP_LOC (loc)); - - if (DWARF_IS_REG_LOC (loc)) - return (*c->as->acc.access_reg) (c->as, DWARF_GET_LOC (loc), &val, - 1, c->as_arg); - else - return (*c->as->acc.access_mem) (c->as, DWARF_GET_LOC (loc), &val, - 1, c->as_arg); -} - -#endif /* !UNW_LOCAL_ONLY */ - -#define tdep_getcontext_trace unw_getcontext -#define tdep_init_done UNW_OBJ(init_done) -#define tdep_init UNW_OBJ(init) -/* Platforms that support UNW_INFO_FORMAT_TABLE need to define - tdep_search_unwind_table. */ -#define tdep_search_unwind_table dwarf_search_unwind_table -#define tdep_find_unwind_table dwarf_find_unwind_table -#define tdep_uc_addr UNW_ARCH_OBJ(uc_addr) -#define tdep_get_elf_image UNW_ARCH_OBJ(get_elf_image) -#define tdep_get_exe_image_path UNW_ARCH_OBJ(get_exe_image_path) -#define tdep_access_reg UNW_OBJ(access_reg) -#define tdep_access_fpreg UNW_OBJ(access_fpreg) -#define tdep_fetch_frame(c,ip,n) do {} while(0) -#define tdep_cache_frame(c) 0 -#define tdep_reuse_frame(c,frame) do {} while(0) -#define tdep_stash_frame(c,rs) do {} while(0) -#define tdep_trace(cur,addr,n) (-UNW_ENOINFO) - -#ifdef UNW_LOCAL_ONLY -# define tdep_find_proc_info(c,ip,n) \ - dwarf_find_proc_info((c)->as, (ip), &(c)->pi, (n), \ - (c)->as_arg) -# define tdep_put_unwind_info(as,pi,arg) \ - dwarf_put_unwind_info((as), (pi), (arg)) -#else -# define tdep_find_proc_info(c,ip,n) \ - (*(c)->as->acc.find_proc_info)((c)->as, (ip), &(c)->pi, (n), \ - (c)->as_arg) -# define tdep_put_unwind_info(as,pi,arg) \ - (*(as)->acc.put_unwind_info)((as), (pi), (arg)) -#endif - -#define tdep_get_as(c) ((c)->dwarf.as) -#define tdep_get_as_arg(c) ((c)->dwarf.as_arg) -#define tdep_get_ip(c) ((c)->dwarf.ip) -#define tdep_big_endian(as) 1 - -extern int tdep_init_done; - -extern void tdep_init (void); -extern int tdep_search_unwind_table (unw_addr_space_t as, unw_word_t ip, - unw_dyn_info_t *di, unw_proc_info_t *pi, - int need_unwind_info, void *arg); -extern void *tdep_uc_addr (ucontext_t *uc, int reg); -extern int tdep_get_elf_image (struct elf_image *ei, pid_t pid, unw_word_t ip, - unsigned long *segbase, unsigned long *mapoff, - char *path, size_t pathlen); -extern void tdep_get_exe_image_path (char *path); -extern int tdep_access_reg (struct cursor *c, unw_regnum_t reg, - unw_word_t *valp, int write); -extern int tdep_access_fpreg (struct cursor *c, unw_regnum_t reg, - unw_fpreg_t *valp, int write); - -#endif /* HPPA_LIBUNWIND_I_H */ diff --git a/src/pal/src/libunwind/include/tdep-ia64/jmpbuf.h b/src/pal/src/libunwind/include/tdep-ia64/jmpbuf.h deleted file mode 100644 index d642af207..000000000 --- a/src/pal/src/libunwind/include/tdep-ia64/jmpbuf.h +++ /dev/null @@ -1,32 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -/* Use glibc's jump-buffer indices; NPTL peeks at SP and BSP: */ - -#define JB_SP 0 -#define JB_RP 8 -#define JB_BSP 17 -#define JB_MASK_SAVED 70 -#define JB_MASK 71 diff --git a/src/pal/src/libunwind/include/tdep-ia64/libunwind_i.h b/src/pal/src/libunwind/include/tdep-ia64/libunwind_i.h deleted file mode 100644 index 1d9770bab..000000000 --- a/src/pal/src/libunwind/include/tdep-ia64/libunwind_i.h +++ /dev/null @@ -1,281 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2001-2005 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#ifndef IA64_LIBUNWIND_I_H -#define IA64_LIBUNWIND_I_H - -/* Target-dependent definitions that are internal to libunwind but need - to be shared with target-independent code. */ - -#include "elf64.h" -#include "mempool.h" - -typedef struct - { - /* no ia64-specific fast trace */ - } -unw_tdep_frame_t; - -enum ia64_pregnum - { - /* primary unat: */ - IA64_REG_PRI_UNAT_GR, - IA64_REG_PRI_UNAT_MEM, - - /* memory stack (order matters: see build_script() */ - IA64_REG_PSP, /* previous memory stack pointer */ - /* register stack */ - IA64_REG_BSP, /* register stack pointer */ - IA64_REG_BSPSTORE, - IA64_REG_PFS, /* previous function state */ - IA64_REG_RNAT, - /* instruction pointer: */ - IA64_REG_IP, - - /* preserved registers: */ - IA64_REG_R4, IA64_REG_R5, IA64_REG_R6, IA64_REG_R7, - IA64_REG_NAT4, IA64_REG_NAT5, IA64_REG_NAT6, IA64_REG_NAT7, - IA64_REG_UNAT, IA64_REG_PR, IA64_REG_LC, IA64_REG_FPSR, - IA64_REG_B1, IA64_REG_B2, IA64_REG_B3, IA64_REG_B4, IA64_REG_B5, - IA64_REG_F2, IA64_REG_F3, IA64_REG_F4, IA64_REG_F5, - IA64_REG_F16, IA64_REG_F17, IA64_REG_F18, IA64_REG_F19, - IA64_REG_F20, IA64_REG_F21, IA64_REG_F22, IA64_REG_F23, - IA64_REG_F24, IA64_REG_F25, IA64_REG_F26, IA64_REG_F27, - IA64_REG_F28, IA64_REG_F29, IA64_REG_F30, IA64_REG_F31, - IA64_NUM_PREGS - }; - -#ifdef UNW_LOCAL_ONLY - -typedef unw_word_t ia64_loc_t; - -#else /* !UNW_LOCAL_ONLY */ - -typedef struct ia64_loc - { - unw_word_t w0, w1; - } -ia64_loc_t; - -#endif /* !UNW_LOCAL_ONLY */ - -#include "script.h" - -#define ABI_UNKNOWN 0 -#define ABI_LINUX 1 -#define ABI_HPUX 2 -#define ABI_FREEBSD 3 -#define ABI_OPENVMS 4 -#define ABI_NSK 5 /* Tandem/HP Non-Stop Kernel */ -#define ABI_WINDOWS 6 - -struct unw_addr_space - { - struct unw_accessors acc; - int big_endian; - int abi; /* abi < 0 => unknown, 0 => SysV, 1 => HP-UX, 2 => Windows */ - unw_caching_policy_t caching_policy; -#ifdef HAVE_ATOMIC_OPS_H - AO_t cache_generation; -#else - uint32_t cache_generation; -#endif - unw_word_t dyn_generation; - unw_word_t dyn_info_list_addr; /* (cached) dyn_info_list_addr */ -#ifndef UNW_REMOTE_ONLY - unsigned long long shared_object_removals; -#endif - - struct ia64_script_cache global_cache; - }; - -/* Note: The ABI numbers in the ABI-markers (.unwabi directive) are - not the same as the above ABI numbers. */ -#define ABI_MARKER_OLD_LINUX_SIGTRAMP ((0 << 8) | 's') -#define ABI_MARKER_OLD_LINUX_INTERRUPT ((0 << 8) | 'i') -#define ABI_MARKER_HP_UX_SIGTRAMP ((1 << 8) | 1) -#define ABI_MARKER_LINUX_SIGTRAMP ((3 << 8) | 's') -#define ABI_MARKER_LINUX_INTERRUPT ((3 << 8) | 'i') - -struct cursor - { - void *as_arg; /* argument to address-space callbacks */ - unw_addr_space_t as; /* reference to per-address-space info */ - - /* IP, CFM, and predicate cache (these are always equal to the - values stored in ip_loc, cfm_loc, and pr_loc, - respectively). */ - unw_word_t ip; /* instruction pointer value */ - unw_word_t cfm; /* current frame mask */ - unw_word_t pr; /* current predicate values */ - - /* current frame info: */ - unw_word_t bsp; /* backing store pointer value */ - unw_word_t sp; /* stack pointer value */ - unw_word_t psp; /* previous sp value */ - ia64_loc_t cfm_loc; /* cfm save location (or NULL) */ - ia64_loc_t ec_loc; /* ar.ec save location (usually cfm_loc) */ - ia64_loc_t loc[IA64_NUM_PREGS]; - - unw_word_t eh_args[4]; /* exception handler arguments */ - unw_word_t sigcontext_addr; /* address of sigcontext or 0 */ - unw_word_t sigcontext_off; /* sigcontext-offset relative to signal sp */ - - short hint; - short prev_script; - - uint8_t nat_bitnr[4]; /* NaT bit numbers for r4-r7 */ - uint16_t abi_marker; /* abi_marker for current frame (if any) */ - uint16_t last_abi_marker; /* last abi_marker encountered so far */ - uint8_t eh_valid_mask; - - unsigned int pi_valid :1; /* is proc_info valid? */ - unsigned int pi_is_dynamic :1; /* proc_info found via dynamic proc info? */ - unw_proc_info_t pi; /* info about current procedure */ - - /* In case of stack-discontiguities, such as those introduced by - signal-delivery on an alternate signal-stack (see - sigaltstack(2)), we use the following data-structure to keep - track of the register-backing-store areas across on which the - current frame may be backed up. Since there are at most 96 - stacked registers and since we only have to track the current - frame and only areas that are not empty, this puts an upper - limit on the # of backing-store areas we have to track. - - Note that the rbs-area indexed by rbs_curr identifies the - rbs-area that was in effect at the time AR.BSP had the value - c->bsp. However, this rbs area may not actually contain the - value in the register that c->bsp corresponds to because that - register may not have gotten spilled until much later, when a - possibly different rbs-area might have been in effect - already. */ - uint8_t rbs_curr; /* index of curr. rbs-area (contains c->bsp) */ - uint8_t rbs_left_edge; /* index of inner-most valid rbs-area */ - struct rbs_area - { - unw_word_t end; - unw_word_t size; - ia64_loc_t rnat_loc; - } - rbs_area[96 + 2]; /* 96 stacked regs + 1 extra stack on each side... */ -}; - -struct ia64_global_unwind_state - { - pthread_mutex_t lock; /* global data lock */ - - volatile char init_done; - - /* Table of registers that prologues can save (and order in which - they're saved). */ - const unsigned char save_order[8]; - - /* - * uc_addr() may return pointers to these variables. We need to - * make sure they don't get written via ia64_put() or - * ia64_putfp(). To make it possible to test for these variables - * quickly, we collect them in a single sub-structure. - */ - struct - { - unw_word_t r0; /* r0 is byte-order neutral */ - unw_fpreg_t f0; /* f0 is byte-order neutral */ - unw_fpreg_t f1_le, f1_be; /* f1 is byte-order dependent */ - } - read_only; - unw_fpreg_t nat_val_le, nat_val_be; - unw_fpreg_t int_val_le, int_val_be; - - struct mempool reg_state_pool; - struct mempool labeled_state_pool; - -# if UNW_DEBUG - const char *preg_name[IA64_NUM_PREGS]; -# endif - }; - -#define tdep_getcontext_trace unw_getcontext -#define tdep_init_done unw.init_done -#define tdep_init UNW_OBJ(init) -/* Platforms that support UNW_INFO_FORMAT_TABLE need to define - tdep_search_unwind_table. */ -#define tdep_search_unwind_table unw_search_ia64_unwind_table -#define tdep_find_unwind_table ia64_find_unwind_table -#define tdep_find_proc_info UNW_OBJ(find_proc_info) -#define tdep_uc_addr UNW_OBJ(uc_addr) -#define tdep_get_elf_image UNW_ARCH_OBJ(get_elf_image) -#define tdep_get_exe_image_path UNW_ARCH_OBJ(get_exe_image_path) -#define tdep_access_reg UNW_OBJ(access_reg) -#define tdep_access_fpreg UNW_OBJ(access_fpreg) -#define tdep_fetch_frame(c,ip,n) do {} while(0) -#define tdep_cache_frame(c) 0 -#define tdep_reuse_frame(c,frame) do {} while(0) -#define tdep_stash_frame(c,rs) do {} while(0) -#define tdep_trace(cur,addr,n) (-UNW_ENOINFO) -#define tdep_get_as(c) ((c)->as) -#define tdep_get_as_arg(c) ((c)->as_arg) -#define tdep_get_ip(c) ((c)->ip) -#define tdep_big_endian(as) ((c)->as->big_endian != 0) - -#ifndef UNW_LOCAL_ONLY -# define tdep_put_unwind_info UNW_OBJ(put_unwind_info) -#endif - -/* This can't be an UNW_ARCH_OBJ() because we need separate - unw.initialized flags for the local-only and generic versions of - the library. Also, if we wanted to have a single, shared global - data structure, we couldn't declare "unw" as HIDDEN. */ -#define unw UNW_OBJ(data) - -extern void tdep_init (void); -extern int tdep_find_unwind_table (struct elf_dyn_info *edi, - unw_addr_space_t as, char *path, - unw_word_t segbase, unw_word_t mapoff, - unw_word_t ip); -extern int tdep_find_proc_info (unw_addr_space_t as, unw_word_t ip, - unw_proc_info_t *pi, int need_unwind_info, - void *arg); -extern void tdep_put_unwind_info (unw_addr_space_t as, - unw_proc_info_t *pi, void *arg); -extern void *tdep_uc_addr (ucontext_t *uc, unw_regnum_t regnum, - uint8_t *nat_bitnr); -extern int tdep_get_elf_image (struct elf_image *ei, pid_t pid, unw_word_t ip, - unsigned long *segbase, unsigned long *mapoff, - char *path, size_t pathlen); -extern void tdep_get_exe_image_path (char *path); -extern int tdep_access_reg (struct cursor *c, unw_regnum_t reg, - unw_word_t *valp, int write); -extern int tdep_access_fpreg (struct cursor *c, unw_regnum_t reg, - unw_fpreg_t *valp, int write); - -extern struct ia64_global_unwind_state unw; - -/* In user-level, we have no reasonable way of determining the base of - an arbitrary backing-store. We default to half the - address-space. */ -#define rbs_get_base(c,bspstore,rbs_basep) \ - (*(rbs_basep) = (bspstore) - (((unw_word_t) 1) << 63), 0) - -#endif /* IA64_LIBUNWIND_I_H */ diff --git a/src/pal/src/libunwind/include/tdep-ia64/rse.h b/src/pal/src/libunwind/include/tdep-ia64/rse.h deleted file mode 100644 index ee521a591..000000000 --- a/src/pal/src/libunwind/include/tdep-ia64/rse.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (C) 1998, 1999, 2002, 2003, 2005 Hewlett-Packard Co - * David Mosberger-Tang - * - * Register stack engine related helper functions. This file may be - * used in applications, so be careful about the name-space and give - * some consideration to non-GNU C compilers (though __inline__ is - * fine). - */ -#ifndef RSE_H -#define RSE_H - -#include - -static inline uint64_t -rse_slot_num (uint64_t addr) -{ - return (addr >> 3) & 0x3f; -} - -/* - * Return TRUE if ADDR is the address of an RNAT slot. - */ -static inline uint64_t -rse_is_rnat_slot (uint64_t addr) -{ - return rse_slot_num (addr) == 0x3f; -} - -/* - * Returns the address of the RNAT slot that covers the slot at - * address SLOT_ADDR. - */ -static inline uint64_t -rse_rnat_addr (uint64_t slot_addr) -{ - return slot_addr | (0x3f << 3); -} - -/* - * Calculate the number of registers in the dirty partition starting at - * BSPSTORE and ending at BSP. This isn't simply (BSP-BSPSTORE)/8 - * because every 64th slot stores ar.rnat. - */ -static inline uint64_t -rse_num_regs (uint64_t bspstore, uint64_t bsp) -{ - uint64_t slots = (bsp - bspstore) >> 3; - - return slots - (rse_slot_num(bspstore) + slots)/0x40; -} - -/* - * The inverse of the above: given bspstore and the number of - * registers, calculate ar.bsp. - */ -static inline uint64_t -rse_skip_regs (uint64_t addr, long num_regs) -{ - long delta = rse_slot_num(addr) + num_regs; - - if (num_regs < 0) - delta -= 0x3e; - return addr + ((num_regs + delta/0x3f) << 3); -} - -#endif /* RSE_H */ diff --git a/src/pal/src/libunwind/include/tdep-ia64/script.h b/src/pal/src/libunwind/include/tdep-ia64/script.h deleted file mode 100644 index fe3360bf5..000000000 --- a/src/pal/src/libunwind/include/tdep-ia64/script.h +++ /dev/null @@ -1,85 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2001-2002 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#define IA64_LOG_UNW_CACHE_SIZE 7 -#define IA64_UNW_CACHE_SIZE (1 << IA64_LOG_UNW_CACHE_SIZE) - -#define IA64_LOG_UNW_HASH_SIZE (IA64_LOG_UNW_CACHE_SIZE + 1) -#define IA64_UNW_HASH_SIZE (1 << IA64_LOG_UNW_HASH_SIZE) - -typedef unsigned char unw_hash_index_t; - -struct ia64_script_insn - { - unsigned int opc; /* see enum ia64_script_insn_opcode */ - unsigned int dst; - unw_word_t val; - }; - -/* Updating each preserved register may result in one script - instruction each. At the end of the script, psp gets popped, - accounting for one more instruction. */ -#define IA64_MAX_SCRIPT_LEN (IA64_NUM_PREGS + 1) - -struct ia64_script - { - unw_word_t ip; /* ip this script is for */ - unw_word_t pr_mask; /* mask of predicates script depends on */ - unw_word_t pr_val; /* predicate values this script is for */ - unw_proc_info_t pi; /* info about underlying procedure */ - unsigned short lru_chain; /* used for least-recently-used chain */ - unsigned short coll_chain; /* used for hash collisions */ - unsigned short hint; /* hint for next script to try (or -1) */ - unsigned short count; /* number of instructions in script */ - unsigned short abi_marker; - struct ia64_script_insn insn[IA64_MAX_SCRIPT_LEN]; - }; - -struct ia64_script_cache - { -#ifdef HAVE_ATOMIC_OPS_H - AO_TS_t busy; /* is the script-cache busy? */ -#else - pthread_mutex_t lock; -#endif - unsigned short lru_head; /* index of lead-recently used script */ - unsigned short lru_tail; /* index of most-recently used script */ - - /* hash table that maps instruction pointer to script index: */ - unsigned short hash[IA64_UNW_HASH_SIZE]; - - uint32_t generation; /* generation number */ - - /* script cache: */ - struct ia64_script buckets[IA64_UNW_CACHE_SIZE]; - }; - -#define ia64_cache_proc_info UNW_OBJ(cache_proc_info) -#define ia64_get_cached_proc_info UNW_OBJ(get_cached_proc_info) - -struct cursor; /* forward declaration */ - -extern int ia64_cache_proc_info (struct cursor *c); -extern int ia64_get_cached_proc_info (struct cursor *c); diff --git a/src/pal/src/libunwind/include/tdep-mips/dwarf-config.h b/src/pal/src/libunwind/include/tdep-mips/dwarf-config.h deleted file mode 100644 index 8006d0b8d..000000000 --- a/src/pal/src/libunwind/include/tdep-mips/dwarf-config.h +++ /dev/null @@ -1,54 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - Copyright (C) 2012 Tommi Rantala - -This file is part of libunwind. - -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. */ - -#ifndef dwarf_config_h -#define dwarf_config_h - -/* This is FIRST_PSEUDO_REGISTER in GCC, since DWARF_FRAME_REGISTERS is not - explicitly defined. */ -#define DWARF_NUM_PRESERVED_REGS 188 - -#define dwarf_to_unw_regnum(reg) (((reg) < 32) ? (reg) : 0) - -/* Return TRUE if the ADDR_SPACE uses big-endian byte-order. */ -#define dwarf_is_big_endian(addr_space) ((addr_space)->big_endian) - -/* Return the size of an address, for DWARF purposes. */ -#define dwarf_addr_size(addr_space) ((addr_space)->addr_size) - -/* Convert a pointer to a dwarf_cursor structure to a pointer to - unw_cursor_t. */ -#define dwarf_to_cursor(c) ((unw_cursor_t *) (c)) - -typedef struct dwarf_loc - { - unw_word_t val; -#ifndef UNW_LOCAL_ONLY - unw_word_t type; /* see DWARF_LOC_TYPE_* macros. */ -#endif - } -dwarf_loc_t; - -#endif /* dwarf_config_h */ diff --git a/src/pal/src/libunwind/include/tdep-mips/jmpbuf.h b/src/pal/src/libunwind/include/tdep-mips/jmpbuf.h deleted file mode 100644 index c099f9267..000000000 --- a/src/pal/src/libunwind/include/tdep-mips/jmpbuf.h +++ /dev/null @@ -1,32 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - -This file is part of libunwind. - -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. */ - -/* Use glibc's jump-buffer indices; NPTL peeks at SP: */ - -/* FIXME for MIPS! */ - -#define JB_SP 4 -#define JB_RP 5 -#define JB_MASK_SAVED 6 -#define JB_MASK 7 diff --git a/src/pal/src/libunwind/include/tdep-mips/libunwind_i.h b/src/pal/src/libunwind/include/tdep-mips/libunwind_i.h deleted file mode 100644 index 3fe40c0c0..000000000 --- a/src/pal/src/libunwind/include/tdep-mips/libunwind_i.h +++ /dev/null @@ -1,331 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - -This file is part of libunwind. - -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. */ - -#ifndef MIPS_LIBUNWIND_I_H -#define MIPS_LIBUNWIND_I_H - -/* Target-dependent definitions that are internal to libunwind but need - to be shared with target-independent code. */ - -#include -#include - -#if !defined(UNW_REMOTE_ONLY) && _MIPS_SIM == _ABI64 -# include "elf64.h" -#else -# include "elf32.h" -#endif -#include "mempool.h" -#include "dwarf.h" - -typedef struct - { - /* no mips-specific fast trace */ - } -unw_tdep_frame_t; - -struct unw_addr_space - { - struct unw_accessors acc; - - int big_endian; - mips_abi_t abi; - unsigned int addr_size; - - unw_caching_policy_t caching_policy; -#ifdef HAVE_ATOMIC_OPS_H - AO_t cache_generation; -#else - uint32_t cache_generation; -#endif - unw_word_t dyn_generation; /* see dyn-common.h */ - unw_word_t dyn_info_list_addr; /* (cached) dyn_info_list_addr */ - struct dwarf_rs_cache global_cache; - struct unw_debug_frame_list *debug_frames; -}; - -#define tdep_big_endian(as) ((as)->big_endian) - -struct cursor - { - struct dwarf_cursor dwarf; /* must be first */ - unw_word_t sigcontext_addr; - }; - -#define DWARF_GET_LOC(l) ((l).val) - -#ifndef UNW_REMOTE_ONLY -# if _MIPS_SIM == _ABIN32 -typedef long long mips_reg_t; -# else -typedef long mips_reg_t; -# endif -#endif - -#ifdef UNW_LOCAL_ONLY -# define DWARF_NULL_LOC DWARF_LOC (0, 0) -# define DWARF_IS_NULL_LOC(l) (DWARF_GET_LOC (l) == 0) -# define DWARF_LOC(r, t) ((dwarf_loc_t) { .val = (r) }) -# define DWARF_IS_REG_LOC(l) 0 -# define DWARF_REG_LOC(c,r) (DWARF_LOC((unw_word_t) (intptr_t) \ - tdep_uc_addr((c)->as_arg, (r)), 0)) -# define DWARF_MEM_LOC(c,m) DWARF_LOC ((m), 0) -# define DWARF_FPREG_LOC(c,r) (DWARF_LOC((unw_word_t) (intptr_t) \ - tdep_uc_addr((c)->as_arg, (r)), 0)) - -/* FIXME: Implement these for the MIPS FPU. */ -static inline int -dwarf_getfp (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t *val) -{ - if (!DWARF_GET_LOC (loc)) - return -1; - *val = *(unw_fpreg_t *) (intptr_t) DWARF_GET_LOC (loc); - return 0; -} - -static inline int -dwarf_putfp (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t val) -{ - if (!DWARF_GET_LOC (loc)) - return -1; - *(unw_fpreg_t *) (intptr_t) DWARF_GET_LOC (loc) = val; - return 0; -} - -static inline int -dwarf_get (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t *val) -{ - if (!DWARF_GET_LOC (loc)) - return -1; - *val = *(mips_reg_t *) (intptr_t) DWARF_GET_LOC (loc); - return 0; -} - -static inline int -dwarf_put (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t val) -{ - if (!DWARF_GET_LOC (loc)) - return -1; - *(mips_reg_t *) (intptr_t) DWARF_GET_LOC (loc) = val; - return 0; -} - -#else /* !UNW_LOCAL_ONLY */ -# define DWARF_LOC_TYPE_FP (1 << 0) -# define DWARF_LOC_TYPE_REG (1 << 1) -# define DWARF_NULL_LOC DWARF_LOC (0, 0) -# define DWARF_IS_NULL_LOC(l) \ - ({ dwarf_loc_t _l = (l); _l.val == 0 && _l.type == 0; }) -# define DWARF_LOC(r, t) ((dwarf_loc_t) { .val = (r), .type = (t) }) -# define DWARF_IS_REG_LOC(l) (((l).type & DWARF_LOC_TYPE_REG) != 0) -# define DWARF_IS_FP_LOC(l) (((l).type & DWARF_LOC_TYPE_FP) != 0) -# define DWARF_REG_LOC(c,r) DWARF_LOC((r), DWARF_LOC_TYPE_REG) -# define DWARF_MEM_LOC(c,m) DWARF_LOC ((m), 0) -# define DWARF_FPREG_LOC(c,r) DWARF_LOC((r), (DWARF_LOC_TYPE_REG \ - | DWARF_LOC_TYPE_FP)) - -static inline int -read_s32 (struct dwarf_cursor *c, unw_word_t addr, unw_word_t *val) -{ - int offset = addr & 4; - int ret; - unw_word_t memval; - - ret = (*c->as->acc.access_mem) (c->as, addr - offset, &memval, 0, c->as_arg); - if (ret < 0) - return ret; - - if ((offset != 0) == tdep_big_endian (c->as)) - *val = (int32_t) memval; - else - *val = (int32_t) (memval >> 32); - - return 0; -} - -static inline int -write_s32 (struct dwarf_cursor *c, unw_word_t addr, const unw_word_t *val) -{ - int offset = addr & 4; - int ret; - unw_word_t memval; - - ret = (*c->as->acc.access_mem) (c->as, addr - offset, &memval, 0, c->as_arg); - if (ret < 0) - return ret; - - if ((offset != 0) == tdep_big_endian (c->as)) - memval = (memval & ~0xffffffffLL) | (uint32_t) *val; - else - memval = (memval & 0xffffffffLL) | (uint32_t) (*val << 32); - - return (*c->as->acc.access_mem) (c->as, addr - offset, &memval, 1, c->as_arg); -} - -/* FIXME: Implement these for the MIPS FPU. */ -static inline int -dwarf_getfp (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t *val) -{ - char *valp = (char *) &val; - unw_word_t addr; - int ret; - - if (DWARF_IS_NULL_LOC (loc)) - return -UNW_EBADREG; - - if (DWARF_IS_REG_LOC (loc)) - return (*c->as->acc.access_fpreg) (c->as, DWARF_GET_LOC (loc), - val, 0, c->as_arg); - - addr = DWARF_GET_LOC (loc); - if ((ret = (*c->as->acc.access_mem) (c->as, addr + 0, (unw_word_t *) valp, - 0, c->as_arg)) < 0) - return ret; - - return (*c->as->acc.access_mem) (c->as, addr + 4, (unw_word_t *) valp + 1, 0, - c->as_arg); -} - -static inline int -dwarf_putfp (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t val) -{ - char *valp = (char *) &val; - unw_word_t addr; - int ret; - - if (DWARF_IS_NULL_LOC (loc)) - return -UNW_EBADREG; - - if (DWARF_IS_REG_LOC (loc)) - return (*c->as->acc.access_fpreg) (c->as, DWARF_GET_LOC (loc), - &val, 1, c->as_arg); - - addr = DWARF_GET_LOC (loc); - if ((ret = (*c->as->acc.access_mem) (c->as, addr + 0, (unw_word_t *) valp, - 1, c->as_arg)) < 0) - return ret; - - return (*c->as->acc.access_mem) (c->as, addr + 4, (unw_word_t *) valp + 1, - 1, c->as_arg); -} - -static inline int -dwarf_get (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t *val) -{ - if (DWARF_IS_NULL_LOC (loc)) - return -UNW_EBADREG; - - /* If a code-generator were to save a value of type unw_word_t in a - floating-point register, we would have to support this case. I - suppose it could happen with MMX registers, but does it really - happen? */ - assert (!DWARF_IS_FP_LOC (loc)); - - if (DWARF_IS_REG_LOC (loc)) - return (*c->as->acc.access_reg) (c->as, DWARF_GET_LOC (loc), val, - 0, c->as_arg); - else if (c->as->abi == UNW_MIPS_ABI_O32) - return read_s32 (c, DWARF_GET_LOC (loc), val); - else - return (*c->as->acc.access_mem) (c->as, DWARF_GET_LOC (loc), val, - 0, c->as_arg); -} - -static inline int -dwarf_put (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t val) -{ - if (DWARF_IS_NULL_LOC (loc)) - return -UNW_EBADREG; - - /* If a code-generator were to save a value of type unw_word_t in a - floating-point register, we would have to support this case. I - suppose it could happen with MMX registers, but does it really - happen? */ - assert (!DWARF_IS_FP_LOC (loc)); - - if (DWARF_IS_REG_LOC (loc)) - return (*c->as->acc.access_reg) (c->as, DWARF_GET_LOC (loc), &val, - 1, c->as_arg); - else if (c->as->abi == UNW_MIPS_ABI_O32) - return write_s32 (c, DWARF_GET_LOC (loc), &val); - else - return (*c->as->acc.access_mem) (c->as, DWARF_GET_LOC (loc), &val, - 1, c->as_arg); -} - -#endif /* !UNW_LOCAL_ONLY */ - -#define tdep_getcontext_trace unw_getcontext -#define tdep_init_done UNW_OBJ(init_done) -#define tdep_init UNW_OBJ(init) -/* Platforms that support UNW_INFO_FORMAT_TABLE need to define - tdep_search_unwind_table. */ -#define tdep_search_unwind_table dwarf_search_unwind_table -#define tdep_find_unwind_table dwarf_find_unwind_table -#define tdep_uc_addr UNW_ARCH_OBJ(uc_addr) -#define tdep_get_elf_image UNW_ARCH_OBJ(get_elf_image) -#define tdep_get_exe_image_path UNW_ARCH_OBJ(get_exe_image_path) -#define tdep_access_reg UNW_OBJ(access_reg) -#define tdep_access_fpreg UNW_OBJ(access_fpreg) -#define tdep_fetch_frame(c,ip,n) do {} while(0) -#define tdep_cache_frame(c) 0 -#define tdep_reuse_frame(c,frame) do {} while(0) -#define tdep_stash_frame(c,rs) do {} while(0) -#define tdep_trace(cur,addr,n) (-UNW_ENOINFO) - -#ifdef UNW_LOCAL_ONLY -# define tdep_find_proc_info(c,ip,n) \ - dwarf_find_proc_info((c)->as, (ip), &(c)->pi, (n), \ - (c)->as_arg) -# define tdep_put_unwind_info(as,pi,arg) \ - dwarf_put_unwind_info((as), (pi), (arg)) -#else -# define tdep_find_proc_info(c,ip,n) \ - (*(c)->as->acc.find_proc_info)((c)->as, (ip), &(c)->pi, (n), \ - (c)->as_arg) -# define tdep_put_unwind_info(as,pi,arg) \ - (*(as)->acc.put_unwind_info)((as), (pi), (arg)) -#endif - -#define tdep_get_as(c) ((c)->dwarf.as) -#define tdep_get_as_arg(c) ((c)->dwarf.as_arg) -#define tdep_get_ip(c) ((c)->dwarf.ip) - -extern int tdep_init_done; - -extern void tdep_init (void); -extern int tdep_search_unwind_table (unw_addr_space_t as, unw_word_t ip, - unw_dyn_info_t *di, unw_proc_info_t *pi, - int need_unwind_info, void *arg); -extern void *tdep_uc_addr (ucontext_t *uc, int reg); -extern int tdep_get_elf_image (struct elf_image *ei, pid_t pid, unw_word_t ip, - unsigned long *segbase, unsigned long *mapoff, - char *path, size_t pathlen); -extern void tdep_get_exe_image_path (char *path); -extern int tdep_access_reg (struct cursor *c, unw_regnum_t reg, - unw_word_t *valp, int write); -extern int tdep_access_fpreg (struct cursor *c, unw_regnum_t reg, - unw_fpreg_t *valp, int write); - -#endif /* MIPS_LIBUNWIND_I_H */ diff --git a/src/pal/src/libunwind/include/tdep-ppc32/dwarf-config.h b/src/pal/src/libunwind/include/tdep-ppc32/dwarf-config.h deleted file mode 100644 index bf6886b06..000000000 --- a/src/pal/src/libunwind/include/tdep-ppc32/dwarf-config.h +++ /dev/null @@ -1,56 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2006-2007 IBM - Contributed by - Corey Ashford - Jose Flavio Aguilar Paulino - - Copied from libunwind-x86_64.h, modified slightly for building - frysk successfully on ppc64, by Wu Zhou - Will be replaced when libunwind is ready on ppc64 platform. - -This file is part of libunwind. - -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. */ - -#ifndef dwarf_config_h -#define dwarf_config_h - -/* For PPC64, 48 GPRs + 33 FPRs + 33 AltiVec + 1 SPE */ -#define DWARF_NUM_PRESERVED_REGS 115 - -#define DWARF_REGNUM_MAP_LENGTH 115 - -/* Return TRUE if the ADDR_SPACE uses big-endian byte-order. */ -#define dwarf_is_big_endian(addr_space) 1 - -/* Convert a pointer to a dwarf_cursor structure to a pointer to - unw_cursor_t. */ -#define dwarf_to_cursor(c) ((unw_cursor_t *) (c)) - -typedef struct dwarf_loc - { - unw_word_t val; -#ifndef UNW_LOCAL_ONLY - unw_word_t type; /* see X86_LOC_TYPE_* macros. */ -#endif - } -dwarf_loc_t; - -#endif /* dwarf_config_h */ diff --git a/src/pal/src/libunwind/include/tdep-ppc32/jmpbuf.h b/src/pal/src/libunwind/include/tdep-ppc32/jmpbuf.h deleted file mode 100644 index 861e94d97..000000000 --- a/src/pal/src/libunwind/include/tdep-ppc32/jmpbuf.h +++ /dev/null @@ -1,37 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2006-2007 IBM - Contributed by - Corey Ashford - Jose Flavio Aguilar Paulino - - Copied from libunwind-x86_64.h, modified slightly for building - frysk successfully on ppc64, by Wu Zhou - Will be replaced when libunwind is ready on ppc64 platform. - -This file is part of libunwind. - -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. */ - -/* Use glibc's jump-buffer indices; NPTL peeks at SP: */ - -#define JB_SP 6 -#define JB_RP 7 -#define JB_MASK_SAVED 8 -#define JB_MASK 9 diff --git a/src/pal/src/libunwind/include/tdep-ppc32/libunwind_i.h b/src/pal/src/libunwind/include/tdep-ppc32/libunwind_i.h deleted file mode 100644 index 4cf6d135f..000000000 --- a/src/pal/src/libunwind/include/tdep-ppc32/libunwind_i.h +++ /dev/null @@ -1,314 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2006-2007 IBM - Contributed by - Corey Ashford - Jose Flavio Aguilar Paulino - - Copied from libunwind-x86_64.h, modified slightly for building - frysk successfully on ppc64, by Wu Zhou - Will be replaced when libunwind is ready on ppc64 platform. - -This file is part of libunwind. - -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. */ - -#ifndef PPC32_LIBUNWIND_I_H -#define PPC32_LIBUNWIND_I_H - -/* Target-dependent definitions that are internal to libunwind but need - to be shared with target-independent code. */ - -#include -#include - -#include "elf32.h" -#include "mempool.h" -#include "dwarf.h" - -typedef struct - { - /* no ppc32-specific fast trace */ - } -unw_tdep_frame_t; - -struct unw_addr_space -{ - struct unw_accessors acc; - unw_caching_policy_t caching_policy; -#ifdef HAVE_ATOMIC_OPS_H - AO_t cache_generation; -#else - uint32_t cache_generation; -#endif - unw_word_t dyn_generation; /* see dyn-common.h */ - unw_word_t dyn_info_list_addr; /* (cached) dyn_info_list_addr */ - struct dwarf_rs_cache global_cache; - struct unw_debug_frame_list *debug_frames; - int validate; -}; - -struct cursor -{ - struct dwarf_cursor dwarf; /* must be first */ - - /* Format of sigcontext structure and address at which it is - stored: */ - enum - { - PPC_SCF_NONE, /* no signal frame encountered */ - PPC_SCF_LINUX_RT_SIGFRAME /* POSIX ucontext_t */ - } - sigcontext_format; - unw_word_t sigcontext_addr; -}; - -#define DWARF_GET_LOC(l) ((l).val) - -#ifdef UNW_LOCAL_ONLY -# define DWARF_NULL_LOC DWARF_LOC (0, 0) -# define DWARF_IS_NULL_LOC(l) (DWARF_GET_LOC (l) == 0) -# define DWARF_LOC(r, t) ((dwarf_loc_t) { .val = (r) }) -# define DWARF_IS_REG_LOC(l) 0 -# define DWARF_IS_FP_LOC(l) 0 -# define DWARF_IS_V_LOC(l) 0 -# define DWARF_MEM_LOC(c,m) DWARF_LOC ((m), 0) -# define DWARF_REG_LOC(c,r) (DWARF_LOC((unw_word_t) \ - tdep_uc_addr((c)->as_arg, (r)), 0)) -# define DWARF_FPREG_LOC(c,r) (DWARF_LOC((unw_word_t) \ - tdep_uc_addr((c)->as_arg, (r)), 0)) -# define DWARF_VREG_LOC(c,r) (DWARF_LOC((unw_word_t) \ - tdep_uc_addr((c)->as_arg, (r)), 0)) -#else /* !UNW_LOCAL_ONLY */ - -# define DWARF_LOC_TYPE_FP (1 << 0) -# define DWARF_LOC_TYPE_REG (1 << 1) -# define DWARF_LOC_TYPE_V (1 << 2) -# define DWARF_NULL_LOC DWARF_LOC (0, 0) -# define DWARF_IS_NULL_LOC(l) \ - ({ dwarf_loc_t _l = (l); _l.val == 0 && _l.type == 0; }) -# define DWARF_LOC(r, t) ((dwarf_loc_t) { .val = (r), .type = (t) }) -# define DWARF_IS_REG_LOC(l) (((l).type & DWARF_LOC_TYPE_REG) != 0) -# define DWARF_IS_FP_LOC(l) (((l).type & DWARF_LOC_TYPE_FP) != 0) -# define DWARF_IS_V_LOC(l) (((l).type & DWARF_LOC_TYPE_V) != 0) -# define DWARF_MEM_LOC(c,m) DWARF_LOC ((m), 0) -# define DWARF_REG_LOC(c,r) DWARF_LOC((r), DWARF_LOC_TYPE_REG) -# define DWARF_FPREG_LOC(c,r) DWARF_LOC((r), (DWARF_LOC_TYPE_REG \ - | DWARF_LOC_TYPE_FP)) -# define DWARF_VREG_LOC(c,r) DWARF_LOC((r), (DWARF_LOC_TYPE_REG \ - | DWARF_LOC_TYPE_V)) - -#endif /* !UNW_LOCAL_ONLY */ - -static inline int -dwarf_getvr (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t * val) -{ - unw_word_t *valp = (unw_word_t *) val; - unw_word_t addr; - int ret; - - if (DWARF_IS_NULL_LOC (loc)) - return -UNW_EBADREG; - - assert (DWARF_IS_V_LOC (loc)); - assert (!DWARF_IS_FP_LOC (loc)); - - if (DWARF_IS_REG_LOC (loc)) - return (*c->as->acc.access_fpreg) (c->as, DWARF_GET_LOC (loc), - val, 0, c->as_arg); - - addr = DWARF_GET_LOC (loc); - - if ((ret = (*c->as->acc.access_mem) (c->as, addr + 0, valp, - 0, c->as_arg)) < 0) - return ret; - - return (*c->as->acc.access_mem) (c->as, addr + 8, valp + 1, 0, c->as_arg); -} - -static inline int -dwarf_putvr (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t val) -{ - unw_word_t *valp = (unw_word_t *) & val; - unw_word_t addr; - int ret; - - if (DWARF_IS_NULL_LOC (loc)) - return -UNW_EBADREG; - - assert (DWARF_IS_V_LOC (loc)); - assert (!DWARF_IS_FP_LOC (loc)); - - if (DWARF_IS_REG_LOC (loc)) - return (*c->as->acc.access_fpreg) (c->as, DWARF_GET_LOC (loc), - &val, 1, c->as_arg); - - addr = DWARF_GET_LOC (loc); - if ((ret = (*c->as->acc.access_mem) (c->as, addr + 0, valp, - 1, c->as_arg)) < 0) - return ret; - - return (*c->as->acc.access_mem) (c->as, addr + 8, valp + 1, 1, c->as_arg); -} - -static inline int -dwarf_getfp (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t * val) -{ - unw_word_t *valp = (unw_word_t *) val; - unw_word_t addr; - - if (DWARF_IS_NULL_LOC (loc)) - return -UNW_EBADREG; - - assert (DWARF_IS_FP_LOC (loc)); - assert (!DWARF_IS_V_LOC (loc)); - - if (DWARF_IS_REG_LOC (loc)) - return (*c->as->acc.access_fpreg) (c->as, DWARF_GET_LOC (loc), - val, 0, c->as_arg); - - addr = DWARF_GET_LOC (loc); - return (*c->as->acc.access_mem) (c->as, addr + 0, valp, 0, c->as_arg); - -} - -static inline int -dwarf_putfp (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t val) -{ - unw_word_t *valp = (unw_word_t *) & val; - unw_word_t addr; - - if (DWARF_IS_NULL_LOC (loc)) - return -UNW_EBADREG; - - assert (DWARF_IS_FP_LOC (loc)); - assert (!DWARF_IS_V_LOC (loc)); - - if (DWARF_IS_REG_LOC (loc)) - return (*c->as->acc.access_fpreg) (c->as, DWARF_GET_LOC (loc), - &val, 1, c->as_arg); - - addr = DWARF_GET_LOC (loc); - - return (*c->as->acc.access_mem) (c->as, addr + 0, valp, 1, c->as_arg); -} - -static inline int -dwarf_get (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t * val) -{ - if (DWARF_IS_NULL_LOC (loc)) - return -UNW_EBADREG; - - /* If a code-generator were to save a value of type unw_word_t in a - floating-point register, we would have to support this case. I - suppose it could happen with MMX registers, but does it really - happen? */ - assert (!DWARF_IS_FP_LOC (loc)); - assert (!DWARF_IS_V_LOC (loc)); - - if (DWARF_IS_REG_LOC (loc)) - return (*c->as->acc.access_reg) (c->as, DWARF_GET_LOC (loc), val, - 0, c->as_arg); - else - return (*c->as->acc.access_mem) (c->as, DWARF_GET_LOC (loc), val, - 0, c->as_arg); -} - -static inline int -dwarf_put (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t val) -{ - if (DWARF_IS_NULL_LOC (loc)) - return -UNW_EBADREG; - - /* If a code-generator were to save a value of type unw_word_t in a - floating-point register, we would have to support this case. I - suppose it could happen with MMX registers, but does it really - happen? */ - assert (!DWARF_IS_FP_LOC (loc)); - assert (!DWARF_IS_V_LOC (loc)); - - if (DWARF_IS_REG_LOC (loc)) - return (*c->as->acc.access_reg) (c->as, DWARF_GET_LOC (loc), &val, - 1, c->as_arg); - else - return (*c->as->acc.access_mem) (c->as, DWARF_GET_LOC (loc), &val, - 1, c->as_arg); -} - -#define tdep_getcontext_trace unw_getcontext -#define tdep_init_done UNW_OBJ(init_done) -#define tdep_init UNW_OBJ(init) -/* Platforms that support UNW_INFO_FORMAT_TABLE need to define - tdep_search_unwind_table. */ -#define tdep_search_unwind_table dwarf_search_unwind_table -#define tdep_find_unwind_table dwarf_find_unwind_table -#define tdep_uc_addr UNW_ARCH_OBJ(uc_addr) -#define tdep_get_elf_image UNW_ARCH_OBJ(get_elf_image) -#define tdep_get_exe_image_path UNW_ARCH_OBJ(get_exe_image_path) -#define tdep_access_reg UNW_OBJ(access_reg) -#define tdep_access_fpreg UNW_OBJ(access_fpreg) -#define tdep_fetch_frame(c,ip,n) do {} while(0) -#define tdep_cache_frame(c) 0 -#define tdep_reuse_frame(c,frame) do {} while(0) -#define tdep_stash_frame(c,rs) do {} while(0) -#define tdep_trace(cur,addr,n) (-UNW_ENOINFO) -#define tdep_get_func_addr UNW_OBJ(get_func_addr) - -#ifdef UNW_LOCAL_ONLY -# define tdep_find_proc_info(c,ip,n) \ - dwarf_find_proc_info((c)->as, (ip), &(c)->pi, (n), \ - (c)->as_arg) -# define tdep_put_unwind_info(as,pi,arg) \ - dwarf_put_unwind_info((as), (pi), (arg)) -#else -# define tdep_find_proc_info(c,ip,n) \ - (*(c)->as->acc.find_proc_info)((c)->as, (ip), &(c)->pi, (n), \ - (c)->as_arg) -# define tdep_put_unwind_info(as,pi,arg) \ - (*(as)->acc.put_unwind_info)((as), (pi), (arg)) -#endif - -extern int tdep_fetch_proc_info_post (struct dwarf_cursor *c, unw_word_t ip, - int need_unwind_info); - -#define tdep_get_as(c) ((c)->dwarf.as) -#define tdep_get_as_arg(c) ((c)->dwarf.as_arg) -#define tdep_get_ip(c) ((c)->dwarf.ip) -#define tdep_big_endian(as) 1 - -extern int tdep_init_done; - -extern void tdep_init (void); -extern int tdep_search_unwind_table (unw_addr_space_t as, unw_word_t ip, - unw_dyn_info_t * di, - unw_proc_info_t * pi, - int need_unwind_info, void *arg); -extern void *tdep_uc_addr (ucontext_t * uc, int reg); -extern int tdep_get_elf_image (struct elf_image *ei, pid_t pid, unw_word_t ip, - unsigned long *segbase, unsigned long *mapoff, - char *path, size_t pathlen); -extern void tdep_get_exe_image_path (char *path); -extern int tdep_access_reg (struct cursor *c, unw_regnum_t reg, - unw_word_t * valp, int write); -extern int tdep_access_fpreg (struct cursor *c, unw_regnum_t reg, - unw_fpreg_t * valp, int write); -extern int tdep_get_func_addr (unw_addr_space_t as, unw_word_t addr, - unw_word_t *entry_point); - -#endif /* PPC64_LIBUNWIND_I_H */ diff --git a/src/pal/src/libunwind/include/tdep-ppc64/dwarf-config.h b/src/pal/src/libunwind/include/tdep-ppc64/dwarf-config.h deleted file mode 100644 index 6d8ef0a94..000000000 --- a/src/pal/src/libunwind/include/tdep-ppc64/dwarf-config.h +++ /dev/null @@ -1,56 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2006-2007 IBM - Contributed by - Corey Ashford - Jose Flavio Aguilar Paulino - - Copied from libunwind-x86_64.h, modified slightly for building - frysk successfully on ppc64, by Wu Zhou - Will be replaced when libunwind is ready on ppc64 platform. - -This file is part of libunwind. - -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. */ - -#ifndef dwarf_config_h -#define dwarf_config_h - -/* For PPC64, 48 GPRs + 33 FPRs + 33 AltiVec + 1 SPE */ -#define DWARF_NUM_PRESERVED_REGS 115 - -#define DWARF_REGNUM_MAP_LENGTH 115 - -/* Return TRUE if the ADDR_SPACE uses big-endian byte-order. */ -#define dwarf_is_big_endian(addr_space) ((addr_space)->big_endian) - -/* Convert a pointer to a dwarf_cursor structure to a pointer to - unw_cursor_t. */ -#define dwarf_to_cursor(c) ((unw_cursor_t *) (c)) - -typedef struct dwarf_loc - { - unw_word_t val; -#ifndef UNW_LOCAL_ONLY - unw_word_t type; /* see X86_LOC_TYPE_* macros. */ -#endif - } -dwarf_loc_t; - -#endif /* dwarf_config_h */ diff --git a/src/pal/src/libunwind/include/tdep-ppc64/jmpbuf.h b/src/pal/src/libunwind/include/tdep-ppc64/jmpbuf.h deleted file mode 100644 index 861e94d97..000000000 --- a/src/pal/src/libunwind/include/tdep-ppc64/jmpbuf.h +++ /dev/null @@ -1,37 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2006-2007 IBM - Contributed by - Corey Ashford - Jose Flavio Aguilar Paulino - - Copied from libunwind-x86_64.h, modified slightly for building - frysk successfully on ppc64, by Wu Zhou - Will be replaced when libunwind is ready on ppc64 platform. - -This file is part of libunwind. - -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. */ - -/* Use glibc's jump-buffer indices; NPTL peeks at SP: */ - -#define JB_SP 6 -#define JB_RP 7 -#define JB_MASK_SAVED 8 -#define JB_MASK 9 diff --git a/src/pal/src/libunwind/include/tdep-ppc64/libunwind_i.h b/src/pal/src/libunwind/include/tdep-ppc64/libunwind_i.h deleted file mode 100644 index 975f3bb36..000000000 --- a/src/pal/src/libunwind/include/tdep-ppc64/libunwind_i.h +++ /dev/null @@ -1,369 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2006-2007 IBM - Contributed by - Corey Ashford - Jose Flavio Aguilar Paulino - - Copied from libunwind-x86_64.h, modified slightly for building - frysk successfully on ppc64, by Wu Zhou - Will be replaced when libunwind is ready on ppc64 platform. - -This file is part of libunwind. - -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. */ - -#ifndef PPC64_LIBUNWIND_I_H -#define PPC64_LIBUNWIND_I_H - -/* Target-dependent definitions that are internal to libunwind but need - to be shared with target-independent code. */ - -#include -#include - -#include "elf64.h" -#include "mempool.h" -#include "dwarf.h" - -typedef struct - { - /* no ppc64-specific fast trace */ - } -unw_tdep_frame_t; - -struct unw_addr_space -{ - struct unw_accessors acc; - int big_endian; - ppc64_abi_t abi; - unw_caching_policy_t caching_policy; -#ifdef HAVE_ATOMIC_OPS_H - AO_t cache_generation; -#else - uint32_t cache_generation; -#endif - unw_word_t dyn_generation; /* see dyn-common.h */ - unw_word_t dyn_info_list_addr; /* (cached) dyn_info_list_addr */ - struct dwarf_rs_cache global_cache; - struct unw_debug_frame_list *debug_frames; - int validate; -}; - -struct cursor -{ - struct dwarf_cursor dwarf; /* must be first */ - - /* Format of sigcontext structure and address at which it is - stored: */ - enum - { - PPC_SCF_NONE, /* no signal frame encountered */ - PPC_SCF_LINUX_RT_SIGFRAME /* POSIX ucontext_t */ - } - sigcontext_format; - unw_word_t sigcontext_addr; -}; - -#define DWARF_GET_LOC(l) ((l).val) - -#ifdef UNW_LOCAL_ONLY -# define DWARF_NULL_LOC DWARF_LOC (0, 0) -# define DWARF_IS_NULL_LOC(l) (DWARF_GET_LOC (l) == 0) -# define DWARF_LOC(r, t) ((dwarf_loc_t) { .val = (r) }) -# define DWARF_IS_REG_LOC(l) 0 -# define DWARF_REG_LOC(c,r) (DWARF_LOC((unw_word_t) \ - tdep_uc_addr((c)->as_arg, (r)), 0)) -# define DWARF_MEM_LOC(c,m) DWARF_LOC ((m), 0) -# define DWARF_FPREG_LOC(c,r) (DWARF_LOC((unw_word_t) \ - tdep_uc_addr((c)->as_arg, (r)), 0)) -# define DWARF_VREG_LOC(c,r) (DWARF_LOC((unw_word_t) \ - tdep_uc_addr((c)->as_arg, (r)), 0)) - -static inline int -dwarf_getvr (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t * val) -{ - if (!DWARF_GET_LOC (loc)) - return -1; - *val = *(unw_fpreg_t *) DWARF_GET_LOC (loc); - return 0; -} - -static inline int -dwarf_putvr (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t val) -{ - if (!DWARF_GET_LOC (loc)) - return -1; - *(unw_fpreg_t *) DWARF_GET_LOC (loc) = val; - return 0; -} - -static inline int -dwarf_getfp (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t *val) -{ - if (!DWARF_GET_LOC (loc)) - return -1; - *val = *(unw_fpreg_t *) DWARF_GET_LOC (loc); - return 0; -} - -static inline int -dwarf_putfp (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t val) -{ - if (!DWARF_GET_LOC (loc)) - return -1; - *(unw_fpreg_t *) DWARF_GET_LOC (loc) = val; - return 0; -} - -static inline int -dwarf_get (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t *val) -{ - if (!DWARF_GET_LOC (loc)) - return -1; - *val = *(unw_word_t *) DWARF_GET_LOC (loc); - return 0; -} - -static inline int -dwarf_put (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t val) -{ - if (!DWARF_GET_LOC (loc)) - return -1; - *(unw_word_t *) DWARF_GET_LOC (loc) = val; - return 0; -} - -#else /* !UNW_LOCAL_ONLY */ - -# define DWARF_LOC_TYPE_FP (1 << 0) -# define DWARF_LOC_TYPE_REG (1 << 1) -# define DWARF_LOC_TYPE_V (1 << 2) -# define DWARF_NULL_LOC DWARF_LOC (0, 0) -# define DWARF_IS_NULL_LOC(l) \ - ({ dwarf_loc_t _l = (l); _l.val == 0 && _l.type == 0; }) -# define DWARF_LOC(r, t) ((dwarf_loc_t) { .val = (r), .type = (t) }) -# define DWARF_IS_REG_LOC(l) (((l).type & DWARF_LOC_TYPE_REG) != 0) -# define DWARF_IS_FP_LOC(l) (((l).type & DWARF_LOC_TYPE_FP) != 0) -# define DWARF_IS_V_LOC(l) (((l).type & DWARF_LOC_TYPE_V) != 0) -# define DWARF_MEM_LOC(c,m) DWARF_LOC ((m), 0) -# define DWARF_REG_LOC(c,r) DWARF_LOC((r), DWARF_LOC_TYPE_REG) -# define DWARF_FPREG_LOC(c,r) DWARF_LOC((r), (DWARF_LOC_TYPE_REG \ - | DWARF_LOC_TYPE_FP)) -# define DWARF_VREG_LOC(c,r) DWARF_LOC((r), (DWARF_LOC_TYPE_REG \ - | DWARF_LOC_TYPE_V)) - -static inline int -dwarf_getvr (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t * val) -{ - unw_word_t *valp = (unw_word_t *) val; - unw_word_t addr; - int ret; - - if (DWARF_IS_NULL_LOC (loc)) - return -UNW_EBADREG; - - assert (DWARF_IS_V_LOC (loc)); - assert (!DWARF_IS_FP_LOC (loc)); - - if (DWARF_IS_REG_LOC (loc)) - return (*c->as->acc.access_fpreg) (c->as, DWARF_GET_LOC (loc), - val, 0, c->as_arg); - - addr = DWARF_GET_LOC (loc); - - if ((ret = (*c->as->acc.access_mem) (c->as, addr + 0, valp, - 0, c->as_arg)) < 0) - return ret; - - return (*c->as->acc.access_mem) (c->as, addr + 8, valp + 1, 0, c->as_arg); -} - -static inline int -dwarf_putvr (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t val) -{ - unw_word_t *valp = (unw_word_t *) & val; - unw_word_t addr; - int ret; - - if (DWARF_IS_NULL_LOC (loc)) - return -UNW_EBADREG; - - assert (DWARF_IS_V_LOC (loc)); - assert (!DWARF_IS_FP_LOC (loc)); - - if (DWARF_IS_REG_LOC (loc)) - return (*c->as->acc.access_fpreg) (c->as, DWARF_GET_LOC (loc), - &val, 1, c->as_arg); - - addr = DWARF_GET_LOC (loc); - if ((ret = (*c->as->acc.access_mem) (c->as, addr + 0, valp, - 1, c->as_arg)) < 0) - return ret; - - return (*c->as->acc.access_mem) (c->as, addr + 8, valp + 1, 1, c->as_arg); -} - -static inline int -dwarf_getfp (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t * val) -{ - unw_word_t *valp = (unw_word_t *) val; - unw_word_t addr; - - if (DWARF_IS_NULL_LOC (loc)) - return -UNW_EBADREG; - - assert (DWARF_IS_FP_LOC (loc)); - assert (!DWARF_IS_V_LOC (loc)); - - if (DWARF_IS_REG_LOC (loc)) - return (*c->as->acc.access_fpreg) (c->as, DWARF_GET_LOC (loc), - val, 0, c->as_arg); - - addr = DWARF_GET_LOC (loc); - return (*c->as->acc.access_mem) (c->as, addr + 0, valp, 0, c->as_arg); - -} - -static inline int -dwarf_putfp (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t val) -{ - unw_word_t *valp = (unw_word_t *) & val; - unw_word_t addr; - - if (DWARF_IS_NULL_LOC (loc)) - return -UNW_EBADREG; - - assert (DWARF_IS_FP_LOC (loc)); - assert (!DWARF_IS_V_LOC (loc)); - - if (DWARF_IS_REG_LOC (loc)) - return (*c->as->acc.access_fpreg) (c->as, DWARF_GET_LOC (loc), - &val, 1, c->as_arg); - - addr = DWARF_GET_LOC (loc); - - return (*c->as->acc.access_mem) (c->as, addr + 0, valp, 1, c->as_arg); -} - -static inline int -dwarf_get (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t * val) -{ - if (DWARF_IS_NULL_LOC (loc)) - return -UNW_EBADREG; - - /* If a code-generator were to save a value of type unw_word_t in a - floating-point register, we would have to support this case. I - suppose it could happen with MMX registers, but does it really - happen? */ - assert (!DWARF_IS_FP_LOC (loc)); - assert (!DWARF_IS_V_LOC (loc)); - - if (DWARF_IS_REG_LOC (loc)) - return (*c->as->acc.access_reg) (c->as, DWARF_GET_LOC (loc), val, - 0, c->as_arg); - else - return (*c->as->acc.access_mem) (c->as, DWARF_GET_LOC (loc), val, - 0, c->as_arg); -} - -static inline int -dwarf_put (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t val) -{ - if (DWARF_IS_NULL_LOC (loc)) - return -UNW_EBADREG; - - /* If a code-generator were to save a value of type unw_word_t in a - floating-point register, we would have to support this case. I - suppose it could happen with MMX registers, but does it really - happen? */ - assert (!DWARF_IS_FP_LOC (loc)); - assert (!DWARF_IS_V_LOC (loc)); - - if (DWARF_IS_REG_LOC (loc)) - return (*c->as->acc.access_reg) (c->as, DWARF_GET_LOC (loc), &val, - 1, c->as_arg); - else - return (*c->as->acc.access_mem) (c->as, DWARF_GET_LOC (loc), &val, - 1, c->as_arg); -} - -#endif /* !UNW_LOCAL_ONLY */ - -#define tdep_getcontext_trace unw_getcontext -#define tdep_init_done UNW_OBJ(init_done) -#define tdep_init UNW_OBJ(init) -/* Platforms that support UNW_INFO_FORMAT_TABLE need to define - tdep_search_unwind_table. */ -#define tdep_search_unwind_table dwarf_search_unwind_table -#define tdep_find_unwind_table dwarf_find_unwind_table -#define tdep_uc_addr UNW_ARCH_OBJ(uc_addr) -#define tdep_get_elf_image UNW_ARCH_OBJ(get_elf_image) -#define tdep_get_exe_image_path UNW_ARCH_OBJ(get_exe_image_path) -#define tdep_access_reg UNW_OBJ(access_reg) -#define tdep_access_fpreg UNW_OBJ(access_fpreg) -#define tdep_fetch_frame(c,ip,n) do {} while(0) -#define tdep_cache_frame(c) 0 -#define tdep_reuse_frame(c,frame) do {} while(0) -#define tdep_stash_frame(c,rs) do {} while(0) -#define tdep_trace(cur,addr,n) (-UNW_ENOINFO) -#define tdep_get_func_addr UNW_OBJ(get_func_addr) - -#ifdef UNW_LOCAL_ONLY -# define tdep_find_proc_info(c,ip,n) \ - dwarf_find_proc_info((c)->as, (ip), &(c)->pi, (n), \ - (c)->as_arg) -# define tdep_put_unwind_info(as,pi,arg) \ - dwarf_put_unwind_info((as), (pi), (arg)) -#else -# define tdep_find_proc_info(c,ip,n) \ - (*(c)->as->acc.find_proc_info)((c)->as, (ip), &(c)->pi, (n), \ - (c)->as_arg) -# define tdep_put_unwind_info(as,pi,arg) \ - (*(as)->acc.put_unwind_info)((as), (pi), (arg)) -#endif - -extern int tdep_fetch_proc_info_post (struct dwarf_cursor *c, unw_word_t ip, - int need_unwind_info); - -#define tdep_get_as(c) ((c)->dwarf.as) -#define tdep_get_as_arg(c) ((c)->dwarf.as_arg) -#define tdep_get_ip(c) ((c)->dwarf.ip) -#define tdep_big_endian(as) ((as)->big_endian) - -extern int tdep_init_done; - -extern void tdep_init (void); -extern int tdep_search_unwind_table (unw_addr_space_t as, unw_word_t ip, - unw_dyn_info_t * di, - unw_proc_info_t * pi, - int need_unwind_info, void *arg); -extern void *tdep_uc_addr (ucontext_t * uc, int reg); -extern int tdep_get_elf_image (struct elf_image *ei, pid_t pid, unw_word_t ip, - unsigned long *segbase, unsigned long *mapoff, - char *path, size_t pathlen); -extern void tdep_get_exe_image_path (char *path); -extern int tdep_access_reg (struct cursor *c, unw_regnum_t reg, - unw_word_t * valp, int write); -extern int tdep_access_fpreg (struct cursor *c, unw_regnum_t reg, - unw_fpreg_t * valp, int write); -extern int tdep_get_func_addr (unw_addr_space_t as, unw_word_t addr, - unw_word_t *entry_point); - -#endif /* PPC64_LIBUNWIND_I_H */ diff --git a/src/pal/src/libunwind/include/tdep-sh/dwarf-config.h b/src/pal/src/libunwind/include/tdep-sh/dwarf-config.h deleted file mode 100644 index 2f76f5be7..000000000 --- a/src/pal/src/libunwind/include/tdep-sh/dwarf-config.h +++ /dev/null @@ -1,49 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - Copyright (C) 2012 Tommi Rantala - -This file is part of libunwind. - -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. */ - -#ifndef dwarf_config_h -#define dwarf_config_h - -#define DWARF_NUM_PRESERVED_REGS 18 - -#define dwarf_to_unw_regnum(reg) (((reg) <= UNW_SH_PR) ? (reg) : 0) - -/* Return TRUE if the ADDR_SPACE uses big-endian byte-order. */ -#define dwarf_is_big_endian(addr_space) ((addr_space)->big_endian) - -/* Convert a pointer to a dwarf_cursor structure to a pointer to - unw_cursor_t. */ -#define dwarf_to_cursor(c) ((unw_cursor_t *) (c)) - -typedef struct dwarf_loc - { - unw_word_t val; -#ifndef UNW_LOCAL_ONLY - unw_word_t type; /* see DWARF_LOC_TYPE_* macros. */ -#endif - } -dwarf_loc_t; - -#endif /* dwarf_config_h */ diff --git a/src/pal/src/libunwind/include/tdep-sh/jmpbuf.h b/src/pal/src/libunwind/include/tdep-sh/jmpbuf.h deleted file mode 100644 index 8b44b5b21..000000000 --- a/src/pal/src/libunwind/include/tdep-sh/jmpbuf.h +++ /dev/null @@ -1,48 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2012 Tommi Rantala - -This file is part of libunwind. - -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. */ - -/* Use glibc's jump-buffer indices; NPTL peeks at SP: */ - -/* SH4 glibc jump buffer contents: - * 0. r8 - * 1. r9 - * 2. r10 - * 3. r11 - * 4. r12 - * 5. r13 - * 6. r14 - * 7. r15 - * 8. pr/pc - * 9. gbr - * 10. fpscr - * 11. fr12 - * 12. fr13 - * 13. fr14 - * 14. fr15 - */ - -#define JB_SP 7 -#define JB_RP 8 -#define JB_MASK_SAVED 15 -#define JB_MASK 16 diff --git a/src/pal/src/libunwind/include/tdep-sh/libunwind_i.h b/src/pal/src/libunwind/include/tdep-sh/libunwind_i.h deleted file mode 100644 index 8ced49104..000000000 --- a/src/pal/src/libunwind/include/tdep-sh/libunwind_i.h +++ /dev/null @@ -1,280 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - Copyright (C) 2012 Tommi Rantala - -This file is part of libunwind. - -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. */ - -#ifndef SH_LIBUNWIND_I_H -#define SH_LIBUNWIND_I_H - -/* Target-dependent definitions that are internal to libunwind but need - to be shared with target-independent code. */ - -#include -#include - -#include "elf32.h" -#include "mempool.h" -#include "dwarf.h" - -typedef struct - { - /* no sh-specific fast trace */ - } -unw_tdep_frame_t; - -struct unw_addr_space - { - struct unw_accessors acc; - int big_endian; - unw_caching_policy_t caching_policy; -#ifdef HAVE_ATOMIC_OPS_H - AO_t cache_generation; -#else - uint32_t cache_generation; -#endif - unw_word_t dyn_generation; /* see dyn-common.h */ - unw_word_t dyn_info_list_addr; /* (cached) dyn_info_list_addr */ - struct dwarf_rs_cache global_cache; - struct unw_debug_frame_list *debug_frames; - }; - -struct cursor - { - struct dwarf_cursor dwarf; /* must be first */ - enum - { - SH_SCF_NONE, /* no signal frame */ - SH_SCF_LINUX_SIGFRAME, /* non-RT signal frame */ - SH_SCF_LINUX_RT_SIGFRAME, /* RT signal frame */ - } - sigcontext_format; - unw_word_t sigcontext_addr; - unw_word_t sigcontext_sp; - unw_word_t sigcontext_pc; - }; - -#define DWARF_GET_LOC(l) ((l).val) - -#ifdef UNW_LOCAL_ONLY -# define DWARF_NULL_LOC DWARF_LOC (0, 0) -# define DWARF_IS_NULL_LOC(l) (DWARF_GET_LOC (l) == 0) -# define DWARF_LOC(r, t) ((dwarf_loc_t) { .val = (r) }) -# define DWARF_IS_REG_LOC(l) 0 -# define DWARF_REG_LOC(c,r) (DWARF_LOC((unw_word_t) \ - tdep_uc_addr((c)->as_arg, (r)), 0)) -# define DWARF_MEM_LOC(c,m) DWARF_LOC ((m), 0) -# define DWARF_FPREG_LOC(c,r) (DWARF_LOC((unw_word_t) \ - tdep_uc_addr((c)->as_arg, (r)), 0)) - -static inline int -dwarf_getfp (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t *val) -{ - if (!DWARF_GET_LOC (loc)) - return -1; - *val = *(unw_fpreg_t *) DWARF_GET_LOC (loc); - return 0; -} - -static inline int -dwarf_putfp (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t val) -{ - if (!DWARF_GET_LOC (loc)) - return -1; - *(unw_fpreg_t *) DWARF_GET_LOC (loc) = val; - return 0; -} - -static inline int -dwarf_get (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t *val) -{ - if (!DWARF_GET_LOC (loc)) - return -1; - *val = *(unw_word_t *) DWARF_GET_LOC (loc); - return 0; -} - -static inline int -dwarf_put (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t val) -{ - if (!DWARF_GET_LOC (loc)) - return -1; - *(unw_word_t *) DWARF_GET_LOC (loc) = val; - return 0; -} - -#else /* !UNW_LOCAL_ONLY */ -# define DWARF_LOC_TYPE_FP (1 << 0) -# define DWARF_LOC_TYPE_REG (1 << 1) -# define DWARF_NULL_LOC DWARF_LOC (0, 0) -# define DWARF_IS_NULL_LOC(l) \ - ({ dwarf_loc_t _l = (l); _l.val == 0 && _l.type == 0; }) -# define DWARF_LOC(r, t) ((dwarf_loc_t) { .val = (r), .type = (t) }) -# define DWARF_IS_REG_LOC(l) (((l).type & DWARF_LOC_TYPE_REG) != 0) -# define DWARF_IS_FP_LOC(l) (((l).type & DWARF_LOC_TYPE_FP) != 0) -# define DWARF_REG_LOC(c,r) DWARF_LOC((r), DWARF_LOC_TYPE_REG) -# define DWARF_MEM_LOC(c,m) DWARF_LOC ((m), 0) -# define DWARF_FPREG_LOC(c,r) DWARF_LOC((r), (DWARF_LOC_TYPE_REG \ - | DWARF_LOC_TYPE_FP)) - -static inline int -dwarf_getfp (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t *val) -{ - char *valp = (char *) &val; - unw_word_t addr; - int ret; - - if (DWARF_IS_NULL_LOC (loc)) - return -UNW_EBADREG; - - if (DWARF_IS_REG_LOC (loc)) - return (*c->as->acc.access_fpreg) (c->as, DWARF_GET_LOC (loc), - val, 0, c->as_arg); - - addr = DWARF_GET_LOC (loc); - if ((ret = (*c->as->acc.access_mem) (c->as, addr + 0, (unw_word_t *) valp, - 0, c->as_arg)) < 0) - return ret; - - return (*c->as->acc.access_mem) (c->as, addr + 4, (unw_word_t *) valp + 1, 0, - c->as_arg); -} - -static inline int -dwarf_putfp (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t val) -{ - char *valp = (char *) &val; - unw_word_t addr; - int ret; - - if (DWARF_IS_NULL_LOC (loc)) - return -UNW_EBADREG; - - if (DWARF_IS_REG_LOC (loc)) - return (*c->as->acc.access_fpreg) (c->as, DWARF_GET_LOC (loc), - &val, 1, c->as_arg); - - addr = DWARF_GET_LOC (loc); - if ((ret = (*c->as->acc.access_mem) (c->as, addr + 0, (unw_word_t *) valp, - 1, c->as_arg)) < 0) - return ret; - - return (*c->as->acc.access_mem) (c->as, addr + 4, (unw_word_t *) valp + 1, - 1, c->as_arg); -} - -static inline int -dwarf_get (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t *val) -{ - if (DWARF_IS_NULL_LOC (loc)) - return -UNW_EBADREG; - - /* If a code-generator were to save a value of type unw_word_t in a - floating-point register, we would have to support this case. I - suppose it could happen with MMX registers, but does it really - happen? */ - assert (!DWARF_IS_FP_LOC (loc)); - - if (DWARF_IS_REG_LOC (loc)) - return (*c->as->acc.access_reg) (c->as, DWARF_GET_LOC (loc), val, - 0, c->as_arg); - else - return (*c->as->acc.access_mem) (c->as, DWARF_GET_LOC (loc), val, - 0, c->as_arg); -} - -static inline int -dwarf_put (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t val) -{ - if (DWARF_IS_NULL_LOC (loc)) - return -UNW_EBADREG; - - /* If a code-generator were to save a value of type unw_word_t in a - floating-point register, we would have to support this case. I - suppose it could happen with MMX registers, but does it really - happen? */ - assert (!DWARF_IS_FP_LOC (loc)); - - if (DWARF_IS_REG_LOC (loc)) - return (*c->as->acc.access_reg) (c->as, DWARF_GET_LOC (loc), &val, - 1, c->as_arg); - else - return (*c->as->acc.access_mem) (c->as, DWARF_GET_LOC (loc), &val, - 1, c->as_arg); -} - -#endif /* !UNW_LOCAL_ONLY */ - -#define tdep_getcontext_trace unw_getcontext -#define tdep_init_done UNW_OBJ(init_done) -#define tdep_init UNW_OBJ(init) -/* Platforms that support UNW_INFO_FORMAT_TABLE need to define - tdep_search_unwind_table. */ -#define tdep_search_unwind_table dwarf_search_unwind_table -#define tdep_find_unwind_table dwarf_find_unwind_table -#define tdep_uc_addr UNW_ARCH_OBJ(uc_addr) -#define tdep_get_elf_image UNW_ARCH_OBJ(get_elf_image) -#define tdep_get_exe_image_path UNW_ARCH_OBJ(get_exe_image_path) -#define tdep_access_reg UNW_OBJ(access_reg) -#define tdep_access_fpreg UNW_OBJ(access_fpreg) -#define tdep_fetch_frame(c,ip,n) do {} while(0) -#define tdep_cache_frame(c) 0 -#define tdep_reuse_frame(c,frame) do {} while(0) -#define tdep_stash_frame(c,rs) do {} while(0) -#define tdep_trace(cur,addr,n) (-UNW_ENOINFO) - -#ifdef UNW_LOCAL_ONLY -# define tdep_find_proc_info(c,ip,n) \ - dwarf_find_proc_info((c)->as, (ip), &(c)->pi, (n), \ - (c)->as_arg) -# define tdep_put_unwind_info(as,pi,arg) \ - dwarf_put_unwind_info((as), (pi), (arg)) -#else -# define tdep_find_proc_info(c,ip,n) \ - (*(c)->as->acc.find_proc_info)((c)->as, (ip), &(c)->pi, (n), \ - (c)->as_arg) -# define tdep_put_unwind_info(as,pi,arg) \ - (*(as)->acc.put_unwind_info)((as), (pi), (arg)) -#endif - -#define tdep_get_as(c) ((c)->dwarf.as) -#define tdep_get_as_arg(c) ((c)->dwarf.as_arg) -#define tdep_get_ip(c) ((c)->dwarf.ip) -#define tdep_big_endian(as) ((as)->big_endian) - -extern int tdep_init_done; - -extern void tdep_init (void); -extern int tdep_search_unwind_table (unw_addr_space_t as, unw_word_t ip, - unw_dyn_info_t *di, unw_proc_info_t *pi, - int need_unwind_info, void *arg); -extern void *tdep_uc_addr (unw_tdep_context_t *uc, int reg); -extern int tdep_get_elf_image (struct elf_image *ei, pid_t pid, unw_word_t ip, - unsigned long *segbase, unsigned long *mapoff, - char *path, size_t pathlen); -extern void tdep_get_exe_image_path (char *path); -extern int tdep_access_reg (struct cursor *c, unw_regnum_t reg, - unw_word_t *valp, int write); -extern int tdep_access_fpreg (struct cursor *c, unw_regnum_t reg, - unw_fpreg_t *valp, int write); - -#endif /* SH_LIBUNWIND_I_H */ diff --git a/src/pal/src/libunwind/include/tdep-tilegx/dwarf-config.h b/src/pal/src/libunwind/include/tdep-tilegx/dwarf-config.h deleted file mode 100644 index 93bc6aaec..000000000 --- a/src/pal/src/libunwind/include/tdep-tilegx/dwarf-config.h +++ /dev/null @@ -1,50 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - Copyright (C) 2014 Tilera Corp. - -This file is part of libunwind. - -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. */ - -#ifndef dwarf_config_h -#define dwarf_config_h - -/* This is FIRST_PSEUDO_REGISTER in GCC, since DWARF_FRAME_REGISTERS is not - explicitly defined. */ -#define DWARF_NUM_PRESERVED_REGS 188 - -#define DWARF_REGNUM_MAP_LENGTH (56 + 2) - -/* Return TRUE if the ADDR_SPACE uses big-endian byte-order. */ -#define dwarf_is_big_endian(addr_space) ((addr_space)->big_endian) - -/* Convert a pointer to a dwarf_cursor structure to a pointer to - unw_cursor_t. */ -#define dwarf_to_cursor(c) ((unw_cursor_t *) (c)) - -typedef struct dwarf_loc -{ - unw_word_t val; -#ifndef UNW_LOCAL_ONLY - unw_word_t type; /* see DWARF_LOC_TYPE_* macros. */ -#endif -} dwarf_loc_t; - -#endif /* dwarf_config_h */ diff --git a/src/pal/src/libunwind/include/tdep-tilegx/jmpbuf.h b/src/pal/src/libunwind/include/tdep-tilegx/jmpbuf.h deleted file mode 100644 index 3afe9e46c..000000000 --- a/src/pal/src/libunwind/include/tdep-tilegx/jmpbuf.h +++ /dev/null @@ -1,33 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - Copyright (C) 2014 Tilera Corp. - -This file is part of libunwind. - -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. */ - -/* Use glibc's jump-buffer indices; NPTL peeks at SP: */ - -/* FIXME for Tilegx! */ - -#define JB_SP 4 -#define JB_RP 5 -#define JB_MASK_SAVED 6 -#define JB_MASK 7 diff --git a/src/pal/src/libunwind/include/tdep-tilegx/libunwind_i.h b/src/pal/src/libunwind/include/tdep-tilegx/libunwind_i.h deleted file mode 100644 index 2cfed456a..000000000 --- a/src/pal/src/libunwind/include/tdep-tilegx/libunwind_i.h +++ /dev/null @@ -1,263 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - Copyright (C) 2014 Tilera Corp. - -This file is part of libunwind. - -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. */ - -#ifndef TILEGX_LIBUNWIND_I_H -#define TILEGX_LIBUNWIND_I_H - -/* Target-dependent definitions that are internal to libunwind but need - to be shared with target-independent code. */ - -#include -#include - -# include "elf64.h" -#include "mempool.h" -#include "dwarf.h" - -typedef struct -{ - /* no Tilegx-specific fast trace */ -} unw_tdep_frame_t; - -struct unw_addr_space -{ - struct unw_accessors acc; - - int big_endian; - tilegx_abi_t abi; - unsigned int addr_size; - - unw_caching_policy_t caching_policy; -#ifdef HAVE_ATOMIC_OPS_H - AO_t cache_generation; -#else - uint32_t cache_generation; -#endif - unw_word_t dyn_generation; /* see dyn-common.h */ - unw_word_t dyn_info_list_addr; /* (cached) dyn_info_list_addr */ - struct dwarf_rs_cache global_cache; - struct unw_debug_frame_list *debug_frames; -}; - -#define tdep_big_endian(as) ((as)->big_endian) - -struct cursor -{ - struct dwarf_cursor dwarf; /* must be first */ - unw_word_t sigcontext_addr; - unw_word_t sigcontext_sp; - unw_word_t sigcontext_pc; -}; - -#define DWARF_GET_LOC(l) ((l).val) - -#ifndef UNW_REMOTE_ONLY -typedef long tilegx_reg_t; -#endif - -#ifdef UNW_LOCAL_ONLY -#define DWARF_NULL_LOC DWARF_LOC (0, 0) -#define DWARF_IS_NULL_LOC(l) (DWARF_GET_LOC (l) == 0) -#define DWARF_LOC(r, t) ((dwarf_loc_t) { .val = (r) }) -#define DWARF_IS_REG_LOC(l) 0 -#define DWARF_REG_LOC(c,r) (DWARF_LOC((unw_word_t) (intptr_t) \ - tdep_uc_addr((c)->as_arg, (r)), 0)) -#define DWARF_MEM_LOC(c,m) DWARF_LOC ((m), 0) -#define DWARF_FPREG_LOC(c,r) (DWARF_LOC((unw_word_t) (intptr_t) \ - tdep_uc_addr((c)->as_arg, (r)), 0)) - -/* Tilegx has no FP. */ -static inline int -dwarf_getfp (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t *val) -{ - Debug (1, "Tielgx has no fp!\n"); - abort(); - return 0; -} - -static inline int -dwarf_putfp (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t val) -{ - Debug (1, "Tielgx has no fp!\n"); - abort(); - return 0; -} - -static inline int -dwarf_get (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t *val) -{ - if (!DWARF_GET_LOC (loc)) - return -1; - - *val = *(tilegx_reg_t *) (intptr_t) DWARF_GET_LOC (loc); - return 0; -} - -static inline int -dwarf_put (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t val) -{ - if (!DWARF_GET_LOC (loc)) - return -1; - - *(tilegx_reg_t *) (intptr_t) DWARF_GET_LOC (loc) = val; - return 0; -} - -#else /* !UNW_LOCAL_ONLY */ -#define DWARF_LOC_TYPE_FP (1 << 0) -#define DWARF_LOC_TYPE_REG (1 << 1) -#define DWARF_NULL_LOC DWARF_LOC (0, 0) -#define DWARF_IS_NULL_LOC(l) \ - ({ dwarf_loc_t _l = (l); _l.val == 0 && _l.type == 0; }) -#define DWARF_LOC(r, t) ((dwarf_loc_t) { .val = (r), .type = (t) }) -#define DWARF_IS_REG_LOC(l) (((l).type & DWARF_LOC_TYPE_REG) != 0) -#define DWARF_IS_FP_LOC(l) (((l).type & DWARF_LOC_TYPE_FP) != 0) -#define DWARF_REG_LOC(c,r) DWARF_LOC((r), DWARF_LOC_TYPE_REG) -#define DWARF_MEM_LOC(c,m) DWARF_LOC ((m), 0) -#define DWARF_FPREG_LOC(c,r) DWARF_LOC((r), (DWARF_LOC_TYPE_REG \ - | DWARF_LOC_TYPE_FP)) - -/* TILEGX has no fp. */ -static inline int -dwarf_getfp (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t *val) -{ - Debug (1, "Tielgx has no fp!\n"); - abort(); - return 0; -} - -static inline int -dwarf_putfp (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t val) -{ - Debug (1, "Tielgx has no fp!\n"); - abort(); - return 0; -} - -static inline int -dwarf_get (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t *val) -{ - if (DWARF_IS_NULL_LOC (loc)) - return -UNW_EBADREG; - - /* If a code-generator were to save a value of type unw_word_t in a - floating-point register, we would have to support this case. I - suppose it could happen with MMX registers, but does it really - happen? */ - assert (!DWARF_IS_FP_LOC (loc)); - - if (DWARF_IS_REG_LOC (loc)) - return (*c->as->acc.access_reg) (c->as, DWARF_GET_LOC (loc), val, - 0, c->as_arg); - - return (*c->as->acc.access_mem) (c->as, DWARF_GET_LOC (loc), val, - 0, c->as_arg); -} - -static inline int -dwarf_put (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t val) -{ - if (DWARF_IS_NULL_LOC (loc)) - return -UNW_EBADREG; - - /* If a code-generator were to save a value of type unw_word_t in a - floating-point register, we would have to support this case. I - suppose it could happen with MMX registers, but does it really - happen? */ - assert (!DWARF_IS_FP_LOC (loc)); - - if (DWARF_IS_REG_LOC (loc)) - return (*c->as->acc.access_reg) (c->as, DWARF_GET_LOC (loc), &val, - 1, c->as_arg); - - return (*c->as->acc.access_mem) (c->as, DWARF_GET_LOC (loc), &val, - 1, c->as_arg); -} - -#endif /* !UNW_LOCAL_ONLY */ - -#define tdep_getcontext_trace unw_getcontext -#define tdep_init_done UNW_OBJ(init_done) -#define tdep_needs_initialization UNW_OBJ(needs_initialization) -#define tdep_init UNW_OBJ(init) -/* Platforms that support UNW_INFO_FORMAT_TABLE need to define - tdep_search_unwind_table. */ -#define tdep_search_unwind_table dwarf_search_unwind_table -#define tdep_find_unwind_table dwarf_find_unwind_table -#define tdep_uc_addr UNW_ARCH_OBJ(uc_addr) -#define tdep_get_elf_image UNW_ARCH_OBJ(get_elf_image) -#define tdep_get_exe_image_path UNW_ARCH_OBJ(get_exe_image_path) -#define tdep_access_reg UNW_OBJ(access_reg) -#define tdep_access_fpreg UNW_OBJ(access_fpreg) -#define tdep_fetch_frame(c,ip,n) do {} while(0) -#define tdep_cache_frame(c) 0 -#define tdep_reuse_frame(c,frame) do {} while(0) -#define tdep_stash_frame(c,rs) do {} while(0) -#define tdep_trace(cur,addr,n) (-UNW_ENOINFO) - -#ifdef UNW_LOCAL_ONLY -#define tdep_find_proc_info(c,ip,n) \ - dwarf_find_proc_info((c)->as, (ip), &(c)->pi, (n), \ - (c)->as_arg) -#define tdep_put_unwind_info(as,pi,arg) \ - dwarf_put_unwind_info((as), (pi), (arg)) -#else -#define tdep_find_proc_info(c,ip,n) \ - (*(c)->as->acc.find_proc_info)((c)->as, (ip), &(c)->pi, (n), \ - (c)->as_arg) -#define tdep_put_unwind_info(as,pi,arg) \ - (*(as)->acc.put_unwind_info)((as), (pi), (arg)) -#endif - -#define tdep_get_as(c) ((c)->dwarf.as) -#define tdep_get_as_arg(c) ((c)->dwarf.as_arg) -#define tdep_get_ip(c) ((c)->dwarf.ip) - -extern int tdep_init_done; - -extern void tdep_init (void); -extern int tdep_search_unwind_table (unw_addr_space_t as, - unw_word_t ip, - unw_dyn_info_t *di, - unw_proc_info_t *pi, - int need_unwind_info, - void *arg); -extern void *tdep_uc_addr (ucontext_t *uc, int reg); -extern int tdep_get_elf_image (struct elf_image *ei, - pid_t pid, unw_word_t ip, - unsigned long *segbase, - unsigned long *mapoff, - char *path, size_t pathlen); -extern void tdep_get_exe_image_path (char *path); -extern int tdep_access_reg (struct cursor *c, - unw_regnum_t reg, - unw_word_t *valp, - int write); -extern int tdep_access_fpreg (struct cursor *c, - unw_regnum_t reg, - unw_fpreg_t *valp, - int write); - -#endif /* TILEGX_LIBUNWIND_I_H */ diff --git a/src/pal/src/libunwind/include/tdep-x86/dwarf-config.h b/src/pal/src/libunwind/include/tdep-x86/dwarf-config.h deleted file mode 100644 index f76f9c1c4..000000000 --- a/src/pal/src/libunwind/include/tdep-x86/dwarf-config.h +++ /dev/null @@ -1,52 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (c) 2003 Hewlett-Packard Development Company, L.P. - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#ifndef dwarf_config_h -#define dwarf_config_h - -/* This matches the value used by GCC (see - gcc/config/i386.h:DWARF_FRAME_REGISTERS), which leaves plenty of - room for expansion. */ -#define DWARF_NUM_PRESERVED_REGS 17 - -#define DWARF_REGNUM_MAP_LENGTH 19 - -/* Return TRUE if the ADDR_SPACE uses big-endian byte-order. */ -#define dwarf_is_big_endian(addr_space) 0 - -/* Convert a pointer to a dwarf_cursor structure to a pointer to - unw_cursor_t. */ -#define dwarf_to_cursor(c) ((unw_cursor_t *) (c)) - -typedef struct dwarf_loc - { - unw_word_t val; -#ifndef UNW_LOCAL_ONLY - unw_word_t type; /* see X86_LOC_TYPE_* macros. */ -#endif - } -dwarf_loc_t; - -#endif /* dwarf_config_h */ diff --git a/src/pal/src/libunwind/include/tdep-x86/jmpbuf.h b/src/pal/src/libunwind/include/tdep-x86/jmpbuf.h deleted file mode 100644 index 521dfa699..000000000 --- a/src/pal/src/libunwind/include/tdep-x86/jmpbuf.h +++ /dev/null @@ -1,42 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -/* Use glibc's jump-buffer indices; NPTL peeks at SP: */ - -#if defined __linux__ - -#define JB_SP 4 -#define JB_RP 5 -#define JB_MASK_SAVED 6 -#define JB_MASK 7 - -#elif defined __FreeBSD__ - -#define JB_SP 2 -#define JB_RP 0 -#define JB_MASK_SAVED 11 -#define JB_MASK 7 - -#endif diff --git a/src/pal/src/libunwind/include/tdep-x86/libunwind_i.h b/src/pal/src/libunwind/include/tdep-x86/libunwind_i.h deleted file mode 100644 index 5231189a4..000000000 --- a/src/pal/src/libunwind/include/tdep-x86/libunwind_i.h +++ /dev/null @@ -1,293 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2002-2005 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#ifndef X86_LIBUNWIND_I_H -#define X86_LIBUNWIND_I_H - -/* Target-dependent definitions that are internal to libunwind but need - to be shared with target-independent code. */ - -#include -#include - -#include "elf32.h" -#include "mempool.h" -#include "dwarf.h" - -typedef struct - { - /* no x86-specific fast trace */ - } -unw_tdep_frame_t; - -struct unw_addr_space - { - struct unw_accessors acc; - unw_caching_policy_t caching_policy; -#ifdef HAVE_ATOMIC_OPS_H - AO_t cache_generation; -#else - uint32_t cache_generation; -#endif - unw_word_t dyn_generation; /* see dyn-common.h */ - unw_word_t dyn_info_list_addr; /* (cached) dyn_info_list_addr */ - struct dwarf_rs_cache global_cache; - struct unw_debug_frame_list *debug_frames; - }; - -struct cursor - { - struct dwarf_cursor dwarf; /* must be first */ - - /* Format of sigcontext structure and address at which it is - stored: */ - enum - { - X86_SCF_NONE, /* no signal frame encountered */ - X86_SCF_LINUX_SIGFRAME, /* Linux x86 sigcontext */ - X86_SCF_LINUX_RT_SIGFRAME, /* POSIX ucontext_t */ - X86_SCF_FREEBSD_SIGFRAME, /* FreeBSD x86 sigcontext */ - X86_SCF_FREEBSD_SIGFRAME4, /* FreeBSD 4.x x86 sigcontext */ - X86_SCF_FREEBSD_OSIGFRAME, /* FreeBSD pre-4.x x86 sigcontext */ - X86_SCF_FREEBSD_SYSCALL, /* FreeBSD x86 syscall */ - } - sigcontext_format; - unw_word_t sigcontext_addr; - int validate; - ucontext_t *uc; - }; - -static inline ucontext_t * -dwarf_get_uc(const struct dwarf_cursor *cursor) -{ - const struct cursor *c = (struct cursor *) cursor->as_arg; - return c->uc; -} - -#define DWARF_GET_LOC(l) ((l).val) - -#ifdef UNW_LOCAL_ONLY -# define DWARF_NULL_LOC DWARF_LOC (0, 0) -# define DWARF_IS_NULL_LOC(l) (DWARF_GET_LOC (l) == 0) -# define DWARF_LOC(r, t) ((dwarf_loc_t) { .val = (r) }) -# define DWARF_IS_REG_LOC(l) 0 -# define DWARF_REG_LOC(c,r) (DWARF_LOC((unw_word_t) \ - tdep_uc_addr(dwarf_get_uc(c), (r)), 0)) -# define DWARF_MEM_LOC(c,m) DWARF_LOC ((m), 0) -# define DWARF_FPREG_LOC(c,r) (DWARF_LOC((unw_word_t) \ - tdep_uc_addr(dwarf_get_uc(c), (r)), 0)) - -static inline int -dwarf_getfp (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t *val) -{ - if (!DWARF_GET_LOC (loc)) - return -1; - *val = *(unw_fpreg_t *) DWARF_GET_LOC (loc); - return 0; -} - -static inline int -dwarf_putfp (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t val) -{ - if (!DWARF_GET_LOC (loc)) - return -1; - *(unw_fpreg_t *) DWARF_GET_LOC (loc) = val; - return 0; -} - -static inline int -dwarf_get (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t *val) -{ - if (!DWARF_GET_LOC (loc)) - return -1; - return (*c->as->acc.access_mem) (c->as, DWARF_GET_LOC (loc), val, - 0, c->as_arg); -} - -static inline int -dwarf_put (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t val) -{ - if (!DWARF_GET_LOC (loc)) - return -1; - return (*c->as->acc.access_mem) (c->as, DWARF_GET_LOC (loc), &val, - 1, c->as_arg); -} - -#else /* !UNW_LOCAL_ONLY */ -# define DWARF_LOC_TYPE_FP (1 << 0) -# define DWARF_LOC_TYPE_REG (1 << 1) -# define DWARF_NULL_LOC DWARF_LOC (0, 0) -# define DWARF_IS_NULL_LOC(l) \ - ({ dwarf_loc_t _l = (l); _l.val == 0 && _l.type == 0; }) -# define DWARF_LOC(r, t) ((dwarf_loc_t) { .val = (r), .type = (t) }) -# define DWARF_IS_REG_LOC(l) (((l).type & DWARF_LOC_TYPE_REG) != 0) -# define DWARF_IS_FP_LOC(l) (((l).type & DWARF_LOC_TYPE_FP) != 0) -# define DWARF_REG_LOC(c,r) DWARF_LOC((r), DWARF_LOC_TYPE_REG) -# define DWARF_MEM_LOC(c,m) DWARF_LOC ((m), 0) -# define DWARF_FPREG_LOC(c,r) DWARF_LOC((r), (DWARF_LOC_TYPE_REG \ - | DWARF_LOC_TYPE_FP)) - -static inline int -dwarf_getfp (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t *val) -{ - char *valp = (char *) &val; - unw_word_t addr; - int ret; - - if (DWARF_IS_NULL_LOC (loc)) - return -UNW_EBADREG; - - if (DWARF_IS_REG_LOC (loc)) - return (*c->as->acc.access_fpreg) (c->as, DWARF_GET_LOC (loc), - val, 0, c->as_arg); - - addr = DWARF_GET_LOC (loc); - if ((ret = (*c->as->acc.access_mem) (c->as, addr + 0, (unw_word_t *) valp, - 0, c->as_arg)) < 0) - return ret; - - return (*c->as->acc.access_mem) (c->as, addr + 4, (unw_word_t *) valp + 1, 0, - c->as_arg); -} - -static inline int -dwarf_putfp (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t val) -{ - char *valp = (char *) &val; - unw_word_t addr; - int ret; - - if (DWARF_IS_NULL_LOC (loc)) - return -UNW_EBADREG; - - if (DWARF_IS_REG_LOC (loc)) - return (*c->as->acc.access_fpreg) (c->as, DWARF_GET_LOC (loc), - &val, 1, c->as_arg); - - addr = DWARF_GET_LOC (loc); - if ((ret = (*c->as->acc.access_mem) (c->as, addr + 0, (unw_word_t *) valp, - 1, c->as_arg)) < 0) - return ret; - - return (*c->as->acc.access_mem) (c->as, addr + 4, (unw_word_t *) valp + 1, - 1, c->as_arg); -} - -static inline int -dwarf_get (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t *val) -{ - if (DWARF_IS_NULL_LOC (loc)) - return -UNW_EBADREG; - - /* If a code-generator were to save a value of type unw_word_t in a - floating-point register, we would have to support this case. I - suppose it could happen with MMX registers, but does it really - happen? */ - assert (!DWARF_IS_FP_LOC (loc)); - - if (DWARF_IS_REG_LOC (loc)) - return (*c->as->acc.access_reg) (c->as, DWARF_GET_LOC (loc), val, - 0, c->as_arg); - else - return (*c->as->acc.access_mem) (c->as, DWARF_GET_LOC (loc), val, - 0, c->as_arg); -} - -static inline int -dwarf_put (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t val) -{ - if (DWARF_IS_NULL_LOC (loc)) - return -UNW_EBADREG; - - /* If a code-generator were to save a value of type unw_word_t in a - floating-point register, we would have to support this case. I - suppose it could happen with MMX registers, but does it really - happen? */ - assert (!DWARF_IS_FP_LOC (loc)); - - if (DWARF_IS_REG_LOC (loc)) - return (*c->as->acc.access_reg) (c->as, DWARF_GET_LOC (loc), &val, - 1, c->as_arg); - else - return (*c->as->acc.access_mem) (c->as, DWARF_GET_LOC (loc), &val, - 1, c->as_arg); -} - -#endif /* !UNW_LOCAL_ONLY */ - -#define tdep_getcontext_trace unw_getcontext -#define tdep_init_done UNW_OBJ(init_done) -#define tdep_init UNW_OBJ(init) -/* Platforms that support UNW_INFO_FORMAT_TABLE need to define - tdep_search_unwind_table. */ -#define tdep_search_unwind_table dwarf_search_unwind_table -#define tdep_find_unwind_table dwarf_find_unwind_table -#define tdep_uc_addr UNW_ARCH_OBJ(uc_addr) -#define tdep_get_elf_image UNW_ARCH_OBJ(get_elf_image) -#define tdep_get_exe_image_path UNW_ARCH_OBJ(get_exe_image_path) -#define tdep_access_reg UNW_OBJ(access_reg) -#define tdep_access_fpreg UNW_OBJ(access_fpreg) -#define tdep_fetch_frame(c,ip,n) do {} while(0) -#define tdep_cache_frame(c) 0 -#define tdep_reuse_frame(c,frame) do {} while(0) -#define tdep_stash_frame(c,rs) do {} while(0) -#define tdep_trace(cur,addr,n) (-UNW_ENOINFO) - -#ifdef UNW_LOCAL_ONLY -# define tdep_find_proc_info(c,ip,n) \ - dwarf_find_proc_info((c)->as, (ip), &(c)->pi, (n), \ - (c)->as_arg) -# define tdep_put_unwind_info(as,pi,arg) \ - dwarf_put_unwind_info((as), (pi), (arg)) -#else -# define tdep_find_proc_info(c,ip,n) \ - (*(c)->as->acc.find_proc_info)((c)->as, (ip), &(c)->pi, (n), \ - (c)->as_arg) -# define tdep_put_unwind_info(as,pi,arg) \ - (*(as)->acc.put_unwind_info)((as), (pi), (arg)) -#endif - -#define tdep_get_as(c) ((c)->dwarf.as) -#define tdep_get_as_arg(c) ((c)->dwarf.as_arg) -#define tdep_get_ip(c) ((c)->dwarf.ip) -#define tdep_big_endian(as) 0 - -extern int tdep_init_done; - -extern void tdep_init (void); -extern int tdep_search_unwind_table (unw_addr_space_t as, unw_word_t ip, - unw_dyn_info_t *di, unw_proc_info_t *pi, - int need_unwind_info, void *arg); -extern void *tdep_uc_addr (ucontext_t *uc, int reg); -extern int tdep_get_elf_image (struct elf_image *ei, pid_t pid, unw_word_t ip, - unsigned long *segbase, unsigned long *mapoff, - char *path, size_t pathlen); -extern void tdep_get_exe_image_path (char *path); -extern int tdep_access_reg (struct cursor *c, unw_regnum_t reg, - unw_word_t *valp, int write); -extern int tdep_access_fpreg (struct cursor *c, unw_regnum_t reg, - unw_fpreg_t *valp, int write); - -#endif /* X86_LIBUNWIND_I_H */ diff --git a/src/pal/src/libunwind/include/tdep-x86_64/dwarf-config.h b/src/pal/src/libunwind/include/tdep-x86_64/dwarf-config.h deleted file mode 100644 index ff77808e0..000000000 --- a/src/pal/src/libunwind/include/tdep-x86_64/dwarf-config.h +++ /dev/null @@ -1,57 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (c) 2003, 2005 Hewlett-Packard Development Company, L.P. - Contributed by David Mosberger-Tang - - Modified for x86_64 by Max Asbock - -This file is part of libunwind. - -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. */ - -/* copy of include/tdep-x86/dwarf-config.h, modified slightly for x86-64 - some consolidation is possible here */ - -#ifndef dwarf_config_h -#define dwarf_config_h - -/* XXX need to verify if this value is correct */ -#ifdef CONFIG_MSABI_SUPPORT -#define DWARF_NUM_PRESERVED_REGS 33 -#else -#define DWARF_NUM_PRESERVED_REGS 17 -#endif - -#define DWARF_REGNUM_MAP_LENGTH DWARF_NUM_PRESERVED_REGS - -/* Return TRUE if the ADDR_SPACE uses big-endian byte-order. */ -#define dwarf_is_big_endian(addr_space) 0 - -/* Convert a pointer to a dwarf_cursor structure to a pointer to - unw_cursor_t. */ -#define dwarf_to_cursor(c) ((unw_cursor_t *) (c)) - -typedef struct dwarf_loc - { - unw_word_t val; - unw_word_t type; /* see X86_LOC_TYPE_* macros. */ - } -dwarf_loc_t; - -#endif /* dwarf_config_h */ diff --git a/src/pal/src/libunwind/include/tdep-x86_64/jmpbuf.h b/src/pal/src/libunwind/include/tdep-x86_64/jmpbuf.h deleted file mode 100644 index d57196676..000000000 --- a/src/pal/src/libunwind/include/tdep-x86_64/jmpbuf.h +++ /dev/null @@ -1,43 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#if defined __linux__ - -/* Use glibc's jump-buffer indices; NPTL peeks at SP: */ - -#define JB_SP 6 -#define JB_RP 7 -#define JB_MASK_SAVED 8 -#define JB_MASK 9 - -#elif defined __FreeBSD__ - -#define JB_SP 2 -#define JB_RP 0 -/* Pretend the ip cannot be 0 and mask is always saved */ -#define JB_MASK_SAVED 0 -#define JB_MASK 9 - -#endif diff --git a/src/pal/src/libunwind/include/tdep-x86_64/libunwind_i.h b/src/pal/src/libunwind/include/tdep-x86_64/libunwind_i.h deleted file mode 100644 index 283525c16..000000000 --- a/src/pal/src/libunwind/include/tdep-x86_64/libunwind_i.h +++ /dev/null @@ -1,264 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2002-2005 Hewlett-Packard Co - Contributed by David Mosberger-Tang - - Modified for x86_64 by Max Asbock - -This file is part of libunwind. - -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. */ - -#ifndef X86_64_LIBUNWIND_I_H -#define X86_64_LIBUNWIND_I_H - -/* Target-dependent definitions that are internal to libunwind but need - to be shared with target-independent code. */ - -#include -#include - -#include "elf64.h" -#include "mempool.h" -#include "dwarf.h" - -typedef enum - { - UNW_X86_64_FRAME_ALIGNED = -3, /* frame stack pointer aligned */ - UNW_X86_64_FRAME_STANDARD = -2, /* regular rbp, rsp +/- offset */ - UNW_X86_64_FRAME_SIGRETURN = -1, /* special sigreturn frame */ - UNW_X86_64_FRAME_OTHER = 0, /* not cacheable (special or unrecognised) */ - UNW_X86_64_FRAME_GUESSED = 1 /* guessed it was regular, but not known */ - } -unw_tdep_frame_type_t; - -typedef struct - { - uint64_t virtual_address; - int64_t frame_type : 3; /* unw_tdep_frame_type_t classification */ - int64_t last_frame : 1; /* non-zero if last frame in chain */ - int64_t cfa_reg_rsp : 1; /* cfa dwarf base register is rsp vs. rbp */ - int64_t cfa_reg_offset : 29; /* cfa is at this offset from base register value */ - int64_t rbp_cfa_offset : 15; /* rbp saved at this offset from cfa (-1 = not saved) */ - int64_t rsp_cfa_offset : 15; /* rsp saved at this offset from cfa (-1 = not saved) */ - } -unw_tdep_frame_t; - -struct unw_addr_space - { - struct unw_accessors acc; - unw_caching_policy_t caching_policy; -#ifdef HAVE_ATOMIC_OPS_H - AO_t cache_generation; -#else - uint32_t cache_generation; -#endif - unw_word_t dyn_generation; /* see dyn-common.h */ - unw_word_t dyn_info_list_addr; /* (cached) dyn_info_list_addr */ - struct dwarf_rs_cache global_cache; - struct unw_debug_frame_list *debug_frames; - }; - -struct cursor - { - struct dwarf_cursor dwarf; /* must be first */ - - unw_tdep_frame_t frame_info; /* quick tracing assist info */ - - /* Format of sigcontext structure and address at which it is - stored: */ - enum - { - X86_64_SCF_NONE, /* no signal frame encountered */ - X86_64_SCF_LINUX_RT_SIGFRAME, /* Linux ucontext_t */ - X86_64_SCF_FREEBSD_SIGFRAME, /* FreeBSD signal frame */ - X86_64_SCF_FREEBSD_SYSCALL, /* FreeBSD syscall */ - } - sigcontext_format; - unw_word_t sigcontext_addr; - int validate; - ucontext_t *uc; - }; - -static inline ucontext_t * -dwarf_get_uc(const struct dwarf_cursor *cursor) -{ - const struct cursor *c = (struct cursor *) cursor->as_arg; - return c->uc; -} - -#define DWARF_GET_LOC(l) ((l).val) -# define DWARF_LOC_TYPE_MEM (0 << 0) -# define DWARF_LOC_TYPE_FP (1 << 0) -# define DWARF_LOC_TYPE_REG (1 << 1) -# define DWARF_LOC_TYPE_VAL (1 << 2) - -# define DWARF_IS_REG_LOC(l) (((l).type & DWARF_LOC_TYPE_REG) != 0) -# define DWARF_IS_FP_LOC(l) (((l).type & DWARF_LOC_TYPE_FP) != 0) -# define DWARF_IS_MEM_LOC(l) ((l).type == DWARF_LOC_TYPE_MEM) -# define DWARF_IS_VAL_LOC(l) (((l).type & DWARF_LOC_TYPE_VAL) != 0) - -# define DWARF_LOC(r, t) ((dwarf_loc_t) { .val = (r), .type = (t) }) -# define DWARF_VAL_LOC(c,v) DWARF_LOC ((v), DWARF_LOC_TYPE_VAL) -# define DWARF_MEM_LOC(c,m) DWARF_LOC ((m), DWARF_LOC_TYPE_MEM) - -#ifdef UNW_LOCAL_ONLY -# define DWARF_NULL_LOC DWARF_LOC (0, 0) -# define DWARF_IS_NULL_LOC(l) (DWARF_GET_LOC (l) == 0) -# define DWARF_REG_LOC(c,r) (DWARF_LOC((unw_word_t) \ - x86_64_r_uc_addr(dwarf_get_uc(c), (r)), 0)) -# define DWARF_FPREG_LOC(c,r) (DWARF_LOC((unw_word_t) \ - x86_64_r_uc_addr(dwarf_get_uc(c), (r)), 0)) - -#else /* !UNW_LOCAL_ONLY */ - -# define DWARF_NULL_LOC DWARF_LOC (0, 0) -# define DWARF_IS_NULL_LOC(l) \ - ({ dwarf_loc_t _l = (l); _l.val == 0 && _l.type == 0; }) -# define DWARF_REG_LOC(c,r) DWARF_LOC((r), DWARF_LOC_TYPE_REG) -# define DWARF_FPREG_LOC(c,r) DWARF_LOC((r), (DWARF_LOC_TYPE_REG \ - | DWARF_LOC_TYPE_FP)) - -#endif /* !UNW_LOCAL_ONLY */ - -static inline int -dwarf_getfp (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t *val) -{ - if (DWARF_IS_NULL_LOC (loc)) - return -UNW_EBADREG; - - abort (); -} - -static inline int -dwarf_putfp (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t val) -{ - if (DWARF_IS_NULL_LOC (loc)) - return -UNW_EBADREG; - - abort (); -} - -static inline int -dwarf_get (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t *val) -{ - if (DWARF_IS_NULL_LOC (loc)) - return -UNW_EBADREG; - - if (DWARF_IS_REG_LOC (loc)) - return (*c->as->acc.access_reg) (c->as, DWARF_GET_LOC (loc), val, - 0, c->as_arg); - if (DWARF_IS_MEM_LOC (loc)) - return (*c->as->acc.access_mem) (c->as, DWARF_GET_LOC (loc), val, - 0, c->as_arg); - assert(DWARF_IS_VAL_LOC (loc)); - *val = DWARF_GET_LOC (loc); - return 0; -} - -static inline int -dwarf_put (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t val) -{ - assert(!DWARF_IS_VAL_LOC (loc)); - - if (DWARF_IS_NULL_LOC (loc)) - return -UNW_EBADREG; - - if (DWARF_IS_REG_LOC (loc)) - return (*c->as->acc.access_reg) (c->as, DWARF_GET_LOC (loc), &val, - 1, c->as_arg); - else - return (*c->as->acc.access_mem) (c->as, DWARF_GET_LOC (loc), &val, - 1, c->as_arg); -} - -#define tdep_getcontext_trace UNW_ARCH_OBJ(getcontext_trace) -#define tdep_init_done UNW_OBJ(init_done) -#define tdep_init_mem_validate UNW_OBJ(init_mem_validate) -#define tdep_init UNW_OBJ(init) -/* Platforms that support UNW_INFO_FORMAT_TABLE need to define - tdep_search_unwind_table. */ -#define tdep_search_unwind_table dwarf_search_unwind_table -#define tdep_find_unwind_table dwarf_find_unwind_table -#define tdep_get_elf_image UNW_ARCH_OBJ(get_elf_image) -#define tdep_get_exe_image_path UNW_ARCH_OBJ(get_exe_image_path) -#define tdep_access_reg UNW_OBJ(access_reg) -#define tdep_access_fpreg UNW_OBJ(access_fpreg) -#if __linux__ -# define tdep_fetch_frame UNW_OBJ(fetch_frame) -# define tdep_cache_frame UNW_OBJ(cache_frame) -# define tdep_reuse_frame UNW_OBJ(reuse_frame) -#else -# define tdep_fetch_frame(c,ip,n) do {} while(0) -# define tdep_cache_frame(c) 0 -# define tdep_reuse_frame(c,frame) do {} while(0) -#endif -#define tdep_stash_frame UNW_OBJ(stash_frame) -#define tdep_trace UNW_OBJ(tdep_trace) -#define x86_64_r_uc_addr UNW_OBJ(r_uc_addr) - -#ifdef UNW_LOCAL_ONLY -# define tdep_find_proc_info(c,ip,n) \ - dwarf_find_proc_info((c)->as, (ip), &(c)->pi, (n), \ - (c)->as_arg) -# define tdep_put_unwind_info(as,pi,arg) \ - dwarf_put_unwind_info((as), (pi), (arg)) -#else -# define tdep_find_proc_info(c,ip,n) \ - (*(c)->as->acc.find_proc_info)((c)->as, (ip), &(c)->pi, (n), \ - (c)->as_arg) -# define tdep_put_unwind_info(as,pi,arg) \ - (*(as)->acc.put_unwind_info)((as), (pi), (arg)) -#endif - -#define tdep_get_as(c) ((c)->dwarf.as) -#define tdep_get_as_arg(c) ((c)->dwarf.as_arg) -#define tdep_get_ip(c) ((c)->dwarf.ip) -#define tdep_big_endian(as) 0 - -extern int tdep_init_done; - -extern void tdep_init (void); -extern void tdep_init_mem_validate (void); -extern int tdep_search_unwind_table (unw_addr_space_t as, unw_word_t ip, - unw_dyn_info_t *di, unw_proc_info_t *pi, - int need_unwind_info, void *arg); -extern void *x86_64_r_uc_addr (ucontext_t *uc, int reg); -extern int tdep_get_elf_image (struct elf_image *ei, pid_t pid, unw_word_t ip, - unsigned long *segbase, unsigned long *mapoff, - char *path, size_t pathlen); -extern void tdep_get_exe_image_path (char *path); -extern int tdep_access_reg (struct cursor *c, unw_regnum_t reg, - unw_word_t *valp, int write); -extern int tdep_access_fpreg (struct cursor *c, unw_regnum_t reg, - unw_fpreg_t *valp, int write); -#if __linux__ -extern void tdep_fetch_frame (struct dwarf_cursor *c, unw_word_t ip, - int need_unwind_info); -extern int tdep_cache_frame (struct dwarf_cursor *c); -extern void tdep_reuse_frame (struct dwarf_cursor *c, - int frame); -extern void tdep_stash_frame (struct dwarf_cursor *c, - struct dwarf_reg_state *rs); -#endif - -extern int tdep_getcontext_trace (unw_tdep_context_t *); -extern int tdep_trace (unw_cursor_t *cursor, void **addresses, int *n); - -#endif /* X86_64_LIBUNWIND_I_H */ diff --git a/src/pal/src/libunwind/include/tdep/dwarf-config.h b/src/pal/src/libunwind/include/tdep/dwarf-config.h deleted file mode 100644 index c759a46c6..000000000 --- a/src/pal/src/libunwind/include/tdep/dwarf-config.h +++ /dev/null @@ -1,28 +0,0 @@ -/* Provide a real file - not a symlink - as it would cause multiarch conflicts - when multiple different arch releases are installed simultaneously. */ - -#if defined __aarch64__ -# include "tdep-aarch64/dwarf-config.h" -#elif defined __arm__ -# include "tdep-arm/dwarf-config.h" -#elif defined __hppa__ -# include "tdep-hppa/dwarf-config.h" -#elif defined __ia64__ -# include "tdep-ia64/dwarf-config.h" -#elif defined __mips__ -# include "tdep-mips/dwarf-config.h" -#elif defined __powerpc__ && !defined __powerpc64__ -# include "tdep-ppc32/dwarf-config.h" -#elif defined __powerpc64__ -# include "tdep-ppc64/dwarf-config.h" -#elif defined __sh__ -# include "tdep-sh/dwarf-config.h" -#elif defined __i386__ -# include "tdep-x86/dwarf-config.h" -#elif defined __x86_64__ || defined __amd64__ -# include "tdep-x86_64/dwarf-config.h" -#elif defined __tilegx__ -# include "tdep-tilegx/dwarf-config.h" -#else -# error "Unsupported arch" -#endif diff --git a/src/pal/src/libunwind/include/tdep/jmpbuf.h b/src/pal/src/libunwind/include/tdep/jmpbuf.h deleted file mode 100644 index 13093a0cd..000000000 --- a/src/pal/src/libunwind/include/tdep/jmpbuf.h +++ /dev/null @@ -1,30 +0,0 @@ -/* Provide a real file - not a symlink - as it would cause multiarch conflicts - when multiple different arch releases are installed simultaneously. */ - -#ifndef UNW_REMOTE_ONLY - -#if defined __aarch64__ -# include "tdep-aarch64/jmpbuf.h" -#elif defined __arm__ -# include "tdep-arm/jmpbuf.h" -#elif defined __hppa__ -# include "tdep-hppa/jmpbuf.h" -#elif defined __ia64__ -# include "tdep-ia64/jmpbuf.h" -#elif defined __mips__ -# include "tdep-mips/jmpbuf.h" -#elif defined __powerpc__ && !defined __powerpc64__ -# include "tdep-ppc32/jmpbuf.h" -#elif defined __powerpc64__ -# include "tdep-ppc64/jmpbuf.h" -#elif defined __i386__ -# include "tdep-x86/jmpbuf.h" -#elif defined __x86_64__ -# include "tdep-x86_64/jmpbuf.h" -#elif defined __tilegx__ -# include "tdep-tilegx/jmpbuf.h" -#else -# error "Unsupported arch" -#endif - -#endif /* !UNW_REMOTE_ONLY */ diff --git a/src/pal/src/libunwind/include/tdep/libunwind_i.h.in b/src/pal/src/libunwind/include/tdep/libunwind_i.h.in deleted file mode 100644 index af05a7fba..000000000 --- a/src/pal/src/libunwind/include/tdep/libunwind_i.h.in +++ /dev/null @@ -1,37 +0,0 @@ -/* Provide a real file - not a symlink - as it would cause multiarch conflicts - when multiple different arch releases are installed simultaneously. */ - -#ifndef UNW_REMOTE_ONLY - -#if defined __aarch64__ -# include "tdep-aarch64/libunwind_i.h" -#elif defined __arm__ -# include "tdep-arm/libunwind_i.h" -#elif defined __hppa__ -# include "tdep-hppa/libunwind_i.h" -#elif defined __ia64__ -# include "tdep-ia64/libunwind_i.h" -#elif defined __mips__ -# include "tdep-mips/libunwind_i.h" -#elif defined __powerpc__ && !defined __powerpc64__ -# include "tdep-ppc32/libunwind_i.h" -#elif defined __powerpc64__ -# include "tdep-ppc64/libunwind_i.h" -#elif defined __sh__ -# include "tdep-sh/libunwind_i.h" -#elif defined __i386__ -# include "tdep-x86/libunwind_i.h" -#elif defined __x86_64__ -# include "tdep-x86_64/libunwind_i.h" -#elif defined __tilegx__ -# include "tdep-tilegx/libunwind_i.h" -#else -# error "Unsupported arch" -#endif - - -#else /* UNW_REMOTE_ONLY */ - -# include "tdep-@arch@/libunwind_i.h" - -#endif /* UNW_REMOTE_ONLY */ diff --git a/src/pal/src/libunwind/include/unwind.h b/src/pal/src/libunwind/include/unwind.h deleted file mode 100644 index 7cf128dec..000000000 --- a/src/pal/src/libunwind/include/unwind.h +++ /dev/null @@ -1,154 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2003 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#ifndef _UNWIND_H -#define _UNWIND_H - -/* For uint64_t */ -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* Minimal interface as per C++ ABI draft standard: - - http://www.codesourcery.com/cxx-abi/abi-eh.html */ - -typedef enum - { - _URC_NO_REASON = 0, - _URC_FOREIGN_EXCEPTION_CAUGHT = 1, - _URC_FATAL_PHASE2_ERROR = 2, - _URC_FATAL_PHASE1_ERROR = 3, - _URC_NORMAL_STOP = 4, - _URC_END_OF_STACK = 5, - _URC_HANDLER_FOUND = 6, - _URC_INSTALL_CONTEXT = 7, - _URC_CONTINUE_UNWIND = 8 - } -_Unwind_Reason_Code; - -typedef int _Unwind_Action; - -#define _UA_SEARCH_PHASE 1 -#define _UA_CLEANUP_PHASE 2 -#define _UA_HANDLER_FRAME 4 -#define _UA_FORCE_UNWIND 8 - -struct _Unwind_Context; /* opaque data-structure */ -struct _Unwind_Exception; /* forward-declaration */ - -typedef void (*_Unwind_Exception_Cleanup_Fn) (_Unwind_Reason_Code, - struct _Unwind_Exception *); - -typedef _Unwind_Reason_Code (*_Unwind_Stop_Fn) (int, _Unwind_Action, - uint64_t, - struct _Unwind_Exception *, - struct _Unwind_Context *, - void *); - -/* The C++ ABI requires exception_class, private_1, and private_2 to - be of type uint64 and the entire structure to be - double-word-aligned. Please note that exception_class stays 64-bit - even on 32-bit machines for gcc compatibility. */ -struct _Unwind_Exception - { - uint64_t exception_class; - _Unwind_Exception_Cleanup_Fn exception_cleanup; - unsigned long private_1; - unsigned long private_2; - } __attribute__((__aligned__)); - -extern _Unwind_Reason_Code _Unwind_RaiseException (struct _Unwind_Exception *); -extern _Unwind_Reason_Code _Unwind_ForcedUnwind (struct _Unwind_Exception *, - _Unwind_Stop_Fn, void *); -extern void _Unwind_Resume (struct _Unwind_Exception *); -extern void _Unwind_DeleteException (struct _Unwind_Exception *); -extern unsigned long _Unwind_GetGR (struct _Unwind_Context *, int); -extern void _Unwind_SetGR (struct _Unwind_Context *, int, unsigned long); -extern unsigned long _Unwind_GetIP (struct _Unwind_Context *); -extern unsigned long _Unwind_GetIPInfo (struct _Unwind_Context *, int *); -extern void _Unwind_SetIP (struct _Unwind_Context *, unsigned long); -extern unsigned long _Unwind_GetLanguageSpecificData (struct _Unwind_Context*); -extern unsigned long _Unwind_GetRegionStart (struct _Unwind_Context *); - -#ifdef _GNU_SOURCE - -/* Callback for _Unwind_Backtrace(). The backtrace stops immediately - if the callback returns any value other than _URC_NO_REASON. */ -typedef _Unwind_Reason_Code (*_Unwind_Trace_Fn) (struct _Unwind_Context *, - void *); - -/* See http://gcc.gnu.org/ml/gcc-patches/2001-09/msg00082.html for why - _UA_END_OF_STACK exists. */ -# define _UA_END_OF_STACK 16 - -/* If the unwind was initiated due to a forced unwind, resume that - operation, else re-raise the exception. This is used by - __cxa_rethrow(). */ -extern _Unwind_Reason_Code - _Unwind_Resume_or_Rethrow (struct _Unwind_Exception *); - -/* See http://gcc.gnu.org/ml/gcc-patches/2003-09/msg00154.html for why - _Unwind_GetBSP() exists. */ -extern unsigned long _Unwind_GetBSP (struct _Unwind_Context *); - -/* Return the "canonical frame address" for the given context. - This is used by NPTL... */ -extern unsigned long _Unwind_GetCFA (struct _Unwind_Context *); - -/* Return the base-address for data references. */ -extern unsigned long _Unwind_GetDataRelBase (struct _Unwind_Context *); - -/* Return the base-address for text references. */ -extern unsigned long _Unwind_GetTextRelBase (struct _Unwind_Context *); - -/* Call _Unwind_Trace_Fn once for each stack-frame, without doing any - cleanup. The first frame for which the callback is invoked is the - one for the caller of _Unwind_Backtrace(). _Unwind_Backtrace() - returns _URC_END_OF_STACK when the backtrace stopped due to - reaching the end of the call-chain or _URC_FATAL_PHASE1_ERROR if it - stops for any other reason. */ -extern _Unwind_Reason_Code _Unwind_Backtrace (_Unwind_Trace_Fn, void *); - -/* Find the start-address of the procedure containing the specified IP - or NULL if it cannot be found (e.g., because the function has no - unwind info). Note: there is not necessarily a one-to-one - correspondence between source-level functions and procedures: some - functions don't have unwind-info and others are split into multiple - procedures. */ -extern void *_Unwind_FindEnclosingFunction (void *); - -/* See also Linux Standard Base Spec: - http://www.linuxbase.org/spec/refspecs/LSB_1.3.0/gLSB/gLSB/libgcc-s.html */ - -#endif /* _GNU_SOURCE */ - -#ifdef __cplusplus -}; -#endif - -#endif /* _UNWIND_H */ diff --git a/src/pal/src/libunwind/include/x86/jmpbuf.h b/src/pal/src/libunwind/include/x86/jmpbuf.h deleted file mode 100644 index 94d5984f0..000000000 --- a/src/pal/src/libunwind/include/x86/jmpbuf.h +++ /dev/null @@ -1,31 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -/* Use glibc's jump-buffer indices; NPTL peeks at SP: */ - -#define JB_SP 4 -#define JB_RP 5 -#define JB_MASK_SAVED 6 -#define JB_MASK 7 diff --git a/src/pal/src/libunwind/scripts/kernel-diff.sh b/src/pal/src/libunwind/scripts/kernel-diff.sh deleted file mode 100644 index 459194e15..000000000 --- a/src/pal/src/libunwind/scripts/kernel-diff.sh +++ /dev/null @@ -1,10 +0,0 @@ -kdir=${1:-../kernel} -scriptdir=$(dirname $0) -udir=$(dirname $scriptdir) -cat $scriptdir/kernel-files.txt | \ -(while read l r; do - left=$(eval echo $l) - right=$(eval echo $r) -# echo $left $right - diff -up $left $right -done) diff --git a/src/pal/src/libunwind/scripts/kernel-files.txt b/src/pal/src/libunwind/scripts/kernel-files.txt deleted file mode 100644 index d79e453a3..000000000 --- a/src/pal/src/libunwind/scripts/kernel-files.txt +++ /dev/null @@ -1,19 +0,0 @@ -$udir/include/tdep-ia64/rse.h $kdir/arch/ia64/unwind/rse.h -$udir/src/ia64/Ginit_local.c $kdir/arch/ia64/unwind/init_local.c -$udir/src/ia64/Gis_signal_frame.c $kdir/arch/ia64/unwind/is_signal_frame.c -$udir/src/ia64/Gparser.c $kdir/arch/ia64/unwind/parser.c -$udir/src/ia64/Grbs.c $kdir/arch/ia64/unwind/rbs.c -$udir/src/ia64/Gregs.c $kdir/arch/ia64/unwind/regs.c -$udir/src/ia64/Gscript.c $kdir/arch/ia64/unwind/script.c -$udir/src/ia64/Gstep.c $kdir/arch/ia64/unwind/step.c -$udir/src/ia64/init.h $kdir/arch/ia64/unwind/init.h -$udir/src/ia64/offsets.h $kdir/arch/ia64/unwind/offsets.h -$udir/src/ia64/regname.c $kdir/arch/ia64/unwind/regname.c -$udir/src/ia64/regs.h $kdir/arch/ia64/unwind/regs.h -$udir/src/ia64/unwind_decoder.h $kdir/arch/ia64/unwind/unwind_decoder.h -$udir/src/mi/Gget_fpreg.c $kdir/unwind/get_fpreg.c -$udir/src/mi/Gget_reg.c $kdir/unwind/get_reg.c -$udir/src/mi/Gset_fpreg.c $kdir/unwind/set_fpreg.c -$udir/src/mi/Gset_reg.c $kdir/unwind/set_reg.c -$udir/src/mi/flush_cache.c $kdir/unwind/flush_cache.c -$udir/src/mi/mempool.c $kdir/unwind/mempool.c diff --git a/src/pal/src/libunwind/scripts/make-L-files b/src/pal/src/libunwind/scripts/make-L-files deleted file mode 100644 index 8280e3d76..000000000 --- a/src/pal/src/libunwind/scripts/make-L-files +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/sh -cwd=`pwd` -dir=`basename ${cwd}` -# -# When compiling a file that goes into libunwind, we only -# need to compile it when we really do support UNW_LOCAL_ONLY. -# In contrast, libunwind-tests should always get compiled. -# -if test $dir = "tests"; then - local_only_test="" -else - local_only_test="defined(UNW_LOCAL_ONLY) && " -fi -for gname in `ls G*.c G*.cxx G*.S 2>/dev/null`; do - lname="L$(expr $gname : '.\(.*\)')" - bk edit $lname >/dev/null 2>&1 - ext=$(expr $gname : '[^.]*[.]\(.*\)') - if [ "$ext" = "S" ]; then - include="" - else - include="#include " - fi - echo -e "\ -#define UNW_LOCAL_ONLY\n\ -$include\n\ -#if ${local_only_test}!defined(UNW_REMOTE_ONLY)\n\ -#include \"$gname\"\n\ -#endif" > $lname - echo created $lname -done diff --git a/src/pal/src/libunwind/src/CMakeLists.txt b/src/pal/src/libunwind/src/CMakeLists.txt deleted file mode 100644 index c035f64c1..000000000 --- a/src/pal/src/libunwind/src/CMakeLists.txt +++ /dev/null @@ -1,347 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -project(unwind) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - - -include(configure.cmake) - -# The HAVE___THREAD set to 1 causes creation of thread local variable with tls_model("initial-exec") -# which is incompatible with usage of the unwind code in a shared library. -add_definitions(-DHAVE___THREAD=0) -add_definitions(-DHAVE_CONFIG_H=1) - -add_definitions(-DPACKAGE_STRING="") -add_definitions(-DPACKAGE_BUGREPORT="") - -add_definitions(-D_GNU_SOURCE) -# Ensure that the remote and local unwind code can reside in the same binary without name clashing -add_definitions("-Ddwarf_search_unwind_table_int=UNW_OBJ(dwarf_search_unwind_table_int)") - -add_compile_options(-Wno-header-guard) - -if(CLR_CMAKE_PLATFORM_ARCH_ARM) - # Ensure that the remote and local unwind code can reside in the same binary without name clashing - add_definitions("-Darm_search_unwind_table=UNW_OBJ(arm_search_unwind_table)") - # Disable warning in asm: use of SP or PC in the list is deprecated - add_compile_options(-Wno-inline-asm) - # Disable warning due to labs function called on unsigned argument - add_compile_options(-Wno-absolute-value) - # Disable warning due to incorrect format specifier in debugging printf via the Debug macro - add_compile_options(-Wno-format) - # Disable warning for a bug in the libunwind source src/arm/Gtrace.c:529, but not in code that we exercise - add_compile_options(-Wno-implicit-function-declaration) - # Disable warning due to an unused function prel31_read - add_compile_options(-Wno-unused-function) - # We compile code with -std=c99 and the asm keyword is not recognized as it is a gnu extension - add_definitions(-Dasm=__asm__) - # The arm sources include ex_tables.h from include/tdep-arm without going through a redirection - # in include/tdep like it works for similar files on other architectures. So we need to add - # the include/tdep-arm to include directories - include_directories(../include/tdep-arm) -elseif(CLR_CMAKE_PLATFORM_ARCH_ARM64) - # Disable warning due to labs function called on unsigned argument - add_compile_options(-Wno-absolute-value) - # We compile code with -std=c99 and the asm keyword is not recognized as it is a gnu extension - add_definitions(-Dasm=__asm__) -elseif(CLR_CMAKE_PLATFORM_ARCH_I386) - # Disable warning due to incorrect format specifier in debugging printf via the Debug macro - add_compile_options(-Wno-format) - # Disable warning for a bug in the libunwind source src/x86/Gos-linux.c, but not in code that we exercise - add_compile_options(-Wno-incompatible-pointer-types) -endif() - -SET(libunwind_ptrace_la_SOURCES - ptrace/_UPT_elf.c - ptrace/_UPT_accessors.c ptrace/_UPT_access_fpreg.c - ptrace/_UPT_access_mem.c ptrace/_UPT_access_reg.c - ptrace/_UPT_create.c ptrace/_UPT_destroy.c - ptrace/_UPT_find_proc_info.c ptrace/_UPT_get_dyn_info_list_addr.c - ptrace/_UPT_put_unwind_info.c ptrace/_UPT_get_proc_name.c - ptrace/_UPT_reg_offset.c ptrace/_UPT_resume.c -) - -SET(libunwind_coredump_la_SOURCES - coredump/_UCD_accessors.c - coredump/_UCD_create.c - coredump/_UCD_destroy.c - coredump/_UCD_access_mem.c - coredump/_UCD_elf_map_image.c - coredump/_UCD_find_proc_info.c - coredump/_UCD_get_proc_name.c - - coredump/_UPT_elf.c - coredump/_UPT_access_fpreg.c - coredump/_UPT_get_dyn_info_list_addr.c - coredump/_UPT_put_unwind_info.c - coredump/_UPT_resume.c -) - -# List of arch-independent files needed by generic library (libunwind-$ARCH): -SET(libunwind_la_SOURCES_generic - mi/Gdyn-extract.c mi/Gdyn-remote.c mi/Gfind_dynamic_proc_info.c - # The Gget_accessors.c implements the same function as Lget_accessors.c, so - # the source is excluded here to prevent name clash - #mi/Gget_accessors.c - mi/Gget_proc_info_by_ip.c mi/Gget_proc_name.c - mi/Gput_dynamic_unwind_info.c mi/Gdestroy_addr_space.c - mi/Gget_reg.c mi/Gset_reg.c - mi/Gget_fpreg.c mi/Gset_fpreg.c - mi/Gset_caching_policy.c - mi/Gset_cache_size.c -) - -SET(libunwind_la_SOURCES_os_linux - os-linux.c -) - -SET(libunwind_la_SOURCES_os_linux_local -# Nothing when we don't want to support CXX exceptions -) - -SET(libunwind_la_SOURCES_os_freebsd - os-freebsd.c -) - -SET(libunwind_la_SOURCES_os_freebsd_local -# Nothing -) - -if(CLR_CMAKE_PLATFORM_LINUX) - SET(libunwind_la_SOURCES_os ${libunwind_la_SOURCES_os_linux}) - SET(libunwind_la_SOURCES_os_local ${libunwind_la_SOURCES_os_linux_local}) - SET(libunwind_la_SOURCES_x86_os x86/Gos-linux.c) - SET(libunwind_x86_la_SOURCES_os x86/getcontext-linux.S) - SET(libunwind_la_SOURCES_x86_os_local x86/Los-linux.c) - SET(libunwind_la_SOURCES_x86_64_os x86_64/Gos-linux.c) - SET(libunwind_la_SOURCES_x86_64_os_local x86_64/Los-linux.c) - SET(libunwind_la_SOURCES_arm_os arm/Gos-linux.c) - SET(libunwind_la_SOURCES_arm_os_local arm/Los-linux.c) - list(APPEND libunwind_coredump_la_SOURCES coredump/_UCD_access_reg_linux.c) -elseif(CLR_CMAKE_PLATFORM_FREEBSD) - SET(libunwind_la_SOURCES_os ${libunwind_la_SOURCES_os_freebsd}) - SET(libunwind_la_SOURCES_os_local ${libunwind_la_SOURCES_os_freebsd_local}) - SET(libunwind_la_SOURCES_x86_os x86/Gos-freebsd.c) - SET(libunwind_x86_la_SOURCES_os x86/getcontext-freebsd.S) - SET(libunwind_la_SOURCES_x86_os_local x86/Los-freebsd.c) - SET(libunwind_la_SOURCES_x86_64_os x86_64/Gos-freebsd.c) - SET(libunwind_la_SOURCES_x86_64_os_local x86_64/Los-freebsd.c) - SET(libunwind_la_SOURCES_arm_os arm/Gos-freebsd.c) - SET(libunwind_la_SOURCES_arm_os_local arm/Los-freebsd.c) - list(APPEND libunwind_coredump_la_SOURCES coredump/_UCD_access_reg_freebsd.c) -endif() - -# List of arch-independent files needed by both local-only and generic -# libraries: -SET(libunwind_la_SOURCES_common - ${libunwind_la_SOURCES_os} - mi/init.c mi/flush_cache.c mi/mempool.c mi/strerror.c -) - -SET(libunwind_la_SOURCES_local_unwind -# Nothing when we don't want to support CXX exceptions -) - -# List of arch-independent files needed by local-only library (libunwind): -SET(libunwind_la_SOURCES_local_nounwind - ${libunwind_la_SOURCES_os_local} - mi/backtrace.c - mi/dyn-cancel.c mi/dyn-info-list.c mi/dyn-register.c - mi/Ldyn-extract.c mi/Lfind_dynamic_proc_info.c - mi/Lget_accessors.c - mi/Lget_proc_info_by_ip.c mi/Lget_proc_name.c - mi/Lput_dynamic_unwind_info.c mi/Ldestroy_addr_space.c - mi/Lget_reg.c mi/Lset_reg.c - mi/Lget_fpreg.c mi/Lset_fpreg.c - mi/Lset_caching_policy.c - mi/Lset_cache_size.c -) - -SET(libunwind_la_SOURCES_local - ${libunwind_la_SOURCES_local_nounwind} - ${libunwind_la_SOURCES_local_unwind} -) - -SET(libunwind_dwarf_common_la_SOURCES - dwarf/global.c -) - -SET(libunwind_dwarf_local_la_SOURCES - dwarf/Lexpr.c dwarf/Lfde.c dwarf/Lparser.c dwarf/Lpe.c - dwarf/Lfind_proc_info-lsb.c - dwarf/Lfind_unwind_table.c -) - -SET(libunwind_dwarf_generic_la_SOURCES - dwarf/Gexpr.c dwarf/Gfde.c dwarf/Gparser.c dwarf/Gpe.c - dwarf/Gfind_proc_info-lsb.c - dwarf/Gfind_unwind_table.c -) - -SET(libunwind_elf32_la_SOURCES - elf32.c -) - -SET(libunwind_elf64_la_SOURCES - elf64.c -) -SET(libunwind_elfxx_la_SOURCES - elfxx.c -) - -# The list of files that go into libunwind and libunwind-aarch64: -SET(libunwind_la_SOURCES_aarch64_common - ${libunwind_la_SOURCES_common} - aarch64/is_fpreg.c - aarch64/regname.c -) - -# The list of files that go into libunwind: -SET(libunwind_la_SOURCES_aarch64 - ${libunwind_la_SOURCES_aarch64_common} - ${libunwind_la_SOURCES_local} - aarch64/Lapply_reg_state.c aarch64/Lreg_states_iterate.c - aarch64/Lcreate_addr_space.c aarch64/Lget_proc_info.c - aarch64/Lget_save_loc.c aarch64/Lglobal.c aarch64/Linit.c - aarch64/Linit_local.c aarch64/Linit_remote.c - aarch64/Lis_signal_frame.c aarch64/Lregs.c aarch64/Lresume.c - aarch64/Lstash_frame.c aarch64/Lstep.c aarch64/Ltrace.c - aarch64/getcontext.S -) - -SET(libunwind_aarch64_la_SOURCES_aarch64 - ${libunwind_la_SOURCES_aarch64_common} - ${libunwind_la_SOURCES_generic} - aarch64/Gapply_reg_state.c aarch64/Greg_states_iterate.c - aarch64/Gcreate_addr_space.c aarch64/Gget_proc_info.c - aarch64/Gget_save_loc.c aarch64/Gglobal.c aarch64/Ginit.c - aarch64/Ginit_local.c aarch64/Ginit_remote.c - aarch64/Gis_signal_frame.c aarch64/Gregs.c aarch64/Gresume.c - aarch64/Gstash_frame.c aarch64/Gstep.c aarch64/Gtrace.c -) - -# The list of files that go into libunwind and libunwind-arm: -SET(libunwind_la_SOURCES_arm_common - ${libunwind_la_SOURCES_common} - arm/is_fpreg.c arm/regname.c -) - -# The list of files that go into libunwind: -SET(libunwind_la_SOURCES_arm - ${libunwind_la_SOURCES_arm_common} - ${libunwind_la_SOURCES_arm_os_local} - ${libunwind_la_SOURCES_local} - arm/getcontext.S - arm/Lapply_reg_state.c arm/Lreg_states_iterate.c - arm/Lcreate_addr_space.c arm/Lget_proc_info.c arm/Lget_save_loc.c - arm/Lglobal.c arm/Linit.c arm/Linit_local.c arm/Linit_remote.c - arm/Lregs.c arm/Lresume.c arm/Lstep.c - arm/Lex_tables.c arm/Lstash_frame.c arm/Ltrace.c -) - -# The list of files that go into libunwind-arm: -SET(libunwind_arm_la_SOURCES_arm - ${libunwind_la_SOURCES_arm_common} - ${libunwind_la_SOURCES_arm_os} - ${libunwind_la_SOURCES_generic} - arm/Gapply_reg_state.c arm/Greg_states_iterate.c - arm/Gcreate_addr_space.c arm/Gget_proc_info.c arm/Gget_save_loc.c - arm/Gglobal.c arm/Ginit.c arm/Ginit_local.c arm/Ginit_remote.c - arm/Gregs.c arm/Gresume.c arm/Gstep.c - arm/Gex_tables.c arm/Gstash_frame.c arm/Gtrace.c -) - -# The list of files that go both into libunwind and libunwind-x86: -SET(libunwind_la_SOURCES_x86_common - ${libunwind_la_SOURCES_common} - x86/is_fpreg.c x86/regname.c -) - -# The list of files that go into libunwind: -SET(libunwind_la_SOURCES_x86 - ${libunwind_la_SOURCES_x86_common} - ${libunwind_la_SOURCES_x86_os_local} - ${libunwind_la_SOURCES_local} - x86/Lapply_reg_state.c x86/Lreg_states_iterate.c - x86/Lcreate_addr_space.c x86/Lget_save_loc.c x86/Lglobal.c - x86/Linit.c x86/Linit_local.c x86/Linit_remote.c - x86/Lget_proc_info.c x86/Lregs.c - x86/Lresume.c x86/Lstep.c -) - -# The list of files that go into libunwind-x86: -SET(libunwind_x86_la_SOURCES_x86 - ${libunwind_la_SOURCES_x86_common} - ${libunwind_la_SOURCES_x86_os} - ${libunwind_la_SOURCES_generic} - x86/Gapply_reg_state.c x86/Greg_states_iterate.c - x86/Gcreate_addr_space.c x86/Gget_save_loc.c x86/Gglobal.c - x86/Ginit.c x86/Ginit_local.c x86/Ginit_remote.c - x86/Gget_proc_info.c x86/Gregs.c - x86/Gresume.c x86/Gstep.c -) - -# The list of files that go both into libunwind and libunwind-x86_64: -SET(libunwind_la_SOURCES_x86_64_common - ${libunwind_la_SOURCES_common} - x86_64/is_fpreg.c x86_64/regname.c -) - -# The list of files that go into libunwind: -SET(libunwind_la_SOURCES_x86_64 - ${libunwind_la_SOURCES_x86_64_common} - ${libunwind_la_SOURCES_x86_64_os_local} - ${libunwind_la_SOURCES_local} - x86_64/setcontext.S - x86_64/Lapply_reg_state.c x86_64/Lreg_states_iterate.c - x86_64/Lcreate_addr_space.c x86_64/Lget_save_loc.c x86_64/Lglobal.c - x86_64/Linit.c x86_64/Linit_local.c x86_64/Linit_remote.c - x86_64/Lget_proc_info.c x86_64/Lregs.c x86_64/Lresume.c - x86_64/Lstash_frame.c x86_64/Lstep.c x86_64/Ltrace.c x86_64/getcontext.S -) - -# The list of files that go into libunwind-x86_64: -SET(libunwind_x86_64_la_SOURCES_x86_64 - ${libunwind_la_SOURCES_x86_64_common} - ${libunwind_la_SOURCES_x86_64_os} - ${libunwind_la_SOURCES_generic} - x86_64/Gapply_reg_state.c x86_64/Greg_states_iterate.c - x86_64/Gcreate_addr_space.c x86_64/Gget_save_loc.c x86_64/Gglobal.c - x86_64/Ginit.c x86_64/Ginit_local.c x86_64/Ginit_remote.c - x86_64/Gget_proc_info.c x86_64/Gregs.c x86_64/Gresume.c - x86_64/Gstash_frame.c x86_64/Gstep.c x86_64/Gtrace.c -) - -if(CLR_CMAKE_PLATFORM_ARCH_ARM64) - SET(libunwind_la_SOURCES ${libunwind_la_SOURCES_aarch64}) - SET(libunwind_remote_la_SOURCES ${libunwind_aarch64_la_SOURCES_aarch64}) - SET(libunwind_elf_la_SOURCES ${libunwind_elf64_la_SOURCES}) - list(APPEND libunwind_setjmp_la_SOURCES aarch64/siglongjmp.S) -elseif(CLR_CMAKE_PLATFORM_ARCH_ARM) - SET(libunwind_la_SOURCES ${libunwind_la_SOURCES_arm}) - SET(libunwind_remote_la_SOURCES ${libunwind_arm_la_SOURCES_arm}) - SET(libunwind_elf_la_SOURCES ${libunwind_elf32_la_SOURCES}) - list(APPEND libunwind_setjmp_la_SOURCES arm/siglongjmp.S) -elseif(CLR_CMAKE_PLATFORM_ARCH_I386) - SET(libunwind_la_SOURCES ${libunwind_la_SOURCES_x86} ${libunwind_x86_la_SOURCES_os}) - SET(libunwind_remote_la_SOURCES ${libunwind_x86_la_SOURCES_x86}) - SET(libunwind_elf_la_SOURCES ${libunwind_elf32_la_SOURCES}) - list(APPEND libunwind_setjmp_la_SOURCES x86/longjmp.S x86/siglongjmp.S) -elseif(CLR_CMAKE_PLATFORM_ARCH_AMD64) - SET(libunwind_la_SOURCES ${libunwind_la_SOURCES_x86_64}) - SET(libunwind_remote_la_SOURCES ${libunwind_x86_64_la_SOURCES_x86_64}) - SET(libunwind_elf_la_SOURCES ${libunwind_elf64_la_SOURCES}) - list(APPEND libunwind_setjmp_la_SOURCES x86_64/longjmp.S x86_64/siglongjmp.SA) -endif() - -add_library(libunwind - OBJECT - ${libunwind_la_SOURCES} - ${libunwind_remote_la_SOURCES} - ${libunwind_dwarf_local_la_SOURCES} - ${libunwind_dwarf_common_la_SOURCES} - ${libunwind_dwarf_generic_la_SOURCES} - ${libunwind_elf_la_SOURCES} -) - diff --git a/src/pal/src/libunwind/src/Makefile.am b/src/pal/src/libunwind/src/Makefile.am deleted file mode 100644 index a557d8d1f..000000000 --- a/src/pal/src/libunwind/src/Makefile.am +++ /dev/null @@ -1,750 +0,0 @@ -SOVERSION=8:1:0 # See comments at end of file. -SETJMP_SO_VERSION=0:0:0 -COREDUMP_SO_VERSION=0:0:0 -# -# Don't link with start-files since we don't use any constructors/destructors: -# -COMMON_SO_LDFLAGS = $(LDFLAGS_NOSTARTFILES) - -lib_LIBRARIES = -lib_LTLIBRARIES = -if !REMOTE_ONLY -lib_LTLIBRARIES += libunwind.la -if BUILD_PTRACE -lib_LTLIBRARIES += libunwind-ptrace.la -endif -if BUILD_COREDUMP -lib_LTLIBRARIES += libunwind-coredump.la -endif -endif - -noinst_HEADERS = -noinst_LTLIBRARIES = - -pkgconfigdir = $(libdir)/pkgconfig -pkgconfig_DATA = libunwind-generic.pc - -if !REMOTE_ONLY -pkgconfig_DATA += unwind/libunwind.pc -endif - -if BUILD_PTRACE -pkgconfig_DATA += ptrace/libunwind-ptrace.pc -endif - -if BUILD_SETJMP -pkgconfig_DATA += setjmp/libunwind-setjmp.pc -endif - -if BUILD_COREDUMP -pkgconfig_DATA += coredump/libunwind-coredump.pc -endif - -### libunwind-ptrace: -libunwind_ptrace_la_SOURCES = \ - ptrace/_UPT_elf.c \ - ptrace/_UPT_accessors.c ptrace/_UPT_access_fpreg.c \ - ptrace/_UPT_access_mem.c ptrace/_UPT_access_reg.c \ - ptrace/_UPT_create.c ptrace/_UPT_destroy.c \ - ptrace/_UPT_find_proc_info.c ptrace/_UPT_get_dyn_info_list_addr.c \ - ptrace/_UPT_put_unwind_info.c ptrace/_UPT_get_proc_name.c \ - ptrace/_UPT_reg_offset.c ptrace/_UPT_resume.c -noinst_HEADERS += ptrace/_UPT_internal.h - -### libunwind-coredump: -libunwind_coredump_la_SOURCES = \ - coredump/_UCD_accessors.c \ - coredump/_UCD_create.c \ - coredump/_UCD_destroy.c \ - coredump/_UCD_access_mem.c \ - coredump/_UCD_elf_map_image.c \ - coredump/_UCD_find_proc_info.c \ - coredump/_UCD_get_proc_name.c \ - \ - coredump/_UPT_elf.c \ - coredump/_UPT_access_fpreg.c \ - coredump/_UPT_get_dyn_info_list_addr.c \ - coredump/_UPT_put_unwind_info.c \ - coredump/_UPT_resume.c -libunwind_coredump_la_LDFLAGS = $(COMMON_SO_LDFLAGS) \ - -version-info $(COREDUMP_SO_VERSION) -libunwind_coredump_la_LIBADD = $(LIBLZMA) -noinst_HEADERS += coredump/_UCD_internal.h coredump/_UCD_lib.h - -### libunwind-setjmp: -libunwind_setjmp_la_LDFLAGS = $(COMMON_SO_LDFLAGS) \ - -version-info $(SETJMP_SO_VERSION) - -if USE_ELF32 -LIBUNWIND_ELF = libunwind-elf32.la -endif -if USE_ELF64 -LIBUNWIND_ELF = libunwind-elf64.la -endif -if USE_ELFXX -LIBUNWIND_ELF = libunwind-elfxx.la -endif - -libunwind_setjmp_la_LIBADD = $(LIBUNWIND_ELF) \ - libunwind-$(arch).la \ - libunwind.la -lc -libunwind_setjmp_la_SOURCES = setjmp/longjmp.c \ - setjmp/siglongjmp.c -noinst_HEADERS += setjmp/setjmp_i.h - -### libunwind: -libunwind_la_LIBADD = - -# List of arch-independent files needed by both local-only and generic -# libraries: -libunwind_la_SOURCES_common = \ - $(libunwind_la_SOURCES_os) \ - mi/init.c mi/flush_cache.c mi/mempool.c mi/strerror.c - -# List of arch-independent files needed by generic library (libunwind-$ARCH): -libunwind_la_SOURCES_generic = \ - mi/Gdyn-extract.c mi/Gdyn-remote.c mi/Gfind_dynamic_proc_info.c \ - mi/Gget_accessors.c \ - mi/Gget_proc_info_by_ip.c mi/Gget_proc_name.c \ - mi/Gput_dynamic_unwind_info.c mi/Gdestroy_addr_space.c \ - mi/Gget_reg.c mi/Gset_reg.c \ - mi/Gget_fpreg.c mi/Gset_fpreg.c \ - mi/Gset_caching_policy.c \ - mi/Gset_cache_size.c - -if SUPPORT_CXX_EXCEPTIONS -libunwind_la_SOURCES_local_unwind = \ - unwind/Backtrace.c unwind/DeleteException.c \ - unwind/FindEnclosingFunction.c unwind/ForcedUnwind.c \ - unwind/GetBSP.c unwind/GetCFA.c unwind/GetDataRelBase.c \ - unwind/GetGR.c unwind/GetIP.c unwind/GetLanguageSpecificData.c \ - unwind/GetRegionStart.c unwind/GetTextRelBase.c \ - unwind/RaiseException.c unwind/Resume.c \ - unwind/Resume_or_Rethrow.c unwind/SetGR.c unwind/SetIP.c \ - unwind/GetIPInfo.c - -# _ReadULEB()/_ReadSLEB() are needed for Intel C++ 8.0 compatibility -libunwind_la_SOURCES_os_linux_local = mi/_ReadULEB.c mi/_ReadSLEB.c -endif - -# List of arch-independent files needed by local-only library (libunwind): -libunwind_la_SOURCES_local_nounwind = \ - $(libunwind_la_SOURCES_os_local) \ - mi/backtrace.c \ - mi/dyn-cancel.c mi/dyn-info-list.c mi/dyn-register.c \ - mi/Ldyn-extract.c mi/Lfind_dynamic_proc_info.c \ - mi/Lget_accessors.c \ - mi/Lget_proc_info_by_ip.c mi/Lget_proc_name.c \ - mi/Lput_dynamic_unwind_info.c mi/Ldestroy_addr_space.c \ - mi/Lget_reg.c mi/Lset_reg.c \ - mi/Lget_fpreg.c mi/Lset_fpreg.c \ - mi/Lset_caching_policy.c \ - mi/Lset_cache_size.c - -libunwind_la_SOURCES_local = \ - $(libunwind_la_SOURCES_local_nounwind) \ - $(libunwind_la_SOURCES_local_unwind) - -noinst_HEADERS += os-linux.h -libunwind_la_SOURCES_os_linux = os-linux.c - -libunwind_la_SOURCES_os_hpux = os-hpux.c - -libunwind_la_SOURCES_os_freebsd = os-freebsd.c - -libunwind_la_SOURCES_os_qnx = os-qnx.c - -libunwind_dwarf_common_la_SOURCES = dwarf/global.c - -libunwind_dwarf_local_la_SOURCES = \ - dwarf/Lexpr.c dwarf/Lfde.c dwarf/Lparser.c dwarf/Lpe.c \ - dwarf/Lfind_proc_info-lsb.c \ - dwarf/Lfind_unwind_table.c -libunwind_dwarf_local_la_LIBADD = libunwind-dwarf-common.la - -libunwind_dwarf_generic_la_SOURCES = \ - dwarf/Gexpr.c dwarf/Gfde.c dwarf/Gparser.c dwarf/Gpe.c \ - dwarf/Gfind_proc_info-lsb.c \ - dwarf/Gfind_unwind_table.c -libunwind_dwarf_generic_la_LIBADD = libunwind-dwarf-common.la - -if USE_DWARF - noinst_LTLIBRARIES += libunwind-dwarf-common.la libunwind-dwarf-generic.la -if !REMOTE_ONLY - noinst_LTLIBRARIES += libunwind-dwarf-local.la -endif - libunwind_la_LIBADD += libunwind-dwarf-local.la -endif - -noinst_HEADERS += elf32.h elf64.h elfxx.h - -libunwind_elf32_la_SOURCES = elf32.c -libunwind_elf64_la_SOURCES = elf64.c -libunwind_elfxx_la_SOURCES = elfxx.c -libunwind_elf32_la_LIBADD = $(LIBLZMA) -libunwind_elf64_la_LIBADD = $(LIBLZMA) -libunwind_elfxx_la_LIBADD = $(LIBLZMA) - -noinst_LTLIBRARIES += $(LIBUNWIND_ELF) -libunwind_la_LIBADD += $(LIBUNWIND_ELF) - -# The list of files that go into libunwind and libunwind-aarch64: -noinst_HEADERS += aarch64/init.h aarch64/offsets.h aarch64/unwind_i.h -libunwind_la_SOURCES_aarch64_common = $(libunwind_la_SOURCES_common) \ - aarch64/is_fpreg.c aarch64/regname.c - -# The list of files that go into libunwind: -libunwind_la_SOURCES_aarch64 = $(libunwind_la_SOURCES_aarch64_common) \ - $(libunwind_la_SOURCES_local) \ - aarch64/Lapply_reg_state.c aarch64/Lreg_states_iterate.c \ - aarch64/Lcreate_addr_space.c aarch64/Lget_proc_info.c \ - aarch64/Lget_save_loc.c aarch64/Lglobal.c aarch64/Linit.c \ - aarch64/Linit_local.c aarch64/Linit_remote.c \ - aarch64/Lis_signal_frame.c aarch64/Lregs.c aarch64/Lresume.c \ - aarch64/Lstash_frame.c aarch64/Lstep.c aarch64/Ltrace.c \ - aarch64/getcontext.S - -libunwind_aarch64_la_SOURCES_aarch64 = $(libunwind_la_SOURCES_aarch64_common) \ - $(libunwind_la_SOURCES_generic) \ - aarch64/Gapply_reg_state.c aarch64/Greg_states_iterate.c \ - aarch64/Gcreate_addr_space.c aarch64/Gget_proc_info.c \ - aarch64/Gget_save_loc.c aarch64/Gglobal.c aarch64/Ginit.c \ - aarch64/Ginit_local.c aarch64/Ginit_remote.c \ - aarch64/Gis_signal_frame.c aarch64/Gregs.c aarch64/Gresume.c \ - aarch64/Gstash_frame.c aarch64/Gstep.c aarch64/Gtrace.c - -# The list of files that go into libunwind and libunwind-arm: -noinst_HEADERS += arm/init.h arm/offsets.h arm/unwind_i.h -libunwind_la_SOURCES_arm_common = $(libunwind_la_SOURCES_common) \ - arm/is_fpreg.c arm/regname.c - -# The list of files that go into libunwind: -libunwind_la_SOURCES_arm = $(libunwind_la_SOURCES_arm_common) \ - $(libunwind_la_SOURCES_arm_os_local) \ - $(libunwind_la_SOURCES_local) \ - arm/getcontext.S \ - arm/Lapply_reg_state.c arm/Lreg_states_iterate.c \ - arm/Lcreate_addr_space.c arm/Lget_proc_info.c arm/Lget_save_loc.c \ - arm/Lglobal.c arm/Linit.c arm/Linit_local.c arm/Linit_remote.c \ - arm/Lregs.c arm/Lresume.c arm/Lstep.c \ - arm/Lex_tables.c arm/Lstash_frame.c arm/Ltrace.c - -# The list of files that go into libunwind-arm: -libunwind_arm_la_SOURCES_arm = $(libunwind_la_SOURCES_arm_common) \ - $(libunwind_la_SOURCES_arm_os) \ - $(libunwind_la_SOURCES_generic) \ - arm/Gapply_reg_state.c arm/Greg_states_iterate.c \ - arm/Gcreate_addr_space.c arm/Gget_proc_info.c arm/Gget_save_loc.c \ - arm/Gglobal.c arm/Ginit.c arm/Ginit_local.c arm/Ginit_remote.c \ - arm/Gregs.c arm/Gresume.c arm/Gstep.c \ - arm/Gex_tables.c arm/Gstash_frame.c arm/Gtrace.c - -# The list of files that go both into libunwind and libunwind-ia64: -noinst_HEADERS += ia64/init.h ia64/offsets.h ia64/regs.h \ - ia64/ucontext_i.h ia64/unwind_decoder.h ia64/unwind_i.h -libunwind_la_SOURCES_ia64_common = $(libunwind_la_SOURCES_common) \ - ia64/regname.c - -# The list of files that go into libunwind: -libunwind_la_SOURCES_ia64 = $(libunwind_la_SOURCES_ia64_common) \ - $(libunwind_la_SOURCES_local) \ - \ - ia64/dyn_info_list.S ia64/getcontext.S \ - \ - ia64/Lapply_reg_state.c ia64/Lreg_states_iterate.c \ - ia64/Lcreate_addr_space.c ia64/Lget_proc_info.c ia64/Lget_save_loc.c \ - ia64/Lglobal.c ia64/Linit.c ia64/Linit_local.c ia64/Linit_remote.c \ - ia64/Linstall_cursor.S ia64/Lis_signal_frame.c ia64/Lparser.c \ - ia64/Lrbs.c ia64/Lregs.c ia64/Lresume.c ia64/Lscript.c ia64/Lstep.c \ - ia64/Ltables.c ia64/Lfind_unwind_table.c - -# The list of files that go into libunwind-ia64: -libunwind_ia64_la_SOURCES_ia64 = $(libunwind_la_SOURCES_ia64_common) \ - $(libunwind_la_SOURCES_generic) \ - ia64/Gapply_reg_state.c ia64/Greg_states_iterate.c \ - ia64/Gcreate_addr_space.c ia64/Gget_proc_info.c ia64/Gget_save_loc.c \ - ia64/Gglobal.c ia64/Ginit.c ia64/Ginit_local.c ia64/Ginit_remote.c \ - ia64/Ginstall_cursor.S ia64/Gis_signal_frame.c ia64/Gparser.c \ - ia64/Grbs.c ia64/Gregs.c ia64/Gresume.c ia64/Gscript.c ia64/Gstep.c \ - ia64/Gtables.c ia64/Gfind_unwind_table.c - -# The list of files that go both into libunwind and libunwind-hppa: -noinst_HEADERS += hppa/init.h hppa/offsets.h hppa/unwind_i.h -libunwind_la_SOURCES_hppa_common = $(libunwind_la_SOURCES_common) \ - hppa/regname.c - -# The list of files that go into libunwind: -libunwind_la_SOURCES_hppa = $(libunwind_la_SOURCES_hppa_common) \ - $(libunwind_la_SOURCES_local) \ - hppa/getcontext.S hppa/setcontext.S \ - hppa/Lapply_reg_state.c hppa/Lreg_states_iterate.c \ - hppa/Lcreate_addr_space.c hppa/Lget_save_loc.c hppa/Lglobal.c \ - hppa/Linit.c hppa/Linit_local.c hppa/Linit_remote.c \ - hppa/Lis_signal_frame.c hppa/Lget_proc_info.c hppa/Lregs.c \ - hppa/Lresume.c hppa/Lstep.c - -# The list of files that go into libunwind-hppa: -libunwind_hppa_la_SOURCES_hppa = $(libunwind_la_SOURCES_hppa_common) \ - $(libunwind_la_SOURCES_generic) \ - hppa/Gapply_reg_state.c hppa/Greg_states_iterate.c \ - hppa/Gcreate_addr_space.c hppa/Gget_save_loc.c hppa/Gglobal.c \ - hppa/Ginit.c hppa/Ginit_local.c hppa/Ginit_remote.c \ - hppa/Gis_signal_frame.c hppa/Gget_proc_info.c hppa/Gregs.c \ - hppa/Gresume.c hppa/Gstep.c - -# The list of files that go info libunwind and libunwind-mips: -noinst_HEADERS += mips/init.h mips/offsets.h mips/unwind_i.h -libunwind_la_SOURCES_mips_common = $(libunwind_la_SOURCES_common) \ - mips/is_fpreg.c mips/regname.c - -# The list of files that go into libunwind: -libunwind_la_SOURCES_mips = $(libunwind_la_SOURCES_mips_common) \ - $(libunwind_la_SOURCES_local) \ - mips/getcontext.S \ - mips/Lapply_reg_state.c mips/Lreg_states_iterate.c \ - mips/Lcreate_addr_space.c mips/Lget_proc_info.c mips/Lget_save_loc.c \ - mips/Lglobal.c mips/Linit.c mips/Linit_local.c mips/Linit_remote.c \ - mips/Lis_signal_frame.c mips/Lregs.c mips/Lresume.c mips/Lstep.c - -libunwind_mips_la_SOURCES_mips = $(libunwind_la_SOURCES_mips_common) \ - $(libunwind_la_SOURCES_generic) \ - mips/Gapply_reg_state.c mips/Greg_states_iterate.c \ - mips/Gcreate_addr_space.c mips/Gget_proc_info.c mips/Gget_save_loc.c \ - mips/Gglobal.c mips/Ginit.c mips/Ginit_local.c mips/Ginit_remote.c \ - mips/Gis_signal_frame.c mips/Gregs.c mips/Gresume.c mips/Gstep.c - -# The list of files that go info libunwind and libunwind-tilegx: -noinst_HEADERS += tilegx/init.h tilegx/offsets.h tilegx/unwind_i.h -libunwind_la_SOURCES_tilegx_common = $(libunwind_la_SOURCES_common) \ - tilegx/is_fpreg.c tilegx/regname.c - -# The list of files that go into libunwind: -libunwind_la_SOURCES_tilegx = $(libunwind_la_SOURCES_tilegx_common) \ - $(libunwind_la_SOURCES_local) \ - tilegx/getcontext.S \ - tilegx/Lapply_reg_state.c tilegx/Lreg_states_iterate.c \ - tilegx/Lcreate_addr_space.c tilegx/Lget_proc_info.c tilegx/Lget_save_loc.c \ - tilegx/Lglobal.c tilegx/Linit.c tilegx/Linit_local.c tilegx/Linit_remote.c \ - tilegx/Lis_signal_frame.c tilegx/Lregs.c tilegx/Lresume.c tilegx/Lstep.c - -libunwind_tilegx_la_SOURCES_tilegx = $(libunwind_la_SOURCES_tilegx_common) \ - $(libunwind_la_SOURCES_generic) \ - tilegx/Gapply_reg_state.c tilegx/Greg_states_iterate.c \ - tilegx/Gcreate_addr_space.c tilegx/Gget_proc_info.c tilegx/Gget_save_loc.c \ - tilegx/Gglobal.c tilegx/Ginit.c tilegx/Ginit_local.c tilegx/Ginit_remote.c \ - tilegx/Gis_signal_frame.c tilegx/Gregs.c tilegx/Gresume.c tilegx/Gstep.c - - -# The list of files that go both into libunwind and libunwind-x86: -noinst_HEADERS += x86/init.h x86/offsets.h x86/unwind_i.h -libunwind_la_SOURCES_x86_common = $(libunwind_la_SOURCES_common) \ - x86/is_fpreg.c x86/regname.c - -# The list of files that go into libunwind: -libunwind_la_SOURCES_x86 = $(libunwind_la_SOURCES_x86_common) \ - $(libunwind_la_SOURCES_x86_os_local) \ - $(libunwind_la_SOURCES_local) \ - x86/Lapply_reg_state.c x86/Lreg_states_iterate.c \ - x86/Lcreate_addr_space.c x86/Lget_save_loc.c x86/Lglobal.c \ - x86/Linit.c x86/Linit_local.c x86/Linit_remote.c \ - x86/Lget_proc_info.c x86/Lregs.c \ - x86/Lresume.c x86/Lstep.c - -# The list of files that go into libunwind-x86: -libunwind_x86_la_SOURCES_x86 = $(libunwind_la_SOURCES_x86_common) \ - $(libunwind_la_SOURCES_x86_os) \ - $(libunwind_la_SOURCES_generic) \ - x86/Gapply_reg_state.c x86/Greg_states_iterate.c \ - x86/Gcreate_addr_space.c x86/Gget_save_loc.c x86/Gglobal.c \ - x86/Ginit.c x86/Ginit_local.c x86/Ginit_remote.c \ - x86/Gget_proc_info.c x86/Gregs.c \ - x86/Gresume.c x86/Gstep.c - -# The list of files that go both into libunwind and libunwind-x86_64: -noinst_HEADERS += x86_64/offsets.h \ - x86_64/init.h x86_64/unwind_i.h x86_64/ucontext_i.h -libunwind_la_SOURCES_x86_64_common = $(libunwind_la_SOURCES_common) \ - x86_64/is_fpreg.c x86_64/regname.c - -# The list of files that go into libunwind: -libunwind_la_SOURCES_x86_64 = $(libunwind_la_SOURCES_x86_64_common) \ - $(libunwind_la_SOURCES_x86_64_os_local) \ - $(libunwind_la_SOURCES_local) \ - x86_64/setcontext.S \ - x86_64/Lapply_reg_state.c x86_64/Lreg_states_iterate.c \ - x86_64/Lcreate_addr_space.c x86_64/Lget_save_loc.c x86_64/Lglobal.c \ - x86_64/Linit.c x86_64/Linit_local.c x86_64/Linit_remote.c \ - x86_64/Lget_proc_info.c x86_64/Lregs.c x86_64/Lresume.c \ - x86_64/Lstash_frame.c x86_64/Lstep.c x86_64/Ltrace.c x86_64/getcontext.S - -# The list of files that go into libunwind-x86_64: -libunwind_x86_64_la_SOURCES_x86_64 = $(libunwind_la_SOURCES_x86_64_common) \ - $(libunwind_la_SOURCES_x86_64_os) \ - $(libunwind_la_SOURCES_generic) \ - x86_64/Gapply_reg_state.c x86_64/Greg_states_iterate.c \ - x86_64/Gcreate_addr_space.c x86_64/Gget_save_loc.c x86_64/Gglobal.c \ - x86_64/Ginit.c x86_64/Ginit_local.c x86_64/Ginit_remote.c \ - x86_64/Gget_proc_info.c x86_64/Gregs.c x86_64/Gresume.c \ - x86_64/Gstash_frame.c x86_64/Gstep.c x86_64/Gtrace.c - -# The list of local files that go to Power 64 and 32: -libunwind_la_SOURCES_ppc = \ - ppc/Lget_proc_info.c ppc/Lget_save_loc.c ppc/Linit_local.c \ - ppc/Linit_remote.c ppc/Lis_signal_frame.c - -# The list of generic files that go to Power 64 and 32: -libunwind_ppc_la_SOURCES_ppc_generic = \ - ppc/Gget_proc_info.c ppc/Gget_save_loc.c ppc/Ginit_local.c \ - ppc/Ginit_remote.c ppc/Gis_signal_frame.c - -# The list of files that go both into libunwind and libunwind-ppc32: -noinst_HEADERS += ppc32/init.h ppc32/unwind_i.h ppc32/ucontext_i.h -libunwind_la_SOURCES_ppc32_common = $(libunwind_la_SOURCES_common) \ - ppc32/is_fpreg.c ppc32/regname.c ppc32/get_func_addr.c - -# The list of files that go into libunwind: -libunwind_la_SOURCES_ppc32 = $(libunwind_la_SOURCES_ppc32_common) \ - $(libunwind_la_SOURCES_local) \ - $(libunwind_la_SOURCES_ppc) \ - ppc32/Lapply_reg_state.c ppc32/Lreg_states_iterate.c \ - ppc32/Lcreate_addr_space.c \ - ppc32/Lglobal.c ppc32/Linit.c \ - ppc32/Lregs.c ppc32/Lresume.c ppc32/Lstep.c - -# The list of files that go into libunwind-ppc32: -libunwind_ppc32_la_SOURCES_ppc32 = $(libunwind_la_SOURCES_ppc32_common) \ - $(libunwind_la_SOURCES_generic) \ - $(libunwind_ppc_la_SOURCES_ppc_generic) \ - ppc32/Gapply_reg_state.c ppc32/Greg_states_iterate.c \ - ppc32/Gcreate_addr_space.c \ - ppc32/Gglobal.c ppc32/Ginit.c \ - ppc32/Gregs.c ppc32/Gresume.c ppc32/Gstep.c - -# The list of files that go both into libunwind and libunwind-ppc64: -noinst_HEADERS += ppc64/init.h ppc64/unwind_i.h ppc64/ucontext_i.h -libunwind_la_SOURCES_ppc64_common = $(libunwind_la_SOURCES_common) \ - ppc64/is_fpreg.c ppc64/regname.c ppc64/get_func_addr.c - -# The list of files that go into libunwind: -libunwind_la_SOURCES_ppc64 = $(libunwind_la_SOURCES_ppc64_common) \ - $(libunwind_la_SOURCES_local) \ - $(libunwind_la_SOURCES_ppc) \ - ppc64/Lapply_reg_state.c ppc64/Lreg_states_iterate.c \ - ppc64/Lcreate_addr_space.c \ - ppc64/Lglobal.c ppc64/Linit.c \ - ppc64/Lregs.c ppc64/Lresume.c ppc64/Lstep.c - -# The list of files that go into libunwind-ppc64: -libunwind_ppc64_la_SOURCES_ppc64 = $(libunwind_la_SOURCES_ppc64_common) \ - $(libunwind_la_SOURCES_generic) \ - $(libunwind_ppc_la_SOURCES_ppc_generic) \ - ppc64/Gapply_reg_state.c ppc64/Greg_states_iterate.c \ - ppc64/Gcreate_addr_space.c \ - ppc64/Gglobal.c ppc64/Ginit.c \ - ppc64/Gregs.c ppc64/Gresume.c ppc64/Gstep.c - -# The list of files that go into libunwind and libunwind-sh: -noinst_HEADERS += sh/init.h sh/offsets.h sh/unwind_i.h -libunwind_la_SOURCES_sh_common = $(libunwind_la_SOURCES_common) \ - sh/is_fpreg.c sh/regname.c - -# The list of files that go into libunwind: -libunwind_la_SOURCES_sh = $(libunwind_la_SOURCES_sh_common) \ - $(libunwind_la_SOURCES_local) \ - sh/Lapply_reg_state.c sh/Lreg_states_iterate.c \ - sh/Lcreate_addr_space.c sh/Lget_proc_info.c sh/Lget_save_loc.c \ - sh/Lglobal.c sh/Linit.c sh/Linit_local.c sh/Linit_remote.c \ - sh/Lis_signal_frame.c sh/Lregs.c sh/Lresume.c sh/Lstep.c - -libunwind_sh_la_SOURCES_sh = $(libunwind_la_SOURCES_sh_common) \ - $(libunwind_la_SOURCES_generic) \ - sh/Gapply_reg_state.c sh/Greg_states_iterate.c \ - sh/Gcreate_addr_space.c sh/Gget_proc_info.c sh/Gget_save_loc.c \ - sh/Gglobal.c sh/Ginit.c sh/Ginit_local.c sh/Ginit_remote.c \ - sh/Gis_signal_frame.c sh/Gregs.c sh/Gresume.c sh/Gstep.c - -if REMOTE_ONLY -install-exec-hook: -# Nothing to do here.... -else -# -# This is not ideal, but I know of no other way to install an -# alias for a library. For the shared version, we have to do -# a file check before creating the link, because it isn't going -# to be there if the user configured with --disable-shared. -# -install-exec-hook: - if test -f $(DESTDIR)$(libdir)/libunwind-$(arch).a; then \ - cd $(DESTDIR)$(libdir) && $(LN_S) -f libunwind-$(arch).a libunwind-generic.a; \ - fi - if test -f $(DESTDIR)$(libdir)/libunwind-$(arch).so; then \ - cd $(DESTDIR)$(libdir) && $(LN_S) -f libunwind-$(arch).so \ - libunwind-generic.so; \ - fi -endif - -if OS_LINUX - libunwind_la_SOURCES_os = $(libunwind_la_SOURCES_os_linux) - libunwind_la_SOURCES_os_local = $(libunwind_la_SOURCES_os_linux_local) - libunwind_la_SOURCES_x86_os = x86/Gos-linux.c - libunwind_x86_la_SOURCES_os = x86/getcontext-linux.S - libunwind_la_SOURCES_x86_os_local = x86/Los-linux.c - libunwind_la_SOURCES_x86_64_os = x86_64/Gos-linux.c - libunwind_la_SOURCES_x86_64_os_local = x86_64/Los-linux.c - libunwind_la_SOURCES_arm_os = arm/Gos-linux.c - libunwind_la_SOURCES_arm_os_local = arm/Los-linux.c - libunwind_coredump_la_SOURCES += coredump/_UCD_access_reg_linux.c -endif - -if OS_HPUX - libunwind_la_SOURCES_os = $(libunwind_la_SOURCES_os_hpux) - libunwind_la_SOURCES_os_local = $(libunwind_la_SOURCES_os_hpux_local) -endif - -if OS_FREEBSD - libunwind_la_SOURCES_os = $(libunwind_la_SOURCES_os_freebsd) - libunwind_la_SOURCES_os_local = $(libunwind_la_SOURCES_os_freebsd_local) - libunwind_la_SOURCES_x86_os = x86/Gos-freebsd.c - libunwind_x86_la_SOURCES_os = x86/getcontext-freebsd.S - libunwind_la_SOURCES_x86_os_local = x86/Los-freebsd.c - libunwind_la_SOURCES_x86_64_os = x86_64/Gos-freebsd.c - libunwind_la_SOURCES_x86_64_os_local = x86_64/Los-freebsd.c - libunwind_la_SOURCES_arm_os = arm/Gos-freebsd.c - libunwind_la_SOURCES_arm_os_local = arm/Los-freebsd.c - libunwind_coredump_la_SOURCES += coredump/_UCD_access_reg_freebsd.c -endif - -if OS_QNX - libunwind_la_SOURCES_os = $(libunwind_la_SOURCES_os_qnx) - libunwind_la_SOURCES_os_local = $(libunwind_la_SOURCES_os_qnx_local) - libunwind_la_SOURCES_arm_os = arm/Gos-other.c - libunwind_la_SOURCES_arm_os_local = arm/Los-other.c -endif - -if ARCH_AARCH64 - lib_LTLIBRARIES += libunwind-aarch64.la - libunwind_la_SOURCES = $(libunwind_la_SOURCES_aarch64) - libunwind_aarch64_la_SOURCES = $(libunwind_aarch64_la_SOURCES_aarch64) - libunwind_aarch64_la_LDFLAGS = $(COMMON_SO_LDFLAGS) -version-info $(SOVERSION) - libunwind_aarch64_la_LIBADD = libunwind-dwarf-generic.la - libunwind_aarch64_la_LIBADD += libunwind-elf64.la -if !REMOTE_ONLY - libunwind_aarch64_la_LIBADD += libunwind.la -lc -endif - libunwind_setjmp_la_SOURCES += aarch64/siglongjmp.S -else -if ARCH_ARM - lib_LTLIBRARIES += libunwind-arm.la - libunwind_la_SOURCES = $(libunwind_la_SOURCES_arm) - libunwind_arm_la_SOURCES = $(libunwind_arm_la_SOURCES_arm) - libunwind_arm_la_LDFLAGS = $(COMMON_SO_LDFLAGS) -version-info $(SOVERSION) - libunwind_arm_la_LIBADD = libunwind-dwarf-generic.la - libunwind_arm_la_LIBADD += libunwind-elf32.la -if !REMOTE_ONLY - libunwind_arm_la_LIBADD += libunwind.la -lc -endif - libunwind_setjmp_la_SOURCES += arm/siglongjmp.S -else -if ARCH_IA64 - BUILT_SOURCES = Gcursor_i.h Lcursor_i.h -mk_Gcursor_i.s: $(srcdir)/ia64/mk_Gcursor_i.c - $(COMPILE) -S "$(srcdir)/ia64/mk_Gcursor_i.c" -o mk_Gcursor_i.s -mk_Lcursor_i.s: $(srcdir)/ia64/mk_Lcursor_i.c - $(COMPILE) -S "$(srcdir)/ia64/mk_Lcursor_i.c" -o mk_Lcursor_i.s -Gcursor_i.h: mk_Gcursor_i.s - "$(srcdir)/ia64/mk_cursor_i" mk_Gcursor_i.s > Gcursor_i.h -Lcursor_i.h: mk_Lcursor_i.s - "$(srcdir)/ia64/mk_cursor_i" mk_Lcursor_i.s > Lcursor_i.h - - lib_LTLIBRARIES += libunwind-ia64.la - libunwind_la_SOURCES = $(libunwind_la_SOURCES_ia64) - libunwind_ia64_la_SOURCES = $(libunwind_ia64_la_SOURCES_ia64) - libunwind_ia64_la_LDFLAGS = $(COMMON_SO_LDFLAGS) -version-info $(SOVERSION) - libunwind_ia64_la_LIBADD = libunwind-elf64.la -if !REMOTE_ONLY - libunwind_ia64_la_LIBADD += libunwind.la -lc -endif - libunwind_setjmp_la_SOURCES += ia64/setjmp.S ia64/sigsetjmp.S \ - ia64/longjmp.S ia64/siglongjmp.S -else -if ARCH_HPPA - lib_LTLIBRARIES += libunwind-hppa.la - libunwind_la_SOURCES = $(libunwind_la_SOURCES_hppa) - libunwind_hppa_la_SOURCES = $(libunwind_hppa_la_SOURCES_hppa) - libunwind_hppa_la_LDFLAGS = $(COMMON_SO_LDFLAGS) -version-info $(SOVERSION) - libunwind_hppa_la_LIBADD = libunwind-dwarf-generic.la - libunwind_hppa_la_LIBADD += libunwind-elf32.la -if !REMOTE_ONLY - libunwind_hppa_la_LIBADD += libunwind.la -lc -endif - libunwind_setjmp_la_SOURCES += hppa/siglongjmp.S -else -if ARCH_MIPS - lib_LTLIBRARIES += libunwind-mips.la - libunwind_la_SOURCES = $(libunwind_la_SOURCES_mips) - libunwind_mips_la_SOURCES = $(libunwind_mips_la_SOURCES_mips) - libunwind_mips_la_LDFLAGS = $(COMMON_SO_LDFLAGS) -version-info $(SOVERSION) - libunwind_mips_la_LIBADD = libunwind-dwarf-generic.la - libunwind_mips_la_LIBADD += libunwind-elfxx.la -if !REMOTE_ONLY - libunwind_mips_la_LIBADD += libunwind.la -lc -endif - libunwind_setjmp_la_SOURCES += mips/siglongjmp.S -else -if ARCH_TILEGX - lib_LTLIBRARIES += libunwind-tilegx.la - libunwind_la_SOURCES = $(libunwind_la_SOURCES_tilegx) - libunwind_tilegx_la_SOURCES = $(libunwind_tilegx_la_SOURCES_tilegx) - libunwind_tilegx_la_LDFLAGS = $(COMMON_SO_LDFLAGS) -version-info $(SOVERSION) - libunwind_tilegx_la_LIBADD = libunwind-dwarf-generic.la - libunwind_tilegx_la_LIBADD += libunwind-elfxx.la -if !REMOTE_ONLY - libunwind_tilegx_la_LIBADD += libunwind.la -lc -endif - libunwind_setjmp_la_SOURCES += tilegx/siglongjmp.S -else -if ARCH_X86 - lib_LTLIBRARIES += libunwind-x86.la - libunwind_la_SOURCES = $(libunwind_la_SOURCES_x86) $(libunwind_x86_la_SOURCES_os) - libunwind_x86_la_SOURCES = $(libunwind_x86_la_SOURCES_x86) - libunwind_x86_la_LDFLAGS = $(COMMON_SO_LDFLAGS) -version-info $(SOVERSION) - libunwind_x86_la_LIBADD = libunwind-dwarf-generic.la - libunwind_x86_la_LIBADD += libunwind-elf32.la -if !REMOTE_ONLY - libunwind_x86_la_LIBADD += libunwind.la -lc -endif - libunwind_setjmp_la_SOURCES += x86/longjmp.S x86/siglongjmp.S -else -if ARCH_X86_64 - lib_LTLIBRARIES += libunwind-x86_64.la - libunwind_la_SOURCES = $(libunwind_la_SOURCES_x86_64) - libunwind_x86_64_la_SOURCES = $(libunwind_x86_64_la_SOURCES_x86_64) - libunwind_x86_64_la_LDFLAGS = $(COMMON_SO_LDFLAGS) -version-info $(SOVERSION) - libunwind_x86_64_la_LIBADD = libunwind-dwarf-generic.la - libunwind_x86_64_la_LIBADD += libunwind-elf64.la -if !REMOTE_ONLY - libunwind_x86_64_la_LIBADD += libunwind.la -lc -endif - libunwind_setjmp_la_SOURCES += x86_64/longjmp.S x86_64/siglongjmp.S -else -if ARCH_PPC32 - lib_LTLIBRARIES += libunwind-ppc32.la - libunwind_la_SOURCES = $(libunwind_la_SOURCES_ppc32) - libunwind_ppc32_la_SOURCES = $(libunwind_ppc32_la_SOURCES_ppc32) - libunwind_ppc32_la_LDFLAGS = $(COMMON_SO_LDFLAGS) -version-info $(SOVERSION) - libunwind_ppc32_la_LIBADD = libunwind-dwarf-generic.la - libunwind_ppc32_la_LIBADD += libunwind-elf32.la -if !REMOTE_ONLY - libunwind_ppc32_la_LIBADD += libunwind.la -lc -endif - libunwind_setjmp_la_SOURCES += ppc/longjmp.S ppc/siglongjmp.S -else -if ARCH_PPC64 - lib_LTLIBRARIES += libunwind-ppc64.la - libunwind_la_SOURCES = $(libunwind_la_SOURCES_ppc64) - libunwind_ppc64_la_SOURCES = $(libunwind_ppc64_la_SOURCES_ppc64) - libunwind_ppc64_la_LDFLAGS = $(COMMON_SO_LDFLAGS) -version-info $(SOVERSION) - libunwind_ppc64_la_LIBADD = libunwind-dwarf-generic.la - libunwind_ppc64_la_LIBADD += libunwind-elf64.la -if !REMOTE_ONLY - libunwind_ppc64_la_LIBADD += libunwind.la -lc -endif - libunwind_setjmp_la_SOURCES += ppc/longjmp.S ppc/siglongjmp.S -else -if ARCH_SH - lib_LTLIBRARIES += libunwind-sh.la - libunwind_la_SOURCES = $(libunwind_la_SOURCES_sh) - libunwind_sh_la_SOURCES = $(libunwind_sh_la_SOURCES_sh) - libunwind_sh_la_LDFLAGS = $(COMMON_SO_LDFLAGS) -version-info $(SOVERSION) - libunwind_sh_la_LIBADD = libunwind-dwarf-generic.la - libunwind_sh_la_LIBADD += libunwind-elf32.la -if !REMOTE_ONLY - libunwind_sh_la_LIBADD += libunwind.la -lc -endif - libunwind_setjmp_la_SOURCES += sh/siglongjmp.S - -endif # ARCH_SH -endif # ARCH_PPC64 -endif # ARCH_PPC32 -endif # ARCH_X86_64 -endif # ARCH_X86 -endif # ARCH_TILEGX -endif # ARCH_MIPS -endif # ARCH_HPPA -endif # ARCH_IA64 -endif # ARCH_ARM -endif # ARCH_AARCH64 - -# libunwind-setjmp depends on libunwind-$(arch). Therefore must be added -# at the end. -if BUILD_SETJMP -lib_LTLIBRARIES += libunwind-setjmp.la -endif - -# -# Don't link with standard libraries, because those may mention -# libunwind already. -# -libunwind_la_LDFLAGS = $(COMMON_SO_LDFLAGS) -XCClinker -nostdlib \ - $(LDFLAGS_STATIC_LIBCXA) -version-info $(SOVERSION) -libunwind_la_LIBADD += -lc $(LIBCRTS) -libunwind_la_LIBADD += $(LIBLZMA) - -AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/include/tdep-$(arch) -I. -AM_CCASFLAGS = $(AM_CPPFLAGS) -noinst_HEADERS += unwind/unwind-internal.h - -EXTRA_DIST = $(libunwind_la_SOURCES_aarch64) \ - $(libunwind_la_SOURCES_arm) \ - $(libunwind_la_SOURCES_hppa) \ - $(libunwind_la_SOURCES_ia64) \ - $(libunwind_la_SOURCES_mips) \ - $(libunwind_la_SOURCES_sh) \ - $(libunwind_la_SOURCES_x86) \ - $(libunwind_la_SOURCES_os_freebsd) \ - $(libunwind_la_SOURCES_os_linux) \ - $(libunwind_la_SOURCES_os_hpux) \ - $(libunwind_la_SOURCES_os_qnx) \ - $(libunwind_la_SOURCES_common) \ - $(libunwind_la_SOURCES_local) \ - $(libunwind_la_SOURCES_generic) \ - $(libunwind_aarch64_la_SOURCES_aarch64) \ - $(libunwind_arm_la_SOURCES_arm) \ - $(libunwind_hppa_la_SOURCES_hppa) \ - $(libunwind_ia64_la_SOURCES_ia64) \ - $(libunwind_mips_la_SOURCES_mips) \ - $(libunwind_sh_la_SOURCES_sh) \ - $(libunwind_x86_la_SOURCES_x86) \ - $(libunwind_x86_64_la_SOURCES_x86_64) - -MAINTAINERCLEANFILES = Makefile.in - -# The -version-info flag accepts an argument of the form -# `current[:revision[:age]]'. So, passing `-version-info 3:12:1' sets -# current to 3, revision to 12, and age to 1. - -# If either revision or age are omitted, they default to 0. Also note -# that age must be less than or equal to the current interface number. - -# Here are a set of rules to help you update your library version -# information: - -# 1. Start with version information of `0:0:0' for each libtool -# library. - -# 2. Update the version information only immediately before a public -# release of your software. More frequent updates are unnecessary, -# and only guarantee that the current interface number gets larger -# faster. - -# 3. If the library source code has changed at all since the last -# update, then increment revision (`c:r:a' becomes `c:r+1:a'). - -# 4. If any interfaces have been added, removed, or changed since the -# last update, increment current, and set revision to 0. - -# 5. If any interfaces have been added since the last public release, -# then increment age. - -# 6. If any interfaces have been removed since the last public -# release, then set age to 0. diff --git a/src/pal/src/libunwind/src/aarch64/Gapply_reg_state.c b/src/pal/src/libunwind/src/aarch64/Gapply_reg_state.c deleted file mode 100644 index 82f056da6..000000000 --- a/src/pal/src/libunwind/src/aarch64/Gapply_reg_state.c +++ /dev/null @@ -1,37 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (c) 2002-2003 Hewlett-Packard Development Company, L.P. - Contributed by David Mosberger-Tang - - Modified for x86_64 by Max Asbock - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" - -int -unw_apply_reg_state (unw_cursor_t *cursor, - void *reg_states_data) -{ - struct cursor *c = (struct cursor *) cursor; - - return dwarf_apply_reg_state (&c->dwarf, (dwarf_reg_state_t *)reg_states_data); -} diff --git a/src/pal/src/libunwind/src/aarch64/Gcreate_addr_space.c b/src/pal/src/libunwind/src/aarch64/Gcreate_addr_space.c deleted file mode 100644 index f217adc74..000000000 --- a/src/pal/src/libunwind/src/aarch64/Gcreate_addr_space.c +++ /dev/null @@ -1,60 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2012 Tommi Rantala - Copyright (C) 2013 Linaro Limited - -This file is part of libunwind. - -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. */ - -#include -#include - -#include "unwind_i.h" - -unw_addr_space_t -unw_create_addr_space (unw_accessors_t *a, int byte_order) -{ -#ifdef UNW_LOCAL_ONLY - return NULL; -#else - unw_addr_space_t as; - - /* AArch64 supports little-endian and big-endian. */ - if (byte_order != 0 && byte_order != __LITTLE_ENDIAN - && byte_order != __BIG_ENDIAN) - return NULL; - - as = malloc (sizeof (*as)); - if (!as) - return NULL; - - memset (as, 0, sizeof (*as)); - - as->acc = *a; - - /* Default to little-endian for AArch64. */ - if (byte_order == 0 || byte_order == __LITTLE_ENDIAN) - as->big_endian = 0; - else - as->big_endian = 1; - - return as; -#endif -} diff --git a/src/pal/src/libunwind/src/aarch64/Gget_proc_info.c b/src/pal/src/libunwind/src/aarch64/Gget_proc_info.c deleted file mode 100644 index c363d2405..000000000 --- a/src/pal/src/libunwind/src/aarch64/Gget_proc_info.c +++ /dev/null @@ -1,39 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" - -int -unw_get_proc_info (unw_cursor_t *cursor, unw_proc_info_t *pi) -{ - struct cursor *c = (struct cursor *) cursor; - int ret; - - ret = dwarf_make_proc_info (&c->dwarf); - if (ret < 0) - return ret; - - *pi = c->dwarf.pi; - return 0; -} diff --git a/src/pal/src/libunwind/src/aarch64/Gget_save_loc.c b/src/pal/src/libunwind/src/aarch64/Gget_save_loc.c deleted file mode 100644 index 86bbbd03d..000000000 --- a/src/pal/src/libunwind/src/aarch64/Gget_save_loc.c +++ /dev/null @@ -1,100 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - Copyright (C) 2012 Tommi Rantala - Copyright (C) 2013 Linaro Limited - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" - -int -unw_get_save_loc (unw_cursor_t *cursor, int reg, unw_save_loc_t *sloc) -{ - struct cursor *c = (struct cursor *) cursor; - dwarf_loc_t loc; - - switch (reg) - { - case UNW_AARCH64_X0: - case UNW_AARCH64_X1: - case UNW_AARCH64_X2: - case UNW_AARCH64_X3: - case UNW_AARCH64_X4: - case UNW_AARCH64_X5: - case UNW_AARCH64_X6: - case UNW_AARCH64_X7: - case UNW_AARCH64_X8: - case UNW_AARCH64_X9: - case UNW_AARCH64_X10: - case UNW_AARCH64_X11: - case UNW_AARCH64_X12: - case UNW_AARCH64_X13: - case UNW_AARCH64_X14: - case UNW_AARCH64_X15: - case UNW_AARCH64_X16: - case UNW_AARCH64_X17: - case UNW_AARCH64_X18: - case UNW_AARCH64_X19: - case UNW_AARCH64_X20: - case UNW_AARCH64_X21: - case UNW_AARCH64_X22: - case UNW_AARCH64_X23: - case UNW_AARCH64_X24: - case UNW_AARCH64_X25: - case UNW_AARCH64_X26: - case UNW_AARCH64_X27: - case UNW_AARCH64_X28: - case UNW_AARCH64_X29: - case UNW_AARCH64_X30: - case UNW_AARCH64_SP: - case UNW_AARCH64_PC: - case UNW_AARCH64_PSTATE: - loc = c->dwarf.loc[reg]; - break; - - default: - loc = DWARF_NULL_LOC; /* default to "not saved" */ - break; - } - - memset (sloc, 0, sizeof (*sloc)); - - if (DWARF_IS_NULL_LOC (loc)) - { - sloc->type = UNW_SLT_NONE; - return 0; - } - -#if !defined(UNW_LOCAL_ONLY) - if (DWARF_IS_REG_LOC (loc)) - { - sloc->type = UNW_SLT_REG; - sloc->u.regnum = DWARF_GET_LOC (loc); - } - else -#endif - { - sloc->type = UNW_SLT_MEMORY; - sloc->u.addr = DWARF_GET_LOC (loc); - } - return 0; -} diff --git a/src/pal/src/libunwind/src/aarch64/Gglobal.c b/src/pal/src/libunwind/src/aarch64/Gglobal.c deleted file mode 100644 index 72e36b2d4..000000000 --- a/src/pal/src/libunwind/src/aarch64/Gglobal.c +++ /dev/null @@ -1,57 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - Copyright (C) 2012 Tommi Rantala - Copyright (C) 2013 Linaro Limited - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" -#include "dwarf_i.h" - -HIDDEN define_lock (aarch64_lock); -HIDDEN int tdep_init_done; - -HIDDEN void -tdep_init (void) -{ - intrmask_t saved_mask; - - sigfillset (&unwi_full_mask); - - lock_acquire (&aarch64_lock, saved_mask); - { - if (tdep_init_done) - /* another thread else beat us to it... */ - goto out; - - mi_init (); - - dwarf_init (); - -#ifndef UNW_REMOTE_ONLY - aarch64_local_addr_space_init (); -#endif - tdep_init_done = 1; /* signal that we're initialized... */ - } - out: - lock_release (&aarch64_lock, saved_mask); -} diff --git a/src/pal/src/libunwind/src/aarch64/Ginit.c b/src/pal/src/libunwind/src/aarch64/Ginit.c deleted file mode 100644 index 9c4eae829..000000000 --- a/src/pal/src/libunwind/src/aarch64/Ginit.c +++ /dev/null @@ -1,190 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - Copyright (C) 2012 Tommi Rantala - Copyright (C) 2013 Linaro Limited - -This file is part of libunwind. - -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. */ - -#include -#include - -#include "unwind_i.h" - -#ifdef UNW_REMOTE_ONLY - -/* unw_local_addr_space is a NULL pointer in this case. */ -unw_addr_space_t unw_local_addr_space; - -#else /* !UNW_REMOTE_ONLY */ - -static struct unw_addr_space local_addr_space; - -unw_addr_space_t unw_local_addr_space = &local_addr_space; - -static inline void * -uc_addr (ucontext_t *uc, int reg) -{ - if (reg >= UNW_AARCH64_X0 && reg < UNW_AARCH64_V0) - return &uc->uc_mcontext.regs[reg]; - else if (reg >= UNW_AARCH64_V0 && reg <= UNW_AARCH64_V31) - return &GET_FPCTX(uc)->vregs[reg - UNW_AARCH64_V0]; - else - return NULL; -} - -# ifdef UNW_LOCAL_ONLY - -HIDDEN void * -tdep_uc_addr (ucontext_t *uc, int reg) -{ - return uc_addr (uc, reg); -} - -# endif /* UNW_LOCAL_ONLY */ - -HIDDEN unw_dyn_info_list_t _U_dyn_info_list; - -/* XXX fix me: there is currently no way to locate the dyn-info list - by a remote unwinder. On ia64, this is done via a special - unwind-table entry. Perhaps something similar can be done with - DWARF2 unwind info. */ - -static void -put_unwind_info (unw_addr_space_t as, unw_proc_info_t *proc_info, void *arg) -{ - /* it's a no-op */ -} - -static int -get_dyn_info_list_addr (unw_addr_space_t as, unw_word_t *dyn_info_list_addr, - void *arg) -{ - *dyn_info_list_addr = (unw_word_t) &_U_dyn_info_list; - return 0; -} - -static int -access_mem (unw_addr_space_t as, unw_word_t addr, unw_word_t *val, int write, - void *arg) -{ - if (write) - { - Debug (16, "mem[%lx] <- %lx\n", addr, *val); - *(unw_word_t *) addr = *val; - } - else - { - *val = *(unw_word_t *) addr; - Debug (16, "mem[%lx] -> %lx\n", addr, *val); - } - return 0; -} - -static int -access_reg (unw_addr_space_t as, unw_regnum_t reg, unw_word_t *val, int write, - void *arg) -{ - unw_word_t *addr; - ucontext_t *uc = arg; - - if (unw_is_fpreg (reg)) - goto badreg; - - if (!(addr = uc_addr (uc, reg))) - goto badreg; - - if (write) - { - *(unw_word_t *) addr = *val; - Debug (12, "%s <- %lx\n", unw_regname (reg), *val); - } - else - { - *val = *(unw_word_t *) addr; - Debug (12, "%s -> %lx\n", unw_regname (reg), *val); - } - return 0; - - badreg: - Debug (1, "bad register number %u\n", reg); - return -UNW_EBADREG; -} - -static int -access_fpreg (unw_addr_space_t as, unw_regnum_t reg, unw_fpreg_t *val, - int write, void *arg) -{ - ucontext_t *uc = arg; - unw_fpreg_t *addr; - - if (!unw_is_fpreg (reg)) - goto badreg; - - if (!(addr = uc_addr (uc, reg))) - goto badreg; - - if (write) - { - Debug (12, "%s <- %08lx.%08lx.%08lx\n", unw_regname (reg), - ((long *)val)[0], ((long *)val)[1], ((long *)val)[2]); - *(unw_fpreg_t *) addr = *val; - } - else - { - *val = *(unw_fpreg_t *) addr; - Debug (12, "%s -> %08lx.%08lx.%08lx\n", unw_regname (reg), - ((long *)val)[0], ((long *)val)[1], ((long *)val)[2]); - } - return 0; - - badreg: - Debug (1, "bad register number %u\n", reg); - /* attempt to access a non-preserved register */ - return -UNW_EBADREG; -} - -static int -get_static_proc_name (unw_addr_space_t as, unw_word_t ip, - char *buf, size_t buf_len, unw_word_t *offp, - void *arg) -{ - return _Uelf64_get_proc_name (as, getpid (), ip, buf, buf_len, offp); -} - -HIDDEN void -aarch64_local_addr_space_init (void) -{ - memset (&local_addr_space, 0, sizeof (local_addr_space)); - local_addr_space.caching_policy = UNWI_DEFAULT_CACHING_POLICY; - local_addr_space.acc.find_proc_info = dwarf_find_proc_info; - local_addr_space.acc.put_unwind_info = put_unwind_info; - local_addr_space.acc.get_dyn_info_list_addr = get_dyn_info_list_addr; - local_addr_space.acc.access_mem = access_mem; - local_addr_space.acc.access_reg = access_reg; - local_addr_space.acc.access_fpreg = access_fpreg; - local_addr_space.acc.resume = aarch64_local_resume; - local_addr_space.acc.get_proc_name = get_static_proc_name; - local_addr_space.big_endian = (__BYTE_ORDER == __BIG_ENDIAN); - unw_flush_cache (&local_addr_space, 0, 0); -} - -#endif /* !UNW_REMOTE_ONLY */ diff --git a/src/pal/src/libunwind/src/aarch64/Ginit_local.c b/src/pal/src/libunwind/src/aarch64/Ginit_local.c deleted file mode 100644 index cd60ca840..000000000 --- a/src/pal/src/libunwind/src/aarch64/Ginit_local.c +++ /dev/null @@ -1,78 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - Copyright (C) 2011-2013 Linaro Limited - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" -#include "init.h" - -#ifdef UNW_REMOTE_ONLY - -int -unw_init_local (unw_cursor_t *cursor, unw_context_t *uc) -{ - return -UNW_EINVAL; -} - -#else /* !UNW_REMOTE_ONLY */ - -static int -unw_init_local_common (unw_cursor_t *cursor, unw_context_t *uc, unsigned use_prev_instr) -{ - struct cursor *c = (struct cursor *) cursor; - - if (!tdep_init_done) - tdep_init (); - - Debug (1, "(cursor=%p)\n", c); - - c->dwarf.as = unw_local_addr_space; - c->dwarf.as_arg = uc; - - return common_init (c, use_prev_instr); -} - -int -unw_init_local (unw_cursor_t *cursor, unw_context_t *uc) -{ - return unw_init_local_common(cursor, uc, 1); -} - -int -unw_init_local2 (unw_cursor_t *cursor, ucontext_t *uc, int flag) -{ - if (!flag) - { - return unw_init_local_common(cursor, uc, 1); - } - else if (flag == UNW_INIT_SIGNAL_FRAME) - { - return unw_init_local_common(cursor, uc, 0); - } - else - { - return -UNW_EINVAL; - } -} - -#endif /* !UNW_REMOTE_ONLY */ diff --git a/src/pal/src/libunwind/src/aarch64/Ginit_remote.c b/src/pal/src/libunwind/src/aarch64/Ginit_remote.c deleted file mode 100644 index 9b8ba5b89..000000000 --- a/src/pal/src/libunwind/src/aarch64/Ginit_remote.c +++ /dev/null @@ -1,45 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - -This file is part of libunwind. - -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. */ - -#include "init.h" -#include "unwind_i.h" - -int -unw_init_remote (unw_cursor_t *cursor, unw_addr_space_t as, void *as_arg) -{ -#ifdef UNW_LOCAL_ONLY - return -UNW_EINVAL; -#else /* !UNW_LOCAL_ONLY */ - struct cursor *c = (struct cursor *) cursor; - - if (!tdep_init_done) - tdep_init (); - - Debug (1, "(cursor=%p)\n", c); - - c->dwarf.as = as; - c->dwarf.as_arg = as_arg; - return common_init (c, 0); -#endif /* !UNW_LOCAL_ONLY */ -} diff --git a/src/pal/src/libunwind/src/aarch64/Gis_signal_frame.c b/src/pal/src/libunwind/src/aarch64/Gis_signal_frame.c deleted file mode 100644 index 67159d839..000000000 --- a/src/pal/src/libunwind/src/aarch64/Gis_signal_frame.c +++ /dev/null @@ -1,64 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2012 Tommi Rantala - Copyright (C) 2013 Linaro Limited - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" - -/* The restorer stub will always have the form: - - d2801168 movz x8, #0x8b - d4000001 svc #0x0 -*/ - -int -unw_is_signal_frame (unw_cursor_t *cursor) -{ -#ifdef __linux__ - struct cursor *c = (struct cursor *) cursor; - unw_word_t w0, ip; - unw_addr_space_t as; - unw_accessors_t *a; - void *arg; - int ret; - - as = c->dwarf.as; - a = unw_get_accessors_int (as); - arg = c->dwarf.as_arg; - - ip = c->dwarf.ip; - - ret = (*a->access_mem) (as, ip, &w0, 0, arg); - if (ret < 0) - return ret; - - /* FIXME: distinguish 32bit insn vs 64bit registers. */ - if (w0 != 0xd4000001d2801168) - return 0; - - return 1; - -#else - return -UNW_ENOINFO; -#endif -} diff --git a/src/pal/src/libunwind/src/aarch64/Greg_states_iterate.c b/src/pal/src/libunwind/src/aarch64/Greg_states_iterate.c deleted file mode 100644 index a17dc1b56..000000000 --- a/src/pal/src/libunwind/src/aarch64/Greg_states_iterate.c +++ /dev/null @@ -1,37 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (c) 2002-2003 Hewlett-Packard Development Company, L.P. - Contributed by David Mosberger-Tang - - Modified for x86_64 by Max Asbock - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" - -int -unw_reg_states_iterate (unw_cursor_t *cursor, - unw_reg_states_callback cb, void *token) -{ - struct cursor *c = (struct cursor *) cursor; - - return dwarf_reg_states_iterate (&c->dwarf, cb, token); -} diff --git a/src/pal/src/libunwind/src/aarch64/Gregs.c b/src/pal/src/libunwind/src/aarch64/Gregs.c deleted file mode 100644 index a88437344..000000000 --- a/src/pal/src/libunwind/src/aarch64/Gregs.c +++ /dev/null @@ -1,118 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - Copyright (C) 2012 Tommi Rantala - Copyright (C) 2013 Linaro Limited - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" - -HIDDEN int -tdep_access_reg (struct cursor *c, unw_regnum_t reg, unw_word_t *valp, - int write) -{ - dwarf_loc_t loc = DWARF_NULL_LOC; - unsigned int mask; - - switch (reg) - { - case UNW_AARCH64_X0: - case UNW_AARCH64_X1: - case UNW_AARCH64_X2: - case UNW_AARCH64_X3: - mask = 1 << reg; - if (write) - { - c->dwarf.eh_args[reg] = *valp; - c->dwarf.eh_valid_mask |= mask; - return 0; - } - else if ((c->dwarf.eh_valid_mask & mask) != 0) - { - *valp = c->dwarf.eh_args[reg]; - return 0; - } - else - loc = c->dwarf.loc[reg]; - break; - - case UNW_AARCH64_X30: - if (write) - c->dwarf.ip = *valp; /* update the IP cache */ - case UNW_AARCH64_X4: - case UNW_AARCH64_X5: - case UNW_AARCH64_X6: - case UNW_AARCH64_X7: - case UNW_AARCH64_X8: - case UNW_AARCH64_X9: - case UNW_AARCH64_X10: - case UNW_AARCH64_X11: - case UNW_AARCH64_X12: - case UNW_AARCH64_X13: - case UNW_AARCH64_X14: - case UNW_AARCH64_X15: - case UNW_AARCH64_X16: - case UNW_AARCH64_X17: - case UNW_AARCH64_X18: - case UNW_AARCH64_X19: - case UNW_AARCH64_X20: - case UNW_AARCH64_X21: - case UNW_AARCH64_X22: - case UNW_AARCH64_X23: - case UNW_AARCH64_X24: - case UNW_AARCH64_X25: - case UNW_AARCH64_X26: - case UNW_AARCH64_X27: - case UNW_AARCH64_X28: - case UNW_AARCH64_X29: - case UNW_AARCH64_PC: - case UNW_AARCH64_PSTATE: - loc = c->dwarf.loc[reg]; - break; - - case UNW_AARCH64_SP: - if (write) - return -UNW_EREADONLYREG; - *valp = c->dwarf.cfa; - return 0; - - default: - Debug (1, "bad register number %u\n", reg); - return -UNW_EBADREG; - } - - if (write) - return dwarf_put (&c->dwarf, loc, *valp); - else - return dwarf_get (&c->dwarf, loc, valp); -} - -HIDDEN int -tdep_access_fpreg (struct cursor *c, unw_regnum_t reg, unw_fpreg_t *valp, - int write) -{ - dwarf_loc_t loc = c->dwarf.loc[reg]; - if (write) - return dwarf_putfp (&c->dwarf, loc, *valp); - else - return dwarf_getfp (&c->dwarf, loc, valp); -} diff --git a/src/pal/src/libunwind/src/aarch64/Gresume.c b/src/pal/src/libunwind/src/aarch64/Gresume.c deleted file mode 100644 index 3d8273929..000000000 --- a/src/pal/src/libunwind/src/aarch64/Gresume.c +++ /dev/null @@ -1,198 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - Copyright (C) 2011-2013 Linaro Limited - Copyright (C) 2012 Tommi Rantala - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" -#include "offsets.h" - -#ifndef UNW_REMOTE_ONLY - -HIDDEN inline int -aarch64_local_resume (unw_addr_space_t as, unw_cursor_t *cursor, void *arg) -{ -#ifdef __linux__ - struct cursor *c = (struct cursor *) cursor; - unw_tdep_context_t *uc = c->dwarf.as_arg; - - if (c->sigcontext_format == AARCH64_SCF_NONE) - { - /* Since there are no signals involved here we restore EH and non scratch - registers only. */ - unsigned long regs[24]; - regs[0] = uc->uc_mcontext.regs[0]; - regs[1] = uc->uc_mcontext.regs[1]; - regs[2] = uc->uc_mcontext.regs[2]; - regs[3] = uc->uc_mcontext.regs[3]; - regs[4] = uc->uc_mcontext.regs[19]; - regs[5] = uc->uc_mcontext.regs[20]; - regs[6] = uc->uc_mcontext.regs[21]; - regs[7] = uc->uc_mcontext.regs[22]; - regs[8] = uc->uc_mcontext.regs[23]; - regs[9] = uc->uc_mcontext.regs[24]; - regs[10] = uc->uc_mcontext.regs[25]; - regs[11] = uc->uc_mcontext.regs[26]; - regs[12] = uc->uc_mcontext.regs[27]; - regs[13] = uc->uc_mcontext.regs[28]; - regs[14] = uc->uc_mcontext.regs[29]; /* FP */ - regs[15] = uc->uc_mcontext.regs[30]; /* LR */ - regs[16] = GET_FPCTX(uc)->vregs[8]; - regs[17] = GET_FPCTX(uc)->vregs[9]; - regs[18] = GET_FPCTX(uc)->vregs[10]; - regs[19] = GET_FPCTX(uc)->vregs[11]; - regs[20] = GET_FPCTX(uc)->vregs[12]; - regs[21] = GET_FPCTX(uc)->vregs[13]; - regs[22] = GET_FPCTX(uc)->vregs[14]; - regs[23] = GET_FPCTX(uc)->vregs[15]; - unsigned long sp = uc->uc_mcontext.sp; - - struct regs_overlay { - char x[sizeof(regs)]; - }; - - asm volatile ( - "mov x4, %0\n" - "mov x5, %1\n" - "ldp x0, x1, [x4]\n" - "ldp x2, x3, [x4,16]\n" - "ldp x19, x20, [x4,32]\n" - "ldp x21, x22, [x4,48]\n" - "ldp x23, x24, [x4,64]\n" - "ldp x25, x26, [x4,80]\n" - "ldp x27, x28, [x4,96]\n" - "ldp x29, x30, [x4,112]\n" - "ldp d8, d9, [x4,128]\n" - "ldp d10, d11, [x4,144]\n" - "ldp d12, d13, [x4,160]\n" - "ldp d14, d15, [x4,176]\n" - "mov sp, x5\n" - "ret \n" - : - : "r" (regs), - "r" (sp), - "m" (*(struct regs_overlay *)regs) - ); - } - else - { - struct sigcontext *sc = (struct sigcontext *) c->sigcontext_addr; - - if (c->dwarf.eh_valid_mask & 0x1) sc->regs[0] = c->dwarf.eh_args[0]; - if (c->dwarf.eh_valid_mask & 0x2) sc->regs[1] = c->dwarf.eh_args[1]; - if (c->dwarf.eh_valid_mask & 0x4) sc->regs[2] = c->dwarf.eh_args[2]; - if (c->dwarf.eh_valid_mask & 0x8) sc->regs[3] = c->dwarf.eh_args[3]; - - sc->regs[4] = uc->uc_mcontext.regs[4]; - sc->regs[5] = uc->uc_mcontext.regs[5]; - sc->regs[6] = uc->uc_mcontext.regs[6]; - sc->regs[7] = uc->uc_mcontext.regs[7]; - sc->regs[8] = uc->uc_mcontext.regs[8]; - sc->regs[9] = uc->uc_mcontext.regs[9]; - sc->regs[10] = uc->uc_mcontext.regs[10]; - sc->regs[11] = uc->uc_mcontext.regs[11]; - sc->regs[12] = uc->uc_mcontext.regs[12]; - sc->regs[13] = uc->uc_mcontext.regs[13]; - sc->regs[14] = uc->uc_mcontext.regs[14]; - sc->regs[15] = uc->uc_mcontext.regs[15]; - sc->regs[16] = uc->uc_mcontext.regs[16]; - sc->regs[17] = uc->uc_mcontext.regs[17]; - sc->regs[18] = uc->uc_mcontext.regs[18]; - sc->regs[19] = uc->uc_mcontext.regs[19]; - sc->regs[20] = uc->uc_mcontext.regs[20]; - sc->regs[21] = uc->uc_mcontext.regs[21]; - sc->regs[22] = uc->uc_mcontext.regs[22]; - sc->regs[23] = uc->uc_mcontext.regs[23]; - sc->regs[24] = uc->uc_mcontext.regs[24]; - sc->regs[25] = uc->uc_mcontext.regs[25]; - sc->regs[26] = uc->uc_mcontext.regs[26]; - sc->regs[27] = uc->uc_mcontext.regs[27]; - sc->regs[28] = uc->uc_mcontext.regs[28]; - sc->regs[29] = uc->uc_mcontext.regs[29]; - sc->regs[30] = uc->uc_mcontext.regs[30]; - sc->sp = uc->uc_mcontext.sp; - sc->pc = uc->uc_mcontext.pc; - sc->pstate = uc->uc_mcontext.pstate; - - asm volatile ( - "mov sp, %0\n" - "ret %1\n" - : : "r" (c->sigcontext_sp), "r" (c->sigcontext_pc) - ); - } - unreachable(); -#else - printf ("%s: implement me\n", __FUNCTION__); -#endif - return -UNW_EINVAL; -} - -#endif /* !UNW_REMOTE_ONLY */ - -static inline void -establish_machine_state (struct cursor *c) -{ - unw_addr_space_t as = c->dwarf.as; - void *arg = c->dwarf.as_arg; - unw_fpreg_t fpval; - unw_word_t val; - int reg; - - Debug (8, "copying out cursor state\n"); - - for (reg = 0; reg <= UNW_AARCH64_V31; ++reg) - { - Debug (16, "copying %s %d\n", unw_regname (reg), reg); - if (unw_is_fpreg (reg)) - { - if (tdep_access_fpreg (c, reg, &fpval, 0) >= 0) - as->acc.access_fpreg (as, reg, &fpval, 1, arg); - } - else - { - if (tdep_access_reg (c, reg, &val, 0) >= 0) - as->acc.access_reg (as, reg, &val, 1, arg); - } - } -} - -int -unw_resume (unw_cursor_t *cursor) -{ - struct cursor *c = (struct cursor *) cursor; - - Debug (1, "(cursor=%p)\n", c); - - if (!c->dwarf.ip) - { - /* This can happen easily when the frame-chain gets truncated - due to bad or missing unwind-info. */ - Debug (1, "refusing to resume execution at address 0\n"); - return -UNW_EINVAL; - } - - establish_machine_state (c); - - return (*c->dwarf.as->acc.resume) (c->dwarf.as, (unw_cursor_t *) c, - c->dwarf.as_arg); -} diff --git a/src/pal/src/libunwind/src/aarch64/Gstash_frame.c b/src/pal/src/libunwind/src/aarch64/Gstash_frame.c deleted file mode 100644 index 6689af1a6..000000000 --- a/src/pal/src/libunwind/src/aarch64/Gstash_frame.c +++ /dev/null @@ -1,89 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2010, 2011 by FERMI NATIONAL ACCELERATOR LABORATORY - Copyright (C) 2014 CERN and Aalto University - Contributed by Filip Nyback - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" - -HIDDEN void -tdep_stash_frame (struct dwarf_cursor *d, struct dwarf_reg_state *rs) -{ - struct cursor *c = (struct cursor *) dwarf_to_cursor (d); - unw_tdep_frame_t *f = &c->frame_info; - - Debug (4, "ip=0x%lx cfa=0x%lx type %d cfa [where=%d val=%ld] cfaoff=%ld" - " ra=0x%lx fp [where=%d val=%ld @0x%lx] lr [where=%d val=%ld @0x%lx] " - "sp [where=%d val=%ld @0x%lx]\n", - d->ip, d->cfa, f->frame_type, - rs->reg.where[DWARF_CFA_REG_COLUMN], - rs->reg.val[DWARF_CFA_REG_COLUMN], - rs->reg.val[DWARF_CFA_OFF_COLUMN], - DWARF_GET_LOC(d->loc[rs->ret_addr_column]), - rs->reg.where[FP], rs->reg.val[FP], DWARF_GET_LOC(d->loc[FP]), - rs->reg.where[LR], rs->reg.val[LR], DWARF_GET_LOC(d->loc[LR]), - rs->reg.where[SP], rs->reg.val[SP], DWARF_GET_LOC(d->loc[SP])); - - /* A standard frame is defined as: - - CFA is register-relative offset off FP or SP; - - Return address is saved in LR; - - FP is unsaved or saved at CFA+offset, offset != -1; - - LR is unsaved or saved at CFA+offset, offset != -1; - - SP is unsaved or saved at CFA+offset, offset != -1. */ - if (f->frame_type == UNW_AARCH64_FRAME_OTHER - && (rs->reg.where[DWARF_CFA_REG_COLUMN] == DWARF_WHERE_REG) - && (rs->reg.val[DWARF_CFA_REG_COLUMN] == FP - || rs->reg.val[DWARF_CFA_REG_COLUMN] == SP) - && labs(rs->reg.val[DWARF_CFA_OFF_COLUMN]) < (1 << 29) - && rs->ret_addr_column == LR - && (rs->reg.where[FP] == DWARF_WHERE_UNDEF - || rs->reg.where[FP] == DWARF_WHERE_SAME - || (rs->reg.where[FP] == DWARF_WHERE_CFAREL - && labs(rs->reg.val[FP]) < (1 << 29) - && rs->reg.val[FP]+1 != 0)) - && (rs->reg.where[LR] == DWARF_WHERE_UNDEF - || rs->reg.where[LR] == DWARF_WHERE_SAME - || (rs->reg.where[LR] == DWARF_WHERE_CFAREL - && labs(rs->reg.val[LR]) < (1 << 29) - && rs->reg.val[LR]+1 != 0)) - && (rs->reg.where[SP] == DWARF_WHERE_UNDEF - || rs->reg.where[SP] == DWARF_WHERE_SAME - || (rs->reg.where[SP] == DWARF_WHERE_CFAREL - && labs(rs->reg.val[SP]) < (1 << 29) - && rs->reg.val[SP]+1 != 0))) - { - /* Save information for a standard frame. */ - f->frame_type = UNW_AARCH64_FRAME_STANDARD; - f->cfa_reg_sp = (rs->reg.val[DWARF_CFA_REG_COLUMN] == SP); - f->cfa_reg_offset = rs->reg.val[DWARF_CFA_OFF_COLUMN]; - if (rs->reg.where[FP] == DWARF_WHERE_CFAREL) - f->fp_cfa_offset = rs->reg.val[FP]; - if (rs->reg.where[LR] == DWARF_WHERE_CFAREL) - f->lr_cfa_offset = rs->reg.val[LR]; - if (rs->reg.where[SP] == DWARF_WHERE_CFAREL) - f->sp_cfa_offset = rs->reg.val[SP]; - Debug (4, " standard frame\n"); - } - else - Debug (4, " unusual frame\n"); -} diff --git a/src/pal/src/libunwind/src/aarch64/Gstep.c b/src/pal/src/libunwind/src/aarch64/Gstep.c deleted file mode 100644 index fdf64a73f..000000000 --- a/src/pal/src/libunwind/src/aarch64/Gstep.c +++ /dev/null @@ -1,189 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - Copyright (C) 2011-2013 Linaro Limited - Copyright (C) 2012 Tommi Rantala - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" -#include "offsets.h" - -/* Recognise PLT entries such as: - 40ddf0: b0000570 adrp x16, 4ba000 <_GLOBAL_OFFSET_TABLE_+0x2a8> - 40ddf4: f9433611 ldr x17, [x16,#1640] - 40ddf8: 9119a210 add x16, x16, #0x668 - 40ddfc: d61f0220 br x17 */ -static int -is_plt_entry (struct dwarf_cursor *c) -{ - unw_word_t w0, w1; - unw_accessors_t *a; - int ret; - - a = unw_get_accessors_int (c->as); - if ((ret = (*a->access_mem) (c->as, c->ip, &w0, 0, c->as_arg)) < 0 - || (ret = (*a->access_mem) (c->as, c->ip + 8, &w1, 0, c->as_arg)) < 0) - return 0; - - ret = (((w0 & 0xff0000009f000000) == 0xf900000090000000) - && ((w1 & 0xffffffffff000000) == 0xd61f022091000000)); - - Debug (14, "ip=0x%lx => 0x%016lx 0x%016lx, ret = %d\n", c->ip, w0, w1, ret); - return ret; -} - -static int -aarch64_handle_signal_frame (unw_cursor_t *cursor) -{ - struct cursor *c = (struct cursor *) cursor; - int ret; - unw_word_t sc_addr, sp, sp_addr = c->dwarf.cfa; - struct dwarf_loc sp_loc = DWARF_LOC (sp_addr, 0); - - if ((ret = dwarf_get (&c->dwarf, sp_loc, &sp)) < 0) - return -UNW_EUNSPEC; - - ret = unw_is_signal_frame (cursor); - Debug(1, "unw_is_signal_frame()=%d\n", ret); - - /* Save the SP and PC to be able to return execution at this point - later in time (unw_resume). */ - c->sigcontext_sp = c->dwarf.cfa; - c->sigcontext_pc = c->dwarf.ip; - - if (ret) - { - c->sigcontext_format = AARCH64_SCF_LINUX_RT_SIGFRAME; - sc_addr = sp_addr + sizeof (siginfo_t) + LINUX_UC_MCONTEXT_OFF; - } - else - return -UNW_EUNSPEC; - - c->sigcontext_addr = sc_addr; - c->frame_info.frame_type = UNW_AARCH64_FRAME_SIGRETURN; - c->frame_info.cfa_reg_offset = sc_addr - sp_addr; - - /* Update the dwarf cursor. - Set the location of the registers to the corresponding addresses of the - uc_mcontext / sigcontext structure contents. */ - c->dwarf.loc[UNW_AARCH64_X0] = DWARF_LOC (sc_addr + LINUX_SC_X0_OFF, 0); - c->dwarf.loc[UNW_AARCH64_X1] = DWARF_LOC (sc_addr + LINUX_SC_X1_OFF, 0); - c->dwarf.loc[UNW_AARCH64_X2] = DWARF_LOC (sc_addr + LINUX_SC_X2_OFF, 0); - c->dwarf.loc[UNW_AARCH64_X3] = DWARF_LOC (sc_addr + LINUX_SC_X3_OFF, 0); - c->dwarf.loc[UNW_AARCH64_X4] = DWARF_LOC (sc_addr + LINUX_SC_X4_OFF, 0); - c->dwarf.loc[UNW_AARCH64_X5] = DWARF_LOC (sc_addr + LINUX_SC_X5_OFF, 0); - c->dwarf.loc[UNW_AARCH64_X6] = DWARF_LOC (sc_addr + LINUX_SC_X6_OFF, 0); - c->dwarf.loc[UNW_AARCH64_X7] = DWARF_LOC (sc_addr + LINUX_SC_X7_OFF, 0); - c->dwarf.loc[UNW_AARCH64_X8] = DWARF_LOC (sc_addr + LINUX_SC_X8_OFF, 0); - c->dwarf.loc[UNW_AARCH64_X9] = DWARF_LOC (sc_addr + LINUX_SC_X9_OFF, 0); - c->dwarf.loc[UNW_AARCH64_X10] = DWARF_LOC (sc_addr + LINUX_SC_X10_OFF, 0); - c->dwarf.loc[UNW_AARCH64_X11] = DWARF_LOC (sc_addr + LINUX_SC_X11_OFF, 0); - c->dwarf.loc[UNW_AARCH64_X12] = DWARF_LOC (sc_addr + LINUX_SC_X12_OFF, 0); - c->dwarf.loc[UNW_AARCH64_X13] = DWARF_LOC (sc_addr + LINUX_SC_X13_OFF, 0); - c->dwarf.loc[UNW_AARCH64_X14] = DWARF_LOC (sc_addr + LINUX_SC_X14_OFF, 0); - c->dwarf.loc[UNW_AARCH64_X15] = DWARF_LOC (sc_addr + LINUX_SC_X15_OFF, 0); - c->dwarf.loc[UNW_AARCH64_X16] = DWARF_LOC (sc_addr + LINUX_SC_X16_OFF, 0); - c->dwarf.loc[UNW_AARCH64_X17] = DWARF_LOC (sc_addr + LINUX_SC_X17_OFF, 0); - c->dwarf.loc[UNW_AARCH64_X18] = DWARF_LOC (sc_addr + LINUX_SC_X18_OFF, 0); - c->dwarf.loc[UNW_AARCH64_X19] = DWARF_LOC (sc_addr + LINUX_SC_X19_OFF, 0); - c->dwarf.loc[UNW_AARCH64_X20] = DWARF_LOC (sc_addr + LINUX_SC_X20_OFF, 0); - c->dwarf.loc[UNW_AARCH64_X21] = DWARF_LOC (sc_addr + LINUX_SC_X21_OFF, 0); - c->dwarf.loc[UNW_AARCH64_X22] = DWARF_LOC (sc_addr + LINUX_SC_X22_OFF, 0); - c->dwarf.loc[UNW_AARCH64_X23] = DWARF_LOC (sc_addr + LINUX_SC_X23_OFF, 0); - c->dwarf.loc[UNW_AARCH64_X24] = DWARF_LOC (sc_addr + LINUX_SC_X24_OFF, 0); - c->dwarf.loc[UNW_AARCH64_X25] = DWARF_LOC (sc_addr + LINUX_SC_X25_OFF, 0); - c->dwarf.loc[UNW_AARCH64_X26] = DWARF_LOC (sc_addr + LINUX_SC_X26_OFF, 0); - c->dwarf.loc[UNW_AARCH64_X27] = DWARF_LOC (sc_addr + LINUX_SC_X27_OFF, 0); - c->dwarf.loc[UNW_AARCH64_X28] = DWARF_LOC (sc_addr + LINUX_SC_X28_OFF, 0); - c->dwarf.loc[UNW_AARCH64_X29] = DWARF_LOC (sc_addr + LINUX_SC_X29_OFF, 0); - c->dwarf.loc[UNW_AARCH64_X30] = DWARF_LOC (sc_addr + LINUX_SC_X30_OFF, 0); - c->dwarf.loc[UNW_AARCH64_SP] = DWARF_LOC (sc_addr + LINUX_SC_SP_OFF, 0); - c->dwarf.loc[UNW_AARCH64_PC] = DWARF_LOC (sc_addr + LINUX_SC_PC_OFF, 0); - c->dwarf.loc[UNW_AARCH64_PSTATE] = DWARF_LOC (sc_addr + LINUX_SC_PSTATE_OFF, 0); - - /* Set SP/CFA and PC/IP. */ - dwarf_get (&c->dwarf, c->dwarf.loc[UNW_AARCH64_SP], &c->dwarf.cfa); - dwarf_get (&c->dwarf, c->dwarf.loc[UNW_AARCH64_PC], &c->dwarf.ip); - - c->dwarf.pi_valid = 0; - c->dwarf.use_prev_instr = 0; - - return 1; -} - -int -unw_step (unw_cursor_t *cursor) -{ - struct cursor *c = (struct cursor *) cursor; - int ret; - - Debug (1, "(cursor=%p, ip=0x%016lx, cfa=0x%016lx))\n", - c, c->dwarf.ip, c->dwarf.cfa); - - /* Check if this is a signal frame. */ - if (unw_is_signal_frame (cursor) > 0) - return aarch64_handle_signal_frame (cursor); - - ret = dwarf_step (&c->dwarf); - Debug(1, "dwarf_step()=%d\n", ret); - - if (unlikely (ret == -UNW_ESTOPUNWIND)) - return ret; - - if (unlikely (ret < 0)) - { - /* DWARF failed. */ - if (is_plt_entry (&c->dwarf)) - { - Debug (2, "found plt entry\n"); - c->frame_info.frame_type = UNW_AARCH64_FRAME_STANDARD; - } - else - { - Debug (2, "fallback\n"); - c->frame_info.frame_type = UNW_AARCH64_FRAME_GUESSED; - } - /* Use link register (X30). */ - c->frame_info.cfa_reg_offset = 0; - c->frame_info.cfa_reg_sp = 0; - c->frame_info.fp_cfa_offset = -1; - c->frame_info.lr_cfa_offset = -1; - c->frame_info.sp_cfa_offset = -1; - c->dwarf.loc[UNW_AARCH64_PC] = c->dwarf.loc[UNW_AARCH64_X30]; - c->dwarf.loc[UNW_AARCH64_X30] = DWARF_NULL_LOC; - if (!DWARF_IS_NULL_LOC (c->dwarf.loc[UNW_AARCH64_PC])) - { - ret = dwarf_get (&c->dwarf, c->dwarf.loc[UNW_AARCH64_PC], &c->dwarf.ip); - if (ret < 0) - { - Debug (2, "failed to get pc from link register: %d\n", ret); - return ret; - } - Debug (2, "link register (x30) = 0x%016lx\n", c->dwarf.ip); - ret = 1; - } - else - c->dwarf.ip = 0; - } - - return (c->dwarf.ip == 0) ? 0 : 1; -} diff --git a/src/pal/src/libunwind/src/aarch64/Gtrace.c b/src/pal/src/libunwind/src/aarch64/Gtrace.c deleted file mode 100644 index c67faf0e3..000000000 --- a/src/pal/src/libunwind/src/aarch64/Gtrace.c +++ /dev/null @@ -1,548 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2010, 2011 by FERMI NATIONAL ACCELERATOR LABORATORY - Copyright (C) 2014 CERN and Aalto University - Contributed by Filip Nyback - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" -#include "offsets.h" -#include -#include - -#pragma weak pthread_once -#pragma weak pthread_key_create -#pragma weak pthread_getspecific -#pragma weak pthread_setspecific - -/* Initial hash table size. Table expands by 2 bits (times four). */ -#define HASH_MIN_BITS 14 - -typedef struct -{ - unw_tdep_frame_t *frames; - size_t log_size; - size_t used; - size_t dtor_count; /* Counts how many times our destructor has already - been called. */ -} unw_trace_cache_t; - -static const unw_tdep_frame_t empty_frame = { 0, UNW_AARCH64_FRAME_OTHER, -1, -1, 0, -1, -1, -1 }; -static define_lock (trace_init_lock); -static pthread_once_t trace_cache_once = PTHREAD_ONCE_INIT; -static sig_atomic_t trace_cache_once_happen; -static pthread_key_t trace_cache_key; -static struct mempool trace_cache_pool; -static __thread unw_trace_cache_t *tls_cache; -static __thread int tls_cache_destroyed; - -/* Free memory for a thread's trace cache. */ -static void -trace_cache_free (void *arg) -{ - unw_trace_cache_t *cache = arg; - if (++cache->dtor_count < PTHREAD_DESTRUCTOR_ITERATIONS) - { - /* Not yet our turn to get destroyed. Re-install ourselves into the key. */ - pthread_setspecific(trace_cache_key, cache); - Debug(5, "delayed freeing cache %p (%zx to go)\n", cache, - PTHREAD_DESTRUCTOR_ITERATIONS - cache->dtor_count); - return; - } - tls_cache_destroyed = 1; - tls_cache = NULL; - munmap (cache->frames, (1u << cache->log_size) * sizeof(unw_tdep_frame_t)); - mempool_free (&trace_cache_pool, cache); - Debug(5, "freed cache %p\n", cache); -} - -/* Initialise frame tracing for threaded use. */ -static void -trace_cache_init_once (void) -{ - pthread_key_create (&trace_cache_key, &trace_cache_free); - mempool_init (&trace_cache_pool, sizeof (unw_trace_cache_t), 0); - trace_cache_once_happen = 1; -} - -static unw_tdep_frame_t * -trace_cache_buckets (size_t n) -{ - unw_tdep_frame_t *frames; - size_t i; - - GET_MEMORY(frames, n * sizeof (unw_tdep_frame_t)); - if (likely(frames != NULL)) - for (i = 0; i < n; ++i) - frames[i] = empty_frame; - - return frames; -} - -/* Allocate and initialise hash table for frame cache lookups. - Returns the cache initialised with (1u << HASH_LOW_BITS) hash - buckets, or NULL if there was a memory allocation problem. */ -static unw_trace_cache_t * -trace_cache_create (void) -{ - unw_trace_cache_t *cache; - - if (tls_cache_destroyed) - { - /* The current thread is in the process of exiting. Don't recreate - cache, as we wouldn't have another chance to free it. */ - Debug(5, "refusing to reallocate cache: " - "thread-locals are being deallocated\n"); - return NULL; - } - - if (! (cache = mempool_alloc(&trace_cache_pool))) - { - Debug(5, "failed to allocate cache\n"); - return NULL; - } - - if (! (cache->frames = trace_cache_buckets(1u << HASH_MIN_BITS))) - { - Debug(5, "failed to allocate buckets\n"); - mempool_free(&trace_cache_pool, cache); - return NULL; - } - - cache->log_size = HASH_MIN_BITS; - cache->used = 0; - cache->dtor_count = 0; - tls_cache_destroyed = 0; /* Paranoia: should already be 0. */ - Debug(5, "allocated cache %p\n", cache); - return cache; -} - -/* Expand the hash table in the frame cache if possible. This always - quadruples the hash size, and clears all previous frame entries. */ -static int -trace_cache_expand (unw_trace_cache_t *cache) -{ - size_t old_size = (1u << cache->log_size); - size_t new_log_size = cache->log_size + 2; - unw_tdep_frame_t *new_frames = trace_cache_buckets (1u << new_log_size); - - if (unlikely(! new_frames)) - { - Debug(5, "failed to expand cache to 2^%lu buckets\n", new_log_size); - return -UNW_ENOMEM; - } - - Debug(5, "expanded cache from 2^%lu to 2^%lu buckets\n", cache->log_size, new_log_size); - munmap(cache->frames, old_size * sizeof(unw_tdep_frame_t)); - cache->frames = new_frames; - cache->log_size = new_log_size; - cache->used = 0; - return 0; -} - -static unw_trace_cache_t * -trace_cache_get_unthreaded (void) -{ - unw_trace_cache_t *cache; - intrmask_t saved_mask; - static unw_trace_cache_t *global_cache = NULL; - lock_acquire (&trace_init_lock, saved_mask); - if (! global_cache) - { - mempool_init (&trace_cache_pool, sizeof (unw_trace_cache_t), 0); - global_cache = trace_cache_create (); - } - cache = global_cache; - lock_release (&trace_init_lock, saved_mask); - Debug(5, "using cache %p\n", cache); - return cache; -} - -/* Get the frame cache for the current thread. Create it if there is none. */ -static unw_trace_cache_t * -trace_cache_get (void) -{ - unw_trace_cache_t *cache; - if (likely (pthread_once != NULL)) - { - pthread_once(&trace_cache_once, &trace_cache_init_once); - if (!trace_cache_once_happen) - { - return trace_cache_get_unthreaded(); - } - if (! (cache = tls_cache)) - { - cache = trace_cache_create(); - pthread_setspecific(trace_cache_key, cache); - tls_cache = cache; - } - Debug(5, "using cache %p\n", cache); - return cache; - } - else - { - return trace_cache_get_unthreaded(); - } -} - -/* Initialise frame properties for address cache slot F at address - PC using current CFA, FP and SP values. Modifies CURSOR to - that location, performs one unw_step(), and fills F with what - was discovered about the location. Returns F. - - FIXME: This probably should tell DWARF handling to never evaluate - or use registers other than FP, SP and PC in case there is - highly unusual unwind info which uses these creatively. */ -static unw_tdep_frame_t * -trace_init_addr (unw_tdep_frame_t *f, - unw_cursor_t *cursor, - unw_word_t cfa, - unw_word_t pc, - unw_word_t fp, - unw_word_t sp) -{ - struct cursor *c = (struct cursor *) cursor; - struct dwarf_cursor *d = &c->dwarf; - int ret = -UNW_EINVAL; - - /* Initialise frame properties: unknown, not last. */ - f->virtual_address = pc; - f->frame_type = UNW_AARCH64_FRAME_OTHER; - f->last_frame = 0; - f->cfa_reg_sp = -1; - f->cfa_reg_offset = 0; - f->fp_cfa_offset = -1; - f->lr_cfa_offset = -1; - f->sp_cfa_offset = -1; - - /* Reinitialise cursor to this instruction - but undo next/prev PC - adjustment because unw_step will redo it - and force PC, FP and - SP into register locations (=~ ucontext we keep), then set - their desired values. Then perform the step. */ - d->ip = pc + d->use_prev_instr; - d->cfa = cfa; - d->loc[UNW_AARCH64_X29] = DWARF_REG_LOC (d, UNW_AARCH64_X29); - d->loc[UNW_AARCH64_SP] = DWARF_REG_LOC (d, UNW_AARCH64_SP); - d->loc[UNW_AARCH64_PC] = DWARF_REG_LOC (d, UNW_AARCH64_PC); - c->frame_info = *f; - - if (likely(dwarf_put (d, d->loc[UNW_AARCH64_X29], fp) >= 0) - && likely(dwarf_put (d, d->loc[UNW_AARCH64_SP], sp) >= 0) - && likely(dwarf_put (d, d->loc[UNW_AARCH64_PC], pc) >= 0) - && likely((ret = unw_step (cursor)) >= 0)) - *f = c->frame_info; - - /* If unw_step() stopped voluntarily, remember that, even if it - otherwise could not determine anything useful. This avoids - failing trace if we hit frames without unwind info, which is - common for the outermost frame (CRT stuff) on many systems. - This avoids failing trace in very common circumstances; failing - to unw_step() loop wouldn't produce any better result. */ - if (ret == 0) - f->last_frame = -1; - - Debug (3, "frame va %lx type %d last %d cfa %s+%d fp @ cfa%+d lr @ cfa%+d sp @ cfa%+d\n", - f->virtual_address, f->frame_type, f->last_frame, - f->cfa_reg_sp ? "sp" : "fp", f->cfa_reg_offset, - f->fp_cfa_offset, f->lr_cfa_offset, f->sp_cfa_offset); - - return f; -} - -/* Look up and if necessary fill in frame attributes for address PC - in CACHE using current CFA, FP and SP values. Uses CURSOR to - perform any unwind steps necessary to fill the cache. Returns the - frame cache slot which describes RIP. */ -static unw_tdep_frame_t * -trace_lookup (unw_cursor_t *cursor, - unw_trace_cache_t *cache, - unw_word_t cfa, - unw_word_t pc, - unw_word_t fp, - unw_word_t sp) -{ - /* First look up for previously cached information using cache as - linear probing hash table with probe step of 1. Majority of - lookups should be completed within few steps, but it is very - important the hash table does not fill up, or performance falls - off the cliff. */ - uint64_t i, addr; - uint64_t cache_size = 1u << cache->log_size; - uint64_t slot = ((pc * 0x9e3779b97f4a7c16) >> 43) & (cache_size-1); - unw_tdep_frame_t *frame; - - for (i = 0; i < 16; ++i) - { - frame = &cache->frames[slot]; - addr = frame->virtual_address; - - /* Return if we found the address. */ - if (likely(addr == pc)) - { - Debug (4, "found address after %ld steps\n", i); - return frame; - } - - /* If slot is empty, reuse it. */ - if (likely(! addr)) - break; - - /* Linear probe to next slot candidate, step = 1. */ - if (++slot >= cache_size) - slot -= cache_size; - } - - /* If we collided after 16 steps, or if the hash is more than half - full, force the hash to expand. Fill the selected slot, whether - it's free or collides. Note that hash expansion drops previous - contents; further lookups will refill the hash. */ - Debug (4, "updating slot %lu after %ld steps, replacing 0x%lx\n", slot, i, addr); - if (unlikely(addr || cache->used >= cache_size / 2)) - { - if (unlikely(trace_cache_expand (cache) < 0)) - return NULL; - - cache_size = 1u << cache->log_size; - slot = ((pc * 0x9e3779b97f4a7c16) >> 43) & (cache_size-1); - frame = &cache->frames[slot]; - addr = frame->virtual_address; - } - - if (! addr) - ++cache->used; - - return trace_init_addr (frame, cursor, cfa, pc, fp, sp); -} - -/* Fast stack backtrace for AArch64. - - This is used by backtrace() implementation to accelerate frequent - queries for current stack, without any desire to unwind. It fills - BUFFER with the call tree from CURSOR upwards for at most SIZE - stack levels. The first frame, backtrace itself, is omitted. When - called, SIZE should give the maximum number of entries that can be - stored into BUFFER. Uses an internal thread-specific cache to - accelerate queries. - - The caller should fall back to a unw_step() loop if this function - fails by returning -UNW_ESTOPUNWIND, meaning the routine hit a - stack frame that is too complex to be traced in the fast path. - - This function is tuned for clients which only need to walk the - stack to get the call tree as fast as possible but without any - other details, for example profilers sampling the stack thousands - to millions of times per second. The routine handles the most - common AArch64 ABI stack layouts: CFA is FP or SP plus/minus - constant offset, return address is in LR, and FP, LR and SP are - either unchanged or saved on stack at constant offset from the CFA; - the signal return frame; and frames without unwind info provided - they are at the outermost (final) frame or can conservatively be - assumed to be frame-pointer based. - - Any other stack layout will cause the routine to give up. There - are only a handful of relatively rarely used functions which do - not have a stack in the standard form: vfork, longjmp, setcontext - and _dl_runtime_profile on common linux systems for example. - - On success BUFFER and *SIZE reflect the trace progress up to *SIZE - stack levels or the outermost frame, which ever is less. It may - stop short of outermost frame if unw_step() loop would also do so, - e.g. if there is no more unwind information; this is not reported - as an error. - - The function returns a negative value for errors, -UNW_ESTOPUNWIND - if tracing stopped because of an unusual frame unwind info. The - BUFFER and *SIZE reflect tracing progress up to the error frame. - - Callers of this function would normally look like this: - - unw_cursor_t cur; - unw_context_t ctx; - void addrs[128]; - int depth = 128; - int ret; - - unw_getcontext(&ctx); - unw_init_local(&cur, &ctx); - if ((ret = unw_tdep_trace(&cur, addrs, &depth)) < 0) - { - depth = 0; - unw_getcontext(&ctx); - unw_init_local(&cur, &ctx); - while ((ret = unw_step(&cur)) > 0 && depth < 128) - { - unw_word_t ip; - unw_get_reg(&cur, UNW_REG_IP, &ip); - addresses[depth++] = (void *) ip; - } - } -*/ -HIDDEN int -tdep_trace (unw_cursor_t *cursor, void **buffer, int *size) -{ - struct cursor *c = (struct cursor *) cursor; - struct dwarf_cursor *d = &c->dwarf; - unw_trace_cache_t *cache; - unw_word_t fp, sp, pc, cfa, lr; - int maxdepth = 0; - int depth = 0; - int ret; - - /* Check input parametres. */ - if (unlikely(! cursor || ! buffer || ! size || (maxdepth = *size) <= 0)) - return -UNW_EINVAL; - - Debug (1, "begin ip 0x%lx cfa 0x%lx\n", d->ip, d->cfa); - - /* Tell core dwarf routines to call back to us. */ - d->stash_frames = 1; - - /* Determine initial register values. These are direct access safe - because we know they come from the initial machine context. */ - pc = d->ip; - sp = cfa = d->cfa; - ACCESS_MEM_FAST(ret, 0, d, DWARF_GET_LOC(d->loc[UNW_AARCH64_X29]), fp); - assert(ret == 0); - lr = 0; - - /* Get frame cache. */ - if (unlikely(! (cache = trace_cache_get()))) - { - Debug (1, "returning %d, cannot get trace cache\n", -UNW_ENOMEM); - *size = 0; - d->stash_frames = 0; - return -UNW_ENOMEM; - } - - /* Trace the stack upwards, starting from current RIP. Adjust - the RIP address for previous/next instruction as the main - unwinding logic would also do. We undo this before calling - back into unw_step(). */ - while (depth < maxdepth) - { - pc -= d->use_prev_instr; - Debug (2, "depth %d cfa 0x%lx pc 0x%lx sp 0x%lx fp 0x%lx\n", - depth, cfa, pc, sp, fp); - - /* See if we have this address cached. If not, evaluate enough of - the dwarf unwind information to fill the cache line data, or to - decide this frame cannot be handled in fast trace mode. We - cache negative results too to prevent unnecessary dwarf parsing - for common failures. */ - unw_tdep_frame_t *f = trace_lookup (cursor, cache, cfa, pc, fp, sp); - - /* If we don't have information for this frame, give up. */ - if (unlikely(! f)) - { - ret = -UNW_ENOINFO; - break; - } - - Debug (3, "frame va %lx type %d last %d cfa %s+%d fp @ cfa%+d lr @ cfa%+d sp @ cfa%+d\n", - f->virtual_address, f->frame_type, f->last_frame, - f->cfa_reg_sp ? "sp" : "fp", f->cfa_reg_offset, - f->fp_cfa_offset, f->lr_cfa_offset, f->sp_cfa_offset); - - assert (f->virtual_address == pc); - - /* Stop if this was the last frame. In particular don't evaluate - new register values as it may not be safe - we don't normally - run with full validation on, and do not want to - and there's - enough bad unwind info floating around that we need to trust - what unw_step() previously said, in potentially bogus frames. */ - if (f->last_frame) - break; - - /* Evaluate CFA and registers for the next frame. */ - switch (f->frame_type) - { - case UNW_AARCH64_FRAME_GUESSED: - /* Fall thru to standard processing after forcing validation. */ - c->validate = 1; - - case UNW_AARCH64_FRAME_STANDARD: - /* Advance standard traceable frame. */ - cfa = (f->cfa_reg_sp ? sp : fp) + f->cfa_reg_offset; - if (likely(f->lr_cfa_offset != -1)) - ACCESS_MEM_FAST(ret, c->validate, d, cfa + f->lr_cfa_offset, pc); - else if (lr != 0) - { - /* Use the saved link register as the new pc. */ - pc = lr; - lr = 0; - } - if (likely(ret >= 0) && likely(f->fp_cfa_offset != -1)) - ACCESS_MEM_FAST(ret, c->validate, d, cfa + f->fp_cfa_offset, fp); - - /* Don't bother reading SP from DWARF, CFA becomes new SP. */ - sp = cfa; - - /* Next frame needs to back up for unwind info lookup. */ - d->use_prev_instr = 1; - break; - - case UNW_AARCH64_FRAME_SIGRETURN: - cfa = cfa + f->cfa_reg_offset; /* cfa now points to ucontext_t. */ - - ACCESS_MEM_FAST(ret, c->validate, d, cfa + LINUX_SC_PC_OFF, pc); - if (likely(ret >= 0)) - ACCESS_MEM_FAST(ret, c->validate, d, cfa + LINUX_SC_X29_OFF, fp); - if (likely(ret >= 0)) - ACCESS_MEM_FAST(ret, c->validate, d, cfa + LINUX_SC_SP_OFF, sp); - /* Save the link register here in case we end up in a function that - doesn't save the link register in the prologue, e.g. kill. */ - if (likely(ret >= 0)) - ACCESS_MEM_FAST(ret, c->validate, d, cfa + LINUX_SC_X30_OFF, lr); - - /* Resume stack at signal restoration point. The stack is not - necessarily continuous here, especially with sigaltstack(). */ - cfa = sp; - - /* Next frame should not back up. */ - d->use_prev_instr = 0; - break; - - default: - /* We cannot trace through this frame, give up and tell the - caller we had to stop. Data collected so far may still be - useful to the caller, so let it know how far we got. */ - ret = -UNW_ESTOPUNWIND; - break; - } - - Debug (4, "new cfa 0x%lx pc 0x%lx sp 0x%lx fp 0x%lx\n", - cfa, pc, sp, fp); - - /* If we failed or ended up somewhere bogus, stop. */ - if (unlikely(ret < 0 || pc < 0x4000)) - break; - - /* Record this address in stack trace. We skipped the first address. */ - buffer[depth++] = (void *) (pc - d->use_prev_instr); - } - -#if UNW_DEBUG - Debug (1, "returning %d, depth %d\n", ret, depth); -#endif - *size = depth; - return ret; -} diff --git a/src/pal/src/libunwind/src/aarch64/Lapply_reg_state.c b/src/pal/src/libunwind/src/aarch64/Lapply_reg_state.c deleted file mode 100644 index 7ebada480..000000000 --- a/src/pal/src/libunwind/src/aarch64/Lapply_reg_state.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gapply_reg_state.c" -#endif diff --git a/src/pal/src/libunwind/src/aarch64/Lcreate_addr_space.c b/src/pal/src/libunwind/src/aarch64/Lcreate_addr_space.c deleted file mode 100644 index 0f2dc6be9..000000000 --- a/src/pal/src/libunwind/src/aarch64/Lcreate_addr_space.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gcreate_addr_space.c" -#endif diff --git a/src/pal/src/libunwind/src/aarch64/Lget_proc_info.c b/src/pal/src/libunwind/src/aarch64/Lget_proc_info.c deleted file mode 100644 index 69028b019..000000000 --- a/src/pal/src/libunwind/src/aarch64/Lget_proc_info.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gget_proc_info.c" -#endif diff --git a/src/pal/src/libunwind/src/aarch64/Lget_save_loc.c b/src/pal/src/libunwind/src/aarch64/Lget_save_loc.c deleted file mode 100644 index 9ea048a90..000000000 --- a/src/pal/src/libunwind/src/aarch64/Lget_save_loc.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gget_save_loc.c" -#endif diff --git a/src/pal/src/libunwind/src/aarch64/Lglobal.c b/src/pal/src/libunwind/src/aarch64/Lglobal.c deleted file mode 100644 index 6d7b489e1..000000000 --- a/src/pal/src/libunwind/src/aarch64/Lglobal.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gglobal.c" -#endif diff --git a/src/pal/src/libunwind/src/aarch64/Linit.c b/src/pal/src/libunwind/src/aarch64/Linit.c deleted file mode 100644 index e9abfdd46..000000000 --- a/src/pal/src/libunwind/src/aarch64/Linit.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Ginit.c" -#endif diff --git a/src/pal/src/libunwind/src/aarch64/Linit_local.c b/src/pal/src/libunwind/src/aarch64/Linit_local.c deleted file mode 100644 index 68a1687e8..000000000 --- a/src/pal/src/libunwind/src/aarch64/Linit_local.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Ginit_local.c" -#endif diff --git a/src/pal/src/libunwind/src/aarch64/Linit_remote.c b/src/pal/src/libunwind/src/aarch64/Linit_remote.c deleted file mode 100644 index 58cb04ab7..000000000 --- a/src/pal/src/libunwind/src/aarch64/Linit_remote.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Ginit_remote.c" -#endif diff --git a/src/pal/src/libunwind/src/aarch64/Lis_signal_frame.c b/src/pal/src/libunwind/src/aarch64/Lis_signal_frame.c deleted file mode 100644 index b9a7c4f51..000000000 --- a/src/pal/src/libunwind/src/aarch64/Lis_signal_frame.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gis_signal_frame.c" -#endif diff --git a/src/pal/src/libunwind/src/aarch64/Lreg_states_iterate.c b/src/pal/src/libunwind/src/aarch64/Lreg_states_iterate.c deleted file mode 100644 index f1eb1e79d..000000000 --- a/src/pal/src/libunwind/src/aarch64/Lreg_states_iterate.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Greg_states_iterate.c" -#endif diff --git a/src/pal/src/libunwind/src/aarch64/Lregs.c b/src/pal/src/libunwind/src/aarch64/Lregs.c deleted file mode 100644 index 2c9c75cd7..000000000 --- a/src/pal/src/libunwind/src/aarch64/Lregs.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gregs.c" -#endif diff --git a/src/pal/src/libunwind/src/aarch64/Lresume.c b/src/pal/src/libunwind/src/aarch64/Lresume.c deleted file mode 100644 index 41a8cf003..000000000 --- a/src/pal/src/libunwind/src/aarch64/Lresume.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gresume.c" -#endif diff --git a/src/pal/src/libunwind/src/aarch64/Lstash_frame.c b/src/pal/src/libunwind/src/aarch64/Lstash_frame.c deleted file mode 100644 index 77587803d..000000000 --- a/src/pal/src/libunwind/src/aarch64/Lstash_frame.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gstash_frame.c" -#endif diff --git a/src/pal/src/libunwind/src/aarch64/Lstep.c b/src/pal/src/libunwind/src/aarch64/Lstep.c deleted file mode 100644 index c1ac3c754..000000000 --- a/src/pal/src/libunwind/src/aarch64/Lstep.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gstep.c" -#endif diff --git a/src/pal/src/libunwind/src/aarch64/Ltrace.c b/src/pal/src/libunwind/src/aarch64/Ltrace.c deleted file mode 100644 index fcd3f239c..000000000 --- a/src/pal/src/libunwind/src/aarch64/Ltrace.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gtrace.c" -#endif diff --git a/src/pal/src/libunwind/src/aarch64/gen-offsets.c b/src/pal/src/libunwind/src/aarch64/gen-offsets.c deleted file mode 100644 index eadc2377d..000000000 --- a/src/pal/src/libunwind/src/aarch64/gen-offsets.c +++ /dev/null @@ -1,68 +0,0 @@ -#include -#include -#include -#include - -#define UC(N,X) \ - printf ("#define LINUX_UC_" N "_OFF\t0x%X\n", offsetof (ucontext_t, X)) - -#define SC(N,X) \ - printf ("#define LINUX_SC_" N "_OFF\t0x%X\n", offsetof (struct sigcontext, X)) - -int -main (void) -{ - printf ( -"/* Linux-specific definitions: */\n\n" - -"/* Define various structure offsets to simplify cross-compilation. */\n\n" - -"/* Offsets for AArch64 Linux \"ucontext_t\": */\n\n"); - - UC ("FLAGS", uc_flags); - UC ("LINK", uc_link); - UC ("STACK", uc_stack); - UC ("MCONTEXT", uc_mcontext); - UC ("SIGMASK", uc_sigmask); - - printf ("\n/* Offsets for AArch64 Linux \"struct sigcontext\": */\n\n"); - - SC ("R0", regs[0]); - SC ("R1", regs[1]); - SC ("R2", regs[2]); - SC ("R3", regs[3]); - SC ("R4", regs[4]); - SC ("R5", regs[5]); - SC ("R6", regs[6]); - SC ("R7", regs[7]); - SC ("R8", regs[8]); - SC ("R9", regs[9]); - SC ("R10", regs[10]); - SC ("R11", regs[11]); - SC ("R12", regs[12]); - SC ("R13", regs[13]); - SC ("R14", regs[14]); - SC ("R15", regs[15]); - SC ("R16", regs[16]); - SC ("R17", regs[17]); - SC ("R18", regs[18]); - SC ("R19", regs[19]); - SC ("R20", regs[20]); - SC ("R21", regs[21]); - SC ("R22", regs[22]); - SC ("R23", regs[23]); - SC ("R24", regs[24]); - SC ("R25", regs[25]); - SC ("R26", regs[26]); - SC ("R27", regs[27]); - SC ("R28", regs[28]); - SC ("R29", regs[29]); - SC ("R30", regs[30]); - SC ("R31", regs[31]); - - SC ("PC", pc); - SC ("SP", sp); - SC ("Fault", fault_address); - SC ("state", pstate); - return 0; -} diff --git a/src/pal/src/libunwind/src/aarch64/getcontext.S b/src/pal/src/libunwind/src/aarch64/getcontext.S deleted file mode 100644 index 25ed5b66b..000000000 --- a/src/pal/src/libunwind/src/aarch64/getcontext.S +++ /dev/null @@ -1,52 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 Google, Inc - Contributed by Paul Pluzhnikov - Copyright (C) 2010 Konstantin Belousov - -This file is part of libunwind. - -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. */ - -#include "offsets.h" - -/* int _Uaarch64_getcontext_trace (unw_tdep_context_t *ucp) - - Saves limited machine context in UCP necessary for fast trace. If fast trace - fails, caller will have to get the full context. -*/ - - .global _Uaarch64_getcontext_trace - .hidden _Uaarch64_getcontext_trace - .type _Uaarch64_getcontext_trace, @function -_Uaarch64_getcontext_trace: - .cfi_startproc - - /* Save only FP, SP, PC - exclude this call. */ - str x29, [x0, #(LINUX_UC_MCONTEXT_OFF + LINUX_SC_X29_OFF)] - mov x9, sp - str x9, [x0, #(LINUX_UC_MCONTEXT_OFF + LINUX_SC_SP_OFF)] - str x30, [x0, #(LINUX_UC_MCONTEXT_OFF + LINUX_SC_PC_OFF)] - - ret - .cfi_endproc - .size _Uaarch64_getcontext_trace, . - _Uaarch64_getcontext_trace - - /* We do not need executable stack. */ - .section .note.GNU-stack,"",@progbits diff --git a/src/pal/src/libunwind/src/aarch64/init.h b/src/pal/src/libunwind/src/aarch64/init.h deleted file mode 100644 index 5dab60bb6..000000000 --- a/src/pal/src/libunwind/src/aarch64/init.h +++ /dev/null @@ -1,126 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2012 Tommi Rantala - Copyright (C) 2013 Linaro Limited - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" - -static inline int -common_init (struct cursor *c, unsigned use_prev_instr) -{ - int ret, i; - - c->dwarf.loc[UNW_AARCH64_X0] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_X0); - c->dwarf.loc[UNW_AARCH64_X1] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_X1); - c->dwarf.loc[UNW_AARCH64_X2] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_X2); - c->dwarf.loc[UNW_AARCH64_X3] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_X3); - c->dwarf.loc[UNW_AARCH64_X4] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_X4); - c->dwarf.loc[UNW_AARCH64_X5] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_X5); - c->dwarf.loc[UNW_AARCH64_X6] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_X6); - c->dwarf.loc[UNW_AARCH64_X7] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_X7); - c->dwarf.loc[UNW_AARCH64_X8] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_X8); - c->dwarf.loc[UNW_AARCH64_X9] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_X9); - c->dwarf.loc[UNW_AARCH64_X10] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_X10); - c->dwarf.loc[UNW_AARCH64_X11] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_X11); - c->dwarf.loc[UNW_AARCH64_X12] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_X12); - c->dwarf.loc[UNW_AARCH64_X13] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_X13); - c->dwarf.loc[UNW_AARCH64_X14] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_X14); - c->dwarf.loc[UNW_AARCH64_X15] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_X15); - c->dwarf.loc[UNW_AARCH64_X16] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_X16); - c->dwarf.loc[UNW_AARCH64_X17] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_X17); - c->dwarf.loc[UNW_AARCH64_X18] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_X18); - c->dwarf.loc[UNW_AARCH64_X19] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_X19); - c->dwarf.loc[UNW_AARCH64_X20] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_X20); - c->dwarf.loc[UNW_AARCH64_X21] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_X21); - c->dwarf.loc[UNW_AARCH64_X22] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_X22); - c->dwarf.loc[UNW_AARCH64_X23] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_X23); - c->dwarf.loc[UNW_AARCH64_X24] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_X24); - c->dwarf.loc[UNW_AARCH64_X25] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_X25); - c->dwarf.loc[UNW_AARCH64_X26] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_X26); - c->dwarf.loc[UNW_AARCH64_X27] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_X27); - c->dwarf.loc[UNW_AARCH64_X28] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_X28); - c->dwarf.loc[UNW_AARCH64_X29] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_X29); - c->dwarf.loc[UNW_AARCH64_X30] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_X30); - c->dwarf.loc[UNW_AARCH64_SP] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_SP); - c->dwarf.loc[UNW_AARCH64_PC] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_PC); - c->dwarf.loc[UNW_AARCH64_PSTATE] = DWARF_REG_LOC (&c->dwarf, - UNW_AARCH64_PSTATE); - c->dwarf.loc[UNW_AARCH64_V0] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V0); - c->dwarf.loc[UNW_AARCH64_V1] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V1); - c->dwarf.loc[UNW_AARCH64_V2] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V2); - c->dwarf.loc[UNW_AARCH64_V3] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V3); - c->dwarf.loc[UNW_AARCH64_V4] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V4); - c->dwarf.loc[UNW_AARCH64_V5] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V5); - c->dwarf.loc[UNW_AARCH64_V6] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V6); - c->dwarf.loc[UNW_AARCH64_V7] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V7); - c->dwarf.loc[UNW_AARCH64_V8] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V8); - c->dwarf.loc[UNW_AARCH64_V9] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V9); - c->dwarf.loc[UNW_AARCH64_V10] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V10); - c->dwarf.loc[UNW_AARCH64_V11] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V11); - c->dwarf.loc[UNW_AARCH64_V12] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V12); - c->dwarf.loc[UNW_AARCH64_V13] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V13); - c->dwarf.loc[UNW_AARCH64_V14] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V14); - c->dwarf.loc[UNW_AARCH64_V15] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V15); - c->dwarf.loc[UNW_AARCH64_V16] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V16); - c->dwarf.loc[UNW_AARCH64_V17] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V17); - c->dwarf.loc[UNW_AARCH64_V18] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V18); - c->dwarf.loc[UNW_AARCH64_V19] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V19); - c->dwarf.loc[UNW_AARCH64_V20] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V20); - c->dwarf.loc[UNW_AARCH64_V21] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V21); - c->dwarf.loc[UNW_AARCH64_V22] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V22); - c->dwarf.loc[UNW_AARCH64_V23] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V23); - c->dwarf.loc[UNW_AARCH64_V24] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V24); - c->dwarf.loc[UNW_AARCH64_V25] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V25); - c->dwarf.loc[UNW_AARCH64_V26] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V26); - c->dwarf.loc[UNW_AARCH64_V27] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V27); - c->dwarf.loc[UNW_AARCH64_V28] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V28); - c->dwarf.loc[UNW_AARCH64_V29] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V29); - c->dwarf.loc[UNW_AARCH64_V30] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V30); - c->dwarf.loc[UNW_AARCH64_V31] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V31); - - for (i = UNW_AARCH64_PSTATE + 1; i < UNW_AARCH64_V0; ++i) - c->dwarf.loc[i] = DWARF_NULL_LOC; - - ret = dwarf_get (&c->dwarf, c->dwarf.loc[UNW_AARCH64_PC], &c->dwarf.ip); - if (ret < 0) - return ret; - - ret = dwarf_get (&c->dwarf, c->dwarf.loc[UNW_AARCH64_SP], &c->dwarf.cfa); - if (ret < 0) - return ret; - - c->sigcontext_format = AARCH64_SCF_NONE; - c->sigcontext_addr = 0; - c->sigcontext_sp = 0; - c->sigcontext_pc = 0; - - c->dwarf.args_size = 0; - c->dwarf.stash_frames = 0; - c->dwarf.use_prev_instr = use_prev_instr; - c->dwarf.pi_valid = 0; - c->dwarf.pi_is_dynamic = 0; - c->dwarf.hint = 0; - c->dwarf.prev_rs = 0; - - return 0; -} diff --git a/src/pal/src/libunwind/src/aarch64/is_fpreg.c b/src/pal/src/libunwind/src/aarch64/is_fpreg.c deleted file mode 100644 index 2981d2752..000000000 --- a/src/pal/src/libunwind/src/aarch64/is_fpreg.c +++ /dev/null @@ -1,32 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - Copyright (C) 2013 Linaro Limited - -This file is part of libunwind. - -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. */ - -#include "libunwind_i.h" - -int -unw_is_fpreg (int regnum) -{ - return (regnum >= UNW_AARCH64_V0 && regnum <= UNW_AARCH64_V31); -} diff --git a/src/pal/src/libunwind/src/aarch64/offsets.h b/src/pal/src/libunwind/src/aarch64/offsets.h deleted file mode 100644 index e78251d0a..000000000 --- a/src/pal/src/libunwind/src/aarch64/offsets.h +++ /dev/null @@ -1,49 +0,0 @@ -/* Linux-specific definitions: */ - -/* Define various structure offsets to simplify cross-compilation. */ - -/* Offsets for AArch64 Linux "ucontext_t": */ - -#define LINUX_UC_FLAGS_OFF 0x0 -#define LINUX_UC_LINK_OFF 0x8 -#define LINUX_UC_STACK_OFF 0x10 -#define LINUX_UC_SIGMASK_OFF 0x28 -#define LINUX_UC_MCONTEXT_OFF 0xb0 - -/* Offsets for AArch64 Linux "struct sigcontext": */ - -#define LINUX_SC_FAULTADDRESS_OFF 0x00 -#define LINUX_SC_X0_OFF 0x008 -#define LINUX_SC_X1_OFF 0x010 -#define LINUX_SC_X2_OFF 0x018 -#define LINUX_SC_X3_OFF 0x020 -#define LINUX_SC_X4_OFF 0x028 -#define LINUX_SC_X5_OFF 0x030 -#define LINUX_SC_X6_OFF 0x038 -#define LINUX_SC_X7_OFF 0x040 -#define LINUX_SC_X8_OFF 0x048 -#define LINUX_SC_X9_OFF 0x050 -#define LINUX_SC_X10_OFF 0x058 -#define LINUX_SC_X11_OFF 0x060 -#define LINUX_SC_X12_OFF 0x068 -#define LINUX_SC_X13_OFF 0x070 -#define LINUX_SC_X14_OFF 0x078 -#define LINUX_SC_X15_OFF 0x080 -#define LINUX_SC_X16_OFF 0x088 -#define LINUX_SC_X17_OFF 0x090 -#define LINUX_SC_X18_OFF 0x098 -#define LINUX_SC_X19_OFF 0x0a0 -#define LINUX_SC_X20_OFF 0x0a8 -#define LINUX_SC_X21_OFF 0x0b0 -#define LINUX_SC_X22_OFF 0x0b8 -#define LINUX_SC_X23_OFF 0x0c0 -#define LINUX_SC_X24_OFF 0x0c8 -#define LINUX_SC_X25_OFF 0x0d0 -#define LINUX_SC_X26_OFF 0x0d8 -#define LINUX_SC_X27_OFF 0x0e0 -#define LINUX_SC_X28_OFF 0x0e8 -#define LINUX_SC_X29_OFF 0x0f0 -#define LINUX_SC_X30_OFF 0x0f8 -#define LINUX_SC_SP_OFF 0x100 -#define LINUX_SC_PC_OFF 0x108 -#define LINUX_SC_PSTATE_OFF 0x110 diff --git a/src/pal/src/libunwind/src/aarch64/regname.c b/src/pal/src/libunwind/src/aarch64/regname.c deleted file mode 100644 index 0f7a8bdcf..000000000 --- a/src/pal/src/libunwind/src/aarch64/regname.c +++ /dev/null @@ -1,106 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2012 Tommi Rantala - Copyright (C) 2013 Linaro Limited - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" - -static const char *const regname[] = - { - [UNW_AARCH64_X0] = "x0", - [UNW_AARCH64_X1] = "x1", - [UNW_AARCH64_X2] = "x2", - [UNW_AARCH64_X3] = "x3", - [UNW_AARCH64_X4] = "x4", - [UNW_AARCH64_X5] = "x5", - [UNW_AARCH64_X6] = "x6", - [UNW_AARCH64_X7] = "x7", - [UNW_AARCH64_X8] = "x8", - [UNW_AARCH64_X9] = "x9", - [UNW_AARCH64_X10] = "x10", - [UNW_AARCH64_X11] = "x11", - [UNW_AARCH64_X12] = "x12", - [UNW_AARCH64_X13] = "x13", - [UNW_AARCH64_X14] = "x14", - [UNW_AARCH64_X15] = "x15", - [UNW_AARCH64_X16] = "ip0", - [UNW_AARCH64_X17] = "ip1", - [UNW_AARCH64_X18] = "x18", - [UNW_AARCH64_X19] = "x19", - [UNW_AARCH64_X20] = "x20", - [UNW_AARCH64_X21] = "x21", - [UNW_AARCH64_X22] = "x22", - [UNW_AARCH64_X23] = "x23", - [UNW_AARCH64_X24] = "x24", - [UNW_AARCH64_X25] = "x25", - [UNW_AARCH64_X26] = "x26", - [UNW_AARCH64_X27] = "x27", - [UNW_AARCH64_X28] = "x28", - [UNW_AARCH64_X29] = "fp", - [UNW_AARCH64_X30] = "lr", - [UNW_AARCH64_SP] = "sp", - [UNW_AARCH64_PC] = "pc", - [UNW_AARCH64_V0] = "v0", - [UNW_AARCH64_V1] = "v1", - [UNW_AARCH64_V2] = "v2", - [UNW_AARCH64_V3] = "v3", - [UNW_AARCH64_V4] = "v4", - [UNW_AARCH64_V5] = "v5", - [UNW_AARCH64_V6] = "v6", - [UNW_AARCH64_V7] = "v7", - [UNW_AARCH64_V8] = "v8", - [UNW_AARCH64_V9] = "v9", - [UNW_AARCH64_V10] = "v10", - [UNW_AARCH64_V11] = "v11", - [UNW_AARCH64_V12] = "v12", - [UNW_AARCH64_V13] = "v13", - [UNW_AARCH64_V14] = "v14", - [UNW_AARCH64_V15] = "v15", - [UNW_AARCH64_V16] = "v16", - [UNW_AARCH64_V17] = "v17", - [UNW_AARCH64_V18] = "v18", - [UNW_AARCH64_V19] = "v19", - [UNW_AARCH64_V20] = "v20", - [UNW_AARCH64_V21] = "v21", - [UNW_AARCH64_V22] = "v22", - [UNW_AARCH64_V23] = "v23", - [UNW_AARCH64_V24] = "v24", - [UNW_AARCH64_V25] = "v25", - [UNW_AARCH64_V26] = "v26", - [UNW_AARCH64_V27] = "v27", - [UNW_AARCH64_V28] = "v28", - [UNW_AARCH64_V29] = "v29", - [UNW_AARCH64_V30] = "v30", - [UNW_AARCH64_V31] = "v31", - [UNW_AARCH64_FPSR] = "fpsr", - [UNW_AARCH64_FPCR] = "fpcr", - }; - -const char * -unw_regname (unw_regnum_t reg) -{ - if (reg < (unw_regnum_t) ARRAY_SIZE (regname) && regname[reg] != NULL) - return regname[reg]; - else - return "???"; -} diff --git a/src/pal/src/libunwind/src/aarch64/siglongjmp.S b/src/pal/src/libunwind/src/aarch64/siglongjmp.S deleted file mode 100644 index 9985c4b4a..000000000 --- a/src/pal/src/libunwind/src/aarch64/siglongjmp.S +++ /dev/null @@ -1,12 +0,0 @@ - /* Dummy implementation for now. */ - - .global _UI_siglongjmp_cont - .global _UI_longjmp_cont - -_UI_siglongjmp_cont: -_UI_longjmp_cont: - ret -#ifdef __linux__ - /* We do not need executable stack. */ - .section .note.GNU-stack,"",%progbits -#endif diff --git a/src/pal/src/libunwind/src/aarch64/unwind_i.h b/src/pal/src/libunwind/src/aarch64/unwind_i.h deleted file mode 100644 index 3d324c2b0..000000000 --- a/src/pal/src/libunwind/src/aarch64/unwind_i.h +++ /dev/null @@ -1,64 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - Copyright (C) 2013 Linaro Limited - -This file is part of libunwind. - -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. */ - -#ifndef unwind_i_h -#define unwind_i_h - -#include - -#include - -#include "libunwind_i.h" - -/* DWARF column numbers for AArch64: */ -#define X29 29 -#define FP 29 -#define X30 30 -#define LR 30 -#define SP 31 - -#define aarch64_lock UNW_OBJ(lock) -#define aarch64_local_resume UNW_OBJ(local_resume) -#define aarch64_local_addr_space_init UNW_OBJ(local_addr_space_init) - -extern void aarch64_local_addr_space_init (void); -extern int aarch64_local_resume (unw_addr_space_t as, unw_cursor_t *cursor, - void *arg); - -/* By-pass calls to access_mem() when known to be safe. */ -#ifdef UNW_LOCAL_ONLY -# undef ACCESS_MEM_FAST -# define ACCESS_MEM_FAST(ret,validate,cur,addr,to) \ - do { \ - if (unlikely(validate)) \ - (ret) = dwarf_get ((cur), DWARF_MEM_LOC ((cur), (addr)), &(to)); \ - else \ - (ret) = 0, (to) = *(unw_word_t *)(addr); \ - } while (0) -#endif - -#define GET_FPCTX(uc) ((struct fpsimd_context *)(&uc->uc_mcontext.__reserved)) - -#endif /* unwind_i_h */ diff --git a/src/pal/src/libunwind/src/arm/Gapply_reg_state.c b/src/pal/src/libunwind/src/arm/Gapply_reg_state.c deleted file mode 100644 index 82f056da6..000000000 --- a/src/pal/src/libunwind/src/arm/Gapply_reg_state.c +++ /dev/null @@ -1,37 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (c) 2002-2003 Hewlett-Packard Development Company, L.P. - Contributed by David Mosberger-Tang - - Modified for x86_64 by Max Asbock - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" - -int -unw_apply_reg_state (unw_cursor_t *cursor, - void *reg_states_data) -{ - struct cursor *c = (struct cursor *) cursor; - - return dwarf_apply_reg_state (&c->dwarf, (dwarf_reg_state_t *)reg_states_data); -} diff --git a/src/pal/src/libunwind/src/arm/Gcreate_addr_space.c b/src/pal/src/libunwind/src/arm/Gcreate_addr_space.c deleted file mode 100644 index 7b2d6bacf..000000000 --- a/src/pal/src/libunwind/src/arm/Gcreate_addr_space.c +++ /dev/null @@ -1,60 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - -This file is part of libunwind. - -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. */ - -#include - -#include "unwind_i.h" - -unw_addr_space_t -unw_create_addr_space (unw_accessors_t *a, int byte_order) -{ -#ifdef UNW_LOCAL_ONLY - return NULL; -#else - unw_addr_space_t as; - - /* - * ARM supports little-endian and big-endian. - */ - if (byte_order != 0 && byte_order != __LITTLE_ENDIAN - && byte_order != __BIG_ENDIAN) - return NULL; - - as = malloc (sizeof (*as)); - if (!as) - return NULL; - - memset (as, 0, sizeof (*as)); - - as->acc = *a; - - /* Default to little-endian for ARM. */ - if (byte_order == 0 || byte_order == __LITTLE_ENDIAN) - as->big_endian = 0; - else - as->big_endian = 1; - - return as; -#endif -} diff --git a/src/pal/src/libunwind/src/arm/Gex_tables.c b/src/pal/src/libunwind/src/arm/Gex_tables.c deleted file mode 100644 index d6573a65e..000000000 --- a/src/pal/src/libunwind/src/arm/Gex_tables.c +++ /dev/null @@ -1,549 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright 2011 Linaro Limited - -This file is part of libunwind. - -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. */ - -/* This file contains functionality for parsing and interpreting the ARM -specific unwind information. Documentation about the exception handling -ABI for the ARM architecture can be found at: -http://infocenter.arm.com/help/topic/com.arm.doc.ihi0038a/IHI0038A_ehabi.pdf -*/ - -#include "libunwind_i.h" - -#define ARM_EXBUF_START(x) (((x) >> 4) & 0x0f) -#define ARM_EXBUF_COUNT(x) ((x) & 0x0f) -#define ARM_EXBUF_END(x) (ARM_EXBUF_START(x) + ARM_EXBUF_COUNT(x)) - -#define ARM_EXIDX_CANT_UNWIND 0x00000001 -#define ARM_EXIDX_COMPACT 0x80000000 - -#define ARM_EXTBL_OP_FINISH 0xb0 - -enum arm_exbuf_cmd_flags { - ARM_EXIDX_VFP_SHIFT_16 = 1 << 16, - ARM_EXIDX_VFP_DOUBLE = 1 << 17, -}; - -struct arm_cb_data - { - /* in: */ - unw_word_t ip; /* instruction-pointer we're looking for */ - unw_proc_info_t *pi; /* proc-info pointer */ - /* out: */ - unw_dyn_info_t di; /* info about the ARM exidx segment */ - }; - -static inline uint32_t CONST_ATTR -prel31_read (uint32_t prel31) -{ - return ((int32_t)prel31 << 1) >> 1; -} - -static inline int -prel31_to_addr (unw_addr_space_t as, void *arg, unw_word_t prel31, - unw_word_t *val) -{ - unw_word_t offset; - - if ((*as->acc.access_mem)(as, prel31, &offset, 0, arg) < 0) - return -UNW_EINVAL; - - offset = ((long)offset << 1) >> 1; - *val = prel31 + offset; - - return 0; -} - -/** - * Applies the given command onto the new state to the given dwarf_cursor. - */ -HIDDEN int -arm_exidx_apply_cmd (struct arm_exbuf_data *edata, struct dwarf_cursor *c) -{ - int ret = 0; - unsigned i; - - switch (edata->cmd) - { - case ARM_EXIDX_CMD_FINISH: - /* Set LR to PC if not set already. */ - if (DWARF_IS_NULL_LOC (c->loc[UNW_ARM_R15])) - c->loc[UNW_ARM_R15] = c->loc[UNW_ARM_R14]; - /* Set IP. */ - dwarf_get (c, c->loc[UNW_ARM_R15], &c->ip); - break; - case ARM_EXIDX_CMD_DATA_PUSH: - Debug (2, "vsp = vsp - %d\n", edata->data); - c->cfa -= edata->data; - break; - case ARM_EXIDX_CMD_DATA_POP: - Debug (2, "vsp = vsp + %d\n", edata->data); - c->cfa += edata->data; - break; - case ARM_EXIDX_CMD_REG_POP: - for (i = 0; i < 16; i++) - if (edata->data & (1 << i)) - { - Debug (2, "pop {r%d}\n", i); - c->loc[UNW_ARM_R0 + i] = DWARF_LOC (c->cfa, 0); - c->cfa += 4; - } - /* Set cfa in case the SP got popped. */ - if (edata->data & (1 << 13)) - dwarf_get (c, c->loc[UNW_ARM_R13], &c->cfa); - break; - case ARM_EXIDX_CMD_REG_TO_SP: - assert (edata->data < 16); - Debug (2, "vsp = r%d\n", edata->data); - c->loc[UNW_ARM_R13] = c->loc[UNW_ARM_R0 + edata->data]; - dwarf_get (c, c->loc[UNW_ARM_R13], &c->cfa); - break; - case ARM_EXIDX_CMD_VFP_POP: - /* Skip VFP registers, but be sure to adjust stack */ - for (i = ARM_EXBUF_START (edata->data); i <= ARM_EXBUF_END (edata->data); - i++) - c->cfa += 8; - if (!(edata->data & ARM_EXIDX_VFP_DOUBLE)) - c->cfa += 4; - break; - case ARM_EXIDX_CMD_WREG_POP: - for (i = ARM_EXBUF_START (edata->data); i <= ARM_EXBUF_END (edata->data); - i++) - c->cfa += 8; - break; - case ARM_EXIDX_CMD_WCGR_POP: - for (i = 0; i < 4; i++) - if (edata->data & (1 << i)) - c->cfa += 4; - break; - case ARM_EXIDX_CMD_REFUSED: - case ARM_EXIDX_CMD_RESERVED: - ret = -1; - break; - } - return ret; -} - -/** - * Decodes the given unwind instructions into arm_exbuf_data and calls - * arm_exidx_apply_cmd that applies the command onto the dwarf_cursor. - */ -HIDDEN int -arm_exidx_decode (const uint8_t *buf, uint8_t len, struct dwarf_cursor *c) -{ -#define READ_OP() *buf++ - const uint8_t *end = buf + len; - int ret; - struct arm_exbuf_data edata; - - assert(buf != NULL); - assert(len > 0); - - while (buf < end) - { - uint8_t op = READ_OP (); - if ((op & 0xc0) == 0x00) - { - edata.cmd = ARM_EXIDX_CMD_DATA_POP; - edata.data = (((int)op & 0x3f) << 2) + 4; - } - else if ((op & 0xc0) == 0x40) - { - edata.cmd = ARM_EXIDX_CMD_DATA_PUSH; - edata.data = (((int)op & 0x3f) << 2) + 4; - } - else if ((op & 0xf0) == 0x80) - { - uint8_t op2 = READ_OP (); - if (op == 0x80 && op2 == 0x00) - edata.cmd = ARM_EXIDX_CMD_REFUSED; - else - { - edata.cmd = ARM_EXIDX_CMD_REG_POP; - edata.data = ((op & 0xf) << 8) | op2; - edata.data = edata.data << 4; - } - } - else if ((op & 0xf0) == 0x90) - { - if (op == 0x9d || op == 0x9f) - edata.cmd = ARM_EXIDX_CMD_RESERVED; - else - { - edata.cmd = ARM_EXIDX_CMD_REG_TO_SP; - edata.data = op & 0x0f; - } - } - else if ((op & 0xf0) == 0xa0) - { - unsigned end = (op & 0x07); - edata.data = (1 << (end + 1)) - 1; - edata.data = edata.data << 4; - if (op & 0x08) - edata.data |= 1 << 14; - edata.cmd = ARM_EXIDX_CMD_REG_POP; - } - else if (op == ARM_EXTBL_OP_FINISH) - { - edata.cmd = ARM_EXIDX_CMD_FINISH; - buf = end; - } - else if (op == 0xb1) - { - uint8_t op2 = READ_OP (); - if (op2 == 0 || (op2 & 0xf0)) - edata.cmd = ARM_EXIDX_CMD_RESERVED; - else - { - edata.cmd = ARM_EXIDX_CMD_REG_POP; - edata.data = op2 & 0x0f; - } - } - else if (op == 0xb2) - { - uint32_t offset = 0; - uint8_t byte, shift = 0; - do - { - byte = READ_OP (); - offset |= (byte & 0x7f) << shift; - shift += 7; - } - while (byte & 0x80); - edata.data = offset * 4 + 0x204; - edata.cmd = ARM_EXIDX_CMD_DATA_POP; - } - else if (op == 0xb3 || op == 0xc8 || op == 0xc9) - { - edata.cmd = ARM_EXIDX_CMD_VFP_POP; - edata.data = READ_OP (); - if (op == 0xc8) - edata.data |= ARM_EXIDX_VFP_SHIFT_16; - if (op != 0xb3) - edata.data |= ARM_EXIDX_VFP_DOUBLE; - } - else if ((op & 0xf8) == 0xb8 || (op & 0xf8) == 0xd0) - { - edata.cmd = ARM_EXIDX_CMD_VFP_POP; - edata.data = 0x80 | (op & 0x07); - if ((op & 0xf8) == 0xd0) - edata.data |= ARM_EXIDX_VFP_DOUBLE; - } - else if (op >= 0xc0 && op <= 0xc5) - { - edata.cmd = ARM_EXIDX_CMD_WREG_POP; - edata.data = 0xa0 | (op & 0x07); - } - else if (op == 0xc6) - { - edata.cmd = ARM_EXIDX_CMD_WREG_POP; - edata.data = READ_OP (); - } - else if (op == 0xc7) - { - uint8_t op2 = READ_OP (); - if (op2 == 0 || (op2 & 0xf0)) - edata.cmd = ARM_EXIDX_CMD_RESERVED; - else - { - edata.cmd = ARM_EXIDX_CMD_WCGR_POP; - edata.data = op2 & 0x0f; - } - } - else - edata.cmd = ARM_EXIDX_CMD_RESERVED; - - ret = arm_exidx_apply_cmd (&edata, c); - if (ret < 0) - return ret; - } - return 0; -} - -/** - * Reads the entry from the given cursor and extracts the unwind instructions - * into buf. Returns the number of the extracted unwind insns or - * -UNW_ESTOPUNWIND if the special bit pattern ARM_EXIDX_CANT_UNWIND (0x1) was - * found. - */ -HIDDEN int -arm_exidx_extract (struct dwarf_cursor *c, uint8_t *buf) -{ - int nbuf = 0; - unw_word_t entry = (unw_word_t) c->pi.unwind_info; - unw_word_t addr; - uint32_t data; - - /* An ARM unwind entry consists of a prel31 offset to the start of a - function followed by 31bits of data: - * if set to 0x1: the function cannot be unwound (EXIDX_CANTUNWIND) - * if bit 31 is one: this is a table entry itself (ARM_EXIDX_COMPACT) - * if bit 31 is zero: this is a prel31 offset of the start of the - table entry for this function */ - if (prel31_to_addr(c->as, c->as_arg, entry, &addr) < 0) - return -UNW_EINVAL; - - if ((*c->as->acc.access_mem)(c->as, entry + 4, &data, 0, c->as_arg) < 0) - return -UNW_EINVAL; - - if (data == ARM_EXIDX_CANT_UNWIND) - { - Debug (2, "0x1 [can't unwind]\n"); - nbuf = -UNW_ESTOPUNWIND; - } - else if (data & ARM_EXIDX_COMPACT) - { - Debug (2, "%p compact model %d [%8.8x]\n", (void *)addr, - (data >> 24) & 0x7f, data); - buf[nbuf++] = data >> 16; - buf[nbuf++] = data >> 8; - buf[nbuf++] = data; - } - else - { - unw_word_t extbl_data; - unsigned int n_table_words = 0; - - if (prel31_to_addr(c->as, c->as_arg, entry + 4, &extbl_data) < 0) - return -UNW_EINVAL; - - if ((*c->as->acc.access_mem)(c->as, extbl_data, &data, 0, c->as_arg) < 0) - return -UNW_EINVAL; - - if (data & ARM_EXIDX_COMPACT) - { - int pers = (data >> 24) & 0x0f; - Debug (2, "%p compact model %d [%8.8x]\n", (void *)addr, pers, data); - if (pers == 1 || pers == 2) - { - n_table_words = (data >> 16) & 0xff; - extbl_data += 4; - } - else - buf[nbuf++] = data >> 16; - buf[nbuf++] = data >> 8; - buf[nbuf++] = data; - } - else - { - unw_word_t pers; - if (prel31_to_addr (c->as, c->as_arg, extbl_data, &pers) < 0) - return -UNW_EINVAL; - Debug (2, "%p Personality routine: %8p\n", (void *)addr, - (void *)pers); - if ((*c->as->acc.access_mem)(c->as, extbl_data + 4, &data, 0, - c->as_arg) < 0) - return -UNW_EINVAL; - n_table_words = data >> 24; - buf[nbuf++] = data >> 16; - buf[nbuf++] = data >> 8; - buf[nbuf++] = data; - extbl_data += 8; - } - assert (n_table_words <= 5); - unsigned j; - for (j = 0; j < n_table_words; j++) - { - if ((*c->as->acc.access_mem)(c->as, extbl_data, &data, 0, - c->as_arg) < 0) - return -UNW_EINVAL; - extbl_data += 4; - buf[nbuf++] = data >> 24; - buf[nbuf++] = data >> 16; - buf[nbuf++] = data >> 8; - buf[nbuf++] = data >> 0; - } - } - - if (nbuf > 0 && buf[nbuf - 1] != ARM_EXTBL_OP_FINISH) - buf[nbuf++] = ARM_EXTBL_OP_FINISH; - - return nbuf; -} - -int -arm_search_unwind_table (unw_addr_space_t as, unw_word_t ip, - unw_dyn_info_t *di, unw_proc_info_t *pi, - int need_unwind_info, void *arg) -{ - /* The .ARM.exidx section contains a sorted list of key-value pairs - - the unwind entries. The 'key' is a prel31 offset to the start of a - function. We binary search this section in order to find the - appropriate unwind entry. */ - unw_word_t first = di->u.rti.table_data; - unw_word_t last = di->u.rti.table_data + di->u.rti.table_len - 8; - unw_word_t entry, val; - - if (prel31_to_addr (as, arg, first, &val) < 0 || ip < val) - return -UNW_ENOINFO; - - if (prel31_to_addr (as, arg, last, &val) < 0) - return -UNW_EINVAL; - - if (ip >= val) - { - entry = last; - - if (prel31_to_addr (as, arg, last, &pi->start_ip) < 0) - return -UNW_EINVAL; - - pi->end_ip = di->end_ip -1; - } - else - { - while (first < last - 8) - { - entry = first + (((last - first) / 8 + 1) >> 1) * 8; - - if (prel31_to_addr (as, arg, entry, &val) < 0) - return -UNW_EINVAL; - - if (ip < val) - last = entry; - else - first = entry; - } - - entry = first; - - if (prel31_to_addr (as, arg, entry, &pi->start_ip) < 0) - return -UNW_EINVAL; - - if (prel31_to_addr (as, arg, entry + 8, &pi->end_ip) < 0) - return -UNW_EINVAL; - - pi->end_ip--; - } - - if (need_unwind_info) - { - pi->unwind_info_size = 8; - pi->unwind_info = (void *) entry; - pi->format = UNW_INFO_FORMAT_ARM_EXIDX; - } - return 0; -} - -int -tdep_search_unwind_table (unw_addr_space_t as, unw_word_t ip, - unw_dyn_info_t *di, unw_proc_info_t *pi, - int need_unwind_info, void *arg) -{ - if (UNW_TRY_METHOD (UNW_ARM_METHOD_EXIDX) - && di->format == UNW_INFO_FORMAT_ARM_EXIDX) - return arm_search_unwind_table (as, ip, di, pi, need_unwind_info, arg); - else if (UNW_TRY_METHOD(UNW_ARM_METHOD_DWARF) - && di->format != UNW_INFO_FORMAT_ARM_EXIDX) - return dwarf_search_unwind_table (as, ip, di, pi, need_unwind_info, arg); - - return -UNW_ENOINFO; -} - -#ifndef UNW_REMOTE_ONLY -/** - * Callback to dl_iterate_phdr to find infos about the ARM exidx segment. - */ -static int -arm_phdr_cb (struct dl_phdr_info *info, size_t size, void *data) -{ - struct arm_cb_data *cb_data = data; - const Elf_W(Phdr) *p_text = NULL; - const Elf_W(Phdr) *p_arm_exidx = NULL; - const Elf_W(Phdr) *phdr = info->dlpi_phdr; - long n; - - for (n = info->dlpi_phnum; --n >= 0; phdr++) - { - switch (phdr->p_type) - { - case PT_LOAD: - if (cb_data->ip >= phdr->p_vaddr + info->dlpi_addr && - cb_data->ip < phdr->p_vaddr + info->dlpi_addr + phdr->p_memsz) - p_text = phdr; - break; - - case PT_ARM_EXIDX: - p_arm_exidx = phdr; - break; - - default: - break; - } - } - - if (p_text && p_arm_exidx) - { - cb_data->di.format = UNW_INFO_FORMAT_ARM_EXIDX; - cb_data->di.start_ip = p_text->p_vaddr + info->dlpi_addr; - cb_data->di.end_ip = cb_data->di.start_ip + p_text->p_memsz; - cb_data->di.u.rti.name_ptr = (unw_word_t) info->dlpi_name; - cb_data->di.u.rti.table_data = p_arm_exidx->p_vaddr + info->dlpi_addr; - cb_data->di.u.rti.table_len = p_arm_exidx->p_memsz; - return 1; - } - - return 0; -} - -HIDDEN int -arm_find_proc_info (unw_addr_space_t as, unw_word_t ip, - unw_proc_info_t *pi, int need_unwind_info, void *arg) -{ - int ret = -1; - intrmask_t saved_mask; - - Debug (14, "looking for IP=0x%lx\n", (long) ip); - - if (UNW_TRY_METHOD(UNW_ARM_METHOD_DWARF)) - ret = dwarf_find_proc_info (as, ip, pi, need_unwind_info, arg); - - if (ret < 0 && UNW_TRY_METHOD (UNW_ARM_METHOD_EXIDX)) - { - struct arm_cb_data cb_data; - - memset (&cb_data, 0, sizeof (cb_data)); - cb_data.ip = ip; - cb_data.pi = pi; - cb_data.di.format = -1; - - SIGPROCMASK (SIG_SETMASK, &unwi_full_mask, &saved_mask); - ret = dl_iterate_phdr (arm_phdr_cb, &cb_data); - SIGPROCMASK (SIG_SETMASK, &saved_mask, NULL); - - if (cb_data.di.format != -1) - ret = arm_search_unwind_table (as, ip, &cb_data.di, pi, - need_unwind_info, arg); - else - ret = -UNW_ENOINFO; - } - - return ret; -} - -HIDDEN void -arm_put_unwind_info (unw_addr_space_t as, unw_proc_info_t *proc_info, void *arg) -{ - /* it's a no-op */ -} -#endif /* !UNW_REMOTE_ONLY */ - diff --git a/src/pal/src/libunwind/src/arm/Gget_proc_info.c b/src/pal/src/libunwind/src/arm/Gget_proc_info.c deleted file mode 100644 index 4051a1076..000000000 --- a/src/pal/src/libunwind/src/arm/Gget_proc_info.c +++ /dev/null @@ -1,41 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" - -int -unw_get_proc_info (unw_cursor_t *cursor, unw_proc_info_t *pi) -{ - struct cursor *c = (struct cursor *) cursor; - int ret; - - /* We can only unwind using Dwarf into on ARM: return failure code - if it's not present. */ - ret = dwarf_make_proc_info (&c->dwarf); - if (ret < 0) - return ret; - - *pi = c->dwarf.pi; - return 0; -} diff --git a/src/pal/src/libunwind/src/arm/Gget_save_loc.c b/src/pal/src/libunwind/src/arm/Gget_save_loc.c deleted file mode 100644 index 9fb070489..000000000 --- a/src/pal/src/libunwind/src/arm/Gget_save_loc.c +++ /dev/null @@ -1,81 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" - -int -unw_get_save_loc (unw_cursor_t *cursor, int reg, unw_save_loc_t *sloc) -{ - struct cursor *c = (struct cursor *) cursor; - dwarf_loc_t loc; - - loc = DWARF_NULL_LOC; /* default to "not saved" */ - - switch (reg) - { - case UNW_ARM_R0: - case UNW_ARM_R1: - case UNW_ARM_R2: - case UNW_ARM_R3: - case UNW_ARM_R4: - case UNW_ARM_R5: - case UNW_ARM_R6: - case UNW_ARM_R7: - case UNW_ARM_R8: - case UNW_ARM_R9: - case UNW_ARM_R10: - case UNW_ARM_R11: - case UNW_ARM_R12: - case UNW_ARM_R13: - case UNW_ARM_R14: - case UNW_ARM_R15: - loc = c->dwarf.loc[reg - UNW_ARM_R0]; - break; - - default: - break; - } - - memset (sloc, 0, sizeof (*sloc)); - - if (DWARF_IS_NULL_LOC (loc)) - { - sloc->type = UNW_SLT_NONE; - return 0; - } - -#if !defined(UNW_LOCAL_ONLY) - if (DWARF_IS_REG_LOC (loc)) - { - sloc->type = UNW_SLT_REG; - sloc->u.regnum = DWARF_GET_LOC (loc); - } - else -#endif - { - sloc->type = UNW_SLT_MEMORY; - sloc->u.addr = DWARF_GET_LOC (loc); - } - return 0; -} diff --git a/src/pal/src/libunwind/src/arm/Gglobal.c b/src/pal/src/libunwind/src/arm/Gglobal.c deleted file mode 100644 index 7b93fbd89..000000000 --- a/src/pal/src/libunwind/src/arm/Gglobal.c +++ /dev/null @@ -1,65 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" -#include "dwarf_i.h" - -HIDDEN define_lock (arm_lock); -HIDDEN int tdep_init_done; - -/* Unwinding methods to use. See UNW_METHOD_ enums */ -HIDDEN int unwi_unwind_method = UNW_ARM_METHOD_ALL; - -HIDDEN void -tdep_init (void) -{ - intrmask_t saved_mask; - - sigfillset (&unwi_full_mask); - - lock_acquire (&arm_lock, saved_mask); - { - if (tdep_init_done) - /* another thread else beat us to it... */ - goto out; - - /* read ARM unwind method setting */ - const char* str = getenv ("UNW_ARM_UNWIND_METHOD"); - if (str) - { - unwi_unwind_method = atoi (str); - } - - mi_init (); - - dwarf_init (); - -#ifndef UNW_REMOTE_ONLY - arm_local_addr_space_init (); -#endif - tdep_init_done = 1; /* signal that we're initialized... */ - } - out: - lock_release (&arm_lock, saved_mask); -} diff --git a/src/pal/src/libunwind/src/arm/Ginit.c b/src/pal/src/libunwind/src/arm/Ginit.c deleted file mode 100644 index 2720d063a..000000000 --- a/src/pal/src/libunwind/src/arm/Ginit.c +++ /dev/null @@ -1,235 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - -This file is part of libunwind. - -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. */ - -#include -#include - -#include "unwind_i.h" - -#ifdef UNW_REMOTE_ONLY - -/* unw_local_addr_space is a NULL pointer in this case. */ -unw_addr_space_t unw_local_addr_space; - -#else /* !UNW_REMOTE_ONLY */ - -static struct unw_addr_space local_addr_space; - -unw_addr_space_t unw_local_addr_space = &local_addr_space; - -static inline void * -uc_addr (unw_tdep_context_t *uc, int reg) -{ - if (reg >= UNW_ARM_R0 && reg < UNW_ARM_R0 + 16) - return &uc->regs[reg - UNW_ARM_R0]; - else - return NULL; -} - -# ifdef UNW_LOCAL_ONLY - -HIDDEN void * -tdep_uc_addr (unw_tdep_context_t *uc, int reg) -{ - return uc_addr (uc, reg); -} - -# endif /* UNW_LOCAL_ONLY */ - -HIDDEN unw_dyn_info_list_t _U_dyn_info_list; - -/* XXX fix me: there is currently no way to locate the dyn-info list - by a remote unwinder. On ia64, this is done via a special - unwind-table entry. Perhaps something similar can be done with - DWARF2 unwind info. */ - -static int -get_dyn_info_list_addr (unw_addr_space_t as, unw_word_t *dyn_info_list_addr, - void *arg) -{ - *dyn_info_list_addr = (unw_word_t) &_U_dyn_info_list; - return 0; -} - -#define PAGE_SIZE 4096 -#define PAGE_START(a) ((a) & ~(PAGE_SIZE-1)) - -/* Cache of already validated addresses */ -#define NLGA 4 -static unw_word_t last_good_addr[NLGA]; -static int lga_victim; - -static int -validate_mem (unw_word_t addr) -{ - int i, victim; - size_t len; - - if (PAGE_START(addr + sizeof (unw_word_t) - 1) == PAGE_START(addr)) - len = PAGE_SIZE; - else - len = PAGE_SIZE * 2; - - addr = PAGE_START(addr); - - if (addr == 0) - return -1; - - for (i = 0; i < NLGA; i++) - { - if (last_good_addr[i] && (addr == last_good_addr[i])) - return 0; - } - - if (msync ((void *) addr, len, MS_ASYNC) == -1) - return -1; - - victim = lga_victim; - for (i = 0; i < NLGA; i++) { - if (!last_good_addr[victim]) { - last_good_addr[victim++] = addr; - return 0; - } - victim = (victim + 1) % NLGA; - } - - /* All slots full. Evict the victim. */ - last_good_addr[victim] = addr; - victim = (victim + 1) % NLGA; - lga_victim = victim; - - return 0; -} - -static int -access_mem (unw_addr_space_t as, unw_word_t addr, unw_word_t *val, int write, - void *arg) -{ - /* validate address */ - const struct cursor *c = (const struct cursor *) arg; - if (c && validate_mem(addr)) - return -1; - - if (write) - { - Debug (16, "mem[%x] <- %x\n", addr, *val); - *(unw_word_t *) addr = *val; - } - else - { - *val = *(unw_word_t *) addr; - Debug (16, "mem[%x] -> %x\n", addr, *val); - } - return 0; -} - -static int -access_reg (unw_addr_space_t as, unw_regnum_t reg, unw_word_t *val, int write, - void *arg) -{ - unw_word_t *addr; - unw_tdep_context_t *uc = arg; - - if (unw_is_fpreg (reg)) - goto badreg; - -Debug (16, "reg = %s\n", unw_regname (reg)); - if (!(addr = uc_addr (uc, reg))) - goto badreg; - - if (write) - { - *(unw_word_t *) addr = *val; - Debug (12, "%s <- %x\n", unw_regname (reg), *val); - } - else - { - *val = *(unw_word_t *) addr; - Debug (12, "%s -> %x\n", unw_regname (reg), *val); - } - return 0; - - badreg: - Debug (1, "bad register number %u\n", reg); - return -UNW_EBADREG; -} - -static int -access_fpreg (unw_addr_space_t as, unw_regnum_t reg, unw_fpreg_t *val, - int write, void *arg) -{ - unw_tdep_context_t *uc = arg; - unw_fpreg_t *addr; - - if (!unw_is_fpreg (reg)) - goto badreg; - - if (!(addr = uc_addr (uc, reg))) - goto badreg; - - if (write) - { - Debug (12, "%s <- %08lx.%08lx.%08lx\n", unw_regname (reg), - ((long *)val)[0], ((long *)val)[1], ((long *)val)[2]); - *(unw_fpreg_t *) addr = *val; - } - else - { - *val = *(unw_fpreg_t *) addr; - Debug (12, "%s -> %08lx.%08lx.%08lx\n", unw_regname (reg), - ((long *)val)[0], ((long *)val)[1], ((long *)val)[2]); - } - return 0; - - badreg: - Debug (1, "bad register number %u\n", reg); - /* attempt to access a non-preserved register */ - return -UNW_EBADREG; -} - -static int -get_static_proc_name (unw_addr_space_t as, unw_word_t ip, - char *buf, size_t buf_len, unw_word_t *offp, - void *arg) -{ - return _Uelf32_get_proc_name (as, getpid (), ip, buf, buf_len, offp); -} - -HIDDEN void -arm_local_addr_space_init (void) -{ - memset (&local_addr_space, 0, sizeof (local_addr_space)); - local_addr_space.caching_policy = UNWI_DEFAULT_CACHING_POLICY; - local_addr_space.acc.find_proc_info = arm_find_proc_info; - local_addr_space.acc.put_unwind_info = arm_put_unwind_info; - local_addr_space.acc.get_dyn_info_list_addr = get_dyn_info_list_addr; - local_addr_space.acc.access_mem = access_mem; - local_addr_space.acc.access_reg = access_reg; - local_addr_space.acc.access_fpreg = access_fpreg; - local_addr_space.acc.resume = arm_local_resume; - local_addr_space.acc.get_proc_name = get_static_proc_name; - unw_flush_cache (&local_addr_space, 0, 0); -} - -#endif /* !UNW_REMOTE_ONLY */ diff --git a/src/pal/src/libunwind/src/arm/Ginit_local.c b/src/pal/src/libunwind/src/arm/Ginit_local.c deleted file mode 100644 index e13519b79..000000000 --- a/src/pal/src/libunwind/src/arm/Ginit_local.c +++ /dev/null @@ -1,78 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - Copyright 2011 Linaro Limited - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" -#include "init.h" - -#ifdef UNW_REMOTE_ONLY - -int -unw_init_local (unw_cursor_t *cursor, unw_context_t *uc) -{ - return -UNW_EINVAL; -} - -#else /* !UNW_REMOTE_ONLY */ - -static int -unw_init_local_common (unw_cursor_t *cursor, unw_context_t *uc, unsigned use_prev_instr) -{ - struct cursor *c = (struct cursor *) cursor; - - if (!tdep_init_done) - tdep_init (); - - Debug (1, "(cursor=%p)\n", c); - - c->dwarf.as = unw_local_addr_space; - c->dwarf.as_arg = uc; - - return common_init (c, use_prev_instr); -} - -int -unw_init_local (unw_cursor_t *cursor, unw_context_t *uc) -{ - return unw_init_local_common(cursor, uc, 1); -} - -int -unw_init_local2 (unw_cursor_t *cursor, unw_context_t *uc, int flag) -{ - if (!flag) - { - return unw_init_local_common(cursor, uc, 1); - } - else if (flag == UNW_INIT_SIGNAL_FRAME) - { - return unw_init_local_common(cursor, uc, 0); - } - else - { - return -UNW_EINVAL; - } -} - -#endif /* !UNW_REMOTE_ONLY */ diff --git a/src/pal/src/libunwind/src/arm/Ginit_remote.c b/src/pal/src/libunwind/src/arm/Ginit_remote.c deleted file mode 100644 index 9b8ba5b89..000000000 --- a/src/pal/src/libunwind/src/arm/Ginit_remote.c +++ /dev/null @@ -1,45 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - -This file is part of libunwind. - -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. */ - -#include "init.h" -#include "unwind_i.h" - -int -unw_init_remote (unw_cursor_t *cursor, unw_addr_space_t as, void *as_arg) -{ -#ifdef UNW_LOCAL_ONLY - return -UNW_EINVAL; -#else /* !UNW_LOCAL_ONLY */ - struct cursor *c = (struct cursor *) cursor; - - if (!tdep_init_done) - tdep_init (); - - Debug (1, "(cursor=%p)\n", c); - - c->dwarf.as = as; - c->dwarf.as_arg = as_arg; - return common_init (c, 0); -#endif /* !UNW_LOCAL_ONLY */ -} diff --git a/src/pal/src/libunwind/src/arm/Gos-freebsd.c b/src/pal/src/libunwind/src/arm/Gos-freebsd.c deleted file mode 100644 index a1069223a..000000000 --- a/src/pal/src/libunwind/src/arm/Gos-freebsd.c +++ /dev/null @@ -1,129 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - Copyright 2011 Linaro Limited - Copyright (C) 2012 Tommi Rantala - Copyright 2015 The FreeBSD Foundation - - Portions of this software were developed by Konstantin Belousov - under sponsorship from the FreeBSD Foundation. - -This file is part of libunwind. - -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. */ - -#include -#include -#include "unwind_i.h" -#include "offsets.h" -#include "ex_tables.h" - -HIDDEN int -arm_handle_signal_frame (unw_cursor_t *cursor) -{ - struct cursor *c = (struct cursor *) cursor; - int ret, fmt; - unw_word_t sc_addr, sp, sp_addr = c->dwarf.cfa; - struct dwarf_loc sp_loc = DWARF_LOC (sp_addr, 0); - - if ((ret = dwarf_get (&c->dwarf, sp_loc, &sp)) < 0) - return -UNW_EUNSPEC; - fmt = unw_is_signal_frame(cursor); - - c->dwarf.pi_valid = 0; - - if (fmt == UNW_ARM_FRAME_SYSCALL) - { - c->sigcontext_format = ARM_SCF_FREEBSD_SYSCALL; - c->frame_info.frame_type = UNW_ARM_FRAME_SYSCALL; - c->frame_info.cfa_reg_offset = 0; - c->dwarf.loc[UNW_ARM_R7] = c->dwarf.loc[UNW_ARM_R12]; - dwarf_get (&c->dwarf, c->dwarf.loc[UNW_ARM_R14], &c->dwarf.ip); - return 1; - } - - c->sigcontext_format = ARM_SCF_FREEBSD_SIGFRAME; - sc_addr = sp_addr; - - /* Save the SP and PC to be able to return execution at this point - later in time (unw_resume). */ - c->sigcontext_sp = c->dwarf.cfa; - c->sigcontext_pc = c->dwarf.ip; - - c->sigcontext_addr = sc_addr; - c->frame_info.frame_type = UNW_ARM_FRAME_SIGRETURN; - c->frame_info.cfa_reg_offset = sc_addr - sp_addr; - - /* Update the dwarf cursor. - Set the location of the registers to the corresponding addresses of the - uc_mcontext / sigcontext structure contents. */ -#define ROFF(n) (FREEBSD_SC_UCONTEXT_OFF + FREEBSD_UC_MCONTEXT_OFF + \ - FREEBSD_MC_R0_OFF + (n) * 4) -#define SL(n) \ - c->dwarf.loc[UNW_ARM_R ## n] = DWARF_LOC (sc_addr + ROFF(n), 0); - SL(0); SL(1); SL(2); SL(3); SL(4); SL(5); SL(6); SL(7); - SL(8); SL(9); SL(10); SL(11); SL(12); SL(13); SL(14); SL(15); -#undef SL -#undef ROFF - - /* Set SP/CFA and PC/IP. */ - dwarf_get (&c->dwarf, c->dwarf.loc[UNW_ARM_R13], &c->dwarf.cfa); - dwarf_get (&c->dwarf, c->dwarf.loc[UNW_ARM_R15], &c->dwarf.ip); - - return 1; -} - -/* Returns 1 in case of a non-RT signal frame and 2 in case of a RT signal - frame. */ -int -unw_is_signal_frame (unw_cursor_t *cursor) -{ - struct cursor *c = (struct cursor *) cursor; - unw_word_t w0, w1, w2, w3, ip; - unw_addr_space_t as; - unw_accessors_t *a; - void *arg; - int ret; - - as = c->dwarf.as; - a = unw_get_accessors_int (as); - arg = c->dwarf.as_arg; - - ip = c->dwarf.ip; - - if ((ret = (*a->access_mem) (as, ip, &w0, 0, arg)) < 0) - return ret; - if ((ret = (*a->access_mem) (as, ip + 4, &w1, 0, arg)) < 0) - return ret; - if ((ret = (*a->access_mem) (as, ip + 8, &w2, 0, arg)) < 0) - return ret; - if ((ret = (*a->access_mem) (as, ip + 12, &w3, 0, arg)) < 0) - return ret; - - if (w0 == 0xe1a0000d && w1 == 0xe2800040 && w2 == 0xe59f700c && - w3 == 0xef0001a1) - return UNW_ARM_FRAME_SIGRETURN; - - if ((ret = (*a->access_mem) (as, ip - 4, &w0, 0, arg)) < 0) - return ret; - if (w0 == 0xef000000) - return UNW_ARM_FRAME_SYSCALL; - - return 0; -} diff --git a/src/pal/src/libunwind/src/arm/Gos-linux.c b/src/pal/src/libunwind/src/arm/Gos-linux.c deleted file mode 100644 index 260e086f6..000000000 --- a/src/pal/src/libunwind/src/arm/Gos-linux.c +++ /dev/null @@ -1,182 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - Copyright 2011 Linaro Limited - Copyright (C) 2012 Tommi Rantala - -This file is part of libunwind. - -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. */ - -#include -#include -#include "unwind_i.h" -#include "offsets.h" - -HIDDEN int -arm_handle_signal_frame (unw_cursor_t *cursor) -{ - struct cursor *c = (struct cursor *) cursor; - int ret; - unw_word_t sc_addr, sp, sp_addr = c->dwarf.cfa; - struct dwarf_loc sp_loc = DWARF_LOC (sp_addr, 0); - - if ((ret = dwarf_get (&c->dwarf, sp_loc, &sp)) < 0) - return -UNW_EUNSPEC; - - /* Obtain signal frame type (non-RT or RT). */ - ret = unw_is_signal_frame (cursor); - - /* Save the SP and PC to be able to return execution at this point - later in time (unw_resume). */ - c->sigcontext_sp = c->dwarf.cfa; - c->sigcontext_pc = c->dwarf.ip; - - /* Since kernel version 2.6.18 the non-RT signal frame starts with a - ucontext while the RT signal frame starts with a siginfo, followed - by a sigframe whose first element is an ucontext. - Prior 2.6.18 the non-RT signal frame starts with a sigcontext while - the RT signal frame starts with two pointers followed by a siginfo - and an ucontext. The first pointer points to the start of the siginfo - structure and the second one to the ucontext structure. */ - - if (ret == 1) - { - /* Handle non-RT signal frames. Check if the first word on the stack - is the magic number. */ - if (sp == 0x5ac3c35a) - { - c->sigcontext_format = ARM_SCF_LINUX_SIGFRAME; - sc_addr = sp_addr + LINUX_UC_MCONTEXT_OFF; - } - else - { - c->sigcontext_format = ARM_SCF_LINUX_OLD_SIGFRAME; - sc_addr = sp_addr; - } - } - else if (ret == 2) - { - /* Handle RT signal frames. Check if the first word on the stack is a - pointer to the siginfo structure. */ - if (sp == sp_addr + 8) - { - c->sigcontext_format = ARM_SCF_LINUX_OLD_RT_SIGFRAME; - sc_addr = sp_addr + 8 + sizeof (siginfo_t) + LINUX_UC_MCONTEXT_OFF; - } - else - { - c->sigcontext_format = ARM_SCF_LINUX_RT_SIGFRAME; - sc_addr = sp_addr + sizeof (siginfo_t) + LINUX_UC_MCONTEXT_OFF; - } - } - else - return -UNW_EUNSPEC; - - c->sigcontext_addr = sc_addr; - c->frame_info.frame_type = UNW_ARM_FRAME_SIGRETURN; - c->frame_info.cfa_reg_offset = sc_addr - sp_addr; - - /* Update the dwarf cursor. - Set the location of the registers to the corresponding addresses of the - uc_mcontext / sigcontext structure contents. */ - c->dwarf.loc[UNW_ARM_R0] = DWARF_LOC (sc_addr + LINUX_SC_R0_OFF, 0); - c->dwarf.loc[UNW_ARM_R1] = DWARF_LOC (sc_addr + LINUX_SC_R1_OFF, 0); - c->dwarf.loc[UNW_ARM_R2] = DWARF_LOC (sc_addr + LINUX_SC_R2_OFF, 0); - c->dwarf.loc[UNW_ARM_R3] = DWARF_LOC (sc_addr + LINUX_SC_R3_OFF, 0); - c->dwarf.loc[UNW_ARM_R4] = DWARF_LOC (sc_addr + LINUX_SC_R4_OFF, 0); - c->dwarf.loc[UNW_ARM_R5] = DWARF_LOC (sc_addr + LINUX_SC_R5_OFF, 0); - c->dwarf.loc[UNW_ARM_R6] = DWARF_LOC (sc_addr + LINUX_SC_R6_OFF, 0); - c->dwarf.loc[UNW_ARM_R7] = DWARF_LOC (sc_addr + LINUX_SC_R7_OFF, 0); - c->dwarf.loc[UNW_ARM_R8] = DWARF_LOC (sc_addr + LINUX_SC_R8_OFF, 0); - c->dwarf.loc[UNW_ARM_R9] = DWARF_LOC (sc_addr + LINUX_SC_R9_OFF, 0); - c->dwarf.loc[UNW_ARM_R10] = DWARF_LOC (sc_addr + LINUX_SC_R10_OFF, 0); - c->dwarf.loc[UNW_ARM_R11] = DWARF_LOC (sc_addr + LINUX_SC_FP_OFF, 0); - c->dwarf.loc[UNW_ARM_R12] = DWARF_LOC (sc_addr + LINUX_SC_IP_OFF, 0); - c->dwarf.loc[UNW_ARM_R13] = DWARF_LOC (sc_addr + LINUX_SC_SP_OFF, 0); - c->dwarf.loc[UNW_ARM_R14] = DWARF_LOC (sc_addr + LINUX_SC_LR_OFF, 0); - c->dwarf.loc[UNW_ARM_R15] = DWARF_LOC (sc_addr + LINUX_SC_PC_OFF, 0); - - /* Set SP/CFA and PC/IP. */ - dwarf_get (&c->dwarf, c->dwarf.loc[UNW_ARM_R13], &c->dwarf.cfa); - dwarf_get (&c->dwarf, c->dwarf.loc[UNW_ARM_R15], &c->dwarf.ip); - - c->dwarf.pi_valid = 0; - - return 1; -} - -#define ARM_NR_sigreturn 119 -#define ARM_NR_rt_sigreturn 173 -#define ARM_NR_OABI_SYSCALL_BASE 0x900000 - -/* ARM EABI sigreturn (the syscall number is loaded into r7) */ -#define MOV_R7_SIGRETURN (0xe3a07000UL | ARM_NR_sigreturn) -#define MOV_R7_RT_SIGRETURN (0xe3a07000UL | ARM_NR_rt_sigreturn) - -/* ARM OABI sigreturn (using SWI) */ -#define ARM_SIGRETURN \ - (0xef000000UL | ARM_NR_sigreturn | ARM_NR_OABI_SYSCALL_BASE) -#define ARM_RT_SIGRETURN \ - (0xef000000UL | ARM_NR_rt_sigreturn | ARM_NR_OABI_SYSCALL_BASE) - -/* Thumb sigreturn (two insns, syscall number is loaded into r7) */ -#define THUMB_SIGRETURN (0xdf00UL << 16 | 0x2700 | ARM_NR_sigreturn) -#define THUMB_RT_SIGRETURN (0xdf00UL << 16 | 0x2700 | ARM_NR_rt_sigreturn) - -/* Thumb2 sigreturn (mov.w r7, $SYS_ify(rt_sigreturn/sigreturn)) */ -#define THUMB2_SIGRETURN (((0x0700 | ARM_NR_sigreturn) << 16) | \ - 0xf04f) -#define THUMB2_RT_SIGRETURN (((0x0700 | ARM_NR_rt_sigreturn) << 16) | \ - 0xf04f) -/* TODO: with different toolchains, there are a lot more possibilities */ - -/* Returns 1 in case of a non-RT signal frame and 2 in case of a RT signal - frame. */ -int -unw_is_signal_frame (unw_cursor_t *cursor) -{ - struct cursor *c = (struct cursor *) cursor; - unw_word_t w0, ip; - unw_addr_space_t as; - unw_accessors_t *a; - void *arg; - int ret; - - as = c->dwarf.as; - a = unw_get_accessors_int (as); - arg = c->dwarf.as_arg; - - /* The least bit denotes thumb/arm mode. Do not read there. */ - ip = c->dwarf.ip & ~0x1; - - if ((ret = (*a->access_mem) (as, ip, &w0, 0, arg)) < 0) - return ret; - - /* Return 1 if the IP points to a non-RT sigreturn sequence. */ - if (w0 == MOV_R7_SIGRETURN || w0 == ARM_SIGRETURN || w0 == THUMB_SIGRETURN - || w0 == THUMB2_SIGRETURN) - return 1; - /* Return 2 if the IP points to a RT sigreturn sequence. */ - else if (w0 == MOV_R7_RT_SIGRETURN || w0 == ARM_RT_SIGRETURN - || w0 == THUMB_RT_SIGRETURN || w0 == THUMB2_RT_SIGRETURN) - return 2; - - return 0; -} diff --git a/src/pal/src/libunwind/src/arm/Gos-other.c b/src/pal/src/libunwind/src/arm/Gos-other.c deleted file mode 100644 index 73c102c3d..000000000 --- a/src/pal/src/libunwind/src/arm/Gos-other.c +++ /dev/null @@ -1,48 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - Copyright 2011 Linaro Limited - Copyright (C) 2012 Tommi Rantala - -This file is part of libunwind. - -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. */ - -#include -#include -#include "unwind_i.h" -#include "offsets.h" - -HIDDEN int -arm_handle_signal_frame (unw_cursor_t *cursor) -{ - return -UNW_EUNSPEC; -} - -int -unw_is_signal_frame (unw_cursor_t *cursor) -{ -#if defined(__QNX__) - /* Not supported yet */ - return 0; -#else - printf ("%s: implement me\n", __FUNCTION__); - return -UNW_ENOINFO; -#endif -} diff --git a/src/pal/src/libunwind/src/arm/Greg_states_iterate.c b/src/pal/src/libunwind/src/arm/Greg_states_iterate.c deleted file mode 100644 index a17dc1b56..000000000 --- a/src/pal/src/libunwind/src/arm/Greg_states_iterate.c +++ /dev/null @@ -1,37 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (c) 2002-2003 Hewlett-Packard Development Company, L.P. - Contributed by David Mosberger-Tang - - Modified for x86_64 by Max Asbock - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" - -int -unw_reg_states_iterate (unw_cursor_t *cursor, - unw_reg_states_callback cb, void *token) -{ - struct cursor *c = (struct cursor *) cursor; - - return dwarf_reg_states_iterate (&c->dwarf, cb, token); -} diff --git a/src/pal/src/libunwind/src/arm/Gregs.c b/src/pal/src/libunwind/src/arm/Gregs.c deleted file mode 100644 index 0d52f0b22..000000000 --- a/src/pal/src/libunwind/src/arm/Gregs.c +++ /dev/null @@ -1,83 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" - -HIDDEN int -tdep_access_reg (struct cursor *c, unw_regnum_t reg, unw_word_t *valp, - int write) -{ - dwarf_loc_t loc = DWARF_NULL_LOC; - - switch (reg) - { - case UNW_ARM_R15: - if (write) - c->dwarf.ip = *valp; /* update the IP cache */ - case UNW_ARM_R0: - case UNW_ARM_R1: - case UNW_ARM_R2: - case UNW_ARM_R3: - case UNW_ARM_R4: - case UNW_ARM_R5: - case UNW_ARM_R6: - case UNW_ARM_R7: - case UNW_ARM_R8: - case UNW_ARM_R9: - case UNW_ARM_R10: - case UNW_ARM_R11: - case UNW_ARM_R12: - case UNW_ARM_R14: - loc = c->dwarf.loc[reg - UNW_ARM_R0]; - break; - - case UNW_ARM_R13: - case UNW_ARM_CFA: - if (write) - return -UNW_EREADONLYREG; - *valp = c->dwarf.cfa; - return 0; - - /* FIXME: Initialise coprocessor & shadow registers? */ - - default: - Debug (1, "bad register number %u\n", reg); - return -UNW_EBADREG; - } - - if (write) - return dwarf_put (&c->dwarf, loc, *valp); - else - return dwarf_get (&c->dwarf, loc, valp); -} - -/* FIXME for ARM. */ - -HIDDEN int -tdep_access_fpreg (struct cursor *c, unw_regnum_t reg, unw_fpreg_t *valp, - int write) -{ - Debug (1, "bad register number %u\n", reg); - return -UNW_EBADREG; -} diff --git a/src/pal/src/libunwind/src/arm/Gresume.c b/src/pal/src/libunwind/src/arm/Gresume.c deleted file mode 100644 index a8288628a..000000000 --- a/src/pal/src/libunwind/src/arm/Gresume.c +++ /dev/null @@ -1,154 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - Copyright 2011 Linaro Limited - Copyright (C) 2012 Tommi Rantala - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" -#include "offsets.h" - -#ifndef UNW_REMOTE_ONLY - -HIDDEN inline int -arm_local_resume (unw_addr_space_t as, unw_cursor_t *cursor, void *arg) -{ -#ifdef __linux__ - struct cursor *c = (struct cursor *) cursor; - unw_tdep_context_t *uc = c->dwarf.as_arg; - - if (c->sigcontext_format == ARM_SCF_NONE) - { - /* Since there are no signals involved here we restore the non scratch - registers only. */ - unsigned long regs[10]; - regs[0] = uc->regs[4]; - regs[1] = uc->regs[5]; - regs[2] = uc->regs[6]; - regs[3] = uc->regs[7]; - regs[4] = uc->regs[8]; - regs[5] = uc->regs[9]; - regs[6] = uc->regs[10]; - regs[7] = uc->regs[11]; /* FP */ - regs[8] = uc->regs[13]; /* SP */ - regs[9] = uc->regs[14]; /* LR */ - - struct regs_overlay { - char x[sizeof(regs)]; - }; - - asm __volatile__ ( - "ldmia %0, {r4-r12, lr}\n" - "mov sp, r12\n" - "bx lr\n" - : : "r" (regs), - "m" (*(struct regs_overlay *)regs) - ); - } - else - { - /* In case a signal frame is involved, we're using its trampoline which - calls sigreturn. */ - struct sigcontext *sc = (struct sigcontext *) c->sigcontext_addr; - sc->arm_r0 = uc->regs[0]; - sc->arm_r1 = uc->regs[1]; - sc->arm_r2 = uc->regs[2]; - sc->arm_r3 = uc->regs[3]; - sc->arm_r4 = uc->regs[4]; - sc->arm_r5 = uc->regs[5]; - sc->arm_r6 = uc->regs[6]; - sc->arm_r7 = uc->regs[7]; - sc->arm_r8 = uc->regs[8]; - sc->arm_r9 = uc->regs[9]; - sc->arm_r10 = uc->regs[10]; - sc->arm_fp = uc->regs[11]; /* FP */ - sc->arm_ip = uc->regs[12]; /* IP */ - sc->arm_sp = uc->regs[13]; /* SP */ - sc->arm_lr = uc->regs[14]; /* LR */ - sc->arm_pc = uc->regs[15]; /* PC */ - /* clear the ITSTATE bits. */ - sc->arm_cpsr &= 0xf9ff03ffUL; - - /* Set the SP and the PC in order to continue execution at the modified - trampoline which restores the signal mask and the registers. */ - asm __volatile__ ( - "mov sp, %0\n" - "bx %1\n" - : : "r" (c->sigcontext_sp), "r" (c->sigcontext_pc) - ); - } - unreachable(); -#else - printf ("%s: implement me\n", __FUNCTION__); -#endif - return -UNW_EINVAL; -} - -#endif /* !UNW_REMOTE_ONLY */ - -static inline void -establish_machine_state (struct cursor *c) -{ - unw_addr_space_t as = c->dwarf.as; - void *arg = c->dwarf.as_arg; - unw_fpreg_t fpval; - unw_word_t val; - int reg; - - Debug (8, "copying out cursor state\n"); - - for (reg = 0; reg <= UNW_REG_LAST; ++reg) - { - Debug (16, "copying %s %d\n", unw_regname (reg), reg); - if (unw_is_fpreg (reg)) - { - if (tdep_access_fpreg (c, reg, &fpval, 0) >= 0) - as->acc.access_fpreg (as, reg, &fpval, 1, arg); - } - else - { - if (tdep_access_reg (c, reg, &val, 0) >= 0) - as->acc.access_reg (as, reg, &val, 1, arg); - } - } -} - -int -unw_resume (unw_cursor_t *cursor) -{ - struct cursor *c = (struct cursor *) cursor; - - Debug (1, "(cursor=%p)\n", c); - - if (!c->dwarf.ip) - { - /* This can happen easily when the frame-chain gets truncated - due to bad or missing unwind-info. */ - Debug (1, "refusing to resume execution at address 0\n"); - return -UNW_EINVAL; - } - - establish_machine_state (c); - - return (*c->dwarf.as->acc.resume) (c->dwarf.as, (unw_cursor_t *) c, - c->dwarf.as_arg); -} diff --git a/src/pal/src/libunwind/src/arm/Gstash_frame.c b/src/pal/src/libunwind/src/arm/Gstash_frame.c deleted file mode 100644 index c5a76b86d..000000000 --- a/src/pal/src/libunwind/src/arm/Gstash_frame.c +++ /dev/null @@ -1,90 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2010, 2011 by FERMI NATIONAL ACCELERATOR LABORATORY - Copyright (C) 2014 CERN and Aalto University - Contributed by Filip Nyback - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" - -HIDDEN void -tdep_stash_frame (struct dwarf_cursor *d, struct dwarf_reg_state *rs) -{ - struct cursor *c = (struct cursor *) dwarf_to_cursor (d); - unw_tdep_frame_t *f = &c->frame_info; - - Debug (4, "ip=0x%x cfa=0x%x type %d cfa [where=%d val=%d] cfaoff=%d" - " ra=0x%x r7 [where=%d val=%d @0x%x] lr [where=%d val=%d @0x%x] " - "sp [where=%d val=%d @0x%x]\n", - d->ip, d->cfa, f->frame_type, - rs->reg.where[DWARF_CFA_REG_COLUMN], - rs->reg.val[DWARF_CFA_REG_COLUMN], - rs->reg.val[DWARF_CFA_OFF_COLUMN], - DWARF_GET_LOC(d->loc[rs->ret_addr_column]), - rs->reg.where[R7], rs->reg.val[R7], DWARF_GET_LOC(d->loc[R7]), - rs->reg.where[LR], rs->reg.val[LR], DWARF_GET_LOC(d->loc[LR]), - rs->reg.where[SP], rs->reg.val[SP], DWARF_GET_LOC(d->loc[SP])); - - /* A standard frame is defined as: - - CFA is register-relative offset off R7 or SP; - - Return address is saved in LR; - - R7 is unsaved or saved at CFA+offset, offset != -1; - - LR is unsaved or saved at CFA+offset, offset != -1; - - SP is unsaved or saved at CFA+offset, offset != -1. */ - if (f->frame_type == UNW_ARM_FRAME_OTHER - && (rs->reg.where[DWARF_CFA_REG_COLUMN] == DWARF_WHERE_REG) - && (rs->reg.val[DWARF_CFA_REG_COLUMN] == R7 - || rs->reg.val[DWARF_CFA_REG_COLUMN] == SP) - && labs(rs->reg.val[DWARF_CFA_OFF_COLUMN]) < (1 << 29) - && rs->ret_addr_column == LR - && (rs->reg.where[R7] == DWARF_WHERE_UNDEF - || rs->reg.where[R7] == DWARF_WHERE_SAME - || (rs->reg.where[R7] == DWARF_WHERE_CFAREL - && labs(rs->reg.val[R7]) < (1 << 29) - && rs->reg.val[R7]+1 != 0)) - && (rs->reg.where[LR] == DWARF_WHERE_UNDEF - || rs->reg.where[LR] == DWARF_WHERE_SAME - || (rs->reg.where[LR] == DWARF_WHERE_CFAREL - && labs(rs->reg.val[LR]) < (1 << 29) - && rs->reg.val[LR]+1 != 0)) - && (rs->reg.where[SP] == DWARF_WHERE_UNDEF - || rs->reg.where[SP] == DWARF_WHERE_SAME - || (rs->reg.where[SP] == DWARF_WHERE_CFAREL - && labs(rs->reg.val[SP]) < (1 << 29) - && rs->reg.val[SP]+1 != 0))) - { - /* Save information for a standard frame. */ - f->frame_type = UNW_ARM_FRAME_STANDARD; - f->cfa_reg_sp = (rs->reg.val[DWARF_CFA_REG_COLUMN] == SP); - f->cfa_reg_offset = rs->reg.val[DWARF_CFA_OFF_COLUMN]; - if (rs->reg.where[R7] == DWARF_WHERE_CFAREL) - f->r7_cfa_offset = rs->reg.val[R7]; - if (rs->reg.where[LR] == DWARF_WHERE_CFAREL) - f->lr_cfa_offset = rs->reg.val[LR]; - if (rs->reg.where[SP] == DWARF_WHERE_CFAREL) - f->sp_cfa_offset = rs->reg.val[SP]; - Debug (4, " standard frame\n"); - } - else - Debug (4, " unusual frame\n"); -} - diff --git a/src/pal/src/libunwind/src/arm/Gstep.c b/src/pal/src/libunwind/src/arm/Gstep.c deleted file mode 100644 index 516c9f4d1..000000000 --- a/src/pal/src/libunwind/src/arm/Gstep.c +++ /dev/null @@ -1,192 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - Copyright 2011 Linaro Limited - Copyright (C) 2012 Tommi Rantala - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" -#include "offsets.h" -#include "ex_tables.h" - -#include - -#define arm_exidx_step UNW_OBJ(arm_exidx_step) - -static inline int -arm_exidx_step (struct cursor *c) -{ - unw_word_t old_ip, old_cfa; - uint8_t buf[32]; - int ret; - - old_ip = c->dwarf.ip; - old_cfa = c->dwarf.cfa; - - /* mark PC unsaved */ - c->dwarf.loc[UNW_ARM_R15] = DWARF_NULL_LOC; - unw_word_t ip = c->dwarf.ip; - if (c->dwarf.use_prev_instr) - --ip; - - /* check dynamic info first --- it overrides everything else */ - ret = unwi_find_dynamic_proc_info (c->dwarf.as, ip, &c->dwarf.pi, 1, - c->dwarf.as_arg); - if (ret == -UNW_ENOINFO) - { - if ((ret = tdep_find_proc_info (&c->dwarf, ip, 1)) < 0) - return ret; - } - - if (c->dwarf.pi.format != UNW_INFO_FORMAT_ARM_EXIDX) - return -UNW_ENOINFO; - - ret = arm_exidx_extract (&c->dwarf, buf); - if (ret == -UNW_ESTOPUNWIND) - return 0; - else if (ret < 0) - return ret; - - ret = arm_exidx_decode (buf, ret, &c->dwarf); - if (ret < 0) - return ret; - - if (c->dwarf.ip == old_ip && c->dwarf.cfa == old_cfa) - { - Dprintf ("%s: ip and cfa unchanged; stopping here (ip=0x%lx)\n", - __FUNCTION__, (long) c->dwarf.ip); - return -UNW_EBADFRAME; - } - - c->dwarf.pi_valid = 0; - - return (c->dwarf.ip == 0) ? 0 : 1; -} - -int -unw_step (unw_cursor_t *cursor) -{ - struct cursor *c = (struct cursor *) cursor; - int ret = -UNW_EUNSPEC; - - Debug (1, "(cursor=%p)\n", c); - - /* Check if this is a signal frame. */ - if (unw_is_signal_frame (cursor) > 0) - return arm_handle_signal_frame (cursor); - -#ifdef CONFIG_DEBUG_FRAME - /* First, try DWARF-based unwinding. */ - if (UNW_TRY_METHOD(UNW_ARM_METHOD_DWARF)) - { - ret = dwarf_step (&c->dwarf); - Debug(1, "dwarf_step()=%d\n", ret); - - if (likely (ret > 0)) - return 1; - else if (unlikely (ret == -UNW_ESTOPUNWIND)) - return ret; - - if (ret < 0 && ret != -UNW_ENOINFO) - { - Debug (2, "returning %d\n", ret); - return ret; - } - } -#endif /* CONFIG_DEBUG_FRAME */ - - /* Next, try extbl-based unwinding. */ - if (UNW_TRY_METHOD (UNW_ARM_METHOD_EXIDX)) - { - ret = arm_exidx_step (c); - if (ret > 0) - return 1; - if (ret == -UNW_ESTOPUNWIND || ret == 0) - return ret; - } - - /* Fall back on APCS frame parsing. - Note: This won't work in case the ARM EABI is used. */ -#ifdef __FreeBSD__ - if (0) -#else - if (unlikely (ret < 0)) -#endif - { - if (UNW_TRY_METHOD(UNW_ARM_METHOD_FRAME)) - { - Debug (13, "dwarf_step() failed (ret=%d), trying frame-chain\n", ret); - ret = UNW_ESUCCESS; - /* DWARF unwinding failed, try to follow APCS/optimized APCS frame chain */ - unw_word_t instr, i; - dwarf_loc_t ip_loc, fp_loc; - unw_word_t frame; - /* Mark all registers unsaved, since we don't know where - they are saved (if at all), except for the EBP and - EIP. */ - if (dwarf_get(&c->dwarf, c->dwarf.loc[UNW_ARM_R11], &frame) < 0) - { - return 0; - } - for (i = 0; i < DWARF_NUM_PRESERVED_REGS; ++i) { - c->dwarf.loc[i] = DWARF_NULL_LOC; - } - if (frame) - { - if (dwarf_get(&c->dwarf, DWARF_LOC(frame, 0), &instr) < 0) - { - return 0; - } - instr -= 8; - if (dwarf_get(&c->dwarf, DWARF_LOC(instr, 0), &instr) < 0) - { - return 0; - } - if ((instr & 0xFFFFD800) == 0xE92DD800) - { - /* Standard APCS frame. */ - ip_loc = DWARF_LOC(frame - 4, 0); - fp_loc = DWARF_LOC(frame - 12, 0); - } - else - { - /* Codesourcery optimized normal frame. */ - ip_loc = DWARF_LOC(frame, 0); - fp_loc = DWARF_LOC(frame - 4, 0); - } - if (dwarf_get(&c->dwarf, ip_loc, &c->dwarf.ip) < 0) - { - return 0; - } - c->dwarf.loc[UNW_ARM_R12] = ip_loc; - c->dwarf.loc[UNW_ARM_R11] = fp_loc; - c->dwarf.pi_valid = 0; - Debug(15, "ip=%x\n", c->dwarf.ip); - } - else - { - ret = -UNW_ENOINFO; - } - } - } - return ret == -UNW_ENOINFO ? 0 : ret; -} diff --git a/src/pal/src/libunwind/src/arm/Gtrace.c b/src/pal/src/libunwind/src/arm/Gtrace.c deleted file mode 100644 index 2f277520b..000000000 --- a/src/pal/src/libunwind/src/arm/Gtrace.c +++ /dev/null @@ -1,557 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2010, 2011 by FERMI NATIONAL ACCELERATOR LABORATORY - Copyright (C) 2014 CERN and Aalto University - Contributed by Filip Nyback - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" -#include "offsets.h" -#include -#include - -#pragma weak pthread_once -#pragma weak pthread_key_create -#pragma weak pthread_getspecific -#pragma weak pthread_setspecific - -/* Initial hash table size. Table expands by 2 bits (times four). */ -#define HASH_MIN_BITS 14 - -typedef struct -{ - unw_tdep_frame_t *frames; - size_t log_size; - size_t used; - size_t dtor_count; /* Counts how many times our destructor has already - been called. */ -} unw_trace_cache_t; - -static const unw_tdep_frame_t empty_frame = { 0, UNW_ARM_FRAME_OTHER, -1, -1, 0, -1, -1, -1 }; -static define_lock (trace_init_lock); -static pthread_once_t trace_cache_once = PTHREAD_ONCE_INIT; -static sig_atomic_t trace_cache_once_happen; -static pthread_key_t trace_cache_key; -static struct mempool trace_cache_pool; -static __thread unw_trace_cache_t *tls_cache; -static __thread int tls_cache_destroyed; - -/* Free memory for a thread's trace cache. */ -static void -trace_cache_free (void *arg) -{ - unw_trace_cache_t *cache = arg; - if (++cache->dtor_count < PTHREAD_DESTRUCTOR_ITERATIONS) - { - /* Not yet our turn to get destroyed. Re-install ourselves into the key. */ - pthread_setspecific(trace_cache_key, cache); - Debug(5, "delayed freeing cache %p (%zx to go)\n", cache, - PTHREAD_DESTRUCTOR_ITERATIONS - cache->dtor_count); - return; - } - tls_cache_destroyed = 1; - tls_cache = NULL; - munmap (cache->frames, (1u << cache->log_size) * sizeof(unw_tdep_frame_t)); - mempool_free (&trace_cache_pool, cache); - Debug(5, "freed cache %p\n", cache); -} - -/* Initialise frame tracing for threaded use. */ -static void -trace_cache_init_once (void) -{ - pthread_key_create (&trace_cache_key, &trace_cache_free); - mempool_init (&trace_cache_pool, sizeof (unw_trace_cache_t), 0); - trace_cache_once_happen = 1; -} - -static unw_tdep_frame_t * -trace_cache_buckets (size_t n) -{ - unw_tdep_frame_t *frames; - size_t i; - - GET_MEMORY(frames, n * sizeof (unw_tdep_frame_t)); - if (likely(frames != NULL)) - for (i = 0; i < n; ++i) - frames[i] = empty_frame; - - return frames; -} - -/* Allocate and initialise hash table for frame cache lookups. - Returns the cache initialised with (1u << HASH_LOW_BITS) hash - buckets, or NULL if there was a memory allocation problem. */ -static unw_trace_cache_t * -trace_cache_create (void) -{ - unw_trace_cache_t *cache; - - if (tls_cache_destroyed) - { - /* The current thread is in the process of exiting. Don't recreate - cache, as we wouldn't have another chance to free it. */ - Debug(5, "refusing to reallocate cache: " - "thread-locals are being deallocated\n"); - return NULL; - } - - if (! (cache = mempool_alloc(&trace_cache_pool))) - { - Debug(5, "failed to allocate cache\n"); - return NULL; - } - - if (! (cache->frames = trace_cache_buckets(1u << HASH_MIN_BITS))) - { - Debug(5, "failed to allocate buckets\n"); - mempool_free(&trace_cache_pool, cache); - return NULL; - } - - cache->log_size = HASH_MIN_BITS; - cache->used = 0; - cache->dtor_count = 0; - tls_cache_destroyed = 0; /* Paranoia: should already be 0. */ - Debug(5, "allocated cache %p\n", cache); - return cache; -} - -/* Expand the hash table in the frame cache if possible. This always - quadruples the hash size, and clears all previous frame entries. */ -static int -trace_cache_expand (unw_trace_cache_t *cache) -{ - size_t old_size = (1u << cache->log_size); - size_t new_log_size = cache->log_size + 2; - unw_tdep_frame_t *new_frames = trace_cache_buckets (1u << new_log_size); - - if (unlikely(! new_frames)) - { - Debug(5, "failed to expand cache to 2^%u buckets\n", new_log_size); - return -UNW_ENOMEM; - } - - Debug(5, "expanded cache from 2^%u to 2^%u buckets\n", cache->log_size, - new_log_size); - munmap(cache->frames, old_size * sizeof(unw_tdep_frame_t)); - cache->frames = new_frames; - cache->log_size = new_log_size; - cache->used = 0; - return 0; -} - -static unw_trace_cache_t * -trace_cache_get_unthreaded (void) -{ - unw_trace_cache_t *cache; - intrmask_t saved_mask; - static unw_trace_cache_t *global_cache = NULL; - lock_acquire (&trace_init_lock, saved_mask); - if (! global_cache) - { - mempool_init (&trace_cache_pool, sizeof (unw_trace_cache_t), 0); - global_cache = trace_cache_create (); - } - cache = global_cache; - lock_release (&trace_init_lock, saved_mask); - Debug(5, "using cache %p\n", cache); - return cache; -} - -/* Get the frame cache for the current thread. Create it if there is none. */ -static unw_trace_cache_t * -trace_cache_get (void) -{ - unw_trace_cache_t *cache; - if (likely (pthread_once != NULL)) - { - pthread_once(&trace_cache_once, &trace_cache_init_once); - if (!trace_cache_once_happen) - { - return trace_cache_get_unthreaded(); - } - if (! (cache = tls_cache)) - { - cache = trace_cache_create(); - pthread_setspecific(trace_cache_key, cache); - tls_cache = cache; - } - Debug(5, "using cache %p\n", cache); - return cache; - } - else - { - return trace_cache_get_unthreaded(); - } -} - -/* Initialise frame properties for address cache slot F at address - PC using current CFA, R7 and SP values. Modifies CURSOR to - that location, performs one unw_step(), and fills F with what - was discovered about the location. Returns F. - - FIXME: This probably should tell DWARF handling to never evaluate - or use registers other than R7, SP and PC in case there is - highly unusual unwind info which uses these creatively. */ -static unw_tdep_frame_t * -trace_init_addr (unw_tdep_frame_t *f, - unw_cursor_t *cursor, - unw_word_t cfa, - unw_word_t pc, - unw_word_t r7, - unw_word_t sp) -{ - struct cursor *c = (struct cursor *) cursor; - struct dwarf_cursor *d = &c->dwarf; - int ret = -UNW_EINVAL; - - /* Initialise frame properties: unknown, not last. */ - f->virtual_address = pc; - f->frame_type = UNW_ARM_FRAME_OTHER; - f->last_frame = 0; - f->cfa_reg_sp = -1; - f->cfa_reg_offset = 0; - f->r7_cfa_offset = -1; - f->lr_cfa_offset = -1; - f->sp_cfa_offset = -1; - - /* Reinitialise cursor to this instruction - but undo next/prev RIP - adjustment because unw_step will redo it - and force PC, R7 and - SP into register locations (=~ ucontext we keep), then set - their desired values. Then perform the step. */ - d->ip = pc + d->use_prev_instr; - d->cfa = cfa; - d->loc[UNW_ARM_R7] = DWARF_REG_LOC (d, UNW_ARM_R7); - d->loc[UNW_ARM_R13] = DWARF_REG_LOC (d, UNW_ARM_R13); - d->loc[UNW_ARM_R15] = DWARF_REG_LOC (d, UNW_ARM_R15); - c->frame_info = *f; - - if (likely(dwarf_put (d, d->loc[UNW_ARM_R7], r7) >= 0) - && likely(dwarf_put (d, d->loc[UNW_ARM_R13], sp) >= 0) - && likely(dwarf_put (d, d->loc[UNW_ARM_R15], pc) >= 0) - && likely((ret = unw_step (cursor)) >= 0)) - *f = c->frame_info; - - /* If unw_step() stopped voluntarily, remember that, even if it - otherwise could not determine anything useful. This avoids - failing trace if we hit frames without unwind info, which is - common for the outermost frame (CRT stuff) on many systems. - This avoids failing trace in very common circumstances; failing - to unw_step() loop wouldn't produce any better result. */ - if (ret == 0) - f->last_frame = -1; - - Debug (3, "frame va %x type %d last %d cfa %s+%d r7 @ cfa%+d lr @ cfa%+d sp @ cfa%+d\n", - f->virtual_address, f->frame_type, f->last_frame, - f->cfa_reg_sp ? "sp" : "r7", f->cfa_reg_offset, - f->r7_cfa_offset, f->lr_cfa_offset, f->sp_cfa_offset); - - return f; -} - -/* Look up and if necessary fill in frame attributes for address PC - in CACHE using current CFA, R7 and SP values. Uses CURSOR to - perform any unwind steps necessary to fill the cache. Returns the - frame cache slot which describes RIP. */ -static unw_tdep_frame_t * -trace_lookup (unw_cursor_t *cursor, - unw_trace_cache_t *cache, - unw_word_t cfa, - unw_word_t pc, - unw_word_t r7, - unw_word_t sp) -{ - /* First look up for previously cached information using cache as - linear probing hash table with probe step of 1. Majority of - lookups should be completed within few steps, but it is very - important the hash table does not fill up, or performance falls - off the cliff. */ - uint32_t i, addr; - uint32_t cache_size = 1u << cache->log_size; - uint32_t slot = ((pc * 0x9e3779b9) >> 11) & (cache_size-1); - unw_tdep_frame_t *frame; - - for (i = 0; i < 16; ++i) - { - frame = &cache->frames[slot]; - addr = frame->virtual_address; - - /* Return if we found the address. */ - if (likely(addr == pc)) - { - Debug (4, "found address after %d steps\n", i); - return frame; - } - - /* If slot is empty, reuse it. */ - if (likely(! addr)) - break; - - /* Linear probe to next slot candidate, step = 1. */ - if (++slot >= cache_size) - slot -= cache_size; - } - - /* If we collided after 16 steps, or if the hash is more than half - full, force the hash to expand. Fill the selected slot, whether - it's free or collides. Note that hash expansion drops previous - contents; further lookups will refill the hash. */ - Debug (4, "updating slot %u after %d steps, replacing 0x%x\n", slot, i, addr); - if (unlikely(addr || cache->used >= cache_size / 2)) - { - if (unlikely(trace_cache_expand (cache) < 0)) - return NULL; - - cache_size = 1u << cache->log_size; - slot = ((pc * 0x9e3779b9) >> 11) & (cache_size-1); - frame = &cache->frames[slot]; - addr = frame->virtual_address; - } - - if (! addr) - ++cache->used; - - return trace_init_addr (frame, cursor, cfa, pc, r7, sp); -} - -/* Fast stack backtrace for ARM. - - This is used by backtrace() implementation to accelerate frequent - queries for current stack, without any desire to unwind. It fills - BUFFER with the call tree from CURSOR upwards for at most SIZE - stack levels. The first frame, backtrace itself, is omitted. When - called, SIZE should give the maximum number of entries that can be - stored into BUFFER. Uses an internal thread-specific cache to - accelerate queries. - - The caller should fall back to a unw_step() loop if this function - fails by returning -UNW_ESTOPUNWIND, meaning the routine hit a - stack frame that is too complex to be traced in the fast path. - - This function is tuned for clients which only need to walk the - stack to get the call tree as fast as possible but without any - other details, for example profilers sampling the stack thousands - to millions of times per second. The routine handles the most - common ARM ABI stack layouts: CFA is R7 or SP plus/minus - constant offset, return address is in LR, and R7, LR and SP are - either unchanged or saved on stack at constant offset from the CFA; - the signal return frame; and frames without unwind info provided - they are at the outermost (final) frame or can conservatively be - assumed to be frame-pointer based. - - Any other stack layout will cause the routine to give up. There - are only a handful of relatively rarely used functions which do - not have a stack in the standard form: vfork, longjmp, setcontext - and _dl_runtime_profile on common linux systems for example. - - On success BUFFER and *SIZE reflect the trace progress up to *SIZE - stack levels or the outermost frame, which ever is less. It may - stop short of outermost frame if unw_step() loop would also do so, - e.g. if there is no more unwind information; this is not reported - as an error. - - The function returns a negative value for errors, -UNW_ESTOPUNWIND - if tracing stopped because of an unusual frame unwind info. The - BUFFER and *SIZE reflect tracing progress up to the error frame. - - Callers of this function would normally look like this: - - unw_cursor_t cur; - unw_context_t ctx; - void addrs[128]; - int depth = 128; - int ret; - - unw_getcontext(&ctx); - unw_init_local(&cur, &ctx); - if ((ret = unw_tdep_trace(&cur, addrs, &depth)) < 0) - { - depth = 0; - unw_getcontext(&ctx); - unw_init_local(&cur, &ctx); - while ((ret = unw_step(&cur)) > 0 && depth < 128) - { - unw_word_t ip; - unw_get_reg(&cur, UNW_REG_IP, &ip); - addresses[depth++] = (void *) ip; - } - } -*/ -HIDDEN int -tdep_trace (unw_cursor_t *cursor, void **buffer, int *size) -{ - struct cursor *c = (struct cursor *) cursor; - struct dwarf_cursor *d = &c->dwarf; - unw_trace_cache_t *cache; - unw_word_t sp, pc, cfa, r7, lr; - int maxdepth = 0; - int depth = 0; - int ret; - - /* Check input parametres. */ - if (unlikely(! cursor || ! buffer || ! size || (maxdepth = *size) <= 0)) - return -UNW_EINVAL; - - Debug (1, "begin ip 0x%x cfa 0x%x\n", d->ip, d->cfa); - - /* Tell core dwarf routines to call back to us. */ - d->stash_frames = 1; - - /* Determine initial register values. These are direct access safe - because we know they come from the initial machine context. */ - pc = d->ip; - sp = cfa = d->cfa; - ACCESS_MEM_FAST(ret, 0, d, DWARF_GET_LOC(d->loc[UNW_ARM_R7]), r7); - assert(ret == 0); - lr = 0; - - /* Get frame cache. */ - if (unlikely(! (cache = trace_cache_get()))) - { - Debug (1, "returning %d, cannot get trace cache\n", -UNW_ENOMEM); - *size = 0; - d->stash_frames = 0; - return -UNW_ENOMEM; - } - - /* Trace the stack upwards, starting from current PC. Adjust - the PC address for previous/next instruction as the main - unwinding logic would also do. We undo this before calling - back into unw_step(). */ - while (depth < maxdepth) - { - pc -= d->use_prev_instr; - Debug (2, "depth %d cfa 0x%x pc 0x%x sp 0x%x r7 0x%x\n", - depth, cfa, pc, sp, r7); - - /* See if we have this address cached. If not, evaluate enough of - the dwarf unwind information to fill the cache line data, or to - decide this frame cannot be handled in fast trace mode. We - cache negative results too to prevent unnecessary dwarf parsing - for common failures. */ - unw_tdep_frame_t *f = trace_lookup (cursor, cache, cfa, pc, r7, sp); - - /* If we don't have information for this frame, give up. */ - if (unlikely(! f)) - { - ret = -UNW_ENOINFO; - break; - } - - Debug (3, "frame va %x type %d last %d cfa %s+%d r7 @ cfa%+d lr @ cfa%+d sp @ cfa%+d\n", - f->virtual_address, f->frame_type, f->last_frame, - f->cfa_reg_sp ? "sp" : "r7", f->cfa_reg_offset, - f->r7_cfa_offset, f->lr_cfa_offset, f->sp_cfa_offset); - - assert (f->virtual_address == pc); - - /* Stop if this was the last frame. In particular don't evaluate - new register values as it may not be safe - we don't normally - run with full validation on, and do not want to - and there's - enough bad unwind info floating around that we need to trust - what unw_step() previously said, in potentially bogus frames. */ - if (f->last_frame) - break; - - /* Evaluate CFA and registers for the next frame. */ - switch (f->frame_type) - { - case UNW_ARM_FRAME_GUESSED: - /* Fall thru to standard processing after forcing validation. */ - c->validate = 1; - - case UNW_ARM_FRAME_STANDARD: - /* Advance standard traceable frame. */ - cfa = (f->cfa_reg_sp ? sp : r7) + f->cfa_reg_offset; - if (likely(f->lr_cfa_offset != -1)) - ACCESS_MEM_FAST(ret, c->validate, d, cfa + f->lr_cfa_offset, pc); - else if (lr != 0) - { - /* Use the saved link register as the new pc. */ - pc = lr; - lr = 0; - } - if (likely(ret >= 0) && likely(f->r7_cfa_offset != -1)) - ACCESS_MEM_FAST(ret, c->validate, d, cfa + f->r7_cfa_offset, r7); - - /* Don't bother reading SP from DWARF, CFA becomes new SP. */ - sp = cfa; - - /* Next frame needs to back up for unwind info lookup. */ - d->use_prev_instr = 1; - break; - - case UNW_ARM_FRAME_SIGRETURN: - cfa = cfa + f->cfa_reg_offset; /* cfa now points to ucontext_t. */ -#if defined(__linux__) - ACCESS_MEM_FAST(ret, c->validate, d, cfa + LINUX_SC_PC_OFF, pc); - if (likely(ret >= 0)) - ACCESS_MEM_FAST(ret, c->validate, d, cfa + LINUX_SC_R7_OFF, r7); - if (likely(ret >= 0)) - ACCESS_MEM_FAST(ret, c->validate, d, cfa + LINUX_SC_SP_OFF, sp); - /* Save the link register here in case we end up in a function that - doesn't save the link register in the prologue, e.g. kill. */ - if (likely(ret >= 0)) - ACCESS_MEM_FAST(ret, c->validate, d, cfa + LINUX_SC_LR_OFF, lr); -#elif defined(__FreeBSD__) - printf("XXX\n"); -#endif - - /* Resume stack at signal restoration point. The stack is not - necessarily continuous here, especially with sigaltstack(). */ - cfa = sp; - - /* Next frame should not back up. */ - d->use_prev_instr = 0; - break; - - case UNW_ARM_FRAME_SYSCALL: - printf("XXX1\n"); - break; - - default: - /* We cannot trace through this frame, give up and tell the - caller we had to stop. Data collected so far may still be - useful to the caller, so let it know how far we got. */ - ret = -UNW_ESTOPUNWIND; - break; - } - - Debug (4, "new cfa 0x%x pc 0x%x sp 0x%x r7 0x%x\n", - cfa, pc, sp, r7); - - /* If we failed or ended up somewhere bogus, stop. */ - if (unlikely(ret < 0 || pc < 0x4000)) - break; - - /* Record this address in stack trace. We skipped the first address. */ - buffer[depth++] = (void *) (pc - d->use_prev_instr); - } - -#if UNW_DEBUG - Debug (1, "returning %d, depth %d\n", ret, depth); -#endif - *size = depth; - return ret; -} - diff --git a/src/pal/src/libunwind/src/arm/Lapply_reg_state.c b/src/pal/src/libunwind/src/arm/Lapply_reg_state.c deleted file mode 100644 index 7ebada480..000000000 --- a/src/pal/src/libunwind/src/arm/Lapply_reg_state.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gapply_reg_state.c" -#endif diff --git a/src/pal/src/libunwind/src/arm/Lcreate_addr_space.c b/src/pal/src/libunwind/src/arm/Lcreate_addr_space.c deleted file mode 100644 index 0f2dc6be9..000000000 --- a/src/pal/src/libunwind/src/arm/Lcreate_addr_space.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gcreate_addr_space.c" -#endif diff --git a/src/pal/src/libunwind/src/arm/Lex_tables.c b/src/pal/src/libunwind/src/arm/Lex_tables.c deleted file mode 100644 index 4a4f925c9..000000000 --- a/src/pal/src/libunwind/src/arm/Lex_tables.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gex_tables.c" -#endif diff --git a/src/pal/src/libunwind/src/arm/Lget_proc_info.c b/src/pal/src/libunwind/src/arm/Lget_proc_info.c deleted file mode 100644 index 69028b019..000000000 --- a/src/pal/src/libunwind/src/arm/Lget_proc_info.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gget_proc_info.c" -#endif diff --git a/src/pal/src/libunwind/src/arm/Lget_save_loc.c b/src/pal/src/libunwind/src/arm/Lget_save_loc.c deleted file mode 100644 index 9ea048a90..000000000 --- a/src/pal/src/libunwind/src/arm/Lget_save_loc.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gget_save_loc.c" -#endif diff --git a/src/pal/src/libunwind/src/arm/Lglobal.c b/src/pal/src/libunwind/src/arm/Lglobal.c deleted file mode 100644 index 6d7b489e1..000000000 --- a/src/pal/src/libunwind/src/arm/Lglobal.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gglobal.c" -#endif diff --git a/src/pal/src/libunwind/src/arm/Linit.c b/src/pal/src/libunwind/src/arm/Linit.c deleted file mode 100644 index e9abfdd46..000000000 --- a/src/pal/src/libunwind/src/arm/Linit.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Ginit.c" -#endif diff --git a/src/pal/src/libunwind/src/arm/Linit_local.c b/src/pal/src/libunwind/src/arm/Linit_local.c deleted file mode 100644 index 68a1687e8..000000000 --- a/src/pal/src/libunwind/src/arm/Linit_local.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Ginit_local.c" -#endif diff --git a/src/pal/src/libunwind/src/arm/Linit_remote.c b/src/pal/src/libunwind/src/arm/Linit_remote.c deleted file mode 100644 index 58cb04ab7..000000000 --- a/src/pal/src/libunwind/src/arm/Linit_remote.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Ginit_remote.c" -#endif diff --git a/src/pal/src/libunwind/src/arm/Lis_signal_frame.c b/src/pal/src/libunwind/src/arm/Lis_signal_frame.c deleted file mode 100644 index b9a7c4f51..000000000 --- a/src/pal/src/libunwind/src/arm/Lis_signal_frame.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gis_signal_frame.c" -#endif diff --git a/src/pal/src/libunwind/src/arm/Los-freebsd.c b/src/pal/src/libunwind/src/arm/Los-freebsd.c deleted file mode 100644 index a75a205df..000000000 --- a/src/pal/src/libunwind/src/arm/Los-freebsd.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gos-freebsd.c" -#endif diff --git a/src/pal/src/libunwind/src/arm/Los-linux.c b/src/pal/src/libunwind/src/arm/Los-linux.c deleted file mode 100644 index 3cc18aabc..000000000 --- a/src/pal/src/libunwind/src/arm/Los-linux.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gos-linux.c" -#endif diff --git a/src/pal/src/libunwind/src/arm/Los-other.c b/src/pal/src/libunwind/src/arm/Los-other.c deleted file mode 100644 index a75a205df..000000000 --- a/src/pal/src/libunwind/src/arm/Los-other.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gos-freebsd.c" -#endif diff --git a/src/pal/src/libunwind/src/arm/Lreg_states_iterate.c b/src/pal/src/libunwind/src/arm/Lreg_states_iterate.c deleted file mode 100644 index f1eb1e79d..000000000 --- a/src/pal/src/libunwind/src/arm/Lreg_states_iterate.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Greg_states_iterate.c" -#endif diff --git a/src/pal/src/libunwind/src/arm/Lregs.c b/src/pal/src/libunwind/src/arm/Lregs.c deleted file mode 100644 index 2c9c75cd7..000000000 --- a/src/pal/src/libunwind/src/arm/Lregs.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gregs.c" -#endif diff --git a/src/pal/src/libunwind/src/arm/Lresume.c b/src/pal/src/libunwind/src/arm/Lresume.c deleted file mode 100644 index 41a8cf003..000000000 --- a/src/pal/src/libunwind/src/arm/Lresume.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gresume.c" -#endif diff --git a/src/pal/src/libunwind/src/arm/Lstash_frame.c b/src/pal/src/libunwind/src/arm/Lstash_frame.c deleted file mode 100644 index 77587803d..000000000 --- a/src/pal/src/libunwind/src/arm/Lstash_frame.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gstash_frame.c" -#endif diff --git a/src/pal/src/libunwind/src/arm/Lstep.c b/src/pal/src/libunwind/src/arm/Lstep.c deleted file mode 100644 index c1ac3c754..000000000 --- a/src/pal/src/libunwind/src/arm/Lstep.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gstep.c" -#endif diff --git a/src/pal/src/libunwind/src/arm/Ltrace.c b/src/pal/src/libunwind/src/arm/Ltrace.c deleted file mode 100644 index 24b7b3cfa..000000000 --- a/src/pal/src/libunwind/src/arm/Ltrace.c +++ /dev/null @@ -1,6 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gtrace.c" -#endif - diff --git a/src/pal/src/libunwind/src/arm/gen-offsets.c b/src/pal/src/libunwind/src/arm/gen-offsets.c deleted file mode 100644 index 7d6bf2f1c..000000000 --- a/src/pal/src/libunwind/src/arm/gen-offsets.c +++ /dev/null @@ -1,54 +0,0 @@ -#include -#include -#include -#include - -#define UC(N,X) \ - printf ("#define LINUX_UC_" N "_OFF\t0x%X\n", offsetof (ucontext_t, X)) - -#define SC(N,X) \ - printf ("#define LINUX_SC_" N "_OFF\t0x%X\n", offsetof (struct sigcontext, X)) - -int -main (void) -{ - printf ( -"/* Linux-specific definitions: */\n\n" - -"/* Define various structure offsets to simplify cross-compilation. */\n\n" - -"/* Offsets for ARM Linux \"ucontext_t\": */\n\n"); - - UC ("FLAGS", uc_flags); - UC ("LINK", uc_link); - UC ("STACK", uc_stack); - UC ("MCONTEXT", uc_mcontext); - UC ("SIGMASK", uc_sigmask); - UC ("REGSPACE", uc_regspace); - - printf ("\n/* Offsets for ARM Linux \"struct sigcontext\": */\n\n"); - - SC ("TRAPNO", trap_no); - SC ("ERRORCODE", error_code); - SC ("OLDMASK", oldmask); - SC ("R0", arm_r0); - SC ("R1", arm_r1); - SC ("R2", arm_r2); - SC ("R3", arm_r3); - SC ("R4", arm_r4); - SC ("R5", arm_r5); - SC ("R6", arm_r6); - SC ("R7", arm_r7); - SC ("R8", arm_r8); - SC ("R9", arm_r9); - SC ("R10", arm_r10); - SC ("FP", arm_fp); - SC ("IP", arm_ip); - SC ("SP", arm_sp); - SC ("LR", arm_lr); - SC ("PC", arm_pc); - SC ("CPSR", arm_cpsr); - SC ("FAULTADDR", fault_address); - - return 0; -} diff --git a/src/pal/src/libunwind/src/arm/getcontext.S b/src/pal/src/libunwind/src/arm/getcontext.S deleted file mode 100644 index 7e1878447..000000000 --- a/src/pal/src/libunwind/src/arm/getcontext.S +++ /dev/null @@ -1,63 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - -This file is part of libunwind. - -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. */ - -#include "offsets.h" - - .text - .arm - - .global _Uarm_getcontext - .type _Uarm_getcontext, %function - @ This is a stub version of getcontext() for ARM which only stores core - @ registers. It must be called in a special way, not as a regular - @ function -- see also the libunwind-arm.h:unw_tdep_getcontext macro. -_Uarm_getcontext: - stmfd sp!, {r0, r1} - @ store r0 -#if defined(__linux__) - str r0, [r0, #LINUX_UC_MCONTEXT_OFF + LINUX_SC_R0_OFF] - add r0, r0, #LINUX_UC_MCONTEXT_OFF + LINUX_SC_R0_OFF -#elif defined(__FreeBSD__) - str r0, [r0, #FREEBSD_UC_MCONTEXT_OFF + FREEBSD_MC_R0_OFF] - add r0, r0, #FREEBSD_UC_MCONTEXT_OFF + FREEBSD_MC_R0_OFF -#else -#error Fix me -#endif - @ store r1 to r12 - stmib r0, {r1-r12} - @ reconstruct r13 at call site, then store - add r1, sp, #12 - str r1, [r0, #13 * 4] - @ retrieve r14 from call site, then store - ldr r1, [sp, #8] - str r1, [r0, #14 * 4] - @ point lr to instruction after call site's stack adjustment - add r1, lr, #4 - str r1, [r0, #15 * 4] - ldmfd sp!, {r0, r1} - bx lr -#if defined(__linux__) || defined(__FreeBSD__) - /* We do not need executable stack. */ - .section .note.GNU-stack,"",%progbits -#endif diff --git a/src/pal/src/libunwind/src/arm/init.h b/src/pal/src/libunwind/src/arm/init.h deleted file mode 100644 index 7d765ecf0..000000000 --- a/src/pal/src/libunwind/src/arm/init.h +++ /dev/null @@ -1,77 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" - -static inline int -common_init (struct cursor *c, unsigned use_prev_instr) -{ - int ret, i; - - c->dwarf.loc[UNW_ARM_R0] = DWARF_REG_LOC (&c->dwarf, UNW_ARM_R0); - c->dwarf.loc[UNW_ARM_R1] = DWARF_REG_LOC (&c->dwarf, UNW_ARM_R1); - c->dwarf.loc[UNW_ARM_R2] = DWARF_REG_LOC (&c->dwarf, UNW_ARM_R2); - c->dwarf.loc[UNW_ARM_R3] = DWARF_REG_LOC (&c->dwarf, UNW_ARM_R3); - c->dwarf.loc[UNW_ARM_R4] = DWARF_REG_LOC (&c->dwarf, UNW_ARM_R4); - c->dwarf.loc[UNW_ARM_R5] = DWARF_REG_LOC (&c->dwarf, UNW_ARM_R5); - c->dwarf.loc[UNW_ARM_R6] = DWARF_REG_LOC (&c->dwarf, UNW_ARM_R6); - c->dwarf.loc[UNW_ARM_R7] = DWARF_REG_LOC (&c->dwarf, UNW_ARM_R7); - c->dwarf.loc[UNW_ARM_R8] = DWARF_REG_LOC (&c->dwarf, UNW_ARM_R8); - c->dwarf.loc[UNW_ARM_R9] = DWARF_REG_LOC (&c->dwarf, UNW_ARM_R9); - c->dwarf.loc[UNW_ARM_R10] = DWARF_REG_LOC (&c->dwarf, UNW_ARM_R10); - c->dwarf.loc[UNW_ARM_R11] = DWARF_REG_LOC (&c->dwarf, UNW_ARM_R11); - c->dwarf.loc[UNW_ARM_R12] = DWARF_REG_LOC (&c->dwarf, UNW_ARM_R12); - c->dwarf.loc[UNW_ARM_R13] = DWARF_REG_LOC (&c->dwarf, UNW_ARM_R13); - c->dwarf.loc[UNW_ARM_R14] = DWARF_REG_LOC (&c->dwarf, UNW_ARM_R14); - c->dwarf.loc[UNW_ARM_R15] = DWARF_REG_LOC (&c->dwarf, UNW_ARM_R15); - for (i = UNW_ARM_R15 + 1; i < DWARF_NUM_PRESERVED_REGS; ++i) - c->dwarf.loc[i] = DWARF_NULL_LOC; - - ret = dwarf_get (&c->dwarf, c->dwarf.loc[UNW_ARM_R15], &c->dwarf.ip); - if (ret < 0) - return ret; - - /* FIXME: correct for ARM? */ - ret = dwarf_get (&c->dwarf, DWARF_REG_LOC (&c->dwarf, UNW_ARM_R13), - &c->dwarf.cfa); - if (ret < 0) - return ret; - - c->sigcontext_format = ARM_SCF_NONE; - c->sigcontext_addr = 0; - c->sigcontext_sp = 0; - c->sigcontext_pc = 0; - - /* FIXME: Initialisation for other registers. */ - - c->dwarf.args_size = 0; - c->dwarf.stash_frames = 0; - c->dwarf.use_prev_instr = use_prev_instr; - c->dwarf.pi_valid = 0; - c->dwarf.pi_is_dynamic = 0; - c->dwarf.hint = 0; - c->dwarf.prev_rs = 0; - - return 0; -} diff --git a/src/pal/src/libunwind/src/arm/is_fpreg.c b/src/pal/src/libunwind/src/arm/is_fpreg.c deleted file mode 100644 index e55bcff03..000000000 --- a/src/pal/src/libunwind/src/arm/is_fpreg.c +++ /dev/null @@ -1,39 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - -This file is part of libunwind. - -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. */ - -#include "libunwind_i.h" - -/* FIXME: I'm not sure if libunwind's GP/FP register distinction is very useful - on ARM. Count all the FP or coprocessor registers we know about for now. */ - -int -unw_is_fpreg (int regnum) -{ - return ((regnum >= UNW_ARM_S0 && regnum <= UNW_ARM_S31) - || (regnum >= UNW_ARM_F0 && regnum <= UNW_ARM_F7) - || (regnum >= UNW_ARM_wCGR0 && regnum <= UNW_ARM_wCGR7) - || (regnum >= UNW_ARM_wR0 && regnum <= UNW_ARM_wR15) - || (regnum >= UNW_ARM_wC0 && regnum <= UNW_ARM_wC7) - || (regnum >= UNW_ARM_D0 && regnum <= UNW_ARM_D31)); -} diff --git a/src/pal/src/libunwind/src/arm/offsets.h b/src/pal/src/libunwind/src/arm/offsets.h deleted file mode 100644 index 621701106..000000000 --- a/src/pal/src/libunwind/src/arm/offsets.h +++ /dev/null @@ -1,42 +0,0 @@ -/* Linux-specific definitions: */ - -/* Define various structure offsets to simplify cross-compilation. */ - -/* Offsets for ARM Linux "ucontext_t": */ - -#define LINUX_UC_FLAGS_OFF 0x00 -#define LINUX_UC_LINK_OFF 0x04 -#define LINUX_UC_STACK_OFF 0x08 -#define LINUX_UC_MCONTEXT_OFF 0x14 -#define LINUX_UC_SIGMASK_OFF 0x68 -#define LINUX_UC_REGSPACE_OFF 0xE8 - -/* Offsets for ARM Linux "struct sigcontext": */ - -#define LINUX_SC_TRAPNO_OFF 0x00 -#define LINUX_SC_ERRORCODE_OFF 0x04 -#define LINUX_SC_OLDMASK_OFF 0x08 -#define LINUX_SC_R0_OFF 0x0C -#define LINUX_SC_R1_OFF 0x10 -#define LINUX_SC_R2_OFF 0x14 -#define LINUX_SC_R3_OFF 0x18 -#define LINUX_SC_R4_OFF 0x1C -#define LINUX_SC_R5_OFF 0x20 -#define LINUX_SC_R6_OFF 0x24 -#define LINUX_SC_R7_OFF 0x28 -#define LINUX_SC_R8_OFF 0x2C -#define LINUX_SC_R9_OFF 0x30 -#define LINUX_SC_R10_OFF 0x34 -#define LINUX_SC_FP_OFF 0x38 -#define LINUX_SC_IP_OFF 0x3C -#define LINUX_SC_SP_OFF 0x40 -#define LINUX_SC_LR_OFF 0x44 -#define LINUX_SC_PC_OFF 0x48 -#define LINUX_SC_CPSR_OFF 0x4C -#define LINUX_SC_FAULTADDR_OFF 0x50 - -/* FreeBSD-specific definitions: */ - -#define FREEBSD_SC_UCONTEXT_OFF 0x40 -#define FREEBSD_UC_MCONTEXT_OFF 0x10 -#define FREEBSD_MC_R0_OFF 0 diff --git a/src/pal/src/libunwind/src/arm/regname.c b/src/pal/src/libunwind/src/arm/regname.c deleted file mode 100644 index 7cac630c1..000000000 --- a/src/pal/src/libunwind/src/arm/regname.c +++ /dev/null @@ -1,90 +0,0 @@ -#include "unwind_i.h" - -static const char *regname[] = - { - /* 0. */ - "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", - /* 8. */ - "r8", "r9", "r10", "fp", "ip", "sp", "lr", "pc", - /* 16. Obsolete FPA names. */ - "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", - /* 24. */ - 0, 0, 0, 0, 0, 0, 0, 0, - /* 32. */ - 0, 0, 0, 0, 0, 0, 0, 0, - /* 40. */ - 0, 0, 0, 0, 0, 0, 0, 0, - /* 48. */ - 0, 0, 0, 0, 0, 0, 0, 0, - /* 56. */ - 0, 0, 0, 0, 0, 0, 0, 0, - /* 64. */ - "s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7", - /* 72. */ - "s8", "s9", "s10", "s11", "s12", "s13", "s14", "s15", - /* 80. */ - "s16", "s17", "s18", "s19", "s20", "s21", "s22", "s23", - /* 88. */ - "s24", "s25", "s26", "s27", "s28", "s29", "s30", "s31", - /* 96. */ - "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", - /* 104. */ - "wCGR0", "wCGR1", "wCGR2", "wCGR3", "wCGR4", "wCGR5", "wCGR6", "wCGR7", - /* 112. */ - "wR0", "wR1", "wR2", "wR3", "wR4", "wR5", "wR6", "wR7", - /* 128. */ - "spsr", "spsr_fiq", "spsr_irq", "spsr_abt", "spsr_und", "spsr_svc", 0, 0, - /* 136. */ - 0, 0, 0, 0, 0, 0, 0, 0, - /* 144. */ - "r8_usr", "r9_usr", "r10_usr", "r11_usr", "r12_usr", "r13_usr", "r14_usr", - /* 151. */ - "r8_fiq", "r9_fiq", "r10_fiq", "r11_fiq", "r12_fiq", "r13_fiq", "r14_fiq", - /* 158. */ - "r13_irq", "r14_irq", - /* 160. */ - "r13_abt", "r14_abt", - /* 162. */ - "r13_und", "r14_und", - /* 164. */ - "r13_svc", "r14_svc", 0, 0, - /* 168. */ - 0, 0, 0, 0, 0, 0, 0, 0, - /* 176. */ - 0, 0, 0, 0, 0, 0, 0, 0, - /* 184. */ - 0, 0, 0, 0, 0, 0, 0, 0, - /* 192. */ - "wC0", "wC1", "wC2", "wC3", "wC4", "wC5", "wC6", "wC7", - /* 200. */ - 0, 0, 0, 0, 0, 0, 0, 0, - /* 208. */ - 0, 0, 0, 0, 0, 0, 0, 0, - /* 216. */ - 0, 0, 0, 0, 0, 0, 0, 0, - /* 224. */ - 0, 0, 0, 0, 0, 0, 0, 0, - /* 232. */ - 0, 0, 0, 0, 0, 0, 0, 0, - /* 240. */ - 0, 0, 0, 0, 0, 0, 0, 0, - /* 248. */ - 0, 0, 0, 0, 0, 0, 0, 0, - /* 256. */ - "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", - /* 264. */ - "d8", "d9", "d10", "d11", "d12", "d13", "d14", "d15", - /* 272. */ - "d16", "d17", "d18", "d19", "d20", "d21", "d22", "d23", - /* 280. */ - "d24", "d25", "d26", "d27", "d28", "d29", "d30", "d31", - }; - -const char * -unw_regname (unw_regnum_t reg) -{ - if (reg < (unw_regnum_t) ARRAY_SIZE (regname)) - return regname[reg]; - else - return "???"; -} diff --git a/src/pal/src/libunwind/src/arm/siglongjmp.S b/src/pal/src/libunwind/src/arm/siglongjmp.S deleted file mode 100644 index 4df073668..000000000 --- a/src/pal/src/libunwind/src/arm/siglongjmp.S +++ /dev/null @@ -1,12 +0,0 @@ - /* Dummy implementation for now. */ - - .globl _UI_siglongjmp_cont - .globl _UI_longjmp_cont - -_UI_siglongjmp_cont: -_UI_longjmp_cont: - bx lr -#ifdef __linux__ - /* We do not need executable stack. */ - .section .note.GNU-stack,"",%progbits -#endif diff --git a/src/pal/src/libunwind/src/arm/unwind_i.h b/src/pal/src/libunwind/src/arm/unwind_i.h deleted file mode 100644 index fe0bca005..000000000 --- a/src/pal/src/libunwind/src/arm/unwind_i.h +++ /dev/null @@ -1,62 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - -This file is part of libunwind. - -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. */ - -#ifndef unwind_i_h -#define unwind_i_h - -#include - -#include - -#include "libunwind_i.h" - -/* DWARF column numbers for ARM: */ -#define R7 7 -#define SP 13 -#define LR 14 -#define PC 15 - -#define arm_lock UNW_OBJ(lock) -#define arm_local_resume UNW_OBJ(local_resume) -#define arm_local_addr_space_init UNW_OBJ(local_addr_space_init) - -extern void arm_local_addr_space_init (void); -extern int arm_local_resume (unw_addr_space_t as, unw_cursor_t *cursor, - void *arg); -#define arm_handle_signal_frame UNW_OBJ(handle_signal_frame) -extern int arm_handle_signal_frame(unw_cursor_t *cursor); - -/* By-pass calls to access_mem() when known to be safe. */ -#ifdef UNW_LOCAL_ONLY -# undef ACCESS_MEM_FAST -# define ACCESS_MEM_FAST(ret,validate,cur,addr,to) \ - do { \ - if (unlikely(validate)) \ - (ret) = dwarf_get ((cur), DWARF_MEM_LOC ((cur), (addr)), &(to)); \ - else \ - (ret) = 0, (to) = *(unw_word_t *)(addr); \ - } while (0) -#endif - -#endif /* unwind_i_h */ diff --git a/src/pal/src/libunwind/src/config.h.in b/src/pal/src/libunwind/src/config.h.in deleted file mode 100644 index 5e3421b4a..000000000 --- a/src/pal/src/libunwind/src/config.h.in +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef __LIBUNWIND_CONFIG_H__ -#define __LIBUNWIND_CONFIG_H__ - -#cmakedefine HAVE_ELF_H -#cmakedefine HAVE_SYS_ELF_H - -#cmakedefine HAVE_ENDIAN_H -#cmakedefine HAVE_SYS_ENDIAN_H - -#cmakedefine HAVE_LINK_H -#cmakedefine HAVE_SYS_LINK_H - -#cmakedefine HAVE__BUILTIN_UNREACHABLE -#cmakedefine HAVE_SYNC_ATOMICS - -#endif diff --git a/src/pal/src/libunwind/src/configure.cmake b/src/pal/src/libunwind/src/configure.cmake deleted file mode 100644 index 3e45405e7..000000000 --- a/src/pal/src/libunwind/src/configure.cmake +++ /dev/null @@ -1,31 +0,0 @@ -include(CheckCXXSourceCompiles) -include(CheckIncludeFiles) - -check_include_files(elf.h HAVE_ELF_H) -check_include_files(sys/elf.h HAVE_SYS_ELF_H) - -check_include_files(endian.h HAVE_ENDIAN_H) -check_include_files(sys/endian.h HAVE_SYS_ENDIAN_H) - -check_include_files(link.h HAVE_LINK_H) -check_include_files(sys/link.h HAVE_SYS_LINK_H) - -check_cxx_source_compiles(" -int main(int argc, char **argv) -{ - __sync_bool_compare_and_swap((int *)0, 0, 1); - __sync_fetch_and_add((int *)0, 1); - - return 0; -}" HAVE_SYNC_ATOMICS) - - -check_cxx_source_compiles(" -int main(int argc, char **argv) -{ - __builtin_unreachable(); - - return 0; -}" HAVE__BUILTIN_UNREACHABLE) - -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h) diff --git a/src/pal/src/libunwind/src/coredump/README b/src/pal/src/libunwind/src/coredump/README deleted file mode 100644 index 204493c93..000000000 --- a/src/pal/src/libunwind/src/coredump/README +++ /dev/null @@ -1,8 +0,0 @@ -This code is based on "unwinding via ptrace" code from ptrace/ -directory. - -Files with names starting with _UCD_ are substantially changed -from their ptrace/_UPT_... progenitors. - -Files which still have _UPT_... names are either verbiatim copies -from ptrace/, or unimplemented stubs. diff --git a/src/pal/src/libunwind/src/coredump/_UCD_access_mem.c b/src/pal/src/libunwind/src/coredump/_UCD_access_mem.c deleted file mode 100644 index 1fdbd128f..000000000 --- a/src/pal/src/libunwind/src/coredump/_UCD_access_mem.c +++ /dev/null @@ -1,98 +0,0 @@ -/* libunwind - a platform-independent unwind library - -This file is part of libunwind. - -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. */ - -#include "_UCD_lib.h" -#include "_UCD_internal.h" - -int -_UCD_access_mem(unw_addr_space_t as, unw_word_t addr, unw_word_t *val, - int write, void *arg) -{ - if (write) - { - Debug(0, "write is not supported\n"); - return -UNW_EINVAL; - } - - struct UCD_info *ui = arg; - - unw_word_t addr_last = addr + sizeof(*val)-1; - coredump_phdr_t *phdr; - unsigned i; - for (i = 0; i < ui->phdrs_count; i++) - { - phdr = &ui->phdrs[i]; - if (phdr->p_vaddr <= addr && addr_last < phdr->p_vaddr + phdr->p_memsz) - { - goto found; - } - } - Debug(1, "addr 0x%llx is unmapped\n", (unsigned long long)addr); - return -UNW_EINVAL; - - found: ; - - const char *filename UNUSED; - off_t fileofs; - int fd; - if (addr_last >= phdr->p_vaddr + phdr->p_filesz) - { - /* This part of mapped address space is not present in coredump file */ - /* Do we have it in the backup file? */ - if (phdr->backing_fd < 0) - { - Debug(1, "access to not-present data in phdr[%d]: addr:0x%llx\n", - i, (unsigned long long)addr - ); - return -UNW_EINVAL; - } - filename = phdr->backing_filename; - fileofs = addr - phdr->p_vaddr; - fd = phdr->backing_fd; - goto read; - } - - filename = ui->coredump_filename; - fileofs = phdr->p_offset + (addr - phdr->p_vaddr); - fd = ui->coredump_fd; - read: - if (lseek(fd, fileofs, SEEK_SET) != fileofs) - goto read_error; - if (read(fd, val, sizeof(*val)) != sizeof(*val)) - goto read_error; - - Debug(1, "0x%llx <- [addr:0x%llx fileofs:0x%llx]\n", - (unsigned long long)(*val), - (unsigned long long)addr, - (unsigned long long)fileofs - ); - return 0; - - read_error: - Debug(1, "access out of file: addr:0x%llx fileofs:%llx file:'%s'\n", - (unsigned long long)addr, - (unsigned long long)fileofs, - filename - ); - return -UNW_EINVAL; -} diff --git a/src/pal/src/libunwind/src/coredump/_UCD_access_reg_freebsd.c b/src/pal/src/libunwind/src/coredump/_UCD_access_reg_freebsd.c deleted file mode 100644 index 0e3a83bdc..000000000 --- a/src/pal/src/libunwind/src/coredump/_UCD_access_reg_freebsd.c +++ /dev/null @@ -1,137 +0,0 @@ -/* libunwind - a platform-independent unwind library - -This file is part of libunwind. - -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. */ - -#include "_UCD_lib.h" - -#include "_UCD_internal.h" - -int -_UCD_access_reg (unw_addr_space_t as, - unw_regnum_t regnum, unw_word_t *valp, - int write, void *arg) -{ - if (write) - { - Debug(0, "write is not supported\n"); - return -UNW_EINVAL; - } - - struct UCD_info *ui = arg; - -#if defined(UNW_TARGET_X86) - switch (regnum) { - case UNW_X86_EAX: - *valp = ui->prstatus->pr_reg.r_eax; - break; - case UNW_X86_EDX: - *valp = ui->prstatus->pr_reg.r_edx; - break; - case UNW_X86_ECX: - *valp = ui->prstatus->pr_reg.r_ecx; - break; - case UNW_X86_EBX: - *valp = ui->prstatus->pr_reg.r_ebx; - break; - case UNW_X86_ESI: - *valp = ui->prstatus->pr_reg.r_esi; - break; - case UNW_X86_EDI: - *valp = ui->prstatus->pr_reg.r_edi; - break; - case UNW_X86_EBP: - *valp = ui->prstatus->pr_reg.r_ebp; - break; - case UNW_X86_ESP: - *valp = ui->prstatus->pr_reg.r_esp; - break; - case UNW_X86_EIP: - *valp = ui->prstatus->pr_reg.r_eip; - break; - case UNW_X86_EFLAGS: - *valp = ui->prstatus->pr_reg.r_eflags; - break; - case UNW_X86_TRAPNO: - *valp = ui->prstatus->pr_reg.r_trapno; - break; - default: - Debug(0, "bad regnum:%d\n", regnum); - return -UNW_EINVAL; - } -#elif defined(UNW_TARGET_X86_64) - switch (regnum) { - case UNW_X86_64_RAX: - *valp = ui->prstatus->pr_reg.r_rax; - break; - case UNW_X86_64_RDX: - *valp = ui->prstatus->pr_reg.r_rdx; - break; - case UNW_X86_64_RCX: - *valp = ui->prstatus->pr_reg.r_rcx; - break; - case UNW_X86_64_RBX: - *valp = ui->prstatus->pr_reg.r_rbx; - break; - case UNW_X86_64_RSI: - *valp = ui->prstatus->pr_reg.r_rsi; - break; - case UNW_X86_64_RDI: - *valp = ui->prstatus->pr_reg.r_rdi; - break; - case UNW_X86_64_RBP: - *valp = ui->prstatus->pr_reg.r_rbp; - break; - case UNW_X86_64_RSP: - *valp = ui->prstatus->pr_reg.r_rsp; - break; - case UNW_X86_64_RIP: - *valp = ui->prstatus->pr_reg.r_rip; - break; - default: - Debug(0, "bad regnum:%d\n", regnum); - return -UNW_EINVAL; - } -#elif defined(UNW_TARGET_ARM) - if (regnum >= UNW_ARM_R0 && regnum <= UNW_ARM_R12) { - *valp = ui->prstatus->pr_reg.r[regnum]; - } else { - switch (regnum) { - case UNW_ARM_R13: - *valp = ui->prstatus->pr_reg.r_sp; - break; - case UNW_ARM_R14: - *valp = ui->prstatus->pr_reg.r_lr; - break; - case UNW_ARM_R15: - *valp = ui->prstatus->pr_reg.r_pc; - break; - default: - Debug(0, "bad regnum:%d\n", regnum); - return -UNW_EINVAL; - } - } -#else -#error Port me -#endif - - return 0; -} diff --git a/src/pal/src/libunwind/src/coredump/_UCD_access_reg_linux.c b/src/pal/src/libunwind/src/coredump/_UCD_access_reg_linux.c deleted file mode 100644 index 208d8d27b..000000000 --- a/src/pal/src/libunwind/src/coredump/_UCD_access_reg_linux.c +++ /dev/null @@ -1,146 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2012 Tommi Rantala - -This file is part of libunwind. - -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. */ - -#include "_UCD_lib.h" - -#include "_UCD_internal.h" - -int -_UCD_access_reg (unw_addr_space_t as, - unw_regnum_t regnum, unw_word_t *valp, - int write, void *arg) -{ - struct UCD_info *ui = arg; - - if (write) - { - Debug(0, "write is not supported\n"); - return -UNW_EINVAL; - } - - if (regnum < 0) - goto badreg; - -#if defined(UNW_TARGET_AARCH64) - if (regnum >= UNW_AARCH64_FPCR) - goto badreg; -#elif defined(UNW_TARGET_ARM) - if (regnum >= 16) - goto badreg; -#elif defined(UNW_TARGET_SH) - if (regnum > UNW_SH_PR) - goto badreg; -#elif defined(UNW_TARGET_TILEGX) - if (regnum > UNW_TILEGX_CFA) - goto badreg; -#else -#if defined(UNW_TARGET_MIPS) - static const uint8_t remap_regs[] = - { - [UNW_MIPS_R0] = EF_REG0, - [UNW_MIPS_R1] = EF_REG1, - [UNW_MIPS_R2] = EF_REG2, - [UNW_MIPS_R3] = EF_REG3, - [UNW_MIPS_R4] = EF_REG4, - [UNW_MIPS_R5] = EF_REG5, - [UNW_MIPS_R6] = EF_REG6, - [UNW_MIPS_R7] = EF_REG7, - [UNW_MIPS_R8] = EF_REG8, - [UNW_MIPS_R9] = EF_REG9, - [UNW_MIPS_R10] = EF_REG10, - [UNW_MIPS_R11] = EF_REG11, - [UNW_MIPS_R12] = EF_REG12, - [UNW_MIPS_R13] = EF_REG13, - [UNW_MIPS_R14] = EF_REG14, - [UNW_MIPS_R15] = EF_REG15, - [UNW_MIPS_R16] = EF_REG16, - [UNW_MIPS_R17] = EF_REG17, - [UNW_MIPS_R18] = EF_REG18, - [UNW_MIPS_R19] = EF_REG19, - [UNW_MIPS_R20] = EF_REG20, - [UNW_MIPS_R21] = EF_REG21, - [UNW_MIPS_R22] = EF_REG22, - [UNW_MIPS_R23] = EF_REG23, - [UNW_MIPS_R24] = EF_REG24, - [UNW_MIPS_R25] = EF_REG25, - [UNW_MIPS_R28] = EF_REG28, - [UNW_MIPS_R29] = EF_REG29, - [UNW_MIPS_R30] = EF_REG30, - [UNW_MIPS_R31] = EF_REG31, - [UNW_MIPS_PC] = EF_CP0_EPC, - }; -#elif defined(UNW_TARGET_X86) - static const uint8_t remap_regs[] = - { - /* names from libunwind-x86.h */ - [UNW_X86_EAX] = offsetof(struct user_regs_struct, eax) / sizeof(long), - [UNW_X86_EDX] = offsetof(struct user_regs_struct, edx) / sizeof(long), - [UNW_X86_ECX] = offsetof(struct user_regs_struct, ecx) / sizeof(long), - [UNW_X86_EBX] = offsetof(struct user_regs_struct, ebx) / sizeof(long), - [UNW_X86_ESI] = offsetof(struct user_regs_struct, esi) / sizeof(long), - [UNW_X86_EDI] = offsetof(struct user_regs_struct, edi) / sizeof(long), - [UNW_X86_EBP] = offsetof(struct user_regs_struct, ebp) / sizeof(long), - [UNW_X86_ESP] = offsetof(struct user_regs_struct, esp) / sizeof(long), - [UNW_X86_EIP] = offsetof(struct user_regs_struct, eip) / sizeof(long), - [UNW_X86_EFLAGS] = offsetof(struct user_regs_struct, eflags) / sizeof(long), - [UNW_X86_TRAPNO] = offsetof(struct user_regs_struct, orig_eax) / sizeof(long), - }; -#elif defined(UNW_TARGET_X86_64) - static const int8_t remap_regs[] = - { - [UNW_X86_64_RAX] = offsetof(struct user_regs_struct, rax) / sizeof(long), - [UNW_X86_64_RDX] = offsetof(struct user_regs_struct, rdx) / sizeof(long), - [UNW_X86_64_RCX] = offsetof(struct user_regs_struct, rcx) / sizeof(long), - [UNW_X86_64_RBX] = offsetof(struct user_regs_struct, rbx) / sizeof(long), - [UNW_X86_64_RSI] = offsetof(struct user_regs_struct, rsi) / sizeof(long), - [UNW_X86_64_RDI] = offsetof(struct user_regs_struct, rdi) / sizeof(long), - [UNW_X86_64_RBP] = offsetof(struct user_regs_struct, rbp) / sizeof(long), - [UNW_X86_64_RSP] = offsetof(struct user_regs_struct, rsp) / sizeof(long), - [UNW_X86_64_RIP] = offsetof(struct user_regs_struct, rip) / sizeof(long), - }; -#else -#error Port me -#endif - - if (regnum >= (unw_regnum_t)ARRAY_SIZE(remap_regs)) - goto badreg; - - regnum = remap_regs[regnum]; -#endif - - /* pr_reg is a long[] array, but it contains struct user_regs_struct's - * image. - */ - Debug(1, "pr_reg[%d]:%ld (0x%lx)\n", regnum, - (long)ui->prstatus->pr_reg[regnum], - (long)ui->prstatus->pr_reg[regnum] - ); - *valp = ui->prstatus->pr_reg[regnum]; - - return 0; - -badreg: - Debug(0, "bad regnum:%d\n", regnum); - return -UNW_EINVAL; -} diff --git a/src/pal/src/libunwind/src/coredump/_UCD_accessors.c b/src/pal/src/libunwind/src/coredump/_UCD_accessors.c deleted file mode 100644 index ae5c23d21..000000000 --- a/src/pal/src/libunwind/src/coredump/_UCD_accessors.c +++ /dev/null @@ -1,36 +0,0 @@ -/* libunwind - a platform-independent unwind library - -This file is part of libunwind. - -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. */ - -#include "_UCD_internal.h" - -unw_accessors_t _UCD_accessors = - { - .find_proc_info = _UCD_find_proc_info, - .put_unwind_info = _UCD_put_unwind_info, - .get_dyn_info_list_addr = _UCD_get_dyn_info_list_addr, - .access_mem = _UCD_access_mem, - .access_reg = _UCD_access_reg, - .access_fpreg = _UCD_access_fpreg, - .resume = _UCD_resume, - .get_proc_name = _UCD_get_proc_name - }; diff --git a/src/pal/src/libunwind/src/coredump/_UCD_create.c b/src/pal/src/libunwind/src/coredump/_UCD_create.c deleted file mode 100644 index 62f6ee05c..000000000 --- a/src/pal/src/libunwind/src/coredump/_UCD_create.c +++ /dev/null @@ -1,417 +0,0 @@ -/* libunwind - a platform-independent unwind library - -This file is part of libunwind. - -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. */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -/* Endian detection */ -#include -#if defined(HAVE_BYTESWAP_H) -#include -#endif -#if defined(HAVE_ENDIAN_H) -# include -#elif defined(HAVE_SYS_ENDIAN_H) -# include -#endif -#if defined(__BYTE_ORDER) && __BYTE_ORDER == __BIG_ENDIAN -# define WE_ARE_BIG_ENDIAN 1 -# define WE_ARE_LITTLE_ENDIAN 0 -#elif defined(__BYTE_ORDER) && __BYTE_ORDER == __LITTLE_ENDIAN -# define WE_ARE_BIG_ENDIAN 0 -# define WE_ARE_LITTLE_ENDIAN 1 -#elif defined(_BYTE_ORDER) && _BYTE_ORDER == _BIG_ENDIAN -# define WE_ARE_BIG_ENDIAN 1 -# define WE_ARE_LITTLE_ENDIAN 0 -#elif defined(_BYTE_ORDER) && _BYTE_ORDER == _LITTLE_ENDIAN -# define WE_ARE_BIG_ENDIAN 0 -# define WE_ARE_LITTLE_ENDIAN 1 -#elif defined(BYTE_ORDER) && BYTE_ORDER == BIG_ENDIAN -# define WE_ARE_BIG_ENDIAN 1 -# define WE_ARE_LITTLE_ENDIAN 0 -#elif defined(BYTE_ORDER) && BYTE_ORDER == LITTLE_ENDIAN -# define WE_ARE_BIG_ENDIAN 0 -# define WE_ARE_LITTLE_ENDIAN 1 -#elif defined(__386__) -# define WE_ARE_BIG_ENDIAN 0 -# define WE_ARE_LITTLE_ENDIAN 1 -#else -# error "Can't determine endianness" -#endif - -#include -#include /* struct elf_prstatus */ - -#include "_UCD_lib.h" -#include "_UCD_internal.h" - -#define NOTE_DATA(_hdr) STRUCT_MEMBER_P((_hdr), sizeof (Elf32_Nhdr) + UNW_ALIGN((_hdr)->n_namesz, 4)) -#define NOTE_SIZE(_hdr) (sizeof (Elf32_Nhdr) + UNW_ALIGN((_hdr)->n_namesz, 4) + UNW_ALIGN((_hdr)->n_descsz, 4)) -#define NOTE_NEXT(_hdr) STRUCT_MEMBER_P((_hdr), NOTE_SIZE(_hdr)) -#define NOTE_FITS_IN(_hdr, _size) ((_size) >= sizeof (Elf32_Nhdr) && (_size) >= NOTE_SIZE (_hdr)) -#define NOTE_FITS(_hdr, _end) NOTE_FITS_IN((_hdr), (unsigned long)((char *)(_end) - (char *)(_hdr))) - -struct UCD_info * -_UCD_create(const char *filename) -{ - union - { - Elf32_Ehdr h32; - Elf64_Ehdr h64; - } elf_header; -#define elf_header32 elf_header.h32 -#define elf_header64 elf_header.h64 - bool _64bits; - - struct UCD_info *ui = memset(malloc(sizeof(*ui)), 0, sizeof(*ui)); - ui->edi.di_cache.format = -1; - ui->edi.di_debug.format = -1; -#if UNW_TARGET_IA64 - ui->edi.ktab.format = -1; -#endif - - int fd = ui->coredump_fd = open(filename, O_RDONLY); - if (fd < 0) - goto err; - ui->coredump_filename = strdup(filename); - - /* No sane ELF32 file is going to be smaller then ELF64 _header_, - * so let's just read 64-bit sized one. - */ - if (read(fd, &elf_header64, sizeof(elf_header64)) != sizeof(elf_header64)) - { - Debug(0, "'%s' is not an ELF file\n", filename); - goto err; - } - - if (memcmp(&elf_header32, ELFMAG, SELFMAG) != 0) - { - Debug(0, "'%s' is not an ELF file\n", filename); - goto err; - } - - if (elf_header32.e_ident[EI_CLASS] != ELFCLASS32 - && elf_header32.e_ident[EI_CLASS] != ELFCLASS64) - { - Debug(0, "'%s' is not a 32/64 bit ELF file\n", filename); - goto err; - } - - if (WE_ARE_LITTLE_ENDIAN != (elf_header32.e_ident[EI_DATA] == ELFDATA2LSB)) - { - Debug(0, "'%s' is endian-incompatible\n", filename); - goto err; - } - - _64bits = (elf_header32.e_ident[EI_CLASS] == ELFCLASS64); - if (_64bits && sizeof(elf_header64.e_entry) > sizeof(off_t)) - { - Debug(0, "Can't process '%s': 64-bit file " - "while only %ld bits are supported", - filename, 8L * sizeof(off_t)); - goto err; - } - - /* paranoia check */ - if (_64bits - ? 0 /* todo: (elf_header64.e_ehsize != NN || elf_header64.e_phentsize != NN) */ - : (elf_header32.e_ehsize != 52 || elf_header32.e_phentsize != 32) - ) - { - Debug(0, "'%s' has wrong e_ehsize or e_phentsize\n", filename); - goto err; - } - - off_t ofs = (_64bits ? elf_header64.e_phoff : elf_header32.e_phoff); - if (lseek(fd, ofs, SEEK_SET) != ofs) - { - Debug(0, "Can't read phdrs from '%s'\n", filename); - goto err; - } - unsigned size = ui->phdrs_count = (_64bits ? elf_header64.e_phnum : elf_header32.e_phnum); - coredump_phdr_t *phdrs = ui->phdrs = memset(malloc(size * sizeof(phdrs[0])), 0, size * sizeof(phdrs[0])); - if (_64bits) - { - coredump_phdr_t *cur = phdrs; - unsigned i = 0; - while (i < size) - { - Elf64_Phdr hdr64; - if (read(fd, &hdr64, sizeof(hdr64)) != sizeof(hdr64)) - { - Debug(0, "Can't read phdrs from '%s'\n", filename); - goto err; - } - cur->p_type = hdr64.p_type ; - cur->p_flags = hdr64.p_flags ; - cur->p_offset = hdr64.p_offset; - cur->p_vaddr = hdr64.p_vaddr ; - /*cur->p_paddr = hdr32.p_paddr ; always 0 */ -//TODO: check that and abort if it isn't? - cur->p_filesz = hdr64.p_filesz; - cur->p_memsz = hdr64.p_memsz ; - cur->p_align = hdr64.p_align ; - /* cur->backing_filename = NULL; - done by memset */ - cur->backing_fd = -1; - cur->backing_filesize = hdr64.p_filesz; - i++; - cur++; - } - } else { - coredump_phdr_t *cur = phdrs; - unsigned i = 0; - while (i < size) - { - Elf32_Phdr hdr32; - if (read(fd, &hdr32, sizeof(hdr32)) != sizeof(hdr32)) - { - Debug(0, "Can't read phdrs from '%s'\n", filename); - goto err; - } - cur->p_type = hdr32.p_type ; - cur->p_flags = hdr32.p_flags ; - cur->p_offset = hdr32.p_offset; - cur->p_vaddr = hdr32.p_vaddr ; - /*cur->p_paddr = hdr32.p_paddr ; always 0 */ - cur->p_filesz = hdr32.p_filesz; - cur->p_memsz = hdr32.p_memsz ; - cur->p_align = hdr32.p_align ; - /* cur->backing_filename = NULL; - done by memset */ - cur->backing_fd = -1; - cur->backing_filesize = hdr32.p_memsz; - i++; - cur++; - } - } - - unsigned i = 0; - coredump_phdr_t *cur = phdrs; - while (i < size) - { - Debug(2, "phdr[%03d]: type:%d", i, cur->p_type); - if (cur->p_type == PT_NOTE) - { - Elf32_Nhdr *note_hdr, *note_end; - unsigned n_threads; - - ui->note_phdr = malloc(cur->p_filesz); - if (lseek(fd, cur->p_offset, SEEK_SET) != (off_t)cur->p_offset - || (uoff_t)read(fd, ui->note_phdr, cur->p_filesz) != cur->p_filesz) - { - Debug(0, "Can't read PT_NOTE from '%s'\n", filename); - goto err; - } - - note_end = STRUCT_MEMBER_P (ui->note_phdr, cur->p_filesz); - - /* Count number of threads */ - n_threads = 0; - note_hdr = (Elf32_Nhdr *)ui->note_phdr; - while (NOTE_FITS (note_hdr, note_end)) - { - if (note_hdr->n_type == NT_PRSTATUS) - n_threads++; - - note_hdr = NOTE_NEXT (note_hdr); - } - - ui->n_threads = n_threads; - ui->threads = malloc(sizeof (void *) * n_threads); - - n_threads = 0; - note_hdr = (Elf32_Nhdr *)ui->note_phdr; - while (NOTE_FITS (note_hdr, note_end)) - { - if (note_hdr->n_type == NT_PRSTATUS) - ui->threads[n_threads++] = NOTE_DATA (note_hdr); - - note_hdr = NOTE_NEXT (note_hdr); - } - } - if (cur->p_type == PT_LOAD) - { - Debug(2, " ofs:%08llx va:%08llx filesize:%08llx memsize:%08llx flg:%x", - (unsigned long long) cur->p_offset, - (unsigned long long) cur->p_vaddr, - (unsigned long long) cur->p_filesz, - (unsigned long long) cur->p_memsz, - cur->p_flags - ); - if (cur->p_filesz < cur->p_memsz) - Debug(2, " partial"); - if (cur->p_flags & PF_X) - Debug(2, " executable"); - } - Debug(2, "\n"); - i++; - cur++; - } - - if (ui->n_threads == 0) - { - Debug(0, "No NT_PRSTATUS note found in '%s'\n", filename); - goto err; - } - - ui->prstatus = ui->threads[0]; - - return ui; - - err: - _UCD_destroy(ui); - return NULL; -} - -int _UCD_get_num_threads(struct UCD_info *ui) -{ - return ui->n_threads; -} - -void _UCD_select_thread(struct UCD_info *ui, int n) -{ - if (n >= 0 && n < ui->n_threads) - ui->prstatus = ui->threads[n]; -} - -pid_t _UCD_get_pid(struct UCD_info *ui) -{ - return ui->prstatus->pr_pid; -} - -int _UCD_get_cursig(struct UCD_info *ui) -{ - return ui->prstatus->pr_cursig; -} - -int _UCD_add_backing_file_at_segment(struct UCD_info *ui, int phdr_no, const char *filename) -{ - if ((unsigned)phdr_no >= ui->phdrs_count) - { - Debug(0, "There is no segment %d in this coredump\n", phdr_no); - return -1; - } - - struct coredump_phdr *phdr = &ui->phdrs[phdr_no]; - if (phdr->backing_filename) - { - Debug(0, "Backing file already added to segment %d\n", phdr_no); - return -1; - } - - int fd = open(filename, O_RDONLY); - if (fd < 0) - { - Debug(0, "Can't open '%s'\n", filename); - return -1; - } - - phdr->backing_fd = fd; - phdr->backing_filename = strdup(filename); - - struct stat statbuf; - if (fstat(fd, &statbuf) != 0) - { - Debug(0, "Can't stat '%s'\n", filename); - goto err; - } - phdr->backing_filesize = (uoff_t)statbuf.st_size; - - if (phdr->p_flags != (PF_X | PF_R)) - Debug(1, "Note: phdr[%u] is not r-x: flags are 0x%x\n", phdr_no, phdr->p_flags); - - if (phdr->backing_filesize > phdr->p_memsz) - { - /* This is expected */ - Debug(2, "Note: phdr[%u] is %lld bytes, file is larger: %lld bytes\n", - phdr_no, - (unsigned long long)phdr->p_memsz, - (unsigned long long)phdr->backing_filesize - ); - } -//TODO: else loudly complain? Maybe even fail? - - if (phdr->p_filesz != 0) - { -//TODO: loop and compare in smaller blocks - char *core_buf = malloc(phdr->p_filesz); - char *file_buf = malloc(phdr->p_filesz); - if (lseek(ui->coredump_fd, phdr->p_offset, SEEK_SET) != (off_t)phdr->p_offset - || (uoff_t)read(ui->coredump_fd, core_buf, phdr->p_filesz) != phdr->p_filesz - ) - { - Debug(0, "Error reading from coredump file\n"); - err_read: - free(core_buf); - free(file_buf); - goto err; - } - if ((uoff_t)read(fd, file_buf, phdr->p_filesz) != phdr->p_filesz) - { - Debug(0, "Error reading from '%s'\n", filename); - goto err_read; - } - int r = memcmp(core_buf, file_buf, phdr->p_filesz); - free(core_buf); - free(file_buf); - if (r != 0) - { - Debug(1, "Note: phdr[%u] first %lld bytes in core dump and in file do not match\n", - phdr_no, (unsigned long long)phdr->p_filesz - ); - } else { - Debug(1, "Note: phdr[%u] first %lld bytes in core dump and in file match\n", - phdr_no, (unsigned long long)phdr->p_filesz - ); - } - } - - /* Success */ - return 0; - - err: - if (phdr->backing_fd >= 0) - { - close(phdr->backing_fd); - phdr->backing_fd = -1; - } - free(phdr->backing_filename); - phdr->backing_filename = NULL; - return -1; -} - -int _UCD_add_backing_file_at_vaddr(struct UCD_info *ui, - unsigned long vaddr, - const char *filename) -{ - unsigned i; - for (i = 0; i < ui->phdrs_count; i++) - { - struct coredump_phdr *phdr = &ui->phdrs[i]; - if (phdr->p_vaddr != vaddr) - continue; - /* It seems to match. Add it. */ - return _UCD_add_backing_file_at_segment(ui, i, filename); - } - return -1; -} diff --git a/src/pal/src/libunwind/src/coredump/_UCD_destroy.c b/src/pal/src/libunwind/src/coredump/_UCD_destroy.c deleted file mode 100644 index ddc36ec89..000000000 --- a/src/pal/src/libunwind/src/coredump/_UCD_destroy.c +++ /dev/null @@ -1,52 +0,0 @@ -/* libunwind - a platform-independent unwind library - -This file is part of libunwind. - -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. */ - -#include "_UCD_internal.h" - -void -_UCD_destroy (struct UCD_info *ui) -{ - if (!ui) - return; - - if (ui->coredump_fd >= 0) - close(ui->coredump_fd); - free(ui->coredump_filename); - - invalidate_edi (&ui->edi); - - unsigned i; - for (i = 0; i < ui->phdrs_count; i++) - { - struct coredump_phdr *phdr = &ui->phdrs[i]; - free(phdr->backing_filename); - if (phdr->backing_fd >= 0) - close(phdr->backing_fd); - } - - free(ui->phdrs); - free(ui->note_phdr); - free(ui->threads); - - free(ui); -} diff --git a/src/pal/src/libunwind/src/coredump/_UCD_elf_map_image.c b/src/pal/src/libunwind/src/coredump/_UCD_elf_map_image.c deleted file mode 100644 index 4b3db0bbf..000000000 --- a/src/pal/src/libunwind/src/coredump/_UCD_elf_map_image.c +++ /dev/null @@ -1,98 +0,0 @@ -/* libunwind - a platform-independent unwind library - -This file is part of libunwind. - -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. */ - -#include - -#include "_UCD_lib.h" -#include "_UCD_internal.h" - -static coredump_phdr_t * -CD_elf_map_image(struct UCD_info *ui, coredump_phdr_t *phdr) -{ - struct elf_image *ei = &ui->edi.ei; - - if (phdr->backing_fd < 0) - { - /* Note: coredump file contains only phdr->p_filesz bytes. - * We want to map bigger area (phdr->p_memsz bytes) to make sure - * these pages are allocated, but non-accessible. - */ - /* addr, length, prot, flags, fd, fd_offset */ - ei->image = mmap(NULL, phdr->p_memsz, PROT_READ, MAP_PRIVATE, ui->coredump_fd, phdr->p_offset); - if (ei->image == MAP_FAILED) - { - ei->image = NULL; - return NULL; - } - ei->size = phdr->p_filesz; - size_t remainder_len = phdr->p_memsz - phdr->p_filesz; - if (remainder_len > 0) - { - void *remainder_base = (char*) ei->image + phdr->p_filesz; - munmap(remainder_base, remainder_len); - } - } else { - /* We have a backing file for this segment. - * This file is always longer than phdr->p_memsz, - * and if phdr->p_filesz !=0, first phdr->p_filesz bytes in coredump - * are the same as first bytes in the file. (Thus no need to map coredump) - * We map the entire file: - * unwinding may need data which is past phdr->p_memsz bytes. - */ - /* addr, length, prot, flags, fd, fd_offset */ - ei->image = mmap(NULL, phdr->backing_filesize, PROT_READ, MAP_PRIVATE, phdr->backing_fd, 0); - if (ei->image == MAP_FAILED) - { - ei->image = NULL; - return NULL; - } - ei->size = phdr->backing_filesize; - } - - /* Check ELF header for sanity */ - if (!elf_w(valid_object)(ei)) - { - munmap(ei->image, ei->size); - ei->image = NULL; - ei->size = 0; - return NULL; - } - - return phdr; -} - -HIDDEN coredump_phdr_t * -_UCD_get_elf_image(struct UCD_info *ui, unw_word_t ip) -{ - unsigned i; - for (i = 0; i < ui->phdrs_count; i++) - { - coredump_phdr_t *phdr = &ui->phdrs[i]; - if (phdr->p_vaddr <= ip && ip < phdr->p_vaddr + phdr->p_memsz) - { - phdr = CD_elf_map_image(ui, phdr); - return phdr; - } - } - return NULL; -} diff --git a/src/pal/src/libunwind/src/coredump/_UCD_find_proc_info.c b/src/pal/src/libunwind/src/coredump/_UCD_find_proc_info.c deleted file mode 100644 index 33b66c8ed..000000000 --- a/src/pal/src/libunwind/src/coredump/_UCD_find_proc_info.c +++ /dev/null @@ -1,163 +0,0 @@ -/* libunwind - a platform-independent unwind library - -This file is part of libunwind. - -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. */ - -#include - -#include "_UCD_lib.h" -#include "_UCD_internal.h" - -static int -get_unwind_info(struct UCD_info *ui, unw_addr_space_t as, unw_word_t ip) -{ - unsigned long segbase, mapoff; - -#if UNW_TARGET_IA64 && defined(__linux) - if (!ui->edi.ktab.start_ip && _Uia64_get_kernel_table (&ui->edi.ktab) < 0) - return -UNW_ENOINFO; - - if (ui->edi.ktab.format != -1 && ip >= ui->edi.ktab.start_ip && ip < ui->edi.ktab.end_ip) - return 0; -#endif - - if ((ui->edi.di_cache.format != -1 - && ip >= ui->edi.di_cache.start_ip && ip < ui->edi.di_cache.end_ip) -#if UNW_TARGET_ARM - || (ui->edi.di_debug.format != -1 - && ip >= ui->edi.di_arm.start_ip && ip < ui->edi.di_arm.end_ip) -#endif - || (ui->edi.di_debug.format != -1 - && ip >= ui->edi.di_debug.start_ip && ip < ui->edi.di_debug.end_ip)) - return 0; - - invalidate_edi (&ui->edi); - - /* Used to be tdep_get_elf_image() in ptrace unwinding code */ - coredump_phdr_t *phdr = _UCD_get_elf_image(ui, ip); - if (!phdr) - { - Debug(1, "returns error: _UCD_get_elf_image failed\n"); - return -UNW_ENOINFO; - } - /* segbase: where it is mapped in virtual memory */ - /* mapoff: offset in the file */ - segbase = phdr->p_vaddr; - /*mapoff = phdr->p_offset; WRONG! phdr->p_offset is the offset in COREDUMP file */ - mapoff = 0; -///FIXME. text segment is USUALLY, not always, at offset 0 in the binary/.so file. -// ensure that at initialization. - - /* Here, SEGBASE is the starting-address of the (mmap'ped) segment - which covers the IP we're looking for. */ - if (tdep_find_unwind_table(&ui->edi, as, phdr->backing_filename, segbase, mapoff, ip) < 0) - { - Debug(1, "returns error: tdep_find_unwind_table failed\n"); - return -UNW_ENOINFO; - } - - /* This can happen in corner cases where dynamically generated - code falls into the same page that contains the data-segment - and the page-offset of the code is within the first page of - the executable. */ - if (ui->edi.di_cache.format != -1 - && (ip < ui->edi.di_cache.start_ip || ip >= ui->edi.di_cache.end_ip)) - ui->edi.di_cache.format = -1; - - if (ui->edi.di_debug.format != -1 - && (ip < ui->edi.di_debug.start_ip || ip >= ui->edi.di_debug.end_ip)) - ui->edi.di_debug.format = -1; - - if (ui->edi.di_cache.format == -1 -#if UNW_TARGET_ARM - && ui->edi.di_arm.format == -1 -#endif - && ui->edi.di_debug.format == -1) - { - Debug(1, "returns error: all formats are -1\n"); - return -UNW_ENOINFO; - } - - Debug(1, "returns success\n"); - return 0; -} - -int -_UCD_find_proc_info (unw_addr_space_t as, unw_word_t ip, unw_proc_info_t *pi, - int need_unwind_info, void *arg) -{ - struct UCD_info *ui = arg; - - Debug(1, "entering\n"); - - int ret = -UNW_ENOINFO; - - if (get_unwind_info(ui, as, ip) < 0) { - Debug(1, "returns error: get_unwind_info failed\n"); - return -UNW_ENOINFO; - } - -#if UNW_TARGET_IA64 - if (ui->edi.ktab.format != -1) - { - /* The kernel unwind table resides in local memory, so we have - to use the local address space to search it. Since - _UCD_put_unwind_info() has no easy way of detecting this - case, we simply make a copy of the unwind-info, so - _UCD_put_unwind_info() can always free() the unwind-info - without ill effects. */ - ret = tdep_search_unwind_table (unw_local_addr_space, ip, &ui->edi.ktab, pi, - need_unwind_info, arg); - if (ret >= 0) - { - if (!need_unwind_info) - pi->unwind_info = NULL; - else - { - void *mem = malloc (pi->unwind_info_size); - - if (!mem) - return -UNW_ENOMEM; - memcpy (mem, pi->unwind_info, pi->unwind_info_size); - pi->unwind_info = mem; - } - } - } -#endif - - if (ret == -UNW_ENOINFO && ui->edi.di_cache.format != -1) - ret = tdep_search_unwind_table (as, ip, &ui->edi.di_cache, - pi, need_unwind_info, arg); - -#if UNW_TARGET_ARM - if (ret == -UNW_ENOINFO && ui->edi.di_arm.format != -1) - ret = tdep_search_unwind_table (as, ip, &ui->edi.di_arm, pi, - need_unwind_info, arg); -#endif - - if (ret == -UNW_ENOINFO && ui->edi.di_debug.format != -1) - ret = tdep_search_unwind_table (as, ip, &ui->edi.di_debug, pi, - need_unwind_info, arg); - - Debug(1, "returns %d\n", ret); - - return ret; -} diff --git a/src/pal/src/libunwind/src/coredump/_UCD_get_proc_name.c b/src/pal/src/libunwind/src/coredump/_UCD_get_proc_name.c deleted file mode 100644 index 00096c48d..000000000 --- a/src/pal/src/libunwind/src/coredump/_UCD_get_proc_name.c +++ /dev/null @@ -1,70 +0,0 @@ -/* libunwind - a platform-independent unwind library - -This file is part of libunwind. - -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. */ - -#include "_UCD_lib.h" -#include "_UCD_internal.h" - - -/* Find the ELF image that contains IP and return the "closest" - procedure name, if there is one. With some caching, this could be - sped up greatly, but until an application materializes that's - sensitive to the performance of this routine, why bother... */ -static int -elf_w (CD_get_proc_name) (struct UCD_info *ui, unw_addr_space_t as, unw_word_t ip, - char *buf, size_t buf_len, unw_word_t *offp) -{ - unsigned long segbase, mapoff; - int ret; - - /* Used to be tdep_get_elf_image() in ptrace unwinding code */ - coredump_phdr_t *cphdr = _UCD_get_elf_image(ui, ip); - if (!cphdr) - { - Debug(1, "returns error: _UCD_get_elf_image failed\n"); - return -UNW_ENOINFO; - } - /* segbase: where it is mapped in virtual memory */ - /* mapoff: offset in the file */ - segbase = cphdr->p_vaddr; - /*mapoff = phdr->p_offset; WRONG! phdr->p_offset is the offset in COREDUMP file */ - mapoff = 0; - - ret = elf_w (get_proc_name_in_image) (as, &ui->edi.ei, segbase, mapoff, ip, buf, buf_len, offp); - - return ret; -} - -int -_UCD_get_proc_name (unw_addr_space_t as, unw_word_t ip, - char *buf, size_t buf_len, unw_word_t *offp, void *arg) -{ - struct UCD_info *ui = arg; - -#if ELF_CLASS == ELFCLASS64 - return _Uelf64_CD_get_proc_name (ui, as, ip, buf, buf_len, offp); -#elif ELF_CLASS == ELFCLASS32 - return _Uelf32_CD_get_proc_name (ui, as, ip, buf, buf_len, offp); -#else - return -UNW_ENOINFO; -#endif -} diff --git a/src/pal/src/libunwind/src/coredump/_UCD_internal.h b/src/pal/src/libunwind/src/coredump/_UCD_internal.h deleted file mode 100644 index 3c95a2a00..000000000 --- a/src/pal/src/libunwind/src/coredump/_UCD_internal.h +++ /dev/null @@ -1,105 +0,0 @@ -/* libunwind - a platform-independent unwind library - -This file is part of libunwind. - -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. */ - -#ifndef _UCD_internal_h -#define _UCD_internal_h - -#ifdef HAVE_CONFIG_H -#include -#endif - -#ifdef HAVE_SYS_TYPES_H -#include -#endif -#ifdef HAVE_SYS_PROCFS_H -#include /* struct elf_prstatus */ -#endif -#include -#include -#include -#include -#include - -#include - -#include "libunwind_i.h" - - -#if SIZEOF_OFF_T == 4 -typedef uint32_t uoff_t; -#elif SIZEOF_OFF_T == 8 -typedef uint64_t uoff_t; -#else -# error Unknown size of off_t! -#endif - - -/* Similar to ELF phdrs. p_paddr element is absent, - * since it's always 0 in coredumps. - */ -struct coredump_phdr - { - uint32_t p_type; - uint32_t p_flags; - uoff_t p_offset; - uoff_t p_vaddr; - uoff_t p_filesz; - uoff_t p_memsz; - uoff_t p_align; - /* Data for backing file. If backing_fd < 0, there is no file */ - uoff_t backing_filesize; - char *backing_filename; /* for error meesages only */ - int backing_fd; - }; - -typedef struct coredump_phdr coredump_phdr_t; - -#if defined(HAVE_STRUCT_ELF_PRSTATUS) -#define PRSTATUS_STRUCT elf_prstatus -#elif defined(HAVE_STRUCT_PRSTATUS) -#define PRSTATUS_STRUCT prstatus -#else -#define PRSTATUS_STRUCT non_existent -#endif - -struct UCD_info - { - int big_endian; /* bool */ - int coredump_fd; - char *coredump_filename; /* for error meesages only */ - coredump_phdr_t *phdrs; /* array, allocated */ - unsigned phdrs_count; - void *note_phdr; /* allocated or NULL */ - struct PRSTATUS_STRUCT *prstatus; /* points inside note_phdr */ - int n_threads; - struct PRSTATUS_STRUCT **threads; - - struct elf_dyn_info edi; - }; - -extern coredump_phdr_t * _UCD_get_elf_image(struct UCD_info *ui, unw_word_t ip); - -#define STRUCT_MEMBER_P(struct_p, struct_offset) ((void *) ((char*) (struct_p) + (long) (struct_offset))) -#define STRUCT_MEMBER(member_type, struct_p, struct_offset) (*(member_type*) STRUCT_MEMBER_P ((struct_p), (struct_offset))) - -#endif diff --git a/src/pal/src/libunwind/src/coredump/_UCD_lib.h b/src/pal/src/libunwind/src/coredump/_UCD_lib.h deleted file mode 100644 index 22be32ed1..000000000 --- a/src/pal/src/libunwind/src/coredump/_UCD_lib.h +++ /dev/null @@ -1,57 +0,0 @@ -/* libunwind - a platform-independent unwind library - -This file is part of libunwind. - -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. */ - -#ifndef _UCD_lib_h -#define _UCD_lib_h - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#endif diff --git a/src/pal/src/libunwind/src/coredump/_UPT_access_fpreg.c b/src/pal/src/libunwind/src/coredump/_UPT_access_fpreg.c deleted file mode 100644 index 0b8b86ac9..000000000 --- a/src/pal/src/libunwind/src/coredump/_UPT_access_fpreg.c +++ /dev/null @@ -1,34 +0,0 @@ -/* libunwind - a platform-independent unwind library - -This file is part of libunwind. - -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. */ - -#include "_UCD_lib.h" -#include "_UCD_internal.h" - -int -_UCD_access_fpreg (unw_addr_space_t as, unw_regnum_t reg, unw_fpreg_t *val, - int write, void *arg) -{ - print_error (__func__); - print_error (" not implemented\n"); - return -UNW_EINVAL; -} diff --git a/src/pal/src/libunwind/src/coredump/_UPT_elf.c b/src/pal/src/libunwind/src/coredump/_UPT_elf.c deleted file mode 100644 index fb7b19a7c..000000000 --- a/src/pal/src/libunwind/src/coredump/_UPT_elf.c +++ /dev/null @@ -1,5 +0,0 @@ -/* We need to get a separate copy of the ELF-code into - libunwind-coredump since it cannot (and must not) have any ELF - dependencies on libunwind. */ -#include "libunwind_i.h" /* get ELFCLASS defined */ -#include "../elfxx.c" diff --git a/src/pal/src/libunwind/src/coredump/_UPT_get_dyn_info_list_addr.c b/src/pal/src/libunwind/src/coredump/_UPT_get_dyn_info_list_addr.c deleted file mode 100644 index 0d1190556..000000000 --- a/src/pal/src/libunwind/src/coredump/_UPT_get_dyn_info_list_addr.c +++ /dev/null @@ -1,108 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2003-2005 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include "_UCD_lib.h" -#include "_UCD_internal.h" - -#if UNW_TARGET_IA64 && defined(__linux) -# include "elf64.h" -# include "os-linux.h" - -static inline int -get_list_addr (unw_addr_space_t as, unw_word_t *dil_addr, void *arg, - int *countp) -{ - unsigned long lo, hi, off; - struct UPT_info *ui = arg; - struct map_iterator mi; - char path[PATH_MAX]; - unw_dyn_info_t *di; - unw_word_t res; - int count = 0; - - maps_init (&mi, ui->pid); - while (maps_next (&mi, &lo, &hi, &off)) - { - if (off) - continue; - - invalidate_edi (&ui->edi); - - if (elf_map_image (&ui->ei, path) < 0) - /* ignore unmappable stuff like "/SYSV00001b58 (deleted)" */ - continue; - - Debug (16, "checking object %s\n", path); - - di = tdep_find_unwind_table (&ui->edi, as, path, lo, off); - if (di) - { - res = _Uia64_find_dyn_list (as, di, arg); - if (res && count++ == 0) - { - Debug (12, "dyn_info_list_addr = 0x%lx\n", (long) res); - *dil_addr = res; - } - } - } - maps_close (&mi); - *countp = count; - return 0; -} - -#else - -static inline int -get_list_addr (unw_addr_space_t as, unw_word_t *dil_addr, void *arg, - int *countp) -{ -# warning Implement get_list_addr(), please. - *countp = 0; - return 0; -} - -#endif - -int -_UCD_get_dyn_info_list_addr (unw_addr_space_t as, unw_word_t *dil_addr, - void *arg) -{ - int count, ret; - - Debug (12, "looking for dyn_info list\n"); - - if ((ret = get_list_addr (as, dil_addr, arg, &count)) < 0) - return ret; - - /* If multiple dynamic-info list addresses are found, we would have - to determine which was is the one actually in use (since the - dynamic name resolution algorithm will pick one "winner"). - Perhaps we'd have to track them all until we find one that's - non-empty. Hopefully, this case simply will never arise, since - only libunwind defines the dynamic info list head. */ - assert (count <= 1); - - return (count > 0) ? 0 : -UNW_ENOINFO; -} diff --git a/src/pal/src/libunwind/src/coredump/_UPT_put_unwind_info.c b/src/pal/src/libunwind/src/coredump/_UPT_put_unwind_info.c deleted file mode 100644 index 462e1d048..000000000 --- a/src/pal/src/libunwind/src/coredump/_UPT_put_unwind_info.c +++ /dev/null @@ -1,36 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2003 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include "_UCD_lib.h" -#include "_UCD_internal.h" - -void -_UCD_put_unwind_info (unw_addr_space_t as, unw_proc_info_t *pi, void *arg) -{ - if (!pi->unwind_info) - return; - free (pi->unwind_info); - pi->unwind_info = NULL; -} diff --git a/src/pal/src/libunwind/src/coredump/_UPT_resume.c b/src/pal/src/libunwind/src/coredump/_UPT_resume.c deleted file mode 100644 index a729c908c..000000000 --- a/src/pal/src/libunwind/src/coredump/_UPT_resume.c +++ /dev/null @@ -1,35 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2003 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include "_UCD_lib.h" -#include "_UCD_internal.h" - -int -_UCD_resume (unw_addr_space_t as, unw_cursor_t *c, void *arg) -{ - print_error (__func__); - print_error (" not implemented\n"); - return -UNW_EINVAL; -} diff --git a/src/pal/src/libunwind/src/coredump/libunwind-coredump.pc.in b/src/pal/src/libunwind/src/coredump/libunwind-coredump.pc.in deleted file mode 100644 index 9cb62c086..000000000 --- a/src/pal/src/libunwind/src/coredump/libunwind-coredump.pc.in +++ /dev/null @@ -1,11 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ - -Name: libunwind-coredump -Description: libunwind coredump library -Version: @VERSION@ -Requires: libunwind-generic libunwind -Libs: -L${libdir} -lunwind-coredump -Cflags: -I${includedir} diff --git a/src/pal/src/libunwind/src/dwarf/Gexpr.c b/src/pal/src/libunwind/src/dwarf/Gexpr.c deleted file mode 100644 index f63c3d220..000000000 --- a/src/pal/src/libunwind/src/dwarf/Gexpr.c +++ /dev/null @@ -1,696 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (c) 2003, 2005 Hewlett-Packard Development Company, L.P. - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include "dwarf_i.h" -#include "libunwind_i.h" - -/* The "pick" operator provides an index range of 0..255 indicating - that the stack could at least have a depth of up to 256 elements, - but the GCC unwinder restricts the depth to 64, which seems - reasonable so we use the same value here. */ -#define MAX_EXPR_STACK_SIZE 64 - -#define NUM_OPERANDS(signature) (((signature) >> 6) & 0x3) -#define OPND1_TYPE(signature) (((signature) >> 3) & 0x7) -#define OPND2_TYPE(signature) (((signature) >> 0) & 0x7) - -#define OPND_SIGNATURE(n, t1, t2) (((n) << 6) | ((t1) << 3) | ((t2) << 0)) -#define OPND1(t1) OPND_SIGNATURE(1, t1, 0) -#define OPND2(t1, t2) OPND_SIGNATURE(2, t1, t2) - -#define VAL8 0x0 -#define VAL16 0x1 -#define VAL32 0x2 -#define VAL64 0x3 -#define ULEB128 0x4 -#define SLEB128 0x5 -#define OFFSET 0x6 /* 32-bit offset for 32-bit DWARF, 64-bit otherwise */ -#define ADDR 0x7 /* Machine address. */ - -static const uint8_t operands[256] = - { - [DW_OP_addr] = OPND1 (ADDR), - [DW_OP_const1u] = OPND1 (VAL8), - [DW_OP_const1s] = OPND1 (VAL8), - [DW_OP_const2u] = OPND1 (VAL16), - [DW_OP_const2s] = OPND1 (VAL16), - [DW_OP_const4u] = OPND1 (VAL32), - [DW_OP_const4s] = OPND1 (VAL32), - [DW_OP_const8u] = OPND1 (VAL64), - [DW_OP_const8s] = OPND1 (VAL64), - [DW_OP_pick] = OPND1 (VAL8), - [DW_OP_plus_uconst] = OPND1 (ULEB128), - [DW_OP_skip] = OPND1 (VAL16), - [DW_OP_bra] = OPND1 (VAL16), - [DW_OP_breg0 + 0] = OPND1 (SLEB128), - [DW_OP_breg0 + 1] = OPND1 (SLEB128), - [DW_OP_breg0 + 2] = OPND1 (SLEB128), - [DW_OP_breg0 + 3] = OPND1 (SLEB128), - [DW_OP_breg0 + 4] = OPND1 (SLEB128), - [DW_OP_breg0 + 5] = OPND1 (SLEB128), - [DW_OP_breg0 + 6] = OPND1 (SLEB128), - [DW_OP_breg0 + 7] = OPND1 (SLEB128), - [DW_OP_breg0 + 8] = OPND1 (SLEB128), - [DW_OP_breg0 + 9] = OPND1 (SLEB128), - [DW_OP_breg0 + 10] = OPND1 (SLEB128), - [DW_OP_breg0 + 11] = OPND1 (SLEB128), - [DW_OP_breg0 + 12] = OPND1 (SLEB128), - [DW_OP_breg0 + 13] = OPND1 (SLEB128), - [DW_OP_breg0 + 14] = OPND1 (SLEB128), - [DW_OP_breg0 + 15] = OPND1 (SLEB128), - [DW_OP_breg0 + 16] = OPND1 (SLEB128), - [DW_OP_breg0 + 17] = OPND1 (SLEB128), - [DW_OP_breg0 + 18] = OPND1 (SLEB128), - [DW_OP_breg0 + 19] = OPND1 (SLEB128), - [DW_OP_breg0 + 20] = OPND1 (SLEB128), - [DW_OP_breg0 + 21] = OPND1 (SLEB128), - [DW_OP_breg0 + 22] = OPND1 (SLEB128), - [DW_OP_breg0 + 23] = OPND1 (SLEB128), - [DW_OP_breg0 + 24] = OPND1 (SLEB128), - [DW_OP_breg0 + 25] = OPND1 (SLEB128), - [DW_OP_breg0 + 26] = OPND1 (SLEB128), - [DW_OP_breg0 + 27] = OPND1 (SLEB128), - [DW_OP_breg0 + 28] = OPND1 (SLEB128), - [DW_OP_breg0 + 29] = OPND1 (SLEB128), - [DW_OP_breg0 + 30] = OPND1 (SLEB128), - [DW_OP_breg0 + 31] = OPND1 (SLEB128), - [DW_OP_regx] = OPND1 (ULEB128), - [DW_OP_fbreg] = OPND1 (SLEB128), - [DW_OP_bregx] = OPND2 (ULEB128, SLEB128), - [DW_OP_piece] = OPND1 (ULEB128), - [DW_OP_deref_size] = OPND1 (VAL8), - [DW_OP_xderef_size] = OPND1 (VAL8), - [DW_OP_call2] = OPND1 (VAL16), - [DW_OP_call4] = OPND1 (VAL32), - [DW_OP_call_ref] = OPND1 (OFFSET) - }; - -static inline unw_sword_t -sword (unw_addr_space_t as, unw_word_t val) -{ - switch (dwarf_addr_size (as)) - { - case 1: return (int8_t) val; - case 2: return (int16_t) val; - case 4: return (int32_t) val; - case 8: return (int64_t) val; - default: abort (); - } -} - -static inline unw_word_t -read_operand (unw_addr_space_t as, unw_accessors_t *a, - unw_word_t *addr, int operand_type, unw_word_t *val, void *arg) -{ - uint8_t u8; - uint16_t u16; - uint32_t u32; - uint64_t u64; - int ret; - - if (operand_type == ADDR) - switch (dwarf_addr_size (as)) - { - case 1: operand_type = VAL8; break; - case 2: operand_type = VAL16; break; - case 4: operand_type = VAL32; break; - case 8: operand_type = VAL64; break; - default: abort (); - } - - switch (operand_type) - { - case VAL8: - ret = dwarf_readu8 (as, a, addr, &u8, arg); - if (ret < 0) - return ret; - *val = u8; - break; - - case VAL16: - ret = dwarf_readu16 (as, a, addr, &u16, arg); - if (ret < 0) - return ret; - *val = u16; - break; - - case VAL32: - ret = dwarf_readu32 (as, a, addr, &u32, arg); - if (ret < 0) - return ret; - *val = u32; - break; - - case VAL64: - ret = dwarf_readu64 (as, a, addr, &u64, arg); - if (ret < 0) - return ret; - *val = u64; - break; - - case ULEB128: - ret = dwarf_read_uleb128 (as, a, addr, val, arg); - break; - - case SLEB128: - ret = dwarf_read_sleb128 (as, a, addr, val, arg); - break; - - case OFFSET: /* only used by DW_OP_call_ref, which we don't implement */ - default: - Debug (1, "Unexpected operand type %d\n", operand_type); - ret = -UNW_EINVAL; - } - return ret; -} - -HIDDEN int -dwarf_stack_aligned(struct dwarf_cursor *c, unw_word_t cfa_addr, - unw_word_t rbp_addr, unw_word_t *cfa_offset) { - unw_accessors_t *a; - int ret; - void *arg; - unw_word_t len; - uint8_t opcode; - unw_word_t operand1; - - a = unw_get_accessors_int (c->as); - arg = c->as_arg; - - ret = dwarf_read_uleb128(c->as, a, &rbp_addr, &len, arg); - if (len != 2 || ret < 0) - return 0; - - ret = dwarf_readu8(c->as, a, &rbp_addr, &opcode, arg); - if (ret < 0 || opcode != DW_OP_breg6) - return 0; - - ret = read_operand(c->as, a, &rbp_addr, - OPND1_TYPE(operands[opcode]), &operand1, arg); - - if (ret < 0 || operand1 != 0) - return 0; - - ret = dwarf_read_uleb128(c->as, a, &cfa_addr, &len, arg); - if (ret < 0 || len != 3) - return 0; - - ret = dwarf_readu8(c->as, a, &cfa_addr, &opcode, arg); - if (ret < 0 || opcode != DW_OP_breg6) - return 0; - - ret = read_operand(c->as, a, &cfa_addr, - OPND1_TYPE(operands[opcode]), &operand1, arg); - if (ret < 0) - return 0; - - ret = dwarf_readu8(c->as, a, &cfa_addr, &opcode, arg); - if (ret < 0 || opcode != DW_OP_deref) - return 0; - - *cfa_offset = operand1; - return 1; -} - -HIDDEN int -dwarf_eval_expr (struct dwarf_cursor *c, unw_word_t *addr, unw_word_t len, - unw_word_t *valp, int *is_register) -{ - unw_word_t operand1 = 0, operand2 = 0, tmp1, tmp2 = 0, tmp3, end_addr; - uint8_t opcode, operands_signature, u8; - unw_addr_space_t as; - unw_accessors_t *a; - void *arg; - unw_word_t stack[MAX_EXPR_STACK_SIZE]; - unsigned int tos = 0; - uint16_t u16; - uint32_t u32; - uint64_t u64; - int ret; -# define pop() \ -({ \ - if ((tos - 1) >= MAX_EXPR_STACK_SIZE) \ - { \ - Debug (1, "Stack underflow\n"); \ - return -UNW_EINVAL; \ - } \ - stack[--tos]; \ -}) -# define push(x) \ -do { \ - unw_word_t _x = (x); \ - if (tos >= MAX_EXPR_STACK_SIZE) \ - { \ - Debug (1, "Stack overflow\n"); \ - return -UNW_EINVAL; \ - } \ - stack[tos++] = _x; \ -} while (0) -# define pick(n) \ -({ \ - unsigned int _index = tos - 1 - (n); \ - if (_index >= MAX_EXPR_STACK_SIZE) \ - { \ - Debug (1, "Out-of-stack pick\n"); \ - return -UNW_EINVAL; \ - } \ - stack[_index]; \ -}) - - as = c->as; - arg = c->as_arg; - a = unw_get_accessors_int (as); - end_addr = *addr + len; - *is_register = 0; - - Debug (14, "len=%lu, pushing cfa=0x%lx\n", - (unsigned long) len, (unsigned long) c->cfa); - - push (c->cfa); /* push current CFA as required by DWARF spec */ - - while (*addr < end_addr) - { - if ((ret = dwarf_readu8 (as, a, addr, &opcode, arg)) < 0) - return ret; - - operands_signature = operands[opcode]; - - if (unlikely (NUM_OPERANDS (operands_signature) > 0)) - { - if ((ret = read_operand (as, a, addr, - OPND1_TYPE (operands_signature), - &operand1, arg)) < 0) - return ret; - if (NUM_OPERANDS (operands_signature) > 1) - if ((ret = read_operand (as, a, addr, - OPND2_TYPE (operands_signature), - &operand2, arg)) < 0) - return ret; - } - - switch ((dwarf_expr_op_t) opcode) - { - case DW_OP_lit0: case DW_OP_lit1: case DW_OP_lit2: - case DW_OP_lit3: case DW_OP_lit4: case DW_OP_lit5: - case DW_OP_lit6: case DW_OP_lit7: case DW_OP_lit8: - case DW_OP_lit9: case DW_OP_lit10: case DW_OP_lit11: - case DW_OP_lit12: case DW_OP_lit13: case DW_OP_lit14: - case DW_OP_lit15: case DW_OP_lit16: case DW_OP_lit17: - case DW_OP_lit18: case DW_OP_lit19: case DW_OP_lit20: - case DW_OP_lit21: case DW_OP_lit22: case DW_OP_lit23: - case DW_OP_lit24: case DW_OP_lit25: case DW_OP_lit26: - case DW_OP_lit27: case DW_OP_lit28: case DW_OP_lit29: - case DW_OP_lit30: case DW_OP_lit31: - Debug (15, "OP_lit(%d)\n", (int) opcode - DW_OP_lit0); - push (opcode - DW_OP_lit0); - break; - - case DW_OP_breg0: case DW_OP_breg1: case DW_OP_breg2: - case DW_OP_breg3: case DW_OP_breg4: case DW_OP_breg5: - case DW_OP_breg6: case DW_OP_breg7: case DW_OP_breg8: - case DW_OP_breg9: case DW_OP_breg10: case DW_OP_breg11: - case DW_OP_breg12: case DW_OP_breg13: case DW_OP_breg14: - case DW_OP_breg15: case DW_OP_breg16: case DW_OP_breg17: - case DW_OP_breg18: case DW_OP_breg19: case DW_OP_breg20: - case DW_OP_breg21: case DW_OP_breg22: case DW_OP_breg23: - case DW_OP_breg24: case DW_OP_breg25: case DW_OP_breg26: - case DW_OP_breg27: case DW_OP_breg28: case DW_OP_breg29: - case DW_OP_breg30: case DW_OP_breg31: - Debug (15, "OP_breg(r%d,0x%lx)\n", - (int) opcode - DW_OP_breg0, (unsigned long) operand1); - if ((ret = unw_get_reg (dwarf_to_cursor (c), - dwarf_to_unw_regnum (opcode - DW_OP_breg0), - &tmp1)) < 0) - return ret; - push (tmp1 + operand1); - break; - - case DW_OP_bregx: - Debug (15, "OP_bregx(r%d,0x%lx)\n", - (int) operand1, (unsigned long) operand2); - if ((ret = unw_get_reg (dwarf_to_cursor (c), - dwarf_to_unw_regnum (operand1), &tmp1)) < 0) - return ret; - push (tmp1 + operand2); - break; - - case DW_OP_reg0: case DW_OP_reg1: case DW_OP_reg2: - case DW_OP_reg3: case DW_OP_reg4: case DW_OP_reg5: - case DW_OP_reg6: case DW_OP_reg7: case DW_OP_reg8: - case DW_OP_reg9: case DW_OP_reg10: case DW_OP_reg11: - case DW_OP_reg12: case DW_OP_reg13: case DW_OP_reg14: - case DW_OP_reg15: case DW_OP_reg16: case DW_OP_reg17: - case DW_OP_reg18: case DW_OP_reg19: case DW_OP_reg20: - case DW_OP_reg21: case DW_OP_reg22: case DW_OP_reg23: - case DW_OP_reg24: case DW_OP_reg25: case DW_OP_reg26: - case DW_OP_reg27: case DW_OP_reg28: case DW_OP_reg29: - case DW_OP_reg30: case DW_OP_reg31: - Debug (15, "OP_reg(r%d)\n", (int) opcode - DW_OP_reg0); - *valp = dwarf_to_unw_regnum (opcode - DW_OP_reg0); - *is_register = 1; - return 0; - - case DW_OP_regx: - Debug (15, "OP_regx(r%d)\n", (int) operand1); - *valp = dwarf_to_unw_regnum (operand1); - *is_register = 1; - return 0; - - case DW_OP_addr: - case DW_OP_const1u: - case DW_OP_const2u: - case DW_OP_const4u: - case DW_OP_const8u: - case DW_OP_constu: - case DW_OP_const8s: - case DW_OP_consts: - Debug (15, "OP_const(0x%lx)\n", (unsigned long) operand1); - push (operand1); - break; - - case DW_OP_const1s: - if (operand1 & 0x80) - operand1 |= ((unw_word_t) -1) << 8; - Debug (15, "OP_const1s(%ld)\n", (long) operand1); - push (operand1); - break; - - case DW_OP_const2s: - if (operand1 & 0x8000) - operand1 |= ((unw_word_t) -1) << 16; - Debug (15, "OP_const2s(%ld)\n", (long) operand1); - push (operand1); - break; - - case DW_OP_const4s: - if (operand1 & 0x80000000) - operand1 |= (((unw_word_t) -1) << 16) << 16; - Debug (15, "OP_const4s(%ld)\n", (long) operand1); - push (operand1); - break; - - case DW_OP_deref: - Debug (15, "OP_deref\n"); - tmp1 = pop (); - if ((ret = dwarf_readw (as, a, &tmp1, &tmp2, arg)) < 0) - return ret; - push (tmp2); - break; - - case DW_OP_deref_size: - Debug (15, "OP_deref_size(%d)\n", (int) operand1); - tmp1 = pop (); - switch (operand1) - { - default: - Debug (1, "Unexpected DW_OP_deref_size size %d\n", - (int) operand1); - return -UNW_EINVAL; - - case 1: - if ((ret = dwarf_readu8 (as, a, &tmp1, &u8, arg)) < 0) - return ret; - tmp2 = u8; - break; - - case 2: - if ((ret = dwarf_readu16 (as, a, &tmp1, &u16, arg)) < 0) - return ret; - tmp2 = u16; - break; - - case 3: - case 4: - if ((ret = dwarf_readu32 (as, a, &tmp1, &u32, arg)) < 0) - return ret; - tmp2 = u32; - if (operand1 == 3) - { - if (dwarf_is_big_endian (as)) - tmp2 >>= 8; - else - tmp2 &= 0xffffff; - } - break; - case 5: - case 6: - case 7: - case 8: - if ((ret = dwarf_readu64 (as, a, &tmp1, &u64, arg)) < 0) - return ret; - tmp2 = u64; - if (operand1 != 8) - { - if (dwarf_is_big_endian (as)) - tmp2 >>= 64 - 8 * operand1; - else - tmp2 &= (~ (unw_word_t) 0) << (8 * operand1); - } - break; - } - push (tmp2); - break; - - case DW_OP_dup: - Debug (15, "OP_dup\n"); - push (pick (0)); - break; - - case DW_OP_drop: - Debug (15, "OP_drop\n"); - (void) pop (); - break; - - case DW_OP_pick: - Debug (15, "OP_pick(%d)\n", (int) operand1); - push (pick (operand1)); - break; - - case DW_OP_over: - Debug (15, "OP_over\n"); - push (pick (1)); - break; - - case DW_OP_swap: - Debug (15, "OP_swap\n"); - tmp1 = pop (); - tmp2 = pop (); - push (tmp1); - push (tmp2); - break; - - case DW_OP_rot: - Debug (15, "OP_rot\n"); - tmp1 = pop (); - tmp2 = pop (); - tmp3 = pop (); - push (tmp1); - push (tmp3); - push (tmp2); - break; - - case DW_OP_abs: - Debug (15, "OP_abs\n"); - tmp1 = pop (); - if (tmp1 & ((unw_word_t) 1 << (8 * dwarf_addr_size (as) - 1))) - tmp1 = -tmp1; - push (tmp1); - break; - - case DW_OP_and: - Debug (15, "OP_and\n"); - tmp1 = pop (); - tmp2 = pop (); - push (tmp1 & tmp2); - break; - - case DW_OP_div: - Debug (15, "OP_div\n"); - tmp1 = pop (); - tmp2 = pop (); - if (tmp1) - tmp1 = sword (as, tmp2) / sword (as, tmp1); - push (tmp1); - break; - - case DW_OP_minus: - Debug (15, "OP_minus\n"); - tmp1 = pop (); - tmp2 = pop (); - tmp1 = tmp2 - tmp1; - push (tmp1); - break; - - case DW_OP_mod: - Debug (15, "OP_mod\n"); - tmp1 = pop (); - tmp2 = pop (); - if (tmp1) - tmp1 = tmp2 % tmp1; - push (tmp1); - break; - - case DW_OP_mul: - Debug (15, "OP_mul\n"); - tmp1 = pop (); - tmp2 = pop (); - if (tmp1) - tmp1 = tmp2 * tmp1; - push (tmp1); - break; - - case DW_OP_neg: - Debug (15, "OP_neg\n"); - push (-pop ()); - break; - - case DW_OP_not: - Debug (15, "OP_not\n"); - push (~pop ()); - break; - - case DW_OP_or: - Debug (15, "OP_or\n"); - tmp1 = pop (); - tmp2 = pop (); - push (tmp1 | tmp2); - break; - - case DW_OP_plus: - Debug (15, "OP_plus\n"); - tmp1 = pop (); - tmp2 = pop (); - push (tmp1 + tmp2); - break; - - case DW_OP_plus_uconst: - Debug (15, "OP_plus_uconst(%lu)\n", (unsigned long) operand1); - tmp1 = pop (); - push (tmp1 + operand1); - break; - - case DW_OP_shl: - Debug (15, "OP_shl\n"); - tmp1 = pop (); - tmp2 = pop (); - push (tmp2 << tmp1); - break; - - case DW_OP_shr: - Debug (15, "OP_shr\n"); - tmp1 = pop (); - tmp2 = pop (); - push (tmp2 >> tmp1); - break; - - case DW_OP_shra: - Debug (15, "OP_shra\n"); - tmp1 = pop (); - tmp2 = pop (); - push (sword (as, tmp2) >> tmp1); - break; - - case DW_OP_xor: - Debug (15, "OP_xor\n"); - tmp1 = pop (); - tmp2 = pop (); - push (tmp1 ^ tmp2); - break; - - case DW_OP_le: - Debug (15, "OP_le\n"); - tmp1 = pop (); - tmp2 = pop (); - push (sword (as, tmp2) <= sword (as, tmp1)); - break; - - case DW_OP_ge: - Debug (15, "OP_ge\n"); - tmp1 = pop (); - tmp2 = pop (); - push (sword (as, tmp2) >= sword (as, tmp1)); - break; - - case DW_OP_eq: - Debug (15, "OP_eq\n"); - tmp1 = pop (); - tmp2 = pop (); - push (sword (as, tmp2) == sword (as, tmp1)); - break; - - case DW_OP_lt: - Debug (15, "OP_lt\n"); - tmp1 = pop (); - tmp2 = pop (); - push (sword (as, tmp2) < sword (as, tmp1)); - break; - - case DW_OP_gt: - Debug (15, "OP_gt\n"); - tmp1 = pop (); - tmp2 = pop (); - push (sword (as, tmp2) > sword (as, tmp1)); - break; - - case DW_OP_ne: - Debug (15, "OP_ne\n"); - tmp1 = pop (); - tmp2 = pop (); - push (sword (as, tmp2) != sword (as, tmp1)); - break; - - case DW_OP_skip: - Debug (15, "OP_skip(%d)\n", (int16_t) operand1); - *addr += (int16_t) operand1; - break; - - case DW_OP_bra: - Debug (15, "OP_skip(%d)\n", (int16_t) operand1); - tmp1 = pop (); - if (tmp1) - *addr += (int16_t) operand1; - break; - - case DW_OP_nop: - Debug (15, "OP_nop\n"); - break; - - case DW_OP_call2: - case DW_OP_call4: - case DW_OP_call_ref: - case DW_OP_fbreg: - case DW_OP_piece: - case DW_OP_push_object_address: - case DW_OP_xderef: - case DW_OP_xderef_size: - default: - Debug (1, "Unexpected opcode 0x%x\n", opcode); - return -UNW_EINVAL; - } - } - *valp = pop (); - Debug (14, "final value = 0x%lx\n", (unsigned long) *valp); - return 0; -} diff --git a/src/pal/src/libunwind/src/dwarf/Gfde.c b/src/pal/src/libunwind/src/dwarf/Gfde.c deleted file mode 100644 index 9250b895e..000000000 --- a/src/pal/src/libunwind/src/dwarf/Gfde.c +++ /dev/null @@ -1,359 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (c) 2003-2005 Hewlett-Packard Development Company, L.P. - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include "dwarf_i.h" - -static inline int -is_cie_id (unw_word_t val, int is_debug_frame) -{ - /* The CIE ID is normally 0xffffffff (for 32-bit ELF) or - 0xffffffffffffffff (for 64-bit ELF). However, .eh_frame - uses 0. */ - if (is_debug_frame) - return (val == (uint32_t)(-1) || val == (uint64_t)(-1)); - else - return (val == 0); -} - -/* Note: we don't need to keep track of more than the first four - characters of the augmentation string, because we (a) ignore any - augmentation string contents once we find an unrecognized character - and (b) those characters that we do recognize, can't be - repeated. */ -static inline int -parse_cie (unw_addr_space_t as, unw_accessors_t *a, unw_word_t addr, - const unw_proc_info_t *pi, struct dwarf_cie_info *dci, - int is_debug_frame, void *arg) -{ - uint8_t version, ch, augstr[5], fde_encoding, handler_encoding; - unw_word_t len, cie_end_addr, aug_size; - uint32_t u32val; - uint64_t u64val; - size_t i; - int ret; -# define STR2(x) #x -# define STR(x) STR2(x) - - /* Pick appropriate default for FDE-encoding. DWARF spec says - start-IP (initial_location) and the code-size (address_range) are - "address-unit sized constants". The `R' augmentation can be used - to override this, but by default, we pick an address-sized unit - for fde_encoding. */ - switch (dwarf_addr_size (as)) - { - case 4: fde_encoding = DW_EH_PE_udata4; break; - case 8: fde_encoding = DW_EH_PE_udata8; break; - default: fde_encoding = DW_EH_PE_omit; break; - } - - dci->lsda_encoding = DW_EH_PE_omit; - dci->handler = 0; - - if ((ret = dwarf_readu32 (as, a, &addr, &u32val, arg)) < 0) - return ret; - - if (u32val != 0xffffffff) - { - /* the CIE is in the 32-bit DWARF format */ - uint32_t cie_id; - /* DWARF says CIE id should be 0xffffffff, but in .eh_frame, it's 0 */ - const uint32_t expected_id = (is_debug_frame) ? 0xffffffff : 0; - - len = u32val; - cie_end_addr = addr + len; - if ((ret = dwarf_readu32 (as, a, &addr, &cie_id, arg)) < 0) - return ret; - if (cie_id != expected_id) - { - Debug (1, "Unexpected CIE id %x\n", cie_id); - return -UNW_EINVAL; - } - } - else - { - /* the CIE is in the 64-bit DWARF format */ - uint64_t cie_id; - /* DWARF says CIE id should be 0xffffffffffffffff, but in - .eh_frame, it's 0 */ - const uint64_t expected_id = (is_debug_frame) ? 0xffffffffffffffffull : 0; - - if ((ret = dwarf_readu64 (as, a, &addr, &u64val, arg)) < 0) - return ret; - len = u64val; - cie_end_addr = addr + len; - if ((ret = dwarf_readu64 (as, a, &addr, &cie_id, arg)) < 0) - return ret; - if (cie_id != expected_id) - { - Debug (1, "Unexpected CIE id %llx\n", (long long) cie_id); - return -UNW_EINVAL; - } - } - dci->cie_instr_end = cie_end_addr; - - if ((ret = dwarf_readu8 (as, a, &addr, &version, arg)) < 0) - return ret; - - /* GCC emits version 1??? */ - if (version != 1 && (version < DWARF_CIE_VERSION || version > DWARF_CIE_VERSION_MAX)) - { - Debug (1, "Got CIE version %u, expected version 1 or between " - STR (DWARF_CIE_VERSION) " and " STR (DWARF_CIE_VERSION_MAX) "\n", version); - return -UNW_EBADVERSION; - } - - /* read and parse the augmentation string: */ - memset (augstr, 0, sizeof (augstr)); - for (i = 0;;) - { - if ((ret = dwarf_readu8 (as, a, &addr, &ch, arg)) < 0) - return ret; - - if (!ch) - break; /* end of augmentation string */ - - if (i < sizeof (augstr) - 1) - augstr[i++] = ch; - } - - if ((ret = dwarf_read_uleb128 (as, a, &addr, &dci->code_align, arg)) < 0 - || (ret = dwarf_read_sleb128 (as, a, &addr, &dci->data_align, arg)) < 0) - return ret; - - /* Read the return-address column either as a u8 or as a uleb128. */ - if (version == 1) - { - if ((ret = dwarf_readu8 (as, a, &addr, &ch, arg)) < 0) - return ret; - dci->ret_addr_column = ch; - } - else if ((ret = dwarf_read_uleb128 (as, a, &addr, &dci->ret_addr_column, - arg)) < 0) - return ret; - - i = 0; - if (augstr[0] == 'z') - { - dci->sized_augmentation = 1; - if ((ret = dwarf_read_uleb128 (as, a, &addr, &aug_size, arg)) < 0) - return ret; - i++; - } - - for (; i < sizeof (augstr) && augstr[i]; ++i) - switch (augstr[i]) - { - case 'L': - /* read the LSDA pointer-encoding format. */ - if ((ret = dwarf_readu8 (as, a, &addr, &ch, arg)) < 0) - return ret; - dci->lsda_encoding = ch; - break; - - case 'R': - /* read the FDE pointer-encoding format. */ - if ((ret = dwarf_readu8 (as, a, &addr, &fde_encoding, arg)) < 0) - return ret; - break; - - case 'P': - /* read the personality-routine pointer-encoding format. */ - if ((ret = dwarf_readu8 (as, a, &addr, &handler_encoding, arg)) < 0) - return ret; - if ((ret = dwarf_read_encoded_pointer (as, a, &addr, handler_encoding, - pi, &dci->handler, arg)) < 0) - return ret; - break; - - case 'S': - /* This is a signal frame. */ - dci->signal_frame = 1; - - /* Temporarily set it to one so dwarf_parse_fde() knows that - it should fetch the actual ABI/TAG pair from the FDE. */ - dci->have_abi_marker = 1; - break; - - default: - Debug (1, "Unexpected augmentation string `%s'\n", augstr); - if (dci->sized_augmentation) - /* If we have the size of the augmentation body, we can skip - over the parts that we don't understand, so we're OK. */ - goto done; - else - return -UNW_EINVAL; - } - done: - dci->fde_encoding = fde_encoding; - dci->cie_instr_start = addr; - Debug (15, "CIE parsed OK, augmentation = \"%s\", handler=0x%lx\n", - augstr, (long) dci->handler); - return 0; -} - -/* Extract proc-info from the FDE starting at adress ADDR. - - Pass BASE as zero for eh_frame behaviour, or a pointer to - debug_frame base for debug_frame behaviour. */ - -HIDDEN int -dwarf_extract_proc_info_from_fde (unw_addr_space_t as, unw_accessors_t *a, - unw_word_t *addrp, unw_proc_info_t *pi, - unw_word_t base, - int need_unwind_info, int is_debug_frame, - void *arg) -{ - unw_word_t fde_end_addr, cie_addr, cie_offset_addr, aug_end_addr = 0; - unw_word_t start_ip, ip_range, aug_size, addr = *addrp; - int ret, ip_range_encoding; - struct dwarf_cie_info dci; - uint64_t u64val; - uint32_t u32val; - - Debug (12, "FDE @ 0x%lx\n", (long) addr); - - memset (&dci, 0, sizeof (dci)); - - if ((ret = dwarf_readu32 (as, a, &addr, &u32val, arg)) < 0) - return ret; - - if (u32val != 0xffffffff) - { - int32_t cie_offset = 0; - - /* In some configurations, an FDE with a 0 length indicates the - end of the FDE-table. */ - if (u32val == 0) - return -UNW_ENOINFO; - - /* the FDE is in the 32-bit DWARF format */ - - *addrp = fde_end_addr = addr + u32val; - cie_offset_addr = addr; - - if ((ret = dwarf_reads32 (as, a, &addr, &cie_offset, arg)) < 0) - return ret; - - if (is_cie_id (cie_offset, is_debug_frame)) - /* ignore CIEs (happens during linear searches) */ - return 0; - - if (is_debug_frame) - cie_addr = base + cie_offset; - else - /* DWARF says that the CIE_pointer in the FDE is a - .debug_frame-relative offset, but the GCC-generated .eh_frame - sections instead store a "pcrelative" offset, which is just - as fine as it's self-contained. */ - cie_addr = cie_offset_addr - cie_offset; - } - else - { - int64_t cie_offset = 0; - - /* the FDE is in the 64-bit DWARF format */ - - if ((ret = dwarf_readu64 (as, a, &addr, &u64val, arg)) < 0) - return ret; - - *addrp = fde_end_addr = addr + u64val; - cie_offset_addr = addr; - - if ((ret = dwarf_reads64 (as, a, &addr, &cie_offset, arg)) < 0) - return ret; - - if (is_cie_id (cie_offset, is_debug_frame)) - /* ignore CIEs (happens during linear searches) */ - return 0; - - if (is_debug_frame) - cie_addr = base + cie_offset; - else - /* DWARF says that the CIE_pointer in the FDE is a - .debug_frame-relative offset, but the GCC-generated .eh_frame - sections instead store a "pcrelative" offset, which is just - as fine as it's self-contained. */ - cie_addr = (unw_word_t) ((uint64_t) cie_offset_addr - cie_offset); - } - - Debug (15, "looking for CIE at address %lx\n", (long) cie_addr); - - if ((ret = parse_cie (as, a, cie_addr, pi, &dci, is_debug_frame, arg)) < 0) - return ret; - - /* IP-range has same encoding as FDE pointers, except that it's - always an absolute value: */ - ip_range_encoding = dci.fde_encoding & DW_EH_PE_FORMAT_MASK; - - if ((ret = dwarf_read_encoded_pointer (as, a, &addr, dci.fde_encoding, - pi, &start_ip, arg)) < 0 - || (ret = dwarf_read_encoded_pointer (as, a, &addr, ip_range_encoding, - pi, &ip_range, arg)) < 0) - return ret; - pi->start_ip = start_ip; - pi->end_ip = start_ip + ip_range; - pi->handler = dci.handler; - - if (dci.sized_augmentation) - { - if ((ret = dwarf_read_uleb128 (as, a, &addr, &aug_size, arg)) < 0) - return ret; - aug_end_addr = addr + aug_size; - } - - if ((ret = dwarf_read_encoded_pointer (as, a, &addr, dci.lsda_encoding, - pi, &pi->lsda, arg)) < 0) - return ret; - - Debug (15, "FDE covers IP 0x%lx-0x%lx, LSDA=0x%lx\n", - (long) pi->start_ip, (long) pi->end_ip, (long) pi->lsda); - - if (need_unwind_info) - { - pi->format = UNW_INFO_FORMAT_TABLE; - pi->unwind_info_size = sizeof (dci); - pi->unwind_info = mempool_alloc (&dwarf_cie_info_pool); - if (!pi->unwind_info) - return -UNW_ENOMEM; - - if (dci.have_abi_marker) - { - if ((ret = dwarf_readu16 (as, a, &addr, &dci.abi, arg)) < 0 - || (ret = dwarf_readu16 (as, a, &addr, &dci.tag, arg)) < 0) - return ret; - Debug (13, "Found ABI marker = (abi=%u, tag=%u)\n", - dci.abi, dci.tag); - } - - if (dci.sized_augmentation) - dci.fde_instr_start = aug_end_addr; - else - dci.fde_instr_start = addr; - dci.fde_instr_end = fde_end_addr; - - memcpy (pi->unwind_info, &dci, sizeof (dci)); - } - return 0; -} diff --git a/src/pal/src/libunwind/src/dwarf/Gfind_proc_info-lsb.c b/src/pal/src/libunwind/src/dwarf/Gfind_proc_info-lsb.c deleted file mode 100644 index 509ceff47..000000000 --- a/src/pal/src/libunwind/src/dwarf/Gfind_proc_info-lsb.c +++ /dev/null @@ -1,935 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (c) 2003-2005 Hewlett-Packard Development Company, L.P. - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -/* Locate an FDE via the ELF data-structures defined by LSB v1.3 - (http://www.linuxbase.org/spec/). */ - -#include -#include -#include - -#include "dwarf_i.h" -#include "dwarf-eh.h" -#include "libunwind_i.h" - -struct table_entry - { - int32_t start_ip_offset; - int32_t fde_offset; - }; - -#ifndef UNW_REMOTE_ONLY - -#ifdef __linux -#include "os-linux.h" -#endif - -static ALIAS(dwarf_search_unwind_table) int -dwarf_search_unwind_table_int (unw_addr_space_t as, - unw_word_t ip, - unw_dyn_info_t *di, - unw_proc_info_t *pi, - int need_unwind_info, void *arg); -static int -linear_search (unw_addr_space_t as, unw_word_t ip, - unw_word_t eh_frame_start, unw_word_t eh_frame_end, - unw_word_t fde_count, - unw_proc_info_t *pi, int need_unwind_info, void *arg) -{ - unw_accessors_t *a = unw_get_accessors_int (unw_local_addr_space); - unw_word_t i = 0, fde_addr, addr = eh_frame_start; - int ret; - - while (i++ < fde_count && addr < eh_frame_end) - { - fde_addr = addr; - if ((ret = dwarf_extract_proc_info_from_fde (as, a, &addr, pi, - eh_frame_start, - 0, 0, arg)) < 0) - return ret; - - if (ip >= pi->start_ip && ip < pi->end_ip) - { - if (!need_unwind_info) - return 1; - addr = fde_addr; - if ((ret = dwarf_extract_proc_info_from_fde (as, a, &addr, pi, - eh_frame_start, - need_unwind_info, 0, - arg)) - < 0) - return ret; - return 1; - } - } - return -UNW_ENOINFO; -} -#endif /* !UNW_REMOTE_ONLY */ - -#ifdef CONFIG_DEBUG_FRAME -/* Load .debug_frame section from FILE. Allocates and returns space - in *BUF, and sets *BUFSIZE to its size. IS_LOCAL is 1 if using the - local process, in which case we can search the system debug file - directory; 0 for other address spaces, in which case we do - not. Returns 0 on success, 1 on error. Succeeds even if the file - contains no .debug_frame. */ -/* XXX: Could use mmap; but elf_map_image keeps tons mapped in. */ - -static int -load_debug_frame (const char *file, char **buf, size_t *bufsize, int is_local) -{ - struct elf_image ei; - Elf_W (Shdr) *shdr; - int ret; - - ei.image = NULL; - - ret = elf_w (load_debuglink) (file, &ei, is_local); - if (ret != 0) - return ret; - - shdr = elf_w (find_section) (&ei, ".debug_frame"); - if (!shdr || - (shdr->sh_offset + shdr->sh_size > ei.size)) - { - munmap(ei.image, ei.size); - return 1; - } - - *bufsize = shdr->sh_size; - *buf = malloc (*bufsize); - - memcpy(*buf, shdr->sh_offset + ei.image, *bufsize); - - Debug (4, "read %zd bytes of .debug_frame from offset %zd\n", - *bufsize, shdr->sh_offset); - - munmap(ei.image, ei.size); - return 0; -} - -/* Locate the binary which originated the contents of address ADDR. Return - the name of the binary in *name (space is allocated by the caller) - Returns 0 if a binary is successfully found, or 1 if an error occurs. */ - -static int -find_binary_for_address (unw_word_t ip, char *name, size_t name_size) -{ -#if defined(__linux) && (!UNW_REMOTE_ONLY) - struct map_iterator mi; - int found = 0; - int pid = getpid (); - unsigned long segbase, mapoff, hi; - - if (maps_init (&mi, pid) != 0) - return 1; - - while (maps_next (&mi, &segbase, &hi, &mapoff)) - if (ip >= segbase && ip < hi) - { - size_t len = strlen (mi.path); - - if (len + 1 <= name_size) - { - memcpy (name, mi.path, len + 1); - found = 1; - } - break; - } - maps_close (&mi); - return !found; -#endif - - return 1; -} - -/* Locate and/or try to load a debug_frame section for address ADDR. Return - pointer to debug frame descriptor, or zero if not found. */ - -static struct unw_debug_frame_list * -locate_debug_info (unw_addr_space_t as, unw_word_t addr, const char *dlname, - unw_word_t start, unw_word_t end) -{ - struct unw_debug_frame_list *w, *fdesc = 0; - char path[PATH_MAX]; - char *name = path; - int err; - char *buf; - size_t bufsize; - - /* First, see if we loaded this frame already. */ - - for (w = as->debug_frames; w; w = w->next) - { - Debug (4, "checking %p: %lx-%lx\n", w, (long)w->start, (long)w->end); - if (addr >= w->start && addr < w->end) - return w; - } - - /* If the object name we receive is blank, there's still a chance of locating - the file by parsing /proc/self/maps. */ - - if (strcmp (dlname, "") == 0) - { - err = find_binary_for_address (addr, name, sizeof(path)); - if (err) - { - Debug (15, "tried to locate binary for 0x%" PRIx64 ", but no luck\n", - (uint64_t) addr); - return 0; - } - } - else - name = (char*) dlname; - - err = load_debug_frame (name, &buf, &bufsize, as == unw_local_addr_space); - - if (!err) - { - fdesc = malloc (sizeof (struct unw_debug_frame_list)); - - fdesc->start = start; - fdesc->end = end; - fdesc->debug_frame = buf; - fdesc->debug_frame_size = bufsize; - fdesc->index = NULL; - fdesc->next = as->debug_frames; - - as->debug_frames = fdesc; - } - - return fdesc; -} - -struct debug_frame_tab - { - struct table_entry *tab; - uint32_t length; - uint32_t size; - }; - -static void -debug_frame_tab_append (struct debug_frame_tab *tab, - unw_word_t fde_offset, unw_word_t start_ip) -{ - unsigned int length = tab->length; - - if (length == tab->size) - { - tab->size *= 2; - tab->tab = realloc (tab->tab, sizeof (struct table_entry) * tab->size); - } - - tab->tab[length].fde_offset = fde_offset; - tab->tab[length].start_ip_offset = start_ip; - - tab->length = length + 1; -} - -static void -debug_frame_tab_shrink (struct debug_frame_tab *tab) -{ - if (tab->size > tab->length) - { - tab->tab = realloc (tab->tab, sizeof (struct table_entry) * tab->length); - tab->size = tab->length; - } -} - -static int -debug_frame_tab_compare (const void *a, const void *b) -{ - const struct table_entry *fa = a, *fb = b; - - if (fa->start_ip_offset > fb->start_ip_offset) - return 1; - else if (fa->start_ip_offset < fb->start_ip_offset) - return -1; - else - return 0; -} - -HIDDEN int -dwarf_find_debug_frame (int found, unw_dyn_info_t *di_debug, unw_word_t ip, - unw_word_t segbase, const char* obj_name, - unw_word_t start, unw_word_t end) -{ - unw_dyn_info_t *di; - struct unw_debug_frame_list *fdesc = 0; - unw_accessors_t *a; - unw_word_t addr; - - Debug (15, "Trying to find .debug_frame for %s\n", obj_name); - di = di_debug; - - fdesc = locate_debug_info (unw_local_addr_space, ip, obj_name, start, end); - - if (!fdesc) - { - Debug (15, "couldn't load .debug_frame\n"); - return found; - } - else - { - char *buf; - size_t bufsize; - unw_word_t item_start, item_end = 0; - uint32_t u32val = 0; - uint64_t cie_id = 0; - struct debug_frame_tab tab; - - Debug (15, "loaded .debug_frame\n"); - - buf = fdesc->debug_frame; - bufsize = fdesc->debug_frame_size; - - if (bufsize == 0) - { - Debug (15, "zero-length .debug_frame\n"); - return found; - } - - /* Now create a binary-search table, if it does not already exist. */ - if (!fdesc->index) - { - addr = (unw_word_t) (uintptr_t) buf; - - a = unw_get_accessors_int (unw_local_addr_space); - - /* Find all FDE entries in debug_frame, and make into a sorted - index. */ - - tab.length = 0; - tab.size = 16; - tab.tab = calloc (tab.size, sizeof (struct table_entry)); - - while (addr < (unw_word_t) (uintptr_t) (buf + bufsize)) - { - uint64_t id_for_cie; - item_start = addr; - - dwarf_readu32 (unw_local_addr_space, a, &addr, &u32val, NULL); - - if (u32val == 0) - break; - else if (u32val != 0xffffffff) - { - uint32_t cie_id32 = 0; - item_end = addr + u32val; - dwarf_readu32 (unw_local_addr_space, a, &addr, &cie_id32, - NULL); - cie_id = cie_id32; - id_for_cie = 0xffffffff; - } - else - { - uint64_t u64val = 0; - /* Extended length. */ - dwarf_readu64 (unw_local_addr_space, a, &addr, &u64val, NULL); - item_end = addr + u64val; - - dwarf_readu64 (unw_local_addr_space, a, &addr, &cie_id, NULL); - id_for_cie = 0xffffffffffffffffull; - } - - /*Debug (1, "CIE/FDE id = %.8x\n", (int) cie_id);*/ - - if (cie_id == id_for_cie) - ; - /*Debug (1, "Found CIE at %.8x.\n", item_start);*/ - else - { - unw_word_t fde_addr = item_start; - unw_proc_info_t this_pi; - int err; - - /*Debug (1, "Found FDE at %.8x\n", item_start);*/ - - err = dwarf_extract_proc_info_from_fde (unw_local_addr_space, - a, &fde_addr, - &this_pi, - (uintptr_t) buf, 0, 1, - NULL); - if (err == 0) - { - Debug (15, "start_ip = %lx, end_ip = %lx\n", - (long) this_pi.start_ip, (long) this_pi.end_ip); - debug_frame_tab_append (&tab, - item_start - (unw_word_t) (uintptr_t) buf, - this_pi.start_ip); - } - /*else - Debug (1, "FDE parse failed\n");*/ - } - - addr = item_end; - } - - debug_frame_tab_shrink (&tab); - qsort (tab.tab, tab.length, sizeof (struct table_entry), - debug_frame_tab_compare); - /* for (i = 0; i < tab.length; i++) - { - fprintf (stderr, "ip %x, fde offset %x\n", - (int) tab.tab[i].start_ip_offset, - (int) tab.tab[i].fde_offset); - }*/ - fdesc->index = tab.tab; - fdesc->index_size = tab.length; - } - - di->format = UNW_INFO_FORMAT_TABLE; - di->start_ip = fdesc->start; - di->end_ip = fdesc->end; - di->u.ti.name_ptr = (unw_word_t) (uintptr_t) obj_name; - di->u.ti.table_data = (unw_word_t *) fdesc; - di->u.ti.table_len = sizeof (*fdesc) / sizeof (unw_word_t); - di->u.ti.segbase = segbase; - - found = 1; - Debug (15, "found debug_frame table `%s': segbase=0x%lx, len=%lu, " - "gp=0x%lx, table_data=0x%lx\n", - (char *) (uintptr_t) di->u.ti.name_ptr, - (long) di->u.ti.segbase, (long) di->u.ti.table_len, - (long) di->gp, (long) di->u.ti.table_data); - } - return found; -} - -#endif /* CONFIG_DEBUG_FRAME */ - -#ifndef UNW_REMOTE_ONLY - -static Elf_W (Addr) -dwarf_find_eh_frame_section(struct dl_phdr_info *info) -{ - int rc; - struct elf_image ei; - Elf_W (Addr) eh_frame = 0; - Elf_W (Shdr)* shdr; - const char *file = info->dlpi_name; - char exepath[PATH_MAX]; - - if (strlen(file) == 0) - { - tdep_get_exe_image_path(exepath); - file = exepath; - } - - Debug (1, "looking for .eh_frame section in %s\n", - file); - - rc = elf_map_image (&ei, file); - if (rc != 0) - return 0; - - shdr = elf_w (find_section) (&ei, ".eh_frame"); - if (!shdr) - goto out; - - eh_frame = shdr->sh_addr + info->dlpi_addr; - Debug (4, "found .eh_frame at address %lx\n", - eh_frame); - -out: - munmap (ei.image, ei.size); - - return eh_frame; -} - -struct dwarf_callback_data - { - /* in: */ - unw_word_t ip; /* instruction-pointer we're looking for */ - unw_proc_info_t *pi; /* proc-info pointer */ - int need_unwind_info; - /* out: */ - int single_fde; /* did we find a single FDE? (vs. a table) */ - unw_dyn_info_t di; /* table info (if single_fde is false) */ - unw_dyn_info_t di_debug; /* additional table info for .debug_frame */ - }; - -/* ptr is a pointer to a dwarf_callback_data structure and, on entry, - member ip contains the instruction-pointer we're looking - for. */ -HIDDEN int -dwarf_callback (struct dl_phdr_info *info, size_t size, void *ptr) -{ - struct dwarf_callback_data *cb_data = ptr; - unw_dyn_info_t *di = &cb_data->di; - const Elf_W(Phdr) *phdr, *p_eh_hdr, *p_dynamic, *p_text; - unw_word_t addr, eh_frame_start, eh_frame_end, fde_count, ip; - Elf_W(Addr) load_base, max_load_addr = 0; - int ret, need_unwind_info = cb_data->need_unwind_info; - unw_proc_info_t *pi = cb_data->pi; - struct dwarf_eh_frame_hdr *hdr = NULL; - unw_accessors_t *a; - long n; - int found = 0; - struct dwarf_eh_frame_hdr synth_eh_frame_hdr; -#ifdef CONFIG_DEBUG_FRAME - unw_word_t start, end; -#endif /* CONFIG_DEBUG_FRAME*/ - - ip = cb_data->ip; - - /* Make sure struct dl_phdr_info is at least as big as we need. */ - if (size < offsetof (struct dl_phdr_info, dlpi_phnum) - + sizeof (info->dlpi_phnum)) - return -1; - - Debug (15, "checking %s, base=0x%lx)\n", - info->dlpi_name, (long) info->dlpi_addr); - - phdr = info->dlpi_phdr; - load_base = info->dlpi_addr; - p_text = NULL; - p_eh_hdr = NULL; - p_dynamic = NULL; - - /* See if PC falls into one of the loaded segments. Find the - eh-header segment at the same time. */ - for (n = info->dlpi_phnum; --n >= 0; phdr++) - { - if (phdr->p_type == PT_LOAD) - { - Elf_W(Addr) vaddr = phdr->p_vaddr + load_base; - - if (ip >= vaddr && ip < vaddr + phdr->p_memsz) - p_text = phdr; - - if (vaddr + phdr->p_filesz > max_load_addr) - max_load_addr = vaddr + phdr->p_filesz; - } - else if (phdr->p_type == PT_GNU_EH_FRAME) - p_eh_hdr = phdr; - else if (phdr->p_type == PT_DYNAMIC) - p_dynamic = phdr; - } - - if (!p_text) - return 0; - - if (p_eh_hdr) - { - hdr = (struct dwarf_eh_frame_hdr *) (p_eh_hdr->p_vaddr + load_base); - } - else - { - Elf_W (Addr) eh_frame; - Debug (1, "no .eh_frame_hdr section found\n"); - eh_frame = dwarf_find_eh_frame_section (info); - if (eh_frame) - { - Debug (1, "using synthetic .eh_frame_hdr section for %s\n", - info->dlpi_name); - synth_eh_frame_hdr.version = DW_EH_VERSION; - synth_eh_frame_hdr.eh_frame_ptr_enc = DW_EH_PE_absptr | - ((sizeof(Elf_W (Addr)) == 4) ? DW_EH_PE_udata4 : DW_EH_PE_udata8); - synth_eh_frame_hdr.fde_count_enc = DW_EH_PE_omit; - synth_eh_frame_hdr.table_enc = DW_EH_PE_omit; - synth_eh_frame_hdr.eh_frame = eh_frame; - hdr = &synth_eh_frame_hdr; - } - } - - if (hdr) - { - if (p_dynamic) - { - /* For dynamicly linked executables and shared libraries, - DT_PLTGOT is the value that data-relative addresses are - relative to for that object. We call this the "gp". */ - Elf_W(Dyn) *dyn = (Elf_W(Dyn) *)(p_dynamic->p_vaddr + load_base); - for (; dyn->d_tag != DT_NULL; ++dyn) - if (dyn->d_tag == DT_PLTGOT) - { - /* Assume that _DYNAMIC is writable and GLIBC has - relocated it (true for x86 at least). */ - di->gp = dyn->d_un.d_ptr; - break; - } - } - else - /* Otherwise this is a static executable with no _DYNAMIC. Assume - that data-relative addresses are relative to 0, i.e., - absolute. */ - di->gp = 0; - pi->gp = di->gp; - - if (hdr->version != DW_EH_VERSION) - { - Debug (1, "table `%s' has unexpected version %d\n", - info->dlpi_name, hdr->version); - return 0; - } - - a = unw_get_accessors_int (unw_local_addr_space); - addr = (unw_word_t) (uintptr_t) (&hdr->eh_frame); - - /* (Optionally) read eh_frame_ptr: */ - if ((ret = dwarf_read_encoded_pointer (unw_local_addr_space, a, - &addr, hdr->eh_frame_ptr_enc, pi, - &eh_frame_start, NULL)) < 0) - return ret; - - /* (Optionally) read fde_count: */ - if ((ret = dwarf_read_encoded_pointer (unw_local_addr_space, a, - &addr, hdr->fde_count_enc, pi, - &fde_count, NULL)) < 0) - return ret; - - if (hdr->table_enc != (DW_EH_PE_datarel | DW_EH_PE_sdata4)) - { - /* If there is no search table or it has an unsupported - encoding, fall back on linear search. */ - if (hdr->table_enc == DW_EH_PE_omit) - Debug (4, "table `%s' lacks search table; doing linear search\n", - info->dlpi_name); - else - Debug (4, "table `%s' has encoding 0x%x; doing linear search\n", - info->dlpi_name, hdr->table_enc); - - eh_frame_end = max_load_addr; /* XXX can we do better? */ - - if (hdr->fde_count_enc == DW_EH_PE_omit) - fde_count = ~0UL; - if (hdr->eh_frame_ptr_enc == DW_EH_PE_omit) - abort (); - - Debug (1, "eh_frame_start = %lx eh_frame_end = %lx\n", - eh_frame_start, eh_frame_end); - - /* XXX we know how to build a local binary search table for - .debug_frame, so we could do that here too. */ - found = linear_search (unw_local_addr_space, ip, - eh_frame_start, eh_frame_end, fde_count, - pi, need_unwind_info, NULL); - if (found != 1) - found = 0; - else - cb_data->single_fde = 1; - } - else - { - di->format = UNW_INFO_FORMAT_REMOTE_TABLE; - di->start_ip = p_text->p_vaddr + load_base; - di->end_ip = p_text->p_vaddr + load_base + p_text->p_memsz; - di->u.rti.name_ptr = (unw_word_t) (uintptr_t) info->dlpi_name; - di->u.rti.table_data = addr; - assert (sizeof (struct table_entry) % sizeof (unw_word_t) == 0); - di->u.rti.table_len = (fde_count * sizeof (struct table_entry) - / sizeof (unw_word_t)); - /* For the binary-search table in the eh_frame_hdr, data-relative - means relative to the start of that section... */ - di->u.rti.segbase = (unw_word_t) (uintptr_t) hdr; - - found = 1; - Debug (15, "found table `%s': segbase=0x%lx, len=%lu, gp=0x%lx, " - "table_data=0x%lx\n", (char *) (uintptr_t) di->u.rti.name_ptr, - (long) di->u.rti.segbase, (long) di->u.rti.table_len, - (long) di->gp, (long) di->u.rti.table_data); - } - } - -#ifdef CONFIG_DEBUG_FRAME - /* Find the start/end of the described region by parsing the phdr_info - structure. */ - start = (unw_word_t) -1; - end = 0; - - for (n = 0; n < info->dlpi_phnum; n++) - { - if (info->dlpi_phdr[n].p_type == PT_LOAD) - { - unw_word_t seg_start = info->dlpi_addr + info->dlpi_phdr[n].p_vaddr; - unw_word_t seg_end = seg_start + info->dlpi_phdr[n].p_memsz; - - if (seg_start < start) - start = seg_start; - - if (seg_end > end) - end = seg_end; - } - } - - found = dwarf_find_debug_frame (found, &cb_data->di_debug, ip, - info->dlpi_addr, info->dlpi_name, start, - end); -#endif /* CONFIG_DEBUG_FRAME */ - - return found; -} - -HIDDEN int -dwarf_find_proc_info (unw_addr_space_t as, unw_word_t ip, - unw_proc_info_t *pi, int need_unwind_info, void *arg) -{ - struct dwarf_callback_data cb_data; - intrmask_t saved_mask; - int ret; - - Debug (14, "looking for IP=0x%lx\n", (long) ip); - - memset (&cb_data, 0, sizeof (cb_data)); - cb_data.ip = ip; - cb_data.pi = pi; - cb_data.need_unwind_info = need_unwind_info; - cb_data.di.format = -1; - cb_data.di_debug.format = -1; - - SIGPROCMASK (SIG_SETMASK, &unwi_full_mask, &saved_mask); - ret = dl_iterate_phdr (dwarf_callback, &cb_data); - SIGPROCMASK (SIG_SETMASK, &saved_mask, NULL); - - if (ret > 0) - { - if (cb_data.single_fde) - /* already got the result in *pi */ - return 0; - - /* search the table: */ - if (cb_data.di.format != -1) - ret = dwarf_search_unwind_table_int (as, ip, &cb_data.di, - pi, need_unwind_info, arg); - else - ret = -UNW_ENOINFO; - - if (ret == -UNW_ENOINFO && cb_data.di_debug.format != -1) - ret = dwarf_search_unwind_table_int (as, ip, &cb_data.di_debug, pi, - need_unwind_info, arg); - } - else - ret = -UNW_ENOINFO; - - return ret; -} - -static inline const struct table_entry * -lookup (const struct table_entry *table, size_t table_size, int32_t rel_ip) -{ - unsigned long table_len = table_size / sizeof (struct table_entry); - const struct table_entry *e = NULL; - unsigned long lo, hi, mid; - - /* do a binary search for right entry: */ - for (lo = 0, hi = table_len; lo < hi;) - { - mid = (lo + hi) / 2; - e = table + mid; - Debug (15, "e->start_ip_offset = %lx\n", (long) e->start_ip_offset); - if (rel_ip < e->start_ip_offset) - hi = mid; - else - lo = mid + 1; - } - if (hi <= 0) - return NULL; - e = table + hi - 1; - return e; -} - -#endif /* !UNW_REMOTE_ONLY */ - -#ifndef UNW_LOCAL_ONLY - -/* Lookup an unwind-table entry in remote memory. Returns 1 if an - entry is found, 0 if no entry is found, negative if an error - occurred reading remote memory. */ -static int -remote_lookup (unw_addr_space_t as, - unw_word_t table, size_t table_size, int32_t rel_ip, - struct table_entry *e, int32_t *last_ip_offset, void *arg) -{ - unsigned long table_len = table_size / sizeof (struct table_entry); - unw_accessors_t *a = unw_get_accessors_int (as); - unsigned long lo, hi, mid; - unw_word_t e_addr = 0; - int32_t start = 0; - int ret; - - /* do a binary search for right entry: */ - for (lo = 0, hi = table_len; lo < hi;) - { - mid = (lo + hi) / 2; - e_addr = table + mid * sizeof (struct table_entry); - if ((ret = dwarf_reads32 (as, a, &e_addr, &start, arg)) < 0) - return ret; - - if (rel_ip < start) - hi = mid; - else - lo = mid + 1; - } - if (hi <= 0) - return 0; - e_addr = table + (hi - 1) * sizeof (struct table_entry); - if ((ret = dwarf_reads32 (as, a, &e_addr, &e->start_ip_offset, arg)) < 0 - || (ret = dwarf_reads32 (as, a, &e_addr, &e->fde_offset, arg)) < 0 - || (hi < table_len && - (ret = dwarf_reads32 (as, a, &e_addr, last_ip_offset, arg)) < 0)) - return ret; - return 1; -} - -#endif /* !UNW_LOCAL_ONLY */ - -static int is_remote_table(int format) -{ - return (format == UNW_INFO_FORMAT_REMOTE_TABLE || - format == UNW_INFO_FORMAT_IP_OFFSET); -} - -int -dwarf_search_unwind_table (unw_addr_space_t as, unw_word_t ip, - unw_dyn_info_t *di, unw_proc_info_t *pi, - int need_unwind_info, void *arg) -{ - const struct table_entry *e = NULL, *table; - unw_word_t ip_base = 0, segbase = 0, last_ip, fde_addr; - unw_accessors_t *a; -#ifndef UNW_LOCAL_ONLY - struct table_entry ent; -#endif - int ret; - unw_word_t debug_frame_base; - size_t table_len; - -#ifdef UNW_REMOTE_ONLY - assert (is_remote_table(di->format)); -#else - assert (is_remote_table(di->format) - || di->format == UNW_INFO_FORMAT_TABLE); -#endif - assert (ip >= di->start_ip && ip < di->end_ip); - - if (is_remote_table(di->format)) - { - table = (const struct table_entry *) (uintptr_t) di->u.rti.table_data; - table_len = di->u.rti.table_len * sizeof (unw_word_t); - debug_frame_base = 0; - } - else - { - assert(di->format == UNW_INFO_FORMAT_TABLE); -#ifndef UNW_REMOTE_ONLY - struct unw_debug_frame_list *fdesc = (void *) di->u.ti.table_data; - - /* UNW_INFO_FORMAT_TABLE (i.e. .debug_frame) is read from local address - space. Both the index and the unwind tables live in local memory, but - the address space to check for properties like the address size and - endianness is the target one. */ - as = unw_local_addr_space; - table = fdesc->index; - table_len = fdesc->index_size * sizeof (struct table_entry); - debug_frame_base = (uintptr_t) fdesc->debug_frame; -#endif - } - - a = unw_get_accessors_int (as); - - segbase = di->u.rti.segbase; - if (di->format == UNW_INFO_FORMAT_IP_OFFSET) { - ip_base = di->start_ip; - } else { - ip_base = segbase; - } - -#ifndef UNW_REMOTE_ONLY - if (as == unw_local_addr_space) - { - e = lookup (table, table_len, ip - ip_base); - if (e && &e[1] < &table[table_len]) - last_ip = e[1].start_ip_offset + ip_base; - else - last_ip = di->end_ip; - } - else -#endif - { -#ifndef UNW_LOCAL_ONLY - int32_t last_ip_offset = di->end_ip - ip_base; - segbase = di->u.rti.segbase; - if ((ret = remote_lookup (as, (uintptr_t) table, table_len, - ip - ip_base, &ent, &last_ip_offset, arg)) < 0) - return ret; - if (ret) - { - e = &ent; - last_ip = last_ip_offset + ip_base; - } - else - e = NULL; /* no info found */ -#endif - } - if (!e) - { - Debug (1, "IP %lx inside range %lx-%lx, but no explicit unwind info found\n", - (long) ip, (long) di->start_ip, (long) di->end_ip); - /* IP is inside this table's range, but there is no explicit - unwind info. */ - return -UNW_ENOINFO; - } - Debug (15, "ip=0x%lx, start_ip=0x%lx\n", - (long) ip, (long) (e->start_ip_offset)); - if (debug_frame_base) - fde_addr = e->fde_offset + debug_frame_base; - else - fde_addr = e->fde_offset + segbase; - Debug (1, "e->fde_offset = %lx, segbase = %lx, debug_frame_base = %lx, " - "fde_addr = %lx\n", (long) e->fde_offset, (long) segbase, - (long) debug_frame_base, (long) fde_addr); - if ((ret = dwarf_extract_proc_info_from_fde (as, a, &fde_addr, pi, - debug_frame_base ? - debug_frame_base : segbase, - need_unwind_info, - debug_frame_base != 0, arg)) < 0) - return ret; - - /* .debug_frame uses an absolute encoding that does not know about any - shared library relocation. */ - if (di->format == UNW_INFO_FORMAT_TABLE) - { - pi->start_ip += segbase; - pi->end_ip += segbase; - pi->flags = UNW_PI_FLAG_DEBUG_FRAME; - } - -#if defined(NEED_LAST_IP) - pi->last_ip = last_ip; -#else - (void)last_ip; -#endif - if (ip < pi->start_ip || ip >= pi->end_ip) - return -UNW_ENOINFO; - - return 0; -} - -HIDDEN void -dwarf_put_unwind_info (unw_addr_space_t as, unw_proc_info_t *pi, void *arg) -{ - return; /* always a nop */ -} diff --git a/src/pal/src/libunwind/src/dwarf/Gfind_unwind_table.c b/src/pal/src/libunwind/src/dwarf/Gfind_unwind_table.c deleted file mode 100644 index 6a2ad5040..000000000 --- a/src/pal/src/libunwind/src/dwarf/Gfind_unwind_table.c +++ /dev/null @@ -1,230 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2003-2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include -#include -#include - -#include - -#include "libunwind_i.h" -#include "dwarf-eh.h" -#include "dwarf_i.h" - -#define to_unw_word(p) ((unw_word_t) (uintptr_t) (p)) - -int -dwarf_find_unwind_table (struct elf_dyn_info *edi, unw_addr_space_t as, - char *path, unw_word_t segbase, unw_word_t mapoff, - unw_word_t ip) -{ - Elf_W(Phdr) *phdr, *ptxt = NULL, *peh_hdr = NULL, *pdyn = NULL; - unw_word_t addr, eh_frame_start, fde_count, load_base; - unw_word_t max_load_addr = 0; - unw_word_t start_ip = to_unw_word (-1); - unw_word_t end_ip = 0; - struct dwarf_eh_frame_hdr *hdr; - unw_proc_info_t pi; - unw_accessors_t *a; - Elf_W(Ehdr) *ehdr; -#if UNW_TARGET_ARM - const Elf_W(Phdr) *parm_exidx = NULL; -#endif - int i, ret, found = 0; - - /* XXX: Much of this code is Linux/LSB-specific. */ - - if (!elf_w(valid_object) (&edi->ei)) - return -UNW_ENOINFO; - - ehdr = edi->ei.image; - phdr = (Elf_W(Phdr) *) ((char *) edi->ei.image + ehdr->e_phoff); - - for (i = 0; i < ehdr->e_phnum; ++i) - { - switch (phdr[i].p_type) - { - case PT_LOAD: - if (phdr[i].p_vaddr < start_ip) - start_ip = phdr[i].p_vaddr; - - if (phdr[i].p_vaddr + phdr[i].p_memsz > end_ip) - end_ip = phdr[i].p_vaddr + phdr[i].p_memsz; - - if (phdr[i].p_offset == mapoff) - ptxt = phdr + i; - if ((uintptr_t) edi->ei.image + phdr->p_filesz > max_load_addr) - max_load_addr = (uintptr_t) edi->ei.image + phdr->p_filesz; - break; - - case PT_GNU_EH_FRAME: - peh_hdr = phdr + i; - break; - - case PT_DYNAMIC: - pdyn = phdr + i; - break; - -#if UNW_TARGET_ARM - case PT_ARM_EXIDX: - parm_exidx = phdr + i; - break; -#endif - - default: - break; - } - } - - if (!ptxt) - return 0; - - load_base = segbase - ptxt->p_vaddr; - start_ip += load_base; - end_ip += load_base; - - if (peh_hdr) - { - if (pdyn) - { - /* For dynamicly linked executables and shared libraries, - DT_PLTGOT is the value that data-relative addresses are - relative to for that object. We call this the "gp". */ - Elf_W(Dyn) *dyn = (Elf_W(Dyn) *)(pdyn->p_offset - + (char *) edi->ei.image); - for (; dyn->d_tag != DT_NULL; ++dyn) - if (dyn->d_tag == DT_PLTGOT) - { - /* Assume that _DYNAMIC is writable and GLIBC has - relocated it (true for x86 at least). */ - edi->di_cache.gp = dyn->d_un.d_ptr; - break; - } - } - else - /* Otherwise this is a static executable with no _DYNAMIC. Assume - that data-relative addresses are relative to 0, i.e., - absolute. */ - edi->di_cache.gp = 0; - - hdr = (struct dwarf_eh_frame_hdr *) (peh_hdr->p_offset - + (char *) edi->ei.image); - if (hdr->version != DW_EH_VERSION) - { - Debug (1, "table `%s' has unexpected version %d\n", - path, hdr->version); - return -UNW_ENOINFO; - } - - a = unw_get_accessors_int (unw_local_addr_space); - addr = to_unw_word (&hdr->eh_frame); - - /* Fill in a dummy proc_info structure. We just need to fill in - enough to ensure that dwarf_read_encoded_pointer() can do it's - job. Since we don't have a procedure-context at this point, all - we have to do is fill in the global-pointer. */ - memset (&pi, 0, sizeof (pi)); - pi.gp = edi->di_cache.gp; - - /* (Optionally) read eh_frame_ptr: */ - if ((ret = dwarf_read_encoded_pointer (unw_local_addr_space, a, - &addr, hdr->eh_frame_ptr_enc, &pi, - &eh_frame_start, NULL)) < 0) - return -UNW_ENOINFO; - - /* (Optionally) read fde_count: */ - if ((ret = dwarf_read_encoded_pointer (unw_local_addr_space, a, - &addr, hdr->fde_count_enc, &pi, - &fde_count, NULL)) < 0) - return -UNW_ENOINFO; - - if (hdr->table_enc != (DW_EH_PE_datarel | DW_EH_PE_sdata4)) - { - #if 1 - abort (); - #else - unw_word_t eh_frame_end; - - /* If there is no search table or it has an unsupported - encoding, fall back on linear search. */ - if (hdr->table_enc == DW_EH_PE_omit) - Debug (4, "EH lacks search table; doing linear search\n"); - else - Debug (4, "EH table has encoding 0x%x; doing linear search\n", - hdr->table_enc); - - eh_frame_end = max_load_addr; /* XXX can we do better? */ - - if (hdr->fde_count_enc == DW_EH_PE_omit) - fde_count = ~0UL; - if (hdr->eh_frame_ptr_enc == DW_EH_PE_omit) - abort (); - - return linear_search (unw_local_addr_space, ip, - eh_frame_start, eh_frame_end, fde_count, - pi, need_unwind_info, NULL); - #endif - } - - edi->di_cache.start_ip = start_ip; - edi->di_cache.end_ip = end_ip; - edi->di_cache.format = UNW_INFO_FORMAT_REMOTE_TABLE; - edi->di_cache.u.rti.name_ptr = 0; - /* two 32-bit values (ip_offset/fde_offset) per table-entry: */ - edi->di_cache.u.rti.table_len = (fde_count * 8) / sizeof (unw_word_t); - edi->di_cache.u.rti.table_data = ((load_base + peh_hdr->p_vaddr) - + (addr - to_unw_word (edi->ei.image) - - peh_hdr->p_offset)); - - /* For the binary-search table in the eh_frame_hdr, data-relative - means relative to the start of that section... */ - edi->di_cache.u.rti.segbase = ((load_base + peh_hdr->p_vaddr) - + (to_unw_word (hdr) - - to_unw_word (edi->ei.image) - - peh_hdr->p_offset)); - found = 1; - } - -#if UNW_TARGET_ARM - if (parm_exidx) - { - edi->di_arm.format = UNW_INFO_FORMAT_ARM_EXIDX; - edi->di_arm.start_ip = start_ip; - edi->di_arm.end_ip = end_ip; - edi->di_arm.u.rti.name_ptr = to_unw_word (path); - edi->di_arm.u.rti.table_data = load_base + parm_exidx->p_vaddr; - edi->di_arm.u.rti.table_len = parm_exidx->p_memsz; - found = 1; - } -#endif - -#ifdef CONFIG_DEBUG_FRAME - /* Try .debug_frame. */ - found = dwarf_find_debug_frame (found, &edi->di_debug, ip, load_base, path, - start_ip, end_ip); -#endif - - return found; -} diff --git a/src/pal/src/libunwind/src/dwarf/Gparser.c b/src/pal/src/libunwind/src/dwarf/Gparser.c deleted file mode 100644 index 7d255aeea..000000000 --- a/src/pal/src/libunwind/src/dwarf/Gparser.c +++ /dev/null @@ -1,1059 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (c) 2003, 2005 Hewlett-Packard Development Company, L.P. - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include "dwarf_i.h" -#include "libunwind_i.h" -#include -#include - -#define alloc_reg_state() (mempool_alloc (&dwarf_reg_state_pool)) -#define free_reg_state(rs) (mempool_free (&dwarf_reg_state_pool, rs)) - -#define DWARF_UNW_CACHE_SIZE(log_size) (1 << log_size) -#define DWARF_UNW_HASH_SIZE(log_size) (1 << (log_size + 1)) - -static inline int -read_regnum (unw_addr_space_t as, unw_accessors_t *a, unw_word_t *addr, - unw_word_t *valp, void *arg) -{ - int ret; - - if ((ret = dwarf_read_uleb128 (as, a, addr, valp, arg)) < 0) - return ret; - - if (*valp >= DWARF_NUM_PRESERVED_REGS) - { - Debug (1, "Invalid register number %u\n", (unsigned int) *valp); - return -UNW_EBADREG; - } - return 0; -} - -static inline void -set_reg (dwarf_state_record_t *sr, unw_word_t regnum, dwarf_where_t where, - unw_word_t val) -{ - sr->rs_current.reg.where[regnum] = where; - sr->rs_current.reg.val[regnum] = val; -} - -static inline int -push_rstate_stack(dwarf_stackable_reg_state_t **rs_stack) -{ - dwarf_stackable_reg_state_t *old_rs = *rs_stack; - if (NULL == (*rs_stack = alloc_reg_state ())) - { - *rs_stack = old_rs; - return -1; - } - (*rs_stack)->next = old_rs; - return 0; -} - -static inline void -pop_rstate_stack(dwarf_stackable_reg_state_t **rs_stack) -{ - dwarf_stackable_reg_state_t *old_rs = *rs_stack; - *rs_stack = old_rs->next; - free_reg_state (old_rs); -} - -static inline void -empty_rstate_stack(dwarf_stackable_reg_state_t **rs_stack) -{ - while (*rs_stack) - pop_rstate_stack(rs_stack); -} - -/* Run a CFI program to update the register state. */ -static int -run_cfi_program (struct dwarf_cursor *c, dwarf_state_record_t *sr, - unw_word_t *ip, unw_word_t end_ip, - unw_word_t *addr, unw_word_t end_addr, - dwarf_stackable_reg_state_t **rs_stack, - struct dwarf_cie_info *dci) -{ - unw_addr_space_t as; - void *arg; - - if (c->pi.flags & UNW_PI_FLAG_DEBUG_FRAME) - { - /* .debug_frame CFI is stored in local address space. */ - as = unw_local_addr_space; - arg = NULL; - } - else - { - as = c->as; - arg = c->as_arg; - } - unw_accessors_t *a = unw_get_accessors_int (as); - int ret = 0; - - while (*ip <= end_ip && *addr < end_addr && ret >= 0) - { - unw_word_t operand = 0, regnum, val, len; - uint8_t u8, op; - uint16_t u16; - uint32_t u32; - - if ((ret = dwarf_readu8 (as, a, addr, &op, arg)) < 0) - break; - - if (op & DWARF_CFA_OPCODE_MASK) - { - operand = op & DWARF_CFA_OPERAND_MASK; - op &= ~DWARF_CFA_OPERAND_MASK; - } - switch ((dwarf_cfa_t) op) - { - case DW_CFA_advance_loc: - *ip += operand * dci->code_align; - Debug (15, "CFA_advance_loc to 0x%lx\n", (long) *ip); - break; - - case DW_CFA_advance_loc1: - if ((ret = dwarf_readu8 (as, a, addr, &u8, arg)) < 0) - break; - *ip += u8 * dci->code_align; - Debug (15, "CFA_advance_loc1 to 0x%lx\n", (long) *ip); - break; - - case DW_CFA_advance_loc2: - if ((ret = dwarf_readu16 (as, a, addr, &u16, arg)) < 0) - break; - *ip += u16 * dci->code_align; - Debug (15, "CFA_advance_loc2 to 0x%lx\n", (long) *ip); - break; - - case DW_CFA_advance_loc4: - if ((ret = dwarf_readu32 (as, a, addr, &u32, arg)) < 0) - break; - *ip += u32 * dci->code_align; - Debug (15, "CFA_advance_loc4 to 0x%lx\n", (long) *ip); - break; - - case DW_CFA_MIPS_advance_loc8: -#ifdef UNW_TARGET_MIPS - { - uint64_t u64 = 0; - - if ((ret = dwarf_readu64 (as, a, addr, &u64, arg)) < 0) - break; - *ip += u64 * dci->code_align; - Debug (15, "CFA_MIPS_advance_loc8\n"); - break; - } -#else - Debug (1, "DW_CFA_MIPS_advance_loc8 on non-MIPS target\n"); - ret = -UNW_EINVAL; - break; -#endif - - case DW_CFA_offset: - regnum = operand; - if (regnum >= DWARF_NUM_PRESERVED_REGS) - { - Debug (1, "Invalid register number %u in DW_cfa_OFFSET\n", - (unsigned int) regnum); - ret = -UNW_EBADREG; - break; - } - if ((ret = dwarf_read_uleb128 (as, a, addr, &val, arg)) < 0) - break; - set_reg (sr, regnum, DWARF_WHERE_CFAREL, val * dci->data_align); - Debug (15, "CFA_offset r%lu at cfa+0x%lx\n", - (long) regnum, (long) (val * dci->data_align)); - break; - - case DW_CFA_offset_extended: - if (((ret = read_regnum (as, a, addr, ®num, arg)) < 0) - || ((ret = dwarf_read_uleb128 (as, a, addr, &val, arg)) < 0)) - break; - set_reg (sr, regnum, DWARF_WHERE_CFAREL, val * dci->data_align); - Debug (15, "CFA_offset_extended r%lu at cf+0x%lx\n", - (long) regnum, (long) (val * dci->data_align)); - break; - - case DW_CFA_offset_extended_sf: - if (((ret = read_regnum (as, a, addr, ®num, arg)) < 0) - || ((ret = dwarf_read_sleb128 (as, a, addr, &val, arg)) < 0)) - break; - set_reg (sr, regnum, DWARF_WHERE_CFAREL, val * dci->data_align); - Debug (15, "CFA_offset_extended_sf r%lu at cf+0x%lx\n", - (long) regnum, (long) (val * dci->data_align)); - break; - - case DW_CFA_restore: - regnum = operand; - if (regnum >= DWARF_NUM_PRESERVED_REGS) - { - Debug (1, "Invalid register number %u in DW_CFA_restore\n", - (unsigned int) regnum); - ret = -UNW_EINVAL; - break; - } - sr->rs_current.reg.where[regnum] = sr->rs_initial.reg.where[regnum]; - sr->rs_current.reg.val[regnum] = sr->rs_initial.reg.val[regnum]; - Debug (15, "CFA_restore r%lu\n", (long) regnum); - break; - - case DW_CFA_restore_extended: - if ((ret = dwarf_read_uleb128 (as, a, addr, ®num, arg)) < 0) - break; - if (regnum >= DWARF_NUM_PRESERVED_REGS) - { - Debug (1, "Invalid register number %u in " - "DW_CFA_restore_extended\n", (unsigned int) regnum); - ret = -UNW_EINVAL; - break; - } - sr->rs_current.reg.where[regnum] = sr->rs_initial.reg.where[regnum]; - sr->rs_current.reg.val[regnum] = sr->rs_initial.reg.val[regnum]; - Debug (15, "CFA_restore_extended r%lu\n", (long) regnum); - break; - - case DW_CFA_nop: - break; - - case DW_CFA_set_loc: - if ((ret = dwarf_read_encoded_pointer (as, a, addr, dci->fde_encoding, - &c->pi, ip, - arg)) < 0) - break; - Debug (15, "CFA_set_loc to 0x%lx\n", (long) *ip); - break; - - case DW_CFA_undefined: - if ((ret = read_regnum (as, a, addr, ®num, arg)) < 0) - break; - set_reg (sr, regnum, DWARF_WHERE_UNDEF, 0); - Debug (15, "CFA_undefined r%lu\n", (long) regnum); - break; - - case DW_CFA_same_value: - if ((ret = read_regnum (as, a, addr, ®num, arg)) < 0) - break; - set_reg (sr, regnum, DWARF_WHERE_SAME, 0); - Debug (15, "CFA_same_value r%lu\n", (long) regnum); - break; - - case DW_CFA_register: - if (((ret = read_regnum (as, a, addr, ®num, arg)) < 0) - || ((ret = dwarf_read_uleb128 (as, a, addr, &val, arg)) < 0)) - break; - set_reg (sr, regnum, DWARF_WHERE_REG, val); - Debug (15, "CFA_register r%lu to r%lu\n", (long) regnum, (long) val); - break; - - case DW_CFA_remember_state: - if (push_rstate_stack(rs_stack) < 0) - { - Debug (1, "Out of memory in DW_CFA_remember_state\n"); - ret = -UNW_ENOMEM; - break; - } - (*rs_stack)->state = sr->rs_current; - Debug (15, "CFA_remember_state\n"); - break; - - case DW_CFA_restore_state: - if (!*rs_stack) - { - Debug (1, "register-state stack underflow\n"); - ret = -UNW_EINVAL; - break; - } - sr->rs_current = (*rs_stack)->state; - pop_rstate_stack(rs_stack); - Debug (15, "CFA_restore_state\n"); - break; - - case DW_CFA_def_cfa: - if (((ret = read_regnum (as, a, addr, ®num, arg)) < 0) - || ((ret = dwarf_read_uleb128 (as, a, addr, &val, arg)) < 0)) - break; - set_reg (sr, DWARF_CFA_REG_COLUMN, DWARF_WHERE_REG, regnum); - set_reg (sr, DWARF_CFA_OFF_COLUMN, 0, val); /* NOT factored! */ - Debug (15, "CFA_def_cfa r%lu+0x%lx\n", (long) regnum, (long) val); - break; - - case DW_CFA_def_cfa_sf: - if (((ret = read_regnum (as, a, addr, ®num, arg)) < 0) - || ((ret = dwarf_read_sleb128 (as, a, addr, &val, arg)) < 0)) - break; - set_reg (sr, DWARF_CFA_REG_COLUMN, DWARF_WHERE_REG, regnum); - set_reg (sr, DWARF_CFA_OFF_COLUMN, 0, - val * dci->data_align); /* factored! */ - Debug (15, "CFA_def_cfa_sf r%lu+0x%lx\n", - (long) regnum, (long) (val * dci->data_align)); - break; - - case DW_CFA_def_cfa_register: - if ((ret = read_regnum (as, a, addr, ®num, arg)) < 0) - break; - set_reg (sr, DWARF_CFA_REG_COLUMN, DWARF_WHERE_REG, regnum); - Debug (15, "CFA_def_cfa_register r%lu\n", (long) regnum); - break; - - case DW_CFA_def_cfa_offset: - if ((ret = dwarf_read_uleb128 (as, a, addr, &val, arg)) < 0) - break; - set_reg (sr, DWARF_CFA_OFF_COLUMN, 0, val); /* NOT factored! */ - Debug (15, "CFA_def_cfa_offset 0x%lx\n", (long) val); - break; - - case DW_CFA_def_cfa_offset_sf: - if ((ret = dwarf_read_sleb128 (as, a, addr, &val, arg)) < 0) - break; - set_reg (sr, DWARF_CFA_OFF_COLUMN, 0, - val * dci->data_align); /* factored! */ - Debug (15, "CFA_def_cfa_offset_sf 0x%lx\n", - (long) (val * dci->data_align)); - break; - - case DW_CFA_def_cfa_expression: - /* Save the address of the DW_FORM_block for later evaluation. */ - set_reg (sr, DWARF_CFA_REG_COLUMN, DWARF_WHERE_EXPR, *addr); - - if ((ret = dwarf_read_uleb128 (as, a, addr, &len, arg)) < 0) - break; - - Debug (15, "CFA_def_cfa_expr @ 0x%lx [%lu bytes]\n", - (long) *addr, (long) len); - *addr += len; - break; - - case DW_CFA_expression: - if ((ret = read_regnum (as, a, addr, ®num, arg)) < 0) - break; - - /* Save the address of the DW_FORM_block for later evaluation. */ - set_reg (sr, regnum, DWARF_WHERE_EXPR, *addr); - - if ((ret = dwarf_read_uleb128 (as, a, addr, &len, arg)) < 0) - break; - - Debug (15, "CFA_expression r%lu @ 0x%lx [%lu bytes]\n", - (long) regnum, (long) addr, (long) len); - *addr += len; - break; - - case DW_CFA_val_expression: - if ((ret = read_regnum (as, a, addr, ®num, arg)) < 0) - break; - - /* Save the address of the DW_FORM_block for later evaluation. */ - set_reg (sr, regnum, DWARF_WHERE_VAL_EXPR, *addr); - - if ((ret = dwarf_read_uleb128 (as, a, addr, &len, arg)) < 0) - break; - - Debug (15, "CFA_val_expression r%lu @ 0x%lx [%lu bytes]\n", - (long) regnum, (long) addr, (long) len); - *addr += len; - break; - - case DW_CFA_GNU_args_size: - if ((ret = dwarf_read_uleb128 (as, a, addr, &val, arg)) < 0) - break; - sr->args_size = val; - Debug (15, "CFA_GNU_args_size %lu\n", (long) val); - break; - - case DW_CFA_GNU_negative_offset_extended: - /* A comment in GCC says that this is obsoleted by - DW_CFA_offset_extended_sf, but that it's used by older - PowerPC code. */ - if (((ret = read_regnum (as, a, addr, ®num, arg)) < 0) - || ((ret = dwarf_read_uleb128 (as, a, addr, &val, arg)) < 0)) - break; - set_reg (sr, regnum, DWARF_WHERE_CFAREL, -(val * dci->data_align)); - Debug (15, "CFA_GNU_negative_offset_extended cfa+0x%lx\n", - (long) -(val * dci->data_align)); - break; - - case DW_CFA_GNU_window_save: -#ifdef UNW_TARGET_SPARC - /* This is a special CFA to handle all 16 windowed registers - on SPARC. */ - for (regnum = 16; regnum < 32; ++regnum) - set_reg (sr, regnum, DWARF_WHERE_CFAREL, - (regnum - 16) * sizeof (unw_word_t)); - Debug (15, "CFA_GNU_window_save\n"); - break; -#else - /* FALL THROUGH */ -#endif - case DW_CFA_lo_user: - case DW_CFA_hi_user: - Debug (1, "Unexpected CFA opcode 0x%x\n", op); - ret = -UNW_EINVAL; - break; - } - } - - if (ret > 0) - ret = 0; - return ret; -} - -static int -fetch_proc_info (struct dwarf_cursor *c, unw_word_t ip) -{ - int ret, dynamic = 1; - - /* The 'ip' can point either to the previous or next instruction - depending on what type of frame we have: normal call or a place - to resume execution (e.g. after signal frame). - - For a normal call frame we need to back up so we point within the - call itself; this is important because a) the call might be the - very last instruction of the function and the edge of the FDE, - and b) so that run_cfi_program() runs locations up to the call - but not more. - - For signal frame, we need to do the exact opposite and look - up using the current 'ip' value. That is where execution will - continue, and it's important we get this right, as 'ip' could be - right at the function entry and hence FDE edge, or at instruction - that manipulates CFA (push/pop). */ - if (c->use_prev_instr) - --ip; - - memset (&c->pi, 0, sizeof (c->pi)); - - /* check dynamic info first --- it overrides everything else */ - ret = unwi_find_dynamic_proc_info (c->as, ip, &c->pi, 1, - c->as_arg); - if (ret == -UNW_ENOINFO) - { - dynamic = 0; - if ((ret = tdep_find_proc_info (c, ip, 1)) < 0) - return ret; - } - - if (c->pi.format != UNW_INFO_FORMAT_DYNAMIC - && c->pi.format != UNW_INFO_FORMAT_TABLE - && c->pi.format != UNW_INFO_FORMAT_REMOTE_TABLE) - return -UNW_ENOINFO; - - c->pi_valid = 1; - c->pi_is_dynamic = dynamic; - - /* Let system/machine-dependent code determine frame-specific attributes. */ - if (ret >= 0) - tdep_fetch_frame (c, ip, 1); - - return ret; -} - -static int -parse_dynamic (struct dwarf_cursor *c, unw_word_t ip, dwarf_state_record_t *sr) -{ - Debug (1, "Not yet implemented\n"); - return -UNW_ENOINFO; -} - -static inline void -put_unwind_info (struct dwarf_cursor *c, unw_proc_info_t *pi) -{ - if (c->pi_is_dynamic) - unwi_put_dynamic_unwind_info (c->as, pi, c->as_arg); - else if (pi->unwind_info && pi->format == UNW_INFO_FORMAT_TABLE) - { - mempool_free (&dwarf_cie_info_pool, pi->unwind_info); - pi->unwind_info = NULL; - } - c->pi_valid = 0; -} - -static inline int -setup_fde (struct dwarf_cursor *c, dwarf_state_record_t *sr) -{ - int i, ret; - - assert (c->pi_valid); - - memset (sr, 0, sizeof (*sr)); - for (i = 0; i < DWARF_NUM_PRESERVED_REGS + 2; ++i) - set_reg (sr, i, DWARF_WHERE_SAME, 0); - - struct dwarf_cie_info *dci = c->pi.unwind_info; - sr->rs_current.ret_addr_column = dci->ret_addr_column; - unw_word_t addr = dci->cie_instr_start; - unw_word_t curr_ip = 0; - dwarf_stackable_reg_state_t *rs_stack = NULL; - ret = run_cfi_program (c, sr, &curr_ip, ~(unw_word_t) 0, &addr, - dci->cie_instr_end, - &rs_stack, dci); - empty_rstate_stack(&rs_stack); - if (ret < 0) - return ret; - - memcpy (&sr->rs_initial, &sr->rs_current, sizeof (sr->rs_initial)); - return 0; -} - -static inline int -parse_fde (struct dwarf_cursor *c, unw_word_t ip, dwarf_state_record_t *sr) -{ - int ret; - struct dwarf_cie_info *dci = c->pi.unwind_info; - unw_word_t addr = dci->fde_instr_start; - unw_word_t curr_ip = c->pi.start_ip; - dwarf_stackable_reg_state_t *rs_stack = NULL; - /* Process up to current `ip` for signal frame and `ip - 1` for normal call frame - See `c->use_prev_instr` use in `fetch_proc_info` for details. */ - ret = run_cfi_program (c, sr, &curr_ip, ip - c->use_prev_instr, &addr, dci->fde_instr_end, - &rs_stack, dci); - empty_rstate_stack(&rs_stack); - if (ret < 0) - return ret; - - return 0; -} - -HIDDEN int -dwarf_flush_rs_cache (struct dwarf_rs_cache *cache) -{ - int i; - - if (cache->log_size == DWARF_DEFAULT_LOG_UNW_CACHE_SIZE - || !cache->hash) { - cache->hash = cache->default_hash; - cache->buckets = cache->default_buckets; - cache->links = cache->default_links; - cache->log_size = DWARF_DEFAULT_LOG_UNW_CACHE_SIZE; - } else { - if (cache->hash && cache->hash != cache->default_hash) - munmap(cache->hash, DWARF_UNW_HASH_SIZE(cache->prev_log_size) - * sizeof (cache->hash[0])); - if (cache->buckets && cache->buckets != cache->default_buckets) - munmap(cache->buckets, DWARF_UNW_CACHE_SIZE(cache->prev_log_size) - * sizeof (cache->buckets[0])); - if (cache->links && cache->links != cache->default_links) - munmap(cache->links, DWARF_UNW_CACHE_SIZE(cache->prev_log_size) - * sizeof (cache->links[0])); - GET_MEMORY(cache->hash, DWARF_UNW_HASH_SIZE(cache->log_size) - * sizeof (cache->hash[0])); - GET_MEMORY(cache->buckets, DWARF_UNW_CACHE_SIZE(cache->log_size) - * sizeof (cache->buckets[0])); - GET_MEMORY(cache->links, DWARF_UNW_CACHE_SIZE(cache->log_size) - * sizeof (cache->links[0])); - if (!cache->hash || !cache->buckets || !cache->links) - { - Debug (1, "Unable to allocate cache memory"); - return -UNW_ENOMEM; - } - cache->prev_log_size = cache->log_size; - } - - cache->rr_head = 0; - - for (i = 0; i < DWARF_UNW_CACHE_SIZE(cache->log_size); ++i) - { - cache->links[i].coll_chain = -1; - cache->links[i].ip = 0; - cache->links[i].valid = 0; - } - for (i = 0; i< DWARF_UNW_HASH_SIZE(cache->log_size); ++i) - cache->hash[i] = -1; - - return 0; -} - -static inline struct dwarf_rs_cache * -get_rs_cache (unw_addr_space_t as, intrmask_t *saved_maskp) -{ - struct dwarf_rs_cache *cache = &as->global_cache; - unw_caching_policy_t caching = as->caching_policy; - - if (caching == UNW_CACHE_NONE) - return NULL; - -#if defined(HAVE___THREAD) && HAVE___THREAD - if (likely (caching == UNW_CACHE_PER_THREAD)) - { - static __thread struct dwarf_rs_cache tls_cache __attribute__((tls_model("initial-exec"))); - Debug (16, "using TLS cache\n"); - cache = &tls_cache; - } - else -#else - if (likely (caching == UNW_CACHE_GLOBAL)) -#endif - { - Debug (16, "acquiring lock\n"); - lock_acquire (&cache->lock, *saved_maskp); - } - - if ((atomic_read (&as->cache_generation) != atomic_read (&cache->generation)) - || !cache->hash) - { - /* cache_size is only set in the global_cache, copy it over before flushing */ - cache->log_size = as->global_cache.log_size; - if (dwarf_flush_rs_cache (cache) < 0) - return NULL; - cache->generation = as->cache_generation; - } - - return cache; -} - -static inline void -put_rs_cache (unw_addr_space_t as, struct dwarf_rs_cache *cache, - intrmask_t *saved_maskp) -{ - assert (as->caching_policy != UNW_CACHE_NONE); - - Debug (16, "unmasking signals/interrupts and releasing lock\n"); - if (likely (as->caching_policy == UNW_CACHE_GLOBAL)) - lock_release (&cache->lock, *saved_maskp); -} - -static inline unw_hash_index_t CONST_ATTR -hash (unw_word_t ip, unsigned short log_size) -{ - /* based on (sqrt(5)/2-1)*2^64 */ -# define magic ((unw_word_t) 0x9e3779b97f4a7c16ULL) - - return ip * magic >> ((sizeof(unw_word_t) * 8) - (log_size + 1)); -} - -static inline long -cache_match (struct dwarf_rs_cache *cache, unsigned short index, unw_word_t ip) -{ - return (cache->links[index].valid && (ip == cache->links[index].ip)); -} - -static dwarf_reg_state_t * -rs_lookup (struct dwarf_rs_cache *cache, struct dwarf_cursor *c) -{ - unsigned short index; - unw_word_t ip = c->ip; - - if (c->hint > 0) - { - index = c->hint - 1; - if (cache_match (cache, index, ip)) - return &cache->buckets[index]; - } - - for (index = cache->hash[hash (ip, cache->log_size)]; - index < DWARF_UNW_CACHE_SIZE(cache->log_size); - index = cache->links[index].coll_chain) - { - if (cache_match (cache, index, ip)) - return &cache->buckets[index]; - } - return NULL; -} - -static inline dwarf_reg_state_t * -rs_new (struct dwarf_rs_cache *cache, struct dwarf_cursor * c) -{ - unw_hash_index_t index; - unsigned short head; - - head = cache->rr_head; - cache->rr_head = (head + 1) & (DWARF_UNW_CACHE_SIZE(cache->log_size) - 1); - - /* remove the old rs from the hash table (if it's there): */ - if (cache->links[head].ip) - { - unsigned short *pindex; - for (pindex = &cache->hash[hash (cache->links[head].ip, cache->log_size)]; - *pindex < DWARF_UNW_CACHE_SIZE(cache->log_size); - pindex = &cache->links[*pindex].coll_chain) - { - if (*pindex == head) - { - *pindex = cache->links[*pindex].coll_chain; - break; - } - } - } - - /* enter new rs in the hash table */ - index = hash (c->ip, cache->log_size); - cache->links[head].coll_chain = cache->hash[index]; - cache->hash[index] = head; - - cache->links[head].ip = c->ip; - cache->links[head].valid = 1; - cache->links[head].signal_frame = tdep_cache_frame(c); - return cache->buckets + head; -} - -static int -create_state_record_for (struct dwarf_cursor *c, dwarf_state_record_t *sr, - unw_word_t ip) -{ - int ret; - switch (c->pi.format) - { - case UNW_INFO_FORMAT_TABLE: - case UNW_INFO_FORMAT_REMOTE_TABLE: - if ((ret = setup_fde(c, sr)) < 0) - return ret; - ret = parse_fde (c, ip, sr); - break; - - case UNW_INFO_FORMAT_DYNAMIC: - ret = parse_dynamic (c, ip, sr); - break; - - default: - Debug (1, "Unexpected unwind-info format %d\n", c->pi.format); - ret = -UNW_EINVAL; - } - return ret; -} - -static inline int -eval_location_expr (struct dwarf_cursor *c, unw_addr_space_t as, - unw_accessors_t *a, unw_word_t addr, - dwarf_loc_t *locp, void *arg) -{ - int ret, is_register; - unw_word_t len, val; - - /* read the length of the expression: */ - if ((ret = dwarf_read_uleb128 (as, a, &addr, &len, arg)) < 0) - return ret; - - /* evaluate the expression: */ - if ((ret = dwarf_eval_expr (c, &addr, len, &val, &is_register)) < 0) - return ret; - - if (is_register) - *locp = DWARF_REG_LOC (c, dwarf_to_unw_regnum (val)); - else - *locp = DWARF_MEM_LOC (c, val); - - return 0; -} - -static int -apply_reg_state (struct dwarf_cursor *c, struct dwarf_reg_state *rs) -{ - unw_word_t regnum, addr, cfa, ip; - unw_word_t prev_ip, prev_cfa; - unw_addr_space_t as; - dwarf_loc_t cfa_loc; - unw_accessors_t *a; - int i, ret; - void *arg; - - prev_ip = c->ip; - prev_cfa = c->cfa; - - as = c->as; - arg = c->as_arg; - a = unw_get_accessors_int (as); - - /* Evaluate the CFA first, because it may be referred to by other - expressions. */ - - if (rs->reg.where[DWARF_CFA_REG_COLUMN] == DWARF_WHERE_REG) - { - /* CFA is equal to [reg] + offset: */ - - /* As a special-case, if the stack-pointer is the CFA and the - stack-pointer wasn't saved, popping the CFA implicitly pops - the stack-pointer as well. */ - if ((rs->reg.val[DWARF_CFA_REG_COLUMN] == UNW_TDEP_SP) - && (UNW_TDEP_SP < ARRAY_SIZE(rs->reg.val)) - && (rs->reg.where[UNW_TDEP_SP] == DWARF_WHERE_SAME)) - cfa = c->cfa; - else - { - regnum = dwarf_to_unw_regnum (rs->reg.val[DWARF_CFA_REG_COLUMN]); - if ((ret = unw_get_reg ((unw_cursor_t *) c, regnum, &cfa)) < 0) - return ret; - } - cfa += rs->reg.val[DWARF_CFA_OFF_COLUMN]; - } - else - { - /* CFA is equal to EXPR: */ - - assert (rs->reg.where[DWARF_CFA_REG_COLUMN] == DWARF_WHERE_EXPR); - - addr = rs->reg.val[DWARF_CFA_REG_COLUMN]; - if ((ret = eval_location_expr (c, as, a, addr, &cfa_loc, arg)) < 0) - return ret; - /* the returned location better be a memory location... */ - if (DWARF_IS_REG_LOC (cfa_loc)) - return -UNW_EBADFRAME; - cfa = DWARF_GET_LOC (cfa_loc); - } - - dwarf_loc_t new_loc[DWARF_NUM_PRESERVED_REGS]; - memcpy(new_loc, c->loc, sizeof(new_loc)); - - for (i = 0; i < DWARF_NUM_PRESERVED_REGS; ++i) - { - switch ((dwarf_where_t) rs->reg.where[i]) - { - case DWARF_WHERE_UNDEF: - new_loc[i] = DWARF_NULL_LOC; - break; - - case DWARF_WHERE_SAME: - break; - - case DWARF_WHERE_CFAREL: - new_loc[i] = DWARF_MEM_LOC (c, cfa + rs->reg.val[i]); - break; - - case DWARF_WHERE_REG: - new_loc[i] = DWARF_REG_LOC (c, dwarf_to_unw_regnum (rs->reg.val[i])); - break; - - case DWARF_WHERE_EXPR: - addr = rs->reg.val[i]; - if ((ret = eval_location_expr (c, as, a, addr, new_loc + i, arg)) < 0) - return ret; - break; - - case DWARF_WHERE_VAL_EXPR: - addr = rs->reg.val[i]; - if ((ret = eval_location_expr (c, as, a, addr, new_loc + i, arg)) < 0) - return ret; - new_loc[i] = DWARF_VAL_LOC (c, DWARF_GET_LOC (new_loc[i])); - break; - } - } - - memcpy(c->loc, new_loc, sizeof(new_loc)); - - c->cfa = cfa; - /* DWARF spec says undefined return address location means end of stack. */ - if (DWARF_IS_NULL_LOC (c->loc[rs->ret_addr_column])) - { - c->ip = 0; - ret = 0; - } - else - { - ret = dwarf_get (c, c->loc[rs->ret_addr_column], &ip); - if (ret < 0) - return ret; - c->ip = ip; - ret = 1; - } - - /* XXX: check for ip to be code_aligned */ - if (c->ip == prev_ip && c->cfa == prev_cfa) - { - Dprintf ("%s: ip and cfa unchanged; stopping here (ip=0x%lx)\n", - __FUNCTION__, (long) c->ip); - return -UNW_EBADFRAME; - } - - if (c->stash_frames) - tdep_stash_frame (c, rs); - - return ret; -} - -/* Find the saved locations. */ -static int -find_reg_state (struct dwarf_cursor *c, dwarf_state_record_t *sr) -{ - dwarf_reg_state_t *rs; - struct dwarf_rs_cache *cache; - int ret = 0; - intrmask_t saved_mask; - - if ((cache = get_rs_cache(c->as, &saved_mask)) && - (rs = rs_lookup(cache, c))) - { - /* update hint; no locking needed: single-word writes are atomic */ - unsigned short index = rs - cache->buckets; - c->use_prev_instr = ! cache->links[index].signal_frame; - memcpy (&sr->rs_current, rs, sizeof (*rs)); - } - else - { - ret = fetch_proc_info (c, c->ip); - int next_use_prev_instr = c->use_prev_instr; - if (ret >= 0) - { - /* Update use_prev_instr for the next frame. */ - assert(c->pi.unwind_info); - struct dwarf_cie_info *dci = c->pi.unwind_info; - next_use_prev_instr = ! dci->signal_frame; - ret = create_state_record_for (c, sr, c->ip); - } - put_unwind_info (c, &c->pi); - c->use_prev_instr = next_use_prev_instr; - - if (cache && ret >= 0) - { - rs = rs_new (cache, c); - cache->links[rs - cache->buckets].hint = 0; - memcpy(rs, &sr->rs_current, sizeof(*rs)); - } - } - - unsigned short index = -1; - if (cache) - { - put_rs_cache (c->as, cache, &saved_mask); - if (rs) - { - index = rs - cache->buckets; - c->hint = cache->links[index].hint; - cache->links[c->prev_rs].hint = index + 1; - c->prev_rs = index; - } - } - if (ret < 0) - return ret; - if (cache) - tdep_reuse_frame (c, cache->links[index].signal_frame); - return 0; -} - -/* The function finds the saved locations and applies the register - state as well. */ -HIDDEN int -dwarf_step (struct dwarf_cursor *c) -{ - int ret; - dwarf_state_record_t sr; - if ((ret = find_reg_state (c, &sr)) < 0) - return ret; - return apply_reg_state (c, &sr.rs_current); -} - -HIDDEN int -dwarf_make_proc_info (struct dwarf_cursor *c) -{ -#if 0 - if (c->as->caching_policy == UNW_CACHE_NONE - || get_cached_proc_info (c) < 0) -#endif - /* Need to check if current frame contains - args_size, and set cursor appropriately. Only - needed for unw_resume */ - dwarf_state_record_t sr; - int ret; - - /* Lookup it up the slow way... */ - ret = fetch_proc_info (c, c->ip); - if (ret >= 0) - ret = create_state_record_for (c, &sr, c->ip); - put_unwind_info (c, &c->pi); - if (ret < 0) - return ret; - c->args_size = sr.args_size; - - return 0; -} - -static int -dwarf_reg_states_dynamic_iterate(struct dwarf_cursor *c, - unw_reg_states_callback cb, - void *token) -{ - Debug (1, "Not yet implemented\n"); - return -UNW_ENOINFO; -} - -static int -dwarf_reg_states_table_iterate(struct dwarf_cursor *c, - unw_reg_states_callback cb, - void *token) -{ - dwarf_state_record_t sr; - int ret = setup_fde(c, &sr); - struct dwarf_cie_info *dci = c->pi.unwind_info; - unw_word_t addr = dci->fde_instr_start; - unw_word_t curr_ip = c->pi.start_ip; - dwarf_stackable_reg_state_t *rs_stack = NULL; - while (ret >= 0 && curr_ip < c->pi.end_ip && addr < dci->fde_instr_end) - { - unw_word_t prev_ip = curr_ip; - ret = run_cfi_program (c, &sr, &curr_ip, prev_ip, &addr, dci->fde_instr_end, - &rs_stack, dci); - if (ret >= 0 && prev_ip < curr_ip) - ret = cb(token, &sr.rs_current, sizeof(sr.rs_current), prev_ip, curr_ip); - } - empty_rstate_stack(&rs_stack); -#if defined(NEED_LAST_IP) - if (ret >= 0 && curr_ip < c->pi.last_ip) - /* report the dead zone after the procedure ends */ - ret = cb(token, &sr.rs_current, sizeof(sr.rs_current), curr_ip, c->pi.last_ip); -#else - if (ret >= 0 && curr_ip < c->pi.end_ip) - /* report for whatever is left before procedure end */ - ret = cb(token, &sr.rs_current, sizeof(sr.rs_current), curr_ip, c->pi.end_ip); -#endif - return ret; -} - -HIDDEN int -dwarf_reg_states_iterate(struct dwarf_cursor *c, - unw_reg_states_callback cb, - void *token) -{ - int ret = fetch_proc_info (c, c->ip); - int next_use_prev_instr = c->use_prev_instr; - if (ret >= 0) - { - /* Update use_prev_instr for the next frame. */ - assert(c->pi.unwind_info); - struct dwarf_cie_info *dci = c->pi.unwind_info; - next_use_prev_instr = ! dci->signal_frame; - switch (c->pi.format) - { - case UNW_INFO_FORMAT_TABLE: - case UNW_INFO_FORMAT_REMOTE_TABLE: - ret = dwarf_reg_states_table_iterate(c, cb, token); - break; - - case UNW_INFO_FORMAT_DYNAMIC: - ret = dwarf_reg_states_dynamic_iterate (c, cb, token); - break; - - default: - Debug (1, "Unexpected unwind-info format %d\n", c->pi.format); - ret = -UNW_EINVAL; - } - } - put_unwind_info (c, &c->pi); - c->use_prev_instr = next_use_prev_instr; - return ret; -} - -HIDDEN int -dwarf_apply_reg_state (struct dwarf_cursor *c, struct dwarf_reg_state *rs) -{ - return apply_reg_state(c, rs); -} diff --git a/src/pal/src/libunwind/src/dwarf/Gpe.c b/src/pal/src/libunwind/src/dwarf/Gpe.c deleted file mode 100644 index a0e37ba23..000000000 --- a/src/pal/src/libunwind/src/dwarf/Gpe.c +++ /dev/null @@ -1,39 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (c) 2003, 2005 Hewlett-Packard Development Company, L.P. - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include "dwarf_i.h" -#include "libunwind_i.h" - -#include - -HIDDEN int -dwarf_read_encoded_pointer (unw_addr_space_t as, unw_accessors_t *a, - unw_word_t *addr, unsigned char encoding, - const unw_proc_info_t *pi, - unw_word_t *valp, void *arg) -{ - return dwarf_read_encoded_pointer_inlined (as, a, addr, encoding, - pi, valp, arg); -} diff --git a/src/pal/src/libunwind/src/dwarf/Lexpr.c b/src/pal/src/libunwind/src/dwarf/Lexpr.c deleted file mode 100644 index 245970c9e..000000000 --- a/src/pal/src/libunwind/src/dwarf/Lexpr.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gexpr.c" -#endif diff --git a/src/pal/src/libunwind/src/dwarf/Lfde.c b/src/pal/src/libunwind/src/dwarf/Lfde.c deleted file mode 100644 index e779e8f19..000000000 --- a/src/pal/src/libunwind/src/dwarf/Lfde.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gfde.c" -#endif diff --git a/src/pal/src/libunwind/src/dwarf/Lfind_proc_info-lsb.c b/src/pal/src/libunwind/src/dwarf/Lfind_proc_info-lsb.c deleted file mode 100644 index 27a5eeac1..000000000 --- a/src/pal/src/libunwind/src/dwarf/Lfind_proc_info-lsb.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gfind_proc_info-lsb.c" -#endif diff --git a/src/pal/src/libunwind/src/dwarf/Lfind_unwind_table.c b/src/pal/src/libunwind/src/dwarf/Lfind_unwind_table.c deleted file mode 100644 index 68e269f1d..000000000 --- a/src/pal/src/libunwind/src/dwarf/Lfind_unwind_table.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gfind_unwind_table.c" -#endif diff --git a/src/pal/src/libunwind/src/dwarf/Lparser.c b/src/pal/src/libunwind/src/dwarf/Lparser.c deleted file mode 100644 index f23aaf48e..000000000 --- a/src/pal/src/libunwind/src/dwarf/Lparser.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gparser.c" -#endif diff --git a/src/pal/src/libunwind/src/dwarf/Lpe.c b/src/pal/src/libunwind/src/dwarf/Lpe.c deleted file mode 100644 index a672358f0..000000000 --- a/src/pal/src/libunwind/src/dwarf/Lpe.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gpe.c" -#endif diff --git a/src/pal/src/libunwind/src/dwarf/global.c b/src/pal/src/libunwind/src/dwarf/global.c deleted file mode 100644 index 709850714..000000000 --- a/src/pal/src/libunwind/src/dwarf/global.c +++ /dev/null @@ -1,37 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (c) 2003-2004 Hewlett-Packard Development Company, L.P. - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include "dwarf_i.h" - -HIDDEN struct mempool dwarf_reg_state_pool; -HIDDEN struct mempool dwarf_cie_info_pool; - -HIDDEN int -dwarf_init (void) -{ - mempool_init (&dwarf_reg_state_pool, sizeof (dwarf_stackable_reg_state_t), 0); - mempool_init (&dwarf_cie_info_pool, sizeof (struct dwarf_cie_info), 0); - return 0; -} diff --git a/src/pal/src/libunwind/src/elf32.c b/src/pal/src/libunwind/src/elf32.c deleted file mode 100644 index a70bb58f2..000000000 --- a/src/pal/src/libunwind/src/elf32.c +++ /dev/null @@ -1,4 +0,0 @@ -#ifndef UNW_REMOTE_ONLY -# include "elf32.h" -# include "elfxx.c" -#endif diff --git a/src/pal/src/libunwind/src/elf32.h b/src/pal/src/libunwind/src/elf32.h deleted file mode 100644 index 2c7bca4c9..000000000 --- a/src/pal/src/libunwind/src/elf32.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef elf32_h -#define elf32_h - -#ifndef ELF_CLASS -#define ELF_CLASS ELFCLASS32 -#endif -#include "elfxx.h" - -#endif /* elf32_h */ diff --git a/src/pal/src/libunwind/src/elf64.c b/src/pal/src/libunwind/src/elf64.c deleted file mode 100644 index 195b88794..000000000 --- a/src/pal/src/libunwind/src/elf64.c +++ /dev/null @@ -1,4 +0,0 @@ -#ifndef UNW_REMOTE_ONLY -# include "elf64.h" -# include "elfxx.c" -#endif diff --git a/src/pal/src/libunwind/src/elf64.h b/src/pal/src/libunwind/src/elf64.h deleted file mode 100644 index 091fba8e1..000000000 --- a/src/pal/src/libunwind/src/elf64.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef elf64_h -#define elf64_h - -#ifndef ELF_CLASS -#define ELF_CLASS ELFCLASS64 -#endif -#include "elfxx.h" - -#endif /* elf64_h */ diff --git a/src/pal/src/libunwind/src/elfxx.c b/src/pal/src/libunwind/src/elfxx.c deleted file mode 100644 index b03dfcb73..000000000 --- a/src/pal/src/libunwind/src/elfxx.c +++ /dev/null @@ -1,481 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2003-2005 Hewlett-Packard Co - Copyright (C) 2007 David Mosberger-Tang - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include "libunwind_i.h" - -#include -#include - -#ifdef HAVE_LZMA -#include -#endif /* HAVE_LZMA */ - -static Elf_W (Shdr)* -elf_w (section_table) (struct elf_image *ei) -{ - Elf_W (Ehdr) *ehdr = ei->image; - Elf_W (Off) soff; - - soff = ehdr->e_shoff; - if (soff + ehdr->e_shnum * ehdr->e_shentsize > ei->size) - { - Debug (1, "section table outside of image? (%lu > %lu)\n", - (unsigned long) (soff + ehdr->e_shnum * ehdr->e_shentsize), - (unsigned long) ei->size); - return NULL; - } - - return (Elf_W (Shdr) *) ((char *) ei->image + soff); -} - -static char* -elf_w (string_table) (struct elf_image *ei, int section) -{ - Elf_W (Ehdr) *ehdr = ei->image; - Elf_W (Off) soff, str_soff; - Elf_W (Shdr) *str_shdr; - - /* this offset is assumed to be OK */ - soff = ehdr->e_shoff; - - str_soff = soff + (section * ehdr->e_shentsize); - if (str_soff + ehdr->e_shentsize > ei->size) - { - Debug (1, "string shdr table outside of image? (%lu > %lu)\n", - (unsigned long) (str_soff + ehdr->e_shentsize), - (unsigned long) ei->size); - return NULL; - } - str_shdr = (Elf_W (Shdr) *) ((char *) ei->image + str_soff); - - if (str_shdr->sh_offset + str_shdr->sh_size > ei->size) - { - Debug (1, "string table outside of image? (%lu > %lu)\n", - (unsigned long) (str_shdr->sh_offset + str_shdr->sh_size), - (unsigned long) ei->size); - return NULL; - } - - Debug (16, "strtab=0x%lx\n", (long) str_shdr->sh_offset); - return ei->image + str_shdr->sh_offset; -} - -static int -elf_w (lookup_symbol) (unw_addr_space_t as, - unw_word_t ip, struct elf_image *ei, - Elf_W (Addr) load_offset, - char *buf, size_t buf_len, Elf_W (Addr) *min_dist) -{ - size_t syment_size; - Elf_W (Ehdr) *ehdr = ei->image; - Elf_W (Sym) *sym, *symtab, *symtab_end; - Elf_W (Shdr) *shdr; - Elf_W (Addr) val; - int i, ret = -UNW_ENOINFO; - char *strtab; - - if (!elf_w (valid_object) (ei)) - return -UNW_ENOINFO; - - shdr = elf_w (section_table) (ei); - if (!shdr) - return -UNW_ENOINFO; - - for (i = 0; i < ehdr->e_shnum; ++i) - { - switch (shdr->sh_type) - { - case SHT_SYMTAB: - case SHT_DYNSYM: - symtab = (Elf_W (Sym) *) ((char *) ei->image + shdr->sh_offset); - symtab_end = (Elf_W (Sym) *) ((char *) symtab + shdr->sh_size); - syment_size = shdr->sh_entsize; - - strtab = elf_w (string_table) (ei, shdr->sh_link); - if (!strtab) - break; - - Debug (16, "symtab=0x%lx[%d]\n", - (long) shdr->sh_offset, shdr->sh_type); - - for (sym = symtab; - sym < symtab_end; - sym = (Elf_W (Sym) *) ((char *) sym + syment_size)) - { - if (ELF_W (ST_TYPE) (sym->st_info) == STT_FUNC - && sym->st_shndx != SHN_UNDEF) - { - val = sym->st_value; - if (sym->st_shndx != SHN_ABS) - val += load_offset; - if (tdep_get_func_addr (as, val, &val) < 0) - continue; - Debug (16, "0x%016lx info=0x%02x %s\n", - (long) val, sym->st_info, strtab + sym->st_name); - - if ((Elf_W (Addr)) (ip - val) < *min_dist) - { - *min_dist = (Elf_W (Addr)) (ip - val); - strncpy (buf, strtab + sym->st_name, buf_len); - buf[buf_len - 1] = '\0'; - ret = (strlen (strtab + sym->st_name) >= buf_len - ? -UNW_ENOMEM : 0); - } - } - } - break; - - default: - break; - } - shdr = (Elf_W (Shdr) *) (((char *) shdr) + ehdr->e_shentsize); - } - return ret; -} - -static Elf_W (Addr) -elf_w (get_load_offset) (struct elf_image *ei, unsigned long segbase, - unsigned long mapoff) -{ - Elf_W (Addr) offset = 0; - Elf_W (Ehdr) *ehdr; - Elf_W (Phdr) *phdr; - int i; - - ehdr = ei->image; - phdr = (Elf_W (Phdr) *) ((char *) ei->image + ehdr->e_phoff); - - for (i = 0; i < ehdr->e_phnum; ++i) - if (phdr[i].p_type == PT_LOAD && phdr[i].p_offset == mapoff) - { - offset = segbase - phdr[i].p_vaddr; - break; - } - - return offset; -} - -#if HAVE_LZMA -static size_t -xz_uncompressed_size (uint8_t *compressed, size_t length) -{ - uint64_t memlimit = UINT64_MAX; - size_t ret = 0, pos = 0; - lzma_stream_flags options; - lzma_index *index; - - if (length < LZMA_STREAM_HEADER_SIZE) - return 0; - - uint8_t *footer = compressed + length - LZMA_STREAM_HEADER_SIZE; - if (lzma_stream_footer_decode (&options, footer) != LZMA_OK) - return 0; - - if (length < LZMA_STREAM_HEADER_SIZE + options.backward_size) - return 0; - - uint8_t *indexdata = footer - options.backward_size; - if (lzma_index_buffer_decode (&index, &memlimit, NULL, indexdata, - &pos, options.backward_size) != LZMA_OK) - return 0; - - if (lzma_index_size (index) == options.backward_size) - { - ret = lzma_index_uncompressed_size (index); - } - - lzma_index_end (index, NULL); - return ret; -} - -static int -elf_w (extract_minidebuginfo) (struct elf_image *ei, struct elf_image *mdi) -{ - Elf_W (Shdr) *shdr; - uint8_t *compressed = NULL; - uint64_t memlimit = UINT64_MAX; /* no memory limit */ - size_t compressed_len, uncompressed_len; - - shdr = elf_w (find_section) (ei, ".gnu_debugdata"); - if (!shdr) - return 0; - - compressed = ((uint8_t *) ei->image) + shdr->sh_offset; - compressed_len = shdr->sh_size; - - uncompressed_len = xz_uncompressed_size (compressed, compressed_len); - if (uncompressed_len == 0) - { - Debug (1, "invalid .gnu_debugdata contents\n"); - return 0; - } - - mdi->size = uncompressed_len; - mdi->image = mmap (NULL, uncompressed_len, PROT_READ|PROT_WRITE, - MAP_PRIVATE|MAP_ANONYMOUS, -1, 0); - - if (mdi->image == MAP_FAILED) - return 0; - - size_t in_pos = 0, out_pos = 0; - lzma_ret lret; - lret = lzma_stream_buffer_decode (&memlimit, 0, NULL, - compressed, &in_pos, compressed_len, - mdi->image, &out_pos, mdi->size); - if (lret != LZMA_OK) - { - Debug (1, "LZMA decompression failed: %d\n", lret); - munmap (mdi->image, mdi->size); - return 0; - } - - return 1; -} -#else -static int -elf_w (extract_minidebuginfo) (struct elf_image *ei, struct elf_image *mdi) -{ - return 0; -} -#endif /* !HAVE_LZMA */ - -/* Find the ELF image that contains IP and return the "closest" - procedure name, if there is one. With some caching, this could be - sped up greatly, but until an application materializes that's - sensitive to the performance of this routine, why bother... */ - -HIDDEN int -elf_w (get_proc_name_in_image) (unw_addr_space_t as, struct elf_image *ei, - unsigned long segbase, - unsigned long mapoff, - unw_word_t ip, - char *buf, size_t buf_len, unw_word_t *offp) -{ - Elf_W (Addr) load_offset; - Elf_W (Addr) min_dist = ~(Elf_W (Addr))0; - int ret; - - load_offset = elf_w (get_load_offset) (ei, segbase, mapoff); - ret = elf_w (lookup_symbol) (as, ip, ei, load_offset, buf, buf_len, &min_dist); - - /* If the ELF image has MiniDebugInfo embedded in it, look up the symbol in - there as well and replace the previously found if it is closer. */ - struct elf_image mdi; - if (elf_w (extract_minidebuginfo) (ei, &mdi)) - { - int ret_mdi = elf_w (lookup_symbol) (as, ip, &mdi, load_offset, buf, - buf_len, &min_dist); - - /* Closer symbol was found (possibly truncated). */ - if (ret_mdi == 0 || ret_mdi == -UNW_ENOMEM) - { - ret = ret_mdi; - } - - munmap (mdi.image, mdi.size); - } - - if (min_dist >= ei->size) - return -UNW_ENOINFO; /* not found */ - if (offp) - *offp = min_dist; - return ret; -} - -HIDDEN int -elf_w (get_proc_name) (unw_addr_space_t as, pid_t pid, unw_word_t ip, - char *buf, size_t buf_len, unw_word_t *offp) -{ - unsigned long segbase, mapoff; - struct elf_image ei; - int ret; - char file[PATH_MAX]; - - ret = tdep_get_elf_image (&ei, pid, ip, &segbase, &mapoff, file, PATH_MAX); - if (ret < 0) - return ret; - - ret = elf_w (load_debuglink) (file, &ei, 1); - if (ret < 0) - return ret; - - ret = elf_w (get_proc_name_in_image) (as, &ei, segbase, mapoff, ip, buf, buf_len, offp); - - munmap (ei.image, ei.size); - ei.image = NULL; - - return ret; -} - -HIDDEN Elf_W (Shdr)* -elf_w (find_section) (struct elf_image *ei, const char* secname) -{ - Elf_W (Ehdr) *ehdr = ei->image; - Elf_W (Shdr) *shdr; - char *strtab; - int i; - - if (!elf_w (valid_object) (ei)) - return 0; - - shdr = elf_w (section_table) (ei); - if (!shdr) - return 0; - - strtab = elf_w (string_table) (ei, ehdr->e_shstrndx); - if (!strtab) - return 0; - - for (i = 0; i < ehdr->e_shnum; ++i) - { - if (strcmp (strtab + shdr->sh_name, secname) == 0) - { - if (shdr->sh_offset + shdr->sh_size > ei->size) - { - Debug (1, "section \"%s\" outside image? (0x%lu > 0x%lu)\n", - secname, - (unsigned long) shdr->sh_offset + shdr->sh_size, - (unsigned long) ei->size); - return 0; - } - - Debug (16, "found section \"%s\" at 0x%lx\n", - secname, (unsigned long) shdr->sh_offset); - return shdr; - } - - shdr = (Elf_W (Shdr) *) (((char *) shdr) + ehdr->e_shentsize); - } - - /* section not found */ - return 0; -} - -/* Load a debug section, following .gnu_debuglink if appropriate - * Loads ei from file if not already mapped. - * If is_local, will also search sys directories /usr/local/dbg - * - * Returns 0 on success, failure otherwise. - * ei will be mapped to file or the located .gnu_debuglink from file - */ -HIDDEN int -elf_w (load_debuglink) (const char* file, struct elf_image *ei, int is_local) -{ - int ret; - Elf_W (Shdr) *shdr; - Elf_W (Ehdr) *prev_image; - off_t prev_size; - - if (!ei->image) - { - ret = elf_map_image(ei, file); - if (ret) - return ret; - } - - prev_image = ei->image; - prev_size = ei->size; - - /* Ignore separate debug files which contain a .gnu_debuglink section. */ - if (is_local == -1) { - return 0; - } - - shdr = elf_w (find_section) (ei, ".gnu_debuglink"); - if (shdr) { - if (shdr->sh_size >= PATH_MAX || - (shdr->sh_offset + shdr->sh_size > ei->size)) - { - return 0; - } - - { - char linkbuf[shdr->sh_size]; - char *link = ((char *) ei->image) + shdr->sh_offset; - char *p; - static const char *debugdir = "/usr/lib/debug"; - char basedir[strlen(file) + 1]; - char newname[shdr->sh_size + strlen (debugdir) + strlen (file) + 9]; - - memcpy(linkbuf, link, shdr->sh_size); - - if (memchr (linkbuf, 0, shdr->sh_size) == NULL) - return 0; - - ei->image = NULL; - - Debug(1, "Found debuglink section, following %s\n", linkbuf); - - p = strrchr (file, '/'); - if (p != NULL) - { - memcpy (basedir, file, p - file); - basedir[p - file] = '\0'; - } - else - basedir[0] = 0; - - strcpy (newname, basedir); - strcat (newname, "/"); - strcat (newname, linkbuf); - ret = elf_w (load_debuglink) (newname, ei, -1); - - if (ret == -1) - { - strcpy (newname, basedir); - strcat (newname, "/.debug/"); - strcat (newname, linkbuf); - ret = elf_w (load_debuglink) (newname, ei, -1); - } - - if (ret == -1 && is_local == 1) - { - strcpy (newname, debugdir); - strcat (newname, basedir); - strcat (newname, "/"); - strcat (newname, linkbuf); - ret = elf_w (load_debuglink) (newname, ei, -1); - } - - if (ret == -1) - { - /* No debuglink file found even though .gnu_debuglink existed */ - ei->image = prev_image; - ei->size = prev_size; - - return 0; - } - else - { - munmap (prev_image, prev_size); - } - - return ret; - } - } - - return 0; -} diff --git a/src/pal/src/libunwind/src/elfxx.h b/src/pal/src/libunwind/src/elfxx.h deleted file mode 100644 index 830432c2e..000000000 --- a/src/pal/src/libunwind/src/elfxx.h +++ /dev/null @@ -1,101 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2003, 2005 Hewlett-Packard Co - Copyright (C) 2007 David Mosberger-Tang - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include -#include - -#include -#include - -#include "libunwind_i.h" - -#if ELF_CLASS == ELFCLASS32 -# define ELF_W(x) ELF32_##x -# define Elf_W(x) Elf32_##x -# define elf_w(x) _Uelf32_##x -#else -# define ELF_W(x) ELF64_##x -# define Elf_W(x) Elf64_##x -# define elf_w(x) _Uelf64_##x -#endif - -extern int elf_w (get_proc_name) (unw_addr_space_t as, - pid_t pid, unw_word_t ip, - char *buf, size_t len, - unw_word_t *offp); - -extern int elf_w (get_proc_name_in_image) (unw_addr_space_t as, - struct elf_image *ei, - unsigned long segbase, - unsigned long mapoff, - unw_word_t ip, - char *buf, size_t buf_len, unw_word_t *offp); - -extern Elf_W (Shdr)* elf_w (find_section) (struct elf_image *ei, const char* secname); -extern int elf_w (load_debuglink) (const char* file, struct elf_image *ei, int is_local); - -static inline int -elf_w (valid_object) (struct elf_image *ei) -{ - if (ei->size <= EI_VERSION) - return 0; - - return (memcmp (ei->image, ELFMAG, SELFMAG) == 0 - && ((uint8_t *) ei->image)[EI_CLASS] == ELF_CLASS - && ((uint8_t *) ei->image)[EI_VERSION] != EV_NONE - && ((uint8_t *) ei->image)[EI_VERSION] <= EV_CURRENT); -} - -static inline int -elf_map_image (struct elf_image *ei, const char *path) -{ - struct stat stat; - int fd; - - fd = open (path, O_RDONLY); - if (fd < 0) - return -1; - - if (fstat (fd, &stat) < 0) - { - close (fd); - return -1; - } - - ei->size = stat.st_size; - ei->image = mmap (NULL, ei->size, PROT_READ, MAP_PRIVATE, fd, 0); - close (fd); - if (ei->image == MAP_FAILED) - return -1; - - if (!elf_w (valid_object) (ei)) - { - munmap(ei->image, ei->size); - return -1; - } - - return 0; -} diff --git a/src/pal/src/libunwind/src/hppa/Gapply_reg_state.c b/src/pal/src/libunwind/src/hppa/Gapply_reg_state.c deleted file mode 100644 index 82f056da6..000000000 --- a/src/pal/src/libunwind/src/hppa/Gapply_reg_state.c +++ /dev/null @@ -1,37 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (c) 2002-2003 Hewlett-Packard Development Company, L.P. - Contributed by David Mosberger-Tang - - Modified for x86_64 by Max Asbock - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" - -int -unw_apply_reg_state (unw_cursor_t *cursor, - void *reg_states_data) -{ - struct cursor *c = (struct cursor *) cursor; - - return dwarf_apply_reg_state (&c->dwarf, (dwarf_reg_state_t *)reg_states_data); -} diff --git a/src/pal/src/libunwind/src/hppa/Gcreate_addr_space.c b/src/pal/src/libunwind/src/hppa/Gcreate_addr_space.c deleted file mode 100644 index 8a6cb8b4e..000000000 --- a/src/pal/src/libunwind/src/hppa/Gcreate_addr_space.c +++ /dev/null @@ -1,54 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include - -#include "unwind_i.h" - -unw_addr_space_t -unw_create_addr_space (unw_accessors_t *a, int byte_order) -{ -#ifdef UNW_LOCAL_ONLY - return NULL; -#else - unw_addr_space_t as; - - /* - * hppa supports only big-endian. - */ - if (byte_order != 0 && byte_order != __BIG_ENDIAN) - return NULL; - - as = malloc (sizeof (*as)); - if (!as) - return NULL; - - memset (as, 0, sizeof (*as)); - - as->acc = *a; - - return as; -#endif -} diff --git a/src/pal/src/libunwind/src/hppa/Gget_proc_info.c b/src/pal/src/libunwind/src/hppa/Gget_proc_info.c deleted file mode 100644 index e10efcfca..000000000 --- a/src/pal/src/libunwind/src/hppa/Gget_proc_info.c +++ /dev/null @@ -1,46 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" - -int -unw_get_proc_info (unw_cursor_t *cursor, unw_proc_info_t *pi) -{ - struct cursor *c = (struct cursor *) cursor; - - if (dwarf_make_proc_info (&c->dwarf) < 0) - { - /* On hppa, some key routines such as _start() and _dl_start() - are missing DWARF unwind info. We don't want to fail in that - case, because those frames are uninteresting and just mark - the end of the frame-chain anyhow. */ - memset (pi, 0, sizeof (*pi)); - pi->start_ip = c->dwarf.ip; - pi->end_ip = c->dwarf.ip + 4; - return 0; - } - *pi = c->dwarf.pi; - return 0; -} diff --git a/src/pal/src/libunwind/src/hppa/Gget_save_loc.c b/src/pal/src/libunwind/src/hppa/Gget_save_loc.c deleted file mode 100644 index 02dfa3084..000000000 --- a/src/pal/src/libunwind/src/hppa/Gget_save_loc.c +++ /dev/null @@ -1,59 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" - -int -unw_get_save_loc (unw_cursor_t *cursor, int reg, unw_save_loc_t *sloc) -{ - /* struct cursor *c = (struct cursor *) cursor; */ - dwarf_loc_t loc; - - loc = DWARF_NULL_LOC; /* default to "not saved" */ - -#warning FIX ME! - - memset (sloc, 0, sizeof (*sloc)); - - if (DWARF_IS_NULL_LOC (loc)) - { - sloc->type = UNW_SLT_NONE; - return 0; - } - -#if !defined(UNW_LOCAL_ONLY) - if (DWARF_IS_REG_LOC (loc)) - { - sloc->type = UNW_SLT_REG; - sloc->u.regnum = DWARF_GET_LOC (loc); - } - else -#endif - { - sloc->type = UNW_SLT_MEMORY; - sloc->u.addr = DWARF_GET_LOC (loc); - } - return 0; -} diff --git a/src/pal/src/libunwind/src/hppa/Gglobal.c b/src/pal/src/libunwind/src/hppa/Gglobal.c deleted file mode 100644 index 351a5015d..000000000 --- a/src/pal/src/libunwind/src/hppa/Gglobal.c +++ /dev/null @@ -1,55 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (c) 2004-2005 Hewlett-Packard Development Company, L.P. - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" - -HIDDEN define_lock (hppa_lock); -HIDDEN int tdep_init_done; - -HIDDEN void -tdep_init (void) -{ - intrmask_t saved_mask; - - sigfillset (&unwi_full_mask); - - lock_acquire (&hppa_lock, saved_mask); - { - if (tdep_init_done) - /* another thread else beat us to it... */ - goto out; - - mi_init (); - - dwarf_init (); - -#ifndef UNW_REMOTE_ONLY - hppa_local_addr_space_init (); -#endif - tdep_init_done = 1; /* signal that we're initialized... */ - } - out: - lock_release (&hppa_lock, saved_mask); -} diff --git a/src/pal/src/libunwind/src/hppa/Ginit.c b/src/pal/src/libunwind/src/hppa/Ginit.c deleted file mode 100644 index 461e4b93d..000000000 --- a/src/pal/src/libunwind/src/hppa/Ginit.c +++ /dev/null @@ -1,194 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2002, 2004 Hewlett-Packard Co - Copyright (C) 2007 David Mosberger-Tang - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include -#include - -#include "unwind_i.h" - -#ifdef UNW_REMOTE_ONLY - -/* unw_local_addr_space is a NULL pointer in this case. */ -unw_addr_space_t unw_local_addr_space; - -#else /* !UNW_REMOTE_ONLY */ - -static struct unw_addr_space local_addr_space; - -unw_addr_space_t unw_local_addr_space = &local_addr_space; - -static inline void * -uc_addr (ucontext_t *uc, int reg) -{ - void *addr; - - if ((unsigned) (reg - UNW_HPPA_GR) < 32) - addr = &uc->uc_mcontext.sc_gr[reg - UNW_HPPA_GR]; - else if ((unsigned) (reg - UNW_HPPA_FR) < 32) - addr = &uc->uc_mcontext.sc_fr[reg - UNW_HPPA_FR]; - else - addr = NULL; - return addr; -} - -# ifdef UNW_LOCAL_ONLY - -void * -_Uhppa_uc_addr (ucontext_t *uc, int reg) -{ - return uc_addr (uc, reg); -} - -# endif /* UNW_LOCAL_ONLY */ - -HIDDEN unw_dyn_info_list_t _U_dyn_info_list; - -/* XXX fix me: there is currently no way to locate the dyn-info list - by a remote unwinder. On ia64, this is done via a special - unwind-table entry. Perhaps something similar can be done with - DWARF2 unwind info. */ - -static void -put_unwind_info (unw_addr_space_t as, unw_proc_info_t *proc_info, void *arg) -{ - /* it's a no-op */ -} - -static int -get_dyn_info_list_addr (unw_addr_space_t as, unw_word_t *dyn_info_list_addr, - void *arg) -{ - *dyn_info_list_addr = (unw_word_t) &_U_dyn_info_list; - return 0; -} - -static int -access_mem (unw_addr_space_t as, unw_word_t addr, unw_word_t *val, int write, - void *arg) -{ - if (write) - { - Debug (12, "mem[%x] <- %x\n", addr, *val); - *(unw_word_t *) addr = *val; - } - else - { - *val = *(unw_word_t *) addr; - Debug (12, "mem[%x] -> %x\n", addr, *val); - } - return 0; -} - -static int -access_reg (unw_addr_space_t as, unw_regnum_t reg, unw_word_t *val, int write, - void *arg) -{ - unw_word_t *addr; - ucontext_t *uc = arg; - - if ((unsigned int) (reg - UNW_HPPA_FR) < 32) - goto badreg; - - addr = uc_addr (uc, reg); - if (!addr) - goto badreg; - - if (write) - { - *(unw_word_t *) addr = *val; - Debug (12, "%s <- %x\n", unw_regname (reg), *val); - } - else - { - *val = *(unw_word_t *) addr; - Debug (12, "%s -> %x\n", unw_regname (reg), *val); - } - return 0; - - badreg: - Debug (1, "bad register number %u\n", reg); - return -UNW_EBADREG; -} - -static int -access_fpreg (unw_addr_space_t as, unw_regnum_t reg, unw_fpreg_t *val, - int write, void *arg) -{ - ucontext_t *uc = arg; - unw_fpreg_t *addr; - - if ((unsigned) (reg - UNW_HPPA_FR) > 32) - goto badreg; - - addr = uc_addr (uc, reg); - if (!addr) - goto badreg; - - if (write) - { - Debug (12, "%s <- %08x.%08x\n", - unw_regname (reg), val->raw.bits[1], val->raw.bits[0]); - *(unw_fpreg_t *) addr = *val; - } - else - { - *val = *(unw_fpreg_t *) addr; - Debug (12, "%s -> %08x.%08x\n", - unw_regname (reg), val->raw.bits[1], val->raw.bits[0]); - } - return 0; - - badreg: - Debug (1, "bad register number %u\n", reg); - /* attempt to access a non-preserved register */ - return -UNW_EBADREG; -} - -static int -get_static_proc_name (unw_addr_space_t as, unw_word_t ip, - char *buf, size_t buf_len, unw_word_t *offp, - void *arg) -{ - return _Uelf32_get_proc_name (as, getpid (), ip, buf, buf_len, offp); -} - -HIDDEN void -hppa_local_addr_space_init (void) -{ - memset (&local_addr_space, 0, sizeof (local_addr_space)); - local_addr_space.caching_policy = UNWI_DEFAULT_CACHING_POLICY; - local_addr_space.acc.find_proc_info = dwarf_find_proc_info; - local_addr_space.acc.put_unwind_info = put_unwind_info; - local_addr_space.acc.get_dyn_info_list_addr = get_dyn_info_list_addr; - local_addr_space.acc.access_mem = access_mem; - local_addr_space.acc.access_reg = access_reg; - local_addr_space.acc.access_fpreg = access_fpreg; - local_addr_space.acc.resume = hppa_local_resume; - local_addr_space.acc.get_proc_name = get_static_proc_name; - unw_flush_cache (&local_addr_space, 0, 0); -} - -#endif /* !UNW_REMOTE_ONLY */ diff --git a/src/pal/src/libunwind/src/hppa/Ginit_local.c b/src/pal/src/libunwind/src/hppa/Ginit_local.c deleted file mode 100644 index 1fdc7716f..000000000 --- a/src/pal/src/libunwind/src/hppa/Ginit_local.c +++ /dev/null @@ -1,77 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2003 Hewlett-Packard Co - Contributed by ... - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" -#include "init.h" - -#ifdef UNW_REMOTE_ONLY - -int -unw_init_local (unw_cursor_t *cursor, ucontext_t *uc) -{ - return -UNW_EINVAL; -} - -#else /* !UNW_REMOTE_ONLY */ - -static int -unw_init_local_common (unw_cursor_t *cursor, ucontext_t *uc, unsigned use_prev_instr) -{ - struct cursor *c = (struct cursor *) cursor; - - if (!tdep_init_done) - tdep_init (); - - Debug (1, "(cursor=%p)\n", c); - - c->dwarf.as = unw_local_addr_space; - c->dwarf.as_arg = uc; - return common_init (c, use_prev_instr); -} - -int -unw_init_local (unw_cursor_t *cursor, ucontext_t *uc) -{ - return unw_init_local_common(cursor, uc, 1); -} - -int -unw_init_local2 (unw_cursor_t *cursor, ucontext_t *uc, int flag) -{ - if (!flag) - { - return unw_init_local_common(cursor, uc, 1); - } - else if (flag == UNW_INIT_SIGNAL_FRAME) - { - return unw_init_local_common(cursor, uc, 0); - } - else - { - return -UNW_EINVAL; - } -} - -#endif /* !UNW_REMOTE_ONLY */ diff --git a/src/pal/src/libunwind/src/hppa/Ginit_remote.c b/src/pal/src/libunwind/src/hppa/Ginit_remote.c deleted file mode 100644 index 71096ce0e..000000000 --- a/src/pal/src/libunwind/src/hppa/Ginit_remote.c +++ /dev/null @@ -1,46 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (c) 2004 Hewlett-Packard Development Company, L.P. - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include "init.h" -#include "unwind_i.h" - -int -unw_init_remote (unw_cursor_t *cursor, unw_addr_space_t as, void *as_arg) -{ -#ifdef UNW_LOCAL_ONLY - return -UNW_EINVAL; -#else /* !UNW_LOCAL_ONLY */ - struct cursor *c = (struct cursor *) cursor; - - if (!tdep_init_done) - tdep_init (); - - Debug (1, "(cursor=%p)\n", c); - - c->dwarf.as = as; - c->dwarf.as_arg = as_arg; - return common_init (c, 0); -#endif /* !UNW_LOCAL_ONLY */ -} diff --git a/src/pal/src/libunwind/src/hppa/Gis_signal_frame.c b/src/pal/src/libunwind/src/hppa/Gis_signal_frame.c deleted file mode 100644 index addb55181..000000000 --- a/src/pal/src/libunwind/src/hppa/Gis_signal_frame.c +++ /dev/null @@ -1,74 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" - -int -unw_is_signal_frame (unw_cursor_t *cursor) -{ -#ifdef __linux__ - struct cursor *c = (struct cursor *) cursor; - unw_word_t w0, w1, w2, w3, ip; - unw_addr_space_t as; - unw_accessors_t *a; - void *arg; - int ret; - - as = c->dwarf.as; - a = unw_get_accessors_int (as); - arg = c->dwarf.as_arg; - - /* Check if IP points at sigreturn() sequence. On Linux, this normally is: - - rt_sigreturn: - 0x34190000 ldi 0, %r25 - 0x3414015a ldi __NR_rt_sigreturn,%r20 - 0xe4008200 be,l 0x100(%sr2,%r0),%sr0,%r31 - 0x08000240 nop - - When a signal interrupts a system call, the first word is instead: - - 0x34190002 ldi 1, %r25 - */ - ip = c->dwarf.ip; - if (!ip) - return 0; - if ((ret = (*a->access_mem) (as, ip, &w0, 0, arg)) < 0 - || (ret = (*a->access_mem) (as, ip + 4, &w1, 0, arg)) < 0 - || (ret = (*a->access_mem) (as, ip + 8, &w2, 0, arg)) < 0 - || (ret = (*a->access_mem) (as, ip + 12, &w3, 0, arg)) < 0) - { - Debug (1, "failed to read sigreturn code (ret=%d)\n", ret); - return ret; - } - ret = ((w0 == 0x34190000 || w0 == 0x34190002) - && w1 == 0x3414015a && w2 == 0xe4008200 && w3 == 0x08000240); - Debug (1, "(cursor=%p, ip=0x%08lx) -> %d\n", c, (unsigned) ip, ret); - return ret; -#else - printf ("%s: implement me\n", __FUNCTION__); -#endif - return -UNW_ENOINFO; -} diff --git a/src/pal/src/libunwind/src/hppa/Greg_states_iterate.c b/src/pal/src/libunwind/src/hppa/Greg_states_iterate.c deleted file mode 100644 index a17dc1b56..000000000 --- a/src/pal/src/libunwind/src/hppa/Greg_states_iterate.c +++ /dev/null @@ -1,37 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (c) 2002-2003 Hewlett-Packard Development Company, L.P. - Contributed by David Mosberger-Tang - - Modified for x86_64 by Max Asbock - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" - -int -unw_reg_states_iterate (unw_cursor_t *cursor, - unw_reg_states_callback cb, void *token) -{ - struct cursor *c = (struct cursor *) cursor; - - return dwarf_reg_states_iterate (&c->dwarf, cb, token); -} diff --git a/src/pal/src/libunwind/src/hppa/Gregs.c b/src/pal/src/libunwind/src/hppa/Gregs.c deleted file mode 100644 index da0542c81..000000000 --- a/src/pal/src/libunwind/src/hppa/Gregs.c +++ /dev/null @@ -1,87 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" - -HIDDEN int -tdep_access_reg (struct cursor *c, unw_regnum_t reg, unw_word_t *valp, - int write) -{ - struct dwarf_loc loc; - - switch (reg) - { - case UNW_HPPA_IP: - if (write) - c->dwarf.ip = *valp; /* update the IP cache */ - if (c->dwarf.pi_valid && (*valp < c->dwarf.pi.start_ip - || *valp >= c->dwarf.pi.end_ip)) - c->dwarf.pi_valid = 0; /* new IP outside of current proc */ - break; - - case UNW_HPPA_CFA: - case UNW_HPPA_SP: - if (write) - return -UNW_EREADONLYREG; - *valp = c->dwarf.cfa; - return 0; - - /* Do the exception-handling register remapping: */ - case UNW_HPPA_EH0: reg = UNW_HPPA_GR + 20; break; - case UNW_HPPA_EH1: reg = UNW_HPPA_GR + 21; break; - case UNW_HPPA_EH2: reg = UNW_HPPA_GR + 22; break; - case UNW_HPPA_EH3: reg = UNW_HPPA_GR + 31; break; - - default: - break; - } - - if ((unsigned) (reg - UNW_HPPA_GR) >= 32) - return -UNW_EBADREG; - - loc = c->dwarf.loc[reg]; - - if (write) - return dwarf_put (&c->dwarf, loc, *valp); - else - return dwarf_get (&c->dwarf, loc, valp); -} - -HIDDEN int -tdep_access_fpreg (struct cursor *c, unw_regnum_t reg, unw_fpreg_t *valp, - int write) -{ - struct dwarf_loc loc; - - if ((unsigned) (reg - UNW_HPPA_FR) >= 32) - return -UNW_EBADREG; - - loc = c->dwarf.loc[reg]; - - if (write) - return dwarf_putfp (&c->dwarf, loc, *valp); - else - return dwarf_getfp (&c->dwarf, loc, valp); -} diff --git a/src/pal/src/libunwind/src/hppa/Gresume.c b/src/pal/src/libunwind/src/hppa/Gresume.c deleted file mode 100644 index 6c11f1403..000000000 --- a/src/pal/src/libunwind/src/hppa/Gresume.c +++ /dev/null @@ -1,145 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (c) 2004 Hewlett-Packard Development Company, L.P. - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include - -#include "unwind_i.h" - -#ifndef UNW_REMOTE_ONLY - -#if defined(__linux) - -# include - -static NORETURN inline long -my_rt_sigreturn (void *new_sp, int in_syscall) -{ - register unsigned long r25 __asm__ ("r25") = (in_syscall != 0); - register unsigned long r20 __asm__ ("r20") = SYS_rt_sigreturn; - - __asm__ __volatile__ ("copy %0, %%sp\n" - "be,l 0x100(%%sr2,%%r0),%%sr0,%%r31\n" - "nop" - : - : "r"(new_sp), "r"(r20), "r"(r25) - : "memory"); - abort (); -} - -#endif /* __linux */ - -HIDDEN inline int -hppa_local_resume (unw_addr_space_t as, unw_cursor_t *cursor, void *arg) -{ -#if defined(__linux) - struct cursor *c = (struct cursor *) cursor; - ucontext_t *uc = c->dwarf.as_arg; - - /* Ensure c->pi is up-to-date. On PA-RISC, it's relatively common to be - missing DWARF unwind info. We don't want to fail in that case, - because the frame-chain still would let us do a backtrace at - least. */ - dwarf_make_proc_info (&c->dwarf); - - if (unlikely (c->sigcontext_format != HPPA_SCF_NONE)) - { - struct sigcontext *sc = (struct sigcontext *) c->sigcontext_addr; - - Debug (8, "resuming at ip=%x via sigreturn(%p)\n", c->dwarf.ip, sc); - my_rt_sigreturn (sc, (sc->sc_flags & PARISC_SC_FLAG_IN_SYSCALL) != 0); - } - else - { - Debug (8, "resuming at ip=%x via setcontext()\n", c->dwarf.ip); - setcontext (uc); - } -#else -# warning Implement me! -#endif - return -UNW_EINVAL; -} - -#endif /* !UNW_REMOTE_ONLY */ - -/* This routine is responsible for copying the register values in - cursor C and establishing them as the current machine state. */ - -static inline int -establish_machine_state (struct cursor *c) -{ - int (*access_reg) (unw_addr_space_t, unw_regnum_t, unw_word_t *, - int write, void *); - int (*access_fpreg) (unw_addr_space_t, unw_regnum_t, unw_fpreg_t *, - int write, void *); - unw_addr_space_t as = c->dwarf.as; - void *arg = c->dwarf.as_arg; - unw_fpreg_t fpval; - unw_word_t val; - int reg; - - access_reg = as->acc.access_reg; - access_fpreg = as->acc.access_fpreg; - - Debug (8, "copying out cursor state\n"); - - for (reg = 0; reg <= UNW_REG_LAST; ++reg) - { - Debug (16, "copying %s %d\n", unw_regname (reg), reg); - if (unw_is_fpreg (reg)) - { - if (tdep_access_fpreg (c, reg, &fpval, 0) >= 0) - (*access_fpreg) (as, reg, &fpval, 1, arg); - } - else - { - if (tdep_access_reg (c, reg, &val, 0) >= 0) - (*access_reg) (as, reg, &val, 1, arg); - } - } - return 0; -} - -int -unw_resume (unw_cursor_t *cursor) -{ - struct cursor *c = (struct cursor *) cursor; - int ret; - - Debug (1, "(cursor=%p)\n", c); - - if (!c->dwarf.ip) - { - /* This can happen easily when the frame-chain gets truncated - due to bad or missing unwind-info. */ - Debug (1, "refusing to resume execution at address 0\n"); - return -UNW_EINVAL; - } - - if ((ret = establish_machine_state (c)) < 0) - return ret; - - return (*c->dwarf.as->acc.resume) (c->dwarf.as, (unw_cursor_t *) c, - c->dwarf.as_arg); -} diff --git a/src/pal/src/libunwind/src/hppa/Gstep.c b/src/pal/src/libunwind/src/hppa/Gstep.c deleted file mode 100644 index 4fc8a8776..000000000 --- a/src/pal/src/libunwind/src/hppa/Gstep.c +++ /dev/null @@ -1,95 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2003-2004 Hewlett-Packard Co - Contributed by David Mosberger - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" -#include "offsets.h" - -int -unw_step (unw_cursor_t *cursor) -{ - struct cursor *c = (struct cursor *) cursor; - int ret, i; - - Debug (1, "(cursor=%p, ip=0x%08x)\n", c, (unsigned) c->dwarf.ip); - - /* Try DWARF-based unwinding... */ - ret = dwarf_step (&c->dwarf); - - if (ret < 0 && ret != -UNW_ENOINFO) - { - Debug (2, "returning %d\n", ret); - return ret; - } - - if (unlikely (ret < 0)) - { - /* DWARF failed, let's see if we can follow the frame-chain - or skip over the signal trampoline. */ - - Debug (13, "dwarf_step() failed (ret=%d), trying fallback\n", ret); - - if (unw_is_signal_frame (cursor)) - { -#ifdef __linux__ - /* Assume that the trampoline is at the beginning of the - sigframe. */ - unw_word_t ip, sc_addr = c->dwarf.ip + LINUX_RT_SIGFRAME_UC_OFF; - dwarf_loc_t iaoq_loc = DWARF_LOC (sc_addr + LINUX_SC_IAOQ_OFF, 0); - - c->sigcontext_format = HPPA_SCF_LINUX_RT_SIGFRAME; - c->sigcontext_addr = sc_addr; - - if ((ret = dwarf_get (&c->dwarf, iaoq_loc, &ip)) < 0) - { - Debug (2, "failed to read IAOQ[1] (ret=%d)\n", ret); - return ret; - } - c->dwarf.ip = ip & ~0x3; /* mask out the privilege level */ - - for (i = 0; i < 32; ++i) - { - c->dwarf.loc[UNW_HPPA_GR + i] - = DWARF_LOC (sc_addr + LINUX_SC_GR_OFF + 4*i, 0); - c->dwarf.loc[UNW_HPPA_FR + i] - = DWARF_LOC (sc_addr + LINUX_SC_FR_OFF + 4*i, 0); - } - - if ((ret = dwarf_get (&c->dwarf, c->dwarf.loc[UNW_HPPA_SP], - &c->dwarf.cfa)) < 0) - { - Debug (2, "failed to read SP (ret=%d)\n", ret); - return ret; - } -#else -# error Implement me! -#endif - } - else - c->dwarf.ip = 0; - } - ret = (c->dwarf.ip == 0) ? 0 : 1; - Debug (2, "returning %d\n", ret); - return ret; -} diff --git a/src/pal/src/libunwind/src/hppa/Lapply_reg_state.c b/src/pal/src/libunwind/src/hppa/Lapply_reg_state.c deleted file mode 100644 index 7ebada480..000000000 --- a/src/pal/src/libunwind/src/hppa/Lapply_reg_state.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gapply_reg_state.c" -#endif diff --git a/src/pal/src/libunwind/src/hppa/Lcreate_addr_space.c b/src/pal/src/libunwind/src/hppa/Lcreate_addr_space.c deleted file mode 100644 index 0f2dc6be9..000000000 --- a/src/pal/src/libunwind/src/hppa/Lcreate_addr_space.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gcreate_addr_space.c" -#endif diff --git a/src/pal/src/libunwind/src/hppa/Lget_proc_info.c b/src/pal/src/libunwind/src/hppa/Lget_proc_info.c deleted file mode 100644 index 69028b019..000000000 --- a/src/pal/src/libunwind/src/hppa/Lget_proc_info.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gget_proc_info.c" -#endif diff --git a/src/pal/src/libunwind/src/hppa/Lget_save_loc.c b/src/pal/src/libunwind/src/hppa/Lget_save_loc.c deleted file mode 100644 index 9ea048a90..000000000 --- a/src/pal/src/libunwind/src/hppa/Lget_save_loc.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gget_save_loc.c" -#endif diff --git a/src/pal/src/libunwind/src/hppa/Lglobal.c b/src/pal/src/libunwind/src/hppa/Lglobal.c deleted file mode 100644 index 6d7b489e1..000000000 --- a/src/pal/src/libunwind/src/hppa/Lglobal.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gglobal.c" -#endif diff --git a/src/pal/src/libunwind/src/hppa/Linit.c b/src/pal/src/libunwind/src/hppa/Linit.c deleted file mode 100644 index e9abfdd46..000000000 --- a/src/pal/src/libunwind/src/hppa/Linit.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Ginit.c" -#endif diff --git a/src/pal/src/libunwind/src/hppa/Linit_local.c b/src/pal/src/libunwind/src/hppa/Linit_local.c deleted file mode 100644 index 68a1687e8..000000000 --- a/src/pal/src/libunwind/src/hppa/Linit_local.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Ginit_local.c" -#endif diff --git a/src/pal/src/libunwind/src/hppa/Linit_remote.c b/src/pal/src/libunwind/src/hppa/Linit_remote.c deleted file mode 100644 index 58cb04ab7..000000000 --- a/src/pal/src/libunwind/src/hppa/Linit_remote.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Ginit_remote.c" -#endif diff --git a/src/pal/src/libunwind/src/hppa/Lis_signal_frame.c b/src/pal/src/libunwind/src/hppa/Lis_signal_frame.c deleted file mode 100644 index b9a7c4f51..000000000 --- a/src/pal/src/libunwind/src/hppa/Lis_signal_frame.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gis_signal_frame.c" -#endif diff --git a/src/pal/src/libunwind/src/hppa/Lreg_states_iterate.c b/src/pal/src/libunwind/src/hppa/Lreg_states_iterate.c deleted file mode 100644 index f1eb1e79d..000000000 --- a/src/pal/src/libunwind/src/hppa/Lreg_states_iterate.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Greg_states_iterate.c" -#endif diff --git a/src/pal/src/libunwind/src/hppa/Lregs.c b/src/pal/src/libunwind/src/hppa/Lregs.c deleted file mode 100644 index 2c9c75cd7..000000000 --- a/src/pal/src/libunwind/src/hppa/Lregs.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gregs.c" -#endif diff --git a/src/pal/src/libunwind/src/hppa/Lresume.c b/src/pal/src/libunwind/src/hppa/Lresume.c deleted file mode 100644 index 41a8cf003..000000000 --- a/src/pal/src/libunwind/src/hppa/Lresume.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gresume.c" -#endif diff --git a/src/pal/src/libunwind/src/hppa/Lstep.c b/src/pal/src/libunwind/src/hppa/Lstep.c deleted file mode 100644 index c1ac3c754..000000000 --- a/src/pal/src/libunwind/src/hppa/Lstep.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gstep.c" -#endif diff --git a/src/pal/src/libunwind/src/hppa/get_accessors.c b/src/pal/src/libunwind/src/hppa/get_accessors.c deleted file mode 100644 index 24795801b..000000000 --- a/src/pal/src/libunwind/src/hppa/get_accessors.c +++ /dev/null @@ -1,38 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2003 Hewlett-Packard Co - Contributed by ... - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" - -HIDDEN ALIAS(unw_get_accessors) unw_accessors_t * -unw_get_accessors_int (unw_addr_space_t as); - -unw_accessors_t * -unw_get_accessors (unw_addr_space_t as) -{ - if (!tdep_init_done) - tdep_init (); - - return &as->acc; -} diff --git a/src/pal/src/libunwind/src/hppa/getcontext.S b/src/pal/src/libunwind/src/hppa/getcontext.S deleted file mode 100644 index ec7554a02..000000000 --- a/src/pal/src/libunwind/src/hppa/getcontext.S +++ /dev/null @@ -1,74 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#define SPILL(n) stw %r##n, (LINUX_UC_MCONTEXT_OFF+LINUX_SC_GR_OFF+4*(n))(%r26) - -#include "offsets.h" - - .align 4 - .protected _Uhppa_getcontext - .global _Uhppa_getcontext - .proc - .callinfo -_Uhppa_getcontext: - SPILL (2) /* return-pointer */ - SPILL (3) /* frame pointer */ - SPILL (4) /* 2nd-ary frame pointer */ - SPILL (5) /* preserved register */ - SPILL (6) /* preserved register */ - SPILL (7) /* preserved register */ - SPILL (8) /* preserved register */ - SPILL (9) /* preserved register */ - SPILL (10) /* preserved register */ - SPILL (11) /* preserved register */ - SPILL (12) /* preserved register */ - SPILL (13) /* preserved register */ - SPILL (14) /* preserved register */ - SPILL (15) /* preserved register */ - SPILL (16) /* preserved register */ - SPILL (17) /* preserved register */ - SPILL (18) /* preserved register */ - SPILL (19) /* linkage-table register */ - SPILL (27) /* global-data pointer */ - SPILL (30) /* stack pointer */ - - ldo (LINUX_UC_MCONTEXT_OFF+LINUX_SC_FR_OFF)(%r26), %r29 - fstds,ma %fr12, 8(%r29) - fstds,ma %fr13, 8(%r29) - fstds,ma %fr14, 8(%r29) - fstds,ma %fr15, 8(%r29) - fstds,ma %fr16, 8(%r29) - fstds,ma %fr17, 8(%r29) - fstds,ma %fr18, 8(%r29) - fstds,ma %fr19, 8(%r29) - fstds,ma %fr20, 8(%r29) - fstds %fr21, 8(%r29) - - bv,n %r0(%rp) - .procend -#ifdef __linux__ - /* We do not need executable stack. */ - .section .note.GNU-stack,"",@progbits -#endif diff --git a/src/pal/src/libunwind/src/hppa/init.h b/src/pal/src/libunwind/src/hppa/init.h deleted file mode 100644 index 4e23b8613..000000000 --- a/src/pal/src/libunwind/src/hppa/init.h +++ /dev/null @@ -1,47 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2003 Hewlett-Packard Co - Contributed by ... - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" - -static inline int -common_init (struct cursor *c, unsigned use_prev_instr) -{ - int ret; - - c->dwarf.loc[UNW_HPPA_IP] = DWARF_REG_LOC (&c->dwarf, UNW_HPPA_IP); - c->dwarf.loc[UNW_HPPA_SP] = DWARF_REG_LOC (&c->dwarf, UNW_HPPA_SP); - - ret = dwarf_get (&c->dwarf, c->dwarf.loc[UNW_HPPA_IP], &c->dwarf.ip); - if (ret < 0) - return ret; - - ret = dwarf_get (&c->dwarf, c->dwarf.loc[UNW_HPPA_SP], &c->dwarf.cfa); - if (ret < 0) - return ret; - - c->dwarf.stash_frames = 0; - c->dwarf.use_prev_instr = use_prev_instr; - return 0; -} diff --git a/src/pal/src/libunwind/src/hppa/offsets.h b/src/pal/src/libunwind/src/hppa/offsets.h deleted file mode 100644 index 24e6453ac..000000000 --- a/src/pal/src/libunwind/src/hppa/offsets.h +++ /dev/null @@ -1,17 +0,0 @@ -#define LINUX_UC_FLAGS_OFF 0x000 -#define LINUX_UC_LINK_OFF 0x004 -#define LINUX_UC_STACK_OFF 0x008 -#define LINUX_UC_MCONTEXT_OFF 0x018 -#define LINUX_UC_SIGMASK_OFF 0x1b8 - -#define LINUX_SC_FLAGS_OFF 0x000 -#define LINUX_SC_GR_OFF 0x004 -#define LINUX_SC_FR_OFF 0x088 -#define LINUX_SC_IASQ_OFF 0x188 -#define LINUX_SC_IAOQ_OFF 0x190 -#define LINUX_SC_SAR_OFF 0x198 - -/* The signal frame contains 4 words of space for the sigreturn - trampoline, the siginfo structure, and then the sigcontext - structure. See include/asm-parisc/compat_rt_sigframe.h. */ -#define LINUX_RT_SIGFRAME_UC_OFF 0xac diff --git a/src/pal/src/libunwind/src/hppa/regname.c b/src/pal/src/libunwind/src/hppa/regname.c deleted file mode 100644 index 5698a58ad..000000000 --- a/src/pal/src/libunwind/src/hppa/regname.c +++ /dev/null @@ -1,50 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (c) 2004-2005 Hewlett-Packard Development Company, L.P. - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" - -static const char *regname[] = - { - "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", - "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", - "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23", - "r24", "r25", "r26", "r27", "r28", "r29", "r30", "r31", - "fr0", "fr1", "fr2", "fr3", "fr4", "fr5", "fr6", "fr7", - "fr8", "fr9", "fr10", "fr11", "fr12", "fr13", "fr14", "fr15", - "fr16", "fr17", "fr18", "fr19", "fr20", "fr21", "fr22", "fr23", - "fr24", "fr25", "fr26", "fr27", "fr28", "fr29", "fr30", "fr31", - "ip", - "eh0", "eh1", "eh2", "eh3", - "cfa" - }; - -const char * -unw_regname (unw_regnum_t reg) -{ - if (reg < (unw_regnum_t) ARRAY_SIZE (regname)) - return regname[reg]; - else - return "???"; -} diff --git a/src/pal/src/libunwind/src/hppa/setcontext.S b/src/pal/src/libunwind/src/hppa/setcontext.S deleted file mode 100644 index a36ea35cc..000000000 --- a/src/pal/src/libunwind/src/hppa/setcontext.S +++ /dev/null @@ -1,77 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -/* The setcontext() in glibc is a no-op (as of 4 Dec 2004), so we have - to implement something useful on our own here. */ - -#define FILL(n) ldw (LINUX_UC_MCONTEXT_OFF+LINUX_SC_GR_OFF+4*(n))(%r26),%r##n - -#include "offsets.h" - - .align 4 - .global _Uhppa_setcontext - .protected _Uhppa_setcontext - .proc - .callinfo -_Uhppa_setcontext: - FILL (2) /* return-pointer */ - FILL (3) /* frame pointer */ - FILL (4) /* 2nd-ary frame pointer */ - FILL (5) /* preserved register */ - FILL (6) /* preserved register */ - FILL (7) /* preserved register */ - FILL (8) /* preserved register */ - FILL (9) /* preserved register */ - FILL (10) /* preserved register */ - FILL (11) /* preserved register */ - FILL (12) /* preserved register */ - FILL (13) /* preserved register */ - FILL (14) /* preserved register */ - FILL (15) /* preserved register */ - FILL (16) /* preserved register */ - FILL (17) /* preserved register */ - FILL (18) /* preserved register */ - FILL (19) /* linkage-table register */ - FILL (27) /* global-data pointer */ - FILL (30) /* stack pointer */ - - ldo (LINUX_UC_MCONTEXT_OFF+LINUX_SC_FR_OFF)(%r26), %r29 - fldds,ma 8(%r29), %fr12 - fldds,ma 8(%r29), %fr13 - fldds,ma 8(%r29), %fr14 - fldds,ma 8(%r29), %fr15 - fldds,ma 8(%r29), %fr16 - fldds,ma 8(%r29), %fr17 - fldds,ma 8(%r29), %fr18 - fldds,ma 8(%r29), %fr19 - fldds,ma 8(%r29), %fr20 - fldds 8(%r29), %fr21 - - bv,n %r0(%rp) - .procend -#ifdef __linux__ - /* We do not need executable stack. */ - .section .note.GNU-stack,"",@progbits -#endif diff --git a/src/pal/src/libunwind/src/hppa/siglongjmp.S b/src/pal/src/libunwind/src/hppa/siglongjmp.S deleted file mode 100644 index 34878dbe8..000000000 --- a/src/pal/src/libunwind/src/hppa/siglongjmp.S +++ /dev/null @@ -1,16 +0,0 @@ - /* Dummy implementation for now. */ - - .globl _UI_siglongjmp_cont - .globl _UI_longjmp_cont - -_UI_siglongjmp_cont: -_UI_longjmp_cont: - .proc - .callinfo -#warning fix me - bv %r0(%rp) - .procend -#ifdef __linux__ - /* We do not need executable stack. */ - .section .note.GNU-stack,"",@progbits -#endif diff --git a/src/pal/src/libunwind/src/hppa/tables.c b/src/pal/src/libunwind/src/hppa/tables.c deleted file mode 100644 index 5104d4d34..000000000 --- a/src/pal/src/libunwind/src/hppa/tables.c +++ /dev/null @@ -1,43 +0,0 @@ -#include "unwind_i.h" - -static inline int -is_local_addr_space (unw_addr_space_t as) -{ - extern unw_addr_space_t _ULhppa_local_addr_space; - - return (as == _Uhppa_local_addr_space -#ifndef UNW_REMOTE_ONLY - || as == _ULhppa_local_addr_space -#endif - ); -} - -HIDDEN int -tdep_find_proc_info (unw_addr_space_t as, unw_word_t ip, - unw_proc_info_t *pi, int need_unwind_info, void *arg) -{ - printf ("%s: begging to get implemented...\n", __FUNCTION__); - return 0; -} - -HIDDEN int -tdep_search_unwind_table (unw_addr_space_t as, unw_word_t ip, - unw_dyn_info_t *di, - unw_proc_info_t *pi, int need_unwind_info, void *arg) -{ - printf ("%s: the biggest beggar of them all...\n", __FUNCTION__); - return 0; -} - -HIDDEN void -tdep_put_unwind_info (unw_addr_space_t as, unw_proc_info_t *pi, void *arg) -{ - if (!pi->unwind_info) - return; - - if (!is_local_addr_space (as)) - { - free (pi->unwind_info); - pi->unwind_info = NULL; - } -} diff --git a/src/pal/src/libunwind/src/hppa/unwind_i.h b/src/pal/src/libunwind/src/hppa/unwind_i.h deleted file mode 100644 index cafeab57b..000000000 --- a/src/pal/src/libunwind/src/hppa/unwind_i.h +++ /dev/null @@ -1,47 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2004-2005 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#ifndef unwind_i_h -#define unwind_i_h - -#include - -#include - -#include "libunwind_i.h" - -#define hppa_lock UNW_OBJ(lock) -#define hppa_local_resume UNW_OBJ(local_resume) -#define hppa_local_addr_space_init UNW_OBJ(local_addr_space_init) -#define hppa_scratch_loc UNW_OBJ(scratch_loc) -#define setcontext UNW_ARCH_OBJ (setcontext) - -extern void hppa_local_addr_space_init (void); -extern int hppa_local_resume (unw_addr_space_t as, unw_cursor_t *cursor, - void *arg); -extern dwarf_loc_t hppa_scratch_loc (struct cursor *c, unw_regnum_t reg); -extern int setcontext (const ucontext_t *ucp); - -#endif /* unwind_i_h */ diff --git a/src/pal/src/libunwind/src/ia64/Gapply_reg_state.c b/src/pal/src/libunwind/src/ia64/Gapply_reg_state.c deleted file mode 100644 index b45d1b5d9..000000000 --- a/src/pal/src/libunwind/src/ia64/Gapply_reg_state.c +++ /dev/null @@ -1,39 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (c) 2002-2003 Hewlett-Packard Development Company, L.P. - Contributed by David Mosberger-Tang - - Modified for x86_64 by Max Asbock - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" - -int -unw_apply_reg_state (unw_cursor_t *cursor, - void *reg_states_data) -{ - struct cursor *c = (struct cursor *) cursor; - - // Needs dwarf support on ia64 - // return dwarf_apply_reg_state (&c->dwarf, (dwarf_reg_state_t *)reg_states_data); - return -UNW_EINVAL; -} diff --git a/src/pal/src/libunwind/src/ia64/Gcreate_addr_space.c b/src/pal/src/libunwind/src/ia64/Gcreate_addr_space.c deleted file mode 100644 index 7ad29cbbd..000000000 --- a/src/pal/src/libunwind/src/ia64/Gcreate_addr_space.c +++ /dev/null @@ -1,63 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2002 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include - -#include "unwind_i.h" - -unw_addr_space_t -unw_create_addr_space (unw_accessors_t *a, int byte_order) -{ -#ifdef UNW_LOCAL_ONLY - return NULL; -#else - unw_addr_space_t as; - - /* - * IA-64 supports only big or little-endian, not weird stuff like - * PDP_ENDIAN. - */ - if (byte_order != 0 - && byte_order != __LITTLE_ENDIAN - && byte_order != __BIG_ENDIAN) - return NULL; - - as = malloc (sizeof (*as)); - - if (!as) - return NULL; - - memset (as, 0, sizeof (*as)); - - as->acc = *a; - - if (byte_order == 0) - /* use host default: */ - as->big_endian = (__BYTE_ORDER == __BIG_ENDIAN); - else - as->big_endian = (byte_order == __BIG_ENDIAN); - return as; -#endif -} diff --git a/src/pal/src/libunwind/src/ia64/Gfind_unwind_table.c b/src/pal/src/libunwind/src/ia64/Gfind_unwind_table.c deleted file mode 100644 index 9fd2707ac..000000000 --- a/src/pal/src/libunwind/src/ia64/Gfind_unwind_table.c +++ /dev/null @@ -1,143 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2003-2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ -#include -#include -#include -#include - -#include - -#include "libunwind_i.h" -#include "elf64.h" - -static unw_word_t -find_gp (struct elf_dyn_info *edi, Elf64_Phdr *pdyn, Elf64_Addr load_base) -{ - Elf64_Off soff, str_soff; - Elf64_Ehdr *ehdr = edi->ei.image; - Elf64_Shdr *shdr; - Elf64_Shdr *str_shdr; - Elf64_Addr gp = 0; - char *strtab; - int i; - - if (pdyn) - { - /* If we have a PT_DYNAMIC program header, fetch the gp-value - from the DT_PLTGOT entry. */ - Elf64_Dyn *dyn = (Elf64_Dyn *) (pdyn->p_offset + (char *) edi->ei.image); - for (; dyn->d_tag != DT_NULL; ++dyn) - if (dyn->d_tag == DT_PLTGOT) - { - gp = (Elf64_Addr) dyn->d_un.d_ptr + load_base; - goto done; - } - } - - /* Without a PT_DYAMIC header, lets try to look for a non-empty .opd - section. If there is such a section, we know it's full of - function descriptors, and we can simply pick up the gp from the - second word of the first entry in this table. */ - - soff = ehdr->e_shoff; - str_soff = soff + (ehdr->e_shstrndx * ehdr->e_shentsize); - - if (soff + ehdr->e_shnum * ehdr->e_shentsize > edi->ei.size) - { - Debug (1, "section table outside of image? (%lu > %lu)", - soff + ehdr->e_shnum * ehdr->e_shentsize, - edi->ei.size); - goto done; - } - - shdr = (Elf64_Shdr *) ((char *) edi->ei.image + soff); - str_shdr = (Elf64_Shdr *) ((char *) edi->ei.image + str_soff); - strtab = (char *) edi->ei.image + str_shdr->sh_offset; - for (i = 0; i < ehdr->e_shnum; ++i) - { - if (strcmp (strtab + shdr->sh_name, ".opd") == 0 - && shdr->sh_size >= 16) - { - gp = ((Elf64_Addr *) ((char *) edi->ei.image + shdr->sh_offset))[1]; - goto done; - } - shdr = (Elf64_Shdr *) (((char *) shdr) + ehdr->e_shentsize); - } - - done: - Debug (16, "image at %p, gp = %lx\n", edi->ei.image, gp); - return gp; -} - -int -ia64_find_unwind_table (struct elf_dyn_info *edi, unw_addr_space_t as, - char *path, unw_word_t segbase, unw_word_t mapoff, - unw_word_t ip) -{ - Elf64_Phdr *phdr, *ptxt = NULL, *punw = NULL, *pdyn = NULL; - Elf64_Ehdr *ehdr; - int i; - - if (!_Uelf64_valid_object (&edi->ei)) - return -UNW_ENOINFO; - - ehdr = edi->ei.image; - phdr = (Elf64_Phdr *) ((char *) edi->ei.image + ehdr->e_phoff); - - for (i = 0; i < ehdr->e_phnum; ++i) - { - switch (phdr[i].p_type) - { - case PT_LOAD: - if (phdr[i].p_offset == mapoff) - ptxt = phdr + i; - break; - - case PT_IA_64_UNWIND: - punw = phdr + i; - break; - - case PT_DYNAMIC: - pdyn = phdr + i; - break; - - default: - break; - } - } - if (!ptxt || !punw) - return 0; - - edi->di_cache.start_ip = segbase; - edi->di_cache.end_ip = edi->di_cache.start_ip + ptxt->p_memsz; - edi->di_cache.gp = find_gp (edi, pdyn, segbase - ptxt->p_vaddr); - edi->di_cache.format = UNW_INFO_FORMAT_TABLE; - edi->di_cache.u.ti.name_ptr = 0; - edi->di_cache.u.ti.segbase = segbase; - edi->di_cache.u.ti.table_len = punw->p_memsz / sizeof (unw_word_t); - edi->di_cache.u.ti.table_data = (unw_word_t *) - ((char *) edi->ei.image + (punw->p_vaddr - ptxt->p_vaddr)); - return 1; -} diff --git a/src/pal/src/libunwind/src/ia64/Gget_proc_info.c b/src/pal/src/libunwind/src/ia64/Gget_proc_info.c deleted file mode 100644 index 3ec82b9f8..000000000 --- a/src/pal/src/libunwind/src/ia64/Gget_proc_info.c +++ /dev/null @@ -1,38 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2002 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" - -int -unw_get_proc_info (unw_cursor_t *cursor, unw_proc_info_t *pi) -{ - struct cursor *c = (struct cursor *) cursor; - int ret; - - if ((ret = ia64_make_proc_info (c)) < 0) - return ret; - *pi = c->pi; - return 0; -} diff --git a/src/pal/src/libunwind/src/ia64/Gget_save_loc.c b/src/pal/src/libunwind/src/ia64/Gget_save_loc.c deleted file mode 100644 index 34efe99a7..000000000 --- a/src/pal/src/libunwind/src/ia64/Gget_save_loc.c +++ /dev/null @@ -1,168 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2002-2003, 2005 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include - -#include "rse.h" - -#include "offsets.h" -#include "regs.h" - -int -unw_get_save_loc (unw_cursor_t *cursor, int reg, unw_save_loc_t *sloc) -{ - struct cursor *c = (struct cursor *) cursor; - ia64_loc_t loc, reg_loc; - uint8_t nat_bitnr; - int ret; - - loc = IA64_NULL_LOC; /* default to "not saved" */ - - switch (reg) - { - /* frame registers */ - case UNW_IA64_BSP: - case UNW_REG_SP: - default: - break; - - case UNW_REG_IP: - loc = c->loc[IA64_REG_IP]; - break; - - /* preserved registers: */ - case UNW_IA64_GR + 4 ... UNW_IA64_GR + 7: - loc = c->loc[IA64_REG_R4 + (reg - (UNW_IA64_GR + 4))]; - break; - - case UNW_IA64_NAT + 4 ... UNW_IA64_NAT + 7: - loc = c->loc[IA64_REG_NAT4 + (reg - (UNW_IA64_NAT + 4))]; - reg_loc = c->loc[IA64_REG_R4 + (reg - (UNW_IA64_NAT + 4))]; - nat_bitnr = c->nat_bitnr[reg - (UNW_IA64_NAT + 4)]; - if (IA64_IS_FP_LOC (reg_loc)) - /* NaT bit saved as a NaTVal. */ - loc = reg_loc; - break; - - case UNW_IA64_FR + 2: loc = c->loc[IA64_REG_F2]; break; - case UNW_IA64_FR + 3: loc = c->loc[IA64_REG_F3]; break; - case UNW_IA64_FR + 4: loc = c->loc[IA64_REG_F4]; break; - case UNW_IA64_FR + 5: loc = c->loc[IA64_REG_F5]; break; - case UNW_IA64_FR + 16 ... UNW_IA64_FR + 31: - loc = c->loc[IA64_REG_F16 + (reg - (UNW_IA64_FR + 16))]; - break; - - case UNW_IA64_AR_BSP: loc = c->loc[IA64_REG_BSP]; break; - case UNW_IA64_AR_BSPSTORE: loc = c->loc[IA64_REG_BSPSTORE]; break; - case UNW_IA64_AR_PFS: loc = c->loc[IA64_REG_PFS]; break; - case UNW_IA64_AR_RNAT: loc = c->loc[IA64_REG_RNAT]; break; - case UNW_IA64_AR_UNAT: loc = c->loc[IA64_REG_UNAT]; break; - case UNW_IA64_AR_LC: loc = c->loc[IA64_REG_LC]; break; - case UNW_IA64_AR_FPSR: loc = c->loc[IA64_REG_FPSR]; break; - case UNW_IA64_BR + 1: loc = c->loc[IA64_REG_B1]; break; - case UNW_IA64_BR + 2: loc = c->loc[IA64_REG_B2]; break; - case UNW_IA64_BR + 3: loc = c->loc[IA64_REG_B3]; break; - case UNW_IA64_BR + 4: loc = c->loc[IA64_REG_B4]; break; - case UNW_IA64_BR + 5: loc = c->loc[IA64_REG_B5]; break; - case UNW_IA64_CFM: loc = c->cfm_loc; break; - case UNW_IA64_PR: loc = c->loc[IA64_REG_PR]; break; - - case UNW_IA64_GR + 32 ... UNW_IA64_GR + 127: /* stacked reg */ - reg = rotate_gr (c, reg - UNW_IA64_GR); - ret = ia64_get_stacked (c, reg, &loc, NULL); - if (ret < 0) - return ret; - break; - - case UNW_IA64_NAT + 32 ... UNW_IA64_NAT + 127: /* stacked reg */ - reg = rotate_gr (c, reg - UNW_IA64_NAT); - ret = ia64_get_stacked (c, reg, NULL, &loc); - break; - - case UNW_IA64_AR_EC: - loc = c->cfm_loc; - break; - - /* scratch & special registers: */ - - case UNW_IA64_GR + 0: - case UNW_IA64_GR + 1: /* global pointer */ - case UNW_IA64_NAT + 0: - case UNW_IA64_NAT + 1: /* global pointer */ - case UNW_IA64_FR + 0: - case UNW_IA64_FR + 1: - break; - - case UNW_IA64_NAT + 2 ... UNW_IA64_NAT + 3: - case UNW_IA64_NAT + 8 ... UNW_IA64_NAT + 31: - loc = ia64_scratch_loc (c, reg, &nat_bitnr); - break; - - case UNW_IA64_GR + 2 ... UNW_IA64_GR + 3: - case UNW_IA64_GR + 8 ... UNW_IA64_GR + 31: - case UNW_IA64_BR + 0: - case UNW_IA64_BR + 6: - case UNW_IA64_BR + 7: - case UNW_IA64_AR_RSC: - case UNW_IA64_AR_CSD: - case UNW_IA64_AR_SSD: - case UNW_IA64_AR_CCV: - loc = ia64_scratch_loc (c, reg, NULL); - break; - - case UNW_IA64_FR + 6 ... UNW_IA64_FR + 15: - loc = ia64_scratch_loc (c, reg, NULL); - break; - - case UNW_IA64_FR + 32 ... UNW_IA64_FR + 127: - reg = rotate_fr (c, reg - UNW_IA64_FR) + UNW_IA64_FR; - loc = ia64_scratch_loc (c, reg, NULL); - break; - } - - memset (sloc, 0, sizeof (*sloc)); - - if (IA64_IS_NULL_LOC (loc)) - { - sloc->type = UNW_SLT_NONE; - return 0; - } - -#if !defined(UNW_LOCAL_ONLY) - if (IA64_IS_REG_LOC (loc)) - { - sloc->type = UNW_SLT_REG; - sloc->u.regnum = IA64_GET_REG (loc); - sloc->extra.nat_bitnr = nat_bitnr; - } - else -#endif - { - sloc->type = UNW_SLT_MEMORY; - sloc->u.addr = IA64_GET_ADDR (loc); - sloc->extra.nat_bitnr = nat_bitnr; - } - return 0; -} diff --git a/src/pal/src/libunwind/src/ia64/Gglobal.c b/src/pal/src/libunwind/src/ia64/Gglobal.c deleted file mode 100644 index 5c6156f0e..000000000 --- a/src/pal/src/libunwind/src/ia64/Gglobal.c +++ /dev/null @@ -1,122 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2002-2005 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include - -#include "unwind_i.h" - -HIDDEN struct ia64_global_unwind_state unw = - { - .lock = PTHREAD_MUTEX_INITIALIZER, - .save_order = { - IA64_REG_IP, IA64_REG_PFS, IA64_REG_PSP, IA64_REG_PR, - IA64_REG_UNAT, IA64_REG_LC, IA64_REG_FPSR, IA64_REG_PRI_UNAT_GR - }, -#if UNW_DEBUG - .preg_name = { - "pri_unat_gr", "pri_unat_mem", "psp", "bsp", "bspstore", - "ar.pfs", "ar.rnat", "rp", - "r4", "r5", "r6", "r7", - "nat4", "nat5", "nat6", "nat7", - "ar.unat", "pr", "ar.lc", "ar.fpsr", - "b1", "b2", "b3", "b4", "b5", - "f2", "f3", "f4", "f5", - "f16", "f17", "f18", "f19", "f20", "f21", "f22", "f23", - "f24", "f25", "f26", "f27", "f28", "f29", "f30", "f31" - } -#endif -}; - -HIDDEN void -tdep_init (void) -{ - const uint8_t f1_bytes[16] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, - 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - }; - const uint8_t nat_val_bytes[16] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0xfe, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - }; - const uint8_t int_val_bytes[16] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x3e, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - }; - intrmask_t saved_mask; - uint8_t *lep, *bep; - long i; - - sigfillset (&unwi_full_mask); - - lock_acquire (&unw.lock, saved_mask); - { - if (tdep_init_done) - /* another thread else beat us to it... */ - goto out; - - mi_init (); - - mempool_init (&unw.reg_state_pool, sizeof (struct ia64_reg_state), 0); - mempool_init (&unw.labeled_state_pool, - sizeof (struct ia64_labeled_state), 0); - - unw.read_only.r0 = 0; - unw.read_only.f0.raw.bits[0] = 0; - unw.read_only.f0.raw.bits[1] = 0; - - lep = (uint8_t *) &unw.read_only.f1_le + 16; - bep = (uint8_t *) &unw.read_only.f1_be; - for (i = 0; i < 16; ++i) - { - *--lep = f1_bytes[i]; - *bep++ = f1_bytes[i]; - } - - lep = (uint8_t *) &unw.nat_val_le + 16; - bep = (uint8_t *) &unw.nat_val_be; - for (i = 0; i < 16; ++i) - { - *--lep = nat_val_bytes[i]; - *bep++ = nat_val_bytes[i]; - } - - lep = (uint8_t *) &unw.int_val_le + 16; - bep = (uint8_t *) &unw.int_val_be; - for (i = 0; i < 16; ++i) - { - *--lep = int_val_bytes[i]; - *bep++ = int_val_bytes[i]; - } - - assert (8*sizeof(unw_hash_index_t) >= IA64_LOG_UNW_HASH_SIZE); - -#ifndef UNW_REMOTE_ONLY - ia64_local_addr_space_init (); -#endif - tdep_init_done = 1; /* signal that we're initialized... */ - } - out: - lock_release (&unw.lock, saved_mask); -} diff --git a/src/pal/src/libunwind/src/ia64/Ginit.c b/src/pal/src/libunwind/src/ia64/Ginit.c deleted file mode 100644 index b09a2ad57..000000000 --- a/src/pal/src/libunwind/src/ia64/Ginit.c +++ /dev/null @@ -1,505 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2001-2005 Hewlett-Packard Co - Copyright (C) 2007 David Mosberger-Tang - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" - -#ifdef HAVE_SYS_UC_ACCESS_H -# include -#endif - -#ifdef UNW_REMOTE_ONLY - -/* unw_local_addr_space is a NULL pointer in this case. */ -unw_addr_space_t unw_local_addr_space; - -#else /* !UNW_REMOTE_ONLY */ - -static struct unw_addr_space local_addr_space; - -unw_addr_space_t unw_local_addr_space = &local_addr_space; - -#ifdef HAVE_SYS_UC_ACCESS_H - -#else /* !HAVE_SYS_UC_ACCESS_H */ - -HIDDEN void * -tdep_uc_addr (ucontext_t *uc, int reg, uint8_t *nat_bitnr) -{ - return inlined_uc_addr (uc, reg, nat_bitnr); -} - -#endif /* !HAVE_SYS_UC_ACCESS_H */ - -static void -put_unwind_info (unw_addr_space_t as, unw_proc_info_t *proc_info, void *arg) -{ - /* it's a no-op */ -} - -static int -get_dyn_info_list_addr (unw_addr_space_t as, unw_word_t *dyn_info_list_addr, - void *arg) -{ -#ifndef UNW_LOCAL_ONLY -# pragma weak _U_dyn_info_list_addr - if (!_U_dyn_info_list_addr) - return -UNW_ENOINFO; -#endif - *dyn_info_list_addr = _U_dyn_info_list_addr (); - return 0; -} - -static int -access_mem (unw_addr_space_t as, unw_word_t addr, unw_word_t *val, int write, - void *arg) -{ - if (write) - { - Debug (12, "mem[%lx] <- %lx\n", addr, *val); - *(unw_word_t *) addr = *val; - } - else - { - *val = *(unw_word_t *) addr; - Debug (12, "mem[%lx] -> %lx\n", addr, *val); - } - return 0; -} - -#ifdef HAVE_SYS_UC_ACCESS_H - -#define SYSCALL_CFM_SAVE_REG 11 /* on a syscall, ar.pfs is saved in r11 */ -#define REASON_SYSCALL 0 - -static int -access_reg (unw_addr_space_t as, unw_regnum_t reg, unw_word_t *val, int write, - void *arg) -{ - ucontext_t *uc = arg; - unsigned int nat, mask; - uint64_t value; - uint16_t reason; - int ret; - - __uc_get_reason (uc, &reason); - - switch (reg) - { - case UNW_IA64_GR ... UNW_IA64_GR + 31: - if ((ret = __uc_get_grs (uc, (reg - UNW_IA64_GR), 1, &value, &nat))) - break; - - if (write) - ret = __uc_set_grs (uc, (reg - UNW_IA64_GR), 1, val, nat); - else - *val = value; - break; - - case UNW_IA64_NAT ... UNW_IA64_NAT + 31: - if ((ret = __uc_get_grs (uc, (reg - UNW_IA64_GR), 1, &value, &nat))) - break; - - mask = 1 << (reg - UNW_IA64_GR); - - if (write) - { - if (*val) - nat |= mask; - else - nat &= ~mask; - ret = __uc_set_grs (uc, (reg - UNW_IA64_GR), 1, &value, nat); - } - else - *val = (nat & mask) != 0; - break; - - case UNW_IA64_AR ... UNW_IA64_AR + 127: - if (reg == UNW_IA64_AR_BSP) - { - if (write) - ret = __uc_set_ar (uc, (reg - UNW_IA64_AR), *val); - else - ret = __uc_get_ar (uc, (reg - UNW_IA64_AR), val); - } - else if (reg == UNW_IA64_AR_PFS && reason == REASON_SYSCALL) - { - /* As of HP-UX 11.22, getcontext() does not have unwind info - and because of that, we need to hack thins manually here. - Hopefully, this is OK because the HP-UX kernel also needs - to know where AR.PFS has been saved, so the use of - register r11 for this purpose is pretty much nailed - down. */ - if (write) - ret = __uc_set_grs (uc, SYSCALL_CFM_SAVE_REG, 1, val, 0); - else - ret = __uc_get_grs (uc, SYSCALL_CFM_SAVE_REG, 1, val, &nat); - } - else - { - if (write) - ret = __uc_set_ar (uc, (reg - UNW_IA64_AR), *val); - else - ret = __uc_get_ar (uc, (reg - UNW_IA64_AR), val); - } - break; - - case UNW_IA64_BR ... UNW_IA64_BR + 7: - if (write) - ret = __uc_set_brs (uc, (reg - UNW_IA64_BR), 1, val); - else - ret = __uc_get_brs (uc, (reg - UNW_IA64_BR), 1, val); - break; - - case UNW_IA64_PR: - if (write) - ret = __uc_set_prs (uc, *val); - else - ret = __uc_get_prs (uc, val); - break; - - case UNW_IA64_IP: - if (write) - ret = __uc_set_ip (uc, *val); - else - ret = __uc_get_ip (uc, val); - break; - - case UNW_IA64_CFM: - if (write) - ret = __uc_set_cfm (uc, *val); - else - ret = __uc_get_cfm (uc, val); - break; - - case UNW_IA64_FR ... UNW_IA64_FR + 127: - default: - ret = EINVAL; - break; - } - - if (ret != 0) - { - Debug (1, "failed to %s %s (ret = %d)\n", - write ? "write" : "read", unw_regname (reg), ret); - return -UNW_EBADREG; - } - - if (write) - Debug (12, "%s <- %lx\n", unw_regname (reg), *val); - else - Debug (12, "%s -> %lx\n", unw_regname (reg), *val); - return 0; -} - -static int -access_fpreg (unw_addr_space_t as, unw_regnum_t reg, unw_fpreg_t *val, - int write, void *arg) -{ - ucontext_t *uc = arg; - fp_regval_t fp_regval; - int ret; - - switch (reg) - { - case UNW_IA64_FR ... UNW_IA64_FR + 127: - if (write) - { - memcpy (&fp_regval, val, sizeof (fp_regval)); - ret = __uc_set_frs (uc, (reg - UNW_IA64_FR), 1, &fp_regval); - } - else - { - ret = __uc_get_frs (uc, (reg - UNW_IA64_FR), 1, &fp_regval); - memcpy (val, &fp_regval, sizeof (*val)); - } - break; - - default: - ret = EINVAL; - break; - } - if (ret != 0) - return -UNW_EBADREG; - - return 0; -} - -#else /* !HAVE_SYS_UC_ACCESS_H */ - -static int -access_reg (unw_addr_space_t as, unw_regnum_t reg, unw_word_t *val, int write, - void *arg) -{ - unw_word_t *addr, mask; - ucontext_t *uc = arg; - - if (reg >= UNW_IA64_NAT + 4 && reg <= UNW_IA64_NAT + 7) - { - mask = ((unw_word_t) 1) << (reg - UNW_IA64_NAT); - if (write) - { - if (*val) - uc->uc_mcontext.sc_nat |= mask; - else - uc->uc_mcontext.sc_nat &= ~mask; - } - else - *val = (uc->uc_mcontext.sc_nat & mask) != 0; - - if (write) - Debug (12, "%s <- %lx\n", unw_regname (reg), *val); - else - Debug (12, "%s -> %lx\n", unw_regname (reg), *val); - return 0; - } - - addr = tdep_uc_addr (uc, reg, NULL); - if (!addr) - goto badreg; - - if (write) - { - if (ia64_read_only_reg (addr)) - { - Debug (16, "attempt to write read-only register\n"); - return -UNW_EREADONLYREG; - } - *addr = *val; - Debug (12, "%s <- %lx\n", unw_regname (reg), *val); - } - else - { - *val = *(unw_word_t *) addr; - Debug (12, "%s -> %lx\n", unw_regname (reg), *val); - } - return 0; - - badreg: - Debug (1, "bad register number %u\n", reg); - return -UNW_EBADREG; -} - -static int -access_fpreg (unw_addr_space_t as, unw_regnum_t reg, unw_fpreg_t *val, - int write, void *arg) -{ - ucontext_t *uc = arg; - unw_fpreg_t *addr; - - if (reg < UNW_IA64_FR || reg >= UNW_IA64_FR + 128) - goto badreg; - - addr = tdep_uc_addr (uc, reg, NULL); - if (!addr) - goto badreg; - - if (write) - { - if (ia64_read_only_reg (addr)) - { - Debug (16, "attempt to write read-only register\n"); - return -UNW_EREADONLYREG; - } - *addr = *val; - Debug (12, "%s <- %016lx.%016lx\n", - unw_regname (reg), val->raw.bits[1], val->raw.bits[0]); - } - else - { - *val = *(unw_fpreg_t *) addr; - Debug (12, "%s -> %016lx.%016lx\n", - unw_regname (reg), val->raw.bits[1], val->raw.bits[0]); - } - return 0; - - badreg: - Debug (1, "bad register number %u\n", reg); - /* attempt to access a non-preserved register */ - return -UNW_EBADREG; -} - -#endif /* !HAVE_SYS_UC_ACCESS_H */ - -static int -get_static_proc_name (unw_addr_space_t as, unw_word_t ip, - char *buf, size_t buf_len, unw_word_t *offp, - void *arg) -{ - return _Uelf64_get_proc_name (as, getpid (), ip, buf, buf_len, offp); -} - -HIDDEN void -ia64_local_addr_space_init (void) -{ - memset (&local_addr_space, 0, sizeof (local_addr_space)); - local_addr_space.big_endian = (__BYTE_ORDER == __BIG_ENDIAN); -#if defined(__linux) - local_addr_space.abi = ABI_LINUX; -#elif defined(__hpux) - local_addr_space.abi = ABI_HPUX; -#endif - local_addr_space.caching_policy = UNWI_DEFAULT_CACHING_POLICY; - local_addr_space.acc.find_proc_info = tdep_find_proc_info; - local_addr_space.acc.put_unwind_info = put_unwind_info; - local_addr_space.acc.get_dyn_info_list_addr = get_dyn_info_list_addr; - local_addr_space.acc.access_mem = access_mem; - local_addr_space.acc.access_reg = access_reg; - local_addr_space.acc.access_fpreg = access_fpreg; - local_addr_space.acc.resume = ia64_local_resume; - local_addr_space.acc.get_proc_name = get_static_proc_name; - unw_flush_cache (&local_addr_space, 0, 0); -} - -#endif /* !UNW_REMOTE_ONLY */ - -#ifndef UNW_LOCAL_ONLY - -HIDDEN int -ia64_uc_access_reg (struct cursor *c, ia64_loc_t loc, unw_word_t *valp, - int write) -{ -#ifdef HAVE_SYS_UC_ACCESS_H - unw_word_t uc_addr = IA64_GET_AUX_ADDR (loc); - ucontext_t *ucp; - int ret; - - Debug (16, "%s location %s\n", - write ? "writing" : "reading", ia64_strloc (loc)); - - if (c->as == unw_local_addr_space) - ucp = (ucontext_t *) uc_addr; - else - { - unw_word_t *dst, src; - - /* Need to copy-in ucontext_t first. */ - ucp = alloca (sizeof (ucontext_t)); - if (!ucp) - return -UNW_ENOMEM; - - /* For now, there is no non-HP-UX implementation of the - uc_access(3) interface. Because of that, we cannot, e.g., - unwind an HP-UX program from a Linux program. Should that - become possible at some point in the future, the - copy-in/copy-out needs to be adjusted to do byte-swapping if - necessary. */ - assert (c->as->big_endian == (__BYTE_ORDER == __BIG_ENDIAN)); - - dst = (unw_word_t *) ucp; - for (src = uc_addr; src < uc_addr + sizeof (ucontext_t); src += 8) - if ((ret = (*c->as->acc.access_mem) (c->as, src, dst++, 0, c->as_arg)) - < 0) - return ret; - } - - if (IA64_IS_REG_LOC (loc)) - ret = access_reg (unw_local_addr_space, IA64_GET_REG (loc), valp, write, - ucp); - else - { - /* Must be an access to the RSE backing store in ucontext_t. */ - unw_word_t addr = IA64_GET_ADDR (loc); - - if (write) - ret = __uc_set_rsebs (ucp, (uint64_t *) addr, 1, valp); - else - ret = __uc_get_rsebs (ucp, (uint64_t *) addr, 1, valp); - if (ret != 0) - ret = -UNW_EBADREG; - } - if (ret < 0) - return ret; - - if (write && c->as != unw_local_addr_space) - { - /* need to copy-out ucontext_t: */ - unw_word_t dst, *src = (unw_word_t *) ucp; - for (dst = uc_addr; dst < uc_addr + sizeof (ucontext_t); dst += 8) - if ((ret = (*c->as->acc.access_mem) (c->as, dst, src++, 1, c->as_arg)) - < 0) - return ret; - } - return 0; -#else /* !HAVE_SYS_UC_ACCESS_H */ - return -UNW_EINVAL; -#endif /* !HAVE_SYS_UC_ACCESS_H */ -} - -HIDDEN int -ia64_uc_access_fpreg (struct cursor *c, ia64_loc_t loc, unw_fpreg_t *valp, - int write) -{ -#ifdef HAVE_SYS_UC_ACCESS_H - unw_word_t uc_addr = IA64_GET_AUX_ADDR (loc); - ucontext_t *ucp; - int ret; - - if (c->as == unw_local_addr_space) - ucp = (ucontext_t *) uc_addr; - else - { - unw_word_t *dst, src; - - /* Need to copy-in ucontext_t first. */ - ucp = alloca (sizeof (ucontext_t)); - if (!ucp) - return -UNW_ENOMEM; - - /* For now, there is no non-HP-UX implementation of the - uc_access(3) interface. Because of that, we cannot, e.g., - unwind an HP-UX program from a Linux program. Should that - become possible at some point in the future, the - copy-in/copy-out needs to be adjusted to do byte-swapping if - necessary. */ - assert (c->as->big_endian == (__BYTE_ORDER == __BIG_ENDIAN)); - - dst = (unw_word_t *) ucp; - for (src = uc_addr; src < uc_addr + sizeof (ucontext_t); src += 8) - if ((ret = (*c->as->acc.access_mem) (c->as, src, dst++, 0, c->as_arg)) - < 0) - return ret; - } - - if ((ret = access_fpreg (unw_local_addr_space, IA64_GET_REG (loc), valp, - write, ucp)) < 0) - return ret; - - if (write && c->as != unw_local_addr_space) - { - /* need to copy-out ucontext_t: */ - unw_word_t dst, *src = (unw_word_t *) ucp; - for (dst = uc_addr; dst < uc_addr + sizeof (ucontext_t); dst += 8) - if ((ret = (*c->as->acc.access_mem) (c->as, dst, src++, 1, c->as_arg)) - < 0) - return ret; - } - return 0; -#else /* !HAVE_SYS_UC_ACCESS_H */ - return -UNW_EINVAL; -#endif /* !HAVE_SYS_UC_ACCESS_H */ -} - -#endif /* UNW_LOCAL_ONLY */ diff --git a/src/pal/src/libunwind/src/ia64/Ginit_local.c b/src/pal/src/libunwind/src/ia64/Ginit_local.c deleted file mode 100644 index 8fe1c679b..000000000 --- a/src/pal/src/libunwind/src/ia64/Ginit_local.c +++ /dev/null @@ -1,110 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2001-2003, 2005 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include "init.h" -#include "unwind_i.h" - -#ifdef UNW_REMOTE_ONLY - -int -unw_init_local (unw_cursor_t *cursor, unw_context_t *uc) -{ - return -UNW_EINVAL; -} - -#else /* !UNW_REMOTE_ONLY */ - -static inline void -set_as_arg (struct cursor *c, unw_context_t *uc) -{ -#if defined(__linux) && defined(__KERNEL__) - c->task = current; - c->as_arg = &uc->sw; -#else - c->as_arg = uc; -#endif -} - -static inline int -get_initial_stack_pointers (struct cursor *c, unw_context_t *uc, - unw_word_t *sp, unw_word_t *bsp) -{ -#if defined(__linux) - unw_word_t sol, bspstore; - -#ifdef __KERNEL__ - sol = (uc->sw.ar_pfs >> 7) & 0x7f; - bspstore = uc->sw.ar_bspstore; - *sp = uc->ksp; -# else - sol = (uc->uc_mcontext.sc_ar_pfs >> 7) & 0x7f; - bspstore = uc->uc_mcontext.sc_ar_bsp; - *sp = uc->uc_mcontext.sc_gr[12]; -# endif - *bsp = rse_skip_regs (bspstore, -sol); -#elif defined(__hpux) - int ret; - - if ((ret = ia64_get (c, IA64_REG_LOC (c, UNW_IA64_GR + 12), sp)) < 0 - || (ret = ia64_get (c, IA64_REG_LOC (c, UNW_IA64_AR_BSP), bsp)) < 0) - return ret; -#else -# error Fix me. -#endif - return 0; -} - -int -unw_init_local (unw_cursor_t *cursor, unw_context_t *uc) -{ - struct cursor *c = (struct cursor *) cursor; - unw_word_t sp, bsp; - int ret; - - if (!tdep_init_done) - tdep_init (); - - Debug (1, "(cursor=%p)\n", c); - - c->as = unw_local_addr_space; - set_as_arg (c, uc); - - if ((ret = get_initial_stack_pointers (c, uc, &sp, &bsp)) < 0) - return ret; - - Debug (4, "initial bsp=%lx, sp=%lx\n", bsp, sp); - - if ((ret = common_init (c, sp, bsp)) < 0) - return ret; - -#ifdef __hpux - /* On HP-UX, the context created by getcontext() points to the - getcontext() system call stub. Step over it: */ - ret = unw_step (cursor); -#endif - return ret; -} - -#endif /* !UNW_REMOTE_ONLY */ diff --git a/src/pal/src/libunwind/src/ia64/Ginit_remote.c b/src/pal/src/libunwind/src/ia64/Ginit_remote.c deleted file mode 100644 index b570c7eab..000000000 --- a/src/pal/src/libunwind/src/ia64/Ginit_remote.c +++ /dev/null @@ -1,61 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2001-2002, 2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include "init.h" -#include "unwind_i.h" - -int -unw_init_remote (unw_cursor_t *cursor, unw_addr_space_t as, void *as_arg) -{ -#ifdef UNW_LOCAL_ONLY - return -UNW_EINVAL; -#else /* !UNW_LOCAL_ONLY */ - struct cursor *c = (struct cursor *) cursor; - unw_word_t sp, bsp; - int ret; - - if (!tdep_init_done) - tdep_init (); - - Debug (1, "(cursor=%p)\n", c); - - if (as == unw_local_addr_space) - /* This special-casing is unfortunate and shouldn't be needed; - however, both Linux and HP-UX need to adjust the context a bit - before it's usable. Try to think of a cleaner way of doing - this. Not sure it's possible though, as long as we want to be - able to use the context returned by getcontext() et al. */ - return unw_init_local (cursor, as_arg); - - c->as = as; - c->as_arg = as_arg; - - if ((ret = ia64_get (c, IA64_REG_LOC (c, UNW_IA64_GR + 12), &sp)) < 0 - || (ret = ia64_get (c, IA64_REG_LOC (c, UNW_IA64_AR_BSP), &bsp)) < 0) - return ret; - - return common_init (c, sp, bsp); -#endif /* !UNW_LOCAL_ONLY */ -} diff --git a/src/pal/src/libunwind/src/ia64/Ginstall_cursor.S b/src/pal/src/libunwind/src/ia64/Ginstall_cursor.S deleted file mode 100644 index 6fb4401fa..000000000 --- a/src/pal/src/libunwind/src/ia64/Ginstall_cursor.S +++ /dev/null @@ -1,348 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2001-2003 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include "ucontext_i.h" - -#ifdef UNW_LOCAL_ONLY -# include "Lcursor_i.h" -# define ia64_install_cursor _ULia64_install_cursor -#else -# include "Gcursor_i.h" -# define ia64_install_cursor _Uia64_install_cursor -#endif - -#define SYS_sigreturn 1181 - -#ifndef UNW_REMOTE_ONLY - -/* ia64_install_cursor (const cursor *c, long pri_unat, long *extra, - long bspstore, long dirty_size, long *dirty_partition, - long dirty_rnat) - - Restores the machine-state represented by C and thereby resumes execution - in that frame. If the frame or one of its descendants was interrupted - by a signal, all registers are restored (including the signal mask). - Otherwise, only the preserved registers, the global-pointer (r1), and - the exception-arguments (r15-r18) are restored. */ - -#define pRet p6 -#define pSig p7 - - .align 32 - .hidden ia64_install_cursor - .global ia64_install_cursor - .proc ia64_install_cursor -ia64_install_cursor: - alloc r3 = ar.pfs, 7, 0, 0, 0 - invala - add r2 = FR_LOC_OFF, in0 - ;; - - ld8 r16 = [r2], LOC_SIZE // r16 = loc[IA64_REG_FR16] - mov.m r10 = ar.rsc // (ar.rsc: ~ 12 cycle latency) - add r3 = FR_LOC_OFF + 16, in0 - ;; - - ld8 r17 = [r2], 2*LOC_SIZE // r17 = loc[IA64_REG_FR17] - ld8 r18 = [r3], 2*LOC_SIZE // r18 = loc[IA64_REG_FR18] - and r16 = -4, r16 - ;; - - ld8 r19 = [r2], 2*LOC_SIZE // r19 = loc[IA64_REG_FR19] - ld8 r20 = [r3], 2*LOC_SIZE // r20 = loc[IA64_REG_FR20] - and r17 = -4, r17 - ;; - - ldf.fill f16 = [r16] // f16 restored (don't touch no more) - ldf.fill f17 = [r17] // f17 restored (don't touch no more) - and r18 = -4, r18 - - ld8 r21 = [r2], 2*LOC_SIZE // r21 = loc[IA64_REG_FR21] - ld8 r22 = [r3], 2*LOC_SIZE // r22 = loc[IA64_REG_FR22] - and r19 = -4, r19 - ;; - - ldf.fill f18 = [r18] // f18 restored (don't touch no more) - ldf.fill f19 = [r19] // f19 restored (don't touch no more) - and r20 = -4, r20 - - ld8 r23 = [r2], 2*LOC_SIZE // r23 = loc[IA64_REG_FR23] - ld8 r24 = [r3], 2*LOC_SIZE // r24 = loc[IA64_REG_FR24] - and r21 = -4, r21 - ;; - - ldf.fill f20 = [r20] // f20 restored (don't touch no more) - ldf.fill f21 = [r21] // f21 restored (don't touch no more) - and r22 = -4, r22 - - ld8 r25 = [r2], 2*LOC_SIZE // r25 = loc[IA64_REG_FR25] - ld8 r26 = [r3], 2*LOC_SIZE // r26 = loc[IA64_REG_FR26] - and r23 = -4, r23 - ;; - - ldf.fill f22 = [r22] // f22 restored (don't touch no more) - ldf.fill f23 = [r23] // f23 restored (don't touch no more) - and r24 = -4, r24 - - ld8 r27 = [r2], 2*LOC_SIZE // r27 = loc[IA64_REG_FR27] - ld8 r28 = [r3], 2*LOC_SIZE // r28 = loc[IA64_REG_FR28] - and r25 = -4, r25 - ;; - - ldf.fill f24 = [r24] // f24 restored (don't touch no more) - ldf.fill f25 = [r25] // f25 restored (don't touch no more) - and r26 = -4, r26 - - ld8 r29 = [r2], 2*LOC_SIZE // r29 = loc[IA64_REG_FR29] - ld8 r30 = [r3], 2*LOC_SIZE // r30 = loc[IA64_REG_FR30] - and r27 = -4, r27 - ;; - - ldf.fill f26 = [r26] // f26 restored (don't touch no more) - ldf.fill f27 = [r27] // f27 restored (don't touch no more) - and r28 = -4, r28 - - ld8 r31 = [r2] // r31 = loc[IA64_REG_FR31] - mov.m ar.unat = in1 - and r29 = -4, r29 - ;; - - ldf.fill f28 = [r28] // f28 restored (don't touch no more) - ldf.fill f29 = [r29] // f29 restored (don't touch no more) - and r30 = -4, r30 - - ld8 r1 = [in2], 8 // gp restored (don't touch no more) - add r8 = SIGCONTEXT_ADDR_OFF, in0 - and r31 = -4, r31 - ;; - - ld8 r8 = [r8] // r8 = sigcontext_addr - and r11 = 0x1c, r10 // clear all but rsc.be and rsc.pl - add r2 = PFS_LOC_OFF, in0 - - ldf.fill f30 = [r30] // f30 restored (don't touch no more) - ldf.fill f31 = [r31] // f31 restored (don't touch no more) - add r3 = 8, in2 - ;; - - ld8.fill r4 = [in2], 16 // r4 restored (don't touch no more) - ld8.fill r5 = [r3], 16 // r5 restored (don't touch no more) - cmp.eq pRet, pSig = r0, r8 // sigcontext_addr == NULL? - ;; - ld8.fill r6 = [in2], 16 // r6 restored (don't touch no more) - ld8.fill r7 = [r3] // r7 restored (don't touch no more) - add r3 = IP_OFF, in0 - ;; - - ld8 r14 = [r2], (B1_LOC_OFF - PFS_LOC_OFF) // r14 = pfs_loc - ld8 r15 = [r3] // r15 = ip - add r3 = (B2_LOC_OFF - IP_OFF), r3 - ;; - - ld8 r16 = [r2], (B3_LOC_OFF - B1_LOC_OFF) // r16 = b1_loc - ld8 r17= [r3], (B4_LOC_OFF - B2_LOC_OFF) // r17 = b2_loc - and r14 = -4, r14 - ;; - - ld8 r18 = [r2], (B5_LOC_OFF - B3_LOC_OFF) // r18 = b3_loc - ld8 r19 = [r3], (F2_LOC_OFF - B4_LOC_OFF) // r19 = b4_loc - and r16 = -4, r16 - ;; - - ld8 r20 = [r2], (F3_LOC_OFF - B5_LOC_OFF) // r20 = b5_loc - ld8 r21 = [r3], (F4_LOC_OFF - F2_LOC_OFF) // r21 = f2_loc - and r17 = -4, r17 - ;; - - ld8 r16 = [r16] // r16 = *b1_loc - ld8 r17 = [r17] // r17 = *b2_loc - and r18 = -4, r18 - - ld8 r22 = [r2], (F5_LOC_OFF - F3_LOC_OFF) // r21 = f3_loc - ld8 r23 = [r3], (UNAT_LOC_OFF - F4_LOC_OFF) // r22 = f4_loc - and r19 = -4, r19 - ;; - - ld8 r18 = [r18] // r18 = *b3_loc - ld8 r19 = [r19] // r19 = *b4_loc - and r20 = -4, r20 - - ld8 r24 = [r2], (LC_LOC_OFF - F5_LOC_OFF) // r24 = f5_loc - ld8 r25 = [r3], (FPSR_LOC_OFF - UNAT_LOC_OFF) // r25 = unat_loc - and r21 = -4, r21 - ;; - - and r22 = -4, r22 - and r23 = -4, r23 - and r24 = -4, r24 - - ld8 r20 = [r20] // r20 = *b5_loc - ldf.fill f2 = [r21] // f2 restored (don't touch no more) - mov b1 = r16 // b1 restored (don't touch no more) - ;; - - ldf.fill f3 = [r22] // f3 restored (don't touch no more) - ldf.fill f4 = [r23] // f4 restored (don't touch no more) - mov b2 = r17 // b2 restored (don't touch no more) - - ld8 r26 = [r2], (RNAT_LOC_OFF - LC_LOC_OFF) // r26 = lc_loc - ld8 r27 = [r3] // r27 = fpsr_loc - and r25 = -4, r25 - - add r3 = (PSP_OFF - FPSR_LOC_OFF), r3 - nop 0 - nop 0 - ;; - - ldf.fill f5 = [r24] // f5 restored (don't touch no more) -(pRet) ld8 r25 = [r25] // r25 = *unat_loc - mov b3 = r18 // b3 restored (don't touch no more) - - ld8 r28 = [r2], (BSP_OFF - RNAT_LOC_OFF) // r28 = rnat_loc - ld8 r29 = [r3], (PR_OFF - PSP_OFF) // r29 = sp - mov b4 = r19 // b4 restored (don't touch no more) - - and r26 = -4, r26 - and r27 = -4, r27 - mov b5 = r20 // b5 restored (don't touch no more) - ;; - - ld8 r26 = [r26] // r26 = *lc_loc - ld8 r27 = [r27] // r27 = *fpsr_loc - and r28 = -4, r28 - - mov r30 = in3 // make backup-copy of new bsp - ld8 r31 = [r3] // r31 = pr - mov rp = r15 - ;; - - ld8 r28 = [r28] // r28 = rnat - mov.m ar.rsc = r11 // put RSE into enforced lazy mode - mov.i ar.lc = r26 // lc restored (don't touch no more) - ;; - - loadrs // drop dirty partition - mov r9 = in2 // make backup-copy of &extra[r16] - cmp.eq p8, p0 = in4, r0 // dirty-size == 0? -(p8) br.cond.dpnt.many .skip_load_dirty - - mov r2 = in4 // make backup-copy of dirty_size - mov r15 = in5 // make backup-copy of dirty_partition - mov r16 = in6 // make backup-copy of dirty_rnat - ;; - - alloc r3 = ar.pfs, 0, 0, 0, 0 // drop register frame - dep r11 = r2, r11, 16, 16 - ;; - mov.m ar.bspstore = r15 - ;; - mov.m ar.rnat = r16 - mov.m ar.rsc = r11 // 14 cycles latency to loadrs - ;; - loadrs // loadup new dirty partition - ;; - -.skip_load_dirty: - mov.m ar.bspstore = r30 // restore register backing-store - add r3 = 8, r9 // r3 = &extra[r16] - ;; - -(pRet) mov.m ar.fpsr = r27 // fpsr restored (don't touch no more) - mov.m ar.rnat = r28 -(pSig) br.cond.dpnt.many .next - -/****** Return via br.ret: */ - - ld8 r14 = [r14] // r14 = *pfs_loc - ld8 r15 = [r9], 16 // r15 restored (don't touch no more) - mov pr = r31, -1 // pr restored (don't touch no more) - ;; - - ld8 r16 = [r3], 16 // r16 restored (don't touch no more) - ld8 r17 = [r9] // r17 restored (don't touch no more) - nop.i 0 - ;; - - ld8 r18 = [r3] // r18 restored (don't touch no more) - mov.m ar.rsc = r10 // restore original ar.rsc - mov sp = r29 - - mov.m ar.unat = r25 // unat restored (don't touch no more) - mov.i ar.pfs = r14 - br.ret.sptk.many rp - ;; - -/****** Return via sigreturn(): */ - -.next: mov.m ar.rsc = r10 // restore original ar.rsc - add r2 = (SC_FR + 6*16), r8 - add r3 = (SC_FR + 7*16), r8 - ;; - - ldf.fill f6 = [r2], 32 - ldf.fill f7 = [r3], 32 - nop 0 - ;; - - ldf.fill f8 = [r2], 32 - ldf.fill f9 = [r3], 32 - nop 0 - ;; - - ldf.fill f10 = [r2], 32 - ldf.fill f11 = [r3], 32 - nop 0 - ;; - - ldf.fill f12 = [r2], 32 - ldf.fill f13 = [r3], 32 - nop 0 - ;; - - ldf.fill f14 = [r2], 32 - ldf.fill f15 = [r3], 32 - mov sp = r29 - ;; - -#if NEW_SYSCALL - add r2 = 8, tp;; - ld8 r2 = [r2] - mov r15 = SYS_sigreturn - mov b7 = r2 - br.call.sptk.many b6 = b7 - ;; -#else - mov r15 = SYS_sigreturn - break 0x100000 -#endif - break 0 // bug out if sigreturn() returns - - .endp ia64_install_cursor - -#endif /* !UNW_REMOTE_ONLY */ -#ifdef __linux__ - /* We do not need executable stack. */ - .section .note.GNU-stack,"",@progbits -#endif diff --git a/src/pal/src/libunwind/src/ia64/Gis_signal_frame.c b/src/pal/src/libunwind/src/ia64/Gis_signal_frame.c deleted file mode 100644 index e268a0629..000000000 --- a/src/pal/src/libunwind/src/ia64/Gis_signal_frame.c +++ /dev/null @@ -1,54 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2001-2002 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" - -int -unw_is_signal_frame (unw_cursor_t *cursor) -{ - struct cursor *c = (struct cursor *) cursor; - struct ia64_state_record sr; - int ret; - - /* Crude and slow, but we need to peek ahead into the unwind - descriptors to find out if the current IP is inside the signal - trampoline. */ - ret = ia64_fetch_proc_info (c, c->ip, 1); - if (ret < 0) - return ret; - - ret = ia64_create_state_record (c, &sr); - if (ret < 0) - return ret; - - /* For now, we assume that any non-zero abi marker implies a signal frame. - This should get us pretty far. */ - ret = (sr.abi_marker != 0); - - ia64_free_state_record (&sr); - - Debug (1, "(cursor=%p, ip=0x%016lx) -> %d\n", c, c->ip, ret); - return ret; -} diff --git a/src/pal/src/libunwind/src/ia64/Gparser.c b/src/pal/src/libunwind/src/ia64/Gparser.c deleted file mode 100644 index b1f0f4a11..000000000 --- a/src/pal/src/libunwind/src/ia64/Gparser.c +++ /dev/null @@ -1,1131 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2001-2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" - -/* forward declaration: */ -static int create_state_record_for (struct cursor *c, - struct ia64_state_record *sr, - unw_word_t ip); - -typedef unsigned long unw_word; - -#define alloc_reg_state() (mempool_alloc (&unw.reg_state_pool)) -#define free_reg_state(rs) (mempool_free (&unw.reg_state_pool, rs)) -#define alloc_labeled_state() (mempool_alloc (&unw.labeled_state_pool)) -#define free_labeled_state(s) (mempool_free (&unw.labeled_state_pool, s)) - -/* Routines to manipulate the state stack. */ - -static inline void -push (struct ia64_state_record *sr) -{ - struct ia64_reg_state *rs; - - rs = alloc_reg_state (); - if (!rs) - { - print_error ("libunwind: cannot stack reg state!\n"); - return; - } - memcpy (rs, &sr->curr, sizeof (*rs)); - sr->curr.next = rs; -} - -static void -pop (struct ia64_state_record *sr) -{ - struct ia64_reg_state *rs = sr->curr.next; - - if (!rs) - { - print_error ("libunwind: stack underflow!\n"); - return; - } - memcpy (&sr->curr, rs, sizeof (*rs)); - free_reg_state (rs); -} - -/* Make a copy of the state stack. Non-recursive to avoid stack overflows. */ -static struct ia64_reg_state * -dup_state_stack (struct ia64_reg_state *rs) -{ - struct ia64_reg_state *copy, *prev = NULL, *first = NULL; - - while (rs) - { - copy = alloc_reg_state (); - if (!copy) - { - print_error ("unwind.dup_state_stack: out of memory\n"); - return NULL; - } - memcpy (copy, rs, sizeof (*copy)); - if (first) - prev->next = copy; - else - first = copy; - rs = rs->next; - prev = copy; - } - return first; -} - -/* Free all stacked register states (but not RS itself). */ -static void -free_state_stack (struct ia64_reg_state *rs) -{ - struct ia64_reg_state *p, *next; - - for (p = rs->next; p != NULL; p = next) - { - next = p->next; - free_reg_state (p); - } - rs->next = NULL; -} - -/* Unwind decoder routines */ - -static enum ia64_pregnum CONST_ATTR -decode_abreg (unsigned char abreg, int memory) -{ - switch (abreg) - { - case 0x04 ... 0x07: - return IA64_REG_R4 + (abreg - 0x04); - case 0x22 ... 0x25: - return IA64_REG_F2 + (abreg - 0x22); - case 0x30 ... 0x3f: - return IA64_REG_F16 + (abreg - 0x30); - case 0x41 ... 0x45: - return IA64_REG_B1 + (abreg - 0x41); - case 0x60: - return IA64_REG_PR; - case 0x61: - return IA64_REG_PSP; - case 0x62: - return memory ? IA64_REG_PRI_UNAT_MEM : IA64_REG_PRI_UNAT_GR; - case 0x63: - return IA64_REG_IP; - case 0x64: - return IA64_REG_BSP; - case 0x65: - return IA64_REG_BSPSTORE; - case 0x66: - return IA64_REG_RNAT; - case 0x67: - return IA64_REG_UNAT; - case 0x68: - return IA64_REG_FPSR; - case 0x69: - return IA64_REG_PFS; - case 0x6a: - return IA64_REG_LC; - default: - break; - } - Dprintf ("libunwind: bad abreg=0x%x\n", abreg); - return IA64_REG_LC; -} - -static void -set_reg (struct ia64_reg_info *reg, enum ia64_where where, int when, - unsigned long val) -{ - reg->val = val; - reg->where = where; - if (reg->when == IA64_WHEN_NEVER) - reg->when = when; -} - -static void -alloc_spill_area (unsigned long *offp, unsigned long regsize, - struct ia64_reg_info *lo, struct ia64_reg_info *hi) -{ - struct ia64_reg_info *reg; - - for (reg = hi; reg >= lo; --reg) - { - if (reg->where == IA64_WHERE_SPILL_HOME) - { - reg->where = IA64_WHERE_PSPREL; - *offp -= regsize; - reg->val = *offp; - } - } -} - -static inline void -spill_next_when (struct ia64_reg_info **regp, struct ia64_reg_info *lim, - unw_word t) -{ - struct ia64_reg_info *reg; - - for (reg = *regp; reg <= lim; ++reg) - { - if (reg->where == IA64_WHERE_SPILL_HOME) - { - reg->when = t; - *regp = reg + 1; - return; - } - } - Dprintf ("libunwind: excess spill!\n"); -} - -static inline void -finish_prologue (struct ia64_state_record *sr) -{ - struct ia64_reg_info *reg; - unsigned long off; - int i; - - /* First, resolve implicit register save locations (see Section - "11.4.2.3 Rules for Using Unwind Descriptors", rule 3). */ - for (i = 0; i < (int) ARRAY_SIZE (unw.save_order); ++i) - { - reg = sr->curr.reg + unw.save_order[i]; - if (reg->where == IA64_WHERE_GR_SAVE) - { - reg->where = IA64_WHERE_GR; - reg->val = sr->gr_save_loc++; - } - } - - /* Next, compute when the fp, general, and branch registers get - saved. This must come before alloc_spill_area() because we need - to know which registers are spilled to their home locations. */ - - if (sr->imask) - { - unsigned char kind, mask = 0, *cp = sr->imask; - unsigned long t; - static const unsigned char limit[3] = - { - IA64_REG_F31, IA64_REG_R7, IA64_REG_B5 - }; - struct ia64_reg_info *(regs[3]); - - regs[0] = sr->curr.reg + IA64_REG_F2; - regs[1] = sr->curr.reg + IA64_REG_R4; - regs[2] = sr->curr.reg + IA64_REG_B1; - - for (t = 0; (int) t < sr->region_len; ++t) - { - if ((t & 3) == 0) - mask = *cp++; - kind = (mask >> 2 * (3 - (t & 3))) & 3; - if (kind > 0) - spill_next_when (®s[kind - 1], sr->curr.reg + limit[kind - 1], - sr->region_start + t); - } - } - - /* Next, lay out the memory stack spill area. */ - - if (sr->any_spills) - { - off = sr->spill_offset; - alloc_spill_area (&off, 16, sr->curr.reg + IA64_REG_F2, - sr->curr.reg + IA64_REG_F31); - alloc_spill_area (&off, 8, sr->curr.reg + IA64_REG_B1, - sr->curr.reg + IA64_REG_B5); - alloc_spill_area (&off, 8, sr->curr.reg + IA64_REG_R4, - sr->curr.reg + IA64_REG_R7); - } -} - -/* Region header descriptors. */ - -static void -desc_prologue (int body, unw_word rlen, unsigned char mask, - unsigned char grsave, struct ia64_state_record *sr) -{ - int i, region_start; - - if (!(sr->in_body || sr->first_region)) - finish_prologue (sr); - sr->first_region = 0; - - /* check if we're done: */ - if (sr->when_target < sr->region_start + sr->region_len) - { - sr->done = 1; - return; - } - - region_start = sr->region_start + sr->region_len; - - for (i = 0; i < sr->epilogue_count; ++i) - pop (sr); - sr->epilogue_count = 0; - sr->when_sp_restored = IA64_WHEN_NEVER; - - sr->region_start = region_start; - sr->region_len = rlen; - sr->in_body = body; - - if (!body) - { - push (sr); - - if (mask) - for (i = 0; i < 4; ++i) - { - if (mask & 0x8) - set_reg (sr->curr.reg + unw.save_order[i], IA64_WHERE_GR, - sr->region_start + sr->region_len - 1, grsave++); - mask <<= 1; - } - sr->gr_save_loc = grsave; - sr->any_spills = 0; - sr->imask = 0; - sr->spill_offset = 0x10; /* default to psp+16 */ - } -} - -/* Prologue descriptors. */ - -static inline void -desc_abi (unsigned char abi, unsigned char context, - struct ia64_state_record *sr) -{ - sr->abi_marker = (abi << 8) | context; -} - -static inline void -desc_br_gr (unsigned char brmask, unsigned char gr, - struct ia64_state_record *sr) -{ - int i; - - for (i = 0; i < 5; ++i) - { - if (brmask & 1) - set_reg (sr->curr.reg + IA64_REG_B1 + i, IA64_WHERE_GR, - sr->region_start + sr->region_len - 1, gr++); - brmask >>= 1; - } -} - -static inline void -desc_br_mem (unsigned char brmask, struct ia64_state_record *sr) -{ - int i; - - for (i = 0; i < 5; ++i) - { - if (brmask & 1) - { - set_reg (sr->curr.reg + IA64_REG_B1 + i, IA64_WHERE_SPILL_HOME, - sr->region_start + sr->region_len - 1, 0); - sr->any_spills = 1; - } - brmask >>= 1; - } -} - -static inline void -desc_frgr_mem (unsigned char grmask, unw_word frmask, - struct ia64_state_record *sr) -{ - int i; - - for (i = 0; i < 4; ++i) - { - if ((grmask & 1) != 0) - { - set_reg (sr->curr.reg + IA64_REG_R4 + i, IA64_WHERE_SPILL_HOME, - sr->region_start + sr->region_len - 1, 0); - sr->any_spills = 1; - } - grmask >>= 1; - } - for (i = 0; i < 20; ++i) - { - if ((frmask & 1) != 0) - { - int base = (i < 4) ? IA64_REG_F2 : IA64_REG_F16 - 4; - set_reg (sr->curr.reg + base + i, IA64_WHERE_SPILL_HOME, - sr->region_start + sr->region_len - 1, 0); - sr->any_spills = 1; - } - frmask >>= 1; - } -} - -static inline void -desc_fr_mem (unsigned char frmask, struct ia64_state_record *sr) -{ - int i; - - for (i = 0; i < 4; ++i) - { - if ((frmask & 1) != 0) - { - set_reg (sr->curr.reg + IA64_REG_F2 + i, IA64_WHERE_SPILL_HOME, - sr->region_start + sr->region_len - 1, 0); - sr->any_spills = 1; - } - frmask >>= 1; - } -} - -static inline void -desc_gr_gr (unsigned char grmask, unsigned char gr, - struct ia64_state_record *sr) -{ - int i; - - for (i = 0; i < 4; ++i) - { - if ((grmask & 1) != 0) - set_reg (sr->curr.reg + IA64_REG_R4 + i, IA64_WHERE_GR, - sr->region_start + sr->region_len - 1, gr++); - grmask >>= 1; - } -} - -static inline void -desc_gr_mem (unsigned char grmask, struct ia64_state_record *sr) -{ - int i; - - for (i = 0; i < 4; ++i) - { - if ((grmask & 1) != 0) - { - set_reg (sr->curr.reg + IA64_REG_R4 + i, IA64_WHERE_SPILL_HOME, - sr->region_start + sr->region_len - 1, 0); - sr->any_spills = 1; - } - grmask >>= 1; - } -} - -static inline void -desc_mem_stack_f (unw_word t, unw_word size, struct ia64_state_record *sr) -{ - set_reg (sr->curr.reg + IA64_REG_PSP, IA64_WHERE_NONE, - sr->region_start + MIN ((int) t, sr->region_len - 1), 16 * size); -} - -static inline void -desc_mem_stack_v (unw_word t, struct ia64_state_record *sr) -{ - sr->curr.reg[IA64_REG_PSP].when = - sr->region_start + MIN ((int) t, sr->region_len - 1); -} - -static inline void -desc_reg_gr (unsigned char reg, unsigned char dst, - struct ia64_state_record *sr) -{ - set_reg (sr->curr.reg + reg, IA64_WHERE_GR, - sr->region_start + sr->region_len - 1, dst); -} - -static inline void -desc_reg_psprel (unsigned char reg, unw_word pspoff, - struct ia64_state_record *sr) -{ - set_reg (sr->curr.reg + reg, IA64_WHERE_PSPREL, - sr->region_start + sr->region_len - 1, 0x10 - 4 * pspoff); -} - -static inline void -desc_reg_sprel (unsigned char reg, unw_word spoff, - struct ia64_state_record *sr) -{ - set_reg (sr->curr.reg + reg, IA64_WHERE_SPREL, - sr->region_start + sr->region_len - 1, 4 * spoff); -} - -static inline void -desc_rp_br (unsigned char dst, struct ia64_state_record *sr) -{ - sr->return_link_reg = dst; -} - -static inline void -desc_reg_when (unsigned char regnum, unw_word t, struct ia64_state_record *sr) -{ - struct ia64_reg_info *reg = sr->curr.reg + regnum; - - if (reg->where == IA64_WHERE_NONE) - reg->where = IA64_WHERE_GR_SAVE; - reg->when = sr->region_start + MIN ((int) t, sr->region_len - 1); -} - -static inline void -desc_spill_base (unw_word pspoff, struct ia64_state_record *sr) -{ - sr->spill_offset = 0x10 - 4 * pspoff; -} - -static inline unsigned char * -desc_spill_mask (unsigned char *imaskp, struct ia64_state_record *sr) -{ - sr->imask = imaskp; - return imaskp + (2 * sr->region_len + 7) / 8; -} - -/* Body descriptors. */ - -static inline void -desc_epilogue (unw_word t, unw_word ecount, struct ia64_state_record *sr) -{ - sr->when_sp_restored = sr->region_start + sr->region_len - 1 - t; - sr->epilogue_count = ecount + 1; -} - -static inline void -desc_copy_state (unw_word label, struct ia64_state_record *sr) -{ - struct ia64_labeled_state *ls; - - for (ls = sr->labeled_states; ls; ls = ls->next) - { - if (ls->label == label) - { - free_state_stack (&sr->curr); - memcpy (&sr->curr, &ls->saved_state, sizeof (sr->curr)); - sr->curr.next = dup_state_stack (ls->saved_state.next); - return; - } - } - print_error ("libunwind: failed to find labeled state\n"); -} - -static inline void -desc_label_state (unw_word label, struct ia64_state_record *sr) -{ - struct ia64_labeled_state *ls; - - ls = alloc_labeled_state (); - if (!ls) - { - print_error ("unwind.desc_label_state(): out of memory\n"); - return; - } - ls->label = label; - memcpy (&ls->saved_state, &sr->curr, sizeof (ls->saved_state)); - ls->saved_state.next = dup_state_stack (sr->curr.next); - - /* insert into list of labeled states: */ - ls->next = sr->labeled_states; - sr->labeled_states = ls; -} - -/* General descriptors. */ - -static inline int -desc_is_active (unsigned char qp, unw_word t, struct ia64_state_record *sr) -{ - if (sr->when_target <= sr->region_start + MIN ((int) t, sr->region_len - 1)) - return 0; - if (qp > 0) - { - if ((sr->pr_val & ((unw_word_t) 1 << qp)) == 0) - return 0; - sr->pr_mask |= ((unw_word_t) 1 << qp); - } - return 1; -} - -static inline void -desc_restore_p (unsigned char qp, unw_word t, unsigned char abreg, - struct ia64_state_record *sr) -{ - struct ia64_reg_info *r; - - if (!desc_is_active (qp, t, sr)) - return; - - r = sr->curr.reg + decode_abreg (abreg, 0); - r->where = IA64_WHERE_NONE; - r->when = IA64_WHEN_NEVER; - r->val = 0; -} - -static inline void -desc_spill_reg_p (unsigned char qp, unw_word t, unsigned char abreg, - unsigned char x, unsigned char ytreg, - struct ia64_state_record *sr) -{ - enum ia64_where where = IA64_WHERE_GR; - struct ia64_reg_info *r; - - if (!desc_is_active (qp, t, sr)) - return; - - if (x) - where = IA64_WHERE_BR; - else if (ytreg & 0x80) - where = IA64_WHERE_FR; - - r = sr->curr.reg + decode_abreg (abreg, 0); - r->where = where; - r->when = sr->region_start + MIN ((int) t, sr->region_len - 1); - r->val = (ytreg & 0x7f); -} - -static inline void -desc_spill_psprel_p (unsigned char qp, unw_word t, unsigned char abreg, - unw_word pspoff, struct ia64_state_record *sr) -{ - struct ia64_reg_info *r; - - if (!desc_is_active (qp, t, sr)) - return; - - r = sr->curr.reg + decode_abreg (abreg, 1); - r->where = IA64_WHERE_PSPREL; - r->when = sr->region_start + MIN ((int) t, sr->region_len - 1); - r->val = 0x10 - 4 * pspoff; -} - -static inline void -desc_spill_sprel_p (unsigned char qp, unw_word t, unsigned char abreg, - unw_word spoff, struct ia64_state_record *sr) -{ - struct ia64_reg_info *r; - - if (!desc_is_active (qp, t, sr)) - return; - - r = sr->curr.reg + decode_abreg (abreg, 1); - r->where = IA64_WHERE_SPREL; - r->when = sr->region_start + MIN ((int) t, sr->region_len - 1); - r->val = 4 * spoff; -} - -#define UNW_DEC_BAD_CODE(code) \ - print_error ("libunwind: unknown code encountered\n") - -/* Register names. */ -#define UNW_REG_BSP IA64_REG_BSP -#define UNW_REG_BSPSTORE IA64_REG_BSPSTORE -#define UNW_REG_FPSR IA64_REG_FPSR -#define UNW_REG_LC IA64_REG_LC -#define UNW_REG_PFS IA64_REG_PFS -#define UNW_REG_PR IA64_REG_PR -#define UNW_REG_RNAT IA64_REG_RNAT -#define UNW_REG_PSP IA64_REG_PSP -#define UNW_REG_RP IA64_REG_IP -#define UNW_REG_UNAT IA64_REG_UNAT - -/* Region headers. */ -#define UNW_DEC_PROLOGUE_GR(fmt,r,m,gr,arg) desc_prologue(0,r,m,gr,arg) -#define UNW_DEC_PROLOGUE(fmt,b,r,arg) desc_prologue(b,r,0,32,arg) - -/* Prologue descriptors. */ -#define UNW_DEC_ABI(fmt,a,c,arg) desc_abi(a,c,arg) -#define UNW_DEC_BR_GR(fmt,b,g,arg) desc_br_gr(b,g,arg) -#define UNW_DEC_BR_MEM(fmt,b,arg) desc_br_mem(b,arg) -#define UNW_DEC_FRGR_MEM(fmt,g,f,arg) desc_frgr_mem(g,f,arg) -#define UNW_DEC_FR_MEM(fmt,f,arg) desc_fr_mem(f,arg) -#define UNW_DEC_GR_GR(fmt,m,g,arg) desc_gr_gr(m,g,arg) -#define UNW_DEC_GR_MEM(fmt,m,arg) desc_gr_mem(m,arg) -#define UNW_DEC_MEM_STACK_F(fmt,t,s,arg) desc_mem_stack_f(t,s,arg) -#define UNW_DEC_MEM_STACK_V(fmt,t,arg) desc_mem_stack_v(t,arg) -#define UNW_DEC_REG_GR(fmt,r,d,arg) desc_reg_gr(r,d,arg) -#define UNW_DEC_REG_PSPREL(fmt,r,o,arg) desc_reg_psprel(r,o,arg) -#define UNW_DEC_REG_SPREL(fmt,r,o,arg) desc_reg_sprel(r,o,arg) -#define UNW_DEC_REG_WHEN(fmt,r,t,arg) desc_reg_when(r,t,arg) -#define UNW_DEC_PRIUNAT_WHEN_GR(fmt,t,arg) \ - desc_reg_when(IA64_REG_PRI_UNAT_GR,t,arg) -#define UNW_DEC_PRIUNAT_WHEN_MEM(fmt,t,arg) \ - desc_reg_when(IA64_REG_PRI_UNAT_MEM,t,arg) -#define UNW_DEC_PRIUNAT_GR(fmt,r,arg) \ - desc_reg_gr(IA64_REG_PRI_UNAT_GR,r,arg) -#define UNW_DEC_PRIUNAT_PSPREL(fmt,o,arg) \ - desc_reg_psprel(IA64_REG_PRI_UNAT_MEM,o,arg) -#define UNW_DEC_PRIUNAT_SPREL(fmt,o,arg) \ - desc_reg_sprel(IA64_REG_PRI_UNAT_MEM,o,arg) -#define UNW_DEC_RP_BR(fmt,d,arg) desc_rp_br(d,arg) -#define UNW_DEC_SPILL_BASE(fmt,o,arg) desc_spill_base(o,arg) -#define UNW_DEC_SPILL_MASK(fmt,m,arg) (m = desc_spill_mask(m,arg)) - -/* Body descriptors. */ -#define UNW_DEC_EPILOGUE(fmt,t,c,arg) desc_epilogue(t,c,arg) -#define UNW_DEC_COPY_STATE(fmt,l,arg) desc_copy_state(l,arg) -#define UNW_DEC_LABEL_STATE(fmt,l,arg) desc_label_state(l,arg) - -/* General unwind descriptors. */ -#define UNW_DEC_SPILL_REG_P(f,p,t,a,x,y,arg) desc_spill_reg_p(p,t,a,x,y,arg) -#define UNW_DEC_SPILL_REG(f,t,a,x,y,arg) desc_spill_reg_p(0,t,a,x,y,arg) -#define UNW_DEC_SPILL_PSPREL_P(f,p,t,a,o,arg) \ - desc_spill_psprel_p(p,t,a,o,arg) -#define UNW_DEC_SPILL_PSPREL(f,t,a,o,arg) \ - desc_spill_psprel_p(0,t,a,o,arg) -#define UNW_DEC_SPILL_SPREL_P(f,p,t,a,o,arg) desc_spill_sprel_p(p,t,a,o,arg) -#define UNW_DEC_SPILL_SPREL(f,t,a,o,arg) desc_spill_sprel_p(0,t,a,o,arg) -#define UNW_DEC_RESTORE_P(f,p,t,a,arg) desc_restore_p(p,t,a,arg) -#define UNW_DEC_RESTORE(f,t,a,arg) desc_restore_p(0,t,a,arg) - -#include "unwind_decoder.h" - -#ifdef _U_dyn_op - -/* parse dynamic unwind info */ - -static struct ia64_reg_info * -lookup_preg (int regnum, int memory, struct ia64_state_record *sr) -{ - int preg; - - switch (regnum) - { - case UNW_IA64_AR_BSP: preg = IA64_REG_BSP; break; - case UNW_IA64_AR_BSPSTORE: preg = IA64_REG_BSPSTORE; break; - case UNW_IA64_AR_FPSR: preg = IA64_REG_FPSR; break; - case UNW_IA64_AR_LC: preg = IA64_REG_LC; break; - case UNW_IA64_AR_PFS: preg = IA64_REG_PFS; break; - case UNW_IA64_AR_RNAT: preg = IA64_REG_RNAT; break; - case UNW_IA64_AR_UNAT: preg = IA64_REG_UNAT; break; - case UNW_IA64_BR + 0: preg = IA64_REG_IP; break; - case UNW_IA64_PR: preg = IA64_REG_PR; break; - case UNW_IA64_SP: preg = IA64_REG_PSP; break; - - case UNW_IA64_NAT: - if (memory) - preg = IA64_REG_PRI_UNAT_MEM; - else - preg = IA64_REG_PRI_UNAT_GR; - break; - - case UNW_IA64_GR + 4 ... UNW_IA64_GR + 7: - preg = IA64_REG_R4 + (regnum - (UNW_IA64_GR + 4)); - break; - - case UNW_IA64_BR + 1 ... UNW_IA64_BR + 5: - preg = IA64_REG_B1 + (regnum - UNW_IA64_BR); - break; - - case UNW_IA64_FR + 2 ... UNW_IA64_FR + 5: - preg = IA64_REG_F2 + (regnum - (UNW_IA64_FR + 2)); - break; - - case UNW_IA64_FR + 16 ... UNW_IA64_FR + 31: - preg = IA64_REG_F16 + (regnum - (UNW_IA64_FR + 16)); - break; - - default: - Dprintf ("%s: invalid register number %d\n", __FUNCTION__, regnum); - return NULL; - } - return sr->curr.reg + preg; -} - -/* An alias directive inside a region of length RLEN is interpreted to - mean that the region behaves exactly like the first RLEN - instructions at the aliased IP. RLEN=0 implies that the current - state matches exactly that of before the instruction at the aliased - IP is executed. */ - -static int -desc_alias (unw_dyn_op_t *op, struct cursor *c, struct ia64_state_record *sr) -{ - struct ia64_state_record orig_sr = *sr; - int i, ret, when, rlen = sr->region_len; - unw_word_t new_ip; - - when = MIN (sr->when_target, rlen); - new_ip = op->val + ((when / 3) * 16 + (when % 3)); - - if ((ret = ia64_fetch_proc_info (c, new_ip, 1)) < 0) - return ret; - - if ((ret = create_state_record_for (c, sr, new_ip)) < 0) - return ret; - - sr->first_region = orig_sr.first_region; - sr->done = 0; - sr->any_spills |= orig_sr.any_spills; - sr->in_body = orig_sr.in_body; - sr->region_start = orig_sr.region_start; - sr->region_len = orig_sr.region_len; - if (sr->when_sp_restored != IA64_WHEN_NEVER) - sr->when_sp_restored = op->when + MIN (orig_sr.when_sp_restored, rlen); - sr->epilogue_count = orig_sr.epilogue_count; - sr->when_target = orig_sr.when_target; - - for (i = 0; i < IA64_NUM_PREGS; ++i) - if (sr->curr.reg[i].when != IA64_WHEN_NEVER) - sr->curr.reg[i].when = op->when + MIN (sr->curr.reg[i].when, rlen); - - ia64_free_state_record (sr); - sr->labeled_states = orig_sr.labeled_states; - sr->curr.next = orig_sr.curr.next; - return 0; -} - -static inline int -parse_dynamic (struct cursor *c, struct ia64_state_record *sr) -{ - unw_dyn_info_t *di = c->pi.unwind_info; - unw_dyn_proc_info_t *proc = &di->u.pi; - unw_dyn_region_info_t *r; - struct ia64_reg_info *ri; - enum ia64_where where; - int32_t when, len; - unw_dyn_op_t *op; - unw_word_t val; - int memory, ret; - int8_t qp; - - for (r = proc->regions; r; r = r->next) - { - len = r->insn_count; - if (len < 0) - { - if (r->next) - { - Debug (1, "negative region length allowed in last region only!"); - return -UNW_EINVAL; - } - len = -len; - /* hack old region info to set the start where we need it: */ - sr->region_start = (di->end_ip - di->start_ip) / 0x10 * 3 - len; - sr->region_len = 0; - } - /* all regions are treated as prologue regions: */ - desc_prologue (0, len, 0, 0, sr); - - if (sr->done) - return 0; - - for (op = r->op; op < r->op + r->op_count; ++op) - { - when = op->when; - val = op->val; - qp = op->qp; - - if (!desc_is_active (qp, when, sr)) - continue; - - when = sr->region_start + MIN ((int) when, sr->region_len - 1); - - switch (op->tag) - { - case UNW_DYN_SAVE_REG: - memory = 0; - if ((unsigned) (val - UNW_IA64_GR) < 128) - where = IA64_WHERE_GR; - else if ((unsigned) (val - UNW_IA64_FR) < 128) - where = IA64_WHERE_FR; - else if ((unsigned) (val - UNW_IA64_BR) < 8) - where = IA64_WHERE_BR; - else - { - Dprintf ("%s: can't save to register number %d\n", - __FUNCTION__, (int) op->reg); - return -UNW_EBADREG; - } - /* fall through */ - update_reg_info: - ri = lookup_preg (op->reg, memory, sr); - if (!ri) - return -UNW_EBADREG; - ri->where = where; - ri->when = when; - ri->val = val; - break; - - case UNW_DYN_SPILL_FP_REL: - memory = 1; - where = IA64_WHERE_PSPREL; - val = 0x10 - val; - goto update_reg_info; - - case UNW_DYN_SPILL_SP_REL: - memory = 1; - where = IA64_WHERE_SPREL; - goto update_reg_info; - - case UNW_DYN_ADD: - if (op->reg == UNW_IA64_SP) - { - if (val & 0xf) - { - Dprintf ("%s: frame-size %ld not an integer " - "multiple of 16\n", - __FUNCTION__, (long) op->val); - return -UNW_EINVAL; - } - desc_mem_stack_f (when, -((int64_t) val / 16), sr); - } - else - { - Dprintf ("%s: can only ADD to stack-pointer\n", - __FUNCTION__); - return -UNW_EBADREG; - } - break; - - case UNW_DYN_POP_FRAMES: - sr->when_sp_restored = when; - sr->epilogue_count = op->val; - break; - - case UNW_DYN_LABEL_STATE: - desc_label_state (op->val, sr); - break; - - case UNW_DYN_COPY_STATE: - desc_copy_state (op->val, sr); - break; - - case UNW_DYN_ALIAS: - if ((ret = desc_alias (op, c, sr)) < 0) - return ret; - - case UNW_DYN_STOP: - goto end_of_ops; - } - } - end_of_ops: - ; - } - return 0; -} -#else -# define parse_dynamic(c,sr) (-UNW_EINVAL) -#endif /* _U_dyn_op */ - - -HIDDEN int -ia64_fetch_proc_info (struct cursor *c, unw_word_t ip, int need_unwind_info) -{ - int ret, dynamic = 1; - - if (c->pi_valid && !need_unwind_info) - return 0; - - /* check dynamic info first --- it overrides everything else */ - ret = unwi_find_dynamic_proc_info (c->as, ip, &c->pi, need_unwind_info, - c->as_arg); - if (ret == -UNW_ENOINFO) - { - dynamic = 0; - ret = ia64_find_proc_info (c, ip, need_unwind_info); - } - - c->pi_valid = 1; - c->pi_is_dynamic = dynamic; - return ret; -} - -static inline void -put_unwind_info (struct cursor *c, unw_proc_info_t *pi) -{ - if (!c->pi_valid) - return; - - if (c->pi_is_dynamic) - unwi_put_dynamic_unwind_info (c->as, pi, c->as_arg); - else - ia64_put_unwind_info (c, pi); -} - -static int -create_state_record_for (struct cursor *c, struct ia64_state_record *sr, - unw_word_t ip) -{ - unw_word_t predicates = c->pr; - struct ia64_reg_info *r; - uint8_t *dp, *desc_end; - int ret; - - assert (c->pi_valid); - - /* build state record */ - memset (sr, 0, sizeof (*sr)); - for (r = sr->curr.reg; r < sr->curr.reg + IA64_NUM_PREGS; ++r) - r->when = IA64_WHEN_NEVER; - sr->pr_val = predicates; - sr->first_region = 1; - - if (!c->pi.unwind_info) - { - /* No info, return default unwinder (leaf proc, no mem stack, no - saved regs), rp in b0, pfs in ar.pfs. */ - Debug (1, "no unwind info for ip=0x%lx (gp=%lx)\n", - (long) ip, (long) c->pi.gp); - sr->curr.reg[IA64_REG_IP].where = IA64_WHERE_BR; - sr->curr.reg[IA64_REG_IP].when = -1; - sr->curr.reg[IA64_REG_IP].val = 0; - goto out; - } - - sr->when_target = (3 * ((ip & ~(unw_word_t) 0xf) - c->pi.start_ip) / 16 - + (ip & 0xf)); - - switch (c->pi.format) - { - case UNW_INFO_FORMAT_TABLE: - case UNW_INFO_FORMAT_REMOTE_TABLE: - dp = c->pi.unwind_info; - desc_end = dp + c->pi.unwind_info_size; - while (!sr->done && dp < desc_end) - dp = unw_decode (dp, sr->in_body, sr); - ret = 0; - break; - - case UNW_INFO_FORMAT_DYNAMIC: - ret = parse_dynamic (c, sr); - break; - - default: - ret = -UNW_EINVAL; - } - - put_unwind_info (c, &c->pi); - - if (ret < 0) - return ret; - - if (sr->when_target > sr->when_sp_restored) - { - /* sp has been restored and all values on the memory stack below - psp also have been restored. */ - sr->curr.reg[IA64_REG_PSP].val = 0; - sr->curr.reg[IA64_REG_PSP].where = IA64_WHERE_NONE; - sr->curr.reg[IA64_REG_PSP].when = IA64_WHEN_NEVER; - for (r = sr->curr.reg; r < sr->curr.reg + IA64_NUM_PREGS; ++r) - if ((r->where == IA64_WHERE_PSPREL && r->val <= 0x10) - || r->where == IA64_WHERE_SPREL) - { - r->val = 0; - r->where = IA64_WHERE_NONE; - r->when = IA64_WHEN_NEVER; - } - } - - /* If RP did't get saved, generate entry for the return link - register. */ - if (sr->curr.reg[IA64_REG_IP].when >= sr->when_target) - { - sr->curr.reg[IA64_REG_IP].where = IA64_WHERE_BR; - sr->curr.reg[IA64_REG_IP].when = -1; - sr->curr.reg[IA64_REG_IP].val = sr->return_link_reg; - } - - if (sr->when_target > sr->curr.reg[IA64_REG_BSP].when - && sr->when_target > sr->curr.reg[IA64_REG_BSPSTORE].when - && sr->when_target > sr->curr.reg[IA64_REG_RNAT].when) - { - Debug (8, "func 0x%lx may switch the register-backing-store\n", - c->pi.start_ip); - c->pi.flags |= UNW_PI_FLAG_IA64_RBS_SWITCH; - } - out: -#if UNW_DEBUG - if (unwi_debug_level > 2) - { - Dprintf ("%s: state record for func 0x%lx, t=%u (flags=0x%lx):\n", - __FUNCTION__, - (long) c->pi.start_ip, sr->when_target, (long) c->pi.flags); - for (r = sr->curr.reg; r < sr->curr.reg + IA64_NUM_PREGS; ++r) - { - if (r->where != IA64_WHERE_NONE || r->when != IA64_WHEN_NEVER) - { - Dprintf (" %s <- ", unw.preg_name[r - sr->curr.reg]); - switch (r->where) - { - case IA64_WHERE_GR: - Dprintf ("r%lu", (long) r->val); - break; - case IA64_WHERE_FR: - Dprintf ("f%lu", (long) r->val); - break; - case IA64_WHERE_BR: - Dprintf ("b%lu", (long) r->val); - break; - case IA64_WHERE_SPREL: - Dprintf ("[sp+0x%lx]", (long) r->val); - break; - case IA64_WHERE_PSPREL: - Dprintf ("[psp+0x%lx]", (long) r->val); - break; - case IA64_WHERE_NONE: - Dprintf ("%s+0x%lx", - unw.preg_name[r - sr->curr.reg], (long) r->val); - break; - default: - Dprintf ("BADWHERE(%d)", r->where); - break; - } - Dprintf ("\t\t%d\n", r->when); - } - } - } -#endif - return 0; -} - -/* The proc-info must be valid for IP before this routine can be - called. */ -HIDDEN int -ia64_create_state_record (struct cursor *c, struct ia64_state_record *sr) -{ - return create_state_record_for (c, sr, c->ip); -} - -HIDDEN int -ia64_free_state_record (struct ia64_state_record *sr) -{ - struct ia64_labeled_state *ls, *next; - - /* free labeled register states & stack: */ - - for (ls = sr->labeled_states; ls; ls = next) - { - next = ls->next; - free_state_stack (&ls->saved_state); - free_labeled_state (ls); - } - free_state_stack (&sr->curr); - - return 0; -} - -HIDDEN int -ia64_make_proc_info (struct cursor *c) -{ - int ret, caching = c->as->caching_policy != UNW_CACHE_NONE; - - if (!caching || ia64_get_cached_proc_info (c) < 0) - { - /* Lookup it up the slow way... */ - if ((ret = ia64_fetch_proc_info (c, c->ip, 0)) < 0) - return ret; - if (caching) - ia64_cache_proc_info (c); - } - return 0; -} diff --git a/src/pal/src/libunwind/src/ia64/Grbs.c b/src/pal/src/libunwind/src/ia64/Grbs.c deleted file mode 100644 index e7c01fe21..000000000 --- a/src/pal/src/libunwind/src/ia64/Grbs.c +++ /dev/null @@ -1,319 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2003-2005 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -/* Logically, we like to think of the stack as a contiguous region of -memory. Unfortunately, this logical view doesn't work for the -register backing store, because the RSE is an asynchronous engine and -because UNIX/Linux allow for stack-switching via sigaltstack(2). -Specifically, this means that any given stacked register may or may -not be backed up by memory in the current stack. If not, then the -backing memory may be found in any of the "more inner" (younger) -stacks. The routines in this file help manage the discontiguous -nature of the register backing store. The routines are completely -independent of UNIX/Linux, but each stack frame that switches the -backing store is expected to reserve 4 words for use by libunwind. For -example, in the Linux sigcontext, sc_fr[0] and sc_fr[1] serve this -purpose. */ - -#include "unwind_i.h" - -#if UNW_DEBUG - -HIDDEN const char * -ia64_strloc (ia64_loc_t loc) -{ - static char buf[128]; - - if (IA64_IS_NULL_LOC (loc)) - return ""; - - buf[0] = '\0'; - - if (IA64_IS_MEMSTK_NAT (loc)) - strcat (buf, "memstk_nat("); - if (IA64_IS_UC_LOC (loc)) - strcat (buf, "uc("); - if (IA64_IS_FP_LOC (loc)) - strcat (buf, "fp("); - - if (IA64_IS_REG_LOC (loc)) - sprintf (buf + strlen (buf), "%s", unw_regname (IA64_GET_REG (loc))); - else - sprintf (buf + strlen (buf), "0x%llx", - (unsigned long long) IA64_GET_ADDR (loc)); - - if (IA64_IS_FP_LOC (loc)) - strcat (buf, ")"); - if (IA64_IS_UC_LOC (loc)) - strcat (buf, ")"); - if (IA64_IS_MEMSTK_NAT (loc)) - strcat (buf, ")"); - - return buf; -} - -#endif /* UNW_DEBUG */ - -HIDDEN int -rbs_switch (struct cursor *c, - unw_word_t saved_bsp, unw_word_t saved_bspstore, - ia64_loc_t saved_rnat_loc) -{ - struct rbs_area *rbs = &c->rbs_area[c->rbs_curr]; - unw_word_t lo, ndirty, rbs_base; - int ret; - - Debug (10, "(left=%u, curr=%u)\n", c->rbs_left_edge, c->rbs_curr); - - /* Calculate address "lo" at which the backing store starts: */ - ndirty = rse_num_regs (saved_bspstore, saved_bsp); - lo = rse_skip_regs (c->bsp, -ndirty); - - rbs->size = (rbs->end - lo); - - /* If the previously-recorded rbs-area is empty we don't need to - track it and we can simply overwrite it... */ - if (rbs->size) - { - Debug (10, "inner=[0x%lx-0x%lx)\n", - (long) (rbs->end - rbs->size), (long) rbs->end); - - c->rbs_curr = (c->rbs_curr + 1) % ARRAY_SIZE (c->rbs_area); - rbs = c->rbs_area + c->rbs_curr; - - if (c->rbs_curr == c->rbs_left_edge) - c->rbs_left_edge = (c->rbs_left_edge + 1) % ARRAY_SIZE (c->rbs_area); - } - - if ((ret = rbs_get_base (c, saved_bspstore, &rbs_base)) < 0) - return ret; - - rbs->end = saved_bspstore; - rbs->size = saved_bspstore - rbs_base; - rbs->rnat_loc = saved_rnat_loc; - - c->bsp = saved_bsp; - - Debug (10, "outer=[0x%llx-0x%llx), rnat@%s\n", (long long) rbs_base, - (long long) rbs->end, ia64_strloc (rbs->rnat_loc)); - return 0; -} - -HIDDEN int -rbs_find_stacked (struct cursor *c, unw_word_t regs_to_skip, - ia64_loc_t *locp, ia64_loc_t *rnat_locp) -{ - unw_word_t nregs, bsp = c->bsp, curr = c->rbs_curr, n; - unw_word_t left_edge = c->rbs_left_edge; -#if UNW_DEBUG - int reg = 32 + regs_to_skip; -#endif - - while (!rbs_contains (&c->rbs_area[curr], bsp)) - { - if (curr == left_edge) - { - Debug (1, "could not find register r%d!\n", reg); - return -UNW_EBADREG; - } - - n = rse_num_regs (c->rbs_area[curr].end, bsp); - curr = (curr + ARRAY_SIZE (c->rbs_area) - 1) % ARRAY_SIZE (c->rbs_area); - bsp = rse_skip_regs (c->rbs_area[curr].end - c->rbs_area[curr].size, n); - } - - while (1) - { - nregs = rse_num_regs (bsp, c->rbs_area[curr].end); - - if (regs_to_skip < nregs) - { - /* found it: */ - unw_word_t addr; - - addr = rse_skip_regs (bsp, regs_to_skip); - if (locp) - *locp = rbs_loc (c->rbs_area + curr, addr); - if (rnat_locp) - *rnat_locp = rbs_get_rnat_loc (c->rbs_area + curr, addr); - return 0; - } - - if (curr == left_edge) - { - Debug (1, "could not find register r%d!\n", reg); - return -UNW_EBADREG; - } - - regs_to_skip -= nregs; - - curr = (curr + ARRAY_SIZE (c->rbs_area) - 1) % ARRAY_SIZE (c->rbs_area); - bsp = c->rbs_area[curr].end - c->rbs_area[curr].size; - } -} - -#ifdef NEED_RBS_COVER_AND_FLUSH - -static inline int -get_rnat (struct cursor *c, struct rbs_area *rbs, unw_word_t bsp, - unw_word_t *__restrict rnatp) -{ - ia64_loc_t rnat_locp = rbs_get_rnat_loc (rbs, bsp); - - return ia64_get (c, rnat_locp, rnatp); -} - -/* Simulate the effect of "cover" followed by a "flushrs" for the - target-frame. However, since the target-frame's backing store - may not have space for the registers that got spilled onto other - rbs-areas, we save those registers to DIRTY_PARTITION where - we can then load them via a single "loadrs". - - This function returns the size of the dirty-partition that was - created or a negative error-code in case of error. - - Note: This does not modify the rbs_area[] structure in any way. */ -HIDDEN int -rbs_cover_and_flush (struct cursor *c, unw_word_t nregs, - unw_word_t *dirty_partition, unw_word_t *dirty_rnat, - unw_word_t *bspstore) -{ - unw_word_t n, src_mask, dst_mask, bsp, *dst, src_rnat, dst_rnat = 0; - unw_word_t curr = c->rbs_curr, left_edge = c->rbs_left_edge; - struct rbs_area *rbs = c->rbs_area + curr; - int ret; - - bsp = c->bsp; - c->bsp = rse_skip_regs (bsp, nregs); - - if (likely (rbs_contains (rbs, bsp))) - { - /* at least _some_ registers are on rbs... */ - n = rse_num_regs (bsp, rbs->end); - if (likely (n >= nregs)) - { - /* common case #1: all registers are on current rbs... */ - /* got lucky: _all_ registers are on rbs... */ - ia64_loc_t rnat_loc = rbs_get_rnat_loc (rbs, c->bsp); - - *bspstore = c->bsp; - - if (IA64_IS_REG_LOC (rnat_loc)) - { - unw_word_t rnat_addr = (unw_word_t) - tdep_uc_addr (c->as_arg, UNW_IA64_AR_RNAT, NULL); - rnat_loc = IA64_LOC_ADDR (rnat_addr, 0); - } - c->loc[IA64_REG_RNAT] = rnat_loc; - return 0; /* all done */ - } - nregs -= n; /* account for registers already on the rbs */ - - assert (rse_skip_regs (c->bsp, -nregs) == rse_skip_regs (rbs->end, 0)); - } - else - /* Earlier frames also didn't get spilled; need to "loadrs" those, - too... */ - nregs += rse_num_regs (rbs->end, bsp); - - /* OK, we need to copy NREGS registers to the dirty partition. */ - - *bspstore = bsp = rbs->end; - c->loc[IA64_REG_RNAT] = rbs->rnat_loc; - assert (!IA64_IS_REG_LOC (rbs->rnat_loc)); - - dst = dirty_partition; - - while (nregs > 0) - { - if (unlikely (!rbs_contains (rbs, bsp))) - { - /* switch to next non-empty rbs-area: */ - do - { - if (curr == left_edge) - { - Debug (0, "rbs-underflow while flushing %lu regs, " - "bsp=0x%lx, dst=0x%p\n", (unsigned long) nregs, - (unsigned long) bsp, dst); - return -UNW_EBADREG; - } - - assert (rse_num_regs (rbs->end, bsp) == 0); - - curr = (curr + ARRAY_SIZE (c->rbs_area) - 1) - % ARRAY_SIZE (c->rbs_area); - rbs = c->rbs_area + curr; - bsp = rbs->end - rbs->size; - } - while (rbs->size == 0); - - if ((ret = get_rnat (c, rbs, bsp, &src_rnat)) < 0) - return ret; - } - - if (unlikely (rse_is_rnat_slot (bsp))) - { - bsp += 8; - if ((ret = get_rnat (c, rbs, bsp, &src_rnat)) < 0) - return ret; - } - if (unlikely (rse_is_rnat_slot ((unw_word_t) dst))) - { - *dst++ = dst_rnat; - dst_rnat = 0; - } - - src_mask = ((unw_word_t) 1) << rse_slot_num (bsp); - dst_mask = ((unw_word_t) 1) << rse_slot_num ((unw_word_t) dst); - - if (src_rnat & src_mask) - dst_rnat |= dst_mask; - else - dst_rnat &= ~dst_mask; - - /* copy one slot: */ - if ((ret = ia64_get (c, rbs_loc (rbs, bsp), dst)) < 0) - return ret; - - /* advance to next slot: */ - --nregs; - bsp += 8; - ++dst; - } - if (unlikely (rse_is_rnat_slot ((unw_word_t) dst))) - { - /* The LOADRS instruction loads "the N bytes below the current - BSP" but BSP can never point to an RNaT slot so if the last - destination word happens to be an RNaT slot, we need to write - that slot now. */ - *dst++ = dst_rnat; - dst_rnat = 0; - } - *dirty_rnat = dst_rnat; - return (char *) dst - (char *) dirty_partition; -} - -#endif /* !UNW_REMOTE_ONLY */ diff --git a/src/pal/src/libunwind/src/ia64/Greg_states_iterate.c b/src/pal/src/libunwind/src/ia64/Greg_states_iterate.c deleted file mode 100644 index 3570740af..000000000 --- a/src/pal/src/libunwind/src/ia64/Greg_states_iterate.c +++ /dev/null @@ -1,39 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (c) 2002-2003 Hewlett-Packard Development Company, L.P. - Contributed by David Mosberger-Tang - - Modified for x86_64 by Max Asbock - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" - -int -unw_reg_states_iterate (unw_cursor_t *cursor, - unw_reg_states_callback cb, void *token) -{ - struct cursor *c = (struct cursor *) cursor; - - // Needs dwarf support on ia64 - // return dwarf_reg_states_iterate (&c->dwarf, cb, token); - return -UNW_EINVAL; -} diff --git a/src/pal/src/libunwind/src/ia64/Gregs.c b/src/pal/src/libunwind/src/ia64/Gregs.c deleted file mode 100644 index ac6f738a6..000000000 --- a/src/pal/src/libunwind/src/ia64/Gregs.c +++ /dev/null @@ -1,612 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2001-2005 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include "offsets.h" -#include "regs.h" -#include "unwind_i.h" - -static inline ia64_loc_t -linux_scratch_loc (struct cursor *c, unw_regnum_t reg, uint8_t *nat_bitnr) -{ -#if !defined(UNW_LOCAL_ONLY) || defined(__linux) - unw_word_t addr = c->sigcontext_addr, flags, tmp_addr; - int i; - - if (ia64_get_abi_marker (c) == ABI_MARKER_LINUX_SIGTRAMP - || ia64_get_abi_marker (c) == ABI_MARKER_OLD_LINUX_SIGTRAMP) - { - switch (reg) - { - case UNW_IA64_NAT + 2 ... UNW_IA64_NAT + 3: - case UNW_IA64_NAT + 8 ... UNW_IA64_NAT + 31: - /* Linux sigcontext contains the NaT bit of scratch register - N in bit position N of the sc_nat member. */ - *nat_bitnr = (reg - UNW_IA64_NAT); - addr += LINUX_SC_NAT_OFF; - break; - - case UNW_IA64_GR + 2 ... UNW_IA64_GR + 3: - case UNW_IA64_GR + 8 ... UNW_IA64_GR + 31: - addr += LINUX_SC_GR_OFF + 8 * (reg - UNW_IA64_GR); - break; - - case UNW_IA64_FR + 6 ... UNW_IA64_FR + 15: - addr += LINUX_SC_FR_OFF + 16 * (reg - UNW_IA64_FR); - return IA64_LOC_ADDR (addr, IA64_LOC_TYPE_FP); - - case UNW_IA64_FR + 32 ... UNW_IA64_FR + 127: - if (ia64_get (c, IA64_LOC_ADDR (addr + LINUX_SC_FLAGS_OFF, 0), - &flags) < 0) - return IA64_NULL_LOC; - - if (!(flags & IA64_SC_FLAG_FPH_VALID)) - { - /* initialize fph partition: */ - tmp_addr = addr + LINUX_SC_FR_OFF + 32*16; - for (i = 32; i < 128; ++i, tmp_addr += 16) - if (ia64_putfp (c, IA64_LOC_ADDR (tmp_addr, 0), - unw.read_only.f0) < 0) - return IA64_NULL_LOC; - /* mark fph partition as valid: */ - if (ia64_put (c, IA64_LOC_ADDR (addr + LINUX_SC_FLAGS_OFF, 0), - flags | IA64_SC_FLAG_FPH_VALID) < 0) - return IA64_NULL_LOC; - } - - addr += LINUX_SC_FR_OFF + 16 * (reg - UNW_IA64_FR); - return IA64_LOC_ADDR (addr, IA64_LOC_TYPE_FP); - - case UNW_IA64_BR + 0: addr += LINUX_SC_BR_OFF + 0; break; - case UNW_IA64_BR + 6: addr += LINUX_SC_BR_OFF + 6*8; break; - case UNW_IA64_BR + 7: addr += LINUX_SC_BR_OFF + 7*8; break; - case UNW_IA64_AR_RSC: addr += LINUX_SC_AR_RSC_OFF; break; - case UNW_IA64_AR_CSD: addr += LINUX_SC_AR_CSD_OFF; break; - case UNW_IA64_AR_SSD: addr += LINUX_SC_AR_SSD_OFF; break; - case UNW_IA64_AR_CCV: addr += LINUX_SC_AR_CCV; break; - - default: - if (unw_is_fpreg (reg)) - return IA64_FPREG_LOC (c, reg); - else - return IA64_REG_LOC (c, reg); - } - return IA64_LOC_ADDR (addr, 0); - } - else - { - int is_nat = 0; - - if ((unsigned) (reg - UNW_IA64_NAT) < 128) - { - is_nat = 1; - reg -= (UNW_IA64_NAT - UNW_IA64_GR); - } - if (ia64_get_abi_marker (c) == ABI_MARKER_LINUX_INTERRUPT) - { - switch (reg) - { - case UNW_IA64_BR + 6 ... UNW_IA64_BR + 7: - addr += LINUX_PT_B6_OFF + 8 * (reg - (UNW_IA64_BR + 6)); - break; - - case UNW_IA64_AR_CSD: addr += LINUX_PT_CSD_OFF; break; - case UNW_IA64_AR_SSD: addr += LINUX_PT_SSD_OFF; break; - - case UNW_IA64_GR + 8 ... UNW_IA64_GR + 11: - addr += LINUX_PT_R8_OFF + 8 * (reg - (UNW_IA64_GR + 8)); - break; - - case UNW_IA64_IP: addr += LINUX_PT_IIP_OFF; break; - case UNW_IA64_CFM: addr += LINUX_PT_IFS_OFF; break; - case UNW_IA64_AR_UNAT: addr += LINUX_PT_UNAT_OFF; break; - case UNW_IA64_AR_PFS: addr += LINUX_PT_PFS_OFF; break; - case UNW_IA64_AR_RSC: addr += LINUX_PT_RSC_OFF; break; - case UNW_IA64_AR_RNAT: addr += LINUX_PT_RNAT_OFF; break; - case UNW_IA64_AR_BSPSTORE: addr += LINUX_PT_BSPSTORE_OFF; break; - case UNW_IA64_PR: addr += LINUX_PT_PR_OFF; break; - case UNW_IA64_BR + 0: addr += LINUX_PT_B0_OFF; break; - - case UNW_IA64_GR + 1: - /* The saved r1 value is valid only in the frame in which - it was saved; for everything else we need to look up - the appropriate gp value. */ - if (c->sigcontext_addr != c->sp + 0x10) - return IA64_NULL_LOC; - addr += LINUX_PT_R1_OFF; - break; - - case UNW_IA64_GR + 12: addr += LINUX_PT_R12_OFF; break; - case UNW_IA64_GR + 13: addr += LINUX_PT_R13_OFF; break; - case UNW_IA64_AR_FPSR: addr += LINUX_PT_FPSR_OFF; break; - case UNW_IA64_GR + 15: addr += LINUX_PT_R15_OFF; break; - case UNW_IA64_GR + 14: addr += LINUX_PT_R14_OFF; break; - case UNW_IA64_GR + 2: addr += LINUX_PT_R2_OFF; break; - case UNW_IA64_GR + 3: addr += LINUX_PT_R3_OFF; break; - - case UNW_IA64_GR + 16 ... UNW_IA64_GR + 31: - addr += LINUX_PT_R16_OFF + 8 * (reg - (UNW_IA64_GR + 16)); - break; - - case UNW_IA64_AR_CCV: addr += LINUX_PT_CCV_OFF; break; - - case UNW_IA64_FR + 6 ... UNW_IA64_FR + 11: - addr += LINUX_PT_F6_OFF + 16 * (reg - (UNW_IA64_FR + 6)); - return IA64_LOC_ADDR (addr, IA64_LOC_TYPE_FP); - - default: - if (unw_is_fpreg (reg)) - return IA64_FPREG_LOC (c, reg); - else - return IA64_REG_LOC (c, reg); - } - } - else if (ia64_get_abi_marker (c) == ABI_MARKER_OLD_LINUX_INTERRUPT) - { - switch (reg) - { - case UNW_IA64_GR + 1: - /* The saved r1 value is valid only in the frame in which - it was saved; for everything else we need to look up - the appropriate gp value. */ - if (c->sigcontext_addr != c->sp + 0x10) - return IA64_NULL_LOC; - addr += LINUX_OLD_PT_R1_OFF; - break; - - case UNW_IA64_GR + 2 ... UNW_IA64_GR + 3: - addr += LINUX_OLD_PT_R2_OFF + 8 * (reg - (UNW_IA64_GR + 2)); - break; - - case UNW_IA64_GR + 8 ... UNW_IA64_GR + 11: - addr += LINUX_OLD_PT_R8_OFF + 8 * (reg - (UNW_IA64_GR + 8)); - break; - - case UNW_IA64_GR + 16 ... UNW_IA64_GR + 31: - addr += LINUX_OLD_PT_R16_OFF + 8 * (reg - (UNW_IA64_GR + 16)); - break; - - case UNW_IA64_FR + 6 ... UNW_IA64_FR + 9: - addr += LINUX_OLD_PT_F6_OFF + 16 * (reg - (UNW_IA64_FR + 6)); - return IA64_LOC_ADDR (addr, IA64_LOC_TYPE_FP); - - case UNW_IA64_BR + 0: addr += LINUX_OLD_PT_B0_OFF; break; - case UNW_IA64_BR + 6: addr += LINUX_OLD_PT_B6_OFF; break; - case UNW_IA64_BR + 7: addr += LINUX_OLD_PT_B7_OFF; break; - - case UNW_IA64_AR_RSC: addr += LINUX_OLD_PT_RSC_OFF; break; - case UNW_IA64_AR_CCV: addr += LINUX_OLD_PT_CCV_OFF; break; - - default: - if (unw_is_fpreg (reg)) - return IA64_FPREG_LOC (c, reg); - else - return IA64_REG_LOC (c, reg); - } - } - if (is_nat) - { - /* For Linux pt-regs structure, bit number is determined by - the UNaT slot number (as determined by st8.spill) and the - bits are saved wherever the (primary) UNaT was saved. */ - *nat_bitnr = ia64_unat_slot_num (addr); - return c->loc[IA64_REG_PRI_UNAT_MEM]; - } - return IA64_LOC_ADDR (addr, 0); - } -#endif - return IA64_NULL_LOC; -} - -static inline ia64_loc_t -hpux_scratch_loc (struct cursor *c, unw_regnum_t reg, uint8_t *nat_bitnr) -{ -#if !defined(UNW_LOCAL_ONLY) || defined(__hpux) - return IA64_LOC_UC_REG (reg, c->sigcontext_addr); -#else - return IA64_NULL_LOC; -#endif -} - -HIDDEN ia64_loc_t -ia64_scratch_loc (struct cursor *c, unw_regnum_t reg, uint8_t *nat_bitnr) -{ - if (c->sigcontext_addr) - { - if (ia64_get_abi (c) == ABI_LINUX) - return linux_scratch_loc (c, reg, nat_bitnr); - else if (ia64_get_abi (c) == ABI_HPUX) - return hpux_scratch_loc (c, reg, nat_bitnr); - else - return IA64_NULL_LOC; - } - else - return IA64_REG_LOC (c, reg); -} - -static inline int -update_nat (struct cursor *c, ia64_loc_t nat_loc, unw_word_t mask, - unw_word_t *valp, int write) -{ - unw_word_t nat_word; - int ret; - - ret = ia64_get (c, nat_loc, &nat_word); - if (ret < 0) - return ret; - - if (write) - { - if (*valp) - nat_word |= mask; - else - nat_word &= ~mask; - ret = ia64_put (c, nat_loc, nat_word); - } - else - *valp = (nat_word & mask) != 0; - return ret; -} - -static int -access_nat (struct cursor *c, - ia64_loc_t nat_loc, ia64_loc_t reg_loc, uint8_t nat_bitnr, - unw_word_t *valp, int write) -{ - unw_word_t mask = 0; - unw_fpreg_t tmp; - int ret; - - if (IA64_IS_FP_LOC (reg_loc)) - { - /* NaT bit is saved as a NaTVal. This happens when a general - register is saved to a floating-point register. */ - if (write) - { - if (*valp) - { - if (ia64_is_big_endian (c)) - ret = ia64_putfp (c, reg_loc, unw.nat_val_be); - else - ret = ia64_putfp (c, reg_loc, unw.nat_val_le); - } - else - { - unw_word_t *src, *dst; - unw_fpreg_t tmp; - - ret = ia64_getfp (c, reg_loc, &tmp); - if (ret < 0) - return ret; - - /* Reset the exponent to 0x1003e so that the significand - will be interpreted as an integer value. */ - src = (unw_word_t *) &unw.int_val_be; - dst = (unw_word_t *) &tmp; - if (!ia64_is_big_endian (c)) - ++src, ++dst; - *dst = *src; - - ret = ia64_putfp (c, reg_loc, tmp); - } - } - else - { - ret = ia64_getfp (c, reg_loc, &tmp); - if (ret < 0) - return ret; - - if (ia64_is_big_endian (c)) - *valp = (memcmp (&tmp, &unw.nat_val_be, sizeof (tmp)) == 0); - else - *valp = (memcmp (&tmp, &unw.nat_val_le, sizeof (tmp)) == 0); - } - return ret; - } - - if ((IA64_IS_REG_LOC (nat_loc) - && (unsigned) (IA64_GET_REG (nat_loc) - UNW_IA64_NAT) < 128) - || IA64_IS_UC_LOC (reg_loc)) - { - if (write) - return ia64_put (c, nat_loc, *valp); - else - return ia64_get (c, nat_loc, valp); - } - - if (IA64_IS_NULL_LOC (nat_loc)) - { - /* NaT bit is not saved. This happens if a general register is - saved to a branch register. Since the NaT bit gets lost, we - need to drop it here, too. Note that if the NaT bit had been - set when the save occurred, it would have caused a NaT - consumption fault. */ - if (write) - { - if (*valp) - return -UNW_EBADREG; /* can't set NaT bit */ - } - else - *valp = 0; - return 0; - } - - mask = (unw_word_t) 1 << nat_bitnr; - return update_nat (c, nat_loc, mask, valp, write); -} - -HIDDEN int -tdep_access_reg (struct cursor *c, unw_regnum_t reg, unw_word_t *valp, - int write) -{ - ia64_loc_t loc, reg_loc, nat_loc; - unw_word_t mask, val; - uint8_t nat_bitnr; - int ret; - - switch (reg) - { - /* frame registers: */ - - case UNW_IA64_BSP: - if (write) - c->bsp = *valp; - else - *valp = c->bsp; - return 0; - - case UNW_REG_SP: - if (write) - c->sp = *valp; - else - *valp = c->sp; - return 0; - - case UNW_REG_IP: - if (write) - { - c->ip = *valp; /* also update the IP cache */ - if (c->pi_valid && (*valp < c->pi.start_ip || *valp >= c->pi.end_ip)) - c->pi_valid = 0; /* new IP outside of current proc */ - } - loc = c->loc[IA64_REG_IP]; - break; - - /* preserved registers: */ - - case UNW_IA64_GR + 4 ... UNW_IA64_GR + 7: - loc = c->loc[IA64_REG_R4 + (reg - (UNW_IA64_GR + 4))]; - break; - - case UNW_IA64_NAT + 4 ... UNW_IA64_NAT + 7: - loc = c->loc[IA64_REG_NAT4 + (reg - (UNW_IA64_NAT + 4))]; - reg_loc = c->loc[IA64_REG_R4 + (reg - (UNW_IA64_NAT + 4))]; - nat_bitnr = c->nat_bitnr[reg - (UNW_IA64_NAT + 4)]; - return access_nat (c, loc, reg_loc, nat_bitnr, valp, write); - - case UNW_IA64_AR_BSP: loc = c->loc[IA64_REG_BSP]; break; - case UNW_IA64_AR_BSPSTORE: loc = c->loc[IA64_REG_BSPSTORE]; break; - case UNW_IA64_AR_PFS: loc = c->loc[IA64_REG_PFS]; break; - case UNW_IA64_AR_RNAT: loc = c->loc[IA64_REG_RNAT]; break; - case UNW_IA64_AR_UNAT: loc = c->loc[IA64_REG_UNAT]; break; - case UNW_IA64_AR_LC: loc = c->loc[IA64_REG_LC]; break; - case UNW_IA64_AR_FPSR: loc = c->loc[IA64_REG_FPSR]; break; - case UNW_IA64_BR + 1: loc = c->loc[IA64_REG_B1]; break; - case UNW_IA64_BR + 2: loc = c->loc[IA64_REG_B2]; break; - case UNW_IA64_BR + 3: loc = c->loc[IA64_REG_B3]; break; - case UNW_IA64_BR + 4: loc = c->loc[IA64_REG_B4]; break; - case UNW_IA64_BR + 5: loc = c->loc[IA64_REG_B5]; break; - - case UNW_IA64_CFM: - if (write) - c->cfm = *valp; /* also update the CFM cache */ - loc = c->cfm_loc; - break; - - case UNW_IA64_PR: - /* - * Note: broad-side access to the predicates is NOT rotated - * (i.e., it is done as if CFM.rrb.pr == 0. - */ - if (write) - { - c->pr = *valp; /* update the predicate cache */ - return ia64_put (c, c->loc[IA64_REG_PR], *valp); - } - else - return ia64_get (c, c->loc[IA64_REG_PR], valp); - - case UNW_IA64_GR + 32 ... UNW_IA64_GR + 127: /* stacked reg */ - reg = rotate_gr (c, reg - UNW_IA64_GR); - if (reg < 0) - return -UNW_EBADREG; - ret = ia64_get_stacked (c, reg, &loc, NULL); - if (ret < 0) - return ret; - break; - - case UNW_IA64_NAT + 32 ... UNW_IA64_NAT + 127: /* stacked reg */ - reg = rotate_gr (c, reg - UNW_IA64_NAT); - if (reg < 0) - return -UNW_EBADREG; - ret = ia64_get_stacked (c, reg, &loc, &nat_loc); - if (ret < 0) - return ret; - assert (!IA64_IS_REG_LOC (loc)); - mask = (unw_word_t) 1 << rse_slot_num (IA64_GET_ADDR (loc)); - return update_nat (c, nat_loc, mask, valp, write); - - case UNW_IA64_AR_EC: - if ((ret = ia64_get (c, c->ec_loc, &val)) < 0) - return ret; - - if (write) - { - val = ((val & ~((unw_word_t) 0x3f << 52)) | ((*valp & 0x3f) << 52)); - return ia64_put (c, c->ec_loc, val); - } - else - { - *valp = (val >> 52) & 0x3f; - return 0; - } - - /* scratch & special registers: */ - - case UNW_IA64_GR + 0: - if (write) - return -UNW_EREADONLYREG; - *valp = 0; - return 0; - - case UNW_IA64_NAT + 0: - if (write) - return -UNW_EREADONLYREG; - *valp = 0; - return 0; - - case UNW_IA64_NAT + 1: - case UNW_IA64_NAT + 2 ... UNW_IA64_NAT + 3: - case UNW_IA64_NAT + 8 ... UNW_IA64_NAT + 31: - loc = ia64_scratch_loc (c, reg, &nat_bitnr); - if (IA64_IS_NULL_LOC (loc) && reg == UNW_IA64_NAT + 1) - { - /* access to GP */ - if (write) - return -UNW_EREADONLYREG; - *valp = 0; - return 0; - } - if (!(IA64_IS_REG_LOC (loc) || IA64_IS_UC_LOC (loc) - || IA64_IS_FP_LOC (loc))) - /* We're dealing with a NaT bit stored in memory. */ - return update_nat(c, loc, (unw_word_t) 1 << nat_bitnr, valp, write); - break; - - case UNW_IA64_GR + 15 ... UNW_IA64_GR + 18: - mask = 1 << (reg - (UNW_IA64_GR + 15)); - if (write) - { - c->eh_args[reg - (UNW_IA64_GR + 15)] = *valp; - c->eh_valid_mask |= mask; - return 0; - } - else if ((c->eh_valid_mask & mask) != 0) - { - *valp = c->eh_args[reg - (UNW_IA64_GR + 15)]; - return 0; - } - else - loc = ia64_scratch_loc (c, reg, NULL); - break; - - case UNW_IA64_GR + 1: /* global pointer */ - case UNW_IA64_GR + 2 ... UNW_IA64_GR + 3: - case UNW_IA64_GR + 8 ... UNW_IA64_GR + 14: - case UNW_IA64_GR + 19 ... UNW_IA64_GR + 31: - case UNW_IA64_BR + 0: - case UNW_IA64_BR + 6: - case UNW_IA64_BR + 7: - case UNW_IA64_AR_RSC: - case UNW_IA64_AR_CSD: - case UNW_IA64_AR_SSD: - case UNW_IA64_AR_CCV: - loc = ia64_scratch_loc (c, reg, NULL); - if (IA64_IS_NULL_LOC (loc) && reg == UNW_IA64_GR + 1) - { - /* access to GP */ - if (write) - return -UNW_EREADONLYREG; - - /* ensure c->pi is up-to-date: */ - if ((ret = ia64_make_proc_info (c)) < 0) - return ret; - *valp = c->pi.gp; - return 0; - } - break; - - default: - Debug (1, "bad register number %d\n", reg); - return -UNW_EBADREG; - } - - if (write) - return ia64_put (c, loc, *valp); - else - return ia64_get (c, loc, valp); -} - -HIDDEN int -tdep_access_fpreg (struct cursor *c, int reg, unw_fpreg_t *valp, - int write) -{ - ia64_loc_t loc; - - switch (reg) - { - case UNW_IA64_FR + 0: - if (write) - return -UNW_EREADONLYREG; - *valp = unw.read_only.f0; - return 0; - - case UNW_IA64_FR + 1: - if (write) - return -UNW_EREADONLYREG; - - if (ia64_is_big_endian (c)) - *valp = unw.read_only.f1_be; - else - *valp = unw.read_only.f1_le; - return 0; - - case UNW_IA64_FR + 2: loc = c->loc[IA64_REG_F2]; break; - case UNW_IA64_FR + 3: loc = c->loc[IA64_REG_F3]; break; - case UNW_IA64_FR + 4: loc = c->loc[IA64_REG_F4]; break; - case UNW_IA64_FR + 5: loc = c->loc[IA64_REG_F5]; break; - - case UNW_IA64_FR + 16 ... UNW_IA64_FR + 31: - loc = c->loc[IA64_REG_F16 + (reg - (UNW_IA64_FR + 16))]; - break; - - case UNW_IA64_FR + 6 ... UNW_IA64_FR + 15: - loc = ia64_scratch_loc (c, reg, NULL); - break; - - case UNW_IA64_FR + 32 ... UNW_IA64_FR + 127: - reg = rotate_fr (c, reg - UNW_IA64_FR) + UNW_IA64_FR; - loc = ia64_scratch_loc (c, reg, NULL); - break; - - default: - Debug (1, "bad register number %d\n", reg); - return -UNW_EBADREG; - } - - if (write) - return ia64_putfp (c, loc, *valp); - else - return ia64_getfp (c, loc, valp); -} diff --git a/src/pal/src/libunwind/src/ia64/Gresume.c b/src/pal/src/libunwind/src/ia64/Gresume.c deleted file mode 100644 index 68fe8a659..000000000 --- a/src/pal/src/libunwind/src/ia64/Gresume.c +++ /dev/null @@ -1,274 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2001-2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include - -#include "unwind_i.h" -#include "offsets.h" - -#ifndef UNW_REMOTE_ONLY - -static inline int -local_resume (unw_addr_space_t as, unw_cursor_t *cursor, void *arg) -{ -#if defined(__linux) - unw_word_t dirty_partition[2048]; /* AR.RSC.LOADRS is a 14-bit field */ - unw_word_t val, sol, sof, pri_unat, n, pfs, bspstore, dirty_rnat; - struct cursor *c = (struct cursor *) cursor; - struct - { - unw_word_t r1; - unw_word_t r4; - unw_word_t r5; - unw_word_t r6; - unw_word_t r7; - unw_word_t r15; - unw_word_t r16; - unw_word_t r17; - unw_word_t r18; - } - extra; - int ret, dirty_size; -# define GET_NAT(n) \ - do \ - { \ - ret = tdep_access_reg (c, UNW_IA64_NAT + (n), &val, 0); \ - if (ret < 0) \ - return ret; \ - if (val) \ - pri_unat |= (unw_word_t) 1 << n; \ - } \ - while (0) - - /* ensure c->pi is up-to-date: */ - if ((ret = ia64_make_proc_info (c)) < 0) - return ret; - - /* Copy contents of r4-r7 into "extra", so that their values end up - contiguous, so we can use a single (primary-) UNaT value. */ - if ((ret = ia64_get (c, c->loc[IA64_REG_R4], &extra.r4)) < 0 - || (ret = ia64_get (c, c->loc[IA64_REG_R5], &extra.r5)) < 0 - || (ret = ia64_get (c, c->loc[IA64_REG_R6], &extra.r6)) < 0 - || (ret = ia64_get (c, c->loc[IA64_REG_R7], &extra.r7)) < 0) - return ret; - - /* Form the primary UNaT value: */ - pri_unat = 0; - GET_NAT (4); GET_NAT(5); - GET_NAT (6); GET_NAT(7); - n = (((uintptr_t) &extra.r4) / 8 - 4) % 64; - pri_unat = (pri_unat << n) | (pri_unat >> (64 - n)); - - if (unlikely (c->sigcontext_addr)) - { - struct sigcontext *sc = (struct sigcontext *) c->sigcontext_addr; -# define PR_SCRATCH 0xffc0 /* p6-p15 are scratch */ -# define PR_PRESERVED (~(PR_SCRATCH | 1)) - - /* We're returning to a frame that was (either directly or - indirectly) interrupted by a signal. We have to restore - _both_ "preserved" and "scratch" registers. That doesn't - leave us any registers to work with, and the only way we can - achieve this is by doing a sigreturn(). - - Note: it might be tempting to think that we don't have to - restore the scratch registers when returning to a frame that - was indirectly interrupted by a signal. However, that is not - safe because that frame and its descendants could have been - using a special convention that stores "preserved" state in - scratch registers. For example, the Linux fsyscall - convention does this with r11 (to save ar.pfs) and b6 (to - save "rp"). */ - - sc->sc_gr[12] = c->psp; - c->psp = c->sigcontext_addr - c->sigcontext_off; - - sof = (c->cfm & 0x7f); - if ((dirty_size = rbs_cover_and_flush (c, sof, dirty_partition, - &dirty_rnat, &bspstore)) < 0) - return dirty_size; - - /* Clear the "in-syscall" flag, because in general we won't be - returning to the interruption-point and we need all registers - restored. */ - sc->sc_flags &= ~IA64_SC_FLAG_IN_SYSCALL; - sc->sc_ip = c->ip; - sc->sc_cfm = c->cfm & (((unw_word_t) 1 << 38) - 1); - sc->sc_pr = (c->pr & ~PR_SCRATCH) | (sc->sc_pr & ~PR_PRESERVED); - if ((ret = ia64_get (c, c->loc[IA64_REG_PFS], &sc->sc_ar_pfs)) < 0 - || (ret = ia64_get (c, c->loc[IA64_REG_FPSR], &sc->sc_ar_fpsr)) < 0 - || (ret = ia64_get (c, c->loc[IA64_REG_UNAT], &sc->sc_ar_unat)) < 0) - return ret; - - sc->sc_gr[1] = c->pi.gp; - if (c->eh_valid_mask & 0x1) sc->sc_gr[15] = c->eh_args[0]; - if (c->eh_valid_mask & 0x2) sc->sc_gr[16] = c->eh_args[1]; - if (c->eh_valid_mask & 0x4) sc->sc_gr[17] = c->eh_args[2]; - if (c->eh_valid_mask & 0x8) sc->sc_gr[18] = c->eh_args[3]; - Debug (9, "sc: r15=%lx,r16=%lx,r17=%lx,r18=%lx\n", - (long) sc->sc_gr[15], (long) sc->sc_gr[16], - (long) sc->sc_gr[17], (long) sc->sc_gr[18]); - } - else - { - /* Account for the fact that _Uia64_install_context() will - return via br.ret, which will decrement bsp by size-of-locals. */ - if ((ret = ia64_get (c, c->loc[IA64_REG_PFS], &pfs)) < 0) - return ret; - sol = (pfs >> 7) & 0x7f; - if ((dirty_size = rbs_cover_and_flush (c, sol, dirty_partition, - &dirty_rnat, &bspstore)) < 0) - return dirty_size; - - extra.r1 = c->pi.gp; - extra.r15 = c->eh_args[0]; - extra.r16 = c->eh_args[1]; - extra.r17 = c->eh_args[2]; - extra.r18 = c->eh_args[3]; - Debug (9, "extra: r15=%lx,r16=%lx,r17=%lx,r18=%lx\n", - (long) extra.r15, (long) extra.r16, - (long) extra.r17, (long) extra.r18); - } - Debug (8, "resuming at ip=%lx\n", (long) c->ip); - ia64_install_cursor (c, pri_unat, (unw_word_t *) &extra, - bspstore, dirty_size, dirty_partition + dirty_size/8, - dirty_rnat); -#elif defined(__hpux) - struct cursor *c = (struct cursor *) cursor; - - setcontext (c->as_arg); /* should not return */ -#endif - return -UNW_EINVAL; -} - -HIDDEN int -ia64_local_resume (unw_addr_space_t as, unw_cursor_t *cursor, void *arg) -{ - return local_resume (as, cursor, arg); -} - -#endif /* !UNW_REMOTE_ONLY */ - -#ifndef UNW_LOCAL_ONLY - -static inline int -remote_install_cursor (struct cursor *c) -{ - int (*access_reg) (unw_addr_space_t, unw_regnum_t, unw_word_t *, - int write, void *); - int (*access_fpreg) (unw_addr_space_t, unw_regnum_t, unw_fpreg_t *, - int write, void *); - unw_fpreg_t fpval; - unw_word_t val; - int reg; - -#if defined(__linux) && !defined(UNW_REMOTE_ONLY) - if (c->as == unw_local_addr_space) - { - /* Take a short-cut: we directly resume out of the cursor and - all we need to do is make sure that all locations point to - memory, not registers. Furthermore, R4-R7 and NAT4-NAT7 are - taken care of by ia64_local_resume() so they don't need to be - handled here. */ -# define MEMIFY(preg, reg) \ - do { \ - if (IA64_IS_REG_LOC (c->loc[(preg)])) \ - c->loc[(preg)] = IA64_LOC_ADDR ((unw_word_t) \ - tdep_uc_addr(c->as_arg, (reg), \ - NULL), 0); \ - } while (0) - MEMIFY (IA64_REG_PR, UNW_IA64_PR); - MEMIFY (IA64_REG_PFS, UNW_IA64_AR_PFS); - MEMIFY (IA64_REG_RNAT, UNW_IA64_AR_RNAT); - MEMIFY (IA64_REG_UNAT, UNW_IA64_AR_UNAT); - MEMIFY (IA64_REG_LC, UNW_IA64_AR_LC); - MEMIFY (IA64_REG_FPSR, UNW_IA64_AR_FPSR); - MEMIFY (IA64_REG_IP, UNW_IA64_BR + 0); - MEMIFY (IA64_REG_B1, UNW_IA64_BR + 1); - MEMIFY (IA64_REG_B2, UNW_IA64_BR + 2); - MEMIFY (IA64_REG_B3, UNW_IA64_BR + 3); - MEMIFY (IA64_REG_B4, UNW_IA64_BR + 4); - MEMIFY (IA64_REG_B5, UNW_IA64_BR + 5); - MEMIFY (IA64_REG_F2, UNW_IA64_FR + 2); - MEMIFY (IA64_REG_F3, UNW_IA64_FR + 3); - MEMIFY (IA64_REG_F4, UNW_IA64_FR + 4); - MEMIFY (IA64_REG_F5, UNW_IA64_FR + 5); - MEMIFY (IA64_REG_F16, UNW_IA64_FR + 16); - MEMIFY (IA64_REG_F17, UNW_IA64_FR + 17); - MEMIFY (IA64_REG_F18, UNW_IA64_FR + 18); - MEMIFY (IA64_REG_F19, UNW_IA64_FR + 19); - MEMIFY (IA64_REG_F20, UNW_IA64_FR + 20); - MEMIFY (IA64_REG_F21, UNW_IA64_FR + 21); - MEMIFY (IA64_REG_F22, UNW_IA64_FR + 22); - MEMIFY (IA64_REG_F23, UNW_IA64_FR + 23); - MEMIFY (IA64_REG_F24, UNW_IA64_FR + 24); - MEMIFY (IA64_REG_F25, UNW_IA64_FR + 25); - MEMIFY (IA64_REG_F26, UNW_IA64_FR + 26); - MEMIFY (IA64_REG_F27, UNW_IA64_FR + 27); - MEMIFY (IA64_REG_F28, UNW_IA64_FR + 28); - MEMIFY (IA64_REG_F29, UNW_IA64_FR + 29); - MEMIFY (IA64_REG_F30, UNW_IA64_FR + 30); - MEMIFY (IA64_REG_F31, UNW_IA64_FR + 31); - } - else -#endif /* __linux && !UNW_REMOTE_ONLY */ - { - access_reg = c->as->acc.access_reg; - access_fpreg = c->as->acc.access_fpreg; - - Debug (8, "copying out cursor state\n"); - - for (reg = 0; reg <= UNW_REG_LAST; ++reg) - { - if (unw_is_fpreg (reg)) - { - if (tdep_access_fpreg (c, reg, &fpval, 0) >= 0) - (*access_fpreg) (c->as, reg, &fpval, 1, c->as_arg); - } - else - { - if (tdep_access_reg (c, reg, &val, 0) >= 0) - (*access_reg) (c->as, reg, &val, 1, c->as_arg); - } - } - } - return (*c->as->acc.resume) (c->as, (unw_cursor_t *) c, c->as_arg); -} - -#endif /* !UNW_LOCAL_ONLY */ - -int -unw_resume (unw_cursor_t *cursor) -{ - struct cursor *c = (struct cursor *) cursor; - - Debug (1, "(cursor=%p, ip=0x%016lx)\n", c, (unsigned long) c->ip); - -#ifdef UNW_LOCAL_ONLY - return local_resume (c->as, cursor, c->as_arg); -#else - return remote_install_cursor (c); -#endif -} diff --git a/src/pal/src/libunwind/src/ia64/Gscript.c b/src/pal/src/libunwind/src/ia64/Gscript.c deleted file mode 100644 index 526aeaf29..000000000 --- a/src/pal/src/libunwind/src/ia64/Gscript.c +++ /dev/null @@ -1,765 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2001-2005 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include "offsets.h" -#include "regs.h" -#include "unwind_i.h" - -enum ia64_script_insn_opcode - { - IA64_INSN_INC_PSP, /* psp += val */ - IA64_INSN_LOAD_PSP, /* psp = *psp_loc */ - IA64_INSN_ADD_PSP, /* s[dst] = (s.psp + val) */ - IA64_INSN_ADD_PSP_NAT, /* like above, but with NaT info */ - IA64_INSN_ADD_SP, /* s[dst] = (s.sp + val) */ - IA64_INSN_ADD_SP_NAT, /* like above, but with NaT info */ - IA64_INSN_MOVE, /* s[dst] = s[val] */ - IA64_INSN_MOVE_NAT, /* like above, but with NaT info */ - IA64_INSN_MOVE_NO_NAT, /* like above, but clear NaT info */ - IA64_INSN_MOVE_STACKED, /* s[dst] = rse_skip(*s.bsp_loc, val) */ - IA64_INSN_MOVE_STACKED_NAT, /* like above, but with NaT info */ - IA64_INSN_MOVE_SCRATCH, /* s[dst] = scratch reg "val" */ - IA64_INSN_MOVE_SCRATCH_NAT, /* like above, but with NaT info */ - IA64_INSN_MOVE_SCRATCH_NO_NAT /* like above, but clear NaT info */ - }; - -#if defined(HAVE___THREAD) && HAVE___THREAD -static __thread struct ia64_script_cache ia64_per_thread_cache = - { -#ifdef HAVE_ATOMIC_OPS_H - .busy = AO_TS_INITIALIZER -#else - .lock = PTHREAD_MUTEX_INITIALIZER -#endif - }; -#endif - -static inline unw_hash_index_t CONST_ATTR -hash (unw_word_t ip) -{ - /* based on (sqrt(5)/2-1)*2^64 */ -# define magic ((unw_word_t) 0x9e3779b97f4a7c16ULL) - - return (ip >> 4) * magic >> (64 - IA64_LOG_UNW_HASH_SIZE); -} - -static inline long -cache_match (struct ia64_script *script, unw_word_t ip, unw_word_t pr) -{ - if (ip == script->ip && ((pr ^ script->pr_val) & script->pr_mask) == 0) - return 1; - return 0; -} - -static inline void -flush_script_cache (struct ia64_script_cache *cache) -{ - int i; - - cache->lru_head = IA64_UNW_CACHE_SIZE - 1; - cache->lru_tail = 0; - - for (i = 0; i < IA64_UNW_CACHE_SIZE; ++i) - { - if (i > 0) - cache->buckets[i].lru_chain = (i - 1); - cache->buckets[i].coll_chain = -1; - cache->buckets[i].ip = 0; - } - for (i = 0; ihash[i] = -1; -} - -static inline struct ia64_script_cache * -get_script_cache (unw_addr_space_t as, intrmask_t *saved_maskp) -{ - struct ia64_script_cache *cache = &as->global_cache; - unw_caching_policy_t caching = as->caching_policy; - - if (caching == UNW_CACHE_NONE) - return NULL; - -#ifdef HAVE_ATOMIC_H - if (!spin_trylock_irqsave (&cache->busy, *saved_maskp)) - return NULL; -#else -# if defined(HAVE___THREAD) && HAVE___THREAD - if (as->caching_policy == UNW_CACHE_PER_THREAD) - cache = &ia64_per_thread_cache; -# endif -# ifdef HAVE_ATOMIC_OPS_H - if (AO_test_and_set (&cache->busy) == AO_TS_SET) - return NULL; -# else - if (likely (caching == UNW_CACHE_GLOBAL)) - { - Debug (16, "acquiring lock\n"); - lock_acquire (&cache->lock, *saved_maskp); - } -# endif -#endif - - if (atomic_read (&as->cache_generation) != atomic_read (&cache->generation)) - { - flush_script_cache (cache); - cache->generation = as->cache_generation; - } - return cache; -} - -static inline void -put_script_cache (unw_addr_space_t as, struct ia64_script_cache *cache, - intrmask_t *saved_maskp) -{ - assert (as->caching_policy != UNW_CACHE_NONE); - - Debug (16, "unmasking signals/interrupts and releasing lock\n"); -#ifdef HAVE_ATOMIC_H - spin_unlock_irqrestore (&cache->busy, *saved_maskp); -#else -# ifdef HAVE_ATOMIC_OPS_H - AO_CLEAR (&cache->busy); -# else - if (likely (as->caching_policy == UNW_CACHE_GLOBAL)) - lock_release (&cache->lock, *saved_maskp); -# endif -#endif -} - -static struct ia64_script * -script_lookup (struct ia64_script_cache *cache, struct cursor *c) -{ - struct ia64_script *script = cache->buckets + c->hint; - unsigned short index; - unw_word_t ip, pr; - - ip = c->ip; - pr = c->pr; - - if (cache_match (script, ip, pr)) - return script; - - index = cache->hash[hash (ip)]; - if (index >= IA64_UNW_CACHE_SIZE) - return 0; - - script = cache->buckets + index; - while (1) - { - if (cache_match (script, ip, pr)) - { - /* update hint; no locking needed: single-word writes are atomic */ - c->hint = cache->buckets[c->prev_script].hint = - (script - cache->buckets); - return script; - } - if (script->coll_chain >= IA64_UNW_HASH_SIZE) - return 0; - script = cache->buckets + script->coll_chain; - } -} - -static inline void -script_init (struct ia64_script *script, unw_word_t ip) -{ - script->ip = ip; - script->hint = 0; - script->count = 0; - script->abi_marker = 0; -} - -static inline struct ia64_script * -script_new (struct ia64_script_cache *cache, unw_word_t ip) -{ - struct ia64_script *script, *prev, *tmp; - unw_hash_index_t index; - unsigned short head; - - head = cache->lru_head; - script = cache->buckets + head; - cache->lru_head = script->lru_chain; - - /* re-insert script at the tail of the LRU chain: */ - cache->buckets[cache->lru_tail].lru_chain = head; - cache->lru_tail = head; - - /* remove the old script from the hash table (if it's there): */ - if (script->ip) - { - index = hash (script->ip); - tmp = cache->buckets + cache->hash[index]; - prev = 0; - while (1) - { - if (tmp == script) - { - if (prev) - prev->coll_chain = tmp->coll_chain; - else - cache->hash[index] = tmp->coll_chain; - break; - } - else - prev = tmp; - if (tmp->coll_chain >= IA64_UNW_CACHE_SIZE) - /* old script wasn't in the hash-table */ - break; - tmp = cache->buckets + tmp->coll_chain; - } - } - - /* enter new script in the hash table */ - index = hash (ip); - script->coll_chain = cache->hash[index]; - cache->hash[index] = script - cache->buckets; - - script_init (script, ip); - return script; -} - -static inline void -script_finalize (struct ia64_script *script, struct cursor *c, - struct ia64_state_record *sr) -{ - script->pr_mask = sr->pr_mask; - script->pr_val = sr->pr_val; - script->pi = c->pi; -} - -static inline void -script_emit (struct ia64_script *script, struct ia64_script_insn insn) -{ - if (script->count >= IA64_MAX_SCRIPT_LEN) - { - Dprintf ("%s: script exceeds maximum size of %u instructions!\n", - __FUNCTION__, IA64_MAX_SCRIPT_LEN); - return; - } - script->insn[script->count++] = insn; -} - -static void -compile_reg (struct ia64_state_record *sr, int i, struct ia64_reg_info *r, - struct ia64_script *script) -{ - enum ia64_script_insn_opcode opc; - unsigned long val, rval; - struct ia64_script_insn insn; - long is_preserved_gr; - - if (r->where == IA64_WHERE_NONE || r->when >= sr->when_target) - return; - - opc = IA64_INSN_MOVE; - val = rval = r->val; - is_preserved_gr = (i >= IA64_REG_R4 && i <= IA64_REG_R7); - - if (r->where == IA64_WHERE_GR) - { - /* Handle most common case first... */ - if (rval >= 32) - { - /* register got spilled to a stacked register */ - if (is_preserved_gr) - opc = IA64_INSN_MOVE_STACKED_NAT; - else - opc = IA64_INSN_MOVE_STACKED; - val = rval; - } - else if (rval >= 4 && rval <= 7) - { - /* register got spilled to a preserved register */ - val = IA64_REG_R4 + (rval - 4); - if (is_preserved_gr) - opc = IA64_INSN_MOVE_NAT; - } - else - { - /* register got spilled to a scratch register */ - if (is_preserved_gr) - opc = IA64_INSN_MOVE_SCRATCH_NAT; - else - opc = IA64_INSN_MOVE_SCRATCH; - val = UNW_IA64_GR + rval; - } - } - else - { - switch (r->where) - { - case IA64_WHERE_FR: - /* Note: There is no need to handle NaT-bit info here - (indepent of is_preserved_gr), because for floating-point - NaTs are represented as NaTVal, so the NaT-info never - needs to be consulated. */ - if (rval >= 2 && rval <= 5) - val = IA64_REG_F2 + (rval - 2); - else if (rval >= 16 && rval <= 31) - val = IA64_REG_F16 + (rval - 16); - else - { - opc = IA64_INSN_MOVE_SCRATCH; - val = UNW_IA64_FR + rval; - } - break; - - case IA64_WHERE_BR: - if (rval >= 1 && rval <= 5) - { - val = IA64_REG_B1 + (rval - 1); - if (is_preserved_gr) - opc = IA64_INSN_MOVE_NO_NAT; - } - else - { - opc = IA64_INSN_MOVE_SCRATCH; - if (is_preserved_gr) - opc = IA64_INSN_MOVE_SCRATCH_NO_NAT; - val = UNW_IA64_BR + rval; - } - break; - - case IA64_WHERE_SPREL: - if (is_preserved_gr) - opc = IA64_INSN_ADD_SP_NAT; - else - { - opc = IA64_INSN_ADD_SP; - if (i >= IA64_REG_F2 && i <= IA64_REG_F31) - val |= IA64_LOC_TYPE_FP; - } - break; - - case IA64_WHERE_PSPREL: - if (is_preserved_gr) - opc = IA64_INSN_ADD_PSP_NAT; - else - { - opc = IA64_INSN_ADD_PSP; - if (i >= IA64_REG_F2 && i <= IA64_REG_F31) - val |= IA64_LOC_TYPE_FP; - } - break; - - default: - Dprintf ("%s: register %u has unexpected `where' value of %u\n", - __FUNCTION__, i, r->where); - break; - } - } - insn.opc = opc; - insn.dst = i; - insn.val = val; - script_emit (script, insn); - - if (i == IA64_REG_PSP) - { - /* c->psp must contain the _value_ of the previous sp, not it's - save-location. We get this by dereferencing the value we - just stored in loc[IA64_REG_PSP]: */ - insn.opc = IA64_INSN_LOAD_PSP; - script_emit (script, insn); - } -} - -/* Sort the registers which got saved in decreasing order of WHEN - value. This is needed to ensure that the save-locations are - updated in the proper order. For example, suppose r4 gets spilled - to memory and then r5 gets saved in r4. In this case, we need to - update the save location of r5 before the one of r4. */ - -static inline int -sort_regs (struct ia64_state_record *sr, int regorder[]) -{ - int r, i, j, max, max_reg, max_when, num_regs = 0; - - assert (IA64_REG_BSP == 3); - - for (r = IA64_REG_BSP; r < IA64_NUM_PREGS; ++r) - { - if (sr->curr.reg[r].where == IA64_WHERE_NONE - || sr->curr.reg[r].when >= sr->when_target) - continue; - - regorder[num_regs++] = r; - } - - /* Simple insertion-sort. Involves about N^2/2 comparisons and N - exchanges. N is often small (say, 2-5) so a fancier sorting - algorithm may not be worthwhile. */ - - for (i = max = 0; i < num_regs - 1; ++i) - { - max_reg = regorder[max]; - max_when = sr->curr.reg[max_reg].when; - - for (j = i + 1; j < num_regs; ++j) - if (sr->curr.reg[regorder[j]].when > max_when) - { - max = j; - max_reg = regorder[j]; - max_when = sr->curr.reg[max_reg].when; - } - if (i != max) - { - regorder[max] = regorder[i]; - regorder[i] = max_reg; - } - } - return num_regs; -} - -/* Build an unwind script that unwinds from state OLD_STATE to the - entrypoint of the function that called OLD_STATE. */ - -static inline int -build_script (struct cursor *c, struct ia64_script *script) -{ - int num_regs, i, ret, regorder[IA64_NUM_PREGS - 3]; - struct ia64_reg_info *pri_unat; - struct ia64_state_record sr; - struct ia64_script_insn insn; - - ret = ia64_create_state_record (c, &sr); - if (ret < 0) - return ret; - - /* First, compile the update for IA64_REG_PSP. This is important - because later save-locations may depend on it's correct (updated) - value. Fixed-size frames are handled specially and variable-size - frames get handled via the normal compile_reg(). */ - - if (sr.when_target > sr.curr.reg[IA64_REG_PSP].when - && (sr.curr.reg[IA64_REG_PSP].where == IA64_WHERE_NONE) - && sr.curr.reg[IA64_REG_PSP].val != 0) - { - /* new psp is psp plus frame size */ - insn.opc = IA64_INSN_INC_PSP; - insn.val = sr.curr.reg[IA64_REG_PSP].val; /* frame size */ - script_emit (script, insn); - } - else - compile_reg (&sr, IA64_REG_PSP, sr.curr.reg + IA64_REG_PSP, script); - - /* Second, compile the update for the primary UNaT, if any: */ - - if (sr.when_target >= sr.curr.reg[IA64_REG_PRI_UNAT_GR].when - || sr.when_target >= sr.curr.reg[IA64_REG_PRI_UNAT_MEM].when) - { - if (sr.when_target < sr.curr.reg[IA64_REG_PRI_UNAT_GR].when) - /* (primary) NaT bits were saved to memory only */ - pri_unat = sr.curr.reg + IA64_REG_PRI_UNAT_MEM; - else if (sr.when_target < sr.curr.reg[IA64_REG_PRI_UNAT_MEM].when) - /* (primary) NaT bits were saved to a register only */ - pri_unat = sr.curr.reg + IA64_REG_PRI_UNAT_GR; - else if (sr.curr.reg[IA64_REG_PRI_UNAT_MEM].when > - sr.curr.reg[IA64_REG_PRI_UNAT_GR].when) - /* (primary) NaT bits were last saved to memory */ - pri_unat = sr.curr.reg + IA64_REG_PRI_UNAT_MEM; - else - /* (primary) NaT bits were last saved to a register */ - pri_unat = sr.curr.reg + IA64_REG_PRI_UNAT_GR; - - /* Note: we always store the final primary-UNaT location in UNAT_MEM. */ - compile_reg (&sr, IA64_REG_PRI_UNAT_MEM, pri_unat, script); - } - - /* Third, compile the other register in decreasing order of WHEN values. */ - - num_regs = sort_regs (&sr, regorder); - for (i = 0; i < num_regs; ++i) - compile_reg (&sr, regorder[i], sr.curr.reg + regorder[i], script); - - script->abi_marker = sr.abi_marker; - script_finalize (script, c, &sr); - - ia64_free_state_record (&sr); - return 0; -} - -static inline void -set_nat_info (struct cursor *c, unsigned long dst, - ia64_loc_t nat_loc, uint8_t bitnr) -{ - assert (dst >= IA64_REG_R4 && dst <= IA64_REG_R7); - - c->loc[dst - IA64_REG_R4 + IA64_REG_NAT4] = nat_loc; - c->nat_bitnr[dst - IA64_REG_R4] = bitnr; -} - -/* Apply the unwinding actions represented by OPS and update SR to - reflect the state that existed upon entry to the function that this - unwinder represents. */ - -static inline int -run_script (struct ia64_script *script, struct cursor *c) -{ - struct ia64_script_insn *ip, *limit, next_insn; - ia64_loc_t loc, nat_loc; - unsigned long opc, dst; - uint8_t nat_bitnr; - unw_word_t val; - int ret; - - c->pi = script->pi; - ip = script->insn; - limit = script->insn + script->count; - next_insn = *ip; - c->abi_marker = script->abi_marker; - - while (ip++ < limit) - { - opc = next_insn.opc; - dst = next_insn.dst; - val = next_insn.val; - next_insn = *ip; - - /* This is by far the most common operation: */ - if (likely (opc == IA64_INSN_MOVE_STACKED)) - { - if ((ret = ia64_get_stacked (c, val, &loc, NULL)) < 0) - return ret; - } - else - switch (opc) - { - case IA64_INSN_INC_PSP: - c->psp += val; - continue; - - case IA64_INSN_LOAD_PSP: - if ((ret = ia64_get (c, c->loc[IA64_REG_PSP], &c->psp)) < 0) - return ret; - continue; - - case IA64_INSN_ADD_PSP: - loc = IA64_LOC_ADDR (c->psp + val, (val & IA64_LOC_TYPE_FP)); - break; - - case IA64_INSN_ADD_SP: - loc = IA64_LOC_ADDR (c->sp + val, (val & IA64_LOC_TYPE_FP)); - break; - - case IA64_INSN_MOVE_NO_NAT: - set_nat_info (c, dst, IA64_NULL_LOC, 0); - case IA64_INSN_MOVE: - loc = c->loc[val]; - break; - - case IA64_INSN_MOVE_SCRATCH_NO_NAT: - set_nat_info (c, dst, IA64_NULL_LOC, 0); - case IA64_INSN_MOVE_SCRATCH: - loc = ia64_scratch_loc (c, val, NULL); - break; - - case IA64_INSN_ADD_PSP_NAT: - loc = IA64_LOC_ADDR (c->psp + val, 0); - assert (!IA64_IS_REG_LOC (loc)); - set_nat_info (c, dst, - c->loc[IA64_REG_PRI_UNAT_MEM], - ia64_unat_slot_num (IA64_GET_ADDR (loc))); - break; - - case IA64_INSN_ADD_SP_NAT: - loc = IA64_LOC_ADDR (c->sp + val, 0); - assert (!IA64_IS_REG_LOC (loc)); - set_nat_info (c, dst, - c->loc[IA64_REG_PRI_UNAT_MEM], - ia64_unat_slot_num (IA64_GET_ADDR (loc))); - break; - - case IA64_INSN_MOVE_NAT: - loc = c->loc[val]; - set_nat_info (c, dst, - c->loc[val - IA64_REG_R4 + IA64_REG_NAT4], - c->nat_bitnr[val - IA64_REG_R4]); - break; - - case IA64_INSN_MOVE_STACKED_NAT: - if ((ret = ia64_get_stacked (c, val, &loc, &nat_loc)) < 0) - return ret; - assert (!IA64_IS_REG_LOC (loc)); - set_nat_info (c, dst, nat_loc, rse_slot_num (IA64_GET_ADDR (loc))); - break; - - case IA64_INSN_MOVE_SCRATCH_NAT: - loc = ia64_scratch_loc (c, val, NULL); - nat_loc = ia64_scratch_loc (c, val + (UNW_IA64_NAT - UNW_IA64_GR), - &nat_bitnr); - set_nat_info (c, dst, nat_loc, nat_bitnr); - break; - } - c->loc[dst] = loc; - } - return 0; -} - -static int -uncached_find_save_locs (struct cursor *c) -{ - struct ia64_script script; - int ret = 0; - - if ((ret = ia64_fetch_proc_info (c, c->ip, 1)) < 0) - return ret; - - script_init (&script, c->ip); - if ((ret = build_script (c, &script)) < 0) - { - if (ret != -UNW_ESTOPUNWIND) - Dprintf ("%s: failed to build unwind script for ip %lx\n", - __FUNCTION__, (long) c->ip); - return ret; - } - return run_script (&script, c); -} - -HIDDEN int -ia64_find_save_locs (struct cursor *c) -{ - struct ia64_script_cache *cache = NULL; - struct ia64_script *script = NULL; - intrmask_t saved_mask; - int ret = 0; - - if (c->as->caching_policy == UNW_CACHE_NONE) - return uncached_find_save_locs (c); - - cache = get_script_cache (c->as, &saved_mask); - if (!cache) - { - Debug (1, "contention on script-cache; doing uncached lookup\n"); - return uncached_find_save_locs (c); - } - { - script = script_lookup (cache, c); - Debug (8, "ip %lx %s in script cache\n", (long) c->ip, - script ? "hit" : "missed"); - - if (!script || (script->count == 0 && !script->pi.unwind_info)) - { - if ((ret = ia64_fetch_proc_info (c, c->ip, 1)) < 0) - goto out; - } - - if (!script) - { - script = script_new (cache, c->ip); - if (!script) - { - Dprintf ("%s: failed to create unwind script\n", __FUNCTION__); - ret = -UNW_EUNSPEC; - goto out; - } - } - cache->buckets[c->prev_script].hint = script - cache->buckets; - - if (script->count == 0) - ret = build_script (c, script); - - assert (script->count > 0); - - c->hint = script->hint; - c->prev_script = script - cache->buckets; - - if (ret < 0) - { - if (ret != -UNW_ESTOPUNWIND) - Dprintf ("%s: failed to locate/build unwind script for ip %lx\n", - __FUNCTION__, (long) c->ip); - goto out; - } - - ret = run_script (script, c); - } - out: - put_script_cache (c->as, cache, &saved_mask); - return ret; -} - -HIDDEN void -ia64_validate_cache (unw_addr_space_t as, void *arg) -{ -#ifndef UNW_REMOTE_ONLY - if (as == unw_local_addr_space && ia64_local_validate_cache (as, arg) == 1) - return; -#endif - -#ifndef UNW_LOCAL_ONLY - /* local info is up-to-date, check dynamic info. */ - unwi_dyn_validate_cache (as, arg); -#endif -} - -HIDDEN int -ia64_cache_proc_info (struct cursor *c) -{ - struct ia64_script_cache *cache; - struct ia64_script *script; - intrmask_t saved_mask; - int ret = 0; - - cache = get_script_cache (c->as, &saved_mask); - if (!cache) - return ret; /* cache is busy */ - - /* Re-check to see if a cache entry has been added in the meantime: */ - script = script_lookup (cache, c); - if (script) - goto out; - - script = script_new (cache, c->ip); - if (!script) - { - Dprintf ("%s: failed to create unwind script\n", __FUNCTION__); - ret = -UNW_EUNSPEC; - goto out; - } - - script->pi = c->pi; - - out: - put_script_cache (c->as, cache, &saved_mask); - return ret; -} - -HIDDEN int -ia64_get_cached_proc_info (struct cursor *c) -{ - struct ia64_script_cache *cache; - struct ia64_script *script; - intrmask_t saved_mask; - - cache = get_script_cache (c->as, &saved_mask); - if (!cache) - return -UNW_ENOINFO; /* cache is busy */ - { - script = script_lookup (cache, c); - if (script) - c->pi = script->pi; - } - put_script_cache (c->as, cache, &saved_mask); - return script ? 0 : -UNW_ENOINFO; -} diff --git a/src/pal/src/libunwind/src/ia64/Gstep.c b/src/pal/src/libunwind/src/ia64/Gstep.c deleted file mode 100644 index df4ecb879..000000000 --- a/src/pal/src/libunwind/src/ia64/Gstep.c +++ /dev/null @@ -1,359 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2001-2005 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include "offsets.h" -#include "unwind_i.h" - -static inline int -linux_sigtramp (struct cursor *c, ia64_loc_t prev_cfm_loc, - unw_word_t *num_regsp) -{ -#if defined(UNW_LOCAL_ONLY) && !defined(__linux) - return -UNW_EINVAL; -#else - unw_word_t sc_addr; - int ret; - - if ((ret = ia64_get (c, IA64_LOC_ADDR (c->sp + 0x10 - + LINUX_SIGFRAME_ARG2_OFF, 0), - &sc_addr)) < 0) - return ret; - - c->sigcontext_addr = sc_addr; - - if (!IA64_IS_REG_LOC (c->loc[IA64_REG_IP]) - && IA64_GET_ADDR (c->loc[IA64_REG_IP]) == sc_addr + LINUX_SC_BR_OFF + 8) - { - /* Linux kernels before 2.4.19 and 2.5.10 had buggy - unwind info for sigtramp. Fix it up here. */ - c->loc[IA64_REG_IP] = IA64_LOC_ADDR (sc_addr + LINUX_SC_IP_OFF, 0); - c->cfm_loc = IA64_LOC_ADDR (sc_addr + LINUX_SC_CFM_OFF, 0); - } - - /* do what can't be described by unwind directives: */ - c->loc[IA64_REG_PFS] = IA64_LOC_ADDR (sc_addr + LINUX_SC_AR_PFS_OFF, 0); - c->ec_loc = prev_cfm_loc; - *num_regsp = c->cfm & 0x7f; /* size of frame */ - return 0; -#endif -} - -static inline int -linux_interrupt (struct cursor *c, ia64_loc_t prev_cfm_loc, - unw_word_t *num_regsp, int marker) -{ -#if defined(UNW_LOCAL_ONLY) && !(defined(__linux) && defined(__KERNEL__)) - return -UNW_EINVAL; -#else - unw_word_t sc_addr, num_regs; - ia64_loc_t pfs_loc; - - sc_addr = c->sigcontext_addr = c->sp + 0x10; - - if ((c->pr & (1UL << LINUX_PT_P_NONSYS)) != 0) - num_regs = c->cfm & 0x7f; - else - num_regs = 0; - - /* do what can't be described by unwind directives: */ - if (marker == ABI_MARKER_OLD_LINUX_INTERRUPT) - pfs_loc = IA64_LOC_ADDR (sc_addr + LINUX_OLD_PT_PFS_OFF, 0); - else - pfs_loc = IA64_LOC_ADDR (sc_addr + LINUX_PT_PFS_OFF, 0); - c->loc[IA64_REG_PFS] = pfs_loc; - c->ec_loc = prev_cfm_loc; - *num_regsp = num_regs; /* size of frame */ - return 0; -#endif -} - -static inline int -hpux_sigtramp (struct cursor *c, ia64_loc_t prev_cfm_loc, - unw_word_t *num_regsp) -{ -#if defined(UNW_LOCAL_ONLY) && !defined(__hpux) - return -UNW_EINVAL; -#else - unw_word_t sc_addr, bsp, bspstore; - ia64_loc_t sc_loc; - int ret, i; - - /* HP-UX passes the address of ucontext_t in r32: */ - if ((ret = ia64_get_stacked (c, 32, &sc_loc, NULL)) < 0) - return ret; - if ((ret = ia64_get (c, sc_loc, &sc_addr)) < 0) - return ret; - - c->sigcontext_addr = sc_addr; - - /* Now mark all (preserved) registers as coming from the - signal context: */ - c->cfm_loc = IA64_LOC_UC_REG (UNW_IA64_CFM, sc_addr); - c->loc[IA64_REG_PRI_UNAT_MEM] = IA64_NULL_LOC; - c->loc[IA64_REG_PSP] = IA64_LOC_UC_REG (UNW_IA64_GR + 12, sc_addr); - c->loc[IA64_REG_BSP] = IA64_LOC_UC_REG (UNW_IA64_AR_BSP, sc_addr); - c->loc[IA64_REG_BSPSTORE] = IA64_LOC_UC_REG (UNW_IA64_AR_BSPSTORE, sc_addr); - c->loc[IA64_REG_PFS] = IA64_LOC_UC_REG (UNW_IA64_AR_PFS, sc_addr); - c->loc[IA64_REG_RNAT] = IA64_LOC_UC_REG (UNW_IA64_AR_RNAT, sc_addr); - c->loc[IA64_REG_IP] = IA64_LOC_UC_REG (UNW_IA64_IP, sc_addr); - c->loc[IA64_REG_R4] = IA64_LOC_UC_REG (UNW_IA64_GR + 4, sc_addr); - c->loc[IA64_REG_R5] = IA64_LOC_UC_REG (UNW_IA64_GR + 5, sc_addr); - c->loc[IA64_REG_R6] = IA64_LOC_UC_REG (UNW_IA64_GR + 6, sc_addr); - c->loc[IA64_REG_R7] = IA64_LOC_UC_REG (UNW_IA64_GR + 7, sc_addr); - c->loc[IA64_REG_NAT4] = IA64_LOC_UC_REG (UNW_IA64_NAT + 4, sc_addr); - c->loc[IA64_REG_NAT5] = IA64_LOC_UC_REG (UNW_IA64_NAT + 5, sc_addr); - c->loc[IA64_REG_NAT6] = IA64_LOC_UC_REG (UNW_IA64_NAT + 6, sc_addr); - c->loc[IA64_REG_NAT7] = IA64_LOC_UC_REG (UNW_IA64_NAT + 7, sc_addr); - c->loc[IA64_REG_UNAT] = IA64_LOC_UC_REG (UNW_IA64_AR_UNAT, sc_addr); - c->loc[IA64_REG_PR] = IA64_LOC_UC_REG (UNW_IA64_PR, sc_addr); - c->loc[IA64_REG_LC] = IA64_LOC_UC_REG (UNW_IA64_AR_LC, sc_addr); - c->loc[IA64_REG_FPSR] = IA64_LOC_UC_REG (UNW_IA64_AR_FPSR, sc_addr); - c->loc[IA64_REG_B1] = IA64_LOC_UC_REG (UNW_IA64_BR + 1, sc_addr); - c->loc[IA64_REG_B2] = IA64_LOC_UC_REG (UNW_IA64_BR + 2, sc_addr); - c->loc[IA64_REG_B3] = IA64_LOC_UC_REG (UNW_IA64_BR + 3, sc_addr); - c->loc[IA64_REG_B4] = IA64_LOC_UC_REG (UNW_IA64_BR + 4, sc_addr); - c->loc[IA64_REG_B5] = IA64_LOC_UC_REG (UNW_IA64_BR + 5, sc_addr); - c->loc[IA64_REG_F2] = IA64_LOC_UC_REG (UNW_IA64_FR + 2, sc_addr); - c->loc[IA64_REG_F3] = IA64_LOC_UC_REG (UNW_IA64_FR + 3, sc_addr); - c->loc[IA64_REG_F4] = IA64_LOC_UC_REG (UNW_IA64_FR + 4, sc_addr); - c->loc[IA64_REG_F5] = IA64_LOC_UC_REG (UNW_IA64_FR + 5, sc_addr); - for (i = 0; i < 16; ++i) - c->loc[IA64_REG_F16 + i] = IA64_LOC_UC_REG (UNW_IA64_FR + 16 + i, sc_addr); - - c->pi.flags |= UNW_PI_FLAG_IA64_RBS_SWITCH; - - /* update the CFM cache: */ - if ((ret = ia64_get (c, c->cfm_loc, &c->cfm)) < 0) - return ret; - /* update the PSP cache: */ - if ((ret = ia64_get (c, c->loc[IA64_REG_PSP], &c->psp)) < 0) - return ret; - - if ((ret = ia64_get (c, c->loc[IA64_REG_BSP], &bsp)) < 0 - || (ret = ia64_get (c, c->loc[IA64_REG_BSPSTORE], &bspstore)) < 0) - return ret; - if (bspstore < bsp) - /* Dirty partition got spilled into the ucontext_t structure - itself. We'll need to access it via uc_access(3). */ - rbs_switch (c, bsp, bspstore, IA64_LOC_UC_ADDR (bsp | 0x1f8, 0)); - - c->ec_loc = prev_cfm_loc; - - *num_regsp = 0; - return 0; -#endif -} - - -static inline int -check_rbs_switch (struct cursor *c) -{ - unw_word_t saved_bsp, saved_bspstore, loadrs, ndirty; - int ret = 0; - - saved_bsp = c->bsp; - if (c->pi.flags & UNW_PI_FLAG_IA64_RBS_SWITCH) - { - /* Got ourselves a frame that has saved ar.bspstore, ar.bsp, - and ar.rnat, so we're all set for rbs-switching: */ - if ((ret = ia64_get (c, c->loc[IA64_REG_BSP], &saved_bsp)) < 0 - || (ret = ia64_get (c, c->loc[IA64_REG_BSPSTORE], &saved_bspstore))) - return ret; - } - else if ((c->abi_marker == ABI_MARKER_LINUX_SIGTRAMP - || c->abi_marker == ABI_MARKER_OLD_LINUX_SIGTRAMP) - && !IA64_IS_REG_LOC (c->loc[IA64_REG_BSP]) - && (IA64_GET_ADDR (c->loc[IA64_REG_BSP]) - == c->sigcontext_addr + LINUX_SC_AR_BSP_OFF)) - { - /* When Linux delivers a signal on an alternate stack, it - does things a bit differently from what the unwind - conventions allow us to describe: instead of saving - ar.rnat, ar.bsp, and ar.bspstore, it saves the former two - plus the "loadrs" value. Because of this, we need to - detect & record a potential rbs-area switch - manually... */ - - /* If ar.bsp has been saved already AND the current bsp is - not equal to the saved value, then we know for sure that - we're past the point where the backing store has been - switched (and before the point where it's restored). */ - if ((ret = ia64_get (c, IA64_LOC_ADDR (c->sigcontext_addr - + LINUX_SC_AR_BSP_OFF, 0), - &saved_bsp) < 0) - || (ret = ia64_get (c, IA64_LOC_ADDR (c->sigcontext_addr - + LINUX_SC_LOADRS_OFF, 0), - &loadrs) < 0)) - return ret; - loadrs >>= 16; - ndirty = rse_num_regs (c->bsp - loadrs, c->bsp); - saved_bspstore = rse_skip_regs (saved_bsp, -ndirty); - } - - if (saved_bsp == c->bsp) - return 0; - - return rbs_switch (c, saved_bsp, saved_bspstore, c->loc[IA64_REG_RNAT]); -} - -static inline int -update_frame_state (struct cursor *c) -{ - unw_word_t prev_ip, prev_sp, prev_bsp, ip, num_regs; - ia64_loc_t prev_cfm_loc; - int ret; - - prev_cfm_loc = c->cfm_loc; - prev_ip = c->ip; - prev_sp = c->sp; - prev_bsp = c->bsp; - - /* Update the IP cache (do this first: if we reach the end of the - frame-chain, the rest of the info may not be valid/useful - anymore. */ - ret = ia64_get (c, c->loc[IA64_REG_IP], &ip); - if (ret < 0) - return ret; - c->ip = ip; - - if ((ip & 0xc) != 0) - { - /* don't let obviously bad addresses pollute the cache */ - Debug (1, "rejecting bad ip=0x%lx\n", (long) c->ip); - return -UNW_EINVALIDIP; - } - - c->cfm_loc = c->loc[IA64_REG_PFS]; - /* update the CFM cache: */ - ret = ia64_get (c, c->cfm_loc, &c->cfm); - if (ret < 0) - return ret; - - /* Normally, AR.EC is stored in the CFM save-location. That - save-location contains the full function-state as defined by - AR.PFS. However, interruptions only save the frame-marker, not - any other info in CFM. Instead, AR.EC gets saved on the first - call by the interruption-handler. Thus, interruption-related - frames need to track the _previous_ CFM save-location since - that's were AR.EC is saved. We support this by setting ec_loc to - cfm_loc by default and giving frames marked with an ABI-marker - the chance to override this value with prev_cfm_loc. */ - c->ec_loc = c->cfm_loc; - - num_regs = 0; - if (unlikely (c->abi_marker)) - { - c->last_abi_marker = c->abi_marker; - switch (ia64_get_abi_marker (c)) - { - case ABI_MARKER_LINUX_SIGTRAMP: - case ABI_MARKER_OLD_LINUX_SIGTRAMP: - ia64_set_abi (c, ABI_LINUX); - if ((ret = linux_sigtramp (c, prev_cfm_loc, &num_regs)) < 0) - return ret; - break; - - case ABI_MARKER_OLD_LINUX_INTERRUPT: - case ABI_MARKER_LINUX_INTERRUPT: - ia64_set_abi (c, ABI_LINUX); - if ((ret = linux_interrupt (c, prev_cfm_loc, &num_regs, - c->abi_marker)) < 0) - return ret; - break; - - case ABI_MARKER_HP_UX_SIGTRAMP: - ia64_set_abi (c, ABI_HPUX); - if ((ret = hpux_sigtramp (c, prev_cfm_loc, &num_regs)) < 0) - return ret; - break; - - default: - Debug (1, "unknown ABI marker: ABI=%u, context=%u\n", - c->abi_marker >> 8, c->abi_marker & 0xff); - return -UNW_EINVAL; - } - Debug (12, "sigcontext_addr=%lx (ret=%d)\n", - (unsigned long) c->sigcontext_addr, ret); - - c->sigcontext_off = c->sigcontext_addr - c->sp; - - /* update the IP cache: */ - if ((ret = ia64_get (c, c->loc[IA64_REG_IP], &ip)) < 0) - return ret; - c->ip = ip; - if (ip == 0) - /* end of frame-chain reached */ - return 0; - } - else - num_regs = (c->cfm >> 7) & 0x7f; /* size of locals */ - - if (!IA64_IS_NULL_LOC (c->loc[IA64_REG_BSP])) - { - ret = check_rbs_switch (c); - if (ret < 0) - return ret; - } - - c->bsp = rse_skip_regs (c->bsp, -num_regs); - - c->sp = c->psp; - c->abi_marker = 0; - - if (c->ip == prev_ip && c->sp == prev_sp && c->bsp == prev_bsp) - { - Dprintf ("%s: ip, sp, and bsp unchanged; stopping here (ip=0x%lx)\n", - __FUNCTION__, (long) ip); - return -UNW_EBADFRAME; - } - - /* as we unwind, the saved ar.unat becomes the primary unat: */ - c->loc[IA64_REG_PRI_UNAT_MEM] = c->loc[IA64_REG_UNAT]; - - /* restore the predicates: */ - ret = ia64_get (c, c->loc[IA64_REG_PR], &c->pr); - if (ret < 0) - return ret; - - c->pi_valid = 0; - return 0; -} - - -int -unw_step (unw_cursor_t *cursor) -{ - struct cursor *c = (struct cursor *) cursor; - int ret; - - Debug (1, "(cursor=%p, ip=0x%016lx)\n", c, (unsigned long) c->ip); - - if ((ret = ia64_find_save_locs (c)) >= 0 - && (ret = update_frame_state (c)) >= 0) - ret = (c->ip == 0) ? 0 : 1; - - Debug (2, "returning %d (ip=0x%016lx)\n", ret, (unsigned long) c->ip); - return ret; -} diff --git a/src/pal/src/libunwind/src/ia64/Gtables.c b/src/pal/src/libunwind/src/ia64/Gtables.c deleted file mode 100644 index f5e8f2d8f..000000000 --- a/src/pal/src/libunwind/src/ia64/Gtables.c +++ /dev/null @@ -1,731 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (c) 2001-2005 Hewlett-Packard Development Company, L.P. - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include -#include -#include - -#include "unwind_i.h" - -#ifdef HAVE_IA64INTRIN_H -# include -#endif - -extern unw_addr_space_t _ULia64_local_addr_space; - -struct ia64_table_entry - { - uint64_t start_offset; - uint64_t end_offset; - uint64_t info_offset; - }; - -#ifdef UNW_LOCAL_ONLY - -static inline int -is_local_addr_space (unw_addr_space_t as) -{ - return 1; -} - -static inline int -read_mem (unw_addr_space_t as, unw_word_t addr, unw_word_t *valp, void *arg) -{ - *valp = *(unw_word_t *) addr; - return 0; -} - -#else /* !UNW_LOCAL_ONLY */ - -static inline int -is_local_addr_space (unw_addr_space_t as) -{ - return as == unw_local_addr_space; -} - -static inline int -read_mem (unw_addr_space_t as, unw_word_t addr, unw_word_t *valp, void *arg) -{ - unw_accessors_t *a = unw_get_accessors_int (as); - - return (*a->access_mem) (as, addr, valp, 0, arg); -} - -/* Helper macro for reading an ia64_table_entry from remote memory. */ -#define remote_read(addr, member) \ - (*a->access_mem) (as, (addr) + offsetof (struct ia64_table_entry, \ - member), &member, 0, arg) - -/* Lookup an unwind-table entry in remote memory. Returns 1 if an - entry is found, 0 if no entry is found, negative if an error - occurred reading remote memory. */ -static int -remote_lookup (unw_addr_space_t as, - unw_word_t table, size_t table_size, unw_word_t rel_ip, - struct ia64_table_entry *e, void *arg) -{ - unw_word_t e_addr = 0, start_offset, end_offset, info_offset; - unw_accessors_t *a = unw_get_accessors_int (as); - unsigned long lo, hi, mid; - int ret; - - /* do a binary search for right entry: */ - for (lo = 0, hi = table_size / sizeof (struct ia64_table_entry); lo < hi;) - { - mid = (lo + hi) / 2; - e_addr = table + mid * sizeof (struct ia64_table_entry); - if ((ret = remote_read (e_addr, start_offset)) < 0) - return ret; - - if (rel_ip < start_offset) - hi = mid; - else - { - if ((ret = remote_read (e_addr, end_offset)) < 0) - return ret; - - if (rel_ip >= end_offset) - lo = mid + 1; - else - break; - } - } - if (rel_ip < start_offset || rel_ip >= end_offset) - return 0; - e->start_offset = start_offset; - e->end_offset = end_offset; - - if ((ret = remote_read (e_addr, info_offset)) < 0) - return ret; - e->info_offset = info_offset; - return 1; -} - -HIDDEN void -tdep_put_unwind_info (unw_addr_space_t as, unw_proc_info_t *pi, void *arg) -{ - if (!pi->unwind_info) - return; - - if (is_local_addr_space (as)) - { - free (pi->unwind_info); - pi->unwind_info = NULL; - } -} - -unw_word_t -_Uia64_find_dyn_list (unw_addr_space_t as, unw_dyn_info_t *di, void *arg) -{ - unw_word_t hdr_addr, info_addr, hdr, directives, pers, cookie, off; - unw_word_t start_offset, end_offset, info_offset, segbase; - struct ia64_table_entry *e; - size_t table_size; - unw_word_t gp = di->gp; - int ret; - - switch (di->format) - { - case UNW_INFO_FORMAT_DYNAMIC: - default: - return 0; - - case UNW_INFO_FORMAT_TABLE: - e = (struct ia64_table_entry *) di->u.ti.table_data; - table_size = di->u.ti.table_len * sizeof (di->u.ti.table_data[0]); - segbase = di->u.ti.segbase; - if (table_size < sizeof (struct ia64_table_entry)) - return 0; - start_offset = e[0].start_offset; - end_offset = e[0].end_offset; - info_offset = e[0].info_offset; - break; - - case UNW_INFO_FORMAT_REMOTE_TABLE: - { - unw_accessors_t *a = unw_get_accessors_int (as); - unw_word_t e_addr = di->u.rti.table_data; - - table_size = di->u.rti.table_len * sizeof (unw_word_t); - segbase = di->u.rti.segbase; - if (table_size < sizeof (struct ia64_table_entry)) - return 0; - - if ( (ret = remote_read (e_addr, start_offset) < 0) - || (ret = remote_read (e_addr, end_offset) < 0) - || (ret = remote_read (e_addr, info_offset) < 0)) - return ret; - } - break; - } - - if (start_offset != end_offset) - /* dyn-list entry cover a zero-length "procedure" and should be - first entry (note: technically a binary could contain code - below the segment base, but this doesn't happen for normal - binaries and certainly doesn't happen when libunwind is a - separate shared object. For weird cases, the application may - have to provide its own (slower) version of this routine. */ - return 0; - - hdr_addr = info_offset + segbase; - info_addr = hdr_addr + 8; - - /* read the header word: */ - if ((ret = read_mem (as, hdr_addr, &hdr, arg)) < 0) - return ret; - - if (IA64_UNW_VER (hdr) != 1 - || IA64_UNW_FLAG_EHANDLER (hdr) || IA64_UNW_FLAG_UHANDLER (hdr)) - /* dyn-list entry must be version 1 and doesn't have ehandler - or uhandler */ - return 0; - - if (IA64_UNW_LENGTH (hdr) != 1) - /* dyn-list entry must consist of a single word of NOP directives */ - return 0; - - if ( ((ret = read_mem (as, info_addr, &directives, arg)) < 0) - || ((ret = read_mem (as, info_addr + 0x08, &pers, arg)) < 0) - || ((ret = read_mem (as, info_addr + 0x10, &cookie, arg)) < 0) - || ((ret = read_mem (as, info_addr + 0x18, &off, arg)) < 0)) - return 0; - - if (directives != 0 || pers != 0 - || (!as->big_endian && cookie != 0x7473696c2d6e7964ULL) - || ( as->big_endian && cookie != 0x64796e2d6c697374ULL)) - return 0; - - /* OK, we ran the gauntlet and found it: */ - return off + gp; -} - -#endif /* !UNW_LOCAL_ONLY */ - -static inline const struct ia64_table_entry * -lookup (struct ia64_table_entry *table, size_t table_size, unw_word_t rel_ip) -{ - const struct ia64_table_entry *e = 0; - unsigned long lo, hi, mid; - - /* do a binary search for right entry: */ - for (lo = 0, hi = table_size / sizeof (struct ia64_table_entry); lo < hi;) - { - mid = (lo + hi) / 2; - e = table + mid; - if (rel_ip < e->start_offset) - hi = mid; - else if (rel_ip >= e->end_offset) - lo = mid + 1; - else - break; - } - if (rel_ip < e->start_offset || rel_ip >= e->end_offset) - return NULL; - return e; -} - -int -unw_search_ia64_unwind_table (unw_addr_space_t as, unw_word_t ip, - unw_dyn_info_t *di, unw_proc_info_t *pi, - int need_unwind_info, void *arg) -{ - unw_word_t addr, hdr_addr, info_addr, info_end_addr, hdr, *wp; - const struct ia64_table_entry *e = NULL; - unw_word_t handler_offset, segbase = 0; - int ret, is_local; -#ifndef UNW_LOCAL_ONLY - struct ia64_table_entry ent; -#endif - - assert ((di->format == UNW_INFO_FORMAT_TABLE - || di->format == UNW_INFO_FORMAT_REMOTE_TABLE) - && (ip >= di->start_ip && ip < di->end_ip)); - - pi->flags = 0; - pi->unwind_info = 0; - pi->handler = 0; - - if (likely (di->format == UNW_INFO_FORMAT_TABLE)) - { - segbase = di->u.ti.segbase; - e = lookup ((struct ia64_table_entry *) di->u.ti.table_data, - di->u.ti.table_len * sizeof (unw_word_t), - ip - segbase); - } -#ifndef UNW_LOCAL_ONLY - else - { - segbase = di->u.rti.segbase; - if ((ret = remote_lookup (as, di->u.rti.table_data, - di->u.rti.table_len * sizeof (unw_word_t), - ip - segbase, &ent, arg)) < 0) - return ret; - if (ret) - e = &ent; - } -#endif - if (!e) - { - /* IP is inside this table's range, but there is no explicit - unwind info => use default conventions (i.e., this is NOT an - error). */ - memset (pi, 0, sizeof (*pi)); - pi->start_ip = 0; - pi->end_ip = 0; - pi->gp = di->gp; - pi->lsda = 0; - return 0; - } - - pi->start_ip = e->start_offset + segbase; - pi->end_ip = e->end_offset + segbase; - - hdr_addr = e->info_offset + segbase; - info_addr = hdr_addr + 8; - - /* Read the header word. Note: the actual unwind-info is always - assumed to reside in memory, independent of whether di->format is - UNW_INFO_FORMAT_TABLE or UNW_INFO_FORMAT_REMOTE_TABLE. */ - - if ((ret = read_mem (as, hdr_addr, &hdr, arg)) < 0) - return ret; - - if (IA64_UNW_VER (hdr) != 1) - { - Debug (1, "Unknown header version %ld (hdr word=0x%lx @ 0x%lx)\n", - IA64_UNW_VER (hdr), (unsigned long) hdr, - (unsigned long) hdr_addr); - return -UNW_EBADVERSION; - } - - info_end_addr = info_addr + 8 * IA64_UNW_LENGTH (hdr); - - is_local = is_local_addr_space (as); - - /* If we must have the unwind-info, return it. Also, if we are in - the local address-space, return the unwind-info because it's so - cheap to do so and it may come in handy later on. */ - if (need_unwind_info || is_local) - { - pi->unwind_info_size = 8 * IA64_UNW_LENGTH (hdr); - - if (is_local) - pi->unwind_info = (void *) (uintptr_t) info_addr; - else - { - /* Internalize unwind info. Note: since we're doing this - only for non-local address spaces, there is no - signal-safety issue and it is OK to use malloc()/free(). */ - pi->unwind_info = malloc (8 * IA64_UNW_LENGTH (hdr)); - if (!pi->unwind_info) - return -UNW_ENOMEM; - - wp = (unw_word_t *) pi->unwind_info; - for (addr = info_addr; addr < info_end_addr; addr += 8, ++wp) - { - if ((ret = read_mem (as, addr, wp, arg)) < 0) - { - free (pi->unwind_info); - return ret; - } - } - } - } - - if (IA64_UNW_FLAG_EHANDLER (hdr) || IA64_UNW_FLAG_UHANDLER (hdr)) - { - /* read the personality routine address (address is gp-relative): */ - if ((ret = read_mem (as, info_end_addr, &handler_offset, arg)) < 0) - return ret; - Debug (4, "handler ptr @ offset=%lx, gp=%lx\n", handler_offset, di->gp); - if ((read_mem (as, handler_offset + di->gp, &pi->handler, arg)) < 0) - return ret; - } - pi->lsda = info_end_addr + 8; - pi->gp = di->gp; - pi->format = di->format; - return 0; -} - -#ifndef UNW_REMOTE_ONLY - -# if defined(HAVE_DL_ITERATE_PHDR) -# include -# include - -# if __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 2) \ - || (__GLIBC__ == 2 && __GLIBC_MINOR__ == 2 && !defined(DT_CONFIG)) -# error You need GLIBC 2.2.4 or later on IA-64 Linux -# endif - -# if defined(HAVE_GETUNWIND) - extern unsigned long getunwind (void *buf, size_t len); -# else /* HAVE_GETUNWIND */ -# include -# include -# ifndef __NR_getunwind -# define __NR_getunwind 1215 -# endif - -static unsigned long -getunwind (void *buf, size_t len) -{ - return syscall (SYS_getunwind, buf, len); -} - -# endif /* HAVE_GETUNWIND */ - -static unw_dyn_info_t kernel_table; - -static int -get_kernel_table (unw_dyn_info_t *di) -{ - struct ia64_table_entry *ktab, *etab; - size_t size; - - Debug (16, "getting kernel table"); - - size = getunwind (NULL, 0); - ktab = sos_alloc (size); - if (!ktab) - { - Dprintf (__FILE__".%s: failed to allocate %zu bytes", - __FUNCTION__, size); - return -UNW_ENOMEM; - } - getunwind (ktab, size); - - /* Determine length of kernel's unwind table & relocate its entries. */ - for (etab = ktab; etab->start_offset; ++etab) - etab->info_offset += (uint64_t) ktab; - - di->format = UNW_INFO_FORMAT_TABLE; - di->gp = 0; - di->start_ip = ktab[0].start_offset; - di->end_ip = etab[-1].end_offset; - di->u.ti.name_ptr = (unw_word_t) ""; - di->u.ti.segbase = 0; - di->u.ti.table_len = ((char *) etab - (char *) ktab) / sizeof (unw_word_t); - di->u.ti.table_data = (unw_word_t *) ktab; - - Debug (16, "found table `%s': [%lx-%lx) segbase=%lx len=%lu\n", - (char *) di->u.ti.name_ptr, di->start_ip, di->end_ip, - di->u.ti.segbase, di->u.ti.table_len); - return 0; -} - -# ifndef UNW_LOCAL_ONLY - -/* This is exported for the benefit of libunwind-ptrace.a. */ -int -_Uia64_get_kernel_table (unw_dyn_info_t *di) -{ - int ret; - - if (!kernel_table.u.ti.table_data) - if ((ret = get_kernel_table (&kernel_table)) < 0) - return ret; - - memcpy (di, &kernel_table, sizeof (*di)); - return 0; -} - -# endif /* !UNW_LOCAL_ONLY */ - -static inline unsigned long -current_gp (void) -{ -# if defined(__GNUC__) && !defined(__INTEL_COMPILER) - register unsigned long gp __asm__("gp"); - return gp; -# elif HAVE_IA64INTRIN_H - return __getReg (_IA64_REG_GP); -# else -# error Implement me. -# endif -} - -static int -callback (struct dl_phdr_info *info, size_t size, void *ptr) -{ - unw_dyn_info_t *di = ptr; - const Elf64_Phdr *phdr, *p_unwind, *p_dynamic, *p_text; - long n; - Elf64_Addr load_base, segbase = 0; - - /* Make sure struct dl_phdr_info is at least as big as we need. */ - if (size < offsetof (struct dl_phdr_info, dlpi_phnum) - + sizeof (info->dlpi_phnum)) - return -1; - - Debug (16, "checking `%s' (load_base=%lx)\n", - info->dlpi_name, info->dlpi_addr); - - phdr = info->dlpi_phdr; - load_base = info->dlpi_addr; - p_text = NULL; - p_unwind = NULL; - p_dynamic = NULL; - - /* See if PC falls into one of the loaded segments. Find the unwind - segment at the same time. */ - for (n = info->dlpi_phnum; --n >= 0; phdr++) - { - if (phdr->p_type == PT_LOAD) - { - Elf64_Addr vaddr = phdr->p_vaddr + load_base; - if (di->u.ti.segbase >= vaddr - && di->u.ti.segbase < vaddr + phdr->p_memsz) - p_text = phdr; - } - else if (phdr->p_type == PT_IA_64_UNWIND) - p_unwind = phdr; - else if (phdr->p_type == PT_DYNAMIC) - p_dynamic = phdr; - } - if (!p_text || !p_unwind) - return 0; - - if (likely (p_unwind->p_vaddr >= p_text->p_vaddr - && p_unwind->p_vaddr < p_text->p_vaddr + p_text->p_memsz)) - /* normal case: unwind table is inside text segment */ - segbase = p_text->p_vaddr + load_base; - else - { - /* Special case: unwind table is in some other segment; this - happens for the Linux kernel's gate DSO, for example. */ - phdr = info->dlpi_phdr; - for (n = info->dlpi_phnum; --n >= 0; phdr++) - { - if (phdr->p_type == PT_LOAD && p_unwind->p_vaddr >= phdr->p_vaddr - && p_unwind->p_vaddr < phdr->p_vaddr + phdr->p_memsz) - { - segbase = phdr->p_vaddr + load_base; - break; - } - } - } - - if (p_dynamic) - { - /* For dynamicly linked executables and shared libraries, - DT_PLTGOT is the gp value for that object. */ - Elf64_Dyn *dyn = (Elf64_Dyn *)(p_dynamic->p_vaddr + load_base); - for (; dyn->d_tag != DT_NULL; ++dyn) - if (dyn->d_tag == DT_PLTGOT) - { - /* On IA-64, _DYNAMIC is writable and GLIBC has relocated it. */ - di->gp = dyn->d_un.d_ptr; - break; - } - } - else - /* Otherwise this is a static executable with no _DYNAMIC. - The gp is constant program-wide. */ - di->gp = current_gp(); - di->format = UNW_INFO_FORMAT_TABLE; - di->start_ip = p_text->p_vaddr + load_base; - di->end_ip = p_text->p_vaddr + load_base + p_text->p_memsz; - di->u.ti.name_ptr = (unw_word_t) info->dlpi_name; - di->u.ti.table_data = (void *) (p_unwind->p_vaddr + load_base); - di->u.ti.table_len = p_unwind->p_memsz / sizeof (unw_word_t); - di->u.ti.segbase = segbase; - - Debug (16, "found table `%s': segbase=%lx, len=%lu, gp=%lx, " - "table_data=%p\n", (char *) di->u.ti.name_ptr, di->u.ti.segbase, - di->u.ti.table_len, di->gp, di->u.ti.table_data); - return 1; -} - -# ifdef HAVE_DL_PHDR_REMOVALS_COUNTER - -static inline int -validate_cache (unw_addr_space_t as) -{ - /* Note: we don't need to serialize here with respect to - dl_iterate_phdr() because if somebody were to remove an object - that is required to complete the unwind on whose behalf we're - validating the cache here, we'd be hosed anyhow. What we're - guarding against here is the case where library FOO gets mapped, - unwind info for FOO gets cached, FOO gets unmapped, BAR gets - mapped in the place where FOO was and then we unwind across a - function in FOO. Since no thread can execute in BAR before FOO - has been removed, we are guaranteed that - dl_phdr_removals_counter() would have been incremented before we - get here. */ - unsigned long long removals = dl_phdr_removals_counter (); - - if (removals == as->shared_object_removals) - return 1; - - as->shared_object_removals = removals; - unw_flush_cache (as, 0, 0); - return -1; -} - -# else /* !HAVE_DL_PHDR_REMOVALS_COUNTER */ - -/* Check whether any phdrs have been removed since we last flushed the - cache. If so we flush the cache and return -1, if not, we do - nothing and return 1. */ - -static int -check_callback (struct dl_phdr_info *info, size_t size, void *ptr) -{ -# ifdef HAVE_STRUCT_DL_PHDR_INFO_DLPI_SUBS - unw_addr_space_t as = ptr; - - if (size < - offsetof (struct dl_phdr_info, dlpi_subs) + sizeof (info->dlpi_subs)) - /* It would be safer to flush the cache here, but that would - disable caching for older libc's which would be incompatible - with the behavior of older versions of libunwind so we return 1 - instead and hope nobody runs into stale cache info... */ - return 1; - - if (info->dlpi_subs == as->shared_object_removals) - return 1; - - as->shared_object_removals = info->dlpi_subs; - unw_flush_cache (as, 0, 0); - return -1; /* indicate that there were removals */ -# else - return 1; -# endif -} - -static inline int -validate_cache (unw_addr_space_t as) -{ - intrmask_t saved_mask; - int ret; - - SIGPROCMASK (SIG_SETMASK, &unwi_full_mask, &saved_mask); - ret = dl_iterate_phdr (check_callback, as); - SIGPROCMASK (SIG_SETMASK, &saved_mask, NULL); - return ret; -} - -# endif /* HAVE_DL_PHDR_REMOVALS_COUNTER */ - -# elif defined(HAVE_DLMODINFO) - /* Support for HP-UX-style dlmodinfo() */ -# include - -static inline int -validate_cache (unw_addr_space_t as) -{ - return 1; -} - -# endif /* !HAVE_DLMODINFO */ - -HIDDEN int -tdep_find_proc_info (unw_addr_space_t as, unw_word_t ip, - unw_proc_info_t *pi, int need_unwind_info, void *arg) -{ -# if defined(HAVE_DL_ITERATE_PHDR) - unw_dyn_info_t di, *dip = &di; - intrmask_t saved_mask; - int ret; - - di.u.ti.segbase = ip; /* this is cheap... */ - - SIGPROCMASK (SIG_SETMASK, &unwi_full_mask, &saved_mask); - ret = dl_iterate_phdr (callback, &di); - SIGPROCMASK (SIG_SETMASK, &saved_mask, NULL); - - if (ret <= 0) - { - if (!kernel_table.u.ti.table_data) - { - if ((ret = get_kernel_table (&kernel_table)) < 0) - return ret; - } - if (ip < kernel_table.start_ip || ip >= kernel_table.end_ip) - return -UNW_ENOINFO; - dip = &kernel_table; - } -# elif defined(HAVE_DLMODINFO) -# define UNWIND_TBL_32BIT 0x8000000000000000 - struct load_module_desc lmd; - unw_dyn_info_t di, *dip = &di; - struct unwind_header - { - uint64_t header_version; - uint64_t start_offset; - uint64_t end_offset; - } - *uhdr; - - if (!dlmodinfo (ip, &lmd, sizeof (lmd), NULL, 0, 0)) - return -UNW_ENOINFO; - - di.format = UNW_INFO_FORMAT_TABLE; - di.start_ip = lmd.text_base; - di.end_ip = lmd.text_base + lmd.text_size; - di.gp = lmd.linkage_ptr; - di.u.ti.name_ptr = 0; /* no obvious table-name available */ - di.u.ti.segbase = lmd.text_base; - - uhdr = (struct unwind_header *) lmd.unwind_base; - - if ((uhdr->header_version & ~UNWIND_TBL_32BIT) != 1 - && (uhdr->header_version & ~UNWIND_TBL_32BIT) != 2) - { - Debug (1, "encountered unknown unwind header version %ld\n", - (long) (uhdr->header_version & ~UNWIND_TBL_32BIT)); - return -UNW_EBADVERSION; - } - if (uhdr->header_version & UNWIND_TBL_32BIT) - { - Debug (1, "32-bit unwind tables are not supported yet\n"); - return -UNW_EINVAL; - } - - di.u.ti.table_data = (unw_word_t *) (di.u.ti.segbase + uhdr->start_offset); - di.u.ti.table_len = ((uhdr->end_offset - uhdr->start_offset) - / sizeof (unw_word_t)); - - Debug (16, "found table `%s': segbase=%lx, len=%lu, gp=%lx, " - "table_data=%p\n", (char *) di.u.ti.name_ptr, di.u.ti.segbase, - di.u.ti.table_len, di.gp, di.u.ti.table_data); -# endif - - /* now search the table: */ - return tdep_search_unwind_table (as, ip, dip, pi, need_unwind_info, arg); -} - -/* Returns 1 if the cache is up-to-date or -1 if the cache contained - stale data and had to be flushed. */ - -HIDDEN int -ia64_local_validate_cache (unw_addr_space_t as, void *arg) -{ - return validate_cache (as); -} - -#endif /* !UNW_REMOTE_ONLY */ diff --git a/src/pal/src/libunwind/src/ia64/Lapply_reg_state.c b/src/pal/src/libunwind/src/ia64/Lapply_reg_state.c deleted file mode 100644 index 7ebada480..000000000 --- a/src/pal/src/libunwind/src/ia64/Lapply_reg_state.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gapply_reg_state.c" -#endif diff --git a/src/pal/src/libunwind/src/ia64/Lcreate_addr_space.c b/src/pal/src/libunwind/src/ia64/Lcreate_addr_space.c deleted file mode 100644 index 0f2dc6be9..000000000 --- a/src/pal/src/libunwind/src/ia64/Lcreate_addr_space.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gcreate_addr_space.c" -#endif diff --git a/src/pal/src/libunwind/src/ia64/Lfind_unwind_table.c b/src/pal/src/libunwind/src/ia64/Lfind_unwind_table.c deleted file mode 100644 index 68e269f1d..000000000 --- a/src/pal/src/libunwind/src/ia64/Lfind_unwind_table.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gfind_unwind_table.c" -#endif diff --git a/src/pal/src/libunwind/src/ia64/Lget_proc_info.c b/src/pal/src/libunwind/src/ia64/Lget_proc_info.c deleted file mode 100644 index 69028b019..000000000 --- a/src/pal/src/libunwind/src/ia64/Lget_proc_info.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gget_proc_info.c" -#endif diff --git a/src/pal/src/libunwind/src/ia64/Lget_save_loc.c b/src/pal/src/libunwind/src/ia64/Lget_save_loc.c deleted file mode 100644 index 9ea048a90..000000000 --- a/src/pal/src/libunwind/src/ia64/Lget_save_loc.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gget_save_loc.c" -#endif diff --git a/src/pal/src/libunwind/src/ia64/Lglobal.c b/src/pal/src/libunwind/src/ia64/Lglobal.c deleted file mode 100644 index 6d7b489e1..000000000 --- a/src/pal/src/libunwind/src/ia64/Lglobal.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gglobal.c" -#endif diff --git a/src/pal/src/libunwind/src/ia64/Linit.c b/src/pal/src/libunwind/src/ia64/Linit.c deleted file mode 100644 index e9abfdd46..000000000 --- a/src/pal/src/libunwind/src/ia64/Linit.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Ginit.c" -#endif diff --git a/src/pal/src/libunwind/src/ia64/Linit_local.c b/src/pal/src/libunwind/src/ia64/Linit_local.c deleted file mode 100644 index 68a1687e8..000000000 --- a/src/pal/src/libunwind/src/ia64/Linit_local.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Ginit_local.c" -#endif diff --git a/src/pal/src/libunwind/src/ia64/Linit_remote.c b/src/pal/src/libunwind/src/ia64/Linit_remote.c deleted file mode 100644 index 58cb04ab7..000000000 --- a/src/pal/src/libunwind/src/ia64/Linit_remote.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Ginit_remote.c" -#endif diff --git a/src/pal/src/libunwind/src/ia64/Linstall_cursor.S b/src/pal/src/libunwind/src/ia64/Linstall_cursor.S deleted file mode 100644 index 8c7233972..000000000 --- a/src/pal/src/libunwind/src/ia64/Linstall_cursor.S +++ /dev/null @@ -1,6 +0,0 @@ -#define UNW_LOCAL_ONLY -#include "Ginstall_cursor.S" -#ifdef __linux__ - /* We do not need executable stack. */ - .section .note.GNU-stack,"",@progbits -#endif diff --git a/src/pal/src/libunwind/src/ia64/Lis_signal_frame.c b/src/pal/src/libunwind/src/ia64/Lis_signal_frame.c deleted file mode 100644 index b9a7c4f51..000000000 --- a/src/pal/src/libunwind/src/ia64/Lis_signal_frame.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gis_signal_frame.c" -#endif diff --git a/src/pal/src/libunwind/src/ia64/Lparser.c b/src/pal/src/libunwind/src/ia64/Lparser.c deleted file mode 100644 index f23aaf48e..000000000 --- a/src/pal/src/libunwind/src/ia64/Lparser.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gparser.c" -#endif diff --git a/src/pal/src/libunwind/src/ia64/Lrbs.c b/src/pal/src/libunwind/src/ia64/Lrbs.c deleted file mode 100644 index a91b5f297..000000000 --- a/src/pal/src/libunwind/src/ia64/Lrbs.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Grbs.c" -#endif diff --git a/src/pal/src/libunwind/src/ia64/Lreg_states_iterate.c b/src/pal/src/libunwind/src/ia64/Lreg_states_iterate.c deleted file mode 100644 index f1eb1e79d..000000000 --- a/src/pal/src/libunwind/src/ia64/Lreg_states_iterate.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Greg_states_iterate.c" -#endif diff --git a/src/pal/src/libunwind/src/ia64/Lregs.c b/src/pal/src/libunwind/src/ia64/Lregs.c deleted file mode 100644 index 2c9c75cd7..000000000 --- a/src/pal/src/libunwind/src/ia64/Lregs.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gregs.c" -#endif diff --git a/src/pal/src/libunwind/src/ia64/Lresume.c b/src/pal/src/libunwind/src/ia64/Lresume.c deleted file mode 100644 index 41a8cf003..000000000 --- a/src/pal/src/libunwind/src/ia64/Lresume.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gresume.c" -#endif diff --git a/src/pal/src/libunwind/src/ia64/Lscript.c b/src/pal/src/libunwind/src/ia64/Lscript.c deleted file mode 100644 index 57b926bf8..000000000 --- a/src/pal/src/libunwind/src/ia64/Lscript.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gscript.c" -#endif diff --git a/src/pal/src/libunwind/src/ia64/Lstep.c b/src/pal/src/libunwind/src/ia64/Lstep.c deleted file mode 100644 index c1ac3c754..000000000 --- a/src/pal/src/libunwind/src/ia64/Lstep.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gstep.c" -#endif diff --git a/src/pal/src/libunwind/src/ia64/Ltables.c b/src/pal/src/libunwind/src/ia64/Ltables.c deleted file mode 100644 index 876b0aac0..000000000 --- a/src/pal/src/libunwind/src/ia64/Ltables.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gtables.c" -#endif diff --git a/src/pal/src/libunwind/src/ia64/NOTES b/src/pal/src/libunwind/src/ia64/NOTES deleted file mode 100644 index a5805e834..000000000 --- a/src/pal/src/libunwind/src/ia64/NOTES +++ /dev/null @@ -1,65 +0,0 @@ -- the frame state consists of the following: - - - ip current instruction pointer - - sp current stack pointer value - - bsp current backing store pointer - - cfm current frame mask - - these are derived from the next younger (more deeply nested) frame - as follows: - - - ip == saved return-link (may be b0 or an alternate branch-reg) - - sp == if younger frame has a fixed-sized frame, sp + size-of-frame, - else saved sp - - cfm == saved ar.pfs - - bsp == if ar.bsp has been saved, saved ar.bsp, otherwise, - ar.bsp \ominus saved ar.pfs.pfm.sol - -The unwind cursor should represent the machine state as it existed at -the address contained in register ip. This state consists of the -*current* frame state and the save locations in the next younger -frame. - -An unwind script current takes the old save locations and updates them -for the next older frame. With the new setup, we need to update the -frame state first, without updating the other save locations. For this -to work, we need the following info: - - - save location of return-link - - save location of ar.pfs - - save location of bsp (if it has been saved) - - size of stack frame (fixed case) or save location of sp - - -setup: - - func: ... - ... - ... - br.call foo <-- call site - ... <-- ip - ... - -initial state: - - The unwind cursor represents the (preserved) machine state - as it existed at "ip". - - Evaluating the unwind descriptors for "ip" yields the following - info: - - - frame size at call site (or previous sp) - - what registers where saved where by func before - the call site was reached - - - Note that there is some procedure info that needs to be obtained - for the new "ip" which is contained in the unwind descriptors. - Specifically, the following is needed: - - - procedure's start address - - personality address - - pointer to language-specific data area - - This info is stored in a separate proc_info structure and needs - to be obtained right after running the unwind script for func. diff --git a/src/pal/src/libunwind/src/ia64/dyn_info_list.S b/src/pal/src/libunwind/src/ia64/dyn_info_list.S deleted file mode 100644 index 31265f66a..000000000 --- a/src/pal/src/libunwind/src/ia64/dyn_info_list.S +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef UNW_REMOTE_ONLY - -/* - * Create a special unwind-table entry which makes it easy for an - * unwinder to locate the dynamic registration list. The special - * entry covers address range [0-0) and is therefore guaranteed to be - * the first in the unwind-table. - */ - .global _U_dyn_info_list - .hidden _U_dyn_info_list - - .section .IA_64.unwind_info,"a","progbits" -.info: data8 (1<<48) | 1 /* v1, length==1 (8-byte word) */ - data8 0 /* 8 empty .prologue directives (nops) */ - data8 0 /* personality routine (ignored) */ - string "dyn-list" /* lsda */ - data8 @gprel(_U_dyn_info_list) - - .section .IA_64.unwind, "a", "progbits" - data8 0, 0, @segrel(.info) - -#endif -#ifdef __linux__ - /* We do not need executable stack. */ - .section .note.GNU-stack,"",@progbits -#endif diff --git a/src/pal/src/libunwind/src/ia64/getcontext.S b/src/pal/src/libunwind/src/ia64/getcontext.S deleted file mode 100644 index d8da732ac..000000000 --- a/src/pal/src/libunwind/src/ia64/getcontext.S +++ /dev/null @@ -1,177 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include "ucontext_i.h" - -#define GR(n) (SC_GR + (n)*8) -#define BR(n) (SC_BR + (n)*8) -#define FR(n) (SC_FR + (n)*16) - -/* This should be compatible to the libc's getcontext(), except that - the sc->sc_mask field is always cleared and that the name is - prefixed with _Uia64_ so we don't step on the application's - name-space. */ - - .align 32 - .protected _Uia64_getcontext - .global _Uia64_getcontext - .proc _Uia64_getcontext -_Uia64_getcontext: - .prologue - alloc rPFS = ar.pfs, 1, 0, 0, 0 // M2 - mov rPR = pr // I0, 2 cycles - add r2 = GR(1), in0 // I1 - ;; - - .save ar.unat, rUNAT - mov.m rUNAT = ar.unat // M2, 5 cycles - .body - st8.spill [r2] = r1, (SC_FLAGS - GR(1)) // M3 - dep.z rFLAGS = -1, IA64_SC_FLAG_SYNCHRONOUS_BIT, 1 // I0, 1 cycle - ;; - - mov.m rRSC = ar.rsc // M2, 12 cyc. - st8 [r2] = rFLAGS, (SC_PR - SC_FLAGS) // M3 - add r3 = FR(2), in0 - ;; - - mov.m rBSP = ar.bsp // M2, 12 cyc. - st8 [r2] = rPR, (GR(12) - SC_PR) // M3 - add r8 = FR(16), in0 - ;; - - mov.m rFPSR = ar.fpsr // M2, 12 cyc. - st8.spill [r2] = r12, (GR(4) - GR(12)) // M3 - add r9 = FR(24), in0 - ;; - - stf.spill [r3] = f2 // M2 - stf.spill [r8] = f16 // M3 - add r3 = GR(7), in0 - ;; - - flushrs // M0 - stf.spill [r9] = f24, (FR(31) - FR(24)) // M2 - mov rB0 = b0 // I0, 2 cycles - ;; - - stf.spill [r9] = f31 // M2 - st8.spill [r2] = r4, (GR(5) - GR(4)) // M3, bank 1 - mov rB1 = b1 // I0, 2 cycles - ;; - -.mem.offset 0,0; st8.spill [r2] = r5, (GR(6) - GR(5)) // M4, bank 0 -.mem.offset 8,0; st8.spill [r3] = r7, (BR(0) - GR(7)) // M3, bank 0 - mov rB2 = b2 // I0, 2 cycles - ;; - - st8.spill [r2] = r6, (BR(1) - GR(6)) // M2, bank 1 - st8 [r3] = rB0, (BR(4) - BR(0)) // M3, bank 1 - mov rB4 = b4 // I0, 2 cycles - ;; - - mov.m rNAT = ar.unat // M2, 5 cycles - st8 [r2] = rB1, (BR(2) - BR(1)) // M3, bank 0 - mov rB3 = b3 - ;; - - st8 [r2] = rB2, (BR(3) - BR(2)) // M2, bank 1 - st8 [r3] = rB4, (SC_LC - BR(4)) // M3, bank 1 - mov rB5 = b5 // I0, 2 cycles - ;; - - and rTMP = ~0x3, rRSC // M0 - add rPOS = GR(0), in0 // rPOS <- &sc_gr[0] // M1 - mov.i rLC = ar.lc // I0, 2 cycles - ;; - - mov.m ar.rsc = rTMP // put RSE into lazy mode // M2, ? cycles - st8 [r2] = rB3, (BR(5) - BR(3)) // M3, bank 0 - extr.u rPOS = rPOS, 3, 6 // get NaT bitnr for r0 // I0 - ;; - - mov.m rRNAT = ar.rnat // M2, 5 cycles - st8 [r2] = rB5, (SC_PFS - BR(5)) // M3, bank 0 - sub rCPOS = 64, rPOS // I0 - ;; - - st8 [r2] = rPFS, (SC_UNAT - SC_PFS) // M2 - st8 [r3] = rLC, (SC_BSP - SC_LC) // M3 - shr.u rTMP = rNAT, rPOS // I0, 3 cycles - ;; - - st8 [r2] = rUNAT, (SC_FPSR - SC_UNAT) // M2 - st8 [r3] = rBSP // M3 - add r8 = FR(3), in0 - ;; - - st8 [r2] = rFPSR, (SC_RNAT - SC_FPSR) // M2 - stf.spill [r8] = f3, (FR(4) - FR(3)) // M3 - add r9 = FR(5), in0 - ;; - - stf.spill [r8] = f4, (FR(17) - FR(4)) // M2 - stf.spill [r9] = f5, (FR(19) - FR(5)) // M3 - shl rNAT = rNAT, rCPOS // I0, 3 cycles - ;; - - st8 [r2] = rRNAT, (SC_NAT - SC_RNAT) // M2 - stf.spill [r8] = f17, (FR(18) - FR(17)) // M3 - nop.i 0 - ;; - - stf.spill [r8] = f18, (FR(20) - FR(18)) // M2 - stf.spill [r9] = f19, (FR(21) - FR(19)) // M3 - nop.i 0 - ;; - - stf.spill [r8] = f20, (FR(22) - FR(20)) // M2 - stf.spill [r9] = f21, (FR(23) - FR(21)) // M3 - or rNAT = rNAT, rTMP // I0 - ;; - - st8 [r2] = rNAT // M2 - stf.spill [r8] = f22, (FR(25) - FR(22)) // M3 - ;; - stf.spill [r9] = f23, (FR(26) - FR(23)) // M2 - stf.spill [r8] = f25, (FR(27) - FR(25)) // M3 - ;; - stf.spill [r9] = f26, (FR(28) - FR(26)) // M2 - stf.spill [r8] = f27, (FR(29) - FR(27)) // M3 - ;; - mov.m ar.rsc = rRSC // restore RSE mode // M2 - stf.spill [r9] = f28, (FR(30) - FR(28)) // M3 - ;; - mov.m ar.unat = rUNAT // restore caller's UNaT // M2 - stf.spill [r8] = f29 // M3 - ;; - stf.spill [r9] = f30 // M2 - mov r8 = 0 - br.ret.sptk.many rp - .endp _Uia64_getcontext -#ifdef __linux__ - /* We do not need executable stack. */ - .section .note.GNU-stack,"",@progbits -#endif diff --git a/src/pal/src/libunwind/src/ia64/init.h b/src/pal/src/libunwind/src/ia64/init.h deleted file mode 100644 index 6628a1d88..000000000 --- a/src/pal/src/libunwind/src/ia64/init.h +++ /dev/null @@ -1,132 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2002-2005 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" - -static ALWAYS_INLINE int -common_init (struct cursor *c, unw_word_t sp, unw_word_t bsp) -{ - unw_word_t bspstore, rbs_base; - int ret; - - if (c->as->caching_policy != UNW_CACHE_NONE) - /* ensure cache doesn't have any stale contents: */ - ia64_validate_cache (c->as, c->as_arg); - - c->cfm_loc = IA64_REG_LOC (c, UNW_IA64_CFM); - c->loc[IA64_REG_BSP] = IA64_NULL_LOC; - c->loc[IA64_REG_BSPSTORE] = IA64_REG_LOC (c, UNW_IA64_AR_BSPSTORE); - c->loc[IA64_REG_PFS] = IA64_REG_LOC (c, UNW_IA64_AR_PFS); - c->loc[IA64_REG_RNAT] = IA64_REG_LOC (c, UNW_IA64_AR_RNAT); - c->loc[IA64_REG_IP] = IA64_REG_LOC (c, UNW_IA64_IP); - c->loc[IA64_REG_PRI_UNAT_MEM] = IA64_NULL_LOC; /* no primary UNaT location */ - c->loc[IA64_REG_UNAT] = IA64_REG_LOC (c, UNW_IA64_AR_UNAT); - c->loc[IA64_REG_PR] = IA64_REG_LOC (c, UNW_IA64_PR); - c->loc[IA64_REG_LC] = IA64_REG_LOC (c, UNW_IA64_AR_LC); - c->loc[IA64_REG_FPSR] = IA64_REG_LOC (c, UNW_IA64_AR_FPSR); - - c->loc[IA64_REG_R4] = IA64_REG_LOC (c, UNW_IA64_GR + 4); - c->loc[IA64_REG_R5] = IA64_REG_LOC (c, UNW_IA64_GR + 5); - c->loc[IA64_REG_R6] = IA64_REG_LOC (c, UNW_IA64_GR + 6); - c->loc[IA64_REG_R7] = IA64_REG_LOC (c, UNW_IA64_GR + 7); - - c->loc[IA64_REG_NAT4] = IA64_REG_NAT_LOC (c, UNW_IA64_NAT + 4, &c->nat_bitnr[0]); - c->loc[IA64_REG_NAT5] = IA64_REG_NAT_LOC (c, UNW_IA64_NAT + 5, &c->nat_bitnr[1]); - c->loc[IA64_REG_NAT6] = IA64_REG_NAT_LOC (c, UNW_IA64_NAT + 6, &c->nat_bitnr[2]); - c->loc[IA64_REG_NAT7] = IA64_REG_NAT_LOC (c, UNW_IA64_NAT + 7, &c->nat_bitnr[3]); - - c->loc[IA64_REG_B1] = IA64_REG_LOC (c, UNW_IA64_BR + 1); - c->loc[IA64_REG_B2] = IA64_REG_LOC (c, UNW_IA64_BR + 2); - c->loc[IA64_REG_B3] = IA64_REG_LOC (c, UNW_IA64_BR + 3); - c->loc[IA64_REG_B4] = IA64_REG_LOC (c, UNW_IA64_BR + 4); - c->loc[IA64_REG_B5] = IA64_REG_LOC (c, UNW_IA64_BR + 5); - - c->loc[IA64_REG_F2] = IA64_FPREG_LOC (c, UNW_IA64_FR + 2); - c->loc[IA64_REG_F3] = IA64_FPREG_LOC (c, UNW_IA64_FR + 3); - c->loc[IA64_REG_F4] = IA64_FPREG_LOC (c, UNW_IA64_FR + 4); - c->loc[IA64_REG_F5] = IA64_FPREG_LOC (c, UNW_IA64_FR + 5); - c->loc[IA64_REG_F16] = IA64_FPREG_LOC (c, UNW_IA64_FR + 16); - c->loc[IA64_REG_F17] = IA64_FPREG_LOC (c, UNW_IA64_FR + 17); - c->loc[IA64_REG_F18] = IA64_FPREG_LOC (c, UNW_IA64_FR + 18); - c->loc[IA64_REG_F19] = IA64_FPREG_LOC (c, UNW_IA64_FR + 19); - c->loc[IA64_REG_F20] = IA64_FPREG_LOC (c, UNW_IA64_FR + 20); - c->loc[IA64_REG_F21] = IA64_FPREG_LOC (c, UNW_IA64_FR + 21); - c->loc[IA64_REG_F22] = IA64_FPREG_LOC (c, UNW_IA64_FR + 22); - c->loc[IA64_REG_F23] = IA64_FPREG_LOC (c, UNW_IA64_FR + 23); - c->loc[IA64_REG_F24] = IA64_FPREG_LOC (c, UNW_IA64_FR + 24); - c->loc[IA64_REG_F25] = IA64_FPREG_LOC (c, UNW_IA64_FR + 25); - c->loc[IA64_REG_F26] = IA64_FPREG_LOC (c, UNW_IA64_FR + 26); - c->loc[IA64_REG_F27] = IA64_FPREG_LOC (c, UNW_IA64_FR + 27); - c->loc[IA64_REG_F28] = IA64_FPREG_LOC (c, UNW_IA64_FR + 28); - c->loc[IA64_REG_F29] = IA64_FPREG_LOC (c, UNW_IA64_FR + 29); - c->loc[IA64_REG_F30] = IA64_FPREG_LOC (c, UNW_IA64_FR + 30); - c->loc[IA64_REG_F31] = IA64_FPREG_LOC (c, UNW_IA64_FR + 31); - - ret = ia64_get (c, c->loc[IA64_REG_IP], &c->ip); - if (ret < 0) - return ret; - - ret = ia64_get (c, c->cfm_loc, &c->cfm); - if (ret < 0) - return ret; - - ret = ia64_get (c, c->loc[IA64_REG_PR], &c->pr); - if (ret < 0) - return ret; - - c->sp = c->psp = sp; - c->bsp = bsp; - - ret = ia64_get (c, c->loc[IA64_REG_BSPSTORE], &bspstore); - if (ret < 0) - return ret; - - c->rbs_curr = c->rbs_left_edge = 0; - - /* Try to find a base of the register backing-store. We may default - to a reasonable value (e.g., half the address-space down from - bspstore). If the BSPSTORE looks corrupt, we fail. */ - if ((ret = rbs_get_base (c, bspstore, &rbs_base)) < 0) - return ret; - - c->rbs_area[0].end = bspstore; - c->rbs_area[0].size = bspstore - rbs_base; - c->rbs_area[0].rnat_loc = IA64_REG_LOC (c, UNW_IA64_AR_RNAT); - Debug (10, "initial rbs-area: [0x%llx-0x%llx), rnat@%s\n", - (long long) rbs_base, (long long) c->rbs_area[0].end, - ia64_strloc (c->rbs_area[0].rnat_loc)); - - c->pi.flags = 0; - - c->sigcontext_addr = 0; - c->abi_marker = 0; - c->last_abi_marker = 0; - - c->hint = 0; - c->prev_script = 0; - c->eh_valid_mask = 0; - c->pi_valid = 0; - return 0; -} diff --git a/src/pal/src/libunwind/src/ia64/longjmp.S b/src/pal/src/libunwind/src/ia64/longjmp.S deleted file mode 100644 index 2a2f28659..000000000 --- a/src/pal/src/libunwind/src/ia64/longjmp.S +++ /dev/null @@ -1,42 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - - .global _UI_longjmp_cont - - .align 32 - .proc longjmp_continuation -longjmp_continuation: -_UI_longjmp_cont: // non-function label for {sig,}longjmp.c - .prologue - .save rp, r15 - .body - mov rp = r15 - mov r8 = r16 - br.sptk.many rp - .endp longjmp_continuation -#ifdef __linux__ - /* We do not need executable stack. */ - .section .note.GNU-stack,"",@progbits -#endif diff --git a/src/pal/src/libunwind/src/ia64/mk_cursor_i b/src/pal/src/libunwind/src/ia64/mk_cursor_i deleted file mode 100644 index 9211f91bb..000000000 --- a/src/pal/src/libunwind/src/ia64/mk_cursor_i +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh -test -z "$1" && exit 1 -echo "/* GENERATED */" -echo "#ifndef cursor_i_h" -echo "#define cursor_i_h" -sed -ne 's/^->"\(\S*\)" \(\d*\)/#define \1 \2/p' < $1 || exit $? -echo "#endif" diff --git a/src/pal/src/libunwind/src/ia64/offsets.h b/src/pal/src/libunwind/src/ia64/offsets.h deleted file mode 100644 index 5ab7f8b31..000000000 --- a/src/pal/src/libunwind/src/ia64/offsets.h +++ /dev/null @@ -1,137 +0,0 @@ -/* Linux-specific definitions: */ - -/* Define various structure offsets to simplify cross-compilation. */ - -/* The first three 64-bit words in a signal frame contain the signal - number, siginfo pointer, and sigcontext pointer passed to the - signal handler. We use this to locate the sigcontext pointer. */ - -#define LINUX_SIGFRAME_ARG2_OFF 0x10 - -#define LINUX_SC_FLAGS_OFF 0x000 -#define LINUX_SC_NAT_OFF 0x008 -#define LINUX_SC_STACK_OFF 0x010 -#define LINUX_SC_IP_OFF 0x028 -#define LINUX_SC_CFM_OFF 0x030 -#define LINUX_SC_UM_OFF 0x038 -#define LINUX_SC_AR_RSC_OFF 0x040 -#define LINUX_SC_AR_BSP_OFF 0x048 -#define LINUX_SC_AR_RNAT_OFF 0x050 -#define LINUX_SC_AR_CCV 0x058 -#define LINUX_SC_AR_UNAT_OFF 0x060 -#define LINUX_SC_AR_FPSR_OFF 0x068 -#define LINUX_SC_AR_PFS_OFF 0x070 -#define LINUX_SC_AR_LC_OFF 0x078 -#define LINUX_SC_PR_OFF 0x080 -#define LINUX_SC_BR_OFF 0x088 -#define LINUX_SC_GR_OFF 0x0c8 -#define LINUX_SC_FR_OFF 0x1d0 -#define LINUX_SC_RBS_BASE_OFF 0x9d0 -#define LINUX_SC_LOADRS_OFF 0x9d8 -#define LINUX_SC_AR_CSD_OFF 0x9e0 -#define LINUX_SC_AR_SSD_OFF 0x9e8 -#define LINUX_SC_MASK 0xa50 - -/* Layout of old Linux kernel interrupt frame (struct pt_regs). */ - -#define LINUX_OLD_PT_IPSR_OFF 0x000 -#define LINUX_OLD_PT_IIP_OFF 0x008 -#define LINUX_OLD_PT_IFS_OFF 0x010 -#define LINUX_OLD_PT_UNAT_OFF 0x018 -#define LINUX_OLD_PT_PFS_OFF 0x020 -#define LINUX_OLD_PT_RSC_OFF 0x028 -#define LINUX_OLD_PT_RNAT_OFF 0x030 -#define LINUX_OLD_PT_BSPSTORE_OFF 0x038 -#define LINUX_OLD_PT_PR_OFF 0x040 -#define LINUX_OLD_PT_B6_OFF 0x048 -#define LINUX_OLD_PT_LOADRS_OFF 0x050 -#define LINUX_OLD_PT_R1_OFF 0x058 -#define LINUX_OLD_PT_R2_OFF 0x060 -#define LINUX_OLD_PT_R3_OFF 0x068 -#define LINUX_OLD_PT_R12_OFF 0x070 -#define LINUX_OLD_PT_R13_OFF 0x078 -#define LINUX_OLD_PT_R14_OFF 0x080 -#define LINUX_OLD_PT_R15_OFF 0x088 -#define LINUX_OLD_PT_R8_OFF 0x090 -#define LINUX_OLD_PT_R9_OFF 0x098 -#define LINUX_OLD_PT_R10_OFF 0x0a0 -#define LINUX_OLD_PT_R11_OFF 0x0a8 -#define LINUX_OLD_PT_R16_OFF 0x0b0 -#define LINUX_OLD_PT_R17_OFF 0x0b8 -#define LINUX_OLD_PT_R18_OFF 0x0c0 -#define LINUX_OLD_PT_R19_OFF 0x0c8 -#define LINUX_OLD_PT_R20_OFF 0x0d0 -#define LINUX_OLD_PT_R21_OFF 0x0d8 -#define LINUX_OLD_PT_R22_OFF 0x0e0 -#define LINUX_OLD_PT_R23_OFF 0x0e8 -#define LINUX_OLD_PT_R24_OFF 0x0f0 -#define LINUX_OLD_PT_R25_OFF 0x0f8 -#define LINUX_OLD_PT_R26_OFF 0x100 -#define LINUX_OLD_PT_R27_OFF 0x108 -#define LINUX_OLD_PT_R28_OFF 0x110 -#define LINUX_OLD_PT_R29_OFF 0x118 -#define LINUX_OLD_PT_R30_OFF 0x120 -#define LINUX_OLD_PT_R31_OFF 0x128 -#define LINUX_OLD_PT_CCV_OFF 0x130 -#define LINUX_OLD_PT_FPSR_OFF 0x138 -#define LINUX_OLD_PT_B0_OFF 0x140 -#define LINUX_OLD_PT_B7_OFF 0x148 -#define LINUX_OLD_PT_F6_OFF 0x150 -#define LINUX_OLD_PT_F7_OFF 0x160 -#define LINUX_OLD_PT_F8_OFF 0x170 -#define LINUX_OLD_PT_F9_OFF 0x180 - -/* Layout of new Linux kernel interrupt frame (struct pt_regs). */ - -#define LINUX_PT_B6_OFF 0 -#define LINUX_PT_B7_OFF 8 -#define LINUX_PT_CSD_OFF 16 -#define LINUX_PT_SSD_OFF 24 -#define LINUX_PT_R8_OFF 32 -#define LINUX_PT_R9_OFF 40 -#define LINUX_PT_R10_OFF 48 -#define LINUX_PT_R11_OFF 56 -#define LINUX_PT_IPSR_OFF 64 -#define LINUX_PT_IIP_OFF 72 -#define LINUX_PT_IFS_OFF 80 -#define LINUX_PT_UNAT_OFF 88 -#define LINUX_PT_PFS_OFF 96 -#define LINUX_PT_RSC_OFF 104 -#define LINUX_PT_RNAT_OFF 112 -#define LINUX_PT_BSPSTORE_OFF 120 -#define LINUX_PT_PR_OFF 128 -#define LINUX_PT_B0_OFF 136 -#define LINUX_PT_LOADRS_OFF 144 -#define LINUX_PT_R1_OFF 152 -#define LINUX_PT_R12_OFF 160 -#define LINUX_PT_R13_OFF 168 -#define LINUX_PT_FPSR_OFF 176 -#define LINUX_PT_R15_OFF 184 -#define LINUX_PT_R14_OFF 192 -#define LINUX_PT_R2_OFF 200 -#define LINUX_PT_R3_OFF 208 -#define LINUX_PT_R16_OFF 216 -#define LINUX_PT_R17_OFF 224 -#define LINUX_PT_R18_OFF 232 -#define LINUX_PT_R19_OFF 240 -#define LINUX_PT_R20_OFF 248 -#define LINUX_PT_R21_OFF 256 -#define LINUX_PT_R22_OFF 264 -#define LINUX_PT_R23_OFF 272 -#define LINUX_PT_R24_OFF 280 -#define LINUX_PT_R25_OFF 288 -#define LINUX_PT_R26_OFF 296 -#define LINUX_PT_R27_OFF 304 -#define LINUX_PT_R28_OFF 312 -#define LINUX_PT_R29_OFF 320 -#define LINUX_PT_R30_OFF 328 -#define LINUX_PT_R31_OFF 336 -#define LINUX_PT_CCV_OFF 344 -#define LINUX_PT_F6_OFF 352 -#define LINUX_PT_F7_OFF 368 -#define LINUX_PT_F8_OFF 384 -#define LINUX_PT_F9_OFF 400 -#define LINUX_PT_F10_OFF 416 -#define LINUX_PT_F11_OFF 432 - -#define LINUX_PT_P_NONSYS 5 /* must match pNonSys in entry.h */ diff --git a/src/pal/src/libunwind/src/ia64/regname.c b/src/pal/src/libunwind/src/ia64/regname.c deleted file mode 100644 index 3636df87d..000000000 --- a/src/pal/src/libunwind/src/ia64/regname.c +++ /dev/null @@ -1,189 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2002-2005 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -/* Logically, we like to think of the stack as a contiguous region of -memory. Unfortunately, this logical view doesn't work for the -register backing store, because the RSE is an asynchronous engine and -because UNIX/Linux allow for stack-switching via sigaltstack(2). -Specifically, this means that any given stacked register may or may -not be backed up by memory in the current stack. If not, then the -backing memory may be found in any of the "more inner" (younger) -stacks. The routines in this file help manage the discontiguous -nature of the register backing store. The routines are completely -independent of UNIX/Linux, but each stack frame that switches the -backing store is expected to reserve 4 words for use by libunwind. For -example, in the Linux sigcontext, sc_fr[0] and sc_fr[1] serve this -purpose. */ - -#include "libunwind_i.h" - -/* Maintain the register names as a single string to keep the number - of dynamic relocations in the shared object to a minimum. */ - -#define regname_len 9 -#define regname_str \ - "r0\0\0\0\0\0\0\0r1\0\0\0\0\0\0\0r2\0\0\0\0\0\0\0r3\0\0\0\0\0\0\0" \ - "r4\0\0\0\0\0\0\0r5\0\0\0\0\0\0\0r6\0\0\0\0\0\0\0r7\0\0\0\0\0\0\0" \ - "r8\0\0\0\0\0\0\0r9\0\0\0\0\0\0\0r10\0\0\0\0\0\0r11\0\0\0\0\0\0" \ - "r12\0\0\0\0\0\0r13\0\0\0\0\0\0r14\0\0\0\0\0\0r15\0\0\0\0\0\0" \ - "r16\0\0\0\0\0\0r17\0\0\0\0\0\0r18\0\0\0\0\0\0r19\0\0\0\0\0\0" \ - "r20\0\0\0\0\0\0r21\0\0\0\0\0\0r22\0\0\0\0\0\0r23\0\0\0\0\0\0" \ - "r24\0\0\0\0\0\0r25\0\0\0\0\0\0r26\0\0\0\0\0\0r27\0\0\0\0\0\0" \ - "r28\0\0\0\0\0\0r29\0\0\0\0\0\0r30\0\0\0\0\0\0r31\0\0\0\0\0\0" \ - "r32\0\0\0\0\0\0r33\0\0\0\0\0\0r34\0\0\0\0\0\0r35\0\0\0\0\0\0" \ - "r36\0\0\0\0\0\0r37\0\0\0\0\0\0r38\0\0\0\0\0\0r39\0\0\0\0\0\0" \ - "r40\0\0\0\0\0\0r41\0\0\0\0\0\0r42\0\0\0\0\0\0r43\0\0\0\0\0\0" \ - "r44\0\0\0\0\0\0r45\0\0\0\0\0\0r46\0\0\0\0\0\0r47\0\0\0\0\0\0" \ - "r48\0\0\0\0\0\0r49\0\0\0\0\0\0r50\0\0\0\0\0\0r51\0\0\0\0\0\0" \ - "r52\0\0\0\0\0\0r53\0\0\0\0\0\0r54\0\0\0\0\0\0r55\0\0\0\0\0\0" \ - "r56\0\0\0\0\0\0r57\0\0\0\0\0\0r58\0\0\0\0\0\0r59\0\0\0\0\0\0" \ - "r60\0\0\0\0\0\0r61\0\0\0\0\0\0r62\0\0\0\0\0\0r63\0\0\0\0\0\0" \ - "r64\0\0\0\0\0\0r65\0\0\0\0\0\0r66\0\0\0\0\0\0r67\0\0\0\0\0\0" \ - "r68\0\0\0\0\0\0r69\0\0\0\0\0\0r70\0\0\0\0\0\0r71\0\0\0\0\0\0" \ - "r72\0\0\0\0\0\0r73\0\0\0\0\0\0r74\0\0\0\0\0\0r75\0\0\0\0\0\0" \ - "r76\0\0\0\0\0\0r77\0\0\0\0\0\0r78\0\0\0\0\0\0r79\0\0\0\0\0\0" \ - "r80\0\0\0\0\0\0r81\0\0\0\0\0\0r82\0\0\0\0\0\0r83\0\0\0\0\0\0" \ - "r84\0\0\0\0\0\0r85\0\0\0\0\0\0r86\0\0\0\0\0\0r87\0\0\0\0\0\0" \ - "r88\0\0\0\0\0\0r89\0\0\0\0\0\0r90\0\0\0\0\0\0r91\0\0\0\0\0\0" \ - "r92\0\0\0\0\0\0r93\0\0\0\0\0\0r94\0\0\0\0\0\0r95\0\0\0\0\0\0" \ - "r96\0\0\0\0\0\0r97\0\0\0\0\0\0r98\0\0\0\0\0\0r99\0\0\0\0\0\0" \ - "r100\0\0\0\0\0r101\0\0\0\0\0r102\0\0\0\0\0r103\0\0\0\0\0" \ - "r104\0\0\0\0\0r105\0\0\0\0\0r106\0\0\0\0\0r107\0\0\0\0\0" \ - "r108\0\0\0\0\0r109\0\0\0\0\0r110\0\0\0\0\0r111\0\0\0\0\0" \ - "r112\0\0\0\0\0r113\0\0\0\0\0r114\0\0\0\0\0r115\0\0\0\0\0" \ - "r116\0\0\0\0\0r117\0\0\0\0\0r118\0\0\0\0\0r119\0\0\0\0\0" \ - "r120\0\0\0\0\0r121\0\0\0\0\0r122\0\0\0\0\0r123\0\0\0\0\0" \ - "r124\0\0\0\0\0r125\0\0\0\0\0r126\0\0\0\0\0r127\0\0\0\0\0" \ - "nat0\0\0\0\0\0nat1\0\0\0\0\0nat2\0\0\0\0\0nat3\0\0\0\0\0" \ - "nat4\0\0\0\0\0nat5\0\0\0\0\0nat6\0\0\0\0\0nat7\0\0\0\0\0" \ - "nat8\0\0\0\0\0nat9\0\0\0\0\0nat10\0\0\0\0nat11\0\0\0\0" \ - "nat12\0\0\0\0nat13\0\0\0\0nat14\0\0\0\0nat15\0\0\0\0" \ - "nat16\0\0\0\0nat17\0\0\0\0nat18\0\0\0\0nat19\0\0\0\0" \ - "nat20\0\0\0\0nat21\0\0\0\0nat22\0\0\0\0nat23\0\0\0\0" \ - "nat24\0\0\0\0nat25\0\0\0\0nat26\0\0\0\0nat27\0\0\0\0" \ - "nat28\0\0\0\0nat29\0\0\0\0nat30\0\0\0\0nat31\0\0\0\0" \ - "nat32\0\0\0\0nat33\0\0\0\0nat34\0\0\0\0nat35\0\0\0\0" \ - "nat36\0\0\0\0nat37\0\0\0\0nat38\0\0\0\0nat39\0\0\0\0" \ - "nat40\0\0\0\0nat41\0\0\0\0nat42\0\0\0\0nat43\0\0\0\0" \ - "nat44\0\0\0\0nat45\0\0\0\0nat46\0\0\0\0nat47\0\0\0\0" \ - "nat48\0\0\0\0nat49\0\0\0\0nat50\0\0\0\0nat51\0\0\0\0" \ - "nat52\0\0\0\0nat53\0\0\0\0nat54\0\0\0\0nat55\0\0\0\0" \ - "nat56\0\0\0\0nat57\0\0\0\0nat58\0\0\0\0nat59\0\0\0\0" \ - "nat60\0\0\0\0nat61\0\0\0\0nat62\0\0\0\0nat63\0\0\0\0" \ - "nat64\0\0\0\0nat65\0\0\0\0nat66\0\0\0\0nat67\0\0\0\0" \ - "nat68\0\0\0\0nat69\0\0\0\0nat70\0\0\0\0nat71\0\0\0\0" \ - "nat72\0\0\0\0nat73\0\0\0\0nat74\0\0\0\0nat75\0\0\0\0" \ - "nat76\0\0\0\0nat77\0\0\0\0nat78\0\0\0\0nat79\0\0\0\0" \ - "nat80\0\0\0\0nat81\0\0\0\0nat82\0\0\0\0nat83\0\0\0\0" \ - "nat84\0\0\0\0nat85\0\0\0\0nat86\0\0\0\0nat87\0\0\0\0" \ - "nat88\0\0\0\0nat89\0\0\0\0nat90\0\0\0\0nat91\0\0\0\0" \ - "nat92\0\0\0\0nat93\0\0\0\0nat94\0\0\0\0nat95\0\0\0\0" \ - "nat96\0\0\0\0nat97\0\0\0\0nat98\0\0\0\0nat99\0\0\0\0" \ - "nat100\0\0\0nat101\0\0\0nat102\0\0\0nat103\0\0\0" \ - "nat104\0\0\0nat105\0\0\0nat106\0\0\0nat107\0\0\0" \ - "nat108\0\0\0nat109\0\0\0nat110\0\0\0nat111\0\0\0" \ - "nat112\0\0\0nat113\0\0\0nat114\0\0\0nat115\0\0\0" \ - "nat116\0\0\0nat117\0\0\0nat118\0\0\0nat119\0\0\0" \ - "nat120\0\0\0nat121\0\0\0nat122\0\0\0nat123\0\0\0" \ - "nat124\0\0\0nat125\0\0\0nat126\0\0\0nat127\0\0\0" \ - "f0\0\0\0\0\0\0\0f1\0\0\0\0\0\0\0f2\0\0\0\0\0\0\0f3\0\0\0\0\0\0\0" \ - "f4\0\0\0\0\0\0\0f5\0\0\0\0\0\0\0f6\0\0\0\0\0\0\0f7\0\0\0\0\0\0\0" \ - "f8\0\0\0\0\0\0\0f9\0\0\0\0\0\0\0f10\0\0\0\0\0\0f11\0\0\0\0\0\0" \ - "f12\0\0\0\0\0\0f13\0\0\0\0\0\0f14\0\0\0\0\0\0f15\0\0\0\0\0\0" \ - "f16\0\0\0\0\0\0f17\0\0\0\0\0\0f18\0\0\0\0\0\0f19\0\0\0\0\0\0" \ - "f20\0\0\0\0\0\0f21\0\0\0\0\0\0f22\0\0\0\0\0\0f23\0\0\0\0\0\0" \ - "f24\0\0\0\0\0\0f25\0\0\0\0\0\0f26\0\0\0\0\0\0f27\0\0\0\0\0\0" \ - "f28\0\0\0\0\0\0f29\0\0\0\0\0\0f30\0\0\0\0\0\0f31\0\0\0\0\0\0" \ - "f32\0\0\0\0\0\0f33\0\0\0\0\0\0f34\0\0\0\0\0\0f35\0\0\0\0\0\0" \ - "f36\0\0\0\0\0\0f37\0\0\0\0\0\0f38\0\0\0\0\0\0f39\0\0\0\0\0\0" \ - "f40\0\0\0\0\0\0f41\0\0\0\0\0\0f42\0\0\0\0\0\0f43\0\0\0\0\0\0" \ - "f44\0\0\0\0\0\0f45\0\0\0\0\0\0f46\0\0\0\0\0\0f47\0\0\0\0\0\0" \ - "f48\0\0\0\0\0\0f49\0\0\0\0\0\0f50\0\0\0\0\0\0f51\0\0\0\0\0\0" \ - "f52\0\0\0\0\0\0f53\0\0\0\0\0\0f54\0\0\0\0\0\0f55\0\0\0\0\0\0" \ - "f56\0\0\0\0\0\0f57\0\0\0\0\0\0f58\0\0\0\0\0\0f59\0\0\0\0\0\0" \ - "f60\0\0\0\0\0\0f61\0\0\0\0\0\0f62\0\0\0\0\0\0f63\0\0\0\0\0\0" \ - "f64\0\0\0\0\0\0f65\0\0\0\0\0\0f66\0\0\0\0\0\0f67\0\0\0\0\0\0" \ - "f68\0\0\0\0\0\0f69\0\0\0\0\0\0f70\0\0\0\0\0\0f71\0\0\0\0\0\0" \ - "f72\0\0\0\0\0\0f73\0\0\0\0\0\0f74\0\0\0\0\0\0f75\0\0\0\0\0\0" \ - "f76\0\0\0\0\0\0f77\0\0\0\0\0\0f78\0\0\0\0\0\0f79\0\0\0\0\0\0" \ - "f80\0\0\0\0\0\0f81\0\0\0\0\0\0f82\0\0\0\0\0\0f83\0\0\0\0\0\0" \ - "f84\0\0\0\0\0\0f85\0\0\0\0\0\0f86\0\0\0\0\0\0f87\0\0\0\0\0\0" \ - "f88\0\0\0\0\0\0f89\0\0\0\0\0\0f90\0\0\0\0\0\0f91\0\0\0\0\0\0" \ - "f92\0\0\0\0\0\0f93\0\0\0\0\0\0f94\0\0\0\0\0\0f95\0\0\0\0\0\0" \ - "f96\0\0\0\0\0\0f97\0\0\0\0\0\0f98\0\0\0\0\0\0f99\0\0\0\0\0\0" \ - "f100\0\0\0\0\0f101\0\0\0\0\0f102\0\0\0\0\0f103\0\0\0\0\0" \ - "f104\0\0\0\0\0f105\0\0\0\0\0f106\0\0\0\0\0f107\0\0\0\0\0" \ - "f108\0\0\0\0\0f109\0\0\0\0\0f110\0\0\0\0\0f111\0\0\0\0\0" \ - "f112\0\0\0\0\0f113\0\0\0\0\0f114\0\0\0\0\0f115\0\0\0\0\0" \ - "f116\0\0\0\0\0f117\0\0\0\0\0f118\0\0\0\0\0f119\0\0\0\0\0" \ - "f120\0\0\0\0\0f121\0\0\0\0\0f122\0\0\0\0\0f123\0\0\0\0\0" \ - "f124\0\0\0\0\0f125\0\0\0\0\0f126\0\0\0\0\0f127\0\0\0\0\0" \ - "ar0\0\0\0\0\0\0ar1\0\0\0\0\0\0ar2\0\0\0\0\0\0ar3\0\0\0\0\0\0" \ - "ar4\0\0\0\0\0\0ar5\0\0\0\0\0\0ar6\0\0\0\0\0\0ar7\0\0\0\0\0\0" \ - "ar8\0\0\0\0\0\0ar9\0\0\0\0\0\0ar10\0\0\0\0\0ar11\0\0\0\0\0" \ - "ar12\0\0\0\0\0ar13\0\0\0\0\0ar14\0\0\0\0\0ar15\0\0\0\0\0" \ - "rsc\0\0\0\0\0\0bsp\0\0\0\0\0\0bspstore\0rnat\0\0\0\0\0" \ - "ar20\0\0\0\0\0ar21\0\0\0\0\0ar22\0\0\0\0\0ar23\0\0\0\0\0" \ - "ar24\0\0\0\0\0ar25\0\0\0\0\0ar26\0\0\0\0\0ar27\0\0\0\0\0" \ - "ar28\0\0\0\0\0ar29\0\0\0\0\0ar30\0\0\0\0\0ar31\0\0\0\0\0" \ - "ccv\0\0\0\0\0\0ar33\0\0\0\0\0ar34\0\0\0\0\0ar35\0\0\0\0\0" \ - "unat\0\0\0\0\0ar37\0\0\0\0\0ar38\0\0\0\0\0ar39\0\0\0\0\0" \ - "fpsr\0\0\0\0\0ar41\0\0\0\0\0ar42\0\0\0\0\0ar43\0\0\0\0\0" \ - "ar44\0\0\0\0\0ar45\0\0\0\0\0ar46\0\0\0\0\0ar47\0\0\0\0\0" \ - "ar48\0\0\0\0\0ar49\0\0\0\0\0ar50\0\0\0\0\0ar51\0\0\0\0\0" \ - "ar52\0\0\0\0\0ar53\0\0\0\0\0ar54\0\0\0\0\0ar55\0\0\0\0\0" \ - "ar56\0\0\0\0\0ar57\0\0\0\0\0ar58\0\0\0\0\0ar59\0\0\0\0\0" \ - "ar60\0\0\0\0\0ar61\0\0\0\0\0ar62\0\0\0\0\0ar63\0\0\0\0\0" \ - "pfs\0\0\0\0\0\0lc\0\0\0\0\0\0\0ec\0\0\0\0\0\0\0ar67\0\0\0\0\0" \ - "ar68\0\0\0\0\0ar69\0\0\0\0\0ar70\0\0\0\0\0ar71\0\0\0\0\0" \ - "ar72\0\0\0\0\0ar73\0\0\0\0\0ar74\0\0\0\0\0ar75\0\0\0\0\0" \ - "ar76\0\0\0\0\0ar77\0\0\0\0\0ar78\0\0\0\0\0ar79\0\0\0\0\0" \ - "ar80\0\0\0\0\0ar81\0\0\0\0\0ar82\0\0\0\0\0ar83\0\0\0\0\0" \ - "ar84\0\0\0\0\0ar85\0\0\0\0\0ar86\0\0\0\0\0ar87\0\0\0\0\0" \ - "ar88\0\0\0\0\0ar89\0\0\0\0\0ar90\0\0\0\0\0ar91\0\0\0\0\0" \ - "ar92\0\0\0\0\0ar93\0\0\0\0\0ar94\0\0\0\0\0ar95\0\0\0\0\0" \ - "ar96\0\0\0\0\0ar97\0\0\0\0\0ar98\0\0\0\0\0ar99\0\0\0\0\0" \ - "ar100\0\0\0\0ar101\0\0\0\0ar102\0\0\0\0ar103\0\0\0\0" \ - "ar104\0\0\0\0ar105\0\0\0\0ar106\0\0\0\0ar107\0\0\0\0" \ - "ar108\0\0\0\0ar109\0\0\0\0ar110\0\0\0\0ar111\0\0\0\0" \ - "ar112\0\0\0\0ar113\0\0\0\0ar114\0\0\0\0ar115\0\0\0\0" \ - "ar116\0\0\0\0ar117\0\0\0\0ar118\0\0\0\0ar119\0\0\0\0" \ - "ar120\0\0\0\0ar121\0\0\0\0ar122\0\0\0\0ar123\0\0\0\0" \ - "ar124\0\0\0\0ar125\0\0\0\0ar126\0\0\0\0ar127\0\0\0\0" \ - "rp\0\0\0\0\0\0\0b1\0\0\0\0\0\0\0b2\0\0\0\0\0\0\0b3\0\0\0\0\0\0\0" \ - "b4\0\0\0\0\0\0\0b5\0\0\0\0\0\0\0b6\0\0\0\0\0\0\0b7\0\0\0\0\0\0\0" \ - "pr\0\0\0\0\0\0\0cfm\0\0\0\0\0\0bsp\0\0\0\0\0\0ip\0\0\0\0\0\0\0" \ - "sp\0\0\0\0\0\0\0" - -#define NREGS ((int) (sizeof (regname_str) - 1) / regname_len) - -const char * -unw_regname (unw_regnum_t reg) -{ - if (reg < NREGS) - return regname_str + reg * regname_len; - else - return "???"; -} diff --git a/src/pal/src/libunwind/src/ia64/regs.h b/src/pal/src/libunwind/src/ia64/regs.h deleted file mode 100644 index a22a81877..000000000 --- a/src/pal/src/libunwind/src/ia64/regs.h +++ /dev/null @@ -1,73 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2002-2005 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" - -/* Apply rotation to a general register. REG must be in the range 0-127. */ - -static inline int -rotate_gr (struct cursor *c, int reg) -{ - unsigned int rrb_gr, sor; - int preg; - - sor = 8 * ((c->cfm >> 14) & 0xf); - rrb_gr = (c->cfm >> 18) & 0x7f; - - if ((unsigned) (reg - 32) >= sor) - preg = reg; - else - { - preg = reg + rrb_gr; /* apply rotation */ - if ((unsigned) (preg - 32) >= sor) - preg -= sor; /* wrap around */ - } - if (sor) - Debug (15, "sor=%u rrb.gr=%u, r%d -> r%d\n", sor, rrb_gr, reg, preg); - return preg; -} - -/* Apply rotation to a floating-point register. The number REG must - be in the range of 0-127. */ - -static inline int -rotate_fr (struct cursor *c, int reg) -{ - unsigned int rrb_fr; - int preg; - - rrb_fr = (c->cfm >> 25) & 0x7f; - if (reg < 32) - preg = reg; /* register not part of the rotating partition */ - else - { - preg = reg + rrb_fr; /* apply rotation */ - if (preg > 127) - preg -= 96; /* wrap around */ - } - if (rrb_fr) - Debug (15, "rrb.fr=%u, f%d -> f%d\n", rrb_fr, reg, preg); - return preg; -} diff --git a/src/pal/src/libunwind/src/ia64/setjmp.S b/src/pal/src/libunwind/src/ia64/setjmp.S deleted file mode 100644 index 384615b84..000000000 --- a/src/pal/src/libunwind/src/ia64/setjmp.S +++ /dev/null @@ -1,51 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2003-2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include "jmpbuf.h" - - .align 32 - - .global _setjmp - - .proc _setjmp - -_setjmp: - mov r2 = ar.bsp - st8 [r32] = r12 // jmp_buf[JB_SP] = sp - mov r3 = rp - - adds r16 = JB_RP*8, r32 - adds r17 = JB_BSP*8, r32 - mov r8 = 0 - ;; - st8 [r16] = r3 // jmp_buf[JB_RP] = rp - st8 [r17] = r2 // jmp_buf[JB_BSP] = bsp - br.ret.sptk.many rp - - .endp _setjmp -#ifdef __linux__ - /* We do not need executable stack. */ - .section .note.GNU-stack,"",@progbits -#endif diff --git a/src/pal/src/libunwind/src/ia64/siglongjmp.S b/src/pal/src/libunwind/src/ia64/siglongjmp.S deleted file mode 100644 index d77b43753..000000000 --- a/src/pal/src/libunwind/src/ia64/siglongjmp.S +++ /dev/null @@ -1,69 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2003-2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#define SIG_SETMASK 2 - - .global _UI_siglongjmp_cont - .global sigprocmask - - .align 32 - .proc siglongjmp_continuation -siglongjmp_continuation: -_UI_siglongjmp_cont: // non-function label for siglongjmp.c - .prologue - .save rp, r15 - .body - nop 0 - nop 0 - br.call.sptk.many b6 = .next - ;; - .prologue - .save ar.pfs, r33 -.next: alloc loc1 = ar.pfs, 0, 3, 3, 0 - /* - * Note: we can use the scratch stack are because the caller - * of sigsetjmp() by definition is not a leaf-procedure. - */ - st8 [sp] = r17 // store signal mask - .save rp, loc0 - mov loc0 = r15 // final continuation point - ;; - .body - mov loc2 = r16 // value to return in r8 - - mov out0 = SIG_SETMASK - mov out1 = sp - mov out2 = r0 - br.call.sptk.many rp = sigprocmask - ;; - mov rp = loc0 - mov ar.pfs = loc1 - mov r8 = loc2 - br.ret.sptk.many rp - .endp siglongjmp_continuation -#ifdef __linux__ - /* We do not need executable stack. */ - .section .note.GNU-stack,"",@progbits -#endif diff --git a/src/pal/src/libunwind/src/ia64/sigsetjmp.S b/src/pal/src/libunwind/src/ia64/sigsetjmp.S deleted file mode 100644 index 02f7af4b3..000000000 --- a/src/pal/src/libunwind/src/ia64/sigsetjmp.S +++ /dev/null @@ -1,69 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2003-2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include "jmpbuf.h" - -#define SIG_BLOCK 0 - - .align 32 - - .global __sigsetjmp - .global sigprocmask - - .proc __sigsetjmp - -__sigsetjmp: - .prologue - .save ar.pfs, r35 - alloc loc1 = ar.pfs, 2, 3, 3, 0 - add out2 = JB_MASK*8, in0 - .save rp, loc0 - mov loc0 = rp - mov out0 = SIG_BLOCK - .body - ;; - cmp.ne p6, p0 = in1, r0 - mov out1 = r0 - mov loc2 = ar.bsp -(p6) br.call.sptk.many rp = sigprocmask // sigjmp_buf[JB_MASK] = sigmask - ;; - - add r16 = JB_MASK_SAVED*8, in0 - st8 [in0] = sp, (JB_RP-JB_SP)*8 // sigjmp_buf[JB_SP] = sp - mov r8 = 0 - ;; - st8 [in0] = loc0, (JB_BSP-JB_RP)*8 // sigjmp_buf[JB_RP] = rp - st8 [r16] = in1 // sigjmp_buf[JB_MASK_SAVED] = savemask - mov rp = loc0 - ;; - st8 [in0] = loc2 // sigjmp_buf[JB_BSP] = bsp - mov.i ar.pfs = loc1 - br.ret.sptk.many rp - - .endp __sigsetjmp -#ifdef __linux__ - /* We do not need executable stack. */ - .section .note.GNU-stack,"",@progbits -#endif diff --git a/src/pal/src/libunwind/src/ia64/ucontext_i.h b/src/pal/src/libunwind/src/ia64/ucontext_i.h deleted file mode 100644 index ea32c8aaa..000000000 --- a/src/pal/src/libunwind/src/ia64/ucontext_i.h +++ /dev/null @@ -1,68 +0,0 @@ -/* Copyright (C) 2002 Hewlett-Packard Co. - Contributed by David Mosberger-Tang . - -This file is part of libunwind. - -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. */ - -/* Constants shared between setcontext() and getcontext(). Don't - install this header file. */ - -#define SIG_BLOCK 0 -#define SIG_UNBLOCK 1 -#define SIG_SETMASK 2 - -#define IA64_SC_FLAG_SYNCHRONOUS_BIT 63 - -#define SC_FLAGS 0x000 -#define SC_NAT 0x008 -#define SC_BSP 0x048 -#define SC_RNAT 0x050 -#define SC_UNAT 0x060 -#define SC_FPSR 0x068 -#define SC_PFS 0x070 -#define SC_LC 0x078 -#define SC_PR 0x080 -#define SC_BR 0x088 -#define SC_GR 0x0c8 -#define SC_FR 0x1d0 -#define SC_MASK 0x9d0 - - -#define rTMP r10 -#define rPOS r11 -#define rCPOS r14 -#define rNAT r15 -#define rFLAGS r16 - -#define rB5 r18 -#define rB4 r19 -#define rB3 r20 -#define rB2 r21 -#define rB1 r22 -#define rB0 r23 -#define rRSC r24 -#define rBSP r25 -#define rRNAT r26 -#define rUNAT r27 -#define rFPSR r28 -#define rPFS r29 -#define rLC r30 -#define rPR r31 diff --git a/src/pal/src/libunwind/src/ia64/unwind_decoder.h b/src/pal/src/libunwind/src/ia64/unwind_decoder.h deleted file mode 100644 index 7fd41740d..000000000 --- a/src/pal/src/libunwind/src/ia64/unwind_decoder.h +++ /dev/null @@ -1,477 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2001-2002 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -/* - * Generic IA-64 unwind info decoder. - * - * This file is used both by the Linux kernel and objdump. Please keep - * the two copies of this file in sync. - * - * You need to customize the decoder by defining the following - * macros/constants before including this file: - * - * Types: - * unw_word Unsigned integer type with at least 64 bits - * - * Register names: - * UNW_REG_BSP - * UNW_REG_BSPSTORE - * UNW_REG_FPSR - * UNW_REG_LC - * UNW_REG_PFS - * UNW_REG_PR - * UNW_REG_RNAT - * UNW_REG_PSP - * UNW_REG_RP - * UNW_REG_UNAT - * - * Decoder action macros: - * UNW_DEC_BAD_CODE(code) - * UNW_DEC_ABI(fmt,abi,context,arg) - * UNW_DEC_BR_GR(fmt,brmask,gr,arg) - * UNW_DEC_BR_MEM(fmt,brmask,arg) - * UNW_DEC_COPY_STATE(fmt,label,arg) - * UNW_DEC_EPILOGUE(fmt,t,ecount,arg) - * UNW_DEC_FRGR_MEM(fmt,grmask,frmask,arg) - * UNW_DEC_FR_MEM(fmt,frmask,arg) - * UNW_DEC_GR_GR(fmt,grmask,gr,arg) - * UNW_DEC_GR_MEM(fmt,grmask,arg) - * UNW_DEC_LABEL_STATE(fmt,label,arg) - * UNW_DEC_MEM_STACK_F(fmt,t,size,arg) - * UNW_DEC_MEM_STACK_V(fmt,t,arg) - * UNW_DEC_PRIUNAT_GR(fmt,r,arg) - * UNW_DEC_PRIUNAT_WHEN_GR(fmt,t,arg) - * UNW_DEC_PRIUNAT_WHEN_MEM(fmt,t,arg) - * UNW_DEC_PRIUNAT_WHEN_PSPREL(fmt,pspoff,arg) - * UNW_DEC_PRIUNAT_WHEN_SPREL(fmt,spoff,arg) - * UNW_DEC_PROLOGUE(fmt,body,rlen,arg) - * UNW_DEC_PROLOGUE_GR(fmt,rlen,mask,grsave,arg) - * UNW_DEC_REG_PSPREL(fmt,reg,pspoff,arg) - * UNW_DEC_REG_REG(fmt,src,dst,arg) - * UNW_DEC_REG_SPREL(fmt,reg,spoff,arg) - * UNW_DEC_REG_WHEN(fmt,reg,t,arg) - * UNW_DEC_RESTORE(fmt,t,abreg,arg) - * UNW_DEC_RESTORE_P(fmt,qp,t,abreg,arg) - * UNW_DEC_SPILL_BASE(fmt,pspoff,arg) - * UNW_DEC_SPILL_MASK(fmt,imaskp,arg) - * UNW_DEC_SPILL_PSPREL(fmt,t,abreg,pspoff,arg) - * UNW_DEC_SPILL_PSPREL_P(fmt,qp,t,abreg,pspoff,arg) - * UNW_DEC_SPILL_REG(fmt,t,abreg,x,ytreg,arg) - * UNW_DEC_SPILL_REG_P(fmt,qp,t,abreg,x,ytreg,arg) - * UNW_DEC_SPILL_SPREL(fmt,t,abreg,spoff,arg) - * UNW_DEC_SPILL_SPREL_P(fmt,qp,t,abreg,pspoff,arg) - */ - -static unw_word -unw_decode_uleb128 (unsigned char **dpp) -{ - unsigned shift = 0; - unw_word byte, result = 0; - unsigned char *bp = *dpp; - - while (1) - { - byte = *bp++; - result |= (byte & 0x7f) << shift; - if ((byte & 0x80) == 0) - break; - shift += 7; - } - *dpp = bp; - return result; -} - -static unsigned char * -unw_decode_x1 (unsigned char *dp, unsigned char code, void *arg) -{ - unsigned char byte1, abreg; - unw_word t, off; - - byte1 = *dp++; - t = unw_decode_uleb128 (&dp); - off = unw_decode_uleb128 (&dp); - abreg = (byte1 & 0x7f); - if (byte1 & 0x80) - UNW_DEC_SPILL_SPREL(X1, t, abreg, off, arg); - else - UNW_DEC_SPILL_PSPREL(X1, t, abreg, off, arg); - return dp; -} - -static unsigned char * -unw_decode_x2 (unsigned char *dp, unsigned char code, void *arg) -{ - unsigned char byte1, byte2, abreg, x, ytreg; - unw_word t; - - byte1 = *dp++; byte2 = *dp++; - t = unw_decode_uleb128 (&dp); - abreg = (byte1 & 0x7f); - ytreg = byte2; - x = (byte1 >> 7) & 1; - if ((byte1 & 0x80) == 0 && ytreg == 0) - UNW_DEC_RESTORE(X2, t, abreg, arg); - else - UNW_DEC_SPILL_REG(X2, t, abreg, x, ytreg, arg); - return dp; -} - -static unsigned char * -unw_decode_x3 (unsigned char *dp, unsigned char code, void *arg) -{ - unsigned char byte1, byte2, abreg, qp; - unw_word t, off; - - byte1 = *dp++; byte2 = *dp++; - t = unw_decode_uleb128 (&dp); - off = unw_decode_uleb128 (&dp); - - qp = (byte1 & 0x3f); - abreg = (byte2 & 0x7f); - - if (byte1 & 0x80) - UNW_DEC_SPILL_SPREL_P(X3, qp, t, abreg, off, arg); - else - UNW_DEC_SPILL_PSPREL_P(X3, qp, t, abreg, off, arg); - return dp; -} - -static unsigned char * -unw_decode_x4 (unsigned char *dp, unsigned char code, void *arg) -{ - unsigned char byte1, byte2, byte3, qp, abreg, x, ytreg; - unw_word t; - - byte1 = *dp++; byte2 = *dp++; byte3 = *dp++; - t = unw_decode_uleb128 (&dp); - - qp = (byte1 & 0x3f); - abreg = (byte2 & 0x7f); - x = (byte2 >> 7) & 1; - ytreg = byte3; - - if ((byte2 & 0x80) == 0 && byte3 == 0) - UNW_DEC_RESTORE_P(X4, qp, t, abreg, arg); - else - UNW_DEC_SPILL_REG_P(X4, qp, t, abreg, x, ytreg, arg); - return dp; -} - -static inline unsigned char * -unw_decode_r1 (unsigned char *dp, unsigned char code, void *arg) -{ - int body = (code & 0x20) != 0; - unw_word rlen; - - rlen = (code & 0x1f); - UNW_DEC_PROLOGUE(R1, body, rlen, arg); - return dp; -} - -static inline unsigned char * -unw_decode_r2 (unsigned char *dp, unsigned char code, void *arg) -{ - unsigned char byte1, mask, grsave; - unw_word rlen; - - byte1 = *dp++; - - mask = ((code & 0x7) << 1) | ((byte1 >> 7) & 1); - grsave = (byte1 & 0x7f); - rlen = unw_decode_uleb128 (&dp); - UNW_DEC_PROLOGUE_GR(R2, rlen, mask, grsave, arg); - return dp; -} - -static inline unsigned char * -unw_decode_r3 (unsigned char *dp, unsigned char code, void *arg) -{ - unw_word rlen; - - rlen = unw_decode_uleb128 (&dp); - UNW_DEC_PROLOGUE(R3, ((code & 0x3) == 1), rlen, arg); - return dp; -} - -static inline unsigned char * -unw_decode_p1 (unsigned char *dp, unsigned char code, void *arg) -{ - unsigned char brmask = (code & 0x1f); - - UNW_DEC_BR_MEM(P1, brmask, arg); - return dp; -} - -static inline unsigned char * -unw_decode_p2_p5 (unsigned char *dp, unsigned char code, void *arg) -{ - if ((code & 0x10) == 0) - { - unsigned char byte1 = *dp++; - - UNW_DEC_BR_GR(P2, ((code & 0xf) << 1) | ((byte1 >> 7) & 1), - (byte1 & 0x7f), arg); - } - else if ((code & 0x08) == 0) - { - unsigned char byte1 = *dp++, r, dst; - - r = ((code & 0x7) << 1) | ((byte1 >> 7) & 1); - dst = (byte1 & 0x7f); - switch (r) - { - case 0: UNW_DEC_REG_GR(P3, UNW_REG_PSP, dst, arg); break; - case 1: UNW_DEC_REG_GR(P3, UNW_REG_RP, dst, arg); break; - case 2: UNW_DEC_REG_GR(P3, UNW_REG_PFS, dst, arg); break; - case 3: UNW_DEC_REG_GR(P3, UNW_REG_PR, dst, arg); break; - case 4: UNW_DEC_REG_GR(P3, UNW_REG_UNAT, dst, arg); break; - case 5: UNW_DEC_REG_GR(P3, UNW_REG_LC, dst, arg); break; - case 6: UNW_DEC_RP_BR(P3, dst, arg); break; - case 7: UNW_DEC_REG_GR(P3, UNW_REG_RNAT, dst, arg); break; - case 8: UNW_DEC_REG_GR(P3, UNW_REG_BSP, dst, arg); break; - case 9: UNW_DEC_REG_GR(P3, UNW_REG_BSPSTORE, dst, arg); break; - case 10: UNW_DEC_REG_GR(P3, UNW_REG_FPSR, dst, arg); break; - case 11: UNW_DEC_PRIUNAT_GR(P3, dst, arg); break; - default: UNW_DEC_BAD_CODE(r); break; - } - } - else if ((code & 0x7) == 0) - UNW_DEC_SPILL_MASK(P4, dp, arg); - else if ((code & 0x7) == 1) - { - unw_word grmask, frmask, byte1, byte2, byte3; - - byte1 = *dp++; byte2 = *dp++; byte3 = *dp++; - grmask = ((byte1 >> 4) & 0xf); - frmask = ((byte1 & 0xf) << 16) | (byte2 << 8) | byte3; - UNW_DEC_FRGR_MEM(P5, grmask, frmask, arg); - } - else - UNW_DEC_BAD_CODE(code); - return dp; -} - -static inline unsigned char * -unw_decode_p6 (unsigned char *dp, unsigned char code, void *arg) -{ - int gregs = (code & 0x10) != 0; - unsigned char mask = (code & 0x0f); - - if (gregs) - UNW_DEC_GR_MEM(P6, mask, arg); - else - UNW_DEC_FR_MEM(P6, mask, arg); - return dp; -} - -static inline unsigned char * -unw_decode_p7_p10 (unsigned char *dp, unsigned char code, void *arg) -{ - unsigned char r, byte1, byte2; - unw_word t, size; - - if ((code & 0x10) == 0) - { - r = (code & 0xf); - t = unw_decode_uleb128 (&dp); - switch (r) - { - case 0: - size = unw_decode_uleb128 (&dp); - UNW_DEC_MEM_STACK_F(P7, t, size, arg); - break; - - case 1: UNW_DEC_MEM_STACK_V(P7, t, arg); break; - case 2: UNW_DEC_SPILL_BASE(P7, t, arg); break; - case 3: UNW_DEC_REG_SPREL(P7, UNW_REG_PSP, t, arg); break; - case 4: UNW_DEC_REG_WHEN(P7, UNW_REG_RP, t, arg); break; - case 5: UNW_DEC_REG_PSPREL(P7, UNW_REG_RP, t, arg); break; - case 6: UNW_DEC_REG_WHEN(P7, UNW_REG_PFS, t, arg); break; - case 7: UNW_DEC_REG_PSPREL(P7, UNW_REG_PFS, t, arg); break; - case 8: UNW_DEC_REG_WHEN(P7, UNW_REG_PR, t, arg); break; - case 9: UNW_DEC_REG_PSPREL(P7, UNW_REG_PR, t, arg); break; - case 10: UNW_DEC_REG_WHEN(P7, UNW_REG_LC, t, arg); break; - case 11: UNW_DEC_REG_PSPREL(P7, UNW_REG_LC, t, arg); break; - case 12: UNW_DEC_REG_WHEN(P7, UNW_REG_UNAT, t, arg); break; - case 13: UNW_DEC_REG_PSPREL(P7, UNW_REG_UNAT, t, arg); break; - case 14: UNW_DEC_REG_WHEN(P7, UNW_REG_FPSR, t, arg); break; - case 15: UNW_DEC_REG_PSPREL(P7, UNW_REG_FPSR, t, arg); break; - default: UNW_DEC_BAD_CODE(r); break; - } - } - else - { - switch (code & 0xf) - { - case 0x0: /* p8 */ - { - r = *dp++; - t = unw_decode_uleb128 (&dp); - switch (r) - { - case 1: UNW_DEC_REG_SPREL(P8, UNW_REG_RP, t, arg); break; - case 2: UNW_DEC_REG_SPREL(P8, UNW_REG_PFS, t, arg); break; - case 3: UNW_DEC_REG_SPREL(P8, UNW_REG_PR, t, arg); break; - case 4: UNW_DEC_REG_SPREL(P8, UNW_REG_LC, t, arg); break; - case 5: UNW_DEC_REG_SPREL(P8, UNW_REG_UNAT, t, arg); break; - case 6: UNW_DEC_REG_SPREL(P8, UNW_REG_FPSR, t, arg); break; - case 7: UNW_DEC_REG_WHEN(P8, UNW_REG_BSP, t, arg); break; - case 8: UNW_DEC_REG_PSPREL(P8, UNW_REG_BSP, t, arg); break; - case 9: UNW_DEC_REG_SPREL(P8, UNW_REG_BSP, t, arg); break; - case 10: UNW_DEC_REG_WHEN(P8, UNW_REG_BSPSTORE, t, arg); break; - case 11: UNW_DEC_REG_PSPREL(P8, UNW_REG_BSPSTORE, t, arg); break; - case 12: UNW_DEC_REG_SPREL(P8, UNW_REG_BSPSTORE, t, arg); break; - case 13: UNW_DEC_REG_WHEN(P8, UNW_REG_RNAT, t, arg); break; - case 14: UNW_DEC_REG_PSPREL(P8, UNW_REG_RNAT, t, arg); break; - case 15: UNW_DEC_REG_SPREL(P8, UNW_REG_RNAT, t, arg); break; - case 16: UNW_DEC_PRIUNAT_WHEN_GR(P8, t, arg); break; - case 17: UNW_DEC_PRIUNAT_PSPREL(P8, t, arg); break; - case 18: UNW_DEC_PRIUNAT_SPREL(P8, t, arg); break; - case 19: UNW_DEC_PRIUNAT_WHEN_MEM(P8, t, arg); break; - default: UNW_DEC_BAD_CODE(r); break; - } - } - break; - - case 0x1: - byte1 = *dp++; byte2 = *dp++; - UNW_DEC_GR_GR(P9, (byte1 & 0xf), (byte2 & 0x7f), arg); - break; - - case 0xf: /* p10 */ - byte1 = *dp++; byte2 = *dp++; - UNW_DEC_ABI(P10, byte1, byte2, arg); - break; - - case 0x9: - return unw_decode_x1 (dp, code, arg); - - case 0xa: - return unw_decode_x2 (dp, code, arg); - - case 0xb: - return unw_decode_x3 (dp, code, arg); - - case 0xc: - return unw_decode_x4 (dp, code, arg); - - default: - UNW_DEC_BAD_CODE(code); - break; - } - } - return dp; -} - -static inline unsigned char * -unw_decode_b1 (unsigned char *dp, unsigned char code, void *arg) -{ - unw_word label = (code & 0x1f); - - if ((code & 0x20) != 0) - UNW_DEC_COPY_STATE(B1, label, arg); - else - UNW_DEC_LABEL_STATE(B1, label, arg); - return dp; -} - -static inline unsigned char * -unw_decode_b2 (unsigned char *dp, unsigned char code, void *arg) -{ - unw_word t; - - t = unw_decode_uleb128 (&dp); - UNW_DEC_EPILOGUE(B2, t, (code & 0x1f), arg); - return dp; -} - -static inline unsigned char * -unw_decode_b3_x4 (unsigned char *dp, unsigned char code, void *arg) -{ - unw_word t, ecount, label; - - if ((code & 0x10) == 0) - { - t = unw_decode_uleb128 (&dp); - ecount = unw_decode_uleb128 (&dp); - UNW_DEC_EPILOGUE(B3, t, ecount, arg); - } - else if ((code & 0x07) == 0) - { - label = unw_decode_uleb128 (&dp); - if ((code & 0x08) != 0) - UNW_DEC_COPY_STATE(B4, label, arg); - else - UNW_DEC_LABEL_STATE(B4, label, arg); - } - else - switch (code & 0x7) - { - case 1: return unw_decode_x1 (dp, code, arg); - case 2: return unw_decode_x2 (dp, code, arg); - case 3: return unw_decode_x3 (dp, code, arg); - case 4: return unw_decode_x4 (dp, code, arg); - default: UNW_DEC_BAD_CODE(code); break; - } - return dp; -} - -typedef unsigned char *(*unw_decoder) (unsigned char *, unsigned char, void *); - -/* - * Decode one descriptor and return address of next descriptor. - */ -static inline unsigned char * -unw_decode (unsigned char *dp, int inside_body, void *arg) -{ - unsigned char code, primary; - - code = *dp++; - primary = code >> 5; - - if (primary < 2) - dp = unw_decode_r1 (dp, code, arg); - else if (primary == 2) - dp = unw_decode_r2 (dp, code, arg); - else if (primary == 3) - dp = unw_decode_r3 (dp, code, arg); - else if (inside_body) - switch (primary) - { - case 4: - case 5: dp = unw_decode_b1 (dp, code, arg); break; - case 6: dp = unw_decode_b2 (dp, code, arg); break; - case 7: dp = unw_decode_b3_x4 (dp, code, arg); break; - } - else - switch (primary) - { - case 4: dp = unw_decode_p1 (dp, code, arg); break; - case 5: dp = unw_decode_p2_p5 (dp, code, arg); break; - case 6: dp = unw_decode_p6 (dp, code, arg); break; - case 7: dp = unw_decode_p7_p10 (dp, code, arg); break; - } - return dp; -} diff --git a/src/pal/src/libunwind/src/ia64/unwind_i.h b/src/pal/src/libunwind/src/ia64/unwind_i.h deleted file mode 100644 index 8ccbb46c9..000000000 --- a/src/pal/src/libunwind/src/ia64/unwind_i.h +++ /dev/null @@ -1,633 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2001-2005 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#ifndef unwind_i_h -#define unwind_i_h - -#include -#include - -#include - -#include "rse.h" - -#include "libunwind_i.h" - -#define IA64_UNW_VER(x) ((x) >> 48) -#define IA64_UNW_FLAG_MASK ((unw_word_t) 0x0000ffff00000000ULL) -#define IA64_UNW_FLAG_OSMASK ((unw_word_t) 0x0000f00000000000ULL) -#define IA64_UNW_FLAG_EHANDLER(x) ((x) & (unw_word_t) 0x0000000100000000ULL) -#define IA64_UNW_FLAG_UHANDLER(x) ((x) & (unw_word_t) 0x0000000200000000ULL) -#define IA64_UNW_LENGTH(x) ((x) & (unw_word_t) 0x00000000ffffffffULL) - -#ifdef MIN -# undef MIN -#endif -#define MIN(a,b) ((a) < (b) ? (a) : (b)) - -#if !defined(HAVE_SYS_UC_ACCESS_H) && !defined(UNW_REMOTE_ONLY) - -static ALWAYS_INLINE void * -inlined_uc_addr (ucontext_t *uc, int reg, uint8_t *nat_bitnr) -{ - unw_word_t reg_addr; - void *addr; - - switch (reg) - { - case UNW_IA64_GR + 0: addr = &unw.read_only.r0; break; - case UNW_IA64_NAT + 0: addr = &unw.read_only.r0; break; - case UNW_IA64_FR + 0: addr = &unw.read_only.f0; break; - case UNW_IA64_FR + 1: - if (__BYTE_ORDER == __BIG_ENDIAN) - addr = &unw.read_only.f1_be; - else - addr = &unw.read_only.f1_le; - break; - case UNW_IA64_IP: addr = &uc->uc_mcontext.sc_br[0]; break; - case UNW_IA64_CFM: addr = &uc->uc_mcontext.sc_ar_pfs; break; - case UNW_IA64_AR_RNAT: addr = &uc->uc_mcontext.sc_ar_rnat; break; - case UNW_IA64_AR_UNAT: addr = &uc->uc_mcontext.sc_ar_unat; break; - case UNW_IA64_AR_LC: addr = &uc->uc_mcontext.sc_ar_lc; break; - case UNW_IA64_AR_FPSR: addr = &uc->uc_mcontext.sc_ar_fpsr; break; - case UNW_IA64_PR: addr = &uc->uc_mcontext.sc_pr; break; - case UNW_IA64_AR_BSPSTORE: addr = &uc->uc_mcontext.sc_ar_bsp; break; - - case UNW_IA64_GR + 4 ... UNW_IA64_GR + 7: - case UNW_IA64_GR + 12: - addr = &uc->uc_mcontext.sc_gr[reg - UNW_IA64_GR]; - break; - - case UNW_IA64_NAT + 4 ... UNW_IA64_NAT + 7: - case UNW_IA64_NAT + 12: - addr = &uc->uc_mcontext.sc_nat; - reg_addr = (unw_word_t) &uc->uc_mcontext.sc_gr[reg - UNW_IA64_NAT]; - *nat_bitnr = reg - UNW_IA64_NAT; - break; - - case UNW_IA64_BR + 1 ... UNW_IA64_BR + 5: - addr = &uc->uc_mcontext.sc_br[reg - UNW_IA64_BR]; - break; - - case UNW_IA64_FR+ 2 ... UNW_IA64_FR+ 5: - case UNW_IA64_FR+16 ... UNW_IA64_FR+31: - addr = &uc->uc_mcontext.sc_fr[reg - UNW_IA64_FR]; - break; - - default: - addr = NULL; - } - return addr; -} - -static inline void * -uc_addr (ucontext_t *uc, int reg, uint8_t *nat_bitnr) -{ - if (__builtin_constant_p (reg)) - return inlined_uc_addr (uc, reg, nat_bitnr); - else - return tdep_uc_addr (uc, reg, nat_bitnr); -} - -/* Return TRUE if ADDR points inside unw.read_only_reg. */ - -static inline long -ia64_read_only_reg (void *addr) -{ - return ((unsigned long) ((char *) addr - (char *) &unw.read_only) - < sizeof (unw.read_only)); -} - -#endif /* !defined(HAVE_SYS_UC_ACCESS_H) && !defined(UNW_REMOTE_ONLY) */ - -/* Bits 0 and 1 of a location are used to encode its type: - bit 0: set if location uses floating-point format. - bit 1: set if location is a NaT bit on memory stack. */ - -#define IA64_LOC_TYPE_FP (1 << 0) -#define IA64_LOC_TYPE_MEMSTK_NAT (1 << 1) - -#ifdef UNW_LOCAL_ONLY -#define IA64_LOC_REG(r,t) (((r) << 2) | (t)) -#define IA64_LOC_ADDR(a,t) (((a) & ~0x3) | (t)) -#define IA64_LOC_UC_ADDR(a,t) IA64_LOC_ADDR(a, t) -#define IA64_NULL_LOC (0) - -#define IA64_GET_REG(l) ((l) >> 2) -#define IA64_GET_ADDR(l) ((l) & ~0x3) -#define IA64_IS_NULL_LOC(l) ((l) == 0) -#define IA64_IS_FP_LOC(l) (((l) & IA64_LOC_TYPE_FP) != 0) -#define IA64_IS_MEMSTK_NAT(l) (((l) & IA64_LOC_TYPE_MEMSTK_NAT) != 0) -#define IA64_IS_REG_LOC(l) 0 -#define IA64_IS_UC_LOC(l) 0 - -#define IA64_REG_LOC(c,r) ((unw_word_t) uc_addr((c)->as_arg, r, NULL)) -#define IA64_REG_NAT_LOC(c,r,n) ((unw_word_t) uc_addr((c)->as_arg, r, n)) -#define IA64_FPREG_LOC(c,r) \ - ((unw_word_t) uc_addr((c)->as_arg, (r), NULL) | IA64_LOC_TYPE_FP) - -# define ia64_find_proc_info(c,ip,n) \ - tdep_find_proc_info(unw_local_addr_space, (ip), &(c)->pi, (n), \ - (c)->as_arg) -# define ia64_put_unwind_info(c, pi) do { ; } while (0) - -/* Note: the register accessors (ia64_{get,set}{,fp}()) must check for - NULL locations because uc_addr() returns NULL for unsaved - registers. */ - -static inline int -ia64_getfp (struct cursor *c, unw_word_t loc, unw_fpreg_t *val) -{ - if (IA64_IS_NULL_LOC (loc)) - { - Debug (16, "access to unsaved register\n"); - return -UNW_EBADREG; - } - *val = *(unw_fpreg_t *) IA64_GET_ADDR (loc); - return 0; -} - -static inline int -ia64_putfp (struct cursor *c, unw_word_t loc, unw_fpreg_t val) -{ - unw_fpreg_t *addr = (unw_fpreg_t *) IA64_GET_ADDR (loc); - - if (IA64_IS_NULL_LOC (loc)) - { - Debug (16, "access to unsaved register\n"); - return -UNW_EBADREG; - } - else if (ia64_read_only_reg (addr)) - { - Debug (16, "attempt to read-only register\n"); - return -UNW_EREADONLYREG; - } - *addr = val; - return 0; -} - -static inline int -ia64_get (struct cursor *c, unw_word_t loc, unw_word_t *val) -{ - if (IA64_IS_NULL_LOC (loc)) - { - Debug (16, "access to unsaved register\n"); - return -UNW_EBADREG; - } - *val = *(unw_word_t *) IA64_GET_ADDR (loc); - return 0; -} - -static inline int -ia64_put (struct cursor *c, unw_word_t loc, unw_word_t val) -{ - unw_word_t *addr = (unw_word_t *) IA64_GET_ADDR (loc); - - if (IA64_IS_NULL_LOC (loc)) - { - Debug (16, "access to unsaved register\n"); - return -UNW_EBADREG; - } - else if (ia64_read_only_reg (addr)) - { - Debug (16, "attempt to read-only register\n"); - return -UNW_EREADONLYREG; - } - *addr = val; - return 0; -} - -#else /* !UNW_LOCAL_ONLY */ - -/* Bits 0 and 1 of the second word (w1) of a location are used - to further distinguish what location we're dealing with: - - bit 0: set if the location is a register - bit 1: set of the location is accessed via uc_access(3) */ -#define IA64_LOC_TYPE_REG (1 << 0) -#define IA64_LOC_TYPE_UC (1 << 1) - -#define IA64_LOC_REG(r,t) ((ia64_loc_t) { ((r) << 2) | (t), \ - IA64_LOC_TYPE_REG }) -#define IA64_LOC_ADDR(a,t) ((ia64_loc_t) { ((a) & ~0x3) | (t), 0 }) -#define IA64_LOC_UC_ADDR(a,t) ((ia64_loc_t) { ((a) & ~0x3) | (t), \ - IA64_LOC_TYPE_UC }) -#define IA64_LOC_UC_REG(r,a) ((ia64_loc_t) { ((r) << 2), \ - ((a) | IA64_LOC_TYPE_REG \ - | IA64_LOC_TYPE_UC) }) -#define IA64_NULL_LOC ((ia64_loc_t) { 0, 0 }) - -#define IA64_GET_REG(l) ((l).w0 >> 2) -#define IA64_GET_ADDR(l) ((l).w0 & ~0x3) -#define IA64_GET_AUX_ADDR(l) ((l).w1 & ~0x3) -#define IA64_IS_NULL_LOC(l) (((l).w0 | (l).w1) == 0) -#define IA64_IS_FP_LOC(l) (((l).w0 & IA64_LOC_TYPE_FP) != 0) -#define IA64_IS_MEMSTK_NAT(l) (((l).w0 & IA64_LOC_TYPE_MEMSTK_NAT) != 0) -#define IA64_IS_REG_LOC(l) (((l).w1 & IA64_LOC_TYPE_REG) != 0) -#define IA64_IS_UC_LOC(l) (((l).w1 & IA64_LOC_TYPE_UC) != 0) - -#define IA64_REG_LOC(c,r) IA64_LOC_REG ((r), 0) -#define IA64_REG_NAT_LOC(c,r,n) IA64_LOC_REG ((r), 0) -#define IA64_FPREG_LOC(c,r) IA64_LOC_REG ((r), IA64_LOC_TYPE_FP) - -# define ia64_find_proc_info(c,ip,n) \ - (*(c)->as->acc.find_proc_info)((c)->as, (ip), &(c)->pi, (n), \ - (c)->as_arg) -# define ia64_put_unwind_info(c,pi) \ - (*(c)->as->acc.put_unwind_info)((c)->as, (pi), (c)->as_arg) - -#define ia64_uc_access_reg UNW_OBJ(uc_access_reg) -#define ia64_uc_access_fpreg UNW_OBJ(uc_access_fpreg) - -extern int ia64_uc_access_reg (struct cursor *c, ia64_loc_t loc, - unw_word_t *valp, int write); -extern int ia64_uc_access_fpreg (struct cursor *c, ia64_loc_t loc, - unw_fpreg_t *valp, int write); - -static inline int -ia64_getfp (struct cursor *c, ia64_loc_t loc, unw_fpreg_t *val) -{ - unw_word_t addr; - int ret; - - if (IA64_IS_NULL_LOC (loc)) - { - Debug (16, "access to unsaved register\n"); - return -UNW_EBADREG; - } - - if (IA64_IS_UC_LOC (loc)) - return ia64_uc_access_fpreg (c, loc, val, 0); - - if (IA64_IS_REG_LOC (loc)) - return (*c->as->acc.access_fpreg) (c->as, IA64_GET_REG (loc), - val, 0, c->as_arg); - - addr = IA64_GET_ADDR (loc); - ret = (*c->as->acc.access_mem) (c->as, addr + 0, &val->raw.bits[0], 0, - c->as_arg); - if (ret < 0) - return ret; - - return (*c->as->acc.access_mem) (c->as, addr + 8, &val->raw.bits[1], 0, - c->as_arg); -} - -static inline int -ia64_putfp (struct cursor *c, ia64_loc_t loc, unw_fpreg_t val) -{ - unw_word_t addr; - int ret; - - if (IA64_IS_NULL_LOC (loc)) - { - Debug (16, "access to unsaved register\n"); - return -UNW_EBADREG; - } - - if (IA64_IS_UC_LOC (loc)) - return ia64_uc_access_fpreg (c, loc, &val, 1); - - if (IA64_IS_REG_LOC (loc)) - return (*c->as->acc.access_fpreg) (c->as, IA64_GET_REG (loc), &val, 1, - c->as_arg); - - addr = IA64_GET_ADDR (loc); - ret = (*c->as->acc.access_mem) (c->as, addr + 0, &val.raw.bits[0], 1, - c->as_arg); - if (ret < 0) - return ret; - - return (*c->as->acc.access_mem) (c->as, addr + 8, &val.raw.bits[1], 1, - c->as_arg); -} - -/* Get the 64 data bits from location LOC. If bit 0 is cleared, LOC - is a memory address, otherwise it is a register number. If the - register is a floating-point register, the 64 bits are read from - the significand bits. */ - -static inline int -ia64_get (struct cursor *c, ia64_loc_t loc, unw_word_t *val) -{ - if (IA64_IS_NULL_LOC (loc)) - { - Debug (16, "access to unsaved register\n"); - return -UNW_EBADREG; - } - - if (IA64_IS_FP_LOC (loc)) - { - unw_fpreg_t tmp; - int ret; - - ret = ia64_getfp (c, loc, &tmp); - if (ret < 0) - return ret; - - if (c->as->big_endian) - *val = tmp.raw.bits[1]; - else - *val = tmp.raw.bits[0]; - return 0; - } - - if (IA64_IS_UC_LOC (loc)) - return ia64_uc_access_reg (c, loc, val, 0); - - if (IA64_IS_REG_LOC (loc)) - return (*c->as->acc.access_reg)(c->as, IA64_GET_REG (loc), val, 0, - c->as_arg); - else - return (*c->as->acc.access_mem)(c->as, IA64_GET_ADDR (loc), val, 0, - c->as_arg); -} - -static inline int -ia64_put (struct cursor *c, ia64_loc_t loc, unw_word_t val) -{ - if (IA64_IS_NULL_LOC (loc)) - { - Debug (16, "access to unsaved register\n"); - return -UNW_EBADREG; - } - - if (IA64_IS_FP_LOC (loc)) - { - unw_fpreg_t tmp; - - memset (&tmp, 0, sizeof (tmp)); - if (c->as->big_endian) - tmp.raw.bits[1] = val; - else - tmp.raw.bits[0] = val; - return ia64_putfp (c, loc, tmp); - } - - if (IA64_IS_UC_LOC (loc)) - return ia64_uc_access_reg (c, loc, &val, 1); - - if (IA64_IS_REG_LOC (loc)) - return (*c->as->acc.access_reg)(c->as, IA64_GET_REG (loc), &val, 1, - c->as_arg); - else - return (*c->as->acc.access_mem)(c->as, IA64_GET_ADDR (loc), &val, 1, - c->as_arg); -} - -#endif /* !UNW_LOCAL_ONLY */ - -struct ia64_unwind_block - { - unw_word_t header; - unw_word_t desc[0]; /* unwind descriptors */ - - /* Personality routine and language-specific data follow behind - descriptors. */ - }; - -enum ia64_where - { - IA64_WHERE_NONE, /* register isn't saved at all */ - IA64_WHERE_GR, /* register is saved in a general register */ - IA64_WHERE_FR, /* register is saved in a floating-point register */ - IA64_WHERE_BR, /* register is saved in a branch register */ - IA64_WHERE_SPREL, /* register is saved on memstack (sp-relative) */ - IA64_WHERE_PSPREL, /* register is saved on memstack (psp-relative) */ - - /* At the end of each prologue these locations get resolved to - IA64_WHERE_PSPREL and IA64_WHERE_GR, respectively: */ - - IA64_WHERE_SPILL_HOME, /* register is saved in its spill home */ - IA64_WHERE_GR_SAVE /* register is saved in next general register */ - }; - -#define IA64_WHEN_NEVER 0x7fffffff - -struct ia64_reg_info - { - unw_word_t val; /* save location: register number or offset */ - enum ia64_where where; /* where the register gets saved */ - int when; /* when the register gets saved */ - }; - -struct ia64_labeled_state; /* opaque structure */ - -struct ia64_reg_state - { - struct ia64_reg_state *next; /* next (outer) element on state stack */ - struct ia64_reg_info reg[IA64_NUM_PREGS]; /* register save locations */ - }; - -struct ia64_state_record - { - unsigned int first_region : 1; /* is this the first region? */ - unsigned int done : 1; /* are we done scanning descriptors? */ - unsigned int any_spills : 1; /* got any register spills? */ - unsigned int in_body : 1; /* are we inside prologue or body? */ - uint8_t *imask; /* imask of spill_mask record or NULL */ - uint16_t abi_marker; - - unw_word_t pr_val; /* predicate values */ - unw_word_t pr_mask; /* predicate mask */ - - long spill_offset; /* psp-relative offset for spill base */ - int region_start; - int region_len; - int when_sp_restored; - int epilogue_count; - int when_target; - - uint8_t gr_save_loc; /* next save register */ - uint8_t return_link_reg; /* branch register used as return pointer */ - - struct ia64_labeled_state *labeled_states; - struct ia64_reg_state curr; - }; - -struct ia64_labeled_state - { - struct ia64_labeled_state *next; /* next label (or NULL) */ - unsigned long label; /* label for this state */ - struct ia64_reg_state saved_state; - }; - -/* Convenience macros: */ -#define ia64_make_proc_info UNW_OBJ(make_proc_info) -#define ia64_fetch_proc_info UNW_OBJ(fetch_proc_info) -#define ia64_create_state_record UNW_OBJ(create_state_record) -#define ia64_free_state_record UNW_OBJ(free_state_record) -#define ia64_find_save_locs UNW_OBJ(find_save_locs) -#define ia64_validate_cache UNW_OBJ(ia64_validate_cache) -#define ia64_local_validate_cache UNW_OBJ(ia64_local_validate_cache) -#define ia64_per_thread_cache UNW_OBJ(per_thread_cache) -#define ia64_scratch_loc UNW_OBJ(scratch_loc) -#define ia64_local_resume UNW_OBJ(local_resume) -#define ia64_local_addr_space_init UNW_OBJ(local_addr_space_init) -#define ia64_strloc UNW_OBJ(strloc) -#define ia64_install_cursor UNW_OBJ(install_cursor) -#define rbs_switch UNW_OBJ(rbs_switch) -#define rbs_find_stacked UNW_OBJ(rbs_find_stacked) - -extern int ia64_make_proc_info (struct cursor *c); -extern int ia64_fetch_proc_info (struct cursor *c, unw_word_t ip, - int need_unwind_info); -/* The proc-info must be valid for IP before this routine can be - called: */ -extern int ia64_create_state_record (struct cursor *c, - struct ia64_state_record *sr); -extern int ia64_free_state_record (struct ia64_state_record *sr); -extern int ia64_find_save_locs (struct cursor *c); -extern void ia64_validate_cache (unw_addr_space_t as, void *arg); -extern int ia64_local_validate_cache (unw_addr_space_t as, void *arg); -extern void ia64_local_addr_space_init (void); -extern ia64_loc_t ia64_scratch_loc (struct cursor *c, unw_regnum_t reg, - uint8_t *nat_bitnr); - -extern NORETURN void ia64_install_cursor (struct cursor *c, - unw_word_t pri_unat, - unw_word_t *extra, - unw_word_t bspstore, - unw_word_t dirty_size, - unw_word_t *dirty_partition, - unw_word_t dirty_rnat); -extern int ia64_local_resume (unw_addr_space_t as, unw_cursor_t *cursor, - void *arg); -extern int rbs_switch (struct cursor *c, - unw_word_t saved_bsp, unw_word_t saved_bspstore, - ia64_loc_t saved_rnat_loc); -extern int rbs_find_stacked (struct cursor *c, unw_word_t regs_to_skip, - ia64_loc_t *locp, ia64_loc_t *rnat_locp); - -#ifndef UNW_REMOTE_ONLY -# define NEED_RBS_COVER_AND_FLUSH -# define rbs_cover_and_flush UNW_OBJ(rbs_cover_and_flush) - extern int rbs_cover_and_flush (struct cursor *c, unw_word_t nregs, - unw_word_t *dirty_partition, - unw_word_t *dirty_rnat, - unw_word_t *bspstore); -#endif - -/* Warning: ia64_strloc() is for debugging only and it is NOT re-entrant! */ -extern const char *ia64_strloc (ia64_loc_t loc); - -/* Return true if the register-backing store is inside a ucontext_t - that needs to be accessed via uc_access(3). */ - -static inline int -rbs_on_uc (struct rbs_area *rbs) -{ - return IA64_IS_UC_LOC (rbs->rnat_loc) && !IA64_IS_REG_LOC (rbs->rnat_loc); -} - -/* Return true if BSP points to a word that's stored on register - backing-store RBS. */ -static inline int -rbs_contains (struct rbs_area *rbs, unw_word_t bsp) -{ - int result; - - /* Caveat: this takes advantage of unsigned arithmetic. The full - test is (bsp >= rbs->end - rbs->size) && (bsp < rbs->end). We - take advantage of the fact that -n == ~n + 1. */ - result = bsp - rbs->end > ~rbs->size; - Debug (16, "0x%lx in [0x%lx-0x%lx) => %d\n", - (long) bsp, (long) (rbs->end - rbs->size), (long) rbs->end, result); - return result; -} - -static inline ia64_loc_t -rbs_get_rnat_loc (struct rbs_area *rbs, unw_word_t bsp) -{ - unw_word_t rnat_addr = rse_rnat_addr (bsp); - ia64_loc_t rnat_loc; - - if (rbs_contains (rbs, rnat_addr)) - { - if (rbs_on_uc (rbs)) - rnat_loc = IA64_LOC_UC_ADDR (rnat_addr, 0); - else - rnat_loc = IA64_LOC_ADDR (rnat_addr, 0); - } - else - rnat_loc = rbs->rnat_loc; - return rnat_loc; -} - -static inline ia64_loc_t -rbs_loc (struct rbs_area *rbs, unw_word_t bsp) -{ - if (rbs_on_uc (rbs)) - return IA64_LOC_UC_ADDR (bsp, 0); - else - return IA64_LOC_ADDR (bsp, 0); -} - -static inline int -ia64_get_stacked (struct cursor *c, unw_word_t reg, - ia64_loc_t *locp, ia64_loc_t *rnat_locp) -{ - struct rbs_area *rbs = c->rbs_area + c->rbs_curr; - unw_word_t addr, regs_to_skip = reg - 32; - int ret = 0; - - assert (reg >= 32 && reg < 128); - - addr = rse_skip_regs (c->bsp, regs_to_skip); - if (locp) - *locp = rbs_loc (rbs, addr); - if (rnat_locp) - *rnat_locp = rbs_get_rnat_loc (rbs, addr); - - if (!rbs_contains (rbs, addr)) - ret = rbs_find_stacked (c, regs_to_skip, locp, rnat_locp); - return ret; -} - -/* The UNaT slot # calculation is identical to the one for RNaT slots, - but for readability/clarity, we don't want to use - ia64_rnat_slot_num() directly. */ -#define ia64_unat_slot_num(addr) rse_slot_num(addr) - -/* The following are helper macros which makes it easier for libunwind - to be used in the kernel. They allow the kernel to optimize away - any unused code without littering everything with #ifdefs. */ -#define ia64_is_big_endian(c) ((c)->as->big_endian) -#define ia64_get_abi(c) ((c)->as->abi) -#define ia64_set_abi(c, v) ((c)->as->abi = (v)) -#define ia64_get_abi_marker(c) ((c)->last_abi_marker) - -/* XXX should be in glibc: */ -#ifndef IA64_SC_FLAG_ONSTACK -# define IA64_SC_FLAG_ONSTACK_BIT 0 /* running on signal stack? */ -# define IA64_SC_FLAG_IN_SYSCALL_BIT 1 /* did signal interrupt a syscall? */ -# define IA64_SC_FLAG_FPH_VALID_BIT 2 /* is state in f[32]-f[127] valid? */ - -# define IA64_SC_FLAG_ONSTACK (1 << IA64_SC_FLAG_ONSTACK_BIT) -# define IA64_SC_FLAG_IN_SYSCALL (1 << IA64_SC_FLAG_IN_SYSCALL_BIT) -# define IA64_SC_FLAG_FPH_VALID (1 << IA64_SC_FLAG_FPH_VALID_BIT) -#endif - -#endif /* unwind_i_h */ diff --git a/src/pal/src/libunwind/src/libunwind-generic.pc.in b/src/pal/src/libunwind/src/libunwind-generic.pc.in deleted file mode 100644 index 1f3baffe5..000000000 --- a/src/pal/src/libunwind/src/libunwind-generic.pc.in +++ /dev/null @@ -1,11 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ - -Name: libunwind-generic -Description: libunwind generic library -Version: @VERSION@ -Requires: libunwind -Libs: -L${libdir} -lunwind-generic -Cflags: -I${includedir} diff --git a/src/pal/src/libunwind/src/mi/Gdestroy_addr_space.c b/src/pal/src/libunwind/src/mi/Gdestroy_addr_space.c deleted file mode 100644 index 504558e1a..000000000 --- a/src/pal/src/libunwind/src/mi/Gdestroy_addr_space.c +++ /dev/null @@ -1,37 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2002, 2005 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include "libunwind_i.h" - -void -unw_destroy_addr_space (unw_addr_space_t as) -{ -#ifndef UNW_LOCAL_ONLY -# if UNW_DEBUG - memset (as, 0, sizeof (*as)); -# endif - free (as); -#endif -} diff --git a/src/pal/src/libunwind/src/mi/Gdyn-extract.c b/src/pal/src/libunwind/src/mi/Gdyn-extract.c deleted file mode 100644 index 5f7682e65..000000000 --- a/src/pal/src/libunwind/src/mi/Gdyn-extract.c +++ /dev/null @@ -1,64 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2001-2002, 2005 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include "libunwind_i.h" - -HIDDEN int -unwi_extract_dynamic_proc_info (unw_addr_space_t as, unw_word_t ip, - unw_proc_info_t *pi, unw_dyn_info_t *di, - int need_unwind_info, void *arg) -{ - pi->start_ip = di->start_ip; - pi->end_ip = di->end_ip; - pi->gp = di->gp; - pi->format = di->format; - switch (di->format) - { - case UNW_INFO_FORMAT_DYNAMIC: - pi->handler = di->u.pi.handler; - pi->lsda = 0; - pi->flags = di->u.pi.flags; - pi->unwind_info_size = 0; - if (need_unwind_info) - pi->unwind_info = di; - else - pi->unwind_info = NULL; - return 0; - - case UNW_INFO_FORMAT_TABLE: - case UNW_INFO_FORMAT_REMOTE_TABLE: - case UNW_INFO_FORMAT_ARM_EXIDX: - case UNW_INFO_FORMAT_IP_OFFSET: -#ifdef tdep_search_unwind_table - /* call platform-specific search routine: */ - return tdep_search_unwind_table (as, ip, di, pi, need_unwind_info, arg); -#else - /* fall through */ -#endif - default: - break; - } - return -UNW_EINVAL; -} diff --git a/src/pal/src/libunwind/src/mi/Gdyn-remote.c b/src/pal/src/libunwind/src/mi/Gdyn-remote.c deleted file mode 100644 index 40a5ad8b5..000000000 --- a/src/pal/src/libunwind/src/mi/Gdyn-remote.c +++ /dev/null @@ -1,326 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2001-2002, 2005 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include - -#include "libunwind_i.h" -#include "remote.h" - -static void -free_regions (unw_dyn_region_info_t *region) -{ - if (region->next) - free_regions (region->next); - free (region); -} - -static int -intern_op (unw_addr_space_t as, unw_accessors_t *a, unw_word_t *addr, - unw_dyn_op_t *op, void *arg) -{ - int ret; - - if ((ret = fetch8 (as, a, addr, &op->tag, arg)) < 0 - || (ret = fetch8 (as, a, addr, &op->qp, arg)) < 0 - || (ret = fetch16 (as, a, addr, &op->reg, arg)) < 0 - || (ret = fetch32 (as, a, addr, &op->when, arg)) < 0 - || (ret = fetchw (as, a, addr, &op->val, arg)) < 0) - return ret; - return 0; -} - -static int -intern_regions (unw_addr_space_t as, unw_accessors_t *a, - unw_word_t *addr, unw_dyn_region_info_t **regionp, void *arg) -{ - uint32_t insn_count, op_count, i; - unw_dyn_region_info_t *region; - unw_word_t next_addr; - int ret; - - *regionp = NULL; - - if (!*addr) - return 0; /* NULL region-list */ - - if ((ret = fetchw (as, a, addr, &next_addr, arg)) < 0 - || (ret = fetch32 (as, a, addr, (int32_t *) &insn_count, arg)) < 0 - || (ret = fetch32 (as, a, addr, (int32_t *) &op_count, arg)) < 0) - return ret; - - region = calloc (1, _U_dyn_region_info_size (op_count)); - if (!region) - { - ret = -UNW_ENOMEM; - goto out; - } - - region->insn_count = insn_count; - region->op_count = op_count; - for (i = 0; i < op_count; ++i) - if ((ret = intern_op (as, a, addr, region->op + i, arg)) < 0) - goto out; - - if (next_addr) - if ((ret = intern_regions (as, a, &next_addr, ®ion->next, arg)) < 0) - goto out; - - *regionp = region; - return 0; - - out: - if (region) - free_regions (region); - return ret; -} - -static int -intern_array (unw_addr_space_t as, unw_accessors_t *a, - unw_word_t *addr, unw_word_t table_len, unw_word_t **table_data, - void *arg) -{ - unw_word_t i, *data = calloc (table_len, WSIZE); - int ret = 0; - - if (!data) - { - ret = -UNW_ENOMEM; - goto out; - } - - for (i = 0; i < table_len; ++i) - if (fetchw (as, a, addr, data + i, arg) < 0) - goto out; - - *table_data = data; - return 0; - - out: - if (data) - free (data); - return ret; -} - -static void -free_dyn_info (unw_dyn_info_t *di) -{ - switch (di->format) - { - case UNW_INFO_FORMAT_DYNAMIC: - if (di->u.pi.regions) - { - free_regions (di->u.pi.regions); - di->u.pi.regions = NULL; - } - break; - - case UNW_INFO_FORMAT_TABLE: - if (di->u.ti.table_data) - { - free (di->u.ti.table_data); - di->u.ti.table_data = NULL; - } - break; - - case UNW_INFO_FORMAT_REMOTE_TABLE: - default: - break; - } -} - -static int -intern_dyn_info (unw_addr_space_t as, unw_accessors_t *a, - unw_word_t *addr, unw_dyn_info_t *di, void *arg) -{ - unw_word_t first_region; - int ret; - - switch (di->format) - { - case UNW_INFO_FORMAT_DYNAMIC: - if ((ret = fetchw (as, a, addr, &di->u.pi.name_ptr, arg)) < 0 - || (ret = fetchw (as, a, addr, &di->u.pi.handler, arg)) < 0 - || (ret = fetch32 (as, a, addr, - (int32_t *) &di->u.pi.flags, arg)) < 0) - goto out; - *addr += 4; /* skip over pad0 */ - if ((ret = fetchw (as, a, addr, &first_region, arg)) < 0 - || (ret = intern_regions (as, a, &first_region, &di->u.pi.regions, - arg)) < 0) - goto out; - break; - - case UNW_INFO_FORMAT_TABLE: - if ((ret = fetchw (as, a, addr, &di->u.ti.name_ptr, arg)) < 0 - || (ret = fetchw (as, a, addr, &di->u.ti.segbase, arg)) < 0 - || (ret = fetchw (as, a, addr, &di->u.ti.table_len, arg)) < 0 - || (ret = intern_array (as, a, addr, di->u.ti.table_len, - &di->u.ti.table_data, arg)) < 0) - goto out; - break; - - case UNW_INFO_FORMAT_REMOTE_TABLE: - if ((ret = fetchw (as, a, addr, &di->u.rti.name_ptr, arg)) < 0 - || (ret = fetchw (as, a, addr, &di->u.rti.segbase, arg)) < 0 - || (ret = fetchw (as, a, addr, &di->u.rti.table_len, arg)) < 0 - || (ret = fetchw (as, a, addr, &di->u.rti.table_data, arg)) < 0) - goto out; - break; - - default: - ret = -UNW_ENOINFO; - goto out; - } - return 0; - - out: - free_dyn_info (di); - return ret; -} - -HIDDEN int -unwi_dyn_remote_find_proc_info (unw_addr_space_t as, unw_word_t ip, - unw_proc_info_t *pi, - int need_unwind_info, void *arg) -{ - unw_accessors_t *a = unw_get_accessors_int (as); - unw_word_t dyn_list_addr, addr, next_addr, gen1, gen2, start_ip, end_ip; - unw_dyn_info_t *di = NULL; - int ret; - - if (as->dyn_info_list_addr) - dyn_list_addr = as->dyn_info_list_addr; - else - { - if ((*a->get_dyn_info_list_addr) (as, &dyn_list_addr, arg) < 0) - return -UNW_ENOINFO; - if (as->caching_policy != UNW_CACHE_NONE) - as->dyn_info_list_addr = dyn_list_addr; - } - - do - { - addr = dyn_list_addr; - - ret = -UNW_ENOINFO; - - if (fetchw (as, a, &addr, &gen1, arg) < 0 - || fetchw (as, a, &addr, &next_addr, arg) < 0) - return ret; - - for (addr = next_addr; addr != 0; addr = next_addr) - { - if (fetchw (as, a, &addr, &next_addr, arg) < 0) - goto recheck; /* only fail if generation # didn't change */ - - addr += WSIZE; /* skip over prev_addr */ - - if (fetchw (as, a, &addr, &start_ip, arg) < 0 - || fetchw (as, a, &addr, &end_ip, arg) < 0) - goto recheck; /* only fail if generation # didn't change */ - - if (ip >= start_ip && ip < end_ip) - { - if (!di) - di = calloc (1, sizeof (*di)); - - di->start_ip = start_ip; - di->end_ip = end_ip; - - if (fetchw (as, a, &addr, &di->gp, arg) < 0 - || fetch32 (as, a, &addr, &di->format, arg) < 0) - goto recheck; /* only fail if generation # didn't change */ - - addr += 4; /* skip over padding */ - - if (need_unwind_info - && intern_dyn_info (as, a, &addr, di, arg) < 0) - goto recheck; /* only fail if generation # didn't change */ - - if (unwi_extract_dynamic_proc_info (as, ip, pi, di, - need_unwind_info, arg) < 0) - { - free_dyn_info (di); - goto recheck; /* only fail if generation # didn't change */ - } - ret = 0; /* OK, found it */ - break; - } - } - - /* Re-check generation number to ensure the data we have is - consistent. */ - recheck: - addr = dyn_list_addr; - if (fetchw (as, a, &addr, &gen2, arg) < 0) - return ret; - } - while (gen1 != gen2); - - if (ret < 0 && di) - free (di); - - return ret; -} - -HIDDEN void -unwi_dyn_remote_put_unwind_info (unw_addr_space_t as, unw_proc_info_t *pi, - void *arg) -{ - if (!pi->unwind_info) - return; - - free_dyn_info (pi->unwind_info); - free (pi->unwind_info); - pi->unwind_info = NULL; -} - -/* Returns 1 if the cache is up-to-date or -1 if the cache contained - stale data and had to be flushed. */ - -HIDDEN int -unwi_dyn_validate_cache (unw_addr_space_t as, void *arg) -{ - unw_word_t addr, gen; - unw_accessors_t *a; - - if (!as->dyn_info_list_addr) - /* If we don't have the dyn_info_list_addr, we don't have anything - in the cache. */ - return 0; - - a = unw_get_accessors_int (as); - addr = as->dyn_info_list_addr; - - if (fetchw (as, a, &addr, &gen, arg) < 0) - return 1; - - if (gen == as->dyn_generation) - return 1; - - unw_flush_cache (as, 0, 0); - as->dyn_generation = gen; - return -1; -} diff --git a/src/pal/src/libunwind/src/mi/Gfind_dynamic_proc_info.c b/src/pal/src/libunwind/src/mi/Gfind_dynamic_proc_info.c deleted file mode 100644 index 98d350128..000000000 --- a/src/pal/src/libunwind/src/mi/Gfind_dynamic_proc_info.c +++ /dev/null @@ -1,91 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2001-2002, 2005 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include "libunwind_i.h" - -#ifdef UNW_REMOTE_ONLY - -static inline int -local_find_proc_info (unw_addr_space_t as, unw_word_t ip, unw_proc_info_t *pi, - int need_unwind_info, void *arg) -{ - return -UNW_ENOINFO; -} - -#else /* !UNW_REMOTE_ONLY */ - -static inline int -local_find_proc_info (unw_addr_space_t as, unw_word_t ip, unw_proc_info_t *pi, - int need_unwind_info, void *arg) -{ - unw_dyn_info_list_t *list; - unw_dyn_info_t *di; - -#ifndef UNW_LOCAL_ONLY -# pragma weak _U_dyn_info_list_addr - if (!_U_dyn_info_list_addr) - return -UNW_ENOINFO; -#endif - - list = (unw_dyn_info_list_t *) (uintptr_t) _U_dyn_info_list_addr (); - for (di = list->first; di; di = di->next) - if (ip >= di->start_ip && ip < di->end_ip) - return unwi_extract_dynamic_proc_info (as, ip, pi, di, need_unwind_info, - arg); - return -UNW_ENOINFO; -} - -#endif /* !UNW_REMOTE_ONLY */ - -#ifdef UNW_LOCAL_ONLY - -static inline int -remote_find_proc_info (unw_addr_space_t as, unw_word_t ip, unw_proc_info_t *pi, - int need_unwind_info, void *arg) -{ - return -UNW_ENOINFO; -} - -#else /* !UNW_LOCAL_ONLY */ - -static inline int -remote_find_proc_info (unw_addr_space_t as, unw_word_t ip, unw_proc_info_t *pi, - int need_unwind_info, void *arg) -{ - return unwi_dyn_remote_find_proc_info (as, ip, pi, need_unwind_info, arg); -} - -#endif /* !UNW_LOCAL_ONLY */ - -HIDDEN int -unwi_find_dynamic_proc_info (unw_addr_space_t as, unw_word_t ip, - unw_proc_info_t *pi, int need_unwind_info, - void *arg) -{ - if (as == unw_local_addr_space) - return local_find_proc_info (as, ip, pi, need_unwind_info, arg); - else - return remote_find_proc_info (as, ip, pi, need_unwind_info, arg); -} diff --git a/src/pal/src/libunwind/src/mi/Gget_accessors.c b/src/pal/src/libunwind/src/mi/Gget_accessors.c deleted file mode 100644 index 31a6fbaf0..000000000 --- a/src/pal/src/libunwind/src/mi/Gget_accessors.c +++ /dev/null @@ -1,37 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2002, 2004-2005 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include "libunwind_i.h" - -HIDDEN ALIAS(unw_get_accessors) unw_accessors_t * -unw_get_accessors_int (unw_addr_space_t as); - -unw_accessors_t * -unw_get_accessors (unw_addr_space_t as) -{ - if (!tdep_init_done) - tdep_init (); - return &as->acc; -} diff --git a/src/pal/src/libunwind/src/mi/Gget_fpreg.c b/src/pal/src/libunwind/src/mi/Gget_fpreg.c deleted file mode 100644 index f32b12862..000000000 --- a/src/pal/src/libunwind/src/mi/Gget_fpreg.c +++ /dev/null @@ -1,34 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2004-2005 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include "libunwind_i.h" - -int -unw_get_fpreg (unw_cursor_t *cursor, int regnum, unw_fpreg_t *valp) -{ - struct cursor *c = (struct cursor *) cursor; - - return tdep_access_fpreg (c, regnum, valp, 0); -} diff --git a/src/pal/src/libunwind/src/mi/Gget_proc_info_by_ip.c b/src/pal/src/libunwind/src/mi/Gget_proc_info_by_ip.c deleted file mode 100644 index 2697ff84e..000000000 --- a/src/pal/src/libunwind/src/mi/Gget_proc_info_by_ip.c +++ /dev/null @@ -1,39 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2003, 2005 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include "libunwind_i.h" - -int -unw_get_proc_info_by_ip (unw_addr_space_t as, unw_word_t ip, - unw_proc_info_t *pi, void *as_arg) -{ - unw_accessors_t *a = unw_get_accessors_int (as); - int ret; - - ret = unwi_find_dynamic_proc_info (as, ip, pi, 0, as_arg); - if (ret == -UNW_ENOINFO) - ret = (*a->find_proc_info) (as, ip, pi, 0, as_arg); - return ret; -} diff --git a/src/pal/src/libunwind/src/mi/Gget_proc_name.c b/src/pal/src/libunwind/src/mi/Gget_proc_name.c deleted file mode 100644 index 840d9007f..000000000 --- a/src/pal/src/libunwind/src/mi/Gget_proc_name.c +++ /dev/null @@ -1,118 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2001-2005 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include "libunwind_i.h" -#include "remote.h" - -static inline int -intern_string (unw_addr_space_t as, unw_accessors_t *a, - unw_word_t addr, char *buf, size_t buf_len, void *arg) -{ - size_t i; - int ret; - - for (i = 0; i < buf_len; ++i) - { - if ((ret = fetch8 (as, a, &addr, (int8_t *) buf + i, arg)) < 0) - return ret; - - if (buf[i] == '\0') - return 0; /* copied full string; return success */ - } - buf[buf_len - 1] = '\0'; /* ensure string is NUL terminated */ - return -UNW_ENOMEM; -} - -static inline int -get_proc_name (unw_addr_space_t as, unw_word_t ip, - char *buf, size_t buf_len, unw_word_t *offp, void *arg) -{ - unw_accessors_t *a = unw_get_accessors_int (as); - unw_proc_info_t pi; - int ret; - - buf[0] = '\0'; /* always return a valid string, even if it's empty */ - - ret = unwi_find_dynamic_proc_info (as, ip, &pi, 1, arg); - if (ret == 0) - { - unw_dyn_info_t *di = pi.unwind_info; - - if (offp) - *offp = ip - pi.start_ip; - - switch (di->format) - { - case UNW_INFO_FORMAT_DYNAMIC: - ret = intern_string (as, a, di->u.pi.name_ptr, buf, buf_len, arg); - break; - - case UNW_INFO_FORMAT_TABLE: - case UNW_INFO_FORMAT_REMOTE_TABLE: - /* XXX should we create a fake name, e.g.: "tablenameN", - where N is the index of the function in the table??? */ - ret = -UNW_ENOINFO; - break; - - default: - ret = -UNW_EINVAL; - break; - } - unwi_put_dynamic_unwind_info (as, &pi, arg); - return ret; - } - - if (ret != -UNW_ENOINFO) - return ret; - - /* not a dynamic procedure, try to lookup static procedure name: */ - - if (a->get_proc_name) - return (*a->get_proc_name) (as, ip, buf, buf_len, offp, arg); - - return -UNW_ENOINFO; -} - -int -unw_get_proc_name (unw_cursor_t *cursor, char *buf, size_t buf_len, - unw_word_t *offp) -{ - struct cursor *c = (struct cursor *) cursor; - unw_word_t ip; - int error; - - ip = tdep_get_ip (c); -#if !defined(__ia64__) - if (c->dwarf.use_prev_instr) - --ip; -#endif - error = get_proc_name (tdep_get_as (c), ip, buf, buf_len, offp, - tdep_get_as_arg (c)); -#if !defined(__ia64__) - if (c->dwarf.use_prev_instr && offp != NULL && error == 0) - *offp += 1; -#endif - return error; -} diff --git a/src/pal/src/libunwind/src/mi/Gget_reg.c b/src/pal/src/libunwind/src/mi/Gget_reg.c deleted file mode 100644 index 9fc725c9c..000000000 --- a/src/pal/src/libunwind/src/mi/Gget_reg.c +++ /dev/null @@ -1,41 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2002, 2005 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include "libunwind_i.h" - -int -unw_get_reg (unw_cursor_t *cursor, int regnum, unw_word_t *valp) -{ - struct cursor *c = (struct cursor *) cursor; - - // We can get the IP value directly without needing a lookup. - if (regnum == UNW_REG_IP) - { - *valp = tdep_get_ip (c); - return 0; - } - - return tdep_access_reg (c, regnum, valp, 0); -} diff --git a/src/pal/src/libunwind/src/mi/Gput_dynamic_unwind_info.c b/src/pal/src/libunwind/src/mi/Gput_dynamic_unwind_info.c deleted file mode 100644 index ca377c98a..000000000 --- a/src/pal/src/libunwind/src/mi/Gput_dynamic_unwind_info.c +++ /dev/null @@ -1,55 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2001-2002, 2005 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include "libunwind_i.h" - -HIDDEN void -unwi_put_dynamic_unwind_info (unw_addr_space_t as, unw_proc_info_t *pi, - void *arg) -{ - switch (pi->format) - { - case UNW_INFO_FORMAT_DYNAMIC: -#ifndef UNW_LOCAL_ONLY -# ifdef UNW_REMOTE_ONLY - unwi_dyn_remote_put_unwind_info (as, pi, arg); -# else - if (as != unw_local_addr_space) - unwi_dyn_remote_put_unwind_info (as, pi, arg); -# endif -#endif - break; - - case UNW_INFO_FORMAT_TABLE: - case UNW_INFO_FORMAT_REMOTE_TABLE: -#ifdef tdep_put_unwind_info - tdep_put_unwind_info (as, pi, arg); - break; -#endif - /* fall through */ - default: - break; - } -} diff --git a/src/pal/src/libunwind/src/mi/Gset_cache_size.c b/src/pal/src/libunwind/src/mi/Gset_cache_size.c deleted file mode 100644 index 07b282e2c..000000000 --- a/src/pal/src/libunwind/src/mi/Gset_cache_size.c +++ /dev/null @@ -1,72 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2014 - Contributed by Milian Wolff - and Dave Watson - -This file is part of libunwind. - -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. */ - -#include "libunwind_i.h" - -int -unw_set_cache_size (unw_addr_space_t as, size_t size, int flag) -{ - size_t power = 1; - unsigned short log_size = 0; - - if (!tdep_init_done) - tdep_init (); - - if (flag != 0) - return -1; - - /* Currently not supported for per-thread cache due to memory leak */ - /* A pthread-key destructor would work, but is not signal safe */ -#if defined(HAVE___THREAD) && HAVE___THREAD - return -1; -#endif - - /* Round up to next power of two, slowly but portably */ - while(power < size) - { - power *= 2; - log_size++; - /* Largest size currently supported by rs_cache */ - if (log_size >= 15) - break; - } - -#if !defined(__ia64__) - if (log_size == as->global_cache.log_size) - return 0; /* no change */ - - as->global_cache.log_size = log_size; -#endif - - /* Ensure caches are empty (and initialized). */ - unw_flush_cache (as, 0, 0); -#ifdef __ia64__ - return 0; -#else - /* Synchronously purge cache, to ensure memory is allocated */ - return dwarf_flush_rs_cache(&as->global_cache); -#endif -} diff --git a/src/pal/src/libunwind/src/mi/Gset_caching_policy.c b/src/pal/src/libunwind/src/mi/Gset_caching_policy.c deleted file mode 100644 index aa3d23714..000000000 --- a/src/pal/src/libunwind/src/mi/Gset_caching_policy.c +++ /dev/null @@ -1,46 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2002, 2005 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include "libunwind_i.h" - -int -unw_set_caching_policy (unw_addr_space_t as, unw_caching_policy_t policy) -{ - if (!tdep_init_done) - tdep_init (); - -#if !(defined(HAVE___THREAD) && HAVE___THREAD) - if (policy == UNW_CACHE_PER_THREAD) - policy = UNW_CACHE_GLOBAL; -#endif - - if (policy == as->caching_policy) - return 0; /* no change */ - - as->caching_policy = policy; - /* Ensure caches are empty (and initialized). */ - unw_flush_cache (as, 0, 0); - return 0; -} diff --git a/src/pal/src/libunwind/src/mi/Gset_fpreg.c b/src/pal/src/libunwind/src/mi/Gset_fpreg.c deleted file mode 100644 index 8c37afd22..000000000 --- a/src/pal/src/libunwind/src/mi/Gset_fpreg.c +++ /dev/null @@ -1,34 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2004-2005 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include "libunwind_i.h" - -int -unw_set_fpreg (unw_cursor_t *cursor, int regnum, unw_fpreg_t val) -{ - struct cursor *c = (struct cursor *) cursor; - - return tdep_access_fpreg (c, regnum, &val, 1); -} diff --git a/src/pal/src/libunwind/src/mi/Gset_reg.c b/src/pal/src/libunwind/src/mi/Gset_reg.c deleted file mode 100644 index b1b177033..000000000 --- a/src/pal/src/libunwind/src/mi/Gset_reg.c +++ /dev/null @@ -1,34 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2002, 2005 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include "libunwind_i.h" - -int -unw_set_reg (unw_cursor_t *cursor, int regnum, unw_word_t valp) -{ - struct cursor *c = (struct cursor *) cursor; - - return tdep_access_reg (c, regnum, &valp, 1); -} diff --git a/src/pal/src/libunwind/src/mi/Ldestroy_addr_space.c b/src/pal/src/libunwind/src/mi/Ldestroy_addr_space.c deleted file mode 100644 index 5bf9364bc..000000000 --- a/src/pal/src/libunwind/src/mi/Ldestroy_addr_space.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gdestroy_addr_space.c" -#endif diff --git a/src/pal/src/libunwind/src/mi/Ldyn-extract.c b/src/pal/src/libunwind/src/mi/Ldyn-extract.c deleted file mode 100644 index 1802f865f..000000000 --- a/src/pal/src/libunwind/src/mi/Ldyn-extract.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gdyn-extract.c" -#endif diff --git a/src/pal/src/libunwind/src/mi/Ldyn-remote.c b/src/pal/src/libunwind/src/mi/Ldyn-remote.c deleted file mode 100644 index 260722a04..000000000 --- a/src/pal/src/libunwind/src/mi/Ldyn-remote.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gdyn-remote.c" -#endif diff --git a/src/pal/src/libunwind/src/mi/Lfind_dynamic_proc_info.c b/src/pal/src/libunwind/src/mi/Lfind_dynamic_proc_info.c deleted file mode 100644 index bc88e1c53..000000000 --- a/src/pal/src/libunwind/src/mi/Lfind_dynamic_proc_info.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gfind_dynamic_proc_info.c" -#endif diff --git a/src/pal/src/libunwind/src/mi/Lget_accessors.c b/src/pal/src/libunwind/src/mi/Lget_accessors.c deleted file mode 100644 index 555e37f30..000000000 --- a/src/pal/src/libunwind/src/mi/Lget_accessors.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gget_accessors.c" -#endif diff --git a/src/pal/src/libunwind/src/mi/Lget_fpreg.c b/src/pal/src/libunwind/src/mi/Lget_fpreg.c deleted file mode 100644 index e3be44143..000000000 --- a/src/pal/src/libunwind/src/mi/Lget_fpreg.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gget_fpreg.c" -#endif diff --git a/src/pal/src/libunwind/src/mi/Lget_proc_info_by_ip.c b/src/pal/src/libunwind/src/mi/Lget_proc_info_by_ip.c deleted file mode 100644 index 96910d83e..000000000 --- a/src/pal/src/libunwind/src/mi/Lget_proc_info_by_ip.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gget_proc_info_by_ip.c" -#endif diff --git a/src/pal/src/libunwind/src/mi/Lget_proc_name.c b/src/pal/src/libunwind/src/mi/Lget_proc_name.c deleted file mode 100644 index 378097b57..000000000 --- a/src/pal/src/libunwind/src/mi/Lget_proc_name.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gget_proc_name.c" -#endif diff --git a/src/pal/src/libunwind/src/mi/Lget_reg.c b/src/pal/src/libunwind/src/mi/Lget_reg.c deleted file mode 100644 index effe8a806..000000000 --- a/src/pal/src/libunwind/src/mi/Lget_reg.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gget_reg.c" -#endif diff --git a/src/pal/src/libunwind/src/mi/Lput_dynamic_unwind_info.c b/src/pal/src/libunwind/src/mi/Lput_dynamic_unwind_info.c deleted file mode 100644 index 99597cd5f..000000000 --- a/src/pal/src/libunwind/src/mi/Lput_dynamic_unwind_info.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gput_dynamic_unwind_info.c" -#endif diff --git a/src/pal/src/libunwind/src/mi/Lset_cache_size.c b/src/pal/src/libunwind/src/mi/Lset_cache_size.c deleted file mode 100644 index 670f64d3a..000000000 --- a/src/pal/src/libunwind/src/mi/Lset_cache_size.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gset_cache_size.c" -#endif diff --git a/src/pal/src/libunwind/src/mi/Lset_caching_policy.c b/src/pal/src/libunwind/src/mi/Lset_caching_policy.c deleted file mode 100644 index cc18816b3..000000000 --- a/src/pal/src/libunwind/src/mi/Lset_caching_policy.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gset_caching_policy.c" -#endif diff --git a/src/pal/src/libunwind/src/mi/Lset_fpreg.c b/src/pal/src/libunwind/src/mi/Lset_fpreg.c deleted file mode 100644 index 2497d404f..000000000 --- a/src/pal/src/libunwind/src/mi/Lset_fpreg.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gset_fpreg.c" -#endif diff --git a/src/pal/src/libunwind/src/mi/Lset_reg.c b/src/pal/src/libunwind/src/mi/Lset_reg.c deleted file mode 100644 index c7a872b01..000000000 --- a/src/pal/src/libunwind/src/mi/Lset_reg.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gset_reg.c" -#endif diff --git a/src/pal/src/libunwind/src/mi/_ReadSLEB.c b/src/pal/src/libunwind/src/mi/_ReadSLEB.c deleted file mode 100644 index c041e37a0..000000000 --- a/src/pal/src/libunwind/src/mi/_ReadSLEB.c +++ /dev/null @@ -1,25 +0,0 @@ -#include - -unw_word_t -_ReadSLEB (unsigned char **dpp) -{ - unsigned shift = 0; - unw_word_t byte, result = 0; - unsigned char *bp = *dpp; - - while (1) - { - byte = *bp++; - result |= (byte & 0x7f) << shift; - shift += 7; - if ((byte & 0x80) == 0) - break; - } - - if (shift < 8 * sizeof (unw_word_t) && (byte & 0x40) != 0) - /* sign-extend negative value */ - result |= ((unw_word_t) -1) << shift; - - *dpp = bp; - return result; -} diff --git a/src/pal/src/libunwind/src/mi/_ReadULEB.c b/src/pal/src/libunwind/src/mi/_ReadULEB.c deleted file mode 100644 index 116f3e19b..000000000 --- a/src/pal/src/libunwind/src/mi/_ReadULEB.c +++ /dev/null @@ -1,20 +0,0 @@ -#include - -unw_word_t -_ReadULEB (unsigned char **dpp) -{ - unsigned shift = 0; - unw_word_t byte, result = 0; - unsigned char *bp = *dpp; - - while (1) - { - byte = *bp++; - result |= (byte & 0x7f) << shift; - if ((byte & 0x80) == 0) - break; - shift += 7; - } - *dpp = bp; - return result; -} diff --git a/src/pal/src/libunwind/src/mi/backtrace.c b/src/pal/src/libunwind/src/mi/backtrace.c deleted file mode 100644 index c7aa2bdcd..000000000 --- a/src/pal/src/libunwind/src/mi/backtrace.c +++ /dev/null @@ -1,81 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2001-2002 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#ifndef UNW_REMOTE_ONLY - -#define UNW_LOCAL_ONLY -#include -#include -#include - -/* See glibc manual for a description of this function. */ - -static ALWAYS_INLINE int -slow_backtrace (void **buffer, int size, unw_context_t *uc) -{ - unw_cursor_t cursor; - unw_word_t ip; - int n = 0; - - if (unlikely (unw_init_local (&cursor, uc) < 0)) - return 0; - - while (unw_step (&cursor) > 0) - { - if (n >= size) - return n; - - if (unw_get_reg (&cursor, UNW_REG_IP, &ip) < 0) - return n; - buffer[n++] = (void *) (uintptr_t) ip; - } - return n; -} - -int -unw_backtrace (void **buffer, int size) -{ - unw_cursor_t cursor; - unw_context_t uc; - int n = size; - - tdep_getcontext_trace (&uc); - - if (unlikely (unw_init_local (&cursor, &uc) < 0)) - return 0; - - if (unlikely (tdep_trace (&cursor, buffer, &n) < 0)) - { - unw_getcontext (&uc); - return slow_backtrace (buffer, size, &uc); - } - - return n; -} - -extern int backtrace (void **buffer, int size) - WEAK ALIAS(unw_backtrace); - -#endif /* !UNW_REMOTE_ONLY */ diff --git a/src/pal/src/libunwind/src/mi/dyn-cancel.c b/src/pal/src/libunwind/src/mi/dyn-cancel.c deleted file mode 100644 index 9d7472d5f..000000000 --- a/src/pal/src/libunwind/src/mi/dyn-cancel.c +++ /dev/null @@ -1,46 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2001-2002, 2005 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include "libunwind_i.h" - -void -_U_dyn_cancel (unw_dyn_info_t *di) -{ - mutex_lock (&_U_dyn_info_list_lock); - { - ++_U_dyn_info_list.generation; - - if (di->prev) - di->prev->next = di->next; - else - _U_dyn_info_list.first = di->next; - - if (di->next) - di->next->prev = di->prev; - } - mutex_unlock (&_U_dyn_info_list_lock); - - di->next = di->prev = NULL; -} diff --git a/src/pal/src/libunwind/src/mi/dyn-info-list.c b/src/pal/src/libunwind/src/mi/dyn-info-list.c deleted file mode 100644 index 1c7c55090..000000000 --- a/src/pal/src/libunwind/src/mi/dyn-info-list.c +++ /dev/null @@ -1,34 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2001-2002, 2005 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include "libunwind_i.h" - -HIDDEN unw_dyn_info_list_t _U_dyn_info_list; - -unw_word_t -_U_dyn_info_list_addr (void) -{ - return (unw_word_t) (uintptr_t) &_U_dyn_info_list; -} diff --git a/src/pal/src/libunwind/src/mi/dyn-register.c b/src/pal/src/libunwind/src/mi/dyn-register.c deleted file mode 100644 index efdad3de0..000000000 --- a/src/pal/src/libunwind/src/mi/dyn-register.c +++ /dev/null @@ -1,44 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2001-2002, 2005 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include "libunwind_i.h" - -HIDDEN define_lock (_U_dyn_info_list_lock); - -void -_U_dyn_register (unw_dyn_info_t *di) -{ - mutex_lock (&_U_dyn_info_list_lock); - { - ++_U_dyn_info_list.generation; - - di->next = _U_dyn_info_list.first; - di->prev = NULL; - if (di->next) - di->next->prev = di; - _U_dyn_info_list.first = di; - } - mutex_unlock (&_U_dyn_info_list_lock); -} diff --git a/src/pal/src/libunwind/src/mi/flush_cache.c b/src/pal/src/libunwind/src/mi/flush_cache.c deleted file mode 100644 index cbd93e1a1..000000000 --- a/src/pal/src/libunwind/src/mi/flush_cache.c +++ /dev/null @@ -1,59 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2002-2005 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include "libunwind_i.h" - -void -unw_flush_cache (unw_addr_space_t as, unw_word_t lo, unw_word_t hi) -{ -#if !UNW_TARGET_IA64 - struct unw_debug_frame_list *w = as->debug_frames; -#endif - - /* clear dyn_info_list_addr cache: */ - as->dyn_info_list_addr = 0; - -#if !UNW_TARGET_IA64 - for (; w; w = w->next) - { - if (w->index) - free (w->index); - free (w->debug_frame); - } - as->debug_frames = NULL; -#endif - - /* This lets us flush caches lazily. The implementation currently - ignores the flush range arguments (lo-hi). This is OK because - unw_flush_cache() is allowed to flush more than the requested - range. */ - -#ifdef HAVE_FETCH_AND_ADD - fetch_and_add1 (&as->cache_generation); -#else -# warning unw_flush_cache(): need a way to atomically increment an integer. - ++as->cache_generation; -#endif -} diff --git a/src/pal/src/libunwind/src/mi/init.c b/src/pal/src/libunwind/src/mi/init.c deleted file mode 100644 index 60a48c589..000000000 --- a/src/pal/src/libunwind/src/mi/init.c +++ /dev/null @@ -1,60 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2002-2005 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include "libunwind_i.h" - -HIDDEN intrmask_t unwi_full_mask; - -static const char rcsid[] UNUSED = - "$Id: " PACKAGE_STRING " --- report bugs to " PACKAGE_BUGREPORT " $"; - -#if UNW_DEBUG - -/* Must not be declared HIDDEN because libunwind.so and - libunwind-PLATFORM.so will both define their own copies of this - variable and we want to use only one or the other when both - libraries are loaded. */ -long unwi_debug_level; - -#endif /* UNW_DEBUG */ - -HIDDEN void -mi_init (void) -{ -#if UNW_DEBUG - const char *str = getenv ("UNW_DEBUG_LEVEL"); - - if (str) - unwi_debug_level = atoi (str); - - if (unwi_debug_level > 0) - { - setbuf (stdout, NULL); - setbuf (stderr, NULL); - } -#endif - - assert (sizeof (struct cursor) <= sizeof (unw_cursor_t)); -} diff --git a/src/pal/src/libunwind/src/mi/mempool.c b/src/pal/src/libunwind/src/mi/mempool.c deleted file mode 100644 index 536b64e81..000000000 --- a/src/pal/src/libunwind/src/mi/mempool.c +++ /dev/null @@ -1,184 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2002-2003, 2005 Hewlett-Packard Co - Contributed by David Mosberger-Tang - Copyright (C) 2012 Tommi Rantala - -This file is part of libunwind. - -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. */ - -#include "libunwind_i.h" - -/* From GCC docs: ``Gcc also provides a target specific macro - * __BIGGEST_ALIGNMENT__, which is the largest alignment ever used for any data - * type on the target machine you are compiling for.'' */ -#ifdef __BIGGEST_ALIGNMENT__ -# define MAX_ALIGN __BIGGEST_ALIGNMENT__ -#else -/* Crude hack to check that MAX_ALIGN is power-of-two. - * sizeof(long double) = 12 on i386. */ -# define MAX_ALIGN_(n) (n < 8 ? 8 : \ - n < 16 ? 16 : n) -# define MAX_ALIGN MAX_ALIGN_(sizeof (long double)) -#endif - -static char sos_memory[SOS_MEMORY_SIZE] ALIGNED(MAX_ALIGN); -static size_t sos_memory_freepos; -static size_t pg_size; - -HIDDEN void * -sos_alloc (size_t size) -{ - size_t pos; - - size = UNW_ALIGN(size, MAX_ALIGN); - -#if defined(__GNUC__) && defined(HAVE_FETCH_AND_ADD) - /* Assume `sos_memory' is suitably aligned. */ - assert(((uintptr_t) &sos_memory[0] & (MAX_ALIGN-1)) == 0); - - pos = fetch_and_add (&sos_memory_freepos, size); -#else - static define_lock (sos_lock); - intrmask_t saved_mask; - - lock_acquire (&sos_lock, saved_mask); - { - /* No assumptions about `sos_memory' alignment. */ - if (sos_memory_freepos == 0) - { - unsigned align = UNW_ALIGN((uintptr_t) &sos_memory[0], MAX_ALIGN) - - (uintptr_t) &sos_memory[0]; - sos_memory_freepos = align; - } - pos = sos_memory_freepos; - sos_memory_freepos += size; - } - lock_release (&sos_lock, saved_mask); -#endif - - assert (((uintptr_t) &sos_memory[pos] & (MAX_ALIGN-1)) == 0); - assert ((pos+size) <= SOS_MEMORY_SIZE); - - return &sos_memory[pos]; -} - -/* Must be called while holding the mempool lock. */ - -static void -free_object (struct mempool *pool, void *object) -{ - struct object *obj = object; - - obj->next = pool->free_list; - pool->free_list = obj; - ++pool->num_free; -} - -static void -add_memory (struct mempool *pool, char *mem, size_t size, size_t obj_size) -{ - char *obj; - - for (obj = mem; obj <= mem + size - obj_size; obj += obj_size) - free_object (pool, obj); -} - -static void -expand (struct mempool *pool) -{ - size_t size; - char *mem; - - size = pool->chunk_size; - GET_MEMORY (mem, size); - if (!mem) - { - size = UNW_ALIGN(pool->obj_size, pg_size); - GET_MEMORY (mem, size); - if (!mem) - { - /* last chance: try to allocate one object from the SOS memory */ - size = pool->obj_size; - mem = sos_alloc (size); - } - } - add_memory (pool, mem, size, pool->obj_size); -} - -HIDDEN void -mempool_init (struct mempool *pool, size_t obj_size, size_t reserve) -{ - if (pg_size == 0) - pg_size = getpagesize (); - - memset (pool, 0, sizeof (*pool)); - - lock_init (&pool->lock); - - /* round object-size up to integer multiple of MAX_ALIGN */ - obj_size = UNW_ALIGN(obj_size, MAX_ALIGN); - - if (!reserve) - { - reserve = pg_size / obj_size / 4; - if (!reserve) - reserve = 16; - } - - pool->obj_size = obj_size; - pool->reserve = reserve; - pool->chunk_size = UNW_ALIGN(2*reserve*obj_size, pg_size); - - expand (pool); -} - -HIDDEN void * -mempool_alloc (struct mempool *pool) -{ - intrmask_t saved_mask; - struct object *obj; - - lock_acquire (&pool->lock, saved_mask); - { - if (pool->num_free <= pool->reserve) - expand (pool); - - assert (pool->num_free > 0); - - --pool->num_free; - obj = pool->free_list; - pool->free_list = obj->next; - } - lock_release (&pool->lock, saved_mask); - return obj; -} - -HIDDEN void -mempool_free (struct mempool *pool, void *object) -{ - intrmask_t saved_mask; - - lock_acquire (&pool->lock, saved_mask); - { - free_object (pool, object); - } - lock_release (&pool->lock, saved_mask); -} diff --git a/src/pal/src/libunwind/src/mi/strerror.c b/src/pal/src/libunwind/src/mi/strerror.c deleted file mode 100644 index 2cec73d1d..000000000 --- a/src/pal/src/libunwind/src/mi/strerror.c +++ /dev/null @@ -1,51 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2004 BEA Systems - Contributed by Thomas Hallgren - -This file is part of libunwind. - -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. */ - -#include "libunwind_i.h" - -/* Returns the text corresponding to the given err_code or the - text "invalid error code" if the err_code is invalid. */ -const char * -unw_strerror (int err_code) -{ - const char *cp; - unw_error_t error = (unw_error_t)-err_code; - switch (error) - { - case UNW_ESUCCESS: cp = "no error"; break; - case UNW_EUNSPEC: cp = "unspecified (general) error"; break; - case UNW_ENOMEM: cp = "out of memory"; break; - case UNW_EBADREG: cp = "bad register number"; break; - case UNW_EREADONLYREG: cp = "attempt to write read-only register"; break; - case UNW_ESTOPUNWIND: cp = "stop unwinding"; break; - case UNW_EINVALIDIP: cp = "invalid IP"; break; - case UNW_EBADFRAME: cp = "bad frame"; break; - case UNW_EINVAL: cp = "unsupported operation or bad value"; break; - case UNW_EBADVERSION: cp = "unwind info has unsupported version"; break; - case UNW_ENOINFO: cp = "no unwind info found"; break; - default: cp = "invalid error code"; - } - return cp; -} diff --git a/src/pal/src/libunwind/src/mips/Gapply_reg_state.c b/src/pal/src/libunwind/src/mips/Gapply_reg_state.c deleted file mode 100644 index 82f056da6..000000000 --- a/src/pal/src/libunwind/src/mips/Gapply_reg_state.c +++ /dev/null @@ -1,37 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (c) 2002-2003 Hewlett-Packard Development Company, L.P. - Contributed by David Mosberger-Tang - - Modified for x86_64 by Max Asbock - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" - -int -unw_apply_reg_state (unw_cursor_t *cursor, - void *reg_states_data) -{ - struct cursor *c = (struct cursor *) cursor; - - return dwarf_apply_reg_state (&c->dwarf, (dwarf_reg_state_t *)reg_states_data); -} diff --git a/src/pal/src/libunwind/src/mips/Gcreate_addr_space.c b/src/pal/src/libunwind/src/mips/Gcreate_addr_space.c deleted file mode 100644 index 493d03db6..000000000 --- a/src/pal/src/libunwind/src/mips/Gcreate_addr_space.c +++ /dev/null @@ -1,66 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - -This file is part of libunwind. - -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. */ - -#include - -#include "unwind_i.h" - -unw_addr_space_t -unw_create_addr_space (unw_accessors_t *a, int byte_order) -{ -#ifdef UNW_LOCAL_ONLY - return NULL; -#else - unw_addr_space_t as; - - /* - * MIPS supports only big or little-endian, not weird stuff like - * PDP_ENDIAN. - */ - if (byte_order != 0 - && byte_order != __LITTLE_ENDIAN - && byte_order != __BIG_ENDIAN) - return NULL; - - as = malloc (sizeof (*as)); - if (!as) - return NULL; - - memset (as, 0, sizeof (*as)); - - as->acc = *a; - - if (byte_order == 0) - /* use host default: */ - as->big_endian = (__BYTE_ORDER == __BIG_ENDIAN); - else - as->big_endian = (byte_order == __BIG_ENDIAN); - - /* FIXME! There is no way to specify the ABI. */ - as->abi = UNW_MIPS_ABI_O32; - as->addr_size = 4; - - return as; -#endif -} diff --git a/src/pal/src/libunwind/src/mips/Gget_proc_info.c b/src/pal/src/libunwind/src/mips/Gget_proc_info.c deleted file mode 100644 index 7b84be87b..000000000 --- a/src/pal/src/libunwind/src/mips/Gget_proc_info.c +++ /dev/null @@ -1,41 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" - -int -unw_get_proc_info (unw_cursor_t *cursor, unw_proc_info_t *pi) -{ - struct cursor *c = (struct cursor *) cursor; - int ret; - - /* We can only unwind using Dwarf into on MIPS: return failure code - if it's not present. */ - ret = dwarf_make_proc_info (&c->dwarf); - if (ret < 0) - return ret; - - *pi = c->dwarf.pi; - return 0; -} diff --git a/src/pal/src/libunwind/src/mips/Gget_save_loc.c b/src/pal/src/libunwind/src/mips/Gget_save_loc.c deleted file mode 100644 index c21f9b06d..000000000 --- a/src/pal/src/libunwind/src/mips/Gget_save_loc.c +++ /dev/null @@ -1,100 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" - -/* FIXME for MIPS. */ - -int -unw_get_save_loc (unw_cursor_t *cursor, int reg, unw_save_loc_t *sloc) -{ - struct cursor *c = (struct cursor *) cursor; - dwarf_loc_t loc; - - loc = DWARF_NULL_LOC; /* default to "not saved" */ - - switch (reg) - { - case UNW_MIPS_R0: - case UNW_MIPS_R1: - case UNW_MIPS_R2: - case UNW_MIPS_R3: - case UNW_MIPS_R4: - case UNW_MIPS_R5: - case UNW_MIPS_R6: - case UNW_MIPS_R7: - case UNW_MIPS_R8: - case UNW_MIPS_R9: - case UNW_MIPS_R10: - case UNW_MIPS_R11: - case UNW_MIPS_R12: - case UNW_MIPS_R13: - case UNW_MIPS_R14: - case UNW_MIPS_R15: - case UNW_MIPS_R16: - case UNW_MIPS_R17: - case UNW_MIPS_R18: - case UNW_MIPS_R19: - case UNW_MIPS_R20: - case UNW_MIPS_R21: - case UNW_MIPS_R22: - case UNW_MIPS_R23: - case UNW_MIPS_R24: - case UNW_MIPS_R25: - case UNW_MIPS_R26: - case UNW_MIPS_R27: - case UNW_MIPS_R28: - case UNW_MIPS_R29: - case UNW_MIPS_R30: - case UNW_MIPS_R31: - case UNW_MIPS_PC: - loc = c->dwarf.loc[reg - UNW_MIPS_R0]; - break; - - default: - break; - } - - memset (sloc, 0, sizeof (*sloc)); - - if (DWARF_IS_NULL_LOC (loc)) - { - sloc->type = UNW_SLT_NONE; - return 0; - } - -#if !defined(UNW_LOCAL_ONLY) - if (DWARF_IS_REG_LOC (loc)) - { - sloc->type = UNW_SLT_REG; - sloc->u.regnum = DWARF_GET_LOC (loc); - } - else -#endif - { - sloc->type = UNW_SLT_MEMORY; - sloc->u.addr = DWARF_GET_LOC (loc); - } - return 0; -} diff --git a/src/pal/src/libunwind/src/mips/Gglobal.c b/src/pal/src/libunwind/src/mips/Gglobal.c deleted file mode 100644 index fa9478eeb..000000000 --- a/src/pal/src/libunwind/src/mips/Gglobal.c +++ /dev/null @@ -1,55 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" -#include "dwarf_i.h" - -HIDDEN define_lock (mips_lock); -HIDDEN int tdep_init_done; - -HIDDEN void -tdep_init (void) -{ - intrmask_t saved_mask; - - sigfillset (&unwi_full_mask); - - lock_acquire (&mips_lock, saved_mask); - { - if (tdep_init_done) - /* another thread else beat us to it... */ - goto out; - - mi_init (); - - dwarf_init (); - -#ifndef UNW_REMOTE_ONLY - mips_local_addr_space_init (); -#endif - tdep_init_done = 1; /* signal that we're initialized... */ - } - out: - lock_release (&mips_lock, saved_mask); -} diff --git a/src/pal/src/libunwind/src/mips/Ginit.c b/src/pal/src/libunwind/src/mips/Ginit.c deleted file mode 100644 index 3df170c75..000000000 --- a/src/pal/src/libunwind/src/mips/Ginit.c +++ /dev/null @@ -1,210 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - -This file is part of libunwind. - -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. */ - -#include -#include - -#include "unwind_i.h" - -#ifdef UNW_REMOTE_ONLY - -/* unw_local_addr_space is a NULL pointer in this case. */ -unw_addr_space_t unw_local_addr_space; - -#else /* !UNW_REMOTE_ONLY */ - -static struct unw_addr_space local_addr_space; - -unw_addr_space_t unw_local_addr_space = &local_addr_space; - -/* Return the address of the 64-bit slot in UC for REG (even for o32, - where registers are 32-bit, the slots are still 64-bit). */ - -static inline void * -uc_addr (ucontext_t *uc, int reg) -{ - if (reg >= UNW_MIPS_R0 && reg < UNW_MIPS_R0 + 32) - return &uc->uc_mcontext.gregs[reg - UNW_MIPS_R0]; - else if (reg == UNW_MIPS_PC) - return &uc->uc_mcontext.pc; - else - return NULL; -} - -# ifdef UNW_LOCAL_ONLY - -HIDDEN void * -tdep_uc_addr (ucontext_t *uc, int reg) -{ - char *addr = uc_addr (uc, reg); - - if (((reg >= UNW_MIPS_R0 && reg <= UNW_MIPS_R31) || reg == UNW_MIPS_PC) - && tdep_big_endian (unw_local_addr_space) - && unw_local_addr_space->abi == UNW_MIPS_ABI_O32) - addr += 4; - - return addr; -} - -# endif /* UNW_LOCAL_ONLY */ - -HIDDEN unw_dyn_info_list_t _U_dyn_info_list; - -/* XXX fix me: there is currently no way to locate the dyn-info list - by a remote unwinder. On ia64, this is done via a special - unwind-table entry. Perhaps something similar can be done with - DWARF2 unwind info. */ - -static void -put_unwind_info (unw_addr_space_t as, unw_proc_info_t *proc_info, void *arg) -{ - /* it's a no-op */ -} - -static int -get_dyn_info_list_addr (unw_addr_space_t as, unw_word_t *dyn_info_list_addr, - void *arg) -{ - *dyn_info_list_addr = (unw_word_t) (intptr_t) &_U_dyn_info_list; - return 0; -} - -static int -access_mem (unw_addr_space_t as, unw_word_t addr, unw_word_t *val, int write, - void *arg) -{ - if (write) - { - Debug (16, "mem[%llx] <- %llx\n", (long long) addr, (long long) *val); - *(unw_word_t *) (intptr_t) addr = *val; - } - else - { - *val = *(unw_word_t *) (intptr_t) addr; - Debug (16, "mem[%llx] -> %llx\n", (long long) addr, (long long) *val); - } - return 0; -} - -static int -access_reg (unw_addr_space_t as, unw_regnum_t reg, unw_word_t *val, int write, - void *arg) -{ - unw_word_t *addr; - ucontext_t *uc = arg; - - if (unw_is_fpreg (reg)) - goto badreg; - - Debug (16, "reg = %s\n", unw_regname (reg)); - if (!(addr = uc_addr (uc, reg))) - goto badreg; - - if (write) - { - *(unw_word_t *) (intptr_t) addr = (mips_reg_t) *val; - Debug (12, "%s <- %llx\n", unw_regname (reg), (long long) *val); - } - else - { - *val = (mips_reg_t) *(unw_word_t *) (intptr_t) addr; - Debug (12, "%s -> %llx\n", unw_regname (reg), (long long) *val); - } - return 0; - - badreg: - Debug (1, "bad register number %u\n", reg); - return -UNW_EBADREG; -} - -static int -access_fpreg (unw_addr_space_t as, unw_regnum_t reg, unw_fpreg_t *val, - int write, void *arg) -{ - ucontext_t *uc = arg; - unw_fpreg_t *addr; - - if (!unw_is_fpreg (reg)) - goto badreg; - - if (!(addr = uc_addr (uc, reg))) - goto badreg; - - if (write) - { - Debug (12, "%s <- %08lx.%08lx.%08lx\n", unw_regname (reg), - ((long *)val)[0], ((long *)val)[1], ((long *)val)[2]); - *(unw_fpreg_t *) (intptr_t) addr = *val; - } - else - { - *val = *(unw_fpreg_t *) (intptr_t) addr; - Debug (12, "%s -> %08lx.%08lx.%08lx\n", unw_regname (reg), - ((long *)val)[0], ((long *)val)[1], ((long *)val)[2]); - } - return 0; - - badreg: - Debug (1, "bad register number %u\n", reg); - /* attempt to access a non-preserved register */ - return -UNW_EBADREG; -} - -static int -get_static_proc_name (unw_addr_space_t as, unw_word_t ip, - char *buf, size_t buf_len, unw_word_t *offp, - void *arg) -{ - - return elf_w (get_proc_name) (as, getpid (), ip, buf, buf_len, offp); -} - -HIDDEN void -mips_local_addr_space_init (void) -{ - memset (&local_addr_space, 0, sizeof (local_addr_space)); - local_addr_space.big_endian = (__BYTE_ORDER == __BIG_ENDIAN); -#if _MIPS_SIM == _ABIO32 - local_addr_space.abi = UNW_MIPS_ABI_O32; -#elif _MIPS_SIM == _ABIN32 - local_addr_space.abi = UNW_MIPS_ABI_N32; -#elif _MIPS_SIM == _ABI64 - local_addr_space.abi = UNW_MIPS_ABI_N64; -#else -# error Unsupported ABI -#endif - local_addr_space.addr_size = sizeof (void *); - local_addr_space.caching_policy = UNWI_DEFAULT_CACHING_POLICY; - local_addr_space.acc.find_proc_info = dwarf_find_proc_info; - local_addr_space.acc.put_unwind_info = put_unwind_info; - local_addr_space.acc.get_dyn_info_list_addr = get_dyn_info_list_addr; - local_addr_space.acc.access_mem = access_mem; - local_addr_space.acc.access_reg = access_reg; - local_addr_space.acc.access_fpreg = access_fpreg; - local_addr_space.acc.resume = NULL; /* mips_local_resume? FIXME! */ - local_addr_space.acc.get_proc_name = get_static_proc_name; - unw_flush_cache (&local_addr_space, 0, 0); -} - -#endif /* !UNW_REMOTE_ONLY */ diff --git a/src/pal/src/libunwind/src/mips/Ginit_local.c b/src/pal/src/libunwind/src/mips/Ginit_local.c deleted file mode 100644 index f3153b5ba..000000000 --- a/src/pal/src/libunwind/src/mips/Ginit_local.c +++ /dev/null @@ -1,76 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" -#include "init.h" - -#ifdef UNW_REMOTE_ONLY - -int -unw_init_local (unw_cursor_t *cursor, ucontext_t *uc) -{ - return -UNW_EINVAL; -} - -#else /* !UNW_REMOTE_ONLY */ - -static int -unw_init_local_common(unw_cursor_t *cursor, ucontext_t *uc, unsigned use_prev_instr) -{ - struct cursor *c = (struct cursor *) cursor; - - if (!tdep_init_done) - tdep_init (); - - Debug (1, "(cursor=%p)\n", c); - - c->dwarf.as = unw_local_addr_space; - c->dwarf.as_arg = uc; - return common_init (c, use_prev_instr); -} - -int -unw_init_local(unw_cursor_t *cursor, ucontext_t *uc) -{ - return unw_init_local_common(cursor, uc, 1); -} - -int -unw_init_local2 (unw_cursor_t *cursor, ucontext_t *uc, int flag) -{ - if (!flag) - { - return unw_init_local_common(cursor, uc, 1); - } - else if (flag == UNW_INIT_SIGNAL_FRAME) - { - return unw_init_local_common(cursor, uc, 0); - } - else - { - return -UNW_EINVAL; - } -} - -#endif /* !UNW_REMOTE_ONLY */ diff --git a/src/pal/src/libunwind/src/mips/Ginit_remote.c b/src/pal/src/libunwind/src/mips/Ginit_remote.c deleted file mode 100644 index 9b8ba5b89..000000000 --- a/src/pal/src/libunwind/src/mips/Ginit_remote.c +++ /dev/null @@ -1,45 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - -This file is part of libunwind. - -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. */ - -#include "init.h" -#include "unwind_i.h" - -int -unw_init_remote (unw_cursor_t *cursor, unw_addr_space_t as, void *as_arg) -{ -#ifdef UNW_LOCAL_ONLY - return -UNW_EINVAL; -#else /* !UNW_LOCAL_ONLY */ - struct cursor *c = (struct cursor *) cursor; - - if (!tdep_init_done) - tdep_init (); - - Debug (1, "(cursor=%p)\n", c); - - c->dwarf.as = as; - c->dwarf.as_arg = as_arg; - return common_init (c, 0); -#endif /* !UNW_LOCAL_ONLY */ -} diff --git a/src/pal/src/libunwind/src/mips/Gis_signal_frame.c b/src/pal/src/libunwind/src/mips/Gis_signal_frame.c deleted file mode 100644 index c0e3b9836..000000000 --- a/src/pal/src/libunwind/src/mips/Gis_signal_frame.c +++ /dev/null @@ -1,78 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2015 Imagination Technologies Limited - Copyright (C) 2008 CodeSourcery - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" -#include - -int -unw_is_signal_frame (unw_cursor_t *cursor) -{ - struct cursor *c = (struct cursor *) cursor; - unw_word_t w0, w1, ip; - unw_addr_space_t as; - unw_accessors_t *a; - void *arg; - int ret; - - as = c->dwarf.as; - a = unw_get_accessors_int (as); - arg = c->dwarf.as_arg; - - ip = c->dwarf.ip; - - /* syscall */ - if ((ret = (*a->access_mem) (as, ip + 4, &w1, 0, arg)) < 0) - return 0; - if ((w1 & 0xffffffff) != 0x0c) - return 0; - - /* li v0, 0x1061 (rt) or li v0, 0x1017 */ - if ((ret = (*a->access_mem) (as, ip, &w0, 0, arg)) < 0) - return 0; - - switch (c->dwarf.as->abi) - { - case UNW_MIPS_ABI_O32: - switch (w0 & 0xffffffff) - { - case 0x24021061: - return 1; - case 0x24021017: - return 2; - default: - return 0; - } - case UNW_MIPS_ABI_N64: - switch (w0 & 0xffffffff) - { - case 0x2402145b: - return 1; - default: - return 0; - } - default: - return 0; - } -} diff --git a/src/pal/src/libunwind/src/mips/Greg_states_iterate.c b/src/pal/src/libunwind/src/mips/Greg_states_iterate.c deleted file mode 100644 index a17dc1b56..000000000 --- a/src/pal/src/libunwind/src/mips/Greg_states_iterate.c +++ /dev/null @@ -1,37 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (c) 2002-2003 Hewlett-Packard Development Company, L.P. - Contributed by David Mosberger-Tang - - Modified for x86_64 by Max Asbock - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" - -int -unw_reg_states_iterate (unw_cursor_t *cursor, - unw_reg_states_callback cb, void *token) -{ - struct cursor *c = (struct cursor *) cursor; - - return dwarf_reg_states_iterate (&c->dwarf, cb, token); -} diff --git a/src/pal/src/libunwind/src/mips/Gregs.c b/src/pal/src/libunwind/src/mips/Gregs.c deleted file mode 100644 index 95194022d..000000000 --- a/src/pal/src/libunwind/src/mips/Gregs.c +++ /dev/null @@ -1,105 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" - -/* FIXME: The following is probably unfinished and/or at least partly bogus. */ - -HIDDEN int -tdep_access_reg (struct cursor *c, unw_regnum_t reg, unw_word_t *valp, - int write) -{ - dwarf_loc_t loc = DWARF_NULL_LOC; - - switch (reg) - { - case UNW_MIPS_R0: - case UNW_MIPS_R1: - case UNW_MIPS_R2: - case UNW_MIPS_R3: - case UNW_MIPS_R4: - case UNW_MIPS_R5: - case UNW_MIPS_R6: - case UNW_MIPS_R7: - case UNW_MIPS_R8: - case UNW_MIPS_R9: - case UNW_MIPS_R10: - case UNW_MIPS_R11: - case UNW_MIPS_R12: - case UNW_MIPS_R13: - case UNW_MIPS_R14: - case UNW_MIPS_R15: - case UNW_MIPS_R16: - case UNW_MIPS_R17: - case UNW_MIPS_R18: - case UNW_MIPS_R19: - case UNW_MIPS_R20: - case UNW_MIPS_R21: - case UNW_MIPS_R22: - case UNW_MIPS_R23: - case UNW_MIPS_R24: - case UNW_MIPS_R25: - case UNW_MIPS_R26: - case UNW_MIPS_R27: - case UNW_MIPS_R28: - case UNW_MIPS_R29: - case UNW_MIPS_R30: - case UNW_MIPS_R31: - loc = c->dwarf.loc[reg - UNW_MIPS_R0]; - break; - - case UNW_MIPS_PC: - if (write) - c->dwarf.ip = *valp; /* update the IP cache */ - loc = c->dwarf.loc[reg]; - break; - - case UNW_MIPS_CFA: - if (write) - return -UNW_EREADONLYREG; - *valp = c->dwarf.cfa; - return 0; - - /* FIXME: IP? Copro & shadow registers? */ - - default: - Debug (1, "bad register number %u\n", reg); - return -UNW_EBADREG; - } - - if (write) - return dwarf_put (&c->dwarf, loc, *valp); - else - return dwarf_get (&c->dwarf, loc, valp); -} - -/* FIXME for MIPS. */ - -HIDDEN int -tdep_access_fpreg (struct cursor *c, unw_regnum_t reg, unw_fpreg_t *valp, - int write) -{ - Debug (1, "bad register number %u\n", reg); - return -UNW_EBADREG; -} diff --git a/src/pal/src/libunwind/src/mips/Gresume.c b/src/pal/src/libunwind/src/mips/Gresume.c deleted file mode 100644 index cb70abc8c..000000000 --- a/src/pal/src/libunwind/src/mips/Gresume.c +++ /dev/null @@ -1,45 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - -This file is part of libunwind. - -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. */ - -/* FIXME for MIPS. */ - -#include - -#include "unwind_i.h" - -#ifndef UNW_REMOTE_ONLY - -HIDDEN inline int -mips_local_resume (unw_addr_space_t as, unw_cursor_t *cursor, void *arg) -{ - return -UNW_EINVAL; -} - -#endif /* !UNW_REMOTE_ONLY */ - -int -unw_resume (unw_cursor_t *cursor) -{ - return -UNW_EINVAL; -} diff --git a/src/pal/src/libunwind/src/mips/Gstep.c b/src/pal/src/libunwind/src/mips/Gstep.c deleted file mode 100644 index 937136aef..000000000 --- a/src/pal/src/libunwind/src/mips/Gstep.c +++ /dev/null @@ -1,132 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2015 Imagination Technologies Limited - Copyright (C) 2008 CodeSourcery - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" -#include "offsets.h" - -static int -mips_handle_signal_frame (unw_cursor_t *cursor) -{ - struct cursor *c = (struct cursor *) cursor; - unw_word_t sc_addr, sp_addr = c->dwarf.cfa; - unw_word_t ra, fp; - int ret; - - switch (unw_is_signal_frame (cursor)) { - case 1: - sc_addr = sp_addr + LINUX_SF_TRAMP_SIZE + sizeof (siginfo_t) + - LINUX_UC_MCONTEXT_OFF; - break; - case 2: - sc_addr = sp_addr + LINUX_UC_MCONTEXT_OFF; - break; - default: - return -UNW_EUNSPEC; - } - - if (tdep_big_endian(c->dwarf.as)) - sc_addr += 4; - - c->sigcontext_addr = sc_addr; - - /* Update the dwarf cursor. */ - c->dwarf.loc[UNW_MIPS_R0] = DWARF_LOC (sc_addr + LINUX_SC_R0_OFF, 0); - c->dwarf.loc[UNW_MIPS_R1] = DWARF_LOC (sc_addr + LINUX_SC_R1_OFF, 0); - c->dwarf.loc[UNW_MIPS_R2] = DWARF_LOC (sc_addr + LINUX_SC_R2_OFF, 0); - c->dwarf.loc[UNW_MIPS_R3] = DWARF_LOC (sc_addr + LINUX_SC_R3_OFF, 0); - c->dwarf.loc[UNW_MIPS_R4] = DWARF_LOC (sc_addr + LINUX_SC_R4_OFF, 0); - c->dwarf.loc[UNW_MIPS_R5] = DWARF_LOC (sc_addr + LINUX_SC_R5_OFF, 0); - c->dwarf.loc[UNW_MIPS_R6] = DWARF_LOC (sc_addr + LINUX_SC_R6_OFF, 0); - c->dwarf.loc[UNW_MIPS_R7] = DWARF_LOC (sc_addr + LINUX_SC_R7_OFF, 0); - c->dwarf.loc[UNW_MIPS_R8] = DWARF_LOC (sc_addr + LINUX_SC_R8_OFF, 0); - c->dwarf.loc[UNW_MIPS_R9] = DWARF_LOC (sc_addr + LINUX_SC_R9_OFF, 0); - c->dwarf.loc[UNW_MIPS_R10] = DWARF_LOC (sc_addr + LINUX_SC_R10_OFF, 0); - c->dwarf.loc[UNW_MIPS_R11] = DWARF_LOC (sc_addr + LINUX_SC_R11_OFF, 0); - c->dwarf.loc[UNW_MIPS_R12] = DWARF_LOC (sc_addr + LINUX_SC_R12_OFF, 0); - c->dwarf.loc[UNW_MIPS_R13] = DWARF_LOC (sc_addr + LINUX_SC_R13_OFF, 0); - c->dwarf.loc[UNW_MIPS_R14] = DWARF_LOC (sc_addr + LINUX_SC_R14_OFF, 0); - c->dwarf.loc[UNW_MIPS_R15] = DWARF_LOC (sc_addr + LINUX_SC_R15_OFF, 0); - c->dwarf.loc[UNW_MIPS_R16] = DWARF_LOC (sc_addr + LINUX_SC_R16_OFF, 0); - c->dwarf.loc[UNW_MIPS_R17] = DWARF_LOC (sc_addr + LINUX_SC_R17_OFF, 0); - c->dwarf.loc[UNW_MIPS_R18] = DWARF_LOC (sc_addr + LINUX_SC_R18_OFF, 0); - c->dwarf.loc[UNW_MIPS_R19] = DWARF_LOC (sc_addr + LINUX_SC_R19_OFF, 0); - c->dwarf.loc[UNW_MIPS_R20] = DWARF_LOC (sc_addr + LINUX_SC_R20_OFF, 0); - c->dwarf.loc[UNW_MIPS_R21] = DWARF_LOC (sc_addr + LINUX_SC_R21_OFF, 0); - c->dwarf.loc[UNW_MIPS_R22] = DWARF_LOC (sc_addr + LINUX_SC_R22_OFF, 0); - c->dwarf.loc[UNW_MIPS_R23] = DWARF_LOC (sc_addr + LINUX_SC_R23_OFF, 0); - c->dwarf.loc[UNW_MIPS_R24] = DWARF_LOC (sc_addr + LINUX_SC_R24_OFF, 0); - c->dwarf.loc[UNW_MIPS_R25] = DWARF_LOC (sc_addr + LINUX_SC_R25_OFF, 0); - c->dwarf.loc[UNW_MIPS_R26] = DWARF_LOC (sc_addr + LINUX_SC_R26_OFF, 0); - c->dwarf.loc[UNW_MIPS_R27] = DWARF_LOC (sc_addr + LINUX_SC_R27_OFF, 0); - c->dwarf.loc[UNW_MIPS_R28] = DWARF_LOC (sc_addr + LINUX_SC_R28_OFF, 0); - c->dwarf.loc[UNW_MIPS_R29] = DWARF_LOC (sc_addr + LINUX_SC_R29_OFF, 0); - c->dwarf.loc[UNW_MIPS_R30] = DWARF_LOC (sc_addr + LINUX_SC_R30_OFF, 0); - c->dwarf.loc[UNW_MIPS_R31] = DWARF_LOC (sc_addr + LINUX_SC_R31_OFF, 0); - c->dwarf.loc[UNW_MIPS_PC] = DWARF_LOC (sc_addr + LINUX_SC_PC_OFF, 0); - - /* Set SP/CFA and PC/IP. */ - dwarf_get (&c->dwarf, c->dwarf.loc[UNW_MIPS_R29], &c->dwarf.cfa); - - if ((ret = dwarf_get(&c->dwarf, DWARF_LOC(sc_addr + LINUX_SC_PC_OFF, 0), - &c->dwarf.ip)) < 0) - return ret; - - if ((ret = dwarf_get(&c->dwarf, DWARF_LOC(sc_addr + LINUX_SC_R31_OFF, 0), - &ra)) < 0) - return ret; - if ((ret = dwarf_get(&c->dwarf, DWARF_LOC(sc_addr + LINUX_SC_R30_OFF, 0), - &fp)) < 0) - return ret; - - Debug (2, "SH (ip=0x%016llx, ra=0x%016llx, sp=0x%016llx, fp=0x%016llx)\n", - (unsigned long long)c->dwarf.ip, (unsigned long long)ra, - (unsigned long long)c->dwarf.cfa, (unsigned long long)fp); - - c->dwarf.pi_valid = 0; - c->dwarf.use_prev_instr = 0; - - return 1; -} - -int -unw_step (unw_cursor_t *cursor) -{ - struct cursor *c = (struct cursor *) cursor; - int ret; - - ret = mips_handle_signal_frame (cursor); - if (ret < 0) - /* Not a signal frame, try DWARF-based unwinding. */ - ret = dwarf_step (&c->dwarf); - - if (unlikely (ret == -UNW_ESTOPUNWIND)) - return ret; - - /* Dwarf unwinding didn't work, stop. */ - if (unlikely (ret < 0)) - return 0; - - return (c->dwarf.ip == 0) ? 0 : 1; -} diff --git a/src/pal/src/libunwind/src/mips/Lapply_reg_state.c b/src/pal/src/libunwind/src/mips/Lapply_reg_state.c deleted file mode 100644 index 7ebada480..000000000 --- a/src/pal/src/libunwind/src/mips/Lapply_reg_state.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gapply_reg_state.c" -#endif diff --git a/src/pal/src/libunwind/src/mips/Lcreate_addr_space.c b/src/pal/src/libunwind/src/mips/Lcreate_addr_space.c deleted file mode 100644 index 0f2dc6be9..000000000 --- a/src/pal/src/libunwind/src/mips/Lcreate_addr_space.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gcreate_addr_space.c" -#endif diff --git a/src/pal/src/libunwind/src/mips/Lget_proc_info.c b/src/pal/src/libunwind/src/mips/Lget_proc_info.c deleted file mode 100644 index 69028b019..000000000 --- a/src/pal/src/libunwind/src/mips/Lget_proc_info.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gget_proc_info.c" -#endif diff --git a/src/pal/src/libunwind/src/mips/Lget_save_loc.c b/src/pal/src/libunwind/src/mips/Lget_save_loc.c deleted file mode 100644 index 9ea048a90..000000000 --- a/src/pal/src/libunwind/src/mips/Lget_save_loc.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gget_save_loc.c" -#endif diff --git a/src/pal/src/libunwind/src/mips/Lglobal.c b/src/pal/src/libunwind/src/mips/Lglobal.c deleted file mode 100644 index 6d7b489e1..000000000 --- a/src/pal/src/libunwind/src/mips/Lglobal.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gglobal.c" -#endif diff --git a/src/pal/src/libunwind/src/mips/Linit.c b/src/pal/src/libunwind/src/mips/Linit.c deleted file mode 100644 index e9abfdd46..000000000 --- a/src/pal/src/libunwind/src/mips/Linit.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Ginit.c" -#endif diff --git a/src/pal/src/libunwind/src/mips/Linit_local.c b/src/pal/src/libunwind/src/mips/Linit_local.c deleted file mode 100644 index 68a1687e8..000000000 --- a/src/pal/src/libunwind/src/mips/Linit_local.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Ginit_local.c" -#endif diff --git a/src/pal/src/libunwind/src/mips/Linit_remote.c b/src/pal/src/libunwind/src/mips/Linit_remote.c deleted file mode 100644 index 58cb04ab7..000000000 --- a/src/pal/src/libunwind/src/mips/Linit_remote.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Ginit_remote.c" -#endif diff --git a/src/pal/src/libunwind/src/mips/Lis_signal_frame.c b/src/pal/src/libunwind/src/mips/Lis_signal_frame.c deleted file mode 100644 index b9a7c4f51..000000000 --- a/src/pal/src/libunwind/src/mips/Lis_signal_frame.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gis_signal_frame.c" -#endif diff --git a/src/pal/src/libunwind/src/mips/Lreg_states_iterate.c b/src/pal/src/libunwind/src/mips/Lreg_states_iterate.c deleted file mode 100644 index f1eb1e79d..000000000 --- a/src/pal/src/libunwind/src/mips/Lreg_states_iterate.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Greg_states_iterate.c" -#endif diff --git a/src/pal/src/libunwind/src/mips/Lregs.c b/src/pal/src/libunwind/src/mips/Lregs.c deleted file mode 100644 index 2c9c75cd7..000000000 --- a/src/pal/src/libunwind/src/mips/Lregs.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gregs.c" -#endif diff --git a/src/pal/src/libunwind/src/mips/Lresume.c b/src/pal/src/libunwind/src/mips/Lresume.c deleted file mode 100644 index 41a8cf003..000000000 --- a/src/pal/src/libunwind/src/mips/Lresume.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gresume.c" -#endif diff --git a/src/pal/src/libunwind/src/mips/Lstep.c b/src/pal/src/libunwind/src/mips/Lstep.c deleted file mode 100644 index c1ac3c754..000000000 --- a/src/pal/src/libunwind/src/mips/Lstep.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gstep.c" -#endif diff --git a/src/pal/src/libunwind/src/mips/elfxx.c b/src/pal/src/libunwind/src/mips/elfxx.c deleted file mode 100644 index 07d3d12b9..000000000 --- a/src/pal/src/libunwind/src/mips/elfxx.c +++ /dev/null @@ -1,27 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - -This file is part of libunwind. - -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. */ - -#include "libunwind_i.h" - -#include "../src/elfxx.c" diff --git a/src/pal/src/libunwind/src/mips/gen-offsets.c b/src/pal/src/libunwind/src/mips/gen-offsets.c deleted file mode 100644 index 448f69453..000000000 --- a/src/pal/src/libunwind/src/mips/gen-offsets.c +++ /dev/null @@ -1,30 +0,0 @@ -#include -#include -#include - -#define UC(N,X) \ - printf ("#define LINUX_UC_" N "_OFF\t0x%X\n", offsetof (ucontext_t, X)) - -#define SC(N,X) \ - printf ("#define LINUX_SC_" N "_OFF\t0x%X\n", offsetof (struct sigcontext, X)) - -int -main (void) -{ - printf ( -"/* Linux-specific definitions: */\n\n" - -"/* Define various structure offsets to simplify cross-compilation. */\n\n" - -"/* Offsets for MIPS Linux \"ucontext_t\": */\n\n"); - - UC ("FLAGS", uc_flags); - UC ("LINK", uc_link); - UC ("STACK", uc_stack); - UC ("MCONTEXT", uc_mcontext); - UC ("SIGMASK", uc_sigmask); - - UC ("MCONTEXT_GREGS", uc_mcontext.gregs); - - return 0; -} diff --git a/src/pal/src/libunwind/src/mips/getcontext.S b/src/pal/src/libunwind/src/mips/getcontext.S deleted file mode 100644 index d1dbd5793..000000000 --- a/src/pal/src/libunwind/src/mips/getcontext.S +++ /dev/null @@ -1,93 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - Copyright (C) 2012 Tommi Rantala - -This file is part of libunwind. - -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. */ - -#include "offsets.h" -#include - - .text - -#if _MIPS_SIM == _ABIO32 -# if __BYTE_ORDER == __BIG_ENDIAN -# define OFFSET 4 -# else -# define OFFSET 0 -# endif -# define SREG(X) \ - sw $X, (LINUX_UC_MCONTEXT_GREGS + 8 * X + OFFSET) ($4); \ - sra $1, $X, 31; \ - sw $1, (LINUX_UC_MCONTEXT_GREGS + 8 * X + 4 - OFFSET) ($4) -/* Yes, we save the return address to PC. */ -# define SPC \ - sw $31, (LINUX_UC_MCONTEXT_PC + OFFSET) ($4); \ - sra $1, $31, 31; \ - sw $1, (LINUX_UC_MCONTEXT_PC + 4 - OFFSET) ($4) -#else -# define SREG(X) sd $X, (LINUX_UC_MCONTEXT_GREGS + 8 * X) ($4) -# define SPC sd $31, (LINUX_UC_MCONTEXT_PC) ($4) -#endif - - .global _Umips_getcontext - .type _Umips_getcontext, %function - # This is a stub version of getcontext() for MIPS which only stores core - # registers. -_Umips_getcontext: - .set noat - SREG (1) - SREG (0) - SREG (2) - SREG (3) - SREG (4) - SREG (5) - SREG (6) - SREG (7) - SREG (8) - SREG (9) - SREG (10) - SREG (11) - SREG (12) - SREG (13) - SREG (14) - SREG (15) - SREG (16) - SREG (17) - SREG (18) - SREG (19) - SREG (20) - SREG (21) - SREG (22) - SREG (23) - SREG (24) - SREG (25) - SREG (26) - SREG (27) - SREG (28) - SREG (29) - SREG (30) - SREG (31) - SPC - li $2, 0 - j $31 - - .size _Umips_getcontext, .-_Umips_getcontext diff --git a/src/pal/src/libunwind/src/mips/init.h b/src/pal/src/libunwind/src/mips/init.h deleted file mode 100644 index 30c193a18..000000000 --- a/src/pal/src/libunwind/src/mips/init.h +++ /dev/null @@ -1,59 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" - -static inline int -common_init (struct cursor *c, unsigned use_prev_instr) -{ - int ret, i; - - for (i = 0; i < 32; i++) - c->dwarf.loc[i] = DWARF_REG_LOC (&c->dwarf, UNW_MIPS_R0 + i); - for (i = 32; i < DWARF_NUM_PRESERVED_REGS; ++i) - c->dwarf.loc[i] = DWARF_NULL_LOC; - - c->dwarf.loc[UNW_MIPS_PC] = DWARF_REG_LOC (&c->dwarf, UNW_MIPS_PC); - - ret = dwarf_get (&c->dwarf, c->dwarf.loc[UNW_MIPS_PC], &c->dwarf.ip); - if (ret < 0) - return ret; - - ret = dwarf_get (&c->dwarf, DWARF_REG_LOC (&c->dwarf, UNW_MIPS_R29), - &c->dwarf.cfa); - if (ret < 0) - return ret; - - /* FIXME: Initialisation for other registers. */ - - c->dwarf.args_size = 0; - c->dwarf.stash_frames = 0; - c->dwarf.use_prev_instr = use_prev_instr; - c->dwarf.pi_valid = 0; - c->dwarf.pi_is_dynamic = 0; - c->dwarf.hint = 0; - c->dwarf.prev_rs = 0; - - return 0; -} diff --git a/src/pal/src/libunwind/src/mips/is_fpreg.c b/src/pal/src/libunwind/src/mips/is_fpreg.c deleted file mode 100644 index a92dd5ece..000000000 --- a/src/pal/src/libunwind/src/mips/is_fpreg.c +++ /dev/null @@ -1,35 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - -This file is part of libunwind. - -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. */ - -#include "libunwind_i.h" - -/* FIXME: I'm not sure if libunwind's GP/FP register distinction is very useful - on MIPS. */ - -int -unw_is_fpreg (int regnum) -{ - /* FIXME: Support FP. */ - return 0; -} diff --git a/src/pal/src/libunwind/src/mips/offsets.h b/src/pal/src/libunwind/src/mips/offsets.h deleted file mode 100644 index b50605136..000000000 --- a/src/pal/src/libunwind/src/mips/offsets.h +++ /dev/null @@ -1,86 +0,0 @@ -/* Linux-specific definitions: */ - -/* Define various structure offsets to simplify cross-compilation. */ - -/* FIXME: Currently these are only used in getcontext.S, which is only used - for a local unwinder, so we can use the compile-time ABI. At a later date - we will want all three here, to use for signal handlers. Also, because - of the three ABIs, gen-offsets.c can not quite generate this file. */ - -/* Offsets for MIPS Linux "ucontext_t": */ - -/* First 24 bytes in sigframe are argument save space and padding for -what used to be signal trampolines. Ref: arch/mips/kernel/signal.c */ -#define LINUX_SF_TRAMP_SIZE 0x18 - -#if _MIPS_SIM == _ABIO32 - -# define LINUX_UC_FLAGS_OFF 0x0 -# define LINUX_UC_LINK_OFF 0x4 -# define LINUX_UC_STACK_OFF 0x8 -# define LINUX_UC_MCONTEXT_OFF 0x18 -# define LINUX_UC_SIGMASK_OFF 0x268 -# define LINUX_UC_MCONTEXT_PC 0x20 -# define LINUX_UC_MCONTEXT_GREGS 0x28 - -#elif _MIPS_SIM == _ABIN32 - -# define LINUX_UC_FLAGS_OFF 0x0 -# define LINUX_UC_LINK_OFF 0x4 -# define LINUX_UC_STACK_OFF 0x8 -# define LINUX_UC_MCONTEXT_OFF 0x18 -# define LINUX_UC_SIGMASK_OFF 0x270 -# define LINUX_UC_MCONTEXT_PC 0x258 -# define LINUX_UC_MCONTEXT_GREGS 0x18 - -#elif _MIPS_SIM == _ABI64 - -# define LINUX_UC_FLAGS_OFF 0x0 -# define LINUX_UC_LINK_OFF 0x8 -# define LINUX_UC_STACK_OFF 0x10 -# define LINUX_UC_MCONTEXT_OFF 0x28 -# define LINUX_UC_SIGMASK_OFF 0x280 -# define LINUX_UC_MCONTEXT_PC 0x268 -# define LINUX_UC_MCONTEXT_GREGS 0x28 - -#else - -#error Unsupported ABI - -#endif - -#define LINUX_SC_R0_OFF (LINUX_UC_MCONTEXT_GREGS - LINUX_UC_MCONTEXT_OFF) -#define LINUX_SC_R1_OFF (LINUX_SC_R0_OFF + 1*8) -#define LINUX_SC_R2_OFF (LINUX_SC_R0_OFF + 2*8) -#define LINUX_SC_R3_OFF (LINUX_SC_R0_OFF + 3*8) -#define LINUX_SC_R4_OFF (LINUX_SC_R0_OFF + 4*8) -#define LINUX_SC_R5_OFF (LINUX_SC_R0_OFF + 5*8) -#define LINUX_SC_R6_OFF (LINUX_SC_R0_OFF + 6*8) -#define LINUX_SC_R7_OFF (LINUX_SC_R0_OFF + 7*8) -#define LINUX_SC_R8_OFF (LINUX_SC_R0_OFF + 8*8) -#define LINUX_SC_R9_OFF (LINUX_SC_R0_OFF + 9*8) -#define LINUX_SC_R10_OFF (LINUX_SC_R0_OFF + 10*8) -#define LINUX_SC_R11_OFF (LINUX_SC_R0_OFF + 11*8) -#define LINUX_SC_R12_OFF (LINUX_SC_R0_OFF + 12*8) -#define LINUX_SC_R13_OFF (LINUX_SC_R0_OFF + 13*8) -#define LINUX_SC_R14_OFF (LINUX_SC_R0_OFF + 14*8) -#define LINUX_SC_R15_OFF (LINUX_SC_R0_OFF + 15*8) -#define LINUX_SC_R16_OFF (LINUX_SC_R0_OFF + 16*8) -#define LINUX_SC_R17_OFF (LINUX_SC_R0_OFF + 17*8) -#define LINUX_SC_R18_OFF (LINUX_SC_R0_OFF + 18*8) -#define LINUX_SC_R19_OFF (LINUX_SC_R0_OFF + 19*8) -#define LINUX_SC_R20_OFF (LINUX_SC_R0_OFF + 20*8) -#define LINUX_SC_R21_OFF (LINUX_SC_R0_OFF + 21*8) -#define LINUX_SC_R22_OFF (LINUX_SC_R0_OFF + 22*8) -#define LINUX_SC_R23_OFF (LINUX_SC_R0_OFF + 23*8) -#define LINUX_SC_R24_OFF (LINUX_SC_R0_OFF + 24*8) -#define LINUX_SC_R25_OFF (LINUX_SC_R0_OFF + 25*8) -#define LINUX_SC_R26_OFF (LINUX_SC_R0_OFF + 26*8) -#define LINUX_SC_R27_OFF (LINUX_SC_R0_OFF + 27*8) -#define LINUX_SC_R28_OFF (LINUX_SC_R0_OFF + 28*8) -#define LINUX_SC_R29_OFF (LINUX_SC_R0_OFF + 29*8) -#define LINUX_SC_R30_OFF (LINUX_SC_R0_OFF + 30*8) -#define LINUX_SC_R31_OFF (LINUX_SC_R0_OFF + 31*8) - -#define LINUX_SC_SP_OFF LINUX_SC_R29_OFF -#define LINUX_SC_PC_OFF (LINUX_UC_MCONTEXT_PC - LINUX_UC_MCONTEXT_OFF) diff --git a/src/pal/src/libunwind/src/mips/regname.c b/src/pal/src/libunwind/src/mips/regname.c deleted file mode 100644 index b137b972b..000000000 --- a/src/pal/src/libunwind/src/mips/regname.c +++ /dev/null @@ -1,48 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" - -static const char *regname[] = - { - /* 0. */ - "$0", "$1", "$2", "$3", "$4", "$5", "$6", "$7", - /* 8. */ - "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", - /* 16. */ - "$16", "$17", "$18", "$19", "$20", "$21", "$22", "$23", - /* 24. */ - "$24", "$25", "$26", "$27", "$28", "$29", "$30", "$31", - }; - -const char * -unw_regname (unw_regnum_t reg) -{ - if (reg < (unw_regnum_t) ARRAY_SIZE (regname)) - return regname[reg]; - else if (reg == UNW_MIPS_PC) - return "pc"; - else - return "???"; -} diff --git a/src/pal/src/libunwind/src/mips/siglongjmp.S b/src/pal/src/libunwind/src/mips/siglongjmp.S deleted file mode 100644 index 9cbcf3dc0..000000000 --- a/src/pal/src/libunwind/src/mips/siglongjmp.S +++ /dev/null @@ -1,8 +0,0 @@ - /* Dummy implementation for now. */ - - .globl _UI_siglongjmp_cont - .globl _UI_longjmp_cont - -_UI_siglongjmp_cont: -_UI_longjmp_cont: - j $31 diff --git a/src/pal/src/libunwind/src/mips/unwind_i.h b/src/pal/src/libunwind/src/mips/unwind_i.h deleted file mode 100644 index 3382dcfe5..000000000 --- a/src/pal/src/libunwind/src/mips/unwind_i.h +++ /dev/null @@ -1,43 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - -This file is part of libunwind. - -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. */ - -#ifndef unwind_i_h -#define unwind_i_h - -#include - -#include - -#include "libunwind_i.h" - -#define mips_lock UNW_OBJ(lock) -#define mips_local_resume UNW_OBJ(local_resume) -#define mips_local_addr_space_init UNW_OBJ(local_addr_space_init) - -extern int mips_local_resume (unw_addr_space_t as, unw_cursor_t *cursor, - void *arg); - -extern void mips_local_addr_space_init (void); - -#endif /* unwind_i_h */ diff --git a/src/pal/src/libunwind/src/os-freebsd.c b/src/pal/src/libunwind/src/os-freebsd.c deleted file mode 100644 index 753e819df..000000000 --- a/src/pal/src/libunwind/src/os-freebsd.c +++ /dev/null @@ -1,166 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2010 Konstantin Belousov - -This file is part of libunwind. - -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. */ - -#include -#include -#include -#include -#include -#include -#include - -#include "libunwind_i.h" - -static void * -get_mem(size_t sz) -{ - void *res; - - res = mmap(NULL, sz, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0); - if (res == MAP_FAILED) - return (NULL); - return (res); -} - -static void -free_mem(void *ptr, size_t sz) -{ - munmap(ptr, sz); -} - -static int -get_pid_by_tid(int tid) -{ - int mib[3], error; - size_t len, len1; - char *buf; - struct kinfo_proc *kv; - unsigned i, pid; - - len = 0; - mib[0] = CTL_KERN; - mib[1] = KERN_PROC; - mib[2] = KERN_PROC_ALL; - - error = sysctl(mib, 3, NULL, &len, NULL, 0); - if (error == -1) - return (-1); - len1 = len * 4 / 3; - buf = get_mem(len1); - if (buf == NULL) - return (-1); - len = len1; - error = sysctl(mib, 3, buf, &len, NULL, 0); - if (error == -1) { - free_mem(buf, len1); - return (-1); - } - pid = -1; - for (i = 0, kv = (struct kinfo_proc *)buf; i < len / sizeof(*kv); - i++, kv++) { - if (kv->ki_tid == tid) { - pid = kv->ki_pid; - break; - } - } - free_mem(buf, len1); - return (pid); -} - -int -tdep_get_elf_image (struct elf_image *ei, pid_t pid, unw_word_t ip, - unsigned long *segbase, unsigned long *mapoff, char *path, size_t pathlen) -{ - int mib[4], error, ret; - size_t len, len1; - char *buf, *bp, *eb; - struct kinfo_vmentry *kv; - - len = 0; - mib[0] = CTL_KERN; - mib[1] = KERN_PROC; - mib[2] = KERN_PROC_VMMAP; - mib[3] = pid; - - error = sysctl(mib, 4, NULL, &len, NULL, 0); - if (error == -1) { - if (errno == ESRCH) { - mib[3] = get_pid_by_tid(pid); - if (mib[3] != -1) - error = sysctl(mib, 4, NULL, &len, NULL, 0); - if (error == -1) - return (-UNW_EUNSPEC); - } else - return (-UNW_EUNSPEC); - } - len1 = len * 4 / 3; - buf = get_mem(len1); - if (buf == NULL) - return (-UNW_EUNSPEC); - len = len1; - error = sysctl(mib, 4, buf, &len, NULL, 0); - if (error == -1) { - free_mem(buf, len1); - return (-UNW_EUNSPEC); - } - ret = -UNW_EUNSPEC; - for (bp = buf, eb = buf + len; bp < eb; bp += kv->kve_structsize) { - kv = (struct kinfo_vmentry *)(uintptr_t)bp; - if (ip < kv->kve_start || ip >= kv->kve_end) - continue; - if (kv->kve_type != KVME_TYPE_VNODE) - continue; - *segbase = kv->kve_start; - *mapoff = kv->kve_offset; - if (path) - { - strncpy(path, kv->kve_path, pathlen); - } - ret = elf_map_image (ei, kv->kve_path); - break; - } - free_mem(buf, len1); - return (ret); -} - -#ifndef UNW_REMOTE_ONLY - -void -tdep_get_exe_image_path (char *path) -{ - int mib[4], error; - size_t len; - - len = 0; - mib[0] = CTL_KERN; - mib[1] = KERN_PROC; - mib[2] = KERN_PROC_PATHNAME; - mib[3] = getpid(); - - error = sysctl(mib, 4, path, &len, NULL, 0); - if (error == -1) - path[0] = 0; -} - -#endif diff --git a/src/pal/src/libunwind/src/os-hpux.c b/src/pal/src/libunwind/src/os-hpux.c deleted file mode 100644 index 48bfb05cf..000000000 --- a/src/pal/src/libunwind/src/os-hpux.c +++ /dev/null @@ -1,78 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2003-2005 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include -#include -#include - -#include "libunwind_i.h" - -#include "elf64.h" - -HIDDEN int -tdep_get_elf_image (struct elf_image *ei, pid_t pid, unw_word_t ip, - unsigned long *segbase, unsigned long *mapoff, - char *path, size_t pathlen) -{ - struct load_module_desc lmd; - const char *path2; - - if (pid != getpid ()) - { - printf ("%s: remote case not implemented yet\n", __FUNCTION__); - return -UNW_ENOINFO; - } - - if (!dlmodinfo (ip, &lmd, sizeof (lmd), NULL, 0, 0)) - return -UNW_ENOINFO; - - *segbase = lmd.text_base; - *mapoff = 0; /* XXX fix me? */ - - path2 = dlgetname (&lmd, sizeof (lmd), NULL, 0, 0); - if (!path2) - return -UNW_ENOINFO; - if (path) - { - strncpy(path, path2, pathlen); - path[pathlen - 1] = '\0'; - if (strcmp(path, path2) != 0) - Debug(1, "buffer size (%d) not big enough to hold path\n", pathlen); - } - Debug(1, "segbase=%lx, mapoff=%lx, path=%s\n", *segbase, *mapoff, path); - - return elf_map_image (ei, path); -} - -#ifndef UNW_REMOTE_ONLY - -void -tdep_get_exe_image_path (char *path) -{ - path[0] = 0; /* XXX */ -} - -#endif - diff --git a/src/pal/src/libunwind/src/os-linux.c b/src/pal/src/libunwind/src/os-linux.c deleted file mode 100644 index 8a00669fb..000000000 --- a/src/pal/src/libunwind/src/os-linux.c +++ /dev/null @@ -1,73 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2003-2005 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include -#include - -#include "libunwind_i.h" -#include "os-linux.h" - -int -tdep_get_elf_image (struct elf_image *ei, pid_t pid, unw_word_t ip, - unsigned long *segbase, unsigned long *mapoff, - char *path, size_t pathlen) -{ - struct map_iterator mi; - int found = 0, rc; - unsigned long hi; - - if (maps_init (&mi, pid) < 0) - return -1; - - while (maps_next (&mi, segbase, &hi, mapoff)) - if (ip >= *segbase && ip < hi) - { - found = 1; - break; - } - - if (!found) - { - maps_close (&mi); - return -1; - } - if (path) - { - strncpy(path, mi.path, pathlen); - } - rc = elf_map_image (ei, mi.path); - maps_close (&mi); - return rc; -} - -#ifndef UNW_REMOTE_ONLY - -void -tdep_get_exe_image_path (char *path) -{ - strcpy(path, "/proc/self/exe"); -} - -#endif /* !UNW_REMOTE_ONLY */ diff --git a/src/pal/src/libunwind/src/os-linux.h b/src/pal/src/libunwind/src/os-linux.h deleted file mode 100644 index 3976b38cc..000000000 --- a/src/pal/src/libunwind/src/os-linux.h +++ /dev/null @@ -1,297 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2003-2004 Hewlett-Packard Co - Copyright (C) 2007 David Mosberger-Tang - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#ifndef os_linux_h -#define os_linux_h - -struct map_iterator - { - off_t offset; - int fd; - size_t buf_size; - char *buf; - char *buf_end; - char *path; - }; - -static inline char * -ltoa (char *buf, long val) -{ - char *cp = buf, tmp; - ssize_t i, len; - - do - { - *cp++ = '0' + (val % 10); - val /= 10; - } - while (val); - - /* reverse the order of the digits: */ - len = cp - buf; - --cp; - for (i = 0; i < len / 2; ++i) - { - tmp = buf[i]; - buf[i] = cp[-i]; - cp[-i] = tmp; - } - return buf + len; -} - -static inline int -maps_init (struct map_iterator *mi, pid_t pid) -{ - char path[sizeof ("/proc/0123456789/maps")], *cp; - - memcpy (path, "/proc/", 6); - cp = ltoa (path + 6, pid); - assert (cp + 6 < path + sizeof (path)); - memcpy (cp, "/maps", 6); - - mi->fd = open (path, O_RDONLY); - if (mi->fd >= 0) - { - /* Try to allocate a page-sized buffer. */ - mi->buf_size = getpagesize (); - cp = mmap (NULL, mi->buf_size, PROT_READ | PROT_WRITE, - MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); - if (cp == MAP_FAILED) - { - close(mi->fd); - mi->fd = -1; - return -1; - } - else - { - mi->offset = 0; - mi->buf = mi->buf_end = cp + mi->buf_size; - return 0; - } - } - return -1; -} - -static inline char * -skip_whitespace (char *cp) -{ - if (!cp) - return NULL; - - while (*cp == ' ' || *cp == '\t') - ++cp; - return cp; -} - -static inline char * -scan_hex (char *cp, unsigned long *valp) -{ - unsigned long num_digits = 0, digit, val = 0; - - cp = skip_whitespace (cp); - if (!cp) - return NULL; - - while (1) - { - digit = *cp; - if ((digit - '0') <= 9) - digit -= '0'; - else if ((digit - 'a') < 6) - digit -= 'a' - 10; - else if ((digit - 'A') < 6) - digit -= 'A' - 10; - else - break; - val = (val << 4) | digit; - ++num_digits; - ++cp; - } - if (!num_digits) - return NULL; - *valp = val; - return cp; -} - -static inline char * -scan_dec (char *cp, unsigned long *valp) -{ - unsigned long num_digits = 0, digit, val = 0; - - if (!(cp = skip_whitespace (cp))) - return NULL; - - while (1) - { - digit = *cp; - if ((digit - '0') <= 9) - { - digit -= '0'; - ++cp; - } - else - break; - val = (10 * val) + digit; - ++num_digits; - } - if (!num_digits) - return NULL; - *valp = val; - return cp; -} - -static inline char * -scan_char (char *cp, char *valp) -{ - if (!cp) - return NULL; - - *valp = *cp; - - /* don't step over NUL terminator */ - if (*cp) - ++cp; - return cp; -} - -/* Scan a string delimited by white-space. Fails on empty string or - if string is doesn't fit in the specified buffer. */ -static inline char * -scan_string (char *cp, char *valp, size_t buf_size) -{ - size_t i = 0; - - if (!(cp = skip_whitespace (cp))) - return NULL; - - while (*cp != ' ' && *cp != '\t' && *cp != '\0') - { - if ((valp != NULL) && (i < buf_size - 1)) - valp[i++] = *cp; - ++cp; - } - if (i == 0 || i >= buf_size) - return NULL; - valp[i] = '\0'; - return cp; -} - -static inline int -maps_next (struct map_iterator *mi, - unsigned long *low, unsigned long *high, unsigned long *offset) -{ - char perm[16], dash = 0, colon = 0, *cp; - unsigned long major, minor, inum; - ssize_t i, nread; - - if (mi->fd < 0) - return 0; - - while (1) - { - ssize_t bytes_left = mi->buf_end - mi->buf; - char *eol = NULL; - - for (i = 0; i < bytes_left; ++i) - { - if (mi->buf[i] == '\n') - { - eol = mi->buf + i; - break; - } - else if (mi->buf[i] == '\0') - break; - } - if (!eol) - { - /* copy down the remaining bytes, if any */ - if (bytes_left > 0) - memmove (mi->buf_end - mi->buf_size, mi->buf, bytes_left); - - mi->buf = mi->buf_end - mi->buf_size; - nread = read (mi->fd, mi->buf + bytes_left, - mi->buf_size - bytes_left); - if (nread <= 0) - return 0; - else if ((size_t) (nread + bytes_left) < mi->buf_size) - { - /* Move contents to the end of the buffer so we - maintain the invariant that all bytes between - mi->buf and mi->buf_end are valid. */ - memmove (mi->buf_end - nread - bytes_left, mi->buf, - nread + bytes_left); - mi->buf = mi->buf_end - nread - bytes_left; - } - - eol = mi->buf + bytes_left + nread - 1; - - for (i = bytes_left; i < bytes_left + nread; ++i) - if (mi->buf[i] == '\n') - { - eol = mi->buf + i; - break; - } - } - cp = mi->buf; - mi->buf = eol + 1; - *eol = '\0'; - - /* scan: "LOW-HIGH PERM OFFSET MAJOR:MINOR INUM PATH" */ - cp = scan_hex (cp, low); - cp = scan_char (cp, &dash); - cp = scan_hex (cp, high); - cp = scan_string (cp, perm, sizeof (perm)); - cp = scan_hex (cp, offset); - cp = scan_hex (cp, &major); - cp = scan_char (cp, &colon); - cp = scan_hex (cp, &minor); - cp = scan_dec (cp, &inum); - cp = mi->path = skip_whitespace (cp); - if (!cp) - continue; - cp = scan_string (cp, NULL, 0); - if (dash != '-' || colon != ':') - continue; /* skip line with unknown or bad format */ - return 1; - } - return 0; -} - -static inline void -maps_close (struct map_iterator *mi) -{ - if (mi->fd < 0) - return; - close (mi->fd); - mi->fd = -1; - if (mi->buf) - { - munmap (mi->buf_end - mi->buf_size, mi->buf_size); - mi->buf = mi->buf_end = NULL; - } -} - -#endif /* os_linux_h */ diff --git a/src/pal/src/libunwind/src/os-qnx.c b/src/pal/src/libunwind/src/os-qnx.c deleted file mode 100644 index 4a76c7cda..000000000 --- a/src/pal/src/libunwind/src/os-qnx.c +++ /dev/null @@ -1,117 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2013 Garmin International - Contributed by Matt Fischer - -This file is part of libunwind. - -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. */ - -#include - -#include "libunwind_i.h" - -struct cb_info -{ - unw_word_t ip; - unsigned long segbase; - unsigned long offset; - const char *path; -}; - -static int callback(const struct dl_phdr_info *info, size_t size, void *data) -{ - int i; - struct cb_info *cbi = (struct cb_info*)data; - for(i=0; idlpi_phnum; i++) { - int segbase = info->dlpi_addr + info->dlpi_phdr[i].p_vaddr; - if(cbi->ip >= segbase && cbi->ip < segbase + info->dlpi_phdr[i].p_memsz) - { - cbi->path = info->dlpi_name; - cbi->offset = info->dlpi_phdr[i].p_offset; - cbi->segbase = segbase; - return 1; - } - } - - return 0; -} - -int -tdep_get_elf_image (struct elf_image *ei, pid_t pid, unw_word_t ip, - unsigned long *segbase, unsigned long *mapoff, - char *path, size_t pathlen) -{ - struct cb_info cbi; - int ret = -1; - cbi.ip = ip; - cbi.segbase = 0; - cbi.offset = 0; - cbi.path = NULL; - - /* QNX's support for accessing symbol maps is severely broken. There is - a devctl() call that can be made on a proc node (DCMD_PROC_MAPDEBUG) - which returns information similar to Linux's /proc//maps - node, however the filename that is returned by this call is not an - absolute path, and there is no foolproof way to map the filename - back to the file that it came from. - - Therefore, the normal approach for implementing this function, - which works equally well for both local and remote unwinding, - will not work here. The only type of image lookup which works - reliably is locally, using dl_iterate_phdr(). However, the only - time that this function is required to look up a remote image is for - ptrace support, which doesn't work on QNX anyway. Local unwinding, - which is the main case that makes use of this function, will work - fine with dl_iterate_phdr(). Therefore, in lieu of any better - platform support for remote image lookup, this function has just - been implemented in terms of dl_iterate_phdr(). - */ - - if (pid != getpid()) - { - /* Return an error if an attempt is made to perform remote image lookup */ - return -1; - } - - if (dl_iterate_phdr (callback, &cbi) != 0) - { - if (path) - { - strncpy (path, cbi.path, pathlen); - } - - *mapoff = cbi.offset; - *segbase = cbi.segbase; - - ret = elf_map_image (ei, cbi.path); - } - - return ret; -} - -#ifndef UNW_REMOTE_ONLY - -void -tdep_get_exe_image_path (char *path) -{ - path[0] = 0; /* XXX */ -} - -#endif diff --git a/src/pal/src/libunwind/src/ppc/Gapply_reg_state.c b/src/pal/src/libunwind/src/ppc/Gapply_reg_state.c deleted file mode 100644 index 82f056da6..000000000 --- a/src/pal/src/libunwind/src/ppc/Gapply_reg_state.c +++ /dev/null @@ -1,37 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (c) 2002-2003 Hewlett-Packard Development Company, L.P. - Contributed by David Mosberger-Tang - - Modified for x86_64 by Max Asbock - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" - -int -unw_apply_reg_state (unw_cursor_t *cursor, - void *reg_states_data) -{ - struct cursor *c = (struct cursor *) cursor; - - return dwarf_apply_reg_state (&c->dwarf, (dwarf_reg_state_t *)reg_states_data); -} diff --git a/src/pal/src/libunwind/src/ppc/Gget_proc_info.c b/src/pal/src/libunwind/src/ppc/Gget_proc_info.c deleted file mode 100644 index 7dfb6d4e4..000000000 --- a/src/pal/src/libunwind/src/ppc/Gget_proc_info.c +++ /dev/null @@ -1,41 +0,0 @@ -/* libunwind - a platform-independent unwind library - - Copied from src/x86_64/, modified slightly (or made empty stubs) for - building frysk successfully on ppc64, by Wu Zhou - -This file is part of libunwind. - -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. */ - -#include - -int -unw_get_proc_info (unw_cursor_t *cursor, unw_proc_info_t *pi) -{ - struct cursor *c = (struct cursor *) cursor; - int ret; - - ret = dwarf_make_proc_info (&c->dwarf); - if (ret < 0) - return ret; - - *pi = c->dwarf.pi; - return 0; -} diff --git a/src/pal/src/libunwind/src/ppc/Gget_save_loc.c b/src/pal/src/libunwind/src/ppc/Gget_save_loc.c deleted file mode 100644 index 5343fa4c7..000000000 --- a/src/pal/src/libunwind/src/ppc/Gget_save_loc.c +++ /dev/null @@ -1,34 +0,0 @@ -/* libunwind - a platform-independent unwind library - - Copied from src/x86_64/, modified slightly (or made empty stubs) for - building frysk successfully on ppc64, by Wu Zhou - -This file is part of libunwind. - -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. */ - -#include - -int -unw_get_save_loc (unw_cursor_t *cursor, int reg, unw_save_loc_t *sloc) -{ - /* XXX: empty stub. */ - return 0; -} diff --git a/src/pal/src/libunwind/src/ppc/Ginit_local.c b/src/pal/src/libunwind/src/ppc/Ginit_local.c deleted file mode 100644 index 366cf5bda..000000000 --- a/src/pal/src/libunwind/src/ppc/Ginit_local.c +++ /dev/null @@ -1,88 +0,0 @@ -/* libunwind - a platform-independent unwind library - - Copied from src/x86_64/, modified slightly (or made empty stubs) for - building frysk successfully on ppc64, by Wu Zhou - -This file is part of libunwind. - -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. */ - -#include - -#ifdef UNW_TARGET_PPC64 -#include "../ppc64/init.h" -#else -#include "../ppc32/init.h" -#endif - -#ifdef UNW_REMOTE_ONLY - -int -unw_init_local (unw_cursor_t *cursor, ucontext_t *uc) -{ - /* XXX: empty stub. */ - return -UNW_EINVAL; -} - -#else /* !UNW_REMOTE_ONLY */ - -static int -unw_init_local_common(unw_cursor_t *cursor, ucontext_t *uc, unsigned use_prev_instr) -{ - struct cursor *c = (struct cursor *) cursor; - - if (!tdep_init_done) - tdep_init (); - - Debug (1, "(cursor=%p)\n", c); - - c->dwarf.as = unw_local_addr_space; - c->dwarf.as_arg = uc; - #ifdef UNW_TARGET_PPC64 - return common_init_ppc64 (c, use_prev_instr); - #else - return common_init_ppc32 (c, use_prev_instr); - #endif -} - -int -unw_init_local(unw_cursor_t *cursor, ucontext_t *uc) -{ - return unw_init_local_common(cursor, uc, 1); -} - -int -unw_init_local2 (unw_cursor_t *cursor, ucontext_t *uc, int flag) -{ - if (!flag) - { - return unw_init_local_common(cursor, uc, 1); - } - else if (flag == UNW_INIT_SIGNAL_FRAME) - { - return unw_init_local_common(cursor, uc, 0); - } - else - { - return -UNW_EINVAL; - } -} - -#endif /* !UNW_REMOTE_ONLY */ diff --git a/src/pal/src/libunwind/src/ppc/Ginit_remote.c b/src/pal/src/libunwind/src/ppc/Ginit_remote.c deleted file mode 100644 index ed85be897..000000000 --- a/src/pal/src/libunwind/src/ppc/Ginit_remote.c +++ /dev/null @@ -1,60 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2006-2007 IBM - Contributed by - Corey Ashford - Jose Flavio Aguilar Paulino - -This file is part of libunwind. - -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. */ - -#include - -#ifdef UNW_TARGET_PPC64 -#include "../ppc64/init.h" -#else -#include "../ppc32/init.h" -#endif - -int -unw_init_remote (unw_cursor_t *cursor, unw_addr_space_t as, void *as_arg) -{ -#ifdef UNW_LOCAL_ONLY - return -UNW_EINVAL; -#else /* !UNW_LOCAL_ONLY */ - struct cursor *c = (struct cursor *) cursor; - - if (!tdep_init_done) - tdep_init (); - - Debug (1, "(cursor=%p)\n", c); - - c->dwarf.as = as; - c->dwarf.as_arg = as_arg; - - #ifdef UNW_TARGET_PPC64 - return common_init_ppc64 (c, 0); - #elif UNW_TARGET_PPC32 - return common_init_ppc32 (c, 0); - #else - #error init_remote :: NO VALID PPC ARCH! - #endif -#endif /* !UNW_LOCAL_ONLY */ -} diff --git a/src/pal/src/libunwind/src/ppc/Gis_signal_frame.c b/src/pal/src/libunwind/src/ppc/Gis_signal_frame.c deleted file mode 100644 index 6184dd5d4..000000000 --- a/src/pal/src/libunwind/src/ppc/Gis_signal_frame.c +++ /dev/null @@ -1,78 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2006-2007 IBM - Contributed by - Corey Ashford - Jose Flavio Aguilar Paulino - -This file is part of libunwind. - -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. */ - -#include - -int -unw_is_signal_frame (unw_cursor_t * cursor) -{ - struct cursor *c = (struct cursor *) cursor; - unw_word_t w0, w1, i0, i1, i2, ip; - unw_addr_space_t as; - unw_accessors_t *a; - void *arg; - int ret; - - as = c->dwarf.as; - as->validate = 1; /* Don't trust the ip */ - arg = c->dwarf.as_arg; - - /* Check if return address points at sigreturn sequence. - on ppc64 Linux that is (see libc.so): - 0x38210080 addi r1, r1, 128 // pop the stack - 0x380000ac li r0, 172 // invoke system service 172 - 0x44000002 sc - */ - - ip = c->dwarf.ip; - if (ip == 0) - return 0; - - /* Read up two 8-byte words at the IP. We are only looking at 3 - consecutive 32-bit words, so the second 8-byte word needs to be - shifted right by 32 bits (think big-endian) */ - - a = unw_get_accessors_int (as); - if ((ret = (*a->access_mem) (as, ip, &w0, 0, arg)) < 0 - || (ret = (*a->access_mem) (as, ip + 8, &w1, 0, arg)) < 0) - return 0; - - if (tdep_big_endian (as)) - { - i0 = w0 >> 32; - i1 = w0 & 0xffffffffUL; - i2 = w1 >> 32; - } - else - { - i0 = w0 & 0xffffffffUL; - i1 = w0 >> 32; - i2 = w1 & 0xffffffffUL; - } - - return (i0 == 0x38210080 && i1 == 0x380000ac && i2 == 0x44000002); -} diff --git a/src/pal/src/libunwind/src/ppc/Greg_states_iterate.c b/src/pal/src/libunwind/src/ppc/Greg_states_iterate.c deleted file mode 100644 index a17dc1b56..000000000 --- a/src/pal/src/libunwind/src/ppc/Greg_states_iterate.c +++ /dev/null @@ -1,37 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (c) 2002-2003 Hewlett-Packard Development Company, L.P. - Contributed by David Mosberger-Tang - - Modified for x86_64 by Max Asbock - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" - -int -unw_reg_states_iterate (unw_cursor_t *cursor, - unw_reg_states_callback cb, void *token) -{ - struct cursor *c = (struct cursor *) cursor; - - return dwarf_reg_states_iterate (&c->dwarf, cb, token); -} diff --git a/src/pal/src/libunwind/src/ppc/Lapply_reg_state.c b/src/pal/src/libunwind/src/ppc/Lapply_reg_state.c deleted file mode 100644 index 7ebada480..000000000 --- a/src/pal/src/libunwind/src/ppc/Lapply_reg_state.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gapply_reg_state.c" -#endif diff --git a/src/pal/src/libunwind/src/ppc/Lget_proc_info.c b/src/pal/src/libunwind/src/ppc/Lget_proc_info.c deleted file mode 100644 index 69028b019..000000000 --- a/src/pal/src/libunwind/src/ppc/Lget_proc_info.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gget_proc_info.c" -#endif diff --git a/src/pal/src/libunwind/src/ppc/Lget_save_loc.c b/src/pal/src/libunwind/src/ppc/Lget_save_loc.c deleted file mode 100644 index 9ea048a90..000000000 --- a/src/pal/src/libunwind/src/ppc/Lget_save_loc.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gget_save_loc.c" -#endif diff --git a/src/pal/src/libunwind/src/ppc/Linit_local.c b/src/pal/src/libunwind/src/ppc/Linit_local.c deleted file mode 100644 index 68a1687e8..000000000 --- a/src/pal/src/libunwind/src/ppc/Linit_local.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Ginit_local.c" -#endif diff --git a/src/pal/src/libunwind/src/ppc/Linit_remote.c b/src/pal/src/libunwind/src/ppc/Linit_remote.c deleted file mode 100644 index 58cb04ab7..000000000 --- a/src/pal/src/libunwind/src/ppc/Linit_remote.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Ginit_remote.c" -#endif diff --git a/src/pal/src/libunwind/src/ppc/Lis_signal_frame.c b/src/pal/src/libunwind/src/ppc/Lis_signal_frame.c deleted file mode 100644 index b9a7c4f51..000000000 --- a/src/pal/src/libunwind/src/ppc/Lis_signal_frame.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gis_signal_frame.c" -#endif diff --git a/src/pal/src/libunwind/src/ppc/Lreg_states_iterate.c b/src/pal/src/libunwind/src/ppc/Lreg_states_iterate.c deleted file mode 100644 index f1eb1e79d..000000000 --- a/src/pal/src/libunwind/src/ppc/Lreg_states_iterate.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Greg_states_iterate.c" -#endif diff --git a/src/pal/src/libunwind/src/ppc/longjmp.S b/src/pal/src/libunwind/src/ppc/longjmp.S deleted file mode 100644 index d363aef22..000000000 --- a/src/pal/src/libunwind/src/ppc/longjmp.S +++ /dev/null @@ -1,36 +0,0 @@ -/* libunwind - a platform-independent unwind library - - Copied from src/x86_64/, modified slightly (or made empty stubs) for - building frysk successfully on ppc64, by Wu Zhou - -This file is part of libunwind. - -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. */ - - .globl _UI_longjmp_cont - - .type _UI_longjmp_cont, @function -_UI_longjmp_cont: - .size _UI_longjmp_cont, .-_UI_longjmp_cont - -#ifdef __linux__ - /* We do not need executable stack. */ - .section .note.GNU-stack,"",@progbits -#endif diff --git a/src/pal/src/libunwind/src/ppc/siglongjmp.S b/src/pal/src/libunwind/src/ppc/siglongjmp.S deleted file mode 100644 index 64be36ce1..000000000 --- a/src/pal/src/libunwind/src/ppc/siglongjmp.S +++ /dev/null @@ -1,31 +0,0 @@ -/* libunwind - a platform-independent unwind library - -This file is part of libunwind. - -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. */ - - .globl _UI_siglongjmp_cont - - _UI_siglongjmp_cont: - -#ifdef __linux__ - /* We do not need executable stack. */ - .section .note.GNU-stack,"",@progbits -#endif diff --git a/src/pal/src/libunwind/src/ppc32/Gapply_reg_state.c b/src/pal/src/libunwind/src/ppc32/Gapply_reg_state.c deleted file mode 100644 index 82f056da6..000000000 --- a/src/pal/src/libunwind/src/ppc32/Gapply_reg_state.c +++ /dev/null @@ -1,37 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (c) 2002-2003 Hewlett-Packard Development Company, L.P. - Contributed by David Mosberger-Tang - - Modified for x86_64 by Max Asbock - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" - -int -unw_apply_reg_state (unw_cursor_t *cursor, - void *reg_states_data) -{ - struct cursor *c = (struct cursor *) cursor; - - return dwarf_apply_reg_state (&c->dwarf, (dwarf_reg_state_t *)reg_states_data); -} diff --git a/src/pal/src/libunwind/src/ppc32/Gcreate_addr_space.c b/src/pal/src/libunwind/src/ppc32/Gcreate_addr_space.c deleted file mode 100644 index aaa68bb35..000000000 --- a/src/pal/src/libunwind/src/ppc32/Gcreate_addr_space.c +++ /dev/null @@ -1,56 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2006-2007 IBM - Contributed by - Corey Ashford - Jose Flavio Aguilar Paulino - -This file is part of libunwind. - -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. */ - -#include - -#include - -unw_addr_space_t -unw_create_addr_space (unw_accessors_t *a, int byte_order) -{ -#ifdef UNW_LOCAL_ONLY - return NULL; -#else - unw_addr_space_t as; - - /* - * We support only big-endian on Linux ppc32. - */ - if (byte_order != 0 && byte_order != __BIG_ENDIAN) - return NULL; - - as = malloc (sizeof (*as)); - if (!as) - return NULL; - - memset (as, 0, sizeof (*as)); - - as->acc = *a; - - return as; -#endif -} diff --git a/src/pal/src/libunwind/src/ppc32/Gglobal.c b/src/pal/src/libunwind/src/ppc32/Gglobal.c deleted file mode 100644 index a0f80beec..000000000 --- a/src/pal/src/libunwind/src/ppc32/Gglobal.c +++ /dev/null @@ -1,135 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2006-2007 IBM - Contributed by - Corey Ashford - Jose Flavio Aguilar Paulino - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" -#include "dwarf_i.h" - -HIDDEN define_lock (ppc32_lock); -HIDDEN int tdep_init_done; - -/* The API register numbers are exactly the same as the .eh_frame - registers, for now at least. */ -HIDDEN const uint8_t dwarf_to_unw_regnum_map[DWARF_REGNUM_MAP_LENGTH] = - { - [UNW_PPC32_R0]=UNW_PPC32_R0, - [UNW_PPC32_R1]=UNW_PPC32_R1, - [UNW_PPC32_R2]=UNW_PPC32_R2, - [UNW_PPC32_R3]=UNW_PPC32_R3, - [UNW_PPC32_R4]=UNW_PPC32_R4, - [UNW_PPC32_R5]=UNW_PPC32_R5, - [UNW_PPC32_R6]=UNW_PPC32_R6, - [UNW_PPC32_R7]=UNW_PPC32_R7, - [UNW_PPC32_R8]=UNW_PPC32_R8, - [UNW_PPC32_R9]=UNW_PPC32_R9, - [UNW_PPC32_R10]=UNW_PPC32_R10, - [UNW_PPC32_R11]=UNW_PPC32_R11, - [UNW_PPC32_R12]=UNW_PPC32_R12, - [UNW_PPC32_R13]=UNW_PPC32_R13, - [UNW_PPC32_R14]=UNW_PPC32_R14, - [UNW_PPC32_R15]=UNW_PPC32_R15, - [UNW_PPC32_R16]=UNW_PPC32_R16, - [UNW_PPC32_R17]=UNW_PPC32_R17, - [UNW_PPC32_R18]=UNW_PPC32_R18, - [UNW_PPC32_R19]=UNW_PPC32_R19, - [UNW_PPC32_R20]=UNW_PPC32_R20, - [UNW_PPC32_R21]=UNW_PPC32_R21, - [UNW_PPC32_R22]=UNW_PPC32_R22, - [UNW_PPC32_R23]=UNW_PPC32_R23, - [UNW_PPC32_R24]=UNW_PPC32_R24, - [UNW_PPC32_R25]=UNW_PPC32_R25, - [UNW_PPC32_R26]=UNW_PPC32_R26, - [UNW_PPC32_R27]=UNW_PPC32_R27, - [UNW_PPC32_R28]=UNW_PPC32_R28, - [UNW_PPC32_R29]=UNW_PPC32_R29, - [UNW_PPC32_R30]=UNW_PPC32_R30, - [UNW_PPC32_R31]=UNW_PPC32_R31, - - [UNW_PPC32_CTR]=UNW_PPC32_CTR, - [UNW_PPC32_XER]=UNW_PPC32_XER, - [UNW_PPC32_CCR]=UNW_PPC32_CCR, - [UNW_PPC32_LR]=UNW_PPC32_LR, - [UNW_PPC32_FPSCR]=UNW_PPC32_FPSCR, - - [UNW_PPC32_F0]=UNW_PPC32_F0, - [UNW_PPC32_F1]=UNW_PPC32_F1, - [UNW_PPC32_F2]=UNW_PPC32_F2, - [UNW_PPC32_F3]=UNW_PPC32_F3, - [UNW_PPC32_F4]=UNW_PPC32_F4, - [UNW_PPC32_F5]=UNW_PPC32_F5, - [UNW_PPC32_F6]=UNW_PPC32_F6, - [UNW_PPC32_F7]=UNW_PPC32_F7, - [UNW_PPC32_F8]=UNW_PPC32_F8, - [UNW_PPC32_F9]=UNW_PPC32_F9, - [UNW_PPC32_F10]=UNW_PPC32_F10, - [UNW_PPC32_F11]=UNW_PPC32_F11, - [UNW_PPC32_F12]=UNW_PPC32_F12, - [UNW_PPC32_F13]=UNW_PPC32_F13, - [UNW_PPC32_F14]=UNW_PPC32_F14, - [UNW_PPC32_F15]=UNW_PPC32_F15, - [UNW_PPC32_F16]=UNW_PPC32_F16, - [UNW_PPC32_F17]=UNW_PPC32_F17, - [UNW_PPC32_F18]=UNW_PPC32_F18, - [UNW_PPC32_F19]=UNW_PPC32_F19, - [UNW_PPC32_F20]=UNW_PPC32_F20, - [UNW_PPC32_F21]=UNW_PPC32_F21, - [UNW_PPC32_F22]=UNW_PPC32_F22, - [UNW_PPC32_F23]=UNW_PPC32_F23, - [UNW_PPC32_F24]=UNW_PPC32_F24, - [UNW_PPC32_F25]=UNW_PPC32_F25, - [UNW_PPC32_F26]=UNW_PPC32_F26, - [UNW_PPC32_F27]=UNW_PPC32_F27, - [UNW_PPC32_F28]=UNW_PPC32_F28, - [UNW_PPC32_F29]=UNW_PPC32_F29, - [UNW_PPC32_F30]=UNW_PPC32_F30, - [UNW_PPC32_F31]=UNW_PPC32_F31, -}; - -HIDDEN void -tdep_init (void) -{ - intrmask_t saved_mask; - - sigfillset (&unwi_full_mask); - - lock_acquire (&ppc32_lock, saved_mask); - { - if (tdep_init_done) - /* another thread else beat us to it... */ - goto out; - - mi_init (); - - dwarf_init (); - -#ifndef UNW_REMOTE_ONLY - ppc32_local_addr_space_init (); -#endif - tdep_init_done = 1; /* signal that we're initialized... */ - } - out: - lock_release (&ppc32_lock, saved_mask); -} diff --git a/src/pal/src/libunwind/src/ppc32/Ginit.c b/src/pal/src/libunwind/src/ppc32/Ginit.c deleted file mode 100644 index ba302448a..000000000 --- a/src/pal/src/libunwind/src/ppc32/Ginit.c +++ /dev/null @@ -1,216 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2006-2007 IBM - Contributed by - Corey Ashford - Jose Flavio Aguilar Paulino - -This file is part of libunwind. - -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. */ - -#include -#include - -#include "ucontext_i.h" -#include "unwind_i.h" - -#ifdef UNW_REMOTE_ONLY - -/* unw_local_addr_space is a NULL pointer in this case. */ -unw_addr_space_t unw_local_addr_space; - -#else /* !UNW_REMOTE_ONLY */ - -static struct unw_addr_space local_addr_space; - -unw_addr_space_t unw_local_addr_space = &local_addr_space; - -static void * -uc_addr (ucontext_t *uc, int reg) -{ - void *addr; - - if ((unsigned) (reg - UNW_PPC32_R0) < 32) - addr = &uc->uc_mcontext.uc_regs->gregs[reg - UNW_PPC32_R0]; - - else - if ( ((unsigned) (reg - UNW_PPC32_F0) < 32) && - ((unsigned) (reg - UNW_PPC32_F0) >= 0) ) - addr = &uc->uc_mcontext.uc_regs->fpregs.fpregs[reg - UNW_PPC32_F0]; - - else - { - unsigned gregs_idx; - - switch (reg) - { - case UNW_PPC32_CTR: - gregs_idx = CTR_IDX; - break; - case UNW_PPC32_LR: - gregs_idx = LINK_IDX; - break; - case UNW_PPC32_XER: - gregs_idx = XER_IDX; - break; - case UNW_PPC32_CCR: - gregs_idx = CCR_IDX; - break; - default: - return NULL; - } - addr = &uc->uc_mcontext.uc_regs->gregs[gregs_idx]; - } - return addr; -} - -# ifdef UNW_LOCAL_ONLY - -HIDDEN void * -tdep_uc_addr (ucontext_t *uc, int reg) -{ - return uc_addr (uc, reg); -} - -# endif /* UNW_LOCAL_ONLY */ - -HIDDEN unw_dyn_info_list_t _U_dyn_info_list; - - -static void -put_unwind_info (unw_addr_space_t as, unw_proc_info_t *proc_info, void *arg) -{ - /* it's a no-op */ -} - -static int -get_dyn_info_list_addr (unw_addr_space_t as, unw_word_t *dyn_info_list_addr, - void *arg) -{ - *dyn_info_list_addr = (unw_word_t) &_U_dyn_info_list; - return 0; -} - -static int -access_mem (unw_addr_space_t as, unw_word_t addr, unw_word_t *val, int write, - void *arg) -{ - if (write) - { - Debug (12, "mem[%lx] <- %lx\n", addr, *val); - *(unw_word_t *) addr = *val; - } - else - { - *val = *(unw_word_t *) addr; - Debug (12, "mem[%lx] -> %lx\n", addr, *val); - } - return 0; -} - -static int -access_reg (unw_addr_space_t as, unw_regnum_t reg, unw_word_t *val, - int write, void *arg) -{ - unw_word_t *addr; - ucontext_t *uc = arg; - - if ( ((unsigned int) (reg - UNW_PPC32_F0) < 32) && - ((unsigned int) (reg - UNW_PPC32_F0) >= 0)) - goto badreg; - - addr = uc_addr (uc, reg); - if (!addr) - goto badreg; - - if (write) - { - *(unw_word_t *) addr = *val; - Debug (12, "%s <- %lx\n", unw_regname (reg), *val); - } - else - { - *val = *(unw_word_t *) addr; - Debug (12, "%s -> %lx\n", unw_regname (reg), *val); - } - return 0; - -badreg: - Debug (1, "bad register number %u\n", reg); - return -UNW_EBADREG; -} - -static int -access_fpreg (unw_addr_space_t as, unw_regnum_t reg, unw_fpreg_t *val, - int write, void *arg) -{ - ucontext_t *uc = arg; - unw_fpreg_t *addr; - - if ((unsigned) (reg - UNW_PPC32_F0) < 0) - goto badreg; - - addr = uc_addr (uc, reg); - if (!addr) - goto badreg; - - if (write) - { - Debug (12, "%s <- %016Lf\n", unw_regname (reg), *val); - *(unw_fpreg_t *) addr = *val; - } - else - { - *val = *(unw_fpreg_t *) addr; - Debug (12, "%s -> %016Lf\n", unw_regname (reg), *val); - } - return 0; - -badreg: - Debug (1, "bad register number %u\n", reg); - /* attempt to access a non-preserved register */ - return -UNW_EBADREG; -} - -static int -get_static_proc_name (unw_addr_space_t as, unw_word_t ip, - char *buf, size_t buf_len, unw_word_t *offp, - void *arg) -{ - return _Uelf32_get_proc_name (as, getpid (), ip, buf, buf_len, offp); -} - -HIDDEN void -ppc32_local_addr_space_init (void) -{ - memset (&local_addr_space, 0, sizeof (local_addr_space)); - local_addr_space.caching_policy = UNWI_DEFAULT_CACHING_POLICY; - local_addr_space.acc.find_proc_info = dwarf_find_proc_info; - local_addr_space.acc.put_unwind_info = put_unwind_info; - local_addr_space.acc.get_dyn_info_list_addr = get_dyn_info_list_addr; - local_addr_space.acc.access_mem = access_mem; - local_addr_space.acc.access_reg = access_reg; - local_addr_space.acc.access_fpreg = access_fpreg; - local_addr_space.acc.resume = ppc32_local_resume; - local_addr_space.acc.get_proc_name = get_static_proc_name; - unw_flush_cache (&local_addr_space, 0, 0); -} - -#endif /* !UNW_REMOTE_ONLY */ diff --git a/src/pal/src/libunwind/src/ppc32/Greg_states_iterate.c b/src/pal/src/libunwind/src/ppc32/Greg_states_iterate.c deleted file mode 100644 index a17dc1b56..000000000 --- a/src/pal/src/libunwind/src/ppc32/Greg_states_iterate.c +++ /dev/null @@ -1,37 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (c) 2002-2003 Hewlett-Packard Development Company, L.P. - Contributed by David Mosberger-Tang - - Modified for x86_64 by Max Asbock - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" - -int -unw_reg_states_iterate (unw_cursor_t *cursor, - unw_reg_states_callback cb, void *token) -{ - struct cursor *c = (struct cursor *) cursor; - - return dwarf_reg_states_iterate (&c->dwarf, cb, token); -} diff --git a/src/pal/src/libunwind/src/ppc32/Gregs.c b/src/pal/src/libunwind/src/ppc32/Gregs.c deleted file mode 100644 index 9344455e6..000000000 --- a/src/pal/src/libunwind/src/ppc32/Gregs.c +++ /dev/null @@ -1,90 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2006-2007 IBM - Contributed by - Corey Ashford - Jose Flavio Aguilar Paulino - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" - -HIDDEN int -tdep_access_reg (struct cursor *c, unw_regnum_t reg, unw_word_t *valp, - int write) -{ - struct dwarf_loc loc; - - switch (reg) - { - case UNW_TDEP_IP: - if (write) - { - c->dwarf.ip = *valp; /* update the IP cache */ - if (c->dwarf.pi_valid && (*valp < c->dwarf.pi.start_ip - || *valp >= c->dwarf.pi.end_ip)) - c->dwarf.pi_valid = 0; /* new IP outside of current proc */ - } - else - *valp = c->dwarf.ip; - return 0; - - case UNW_TDEP_SP: - if (write) - return -UNW_EREADONLYREG; - *valp = c->dwarf.cfa; - return 0; - - - default: - break; - } - - /* make sure it's not an FP or VR register */ - if ((((unsigned) (reg - UNW_PPC32_F0)) <= 31)) - return -UNW_EBADREG; - - loc = c->dwarf.loc[reg]; - - if (write) - return dwarf_put (&c->dwarf, loc, *valp); - else - return dwarf_get (&c->dwarf, loc, valp); -} - -HIDDEN int -tdep_access_fpreg (struct cursor *c, unw_regnum_t reg, unw_fpreg_t *valp, - int write) -{ - struct dwarf_loc loc; - - if ((unsigned) (reg - UNW_PPC32_F0) < 32) - { - loc = c->dwarf.loc[reg]; - if (write) - return dwarf_putfp (&c->dwarf, loc, *valp); - else - return dwarf_getfp (&c->dwarf, loc, valp); - } - - return -UNW_EBADREG; -} - diff --git a/src/pal/src/libunwind/src/ppc32/Gresume.c b/src/pal/src/libunwind/src/ppc32/Gresume.c deleted file mode 100644 index c0f95837b..000000000 --- a/src/pal/src/libunwind/src/ppc32/Gresume.c +++ /dev/null @@ -1,77 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2006-2007 IBM - Contributed by - Corey Ashford cjashfor@us.ibm.com - Jose Flavio Aguilar Paulino - -This file is part of libunwind. - -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. */ - -#include - -#include "unwind_i.h" - -#ifndef UNW_REMOTE_ONLY - -#include - -/* sigreturn() is a no-op on x86_64 glibc. */ - -static NORETURN inline long -my_rt_sigreturn (void *new_sp) -{ - /* XXX: empty stub. */ - abort (); -} - -HIDDEN inline int -ppc32_local_resume (unw_addr_space_t as, unw_cursor_t *cursor, void *arg) -{ - /* XXX: empty stub. */ - return -UNW_EINVAL; -} - -#endif /* !UNW_REMOTE_ONLY */ - -/* This routine is responsible for copying the register values in - cursor C and establishing them as the current machine state. */ - -static inline int -establish_machine_state (struct cursor *c) -{ - /* XXX: empty stub. */ - return 0; -} - -int -unw_resume (unw_cursor_t *cursor) -{ - struct cursor *c = (struct cursor *) cursor; - int ret; - - Debug (1, "(cursor=%p)\n", c); - - if ((ret = establish_machine_state (c)) < 0) - return ret; - - return (*c->dwarf.as->acc.resume) (c->dwarf.as, (unw_cursor_t *) c, - c->dwarf.as_arg); -} diff --git a/src/pal/src/libunwind/src/ppc32/Gstep.c b/src/pal/src/libunwind/src/ppc32/Gstep.c deleted file mode 100644 index 478d3a6c1..000000000 --- a/src/pal/src/libunwind/src/ppc32/Gstep.c +++ /dev/null @@ -1,309 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2006-2007 IBM - Contributed by - Corey Ashford - Jose Flavio Aguilar Paulino - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" -#include "ucontext_i.h" -#include - -/* This definition originates in /usr/include/asm-ppc64/ptrace.h, but is - defined there only when __KERNEL__ is defined. We reproduce it here for - our use at the user level in order to locate the ucontext record, which - appears to be at this offset relative to the stack pointer when in the - context of the signal handler return trampoline code - - __kernel_sigtramp_rt64. */ -#define __SIGNAL_FRAMESIZE 128 - -/* This definition comes from the document "64-bit PowerPC ELF Application - Binary Interface Supplement 1.9", section 3.2.2. - http://www.linux-foundation.org/spec/ELF/ppc64/PPC-elf64abi-1.9.html#STACK */ - -typedef struct -{ - long unsigned back_chain; - long unsigned lr_save; - /* many more fields here, but they are unused by this code */ -} stack_frame_t; - - -int -unw_step (unw_cursor_t * cursor) -{ - struct cursor *c = (struct cursor *) cursor; - stack_frame_t dummy; - unw_word_t back_chain_offset, lr_save_offset; - struct dwarf_loc back_chain_loc, lr_save_loc, sp_loc, ip_loc; - int ret; - - Debug (1, "(cursor=%p, ip=0x%016lx)\n", c, (unsigned long) c->dwarf.ip); - - if (c->dwarf.ip == 0) - { - /* Unless the cursor or stack is corrupt or uninitialized, - we've most likely hit the top of the stack */ - return 0; - } - - /* Try DWARF-based unwinding... */ - - ret = dwarf_step (&c->dwarf); - - if (ret < 0 && ret != -UNW_ENOINFO) - { - Debug (2, "returning %d\n", ret); - return ret; - } - - if (unlikely (ret < 0)) - { - if (likely (unw_is_signal_frame (cursor) <= 0)) - { - /* DWARF unwinding failed. As of 09/26/2006, gcc in 64-bit mode - produces the mandatory level of traceback record in the code, but - I get the impression that this is transitory, that eventually gcc - will not produce any traceback records at all. So, for now, we - won't bother to try to find and use these records. - - We can, however, attempt to unwind the frame by using the callback - chain. This is very crude, however, and won't be able to unwind - any registers besides the IP, SP, and LR . */ - - back_chain_offset = ((void *) &dummy.back_chain - (void *) &dummy); - lr_save_offset = ((void *) &dummy.lr_save - (void *) &dummy); - - back_chain_loc = DWARF_LOC (c->dwarf.cfa + back_chain_offset, 0); - - if ((ret = - dwarf_get (&c->dwarf, back_chain_loc, &c->dwarf.cfa)) < 0) - { - Debug (2, - "Unable to retrieve CFA from back chain in stack frame - %d\n", - ret); - return ret; - } - if (c->dwarf.cfa == 0) - /* Unless the cursor or stack is corrupt or uninitialized we've most - likely hit the top of the stack */ - return 0; - - lr_save_loc = DWARF_LOC (c->dwarf.cfa + lr_save_offset, 0); - - if ((ret = dwarf_get (&c->dwarf, lr_save_loc, &c->dwarf.ip)) < 0) - { - Debug (2, - "Unable to retrieve IP from lr save in stack frame - %d\n", - ret); - return ret; - } - ret = 1; - } - else - { - /* Find the sigcontext record by taking the CFA and adjusting by - the dummy signal frame size. - - Note that there isn't any way to determined if SA_SIGINFO was - set in the sa_flags parameter to sigaction when the signal - handler was established. If it was not set, the ucontext - record is not required to be on the stack, in which case the - following code will likely cause a seg fault or other crash - condition. */ - - unw_word_t ucontext = c->dwarf.cfa + __SIGNAL_FRAMESIZE; - - Debug (1, "signal frame, skip over trampoline\n"); - - c->sigcontext_format = PPC_SCF_LINUX_RT_SIGFRAME; - c->sigcontext_addr = ucontext; - - sp_loc = DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R1, 0); - ip_loc = DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_LINK, 0); - - ret = dwarf_get (&c->dwarf, sp_loc, &c->dwarf.cfa); - if (ret < 0) - { - Debug (2, "returning %d\n", ret); - return ret; - } - ret = dwarf_get (&c->dwarf, ip_loc, &c->dwarf.ip); - if (ret < 0) - { - Debug (2, "returning %d\n", ret); - return ret; - } - - /* Instead of just restoring the non-volatile registers, do all - of the registers for now. This will incur a performance hit, - but it's rare enough not to cause too much of a problem, and - might be useful in some cases. */ - c->dwarf.loc[UNW_PPC32_R0] = - DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R0, 0); - c->dwarf.loc[UNW_PPC32_R1] = - DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R1, 0); - c->dwarf.loc[UNW_PPC32_R2] = - DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R2, 0); - c->dwarf.loc[UNW_PPC32_R3] = - DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R3, 0); - c->dwarf.loc[UNW_PPC32_R4] = - DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R4, 0); - c->dwarf.loc[UNW_PPC32_R5] = - DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R5, 0); - c->dwarf.loc[UNW_PPC32_R6] = - DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R6, 0); - c->dwarf.loc[UNW_PPC32_R7] = - DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R7, 0); - c->dwarf.loc[UNW_PPC32_R8] = - DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R8, 0); - c->dwarf.loc[UNW_PPC32_R9] = - DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R9, 0); - c->dwarf.loc[UNW_PPC32_R10] = - DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R10, 0); - c->dwarf.loc[UNW_PPC32_R11] = - DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R11, 0); - c->dwarf.loc[UNW_PPC32_R12] = - DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R12, 0); - c->dwarf.loc[UNW_PPC32_R13] = - DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R13, 0); - c->dwarf.loc[UNW_PPC32_R14] = - DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R14, 0); - c->dwarf.loc[UNW_PPC32_R15] = - DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R15, 0); - c->dwarf.loc[UNW_PPC32_R16] = - DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R16, 0); - c->dwarf.loc[UNW_PPC32_R17] = - DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R17, 0); - c->dwarf.loc[UNW_PPC32_R18] = - DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R18, 0); - c->dwarf.loc[UNW_PPC32_R19] = - DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R19, 0); - c->dwarf.loc[UNW_PPC32_R20] = - DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R20, 0); - c->dwarf.loc[UNW_PPC32_R21] = - DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R21, 0); - c->dwarf.loc[UNW_PPC32_R22] = - DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R22, 0); - c->dwarf.loc[UNW_PPC32_R23] = - DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R23, 0); - c->dwarf.loc[UNW_PPC32_R24] = - DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R24, 0); - c->dwarf.loc[UNW_PPC32_R25] = - DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R25, 0); - c->dwarf.loc[UNW_PPC32_R26] = - DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R26, 0); - c->dwarf.loc[UNW_PPC32_R27] = - DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R27, 0); - c->dwarf.loc[UNW_PPC32_R28] = - DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R28, 0); - c->dwarf.loc[UNW_PPC32_R29] = - DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R29, 0); - c->dwarf.loc[UNW_PPC32_R30] = - DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R30, 0); - c->dwarf.loc[UNW_PPC32_R31] = - DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R31, 0); - - c->dwarf.loc[UNW_PPC32_LR] = - DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_LINK, 0); - c->dwarf.loc[UNW_PPC32_CTR] = - DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_CTR, 0); - - /* This CR0 assignment is probably wrong. There are 8 dwarf columns - assigned to the CR registers, but only one CR register in the - mcontext structure */ - c->dwarf.loc[UNW_PPC32_CCR] = - DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_CCR, 0); - c->dwarf.loc[UNW_PPC32_XER] = - DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_XER, 0); - - c->dwarf.loc[UNW_PPC32_F0] = - DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R0, 0); - c->dwarf.loc[UNW_PPC32_F1] = - DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R1, 0); - c->dwarf.loc[UNW_PPC32_F2] = - DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R2, 0); - c->dwarf.loc[UNW_PPC32_F3] = - DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R3, 0); - c->dwarf.loc[UNW_PPC32_F4] = - DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R4, 0); - c->dwarf.loc[UNW_PPC32_F5] = - DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R5, 0); - c->dwarf.loc[UNW_PPC32_F6] = - DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R6, 0); - c->dwarf.loc[UNW_PPC32_F7] = - DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R7, 0); - c->dwarf.loc[UNW_PPC32_F8] = - DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R8, 0); - c->dwarf.loc[UNW_PPC32_F9] = - DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R9, 0); - c->dwarf.loc[UNW_PPC32_F10] = - DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R10, 0); - c->dwarf.loc[UNW_PPC32_F11] = - DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R11, 0); - c->dwarf.loc[UNW_PPC32_F12] = - DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R12, 0); - c->dwarf.loc[UNW_PPC32_F13] = - DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R13, 0); - c->dwarf.loc[UNW_PPC32_F14] = - DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R14, 0); - c->dwarf.loc[UNW_PPC32_F15] = - DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R15, 0); - c->dwarf.loc[UNW_PPC32_F16] = - DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R16, 0); - c->dwarf.loc[UNW_PPC32_F17] = - DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R17, 0); - c->dwarf.loc[UNW_PPC32_F18] = - DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R18, 0); - c->dwarf.loc[UNW_PPC32_F19] = - DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R19, 0); - c->dwarf.loc[UNW_PPC32_F20] = - DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R20, 0); - c->dwarf.loc[UNW_PPC32_F21] = - DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R21, 0); - c->dwarf.loc[UNW_PPC32_F22] = - DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R22, 0); - c->dwarf.loc[UNW_PPC32_F23] = - DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R23, 0); - c->dwarf.loc[UNW_PPC32_F24] = - DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R24, 0); - c->dwarf.loc[UNW_PPC32_F25] = - DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R25, 0); - c->dwarf.loc[UNW_PPC32_F26] = - DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R26, 0); - c->dwarf.loc[UNW_PPC32_F27] = - DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R27, 0); - c->dwarf.loc[UNW_PPC32_F28] = - DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R28, 0); - c->dwarf.loc[UNW_PPC32_F29] = - DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R29, 0); - c->dwarf.loc[UNW_PPC32_F30] = - DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R30, 0); - c->dwarf.loc[UNW_PPC32_F31] = - DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R31, 0); - - ret = 1; - } - } - return ret; -} diff --git a/src/pal/src/libunwind/src/ppc32/Lapply_reg_state.c b/src/pal/src/libunwind/src/ppc32/Lapply_reg_state.c deleted file mode 100644 index 7ebada480..000000000 --- a/src/pal/src/libunwind/src/ppc32/Lapply_reg_state.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gapply_reg_state.c" -#endif diff --git a/src/pal/src/libunwind/src/ppc32/Lcreate_addr_space.c b/src/pal/src/libunwind/src/ppc32/Lcreate_addr_space.c deleted file mode 100644 index 0f2dc6be9..000000000 --- a/src/pal/src/libunwind/src/ppc32/Lcreate_addr_space.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gcreate_addr_space.c" -#endif diff --git a/src/pal/src/libunwind/src/ppc32/Lglobal.c b/src/pal/src/libunwind/src/ppc32/Lglobal.c deleted file mode 100644 index 6d7b489e1..000000000 --- a/src/pal/src/libunwind/src/ppc32/Lglobal.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gglobal.c" -#endif diff --git a/src/pal/src/libunwind/src/ppc32/Linit.c b/src/pal/src/libunwind/src/ppc32/Linit.c deleted file mode 100644 index e9abfdd46..000000000 --- a/src/pal/src/libunwind/src/ppc32/Linit.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Ginit.c" -#endif diff --git a/src/pal/src/libunwind/src/ppc32/Lreg_states_iterate.c b/src/pal/src/libunwind/src/ppc32/Lreg_states_iterate.c deleted file mode 100644 index f1eb1e79d..000000000 --- a/src/pal/src/libunwind/src/ppc32/Lreg_states_iterate.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Greg_states_iterate.c" -#endif diff --git a/src/pal/src/libunwind/src/ppc32/Lregs.c b/src/pal/src/libunwind/src/ppc32/Lregs.c deleted file mode 100644 index 2c9c75cd7..000000000 --- a/src/pal/src/libunwind/src/ppc32/Lregs.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gregs.c" -#endif diff --git a/src/pal/src/libunwind/src/ppc32/Lresume.c b/src/pal/src/libunwind/src/ppc32/Lresume.c deleted file mode 100644 index 41a8cf003..000000000 --- a/src/pal/src/libunwind/src/ppc32/Lresume.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gresume.c" -#endif diff --git a/src/pal/src/libunwind/src/ppc32/Lstep.c b/src/pal/src/libunwind/src/ppc32/Lstep.c deleted file mode 100644 index c1ac3c754..000000000 --- a/src/pal/src/libunwind/src/ppc32/Lstep.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gstep.c" -#endif diff --git a/src/pal/src/libunwind/src/ppc32/Make-arch.in b/src/pal/src/libunwind/src/ppc32/Make-arch.in deleted file mode 100644 index 947dd5fa0..000000000 --- a/src/pal/src/libunwind/src/ppc32/Make-arch.in +++ /dev/null @@ -1,11 +0,0 @@ -# Word size. -ELFW = 64 -# Does use dwarf2 unwind info. -dwarf_target = true - -libunwind_setjmp_OBJS += \ - $(arch)/longjmp.o \ - $(arch)/siglongjmp.o - -libunwind_OBJS_common += \ - $(arch)/is_fpreg.o diff --git a/src/pal/src/libunwind/src/ppc32/get_func_addr.c b/src/pal/src/libunwind/src/ppc32/get_func_addr.c deleted file mode 100644 index 66ff795fe..000000000 --- a/src/pal/src/libunwind/src/ppc32/get_func_addr.c +++ /dev/null @@ -1,36 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2006-2007 IBM - Contributed by - Corey Ashford - Jose Flavio Aguilar Paulino - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" - -int -tdep_get_func_addr (unw_addr_space_t as, unw_word_t symbol_val_addr, - unw_word_t *real_func_addr) -{ - *real_func_addr = symbol_val_addr; - return 0; -} diff --git a/src/pal/src/libunwind/src/ppc32/init.h b/src/pal/src/libunwind/src/ppc32/init.h deleted file mode 100644 index 87a69b145..000000000 --- a/src/pal/src/libunwind/src/ppc32/init.h +++ /dev/null @@ -1,72 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2006-2007 IBM - Contributed by - Corey Ashford - Jose Flavio Aguilar Paulino - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" - -/* Here is the "common" init, for remote and local debuging" */ - -static inline int -common_init_ppc32 (struct cursor *c, unsigned use_prev_instr) -{ - int ret; - int i; - - for (i = UNW_PPC32_R0; i <= UNW_PPC32_R31; i++) { - c->dwarf.loc[i] = DWARF_REG_LOC (&c->dwarf, i); - } - for (i = UNW_PPC32_F0; i <= UNW_PPC32_F31; i++) { - c->dwarf.loc[i] = DWARF_FPREG_LOC (&c->dwarf, i); - } - - c->dwarf.loc[UNW_PPC32_CTR] = DWARF_REG_LOC (&c->dwarf, UNW_PPC32_CTR); - c->dwarf.loc[UNW_PPC32_XER] = DWARF_REG_LOC (&c->dwarf, UNW_PPC32_XER); - c->dwarf.loc[UNW_PPC32_CCR] = DWARF_REG_LOC (&c->dwarf, UNW_PPC32_CCR); - c->dwarf.loc[UNW_PPC32_LR] = DWARF_REG_LOC (&c->dwarf, UNW_PPC32_LR); - c->dwarf.loc[UNW_PPC32_FPSCR] = DWARF_REG_LOC (&c->dwarf, UNW_PPC32_FPSCR); - - ret = dwarf_get (&c->dwarf, c->dwarf.loc[UNW_PPC32_LR], &c->dwarf.ip); - if (ret < 0) - return ret; - - ret = dwarf_get (&c->dwarf, DWARF_REG_LOC (&c->dwarf, UNW_PPC32_R1), - &c->dwarf.cfa); - if (ret < 0) - return ret; - - c->sigcontext_format = PPC_SCF_NONE; - c->sigcontext_addr = 0; - - c->dwarf.args_size = 0; - c->dwarf.stash_frames = 0; - c->dwarf.use_prev_instr = use_prev_instr; - c->dwarf.pi_valid = 0; - c->dwarf.pi_is_dynamic = 0; - c->dwarf.hint = 0; - c->dwarf.prev_rs = 0; - - return 0; -} diff --git a/src/pal/src/libunwind/src/ppc32/is_fpreg.c b/src/pal/src/libunwind/src/ppc32/is_fpreg.c deleted file mode 100644 index 646ff2379..000000000 --- a/src/pal/src/libunwind/src/ppc32/is_fpreg.c +++ /dev/null @@ -1,34 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2006-2007 IBM - Contributed by - Corey Ashford - Jose Flavio Aguilar Paulino - -This file is part of libunwind. - -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. */ - -#include "libunwind_i.h" - -int -unw_is_fpreg (int regnum) -{ - return (regnum >= UNW_PPC32_F0 && regnum <= UNW_PPC32_F31); -} diff --git a/src/pal/src/libunwind/src/ppc32/regname.c b/src/pal/src/libunwind/src/ppc32/regname.c deleted file mode 100644 index 459b83a4e..000000000 --- a/src/pal/src/libunwind/src/ppc32/regname.c +++ /dev/null @@ -1,112 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2006-2007 IBM - Contributed by - Corey Ashford - Jose Flavio Aguilar Paulino - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" - -static const char *regname[] = - { - [UNW_PPC32_R0]="GPR0", - [UNW_PPC32_R1]="GPR1", - [UNW_PPC32_R2]="GPR2", - [UNW_PPC32_R3]="GPR3", - [UNW_PPC32_R4]="GPR4", - [UNW_PPC32_R5]="GPR5", - [UNW_PPC32_R6]="GPR6", - [UNW_PPC32_R7]="GPR7", - [UNW_PPC32_R8]="GPR8", - [UNW_PPC32_R9]="GPR9", - [UNW_PPC32_R10]="GPR10", - [UNW_PPC32_R11]="GPR11", - [UNW_PPC32_R12]="GPR12", - [UNW_PPC32_R13]="GPR13", - [UNW_PPC32_R14]="GPR14", - [UNW_PPC32_R15]="GPR15", - [UNW_PPC32_R16]="GPR16", - [UNW_PPC32_R17]="GPR17", - [UNW_PPC32_R18]="GPR18", - [UNW_PPC32_R19]="GPR19", - [UNW_PPC32_R20]="GPR20", - [UNW_PPC32_R21]="GPR21", - [UNW_PPC32_R22]="GPR22", - [UNW_PPC32_R23]="GPR23", - [UNW_PPC32_R24]="GPR24", - [UNW_PPC32_R25]="GPR25", - [UNW_PPC32_R26]="GPR26", - [UNW_PPC32_R27]="GPR27", - [UNW_PPC32_R28]="GPR28", - [UNW_PPC32_R29]="GPR29", - [UNW_PPC32_R30]="GPR30", - [UNW_PPC32_R31]="GPR31", - - [UNW_PPC32_CTR]="CTR", - [UNW_PPC32_XER]="XER", - [UNW_PPC32_CCR]="CCR", - [UNW_PPC32_LR]="LR", - [UNW_PPC32_FPSCR]="FPSCR", - - [UNW_PPC32_F0]="FPR0", - [UNW_PPC32_F1]="FPR1", - [UNW_PPC32_F2]="FPR2", - [UNW_PPC32_F3]="FPR3", - [UNW_PPC32_F4]="FPR4", - [UNW_PPC32_F5]="FPR5", - [UNW_PPC32_F6]="FPR6", - [UNW_PPC32_F7]="FPR7", - [UNW_PPC32_F8]="FPR8", - [UNW_PPC32_F9]="FPR9", - [UNW_PPC32_F10]="FPR10", - [UNW_PPC32_F11]="FPR11", - [UNW_PPC32_F12]="FPR12", - [UNW_PPC32_F13]="FPR13", - [UNW_PPC32_F14]="FPR14", - [UNW_PPC32_F15]="FPR15", - [UNW_PPC32_F16]="FPR16", - [UNW_PPC32_F17]="FPR17", - [UNW_PPC32_F18]="FPR18", - [UNW_PPC32_F19]="FPR19", - [UNW_PPC32_F20]="FPR20", - [UNW_PPC32_F21]="FPR21", - [UNW_PPC32_F22]="FPR22", - [UNW_PPC32_F23]="FPR23", - [UNW_PPC32_F24]="FPR24", - [UNW_PPC32_F25]="FPR25", - [UNW_PPC32_F26]="FPR26", - [UNW_PPC32_F27]="FPR27", - [UNW_PPC32_F28]="FPR28", - [UNW_PPC32_F29]="FPR29", - [UNW_PPC32_F30]="FPR30", - [UNW_PPC32_F31]="FPR31" -}; - -const char * -unw_regname (unw_regnum_t reg) -{ - if (reg < (unw_regnum_t) ARRAY_SIZE (regname)) - return regname[reg]; - else - return "???"; -} diff --git a/src/pal/src/libunwind/src/ppc32/setcontext.S b/src/pal/src/libunwind/src/ppc32/setcontext.S deleted file mode 100644 index b54378a9d..000000000 --- a/src/pal/src/libunwind/src/ppc32/setcontext.S +++ /dev/null @@ -1,9 +0,0 @@ - .global _UI_setcontext - -_UI_setcontext: - retq - -#ifdef __linux__ - /* We do not need executable stack. */ - .section .note.GNU-stack,"",@progbits -#endif diff --git a/src/pal/src/libunwind/src/ppc32/ucontext_i.h b/src/pal/src/libunwind/src/ppc32/ucontext_i.h deleted file mode 100644 index c6ba806a0..000000000 --- a/src/pal/src/libunwind/src/ppc32/ucontext_i.h +++ /dev/null @@ -1,128 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2006-2007 IBM - Contributed by - Corey Ashford - Jose Flavio Aguilar Paulino - -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. */ - -#ifndef ucontext_i_h -#define ucontext_i_h - -#include "compiler.h" -#include - -/* These values were derived by reading - /usr/src/linux-2.6.18-1.8/arch/um/include/sysdep-ppc/ptrace.h and - /usr/src/linux-2.6.18-1.8/arch/powerpc/kernel/ppc32.h -*/ - -//#define NIP_IDX 32 -#define CTR_IDX 32 -#define XER_IDX 33 -#define CCR_IDX 34 -#define MSR_IDX 35 -//#define MQ_IDX 36 -#define LINK_IDX 36 - -/* These are dummy structures used only for obtaining the offsets of the - various structure members. */ -static ucontext_t dmy_ctxt UNUSED; - -#define UC_MCONTEXT_GREGS_R0 ((void *)&dmy_ctxt.uc_mcontext.uc_regs->gregs[0] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_GREGS_R1 ((void *)&dmy_ctxt.uc_mcontext.uc_regs->gregs[1] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_GREGS_R2 ((void *)&dmy_ctxt.uc_mcontext.uc_regs->gregs[2] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_GREGS_R3 ((void *)&dmy_ctxt.uc_mcontext.uc_regs->gregs[3] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_GREGS_R4 ((void *)&dmy_ctxt.uc_mcontext.uc_regs->gregs[4] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_GREGS_R5 ((void *)&dmy_ctxt.uc_mcontext.uc_regs->gregs[5] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_GREGS_R6 ((void *)&dmy_ctxt.uc_mcontext.uc_regs->gregs[6] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_GREGS_R7 ((void *)&dmy_ctxt.uc_mcontext.uc_regs->gregs[7] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_GREGS_R8 ((void *)&dmy_ctxt.uc_mcontext.uc_regs->gregs[8] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_GREGS_R9 ((void *)&dmy_ctxt.uc_mcontext.uc_regs->gregs[9] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_GREGS_R10 ((void *)&dmy_ctxt.uc_mcontext.uc_regs->gregs[10] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_GREGS_R11 ((void *)&dmy_ctxt.uc_mcontext.uc_regs->gregs[11] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_GREGS_R12 ((void *)&dmy_ctxt.uc_mcontext.uc_regs->gregs[12] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_GREGS_R13 ((void *)&dmy_ctxt.uc_mcontext.uc_regs->gregs[13] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_GREGS_R14 ((void *)&dmy_ctxt.uc_mcontext.uc_regs->gregs[14] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_GREGS_R15 ((void *)&dmy_ctxt.uc_mcontext.uc_regs->gregs[15] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_GREGS_R16 ((void *)&dmy_ctxt.uc_mcontext.uc_regs->gregs[16] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_GREGS_R17 ((void *)&dmy_ctxt.uc_mcontext.uc_regs->gregs[17] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_GREGS_R18 ((void *)&dmy_ctxt.uc_mcontext.uc_regs->gregs[18] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_GREGS_R19 ((void *)&dmy_ctxt.uc_mcontext.uc_regs->gregs[19] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_GREGS_R20 ((void *)&dmy_ctxt.uc_mcontext.uc_regs->gregs[20] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_GREGS_R21 ((void *)&dmy_ctxt.uc_mcontext.uc_regs->gregs[21] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_GREGS_R22 ((void *)&dmy_ctxt.uc_mcontext.uc_regs->gregs[22] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_GREGS_R23 ((void *)&dmy_ctxt.uc_mcontext.uc_regs->gregs[23] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_GREGS_R24 ((void *)&dmy_ctxt.uc_mcontext.uc_regs->gregs[24] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_GREGS_R25 ((void *)&dmy_ctxt.uc_mcontext.uc_regs->gregs[25] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_GREGS_R26 ((void *)&dmy_ctxt.uc_mcontext.uc_regs->gregs[26] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_GREGS_R27 ((void *)&dmy_ctxt.uc_mcontext.uc_regs->gregs[27] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_GREGS_R28 ((void *)&dmy_ctxt.uc_mcontext.uc_regs->gregs[28] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_GREGS_R29 ((void *)&dmy_ctxt.uc_mcontext.uc_regs->gregs[29] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_GREGS_R30 ((void *)&dmy_ctxt.uc_mcontext.uc_regs->gregs[30] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_GREGS_R31 ((void *)&dmy_ctxt.uc_mcontext.uc_regs->gregs[31] - (void *)&dmy_ctxt) - -#define UC_MCONTEXT_GREGS_MSR ((void *)&dmy_ctxt.uc_mcontext.uc_regs->gregs[MSR_IDX] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_GREGS_ORIG_GPR3 ((void *)&dmy_ctxt.uc_mcontext.uc_regs->gregs[ORIG_GPR3_IDX] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_GREGS_CTR ((void *)&dmy_ctxt.uc_mcontext.uc_regs->gregs[CTR_IDX] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_GREGS_LINK ((void *)&dmy_ctxt.uc_mcontext.uc_regs->gregs[LINK_IDX] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_GREGS_XER ((void *)&dmy_ctxt.uc_mcontext.uc_regs->gregs[XER_IDX] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_GREGS_CCR ((void *)&dmy_ctxt.uc_mcontext.uc_regs->gregs[CCR_IDX] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_GREGS_SOFTE ((void *)&dmy_ctxt.uc_mcontext.uc_regs->gregs[SOFTE_IDX] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_GREGS_TRAP ((void *)&dmy_ctxt.uc_mcontext.uc_regs->gregs[TRAP_IDX] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_GREGS_DAR ((void *)&dmy_ctxt.uc_mcontext.uc_regs->gregs[DAR_IDX] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_GREGS_DSISR ((void *)&dmy_ctxt.uc_mcontext.uc_regs->gregs[DSISR_IDX] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_GREGS_RESULT ((void *)&dmy_ctxt.uc_mcontext.uc_regs->gregs[RESULT_IDX] - (void *)&dmy_ctxt) - -#define UC_MCONTEXT_FREGS_R0 ((void *)&dmy_ctxt.uc_mcontext.uc_regs->fpregs.fpregs[0] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_FREGS_R1 ((void *)&dmy_ctxt.uc_mcontext.uc_regs->fpregs.fpregs[1] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_FREGS_R2 ((void *)&dmy_ctxt.uc_mcontext.uc_regs->fpregs.fpregs[2] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_FREGS_R3 ((void *)&dmy_ctxt.uc_mcontext.uc_regs->fpregs.fpregs[3] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_FREGS_R4 ((void *)&dmy_ctxt.uc_mcontext.uc_regs->fpregs.fpregs[4] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_FREGS_R5 ((void *)&dmy_ctxt.uc_mcontext.uc_regs->fpregs.fpregs[5] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_FREGS_R6 ((void *)&dmy_ctxt.uc_mcontext.uc_regs->fpregs.fpregs[6] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_FREGS_R7 ((void *)&dmy_ctxt.uc_mcontext.uc_regs->fpregs.fpregs[7] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_FREGS_R8 ((void *)&dmy_ctxt.uc_mcontext.uc_regs->fpregs.fpregs[8] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_FREGS_R9 ((void *)&dmy_ctxt.uc_mcontext.uc_regs->fpregs.fpregs[9] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_FREGS_R10 ((void *)&dmy_ctxt.uc_mcontext.uc_regs->fpregs.fpregs[10] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_FREGS_R11 ((void *)&dmy_ctxt.uc_mcontext.uc_regs->fpregs.fpregs[11] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_FREGS_R12 ((void *)&dmy_ctxt.uc_mcontext.uc_regs->fpregs.fpregs[12] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_FREGS_R13 ((void *)&dmy_ctxt.uc_mcontext.uc_regs->fpregs.fpregs[13] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_FREGS_R14 ((void *)&dmy_ctxt.uc_mcontext.uc_regs->fpregs.fpregs[14] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_FREGS_R15 ((void *)&dmy_ctxt.uc_mcontext.uc_regs->fpregs.fpregs[15] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_FREGS_R16 ((void *)&dmy_ctxt.uc_mcontext.uc_regs->fpregs.fpregs[16] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_FREGS_R17 ((void *)&dmy_ctxt.uc_mcontext.uc_regs->fpregs.fpregs[17] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_FREGS_R18 ((void *)&dmy_ctxt.uc_mcontext.uc_regs->fpregs.fpregs[18] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_FREGS_R19 ((void *)&dmy_ctxt.uc_mcontext.uc_regs->fpregs.fpregs[19] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_FREGS_R20 ((void *)&dmy_ctxt.uc_mcontext.uc_regs->fpregs.fpregs[20] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_FREGS_R21 ((void *)&dmy_ctxt.uc_mcontext.uc_regs->fpregs.fpregs[21] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_FREGS_R22 ((void *)&dmy_ctxt.uc_mcontext.uc_regs->fpregs.fpregs[22] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_FREGS_R23 ((void *)&dmy_ctxt.uc_mcontext.uc_regs->fpregs.fpregs[23] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_FREGS_R24 ((void *)&dmy_ctxt.uc_mcontext.uc_regs->fpregs.fpregs[24] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_FREGS_R25 ((void *)&dmy_ctxt.uc_mcontext.uc_regs->fpregs.fpregs[25] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_FREGS_R26 ((void *)&dmy_ctxt.uc_mcontext.uc_regs->fpregs.fpregs[26] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_FREGS_R27 ((void *)&dmy_ctxt.uc_mcontext.uc_regs->fpregs.fpregs[27] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_FREGS_R28 ((void *)&dmy_ctxt.uc_mcontext.uc_regs->fpregs.fpregs[28] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_FREGS_R29 ((void *)&dmy_ctxt.uc_mcontext.uc_regs->fpregs.fpregs[29] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_FREGS_R30 ((void *)&dmy_ctxt.uc_mcontext.uc_regs->fpregs.fpregs[30] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_FREGS_R31 ((void *)&dmy_ctxt.uc_mcontext.uc_regs->fpregs.fpregs[31] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_FREGS_FPSCR ((void *)&dmy_ctxt.uc_mcontext.uc_regs->fpregs.fpregs[32] - (void *)&dmy_ctxt) - -#endif diff --git a/src/pal/src/libunwind/src/ppc32/unwind_i.h b/src/pal/src/libunwind/src/ppc32/unwind_i.h deleted file mode 100644 index ad32d0565..000000000 --- a/src/pal/src/libunwind/src/ppc32/unwind_i.h +++ /dev/null @@ -1,46 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2006-2007 IBM - Contributed by - Corey Ashford - Jose Flavio Aguilar Paulino - -This file is part of libunwind. - -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. */ - -#ifndef unwind_i_h -#define unwind_i_h - -#include - -#include - -#include -#include - -#define ppc32_lock UNW_OBJ(lock) -#define ppc32_local_resume UNW_OBJ(local_resume) -#define ppc32_local_addr_space_init UNW_OBJ(local_addr_space_init) - -extern void ppc32_local_addr_space_init (void); -extern int ppc32_local_resume (unw_addr_space_t as, unw_cursor_t *cursor, - void *arg); - -#endif /* unwind_i_h */ diff --git a/src/pal/src/libunwind/src/ppc64/Gapply_reg_state.c b/src/pal/src/libunwind/src/ppc64/Gapply_reg_state.c deleted file mode 100644 index 82f056da6..000000000 --- a/src/pal/src/libunwind/src/ppc64/Gapply_reg_state.c +++ /dev/null @@ -1,37 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (c) 2002-2003 Hewlett-Packard Development Company, L.P. - Contributed by David Mosberger-Tang - - Modified for x86_64 by Max Asbock - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" - -int -unw_apply_reg_state (unw_cursor_t *cursor, - void *reg_states_data) -{ - struct cursor *c = (struct cursor *) cursor; - - return dwarf_apply_reg_state (&c->dwarf, (dwarf_reg_state_t *)reg_states_data); -} diff --git a/src/pal/src/libunwind/src/ppc64/Gcreate_addr_space.c b/src/pal/src/libunwind/src/ppc64/Gcreate_addr_space.c deleted file mode 100644 index bd48555d4..000000000 --- a/src/pal/src/libunwind/src/ppc64/Gcreate_addr_space.c +++ /dev/null @@ -1,71 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2006-2007 IBM - Contributed by - Corey Ashford - Jose Flavio Aguilar Paulino - -This file is part of libunwind. - -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. */ - -#include - -#include - -unw_addr_space_t -unw_create_addr_space (unw_accessors_t *a, int byte_order) -{ -#ifdef UNW_LOCAL_ONLY - return NULL; -#else - unw_addr_space_t as; - - /* - * We support both big- and little-endian on Linux ppc64. - */ - if (byte_order != 0 - && byte_order != __LITTLE_ENDIAN - && byte_order != __BIG_ENDIAN) - return NULL; - - as = malloc (sizeof (*as)); - if (!as) - return NULL; - - memset (as, 0, sizeof (*as)); - - as->acc = *a; - - if (byte_order == 0) - /* use host default: */ - as->big_endian = (__BYTE_ORDER == __BIG_ENDIAN); - else - as->big_endian = (byte_order == __BIG_ENDIAN); - - /* FIXME! There is no way to specify the ABI. - Default to ELFv1 on big-endian and ELFv2 on little-endian. */ - if (as->big_endian) - as->abi = UNW_PPC64_ABI_ELFv1; - else - as->abi = UNW_PPC64_ABI_ELFv2; - - return as; -#endif -} diff --git a/src/pal/src/libunwind/src/ppc64/Gglobal.c b/src/pal/src/libunwind/src/ppc64/Gglobal.c deleted file mode 100644 index 9d0b0f55a..000000000 --- a/src/pal/src/libunwind/src/ppc64/Gglobal.c +++ /dev/null @@ -1,182 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2006-2007 IBM - Contributed by - Corey Ashford - Jose Flavio Aguilar Paulino - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" -#include "dwarf_i.h" - -HIDDEN define_lock (ppc64_lock); -HIDDEN int tdep_init_done; - -/* The API register numbers are exactly the same as the .eh_frame - registers, for now at least. */ -HIDDEN const uint8_t dwarf_to_unw_regnum_map[DWARF_REGNUM_MAP_LENGTH] = - { - [UNW_PPC64_R0]=UNW_PPC64_R0, - [UNW_PPC64_R1]=UNW_PPC64_R1, - [UNW_PPC64_R2]=UNW_PPC64_R2, - [UNW_PPC64_R3]=UNW_PPC64_R3, - [UNW_PPC64_R4]=UNW_PPC64_R4, - [UNW_PPC64_R5]=UNW_PPC64_R5, - [UNW_PPC64_R6]=UNW_PPC64_R6, - [UNW_PPC64_R7]=UNW_PPC64_R7, - [UNW_PPC64_R8]=UNW_PPC64_R8, - [UNW_PPC64_R9]=UNW_PPC64_R9, - [UNW_PPC64_R10]=UNW_PPC64_R10, - [UNW_PPC64_R11]=UNW_PPC64_R11, - [UNW_PPC64_R12]=UNW_PPC64_R12, - [UNW_PPC64_R13]=UNW_PPC64_R13, - [UNW_PPC64_R14]=UNW_PPC64_R14, - [UNW_PPC64_R15]=UNW_PPC64_R15, - [UNW_PPC64_R16]=UNW_PPC64_R16, - [UNW_PPC64_R17]=UNW_PPC64_R17, - [UNW_PPC64_R18]=UNW_PPC64_R18, - [UNW_PPC64_R19]=UNW_PPC64_R19, - [UNW_PPC64_R20]=UNW_PPC64_R20, - [UNW_PPC64_R21]=UNW_PPC64_R21, - [UNW_PPC64_R22]=UNW_PPC64_R22, - [UNW_PPC64_R23]=UNW_PPC64_R23, - [UNW_PPC64_R24]=UNW_PPC64_R24, - [UNW_PPC64_R25]=UNW_PPC64_R25, - [UNW_PPC64_R26]=UNW_PPC64_R26, - [UNW_PPC64_R27]=UNW_PPC64_R27, - [UNW_PPC64_R28]=UNW_PPC64_R28, - [UNW_PPC64_R29]=UNW_PPC64_R29, - [UNW_PPC64_R30]=UNW_PPC64_R30, - [UNW_PPC64_R31]=UNW_PPC64_R31, - - [UNW_PPC64_F0]=UNW_PPC64_F0, - [UNW_PPC64_F1]=UNW_PPC64_F1, - [UNW_PPC64_F2]=UNW_PPC64_F2, - [UNW_PPC64_F3]=UNW_PPC64_F3, - [UNW_PPC64_F4]=UNW_PPC64_F4, - [UNW_PPC64_F5]=UNW_PPC64_F5, - [UNW_PPC64_F6]=UNW_PPC64_F6, - [UNW_PPC64_F7]=UNW_PPC64_F7, - [UNW_PPC64_F8]=UNW_PPC64_F8, - [UNW_PPC64_F9]=UNW_PPC64_F9, - [UNW_PPC64_F10]=UNW_PPC64_F10, - [UNW_PPC64_F11]=UNW_PPC64_F11, - [UNW_PPC64_F12]=UNW_PPC64_F12, - [UNW_PPC64_F13]=UNW_PPC64_F13, - [UNW_PPC64_F14]=UNW_PPC64_F14, - [UNW_PPC64_F15]=UNW_PPC64_F15, - [UNW_PPC64_F16]=UNW_PPC64_F16, - [UNW_PPC64_F17]=UNW_PPC64_F17, - [UNW_PPC64_F18]=UNW_PPC64_F18, - [UNW_PPC64_F19]=UNW_PPC64_F19, - [UNW_PPC64_F20]=UNW_PPC64_F20, - [UNW_PPC64_F21]=UNW_PPC64_F21, - [UNW_PPC64_F22]=UNW_PPC64_F22, - [UNW_PPC64_F23]=UNW_PPC64_F23, - [UNW_PPC64_F24]=UNW_PPC64_F24, - [UNW_PPC64_F25]=UNW_PPC64_F25, - [UNW_PPC64_F26]=UNW_PPC64_F26, - [UNW_PPC64_F27]=UNW_PPC64_F27, - [UNW_PPC64_F28]=UNW_PPC64_F28, - [UNW_PPC64_F29]=UNW_PPC64_F29, - [UNW_PPC64_F30]=UNW_PPC64_F30, - [UNW_PPC64_F31]=UNW_PPC64_F31, - - [UNW_PPC64_LR]=UNW_PPC64_LR, - [UNW_PPC64_CTR]=UNW_PPC64_CTR, - [UNW_PPC64_ARG_POINTER]=UNW_PPC64_ARG_POINTER, - - [UNW_PPC64_CR0]=UNW_PPC64_CR0, - [UNW_PPC64_CR1]=UNW_PPC64_CR1, - [UNW_PPC64_CR2]=UNW_PPC64_CR2, - [UNW_PPC64_CR3]=UNW_PPC64_CR3, - [UNW_PPC64_CR4]=UNW_PPC64_CR4, - [UNW_PPC64_CR5]=UNW_PPC64_CR5, - [UNW_PPC64_CR6]=UNW_PPC64_CR6, - [UNW_PPC64_CR7]=UNW_PPC64_CR7, - - [UNW_PPC64_XER]=UNW_PPC64_XER, - - [UNW_PPC64_V0]=UNW_PPC64_V0, - [UNW_PPC64_V1]=UNW_PPC64_V1, - [UNW_PPC64_V2]=UNW_PPC64_V2, - [UNW_PPC64_V3]=UNW_PPC64_V3, - [UNW_PPC64_V4]=UNW_PPC64_V4, - [UNW_PPC64_V5]=UNW_PPC64_V5, - [UNW_PPC64_V6]=UNW_PPC64_V6, - [UNW_PPC64_V7]=UNW_PPC64_V7, - [UNW_PPC64_V8]=UNW_PPC64_V8, - [UNW_PPC64_V9]=UNW_PPC64_V9, - [UNW_PPC64_V10]=UNW_PPC64_V10, - [UNW_PPC64_V11]=UNW_PPC64_V11, - [UNW_PPC64_V12]=UNW_PPC64_V12, - [UNW_PPC64_V13]=UNW_PPC64_V13, - [UNW_PPC64_V14]=UNW_PPC64_V14, - [UNW_PPC64_V15]=UNW_PPC64_V15, - [UNW_PPC64_V16]=UNW_PPC64_V16, - [UNW_PPC64_V17]=UNW_PPC64_V17, - [UNW_PPC64_V18]=UNW_PPC64_V18, - [UNW_PPC64_V19]=UNW_PPC64_V19, - [UNW_PPC64_V20]=UNW_PPC64_V20, - [UNW_PPC64_V21]=UNW_PPC64_V21, - [UNW_PPC64_V22]=UNW_PPC64_V22, - [UNW_PPC64_V23]=UNW_PPC64_V23, - [UNW_PPC64_V24]=UNW_PPC64_V24, - [UNW_PPC64_V25]=UNW_PPC64_V25, - [UNW_PPC64_V26]=UNW_PPC64_V26, - [UNW_PPC64_V27]=UNW_PPC64_V27, - [UNW_PPC64_V28]=UNW_PPC64_V28, - [UNW_PPC64_V29]=UNW_PPC64_V29, - [UNW_PPC64_V30]=UNW_PPC64_V30, - [UNW_PPC64_V31]=UNW_PPC64_V31, - - [UNW_PPC64_VRSAVE]=UNW_PPC64_VRSAVE, - [UNW_PPC64_VSCR]=UNW_PPC64_VSCR, - [UNW_PPC64_SPE_ACC]=UNW_PPC64_SPE_ACC, - [UNW_PPC64_SPEFSCR]=UNW_PPC64_SPEFSCR, - }; - -HIDDEN void -tdep_init (void) -{ - intrmask_t saved_mask; - - sigfillset (&unwi_full_mask); - - lock_acquire (&ppc64_lock, saved_mask); - { - if (tdep_init_done) - /* another thread else beat us to it... */ - goto out; - - mi_init (); - - dwarf_init (); - -#ifndef UNW_REMOTE_ONLY - ppc64_local_addr_space_init (); -#endif - tdep_init_done = 1; /* signal that we're initialized... */ - } - out: - lock_release (&ppc64_lock, saved_mask); -} diff --git a/src/pal/src/libunwind/src/ppc64/Ginit.c b/src/pal/src/libunwind/src/ppc64/Ginit.c deleted file mode 100644 index 4c88cd6e7..000000000 --- a/src/pal/src/libunwind/src/ppc64/Ginit.c +++ /dev/null @@ -1,229 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2006-2007 IBM - Contributed by - Corey Ashford - Jose Flavio Aguilar Paulino - -This file is part of libunwind. - -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. */ - -#include -#include - -#include "ucontext_i.h" -#include "unwind_i.h" - -#ifdef UNW_REMOTE_ONLY - -/* unw_local_addr_space is a NULL pointer in this case. */ -unw_addr_space_t unw_local_addr_space; - -#else /* !UNW_REMOTE_ONLY */ - -static struct unw_addr_space local_addr_space; - -unw_addr_space_t unw_local_addr_space = &local_addr_space; - -static void * -uc_addr (ucontext_t *uc, int reg) -{ - void *addr; - - if ((unsigned) (reg - UNW_PPC64_R0) < 32) - addr = &uc->uc_mcontext.gp_regs[reg - UNW_PPC64_R0]; - - else if ((unsigned) (reg - UNW_PPC64_F0) < 32) - addr = &uc->uc_mcontext.fp_regs[reg - UNW_PPC64_F0]; - - else if ((unsigned) (reg - UNW_PPC64_V0) < 32) - addr = (uc->uc_mcontext.v_regs == 0) ? NULL : &uc->uc_mcontext.v_regs->vrregs[reg - UNW_PPC64_V0][0]; - - else - { - unsigned gregs_idx; - - switch (reg) - { - case UNW_PPC64_NIP: - gregs_idx = NIP_IDX; - break; - case UNW_PPC64_CTR: - gregs_idx = CTR_IDX; - break; - case UNW_PPC64_LR: - gregs_idx = LINK_IDX; - break; - case UNW_PPC64_XER: - gregs_idx = XER_IDX; - break; - case UNW_PPC64_CR0: - gregs_idx = CCR_IDX; - break; - default: - return NULL; - } - addr = &uc->uc_mcontext.gp_regs[gregs_idx]; - } - return addr; -} - -# ifdef UNW_LOCAL_ONLY - -HIDDEN void * -tdep_uc_addr (ucontext_t *uc, int reg) -{ - return uc_addr (uc, reg); -} - -# endif /* UNW_LOCAL_ONLY */ - -HIDDEN unw_dyn_info_list_t _U_dyn_info_list; - - -static void -put_unwind_info (unw_addr_space_t as, unw_proc_info_t *proc_info, void *arg) -{ - /* it's a no-op */ -} - -static int -get_dyn_info_list_addr (unw_addr_space_t as, unw_word_t *dyn_info_list_addr, - void *arg) -{ - *dyn_info_list_addr = (unw_word_t) &_U_dyn_info_list; - return 0; -} - -static int -access_mem (unw_addr_space_t as, unw_word_t addr, unw_word_t *val, int write, - void *arg) -{ - if (write) - { - Debug (12, "mem[%lx] <- %lx\n", addr, *val); - *(unw_word_t *) addr = *val; - } - else - { - *val = *(unw_word_t *) addr; - Debug (12, "mem[%lx] -> %lx\n", addr, *val); - } - return 0; -} - -static int -access_reg (unw_addr_space_t as, unw_regnum_t reg, unw_word_t *val, - int write, void *arg) -{ - unw_word_t *addr; - ucontext_t *uc = arg; - - if (UNW_PPC64_F0 <= reg && reg <= UNW_PPC64_F31) - goto badreg; - if (UNW_PPC64_V0 <= reg && reg <= UNW_PPC64_V31) - goto badreg; - - addr = uc_addr (uc, reg); - if (!addr) - goto badreg; - - if (write) - { - *(unw_word_t *) addr = *val; - Debug (12, "%s <- %lx\n", unw_regname (reg), *val); - } - else - { - *val = *(unw_word_t *) addr; - Debug (12, "%s -> %lx\n", unw_regname (reg), *val); - } - return 0; - -badreg: - Debug (1, "bad register number %u\n", reg); - return -UNW_EBADREG; -} - -static int -access_fpreg (unw_addr_space_t as, unw_regnum_t reg, unw_fpreg_t *val, - int write, void *arg) -{ - ucontext_t *uc = arg; - unw_fpreg_t *addr; - - /* Allow only 32 fregs and 32 vregs */ - if (!(((unsigned) (reg - UNW_PPC64_F0) < 32) - ||((unsigned) (reg - UNW_PPC64_V0) < 32))) - goto badreg; - - addr = uc_addr (uc, reg); - if (!addr) - goto badreg; - - if (write) - { - Debug (12, "%s <- %016Lf\n", unw_regname (reg), *val); - *(unw_fpreg_t *) addr = *val; - } - else - { - *val = *(unw_fpreg_t *) addr; - Debug (12, "%s -> %016Lf\n", unw_regname (reg), *val); - } - return 0; - -badreg: - Debug (1, "bad register number %u\n", reg); - /* attempt to access a non-preserved register */ - return -UNW_EBADREG; -} - -static int -get_static_proc_name (unw_addr_space_t as, unw_word_t ip, - char *buf, size_t buf_len, unw_word_t *offp, - void *arg) -{ - return _Uelf64_get_proc_name (as, getpid (), ip, buf, buf_len, offp); -} - -HIDDEN void -ppc64_local_addr_space_init (void) -{ - memset (&local_addr_space, 0, sizeof (local_addr_space)); - local_addr_space.big_endian = (__BYTE_ORDER == __BIG_ENDIAN); -#if _CALL_ELF == 2 - local_addr_space.abi = UNW_PPC64_ABI_ELFv2; -#else - local_addr_space.abi = UNW_PPC64_ABI_ELFv1; -#endif - local_addr_space.caching_policy = UNWI_DEFAULT_CACHING_POLICY; - local_addr_space.acc.find_proc_info = dwarf_find_proc_info; - local_addr_space.acc.put_unwind_info = put_unwind_info; - local_addr_space.acc.get_dyn_info_list_addr = get_dyn_info_list_addr; - local_addr_space.acc.access_mem = access_mem; - local_addr_space.acc.access_reg = access_reg; - local_addr_space.acc.access_fpreg = access_fpreg; - local_addr_space.acc.resume = ppc64_local_resume; - local_addr_space.acc.get_proc_name = get_static_proc_name; - unw_flush_cache (&local_addr_space, 0, 0); -} - -#endif /* !UNW_REMOTE_ONLY */ diff --git a/src/pal/src/libunwind/src/ppc64/Greg_states_iterate.c b/src/pal/src/libunwind/src/ppc64/Greg_states_iterate.c deleted file mode 100644 index a17dc1b56..000000000 --- a/src/pal/src/libunwind/src/ppc64/Greg_states_iterate.c +++ /dev/null @@ -1,37 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (c) 2002-2003 Hewlett-Packard Development Company, L.P. - Contributed by David Mosberger-Tang - - Modified for x86_64 by Max Asbock - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" - -int -unw_reg_states_iterate (unw_cursor_t *cursor, - unw_reg_states_callback cb, void *token) -{ - struct cursor *c = (struct cursor *) cursor; - - return dwarf_reg_states_iterate (&c->dwarf, cb, token); -} diff --git a/src/pal/src/libunwind/src/ppc64/Gregs.c b/src/pal/src/libunwind/src/ppc64/Gregs.c deleted file mode 100644 index 1cb5d9dc6..000000000 --- a/src/pal/src/libunwind/src/ppc64/Gregs.c +++ /dev/null @@ -1,141 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2006-2007 IBM - Contributed by - Corey Ashford - Jose Flavio Aguilar Paulino - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" - -HIDDEN int -tdep_access_reg (struct cursor *c, unw_regnum_t reg, unw_word_t *valp, - int write) -{ - struct dwarf_loc loc; - - switch (reg) - { - case UNW_PPC64_R0: - case UNW_PPC64_R2: - case UNW_PPC64_R3: - case UNW_PPC64_R4: - case UNW_PPC64_R5: - case UNW_PPC64_R6: - case UNW_PPC64_R7: - case UNW_PPC64_R8: - case UNW_PPC64_R9: - case UNW_PPC64_R10: - case UNW_PPC64_R11: - case UNW_PPC64_R12: - case UNW_PPC64_R13: - case UNW_PPC64_R14: - case UNW_PPC64_R15: - case UNW_PPC64_R16: - case UNW_PPC64_R17: - case UNW_PPC64_R18: - case UNW_PPC64_R19: - case UNW_PPC64_R20: - case UNW_PPC64_R21: - case UNW_PPC64_R22: - case UNW_PPC64_R23: - case UNW_PPC64_R24: - case UNW_PPC64_R25: - case UNW_PPC64_R26: - case UNW_PPC64_R27: - case UNW_PPC64_R28: - case UNW_PPC64_R29: - case UNW_PPC64_R30: - case UNW_PPC64_R31: - case UNW_PPC64_LR: - case UNW_PPC64_CTR: - case UNW_PPC64_CR0: - case UNW_PPC64_CR1: - case UNW_PPC64_CR2: - case UNW_PPC64_CR3: - case UNW_PPC64_CR4: - case UNW_PPC64_CR5: - case UNW_PPC64_CR6: - case UNW_PPC64_CR7: - case UNW_PPC64_VRSAVE: - case UNW_PPC64_VSCR: - case UNW_PPC64_SPE_ACC: - case UNW_PPC64_SPEFSCR: - loc = c->dwarf.loc[reg]; - break; - - case UNW_TDEP_IP: - if (write) - { - c->dwarf.ip = *valp; /* update the IP cache */ - if (c->dwarf.pi_valid && (*valp < c->dwarf.pi.start_ip - || *valp >= c->dwarf.pi.end_ip)) - c->dwarf.pi_valid = 0; /* new IP outside of current proc */ - } - else - *valp = c->dwarf.ip; - return 0; - - case UNW_TDEP_SP: - if (write) - return -UNW_EREADONLYREG; - *valp = c->dwarf.cfa; - return 0; - - default: - return -UNW_EBADREG; - break; - } - - if (write) - return dwarf_put (&c->dwarf, loc, *valp); - else - return dwarf_get (&c->dwarf, loc, valp); -} - -HIDDEN int -tdep_access_fpreg (struct cursor *c, unw_regnum_t reg, unw_fpreg_t *valp, - int write) -{ - struct dwarf_loc loc; - - if ((unsigned) (reg - UNW_PPC64_F0) < 32) - { - loc = c->dwarf.loc[reg]; - if (write) - return dwarf_putfp (&c->dwarf, loc, *valp); - else - return dwarf_getfp (&c->dwarf, loc, valp); - } - else - if ((unsigned) (reg - UNW_PPC64_V0) < 32) - { - loc = c->dwarf.loc[reg]; - if (write) - return dwarf_putvr (&c->dwarf, loc, *valp); - else - return dwarf_getvr (&c->dwarf, loc, valp); - } - - return -UNW_EBADREG; -} - diff --git a/src/pal/src/libunwind/src/ppc64/Gresume.c b/src/pal/src/libunwind/src/ppc64/Gresume.c deleted file mode 100644 index 0d832d0d9..000000000 --- a/src/pal/src/libunwind/src/ppc64/Gresume.c +++ /dev/null @@ -1,111 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2006-2007 IBM - Contributed by - Corey Ashford cjashfor@us.ibm.com - Jose Flavio Aguilar Paulino - -This file is part of libunwind. - -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. */ - -#include - -#include "unwind_i.h" - -#ifndef UNW_REMOTE_ONLY - -#include - -/* sigreturn() is a no-op on x86_64 glibc. */ - -static NORETURN inline long -my_rt_sigreturn (void *new_sp) -{ - /* XXX: empty stub. */ - abort (); -} - -HIDDEN inline int -ppc64_local_resume (unw_addr_space_t as, unw_cursor_t *cursor, void *arg) -{ - struct cursor *c = (struct cursor *) cursor; - ucontext_t *uc = (ucontext_t *)c->dwarf.as_arg; - - if (unlikely (c->sigcontext_format != PPC_SCF_NONE)) - { - my_rt_sigreturn(cursor); - abort(); - } - else - { - Debug (8, "resuming at ip=%llx via setcontext()\n", - (unsigned long long) c->dwarf.ip); - setcontext (uc); - } - return -UNW_EINVAL; -} - -#endif /* !UNW_REMOTE_ONLY */ - -/* This routine is responsible for copying the register values in - cursor C and establishing them as the current machine state. */ - -static inline int -establish_machine_state (struct cursor *c) -{ - unw_addr_space_t as = c->dwarf.as; - void *arg = c->dwarf.as_arg; - unw_fpreg_t fpval; - unw_word_t val; - int reg; - - Debug (8, "copying out cursor state\n"); - - for (reg = 0; reg <= UNW_REG_LAST; ++reg) - { - Debug (16, "copying %s %d\n", unw_regname (reg), reg); - if (unw_is_fpreg (reg)) - { - if (tdep_access_fpreg (c, reg, &fpval, 0) >= 0) - as->acc.access_fpreg (as, reg, &fpval, 1, arg); - } - else - { - if (tdep_access_reg (c, reg, &val, 0) >= 0) - as->acc.access_reg (as, reg, &val, 1, arg); - } - } - return 0; -} - -int -unw_resume (unw_cursor_t *cursor) -{ - struct cursor *c = (struct cursor *) cursor; - int ret; - - Debug (1, "(cursor=%p)\n", c); - - if ((ret = establish_machine_state (c)) < 0) - return ret; - - return (*c->dwarf.as->acc.resume) (c->dwarf.as, (unw_cursor_t *) c, - c->dwarf.as_arg); -} diff --git a/src/pal/src/libunwind/src/ppc64/Gstep.c b/src/pal/src/libunwind/src/ppc64/Gstep.c deleted file mode 100644 index f44e95910..000000000 --- a/src/pal/src/libunwind/src/ppc64/Gstep.c +++ /dev/null @@ -1,466 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2006-2007 IBM - Contributed by - Corey Ashford - Jose Flavio Aguilar Paulino - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" -#include "ucontext_i.h" -#include "remote.h" -#include - -/* This definition originates in /usr/include/asm-ppc64/ptrace.h, but is - defined there only when __KERNEL__ is defined. We reproduce it here for - our use at the user level in order to locate the ucontext record, which - appears to be at this offset relative to the stack pointer when in the - context of the signal handler return trampoline code - - __kernel_sigtramp_rt64. */ -#define __SIGNAL_FRAMESIZE 128 - -/* This definition comes from the document "64-bit PowerPC ELF Application - Binary Interface Supplement 1.9", section 3.2.2. - http://www.linux-foundation.org/spec/ELF/ppc64/PPC-elf64abi-1.9.html#STACK */ - -typedef struct -{ - long unsigned back_chain; - long unsigned cr_save; - long unsigned lr_save; - /* many more fields here, but they are unused by this code */ -} stack_frame_t; - - -int -unw_step (unw_cursor_t * cursor) -{ - struct cursor *c = (struct cursor *) cursor; - stack_frame_t dummy; - unw_word_t back_chain_offset, lr_save_offset, v_regs_ptr; - struct dwarf_loc back_chain_loc, lr_save_loc, sp_loc, ip_loc, v_regs_loc; - int ret, i; - - Debug (1, "(cursor=%p, ip=0x%016lx)\n", c, (unsigned long) c->dwarf.ip); - - /* Try DWARF-based unwinding... */ - - ret = dwarf_step (&c->dwarf); - - if (ret < 0 && ret != -UNW_ENOINFO) - { - Debug (2, "returning %d\n", ret); - return ret; - } - - if (unlikely (ret < 0)) - { - if (likely (unw_is_signal_frame (cursor) <= 0)) - { - /* DWARF unwinding failed. As of 09/26/2006, gcc in 64-bit mode - produces the mandatory level of traceback record in the code, but - I get the impression that this is transitory, that eventually gcc - will not produce any traceback records at all. So, for now, we - won't bother to try to find and use these records. - - We can, however, attempt to unwind the frame by using the callback - chain. This is very crude, however, and won't be able to unwind - any registers besides the IP, SP, and LR . */ - - back_chain_offset = ((void *) &dummy.back_chain - (void *) &dummy); - lr_save_offset = ((void *) &dummy.lr_save - (void *) &dummy); - - back_chain_loc = DWARF_LOC (c->dwarf.cfa + back_chain_offset, 0); - - if ((ret = - dwarf_get (&c->dwarf, back_chain_loc, &c->dwarf.cfa)) < 0) - { - Debug (2, - "Unable to retrieve CFA from back chain in stack frame - %d\n", - ret); - return ret; - } - if (c->dwarf.cfa == 0) - /* Unless the cursor or stack is corrupt or uninitialized we've most - likely hit the top of the stack */ - return 0; - - lr_save_loc = DWARF_LOC (c->dwarf.cfa + lr_save_offset, 0); - - if ((ret = dwarf_get (&c->dwarf, lr_save_loc, &c->dwarf.ip)) < 0) - { - Debug (2, - "Unable to retrieve IP from lr save in stack frame - %d\n", - ret); - return ret; - } - - /* Mark all registers unsaved */ - for (i = 0; i < DWARF_NUM_PRESERVED_REGS; ++i) - c->dwarf.loc[i] = DWARF_NULL_LOC; - - ret = 1; - } - else - { - /* Find the sigcontext record by taking the CFA and adjusting by - the dummy signal frame size. - - Note that there isn't any way to determined if SA_SIGINFO was - set in the sa_flags parameter to sigaction when the signal - handler was established. If it was not set, the ucontext - record is not required to be on the stack, in which case the - following code will likely cause a seg fault or other crash - condition. */ - - unw_word_t ucontext = c->dwarf.cfa + __SIGNAL_FRAMESIZE; - - Debug (1, "signal frame, skip over trampoline\n"); - - c->sigcontext_format = PPC_SCF_LINUX_RT_SIGFRAME; - c->sigcontext_addr = ucontext; - - sp_loc = DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R1, 0); - ip_loc = DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_NIP, 0); - - ret = dwarf_get (&c->dwarf, sp_loc, &c->dwarf.cfa); - if (ret < 0) - { - Debug (2, "returning %d\n", ret); - return ret; - } - ret = dwarf_get (&c->dwarf, ip_loc, &c->dwarf.ip); - if (ret < 0) - { - Debug (2, "returning %d\n", ret); - return ret; - } - - /* Instead of just restoring the non-volatile registers, do all - of the registers for now. This will incur a performance hit, - but it's rare enough not to cause too much of a problem, and - might be useful in some cases. */ - c->dwarf.loc[UNW_PPC64_R0] = - DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R0, 0); - c->dwarf.loc[UNW_PPC64_R1] = - DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R1, 0); - c->dwarf.loc[UNW_PPC64_R2] = - DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R2, 0); - c->dwarf.loc[UNW_PPC64_R3] = - DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R3, 0); - c->dwarf.loc[UNW_PPC64_R4] = - DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R4, 0); - c->dwarf.loc[UNW_PPC64_R5] = - DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R5, 0); - c->dwarf.loc[UNW_PPC64_R6] = - DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R6, 0); - c->dwarf.loc[UNW_PPC64_R7] = - DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R7, 0); - c->dwarf.loc[UNW_PPC64_R8] = - DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R8, 0); - c->dwarf.loc[UNW_PPC64_R9] = - DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R9, 0); - c->dwarf.loc[UNW_PPC64_R10] = - DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R10, 0); - c->dwarf.loc[UNW_PPC64_R11] = - DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R11, 0); - c->dwarf.loc[UNW_PPC64_R12] = - DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R12, 0); - c->dwarf.loc[UNW_PPC64_R13] = - DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R13, 0); - c->dwarf.loc[UNW_PPC64_R14] = - DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R14, 0); - c->dwarf.loc[UNW_PPC64_R15] = - DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R15, 0); - c->dwarf.loc[UNW_PPC64_R16] = - DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R16, 0); - c->dwarf.loc[UNW_PPC64_R17] = - DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R17, 0); - c->dwarf.loc[UNW_PPC64_R18] = - DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R18, 0); - c->dwarf.loc[UNW_PPC64_R19] = - DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R19, 0); - c->dwarf.loc[UNW_PPC64_R20] = - DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R20, 0); - c->dwarf.loc[UNW_PPC64_R21] = - DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R21, 0); - c->dwarf.loc[UNW_PPC64_R22] = - DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R22, 0); - c->dwarf.loc[UNW_PPC64_R23] = - DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R23, 0); - c->dwarf.loc[UNW_PPC64_R24] = - DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R24, 0); - c->dwarf.loc[UNW_PPC64_R25] = - DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R25, 0); - c->dwarf.loc[UNW_PPC64_R26] = - DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R26, 0); - c->dwarf.loc[UNW_PPC64_R27] = - DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R27, 0); - c->dwarf.loc[UNW_PPC64_R28] = - DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R28, 0); - c->dwarf.loc[UNW_PPC64_R29] = - DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R29, 0); - c->dwarf.loc[UNW_PPC64_R30] = - DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R30, 0); - c->dwarf.loc[UNW_PPC64_R31] = - DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R31, 0); - - c->dwarf.loc[UNW_PPC64_LR] = - DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_LINK, 0); - c->dwarf.loc[UNW_PPC64_CTR] = - DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_CTR, 0); - /* This CR0 assignment is probably wrong. There are 8 dwarf columns - assigned to the CR registers, but only one CR register in the - mcontext structure */ - c->dwarf.loc[UNW_PPC64_CR0] = - DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_CCR, 0); - c->dwarf.loc[UNW_PPC64_XER] = - DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_XER, 0); - c->dwarf.loc[UNW_PPC64_NIP] = - DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_NIP, 0); - - /* TODO: Is there a way of obtaining the value of the - pseudo frame pointer (which is sp + some fixed offset, I - assume), based on the contents of the ucontext record - structure? For now, set this loc to null. */ - c->dwarf.loc[UNW_PPC64_FRAME_POINTER] = DWARF_NULL_LOC; - - c->dwarf.loc[UNW_PPC64_F0] = - DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R0, 0); - c->dwarf.loc[UNW_PPC64_F1] = - DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R1, 0); - c->dwarf.loc[UNW_PPC64_F2] = - DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R2, 0); - c->dwarf.loc[UNW_PPC64_F3] = - DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R3, 0); - c->dwarf.loc[UNW_PPC64_F4] = - DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R4, 0); - c->dwarf.loc[UNW_PPC64_F5] = - DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R5, 0); - c->dwarf.loc[UNW_PPC64_F6] = - DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R6, 0); - c->dwarf.loc[UNW_PPC64_F7] = - DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R7, 0); - c->dwarf.loc[UNW_PPC64_F8] = - DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R8, 0); - c->dwarf.loc[UNW_PPC64_F9] = - DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R9, 0); - c->dwarf.loc[UNW_PPC64_F10] = - DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R10, 0); - c->dwarf.loc[UNW_PPC64_F11] = - DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R11, 0); - c->dwarf.loc[UNW_PPC64_F12] = - DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R12, 0); - c->dwarf.loc[UNW_PPC64_F13] = - DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R13, 0); - c->dwarf.loc[UNW_PPC64_F14] = - DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R14, 0); - c->dwarf.loc[UNW_PPC64_F15] = - DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R15, 0); - c->dwarf.loc[UNW_PPC64_F16] = - DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R16, 0); - c->dwarf.loc[UNW_PPC64_F17] = - DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R17, 0); - c->dwarf.loc[UNW_PPC64_F18] = - DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R18, 0); - c->dwarf.loc[UNW_PPC64_F19] = - DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R19, 0); - c->dwarf.loc[UNW_PPC64_F20] = - DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R20, 0); - c->dwarf.loc[UNW_PPC64_F21] = - DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R21, 0); - c->dwarf.loc[UNW_PPC64_F22] = - DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R22, 0); - c->dwarf.loc[UNW_PPC64_F23] = - DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R23, 0); - c->dwarf.loc[UNW_PPC64_F24] = - DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R24, 0); - c->dwarf.loc[UNW_PPC64_F25] = - DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R25, 0); - c->dwarf.loc[UNW_PPC64_F26] = - DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R26, 0); - c->dwarf.loc[UNW_PPC64_F27] = - DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R27, 0); - c->dwarf.loc[UNW_PPC64_F28] = - DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R28, 0); - c->dwarf.loc[UNW_PPC64_F29] = - DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R29, 0); - c->dwarf.loc[UNW_PPC64_F30] = - DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R30, 0); - c->dwarf.loc[UNW_PPC64_F31] = - DWARF_LOC (ucontext + UC_MCONTEXT_FREGS_R31, 0); - /* Note that there is no .eh_section register column for the - FPSCR register. I don't know why this is. */ - - v_regs_loc = DWARF_LOC (ucontext + UC_MCONTEXT_V_REGS, 0); - ret = dwarf_get (&c->dwarf, v_regs_loc, &v_regs_ptr); - if (ret < 0) - { - Debug (2, "returning %d\n", ret); - return ret; - } - if (v_regs_ptr != 0) - { - /* The v_regs_ptr is not null. Set all of the AltiVec locs */ - - c->dwarf.loc[UNW_PPC64_V0] = - DWARF_LOC (v_regs_ptr + UC_MCONTEXT_VREGS_R0, 0); - c->dwarf.loc[UNW_PPC64_V1] = - DWARF_LOC (v_regs_ptr + UC_MCONTEXT_VREGS_R1, 0); - c->dwarf.loc[UNW_PPC64_V2] = - DWARF_LOC (v_regs_ptr + UC_MCONTEXT_VREGS_R2, 0); - c->dwarf.loc[UNW_PPC64_V3] = - DWARF_LOC (v_regs_ptr + UC_MCONTEXT_VREGS_R3, 0); - c->dwarf.loc[UNW_PPC64_V4] = - DWARF_LOC (v_regs_ptr + UC_MCONTEXT_VREGS_R4, 0); - c->dwarf.loc[UNW_PPC64_V5] = - DWARF_LOC (v_regs_ptr + UC_MCONTEXT_VREGS_R5, 0); - c->dwarf.loc[UNW_PPC64_V6] = - DWARF_LOC (v_regs_ptr + UC_MCONTEXT_VREGS_R6, 0); - c->dwarf.loc[UNW_PPC64_V7] = - DWARF_LOC (v_regs_ptr + UC_MCONTEXT_VREGS_R7, 0); - c->dwarf.loc[UNW_PPC64_V8] = - DWARF_LOC (v_regs_ptr + UC_MCONTEXT_VREGS_R8, 0); - c->dwarf.loc[UNW_PPC64_V9] = - DWARF_LOC (v_regs_ptr + UC_MCONTEXT_VREGS_R9, 0); - c->dwarf.loc[UNW_PPC64_V10] = - DWARF_LOC (v_regs_ptr + UC_MCONTEXT_VREGS_R10, 0); - c->dwarf.loc[UNW_PPC64_V11] = - DWARF_LOC (v_regs_ptr + UC_MCONTEXT_VREGS_R11, 0); - c->dwarf.loc[UNW_PPC64_V12] = - DWARF_LOC (v_regs_ptr + UC_MCONTEXT_VREGS_R12, 0); - c->dwarf.loc[UNW_PPC64_V13] = - DWARF_LOC (v_regs_ptr + UC_MCONTEXT_VREGS_R13, 0); - c->dwarf.loc[UNW_PPC64_V14] = - DWARF_LOC (v_regs_ptr + UC_MCONTEXT_VREGS_R14, 0); - c->dwarf.loc[UNW_PPC64_V15] = - DWARF_LOC (v_regs_ptr + UC_MCONTEXT_VREGS_R15, 0); - c->dwarf.loc[UNW_PPC64_V16] = - DWARF_LOC (v_regs_ptr + UC_MCONTEXT_VREGS_R16, 0); - c->dwarf.loc[UNW_PPC64_V17] = - DWARF_LOC (v_regs_ptr + UC_MCONTEXT_VREGS_R17, 0); - c->dwarf.loc[UNW_PPC64_V18] = - DWARF_LOC (v_regs_ptr + UC_MCONTEXT_VREGS_R18, 0); - c->dwarf.loc[UNW_PPC64_V19] = - DWARF_LOC (v_regs_ptr + UC_MCONTEXT_VREGS_R19, 0); - c->dwarf.loc[UNW_PPC64_V20] = - DWARF_LOC (v_regs_ptr + UC_MCONTEXT_VREGS_R20, 0); - c->dwarf.loc[UNW_PPC64_V21] = - DWARF_LOC (v_regs_ptr + UC_MCONTEXT_VREGS_R21, 0); - c->dwarf.loc[UNW_PPC64_V22] = - DWARF_LOC (v_regs_ptr + UC_MCONTEXT_VREGS_R22, 0); - c->dwarf.loc[UNW_PPC64_V23] = - DWARF_LOC (v_regs_ptr + UC_MCONTEXT_VREGS_R23, 0); - c->dwarf.loc[UNW_PPC64_V24] = - DWARF_LOC (v_regs_ptr + UC_MCONTEXT_VREGS_R24, 0); - c->dwarf.loc[UNW_PPC64_V25] = - DWARF_LOC (v_regs_ptr + UC_MCONTEXT_VREGS_R25, 0); - c->dwarf.loc[UNW_PPC64_V26] = - DWARF_LOC (v_regs_ptr + UC_MCONTEXT_VREGS_R26, 0); - c->dwarf.loc[UNW_PPC64_V27] = - DWARF_LOC (v_regs_ptr + UC_MCONTEXT_VREGS_R27, 0); - c->dwarf.loc[UNW_PPC64_V28] = - DWARF_LOC (v_regs_ptr + UC_MCONTEXT_VREGS_R28, 0); - c->dwarf.loc[UNW_PPC64_V29] = - DWARF_LOC (v_regs_ptr + UC_MCONTEXT_VREGS_R29, 0); - c->dwarf.loc[UNW_PPC64_V30] = - DWARF_LOC (v_regs_ptr + UC_MCONTEXT_VREGS_R30, 0); - c->dwarf.loc[UNW_PPC64_V31] = - DWARF_LOC (v_regs_ptr + UC_MCONTEXT_VREGS_R31, 0); - c->dwarf.loc[UNW_PPC64_VRSAVE] = - DWARF_LOC (v_regs_ptr + UC_MCONTEXT_VREGS_VRSAVE, 0); - c->dwarf.loc[UNW_PPC64_VSCR] = - DWARF_LOC (v_regs_ptr + UC_MCONTEXT_VREGS_VSCR, 0); - } - else - { - c->dwarf.loc[UNW_PPC64_V0] = DWARF_NULL_LOC; - c->dwarf.loc[UNW_PPC64_V1] = DWARF_NULL_LOC; - c->dwarf.loc[UNW_PPC64_V2] = DWARF_NULL_LOC; - c->dwarf.loc[UNW_PPC64_V3] = DWARF_NULL_LOC; - c->dwarf.loc[UNW_PPC64_V4] = DWARF_NULL_LOC; - c->dwarf.loc[UNW_PPC64_V5] = DWARF_NULL_LOC; - c->dwarf.loc[UNW_PPC64_V6] = DWARF_NULL_LOC; - c->dwarf.loc[UNW_PPC64_V7] = DWARF_NULL_LOC; - c->dwarf.loc[UNW_PPC64_V8] = DWARF_NULL_LOC; - c->dwarf.loc[UNW_PPC64_V9] = DWARF_NULL_LOC; - c->dwarf.loc[UNW_PPC64_V10] = DWARF_NULL_LOC; - c->dwarf.loc[UNW_PPC64_V11] = DWARF_NULL_LOC; - c->dwarf.loc[UNW_PPC64_V12] = DWARF_NULL_LOC; - c->dwarf.loc[UNW_PPC64_V13] = DWARF_NULL_LOC; - c->dwarf.loc[UNW_PPC64_V14] = DWARF_NULL_LOC; - c->dwarf.loc[UNW_PPC64_V15] = DWARF_NULL_LOC; - c->dwarf.loc[UNW_PPC64_V16] = DWARF_NULL_LOC; - c->dwarf.loc[UNW_PPC64_V17] = DWARF_NULL_LOC; - c->dwarf.loc[UNW_PPC64_V18] = DWARF_NULL_LOC; - c->dwarf.loc[UNW_PPC64_V19] = DWARF_NULL_LOC; - c->dwarf.loc[UNW_PPC64_V20] = DWARF_NULL_LOC; - c->dwarf.loc[UNW_PPC64_V21] = DWARF_NULL_LOC; - c->dwarf.loc[UNW_PPC64_V22] = DWARF_NULL_LOC; - c->dwarf.loc[UNW_PPC64_V23] = DWARF_NULL_LOC; - c->dwarf.loc[UNW_PPC64_V24] = DWARF_NULL_LOC; - c->dwarf.loc[UNW_PPC64_V25] = DWARF_NULL_LOC; - c->dwarf.loc[UNW_PPC64_V26] = DWARF_NULL_LOC; - c->dwarf.loc[UNW_PPC64_V27] = DWARF_NULL_LOC; - c->dwarf.loc[UNW_PPC64_V28] = DWARF_NULL_LOC; - c->dwarf.loc[UNW_PPC64_V29] = DWARF_NULL_LOC; - c->dwarf.loc[UNW_PPC64_V30] = DWARF_NULL_LOC; - c->dwarf.loc[UNW_PPC64_V31] = DWARF_NULL_LOC; - c->dwarf.loc[UNW_PPC64_VRSAVE] = DWARF_NULL_LOC; - c->dwarf.loc[UNW_PPC64_VSCR] = DWARF_NULL_LOC; - } - ret = 1; - } - } - - if (c->dwarf.ip == 0) - { - /* Unless the cursor or stack is corrupt or uninitialized, - we've most likely hit the top of the stack */ - Debug (2, "returning 0\n"); - return 0; - } - - // on ppc64, R2 register is used as pointer to TOC - // section which is used for symbol lookup in PIC code - // ppc64 linker generates "ld r2, 40(r1)" (ELFv1) or - // "ld r2, 24(r1)" (ELFv2) instruction after each - // @plt call. We need restore R2, but only for @plt calls - { - unw_word_t ip = c->dwarf.ip; - unw_addr_space_t as = c->dwarf.as; - unw_accessors_t *a = unw_get_accessors_int (as); - void *arg = c->dwarf.as_arg; - uint32_t toc_save = (as->abi == UNW_PPC64_ABI_ELFv2)? 24 : 40; - int32_t inst; - - if (fetch32 (as, a, &ip, &inst, arg) >= 0 - && (uint32_t)inst == (0xE8410000U + toc_save)) - { - // @plt call, restoring R2 from CFA+toc_save - c->dwarf.loc[UNW_PPC64_R2] = DWARF_LOC(c->dwarf.cfa + toc_save, 0); - } - } - - Debug (2, "returning %d with last return statement\n", ret); - return ret; -} diff --git a/src/pal/src/libunwind/src/ppc64/Lapply_reg_state.c b/src/pal/src/libunwind/src/ppc64/Lapply_reg_state.c deleted file mode 100644 index 7ebada480..000000000 --- a/src/pal/src/libunwind/src/ppc64/Lapply_reg_state.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gapply_reg_state.c" -#endif diff --git a/src/pal/src/libunwind/src/ppc64/Lcreate_addr_space.c b/src/pal/src/libunwind/src/ppc64/Lcreate_addr_space.c deleted file mode 100644 index 0f2dc6be9..000000000 --- a/src/pal/src/libunwind/src/ppc64/Lcreate_addr_space.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gcreate_addr_space.c" -#endif diff --git a/src/pal/src/libunwind/src/ppc64/Lglobal.c b/src/pal/src/libunwind/src/ppc64/Lglobal.c deleted file mode 100644 index 6d7b489e1..000000000 --- a/src/pal/src/libunwind/src/ppc64/Lglobal.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gglobal.c" -#endif diff --git a/src/pal/src/libunwind/src/ppc64/Linit.c b/src/pal/src/libunwind/src/ppc64/Linit.c deleted file mode 100644 index e9abfdd46..000000000 --- a/src/pal/src/libunwind/src/ppc64/Linit.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Ginit.c" -#endif diff --git a/src/pal/src/libunwind/src/ppc64/Lreg_states_iterate.c b/src/pal/src/libunwind/src/ppc64/Lreg_states_iterate.c deleted file mode 100644 index f1eb1e79d..000000000 --- a/src/pal/src/libunwind/src/ppc64/Lreg_states_iterate.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Greg_states_iterate.c" -#endif diff --git a/src/pal/src/libunwind/src/ppc64/Lregs.c b/src/pal/src/libunwind/src/ppc64/Lregs.c deleted file mode 100644 index 2c9c75cd7..000000000 --- a/src/pal/src/libunwind/src/ppc64/Lregs.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gregs.c" -#endif diff --git a/src/pal/src/libunwind/src/ppc64/Lresume.c b/src/pal/src/libunwind/src/ppc64/Lresume.c deleted file mode 100644 index 41a8cf003..000000000 --- a/src/pal/src/libunwind/src/ppc64/Lresume.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gresume.c" -#endif diff --git a/src/pal/src/libunwind/src/ppc64/Lstep.c b/src/pal/src/libunwind/src/ppc64/Lstep.c deleted file mode 100644 index c1ac3c754..000000000 --- a/src/pal/src/libunwind/src/ppc64/Lstep.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gstep.c" -#endif diff --git a/src/pal/src/libunwind/src/ppc64/get_func_addr.c b/src/pal/src/libunwind/src/ppc64/get_func_addr.c deleted file mode 100644 index 80a58fa1f..000000000 --- a/src/pal/src/libunwind/src/ppc64/get_func_addr.c +++ /dev/null @@ -1,51 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2006-2007 IBM - Contributed by - Corey Ashford - Jose Flavio Aguilar Paulino - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" - -int -tdep_get_func_addr (unw_addr_space_t as, unw_word_t addr, - unw_word_t *entry_point) -{ - if (as->abi == UNW_PPC64_ABI_ELFv1) - { - unw_accessors_t *a; - int ret; - - a = unw_get_accessors_int (as); - /* Entry-point is stored in the 1st word of the function descriptor. - In case that changes in the future, we'd have to update the line - below and read the word at addr + offset: */ - ret = (*a->access_mem) (as, addr, entry_point, 0, NULL); - if (ret < 0) - return ret; - } - else - *entry_point = addr; - - return 0; -} diff --git a/src/pal/src/libunwind/src/ppc64/init.h b/src/pal/src/libunwind/src/ppc64/init.h deleted file mode 100644 index 9b8139343..000000000 --- a/src/pal/src/libunwind/src/ppc64/init.h +++ /dev/null @@ -1,82 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2006-2007 IBM - Contributed by - Corey Ashford - Jose Flavio Aguilar Paulino - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" - -static inline int -common_init_ppc64 (struct cursor *c, unsigned use_prev_instr) -{ - int ret; - int i; - - for (i = UNW_PPC64_R0; i <= UNW_PPC64_R31; i++) { - c->dwarf.loc[i] = DWARF_REG_LOC (&c->dwarf, i); - } - for (i = UNW_PPC64_F0; i <= UNW_PPC64_F31; i++) { - c->dwarf.loc[i] = DWARF_FPREG_LOC (&c->dwarf, i); - } - for (i = UNW_PPC64_V0; i <= UNW_PPC64_V31; i++) { - c->dwarf.loc[i] = DWARF_VREG_LOC (&c->dwarf, i); - } - - for (i = UNW_PPC64_CR0; i <= UNW_PPC64_CR7; i++) { - c->dwarf.loc[i] = DWARF_REG_LOC (&c->dwarf, i); - } - c->dwarf.loc[UNW_PPC64_ARG_POINTER] = DWARF_REG_LOC (&c->dwarf, UNW_PPC64_ARG_POINTER); - c->dwarf.loc[UNW_PPC64_CTR] = DWARF_REG_LOC (&c->dwarf, UNW_PPC64_CTR); - c->dwarf.loc[UNW_PPC64_VSCR] = DWARF_REG_LOC (&c->dwarf, UNW_PPC64_VSCR); - - c->dwarf.loc[UNW_PPC64_XER] = DWARF_REG_LOC (&c->dwarf, UNW_PPC64_XER); - c->dwarf.loc[UNW_PPC64_LR] = DWARF_REG_LOC (&c->dwarf, UNW_PPC64_LR); - c->dwarf.loc[UNW_PPC64_VRSAVE] = DWARF_REG_LOC (&c->dwarf, UNW_PPC64_VRSAVE); - c->dwarf.loc[UNW_PPC64_SPEFSCR] = DWARF_REG_LOC (&c->dwarf, UNW_PPC64_SPEFSCR); - c->dwarf.loc[UNW_PPC64_SPE_ACC] = DWARF_REG_LOC (&c->dwarf, UNW_PPC64_SPE_ACC); - - c->dwarf.loc[UNW_PPC64_NIP] = DWARF_REG_LOC (&c->dwarf, UNW_PPC64_NIP); - - ret = dwarf_get (&c->dwarf, c->dwarf.loc[UNW_PPC64_NIP], &c->dwarf.ip); - if (ret < 0) - return ret; - - ret = dwarf_get (&c->dwarf, DWARF_REG_LOC (&c->dwarf, UNW_PPC64_R1), - &c->dwarf.cfa); - if (ret < 0) - return ret; - - c->sigcontext_format = PPC_SCF_NONE; - c->sigcontext_addr = 0; - - c->dwarf.args_size = 0; - c->dwarf.stash_frames = 0; - c->dwarf.use_prev_instr = use_prev_instr; - c->dwarf.pi_valid = 0; - c->dwarf.pi_is_dynamic = 0; - c->dwarf.hint = 0; - c->dwarf.prev_rs = 0; - - return 0; -} diff --git a/src/pal/src/libunwind/src/ppc64/is_fpreg.c b/src/pal/src/libunwind/src/ppc64/is_fpreg.c deleted file mode 100644 index 653964a7d..000000000 --- a/src/pal/src/libunwind/src/ppc64/is_fpreg.c +++ /dev/null @@ -1,34 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2006-2007 IBM - Contributed by - Corey Ashford - Jose Flavio Aguilar Paulino - -This file is part of libunwind. - -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. */ - -#include "libunwind_i.h" - -int -unw_is_fpreg (int regnum) -{ - return (regnum >= UNW_PPC64_F0 && regnum <= UNW_PPC64_F31); -} diff --git a/src/pal/src/libunwind/src/ppc64/regname.c b/src/pal/src/libunwind/src/ppc64/regname.c deleted file mode 100644 index 58c6fa6d8..000000000 --- a/src/pal/src/libunwind/src/ppc64/regname.c +++ /dev/null @@ -1,164 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2006-2007 IBM - Contributed by - Corey Ashford - Jose Flavio Aguilar Paulino - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" - -static const char *regname[] = - { - [UNW_PPC64_R0]="GPR0", - [UNW_PPC64_R1]="GPR1", - [UNW_PPC64_R2]="GPR2", - [UNW_PPC64_R3]="GPR3", - [UNW_PPC64_R4]="GPR4", - [UNW_PPC64_R5]="GPR5", - [UNW_PPC64_R6]="GPR6", - [UNW_PPC64_R7]="GPR7", - [UNW_PPC64_R8]="GPR8", - [UNW_PPC64_R9]="GPR9", - [UNW_PPC64_R10]="GPR10", - [UNW_PPC64_R11]="GPR11", - [UNW_PPC64_R12]="GPR12", - [UNW_PPC64_R13]="GPR13", - [UNW_PPC64_R14]="GPR14", - [UNW_PPC64_R15]="GPR15", - [UNW_PPC64_R16]="GPR16", - [UNW_PPC64_R17]="GPR17", - [UNW_PPC64_R18]="GPR18", - [UNW_PPC64_R19]="GPR19", - [UNW_PPC64_R20]="GPR20", - [UNW_PPC64_R21]="GPR21", - [UNW_PPC64_R22]="GPR22", - [UNW_PPC64_R23]="GPR23", - [UNW_PPC64_R24]="GPR24", - [UNW_PPC64_R25]="GPR25", - [UNW_PPC64_R26]="GPR26", - [UNW_PPC64_R27]="GPR27", - [UNW_PPC64_R28]="GPR28", - [UNW_PPC64_R29]="GPR29", - [UNW_PPC64_R30]="GPR30", - [UNW_PPC64_R31]="GPR31", - - [UNW_PPC64_F0]="FPR0", - [UNW_PPC64_F1]="FPR1", - [UNW_PPC64_F2]="FPR2", - [UNW_PPC64_F3]="FPR3", - [UNW_PPC64_F4]="FPR4", - [UNW_PPC64_F5]="FPR5", - [UNW_PPC64_F6]="FPR6", - [UNW_PPC64_F7]="FPR7", - [UNW_PPC64_F8]="FPR8", - [UNW_PPC64_F9]="FPR9", - [UNW_PPC64_F10]="FPR10", - [UNW_PPC64_F11]="FPR11", - [UNW_PPC64_F12]="FPR12", - [UNW_PPC64_F13]="FPR13", - [UNW_PPC64_F14]="FPR14", - [UNW_PPC64_F15]="FPR15", - [UNW_PPC64_F16]="FPR16", - [UNW_PPC64_F17]="FPR17", - [UNW_PPC64_F18]="FPR18", - [UNW_PPC64_F19]="FPR19", - [UNW_PPC64_F20]="FPR20", - [UNW_PPC64_F21]="FPR21", - [UNW_PPC64_F22]="FPR22", - [UNW_PPC64_F23]="FPR23", - [UNW_PPC64_F24]="FPR24", - [UNW_PPC64_F25]="FPR25", - [UNW_PPC64_F26]="FPR26", - [UNW_PPC64_F27]="FPR27", - [UNW_PPC64_F28]="FPR28", - [UNW_PPC64_F29]="FPR29", - [UNW_PPC64_F30]="FPR30", - [UNW_PPC64_F31]="FPR31", - - [UNW_PPC64_LR]="LR", - [UNW_PPC64_CTR]="CTR", - [UNW_PPC64_ARG_POINTER]="ARG_POINTER", - - [UNW_PPC64_CR0]="CR0", - [UNW_PPC64_CR1]="CR1", - [UNW_PPC64_CR2]="CR2", - [UNW_PPC64_CR3]="CR3", - [UNW_PPC64_CR4]="CR4", - [UNW_PPC64_CR5]="CR5", - [UNW_PPC64_CR6]="CR6", - [UNW_PPC64_CR7]="CR7", - - [UNW_PPC64_XER]="XER", - - [UNW_PPC64_V0]="VR0", - [UNW_PPC64_V1]="VR1", - [UNW_PPC64_V2]="VR2", - [UNW_PPC64_V3]="VR3", - [UNW_PPC64_V4]="VR4", - [UNW_PPC64_V5]="VR5", - [UNW_PPC64_V6]="VR6", - [UNW_PPC64_V7]="VR7", - [UNW_PPC64_V8]="VR8", - [UNW_PPC64_V9]="VR9", - [UNW_PPC64_V10]="VR10", - [UNW_PPC64_V11]="VR11", - [UNW_PPC64_V12]="VR12", - [UNW_PPC64_V13]="VR13", - [UNW_PPC64_V14]="VR14", - [UNW_PPC64_V15]="VR15", - [UNW_PPC64_V16]="VR16", - [UNW_PPC64_V17]="VR17", - [UNW_PPC64_V18]="VR18", - [UNW_PPC64_V19]="VR19", - [UNW_PPC64_V20]="VR20", - [UNW_PPC64_V21]="VR21", - [UNW_PPC64_V22]="VR22", - [UNW_PPC64_V23]="VR23", - [UNW_PPC64_V24]="VR24", - [UNW_PPC64_V25]="VR25", - [UNW_PPC64_V26]="VR26", - [UNW_PPC64_V27]="VR27", - [UNW_PPC64_V28]="VR28", - [UNW_PPC64_V29]="VR29", - [UNW_PPC64_V30]="VR30", - [UNW_PPC64_V31]="VR31", - - [UNW_PPC64_VSCR]="VSCR", - - [UNW_PPC64_VRSAVE]="VRSAVE", - [UNW_PPC64_SPE_ACC]="SPE_ACC", - [UNW_PPC64_SPEFSCR]="SPEFSCR", - - [UNW_PPC64_FRAME_POINTER]="FRAME_POINTER", - [UNW_PPC64_NIP]="NIP", - - }; - -const char * -unw_regname (unw_regnum_t reg) -{ - if (reg < (unw_regnum_t) ARRAY_SIZE (regname)) - return regname[reg]; - else - return "???"; -} diff --git a/src/pal/src/libunwind/src/ppc64/setcontext.S b/src/pal/src/libunwind/src/ppc64/setcontext.S deleted file mode 100644 index ffc2500a5..000000000 --- a/src/pal/src/libunwind/src/ppc64/setcontext.S +++ /dev/null @@ -1,9 +0,0 @@ - .global _UI_setcontext - -_UI_setcontext: - blr - -#ifdef __linux__ - /* We do not need executable stack. */ - .section .note.GNU-stack,"",@progbits -#endif diff --git a/src/pal/src/libunwind/src/ppc64/ucontext_i.h b/src/pal/src/libunwind/src/ppc64/ucontext_i.h deleted file mode 100644 index 2ddfdb865..000000000 --- a/src/pal/src/libunwind/src/ppc64/ucontext_i.h +++ /dev/null @@ -1,173 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2006-2007 IBM - Contributed by - Corey Ashford - Jose Flavio Aguilar Paulino - -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. */ - -#ifndef ucontext_i_h -#define ucontext_i_h - -#include - -/* These values were derived by reading - /usr/src/linux-2.6.18-1.8/arch/um/include/sysdep-ppc/ptrace.h and - /usr/src/linux-2.6.18-1.8/arch/powerpc/kernel/ppc32.h -*/ - -#define NIP_IDX 32 -#define MSR_IDX 33 -#define ORIG_GPR3_IDX 34 -#define CTR_IDX 35 -#define LINK_IDX 36 -#define XER_IDX 37 -#define CCR_IDX 38 -#define SOFTE_IDX 39 -#define TRAP_IDX 40 -#define DAR_IDX 41 -#define DSISR_IDX 42 -#define RESULT_IDX 43 - -#define VSCR_IDX 32 -#define VRSAVE_IDX 33 - -/* These are dummy structures used only for obtaining the offsets of the - various structure members. */ -static ucontext_t dmy_ctxt; -static vrregset_t dmy_vrregset; - -#define UC_MCONTEXT_GREGS_R0 ((void *)&dmy_ctxt.uc_mcontext.gp_regs[0] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_GREGS_R1 ((void *)&dmy_ctxt.uc_mcontext.gp_regs[1] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_GREGS_R2 ((void *)&dmy_ctxt.uc_mcontext.gp_regs[2] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_GREGS_R3 ((void *)&dmy_ctxt.uc_mcontext.gp_regs[3] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_GREGS_R4 ((void *)&dmy_ctxt.uc_mcontext.gp_regs[4] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_GREGS_R5 ((void *)&dmy_ctxt.uc_mcontext.gp_regs[5] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_GREGS_R6 ((void *)&dmy_ctxt.uc_mcontext.gp_regs[6] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_GREGS_R7 ((void *)&dmy_ctxt.uc_mcontext.gp_regs[7] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_GREGS_R8 ((void *)&dmy_ctxt.uc_mcontext.gp_regs[8] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_GREGS_R9 ((void *)&dmy_ctxt.uc_mcontext.gp_regs[9] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_GREGS_R10 ((void *)&dmy_ctxt.uc_mcontext.gp_regs[10] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_GREGS_R11 ((void *)&dmy_ctxt.uc_mcontext.gp_regs[11] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_GREGS_R12 ((void *)&dmy_ctxt.uc_mcontext.gp_regs[12] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_GREGS_R13 ((void *)&dmy_ctxt.uc_mcontext.gp_regs[13] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_GREGS_R14 ((void *)&dmy_ctxt.uc_mcontext.gp_regs[14] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_GREGS_R15 ((void *)&dmy_ctxt.uc_mcontext.gp_regs[15] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_GREGS_R16 ((void *)&dmy_ctxt.uc_mcontext.gp_regs[16] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_GREGS_R17 ((void *)&dmy_ctxt.uc_mcontext.gp_regs[17] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_GREGS_R18 ((void *)&dmy_ctxt.uc_mcontext.gp_regs[18] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_GREGS_R19 ((void *)&dmy_ctxt.uc_mcontext.gp_regs[19] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_GREGS_R20 ((void *)&dmy_ctxt.uc_mcontext.gp_regs[20] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_GREGS_R21 ((void *)&dmy_ctxt.uc_mcontext.gp_regs[21] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_GREGS_R22 ((void *)&dmy_ctxt.uc_mcontext.gp_regs[22] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_GREGS_R23 ((void *)&dmy_ctxt.uc_mcontext.gp_regs[23] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_GREGS_R24 ((void *)&dmy_ctxt.uc_mcontext.gp_regs[24] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_GREGS_R25 ((void *)&dmy_ctxt.uc_mcontext.gp_regs[25] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_GREGS_R26 ((void *)&dmy_ctxt.uc_mcontext.gp_regs[26] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_GREGS_R27 ((void *)&dmy_ctxt.uc_mcontext.gp_regs[27] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_GREGS_R28 ((void *)&dmy_ctxt.uc_mcontext.gp_regs[28] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_GREGS_R29 ((void *)&dmy_ctxt.uc_mcontext.gp_regs[29] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_GREGS_R30 ((void *)&dmy_ctxt.uc_mcontext.gp_regs[30] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_GREGS_R31 ((void *)&dmy_ctxt.uc_mcontext.gp_regs[31] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_GREGS_NIP ((void *)&dmy_ctxt.uc_mcontext.gp_regs[NIP_IDX] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_GREGS_MSR ((void *)&dmy_ctxt.uc_mcontext.gp_regs[MSR_IDX] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_GREGS_ORIG_GPR3 ((void *)&dmy_ctxt.uc_mcontext.gp_regs[ORIG_GPR3_IDX] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_GREGS_CTR ((void *)&dmy_ctxt.uc_mcontext.gp_regs[CTR_IDX] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_GREGS_LINK ((void *)&dmy_ctxt.uc_mcontext.gp_regs[LINK_IDX] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_GREGS_XER ((void *)&dmy_ctxt.uc_mcontext.gp_regs[XER_IDX] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_GREGS_CCR ((void *)&dmy_ctxt.uc_mcontext.gp_regs[CCR_IDX] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_GREGS_SOFTE ((void *)&dmy_ctxt.uc_mcontext.gp_regs[SOFTE_IDX] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_GREGS_TRAP ((void *)&dmy_ctxt.uc_mcontext.gp_regs[TRAP_IDX] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_GREGS_DAR ((void *)&dmy_ctxt.uc_mcontext.gp_regs[DAR_IDX] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_GREGS_DSISR ((void *)&dmy_ctxt.uc_mcontext.gp_regs[DSISR_IDX] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_GREGS_RESULT ((void *)&dmy_ctxt.uc_mcontext.gp_regs[RESULT_IDX] - (void *)&dmy_ctxt) - -#define UC_MCONTEXT_FREGS_R0 ((void *)&dmy_ctxt.uc_mcontext.fp_regs[0] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_FREGS_R1 ((void *)&dmy_ctxt.uc_mcontext.fp_regs[1] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_FREGS_R2 ((void *)&dmy_ctxt.uc_mcontext.fp_regs[2] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_FREGS_R3 ((void *)&dmy_ctxt.uc_mcontext.fp_regs[3] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_FREGS_R4 ((void *)&dmy_ctxt.uc_mcontext.fp_regs[4] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_FREGS_R5 ((void *)&dmy_ctxt.uc_mcontext.fp_regs[5] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_FREGS_R6 ((void *)&dmy_ctxt.uc_mcontext.fp_regs[6] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_FREGS_R7 ((void *)&dmy_ctxt.uc_mcontext.fp_regs[7] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_FREGS_R8 ((void *)&dmy_ctxt.uc_mcontext.fp_regs[8] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_FREGS_R9 ((void *)&dmy_ctxt.uc_mcontext.fp_regs[9] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_FREGS_R10 ((void *)&dmy_ctxt.uc_mcontext.fp_regs[10] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_FREGS_R11 ((void *)&dmy_ctxt.uc_mcontext.fp_regs[11] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_FREGS_R12 ((void *)&dmy_ctxt.uc_mcontext.fp_regs[12] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_FREGS_R13 ((void *)&dmy_ctxt.uc_mcontext.fp_regs[13] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_FREGS_R14 ((void *)&dmy_ctxt.uc_mcontext.fp_regs[14] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_FREGS_R15 ((void *)&dmy_ctxt.uc_mcontext.fp_regs[15] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_FREGS_R16 ((void *)&dmy_ctxt.uc_mcontext.fp_regs[16] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_FREGS_R17 ((void *)&dmy_ctxt.uc_mcontext.fp_regs[17] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_FREGS_R18 ((void *)&dmy_ctxt.uc_mcontext.fp_regs[18] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_FREGS_R19 ((void *)&dmy_ctxt.uc_mcontext.fp_regs[19] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_FREGS_R20 ((void *)&dmy_ctxt.uc_mcontext.fp_regs[20] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_FREGS_R21 ((void *)&dmy_ctxt.uc_mcontext.fp_regs[21] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_FREGS_R22 ((void *)&dmy_ctxt.uc_mcontext.fp_regs[22] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_FREGS_R23 ((void *)&dmy_ctxt.uc_mcontext.fp_regs[23] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_FREGS_R24 ((void *)&dmy_ctxt.uc_mcontext.fp_regs[24] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_FREGS_R25 ((void *)&dmy_ctxt.uc_mcontext.fp_regs[25] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_FREGS_R26 ((void *)&dmy_ctxt.uc_mcontext.fp_regs[26] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_FREGS_R27 ((void *)&dmy_ctxt.uc_mcontext.fp_regs[27] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_FREGS_R28 ((void *)&dmy_ctxt.uc_mcontext.fp_regs[28] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_FREGS_R29 ((void *)&dmy_ctxt.uc_mcontext.fp_regs[29] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_FREGS_R30 ((void *)&dmy_ctxt.uc_mcontext.fp_regs[30] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_FREGS_R31 ((void *)&dmy_ctxt.uc_mcontext.fp_regs[31] - (void *)&dmy_ctxt) -#define UC_MCONTEXT_FREGS_FPSCR ((void *)&dmy_ctxt.uc_mcontext.fp_regs[32] - (void *)&dmy_ctxt) - -#define UC_MCONTEXT_V_REGS ((void *)&dmy_ctxt.uc_mcontext.v_regs - (void *)&dmy_ctxt) - -#define UC_MCONTEXT_VREGS_R0 ((void *)&dmy_vrregset.vrregs[0] - (void *)&dmy_vrregset) -#define UC_MCONTEXT_VREGS_R1 ((void *)&dmy_vrregset.vrregs[1] - (void *)&dmy_vrregset) -#define UC_MCONTEXT_VREGS_R2 ((void *)&dmy_vrregset.vrregs[2] - (void *)&dmy_vrregset) -#define UC_MCONTEXT_VREGS_R3 ((void *)&dmy_vrregset.vrregs[3] - (void *)&dmy_vrregset) -#define UC_MCONTEXT_VREGS_R4 ((void *)&dmy_vrregset.vrregs[4] - (void *)&dmy_vrregset) -#define UC_MCONTEXT_VREGS_R5 ((void *)&dmy_vrregset.vrregs[5] - (void *)&dmy_vrregset) -#define UC_MCONTEXT_VREGS_R6 ((void *)&dmy_vrregset.vrregs[6] - (void *)&dmy_vrregset) -#define UC_MCONTEXT_VREGS_R7 ((void *)&dmy_vrregset.vrregs[7] - (void *)&dmy_vrregset) -#define UC_MCONTEXT_VREGS_R8 ((void *)&dmy_vrregset.vrregs[8] - (void *)&dmy_vrregset) -#define UC_MCONTEXT_VREGS_R9 ((void *)&dmy_vrregset.vrregs[9] - (void *)&dmy_vrregset) -#define UC_MCONTEXT_VREGS_R10 ((void *)&dmy_vrregset.vrregs[10] - (void *)&dmy_vrregset) -#define UC_MCONTEXT_VREGS_R11 ((void *)&dmy_vrregset.vrregs[11] - (void *)&dmy_vrregset) -#define UC_MCONTEXT_VREGS_R12 ((void *)&dmy_vrregset.vrregs[12] - (void *)&dmy_vrregset) -#define UC_MCONTEXT_VREGS_R13 ((void *)&dmy_vrregset.vrregs[13] - (void *)&dmy_vrregset) -#define UC_MCONTEXT_VREGS_R14 ((void *)&dmy_vrregset.vrregs[14] - (void *)&dmy_vrregset) -#define UC_MCONTEXT_VREGS_R15 ((void *)&dmy_vrregset.vrregs[15] - (void *)&dmy_vrregset) -#define UC_MCONTEXT_VREGS_R16 ((void *)&dmy_vrregset.vrregs[16] - (void *)&dmy_vrregset) -#define UC_MCONTEXT_VREGS_R17 ((void *)&dmy_vrregset.vrregs[17] - (void *)&dmy_vrregset) -#define UC_MCONTEXT_VREGS_R18 ((void *)&dmy_vrregset.vrregs[18] - (void *)&dmy_vrregset) -#define UC_MCONTEXT_VREGS_R19 ((void *)&dmy_vrregset.vrregs[19] - (void *)&dmy_vrregset) -#define UC_MCONTEXT_VREGS_R20 ((void *)&dmy_vrregset.vrregs[20] - (void *)&dmy_vrregset) -#define UC_MCONTEXT_VREGS_R21 ((void *)&dmy_vrregset.vrregs[21] - (void *)&dmy_vrregset) -#define UC_MCONTEXT_VREGS_R22 ((void *)&dmy_vrregset.vrregs[22] - (void *)&dmy_vrregset) -#define UC_MCONTEXT_VREGS_R23 ((void *)&dmy_vrregset.vrregs[23] - (void *)&dmy_vrregset) -#define UC_MCONTEXT_VREGS_R24 ((void *)&dmy_vrregset.vrregs[24] - (void *)&dmy_vrregset) -#define UC_MCONTEXT_VREGS_R25 ((void *)&dmy_vrregset.vrregs[25] - (void *)&dmy_vrregset) -#define UC_MCONTEXT_VREGS_R26 ((void *)&dmy_vrregset.vrregs[26] - (void *)&dmy_vrregset) -#define UC_MCONTEXT_VREGS_R27 ((void *)&dmy_vrregset.vrregs[27] - (void *)&dmy_vrregset) -#define UC_MCONTEXT_VREGS_R28 ((void *)&dmy_vrregset.vrregs[28] - (void *)&dmy_vrregset) -#define UC_MCONTEXT_VREGS_R29 ((void *)&dmy_vrregset.vrregs[29] - (void *)&dmy_vrregset) -#define UC_MCONTEXT_VREGS_R30 ((void *)&dmy_vrregset.vrregs[30] - (void *)&dmy_vrregset) -#define UC_MCONTEXT_VREGS_R31 ((void *)&dmy_vrregset.vrregs[31] - (void *)&dmy_vrregset) -#define UC_MCONTEXT_VREGS_VSCR ((void *)&dmy_vrregset.vscr - (void *)&dmy_vrregset) -#define UC_MCONTEXT_VREGS_VRSAVE ((void *)&dmy_vrregset.vrsave - (void *)&dmy_vrregset) - -#endif diff --git a/src/pal/src/libunwind/src/ppc64/unwind_i.h b/src/pal/src/libunwind/src/ppc64/unwind_i.h deleted file mode 100644 index 26bbc2df8..000000000 --- a/src/pal/src/libunwind/src/ppc64/unwind_i.h +++ /dev/null @@ -1,52 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2006-2007 IBM - Contributed by - Corey Ashford - Jose Flavio Aguilar Paulino - -This file is part of libunwind. - -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. */ - -#ifndef unwind_i_h -#define unwind_i_h - -#include - -#include - -#include -#include - -#define ppc64_lock UNW_OBJ(lock) -#define ppc64_local_resume UNW_OBJ(local_resume) -#define ppc64_local_addr_space_init UNW_OBJ(local_addr_space_init) -#if 0 -#define ppc64_scratch_loc UNW_OBJ(scratch_loc) -#endif - -extern void ppc64_local_addr_space_init (void); -extern int ppc64_local_resume (unw_addr_space_t as, unw_cursor_t *cursor, - void *arg); -#if 0 -extern dwarf_loc_t ppc64_scratch_loc (struct cursor *c, unw_regnum_t reg); -#endif - -#endif /* unwind_i_h */ diff --git a/src/pal/src/libunwind/src/ptrace/_UPT_access_fpreg.c b/src/pal/src/libunwind/src/ptrace/_UPT_access_fpreg.c deleted file mode 100644 index 2b92462fa..000000000 --- a/src/pal/src/libunwind/src/ptrace/_UPT_access_fpreg.c +++ /dev/null @@ -1,121 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2003 Hewlett-Packard Co - Contributed by David Mosberger-Tang - Copyright (C) 2010 Konstantin Belousov - -This file is part of libunwind. - -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. */ - -#include "_UPT_internal.h" - -#if HAVE_DECL_PTRACE_POKEUSER || HAVE_TTRACE -int -_UPT_access_fpreg (unw_addr_space_t as, unw_regnum_t reg, unw_fpreg_t *val, - int write, void *arg) -{ - unw_word_t *wp = (unw_word_t *) val; - struct UPT_info *ui = arg; - pid_t pid = ui->pid; - int i; - - if ((unsigned) reg >= ARRAY_SIZE (_UPT_reg_offset)) - return -UNW_EBADREG; - - errno = 0; - if (write) - for (i = 0; i < (int) (sizeof (*val) / sizeof (wp[i])); ++i) - { -#ifdef HAVE_TTRACE -# warning No support for ttrace() yet. -#else - ptrace (PTRACE_POKEUSER, pid, _UPT_reg_offset[reg] + i * sizeof(wp[i]), - wp[i]); -#endif - if (errno) - return -UNW_EBADREG; - } - else - for (i = 0; i < (int) (sizeof (*val) / sizeof (wp[i])); ++i) - { -#ifdef HAVE_TTRACE -# warning No support for ttrace() yet. -#else - wp[i] = ptrace (PTRACE_PEEKUSER, pid, - _UPT_reg_offset[reg] + i * sizeof(wp[i]), 0); -#endif - if (errno) - return -UNW_EBADREG; - } - return 0; -} -#elif HAVE_DECL_PT_GETFPREGS -int -_UPT_access_fpreg (unw_addr_space_t as, unw_regnum_t reg, unw_fpreg_t *val, - int write, void *arg) -{ - struct UPT_info *ui = arg; - pid_t pid = ui->pid; - fpregset_t fpreg; - -#if defined(__amd64__) - if (1) /* XXXKIB */ - return -UNW_EBADREG; -#elif defined(__i386__) - if ((unsigned) reg < UNW_X86_ST0 || (unsigned) reg > UNW_X86_ST7) - return -UNW_EBADREG; -#elif defined(__arm__) - if ((unsigned) reg < UNW_ARM_F0 || (unsigned) reg > UNW_ARM_F7) - return -UNW_EBADREG; -#else -#error Fix me -#endif - if ((unsigned) reg >= ARRAY_SIZE (_UPT_reg_offset)) - return -UNW_EBADREG; - - if (ptrace(PT_GETFPREGS, pid, (caddr_t)&fpreg, 0) == -1) - return -UNW_EBADREG; - if (write) { -#if defined(__amd64__) - memcpy(&fpreg.fpr_xacc[reg], val, sizeof(unw_fpreg_t)); -#elif defined(__i386__) - memcpy(&fpreg.fpr_acc[reg], val, sizeof(unw_fpreg_t)); -#elif defined(__arm__) - memcpy(&fpreg.fpr[reg], val, sizeof(unw_fpreg_t)); -#else -#error Fix me -#endif - if (ptrace(PT_SETFPREGS, pid, (caddr_t)&fpreg, 0) == -1) - return -UNW_EBADREG; - } else -#if defined(__amd64__) - memcpy(val, &fpreg.fpr_xacc[reg], sizeof(unw_fpreg_t)); -#elif defined(__i386__) - memcpy(val, &fpreg.fpr_acc[reg], sizeof(unw_fpreg_t)); -#elif defined(__arm__) - memcpy(val, &fpreg.fpr[reg], sizeof(unw_fpreg_t)); -#else -#error Fix me -#endif - return 0; -} -#else -#error Fix me -#endif diff --git a/src/pal/src/libunwind/src/ptrace/_UPT_access_mem.c b/src/pal/src/libunwind/src/ptrace/_UPT_access_mem.c deleted file mode 100644 index 79bde25df..000000000 --- a/src/pal/src/libunwind/src/ptrace/_UPT_access_mem.c +++ /dev/null @@ -1,123 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2003-2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - Copyright (C) 2010 Konstantin Belousov - -This file is part of libunwind. - -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. */ - -#include "_UPT_internal.h" - -#if HAVE_DECL_PTRACE_POKEDATA || HAVE_TTRACE -int -_UPT_access_mem (unw_addr_space_t as, unw_word_t addr, unw_word_t *val, - int write, void *arg) -{ - struct UPT_info *ui = arg; - int i, end; - unw_word_t tmp_val; - - if (!ui) - return -UNW_EINVAL; - - pid_t pid = ui->pid; - - // Some 32-bit archs have to define a 64-bit unw_word_t. - // Callers of this function therefore expect a 64-bit - // return value, but ptrace only returns a 32-bit value - // in such cases. - if (sizeof(long) == 4 && sizeof(unw_word_t) == 8) - end = 2; - else - end = 1; - - for (i = 0; i < end; i++) - { - unw_word_t tmp_addr = i == 0 ? addr : addr + 4; - - errno = 0; - if (write) - { -#if __BYTE_ORDER == __LITTLE_ENDIAN - tmp_val = i == 0 ? *val : *val >> 32; -#else - tmp_val = i == 0 && end == 2 ? *val >> 32 : *val; -#endif - - Debug (16, "mem[%lx] <- %lx\n", (long) tmp_addr, (long) tmp_val); -#ifdef HAVE_TTRACE -# warning No support for ttrace() yet. -#else - ptrace (PTRACE_POKEDATA, pid, tmp_addr, tmp_val); - if (errno) - return -UNW_EINVAL; -#endif - } - else - { -#ifdef HAVE_TTRACE -# warning No support for ttrace() yet. -#else - tmp_val = (unsigned long) ptrace (PTRACE_PEEKDATA, pid, tmp_addr, 0); - - if (i == 0) - *val = 0; - -#if __BYTE_ORDER == __LITTLE_ENDIAN - *val |= tmp_val << (i * 32); -#else - *val |= i == 0 && end == 2 ? tmp_val << 32 : tmp_val; -#endif - - if (errno) - return -UNW_EINVAL; -#endif - Debug (16, "mem[%lx] -> %lx\n", (long) tmp_addr, (long) tmp_val); - } - } - return 0; -} -#elif HAVE_DECL_PT_IO -int -_UPT_access_mem (unw_addr_space_t as, unw_word_t addr, unw_word_t *val, - int write, void *arg) -{ - struct UPT_info *ui = arg; - if (!ui) - return -UNW_EINVAL; - pid_t pid = ui->pid; - struct ptrace_io_desc iod; - - iod.piod_offs = (void *)addr; - iod.piod_addr = val; - iod.piod_len = sizeof(*val); - iod.piod_op = write ? PIOD_WRITE_D : PIOD_READ_D; - if (write) - Debug (16, "mem[%lx] <- %lx\n", (long) addr, (long) *val); - if (ptrace(PT_IO, pid, (caddr_t)&iod, 0) == -1) - return -UNW_EINVAL; - if (!write) - Debug (16, "mem[%lx] -> %lx\n", (long) addr, (long) *val); - return 0; -} -#else -#error Fix me -#endif diff --git a/src/pal/src/libunwind/src/ptrace/_UPT_access_reg.c b/src/pal/src/libunwind/src/ptrace/_UPT_access_reg.c deleted file mode 100644 index ce25c783b..000000000 --- a/src/pal/src/libunwind/src/ptrace/_UPT_access_reg.c +++ /dev/null @@ -1,352 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2003-2005 Hewlett-Packard Co - Contributed by David Mosberger-Tang - Copyright (C) 2010 Konstantin Belousov - -This file is part of libunwind. - -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. */ - -#include "_UPT_internal.h" - -#if UNW_TARGET_IA64 -# include -# ifdef HAVE_ASM_PTRACE_OFFSETS_H -# include -# endif -# include "tdep-ia64/rse.h" -#endif - -#if HAVE_DECL_PTRACE_SETREGSET -#include -int -_UPT_access_reg (unw_addr_space_t as, unw_regnum_t reg, unw_word_t *val, - int write, void *arg) -{ - struct UPT_info *ui = arg; - pid_t pid = ui->pid; - gregset_t regs; - char *r; - struct iovec loc; - -#if UNW_DEBUG - Debug(16, "using getregset: reg: %s [%u], val: %lx, write: %u\n", - unw_regname(reg), (unsigned) reg, (long) val, write); - - if (write) - Debug (16, "%s [%u] <- %lx\n", unw_regname (reg), (unsigned) reg, (long) *val); -#endif - if ((unsigned) reg >= ARRAY_SIZE (_UPT_reg_offset)) - { - errno = EINVAL; - goto badreg; - } - - loc.iov_base = ®s; - loc.iov_len = sizeof(regs); - - r = (char *)®s + _UPT_reg_offset[reg]; - if (ptrace (PTRACE_GETREGSET, pid, NT_PRSTATUS, &loc) == -1) - goto badreg; - if (write) { - memcpy(r, val, sizeof(unw_word_t)); - if (ptrace(PTRACE_SETREGSET, pid, NT_PRSTATUS, &loc) == -1) - goto badreg; - } else - memcpy(val, r, sizeof(unw_word_t)); - return 0; - -badreg: - Debug (1, "bad register %s [%u] (error: %s)\n", unw_regname(reg), reg, strerror (errno)); - return -UNW_EBADREG; -} -#elif HAVE_DECL_PTRACE_POKEUSER || HAVE_TTRACE -int -_UPT_access_reg (unw_addr_space_t as, unw_regnum_t reg, unw_word_t *val, - int write, void *arg) -{ - struct UPT_info *ui = arg; - pid_t pid = ui->pid; - -#if UNW_DEBUG - Debug(16, "using pokeuser: reg: %s [%u], val: %lx, write: %d\n", unw_regname(reg), (unsigned) reg, (long) val, write); - - if (write) - Debug (16, "%s <- %lx\n", unw_regname (reg), (long) *val); -#endif - -#if UNW_TARGET_IA64 - if ((unsigned) reg - UNW_IA64_NAT < 32) - { - unsigned long nat_bits, mask; - - /* The Linux ptrace represents the statc NaT bits as a single word. */ - mask = ((unw_word_t) 1) << (reg - UNW_IA64_NAT); - errno = 0; -#ifdef HAVE_TTRACE -# warning No support for ttrace() yet. -#else - nat_bits = ptrace (PTRACE_PEEKUSER, pid, PT_NAT_BITS, 0); - if (errno) - goto badreg; -#endif - - if (write) - { - if (*val) - nat_bits |= mask; - else - nat_bits &= ~mask; -#ifdef HAVE_TTRACE -# warning No support for ttrace() yet. -#else - errno = 0; - ptrace (PTRACE_POKEUSER, pid, PT_NAT_BITS, nat_bits); - if (errno) - goto badreg; -#endif - } - goto out; - } - else - switch (reg) - { - case UNW_IA64_GR + 0: - if (write) - goto badreg; - *val = 0; - return 0; - - case UNW_REG_IP: - { - unsigned long ip, psr; - - /* distribute bundle-addr. & slot-number across PT_IIP & PT_IPSR. */ -#ifdef HAVE_TTRACE -# warning No support for ttrace() yet. -#else - errno = 0; - psr = ptrace (PTRACE_PEEKUSER, pid, PT_CR_IPSR, 0); - if (errno) - goto badreg; -#endif - if (write) - { - ip = *val & ~0xfUL; - psr = (psr & ~0x3UL << 41) | (*val & 0x3); -#ifdef HAVE_TTRACE -# warning No support for ttrace() yet. -#else - errno = 0; - ptrace (PTRACE_POKEUSER, pid, PT_CR_IIP, ip); - ptrace (PTRACE_POKEUSER, pid, PT_CR_IPSR, psr); - if (errno) - goto badreg; -#endif - } - else - { -#ifdef HAVE_TTRACE -# warning No support for ttrace() yet. -#else - errno = 0; - ip = ptrace (PTRACE_PEEKUSER, pid, PT_CR_IIP, 0); - if (errno) - goto badreg; -#endif - *val = ip + ((psr >> 41) & 0x3); - } - goto out; - } - - case UNW_IA64_AR_BSPSTORE: - reg = UNW_IA64_AR_BSP; - break; - - case UNW_IA64_AR_BSP: - case UNW_IA64_BSP: - { - unsigned long sof, cfm, bsp; - -#ifdef HAVE_TTRACE -# warning No support for ttrace() yet. -#else - /* Account for the fact that ptrace() expects bsp to point - _after_ the current register frame. */ - errno = 0; - cfm = ptrace (PTRACE_PEEKUSER, pid, PT_CFM, 0); - if (errno) - goto badreg; -#endif - sof = (cfm & 0x7f); - - if (write) - { - bsp = rse_skip_regs (*val, sof); -#ifdef HAVE_TTRACE -# warning No support for ttrace() yet. -#else - errno = 0; - ptrace (PTRACE_POKEUSER, pid, PT_AR_BSP, bsp); - if (errno) - goto badreg; -#endif - } - else - { -#ifdef HAVE_TTRACE -# warning No support for ttrace() yet. -#else - errno = 0; - bsp = ptrace (PTRACE_PEEKUSER, pid, PT_AR_BSP, 0); - if (errno) - goto badreg; -#endif - *val = rse_skip_regs (bsp, -sof); - } - goto out; - } - - case UNW_IA64_CFM: - /* If we change CFM, we need to adjust ptrace's notion of bsp - accordingly, so that the real bsp remains unchanged. */ - if (write) - { - unsigned long new_sof, old_sof, cfm, bsp; - -#ifdef HAVE_TTRACE -# warning No support for ttrace() yet. -#else - errno = 0; - bsp = ptrace (PTRACE_PEEKUSER, pid, PT_AR_BSP, 0); - cfm = ptrace (PTRACE_PEEKUSER, pid, PT_CFM, 0); -#endif - if (errno) - goto badreg; - old_sof = (cfm & 0x7f); - new_sof = (*val & 0x7f); - if (old_sof != new_sof) - { - bsp = rse_skip_regs (bsp, -old_sof + new_sof); -#ifdef HAVE_TTRACE -# warning No support for ttrace() yet. -#else - errno = 0; - ptrace (PTRACE_POKEUSER, pid, PT_AR_BSP, 0); - if (errno) - goto badreg; -#endif - } -#ifdef HAVE_TTRACE -# warning No support for ttrace() yet. -#else - errno = 0; - ptrace (PTRACE_POKEUSER, pid, PT_CFM, *val); - if (errno) - goto badreg; -#endif - goto out; - } - break; - } -#endif /* End of IA64 */ - - if ((unsigned) reg >= ARRAY_SIZE (_UPT_reg_offset)) - { -#if UNW_DEBUG - Debug(2, "register out of range: >= %zu / %zu\n", sizeof(_UPT_reg_offset), sizeof(_UPT_reg_offset[0])); -#endif - errno = EINVAL; - goto badreg; - } - -#ifdef HAVE_TTRACE -# warning No support for ttrace() yet. -#else - errno = 0; - if (write) - ptrace (PTRACE_POKEUSER, pid, _UPT_reg_offset[reg], *val); - else { -#if UNW_DEBUG - Debug(16, "ptrace PEEKUSER pid: %lu , reg: %lu , offs: %lu\n", (unsigned long)pid, (unsigned long)reg, - (unsigned long)_UPT_reg_offset[reg]); -#endif - *val = ptrace (PTRACE_PEEKUSER, pid, _UPT_reg_offset[reg], 0); - } - if (errno) { -#if UNW_DEBUG - Debug(2, "ptrace failure\n"); -#endif - goto badreg; - } -#endif - -#ifdef UNW_TARGET_IA64 - out: -#endif -#if UNW_DEBUG - if (!write) - Debug (16, "%s[%u] -> %lx\n", unw_regname (reg), (unsigned) reg, (long) *val); -#endif - return 0; - - badreg: - Debug (1, "bad register %s [%u] (error: %s)\n", unw_regname(reg), reg, strerror (errno)); - return -UNW_EBADREG; -} -#elif HAVE_DECL_PT_GETREGS -int -_UPT_access_reg (unw_addr_space_t as, unw_regnum_t reg, unw_word_t *val, - int write, void *arg) -{ - struct UPT_info *ui = arg; - pid_t pid = ui->pid; - gregset_t regs; - char *r; - -#if UNW_DEBUG - Debug(16, "using getregs: reg: %s [%u], val: %lx, write: %u\n", unw_regname(reg), (unsigned) reg, (long) val, write); - - if (write) - Debug (16, "%s [%u] <- %lx\n", unw_regname (reg), (unsigned) reg, (long) *val); -#endif - if ((unsigned) reg >= ARRAY_SIZE (_UPT_reg_offset)) - { - errno = EINVAL; - goto badreg; - } - r = (char *)®s + _UPT_reg_offset[reg]; - if (ptrace(PT_GETREGS, pid, (caddr_t)®s, 0) == -1) - goto badreg; - if (write) { - memcpy(r, val, sizeof(unw_word_t)); - if (ptrace(PT_SETREGS, pid, (caddr_t)®s, 0) == -1) - goto badreg; - } else - memcpy(val, r, sizeof(unw_word_t)); - return 0; - - badreg: - Debug (1, "bad register %s [%u] (error: %s)\n", unw_regname(reg), reg, strerror (errno)); - return -UNW_EBADREG; -} -#else -#error Port me -#endif diff --git a/src/pal/src/libunwind/src/ptrace/_UPT_accessors.c b/src/pal/src/libunwind/src/ptrace/_UPT_accessors.c deleted file mode 100644 index 4724360bb..000000000 --- a/src/pal/src/libunwind/src/ptrace/_UPT_accessors.c +++ /dev/null @@ -1,38 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2003 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include "_UPT_internal.h" - -unw_accessors_t _UPT_accessors = - { - .find_proc_info = _UPT_find_proc_info, - .put_unwind_info = _UPT_put_unwind_info, - .get_dyn_info_list_addr = _UPT_get_dyn_info_list_addr, - .access_mem = _UPT_access_mem, - .access_reg = _UPT_access_reg, - .access_fpreg = _UPT_access_fpreg, - .resume = _UPT_resume, - .get_proc_name = _UPT_get_proc_name - }; diff --git a/src/pal/src/libunwind/src/ptrace/_UPT_create.c b/src/pal/src/libunwind/src/ptrace/_UPT_create.c deleted file mode 100644 index dd59e974a..000000000 --- a/src/pal/src/libunwind/src/ptrace/_UPT_create.c +++ /dev/null @@ -1,46 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2003 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include - -#include "_UPT_internal.h" - -void * -_UPT_create (pid_t pid) -{ - struct UPT_info *ui = malloc (sizeof (struct UPT_info)); - - if (!ui) - return NULL; - - memset (ui, 0, sizeof (*ui)); - ui->pid = pid; - ui->edi.di_cache.format = -1; - ui->edi.di_debug.format = -1; -#if UNW_TARGET_IA64 - ui->edi.ktab.format = -1; -#endif - return ui; -} diff --git a/src/pal/src/libunwind/src/ptrace/_UPT_destroy.c b/src/pal/src/libunwind/src/ptrace/_UPT_destroy.c deleted file mode 100644 index edb664ce1..000000000 --- a/src/pal/src/libunwind/src/ptrace/_UPT_destroy.c +++ /dev/null @@ -1,34 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2003 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include "_UPT_internal.h" - -void -_UPT_destroy (void *ptr) -{ - struct UPT_info *ui = (struct UPT_info *) ptr; - invalidate_edi (&ui->edi); - free (ptr); -} diff --git a/src/pal/src/libunwind/src/ptrace/_UPT_elf.c b/src/pal/src/libunwind/src/ptrace/_UPT_elf.c deleted file mode 100644 index efc43b578..000000000 --- a/src/pal/src/libunwind/src/ptrace/_UPT_elf.c +++ /dev/null @@ -1,5 +0,0 @@ -/* We need to get a separate copy of the ELF-code into - libunwind-ptrace since it cannot (and must not) have any ELF - dependencies on libunwind. */ -#include "libunwind_i.h" /* get ELFCLASS defined */ -#include "../elfxx.c" diff --git a/src/pal/src/libunwind/src/ptrace/_UPT_find_proc_info.c b/src/pal/src/libunwind/src/ptrace/_UPT_find_proc_info.c deleted file mode 100644 index b3209f451..000000000 --- a/src/pal/src/libunwind/src/ptrace/_UPT_find_proc_info.c +++ /dev/null @@ -1,145 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2003-2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include -#include -#include -#include - -#include - -#include "_UPT_internal.h" - -static int -get_unwind_info (struct elf_dyn_info *edi, pid_t pid, unw_addr_space_t as, unw_word_t ip) -{ - unsigned long segbase, mapoff; - char path[PATH_MAX]; - -#if UNW_TARGET_IA64 && defined(__linux) - if (!edi->ktab.start_ip && _Uia64_get_kernel_table (&edi->ktab) < 0) - return -UNW_ENOINFO; - - if (edi->ktab.format != -1 && ip >= edi->ktab.start_ip && ip < edi->ktab.end_ip) - return 0; -#endif - - if ((edi->di_cache.format != -1 - && ip >= edi->di_cache.start_ip && ip < edi->di_cache.end_ip) -#if UNW_TARGET_ARM - || (edi->di_debug.format != -1 - && ip >= edi->di_arm.start_ip && ip < edi->di_arm.end_ip) -#endif - || (edi->di_debug.format != -1 - && ip >= edi->di_debug.start_ip && ip < edi->di_debug.end_ip)) - return 0; - - invalidate_edi(edi); - - if (tdep_get_elf_image (&edi->ei, pid, ip, &segbase, &mapoff, path, - sizeof(path)) < 0) - return -UNW_ENOINFO; - - /* Here, SEGBASE is the starting-address of the (mmap'ped) segment - which covers the IP we're looking for. */ - if (tdep_find_unwind_table (edi, as, path, segbase, mapoff, ip) < 0) - return -UNW_ENOINFO; - - /* This can happen in corner cases where dynamically generated - code falls into the same page that contains the data-segment - and the page-offset of the code is within the first page of - the executable. */ - if (edi->di_cache.format != -1 - && (ip < edi->di_cache.start_ip || ip >= edi->di_cache.end_ip)) - edi->di_cache.format = -1; - - if (edi->di_debug.format != -1 - && (ip < edi->di_debug.start_ip || ip >= edi->di_debug.end_ip)) - edi->di_debug.format = -1; - - if (edi->di_cache.format == -1 -#if UNW_TARGET_ARM - && edi->di_arm.format == -1 -#endif - && edi->di_debug.format == -1) - return -UNW_ENOINFO; - - return 0; -} - -int -_UPT_find_proc_info (unw_addr_space_t as, unw_word_t ip, unw_proc_info_t *pi, - int need_unwind_info, void *arg) -{ - struct UPT_info *ui = arg; - int ret = -UNW_ENOINFO; - - if (get_unwind_info (&ui->edi, ui->pid, as, ip) < 0) - return -UNW_ENOINFO; - -#if UNW_TARGET_IA64 - if (ui->edi.ktab.format != -1) - { - /* The kernel unwind table resides in local memory, so we have - to use the local address space to search it. Since - _UPT_put_unwind_info() has no easy way of detecting this - case, we simply make a copy of the unwind-info, so - _UPT_put_unwind_info() can always free() the unwind-info - without ill effects. */ - ret = tdep_search_unwind_table (unw_local_addr_space, ip, &ui->edi.ktab, pi, - need_unwind_info, arg); - if (ret >= 0) - { - if (!need_unwind_info) - pi->unwind_info = NULL; - else - { - void *mem = malloc (pi->unwind_info_size); - - if (!mem) - return -UNW_ENOMEM; - memcpy (mem, pi->unwind_info, pi->unwind_info_size); - pi->unwind_info = mem; - } - } - } -#endif - - if (ret == -UNW_ENOINFO && ui->edi.di_cache.format != -1) - ret = tdep_search_unwind_table (as, ip, &ui->edi.di_cache, - pi, need_unwind_info, arg); - - if (ret == -UNW_ENOINFO && ui->edi.di_debug.format != -1) - ret = tdep_search_unwind_table (as, ip, &ui->edi.di_debug, pi, - need_unwind_info, arg); - -#if UNW_TARGET_ARM - if (ret == -UNW_ENOINFO && ui->edi.di_arm.format != -1) - ret = tdep_search_unwind_table (as, ip, &ui->edi.di_arm, pi, - need_unwind_info, arg); -#endif - - return ret; -} diff --git a/src/pal/src/libunwind/src/ptrace/_UPT_get_dyn_info_list_addr.c b/src/pal/src/libunwind/src/ptrace/_UPT_get_dyn_info_list_addr.c deleted file mode 100644 index cc5ed0441..000000000 --- a/src/pal/src/libunwind/src/ptrace/_UPT_get_dyn_info_list_addr.c +++ /dev/null @@ -1,105 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2003-2005 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include "_UPT_internal.h" - -#if UNW_TARGET_IA64 && defined(__linux) -# include "elf64.h" -# include "os-linux.h" - -static inline int -get_list_addr (unw_addr_space_t as, unw_word_t *dil_addr, void *arg, - int *countp) -{ - unsigned long lo, hi, off; - struct UPT_info *ui = arg; - struct map_iterator mi; - char path[PATH_MAX]; - unw_word_t res; - int count = 0; - - maps_init (&mi, ui->pid); - while (maps_next (&mi, &lo, &hi, &off)) - { - if (off) - continue; - - invalidate_edi(&ui->edi); - - if (elf_map_image (&ui->edi.ei, path) < 0) - /* ignore unmappable stuff like "/SYSV00001b58 (deleted)" */ - continue; - - Debug (16, "checking object %s\n", path); - - if (tdep_find_unwind_table (&ui->edi, as, path, lo, off, 0) > 0) - { - res = _Uia64_find_dyn_list (as, &ui->edi.di_cache, arg); - if (res && count++ == 0) - { - Debug (12, "dyn_info_list_addr = 0x%lx\n", (long) res); - *dil_addr = res; - } - } - } - maps_close (&mi); - *countp = count; - return 0; -} - -#else - -static inline int -get_list_addr (unw_addr_space_t as, unw_word_t *dil_addr, void *arg, - int *countp) -{ -# warning Implement get_list_addr(), please. - *countp = 0; - return 0; -} - -#endif - -int -_UPT_get_dyn_info_list_addr (unw_addr_space_t as, unw_word_t *dil_addr, - void *arg) -{ - int count, ret; - - Debug (12, "looking for dyn_info list\n"); - - if ((ret = get_list_addr (as, dil_addr, arg, &count)) < 0) - return ret; - - /* If multiple dynamic-info list addresses are found, we would have - to determine which was is the one actually in use (since the - dynamic name resolution algorithm will pick one "winner"). - Perhaps we'd have to track them all until we find one that's - non-empty. Hopefully, this case simply will never arise, since - only libunwind defines the dynamic info list head. */ - assert (count <= 1); - - return (count > 0) ? 0 : -UNW_ENOINFO; -} diff --git a/src/pal/src/libunwind/src/ptrace/_UPT_get_proc_name.c b/src/pal/src/libunwind/src/ptrace/_UPT_get_proc_name.c deleted file mode 100644 index 79c1f38e2..000000000 --- a/src/pal/src/libunwind/src/ptrace/_UPT_get_proc_name.c +++ /dev/null @@ -1,42 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2003 Hewlett-Packard Co - Copyright (C) 2007 David Mosberger-Tang - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include "_UPT_internal.h" - -int -_UPT_get_proc_name (unw_addr_space_t as, unw_word_t ip, - char *buf, size_t buf_len, unw_word_t *offp, void *arg) -{ - struct UPT_info *ui = arg; - -#if ELF_CLASS == ELFCLASS64 - return _Uelf64_get_proc_name (as, ui->pid, ip, buf, buf_len, offp); -#elif ELF_CLASS == ELFCLASS32 - return _Uelf32_get_proc_name (as, ui->pid, ip, buf, buf_len, offp); -#else - return -UNW_ENOINFO; -#endif -} diff --git a/src/pal/src/libunwind/src/ptrace/_UPT_internal.h b/src/pal/src/libunwind/src/ptrace/_UPT_internal.h deleted file mode 100644 index 5cef2573e..000000000 --- a/src/pal/src/libunwind/src/ptrace/_UPT_internal.h +++ /dev/null @@ -1,59 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2003, 2005 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#ifndef _UPT_internal_h -#define _UPT_internal_h - -#ifdef HAVE_CONFIG_H -#include -#endif - -#ifdef HAVE_SYS_TYPES_H -#include -#endif -#ifdef HAVE_SYS_PTRACE_H -#include -#endif -#ifdef HAVE_SYS_PROCFS_H -#include -#endif - -#include -#include -#include -#include -#include - -#include "libunwind_i.h" - -struct UPT_info - { - pid_t pid; /* the process-id of the child we're unwinding */ - struct elf_dyn_info edi; - }; - -extern const int _UPT_reg_offset[UNW_REG_LAST + 1]; - -#endif /* _UPT_internal_h */ diff --git a/src/pal/src/libunwind/src/ptrace/_UPT_put_unwind_info.c b/src/pal/src/libunwind/src/ptrace/_UPT_put_unwind_info.c deleted file mode 100644 index d4b846314..000000000 --- a/src/pal/src/libunwind/src/ptrace/_UPT_put_unwind_info.c +++ /dev/null @@ -1,35 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2003 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include "_UPT_internal.h" - -void -_UPT_put_unwind_info (unw_addr_space_t as, unw_proc_info_t *pi, void *arg) -{ - if (!pi->unwind_info) - return; - free (pi->unwind_info); - pi->unwind_info = NULL; -} diff --git a/src/pal/src/libunwind/src/ptrace/_UPT_reg_offset.c b/src/pal/src/libunwind/src/ptrace/_UPT_reg_offset.c deleted file mode 100644 index c82d1c988..000000000 --- a/src/pal/src/libunwind/src/ptrace/_UPT_reg_offset.c +++ /dev/null @@ -1,638 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2003-2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - Copyright (C) 2013 Linaro Limited - -This file is part of libunwind. - -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. */ - -#include "_UPT_internal.h" - -#include - -#ifdef HAVE_ASM_PTRACE_OFFSETS_H -# include -#endif - -const int _UPT_reg_offset[UNW_REG_LAST + 1] = - { -#ifdef HAVE_ASM_PTRACE_OFFSETS_H -# ifndef PT_AR_CSD -# define PT_AR_CSD -1 /* this was introduced with rev 2.1 of ia64 */ -# endif - - [UNW_IA64_GR + 0] = -1, [UNW_IA64_GR + 1] = PT_R1, - [UNW_IA64_GR + 2] = PT_R2, [UNW_IA64_GR + 3] = PT_R3, - [UNW_IA64_GR + 4] = PT_R4, [UNW_IA64_GR + 5] = PT_R5, - [UNW_IA64_GR + 6] = PT_R6, [UNW_IA64_GR + 7] = PT_R7, - [UNW_IA64_GR + 8] = PT_R8, [UNW_IA64_GR + 9] = PT_R9, - [UNW_IA64_GR + 10] = PT_R10, [UNW_IA64_GR + 11] = PT_R11, - [UNW_IA64_GR + 12] = PT_R12, [UNW_IA64_GR + 13] = PT_R13, - [UNW_IA64_GR + 14] = PT_R14, [UNW_IA64_GR + 15] = PT_R15, - [UNW_IA64_GR + 16] = PT_R16, [UNW_IA64_GR + 17] = PT_R17, - [UNW_IA64_GR + 18] = PT_R18, [UNW_IA64_GR + 19] = PT_R19, - [UNW_IA64_GR + 20] = PT_R20, [UNW_IA64_GR + 21] = PT_R21, - [UNW_IA64_GR + 22] = PT_R22, [UNW_IA64_GR + 23] = PT_R23, - [UNW_IA64_GR + 24] = PT_R24, [UNW_IA64_GR + 25] = PT_R25, - [UNW_IA64_GR + 26] = PT_R26, [UNW_IA64_GR + 27] = PT_R27, - [UNW_IA64_GR + 28] = PT_R28, [UNW_IA64_GR + 29] = PT_R29, - [UNW_IA64_GR + 30] = PT_R30, [UNW_IA64_GR + 31] = PT_R31, - - [UNW_IA64_NAT+ 0] = -1, [UNW_IA64_NAT+ 1] = PT_NAT_BITS, - [UNW_IA64_NAT+ 2] = PT_NAT_BITS, [UNW_IA64_NAT+ 3] = PT_NAT_BITS, - [UNW_IA64_NAT+ 4] = PT_NAT_BITS, [UNW_IA64_NAT+ 5] = PT_NAT_BITS, - [UNW_IA64_NAT+ 6] = PT_NAT_BITS, [UNW_IA64_NAT+ 7] = PT_NAT_BITS, - [UNW_IA64_NAT+ 8] = PT_NAT_BITS, [UNW_IA64_NAT+ 9] = PT_NAT_BITS, - [UNW_IA64_NAT+ 10] = PT_NAT_BITS, [UNW_IA64_NAT+ 11] = PT_NAT_BITS, - [UNW_IA64_NAT+ 12] = PT_NAT_BITS, [UNW_IA64_NAT+ 13] = PT_NAT_BITS, - [UNW_IA64_NAT+ 14] = PT_NAT_BITS, [UNW_IA64_NAT+ 15] = PT_NAT_BITS, - [UNW_IA64_NAT+ 16] = PT_NAT_BITS, [UNW_IA64_NAT+ 17] = PT_NAT_BITS, - [UNW_IA64_NAT+ 18] = PT_NAT_BITS, [UNW_IA64_NAT+ 19] = PT_NAT_BITS, - [UNW_IA64_NAT+ 20] = PT_NAT_BITS, [UNW_IA64_NAT+ 21] = PT_NAT_BITS, - [UNW_IA64_NAT+ 22] = PT_NAT_BITS, [UNW_IA64_NAT+ 23] = PT_NAT_BITS, - [UNW_IA64_NAT+ 24] = PT_NAT_BITS, [UNW_IA64_NAT+ 25] = PT_NAT_BITS, - [UNW_IA64_NAT+ 26] = PT_NAT_BITS, [UNW_IA64_NAT+ 27] = PT_NAT_BITS, - [UNW_IA64_NAT+ 28] = PT_NAT_BITS, [UNW_IA64_NAT+ 29] = PT_NAT_BITS, - [UNW_IA64_NAT+ 30] = PT_NAT_BITS, [UNW_IA64_NAT+ 31] = PT_NAT_BITS, - - [UNW_IA64_FR + 0] = -1, [UNW_IA64_FR + 1] = -1, - [UNW_IA64_FR + 2] = PT_F2, [UNW_IA64_FR + 3] = PT_F3, - [UNW_IA64_FR + 4] = PT_F4, [UNW_IA64_FR + 5] = PT_F5, - [UNW_IA64_FR + 6] = PT_F6, [UNW_IA64_FR + 7] = PT_F7, - [UNW_IA64_FR + 8] = PT_F8, [UNW_IA64_FR + 9] = PT_F9, - [UNW_IA64_FR + 10] = PT_F10, [UNW_IA64_FR + 11] = PT_F11, - [UNW_IA64_FR + 12] = PT_F12, [UNW_IA64_FR + 13] = PT_F13, - [UNW_IA64_FR + 14] = PT_F14, [UNW_IA64_FR + 15] = PT_F15, - [UNW_IA64_FR + 16] = PT_F16, [UNW_IA64_FR + 17] = PT_F17, - [UNW_IA64_FR + 18] = PT_F18, [UNW_IA64_FR + 19] = PT_F19, - [UNW_IA64_FR + 20] = PT_F20, [UNW_IA64_FR + 21] = PT_F21, - [UNW_IA64_FR + 22] = PT_F22, [UNW_IA64_FR + 23] = PT_F23, - [UNW_IA64_FR + 24] = PT_F24, [UNW_IA64_FR + 25] = PT_F25, - [UNW_IA64_FR + 26] = PT_F26, [UNW_IA64_FR + 27] = PT_F27, - [UNW_IA64_FR + 28] = PT_F28, [UNW_IA64_FR + 29] = PT_F29, - [UNW_IA64_FR + 30] = PT_F30, [UNW_IA64_FR + 31] = PT_F31, - [UNW_IA64_FR + 32] = PT_F32, [UNW_IA64_FR + 33] = PT_F33, - [UNW_IA64_FR + 34] = PT_F34, [UNW_IA64_FR + 35] = PT_F35, - [UNW_IA64_FR + 36] = PT_F36, [UNW_IA64_FR + 37] = PT_F37, - [UNW_IA64_FR + 38] = PT_F38, [UNW_IA64_FR + 39] = PT_F39, - [UNW_IA64_FR + 40] = PT_F40, [UNW_IA64_FR + 41] = PT_F41, - [UNW_IA64_FR + 42] = PT_F42, [UNW_IA64_FR + 43] = PT_F43, - [UNW_IA64_FR + 44] = PT_F44, [UNW_IA64_FR + 45] = PT_F45, - [UNW_IA64_FR + 46] = PT_F46, [UNW_IA64_FR + 47] = PT_F47, - [UNW_IA64_FR + 48] = PT_F48, [UNW_IA64_FR + 49] = PT_F49, - [UNW_IA64_FR + 50] = PT_F50, [UNW_IA64_FR + 51] = PT_F51, - [UNW_IA64_FR + 52] = PT_F52, [UNW_IA64_FR + 53] = PT_F53, - [UNW_IA64_FR + 54] = PT_F54, [UNW_IA64_FR + 55] = PT_F55, - [UNW_IA64_FR + 56] = PT_F56, [UNW_IA64_FR + 57] = PT_F57, - [UNW_IA64_FR + 58] = PT_F58, [UNW_IA64_FR + 59] = PT_F59, - [UNW_IA64_FR + 60] = PT_F60, [UNW_IA64_FR + 61] = PT_F61, - [UNW_IA64_FR + 62] = PT_F62, [UNW_IA64_FR + 63] = PT_F63, - [UNW_IA64_FR + 64] = PT_F64, [UNW_IA64_FR + 65] = PT_F65, - [UNW_IA64_FR + 66] = PT_F66, [UNW_IA64_FR + 67] = PT_F67, - [UNW_IA64_FR + 68] = PT_F68, [UNW_IA64_FR + 69] = PT_F69, - [UNW_IA64_FR + 70] = PT_F70, [UNW_IA64_FR + 71] = PT_F71, - [UNW_IA64_FR + 72] = PT_F72, [UNW_IA64_FR + 73] = PT_F73, - [UNW_IA64_FR + 74] = PT_F74, [UNW_IA64_FR + 75] = PT_F75, - [UNW_IA64_FR + 76] = PT_F76, [UNW_IA64_FR + 77] = PT_F77, - [UNW_IA64_FR + 78] = PT_F78, [UNW_IA64_FR + 79] = PT_F79, - [UNW_IA64_FR + 80] = PT_F80, [UNW_IA64_FR + 81] = PT_F81, - [UNW_IA64_FR + 82] = PT_F82, [UNW_IA64_FR + 83] = PT_F83, - [UNW_IA64_FR + 84] = PT_F84, [UNW_IA64_FR + 85] = PT_F85, - [UNW_IA64_FR + 86] = PT_F86, [UNW_IA64_FR + 87] = PT_F87, - [UNW_IA64_FR + 88] = PT_F88, [UNW_IA64_FR + 89] = PT_F89, - [UNW_IA64_FR + 90] = PT_F90, [UNW_IA64_FR + 91] = PT_F91, - [UNW_IA64_FR + 92] = PT_F92, [UNW_IA64_FR + 93] = PT_F93, - [UNW_IA64_FR + 94] = PT_F94, [UNW_IA64_FR + 95] = PT_F95, - [UNW_IA64_FR + 96] = PT_F96, [UNW_IA64_FR + 97] = PT_F97, - [UNW_IA64_FR + 98] = PT_F98, [UNW_IA64_FR + 99] = PT_F99, - [UNW_IA64_FR +100] = PT_F100, [UNW_IA64_FR +101] = PT_F101, - [UNW_IA64_FR +102] = PT_F102, [UNW_IA64_FR +103] = PT_F103, - [UNW_IA64_FR +104] = PT_F104, [UNW_IA64_FR +105] = PT_F105, - [UNW_IA64_FR +106] = PT_F106, [UNW_IA64_FR +107] = PT_F107, - [UNW_IA64_FR +108] = PT_F108, [UNW_IA64_FR +109] = PT_F109, - [UNW_IA64_FR +110] = PT_F110, [UNW_IA64_FR +111] = PT_F111, - [UNW_IA64_FR +112] = PT_F112, [UNW_IA64_FR +113] = PT_F113, - [UNW_IA64_FR +114] = PT_F114, [UNW_IA64_FR +115] = PT_F115, - [UNW_IA64_FR +116] = PT_F116, [UNW_IA64_FR +117] = PT_F117, - [UNW_IA64_FR +118] = PT_F118, [UNW_IA64_FR +119] = PT_F119, - [UNW_IA64_FR +120] = PT_F120, [UNW_IA64_FR +121] = PT_F121, - [UNW_IA64_FR +122] = PT_F122, [UNW_IA64_FR +123] = PT_F123, - [UNW_IA64_FR +124] = PT_F124, [UNW_IA64_FR +125] = PT_F125, - [UNW_IA64_FR +126] = PT_F126, [UNW_IA64_FR +127] = PT_F127, - - [UNW_IA64_AR + 0] = -1, [UNW_IA64_AR + 1] = -1, - [UNW_IA64_AR + 2] = -1, [UNW_IA64_AR + 3] = -1, - [UNW_IA64_AR + 4] = -1, [UNW_IA64_AR + 5] = -1, - [UNW_IA64_AR + 6] = -1, [UNW_IA64_AR + 7] = -1, - [UNW_IA64_AR + 8] = -1, [UNW_IA64_AR + 9] = -1, - [UNW_IA64_AR + 10] = -1, [UNW_IA64_AR + 11] = -1, - [UNW_IA64_AR + 12] = -1, [UNW_IA64_AR + 13] = -1, - [UNW_IA64_AR + 14] = -1, [UNW_IA64_AR + 15] = -1, - [UNW_IA64_AR + 16] = PT_AR_RSC, [UNW_IA64_AR + 17] = PT_AR_BSP, - [UNW_IA64_AR + 18] = PT_AR_BSPSTORE,[UNW_IA64_AR + 19] = PT_AR_RNAT, - [UNW_IA64_AR + 20] = -1, [UNW_IA64_AR + 21] = -1, - [UNW_IA64_AR + 22] = -1, [UNW_IA64_AR + 23] = -1, - [UNW_IA64_AR + 24] = -1, [UNW_IA64_AR + 25] = PT_AR_CSD, - [UNW_IA64_AR + 26] = -1, [UNW_IA64_AR + 27] = -1, - [UNW_IA64_AR + 28] = -1, [UNW_IA64_AR + 29] = -1, - [UNW_IA64_AR + 30] = -1, [UNW_IA64_AR + 31] = -1, - [UNW_IA64_AR + 32] = PT_AR_CCV, [UNW_IA64_AR + 33] = -1, - [UNW_IA64_AR + 34] = -1, [UNW_IA64_AR + 35] = -1, - [UNW_IA64_AR + 36] = PT_AR_UNAT, [UNW_IA64_AR + 37] = -1, - [UNW_IA64_AR + 38] = -1, [UNW_IA64_AR + 39] = -1, - [UNW_IA64_AR + 40] = PT_AR_FPSR, [UNW_IA64_AR + 41] = -1, - [UNW_IA64_AR + 42] = -1, [UNW_IA64_AR + 43] = -1, - [UNW_IA64_AR + 44] = -1, [UNW_IA64_AR + 45] = -1, - [UNW_IA64_AR + 46] = -1, [UNW_IA64_AR + 47] = -1, - [UNW_IA64_AR + 48] = -1, [UNW_IA64_AR + 49] = -1, - [UNW_IA64_AR + 50] = -1, [UNW_IA64_AR + 51] = -1, - [UNW_IA64_AR + 52] = -1, [UNW_IA64_AR + 53] = -1, - [UNW_IA64_AR + 54] = -1, [UNW_IA64_AR + 55] = -1, - [UNW_IA64_AR + 56] = -1, [UNW_IA64_AR + 57] = -1, - [UNW_IA64_AR + 58] = -1, [UNW_IA64_AR + 59] = -1, - [UNW_IA64_AR + 60] = -1, [UNW_IA64_AR + 61] = -1, - [UNW_IA64_AR + 62] = -1, [UNW_IA64_AR + 63] = -1, - [UNW_IA64_AR + 64] = PT_AR_PFS, [UNW_IA64_AR + 65] = PT_AR_LC, - [UNW_IA64_AR + 66] = PT_AR_EC, [UNW_IA64_AR + 67] = -1, - [UNW_IA64_AR + 68] = -1, [UNW_IA64_AR + 69] = -1, - [UNW_IA64_AR + 70] = -1, [UNW_IA64_AR + 71] = -1, - [UNW_IA64_AR + 72] = -1, [UNW_IA64_AR + 73] = -1, - [UNW_IA64_AR + 74] = -1, [UNW_IA64_AR + 75] = -1, - [UNW_IA64_AR + 76] = -1, [UNW_IA64_AR + 77] = -1, - [UNW_IA64_AR + 78] = -1, [UNW_IA64_AR + 79] = -1, - [UNW_IA64_AR + 80] = -1, [UNW_IA64_AR + 81] = -1, - [UNW_IA64_AR + 82] = -1, [UNW_IA64_AR + 83] = -1, - [UNW_IA64_AR + 84] = -1, [UNW_IA64_AR + 85] = -1, - [UNW_IA64_AR + 86] = -1, [UNW_IA64_AR + 87] = -1, - [UNW_IA64_AR + 88] = -1, [UNW_IA64_AR + 89] = -1, - [UNW_IA64_AR + 90] = -1, [UNW_IA64_AR + 91] = -1, - [UNW_IA64_AR + 92] = -1, [UNW_IA64_AR + 93] = -1, - [UNW_IA64_AR + 94] = -1, [UNW_IA64_AR + 95] = -1, - [UNW_IA64_AR + 96] = -1, [UNW_IA64_AR + 97] = -1, - [UNW_IA64_AR + 98] = -1, [UNW_IA64_AR + 99] = -1, - [UNW_IA64_AR +100] = -1, [UNW_IA64_AR +101] = -1, - [UNW_IA64_AR +102] = -1, [UNW_IA64_AR +103] = -1, - [UNW_IA64_AR +104] = -1, [UNW_IA64_AR +105] = -1, - [UNW_IA64_AR +106] = -1, [UNW_IA64_AR +107] = -1, - [UNW_IA64_AR +108] = -1, [UNW_IA64_AR +109] = -1, - [UNW_IA64_AR +110] = -1, [UNW_IA64_AR +111] = -1, - [UNW_IA64_AR +112] = -1, [UNW_IA64_AR +113] = -1, - [UNW_IA64_AR +114] = -1, [UNW_IA64_AR +115] = -1, - [UNW_IA64_AR +116] = -1, [UNW_IA64_AR +117] = -1, - [UNW_IA64_AR +118] = -1, [UNW_IA64_AR +119] = -1, - [UNW_IA64_AR +120] = -1, [UNW_IA64_AR +121] = -1, - [UNW_IA64_AR +122] = -1, [UNW_IA64_AR +123] = -1, - [UNW_IA64_AR +124] = -1, [UNW_IA64_AR +125] = -1, - [UNW_IA64_AR +126] = -1, [UNW_IA64_AR +127] = -1, - - [UNW_IA64_BR + 0] = PT_B0, [UNW_IA64_BR + 1] = PT_B1, - [UNW_IA64_BR + 2] = PT_B2, [UNW_IA64_BR + 3] = PT_B3, - [UNW_IA64_BR + 4] = PT_B4, [UNW_IA64_BR + 5] = PT_B5, - [UNW_IA64_BR + 6] = PT_B6, [UNW_IA64_BR + 7] = PT_B7, - - [UNW_IA64_PR] = PT_PR, - [UNW_IA64_CFM] = PT_CFM, - [UNW_IA64_IP] = PT_CR_IIP -#elif defined(HAVE_TTRACE) -# warning No support for ttrace() yet. -#elif defined(UNW_TARGET_HPPA) - [UNW_HPPA_GR + 0] = 0x000, [UNW_HPPA_GR + 1] = 0x004, - [UNW_HPPA_GR + 2] = 0x008, [UNW_HPPA_GR + 3] = 0x00c, - [UNW_HPPA_GR + 4] = 0x010, [UNW_HPPA_GR + 5] = 0x014, - [UNW_HPPA_GR + 6] = 0x018, [UNW_HPPA_GR + 7] = 0x01c, - [UNW_HPPA_GR + 8] = 0x020, [UNW_HPPA_GR + 9] = 0x024, - [UNW_HPPA_GR + 10] = 0x028, [UNW_HPPA_GR + 11] = 0x02c, - [UNW_HPPA_GR + 12] = 0x030, [UNW_HPPA_GR + 13] = 0x034, - [UNW_HPPA_GR + 14] = 0x038, [UNW_HPPA_GR + 15] = 0x03c, - [UNW_HPPA_GR + 16] = 0x040, [UNW_HPPA_GR + 17] = 0x044, - [UNW_HPPA_GR + 18] = 0x048, [UNW_HPPA_GR + 19] = 0x04c, - [UNW_HPPA_GR + 20] = 0x050, [UNW_HPPA_GR + 21] = 0x054, - [UNW_HPPA_GR + 22] = 0x058, [UNW_HPPA_GR + 23] = 0x05c, - [UNW_HPPA_GR + 24] = 0x060, [UNW_HPPA_GR + 25] = 0x064, - [UNW_HPPA_GR + 26] = 0x068, [UNW_HPPA_GR + 27] = 0x06c, - [UNW_HPPA_GR + 28] = 0x070, [UNW_HPPA_GR + 29] = 0x074, - [UNW_HPPA_GR + 30] = 0x078, [UNW_HPPA_GR + 31] = 0x07c, - - [UNW_HPPA_FR + 0] = 0x080, [UNW_HPPA_FR + 1] = 0x088, - [UNW_HPPA_FR + 2] = 0x090, [UNW_HPPA_FR + 3] = 0x098, - [UNW_HPPA_FR + 4] = 0x0a0, [UNW_HPPA_FR + 5] = 0x0a8, - [UNW_HPPA_FR + 6] = 0x0b0, [UNW_HPPA_FR + 7] = 0x0b8, - [UNW_HPPA_FR + 8] = 0x0c0, [UNW_HPPA_FR + 9] = 0x0c8, - [UNW_HPPA_FR + 10] = 0x0d0, [UNW_HPPA_FR + 11] = 0x0d8, - [UNW_HPPA_FR + 12] = 0x0e0, [UNW_HPPA_FR + 13] = 0x0e8, - [UNW_HPPA_FR + 14] = 0x0f0, [UNW_HPPA_FR + 15] = 0x0f8, - [UNW_HPPA_FR + 16] = 0x100, [UNW_HPPA_FR + 17] = 0x108, - [UNW_HPPA_FR + 18] = 0x110, [UNW_HPPA_FR + 19] = 0x118, - [UNW_HPPA_FR + 20] = 0x120, [UNW_HPPA_FR + 21] = 0x128, - [UNW_HPPA_FR + 22] = 0x130, [UNW_HPPA_FR + 23] = 0x138, - [UNW_HPPA_FR + 24] = 0x140, [UNW_HPPA_FR + 25] = 0x148, - [UNW_HPPA_FR + 26] = 0x150, [UNW_HPPA_FR + 27] = 0x158, - [UNW_HPPA_FR + 28] = 0x160, [UNW_HPPA_FR + 29] = 0x168, - [UNW_HPPA_FR + 30] = 0x170, [UNW_HPPA_FR + 31] = 0x178, - - [UNW_HPPA_IP] = 0x1a8 /* IAOQ[0] */ -#elif defined(UNW_TARGET_X86) -#if defined __FreeBSD__ -#define UNW_R_OFF(R, r) \ - [UNW_X86_##R] = offsetof(gregset_t, r_##r), - UNW_R_OFF(EAX, eax) - UNW_R_OFF(EDX, edx) - UNW_R_OFF(ECX, ecx) - UNW_R_OFF(EBX, ebx) - UNW_R_OFF(ESI, esi) - UNW_R_OFF(EDI, edi) - UNW_R_OFF(EBP, ebp) - UNW_R_OFF(ESP, esp) - UNW_R_OFF(EIP, eip) -// UNW_R_OFF(CS, cs) -// UNW_R_OFF(EFLAGS, eflags) -// UNW_R_OFF(SS, ss) -#elif defined __linux__ - [UNW_X86_EAX] = 0x18, - [UNW_X86_EBX] = 0x00, - [UNW_X86_ECX] = 0x04, - [UNW_X86_EDX] = 0x08, - [UNW_X86_ESI] = 0x0c, - [UNW_X86_EDI] = 0x10, - [UNW_X86_EBP] = 0x14, - [UNW_X86_EIP] = 0x30, - [UNW_X86_ESP] = 0x3c -/* CS = 0x34, */ -/* DS = 0x1c, */ -/* ES = 0x20, */ -/* FS = 0x24, */ -/* GS = 0x28, */ -/* ORIG_EAX = 0x2c, */ -/* EFLAGS = 0x38, */ -/* SS = 0x40 */ -#else -#error Port me -#endif -#elif defined(UNW_TARGET_X86_64) -#if defined __FreeBSD__ -#define UNW_R_OFF(R, r) \ - [UNW_X86_64_##R] = offsetof(gregset_t, r_##r), - UNW_R_OFF(RAX, rax) - UNW_R_OFF(RDX, rdx) - UNW_R_OFF(RCX, rcx) - UNW_R_OFF(RBX, rbx) - UNW_R_OFF(RSI, rsi) - UNW_R_OFF(RDI, rdi) - UNW_R_OFF(RBP, rbp) - UNW_R_OFF(RSP, rsp) - UNW_R_OFF(R8, r8) - UNW_R_OFF(R9, r9) - UNW_R_OFF(R10, r10) - UNW_R_OFF(R11, r11) - UNW_R_OFF(R12, r12) - UNW_R_OFF(R13, r13) - UNW_R_OFF(R14, r14) - UNW_R_OFF(R15, r15) - UNW_R_OFF(RIP, rip) -// UNW_R_OFF(CS, cs) -// UNW_R_OFF(EFLAGS, rflags) -// UNW_R_OFF(SS, ss) -#undef UNW_R_OFF -#elif defined __linux__ - [UNW_X86_64_RAX] = 0x50, - [UNW_X86_64_RDX] = 0x60, - [UNW_X86_64_RCX] = 0x58, - [UNW_X86_64_RBX] = 0x28, - [UNW_X86_64_RSI] = 0x68, - [UNW_X86_64_RDI] = 0x70, - [UNW_X86_64_RBP] = 0x20, - [UNW_X86_64_RSP] = 0x98, - [UNW_X86_64_R8] = 0x48, - [UNW_X86_64_R9] = 0x40, - [UNW_X86_64_R10] = 0x38, - [UNW_X86_64_R11] = 0x30, - [UNW_X86_64_R12] = 0x18, - [UNW_X86_64_R13] = 0x10, - [UNW_X86_64_R14] = 0x08, - [UNW_X86_64_R15] = 0x00, - [UNW_X86_64_RIP] = 0x80 -// [UNW_X86_64_CS] = 0x88, -// [UNW_X86_64_EFLAGS] = 0x90, -// [UNW_X86_64_RSP] = 0x98, -// [UNW_X86_64_SS] = 0xa0 -#else -#error Port me -#endif -#elif defined(UNW_TARGET_PPC32) || defined(UNW_TARGET_PPC64) - -#define UNW_REG_SLOT_SIZE sizeof(unsigned long) -#define UNW_PPC_R(v) ((v) * UNW_REG_SLOT_SIZE) -#define UNW_PPC_PT(p) UNW_PPC_R(PT_##p) - -#define UNW_FP_OFF(b, i) \ - [UNW_PPC##b##_F##i] = UNW_PPC_R(PT_FPR0 + i * 8/UNW_REG_SLOT_SIZE) - -#define UNW_R_OFF(b, i) \ - [UNW_PPC##b##_R##i] = UNW_PPC_R(PT_R##i) - -#define UNW_PPC_REGS(b) \ - UNW_R_OFF(b, 0), \ - UNW_R_OFF(b, 1), \ - UNW_R_OFF(b, 2), \ - UNW_R_OFF(b, 3), \ - UNW_R_OFF(b, 4), \ - UNW_R_OFF(b, 5), \ - UNW_R_OFF(b, 6), \ - UNW_R_OFF(b, 7), \ - UNW_R_OFF(b, 8), \ - UNW_R_OFF(b, 9), \ - UNW_R_OFF(b, 10), \ - UNW_R_OFF(b, 11), \ - UNW_R_OFF(b, 12), \ - UNW_R_OFF(b, 13), \ - UNW_R_OFF(b, 14), \ - UNW_R_OFF(b, 15), \ - UNW_R_OFF(b, 16), \ - UNW_R_OFF(b, 17), \ - UNW_R_OFF(b, 18), \ - UNW_R_OFF(b, 19), \ - UNW_R_OFF(b, 20), \ - UNW_R_OFF(b, 21), \ - UNW_R_OFF(b, 22), \ - UNW_R_OFF(b, 23), \ - UNW_R_OFF(b, 24), \ - UNW_R_OFF(b, 25), \ - UNW_R_OFF(b, 26), \ - UNW_R_OFF(b, 27), \ - UNW_R_OFF(b, 28), \ - UNW_R_OFF(b, 29), \ - UNW_R_OFF(b, 30), \ - UNW_R_OFF(b, 31), \ - \ - [UNW_PPC##b##_CTR] = UNW_PPC_PT(CTR), \ - [UNW_PPC##b##_XER] = UNW_PPC_PT(XER), \ - [UNW_PPC##b##_LR] = UNW_PPC_PT(LNK), \ - \ - UNW_FP_OFF(b, 0), \ - UNW_FP_OFF(b, 1), \ - UNW_FP_OFF(b, 2), \ - UNW_FP_OFF(b, 3), \ - UNW_FP_OFF(b, 4), \ - UNW_FP_OFF(b, 5), \ - UNW_FP_OFF(b, 6), \ - UNW_FP_OFF(b, 7), \ - UNW_FP_OFF(b, 8), \ - UNW_FP_OFF(b, 9), \ - UNW_FP_OFF(b, 10), \ - UNW_FP_OFF(b, 11), \ - UNW_FP_OFF(b, 12), \ - UNW_FP_OFF(b, 13), \ - UNW_FP_OFF(b, 14), \ - UNW_FP_OFF(b, 15), \ - UNW_FP_OFF(b, 16), \ - UNW_FP_OFF(b, 17), \ - UNW_FP_OFF(b, 18), \ - UNW_FP_OFF(b, 19), \ - UNW_FP_OFF(b, 20), \ - UNW_FP_OFF(b, 21), \ - UNW_FP_OFF(b, 22), \ - UNW_FP_OFF(b, 23), \ - UNW_FP_OFF(b, 24), \ - UNW_FP_OFF(b, 25), \ - UNW_FP_OFF(b, 26), \ - UNW_FP_OFF(b, 27), \ - UNW_FP_OFF(b, 28), \ - UNW_FP_OFF(b, 29), \ - UNW_FP_OFF(b, 30), \ - UNW_FP_OFF(b, 31) - -#define UNW_PPC32_REGS \ - [UNW_PPC32_FPSCR] = UNW_PPC_PT(FPSCR), \ - [UNW_PPC32_CCR] = UNW_PPC_PT(CCR) - -#define UNW_VR_OFF(i) \ - [UNW_PPC64_V##i] = UNW_PPC_R(PT_VR0 + i * 2) - -#define UNW_PPC64_REGS \ - [UNW_PPC64_NIP] = UNW_PPC_PT(NIP), \ - [UNW_PPC64_FRAME_POINTER] = -1, \ - [UNW_PPC64_ARG_POINTER] = -1, \ - [UNW_PPC64_CR0] = -1, \ - [UNW_PPC64_CR1] = -1, \ - [UNW_PPC64_CR2] = -1, \ - [UNW_PPC64_CR3] = -1, \ - [UNW_PPC64_CR4] = -1, \ - [UNW_PPC64_CR5] = -1, \ - [UNW_PPC64_CR6] = -1, \ - [UNW_PPC64_CR7] = -1, \ - [UNW_PPC64_VRSAVE] = UNW_PPC_PT(VRSAVE), \ - [UNW_PPC64_VSCR] = UNW_PPC_PT(VSCR), \ - [UNW_PPC64_SPE_ACC] = -1, \ - [UNW_PPC64_SPEFSCR] = -1, \ - UNW_VR_OFF(0), \ - UNW_VR_OFF(1), \ - UNW_VR_OFF(2), \ - UNW_VR_OFF(3), \ - UNW_VR_OFF(4), \ - UNW_VR_OFF(5), \ - UNW_VR_OFF(6), \ - UNW_VR_OFF(7), \ - UNW_VR_OFF(8), \ - UNW_VR_OFF(9), \ - UNW_VR_OFF(10), \ - UNW_VR_OFF(11), \ - UNW_VR_OFF(12), \ - UNW_VR_OFF(13), \ - UNW_VR_OFF(14), \ - UNW_VR_OFF(15), \ - UNW_VR_OFF(16), \ - UNW_VR_OFF(17), \ - UNW_VR_OFF(18), \ - UNW_VR_OFF(19), \ - UNW_VR_OFF(20), \ - UNW_VR_OFF(21), \ - UNW_VR_OFF(22), \ - UNW_VR_OFF(23), \ - UNW_VR_OFF(24), \ - UNW_VR_OFF(25), \ - UNW_VR_OFF(26), \ - UNW_VR_OFF(27), \ - UNW_VR_OFF(28), \ - UNW_VR_OFF(29), \ - UNW_VR_OFF(30), \ - UNW_VR_OFF(31) - -#if defined(UNW_TARGET_PPC32) - UNW_PPC_REGS(32), - UNW_PPC32_REGS, -#else - UNW_PPC_REGS(64), - UNW_PPC64_REGS, -#endif - -#elif defined(UNW_TARGET_ARM) -#if defined(__linux__) || defined(__FreeBSD__) - [UNW_ARM_R0] = 0x00, - [UNW_ARM_R1] = 0x04, - [UNW_ARM_R2] = 0x08, - [UNW_ARM_R3] = 0x0c, - [UNW_ARM_R4] = 0x10, - [UNW_ARM_R5] = 0x14, - [UNW_ARM_R6] = 0x18, - [UNW_ARM_R7] = 0x1c, - [UNW_ARM_R8] = 0x20, - [UNW_ARM_R9] = 0x24, - [UNW_ARM_R10] = 0x28, - [UNW_ARM_R11] = 0x2c, - [UNW_ARM_R12] = 0x30, - [UNW_ARM_R13] = 0x34, - [UNW_ARM_R14] = 0x38, - [UNW_ARM_R15] = 0x3c, -#else -#error Fix me -#endif -#elif defined(UNW_TARGET_MIPS) - [UNW_MIPS_R0] = 0, - [UNW_MIPS_R1] = 1, - [UNW_MIPS_R2] = 2, - [UNW_MIPS_R3] = 3, - [UNW_MIPS_R4] = 4, - [UNW_MIPS_R5] = 5, - [UNW_MIPS_R6] = 6, - [UNW_MIPS_R7] = 7, - [UNW_MIPS_R8] = 8, - [UNW_MIPS_R9] = 9, - [UNW_MIPS_R10] = 10, - [UNW_MIPS_R11] = 11, - [UNW_MIPS_R12] = 12, - [UNW_MIPS_R13] = 13, - [UNW_MIPS_R14] = 14, - [UNW_MIPS_R15] = 15, - [UNW_MIPS_R16] = 16, - [UNW_MIPS_R17] = 17, - [UNW_MIPS_R18] = 18, - [UNW_MIPS_R19] = 19, - [UNW_MIPS_R20] = 20, - [UNW_MIPS_R21] = 21, - [UNW_MIPS_R22] = 22, - [UNW_MIPS_R23] = 23, - [UNW_MIPS_R24] = 24, - [UNW_MIPS_R25] = 25, - [UNW_MIPS_R26] = 26, - [UNW_MIPS_R27] = 27, - [UNW_MIPS_R28] = 28, - [UNW_MIPS_R29] = 29, - [UNW_MIPS_R30] = 30, - [UNW_MIPS_R31] = 31, - [UNW_MIPS_PC] = 64, -#elif defined(UNW_TARGET_SH) -#elif defined(UNW_TARGET_AARCH64) - [UNW_AARCH64_X0] = 0x00, - [UNW_AARCH64_X1] = 0x08, - [UNW_AARCH64_X2] = 0x10, - [UNW_AARCH64_X3] = 0x18, - [UNW_AARCH64_X4] = 0x20, - [UNW_AARCH64_X5] = 0x28, - [UNW_AARCH64_X6] = 0x30, - [UNW_AARCH64_X7] = 0x38, - [UNW_AARCH64_X8] = 0x40, - [UNW_AARCH64_X9] = 0x48, - [UNW_AARCH64_X10] = 0x50, - [UNW_AARCH64_X11] = 0x58, - [UNW_AARCH64_X12] = 0x60, - [UNW_AARCH64_X13] = 0x68, - [UNW_AARCH64_X14] = 0x70, - [UNW_AARCH64_X15] = 0x78, - [UNW_AARCH64_X16] = 0x80, - [UNW_AARCH64_X17] = 0x88, - [UNW_AARCH64_X18] = 0x90, - [UNW_AARCH64_X19] = 0x98, - [UNW_AARCH64_X20] = 0xa0, - [UNW_AARCH64_X21] = 0xa8, - [UNW_AARCH64_X22] = 0xb0, - [UNW_AARCH64_X23] = 0xb8, - [UNW_AARCH64_X24] = 0xc0, - [UNW_AARCH64_X25] = 0xc8, - [UNW_AARCH64_X26] = 0xd0, - [UNW_AARCH64_X27] = 0xd8, - [UNW_AARCH64_X28] = 0xe0, - [UNW_AARCH64_X29] = 0xe8, - [UNW_AARCH64_X30] = 0xf0, - [UNW_AARCH64_SP] = 0xf8, - [UNW_AARCH64_PC] = 0x100, - [UNW_AARCH64_PSTATE] = 0x108 -#elif defined(UNW_TARGET_TILEGX) - [UNW_TILEGX_R0] = 0x00, - [UNW_TILEGX_R1] = 0x08, - [UNW_TILEGX_R2] = 0x10, - [UNW_TILEGX_R3] = 0x08, - [UNW_TILEGX_R4] = 0x20, - [UNW_TILEGX_R5] = 0x28, - [UNW_TILEGX_R6] = 0x30, - [UNW_TILEGX_R7] = 0x38, - [UNW_TILEGX_R8] = 0x40, - [UNW_TILEGX_R9] = 0x48, - [UNW_TILEGX_R10] = 0x50, - [UNW_TILEGX_R11] = 0x58, - [UNW_TILEGX_R12] = 0x60, - [UNW_TILEGX_R13] = 0x68, - [UNW_TILEGX_R14] = 0x70, - [UNW_TILEGX_R15] = 0x78, - [UNW_TILEGX_R16] = 0x80, - [UNW_TILEGX_R17] = 0x88, - [UNW_TILEGX_R18] = 0x90, - [UNW_TILEGX_R19] = 0x98, - [UNW_TILEGX_R20] = 0xa0, - [UNW_TILEGX_R21] = 0xa8, - [UNW_TILEGX_R22] = 0xb0, - [UNW_TILEGX_R23] = 0xb8, - [UNW_TILEGX_R24] = 0xc0, - [UNW_TILEGX_R25] = 0xc8, - [UNW_TILEGX_R26] = 0xd0, - [UNW_TILEGX_R27] = 0xd8, - [UNW_TILEGX_R28] = 0xe0, - [UNW_TILEGX_R29] = 0xe8, - [UNW_TILEGX_R30] = 0xf0, - [UNW_TILEGX_R31] = 0xf8, - [UNW_TILEGX_R32] = 0x100, - [UNW_TILEGX_R33] = 0x108, - [UNW_TILEGX_R34] = 0x110, - [UNW_TILEGX_R35] = 0x118, - [UNW_TILEGX_R36] = 0x120, - [UNW_TILEGX_R37] = 0x128, - [UNW_TILEGX_R38] = 0x130, - [UNW_TILEGX_R39] = 0x138, - [UNW_TILEGX_R40] = 0x140, - [UNW_TILEGX_R41] = 0x148, - [UNW_TILEGX_R42] = 0x150, - [UNW_TILEGX_R43] = 0x158, - [UNW_TILEGX_R44] = 0x160, - [UNW_TILEGX_R45] = 0x168, - [UNW_TILEGX_R46] = 0x170, - [UNW_TILEGX_R47] = 0x178, - [UNW_TILEGX_R48] = 0x180, - [UNW_TILEGX_R49] = 0x188, - [UNW_TILEGX_R50] = 0x190, - [UNW_TILEGX_R51] = 0x198, - [UNW_TILEGX_R52] = 0x1a0, - [UNW_TILEGX_R53] = 0x1a8, - [UNW_TILEGX_R54] = 0x1b0, - [UNW_TILEGX_R55] = 0x1b8, - [UNW_TILEGX_PC] = 0x1a0 -#else -# error Fix me. -#endif - }; diff --git a/src/pal/src/libunwind/src/ptrace/_UPT_resume.c b/src/pal/src/libunwind/src/ptrace/_UPT_resume.c deleted file mode 100644 index d70a0d482..000000000 --- a/src/pal/src/libunwind/src/ptrace/_UPT_resume.c +++ /dev/null @@ -1,40 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2003 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include "_UPT_internal.h" - -int -_UPT_resume (unw_addr_space_t as, unw_cursor_t *c, void *arg) -{ - struct UPT_info *ui = arg; - -#ifdef HAVE_TTRACE -# warning No support for ttrace() yet. -#elif HAVE_DECL_PTRACE_CONT - return ptrace (PTRACE_CONT, ui->pid, 0, 0); -#elif HAVE_DECL_PT_CONTINUE - return ptrace(PT_CONTINUE, ui->pid, (caddr_t)1, 0); -#endif -} diff --git a/src/pal/src/libunwind/src/ptrace/libunwind-ptrace.pc.in b/src/pal/src/libunwind/src/ptrace/libunwind-ptrace.pc.in deleted file mode 100644 index 673004b69..000000000 --- a/src/pal/src/libunwind/src/ptrace/libunwind-ptrace.pc.in +++ /dev/null @@ -1,11 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ - -Name: libunwind-ptrace -Description: libunwind ptrace library -Version: @VERSION@ -Requires: libunwind-generic libunwind -Libs: -L${libdir} -lunwind-ptrace -Cflags: -I${includedir} diff --git a/src/pal/src/libunwind/src/setjmp/libunwind-setjmp.pc.in b/src/pal/src/libunwind/src/setjmp/libunwind-setjmp.pc.in deleted file mode 100644 index 7b7112653..000000000 --- a/src/pal/src/libunwind/src/setjmp/libunwind-setjmp.pc.in +++ /dev/null @@ -1,11 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ - -Name: libunwind-setjmp -Description: libunwind setjmp library -Version: @VERSION@ -Requires: libunwind -Libs: -L${libdir} -lunwind-setjmp -Cflags: -I${includedir} diff --git a/src/pal/src/libunwind/src/setjmp/longjmp.c b/src/pal/src/libunwind/src/setjmp/longjmp.c deleted file mode 100644 index 8295a9b8e..000000000 --- a/src/pal/src/libunwind/src/setjmp/longjmp.c +++ /dev/null @@ -1,115 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2003-2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#define UNW_LOCAL_ONLY - -#undef _FORTIFY_SOURCE -#include -#include -#include -#include -#include - -#include "jmpbuf.h" -#include "setjmp_i.h" - -#if defined(__GLIBC__) -#if __GLIBC_PREREQ(2, 4) - -/* Starting with glibc-2.4, {sig,}setjmp in GLIBC obfuscates the - register values in jmp_buf by XORing them with a "random" - canary value. - - This makes it impossible to implement longjmp, as we - can never match wp[JB_SP], unless we decode the canary first. - - Doing so is possible, but doesn't appear to be worth the trouble, - so we simply defer to glibc longjmp here. */ -#define _longjmp __nonworking__longjmp -#define longjmp __nonworking_longjmp -static void _longjmp (jmp_buf env, int val); -static void longjmp (jmp_buf env, int val); -#endif -#endif /* __GLIBC__ */ - -void -_longjmp (jmp_buf env, int val) -{ - extern int _UI_longjmp_cont; - unw_context_t uc; - unw_cursor_t c; - unw_word_t sp; - unw_word_t *wp = (unw_word_t *) env; - - if (unw_getcontext (&uc) < 0 || unw_init_local (&c, &uc) < 0) - abort (); - - do - { - if (unw_get_reg (&c, UNW_REG_SP, &sp) < 0) - abort (); -#ifdef __FreeBSD__ - if (sp != wp[JB_SP] + sizeof(unw_word_t)) -#else - if (sp != wp[JB_SP]) -#endif - continue; - - if (!bsp_match (&c, wp)) - continue; - - /* found the right frame: */ - - assert (UNW_NUM_EH_REGS >= 2); - - if (unw_set_reg (&c, UNW_REG_EH + 0, wp[JB_RP]) < 0 - || unw_set_reg (&c, UNW_REG_EH + 1, val) < 0 - || unw_set_reg (&c, UNW_REG_IP, - (unw_word_t) (uintptr_t) &_UI_longjmp_cont)) - abort (); - - unw_resume (&c); - - abort (); - } - while (unw_step (&c) > 0); - - abort (); -} - -#ifdef __GNUC__ -#define STRINGIFY1(x) #x -#define STRINGIFY(x) STRINGIFY1(x) -void longjmp (jmp_buf env, int val) - __attribute__ ((alias (STRINGIFY(_longjmp)))); -#else - -void -longjmp (jmp_buf env, int val) -{ - _longjmp (env, val); -} - -#endif /* __GNUC__ */ diff --git a/src/pal/src/libunwind/src/setjmp/setjmp.c b/src/pal/src/libunwind/src/setjmp/setjmp.c deleted file mode 100644 index bec9fc7d5..000000000 --- a/src/pal/src/libunwind/src/setjmp/setjmp.c +++ /dev/null @@ -1,49 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2003-2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include -#include - -#include "jmpbuf.h" - -/* Why use K&R syntax here? setjmp() is often a macro and that - expands into a call to, say, __setjmp() and we need to define the - libunwind-version of setjmp() with the name of the actual function. - Using K&R syntax lets us keep the setjmp() macro while keeping the - syntax valid... This trick works provided setjmp() doesn't do - anything other than a function call. */ - -int -setjmp (env) - jmp_buf env; -{ - void **wp = (void **) env; - - /* this should work on most platforms, but may not be - performance-optimal; check the code! */ - wp[JB_SP] = __builtin_frame_address (0); - wp[JB_RP] = (void *) __builtin_return_address (0); - return 0; -} diff --git a/src/pal/src/libunwind/src/setjmp/setjmp_i.h b/src/pal/src/libunwind/src/setjmp/setjmp_i.h deleted file mode 100644 index 4d9139693..000000000 --- a/src/pal/src/libunwind/src/setjmp/setjmp_i.h +++ /dev/null @@ -1,118 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2003-2005 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#if UNW_TARGET_IA64 - -#include "libunwind_i.h" -#include "tdep-ia64/rse.h" - -static inline int -bsp_match (unw_cursor_t *c, unw_word_t *wp) -{ - unw_word_t bsp, pfs, sol; - - if (unw_get_reg (c, UNW_IA64_BSP, &bsp) < 0 - || unw_get_reg (c, UNW_IA64_AR_PFS, &pfs) < 0) - abort (); - - /* simulate the effect of "br.call sigsetjmp" on ar.bsp: */ - sol = (pfs >> 7) & 0x7f; - bsp = rse_skip_regs (bsp, sol); - - if (bsp != wp[JB_BSP]) - return 0; - - if (unlikely (sol == 0)) - { - unw_word_t sp, prev_sp; - unw_cursor_t tmp = *c; - - /* The caller of {sig,}setjmp() cannot have a NULL-frame. If we - see a NULL-frame, we haven't reached the right target yet. - To have a NULL-frame, the number of locals must be zero and - the stack-frame must also be empty. */ - - if (unw_step (&tmp) < 0) - abort (); - - if (unw_get_reg (&tmp, UNW_REG_SP, &sp) < 0 - || unw_get_reg (&tmp, UNW_REG_SP, &prev_sp) < 0) - abort (); - - if (sp == prev_sp) - /* got a NULL-frame; keep looking... */ - return 0; - } - return 1; -} - -/* On ia64 we cannot always call sigprocmask() at - _UI_siglongjmp_cont() because the signal may have switched stacks - and the old stack's register-backing store may have overflown, - leaving us no space to allocate the stacked registers needed to - call sigprocmask(). Fortunately, we can just let unw_resume() (via - sigreturn) take care of restoring the signal-mask. That's faster - anyhow. */ -static inline int -resume_restores_sigmask (unw_cursor_t *c, unw_word_t *wp) -{ - unw_word_t sc_addr = ((struct cursor *) c)->sigcontext_addr; - struct sigcontext *sc = (struct sigcontext *) sc_addr; - sigset_t current_mask; - void *mp; - - if (!sc_addr) - return 0; - - /* let unw_resume() install the desired signal mask */ - - if (wp[JB_MASK_SAVED]) - mp = &wp[JB_MASK]; - else - { - if (sigprocmask (SIG_BLOCK, NULL, ¤t_mask) < 0) - abort (); - mp = ¤t_mask; - } - memcpy (&sc->sc_mask, mp, sizeof (sc->sc_mask)); - return 1; -} - -#else /* !UNW_TARGET_IA64 */ - -static inline int -bsp_match (unw_cursor_t *c, unw_word_t *wp) -{ - return 1; -} - -static inline int -resume_restores_sigmask (unw_cursor_t *c, unw_word_t *wp) -{ - /* We may want to do this analogously as for ia64... */ - return 0; -} - -#endif /* !UNW_TARGET_IA64 */ diff --git a/src/pal/src/libunwind/src/setjmp/siglongjmp.c b/src/pal/src/libunwind/src/setjmp/siglongjmp.c deleted file mode 100644 index 0e286f6f0..000000000 --- a/src/pal/src/libunwind/src/setjmp/siglongjmp.c +++ /dev/null @@ -1,127 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2003-2005 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#define UNW_LOCAL_ONLY - -#include - -#include "libunwind_i.h" -#include "jmpbuf.h" -#include "setjmp_i.h" - -#if !defined(_NSIG) && defined(_SIG_MAXSIG) -# define _NSIG (_SIG_MAXSIG - 1) -#endif - -#if defined(__GLIBC__) -#if __GLIBC_PREREQ(2, 4) - -/* Starting with glibc-2.4, {sig,}setjmp in GLIBC obfuscates the - register values in jmp_buf by XORing them with a "random" - canary value. - - This makes it impossible to implement longjmp, as we - can never match wp[JB_SP], unless we decode the canary first. - - Doing so is possible, but doesn't appear to be worth the trouble, - so we simply defer to glibc siglongjmp here. */ - -#define siglongjmp __nonworking_siglongjmp -static void siglongjmp (sigjmp_buf env, int val) UNUSED; -#endif -#endif /* __GLIBC_PREREQ */ - -void -siglongjmp (sigjmp_buf env, int val) -{ - unw_word_t *wp = (unw_word_t *) env; - extern int _UI_siglongjmp_cont; - extern int _UI_longjmp_cont; - unw_context_t uc; - unw_cursor_t c; - unw_word_t sp; - int *cont; - - if (unw_getcontext (&uc) < 0 || unw_init_local (&c, &uc) < 0) - abort (); - - do - { - if (unw_get_reg (&c, UNW_REG_SP, &sp) < 0) - abort (); -#ifdef __FreeBSD__ - if (sp != wp[JB_SP] + sizeof(unw_word_t)) -#else - if (sp != wp[JB_SP]) -#endif - continue; - - if (!bsp_match (&c, wp)) - continue; - - /* found the right frame: */ - - /* default to resuming without restoring signal-mask */ - cont = &_UI_longjmp_cont; - - /* Order of evaluation is important here: if unw_resume() - restores signal mask, we must set it up appropriately, even - if wp[JB_MASK_SAVED] is FALSE. */ - if (!resume_restores_sigmask (&c, wp) && wp[JB_MASK_SAVED]) - { - /* sigmask was saved */ -#if defined(__linux__) - if (UNW_NUM_EH_REGS < 4 || _NSIG > 16 * sizeof (unw_word_t)) - /* signal mask doesn't fit into EH arguments and we can't - put it on the stack without overwriting something - else... */ - abort (); - else - if (unw_set_reg (&c, UNW_REG_EH + 2, wp[JB_MASK]) < 0 - || (_NSIG > 8 * sizeof (unw_word_t) - && unw_set_reg (&c, UNW_REG_EH + 3, wp[JB_MASK + 1]) < 0)) - abort (); -#elif defined(__FreeBSD__) - if (unw_set_reg (&c, UNW_REG_EH + 2, &wp[JB_MASK]) < 0) - abort(); -#else -#error Port me -#endif - cont = &_UI_siglongjmp_cont; - } - - if (unw_set_reg (&c, UNW_REG_EH + 0, wp[JB_RP]) < 0 - || unw_set_reg (&c, UNW_REG_EH + 1, val) < 0 - || unw_set_reg (&c, UNW_REG_IP, (unw_word_t) (uintptr_t) cont)) - abort (); - - unw_resume (&c); - - abort (); - } - while (unw_step (&c) > 0); - - abort (); -} diff --git a/src/pal/src/libunwind/src/setjmp/sigsetjmp.c b/src/pal/src/libunwind/src/setjmp/sigsetjmp.c deleted file mode 100644 index f84935d63..000000000 --- a/src/pal/src/libunwind/src/setjmp/sigsetjmp.c +++ /dev/null @@ -1,50 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2003-2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include -#include -#include - -#include "jmpbuf.h" - -int -sigsetjmp (sigjmp_buf env, int savemask) -{ - unw_word_t *wp = (unw_word_t *) env; - - /* This should work on most platforms, but may not be - performance-optimal; check the code! */ - - wp[JB_SP] = (unw_word_t) __builtin_frame_address (0); - wp[JB_RP] = (unw_word_t) __builtin_return_address (0); - wp[JB_MASK_SAVED] = savemask; - - /* Note: we assume here that "wp" has same or better alignment as - sigset_t. */ - if (savemask - && sigprocmask (SIG_BLOCK, NULL, (sigset_t *) (wp + JB_MASK)) < 0) - abort (); - return 0; -} diff --git a/src/pal/src/libunwind/src/sh/Gapply_reg_state.c b/src/pal/src/libunwind/src/sh/Gapply_reg_state.c deleted file mode 100644 index 82f056da6..000000000 --- a/src/pal/src/libunwind/src/sh/Gapply_reg_state.c +++ /dev/null @@ -1,37 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (c) 2002-2003 Hewlett-Packard Development Company, L.P. - Contributed by David Mosberger-Tang - - Modified for x86_64 by Max Asbock - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" - -int -unw_apply_reg_state (unw_cursor_t *cursor, - void *reg_states_data) -{ - struct cursor *c = (struct cursor *) cursor; - - return dwarf_apply_reg_state (&c->dwarf, (dwarf_reg_state_t *)reg_states_data); -} diff --git a/src/pal/src/libunwind/src/sh/Gcreate_addr_space.c b/src/pal/src/libunwind/src/sh/Gcreate_addr_space.c deleted file mode 100644 index 6ca3a384d..000000000 --- a/src/pal/src/libunwind/src/sh/Gcreate_addr_space.c +++ /dev/null @@ -1,59 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2012 Tommi Rantala - -This file is part of libunwind. - -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. */ - -#include -#include - -#include "unwind_i.h" - -unw_addr_space_t -unw_create_addr_space (unw_accessors_t *a, int byte_order) -{ -#ifdef UNW_LOCAL_ONLY - return NULL; -#else - unw_addr_space_t as; - - /* SH supports little-endian and big-endian. */ - if (byte_order != 0 && byte_order != __LITTLE_ENDIAN - && byte_order != __BIG_ENDIAN) - return NULL; - - as = malloc (sizeof (*as)); - if (!as) - return NULL; - - memset (as, 0, sizeof (*as)); - - as->acc = *a; - - /* Default to little-endian for SH. */ - if (byte_order == 0 || byte_order == __LITTLE_ENDIAN) - as->big_endian = 0; - else - as->big_endian = 1; - - return as; -#endif -} diff --git a/src/pal/src/libunwind/src/sh/Gget_proc_info.c b/src/pal/src/libunwind/src/sh/Gget_proc_info.c deleted file mode 100644 index c363d2405..000000000 --- a/src/pal/src/libunwind/src/sh/Gget_proc_info.c +++ /dev/null @@ -1,39 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" - -int -unw_get_proc_info (unw_cursor_t *cursor, unw_proc_info_t *pi) -{ - struct cursor *c = (struct cursor *) cursor; - int ret; - - ret = dwarf_make_proc_info (&c->dwarf); - if (ret < 0) - return ret; - - *pi = c->dwarf.pi; - return 0; -} diff --git a/src/pal/src/libunwind/src/sh/Gget_save_loc.c b/src/pal/src/libunwind/src/sh/Gget_save_loc.c deleted file mode 100644 index 24d9f63bc..000000000 --- a/src/pal/src/libunwind/src/sh/Gget_save_loc.c +++ /dev/null @@ -1,83 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - Copyright (C) 2012 Tommi Rantala - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" - -int -unw_get_save_loc (unw_cursor_t *cursor, int reg, unw_save_loc_t *sloc) -{ - struct cursor *c = (struct cursor *) cursor; - dwarf_loc_t loc; - - switch (reg) - { - case UNW_SH_R0: - case UNW_SH_R1: - case UNW_SH_R2: - case UNW_SH_R3: - case UNW_SH_R4: - case UNW_SH_R5: - case UNW_SH_R6: - case UNW_SH_R7: - case UNW_SH_R8: - case UNW_SH_R9: - case UNW_SH_R10: - case UNW_SH_R11: - case UNW_SH_R12: - case UNW_SH_R13: - case UNW_SH_R14: - case UNW_SH_R15: - case UNW_SH_PC: - case UNW_SH_PR: - loc = c->dwarf.loc[reg]; - break; - - default: - loc = DWARF_NULL_LOC; /* default to "not saved" */ - break; - } - - memset (sloc, 0, sizeof (*sloc)); - - if (DWARF_IS_NULL_LOC (loc)) - { - sloc->type = UNW_SLT_NONE; - return 0; - } - -#if !defined(UNW_LOCAL_ONLY) - if (DWARF_IS_REG_LOC (loc)) - { - sloc->type = UNW_SLT_REG; - sloc->u.regnum = DWARF_GET_LOC (loc); - } - else -#endif - { - sloc->type = UNW_SLT_MEMORY; - sloc->u.addr = DWARF_GET_LOC (loc); - } - return 0; -} diff --git a/src/pal/src/libunwind/src/sh/Gglobal.c b/src/pal/src/libunwind/src/sh/Gglobal.c deleted file mode 100644 index ed2733397..000000000 --- a/src/pal/src/libunwind/src/sh/Gglobal.c +++ /dev/null @@ -1,56 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - Copyright (C) 2012 Tommi Rantala - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" -#include "dwarf_i.h" - -HIDDEN define_lock (sh_lock); -HIDDEN int tdep_init_done; - -HIDDEN void -tdep_init (void) -{ - intrmask_t saved_mask; - - sigfillset (&unwi_full_mask); - - lock_acquire (&sh_lock, saved_mask); - { - if (tdep_init_done) - /* another thread else beat us to it... */ - goto out; - - mi_init (); - - dwarf_init (); - -#ifndef UNW_REMOTE_ONLY - sh_local_addr_space_init (); -#endif - tdep_init_done = 1; /* signal that we're initialized... */ - } - out: - lock_release (&sh_lock, saved_mask); -} diff --git a/src/pal/src/libunwind/src/sh/Ginit.c b/src/pal/src/libunwind/src/sh/Ginit.c deleted file mode 100644 index 52988a721..000000000 --- a/src/pal/src/libunwind/src/sh/Ginit.c +++ /dev/null @@ -1,186 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - Copyright (C) 2012 Tommi Rantala - -This file is part of libunwind. - -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. */ - -#include -#include - -#include "unwind_i.h" - -#ifdef UNW_REMOTE_ONLY - -/* unw_local_addr_space is a NULL pointer in this case. */ -unw_addr_space_t unw_local_addr_space; - -#else /* !UNW_REMOTE_ONLY */ - -static struct unw_addr_space local_addr_space; - -unw_addr_space_t unw_local_addr_space = &local_addr_space; - -static inline void * -uc_addr (ucontext_t *uc, int reg) -{ - if (reg >= UNW_SH_R0 && reg <= UNW_SH_PR) - return &uc->uc_mcontext.gregs[reg]; - else - return NULL; -} - -# ifdef UNW_LOCAL_ONLY - -HIDDEN void * -tdep_uc_addr (ucontext_t *uc, int reg) -{ - return uc_addr (uc, reg); -} - -# endif /* UNW_LOCAL_ONLY */ - -HIDDEN unw_dyn_info_list_t _U_dyn_info_list; - -/* XXX fix me: there is currently no way to locate the dyn-info list - by a remote unwinder. On ia64, this is done via a special - unwind-table entry. Perhaps something similar can be done with - DWARF2 unwind info. */ - -static void -put_unwind_info (unw_addr_space_t as, unw_proc_info_t *proc_info, void *arg) -{ - /* it's a no-op */ -} - -static int -get_dyn_info_list_addr (unw_addr_space_t as, unw_word_t *dyn_info_list_addr, - void *arg) -{ - *dyn_info_list_addr = (unw_word_t) &_U_dyn_info_list; - return 0; -} - -static int -access_mem (unw_addr_space_t as, unw_word_t addr, unw_word_t *val, int write, - void *arg) -{ - if (write) - { - Debug (16, "mem[%x] <- %x\n", addr, *val); - *(unw_word_t *) addr = *val; - } - else - { - *val = *(unw_word_t *) addr; - Debug (16, "mem[%x] -> %x\n", addr, *val); - } - return 0; -} - -static int -access_reg (unw_addr_space_t as, unw_regnum_t reg, unw_word_t *val, int write, - void *arg) -{ - unw_word_t *addr; - ucontext_t *uc = arg; - - if (unw_is_fpreg (reg)) - goto badreg; - - if (!(addr = uc_addr (uc, reg))) - goto badreg; - - if (write) - { - *(unw_word_t *) addr = *val; - Debug (12, "%s <- %x\n", unw_regname (reg), *val); - } - else - { - *val = *(unw_word_t *) addr; - Debug (12, "%s -> %x\n", unw_regname (reg), *val); - } - return 0; - - badreg: - Debug (1, "bad register number %u\n", reg); - return -UNW_EBADREG; -} - -static int -access_fpreg (unw_addr_space_t as, unw_regnum_t reg, unw_fpreg_t *val, - int write, void *arg) -{ - ucontext_t *uc = arg; - unw_fpreg_t *addr; - - if (!unw_is_fpreg (reg)) - goto badreg; - - if (!(addr = uc_addr (uc, reg))) - goto badreg; - - if (write) - { - Debug (12, "%s <- %08lx.%08lx.%08lx\n", unw_regname (reg), - ((long *)val)[0], ((long *)val)[1], ((long *)val)[2]); - *(unw_fpreg_t *) addr = *val; - } - else - { - *val = *(unw_fpreg_t *) addr; - Debug (12, "%s -> %08lx.%08lx.%08lx\n", unw_regname (reg), - ((long *)val)[0], ((long *)val)[1], ((long *)val)[2]); - } - return 0; - - badreg: - Debug (1, "bad register number %u\n", reg); - /* attempt to access a non-preserved register */ - return -UNW_EBADREG; -} - -static int -get_static_proc_name (unw_addr_space_t as, unw_word_t ip, - char *buf, size_t buf_len, unw_word_t *offp, - void *arg) -{ - return _Uelf32_get_proc_name (as, getpid (), ip, buf, buf_len, offp); -} - -HIDDEN void -sh_local_addr_space_init (void) -{ - memset (&local_addr_space, 0, sizeof (local_addr_space)); - local_addr_space.caching_policy = UNWI_DEFAULT_CACHING_POLICY; - local_addr_space.acc.find_proc_info = dwarf_find_proc_info; - local_addr_space.acc.put_unwind_info = put_unwind_info; - local_addr_space.acc.get_dyn_info_list_addr = get_dyn_info_list_addr; - local_addr_space.acc.access_mem = access_mem; - local_addr_space.acc.access_reg = access_reg; - local_addr_space.acc.access_fpreg = access_fpreg; - local_addr_space.acc.resume = sh_local_resume; - local_addr_space.acc.get_proc_name = get_static_proc_name; - unw_flush_cache (&local_addr_space, 0, 0); -} - -#endif /* !UNW_REMOTE_ONLY */ diff --git a/src/pal/src/libunwind/src/sh/Ginit_local.c b/src/pal/src/libunwind/src/sh/Ginit_local.c deleted file mode 100644 index 99ddb36fb..000000000 --- a/src/pal/src/libunwind/src/sh/Ginit_local.c +++ /dev/null @@ -1,78 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - Copyright 2011 Linaro Limited - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" -#include "init.h" - -#ifdef UNW_REMOTE_ONLY - -int -unw_init_local (unw_cursor_t *cursor, unw_context_t *uc) -{ - return -UNW_EINVAL; -} - -#else /* !UNW_REMOTE_ONLY */ - -static int -unw_init_local (unw_cursor_t *cursor, unw_context_t *uc, unsigned use_prev_instr) -{ - struct cursor *c = (struct cursor *) cursor; - - if (!tdep_init_done) - tdep_init (); - - Debug (1, "(cursor=%p)\n", c); - - c->dwarf.as = unw_local_addr_space; - c->dwarf.as_arg = uc; - - return common_init (c, use_prev_instr); -} - -int -unw_init_local (unw_cursor_t *cursor, unw_context_t *uc) -{ - return unw_init_local_common(cursor, uc, 1); -} - -int -unw_init_local2 (unw_cursor_t *cursor, ucontext_t *uc, int flag) -{ - if (!flag) - { - return unw_init_local_common(cursor, uc, 1); - } - else if (flag == UNW_INIT_SIGNAL_FRAME) - { - return unw_init_local_common(cursor, uc, 0); - } - else - { - return -UNW_EINVAL; - } -} - -#endif /* !UNW_REMOTE_ONLY */ diff --git a/src/pal/src/libunwind/src/sh/Ginit_remote.c b/src/pal/src/libunwind/src/sh/Ginit_remote.c deleted file mode 100644 index 9b8ba5b89..000000000 --- a/src/pal/src/libunwind/src/sh/Ginit_remote.c +++ /dev/null @@ -1,45 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - -This file is part of libunwind. - -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. */ - -#include "init.h" -#include "unwind_i.h" - -int -unw_init_remote (unw_cursor_t *cursor, unw_addr_space_t as, void *as_arg) -{ -#ifdef UNW_LOCAL_ONLY - return -UNW_EINVAL; -#else /* !UNW_LOCAL_ONLY */ - struct cursor *c = (struct cursor *) cursor; - - if (!tdep_init_done) - tdep_init (); - - Debug (1, "(cursor=%p)\n", c); - - c->dwarf.as = as; - c->dwarf.as_arg = as_arg; - return common_init (c, 0); -#endif /* !UNW_LOCAL_ONLY */ -} diff --git a/src/pal/src/libunwind/src/sh/Gis_signal_frame.c b/src/pal/src/libunwind/src/sh/Gis_signal_frame.c deleted file mode 100644 index 4481fe1a4..000000000 --- a/src/pal/src/libunwind/src/sh/Gis_signal_frame.c +++ /dev/null @@ -1,119 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2012 Tommi Rantala - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" - -/* Disassembly of the Linux VDSO sigreturn functions: - -00000000 <__kernel_sigreturn>: - 0: 05 93 mov.w e <__kernel_sigreturn+0xe>,r3 ! 77 - 2: 10 c3 trapa #16 - 4: 0b 20 or r0,r0 - 6: 0b 20 or r0,r0 - 8: 0b 20 or r0,r0 - a: 0b 20 or r0,r0 - c: 0b 20 or r0,r0 - e: 77 00 .word 0x0077 - 10: 09 00 nop - 12: 09 00 nop - 14: 09 00 nop - 16: 09 00 nop - 18: 09 00 nop - 1a: 09 00 nop - 1c: 09 00 nop - 1e: 09 00 nop - -00000020 <__kernel_rt_sigreturn>: - 20: 05 93 mov.w 2e <__kernel_rt_sigreturn+0xe>,r3 ! ad - 22: 10 c3 trapa #16 - 24: 0b 20 or r0,r0 - 26: 0b 20 or r0,r0 - 28: 0b 20 or r0,r0 - 2a: 0b 20 or r0,r0 - 2c: 0b 20 or r0,r0 - 2e: ad 00 mov.w @(r0,r10),r0 - 30: 09 00 nop - 32: 09 00 nop - 34: 09 00 nop - 36: 09 00 nop - 38: 09 00 nop - 3a: 09 00 nop - 3c: 09 00 nop - 3e: 09 00 nop -*/ - -int -unw_is_signal_frame (unw_cursor_t *cursor) -{ -#ifdef __linux__ - struct cursor *c = (struct cursor *) cursor; - unw_word_t w0, ip; - unw_addr_space_t as; - unw_accessors_t *a; - void *arg; - int ret; - - as = c->dwarf.as; - a = unw_get_accessors_int (as); - arg = c->dwarf.as_arg; - - ip = c->dwarf.ip; - - ret = (*a->access_mem) (as, ip, &w0, 0, arg); - if (ret < 0) - return ret; - - if (w0 != 0xc3109305) - return 0; - - ret = (*a->access_mem) (as, ip+4, &w0, 0, arg); - if (ret < 0) - return ret; - - if (w0 != 0x200b200b) - return 0; - - ret = (*a->access_mem) (as, ip+8, &w0, 0, arg); - if (ret < 0) - return ret; - - if (w0 != 0x200b200b) - return 0; - - ret = (*a->access_mem) (as, ip+12, &w0, 0, arg); - if (ret < 0) - return ret; - - if (w0 == 0x0077200b) - return 1; /* non-RT */ - else if (w0 == 0x00ad200b) - return 2; /* RT */ - - /* does not look like a signal frame */ - return 0; - -#else - return -UNW_ENOINFO; -#endif -} diff --git a/src/pal/src/libunwind/src/sh/Greg_states_iterate.c b/src/pal/src/libunwind/src/sh/Greg_states_iterate.c deleted file mode 100644 index a17dc1b56..000000000 --- a/src/pal/src/libunwind/src/sh/Greg_states_iterate.c +++ /dev/null @@ -1,37 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (c) 2002-2003 Hewlett-Packard Development Company, L.P. - Contributed by David Mosberger-Tang - - Modified for x86_64 by Max Asbock - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" - -int -unw_reg_states_iterate (unw_cursor_t *cursor, - unw_reg_states_callback cb, void *token) -{ - struct cursor *c = (struct cursor *) cursor; - - return dwarf_reg_states_iterate (&c->dwarf, cb, token); -} diff --git a/src/pal/src/libunwind/src/sh/Gregs.c b/src/pal/src/libunwind/src/sh/Gregs.c deleted file mode 100644 index 7d8e8e93d..000000000 --- a/src/pal/src/libunwind/src/sh/Gregs.c +++ /dev/null @@ -1,81 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - Copyright (C) 2012 Tommi Rantala - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" - -HIDDEN int -tdep_access_reg (struct cursor *c, unw_regnum_t reg, unw_word_t *valp, - int write) -{ - dwarf_loc_t loc = DWARF_NULL_LOC; - - switch (reg) - { - case UNW_SH_PC: - if (write) - c->dwarf.ip = *valp; /* update the IP cache */ - case UNW_SH_R0: - case UNW_SH_R1: - case UNW_SH_R2: - case UNW_SH_R3: - case UNW_SH_R4: - case UNW_SH_R5: - case UNW_SH_R6: - case UNW_SH_R7: - case UNW_SH_R8: - case UNW_SH_R9: - case UNW_SH_R10: - case UNW_SH_R11: - case UNW_SH_R12: - case UNW_SH_R13: - case UNW_SH_R14: - case UNW_SH_PR: - loc = c->dwarf.loc[reg]; - break; - - case UNW_SH_R15: - if (write) - return -UNW_EREADONLYREG; - *valp = c->dwarf.cfa; - return 0; - - default: - Debug (1, "bad register number %u\n", reg); - return -UNW_EBADREG; - } - - if (write) - return dwarf_put (&c->dwarf, loc, *valp); - else - return dwarf_get (&c->dwarf, loc, valp); -} - -HIDDEN int -tdep_access_fpreg (struct cursor *c, unw_regnum_t reg, unw_fpreg_t *valp, - int write) -{ - Debug (1, "bad register number %u\n", reg); - return -UNW_EBADREG; -} diff --git a/src/pal/src/libunwind/src/sh/Gresume.c b/src/pal/src/libunwind/src/sh/Gresume.c deleted file mode 100644 index a263c9271..000000000 --- a/src/pal/src/libunwind/src/sh/Gresume.c +++ /dev/null @@ -1,165 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - Copyright 2011 Linaro Limited - Copyright (C) 2012 Tommi Rantala - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" -#include "offsets.h" - -#ifndef UNW_REMOTE_ONLY - -HIDDEN inline int -sh_local_resume (unw_addr_space_t as, unw_cursor_t *cursor, void *arg) -{ -#ifdef __linux__ - struct cursor *c = (struct cursor *) cursor; - unw_tdep_context_t *uc = c->dwarf.as_arg; - - if (c->sigcontext_format == SH_SCF_NONE) - { - /* Since there are no signals involved here we restore the non scratch - registers only. */ - unsigned long regs[8]; - regs[0] = uc->uc_mcontext.gregs[8]; - regs[1] = uc->uc_mcontext.gregs[9]; - regs[2] = uc->uc_mcontext.gregs[10]; - regs[3] = uc->uc_mcontext.gregs[11]; - regs[4] = uc->uc_mcontext.gregs[12]; - regs[5] = uc->uc_mcontext.gregs[13]; - regs[6] = uc->uc_mcontext.gregs[14]; - regs[7] = uc->uc_mcontext.gregs[15]; - unsigned long pc = uc->uc_mcontext.pr; - - struct regs_overlay { - char x[sizeof(regs)]; - }; - - asm volatile ( - "mov.l @%0+, r8\n" - "mov.l @%0+, r9\n" - "mov.l @%0+, r10\n" - "mov.l @%0+, r11\n" - "mov.l @%0+, r12\n" - "mov.l @%0+, r13\n" - "mov.l @%0+, r14\n" - "mov.l @%0, r15\n" - "lds %1, pr\n" - "rts\n" - "nop\n" - : - : "r" (regs), - "r" (pc), - "m" (*(struct regs_overlay *)regs) - ); - } - else - { - /* In case a signal frame is involved, we're using its trampoline which - calls sigreturn. */ - struct sigcontext *sc = (struct sigcontext *) c->sigcontext_addr; - sc->sc_regs[0] = uc->uc_mcontext.gregs[0]; - sc->sc_regs[1] = uc->uc_mcontext.gregs[1]; - sc->sc_regs[2] = uc->uc_mcontext.gregs[2]; - sc->sc_regs[3] = uc->uc_mcontext.gregs[3]; - sc->sc_regs[4] = uc->uc_mcontext.gregs[4]; - sc->sc_regs[5] = uc->uc_mcontext.gregs[5]; - sc->sc_regs[6] = uc->uc_mcontext.gregs[6]; - sc->sc_regs[7] = uc->uc_mcontext.gregs[7]; - sc->sc_regs[8] = uc->uc_mcontext.gregs[8]; - sc->sc_regs[9] = uc->uc_mcontext.gregs[9]; - sc->sc_regs[10] = uc->uc_mcontext.gregs[10]; - sc->sc_regs[11] = uc->uc_mcontext.gregs[11]; - sc->sc_regs[12] = uc->uc_mcontext.gregs[12]; - sc->sc_regs[13] = uc->uc_mcontext.gregs[13]; - sc->sc_regs[14] = uc->uc_mcontext.gregs[14]; - sc->sc_regs[15] = uc->uc_mcontext.gregs[15]; - sc->sc_pc = uc->uc_mcontext.pc; - sc->sc_pr = uc->uc_mcontext.pr; - - /* Set the SP and the PC in order to continue execution at the modified - trampoline which restores the signal mask and the registers. */ - asm __volatile__ ( - "mov %0, r15\n" - "lds %1, pr\n" - "rts\n" - "nop\n" - : - : "r" (c->sigcontext_sp), - "r" (c->sigcontext_pc) - ); - } - unreachable(); -#endif - return -UNW_EINVAL; -} - -#endif /* !UNW_REMOTE_ONLY */ - -static inline void -establish_machine_state (struct cursor *c) -{ - unw_addr_space_t as = c->dwarf.as; - void *arg = c->dwarf.as_arg; - unw_fpreg_t fpval; - unw_word_t val; - int reg; - - Debug (8, "copying out cursor state\n"); - - for (reg = 0; reg <= UNW_REG_LAST; ++reg) - { - Debug (16, "copying %s %d\n", unw_regname (reg), reg); - if (unw_is_fpreg (reg)) - { - if (tdep_access_fpreg (c, reg, &fpval, 0) >= 0) - as->acc.access_fpreg (as, reg, &fpval, 1, arg); - } - else - { - if (tdep_access_reg (c, reg, &val, 0) >= 0) - as->acc.access_reg (as, reg, &val, 1, arg); - } - } -} - -int -unw_resume (unw_cursor_t *cursor) -{ - struct cursor *c = (struct cursor *) cursor; - - Debug (1, "(cursor=%p)\n", c); - - if (!c->dwarf.ip) - { - /* This can happen easily when the frame-chain gets truncated - due to bad or missing unwind-info. */ - Debug (1, "refusing to resume execution at address 0\n"); - return -UNW_EINVAL; - } - - establish_machine_state (c); - - return (*c->dwarf.as->acc.resume) (c->dwarf.as, (unw_cursor_t *) c, - c->dwarf.as_arg); -} diff --git a/src/pal/src/libunwind/src/sh/Gstep.c b/src/pal/src/libunwind/src/sh/Gstep.c deleted file mode 100644 index 60d7ec2ba..000000000 --- a/src/pal/src/libunwind/src/sh/Gstep.c +++ /dev/null @@ -1,117 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - Copyright 2011 Linaro Limited - Copyright (C) 2012 Tommi Rantala - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" -#include "offsets.h" - -static int -sh_handle_signal_frame (unw_cursor_t *cursor) -{ - struct cursor *c = (struct cursor *) cursor; - int ret; - unw_word_t sc_addr, sp, sp_addr = c->dwarf.cfa; - struct dwarf_loc sp_loc = DWARF_LOC (sp_addr, 0); - - if ((ret = dwarf_get (&c->dwarf, sp_loc, &sp)) < 0) - return -UNW_EUNSPEC; - - ret = unw_is_signal_frame (cursor); - Debug(1, "unw_is_signal_frame()=%d\n", ret); - - /* Save the SP and PC to be able to return execution at this point - later in time (unw_resume). */ - c->sigcontext_sp = c->dwarf.cfa; - c->sigcontext_pc = c->dwarf.ip; - - if (ret == 1) - { - /* Handle non-RT signal frame. */ - c->sigcontext_format = SH_SCF_LINUX_SIGFRAME; - sc_addr = sp_addr; - } - else if (ret == 2) - { - /* Handle RT signal frame. */ - c->sigcontext_format = SH_SCF_LINUX_RT_SIGFRAME; - sc_addr = sp_addr + sizeof (siginfo_t) + LINUX_UC_MCONTEXT_OFF; - } - else - return -UNW_EUNSPEC; - - c->sigcontext_addr = sc_addr; - - /* Update the dwarf cursor. - Set the location of the registers to the corresponding addresses of the - uc_mcontext / sigcontext structure contents. */ - c->dwarf.loc[UNW_SH_R0] = DWARF_LOC (sc_addr + LINUX_SC_R0_OFF, 0); - c->dwarf.loc[UNW_SH_R1] = DWARF_LOC (sc_addr + LINUX_SC_R1_OFF, 0); - c->dwarf.loc[UNW_SH_R2] = DWARF_LOC (sc_addr + LINUX_SC_R2_OFF, 0); - c->dwarf.loc[UNW_SH_R3] = DWARF_LOC (sc_addr + LINUX_SC_R3_OFF, 0); - c->dwarf.loc[UNW_SH_R4] = DWARF_LOC (sc_addr + LINUX_SC_R4_OFF, 0); - c->dwarf.loc[UNW_SH_R5] = DWARF_LOC (sc_addr + LINUX_SC_R5_OFF, 0); - c->dwarf.loc[UNW_SH_R6] = DWARF_LOC (sc_addr + LINUX_SC_R6_OFF, 0); - c->dwarf.loc[UNW_SH_R7] = DWARF_LOC (sc_addr + LINUX_SC_R7_OFF, 0); - c->dwarf.loc[UNW_SH_R8] = DWARF_LOC (sc_addr + LINUX_SC_R8_OFF, 0); - c->dwarf.loc[UNW_SH_R9] = DWARF_LOC (sc_addr + LINUX_SC_R9_OFF, 0); - c->dwarf.loc[UNW_SH_R10] = DWARF_LOC (sc_addr + LINUX_SC_R10_OFF, 0); - c->dwarf.loc[UNW_SH_R11] = DWARF_LOC (sc_addr + LINUX_SC_R11_OFF, 0); - c->dwarf.loc[UNW_SH_R12] = DWARF_LOC (sc_addr + LINUX_SC_R12_OFF, 0); - c->dwarf.loc[UNW_SH_R13] = DWARF_LOC (sc_addr + LINUX_SC_R13_OFF, 0); - c->dwarf.loc[UNW_SH_R14] = DWARF_LOC (sc_addr + LINUX_SC_R14_OFF, 0); - c->dwarf.loc[UNW_SH_R15] = DWARF_LOC (sc_addr + LINUX_SC_R15_OFF, 0); - c->dwarf.loc[UNW_SH_PR] = DWARF_LOC (sc_addr + LINUX_SC_PR_OFF, 0); - c->dwarf.loc[UNW_SH_PC] = DWARF_LOC (sc_addr + LINUX_SC_PC_OFF, 0); - - /* Set SP/CFA and PC/IP. */ - dwarf_get (&c->dwarf, c->dwarf.loc[UNW_SH_R15], &c->dwarf.cfa); - dwarf_get (&c->dwarf, c->dwarf.loc[UNW_SH_PC], &c->dwarf.ip); - - c->dwarf.pi_valid = 0; - - return 1; -} - -int -unw_step (unw_cursor_t *cursor) -{ - struct cursor *c = (struct cursor *) cursor; - int ret; - - Debug (1, "(cursor=%p)\n", c); - - if (unw_is_signal_frame (cursor) > 0) - return sh_handle_signal_frame (cursor); - - ret = dwarf_step (&c->dwarf); - - if (unlikely (ret == -UNW_ESTOPUNWIND)) - return ret; - - if (unlikely (ret < 0)) - return 0; - - return (c->dwarf.ip == 0) ? 0 : 1; -} diff --git a/src/pal/src/libunwind/src/sh/Lapply_reg_state.c b/src/pal/src/libunwind/src/sh/Lapply_reg_state.c deleted file mode 100644 index 7ebada480..000000000 --- a/src/pal/src/libunwind/src/sh/Lapply_reg_state.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gapply_reg_state.c" -#endif diff --git a/src/pal/src/libunwind/src/sh/Lcreate_addr_space.c b/src/pal/src/libunwind/src/sh/Lcreate_addr_space.c deleted file mode 100644 index 0f2dc6be9..000000000 --- a/src/pal/src/libunwind/src/sh/Lcreate_addr_space.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gcreate_addr_space.c" -#endif diff --git a/src/pal/src/libunwind/src/sh/Lget_proc_info.c b/src/pal/src/libunwind/src/sh/Lget_proc_info.c deleted file mode 100644 index 69028b019..000000000 --- a/src/pal/src/libunwind/src/sh/Lget_proc_info.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gget_proc_info.c" -#endif diff --git a/src/pal/src/libunwind/src/sh/Lget_save_loc.c b/src/pal/src/libunwind/src/sh/Lget_save_loc.c deleted file mode 100644 index 9ea048a90..000000000 --- a/src/pal/src/libunwind/src/sh/Lget_save_loc.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gget_save_loc.c" -#endif diff --git a/src/pal/src/libunwind/src/sh/Lglobal.c b/src/pal/src/libunwind/src/sh/Lglobal.c deleted file mode 100644 index 6d7b489e1..000000000 --- a/src/pal/src/libunwind/src/sh/Lglobal.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gglobal.c" -#endif diff --git a/src/pal/src/libunwind/src/sh/Linit.c b/src/pal/src/libunwind/src/sh/Linit.c deleted file mode 100644 index e9abfdd46..000000000 --- a/src/pal/src/libunwind/src/sh/Linit.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Ginit.c" -#endif diff --git a/src/pal/src/libunwind/src/sh/Linit_local.c b/src/pal/src/libunwind/src/sh/Linit_local.c deleted file mode 100644 index 68a1687e8..000000000 --- a/src/pal/src/libunwind/src/sh/Linit_local.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Ginit_local.c" -#endif diff --git a/src/pal/src/libunwind/src/sh/Linit_remote.c b/src/pal/src/libunwind/src/sh/Linit_remote.c deleted file mode 100644 index 58cb04ab7..000000000 --- a/src/pal/src/libunwind/src/sh/Linit_remote.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Ginit_remote.c" -#endif diff --git a/src/pal/src/libunwind/src/sh/Lis_signal_frame.c b/src/pal/src/libunwind/src/sh/Lis_signal_frame.c deleted file mode 100644 index b9a7c4f51..000000000 --- a/src/pal/src/libunwind/src/sh/Lis_signal_frame.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gis_signal_frame.c" -#endif diff --git a/src/pal/src/libunwind/src/sh/Lreg_states_iterate.c b/src/pal/src/libunwind/src/sh/Lreg_states_iterate.c deleted file mode 100644 index f1eb1e79d..000000000 --- a/src/pal/src/libunwind/src/sh/Lreg_states_iterate.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Greg_states_iterate.c" -#endif diff --git a/src/pal/src/libunwind/src/sh/Lregs.c b/src/pal/src/libunwind/src/sh/Lregs.c deleted file mode 100644 index 2c9c75cd7..000000000 --- a/src/pal/src/libunwind/src/sh/Lregs.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gregs.c" -#endif diff --git a/src/pal/src/libunwind/src/sh/Lresume.c b/src/pal/src/libunwind/src/sh/Lresume.c deleted file mode 100644 index 41a8cf003..000000000 --- a/src/pal/src/libunwind/src/sh/Lresume.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gresume.c" -#endif diff --git a/src/pal/src/libunwind/src/sh/Lstep.c b/src/pal/src/libunwind/src/sh/Lstep.c deleted file mode 100644 index c1ac3c754..000000000 --- a/src/pal/src/libunwind/src/sh/Lstep.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gstep.c" -#endif diff --git a/src/pal/src/libunwind/src/sh/gen-offsets.c b/src/pal/src/libunwind/src/sh/gen-offsets.c deleted file mode 100644 index 16695a648..000000000 --- a/src/pal/src/libunwind/src/sh/gen-offsets.c +++ /dev/null @@ -1,51 +0,0 @@ -#include -#include -#include -#include - -#define UC(N,X) \ - printf ("#define LINUX_UC_" N "_OFF\t0x%X\n", offsetof (ucontext_t, X)) - -#define SC(N,X) \ - printf ("#define LINUX_SC_" N "_OFF\t0x%X\n", offsetof (struct sigcontext, X)) - -int -main (void) -{ - printf ( -"/* Linux-specific definitions: */\n\n" - -"/* Define various structure offsets to simplify cross-compilation. */\n\n" - -"/* Offsets for SH Linux \"ucontext_t\": */\n\n"); - - UC ("FLAGS", uc_flags); - UC ("LINK", uc_link); - UC ("STACK", uc_stack); - UC ("MCONTEXT", uc_mcontext); - UC ("SIGMASK", uc_sigmask); - - printf ("\n/* Offsets for SH Linux \"struct sigcontext\": */\n\n"); - - SC ("R0", sc_regs[0]); - SC ("R1", sc_regs[1]); - SC ("R2", sc_regs[2]); - SC ("R3", sc_regs[3]); - SC ("R4", sc_regs[4]); - SC ("R5", sc_regs[5]); - SC ("R6", sc_regs[6]); - SC ("R7", sc_regs[7]); - SC ("R8", sc_regs[8]); - SC ("R9", sc_regs[9]); - SC ("R10", sc_regs[10]); - SC ("R11", sc_regs[11]); - SC ("R12", sc_regs[12]); - SC ("R13", sc_regs[13]); - SC ("R14", sc_regs[14]); - SC ("R15", sc_regs[15]); - - SC ("PC", sc_pc); - SC ("PR", sc_pr); - - return 0; -} diff --git a/src/pal/src/libunwind/src/sh/init.h b/src/pal/src/libunwind/src/sh/init.h deleted file mode 100644 index 36713fe89..000000000 --- a/src/pal/src/libunwind/src/sh/init.h +++ /dev/null @@ -1,73 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2012 Tommi Rantala - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" - -static inline int -common_init (struct cursor *c, unsigned use_prev_instr) -{ - int ret; - - c->dwarf.loc[UNW_SH_R0] = DWARF_REG_LOC (&c->dwarf, UNW_SH_R0); - c->dwarf.loc[UNW_SH_R1] = DWARF_REG_LOC (&c->dwarf, UNW_SH_R1); - c->dwarf.loc[UNW_SH_R2] = DWARF_REG_LOC (&c->dwarf, UNW_SH_R2); - c->dwarf.loc[UNW_SH_R3] = DWARF_REG_LOC (&c->dwarf, UNW_SH_R3); - c->dwarf.loc[UNW_SH_R4] = DWARF_REG_LOC (&c->dwarf, UNW_SH_R4); - c->dwarf.loc[UNW_SH_R5] = DWARF_REG_LOC (&c->dwarf, UNW_SH_R5); - c->dwarf.loc[UNW_SH_R6] = DWARF_REG_LOC (&c->dwarf, UNW_SH_R6); - c->dwarf.loc[UNW_SH_R7] = DWARF_REG_LOC (&c->dwarf, UNW_SH_R7); - c->dwarf.loc[UNW_SH_R8] = DWARF_REG_LOC (&c->dwarf, UNW_SH_R8); - c->dwarf.loc[UNW_SH_R9] = DWARF_REG_LOC (&c->dwarf, UNW_SH_R9); - c->dwarf.loc[UNW_SH_R10] = DWARF_REG_LOC (&c->dwarf, UNW_SH_R10); - c->dwarf.loc[UNW_SH_R11] = DWARF_REG_LOC (&c->dwarf, UNW_SH_R11); - c->dwarf.loc[UNW_SH_R12] = DWARF_REG_LOC (&c->dwarf, UNW_SH_R12); - c->dwarf.loc[UNW_SH_R13] = DWARF_REG_LOC (&c->dwarf, UNW_SH_R13); - c->dwarf.loc[UNW_SH_R14] = DWARF_REG_LOC (&c->dwarf, UNW_SH_R14); - c->dwarf.loc[UNW_SH_R15] = DWARF_REG_LOC (&c->dwarf, UNW_SH_R15); - c->dwarf.loc[UNW_SH_PC] = DWARF_REG_LOC (&c->dwarf, UNW_SH_PC); - c->dwarf.loc[UNW_SH_PR] = DWARF_REG_LOC (&c->dwarf, UNW_SH_PR); - - ret = dwarf_get (&c->dwarf, c->dwarf.loc[UNW_SH_PC], &c->dwarf.ip); - if (ret < 0) - return ret; - - ret = dwarf_get (&c->dwarf, c->dwarf.loc[UNW_TDEP_SP], &c->dwarf.cfa); - if (ret < 0) - return ret; - - c->sigcontext_format = SH_SCF_NONE; - c->sigcontext_addr = 0; - c->sigcontext_sp = 0; - c->sigcontext_pc = 0; - - c->dwarf.args_size = 0; - c->dwarf.stash_frames = 0; - c->dwarf.use_prev_instr = use_prev_instr; - c->dwarf.pi_valid = 0; - c->dwarf.pi_is_dynamic = 0; - c->dwarf.hint = 0; - c->dwarf.prev_rs = 0; - - return 0; -} diff --git a/src/pal/src/libunwind/src/sh/is_fpreg.c b/src/pal/src/libunwind/src/sh/is_fpreg.c deleted file mode 100644 index de0934019..000000000 --- a/src/pal/src/libunwind/src/sh/is_fpreg.c +++ /dev/null @@ -1,32 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - -This file is part of libunwind. - -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. */ - -#include "libunwind_i.h" - -int -unw_is_fpreg (int regnum) -{ - /* FIXME: Support FP. */ - return 0; -} diff --git a/src/pal/src/libunwind/src/sh/offsets.h b/src/pal/src/libunwind/src/sh/offsets.h deleted file mode 100644 index b02d8aee1..000000000 --- a/src/pal/src/libunwind/src/sh/offsets.h +++ /dev/null @@ -1,32 +0,0 @@ -/* Linux-specific definitions: */ - -/* Define various structure offsets to simplify cross-compilation. */ - -/* Offsets for SH Linux "ucontext_t": */ - -#define LINUX_UC_FLAGS_OFF 0x0 -#define LINUX_UC_LINK_OFF 0x4 -#define LINUX_UC_STACK_OFF 0x8 -#define LINUX_UC_MCONTEXT_OFF 0x14 -#define LINUX_UC_SIGMASK_OFF 0xFC - -/* Offsets for SH Linux "struct sigcontext": */ - -#define LINUX_SC_R0_OFF 0x4 -#define LINUX_SC_R1_OFF 0x8 -#define LINUX_SC_R2_OFF 0xC -#define LINUX_SC_R3_OFF 0x10 -#define LINUX_SC_R4_OFF 0x14 -#define LINUX_SC_R5_OFF 0x18 -#define LINUX_SC_R6_OFF 0x1C -#define LINUX_SC_R7_OFF 0x20 -#define LINUX_SC_R8_OFF 0x24 -#define LINUX_SC_R9_OFF 0x28 -#define LINUX_SC_R10_OFF 0x2C -#define LINUX_SC_R11_OFF 0x30 -#define LINUX_SC_R12_OFF 0x34 -#define LINUX_SC_R13_OFF 0x38 -#define LINUX_SC_R14_OFF 0x3C -#define LINUX_SC_R15_OFF 0x40 -#define LINUX_SC_PC_OFF 0x44 -#define LINUX_SC_PR_OFF 0x48 diff --git a/src/pal/src/libunwind/src/sh/regname.c b/src/pal/src/libunwind/src/sh/regname.c deleted file mode 100644 index b52925b4d..000000000 --- a/src/pal/src/libunwind/src/sh/regname.c +++ /dev/null @@ -1,56 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2012 Tommi Rantala - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" - -static const char *const regname[] = - { - [UNW_SH_R0] = "r0", - [UNW_SH_R1] = "r1", - [UNW_SH_R2] = "r2", - [UNW_SH_R3] = "r3", - [UNW_SH_R4] = "r4", - [UNW_SH_R5] = "r5", - [UNW_SH_R6] = "r6", - [UNW_SH_R7] = "r7", - [UNW_SH_R8] = "r8", - [UNW_SH_R9] = "r9", - [UNW_SH_R10] = "r10", - [UNW_SH_R11] = "r11", - [UNW_SH_R12] = "r12", - [UNW_SH_R13] = "r13", - [UNW_SH_R14] = "r14", - [UNW_SH_R15] = "r15", - [UNW_SH_PC] = "pc", - [UNW_SH_PR] = "pr", - }; - -const char * -unw_regname (unw_regnum_t reg) -{ - if (reg < (unw_regnum_t) ARRAY_SIZE (regname) && regname[reg] != NULL) - return regname[reg]; - else - return "???"; -} diff --git a/src/pal/src/libunwind/src/sh/siglongjmp.S b/src/pal/src/libunwind/src/sh/siglongjmp.S deleted file mode 100644 index 9ca53d124..000000000 --- a/src/pal/src/libunwind/src/sh/siglongjmp.S +++ /dev/null @@ -1,8 +0,0 @@ - /* Dummy implementation for now. */ - - .globl _UI_siglongjmp_cont - .globl _UI_longjmp_cont - -_UI_siglongjmp_cont: -_UI_longjmp_cont: - rts diff --git a/src/pal/src/libunwind/src/sh/unwind_i.h b/src/pal/src/libunwind/src/sh/unwind_i.h deleted file mode 100644 index 3066d8463..000000000 --- a/src/pal/src/libunwind/src/sh/unwind_i.h +++ /dev/null @@ -1,40 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2012 Tommi Rantala - -This file is part of libunwind. - -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. */ - -#ifndef unwind_i_h -#define unwind_i_h - -#include - -#include "libunwind_i.h" - -#define sh_lock UNW_OBJ(lock) -#define sh_local_resume UNW_OBJ(local_resume) -#define sh_local_addr_space_init UNW_OBJ(local_addr_space_init) - -extern void sh_local_addr_space_init (void); -extern int sh_local_resume (unw_addr_space_t as, unw_cursor_t *cursor, - void *arg); - -#endif /* unwind_i_h */ diff --git a/src/pal/src/libunwind/src/tilegx/Gapply_reg_state.c b/src/pal/src/libunwind/src/tilegx/Gapply_reg_state.c deleted file mode 100644 index 82f056da6..000000000 --- a/src/pal/src/libunwind/src/tilegx/Gapply_reg_state.c +++ /dev/null @@ -1,37 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (c) 2002-2003 Hewlett-Packard Development Company, L.P. - Contributed by David Mosberger-Tang - - Modified for x86_64 by Max Asbock - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" - -int -unw_apply_reg_state (unw_cursor_t *cursor, - void *reg_states_data) -{ - struct cursor *c = (struct cursor *) cursor; - - return dwarf_apply_reg_state (&c->dwarf, (dwarf_reg_state_t *)reg_states_data); -} diff --git a/src/pal/src/libunwind/src/tilegx/Gcreate_addr_space.c b/src/pal/src/libunwind/src/tilegx/Gcreate_addr_space.c deleted file mode 100644 index 39acdc2c3..000000000 --- a/src/pal/src/libunwind/src/tilegx/Gcreate_addr_space.c +++ /dev/null @@ -1,65 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - Copyright (C) 2014 Tilera Corp. - -This file is part of libunwind. - -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. */ - -#include - -#include "unwind_i.h" - -unw_addr_space_t -unw_create_addr_space (unw_accessors_t *a, int byte_order) -{ -#ifdef UNW_LOCAL_ONLY - return NULL; -#else - unw_addr_space_t as = malloc (sizeof (*as)); - - if (!as) - return NULL; - - memset (as, 0, sizeof (*as)); - - as->acc = *a; - - /* - * Tilegx supports only big or little-endian, not weird stuff like - * PDP_ENDIAN. - */ - if (byte_order != 0 - && byte_order != __LITTLE_ENDIAN - && byte_order != __BIG_ENDIAN) - return NULL; - - if (byte_order == 0) - /* use host default: */ - as->big_endian = (__BYTE_ORDER == __BIG_ENDIAN); - else - as->big_endian = (byte_order == __BIG_ENDIAN); - - as->abi = UNW_TILEGX_ABI_N64; - as->addr_size = 8; - - return as; -#endif -} diff --git a/src/pal/src/libunwind/src/tilegx/Gget_proc_info.c b/src/pal/src/libunwind/src/tilegx/Gget_proc_info.c deleted file mode 100644 index 3a158da2d..000000000 --- a/src/pal/src/libunwind/src/tilegx/Gget_proc_info.c +++ /dev/null @@ -1,48 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - Copyright (C) 2014 Tilera Corp. - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" - -int -unw_get_proc_info (unw_cursor_t *cursor, unw_proc_info_t *pi) -{ - struct cursor *c = (struct cursor *) cursor; - int ret; - - ret = dwarf_make_proc_info (&c->dwarf); - - if (ret < 0) - { - /* On Tilegx, some routines i.e. _start() etc has no dwarf info. - Just simply mark the end of the frames. */ - memset (pi, 0, sizeof (*pi)); - pi->start_ip = c->dwarf.ip; - pi->end_ip = c->dwarf.ip + 1; - return 0; - } - - *pi = c->dwarf.pi; - return 0; -} diff --git a/src/pal/src/libunwind/src/tilegx/Gget_save_loc.c b/src/pal/src/libunwind/src/tilegx/Gget_save_loc.c deleted file mode 100644 index fcf069789..000000000 --- a/src/pal/src/libunwind/src/tilegx/Gget_save_loc.c +++ /dev/null @@ -1,62 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - Copyright (C) 2014 Tilera Corp. - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" - -int -unw_get_save_loc (unw_cursor_t *cursor, int reg, unw_save_loc_t *sloc) -{ - struct cursor *c = (struct cursor *) cursor; - dwarf_loc_t loc; - - loc = DWARF_NULL_LOC; /* default to "not saved" */ - - if (reg <= UNW_TILEGX_R55) - loc = c->dwarf.loc[reg - UNW_TILEGX_R0]; - else - printf("\nInvalid register!"); - - memset (sloc, 0, sizeof (*sloc)); - - if (DWARF_IS_NULL_LOC (loc)) - { - sloc->type = UNW_SLT_NONE; - return 0; - } - -#if !defined(UNW_LOCAL_ONLY) - if (DWARF_IS_REG_LOC (loc)) - { - sloc->type = UNW_SLT_REG; - sloc->u.regnum = DWARF_GET_LOC (loc); - } - else -#endif - { - sloc->type = UNW_SLT_MEMORY; - sloc->u.addr = DWARF_GET_LOC (loc); - } - return 0; -} diff --git a/src/pal/src/libunwind/src/tilegx/Gglobal.c b/src/pal/src/libunwind/src/tilegx/Gglobal.c deleted file mode 100644 index e18f50a50..000000000 --- a/src/pal/src/libunwind/src/tilegx/Gglobal.c +++ /dev/null @@ -1,64 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - Copyright (C) 2014 Tilera Corp. - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" -#include "dwarf_i.h" - -__attribute__((weak)) -pthread_mutex_t tilegx_lock = PTHREAD_MUTEX_INITIALIZER; -HIDDEN int tdep_init_done; - -HIDDEN const uint8_t dwarf_to_unw_regnum_map[] = - { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, - 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, - 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, - 48, 49, 50, 51, 52, 53, 54, 55 - }; - -HIDDEN void -tdep_init (void) -{ - intrmask_t saved_mask; - - sigfillset (&unwi_full_mask); - - lock_acquire (&tilegx_lock, saved_mask); - - if (tdep_init_done) - /* another thread else beat us to it... */ - goto out; - - mi_init (); - dwarf_init (); - -#ifndef UNW_REMOTE_ONLY - tilegx_local_addr_space_init (); -#endif - tdep_init_done = 1; /* signal that we're initialized... */ - - out: - lock_release (&tilegx_lock, saved_mask); -} diff --git a/src/pal/src/libunwind/src/tilegx/Ginit.c b/src/pal/src/libunwind/src/tilegx/Ginit.c deleted file mode 100644 index 7564a558b..000000000 --- a/src/pal/src/libunwind/src/tilegx/Ginit.c +++ /dev/null @@ -1,167 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - Copyright (C) 2014 Tilera Corp. - -This file is part of libunwind. - -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. */ - -#include -#include - -#include "unwind_i.h" - -#ifdef UNW_REMOTE_ONLY - -/* unw_local_addr_space is a NULL pointer in this case. */ -unw_addr_space_t unw_local_addr_space; - -#else /* !UNW_REMOTE_ONLY */ - -static struct unw_addr_space local_addr_space; - -unw_addr_space_t unw_local_addr_space = &local_addr_space; - -/* Return the address of the 64-bit slot in UC for REG (even for o32, - where registers are 32-bit, the slots are still 64-bit). */ - -static inline void * -uc_addr (ucontext_t *uc, int reg) -{ - if (reg >= UNW_TILEGX_R0 && reg < UNW_TILEGX_R0 + 56) - return &uc->uc_mcontext.gregs[reg - UNW_TILEGX_R0]; - else if (reg == UNW_TILEGX_PC) - return &uc->uc_mcontext.pc; - else - return NULL; -} - -# ifdef UNW_LOCAL_ONLY - -HIDDEN void * -tdep_uc_addr (ucontext_t *uc, int reg) -{ - char *addr = uc_addr (uc, reg); - return addr; -} - -# endif /* UNW_LOCAL_ONLY */ - -HIDDEN unw_dyn_info_list_t _U_dyn_info_list; - -/* XXX fix me: there is currently no way to locate the dyn-info list - by a remote unwinder. On ia64, this is done via a special - unwind-table entry. Perhaps something similar can be done with - DWARF2 unwind info. */ - -static void -put_unwind_info (unw_addr_space_t as, unw_proc_info_t *proc_info, void *arg) -{ - /* it's a no-op */ -} - -static int -get_dyn_info_list_addr (unw_addr_space_t as, unw_word_t *dyn_info_list_addr, - void *arg) -{ - *dyn_info_list_addr = (unw_word_t) (intptr_t) &_U_dyn_info_list; - return 0; -} - -static int -access_mem (unw_addr_space_t as, unw_word_t addr, unw_word_t *val, int write, - void *arg) -{ - if ((long long)addr & (sizeof(unw_word_t) - 1)) - return 0; - - if (write) - { - Debug (16, "mem[%llx] <- %llx\n", (long long) addr, (long long) *val); - *(unw_word_t *) (intptr_t) addr = *val; - } - else - { - *val = *(unw_word_t *) (intptr_t) addr; - Debug (16, "mem[%llx] -> %llx\n", (long long) addr, (long long) *val); - } - return 0; -} - -static int -access_reg (unw_addr_space_t as, unw_regnum_t reg, unw_word_t *val, int write, - void *arg) -{ - unw_word_t *addr; - ucontext_t *uc = arg; - - if (unw_is_fpreg (reg)) - goto badreg; - - Debug (16, "reg = %s\n", unw_regname (reg)); - if (!(addr = uc_addr (uc, reg))) - goto badreg; - - if (write) - { - *(unw_word_t *) (intptr_t) addr = (tilegx_reg_t) *val; - Debug (12, "%s <- %llx\n", unw_regname (reg), (long long) *val); - } - else - { - *val = (tilegx_reg_t) *(unw_word_t *) (intptr_t) addr; - Debug (12, "%s -> %llx\n", unw_regname (reg), (long long) *val); - } - return 0; - - badreg: - Debug (1, "bad register number %u\n", reg); - return -UNW_EBADREG; -} - -static int -get_static_proc_name (unw_addr_space_t as, unw_word_t ip, - char *buf, size_t buf_len, unw_word_t *offp, - void *arg) -{ - return elf_w (get_proc_name) (as, getpid (), ip, buf, buf_len, offp); -} - -__attribute__((weak)) void -tilegx_local_addr_space_init (void) -{ - memset (&local_addr_space, 0, sizeof (local_addr_space)); - local_addr_space.big_endian = (__BYTE_ORDER == __BIG_ENDIAN); - - local_addr_space.abi = UNW_TILEGX_ABI_N64; - local_addr_space.addr_size = sizeof (void *); - local_addr_space.caching_policy = UNWI_DEFAULT_CACHING_POLICY; - local_addr_space.acc.find_proc_info = dwarf_find_proc_info; - local_addr_space.acc.put_unwind_info = put_unwind_info; - local_addr_space.acc.get_dyn_info_list_addr = get_dyn_info_list_addr; - local_addr_space.acc.access_mem = access_mem; - local_addr_space.acc.access_reg = access_reg; - local_addr_space.acc.access_fpreg = NULL; - local_addr_space.acc.resume = tilegx_local_resume; - local_addr_space.acc.get_proc_name = get_static_proc_name; - unw_flush_cache (&local_addr_space, 0, 0); -} - -#endif /* !UNW_REMOTE_ONLY */ diff --git a/src/pal/src/libunwind/src/tilegx/Ginit_local.c b/src/pal/src/libunwind/src/tilegx/Ginit_local.c deleted file mode 100644 index 31a716df3..000000000 --- a/src/pal/src/libunwind/src/tilegx/Ginit_local.c +++ /dev/null @@ -1,80 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - Copyright (C) 2014 Tilera Corp. - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" -#include "init.h" - -#ifdef UNW_REMOTE_ONLY - -int -unw_init_local (unw_cursor_t *cursor, ucontext_t *uc) -{ - return -UNW_EINVAL; -} - -#else /* !UNW_REMOTE_ONLY */ - -static int -unw_init_local_common(unw_cursor_t *cursor, ucontext_t *uc, unsigned use_prev_instr) -{ - struct cursor *c = (struct cursor *) cursor; - - if (!tdep_init_done) - tdep_init (); - - memset(c, 0, sizeof(unw_cursor_t)); - - Debug (1, "(cursor=%p)\n", c); - - c->dwarf.as = unw_local_addr_space; - - c->dwarf.as_arg = uc; - return common_init (c, use_prev_instr); -} - -int -unw_init_local (unw_cursor_t *cursor, ucontext_t *uc) -{ - return unw_init_local_common(cursor, uc, 1); -} - -int -unw_init_local2 (unw_cursor_t *cursor, ucontext_t *uc, int flag) -{ - if (!flag) - { - return unw_init_local_common(cursor, uc, 1); - } - else if (flag == UNW_INIT_SIGNAL_FRAME) - { - return unw_init_local_common(cursor, uc, 0); - } - else - { - return -UNW_EINVAL; - } -} - -#endif /* !UNW_REMOTE_ONLY */ diff --git a/src/pal/src/libunwind/src/tilegx/Ginit_remote.c b/src/pal/src/libunwind/src/tilegx/Ginit_remote.c deleted file mode 100644 index 2a31b18aa..000000000 --- a/src/pal/src/libunwind/src/tilegx/Ginit_remote.c +++ /dev/null @@ -1,47 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - Copyright (C) 2014 Tilera Corp. - -This file is part of libunwind. - -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. */ - -#include "init.h" -#include "unwind_i.h" - -int -unw_init_remote (unw_cursor_t *cursor, unw_addr_space_t as, void *as_arg) -{ -#ifdef UNW_LOCAL_ONLY - return -UNW_EINVAL; -#else /* !UNW_LOCAL_ONLY */ - struct cursor *c = (struct cursor *) cursor; - - if (!tdep_init_done) - tdep_init (); - - Debug (1, "(cursor=%p)\n", c); - - c->dwarf.as = as; - c->dwarf.as_arg = as_arg; - - return common_init (c, 0); -#endif /* !UNW_LOCAL_ONLY */ -} diff --git a/src/pal/src/libunwind/src/tilegx/Gis_signal_frame.c b/src/pal/src/libunwind/src/tilegx/Gis_signal_frame.c deleted file mode 100644 index 5452c2cb2..000000000 --- a/src/pal/src/libunwind/src/tilegx/Gis_signal_frame.c +++ /dev/null @@ -1,115 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - Copyright (C) 2014 Tilera Corp. - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" -#include -#include "offsets.h" - -#ifdef __linux__ -#include -#include -#else -# error "Only support Linux!" -#endif - -#define MOVELI_R10_RT_SIGRETURN \ - ( 0x000007e051483000ULL | \ - ((unsigned long)__NR_rt_sigreturn << 43) | \ - ((unsigned long)TREG_SYSCALL_NR << 31) ) -#define SWINT1 0x286b180051485000ULL - -int -unw_is_signal_frame (unw_cursor_t *cursor) -{ - struct cursor *c = (struct cursor*) cursor; - unw_word_t w0, w1, ip; - unw_addr_space_t as; - unw_accessors_t *a; - void *arg; - int ret; - - as = c->dwarf.as; - a = unw_get_accessors_int (as); - arg = c->dwarf.as_arg; - - ip = c->dwarf.ip; - - if (!ip || !a->access_mem || (ip & (sizeof(unw_word_t) - 1))) - return 0; - - if ((ret = (*a->access_mem) (as, ip, &w0, 0, arg)) < 0) - return ret; - - if ((ret = (*a->access_mem) (as, ip + 8, &w1, 0, arg)) < 0) - return ret; - - /* Return 1 if the IP points to a RT sigreturn sequence. */ - if (w0 == MOVELI_R10_RT_SIGRETURN && - w1 == SWINT1) - { - return 1; - } - return 0; -} - - -HIDDEN int -tilegx_handle_signal_frame (unw_cursor_t *cursor) -{ - int i; - struct cursor *c = (struct cursor *) cursor; - unw_word_t sc_addr, sp, sp_addr = c->dwarf.cfa; - struct dwarf_loc sp_loc = DWARF_LOC (sp_addr, 0); - int ret; - - if ((ret = dwarf_get (&c->dwarf, sp_loc, &sp)) < 0) - return -UNW_EUNSPEC; - - /* Save the SP and PC to be able to return execution at this point - later in time (unw_resume). */ - c->sigcontext_sp = c->dwarf.cfa; - c->sigcontext_pc = c->dwarf.ip; - - c->sigcontext_addr = sp_addr + sizeof (siginfo_t) + - C_ABI_SAVE_AREA_SIZE; - sc_addr = c->sigcontext_addr + LINUX_UC_MCONTEXT_OFF; - - /* Update the dwarf cursor. - Set the location of the registers to the corresponding addresses of the - uc_mcontext / sigcontext structure contents. */ - -#define SC_REG_OFFSET(X) (8 * X) - - for (i = UNW_TILEGX_R0; i <= UNW_TILEGX_R55; i++) - { - c->dwarf.loc[i] = DWARF_LOC (sc_addr + SC_REG_OFFSET(i), 0); - } - - /* Set SP/CFA and PC/IP. */ - dwarf_get (&c->dwarf, c->dwarf.loc[UNW_TILEGX_R54], &c->dwarf.cfa); - dwarf_get (&c->dwarf, c->dwarf.loc[UNW_TILEGX_R55], &c->dwarf.ip); - - return 1; -} diff --git a/src/pal/src/libunwind/src/tilegx/Greg_states_iterate.c b/src/pal/src/libunwind/src/tilegx/Greg_states_iterate.c deleted file mode 100644 index a17dc1b56..000000000 --- a/src/pal/src/libunwind/src/tilegx/Greg_states_iterate.c +++ /dev/null @@ -1,37 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (c) 2002-2003 Hewlett-Packard Development Company, L.P. - Contributed by David Mosberger-Tang - - Modified for x86_64 by Max Asbock - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" - -int -unw_reg_states_iterate (unw_cursor_t *cursor, - unw_reg_states_callback cb, void *token) -{ - struct cursor *c = (struct cursor *) cursor; - - return dwarf_reg_states_iterate (&c->dwarf, cb, token); -} diff --git a/src/pal/src/libunwind/src/tilegx/Gregs.c b/src/pal/src/libunwind/src/tilegx/Gregs.c deleted file mode 100644 index 565c6f443..000000000 --- a/src/pal/src/libunwind/src/tilegx/Gregs.c +++ /dev/null @@ -1,76 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - Copyright (C) 2014 Tilera Corp. - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" - -HIDDEN int -tdep_access_reg (struct cursor *c, unw_regnum_t reg, unw_word_t *valp, - int write) -{ - dwarf_loc_t loc = DWARF_NULL_LOC; - - if (reg == UNW_TILEGX_R54 && !write) - { - reg = UNW_TILEGX_CFA; - } - - if (reg <= UNW_TILEGX_R55) - loc = c->dwarf.loc[reg - UNW_TILEGX_R0]; - else if (reg == UNW_TILEGX_CFA) - { - if (write) - return -UNW_EREADONLYREG; - *valp = c->dwarf.cfa; - return 0; - } - else - { - Debug (1, "bad register number %u\n", reg); - return -UNW_EBADREG; - } - - if (write) - { - if (ci->dwarf.use_prev_instr == 0) { - if (reg == UNW_TILEGX_PC) - c->dwarf.ip = *valp; /* update the IP cache */ - } - else { - if (reg == UNW_TILEGX_R55) - c->dwarf.ip = *valp; /* update the IP cache */ - } - return dwarf_put (&c->dwarf, loc, *valp); - } - else - return dwarf_get (&c->dwarf, loc, valp); -} - -HIDDEN int -tdep_access_fpreg (struct cursor *c, unw_regnum_t reg, unw_fpreg_t *valp, - int write) -{ - Debug (1, "bad register number %u\n", reg); - return -UNW_EBADREG; -} diff --git a/src/pal/src/libunwind/src/tilegx/Gresume.c b/src/pal/src/libunwind/src/tilegx/Gresume.c deleted file mode 100644 index ece443a5b..000000000 --- a/src/pal/src/libunwind/src/tilegx/Gresume.c +++ /dev/null @@ -1,94 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - Copyright (C) 2014 Tilera Corp. - -This file is part of libunwind. - -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. */ - - -#include "unwind_i.h" -#include "offsets.h" -#include - -#ifndef UNW_REMOTE_ONLY - -HIDDEN inline int -tilegx_local_resume (unw_addr_space_t as, unw_cursor_t *cursor, void *arg) -{ - int i; - struct cursor *c = (struct cursor *) cursor; - ucontext_t *uc = c->dwarf.as_arg; - - Debug (1, "(cursor=%p\n", c); - - return setcontext(uc); -} - -#endif /* !UNW_REMOTE_ONLY */ - -static inline void -establish_machine_state (struct cursor *c) -{ - unw_addr_space_t as = c->dwarf.as; - void *arg = c->dwarf.as_arg; - unw_fpreg_t fpval; - unw_word_t val; - int reg; - - Debug (8, "copying out cursor state\n"); - - for (reg = 0; reg <= UNW_REG_LAST; ++reg) - { - Debug (16, "copying %s %d\n", unw_regname (reg), reg); - - if (unw_is_fpreg (reg)) - { - Debug (1, "no fp!"); - abort (); - } - else - { - if (tdep_access_reg (c, reg, &val, 0) >= 0) - as->acc.access_reg (as, reg, &val, 1, arg); - } - } -} - -int -unw_resume (unw_cursor_t *cursor) -{ - struct cursor *c = (struct cursor *) cursor; - - Debug (1, "(cursor=%p) ip=0x%lx\n", c, c->dwarf.ip); - - if (!c->dwarf.ip) - { - /* This can happen easily when the frame-chain gets truncated - due to bad or missing unwind-info. */ - Debug (1, "refusing to resume execution at address 0\n"); - return -UNW_EINVAL; - } - - establish_machine_state (c); - - return (*c->dwarf.as->acc.resume) (c->dwarf.as, (unw_cursor_t *) c, - c->dwarf.as_arg); -} diff --git a/src/pal/src/libunwind/src/tilegx/Gstep.c b/src/pal/src/libunwind/src/tilegx/Gstep.c deleted file mode 100644 index c748dbc58..000000000 --- a/src/pal/src/libunwind/src/tilegx/Gstep.c +++ /dev/null @@ -1,53 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - Copyright (C) 2014 Tilera Corp. - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" -#include "offsets.h" - -int -unw_step (unw_cursor_t *cursor) -{ - struct cursor *c = (struct cursor *) cursor; - int ret; - - Debug (1, "(cursor=%p, ip=0x%016lx, sp=0x%016lx)\n", - c, c->dwarf.ip, c->dwarf.cfa); - - /* Special handling the singal frame. */ - if (unw_is_signal_frame (cursor) > 0) - return tilegx_handle_signal_frame (cursor); - - /* Try DWARF-based unwinding... */ - ret = dwarf_step (&c->dwarf); - - if (unlikely (ret == -UNW_ESTOPUNWIND)) - return ret; - - /* Dwarf unwinding didn't work, stop. */ - if (unlikely (ret < 0)) - return 0; - - return (c->dwarf.ip == 0) ? 0 : 1; -} diff --git a/src/pal/src/libunwind/src/tilegx/Lapply_reg_state.c b/src/pal/src/libunwind/src/tilegx/Lapply_reg_state.c deleted file mode 100644 index 7ebada480..000000000 --- a/src/pal/src/libunwind/src/tilegx/Lapply_reg_state.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gapply_reg_state.c" -#endif diff --git a/src/pal/src/libunwind/src/tilegx/Lcreate_addr_space.c b/src/pal/src/libunwind/src/tilegx/Lcreate_addr_space.c deleted file mode 100644 index 0f2dc6be9..000000000 --- a/src/pal/src/libunwind/src/tilegx/Lcreate_addr_space.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gcreate_addr_space.c" -#endif diff --git a/src/pal/src/libunwind/src/tilegx/Lget_proc_info.c b/src/pal/src/libunwind/src/tilegx/Lget_proc_info.c deleted file mode 100644 index 69028b019..000000000 --- a/src/pal/src/libunwind/src/tilegx/Lget_proc_info.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gget_proc_info.c" -#endif diff --git a/src/pal/src/libunwind/src/tilegx/Lget_save_loc.c b/src/pal/src/libunwind/src/tilegx/Lget_save_loc.c deleted file mode 100644 index 9ea048a90..000000000 --- a/src/pal/src/libunwind/src/tilegx/Lget_save_loc.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gget_save_loc.c" -#endif diff --git a/src/pal/src/libunwind/src/tilegx/Lglobal.c b/src/pal/src/libunwind/src/tilegx/Lglobal.c deleted file mode 100644 index 6d7b489e1..000000000 --- a/src/pal/src/libunwind/src/tilegx/Lglobal.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gglobal.c" -#endif diff --git a/src/pal/src/libunwind/src/tilegx/Linit.c b/src/pal/src/libunwind/src/tilegx/Linit.c deleted file mode 100644 index e9abfdd46..000000000 --- a/src/pal/src/libunwind/src/tilegx/Linit.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Ginit.c" -#endif diff --git a/src/pal/src/libunwind/src/tilegx/Linit_local.c b/src/pal/src/libunwind/src/tilegx/Linit_local.c deleted file mode 100644 index 68a1687e8..000000000 --- a/src/pal/src/libunwind/src/tilegx/Linit_local.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Ginit_local.c" -#endif diff --git a/src/pal/src/libunwind/src/tilegx/Linit_remote.c b/src/pal/src/libunwind/src/tilegx/Linit_remote.c deleted file mode 100644 index 58cb04ab7..000000000 --- a/src/pal/src/libunwind/src/tilegx/Linit_remote.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Ginit_remote.c" -#endif diff --git a/src/pal/src/libunwind/src/tilegx/Lis_signal_frame.c b/src/pal/src/libunwind/src/tilegx/Lis_signal_frame.c deleted file mode 100644 index b9a7c4f51..000000000 --- a/src/pal/src/libunwind/src/tilegx/Lis_signal_frame.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gis_signal_frame.c" -#endif diff --git a/src/pal/src/libunwind/src/tilegx/Lreg_states_iterate.c b/src/pal/src/libunwind/src/tilegx/Lreg_states_iterate.c deleted file mode 100644 index f1eb1e79d..000000000 --- a/src/pal/src/libunwind/src/tilegx/Lreg_states_iterate.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Greg_states_iterate.c" -#endif diff --git a/src/pal/src/libunwind/src/tilegx/Lregs.c b/src/pal/src/libunwind/src/tilegx/Lregs.c deleted file mode 100644 index 2c9c75cd7..000000000 --- a/src/pal/src/libunwind/src/tilegx/Lregs.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gregs.c" -#endif diff --git a/src/pal/src/libunwind/src/tilegx/Lresume.c b/src/pal/src/libunwind/src/tilegx/Lresume.c deleted file mode 100644 index 41a8cf003..000000000 --- a/src/pal/src/libunwind/src/tilegx/Lresume.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gresume.c" -#endif diff --git a/src/pal/src/libunwind/src/tilegx/Lstep.c b/src/pal/src/libunwind/src/tilegx/Lstep.c deleted file mode 100644 index c1ac3c754..000000000 --- a/src/pal/src/libunwind/src/tilegx/Lstep.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gstep.c" -#endif diff --git a/src/pal/src/libunwind/src/tilegx/elfxx.c b/src/pal/src/libunwind/src/tilegx/elfxx.c deleted file mode 100644 index 07d3d12b9..000000000 --- a/src/pal/src/libunwind/src/tilegx/elfxx.c +++ /dev/null @@ -1,27 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - -This file is part of libunwind. - -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. */ - -#include "libunwind_i.h" - -#include "../src/elfxx.c" diff --git a/src/pal/src/libunwind/src/tilegx/gen-offsets.c b/src/pal/src/libunwind/src/tilegx/gen-offsets.c deleted file mode 100644 index 8704bb215..000000000 --- a/src/pal/src/libunwind/src/tilegx/gen-offsets.c +++ /dev/null @@ -1,30 +0,0 @@ -#include -#include -#include - -#define UC(N,X) \ - printf ("#define LINUX_UC_" N "_OFF\t0x%X\n", offsetof (ucontext_t, X)) - -#define SC(N,X) \ - printf ("#define LINUX_SC_" N "_OFF\t0x%X\n", offsetof (struct sigcontext, X)) - -int -main (void) -{ - printf ( -"/* Linux-specific definitions: */\n\n" - -"/* Define various structure offsets to simplify cross-compilation. */\n\n" - -"/* Offsets for TILEGX Linux \"ucontext_t\": */\n\n"); - - UC ("FLAGS", uc_flags); - UC ("LINK", uc_link); - UC ("STACK", uc_stack); - UC ("MCONTEXT", uc_mcontext); - UC ("SIGMASK", uc_sigmask); - - UC ("MCONTEXT_GREGS", uc_mcontext.gregs); - - return 0; -} diff --git a/src/pal/src/libunwind/src/tilegx/getcontext.S b/src/pal/src/libunwind/src/tilegx/getcontext.S deleted file mode 100644 index fbc8654bc..000000000 --- a/src/pal/src/libunwind/src/tilegx/getcontext.S +++ /dev/null @@ -1,36 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - Copyright (C) 2014 Tilera Corp. - -This file is part of libunwind. - -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. */ - -#include "offsets.h" -#include - - .text - # define REG(X) LINUX_UC_MCONTEXT_GREGS + 8 * (X) - .global _Utilegx_getcontext - .type _Utilegx_getcontext, %function - # This is a stub version of getcontext() for TILEGX. -_Utilegx_getcontext: - - diff --git a/src/pal/src/libunwind/src/tilegx/init.h b/src/pal/src/libunwind/src/tilegx/init.h deleted file mode 100644 index 0e0f7fd1d..000000000 --- a/src/pal/src/libunwind/src/tilegx/init.h +++ /dev/null @@ -1,63 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - Copyright (C) 2014 Tilera Corp. - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" - -static inline int -common_init (struct cursor *c, unsigned use_prev_instr) -{ - int ret, i; - - for (i = 0; i < 56; i++) - c->dwarf.loc[i] = DWARF_REG_LOC (&c->dwarf, UNW_TILEGX_R0 + i); - for (i = 56; i < DWARF_NUM_PRESERVED_REGS; ++i) - c->dwarf.loc[i] = DWARF_NULL_LOC; - - if (use_prev_instr == 0) - ret = dwarf_get (&c->dwarf, DWARF_REG_LOC (&c->dwarf, UNW_TILEGX_PC), - &c->dwarf.ip); - else - ret = dwarf_get (&c->dwarf, DWARF_REG_LOC (&c->dwarf, UNW_TILEGX_R55), - &c->dwarf.ip); - - if (ret < 0) - return ret; - - ret = dwarf_get (&c->dwarf, DWARF_REG_LOC (&c->dwarf, UNW_TILEGX_R54), - &c->dwarf.cfa); - - if (ret < 0) - return ret; - - c->dwarf.args_size = 0; - c->dwarf.stash_frames = 0; - c->dwarf.use_prev_instr = use_prev_instr; - c->dwarf.pi_valid = 0; - c->dwarf.pi_is_dynamic = 0; - c->dwarf.hint = 0; - c->dwarf.prev_rs = 0; - - return 0; -} diff --git a/src/pal/src/libunwind/src/tilegx/is_fpreg.c b/src/pal/src/libunwind/src/tilegx/is_fpreg.c deleted file mode 100644 index d6d589690..000000000 --- a/src/pal/src/libunwind/src/tilegx/is_fpreg.c +++ /dev/null @@ -1,33 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - -This file is part of libunwind. - -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. */ - -#include "libunwind_i.h" - -/* TILEGX has no FP. */ - -int -unw_is_fpreg (int regnum) -{ - return 0; -} diff --git a/src/pal/src/libunwind/src/tilegx/offsets.h b/src/pal/src/libunwind/src/tilegx/offsets.h deleted file mode 100644 index 6d30f1edc..000000000 --- a/src/pal/src/libunwind/src/tilegx/offsets.h +++ /dev/null @@ -1,12 +0,0 @@ -/* Linux-specific definitions: */ - -/* Define various structure offsets to simplify cross-compilation. */ - -/* Offsets for TILEGX Linux "ucontext_t": */ - -#define LINUX_UC_FLAGS_OFF 0x0 -#define LINUX_UC_LINK_OFF 0x8 -#define LINUX_UC_STACK_OFF 0x10 -#define LINUX_UC_MCONTEXT_OFF 0x28 -#define LINUX_UC_SIGMASK_OFF 0x228 -#define LINUX_UC_MCONTEXT_GREGS 0x28 diff --git a/src/pal/src/libunwind/src/tilegx/regname.c b/src/pal/src/libunwind/src/tilegx/regname.c deleted file mode 100644 index 0ce47b9d6..000000000 --- a/src/pal/src/libunwind/src/tilegx/regname.c +++ /dev/null @@ -1,55 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - Copyright (C) 2014 Tilera Corp. - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" - -static const char *regname[] = - { - /* 0. */ - "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", - /* 8. */ - "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", - /* 16. */ - "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23", - /* 24. */ - "r24", "r25", "r26", "r27", "r28", "r29", "r30", "r31", - /* 32. */ - "r32", "r33", "r34", "r35", "r36", "r37", "r38", "r39", - /* 40. */ - "r40", "r41", "r42", "r43", "r44", "r45", "r46", "r47", - /* 48. */ - "r48", "r49", "r50", "r51", "r52", "r53", "r54", "r55", - /* pc, cfa */ - "pc", "cfa" - }; - -const char * -unw_regname (unw_regnum_t reg) -{ - if (reg < (unw_regnum_t) ARRAY_SIZE (regname)) - return regname[reg]; - else - return "???"; -} diff --git a/src/pal/src/libunwind/src/tilegx/siglongjmp.S b/src/pal/src/libunwind/src/tilegx/siglongjmp.S deleted file mode 100644 index bccb1c778..000000000 --- a/src/pal/src/libunwind/src/tilegx/siglongjmp.S +++ /dev/null @@ -1,7 +0,0 @@ - /* Dummy implementation for now. */ - .globl _UI_siglongjmp_cont - .globl _UI_longjmp_cont - -_UI_siglongjmp_cont: -_UI_longjmp_cont: - jrp lr diff --git a/src/pal/src/libunwind/src/tilegx/unwind_i.h b/src/pal/src/libunwind/src/tilegx/unwind_i.h deleted file mode 100644 index 9d41c90b4..000000000 --- a/src/pal/src/libunwind/src/tilegx/unwind_i.h +++ /dev/null @@ -1,46 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 CodeSourcery - -This file is part of libunwind. - -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. */ - -#ifndef unwind_i_h -#define unwind_i_h - -#include -#include - -#include - -#include "libunwind_i.h" - -#define tilegx_local_resume UNW_OBJ(local_resume) -#define tilegx_local_addr_space_init UNW_OBJ(local_addr_space_init) - -extern int tilegx_local_resume (unw_addr_space_t as, - unw_cursor_t *cursor, - void *arg); -#define tilegx_handle_signal_frame UNW_OBJ(handle_signal_frame) -extern int tilegx_handle_signal_frame(unw_cursor_t *cursor); - -extern void tilegx_local_addr_space_init (void); - -#endif /* unwind_i_h */ diff --git a/src/pal/src/libunwind/src/unwind/Backtrace.c b/src/pal/src/libunwind/src/unwind/Backtrace.c deleted file mode 100644 index 0b14df4cb..000000000 --- a/src/pal/src/libunwind/src/unwind/Backtrace.c +++ /dev/null @@ -1,56 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2003-2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include "unwind-internal.h" - -_Unwind_Reason_Code -_Unwind_Backtrace (_Unwind_Trace_Fn trace, void *trace_parameter) -{ - struct _Unwind_Context context; - unw_context_t uc; - int ret; - - if (_Unwind_InitContext (&context, &uc) < 0) - return _URC_FATAL_PHASE1_ERROR; - - /* Phase 1 (search phase) */ - - while (1) - { - if ((ret = unw_step (&context.cursor)) <= 0) - { - if (ret == 0) - return _URC_END_OF_STACK; - else - return _URC_FATAL_PHASE1_ERROR; - } - - if ((*trace) (&context, trace_parameter) != _URC_NO_REASON) - return _URC_FATAL_PHASE1_ERROR; - } -} - -_Unwind_Reason_Code __libunwind_Unwind_Backtrace (_Unwind_Trace_Fn, void *) - ALIAS (_Unwind_Backtrace); diff --git a/src/pal/src/libunwind/src/unwind/DeleteException.c b/src/pal/src/libunwind/src/unwind/DeleteException.c deleted file mode 100644 index ad38eaf65..000000000 --- a/src/pal/src/libunwind/src/unwind/DeleteException.c +++ /dev/null @@ -1,38 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2003-2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include "unwind-internal.h" - -void -_Unwind_DeleteException (struct _Unwind_Exception *exception_object) -{ - _Unwind_Exception_Cleanup_Fn cleanup = exception_object->exception_cleanup; - - if (cleanup) - (*cleanup) (_URC_FOREIGN_EXCEPTION_CAUGHT, exception_object); -} - -void __libunwind_Unwind_DeleteException (struct _Unwind_Exception *) - ALIAS (_Unwind_DeleteException); diff --git a/src/pal/src/libunwind/src/unwind/FindEnclosingFunction.c b/src/pal/src/libunwind/src/unwind/FindEnclosingFunction.c deleted file mode 100644 index 4f1066617..000000000 --- a/src/pal/src/libunwind/src/unwind/FindEnclosingFunction.c +++ /dev/null @@ -1,42 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2003-2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include "unwind-internal.h" - -void * -_Unwind_FindEnclosingFunction (void *ip) -{ - unw_proc_info_t pi; - - if (unw_get_proc_info_by_ip (unw_local_addr_space, - (unw_word_t) (uintptr_t) ip, &pi, 0) - < 0) - return NULL; - - return (void *) (uintptr_t) pi.start_ip; -} - -void *__libunwind_Unwind_FindEnclosingFunction (void *) - ALIAS (_Unwind_FindEnclosingFunction); diff --git a/src/pal/src/libunwind/src/unwind/ForcedUnwind.c b/src/pal/src/libunwind/src/unwind/ForcedUnwind.c deleted file mode 100644 index 905b31cd8..000000000 --- a/src/pal/src/libunwind/src/unwind/ForcedUnwind.c +++ /dev/null @@ -1,52 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2003-2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include "unwind-internal.h" - -_Unwind_Reason_Code -_Unwind_ForcedUnwind (struct _Unwind_Exception *exception_object, - _Unwind_Stop_Fn stop, void *stop_parameter) -{ - struct _Unwind_Context context; - unw_context_t uc; - - /* We check "stop" here to tell the compiler's inliner that - exception_object->private_1 isn't NULL when calling - _Unwind_Phase2(). */ - if (!stop) - return _URC_FATAL_PHASE2_ERROR; - - if (_Unwind_InitContext (&context, &uc) < 0) - return _URC_FATAL_PHASE2_ERROR; - - exception_object->private_1 = (unsigned long) stop; - exception_object->private_2 = (unsigned long) stop_parameter; - - return _Unwind_Phase2 (exception_object, &context); -} - -_Unwind_Reason_Code __libunwind_Unwind_ForcedUnwind (struct _Unwind_Exception*, - _Unwind_Stop_Fn, void *) - ALIAS (_Unwind_ForcedUnwind); diff --git a/src/pal/src/libunwind/src/unwind/GetBSP.c b/src/pal/src/libunwind/src/unwind/GetBSP.c deleted file mode 100644 index d1bc84e0d..000000000 --- a/src/pal/src/libunwind/src/unwind/GetBSP.c +++ /dev/null @@ -1,42 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2003-2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include "unwind-internal.h" - -unsigned long -_Unwind_GetBSP (struct _Unwind_Context *context) -{ -#ifdef UNW_TARGET_IA64 - unw_word_t val; - - unw_get_reg (&context->cursor, UNW_IA64_BSP, &val); - return val; -#else - return 0; -#endif -} - -unsigned long __libunwind_Unwind_GetBSP (struct _Unwind_Context *) - ALIAS (_Unwind_GetBSP); diff --git a/src/pal/src/libunwind/src/unwind/GetCFA.c b/src/pal/src/libunwind/src/unwind/GetCFA.c deleted file mode 100644 index 5ca63903d..000000000 --- a/src/pal/src/libunwind/src/unwind/GetCFA.c +++ /dev/null @@ -1,38 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2003-2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include "unwind-internal.h" - -unsigned long -_Unwind_GetCFA (struct _Unwind_Context *context) -{ - unw_word_t val; - - unw_get_reg (&context->cursor, UNW_REG_SP, &val); - return val; -} - -unsigned long __libunwind_Unwind_GetCFA (struct _Unwind_Context *) - ALIAS (_Unwind_GetCFA); diff --git a/src/pal/src/libunwind/src/unwind/GetDataRelBase.c b/src/pal/src/libunwind/src/unwind/GetDataRelBase.c deleted file mode 100644 index 8e6914f4f..000000000 --- a/src/pal/src/libunwind/src/unwind/GetDataRelBase.c +++ /dev/null @@ -1,39 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2003-2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include "unwind-internal.h" - -unsigned long -_Unwind_GetDataRelBase (struct _Unwind_Context *context) -{ - unw_proc_info_t pi; - - pi.gp = 0; - unw_get_proc_info (&context->cursor, &pi); - return pi.gp; -} - -unsigned long __libunwind_Unwind_GetDataRelBase (struct _Unwind_Context *) - ALIAS (_Unwind_GetDataRelBase); diff --git a/src/pal/src/libunwind/src/unwind/GetGR.c b/src/pal/src/libunwind/src/unwind/GetGR.c deleted file mode 100644 index fa7094343..000000000 --- a/src/pal/src/libunwind/src/unwind/GetGR.c +++ /dev/null @@ -1,43 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2003-2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include "unwind-internal.h" - -unsigned long -_Unwind_GetGR (struct _Unwind_Context *context, int index) -{ - unw_word_t val; - - if (index == UNW_REG_SP && context->end_of_stack) - /* _Unwind_ForcedUnwind() requires us to return a NULL - stack-pointer after reaching the end of the stack. */ - return 0; - - unw_get_reg (&context->cursor, index, &val); - return val; -} - -unsigned long __libunwind_Unwind_GetGR (struct _Unwind_Context *, int) - ALIAS (_Unwind_GetGR); diff --git a/src/pal/src/libunwind/src/unwind/GetIP.c b/src/pal/src/libunwind/src/unwind/GetIP.c deleted file mode 100644 index e9fc49440..000000000 --- a/src/pal/src/libunwind/src/unwind/GetIP.c +++ /dev/null @@ -1,38 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2003-2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include "unwind-internal.h" - -unsigned long -_Unwind_GetIP (struct _Unwind_Context *context) -{ - unw_word_t val; - - unw_get_reg (&context->cursor, UNW_REG_IP, &val); - return val; -} - -unsigned long __libunwind_Unwind_GetIP (struct _Unwind_Context *) - ALIAS (_Unwind_GetIP); diff --git a/src/pal/src/libunwind/src/unwind/GetIPInfo.c b/src/pal/src/libunwind/src/unwind/GetIPInfo.c deleted file mode 100644 index e8ee7fd7f..000000000 --- a/src/pal/src/libunwind/src/unwind/GetIPInfo.c +++ /dev/null @@ -1,42 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2009 Red Hat - Contributed by Jan Kratochvil - -This file is part of libunwind. - -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. */ - -#include "unwind-internal.h" - -/* gcc/unwind-dw2.c: Retrieve the return address and flag whether that IP is - before or after first not yet fully executed instruction. */ - -unsigned long -_Unwind_GetIPInfo (struct _Unwind_Context *context, int *ip_before_insn) -{ - unw_word_t val; - - unw_get_reg (&context->cursor, UNW_REG_IP, &val); - *ip_before_insn = unw_is_signal_frame (&context->cursor); - return val; -} - -unsigned long __libunwind_Unwind_GetIPInfo (struct _Unwind_Context *, int *) - ALIAS (_Unwind_GetIPInfo); diff --git a/src/pal/src/libunwind/src/unwind/GetLanguageSpecificData.c b/src/pal/src/libunwind/src/unwind/GetLanguageSpecificData.c deleted file mode 100644 index e7ca9b453..000000000 --- a/src/pal/src/libunwind/src/unwind/GetLanguageSpecificData.c +++ /dev/null @@ -1,40 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2003-2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include "unwind-internal.h" - -unsigned long -_Unwind_GetLanguageSpecificData (struct _Unwind_Context *context) -{ - unw_proc_info_t pi; - - pi.lsda = 0; - unw_get_proc_info (&context->cursor, &pi); - return pi.lsda; -} - -unsigned long -__libunwind_Unwind_GetLanguageSpecificData (struct _Unwind_Context *) - ALIAS (_Unwind_GetLanguageSpecificData); diff --git a/src/pal/src/libunwind/src/unwind/GetRegionStart.c b/src/pal/src/libunwind/src/unwind/GetRegionStart.c deleted file mode 100644 index f4995813f..000000000 --- a/src/pal/src/libunwind/src/unwind/GetRegionStart.c +++ /dev/null @@ -1,39 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2003-2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include "unwind-internal.h" - -unsigned long -_Unwind_GetRegionStart (struct _Unwind_Context *context) -{ - unw_proc_info_t pi; - - pi.start_ip = 0; - unw_get_proc_info (&context->cursor, &pi); - return pi.start_ip; -} - -unsigned long __libunwind_Unwind_GetRegionStart (struct _Unwind_Context *) - ALIAS (_Unwind_GetRegionStart); diff --git a/src/pal/src/libunwind/src/unwind/GetTextRelBase.c b/src/pal/src/libunwind/src/unwind/GetTextRelBase.c deleted file mode 100644 index ce65ae93e..000000000 --- a/src/pal/src/libunwind/src/unwind/GetTextRelBase.c +++ /dev/null @@ -1,35 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2003-2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include "unwind-internal.h" - -unsigned long -_Unwind_GetTextRelBase (struct _Unwind_Context *context) -{ - return 0; -} - -unsigned long __libunwind_Unwind_GetTextRelBase (struct _Unwind_Context *) - ALIAS (_Unwind_GetTextRelBase); diff --git a/src/pal/src/libunwind/src/unwind/RaiseException.c b/src/pal/src/libunwind/src/unwind/RaiseException.c deleted file mode 100644 index 3c3ca19e9..000000000 --- a/src/pal/src/libunwind/src/unwind/RaiseException.c +++ /dev/null @@ -1,103 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2003-2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include "unwind-internal.h" - -_Unwind_Reason_Code -_Unwind_RaiseException (struct _Unwind_Exception *exception_object) -{ - uint64_t exception_class = exception_object->exception_class; - _Unwind_Personality_Fn personality; - struct _Unwind_Context context; - _Unwind_Reason_Code reason; - unw_proc_info_t pi; - unw_context_t uc; - unw_word_t ip; - int ret; - - Debug (1, "(exception_object=%p)\n", exception_object); - - if (_Unwind_InitContext (&context, &uc) < 0) - return _URC_FATAL_PHASE1_ERROR; - - /* Phase 1 (search phase) */ - - while (1) - { - if ((ret = unw_step (&context.cursor)) <= 0) - { - if (ret == 0) - { - Debug (1, "no handler found\n"); - return _URC_END_OF_STACK; - } - else - return _URC_FATAL_PHASE1_ERROR; - } - - if (unw_get_proc_info (&context.cursor, &pi) < 0) - return _URC_FATAL_PHASE1_ERROR; - - personality = (_Unwind_Personality_Fn) (uintptr_t) pi.handler; - if (personality) - { - reason = (*personality) (_U_VERSION, _UA_SEARCH_PHASE, - exception_class, exception_object, - &context); - if (reason != _URC_CONTINUE_UNWIND) - { - if (reason == _URC_HANDLER_FOUND) - break; - else - { - Debug (1, "personality returned %d\n", reason); - return _URC_FATAL_PHASE1_ERROR; - } - } - } - } - - /* Exceptions are associated with IP-ranges. If a given exception - is handled at a particular IP, it will _always_ be handled at - that IP. If this weren't true, we'd have to track the tuple - (IP,SP,BSP) to uniquely identify the stack frame that's handling - the exception. */ - if (unw_get_reg (&context.cursor, UNW_REG_IP, &ip) < 0) - return _URC_FATAL_PHASE1_ERROR; - exception_object->private_1 = 0; /* clear "stop" pointer */ - exception_object->private_2 = ip; /* save frame marker */ - - Debug (1, "found handler for IP=%lx; entering cleanup phase\n", (long) ip); - - /* Reset the cursor to the first frame: */ - if (unw_init_local (&context.cursor, &uc) < 0) - return _URC_FATAL_PHASE1_ERROR; - - return _Unwind_Phase2 (exception_object, &context); -} - -_Unwind_Reason_Code -__libunwind_Unwind_RaiseException (struct _Unwind_Exception *) - ALIAS (_Unwind_RaiseException); diff --git a/src/pal/src/libunwind/src/unwind/Resume.c b/src/pal/src/libunwind/src/unwind/Resume.c deleted file mode 100644 index e23d6be27..000000000 --- a/src/pal/src/libunwind/src/unwind/Resume.c +++ /dev/null @@ -1,42 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2003-2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include "unwind-internal.h" - -void -_Unwind_Resume (struct _Unwind_Exception *exception_object) -{ - struct _Unwind_Context context; - unw_context_t uc; - - if (_Unwind_InitContext (&context, &uc) < 0) - abort (); - - _Unwind_Phase2 (exception_object, &context); - abort (); -} - -void __libunwind_Unwind_Resume (struct _Unwind_Exception *) - ALIAS (_Unwind_Resume); diff --git a/src/pal/src/libunwind/src/unwind/Resume_or_Rethrow.c b/src/pal/src/libunwind/src/unwind/Resume_or_Rethrow.c deleted file mode 100644 index 9c76443b3..000000000 --- a/src/pal/src/libunwind/src/unwind/Resume_or_Rethrow.c +++ /dev/null @@ -1,47 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2003-2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include "unwind-internal.h" - -_Unwind_Reason_Code -_Unwind_Resume_or_Rethrow (struct _Unwind_Exception *exception_object) -{ - struct _Unwind_Context context; - unw_context_t uc; - - if (exception_object->private_1) - { - if (_Unwind_InitContext (&context, &uc) < 0) - return _URC_FATAL_PHASE2_ERROR; - - return _Unwind_Phase2 (exception_object, &context); - } - else - return _Unwind_RaiseException (exception_object); -} - -_Unwind_Reason_Code -__libunwind_Unwind_Resume_or_Rethrow (struct _Unwind_Exception *) - ALIAS (_Unwind_Resume_or_Rethrow); diff --git a/src/pal/src/libunwind/src/unwind/SetGR.c b/src/pal/src/libunwind/src/unwind/SetGR.c deleted file mode 100644 index ae77a8e82..000000000 --- a/src/pal/src/libunwind/src/unwind/SetGR.c +++ /dev/null @@ -1,47 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2003-2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include "unwind-internal.h" -#ifdef UNW_TARGET_X86 -#include "dwarf_i.h" -#endif - -void -_Unwind_SetGR (struct _Unwind_Context *context, int index, - unsigned long new_value) -{ -#ifdef UNW_TARGET_X86 - index = dwarf_to_unw_regnum(index); -#endif - unw_set_reg (&context->cursor, index, new_value); -#ifdef UNW_TARGET_IA64 - if (index >= UNW_IA64_GR && index <= UNW_IA64_GR + 127) - /* Clear the NaT bit. */ - unw_set_reg (&context->cursor, UNW_IA64_NAT + (index - UNW_IA64_GR), 0); -#endif -} - -void __libunwind_Unwind_SetGR (struct _Unwind_Context *, int, unsigned long) - ALIAS (_Unwind_SetGR); diff --git a/src/pal/src/libunwind/src/unwind/SetIP.c b/src/pal/src/libunwind/src/unwind/SetIP.c deleted file mode 100644 index fccc2f0dd..000000000 --- a/src/pal/src/libunwind/src/unwind/SetIP.c +++ /dev/null @@ -1,35 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2003-2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include "unwind-internal.h" - -void -_Unwind_SetIP (struct _Unwind_Context *context, unsigned long new_value) -{ - unw_set_reg (&context->cursor, UNW_REG_IP, new_value); -} - -void __libunwind_Unwind_SetIP (struct _Unwind_Context *, unsigned long) - ALIAS (_Unwind_SetIP); diff --git a/src/pal/src/libunwind/src/unwind/libunwind.pc.in b/src/pal/src/libunwind/src/unwind/libunwind.pc.in deleted file mode 100644 index 1505c5d6f..000000000 --- a/src/pal/src/libunwind/src/unwind/libunwind.pc.in +++ /dev/null @@ -1,11 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ - -Name: libunwind -Description: libunwind base library -Version: @VERSION@ -Libs: -L${libdir} -lunwind -Libs.private: @LIBLZMA@ -Cflags: -I${includedir} diff --git a/src/pal/src/libunwind/src/unwind/unwind-internal.h b/src/pal/src/libunwind/src/unwind/unwind-internal.h deleted file mode 100644 index c68fc3c5e..000000000 --- a/src/pal/src/libunwind/src/unwind/unwind-internal.h +++ /dev/null @@ -1,140 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2003, 2005 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#ifndef unwind_internal_h -#define unwind_internal_h - -#define UNW_LOCAL_ONLY - -#include -#include -#include - -#include "libunwind_i.h" - -/* The version of the _Unwind_*() interface implemented by this code. */ -#define _U_VERSION 1 - -typedef _Unwind_Reason_Code (*_Unwind_Personality_Fn) - (int, _Unwind_Action, uint64_t, struct _Unwind_Exception *, - struct _Unwind_Context *); - -struct _Unwind_Context { - unw_cursor_t cursor; - int end_of_stack; /* set to 1 if the end of stack was reached */ -}; - -/* This must be a macro because unw_getcontext() must be invoked from - the callee, even if optimization (and hence inlining) is turned - off. The macro arguments MUST NOT have any side-effects. */ -#define _Unwind_InitContext(context, uc) \ - ((context)->end_of_stack = 0, \ - ((unw_getcontext (uc) < 0 || unw_init_local (&(context)->cursor, uc) < 0) \ - ? -1 : 0)) - -static _Unwind_Reason_Code ALWAYS_INLINE -_Unwind_Phase2 (struct _Unwind_Exception *exception_object, - struct _Unwind_Context *context) -{ - _Unwind_Stop_Fn stop = (_Unwind_Stop_Fn) exception_object->private_1; - uint64_t exception_class = exception_object->exception_class; - void *stop_parameter = (void *) exception_object->private_2; - _Unwind_Personality_Fn personality; - _Unwind_Reason_Code reason; - _Unwind_Action actions; - unw_proc_info_t pi; - unw_word_t ip; - int ret; - - actions = _UA_CLEANUP_PHASE; - if (stop) - actions |= _UA_FORCE_UNWIND; - - while (1) - { - ret = unw_step (&context->cursor); - if (ret <= 0) - { - if (ret == 0) - { - actions |= _UA_END_OF_STACK; - context->end_of_stack = 1; - } - else - return _URC_FATAL_PHASE2_ERROR; - } - - if (stop) - { - reason = (*stop) (_U_VERSION, actions, exception_class, - exception_object, context, stop_parameter); - if (reason != _URC_NO_REASON) - /* Stop function may return _URC_FATAL_PHASE2_ERROR if - it's unable to handle end-of-stack condition or - _URC_FATAL_PHASE2_ERROR if something is wrong. Not - that it matters: the resulting state is indeterminate - anyhow so we must return _URC_FATAL_PHASE2_ERROR... */ - return _URC_FATAL_PHASE2_ERROR; - } - - if (context->end_of_stack - || unw_get_proc_info (&context->cursor, &pi) < 0) - return _URC_FATAL_PHASE2_ERROR; - - personality = (_Unwind_Personality_Fn) (uintptr_t) pi.handler; - if (personality) - { - if (!stop) - { - if (unw_get_reg (&context->cursor, UNW_REG_IP, &ip) < 0) - return _URC_FATAL_PHASE2_ERROR; - - if ((unsigned long) stop_parameter == ip) - actions |= _UA_HANDLER_FRAME; - } - - reason = (*personality) (_U_VERSION, actions, exception_class, - exception_object, context); - if (reason != _URC_CONTINUE_UNWIND) - { - if (reason == _URC_INSTALL_CONTEXT) - { - /* we may regain control via _Unwind_Resume() */ - unw_resume (&context->cursor); - abort (); - } - else - return _URC_FATAL_PHASE2_ERROR; - } - if (actions & _UA_HANDLER_FRAME) - /* The personality routine for the handler-frame changed - it's mind; that's a no-no... */ - abort (); - } - } - return _URC_FATAL_PHASE2_ERROR; /* shouldn't be reached */ -} - -#endif /* unwind_internal_h */ diff --git a/src/pal/src/libunwind/src/x86/Gapply_reg_state.c b/src/pal/src/libunwind/src/x86/Gapply_reg_state.c deleted file mode 100644 index 82f056da6..000000000 --- a/src/pal/src/libunwind/src/x86/Gapply_reg_state.c +++ /dev/null @@ -1,37 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (c) 2002-2003 Hewlett-Packard Development Company, L.P. - Contributed by David Mosberger-Tang - - Modified for x86_64 by Max Asbock - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" - -int -unw_apply_reg_state (unw_cursor_t *cursor, - void *reg_states_data) -{ - struct cursor *c = (struct cursor *) cursor; - - return dwarf_apply_reg_state (&c->dwarf, (dwarf_reg_state_t *)reg_states_data); -} diff --git a/src/pal/src/libunwind/src/x86/Gcreate_addr_space.c b/src/pal/src/libunwind/src/x86/Gcreate_addr_space.c deleted file mode 100644 index a7e41a58f..000000000 --- a/src/pal/src/libunwind/src/x86/Gcreate_addr_space.c +++ /dev/null @@ -1,58 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2003 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include - -#include "unwind_i.h" - -#if defined(_LITTLE_ENDIAN) && !defined(__LITTLE_ENDIAN) -#define __LITTLE_ENDIAN _LITTLE_ENDIAN -#endif - -unw_addr_space_t -unw_create_addr_space (unw_accessors_t *a, int byte_order) -{ -#ifdef UNW_LOCAL_ONLY - return NULL; -#else - unw_addr_space_t as; - - /* - * x86 supports only little-endian. - */ - if (byte_order != 0 && byte_order != __LITTLE_ENDIAN) - return NULL; - - as = malloc (sizeof (*as)); - if (!as) - return NULL; - - memset (as, 0, sizeof (*as)); - - as->acc = *a; - - return as; -#endif -} diff --git a/src/pal/src/libunwind/src/x86/Gget_proc_info.c b/src/pal/src/libunwind/src/x86/Gget_proc_info.c deleted file mode 100644 index 4dc2cff36..000000000 --- a/src/pal/src/libunwind/src/x86/Gget_proc_info.c +++ /dev/null @@ -1,45 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (c) 2002-2003 Hewlett-Packard Development Company, L.P. - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" - -int -unw_get_proc_info (unw_cursor_t *cursor, unw_proc_info_t *pi) -{ - struct cursor *c = (struct cursor *) cursor; - - if (dwarf_make_proc_info (&c->dwarf) < 0) - { - /* On x86, it's relatively common to be missing DWARF unwind - info. We don't want to fail in that case, because the - frame-chain still would let us do a backtrace at least. */ - memset (pi, 0, sizeof (*pi)); - pi->start_ip = c->dwarf.ip; - pi->end_ip = c->dwarf.ip + 1; - return 0; - } - *pi = c->dwarf.pi; - return 0; -} diff --git a/src/pal/src/libunwind/src/x86/Gget_save_loc.c b/src/pal/src/libunwind/src/x86/Gget_save_loc.c deleted file mode 100644 index e459382f6..000000000 --- a/src/pal/src/libunwind/src/x86/Gget_save_loc.c +++ /dev/null @@ -1,133 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" - -int -unw_get_save_loc (unw_cursor_t *cursor, int reg, unw_save_loc_t *sloc) -{ - struct cursor *c = (struct cursor *) cursor; - dwarf_loc_t loc; - - loc = DWARF_NULL_LOC; /* default to "not saved" */ - - switch (reg) - { - case UNW_X86_EIP: loc = c->dwarf.loc[EIP]; break; - case UNW_X86_CFA: break; - case UNW_X86_EAX: loc = c->dwarf.loc[EAX]; break; - case UNW_X86_ECX: loc = c->dwarf.loc[ECX]; break; - case UNW_X86_EDX: loc = c->dwarf.loc[EDX]; break; - case UNW_X86_EBX: loc = c->dwarf.loc[EBX]; break; - case UNW_X86_ESP: loc = c->dwarf.loc[ESP]; break; - case UNW_X86_EBP: loc = c->dwarf.loc[EBP]; break; - case UNW_X86_ESI: loc = c->dwarf.loc[ESI]; break; - case UNW_X86_EDI: loc = c->dwarf.loc[EDI]; break; - case UNW_X86_EFLAGS: loc = c->dwarf.loc[EFLAGS]; break; - case UNW_X86_TRAPNO: loc = c->dwarf.loc[TRAPNO]; break; - case UNW_X86_ST0: loc = c->dwarf.loc[ST0]; break; - - case UNW_X86_FCW: - case UNW_X86_FSW: - case UNW_X86_FTW: - case UNW_X86_FOP: - case UNW_X86_FCS: - case UNW_X86_FIP: - case UNW_X86_FEA: - case UNW_X86_FDS: - case UNW_X86_MXCSR: - case UNW_X86_GS: - case UNW_X86_FS: - case UNW_X86_ES: - case UNW_X86_DS: - case UNW_X86_SS: - case UNW_X86_CS: - case UNW_X86_TSS: - case UNW_X86_LDT: - loc = x86_scratch_loc (c, reg); - break; - - /* stacked fp registers */ - case UNW_X86_ST1: - case UNW_X86_ST2: - case UNW_X86_ST3: - case UNW_X86_ST4: - case UNW_X86_ST5: - case UNW_X86_ST6: - case UNW_X86_ST7: - /* SSE fp registers */ - case UNW_X86_XMM0_lo: - case UNW_X86_XMM0_hi: - case UNW_X86_XMM1_lo: - case UNW_X86_XMM1_hi: - case UNW_X86_XMM2_lo: - case UNW_X86_XMM2_hi: - case UNW_X86_XMM3_lo: - case UNW_X86_XMM3_hi: - case UNW_X86_XMM4_lo: - case UNW_X86_XMM4_hi: - case UNW_X86_XMM5_lo: - case UNW_X86_XMM5_hi: - case UNW_X86_XMM6_lo: - case UNW_X86_XMM6_hi: - case UNW_X86_XMM7_lo: - case UNW_X86_XMM7_hi: - case UNW_X86_XMM0: - case UNW_X86_XMM1: - case UNW_X86_XMM2: - case UNW_X86_XMM3: - case UNW_X86_XMM4: - case UNW_X86_XMM5: - case UNW_X86_XMM6: - case UNW_X86_XMM7: - loc = x86_scratch_loc (c, reg); - break; - - default: - break; - } - - memset (sloc, 0, sizeof (*sloc)); - - if (DWARF_IS_NULL_LOC (loc)) - { - sloc->type = UNW_SLT_NONE; - return 0; - } - -#if !defined(UNW_LOCAL_ONLY) - if (DWARF_IS_REG_LOC (loc)) - { - sloc->type = UNW_SLT_REG; - sloc->u.regnum = DWARF_GET_LOC (loc); - } - else -#endif - { - sloc->type = UNW_SLT_MEMORY; - sloc->u.addr = DWARF_GET_LOC (loc); - } - return 0; -} diff --git a/src/pal/src/libunwind/src/x86/Gglobal.c b/src/pal/src/libunwind/src/x86/Gglobal.c deleted file mode 100644 index 132b82499..000000000 --- a/src/pal/src/libunwind/src/x86/Gglobal.c +++ /dev/null @@ -1,67 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (c) 2003, 2005 Hewlett-Packard Development Company, L.P. - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" -#include "dwarf_i.h" - -HIDDEN define_lock (x86_lock); -HIDDEN int tdep_init_done; - -/* See comments for svr4_dbx_register_map[] in gcc/config/i386/i386.c. */ - -HIDDEN const uint8_t dwarf_to_unw_regnum_map[19] = - { - UNW_X86_EAX, UNW_X86_ECX, UNW_X86_EDX, UNW_X86_EBX, - UNW_X86_ESP, UNW_X86_EBP, UNW_X86_ESI, UNW_X86_EDI, - UNW_X86_EIP, UNW_X86_EFLAGS, UNW_X86_TRAPNO, - UNW_X86_ST0, UNW_X86_ST1, UNW_X86_ST2, UNW_X86_ST3, - UNW_X86_ST4, UNW_X86_ST5, UNW_X86_ST6, UNW_X86_ST7 - }; - -HIDDEN void -tdep_init (void) -{ - intrmask_t saved_mask; - - sigfillset (&unwi_full_mask); - - lock_acquire (&x86_lock, saved_mask); - { - if (tdep_init_done) - /* another thread else beat us to it... */ - goto out; - - mi_init (); - - dwarf_init (); - -#ifndef UNW_REMOTE_ONLY - x86_local_addr_space_init (); -#endif - tdep_init_done = 1; /* signal that we're initialized... */ - } - out: - lock_release (&x86_lock, saved_mask); -} diff --git a/src/pal/src/libunwind/src/x86/Ginit.c b/src/pal/src/libunwind/src/x86/Ginit.c deleted file mode 100644 index f6b8dc27d..000000000 --- a/src/pal/src/libunwind/src/x86/Ginit.c +++ /dev/null @@ -1,243 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2002 Hewlett-Packard Co - Copyright (C) 2007 David Mosberger-Tang - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include - -#include "unwind_i.h" - -#ifdef UNW_REMOTE_ONLY - -/* unw_local_addr_space is a NULL pointer in this case. */ -unw_addr_space_t unw_local_addr_space; - -#else /* !UNW_REMOTE_ONLY */ - -static struct unw_addr_space local_addr_space; - -unw_addr_space_t unw_local_addr_space = &local_addr_space; - -# ifdef UNW_LOCAL_ONLY - -HIDDEN void * -tdep_uc_addr (ucontext_t *uc, int reg) -{ - return x86_r_uc_addr (uc, reg); -} - -# endif /* UNW_LOCAL_ONLY */ - -HIDDEN unw_dyn_info_list_t _U_dyn_info_list; - -/* XXX fix me: there is currently no way to locate the dyn-info list - by a remote unwinder. On ia64, this is done via a special - unwind-table entry. Perhaps something similar can be done with - DWARF2 unwind info. */ - -static void -put_unwind_info (unw_addr_space_t as, unw_proc_info_t *proc_info, void *arg) -{ - /* it's a no-op */ -} - -static int -get_dyn_info_list_addr (unw_addr_space_t as, unw_word_t *dyn_info_list_addr, - void *arg) -{ - *dyn_info_list_addr = (unw_word_t) &_U_dyn_info_list; - return 0; -} - -#define PAGE_SIZE 4096 -#define PAGE_START(a) ((a) & ~(PAGE_SIZE-1)) - -/* Cache of already validated addresses */ -#define NLGA 4 -static unw_word_t last_good_addr[NLGA]; -static int lga_victim; - -static int -validate_mem (unw_word_t addr) -{ - int i, victim; -#ifdef HAVE_MINCORE - unsigned char mvec[2]; /* Unaligned access may cross page boundary */ -#endif - size_t len; - - if (PAGE_START(addr + sizeof (unw_word_t) - 1) == PAGE_START(addr)) - len = PAGE_SIZE; - else - len = PAGE_SIZE * 2; - - addr = PAGE_START(addr); - - if (addr == 0) - return -1; - - for (i = 0; i < NLGA; i++) - { - if (last_good_addr[i] && (addr == last_good_addr[i])) - return 0; - } - -#ifdef HAVE_MINCORE - if (mincore ((void *) addr, len, mvec) == -1) -#else - if (msync ((void *) addr, len, MS_ASYNC) == -1) -#endif - return -1; - - victim = lga_victim; - for (i = 0; i < NLGA; i++) { - if (!last_good_addr[victim]) { - last_good_addr[victim++] = addr; - return 0; - } - victim = (victim + 1) % NLGA; - } - - /* All slots full. Evict the victim. */ - last_good_addr[victim] = addr; - victim = (victim + 1) % NLGA; - lga_victim = victim; - - return 0; -} - -static int -access_mem (unw_addr_space_t as, unw_word_t addr, unw_word_t *val, int write, - void *arg) -{ - if (write) - { - Debug (16, "mem[%x] <- %x\n", addr, *val); - *(unw_word_t *) addr = *val; - } - else - { - /* validate address */ - const struct cursor *c = (const struct cursor *)arg; - if (c && c->validate && validate_mem(addr)) - return -1; - *val = *(unw_word_t *) addr; - Debug (16, "mem[%x] -> %x\n", addr, *val); - } - return 0; -} - -static int -access_reg (unw_addr_space_t as, unw_regnum_t reg, unw_word_t *val, int write, - void *arg) -{ - unw_word_t *addr; - ucontext_t *uc = ((struct cursor *)arg)->uc; - - if (unw_is_fpreg (reg)) - goto badreg; - - if (!(addr = x86_r_uc_addr (uc, reg))) - goto badreg; - - if (write) - { - *(unw_word_t *) addr = *val; - Debug (12, "%s <- %x\n", unw_regname (reg), *val); - } - else - { - *val = *(unw_word_t *) addr; - Debug (12, "%s -> %x\n", unw_regname (reg), *val); - } - return 0; - - badreg: - Debug (1, "bad register number %u\n", reg); - return -UNW_EBADREG; -} - -static int -access_fpreg (unw_addr_space_t as, unw_regnum_t reg, unw_fpreg_t *val, - int write, void *arg) -{ - ucontext_t *uc = ((struct cursor *)arg)->uc; - unw_fpreg_t *addr; - - if (!unw_is_fpreg (reg)) - goto badreg; - - if (!(addr = x86_r_uc_addr (uc, reg))) - goto badreg; - - if (write) - { - Debug (12, "%s <- %08lx.%08lx.%08lx\n", unw_regname (reg), - ((long *)val)[0], ((long *)val)[1], ((long *)val)[2]); - *(unw_fpreg_t *) addr = *val; - } - else - { - *val = *(unw_fpreg_t *) addr; - Debug (12, "%s -> %08lx.%08lx.%08lx\n", unw_regname (reg), - ((long *)val)[0], ((long *)val)[1], ((long *)val)[2]); - } - return 0; - - badreg: - Debug (1, "bad register number %u\n", reg); - /* attempt to access a non-preserved register */ - return -UNW_EBADREG; -} - -static int -get_static_proc_name (unw_addr_space_t as, unw_word_t ip, - char *buf, size_t buf_len, unw_word_t *offp, - void *arg) -{ - return _Uelf32_get_proc_name (as, getpid (), ip, buf, buf_len, offp); -} - -HIDDEN void -x86_local_addr_space_init (void) -{ - memset (&local_addr_space, 0, sizeof (local_addr_space)); - local_addr_space.caching_policy = UNWI_DEFAULT_CACHING_POLICY; - local_addr_space.acc.find_proc_info = dwarf_find_proc_info; - local_addr_space.acc.put_unwind_info = put_unwind_info; - local_addr_space.acc.get_dyn_info_list_addr = get_dyn_info_list_addr; - local_addr_space.acc.access_mem = access_mem; - local_addr_space.acc.access_reg = access_reg; - local_addr_space.acc.access_fpreg = access_fpreg; - local_addr_space.acc.resume = x86_local_resume; - local_addr_space.acc.get_proc_name = get_static_proc_name; - unw_flush_cache (&local_addr_space, 0, 0); -} - -#endif /* !UNW_REMOTE_ONLY */ diff --git a/src/pal/src/libunwind/src/x86/Ginit_local.c b/src/pal/src/libunwind/src/x86/Ginit_local.c deleted file mode 100644 index bff068704..000000000 --- a/src/pal/src/libunwind/src/x86/Ginit_local.c +++ /dev/null @@ -1,79 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (c) 2002-2003 Hewlett-Packard Development Company, L.P. - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" -#include "init.h" - -#ifdef UNW_REMOTE_ONLY - -int -unw_init_local (unw_cursor_t *cursor, ucontext_t *uc) -{ - return -UNW_EINVAL; -} - -#else /* !UNW_REMOTE_ONLY */ - -static int -unw_init_local_common(unw_cursor_t *cursor, ucontext_t *uc, unsigned use_prev_instr) -{ - struct cursor *c = (struct cursor *) cursor; - - if (!tdep_init_done) - tdep_init (); - - Debug (1, "(cursor=%p)\n", c); - - c->dwarf.as = unw_local_addr_space; - c->dwarf.as_arg = c; - c->uc = uc; - c->validate = 0; - return common_init (c, use_prev_instr); -} - -int -unw_init_local (unw_cursor_t *cursor, ucontext_t *uc) -{ - return unw_init_local_common(cursor, uc, 1); -} - -int -unw_init_local2 (unw_cursor_t *cursor, ucontext_t *uc, int flag) -{ - if (!flag) - { - return unw_init_local_common(cursor, uc, 1); - } - else if (flag == UNW_INIT_SIGNAL_FRAME) - { - return unw_init_local_common(cursor, uc, 0); - } - else - { - return -UNW_EINVAL; - } -} - -#endif /* !UNW_REMOTE_ONLY */ diff --git a/src/pal/src/libunwind/src/x86/Ginit_remote.c b/src/pal/src/libunwind/src/x86/Ginit_remote.c deleted file mode 100644 index 7c15096e4..000000000 --- a/src/pal/src/libunwind/src/x86/Ginit_remote.c +++ /dev/null @@ -1,56 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (c) 2003 Hewlett-Packard Development Company, L.P. - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include "init.h" -#include "unwind_i.h" - -int -unw_init_remote (unw_cursor_t *cursor, unw_addr_space_t as, void *as_arg) -{ -#ifdef UNW_LOCAL_ONLY - return -UNW_EINVAL; -#else /* !UNW_LOCAL_ONLY */ - struct cursor *c = (struct cursor *) cursor; - - if (!tdep_init_done) - tdep_init (); - - Debug (1, "(cursor=%p)\n", c); - - c->dwarf.as = as; - c->dwarf.as_arg = as_arg; - if (as == unw_local_addr_space) - { - c->dwarf.as_arg = c; - c->uc = as_arg; - } - else - { - c->dwarf.as_arg = as_arg; - c->uc = 0; - } - return common_init (c, 0); -#endif /* !UNW_LOCAL_ONLY */ -} diff --git a/src/pal/src/libunwind/src/x86/Gos-freebsd.c b/src/pal/src/libunwind/src/x86/Gos-freebsd.c deleted file mode 100644 index 7dd014046..000000000 --- a/src/pal/src/libunwind/src/x86/Gos-freebsd.c +++ /dev/null @@ -1,374 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2010 Konstantin Belousov - -This file is part of libunwind. - -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. */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include -#include -#include -#include - -#include "unwind_i.h" -#include "offsets.h" - -int -unw_is_signal_frame (unw_cursor_t *cursor) -{ - struct cursor *c = (struct cursor *) cursor; - unw_word_t w0, w1, w2, w3, w4, w5, ip; - unw_addr_space_t as; - unw_accessors_t *a; - void *arg; - int ret; - - as = c->dwarf.as; - a = unw_get_accessors_int (as); - arg = c->dwarf.as_arg; - - /* Check if EIP points at sigreturn() sequence. It can be: -sigcode+4: from amd64 freebsd32 environment -8d 44 24 20 lea 0x20(%esp),%eax -50 push %eax -b8 a1 01 00 00 mov $0x1a1,%eax -50 push %eax -cd 80 int $0x80 - -sigcode+4: from real i386 -8d 44 24 20 lea 0x20(%esp),%eax -50 push %eax -f7 40 54 00 02 00 testl $0x20000,0x54(%eax) -75 03 jne sigcode+21 -8e 68 14 mov 0x14(%eax),%gs -b8 a1 01 00 00 mov $0x1a1,%eax -50 push %eax -cd 80 int $0x80 - -freebsd4_sigcode+4: -XXX -osigcode: -XXX - */ - ip = c->dwarf.ip; - ret = X86_SCF_NONE; - c->sigcontext_format = ret; - if ((*a->access_mem) (as, ip, &w0, 0, arg) < 0 || - (*a->access_mem) (as, ip + 4, &w1, 0, arg) < 0 || - (*a->access_mem) (as, ip + 8, &w2, 0, arg) < 0 || - (*a->access_mem) (as, ip + 12, &w3, 0, arg) < 0) - return ret; - if (w0 == 0x2024448d && w1 == 0x01a1b850 && w2 == 0xcd500000 && - (w3 & 0xff) == 0x80) - ret = X86_SCF_FREEBSD_SIGFRAME; - else { - if ((*a->access_mem) (as, ip + 16, &w4, 0, arg) < 0 || - (*a->access_mem) (as, ip + 20, &w5, 0, arg) < 0) - return ret; - if (w0 == 0x2024448d && w1 == 0x5440f750 && w2 == 0x75000200 && - w3 == 0x14688e03 && w4 == 0x0001a1b8 && w5 == 0x80cd5000) - ret = X86_SCF_FREEBSD_SIGFRAME; - } - - /* Check for syscall */ - if (ret == X86_SCF_NONE && (*a->access_mem) (as, ip - 2, &w0, 0, arg) >= 0 && - (w0 & 0xffff) == 0x80cd) - ret = X86_SCF_FREEBSD_SYSCALL; - Debug (16, "returning %d\n", ret); - c->sigcontext_format = ret; - return (ret); -} - -HIDDEN int -x86_handle_signal_frame (unw_cursor_t *cursor) -{ - struct cursor *c = (struct cursor *) cursor; - int ret; - - if (c->sigcontext_format == X86_SCF_FREEBSD_SIGFRAME) { - struct sigframe *sf; - uintptr_t uc_addr; - struct dwarf_loc esp_loc; - - sf = (struct sigframe *)c->dwarf.cfa; - uc_addr = (uintptr_t)&(sf->sf_uc); - c->sigcontext_addr = c->dwarf.cfa; - - esp_loc = DWARF_LOC (uc_addr + FREEBSD_UC_MCONTEXT_ESP_OFF, 0); - ret = dwarf_get (&c->dwarf, esp_loc, &c->dwarf.cfa); - if (ret < 0) - { - Debug (2, "returning 0\n"); - return 0; - } - - c->dwarf.loc[EIP] = DWARF_LOC (uc_addr + FREEBSD_UC_MCONTEXT_EIP_OFF, 0); - c->dwarf.loc[ESP] = DWARF_LOC (uc_addr + FREEBSD_UC_MCONTEXT_ESP_OFF, 0); - c->dwarf.loc[EAX] = DWARF_LOC (uc_addr + FREEBSD_UC_MCONTEXT_EAX_OFF, 0); - c->dwarf.loc[ECX] = DWARF_LOC (uc_addr + FREEBSD_UC_MCONTEXT_ECX_OFF, 0); - c->dwarf.loc[EDX] = DWARF_LOC (uc_addr + FREEBSD_UC_MCONTEXT_EDX_OFF, 0); - c->dwarf.loc[EBX] = DWARF_LOC (uc_addr + FREEBSD_UC_MCONTEXT_EBX_OFF, 0); - c->dwarf.loc[EBP] = DWARF_LOC (uc_addr + FREEBSD_UC_MCONTEXT_EBP_OFF, 0); - c->dwarf.loc[ESI] = DWARF_LOC (uc_addr + FREEBSD_UC_MCONTEXT_ESI_OFF, 0); - c->dwarf.loc[EDI] = DWARF_LOC (uc_addr + FREEBSD_UC_MCONTEXT_EDI_OFF, 0); - c->dwarf.loc[EFLAGS] = DWARF_LOC (uc_addr + FREEBSD_UC_MCONTEXT_EFLAGS_OFF, 0); - c->dwarf.loc[TRAPNO] = DWARF_LOC (uc_addr + FREEBSD_UC_MCONTEXT_TRAPNO_OFF, 0); - c->dwarf.loc[ST0] = DWARF_NULL_LOC; - } else if (c->sigcontext_format == X86_SCF_FREEBSD_SYSCALL) { - c->dwarf.loc[EIP] = DWARF_LOC (c->dwarf.cfa, 0); - c->dwarf.loc[EAX] = DWARF_NULL_LOC; - c->dwarf.cfa += 4; - c->dwarf.use_prev_instr = 1; - } else { - Debug (8, "Gstep: not handling frame format %d\n", c->sigcontext_format); - abort(); - } - return 0; -} - -HIDDEN dwarf_loc_t -x86_get_scratch_loc (struct cursor *c, unw_regnum_t reg) -{ - unw_word_t addr = c->sigcontext_addr, off, xmm_off; - unw_word_t fpstate, fpformat; - int ret, is_fpstate = 0, is_xmmstate = 0; - - switch (c->sigcontext_format) - { - case X86_SCF_NONE: - return DWARF_REG_LOC (&c->dwarf, reg); - - case X86_SCF_FREEBSD_SIGFRAME: - addr += offsetof(struct sigframe, sf_uc) + FREEBSD_UC_MCONTEXT_OFF; - break; - - case X86_SCF_FREEBSD_SIGFRAME4: - abort(); - break; - - case X86_SCF_FREEBSD_OSIGFRAME: - /* XXXKIB */ - abort(); - break; - - case X86_SCF_FREEBSD_SYSCALL: - /* XXXKIB */ - abort(); - break; - - default: - /* XXXKIB */ - abort(); - break; - } - - off = 0; /* shut gcc warning */ - switch (reg) - { - case UNW_X86_GS: off = FREEBSD_UC_MCONTEXT_GS_OFF; break; - case UNW_X86_FS: off = FREEBSD_UC_MCONTEXT_FS_OFF; break; - case UNW_X86_ES: off = FREEBSD_UC_MCONTEXT_ES_OFF; break; - case UNW_X86_DS: off = FREEBSD_UC_MCONTEXT_SS_OFF; break; - case UNW_X86_EDI: off = FREEBSD_UC_MCONTEXT_EDI_OFF; break; - case UNW_X86_ESI: off = FREEBSD_UC_MCONTEXT_ESI_OFF; break; - case UNW_X86_EBP: off = FREEBSD_UC_MCONTEXT_EBP_OFF; break; - case UNW_X86_ESP: off = FREEBSD_UC_MCONTEXT_ESP_OFF; break; - case UNW_X86_EBX: off = FREEBSD_UC_MCONTEXT_EBX_OFF; break; - case UNW_X86_EDX: off = FREEBSD_UC_MCONTEXT_EDX_OFF; break; - case UNW_X86_ECX: off = FREEBSD_UC_MCONTEXT_ECX_OFF; break; - case UNW_X86_EAX: off = FREEBSD_UC_MCONTEXT_EAX_OFF; break; - case UNW_X86_TRAPNO: off = FREEBSD_UC_MCONTEXT_TRAPNO_OFF; break; - case UNW_X86_EIP: off = FREEBSD_UC_MCONTEXT_EIP_OFF; break; - case UNW_X86_CS: off = FREEBSD_UC_MCONTEXT_CS_OFF; break; - case UNW_X86_EFLAGS: off = FREEBSD_UC_MCONTEXT_EFLAGS_OFF; break; - case UNW_X86_SS: off = FREEBSD_UC_MCONTEXT_SS_OFF; break; - - case UNW_X86_FCW: - is_fpstate = 1; - off = FREEBSD_UC_MCONTEXT_CW_OFF; - xmm_off = FREEBSD_UC_MCONTEXT_CW_XMM_OFF; - break; - case UNW_X86_FSW: - is_fpstate = 1; - off = FREEBSD_UC_MCONTEXT_SW_OFF; - xmm_off = FREEBSD_UC_MCONTEXT_SW_XMM_OFF; - break; - case UNW_X86_FTW: - is_fpstate = 1; - xmm_off = FREEBSD_UC_MCONTEXT_TAG_XMM_OFF; - off = FREEBSD_UC_MCONTEXT_TAG_OFF; - break; - case UNW_X86_FCS: - is_fpstate = 1; - off = FREEBSD_UC_MCONTEXT_CSSEL_OFF; - xmm_off = FREEBSD_UC_MCONTEXT_CSSEL_XMM_OFF; - break; - case UNW_X86_FIP: - is_fpstate = 1; - off = FREEBSD_UC_MCONTEXT_IPOFF_OFF; - xmm_off = FREEBSD_UC_MCONTEXT_IPOFF_XMM_OFF; - break; - case UNW_X86_FEA: - is_fpstate = 1; - off = FREEBSD_UC_MCONTEXT_DATAOFF_OFF; - xmm_off = FREEBSD_UC_MCONTEXT_DATAOFF_XMM_OFF; - break; - case UNW_X86_FDS: - is_fpstate = 1; - off = FREEBSD_US_MCONTEXT_DATASEL_OFF; - xmm_off = FREEBSD_US_MCONTEXT_DATASEL_XMM_OFF; - break; - case UNW_X86_MXCSR: - is_fpstate = 1; - is_xmmstate = 1; - xmm_off = FREEBSD_UC_MCONTEXT_MXCSR_XMM_OFF; - break; - - /* stacked fp registers */ - case UNW_X86_ST0: case UNW_X86_ST1: case UNW_X86_ST2: case UNW_X86_ST3: - case UNW_X86_ST4: case UNW_X86_ST5: case UNW_X86_ST6: case UNW_X86_ST7: - is_fpstate = 1; - off = FREEBSD_UC_MCONTEXT_ST0_OFF + 10*(reg - UNW_X86_ST0); - xmm_off = FREEBSD_UC_MCONTEXT_ST0_XMM_OFF + 10*(reg - UNW_X86_ST0); - break; - - /* SSE fp registers */ - case UNW_X86_XMM0_lo: case UNW_X86_XMM0_hi: - case UNW_X86_XMM1_lo: case UNW_X86_XMM1_hi: - case UNW_X86_XMM2_lo: case UNW_X86_XMM2_hi: - case UNW_X86_XMM3_lo: case UNW_X86_XMM3_hi: - case UNW_X86_XMM4_lo: case UNW_X86_XMM4_hi: - case UNW_X86_XMM5_lo: case UNW_X86_XMM5_hi: - case UNW_X86_XMM6_lo: case UNW_X86_XMM6_hi: - case UNW_X86_XMM7_lo: case UNW_X86_XMM7_hi: - is_fpstate = 1; - is_xmmstate = 1; - xmm_off = FREEBSD_UC_MCONTEXT_XMM0_OFF + 8*(reg - UNW_X86_XMM0_lo); - break; - case UNW_X86_XMM0: - case UNW_X86_XMM1: - case UNW_X86_XMM2: - case UNW_X86_XMM3: - case UNW_X86_XMM4: - case UNW_X86_XMM5: - case UNW_X86_XMM6: - case UNW_X86_XMM7: - is_fpstate = 1; - is_xmmstate = 1; - xmm_off = FREEBSD_UC_MCONTEXT_XMM0_OFF + 16*(reg - UNW_X86_XMM0); - break; - - case UNW_X86_FOP: - case UNW_X86_TSS: - case UNW_X86_LDT: - default: - return DWARF_REG_LOC (&c->dwarf, reg); - } - - if (is_fpstate) - { - if ((ret = dwarf_get (&c->dwarf, - DWARF_MEM_LOC (&c->dwarf, addr + FREEBSD_UC_MCONTEXT_FPSTATE_OFF), - &fpstate)) < 0) - return DWARF_NULL_LOC; - if (fpstate == FREEBSD_UC_MCONTEXT_FPOWNED_NONE) - return DWARF_NULL_LOC; - if ((ret = dwarf_get (&c->dwarf, - DWARF_MEM_LOC (&c->dwarf, addr + FREEBSD_UC_MCONTEXT_FPFORMAT_OFF), - &fpformat)) < 0) - return DWARF_NULL_LOC; - if (fpformat == FREEBSD_UC_MCONTEXT_FPFMT_NODEV || - (is_xmmstate && fpformat != FREEBSD_UC_MCONTEXT_FPFMT_XMM)) - return DWARF_NULL_LOC; - if (is_xmmstate) - off = xmm_off; - } - - return DWARF_MEM_LOC (c, addr + off); -} - -#ifndef UNW_REMOTE_ONLY -HIDDEN void * -x86_r_uc_addr (ucontext_t *uc, int reg) -{ - void *addr; - - switch (reg) - { - case UNW_X86_GS: addr = &uc->uc_mcontext.mc_gs; break; - case UNW_X86_FS: addr = &uc->uc_mcontext.mc_fs; break; - case UNW_X86_ES: addr = &uc->uc_mcontext.mc_es; break; - case UNW_X86_DS: addr = &uc->uc_mcontext.mc_ds; break; - case UNW_X86_EAX: addr = &uc->uc_mcontext.mc_eax; break; - case UNW_X86_EBX: addr = &uc->uc_mcontext.mc_ebx; break; - case UNW_X86_ECX: addr = &uc->uc_mcontext.mc_ecx; break; - case UNW_X86_EDX: addr = &uc->uc_mcontext.mc_edx; break; - case UNW_X86_ESI: addr = &uc->uc_mcontext.mc_esi; break; - case UNW_X86_EDI: addr = &uc->uc_mcontext.mc_edi; break; - case UNW_X86_EBP: addr = &uc->uc_mcontext.mc_ebp; break; - case UNW_X86_EIP: addr = &uc->uc_mcontext.mc_eip; break; - case UNW_X86_ESP: addr = &uc->uc_mcontext.mc_esp; break; - case UNW_X86_TRAPNO: addr = &uc->uc_mcontext.mc_trapno; break; - case UNW_X86_CS: addr = &uc->uc_mcontext.mc_cs; break; - case UNW_X86_EFLAGS: addr = &uc->uc_mcontext.mc_eflags; break; - case UNW_X86_SS: addr = &uc->uc_mcontext.mc_ss; break; - - default: - addr = NULL; - } - return addr; -} - -HIDDEN int -x86_local_resume (unw_addr_space_t as, unw_cursor_t *cursor, void *arg) -{ - struct cursor *c = (struct cursor *) cursor; - ucontext_t *uc = c->uc; - - /* Ensure c->pi is up-to-date. On x86, it's relatively common to be - missing DWARF unwind info. We don't want to fail in that case, - because the frame-chain still would let us do a backtrace at - least. */ - dwarf_make_proc_info (&c->dwarf); - - if (c->sigcontext_format == X86_SCF_NONE) { - Debug (8, "resuming at ip=%x via setcontext()\n", c->dwarf.ip); - setcontext (uc); - abort(); - } else if (c->sigcontext_format == X86_SCF_FREEBSD_SIGFRAME) { - struct sigcontext *sc = (struct sigcontext *) c->sigcontext_addr; - - Debug (8, "resuming at ip=%x via sigreturn(%p)\n", c->dwarf.ip, sc); - sigreturn((ucontext_t *)((const char *)sc + FREEBSD_SC_UCONTEXT_OFF)); - abort(); - } else { - Debug (8, "resuming at ip=%x for sigcontext format %d not implemented\n", - c->dwarf.ip, c->sigcontext_format); - abort(); - } - return -UNW_EINVAL; -} - -#endif diff --git a/src/pal/src/libunwind/src/x86/Gos-linux.c b/src/pal/src/libunwind/src/x86/Gos-linux.c deleted file mode 100644 index fb9a5e346..000000000 --- a/src/pal/src/libunwind/src/x86/Gos-linux.c +++ /dev/null @@ -1,331 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2002-2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" -#include "offsets.h" - -#include - -int -unw_is_signal_frame (unw_cursor_t *cursor) -{ - struct cursor *c = (struct cursor *) cursor; - unw_word_t w0, w1, ip; - unw_addr_space_t as; - unw_accessors_t *a; - void *arg; - int ret; - - as = c->dwarf.as; - a = unw_get_accessors_int (as); - arg = c->dwarf.as_arg; - - /* Check if EIP points at sigreturn() sequence. On Linux, this is: - - __restore: - 0x58 pop %eax - 0xb8 0x77 0x00 0x00 0x00 movl 0x77,%eax - 0xcd 0x80 int 0x80 - - without SA_SIGINFO, and - - __restore_rt: - 0xb8 0xad 0x00 0x00 0x00 movl 0xad,%eax - 0xcd 0x80 int 0x80 - 0x00 - - if SA_SIGINFO is specified. - */ - ip = c->dwarf.ip; - if ((*a->access_mem) (as, ip, &w0, 0, arg) < 0 - || (*a->access_mem) (as, ip + 4, &w1, 0, arg) < 0) - ret = 0; - else - ret = ((w0 == 0x0077b858 && w1 == 0x80cd0000) - || (w0 == 0x0000adb8 && (w1 & 0xffffff) == 0x80cd00)); - Debug (16, "returning %d\n", ret); - return ret; -} - -HIDDEN int -x86_handle_signal_frame (unw_cursor_t *cursor) -{ - struct cursor *c = (struct cursor *) cursor; - int ret; - - /* c->esp points at the arguments to the handler. Without - SA_SIGINFO, the arguments consist of a signal number - followed by a struct sigcontext. With SA_SIGINFO, the - arguments consist a signal number, a siginfo *, and a - ucontext *. */ - unw_word_t sc_addr; - unw_word_t siginfo_ptr_addr = c->dwarf.cfa + 4; - unw_word_t sigcontext_ptr_addr = c->dwarf.cfa + 8; - unw_word_t siginfo_ptr, sigcontext_ptr; - struct dwarf_loc esp_loc, siginfo_ptr_loc, sigcontext_ptr_loc; - - siginfo_ptr_loc = DWARF_LOC (siginfo_ptr_addr, 0); - sigcontext_ptr_loc = DWARF_LOC (sigcontext_ptr_addr, 0); - ret = (dwarf_get (&c->dwarf, siginfo_ptr_loc, &siginfo_ptr) - | dwarf_get (&c->dwarf, sigcontext_ptr_loc, &sigcontext_ptr)); - if (ret < 0) - { - Debug (2, "returning 0\n"); - return 0; - } - if (siginfo_ptr < c->dwarf.cfa - || siginfo_ptr > c->dwarf.cfa + 256 - || sigcontext_ptr < c->dwarf.cfa - || sigcontext_ptr > c->dwarf.cfa + 256) - { - /* Not plausible for SA_SIGINFO signal */ - c->sigcontext_format = X86_SCF_LINUX_SIGFRAME; - c->sigcontext_addr = sc_addr = c->dwarf.cfa + 4; - } - else - { - /* If SA_SIGINFO were not specified, we actually read - various segment pointers instead. We believe that at - least fs and _fsh are always zero for linux, so it is - not just unlikely, but impossible that we would end - up here. */ - c->sigcontext_format = X86_SCF_LINUX_RT_SIGFRAME; - c->sigcontext_addr = sigcontext_ptr; - sc_addr = sigcontext_ptr + LINUX_UC_MCONTEXT_OFF; - } - esp_loc = DWARF_LOC (sc_addr + LINUX_SC_ESP_OFF, 0); - ret = dwarf_get (&c->dwarf, esp_loc, &c->dwarf.cfa); - if (ret < 0) - { - Debug (2, "returning 0\n"); - return 0; - } - - c->dwarf.loc[EAX] = DWARF_LOC (sc_addr + LINUX_SC_EAX_OFF, 0); - c->dwarf.loc[ECX] = DWARF_LOC (sc_addr + LINUX_SC_ECX_OFF, 0); - c->dwarf.loc[EDX] = DWARF_LOC (sc_addr + LINUX_SC_EDX_OFF, 0); - c->dwarf.loc[EBX] = DWARF_LOC (sc_addr + LINUX_SC_EBX_OFF, 0); - c->dwarf.loc[EBP] = DWARF_LOC (sc_addr + LINUX_SC_EBP_OFF, 0); - c->dwarf.loc[ESI] = DWARF_LOC (sc_addr + LINUX_SC_ESI_OFF, 0); - c->dwarf.loc[EDI] = DWARF_LOC (sc_addr + LINUX_SC_EDI_OFF, 0); - c->dwarf.loc[EFLAGS] = DWARF_NULL_LOC; - c->dwarf.loc[TRAPNO] = DWARF_NULL_LOC; - c->dwarf.loc[ST0] = DWARF_NULL_LOC; - c->dwarf.loc[EIP] = DWARF_LOC (sc_addr + LINUX_SC_EIP_OFF, 0); - c->dwarf.loc[ESP] = DWARF_LOC (sc_addr + LINUX_SC_ESP_OFF, 0); - - return 0; -} - -HIDDEN dwarf_loc_t -x86_get_scratch_loc (struct cursor *c, unw_regnum_t reg) -{ - unw_word_t addr = c->sigcontext_addr, fpstate_addr, off; - int ret, is_fpstate = 0; - - switch (c->sigcontext_format) - { - case X86_SCF_NONE: - return DWARF_REG_LOC (&c->dwarf, reg); - - case X86_SCF_LINUX_SIGFRAME: - break; - - case X86_SCF_LINUX_RT_SIGFRAME: - addr += LINUX_UC_MCONTEXT_OFF; - break; - - default: - return DWARF_NULL_LOC; - } - - switch (reg) - { - case UNW_X86_GS: off = LINUX_SC_GS_OFF; break; - case UNW_X86_FS: off = LINUX_SC_FS_OFF; break; - case UNW_X86_ES: off = LINUX_SC_ES_OFF; break; - case UNW_X86_DS: off = LINUX_SC_DS_OFF; break; - case UNW_X86_EDI: off = LINUX_SC_EDI_OFF; break; - case UNW_X86_ESI: off = LINUX_SC_ESI_OFF; break; - case UNW_X86_EBP: off = LINUX_SC_EBP_OFF; break; - case UNW_X86_ESP: off = LINUX_SC_ESP_OFF; break; - case UNW_X86_EBX: off = LINUX_SC_EBX_OFF; break; - case UNW_X86_EDX: off = LINUX_SC_EDX_OFF; break; - case UNW_X86_ECX: off = LINUX_SC_ECX_OFF; break; - case UNW_X86_EAX: off = LINUX_SC_EAX_OFF; break; - case UNW_X86_TRAPNO: off = LINUX_SC_TRAPNO_OFF; break; - case UNW_X86_EIP: off = LINUX_SC_EIP_OFF; break; - case UNW_X86_CS: off = LINUX_SC_CS_OFF; break; - case UNW_X86_EFLAGS: off = LINUX_SC_EFLAGS_OFF; break; - case UNW_X86_SS: off = LINUX_SC_SS_OFF; break; - - /* The following is probably not correct for all possible cases. - Somebody who understands this better should review this for - correctness. */ - - case UNW_X86_FCW: is_fpstate = 1; off = LINUX_FPSTATE_CW_OFF; break; - case UNW_X86_FSW: is_fpstate = 1; off = LINUX_FPSTATE_SW_OFF; break; - case UNW_X86_FTW: is_fpstate = 1; off = LINUX_FPSTATE_TAG_OFF; break; - case UNW_X86_FCS: is_fpstate = 1; off = LINUX_FPSTATE_CSSEL_OFF; break; - case UNW_X86_FIP: is_fpstate = 1; off = LINUX_FPSTATE_IPOFF_OFF; break; - case UNW_X86_FEA: is_fpstate = 1; off = LINUX_FPSTATE_DATAOFF_OFF; break; - case UNW_X86_FDS: is_fpstate = 1; off = LINUX_FPSTATE_DATASEL_OFF; break; - case UNW_X86_MXCSR: is_fpstate = 1; off = LINUX_FPSTATE_MXCSR_OFF; break; - - /* stacked fp registers */ - case UNW_X86_ST0: case UNW_X86_ST1: case UNW_X86_ST2: case UNW_X86_ST3: - case UNW_X86_ST4: case UNW_X86_ST5: case UNW_X86_ST6: case UNW_X86_ST7: - is_fpstate = 1; - off = LINUX_FPSTATE_ST0_OFF + 10*(reg - UNW_X86_ST0); - break; - - /* SSE fp registers */ - case UNW_X86_XMM0_lo: case UNW_X86_XMM0_hi: - case UNW_X86_XMM1_lo: case UNW_X86_XMM1_hi: - case UNW_X86_XMM2_lo: case UNW_X86_XMM2_hi: - case UNW_X86_XMM3_lo: case UNW_X86_XMM3_hi: - case UNW_X86_XMM4_lo: case UNW_X86_XMM4_hi: - case UNW_X86_XMM5_lo: case UNW_X86_XMM5_hi: - case UNW_X86_XMM6_lo: case UNW_X86_XMM6_hi: - case UNW_X86_XMM7_lo: case UNW_X86_XMM7_hi: - is_fpstate = 1; - off = LINUX_FPSTATE_XMM0_OFF + 8*(reg - UNW_X86_XMM0_lo); - break; - case UNW_X86_XMM0: - case UNW_X86_XMM1: - case UNW_X86_XMM2: - case UNW_X86_XMM3: - case UNW_X86_XMM4: - case UNW_X86_XMM5: - case UNW_X86_XMM6: - case UNW_X86_XMM7: - is_fpstate = 1; - off = LINUX_FPSTATE_XMM0_OFF + 16*(reg - UNW_X86_XMM0); - break; - - case UNW_X86_FOP: - case UNW_X86_TSS: - case UNW_X86_LDT: - default: - return DWARF_REG_LOC (&c->dwarf, reg); - } - - if (is_fpstate) - { - if ((ret = dwarf_get (&c->dwarf, - DWARF_MEM_LOC (&c->dwarf, - addr + LINUX_SC_FPSTATE_OFF), - &fpstate_addr)) < 0) - return DWARF_NULL_LOC; - - if (!fpstate_addr) - return DWARF_NULL_LOC; - - return DWARF_MEM_LOC (c, fpstate_addr + off); - } - else - return DWARF_MEM_LOC (c, addr + off); -} - -#ifndef UNW_REMOTE_ONLY -HIDDEN void * -x86_r_uc_addr (ucontext_t *uc, int reg) -{ - void *addr; - - switch (reg) - { - case UNW_X86_GS: addr = &uc->uc_mcontext.gregs[REG_GS]; break; - case UNW_X86_FS: addr = &uc->uc_mcontext.gregs[REG_FS]; break; - case UNW_X86_ES: addr = &uc->uc_mcontext.gregs[REG_ES]; break; - case UNW_X86_DS: addr = &uc->uc_mcontext.gregs[REG_DS]; break; - case UNW_X86_EAX: addr = &uc->uc_mcontext.gregs[REG_EAX]; break; - case UNW_X86_EBX: addr = &uc->uc_mcontext.gregs[REG_EBX]; break; - case UNW_X86_ECX: addr = &uc->uc_mcontext.gregs[REG_ECX]; break; - case UNW_X86_EDX: addr = &uc->uc_mcontext.gregs[REG_EDX]; break; - case UNW_X86_ESI: addr = &uc->uc_mcontext.gregs[REG_ESI]; break; - case UNW_X86_EDI: addr = &uc->uc_mcontext.gregs[REG_EDI]; break; - case UNW_X86_EBP: addr = &uc->uc_mcontext.gregs[REG_EBP]; break; - case UNW_X86_EIP: addr = &uc->uc_mcontext.gregs[REG_EIP]; break; - case UNW_X86_ESP: addr = &uc->uc_mcontext.gregs[REG_ESP]; break; - case UNW_X86_TRAPNO: addr = &uc->uc_mcontext.gregs[REG_TRAPNO]; break; - case UNW_X86_CS: addr = &uc->uc_mcontext.gregs[REG_CS]; break; - case UNW_X86_EFLAGS: addr = &uc->uc_mcontext.gregs[REG_EFL]; break; - case UNW_X86_SS: addr = &uc->uc_mcontext.gregs[REG_SS]; break; - - default: - addr = NULL; - } - return addr; -} - -HIDDEN int -x86_local_resume (unw_addr_space_t as, unw_cursor_t *cursor, void *arg) -{ - struct cursor *c = (struct cursor *) cursor; - ucontext_t *uc = c->uc; - - /* Ensure c->pi is up-to-date. On x86, it's relatively common to be - missing DWARF unwind info. We don't want to fail in that case, - because the frame-chain still would let us do a backtrace at - least. */ - dwarf_make_proc_info (&c->dwarf); - - if (unlikely (c->sigcontext_format != X86_SCF_NONE)) - { - struct sigcontext *sc = (struct sigcontext *) c->sigcontext_addr; - - Debug (8, "resuming at ip=%x via sigreturn(%p)\n", c->dwarf.ip, sc); - x86_sigreturn (sc); - } - else - { - Debug (8, "resuming at ip=%x via setcontext()\n", c->dwarf.ip); - setcontext (uc); - } - return -UNW_EINVAL; -} - -/* sigreturn() is a no-op on x86 glibc. */ -HIDDEN void -x86_sigreturn (unw_cursor_t *cursor) -{ - struct cursor *c = (struct cursor *) cursor; - struct sigcontext *sc = (struct sigcontext *) c->sigcontext_addr; - mcontext_t *sc_mcontext = &((ucontext_t*)sc)->uc_mcontext; - /* Copy in saved uc - all preserved regs are at the start of sigcontext */ - memcpy(sc_mcontext, &c->uc->uc_mcontext, - DWARF_NUM_PRESERVED_REGS * sizeof(unw_word_t)); - - Debug (8, "resuming at ip=%llx via sigreturn(%p)\n", - (unsigned long long) c->dwarf.ip, sc); - __asm__ __volatile__ ("mov %0, %%esp;" - "mov %1, %%eax;" - "syscall" - :: "r"(sc), "i"(SYS_rt_sigreturn) - : "memory"); - abort(); -} -#endif diff --git a/src/pal/src/libunwind/src/x86/Greg_states_iterate.c b/src/pal/src/libunwind/src/x86/Greg_states_iterate.c deleted file mode 100644 index a17dc1b56..000000000 --- a/src/pal/src/libunwind/src/x86/Greg_states_iterate.c +++ /dev/null @@ -1,37 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (c) 2002-2003 Hewlett-Packard Development Company, L.P. - Contributed by David Mosberger-Tang - - Modified for x86_64 by Max Asbock - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" - -int -unw_reg_states_iterate (unw_cursor_t *cursor, - unw_reg_states_callback cb, void *token) -{ - struct cursor *c = (struct cursor *) cursor; - - return dwarf_reg_states_iterate (&c->dwarf, cb, token); -} diff --git a/src/pal/src/libunwind/src/x86/Gregs.c b/src/pal/src/libunwind/src/x86/Gregs.c deleted file mode 100644 index 4a9592617..000000000 --- a/src/pal/src/libunwind/src/x86/Gregs.c +++ /dev/null @@ -1,178 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (c) 2002-2004 Hewlett-Packard Development Company, L.P. - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include "offsets.h" -#include "unwind_i.h" - -HIDDEN dwarf_loc_t -x86_scratch_loc (struct cursor *c, unw_regnum_t reg) -{ - if (c->sigcontext_addr) - return x86_get_scratch_loc (c, reg); - else - return DWARF_REG_LOC (&c->dwarf, reg); -} - -HIDDEN int -tdep_access_reg (struct cursor *c, unw_regnum_t reg, unw_word_t *valp, - int write) -{ - dwarf_loc_t loc = DWARF_NULL_LOC; - unsigned int mask; - int arg_num; - - switch (reg) - { - - case UNW_X86_EIP: - if (write) - c->dwarf.ip = *valp; /* also update the EIP cache */ - loc = c->dwarf.loc[EIP]; - break; - - case UNW_X86_CFA: - case UNW_X86_ESP: - if (write) - return -UNW_EREADONLYREG; - *valp = c->dwarf.cfa; - return 0; - - case UNW_X86_EAX: - case UNW_X86_EDX: - arg_num = reg - UNW_X86_EAX; - mask = (1 << arg_num); - if (write) - { - c->dwarf.eh_args[arg_num] = *valp; - c->dwarf.eh_valid_mask |= mask; - return 0; - } - else if ((c->dwarf.eh_valid_mask & mask) != 0) - { - *valp = c->dwarf.eh_args[arg_num]; - return 0; - } - else - loc = c->dwarf.loc[(reg == UNW_X86_EAX) ? EAX : EDX]; - break; - - case UNW_X86_ECX: loc = c->dwarf.loc[ECX]; break; - case UNW_X86_EBX: loc = c->dwarf.loc[EBX]; break; - - case UNW_X86_EBP: loc = c->dwarf.loc[EBP]; break; - case UNW_X86_ESI: loc = c->dwarf.loc[ESI]; break; - case UNW_X86_EDI: loc = c->dwarf.loc[EDI]; break; - case UNW_X86_EFLAGS: loc = c->dwarf.loc[EFLAGS]; break; - case UNW_X86_TRAPNO: loc = c->dwarf.loc[TRAPNO]; break; - - case UNW_X86_FCW: - case UNW_X86_FSW: - case UNW_X86_FTW: - case UNW_X86_FOP: - case UNW_X86_FCS: - case UNW_X86_FIP: - case UNW_X86_FEA: - case UNW_X86_FDS: - case UNW_X86_MXCSR: - case UNW_X86_GS: - case UNW_X86_FS: - case UNW_X86_ES: - case UNW_X86_DS: - case UNW_X86_SS: - case UNW_X86_CS: - case UNW_X86_TSS: - case UNW_X86_LDT: - loc = x86_scratch_loc (c, reg); - break; - - default: - Debug (1, "bad register number %u\n", reg); - return -UNW_EBADREG; - } - - if (write) - return dwarf_put (&c->dwarf, loc, *valp); - else - return dwarf_get (&c->dwarf, loc, valp); -} - -HIDDEN int -tdep_access_fpreg (struct cursor *c, unw_regnum_t reg, unw_fpreg_t *valp, - int write) -{ - struct dwarf_loc loc = DWARF_NULL_LOC; - - switch (reg) - { - case UNW_X86_ST0: - loc = c->dwarf.loc[ST0]; - break; - - /* stacked fp registers */ - case UNW_X86_ST1: - case UNW_X86_ST2: - case UNW_X86_ST3: - case UNW_X86_ST4: - case UNW_X86_ST5: - case UNW_X86_ST6: - case UNW_X86_ST7: - /* SSE fp registers */ - case UNW_X86_XMM0: - case UNW_X86_XMM1: - case UNW_X86_XMM2: - case UNW_X86_XMM3: - case UNW_X86_XMM4: - case UNW_X86_XMM5: - case UNW_X86_XMM6: - case UNW_X86_XMM7: - case UNW_X86_XMM0_lo: - case UNW_X86_XMM0_hi: - case UNW_X86_XMM1_lo: - case UNW_X86_XMM1_hi: - case UNW_X86_XMM2_lo: - case UNW_X86_XMM2_hi: - case UNW_X86_XMM3_lo: - case UNW_X86_XMM3_hi: - case UNW_X86_XMM4_lo: - case UNW_X86_XMM4_hi: - case UNW_X86_XMM5_lo: - case UNW_X86_XMM5_hi: - case UNW_X86_XMM6_lo: - case UNW_X86_XMM6_hi: - case UNW_X86_XMM7_lo: - case UNW_X86_XMM7_hi: - loc = x86_scratch_loc (c, reg); - break; - - default: - Debug (1, "bad register number %u\n", reg); - return -UNW_EBADREG; - } - - if (write) - return dwarf_putfp (&c->dwarf, loc, *valp); - else - return dwarf_getfp (&c->dwarf, loc, valp); -} diff --git a/src/pal/src/libunwind/src/x86/Gresume.c b/src/pal/src/libunwind/src/x86/Gresume.c deleted file mode 100644 index 5072c4ba0..000000000 --- a/src/pal/src/libunwind/src/x86/Gresume.c +++ /dev/null @@ -1,91 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (c) 2002-2004 Hewlett-Packard Development Company, L.P. - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include - -#include "unwind_i.h" -#include "offsets.h" - -/* This routine is responsible for copying the register values in - cursor C and establishing them as the current machine state. */ - -static inline int -establish_machine_state (struct cursor *c) -{ - int (*access_reg) (unw_addr_space_t, unw_regnum_t, unw_word_t *, - int write, void *); - int (*access_fpreg) (unw_addr_space_t, unw_regnum_t, unw_fpreg_t *, - int write, void *); - unw_addr_space_t as = c->dwarf.as; - void *arg = c->dwarf.as_arg; - unw_fpreg_t fpval; - unw_word_t val; - int reg; - - access_reg = as->acc.access_reg; - access_fpreg = as->acc.access_fpreg; - - Debug (8, "copying out cursor state\n"); - - for (reg = 0; reg <= UNW_REG_LAST; ++reg) - { - Debug (16, "copying %s %d\n", unw_regname (reg), reg); - if (unw_is_fpreg (reg)) - { - if (tdep_access_fpreg (c, reg, &fpval, 0) >= 0) - (*access_fpreg) (as, reg, &fpval, 1, arg); - } - else - { - if (tdep_access_reg (c, reg, &val, 0) >= 0) - (*access_reg) (as, reg, &val, 1, arg); - } - } - - if (c->dwarf.args_size) - { - if (tdep_access_reg (c, UNW_X86_ESP, &val, 0) >= 0) - { - val += c->dwarf.args_size; - (*access_reg) (as, UNW_X86_ESP, &val, 1, arg); - } - } - return 0; -} - -int -unw_resume (unw_cursor_t *cursor) -{ - struct cursor *c = (struct cursor *) cursor; - int ret; - - Debug (1, "(cursor=%p)\n", c); - - if ((ret = establish_machine_state (c)) < 0) - return ret; - - return (*c->dwarf.as->acc.resume) (c->dwarf.as, (unw_cursor_t *) c, - c->dwarf.as_arg); -} diff --git a/src/pal/src/libunwind/src/x86/Gstep.c b/src/pal/src/libunwind/src/x86/Gstep.c deleted file mode 100644 index 129b739a3..000000000 --- a/src/pal/src/libunwind/src/x86/Gstep.c +++ /dev/null @@ -1,115 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2002-2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" -#include "offsets.h" - -int -unw_step (unw_cursor_t *cursor) -{ - struct cursor *c = (struct cursor *) cursor; - int ret, i; - - Debug (1, "(cursor=%p, ip=0x%08x)\n", c, (unsigned) c->dwarf.ip); - - /* Try DWARF-based unwinding... */ - ret = dwarf_step (&c->dwarf); - - if (ret < 0 && ret != -UNW_ENOINFO) - { - Debug (2, "returning %d\n", ret); - return ret; - } - - if (unlikely (ret < 0)) - { - /* DWARF failed, let's see if we can follow the frame-chain - or skip over the signal trampoline. */ - struct dwarf_loc ebp_loc, eip_loc; - - /* We could get here because of missing/bad unwind information. - Validate all addresses before dereferencing. */ - c->validate = 1; - - Debug (13, "dwarf_step() failed (ret=%d), trying frame-chain\n", ret); - - if (unw_is_signal_frame (cursor) > 0) - { - ret = x86_handle_signal_frame(cursor); - if (ret < 0) - { - Debug (2, "returning 0\n"); - return 0; - } - } - else - { - ret = dwarf_get (&c->dwarf, c->dwarf.loc[EBP], &c->dwarf.cfa); - if (ret < 0) - { - Debug (2, "returning %d\n", ret); - return ret; - } - - Debug (13, "[EBP=0x%x] = 0x%x\n", DWARF_GET_LOC (c->dwarf.loc[EBP]), - c->dwarf.cfa); - - ebp_loc = DWARF_LOC (c->dwarf.cfa, 0); - eip_loc = DWARF_LOC (c->dwarf.cfa + 4, 0); - c->dwarf.cfa += 8; - - /* Mark all registers unsaved, since we don't know where - they are saved (if at all), except for the EBP and - EIP. */ - for (i = 0; i < DWARF_NUM_PRESERVED_REGS; ++i) - c->dwarf.loc[i] = DWARF_NULL_LOC; - - c->dwarf.loc[EBP] = ebp_loc; - c->dwarf.loc[EIP] = eip_loc; - c->dwarf.use_prev_instr = 1; - } - - if (!DWARF_IS_NULL_LOC (c->dwarf.loc[EBP])) - { - ret = dwarf_get (&c->dwarf, c->dwarf.loc[EIP], &c->dwarf.ip); - if (ret < 0) - { - Debug (13, "dwarf_get([EIP=0x%x]) failed\n", DWARF_GET_LOC (c->dwarf.loc[EIP])); - Debug (2, "returning %d\n", ret); - return ret; - } - else - { - Debug (13, "[EIP=0x%x] = 0x%x\n", DWARF_GET_LOC (c->dwarf.loc[EIP]), - c->dwarf.ip); - } - } - else - c->dwarf.ip = 0; - } - ret = (c->dwarf.ip == 0) ? 0 : 1; - Debug (2, "returning %d\n", ret); - return ret; -} diff --git a/src/pal/src/libunwind/src/x86/Lapply_reg_state.c b/src/pal/src/libunwind/src/x86/Lapply_reg_state.c deleted file mode 100644 index 7ebada480..000000000 --- a/src/pal/src/libunwind/src/x86/Lapply_reg_state.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gapply_reg_state.c" -#endif diff --git a/src/pal/src/libunwind/src/x86/Lcreate_addr_space.c b/src/pal/src/libunwind/src/x86/Lcreate_addr_space.c deleted file mode 100644 index 0f2dc6be9..000000000 --- a/src/pal/src/libunwind/src/x86/Lcreate_addr_space.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gcreate_addr_space.c" -#endif diff --git a/src/pal/src/libunwind/src/x86/Lget_proc_info.c b/src/pal/src/libunwind/src/x86/Lget_proc_info.c deleted file mode 100644 index 69028b019..000000000 --- a/src/pal/src/libunwind/src/x86/Lget_proc_info.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gget_proc_info.c" -#endif diff --git a/src/pal/src/libunwind/src/x86/Lget_save_loc.c b/src/pal/src/libunwind/src/x86/Lget_save_loc.c deleted file mode 100644 index 9ea048a90..000000000 --- a/src/pal/src/libunwind/src/x86/Lget_save_loc.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gget_save_loc.c" -#endif diff --git a/src/pal/src/libunwind/src/x86/Lglobal.c b/src/pal/src/libunwind/src/x86/Lglobal.c deleted file mode 100644 index 6d7b489e1..000000000 --- a/src/pal/src/libunwind/src/x86/Lglobal.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gglobal.c" -#endif diff --git a/src/pal/src/libunwind/src/x86/Linit.c b/src/pal/src/libunwind/src/x86/Linit.c deleted file mode 100644 index e9abfdd46..000000000 --- a/src/pal/src/libunwind/src/x86/Linit.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Ginit.c" -#endif diff --git a/src/pal/src/libunwind/src/x86/Linit_local.c b/src/pal/src/libunwind/src/x86/Linit_local.c deleted file mode 100644 index 68a1687e8..000000000 --- a/src/pal/src/libunwind/src/x86/Linit_local.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Ginit_local.c" -#endif diff --git a/src/pal/src/libunwind/src/x86/Linit_remote.c b/src/pal/src/libunwind/src/x86/Linit_remote.c deleted file mode 100644 index 58cb04ab7..000000000 --- a/src/pal/src/libunwind/src/x86/Linit_remote.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Ginit_remote.c" -#endif diff --git a/src/pal/src/libunwind/src/x86/Los-freebsd.c b/src/pal/src/libunwind/src/x86/Los-freebsd.c deleted file mode 100644 index a75a205df..000000000 --- a/src/pal/src/libunwind/src/x86/Los-freebsd.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gos-freebsd.c" -#endif diff --git a/src/pal/src/libunwind/src/x86/Los-linux.c b/src/pal/src/libunwind/src/x86/Los-linux.c deleted file mode 100644 index 3cc18aabc..000000000 --- a/src/pal/src/libunwind/src/x86/Los-linux.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gos-linux.c" -#endif diff --git a/src/pal/src/libunwind/src/x86/Lreg_states_iterate.c b/src/pal/src/libunwind/src/x86/Lreg_states_iterate.c deleted file mode 100644 index f1eb1e79d..000000000 --- a/src/pal/src/libunwind/src/x86/Lreg_states_iterate.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Greg_states_iterate.c" -#endif diff --git a/src/pal/src/libunwind/src/x86/Lregs.c b/src/pal/src/libunwind/src/x86/Lregs.c deleted file mode 100644 index 2c9c75cd7..000000000 --- a/src/pal/src/libunwind/src/x86/Lregs.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gregs.c" -#endif diff --git a/src/pal/src/libunwind/src/x86/Lresume.c b/src/pal/src/libunwind/src/x86/Lresume.c deleted file mode 100644 index 41a8cf003..000000000 --- a/src/pal/src/libunwind/src/x86/Lresume.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gresume.c" -#endif diff --git a/src/pal/src/libunwind/src/x86/Lstep.c b/src/pal/src/libunwind/src/x86/Lstep.c deleted file mode 100644 index c1ac3c754..000000000 --- a/src/pal/src/libunwind/src/x86/Lstep.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gstep.c" -#endif diff --git a/src/pal/src/libunwind/src/x86/getcontext-freebsd.S b/src/pal/src/libunwind/src/x86/getcontext-freebsd.S deleted file mode 100644 index 670eff1ae..000000000 --- a/src/pal/src/libunwind/src/x86/getcontext-freebsd.S +++ /dev/null @@ -1,112 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2010 Konstantin Belousov - -This file is part of libunwind. - -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. */ - -#include "offsets.h" - - .global _Ux86_getcontext - .type _Ux86_getcontext, @function -_Ux86_getcontext: - .cfi_startproc - pushl %eax - .cfi_adjust_cfa_offset 4 - mov 8(%esp),%eax /* ucontext_t* */ - popl FREEBSD_UC_MCONTEXT_EAX_OFF(%eax) - .cfi_adjust_cfa_offset 4 - movl %ebx, FREEBSD_UC_MCONTEXT_EBX_OFF(%eax) - movl %ecx, FREEBSD_UC_MCONTEXT_ECX_OFF(%eax) - movl %edx, FREEBSD_UC_MCONTEXT_EDX_OFF(%eax) - movl %edi, FREEBSD_UC_MCONTEXT_EDI_OFF(%eax) - movl %esi, FREEBSD_UC_MCONTEXT_ESI_OFF(%eax) - movl %ebp, FREEBSD_UC_MCONTEXT_EBP_OFF(%eax) - - movl (%esp), %ecx - movl %ecx, FREEBSD_UC_MCONTEXT_EIP_OFF(%eax) - - leal 4(%esp), %ecx /* Exclude the return address. */ - movl %ecx, FREEBSD_UC_MCONTEXT_ESP_OFF(%eax) - - xorl %ecx, %ecx - movw %fs, %cx - movl %ecx, FREEBSD_UC_MCONTEXT_FS_OFF(%eax) - movw %gs, %cx - movl %ecx, FREEBSD_UC_MCONTEXT_GS_OFF(%eax) - movw %ds, %cx - movl %ecx, FREEBSD_UC_MCONTEXT_DS_OFF(%eax) - movw %es, %cx - movl %ecx, FREEBSD_UC_MCONTEXT_ES_OFF(%eax) - movw %ss, %cx - movl %ecx, FREEBSD_UC_MCONTEXT_SS_OFF(%eax) - movw %cs, %cx - movl %ecx, FREEBSD_UC_MCONTEXT_CS_OFF(%eax) - - pushfl - .cfi_adjust_cfa_offset 4 - popl FREEBSD_UC_MCONTEXT_EFLAGS_OFF(%eax) - .cfi_adjust_cfa_offset -4 - - movl $0, FREEBSD_UC_MCONTEXT_TRAPNO_OFF(%eax) - - movl $FREEBSD_UC_MCONTEXT_FPOWNED_FPU,\ - FREEBSD_UC_MCONTEXT_OWNEDFP_OFF(%eax) - movl $FREEBSD_UC_MCONTEXT_FPFMT_XMM,\ - FREEBSD_UC_MCONTEXT_FPFORMAT_OFF(%eax) - - /* - * Require CPU with fxsave implemented, and enabled by OS. - * - * If passed ucontext is not aligned to 16-byte boundary, - * save fpu context into temporary aligned location on stack - * and then copy. - */ - leal FREEBSD_UC_MCONTEXT_FPSTATE_OFF(%eax), %edx - testl $0xf, %edx - jne 2f - fxsave (%edx) /* fast path, passed ucontext save area was aligned */ -1: movl $FREEBSD_UC_MCONTEXT_MC_LEN_VAL,\ - FREEBSD_UC_MCONTEXT_MC_LEN_OFF(%eax) - - xorl %eax, %eax - ret - -2: movl %edx, %edi /* not aligned, do the dance */ - subl $512 + 16, %esp /* save area and 16 bytes for alignment */ - .cfi_adjust_cfa_offset 512 + 16 - movl %esp, %edx - orl $0xf, %edx /* align *%edx to 16-byte up */ - incl %edx - fxsave (%edx) - movl %edx, %esi /* copy to the final destination */ - movl $512/4,%ecx - rep; movsl - addl $512 + 16, %esp /* restore the stack */ - .cfi_adjust_cfa_offset -512 - 16 - movl FREEBSD_UC_MCONTEXT_ESI_OFF(%eax), %esi - movl FREEBSD_UC_MCONTEXT_EDI_OFF(%eax), %edi - jmp 1b - - .cfi_endproc - .size _Ux86_getcontext, . - _Ux86_getcontext - - /* We do not need executable stack. */ - .section .note.GNU-stack,"",@progbits diff --git a/src/pal/src/libunwind/src/x86/getcontext-linux.S b/src/pal/src/libunwind/src/x86/getcontext-linux.S deleted file mode 100644 index c469dadba..000000000 --- a/src/pal/src/libunwind/src/x86/getcontext-linux.S +++ /dev/null @@ -1,74 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2009 Google, Inc - Contributed by Paul Pluzhnikov - -This file is part of libunwind. - -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. */ - -#include "offsets.h" - -/* int _Ux86_getcontext (ucontext_t *ucp) - - Saves the machine context in UCP necessary for libunwind. - Unlike the libc implementation, we don't save the signal mask - and hence avoid the cost of a system call per unwind. - -*/ - - .global _Ux86_getcontext - .type _Ux86_getcontext, @function -_Ux86_getcontext: - .cfi_startproc - mov 4(%esp),%eax /* ucontext_t* */ - - /* EAX is not preserved. */ - movl $0, (LINUX_UC_MCONTEXT_OFF+LINUX_SC_EAX_OFF)(%eax) - - movl %ebx, (LINUX_UC_MCONTEXT_OFF+LINUX_SC_EBX_OFF)(%eax) - movl %ecx, (LINUX_UC_MCONTEXT_OFF+LINUX_SC_ECX_OFF)(%eax) - movl %edx, (LINUX_UC_MCONTEXT_OFF+LINUX_SC_EDX_OFF)(%eax) - movl %edi, (LINUX_UC_MCONTEXT_OFF+LINUX_SC_EDI_OFF)(%eax) - movl %esi, (LINUX_UC_MCONTEXT_OFF+LINUX_SC_ESI_OFF)(%eax) - movl %ebp, (LINUX_UC_MCONTEXT_OFF+LINUX_SC_EBP_OFF)(%eax) - - movl (%esp), %ecx - movl %ecx, (LINUX_UC_MCONTEXT_OFF+LINUX_SC_EIP_OFF)(%eax) - - leal 4(%esp), %ecx /* Exclude the return address. */ - movl %ecx, (LINUX_UC_MCONTEXT_OFF+LINUX_SC_ESP_OFF)(%eax) - - /* glibc getcontext saves FS, but not GS */ - xorl %ecx, %ecx - movw %fs, %cx - movl %ecx, (LINUX_UC_MCONTEXT_OFF+LINUX_SC_FS_OFF)(%eax) - - leal LINUX_UC_FPREGS_MEM_OFF(%eax), %ecx - movl %ecx, (LINUX_UC_MCONTEXT_OFF+LINUX_SC_FPSTATE_OFF)(%eax) - fnstenv (%ecx) - fldenv (%ecx) - - xor %eax, %eax - ret - .cfi_endproc - .size _Ux86_getcontext, . - _Ux86_getcontext - - /* We do not need executable stack. */ - .section .note.GNU-stack,"",@progbits diff --git a/src/pal/src/libunwind/src/x86/init.h b/src/pal/src/libunwind/src/x86/init.h deleted file mode 100644 index b0db8d337..000000000 --- a/src/pal/src/libunwind/src/x86/init.h +++ /dev/null @@ -1,69 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2002 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" - -static inline int -common_init (struct cursor *c, unsigned use_prev_instr) -{ - int ret, i; - - c->dwarf.loc[EAX] = DWARF_REG_LOC (&c->dwarf, UNW_X86_EAX); - c->dwarf.loc[ECX] = DWARF_REG_LOC (&c->dwarf, UNW_X86_ECX); - c->dwarf.loc[EDX] = DWARF_REG_LOC (&c->dwarf, UNW_X86_EDX); - c->dwarf.loc[EBX] = DWARF_REG_LOC (&c->dwarf, UNW_X86_EBX); - c->dwarf.loc[ESP] = DWARF_REG_LOC (&c->dwarf, UNW_X86_ESP); - c->dwarf.loc[EBP] = DWARF_REG_LOC (&c->dwarf, UNW_X86_EBP); - c->dwarf.loc[ESI] = DWARF_REG_LOC (&c->dwarf, UNW_X86_ESI); - c->dwarf.loc[EDI] = DWARF_REG_LOC (&c->dwarf, UNW_X86_EDI); - c->dwarf.loc[EIP] = DWARF_REG_LOC (&c->dwarf, UNW_X86_EIP); - c->dwarf.loc[EFLAGS] = DWARF_REG_LOC (&c->dwarf, UNW_X86_EFLAGS); - c->dwarf.loc[TRAPNO] = DWARF_REG_LOC (&c->dwarf, UNW_X86_TRAPNO); - c->dwarf.loc[ST0] = DWARF_REG_LOC (&c->dwarf, UNW_X86_ST0); - for (i = ST0 + 1; i < DWARF_NUM_PRESERVED_REGS; ++i) - c->dwarf.loc[i] = DWARF_NULL_LOC; - - ret = dwarf_get (&c->dwarf, c->dwarf.loc[EIP], &c->dwarf.ip); - if (ret < 0) - return ret; - - ret = dwarf_get (&c->dwarf, DWARF_REG_LOC (&c->dwarf, UNW_X86_ESP), - &c->dwarf.cfa); - if (ret < 0) - return ret; - - c->sigcontext_format = X86_SCF_NONE; - c->sigcontext_addr = 0; - - c->dwarf.args_size = 0; - c->dwarf.stash_frames = 0; - c->dwarf.use_prev_instr = use_prev_instr; - c->dwarf.pi_valid = 0; - c->dwarf.pi_is_dynamic = 0; - c->dwarf.hint = 0; - c->dwarf.prev_rs = 0; - - return 0; -} diff --git a/src/pal/src/libunwind/src/x86/is_fpreg.c b/src/pal/src/libunwind/src/x86/is_fpreg.c deleted file mode 100644 index a3a98ac8d..000000000 --- a/src/pal/src/libunwind/src/x86/is_fpreg.c +++ /dev/null @@ -1,34 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (c) 2004-2005 Hewlett-Packard Development Company, L.P. - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include "libunwind_i.h" - -int -unw_is_fpreg (int regnum) -{ - return ((regnum >= UNW_X86_ST0 && regnum <= UNW_X86_ST7) - || (regnum >= UNW_X86_XMM0_lo && regnum <= UNW_X86_XMM7_hi) - || (regnum >= UNW_X86_XMM0 && regnum <= UNW_X86_XMM7)); -} diff --git a/src/pal/src/libunwind/src/x86/longjmp.S b/src/pal/src/libunwind/src/x86/longjmp.S deleted file mode 100644 index 05173d0c1..000000000 --- a/src/pal/src/libunwind/src/x86/longjmp.S +++ /dev/null @@ -1,39 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - - .globl _UI_longjmp_cont - - .type _UI_longjmp_cont, @function -_UI_longjmp_cont: - .cfi_startproc - .cfi_register 8, 0 /* IP saved in EAX */ - push %eax /* push target IP as return address */ - .cfi_restore 8 - mov %edx, %eax /* set up return-value */ - ret - .cfi_endproc - .size _UI_siglongjmp_cont, .-_UI_longjmp_cont - /* We do not need executable stack. */ - .section .note.GNU-stack,"",@progbits diff --git a/src/pal/src/libunwind/src/x86/offsets.h b/src/pal/src/libunwind/src/x86/offsets.h deleted file mode 100644 index e5aec7f58..000000000 --- a/src/pal/src/libunwind/src/x86/offsets.h +++ /dev/null @@ -1,140 +0,0 @@ -/* Linux-specific definitions: */ - -/* Define various structure offsets to simplify cross-compilation. */ - -/* Offsets for x86 Linux "ucontext_t": */ - -#define LINUX_UC_FLAGS_OFF 0x00 -#define LINUX_UC_LINK_OFF 0x04 -#define LINUX_UC_STACK_OFF 0x08 -#define LINUX_UC_MCONTEXT_OFF 0x14 -#define LINUX_UC_SIGMASK_OFF 0x6c -#define LINUX_UC_FPREGS_MEM_OFF 0xec - -/* The struct sigcontext is located at an offset of 4 - from the stack pointer in the signal frame. */ - -/* Offsets for x86 Linux "struct sigcontext": */ - -#define LINUX_SC_GS_OFF 0x00 -#define LINUX_SC_GSH_OFF 0x02 -#define LINUX_SC_FS_OFF 0x04 -#define LINUX_SC_FSH_OFF 0x06 -#define LINUX_SC_ES_OFF 0x08 -#define LINUX_SC_ESH_OFF 0x0a -#define LINUX_SC_DS_OFF 0x0c -#define LINUX_SC_DSH_OFF 0x0e -#define LINUX_SC_EDI_OFF 0x10 -#define LINUX_SC_ESI_OFF 0x14 -#define LINUX_SC_EBP_OFF 0x18 -#define LINUX_SC_ESP_OFF 0x1c -#define LINUX_SC_EBX_OFF 0x20 -#define LINUX_SC_EDX_OFF 0x24 -#define LINUX_SC_ECX_OFF 0x28 -#define LINUX_SC_EAX_OFF 0x2c -#define LINUX_SC_TRAPNO_OFF 0x30 -#define LINUX_SC_ERR_OFF 0x34 -#define LINUX_SC_EIP_OFF 0x38 -#define LINUX_SC_CS_OFF 0x3c -#define LINUX_SC_CSH_OFF 0x3e -#define LINUX_SC_EFLAGS_OFF 0x40 -#define LINUX_SC_ESP_AT_SIGNAL_OFF 0x44 -#define LINUX_SC_SS_OFF 0x48 -#define LINUX_SC_SSH_OFF 0x4a -#define LINUX_SC_FPSTATE_OFF 0x4c -#define LINUX_SC_OLDMASK_OFF 0x50 -#define LINUX_SC_CR2_OFF 0x54 - -/* Offsets for x86 Linux "struct _fpstate": */ - -#define LINUX_FPSTATE_CW_OFF 0x000 -#define LINUX_FPSTATE_SW_OFF 0x004 -#define LINUX_FPSTATE_TAG_OFF 0x008 -#define LINUX_FPSTATE_IPOFF_OFF 0x00c -#define LINUX_FPSTATE_CSSEL_OFF 0x010 -#define LINUX_FPSTATE_DATAOFF_OFF 0x014 -#define LINUX_FPSTATE_DATASEL_OFF 0x018 -#define LINUX_FPSTATE_ST0_OFF 0x01c -#define LINUX_FPSTATE_ST1_OFF 0x026 -#define LINUX_FPSTATE_ST2_OFF 0x030 -#define LINUX_FPSTATE_ST3_OFF 0x03a -#define LINUX_FPSTATE_ST4_OFF 0x044 -#define LINUX_FPSTATE_ST5_OFF 0x04e -#define LINUX_FPSTATE_ST6_OFF 0x058 -#define LINUX_FPSTATE_ST7_OFF 0x062 -#define LINUX_FPSTATE_STATUS_OFF 0x06c -#define LINUX_FPSTATE_MAGIC_OFF 0x06e -#define LINUX_FPSTATE_FXSR_ENV_OFF 0x070 -#define LINUX_FPSTATE_MXCSR_OFF 0x088 -#define LINUX_FPSTATE_FXSR_ST0_OFF 0x090 -#define LINUX_FPSTATE_FXSR_ST1_OFF 0x0a0 -#define LINUX_FPSTATE_FXSR_ST2_OFF 0x0b0 -#define LINUX_FPSTATE_FXSR_ST3_OFF 0x0c0 -#define LINUX_FPSTATE_FXSR_ST4_OFF 0x0d0 -#define LINUX_FPSTATE_FXSR_ST5_OFF 0x0e0 -#define LINUX_FPSTATE_FXSR_ST6_OFF 0x0f0 -#define LINUX_FPSTATE_FXSR_ST7_OFF 0x100 -#define LINUX_FPSTATE_XMM0_OFF 0x110 -#define LINUX_FPSTATE_XMM1_OFF 0x120 -#define LINUX_FPSTATE_XMM2_OFF 0x130 -#define LINUX_FPSTATE_XMM3_OFF 0x140 -#define LINUX_FPSTATE_XMM4_OFF 0x150 -#define LINUX_FPSTATE_XMM5_OFF 0x160 -#define LINUX_FPSTATE_XMM6_OFF 0x170 -#define LINUX_FPSTATE_XMM7_OFF 0x180 - -/* FreeBSD-specific definitions: */ - -#define FREEBSD_SC_UCONTEXT_OFF 0x20 -#define FREEBSD_UC_MCONTEXT_OFF 0x10 - -#define FREEBSD_UC_MCONTEXT_GS_OFF 0x14 -#define FREEBSD_UC_MCONTEXT_FS_OFF 0x18 -#define FREEBSD_UC_MCONTEXT_ES_OFF 0x1c -#define FREEBSD_UC_MCONTEXT_DS_OFF 0x20 -#define FREEBSD_UC_MCONTEXT_EDI_OFF 0x24 -#define FREEBSD_UC_MCONTEXT_ESI_OFF 0x28 -#define FREEBSD_UC_MCONTEXT_EBP_OFF 0x2c -#define FREEBSD_UC_MCONTEXT_EBX_OFF 0x34 -#define FREEBSD_UC_MCONTEXT_EDX_OFF 0x38 -#define FREEBSD_UC_MCONTEXT_ECX_OFF 0x3c -#define FREEBSD_UC_MCONTEXT_EAX_OFF 0x40 -#define FREEBSD_UC_MCONTEXT_TRAPNO_OFF 0x44 -#define FREEBSD_UC_MCONTEXT_EIP_OFF 0x4c -#define FREEBSD_UC_MCONTEXT_ESP_OFF 0x58 -#define FREEBSD_UC_MCONTEXT_CS_OFF 0x50 -#define FREEBSD_UC_MCONTEXT_EFLAGS_OFF 0x54 -#define FREEBSD_UC_MCONTEXT_SS_OFF 0x5c -#define FREEBSD_UC_MCONTEXT_MC_LEN_OFF 0x60 -#define FREEBSD_UC_MCONTEXT_FPFORMAT_OFF 0x64 -#define FREEBSD_UC_MCONTEXT_OWNEDFP_OFF 0x68 -#define FREEBSD_UC_MCONTEXT_FPSTATE_OFF 0x70 - -#define FREEBSD_UC_MCONTEXT_CW_OFF 0x70 -#define FREEBSD_UC_MCONTEXT_SW_OFF 0x74 -#define FREEBSD_UC_MCONTEXT_TAG_OFF 0x78 -#define FREEBSD_UC_MCONTEXT_IPOFF_OFF 0x7c -#define FREEBSD_UC_MCONTEXT_CSSEL_OFF 0x80 -#define FREEBSD_UC_MCONTEXT_DATAOFF_OFF 0x84 -#define FREEBSD_US_MCONTEXT_DATASEL_OFF 0x88 -#define FREEBSD_UC_MCONTEXT_ST0_OFF 0x8c - -#define FREEBSD_UC_MCONTEXT_CW_XMM_OFF 0x70 -#define FREEBSD_UC_MCONTEXT_SW_XMM_OFF 0x72 -#define FREEBSD_UC_MCONTEXT_TAG_XMM_OFF 0x74 -#define FREEBSD_UC_MCONTEXT_IPOFF_XMM_OFF 0x78 -#define FREEBSD_UC_MCONTEXT_CSSEL_XMM_OFF 0x7c -#define FREEBSD_UC_MCONTEXT_DATAOFF_XMM_OFF 0x80 -#define FREEBSD_US_MCONTEXT_DATASEL_XMM_OFF 0x84 -#define FREEBSD_UC_MCONTEXT_MXCSR_XMM_OFF 0x88 -#define FREEBSD_UC_MCONTEXT_ST0_XMM_OFF 0x90 -#define FREEBSD_UC_MCONTEXT_XMM0_OFF 0x110 - -#define FREEBSD_UC_MCONTEXT_MC_LEN_VAL 0x280 -#define FREEBSD_UC_MCONTEXT_FPFMT_NODEV 0x10000 -#define FREEBSD_UC_MCONTEXT_FPFMT_387 0x10001 -#define FREEBSD_UC_MCONTEXT_FPFMT_XMM 0x10002 -#define FREEBSD_UC_MCONTEXT_FPOWNED_NONE 0x20000 -#define FREEBSD_UC_MCONTEXT_FPOWNED_FPU 0x20001 -#define FREEBSD_UC_MCONTEXT_FPOWNED_PCB 0x20002 - diff --git a/src/pal/src/libunwind/src/x86/regname.c b/src/pal/src/libunwind/src/x86/regname.c deleted file mode 100644 index 11f622804..000000000 --- a/src/pal/src/libunwind/src/x86/regname.c +++ /dev/null @@ -1,27 +0,0 @@ -#include "unwind_i.h" - -static const char *regname[] = - { - "eax", "edx", "ecx", "ebx", "esi", "edi", "ebp", "esp", "eip", - "eflags", "trapno", - "st0", "st1", "st2", "st3", "st4", "st5", "st6", "st7", - "fcw", "fsw", "ftw", "fop", "fcs", "fip", "fea", "fds", - "xmm0_lo", "xmm0_hi", "xmm1_lo", "xmm1_hi", - "xmm2_lo", "xmm2_hi", "xmm3_lo", "xmm3_hi", - "xmm4_lo", "xmm4_hi", "xmm5_lo", "xmm5_hi", - "xmm6_lo", "xmm6_hi", "xmm7_lo", "xmm7_hi", - "mxcsr", - "gs", "fs", "es", "ds", "ss", "cs", - "tss", "ldt", - "cfi", - "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7", - }; - -const char * -unw_regname (unw_regnum_t reg) -{ - if (reg < (unw_regnum_t) ARRAY_SIZE (regname)) - return regname[reg]; - else - return "???"; -} diff --git a/src/pal/src/libunwind/src/x86/siglongjmp.S b/src/pal/src/libunwind/src/x86/siglongjmp.S deleted file mode 100644 index 32bba3b3b..000000000 --- a/src/pal/src/libunwind/src/x86/siglongjmp.S +++ /dev/null @@ -1,92 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - Copyright (C) 2011 Konstantin Belousov - -This file is part of libunwind. - -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. */ - - .globl _UI_siglongjmp_cont - -#if defined(__linux__) -#define SIG_SETMASK 2 -#elif defined(__FreeBSD__) -#define SIG_SETMASK 3 -#endif - - /* Stack layout at this point: - - +------------+ <- original $esp (at time of setjmp() call) - | sigmask[1] | - +------------+ - | sigmask[0] | - +------------+ - */ - - .type _UI_siglongjmp_cont, @function -_UI_siglongjmp_cont: - .cfi_startproc -#ifdef __linux__ - .cfi_register 8, 0 /* IP saved in EAX */ - .cfi_def_cfa_offset 8 - mov %esp, %ecx /* pass address of signal mask in 3rd sc arg */ - push %eax /* save target IP */ - .cfi_adjust_cfa_offset 4 - .cfi_offset 8, -12 - push %edx /* save return value */ - .cfi_adjust_cfa_offset 4 - push %ebx /* save %ebx (preserved) */ - .cfi_adjust_cfa_offset 4 - .cfi_offset 3, -20 - mov $SIG_SETMASK, %ebx /* 1st syscall arg (how) */ - xor %edx, %edx /* pass NULL as 3rd syscall arg (old maskp) */ - int $0x80 - pop %ebx /* restore %ebx */ - .cfi_adjust_cfa_offset -4 - .cfi_restore 3 - pop %eax /* fetch return value */ - .cfi_adjust_cfa_offset -4 - pop %edx /* pop target IP */ - .cfi_adjust_cfa_offset -4 - .cfi_register 8, 2 /* saved IP is now n EDX */ - lea 8(%esp), %esp /* pop sigmask */ - .cfi_adjust_cfa_offset -4 - jmp *%edx -#elif defined(__FreeBSD__) - pushl %eax - pushl %edx - pushl $0 - pushl %ecx - pushl $SIG_SETMASK - movl $340,%eax - pushl %eax - int $0x80 - addl $16,%esp - popl %eax - popl %edx - jmp *%edx -#else -#error Port me -#endif - .cfi_endproc - .size _UI_siglongjmp_cont, .-_UI_siglongjmp_cont - /* We do not need executable stack. */ - .section .note.GNU-stack,"",@progbits diff --git a/src/pal/src/libunwind/src/x86/unwind_i.h b/src/pal/src/libunwind/src/x86/unwind_i.h deleted file mode 100644 index caa7e02de..000000000 --- a/src/pal/src/libunwind/src/x86/unwind_i.h +++ /dev/null @@ -1,68 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2002 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#ifndef unwind_i_h -#define unwind_i_h - -#include - -#include - -#include "libunwind_i.h" - -/* DWARF column numbers: */ -#define EAX 0 -#define ECX 1 -#define EDX 2 -#define EBX 3 -#define ESP 4 -#define EBP 5 -#define ESI 6 -#define EDI 7 -#define EIP 8 -#define EFLAGS 9 -#define TRAPNO 10 -#define ST0 11 - -#define x86_lock UNW_OBJ(lock) -#define x86_local_resume UNW_OBJ(local_resume) -#define x86_local_addr_space_init UNW_OBJ(local_addr_space_init) -#define x86_scratch_loc UNW_OBJ(scratch_loc) -#define x86_get_scratch_loc UNW_OBJ(get_scratch_loc) -#define x86_r_uc_addr UNW_OBJ(r_uc_addr) -#define x86_sigreturn UNW_OBJ(sigreturn) - -extern void x86_local_addr_space_init (void); -extern int x86_local_resume (unw_addr_space_t as, unw_cursor_t *cursor, - void *arg); -extern dwarf_loc_t x86_scratch_loc (struct cursor *c, unw_regnum_t reg); -extern dwarf_loc_t x86_get_scratch_loc (struct cursor *c, unw_regnum_t reg); -extern void *x86_r_uc_addr (ucontext_t *uc, int reg); - -extern void x86_sigreturn (unw_cursor_t *cursor); -#define x86_handle_signal_frame UNW_OBJ(handle_signal_frame) -extern int x86_handle_signal_frame(unw_cursor_t *cursor); - -#endif /* unwind_i_h */ diff --git a/src/pal/src/libunwind/src/x86_64/Gapply_reg_state.c b/src/pal/src/libunwind/src/x86_64/Gapply_reg_state.c deleted file mode 100644 index 82f056da6..000000000 --- a/src/pal/src/libunwind/src/x86_64/Gapply_reg_state.c +++ /dev/null @@ -1,37 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (c) 2002-2003 Hewlett-Packard Development Company, L.P. - Contributed by David Mosberger-Tang - - Modified for x86_64 by Max Asbock - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" - -int -unw_apply_reg_state (unw_cursor_t *cursor, - void *reg_states_data) -{ - struct cursor *c = (struct cursor *) cursor; - - return dwarf_apply_reg_state (&c->dwarf, (dwarf_reg_state_t *)reg_states_data); -} diff --git a/src/pal/src/libunwind/src/x86_64/Gcreate_addr_space.c b/src/pal/src/libunwind/src/x86_64/Gcreate_addr_space.c deleted file mode 100644 index 9b2db9810..000000000 --- a/src/pal/src/libunwind/src/x86_64/Gcreate_addr_space.c +++ /dev/null @@ -1,61 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2003 Hewlett-Packard Co - Contributed by David Mosberger-Tang - - Modified for x86_64 by Max Asbock - Copyright (C) 2012 Tommi Rantala - -This file is part of libunwind. - -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. */ - -#include - -#include "unwind_i.h" - -#if defined(_LITTLE_ENDIAN) && !defined(__LITTLE_ENDIAN) -#define __LITTLE_ENDIAN _LITTLE_ENDIAN -#endif - -unw_addr_space_t -unw_create_addr_space (unw_accessors_t *a, int byte_order) -{ -#ifdef UNW_LOCAL_ONLY - return NULL; -#else - unw_addr_space_t as; - - /* - * x86_64 supports only little-endian. - */ - if (byte_order != 0 && byte_order != __LITTLE_ENDIAN) - return NULL; - - as = malloc (sizeof (*as)); - if (!as) - return NULL; - - memset (as, 0, sizeof (*as)); - - as->acc = *a; - - return as; -#endif -} diff --git a/src/pal/src/libunwind/src/x86_64/Gget_proc_info.c b/src/pal/src/libunwind/src/x86_64/Gget_proc_info.c deleted file mode 100644 index 50de1e423..000000000 --- a/src/pal/src/libunwind/src/x86_64/Gget_proc_info.c +++ /dev/null @@ -1,48 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (c) 2002-2003 Hewlett-Packard Development Company, L.P. - Contributed by David Mosberger-Tang - - Modified for x86_64 by Max Asbock - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" - -int -unw_get_proc_info (unw_cursor_t *cursor, unw_proc_info_t *pi) -{ - struct cursor *c = (struct cursor *) cursor; - - if (dwarf_make_proc_info (&c->dwarf) < 0) - { - /* On x86-64, some key routines such as _start() and _dl_start() - are missing DWARF unwind info. We don't want to fail in that - case, because those frames are uninteresting and just mark - the end of the frame-chain anyhow. */ - memset (pi, 0, sizeof (*pi)); - pi->start_ip = c->dwarf.ip; - pi->end_ip = c->dwarf.ip + 1; - return 0; - } - *pi = c->dwarf.pi; - return 0; -} diff --git a/src/pal/src/libunwind/src/x86_64/Gget_save_loc.c b/src/pal/src/libunwind/src/x86_64/Gget_save_loc.c deleted file mode 100644 index 0057c62d6..000000000 --- a/src/pal/src/libunwind/src/x86_64/Gget_save_loc.c +++ /dev/null @@ -1,73 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - - Modified for x86_64 by Max Asbock - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" - -int -unw_get_save_loc (unw_cursor_t *cursor, int reg, unw_save_loc_t *sloc) -{ - struct cursor *c = (struct cursor *) cursor; - dwarf_loc_t loc; - - loc = DWARF_NULL_LOC; /* default to "not saved" */ - - switch (reg) - { - case UNW_X86_64_RBX: loc = c->dwarf.loc[RBX]; break; - case UNW_X86_64_RSP: loc = c->dwarf.loc[RSP]; break; - case UNW_X86_64_RBP: loc = c->dwarf.loc[RBP]; break; - case UNW_X86_64_R12: loc = c->dwarf.loc[R12]; break; - case UNW_X86_64_R13: loc = c->dwarf.loc[R13]; break; - case UNW_X86_64_R14: loc = c->dwarf.loc[R14]; break; - case UNW_X86_64_R15: loc = c->dwarf.loc[R15]; break; - - default: - break; - } - - memset (sloc, 0, sizeof (*sloc)); - - if (DWARF_IS_NULL_LOC (loc)) - { - sloc->type = UNW_SLT_NONE; - return 0; - } - -#if !defined(UNW_LOCAL_ONLY) - if (DWARF_IS_REG_LOC (loc)) - { - sloc->type = UNW_SLT_REG; - sloc->u.regnum = DWARF_GET_LOC (loc); - } - else -#endif - { - sloc->type = UNW_SLT_MEMORY; - sloc->u.addr = DWARF_GET_LOC (loc); - } - return 0; -} diff --git a/src/pal/src/libunwind/src/x86_64/Gglobal.c b/src/pal/src/libunwind/src/x86_64/Gglobal.c deleted file mode 100644 index 8d1fbb4b0..000000000 --- a/src/pal/src/libunwind/src/x86_64/Gglobal.c +++ /dev/null @@ -1,102 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (c) 2003, 2005 Hewlett-Packard Development Company, L.P. - Contributed by David Mosberger-Tang - - Modified for x86_64 by Max Asbock - -This file is part of libunwind. - -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. */ - -#include "config.h" -#include "unwind_i.h" -#include "dwarf_i.h" - -HIDDEN define_lock (x86_64_lock); -HIDDEN int tdep_init_done; - -/* See comments for svr4_dbx_register_map[] in gcc/config/i386/i386.c. */ - -HIDDEN const uint8_t dwarf_to_unw_regnum_map[DWARF_NUM_PRESERVED_REGS] = - { - UNW_X86_64_RAX, - UNW_X86_64_RDX, - UNW_X86_64_RCX, - UNW_X86_64_RBX, - UNW_X86_64_RSI, - UNW_X86_64_RDI, - UNW_X86_64_RBP, - UNW_X86_64_RSP, - UNW_X86_64_R8, - UNW_X86_64_R9, - UNW_X86_64_R10, - UNW_X86_64_R11, - UNW_X86_64_R12, - UNW_X86_64_R13, - UNW_X86_64_R14, - UNW_X86_64_R15, - UNW_X86_64_RIP, -#ifdef CONFIG_MSABI_SUPPORT - UNW_X86_64_XMM0, - UNW_X86_64_XMM1, - UNW_X86_64_XMM2, - UNW_X86_64_XMM3, - UNW_X86_64_XMM4, - UNW_X86_64_XMM5, - UNW_X86_64_XMM6, - UNW_X86_64_XMM7, - UNW_X86_64_XMM8, - UNW_X86_64_XMM9, - UNW_X86_64_XMM10, - UNW_X86_64_XMM11, - UNW_X86_64_XMM12, - UNW_X86_64_XMM13, - UNW_X86_64_XMM14, - UNW_X86_64_XMM15 -#endif - }; - -HIDDEN void -tdep_init (void) -{ - intrmask_t saved_mask; - - sigfillset (&unwi_full_mask); - - lock_acquire (&x86_64_lock, saved_mask); - { - if (tdep_init_done) - /* another thread else beat us to it... */ - goto out; - - mi_init (); - - dwarf_init (); - - tdep_init_mem_validate (); - -#ifndef UNW_REMOTE_ONLY - x86_64_local_addr_space_init (); -#endif - tdep_init_done = 1; /* signal that we're initialized... */ - } - out: - lock_release (&x86_64_lock, saved_mask); -} diff --git a/src/pal/src/libunwind/src/x86_64/Ginit.c b/src/pal/src/libunwind/src/x86_64/Ginit.c deleted file mode 100644 index 2a84a1eec..000000000 --- a/src/pal/src/libunwind/src/x86_64/Ginit.c +++ /dev/null @@ -1,342 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2002 Hewlett-Packard Co - Copyright (C) 2007 David Mosberger-Tang - Contributed by David Mosberger-Tang - - Modified for x86_64 by Max Asbock - -This file is part of libunwind. - -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. */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include - -#include "unwind_i.h" - -#ifdef UNW_REMOTE_ONLY - -/* unw_local_addr_space is a NULL pointer in this case. */ -unw_addr_space_t unw_local_addr_space; - -#else /* !UNW_REMOTE_ONLY */ - -static struct unw_addr_space local_addr_space; - -unw_addr_space_t unw_local_addr_space = &local_addr_space; - -HIDDEN unw_dyn_info_list_t _U_dyn_info_list; - -/* XXX fix me: there is currently no way to locate the dyn-info list - by a remote unwinder. On ia64, this is done via a special - unwind-table entry. Perhaps something similar can be done with - DWARF2 unwind info. */ - -static void -put_unwind_info (unw_addr_space_t as, unw_proc_info_t *proc_info, void *arg) -{ - /* it's a no-op */ -} - -static int -get_dyn_info_list_addr (unw_addr_space_t as, unw_word_t *dyn_info_list_addr, - void *arg) -{ - *dyn_info_list_addr = (unw_word_t) &_U_dyn_info_list; - return 0; -} - -#define PAGE_SIZE 4096 -#define PAGE_START(a) ((a) & ~(PAGE_SIZE-1)) - -static int mem_validate_pipe[2] = {-1, -1}; - -static inline void -open_pipe (void) -{ - /* ignore errors for closing invalid fd's */ - close (mem_validate_pipe[0]); - close (mem_validate_pipe[1]); - - pipe2 (mem_validate_pipe, O_CLOEXEC | O_NONBLOCK); -} - -ALWAYS_INLINE -static int -write_validate (void *addr) -{ - int ret = -1; - ssize_t bytes = 0; - - do - { - char buf; - bytes = read (mem_validate_pipe[0], &buf, 1); - } - while ( errno == EINTR ); - - int valid_read = (bytes > 0 || errno == EAGAIN || errno == EWOULDBLOCK); - if (!valid_read) - { - // re-open closed pipe - open_pipe (); - } - - do - { - /* use syscall insteadof write() so that ASAN does not complain */ - ret = syscall (SYS_write, mem_validate_pipe[1], addr, 1); - } - while ( errno == EINTR ); - - return ret; -} - -static int (*mem_validate_func) (void *addr, size_t len); -static int msync_validate (void *addr, size_t len) -{ - if (msync (addr, len, MS_ASYNC) != 0) - { - return -1; - } - - return write_validate (addr); -} - -#ifdef HAVE_MINCORE -static int mincore_validate (void *addr, size_t len) -{ - unsigned char mvec[2]; /* Unaligned access may cross page boundary */ - size_t i; - - /* mincore could fail with EAGAIN but we conservatively return -1 - instead of looping. */ - if (mincore (addr, len, mvec) != 0) - { - return -1; - } - - for (i = 0; i < (len + PAGE_SIZE - 1) / PAGE_SIZE; i++) - { - if (!(mvec[i] & 1)) return -1; - } - - return write_validate (addr); -} -#endif - -/* Initialise memory validation method. On linux kernels <2.6.21, - mincore() returns incorrect value for MAP_PRIVATE mappings, - such as stacks. If mincore() was available at compile time, - check if we can actually use it. If not, use msync() instead. */ -HIDDEN void -tdep_init_mem_validate (void) -{ - open_pipe (); - -#ifdef HAVE_MINCORE - unsigned char present = 1; - unw_word_t addr = PAGE_START((unw_word_t)&present); - unsigned char mvec[1]; - int ret; - while ((ret = mincore ((void*)addr, PAGE_SIZE, mvec)) == -1 && - errno == EAGAIN) {} - if (ret == 0 && (mvec[0] & 1)) - { - Debug(1, "using mincore to validate memory\n"); - mem_validate_func = mincore_validate; - } - else -#endif - { - Debug(1, "using msync to validate memory\n"); - mem_validate_func = msync_validate; - } -} - -/* Cache of already validated addresses */ -#define NLGA 4 -static unw_word_t last_good_addr[NLGA]; -static int lga_victim; - -static int -validate_mem (unw_word_t addr) -{ - int i, victim; - size_t len; - - if (PAGE_START(addr + sizeof (unw_word_t) - 1) == PAGE_START(addr)) - len = PAGE_SIZE; - else - len = PAGE_SIZE * 2; - - addr = PAGE_START(addr); - - if (addr == 0) - return -1; - - for (i = 0; i < NLGA; i++) - { - if (last_good_addr[i] && (addr == last_good_addr[i])) - return 0; - } - - if (mem_validate_func ((void *) addr, len) == -1) - return -1; - - victim = lga_victim; - for (i = 0; i < NLGA; i++) { - if (!last_good_addr[victim]) { - last_good_addr[victim++] = addr; - return 0; - } - victim = (victim + 1) % NLGA; - } - - /* All slots full. Evict the victim. */ - last_good_addr[victim] = addr; - victim = (victim + 1) % NLGA; - lga_victim = victim; - - return 0; -} - -static int -access_mem (unw_addr_space_t as, unw_word_t addr, unw_word_t *val, int write, - void *arg) -{ - if (unlikely (write)) - { - Debug (16, "mem[%016lx] <- %lx\n", addr, *val); - *(unw_word_t *) addr = *val; - } - else - { - /* validate address */ - const struct cursor *c = (const struct cursor *)arg; - if (likely (c != NULL) && unlikely (c->validate) - && unlikely (validate_mem (addr))) { - Debug (16, "mem[%016lx] -> invalid\n", addr); - return -1; - } - *val = *(unw_word_t *) addr; - Debug (16, "mem[%016lx] -> %lx\n", addr, *val); - } - return 0; -} - -static int -access_reg (unw_addr_space_t as, unw_regnum_t reg, unw_word_t *val, int write, - void *arg) -{ - unw_word_t *addr; - ucontext_t *uc = ((struct cursor *)arg)->uc; - - if (unw_is_fpreg (reg)) - goto badreg; - - if (!(addr = x86_64_r_uc_addr (uc, reg))) - goto badreg; - - if (write) - { - *(unw_word_t *) addr = *val; - Debug (12, "%s <- 0x%016lx\n", unw_regname (reg), *val); - } - else - { - *val = *(unw_word_t *) addr; - Debug (12, "%s -> 0x%016lx\n", unw_regname (reg), *val); - } - return 0; - - badreg: - Debug (1, "bad register number %u\n", reg); - return -UNW_EBADREG; -} - -static int -access_fpreg (unw_addr_space_t as, unw_regnum_t reg, unw_fpreg_t *val, - int write, void *arg) -{ - ucontext_t *uc = ((struct cursor *)arg)->uc; - unw_fpreg_t *addr; - - if (!unw_is_fpreg (reg)) - goto badreg; - - if (!(addr = x86_64_r_uc_addr (uc, reg))) - goto badreg; - - if (write) - { - Debug (12, "%s <- %08lx.%08lx.%08lx\n", unw_regname (reg), - ((long *)val)[0], ((long *)val)[1], ((long *)val)[2]); - *(unw_fpreg_t *) addr = *val; - } - else - { - *val = *(unw_fpreg_t *) addr; - Debug (12, "%s -> %08lx.%08lx.%08lx\n", unw_regname (reg), - ((long *)val)[0], ((long *)val)[1], ((long *)val)[2]); - } - return 0; - - badreg: - Debug (1, "bad register number %u\n", reg); - /* attempt to access a non-preserved register */ - return -UNW_EBADREG; -} - -static int -get_static_proc_name (unw_addr_space_t as, unw_word_t ip, - char *buf, size_t buf_len, unw_word_t *offp, - void *arg) -{ - return _Uelf64_get_proc_name (as, getpid (), ip, buf, buf_len, offp); -} - -HIDDEN void -x86_64_local_addr_space_init (void) -{ - memset (&local_addr_space, 0, sizeof (local_addr_space)); - local_addr_space.caching_policy = UNWI_DEFAULT_CACHING_POLICY; - local_addr_space.acc.find_proc_info = dwarf_find_proc_info; - local_addr_space.acc.put_unwind_info = put_unwind_info; - local_addr_space.acc.get_dyn_info_list_addr = get_dyn_info_list_addr; - local_addr_space.acc.access_mem = access_mem; - local_addr_space.acc.access_reg = access_reg; - local_addr_space.acc.access_fpreg = access_fpreg; - local_addr_space.acc.resume = x86_64_local_resume; - local_addr_space.acc.get_proc_name = get_static_proc_name; - unw_flush_cache (&local_addr_space, 0, 0); - - memset (last_good_addr, 0, sizeof (unw_word_t) * NLGA); - lga_victim = 0; -} - -#endif /* !UNW_REMOTE_ONLY */ diff --git a/src/pal/src/libunwind/src/x86_64/Ginit_local.c b/src/pal/src/libunwind/src/x86_64/Ginit_local.c deleted file mode 100644 index 5eaead0f8..000000000 --- a/src/pal/src/libunwind/src/x86_64/Ginit_local.c +++ /dev/null @@ -1,81 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (c) 2002-2003 Hewlett-Packard Development Company, L.P. - Contributed by David Mosberger-Tang - - Modified for x86_64 by Max Asbock - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" -#include "init.h" - -#ifdef UNW_REMOTE_ONLY - -int -unw_init_local (unw_cursor_t *cursor, ucontext_t *uc) -{ - return -UNW_EINVAL; -} - -#else /* !UNW_REMOTE_ONLY */ - -static int -unw_init_local_common (unw_cursor_t *cursor, ucontext_t *uc, unsigned use_prev_instr) -{ - struct cursor *c = (struct cursor *) cursor; - - if (unlikely (!tdep_init_done)) - tdep_init (); - - Debug (1, "(cursor=%p)\n", c); - - c->dwarf.as = unw_local_addr_space; - c->dwarf.as_arg = c; - c->uc = uc; - c->validate = 0; - return common_init (c, use_prev_instr); -} - -int -unw_init_local (unw_cursor_t *cursor, ucontext_t *uc) -{ - return unw_init_local_common(cursor, uc, 1); -} - -int -unw_init_local2 (unw_cursor_t *cursor, ucontext_t *uc, int flag) -{ - if (!flag) - { - return unw_init_local_common(cursor, uc, 1); - } - else if (flag == UNW_INIT_SIGNAL_FRAME) - { - return unw_init_local_common(cursor, uc, 0); - } - else - { - return -UNW_EINVAL; - } -} - -#endif /* !UNW_REMOTE_ONLY */ diff --git a/src/pal/src/libunwind/src/x86_64/Ginit_remote.c b/src/pal/src/libunwind/src/x86_64/Ginit_remote.c deleted file mode 100644 index efd61d64d..000000000 --- a/src/pal/src/libunwind/src/x86_64/Ginit_remote.c +++ /dev/null @@ -1,57 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (c) 2003 Hewlett-Packard Development Company, L.P. - Contributed by David Mosberger-Tang - - Modified for x86_64 by Max Asbock - -This file is part of libunwind. - -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. */ - -#include "init.h" -#include "unwind_i.h" - -int -unw_init_remote (unw_cursor_t *cursor, unw_addr_space_t as, void *as_arg) -{ -#ifdef UNW_LOCAL_ONLY - return -UNW_EINVAL; -#else /* !UNW_LOCAL_ONLY */ - struct cursor *c = (struct cursor *) cursor; - - if (!tdep_init_done) - tdep_init (); - - Debug (1, "(cursor=%p)\n", c); - - c->dwarf.as = as; - if (as == unw_local_addr_space) - { - c->dwarf.as_arg = c; - c->uc = as_arg; - } - else - { - c->dwarf.as_arg = as_arg; - c->uc = NULL; - } - return common_init (c, 0); -#endif /* !UNW_LOCAL_ONLY */ -} diff --git a/src/pal/src/libunwind/src/x86_64/Gos-freebsd.c b/src/pal/src/libunwind/src/x86_64/Gos-freebsd.c deleted file mode 100644 index 883025c88..000000000 --- a/src/pal/src/libunwind/src/x86_64/Gos-freebsd.c +++ /dev/null @@ -1,218 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2010 Konstantin Belousov - -This file is part of libunwind. - -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. */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include -#include -#include -#include "unwind_i.h" -#include "ucontext_i.h" - -int -unw_is_signal_frame (unw_cursor_t *cursor) -{ - /* XXXKIB */ - struct cursor *c = (struct cursor *) cursor; - unw_word_t w0, w1, w2, b0, ip; - unw_addr_space_t as; - unw_accessors_t *a; - void *arg; - int ret; - - as = c->dwarf.as; - a = unw_get_accessors_int (as); - arg = c->dwarf.as_arg; - - /* Check if RIP points at sigreturn sequence. -48 8d 7c 24 10 lea SIGF_UC(%rsp),%rdi -6a 00 pushq $0 -48 c7 c0 a1 01 00 00 movq $SYS_sigreturn,%rax -0f 05 syscall -f4 0: hlt -eb fd jmp 0b - */ - - ip = c->dwarf.ip; - c->sigcontext_format = X86_64_SCF_NONE; - if ((ret = (*a->access_mem) (as, ip, &w0, 0, arg)) < 0 - || (ret = (*a->access_mem) (as, ip + 8, &w1, 0, arg)) < 0 - || (ret = (*a->access_mem) (as, ip + 16, &w2, 0, arg)) < 0) - return 0; - w2 &= 0xffffff; - if (w0 == 0x48006a10247c8d48 && - w1 == 0x050f000001a1c0c7 && - w2 == 0x0000000000fdebf4) - { - c->sigcontext_format = X86_64_SCF_FREEBSD_SIGFRAME; - return (c->sigcontext_format); - } - /* Check if RIP points at standard syscall sequence. -49 89 ca mov %rcx,%r10 -0f 05 syscall - */ - if ((ret = (*a->access_mem) (as, ip - 5, &b0, 0, arg)) < 0) - return (0); - Debug (12, "b0 0x%lx\n", b0); - if ((b0 & 0xffffffffffffff) == 0x050fca89490000 || - (b0 & 0xffffffffff) == 0x050fca8949) - { - c->sigcontext_format = X86_64_SCF_FREEBSD_SYSCALL; - return (c->sigcontext_format); - } - return (X86_64_SCF_NONE); -} - -HIDDEN int -x86_64_handle_signal_frame (unw_cursor_t *cursor) -{ - struct cursor *c = (struct cursor *) cursor; - unw_word_t ucontext; - int ret; - - if (c->sigcontext_format == X86_64_SCF_FREEBSD_SIGFRAME) - { - ucontext = c->dwarf.cfa + offsetof(struct sigframe, sf_uc); - c->sigcontext_addr = c->dwarf.cfa; - Debug(1, "signal frame, skip over trampoline\n"); - - struct dwarf_loc rsp_loc = DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_RSP, 0); - ret = dwarf_get (&c->dwarf, rsp_loc, &c->dwarf.cfa); - if (ret < 0) - { - Debug (2, "returning %d\n", ret); - return ret; - } - - c->dwarf.loc[RAX] = DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_RAX, 0); - c->dwarf.loc[RDX] = DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_RDX, 0); - c->dwarf.loc[RCX] = DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_RCX, 0); - c->dwarf.loc[RBX] = DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_RBX, 0); - c->dwarf.loc[RSI] = DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_RSI, 0); - c->dwarf.loc[RDI] = DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_RDI, 0); - c->dwarf.loc[RBP] = DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_RBP, 0); - c->dwarf.loc[RSP] = DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_RSP, 0); - c->dwarf.loc[ R8] = DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R8, 0); - c->dwarf.loc[ R9] = DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R9, 0); - c->dwarf.loc[R10] = DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R10, 0); - c->dwarf.loc[R11] = DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R11, 0); - c->dwarf.loc[R12] = DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R12, 0); - c->dwarf.loc[R13] = DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R13, 0); - c->dwarf.loc[R14] = DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R14, 0); - c->dwarf.loc[R15] = DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_R15, 0); - c->dwarf.loc[RIP] = DWARF_LOC (ucontext + UC_MCONTEXT_GREGS_RIP, 0); - - return 0; - } - else if (c->sigcontext_format == X86_64_SCF_FREEBSD_SYSCALL) - { - c->dwarf.loc[RCX] = c->dwarf.loc[R10]; - /* rsp_loc = DWARF_LOC(c->dwarf.cfa - 8, 0); */ - /* rbp_loc = c->dwarf.loc[RBP]; */ - c->dwarf.loc[RIP] = DWARF_LOC (c->dwarf.cfa, 0); - ret = dwarf_get (&c->dwarf, c->dwarf.loc[RIP], &c->dwarf.ip); - Debug (1, "Frame Chain [RIP=0x%Lx] = 0x%Lx\n", - (unsigned long long) DWARF_GET_LOC (c->dwarf.loc[RIP]), - (unsigned long long) c->dwarf.ip); - if (ret < 0) - { - Debug (2, "returning %d\n", ret); - return ret; - } - c->dwarf.cfa += 8; - c->dwarf.use_prev_instr = 1; - return 1; - } - else - return -UNW_EBADFRAME; - -} - -#ifndef UNW_REMOTE_ONLY -HIDDEN void * -x86_64_r_uc_addr (ucontext_t *uc, int reg) -{ - /* NOTE: common_init() in init.h inlines these for fast path access. */ - void *addr; - - switch (reg) - { - case UNW_X86_64_R8: addr = &uc->uc_mcontext.mc_r8; break; - case UNW_X86_64_R9: addr = &uc->uc_mcontext.mc_r9; break; - case UNW_X86_64_R10: addr = &uc->uc_mcontext.mc_r10; break; - case UNW_X86_64_R11: addr = &uc->uc_mcontext.mc_r11; break; - case UNW_X86_64_R12: addr = &uc->uc_mcontext.mc_r12; break; - case UNW_X86_64_R13: addr = &uc->uc_mcontext.mc_r13; break; - case UNW_X86_64_R14: addr = &uc->uc_mcontext.mc_r14; break; - case UNW_X86_64_R15: addr = &uc->uc_mcontext.mc_r15; break; - case UNW_X86_64_RDI: addr = &uc->uc_mcontext.mc_rdi; break; - case UNW_X86_64_RSI: addr = &uc->uc_mcontext.mc_rsi; break; - case UNW_X86_64_RBP: addr = &uc->uc_mcontext.mc_rbp; break; - case UNW_X86_64_RBX: addr = &uc->uc_mcontext.mc_rbx; break; - case UNW_X86_64_RDX: addr = &uc->uc_mcontext.mc_rdx; break; - case UNW_X86_64_RAX: addr = &uc->uc_mcontext.mc_rax; break; - case UNW_X86_64_RCX: addr = &uc->uc_mcontext.mc_rcx; break; - case UNW_X86_64_RSP: addr = &uc->uc_mcontext.mc_rsp; break; - case UNW_X86_64_RIP: addr = &uc->uc_mcontext.mc_rip; break; - - default: - addr = NULL; - } - return addr; -} - -HIDDEN NORETURN void -x86_64_sigreturn (unw_cursor_t *cursor) -{ - struct cursor *c = (struct cursor *) cursor; - ucontext_t *uc = (ucontext_t *)(c->sigcontext_addr + - offsetof(struct sigframe, sf_uc)); - - uc->uc_mcontext.mc_r8 = c->uc->uc_mcontext.mc_r8; - uc->uc_mcontext.mc_r9 = c->uc->uc_mcontext.mc_r9; - uc->uc_mcontext.mc_r10 = c->uc->uc_mcontext.mc_r10; - uc->uc_mcontext.mc_r11 = c->uc->uc_mcontext.mc_r11; - uc->uc_mcontext.mc_r12 = c->uc->uc_mcontext.mc_r12; - uc->uc_mcontext.mc_r13 = c->uc->uc_mcontext.mc_r13; - uc->uc_mcontext.mc_r14 = c->uc->uc_mcontext.mc_r14; - uc->uc_mcontext.mc_r15 = c->uc->uc_mcontext.mc_r15; - uc->uc_mcontext.mc_rdi = c->uc->uc_mcontext.mc_rdi; - uc->uc_mcontext.mc_rsi = c->uc->uc_mcontext.mc_rsi; - uc->uc_mcontext.mc_rbp = c->uc->uc_mcontext.mc_rbp; - uc->uc_mcontext.mc_rbx = c->uc->uc_mcontext.mc_rbx; - uc->uc_mcontext.mc_rdx = c->uc->uc_mcontext.mc_rdx; - uc->uc_mcontext.mc_rax = c->uc->uc_mcontext.mc_rax; - uc->uc_mcontext.mc_rcx = c->uc->uc_mcontext.mc_rcx; - uc->uc_mcontext.mc_rsp = c->uc->uc_mcontext.mc_rsp; - uc->uc_mcontext.mc_rip = c->uc->uc_mcontext.mc_rip; - - Debug (8, "resuming at ip=%llx via sigreturn(%p)\n", - (unsigned long long) c->dwarf.ip, uc); - sigreturn(uc); - abort(); -} -#endif diff --git a/src/pal/src/libunwind/src/x86_64/Gos-linux.c b/src/pal/src/libunwind/src/x86_64/Gos-linux.c deleted file mode 100644 index bd142345e..000000000 --- a/src/pal/src/libunwind/src/x86_64/Gos-linux.c +++ /dev/null @@ -1,156 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2002-2003 Hewlett-Packard Co - Contributed by David Mosberger-Tang - - Modified for x86_64 by Max Asbock - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" -#include "ucontext_i.h" - -#include - -HIDDEN void -tdep_fetch_frame (struct dwarf_cursor *dw, unw_word_t ip, int need_unwind_info) -{ - struct cursor *c = (struct cursor *) dw; - assert(! need_unwind_info || dw->pi_valid); - assert(! need_unwind_info || dw->pi.unwind_info); - if (dw->pi_valid - && dw->pi.unwind_info - && ((struct dwarf_cie_info *) dw->pi.unwind_info)->signal_frame) - c->sigcontext_format = X86_64_SCF_LINUX_RT_SIGFRAME; - else - c->sigcontext_format = X86_64_SCF_NONE; - - Debug(5, "fetch frame ip=0x%lx cfa=0x%lx format=%d\n", - dw->ip, dw->cfa, c->sigcontext_format); -} - -HIDDEN int -tdep_cache_frame (struct dwarf_cursor *dw) -{ - struct cursor *c = (struct cursor *) dw; - - Debug(5, "cache frame ip=0x%lx cfa=0x%lx format=%d\n", - dw->ip, dw->cfa, c->sigcontext_format); - return c->sigcontext_format; -} - -HIDDEN void -tdep_reuse_frame (struct dwarf_cursor *dw, int frame) -{ - struct cursor *c = (struct cursor *) dw; - c->sigcontext_format = frame; - if (c->sigcontext_format == X86_64_SCF_LINUX_RT_SIGFRAME) - { - c->frame_info.frame_type = UNW_X86_64_FRAME_SIGRETURN; - /* Offset from cfa to ucontext_t in signal frame. */ - c->frame_info.cfa_reg_offset = 0; - c->sigcontext_addr = dw->cfa; - } - - Debug(5, "reuse frame ip=0x%lx cfa=0x%lx format=%d addr=0x%lx offset=%+d\n", - dw->ip, dw->cfa, c->sigcontext_format, c->sigcontext_addr, - (c->sigcontext_format == X86_64_SCF_LINUX_RT_SIGFRAME - ? c->frame_info.cfa_reg_offset : 0)); -} - -int -unw_is_signal_frame (unw_cursor_t *cursor) -{ - struct cursor *c = (struct cursor *) cursor; - return c->sigcontext_format != X86_64_SCF_NONE; -} - -HIDDEN int -x86_64_handle_signal_frame (unw_cursor_t *cursor) -{ -#if UNW_DEBUG /* To silence compiler warnings */ - /* Should not get here because we now use kernel-provided dwarf - information for the signal trampoline and dwarf_step() works. - Hence unw_step() should never call this function. Maybe - restore old non-dwarf signal handling here, but then the - gating on unw_is_signal_frame() needs to be removed. */ - struct cursor *c = (struct cursor *) cursor; - Debug(1, "old format signal frame? format=%d addr=0x%lx cfa=0x%lx\n", - c->sigcontext_format, c->sigcontext_addr, c->dwarf.cfa); -#endif - return -UNW_EBADFRAME; -} - -#ifndef UNW_REMOTE_ONLY -HIDDEN void * -x86_64_r_uc_addr (ucontext_t *uc, int reg) -{ - /* NOTE: common_init() in init.h inlines these for fast path access. */ - void *addr; - - switch (reg) - { - case UNW_X86_64_R8: addr = &uc->uc_mcontext.gregs[REG_R8]; break; - case UNW_X86_64_R9: addr = &uc->uc_mcontext.gregs[REG_R9]; break; - case UNW_X86_64_R10: addr = &uc->uc_mcontext.gregs[REG_R10]; break; - case UNW_X86_64_R11: addr = &uc->uc_mcontext.gregs[REG_R11]; break; - case UNW_X86_64_R12: addr = &uc->uc_mcontext.gregs[REG_R12]; break; - case UNW_X86_64_R13: addr = &uc->uc_mcontext.gregs[REG_R13]; break; - case UNW_X86_64_R14: addr = &uc->uc_mcontext.gregs[REG_R14]; break; - case UNW_X86_64_R15: addr = &uc->uc_mcontext.gregs[REG_R15]; break; - case UNW_X86_64_RDI: addr = &uc->uc_mcontext.gregs[REG_RDI]; break; - case UNW_X86_64_RSI: addr = &uc->uc_mcontext.gregs[REG_RSI]; break; - case UNW_X86_64_RBP: addr = &uc->uc_mcontext.gregs[REG_RBP]; break; - case UNW_X86_64_RBX: addr = &uc->uc_mcontext.gregs[REG_RBX]; break; - case UNW_X86_64_RDX: addr = &uc->uc_mcontext.gregs[REG_RDX]; break; - case UNW_X86_64_RAX: addr = &uc->uc_mcontext.gregs[REG_RAX]; break; - case UNW_X86_64_RCX: addr = &uc->uc_mcontext.gregs[REG_RCX]; break; - case UNW_X86_64_RSP: addr = &uc->uc_mcontext.gregs[REG_RSP]; break; - case UNW_X86_64_RIP: addr = &uc->uc_mcontext.gregs[REG_RIP]; break; - - default: - addr = NULL; - } - return addr; -} - -/* sigreturn() is a no-op on x86_64 glibc. */ -HIDDEN NORETURN void -x86_64_sigreturn (unw_cursor_t *cursor) -{ - struct cursor *c = (struct cursor *) cursor; - struct sigcontext *sc = (struct sigcontext *) c->sigcontext_addr; - mcontext_t *sc_mcontext = &((ucontext_t*)sc)->uc_mcontext; - /* Copy in saved uc - all preserved regs are at the start of sigcontext */ - memcpy(sc_mcontext, &c->uc->uc_mcontext, - DWARF_NUM_PRESERVED_REGS * sizeof(unw_word_t)); - - Debug (8, "resuming at ip=%llx via sigreturn(%p)\n", - (unsigned long long) c->dwarf.ip, sc); - __asm__ __volatile__ ("mov %0, %%rsp;" - "mov %1, %%rax;" - "syscall" - :: "r"(sc), "i"(SYS_rt_sigreturn) - : "memory"); - abort(); -} - -#endif diff --git a/src/pal/src/libunwind/src/x86_64/Greg_states_iterate.c b/src/pal/src/libunwind/src/x86_64/Greg_states_iterate.c deleted file mode 100644 index a17dc1b56..000000000 --- a/src/pal/src/libunwind/src/x86_64/Greg_states_iterate.c +++ /dev/null @@ -1,37 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (c) 2002-2003 Hewlett-Packard Development Company, L.P. - Contributed by David Mosberger-Tang - - Modified for x86_64 by Max Asbock - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" - -int -unw_reg_states_iterate (unw_cursor_t *cursor, - unw_reg_states_callback cb, void *token) -{ - struct cursor *c = (struct cursor *) cursor; - - return dwarf_reg_states_iterate (&c->dwarf, cb, token); -} diff --git a/src/pal/src/libunwind/src/x86_64/Gregs.c b/src/pal/src/libunwind/src/x86_64/Gregs.c deleted file mode 100644 index baf8a24f0..000000000 --- a/src/pal/src/libunwind/src/x86_64/Gregs.c +++ /dev/null @@ -1,138 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (c) 2002-2004 Hewlett-Packard Development Company, L.P. - Contributed by David Mosberger-Tang - - Modified for x86_64 by Max Asbock - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" - -#if 0 -static inline dwarf_loc_t -linux_scratch_loc (struct cursor *c, unw_regnum_t reg) -{ - unw_word_t addr = c->sigcontext_addr; - - switch (c->sigcontext_format) - { - case X86_64_SCF_NONE: - return DWARF_REG_LOC (&c->dwarf, reg); - - case X86_64_SCF_LINUX_RT_SIGFRAME: - addr += LINUX_UC_MCONTEXT_OFF; - break; - - case X86_64_SCF_FREEBSD_SIGFRAME: - addr += FREEBSD_UC_MCONTEXT_OFF; - break; - } - - return DWARF_REG_LOC (&c->dwarf, reg); - -} - -HIDDEN dwarf_loc_t -x86_64_scratch_loc (struct cursor *c, unw_regnum_t reg) -{ - if (c->sigcontext_addr) - return linux_scratch_loc (c, reg); - else - return DWARF_REG_LOC (&c->dwarf, reg); -} -#endif - -HIDDEN int -tdep_access_reg (struct cursor *c, unw_regnum_t reg, unw_word_t *valp, - int write) -{ - dwarf_loc_t loc = DWARF_NULL_LOC; - unsigned int mask; - int arg_num; - - switch (reg) - { - - case UNW_X86_64_RIP: - if (write) - c->dwarf.ip = *valp; /* also update the RIP cache */ - loc = c->dwarf.loc[RIP]; - break; - - case UNW_X86_64_CFA: - case UNW_X86_64_RSP: - if (write) - return -UNW_EREADONLYREG; - *valp = c->dwarf.cfa; - return 0; - - case UNW_X86_64_RAX: - case UNW_X86_64_RDX: - arg_num = reg - UNW_X86_64_RAX; - mask = (1 << arg_num); - if (write) - { - c->dwarf.eh_args[arg_num] = *valp; - c->dwarf.eh_valid_mask |= mask; - return 0; - } - else if ((c->dwarf.eh_valid_mask & mask) != 0) - { - *valp = c->dwarf.eh_args[arg_num]; - return 0; - } - else - loc = c->dwarf.loc[(reg == UNW_X86_64_RAX) ? RAX : RDX]; - break; - - case UNW_X86_64_RCX: loc = c->dwarf.loc[RCX]; break; - case UNW_X86_64_RBX: loc = c->dwarf.loc[RBX]; break; - - case UNW_X86_64_RBP: loc = c->dwarf.loc[RBP]; break; - case UNW_X86_64_RSI: loc = c->dwarf.loc[RSI]; break; - case UNW_X86_64_RDI: loc = c->dwarf.loc[RDI]; break; - case UNW_X86_64_R8: loc = c->dwarf.loc[R8]; break; - case UNW_X86_64_R9: loc = c->dwarf.loc[R9]; break; - case UNW_X86_64_R10: loc = c->dwarf.loc[R10]; break; - case UNW_X86_64_R11: loc = c->dwarf.loc[R11]; break; - case UNW_X86_64_R12: loc = c->dwarf.loc[R12]; break; - case UNW_X86_64_R13: loc = c->dwarf.loc[R13]; break; - case UNW_X86_64_R14: loc = c->dwarf.loc[R14]; break; - case UNW_X86_64_R15: loc = c->dwarf.loc[R15]; break; - - default: - Debug (1, "bad register number %u\n", reg); - return -UNW_EBADREG; - } - - if (write) - return dwarf_put (&c->dwarf, loc, *valp); - else - return dwarf_get (&c->dwarf, loc, valp); -} - -HIDDEN int -tdep_access_fpreg (struct cursor *c, unw_regnum_t reg, unw_fpreg_t *valp, - int write) -{ - return -UNW_EBADREG; -} diff --git a/src/pal/src/libunwind/src/x86_64/Gresume.c b/src/pal/src/libunwind/src/x86_64/Gresume.c deleted file mode 100644 index 944cdaae1..000000000 --- a/src/pal/src/libunwind/src/x86_64/Gresume.c +++ /dev/null @@ -1,123 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (c) 2002-2004 Hewlett-Packard Development Company, L.P. - Contributed by David Mosberger-Tang - - Modified for x86_64 by Max Asbock - -This file is part of libunwind. - -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. */ - -#include - -#include "offsets.h" -#include "unwind_i.h" - -#ifndef UNW_REMOTE_ONLY - -HIDDEN inline int -x86_64_local_resume (unw_addr_space_t as, unw_cursor_t *cursor, void *arg) -{ - struct cursor *c = (struct cursor *) cursor; - ucontext_t *uc = c->uc; - - /* Ensure c->pi is up-to-date. On x86-64, it's relatively common to - be missing DWARF unwind info. We don't want to fail in that - case, because the frame-chain still would let us do a backtrace - at least. */ - dwarf_make_proc_info (&c->dwarf); - - if (unlikely (c->sigcontext_addr != X86_64_SCF_NONE)) - { - x86_64_sigreturn(cursor); - abort(); - } - else - { - Debug (8, "resuming at ip=%llx via setcontext()\n", - (unsigned long long) c->dwarf.ip); - setcontext (uc); - } - return -UNW_EINVAL; -} - -#endif /* !UNW_REMOTE_ONLY */ - -/* This routine is responsible for copying the register values in - cursor C and establishing them as the current machine state. */ - -static inline int -establish_machine_state (struct cursor *c) -{ - int (*access_reg) (unw_addr_space_t, unw_regnum_t, unw_word_t *, - int write, void *); - int (*access_fpreg) (unw_addr_space_t, unw_regnum_t, unw_fpreg_t *, - int write, void *); - unw_addr_space_t as = c->dwarf.as; - void *arg = c->dwarf.as_arg; - unw_fpreg_t fpval; - unw_word_t val; - int reg; - - access_reg = as->acc.access_reg; - access_fpreg = as->acc.access_fpreg; - - Debug (8, "copying out cursor state\n"); - - for (reg = 0; reg <= UNW_REG_LAST; ++reg) - { - Debug (16, "copying %s %d\n", unw_regname (reg), reg); - if (unw_is_fpreg (reg)) - { - if (tdep_access_fpreg (c, reg, &fpval, 0) >= 0) - (*access_fpreg) (as, reg, &fpval, 1, arg); - } - else - { - if (tdep_access_reg (c, reg, &val, 0) >= 0) - (*access_reg) (as, reg, &val, 1, arg); - } - } - - if (c->dwarf.args_size) - { - if (tdep_access_reg (c, UNW_X86_64_RSP, &val, 0) >= 0) - { - val += c->dwarf.args_size; - (*access_reg) (as, UNW_X86_64_RSP, &val, 1, arg); - } - } - return 0; -} - -int -unw_resume (unw_cursor_t *cursor) -{ - struct cursor *c = (struct cursor *) cursor; - int ret; - - Debug (1, "(cursor=%p)\n", c); - - if ((ret = establish_machine_state (c)) < 0) - return ret; - - return (*c->dwarf.as->acc.resume) (c->dwarf.as, (unw_cursor_t *) c, - c->dwarf.as_arg); -} diff --git a/src/pal/src/libunwind/src/x86_64/Gstash_frame.c b/src/pal/src/libunwind/src/x86_64/Gstash_frame.c deleted file mode 100644 index 2c7bc312e..000000000 --- a/src/pal/src/libunwind/src/x86_64/Gstash_frame.c +++ /dev/null @@ -1,119 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2010, 2011 by FERMI NATIONAL ACCELERATOR LABORATORY - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" -#include "ucontext_i.h" - -HIDDEN void -tdep_stash_frame (struct dwarf_cursor *d, struct dwarf_reg_state *rs) -{ - struct cursor *c = (struct cursor *) dwarf_to_cursor (d); - unw_tdep_frame_t *f = &c->frame_info; - - Debug (4, "ip=0x%lx cfa=0x%lx type %d cfa [where=%d val=%ld] cfaoff=%ld" - " ra=0x%lx rbp [where=%d val=%ld @0x%lx] rsp [where=%d val=%ld @0x%lx]\n", - d->ip, d->cfa, f->frame_type, - rs->reg.where[DWARF_CFA_REG_COLUMN], - rs->reg.val[DWARF_CFA_REG_COLUMN], - rs->reg.val[DWARF_CFA_OFF_COLUMN], - DWARF_GET_LOC(d->loc[rs->ret_addr_column]), - rs->reg.where[RBP], rs->reg.val[RBP], DWARF_GET_LOC(d->loc[RBP]), - rs->reg.where[RSP], rs->reg.val[RSP], DWARF_GET_LOC(d->loc[RSP])); - - if (rs->reg.where[DWARF_CFA_REG_COLUMN] == DWARF_WHERE_EXPR && - rs->reg.where[RBP] == DWARF_WHERE_EXPR) { - /* Check for GCC generated alignment frame for rsp. A simple - * def_cfa_expr that loads a constant offset from rbp, where the - * addres of the rip was pushed on the stack */ - unw_word_t cfa_addr = rs->reg.val[DWARF_CFA_REG_COLUMN]; - unw_word_t rbp_addr = rs->reg.val[RBP]; - unw_word_t cfa_offset; - - int ret = dwarf_stack_aligned(d, cfa_addr, rbp_addr, &cfa_offset); - if (ret) { - f->frame_type = UNW_X86_64_FRAME_ALIGNED; - f->cfa_reg_offset = cfa_offset; - f->cfa_reg_rsp = 0; - } - } - - /* A standard frame is defined as: - - CFA is register-relative offset off RBP or RSP; - - Return address is saved at CFA-8; - - RBP is unsaved or saved at CFA+offset, offset != -1; - - RSP is unsaved or saved at CFA+offset, offset != -1. */ - if (f->frame_type == UNW_X86_64_FRAME_OTHER - && (rs->reg.where[DWARF_CFA_REG_COLUMN] == DWARF_WHERE_REG) - && (rs->reg.val[DWARF_CFA_REG_COLUMN] == RBP - || rs->reg.val[DWARF_CFA_REG_COLUMN] == RSP) - && labs((long) rs->reg.val[DWARF_CFA_OFF_COLUMN]) < (1 << 28) - && DWARF_GET_LOC(d->loc[rs->ret_addr_column]) == d->cfa-8 - && (rs->reg.where[RBP] == DWARF_WHERE_UNDEF - || rs->reg.where[RBP] == DWARF_WHERE_SAME - || (rs->reg.where[RBP] == DWARF_WHERE_CFAREL - && labs((long) rs->reg.val[RBP]) < (1 << 14) - && rs->reg.val[RBP]+1 != 0)) - && (rs->reg.where[RSP] == DWARF_WHERE_UNDEF - || rs->reg.where[RSP] == DWARF_WHERE_SAME - || (rs->reg.where[RSP] == DWARF_WHERE_CFAREL - && labs((long) rs->reg.val[RSP]) < (1 << 14) - && rs->reg.val[RSP]+1 != 0))) - { - /* Save information for a standard frame. */ - f->frame_type = UNW_X86_64_FRAME_STANDARD; - f->cfa_reg_rsp = (rs->reg.val[DWARF_CFA_REG_COLUMN] == RSP); - f->cfa_reg_offset = rs->reg.val[DWARF_CFA_OFF_COLUMN]; - if (rs->reg.where[RBP] == DWARF_WHERE_CFAREL) - f->rbp_cfa_offset = rs->reg.val[RBP]; - if (rs->reg.where[RSP] == DWARF_WHERE_CFAREL) - f->rsp_cfa_offset = rs->reg.val[RSP]; - Debug (4, " standard frame\n"); - } - - /* Signal frame was detected via augmentation in tdep_fetch_frame() */ - else if (f->frame_type == UNW_X86_64_FRAME_SIGRETURN) - { - /* Later we are going to fish out {RBP,RSP,RIP} from sigcontext via - their ucontext_t offsets. Confirm DWARF info agrees with the - offsets we expect. */ - -#ifndef NDEBUG - const unw_word_t uc = c->sigcontext_addr; - - assert (DWARF_GET_LOC(d->loc[RIP]) - uc == UC_MCONTEXT_GREGS_RIP); - assert (DWARF_GET_LOC(d->loc[RBP]) - uc == UC_MCONTEXT_GREGS_RBP); - assert (DWARF_GET_LOC(d->loc[RSP]) - uc == UC_MCONTEXT_GREGS_RSP); -#endif - - Debug (4, " sigreturn frame\n"); - } - - else if (f->frame_type == UNW_X86_64_FRAME_ALIGNED) { - Debug (4, " aligned frame, offset %li\n", f->cfa_reg_offset); - } - - /* PLT and guessed RBP-walked frames are handled in unw_step(). */ - else - Debug (4, " unusual frame\n"); -} diff --git a/src/pal/src/libunwind/src/x86_64/Gstep.c b/src/pal/src/libunwind/src/x86_64/Gstep.c deleted file mode 100644 index 10498170a..000000000 --- a/src/pal/src/libunwind/src/x86_64/Gstep.c +++ /dev/null @@ -1,227 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2002-2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - - Modified for x86_64 by Max Asbock - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" -#include - -/* Recognise PLT entries such as: - 3bdf0: ff 25 e2 49 13 00 jmpq *0x1349e2(%rip) - 3bdf6: 68 ae 03 00 00 pushq $0x3ae - 3bdfb: e9 00 c5 ff ff jmpq 38300 <_init+0x18> */ -static int -is_plt_entry (struct dwarf_cursor *c) -{ - unw_word_t w0, w1; - unw_accessors_t *a; - int ret; - - a = unw_get_accessors_int (c->as); - if ((ret = (*a->access_mem) (c->as, c->ip, &w0, 0, c->as_arg)) < 0 - || (ret = (*a->access_mem) (c->as, c->ip + 8, &w1, 0, c->as_arg)) < 0) - return 0; - - ret = (((w0 & 0xffff) == 0x25ff) - && (((w0 >> 48) & 0xff) == 0x68) - && (((w1 >> 24) & 0xff) == 0xe9)); - - Debug (14, "ip=0x%lx => 0x%016lx 0x%016lx, ret = %d\n", c->ip, w0, w1, ret); - return ret; -} - -int -unw_step (unw_cursor_t *cursor) -{ - struct cursor *c = (struct cursor *) cursor; - int ret, i; - -#if CONSERVATIVE_CHECKS - int val = c->validate; - c->validate = 1; -#endif - - Debug (1, "(cursor=%p, ip=0x%016lx, cfa=0x%016lx)\n", - c, c->dwarf.ip, c->dwarf.cfa); - - /* Try DWARF-based unwinding... */ - c->sigcontext_format = X86_64_SCF_NONE; - ret = dwarf_step (&c->dwarf); - -#if CONSERVATIVE_CHECKS - c->validate = val; -#endif - - if (ret < 0 && ret != -UNW_ENOINFO) - { - Debug (2, "returning %d\n", ret); - return ret; - } - - if (likely (ret >= 0)) - { - /* x86_64 ABI specifies that end of call-chain is marked with a - NULL RBP or undefined return address */ - if (DWARF_IS_NULL_LOC (c->dwarf.loc[RBP])) - { - c->dwarf.ip = 0; - ret = 0; - } - } - else - { - /* DWARF failed. There isn't much of a usable frame-chain on x86-64, - but we do need to handle two special-cases: - - (i) signal trampoline: Old kernels and older libcs don't - export the vDSO needed to get proper unwind info for the - trampoline. Recognize that case by looking at the code - and filling in things by hand. - - (ii) PLT (shared-library) call-stubs: PLT stubs are invoked - via CALLQ. Try this for all non-signal trampoline - code. */ - - unw_word_t prev_ip = c->dwarf.ip, prev_cfa = c->dwarf.cfa; - struct dwarf_loc rbp_loc, rsp_loc, rip_loc; - - /* We could get here because of missing/bad unwind information. - Validate all addresses before dereferencing. */ - c->validate = 1; - - Debug (13, "dwarf_step() failed (ret=%d), trying frame-chain\n", ret); - - if (unw_is_signal_frame (cursor) > 0) - { - ret = x86_64_handle_signal_frame(cursor); - if (ret < 0) - { - Debug (2, "returning 0\n"); - return 0; - } - } - else if (is_plt_entry (&c->dwarf)) - { - /* Like regular frame, CFA = RSP+8, RA = [CFA-8], no regs saved. */ - Debug (2, "found plt entry\n"); - c->frame_info.cfa_reg_offset = 8; - c->frame_info.cfa_reg_rsp = -1; - c->frame_info.frame_type = UNW_X86_64_FRAME_STANDARD; - c->dwarf.loc[RIP] = DWARF_LOC (c->dwarf.cfa, 0); - c->dwarf.cfa += 8; - } - else if (DWARF_IS_NULL_LOC (c->dwarf.loc[RBP])) - { - for (i = 0; i < DWARF_NUM_PRESERVED_REGS; ++i) - c->dwarf.loc[i] = DWARF_NULL_LOC; - } - else - { - unw_word_t rbp; - - ret = dwarf_get (&c->dwarf, c->dwarf.loc[RBP], &rbp); - if (ret < 0) - { - Debug (2, "returning %d [RBP=0x%lx]\n", ret, - DWARF_GET_LOC (c->dwarf.loc[RBP])); - return ret; - } - - if (!rbp) - { - /* Looks like we may have reached the end of the call-chain. */ - rbp_loc = DWARF_NULL_LOC; - rsp_loc = DWARF_NULL_LOC; - rip_loc = DWARF_NULL_LOC; - } - else - { - unw_word_t rbp1 = 0; - rbp_loc = DWARF_LOC(rbp, 0); - rsp_loc = DWARF_NULL_LOC; - rip_loc = DWARF_LOC (rbp + 8, 0); - ret = dwarf_get (&c->dwarf, rbp_loc, &rbp1); - Debug (1, "[RBP=0x%lx] = 0x%lx (cfa = 0x%lx) -> 0x%lx\n", - (unsigned long) DWARF_GET_LOC (c->dwarf.loc[RBP]), - rbp, c->dwarf.cfa, rbp1); - - /* Heuristic to determine incorrect guess. For RBP to be a - valid frame it needs to be above current CFA, but don't - let it go more than a little. Note that we can't deduce - anything about new RBP (rbp1) since it may not be a frame - pointer in the frame above. Just check we get the value. */ - if (ret < 0 - || rbp < c->dwarf.cfa - || (rbp - c->dwarf.cfa) > 0x4000) - { - rip_loc = DWARF_NULL_LOC; - rbp_loc = DWARF_NULL_LOC; - } - - c->frame_info.frame_type = UNW_X86_64_FRAME_GUESSED; - c->frame_info.cfa_reg_rsp = 0; - c->frame_info.cfa_reg_offset = 16; - c->frame_info.rbp_cfa_offset = -16; - c->dwarf.cfa += 16; - } - - /* Mark all registers unsaved */ - for (i = 0; i < DWARF_NUM_PRESERVED_REGS; ++i) - c->dwarf.loc[i] = DWARF_NULL_LOC; - - c->dwarf.loc[RBP] = rbp_loc; - c->dwarf.loc[RSP] = rsp_loc; - c->dwarf.loc[RIP] = rip_loc; - c->dwarf.use_prev_instr = 1; - } - - if (DWARF_IS_NULL_LOC (c->dwarf.loc[RBP])) - { - ret = 0; - Debug (2, "NULL %%rbp loc, returning %d\n", ret); - return ret; - } - if (!DWARF_IS_NULL_LOC (c->dwarf.loc[RIP])) - { - ret = dwarf_get (&c->dwarf, c->dwarf.loc[RIP], &c->dwarf.ip); - Debug (1, "Frame Chain [RIP=0x%Lx] = 0x%Lx\n", - (unsigned long long) DWARF_GET_LOC (c->dwarf.loc[RIP]), - (unsigned long long) c->dwarf.ip); - if (ret < 0) - { - Debug (2, "returning %d\n", ret); - return ret; - } - ret = 1; - } - else - c->dwarf.ip = 0; - - if (c->dwarf.ip == prev_ip && c->dwarf.cfa == prev_cfa) - return -UNW_EBADFRAME; - } - Debug (2, "returning %d\n", ret); - return ret; -} diff --git a/src/pal/src/libunwind/src/x86_64/Gtrace.c b/src/pal/src/libunwind/src/x86_64/Gtrace.c deleted file mode 100644 index 741227105..000000000 --- a/src/pal/src/libunwind/src/x86_64/Gtrace.c +++ /dev/null @@ -1,551 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2010, 2011 by FERMI NATIONAL ACCELERATOR LABORATORY - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" -#include "ucontext_i.h" -#include -#include - -#pragma weak pthread_once -#pragma weak pthread_key_create -#pragma weak pthread_getspecific -#pragma weak pthread_setspecific - -/* Initial hash table size. Table expands by 2 bits (times four). */ -#define HASH_MIN_BITS 14 - -typedef struct -{ - unw_tdep_frame_t *frames; - size_t log_size; - size_t used; - size_t dtor_count; /* Counts how many times our destructor has already - been called. */ -} unw_trace_cache_t; - -static const unw_tdep_frame_t empty_frame = { 0, UNW_X86_64_FRAME_OTHER, -1, -1, 0, -1, -1 }; -static define_lock (trace_init_lock); -static pthread_once_t trace_cache_once = PTHREAD_ONCE_INIT; -static sig_atomic_t trace_cache_once_happen; -static pthread_key_t trace_cache_key; -static struct mempool trace_cache_pool; -static __thread unw_trace_cache_t *tls_cache; -static __thread int tls_cache_destroyed; - -/* Free memory for a thread's trace cache. */ -static void -trace_cache_free (void *arg) -{ - unw_trace_cache_t *cache = arg; - if (++cache->dtor_count < PTHREAD_DESTRUCTOR_ITERATIONS) - { - /* Not yet our turn to get destroyed. Re-install ourselves into the key. */ - pthread_setspecific(trace_cache_key, cache); - Debug(5, "delayed freeing cache %p (%zx to go)\n", cache, - PTHREAD_DESTRUCTOR_ITERATIONS - cache->dtor_count); - return; - } - tls_cache_destroyed = 1; - tls_cache = NULL; - munmap (cache->frames, (1u << cache->log_size) * sizeof(unw_tdep_frame_t)); - mempool_free (&trace_cache_pool, cache); - Debug(5, "freed cache %p\n", cache); -} - -/* Initialise frame tracing for threaded use. */ -static void -trace_cache_init_once (void) -{ - pthread_key_create (&trace_cache_key, &trace_cache_free); - mempool_init (&trace_cache_pool, sizeof (unw_trace_cache_t), 0); - trace_cache_once_happen = 1; -} - -static unw_tdep_frame_t * -trace_cache_buckets (size_t n) -{ - unw_tdep_frame_t *frames; - size_t i; - - GET_MEMORY(frames, n * sizeof (unw_tdep_frame_t)); - if (likely(frames != NULL)) - for (i = 0; i < n; ++i) - frames[i] = empty_frame; - - return frames; -} - -/* Allocate and initialise hash table for frame cache lookups. - Returns the cache initialised with (1u << HASH_LOW_BITS) hash - buckets, or NULL if there was a memory allocation problem. */ -static unw_trace_cache_t * -trace_cache_create (void) -{ - unw_trace_cache_t *cache; - - if (tls_cache_destroyed) - { - /* The current thread is in the process of exiting. Don't recreate - cache, as we wouldn't have another chance to free it. */ - Debug(5, "refusing to reallocate cache: " - "thread-locals are being deallocated\n"); - return NULL; - } - - if (! (cache = mempool_alloc(&trace_cache_pool))) - { - Debug(5, "failed to allocate cache\n"); - return NULL; - } - - if (! (cache->frames = trace_cache_buckets(1u << HASH_MIN_BITS))) - { - Debug(5, "failed to allocate buckets\n"); - mempool_free(&trace_cache_pool, cache); - return NULL; - } - - cache->log_size = HASH_MIN_BITS; - cache->used = 0; - cache->dtor_count = 0; - tls_cache_destroyed = 0; /* Paranoia: should already be 0. */ - Debug(5, "allocated cache %p\n", cache); - return cache; -} - -/* Expand the hash table in the frame cache if possible. This always - quadruples the hash size, and clears all previous frame entries. */ -static int -trace_cache_expand (unw_trace_cache_t *cache) -{ - size_t old_size = (1u << cache->log_size); - size_t new_log_size = cache->log_size + 2; - unw_tdep_frame_t *new_frames = trace_cache_buckets (1u << new_log_size); - - if (unlikely(! new_frames)) - { - Debug(5, "failed to expand cache to 2^%lu buckets\n", new_log_size); - return -UNW_ENOMEM; - } - - Debug(5, "expanded cache from 2^%lu to 2^%lu buckets\n", cache->log_size, new_log_size); - munmap(cache->frames, old_size * sizeof(unw_tdep_frame_t)); - cache->frames = new_frames; - cache->log_size = new_log_size; - cache->used = 0; - return 0; -} - -static unw_trace_cache_t * -trace_cache_get_unthreaded (void) -{ - unw_trace_cache_t *cache; - intrmask_t saved_mask; - static unw_trace_cache_t *global_cache = NULL; - lock_acquire (&trace_init_lock, saved_mask); - if (! global_cache) - { - mempool_init (&trace_cache_pool, sizeof (unw_trace_cache_t), 0); - global_cache = trace_cache_create (); - } - cache = global_cache; - lock_release (&trace_init_lock, saved_mask); - Debug(5, "using cache %p\n", cache); - return cache; -} - -/* Get the frame cache for the current thread. Create it if there is none. */ -static unw_trace_cache_t * -trace_cache_get (void) -{ - unw_trace_cache_t *cache; - if (likely (pthread_once != NULL)) - { - pthread_once(&trace_cache_once, &trace_cache_init_once); - if (!trace_cache_once_happen) - { - return trace_cache_get_unthreaded(); - } - if (! (cache = tls_cache)) - { - cache = trace_cache_create(); - pthread_setspecific(trace_cache_key, cache); - tls_cache = cache; - } - Debug(5, "using cache %p\n", cache); - return cache; - } - else - { - return trace_cache_get_unthreaded(); - } -} - -/* Initialise frame properties for address cache slot F at address - RIP using current CFA, RBP and RSP values. Modifies CURSOR to - that location, performs one unw_step(), and fills F with what - was discovered about the location. Returns F. - - FIXME: This probably should tell DWARF handling to never evaluate - or use registers other than RBP, RSP and RIP in case there is - highly unusual unwind info which uses these creatively. */ -static unw_tdep_frame_t * -trace_init_addr (unw_tdep_frame_t *f, - unw_cursor_t *cursor, - unw_word_t cfa, - unw_word_t rip, - unw_word_t rbp, - unw_word_t rsp) -{ - struct cursor *c = (struct cursor *) cursor; - struct dwarf_cursor *d = &c->dwarf; - int ret = -UNW_EINVAL; - - /* Initialise frame properties: unknown, not last. */ - f->virtual_address = rip; - f->frame_type = UNW_X86_64_FRAME_OTHER; - f->last_frame = 0; - f->cfa_reg_rsp = -1; - f->cfa_reg_offset = 0; - f->rbp_cfa_offset = -1; - f->rsp_cfa_offset = -1; - - /* Reinitialise cursor to this instruction - but undo next/prev RIP - adjustment because unw_step will redo it - and force RIP, RBP - RSP into register locations (=~ ucontext we keep), then set - their desired values. Then perform the step. */ - d->ip = rip + d->use_prev_instr; - d->cfa = cfa; - d->loc[UNW_X86_64_RIP] = DWARF_REG_LOC (d, UNW_X86_64_RIP); - d->loc[UNW_X86_64_RBP] = DWARF_REG_LOC (d, UNW_X86_64_RBP); - d->loc[UNW_X86_64_RSP] = DWARF_REG_LOC (d, UNW_X86_64_RSP); - c->frame_info = *f; - - if (likely(dwarf_put (d, d->loc[UNW_X86_64_RIP], rip) >= 0) - && likely(dwarf_put (d, d->loc[UNW_X86_64_RBP], rbp) >= 0) - && likely(dwarf_put (d, d->loc[UNW_X86_64_RSP], rsp) >= 0) - && likely((ret = unw_step (cursor)) >= 0)) - *f = c->frame_info; - - /* If unw_step() stopped voluntarily, remember that, even if it - otherwise could not determine anything useful. This avoids - failing trace if we hit frames without unwind info, which is - common for the outermost frame (CRT stuff) on many systems. - This avoids failing trace in very common circumstances; failing - to unw_step() loop wouldn't produce any better result. */ - if (ret == 0) - f->last_frame = -1; - - Debug (3, "frame va %lx type %d last %d cfa %s+%d rbp @ cfa%+d rsp @ cfa%+d\n", - f->virtual_address, f->frame_type, f->last_frame, - f->cfa_reg_rsp ? "rsp" : "rbp", f->cfa_reg_offset, - f->rbp_cfa_offset, f->rsp_cfa_offset); - - return f; -} - -/* Look up and if necessary fill in frame attributes for address RIP - in CACHE using current CFA, RBP and RSP values. Uses CURSOR to - perform any unwind steps necessary to fill the cache. Returns the - frame cache slot which describes RIP. */ -static unw_tdep_frame_t * -trace_lookup (unw_cursor_t *cursor, - unw_trace_cache_t *cache, - unw_word_t cfa, - unw_word_t rip, - unw_word_t rbp, - unw_word_t rsp) -{ - /* First look up for previously cached information using cache as - linear probing hash table with probe step of 1. Majority of - lookups should be completed within few steps, but it is very - important the hash table does not fill up, or performance falls - off the cliff. */ - uint64_t i, addr; - uint64_t cache_size = 1u << cache->log_size; - uint64_t slot = ((rip * 0x9e3779b97f4a7c16) >> 43) & (cache_size-1); - unw_tdep_frame_t *frame; - - for (i = 0; i < 16; ++i) - { - frame = &cache->frames[slot]; - addr = frame->virtual_address; - - /* Return if we found the address. */ - if (likely(addr == rip)) - { - Debug (4, "found address after %ld steps\n", i); - return frame; - } - - /* If slot is empty, reuse it. */ - if (likely(! addr)) - break; - - /* Linear probe to next slot candidate, step = 1. */ - if (++slot >= cache_size) - slot -= cache_size; - } - - /* If we collided after 16 steps, or if the hash is more than half - full, force the hash to expand. Fill the selected slot, whether - it's free or collides. Note that hash expansion drops previous - contents; further lookups will refill the hash. */ - Debug (4, "updating slot %lu after %ld steps, replacing 0x%lx\n", slot, i, addr); - if (unlikely(addr || cache->used >= cache_size / 2)) - { - if (unlikely(trace_cache_expand (cache) < 0)) - return NULL; - - cache_size = 1u << cache->log_size; - slot = ((rip * 0x9e3779b97f4a7c16) >> 43) & (cache_size-1); - frame = &cache->frames[slot]; - addr = frame->virtual_address; - } - - if (! addr) - ++cache->used; - - return trace_init_addr (frame, cursor, cfa, rip, rbp, rsp); -} - -/* Fast stack backtrace for x86-64. - - This is used by backtrace() implementation to accelerate frequent - queries for current stack, without any desire to unwind. It fills - BUFFER with the call tree from CURSOR upwards for at most SIZE - stack levels. The first frame, backtrace itself, is omitted. When - called, SIZE should give the maximum number of entries that can be - stored into BUFFER. Uses an internal thread-specific cache to - accelerate queries. - - The caller should fall back to a unw_step() loop if this function - fails by returning -UNW_ESTOPUNWIND, meaning the routine hit a - stack frame that is too complex to be traced in the fast path. - - This function is tuned for clients which only need to walk the - stack to get the call tree as fast as possible but without any - other details, for example profilers sampling the stack thousands - to millions of times per second. The routine handles the most - common x86-64 ABI stack layouts: CFA is RBP or RSP plus/minus - constant offset, return address is at CFA-8, and RBP and RSP are - either unchanged or saved on stack at constant offset from the CFA; - the signal return frame; and frames without unwind info provided - they are at the outermost (final) frame or can conservatively be - assumed to be frame-pointer based. - - Any other stack layout will cause the routine to give up. There - are only a handful of relatively rarely used functions which do - not have a stack in the standard form: vfork, longjmp, setcontext - and _dl_runtime_profile on common linux systems for example. - - On success BUFFER and *SIZE reflect the trace progress up to *SIZE - stack levels or the outermost frame, which ever is less. It may - stop short of outermost frame if unw_step() loop would also do so, - e.g. if there is no more unwind information; this is not reported - as an error. - - The function returns a negative value for errors, -UNW_ESTOPUNWIND - if tracing stopped because of an unusual frame unwind info. The - BUFFER and *SIZE reflect tracing progress up to the error frame. - - Callers of this function would normally look like this: - - unw_cursor_t cur; - unw_context_t ctx; - void addrs[128]; - int depth = 128; - int ret; - - unw_getcontext(&ctx); - unw_init_local(&cur, &ctx); - if ((ret = unw_tdep_trace(&cur, addrs, &depth)) < 0) - { - depth = 0; - unw_getcontext(&ctx); - unw_init_local(&cur, &ctx); - while ((ret = unw_step(&cur)) > 0 && depth < 128) - { - unw_word_t ip; - unw_get_reg(&cur, UNW_REG_IP, &ip); - addresses[depth++] = (void *) ip; - } - } -*/ -HIDDEN int -tdep_trace (unw_cursor_t *cursor, void **buffer, int *size) -{ - struct cursor *c = (struct cursor *) cursor; - struct dwarf_cursor *d = &c->dwarf; - unw_trace_cache_t *cache; - unw_word_t rbp, rsp, rip, cfa; - int maxdepth = 0; - int depth = 0; - int ret; - - /* Check input parametres. */ - if (unlikely(! cursor || ! buffer || ! size || (maxdepth = *size) <= 0)) - return -UNW_EINVAL; - - Debug (1, "begin ip 0x%lx cfa 0x%lx\n", d->ip, d->cfa); - - /* Tell core dwarf routines to call back to us. */ - d->stash_frames = 1; - - /* Determine initial register values. These are direct access safe - because we know they come from the initial machine context. */ - rip = d->ip; - rsp = cfa = d->cfa; - ACCESS_MEM_FAST(ret, 0, d, DWARF_GET_LOC(d->loc[UNW_X86_64_RBP]), rbp); - assert(ret == 0); - - /* Get frame cache. */ - if (unlikely(! (cache = trace_cache_get()))) - { - Debug (1, "returning %d, cannot get trace cache\n", -UNW_ENOMEM); - *size = 0; - d->stash_frames = 0; - return -UNW_ENOMEM; - } - - /* Trace the stack upwards, starting from current RIP. Adjust - the RIP address for previous/next instruction as the main - unwinding logic would also do. We undo this before calling - back into unw_step(). */ - while (depth < maxdepth) - { - rip -= d->use_prev_instr; - Debug (2, "depth %d cfa 0x%lx rip 0x%lx rsp 0x%lx rbp 0x%lx\n", - depth, cfa, rip, rsp, rbp); - - /* See if we have this address cached. If not, evaluate enough of - the dwarf unwind information to fill the cache line data, or to - decide this frame cannot be handled in fast trace mode. We - cache negative results too to prevent unnecessary dwarf parsing - for common failures. */ - unw_tdep_frame_t *f = trace_lookup (cursor, cache, cfa, rip, rbp, rsp); - - /* If we don't have information for this frame, give up. */ - if (unlikely(! f)) - { - ret = -UNW_ENOINFO; - break; - } - - Debug (3, "frame va %lx type %d last %d cfa %s+%d rbp @ cfa%+d rsp @ cfa%+d\n", - f->virtual_address, f->frame_type, f->last_frame, - f->cfa_reg_rsp ? "rsp" : "rbp", f->cfa_reg_offset, - f->rbp_cfa_offset, f->rsp_cfa_offset); - - assert (f->virtual_address == rip); - - /* Stop if this was the last frame. In particular don't evaluate - new register values as it may not be safe - we don't normally - run with full validation on, and do not want to - and there's - enough bad unwind info floating around that we need to trust - what unw_step() previously said, in potentially bogus frames. */ - if (f->last_frame) - break; - - /* Evaluate CFA and registers for the next frame. */ - switch (f->frame_type) - { - case UNW_X86_64_FRAME_GUESSED: - /* Fall thru to standard processing after forcing validation. */ - c->validate = 1; - - case UNW_X86_64_FRAME_STANDARD: - /* Advance standard traceable frame. */ - cfa = (f->cfa_reg_rsp ? rsp : rbp) + f->cfa_reg_offset; - ACCESS_MEM_FAST(ret, c->validate, d, cfa - 8, rip); - if (likely(ret >= 0) && likely(f->rbp_cfa_offset != -1)) - ACCESS_MEM_FAST(ret, c->validate, d, cfa + f->rbp_cfa_offset, rbp); - - /* Don't bother reading RSP from DWARF, CFA becomes new RSP. */ - rsp = cfa; - - /* Next frame needs to back up for unwind info lookup. */ - d->use_prev_instr = 1; - break; - - case UNW_X86_64_FRAME_SIGRETURN: - cfa = cfa + f->cfa_reg_offset; /* cfa now points to ucontext_t. */ - - ACCESS_MEM_FAST(ret, c->validate, d, cfa + UC_MCONTEXT_GREGS_RIP, rip); - if (likely(ret >= 0)) - ACCESS_MEM_FAST(ret, c->validate, d, cfa + UC_MCONTEXT_GREGS_RBP, rbp); - if (likely(ret >= 0)) - ACCESS_MEM_FAST(ret, c->validate, d, cfa + UC_MCONTEXT_GREGS_RSP, rsp); - - /* Resume stack at signal restoration point. The stack is not - necessarily continuous here, especially with sigaltstack(). */ - cfa = rsp; - - /* Next frame should not back up. */ - d->use_prev_instr = 0; - break; - - case UNW_X86_64_FRAME_ALIGNED: - /* Address of RIP was pushed on the stack via a simple - * def_cfa_expr - result stack offset stored in cfa_reg_offset */ - cfa = (f->cfa_reg_rsp ? rsp : rbp) + f->cfa_reg_offset; - ACCESS_MEM_FAST(ret, c->validate, d, cfa, cfa); - if (likely(ret >= 0)) - ACCESS_MEM_FAST(ret, c->validate, d, cfa - 8, rip); - if (likely(ret >= 0)) - ACCESS_MEM_FAST(ret, c->validate, d, rbp, rbp); - - /* Don't bother reading RSP from DWARF, CFA becomes new RSP. */ - rsp = cfa; - - /* Next frame needs to back up for unwind info lookup. */ - d->use_prev_instr = 1; - - break; - - default: - /* We cannot trace through this frame, give up and tell the - caller we had to stop. Data collected so far may still be - useful to the caller, so let it know how far we got. */ - ret = -UNW_ESTOPUNWIND; - break; - } - - Debug (4, "new cfa 0x%lx rip 0x%lx rsp 0x%lx rbp 0x%lx\n", - cfa, rip, rsp, rbp); - - /* If we failed or ended up somewhere bogus, stop. */ - if (unlikely(ret < 0 || rip < 0x4000)) - break; - - /* Record this address in stack trace. We skipped the first address. */ - buffer[depth++] = (void *) (rip - d->use_prev_instr); - } - -#if UNW_DEBUG - Debug (1, "returning %d, depth %d\n", ret, depth); -#endif - *size = depth; - return ret; -} diff --git a/src/pal/src/libunwind/src/x86_64/Lapply_reg_state.c b/src/pal/src/libunwind/src/x86_64/Lapply_reg_state.c deleted file mode 100644 index 7ebada480..000000000 --- a/src/pal/src/libunwind/src/x86_64/Lapply_reg_state.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gapply_reg_state.c" -#endif diff --git a/src/pal/src/libunwind/src/x86_64/Lcreate_addr_space.c b/src/pal/src/libunwind/src/x86_64/Lcreate_addr_space.c deleted file mode 100644 index 0f2dc6be9..000000000 --- a/src/pal/src/libunwind/src/x86_64/Lcreate_addr_space.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gcreate_addr_space.c" -#endif diff --git a/src/pal/src/libunwind/src/x86_64/Lget_proc_info.c b/src/pal/src/libunwind/src/x86_64/Lget_proc_info.c deleted file mode 100644 index 69028b019..000000000 --- a/src/pal/src/libunwind/src/x86_64/Lget_proc_info.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gget_proc_info.c" -#endif diff --git a/src/pal/src/libunwind/src/x86_64/Lget_save_loc.c b/src/pal/src/libunwind/src/x86_64/Lget_save_loc.c deleted file mode 100644 index 9ea048a90..000000000 --- a/src/pal/src/libunwind/src/x86_64/Lget_save_loc.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gget_save_loc.c" -#endif diff --git a/src/pal/src/libunwind/src/x86_64/Lglobal.c b/src/pal/src/libunwind/src/x86_64/Lglobal.c deleted file mode 100644 index 8c43a67c0..000000000 --- a/src/pal/src/libunwind/src/x86_64/Lglobal.c +++ /dev/null @@ -1,6 +0,0 @@ -#define UNW_LOCAL_ONLY -#include "config.h" -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gglobal.c" -#endif diff --git a/src/pal/src/libunwind/src/x86_64/Linit.c b/src/pal/src/libunwind/src/x86_64/Linit.c deleted file mode 100644 index e9abfdd46..000000000 --- a/src/pal/src/libunwind/src/x86_64/Linit.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Ginit.c" -#endif diff --git a/src/pal/src/libunwind/src/x86_64/Linit_local.c b/src/pal/src/libunwind/src/x86_64/Linit_local.c deleted file mode 100644 index 68a1687e8..000000000 --- a/src/pal/src/libunwind/src/x86_64/Linit_local.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Ginit_local.c" -#endif diff --git a/src/pal/src/libunwind/src/x86_64/Linit_remote.c b/src/pal/src/libunwind/src/x86_64/Linit_remote.c deleted file mode 100644 index 58cb04ab7..000000000 --- a/src/pal/src/libunwind/src/x86_64/Linit_remote.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Ginit_remote.c" -#endif diff --git a/src/pal/src/libunwind/src/x86_64/Los-freebsd.c b/src/pal/src/libunwind/src/x86_64/Los-freebsd.c deleted file mode 100644 index a75a205df..000000000 --- a/src/pal/src/libunwind/src/x86_64/Los-freebsd.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gos-freebsd.c" -#endif diff --git a/src/pal/src/libunwind/src/x86_64/Los-linux.c b/src/pal/src/libunwind/src/x86_64/Los-linux.c deleted file mode 100644 index 3cc18aabc..000000000 --- a/src/pal/src/libunwind/src/x86_64/Los-linux.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gos-linux.c" -#endif diff --git a/src/pal/src/libunwind/src/x86_64/Lreg_states_iterate.c b/src/pal/src/libunwind/src/x86_64/Lreg_states_iterate.c deleted file mode 100644 index f1eb1e79d..000000000 --- a/src/pal/src/libunwind/src/x86_64/Lreg_states_iterate.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Greg_states_iterate.c" -#endif diff --git a/src/pal/src/libunwind/src/x86_64/Lregs.c b/src/pal/src/libunwind/src/x86_64/Lregs.c deleted file mode 100644 index 2c9c75cd7..000000000 --- a/src/pal/src/libunwind/src/x86_64/Lregs.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gregs.c" -#endif diff --git a/src/pal/src/libunwind/src/x86_64/Lresume.c b/src/pal/src/libunwind/src/x86_64/Lresume.c deleted file mode 100644 index 41a8cf003..000000000 --- a/src/pal/src/libunwind/src/x86_64/Lresume.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gresume.c" -#endif diff --git a/src/pal/src/libunwind/src/x86_64/Lstash_frame.c b/src/pal/src/libunwind/src/x86_64/Lstash_frame.c deleted file mode 100644 index 77587803d..000000000 --- a/src/pal/src/libunwind/src/x86_64/Lstash_frame.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gstash_frame.c" -#endif diff --git a/src/pal/src/libunwind/src/x86_64/Lstep.c b/src/pal/src/libunwind/src/x86_64/Lstep.c deleted file mode 100644 index c1ac3c754..000000000 --- a/src/pal/src/libunwind/src/x86_64/Lstep.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gstep.c" -#endif diff --git a/src/pal/src/libunwind/src/x86_64/Ltrace.c b/src/pal/src/libunwind/src/x86_64/Ltrace.c deleted file mode 100644 index fcd3f239c..000000000 --- a/src/pal/src/libunwind/src/x86_64/Ltrace.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY) -#include "Gtrace.c" -#endif diff --git a/src/pal/src/libunwind/src/x86_64/getcontext.S b/src/pal/src/libunwind/src/x86_64/getcontext.S deleted file mode 100644 index 7a8b5664b..000000000 --- a/src/pal/src/libunwind/src/x86_64/getcontext.S +++ /dev/null @@ -1,134 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2008 Google, Inc - Contributed by Paul Pluzhnikov - Copyright (C) 2010 Konstantin Belousov - -This file is part of libunwind. - -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. */ - -#include "ucontext_i.h" - -/* int _Ux86_64_getcontext (ucontext_t *ucp) - - Saves the machine context in UCP necessary for libunwind. - Unlike the libc implementation, we don't save the signal mask - and hence avoid the cost of a system call per unwind. - -*/ - - .global _Ux86_64_getcontext - .type _Ux86_64_getcontext, @function -_Ux86_64_getcontext: - .cfi_startproc - - /* Callee saved: RBX, RBP, R12-R15 */ - movq %r12, UC_MCONTEXT_GREGS_R12(%rdi) - movq %r13, UC_MCONTEXT_GREGS_R13(%rdi) - movq %r14, UC_MCONTEXT_GREGS_R14(%rdi) - movq %r15, UC_MCONTEXT_GREGS_R15(%rdi) - movq %rbp, UC_MCONTEXT_GREGS_RBP(%rdi) - movq %rbx, UC_MCONTEXT_GREGS_RBX(%rdi) - - /* Save argument registers (not strictly needed, but setcontext - restores them, so don't restore garbage). */ - movq %r8, UC_MCONTEXT_GREGS_R8(%rdi) - movq %r9, UC_MCONTEXT_GREGS_R9(%rdi) - movq %rdi, UC_MCONTEXT_GREGS_RDI(%rdi) - movq %rsi, UC_MCONTEXT_GREGS_RSI(%rdi) - movq %rdx, UC_MCONTEXT_GREGS_RDX(%rdi) - movq %rax, UC_MCONTEXT_GREGS_RAX(%rdi) - movq %rcx, UC_MCONTEXT_GREGS_RCX(%rdi) - -#if defined __linux__ - /* Save fp state (not needed, except for setcontext not - restoring garbage). */ - leaq UC_MCONTEXT_FPREGS_MEM(%rdi),%r8 - movq %r8, UC_MCONTEXT_FPREGS_PTR(%rdi) - fnstenv (%r8) - stmxcsr FPREGS_OFFSET_MXCSR(%r8) -#elif defined __FreeBSD__ - fxsave UC_MCONTEXT_FPSTATE(%rdi) - movq $UC_MCONTEXT_FPOWNED_FPU,UC_MCONTEXT_OWNEDFP(%rdi) - movq $UC_MCONTEXT_FPFMT_XMM,UC_MCONTEXT_FPFORMAT(%rdi) - /* Save rflags and segment registers, so that sigreturn(2) - does not complain. */ - pushfq - .cfi_adjust_cfa_offset 8 - popq UC_MCONTEXT_RFLAGS(%rdi) - .cfi_adjust_cfa_offset -8 - movl $0, UC_MCONTEXT_FLAGS(%rdi) - movw %cs, UC_MCONTEXT_CS(%rdi) - movw %ss, UC_MCONTEXT_SS(%rdi) -#if 0 - /* Setting the flags to 0 above disables restore of segment - registers from the context */ - movw %ds, UC_MCONTEXT_DS(%rdi) - movw %es, UC_MCONTEXT_ES(%rdi) - movw %fs, UC_MCONTEXT_FS(%rdi) - movw %gs, UC_MCONTEXT_GS(%rdi) -#endif - movq $UC_MCONTEXT_MC_LEN_VAL, UC_MCONTEXT_MC_LEN(%rdi) -#else -#error Port me -#endif - - leaq 8(%rsp), %rax /* exclude this call. */ - movq %rax, UC_MCONTEXT_GREGS_RSP(%rdi) - - movq 0(%rsp), %rax - movq %rax, UC_MCONTEXT_GREGS_RIP(%rdi) - - xorq %rax, %rax - retq - .cfi_endproc - .size _Ux86_64_getcontext, . - _Ux86_64_getcontext - -/* int _Ux86_64_getcontext_trace (ucontext_t *ucp) - - Saves limited machine context in UCP necessary for libunwind. - Unlike _Ux86_64_getcontext, saves only the parts needed for - fast trace. If fast trace fails, caller will have to get the - full context. -*/ - - .global _Ux86_64_getcontext_trace - .hidden _Ux86_64_getcontext_trace - .type _Ux86_64_getcontext_trace, @function -_Ux86_64_getcontext_trace: - .cfi_startproc - - /* Save only RBP, RBX, RSP, RIP - exclude this call. */ - movq %rbp, UC_MCONTEXT_GREGS_RBP(%rdi) - movq %rbx, UC_MCONTEXT_GREGS_RBX(%rdi) - - leaq 8(%rsp), %rax - movq %rax, UC_MCONTEXT_GREGS_RSP(%rdi) - - movq 0(%rsp), %rax - movq %rax, UC_MCONTEXT_GREGS_RIP(%rdi) - - xorq %rax, %rax - retq - .cfi_endproc - .size _Ux86_64_getcontext_trace, . - _Ux86_64_getcontext_trace - - /* We do not need executable stack. */ - .section .note.GNU-stack,"",@progbits diff --git a/src/pal/src/libunwind/src/x86_64/init.h b/src/pal/src/libunwind/src/x86_64/init.h deleted file mode 100644 index a7a996f12..000000000 --- a/src/pal/src/libunwind/src/x86_64/init.h +++ /dev/null @@ -1,89 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2002 Hewlett-Packard Co - Contributed by David Mosberger-Tang - - Modified for x86_64 by Max Asbock - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" - -/* Avoid a trip to x86_64_r_uc_addr() for purely local initialisation. */ -#if defined UNW_LOCAL_ONLY && defined __linux -# define REG_INIT_LOC(c, rlc, ruc) \ - DWARF_LOC ((unw_word_t) &c->uc->uc_mcontext.gregs[REG_ ## ruc], 0) - -#elif defined UNW_LOCAL_ONLY && defined __FreeBSD__ -# define REG_INIT_LOC(c, rlc, ruc) \ - DWARF_LOC ((unw_word_t) &c->uc->uc_mcontext.mc_ ## rlc, 0) - -#else -# define REG_INIT_LOC(c, rlc, ruc) \ - DWARF_REG_LOC (&c->dwarf, UNW_X86_64_ ## ruc) -#endif - -static inline int -common_init (struct cursor *c, unsigned use_prev_instr) -{ - int ret; - - c->dwarf.loc[RAX] = REG_INIT_LOC(c, rax, RAX); - c->dwarf.loc[RDX] = REG_INIT_LOC(c, rdx, RDX); - c->dwarf.loc[RCX] = REG_INIT_LOC(c, rcx, RCX); - c->dwarf.loc[RBX] = REG_INIT_LOC(c, rbx, RBX); - c->dwarf.loc[RSI] = REG_INIT_LOC(c, rsi, RSI); - c->dwarf.loc[RDI] = REG_INIT_LOC(c, rdi, RDI); - c->dwarf.loc[RBP] = REG_INIT_LOC(c, rbp, RBP); - c->dwarf.loc[RSP] = REG_INIT_LOC(c, rsp, RSP); - c->dwarf.loc[R8] = REG_INIT_LOC(c, r8, R8); - c->dwarf.loc[R9] = REG_INIT_LOC(c, r9, R9); - c->dwarf.loc[R10] = REG_INIT_LOC(c, r10, R10); - c->dwarf.loc[R11] = REG_INIT_LOC(c, r11, R11); - c->dwarf.loc[R12] = REG_INIT_LOC(c, r12, R12); - c->dwarf.loc[R13] = REG_INIT_LOC(c, r13, R13); - c->dwarf.loc[R14] = REG_INIT_LOC(c, r14, R14); - c->dwarf.loc[R15] = REG_INIT_LOC(c, r15, R15); - c->dwarf.loc[RIP] = REG_INIT_LOC(c, rip, RIP); - - ret = dwarf_get (&c->dwarf, c->dwarf.loc[RIP], &c->dwarf.ip); - if (ret < 0) - return ret; - - ret = dwarf_get (&c->dwarf, DWARF_REG_LOC (&c->dwarf, UNW_X86_64_RSP), - &c->dwarf.cfa); - if (ret < 0) - return ret; - - c->sigcontext_format = X86_64_SCF_NONE; - c->sigcontext_addr = 0; - - c->dwarf.args_size = 0; - c->dwarf.stash_frames = 0; - c->dwarf.use_prev_instr = use_prev_instr; - c->dwarf.pi_valid = 0; - c->dwarf.pi_is_dynamic = 0; - c->dwarf.hint = 0; - c->dwarf.prev_rs = 0; - c->dwarf.eh_valid_mask = 0; - - return 0; -} diff --git a/src/pal/src/libunwind/src/x86_64/is_fpreg.c b/src/pal/src/libunwind/src/x86_64/is_fpreg.c deleted file mode 100644 index 5c036137b..000000000 --- a/src/pal/src/libunwind/src/x86_64/is_fpreg.c +++ /dev/null @@ -1,38 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (c) 2004-2005 Hewlett-Packard Development Company, L.P. - Contributed by David Mosberger-Tang - - Modified for x86_64 by Max Asbock - -This file is part of libunwind. - -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. */ - -#include "libunwind_i.h" - -int -unw_is_fpreg (int regnum) -{ -#if 0 - return ((regnum >= UNW_X86_ST0 && regnum <= UNW_X86_ST7) - || (regnum >= UNW_X86_XMM0_lo && regnum <= UNW_X86_XMM7_hi)); -#endif - return 0; -} diff --git a/src/pal/src/libunwind/src/x86_64/longjmp.S b/src/pal/src/libunwind/src/x86_64/longjmp.S deleted file mode 100644 index 274778fd8..000000000 --- a/src/pal/src/libunwind/src/x86_64/longjmp.S +++ /dev/null @@ -1,34 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2004-2005 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - - .globl _UI_longjmp_cont - .type _UI_longjmp_cont, @function -_UI_longjmp_cont: - push %rax /* push target IP as return address */ - mov %rdx, %rax /* set up return-value */ - retq - .size _UI_longjmp_cont, .-_UI_longjmp_cont - /* We do not need executable stack. */ - .section .note.GNU-stack,"",@progbits diff --git a/src/pal/src/libunwind/src/x86_64/offsets.h b/src/pal/src/libunwind/src/x86_64/offsets.h deleted file mode 100644 index 0807960f3..000000000 --- a/src/pal/src/libunwind/src/x86_64/offsets.h +++ /dev/null @@ -1,3 +0,0 @@ -/* FreeBSD specific definitions */ - -#define FREEBSD_UC_MCONTEXT_OFF 0x10 diff --git a/src/pal/src/libunwind/src/x86_64/regname.c b/src/pal/src/libunwind/src/x86_64/regname.c deleted file mode 100644 index 77660af4a..000000000 --- a/src/pal/src/libunwind/src/x86_64/regname.c +++ /dev/null @@ -1,56 +0,0 @@ -/* libunwind - a platform-independent unwind library - - Contributed by Max Asbock - -This file is part of libunwind. - -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. */ - -#include "unwind_i.h" - -static const char *regname[] = - { - "RAX", - "RDX", - "RCX", - "RBX", - "RSI", - "RDI", - "RBP", - "RSP", - "R8", - "R9", - "R10", - "R11", - "R12", - "R13", - "R14", - "R15", - "RIP", - }; - -const char * -unw_regname (unw_regnum_t reg) -{ - if (reg < (unw_regnum_t) ARRAY_SIZE (regname)) - return regname[reg]; - else - return "???"; -} diff --git a/src/pal/src/libunwind/src/x86_64/setcontext.S b/src/pal/src/libunwind/src/x86_64/setcontext.S deleted file mode 100644 index 358217def..000000000 --- a/src/pal/src/libunwind/src/x86_64/setcontext.S +++ /dev/null @@ -1,83 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2007 Google, Inc - Contributed by Arun Sharma - Copyright (C) 2010 Konstantin Belousov - -This file is part of libunwind. - -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. */ - -#include "ucontext_i.h" - -/* int _Ux86_64_setcontext (const ucontext_t *ucp) - - Restores the machine context provided. - Unlike the libc implementation, doesn't clobber %rax - -*/ - .global _Ux86_64_setcontext - .type _Ux86_64_setcontext, @function - -_Ux86_64_setcontext: - -#if defined __linux__ - /* restore fp state */ - mov UC_MCONTEXT_FPREGS_PTR(%rdi),%r8 - fldenv (%r8) - ldmxcsr FPREGS_OFFSET_MXCSR(%r8) -#elif defined __FreeBSD__ - /* restore fp state */ - cmpq $UC_MCONTEXT_FPOWNED_FPU,UC_MCONTEXT_OWNEDFP(%rdi) - jne 1f - cmpq $UC_MCONTEXT_FPFMT_XMM,UC_MCONTEXT_FPFORMAT(%rdi) - jne 1f - fxrstor UC_MCONTEXT_FPSTATE(%rdi) -1: -#else -#error Port me -#endif - - /* restore the rest of the state */ - mov UC_MCONTEXT_GREGS_R8(%rdi),%r8 - mov UC_MCONTEXT_GREGS_R9(%rdi),%r9 - mov UC_MCONTEXT_GREGS_RBX(%rdi),%rbx - mov UC_MCONTEXT_GREGS_RBP(%rdi),%rbp - mov UC_MCONTEXT_GREGS_R12(%rdi),%r12 - mov UC_MCONTEXT_GREGS_R13(%rdi),%r13 - mov UC_MCONTEXT_GREGS_R14(%rdi),%r14 - mov UC_MCONTEXT_GREGS_R15(%rdi),%r15 - mov UC_MCONTEXT_GREGS_RSI(%rdi),%rsi - mov UC_MCONTEXT_GREGS_RDX(%rdi),%rdx - mov UC_MCONTEXT_GREGS_RAX(%rdi),%rax - mov UC_MCONTEXT_GREGS_RCX(%rdi),%rcx - mov UC_MCONTEXT_GREGS_RSP(%rdi),%rsp - - /* push the return address on the stack */ - mov UC_MCONTEXT_GREGS_RIP(%rdi),%rcx - push %rcx - - mov UC_MCONTEXT_GREGS_RCX(%rdi),%rcx - mov UC_MCONTEXT_GREGS_RDI(%rdi),%rdi - retq - - .size _Ux86_64_setcontext, . - _Ux86_64_setcontext - - /* We do not need executable stack. */ - .section .note.GNU-stack,"",@progbits diff --git a/src/pal/src/libunwind/src/x86_64/siglongjmp.S b/src/pal/src/libunwind/src/x86_64/siglongjmp.S deleted file mode 100644 index 32489e53a..000000000 --- a/src/pal/src/libunwind/src/x86_64/siglongjmp.S +++ /dev/null @@ -1,32 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - - .globl _UI_siglongjmp_cont - .type _UI_siglongjmp_cont, @function -_UI_siglongjmp_cont: - retq - .size _UI_siglongjmp_cont, . - _UI_siglongjmp_cont - /* We do not need executable stack. */ - .section .note.GNU-stack,"",@progbits diff --git a/src/pal/src/libunwind/src/x86_64/ucontext_i.h b/src/pal/src/libunwind/src/x86_64/ucontext_i.h deleted file mode 100644 index aded941d0..000000000 --- a/src/pal/src/libunwind/src/x86_64/ucontext_i.h +++ /dev/null @@ -1,82 +0,0 @@ -/* Copyright (C) 2004 Hewlett-Packard Co. - Contributed by David Mosberger-Tang . - -This file is part of libunwind. - -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. */ - -#if defined __linux__ -#define UC_MCONTEXT_GREGS_R8 0x28 -#define UC_MCONTEXT_GREGS_R9 0x30 -#define UC_MCONTEXT_GREGS_R10 0x38 -#define UC_MCONTEXT_GREGS_R11 0x40 -#define UC_MCONTEXT_GREGS_R12 0x48 -#define UC_MCONTEXT_GREGS_R13 0x50 -#define UC_MCONTEXT_GREGS_R14 0x58 -#define UC_MCONTEXT_GREGS_R15 0x60 -#define UC_MCONTEXT_GREGS_RDI 0x68 -#define UC_MCONTEXT_GREGS_RSI 0x70 -#define UC_MCONTEXT_GREGS_RBP 0x78 -#define UC_MCONTEXT_GREGS_RBX 0x80 -#define UC_MCONTEXT_GREGS_RDX 0x88 -#define UC_MCONTEXT_GREGS_RAX 0x90 -#define UC_MCONTEXT_GREGS_RCX 0x98 -#define UC_MCONTEXT_GREGS_RSP 0xa0 -#define UC_MCONTEXT_GREGS_RIP 0xa8 -#define UC_MCONTEXT_FPREGS_PTR 0x1a8 -#define UC_MCONTEXT_FPREGS_MEM 0xe0 -#define UC_SIGMASK 0x128 -#define FPREGS_OFFSET_MXCSR 0x18 -#elif defined __FreeBSD__ -#define UC_SIGMASK 0x0 -#define UC_MCONTEXT_GREGS_RDI 0x18 -#define UC_MCONTEXT_GREGS_RSI 0x20 -#define UC_MCONTEXT_GREGS_RDX 0x28 -#define UC_MCONTEXT_GREGS_RCX 0x30 -#define UC_MCONTEXT_GREGS_R8 0x38 -#define UC_MCONTEXT_GREGS_R9 0x40 -#define UC_MCONTEXT_GREGS_RAX 0x48 -#define UC_MCONTEXT_GREGS_RBX 0x50 -#define UC_MCONTEXT_GREGS_RBP 0x58 -#define UC_MCONTEXT_GREGS_R10 0x60 -#define UC_MCONTEXT_GREGS_R11 0x68 -#define UC_MCONTEXT_GREGS_R12 0x70 -#define UC_MCONTEXT_GREGS_R13 0x78 -#define UC_MCONTEXT_GREGS_R14 0x80 -#define UC_MCONTEXT_GREGS_R15 0x88 -#define UC_MCONTEXT_FS 0x94 -#define UC_MCONTEXT_GS 0x96 -#define UC_MCONTEXT_FLAGS 0xa0 -#define UC_MCONTEXT_ES 0xa4 -#define UC_MCONTEXT_DS 0xa6 -#define UC_MCONTEXT_GREGS_RIP 0xb0 -#define UC_MCONTEXT_CS 0xb8 -#define UC_MCONTEXT_RFLAGS 0xc0 -#define UC_MCONTEXT_GREGS_RSP 0xc8 -#define UC_MCONTEXT_SS 0xd0 -#define UC_MCONTEXT_MC_LEN 0xd8 -#define UC_MCONTEXT_FPFORMAT 0xe0 -#define UC_MCONTEXT_OWNEDFP 0xe8 -#define UC_MCONTEXT_FPSTATE 0xf0 -#define UC_MCONTEXT_FPOWNED_FPU 0x20001 -#define UC_MCONTEXT_FPFMT_XMM 0x10002 -#define UC_MCONTEXT_MC_LEN_VAL 0x320 - -#endif diff --git a/src/pal/src/libunwind/src/x86_64/unwind_i.h b/src/pal/src/libunwind/src/x86_64/unwind_i.h deleted file mode 100644 index e95a60ff3..000000000 --- a/src/pal/src/libunwind/src/x86_64/unwind_i.h +++ /dev/null @@ -1,93 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2002, 2005 Hewlett-Packard Co - Contributed by David Mosberger-Tang - - Modified for x86_64 by Max Asbock - -This file is part of libunwind. - -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. */ - -#ifndef unwind_i_h -#define unwind_i_h - -#include - -#include - -#include "libunwind_i.h" -#include - -/* DWARF column numbers for x86_64: */ -#define RAX 0 -#define RDX 1 -#define RCX 2 -#define RBX 3 -#define RSI 4 -#define RDI 5 -#define RBP 6 -#define RSP 7 -#define R8 8 -#define R9 9 -#define R10 10 -#define R11 11 -#define R12 12 -#define R13 13 -#define R14 14 -#define R15 15 -#define RIP 16 - -#define x86_64_lock UNW_OBJ(lock) -#define x86_64_local_resume UNW_OBJ(local_resume) -#define x86_64_local_addr_space_init UNW_OBJ(local_addr_space_init) -#define setcontext UNW_ARCH_OBJ (setcontext) -#if 0 -#define x86_64_scratch_loc UNW_OBJ(scratch_loc) -#endif -#define x86_64_r_uc_addr UNW_OBJ(r_uc_addr) -#define x86_64_sigreturn UNW_OBJ(sigreturn) - -/* By-pass calls to access_mem() when known to be safe. */ -#ifdef UNW_LOCAL_ONLY -# undef ACCESS_MEM_FAST -# define ACCESS_MEM_FAST(ret,validate,cur,addr,to) \ - do { \ - if (unlikely(validate)) \ - (ret) = dwarf_get ((cur), DWARF_MEM_LOC ((cur), (addr)), &(to)); \ - else \ - (ret) = 0, (to) = *(unw_word_t *)(addr); \ - } while (0) -#endif - -extern void x86_64_local_addr_space_init (void); -extern int x86_64_local_resume (unw_addr_space_t as, unw_cursor_t *cursor, - void *arg); -extern int setcontext (const ucontext_t *ucp); - -#if 0 -extern dwarf_loc_t x86_64_scratch_loc (struct cursor *c, unw_regnum_t reg); -#endif - -extern void *x86_64_r_uc_addr (ucontext_t *uc, int reg); -extern NORETURN void x86_64_sigreturn (unw_cursor_t *cursor); -#define x86_64_handle_signal_frame UNW_OBJ(handle_signal_frame) -extern int x86_64_handle_signal_frame(unw_cursor_t *cursor); - -#endif /* unwind_i_h */ diff --git a/src/pal/src/libunwind/tests/Gia64-test-nat.c b/src/pal/src/libunwind/tests/Gia64-test-nat.c deleted file mode 100644 index 89df54e0b..000000000 --- a/src/pal/src/libunwind/tests/Gia64-test-nat.c +++ /dev/null @@ -1,626 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2004-2005 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -/* This file tests corner-cases of NaT-bit handling. */ - -#include -#include -#include -#include - -#include -#include "compiler.h" - -#ifdef HAVE_SYS_UC_ACCESS_H -# include -#endif - -#include "tdep-ia64/rse.h" - -#define NUM_RUNS 1024 -//#define NUM_RUNS 1 -#define MAX_CHECKS 1024 -//#define MAX_CHECKS 2 -#define MAX_VALUES_PER_FUNC 4 - -#define panic(args...) \ - do { printf (args); ++nerrors; } while (0) - -typedef void save_func_t (void *funcs, unsigned long *vals); -typedef unw_word_t *check_func_t (unw_cursor_t *c, unsigned long *vals); - -extern void flushrs (void); - -extern save_func_t save_static_to_stacked; -static check_func_t check_static_to_stacked; - -extern save_func_t save_static_to_fr; -static check_func_t check_static_to_fr; - -extern save_func_t save_static_to_br; -static check_func_t check_static_to_br; - -extern save_func_t save_static_to_mem; -static check_func_t check_static_to_mem; - -extern save_func_t save_static_to_mem2; -static check_func_t check_static_to_mem2; - -extern save_func_t save_static_to_mem3; -static check_func_t check_static_to_mem3; - -extern save_func_t save_static_to_mem4; -static check_func_t check_static_to_mem4; - -extern save_func_t save_static_to_mem5; -static check_func_t check_static_to_mem5; - -extern save_func_t save_static_to_scratch; -static check_func_t check_static_to_scratch; - -extern save_func_t rotate_regs; -static check_func_t check_rotate_regs; - -extern save_func_t save_pr; -static check_func_t check_pr; - -static int verbose; -static int nerrors; - -static int num_checks; -static save_func_t *funcs[MAX_CHECKS + 1]; -static check_func_t *checks[MAX_CHECKS]; -static unw_word_t values[MAX_CHECKS*MAX_VALUES_PER_FUNC]; - -static struct - { - save_func_t *func; - check_func_t *check; - } -all_funcs[] = - { - { save_static_to_stacked, check_static_to_stacked }, - { save_static_to_fr, check_static_to_fr }, - { save_static_to_br, check_static_to_br }, - { save_static_to_mem, check_static_to_mem }, - { save_static_to_mem2, check_static_to_mem2 }, - { save_static_to_mem3, check_static_to_mem3 }, - { save_static_to_mem4, check_static_to_mem4 }, - { save_static_to_mem5, check_static_to_mem5 }, - { save_static_to_scratch, check_static_to_scratch }, - { save_pr, check_pr }, - { rotate_regs, check_rotate_regs }, - }; - -static unw_word_t -random_word (void) -{ - unw_word_t val = random (); - - if (sizeof (unw_word_t) > 4) - val |= ((unw_word_t) random ()) << 32; - - return val; -} - -void -sighandler (int signal, void *siginfo, void *context) -{ - unsigned long *bsp, *arg1; - save_func_t **arg0; - ucontext_t *uc = context; - -#if defined(__linux) - { - long sof; - int sp; - - if (verbose) - printf ("sighandler: signal %d sp=%p nat=%08lx pr=%lx\n", - signal, &sp, uc->uc_mcontext.sc_nat, uc->uc_mcontext.sc_pr); - sof = uc->uc_mcontext.sc_cfm & 0x7f; - bsp = (unsigned long *) rse_skip_regs (uc->uc_mcontext.sc_ar_bsp, -sof); - } -#elif defined(__hpux) - if (__uc_get_ar (uc, UNW_IA64_AR_BSP - UNW_IA64_AR, &bsp) != 0) - { - panic ("%s: reading of ar.bsp failed, errno=%d", __FUNCTION__, errno); - return; - } -#endif - - flushrs (); - arg0 = (save_func_t **) *bsp; - bsp = (unsigned long *) rse_skip_regs ((uint64_t) bsp, 1); - arg1 = (unsigned long *) *bsp; - - (*arg0[0]) (arg0 + 1, arg1); - - /* skip over the instruction which triggered sighandler() */ -#if defined(__linux) - ++uc->uc_mcontext.sc_ip; -#elif defined(HAVE_SYS_UC_ACCESS_H) - { - unsigned long ip; - - if (__uc_get_ip (uc, &ip) != 0) - { - panic ("%s: reading of ip failed, errno=%d", __FUNCTION__, errno); - return; - } - if (__uc_set_ip (uc, ip) != 0) - { - panic ("%s: writing of ip failed, errno=%d", __FUNCTION__, errno); - return; - } - } -#endif -} - -static void -enable_sighandler (void) -{ - struct sigaction act; - - memset (&act, 0, sizeof (act)); - act.sa_handler = (void (*)(int)) sighandler; - act.sa_flags = SA_SIGINFO | SA_NODEFER; - if (sigaction (SIGSEGV, &act, NULL) < 0) - panic ("sigaction: %s\n", strerror (errno)); -} - -static void -disable_sighandler (void) -{ - struct sigaction act; - - memset (&act, 0, sizeof (act)); - act.sa_handler = SIG_DFL; - act.sa_flags = SA_SIGINFO | SA_NODEFER; - if (sigaction (SIGSEGV, &act, NULL) < 0) - panic ("sigaction: %s\n", strerror (errno)); -} - -static unw_word_t * -check_static_to_stacked (unw_cursor_t *c, unw_word_t *vals) -{ - unw_word_t r[4]; - unw_word_t nat[4]; - int i, ret; - - if (verbose) - printf (" %s()\n", __FUNCTION__); - - vals -= 4; - - for (i = 0; i < 4; ++i) - if ((ret = unw_get_reg (c, UNW_IA64_GR + 4 + i, &r[i])) < 0) - panic ("%s: failed to read register r%d, error=%d\n", - __FUNCTION__, 4 + i, ret); - - for (i = 0; i < 4; ++i) - if ((ret = unw_get_reg (c, UNW_IA64_NAT + 4 + i, &nat[i])) < 0) - panic ("%s: failed to read register nat%d, error=%d\n", - __FUNCTION__, 4 + i, ret); - - for (i = 0; i < 4; ++i) - { - if (verbose) - printf (" r%d = %c%016lx (expected %c%016lx)\n", - 4 + i, nat[i] ? '*' : ' ', r[i], - (vals[i] & 1) ? '*' : ' ', vals[i]); - - if (vals[i] & 1) - { - if (!nat[i]) - panic ("%s: r%d not a NaT!\n", __FUNCTION__, 4 + i); - } - else - { - if (nat[i]) - panic ("%s: r%d a NaT!\n", __FUNCTION__, 4 + i); - if (r[i] != vals[i]) - panic ("%s: r%d=%lx instead of %lx!\n", - __FUNCTION__, 4 + i, r[i], vals[i]); - } - } - return vals; -} - -static unw_word_t * -check_static_to_fr (unw_cursor_t *c, unw_word_t *vals) -{ - unw_word_t r4; - unw_word_t nat4; - int ret; - - if (verbose) - printf (" %s()\n", __FUNCTION__); - - vals -= 1; - - if ((ret = unw_get_reg (c, UNW_IA64_GR + 4, &r4)) < 0) - panic ("%s: failed to read register r4, error=%d\n", __FUNCTION__, ret); - - if ((ret = unw_get_reg (c, UNW_IA64_NAT + 4, &nat4)) < 0) - panic ("%s: failed to read register nat4, error=%d\n", __FUNCTION__, ret); - - if (verbose) - printf (" r4 = %c%016lx (expected %c%016lx)\n", - nat4 ? '*' : ' ', r4, (vals[0] & 1) ? '*' : ' ', vals[0]); - - if (vals[0] & 1) - { - if (!nat4) - panic ("%s: r4 not a NaT!\n", __FUNCTION__); - } - else - { - if (nat4) - panic ("%s: r4 a NaT!\n", __FUNCTION__); - if (r4 != vals[0]) - panic ("%s: r4=%lx instead of %lx!\n", __FUNCTION__, r4, vals[0]); - } - return vals; -} - -static unw_word_t * -check_static_to_br (unw_cursor_t *c, unw_word_t *vals) -{ - unw_word_t r4, nat4; - int ret; - - if (verbose) - printf (" %s()\n", __FUNCTION__); - - vals -= 1; - - if ((ret = unw_get_reg (c, UNW_IA64_GR + 4, &r4)) < 0) - panic ("%s: failed to read register r4, error=%d\n", __FUNCTION__, ret); - - if ((ret = unw_get_reg (c, UNW_IA64_NAT + 4, &nat4)) < 0) - panic ("%s: failed to read register nat4, error=%d\n", __FUNCTION__, ret); - - if (verbose) - printf (" r4 = %c%016lx (expected %c%016lx)\n", - nat4 ? '*' : ' ', r4, (vals[0] & 1) ? '*' : ' ', vals[0]); - - if (vals[0] & 1) - { - if (!nat4) - panic ("%s: r4 not a NaT!\n", __FUNCTION__); - } - else - { - if (nat4) - panic ("%s: r4 a NaT!\n", __FUNCTION__); - if (r4 != vals[0]) - panic ("%s: r4=%lx instead of %lx!\n", __FUNCTION__, r4, vals[0]); - } - return vals; -} - -static unw_word_t * -check_static_to_mem (unw_cursor_t *c, unw_word_t *vals) -{ - unw_word_t r5, nat5; - int ret; - - if (verbose) - printf (" %s()\n", __FUNCTION__); - - vals -= 1; - - if ((ret = unw_get_reg (c, UNW_IA64_GR + 5, &r5)) < 0) - panic ("%s: failed to read register r5, error=%d\n", __FUNCTION__, ret); - - if ((ret = unw_get_reg (c, UNW_IA64_NAT + 5, &nat5)) < 0) - panic ("%s: failed to read register nat5, error=%d\n", __FUNCTION__, ret); - - if (verbose) - printf (" r5 = %c%016lx (expected %c%016lx)\n", - nat5 ? '*' : ' ', r5, (vals[0] & 1) ? '*' : ' ', vals[0]); - - if (vals[0] & 1) - { - if (!nat5) - panic ("%s: r5 not a NaT!\n", __FUNCTION__); - } - else - { - if (nat5) - panic ("%s: r5 a NaT!\n", __FUNCTION__); - if (r5 != vals[0]) - panic ("%s: r5=%lx instead of %lx!\n", __FUNCTION__, r5, vals[0]); - } - return vals; -} - -static unw_word_t * -check_static_to_memN (unw_cursor_t *c, unw_word_t *vals, const char *func) -{ - unw_word_t r6, nat6; - int ret; - - if (verbose) - printf (" %s()\n", func); - - vals -= 1; - - if ((ret = unw_get_reg (c, UNW_IA64_GR + 6, &r6)) < 0) - panic ("%s: failed to read register r6, error=%d\n", __FUNCTION__, ret); - - if ((ret = unw_get_reg (c, UNW_IA64_NAT + 6, &nat6)) < 0) - panic ("%s: failed to read register nat6, error=%d\n", __FUNCTION__, ret); - - if (verbose) - printf (" r6 = %c%016lx (expected %c%016lx)\n", - nat6 ? '*' : ' ', r6, (vals[0] & 1) ? '*' : ' ', vals[0]); - - if (vals[0] & 1) - { - if (!nat6) - panic ("%s: r6 not a NaT!\n", __FUNCTION__); - } - else - { - if (nat6) - panic ("%s: r6 a NaT!\n", __FUNCTION__); - if (r6 != vals[0]) - panic ("%s: r6=%lx instead of %lx!\n", __FUNCTION__, r6, vals[0]); - } - return vals; -} - -static unw_word_t * -check_static_to_mem2 (unw_cursor_t *c, unw_word_t *vals) -{ - return check_static_to_memN (c, vals, __FUNCTION__); -} - -static unw_word_t * -check_static_to_mem3 (unw_cursor_t *c, unw_word_t *vals) -{ - return check_static_to_memN (c, vals, __FUNCTION__); -} - -static unw_word_t * -check_static_to_mem4 (unw_cursor_t *c, unw_word_t *vals) -{ - return check_static_to_memN (c, vals, __FUNCTION__); -} - -static unw_word_t * -check_static_to_mem5 (unw_cursor_t *c, unw_word_t *vals) -{ - return check_static_to_memN (c, vals, __FUNCTION__); -} - -static unw_word_t * -check_static_to_scratch (unw_cursor_t *c, unw_word_t *vals) -{ - unw_word_t r[4], nat[4], ec, expected; - unw_fpreg_t f4; - int i, ret; - - if (verbose) - printf (" %s()\n", __FUNCTION__); - - vals -= 4; - - while (!unw_is_signal_frame (c)) - if ((ret = unw_step (c)) < 0) - panic ("%s: unw_step (ret=%d): Failed to skip over signal handler\n", - __FUNCTION__, ret); - if ((ret = unw_step (c)) < 0) - panic ("%s: unw_step (ret=%d): Failed to skip over signal handler\n", - __FUNCTION__, ret); - - for (i = 0; i < 4; ++i) - if ((ret = unw_get_reg (c, UNW_IA64_GR + 4 + i, &r[i])) < 0) - panic ("%s: failed to read register r%d, error=%d\n", - __FUNCTION__, 4 + i, ret); - - for (i = 0; i < 4; ++i) - if ((ret = unw_get_reg (c, UNW_IA64_NAT + 4 + i, &nat[i])) < 0) - panic ("%s: failed to read register nat%d, error=%d\n", - __FUNCTION__, 4 + i, ret); - - for (i = 0; i < 4; ++i) - { - if (verbose) - printf (" r%d = %c%016lx (expected %c%016lx)\n", - 4 + i, nat[i] ? '*' : ' ', r[i], - (vals[i] & 1) ? '*' : ' ', vals[i]); - - if (vals[i] & 1) - { - if (!nat[i]) - panic ("%s: r%d not a NaT!\n", __FUNCTION__, 4 + i); - } - else - { - if (nat[i]) - panic ("%s: r%d a NaT!\n", __FUNCTION__, 4 + i); - if (r[i] != vals[i]) - panic ("%s: r%d=%lx instead of %lx!\n", - __FUNCTION__, 4 + i, r[i], vals[i]); - } - } - if ((ret = unw_get_fpreg (c, UNW_IA64_FR + 4, &f4)) < 0) - panic ("%s: failed to read f4, error=%d\n", __FUNCTION__, ret); - - /* These tests are little-endian specific: */ - if (nat[0]) - { - if (f4.raw.bits[0] != 0 || f4.raw.bits[1] != 0x1fffe) - panic ("%s: f4=%016lx.%016lx instead of NaTVal!\n", - __FUNCTION__, f4.raw.bits[1], f4.raw.bits[0]); - } - else - { - if (f4.raw.bits[0] != r[0] || f4.raw.bits[1] != 0x1003e) - panic ("%s: f4=%016lx.%016lx instead of %lx!\n", - __FUNCTION__, f4.raw.bits[1], f4.raw.bits[0], r[0]); - } - - if ((unw_get_reg (c, UNW_IA64_AR_EC, &ec)) < 0) - panic ("%s: failed to read register ar.ec, error=%d\n", __FUNCTION__, ret); - - expected = vals[0] & 0x3f; - if (ec != expected) - panic ("%s: ar.ec=%016lx instead of %016lx!\n", - __FUNCTION__, ec, expected); - - return vals; -} - -static unw_word_t * -check_pr (unw_cursor_t *c, unw_word_t *vals) -{ - unw_word_t pr, expected; - int ret; -# define BIT(n) ((unw_word_t) 1 << (n)) -# define DONTCARE (BIT( 6) | BIT( 7) | BIT( 8) | BIT( 9) | BIT(10) \ - | BIT(11) | BIT(12) | BIT(13) | BIT(14) | BIT(15)) - - if (verbose) - printf (" %s()\n", __FUNCTION__); - - vals -= 1; - - if ((ret = unw_get_reg (c, UNW_IA64_PR, &pr)) < 0) - panic ("%s: failed to read register pr, error=%d\n", __FUNCTION__, ret); - - pr &= ~DONTCARE; - expected = (vals[0] & ~DONTCARE) | 1; - - if (verbose) - printf (" pr = %016lx (expected %016lx)\n", pr, expected); - - if (pr != expected) - panic ("%s: pr=%lx instead of %lx!\n", __FUNCTION__, pr, expected); - - if ((ret = unw_set_reg (c, UNW_IA64_PR, vals[0])) < 0) - panic ("%s: failed to write register pr, error=%d\n", __FUNCTION__, ret); - - if ((ret = unw_get_reg (c, UNW_IA64_PR, &pr)) < 0) - panic ("%s: failed to read register pr, error=%d\n", __FUNCTION__, ret); - - if (pr != vals[0]) - panic ("%s: secondary pr=%lx instead of %lx!\n", - __FUNCTION__, pr, vals[0]); - return vals; -} - -static unw_word_t * -check_rotate_regs (unw_cursor_t *c, unw_word_t *vals) -{ - if (verbose) - printf (" %s()\n", __FUNCTION__); - return check_pr (c, vals - 1); -} - -static void -start_checks (void *funcs, unsigned long *vals) -{ - unw_context_t uc; - unw_cursor_t c; - int i, ret; - - disable_sighandler (); - - unw_getcontext (&uc); - - if ((ret = unw_init_local (&c, &uc)) < 0) - panic ("%s: unw_init_local (ret=%d)\n", __FUNCTION__, ret); - - if ((ret = unw_step (&c)) < 0) - panic ("%s: unw_step (ret=%d)\n", __FUNCTION__, ret); - - for (i = 0; i < num_checks; ++i) - { - vals = (*checks[num_checks - 1 - i]) (&c, vals); - - if ((ret = unw_step (&c)) < 0) - panic ("%s: unw_step (ret=%d)\n", __FUNCTION__, ret); - } -} - -static void -run_check (int test) -{ - int index, i; - - if (test == 1) - /* Make first test always go the full depth... */ - num_checks = MAX_CHECKS; - else - num_checks = (random () % MAX_CHECKS) + 1; - - for (i = 0; i < num_checks * MAX_VALUES_PER_FUNC; ++i) - values[i] = random_word (); - - for (i = 0; i < num_checks; ++i) - { - if (test == 1) - /* Make first test once go through each test... */ - index = i % (int) ARRAY_SIZE (all_funcs); - else - index = random () % (int) ARRAY_SIZE (all_funcs); - funcs[i] = all_funcs[index].func; - checks[i] = all_funcs[index].check; - } - - funcs[num_checks] = start_checks; - - enable_sighandler (); - (*funcs[0]) (funcs + 1, values); -} - -int -main (int argc, char **argv) -{ - int i; - - if (argc > 1) - verbose = 1; - - for (i = 0; i < NUM_RUNS; ++i) - { - if (verbose) - printf ("Run %d\n", i + 1); - run_check (i + 1); - } - - if (nerrors > 0) - { - fprintf (stderr, "FAILURE: detected %d errors\n", nerrors); - exit (-1); - } - if (verbose) - printf ("SUCCESS.\n"); - return 0; -} diff --git a/src/pal/src/libunwind/tests/Gia64-test-rbs.c b/src/pal/src/libunwind/tests/Gia64-test-rbs.c deleted file mode 100644 index 2181e70fd..000000000 --- a/src/pal/src/libunwind/tests/Gia64-test-rbs.c +++ /dev/null @@ -1,193 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2003-2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -/* This file tests corner-cases of unwinding across multiple stacks. - In particular, it verifies that the extreme case with a frame of 96 - stacked registers that are all backed up by separate stacks works - as expected. */ - -#include -#include - -#include -#include "compiler.h" - -#include "ia64-test-rbs.h" - -#define panic(args...) \ - do { fprintf (stderr, args); ++nerrors; return -9999; } while (0) - -/* The loadrs field in ar.rsc is 14 bits wide, which limits all ia64 - implementations to at most 2048 physical stacked registers - (actually, slightly less than that, because loadrs also counts RNaT - slots). Since we can dirty 93 stacked registers per recursion, we - need to recurse RECURSION_DEPTH times to ensure all physical - stacked registers are in use. */ -#define MAX_PHYS_STACKED 2048 -#define RECURSION_DEPTH ((MAX_PHYS_STACKED + 92) / 93) - -typedef int spill_func_t (long iteration, int (*next_func[])()); - -extern int loadup (long iteration, int *values, int (*next_func[])()); -extern char resumption_point_label; - -#define DCL(n) \ - extern int rbs_spill_##n (long iteration, int (*next_func[])()) - DCL(2); DCL(3); DCL(4); DCL(5); DCL(6); DCL(7); - DCL(8); DCL(9); DCL(10); DCL(11); DCL(12); DCL(13); DCL(14); DCL(15); - DCL(16); DCL(17); DCL(18); DCL(19); DCL(20); DCL(21); DCL(22); DCL(23); - DCL(24); DCL(25); DCL(26); DCL(27); DCL(28); DCL(29); DCL(30); DCL(31); - DCL(32); DCL(33); DCL(34); DCL(35); DCL(36); DCL(37); DCL(38); DCL(39); - DCL(40); DCL(41); DCL(42); DCL(43); DCL(44); DCL(45); DCL(46); DCL(47); - DCL(48); DCL(49); DCL(50); DCL(51); DCL(52); DCL(53); DCL(54); DCL(55); - DCL(56); DCL(57); DCL(58); DCL(59); DCL(60); DCL(61); DCL(62); DCL(63); - DCL(64); DCL(65); DCL(66); DCL(67); DCL(68); DCL(69); DCL(70); DCL(71); - DCL(72); DCL(73); DCL(74); DCL(75); DCL(76); DCL(77); DCL(78); DCL(79); - DCL(80); DCL(81); DCL(82); DCL(83); DCL(84); DCL(85); DCL(86); DCL(87); - DCL(88); DCL(89); DCL(90); DCL(91); DCL(92); DCL(93); DCL(94); - -#define SPL(n) rbs_spill_##n -spill_func_t *spill_funcs[] = - { - SPL(2), SPL(3), SPL(4), SPL(5), SPL(6), SPL(7), - SPL(8), SPL(9), SPL(10), SPL(11), SPL(12), SPL(13), SPL(14), SPL(15), - SPL(16), SPL(17), SPL(18), SPL(19), SPL(20), SPL(21), SPL(22), SPL(23), - SPL(24), SPL(25), SPL(26), SPL(27), SPL(28), SPL(29), SPL(30), SPL(31), - SPL(32), SPL(33), SPL(34), SPL(35), SPL(36), SPL(37), SPL(38), SPL(39), - SPL(40), SPL(41), SPL(42), SPL(43), SPL(44), SPL(45), SPL(46), SPL(47), - SPL(48), SPL(49), SPL(50), SPL(51), SPL(52), SPL(53), SPL(54), SPL(55), - SPL(56), SPL(57), SPL(58), SPL(59), SPL(60), SPL(61), SPL(62), SPL(63), - SPL(64), SPL(65), SPL(66), SPL(67), SPL(68), SPL(69), SPL(70), SPL(71), - SPL(72), SPL(73), SPL(74), SPL(75), SPL(76), SPL(77), SPL(78), SPL(79), - SPL(80), SPL(81), SPL(82), SPL(83), SPL(84), SPL(85), SPL(86), SPL(87), - SPL(88), SPL(89), SPL(90), SPL(91), SPL(92), SPL(93), SPL(94) - }; - -static int verbose; -static int nerrors; -static int unwind_count; - -static int -unwind_and_resume (long iteration, int (*next_func[])()) -{ - unw_context_t uc; - unw_cursor_t c; - unw_word_t ip; - int i, ret; - - if (verbose) - printf (" %s(iteration=%ld, next_func=%p)\n", - __FUNCTION__, iteration, next_func); - - unw_getcontext (&uc); - if ((ret = unw_init_local (&c, &uc)) < 0) - panic ("unw_init_local (ret=%d)", ret); - - for (i = 0; i < unwind_count; ++i) - if ((ret = unw_step (&c)) < 0) - panic ("unw_step (ret=%d)", ret); - - if (unw_get_reg (&c, UNW_REG_IP, &ip) < 0 - || unw_set_reg (&c, UNW_REG_IP, (unw_word_t) &resumption_point_label) < 0 - || unw_set_reg (&c, UNW_REG_EH + 0, 0) /* ret val */ - || unw_set_reg (&c, UNW_REG_EH + 1, ip)) - panic ("failed to redirect to resumption_point\n"); - - if (verbose) - { - unw_word_t bsp; - if (unw_get_reg (&c, UNW_IA64_BSP, &bsp) < 0) - panic ("unw_get_reg() failed\n"); - printf (" bsp=%lx, old ip=%lx, new ip=%p\n", bsp, - ip, &resumption_point_label); - } - - ret = unw_resume (&c); - panic ("unw_resume() returned (ret=%d)!!\n", ret); - return 0; -} - -static int -run_check (int test) -{ - int nfuncs, nspills, n, ret, i, reg_values[88]; - spill_func_t *func[NSTACKS + 1]; - - /* First, generate a set of 88 random values which loadup() will load - into loc2-loc89 (r37-r124). */ - for (i = 0; i < (int) ARRAY_SIZE (reg_values); ++i) - { - reg_values[i] = random (); - /* Generate NaTs with a reasonably probability (1/16th): */ - if (reg_values[i] < 0x10000000) - reg_values[i] = 0; - } - - nspills = 0; - nfuncs = 0; - do - { - n = random () % (int) ARRAY_SIZE (spill_funcs); - func[nfuncs++] = spill_funcs[n]; - nspills += 2 + n; - } - while (nspills < 128); - func[nfuncs++] = unwind_and_resume; - - unwind_count = 1 + (random () % (nfuncs + RECURSION_DEPTH - 1)); - - if (verbose) - printf ("test%d: nfuncs=%d, unwind_count=%d\n", - test, nfuncs, unwind_count); - - ret = loadup (RECURSION_DEPTH, reg_values, func); - if (ret < 0) - panic ("test%d: load() returned %d\n", test, ret); - else if (ret != RECURSION_DEPTH + nfuncs - unwind_count) - panic ("test%d: resumed wrong frame: expected %d, got %d\n", - test, RECURSION_DEPTH + nfuncs - unwind_count, ret); - return 0; -} - -int -main (int argc, char **argv) -{ - int i; - - if (argc > 1) - verbose = 1; - - for (i = 0; i < 100000; ++i) - run_check (i + 1); - - if (nerrors > 0) - { - fprintf (stderr, "FAILURE: detected %d errors\n", nerrors); - exit (-1); - } - if (verbose) - printf ("SUCCESS.\n"); - return 0; -} diff --git a/src/pal/src/libunwind/tests/Gia64-test-readonly.c b/src/pal/src/libunwind/tests/Gia64-test-readonly.c deleted file mode 100644 index 25f050610..000000000 --- a/src/pal/src/libunwind/tests/Gia64-test-readonly.c +++ /dev/null @@ -1,89 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -/* This file verifies that read-only registers cannot be written to. */ - -#include -#include -#include -#include - -#include - -#define panic(args...) \ - do { printf (args); ++nerrors; } while (0) - -static int verbose; -static int nerrors; - -extern void test_func (void (*) (void)); - -void -checker (void) -{ - unw_fpreg_t fpval; - unw_context_t uc; - unw_cursor_t c; - int ret; - - fpval.raw.bits[0] = 100; - fpval.raw.bits[1] = 101; - - unw_getcontext (&uc); - - if ((ret = unw_init_local (&c, &uc)) < 0) - panic ("%s: unw_init_local (ret=%d)\n", __FUNCTION__, ret); - - if ((ret = unw_step (&c)) < 0) - panic ("%s: unw_step (ret=%d)\n", __FUNCTION__, ret); - - if ((ret = unw_step (&c)) < 0) - panic ("%s: unw_step (ret=%d)\n", __FUNCTION__, ret); - - if ((ret = unw_set_reg (&c, UNW_IA64_IP, 99)) != -UNW_EREADONLYREG) - panic ("%s: unw_set_reg (ip) returned %d instead of %d\n", - __FUNCTION__, ret, -UNW_EREADONLYREG); - if ((ret = unw_set_reg (&c, UNW_IA64_AR_LC, 99)) != -UNW_EREADONLYREG) - panic ("%s: unw_set_reg (ar.lc) returned %d instead of %d\n", - __FUNCTION__, ret, -UNW_EREADONLYREG); -} - -int -main (int argc, char **argv) -{ - if (argc > 1) - verbose = 1; - - test_func (checker); - - if (nerrors > 0) - { - fprintf (stderr, "FAILURE: detected %d errors\n", nerrors); - exit (-1); - } - if (verbose) - printf ("SUCCESS.\n"); - return 0; -} diff --git a/src/pal/src/libunwind/tests/Gia64-test-stack.c b/src/pal/src/libunwind/tests/Gia64-test-stack.c deleted file mode 100644 index 05874b291..000000000 --- a/src/pal/src/libunwind/tests/Gia64-test-stack.c +++ /dev/null @@ -1,176 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2003 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -/* This file tests corner-cases of unwinding across multiple stacks. - In particular, it verifies that the extreme case with a frame of 96 - stacked registers that are all backed up by separate stacks works - as expected. */ - -#include -#include -#include - -#include "ia64-test-stack.h" - -#define panic(args...) \ - { printf (args); ++nerrors; } - -/* The loadrs field in ar.rsc is 14 bits wide, which limits all ia64 - implementations to at most 2048 physical stacked registers - (actually, slightly less than that, because loadrs also counts RNaT - slots). Since we can dirty 95 stacked registers per recursion, we - need to recurse RECURSION_DEPTH times to ensure all physical - stacked registers are in use. */ -#define MAX_PHYS_STACKED 2048 -#define RECURSION_DEPTH ((MAX_PHYS_STACKED + 94) / 95) - -extern void touch_all (unsigned long recursion_depth); -extern void flushrs (void); - -int nerrors; -int verbose; - -void -do_unwind_tests (void) -{ - unw_word_t ip, sp, bsp, v0, v1, v2, v3, n0, n1, n2, n3, cfm, sof, sol, r32; - int ret, reg, i, l; - unw_context_t uc; - unw_cursor_t c; - - if (verbose) - printf ("do_unwind_tests: here we go!\n"); - - /* do a full stack-dump: */ - unw_getcontext (&uc); - unw_init_local (&c, &uc); - i = 0; - do - { - if (verbose) - { - if ((ret = unw_get_reg (&c, UNW_IA64_IP, &ip)) < 0 - || (ret = unw_get_reg (&c, UNW_IA64_SP, &sp)) < 0 - || (ret = unw_get_reg (&c, UNW_IA64_BSP, &bsp)) < 0) - break; - printf ("ip=0x%16lx sp=0x%16lx bsp=0x%16lx\n", ip, sp, bsp); - - for (reg = 32; reg < 128; reg += 4) - { - v0 = v1 = v2 = v3 = 0; - n0 = n1 = n2 = n3 = 0; - (void) - ((ret = unw_get_reg (&c, UNW_IA64_GR + reg, &v0)) < 0 - || (ret = unw_get_reg (&c, UNW_IA64_NAT + reg, &n0)) < 0 - || (ret = unw_get_reg (&c, UNW_IA64_GR + reg + 1, &v1)) < 0 - || (ret = unw_get_reg (&c, UNW_IA64_NAT + reg + 1, &n1)) < 0 - || (ret = unw_get_reg (&c, UNW_IA64_GR + reg + 2, &v2)) < 0 - || (ret = unw_get_reg (&c, UNW_IA64_NAT + reg + 2, &n2)) < 0 - || (ret = unw_get_reg (&c, UNW_IA64_GR + reg + 3, &v3)) < 0 - || (ret = unw_get_reg (&c, UNW_IA64_NAT + reg + 3, &n3)) < 0); - if (reg < 100) - printf (" r%d", reg); - else - printf (" r%d", reg); - printf (" %c%016lx %c%016lx %c%016lx %c%016lx\n", - n0 ? '*' : ' ', v0, n1 ? '*' : ' ', v1, - n2 ? '*' : ' ', v2, n3 ? '*' : ' ', v3); - if (ret < 0) - break; - } - } - - if (i >= 1 && i <= NSTACKS) - { - if ((ret = unw_get_reg (&c, UNW_IA64_CFM, &cfm)) < 0) - break; - sof = cfm & 0x7f; - if (sof != (unw_word_t) (i & 1)) - panic ("\texpected sof=%d, found sof=%lu\n", i - 1, sof); - if (sof == 1) - { - if ((ret = unw_get_reg (&c, UNW_IA64_GR + 32, &r32)) < 0) - break; - if (r32 != (unw_word_t) (i - 1)) - panic ("\texpected r32=%d, found r32=%lu\n", i - 1, r32); - } - } - else if (i > NSTACKS && i <= NSTACKS + RECURSION_DEPTH) - { - if ((ret = unw_get_reg (&c, UNW_IA64_CFM, &cfm)) < 0) - break; - sof = cfm & 0x7f; - sol = (cfm >> 7) & 0x7f; - if (sof != 96) - panic ("\texpected sof=96, found sof=%lu\n", sof); - if (sol != 95) - panic ("\texpected sol=95, found sol=%lu\n", sol); - - for (l = 2; l <= 93; ++l) - { - if ((ret = unw_get_reg (&c, UNW_IA64_GR + 33 + l, &v0)) < 0 - || (ret = unw_get_reg (&c, UNW_IA64_NAT + 33 + l, &n0)) < 0) - break; - switch (l) - { - case 2: case 31: case 73: case 93: - if (!n0) - panic ("\texpected loc%d to be a NaT!\n", l); - break; - - default: - if (n0) - panic ("\tloc%d is unexpectedly a NaT!\n", l); - v1 = ((unw_word_t) (i - NSTACKS) << 32) + l; - if (v0 != v1) - panic ("\tloc%d expected to be %lx, found to be %lx\n", - l, v1, v0); - } - } - } - ++i; - } - while ((ret = unw_step (&c)) > 0); - - if (ret < 0) - panic ("libunwind returned %d\n", ret); -} - -int -main (int argc, char **argv) -{ - if (argc > 1) - ++verbose; - - touch_all (RECURSION_DEPTH); - if (nerrors) - { - printf ("FAILURE: detected %d errors\n", nerrors); - exit (-1); - } - if (verbose) - printf ("SUCCESS\n"); - return 0; -} diff --git a/src/pal/src/libunwind/tests/Gperf-simple.c b/src/pal/src/libunwind/tests/Gperf-simple.c deleted file mode 100644 index e18191821..000000000 --- a/src/pal/src/libunwind/tests/Gperf-simple.c +++ /dev/null @@ -1,264 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2003-2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -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. */ - -#include -#include -#include -#include - -#include -#include "compiler.h" - -#include -#include - -#define panic(args...) \ - do { fprintf (stderr, args); exit (-1); } while (0) - -long dummy; - -static long iterations = 10000; -static int maxlevel = 100; - -#define KB 1024 -#define MB (1024*1024) - -static char big[64*MB]; /* should be >> max. cache size */ - -static inline double -gettime (void) -{ - struct timeval tv; - - gettimeofday (&tv, NULL); - return tv.tv_sec + 1e-6*tv.tv_usec; -} - -static int NOINLINE -measure_unwind (int maxlevel, double *step) -{ - double stop, start; - unw_cursor_t cursor; - unw_context_t uc; - int ret, level = 0; - - unw_getcontext (&uc); - if (unw_init_local (&cursor, &uc) < 0) - panic ("unw_init_local() failed\n"); - - start = gettime (); - - do - { - ret = unw_step (&cursor); - if (ret < 0) - panic ("unw_step() failed\n"); - ++level; - } - while (ret > 0); - - stop = gettime (); - - if (level <= maxlevel) - panic ("Unwound only %d levels, expected at least %d levels\n", - level, maxlevel); - - *step = (stop - start) / (double) level; - return 0; -} - -static int f1 (int, int, double *); - -static int NOINLINE -g1 (int level, int maxlevel, double *step) -{ - if (level == maxlevel) - return measure_unwind (maxlevel, step); - else - /* defeat last-call/sibcall optimization */ - return f1 (level + 1, maxlevel, step) + level; -} - -static int NOINLINE -f1 (int level, int maxlevel, double *step) -{ - if (level == maxlevel) - return measure_unwind (maxlevel, step); - else - /* defeat last-call/sibcall optimization */ - return g1 (level + 1, maxlevel, step) + level; -} - -static void -doit (const char *label) -{ - double step, min_step, first_step, sum_step; - int i; - - sum_step = first_step = 0.0; - min_step = 1e99; - for (i = 0; i < iterations; ++i) - { - f1 (0, maxlevel, &step); - - sum_step += step; - - if (step < min_step) - min_step = step; - - if (i == 0) - first_step = step; - } - printf ("%s: unw_step : 1st=%9.3f min=%9.3f avg=%9.3f nsec\n", label, - 1e9*first_step, 1e9*min_step, 1e9*sum_step/iterations); -} - -static long -sum (void *buf, size_t size) -{ - long s = 0; - char *cp = buf; - size_t i; - - for (i = 0; i < size; i += 8) - s += cp[i]; - return s; -} - -static void -measure_init (void) -{ -# define N 100 -# define M 10 /* must be at least 2 to get steady-state */ - double stop, start, get_cold, get_warm, init_cold, init_warm, delta; - struct - { - unw_cursor_t c; - char padding[1024]; /* should be > 2 * max. cacheline size */ - } - cursor[N]; - struct - { - unw_context_t uc; - char padding[1024]; /* should be > 2 * max. cacheline size */ - } - uc[N]; - int i, j; - - /* Run each test M times and take the minimum to filter out noise - such dynamic linker resolving overhead, context-switches, - page-in, cache, and TLB effects. */ - - get_cold = 1e99; - for (j = 0; j < M; ++j) - { - dummy += sum (big, sizeof (big)); /* flush the cache */ - for (i = 0; i < N; ++i) - uc[i].padding[511] = i; /* warm up the TLB */ - start = gettime (); - for (i = 0; i < N; ++i) - unw_getcontext (&uc[i].uc); - stop = gettime (); - delta = (stop - start) / N; - if (delta < get_cold) - get_cold = delta; - } - - init_cold = 1e99; - for (j = 0; j < M; ++j) - { - dummy += sum (big, sizeof (big)); /* flush cache */ - for (i = 0; i < N; ++i) - uc[i].padding[511] = i; /* warm up the TLB */ - start = gettime (); - for (i = 0; i < N; ++i) - unw_init_local (&cursor[i].c, &uc[i].uc); - stop = gettime (); - delta = (stop - start) / N; - if (delta < init_cold) - init_cold = delta; - } - - get_warm = 1e99; - for (j = 0; j < M; ++j) - { - start = gettime (); - for (i = 0; i < N; ++i) - unw_getcontext (&uc[0].uc); - stop = gettime (); - delta = (stop - start) / N; - if (delta < get_warm) - get_warm = delta; - } - - init_warm = 1e99; - for (j = 0; j < M; ++j) - { - start = gettime (); - for (i = 0; i < N; ++i) - unw_init_local (&cursor[0].c, &uc[0].uc); - stop = gettime (); - delta = (stop - start) / N; - if (delta < init_warm) - init_warm = delta; - } - - printf ("unw_getcontext : cold avg=%9.3f nsec, warm avg=%9.3f nsec\n", - 1e9 * get_cold, 1e9 * get_warm); - printf ("unw_init_local : cold avg=%9.3f nsec, warm avg=%9.3f nsec\n", - 1e9 * init_cold, 1e9 * init_warm); -} - -int -main (int argc, char **argv) -{ - struct rlimit rlim; - - rlim.rlim_cur = RLIM_INFINITY; - rlim.rlim_max = RLIM_INFINITY; - setrlimit (RLIMIT_STACK, &rlim); - - memset (big, 0xaa, sizeof (big)); - - if (argc > 1) - { - maxlevel = atol (argv[1]); - if (argc > 2) - iterations = atol (argv[2]); - } - - measure_init (); - - doit ("default "); - - unw_set_caching_policy (unw_local_addr_space, UNW_CACHE_NONE); - doit ("no cache "); - - unw_set_caching_policy (unw_local_addr_space, UNW_CACHE_GLOBAL); - doit ("global cache "); - - unw_set_caching_policy (unw_local_addr_space, UNW_CACHE_PER_THREAD); - doit ("per-thread cache"); - - return 0; -} diff --git a/src/pal/src/libunwind/tests/Gperf-trace.c b/src/pal/src/libunwind/tests/Gperf-trace.c deleted file mode 100644 index 4d24fa5ca..000000000 --- a/src/pal/src/libunwind/tests/Gperf-trace.c +++ /dev/null @@ -1,250 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2003-2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -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. */ - -#include -#include -#include -#include - -#include -#include "compiler.h" - -#include -#include - -#define panic(args...) \ - do { fprintf (stderr, args); exit (-1); } while (0) - -long dummy; - -static long iterations = 10000; -static int maxlevel = 100; - -#define KB 1024 -#define MB (1024*1024) - -static char big[64*MB]; /* should be >> max. cache size */ - -static inline double -gettime (void) -{ - struct timeval tv; - - gettimeofday (&tv, NULL); - return tv.tv_sec + 1e-6*tv.tv_usec; -} - -static int NOINLINE -measure_unwind (int maxlevel, double *step) -{ - double stop, start; - int level = 0; - void *buffer[128]; - - start = gettime (); - level = unw_backtrace(buffer, 128); - stop = gettime (); - - if (level <= maxlevel) - panic ("Unwound only %d levels, expected at least %d levels\n", - level, maxlevel); - - *step = (stop - start) / (double) level; - return 0; -} - -static int f1 (int, int, double *); - -static int NOINLINE -g1 (int level, int maxlevel, double *step) -{ - if (level == maxlevel) - return measure_unwind (maxlevel, step); - else - /* defeat last-call/sibcall optimization */ - return f1 (level + 1, maxlevel, step) + level; -} - -static int NOINLINE -f1 (int level, int maxlevel, double *step) -{ - if (level == maxlevel) - return measure_unwind (maxlevel, step); - else - /* defeat last-call/sibcall optimization */ - return g1 (level + 1, maxlevel, step) + level; -} - -static void -doit (const char *label) -{ - double step, min_step, first_step, sum_step; - int i; - - sum_step = first_step = 0.0; - min_step = 1e99; - for (i = 0; i < iterations; ++i) - { - f1 (0, maxlevel, &step); - - sum_step += step; - - if (step < min_step) - min_step = step; - - if (i == 0) - first_step = step; - } - printf ("%s: unw_step : 1st=%9.3f min=%9.3f avg=%9.3f nsec\n", label, - 1e9*first_step, 1e9*min_step, 1e9*sum_step/iterations); -} - -static long -sum (void *buf, size_t size) -{ - long s = 0; - char *cp = buf; - size_t i; - - for (i = 0; i < size; i += 8) - s += cp[i]; - return s; -} - -static void -measure_init (void) -{ -# define N 100 -# define M 10 /* must be at least 2 to get steady-state */ - double stop, start, get_cold, get_warm, init_cold, init_warm, delta; - struct - { - unw_cursor_t c; - char padding[1024]; /* should be > 2 * max. cacheline size */ - } - cursor[N]; - struct - { - unw_context_t uc; - char padding[1024]; /* should be > 2 * max. cacheline size */ - } - uc[N]; - int i, j; - - /* Run each test M times and take the minimum to filter out noise - such dynamic linker resolving overhead, context-switches, - page-in, cache, and TLB effects. */ - - get_cold = 1e99; - for (j = 0; j < M; ++j) - { - dummy += sum (big, sizeof (big)); /* flush the cache */ - for (i = 0; i < N; ++i) - uc[i].padding[511] = i; /* warm up the TLB */ - start = gettime (); - for (i = 0; i < N; ++i) - unw_getcontext (&uc[i].uc); - stop = gettime (); - delta = (stop - start) / N; - if (delta < get_cold) - get_cold = delta; - } - - init_cold = 1e99; - for (j = 0; j < M; ++j) - { - dummy += sum (big, sizeof (big)); /* flush cache */ - for (i = 0; i < N; ++i) - uc[i].padding[511] = i; /* warm up the TLB */ - start = gettime (); - for (i = 0; i < N; ++i) - unw_init_local (&cursor[i].c, &uc[i].uc); - stop = gettime (); - delta = (stop - start) / N; - if (delta < init_cold) - init_cold = delta; - } - - get_warm = 1e99; - for (j = 0; j < M; ++j) - { - start = gettime (); - for (i = 0; i < N; ++i) - unw_getcontext (&uc[0].uc); - stop = gettime (); - delta = (stop - start) / N; - if (delta < get_warm) - get_warm = delta; - } - - init_warm = 1e99; - for (j = 0; j < M; ++j) - { - start = gettime (); - for (i = 0; i < N; ++i) - unw_init_local (&cursor[0].c, &uc[0].uc); - stop = gettime (); - delta = (stop - start) / N; - if (delta < init_warm) - init_warm = delta; - } - - printf ("unw_getcontext : cold avg=%9.3f nsec, warm avg=%9.3f nsec\n", - 1e9 * get_cold, 1e9 * get_warm); - printf ("unw_init_local : cold avg=%9.3f nsec, warm avg=%9.3f nsec\n", - 1e9 * init_cold, 1e9 * init_warm); -} - -int -main (int argc, char **argv) -{ - struct rlimit rlim; - - rlim.rlim_cur = RLIM_INFINITY; - rlim.rlim_max = RLIM_INFINITY; - setrlimit (RLIMIT_STACK, &rlim); - - memset (big, 0xaa, sizeof (big)); - - if (argc > 1) - { - maxlevel = atol (argv[1]); - if (argc > 2) - iterations = atol (argv[2]); - } - - measure_init (); - - doit ("default "); - - unw_set_caching_policy (unw_local_addr_space, UNW_CACHE_NONE); - doit ("no cache "); - - unw_set_caching_policy (unw_local_addr_space, UNW_CACHE_GLOBAL); - doit ("global cache "); - - unw_set_caching_policy (unw_local_addr_space, UNW_CACHE_PER_THREAD); - doit ("per-thread cache"); - - return 0; -} diff --git a/src/pal/src/libunwind/tests/Gtest-bt.c b/src/pal/src/libunwind/tests/Gtest-bt.c deleted file mode 100644 index beae2a3cc..000000000 --- a/src/pal/src/libunwind/tests/Gtest-bt.c +++ /dev/null @@ -1,263 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2001-2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -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. */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "compiler.h" - -#include -#if HAVE_EXECINFO_H -# include -#else - extern int backtrace (void **, int); -#endif -#include -#include -#include -#include -#include -#include -#include - -#define panic(args...) \ - { fprintf (stderr, args); exit (-1); } - -#define SIG_STACK_SIZE 0x100000 - -int verbose; -int num_errors; - -/* These variables are global because they - * cause the signal stack to overflow */ -char buf[512], name[256]; -unw_cursor_t cursor; -unw_context_t uc; - -static void -do_backtrace (void) -{ - unw_word_t ip, sp, off; - unw_proc_info_t pi; - int ret; - - if (verbose) - printf ("\texplicit backtrace:\n"); - - unw_getcontext (&uc); - if (unw_init_local (&cursor, &uc) < 0) - panic ("unw_init_local failed!\n"); - - do - { - unw_get_reg (&cursor, UNW_REG_IP, &ip); - unw_get_reg (&cursor, UNW_REG_SP, &sp); - buf[0] = '\0'; - if (unw_get_proc_name (&cursor, name, sizeof (name), &off) == 0) - { - if (off) - snprintf (buf, sizeof (buf), "<%s+0x%lx>", name, (long) off); - else - snprintf (buf, sizeof (buf), "<%s>", name); - } - if (verbose) - { - printf ("%016lx %-32s (sp=%016lx)\n", (long) ip, buf, (long) sp); - - if (unw_get_proc_info (&cursor, &pi) == 0) - { - printf ("\tproc=0x%lx-0x%lx\n\thandler=0x%lx lsda=0x%lx gp=0x%lx", - (long) pi.start_ip, (long) pi.end_ip, - (long) pi.handler, (long) pi.lsda, (long) pi.gp); - } - -#if UNW_TARGET_IA64 - { - unw_word_t bsp; - - unw_get_reg (&cursor, UNW_IA64_BSP, &bsp); - printf (" bsp=%lx", bsp); - } -#endif - printf ("\n"); - } - - ret = unw_step (&cursor); - if (ret < 0) - { - unw_get_reg (&cursor, UNW_REG_IP, &ip); - printf ("FAILURE: unw_step() returned %d for ip=%lx\n", - ret, (long) ip); - ++num_errors; - } - } - while (ret > 0); - - { - void *buffer[20]; - int i, n; - - if (verbose) - printf ("\n\tvia backtrace():\n"); - n = backtrace (buffer, 20); - if (verbose) - for (i = 0; i < n; ++i) - printf ("[%d] ip=%p\n", i, buffer[i]); - } -} - -void -foo (long val UNUSED) -{ - do_backtrace (); -} - -void -bar (long v) -{ - extern long f (long); - int arr[v]; - - /* This is a vain attempt to use up lots of registers to force - the frame-chain info to be saved on the memory stack on ia64. - It happens to work with gcc v3.3.4 and gcc v3.4.1 but perhaps - not with any other compiler. */ - foo (f (arr[0]) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) - + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) - + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) - + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) - + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) - + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) - + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) - + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) - + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) - + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) - + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) - + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) - + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) - + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) - + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) - + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) - + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + f (v)) - )))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) - ))))))))))))))))))))))))))))))))))))))))))))))))))))))); -} - -void -sighandler (int signal, void *siginfo UNUSED, void *context) -{ - ucontext_t *uc UNUSED; - int sp; - - uc = context; - - if (verbose) - { - printf ("sighandler: got signal %d, sp=%p", signal, &sp); -#if UNW_TARGET_IA64 -# if defined(__linux__) - printf (" @ %lx", uc->uc_mcontext.sc_ip); -# else - { - uint16_t reason; - uint64_t ip; - - __uc_get_reason (uc, &reason); - __uc_get_ip (uc, &ip); - printf (" @ %lx (reason=%d)", ip, reason); - } -# endif -#elif UNW_TARGET_X86 -#if defined __linux__ - printf (" @ %lx", (unsigned long) uc->uc_mcontext.gregs[REG_EIP]); -#elif defined __FreeBSD__ - printf (" @ %lx", (unsigned long) uc->uc_mcontext.mc_eip); -#endif -#elif UNW_TARGET_X86_64 -#if defined __linux__ - printf (" @ %lx", (unsigned long) uc->uc_mcontext.gregs[REG_RIP]); -#elif defined __FreeBSD__ - printf (" @ %lx", (unsigned long) uc->uc_mcontext.mc_rip); -#endif -#endif - printf ("\n"); - } - do_backtrace(); -} - -int -main (int argc, char **argv UNUSED) -{ - struct sigaction act; - stack_t stk; - - verbose = (argc > 1); - - if (verbose) - printf ("Normal backtrace:\n"); - - bar (1); - - memset (&act, 0, sizeof (act)); - act.sa_handler = (void (*)(int)) sighandler; - act.sa_flags = SA_SIGINFO; - if (sigaction (SIGTERM, &act, NULL) < 0) - panic ("sigaction: %s\n", strerror (errno)); - - if (verbose) - printf ("\nBacktrace across signal handler:\n"); - kill (getpid (), SIGTERM); - - if (verbose) - printf ("\nBacktrace across signal handler on alternate stack:\n"); - stk.ss_sp = malloc (SIG_STACK_SIZE); - if (!stk.ss_sp) - panic ("failed to allocate %u bytes\n", SIG_STACK_SIZE); - stk.ss_size = SIG_STACK_SIZE; - stk.ss_flags = 0; - if (sigaltstack (&stk, NULL) < 0) - panic ("sigaltstack: %s\n", strerror (errno)); - - memset (&act, 0, sizeof (act)); - act.sa_handler = (void (*)(int)) sighandler; - act.sa_flags = SA_ONSTACK | SA_SIGINFO; - if (sigaction (SIGTERM, &act, NULL) < 0) - panic ("sigaction: %s\n", strerror (errno)); - kill (getpid (), SIGTERM); - - if (num_errors > 0) - { - fprintf (stderr, "FAILURE: detected %d errors\n", num_errors); - exit (-1); - } - if (verbose) - printf ("SUCCESS.\n"); - - signal (SIGTERM, SIG_DFL); - stk.ss_flags = SS_DISABLE; - sigaltstack (&stk, NULL); - free (stk.ss_sp); - - return 0; -} diff --git a/src/pal/src/libunwind/tests/Gtest-concurrent.c b/src/pal/src/libunwind/tests/Gtest-concurrent.c deleted file mode 100644 index 6f3447fd8..000000000 --- a/src/pal/src/libunwind/tests/Gtest-concurrent.c +++ /dev/null @@ -1,136 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2003-2005 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -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. */ - -/* Verify that multi-threaded concurrent unwinding works as expected. */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "compiler.h" - -#include -#include -#include -#include -#include -#include -#include - -#define NTHREADS 128 - -#define panic(args...) \ - do { fprintf (stderr, args); ++nerrors; } while (0) - -int verbose; -int nerrors; -int got_usr1, got_usr2; -char *sigusr1_sp; - -void -handler (int sig UNUSED) -{ - unw_word_t ip; - unw_context_t uc; - unw_cursor_t c; - int ret; - - unw_getcontext (&uc); - unw_init_local (&c, &uc); - do - { - unw_get_reg (&c, UNW_REG_IP, &ip); - if (verbose) - printf ("%lx: IP=%lx\n", (long) pthread_self (), (unsigned long) ip); - } - while ((ret = unw_step (&c)) > 0); - - if (ret < 0) - panic ("unw_step() returned %d\n", ret); -} - -void * -worker (void *arg UNUSED) -{ - signal (SIGUSR1, handler); - - if (verbose) - printf ("sending SIGUSR1\n"); - pthread_kill (pthread_self (), SIGUSR1); - return NULL; -} - -static void -doit (void) -{ - pthread_t th[NTHREADS]; - pthread_attr_t attr; - int i; - - pthread_attr_init (&attr); - pthread_attr_setstacksize (&attr, PTHREAD_STACK_MIN + 64*1024); - - for (i = 0; i < NTHREADS; ++i) - if (pthread_create (th + i, &attr, worker, NULL)) - { - fprintf (stderr, "FAILURE: Failed to create %u threads " - "(after %u threads)\n", - NTHREADS, i); - exit (-1); - } - - for (i = 0; i < NTHREADS; ++i) - pthread_join (th[i], NULL); -} - -int -main (int argc, char **argv UNUSED) -{ - if (argc > 1) - verbose = 1; - - if (verbose) - printf ("Caching: none\n"); - unw_set_caching_policy (unw_local_addr_space, UNW_CACHE_NONE); - doit (); - - if (verbose) - printf ("Caching: global\n"); - unw_set_caching_policy (unw_local_addr_space, UNW_CACHE_GLOBAL); - doit (); - - if (verbose) - printf ("Caching: per-thread\n"); - unw_set_caching_policy (unw_local_addr_space, UNW_CACHE_PER_THREAD); - doit (); - - if (nerrors) - { - fprintf (stderr, "FAILURE: detected %d errors\n", nerrors); - exit (-1); - } - - if (verbose) - printf ("SUCCESS\n"); - return 0; -} diff --git a/src/pal/src/libunwind/tests/Gtest-dyn1.c b/src/pal/src/libunwind/tests/Gtest-dyn1.c deleted file mode 100644 index bc7dc9cf7..000000000 --- a/src/pal/src/libunwind/tests/Gtest-dyn1.c +++ /dev/null @@ -1,223 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2002-2003 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -/* This file tests dynamic code-generation via function-cloning. */ - -#include "flush-cache.h" - -#include "compiler.h" - -#include -#include -#include -#include -#include -#include -#include - -#if UNW_TARGET_ARM -#define MAX_FUNC_SIZE 96 /* FIXME: arch/compiler dependent */ -#else -#define MAX_FUNC_SIZE 2048 /* max. size of cloned function */ -#endif - -#define panic(args...) \ - { fprintf (stderr, args); exit (-1); } - -typedef void (*template_t) (int, void (*)(), - int (*)(const char *, ...), const char *, - const char **); - -int verbose; - -static const char *strarr[] = - { - "i", "ii", "iii", "iv", "v", "vi", "vii", "viii", "ix", "x", NULL - }; - -#ifdef __ia64__ -struct fdesc - { - long code; - long gp; - }; -# define get_fdesc(fdesc,func) (fdesc = *(struct fdesc *) &(func)) -# define get_funcp(fdesc) ((template_t) &(fdesc)) -# define get_gp(fdesc) ((fdesc).gp) -#elif __arm__ -struct fdesc - { - long code; - long is_thumb; - }; -/* Workaround GCC bug: https://bugs.launchpad.net/gcc-linaro/+bug/721531 */ -# define get_fdesc(fdesc,func) ({long tmp = (long) &(func); \ - (fdesc).code = (long) &(func) & ~0x1; \ - (fdesc).is_thumb = tmp & 0x1;}) -/*# define get_fdesc(fdesc,func) ({(fdesc).code = (long) &(func) & ~0x1; \ - (fdesc).is_thumb = (long) &(func) & 0x1;})*/ -# define get_funcp(fdesc) ((template_t) ((fdesc).code | (fdesc).is_thumb)) -# define get_gp(fdesc) (0) -#else -struct fdesc - { - long code; - }; -# define get_fdesc(fdesc,func) (fdesc.code = (long) &(func)) -# define get_funcp(fdesc) ((template_t) (fdesc).code) -# define get_gp(fdesc) (0) -#endif - -void -template (int i, template_t self, - int (*printer)(const char *, ...), const char *fmt, const char **arr) -{ - (*printer) (fmt, arr[11 - i][0], arr[11 - i] + 1); - if (i > 0) - (*self) (i - 1, self, printer, fmt, arr); -} - -static void -sighandler (int signal) -{ - unw_cursor_t cursor; - char name[128], off[32]; - unw_word_t ip, offset; - unw_context_t uc; - int count; - - if (verbose) - printf ("caught signal %d\n", signal); - - unw_getcontext (&uc); - unw_init_local (&cursor, &uc); - - count = 0; - while (!unw_is_signal_frame (&cursor)) - { - if (unw_step (&cursor) < 0) - panic ("failed to find signal frame!\n"); - - if (count++ > 20) - { - panic ("Too many steps to the signal frame (%d)\n", count); - break; - } - } - unw_step (&cursor); - - count = 0; - do - { - unw_get_reg (&cursor, UNW_REG_IP, &ip); - name[0] = '\0'; - off[0] = '\0'; - if (unw_get_proc_name (&cursor, name, sizeof (name), &offset) == 0 - && offset > 0) - snprintf (off, sizeof (off), "+0x%lx", (long) offset); - if (verbose) - printf ("ip = %lx <%s%s>\n", (long) ip, name, off); - ++count; - - if (count > 20) - { - panic ("Too many steps (%d)\n", count); - break; - } - - } - while (unw_step (&cursor) > 0); - - if (count != 13) - panic ("FAILURE: expected 13, not %d frames below signal frame\n", count); - - if (verbose) - printf ("SUCCESS\n"); - exit (0); -} - -int -dev_null (const char *format UNUSED, ...) -{ - return 0; -} - -int -main (int argc, char *argv[] UNUSED) -{ - unw_dyn_region_info_t *region; - unw_dyn_info_t di; - struct fdesc fdesc; - template_t funcp; - void *mem; - - if (argc > 1) - ++verbose; - - mem = malloc (getpagesize ()); - - get_fdesc (fdesc, template); - - if (verbose) - printf ("old code @ %p, new code @ %p\n", (void *) fdesc.code, mem); - - memcpy (mem, (void *) fdesc.code, MAX_FUNC_SIZE); - mprotect ((void *) ((long) mem & ~(getpagesize () - 1)), - 2*getpagesize(), PROT_READ | PROT_WRITE | PROT_EXEC); - - flush_cache (mem, MAX_FUNC_SIZE); - - signal (SIGSEGV, sighandler); - - /* register the new function: */ - region = alloca (_U_dyn_region_info_size (2)); - region->next = NULL; - region->insn_count = 3 * (MAX_FUNC_SIZE / 16); - region->op_count = 2; - _U_dyn_op_alias (®ion->op[0], 0, -1, fdesc.code); - _U_dyn_op_stop (®ion->op[1]); - - memset (&di, 0, sizeof (di)); - di.start_ip = (long) mem; - di.end_ip = (long) mem + 16*region->insn_count/3; - di.gp = get_gp (fdesc); - di.format = UNW_INFO_FORMAT_DYNAMIC; - di.u.pi.name_ptr = (unw_word_t) "copy_of_template"; - di.u.pi.regions = region; - - _U_dyn_register (&di); - - /* call new function: */ - fdesc.code = (long) mem; - funcp = get_funcp (fdesc); - - if (verbose) - (*funcp) (10, funcp, printf, "iteration %c%s\n", strarr); - else - (*funcp) (10, funcp, dev_null, "iteration %c%s\n", strarr); - - _U_dyn_cancel (&di); - return -1; -} diff --git a/src/pal/src/libunwind/tests/Gtest-exc.c b/src/pal/src/libunwind/tests/Gtest-exc.c deleted file mode 100644 index 1170bdd03..000000000 --- a/src/pal/src/libunwind/tests/Gtest-exc.c +++ /dev/null @@ -1,162 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2001-2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -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. */ - -/* This illustrates the basics of using the unwind interface for - exception handling. */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include -#include -#include - -#include - -#ifdef HAVE_IA64INTRIN_H -# include -#endif - -#define panic(args...) \ - { ++nerrors; fprintf (stderr, args); } - -int nerrors = 0; -int verbose = 0; -int depth = 13; -volatile int got_here = 0; - -extern void b (int); - -void -raise_exception (void) -{ - unw_cursor_t cursor; - unw_context_t uc; - int i; - - unw_getcontext (&uc); - if (unw_init_local (&cursor, &uc) < 0) - { - panic ("unw_init_local() failed!\n"); - return; - } - - /* unwind to top-most frame a(), skipping over b() and raise_exception(): */ - for (i = 0; i < depth + 2; ++i) - if (unw_step (&cursor) < 0) - { - panic ("unw_step() failed!\n"); - return; - } - unw_resume (&cursor); /* transfer control to exception handler */ -} - -uintptr_t -get_bsp (void) -{ -#if UNW_TARGET_IA64 -# ifdef __INTEL_COMPILER - return __getReg (_IA64_REG_AR_BSP); -# else - return (uintptr_t) __builtin_ia64_bsp (); -# endif -#else - return 0; -#endif -} - -int -a (int n) -{ - long stack; - int result = 99; - - if (verbose) - printf ("a(n=%d): sp=%p bsp=0x%lx\n", - n, &stack, (unsigned long) get_bsp ()); - - if (n > 0) - a (n - 1); - else - b (16); - - if (verbose) - { - printf ("exception handler: here we go (sp=%p, bsp=0x%lx)...\n", - &stack, (unsigned long) get_bsp ()); - /* This call works around a bug in gcc (up-to pre3.4) which - causes invalid assembly code to be generated when - __builtin_ia64_bsp() gets predicated. */ - getpid (); - } - if (n == depth) - { - result = 0; - got_here = 1; - } - return result; -} - -void -b (int n) -{ - if ((n & 1) == 0) - { - if (verbose) - printf ("b(n=%d) calling raise_exception()\n", n); - raise_exception (); - } - panic ("FAILURE: b() returned from raise_exception()!!\n"); -} - -int -main (int argc, char **argv) -{ - int result; - - if (argc > 1) - { - ++verbose; - depth = atol (argv[1]); - if (depth < 1) - { - fprintf (stderr, "Usage: %s depth\n" - " depth must be >= 1\n", argv[0]); - exit (-1); - } - } - - result = a (depth); - if (result != 0 || !got_here || nerrors > 0) - { - fprintf (stderr, - "FAILURE: test failed: result=%d got_here=%d nerrors=%d\n", - result, got_here, nerrors); - exit (-1); - } - - if (verbose) - printf ("SUCCESS!\n"); - return 0; -} diff --git a/src/pal/src/libunwind/tests/Gtest-init.cxx b/src/pal/src/libunwind/tests/Gtest-init.cxx deleted file mode 100644 index afded0192..000000000 --- a/src/pal/src/libunwind/tests/Gtest-init.cxx +++ /dev/null @@ -1,107 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2002-2003 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -/* This file tests unwinding from a constructor from within an - atexit() handler. */ - -#include -#include -#include - -#include -#include "compiler.h" - -int verbose, errors; - -#define panic(args...) \ - { ++errors; fprintf (stderr, args); return; } - -class Test_Class { - public: - Test_Class (void); -}; - -static Test_Class t; - -static void -do_backtrace (void) -{ - char name[128], off[32]; - unw_word_t ip, offset; - unw_cursor_t cursor; - unw_context_t uc; - int ret, count = 0; - - unw_getcontext (&uc); - unw_init_local (&cursor, &uc); - - do - { - unw_get_reg (&cursor, UNW_REG_IP, &ip); - name[0] = '\0'; - off[0] = '\0'; - if (unw_get_proc_name (&cursor, name, sizeof (name), &offset) == 0 - && offset > 0) - snprintf (off, sizeof (off), "+0x%lx", (long) offset); - if (verbose) - printf (" [%lx] <%s%s>\n", (long) ip, name, off); - if (++count > 32) - panic ("FAILURE: didn't reach beginning of unwind-chain\n"); - } - while ((ret = unw_step (&cursor)) > 0); - - if (ret < 0) - panic ("FAILURE: unw_step() returned %d\n", ret); -} - -static void -b (void) -{ - do_backtrace(); -} - -static void -a (void) -{ - if (verbose) - printf ("do_backtrace() from atexit()-handler:\n"); - b(); - if (errors) - abort (); /* cannot portably call exit() from an atexit() handler */ -} - -Test_Class::Test_Class (void) -{ - if (verbose) - printf ("do_backtrace() from constructor:\n"); - b(); -} - -int -main (int argc, char **argv UNUSED) -{ - verbose = argc > 1; - return atexit (a); -} diff --git a/src/pal/src/libunwind/tests/Gtest-nomalloc.c b/src/pal/src/libunwind/tests/Gtest-nomalloc.c deleted file mode 100644 index 5b97fc709..000000000 --- a/src/pal/src/libunwind/tests/Gtest-nomalloc.c +++ /dev/null @@ -1,110 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2009 Google, Inc - Contributed by Arun Sharma - -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. */ - -#include -#include -#include -#include -#include - -#define panic(args...) \ - { fprintf (stderr, args); exit (-1); } - -int verbose; -int num_errors; -int in_unwind; - -void * -malloc(size_t s) -{ - static void * (*func)(); - - if(!func) - func = (void *(*)()) dlsym(RTLD_NEXT, "malloc"); - - if (in_unwind) { - num_errors++; - return NULL; - } else { - return func(s); - } -} - -static void -do_backtrace (void) -{ - unw_word_t ip, sp; - unw_cursor_t cursor; - unw_context_t uc; - int ret; - - in_unwind = 1; - unw_getcontext (&uc); - if (unw_init_local (&cursor, &uc) < 0) - panic ("unw_init_local failed!\n"); - - do - { - unw_get_reg (&cursor, UNW_REG_IP, &ip); - unw_get_reg (&cursor, UNW_REG_SP, &sp); - - ret = unw_step (&cursor); - if (ret < 0) - { - ++num_errors; - } - } - while (ret > 0); - in_unwind = 0; -} - -void -foo3 (void) -{ - do_backtrace (); -} - -void -foo2 (void) -{ - foo3 (); -} - -void -foo1 (void) -{ - foo2 (); -} - -int -main (void) -{ - foo1(); - - if (num_errors > 0) - { - fprintf (stderr, "FAILURE: detected %d errors\n", num_errors); - exit (-1); - } - return 0; -} diff --git a/src/pal/src/libunwind/tests/Gtest-resume-sig-rt.c b/src/pal/src/libunwind/tests/Gtest-resume-sig-rt.c deleted file mode 100644 index df515fc19..000000000 --- a/src/pal/src/libunwind/tests/Gtest-resume-sig-rt.c +++ /dev/null @@ -1,31 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2003-2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - Copyright (C) 2012 Tommi Rantala - -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. */ - -/* The purpose of this test is to invoke different code paths in libunwind (on - * some architectures), that are executed when the SA_SIGINFO sigaction() flag - * is used. - */ - -#define TEST_WITH_SIGINFO 1 -#include "Gtest-resume-sig.c" diff --git a/src/pal/src/libunwind/tests/Gtest-resume-sig.c b/src/pal/src/libunwind/tests/Gtest-resume-sig.c deleted file mode 100644 index 18ec65da7..000000000 --- a/src/pal/src/libunwind/tests/Gtest-resume-sig.c +++ /dev/null @@ -1,200 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2003-2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -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. */ - -/* Verify that unw_resume() restores the signal mask at proper time. */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "compiler.h" - -#include -#include -#include -#include -#include -#include -#include - -#ifdef HAVE_IA64INTRIN_H -# include -#endif - -#define panic(args...) \ - do { fprintf (stderr, args); ++nerrors; } while (0) - -int verbose; -int nerrors; -int got_usr1, got_usr2; -char *sigusr1_sp; - -uintptr_t -get_bsp (void) -{ -#if UNW_TARGET_IA64 -# ifdef __INTEL_COMPILER - return __getReg (_IA64_REG_AR_BSP); -# else - return (uintptr_t) __builtin_ia64_bsp (); -# endif -#else - return 0; -#endif -} - -#ifdef TEST_WITH_SIGINFO -void -handler (int sig, - siginfo_t *si UNUSED, - void *ucontext UNUSED) -#else -void -handler (int sig) -#endif -{ - unw_word_t ip; - sigset_t mask; - unw_context_t uc; - unw_cursor_t c; - char foo; - int ret; - // The test rely on SIGUSR2 mask to be cleared when the handler returns. - // For local context from the signal handler, there doesn't seem to be a way - // currently to set it so just clear the whole struct to make sure the signal mask is cleared. - // This should probably be fixed to avoid signal mask being set to random values - // by `unw_resume` if the context was not pre-zeroed., - // Using the signal ucontext direction should also work automatically but currently doesn't - // on ARM/AArch64 (or any other archs that doesn't have a proper sigreturn implementation) - memset(&uc, 0x0, sizeof(uc)); - -#if UNW_TARGET_IA64 - if (verbose) - printf ("bsp = %llx\n", (unsigned long long) get_bsp ()); -#endif - - if (verbose) - printf ("got signal %d\n", sig); - - if (sig == SIGUSR1) - { - ++got_usr1; - sigusr1_sp = &foo; - - sigemptyset (&mask); - sigaddset (&mask, SIGUSR2); - sigprocmask (SIG_BLOCK, &mask, NULL); - kill (getpid (), SIGUSR2); /* pend SIGUSR2 */ - - signal (SIGUSR1, SIG_IGN); - - if ((ret = unw_getcontext (&uc)) < 0) - panic ("unw_getcontext() failed: ret=%d\n", ret); - if ((ret = unw_init_local (&c, &uc)) < 0) - panic ("unw_init_local() failed: ret=%d\n", ret); - - if ((ret = unw_step (&c)) < 0) /* step to signal trampoline */ - panic ("unw_step(1) failed: ret=%d\n", ret); - - if ((ret = unw_step (&c)) < 0) /* step to kill() */ - panic ("unw_step(2) failed: ret=%d\n", ret); - -#if defined(UNW_TARGET_TILEGX) - if ((ret = unw_step (&c)) < 0) /* step to signal trampoline */ - panic ("unw_step(2) failed: ret=%d\n", ret); -#endif - - if ((ret = unw_get_reg (&c, UNW_REG_IP, &ip)) < 0) - panic ("unw_get_reg(IP) failed: ret=%d\n", ret); - if (verbose) - printf ("resuming at 0x%lx, with SIGUSR2 pending\n", - (unsigned long) ip); - unw_resume (&c); - } - else if (sig == SIGUSR2) - { - ++got_usr2; - if (got_usr1) - { - if (verbose) - printf ("OK: stack still at %p\n", &foo); - } - signal (SIGUSR2, SIG_IGN); - } - else - panic ("Got unexpected signal %d\n", sig); -} - -int -main (int argc, char **argv UNUSED) -{ - struct sigaction sa; - float d = 1.0; - int n = 0; - - if (argc > 1) - verbose = 1; - - memset (&sa, 0, sizeof(sa)); -#ifdef TEST_WITH_SIGINFO - sa.sa_sigaction = handler; - sa.sa_flags = SA_SIGINFO; -#else - sa.sa_handler = handler; -#endif - - if (sigaction (SIGUSR1, &sa, NULL) != 0 || - sigaction (SIGUSR2, &sa, NULL) != 0) - { - fprintf (stderr, "sigaction() failed: %s\n", strerror (errno)); - return -1; - } - - /* Use the FPU a bit; otherwise we get spurious errors should the - signal handler need to use the FPU for any reason. This seems to - happen on x86-64. */ - while (d > 0.0) - { - d /= 2.0; - ++n; - } - if (n > 9999) - return -1; /* can't happen, but don't tell the compiler... */ - - if (verbose) - printf ("sending SIGUSR1\n"); - kill (getpid (), SIGUSR1); - - if (!got_usr2) - panic ("failed to get SIGUSR2\n"); - - if (nerrors) - { - fprintf (stderr, "FAILURE: detected %d errors\n", nerrors); - exit (-1); - } - - if (verbose) - printf ("SUCCESS\n"); - return 0; -} diff --git a/src/pal/src/libunwind/tests/Gtest-trace.c b/src/pal/src/libunwind/tests/Gtest-trace.c deleted file mode 100644 index fc1f646ea..000000000 --- a/src/pal/src/libunwind/tests/Gtest-trace.c +++ /dev/null @@ -1,282 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2010, 2011 by FERMI NATIONAL ACCELERATOR LABORATORY - -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. */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "compiler.h" - -#include -#if HAVE_EXECINFO_H -# include -#else - extern int backtrace (void **, int); -#endif -#include -#include -#include -#include -#include -#include -#include - -#define panic(args...) \ - { fprintf (stderr, args); exit (-1); } - -#define SIG_STACK_SIZE 0x100000 - -int verbose; -int num_errors; - -/* These variables are global because they - * cause the signal stack to overflow */ -char buf[512], name[256]; -void *addresses[3][128]; -unw_cursor_t cursor; -unw_context_t uc; - -static void -do_backtrace (void) -{ - unw_word_t ip; - int ret = -UNW_ENOINFO; - int depth = 0; - int i, n, m; - - if (verbose) - printf ("\tnormal trace:\n"); - - unw_getcontext (&uc); - if (unw_init_local (&cursor, &uc) < 0) - panic ("unw_init_local failed!\n"); - - do - { - unw_get_reg (&cursor, UNW_REG_IP, &ip); - addresses[0][depth] = (void *) ip; - } - while ((ret = unw_step (&cursor)) > 0 && ++depth < 128); - - if (ret < 0) - { - unw_get_reg (&cursor, UNW_REG_IP, &ip); - printf ("FAILURE: unw_step() returned %d for ip=%lx\n", ret, (long) ip); - ++num_errors; - } - - if (verbose) - for (i = 0; i < depth; ++i) - printf ("\t #%-3d ip=%p\n", i, addresses[0][i]); - - if (verbose) - printf ("\n\tvia backtrace():\n"); - - n = backtrace (addresses[1], 128); - - if (verbose) - for (i = 0; i < n; ++i) - printf ("\t #%-3d ip=%p\n", i, addresses[1][i]); - - if (verbose) - printf ("\n\tvia unw_backtrace():\n"); - - m = unw_backtrace (addresses[2], 128); - - if (verbose) - for (i = 0; i < m; ++i) - printf ("\t #%-3d ip=%p\n", i, addresses[2][i]); - - if (m != depth+1) - { - printf ("FAILURE: unw_step() loop and unw_backtrace() depths differ: %d vs. %d\n", depth, m); - ++num_errors; - } - - if (n != depth+1) - { - printf ("FAILURE: unw_step() loop and backtrace() depths differ: %d vs. %d\n", depth, n); - ++num_errors; - } - - if (n == m) - for (i = 1; i < n; ++i) - /* Allow one in difference in comparison, trace returns adjusted addresses. */ - if (labs((unw_word_t) addresses[1][i] - (unw_word_t) addresses[2][i]) > 1) - { - printf ("FAILURE: backtrace() and unw_backtrace() addresses differ at %d: %p vs. %p\n", - i, addresses[1][i], addresses[2][i]); - ++num_errors; - } - - if (n == depth+1) - for (i = 1; i < depth; ++i) - /* Allow one in difference in comparison, trace returns adjusted addresses. */ - if (labs((unw_word_t) addresses[0][i] - (unw_word_t) addresses[1][i]) > 1) - { - printf ("FAILURE: unw_step() loop and backtrace() addresses differ at %d: %p vs. %p\n", - i, addresses[0][i], addresses[1][i]); - ++num_errors; - } -} - -void -foo (long val UNUSED) -{ - do_backtrace (); -} - -void -bar (long v) -{ - extern long f (long); - int arr[v]; - - /* This is a vain attempt to use up lots of registers to force - the frame-chain info to be saved on the memory stack on ia64. - It happens to work with gcc v3.3.4 and gcc v3.4.1 but perhaps - not with any other compiler. */ - foo (f (arr[0]) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) - + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) - + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) - + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) - + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) - + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) - + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) - + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) - + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) - + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) - + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) - + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) - + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) - + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) - + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) - + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) - + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + f (v)) - )))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) - ))))))))))))))))))))))))))))))))))))))))))))))))))))))); -} - -void -sighandler (int signal, void *siginfo UNUSED, void *context) -{ - ucontext_t *uc UNUSED; - int sp; - - uc = context; - - if (verbose) - { - printf ("sighandler: got signal %d, sp=%p", signal, &sp); -#if UNW_TARGET_IA64 -# if defined(__linux__) - printf (" @ %lx", uc->uc_mcontext.sc_ip); -# else - { - uint16_t reason; - uint64_t ip; - - __uc_get_reason (uc, &reason); - __uc_get_ip (uc, &ip); - printf (" @ %lx (reason=%d)", ip, reason); - } -# endif -#elif UNW_TARGET_X86 -#if defined __linux__ - printf (" @ %lx", (unsigned long) uc->uc_mcontext.gregs[REG_EIP]); -#elif defined __FreeBSD__ - printf (" @ %lx", (unsigned long) uc->uc_mcontext.mc_eip); -#endif -#elif UNW_TARGET_X86_64 -#if defined __linux__ - printf (" @ %lx", (unsigned long) uc->uc_mcontext.gregs[REG_RIP]); -#elif defined __FreeBSD__ - printf (" @ %lx", (unsigned long) uc->uc_mcontext.mc_rip); -#endif -#elif defined UNW_TARGET_ARM -#if defined __linux__ - printf (" @ %lx", (unsigned long) uc->uc_mcontext.arm_pc); -#elif defined __FreeBSD__ - printf (" @ %lx", (unsigned long) uc->uc_mcontext.__gregs[_REG_PC]); -#endif -#endif - printf ("\n"); - } - do_backtrace(); -} - -int -main (int argc, char **argv UNUSED) -{ - struct sigaction act; - stack_t stk; - - verbose = (argc > 1); - - if (verbose) - printf ("Normal backtrace:\n"); - - bar (1); - - memset (&act, 0, sizeof (act)); - act.sa_handler = (void (*)(int)) sighandler; - act.sa_flags = SA_SIGINFO; - if (sigaction (SIGTERM, &act, NULL) < 0) - panic ("sigaction: %s\n", strerror (errno)); - - if (verbose) - printf ("\nBacktrace across signal handler:\n"); - kill (getpid (), SIGTERM); - - if (verbose) - printf ("\nBacktrace across signal handler on alternate stack:\n"); - stk.ss_sp = malloc (SIG_STACK_SIZE); - if (!stk.ss_sp) - panic ("failed to allocate %u bytes\n", SIG_STACK_SIZE); - stk.ss_size = SIG_STACK_SIZE; - stk.ss_flags = 0; - if (sigaltstack (&stk, NULL) < 0) - panic ("sigaltstack: %s\n", strerror (errno)); - - memset (&act, 0, sizeof (act)); - act.sa_handler = (void (*)(int)) sighandler; - act.sa_flags = SA_ONSTACK | SA_SIGINFO; - if (sigaction (SIGTERM, &act, NULL) < 0) - panic ("sigaction: %s\n", strerror (errno)); - kill (getpid (), SIGTERM); - - if (num_errors > 0) - { - fprintf (stderr, "FAILURE: detected %d errors\n", num_errors); - exit (-1); - } - - if (verbose) - printf ("SUCCESS.\n"); - - signal (SIGTERM, SIG_DFL); - stk.ss_flags = SS_DISABLE; - sigaltstack (&stk, NULL); - free (stk.ss_sp); - - return 0; -} diff --git a/src/pal/src/libunwind/tests/Lia64-test-nat.c b/src/pal/src/libunwind/tests/Lia64-test-nat.c deleted file mode 100644 index 15ef0cacc..000000000 --- a/src/pal/src/libunwind/tests/Lia64-test-nat.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if !defined(UNW_REMOTE_ONLY) -#include "Gia64-test-nat.c" -#endif diff --git a/src/pal/src/libunwind/tests/Lia64-test-rbs.c b/src/pal/src/libunwind/tests/Lia64-test-rbs.c deleted file mode 100644 index b838ebe42..000000000 --- a/src/pal/src/libunwind/tests/Lia64-test-rbs.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if !defined(UNW_REMOTE_ONLY) -#include "Gia64-test-rbs.c" -#endif diff --git a/src/pal/src/libunwind/tests/Lia64-test-readonly.c b/src/pal/src/libunwind/tests/Lia64-test-readonly.c deleted file mode 100644 index cd23e9261..000000000 --- a/src/pal/src/libunwind/tests/Lia64-test-readonly.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if !defined(UNW_REMOTE_ONLY) -#include "Gia64-test-readonly.c" -#endif diff --git a/src/pal/src/libunwind/tests/Lia64-test-stack.c b/src/pal/src/libunwind/tests/Lia64-test-stack.c deleted file mode 100644 index 3647629c9..000000000 --- a/src/pal/src/libunwind/tests/Lia64-test-stack.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if !defined(UNW_REMOTE_ONLY) -#include "Gia64-test-stack.c" -#endif diff --git a/src/pal/src/libunwind/tests/Lperf-simple.c b/src/pal/src/libunwind/tests/Lperf-simple.c deleted file mode 100644 index cdf38c207..000000000 --- a/src/pal/src/libunwind/tests/Lperf-simple.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if !defined(UNW_REMOTE_ONLY) -#include "Gperf-simple.c" -#endif diff --git a/src/pal/src/libunwind/tests/Lperf-trace.c b/src/pal/src/libunwind/tests/Lperf-trace.c deleted file mode 100644 index 1c3cf21c2..000000000 --- a/src/pal/src/libunwind/tests/Lperf-trace.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if !defined(UNW_REMOTE_ONLY) -#include "Gperf-trace.c" -#endif diff --git a/src/pal/src/libunwind/tests/Lrs-race.c b/src/pal/src/libunwind/tests/Lrs-race.c deleted file mode 100644 index 6fe497202..000000000 --- a/src/pal/src/libunwind/tests/Lrs-race.c +++ /dev/null @@ -1,1514 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2003-2005 Hewlett-Packard Co - Contributed by Paul Pluzhnikov - -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. */ - -/* Verify that register state caches work under all caching policies - in a multi-threaded environment with a large number IPs */ - -#define UNW_LOCAL_ONLY -#include -#include "compiler.h" - -#include -#include -#include - -/* ITERS=1000, NTHREAD=10 caught some bugs in the past */ -#ifndef ITERS -#define ITERS 100 -#endif - -#ifndef NTHREAD -#define NTHREAD 2 -#endif - -int verbose; - -void -foo_0 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_1 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_2 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_3 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_4 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_5 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_6 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_7 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_8 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_9 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_10 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_11 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_12 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_13 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_14 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_15 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_16 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_17 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_18 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_19 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_20 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_21 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_22 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_23 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_24 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_25 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_26 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_27 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_28 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_29 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_30 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_31 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_32 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_33 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_34 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_35 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_36 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_37 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_38 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_39 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_40 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_41 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_42 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_43 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_44 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_45 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_46 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_47 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_48 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_49 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_50 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_51 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_52 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_53 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_54 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_55 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_56 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_57 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_58 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_59 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_60 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_61 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_62 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_63 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_64 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_65 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_66 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_67 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_68 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_69 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_70 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_71 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_72 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_73 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_74 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_75 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_76 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_77 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_78 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_79 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_80 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_81 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_82 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_83 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_84 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_85 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_86 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_87 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_88 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_89 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_90 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_91 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_92 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_93 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_94 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_95 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_96 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_97 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_98 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_99 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_100 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_101 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_102 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_103 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_104 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_105 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_106 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_107 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_108 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_109 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_110 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_111 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_112 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_113 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_114 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_115 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_116 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_117 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_118 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_119 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_120 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_121 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_122 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_123 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_124 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_125 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_126 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_127 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void -foo_128 (void) -{ - void *buf[20]; - int n; - - if ((n = unw_backtrace (buf, 20)) < 3) - abort (); -} - -void * -bar(void *p UNUSED) -{ - int i; - for (i = 0; i < ITERS; ++i) { - foo_0 (); - foo_1 (); - foo_2 (); - foo_3 (); - foo_4 (); - foo_5 (); - foo_6 (); - foo_7 (); - foo_8 (); - foo_9 (); - foo_10 (); - foo_11 (); - foo_12 (); - foo_13 (); - foo_14 (); - foo_15 (); - foo_16 (); - foo_17 (); - foo_18 (); - foo_19 (); - foo_20 (); - foo_21 (); - foo_22 (); - foo_23 (); - foo_24 (); - foo_25 (); - foo_26 (); - foo_27 (); - foo_28 (); - foo_29 (); - foo_30 (); - foo_31 (); - foo_32 (); - foo_33 (); - foo_34 (); - foo_35 (); - foo_36 (); - foo_37 (); - foo_38 (); - foo_39 (); - foo_40 (); - foo_41 (); - foo_42 (); - foo_43 (); - foo_44 (); - foo_45 (); - foo_46 (); - foo_47 (); - foo_48 (); - foo_49 (); - foo_50 (); - foo_51 (); - foo_52 (); - foo_53 (); - foo_54 (); - foo_55 (); - foo_56 (); - foo_57 (); - foo_58 (); - foo_59 (); - foo_60 (); - foo_61 (); - foo_62 (); - foo_63 (); - foo_64 (); - foo_65 (); - foo_66 (); - foo_67 (); - foo_68 (); - foo_69 (); - foo_70 (); - foo_71 (); - foo_72 (); - foo_73 (); - foo_74 (); - foo_75 (); - foo_76 (); - foo_77 (); - foo_78 (); - foo_79 (); - foo_80 (); - foo_81 (); - foo_82 (); - foo_83 (); - foo_84 (); - foo_85 (); - foo_86 (); - foo_87 (); - foo_88 (); - foo_89 (); - foo_90 (); - foo_91 (); - foo_92 (); - foo_93 (); - foo_94 (); - foo_95 (); - foo_96 (); - foo_97 (); - foo_98 (); - foo_99 (); - foo_100 (); - foo_101 (); - foo_102 (); - foo_103 (); - foo_104 (); - foo_105 (); - foo_106 (); - foo_107 (); - foo_108 (); - foo_109 (); - foo_110 (); - foo_111 (); - foo_112 (); - foo_113 (); - foo_114 (); - foo_115 (); - foo_116 (); - foo_117 (); - foo_118 (); - foo_119 (); - foo_120 (); - foo_121 (); - foo_122 (); - foo_123 (); - foo_124 (); - foo_125 (); - foo_126 (); - foo_127 (); - foo_128 (); - } - return NULL; -} - -int doit (void) -{ - pthread_t tid[NTHREAD]; - int i; - - for (i = 0; i < NTHREAD; ++i) - if (pthread_create (&tid[i], NULL, bar, NULL)) - return 1; - - for (i = 0; i < NTHREAD; ++i) - if (pthread_join (tid[i], NULL)) - return 1; - - return 0; -} - -int -main (int argc, char **argv UNUSED) -{ - if (argc > 1) - verbose = 1; - - if (verbose) - printf ("Caching: none\n"); - unw_set_caching_policy (unw_local_addr_space, UNW_CACHE_NONE); - doit (); - - if (verbose) - printf ("Caching: global\n"); - unw_set_caching_policy (unw_local_addr_space, UNW_CACHE_GLOBAL); - doit (); - - if (verbose) - printf ("Caching: per-thread\n"); - unw_set_caching_policy (unw_local_addr_space, UNW_CACHE_PER_THREAD); - doit (); - - if (verbose) - printf ("SUCCESS\n"); - return 0; -} diff --git a/src/pal/src/libunwind/tests/Ltest-bt.c b/src/pal/src/libunwind/tests/Ltest-bt.c deleted file mode 100644 index 3489bf0b5..000000000 --- a/src/pal/src/libunwind/tests/Ltest-bt.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if !defined(UNW_REMOTE_ONLY) -#include "Gtest-bt.c" -#endif diff --git a/src/pal/src/libunwind/tests/Ltest-concurrent.c b/src/pal/src/libunwind/tests/Ltest-concurrent.c deleted file mode 100644 index 9462607ec..000000000 --- a/src/pal/src/libunwind/tests/Ltest-concurrent.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if !defined(UNW_REMOTE_ONLY) -#include "Gtest-concurrent.c" -#endif diff --git a/src/pal/src/libunwind/tests/Ltest-cxx-exceptions.cxx b/src/pal/src/libunwind/tests/Ltest-cxx-exceptions.cxx deleted file mode 100644 index 24bcd13e3..000000000 --- a/src/pal/src/libunwind/tests/Ltest-cxx-exceptions.cxx +++ /dev/null @@ -1,80 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2010 stefan.demharter@gmx.net - Copyright (C) 2010 arun.sharma@google.com - -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. */ - -#include -#include -#include -#include -#include "compiler.h" - -#define panic(args...) \ - { fprintf (stderr, args); exit (-1); } - -static int verbose; - -struct Test -{ - public: // --- ctor/dtor --- - Test() { ++counter_; } - ~Test() { -- counter_; } - Test(const Test&) { ++counter_; } - - public: // --- static members --- - static int counter_; -}; - -int Test::counter_ = 0; - -// Called by foo -extern "C" void bar() -{ - Test t; - try { - Test t; - throw 5; - } catch (...) { - Test t; - if (verbose) - printf("Throwing an int\n"); - throw 6; - } -} - -int main(int argc, char **argv UNUSED) -{ - if (argc > 1) - verbose = 1; - try { - Test t; - bar(); - } catch (int) { - // Dtor of all Test-object has to be called. - if (Test::counter_ != 0) - panic("Counter non-zero\n"); - return Test::counter_; - } catch (...) { - // An int was thrown - we should not get here. - panic("Int was thrown why are we here?\n"); - } - exit(0); -} diff --git a/src/pal/src/libunwind/tests/Ltest-dyn1.c b/src/pal/src/libunwind/tests/Ltest-dyn1.c deleted file mode 100644 index c2cab6b9a..000000000 --- a/src/pal/src/libunwind/tests/Ltest-dyn1.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if !defined(UNW_REMOTE_ONLY) -#include "Gtest-dyn1.c" -#endif diff --git a/src/pal/src/libunwind/tests/Ltest-exc.c b/src/pal/src/libunwind/tests/Ltest-exc.c deleted file mode 100644 index 36a234ca8..000000000 --- a/src/pal/src/libunwind/tests/Ltest-exc.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if !defined(UNW_REMOTE_ONLY) -#include "Gtest-exc.c" -#endif diff --git a/src/pal/src/libunwind/tests/Ltest-init-local-signal-lib.c b/src/pal/src/libunwind/tests/Ltest-init-local-signal-lib.c deleted file mode 100644 index 7474f71f4..000000000 --- a/src/pal/src/libunwind/tests/Ltest-init-local-signal-lib.c +++ /dev/null @@ -1,6 +0,0 @@ -#include - -/* To prevent inlining and optimizing away */ -int foo(volatile int* f) { - return *f; -} diff --git a/src/pal/src/libunwind/tests/Ltest-init-local-signal.c b/src/pal/src/libunwind/tests/Ltest-init-local-signal.c deleted file mode 100644 index 4bde218f3..000000000 --- a/src/pal/src/libunwind/tests/Ltest-init-local-signal.c +++ /dev/null @@ -1,60 +0,0 @@ -#include "libunwind.h" -#include -#include -#include - -#include - -#include -#include -#include - -int stepper(unw_cursor_t* c) { - int steps = 0; - int ret = 1; - while (ret) { - - ret = unw_step(c); - if (!ret) { - break; - } - steps++; - } - return steps; -} - -/* Verify that we can step from both ucontext, and from getcontext() - * roughly the same. This tests that the IP from ucontext is used - * correctly (see impl of unw_init_local2) */ -void handler(int num, siginfo_t* info, void* ucontext) { - unw_cursor_t c; - unw_context_t context; - unw_getcontext(&context); - int ret = unw_init_local2(&c, ucontext, UNW_INIT_SIGNAL_FRAME); - assert(!ret); - int ucontext_steps = stepper(&c); - - ret = unw_init_local(&c, &context); - (void)ret; - assert(!ret); - int getcontext_steps = stepper(&c); - if (ucontext_steps == getcontext_steps - 2) { - exit(0); - } - printf("unw_getcontext steps was %i, ucontext steps was %i, should be %i\n", - getcontext_steps, ucontext_steps, getcontext_steps - 2); - exit(-1); -} - -int foo(volatile int* f); - -int main(){ - struct sigaction a; - memset(&a, 0, sizeof(struct sigaction)); - a.sa_sigaction = &handler; - a.sa_flags = SA_SIGINFO; - sigaction(SIGSEGV, &a, NULL); - - foo(NULL); - return 0; -} diff --git a/src/pal/src/libunwind/tests/Ltest-init.cxx b/src/pal/src/libunwind/tests/Ltest-init.cxx deleted file mode 100644 index 58a6ea427..000000000 --- a/src/pal/src/libunwind/tests/Ltest-init.cxx +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if !defined(UNW_REMOTE_ONLY) -#include "Gtest-init.cxx" -#endif diff --git a/src/pal/src/libunwind/tests/Ltest-mem-validate.c b/src/pal/src/libunwind/tests/Ltest-mem-validate.c deleted file mode 100644 index 1cacb9f02..000000000 --- a/src/pal/src/libunwind/tests/Ltest-mem-validate.c +++ /dev/null @@ -1,143 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2003-2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -Copyright (c) 2003 Hewlett-Packard Co. - -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. */ - -#include "compiler.h" - -#include -#include -#include -#include -#include - -#include -#include - -#define panic(args...) \ - { fprintf (stderr, args); exit (-1); } - -void * stack_start; - -#define PAGE_SIZE 4096 - -void do_backtrace (void) -{ - void* buffer[1024]; - int size = 1024; - mprotect((void*)((uintptr_t)stack_start & ~(PAGE_SIZE - 1)), - PAGE_SIZE, PROT_NONE); - - unw_cursor_t cursor; - unw_word_t ip, sp; - unw_context_t uc; - int ret; - int steps = 0; - - unw_getcontext (&uc); - if (unw_init_local (&cursor, &uc) < 0) - panic ("unw_init_local failed!\n"); - - do - { - unw_get_reg (&cursor, UNW_REG_IP, &ip); - unw_get_reg (&cursor, UNW_REG_SP, &sp); - - ret = unw_step (&cursor); - if (ret < 0) - { - unw_get_reg (&cursor, UNW_REG_IP, &ip); - } - steps ++; - } - while (ret > 0); - - if (steps < 5) - { - exit(-1); - } - - mprotect((void*)((uintptr_t)stack_start & ~(PAGE_SIZE - 1)), - PAGE_SIZE, PROT_READ|PROT_WRITE); -} - -void consume_and_run (int depth) -{ - unw_cursor_t cursor; - unw_context_t uc; - char string[1024]; - - sprintf (string, "hello %p %p\n", &cursor, &uc); - if (depth == 0) { - do_backtrace(); - } else { - consume_and_run(depth - 1); - } -} - -int -main (int argc, char **argv UNUSED) -{ - int start; - unw_context_t uc; - unw_cursor_t cursor; - - stack_start = &start; - - // Initialize pipe mem validate check, opens file descriptors - unw_getcontext(&uc); - if (unw_init_local (&cursor, &uc) < 0) - panic ("unw_init_local failed!\n"); - - int i; - for (i = 3; i < 10; i++) - { - - pid_t childpid = fork(); - if (!childpid) - { - /* Close fds and make sure we still work */ - int ret = close(i); - } - - int status; - if (childpid) - { - wait(&status); - if (WIFEXITED(status)) - return WEXITSTATUS(status); - else - return -1; - } - else - { - consume_and_run (10); - - return 0; - } - } - - return 0; -} diff --git a/src/pal/src/libunwind/tests/Ltest-nocalloc.c b/src/pal/src/libunwind/tests/Ltest-nocalloc.c deleted file mode 100644 index f5c31b2a3..000000000 --- a/src/pal/src/libunwind/tests/Ltest-nocalloc.c +++ /dev/null @@ -1,137 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2011 Google, Inc - Contributed by Paul Pluzhnikov - -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. */ - -#define UNW_LOCAL_ONLY -#include - -#include -#include -#include -#include -#include - -#define panic(args...) \ - { fprintf (stderr, args); exit (-1); } - -int num_mallocs; -int num_callocs; -int in_unwind; - -void * -calloc(size_t n, size_t s) -{ - static void * (*func)(size_t, size_t); - -#ifdef __GLIBC__ - /* In glibc, dlsym() calls calloc. Calling dlsym(RTLD_NEXT, "calloc") here - causes infinite recursion. Instead, we simply use it by its other - name. */ - extern void *__libc_calloc(size_t, size_t); - if (!func) - func = &__libc_calloc; -#else - if(!func) - func = dlsym(RTLD_NEXT, "calloc"); -#endif - - if (in_unwind) { - num_callocs++; - return NULL; - } else { - return func(n, s); - } -} - -void * -malloc(size_t s) -{ - static void * (*func)(size_t); - - if(!func) - func = dlsym(RTLD_NEXT, "malloc"); - - if (in_unwind) { - num_mallocs++; - return NULL; - } else { - return func(s); - } -} - -static void -do_backtrace (void) -{ - const int num_levels = 100; - void *pc[num_levels]; - - in_unwind = 1; - unw_backtrace(pc, num_levels); - in_unwind = 0; -} - -void -foo3 (void) -{ - do_backtrace (); -} - -void -foo2 (void) -{ - foo3 (); -} - -void -foo1 (void) -{ - foo2 (); -} - -int -main (void) -{ - int i, num_errors; - - /* Create (and leak) 100 TSDs, then call backtrace() - and check that it doesn't call malloc()/calloc(). */ - for (i = 0; i < 100; ++i) { - pthread_key_t key; - if (pthread_key_create (&key, NULL)) - panic ("FAILURE: unable to create key %d\n", i); - } - /* Call backtrace right after thread creation, - * where we are sure that we're not inside malloc */ - do_backtrace(); - num_mallocs = num_callocs = 0; - foo1 (); - num_errors = num_mallocs + num_callocs; - if (num_errors > 0) - { - fprintf (stderr, - "FAILURE: detected %d error%s (malloc: %d, calloc: %d)\n", - num_errors, num_errors > 1 ? "s" : "", - num_mallocs, num_callocs); - exit (-1); - } - return 0; -} diff --git a/src/pal/src/libunwind/tests/Ltest-nomalloc.c b/src/pal/src/libunwind/tests/Ltest-nomalloc.c deleted file mode 100644 index 74d633128..000000000 --- a/src/pal/src/libunwind/tests/Ltest-nomalloc.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if !defined(UNW_REMOTE_ONLY) -#include "Gtest-nomalloc.c" -#endif diff --git a/src/pal/src/libunwind/tests/Ltest-resume-sig-rt.c b/src/pal/src/libunwind/tests/Ltest-resume-sig-rt.c deleted file mode 100644 index 01fd6dc7d..000000000 --- a/src/pal/src/libunwind/tests/Ltest-resume-sig-rt.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if !defined(UNW_REMOTE_ONLY) -#include "Gtest-resume-sig-rt.c" -#endif diff --git a/src/pal/src/libunwind/tests/Ltest-resume-sig.c b/src/pal/src/libunwind/tests/Ltest-resume-sig.c deleted file mode 100644 index 0047b524a..000000000 --- a/src/pal/src/libunwind/tests/Ltest-resume-sig.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if !defined(UNW_REMOTE_ONLY) -#include "Gtest-resume-sig.c" -#endif diff --git a/src/pal/src/libunwind/tests/Ltest-trace.c b/src/pal/src/libunwind/tests/Ltest-trace.c deleted file mode 100644 index fb0e9c10b..000000000 --- a/src/pal/src/libunwind/tests/Ltest-trace.c +++ /dev/null @@ -1,5 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#if !defined(UNW_REMOTE_ONLY) -#include "Gtest-trace.c" -#endif diff --git a/src/pal/src/libunwind/tests/Ltest-varargs.c b/src/pal/src/libunwind/tests/Ltest-varargs.c deleted file mode 100644 index 17ac600be..000000000 --- a/src/pal/src/libunwind/tests/Ltest-varargs.c +++ /dev/null @@ -1,84 +0,0 @@ -#define UNW_LOCAL_ONLY -#include -#include "compiler.h" - -#include -#include -#include -#include - -int ok; -int verbose; - -#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 3) -void a (int, ...) __attribute__((optimize(0))); -void b (void) __attribute__((optimize(0))); -void c (void) __attribute__((optimize(0))); -#endif - -void NOINLINE -b (void) -{ - void *v[20]; - int i, n; - - n = unw_backtrace(v, 20); - - /* Check that the number of addresses given by unw_backtrace() looks - * reasonable. If the compiler inlined everything, then this check will also - * break. */ - if (n >= 7) - ok = 1; - - if (verbose) - for (i = 0; i < n; ++i) - printf ("[%d] %p\n", i, v[i]); -} - -void NOINLINE -c (void) -{ - b (); -} - -void NOINLINE -a (int d, ...) -{ - switch (d) - { - case 5: - a (4, 2,4); - break; - case 4: - a (3, 1,3,5); - break; - case 3: - a (2, 11, 13, 17, 23); - break; - case 2: - a (1); - break; - case 1: - c (); - } -} - -int -main (int argc, char **argv UNUSED) -{ - if (argc > 1) - verbose = 1; - - a (5, 3, 4, 5, 6); - - if (!ok) - { - fprintf (stderr, "FAILURE: expected deeper backtrace.\n"); - return 1; - } - - if (verbose) - printf ("SUCCESS.\n"); - - return 0; -} diff --git a/src/pal/src/libunwind/tests/Makefile.am b/src/pal/src/libunwind/tests/Makefile.am deleted file mode 100644 index 4b0b9db7d..000000000 --- a/src/pal/src/libunwind/tests/Makefile.am +++ /dev/null @@ -1,234 +0,0 @@ -AM_CPPFLAGS = -I$(top_srcdir)/include - -EXTRA_DIST = run-ia64-test-dyn1 run-ptrace-mapper run-ptrace-misc \ - run-check-namespace run-coredump-unwind \ - run-coredump-unwind-mdi check-namespace.sh.in \ - Gtest-nomalloc.c - -MAINTAINERCLEANFILES = Makefile.in - -noinst_PROGRAMS_arch = -noinst_PROGRAMS_cdep = -noinst_PROGRAMS_common = -check_PROGRAMS_arch = -check_PROGRAMS_cdep = -check_PROGRAMS_common = test-proc-info test-static-link \ - test-strerror -check_SCRIPTS_arch = -check_SCRIPTS_cdep = -check_SCRIPTS_common = run-check-namespace - -if REMOTE_ONLY - -perf: - -else - LIBUNWIND_local = $(top_builddir)/src/libunwind.la -if ARCH_IA64 - noinst_PROGRAMS_arch += ia64-test-dyn1 - check_SCRIPTS_arch += run-ia64-test-dyn1 - check_PROGRAMS_arch += Gia64-test-stack Lia64-test-stack \ - Gia64-test-nat Lia64-test-nat \ - Gia64-test-rbs Lia64-test-rbs \ - Gia64-test-readonly Lia64-test-readonly \ - ia64-test-setjmp ia64-test-sig -else #!ARCH_IA64 -if ARCH_PPC64 -if USE_ALTIVEC - noinst_PROGRAMS_arch += ppc64-test-altivec -endif #USE_ALTIVEC -endif #ARCH_PPC64 -endif #!ARCH_IA64 - check_PROGRAMS_cdep += Gtest-bt Ltest-bt Gtest-exc Ltest-exc \ - Gtest-init Ltest-init \ - Gtest-concurrent Ltest-concurrent \ - Gtest-resume-sig Ltest-resume-sig \ - Gtest-resume-sig-rt Ltest-resume-sig-rt \ - Gtest-trace Ltest-trace \ - Ltest-init-local-signal \ - Ltest-mem-validate \ - test-async-sig test-flush-cache test-init-remote \ - test-mem test-reg-state Ltest-varargs \ - Ltest-nomalloc Ltest-nocalloc Lrs-race - noinst_PROGRAMS_cdep += forker Gperf-simple Lperf-simple \ - Gperf-trace Lperf-trace - -if BUILD_PTRACE - check_SCRIPTS_cdep += run-ptrace-mapper run-ptrace-misc - check_PROGRAMS_cdep += test-ptrace - noinst_PROGRAMS_cdep += mapper test-ptrace-misc -endif - -if BUILD_SETJMP - check_PROGRAMS_cdep += test-setjmp -endif - -if SUPPORT_CXX_EXCEPTIONS - check_PROGRAMS_cdep += Ltest-cxx-exceptions -endif - -if OS_LINUX -if BUILD_COREDUMP - check_SCRIPTS_cdep += run-coredump-unwind - noinst_PROGRAMS_cdep += crasher test-coredump-unwind - -if HAVE_LZMA - check_SCRIPTS_cdep += run-coredump-unwind-mdi -endif # HAVE_LZMA -endif # BUILD_COREDUMP -endif # OS_LINUX - -perf: perf-startup Gperf-simple Lperf-simple Lperf-trace - @echo "########## Basic performance of generic libunwind:" - @./Gperf-simple - @echo "########## Basic performance of local-only libunwind:" - @./Lperf-simple - @echo "########## Performance of fast unwind:" - @./Lperf-trace - @echo "########## Startup overhead:" - @$(srcdir)/perf-startup @arch@ - -endif - -check_PROGRAMS = $(check_PROGRAMS_common) $(check_PROGRAMS_cdep) \ - $(check_PROGRAMS_arch) -check_SCRIPTS = $(check_SCRIPTS_common) $(check_SCRIPTS_cdep) \ - $(check_SCRIPTS_arch) - - -TESTS = $(check_PROGRAMS) $(check_SCRIPTS) -XFAIL_TESTS = - -if ARCH_IA64 - check_PROGRAMS_cdep += Gtest-dyn1 Ltest-dyn1 -endif - -# Use if arch defines but does not support PTRACE_SINGLESTEP -# ptrace request used in the tests. -XFAIL_TESTS_PTRACE_SINGLESTEP = run-ptrace-mapper run-ptrace-misc - -if ARCH_MIPS -XFAIL_TESTS += $(XFAIL_TESTS_PTRACE_SINGLESTEP) -endif - -if ARCH_ARM -# ARM Linux kernel >=2.6.39 removed PTRACE_SINGLESTEP emulation -XFAIL_TESTS += $(XFAIL_TESTS_PTRACE_SINGLESTEP) -endif - -# This is meant for multilib binaries, -m32. -# ptrace gives EBADREG when testing, -# but generally everything else works. -if NO_PTRACE_TEST - XFAIL_TESTS += run-ptrace-mapper test-ptrace Ltest-init-local-signal -endif - -noinst_PROGRAMS = $(noinst_PROGRAMS_common) $(noinst_PROGRAMS_cdep) \ - $(noinst_PROGRAMS_arch) - -Lia64_test_readonly_SOURCES = Lia64-test-readonly.c ia64-test-readonly-asm.S -Gia64_test_readonly_SOURCES = Gia64-test-readonly.c ia64-test-readonly-asm.S -Lia64_test_stack_SOURCES = Lia64-test-stack.c ia64-test-stack-asm.S \ - ia64-test-stack.h -Gia64_test_stack_SOURCES = Gia64-test-stack.c ia64-test-stack-asm.S \ - ia64-test-stack.h -Lia64_test_rbs_SOURCES = Lia64-test-rbs.c ia64-test-rbs-asm.S ia64-test-rbs.h -Gia64_test_rbs_SOURCES = Gia64-test-rbs.c ia64-test-rbs-asm.S ia64-test-rbs.h -Lia64_test_nat_SOURCES = Lia64-test-nat.c ia64-test-nat-asm.S -Gia64_test_nat_SOURCES = Gia64-test-nat.c ia64-test-nat-asm.S -ia64_test_dyn1_SOURCES = ia64-test-dyn1.c ia64-dyn-asm.S flush-cache.S \ - flush-cache.h -ppc64_test_altivec_SOURCES = ppc64-test-altivec.c ppc64-test-altivec-utils.c -Gtest_init_SOURCES = Gtest-init.cxx -Ltest_init_SOURCES = Ltest-init.cxx -Ltest_cxx_exceptions_SOURCES = Ltest-cxx-exceptions.cxx - -Ltest_init_local_signal_SOURCES = Ltest-init-local-signal.c Ltest-init-local-signal-lib.c - -Gtest_dyn1_SOURCES = Gtest-dyn1.c flush-cache.S flush-cache.h -Ltest_dyn1_SOURCES = Ltest-dyn1.c flush-cache.S flush-cache.h -test_static_link_SOURCES = test-static-link-loc.c test-static-link-gen.c -test_static_link_LDFLAGS = -static -forker_LDFLAGS = -static -Gtest_bt_SOURCES = Gtest-bt.c ident.c -Ltest_bt_SOURCES = Ltest-bt.c ident.c -test_ptrace_misc_SOURCES = test-ptrace-misc.c ident.c -Ltest_nomalloc_SOURCES = Ltest-nomalloc.c -Ltest_nocalloc_SOURCES = Ltest-nocalloc.c -Gtest_trace_SOURCES = Gtest-trace.c ident.c -Ltest_trace_SOURCES = Ltest-trace.c ident.c -Ltest_mem_validate_SOURCES = Ltest-mem-validate.c - -LIBUNWIND = $(top_builddir)/src/libunwind-$(arch).la -LIBUNWIND_ptrace = $(top_builddir)/src/libunwind-ptrace.la -LIBUNWIND_coredump = $(top_builddir)/src/libunwind-coredump.la - -if USE_ELF32 -LIBUNWIND_ELF = $(top_builddir)/src/libunwind-elf32.la -endif -if USE_ELF64 -LIBUNWIND_ELF = $(top_builddir)/src/libunwind-elf64.la -endif -if USE_ELFXX -LIBUNWIND_ELF = $(top_builddir)/src/libunwind-elfxx.la -endif - -LIBUNWIND_setjmp = $(top_builddir)/src/libunwind-setjmp.la \ - $(LIBUNWIND_ELF) $(LIBUNWIND) - -test_async_sig_LDADD = $(LIBUNWIND_local) -lpthread -test_flush_cache_LDADD = $(LIBUNWIND_local) -test_init_remote_LDADD = $(LIBUNWIND) $(LIBUNWIND_local) -test_mem_LDADD = $(LIBUNWIND) $(LIBUNWIND_local) -test_reg_state_LDADD = $(LIBUNWIND) $(LIBUNWIND_local) -test_ptrace_LDADD = $(LIBUNWIND_ptrace) $(LIBUNWIND) -test_proc_info_LDADD = $(LIBUNWIND) -test_static_link_LDADD = $(LIBUNWIND) -test_strerror_LDADD = $(LIBUNWIND) -Lrs_race_LDADD = $(LIBUNWIND_local) -lpthread -Ltest_varargs_LDADD = $(LIBUNWIND_local) -Ltest_init_local_signal_LDADD = $(LIBUNWIND) $(LIBUNWIND_local) - -Gtest_bt_LDADD = $(LIBUNWIND) $(LIBUNWIND_local) -Gtest_concurrent_LDADD = $(LIBUNWIND) $(LIBUNWIND_local) -lpthread -Gtest_dyn1_LDADD = $(LIBUNWIND) $(LIBUNWIND_local) -Gtest_exc_LDADD = $(LIBUNWIND) $(LIBUNWIND_local) -Gtest_init_LDADD = $(LIBUNWIND) $(LIBUNWIND_local) @BACKTRACELIB@ -Gtest_resume_sig_LDADD = $(LIBUNWIND) $(LIBUNWIND_local) -Gtest_resume_sig_rt_LDADD = $(LIBUNWIND) $(LIBUNWIND_local) -Gperf_simple_LDADD = $(LIBUNWIND) $(LIBUNWIND_local) -Gtest_trace_LDADD=$(LIBUNWIND) $(LIBUNWIND_local) -Gperf_trace_LDADD = $(LIBUNWIND) $(LIBUNWIND_local) - -Ltest_bt_LDADD = $(LIBUNWIND_local) -Ltest_concurrent_LDADD = $(LIBUNWIND_local) -lpthread -Ltest_dyn1_LDADD = $(LIBUNWIND_local) -Ltest_exc_LDADD = $(LIBUNWIND_local) -Ltest_init_LDADD = $(LIBUNWIND_local) -Ltest_nomalloc_LDADD = $(LIBUNWIND_local) @DLLIB@ -Ltest_nocalloc_LDADD = $(LIBUNWIND_local) @DLLIB@ -lpthread -Ltest_resume_sig_LDADD = $(LIBUNWIND_local) -Ltest_resume_sig_rt_LDADD = $(LIBUNWIND_local) -Lperf_simple_LDADD = $(LIBUNWIND_local) -Ltest_trace_LDADD = $(LIBUNWIND_local) -Lperf_trace_LDADD = $(LIBUNWIND_local) -Ltest_mem_validate_LDADD = $(LIBUNWIND) $(LIBUNWIND_local) - -test_setjmp_LDADD = $(LIBUNWIND_setjmp) -ia64_test_setjmp_LDADD = $(LIBUNWIND_setjmp) - -if BUILD_COREDUMP -test_coredump_unwind_LDADD = $(LIBUNWIND_coredump) $(LIBUNWIND) @BACKTRACELIB@ -endif - -Gia64_test_nat_LDADD = $(LIBUNWIND) $(LIBUNWIND_local) -Gia64_test_stack_LDADD = $(LIBUNWIND) $(LIBUNWIND_local) -Gia64_test_rbs_LDADD = $(LIBUNWIND) $(LIBUNWIND_local) -Gia64_test_readonly_LDADD = $(LIBUNWIND) $(LIBUNWIND_local) -Lia64_test_nat_LDADD = $(LIBUNWIND_local) -Lia64_test_stack_LDADD = $(LIBUNWIND_local) -Lia64_test_rbs_LDADD = $(LIBUNWIND_local) -Lia64_test_readonly_LDADD = $(LIBUNWIND_local) -ia64_test_dyn1_LDADD = $(LIBUNWIND) -ia64_test_sig_LDADD = $(LIBUNWIND) -ppc64_test_altivec_LDADD = $(LIBUNWIND) diff --git a/src/pal/src/libunwind/tests/check-namespace.sh.in b/src/pal/src/libunwind/tests/check-namespace.sh.in deleted file mode 100644 index 6d0081732..000000000 --- a/src/pal/src/libunwind/tests/check-namespace.sh.in +++ /dev/null @@ -1,367 +0,0 @@ -#!/bin/sh -verbose=false -if [ "$1" = "-v" ]; then - verbose=true - shift -fi - -build_plat=@build_arch@ -plat=@arch@ -os=@target_os@ -num_errors=0 - -LIBUNWIND=../src/.libs/libunwind.so -LIBUNWIND_GENERIC=../src/.libs/libunwind-${plat}.so - -fetch_symtab () { - filename=$1 - - if [ ! -r $filename ]; then - return - fi - - if $verbose; then - echo "Checking $filename..." - fi - - # - # Unfortunately, "nm --defined" is a GNU-extension. For portability, - # build the list of defined symbols by hand. - # - symtab=`nm -g $filename` - saved_IFS="$IFS" - IFS="" - undef=`nm -g -u $filename` - for line in $undef; do - symtab=`echo "$symtab" | grep -v "^${line}"\$` - done; - IFS="$saved_IFS" -} - -ignore () { - sym=$1 - symtab=`echo "$symtab" | grep -v " ${sym}\$"` -} - -match () { - sym=$1 - if `echo "$symtab" | grep -q " ${sym}\$"`; then - symtab=`echo "$symtab" | grep -v " ${sym}\$"` - else - echo " ERROR: Symbol \"$sym\" missing." - num_errors=`expr $num_errors + 1` - fi -} - -# -# Filter out miscellaneous symbols that get defined by the -# linker for each shared object. -# -filter_misc () { - ignore _DYNAMIC - ignore _GLOBAL_OFFSET_TABLE_ - ignore __bss_start - ignore _edata - ignore _end - ignore _Uelf32_get_proc_name - ignore _Uelf32_valid_object - ignore _Uelf64_get_proc_name - ignore _Uelf64_valid_object - ignore _U.*debug_level - ignore ICRT.INTERNAL # ICC 8.x defines this - - # Ignore symbols generated by the ARM Linux default linker script. - # For details see the binutils sources (src/ld/emulparams/armelf_linux.sh). - if [ ${plat} = "arm" ]; then - ignore __bss_start__ - ignore __bss_end__ - ignore __end__ - ignore _bss_end__ - fi - - if [ ${plat} = "mips" ]; then - ignore _fbss - ignore _fdata - ignore _ftext - ignore _gp - fi -} - -check_local_unw_abi () { - match _UL${plat}_apply_reg_state - match _UL${plat}_reg_states_iterate - match _UL${plat}_create_addr_space - match _UL${plat}_destroy_addr_space - match _UL${plat}_get_fpreg - match _UL${plat}_get_proc_info - match _UL${plat}_get_proc_info_by_ip - match _UL${plat}_get_proc_name - match _UL${plat}_get_reg - match _UL${plat}_get_save_loc - match _UL${plat}_init_local - match _UL${plat}_init_local2 - match _UL${plat}_init_remote - match _UL${plat}_is_signal_frame - match _UL${plat}_local_addr_space - match _UL${plat}_resume - match _UL${plat}_set_caching_policy - match _UL${plat}_set_cache_size - match _UL${plat}_set_reg - match _UL${plat}_set_fpreg - match _UL${plat}_step - - match _U${plat}_flush_cache - match _U${plat}_get_accessors - match _U${plat}_getcontext - match _U${plat}_regname - match _U${plat}_strerror - - match _U_dyn_cancel - match _U_dyn_info_list_addr - match _U_dyn_register - - match unw_backtrace - match backtrace - - case ${plat} in - arm) - match _U${plat}_get_elf_image - match _U${plat}_get_exe_image_path - match _U${plat}_is_fpreg - match _UL${plat}_search_unwind_table - match _UL${plat}_dwarf_search_unwind_table - match _UL${plat}_dwarf_find_unwind_table - ;; - hppa) - match _UL${plat}_dwarf_search_unwind_table - match _UL${plat}_dwarf_find_unwind_table - match _U${plat}_get_elf_image - match _U${plat}_get_exe_image_path - match _U${plat}_setcontext - ;; - ia64) - match _UL${plat}_search_unwind_table - match _U${plat}_get_elf_image - match _U${plat}_get_exe_image_path - ;; - x86) - match _U${plat}_get_elf_image - match _U${plat}_get_exe_image_path - match _U${plat}_is_fpreg - match _UL${plat}_dwarf_search_unwind_table - match _UL${plat}_dwarf_find_unwind_table - ;; - x86_64) - match _U${plat}_get_elf_image - match _U${plat}_get_exe_image_path - match _U${plat}_is_fpreg - match _UL${plat}_dwarf_search_unwind_table - match _UL${plat}_dwarf_find_unwind_table - match _U${plat}_setcontext - ;; - ppc*) - match _U${plat}_get_func_addr - match _U${plat}_get_elf_image - match _U${plat}_get_exe_image_path - match _U${plat}_is_fpreg - match _UL${plat}_dwarf_search_unwind_table - match _UL${plat}_dwarf_find_unwind_table - ;; - tilegx) - match _U${plat}_is_fpreg - match _UL${plat}_dwarf_search_unwind_table - match _UL${plat}_dwarf_find_unwind_table - match _UL${plat}_local_addr_space_init - match _U${plat}_get_elf_image - match _U${plat}_get_exe_image_path - match ${plat}_lock - ;; - - *) - match _U${plat}_is_fpreg - match _UL${plat}_dwarf_search_unwind_table - match _UL${plat}_dwarf_find_unwind_table - ;; - esac - - if [ x@enable_debug_frame@ = xyes ]; then - match _UL${plat}_dwarf_find_debug_frame - fi - -} - -check_generic_unw_abi () { - match _U${plat}_apply_reg_state - match _U${plat}_reg_states_iterate - match _U${plat}_create_addr_space - match _U${plat}_destroy_addr_space - match _U${plat}_flush_cache - match _U${plat}_get_accessors - match _U${plat}_get_fpreg - match _U${plat}_get_proc_info - match _U${plat}_get_proc_info_by_ip - match _U${plat}_get_proc_name - match _U${plat}_get_reg - match _U${plat}_get_save_loc - match _U${plat}_init_local - match _U${plat}_init_local2 - match _U${plat}_init_remote - match _U${plat}_is_signal_frame - match _U${plat}_local_addr_space - match _U${plat}_regname - match _U${plat}_resume - match _U${plat}_set_caching_policy - match _U${plat}_set_cache_size - match _U${plat}_set_fpreg - match _U${plat}_set_reg - match _U${plat}_step - match _U${plat}_strerror - - case ${plat} in - arm) - match _U${plat}_is_fpreg - match _U${plat}_get_elf_image - match _U${plat}_get_exe_image_path - match _U${plat}_search_unwind_table - match _U${plat}_dwarf_search_unwind_table - match _U${plat}_dwarf_find_unwind_table - ;; - hppa) - match _U${plat}_dwarf_search_unwind_table - match _U${plat}_dwarf_find_unwind_table - match _U${plat}_get_elf_image - match _U${plat}_get_exe_image_path - ;; - ia64) - match _U${plat}_search_unwind_table - match _U${plat}_find_dyn_list - if [ $plat = $build_plat ]; then - match _U${plat}_get_elf_image - match _U${plat}_get_exe_image_path - case $os in - linux*) - match _U${plat}_get_kernel_table - ;; - esac - fi - ;; - x86) - match _U${plat}_get_elf_image - match _U${plat}_get_exe_image_path - match _U${plat}_is_fpreg - match _U${plat}_dwarf_search_unwind_table - match _U${plat}_dwarf_find_unwind_table - ;; - x86_64) - match _U${plat}_get_elf_image - match _U${plat}_get_exe_image_path - match _U${plat}_is_fpreg - match _U${plat}_dwarf_search_unwind_table - match _U${plat}_dwarf_find_unwind_table - ;; - ppc*) - match _U${plat}_get_elf_image - match _U${plat}_get_exe_image_path - match _U${plat}_get_func_addr - match _U${plat}_is_fpreg - match _U${plat}_dwarf_search_unwind_table - match _U${plat}_dwarf_find_unwind_table - ;; - tilegx) - match _U${plat}_dwarf_search_unwind_table - match _U${plat}_dwarf_find_unwind_table - match _U${plat}_get_elf_image - match _U${plat}_get_exe_image_path - match _U${plat}_is_fpreg - match _U${plat}_local_addr_space_init - match ${plat}_lock - ;; - *) - match _U${plat}_is_fpreg - match _U${plat}_dwarf_search_unwind_table - match _U${plat}_dwarf_find_unwind_table - ;; - esac - - if [ x@enable_debug_frame@ = xyes ]; then - match _U${plat}_dwarf_find_debug_frame - fi -} - -check_cxx_abi () { - match _Unwind_Backtrace - match _Unwind_DeleteException - match _Unwind_FindEnclosingFunction - match _Unwind_ForcedUnwind - match _Unwind_GetBSP - match _Unwind_GetCFA - match _Unwind_GetDataRelBase - match _Unwind_GetGR - match _Unwind_GetIP - match _Unwind_GetIPInfo - match _Unwind_GetLanguageSpecificData - match _Unwind_GetRegionStart - match _Unwind_GetTextRelBase - match _Unwind_RaiseException - match _Unwind_Resume - match _Unwind_Resume_or_Rethrow - match _Unwind_SetGR - match _Unwind_SetIP - match __libunwind_Unwind_Backtrace - match __libunwind_Unwind_DeleteException - match __libunwind_Unwind_FindEnclosingFunction - match __libunwind_Unwind_ForcedUnwind - match __libunwind_Unwind_GetBSP - match __libunwind_Unwind_GetCFA - match __libunwind_Unwind_GetDataRelBase - match __libunwind_Unwind_GetGR - match __libunwind_Unwind_GetIP - match __libunwind_Unwind_GetIPInfo - match __libunwind_Unwind_GetLanguageSpecificData - match __libunwind_Unwind_GetRegionStart - match __libunwind_Unwind_GetTextRelBase - match __libunwind_Unwind_RaiseException - match __libunwind_Unwind_Resume - match __libunwind_Unwind_Resume_or_Rethrow - match __libunwind_Unwind_SetGR - match __libunwind_Unwind_SetIP - case $os in - linux*) - # needed only for Intel 8.0 bug-compatibility - match _ReadSLEB - match _ReadULEB - ;; - esac -} - -check_empty () { - if [ -n "$symtab" ]; then - printf " ERROR: Extraneous symbols:\n$symtab\n" - num_errors=`expr $num_errors + 1` - fi -} - -if [ $plat = $build_plat ]; then - fetch_symtab $LIBUNWIND - filter_misc - check_local_unw_abi - if [ x@enable_cxx_exceptions@ = xyes ]; then - check_cxx_abi - fi - check_empty -fi - -fetch_symtab $LIBUNWIND_GENERIC -filter_misc -check_generic_unw_abi -check_empty - -if [ $num_errors -gt 0 ]; then - echo "FAILURE: Detected $num_errors errors" - exit 1 -fi - -if $verbose; then - echo " SUCCESS: all checks passed" -fi -exit 0 diff --git a/src/pal/src/libunwind/tests/crasher.c b/src/pal/src/libunwind/tests/crasher.c deleted file mode 100644 index 24c78054c..000000000 --- a/src/pal/src/libunwind/tests/crasher.c +++ /dev/null @@ -1,124 +0,0 @@ -/* This program should crash and produce coredump */ - -#include "compiler.h" - -#include -#include -#include -#include -#ifdef __FreeBSD__ -#include -#include -#include -#endif - -#if defined(__linux__) -void write_maps(char *fname) -{ - char buf[512], path[128]; - char exec; - uintmax_t addr; - FILE *maps = fopen("/proc/self/maps", "r"); - FILE *out = fopen(fname, "w"); - - if (!maps || !out) - exit(EXIT_FAILURE); - - while (fgets(buf, sizeof(buf), maps)) - { - if (sscanf(buf, "%jx-%*x %*c%*c%c%*c %*x %*s %*d /%126[^\n]", &addr, &exec, path+1) != 3) - continue; - - if (exec != 'x') - continue; - - path[0] = '/'; - fprintf(out, "0x%jx:%s ", addr, path); - } - fprintf(out, "\n"); - - fclose(out); - fclose(maps); -} -#elif defined(__FreeBSD__) -void -write_maps(char *fname) -{ - FILE *out; - char *buf, *bp, *eb; - struct kinfo_vmentry *kv; - int mib[4], error; - size_t len; - - out = fopen(fname, "w"); - if (out == NULL) - exit(EXIT_FAILURE); - - len = 0; - mib[0] = CTL_KERN; - mib[1] = KERN_PROC; - mib[2] = KERN_PROC_VMMAP; - mib[3] = getpid(); - error = sysctl(mib, 4, NULL, &len, NULL, 0); - if (error == -1) - exit(EXIT_FAILURE); - len = len * 4 / 3; - buf = malloc(len); - if (buf == NULL) - exit(EXIT_FAILURE); - error = sysctl(mib, 4, buf, &len, NULL, 0); - if (error == -1) - exit(EXIT_FAILURE); - - for (bp = buf, eb = buf + len; bp < eb; bp += kv->kve_structsize) { - kv = (struct kinfo_vmentry *)(uintptr_t)bp; - if (kv->kve_type == KVME_TYPE_VNODE && - (kv->kve_protection & KVME_PROT_EXEC) != 0) { - fprintf(out, "0x%jx:%s ", kv->kve_start, kv->kve_path); - } - } - - fprintf(out, "\n"); - fclose(out); - free(buf); -} -#else -#error Port me -#endif - -#ifdef __GNUC__ -int c(int x) NOINLINE ALIAS(b); -#define compiler_barrier() asm volatile(""); -#else -int c(int x); -#define compiler_barrier() -#endif - -int NOINLINE a(void) -{ - *(volatile int *)32 = 1; - return 1; -} - -int NOINLINE b(int x) -{ - int r; - - compiler_barrier(); - - if (x) - r = a(); - else - r = c(1); - return r + 1; -} - -int -main (int argc, char **argv) -{ - if (argc > 1) - write_maps(argv[1]); - b(0); - return 0; -} - diff --git a/src/pal/src/libunwind/tests/flush-cache.S b/src/pal/src/libunwind/tests/flush-cache.S deleted file mode 100644 index 3ee47269e..000000000 --- a/src/pal/src/libunwind/tests/flush-cache.S +++ /dev/null @@ -1,104 +0,0 @@ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#ifndef HAVE__BUILTIN___CLEAR_CACHE - -#if defined(__ia64__) - - .global flush_cache - - .proc flush_cache -flush_cache: - .prologue - alloc r2=ar.pfs,2,0,0,0 - add r8=31,in1 // round up to 32 byte-boundary - ;; - shr.u r8=r8,5 // we flush 32 bytes per iteration - ;; - add r8=-1,r8 - .save ar.lc, r3 - mov r3=ar.lc // save ar.lc - ;; - .body - - mov ar.lc=r8 - ;; -.loop: fc in0 // issuable on M0 only - add in0=32,in0 - br.cloop.sptk.few .loop - ;; - sync.i - ;; - srlz.i - ;; - mov ar.lc=r3 // restore ar.lc - br.ret.sptk.many rp - .endp flush_cache - -#elif defined(__i386__) || defined (__x86_64__) - - .globl flush_cache -flush_cache: - ret - -#elif defined(__hppa__) - -# warning FIX ME!! - - .globl flush_cache -flush_cache: - .proc - .callinfo - bv %r0(%rp) - .procend -#elif defined(__powerpc64__) -# warning IMPLEMENT ME FOR PPC64!! - .globl flush_cache -flush_cache: - lwz 11, 0(1) ; - lwz 0, 4(11) ; - mtlr 0 ; - lwz 31, -4(11) ; - mr 1, 11 ; - blr -#elif defined(__powerpc__) -# warning IMPLEMENT ME FOR PPC32!! - .globl flush_cache -flush_cache: - lwz 11, 0(1) ; - lwz 0, 4(11) ; - mtlr 0 ; - lwz 31, -4(11) ; - mr 1, 11 ; - blr -#elif defined(__arm__) - .text - .globl flush_cache -flush_cache: - bx lr -#elif defined(__tilegx__) - .text - .globl flush_cache -flush_cache: - - andi r0, r0, -64 -1: { - flush r0 ; - addi r0, r0, 64 - } - { - bgtz r1, 1b ; - addi r1, r1, -64 - } - jrp lr -#else -# error Need flush_cache code for this architecture. -#endif - -#if defined ( __linux__) && !defined (__arm__) - /* We do not need executable stack. */ - .section .note.GNU-stack,"",@progbits -#endif - -#endif diff --git a/src/pal/src/libunwind/tests/flush-cache.h b/src/pal/src/libunwind/tests/flush-cache.h deleted file mode 100644 index 8227d85b3..000000000 --- a/src/pal/src/libunwind/tests/flush-cache.h +++ /dev/null @@ -1,38 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2012 Tommi Rantala - -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. */ - -#ifndef FLUSH_CACHE_H -#define FLUSH_CACHE_H - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#ifdef HAVE__BUILTIN___CLEAR_CACHE -#define flush_cache(ADDR, LEN) \ - __builtin___clear_cache((ADDR), (ADDR) + (LEN)) -#else -#include -extern void flush_cache (void *addr, size_t len); -#endif - -#endif /* FLUSH_CACHE_H */ diff --git a/src/pal/src/libunwind/tests/forker.c b/src/pal/src/libunwind/tests/forker.c deleted file mode 100644 index b03f86a7f..000000000 --- a/src/pal/src/libunwind/tests/forker.c +++ /dev/null @@ -1,76 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -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. */ - -#include -#include -#include - -#include -#include -#include - -int -main (int argc, char **argv, char **envp) -{ - char *program, **child_argv; - struct timeval start, stop; - double secs; - int status, i; - long count; - pid_t pid; - - count = atol (argv[1]); - program = argv[2]; - - child_argv = alloca ((argc - 1) * sizeof (char *)); - for (i = 0; i < argc - 2; ++i) - child_argv[i] = argv[2 + i]; - child_argv[i] = NULL; - - gettimeofday (&start, NULL); - for (i = 0; i < count; ++i) - { - pid = fork (); - if (pid == 0) - { - execve (program, child_argv, envp); - _exit (-1); - } - else - { - waitpid (pid, &status, 0); - if (!WIFEXITED (status) || WEXITSTATUS (status) != 0) - { - fprintf (stderr, "%s: child failed\n", argv[0]); - exit (-1); - } - } - } - gettimeofday (&stop, NULL); - - secs = ((stop.tv_sec + 1e-6 * stop.tv_usec) - - (start.tv_sec + 1e-6 * start.tv_usec)); - printf ("%lu nsec/execution\n", - (unsigned long) (1e9 * secs / (double) count)); - return 0; -} diff --git a/src/pal/src/libunwind/tests/ia64-dyn-asm.S b/src/pal/src/libunwind/tests/ia64-dyn-asm.S deleted file mode 100644 index 79582e9e1..000000000 --- a/src/pal/src/libunwind/tests/ia64-dyn-asm.S +++ /dev/null @@ -1,102 +0,0 @@ - .globl func_add1, func_add1_end - .proc func_add1 -func_add1: -{.mib; add r8 = 1, r32 - nop.i 0 - br.ret.sptk.many rp -} -func_add1_end: - .endp func_add1 - - .globl func_add3, func_add3_end - .proc func_add3 -func_add3: -{.mmi; alloc loc0 = ar.pfs, 2, 1, 2, 0 - mov r2 = sp - add sp = -16, sp -} ;; -{.mii; ld8 r8 = [in1], 8 // load the function pointer - mov r3 = rp - mov rp = loc0 // trash rp -} ;; -{.mmi; ld8 r9 = [r8], 8 // load the entry-point - st8 [r2] = r3 - mov out0 = in0 -} ;; -{.mii; ld8 gp = [r8] // load the gp - mov b6 = r9 - mov out1 = in1 -} -{.mib; nop 0 - nop 0 - br.call.sptk rp = b6 -} -{.mmi; add r2 = 16, sp - ;; - ld8 r3 = [r2] // r3 = saved rp - mov ar.pfs = loc0 -} ;; -{.mii; nop 0 - mov rp = r3 - adds sp = 16, sp -} ;; -{.mib; st8 [sp] = in0 // trash rp save location - add r8 = 2, r8 - br.ret.sptk.many rp -} -func_add3_end: - .endp func_add3 - - .globl func_vframe, func_vframe_end - .proc func_vframe -func_vframe: -{.mii; alloc r16 = ar.pfs, 1, 2, 0, 0 // 0 - mov loc0 = rp - mov loc1 = sp -} ;; -{.mmi; sub sp = sp, in0 - st8 [loc1] = r16 - mov r2 = -99 // 0 -} ;; -{.mii; nop 0 - mov rp = r2 - mov ar.pfs = r0 -} -{.mib; mov r16 = r2 - tbit.nz p6, p0 = in0, 4 -(p6) br.cond.sptk.many .exit -} ;; -{.mmi; ld8 r16 = [loc1] - ;; - mov r3 = loc0 // 8 move saved rp to r3 - mov ar.pfs = r16 -} ;; -{.mmi; mov sp = loc1 // 10 - st8 [loc1] = r0 // trash saved pfs - mov loc0 = r2 -} ;; -{.mib; mov r8 = 10 - mov rp = r3 - br.ret.sptk.many rp -} -.exit: -{.mmi; ld8 r16 = [loc1] - ;; - sub sp = 32, sp - mov ar.pfs = r16 -} ;; -{.mmi; mov sp = loc1 - st8 [loc1] = r0 // trash saved pfs - mov rp = loc0 -} -{.mib; nop 0 - mov r8 = 4 - br.ret.sptk.many rp -} -func_vframe_end: - .endp func_vframe - -#ifdef __linux__ - /* We do not need executable stack. */ - .section .note.GNU-stack,"",@progbits -#endif diff --git a/src/pal/src/libunwind/tests/ia64-test-dyn1.c b/src/pal/src/libunwind/tests/ia64-test-dyn1.c deleted file mode 100644 index 90127dd5b..000000000 --- a/src/pal/src/libunwind/tests/ia64-test-dyn1.c +++ /dev/null @@ -1,223 +0,0 @@ -#include "flush-cache.h" - -#include -#include -#include -#include -#include -#include -#include - -#include - -int verbose; - -#ifdef __ia64__ -# define GET_ENTRY(fdesc) (((uintptr_t *) (fdesc))[0]) -# define GET_GP(fdesc) (((uintptr_t *) (fdesc))[0]) -# define EXTRA 16 -#else -# define GET_ENTRY(fdesc) ((uintptr_t ) (fdesc)) -# define GET_GP(fdesc) (0) -# define EXTRA 0 -#endif - -int -make_executable (void *addr, size_t len) -{ - if (mprotect ((void *) (((long) addr) & -getpagesize ()), len, - PROT_READ | PROT_WRITE | PROT_EXEC) < 0) - { - perror ("mprotect"); - return -1; - } - flush_cache (addr, len); - return 0; -} - -void * -create_func (unw_dyn_info_t *di, const char *name, long (*func) (), - void *end, unw_dyn_region_info_t *region) -{ - void *mem, *memend, *addr, *fptr; - unw_word_t gp = 0; - size_t len; - - len = (uintptr_t) end - GET_ENTRY (func) + EXTRA; - mem = malloc (len); - if (verbose) - printf ("%s: cloning %s at %p (%zu bytes)\n", - __FUNCTION__, name, mem, len); - memend = (char *) mem + len; - -#ifdef __ia64__ - addr = (void *) GET_ENTRY (func); - - /* build function descriptor: */ - ((long *) mem)[0] = (long) mem + 16; /* entry point */ - ((long *) mem)[1] = GET_GP (func); /* global-pointer */ - fptr = mem; - mem = (void *) ((long) mem + 16); -#else - fptr = mem; -#endif - - len = (char *) memend - (char *) mem; - memcpy (mem, addr, len); - - if (make_executable (mem, len) < 0) - return NULL; - - if (di) - { - memset (di, 0, sizeof (*di)); - di->start_ip = (unw_word_t) mem; - di->end_ip = (unw_word_t) memend; - di->gp = gp; - di->format = UNW_INFO_FORMAT_DYNAMIC; - di->u.pi.name_ptr = (unw_word_t) name; - di->u.pi.regions = region; - } - return fptr; -} - -int -main (int argc, char **argv) -{ - extern long func_add1 (long); - extern char func_add1_end[]; - extern long func_add3 (long, long (*[])()); - extern char func_add3_end[]; - extern long func_vframe (long); - extern char func_vframe_end[]; - unw_dyn_region_info_t *r_pro, *r_epi, *r, *rtmp; - unw_dyn_info_t di0, di1, di2, di3; - long (*add1) (long); - long (*add3_0) (long); - long (*add3_1) (long, void *[]); - long (*vframe) (long); - void *flist[2]; - long ret; - int i; - - signal (SIGUSR1, SIG_IGN); - signal (SIGUSR2, SIG_IGN); - - if (argc != 1) - verbose = 1; - - add1 = (long (*)(long)) - create_func (&di0, "func_add1", func_add1, func_add1_end, NULL); - - /* Describe the epilogue of func_add3: */ - i = 0; - r_epi = alloca (_U_dyn_region_info_size (5)); - r_epi->op_count = 5; - r_epi->next = NULL; - r_epi->insn_count = -9; - _U_dyn_op_pop_frames (&r_epi->op[i++], - _U_QP_TRUE, /* when=*/ 5, /* num_frames=*/ 1); - _U_dyn_op_stop (&r_epi->op[i++]); - assert ((unsigned) i <= r_epi->op_count); - - /* Describe the prologue of func_add3: */ - i = 0; - r_pro = alloca (_U_dyn_region_info_size (4)); - r_pro->op_count = 4; - r_pro->next = r_epi; - r_pro->insn_count = 8; - _U_dyn_op_save_reg (&r_pro->op[i++], _U_QP_TRUE, /* when=*/ 0, - /* reg=*/ UNW_IA64_AR_PFS, /* dst=*/ UNW_IA64_GR + 34); - _U_dyn_op_add (&r_pro->op[i++], _U_QP_TRUE, /* when=*/ 2, - /* reg= */ UNW_IA64_SP, /* val=*/ -16); - _U_dyn_op_save_reg (&r_pro->op[i++], _U_QP_TRUE, /* when=*/ 4, - /* reg=*/ UNW_IA64_RP, /* dst=*/ UNW_IA64_GR + 3); - _U_dyn_op_spill_sp_rel (&r_pro->op[i++], _U_QP_TRUE, /* when=*/ 7, - /* reg=*/ UNW_IA64_RP, /* off=*/ 16); - assert ((unsigned) i <= r_pro->op_count); - - /* Create regions for func_vframe: */ - i = 0; - r = alloca (_U_dyn_region_info_size (16)); - r->op_count = 16; - r->next = NULL; - r->insn_count = 4; - _U_dyn_op_label_state (&r->op[i++], /* label=*/ 100402); - _U_dyn_op_pop_frames (&r->op[i++], _U_QP_TRUE, /* when=*/ 3, /* frames=*/ 1); - _U_dyn_op_stop (&r->op[i++]); - assert ((unsigned) i <= r->op_count); - - i = 0; - rtmp = r; - r = alloca (_U_dyn_region_info_size (16)); - r->op_count = 16; - r->next = rtmp; - r->insn_count = 16; - _U_dyn_op_save_reg (&r->op[i++], _U_QP_TRUE, /* when=*/ 8, - /* reg=*/ UNW_IA64_RP, /* dst=*/ UNW_IA64_GR + 3); - _U_dyn_op_pop_frames (&r->op[i++], _U_QP_TRUE, /* when=*/ 10, - /* num_frames=*/ 1); - _U_dyn_op_stop (&r->op[i++]); - assert ((unsigned) i <= r->op_count); - - i = 0; - rtmp = r; - r = alloca (_U_dyn_region_info_size (16)); - r->op_count = 16; - r->next = rtmp; - r->insn_count = 5; - _U_dyn_op_save_reg (&r->op[i++], _U_QP_TRUE, /* when=*/ 1, - /* reg=*/ UNW_IA64_RP, /* dst=*/ UNW_IA64_GR + 33); - _U_dyn_op_save_reg (&r->op[i++], _U_QP_TRUE, /* when=*/ 2, - /* reg=*/ UNW_IA64_SP, /* dst=*/ UNW_IA64_GR + 34); - _U_dyn_op_spill_fp_rel (&r->op[i++], _U_QP_TRUE, /* when=*/ 4, - /* reg=*/ UNW_IA64_AR_PFS, /* off=*/ 16); - _U_dyn_op_label_state (&r->op[i++], /* label=*/ 100402); - _U_dyn_op_stop (&r->op[i++]); - assert ((unsigned) i <= r->op_count); - - /* Create two functions which can share the region-list: */ - add3_0 = (long (*) (long)) - create_func (&di1, "func_add3/0", func_add3, func_add3_end, r_pro); - add3_1 = (long (*) (long, void *[])) - create_func (&di2, "func_add3/1", func_add3, func_add3_end, r_pro); - vframe = (long (*) (long)) - create_func (&di3, "func_vframe", func_vframe, func_vframe_end, r); - - _U_dyn_register (&di1); - _U_dyn_register (&di2); - _U_dyn_register (&di3); - _U_dyn_register (&di0); - - flist[0] = add3_0; - flist[1] = add1; - - kill (getpid (), SIGUSR1); /* do something ptmon can latch onto */ - ret = (*add3_1) (13, flist); - if (ret != 18) - { - fprintf (stderr, "FAILURE: (*add3_1)(13) returned %ld\n", ret); - exit (-1); - } - - ret = (*vframe) (48); - if (ret != 4) - { - fprintf (stderr, "FAILURE: (*vframe)(16) returned %ld\n", ret); - exit (-1); - } - ret = (*vframe) (64); - if (ret != 10) - { - fprintf (stderr, "FAILURE: (*vframe)(32) returned %ld\n", ret); - exit (-1); - } - kill (getpid (), SIGUSR2); /* do something ptmon can latch onto */ - - _U_dyn_cancel (&di0); - _U_dyn_cancel (&di1); - _U_dyn_cancel (&di3); - _U_dyn_cancel (&di2); - - return 0; -} diff --git a/src/pal/src/libunwind/tests/ia64-test-nat-asm.S b/src/pal/src/libunwind/tests/ia64-test-nat-asm.S deleted file mode 100644 index eea5ac278..000000000 --- a/src/pal/src/libunwind/tests/ia64-test-nat-asm.S +++ /dev/null @@ -1,508 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2004-2005 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - - .text - -#define CALL_NEXT_PTR(gp_save_reg, arg0, arg1) \ - ld8 r2 = [arg0], 8;; /* read the next function pointer */ \ - ld8 r3 = [r2], 8;; /* read the function's entry-point */ \ - ld8 r2 = [r2];; /* read the function's gp */ \ - mov b6 = r3; \ - mov gp_save_reg = gp; \ - mov out0 = arg0; \ - mov out1 = arg1; \ - mov gp = r2; \ - br.call.sptk.many rp = b6;; \ - mov gp = gp_save_reg - -#define CALL_NEXT(gp_save_reg) CALL_NEXT_PTR(gp_save_reg, in0, in1) - -#define LOAD_VAL(reg) \ - ld8 reg = [in1], 8;; \ - tbit.nz p15, p0 = reg, 0;; \ -(p15) ld8.s reg = [r0] - - - .global flushrs - .proc flushrs -flushrs: - flushrs;; - br.ret.sptk.many rp - .endp flushrs - - /* Save r4-r7 into stacked registers, load them up with the - values passed via the pointer in in1 and then call the - function passed via the pointer in in0. */ - - .global save_static_to_stacked - .proc save_static_to_stacked -save_static_to_stacked: - .prologue - .regstk 2, 7, 2, 0 - .save ar.pfs, loc0 - alloc loc0 = ar.pfs, 2, 7, 2, 0 - .save rp, loc1 - mov loc1 = rp - .spillreg r4, loc2 - mov loc2 = r4 - .spillreg r5, loc3 - mov loc3 = r5 - .spillreg r6, loc4 - mov loc4 = r6 - .spillreg r7, loc5 - mov loc5 = r7 - .body - LOAD_VAL(r4) - LOAD_VAL(r5) - LOAD_VAL(r6) - LOAD_VAL(r7) - CALL_NEXT(loc6) - - mov r4 = loc2 - mov r5 = loc3 - mov r6 = loc4 - mov r7 = loc5 - - mov ar.pfs = loc0 - mov rp = loc1 - br.ret.sptk.many rp - .endp save_static_to_stacked - - /* Save f2 to the memory stack, save r4 to f2, then load - r4 with the value passed via in1 and call the function - passed via in0. */ - - .global save_static_to_fr - .proc save_static_to_fr -save_static_to_fr: - .prologue - .regstk 2, 3, 2, 0 - .save ar.pfs, loc0 - alloc loc0 = ar.pfs, 2, 3, 2, 0 - .save rp, loc1 - mov loc1 = rp - .fframe 16 - .spillpsp f2, 0 - stf.spill [sp] = f2, -16 - .spillreg r4, f2 - setf.sig f2 = r4 - - .body - - ld8 r4 = [in1], 8;; - tbit.nz p6, p0 = r4, 0;; -(p6) ld8.s r4 = [r0] - - CALL_NEXT(loc2) - - getf.sig r4 = f2 // restore r4 - .restore sp - add sp = 16, sp;; - ldf.fill f2 = [sp] // restore r2 - - mov ar.pfs = loc0 - mov rp = loc1 - br.ret.sptk.many rp - .endp save_static_to_fr - - /* If r4 is not a NaT, save b3 to a stacked register and - then save r4 in b3. The non-NaTness of r4 is saved in - p1. */ - - .global save_static_to_br - .proc save_static_to_br -save_static_to_br: - .prologue - .regstk 2, 6, 2, 0 - .save ar.pfs, loc0 - alloc loc0 = ar.pfs, 2, 6, 2, 0 - .save rp, loc1 - mov loc1 = rp - - .save pr, loc2 - mov loc2 = pr // save predicates - - .spillreg b3, loc3 - mov loc3 = b3 - - tnat.z p1, p2 = r4;; - .spillreg.p p1, r4, b3 -(p1) mov b3 = r4 - .spillreg.p p2, r4, loc4 -(p2) mov loc4 = r4 - - .body - - LOAD_VAL(r4) - CALL_NEXT(loc5) - - .pred.rel.mutex p1, p2 -(p1) mov r4 = b3 // restore r4 -(p2) mov r4 = loc4 - - mov ar.pfs = loc0 - mov rp = loc1 - mov pr = loc2, -1 - mov b3 = loc3 // restore b3 - br.ret.sptk.many rp - .endp save_static_to_br - - /* Spill r4 into memory and then save r5 in r4. */ - - .global save_static_to_mem - .proc save_static_to_mem -save_static_to_mem: - .prologue - .regstk 2, 4, 2, 0 - .save ar.pfs, loc0 - alloc loc0 = ar.pfs, 2, 4, 2, 0 - .save rp, loc1 - mov loc1 = rp - .save ar.unat, loc2 - mov loc2 = ar.unat - - .fframe 16 - .spillpsp r4, 0 - st8.spill [sp] = r4, -16 - - .spillreg r5, r4 - mov r4 = r5 - - .body - - LOAD_VAL(r5) - CALL_NEXT(loc3) - - mov r5 = r4 // restore r5 - .restore sp - add sp = 16, sp;; - ld8.fill r4 = [sp] // restore r4 - - mov ar.pfs = loc0 - mov rp = loc1 - mov ar.unat = loc2 // restore ar.unat - br.ret.sptk.many rp - .endp save_static_to_mem - - /* Spill r6 into memory and save primary ar.unat in a register. */ - - .global save_static_to_mem2 - .proc save_static_to_mem2 -save_static_to_mem2: - .prologue - .regstk 2, 5, 2, 0 - .save ar.pfs, loc0 - alloc loc0 = ar.pfs, 2, 5, 2, 0 - .save rp, loc1 - mov loc1 = rp - .save ar.unat, loc2 - mov loc2 = ar.unat - - .fframe 16 - .spillpsp r6, 0 - st8.spill [sp] = r6, -16;; - .save @priunat, loc3 - mov loc3 = ar.unat - mov ar.unat = 0 // trash ar.unat - - .body - - LOAD_VAL(r6) - CALL_NEXT(loc4) - - mov ar.unat = loc3 // restore primary UNaT - .restore sp - add sp = 16, sp;; - ld8.fill r6 = [sp] // restore r6 - - mov ar.pfs = loc0 - mov rp = loc1 - mov ar.unat = loc2 // restore ar.unat - br.ret.sptk.many rp - .endp save_static_to_mem2 - - /* Spill r6 into memory and save primary ar.unat in memory. */ - - .global save_static_to_mem3 - .proc save_static_to_mem3 -save_static_to_mem3: - .prologue - .regstk 2, 5, 2, 0 - .save ar.pfs, loc0 - alloc loc0 = ar.pfs, 2, 5, 2, 0 - .save rp, loc1 - mov loc1 = rp - .save ar.unat, loc2 - mov loc2 = ar.unat - - add r2 = 8, sp - .fframe 16 - .spillpsp r6, 0 - st8.spill [sp] = r6, -16;; - mov r3 = ar.unat;; - .savepsp @priunat, -8 - st8 [r2] = r3 - mov ar.unat = 0 // trash ar.unat - - .body - - LOAD_VAL(r6) - CALL_NEXT(loc4) - - add r2 = 24, sp;; - ld8 r3 = [r2];; - mov ar.unat = r3 // restore primary UNaT - .restore sp - add sp = 16, sp;; - ld8.fill r6 = [sp] // restore r6 - - mov ar.pfs = loc0 - mov rp = loc1 - mov ar.unat = loc2 // restore ar.unat - br.ret.sptk.many rp - .endp save_static_to_mem3 - - /* Spill r6 into memory and save primary ar.unat in register, - then in memory. */ - - .global save_static_to_mem4 - .proc save_static_to_mem4 -save_static_to_mem4: - .prologue - .regstk 2, 5, 2, 0 - .save ar.pfs, loc0 - alloc loc0 = ar.pfs, 2, 5, 2, 0 - .save rp, loc1 - mov loc1 = rp - .save ar.unat, loc2 - mov loc2 = ar.unat - - add r2 = 8, sp - .fframe 16 - .spillpsp r6, 0 - st8.spill [sp] = r6, -16;; - .save @priunat, r3 - mov r3 = ar.unat;; - mov ar.unat = 0 // trash ar.unat - .savepsp @priunat, -8 - st8 [r2] = r3 - mov r3 = r0 // trash register pri UNaT location - .body - - LOAD_VAL(r6) - CALL_NEXT(loc4) - - add r2 = 24, sp;; - ld8 r3 = [r2];; - mov ar.unat = r3 // restore primary UNaT - .restore sp - add sp = 16, sp;; - ld8.fill r6 = [sp] // restore r6 - - mov ar.pfs = loc0 - mov rp = loc1 - mov ar.unat = loc2 // restore ar.unat - br.ret.sptk.many rp - .endp save_static_to_mem4 - - /* Spill r6 into memory and save primary ar.unat in register, - then in memory. */ - - .global save_static_to_mem5 - .proc save_static_to_mem5 -save_static_to_mem5: - .prologue - .regstk 2, 5, 2, 0 - .save ar.pfs, loc0 - alloc loc0 = ar.pfs, 2, 5, 2, 0 - .save rp, loc1 - mov loc1 = rp - .save ar.unat, loc2 - mov loc2 = ar.unat - - add r2 = 8, sp - .fframe 16 - .spillpsp r6, 0 - st8.spill [sp] = r6, -16;; - mov r3 = ar.unat;; - mov ar.unat = 0 // trash ar.unat - .savepsp @priunat, -8 - st8 [r2] = r3 - .save @priunat, loc3 - mov loc3 = r3 - st8 [r2] = r0 // trash memory pri UNaT location - .body - - LOAD_VAL(r6) - CALL_NEXT(loc4) - - add r2 = 24, sp;; - ld8 r3 = [r2];; - mov ar.unat = loc3 // restore primary UNaT - .restore sp - add sp = 16, sp;; - ld8.fill r6 = [sp] // restore r6 - - mov ar.pfs = loc0 - mov rp = loc1 - mov ar.unat = loc2 // restore ar.unat - br.ret.sptk.many rp - .endp save_static_to_mem5 - - /* Save r4-r7 to various scratch registers, then trigger - a segfault. */ - - .global save_static_to_scratch - .proc save_static_to_scratch -save_static_to_scratch: - .prologue - - .spillreg r4, r16 - mov r16 = r4 // save r4 in r16 - tnat.nz p6, p7 = r5;; - .spillreg.p p6, r5, f31 -(p6) setf.sig f31 = r5 // save r5 in f31 if it's a NaT - .spillreg.p p7, r5, b6 -(p7) mov b6 = r5 // in b6 if it not - .spillreg r6, f32 - setf.sig f32 = r6 // save r6 in f32 (fph partition) - .spillsp r7, 0 - st8.spill [sp] = r7 // save r7 in the scratch stack space - .spillreg f4, f6 - mov f6 = f4;; - .body - - ld8 r2 = [in1] - ;; - mov ar.ec = r2 - - LOAD_VAL(r4) - LOAD_VAL(r5) - LOAD_VAL(r6) - LOAD_VAL(r7) - setf.sig f4 = r4 - - /* Now force a SIGSEGV. Make sure the ld8 is at the beginning of a - bundle, so the signal-handler can skip over it simply by - incrementing the IP. */ - { - .mmi - ld8 r2 = [r0] - nop.m 0 - nop.i 0 ;; - } - - mov f4 = f6 - mov r4 = r16 - .pred.rel.mutex p6, p7 -(p6) getf.sig r5 = f31 -(p7) mov r5 = b6 - getf.sig r6 = f32 - ld8.fill r7 = [sp] - - br.ret.sptk.many rp - .endp save_static_to_scratch - - /* Rotate registers a bit in a vain attempt to sow some confusion. - Care must be taken not to write any rotating general register - after rotation, because we keep the preserved state - there... */ - - .global rotate_regs - .proc rotate_regs -rotate_regs: - .prologue - .regstk 2, 14, 2, 16 - .save ar.pfs, loc0 - alloc loc0 = ar.pfs, 2, 14, 2, 16 - .save rp, loc1 - mov loc1 = rp - .save pr, loc2 - mov loc2 = pr - .save ar.lc, loc3 - mov loc3 = ar.lc - .spillreg r4, loc4 - mov loc4 = r4 - - ld8 r2 = [in1], 8;; - mov pr = r2, -1 - - ld8 r2 = [in1], 8;; - mov r8 = in0 - mov r9 = in1 - and r2 = 127, r2;; - mov ar.ec = 0 - mov ar.lc = r2;; - - // use p6 to preserve p63 as it gets rotated into p16: -(p16) cmp.eq.unc p6,p0 = r0,r0;; -1: -(p6) cmp.eq.unc p16,p0 = r0,r0 -(p63) cmp.eq.unc p6,p0 = r0,r0 - br.ctop.dptk.few 1b;; - -(p6) cmp.eq.unc p63,p0 = r0,r0 - - CALL_NEXT_PTR(r4, r8, r9) - - clrrrb - - mov ar.pfs = loc0 - mov rp = loc1 - mov pr = loc2, -1 - mov ar.lc = loc3 - mov r4 = loc4 - br.ret.sptk.many rp - - .endp rotate_regs - - .global save_pr - .proc save_pr -save_pr: - .prologue - .regstk 2, 4, 2, 0 - .save ar.pfs, loc0 - alloc loc0 = ar.pfs, 2, 4, 2, 0 - .save rp, loc1 - mov loc1 = rp - .save pr, loc2 - mov loc2 = pr - - ld8 r2 = [in1], 8;; - mov pr = r2, -1 - - CALL_NEXT(loc3) - - mov ar.pfs = loc0 - mov rp = loc1 - mov pr = loc2, -1 - br.ret.sptk.many rp - - .endp save_pr - -#ifdef __linux__ - /* We do not need executable stack. */ - .section .note.GNU-stack,"",@progbits -#endif diff --git a/src/pal/src/libunwind/tests/ia64-test-rbs-asm.S b/src/pal/src/libunwind/tests/ia64-test-rbs-asm.S deleted file mode 100644 index 9a6d33fb1..000000000 --- a/src/pal/src/libunwind/tests/ia64-test-rbs-asm.S +++ /dev/null @@ -1,275 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2003 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include "ia64-test-rbs.h" - - .common stackmem, NSTACKS*STACK_SIZE, 16 - - .text - -#define SAVED_SP_OFF 0 -#define SAVED_RP_OFF 8 -#define SAVED_PFS_OFF 16 -#define SAVED_RNAT_OFF 24 -#define SAVED_BSP_OFF 32 -#define SAVED_BSPSTORE_OFF 40 -#define FRAME_SIZE 48 - -#define SPILL(n) \ - /* int rbs_spill_#n(long iteration, int (*next_func[])()) */ \ - .globl rbs_spill_##n; \ - .proc rbs_spill_##n; \ -rbs_spill_##n: \ - .prologue; \ - alloc r18 = ar.pfs, 2, (n)-2, 2, 0;/* read ar.pfs */ \ - /* first, calculate address of new stack: */ \ - addl r2 = @ltoff(stackmem), gp; \ - add r8 = 1, in0; \ - ;; \ - ld8 r2 = [r2]; /* r2 = &stackmem */ \ - shl r3 = in0, STACK_SIZE_SHIFT; \ - shladd r8 = r8, 3, in1; /* r8 = &next_func[iteration+1] */ \ - ;; \ - ld8 r8 = [r8]; /* r8 = next_func[iteration+1] */ \ - add r2 = r2, r3; /* r2 = stackmem[iteration] */ \ - ;; \ - ld8 r9 = [r8], 8;; /* r9 = target's entry-point */ \ - ld8 gp = [r8]; /* r22 = target's gp */ \ - addl r3 = STACK_SIZE-FRAME_SIZE, r2; /* r3 = &stackframe */ \ - ;; \ - mov b6 = r9; \ - st8 [r3] = sp; \ - .vframesp SAVED_SP_OFF+16; \ - adds sp = -16, r3; /* switch the memory stack */ \ - ;; \ - adds r3 = (SAVED_RP_OFF - SAVED_SP_OFF), r3; \ - mov r16 = rp; \ - ;; \ - .savesp rp, SAVED_RP_OFF+16; \ - st8 [r3] = r16, (SAVED_PFS_OFF - SAVED_RP_OFF); \ - ;; \ - .savesp ar.pfs, SAVED_PFS_OFF+16; \ - st8 [r3] = r18, (SAVED_BSP_OFF - SAVED_PFS_OFF); \ - mov r16 = ar.bsp; \ - mov r17 = ar.bspstore; \ - mov r18 = ar.rnat; \ - ;; \ - .savesp ar.bsp, SAVED_BSP_OFF+16; \ - st8 [r3] = r16, (SAVED_BSPSTORE_OFF - SAVED_BSP_OFF); \ - ;; \ - .savesp ar.bspstore, SAVED_BSPSTORE_OFF+16; \ - st8 [r3] = r17, (SAVED_RNAT_OFF - SAVED_BSPSTORE_OFF); \ - mov out1 = in1; \ - ;; \ - .savesp ar.rnat, SAVED_RNAT_OFF+16; \ - st8 [r3] = r18; \ - .body; \ - mov ar.bspstore = r2; /* switch the backing store */ \ - adds out0 = 1, in0; \ - ;; \ - br.call.sptk.many rp = b6; \ -1: /* switch back to stack: */ \ - adds r3 = SAVED_SP_OFF+16, sp; \ - cmp.ge p8, p0 = r8, r0; \ - ;; \ -(p8) add r8 = 1, r8; \ - ld8 r16 = [r3], (SAVED_RP_OFF-SAVED_SP_OFF);; /* saved sp */ \ - ld8 r17 = [r3], (SAVED_PFS_OFF-SAVED_RP_OFF);; /* saved rp */ \ - ld8 r18 = [r3], (SAVED_RNAT_OFF-SAVED_PFS_OFF);;/* saved pfs */ \ - ld8 r19 = [r3], (SAVED_BSP_OFF-SAVED_RNAT_OFF);;/* saved rnat */ \ - ld8 r20 = [r3], (SAVED_BSPSTORE_OFF-SAVED_BSP_OFF);;/* saved bsp */ \ - ld8 r21 = [r3];; /* saved bspstore */ \ - mov rp = r17; \ - mov ar.pfs = r18; \ - shl r3 = in0, STACK_SIZE_SHIFT; \ - addl r2 = @ltoff(stackmem), gp;; \ - ld8 r2 = [r2];; /* r2 = &stackmem */ \ - add r2 = r2, r3; /* r2 = stackmem[iteration] */ \ - mov r3 = ar.bsp;; \ - sub r2 = r3, r2;; /* r2 = dirty_size */ \ - shl r2 = r2, 16;; \ - mov ar.rsc = r2;; \ - alloc r3 = ar.pfs, 0, 0, 0, 0;; \ - loadrs;; \ - mov ar.bspstore = r21;; /* this also restores ar.bsp */ \ - mov ar.rnat = r19; \ - .restore sp; \ - mov sp = r16; \ - br.ret.sptk.many rp; \ - .endp rbs_spill_##n - - SPILL(2); SPILL(3) - SPILL(4); SPILL(5); SPILL(6); SPILL(7) - SPILL(8); SPILL(9); SPILL(10); SPILL(11) - SPILL(12); SPILL(13); SPILL(14); SPILL(15) - SPILL(16); SPILL(17); SPILL(18); SPILL(19) - SPILL(20); SPILL(21); SPILL(22); SPILL(23) - SPILL(24); SPILL(25); SPILL(26); SPILL(27) - SPILL(28); SPILL(29); SPILL(30); SPILL(31) - SPILL(32); SPILL(33); SPILL(34); SPILL(35) - SPILL(36); SPILL(37); SPILL(38); SPILL(39) - SPILL(40); SPILL(41); SPILL(42); SPILL(43) - SPILL(44); SPILL(45); SPILL(46); SPILL(47) - SPILL(48); SPILL(49); SPILL(50); SPILL(51) - SPILL(52); SPILL(53); SPILL(54); SPILL(55) - SPILL(56); SPILL(57); SPILL(58); SPILL(59) - SPILL(60); SPILL(61); SPILL(62); SPILL(63) - SPILL(64); SPILL(65); SPILL(66); SPILL(67) - SPILL(68); SPILL(69); SPILL(70); SPILL(71) - SPILL(72); SPILL(73); SPILL(74); SPILL(75) - SPILL(76); SPILL(77); SPILL(78); SPILL(79) - SPILL(80); SPILL(81); SPILL(82); SPILL(83) - SPILL(84); SPILL(85); SPILL(86); SPILL(87) - SPILL(88); SPILL(89); SPILL(90); SPILL(91) - SPILL(92); SPILL(93); SPILL(94) - -#define LD_LOC(n) \ - ld4 loc##n = [in1], 4;; \ - cmp.eq p8, p9 = r0, loc##n;; \ -(p9) or loc##n = loc##n, r8; \ -(p8) ld4.s loc##n = [r0] - -#define CK_LOC(n) \ - ld4 r16 = [in1], 4;; \ - cmp.eq p8, p9 = r0, r16; \ - or r16 = r16, r9;; \ -(p8) tnat.z p10, p0 = loc##n; \ -(p9) cmp.ne p10, p0 = r16, loc##n; \ - ;; \ -(p10) mov r8 = -n; \ -(p10) br.cond.spnt.many .fail - - /* int loadup(long iteration, int *values, next_func[]) */ - - .global loadup - .proc loadup -loadup: - .prologue - .save ar.pfs, r36 - alloc loc1 = ar.pfs, 3, 90, 3, 0 - .save rp, loc0 - mov loc0 = rp - .body - cmp.eq p6, p7 = 1, in0 - ;; - mov ar.rsc = 0 // put RSE into enforced lazy mode -(p6) mov out1 = in2 -(p7) mov out2 = in2 - -(p6) ld8 r17 = [in2] // get address of function descriptor -(p7) add out0 = -1, in0 -(p7) mov out1 = in1 - - ;; -(p6) ld8 r16 = [r17], 8 // load entry point - shl r8 = in0, 32 // store iteration # in top 32 bits - mov r18 = in1 - ;; -(p6) ld8 r1 = [r17] // load gp -(p6) mov b6 = r16 - -(p6) mov out0 = 0 - ;; - LD_LOC( 2); LD_LOC( 3) - LD_LOC( 4); LD_LOC( 5); LD_LOC( 6); LD_LOC( 7) - LD_LOC( 8); LD_LOC( 9); LD_LOC(10); LD_LOC(11) - LD_LOC(12); LD_LOC(13); LD_LOC(14); LD_LOC(15) - LD_LOC(16); LD_LOC(17); LD_LOC(18); LD_LOC(19) - LD_LOC(20); LD_LOC(21); LD_LOC(22); LD_LOC(23) - LD_LOC(24); LD_LOC(25); LD_LOC(26); LD_LOC(27) - LD_LOC(28); LD_LOC(29); LD_LOC(30); LD_LOC(31) - LD_LOC(32); LD_LOC(33); LD_LOC(34); LD_LOC(35) - LD_LOC(36); LD_LOC(37); LD_LOC(38); LD_LOC(39) - LD_LOC(40); LD_LOC(41); LD_LOC(42); LD_LOC(43) - LD_LOC(44); LD_LOC(45); LD_LOC(46); LD_LOC(47) - LD_LOC(48); LD_LOC(49); LD_LOC(50); LD_LOC(51) - LD_LOC(52); LD_LOC(53); LD_LOC(54); LD_LOC(55) - LD_LOC(56); LD_LOC(57); LD_LOC(58); LD_LOC(59) - LD_LOC(60); LD_LOC(61); LD_LOC(62); LD_LOC(63) - LD_LOC(64); LD_LOC(65); LD_LOC(66); LD_LOC(67) - LD_LOC(68); LD_LOC(69); LD_LOC(70); LD_LOC(71) - LD_LOC(72); LD_LOC(73); LD_LOC(74); LD_LOC(75) - LD_LOC(76); LD_LOC(77); LD_LOC(78); LD_LOC(79) - LD_LOC(80); LD_LOC(81); LD_LOC(82); LD_LOC(83) - LD_LOC(84); LD_LOC(85); LD_LOC(86); LD_LOC(87) - LD_LOC(88); LD_LOC(89) - ;; -{ .mbb - mov in1 = r18 -(p6) br.call.sptk.many rp = b6 -(p7) br.call.sptk.many rp = loadup -} - cmp.lt p8, p9 = r8, r0 - shl r9 = in0, 32 // store iteration # in top 32 bits -(p8) br.cond.spnt.few .fail - ;; - add r8 = 1, r8 - CK_LOC( 2); CK_LOC( 3) - CK_LOC( 4); CK_LOC( 5); CK_LOC( 6); CK_LOC( 7) - CK_LOC( 8); CK_LOC( 9); CK_LOC(10); CK_LOC(11) - CK_LOC(12); CK_LOC(13); CK_LOC(14); CK_LOC(15) - CK_LOC(16); CK_LOC(17); CK_LOC(18); CK_LOC(19) - CK_LOC(20); CK_LOC(21); CK_LOC(22); CK_LOC(23) - CK_LOC(24); CK_LOC(25); CK_LOC(26); CK_LOC(27) - CK_LOC(28); CK_LOC(29); CK_LOC(30); CK_LOC(31) - CK_LOC(32); CK_LOC(33); CK_LOC(34); CK_LOC(35) - CK_LOC(36); CK_LOC(37); CK_LOC(38); CK_LOC(39) - CK_LOC(40); CK_LOC(41); CK_LOC(42); CK_LOC(43) - CK_LOC(44); CK_LOC(45); CK_LOC(46); CK_LOC(47) - CK_LOC(48); CK_LOC(49); CK_LOC(50); CK_LOC(51) - CK_LOC(52); CK_LOC(53); CK_LOC(54); CK_LOC(55) - CK_LOC(56); CK_LOC(57); CK_LOC(58); CK_LOC(59) - CK_LOC(60); CK_LOC(61); CK_LOC(62); CK_LOC(63) - CK_LOC(64); CK_LOC(65); CK_LOC(66); CK_LOC(67) - CK_LOC(68); CK_LOC(69); CK_LOC(70); CK_LOC(71) - CK_LOC(72); CK_LOC(73); CK_LOC(74); CK_LOC(75) - CK_LOC(76); CK_LOC(77); CK_LOC(78); CK_LOC(79) - CK_LOC(80); CK_LOC(81); CK_LOC(82); CK_LOC(83) - CK_LOC(84); CK_LOC(85); CK_LOC(86); CK_LOC(87) - CK_LOC(88); CK_LOC(89) -.fail: - mov rp = loc0 - mov ar.pfs = loc1 - br.ret.sptk.many rp - .endp loadup - - .global resumption_point_label - .proc resumption_point -resumption_point: -resumption_point_label: - .prologue - .save rp, r16 - .save ar.pfs, r0 - .body - mov r8 = r15 - mov b6 = r16 - ;; - br.cond.sptk.many b6 - .endp resumption_point - -#ifdef __linux__ - /* We do not need executable stack. */ - .section .note.GNU-stack,"",@progbits -#endif diff --git a/src/pal/src/libunwind/tests/ia64-test-rbs.h b/src/pal/src/libunwind/tests/ia64-test-rbs.h deleted file mode 100644 index 3315ad638..000000000 --- a/src/pal/src/libunwind/tests/ia64-test-rbs.h +++ /dev/null @@ -1,3 +0,0 @@ -#define NSTACKS 128 -#define STACK_SIZE_SHIFT 17 -#define STACK_SIZE (1 << STACK_SIZE_SHIFT) diff --git a/src/pal/src/libunwind/tests/ia64-test-readonly-asm.S b/src/pal/src/libunwind/tests/ia64-test-readonly-asm.S deleted file mode 100644 index acd3ada2c..000000000 --- a/src/pal/src/libunwind/tests/ia64-test-readonly-asm.S +++ /dev/null @@ -1,55 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - - .text - - .global test_func - .proc test_func -test_func: - .prologue - .regstk 1, 3, 0, 0 - .save ar.pfs, loc0 - alloc loc0 = ar.pfs, 1, 3, 0, 0 - mov loc1 = rp - .save rp, r0 - .save ar.lc, r0 - .body - mov loc2 = gp - ld8 r2 = [in0], 8;; - ld8 r1 = [in0];; - mov b6 = r2 - br.call.sptk.many rp = b6 - - mov gp = loc2 - mov rp = loc1 - mov ar.pfs = loc0 - br.ret.sptk.many rp - - .endp test_func - -#ifdef __linux__ - /* We do not need executable stack. */ - .section .note.GNU-stack,"",@progbits -#endif diff --git a/src/pal/src/libunwind/tests/ia64-test-setjmp.c b/src/pal/src/libunwind/tests/ia64-test-setjmp.c deleted file mode 100644 index 50eaa01bc..000000000 --- a/src/pal/src/libunwind/tests/ia64-test-setjmp.c +++ /dev/null @@ -1,155 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -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. */ - -/* Test to verify that we can siglongjmp() into a frame whose register - window is not backed by valid memory. */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#ifdef HAVE_IA64INTRIN_H -# include -#endif - -static sigjmp_buf env; -static int return_level; -static uintptr_t return_bsp; -static int verbose; - -uintptr_t -get_bsp (void) -{ -#ifdef __INTEL_COMPILER - return __getReg (_IA64_REG_AR_BSP); -#else - return (uintptr_t) __builtin_ia64_bsp (); -#endif -} - -static void -sighandler (int signal, void *siginfo, void *sigcontext) -{ - ucontext_t *uc = sigcontext; - int local = 0; - - if (verbose) - printf ("got signal, stack at %p, saved bsp=0x%lx\n", - &local, uc->uc_mcontext.sc_ar_bsp); - siglongjmp (env, 1); -} - -/* Direct call of doit () at the end of doit () would get optimized by GCC to - a branch. */ -static void doit (int n); -typedef void (*doit_type) (int); -static volatile doit_type doit_pointer = doit; - -static void -doit (int n) -{ - uintptr_t guard_page_addr, bsp = get_bsp (); - void *ret; - - if (n == 0) - { - size_t page_size = getpagesize (); - - guard_page_addr = (bsp + page_size - 1) & -page_size; - if (verbose) - printf ("guard_page_addr = 0x%lx\n", (unsigned long) guard_page_addr); - ret = mmap ((void *) guard_page_addr, page_size, PROT_NONE, - MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); - if (ret != (void *) guard_page_addr) - { - if (ret == MAP_FAILED) - perror ("mmap"); - else - fprintf (stderr, "mmap() returned %p, expected 0x%lx\n", - ret, guard_page_addr); - exit (EXIT_FAILURE); - } - } - - if (sigsetjmp (env, 1)) - { - return_level = n; - return_bsp = bsp; - } - else - (*doit_pointer) (n + 1); -} - -int -main (int argc, char **argv) -{ - struct sigaction sa; - stack_t ss; - - if (argc > 1) - verbose = 1; - - ss.ss_sp = malloc (2 * SIGSTKSZ); - if (ss.ss_sp == NULL) - { - puts ("failed to allocate alternate stack"); - return EXIT_FAILURE; - } - ss.ss_flags = 0; - ss.ss_size = 2 * SIGSTKSZ; - if (sigaltstack (&ss, NULL) < 0) - { - printf ("sigaltstack failed: %s\n", strerror (errno)); - return EXIT_FAILURE; - } - - sa.sa_handler = (void (*) (int)) sighandler; - sigemptyset (&sa.sa_mask); - sa.sa_flags = SA_SIGINFO | SA_ONSTACK; - if (sigaction (SIGSEGV, &sa, NULL) < 0) - { - printf ("sigaction failed: %s\n", strerror (errno)); - exit (1); - } - - doit (0); - - if (verbose) - { - printf ("sigsetjmp returned at level %d bsp=0x%lx\n", - return_level, return_bsp); - puts ("Test succeeded!"); - } - return EXIT_SUCCESS; -} diff --git a/src/pal/src/libunwind/tests/ia64-test-sig.c b/src/pal/src/libunwind/tests/ia64-test-sig.c deleted file mode 100644 index 473efe91d..000000000 --- a/src/pal/src/libunwind/tests/ia64-test-sig.c +++ /dev/null @@ -1,102 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2001-2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -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. */ - -/* This test uses the unwind interface to modify the IP in an ancestor - frame while still returning to the parent frame. */ - -#include -#include -#include - -#include - -#define panic(args...) \ - { fprintf (stderr, args); exit (-1); } - -int verbose; - -static void -sighandler (int signal) -{ - unw_cursor_t cursor, cursor2; - unw_word_t ip; - unw_context_t uc; - - if (verbose) - printf ("caught signal %d\n", signal); - - unw_getcontext (&uc); - if (unw_init_local (&cursor, &uc) < 0) - panic ("unw_init() failed!\n"); - - /* get cursor for caller of sighandler: */ - if (unw_step (&cursor) < 0) - panic ("unw_step() failed!\n"); - - cursor2 = cursor; - while (!unw_is_signal_frame (&cursor2)) - if (unw_step (&cursor2) < 0) - panic ("failed to find signal frame!\n"); - - if (unw_step (&cursor2) < 0) - panic ("unw_step() failed!\n"); - - if (unw_get_reg (&cursor2, UNW_REG_IP, &ip) < 0) - panic ("failed to get IP!\n"); - - /* skip faulting instruction (doesn't handle MLX template) */ - ++ip; - if ((ip & 0x3) == 0x3) - ip += 13; - - if (unw_set_reg (&cursor2, UNW_REG_IP, ip) < 0) - panic ("failed to set IP!\n"); - - unw_resume (&cursor); /* update context & return to caller of sighandler() */ - - panic ("unexpected return from unw_resume()!\n"); -} - -static void -doit (volatile char *p) -{ - int ch; - - ch = *p; /* trigger SIGSEGV */ - - if (verbose) - printf ("doit: finishing execution!\n"); -} - -int -main (int argc, char **argv) -{ - if (argc > 1) - verbose = 1; - - signal (SIGSEGV, sighandler); - doit (0); - if (verbose) - printf ("SUCCESS\n"); - return 0; -} diff --git a/src/pal/src/libunwind/tests/ia64-test-stack-asm.S b/src/pal/src/libunwind/tests/ia64-test-stack-asm.S deleted file mode 100644 index 0aea33a44..000000000 --- a/src/pal/src/libunwind/tests/ia64-test-stack-asm.S +++ /dev/null @@ -1,183 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2003 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include "ia64-test-stack.h" - - .common stackmem, NSTACKS*STACK_SIZE, 16 - - .global do_unwind_tests - - .text - -#define SAVED_SP_OFF 0 -#define SAVED_RP_OFF 8 -#define SAVED_PFS_OFF 16 -#define SAVED_RNAT_OFF 24 -#define SAVED_BSP_OFF 32 -#define SAVED_BSPSTORE_OFF 40 -#define FRAME_SIZE 48 - - .proc stack_it -stack_it: - .prologue - alloc r18 = ar.pfs, 0, 0, 0, 0 // read ar.pfs - // first, calculate address of new stack: - addl r2 = @ltoff(stackmem), gp - shl r3 = r8, STACK_SIZE_SHIFT - ;; - ld8 r2 = [r2] // r2 = &stackmem - ;; - add r2 = r2, r3 // r2 = stackmem[iteration] - ;; - addl r3 = STACK_SIZE-FRAME_SIZE, r2 // r3 = &stackframe - ;; - st8 [r3] = sp - .vframesp SAVED_SP_OFF+16 - adds sp = -16, r3 // switch the memory stack - ;; - adds r3 = (SAVED_RP_OFF - SAVED_SP_OFF), r3 - mov r16 = rp - ;; - .savesp rp, SAVED_RP_OFF+16 - st8 [r3] = r16, (SAVED_PFS_OFF - SAVED_RP_OFF) - ;; - .savesp ar.pfs, SAVED_PFS_OFF+16 - st8 [r3] = r18, (SAVED_BSP_OFF - SAVED_PFS_OFF) - - mov r16 = ar.bsp - mov r17 = ar.bspstore - mov r18 = ar.rnat - ;; - .savesp ar.bsp, SAVED_BSP_OFF+16 - st8 [r3] = r16, (SAVED_BSPSTORE_OFF - SAVED_BSP_OFF) - ;; - .savesp ar.bspstore, SAVED_BSPSTORE_OFF+16 - st8 [r3] = r17, (SAVED_RNAT_OFF - SAVED_BSPSTORE_OFF) - ;; - .savesp ar.rnat, SAVED_RNAT_OFF+16 - st8 [r3] = r18 - ;; - mov ar.bspstore = r2 // switch the backing store - - .body - - // for even iterations, allocate a local variable: - tbit.nz p6, p0 = r8, 0 -(p6) br.cond.sptk.few .skip - ;; - alloc r2 = ar.pfs, 0, 1, 0, 0 - mov loc0 = r8 - ;; -.skip: cmp.ne p6, p7 = 0, r8 - ;; -{ .mbb -(p6) adds r8 = -1, r8 -(p6) br.call.sptk.many rp = stack_it // next iteration -(p7) br.call.sptk.many rp = do_unwind_tests // time for introspection... -} - // switch back to stack: - - adds r3 = SAVED_SP_OFF+16, sp - ;; - ld8 r16 = [r3], (SAVED_RP_OFF-SAVED_SP_OFF);; // saved sp - ld8 r17 = [r3], (SAVED_PFS_OFF-SAVED_RP_OFF);; // saved rp - ld8 r18 = [r3], (SAVED_RNAT_OFF-SAVED_PFS_OFF);; // saved pfs - ld8 r19 = [r3], (SAVED_BSP_OFF-SAVED_RNAT_OFF);; // saved rnat - ld8 r20 = [r3], (SAVED_BSPSTORE_OFF-SAVED_BSP_OFF);; // saved bsp - ld8 r21 = [r3];; // saved bspstore - - mov rp = r17 - mov ar.pfs = r18 - mov ar.bspstore = r21 // this also restores ar.bsp - ;; - mov ar.rnat = r19 - - .restore sp - mov sp = r16 - br.ret.sptk.many rp - .endp stack_it - - -#define SET_LOC(n) add loc##n = n, r8 -#define SET_NAT(n) ld8.s loc##n = [r0] - - .global touch_all - .proc touch_all -touch_all: - .prologue - .save ar.pfs, r34 - alloc loc1 = ar.pfs, 1, 94, 1, 0 - .save rp, loc0 - mov loc0 = rp - .body - - mov ar.rsc = 0 // put RSE into enforced lazy mode - shl r8 = in0, 32 // store iteration # in top 32 bits - add out0 = -1, in0 - cmp.eq p6, p7 = 1, in0 - ;; - SET_LOC( 2); SET_LOC( 3) - SET_LOC( 4); SET_LOC( 5); SET_LOC( 6); SET_LOC( 7) - SET_LOC( 8); SET_LOC( 9); SET_LOC(10); SET_LOC(11) - SET_LOC(12); SET_LOC(13); SET_LOC(14); SET_LOC(15) - SET_LOC(16); SET_LOC(17); SET_LOC(18); SET_LOC(19) - SET_LOC(20); SET_LOC(21); SET_LOC(22); SET_LOC(23) - SET_LOC(24); SET_LOC(25); SET_LOC(26); SET_LOC(27) - SET_LOC(28); SET_LOC(29); SET_LOC(30); SET_LOC(31) - SET_LOC(32); SET_LOC(33); SET_LOC(34); SET_LOC(35) - SET_LOC(36); SET_LOC(37); SET_LOC(38); SET_LOC(39) - SET_LOC(40); SET_LOC(41); SET_LOC(42); SET_LOC(43) - SET_LOC(44); SET_LOC(45); SET_LOC(46); SET_LOC(47) - SET_LOC(48); SET_LOC(49); SET_LOC(50); SET_LOC(51) - SET_LOC(52); SET_LOC(53); SET_LOC(54); SET_LOC(55) - SET_LOC(56); SET_LOC(57); SET_LOC(58); SET_LOC(59) - SET_LOC(60); SET_LOC(61); SET_LOC(62); SET_LOC(63) - SET_LOC(64); SET_LOC(65); SET_LOC(66); SET_LOC(67) - SET_LOC(68); SET_LOC(69); SET_LOC(70); SET_LOC(71) - SET_LOC(72); SET_LOC(73); SET_LOC(74); SET_LOC(75) - SET_LOC(76); SET_LOC(77); SET_LOC(78); SET_LOC(79) - SET_LOC(80); SET_LOC(81); SET_LOC(82); SET_LOC(83) - SET_LOC(84); SET_LOC(85); SET_LOC(86); SET_LOC(87) - SET_LOC(88); SET_LOC(89); SET_LOC(90); SET_LOC(91) - SET_LOC(92); SET_LOC(93) - ;; - SET_NAT(2); SET_NAT(31); SET_NAT(73); SET_NAT(93) - ;; -{ .mbb - mov r8=NSTACKS-1 -(p6) br.call.sptk.many rp = stack_it -(p7) br.call.sptk.many rp = touch_all -} - ;; - - mov rp = loc0 - mov ar.pfs = loc1 - br.ret.sptk.many rp - .endp touch_all - -#ifdef __linux__ - /* We do not need executable stack. */ - .section .note.GNU-stack,"",@progbits -#endif diff --git a/src/pal/src/libunwind/tests/ia64-test-stack.h b/src/pal/src/libunwind/tests/ia64-test-stack.h deleted file mode 100644 index 5665a79d9..000000000 --- a/src/pal/src/libunwind/tests/ia64-test-stack.h +++ /dev/null @@ -1,3 +0,0 @@ -#define NSTACKS 1024 -#define STACK_SIZE_SHIFT 17 -#define STACK_SIZE (1 << STACK_SIZE_SHIFT) diff --git a/src/pal/src/libunwind/tests/ident.c b/src/pal/src/libunwind/tests/ident.c deleted file mode 100644 index 9024e292f..000000000 --- a/src/pal/src/libunwind/tests/ident.c +++ /dev/null @@ -1,5 +0,0 @@ -long -f (long val) -{ - return val; -} diff --git a/src/pal/src/libunwind/tests/mapper.c b/src/pal/src/libunwind/tests/mapper.c deleted file mode 100644 index b47ae780f..000000000 --- a/src/pal/src/libunwind/tests/mapper.c +++ /dev/null @@ -1,78 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -/* This program creates lots of mappings such that on Linux the - reading of /proc/PID/maps gets very slow. With proper caching, - test-ptrace should still run at acceptable speed once - /proc/PID/maps has been scanned. If the program dies with a - SIGALRM, it means it was running unexpectedly slow. */ - -#include -#include -#include -#include - -#include - -#if !defined(MAP_ANONYMOUS) && defined(MAP_ANON) -# define MAP_ANONYMOUS MAP_ANON -#endif -#if !defined(MAP_NORESERVE) -# define MAP_NORESERVE 0 -#endif - -int -main (void) -{ - long n = 0; - - signal (SIGUSR1, SIG_IGN); - signal (SIGUSR2, SIG_IGN); - - printf ("Starting mmap test...\n"); - for (n = 0; n < 30000; ++n) - { - if (mmap (NULL, 1, (n & 1) ? PROT_READ : PROT_WRITE, - MAP_PRIVATE | MAP_ANONYMOUS -#ifdef MAP_NORESERVE - | MAP_NORESERVE -#endif - , - -1, 0) == MAP_FAILED) - { - printf ("Failed after %ld successful maps\n", n - 1); - exit (0); - } - } - - alarm (80); /* die if we don't finish in 80 seconds */ - - printf ("Turning on single-stepping...\n"); - kill (getpid (), SIGUSR1); /* tell test-ptrace to start single-stepping */ - printf ("Va bene?\n"); - kill (getpid (), SIGUSR2); /* tell test-ptrace to stop single-stepping */ - printf ("Turned single-stepping off...\n"); - return 0; -} diff --git a/src/pal/src/libunwind/tests/perf-startup b/src/pal/src/libunwind/tests/perf-startup deleted file mode 100644 index 1c24e9a9b..000000000 --- a/src/pal/src/libunwind/tests/perf-startup +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/sh -platform=$1 -LIBUNWIND=../src/.libs/libunwind.so -LIBUNWIND_PLAT=../src/.libs/libunwind-$platform.so -warmup=$(./forker 2000 /bin/true | cut -f1 -d' ') - -nsec1=$(./forker 2000 /bin/true | cut -f1 -d' ') -printf "\"/bin/true\"\t\t\t\t\t\t: $nsec1 nsec/execution\n" - -nsec2=$(LD_PRELOAD=$LIBUNWIND ./forker 2000 /bin/true | cut -f1 -d' ') -printf "\"LD_PRELOAD=$LIBUNWIND /bin/true\"\t: $nsec2 nsec/execution\n" - -nsec3=$(LD_PRELOAD=$LIBUNWIND_PLAT ./forker 2000 /bin/true | cut -f1 -d' ') -printf "\"LD_PRELOAD=$LIBUNWIND_PLAT /bin/true\"\t: $nsec3 nsec/execution\n" - -echo - -printf "Overhead of preloading $LIBUNWIND\t: $(($nsec2 - $nsec1)) nsec\n" -printf "Overhead of preloading $LIBUNWIND_PLAT\t: $(($nsec3 - $nsec1)) nsec\n" diff --git a/src/pal/src/libunwind/tests/ppc64-test-altivec-utils.c b/src/pal/src/libunwind/tests/ppc64-test-altivec-utils.c deleted file mode 100644 index bd67ff7d6..000000000 --- a/src/pal/src/libunwind/tests/ppc64-test-altivec-utils.c +++ /dev/null @@ -1,32 +0,0 @@ -#include -#include - -union si_overlay -{ - vector signed int v; - int ints[4]; -}; - -vector signed int -vec_init () -{ - vector signed int v; - static int count = 1; - - ((union si_overlay *) &v)->ints[0] = count++; - ((union si_overlay *) &v)->ints[1] = count++; - ((union si_overlay *) &v)->ints[2] = count++; - ((union si_overlay *) &v)->ints[3] = count++; - return v; -} - -void -vec_print (vector signed int v) -{ - printf ("%08x %08x %08x %08x", - ((union si_overlay *) &v)->ints[0], - ((union si_overlay *) &v)->ints[1], - ((union si_overlay *) &v)->ints[2], - ((union si_overlay *) &v)->ints[3]); -} - diff --git a/src/pal/src/libunwind/tests/ppc64-test-altivec.c b/src/pal/src/libunwind/tests/ppc64-test-altivec.c deleted file mode 100644 index a3e95eefb..000000000 --- a/src/pal/src/libunwind/tests/ppc64-test-altivec.c +++ /dev/null @@ -1,177 +0,0 @@ - - -#include -#include -#include -#include -#include -#include - -#include - -#define panic(args...) { fprintf (stderr, args); abort(); } - -extern vector signed int vec_init (); -extern void vec_print (vector signed int v); - -vector signed int vec_stack (int count); - -int -main () -{ - printf ("&vec_stack = %016lx\n", (unsigned long) vec_stack); - vec_stack (3); - return 0; -} - - -vector signed int -vec_stack (int count) -{ - register vector signed int v1; - register vector signed int v2; - register vector signed int v3; - register vector signed int v4; - register vector signed int v5; - register vector signed int v6; - register vector signed int v7; - register vector signed int v8; - register vector signed int v9; - - unw_fpreg_t vr; - - unw_cursor_t cursor; - unw_word_t ip, sp; - unw_context_t uc; - int ret; - int verbose = 1; - - /* if (count == 0) return vec_init(); */ - - if (count == 0) - { - unw_getcontext (&uc); - if (unw_init_local (&cursor, &uc) < 0) - { - panic ("unw_init_local failed!\n"); - } - else - { - do - { - if ((ret = unw_get_reg (&cursor, UNW_REG_IP, &ip)) < 0) - { - panic ("FAILURE: unw_get_reg returned %d for UNW_REG_IP\n", - ret); - } - if ((ret = unw_get_reg (&cursor, UNW_REG_SP, &sp)) < 0) - { - panic ("FAILURE: unw_get_reg returned %d for UNW_REG_SP\n", - ret); - } - if ((ret = unw_get_fpreg (&cursor, UNW_PPC64_V30, &vr)) < 0) - { - panic - ("FAILURE: unw_get_vreg returned %d for UNW_PPC64_V30\n", - ret); - } - - - if (verbose) - { - const char *regname = unw_regname (UNW_PPC64_V30); - char proc_name_buffer[256]; - unw_word_t offset; - unsigned int * vec_half1, * vec_half2; - vec_half1 = (unsigned int *)&vr; - vec_half2 = vec_half1 + 1; - printf ("ip = %016lx, sp=%016lx\n", (long) ip, (long) sp); - printf ("vr30 = %08x %08x %08x %08x\n", - (unsigned int) (*vec_half1 >> 16), - (unsigned int) (*vec_half1 & 0xffffffff), - (unsigned int) (*vec_half2 >> 16), - (unsigned int) (*vec_half2 & 0xffffffff)); - ret = - unw_get_proc_name (&cursor, proc_name_buffer, - sizeof (proc_name_buffer), &offset); - if (ret == 0) - { - printf ("proc name = %s, offset = %lx\n", - proc_name_buffer, offset); - } - else - { - panic ("unw_get_proc_name returned %d\n", ret); - } - printf ("unw_regname(UNW_PPC_V30) = %s\n\n", regname); - } - - ret = unw_step (&cursor); - if (ret < 0) - { - unw_get_reg (&cursor, UNW_REG_IP, &ip); - panic ("FAILURE: unw_step() returned %d for ip=%lx\n", ret, - (long) ip); - } - } - while (ret > 0); - } - } - - v1 = vec_init (); - v2 = vec_init (); - v3 = vec_init (); - v4 = vec_init (); - v5 = vec_init (); - v6 = vec_init (); - - /* make use of all of the registers in some calculation */ - v7 = - vec_nor (v1, vec_add (v2, vec_sub (v3, vec_and (v4, vec_or (v5, v6))))); - - /* - * "force" the registers to be non-volatile by making a call and also - * using the registers after the call. - */ - v8 = vec_stack (count - 1); - - /* - * Use the result from the previous call, plus all of the non-volatile - * registers in another calculation. - */ - v9 = - vec_nor (v1, - vec_add (v2, - vec_sub (v3, - vec_and (v4, vec_or (v5, vec_xor (v6, v8)))))); - - printf ("v1 - "); - vec_print (v1); - printf ("\n"); - printf ("v2 - "); - vec_print (v2); - printf ("\n"); - printf ("v3 - "); - vec_print (v3); - printf ("\n"); - printf ("v4 - "); - vec_print (v4); - printf ("\n"); - printf ("v5 - "); - vec_print (v5); - printf ("\n"); - printf ("v6 - "); - vec_print (v6); - printf ("\n"); - printf ("v7 - "); - vec_print (v7); - printf ("\n"); - printf ("v8 - "); - vec_print (v8); - printf ("\n"); - printf ("v9 - "); - vec_print (v9); - printf ("\n"); - - return v9; -} diff --git a/src/pal/src/libunwind/tests/run-check-namespace b/src/pal/src/libunwind/tests/run-check-namespace deleted file mode 100644 index d57c8642a..000000000 --- a/src/pal/src/libunwind/tests/run-check-namespace +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -chmod +x ./check-namespace.sh -./check-namespace.sh $* diff --git a/src/pal/src/libunwind/tests/run-coredump-unwind b/src/pal/src/libunwind/tests/run-coredump-unwind deleted file mode 100644 index 8d0774257..000000000 --- a/src/pal/src/libunwind/tests/run-coredump-unwind +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/sh - -# this function is slight modification of the one used in RPM -# found at https://bugzilla.redhat.com/show_bug.cgi?id=834073 -# written by Alexander Larsson -add_minidebug() -{ - debuginfo="$1" ## we don't have separate debuginfo file - binary="$1" - - dynsyms=`mktemp` - funcsyms=`mktemp` - keep_symbols=`mktemp` - mini_debuginfo=`mktemp` - - # Extract the dynamic symbols from the main binary, there is no need to also have these - # in the normal symbol table - nm -D "$binary" --format=posix --defined-only | awk '{ print $1 }' | sort > "$dynsyms" - # Extract all the text (i.e. function) symbols from the debuginfo - nm "$debuginfo" --format=posix --defined-only | awk '{ if ($2 == "T" || $2 == "t") print $1 }' | sort > "$funcsyms" - # Keep all the function symbols not already in the dynamic symbol table - comm -13 "$dynsyms" "$funcsyms" > "$keep_symbols" - # Copy the full debuginfo, keeping only a minumal set of symbols and removing some unnecessary sections - objcopy -S --remove-section .gdb_index --remove-section .comment --keep-symbols="$keep_symbols" "$debuginfo" "$mini_debuginfo" &> /dev/null - #Inject the compressed data into the .gnu_debugdata section of the original binary - xz "$mini_debuginfo" - mini_debuginfo="${mini_debuginfo}.xz" - objcopy --add-section .gnu_debugdata="$mini_debuginfo" "$binary" - rm -f "$dynsyms" "$funcsyms" "$keep_symbols" "$mini_debuginfo" - - strip "$binary" ## throw away the symbol table -} - - -TESTDIR=`pwd` -TEMPDIR=`mktemp --tmpdir -d libunwind-test-XXXXXXXXXX` -trap "rm -r -- $TEMPDIR" EXIT - -cp crasher $TEMPDIR/crasher -if [ "$1" = "-minidebuginfo" ]; then - add_minidebug $TEMPDIR/crasher -fi - -# create core dump -( - cd $TEMPDIR - ulimit -c 10000 - ./crasher backing_files -) 2>/dev/null -COREFILE=$TEMPDIR/core* - -# magic option -testcase enables checking for the specific contents of the stack -./test-coredump-unwind $COREFILE -testcase `cat $TEMPDIR/backing_files` diff --git a/src/pal/src/libunwind/tests/run-coredump-unwind-mdi b/src/pal/src/libunwind/tests/run-coredump-unwind-mdi deleted file mode 100644 index d0a315b8e..000000000 --- a/src/pal/src/libunwind/tests/run-coredump-unwind-mdi +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh - -# This test intends to test the unw_get_proc_name function on binaries without -# the symbol table but with so called MiniDebuginfo available. In particular, -# it is tested using the coredump accessors. For more info about MiniDebugInfo -# see e.g. http://fedoraproject.org/wiki/Features/MiniDebugInfo - -${0%/*}/run-coredump-unwind -minidebuginfo diff --git a/src/pal/src/libunwind/tests/run-ia64-test-dyn1 b/src/pal/src/libunwind/tests/run-ia64-test-dyn1 deleted file mode 100644 index acce944ca..000000000 --- a/src/pal/src/libunwind/tests/run-ia64-test-dyn1 +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -./test-ptrace -t ./ia64-test-dyn1 diff --git a/src/pal/src/libunwind/tests/run-ptrace-mapper b/src/pal/src/libunwind/tests/run-ptrace-mapper deleted file mode 100644 index dc3010d4b..000000000 --- a/src/pal/src/libunwind/tests/run-ptrace-mapper +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -./test-ptrace -c -n -t ./mapper $* diff --git a/src/pal/src/libunwind/tests/run-ptrace-misc b/src/pal/src/libunwind/tests/run-ptrace-misc deleted file mode 100644 index c3a6552f1..000000000 --- a/src/pal/src/libunwind/tests/run-ptrace-misc +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -./test-ptrace -c -t ./test-ptrace-misc diff --git a/src/pal/src/libunwind/tests/test-async-sig.c b/src/pal/src/libunwind/tests/test-async-sig.c deleted file mode 100644 index 2ce8b4bb7..000000000 --- a/src/pal/src/libunwind/tests/test-async-sig.c +++ /dev/null @@ -1,193 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -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. */ - -/* Check whether basic unwinding truly is async-signal safe. */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "compiler.h" - -#include -#include -#include -#include -#include - -#include - -#define UNW_LOCAL_ONLY -#include - -static const int nerrors_max = 100; - -struct itimerval interval = - { - .it_interval = { .tv_sec = 0, .tv_usec = 0 }, - .it_value = { .tv_sec = 0, .tv_usec = 1000 } - }; - -int verbose; -int nerrors; -int sigcount; - -#ifndef CONFIG_BLOCK_SIGNALS -/* When libunwind is configured with --enable-block-signals=no, the caller - is responsible for preventing recursion via signal handlers. - We use a simple global here. In a multithreaded program, one would use - a thread-local variable. */ -int recurcount; -#endif - -#define panic(args...) \ - { ++nerrors; fprintf (stderr, args); return; } - -static void -do_backtrace (int may_print, int get_proc_name) -{ - char buf[512], name[256]; - unw_cursor_t cursor; - unw_word_t ip, sp, off; - unw_context_t uc; - int ret; - int depth = 0; - -#ifndef CONFIG_BLOCK_SIGNALS - if (recurcount > 0) - return; - recurcount += 1; -#endif - - unw_getcontext (&uc); - if (unw_init_local (&cursor, &uc) < 0) - panic ("unw_init_local failed!\n"); - - do - { - unw_get_reg (&cursor, UNW_REG_IP, &ip); - unw_get_reg (&cursor, UNW_REG_SP, &sp); - - buf[0] = '\0'; - if (get_proc_name || (may_print && verbose)) - { - ret = unw_get_proc_name (&cursor, name, sizeof (name), &off); - if (ret == 0 && (may_print && verbose)) - { - if (off) - snprintf (buf, sizeof (buf), "<%s+0x%lx>", name, (long) off); - else - { - size_t len = strlen (name); - buf[0] = '<'; - memcpy (buf + 1, name, len); - buf[len + 1] = '>'; - buf[len + 2] = '\0'; - } - } - } - - if (may_print && verbose) - printf ("%016lx %-32s (sp=%016lx)\n", (long) ip, buf, (long) sp); - - ret = unw_step (&cursor); - if (ret < 0) - { - unw_get_reg (&cursor, UNW_REG_IP, &ip); - panic ("FAILURE: unw_step() returned %d for ip=%lx\n", - ret, (long) ip); - } - if (depth++ > 100) - { - panic ("FAILURE: unw_step() looping over %d iterations\n", depth); - break; - } - } - while (ret > 0); - -#ifndef CONFIG_BLOCK_SIGNALS - recurcount -= 1; -#endif -} - -void -sighandler (int signal) -{ - if (verbose) - printf ("sighandler(signal=%d, count=%d)\n", signal, sigcount); - - do_backtrace (1, 1); - - ++sigcount; - - if (sigcount == 100) - unw_set_caching_policy (unw_local_addr_space, UNW_CACHE_GLOBAL); - else if (sigcount == 200) - unw_set_caching_policy (unw_local_addr_space, UNW_CACHE_PER_THREAD); - else if (sigcount == 300 || nerrors > nerrors_max) - { - if (nerrors > nerrors_max) - panic ("Too many errors (%d)\n", nerrors); - if (nerrors) - { - fprintf (stderr, "FAILURE: detected %d errors\n", nerrors); - exit (-1); - } - if (verbose) - printf ("SUCCESS.\n"); - exit (0); - } - setitimer (ITIMER_VIRTUAL, &interval, NULL); -} - -int -main (int argc, char **argv UNUSED) -{ - struct sigaction act; - long i = 0; - - if (argc > 1) - verbose = 1; - - unw_set_caching_policy (unw_local_addr_space, UNW_CACHE_NONE); - - memset (&act, 0, sizeof (act)); - act.sa_handler = sighandler; - act.sa_flags = SA_SIGINFO; - sigaction (SIGVTALRM, &act, NULL); - - setitimer (ITIMER_VIRTUAL, &interval, NULL); - - while (1) - { - if (0 && verbose) - printf ("%s: starting backtrace\n", __FUNCTION__); - do_backtrace (0, (i++ % 100) == 0); - if (nerrors > nerrors_max) - { - fprintf (stderr, "Too many errors (%d)\n", nerrors); - exit (-1); - } - } - return (0); -} diff --git a/src/pal/src/libunwind/tests/test-coredump-unwind.c b/src/pal/src/libunwind/tests/test-coredump-unwind.c deleted file mode 100644 index 53498237c..000000000 --- a/src/pal/src/libunwind/tests/test-coredump-unwind.c +++ /dev/null @@ -1,395 +0,0 @@ -/* - * Example program for unwinding core dumps. - * - * Compile a-la: - * gcc -Os -Wall \ - * -Wl,--start-group \ - * -lunwind -lunwind-x86 -lunwind-coredump \ - * example-core-unwind.c \ - * -Wl,--end-group \ - * -oexample-core-unwind - * - * Run: - * eu-unstrip -n --core COREDUMP - * figure out which virtual addresses in COREDUMP correspond to which mapped executable files - * (binary and libraries), then supply them like this: - * ./example-core-unwind COREDUMP 0x400000:/bin/crashed_program 0x3458600000:/lib/libc.so.6 [...] - * - * Note: Program eu-unstrip is part of elfutils, virtual addresses of shared - * libraries can be determined by ldd (at least on linux). - */ - -#include "compiler.h" - -#undef _GNU_SOURCE -#define _GNU_SOURCE 1 -#undef __USE_GNU -#define __USE_GNU 1 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* For SIGSEGV handler code */ -#include -#include - -#include - - -/* Utility logging functions */ - -enum { - LOGMODE_NONE = 0, - LOGMODE_STDIO = (1 << 0), - LOGMODE_SYSLOG = (1 << 1), - LOGMODE_BOTH = LOGMODE_SYSLOG + LOGMODE_STDIO, -}; -const char *msg_prefix = ""; -const char *msg_eol = "\n"; -int logmode = LOGMODE_STDIO; -int xfunc_error_retval = EXIT_FAILURE; - -void xfunc_die(void) -{ - exit(xfunc_error_retval); -} - -static void verror_msg_helper(const char *s, - va_list p, - const char* strerr, - int flags) -{ - char *msg; - int prefix_len, strerr_len, msgeol_len, used; - - if (!logmode) - return; - - used = vasprintf(&msg, s, p); - if (used < 0) - return; - - /* This is ugly and costs +60 bytes compared to multiple - * fprintf's, but is guaranteed to do a single write. - * This is needed for e.g. when multiple children - * can produce log messages simultaneously. */ - - prefix_len = msg_prefix[0] ? strlen(msg_prefix) + 2 : 0; - strerr_len = strerr ? strlen(strerr) : 0; - msgeol_len = strlen(msg_eol); - /* +3 is for ": " before strerr and for terminating NUL */ - char *msg1 = (char*) realloc(msg, prefix_len + used + strerr_len + msgeol_len + 3); - if (!msg1) - { - free(msg); - return; - } - msg = msg1; - /* TODO: maybe use writev instead of memmoving? Need full_writev? */ - if (prefix_len) - { - char *p; - memmove(msg + prefix_len, msg, used); - used += prefix_len; - p = stpcpy(msg, msg_prefix); - p[0] = ':'; - p[1] = ' '; - } - if (strerr) - { - if (s[0]) - { - msg[used++] = ':'; - msg[used++] = ' '; - } - strcpy(&msg[used], strerr); - used += strerr_len; - } - strcpy(&msg[used], msg_eol); - - if (flags & LOGMODE_STDIO) - { - fflush(stdout); - write(STDERR_FILENO, msg, used + msgeol_len); - } - msg[used] = '\0'; /* remove msg_eol (usually "\n") */ - if (flags & LOGMODE_SYSLOG) - { - syslog(LOG_ERR, "%s", msg + prefix_len); - } - free(msg); -} - -void log_msg(const char *s, ...) -{ - va_list p; - va_start(p, s); - verror_msg_helper(s, p, NULL, logmode); - va_end(p); -} -/* It's a macro, not function, since it collides with log() from math.h */ -#undef log -#define log(...) log_msg(__VA_ARGS__) - -void error_msg(const char *s, ...) -{ - va_list p; - va_start(p, s); - verror_msg_helper(s, p, NULL, logmode); - va_end(p); -} - -void error_msg_and_die(const char *s, ...) -{ - va_list p; - va_start(p, s); - verror_msg_helper(s, p, NULL, logmode); - va_end(p); - xfunc_die(); -} - -void perror_msg(const char *s, ...) -{ - va_list p; - va_start(p, s); - /* Guard against ": Success" */ - verror_msg_helper(s, p, errno ? strerror(errno) : NULL, logmode); - va_end(p); -} - -void perror_msg_and_die(const char *s, ...) -{ - va_list p; - va_start(p, s); - /* Guard against ": Success" */ - verror_msg_helper(s, p, errno ? strerror(errno) : NULL, logmode); - va_end(p); - xfunc_die(); -} - -void die_out_of_memory(void) -{ - error_msg_and_die("Out of memory, exiting"); -} - -/* End of utility logging functions */ - - - -static -void handle_sigsegv(int sig, siginfo_t *info, void *ucontext) -{ - long ip = 0; - ucontext_t *uc UNUSED; - - uc = ucontext; -#if defined(__linux__) -#ifdef UNW_TARGET_X86 - ip = uc->uc_mcontext.gregs[REG_EIP]; -#elif defined(UNW_TARGET_X86_64) - ip = uc->uc_mcontext.gregs[REG_RIP]; -#elif defined(UNW_TARGET_ARM) - ip = uc->uc_mcontext.arm_pc; -#endif -#elif defined(__FreeBSD__) -#ifdef __i386__ - ip = uc->uc_mcontext.mc_eip; -#elif defined(__amd64__) - ip = uc->uc_mcontext.mc_rip; -#else -#error Port me -#endif -#else -#error Port me -#endif - dprintf(2, "signal:%d address:0x%lx ip:0x%lx\n", - sig, - /* this is void*, but using %p would print "(null)" - * even for ptrs which are not exactly 0, but, say, 0x123: - */ - (long)info->si_addr, - ip); - - { - /* glibc extension */ - void *array[50]; - int size; - size = backtrace(array, 50); -#ifdef __linux__ - backtrace_symbols_fd(array, size, 2); -#endif - } - - _exit(1); -} - -static void install_sigsegv_handler(void) -{ - struct sigaction sa; - memset(&sa, 0, sizeof(sa)); - sa.sa_sigaction = handle_sigsegv; - sa.sa_flags = SA_SIGINFO; - sigaction(SIGSEGV, &sa, NULL); - sigaction(SIGILL, &sa, NULL); - sigaction(SIGFPE, &sa, NULL); - sigaction(SIGBUS, &sa, NULL); -} - -int -main(int argc UNUSED, char **argv) -{ - unw_addr_space_t as; - struct UCD_info *ui; - unw_cursor_t c; - int ret; - -#define TEST_FRAMES 4 -#define TEST_NAME_LEN 32 - int testcase = 0; - int test_cur = 0; - long test_start_ips[TEST_FRAMES]; - char test_names[TEST_FRAMES][TEST_NAME_LEN]; - - install_sigsegv_handler(); - - const char *progname = strrchr(argv[0], '/'); - if (progname) - progname++; - else - progname = argv[0]; - - if (!argv[1]) - error_msg_and_die("Usage: %s COREDUMP [VADDR:BINARY_FILE]...", progname); - - msg_prefix = progname; - - as = unw_create_addr_space(&_UCD_accessors, 0); - if (!as) - error_msg_and_die("unw_create_addr_space() failed"); - - ui = _UCD_create(argv[1]); - if (!ui) - error_msg_and_die("_UCD_create('%s') failed", argv[1]); - ret = unw_init_remote(&c, as, ui); - if (ret < 0) - error_msg_and_die("unw_init_remote() failed: ret=%d\n", ret); - - argv += 2; - - /* Enable checks for the crasher test program? */ - if (*argv && !strcmp(*argv, "-testcase")) - { - testcase = 1; - logmode = LOGMODE_NONE; - argv++; - } - - while (*argv) - { - char *colon; - unsigned long vaddr = strtoul(*argv, &colon, 16); - if (*colon != ':') - error_msg_and_die("Bad format: '%s'", *argv); - if (_UCD_add_backing_file_at_vaddr(ui, vaddr, colon + 1) < 0) - error_msg_and_die("Can't add backing file '%s'", colon + 1); - argv++; - } - - for (;;) - { - unw_word_t ip; - ret = unw_get_reg(&c, UNW_REG_IP, &ip); - if (ret < 0) - error_msg_and_die("unw_get_reg(UNW_REG_IP) failed: ret=%d\n", ret); - - unw_proc_info_t pi; - ret = unw_get_proc_info(&c, &pi); - if (ret < 0) - error_msg_and_die("unw_get_proc_info(ip=0x%lx) failed: ret=%d\n", (long) ip, ret); - - if (!testcase) - printf("\tip=0x%08lx proc=%08lx-%08lx handler=0x%08lx lsda=0x%08lx\n", - (long) ip, - (long) pi.start_ip, (long) pi.end_ip, - (long) pi.handler, (long) pi.lsda); - - if (testcase && test_cur < TEST_FRAMES) - { - unw_word_t off; - - test_start_ips[test_cur] = (long) pi.start_ip; - if (unw_get_proc_name(&c, test_names[test_cur], sizeof(test_names[0]), &off) != 0) - { - test_names[test_cur][0] = '\0'; - } - test_cur++; - } - - log("step"); - ret = unw_step(&c); - log("step done:%d", ret); - if (ret < 0) - error_msg_and_die("FAILURE: unw_step() returned %d", ret); - if (ret == 0) - break; - } - log("stepping ended"); - - /* Check that the second and third frames are equal, but distinct of the - * others */ - if (testcase && - (test_cur != 4 - || test_start_ips[1] != test_start_ips[2] - || test_start_ips[0] == test_start_ips[1] - || test_start_ips[2] == test_start_ips[3] - ) - ) - { - fprintf(stderr, "FAILURE: start IPs incorrect\n"); - return -1; - } - - if (testcase && - ( strcmp(test_names[0], "a") - || strcmp(test_names[1], "b") - || strcmp(test_names[2], "b") - || strcmp(test_names[3], "main") - ) - ) - { - fprintf(stderr, "FAILURE: procedure names are missing/incorrect\n"); - return -1; - } - - _UCD_destroy(ui); - unw_destroy_addr_space(as); - - return 0; -} diff --git a/src/pal/src/libunwind/tests/test-flush-cache.c b/src/pal/src/libunwind/tests/test-flush-cache.c deleted file mode 100644 index 1611cf48e..000000000 --- a/src/pal/src/libunwind/tests/test-flush-cache.c +++ /dev/null @@ -1,143 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2003 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -Copyright (c) 2003 Hewlett-Packard Co. - -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. */ - -#include -#include - -#define UNW_LOCAL_ONLY /* must define this for consistency with backtrace() */ -#include - -int verbose; - -int -f257 (void) -{ - void *buffer[300]; - int i, n; - - if (verbose) - printf ("First backtrace:\n"); - n = unw_backtrace (buffer, 300); - if (verbose) - for (i = 0; i < n; ++i) - printf ("[%d] ip=%p\n", i, buffer[i]); - - unw_set_cache_size (unw_local_addr_space, 1023, 0); - unw_flush_cache (unw_local_addr_space, 0, 0); - - if (verbose) - printf ("\nSecond backtrace:\n"); - n = unw_backtrace (buffer, 300); - if (verbose) - for (i = 0; i < n; ++i) - printf ("[%d] ip=%p\n", i, buffer[i]); - return 0; -} - -#define F(n,m) \ -int \ -f##n (void) \ -{ \ - return f##m (); \ -} - -/* Here, we rely on the fact that the script-cache's hash-table is 256 - entries big. With 257 functions, we're guaranteed to get at least - one hash-collision. */ -F(256,257) F(255,256) F(254,255) F(253,254) -F(252,253) F(251,252) F(250,251) F(249,250) -F(248,249) F(247,248) F(246,247) F(245,246) -F(244,245) F(243,244) F(242,243) F(241,242) -F(240,241) F(239,240) F(238,239) F(237,238) -F(236,237) F(235,236) F(234,235) F(233,234) -F(232,233) F(231,232) F(230,231) F(229,230) -F(228,229) F(227,228) F(226,227) F(225,226) -F(224,225) F(223,224) F(222,223) F(221,222) -F(220,221) F(219,220) F(218,219) F(217,218) -F(216,217) F(215,216) F(214,215) F(213,214) -F(212,213) F(211,212) F(210,211) F(209,210) -F(208,209) F(207,208) F(206,207) F(205,206) -F(204,205) F(203,204) F(202,203) F(201,202) -F(200,201) F(199,200) F(198,199) F(197,198) -F(196,197) F(195,196) F(194,195) F(193,194) -F(192,193) F(191,192) F(190,191) F(189,190) -F(188,189) F(187,188) F(186,187) F(185,186) -F(184,185) F(183,184) F(182,183) F(181,182) -F(180,181) F(179,180) F(178,179) F(177,178) -F(176,177) F(175,176) F(174,175) F(173,174) -F(172,173) F(171,172) F(170,171) F(169,170) -F(168,169) F(167,168) F(166,167) F(165,166) -F(164,165) F(163,164) F(162,163) F(161,162) -F(160,161) F(159,160) F(158,159) F(157,158) -F(156,157) F(155,156) F(154,155) F(153,154) -F(152,153) F(151,152) F(150,151) F(149,150) -F(148,149) F(147,148) F(146,147) F(145,146) -F(144,145) F(143,144) F(142,143) F(141,142) -F(140,141) F(139,140) F(138,139) F(137,138) -F(136,137) F(135,136) F(134,135) F(133,134) -F(132,133) F(131,132) F(130,131) F(129,130) -F(128,129) F(127,128) F(126,127) F(125,126) -F(124,125) F(123,124) F(122,123) F(121,122) -F(120,121) F(119,120) F(118,119) F(117,118) -F(116,117) F(115,116) F(114,115) F(113,114) -F(112,113) F(111,112) F(110,111) F(109,110) -F(108,109) F(107,108) F(106,107) F(105,106) -F(104,105) F(103,104) F(102,103) F(101,102) -F(100,101) F(99,100) F(98,99) F(97,98) -F(96,97) F(95,96) F(94,95) F(93,94) -F(92,93) F(91,92) F(90,91) F(89,90) -F(88,89) F(87,88) F(86,87) F(85,86) -F(84,85) F(83,84) F(82,83) F(81,82) -F(80,81) F(79,80) F(78,79) F(77,78) -F(76,77) F(75,76) F(74,75) F(73,74) -F(72,73) F(71,72) F(70,71) F(69,70) -F(68,69) F(67,68) F(66,67) F(65,66) -F(64,65) F(63,64) F(62,63) F(61,62) -F(60,61) F(59,60) F(58,59) F(57,58) -F(56,57) F(55,56) F(54,55) F(53,54) -F(52,53) F(51,52) F(50,51) F(49,50) -F(48,49) F(47,48) F(46,47) F(45,46) -F(44,45) F(43,44) F(42,43) F(41,42) -F(40,41) F(39,40) F(38,39) F(37,38) -F(36,37) F(35,36) F(34,35) F(33,34) -F(32,33) F(31,32) F(30,31) F(29,30) -F(28,29) F(27,28) F(26,27) F(25,26) -F(24,25) F(23,24) F(22,23) F(21,22) -F(20,21) F(19,20) F(18,19) F(17,18) -F(16,17) F(15,16) F(14,15) F(13,14) -F(12,13) F(11,12) F(10,11) F(9,10) -F(8,9) F(7,8) F(6,7) F(5,6) -F(4,5) F(3,4) F(2,3) F(1,2) - -int -main (int argc, char **argv) -{ - if (argc > 1 && strcmp (argv[1], "-v") == 0) - verbose = 1; - - return f1 (); -} diff --git a/src/pal/src/libunwind/tests/test-init-remote.c b/src/pal/src/libunwind/tests/test-init-remote.c deleted file mode 100644 index 66f2d6a1e..000000000 --- a/src/pal/src/libunwind/tests/test-init-remote.c +++ /dev/null @@ -1,103 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -Copyright (c) 2002 Hewlett-Packard Co. - -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. */ - -/* This test simply verifies that unw_init_remote() can be used in - lieu of unw_init_local(). This was broken for a while on ia64. */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "compiler.h" - -#include -#include -#include -#include - -#define panic(args...) \ - { fprintf (stderr, args); exit (-1); } - -int verbose; - -static int -do_backtrace (void) -{ - char buf[512], name[256]; - unw_word_t ip, sp, off; - unw_cursor_t cursor; - unw_context_t uc; - int ret; - - unw_getcontext (&uc); - if (unw_init_remote (&cursor, unw_local_addr_space, &uc) < 0) - panic ("unw_init_remote failed!\n"); - - do - { - unw_get_reg (&cursor, UNW_REG_IP, &ip); - unw_get_reg (&cursor, UNW_REG_SP, &sp); - buf[0] = '\0'; - if (unw_get_proc_name (&cursor, name, sizeof (name), &off) == 0) - { - if (off) - snprintf (buf, sizeof (buf), "<%s+0x%lx>", name, (long) off); - else - snprintf (buf, sizeof (buf), "<%s>", name); - } - if (verbose) - printf ("%016lx %-32s (sp=%016lx)\n", (long) ip, buf, (long) sp); - - ret = unw_step (&cursor); - if (ret < 0) - { - unw_get_reg (&cursor, UNW_REG_IP, &ip); - printf ("FAILURE: unw_step() returned %d for ip=%lx\n", - ret, (long) ip); - return -1; - } - } - while (ret > 0); - - return 0; -} - -static int -foo (void) -{ - return do_backtrace (); -} - -int -main (int argc, char **argv UNUSED) -{ - verbose = (argc > 1); - - if (verbose) - printf ("Normal backtrace:\n"); - return foo (); -} diff --git a/src/pal/src/libunwind/tests/test-mem.c b/src/pal/src/libunwind/tests/test-mem.c deleted file mode 100644 index 52c977488..000000000 --- a/src/pal/src/libunwind/tests/test-mem.c +++ /dev/null @@ -1,103 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2003-2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -Copyright (c) 2003 Hewlett-Packard Co. - -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. */ - -#include "compiler.h" - -#include -#include -#include -#include -#include - -#include - -#define panic(args...) \ - { fprintf (stderr, args); exit (-1); } - -int verbose; - -static void -do_backtrace (void) -{ - unw_cursor_t cursor; - unw_word_t ip, sp; - unw_context_t uc; - int ret; - - unw_getcontext (&uc); - if (unw_init_local (&cursor, &uc) < 0) - panic ("unw_init_local failed!\n"); - - do - { - unw_get_reg (&cursor, UNW_REG_IP, &ip); - unw_get_reg (&cursor, UNW_REG_SP, &sp); - - if (verbose) - printf ("%016lx (sp=%016lx)\n", (long) ip, (long) sp); - - ret = unw_step (&cursor); - if (ret < 0) - { - unw_get_reg (&cursor, UNW_REG_IP, &ip); - panic ("FAILURE: unw_step() returned %d for ip=%lx\n", - ret, (long) ip); - } - } - while (ret > 0); -} - -int -consume_some_stack_space (void) -{ - unw_cursor_t cursor; - unw_context_t uc; - char string[1024]; - - memset (&cursor, 0, sizeof (cursor)); - memset (&uc, 0, sizeof (uc)); - return sprintf (string, "hello %p %p\n", &cursor, &uc); -} - -int -main (int argc, char **argv UNUSED) -{ - struct rlimit rlim; - - verbose = argc > 1; - - if (consume_some_stack_space () > 9999) - exit (-1); /* can't happen, but don't let the compiler know... */ - - rlim.rlim_cur = 0; - rlim.rlim_max = RLIM_INFINITY; - setrlimit (RLIMIT_DATA, &rlim); - setrlimit (RLIMIT_AS, &rlim); - - do_backtrace (); - return 0; -} diff --git a/src/pal/src/libunwind/tests/test-proc-info.c b/src/pal/src/libunwind/tests/test-proc-info.c deleted file mode 100644 index c4145bc37..000000000 --- a/src/pal/src/libunwind/tests/test-proc-info.c +++ /dev/null @@ -1,171 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2003 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -Copyright (c) 2003 Hewlett-Packard Co. - -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. */ - -/* This test program checks whether proc_info lookup failures are - cached. They must NOT be cached because it could otherwise turn - temporary failures into permanent ones. Furthermore, we allow apps - to return -UNW_ESTOPUNWIND to terminate unwinding (though this - feature is deprecated and dynamic unwind info should be used - instead). */ - -#include -#include - -#include -#include "compiler.h" - -int errors; - -#define panic(args...) \ - { ++errors; fprintf (stderr, args); return -1; } - -static int -find_proc_info (unw_addr_space_t as UNUSED, - unw_word_t ip UNUSED, - unw_proc_info_t *pip UNUSED, - int need_unwind_info UNUSED, - void *arg UNUSED) -{ - return -UNW_ESTOPUNWIND; -} - -static int -access_mem (unw_addr_space_t as UNUSED, - unw_word_t addr UNUSED, - unw_word_t *valp, int write, - void *arg UNUSED) -{ - if (!write) - *valp = 0; - return 0; -} - -static int -access_reg (unw_addr_space_t as UNUSED, - unw_regnum_t regnum UNUSED, - unw_word_t *valp, int write, - void *arg UNUSED) -{ - if (!write) - *valp = 32; - return 0; -} - -static int -access_fpreg (unw_addr_space_t as UNUSED, - unw_regnum_t regnum UNUSED, - unw_fpreg_t *valp, int write, - void *arg UNUSED) -{ - if (!write) - memset (valp, 0, sizeof (*valp)); - return 0; -} - -static int -get_dyn_info_list_addr (unw_addr_space_t as UNUSED, - unw_word_t *dilap UNUSED, - void *arg UNUSED) -{ - return -UNW_ENOINFO; -} - -static void -put_unwind_info (unw_addr_space_t as UNUSED, - unw_proc_info_t *pi UNUSED, - void *arg UNUSED) -{ - ++errors; - fprintf (stderr, "%s() got called!\n", __FUNCTION__); -} - -static int -resume (unw_addr_space_t as UNUSED, - unw_cursor_t *reg UNUSED, - void *arg UNUSED) -{ - panic ("%s() got called!\n", __FUNCTION__); -} - -static int -get_proc_name (unw_addr_space_t as UNUSED, - unw_word_t ip UNUSED, - char *buf UNUSED, - size_t buf_len UNUSED, - unw_word_t *offp UNUSED, - void *arg UNUSED) -{ - panic ("%s() got called!\n", __FUNCTION__); -} - -int -main (int argc, char **argv) -{ - unw_accessors_t acc; - unw_addr_space_t as; - int ret, verbose = 0; - unw_cursor_t c; - - if (argc > 1 && strcmp (argv[1], "-v") == 0) - verbose = 1; - - memset (&acc, 0, sizeof (acc)); - acc.find_proc_info = find_proc_info; - acc.put_unwind_info = put_unwind_info; - acc.get_dyn_info_list_addr = get_dyn_info_list_addr; - acc.access_mem = access_mem; - acc.access_reg = access_reg; - acc.access_fpreg = access_fpreg; - acc.resume = resume; - acc.get_proc_name = get_proc_name; - - as = unw_create_addr_space (&acc, 0); - if (!as) - panic ("unw_create_addr_space() failed\n"); - - unw_set_caching_policy (as, UNW_CACHE_GLOBAL); - - ret = unw_init_remote (&c, as, NULL); - if (ret < 0) - panic ("unw_init_remote() returned %d instead of 0\n", ret); - - ret = unw_step (&c); - if (ret != -UNW_ESTOPUNWIND) - panic ("First call to unw_step() returned %d instead of %d\n", - ret, -UNW_ESTOPUNWIND); - - ret = unw_step (&c); - if (ret != -UNW_ESTOPUNWIND) - panic ("Second call to unw_step() returned %d instead of %d\n", - ret, -UNW_ESTOPUNWIND); - - unw_destroy_addr_space (as); - - if (verbose) - printf ("SUCCESS\n"); - return 0; -} diff --git a/src/pal/src/libunwind/tests/test-ptrace-misc.c b/src/pal/src/libunwind/tests/test-ptrace-misc.c deleted file mode 100644 index 374059dc4..000000000 --- a/src/pal/src/libunwind/tests/test-ptrace-misc.c +++ /dev/null @@ -1,120 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include "compiler.h" - -#include -#include -#include -#include -#include - -#include - -pid_t self; -int global[64]; - -int -func (int arg) -{ - int sum = 0, i, max, arr[1024]; - - if (arg == 0) - { - sum = global[2]; - sum += sum + sum * getppid (); - return sum; - } - else - { - max = arg; - if (max >= 64) - max = 64; - - for (i = 0; i < max; ++i) - arr[i] = func (arg - 1); - - for (i = 0; i < max; ++i) - if (arr[i] > 16) - sum += arr[i]; - else - sum -= arr[i]; - } - return sum; -} - -int -bar (int v) -{ - extern long f (long); - int arr[1] = { v }; - uintptr_t r; - - /* This is a vain attempt to use up lots of registers to force - the frame-chain info to be saved on the memory stack on ia64. - It happens to work with gcc v3.3.4 and gcc v3.4.1 but perhaps - not with any other compiler. */ - r = (uintptr_t) malloc(f (arr[0]) - + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) - + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) - + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) - + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) - + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) - + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) - + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) - + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) - + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) - + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) - + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) - + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) - + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) - + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) - + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) - + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) - + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + (f (v) + f (v)) - )))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) - ))))))))))))))))))))))))))))))))))))))))))))))))))))))); - if (r < 2) - v = r; - - kill (self, SIGUSR1); /* tell test-ptrace to start single-stepping */ - v = func (v); - kill (self, SIGUSR2); /* tell test-ptrace to stop single-stepping */ - return v; -} - -int -main (int argc, char **argv UNUSED) -{ - int val = argc; - - signal (SIGUSR1, SIG_IGN); - signal (SIGUSR2, SIG_IGN); - - self = getpid (); - - printf ("sum = %d\n", bar (val)); - return 0; -} diff --git a/src/pal/src/libunwind/tests/test-ptrace.c b/src/pal/src/libunwind/tests/test-ptrace.c deleted file mode 100644 index e7c7883f3..000000000 --- a/src/pal/src/libunwind/tests/test-ptrace.c +++ /dev/null @@ -1,370 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2003-2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -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. */ - -#include - -#ifdef HAVE_TTRACE - -int -main (void) -{ - printf ("FAILURE: ttrace() not supported yet\n"); - return -1; -} - -#else /* !HAVE_TTRACE */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -extern char **environ; - -static const int nerrors_max = 100; - -int nerrors; -int verbose; -int print_names = 1; - -enum - { - INSTRUCTION, - SYSCALL, - TRIGGER - } -trace_mode = SYSCALL; - -#define panic(args...) \ - do { fprintf (stderr, args); ++nerrors; } while (0) - -static unw_addr_space_t as; -static struct UPT_info *ui; - -static int killed; - -void -do_backtrace (void) -{ - unw_word_t ip, sp, start_ip = 0, off; - int n = 0, ret; - unw_proc_info_t pi; - unw_cursor_t c; - char buf[512]; - size_t len; - - ret = unw_init_remote (&c, as, ui); - if (ret < 0) - panic ("unw_init_remote() failed: ret=%d\n", ret); - - do - { - if ((ret = unw_get_reg (&c, UNW_REG_IP, &ip)) < 0 - || (ret = unw_get_reg (&c, UNW_REG_SP, &sp)) < 0) - panic ("unw_get_reg/unw_get_proc_name() failed: ret=%d\n", ret); - - if (n == 0) - start_ip = ip; - - buf[0] = '\0'; - if (print_names) - unw_get_proc_name (&c, buf, sizeof (buf), &off); - - if (verbose) - { - if (off) - { - len = strlen (buf); - if (len >= sizeof (buf) - 32) - len = sizeof (buf) - 32; - sprintf (buf + len, "+0x%lx", (unsigned long) off); - } - printf ("%016lx %-32s (sp=%016lx)\n", (long) ip, buf, (long) sp); - } - - if ((ret = unw_get_proc_info (&c, &pi)) < 0) - panic ("unw_get_proc_info(ip=0x%lx) failed: ret=%d\n", (long) ip, ret); - else if (verbose) - printf ("\tproc=%016lx-%016lx\n\thandler=%lx lsda=%lx", - (long) pi.start_ip, (long) pi.end_ip, - (long) pi.handler, (long) pi.lsda); - -#if UNW_TARGET_IA64 - { - unw_word_t bsp; - - if ((ret = unw_get_reg (&c, UNW_IA64_BSP, &bsp)) < 0) - panic ("unw_get_reg() failed: ret=%d\n", ret); - else if (verbose) - printf (" bsp=%lx", bsp); - } -#endif - if (verbose) - printf ("\n"); - - ret = unw_step (&c); - if (ret < 0) - { - unw_get_reg (&c, UNW_REG_IP, &ip); - panic ("FAILURE: unw_step() returned %d for ip=%lx (start ip=%lx)\n", - ret, (long) ip, (long) start_ip); - } - - if (++n > 64) - { - /* guard against bad unwind info in old libraries... */ - panic ("too deeply nested---assuming bogus unwind (start ip=%lx)\n", - (long) start_ip); - break; - } - if (nerrors > nerrors_max) - { - panic ("Too many errors (%d)!\n", nerrors); - break; - } - } - while (ret > 0); - - if (ret < 0) - panic ("unwind failed with ret=%d\n", ret); - - if (verbose) - printf ("================\n\n"); -} - -static pid_t target_pid; -static void target_pid_kill (void) -{ - kill (target_pid, SIGKILL); -} - -int -main (int argc, char **argv) -{ - int status, pid, pending_sig, optind = 1, state = 1; - - as = unw_create_addr_space (&_UPT_accessors, 0); - if (!as) - panic ("unw_create_addr_space() failed"); - - if (argc == 1) - { - static char *args[] = { "self", "/bin/ls", "/usr", NULL }; - - /* automated test case */ - argv = args; - - /* Unless the args array is 'walked' the child - process is unable to access it and dies with a segfault */ - fprintf(stderr, "Automated test (%s,%s,%s,%s)\n", - args[0],args[1],args[2],args[3]); - } - else if (argc > 1) - while (argv[optind][0] == '-') - { - if (strcmp (argv[optind], "-v") == 0) - ++optind, verbose = 1; - else if (strcmp (argv[optind], "-i") == 0) - ++optind, trace_mode = INSTRUCTION; /* backtrace at each insn */ - else if (strcmp (argv[optind], "-s") == 0) - ++optind, trace_mode = SYSCALL; /* backtrace at each syscall */ - else if (strcmp (argv[optind], "-t") == 0) - /* Execute until raise(SIGUSR1), then backtrace at each insn - until raise(SIGUSR2). */ - ++optind, trace_mode = TRIGGER; - else if (strcmp (argv[optind], "-c") == 0) - /* Enable caching of unwind-info. */ - ++optind, unw_set_caching_policy (as, UNW_CACHE_GLOBAL); - else if (strcmp (argv[optind], "-n") == 0) - /* Don't look-up and print symbol names. */ - ++optind, print_names = 0; - else - fprintf(stderr, "unrecognized option: %s\n", argv[optind++]); - if (optind >= argc) - break; - } - - target_pid = fork (); - if (!target_pid) - { - /* child */ - - if (!verbose) - dup2 (open ("/dev/null", O_WRONLY), 1); - -#if HAVE_DECL_PTRACE_TRACEME - ptrace (PTRACE_TRACEME, 0, 0, 0); -#elif HAVE_DECL_PT_TRACE_ME - ptrace (PT_TRACE_ME, 0, 0, 0); -#else -#error Trace me -#endif - - if ((argc > 1) && (optind == argc)) { - fprintf(stderr, "Need to specify a command line for the child\n"); - exit (-1); - } - execve (argv[optind], argv + optind, environ); - _exit (-1); - } - atexit (target_pid_kill); - - ui = _UPT_create (target_pid); - - while (nerrors <= nerrors_max) - { - pid = wait4 (-1, &status, 0, NULL); - if (pid == -1) - { - if (errno == EINTR) - continue; - - panic ("wait4() failed (errno=%d)\n", errno); - } - pending_sig = 0; - if (WIFSIGNALED (status) || WIFEXITED (status) - || (WIFSTOPPED (status) && WSTOPSIG (status) != SIGTRAP)) - { - if (WIFEXITED (status)) - { - if (WEXITSTATUS (status) != 0) - panic ("child's exit status %d\n", WEXITSTATUS (status)); - break; - } - else if (WIFSIGNALED (status)) - { - if (!killed) - panic ("child terminated by signal %d\n", WTERMSIG (status)); - break; - } - else - { - pending_sig = WSTOPSIG (status); - /* Avoid deadlock: */ - if (WSTOPSIG (status) == SIGKILL) - break; - if (trace_mode == TRIGGER) - { - if (WSTOPSIG (status) == SIGUSR1) - state = 0; - else if (WSTOPSIG (status) == SIGUSR2) - state = 1; - } - if (WSTOPSIG (status) != SIGUSR1 && WSTOPSIG (status) != SIGUSR2) - { - static int count = 0; - - if (count++ > 100) - { - panic ("Too many child unexpected signals (now %d)\n", - WSTOPSIG (status)); - killed = 1; - } - } - } - } - - switch (trace_mode) - { - case TRIGGER: - if (state) -#if HAVE_DECL_PTRACE_CONT - ptrace (PTRACE_CONT, target_pid, 0, 0); -#elif HAVE_DECL_PT_CONTINUE - ptrace (PT_CONTINUE, target_pid, (caddr_t)1, 0); -#else -#error Port me -#endif - else - { - do_backtrace (); -#if HAVE_DECL_PTRACE_SINGLESTEP - if (ptrace (PTRACE_SINGLESTEP, target_pid, 0, pending_sig) < 0) - { - panic ("ptrace(PTRACE_SINGLESTEP) failed (errno=%d)\n", errno); - killed = 1; - } -#elif HAVE_DECL_PT_STEP - if (ptrace (PT_STEP, target_pid, (caddr_t)1, pending_sig) < 0) - { - panic ("ptrace(PT_STEP) failed (errno=%d)\n", errno); - killed = 1; - } -#else -#error Singlestep me -#endif - } - break; - - case SYSCALL: - if (!state) - do_backtrace (); - state ^= 1; -#if HAVE_DECL_PTRACE_SYSCALL - ptrace (PTRACE_SYSCALL, target_pid, 0, pending_sig); -#elif HAVE_DECL_PT_SYSCALL - ptrace (PT_SYSCALL, target_pid, (caddr_t)1, pending_sig); -#else -#error Syscall me -#endif - break; - - case INSTRUCTION: - do_backtrace (); -#if HAVE_DECL_PTRACE_SINGLESTEP - ptrace (PTRACE_SINGLESTEP, target_pid, 0, pending_sig); -#elif HAVE_DECL_PT_STEP - ptrace (PT_STEP, target_pid, (caddr_t)1, pending_sig); -#else -#error Singlestep me -#endif - break; - } - if (killed) - kill (target_pid, SIGKILL); - } - - _UPT_destroy (ui); - unw_destroy_addr_space (as); - - if (nerrors) - { - printf ("FAILURE: detected %d errors\n", nerrors); - exit (-1); - } - if (verbose) - printf ("SUCCESS\n"); - - return 0; -} - -#endif /* !HAVE_TTRACE */ diff --git a/src/pal/src/libunwind/tests/test-reg-state.c b/src/pal/src/libunwind/tests/test-reg-state.c deleted file mode 100644 index ac713ea68..000000000 --- a/src/pal/src/libunwind/tests/test-reg-state.c +++ /dev/null @@ -1,133 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2003-2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -Copyright (c) 2003 Hewlett-Packard Co. - -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. */ - -#include "compiler.h" - -#include -#include -#include -#include -#include - -#include -#include - -#define panic(args...) \ - { fprintf (stderr, args); exit (-1); } - -int verbose; - -struct cb_data -{ - unw_word_t ip; - void* reg_state; - size_t len; -}; - -static int -dwarf_reg_states_callback(void *token, - void *rs, - size_t size, - unw_word_t start_ip, unw_word_t end_ip) -{ - struct cb_data *data = token; - if (start_ip <= data->ip && data->ip < end_ip) - { - data->reg_state = mmap(NULL, size, PROT_READ | PROT_WRITE, - MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); - memcpy(data->reg_state, rs, size); - data->len = size; - } - return 0; -} - -static void -do_backtrace (void) -{ - unw_cursor_t cursor; - unw_word_t ip, sp; - unw_context_t uc; - int ret; - - unw_getcontext (&uc); - if (unw_init_local (&cursor, &uc) < 0) - panic ("unw_init_local failed!\n"); - - do - { - unw_get_reg (&cursor, UNW_REG_IP, &ip); - unw_get_reg (&cursor, UNW_REG_SP, &sp); - - if (verbose) - printf ("%016lx (sp=%016lx)\n", (long) ip, (long) sp); - - struct cb_data data = {.ip = ip, .reg_state = NULL}; - ret = unw_reg_states_iterate(&cursor, dwarf_reg_states_callback, &data); - if (ret > 0) - { - ret = unw_apply_reg_state (&cursor, data.reg_state); - munmap(data.reg_state, data.len); - } - if (ret < 0) - { - unw_get_reg (&cursor, UNW_REG_IP, &ip); - panic ("FAILURE: unw_step() returned %d for ip=%lx\n", - ret, (long) ip); - } - } - while (ret > 0); -} - -int -consume_some_stack_space (void) -{ - unw_cursor_t cursor; - unw_context_t uc; - char string[1024]; - - memset (&cursor, 0, sizeof (cursor)); - memset (&uc, 0, sizeof (uc)); - return sprintf (string, "hello %p %p\n", &cursor, &uc); -} - -int -main (int argc, char **argv UNUSED) -{ - struct rlimit rlim; - - verbose = argc > 1; - - if (consume_some_stack_space () > 9999) - exit (-1); /* can't happen, but don't let the compiler know... */ - - rlim.rlim_cur = 0; - rlim.rlim_max = RLIM_INFINITY; - setrlimit (RLIMIT_DATA, &rlim); - - do_backtrace (); - return 0; -} diff --git a/src/pal/src/libunwind/tests/test-setjmp.c b/src/pal/src/libunwind/tests/test-setjmp.c deleted file mode 100644 index 769b71b22..000000000 --- a/src/pal/src/libunwind/tests/test-setjmp.c +++ /dev/null @@ -1,285 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2003 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -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. */ - -/* The setjmp()/longjmp(), sigsetjmp()/siglongjmp(). */ - -#include "compiler.h" - -#include -#include -#include -#include -#include -#include - -int nerrors; -int verbose; - -static jmp_buf jbuf; -static sigjmp_buf sigjbuf; -static sigset_t sigset4; - -void -raise_longjmp (jmp_buf jbuf, int i, int n) -{ - while (i < n) - raise_longjmp (jbuf, i + 1, n); - - longjmp (jbuf, n); -} - -void -test_setjmp (void) -{ - volatile int i; - jmp_buf jbuf; - int ret; - - for (i = 0; i < 10; ++i) - { - if ((ret = setjmp (jbuf))) - { - if (verbose) - printf ("%s: secondary setjmp () return, ret=%d\n", - __FUNCTION__, ret); - if (ret != i + 1) - { - fprintf (stderr, "%s: setjmp() returned %d, expected %d\n", - __FUNCTION__, ret, i + 1); - ++nerrors; - } - continue; - } - if (verbose) - printf ("%s.%d: done with setjmp(); calling children\n", - __FUNCTION__, i + 1); - - raise_longjmp (jbuf, 0, i + 1); - - fprintf (stderr, "%s: raise_longjmp() returned unexpectedly\n", - __FUNCTION__); - ++nerrors; - } -} - - -void -raise_siglongjmp (sigjmp_buf jbuf, int i, int n) -{ - while (i < n) - raise_siglongjmp (jbuf, i + 1, n); - - siglongjmp (jbuf, n); -} - -void -test_sigsetjmp (void) -{ - sigjmp_buf jbuf; - volatile int i; - int ret; - - for (i = 0; i < 10; ++i) - { - if ((ret = sigsetjmp (jbuf, 1))) - { - if (verbose) - printf ("%s: secondary sigsetjmp () return, ret=%d\n", - __FUNCTION__, ret); - if (ret != i + 1) - { - fprintf (stderr, "%s: sigsetjmp() returned %d, expected %d\n", - __FUNCTION__, ret, i + 1); - ++nerrors; - } - continue; - } - if (verbose) - printf ("%s.%d: done with sigsetjmp(); calling children\n", - __FUNCTION__, i + 1); - - raise_siglongjmp (jbuf, 0, i + 1); - - fprintf (stderr, "%s: raise_siglongjmp() returned unexpectedly\n", - __FUNCTION__); - ++nerrors; - } -} - -void -sighandler (int signal) -{ - if (verbose) - printf ("%s: got signal %d\n", __FUNCTION__, signal); - - sigprocmask (SIG_BLOCK, NULL, (sigset_t *) &sigset4); - if (verbose) - printf ("%s: back from sigprocmask\n", __FUNCTION__); - - siglongjmp (sigjbuf, 1); - printf ("%s: siglongjmp() returned unexpectedly!\n", __FUNCTION__); -} - -int -main (int argc, char **argv UNUSED) -{ - volatile sigset_t sigset1, sigset2, sigset3; - volatile struct sigaction act; - - if (argc > 1) - verbose = 1; - - sigemptyset ((sigset_t *) &sigset1); - sigaddset ((sigset_t *) &sigset1, SIGUSR1); - sigemptyset ((sigset_t *) &sigset2); - sigaddset ((sigset_t *) &sigset2, SIGUSR2); - - memset ((void *) &act, 0, sizeof (act)); - act.sa_handler = sighandler; - sigaction (SIGTERM, (struct sigaction *) &act, NULL); - - test_setjmp (); - test_sigsetjmp (); - - /* _setjmp() MUST NOT change signal mask: */ - sigprocmask (SIG_SETMASK, (sigset_t *) &sigset1, NULL); - if (_setjmp (jbuf)) - { - sigemptyset ((sigset_t *) &sigset3); - sigprocmask (SIG_BLOCK, NULL, (sigset_t *) &sigset3); - if (memcmp ((sigset_t *) &sigset3, (sigset_t *) &sigset2, - sizeof (sigset_t)) != 0) - { - fprintf (stderr, "FAILURE: _longjmp() manipulated signal mask!\n"); - ++nerrors; - } - else if (verbose) - printf ("OK: _longjmp() seems not to change signal mask\n"); - } - else - { - sigprocmask (SIG_SETMASK, (sigset_t *) &sigset2, NULL); - _longjmp (jbuf, 1); - } - - /* sigsetjmp(jbuf, 1) MUST preserve signal mask: */ - sigprocmask (SIG_SETMASK, (sigset_t *) &sigset1, NULL); - if (sigsetjmp (sigjbuf, 1)) - { - sigemptyset ((sigset_t *) &sigset3); - sigprocmask (SIG_BLOCK, NULL, (sigset_t *) &sigset3); - if (memcmp ((sigset_t *) &sigset3, (sigset_t *) &sigset1, - sizeof (sigset_t)) != 0) - { - fprintf (stderr, - "FAILURE: siglongjmp() didn't restore signal mask!\n"); - ++nerrors; - } - else if (verbose) - printf ("OK: siglongjmp() restores signal mask when asked to\n"); - } - else - { - sigprocmask (SIG_SETMASK, (sigset_t *) &sigset2, NULL); - siglongjmp (sigjbuf, 1); - } - - /* sigsetjmp(jbuf, 0) MUST NOT preserve signal mask: */ - sigprocmask (SIG_SETMASK, (sigset_t *) &sigset1, NULL); - if (sigsetjmp (sigjbuf, 0)) - { - sigemptyset ((sigset_t *) &sigset3); - sigprocmask (SIG_BLOCK, NULL, (sigset_t *) &sigset3); - if (memcmp ((sigset_t *) &sigset3, (sigset_t *) &sigset2, - sizeof (sigset_t)) != 0) - { - fprintf (stderr, - "FAILURE: siglongjmp() changed signal mask!\n"); - ++nerrors; - } - else if (verbose) - printf ("OK: siglongjmp() leaves signal mask alone when asked to\n"); - } - else - { - sigprocmask (SIG_SETMASK, (sigset_t *) &sigset2, NULL); - siglongjmp (sigjbuf, 1); - } - - /* sigsetjmp(jbuf, 1) MUST preserve signal mask: */ - sigprocmask (SIG_SETMASK, (sigset_t *) &sigset1, NULL); - if (sigsetjmp (sigjbuf, 1)) - { - sigemptyset ((sigset_t *) &sigset3); - sigprocmask (SIG_BLOCK, NULL, (sigset_t *) &sigset3); - if (memcmp ((sigset_t *) &sigset3, (sigset_t *) &sigset1, - sizeof (sigset_t)) != 0) - { - fprintf (stderr, - "FAILURE: siglongjmp() didn't restore signal mask!\n"); - ++nerrors; - } - else if (verbose) - printf ("OK: siglongjmp() restores signal mask when asked to\n"); - } - else - { - sigprocmask (SIG_SETMASK, (sigset_t *) &sigset2, NULL); - kill (getpid (), SIGTERM); - fprintf (stderr, "FAILURE: unexpected return from kill()\n"); - ++nerrors; - } - - /* sigsetjmp(jbuf, 0) MUST NOT preserve signal mask: */ - sigprocmask (SIG_SETMASK, (sigset_t *) &sigset1, NULL); - if (sigsetjmp (sigjbuf, 0)) - { - sigemptyset ((sigset_t *) &sigset3); - sigprocmask (SIG_BLOCK, NULL, (sigset_t *) &sigset3); - if (memcmp ((sigset_t *) &sigset3, (sigset_t *) &sigset4, - sizeof (sigset_t)) != 0) - { - fprintf (stderr, - "FAILURE: siglongjmp() changed signal mask!\n"); - ++nerrors; - } - else if (verbose) - printf ("OK: siglongjmp() leaves signal mask alone when asked to\n"); - } - else - { - sigprocmask (SIG_SETMASK, (sigset_t *) &sigset2, NULL); - kill (getpid (), SIGTERM); - fprintf (stderr, "FAILURE: unexpected return from kill()\n"); - ++nerrors; - } - - if (nerrors > 0) - { - fprintf (stderr, "FAILURE: detected %d failures\n", nerrors); - exit (-1); - } - if (verbose) - printf ("SUCCESS\n"); - return 0; -} diff --git a/src/pal/src/libunwind/tests/test-static-link-gen.c b/src/pal/src/libunwind/tests/test-static-link-gen.c deleted file mode 100644 index d61e7a51c..000000000 --- a/src/pal/src/libunwind/tests/test-static-link-gen.c +++ /dev/null @@ -1,74 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -Copyright (c) 2003 Hewlett-Packard Co. - -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. */ - -#include - -#include - -extern int verbose; - -static void *funcs[] = - { - (void *) &unw_get_reg, - (void *) &unw_get_fpreg, - (void *) &unw_set_reg, - (void *) &unw_set_fpreg, - (void *) &unw_resume, - (void *) &unw_create_addr_space, - (void *) &unw_destroy_addr_space, - (void *) &unw_get_accessors, - (void *) &unw_flush_cache, - (void *) &unw_set_caching_policy, - (void *) &unw_set_cache_size, - (void *) &unw_regname, - (void *) &unw_get_proc_info, - (void *) &unw_get_save_loc, - (void *) &unw_is_signal_frame, - (void *) &unw_get_proc_name - }; - -int -test_generic (void) -{ - if (verbose) - printf (__FILE__": funcs[0]=%p\n", funcs[0]); - -#ifndef UNW_REMOTE_ONLY - { - unw_context_t uc; - unw_cursor_t c; - - unw_getcontext (&uc); - unw_init_local (&c, &uc); - unw_init_remote (&c, unw_local_addr_space, &uc); - - return unw_step (&c); - } -#else - return 0; -#endif -} diff --git a/src/pal/src/libunwind/tests/test-static-link-loc.c b/src/pal/src/libunwind/tests/test-static-link-loc.c deleted file mode 100644 index 1c7aa0378..000000000 --- a/src/pal/src/libunwind/tests/test-static-link-loc.c +++ /dev/null @@ -1,102 +0,0 @@ -/* libunwind - a platform-independent unwind library - Copyright (C) 2004 Hewlett-Packard Co - Contributed by David Mosberger-Tang - -This file is part of libunwind. - -Copyright (c) 2003 Hewlett-Packard Co. - -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. */ - -/* The purpose of this program is simply to link in all libunwind-API - functions both in their local-only and generic variants and to make - sure that the final result can be linked statically. */ - -#include - -#define UNW_LOCAL_ONLY -#include -#include "compiler.h" - -extern int test_generic (void); - -int verbose; - -#ifdef UNW_REMOTE_ONLY - -int -test_local (void) -{ - return 0; -} - -#else /* !UNW_REMOTE_ONLY */ - -static void *funcs[] = - { - (void *) &unw_get_reg, - (void *) &unw_get_fpreg, - (void *) &unw_set_reg, - (void *) &unw_set_fpreg, - (void *) &unw_resume, - (void *) &unw_create_addr_space, - (void *) &unw_destroy_addr_space, - (void *) &unw_get_accessors, - (void *) &unw_flush_cache, - (void *) &unw_set_caching_policy, - (void *) &unw_set_cache_size, - (void *) &unw_regname, - (void *) &unw_get_proc_info, - (void *) &unw_get_save_loc, - (void *) &unw_is_signal_frame, - (void *) &unw_get_proc_name, - (void *) &_U_dyn_register, - (void *) &_U_dyn_cancel - }; - -int -test_local (void) -{ - unw_context_t uc; - unw_cursor_t c; - - if (verbose) - printf (__FILE__": funcs[0]=%p\n", funcs[0]); - - unw_getcontext (&uc); - unw_init_local (&c, &uc); - unw_init_remote (&c, unw_local_addr_space, &uc); - return unw_step (&c); -} - -#endif /* !UNW_REMOTE_ONLY */ - -int -main (int argc, char **argv UNUSED) -{ - if (argc > 1) - verbose = 1; - - if (test_local () < 0) - return -1; - if (test_generic () < 0) - return -1; - return 0; -} diff --git a/src/pal/src/libunwind/tests/test-strerror.c b/src/pal/src/libunwind/tests/test-strerror.c deleted file mode 100644 index f7ae61ed1..000000000 --- a/src/pal/src/libunwind/tests/test-strerror.c +++ /dev/null @@ -1,18 +0,0 @@ -#include "compiler.h" -#include -#include - -int -main (int argc, char **argv UNUSED) -{ - int i, verbose = argc > 1; - const char *msg; - - for (i = 0; i < 16; ++i) - { - msg = unw_strerror (-i); - if (verbose) - printf ("%6d -> %s\n", -i, msg); - } - return 0; -} diff --git a/src/pal/src/loader/module.cpp b/src/pal/src/loader/module.cpp index f73adfa56..097a7bde9 100644 --- a/src/pal/src/loader/module.cpp +++ b/src/pal/src/loader/module.cpp @@ -34,7 +34,6 @@ SET_DEFAULT_DEBUG_CHANNEL(LOADER); // some headers have code with asserts, so do #include "pal/modulename.h" #include "pal/environ.h" #include "pal/virtual.h" -#include "pal/map.hpp" #include "pal/stackstring.hpp" #include @@ -90,7 +89,7 @@ CRITICAL_SECTION module_critsec; MODSTRUCT exe_module; MODSTRUCT *pal_module = nullptr; -char * g_szCoreCLRPath = nullptr; +char *g_szPalLibraryPath = nullptr; int MaxWCharToAcpLength = 3; @@ -401,28 +400,6 @@ FreeLibrary( return retval; } -/*++ -Function: - FreeLibraryAndExitThread - -See MSDN doc. - ---*/ -PALIMPORT -VOID -PALAPI -FreeLibraryAndExitThread( - IN HMODULE hLibModule, - IN DWORD dwExitCode) -{ - PERF_ENTRY(FreeLibraryAndExitThread); - ENTRY("FreeLibraryAndExitThread()\n"); - FreeLibrary(hLibModule); - ExitThread(dwExitCode); - LOGEXIT("FreeLibraryAndExitThread\n"); - PERF_EXIT(FreeLibraryAndExitThread); -} - /*++ Function: GetModuleFileNameA @@ -720,82 +697,6 @@ PAL_UnregisterModule( PERF_EXIT(PAL_UnregisterModule); } -/*++ - PAL_LOADLoadPEFile - - Map a PE format file into memory like Windows LoadLibrary() would do. - Doesn't apply base relocations if the function is relocated. - -Parameters: - IN hFile - file to map - -Return value: - non-NULL - the base address of the mapped image - NULL - error, with last error set. ---*/ -void * -PALAPI -PAL_LOADLoadPEFile(HANDLE hFile) -{ - ENTRY("PAL_LOADLoadPEFile (hFile=%p)\n", hFile); - - void * loadedBase = MAPMapPEFile(hFile); - -#ifdef _DEBUG - if (loadedBase != nullptr) - { - char* envVar = EnvironGetenv("PAL_ForcePEMapFailure"); - if (envVar) - { - if (strlen(envVar) > 0) - { - TRACE("Forcing failure of PE file map, and retry\n"); - PAL_LOADUnloadPEFile(loadedBase); // unload it - loadedBase = MAPMapPEFile(hFile); // load it again - } - - free(envVar); - } - } -#endif // _DEBUG - - LOGEXIT("PAL_LOADLoadPEFile returns %p\n", loadedBase); - return loadedBase; -} - -/*++ - PAL_LOADUnloadPEFile - - Unload a PE file that was loaded by PAL_LOADLoadPEFile(). - -Parameters: - IN ptr - the file pointer returned by PAL_LOADLoadPEFile() - -Return value: - TRUE - success - FALSE - failure (incorrect ptr, etc.) ---*/ -BOOL -PALAPI -PAL_LOADUnloadPEFile(void * ptr) -{ - BOOL retval = FALSE; - - ENTRY("PAL_LOADUnloadPEFile (ptr=%p)\n", ptr); - - if (nullptr == ptr) - { - ERROR( "Invalid pointer value\n" ); - } - else - { - retval = MAPUnmapPEFile(ptr); - } - - LOGEXIT("PAL_LOADUnloadPEFile returns %d\n", retval); - return retval; -} - /*++ PAL_GetSymbolModuleBase @@ -907,6 +808,14 @@ BOOL LOADInitializeModules() exe_module.pDllMain = nullptr; exe_module.hinstance = nullptr; exe_module.threadLibCalls = TRUE; + + // Initialize g_szPalLibraryPath + MODSTRUCT *module = LOADGetPalLibrary(); + if (!module) + { + ERROR("Can not load the PAL module\n"); + return FALSE; + } return TRUE; } @@ -1000,12 +909,6 @@ void LOADCallDllMain(DWORD dwReason, LPVOID lpReserved) BOOL InLoadOrder = TRUE; /* true if in load order, false for reverse */ CPalThread *pThread; - pThread = InternalGetCurrentThread(); - if (UserCreatedThread != pThread->GetThreadType()) - { - return; - } - /* Validate dwReason */ switch(dwReason) { @@ -1071,13 +974,6 @@ static BOOL LOADFreeLibrary(MODSTRUCT *module, BOOL fCallDllMain) LockModuleList(); - if (terminator) - { - /* PAL shutdown is in progress - ignore FreeLibrary calls */ - retval = TRUE; - goto done; - } - if (!LOADValidateModule(module)) { TRACE("Can't free invalid module %p\n", module); @@ -1174,44 +1070,28 @@ static BOOL LOADCallDllMainSafe(MODSTRUCT *module, DWORD dwReason, LPVOID lpRese /* reset ENTRY nesting level back to zero while inside the callback... */ int old_level = DBG_change_entrylevel(0); #endif /* _ENABLE_DEBUG_MESSAGES_ */ - - struct Param - { - MODSTRUCT *module; - DWORD dwReason; - LPVOID lpReserved; - BOOL ret; - } param; - param.module = module; - param.dwReason = dwReason; - param.lpReserved = lpReserved; - param.ret = FALSE; - PAL_TRY(Param *, pParam, ¶m) + BOOL ret; + + PAL_CPP_TRY { - TRACE("Calling DllMain (%p) for module %S\n", - pParam->module->pDllMain, - pParam->module->lib_name ? pParam->module->lib_name : W16_NULLSTRING); - + TRACE("Calling DllMain (%p) for module %S\n", module->pDllMain, module->lib_name ? module->lib_name : W16_NULLSTRING); { - // This module may be foreign to our PAL, so leave our PAL. - // If it depends on us, it will re-enter. - PAL_LeaveHolder holder; - pParam->ret = pParam->module->pDllMain(pParam->module->hinstance, pParam->dwReason, pParam->lpReserved); + ret = module->pDllMain(module->hinstance, dwReason, lpReserved); } } - PAL_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + PAL_CPP_CATCH_ALL { WARN("Call to DllMain (%p) got an unhandled exception; ignoring.\n", module->pDllMain); } - PAL_ENDTRY + PAL_CPP_ENDTRY #if _ENABLE_DEBUG_MESSAGES_ /* ...and set nesting level back to what it was */ DBG_change_entrylevel(old_level); #endif /* _ENABLE_DEBUG_MESSAGES_ */ - return param.ret; + return ret; } /*++ @@ -1232,13 +1112,6 @@ DisableThreadLibraryCalls( LockModuleList(); - if (terminator) - { - /* PAL shutdown in progress - ignore DisableThreadLibraryCalls */ - ret = TRUE; - goto done; - } - module = (MODSTRUCT *) hLibModule; if (!LOADValidateModule(module)) @@ -1668,35 +1541,6 @@ static HMODULE LOADLoadLibrary(LPCSTR shortAsciiName, BOOL fDynamic) return module; } -/*++ - LOADInitializeCoreCLRModule - - Run the initialization methods for CoreCLR module (the module containing this PAL). - -Parameters: - None - -Return value: - TRUE if successful - FALSE if failure ---*/ -BOOL LOADInitializeCoreCLRModule() -{ - MODSTRUCT *module = LOADGetPalLibrary(); - if (!module) - { - ERROR("Can not load the PAL module\n"); - return FALSE; - } - PDLLMAIN pRuntimeDllMain = (PDLLMAIN)dlsym(module->dl_handle, "CoreDllMain"); - if (!pRuntimeDllMain) - { - ERROR("Can not find the CoreDllMain entry point\n"); - return FALSE; - } - return pRuntimeDllMain(module->hinstance, DLL_PROCESS_ATTACH, nullptr); -} - /*++ Function : LOADGetPalLibrary @@ -1714,9 +1558,7 @@ MODSTRUCT *LOADGetPalLibrary() { if (pal_module == nullptr) { - // Initialize the pal module (the module containing LOADGetPalLibrary). Assumes that - // the PAL is linked into the coreclr module because we use the module name containing - // this function for the coreclr path. + // Initialize the pal module (the module containing LOADGetPalLibrary). TRACE("Loading module for PAL library\n"); Dl_info info; @@ -1727,18 +1569,18 @@ MODSTRUCT *LOADGetPalLibrary() } // Stash a copy of the CoreCLR installation path in a global variable. // Make sure it's terminated with a slash. - if (g_szCoreCLRPath == nullptr) + if (g_szPalLibraryPath == nullptr) { - size_t cbszCoreCLRPath = strlen(info.dli_fname) + 1; - g_szCoreCLRPath = (char*) InternalMalloc(cbszCoreCLRPath); + size_t cbPath = strlen(info.dli_fname) + 1; + g_szPalLibraryPath = (char*) InternalMalloc(cbPath); - if (g_szCoreCLRPath == nullptr) + if (g_szPalLibraryPath == nullptr) { ERROR("LOADGetPalLibrary: InternalMalloc failed!"); goto exit; } - if (strcpy_s(g_szCoreCLRPath, cbszCoreCLRPath, info.dli_fname) != SAFECRT_SUCCESS) + if (strcpy_s(g_szPalLibraryPath, cbPath, info.dli_fname) != SAFECRT_SUCCESS) { ERROR("LOADGetPalLibrary: strcpy_s failed!"); goto exit; diff --git a/src/pal/src/locale/unicode.cpp b/src/pal/src/locale/unicode.cpp index 05e916efc..6e33c2683 100644 --- a/src/pal/src/locale/unicode.cpp +++ b/src/pal/src/locale/unicode.cpp @@ -792,7 +792,7 @@ EXIT: return retval; } -extern char * g_szCoreCLRPath; +extern char* g_szPalLibraryPath; /*++ Function : @@ -806,16 +806,16 @@ PALAPI PAL_BindResources(IN LPCSTR lpDomain) { #if HAVE_LIBINTL_H - _ASSERTE(g_szCoreCLRPath != NULL); + _ASSERTE(g_szPalLibraryPath != NULL); char * coreCLRDirectoryPath; PathCharString coreCLRDirectoryPathPS; - int len = strlen(g_szCoreCLRPath); + int len = strlen(g_szPalLibraryPath); coreCLRDirectoryPath = coreCLRDirectoryPathPS.OpenStringBuffer(len); if (NULL == coreCLRDirectoryPath) { return FALSE; } - DWORD size = FILEGetDirectoryFromFullPathA(g_szCoreCLRPath, len, coreCLRDirectoryPath); + DWORD size = FILEGetDirectoryFromFullPathA(g_szPalLibraryPath, len, coreCLRDirectoryPath); coreCLRDirectoryPathPS.CloseBuffer(size); LPCSTR boundPath = bindtextdomain(lpDomain, coreCLRDirectoryPath); diff --git a/src/pal/src/map/map.cpp b/src/pal/src/map/map.cpp index 4a435f8ce..1efd38935 100644 --- a/src/pal/src/map/map.cpp +++ b/src/pal/src/map/map.cpp @@ -70,7 +70,6 @@ static BOOL MAPIsRequestPermissible( DWORD, CFileProcessLocalData * ); static BOOL MAPContainsInvalidFlags( DWORD ); static DWORD MAPConvertProtectToAccess( DWORD ); static INT MAPFileMapToMmapFlags( DWORD ); -static DWORD MAPMmapProtToAccessFlags( int prot ); #if ONE_SHARED_MAPPING_PER_FILEREGION_PER_PROCESS static NativeMapHolder * NewNativeMapHolder(CPalThread *pThread, LPVOID address, SIZE_T size, SIZE_T offset, long init_ref_count); @@ -80,28 +79,6 @@ static PMAPPED_VIEW_LIST FindSharedMappingReplacement(CPalThread *pThread, dev_t SIZE_T size, SIZE_T offset); #endif -static PAL_ERROR -MAPRecordMapping( - IPalObject *pMappingObject, - void *pPEBaseAddress, - void *addr, - size_t len, - int prot - ); - -static PAL_ERROR -MAPmmapAndRecord( - IPalObject *pMappingObject, - void *pPEBaseAddress, - void *addr, - size_t len, - int prot, - int flags, - int fd, - off_t offset, - LPVOID *ppvBaseAddress - ); - #if !HAVE_MMAP_DEV_ZERO /* We need MAP_ANON. However on some platforms like HP-UX, it is defined as MAP_ANONYMOUS */ #if !defined(MAP_ANON) && defined(MAP_ANONYMOUS) @@ -1682,41 +1659,6 @@ static INT MAPFileMapToMmapFlags( DWORD flags ) return -1; } -/*++ -Function : - MAPMmapProtToAccessFlags - - Converts unix protection flags to file access flags. - We ignore PROT_EXEC. ---*/ -static DWORD MAPMmapProtToAccessFlags( int prot ) -{ - DWORD flAccess = 0; // default: no access - - if (PROT_NONE == prot) - { - flAccess = 0; - } - else if ( ((PROT_READ | PROT_WRITE) & prot) == (PROT_READ | PROT_WRITE) ) - { - flAccess = FILE_MAP_ALL_ACCESS; - } - else if ( (PROT_WRITE & prot) == PROT_WRITE ) - { - flAccess = FILE_MAP_WRITE; - } - else if ( (PROT_READ & prot) == PROT_READ ) - { - flAccess = FILE_MAP_READ; - } - else - { - ASSERT( "Unknown Unix protection flag\n" ); - } - - return flAccess; -} - /*++ Function : @@ -2099,559 +2041,3 @@ static LONG NativeMapHolderRelease(CPalThread *pThread, NativeMapHolder * thisNM #endif // ONE_SHARED_MAPPING_PER_FILEREGION_PER_PROCESS -// Record a mapping in the MappedViewList list. -// This call assumes the mapping_critsec has already been taken. -static PAL_ERROR -MAPRecordMapping( - IPalObject *pMappingObject, - void *pPEBaseAddress, - void *addr, - size_t len, - int prot - ) -{ - if (pPEBaseAddress == NULL) - { - return ERROR_INTERNAL_ERROR; - } - - PAL_ERROR palError = NO_ERROR; - PMAPPED_VIEW_LIST pNewView; - pNewView = (PMAPPED_VIEW_LIST)InternalMalloc(sizeof(*pNewView)); - if (NULL != pNewView) - { - pNewView->lpAddress = addr; - pNewView->NumberOfBytesToMap = len; - pNewView->dwDesiredAccess = MAPMmapProtToAccessFlags(prot); - pMappingObject->AddReference(); - pNewView->pFileMapping = pMappingObject; - pNewView->lpPEBaseAddress = pPEBaseAddress; - InsertTailList(&MappedViewList, &pNewView->Link); - - TRACE_(LOADER)("Added address %p, size 0x%x, to the mapped file list.\n", addr, len); - } - else - { - palError = ERROR_INTERNAL_ERROR; - } - - return palError; -} - -// Do the actual mmap() call, and record the mapping in the MappedViewList list. -// This call assumes the mapping_critsec has already been taken. -static PAL_ERROR -MAPmmapAndRecord( - IPalObject *pMappingObject, - void *pPEBaseAddress, - void *addr, - size_t len, - int prot, - int flags, - int fd, - off_t offset, - LPVOID *ppvBaseAddress - ) -{ - _ASSERTE(pPEBaseAddress != NULL); - - PAL_ERROR palError = NO_ERROR; - LPVOID pvBaseAddress = NULL; - - off_t adjust = offset & (GetVirtualPageSize() - 1); - - pvBaseAddress = mmap(static_cast(addr) - adjust, len + adjust, prot, flags, fd, offset - adjust); - if (MAP_FAILED == pvBaseAddress) - { - ERROR_(LOADER)( "mmap failed with code %d: %s.\n", errno, strerror( errno ) ); - palError = FILEGetLastErrorFromErrno(); - } - else - { - palError = MAPRecordMapping(pMappingObject, pPEBaseAddress, pvBaseAddress, len, prot); - if (NO_ERROR != palError) - { - if (-1 == munmap(pvBaseAddress, len)) - { - ERROR_(LOADER)("Unable to unmap the file. Expect trouble.\n"); - } - } - else - { - *ppvBaseAddress = pvBaseAddress; - } - } - - return palError; -} - -/*++ - MAPMapPEFile - - - Map a PE format file into memory like Windows LoadLibrary() would do. - Doesn't apply base relocations if the function is relocated. - -Parameters: - IN hFile - file to map - -Return value: - non-NULL - the base address of the mapped image - NULL - error, with last error set. ---*/ - -void * MAPMapPEFile(HANDLE hFile) -{ - PAL_ERROR palError = 0; - IPalObject *pFileObject = NULL; - IDataLock *pLocalDataLock = NULL; - CFileProcessLocalData *pLocalData = NULL; - CPalThread *pThread = InternalGetCurrentThread(); - void * loadedBase = NULL; - IMAGE_DOS_HEADER * loadedHeader = NULL; - void * retval; -#if _DEBUG - bool forceRelocs = false; - char* envVar; -#endif - - ENTRY("MAPMapPEFile (hFile=%p)\n", hFile); - - //Step 0: Verify values, find internal pal data structures. - if (INVALID_HANDLE_VALUE == hFile) - { - ERROR_(LOADER)( "Invalid file handle\n" ); - palError = ERROR_INVALID_HANDLE; - goto done; - } - - palError = g_pObjectManager->ReferenceObjectByHandle( - pThread, - hFile, - &aotFile, - GENERIC_READ, - &pFileObject - ); - if (NO_ERROR != palError) - { - ERROR_(LOADER)( "ReferenceObjectByHandle failed\n" ); - goto done; - } - - palError = pFileObject->GetProcessLocalData( - pThread, - ReadLock, - &pLocalDataLock, - reinterpret_cast(&pLocalData) - ); - if (NO_ERROR != palError) - { - ERROR_(LOADER)( "GetProcessLocalData failed\n" ); - goto done; - } - - int fd; - fd = pLocalData->unix_fd; - //Step 1: Read the PE headers and reserve enough space for the whole image somewhere. - IMAGE_DOS_HEADER dosHeader; - IMAGE_NT_HEADERS ntHeader; - errno = 0; - if (0 != lseek(fd, 0, SEEK_SET)) - { - palError = FILEGetLastErrorFromErrno(); - ERROR_(LOADER)( "lseek failed\n" ); - goto done; - } - if (sizeof(dosHeader) != read(fd, &dosHeader, sizeof(dosHeader))) - { - palError = FILEGetLastErrorFromErrno(); - ERROR_(LOADER)( "reading dos header failed\n" ); - goto done; - } - if (dosHeader.e_lfanew != lseek(fd, dosHeader.e_lfanew, SEEK_SET)) - { - palError = FILEGetLastErrorFromErrno(); - goto done; - } - if (sizeof(ntHeader) != read(fd, &ntHeader, sizeof(ntHeader))) - { - palError = FILEGetLastErrorFromErrno(); - goto done; - } - - if ((VAL16(IMAGE_DOS_SIGNATURE) != VAL16(dosHeader.e_magic)) - || (VAL32(IMAGE_NT_SIGNATURE) != VAL32(ntHeader.Signature)) - || (VAL16(IMAGE_NT_OPTIONAL_HDR_MAGIC) != VAL16(ntHeader.OptionalHeader.Magic) ) ) - { - ERROR_(LOADER)( "Magic number mismatch\n" ); - palError = ERROR_INVALID_PARAMETER; - goto done; - } - - //This doesn't read the entire NT header (the optional header technically has a variable length. But I - //don't need more directories. - - //I now know how big the file is. Reserve enough address space for the whole thing. Try to get the - //preferred base. Create the intial mapping as "no access". We'll use that for the guard pages in the - //"holes" between sections. - SIZE_T preferredBase, virtualSize; - preferredBase = ntHeader.OptionalHeader.ImageBase; - virtualSize = ntHeader.OptionalHeader.SizeOfImage; - - // Validate the image header - if ( (preferredBase == 0) - || (virtualSize == 0) - || (preferredBase + virtualSize < preferredBase) // Does the image overflow? - ) - { - ERROR_(LOADER)( "image is corrupt\n" ); - palError = ERROR_INVALID_PARAMETER; - goto done; - } - -#if _DEBUG - envVar = EnvironGetenv("PAL_ForceRelocs"); - if (envVar) - { - if (strlen(envVar) > 0) - { - forceRelocs = true; - TRACE_(LOADER)("Forcing rebase of image\n"); - } - - free(envVar); - } - - void * pForceRelocBase; - pForceRelocBase = NULL; - if (forceRelocs) - { - //if we're forcing relocs, create an anonymous mapping at the preferred base. Only create the - //mapping if we can create it at the specified address. - pForceRelocBase = mmap( (void*)preferredBase, GetVirtualPageSize(), PROT_NONE, MAP_ANON|MAP_FIXED|MAP_PRIVATE, -1, 0 ); - if (pForceRelocBase == MAP_FAILED) - { - TRACE_(LOADER)("Attempt to take preferred base of %p to force relocation failed\n", (void*)preferredBase); - forceRelocs = false; - } - else if ((void*)preferredBase != pForceRelocBase) - { - TRACE_(LOADER)("Attempt to take preferred base of %p to force relocation failed; actually got %p\n", (void*)preferredBase, pForceRelocBase); - } - } -#endif // _DEBUG - - // The first mmap mapping covers the entire file but just reserves space. Subsequent mappings cover - // individual parts of the file, and actually map pages in. Note that according to the mmap() man page, "A - // successful mmap deletes any previous mapping in the allocated address range." Also, "If a MAP_FIXED - // request is successful, the mapping established by mmap() replaces any previous mappings for the process' pages - // in the range from addr to addr + len." Thus, we will record a series of mappings here, one for the header - // and each of the sections, as well as all the space between them that we give PROT_NONE protections. - - // We're going to start adding mappings to the mapping list, so take the critical section - InternalEnterCriticalSection(pThread, &mapping_critsec); - -#ifdef BIT64 - // First try to reserve virtual memory using ExecutableAllcator. This allows all PE images to be - // near each other and close to the coreclr library which also allows the runtime to generate - // more efficient code (by avoiding usage of jump stubs). Alignment to a 64 KB granularity should - // not be necessary (alignment to page size should be sufficient), but see - // ExecutableMemoryAllocator::AllocateMemory() for the reason why it is done. - loadedBase = ReserveMemoryFromExecutableAllocator(pThread, ALIGN_UP(virtualSize, VIRTUAL_64KB)); -#endif // BIT64 - - if (loadedBase == NULL) - { - // MAC64 requires we pass MAP_SHARED (or MAP_PRIVATE) flags - otherwise, the call is failed. - // Refer to mmap documentation at http://www.manpagez.com/man/2/mmap/ for details. - loadedBase = mmap(NULL, virtualSize, PROT_NONE, MAP_ANON|MAP_PRIVATE, -1, 0); - } - - if (MAP_FAILED == loadedBase) - { - ERROR_(LOADER)( "mmap failed with code %d: %s.\n", errno, strerror( errno ) ); - palError = FILEGetLastErrorFromErrno(); - loadedBase = NULL; // clear it so we don't try to use it during clean-up - goto doneReleaseMappingCriticalSection; - } - - // All subsequent mappings of the PE file will be in the range [loadedBase, loadedBase + virtualSize) - -#if _DEBUG - if (forceRelocs) - { - _ASSERTE(((SIZE_T)loadedBase) != preferredBase); - munmap(pForceRelocBase, GetVirtualPageSize()); // now that we've forced relocation, let the original address mapping go - } - if (((SIZE_T)loadedBase) != preferredBase) - { - TRACE_(LOADER)("Image rebased from preferredBase of %p to loadedBase of %p\n", preferredBase, loadedBase); - } - else - { - TRACE_(LOADER)("Image loaded at preferred base %p\n", loadedBase); - } -#endif // _DEBUG - - //we have now reserved memory (potentially we got rebased). Walk the PE sections and map each part - //separately. - - size_t headerSize; - headerSize = GetVirtualPageSize(); // if there are lots of sections, this could be wrong - - //first, map the PE header to the first page in the image. Get pointers to the section headers - palError = MAPmmapAndRecord(pFileObject, loadedBase, - loadedBase, headerSize, PROT_READ, MAP_FILE|MAP_PRIVATE|MAP_FIXED, fd, 0, - (void**)&loadedHeader); - if (NO_ERROR != palError) - { - ERROR_(LOADER)( "mmap of PE header failed\n" ); - goto doneReleaseMappingCriticalSection; - } - - TRACE_(LOADER)("PE header loaded @ %p\n", loadedHeader); - _ASSERTE(loadedHeader == loadedBase); // we already preallocated the space, and we used MAP_FIXED, so we should have gotten this address - IMAGE_SECTION_HEADER * firstSection; - firstSection = (IMAGE_SECTION_HEADER*)(((char *)loadedHeader) - + loadedHeader->e_lfanew - + offsetof(IMAGE_NT_HEADERS, OptionalHeader) - + VAL16(ntHeader.FileHeader.SizeOfOptionalHeader)); - unsigned numSections; - numSections = ntHeader.FileHeader.NumberOfSections; - - // Validation - char* sectionHeaderEnd; - sectionHeaderEnd = (char*)firstSection + numSections * sizeof(IMAGE_SECTION_HEADER); - if ( ((void*)firstSection < loadedBase) - || ((char*)firstSection > sectionHeaderEnd) - || (sectionHeaderEnd > (char*)loadedBase + virtualSize) - ) - { - ERROR_(LOADER)( "image is corrupt\n" ); - palError = ERROR_INVALID_PARAMETER; - goto doneReleaseMappingCriticalSection; - } - - void* prevSectionEnd; - prevSectionEnd = (char*)loadedBase + headerSize; // the first "section" for our purposes is the header - for (unsigned i = 0; i < numSections; ++i) - { - //for each section, map the section of the file to the correct virtual offset. Gather the - //protection bits from the PE file and convert them to the correct mmap PROT_* flags. - void * sectionData; - int prot = 0; - IMAGE_SECTION_HEADER ¤tHeader = firstSection[i]; - - void* sectionBase = (char*)loadedBase + currentHeader.VirtualAddress; - void* sectionBaseAligned = ALIGN_DOWN(sectionBase, GetVirtualPageSize()); - - // Validate the section header - if ( (sectionBase < loadedBase) // Did computing the section base overflow? - || ((char*)sectionBase + currentHeader.SizeOfRawData < (char*)sectionBase) // Does the section overflow? - || ((char*)sectionBase + currentHeader.SizeOfRawData > (char*)loadedBase + virtualSize) // Does the section extend past the end of the image as the header stated? - || (prevSectionEnd > sectionBase) // Does this section overlap the previous one? - ) - { - ERROR_(LOADER)( "section %d is corrupt\n", i ); - palError = ERROR_INVALID_PARAMETER; - goto doneReleaseMappingCriticalSection; - } - if (currentHeader.Misc.VirtualSize > currentHeader.SizeOfRawData) - { - ERROR_(LOADER)( "no support for zero-padded sections, section %d\n", i ); - palError = ERROR_INVALID_PARAMETER; - goto doneReleaseMappingCriticalSection; - } - - // Is there space between the previous section and this one? If so, add a PROT_NONE mapping to cover it. - if (prevSectionEnd < sectionBaseAligned) - { - palError = MAPRecordMapping(pFileObject, - loadedBase, - prevSectionEnd, - (char*)sectionBaseAligned - (char*)prevSectionEnd, - PROT_NONE); - if (NO_ERROR != palError) - { - ERROR_(LOADER)( "recording gap section before section %d failed\n", i ); - goto doneReleaseMappingCriticalSection; - } - } - - //Don't discard these sections. We need them to verify PE files - //if (currentHeader.Characteristics & IMAGE_SCN_MEM_DISCARDABLE) - // continue; - if (currentHeader.Characteristics & IMAGE_SCN_MEM_EXECUTE) - prot |= PROT_EXEC; - if (currentHeader.Characteristics & IMAGE_SCN_MEM_READ) - prot |= PROT_READ; - if (currentHeader.Characteristics & IMAGE_SCN_MEM_WRITE) - prot |= PROT_WRITE; - - palError = MAPmmapAndRecord(pFileObject, loadedBase, - sectionBase, - currentHeader.SizeOfRawData, - prot, - MAP_FILE|MAP_PRIVATE|MAP_FIXED, - fd, - currentHeader.PointerToRawData, - §ionData); - if (NO_ERROR != palError) - { - ERROR_(LOADER)( "mmap of section %d failed\n", i ); - goto doneReleaseMappingCriticalSection; - } - -#if _DEBUG - { - // Ensure null termination of section name (which is allowed to not be null terminated if exactly 8 characters long) - char sectionName[9]; - sectionName[8] = '\0'; - memcpy(sectionName, currentHeader.Name, sizeof(currentHeader.Name)); - TRACE_(LOADER)("Section %d '%s' (header @ %p) loaded @ %p (RVA: 0x%x, SizeOfRawData: 0x%x, PointerToRawData: 0x%x)\n", - i, sectionName, ¤tHeader, sectionData, currentHeader.VirtualAddress, currentHeader.SizeOfRawData, currentHeader.PointerToRawData); - } -#endif // _DEBUG - - prevSectionEnd = ALIGN_UP((char*)sectionBase + currentHeader.SizeOfRawData, GetVirtualPageSize()); // round up to page boundary - } - - // Is there space after the last section and before the end of the mapped image? If so, add a PROT_NONE mapping to cover it. - char* imageEnd; - imageEnd = (char*)loadedBase + virtualSize; // actually, points just after the mapped end - if (prevSectionEnd < imageEnd) - { - palError = MAPRecordMapping(pFileObject, - loadedBase, - prevSectionEnd, - (char*)imageEnd - (char*)prevSectionEnd, - PROT_NONE); - if (NO_ERROR != palError) - { - ERROR_(LOADER)( "recording end of image gap section failed\n" ); - goto doneReleaseMappingCriticalSection; - } - } - - palError = ERROR_SUCCESS; - -doneReleaseMappingCriticalSection: - - InternalLeaveCriticalSection(pThread, &mapping_critsec); - -done: - - if (NULL != pLocalDataLock) - { - pLocalDataLock->ReleaseLock(pThread, FALSE); - } - - if (NULL != pFileObject) - { - pFileObject->ReleaseReference(pThread); - } - - if (palError == ERROR_SUCCESS) - { - retval = loadedBase; - LOGEXIT("MAPMapPEFile returns %p\n", retval); - } - else - { - retval = NULL; - LOGEXIT("MAPMapPEFile error: %d\n", palError); - - // If we had an error, and had mapped anything, we need to unmap it - if (loadedBase != NULL) - { - MAPUnmapPEFile(loadedBase); - } - } - return retval; -} - -/*++ -Function : - MAPUnmapPEFile - unmap a PE file, and remove it from the recorded list of PE files mapped - - returns TRUE if successful, FALSE otherwise ---*/ -BOOL MAPUnmapPEFile(LPCVOID lpAddress) -{ - TRACE_(LOADER)("MAPUnmapPEFile(lpAddress=%p)\n", lpAddress); - - if ( NULL == lpAddress ) - { - ERROR_(LOADER)( "lpAddress cannot be NULL\n" ); - return FALSE; - } - - BOOL retval = TRUE; - CPalThread * pThread = InternalGetCurrentThread(); - InternalEnterCriticalSection(pThread, &mapping_critsec); - PLIST_ENTRY pLink, pLinkNext, pLinkLocal = NULL; - unsigned nPESections = 0; - - // Look through the entire MappedViewList for all mappings associated with the - // PE file with base address 'lpAddress'. We want to unmap all the memory - // and then release the file mapping object. Unfortunately, based on the comment - // in CorUnix::InternalUnmapViewOfFile(), we can't release the file mapping object - // while within the mapping critical section. So, we unlink all the elements from the - // main list while in the critical section, and then run through this local list - // doing the real work after releasing the main list critical section. The order - // of the unmapping doesn't matter, so we don't fully set all the list link pointers, - // only a minimal set. - - for(pLink = MappedViewList.Flink; - pLink != &MappedViewList; - pLink = pLinkNext) - { - pLinkNext = pLink->Flink; - PMAPPED_VIEW_LIST pView = CONTAINING_RECORD(pLink, MAPPED_VIEW_LIST, Link); - - if (pView->lpPEBaseAddress == lpAddress) // this entry is associated with the PE file - { - ++nPESections; // for debugging, check that we see at least one - - RemoveEntryList(&pView->Link); - pView->Link.Flink = pLinkLocal; // the local list is singly-linked, NULL terminated - pLinkLocal = &pView->Link; - } - } - -#if _DEBUG - if (nPESections == 0) - { - ERROR_(LOADER)( "MAPUnmapPEFile called to unmap a file that was not in the PE file mapping list\n" ); - } -#endif // _DEBUG - - InternalLeaveCriticalSection(pThread, &mapping_critsec); - - // Now, outside the critical section, do the actual unmapping work - - for(pLink = pLinkLocal; - pLink != NULL; - pLink = pLinkNext) - { - pLinkNext = pLink->Flink; - PMAPPED_VIEW_LIST pView = CONTAINING_RECORD(pLink, MAPPED_VIEW_LIST, Link); - - // remove pView mapping from the list - if (-1 == munmap(pView->lpAddress, pView->NumberOfBytesToMap)) - { - // Emit an error message in a trace, but continue trying to do the rest - ERROR_(LOADER)("Unable to unmap the file. Expect trouble.\n"); - retval = FALSE; - } - - IPalObject* pFileObject = pView->pFileMapping; - if (NULL != pFileObject) - { - pFileObject->ReleaseReference(pThread); - } - free(pView); // this leaves pLink dangling - } - - TRACE_(LOADER)("MAPUnmapPEFile returning %d\n", retval); - return retval; -} diff --git a/src/pal/src/map/virtual.cpp b/src/pal/src/map/virtual.cpp index a5610efe1..926c03292 100644 --- a/src/pal/src/map/virtual.cpp +++ b/src/pal/src/map/virtual.cpp @@ -26,7 +26,6 @@ SET_DEFAULT_DEBUG_CHANNEL(VIRTUAL); // some headers have code with asserts, so d #include "pal/cs.hpp" #include "pal/malloc.hpp" #include "pal/file.hpp" -#include "pal/seh.hpp" #include "pal/virtual.h" #include "pal/map.h" #include "pal/init.h" @@ -1236,72 +1235,6 @@ done: return pRetVal; } -/*++ -Function: - PAL_VirtualReserveFromExecutableMemoryAllocatorWithinRange - - This function attempts to allocate the requested amount of memory in the specified address range, from the executable memory - allocator. If unable to do so, the function returns nullptr and does not set the last error. - - lpBeginAddress - Inclusive beginning of range - lpEndAddress - Exclusive end of range - dwSize - Number of bytes to allocate ---*/ -LPVOID -PALAPI -PAL_VirtualReserveFromExecutableMemoryAllocatorWithinRange( - IN LPCVOID lpBeginAddress, - IN LPCVOID lpEndAddress, - IN SIZE_T dwSize) -{ -#ifdef BIT64 - PERF_ENTRY(PAL_VirtualReserveFromExecutableMemoryAllocatorWithinRange); - ENTRY( - "PAL_VirtualReserveFromExecutableMemoryAllocatorWithinRange(lpBeginAddress = %p, lpEndAddress = %p, dwSize = %Iu)\n", - lpBeginAddress, - lpEndAddress, - dwSize); - - _ASSERTE(lpBeginAddress <= lpEndAddress); - - // Alignment to a 64 KB granularity should not be necessary (alignment to page size should be sufficient), but see - // ExecutableMemoryAllocator::AllocateMemory() for the reason why it is done - SIZE_T reservationSize = ALIGN_UP(dwSize, VIRTUAL_64KB); - - CPalThread *currentThread = InternalGetCurrentThread(); - InternalEnterCriticalSection(currentThread, &virtual_critsec); - - void *address = g_executableMemoryAllocator.AllocateMemoryWithinRange(lpBeginAddress, lpEndAddress, reservationSize); - if (address != nullptr) - { - _ASSERTE(IS_ALIGNED(address, GetVirtualPageSize())); - if (!VIRTUALStoreAllocationInfo((UINT_PTR)address, reservationSize, MEM_RESERVE | MEM_RESERVE_EXECUTABLE, PAGE_NOACCESS)) - { - ASSERT("Unable to store the structure in the list.\n"); - munmap(address, reservationSize); - address = nullptr; - } - } - - LogVaOperation( - VirtualMemoryLogging::VirtualOperation::ReserveFromExecutableMemoryAllocatorWithinRange, - nullptr, - dwSize, - MEM_RESERVE | MEM_RESERVE_EXECUTABLE, - PAGE_NOACCESS, - address, - TRUE); - - InternalLeaveCriticalSection(currentThread, &virtual_critsec); - - LOGEXIT("PAL_VirtualReserveFromExecutableMemoryAllocatorWithinRange returning %p\n", address); - PERF_EXIT(PAL_VirtualReserveFromExecutableMemoryAllocatorWithinRange); - return address; -#else // !BIT64 - return nullptr; -#endif // BIT64 -} - /*++ Function: VirtualAlloc diff --git a/src/pal/src/misc/jitsupport.cpp b/src/pal/src/misc/jitsupport.cpp deleted file mode 100644 index d3d4f1e5c..000000000 --- a/src/pal/src/misc/jitsupport.cpp +++ /dev/null @@ -1,132 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - - -#include "pal/palinternal.h" -#include "pal/dbgmsg.h" -SET_DEFAULT_DEBUG_CHANNEL(MISC); - -#if defined(_ARM64_) -#define _TARGET_ARM64_ -#endif - -#include "../../../inc/corjitflags.h" - -#if HAVE_AUXV_HWCAP_H -#include -#include -#endif - -PALIMPORT -VOID -PALAPI -PAL_GetJitCpuCapabilityFlags(CORJIT_FLAGS *flags) -{ - _ASSERTE(flags); - -#if defined(_ARM64_) -#if HAVE_AUXV_HWCAP_H - unsigned long hwCap = getauxval(AT_HWCAP); - - CORJIT_FLAGS &CPUCompileFlags = *flags; -// HWCAP_* flags are introduced by ARM into the Linux kernel as new extensions are published. -// For a given kernel, some of these flags may not be present yet. -// Use ifdef for each to allow for compilation with any vintage kernel. -// From a single binary distribution perspective, compiling with latest kernel asm/hwcap.h should -// include all published flags. Given flags are merged to kernel and published before silicon is -// available, using the latest kernel for release should be sufficient. -#ifdef HWCAP_AES - if (hwCap & HWCAP_AES) - CPUCompileFlags.Set(CORJIT_FLAGS::CORJIT_FLAG_HAS_ARM64_AES); -#endif -#ifdef HWCAP_ATOMICS - if (hwCap & HWCAP_ATOMICS) - CPUCompileFlags.Set(CORJIT_FLAGS::CORJIT_FLAG_HAS_ARM64_ATOMICS); -#endif -#ifdef HWCAP_CRC32 - if (hwCap & HWCAP_CRC32) - CPUCompileFlags.Set(CORJIT_FLAGS::CORJIT_FLAG_HAS_ARM64_CRC32); -#endif -#ifdef HWCAP_DCPOP - if (hwCap & HWCAP_DCPOP) - CPUCompileFlags.Set(CORJIT_FLAGS::CORJIT_FLAG_HAS_ARM64_DCPOP); -#endif -#ifdef HWCAP_ASIMDDP - if (hwCap & HWCAP_ASIMDDP) - CPUCompileFlags.Set(CORJIT_FLAGS::CORJIT_FLAG_HAS_ARM64_DP); -#endif -#ifdef HWCAP_FCMA - if (hwCap & HWCAP_FCMA) - CPUCompileFlags.Set(CORJIT_FLAGS::CORJIT_FLAG_HAS_ARM64_FCMA); -#endif -#ifdef HWCAP_FP - if (hwCap & HWCAP_FP) - CPUCompileFlags.Set(CORJIT_FLAGS::CORJIT_FLAG_HAS_ARM64_FP); -#endif -#ifdef HWCAP_FPHP - if (hwCap & HWCAP_FPHP) - CPUCompileFlags.Set(CORJIT_FLAGS::CORJIT_FLAG_HAS_ARM64_FP16); -#endif -#ifdef HWCAP_JSCVT - if (hwCap & HWCAP_JSCVT) - CPUCompileFlags.Set(CORJIT_FLAGS::CORJIT_FLAG_HAS_ARM64_JSCVT); -#endif -#ifdef HWCAP_LRCPC - if (hwCap & HWCAP_LRCPC) - CPUCompileFlags.Set(CORJIT_FLAGS::CORJIT_FLAG_HAS_ARM64_LRCPC); -#endif -#ifdef HWCAP_PMULL - if (hwCap & HWCAP_PMULL) - CPUCompileFlags.Set(CORJIT_FLAGS::CORJIT_FLAG_HAS_ARM64_PMULL); -#endif -#ifdef HWCAP_SHA1 - if (hwCap & HWCAP_SHA1) - CPUCompileFlags.Set(CORJIT_FLAGS::CORJIT_FLAG_HAS_ARM64_SHA1); -#endif -#ifdef HWCAP_SHA2 - if (hwCap & HWCAP_SHA2) - CPUCompileFlags.Set(CORJIT_FLAGS::CORJIT_FLAG_HAS_ARM64_SHA256); -#endif -#ifdef HWCAP_SHA512 - if (hwCap & HWCAP_SHA512) - CPUCompileFlags.Set(CORJIT_FLAGS::CORJIT_FLAG_HAS_ARM64_SHA512); -#endif -#ifdef HWCAP_SHA3 - if (hwCap & HWCAP_SHA3) - CPUCompileFlags.Set(CORJIT_FLAGS::CORJIT_FLAG_HAS_ARM64_SHA3); -#endif -#ifdef HWCAP_ASIMD - if (hwCap & HWCAP_ASIMD) - CPUCompileFlags.Set(CORJIT_FLAGS::CORJIT_FLAG_HAS_ARM64_SIMD); -#endif -#ifdef HWCAP_ASIMDRDM - if (hwCap & HWCAP_ASIMDRDM) - CPUCompileFlags.Set(CORJIT_FLAGS::CORJIT_FLAG_HAS_ARM64_SIMD_V81); -#endif -#ifdef HWCAP_ASIMDHP - if (hwCap & HWCAP_ASIMDHP) - CPUCompileFlags.Set(CORJIT_FLAGS::CORJIT_FLAG_HAS_ARM64_SIMD_FP16); -#endif -#ifdef HWCAP_SM3 - if (hwCap & HWCAP_SM3) - CPUCompileFlags.Set(CORJIT_FLAGS::CORJIT_FLAG_HAS_ARM64_SM3); -#endif -#ifdef HWCAP_SM4 - if (hwCap & HWCAP_SM4) - CPUCompileFlags.Set(CORJIT_FLAGS::CORJIT_FLAG_HAS_ARM64_SM4); -#endif -#ifdef HWCAP_SVE - if (hwCap & HWCAP_SVE) - CPUCompileFlags.Set(CORJIT_FLAGS::CORJIT_FLAG_HAS_ARM64_SVE); -#endif -#else // !HAVE_AUXV_HWCAP_H - // CoreCLR SIMD and FP support is included in ARM64 baseline - // On exceptional basis platforms may leave out support, but CoreCLR does not - // yet support such platforms - // Set baseline flags if OS has not exposed mechanism for us to determine CPU capabilities - CPUCompileFlags.Set(CORJIT_FLAGS::CORJIT_FLAG_HAS_ARM64_SIMD); - CPUCompileFlags.Set(CORJIT_FLAGS::CORJIT_FLAG_HAS_ARM64_FP); -#endif // HAVE_AUXV_HWCAP_H -#endif // defined(_ARM64_) -} diff --git a/src/pal/src/misc/miscpalapi.cpp b/src/pal/src/misc/miscpalapi.cpp index 27ff136a0..7ae34f78e 100644 --- a/src/pal/src/misc/miscpalapi.cpp +++ b/src/pal/src/misc/miscpalapi.cpp @@ -58,7 +58,8 @@ Function : --*/ BOOL -PAL_GetPALDirectoryW(PathWCharString& lpDirectoryName) +PAL_GetPALDirectoryW( + PathWCharString& lpDirectoryName) { LPCWSTR lpFullPathAndName = NULL; LPCWSTR lpEndPoint = NULL; @@ -108,7 +109,8 @@ EXIT: } BOOL -PAL_GetPALDirectoryA(PathCharString& lpDirectoryName) +PAL_GetPALDirectoryA( + PathCharString& lpDirectoryName) { BOOL bRet; PathWCharString directory; @@ -161,7 +163,9 @@ See rotor_pal.doc for more details. PALIMPORT BOOL PALAPI -PAL_GetPALDirectoryW( OUT LPWSTR lpDirectoryName, IN OUT UINT* cchDirectoryName ) +PAL_GetPALDirectoryW( + OUT LPWSTR lpDirectoryName, + IN OUT UINT* cchDirectoryName) { PathWCharString directory; BOOL bRet; @@ -195,8 +199,8 @@ PALIMPORT BOOL PALAPI PAL_GetPALDirectoryA( - OUT LPSTR lpDirectoryName, - IN UINT* cchDirectoryName) + OUT LPSTR lpDirectoryName, + IN OUT UINT* cchDirectoryName) { BOOL bRet; PathCharString directory; @@ -212,15 +216,13 @@ PAL_GetPALDirectoryA( { SetLastError( ERROR_INSUFFICIENT_BUFFER ); bRet = FALSE; - *cchDirectoryName = directory.GetCount(); } - else if (strcpy_s(lpDirectoryName, directory.GetCount(), directory.GetString()) == SAFECRT_SUCCESS) - { - } - else + else if (strcpy_s(lpDirectoryName, *cchDirectoryName, directory.GetString()) != SAFECRT_SUCCESS) { bRet = FALSE; } + + *cchDirectoryName = directory.GetCount(); } LOGEXIT( "PAL_GetPALDirectoryA returns BOOL %d.\n", bRet); @@ -231,8 +233,8 @@ PAL_GetPALDirectoryA( VOID PALAPI PAL_Random( - IN OUT LPVOID lpBuffer, - IN DWORD dwLength) + IN OUT LPVOID lpBuffer, + IN DWORD dwLength) { int rand_des = -1; DWORD i; diff --git a/src/pal/src/misc/msgbox.cpp b/src/pal/src/misc/msgbox.cpp index b3041b142..1af7e301a 100644 --- a/src/pal/src/misc/msgbox.cpp +++ b/src/pal/src/misc/msgbox.cpp @@ -142,7 +142,7 @@ MessageBoxW( { WARN("No message text\n"); - if (NULL == (text = PAL__strdup("(no message text)"))) + if (NULL == (text = strdup("(no message text)"))) { ASSERT("strdup() failed\n"); SetLastError( ERROR_INTERNAL_ERROR ); @@ -179,7 +179,7 @@ MessageBoxW( } else { - if (NULL == (caption = PAL__strdup("Error"))) + if (NULL == (caption = strdup("Error"))) { ERROR("strdup() failed\n"); SetLastError( ERROR_NOT_ENOUGH_MEMORY ); diff --git a/src/pal/src/misc/perftrace.cpp b/src/pal/src/misc/perftrace.cpp deleted file mode 100644 index fdefdf669..000000000 --- a/src/pal/src/misc/perftrace.cpp +++ /dev/null @@ -1,1345 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*++ - - - -Module Name: - - misc/perftrace.c - -Abstract: - Implementation of PAL Performance trace utilities. - - - ---*/ - -/* PAL headers */ - - - -#ifdef PAL_PERF - -/* PAL Headers */ -#include "pal/palinternal.h" -#include "pal/perftrace.h" -#include "pal/dbgmsg.h" -#include "pal/cruntime.h" -#include "pal/misc.h" - -/* Standard headers */ -#include -#include -#include -#include -#include /* for pthread_self */ -#include -#include - -SET_DEFAULT_DEBUG_CHANNEL(MISC); - - -#define PAL_PERF_MAX_LOGLINE 0x400 /* 1K */ -#define PAL_PERF_MAX_INPUT 0x1000 /* 4k for single line of input file */ -#define PAL_PERF_MAX_FUNCTION_NAME 128 /* any one want a function name longer than 127 bytes? */ -#define PAL_PERF_PROFILE_BUFFER_SIZE 0x400000 /* 4M */ -#define PAL_PERF_BUFFER_FULL (PAL_PERF_PROFILE_BUFFER_SIZE - PAL_PERF_MAX_LOGLINE ) /* (Buffer size - 1K) */ - -typedef struct _pal_perf_api_info -{ - ULONGLONG entries; /* number of PERF_ENTRY calls for an API function */ - ULONGLONG counter; /* number of PERF_EXIT calls for an API function */ - ULONGLONG min_duration; /* Minimum duration in CPU clock ticks in an API function */ - ULONGLONG max_duration; /* Maximum duration in CPU clock ticks in an API function */ - ULONGLONG sum_duration; /* Sum of duration*/ - double sum_of_square_duration; /* Sum of square of durations */ - DWORD *histograms; /* An array to store the histogram of an API execution cpu ticks. */ -} pal_perf_api_info; - - -typedef struct _pal_perf_thread_info -{ - DWORD threadId; - pal_perf_api_info * api_table; - char * pal_write_buf; - DWORD buf_offset; - BOOL profile_enabled; - ULONGLONG start_ticks; - ULONGLONG total_duration; -} pal_perf_thread_info; - -typedef struct _pal_thread_list_node -{ - pal_perf_thread_info * thread_info; - struct _pal_thread_list_node * next; - -} pal_thread_list_node; - -typedef struct _pal_perf_program_info -{ - char command_line[PAL_PERF_MAX_LOGLINE]; - char exe_path[PAL_PERF_MAX_LOGLINE]; - char hostname[PAL_PERF_MAX_FUNCTION_NAME]; - double cpu_clock_frequency; - ULONGLONG start_ticks; - ULONGLONG elapsed_time; /* Duration in CPU clock ticks of the program */ - ULONGLONG total_duration; /* Total CPU clock ticks of all the threads */ - ULONGLONG pal_duration; /* Total CPU clock ticks spent inside PAL */ - - pid_t process_id; - char start_time[32]; /* must be at least 26 characters */ -} pal_perf_program_info; - -typedef PAL_FILE PERF_FILE; -#define PERF_FILEFN(x) PAL_ ## x - -static ULONGLONG PERFGetTicks(); -static double PERFComputeStandardDeviation(pal_perf_api_info *api); -static void PERFPrintProgramHeaderInfo(PERF_FILE * hFile, BOOL completedExecution); -static BOOL PERFInitProgramInfo(LPWSTR command_line, LPWSTR exe_path); -static BOOL PERFReadSetting( ); -static void PERFLogFileName(PathCharString * destFileString, const char *fileName, const char *suffix, int max_length); -static void PERFlushAllLogs(); -static int PERFWriteCounters(pal_perf_api_info * table); -static BOOL PERFFlushLog(pal_perf_thread_info * local_buffer, BOOL output_header); -static void PERFUpdateApiInfo(pal_perf_api_info *api, ULONGLONG duration); -static char * PERFIsValidPath( const char * path ); -static char * PERFIsValidFile( const char * path, const char * file); - -typedef char PAL_API_NAME[PAL_PERF_MAX_FUNCTION_NAME]; - -static PAL_API_NAME API_list[PAL_API_NUMBER] ; -static pal_perf_program_info program_info; - -static pthread_key_t PERF_tlsTableKey=0 ; - -static pal_thread_list_node * process_pal_thread_list=NULL; -static BOOL pal_profile_on=FALSE; -static BOOL pal_perf_enabled=FALSE; -static char * pal_function_map=NULL; -static char * perf_default_path=NULL; -static char * traced_apis_file=NULL; -static char * enabledapis_path=NULL; -static char * profile_log_path=NULL; -static char * profile_summary_log_name=NULL; -static char * profile_time_log_name=NULL; -static BOOL summary_only=FALSE; -static BOOL nested_tracing=FALSE; -static BOOL calibrate=FALSE; - -/* If report_only_called_apis is TRUE, - those PAL APIs with no function entry or exit - will not be shown in the PAL perf summary file. */ -static BOOL report_only_called_apis=FALSE; - -/* If the wait_for_startup is TRUE, process profiling - will not start until the application - has called PAL_EnableProcessProfile(). */ -static BOOL wait_for_startup=FALSE; - -/* The size of a PAL API execution CPU ticks histogram, i.e., - Number of categories of frequency distrubution of PAL API - execution CPU ticks.*/ -static DWORD pal_perf_histogram_size = 0; - -/* The step size in CPU ticks of each category of the - PAL API execution CPU ticks histogram.*/ -static DWORD pal_perf_histogram_step = 100; - -static const char PAL_PERF_TRACING[]="PAL_PERF_TRACING"; -static const char PAL_DEFAULT_PATH[]="PAL_PERF_DEFAULT_PATH"; -static const char PAL_PERF_TRACEDAPIS_PATH[]="PAL_PERF_TRACEDAPIS_FILE"; -static const char PAL_PERF_LOG_PATH[]="PAL_PERF_LOG_PATH"; -static const char PAL_PERF_SUMMARY_LOG_NAME[]="PAL_PERF_SUMMARY_LOG_NAME"; -static const char PAL_PERF_TIME_LOG_NAME[]="PAL_PERF_TIME_LOG_NAME"; -static const char PAL_PERF_ENABLED_APIS_PATH[]="PAL_PERF_ENABLEDAPIS_FILE"; -static const char PAL_SUMMARY_FLAG[]="PAL_PERF_SUMMARY_ONLY"; -static const char PAL_PERF_NESTED_TRACING[]="PAL_PERF_NESTED_TRACING"; -static const char PAL_PERF_CALIBRATE[]="PAL_PERF_CALIBRATE"; -static const char PAL_PERF_REPORT_ONLY_CALLED_APIS[]="PAL_PERF_REPORT_ONLY_CALLED_APIS"; -static const char PAL_PERF_WAIT_FOR_STARTUP[]="PAL_PERF_WAIT_FOR_STARTUP"; -static const char PAL_PERF_HISTOGRAM_SIZE[]="PAL_PERF_HISTOGRAM_SIZE"; -static const char PAL_PERF_HISTOGRAM_STEP[]="PAL_PERF_HISTOGRAM_STEP"; -static const char traced_apis_filename[]="PerfTracedAPIs.txt"; -static const char perf_enabled_filename[]="AllPerfEnabledAPIs.txt"; -static const char PATH_SEPARATOR[] = "/"; - - - -#define LLFORMAT "%llu" - -static -ULONGLONG -PERFGetTicks(){ -#ifdef _X86_ // for BSD and Windows. - unsigned long a, d; - #ifdef _MSC_VER - __asm{ - rdtsc - mov a, eax - mov d, edx - } - #else - #undef volatile - asm volatile("rdtsc":"=a" (a), "=d" (d)); - #define volatile DoNotUseVolatileKeyword - #endif - return ((ULONGLONG)((unsigned int)(d)) << 32) | (unsigned int)(a); -#else - return 0; // on non-BSD and non-Windows, we'll return 0 for now. -#endif // _X86_ -} - -static -double -PERFComputeStandardDeviation(pal_perf_api_info *api) -{ - double n; - double sum_of_variance; - if (api->counter <= 1) - return 0.0; - n = (double) api->counter; - // Calculates standard deviation based on the entire population given as arguments. - // Same as stdevp in Excel. - sum_of_variance = (n*api->sum_of_square_duration) - (api->sum_duration*api->sum_duration); - if (sum_of_variance <= 0.0) - return 0.0; - return sqrt(sum_of_variance/(n*n)); -} - - -static -void -PERFPrintProgramHeaderInfo(PERF_FILE * hFile, BOOL completedExecution) -{ - ULONGLONG etime = 0; - ULONGLONG ttime = 0; - ULONGLONG ptime = 0; - if (completedExecution) { - etime = program_info.elapsed_time; - ttime = program_info.total_duration; - ptime = program_info.pal_duration; - } - PERF_FILEFN(fprintf)(hFile,"#LOG\tversion=1.00\n"); - - PERF_FILEFN(fprintf)(hFile, "#MACHINE\thostname=%s\tcpu_clock_frequency=%g\n", program_info.hostname, - program_info.cpu_clock_frequency); - PERF_FILEFN(fprintf)(hFile, "#PROCESS\tprocess_id=%d\ttotal_latency=" LLFORMAT "\tthread_times=" LLFORMAT "\tpal_time=" LLFORMAT "\texe_path=%s\tcommand_line=%s\tstart_time=%s", - program_info.process_id, etime, ttime, ptime, - program_info.exe_path,program_info.command_line,program_info.start_time); -} - -static -BOOL -PERFInitProgramInfo(LPWSTR command_line, LPWSTR exe_path) -{ - ULONGLONG start_tick; - struct timeval tv; - - if (WideCharToMultiByte(CP_ACP, 0, command_line, -1, - program_info.command_line, PAL_PERF_MAX_LOGLINE-1, NULL, NULL) == 0) - return FALSE; - if (WideCharToMultiByte(CP_ACP, 0, exe_path, -1, - program_info.exe_path, PAL_PERF_MAX_LOGLINE-1, NULL, NULL) == 0) - return FALSE; - - gethostname(program_info.hostname, PAL_PERF_MAX_FUNCTION_NAME); - program_info.process_id = getpid(); - - gettimeofday(&tv, NULL); - ctime_r(&tv.tv_sec, program_info.start_time); - - // estimate the cpu clock cycles - start_tick = PERFGetTicks(); - if (start_tick != 0) - { - sleep(1); - program_info.cpu_clock_frequency = (double) (PERFGetTicks() - start_tick); - } - else - { - program_info.cpu_clock_frequency = 0.0; - } - - program_info.start_ticks = 0; - program_info.elapsed_time = 0; - program_info.total_duration = 0; - program_info.pal_duration = 0; - - return TRUE; -} - -static -void -PERFCalibrationFunction() -{ - PERF_ENTRY(CalibrationFunction); - PERF_EXIT(CalibrationFunction); -} - -void -PERFCalibrate(const char* msg) -{ - ULONGLONG start_tick, cal_ticks; - int i=0; - int cal_length=100000; - - if (calibrate) { - start_tick = PERFGetTicks(); - for(i=0; ithread_info = local_info; - local_info->api_table=apiTable; - local_info->threadId = THREADSilentGetCurrentThreadId(); - - for (i = 0; i < PAL_API_NUMBER; i++) - { - apiTable[i].entries = 0; - apiTable[i].counter = 0; - apiTable[i].min_duration = _UI64_MAX; - apiTable[i].max_duration = 0; - apiTable[i].sum_duration = 0; - apiTable[i].sum_of_square_duration = 0.0; - if (pal_perf_histogram_size > 0) - { - apiTable[i].histograms = (DWORD *)PAL_malloc(pal_perf_histogram_size*sizeof(DWORD)); - if (apiTable[i].histograms == NULL) - { - ret = FALSE; - goto PERFAllocThreadInfoExit; - } - memset(apiTable[i].histograms, 0, pal_perf_histogram_size*sizeof(DWORD)); - } - else - { - apiTable[i].histograms = NULL; - } - } - - log_buf = (char * )PAL_malloc( PAL_PERF_PROFILE_BUFFER_SIZE ); - - if(log_buf == NULL) - { - ret = FALSE; - goto PERFAllocThreadInfoExit; - } - - local_info->pal_write_buf=log_buf; - local_info->buf_offset = 0; - local_info->profile_enabled = FALSE; - local_info->total_duration = 0; - local_info->start_ticks = 0; - memset(log_buf, 0, PAL_PERF_PROFILE_BUFFER_SIZE); - - if (pthread_setspecific(PERF_tlsTableKey, local_info) != 0) - ret = FALSE; - -PERFAllocThreadInfoExit: - if (ret == TRUE) - { - node->next = process_pal_thread_list; - process_pal_thread_list = node; - PERFFlushLog(local_info, TRUE); - } - else - { - if (node != NULL) - { - PAL_free(node); - } - if (local_info != NULL) - { - PAL_free(local_info); - } - if (apiTable != NULL) - { - for (i = 0; i < PAL_API_NUMBER; i++) - { - if (apiTable[i].histograms != NULL) - { - PAL_free(apiTable[i].histograms); - } - } - PAL_free(apiTable); - } - if (log_buf != NULL) - { - PAL_free(log_buf); - } - } - return ret; -} - -static -void -PERFUpdateProgramInfo(pal_perf_thread_info* local_info) -{ - int i; - - if (!local_info) return; - - // add the elapsed time to the program's total - if (local_info->total_duration == 0) - { - // this thread did not go through PERFDisableThreadProfile code - // so compute the total elapsed time for the thread here - local_info->total_duration = PERFGetTicks() - local_info->start_ticks; - } - program_info.total_duration += local_info->total_duration; - - // Add up all the time spent in PAL - if (local_info->api_table) { - for(i=0; iapi_table[i].sum_duration; - } - } -} - - -static -void -PERFlushAllLogs( ) -{ - pal_thread_list_node * current, * node; - pal_perf_api_info * table1, *table0; - int i; - node = process_pal_thread_list; - if(node == NULL || node->thread_info == NULL || node->thread_info->api_table == NULL ) // should not come here - { - return ; - } - process_pal_thread_list = process_pal_thread_list->next; - table0 = node->thread_info->api_table; - - PERFUpdateProgramInfo(node->thread_info); - - while(process_pal_thread_list) - { - current=process_pal_thread_list; - process_pal_thread_list = process_pal_thread_list->next; - if (current->thread_info) - { - if (current->thread_info->api_table) - { - table1 = current->thread_info->api_table; - for(i=0;i table1[i].min_duration) - table0[i].min_duration = table1[i].min_duration; - if (table0[i].max_duration < table1[i].max_duration) - table0[i].max_duration = table1[i].max_duration; - table0[i].sum_duration += table1[i].sum_duration; - table0[i].sum_of_square_duration += table1[i].sum_of_square_duration; - } - PERFUpdateProgramInfo(current->thread_info); - if (table1->histograms != NULL) - { - PAL_free(table1->histograms); - } - PAL_free(table1); - } - PERFFlushLog(current->thread_info, FALSE); - PAL_free(current->thread_info->pal_write_buf); - PAL_free(current->thread_info); - } - PAL_free(current); - } - PERFWriteCounters(table0); - if (table0->histograms != NULL) - { - PAL_free(table0->histograms); - } - PAL_free(table0); - PERFFlushLog(node->thread_info, FALSE); - PAL_free(node->thread_info->pal_write_buf); - PAL_free(node->thread_info); - PAL_free(node); -} - -static -void -PERFLogFileName(PathCharString& destFileString, const char *fileName, const char *suffix) -{ - const char *dir_path; - CPalThread* pThread = InternalGetCurrentThread(); - dir_path = (profile_log_path == NULL) ? "." : profile_log_path; - - destFileString.Append(dir_path, strlen(dir_path)); - destFileString.Append(PATH_SEPARATOR, strlen(PATH_SEPARATOR)); - if (fileName != NULL) - { - destFileString.Append(fileName, strlen(fileName)); - } - else - { - char buffer[33]; - char* process_id = itoa(program_info.process_id, buffer, 10); - destFileString.Append(process_id, strlen(process_id)); - destFileString.Append("_", 1); - - char* current_thread = itoa(THREADSilentGetCurrentThreadId(),buffer, 10); - destFileString.Append(current_thread, strlen( current_thread)); - destFileString.Append(suffix, strlen(suffix)); - } - -} - -static -int -PERFWriteCounters( pal_perf_api_info * table ) -{ - PathCharString fileName; - pal_perf_api_info * off; - PERF_FILE * hFile; - int i; - - off = table; - - PERFLogFileName(fileName, profile_summary_log_name, "_perf_summary.log"); - hFile = PERF_FILEFN(fopen)(fileName, "a+"); - if(hFile != NULL) - { - PERFPrintProgramHeaderInfo(hFile, TRUE); - PERF_FILEFN(fprintf)(hFile,"#api_name\tapi_id\tperf_entries\tperf_exits\tsum_of_latency\tmin_latency\tmax_latency\tstd_dev_latency\tsum_of_square_latency\n"); - for(i=0;imin_duration == _UI64_MAX) ? 0 : off->min_duration; - if (off->counter >= 1) - { - dev = PERFComputeStandardDeviation(off); - } - else - { - dev = 0.0; - } - - if (off->counter > 0 || !report_only_called_apis) - { - PERF_FILEFN(fprintf)(hFile,"%s\t%d\t" LLFORMAT "\t" LLFORMAT "\t" LLFORMAT "\t" LLFORMAT "\t" LLFORMAT "\t%g\t%g\n", - API_list[i], i, off->entries, off->counter,off->sum_duration, - min_duration, off->max_duration, dev, off->sum_of_square_duration); - } - - off++; - } - } - else - { - return -1; - } - PERF_FILEFN(fclose)(hFile); - - if (pal_perf_histogram_size > 0) - { - off = table; - PERFLogFileName(fileName, profile_summary_log_name, "_perf_summary.hist"); - hFile = PERF_FILEFN(fopen)(fileName, "a+"); - - if (hFile != NULL) - { - DWORD j; - PERF_FILEFN(fprintf)(hFile,"#api_name\tapi_id"); - for (j = 0; j < pal_perf_histogram_size; j++) - { - PERF_FILEFN(fprintf)(hFile, "\t%d", j*pal_perf_histogram_step); - } - PERF_FILEFN(fprintf)(hFile, "\n"); - - for(i = 0; i < PAL_API_NUMBER; i++) - { - if (off->counter > 0) - { - PERF_FILEFN(fprintf)(hFile,"%s\t%d", API_list[i], i); - - for (j = 0; j < pal_perf_histogram_size; j++) - { - PERF_FILEFN(fprintf)(hFile, "\t%d", off->histograms[j]); - } - - PERF_FILEFN(fprintf)(hFile, "\n"); - } - - off++; - } - } - else - { - return -1; - } - PERF_FILEFN(fclose)(hFile); - } - - return 0; -} - -static -BOOL -PERFReadSetting( ) -{ - // this function is not safe right now. - //more code is required to deal with corrupted input file. - BOOL ret; - unsigned int index; - char line[PAL_PERF_MAX_INPUT]; - char * ptr; - char function_name[PAL_PERF_MAX_FUNCTION_NAME]; //no function can be longer than 127 bytes. - - char * file_name_buf; - PathCharString file_name_bufPS; - char * input_file_name; - char * summary_flag_env; - char * nested_tracing_env; - char * calibrate_env; - char * report_only_called_apis_env; - char * wait_for_startup_env; - char * pal_perf_histogram_size_env; - char * pal_perf_histogram_step_env; - - PAL_FILE * hFile; - - if((pal_function_map == NULL) || (PAL_API_NUMBER < 0) ) - { - // should not be here. - } - - /* do some env setting here */ - summary_flag_env = MiscGetenv(PAL_SUMMARY_FLAG); - if (summary_flag_env == NULL || strlen(summary_flag_env) == 0) - { - summary_only = FALSE; - } - else - { - summary_only = TRUE; - } - nested_tracing_env = MiscGetenv(PAL_PERF_NESTED_TRACING); - if (nested_tracing_env == NULL || strlen(nested_tracing_env) == 0) - { - nested_tracing = FALSE; - } - else - { - nested_tracing = TRUE; - } - - calibrate_env = MiscGetenv(PAL_PERF_CALIBRATE); - if (calibrate_env == NULL || strlen(calibrate_env) == 0) - { - calibrate = FALSE; - } - else - { - calibrate = TRUE; - } - - report_only_called_apis_env = MiscGetenv(PAL_PERF_REPORT_ONLY_CALLED_APIS); - if (report_only_called_apis_env == NULL || strlen(report_only_called_apis_env) == 0) - { - report_only_called_apis = FALSE; - } - else - { - report_only_called_apis = TRUE; - } - - wait_for_startup_env = MiscGetenv(PAL_PERF_WAIT_FOR_STARTUP); - if (wait_for_startup_env == NULL || strlen(wait_for_startup_env) == 0) - { - wait_for_startup = FALSE; - } - else - { - wait_for_startup = TRUE; - } - - pal_perf_histogram_size_env = MiscGetenv(PAL_PERF_HISTOGRAM_SIZE); - if (pal_perf_histogram_size_env != NULL && strlen(pal_perf_histogram_size_env) > 0) - { - long value; - char *endptr; - value = strtol(pal_perf_histogram_size_env, &endptr, 10); - if (value > 0) - { - pal_perf_histogram_size = (DWORD) value; - } - } - - pal_perf_histogram_step_env = MiscGetenv(PAL_PERF_HISTOGRAM_STEP); - if (pal_perf_histogram_step_env != NULL && strlen(pal_perf_histogram_step_env) > 0) - { - long value; - char *endptr; - value = strtol(pal_perf_histogram_step_env, &endptr, 10); - if (value > 0) - { - pal_perf_histogram_step = (DWORD) value; - } - } - - traced_apis_file = PERFIsValidFile("", MiscGetenv(PAL_PERF_TRACEDAPIS_PATH)); - enabledapis_path = PERFIsValidFile("", MiscGetenv(PAL_PERF_ENABLED_APIS_PATH)); - profile_log_path = PERFIsValidPath(MiscGetenv(PAL_PERF_LOG_PATH)); - perf_default_path = PERFIsValidPath( MiscGetenv(PAL_DEFAULT_PATH)); - profile_summary_log_name = MiscGetenv(PAL_PERF_SUMMARY_LOG_NAME); - if (profile_summary_log_name != NULL && strlen(profile_summary_log_name) == 0) - profile_summary_log_name = NULL; - profile_time_log_name = MiscGetenv(PAL_PERF_TIME_LOG_NAME); - if (profile_time_log_name != NULL && strlen(profile_time_log_name) == 0) - profile_time_log_name = NULL; - - if( traced_apis_file == NULL) - { - if(perf_default_path==NULL) - { - ret=FALSE; - input_file_name = NULL; - } - else - { - if( PERFIsValidFile(perf_default_path,traced_apis_filename)) - { - int length = strlen(perf_default_path) + strlen(PATH_SEPARATOR) + strlen(traced_apis_filename); - file_name_buf = file_name_bufPS.OpenStringBuffer(length); - if ((strcpy_s(file_name_buf, file_name_bufPS.GetSizeOf(), perf_default_path) != SAFECRT_SUCCESS) || - (strcat_s(file_name_buf, file_name_bufPS.GetSizeOf(), PATH_SEPARATOR) != SAFECRT_SUCCESS) || - (strcat_s(file_name_buf, file_name_bufPS.GetSizeOf(), traced_apis_filename) != SAFECRT_SUCCESS)) - { - file_name_bufPS.CloseBuffer(0); - ret = FALSE; - input_file_name = NULL; - } - else - { - file_name_bufPS.CloseBuffer(length); - input_file_name = file_name_buf; - } - } - else - { - ret = FALSE; - input_file_name=NULL; - } - } - } - else - { - input_file_name=traced_apis_file; - } - - if(input_file_name) - { - hFile = PAL_fopen(input_file_name, "r+"); - if ( hFile == NULL ) - { - memset(pal_function_map, 1, PAL_API_NUMBER); - ret = FALSE; - } - else - { - memset(pal_function_map, 0, PAL_API_NUMBER); - - PAL_fseek(hFile, 0L, SEEK_SET); - - /* Read a line of data from file: */ - while ( PAL_fgets(line, PAL_PERF_MAX_INPUT, hFile) != NULL ) - { - if(strlen(line)==0) - continue; - ptr = strchr( line, '#'); - if( ptr ) - continue; - sscanf_s(line, "%s %u", function_name,&index); - - if( index >= PAL_API_NUMBER) - { - // some code here to deal with incorrect index. - // use function name to cover it. - } - else if(pal_function_map[index]==1) - { - // some code here to deal with conflict index. - // use function name to cover it. - } - else - { - pal_function_map[index]=1; - } - - } - - PAL_fclose(hFile); - ret = TRUE; - } - } - else - { - memset(pal_function_map, 1, PAL_API_NUMBER); - ret = FALSE; - } - - if( enabledapis_path == NULL) - { - if(perf_default_path==NULL) - { - input_file_name = NULL; - } - else - { - if( PERFIsValidFile(perf_default_path,perf_enabled_filename)) - { - if ((strcpy_s(file_name_buf, sizeof(file_name_buf), perf_default_path) != SAFECRT_SUCCESS) || - (strcat_s(file_name_buf, sizeof(file_name_buf), PATH_SEPARATOR) != SAFECRT_SUCCESS) || - (strcat_s(file_name_buf, sizeof(file_name_buf), perf_enabled_filename) != SAFECRT_SUCCESS)) - { - ret = FALSE; - input_file_name = NULL; - } - else - { - input_file_name = file_name_buf; - } - } - else - { - input_file_name=NULL; - } - } - } - else - { - input_file_name=enabledapis_path; - } - - if(input_file_name == NULL) - { - return ret; - } - - hFile = PAL_fopen(input_file_name, "r+"); - - if ( hFile != NULL ) - { - PAL_fseek(hFile, 0L, SEEK_SET); - - /* Read a line of data from file: */ - while (PAL_fgets(line, PAL_PERF_MAX_INPUT, hFile) != NULL) - { - if(strlen(line)==0) - continue; - ptr = strchr( line, '#'); - if( ptr ) - continue; - sscanf_s(line, "%s %u", function_name,&index); - - if( index >= PAL_API_NUMBER) - { - // some code here to deal with incorrect index. - // use function name to cover it. - continue; - } - - if (strcpy_s(API_list[index], sizeof(API_list[index]), function_name) != SAFECRT_SUCCESS) - { - ret = FALSE; - break; - } - } - - PAL_fclose(hFile); - } - - return ret; - -} - - -static -BOOL -PERFFlushLog(pal_perf_thread_info * local_info, BOOL output_header) -{ - BOOL ret = FALSE; - PathCharString fileName; - int nWrittenBytes = 0; - PERF_FILE * hFile; - - if (summary_only) - return TRUE; - - PERFLogFileName(fileName, profile_time_log_name, "_perf_time.log"); - - hFile = PERF_FILEFN(fopen)(fileName, "a+"); - - if(hFile) - { - if (output_header) - { - PERFPrintProgramHeaderInfo(hFile, FALSE); - } - if (local_info->buf_offset > 0) - { - nWrittenBytes = PERF_FILEFN(fwrite)(local_info->pal_write_buf, local_info->buf_offset, 1, hFile); - if (nWrittenBytes < 1) - { - ERROR("fwrite() failed with errno == %d\n", errno); - return ret; - } - local_info->buf_offset = 0; - } - PERF_FILEFN(fclose)(hFile); - ret = TRUE; - } - - return ret; -} - -void -PERFLogFunctionEntry(unsigned int pal_api_id, ULONGLONG *pal_perf_start_tick ) -{ - pal_perf_thread_info * local_info=NULL; - pal_perf_api_info * table; - char * write_buf; - __int32 buf_off; - short bufused = 0; - - - struct timeval tv; - - - if(!pal_perf_enabled || pal_function_map==NULL || !pal_profile_on ) // haven't initialize, just quit. - return; - - if( pal_function_map[pal_api_id] ) - { - local_info= (pal_perf_thread_info * )pthread_getspecific(PERF_tlsTableKey); - - if (local_info==NULL ) - { - return; - } - if ( !local_info->profile_enabled ) /* prevent recursion. */ - { - return; - } - // turn on this flag before call any other functions - local_info->profile_enabled = FALSE; - table = local_info->api_table; - table[pal_api_id].entries++; - - if(!summary_only) - { - write_buf = (local_info->pal_write_buf); - if(local_info->buf_offset >= PAL_PERF_BUFFER_FULL) - { - PERFFlushLog(local_info, FALSE); - } - - gettimeofday(&tv, NULL); - - buf_off = local_info->buf_offset; - - bufused = snprintf(&write_buf[buf_off], PAL_PERF_MAX_LOGLINE, "----> %d %lu %06u entry.\n", pal_api_id, tv.tv_sec, tv.tv_usec ); - local_info->buf_offset += bufused; - } - if(nested_tracing) - local_info->profile_enabled = TRUE; - *pal_perf_start_tick = PERFGetTicks(); - } - return; -} - -static -void -PERFUpdateApiInfo(pal_perf_api_info *api, ULONGLONG duration) -{ - DWORD iBucket; - - api->counter++; - if (api->min_duration > duration) - api->min_duration = duration; - if (api->max_duration < duration) - api->max_duration = duration; - api->sum_duration += duration; - api->sum_of_square_duration += (double) duration * (double)duration; - - if (pal_perf_histogram_size > 0) - { - iBucket = (DWORD)(duration / pal_perf_histogram_step); - if (iBucket >= pal_perf_histogram_size) - { - iBucket = pal_perf_histogram_size - 1; - } - api->histograms[iBucket]++; - } - -} - -void -PERFLogFunctionExit(unsigned int pal_api_id, ULONGLONG *pal_perf_start_tick ) -{ - - pal_perf_thread_info * local_info; - char * buf; - short bufused = 0; - DWORD off; - ULONGLONG duration = 0; - struct timeval timev; - - - if(!pal_perf_enabled || (pal_function_map == NULL) || !pal_profile_on ) // haven't initiallize yet, just quit. - return; - - if (*pal_perf_start_tick != 0) - { - duration = PERFGetTicks() - *pal_perf_start_tick; - } - else - { - return; // pal_perf_start_tick == 0 indicates that we exited PERFLogFunctionEntry before getting the ticks. - } - - if( pal_function_map[pal_api_id] ) - { - local_info = (pal_perf_thread_info*)pthread_getspecific(PERF_tlsTableKey); - - if (NULL == local_info ){ - return; - } - PERFUpdateApiInfo(&local_info->api_table[pal_api_id], duration); - *pal_perf_start_tick = 0; - - if(summary_only) - { - local_info->profile_enabled = TRUE; - return; - } - - gettimeofday(&timev, NULL); - - buf = local_info->pal_write_buf; - if(local_info->buf_offset >= PAL_PERF_BUFFER_FULL) - { - PERFFlushLog(local_info, FALSE); - } - off = local_info->buf_offset; - - bufused = snprintf(&buf[off], PAL_PERF_MAX_LOGLINE, "<---- %d %lu %06u exit. \n", pal_api_id, timev.tv_sec, timev.tv_usec ); - local_info->buf_offset += bufused; - local_info->profile_enabled = TRUE; - } - return; -} - -void -PERFNoLatencyProfileEntry(unsigned int pal_api_id ) -{ - pal_perf_thread_info * local_info=NULL; - pal_perf_api_info * table; - - if(!pal_perf_enabled || pal_function_map==NULL || !pal_profile_on ) // haven't initialize, just quit. - return; - if( pal_function_map[pal_api_id] ) - { - local_info= (pal_perf_thread_info * )pthread_getspecific(PERF_tlsTableKey); - if (local_info==NULL ) - { - return; - } - else{ - table = local_info->api_table; - table[pal_api_id].entries++; - } - } - return; -} - - -void -PERFEnableThreadProfile(BOOL isInternal) -{ - pal_perf_thread_info * local_info; - if (!pal_perf_enabled) - return; - if (NULL != (local_info = (pal_perf_thread_info*)pthread_getspecific(PERF_tlsTableKey))) - { - if (!isInternal || nested_tracing) { - local_info->profile_enabled = TRUE; - local_info->start_ticks = PERFGetTicks(); - } - } -} - - -void -PERFDisableThreadProfile(BOOL isInternal) -{ - pal_perf_thread_info * local_info; - if (!pal_perf_enabled) - return; - if (NULL != (local_info = (pal_perf_thread_info*)pthread_getspecific(PERF_tlsTableKey))) - { - if (!isInternal || nested_tracing) { - local_info->profile_enabled = FALSE; - local_info->total_duration = PERFGetTicks() - local_info->start_ticks; - } - } -} - - -void -PERFEnableProcessProfile( ) -{ - if (!pal_perf_enabled || wait_for_startup) - return; - pal_profile_on = TRUE; - PERFCalibrate("Overhead when profiling is disabled temporarily for a thread"); - // record the cpu clock ticks at the beginning of the profiling. - program_info.start_ticks = PERFGetTicks(); -} - - -void -PERFDisableProcessProfile( ) -{ - if (!pal_perf_enabled) - return; - pal_profile_on = FALSE; - // compute the total program duration in cpu clock ticks. - if (program_info.start_ticks != 0) - { - program_info.elapsed_time += (PERFGetTicks() - program_info.start_ticks); - program_info.start_ticks = 0; - } -} - -BOOL -PERFIsProcessProfileEnabled( ) -{ - return pal_profile_on; -} - -static -char * -PERFIsValidPath( const char * path ) -{ - DIR * dir; - - if(( path==NULL) || (strlen(path)==0)) - return NULL; - - dir = opendir(path); - if( dir!=NULL) - { - closedir(dir); - return ((char *)path); - } - return NULL; -} - -static -char * -PERFIsValidFile( const char * path, const char * file) -{ - FILE * hFile; - char * temp; - PathCharString tempPS; - - if(file==NULL || strlen(file)==0) - return NULL; - - if ( strcmp(path, "") ) - { - int length = strlen(path) + strlen(PATH_SEPARATOR) + strlen(file); - temp = tempPS.OpenStringBuffer(length); - if ((strcpy_s(temp, sizeof(temp), path) != SAFECRT_SUCCESS) || - (strcat_s(temp, sizeof(temp), PATH_SEPARATOR) != SAFECRT_SUCCESS) || - (strcat_s(temp, sizeof(temp), file) != SAFECRT_SUCCESS)) - { - tempPS.CloseBuffer(0); - return NULL; - } - - tempPS.CloseBuffer(length); - hFile = fopen(temp, "r"); - } - else - { - hFile = fopen(file, "r"); - } - - if(hFile) - { - fclose(hFile); - return ((char *) file); - } - else - return NULL; - -} - -PALIMPORT -VOID -PALAPI -PAL_EnableProcessProfile(VOID) -{ - wait_for_startup = FALSE; - pal_profile_on = TRUE; - PERFEnableProcessProfile(); -} - -PALIMPORT -VOID -PALAPI -PAL_DisableProcessProfile(VOID) -{ - pal_profile_on = FALSE; - PERFDisableProcessProfile(); -} - -PALIMPORT -BOOL -PALAPI -PAL_IsProcessProfileEnabled(VOID) -{ - return PERFIsProcessProfileEnabled(); -} - -PALIMPORT -INT64 -PALAPI -PAL_GetCpuTickCount(VOID) -{ - return PERFGetTicks(); -} - -#endif /* PAL_PERF */ - - - - diff --git a/src/pal/src/misc/sysinfo.cpp b/src/pal/src/misc/sysinfo.cpp index bc55dadd4..27929eaa9 100644 --- a/src/pal/src/misc/sysinfo.cpp +++ b/src/pal/src/misc/sysinfo.cpp @@ -59,6 +59,7 @@ Revision History: #endif // HAVE_MACHINE_VMPARAM_H #if defined(_TARGET_MAC64) +#include #include #include #include diff --git a/src/pal/src/misc/time.cpp b/src/pal/src/misc/time.cpp index d16fb587b..4b56e9591 100644 --- a/src/pal/src/misc/time.cpp +++ b/src/pal/src/misc/time.cpp @@ -29,6 +29,7 @@ Abstract: #include #if HAVE_MACH_ABSOLUTE_TIME +#include #include static mach_timebase_info_data_t s_TimebaseInfo; #endif @@ -285,44 +286,6 @@ QueryPerformanceFrequency( return retval; } -/*++ -Function: - QueryThreadCycleTime - -Puts the execution time (in nanoseconds) for the thread pointed to by ThreadHandle, into the unsigned long -pointed to by CycleTime. ThreadHandle must refer to the current thread. Returns TRUE on success, FALSE on -failure. ---*/ - -BOOL -PALAPI -QueryThreadCycleTime( - IN HANDLE ThreadHandle, - OUT PULONG64 CycleTime - ) -{ - - ULONG64 calcTime; - FILETIME kernelTime, userTime; - BOOL retval = TRUE; - - if(!GetThreadTimesInternal(ThreadHandle, &kernelTime, &userTime)) - { - ASSERT("Could not get cycle time for current thread"); - retval = FALSE; - goto EXIT; - } - - calcTime = ((ULONG64)kernelTime.dwHighDateTime << 32); - calcTime += (ULONG64)kernelTime.dwLowDateTime; - calcTime += ((ULONG64)userTime.dwHighDateTime << 32); - calcTime += (ULONG64)userTime.dwLowDateTime; - *CycleTime = calcTime; - -EXIT: - return retval; -} - /*++ Function: GetTickCount64 diff --git a/src/pal/src/misc/tracepointprovider.cpp b/src/pal/src/misc/tracepointprovider.cpp deleted file mode 100644 index 8d2026668..000000000 --- a/src/pal/src/misc/tracepointprovider.cpp +++ /dev/null @@ -1,109 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*++ - -Module Name: - - tracepointprovider.cpp - -Abstract: - - Trace point provider support - -Revision History: - ---*/ - -#include "pal/palinternal.h" -#include "pal/dbgmsg.h" -#include "pal/file.h" -#include "pal/process.h" -#include "pal/module.h" -#include "pal/malloc.hpp" -#include "pal/stackstring.hpp" - -#include -#include -#include -#include - -SET_DEFAULT_DEBUG_CHANNEL(MISC); - -/*++ - -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. - -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. - ---*/ -__attribute__((__unused__)) -__attribute__((constructor (200))) -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. - PathCharString tpProvPath; - int pathLen = strlen(info.dli_fname); - - // 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; - } - - SIZE_T tpLibNameLen = strlen(tpLibName); - - if( !tpProvPath.Reserve(tpLibNameLen + lastTrailingSlashLen) || - // Copy the path without the shared object name. - !tpProvPath.Append(info.dli_fname, lastTrailingSlashLen) || - // Append the shared object name for the tracepoint provider. - !tpProvPath.Append(tpLibName, tpLibNameLen)) - { - return; - } - - - - // 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 diff --git a/src/pal/src/numa/numa.cpp b/src/pal/src/numa/numa.cpp deleted file mode 100644 index 9b2de94b2..000000000 --- a/src/pal/src/numa/numa.cpp +++ /dev/null @@ -1,1020 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*++ - - - -Module Name: - - numa.cpp - -Abstract: - - Implementation of NUMA related APIs - ---*/ - -#include "pal/dbgmsg.h" -SET_DEFAULT_DEBUG_CHANNEL(NUMA); - -#include "pal/palinternal.h" -#include "pal/dbgmsg.h" -#include "pal/numa.h" -#include "pal/corunix.hpp" -#include "pal/thread.hpp" - -#if HAVE_PTHREAD_NP_H -#include -#endif - -#include -#include -#ifdef __FreeBSD__ -#include -#else -#include -#endif - -#include - -#include "numashim.h" - -using namespace CorUnix; - -#if HAVE_CPUSET_T -typedef cpuset_t cpu_set_t; -#endif - -// CPU affinity descriptor -struct CpuAffinity -{ - // NUMA node - BYTE Node; - // CPU number relative to the group the CPU is in - BYTE Number; - // CPU group - WORD Group; -}; - -// Array mapping global CPU index to its affinity -CpuAffinity *g_cpuToAffinity = NULL; - -// Array mapping CPU group and index in the group to the global CPU index -short *g_groupAndIndexToCpu = NULL; -// Array mapping CPU group to the corresponding affinity mask of the CPUs in the group -KAFFINITY *g_groupToCpuMask = NULL; -// Array mapping CPU group to the number of processors in the group -BYTE *g_groupToCpuCount = NULL; - -// Total number of processors in the system -int g_cpuCount = 0; -// Total number of possible processors in the system -int g_possibleCpuCount = 0; -// Total number of CPU groups -int g_groupCount = 0; -// The highest NUMA node available -int g_highestNumaNode = 0; -// Is numa available -bool g_numaAvailable = false; - -void* numaHandle = nullptr; - -#if HAVE_NUMA_H -#define PER_FUNCTION_BLOCK(fn) decltype(fn)* fn##_ptr; -FOR_ALL_NUMA_FUNCTIONS -#undef PER_FUNCTION_BLOCK -#endif // HAVE_NUMA_H - -static const int MaxCpusPerGroup = 8 * sizeof(KAFFINITY); -static const WORD NO_GROUP = 0xffff; - -/*++ -Function: - FreeLookupArrays - -Free CPU and group lookup arrays ---*/ -VOID -FreeLookupArrays() -{ - free(g_groupAndIndexToCpu); - free(g_cpuToAffinity); - free(g_groupToCpuMask); - free(g_groupToCpuCount); - - g_groupAndIndexToCpu = NULL; - g_cpuToAffinity = NULL; - g_groupToCpuMask = NULL; - g_groupToCpuCount = NULL; -} - -/*++ -Function: - AllocateLookupArrays - -Allocate CPU and group lookup arrays -Return TRUE if the allocation succeeded ---*/ -BOOL -AllocateLookupArrays() -{ - g_groupAndIndexToCpu = (short*)malloc(g_groupCount * MaxCpusPerGroup * sizeof(short)); - if (g_groupAndIndexToCpu == NULL) - { - goto FAILED; - } - - g_cpuToAffinity = (CpuAffinity*)malloc(g_possibleCpuCount * sizeof(CpuAffinity)); - if (g_cpuToAffinity == NULL) - { - goto FAILED; - } - - g_groupToCpuMask = (KAFFINITY*)malloc(g_groupCount * sizeof(KAFFINITY)); - if (g_groupToCpuMask == NULL) - { - goto FAILED; - } - - g_groupToCpuCount = (BYTE*)malloc(g_groupCount * sizeof(BYTE)); - if (g_groupToCpuCount == NULL) - { - goto FAILED; - } - - memset(g_groupAndIndexToCpu, 0xff, g_groupCount * MaxCpusPerGroup * sizeof(short)); - memset(g_cpuToAffinity, 0xff, g_possibleCpuCount * sizeof(CpuAffinity)); - memset(g_groupToCpuMask, 0, g_groupCount * sizeof(KAFFINITY)); - memset(g_groupToCpuCount, 0, g_groupCount * sizeof(BYTE)); - - return TRUE; - -FAILED: - FreeLookupArrays(); - - return FALSE; -} - -/*++ -Function: - GetFullAffinityMask - -Get affinity mask for the specified number of processors with all -the processors enabled. ---*/ -KAFFINITY GetFullAffinityMask(int cpuCount) -{ - return ((KAFFINITY)1 << (cpuCount)) - 1; -} - -/*++ -Function: - NUMASupportInitialize - -Initialize data structures for getting and setting thread affinities to processors and -querying NUMA related processor information. -On systems with no NUMA support, it behaves as if there was a single NUMA node with -a single group of processors. ---*/ -BOOL -NUMASupportInitialize() -{ -#if HAVE_NUMA_H - numaHandle = dlopen("libnuma.so", RTLD_LAZY); - if (numaHandle == 0) - { - numaHandle = dlopen("libnuma.so.1", RTLD_LAZY); - } - if (numaHandle != 0) - { - dlsym(numaHandle, "numa_allocate_cpumask"); -#define PER_FUNCTION_BLOCK(fn) \ - fn##_ptr = (decltype(fn)*)dlsym(numaHandle, #fn); \ - if (fn##_ptr == NULL) { fprintf(stderr, "Cannot get symbol " #fn " from libnuma\n"); abort(); } -FOR_ALL_NUMA_FUNCTIONS -#undef PER_FUNCTION_BLOCK - - if (numa_available() == -1) - { - dlclose(numaHandle); - } - else - { - g_numaAvailable = true; - - struct bitmask *mask = numa_allocate_cpumask(); - int numaNodesCount = numa_max_node() + 1; - - g_possibleCpuCount = numa_num_possible_cpus(); - g_cpuCount = 0; - g_groupCount = 0; - - for (int i = 0; i < numaNodesCount; i++) - { - int st = numa_node_to_cpus(i, mask); - // The only failure that can happen is that the mask is not large enough - // but that cannot happen since the mask was allocated by numa_allocate_cpumask - _ASSERTE(st == 0); - unsigned int nodeCpuCount = numa_bitmask_weight(mask); - g_cpuCount += nodeCpuCount; - unsigned int nodeGroupCount = (nodeCpuCount + MaxCpusPerGroup - 1) / MaxCpusPerGroup; - g_groupCount += nodeGroupCount; - } - - if (!AllocateLookupArrays()) - { - dlclose(numaHandle); - return FALSE; - } - - WORD currentGroup = 0; - int currentGroupCpus = 0; - - for (int i = 0; i < numaNodesCount; i++) - { - int st = numa_node_to_cpus(i, mask); - // The only failure that can happen is that the mask is not large enough - // but that cannot happen since the mask was allocated by numa_allocate_cpumask - _ASSERTE(st == 0); - unsigned int nodeCpuCount = numa_bitmask_weight(mask); - unsigned int nodeGroupCount = (nodeCpuCount + MaxCpusPerGroup - 1) / MaxCpusPerGroup; - for (int j = 0; j < g_possibleCpuCount; j++) - { - if (numa_bitmask_isbitset(mask, j)) - { - if (currentGroupCpus == MaxCpusPerGroup) - { - g_groupToCpuCount[currentGroup] = MaxCpusPerGroup; - g_groupToCpuMask[currentGroup] = GetFullAffinityMask(MaxCpusPerGroup); - currentGroupCpus = 0; - currentGroup++; - } - g_cpuToAffinity[j].Node = i; - g_cpuToAffinity[j].Group = currentGroup; - g_cpuToAffinity[j].Number = currentGroupCpus; - g_groupAndIndexToCpu[currentGroup * MaxCpusPerGroup + currentGroupCpus] = j; - currentGroupCpus++; - } - } - - if (currentGroupCpus != 0) - { - g_groupToCpuCount[currentGroup] = currentGroupCpus; - g_groupToCpuMask[currentGroup] = GetFullAffinityMask(currentGroupCpus); - currentGroupCpus = 0; - currentGroup++; - } - } - - numa_free_cpumask(mask); - - g_highestNumaNode = numa_max_node(); - } - } -#endif // HAVE_NUMA_H - if (!g_numaAvailable) - { - // No NUMA - g_possibleCpuCount = PAL_GetLogicalCpuCountFromOS(); - g_cpuCount = PAL_GetLogicalCpuCountFromOS(); - g_groupCount = 1; - g_highestNumaNode = 0; - - if (!AllocateLookupArrays()) - { - return FALSE; - } - - for (int i = 0; i < g_possibleCpuCount; i++) - { - g_cpuToAffinity[i].Number = i; - g_cpuToAffinity[i].Group = 0; - } - } - - return TRUE; -} - -/*++ -Function: - NUMASupportCleanup - -Cleanup of the NUMA support data structures ---*/ -VOID -NUMASupportCleanup() -{ - FreeLookupArrays(); -#if HAVE_NUMA_H - if (g_numaAvailable) - { - dlclose(numaHandle); - } -#endif // HAVE_NUMA_H -} - -/*++ -Function: - GetNumaHighestNodeNumber - -See MSDN doc. ---*/ -BOOL -PALAPI -GetNumaHighestNodeNumber( - OUT PULONG HighestNodeNumber -) -{ - PERF_ENTRY(GetNumaHighestNodeNumber); - ENTRY("GetNumaHighestNodeNumber(HighestNodeNumber=%p)\n", HighestNodeNumber); - *HighestNodeNumber = (ULONG)g_highestNumaNode; - - BOOL success = TRUE; - - LOGEXIT("GetNumaHighestNodeNumber returns BOOL %d\n", success); - PERF_EXIT(GetNumaHighestNodeNumber); - - return success; -} - -/*++ -Function: - GetNumaProcessorNodeEx - -See MSDN doc. ---*/ -BOOL -PALAPI -GetNumaProcessorNodeEx( - IN PPROCESSOR_NUMBER Processor, - OUT PUSHORT NodeNumber -) -{ - PERF_ENTRY(GetNumaProcessorNodeEx); - ENTRY("GetNumaProcessorNodeEx(Processor=%p, NodeNumber=%p)\n", Processor, NodeNumber); - - BOOL success = FALSE; - - if ((Processor->Group < g_groupCount) && - (Processor->Number < MaxCpusPerGroup) && - (Processor->Reserved == 0)) - { - short cpu = g_groupAndIndexToCpu[Processor->Group * MaxCpusPerGroup + Processor->Number]; - if (cpu != -1) - { - *NodeNumber = g_cpuToAffinity[cpu].Node; - success = TRUE; - } - } - - if (!success) - { - *NodeNumber = 0xffff; - SetLastError(ERROR_INVALID_PARAMETER); - } - - LOGEXIT("GetNumaProcessorNodeEx returns BOOL %d\n", success); - PERF_EXIT(GetNumaProcessorNodeEx); - - return success; -} - -/*++ -Function: - GetLogicalProcessorInformationEx - -See MSDN doc. ---*/ -BOOL -PALAPI -GetLogicalProcessorInformationEx( - IN LOGICAL_PROCESSOR_RELATIONSHIP RelationshipType, - OUT OPTIONAL PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX Buffer, - IN OUT PDWORD ReturnedLength -) -{ - PERF_ENTRY(GetLogicalProcessorInformationEx); - ENTRY("GetLogicalProcessorInformationEx(RelationshipType=%d, Buffer=%p, ReturnedLength=%p)\n", RelationshipType, Buffer, ReturnedLength); - - BOOL success = FALSE; - - if (RelationshipType == RelationGroup) - { - size_t requiredSize = __builtin_offsetof(SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX, Group); - requiredSize += __builtin_offsetof(GROUP_RELATIONSHIP, GroupInfo); - requiredSize += g_groupCount * sizeof(PROCESSOR_GROUP_INFO); - - if (*ReturnedLength >= requiredSize) - { - Buffer->Relationship = RelationGroup; - Buffer->Size = requiredSize; - Buffer->Group.MaximumGroupCount = g_groupCount; - Buffer->Group.ActiveGroupCount = g_groupCount; - for (int i = 0; i < g_groupCount; i++) - { - Buffer->Group.GroupInfo[i].MaximumProcessorCount = MaxCpusPerGroup; - Buffer->Group.GroupInfo[i].ActiveProcessorCount = g_groupToCpuCount[i]; - Buffer->Group.GroupInfo[i].ActiveProcessorMask = g_groupToCpuMask[i]; - } - - success = TRUE; - } - else - { - SetLastError(ERROR_INSUFFICIENT_BUFFER); - } - - *ReturnedLength = requiredSize; - } - else - { - // We only support the group relationship - SetLastError(ERROR_INVALID_PARAMETER); - } - - LOGEXIT("GetLogicalProcessorInformationEx returns BOOL %d\n", success); - PERF_EXIT(GetLogicalProcessorInformationEx); - - return success; -} - -/*++ -Function: - GetThreadGroupAffinityInternal - -Get the group affinity for the specified pthread ---*/ -BOOL -GetThreadGroupAffinityInternal( - IN pthread_t thread, - OUT PGROUP_AFFINITY GroupAffinity -) -{ - BOOL success = FALSE; - -#if HAVE_PTHREAD_GETAFFINITY_NP - cpu_set_t cpuSet; - - int st = pthread_getaffinity_np(thread, sizeof(cpu_set_t), &cpuSet); - - if (st == 0) - { - WORD group = NO_GROUP; - KAFFINITY mask = 0; - - for (int i = 0; i < g_possibleCpuCount; i++) - { - if (CPU_ISSET(i, &cpuSet)) - { - WORD g = g_cpuToAffinity[i].Group; - // Unless the thread affinity was already set by SetThreadGroupAffinity, it is possible that - // the current thread has affinity with processors from multiple groups. So we report just the - // first group we find. - if (group == NO_GROUP || g == group) - { - group = g; - mask |= ((KAFFINITY)1) << g_cpuToAffinity[i].Number; - } - } - } - - GroupAffinity->Group = group; - GroupAffinity->Mask = mask; - success = TRUE; - } - else - { - SetLastError(ERROR_GEN_FAILURE); - } -#else // HAVE_PTHREAD_GETAFFINITY_NP - // There is no API to manage thread affinity, so let's return a group affinity - // with all the CPUs on the system. - GroupAffinity->Group = 0; - GroupAffinity->Mask = GetFullAffinityMask(g_possibleCpuCount); - success = TRUE; -#endif // HAVE_PTHREAD_GETAFFINITY_NP - - return success; -} - -/*++ -Function: - GetThreadGroupAffinity - -See MSDN doc. ---*/ -BOOL -PALAPI -GetThreadGroupAffinity( - IN HANDLE hThread, - OUT PGROUP_AFFINITY GroupAffinity -) -{ - PERF_ENTRY(GetThreadGroupAffinity); - ENTRY("GetThreadGroupAffinity(hThread=%p, GroupAffinity=%p)\n", hThread, GroupAffinity); - CPalThread *pCurrentThread = InternalGetCurrentThread(); - CPalThread *pTargetThread = NULL; - IPalObject *pTargetThreadObject = NULL; - - PAL_ERROR palErr = - InternalGetThreadDataFromHandle(pCurrentThread, hThread, - 0, // THREAD_SET_CONTEXT - &pTargetThread, &pTargetThreadObject); - - if (NO_ERROR != palErr) - { - ERROR("Unable to obtain thread data for handle %p (error %x)!\n", hThread, - palErr); - return FALSE; - } - - BOOL success = GetThreadGroupAffinityInternal( - pTargetThread->GetPThreadSelf(), GroupAffinity); - LOGEXIT("GetThreadGroupAffinity returns BOOL %d\n", success); - PERF_EXIT(GetThreadGroupAffinity); - - return success; -} - - -/*++ -Function: - SetThreadGroupAffinity - -See MSDN doc. ---*/ -BOOL -PALAPI -SetThreadGroupAffinity( - IN HANDLE hThread, - IN const GROUP_AFFINITY *GroupAffinity, - OUT OPTIONAL PGROUP_AFFINITY PreviousGroupAffinity -) -{ - PERF_ENTRY(SetThreadGroupAffinity); - ENTRY("SetThreadGroupAffinity(hThread=%p, GroupAffinity=%p, PreviousGroupAffinity=%p)\n", hThread, GroupAffinity, PreviousGroupAffinity); - - CPalThread *pCurrentThread = InternalGetCurrentThread(); - CPalThread *pTargetThread = NULL; - IPalObject *pTargetThreadObject = NULL; - - PAL_ERROR palErr = - InternalGetThreadDataFromHandle(pCurrentThread, hThread, - 0, // THREAD_SET_CONTEXT - &pTargetThread, &pTargetThreadObject); - - if (NO_ERROR != palErr) - { - ERROR("Unable to obtain thread data for handle %p (error %x)!\n", hThread, - palErr); - return FALSE; - } - - pthread_t thread = pTargetThread->GetPThreadSelf(); - - if (PreviousGroupAffinity != NULL) - { - GetThreadGroupAffinityInternal(thread, PreviousGroupAffinity); - } - -#if HAVE_PTHREAD_GETAFFINITY_NP - int groupStartIndex = GroupAffinity->Group * MaxCpusPerGroup; - KAFFINITY mask = 1; - cpu_set_t cpuSet; - CPU_ZERO(&cpuSet); - - for (int i = 0; i < MaxCpusPerGroup; i++, mask <<= 1) - { - if (GroupAffinity->Mask & mask) - { - int cpu = g_groupAndIndexToCpu[groupStartIndex + i]; - if (cpu != -1) - { - CPU_SET(cpu, &cpuSet); - } - } - } - - int st = pthread_setaffinity_np(thread, sizeof(cpu_set_t), &cpuSet); - - if (st != 0) - { - switch (st) - { - case EINVAL: - // There is no processor in the mask that is allowed to execute the process - SetLastError(ERROR_INVALID_PARAMETER); - break; - case ESRCH: - SetLastError(ERROR_INVALID_HANDLE); - break; - default: - SetLastError(ERROR_GEN_FAILURE); - break; - } - } - - BOOL success = (st == 0); -#else // HAVE_PTHREAD_GETAFFINITY_NP - // There is no API to manage thread affinity, so let's ignore the request - BOOL success = TRUE; -#endif // HAVE_PTHREAD_GETAFFINITY_NP - - LOGEXIT("SetThreadGroupAffinity returns BOOL %d\n", success); - PERF_EXIT(SetThreadGroupAffinity); - - return success; -} - -/*++ -Function: - SetThreadAffinityMask - -See MSDN doc. ---*/ -DWORD_PTR -PALAPI -SetThreadAffinityMask( - IN HANDLE hThread, - IN DWORD_PTR dwThreadAffinityMask -) -{ - PERF_ENTRY(SetThreadAffinityMask); - ENTRY("SetThreadAffinityMask(hThread=%p, dwThreadAffinityMask=%p)\n", hThread, dwThreadAffinityMask); - - CPalThread *pCurrentThread = InternalGetCurrentThread(); - CPalThread *pTargetThread = NULL; - IPalObject *pTargetThreadObject = NULL; - - PAL_ERROR palErr = - InternalGetThreadDataFromHandle(pCurrentThread, hThread, - 0, // THREAD_SET_CONTEXT - &pTargetThread, &pTargetThreadObject); - - if (NO_ERROR != palErr) - { - ERROR("Unable to obtain thread data for handle %p (error %x)!\n", hThread, - palErr); - return 0; - } - - pthread_t thread = pTargetThread->GetPThreadSelf(); - -#if HAVE_PTHREAD_GETAFFINITY_NP - cpu_set_t prevCpuSet; - CPU_ZERO(&prevCpuSet); - KAFFINITY prevMask = 0; - - int st = pthread_getaffinity_np(thread, sizeof(cpu_set_t), &prevCpuSet); - - if (st == 0) - { - for (int i = 0; i < std::min(8 * (int)sizeof(KAFFINITY), g_possibleCpuCount); i++) - { - if (CPU_ISSET(i, &prevCpuSet)) - { - prevMask |= ((KAFFINITY)1) << i; - } - } - } - - cpu_set_t cpuSet; - CPU_ZERO(&cpuSet); - - int cpu = 0; - while (dwThreadAffinityMask) - { - if (dwThreadAffinityMask & 1) - { - CPU_SET(cpu, &cpuSet); - } - cpu++; - dwThreadAffinityMask >>= 1; - } - - st = pthread_setaffinity_np(thread, sizeof(cpu_set_t), &cpuSet); - - if (st != 0) - { - switch (st) - { - case EINVAL: - // There is no processor in the mask that is allowed to execute the - // process - SetLastError(ERROR_INVALID_PARAMETER); - break; - case ESRCH: - SetLastError(ERROR_INVALID_HANDLE); - break; - default: - SetLastError(ERROR_GEN_FAILURE); - break; - } - } - - DWORD_PTR ret = (st == 0) ? prevMask : 0; -#else // HAVE_PTHREAD_GETAFFINITY_NP - // There is no API to manage thread affinity, so let's ignore the request - DWORD_PTR ret = 0; -#endif // HAVE_PTHREAD_GETAFFINITY_NP - LOGEXIT("SetThreadAffinityMask returns %lu\n", ret); - PERF_EXIT(SetThreadAffinityMask); - - return ret; -} - -/*++ -Function: - GetCurrentProcessorNumberEx - -See MSDN doc. ---*/ -VOID -PALAPI -GetCurrentProcessorNumberEx( - OUT PPROCESSOR_NUMBER ProcNumber -) -{ - PERF_ENTRY(GetCurrentProcessorNumberEx); - ENTRY("GetCurrentProcessorNumberEx(ProcNumber=%p\n", ProcNumber); - - DWORD cpu = GetCurrentProcessorNumber(); - _ASSERTE(cpu < g_possibleCpuCount); - ProcNumber->Group = g_cpuToAffinity[cpu].Group; - ProcNumber->Number = g_cpuToAffinity[cpu].Number; - - LOGEXIT("GetCurrentProcessorNumberEx\n"); - PERF_EXIT(GetCurrentProcessorNumberEx); -} - -/*++ -Function: - GetProcessAffinityMask - -See MSDN doc. ---*/ -BOOL -PALAPI -GetProcessAffinityMask( - IN HANDLE hProcess, - OUT PDWORD_PTR lpProcessAffinityMask, - OUT PDWORD_PTR lpSystemAffinityMask -) -{ - PERF_ENTRY(GetProcessAffinityMask); - ENTRY("GetProcessAffinityMask(hProcess=%p, lpProcessAffinityMask=%p, lpSystemAffinityMask=%p\n", hProcess, lpProcessAffinityMask, lpSystemAffinityMask); - - BOOL success = FALSE; - - if (hProcess == GetCurrentProcess()) - { - DWORD_PTR systemMask = GetFullAffinityMask(g_cpuCount); - -#if HAVE_SCHED_GETAFFINITY - int pid = getpid(); - cpu_set_t cpuSet; - int st = sched_getaffinity(pid, sizeof(cpu_set_t), &cpuSet); - if (st == 0) - { - WORD group = NO_GROUP; - DWORD_PTR processMask = 0; - - for (int i = 0; i < g_possibleCpuCount; i++) - { - if (CPU_ISSET(i, &cpuSet)) - { - WORD g = g_cpuToAffinity[i].Group; - if (group == NO_GROUP || g == group) - { - group = g; - processMask |= ((DWORD_PTR)1) << g_cpuToAffinity[i].Number; - } - else - { - // The process has affinity in more than one group, in such case - // the function needs to return zero in both masks. - processMask = 0; - systemMask = 0; - group = NO_GROUP; - break; - } - } - } - - success = TRUE; - - *lpProcessAffinityMask = processMask; - *lpSystemAffinityMask = systemMask; - } - else if (errno == EINVAL) - { - // There are more processors than can fit in a cpu_set_t - // return zero in both masks. - *lpProcessAffinityMask = 0; - *lpSystemAffinityMask = 0; - success = TRUE; - } - else - { - // We should not get any of the errors that the sched_getaffinity can return since none - // of them applies for the current thread, so this is an unexpected kind of failure. - SetLastError(ERROR_GEN_FAILURE); - } -#else // HAVE_SCHED_GETAFFINITY - // There is no API to manage thread affinity, so let's return both affinity masks - // with all the CPUs on the system set. - *lpSystemAffinityMask = systemMask; - *lpProcessAffinityMask = systemMask; - - success = TRUE; -#endif // HAVE_SCHED_GETAFFINITY - } - else - { - // PAL supports getting affinity mask for the current process only - SetLastError(ERROR_INVALID_PARAMETER); - } - - LOGEXIT("GetProcessAffinityMask returns BOOL %d\n", success); - PERF_EXIT(GetProcessAffinityMask); - - return success; -} - -/*++ -Function: - VirtualAllocExNuma - -See MSDN doc. ---*/ -LPVOID -PALAPI -VirtualAllocExNuma( - IN HANDLE hProcess, - IN OPTIONAL LPVOID lpAddress, - IN SIZE_T dwSize, - IN DWORD flAllocationType, - IN DWORD flProtect, - IN DWORD nndPreferred -) -{ - PERF_ENTRY(VirtualAllocExNuma); - ENTRY("VirtualAllocExNuma(hProcess=%p, lpAddress=%p, dwSize=%u, flAllocationType=%#x, flProtect=%#x, nndPreferred=%d\n", - hProcess, lpAddress, dwSize, flAllocationType, flProtect, nndPreferred); - - LPVOID result = NULL; - - if (hProcess == GetCurrentProcess()) - { - if (nndPreferred <= g_highestNumaNode) - { - result = VirtualAlloc(lpAddress, dwSize, flAllocationType, flProtect); -#if HAVE_NUMA_H - if (result != NULL && g_numaAvailable) - { - int nodeMaskLength = (g_highestNumaNode + 1 + sizeof(unsigned long) - 1) / sizeof(unsigned long); - unsigned long *nodeMask = (unsigned long*)alloca(nodeMaskLength * sizeof(unsigned long)); - memset(nodeMask, 0, nodeMaskLength); - - int index = nndPreferred / sizeof(unsigned long); - int mask = ((unsigned long)1) << (nndPreferred & (sizeof(unsigned long) - 1)); - nodeMask[index] = mask; - - int st = mbind(result, dwSize, MPOL_PREFERRED, nodeMask, g_highestNumaNode, 0); - - _ASSERTE(st == 0); - // If the mbind fails, we still return the allocated memory since the nndPreferred is just a hint - } -#endif // HAVE_NUMA_H - } - else - { - // The specified node number is larger than the maximum available one - SetLastError(ERROR_INVALID_PARAMETER); - } - } - else - { - // PAL supports allocating from the current process virtual space only - SetLastError(ERROR_INVALID_PARAMETER); - } - - LOGEXIT("VirtualAllocExNuma returns %p\n", result); - PERF_EXIT(VirtualAllocExNuma); - - return result; -} - -/*++ -Function: - SetThreadIdealProcessorEx - -See MSDN doc. ---*/ -BOOL -PALAPI -SetThreadIdealProcessorEx( - IN HANDLE hThread, - IN PPROCESSOR_NUMBER lpIdealProcessor, - OUT PPROCESSOR_NUMBER lpPreviousIdealProcessor) -{ - PERF_ENTRY(SetThreadIdealProcessorEx); - ENTRY("SetThreadIdealProcessorEx(hThread=%p, lpIdealProcessor=%p)\n", hThread, lpIdealProcessor); - - CPalThread *pCurrentThread = InternalGetCurrentThread(); - CPalThread *pTargetThread = NULL; - IPalObject *pTargetThreadObject = NULL; - - PAL_ERROR palErr = - InternalGetThreadDataFromHandle(pCurrentThread, hThread, - 0, // THREAD_SET_CONTEXT - &pTargetThread, &pTargetThreadObject); - - if (NO_ERROR != palErr) - { - ERROR("Unable to obtain thread data for handle %p (error %x)!\n", hThread, - palErr); - return 0; - } - - pthread_t thread = pTargetThread->GetPThreadSelf(); - -#if HAVE_PTHREAD_GETAFFINITY_NP - int cpu = -1; - if ((lpIdealProcessor->Group < g_groupCount) && - (lpIdealProcessor->Number < MaxCpusPerGroup) && - (lpIdealProcessor->Reserved == 0)) - { - cpu = g_groupAndIndexToCpu[lpIdealProcessor->Group * MaxCpusPerGroup + lpIdealProcessor->Number]; - } - - if (cpu == -1) - { - SetLastError(ERROR_INVALID_PARAMETER); - return FALSE; - } - - if (lpPreviousIdealProcessor != NULL) - { - cpu_set_t prevCpuSet; - CPU_ZERO(&prevCpuSet); - DWORD prevCpu = GetCurrentProcessorNumber(); - - int st = pthread_getaffinity_np(thread, sizeof(cpu_set_t), &prevCpuSet); - - if (st == 0) - { - for (int i = 0; i < g_possibleCpuCount; i++) - { - if (CPU_ISSET(i, &prevCpuSet)) - { - prevCpu = i; - break; - } - } - } - - _ASSERTE(prevCpu < g_possibleCpuCount); - lpPreviousIdealProcessor->Group = g_cpuToAffinity[prevCpu].Group; - lpPreviousIdealProcessor->Number = g_cpuToAffinity[prevCpu].Number; - lpPreviousIdealProcessor->Reserved = 0; - } - - cpu_set_t cpuSet; - CPU_ZERO(&cpuSet); - CPU_SET(cpu, &cpuSet); - - int st = pthread_setaffinity_np(thread, sizeof(cpu_set_t), &cpuSet); - - if (st != 0) - { - switch (st) - { - case EINVAL: - // There is no processor in the mask that is allowed to execute the - // process - SetLastError(ERROR_INVALID_PARAMETER); - break; - case ESRCH: - SetLastError(ERROR_INVALID_HANDLE); - break; - default: - SetLastError(ERROR_GEN_FAILURE); - break; - } - } - - BOOL success = (st == 0); - -#else // HAVE_PTHREAD_GETAFFINITY_NP - // There is no API to manage thread affinity, so let's ignore the request - BOOL success = FALSE; -#endif // HAVE_PTHREAD_GETAFFINITY_NP - - LOGEXIT("SetThreadIdealProcessorEx returns BOOL %d\n", success); - PERF_EXIT(SetThreadIdealProcessorEx); - - return success; -} diff --git a/src/pal/src/numa/numashim.h b/src/pal/src/numa/numashim.h deleted file mode 100644 index dd7f58d6d..000000000 --- a/src/pal/src/numa/numashim.h +++ /dev/null @@ -1,49 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -// Enable calling numa functions through shims to make it a soft -// runtime dependency. - -#ifndef __NUMASHIM_H__ -#define __NUMASHIM_H__ - -#if HAVE_NUMA_H - -#include -#include - -#define numa_free_cpumask numa_bitmask_free - -// List of all functions from the numa library that are used -#define FOR_ALL_NUMA_FUNCTIONS \ - PER_FUNCTION_BLOCK(numa_available) \ - PER_FUNCTION_BLOCK(mbind) \ - PER_FUNCTION_BLOCK(numa_num_possible_cpus) \ - PER_FUNCTION_BLOCK(numa_max_node) \ - PER_FUNCTION_BLOCK(numa_allocate_cpumask) \ - PER_FUNCTION_BLOCK(numa_node_to_cpus) \ - PER_FUNCTION_BLOCK(numa_bitmask_weight) \ - PER_FUNCTION_BLOCK(numa_bitmask_isbitset) \ - PER_FUNCTION_BLOCK(numa_bitmask_free) - -// Declare pointers to all the used numa functions -#define PER_FUNCTION_BLOCK(fn) extern decltype(fn)* fn##_ptr; -FOR_ALL_NUMA_FUNCTIONS -#undef PER_FUNCTION_BLOCK - -// Redefine all calls to numa functions as calls through pointers that are set -// to the functions of libnuma in the initialization. -#define numa_available() numa_available_ptr() -#define mbind(...) mbind_ptr(__VA_ARGS__) -#define numa_num_possible_cpus() numa_num_possible_cpus_ptr() -#define numa_max_node() numa_max_node_ptr() -#define numa_allocate_cpumask() numa_allocate_cpumask_ptr() -#define numa_node_to_cpus(...) numa_node_to_cpus_ptr(__VA_ARGS__) -#define numa_bitmask_weight(...) numa_bitmask_weight_ptr(__VA_ARGS__) -#define numa_bitmask_isbitset(...) numa_bitmask_isbitset_ptr(__VA_ARGS__) -#define numa_bitmask_free(...) numa_bitmask_free_ptr(__VA_ARGS__) - -#endif // HAVE_NUMA_H - -#endif // __NUMASHIM_H__ diff --git a/src/pal/src/objmgr/shmobject.cpp b/src/pal/src/objmgr/shmobject.cpp index 17ef3e43d..7bcd36137 100644 --- a/src/pal/src/objmgr/shmobject.cpp +++ b/src/pal/src/objmgr/shmobject.cpp @@ -990,240 +990,3 @@ CSharedMemoryObject::GetObjectSynchData( ASSERT("Attempt to obtain a synch data for a non-waitable object\n"); return ERROR_INVALID_HANDLE; } - -/*++ -Function: - CSharedMemoryWaitableObject::Initialize - - Performs possibly-failing initialization for a newly-constructed - object - -Parameters: - pthr -- thread data for calling thread - poa -- the object attributes (e.g., name) for the object ---*/ - -PAL_ERROR -CSharedMemoryWaitableObject::Initialize( - CPalThread *pthr, - CObjectAttributes *poa - ) -{ - PAL_ERROR palError = NO_ERROR; - - _ASSERTE(NULL != pthr); - _ASSERTE(NULL != poa); - - ENTRY("CSharedMemoryWaitableObject::Initialize" - "(this = %p, pthr = %p, poa = %p)\n", - this, - pthr, - poa - ); - - palError = CSharedMemoryObject::Initialize(pthr, poa); - if (NO_ERROR != palError) - { - goto InitializeExit; - } - - // - // Sanity check the passed in object type - // - - _ASSERTE(CObjectType::WaitableObject == m_pot->GetSynchronizationSupport()); - - palError = g_pSynchronizationManager->AllocateObjectSynchData( - m_pot, - m_ObjectDomain, - &m_pvSynchData - ); - - if (NO_ERROR == palError && SharedObject == m_ObjectDomain) - { - SHMObjData *pshmod = SHMPTR_TO_TYPED_PTR(SHMObjData, m_shmod); - _ASSERTE(NULL != pshmod); - - pshmod->pvSynchData = m_pvSynchData; - } - -InitializeExit: - - LOGEXIT("CSharedMemoryWaitableObject::Initialize returns %d\n", palError); - - return palError; -} - -/*++ -Function: - CSharedMemoryWaitableObject::~CSharedMemoryWaitableObject - - Destructor; should only be called from ReleaseReference ---*/ - -CSharedMemoryWaitableObject::~CSharedMemoryWaitableObject() -{ - ENTRY("CSharedMemoryWaitableObject::~CSharedMemoryWaitableObject" - "(this = %p)\n", - this - ); - - if (!m_fSharedDataDereferenced) - { - ASSERT("DereferenceSharedData not called before object destructor -- delete called directly?\n"); - DereferenceSharedData(); - } - - if (NULL != m_pvSynchData && m_fDeleteSharedData) - { - g_pSynchronizationManager->FreeObjectSynchData( - m_pot, - m_ObjectDomain, - m_pvSynchData - ); - } - - LOGEXIT("CSharedMemoryWaitableObject::~CSharedMemoryWaitableObject\n"); -} - -/*++ -Function: - CSharedMemoryWaitableObject::GetSynchStateController - - Obtain a synchronization state controller for this object. - -Parameters: - pthr -- thread data for calling thread - ppStateController -- on success, receives a pointer to the state controller - instance ---*/ - -PAL_ERROR -CSharedMemoryWaitableObject::GetSynchStateController( - CPalThread *pthr, // IN, OPTIONAL - ISynchStateController **ppStateController // OUT - ) -{ - PAL_ERROR palError = NO_ERROR; - - _ASSERTE(NULL != pthr); - _ASSERTE(NULL != ppStateController); - - ENTRY("CSharedMemoryWaitableObject::GetSynchStateController" - "(this = %p, pthr = %p, ppStateController = %p", - this, - pthr, - ppStateController - ); - - // - // We need to grab the local synch lock before creating the controller - // (otherwise we could get promoted after passing in our parameters) - // - - g_pSynchronizationManager->AcquireProcessLock(pthr); - - palError = g_pSynchronizationManager->CreateSynchStateController( - pthr, - m_pot, - m_pvSynchData, - m_ObjectDomain, - ppStateController - ); - - g_pSynchronizationManager->ReleaseProcessLock(pthr); - - LOGEXIT("CSharedMemoryWaitableObject::GetSynchStateController returns %d\n", - palError - ); - - return palError; -} - -/*++ -Function: - CSharedMemoryWaitableObject::GetSynchWaitController - - Obtain a synchronization wait controller for this object. - -Parameters: - pthr -- thread data for calling thread - ppWaitController -- on success, receives a pointer to the wait controller - instance ---*/ - -PAL_ERROR -CSharedMemoryWaitableObject::GetSynchWaitController( - CPalThread *pthr, // IN, OPTIONAL - ISynchWaitController **ppWaitController // OUT - ) -{ - PAL_ERROR palError = NO_ERROR; - - _ASSERTE(NULL != pthr); - _ASSERTE(NULL != ppWaitController); - - ENTRY("CSharedMemoryWaitableObject::GetSynchWaitController" - "(this = %p, pthr = %p, ppWaitController = %p", - this, - pthr, - ppWaitController - ); - - // - // We need to grab the local synch lock before creating the controller - // (otherwise we could get promoted after passing in our parameters) - // - - g_pSynchronizationManager->AcquireProcessLock(pthr); - - palError = g_pSynchronizationManager->CreateSynchWaitController( - pthr, - m_pot, - m_pvSynchData, - m_ObjectDomain, - ppWaitController - ); - - g_pSynchronizationManager->ReleaseProcessLock(pthr); - - LOGEXIT("CSharedMemoryWaitableObject::GetSynchWaitController returns %d\n", - palError - ); - - return palError; -} - -/*++ -Function: - CSharedMemoryWaitableObject::GetObjectSynchData - - Obtain the synchronization data for this object. This method should only - be called by the synchronization manager - -Parameters: - ppvSynchData -- on success, receives a pointer to the object's synch data ---*/ - -PAL_ERROR -CSharedMemoryWaitableObject::GetObjectSynchData( - VOID **ppvSynchData // OUT - ) -{ - _ASSERTE(NULL != ppvSynchData); - - ENTRY("CSharedMemoryWaitableObject::GetObjectSynchData" - "(this = %p, ppvSynchData = %p)\n", - this, - ppvSynchData - ); - - *ppvSynchData = m_pvSynchData; - - LOGEXIT("CSharedMemoryWaitableObject::GetObjectSynchData returns %d\n", - NO_ERROR - ); - - return NO_ERROR; -} - diff --git a/src/pal/src/objmgr/shmobject.hpp b/src/pal/src/objmgr/shmobject.hpp index 9d55f90ca..1dcaa0223 100644 --- a/src/pal/src/objmgr/shmobject.hpp +++ b/src/pal/src/objmgr/shmobject.hpp @@ -296,79 +296,6 @@ namespace CorUnix ); }; - - class CSharedMemoryWaitableObject : public CSharedMemoryObject - { - template friend void InternalDelete(T *p); - - protected: - - VOID *m_pvSynchData; - - virtual ~CSharedMemoryWaitableObject(); - - public: - - CSharedMemoryWaitableObject( - CObjectType *pot, - CRITICAL_SECTION *pcsObjListLock - ) - : - CSharedMemoryObject(pot, pcsObjListLock), - m_pvSynchData(NULL) - { - }; - - // - // Constructor used to import a shared object into this process. The - // shared memory lock must be held when calling this contstructor - // - - CSharedMemoryWaitableObject( - CObjectType *pot, - CRITICAL_SECTION *pcsObjListLock, - SHMPTR shmSharedObjectData, - SHMObjData *psmod, - bool fAddRefSharedData - ) - : - CSharedMemoryObject(pot, pcsObjListLock, shmSharedObjectData, psmod, fAddRefSharedData), - m_pvSynchData(psmod->pvSynchData) - { - }; - - virtual - PAL_ERROR - Initialize( - CPalThread *pthr, - CObjectAttributes *poa - ); - - // - // IPalObject routines - // - - virtual - PAL_ERROR - GetSynchStateController( - CPalThread *pthr, - ISynchStateController **ppStateController - ); - - virtual - PAL_ERROR - GetSynchWaitController( - CPalThread *pthr, - ISynchWaitController **ppWaitController - ); - - virtual - PAL_ERROR - GetObjectSynchData( - VOID **ppvSynchData - ); - }; - } #endif // _PAL_SHMOBJECT_HPP diff --git a/src/pal/src/objmgr/shmobjectmanager.cpp b/src/pal/src/objmgr/shmobjectmanager.cpp index 90caa655e..709b5e86b 100644 --- a/src/pal/src/objmgr/shmobjectmanager.cpp +++ b/src/pal/src/objmgr/shmobjectmanager.cpp @@ -21,7 +21,6 @@ Abstract: #include "shmobject.hpp" #include "pal/cs.hpp" #include "pal/thread.hpp" -#include "pal/procobj.hpp" #include "pal/dbgmsg.h" SET_DEFAULT_DEBUG_CHANNEL(PAL); @@ -165,7 +164,7 @@ CSharedMemoryObjectManager::AllocateObject( if (CObjectType::WaitableObject == pot->GetSynchronizationSupport()) { - pshmobj = InternalNew(pot, &m_csListLock); + _ASSERTE(FALSE); } else { @@ -1096,7 +1095,7 @@ CSharedMemoryObjectManager::ImportSharedObjectIntoProcess( ) { PAL_ERROR palError = NO_ERROR; - CSharedMemoryObject *pshmobj; + CSharedMemoryObject *pshmobj = NULL; PLIST_ENTRY pleObjectList; _ASSERTE(NULL != pthr); @@ -1120,11 +1119,7 @@ CSharedMemoryObjectManager::ImportSharedObjectIntoProcess( if (CObjectType::WaitableObject == pot->GetSynchronizationSupport()) { - pshmobj = InternalNew(pot, - &m_csListLock, - shmSharedObjectData, - psmod, - fAddRefSharedData); + _ASSERTE(FALSE); } else { diff --git a/src/pal/src/sharedmemory/sharedmemory.cpp b/src/pal/src/sharedmemory/sharedmemory.cpp deleted file mode 100644 index 46c07143a..000000000 --- a/src/pal/src/sharedmemory/sharedmemory.cpp +++ /dev/null @@ -1,1163 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#include "pal/sharedmemory.h" - -#include "pal/dbgmsg.h" -#include "pal/file.hpp" -#include "pal/malloc.hpp" -#include "pal/thread.hpp" -#include "pal/virtual.h" - -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -using namespace CorUnix; - -SET_DEFAULT_DEBUG_CHANNEL(SHMEM); - -#include "pal/sharedmemory.inl" - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// AutoFreeBuffer - -AutoFreeBuffer::AutoFreeBuffer(void *buffer) : m_buffer(buffer), m_cancel(false) -{ -} - -AutoFreeBuffer::~AutoFreeBuffer() -{ - if (!m_cancel && m_buffer != nullptr) - { - free(m_buffer); - } -} - -void AutoFreeBuffer::Cancel() -{ - m_cancel = true; -} - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// SharedMemoryException - -SharedMemoryException::SharedMemoryException(DWORD errorCode) : m_errorCode(errorCode) -{ -} - -DWORD SharedMemoryException::GetErrorCode() const -{ - return m_errorCode; -} - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// SharedMemoryHelpers - -const mode_t SharedMemoryHelpers::PermissionsMask_CurrentUser_ReadWriteExecute = S_IRUSR | S_IWUSR | S_IXUSR; -const mode_t SharedMemoryHelpers::PermissionsMask_AllUsers_ReadWrite = - S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH; -const mode_t SharedMemoryHelpers::PermissionsMask_AllUsers_ReadWriteExecute = - PermissionsMask_AllUsers_ReadWrite | (S_IXUSR | S_IXGRP | S_IXOTH); -const UINT32 SharedMemoryHelpers::InvalidProcessId = static_cast(-1); -const SIZE_T SharedMemoryHelpers::InvalidThreadId = static_cast(-1); -const UINT64 SharedMemoryHelpers::InvalidSharedThreadId = static_cast(-1); - -void *SharedMemoryHelpers::Alloc(SIZE_T byteCount) -{ - void *buffer = InternalMalloc(byteCount); - if (buffer == nullptr) - { - throw SharedMemoryException(static_cast(SharedMemoryError::OutOfMemory)); - } - return buffer; -} - -SIZE_T SharedMemoryHelpers::AlignDown(SIZE_T value, SIZE_T alignment) -{ - _ASSERTE((alignment & (alignment - 1)) == 0); // must be a power of 2 - return value & ~(alignment - 1); -} - -SIZE_T SharedMemoryHelpers::AlignUp(SIZE_T value, SIZE_T alignment) -{ - _ASSERTE((alignment & (alignment - 1)) == 0); // must be a power of 2 - return AlignDown(value + (alignment - 1), alignment); -} - -bool SharedMemoryHelpers::EnsureDirectoryExists( - const char *path, - bool isGlobalLockAcquired, - bool createIfNotExist, - bool isSystemDirectory) -{ - _ASSERTE(path != nullptr); - _ASSERTE(!(isSystemDirectory && createIfNotExist)); // should not create or change permissions on system directories - _ASSERTE(SharedMemoryManager::IsCreationDeletionProcessLockAcquired()); - _ASSERTE(!isGlobalLockAcquired || SharedMemoryManager::IsCreationDeletionFileLockAcquired()); - - // Check if the path already exists - struct stat statInfo; - int statResult = stat(path, &statInfo); - if (statResult != 0 && errno == ENOENT) - { - if (!createIfNotExist) - { - return false; - } - - // The path does not exist, create the directory. The permissions mask passed to mkdir() is filtered by the process' - // permissions umask, so mkdir() may not set all of the requested permissions. We need to use chmod() to set the proper - // permissions. That creates a race when there is no global lock acquired when creating the directory. Another user's - // process may create the directory and this user's process may try to use it before the other process sets the full - // permissions. In that case, create a temporary directory first, set the permissions, and rename it to the actual - // directory name. - - if (isGlobalLockAcquired) - { - if (mkdir(path, PermissionsMask_AllUsers_ReadWriteExecute) != 0) - { - throw SharedMemoryException(static_cast(SharedMemoryError::IO)); - } - if (chmod(path, PermissionsMask_AllUsers_ReadWriteExecute) != 0) - { - rmdir(path); - throw SharedMemoryException(static_cast(SharedMemoryError::IO)); - } - return true; - } - - char tempPath[] = SHARED_MEMORY_UNIQUE_TEMP_NAME_TEMPLATE; - if (mkdtemp(tempPath) == nullptr) - { - throw SharedMemoryException(static_cast(SharedMemoryError::IO)); - } - if (chmod(tempPath, PermissionsMask_AllUsers_ReadWriteExecute) != 0) - { - rmdir(tempPath); - throw SharedMemoryException(static_cast(SharedMemoryError::IO)); - } - if (rename(tempPath, path) == 0) - { - return true; - } - - // Another process may have beaten us to it. Delete the temp directory and continue to check the requested directory to - // see if it meets our needs. - rmdir(tempPath); - statResult = stat(path, &statInfo); - } - - // If the path exists, check that it's a directory - if (statResult != 0 || !(statInfo.st_mode & S_IFDIR)) - { - throw SharedMemoryException(static_cast(SharedMemoryError::IO)); - } - - if (isSystemDirectory) - { - // For system directories (such as SHARED_MEMORY_TEMP_DIRECTORY_PATH), require sufficient permissions only for the - // current user. For instance, "docker run --mount ..." to mount /tmp to some directory on the host mounts the - // destination directory with the same permissions as the source directory, which may not include some permissions for - // other users. In the docker container, other user permissions are typically not relevant and relaxing the permissions - // requirement allows for that scenario to work without having to work around it by first giving sufficient permissions - // for all users. - if ((statInfo.st_mode & PermissionsMask_CurrentUser_ReadWriteExecute) == PermissionsMask_CurrentUser_ReadWriteExecute) - { - return true; - } - throw SharedMemoryException(static_cast(SharedMemoryError::IO)); - } - - // For non-system directories (such as SHARED_MEMORY_RUNTIME_TEMP_DIRECTORY_PATH), require sufficient permissions for all - // users and try to update them if requested to create the directory, so that shared memory files may be shared by all - // processes on the system. - if ((statInfo.st_mode & PermissionsMask_AllUsers_ReadWriteExecute) == PermissionsMask_AllUsers_ReadWriteExecute) - { - return true; - } - if (!createIfNotExist || chmod(path, PermissionsMask_AllUsers_ReadWriteExecute) != 0) - { - throw SharedMemoryException(static_cast(SharedMemoryError::IO)); - } - return true; -} - -int SharedMemoryHelpers::Open(LPCSTR path, int flags, mode_t mode) -{ - int openErrorCode; - do - { - int fileDescriptor = InternalOpen(path, flags, mode); - if (fileDescriptor != -1) - { - return fileDescriptor; - } - openErrorCode = errno; - } while (openErrorCode == EINTR); - - switch (openErrorCode) - { - case ENOENT: - _ASSERTE(!(flags & O_CREAT)); - errno = openErrorCode; - return -1; - - case ENAMETOOLONG: - throw SharedMemoryException(static_cast(SharedMemoryError::NameTooLong)); - - case EMFILE: - case ENFILE: - case ENOMEM: - throw SharedMemoryException(static_cast(SharedMemoryError::OutOfMemory)); - - default: - throw SharedMemoryException(static_cast(SharedMemoryError::IO)); - } -} - -int SharedMemoryHelpers::OpenDirectory(LPCSTR path) -{ - _ASSERTE(path != nullptr); - _ASSERTE(path[0] != '\0'); - - int fileDescriptor = Open(path, O_RDONLY); - _ASSERTE(fileDescriptor != -1 || errno == ENOENT); - return fileDescriptor; -} - -int SharedMemoryHelpers::CreateOrOpenFile(LPCSTR path, bool createIfNotExist, bool *createdRef) -{ - _ASSERTE(path != nullptr); - _ASSERTE(path[0] != '\0'); - _ASSERTE(SharedMemoryManager::IsCreationDeletionProcessLockAcquired()); - _ASSERTE(!createIfNotExist || SharedMemoryManager::IsCreationDeletionFileLockAcquired()); - - // Try to open the file - int openFlags = O_RDWR; - int fileDescriptor = Open(path, openFlags); - if (fileDescriptor != -1) - { - if (createdRef != nullptr) - { - *createdRef = false; - } - return fileDescriptor; - } - _ASSERTE(errno == ENOENT); - if (!createIfNotExist) - { - if (createdRef != nullptr) - { - *createdRef = false; - } - return -1; - } - - // File does not exist, create the file - openFlags |= O_CREAT | O_EXCL; - fileDescriptor = Open(path, openFlags, PermissionsMask_AllUsers_ReadWrite); - _ASSERTE(fileDescriptor != -1); - - // The permissions mask passed to open() is filtered by the process' permissions umask, so open() may not set all of - // the requested permissions. Use chmod() to set the proper permissions. - if (chmod(path, PermissionsMask_AllUsers_ReadWrite) != 0) - { - CloseFile(fileDescriptor); - unlink(path); - throw SharedMemoryException(static_cast(SharedMemoryError::IO)); - } - - if (createdRef != nullptr) - { - *createdRef = true; - } - return fileDescriptor; -} - -void SharedMemoryHelpers::CloseFile(int fileDescriptor) -{ - _ASSERTE(fileDescriptor != -1); - - int closeResult; - do - { - closeResult = close(fileDescriptor); - } while (closeResult != 0 && errno == EINTR); -} - -SIZE_T SharedMemoryHelpers::GetFileSize(int fileDescriptor) -{ - _ASSERTE(fileDescriptor != -1); - - off_t endOffset = lseek(fileDescriptor, 0, SEEK_END); - if (endOffset == static_cast(-1) || - lseek(fileDescriptor, 0, SEEK_SET) == static_cast(-1)) - { - throw SharedMemoryException(static_cast(SharedMemoryError::IO)); - } - return endOffset; -} - -void SharedMemoryHelpers::SetFileSize(int fileDescriptor, SIZE_T byteCount) -{ - _ASSERTE(fileDescriptor != -1); - _ASSERTE(static_cast(byteCount) == byteCount); - - while (true) - { - int ftruncateResult = ftruncate(fileDescriptor, static_cast(byteCount)); - if (ftruncateResult == 0) - { - break; - } - if (errno != EINTR) - { - throw SharedMemoryException(static_cast(SharedMemoryError::IO)); - } - } -} - -void *SharedMemoryHelpers::MemoryMapFile(int fileDescriptor, SIZE_T byteCount) -{ - _ASSERTE(fileDescriptor != -1); - _ASSERTE(byteCount > sizeof(SharedMemorySharedDataHeader)); - _ASSERTE(AlignDown(byteCount, GetVirtualPageSize()) == byteCount); - - void *sharedMemoryBuffer = mmap(nullptr, byteCount, PROT_READ | PROT_WRITE, MAP_SHARED, fileDescriptor, 0); - if (sharedMemoryBuffer != MAP_FAILED) - { - return sharedMemoryBuffer; - } - switch (errno) - { - case ENFILE: - case ENOMEM: - throw SharedMemoryException(static_cast(SharedMemoryError::OutOfMemory)); - - default: - throw SharedMemoryException(static_cast(SharedMemoryError::IO)); - } -} - -bool SharedMemoryHelpers::TryAcquireFileLock(int fileDescriptor, int operation) -{ - // A file lock is acquired once per file descriptor, so the caller will need to synchronize threads of this process - - _ASSERTE(fileDescriptor != -1); - _ASSERTE(!(operation & LOCK_UN)); - - while (true) - { - if (flock(fileDescriptor, operation) == 0) - { - return true; - } - - int flockError = errno; - switch (flockError) - { - case EWOULDBLOCK: - return false; - - case EINTR: - continue; - - default: - throw SharedMemoryException(static_cast(SharedMemoryError::OutOfMemory)); - } - } -} - -void SharedMemoryHelpers::ReleaseFileLock(int fileDescriptor) -{ - _ASSERTE(fileDescriptor != -1); - - int flockResult; - do - { - flockResult = flock(fileDescriptor, LOCK_UN); - } while (flockResult != 0 && errno == EINTR); -} - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// SharedMemoryId - -SharedMemoryId::SharedMemoryId() : m_name(nullptr) -{ -} - -SharedMemoryId::SharedMemoryId(LPCSTR name, SIZE_T nameCharCount, bool isSessionScope) - : m_name(name), m_nameCharCount(nameCharCount), m_isSessionScope(isSessionScope) -{ - _ASSERTE(name != nullptr); - _ASSERTE(nameCharCount != 0); - _ASSERTE(nameCharCount <= SHARED_MEMORY_MAX_FILE_NAME_CHAR_COUNT); - _ASSERTE(strlen(name) == nameCharCount); -} - -SharedMemoryId::SharedMemoryId(LPCSTR name) -{ - _ASSERTE(name != nullptr); - - // Look for "Global\" and "Local\" prefixes in the name, and determine the session ID - if (strncmp(name, "Global\\", 7) == 0) - { - m_isSessionScope = false; - name += _countof("Global\\") - 1; - } - else - { - if (strncmp(name, "Local\\", 6) == 0) - { - name += _countof("Local\\") - 1; - } - m_isSessionScope = true; - } - m_name = name; - - m_nameCharCount = strlen(name); - if (m_nameCharCount == 0) - { - throw SharedMemoryException(static_cast(SharedMemoryError::NameEmpty)); - } - if (m_nameCharCount > SHARED_MEMORY_MAX_FILE_NAME_CHAR_COUNT) - { - throw SharedMemoryException(static_cast(SharedMemoryError::NameTooLong)); - } - - // Look for invalid characters '\' and '/' in the name - for (SIZE_T i = 0; i < m_nameCharCount; ++i) - { - char c = name[i]; - if (c == '\\' || c == '/') - { - throw SharedMemoryException(static_cast(SharedMemoryError::NameInvalid)); - } - } -} - -LPCSTR SharedMemoryId::GetName() const -{ - _ASSERTE(m_name != nullptr); - return m_name; -} - -SIZE_T SharedMemoryId::GetNameCharCount() const -{ - _ASSERTE(m_name != nullptr); - return m_nameCharCount; -} - -bool SharedMemoryId::IsSessionScope() const -{ - _ASSERTE(m_name != nullptr); - return m_isSessionScope; -} - -bool SharedMemoryId::Equals(SharedMemoryId *other) const -{ - return - GetNameCharCount() == other->GetNameCharCount() && - IsSessionScope() == other->IsSessionScope() && - strcmp(GetName(), other->GetName()) == 0; -} - -SIZE_T SharedMemoryId::AppendSessionDirectoryName( - char (&path)[SHARED_MEMORY_MAX_FILE_PATH_CHAR_COUNT + 1], - SIZE_T pathCharCount) const -{ - if (IsSessionScope()) - { - pathCharCount = SharedMemoryHelpers::CopyString(path, pathCharCount, SHARED_MEMORY_SESSION_DIRECTORY_NAME_PREFIX); - pathCharCount = SharedMemoryHelpers::AppendUInt32String(path, pathCharCount, GetCurrentSessionId()); - } - else - { - pathCharCount = SharedMemoryHelpers::CopyString(path, pathCharCount, SHARED_MEMORY_GLOBAL_DIRECTORY_NAME); - } - - _ASSERTE(pathCharCount <= SHARED_MEMORY_MAX_FILE_PATH_CHAR_COUNT); - return pathCharCount; -} - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// SharedMemorySharedDataHeader - -SIZE_T SharedMemorySharedDataHeader::DetermineTotalByteCount(SIZE_T dataByteCount) -{ - return SharedMemoryHelpers::AlignUp(sizeof(SharedMemorySharedDataHeader) + dataByteCount, GetVirtualPageSize()); -} - -SharedMemorySharedDataHeader::SharedMemorySharedDataHeader(SharedMemoryType type, UINT8 version) - : m_type(type), m_version(version) -{ -} - -SharedMemoryType SharedMemorySharedDataHeader::GetType() const -{ - return m_type; -} - -UINT8 SharedMemorySharedDataHeader::GetVersion() const -{ - return m_version; -} - -void *SharedMemorySharedDataHeader::GetData() -{ - return this + 1; -} - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// SharedMemoryProcessDataHeader - -SharedMemoryProcessDataHeader *SharedMemoryProcessDataHeader::CreateOrOpen( - LPCSTR name, - SharedMemorySharedDataHeader requiredSharedDataHeader, - SIZE_T sharedDataByteCount, - bool createIfNotExist, - bool *createdRef) -{ - _ASSERTE(name != nullptr); - _ASSERTE(sharedDataByteCount != 0); - _ASSERTE(!createIfNotExist || createdRef != nullptr); - _ASSERTE(SharedMemoryManager::IsCreationDeletionProcessLockAcquired()); - _ASSERTE(!SharedMemoryManager::IsCreationDeletionFileLockAcquired()); - - if (createdRef != nullptr) - { - *createdRef = false; - } - - SharedMemoryId id(name); - - struct AutoCleanup - { - bool m_acquiredCreationDeletionFileLock; - char *m_filePath; - SIZE_T m_sessionDirectoryPathCharCount; - bool m_createdFile; - int m_fileDescriptor; - bool m_acquiredFileLock; - void *m_mappedBuffer; - SIZE_T m_mappedBufferByteCount; - bool m_cancel; - - AutoCleanup() - : m_acquiredCreationDeletionFileLock(false), - m_filePath(nullptr), - m_sessionDirectoryPathCharCount(0), - m_createdFile(false), - m_fileDescriptor(-1), - m_acquiredFileLock(false), - m_mappedBuffer(nullptr), - m_mappedBufferByteCount(0), - m_cancel(false) - { - } - - ~AutoCleanup() - { - if (m_cancel) - { - return; - } - - if (m_mappedBuffer != nullptr) - { - _ASSERTE(m_mappedBufferByteCount != 0); - munmap(m_mappedBuffer, m_mappedBufferByteCount); - } - - if (m_acquiredFileLock) - { - _ASSERTE(m_fileDescriptor != -1); - SharedMemoryHelpers::ReleaseFileLock(m_fileDescriptor); - } - - if (m_fileDescriptor != -1) - { - SharedMemoryHelpers::CloseFile(m_fileDescriptor); - } - - if (m_createdFile) - { - _ASSERTE(m_filePath != nullptr); - unlink(m_filePath); - } - - if (m_sessionDirectoryPathCharCount != 0) - { - _ASSERTE(m_filePath != nullptr); - m_filePath[m_sessionDirectoryPathCharCount] = '\0'; - rmdir(m_filePath); - } - - if (m_acquiredCreationDeletionFileLock) - { - SharedMemoryManager::ReleaseCreationDeletionFileLock(); - } - } - } autoCleanup; - - SharedMemoryProcessDataHeader *processDataHeader = SharedMemoryManager::FindProcessDataHeader(&id); - if (processDataHeader != nullptr) - { - _ASSERTE( - processDataHeader->GetSharedDataTotalByteCount() == - SharedMemorySharedDataHeader::DetermineTotalByteCount(sharedDataByteCount)); - processDataHeader->IncRefCount(); - return processDataHeader; - } - - SharedMemoryManager::AcquireCreationDeletionFileLock(); - autoCleanup.m_acquiredCreationDeletionFileLock = true; - - // Create the session directory - char filePath[SHARED_MEMORY_MAX_FILE_PATH_CHAR_COUNT + 1]; - SIZE_T filePathCharCount = SharedMemoryHelpers::CopyString(filePath, 0, SHARED_MEMORY_SHARED_MEMORY_DIRECTORY_PATH); - filePath[filePathCharCount++] = '/'; - filePathCharCount = id.AppendSessionDirectoryName(filePath, filePathCharCount); - if (!SharedMemoryHelpers::EnsureDirectoryExists(filePath, true /* isGlobalLockAcquired */, createIfNotExist)) - { - _ASSERTE(!createIfNotExist); - return nullptr; - } - autoCleanup.m_filePath = filePath; - autoCleanup.m_sessionDirectoryPathCharCount = filePathCharCount; - - // Create or open the shared memory file - filePath[filePathCharCount++] = '/'; - filePathCharCount = SharedMemoryHelpers::CopyString(filePath, filePathCharCount, id.GetName(), id.GetNameCharCount()); - bool createdFile; - int fileDescriptor = SharedMemoryHelpers::CreateOrOpenFile(filePath, createIfNotExist, &createdFile); - if (fileDescriptor == -1) - { - _ASSERTE(!createIfNotExist); - return nullptr; - } - autoCleanup.m_createdFile = createdFile; - autoCleanup.m_fileDescriptor = fileDescriptor; - - bool clearContents = false; - if (!createdFile) - { - // A shared file lock on the shared memory file would be held by any process that has opened the same file. Try to take - // an exclusive lock on the file. Successfully acquiring an exclusive lock indicates that no process has a reference to - // the shared memory file, and this process can reinitialize its contents. - if (SharedMemoryHelpers::TryAcquireFileLock(fileDescriptor, LOCK_EX | LOCK_NB)) - { - // The shared memory file is not being used, flag it as created so that its contents will be reinitialized - SharedMemoryHelpers::ReleaseFileLock(fileDescriptor); - autoCleanup.m_createdFile = true; - if (!createIfNotExist) - { - return nullptr; - } - createdFile = true; - clearContents = true; - } - } - - // Set or validate the file length - SIZE_T sharedDataTotalByteCount = SharedMemorySharedDataHeader::DetermineTotalByteCount(sharedDataByteCount); - if (createdFile) - { - SharedMemoryHelpers::SetFileSize(fileDescriptor, sharedDataTotalByteCount); - } - else if (SharedMemoryHelpers::GetFileSize(fileDescriptor) != sharedDataTotalByteCount) - { - throw SharedMemoryException(static_cast(SharedMemoryError::HeaderMismatch)); - } - - // Acquire and hold a shared file lock on the shared memory file as long as it is open, to indicate that this process is - // using the file. An exclusive file lock is attempted above to detect whether the file contents are valid, for the case - // where a process crashes or is killed after the file is created. Since we already hold the creation/deletion locks, a - // non-blocking file lock should succeed. - if (!SharedMemoryHelpers::TryAcquireFileLock(fileDescriptor, LOCK_SH | LOCK_NB)) - { - throw SharedMemoryException(static_cast(SharedMemoryError::IO)); - } - autoCleanup.m_acquiredFileLock = true; - - // Map the file into memory, and initialize or validate the header - void *mappedBuffer = SharedMemoryHelpers::MemoryMapFile(fileDescriptor, sharedDataTotalByteCount); - autoCleanup.m_mappedBuffer = mappedBuffer; - autoCleanup.m_mappedBufferByteCount = sharedDataTotalByteCount; - SharedMemorySharedDataHeader *sharedDataHeader; - if (createdFile) - { - if (clearContents) - { - memset(mappedBuffer, 0, sharedDataTotalByteCount); - } - sharedDataHeader = new(mappedBuffer) SharedMemorySharedDataHeader(requiredSharedDataHeader); - } - else - { - sharedDataHeader = reinterpret_cast(mappedBuffer); - if (sharedDataHeader->GetType() != requiredSharedDataHeader.GetType() || - sharedDataHeader->GetVersion() != requiredSharedDataHeader.GetVersion()) - { - throw SharedMemoryException(static_cast(SharedMemoryError::HeaderMismatch)); - } - } - - // When *createdRef is true, the creation/deletion file lock will remain locked upon returning for the caller to initialize - // the shared data. The caller must release the file lock afterwards. - if (!createdFile) - { - autoCleanup.m_acquiredCreationDeletionFileLock = false; - SharedMemoryManager::ReleaseCreationDeletionFileLock(); - } - - processDataHeader = SharedMemoryProcessDataHeader::New(&id, fileDescriptor, sharedDataHeader, sharedDataTotalByteCount); - - autoCleanup.m_cancel = true; - if (createdFile) - { - _ASSERTE(createIfNotExist); - _ASSERTE(createdRef != nullptr); - *createdRef = true; - } - return processDataHeader; -} - -SharedMemoryProcessDataHeader *SharedMemoryProcessDataHeader::PalObject_GetProcessDataHeader(CorUnix::IPalObject *object) -{ - _ASSERTE(object != nullptr); - _ASSERTE(object->GetObjectType()->GetId() == otiNamedMutex); - _ASSERTE(object->GetObjectType()->GetImmutableDataSize() == sizeof(SharedMemoryProcessDataHeader *)); - - void *immutableDataBuffer; - PAL_ERROR errorCode = object->GetImmutableData(&immutableDataBuffer); - _ASSERTE(errorCode == NO_ERROR); - _ASSERTE(immutableDataBuffer != nullptr); - return *reinterpret_cast(immutableDataBuffer); -} - -void SharedMemoryProcessDataHeader::PalObject_SetProcessDataHeader( - CorUnix::IPalObject *object, - SharedMemoryProcessDataHeader *processDataHeader) -{ - _ASSERTE(object != nullptr); - _ASSERTE(object->GetObjectType()->GetId() == otiNamedMutex); - _ASSERTE(object->GetObjectType()->GetImmutableDataSize() == sizeof(SharedMemoryProcessDataHeader *)); - _ASSERTE(processDataHeader != nullptr); - - void *immutableDataBuffer; - PAL_ERROR errorCode = object->GetImmutableData(&immutableDataBuffer); - _ASSERTE(errorCode == NO_ERROR); - _ASSERTE(immutableDataBuffer != nullptr); - *reinterpret_cast(immutableDataBuffer) = processDataHeader; -} - -void SharedMemoryProcessDataHeader::PalObject_Close( - CPalThread *thread, - IPalObject *object, - bool isShuttingDown, - bool cleanUpPalSharedState) -{ - // This function's signature matches OBJECTCLEANUPROUTINE - _ASSERTE(thread != nullptr); - _ASSERTE(object != nullptr); - _ASSERTE(object->GetObjectType()->GetId() == otiNamedMutex); - _ASSERTE(object->GetObjectType()->GetImmutableDataSize() == sizeof(SharedMemoryProcessDataHeader *)); - - SharedMemoryProcessDataHeader *processDataHeader = PalObject_GetProcessDataHeader(object); - if (processDataHeader == nullptr) - { - // The object was created, but an error must have occurred before the process data was initialized - return; - } - - SharedMemoryManager::AcquireCreationDeletionProcessLock(); - processDataHeader->DecRefCount(); - SharedMemoryManager::ReleaseCreationDeletionProcessLock(); -} - -SharedMemoryProcessDataHeader::SharedMemoryProcessDataHeader( - SharedMemoryId *id, - int fileDescriptor, - SharedMemorySharedDataHeader *sharedDataHeader, - SIZE_T sharedDataTotalByteCount) - : - m_refCount(1), - m_data(nullptr), - m_fileDescriptor(fileDescriptor), - m_sharedDataHeader(sharedDataHeader), - m_sharedDataTotalByteCount(sharedDataTotalByteCount), - m_nextInProcessDataHeaderList(nullptr) -{ - _ASSERTE(SharedMemoryManager::IsCreationDeletionProcessLockAcquired()); - _ASSERTE(id != nullptr); - _ASSERTE(fileDescriptor != -1); - _ASSERTE(sharedDataHeader != nullptr); - _ASSERTE(sharedDataTotalByteCount > sizeof(SharedMemorySharedDataHeader)); - _ASSERTE(SharedMemoryHelpers::AlignDown(sharedDataTotalByteCount, GetVirtualPageSize()) == sharedDataTotalByteCount); - - // Copy the name and initialize the ID - char *nameCopy = reinterpret_cast(this + 1); - SIZE_T nameByteCount = id->GetNameCharCount() + 1; - memcpy_s(nameCopy, nameByteCount, id->GetName(), nameByteCount); - m_id = SharedMemoryId(nameCopy, id->GetNameCharCount(), id->IsSessionScope()); - - SharedMemoryManager::AddProcessDataHeader(this); -} - -SharedMemoryProcessDataHeader *SharedMemoryProcessDataHeader::New( - SharedMemoryId *id, - int fileDescriptor, - SharedMemorySharedDataHeader *sharedDataHeader, - SIZE_T sharedDataTotalByteCount) -{ - _ASSERTE(id != nullptr); - - // Allocate space for the header and a copy of the name - SIZE_T nameByteCount = id->GetNameCharCount() + 1; - SIZE_T totalByteCount = sizeof(SharedMemoryProcessDataHeader) + nameByteCount; - void *buffer = SharedMemoryHelpers::Alloc(totalByteCount); - AutoFreeBuffer autoFreeBuffer(buffer); - SharedMemoryProcessDataHeader *processDataHeader = - new(buffer) SharedMemoryProcessDataHeader(id, fileDescriptor, sharedDataHeader, sharedDataTotalByteCount); - autoFreeBuffer.Cancel(); - return processDataHeader; -} - -SharedMemoryProcessDataHeader::~SharedMemoryProcessDataHeader() -{ - _ASSERTE(m_refCount == 0); - Close(); -} - -void SharedMemoryProcessDataHeader::Close() -{ - _ASSERTE(SharedMemoryManager::IsCreationDeletionProcessLockAcquired()); - _ASSERTE(!SharedMemoryManager::IsCreationDeletionFileLockAcquired()); - - // If the ref count is nonzero, we are shutting down the process abruptly without having closed some shared memory objects. - // There could still be threads running with active references to the shared memory object. So when the ref count is - // nonzero, don't clean up any object or global process-local state. - if (m_refCount == 0) - { - SharedMemoryManager::RemoveProcessDataHeader(this); - } - - struct AutoReleaseCreationDeletionFileLock - { - bool m_acquired; - - AutoReleaseCreationDeletionFileLock() : m_acquired(false) - { - } - - ~AutoReleaseCreationDeletionFileLock() - { - if (m_acquired) - { - SharedMemoryManager::ReleaseCreationDeletionFileLock(); - } - } - } autoReleaseCreationDeletionFileLock; - - // A shared file lock on the shared memory file would be held by any process that has opened the same file. Try to take - // an exclusive lock on the file. Successfully acquiring an exclusive lock indicates that no process has a reference to - // the shared memory file, and this process can delete the file. File locks on the shared memory file are only ever acquired - // or released while holding the creation/deletion locks, so holding the creation/deletion locks while trying an exclusive - // lock on the shared memory file guarantees that another process cannot start using the shared memory file after this - // process has decided to delete the file. - bool releaseSharedData = false; - try - { - SharedMemoryManager::AcquireCreationDeletionFileLock(); - autoReleaseCreationDeletionFileLock.m_acquired = true; - - SharedMemoryHelpers::ReleaseFileLock(m_fileDescriptor); - if (SharedMemoryHelpers::TryAcquireFileLock(m_fileDescriptor, LOCK_EX | LOCK_NB)) - { - SharedMemoryHelpers::ReleaseFileLock(m_fileDescriptor); - releaseSharedData = true; - } - } - catch (SharedMemoryException) - { - // Ignore the error, just don't release shared data - } - - if (m_data != nullptr) - { - m_data->Close(m_refCount != 0 /* isAbruptShutdown */, releaseSharedData); - } - - if (m_refCount == 0) - { - if (m_data != nullptr) - { - InternalDelete(m_data); - } - - if (releaseSharedData) - { - m_sharedDataHeader->~SharedMemorySharedDataHeader(); - } - - munmap(m_sharedDataHeader, m_sharedDataTotalByteCount); - SharedMemoryHelpers::CloseFile(m_fileDescriptor); - } - - if (!releaseSharedData) - { - return; - } - - // Delete the shared memory file, and the session directory if it's not empty - char path[SHARED_MEMORY_MAX_FILE_PATH_CHAR_COUNT + 1]; - SIZE_T sessionDirectoryPathCharCount = SharedMemoryHelpers::CopyString(path, 0, SHARED_MEMORY_SHARED_MEMORY_DIRECTORY_PATH); - path[sessionDirectoryPathCharCount++] = '/'; - sessionDirectoryPathCharCount = m_id.AppendSessionDirectoryName(path, sessionDirectoryPathCharCount); - path[sessionDirectoryPathCharCount++] = '/'; - SharedMemoryHelpers::CopyString(path, sessionDirectoryPathCharCount, m_id.GetName(), m_id.GetNameCharCount()); - unlink(path); - path[sessionDirectoryPathCharCount] = '\0'; - rmdir(path); -} - -SharedMemoryId *SharedMemoryProcessDataHeader::GetId() -{ - return &m_id; -} - -SharedMemoryProcessDataBase *SharedMemoryProcessDataHeader::GetData() const -{ - return m_data; -} - -void SharedMemoryProcessDataHeader::SetData(SharedMemoryProcessDataBase *data) -{ - _ASSERTE(SharedMemoryManager::IsCreationDeletionProcessLockAcquired()); - _ASSERTE(m_data == nullptr); - _ASSERTE(data != nullptr); - - m_data = data; -} - -SharedMemorySharedDataHeader *SharedMemoryProcessDataHeader::GetSharedDataHeader() const -{ - return m_sharedDataHeader; -} - -SIZE_T SharedMemoryProcessDataHeader::GetSharedDataTotalByteCount() const -{ - return m_sharedDataTotalByteCount; -} - -SharedMemoryProcessDataHeader *SharedMemoryProcessDataHeader::GetNextInProcessDataHeaderList() const -{ - _ASSERTE(SharedMemoryManager::IsCreationDeletionProcessLockAcquired()); - return m_nextInProcessDataHeaderList; -} - -void SharedMemoryProcessDataHeader::SetNextInProcessDataHeaderList(SharedMemoryProcessDataHeader *next) -{ - _ASSERTE(SharedMemoryManager::IsCreationDeletionProcessLockAcquired()); - m_nextInProcessDataHeaderList = next; -} - -void SharedMemoryProcessDataHeader::IncRefCount() -{ - _ASSERTE(SharedMemoryManager::IsCreationDeletionProcessLockAcquired()); - _ASSERTE(m_refCount != 0); - - ++m_refCount; -} - -void SharedMemoryProcessDataHeader::DecRefCount() -{ - _ASSERTE(SharedMemoryManager::IsCreationDeletionProcessLockAcquired()); - _ASSERTE(m_refCount != 0); - - if (--m_refCount == 0) - { - InternalDelete(this); - } -} - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// SharedMemoryManager - -CRITICAL_SECTION SharedMemoryManager::s_creationDeletionProcessLock; -int SharedMemoryManager::s_creationDeletionLockFileDescriptor = -1; - -SharedMemoryProcessDataHeader *SharedMemoryManager::s_processDataHeaderListHead = nullptr; - -#ifdef _DEBUG -SIZE_T SharedMemoryManager::s_creationDeletionProcessLockOwnerThreadId = SharedMemoryHelpers::InvalidThreadId; -SIZE_T SharedMemoryManager::s_creationDeletionFileLockOwnerThreadId = SharedMemoryHelpers::InvalidThreadId; -#endif // _DEBUG - -void SharedMemoryManager::StaticInitialize() -{ - InitializeCriticalSection(&s_creationDeletionProcessLock); -} - -void SharedMemoryManager::StaticClose() -{ - // This function could very well be running during abrupt shutdown, and there could still be user threads running. - // Synchronize the deletion, and don't remove or delete items in the linked list. - AcquireCreationDeletionProcessLock(); - for (SharedMemoryProcessDataHeader *current = s_processDataHeaderListHead; - current != nullptr; - current = current->GetNextInProcessDataHeaderList()) - { - current->Close(); - } - ReleaseCreationDeletionProcessLock(); - - // This function could very well be running during abrupt shutdown, and there could still be user threads running. Don't - // delete the creation/deletion process lock, the process is shutting down anyway. -} - -void SharedMemoryManager::AcquireCreationDeletionProcessLock() -{ - _ASSERTE(!IsCreationDeletionProcessLockAcquired()); - _ASSERTE(!IsCreationDeletionFileLockAcquired()); - - EnterCriticalSection(&s_creationDeletionProcessLock); -#ifdef _DEBUG - s_creationDeletionProcessLockOwnerThreadId = THREADSilentGetCurrentThreadId(); -#endif // _DEBUG -} - -void SharedMemoryManager::ReleaseCreationDeletionProcessLock() -{ - _ASSERTE(IsCreationDeletionProcessLockAcquired()); - _ASSERTE(!IsCreationDeletionFileLockAcquired()); - -#ifdef _DEBUG - s_creationDeletionProcessLockOwnerThreadId = SharedMemoryHelpers::InvalidThreadId; -#endif // _DEBUG - LeaveCriticalSection(&s_creationDeletionProcessLock); -} - -void SharedMemoryManager::AcquireCreationDeletionFileLock() -{ - _ASSERTE(IsCreationDeletionProcessLockAcquired()); - _ASSERTE(!IsCreationDeletionFileLockAcquired()); - - if (s_creationDeletionLockFileDescriptor == -1) - { - if (!SharedMemoryHelpers::EnsureDirectoryExists( - SHARED_MEMORY_TEMP_DIRECTORY_PATH, - false /* isGlobalLockAcquired */, - false /* createIfNotExist */, - true /* isSystemDirectory */)) - { - throw SharedMemoryException(static_cast(SharedMemoryError::IO)); - } - SharedMemoryHelpers::EnsureDirectoryExists( - SHARED_MEMORY_RUNTIME_TEMP_DIRECTORY_PATH, - false /* isGlobalLockAcquired */); - SharedMemoryHelpers::EnsureDirectoryExists( - SHARED_MEMORY_SHARED_MEMORY_DIRECTORY_PATH, - false /* isGlobalLockAcquired */); - s_creationDeletionLockFileDescriptor = SharedMemoryHelpers::OpenDirectory(SHARED_MEMORY_SHARED_MEMORY_DIRECTORY_PATH); - if (s_creationDeletionLockFileDescriptor == -1) - { - throw SharedMemoryException(static_cast(SharedMemoryError::IO)); - } - } - - bool acquiredFileLock = SharedMemoryHelpers::TryAcquireFileLock(s_creationDeletionLockFileDescriptor, LOCK_EX); - _ASSERTE(acquiredFileLock); -#ifdef _DEBUG - s_creationDeletionFileLockOwnerThreadId = THREADSilentGetCurrentThreadId(); -#endif // _DEBUG -} - -void SharedMemoryManager::ReleaseCreationDeletionFileLock() -{ - _ASSERTE(IsCreationDeletionProcessLockAcquired()); - _ASSERTE(IsCreationDeletionFileLockAcquired()); - _ASSERTE(s_creationDeletionLockFileDescriptor != -1); - -#ifdef _DEBUG - s_creationDeletionFileLockOwnerThreadId = SharedMemoryHelpers::InvalidThreadId; -#endif // _DEBUG - SharedMemoryHelpers::ReleaseFileLock(s_creationDeletionLockFileDescriptor); -} - -#ifdef _DEBUG -bool SharedMemoryManager::IsCreationDeletionProcessLockAcquired() -{ - return s_creationDeletionProcessLockOwnerThreadId == THREADSilentGetCurrentThreadId(); -} - -bool SharedMemoryManager::IsCreationDeletionFileLockAcquired() -{ - return s_creationDeletionFileLockOwnerThreadId == THREADSilentGetCurrentThreadId(); -} -#endif // _DEBUG - -void SharedMemoryManager::AddProcessDataHeader(SharedMemoryProcessDataHeader *processDataHeader) -{ - _ASSERTE(processDataHeader != nullptr); - _ASSERTE(IsCreationDeletionProcessLockAcquired()); - _ASSERTE(processDataHeader->GetNextInProcessDataHeaderList() == nullptr); - _ASSERTE(FindProcessDataHeader(processDataHeader->GetId()) == nullptr); - - processDataHeader->SetNextInProcessDataHeaderList(s_processDataHeaderListHead); - s_processDataHeaderListHead = processDataHeader; -} - -void SharedMemoryManager::RemoveProcessDataHeader(SharedMemoryProcessDataHeader *processDataHeader) -{ - _ASSERTE(processDataHeader != nullptr); - _ASSERTE(IsCreationDeletionProcessLockAcquired()); - - if (s_processDataHeaderListHead == processDataHeader) - { - s_processDataHeaderListHead = processDataHeader->GetNextInProcessDataHeaderList(); - processDataHeader->SetNextInProcessDataHeaderList(nullptr); - return; - } - for (SharedMemoryProcessDataHeader - *previous = s_processDataHeaderListHead, - *current = previous->GetNextInProcessDataHeaderList(); - current != nullptr; - previous = current, current = current->GetNextInProcessDataHeaderList()) - { - if (current == processDataHeader) - { - previous->SetNextInProcessDataHeaderList(current->GetNextInProcessDataHeaderList()); - current->SetNextInProcessDataHeaderList(nullptr); - return; - } - } - _ASSERTE(false); -} - -SharedMemoryProcessDataHeader *SharedMemoryManager::FindProcessDataHeader(SharedMemoryId *id) -{ - _ASSERTE(IsCreationDeletionProcessLockAcquired()); - - // TODO: Use a hash table - for (SharedMemoryProcessDataHeader *current = s_processDataHeaderListHead; - current != nullptr; - current = current->GetNextInProcessDataHeaderList()) - { - if (current->GetId()->Equals(id)) - { - return current; - } - } - return nullptr; -} diff --git a/src/pal/src/shmemory/shmemory.cpp b/src/pal/src/shmemory/shmemory.cpp index a12bd29c8..eaf1e0c6a 100644 --- a/src/pal/src/shmemory/shmemory.cpp +++ b/src/pal/src/shmemory/shmemory.cpp @@ -26,6 +26,7 @@ Abstract: #if HAVE_YIELD_SYSCALL #include #endif /* HAVE_YIELD_SYSCALL */ +#include SET_DEFAULT_DEBUG_CHANNEL(SHMEM); @@ -385,4 +386,4 @@ BOOL SHMSetInfo(SHM_INFO_ID element, SHMPTR value) shm_header.shm_info[element] = value; return TRUE; -} \ No newline at end of file +} diff --git a/src/pal/src/synchmgr/synchcontrollers.cpp b/src/pal/src/synchmgr/synchcontrollers.cpp deleted file mode 100644 index 6eae9187d..000000000 --- a/src/pal/src/synchmgr/synchcontrollers.cpp +++ /dev/null @@ -1,2046 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*++ - - - -Module Name: - - synchcontrollers.cpp - -Abstract: - Implementation of Synchronization Controllers and related objects - - - ---*/ - -#include "pal/dbgmsg.h" - -SET_DEFAULT_DEBUG_CHANNEL(SYNC); // some headers have code with asserts, so do this first - -#include "synchmanager.hpp" - -#include -#include -#include -#include -#include -#include -#include - -namespace CorUnix -{ -#ifdef SYNCH_STATISTICS - LONG g_rglStatWaitCount[ObjectTypeIdCount] = { 0 }; - LONG g_rglStatContentionCount[ObjectTypeIdCount] = { 0 }; -#endif // SYNCH_STATISTICS - //////////////////////////// - // // - // CSynchControllerBase // - // // - //////////////////////////// - - /*++ - Method: - CSynchControllerBase::Init - - Initializes a generic controller - --*/ - PAL_ERROR CSynchControllerBase::Init( - CPalThread * pthrCurrent, - ControllerType ctCtrlrType, - ObjectDomain odObjectDomain, - CObjectType *potObjectType, - CSynchData * psdSynchData, - WaitDomain wdWaitDomain) - { - VALIDATEOBJECT(psdSynchData); - - _ASSERTE(InternalGetCurrentThread() == pthrCurrent); - - // Initialize internal controller data - m_pthrOwner = pthrCurrent; - m_ctCtrlrType = ctCtrlrType; - m_odObjectDomain = odObjectDomain; - m_potObjectType = potObjectType; - m_psdSynchData = psdSynchData; - m_wdWaitDomain = wdWaitDomain; - - // Add reference to target synch data - m_psdSynchData->AddRef(); - - // Acquire lock implied by the controller - CPalSynchronizationManager::AcquireLocalSynchLock(m_pthrOwner); - if (LocalWait != m_wdWaitDomain) - { - CPalSynchronizationManager::AcquireSharedSynchLock(m_pthrOwner); - } - - return NO_ERROR; - } - - /*++ - Method: - CSynchControllerBase::Release - - Releases a generic controller a return it to the appropriate cache - --*/ - void CSynchControllerBase::Release() - { - VALIDATEOBJECT(m_psdSynchData); - -#ifdef _DEBUG - ThreadWaitInfo * ptwiWaitInfo = - CPalSynchronizationManager::GetThreadWaitInfo(m_pthrOwner); -#endif // _DEBUG - - CPalSynchronizationManager * pSynchManager = - CPalSynchronizationManager::GetInstance(); - - _ASSERTE(InternalGetCurrentThread() == m_pthrOwner); - _ASSERTE(ptwiWaitInfo->pthrOwner == m_pthrOwner); - - // Release reference to target synch data - m_psdSynchData->Release(m_pthrOwner); - - // Release lock implied by the controller - if (LocalWait != m_wdWaitDomain) - { - CPalSynchronizationManager::ReleaseSharedSynchLock(m_pthrOwner); - } - CPalSynchronizationManager::ReleaseLocalSynchLock(m_pthrOwner); - - // Return controller to the appropriate cache - if (WaitController == m_ctCtrlrType) - { - // The cast here must be static_cast and not reinterpet_cast. - // In fact in general static_cast(this) is - // equal to this-sizeof(void*), given that CSynchWaitController - // has a virtual table, while CSynchControllerBase doesn't. - pSynchManager->CacheAddWaitCtrlr(m_pthrOwner, - static_cast(this)); - } - else - { - // The cast here must be static_cast and not reinterpet_cast - pSynchManager->CacheAddStateCtrlr(m_pthrOwner, - static_cast(this)); - } - } - - //////////////////////////// - // // - // CSynchWaitController // - // // - //////////////////////////// - - /*++ - Method: - CSynchWaitController::CanThreadWaitWithoutBlocking - - Returns whether or not the thread owning this controller can - wait on the target object without blocking (i.e. the objet is - signaled) - --*/ - PAL_ERROR CSynchWaitController::CanThreadWaitWithoutBlocking( - bool * pfCanWaitWithoutBlocking, - bool * pfAbandoned) - { - VALIDATEOBJECT(m_psdSynchData); - - bool fRetVal = false; - - _ASSERTE(InternalGetCurrentThread() == m_pthrOwner); - _ASSERTE(NULL != pfCanWaitWithoutBlocking); - _ASSERTE(NULL != pfAbandoned); - - fRetVal = m_psdSynchData->CanWaiterWaitWithoutBlocking(m_pthrOwner, pfAbandoned); - - if(!fRetVal && otiProcess == m_psdSynchData->GetObjectTypeId()) - { - // Note: if the target object is a process, here we need to check - // whether or not it has already exited. In fact, since currently - // we do not monitor a process status as long as there is no - // thread waiting on it, in general if the process already exited - // the process object is likely not to be signaled yet, therefore - // the above CanWaiterWaitWithoutBlocking call probably returned - // false, and, without the check below, that would cause the - // current thread to eventually go to sleep for a short time - // (until the worker thread notifies that the waited process has - // indeed exited), while it would not be necessary. - // As side effect that would cause a WaitForSingleObject with zero - // timeout to always return WAIT_TIMEOUT, even though the target - // process already exited. WaitForSingleObject with zero timeout - // is a common way to probe whether or not a process has already - // exited, and it is supposed to return WAIT_OBJECT_0 if the - // process exited, and WAIT_TIMEOUT if it is still active. - // In order to support this feature we need to check at this time - // whether or not the process has already exited. - - CProcProcessLocalData * pProcLocalData = GetProcessLocalData(); - DWORD dwExitCode = 0; - bool fIsActualExitCode = false; - - _ASSERT_MSG(NULL != pProcLocalData, - "Process synch data pointer is missing\n"); - - if (NULL != pProcLocalData && - CPalSynchronizationManager::HasProcessExited(pProcLocalData->dwProcessId, - &dwExitCode, - &fIsActualExitCode)) - { - TRACE("Process pid=%u exited with %s exitcode=%u\n", - pProcLocalData->dwProcessId, - fIsActualExitCode ? "actual" : "guessed", - dwExitCode); - - // Store the exit code in the process local data - if (fIsActualExitCode) - { - pProcLocalData->dwExitCode = dwExitCode; - } - - // Set process status to PS_DONE - pProcLocalData->ps = PS_DONE; - - // Set signal count - m_psdSynchData->SetSignalCount(1); - - // Releasing all local waiters - // (see comments in DoMonitorProcesses) - m_psdSynchData->ReleaseAllLocalWaiters(m_pthrOwner); - - fRetVal = true; - } - } - - *pfCanWaitWithoutBlocking = fRetVal; - return NO_ERROR; - } - - /*++ - Method: - CSynchWaitController::ReleaseWaitingThreadWithoutBlocking - - Performs all the steps needed to be done by the controller's owner - thread in order to wait on the target object without blocking - (e.g. modifying the object signal count accordingly with its - thread release semantics) - This method should be called only after having received positive - response from CanThreadWaitWithoutBlocking called on the same - controller. - --*/ - PAL_ERROR CSynchWaitController::ReleaseWaitingThreadWithoutBlocking() - { - VALIDATEOBJECT(m_psdSynchData); - - PAL_ERROR palErr = NO_ERROR; - - _ASSERTE(InternalGetCurrentThread() == m_pthrOwner); - - palErr = m_psdSynchData->ReleaseWaiterWithoutBlocking(m_pthrOwner, m_pthrOwner); - -#ifdef SYNCH_STATISTICS - if (NO_ERROR == palErr) - { - m_psdSynchData->IncrementStatWaitCount(); - } -#endif - return palErr; - } - - /*++ - Method: - CSynchWaitController::RegisterWaitingThread - - Registers the controller's owner thread for waiting on the target - object - --*/ - PAL_ERROR CSynchWaitController::RegisterWaitingThread( - WaitType wtWaitType, - DWORD dwIndex, - bool fAlertable, - bool fPrioritize) - { - VALIDATEOBJECT(m_psdSynchData); - - PAL_ERROR palErr = NO_ERROR; - WaitingThreadsListNode * pwtlnNewNode = NULL; - SharedID shridNewNode = NULL; - ThreadWaitInfo * ptwiWaitInfo; - DWORD * pdwWaitState; - bool fSharedObject = (SharedObject == m_odObjectDomain); - bool fEarlyDeath = false; - bool fSynchDataRefd = false; - CPalSynchronizationManager * pSynchManager = - CPalSynchronizationManager::GetInstance(); - - _ASSERTE(InternalGetCurrentThread() == m_pthrOwner); - - ptwiWaitInfo = CPalSynchronizationManager::GetThreadWaitInfo( - m_pthrOwner); - - _ASSERTE(ptwiWaitInfo->pthrOwner == m_pthrOwner); - - pdwWaitState = SharedIDToTypePointer(DWORD, - m_pthrOwner->synchronizationInfo.m_shridWaitAwakened); - - if (fSharedObject) - { - shridNewNode = pSynchManager->CacheGetSharedWTListNode(m_pthrOwner); - pwtlnNewNode = SharedIDToTypePointer(WaitingThreadsListNode, shridNewNode); - } - else - { - pwtlnNewNode = pSynchManager->CacheGetLocalWTListNode(m_pthrOwner); - } - - if (!pwtlnNewNode) - { - if (fSharedObject && (NULL != shridNewNode)) - { - ASSERT("Bad Shared Memory ptr %p\n", shridNewNode); - palErr = ERROR_INTERNAL_ERROR; - } - else - { - ERROR("Out of memory\n"); - palErr = ERROR_NOT_ENOUGH_MEMORY; - } - goto RWT_exit; - } - - if (ptwiWaitInfo->lObjCount >= MAXIMUM_WAIT_OBJECTS) - { - ASSERT("Too many objects"); - palErr = ERROR_INTERNAL_ERROR; - goto RWT_exit; - } - - if (0 == ptwiWaitInfo->lObjCount) - { - ptwiWaitInfo->wtWaitType = wtWaitType; - ptwiWaitInfo->wdWaitDomain = m_wdWaitDomain; - } - else - { - _ASSERT_MSG(wtWaitType == ptwiWaitInfo->wtWaitType, - "Conflicting wait types in wait registration\n"); - - if (m_wdWaitDomain != ptwiWaitInfo->wdWaitDomain) - { - ptwiWaitInfo->wdWaitDomain = MixedWait; - } - } - - pwtlnNewNode->shridSHRThis = NULL; - pwtlnNewNode->ptwiWaitInfo = ptwiWaitInfo; - pwtlnNewNode->dwObjIndex = dwIndex; - pwtlnNewNode->dwProcessId = gPID; - pwtlnNewNode->dwThreadId = m_pthrOwner->GetThreadId(); - pwtlnNewNode->dwFlags = (MultipleObjectsWaitAll == wtWaitType) ? - WTLN_FLAG_WAIT_ALL : 0; - pwtlnNewNode->shridWaitingState = m_pthrOwner->synchronizationInfo.m_shridWaitAwakened; - if (fSharedObject) - { - pwtlnNewNode->dwFlags |= WTLN_FLAG_OWNER_OBJECT_IS_SHARED; - pwtlnNewNode->shridSHRThis = shridNewNode; - pwtlnNewNode->ptrOwnerObjSynchData.shrid = m_psdSynchData->GetSharedThis(); - } - else - { - pwtlnNewNode->ptrOwnerObjSynchData.ptr = m_psdSynchData; - } - - // AddRef the synch data (will be released in UnregisterWait) - m_psdSynchData->AddRef(); - fSynchDataRefd = true; - - ptwiWaitInfo->rgpWTLNodes[ptwiWaitInfo->lObjCount] = pwtlnNewNode; - - if(otiProcess == m_psdSynchData->GetObjectTypeId()) - { - CProcProcessLocalData * pProcLocalData = GetProcessLocalData(); - - if (NULL == pProcLocalData) - { - // Process local data pointer not set in the controller. - // This pointer is set in CSynchWaitController only when the - // wait controller for the object is created by calling - // GetSynchWaitControllersForObjects - ASSERT("Process synch data pointer is missing\n"); - palErr = ERROR_INTERNAL_ERROR; - goto RWT_exit; - } - - palErr = pSynchManager->RegisterProcessForMonitoring(m_pthrOwner, - m_psdSynchData, - m_pProcessObject, - pProcLocalData); - if (NO_ERROR != palErr) - { - goto RWT_exit; - } - } - - if (0 == ptwiWaitInfo->lObjCount) - { - DWORD dwWaitState; - - // Setting the thread in wait state - dwWaitState = (DWORD)(fAlertable ? TWS_ALERTABLE: TWS_WAITING); - - TRACE("Switching my wait state [%p] from TWS_ACTIVE to %u \n", - pdwWaitState, dwWaitState); - - dwWaitState = InterlockedCompareExchange( - (LONG *)pdwWaitState, (LONG)dwWaitState, TWS_ACTIVE); - if ((DWORD)TWS_ACTIVE != dwWaitState) - { - if ((DWORD)TWS_EARLYDEATH == dwWaitState) - { - // Process is terminating, this thread will soon be - // suspended (by SuspendOtherThreads). - WARN("Thread is about to get suspended by " - "TerminateProcess\n"); - - fEarlyDeath = true; - palErr = WAIT_FAILED; - } - else - { - ASSERT("Unexpected thread wait state %d\n", dwWaitState); - palErr = ERROR_INTERNAL_ERROR; - } - goto RWT_exit; - } - } - - // Add new node to queue - if (fSharedObject) - { - m_psdSynchData->SharedWaiterEnqueue(shridNewNode, fPrioritize); - ptwiWaitInfo->lSharedObjCount += 1; - } - else - { - m_psdSynchData->WaiterEnqueue(pwtlnNewNode, fPrioritize); - } - - // Succeeded: update object count - ptwiWaitInfo->lObjCount++; - - RWT_exit: - if (palErr != NO_ERROR) - { - // Unregister any partial wait registration - pSynchManager->UnRegisterWait(m_pthrOwner, ptwiWaitInfo, fSharedObject); - - if (fSynchDataRefd) - { - m_psdSynchData->Release(m_pthrOwner); - } - if ((fSharedObject) && (NULL != shridNewNode)) - { - pSynchManager->CacheAddSharedWTListNode(m_pthrOwner, shridNewNode); - } - else if (NULL != pwtlnNewNode) - { - pSynchManager->CacheAddLocalWTListNode(m_pthrOwner, pwtlnNewNode); - } - - if (fEarlyDeath) - { - // Early death detected, i.e. the process is about to exit. - // We need to completely release the synch lock(s) before - // going to sleep - LONG lLocalSynchLockCount; - LONG lSharedSynchLockCount; - - lSharedSynchLockCount = CPalSynchronizationManager::ResetSharedSynchLock(m_pthrOwner); - lLocalSynchLockCount = CPalSynchronizationManager::ResetLocalSynchLock(m_pthrOwner); - - _ASSERTE(0 < lLocalSynchLockCount); - - // Sleep for ever - CPalSynchronizationManager::ThreadPrepareForShutdown(); - } - } -#ifdef SYNCH_STATISTICS - else - { - m_psdSynchData->IncrementStatWaitCount(); - m_psdSynchData->IncrementStatContentionCount(); - } -#endif - return palErr; - } - - /*++ - Method: - CSynchWaitController::ReleaseController - - Releases the current controller - --*/ - void CSynchWaitController::ReleaseController() - { - VALIDATEOBJECT(m_psdSynchData); - - _ASSERTE(InternalGetCurrentThread() == m_pthrOwner); - - Release(); - } - - /*++ - Method: - CSynchWaitController::GetProcessLocalData - - Accessor Get method for process local data of the target object - --*/ - CProcProcessLocalData * CSynchWaitController::GetProcessLocalData() - { - VALIDATEOBJECT(m_psdSynchData); - - _ASSERTE(InternalGetCurrentThread() == m_pthrOwner); - _ASSERT_MSG(NULL != m_pProcLocalData, - "Pointer to process local data not yet initialized\n"); - - return m_pProcLocalData; - } - - /*++ - Method: - CSynchWaitController::SetProcessData - - Accessor Set method for process local data of the target object - --*/ - void CSynchWaitController::SetProcessData(IPalObject* pProcessObject, CProcProcessLocalData * pProcLocalData) - { - VALIDATEOBJECT(m_psdSynchData); - - _ASSERTE(InternalGetCurrentThread() == m_pthrOwner); - _ASSERT_MSG(m_pProcessObject == nullptr, "SetProcessData should not be called more than once"); - _ASSERT_MSG(pProcessObject != nullptr && pProcessObject->GetObjectType()->GetId() == otiProcess, "Invalid process object passed to SetProcessData"); - - m_pProcessObject = pProcessObject; - m_pProcLocalData = pProcLocalData; - } - - ///////////////////////////// - // // - // CSynchStateController // - // // - ///////////////////////////// - - /*++ - Method: - CSynchStateController::GetSignalCount - - Returns the current signal count of the target object - --*/ - PAL_ERROR CSynchStateController::GetSignalCount(LONG *plSignalCount) - { - VALIDATEOBJECT(m_psdSynchData); - - PAL_ERROR palErr = NO_ERROR; - LONG lCount = m_psdSynchData->GetSignalCount(); - - _ASSERTE(InternalGetCurrentThread() == m_pthrOwner); - _ASSERTE(NULL != plSignalCount); - _ASSERT_MSG(0 <= lCount, - "Internal error: negative signal count [signal count=%d]", - lCount); - - *plSignalCount = lCount; - return palErr; - } - - /*++ - Method: - CSynchStateController::SetSignalCount - - Sets the signal count of the target object, possibly triggering - waiting threads awakening. - --*/ - PAL_ERROR CSynchStateController::SetSignalCount(LONG lNewCount) - { - VALIDATEOBJECT(m_psdSynchData); - - _ASSERTE(InternalGetCurrentThread() == m_pthrOwner); - _ASSERTE(lNewCount >= 0); - - m_psdSynchData->Signal(m_pthrOwner, lNewCount, false); - - return NO_ERROR; - } - - /*++ - Method: - CSynchStateController::IncrementSignalCount - - Increments the signal count of the target object, possibly triggering - waiting threads awakening. - --*/ - PAL_ERROR CSynchStateController::IncrementSignalCount( - LONG lAmountToIncrement) - { - VALIDATEOBJECT(m_psdSynchData); - - _ASSERTE(InternalGetCurrentThread() == m_pthrOwner); - _ASSERTE(lAmountToIncrement > 0); - - LONG lOldCount = m_psdSynchData->GetSignalCount(); - LONG lNewCount = lOldCount + lAmountToIncrement; - - _ASSERT_MSG(lNewCount > lOldCount, - "Signal count increment %d would make current signal count %d to " - "wrap around\n", lAmountToIncrement, lOldCount); - - m_psdSynchData->Signal(m_pthrOwner, lNewCount, false); - - return NO_ERROR; - } - - /*++ - Method: - CSynchStateController::DecrementSignalCount - - Decrements the signal count of the target object. - --*/ - PAL_ERROR CSynchStateController::DecrementSignalCount( - LONG lAmountToDecrement) - { - VALIDATEOBJECT(m_psdSynchData); - - _ASSERTE(InternalGetCurrentThread() == m_pthrOwner); - _ASSERTE(lAmountToDecrement > 0); - - PAL_ERROR palErr = NO_ERROR; - LONG lCount = m_psdSynchData->GetSignalCount(); - _ASSERTE(lAmountToDecrement <= lCount); - - m_psdSynchData->SetSignalCount(lCount - lAmountToDecrement); - - return palErr; - } - - /*++ - Method: - CSynchStateController::SetOwner - - Sets the owner of the target object and initializes the ownership - count to 1 (for objects with tracked ownership). - --*/ - PAL_ERROR CSynchStateController::SetOwner(CPalThread * pNewOwningThread) - { - VALIDATEOBJECT(m_psdSynchData); - - PAL_ERROR palErr = NO_ERROR; - - _ASSERTE(InternalGetCurrentThread() == m_pthrOwner); - _ASSERTE(NULL != pNewOwningThread); - _ASSERT_MSG(CObjectType::OwnershipTracked == - m_potObjectType->GetOwnershipSemantics(), - "SetOwner called on an object without OwnershipTracked " - "semantics\n"); - - if (0 != m_psdSynchData->GetOwnershipCount()) - { - ASSERT("Ownership count should be zero at this time\n"); - palErr = ERROR_INTERNAL_ERROR; - goto SO_exit; - } - - palErr = m_psdSynchData->AssignOwnershipToThread(m_pthrOwner, - pNewOwningThread); - - _ASSERT_MSG(0 == m_psdSynchData->GetOwnershipCount() || - 0 == m_psdSynchData->GetSignalCount(), - "Conflicting values for SignalCount [%d] and " - "OwnershipCount [%d]\n", - m_psdSynchData->GetOwnershipCount(), - m_psdSynchData->GetSignalCount()); - - SO_exit: - return palErr; - } - - /*++ - Method: - CSynchStateController::DecrementOwnershipCount - - Decrements the ownership count of the target object possibly triggering - waiting threads awakening (for objects with tracked ownership). - --*/ - PAL_ERROR CSynchStateController::DecrementOwnershipCount() - { - VALIDATEOBJECT(m_psdSynchData); - - PAL_ERROR palErr = NO_ERROR; - LONG lOwnershipCount = m_psdSynchData->GetOwnershipCount(); - - _ASSERTE(InternalGetCurrentThread() == m_pthrOwner); - _ASSERT_MSG(CObjectType::OwnershipTracked == - m_potObjectType->GetOwnershipSemantics(), - "Trying to decrement ownership count on an object with " - "ownership semantics other than OwnershipTracked\n"); - _ASSERT_MSG(0 <= lOwnershipCount, - "Operation would make ownership count negative - object " - "should be owned at this time [ownership count=%d]\n", - lOwnershipCount); - - if ( (1 > lOwnershipCount) || - (m_psdSynchData->GetOwnerProcessID() != gPID) || - (m_psdSynchData->GetOwnerThread() != m_pthrOwner) ) - { - palErr = ERROR_NOT_OWNER; - goto DOC_exit; - } - - lOwnershipCount--; - m_psdSynchData->SetOwnershipCount(lOwnershipCount); - - if (0 == lOwnershipCount) - { - CPalSynchronizationManager * pSynchManager = - CPalSynchronizationManager::GetInstance(); - OwnedObjectsListNode * pooln = - m_psdSynchData->GetOwnershipListNode(); - - _ASSERT_MSG(NULL != pooln, - "Null ownership node pointer in SynchData with ownership " - "semantics\n"); - _ASSERT_MSG(m_psdSynchData == pooln->pPalObjSynchData, - "Corrupted ownership node\n"); - - // Object has been released - // Remove it from list of owned objs for current thread - m_pthrOwner->synchronizationInfo.RemoveObjectFromOwnedList(pooln); - - // Release SynchData reference count implied by the ownership - // list node - m_psdSynchData->Release(m_pthrOwner); - - // Return node to the cache - pSynchManager->CacheAddOwnedObjsListNode(m_pthrOwner, pooln); - - // Reset ownership - m_psdSynchData->ResetOwnership(); - - // Signal it and trigger waiter thread awakening - m_psdSynchData->Signal(m_pthrOwner, 1, false); - } - - DOC_exit: - return palErr; - } - - /*++ - Method: - CSynchStateController::ReleaseController - - Releases the controller. - --*/ - void CSynchStateController::ReleaseController(void) - { - VALIDATEOBJECT(m_psdSynchData); - - _ASSERTE(InternalGetCurrentThread() == m_pthrOwner); - - Release(); - } - - ////////////////// - // // - // CSynchData // - // // - ////////////////// - - /*++ - Method: - CSynchData::Release - - Decremnt the reference count of the target synchdata and retrurns - it to the appropriate cache if the reference count reaches zero. - --*/ - LONG CSynchData::Release(CPalThread * pthrCurrent) - { - VALIDATEOBJECT(this); - - LONG lCount = InterlockedDecrement(&m_lRefCount); - - _ASSERT_MSG(0 <= lCount, - "CSynchData %p with negative reference count [%d]\n", - this, lCount); - - if (0 == lCount) - { - CPalSynchronizationManager * pSynchManager = - CPalSynchronizationManager::GetInstance(); - bool fSharedObject = (SharedObject == m_odObjectDomain); - - _ASSERT_MSG((fSharedObject && (NULL == m_ptrWTLHead.shrid)) || - (!fSharedObject && (NULL == m_ptrWTLHead.ptr)), - "Final Release on CSynchData with threads still in " - "the waiting list\n"); - - TRACE("Disposing %s waitable object with SynchData @ " - "{shrid=%p, p=%p}\n", - (SharedObject == m_odObjectDomain) ? "shared" : "local", - (PVOID)m_shridThis, this); - - -#ifdef SYNCH_STATISTICS - LONG lStatWaitCount = GetStatWaitCount(); - LONG lStatContentionCount = GetStatContentionCount(); - LONG lCount, lNewCount; - - TRACE("Statistical data for SynchData of otiType=%u @ %p: WaitCount=%d " - "ContentionCount=%d\n", m_otiObjectTypeId, this, lStatWaitCount, - lStatContentionCount); - - do { - lCount = g_rglStatWaitCount[m_otiObjectTypeId]; - lNewCount = lCount + lStatWaitCount; - lNewCount = InterlockedCompareExchange(&(g_rglStatWaitCount[m_otiObjectTypeId]), - lNewCount, lCount); - } while (lCount != lNewCount); - - lStatWaitCount = lNewCount; - - do { - lCount = g_rglStatContentionCount[m_otiObjectTypeId]; - lNewCount = lCount + lStatContentionCount; - lNewCount = InterlockedCompareExchange(&(g_rglStatContentionCount[m_otiObjectTypeId]), - lNewCount, lCount); - } while (lCount != lNewCount); - - lStatContentionCount = lNewCount; - - TRACE("Total current statistical data for otiType=%u objects: WaitCount=%d " - "ContentionCount=%d\n", m_otiObjectTypeId, lStatWaitCount, - lStatContentionCount); -#endif // SYNCH_STATISTICS - - if (fSharedObject) - { - pSynchManager->CacheAddSharedSynchData(pthrCurrent, m_shridThis); - } - else - { - pSynchManager->CacheAddLocalSynchData(pthrCurrent, this); - } - } - - return lCount; - } - - /*++ - Method: - CSynchData::ReleaseWaiterWithoutBlocking - - Performs all the steps needed to be done by the target thread in order - to wait without blocking on the object associated with the current - SynchData (e.g. modifying the object signal count accordingly with its - thread release semantics) - - Note: this method must be called while holding the appropriate - synchronization locks (the local process synch lock if the target - object is local, both local and shared one if the object is shared). - --*/ - PAL_ERROR CSynchData::ReleaseWaiterWithoutBlocking( - CPalThread * pthrCurrent, - CPalThread * pthrTarget) - { - VALIDATEOBJECT(this); - - PAL_ERROR palErr = NO_ERROR; - CObjectType * potObjectType = GetObjectType(); -#ifdef _DEBUG - CObjectType::SignalingSemantics ssSignalingSemantics = - potObjectType->GetSignalingSemantics(); -#endif // _DEBUG - CObjectType::OwnershipSemantics osOwnershipSemantics = - potObjectType->GetOwnershipSemantics(); - CObjectType::ThreadReleaseSemantics trsThreadReleaseSemantics = - potObjectType->GetThreadReleaseSemantics(); - bool fReenteringObjWithOwnership = false; - - _ASSERT_MSG(CObjectType::SignalingNotApplicable != ssSignalingSemantics, - "Signaling not applicable"); - _ASSERT_MSG(CObjectType::ThreadReleaseNotApplicable != - trsThreadReleaseSemantics, - "Thread releasing not applicable"); - _ASSERT_MSG(CObjectType::SingleTransitionObject != ssSignalingSemantics || - (CObjectType::ThreadReleaseHasNoSideEffects == - trsThreadReleaseSemantics && - CObjectType::NoOwner == osOwnershipSemantics), - "Conflicting object synchronization attributes " - "[SignalingSemantics=%u OwnershipSemantics=%u " - "ThreadReleaseSemantics=%u]\n", ssSignalingSemantics, - osOwnershipSemantics, trsThreadReleaseSemantics); - - if (CObjectType::OwnershipTracked == osOwnershipSemantics && - 0 < GetOwnershipCount()) - { - // We are rentering an object with ownership: we need to skip - // the object unsignaling - fReenteringObjWithOwnership = true; - } - - if (!fReenteringObjWithOwnership && - CObjectType::ThreadReleaseAltersSignalCount == trsThreadReleaseSemantics) - { - _ASSERT_MSG(0 < GetSignalCount(), - "Internal error: operation would make signal count " - "negative - object should be signaled at this time " - "[signal count=%d]", GetSignalCount()); - _ASSERT_MSG(CObjectType::OwnershipTracked != osOwnershipSemantics || - 1 == GetSignalCount(), - "Ownable objects cannot have signal count greater " - "than zero [current SignalCount=%d]\n", - GetSignalCount()); - - // Unsignal the object - DecrementSignalCount(); - } - - if (CObjectType::OwnershipTracked == osOwnershipSemantics) - { - _ASSERT_MSG(0 == GetOwnershipCount() || 0 == GetSignalCount(), - "OwnershipCount and SignalCount with conflicting " - "values\n"); - - // Take ownership or increment ownership count. - // We do this after the object unsignaling to minimize possibilities - // of having both SignalCount and OwnershipCount greater than zero - // (see comment in AssignOwnershipToThread) - palErr = AssignOwnershipToThread(pthrCurrent, pthrTarget); - - if (NO_ERROR != palErr) - { - ERROR("AssignOwnershipToThread failed with error %u; " - "ownership data on object with SynchData {shrid=%p p=%p} " - "may be corrupted\n", palErr, (void *)m_shridThis, this); - } - } - -#ifdef SYNCH_STATISTICS - if (NO_ERROR == palErr) - { - IncrementStatWaitCount(); - } -#endif - return palErr; - - } - - /*++ - Method: - CSynchData::CanWaiterWaitWithoutBlocking - - Returns whether or not the waiter thread can wait on the target object - without blocking (i.e. the objet is signaled) - - Note: this method must be called while holding the appropriate - synchronization locks (the local process synch lock if the target - object is local, both local and shared one if the object is shared). - --*/ - bool CSynchData::CanWaiterWaitWithoutBlocking( - CPalThread * pWaiterThread, - bool * pfAbandoned) - { - VALIDATEOBJECT(this); - - bool fRetVal = (0 < GetSignalCount()); - bool fAbandoned = false; - bool fOwnershipTracked = (CObjectType::OwnershipTracked == - GetObjectType()->GetOwnershipSemantics()); - if (fRetVal) - { - // Object signaled: thread can wait without blocking - if (fOwnershipTracked) - { - fAbandoned = IsAbandoned(); - } - - goto CWWWB_exit; - } - - // Object not signaled: thread can wait without blocking only if the - // object is an ownable one, and it is owned by the current thread - if (fOwnershipTracked) - { - _ASSERT_MSG(0 < GetSignalCount() || 0 < GetOwnershipCount(), - "Objects with ownership must be either signaled or " - "owned by a thread\n"); - - if ((GetOwnerProcessID() == gPID) && - (GetOwnerThread() == pWaiterThread) ) - { - fRetVal = true; - goto CWWWB_exit; - } - } - - CWWWB_exit: - *pfAbandoned = fAbandoned; - return fRetVal; - } - - /*++ - Method: - CSynchData::Signal - - Sets the signal count of the object owning the target SynchData, - possibly triggering awakening of waiting threads. - - Note: this method must be called while holding the appropriate - synchronization locks (the local process synch lock if the target - object is local, both local and shared one if the object is shared). - --*/ - void CSynchData::Signal( - CPalThread * pthrCurrent, - LONG lSignalCount, - bool fWorkerThread) - { - VALIDATEOBJECT(this); - - bool fThreadReleased = false; - bool fDelegatedSignaling = false; - bool fReleaseAltersSignalCount = - (CObjectType::ThreadReleaseAltersSignalCount == - GetObjectType()->GetThreadReleaseSemantics()); - - _ASSERTE(0 <= lSignalCount); - - // Preset the signal count to the new value, so that it can be used - // by ReleaseFirstWaiter when delegating signaling to another process - m_lSignalCount = lSignalCount; - - while (m_lSignalCount > 0) - { - fThreadReleased = ReleaseFirstWaiter(pthrCurrent, - &fDelegatedSignaling, - fWorkerThread); - if (!fThreadReleased) - { - // No more threads to release: break out of the loop - // keeping the current signal count - break; - } - if (fReleaseAltersSignalCount) - { - // Adjust signal count - m_lSignalCount--; - } - if (fDelegatedSignaling) - { - // Object signaling has been delegated - m_lSignalCount = 0; - } - } - - _ASSERT_MSG(CObjectType::OwnershipTracked != - GetObjectType()->GetOwnershipSemantics() || - 0 == GetOwnershipCount() || 0 == GetSignalCount(), - "Conflicting values for SignalCount [%d] and " - "OwnershipCount [%d]\n", - GetOwnershipCount(), GetSignalCount()); - - _ASSERT_MSG(otiMutex != m_otiObjectTypeId || m_lSignalCount <= 1, - "Mutex with invalid singal count\n"); - - return; - } - - /*++ - Method: - CSynchData::ReleaseFirstWaiter - - Releases the first thread from the front of the list of waiting threads - whose wait is fully satisfied, possibly triggering remote awakening (if - the target thread lives in a different process) or object signaling - delegation (if the target thread lives in a different processing and it - is blocked on a wait-all). - - Note: this method must be called while holding the appropriate - synchronization locks (the local process synch lock if the target - object is local, both local and shared one if the object is shared). - --*/ - bool CSynchData::ReleaseFirstWaiter( - CPalThread * pthrCurrent, - bool * pfDelegated, - bool fWorkerThread) - { - PAL_ERROR palErr = NO_ERROR; - bool fSharedSynchLock = false; - bool fSharedObject = (SharedObject == GetObjectDomain()); - bool fThreadAwakened = false; - bool fDelegatedSignaling = false; - DWORD * pdwWaitState; - DWORD dwObjIdx; - SharedID shridItem = NULL, shridNextItem = NULL; - WaitingThreadsListNode * pwtlnItem, * pwtlnNextItem; - DWORD dwPid = gPID; - CPalSynchronizationManager * pSynchManager = - CPalSynchronizationManager::GetInstance(); - - VALIDATEOBJECT(this); - - *pfDelegated = false; - - if (fSharedObject) - { - shridItem = GetWTLHeadShmPtr(); - pwtlnItem = SharedIDToTypePointer(WaitingThreadsListNode, shridItem); - } - else - { - pwtlnItem = GetWTLHeadPtr(); - } - - while (pwtlnItem) - { - VALIDATEOBJECT(pwtlnItem); - - WaitCompletionState wcsWaitCompletionState; - bool fWaitAll = (0 != (WTLN_FLAG_WAIT_ALL & pwtlnItem->dwFlags)); - pdwWaitState = SharedIDToTypePointer(DWORD, - pwtlnItem->shridWaitingState); - - if (fSharedObject) - { - shridNextItem = pwtlnItem->ptrNext.shrid; - pwtlnNextItem = SharedIDToTypePointer(WaitingThreadsListNode, - shridNextItem); - } - else - { - pwtlnNextItem = pwtlnItem->ptrNext.ptr; - } - - if (fWaitAll) - { - // Wait All: we need to find out whether the wait is satisfied, - // or it is not, or if that cannot be determined from within - // this process (WaitMayBeSatisfied); in this case we need to - // delegate the object signaling to the process hosting the - // thread that owns the current target WaitingThreadsListNode - - // If the target object is local (fSharedObject == false) - // we're probably not holding the shared lock. - // If the wait is not a LocalWait, it involves at least one - // shared object. If that is the case, at this time we need - // to grab the shared lock. In fact IsRestOfWaitAllSatisfied - // and UnsignalRestOfLocalAwakeningWaitAll must be called - // atomically to prevent that another thread living - // in a different process could race with us stealing the - // signaling from one of the objects involved in the wait-all. - // - // Note: pwtlnItem->ptwiWaitInfo is valid only if the target - // wait originates in the current process. Anyway in the - // following 'if' we don't need to check that since we are - // already making sure that the object is local (!fSharedObject). - // If a wait involves at least one object local to this process, - // it can only be a wait performed by a thread in the current - // process, therefore pwtlnItem->ptwiWaitInfo is valid. - - _ASSERTE(fSharedObject || pwtlnItem->dwProcessId == gPID); - - if (!fSharedSynchLock && !fSharedObject && - LocalWait != pwtlnItem->ptwiWaitInfo->wdWaitDomain) - { - CPalSynchronizationManager::AcquireSharedSynchLock(pthrCurrent); - fSharedSynchLock = true; - } - - // First check if the current target node is already marked for - // wait all check in progress, and in case skip it by setting - // wcsWaitCompletionState to WaitIsNotSatisfied - bool fMarkedForDelegatedObjectSingalingInProgress = - (0 != (WTLN_FLAG_DELEGATED_OBJECT_SIGNALING_IN_PROGRESS & pwtlnItem->dwFlags)); - - wcsWaitCompletionState = - fMarkedForDelegatedObjectSingalingInProgress ? WaitIsNotSatisfied : - IsRestOfWaitAllSatisfied(pwtlnItem); - } - else - { - // Normal Wait: the wait is satisfied by definition - wcsWaitCompletionState = WaitIsSatisfied; - } - - if (WaitIsSatisfied == wcsWaitCompletionState) - { - // - // Target wait is satisfied - // - TRACE("Trying to switch wait state [%p] from WAIT/ALERTABLE " - "to ACTIVE for thread=%u\n", - pdwWaitState, pwtlnItem->dwThreadId); - - if (CPalSynchronizationManager::InterlockedAwaken(pdwWaitState, FALSE)) - { - TRACE("Succeeded switching wait state [%p] from WAIT/ALERTABLE " - "to TWS_ACTIVE for trhead=%u\n", - pdwWaitState, pwtlnItem->dwThreadId); - - dwObjIdx = pwtlnItem->dwObjIndex; - - if (dwPid == pwtlnItem->dwProcessId) - { - /////////////////////////// - // - // Local Thread Awakening - // - /////////////////////////// - ThreadWaitInfo * ptwiWaitInfo = pwtlnItem->ptwiWaitInfo; - bool fAbandoned = false; - - if (CObjectType::OwnershipTracked == - GetObjectType()->GetOwnershipSemantics()) - { - // Get the abandoned status before resetting it by - // assigning ownership to target thread - fAbandoned = IsAbandoned(); - - // Assign ownership to target thread - // Note: This will cause both ownership count and - // signal count to be greater than zero at the - // same time; the signal count will be anyway - // decremented immediately by the caller - // CsynchData::Signal - palErr = AssignOwnershipToThread(pthrCurrent, - ptwiWaitInfo->pthrOwner); - if (NO_ERROR != palErr) - { - ERROR("Synch Worker: AssignOwnershipToThread " - "failed with error %u; ownership data on " - "object with SynchData %p may be " - "corrupted\n", palErr, this); - } - } - - if (fWaitAll) - { - // Wait all satisfied: unsignal other objects - // involved in the wait - CPalSynchronizationManager::UnsignalRestOfLocalAwakeningWaitAll( - pthrCurrent, - ptwiWaitInfo->pthrOwner, - pwtlnItem, - this); - } - - TRACE("Unregistering wait for thread %u and waking it up " - "[pdwWaitState=%p]\n", pwtlnItem->dwThreadId, - pdwWaitState); - - // Unregister the wait - pSynchManager->UnRegisterWait(pthrCurrent, - ptwiWaitInfo, - fSharedObject || fSharedSynchLock); - - // After UnRegisterWait pwtlnItem is invalid - pwtlnItem = NULL; - - palErr = CPalSynchronizationManager::WakeUpLocalThread( - pthrCurrent, - ptwiWaitInfo->pthrOwner, - fAbandoned ? MutexAbondoned : WaitSucceeded, - dwObjIdx); - - if (NO_ERROR != palErr) - { - ERROR("Failed to wakeup local thread %#x: " - "object signaling may be " - "lost\n", ptwiWaitInfo->pthrOwner->GetThreadId()); - } - } - else - { - /////////////////////////// - // - // Remote Thread Awakening - // - /////////////////////////// - - // Note: if we are here, this cannot be a wait-all - _ASSERT_MSG(!fWaitAll, - "Control should never reach this point if " - "target wait is a wait-all\n"); - - // Wake up remote thread - palErr = CPalSynchronizationManager::WakeUpRemoteThread(shridItem); - - if (NO_ERROR != palErr) - { - ERROR("Failed to dispatch remote awakening cmd to " - "worker thread in process pid=%d to wake up" - "thread tid=%#x; object signaling may be " - "lost\n", pwtlnItem->dwProcessId, - pwtlnItem->dwThreadId); - } - } - - // A thread has been awakened - fThreadAwakened = true; - - // break out of the while loop - break; - } - } - else if (WaitMayBeSatisfied == wcsWaitCompletionState) - { - ////////////////////////////////////////// - // - // Wait All with remote thread awakening - // - ////////////////////////////////////////// - - // - // We need to transfer the object signaling to the process - // hosting the target waiter thread - // - - _ASSERT_MSG(fWaitAll, - "IsRestOfWaitAllSatisfied() apparently " - "returned -1 on a normal (non wait all) " - "wait\n"); - _ASSERT_MSG(fSharedObject, - "About to delegate object signaling to a remote " - "process, but the signaled object is actually " - "local\n"); - - // Delegate object signaling to target process - palErr = CPalSynchronizationManager::DelegateSignalingToRemoteProcess( - pthrCurrent, - pwtlnItem->dwProcessId, - pwtlnItem->ptrOwnerObjSynchData.shrid); - - TRACE("Delegating object signaling for SynchData shrid=%p\n", - (VOID *)pwtlnItem->ptrOwnerObjSynchData.shrid); - - if (NO_ERROR == palErr) - { - // A remote thread will be awakened - // This will also cause the object to be unsignaled by the - // code calling ReleaseFirstWaiter before releasing the - // synch locks, so no other WaitForMultipleObjects - // involving the target object may race stealing this - // particuklar object signaling - fThreadAwakened = true; - - fDelegatedSignaling = true; - - // break out of the while loop - break; - } - else - { - ERROR("Failed to delegate object signaling to remote " - "process %d. Looking for another waiter.\n", - pwtlnItem->dwProcessId); - - // Go on: a different target waiter will be selected - } - } - - if (fWorkerThread && fWaitAll && (dwPid == pwtlnItem->dwProcessId)) - { - // Mark the target wait for object signaling - CPalSynchronizationManager::MarkWaitForDelegatedObjectSignalingInProgress( - pthrCurrent, - pwtlnItem); - } - - // Go to the next item - shridItem = shridNextItem; - pwtlnItem = pwtlnNextItem; - } - - if (fDelegatedSignaling) - { - *pfDelegated = true; - } - else if (fWorkerThread) - { - // Reset 'delegated object signaling in progress' flags - CPalSynchronizationManager::UnmarkTWListForDelegatedObjectSignalingInProgress( - this); - } - - if (fSharedSynchLock) - { - CPalSynchronizationManager::ReleaseSharedSynchLock(pthrCurrent); - } - return fThreadAwakened; - } - - /*++ - Method: - CSynchData::Signal - - Releases all the threads waiting on this object and living in the current - process. - - Note: this method must be called while holding the appropriate - synchronization locks (the local process synch lock if the target - object is local, both local and shared one if the object is shared). - --*/ - LONG CSynchData::ReleaseAllLocalWaiters( - CPalThread * pthrCurrent) - { - PAL_ERROR palErr = NO_ERROR; - LONG lAwakenedCount = 0; - bool fSharedSynchLock = false; - bool fSharedObject = (SharedObject == GetObjectDomain()); - DWORD * pdwWaitState; - DWORD dwObjIdx; - SharedID shridItem = NULL, shridNextItem = NULL; - WaitingThreadsListNode * pwtlnItem, * pwtlnNextItem; - DWORD dwPid = gPID; - CPalSynchronizationManager * pSynchManager = - CPalSynchronizationManager::GetInstance(); - - VALIDATEOBJECT(this); - - if (fSharedObject) - { - shridItem = GetWTLHeadShmPtr(); - pwtlnItem = SharedIDToTypePointer(WaitingThreadsListNode, shridItem); - } - else - { - pwtlnItem = GetWTLHeadPtr(); - } - - while (pwtlnItem) - { - VALIDATEOBJECT(pwtlnItem); - - bool fWaitAll = (0 != (WTLN_FLAG_WAIT_ALL & pwtlnItem->dwFlags)); - pdwWaitState = SharedIDToTypePointer(DWORD, - pwtlnItem->shridWaitingState); - - if (fSharedObject) - { - shridNextItem = pwtlnItem->ptrNext.shrid; - pwtlnNextItem = SharedIDToTypePointer(WaitingThreadsListNode, - shridNextItem); - } - else - { - pwtlnNextItem = pwtlnItem->ptrNext.ptr; - } - - // See note in similar spot in ReleaseFirstWaiter - - _ASSERTE(fSharedObject || pwtlnItem->dwProcessId == gPID); - - if (!fSharedSynchLock && !fSharedObject && - LocalWait != pwtlnItem->ptwiWaitInfo->wdWaitDomain) - { - CPalSynchronizationManager::AcquireSharedSynchLock(pthrCurrent); - fSharedSynchLock = true; - } - - if( dwPid == pwtlnItem->dwProcessId && - (!fWaitAll || WaitIsSatisfied == IsRestOfWaitAllSatisfied(pwtlnItem)) ) - { - // - // Target wait is satisfied - // - TRACE("Trying to switch wait state [%p] from WAIT/ALERTABLE " - "to ACTIVE for thread=%u\n", - pdwWaitState, pwtlnItem->dwThreadId); - - if (CPalSynchronizationManager::InterlockedAwaken(pdwWaitState, FALSE)) - { - TRACE("Succeeded switching wait state [%p] from WAIT/ALERTABLE " - "to TWS_ACTIVE for trhead=%u\n", - pdwWaitState, pwtlnItem->dwThreadId); - - dwObjIdx = pwtlnItem->dwObjIndex; - - ThreadWaitInfo * ptwiWaitInfo = pwtlnItem->ptwiWaitInfo; - bool fAbandoned = false; - - if (CObjectType::OwnershipTracked == - GetObjectType()->GetOwnershipSemantics()) - { - // Get the abandoned status before resetting it by - // assigning ownership to target thread - fAbandoned = IsAbandoned(); - - // Assign ownership to target thread - palErr = AssignOwnershipToThread(pthrCurrent, - ptwiWaitInfo->pthrOwner); - if (NO_ERROR != palErr) - { - ERROR("Synch Worker: AssignOwnershipToThread " - "failed with error %u; ownership data on " - "object with SynchData %p may be " - "corrupted\n", palErr, this); - } - } - - if (fWaitAll) - { - // Wait all satisfied: unsignal other objects - // involved in the wait - CPalSynchronizationManager::UnsignalRestOfLocalAwakeningWaitAll( - pthrCurrent, - ptwiWaitInfo->pthrOwner, - pwtlnItem, - this); - } - - TRACE("Unregistering wait for thread %u and waking it up " - "[pdwWaitState=%p]\n", pwtlnItem->dwThreadId, - pdwWaitState); - - // Unregister the wait - pSynchManager->UnRegisterWait(pthrCurrent, - ptwiWaitInfo, - fSharedObject || fSharedSynchLock); - - // After UnRegisterWait pwtlnItem is invalid - pwtlnItem = NULL; - - palErr = CPalSynchronizationManager::WakeUpLocalThread( - pthrCurrent, - ptwiWaitInfo->pthrOwner, - fAbandoned ? MutexAbondoned : WaitSucceeded, - dwObjIdx); - - if (NO_ERROR != palErr) - { - ERROR("Failed to wakeup local thread %#x: " - "object signaling may be " - "lost\n", ptwiWaitInfo->pthrOwner->GetThreadId()); - } - else - { - // A thread has been awakened - lAwakenedCount++; - } - } - } - - // Go to the next item - shridItem = shridNextItem; - pwtlnItem = pwtlnNextItem; - } - - if (fSharedSynchLock) - { - CPalSynchronizationManager::ReleaseSharedSynchLock(pthrCurrent); - } - return lAwakenedCount; - } - - /*++ - Method: - CSynchData::IsRestOfWaitAllSatisfied - - Returns whether or not the current wait-all operation is fully satisfied, - assuming the current target object as signaled (i.e. whether or not all the - involved object, except the current one, are signaled). - It returns: - - WaitIsNotSatisfied if the wait-all is not fully satisfied. - - WaitIsSatisfied if the wait-all is fully satisfied. - - WaitMayBeSatisfied if the target thread lives in a different process and - therefore the wait may involve objects local to the remote process, and - as result is generally not possible to say whther or not the wait-all is - fully satisfied from the current process. - - Note: this method must be called while holding the synchronization locks - appropriate to all the objects involved in the wait-all. If any - of the objects is shared, the caller must own both local and - shared synch locks; if no shared object is involved in the wait, - only the local synch lock is needed. - --*/ - WaitCompletionState CSynchData::IsRestOfWaitAllSatisfied( - WaitingThreadsListNode * pwtlnNode) - { - int iSignaledOrOwnedObjCount = 0; - int iTgtCount = 0; - int i; - WaitCompletionState wcsWaitCompletionState = WaitIsNotSatisfied; - CSynchData * psdSynchDataItem = NULL; - ThreadWaitInfo * ptwiWaitInfo = NULL; - - VALIDATEOBJECT(this); - VALIDATEOBJECT(pwtlnNode); - - _ASSERT_MSG(0 != (WTLN_FLAG_WAIT_ALL & pwtlnNode->dwFlags), - "IsRestOfWaitAllSatisfied() called on a normal " - "(non wait all) wait"); - _ASSERT_MSG((SharedObject == GetObjectDomain()) == - (0 != (WTLN_FLAG_OWNER_OBJECT_IS_SHARED & pwtlnNode->dwFlags)), - "WTLN_FLAG_OWNER_OBJECT_IS_SHARED in WaitingThreadsListNode " - "not consistent with target object's domain\n"); - - if(gPID != pwtlnNode->dwProcessId) - { - //////////////////////////// - // - // Remote Thread Awakening - // - //////////////////////////// - - // Cannot determine whether or not the wait all is satisfied from - // this process - wcsWaitCompletionState = WaitMayBeSatisfied; - goto IROWAS_exit; - } - - /////////////////////////// - // - // Local Thread Awakening - // - /////////////////////////// - - ptwiWaitInfo = pwtlnNode->ptwiWaitInfo; - - iTgtCount = ptwiWaitInfo->lObjCount; - for (i=0; i < iTgtCount; i++) - { - WaitingThreadsListNode * pwtlnItem = ptwiWaitInfo->rgpWTLNodes[i]; - bool fRetVal; - bool fIsAbandoned; - - VALIDATEOBJECT(pwtlnItem); - - if (0 != (WTLN_FLAG_OWNER_OBJECT_IS_SHARED & pwtlnItem->dwFlags)) - { - psdSynchDataItem = SharedIDToTypePointer(CSynchData, - pwtlnItem->ptrOwnerObjSynchData.shrid); - } - else - { - psdSynchDataItem = pwtlnItem->ptrOwnerObjSynchData.ptr; - } - - VALIDATEOBJECT(psdSynchDataItem); - - if (pwtlnItem == pwtlnNode) - { - _ASSERT_MSG (this == psdSynchDataItem, - "pwtlnNode and pwtlnItem match, but this " - "and psdSynchDataItem don't\n"); - - // The target object (the one related to pwtlnNode) is counted as - // signaled/owned without checking it (also if it is not, as - // it normally happens when this method is called) - iSignaledOrOwnedObjCount++; - continue; - } - - fRetVal = psdSynchDataItem->CanWaiterWaitWithoutBlocking( - ptwiWaitInfo->pthrOwner, - &fIsAbandoned); - - if (fRetVal) - { - iSignaledOrOwnedObjCount++; - } - else - { - break; - } - } - - if (iSignaledOrOwnedObjCount < iTgtCount) - { - wcsWaitCompletionState = WaitIsNotSatisfied; - } - else - { - wcsWaitCompletionState = WaitIsSatisfied; - } - - IROWAS_exit: - TRACE("IsRestOfWaitAllSatisfied() returning %u \n", wcsWaitCompletionState); - - return wcsWaitCompletionState; - } - - - /*++ - Method: - CSynchData::SetOwner - - Blindly sets the thread whose CPalThread is passed as argument, as the - owner of the current object. - WARNING: this method discards any previous ownership data and does not - update the list of the object owned by the owner thread. - - Note: this method must be called while holding the appropriate - synchronization locks (the local process synch lock if the target - object is local, both local and shared one if the object is shared). - --*/ - void CSynchData::SetOwner(CPalThread * pOwnerThread) - { - VALIDATEOBJECT(this); - - m_dwOwnerPid = gPID; - m_dwOwnerTid = pOwnerThread->GetThreadId(); - m_pOwnerThread = pOwnerThread; - } - - /*++ - Method: - CSynchData::ResetOwnership - - Resets current object's ownership data - - Note: this method must be called while holding the appropriate - synchronization locks (the local process synch lock if the target - object is local, both local and shared one if the object is shared). - --*/ - void CSynchData::ResetOwnership() - { - VALIDATEOBJECT(this); - - m_lOwnershipCount = 0; - m_dwOwnerPid = 0; - m_dwOwnerTid = 0; - m_pOwnerThread = NULL; - m_poolnOwnedObjectListNode = NULL; - } - - /*++ - Method: - CSynchData::AssignOwnershipToThread - - Assigns thw ownership of the current object to the target thread, performing - all the operations neede to mantain the correct status of ownership data, - also handling recursive object ownership acquisition - - Note: this method must be called while holding the appropriate - synchronization locks (the local process synch lock if the target - object is local, both local and shared one if the object is shared). - --*/ - PAL_ERROR CSynchData::AssignOwnershipToThread( - CPalThread * pthrCurrent, - CPalThread * pthrTarget) - { - // Note: when this method is called by ReleaseFirstWaiter there is - // a small time window in which both SignalCount and - // OwnershipCount can be greater than zero (which normally - // is illegal). Anyway that is fine since ReleaseFirstWaiter - // will restore the value right after, and such situation - // takes place while holding synchroniztion locks, so no - // other thread/process can access the object. - - PAL_ERROR palErr = NO_ERROR; - - _ASSERT_MSG(CObjectType::OwnershipTracked == - GetObjectType()->GetOwnershipSemantics(), - "AssignOwnershipToThread called on a non-ownable " - "CSynchData [this=%p OwnershipSemantics=%u]\n", this, - GetObjectType()->GetOwnershipSemantics()); - - - if (0 < m_lOwnershipCount) - { - // - // Object already owned, incrementing ownership count - // - _ASSERT_MSG(0 == GetSignalCount(), - "Conflicting OwnershipCount and SignalCount values\n"); - - _ASSERT_MSG(pthrTarget == m_pOwnerThread && gPID == m_dwOwnerPid, - "Attempting to assign ownership of CSynchData %p to " - "thread {pid=%#x tid=%#x} while it is currently owned " - "by thread {pid=%#x tid=%#x}\n", this, - gPID, pthrTarget->GetThreadId(), - m_dwOwnerPid, m_pOwnerThread->GetThreadId()); - - m_lOwnershipCount++; - - TRACE("Incrementing ownership count for object with " - "SynchData %p owned by thread %#x [new count=%d]\n", - this, pthrTarget->GetThreadId(), m_lOwnershipCount); - } - else - { - // - // Acquiring currently not owned object - // - CPalSynchronizationManager * pSynchManager = - CPalSynchronizationManager::GetInstance(); - OwnedObjectsListNode * pooln; - - pooln = pSynchManager->CacheGetOwnedObjsListNode(pthrCurrent); - if (NULL == pooln) - { - ERROR("Out of memory while acquiring mutex ownership"); - // In this case we bail out. It will result in no - // thread being awakend, which may cause deadlock, - // but it is anyway better than corrupting the - // ownership list - palErr = ERROR_NOT_ENOUGH_MEMORY; - goto AOTT_exit; - } - - TRACE("Assigning ownable object with SynchData %p to " - "thread %#x\n", - this, pthrTarget->GetThreadId()); - - // Set ownership data - SetOwner(pthrTarget); - SetOwnershipListNode(pooln); - SetOwnershipCount(1); - SetAbandoned(false); - - // Add object to list of owned objs for current thread - pooln->pPalObjSynchData = this; - AddRef(); - pthrTarget->synchronizationInfo.AddObjectToOwnedList(pooln); - } - - AOTT_exit: - return palErr; - } - - /*++ - Method: - CSynchData::WaiterEnqueue - - Adds the WaitingThreadsListNode passed as argument at the end of the - list of WaitingThreadsListNode for the current object, representing - the threads waiting on the current object. The target SynchData is - assumed to be local to the current process - - Note: this method must be called while holding the local process - synchronization lock. - --*/ - void CSynchData::WaiterEnqueue(WaitingThreadsListNode * pwtlnNewNode, bool fPrioritize) - { - VALIDATEOBJECT(this); - VALIDATEOBJECT(pwtlnNewNode); - - _ASSERT_MSG(ProcessLocalObject == GetObjectDomain(), - "Trying to enqueue a WaitingThreadsListNode as local " - "on a shared object\n"); - _ASSERT_MSG(0 == (WTLN_FLAG_OWNER_OBJECT_IS_SHARED & pwtlnNewNode->dwFlags), - "Trying to add a WaitingThreadsListNode marked as shared " - "as it was a local one\n"); - - if (!fPrioritize) - { - // Enqueue normally to the end of the queue - WaitingThreadsListNode * pwtlnCurrLast = m_ptrWTLTail.ptr; - - pwtlnNewNode->ptrNext.ptr = NULL; - if (NULL == pwtlnCurrLast) - { - _ASSERT_MSG(NULL == m_ptrWTLHead.ptr, - "Corrupted waiting list on local CSynchData @ %p\n", - this); - - pwtlnNewNode->ptrPrev.ptr = NULL; - m_ptrWTLHead.ptr = pwtlnNewNode; - m_ptrWTLTail.ptr = pwtlnNewNode; - } - else - { - VALIDATEOBJECT(pwtlnCurrLast); - - pwtlnNewNode->ptrPrev.ptr = pwtlnCurrLast; - pwtlnCurrLast->ptrNext.ptr = pwtlnNewNode; - m_ptrWTLTail.ptr = pwtlnNewNode; - } - } - else - { - // The wait is prioritized, enqueue to the beginning of the queue - WaitingThreadsListNode * pwtlnCurrFirst = m_ptrWTLHead.ptr; - - pwtlnNewNode->ptrPrev.ptr = NULL; - if (NULL == pwtlnCurrFirst) - { - _ASSERT_MSG(NULL == m_ptrWTLTail.ptr, - "Corrupted waiting list on local CSynchData @ %p\n", - this); - - pwtlnNewNode->ptrNext.ptr = NULL; - m_ptrWTLHead.ptr = pwtlnNewNode; - m_ptrWTLTail.ptr = pwtlnNewNode; - } - else - { - VALIDATEOBJECT(pwtlnCurrFirst); - - pwtlnNewNode->ptrNext.ptr = pwtlnCurrFirst; - pwtlnCurrFirst->ptrPrev.ptr = pwtlnNewNode; - m_ptrWTLHead.ptr = pwtlnNewNode; - } - } - - m_ulcWaitingThreads += 1; - - return; - } - - /*++ - Method: - CSynchData::SharedWaiterEnqueue - - Adds the WaitingThreadsListNode passed as argument at the end of the - list of WaitingThreadsListNode for the current object, representing - the threads waiting on the current object. The target SynchData is - assumed to be shared among processes - - Note: this method must be called while holding both local and shared - synchronization locks. - --*/ - void CSynchData::SharedWaiterEnqueue(SharedID shridNewNode, bool fPrioritize) - { - VALIDATEOBJECT(this); - - _ASSERT_MSG(SharedObject == GetObjectDomain(), - "Trying to enqueue a WaitingThreadsListNode as shared " - "on a local object\n"); - - if (!fPrioritize) - { - // Enqueue normally to the end of the queue - SharedID shridCurrLast; - WaitingThreadsListNode * pwtlnCurrLast, * pwtlnNewNode; - - shridCurrLast = m_ptrWTLTail.shrid; - pwtlnCurrLast = SharedIDToTypePointer(WaitingThreadsListNode, shridCurrLast); - pwtlnNewNode = SharedIDToTypePointer(WaitingThreadsListNode, shridNewNode); - - _ASSERT_MSG(1 == (WTLN_FLAG_OWNER_OBJECT_IS_SHARED & pwtlnNewNode->dwFlags), - "Trying to add a WaitingThreadsListNode marked as local " - "as it was a shared one\n"); - - VALIDATEOBJECT(pwtlnNewNode); - - pwtlnNewNode->ptrNext.shrid = NULL; - if (NULL == pwtlnCurrLast) - { - _ASSERT_MSG(NULL == m_ptrWTLHead.shrid, - "Corrupted waiting list on shared CSynchData at " - "{shrid=%p, p=%p}\n", m_shridThis, this); - - pwtlnNewNode->ptrPrev.shrid = NULL; - m_ptrWTLHead.shrid = shridNewNode; - m_ptrWTLTail.shrid = shridNewNode; - } - else - { - VALIDATEOBJECT(pwtlnCurrLast); - - pwtlnNewNode->ptrPrev.shrid = shridCurrLast; - pwtlnCurrLast->ptrNext.shrid = shridNewNode; - m_ptrWTLTail.shrid = shridNewNode; - } - } - else - { - // The wait is prioritized, enqueue to the beginning of the queue - SharedID shridCurrFirst; - WaitingThreadsListNode * pwtlnCurrFirst, * pwtlnNewNode; - - shridCurrFirst = m_ptrWTLHead.shrid; - pwtlnCurrFirst = SharedIDToTypePointer(WaitingThreadsListNode, shridCurrFirst); - pwtlnNewNode = SharedIDToTypePointer(WaitingThreadsListNode, shridNewNode); - - _ASSERT_MSG(1 == (WTLN_FLAG_OWNER_OBJECT_IS_SHARED & pwtlnNewNode->dwFlags), - "Trying to add a WaitingThreadsListNode marked as local " - "as it was a shared one\n"); - - VALIDATEOBJECT(pwtlnNewNode); - - pwtlnNewNode->ptrPrev.shrid = NULL; - if (NULL == pwtlnCurrFirst) - { - _ASSERT_MSG(NULL == m_ptrWTLTail.shrid, - "Corrupted waiting list on shared CSynchData at " - "{shrid=%p, p=%p}\n", m_shridThis, this); - - pwtlnNewNode->ptrNext.shrid = NULL; - m_ptrWTLHead.shrid = shridNewNode; - m_ptrWTLTail.shrid = shridNewNode; - } - else - { - VALIDATEOBJECT(pwtlnCurrFirst); - - pwtlnNewNode->ptrNext.shrid = shridCurrFirst; - pwtlnCurrFirst->ptrPrev.shrid = shridNewNode; - m_ptrWTLHead.shrid = shridNewNode; - } - } - - m_ulcWaitingThreads += 1; - - return; - } - -#ifdef SYNCH_OBJECT_VALIDATION - CSynchData::~CSynchData() - { - ValidateObject(true); - InvalidateObject(); - } - /*++ - Method: - CSynchData::ValidateObject - - Makes sure that the signature at the beginning and at the end of the - current object are those of a currently alive object (i.e. the object - has been constructed and does not appear to have been overwritten) - --*/ - void CSynchData::ValidateObject(bool fDestructor) - { - TRACE("Verifying in-use CSynchData @ %p\n", this); - _ASSERT_MSG(HeadSignature == m_dwDebugHeadSignature, - "CSynchData header signature corruption [p=%p]", this); - _ASSERT_MSG(TailSignature == m_dwDebugTailSignature, - "CSynchData trailer signature corruption [p=%p]", this); - _ASSERT_MSG((fDestructor && 0 == m_lRefCount) || - (!fDestructor && 0 < m_lRefCount), - "CSynchData %p with NULL reference count\n", this); - } - /*++ - Method: - CSynchData::ValidateEmptyObject - - Makes sure that the signature at the beginning and at the end of the - current object are not those of a currently alive object (i.e. the - object has not yet been constructed or it has alread been destructed) - --*/ - void CSynchData::ValidateEmptyObject() - { - TRACE("Verifying empty CSynchData @ %p\n", this); - _ASSERT_MSG(HeadSignature != m_dwDebugHeadSignature, - "CSynchData header previously signed [p=%p]", this); - _ASSERT_MSG(TailSignature != m_dwDebugTailSignature, - "CSynchData trailer previously signed [p=%p]", this); - } - /*++ - Method: - CSynchData::InvalidateObject - - Turns signatures from alive object to destructed object - --*/ - void CSynchData::InvalidateObject() - { - TRACE("Invalidating CSynchData @ %p\n", this); - m_dwDebugHeadSignature = EmptySignature; - m_dwDebugTailSignature = EmptySignature; - } -#endif // SYNCH_OBJECT_VALIDATION -} - diff --git a/src/pal/src/synchmgr/synchmanager.cpp b/src/pal/src/synchmgr/synchmanager.cpp deleted file mode 100644 index 349b3de13..000000000 --- a/src/pal/src/synchmgr/synchmanager.cpp +++ /dev/null @@ -1,4618 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*++ - - - -Module Name: - - synchmanager.cpp - -Abstract: - Implementation of Synchronization Manager and related objects - - - ---*/ - -#include "pal/dbgmsg.h" - -SET_DEFAULT_DEBUG_CHANNEL(SYNC); // some headers have code with asserts, so do this first - -#include "synchmanager.hpp" -#include "pal/file.hpp" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#if HAVE_POLL -#include -#else -#include "pal/fakepoll.h" -#endif // HAVE_POLL - -#include - -const int CorUnix::CThreadSynchronizationInfo::PendingSignalingsArraySize; - -// We use the synchronization manager's worker thread to handle -// process termination requests. It does so by calling the -// registered handler function. -PTERMINATION_REQUEST_HANDLER g_terminationRequestHandler = NULL; - -// Set the handler for process termination requests. -VOID PALAPI PAL_SetTerminationRequestHandler( - IN PTERMINATION_REQUEST_HANDLER terminationHandler) -{ - g_terminationRequestHandler = terminationHandler; -} - -namespace CorUnix -{ - ///////////////////////////////// - // // - // WaitingThreadsListNode // - // // - ///////////////////////////////// -#ifdef SYNCH_OBJECT_VALIDATION - _WaitingThreadsListNode::_WaitingThreadsListNode() - { - ValidateEmptyObject(); - dwDebugHeadSignature = HeadSignature; - dwDebugTailSignature = TailSignature; - } - _WaitingThreadsListNode::~_WaitingThreadsListNode() - { - ValidateObject(); - InvalidateObject(); - } - void _WaitingThreadsListNode::ValidateObject() - { - TRACE("Verifying WaitingThreadsListNode @ %p\n", this); - _ASSERT_MSG(HeadSignature == dwDebugHeadSignature, - "WaitingThreadsListNode header signature corruption [p=%p]", - this); - _ASSERT_MSG(TailSignature == dwDebugTailSignature, - "WaitingThreadsListNode trailer signature corruption [p=%p]", - this); - } - void _WaitingThreadsListNode::ValidateEmptyObject() - { - _ASSERT_MSG(HeadSignature != dwDebugHeadSignature, - "WaitingThreadsListNode header previously signed [p=%p]", - this); - _ASSERT_MSG(TailSignature != dwDebugTailSignature, - "WaitingThreadsListNode trailer previously signed [p=%p]", - this); - } - void _WaitingThreadsListNode::InvalidateObject() - { - TRACE("Invalidating WaitingThreadsListNode @ %p\n", this); - dwDebugHeadSignature = EmptySignature; - dwDebugTailSignature = EmptySignature; - } -#endif // SYNCH_OBJECT_VALIDATION - - ////////////////////////////// - // // - // CPalSynchMgrController // - // // - ////////////////////////////// - - /*++ - Method: - CPalSynchMgrController::CreatePalSynchronizationManager - - Creates the Synchronization Manager. It must be called once per process. - --*/ - IPalSynchronizationManager * CPalSynchMgrController::CreatePalSynchronizationManager() - { - return CPalSynchronizationManager::CreatePalSynchronizationManager(); - }; - - /*++ - Method: - CPalSynchMgrController::StartWorker - - Starts the Synchronization Manager's Worker Thread - --*/ - PAL_ERROR CPalSynchMgrController::StartWorker( - CPalThread * pthrCurrent) - { - return CPalSynchronizationManager::StartWorker(pthrCurrent); - } - - /*++ - Method: - CPalSynchMgrController::PrepareForShutdown - - This method performs the part of Synchronization Manager's shutdown that - needs to be carried out when core PAL subsystems are still active - --*/ - PAL_ERROR CPalSynchMgrController::PrepareForShutdown() - { - return CPalSynchronizationManager::PrepareForShutdown(); - } - - ////////////////////////////////// - // // - // CPalSynchronizationManager // - // // - ////////////////////////////////// - - IPalSynchronizationManager * g_pSynchronizationManager = NULL; - - CPalSynchronizationManager * CPalSynchronizationManager::s_pObjSynchMgr = NULL; - Volatile CPalSynchronizationManager::s_lInitStatus = SynchMgrStatusIdle; - CRITICAL_SECTION CPalSynchronizationManager::s_csSynchProcessLock; - CRITICAL_SECTION CPalSynchronizationManager::s_csMonitoredProcessesLock; - - CPalSynchronizationManager::CPalSynchronizationManager() - : m_dwWorkerThreadTid(0), - m_pipoThread(NULL), - m_pthrWorker(NULL), - m_iProcessPipeRead(-1), - m_iProcessPipeWrite(-1), - m_pmplnMonitoredProcesses(NULL), - m_lMonitoredProcessesCount(0), - m_pmplnExitedNodes(NULL), - m_cacheWaitCtrlrs(CtrlrsCacheMaxSize), - m_cacheStateCtrlrs(CtrlrsCacheMaxSize), - m_cacheSynchData(SynchDataCacheMaxSize), - m_cacheSHRSynchData(SynchDataCacheMaxSize), - m_cacheWTListNodes(WTListNodeCacheMaxSize), - m_cacheSHRWTListNodes(WTListNodeCacheMaxSize), - m_cacheThreadApcInfoNodes(ApcInfoNodeCacheMaxSize), - m_cacheOwnedObjectsListNodes(OwnedObjectsListCacheMaxSize) - { -#if HAVE_KQUEUE && !HAVE_BROKEN_FIFO_KEVENT - m_iKQueue = -1; - // Initialize data to 0 and flags to EV_EOF - EV_SET(&m_keProcessPipeEvent, 0, 0, EV_EOF, 0, 0, 0); -#endif // HAVE_KQUEUE - } - - CPalSynchronizationManager::~CPalSynchronizationManager() - { - } - - /*++ - Method: - CPalSynchronizationManager::BlockThread - - Called by a thread to go to sleep for a wait or a sleep - - NOTE: This method must must be called without holding any - synchronization lock (as well as other locks) - --*/ - PAL_ERROR CPalSynchronizationManager::BlockThread( - CPalThread *pthrCurrent, - DWORD dwTimeout, - bool fAlertable, - bool fIsSleep, - ThreadWakeupReason *ptwrWakeupReason, - DWORD * pdwSignaledObject) - { - PAL_ERROR palErr = NO_ERROR; - ThreadWakeupReason twrWakeupReason = WaitFailed; - DWORD * pdwWaitState; - DWORD dwWaitState = 0; - DWORD dwSigObjIdx = 0; - bool fRaceAlerted = false; - bool fEarlyDeath = false; - - pdwWaitState = SharedIDToTypePointer(DWORD, - pthrCurrent->synchronizationInfo.m_shridWaitAwakened); - - _ASSERT_MSG(NULL != pdwWaitState, - "Got NULL pdwWaitState from m_shridWaitAwakened=%p\n", - (VOID *)pthrCurrent->synchronizationInfo.m_shridWaitAwakened); - - if (fIsSleep) - { - // If fIsSleep is true we are being called by Sleep/SleepEx - // and we need to switch the wait state to TWS_WAITING or - // TWS_ALERTABLE (according to fAlertable) - - if (fAlertable) - { - // If we are in alertable mode we need to grab the lock to - // make sure that no APC is queued right before the - // InterlockedCompareExchange. - // If there are APCs queued at this time, no native wakeup - // will be posted, so we need to skip the native wait - - // Lock - AcquireLocalSynchLock(pthrCurrent); - AcquireSharedSynchLock(pthrCurrent); - - if (AreAPCsPending(pthrCurrent)) - { - // APCs have been queued when the thread wait status was - // still TWS_ACTIVE, therefore the queueing thread will not - // post any native wakeup: we need to skip the actual - // native wait - fRaceAlerted = true; - } - } - - if (!fRaceAlerted) - { - // Setting the thread in wait state - dwWaitState = (DWORD)(fAlertable ? TWS_ALERTABLE : TWS_WAITING); - - TRACE("Switching my wait state [%p] from TWS_ACTIVE to %u [current *pdwWaitState=%u]\n", - pdwWaitState, dwWaitState, *pdwWaitState); - - dwWaitState = InterlockedCompareExchange((LONG *)pdwWaitState, - dwWaitState, - TWS_ACTIVE); - - if ((DWORD)TWS_ACTIVE != dwWaitState) - { - if (fAlertable) - { - // Unlock - ReleaseSharedSynchLock(pthrCurrent); - ReleaseLocalSynchLock(pthrCurrent); - } - - if ((DWORD)TWS_EARLYDEATH == dwWaitState) - { - // Process is terminating, this thread will soon be suspended (by SuspendOtherThreads). - WARN("Thread is about to get suspended by TerminateProcess\n"); - - fEarlyDeath = true; - palErr = WAIT_FAILED; - } - else - { - ASSERT("Unexpected thread wait state %u\n", dwWaitState); - palErr = ERROR_INTERNAL_ERROR; - } - - goto BT_exit; - } - } - - if (fAlertable) - { - // Unlock - ReleaseSharedSynchLock(pthrCurrent); - ReleaseLocalSynchLock(pthrCurrent); - } - } - - if (fRaceAlerted) - { - twrWakeupReason = Alerted; - } - else - { - TRACE("Current thread is about to block for waiting\n"); - - palErr = ThreadNativeWait( - &pthrCurrent->synchronizationInfo.m_tnwdNativeData, - dwTimeout, - &twrWakeupReason, - &dwSigObjIdx); - - if (NO_ERROR != palErr) - { - ERROR("ThreadNativeWait() failed [palErr=%d]\n", palErr); - twrWakeupReason = WaitFailed; - goto BT_exit; - } - - TRACE("ThreadNativeWait returned {WakeupReason=%u " - "dwSigObjIdx=%u}\n", twrWakeupReason, dwSigObjIdx); - } - - if (WaitTimeout == twrWakeupReason) - { - // timeout reached. set wait state back to 'active' - dwWaitState = (DWORD)(fAlertable ? TWS_ALERTABLE : TWS_WAITING); - - TRACE("Current thread awakened for timeout: switching wait " - "state [%p] from %u to TWS_ACTIVE [current *pdwWaitState=%u]\n", - pdwWaitState, dwWaitState, *pdwWaitState); - - DWORD dwOldWaitState = InterlockedCompareExchange( - (LONG *)pdwWaitState, - TWS_ACTIVE, (LONG)dwWaitState); - - switch (dwOldWaitState) - { - case TWS_ACTIVE: - // We were already ACTIVE; someone decided to wake up this - // thread sometime between the moment the native wait - // timed out and here. Since the signaling side succeeded - // its InterlockedCompareExchange, it will signal the - // condition/predicate pair (we just raced overtaking it); - // therefore we need to clear the condition/predicate - // by waiting on it one more time. - // That will also cause this method to report a signal - // rather than a timeout. - // In the remote signaling scenario, this second wait - // also makes sure that the shared id passed over the - // process pipe is valid for the entire duration of time - // in which the worker thread deals with it - TRACE("Current thread already ACTIVE: a signaling raced " - "with the timeout: re-waiting natively to clear the " - "predicate\n"); - - palErr = ThreadNativeWait( - &pthrCurrent->synchronizationInfo.m_tnwdNativeData, - SecondNativeWaitTimeout, - &twrWakeupReason, - &dwSigObjIdx); - - if (NO_ERROR != palErr) - { - ERROR("ThreadNativeWait() failed [palErr=%d]\n", - palErr); - twrWakeupReason = WaitFailed; - } - - if (WaitTimeout == twrWakeupReason) - { - ERROR("Second native wait timed out\n"); - } - - break; - case TWS_EARLYDEATH: - // Thread is about to be suspended by TerminateProcess. - // Anyway, if the wait timed out, we still want to - // (try to) unregister the wait (especially if it - // involves shared objects) - WARN("Thread is about to be suspended by TerminateProcess\n"); - fEarlyDeath = true; - palErr = WAIT_FAILED; - break; - case TWS_WAITING: - case TWS_ALERTABLE: - default: - _ASSERT_MSG(dwOldWaitState == dwWaitState, - "Unexpected wait status: actual=%u, expected=%u\n", - dwOldWaitState, dwWaitState); - break; - } - } - - switch (twrWakeupReason) - { - case WaitTimeout: - { - // Awakened for timeout: we need to unregister the wait - ThreadWaitInfo * ptwiWaitInfo; - - TRACE("Current thread awakened for timeout: unregistering the wait\n"); - - // Local lock - AcquireLocalSynchLock(pthrCurrent); - - ptwiWaitInfo = GetThreadWaitInfo(pthrCurrent); - - // Unregister the wait - // Note: UnRegisterWait will take care of grabbing the shared synch lock, if needed. - UnRegisterWait(pthrCurrent, ptwiWaitInfo, false); - - // Unlock - ReleaseLocalSynchLock(pthrCurrent); - - break; - } - case WaitSucceeded: - case MutexAbondoned: - *pdwSignaledObject = dwSigObjIdx; - break; - default: - // 'Alerted' and 'WaitFailed' go through this case - break; - } - - // Set the returned wakeup reason - *ptwrWakeupReason = twrWakeupReason; - - TRACE("Current thread is now active [WakeupReason=%u SigObjIdx=%u]\n", - twrWakeupReason, dwSigObjIdx); - - _ASSERT_MSG(TWS_ACTIVE == VolatileLoad(pdwWaitState) || - TWS_EARLYDEATH == VolatileLoad(pdwWaitState), - "Unexpected thread wait state %u\n", VolatileLoad(pdwWaitState)); - - BT_exit: - if (fEarlyDeath) - { - ThreadPrepareForShutdown(); - } - - return palErr; - } - - PAL_ERROR CPalSynchronizationManager::ThreadNativeWait( - ThreadNativeWaitData * ptnwdNativeWaitData, - DWORD dwTimeout, - ThreadWakeupReason * ptwrWakeupReason, - DWORD * pdwSignaledObject) - { - PAL_ERROR palErr = NO_ERROR; - int iRet, iWaitRet = 0; - struct timespec tsAbsTmo; - - TRACE("ThreadNativeWait(ptnwdNativeWaitData=%p, dwTimeout=%u, ...)\n", - ptnwdNativeWaitData, dwTimeout); - - if (dwTimeout != INFINITE) - { - // Calculate absolute timeout - palErr = GetAbsoluteTimeout(dwTimeout, &tsAbsTmo, /*fPreferMonotonicClock*/ TRUE); - if (NO_ERROR != palErr) - { - ERROR("Failed to convert timeout to absolute timeout\n"); - goto TNW_exit; - } - } - - // Lock the mutex - iRet = pthread_mutex_lock(&ptnwdNativeWaitData->mutex); - if (0 != iRet) - { - ERROR("Internal Error: cannot lock mutex\n"); - palErr = ERROR_INTERNAL_ERROR; - *ptwrWakeupReason = WaitFailed; - goto TNW_exit; - } - - while (FALSE == ptnwdNativeWaitData->iPred) - { - if (INFINITE == dwTimeout) - { - iWaitRet = pthread_cond_wait(&ptnwdNativeWaitData->cond, - &ptnwdNativeWaitData->mutex); - } - else - { - iWaitRet = pthread_cond_timedwait(&ptnwdNativeWaitData->cond, - &ptnwdNativeWaitData->mutex, - &tsAbsTmo); - } - - if (ETIMEDOUT == iWaitRet) - { - _ASSERT_MSG(INFINITE != dwTimeout, - "Got ETIMEDOUT despite timeout being INFINITE\n"); - break; - } - else if (0 != iWaitRet) - { - ERROR("pthread_cond_%swait returned %d [errno=%d (%s)]\n", - (INFINITE == dwTimeout) ? "" : "timed", - iWaitRet, errno, strerror(errno)); - palErr = ERROR_INTERNAL_ERROR; - break; - } - } - - // Reset the predicate - if (0 == iWaitRet) - { - // We don't want to reset the predicate if pthread_cond_timedwait - // timed out racing with a pthread_cond_signal. When - // pthread_cond_timedwait times out, it needs to grab the mutex - // before returning. At timeout time, it may happen that the - // signaling thread just grabbed the mutex, but it hasn't called - // pthread_cond_signal yet. In this scenario pthread_cond_timedwait - // will have to wait for the signaling side to release the mutex. - // As a result it will return with error timeout, but the predicate - // will be set. Since pthread_cond_timedwait timed out, the - // predicate value is intended for the next signal. In case of a - // object signaling racing with a wait timeout this predicate value - // will be picked up by the 'second native wait' (see comments in - // BlockThread). - - ptnwdNativeWaitData->iPred = FALSE; - } - - // Unlock the mutex - iRet = pthread_mutex_unlock(&ptnwdNativeWaitData->mutex); - if (0 != iRet) - { - ERROR("Cannot unlock mutex [err=%d]\n", iRet); - palErr = ERROR_INTERNAL_ERROR; - goto TNW_exit; - } - - _ASSERT_MSG(ETIMEDOUT != iRet || INFINITE != dwTimeout, "Got timeout return code with INFINITE timeout\n"); - - if (0 == iWaitRet) - { - *ptwrWakeupReason = ptnwdNativeWaitData->twrWakeupReason; - *pdwSignaledObject = ptnwdNativeWaitData->dwObjectIndex; - } - else if (ETIMEDOUT == iWaitRet) - { - *ptwrWakeupReason = WaitTimeout; - } - - TNW_exit: - TRACE("ThreadNativeWait: returning %u [WakeupReason=%u]\n", palErr, *ptwrWakeupReason); - return palErr; - } - - /*++ - Method: - CPalSynchronizationManager::AbandonObjectsOwnedByThread - - This method is called by a thread at thread-exit time to abandon - any currently owned waitable object (mutexes). If pthrTarget is - different from pthrCurrent, AbandonObjectsOwnedByThread assumes - to be called whether by TerminateThread or at shutdown time. See - comments below for more details - --*/ - PAL_ERROR CPalSynchronizationManager::AbandonObjectsOwnedByThread( - CPalThread * pthrCurrent, - CPalThread * pthrTarget) - { - PAL_ERROR palErr = NO_ERROR; - OwnedObjectsListNode * poolnItem; - bool fSharedSynchLock = false; - CThreadSynchronizationInfo * pSynchInfo = &pthrTarget->synchronizationInfo; - CPalSynchronizationManager * pSynchManager = GetInstance(); - - // Local lock - AcquireLocalSynchLock(pthrCurrent); - - // Abandon owned objects - while (NULL != (poolnItem = pSynchInfo->RemoveFirstObjectFromOwnedList())) - { - CSynchData * psdSynchData = poolnItem->pPalObjSynchData; - - _ASSERT_MSG(NULL != psdSynchData, - "NULL psdSynchData pointer in ownership list node\n"); - - VALIDATEOBJECT(psdSynchData); - - TRACE("Abandoning object with SynchData at %p\n", psdSynchData); - - if (!fSharedSynchLock && - (SharedObject == psdSynchData->GetObjectDomain())) - { - AcquireSharedSynchLock(pthrCurrent); - fSharedSynchLock = true; - } - - // Reset ownership data - psdSynchData->ResetOwnership(); - - // Set abandoned status; in case there is a thread to be released: - // - if the thread is local, ReleaseFirstWaiter will reset the - // abandoned status - // - if the thread is remote, the remote worker thread will use - // the value and reset it - psdSynchData->SetAbandoned(true); - - // Signal the object and trigger thread awakening - psdSynchData->Signal(pthrCurrent, 1, false); - - // Release reference to to SynchData - psdSynchData->Release(pthrCurrent); - - // Return node to the cache - pSynchManager->m_cacheOwnedObjectsListNodes.Add(pthrCurrent, poolnItem); - } - - // Abandon owned named mutexes - while (true) - { - NamedMutexProcessData *processData = pSynchInfo->RemoveFirstOwnedNamedMutex(); - if (processData == nullptr) - { - break; - } - processData->Abandon(); - } - - if (pthrTarget != pthrCurrent) - { - // If the target thead is not the current one, we are being called - // at shutdown time, right before the target thread is suspended, - // or anyway the target thread is being terminated. - // In this case we switch its wait state to TWS_EARLYDEATH so that, - // if the thread is currently waiting/sleeping and it wakes up - // before shutdown code manage to suspend it, it will be rerouted - // to ThreadPrepareForShutdown (that will be done without holding - // any internal lock, in a way to accomodate shutdown time thread - // suspension). - // At this time we also unregister the wait, so no dummy nodes are - // left around on waiting objects. - // The TWS_EARLYDEATH wait-state will also prevent the thread from - // successfully registering for a possible new wait in the same - // time window. - LONG lTWState; - DWORD * pdwWaitState; - - pdwWaitState = SharedIDToTypePointer(DWORD, pthrTarget->synchronizationInfo.m_shridWaitAwakened); - lTWState = InterlockedExchange((LONG *)pdwWaitState, TWS_EARLYDEATH); - - if (( ((LONG)TWS_WAITING == lTWState) || ((LONG)TWS_ALERTABLE == lTWState) ) && - (0 < pSynchInfo->m_twiWaitInfo.lObjCount)) - { - // Unregister the wait - // Note: UnRegisterWait will take care of grabbing the shared synch lock, if needed. - UnRegisterWait(pthrCurrent, &pSynchInfo->m_twiWaitInfo, fSharedSynchLock); - } - } - - // Unlock - if (fSharedSynchLock) - { - ReleaseSharedSynchLock(pthrCurrent); - fSharedSynchLock = false; - } - - ReleaseLocalSynchLock(pthrCurrent); - DiscardAllPendingAPCs(pthrCurrent, pthrTarget); - - return palErr; - } - - /*++ - Method: - CPalSynchronizationManager::GetSynchWaitControllersForObjects - - Returns an array of wait controllers, one for each of the objects - in rgObjects - --*/ - PAL_ERROR CPalSynchronizationManager::GetSynchWaitControllersForObjects( - CPalThread *pthrCurrent, - IPalObject *rgObjects[], - DWORD dwObjectCount, - ISynchWaitController * rgControllers[]) - { - return GetSynchControllersForObjects(pthrCurrent, - rgObjects, - dwObjectCount, - (void **)rgControllers, - CSynchControllerBase::WaitController); - } - - /*++ - Method: - CPalSynchronizationManager::GetSynchStateControllersForObjects - - Returns an array of state controllers, one for each of the objects - in rgObjects - --*/ - PAL_ERROR CPalSynchronizationManager::GetSynchStateControllersForObjects( - CPalThread *pthrCurrent, - IPalObject *rgObjects[], - DWORD dwObjectCount, - ISynchStateController *rgControllers[]) - { - return GetSynchControllersForObjects(pthrCurrent, - rgObjects, - dwObjectCount, - (void **)rgControllers, - CSynchControllerBase::StateController); - } - - /*++ - Method: - CPalSynchronizationManager::GetSynchControllersForObjects - - Internal common implementation for GetSynchWaitControllersForObjects and - GetSynchStateControllersForObjects - --*/ - PAL_ERROR CPalSynchronizationManager::GetSynchControllersForObjects( - CPalThread *pthrCurrent, - IPalObject *rgObjects[], - DWORD dwObjectCount, - void ** ppvControllers, - CSynchControllerBase::ControllerType ctCtrlrType) - { - PAL_ERROR palErr = NO_ERROR; - unsigned int uIdx, uCount = 0, uSharedObjectCount = 0; - WaitDomain wdWaitDomain = LocalWait; - CObjectType * potObjectType = NULL; - unsigned int uErrCleanupIdxFirstNotInitializedCtrlr = 0; - unsigned int uErrCleanupIdxLastCtrlr = 0; - bool fLocalSynchLock = false; - - union - { - CSynchWaitController * pWaitCtrlrs[MAXIMUM_WAIT_OBJECTS]; - CSynchStateController * pStateCtrlrs[MAXIMUM_WAIT_OBJECTS]; - } Ctrlrs; - - if ((dwObjectCount <= 0) || (dwObjectCount > MAXIMUM_WAIT_OBJECTS)) - { - palErr = ERROR_INVALID_PARAMETER; - goto GSCFO_exit; - } - - if (CSynchControllerBase::WaitController == ctCtrlrType) - { - uCount = (unsigned int)m_cacheWaitCtrlrs.Get(pthrCurrent, - dwObjectCount, - Ctrlrs.pWaitCtrlrs); - } - else - { - uCount = (unsigned int)m_cacheStateCtrlrs.Get(pthrCurrent, - dwObjectCount, - Ctrlrs.pStateCtrlrs); - } - - if (uCount < dwObjectCount) - { - // We got less controllers (uCount) than we asked for (dwObjectCount), - // probably because of low memory. - // None of these controllers is initialized, so they must be all - // returned directly to the cache - uErrCleanupIdxLastCtrlr = uCount; - - palErr = ERROR_NOT_ENOUGH_MEMORY; - goto GSCFO_error_cleanup; - } - - // - // We need to acquire the local synch lock before evaluating object domains - // - AcquireLocalSynchLock(pthrCurrent); - fLocalSynchLock = true; - - for (uIdx=0; uIdxGetObjectDomain()) - { - ++uSharedObjectCount; - } - - if (uSharedObjectCount > 0 && uSharedObjectCount <= uIdx) - { - wdWaitDomain = MixedWait; - break; - } - } - - if (dwObjectCount == uSharedObjectCount) - { - wdWaitDomain = SharedWait; - } - - for (uIdx=0;uIdxGetObjectDomain(); - - palErr = rgObjects[uIdx]->GetObjectSynchData((void **)&pvSData); - if (NO_ERROR != palErr) - { - break; - } - - psdSynchData = (SharedObject == odObjectDomain) ? SharedIDToTypePointer( - CSynchData, reinterpret_cast(pvSData)) : - static_cast(pvSData); - - VALIDATEOBJECT(psdSynchData); - - potObjectType = rgObjects[uIdx]->GetObjectType(); - - if (CSynchControllerBase::WaitController == ctCtrlrType) - { - Ctrlrs.pWaitCtrlrs[uIdx]->Init(pthrCurrent, - ctCtrlrType, - odObjectDomain, - potObjectType, - psdSynchData, - wdWaitDomain); - } - else - { - Ctrlrs.pStateCtrlrs[uIdx]->Init(pthrCurrent, - ctCtrlrType, - odObjectDomain, - potObjectType, - psdSynchData, - wdWaitDomain); - } - - if (CSynchControllerBase::WaitController == ctCtrlrType && - otiProcess == potObjectType->GetId()) - { - CProcProcessLocalData * pProcLocData; - IDataLock * pDataLock; - - palErr = rgObjects[uIdx]->GetProcessLocalData( - pthrCurrent, - ReadLock, - &pDataLock, - (void **)&pProcLocData); - - if (NO_ERROR != palErr) - { - // In case of failure here, bail out of the loop, but - // keep track (by incrementing the counter 'uIdx') of the - // fact that this controller has already being initialized - // and therefore need to be Release'd rather than just - // returned to the cache - uIdx++; - break; - } - - Ctrlrs.pWaitCtrlrs[uIdx]->SetProcessData(rgObjects[uIdx], pProcLocData); - pDataLock->ReleaseLock(pthrCurrent, false); - } - } - if (NO_ERROR != palErr) - { - // An error occurred while initializing the (uIdx+1)-th controller, - // i.e. the one at index uIdx; therefore the first uIdx controllers - // must be Release'd, while the remaining uCount-uIdx must be returned - // directly to the cache. - uErrCleanupIdxFirstNotInitializedCtrlr = uIdx; - uErrCleanupIdxLastCtrlr = dwObjectCount; - - goto GSCFO_error_cleanup; - } - - // Succeeded - if (CSynchControllerBase::WaitController == ctCtrlrType) - { - for (uIdx=0;uIdx( - static_cast(Ctrlrs.pWaitCtrlrs[uIdx])); - } - } - else - { - for (uIdx=0;uIdx( - static_cast(Ctrlrs.pStateCtrlrs[uIdx])); - } - } - - // Succeeded: skip error cleanup - goto GSCFO_exit; - - GSCFO_error_cleanup: - if (CSynchControllerBase::WaitController == ctCtrlrType) - { - // Release already initialized wait controllers - for (uIdx=0; uIdxRelease(); - } - - // Return to the cache not yet initialized wait controllers - for (uIdx=uErrCleanupIdxFirstNotInitializedCtrlr; uIdxRelease(); - } - - // Return to the cache not yet initialized state controllers - for (uIdx=uErrCleanupIdxFirstNotInitializedCtrlr; uIdxSetWTLHeadShrPtr(NULL); - psdSynchData->SetWTLTailShrPtr(NULL); - - // Store shared pointer to this object - psdSynchData->SetSharedThis(shridSynchData); - - *ppvSynchData = reinterpret_cast(shridSynchData); - } - else - { - psdSynchData = m_cacheSynchData.Get(pthrCurrent); - if (NULL == psdSynchData) - { - ERROR("Unable to allocate memory\n"); - return ERROR_NOT_ENOUGH_MEMORY; - } - - // Initialize waiting list pointers - psdSynchData->SetWTLHeadPtr(NULL); - psdSynchData->SetWTLTailPtr(NULL); - - // Set shared this pointer to NULL - psdSynchData->SetSharedThis(NULL); - - *ppvSynchData = static_cast(psdSynchData); - } - - // Initialize object domain and object type; - psdSynchData->SetObjectDomain(odObjectDomain); - psdSynchData->SetObjectType(potObjectType); - - return palErr; - } - - /*++ - Method: - CPalSynchronizationManager::FreeObjectSynchData - - Called to return a no longer used SynchData to the Synchronization Manager. - The SynchData may actually survive this call, since it is a ref-counted - object and at FreeObjectSynchData time it may still be used from within - the Synchronization Manager itself (e.g. the worker thread). - --*/ - void CPalSynchronizationManager::FreeObjectSynchData( - CObjectType *potObjectType, - ObjectDomain odObjectDomain, - VOID *pvSynchData) - { - CSynchData * psdSynchData; - CPalThread * pthrCurrent = InternalGetCurrentThread(); - - if (odObjectDomain == SharedObject) - { - psdSynchData = SharedIDToTypePointer(CSynchData, - reinterpret_cast(pvSynchData)); - - if (NULL == psdSynchData) - { - ASSERT("Bad shared memory pointer\n"); - return; - } - } - else - { - psdSynchData = static_cast(pvSynchData); - } - - psdSynchData->Release(pthrCurrent); - } - - /*++ - Method: - CPalSynchronizationManager::CreateSynchStateController - - Creates a state controller for the given object - --*/ - PAL_ERROR CPalSynchronizationManager::CreateSynchStateController( - CPalThread *pthrCurrent, - CObjectType *potObjectType, - VOID *pvSynchData, - ObjectDomain odObjectDomain, - ISynchStateController **ppStateController) - { - PAL_ERROR palErr = NO_ERROR; - CSynchStateController * pCtrlr = NULL; - WaitDomain wdWaitDomain = (SharedObject == odObjectDomain) ? SharedWait : LocalWait; - CSynchData * psdSynchData; - - psdSynchData = (SharedObject == odObjectDomain) ? SharedIDToTypePointer(CSynchData, reinterpret_cast(pvSynchData)) - : static_cast(pvSynchData); - - VALIDATEOBJECT(psdSynchData); - - pCtrlr = m_cacheStateCtrlrs.Get(pthrCurrent); - if (NULL == pCtrlr) - { - return ERROR_NOT_ENOUGH_MEMORY; - } - - pCtrlr->Init(pthrCurrent, - CSynchControllerBase::StateController, - odObjectDomain, - potObjectType, - psdSynchData, - wdWaitDomain); - - // Succeeded - *ppStateController = (ISynchStateController *)pCtrlr; - - if (NO_ERROR != palErr) - { - m_cacheStateCtrlrs.Add(pthrCurrent, pCtrlr); - } - - return palErr; - } - - /*++ - Method: - CPalSynchronizationManager::CreateSynchWaitController - - Creates a wait controller for the given object - --*/ - PAL_ERROR CPalSynchronizationManager::CreateSynchWaitController( - CPalThread *pthrCurrent, - CObjectType *potObjectType, - VOID *pvSynchData, - ObjectDomain odObjectDomain, - ISynchWaitController **ppWaitController) - { - CSynchWaitController * pCtrlr = NULL; - WaitDomain wdWaitDomain = (SharedObject == odObjectDomain) ? SharedWait : LocalWait; - CSynchData * psdSynchData; - - psdSynchData = (SharedObject == odObjectDomain) ? SharedIDToTypePointer( - CSynchData, reinterpret_cast(pvSynchData)) : - static_cast(pvSynchData); - - VALIDATEOBJECT(psdSynchData); - - pCtrlr = m_cacheWaitCtrlrs.Get(pthrCurrent); - if (NULL == pCtrlr) - { - return ERROR_NOT_ENOUGH_MEMORY; - } - - pCtrlr->Init(pthrCurrent, - CSynchControllerBase::WaitController, - odObjectDomain, - potObjectType, - psdSynchData, - wdWaitDomain); - - // Succeeded - *ppWaitController = (ISynchWaitController *)pCtrlr; - - return NO_ERROR; - } - - /*++ - Method: - CPalSynchronizationManager::QueueUserAPC - - Internal implementation of QueueUserAPC - --*/ - PAL_ERROR CPalSynchronizationManager::QueueUserAPC(CPalThread * pthrCurrent, - CPalThread * pthrTarget, - PAPCFUNC pfnAPC, - ULONG_PTR uptrData) - { - PAL_ERROR palErr = NO_ERROR; - ThreadApcInfoNode * ptainNode = NULL; - DWORD dwWaitState; - DWORD * pdwWaitState; - ThreadWaitInfo * pTargetTWInfo = GetThreadWaitInfo(pthrTarget); - bool fLocalSynchLock = false; - bool fSharedSynchLock = false; - bool fThreadLock = false; - - ptainNode = m_cacheThreadApcInfoNodes.Get(pthrCurrent); - if (NULL == ptainNode) - { - ERROR("No memory for new APCs linked list entry\n"); - palErr = ERROR_NOT_ENOUGH_MEMORY; - goto QUAPC_exit; - } - - ptainNode->pfnAPC = pfnAPC; - ptainNode->pAPCData = uptrData; - ptainNode->pNext = NULL; - - AcquireLocalSynchLock(pthrCurrent); - fLocalSynchLock = true; - - if (LocalWait != pTargetTWInfo->wdWaitDomain) - { - AcquireSharedSynchLock(pthrCurrent); - fSharedSynchLock = true; - } - - pthrTarget->Lock(pthrCurrent); - fThreadLock = true; - - if (TS_DONE == pthrTarget->synchronizationInfo.GetThreadState()) - { - ERROR("Thread %#x has terminated; can't queue an APC on it\n", - pthrTarget->GetThreadId()); - palErr = ERROR_INVALID_PARAMETER; - goto QUAPC_exit; - } - pdwWaitState = SharedIDToTypePointer(DWORD, - pthrTarget->synchronizationInfo.m_shridWaitAwakened); - if (TWS_EARLYDEATH == VolatileLoad(pdwWaitState)) - { - ERROR("Thread %#x is about to be suspended for process shutdwon, " - "can't queue an APC on it\n", pthrTarget->GetThreadId()); - palErr = ERROR_INVALID_PARAMETER; - goto QUAPC_exit; - } - - if (NULL == pthrTarget->apcInfo.m_ptainTail) - { - _ASSERT_MSG(NULL == pthrTarget->apcInfo.m_ptainHead, "Corrupted APC list\n"); - - pthrTarget->apcInfo.m_ptainHead = ptainNode; - pthrTarget->apcInfo.m_ptainTail = ptainNode; - } - else - { - pthrTarget->apcInfo.m_ptainTail->pNext = ptainNode; - pthrTarget->apcInfo.m_ptainTail = ptainNode; - } - - // Set ptainNode to NULL so it won't be readded to the cache - ptainNode = NULL; - - TRACE("APC %p with parameter %p added to APC queue\n", pfnAPC, uptrData); - - dwWaitState = InterlockedCompareExchange((LONG *)pdwWaitState, - (LONG)TWS_ACTIVE, - (LONG)TWS_ALERTABLE); - - // Release thread lock - pthrTarget->Unlock(pthrCurrent); - fThreadLock = false; - - if (TWS_ALERTABLE == dwWaitState) - { - // Unregister the wait - UnRegisterWait(pthrCurrent, pTargetTWInfo, fSharedSynchLock); - - // Wake up target thread - palErr = WakeUpLocalThread( - pthrCurrent, - pthrTarget, - Alerted, - 0); - - if (NO_ERROR != palErr) - { - ERROR("Failed to wakeup local thread %#x for dispatching APCs [err=%u]\n", - pthrTarget->GetThreadId(), palErr); - } - } - - QUAPC_exit: - if (fThreadLock) - { - pthrTarget->Unlock(pthrCurrent); - } - - if (fSharedSynchLock) - { - ReleaseSharedSynchLock(pthrCurrent); - } - - if (fLocalSynchLock) - { - ReleaseLocalSynchLock(pthrCurrent); - } - - if (ptainNode) - { - m_cacheThreadApcInfoNodes.Add(pthrCurrent, ptainNode); - } - - return palErr; - } - - /*++ - Method: - CPalSynchronizationManager::SendTerminationRequestToWorkerThread - - Send a request to the worker thread to initiate process termination. - --*/ - PAL_ERROR CPalSynchronizationManager::SendTerminationRequestToWorkerThread() - { - PAL_ERROR palErr = GetInstance()->WakeUpLocalWorkerThread(SynchWorkerCmdTerminationRequest); - if (palErr != NO_ERROR) - { - ERROR("Failed to wake up worker thread [errno=%d {%s%}]\n", - errno, strerror(errno)); - palErr = ERROR_INTERNAL_ERROR; - } - - return palErr; - } - - /*++ - Method: - CPalSynchronizationManager::AreAPCsPending - - Returns 'true' if there are APCs currently pending for the target - thread (normally the current one) - --*/ - bool CPalSynchronizationManager::AreAPCsPending( - CPalThread * pthrTarget) - { - // No need to lock here - return (NULL != pthrTarget->apcInfo.m_ptainHead); - } - - /*++ - Method: - CPalSynchronizationManager::DispatchPendingAPCs - - Executes any pending APC for the current thread - --*/ - PAL_ERROR CPalSynchronizationManager::DispatchPendingAPCs( - CPalThread * pthrCurrent) - { - ThreadApcInfoNode * ptainNode, * ptainLocalHead; - int iAPCsCalled = 0; - - while (TRUE) - { - // Lock - pthrCurrent->Lock(pthrCurrent); - ptainLocalHead = pthrCurrent->apcInfo.m_ptainHead; - if (ptainLocalHead) - { - pthrCurrent->apcInfo.m_ptainHead = NULL; - pthrCurrent->apcInfo.m_ptainTail = NULL; - } - - // Unlock - pthrCurrent->Unlock(pthrCurrent); - - if (NULL == ptainLocalHead) - { - break; - } - - while (ptainLocalHead) - { - ptainNode = ptainLocalHead; - ptainLocalHead = ptainNode->pNext; - -#if _ENABLE_DEBUG_MESSAGES_ - // reset ENTRY nesting level back to zero while - // inside the callback ... - int iOldLevel = DBG_change_entrylevel(0); -#endif /* _ENABLE_DEBUG_MESSAGES_ */ - - TRACE("Calling APC %p with parameter %#x\n", - ptainNode->pfnAPC, ptainNode->pfnAPC); - - // Actual APC call - ptainNode->pfnAPC(ptainNode->pAPCData); - -#if _ENABLE_DEBUG_MESSAGES_ - // ... and set nesting level back to what it was - DBG_change_entrylevel(iOldLevel); -#endif /* _ENABLE_DEBUG_MESSAGES_ */ - - iAPCsCalled++; - m_cacheThreadApcInfoNodes.Add(pthrCurrent, ptainNode); - } - } - - return (iAPCsCalled > 0) ? NO_ERROR : ERROR_NOT_FOUND; - } - - /*++ - Method: - CPalSynchronizationManager::DiscardAllPendingAPCs - - Discards any pending APC for the target pthrTarget thread - --*/ - void CPalSynchronizationManager::DiscardAllPendingAPCs( - CPalThread * pthrCurrent, - CPalThread * pthrTarget) - { - ThreadApcInfoNode * ptainNode, * ptainLocalHead; - - // Lock - pthrTarget->Lock(pthrCurrent); - ptainLocalHead = pthrTarget->apcInfo.m_ptainHead; - if (ptainLocalHead) - { - pthrTarget->apcInfo.m_ptainHead = NULL; - pthrTarget->apcInfo.m_ptainTail = NULL; - } - - // Unlock - pthrTarget->Unlock(pthrCurrent); - - while (ptainLocalHead) - { - ptainNode = ptainLocalHead; - ptainLocalHead = ptainNode->pNext; - - m_cacheThreadApcInfoNodes.Add(pthrCurrent, ptainNode); - } - } - - /*++ - Method: - CPalSynchronizationManager::CreatePalSynchronizationManager - - Creates the Synchronization Manager. - Private method, it is called only by CPalSynchMgrController. - --*/ - IPalSynchronizationManager * CPalSynchronizationManager::CreatePalSynchronizationManager() - { - if (s_pObjSynchMgr != NULL) - { - ASSERT("Multiple PAL Synchronization manager initializations\n"); - return NULL; - } - - Initialize(); - return static_cast(s_pObjSynchMgr); - } - - /*++ - Method: - CPalSynchronizationManager::Initialize - - Internal Synchronization Manager initialization - --*/ - PAL_ERROR CPalSynchronizationManager::Initialize() - { - PAL_ERROR palErr = NO_ERROR; - LONG lInit; - CPalSynchronizationManager * pSynchManager = NULL; - - lInit = InterlockedCompareExchange(&s_lInitStatus, - (LONG)SynchMgrStatusInitializing, - (LONG)SynchMgrStatusIdle); - - if ((LONG)SynchMgrStatusIdle != lInit) - { - ASSERT("Synchronization Manager already being initialized"); - palErr = ERROR_INTERNAL_ERROR; - goto I_exit; - } - - InternalInitializeCriticalSection(&s_csSynchProcessLock); - InternalInitializeCriticalSection(&s_csMonitoredProcessesLock); - - pSynchManager = InternalNew(); - if (NULL == pSynchManager) - { - ERROR("Failed to allocate memory for Synchronization Manager"); - palErr = ERROR_NOT_ENOUGH_MEMORY; - goto I_exit; - } - - if (!pSynchManager->CreateProcessPipe()) - { - ERROR("Unable to create process pipe \n"); - palErr = ERROR_OPEN_FAILED; - goto I_exit; - } - - s_pObjSynchMgr = pSynchManager; - - // Initialization was successful - g_pSynchronizationManager = - static_cast(pSynchManager); - s_lInitStatus = (LONG)SynchMgrStatusRunning; - - I_exit: - if (NO_ERROR != palErr) - { - s_lInitStatus = (LONG)SynchMgrStatusError; - if (NULL != pSynchManager) - { - pSynchManager->ShutdownProcessPipe(); - } - - s_pObjSynchMgr = NULL; - g_pSynchronizationManager = NULL; - InternalDelete(pSynchManager); - } - - return palErr; - } - - /*++ - Method: - CPalSynchronizationManager::StartWorker - - Starts the Synchronization Manager's Worker Thread. - Private method, it is called only by CPalSynchMgrController. - --*/ - PAL_ERROR CPalSynchronizationManager::StartWorker( - CPalThread * pthrCurrent) - { - PAL_ERROR palErr = NO_ERROR; - CPalSynchronizationManager * pSynchManager = GetInstance(); - - if ((NULL == pSynchManager) || ((LONG)SynchMgrStatusRunning != s_lInitStatus)) - { - ERROR("Trying to to create worker thread in invalid state\n"); - return ERROR_INTERNAL_ERROR; - } - - HANDLE hWorkerThread = NULL; - palErr = InternalCreateThread(pthrCurrent, - NULL, - 0, - &WorkerThread, - (PVOID)pSynchManager, - 0, - PalWorkerThread, - &pSynchManager->m_dwWorkerThreadTid, - &hWorkerThread); - - if (NO_ERROR == palErr) - { - palErr = InternalGetThreadDataFromHandle(pthrCurrent, - hWorkerThread, - 0, - &pSynchManager->m_pthrWorker, - &pSynchManager->m_pipoThread); - if (NO_ERROR != palErr) - { - ERROR("Unable to get worker thread data\n"); - } - } - else - { - ERROR("Unable to create worker thread\n"); - } - - if (NULL != hWorkerThread) - { - CloseHandle(hWorkerThread); - } - - return palErr; - } - - /*++ - Method: - CPalSynchronizationManager::PrepareForShutdown - - This method performs the part of Synchronization Manager's shutdown that - needs to be carried out when core PAL subsystems are still active. - Private method, it is called only by CPalSynchMgrController. - --*/ - PAL_ERROR CPalSynchronizationManager::PrepareForShutdown() - { - PAL_ERROR palErr = NO_ERROR; - CPalSynchronizationManager * pSynchManager = GetInstance(); - CPalThread * pthrCurrent = InternalGetCurrentThread(); - int iRet; - ThreadNativeWaitData * ptnwdWorkerThreadNativeData; - struct timespec tsAbsTmo = { 0, 0 }; - - LONG lInit = InterlockedCompareExchange(&s_lInitStatus, - (LONG)SynchMgrStatusShuttingDown, (LONG)SynchMgrStatusRunning); - - if ((LONG)SynchMgrStatusRunning != lInit) - { - ASSERT("Unexpected initialization status found " - "in PrepareForShutdown [expected=%d current=%d]\n", - SynchMgrStatusRunning, lInit); - // We intentionally not set s_lInitStatus to SynchMgrStatusError - // cause this could interfere with a previous thread already - // executing shutdown - palErr = ERROR_INTERNAL_ERROR; - goto PFS_exit; - } - - // Discard process monitoring for process waits - pSynchManager->DiscardMonitoredProcesses(pthrCurrent); - - if (NULL == pSynchManager->m_pipoThread) - { - // If m_pipoThread is NULL here, that means that StartWorker has - // never been called. That may happen if PAL_Initialize fails - // sometime after having called CreatePalSynchronizationManager, - // but before calling StartWorker. Nothing else to do here. - goto PFS_exit; - } - - palErr = pSynchManager->WakeUpLocalWorkerThread(SynchWorkerCmdShutdown); - if (NO_ERROR != palErr) - { - ERROR("Failed stopping worker thread [palErr=%u]\n", palErr); - s_lInitStatus = SynchMgrStatusError; - goto PFS_exit; - } - - ptnwdWorkerThreadNativeData = - &pSynchManager->m_pthrWorker->synchronizationInfo.m_tnwdNativeData; - - palErr = GetAbsoluteTimeout(WorkerThreadTerminationTimeout, &tsAbsTmo, /*fPreferMonotonicClock*/ TRUE); - if (NO_ERROR != palErr) - { - ERROR("Failed to convert timeout to absolute timeout\n"); - s_lInitStatus = SynchMgrStatusError; - goto PFS_exit; - } - - // Using the worker thread's predicate/condition/mutex - // to wait for worker thread to be done - iRet = pthread_mutex_lock(&ptnwdWorkerThreadNativeData->mutex); - if (0 != iRet) - { - // pthread calls might fail if the shutdown is called - // from a signal handler. In this case just don't wait - // for the worker thread - ERROR("Cannot lock mutex [err=%d]\n", iRet); - palErr = ERROR_INTERNAL_ERROR; - s_lInitStatus = SynchMgrStatusError; - goto PFS_exit; - } - - while (FALSE == ptnwdWorkerThreadNativeData->iPred) - { - iRet = pthread_cond_timedwait(&ptnwdWorkerThreadNativeData->cond, - &ptnwdWorkerThreadNativeData->mutex, - &tsAbsTmo); - if (0 != iRet) - { - if (ETIMEDOUT == iRet) - { - WARN("Timed out waiting for worker thread to exit " - "(tmo=%u ms)\n", WorkerThreadTerminationTimeout); - } - else - { - ERROR("pthread_cond_timedwait returned %d [errno=%d (%s)]\n", - iRet, errno, strerror(errno)); - } - break; - } - } - if (0 == iRet) - { - ptnwdWorkerThreadNativeData->iPred = FALSE; - } - iRet = pthread_mutex_unlock(&ptnwdWorkerThreadNativeData->mutex); - if (0 != iRet) - { - ERROR("Cannot unlock mutex [err=%d]\n", iRet); - palErr = ERROR_INTERNAL_ERROR; - s_lInitStatus = SynchMgrStatusError; - goto PFS_exit; - } - - PFS_exit: - if (NO_ERROR == palErr) - { - if (NULL != pSynchManager->m_pipoThread) - { - pSynchManager->m_pipoThread->ReleaseReference(pthrCurrent); - - // After this release both m_pipoThread and m_pthrWorker - // are no longer valid - pSynchManager->m_pipoThread = NULL; - pSynchManager->m_pthrWorker = NULL; - } - - // Ready for process shutdown - s_lInitStatus = SynchMgrStatusReadyForProcessShutDown; - } - - return palErr; - } - - // Entry point routine for the thread that initiates process termination. - DWORD PALAPI TerminationRequestHandlingRoutine(LPVOID pArg) - { - // Call the termination request handler if one is registered. - if (g_terminationRequestHandler != NULL) - { - g_terminationRequestHandler(); - } - - return 0; - } - - /*++ - Method: - CPalSynchronizationManager::WorkerThread - - Synchronization Manager's Worker Thread - --*/ - DWORD PALAPI CPalSynchronizationManager::WorkerThread(LPVOID pArg) - { - PAL_ERROR palErr; - bool fShuttingDown = false; - bool fWorkerIsDone = false; - int iPollTimeout = INFTIM; - SynchWorkerCmd swcCmd; - ThreadWakeupReason twrWakeUpReason; - SharedID shridMarshaledData; - DWORD dwData; - CPalSynchronizationManager * pSynchManager = - reinterpret_cast(pArg); - CPalThread * pthrWorker = InternalGetCurrentThread(); - - while (!fWorkerIsDone) - { - LONG lProcessCount; - - palErr = pSynchManager->ReadCmdFromProcessPipe(iPollTimeout, - &swcCmd, - &shridMarshaledData, - &dwData); - if (NO_ERROR != palErr) - { - ERROR("Received error %x from ReadCmdFromProcessPipe()\n", - palErr); - continue; - } - switch (swcCmd) - { - case SynchWorkerCmdTerminationRequest: - // This worker thread is being asked to initiate process termination - - HANDLE hTerminationRequestHandlingThread; - palErr = InternalCreateThread(pthrWorker, - NULL, - 0, - &TerminationRequestHandlingRoutine, - NULL, - 0, - PalWorkerThread, - NULL, - &hTerminationRequestHandlingThread); - - if (NO_ERROR != palErr) - { - ERROR("Unable to create worker thread\n"); - } - - if (hTerminationRequestHandlingThread != NULL) - { - CloseHandle(hTerminationRequestHandlingThread); - } - - break; - case SynchWorkerCmdNop: - TRACE("Synch Worker: received SynchWorkerCmdNop\n"); - if (fShuttingDown) - { - TRACE("Synch Worker: received a timeout when " - "fShuttingDown==true: worker is done, bailing " - "out from the loop\n"); - - // Whether WorkerThreadShuttingDownTimeout has elapsed - // or the last process with a descriptor opened for - // write on our process pipe, has just closed it, - // causing an EOF on the read fd (that can happen only - // at shutdown time since during normal run time we - // hold a fd opened for write within this process). - // In both the case it is time to go for the worker - // thread. - fWorkerIsDone = true; - } - else - { - lProcessCount = pSynchManager->DoMonitorProcesses(pthrWorker); - if (lProcessCount > 0) - { - iPollTimeout = WorkerThreadProcMonitoringTimeout; - } - else - { - iPollTimeout = INFTIM; - } - } - break; - case SynchWorkerCmdRemoteSignal: - { - // Note: this cannot be a wait all - WaitingThreadsListNode * pWLNode; - ThreadWaitInfo * ptwiWaitInfo; - DWORD dwObjIndex; - bool fSharedSynchLock = false; - - // Lock - AcquireLocalSynchLock(pthrWorker); - AcquireSharedSynchLock(pthrWorker); - fSharedSynchLock = true; - - pWLNode = SharedIDToTypePointer(WaitingThreadsListNode, - shridMarshaledData); - - _ASSERT_MSG(NULL != pWLNode, "Received bad Shared ID %p\n", - shridMarshaledData); - _ASSERT_MSG(gPID == pWLNode->dwProcessId, - "Remote signal apparently sent to the wrong " - "process [target pid=%u current pid=%u]\n", - pWLNode->dwProcessId, gPID); - _ASSERT_MSG(0 == (WTLN_FLAG_WAIT_ALL & pWLNode->dwFlags), - "Wait all with remote awakening delegated " - "through SynchWorkerCmdRemoteSignal rather than " - "SynchWorkerCmdDelegatedObjectSignaling\n"); - - - // Get the object index - dwObjIndex = pWLNode->dwObjIndex; - - // Get the WaitInfo - ptwiWaitInfo = pWLNode->ptwiWaitInfo; - - // Initialize the WakeUpReason to WaitSucceeded - twrWakeUpReason = WaitSucceeded; - - CSynchData * psdSynchData = - SharedIDToTypePointer(CSynchData, - pWLNode->ptrOwnerObjSynchData.shrid); - - TRACE("Synch Worker: received REMOTE SIGNAL cmd " - "[WInfo=%p {Type=%u Domain=%u ObjCount=%d TgtThread=%x} " - "SynchData={shriId=%p p=%p} {SigCount=%d IsAbandoned=%d}\n", - ptwiWaitInfo, ptwiWaitInfo->wtWaitType, ptwiWaitInfo->wdWaitDomain, - ptwiWaitInfo->lObjCount, ptwiWaitInfo->pthrOwner->GetThreadId(), - (VOID *)pWLNode->ptrOwnerObjSynchData.shrid, psdSynchData, - psdSynchData->GetSignalCount(), psdSynchData->IsAbandoned()); - - if (CObjectType::OwnershipTracked == - psdSynchData->GetObjectType()->GetOwnershipSemantics()) - { - // Abandoned status is not propagated through process - // pipe: need to get it from the object itself before - // resetting the data by acquiring the object ownership - if (psdSynchData->IsAbandoned()) - { - twrWakeUpReason = MutexAbondoned; - } - - // Acquire ownership - palErr = psdSynchData->AssignOwnershipToThread( - pthrWorker, - ptwiWaitInfo->pthrOwner); - if (NO_ERROR != palErr) - { - ERROR("Synch Worker: AssignOwnershipToThread " - "failed with error %u; ownership data on " - "object with SynchData %p may be " - "corrupted\n", palErr, psdSynchData); - } - } - - // Unregister the wait - pSynchManager->UnRegisterWait(pthrWorker, - ptwiWaitInfo, - fSharedSynchLock); - - // pWLNode is no longer valid after UnRegisterWait - pWLNode = NULL; - - TRACE("Synch Worker: Waking up local thread %x " - "{WakeUpReason=%u ObjIndex=%u}\n", - ptwiWaitInfo->pthrOwner->GetThreadId(), - twrWakeUpReason, dwObjIndex); - - // Wake up the target thread - palErr = WakeUpLocalThread( - pthrWorker, - ptwiWaitInfo->pthrOwner, - twrWakeUpReason, - dwObjIndex); - if (NO_ERROR != palErr) - { - ERROR("Synch Worker: Failed to wake up local thread " - "%#x while propagating remote signaling: " - "object signaling may be lost\n", - ptwiWaitInfo->pthrOwner->GetThreadId()); - } - - // Unlock - ReleaseSharedSynchLock(pthrWorker); - fSharedSynchLock = false; - ReleaseLocalSynchLock(pthrWorker); - - break; - } - case SynchWorkerCmdDelegatedObjectSignaling: - { - CSynchData * psdSynchData; - - TRACE("Synch Worker: received " - "SynchWorkerCmdDelegatedObjectSignaling\n"); - - psdSynchData = SharedIDToTypePointer(CSynchData, - shridMarshaledData); - - _ASSERT_MSG(NULL != psdSynchData, "Received bad Shared ID %p\n", - shridMarshaledData); - _ASSERT_MSG(0 < dwData && (DWORD)INT_MAX > dwData, - "Received remote signaling with invalid signal " - "count\n"); - - // Lock - AcquireLocalSynchLock(pthrWorker); - AcquireSharedSynchLock(pthrWorker); - - TRACE("Synch Worker: received DELEGATED OBJECT SIGNALING " - "cmd [SynchData={shriId=%p p=%p} SigCount=%u] [Current obj SigCount=%d " - "IsAbandoned=%d]\n", (VOID *)shridMarshaledData, - psdSynchData, dwData, psdSynchData->GetSignalCount(), - psdSynchData->IsAbandoned()); - - psdSynchData->Signal(pthrWorker, - psdSynchData->GetSignalCount() + dwData, - true); - - // Current SynchData has been AddRef'd by remote process in - // order to be marshaled to the current one, therefore at - // this point we need to release it - psdSynchData->Release(pthrWorker); - - // Unlock - ReleaseSharedSynchLock(pthrWorker); - ReleaseLocalSynchLock(pthrWorker); - - break; - } - case SynchWorkerCmdShutdown: - TRACE("Synch Worker: received SynchWorkerCmdShutdown\n"); - - // Shutdown the process pipe: this will cause the process - // pipe to be unlinked and its write-only file descriptor - // to be closed, so that when the last fd opened for write - // on the fifo (from another process) will be closed, we - // will receive an EOF on the read end (i.e. poll in - // ReadBytesFromProcessPipe will return 1 with no data to - // be read). That will allow the worker thread to process - // possible commands already successfully written to the - // pipe by some other process, before shutting down. - pSynchManager->ShutdownProcessPipe(); - - // Shutting down: this will cause the worker thread to - // fetch residual cmds from the process pipe until an - // EOF is converted to a SynchWorkerCmdNop or the - // WorkerThreadShuttingDownTimeout has elapsed without - // receiving any cmd. - fShuttingDown = true; - - // Set the timeout to WorkerThreadShuttingDownTimeout - iPollTimeout = WorkerThreadShuttingDownTimeout; - break; - default: - ASSERT("Synch Worker: Unknown worker cmd [swcWorkerCmd=%d]\n", - swcCmd); - break; - } - } - - int iRet; - ThreadNativeWaitData * ptnwdWorkerThreadNativeData = - &pthrWorker->synchronizationInfo.m_tnwdNativeData; - - // Using the worker thread's predicate/condition/mutex - // (that normally are never used) to signal the shutting - // down thread that the worker thread is done - iRet = pthread_mutex_lock(&ptnwdWorkerThreadNativeData->mutex); - _ASSERT_MSG(0 == iRet, "Cannot lock mutex [err=%d]\n", iRet); - - ptnwdWorkerThreadNativeData->iPred = TRUE; - - iRet = pthread_cond_signal(&ptnwdWorkerThreadNativeData->cond); - if (0 != iRet) - { - ERROR ("pthread_cond_signal returned %d [errno=%d (%s)]\n", - iRet, errno, strerror(errno)); - } - - iRet = pthread_mutex_unlock(&ptnwdWorkerThreadNativeData->mutex); - _ASSERT_MSG(0 == iRet, "Cannot lock mutex [err=%d]\n", iRet); - - // Sleep forever - ThreadPrepareForShutdown(); - - return 0; - } - - /*++ - Method: - CPalSynchronizationManager::ReadCmdFromProcessPipe - - Reads a worker thread cmd from the process pipe. If there is no data - to be read on the pipe, it blocks until there is data available or the - timeout expires. - --*/ - PAL_ERROR CPalSynchronizationManager::ReadCmdFromProcessPipe( - int iPollTimeout, - SynchWorkerCmd * pswcWorkerCmd, - SharedID * pshridMarshaledData, - DWORD * pdwData) - { - int iRet; - BYTE byVal; - SynchWorkerCmd swcWorkerCmd = SynchWorkerCmdNop; - - _ASSERTE(NULL != pswcWorkerCmd); - _ASSERTE(NULL != pshridMarshaledData); - _ASSERTE(NULL != pdwData); - - iRet = ReadBytesFromProcessPipe(iPollTimeout, &byVal, sizeof(BYTE)); - - if (0 > iRet) - { - ERROR("Failed polling the process pipe [ret=%d errno=%d (%s)]\n", - iRet, errno, strerror(errno)); - - return ERROR_INTERNAL_ERROR; - } - - if (iRet != 0) - { - _ASSERT_MSG(sizeof(BYTE) == iRet, - "Got %d bytes from process pipe while expecting for %d\n", - iRet, sizeof(BYTE)); - - swcWorkerCmd = (SynchWorkerCmd)byVal; - - if (SynchWorkerCmdLast <= swcWorkerCmd) - { - ERROR("Got unknown worker command code %d from the process " - "pipe!\n", swcWorkerCmd); - - return ERROR_INTERNAL_ERROR; - } - - _ASSERT_MSG(SynchWorkerCmdNop == swcWorkerCmd || - SynchWorkerCmdRemoteSignal == swcWorkerCmd || - SynchWorkerCmdDelegatedObjectSignaling == swcWorkerCmd || - SynchWorkerCmdShutdown == swcWorkerCmd || - SynchWorkerCmdTerminationRequest == swcWorkerCmd, - "Unknown worker command code %u\n", swcWorkerCmd); - - TRACE("Got cmd %u from process pipe\n", swcWorkerCmd); - } - - if (SynchWorkerCmdRemoteSignal == swcWorkerCmd || - SynchWorkerCmdDelegatedObjectSignaling == swcWorkerCmd) - { - SharedID shridMarshaledId = NULL; - - TRACE("Received %s cmd\n", - (swcWorkerCmd == SynchWorkerCmdRemoteSignal) ? - "REMOTE SIGNAL" : "DELEGATED OBJECT SIGNALING" ); - - iRet = ReadBytesFromProcessPipe(WorkerCmdCompletionTimeout, - (BYTE *)&shridMarshaledId, - sizeof(shridMarshaledId)); - if (sizeof(shridMarshaledId) != iRet) - { - ERROR("Unable to read marshaled Shared ID from the " - "process pipe [pipe=%d ret=%d errno=%d (%s)]\n", - m_iProcessPipeRead, iRet, errno, strerror(errno)); - - return ERROR_INTERNAL_ERROR; - } - - TRACE("Received marshaled shrid=%p\n", (VOID *)shridMarshaledId); - - *pshridMarshaledData = shridMarshaledId; - } - - if (SynchWorkerCmdDelegatedObjectSignaling == swcWorkerCmd) - { - DWORD dwData; - - iRet = ReadBytesFromProcessPipe(WorkerCmdCompletionTimeout, - (BYTE *)&dwData, - sizeof(dwData)); - if (sizeof(dwData) != iRet) - { - ERROR("Unable to read signal count from the " - "process pipe [pipe=%d ret=%d errno=%d (%s)]\n", - m_iProcessPipeRead, iRet, errno, strerror(errno)); - - return ERROR_INTERNAL_ERROR; - } - - TRACE("Received signal count %u\n", dwData); - - *pdwData = dwData; - } - - *pswcWorkerCmd = swcWorkerCmd; - return NO_ERROR; - } - - /*++ - Method: - CPalSynchronizationManager::ReadBytesFromProcessPipe - - Reads the specified number of bytes from the process pipe. If there is - no data to be read on the pipe, it blocks until there is data available - or the timeout expires. - --*/ - int CPalSynchronizationManager::ReadBytesFromProcessPipe( - int iTimeout, - BYTE * pRecvBuf, - LONG iBytes) - { -#if !HAVE_KQUEUE - struct pollfd Poll; -#endif // !HAVE_KQUEUE - int iRet = -1; - int iConsecutiveEintrs = 0; - LONG iBytesRead = 0; - BYTE * pPos = pRecvBuf; -#if HAVE_KQUEUE && !HAVE_BROKEN_FIFO_KEVENT - struct kevent keChanges; - struct timespec ts, *pts; - int iNChanges; -#endif // HAVE_KQUEUE - - _ASSERTE(0 <= iBytes); - - do - { - while (TRUE) - { - int iErrno = 0; -#if HAVE_KQUEUE -#if HAVE_BROKEN_FIFO_KEVENT -#if HAVE_BROKEN_FIFO_SELECT -#error Found no way to wait on a FIFO. -#endif - - timeval *ptv; - timeval tv; - - if (INFTIM == iTimeout) - { - ptv = NULL; - } - else - { - tv.tv_usec = (iTimeout % tccSecondsToMillieSeconds) * - tccMillieSecondsToMicroSeconds; - tv.tv_sec = iTimeout / tccSecondsToMillieSeconds; - ptv = &tv; - } - - fd_set readfds; - FD_ZERO(&readfds); - FD_SET(m_iProcessPipeRead, &readfds); - iRet = select(m_iProcessPipeRead + 1, &readfds, NULL, NULL, ptv); - -#else // HAVE_BROKEN_FIFO_KEVENT - - // Note: FreeBSD needs to use kqueue/kevent support here, since on this - // platform the EOF notification on FIFOs is not surfaced through poll, - // and process pipe shutdown relies on this feature. - // If a thread is polling a FIFO or a pipe for POLLIN, when the last - // write descriptor for that pipe is closed, poll() is supposed to - // return with a POLLIN event but no data to be read on the FIFO/pipe, - // which means EOF. - // On FreeBSD such feature works for pipes but it doesn't for FIFOs. - // Using kevent the EOF is instead surfaced correctly. - - if (iBytes > m_keProcessPipeEvent.data) - { - if (INFTIM == iTimeout) - { - pts = NULL; - } - else - { - ts.tv_nsec = (iTimeout % tccSecondsToMillieSeconds) * - tccMillieSecondsToNanoSeconds; - ts.tv_sec = iTimeout / tccSecondsToMillieSeconds; - pts = &ts; - } - - if (0 != (EV_EOF & m_keProcessPipeEvent.flags)) - { - TRACE("Refreshing kevent settings\n"); - EV_SET(&keChanges, m_iProcessPipeRead, EVFILT_READ, - EV_ADD | EV_CLEAR, 0, 0, 0); - iNChanges = 1; - } - else - { - iNChanges = 0; - } - - iRet = kevent(m_iKQueue, &keChanges, iNChanges, - &m_keProcessPipeEvent, 1, pts); - - if (0 < iRet) - { - _ASSERTE(1 == iRet); - _ASSERTE(EVFILT_READ == m_keProcessPipeEvent.filter); - - if (EV_ERROR & m_keProcessPipeEvent.flags) - { - ERROR("EV_ERROR from kevent [ident=%d filter=%d flags=%x]\n", m_keProcessPipeEvent.ident, m_keProcessPipeEvent.filter, m_keProcessPipeEvent.flags); - iRet = -1; - iErrno = m_keProcessPipeEvent.data; - m_keProcessPipeEvent.data = 0; - } - } - else if (0 > iRet) - { - iErrno = errno; - } - - TRACE("Woken up from kevent() with ret=%d flags=%#x data=%d " - "[iTimeout=%d]\n", iRet, m_keProcessPipeEvent.flags, - m_keProcessPipeEvent.data, iTimeout); - } - else - { - // There is enough data already available in the buffer, just use that. - iRet = 1; - } - -#endif // HAVE_BROKEN_FIFO_KEVENT -#else // HAVE_KQUEUE - - Poll.fd = m_iProcessPipeRead; - Poll.events = POLLIN; - Poll.revents = 0; - - iRet = poll(&Poll, 1, iTimeout); - - TRACE("Woken up from poll() with ret=%d [iTimeout=%d]\n", - iRet, iTimeout); - - if (1 == iRet && - ((POLLERR | POLLHUP | POLLNVAL) & Poll.revents)) - { - // During PAL shutdown the pipe gets closed and Poll.revents is set to POLLHUP - // (note: no other flags are set). We will also receive an EOF on from the read call. - // Please see the comment for SynchWorkerCmdShutdown in CPalSynchronizationManager::WorkerThread. - if (!PALIsShuttingDown() || (Poll.revents != POLLHUP)) - { - ERROR("Unexpected revents=%x while polling pipe %d\n", - Poll.revents, Poll.fd); - iErrno = EINVAL; - iRet = -1; - } - } - else if (0 > iRet) - { - iErrno = errno; - } - -#endif // HAVE_KQUEUE - - if (0 == iRet || 1 == iRet) - { - // 0 == wait timed out - // 1 == FIFO has data available - break; - } - else - { - if (1 < iRet) - { - // Unexpected iRet > 1 - ASSERT("Unexpected return code %d from blocking poll/kevent call\n", - iRet); - goto RBFPP_exit; - } - - if (EINTR != iErrno) - { - // Unexpected error - ASSERT("Unexpected error from blocking poll/kevent call: %d (%s)\n", - iErrno, strerror(iErrno)); - goto RBFPP_exit; - } - - iConsecutiveEintrs++; - TRACE("poll() failed with EINTR; re-polling\n"); - - if (iConsecutiveEintrs >= MaxWorkerConsecutiveEintrs) - { - if (iTimeout != INFTIM) - { - WARN("Receiving too many EINTRs; converting one of them " - "to a timeout"); - iRet = 0; - break; - } - else if (0 == (iConsecutiveEintrs % MaxWorkerConsecutiveEintrs)) - { - WARN("Receiving too many EINTRs [%d so far]", - iConsecutiveEintrs); - } - } - } - } - - if (0 == iRet) - { - // Time out - break; - } - else - { -#if HAVE_KQUEUE && !HAVE_BROKEN_FIFO_KEVENT - if (0 != (EV_EOF & m_keProcessPipeEvent.flags) && 0 == m_keProcessPipeEvent.data) - { - // EOF - TRACE("Received an EOF on process pipe via kevent\n"); - goto RBFPP_exit; - } -#endif // HAVE_KQUEUE - - iRet = read(m_iProcessPipeRead, pPos, iBytes - iBytesRead); - - if (0 == iRet) - { - // Poll returned 1 and read returned zero: this is an EOF, - // i.e. no other process has the pipe still open for write - TRACE("Received an EOF on process pipe via poll\n"); - goto RBFPP_exit; - } - else if (0 > iRet) - { - ERROR("Unable to read %d bytes from the the process pipe " - "[pipe=%d ret=%d errno=%d (%s)]\n", iBytes - iBytesRead, - m_iProcessPipeRead, iRet, errno, strerror(errno)); - goto RBFPP_exit; - } - - TRACE("Read %d bytes from process pipe\n", iRet); - - iBytesRead += iRet; - pPos += iRet; - -#if HAVE_KQUEUE && !HAVE_BROKEN_FIFO_KEVENT - // Update available data count - m_keProcessPipeEvent.data -= iRet; - _ASSERTE(0 <= m_keProcessPipeEvent.data); -#endif // HAVE_KQUEUE - } - } while(iBytesRead < iBytes); - - RBFPP_exit: - return (iRet < 0) ? iRet : iBytesRead; - } - - /*++ - Method: - CPalSynchronizationManager::WakeUpLocalThread - - Wakes up a local thead currently sleeping for a wait or a sleep - --*/ - PAL_ERROR CPalSynchronizationManager::WakeUpLocalThread( - CPalThread * pthrCurrent, - CPalThread * pthrTarget, - ThreadWakeupReason twrWakeupReason, - DWORD dwObjectIndex) - { - PAL_ERROR palErr = NO_ERROR; - ThreadNativeWaitData * ptnwdNativeWaitData = - pthrTarget->synchronizationInfo.GetNativeData(); - - TRACE("Waking up a local thread [WakeUpReason=%u ObjectIndex=%u " - "ptnwdNativeWaitData=%p]\n", twrWakeupReason, dwObjectIndex, - ptnwdNativeWaitData); - - // Set wakeup reason and signaled object index - ptnwdNativeWaitData->twrWakeupReason = twrWakeupReason; - ptnwdNativeWaitData->dwObjectIndex = dwObjectIndex; - -#if SYNCHMGR_SUSPENSION_SAFE_CONDITION_SIGNALING - if (0 < GetLocalSynchLockCount(pthrCurrent)) - { - // Defer the actual thread signaling to right after - // releasing the synch lock(s), so that signaling - // can happen from a thread-suspension safe area - palErr = DeferThreadConditionSignaling(pthrCurrent, pthrTarget); - } - else - { - // Signal the target thread's condition - palErr = SignalThreadCondition(ptnwdNativeWaitData); - } -#else // SYNCHMGR_SUSPENSION_SAFE_CONDITION_SIGNALING - // Signal the target thread's condition - palErr = SignalThreadCondition(ptnwdNativeWaitData); -#endif // SYNCHMGR_SUSPENSION_SAFE_CONDITION_SIGNALING - - return palErr; - } - -#if SYNCHMGR_SUSPENSION_SAFE_CONDITION_SIGNALING - /*++ - Method: - CPalSynchronizationManager::DeferThreadConditionSignaling - - Defers thread signaling to the final release of synchronization - lock(s), so that condition signaling can happen when the signaling - thread is marked as safe for thread suspension. - --*/ - PAL_ERROR CPalSynchronizationManager::DeferThreadConditionSignaling( - CPalThread * pthrCurrent, - CPalThread * pthrTarget) - { - PAL_ERROR palErr = NO_ERROR; - LONG lCount = pthrCurrent->synchronizationInfo.m_lPendingSignalingCount; - - _ASSERTE(pthrTarget != pthrCurrent); - - if (CThreadSynchronizationInfo::PendingSignalingsArraySize > lCount) - { - // If there is available room, add the target thread object to - // the array of pending thread signalings. - pthrCurrent->synchronizationInfo.m_rgpthrPendingSignalings[lCount] = pthrTarget; - } - else - { - // If the array is full, add the target thread object at the end - // of the overflow list - DeferredSignalingListNode * pdsln = - InternalNew(); - - if (pdsln) - { - pdsln->pthrTarget = pthrTarget; - - // Add the note to the end of the list. - // Note: no need to synchronize the access to this list since - // it is meant to be accessed only by the owner thread. - InsertTailList(&pthrCurrent->synchronizationInfo.m_lePendingSignalingsOverflowList, - &pdsln->Link); - } - else - { - palErr = ERROR_NOT_ENOUGH_MEMORY; - } - } - - if (NO_ERROR == palErr) - { - // Increment the count of pending signalings - pthrCurrent->synchronizationInfo.m_lPendingSignalingCount += 1; - - // Add a reference to the target CPalThread object; this is - // needed since deferring signaling after releasing the synch - // locks implies accessing the target thread object without - // holding the local synch lock. In rare circumstances, the - // target thread may have already exited while deferred signaling - // takes place, therefore invalidating the thread object. The - // reference added here ensures that the thread object is still - // good, even if the target thread has exited. - pthrTarget->AddThreadReference(); - } - - return palErr; - } -#endif // SYNCHMGR_SUSPENSION_SAFE_CONDITION_SIGNALING - - /*++ - Method: - CPalSynchronizationManager::SignalThreadCondition - - Performs the actual condition signaling in to wake up the target thread - --*/ - PAL_ERROR CPalSynchronizationManager::SignalThreadCondition( - ThreadNativeWaitData * ptnwdNativeWaitData) - { - PAL_ERROR palErr = NO_ERROR; - int iRet; - - // Lock the mutex - iRet = pthread_mutex_lock(&ptnwdNativeWaitData->mutex); - if (0 != iRet) - { - ERROR("Cannot lock mutex [err=%d]\n", iRet); - return ERROR_INTERNAL_ERROR; - } - - // Set the predicate - ptnwdNativeWaitData->iPred = TRUE; - - // Signal the condition - iRet = pthread_cond_signal(&ptnwdNativeWaitData->cond); - if (0 != iRet) - { - ERROR("Failed to signal condition: pthread_cond_signal " - "returned %d [errno=%d (%s)]\n", iRet, errno, - strerror(errno)); - palErr = ERROR_INTERNAL_ERROR; - // Continue in order to unlock the mutex anyway - } - - // Unlock the mutex - iRet = pthread_mutex_unlock(&ptnwdNativeWaitData->mutex); - if (0 != iRet) - { - ERROR("Cannot unlock mutex [err=%d]\n", iRet); - return ERROR_INTERNAL_ERROR; - } - - return palErr; - } - - /*++ - Method: - CPalSynchronizationManager::ReadBytesFromProcessPipe - - Wakes up a remote thead currently sleeping for a wait or a sleep - by sending the appropriate cmd to the remote process' worker - thread, which will take care to convert this command into a - WakeUpLocalThread in the remote process - --*/ - PAL_ERROR CPalSynchronizationManager::WakeUpRemoteThread( - SharedID shridWLNode) - { - const int MsgSize = sizeof(BYTE) + sizeof(SharedID); - PAL_ERROR palErr = NO_ERROR; - BYTE rgSendBuf[MsgSize]; - BYTE * pbySrc, * pbyDst = rgSendBuf; - WaitingThreadsListNode * pWLNode = SharedIDToTypePointer(WaitingThreadsListNode, shridWLNode); - - _ASSERT_MSG(gPID != pWLNode->dwProcessId, "WakeUpRemoteThread called on local thread\n"); - _ASSERT_MSG(NULL != shridWLNode, "NULL shared identifier\n"); - _ASSERT_MSG(NULL != pWLNode, "Bad shared wait list node identifier (%p)\n", (VOID*)shridWLNode); - _ASSERT_MSG(MsgSize <= PIPE_BUF, "Message too long [MsgSize=%d PIPE_BUF=%d]\n", MsgSize, (int)PIPE_BUF); - - TRACE("Waking up remote thread {pid=%x, tid=%x} by sending cmd=%u and shridWLNode=%p over process pipe\n", - pWLNode->dwProcessId, pWLNode->dwThreadId, SynchWorkerCmdRemoteSignal, (VOID *)shridWLNode); - - // Prepare the message - // Cmd - *pbyDst++ = (BYTE)(SynchWorkerCmdRemoteSignal & 0xFF); - - // WaitingThreadsListNode (not aligned, copy byte by byte) - pbySrc = (BYTE *)&shridWLNode; - for (int i = 0; i < (int)sizeof(SharedID); i++) - { - *pbyDst++ = *pbySrc++; - } - - _ASSERT_MSG(pbyDst <= rgSendBuf + MsgSize + 1, "Buffer overrun"); - - // Send the message - palErr = SendMsgToRemoteWorker(pWLNode->dwProcessId, rgSendBuf, MsgSize); - if (NO_ERROR != palErr) - { - ERROR("Failed sending message to remote worker in process %u\n", pWLNode->dwProcessId); - } - - return palErr; - } - - /*++ - Method: - CPalSynchronizationManager::DelegateSignalingToRemoteProcess - - This method transfers an object signaling operation to a remote process, - where it will be performed by the worker thread. Such delegation takes - place when the currently processed thread (among those waiting on the - signald object) lives in a different process as the signaling thread, - and it is performing a wait all. In this case generally is not possible - to find out whether or not the wait all is satisfied, therefore the - signaling operation must be continued in the target process. - --*/ - PAL_ERROR CPalSynchronizationManager::DelegateSignalingToRemoteProcess( - CPalThread * pthrCurrent, - DWORD dwTargetProcessId, - SharedID shridSynchData) - { - const int MsgSize = sizeof(BYTE) + sizeof(SharedID) + sizeof(DWORD); - int i; - PAL_ERROR palErr = NO_ERROR; - BYTE rgSendBuf[MsgSize]; - BYTE * pbySrc, * pbyDst = rgSendBuf; - DWORD dwSigCount; - CSynchData * psdSynchData = - SharedIDToTypePointer(CSynchData, shridSynchData); - - _ASSERT_MSG(gPID != dwTargetProcessId, " called on local thread\n"); - _ASSERT_MSG(NULL != shridSynchData, "NULL shared identifier\n"); - _ASSERT_MSG(NULL != psdSynchData, "Bad shared SynchData identifier (%p)\n", (VOID*)shridSynchData); - _ASSERT_MSG(MsgSize <= PIPE_BUF, "Message too long [MsgSize=%d PIPE_BUF=%d]\n", MsgSize, (int)PIPE_BUF); - - TRACE("Transfering wait all signaling to remote process pid=%x by sending cmd=%u and shridSynchData=%p over process pipe\n", - dwTargetProcessId, SynchWorkerCmdDelegatedObjectSignaling, (VOID *)shridSynchData); - - dwSigCount = psdSynchData->GetSignalCount(); - - // AddRef SynchData to be marshaled to remote process - psdSynchData->AddRef(); - - // - // Prepare the message - // - - // Cmd - *pbyDst++ = (BYTE)(SynchWorkerCmdDelegatedObjectSignaling & 0xFF); - - // CSynchData (not aligned, copy byte by byte) - pbySrc = (BYTE *)&shridSynchData; - for (i=0; i<(int)sizeof(SharedID); i++) - { - *pbyDst++ = *pbySrc++; - } - - // Signal Count (not aligned, copy byte by byte) - pbySrc = (BYTE *)&dwSigCount; - for (i=0; i<(int)sizeof(DWORD); i++) - { - *pbyDst++ = *pbySrc++; - } - - _ASSERT_MSG(pbyDst <= rgSendBuf + MsgSize + 1, "Buffer overrun"); - - // Send the message - palErr = SendMsgToRemoteWorker(dwTargetProcessId, rgSendBuf, MsgSize); - if (NO_ERROR != palErr) - { - TRACE("Failed sending message to remote worker in process %u\n", dwTargetProcessId); - - // Undo refcounting - psdSynchData->Release(pthrCurrent); - } - - return palErr; - } - - /*++ - Method: - CPalSynchronizationManager::SendMsgToRemoteWorker - - Sends a message (command + data) to a remote process's worker thread. - --*/ - PAL_ERROR CPalSynchronizationManager::SendMsgToRemoteWorker( - DWORD dwProcessId, - BYTE * pMsg, - int iMsgSize) - { -#ifndef CORECLR - PAL_ERROR palErr = NO_ERROR; - int iProcessPipe, iBytesToWrite, iRetryCount; - ssize_t sszRet; - char strPipeFilename[MAX_PATH]; - BYTE * pPos = pMsg; - bool fRet; - CPalThread *pthrCurrent = InternalGetCurrentThread(); - - _ASSERT_MSG(gPID != dwProcessId, "SendMsgToRemoteWorker called with local process as target process\n"); - - fRet = GetProcessPipeName(strPipeFilename, MAX_PATH, dwProcessId); - - _ASSERT_MSG(fRet, "Failed to retrieve process pipe's name!\n"); - - iProcessPipe = InternalOpen(strPipeFilename, O_WRONLY); - if (-1 == iProcessPipe) - { - ERROR("Unable to open a process pipe to wake up a remote thread " - "[pid=%u errno=%d (%s) PipeFilename=%s]\n", dwProcessId, - errno, strerror(errno), strPipeFilename); - palErr = ERROR_INTERNAL_ERROR; - goto SMTRW_exit; - } - - pPos = pMsg; - iBytesToWrite = iMsgSize; - while (0 < iBytesToWrite) - { - iRetryCount = 0; - do - { - sszRet = write(iProcessPipe, pPos, iBytesToWrite); - } while (-1 == sszRet && - EAGAIN == errno && - ++iRetryCount < MaxConsecutiveEagains && - 0 == sched_yield()); - - if (0 >= sszRet) - { - ERROR("Error writing message to process pipe %d [target_pid=%u " - "bytes_to_write=%d bytes_written=%d ret=%d errno=%d (%s) " - "PipeFilename=%s]\n", iProcessPipe, dwProcessId, iMsgSize, - iMsgSize - iBytesToWrite, (int)sszRet, errno, strerror(errno), - strPipeFilename); - palErr = ERROR_INTERNAL_ERROR; - break; - } - iBytesToWrite -= (int)sszRet; - pPos += sszRet; - - _ASSERT_MSG(0 == iBytesToWrite, - "Interleaved messages while writing to process pipe %d\n", - iProcessPipe); - } - - // Close the opened pipe - close(iProcessPipe); - - SMTRW_exit: - return palErr; -#else // !CORECLR - ASSERT("There should never be a reason to send a message to a remote worker\n"); - return ERROR_INTERNAL_ERROR; -#endif // !CORECLR - } - - /*++ - Method: - CPalSynchronizationManager::WakeUpLocalWorkerThread - - Wakes up the local worker thread by writing a 'nop' cmd to the - process pipe. - --*/ - PAL_ERROR CPalSynchronizationManager::WakeUpLocalWorkerThread( - SynchWorkerCmd swcWorkerCmd) - { - PAL_ERROR palErr = NO_ERROR; - - _ASSERT_MSG((swcWorkerCmd & 0xFF) == swcWorkerCmd, - "Value too big for swcWorkerCmd\n"); - - _ASSERT_MSG((SynchWorkerCmdNop == swcWorkerCmd) || - (SynchWorkerCmdShutdown == swcWorkerCmd) || - (SynchWorkerCmdTerminationRequest == swcWorkerCmd), - "WakeUpLocalWorkerThread supports only SynchWorkerCmdNop, SynchWorkerCmdShutdown, and SynchWorkerCmdTerminationRequest." - "[received cmd=%d]\n", swcWorkerCmd); - - BYTE byCmd = (BYTE)(swcWorkerCmd & 0xFF); - - TRACE("Waking up Synch Worker Thread for %u [byCmd=%u]\n", - swcWorkerCmd, (unsigned int)byCmd); - - // As long as we use pipes and we keep the message size - // within PIPE_BUF, there's no need to lock here, since the - // write is guaranteed not to be interleaved with/into other - // writes of PIPE_BUF bytes or less. - _ASSERT_MSG(sizeof(BYTE) <= PIPE_BUF, "Message too long\n"); - - int iRetryCount = 0; - ssize_t sszWritten; - do - { - sszWritten = write(m_iProcessPipeWrite, &byCmd, sizeof(BYTE)); - } while (-1 == sszWritten && - EAGAIN == errno && - ++iRetryCount < MaxConsecutiveEagains && - 0 == sched_yield()); - - if (sszWritten != sizeof(BYTE)) - { - ERROR("Unable to write to the process pipe to wake up the " - "worker thread [errno=%d (%s)]\n", errno, strerror(errno)); - palErr = ERROR_INTERNAL_ERROR; - } - - return palErr; - } - - /*++ - Method: - CPalSynchronizationManager::GetThreadWaitInfo - - Returns a pointer to the WaitInfo structure for the passed CPalThread object - --*/ - ThreadWaitInfo * CPalSynchronizationManager::GetThreadWaitInfo( - CPalThread * pthrCurrent) - { - return &pthrCurrent->synchronizationInfo.m_twiWaitInfo; - } - - /*++ - Method: - CPalSynchronizationManager::UnRegisterWait - - Unregister the wait described by ptwiWaitInfo that in general involves - a thread other than the current one (most of the times the deregistration - is performed by the signaling thread) - - Note: this method must be called while holding the local process - synchronization lock. - --*/ - void CPalSynchronizationManager::UnRegisterWait( - CPalThread * pthrCurrent, - ThreadWaitInfo * ptwiWaitInfo, - bool fHaveSharedLock) - { - int i = 0; - CSynchData * psdSynchData = NULL; - bool fSharedSynchLock = false; - - if (!fHaveSharedLock && LocalWait != ptwiWaitInfo->wdWaitDomain) - { - AcquireSharedSynchLock(pthrCurrent); - fSharedSynchLock = true; - } - - TRACE("Unregistering wait for thread=%u [ObjCount=%d WaitType=%u WaitDomain=%u]\n", - ptwiWaitInfo->pthrOwner->GetThreadId(), - ptwiWaitInfo->lObjCount, ptwiWaitInfo->wtWaitType, - ptwiWaitInfo->wdWaitDomain); - - for (i=0; i < ptwiWaitInfo->lObjCount; i++) - { - WaitingThreadsListNode * pwtlnItem = ptwiWaitInfo->rgpWTLNodes[i]; - - VALIDATEOBJECT(pwtlnItem); - - if (pwtlnItem->dwFlags & WTLN_FLAG_OWNER_OBJECT_IS_SHARED) - { - // Shared object - WaitingThreadsListNode * pwtlnItemNext, * pwtlnItemPrev; - - psdSynchData = SharedIDToTypePointer(CSynchData, - pwtlnItem->ptrOwnerObjSynchData.shrid); - - VALIDATEOBJECT(psdSynchData); - - pwtlnItemNext = SharedIDToTypePointer(WaitingThreadsListNode, - pwtlnItem->ptrNext.shrid); - pwtlnItemPrev = SharedIDToTypePointer(WaitingThreadsListNode, - pwtlnItem->ptrPrev.shrid); - if (pwtlnItemPrev) - { - VALIDATEOBJECT(pwtlnItemPrev); - pwtlnItemPrev->ptrNext.shrid = pwtlnItem->ptrNext.shrid; - } - else - { - psdSynchData->SetWTLHeadShrPtr(pwtlnItem->ptrNext.shrid); - } - - if (pwtlnItemNext) - { - VALIDATEOBJECT(pwtlnItemNext); - pwtlnItemNext->ptrPrev.shrid = pwtlnItem->ptrPrev.shrid; - } - else - { - psdSynchData->SetWTLTailShrPtr(pwtlnItem->ptrPrev.shrid); - } - - m_cacheSHRWTListNodes.Add(pthrCurrent, pwtlnItem->shridSHRThis); - } - else - { - // Local object - psdSynchData = pwtlnItem->ptrOwnerObjSynchData.ptr; - - VALIDATEOBJECT(psdSynchData); - - if (pwtlnItem->ptrPrev.ptr) - { - VALIDATEOBJECT(pwtlnItem); - pwtlnItem->ptrPrev.ptr->ptrNext.ptr = pwtlnItem->ptrNext.ptr; - } - else - { - psdSynchData->SetWTLHeadPtr(pwtlnItem->ptrNext.ptr); - } - - if (pwtlnItem->ptrNext.ptr) - { - VALIDATEOBJECT(pwtlnItem); - pwtlnItem->ptrNext.ptr->ptrPrev.ptr = pwtlnItem->ptrPrev.ptr; - } - else - { - psdSynchData->SetWTLTailPtr(pwtlnItem->ptrPrev.ptr); - } - - m_cacheWTListNodes.Add(pthrCurrent, pwtlnItem); - } - - // Release the node's refcount on the synch data, and decerement - // waiting thread count - psdSynchData->DecrementWaitingThreadCount(); - psdSynchData->Release(pthrCurrent); - } - - // Reset wait data in ThreadWaitInfo structure: it is enough - // to reset lObjCount, lSharedObjCount and wdWaitDomain. - ptwiWaitInfo->lObjCount = 0; - ptwiWaitInfo->lSharedObjCount = 0; - ptwiWaitInfo->wdWaitDomain = LocalWait; - - // Done - if (fSharedSynchLock) - { - ReleaseSharedSynchLock(pthrCurrent); - } - - return; - } - - /*++ - Method: - CPalSynchronizationManager::UnsignalRestOfLocalAwakeningWaitAll - - Unsignals all the objects involved in a wait all, except the target - one (i.e. psdTgtObjectSynchData) - - Note: this method must be called while holding the synchronization locks - appropriate to all the objects involved in the wait-all. If any - of the objects is shared, the caller must own both local and - shared synch locks; if no shared object is involved in the wait, - only the local synch lock is needed. - --*/ - void CPalSynchronizationManager::UnsignalRestOfLocalAwakeningWaitAll( - CPalThread * pthrCurrent, - CPalThread * pthrTarget, - WaitingThreadsListNode * pwtlnNode, - CSynchData * psdTgtObjectSynchData) - { - PAL_ERROR palErr = NO_ERROR; - CSynchData * psdSynchDataItem = NULL; - -#ifdef _DEBUG - bool bOriginatingNodeFound = false; -#endif - - VALIDATEOBJECT(psdTgtObjectSynchData); - VALIDATEOBJECT(pwtlnNode); - - _ASSERT_MSG(0 != (WTLN_FLAG_WAIT_ALL & pwtlnNode->dwFlags), - "UnsignalRestOfLocalAwakeningWaitAll() called on a normal (non wait all) wait"); - - _ASSERT_MSG(gPID == pwtlnNode->dwProcessId, - "UnsignalRestOfLocalAwakeningWaitAll() called on a wait all with remote awakening"); - - ThreadWaitInfo *ptwiWaitInfo = pwtlnNode->ptwiWaitInfo; - - int iObjCount = ptwiWaitInfo->lObjCount; - for (int i = 0; i < iObjCount; i++) - { - WaitingThreadsListNode * pwtlnItem = ptwiWaitInfo->rgpWTLNodes[i]; - - VALIDATEOBJECT(pwtlnItem); - - if (0 != (WTLN_FLAG_OWNER_OBJECT_IS_SHARED & pwtlnItem->dwFlags)) - { - psdSynchDataItem = SharedIDToTypePointer(CSynchData, pwtlnItem->ptrOwnerObjSynchData.shrid); - } - else - { - psdSynchDataItem = pwtlnItem->ptrOwnerObjSynchData.ptr; - } - - VALIDATEOBJECT(psdSynchDataItem); - - // Skip originating node - if (psdTgtObjectSynchData == psdSynchDataItem) - { -#ifdef _DEBUG - bOriginatingNodeFound = true; -#endif - continue; - } - - palErr = psdSynchDataItem->ReleaseWaiterWithoutBlocking(pthrCurrent, pthrTarget); - if (NO_ERROR != palErr) - { - ERROR("ReleaseWaiterWithoutBlocking failed on SynchData @ %p [palErr = %u]\n", psdSynchDataItem, palErr); - } - } - - _ASSERT_MSG(bOriginatingNodeFound, "Couldn't find originating node while unsignaling rest of the wait all\n"); - } - - /*++ - Method: - CPalSynchronizationManager::MarkWaitForDelegatedObjectSignalingInProgress - - Marks all the thread waiting list nodes involved in the the current wait-all - for "delegated object signaling in progress", so that this wait cannot be - involved in another delegated object signaling that may happen while the - current object singaling is being tranfered to the target process (while - transfering it, synchronization locks are released in this process and later - grabbed again in the target process; in this time window another thread - could signal another object part of the same wait-all. In this case no - signal delegation must take place. - - Note: this method must be called while holding the synchronization locks - appropriate to the target object described by pwtlnNode (i.e. the - local process synch lock if the target object is local, both local - and shared one if the object is shared). - --*/ - void CPalSynchronizationManager::MarkWaitForDelegatedObjectSignalingInProgress( - CPalThread * pthrCurrent, - WaitingThreadsListNode * pwtlnNode) - { - bool fSharedSynchLock = false; - bool fTargetObjectIsShared = (0 != (WTLN_FLAG_OWNER_OBJECT_IS_SHARED & pwtlnNode->dwFlags)); - - VALIDATEOBJECT(pwtlnNode); - - _ASSERT_MSG(gPID == pwtlnNode->dwProcessId, - "MarkWaitForDelegatedObjectSignalingInProgress() called from the wrong process"); - - ThreadWaitInfo *ptwiWaitInfo = pwtlnNode->ptwiWaitInfo; - - if (!fSharedSynchLock && !fTargetObjectIsShared && - LocalWait != ptwiWaitInfo->wdWaitDomain) - { - AcquireSharedSynchLock(pthrCurrent); - fSharedSynchLock = true; - } - - _ASSERT_MSG(MultipleObjectsWaitAll == ptwiWaitInfo->wtWaitType, - "MarkWaitForDelegatedObjectSignalingInProgress() called on a normal (non wait-all) wait"); - - // Unmark all nodes other than the target one - int iTgtCount = ptwiWaitInfo->lObjCount; - for (int i = 0; i < iTgtCount; i++) - { - VALIDATEOBJECT(ptwiWaitInfo->rgpWTLNodes[i]); - ptwiWaitInfo->rgpWTLNodes[i]->dwFlags &= ~WTLN_FLAG_DELEGATED_OBJECT_SIGNALING_IN_PROGRESS; - } - - // Mark the target node - pwtlnNode->dwFlags |= WTLN_FLAG_DELEGATED_OBJECT_SIGNALING_IN_PROGRESS; - - // Done - if (fSharedSynchLock) - { - ReleaseSharedSynchLock(pthrCurrent); - } - - return; - } - - /*++ - Method: - CPalSynchronizationManager::UnmarkTWListForDelegatedObjectSignalingInProgress - - Resets the "delegated object signaling in progress" flags in all the - nodes of the thread waitin list for the target waitable objects (represented - by its SynchData) - - Note: this method must be called while holding the appropriate - synchronization locks (the local process synch lock if the target - object is local, both local and shared one if the object is shared). - --*/ - void CPalSynchronizationManager::UnmarkTWListForDelegatedObjectSignalingInProgress( - CSynchData * pTgtObjectSynchData) - { - bool fSharedObject = (SharedObject == pTgtObjectSynchData->GetObjectDomain()); - WaitingThreadsListNode * pwtlnNode; - - VALIDATEOBJECT(pTgtObjectSynchData); - - pwtlnNode = fSharedObject ? SharedIDToTypePointer(WaitingThreadsListNode, pTgtObjectSynchData->GetWTLHeadShmPtr()) - : pTgtObjectSynchData->GetWTLHeadPtr(); - - while (pwtlnNode) - { - VALIDATEOBJECT(pwtlnNode); - - pwtlnNode->dwFlags &= ~WTLN_FLAG_DELEGATED_OBJECT_SIGNALING_IN_PROGRESS; - pwtlnNode = fSharedObject ? SharedIDToTypePointer(WaitingThreadsListNode, pwtlnNode->ptrNext.shrid) - : pwtlnNode->ptrNext.ptr; - } - } - - /*++ - Method: - CPalSynchronizationManager::RegisterProcessForMonitoring - - Registers the process object represented by the passed psdSynchData and - pProcLocalData. The worker thread will monitor the actual process and, - upon process termination, it will set the exit code in pProcLocalData, - and it will signal the process object, by signaling its psdSynchData. - --*/ - PAL_ERROR CPalSynchronizationManager::RegisterProcessForMonitoring( - CPalThread * pthrCurrent, - CSynchData *psdSynchData, - IPalObject *pProcessObject, - CProcProcessLocalData * pProcLocalData) - { - PAL_ERROR palErr = NO_ERROR; - MonitoredProcessesListNode * pmpln; - bool fWakeUpWorker = false; - bool fMonitoredProcessesLock = false; - - VALIDATEOBJECT(psdSynchData); - - InternalEnterCriticalSection(pthrCurrent, &s_csMonitoredProcessesLock); - - fMonitoredProcessesLock = true; - - pmpln = m_pmplnMonitoredProcesses; - while (pmpln) - { - if (psdSynchData == pmpln->psdSynchData) - { - _ASSERT_MSG(pmpln->dwPid == pProcLocalData->dwProcessId, "Invalid node in Monitored Processes List\n"); - break; - } - - pmpln = pmpln->pNext; - } - - if (pmpln) - { - pmpln->lRefCount++; - } - else - { - pmpln = InternalNew(); - if (NULL == pmpln) - { - ERROR("No memory to allocate MonitoredProcessesListNode structure\n"); - palErr = ERROR_NOT_ENOUGH_MEMORY; - goto RPFM_exit; - } - - pmpln->lRefCount = 1; - pmpln->dwPid = pProcLocalData->dwProcessId; - pmpln->dwExitCode = 0; - pmpln->pProcessObject = pProcessObject; - pmpln->pProcessObject->AddReference(); - pmpln->pProcLocalData = pProcLocalData; - - // Acquire SynchData and AddRef it - pmpln->psdSynchData = psdSynchData; - psdSynchData->AddRef(); - - pmpln->pNext = m_pmplnMonitoredProcesses; - m_pmplnMonitoredProcesses = pmpln; - m_lMonitoredProcessesCount++; - - fWakeUpWorker = true; - } - - // Unlock - InternalLeaveCriticalSection(pthrCurrent, &s_csMonitoredProcessesLock); - fMonitoredProcessesLock = false; - - if (fWakeUpWorker) - { - CPalSynchronizationManager * pSynchManager = GetInstance(); - - palErr = pSynchManager->WakeUpLocalWorkerThread(SynchWorkerCmdNop); - if (NO_ERROR != palErr) - { - ERROR("Failed waking up worker thread for process " - "monitoring registration [errno=%d {%s%}]\n", - errno, strerror(errno)); - palErr = ERROR_INTERNAL_ERROR; - } - } - - RPFM_exit: - if (fMonitoredProcessesLock) - { - InternalLeaveCriticalSection(pthrCurrent, - &s_csMonitoredProcessesLock); - } - - return palErr; - } - - /*++ - Method: - CPalSynchronizationManager::UnRegisterProcessForMonitoring - - Unregisters a process object currently monitored by the worker thread - (typically called if the wait timed out before the process exited, or - if the wait was a normal (i.e. non wait-all) wait that involved othter - objects, and another object has been signaled). - --*/ - PAL_ERROR CPalSynchronizationManager::UnRegisterProcessForMonitoring( - CPalThread * pthrCurrent, - CSynchData *psdSynchData, - DWORD dwPid) - { - PAL_ERROR palErr = NO_ERROR; - MonitoredProcessesListNode * pmpln, * pmplnPrev = NULL; - - VALIDATEOBJECT(psdSynchData); - - InternalEnterCriticalSection(pthrCurrent, &s_csMonitoredProcessesLock); - - pmpln = m_pmplnMonitoredProcesses; - while (pmpln) - { - if (psdSynchData == pmpln->psdSynchData) - { - _ASSERT_MSG(dwPid == pmpln->dwPid, "Invalid node in Monitored Processes List\n"); - break; - } - - pmplnPrev = pmpln; - pmpln = pmpln->pNext; - } - - if (pmpln) - { - if (0 == --pmpln->lRefCount) - { - if (NULL != pmplnPrev) - { - pmplnPrev->pNext = pmpln->pNext; - } - else - { - m_pmplnMonitoredProcesses = pmpln->pNext; - } - - m_lMonitoredProcessesCount--; - pmpln->pProcessObject->ReleaseReference(pthrCurrent); - pmpln->psdSynchData->Release(pthrCurrent); - InternalDelete(pmpln); - } - } - else - { - palErr = ERROR_NOT_FOUND; - } - - InternalLeaveCriticalSection(pthrCurrent, &s_csMonitoredProcessesLock); - return palErr; - } - - /*++ - Method: - CPalSynchronizationManager::ThreadPrepareForShutdown - - Used to hijack thread execution from known spots within the - Synchronization Manager in case a PAL shutdown is initiated - or the thread is being terminated by another thread. - --*/ - void CPalSynchronizationManager::ThreadPrepareForShutdown() - { - TRACE("The Synchronization Manager hijacked the current thread " - "for process shutdown or thread termination\n"); - while (true) - { - poll(NULL, 0, INFTIM); - sched_yield(); - } - - ASSERT("This code should never be executed\n"); - } - - /*++ - Method: - CPalSynchronizationManager::DoMonitorProcesses - - This method is called by the worker thread to execute one step of - monitoring for all the process currently registered for monitoring - --*/ - LONG CPalSynchronizationManager::DoMonitorProcesses( - CPalThread * pthrCurrent) - { - MonitoredProcessesListNode * pNode, * pPrev = NULL, * pNext; - LONG lInitialNodeCount; - LONG lRemovingCount = 0; - bool fLocalSynchLock = false; - bool fSharedSynchLock = false; - bool fMonitoredProcessesLock = false; - - // Note: we first need to grab the monitored processes lock to walk - // the list of monitored processes, and then, if there is any - // which exited, to grab the synchronization lock(s) to signal - // the process object. Anyway we cannot grab the synchronization - // lock(s) while holding the monitored processes lock; that - // would cause deadlock, since RegisterProcessForMonitoring and - // UnRegisterProcessForMonitoring call stacks grab the locks - // in the opposite order. Grabbing the synch lock(s) first (and - // therefore all the times) would cause unacceptable contention - // (process monitoring is done in polling mode). - // Therefore we need to remove list nodes for processes that - // exited copying them to the exited array, while holding only - // the monitored processes lock, and then to signal them from that - // array holding synch lock(s) and monitored processes lock, - // acquired in this order. Holding again the monitored processes - // lock is needed in order to support object promotion. - - // Grab the monitored processes lock - InternalEnterCriticalSection(pthrCurrent, &s_csMonitoredProcessesLock); - fMonitoredProcessesLock = true; - - lInitialNodeCount = m_lMonitoredProcessesCount; - - pNode = m_pmplnMonitoredProcesses; - while (pNode) - { - pNext = pNode->pNext; - - if (HasProcessExited(pNode->dwPid, - &pNode->dwExitCode, - &pNode->fIsActualExitCode)) - { - TRACE("Process %u exited with return code %u\n", - pNode->dwPid, - pNode->fIsActualExitCode ? "actual" : "guessed", - pNode->dwExitCode); - - if (NULL != pPrev) - { - pPrev->pNext = pNext; - } - else - { - m_pmplnMonitoredProcesses = pNext; - } - - m_lMonitoredProcessesCount--; - - // Insert in the list of nodes for exited processes - pNode->pNext = m_pmplnExitedNodes; - m_pmplnExitedNodes = pNode; - lRemovingCount++; - } - else - { - pPrev = pNode; - } - - // Go to the next - pNode = pNext; - } - - // Release the monitored processes lock - InternalLeaveCriticalSection(pthrCurrent, &s_csMonitoredProcessesLock); - fMonitoredProcessesLock = false; - - if (lRemovingCount > 0) - { - // First grab the local synch lock - AcquireLocalSynchLock(pthrCurrent); - fLocalSynchLock = true; - - // Acquire the monitored processes lock - InternalEnterCriticalSection(pthrCurrent, &s_csMonitoredProcessesLock); - fMonitoredProcessesLock = true; - - if (!fSharedSynchLock) - { - bool fSharedSynchLockIsNeeded = false; - - // See if the shared lock is needed - pNode = m_pmplnExitedNodes; - while (pNode) - { - if (SharedObject == pNode->psdSynchData->GetObjectDomain()) - { - fSharedSynchLockIsNeeded = true; - break; - } - - pNode = pNode->pNext; - } - - if (fSharedSynchLockIsNeeded) - { - // Release the monitored processes lock - InternalLeaveCriticalSection(pthrCurrent, - &s_csMonitoredProcessesLock); - fMonitoredProcessesLock = false; - - // Acquire the shared synch lock - AcquireSharedSynchLock(pthrCurrent); - fSharedSynchLock = true; - - // Acquire again the monitored processes lock - InternalEnterCriticalSection(pthrCurrent, - &s_csMonitoredProcessesLock); - fMonitoredProcessesLock = true; - } - } - - // Start from the beginning of the exited processes list - pNode = m_pmplnExitedNodes; - - // Invalidate the list - m_pmplnExitedNodes = NULL; - - while (pNode) - { - pNext = pNode->pNext; - - TRACE("Process pid=%u exited with exitcode=%u\n", - pNode->dwPid, pNode->dwExitCode); - - // Store the exit code in the process local data - if (pNode->fIsActualExitCode) - { - pNode->pProcLocalData->dwExitCode = pNode->dwExitCode; - } - - // Set process status to PS_DONE - pNode->pProcLocalData->ps = PS_DONE; - - // Set signal count - pNode->psdSynchData->SetSignalCount(1); - - // Releasing all local waiters - // - // We just called directly in CSynchData::SetSignalCount(), so - // we need to take care of waking up waiting threads according - // to the Process object semantics (i.e. every thread must be - // awakend). Anyway if a process object is shared among two or - // more processes and threads from different processes are - // waiting on it, the object will be registered for monitoring - // in each of the processes. As result its signal count will - // be set to one more times (which is not a problem, given the - // process object semantics) and each worker thread will wake - // up waiting threads. Therefore we need to make sure that each - // worker wakes up only threads in its own process: we do that - // by calling ReleaseAllLocalWaiters - pNode->psdSynchData->ReleaseAllLocalWaiters(pthrCurrent); - - // We are done with pProcLocalData, so we can release the process object - pNode->pProcessObject->ReleaseReference(pthrCurrent); - - // Release the reference to the SynchData - pNode->psdSynchData->Release(pthrCurrent); - - // Delete the node - InternalDelete(pNode); - - // Go to the next - pNode = pNext; - } - } - - if (fMonitoredProcessesLock) - { - InternalLeaveCriticalSection(pthrCurrent, &s_csMonitoredProcessesLock); - } - - if (fSharedSynchLock) - { - ReleaseSharedSynchLock(pthrCurrent); - } - - if (fLocalSynchLock) - { - ReleaseLocalSynchLock(pthrCurrent); - } - - return (lInitialNodeCount - lRemovingCount); - } - - /*++ - Method: - CPalSynchronizationManager::DiscardMonitoredProcesses - - This method is called at shutdown time to discard all the registration - for the processes currently monitored by the worker thread. - This method must be called at shutdown time, otherwise some shared memory - may be leaked at process shutdown. - --*/ - void CPalSynchronizationManager::DiscardMonitoredProcesses( - CPalThread * pthrCurrent) - { - MonitoredProcessesListNode * pNode; - - // Grab the monitored processes lock - InternalEnterCriticalSection(pthrCurrent, &s_csMonitoredProcessesLock); - - while (m_pmplnMonitoredProcesses) - { - pNode = m_pmplnMonitoredProcesses; - m_pmplnMonitoredProcesses = pNode->pNext; - pNode->pProcessObject->ReleaseReference(pthrCurrent); - pNode->psdSynchData->Release(pthrCurrent); - InternalDelete(pNode); - } - - // Release the monitored processes lock - InternalLeaveCriticalSection(pthrCurrent, &s_csMonitoredProcessesLock); - } - - /*++ - Method: - CPalSynchronizationManager::CreateProcessPipe - - Creates the process pipe for the current process - --*/ - bool CPalSynchronizationManager::CreateProcessPipe() - { - bool fRet = true; -#if HAVE_KQUEUE && !HAVE_BROKEN_FIFO_KEVENT - int iKq = -1; -#endif // HAVE_KQUEUE && !HAVE_BROKEN_FIFO_KEVENT - -#ifndef CORECLR - int iPipeRd = -1, iPipeWr = -1; - char szPipeFilename[MAX_PATH]; - - /* Create the blocking pipe */ - if (!GetProcessPipeName(szPipeFilename, MAX_PATH, gPID)) - { - ERROR("couldn't get process pipe's name\n"); - szPipeFilename[0] = 0; - fRet = false; - goto CPP_exit; - } - - /* create the pipe, with full access to the owner only */ - if (mkfifo(szPipeFilename, S_IRWXU) == -1) - { - if (errno == EEXIST) - { - /* Some how no one deleted the pipe, perhaps it was left behind - from a crash?? Delete the pipe and try again. */ - if (-1 == unlink(szPipeFilename)) - { - ERROR( "Unable to delete the process pipe that was left behind.\n" ); - fRet = false; - goto CPP_exit; - } - else - { - if (mkfifo(szPipeFilename, S_IRWXU) == -1) - { - ERROR( "Still unable to create the process pipe...giving up!\n" ); - fRet = false; - goto CPP_exit; - } - } - } - else - { - ERROR( "Unable to create the process pipe.\n" ); - fRet = false; - goto CPP_exit; - } - } - - iPipeRd = InternalOpen(szPipeFilename, O_RDONLY | O_NONBLOCK); - if (iPipeRd == -1) - { - ERROR("Unable to open the process pipe for read\n"); - fRet = false; - goto CPP_exit; - } - - iPipeWr = InternalOpen(szPipeFilename, O_WRONLY | O_NONBLOCK); - if (iPipeWr == -1) - { - ERROR("Unable to open the process pipe for write\n"); - fRet = false; - goto CPP_exit; - } -#else // !CORECLR - int rgiPipe[] = { -1, -1 }; - int pipeRv = -#if HAVE_PIPE2 - pipe2(rgiPipe, O_CLOEXEC); -#else - pipe(rgiPipe); -#endif // HAVE_PIPE2 - if (pipeRv == -1) - { - ERROR("Unable to create the process pipe\n"); - fRet = false; - goto CPP_exit; - } -#if !HAVE_PIPE2 - fcntl(rgiPipe[0], F_SETFD, FD_CLOEXEC); // make pipe non-inheritable, if possible - fcntl(rgiPipe[1], F_SETFD, FD_CLOEXEC); -#endif // !HAVE_PIPE2 -#endif // !CORECLR - -#if HAVE_KQUEUE && !HAVE_BROKEN_FIFO_KEVENT - iKq = kqueue(); - if (-1 == iKq) - { - ERROR("Failed to create kqueue associated to process pipe\n"); - fRet = false; - goto CPP_exit; - } -#endif // HAVE_KQUEUE - - CPP_exit: - if (fRet) - { - // Succeeded -#ifndef CORECLR - m_iProcessPipeRead = iPipeRd; - m_iProcessPipeWrite = iPipeWr; -#else // !CORECLR - m_iProcessPipeRead = rgiPipe[0]; - m_iProcessPipeWrite = rgiPipe[1]; -#endif // !CORECLR -#if HAVE_KQUEUE && !HAVE_BROKEN_FIFO_KEVENT - m_iKQueue = iKq; -#endif // HAVE_KQUEUE - } - else - { -#ifndef CORECLR - // Failed - if (0 != szPipeFilename[0]) - { - unlink(szPipeFilename); - } - if (-1 != iPipeRd) - { - close(iPipeRd); - } - if (-1 != iPipeWr) - { - close(iPipeWr); - } -#else // !CORECLR - if (-1 != rgiPipe[0]) - { - close(rgiPipe[0]); - close(rgiPipe[1]); - } -#endif // !CORECLR -#if HAVE_KQUEUE && !HAVE_BROKEN_FIFO_KEVENT - if (-1 != iKq) - { - close(iKq); - } -#endif // HAVE_KQUEUE - } - - return fRet; - } - - /*++ - Method: - CPalSynchronizationManager::ShutdownProcessPipe - - Shuts down the process pipe and removes the fifo so that other processes - can no longer open it. It also closes the local write end of the pipe (see - comment below). From this moment on the worker thread will process any - possible data already received in the pipe (but not yet consumed) and any - data written by processes that still have a opened write end of this pipe; - it will wait (with timeout) until the last remote process which has a write - end opened closes it, and then it will yield to process shutdown. - --*/ - PAL_ERROR CPalSynchronizationManager::ShutdownProcessPipe() - { - PAL_ERROR palErr = NO_ERROR; -#ifndef CORECLR - char szPipeFilename[MAX_PATH]; - - if (GetProcessPipeName(szPipeFilename, MAX_PATH, gPID)) - { - if (unlink(szPipeFilename) == -1) - { - ERROR("Unable to unlink the pipe file name errno=%d (%s)\n", - errno, strerror(errno)); - palErr = ERROR_INTERNAL_ERROR; - // go on anyway - } - } - else - { - ERROR("Couldn't get the process pipe's name\n"); - palErr = ERROR_INTERNAL_ERROR; - // go on anyway - } -#endif // CORECLR - - if (-1 != m_iProcessPipeWrite) - { - // Closing the write end of the process pipe. When the last process - // that still has a open write-fd on this pipe will close it, the - // worker thread will receive an EOF; the worker thread will wait - // for this EOF before shutting down, so to ensure to process any - // possible data already written to the pipe by other processes - // when the shutdown has been initiated in the current process. - // Note: no need here to worry about platforms where close(pipe) - // blocks on outstanding syscalls, since we are the only one using - // this fd. - TRACE("Closing the write end of process pipe\n"); - if (close(m_iProcessPipeWrite) == -1) - { - ERROR("Unable to close the write end of process pipe\n"); - palErr = ERROR_INTERNAL_ERROR; - } - - m_iProcessPipeWrite = -1; - } - - return palErr; - } - -#ifndef CORECLR - /*++ - Method: - CPalSynchronizationManager::GetProcessPipeName - - Returns the process pipe name for the target process (identified by its PID) - --*/ - bool CPalSynchronizationManager::GetProcessPipeName( - LPSTR pDest, - int iDestSize, - DWORD dwPid) - { - CHAR config_dir[MAX_PATH]; - int needed_size; - - _ASSERT_MSG(NULL != pDest, "Destination pointer is NULL!\n"); - _ASSERT_MSG(0 < iDestSize,"Invalid buffer size %d\n", iDestSize); - - if (!PALGetPalConfigDir(config_dir, MAX_PATH)) - { - ASSERT("Unable to determine the PAL config directory.\n"); - pDest[0] = '\0'; - return false; - } - needed_size = snprintf(pDest, iDestSize, "%s/%s-%u", config_dir, - PROCESS_PIPE_NAME_PREFIX, dwPid); - pDest[iDestSize-1] = 0; - if(needed_size >= iDestSize) - { - ERROR("threadpipe name needs %d characters, buffer only has room for " - "%d\n", needed_size, iDestSize+1); - return false; - } - return true; - } -#endif // !CORECLR - - /*++ - Method: - CPalSynchronizationManager::AcquireProcessLock - - Acquires the local Process Lock (which currently is the same as the - the local Process Synch Lock) - --*/ - void CPalSynchronizationManager::AcquireProcessLock(CPalThread * pthrCurrent) - { - AcquireLocalSynchLock(pthrCurrent); - } - - /*++ - Method: - CPalSynchronizationManager::ReleaseProcessLock - - Releases the local Process Lock (which currently is the same as the - the local Process Synch Lock) - --*/ - void CPalSynchronizationManager::ReleaseProcessLock(CPalThread * pthrCurrent) - { - ReleaseLocalSynchLock(pthrCurrent); - } - - /*++ - Method: - CPalSynchronizationManager::PromoteObjectSynchData - - Promotes an object's synchdata from local to shared - --*/ - PAL_ERROR CPalSynchronizationManager::PromoteObjectSynchData( - CPalThread *pthrCurrent, - VOID *pvLocalSynchData, - VOID **ppvSharedSynchData) - { - PAL_ERROR palError = NO_ERROR; - CSynchData *psdLocal = reinterpret_cast(pvLocalSynchData); - CSynchData *psdShared = NULL; - SharedID shridSynchData = NULL; - SharedID *rgshridWTLNodes = NULL; - CObjectType *pot = NULL; - ULONG ulcWaitingThreads; - - _ASSERTE(NULL != pthrCurrent); - _ASSERTE(NULL != pvLocalSynchData); - _ASSERTE(NULL != ppvSharedSynchData); - _ASSERTE(ProcessLocalObject == psdLocal->GetObjectDomain()); - -#if _DEBUG - - // - // TODO: Verify that the proper locks are held - // -#endif - - // - // Allocate shared memory CSynchData and map to local memory - // - - shridSynchData = m_cacheSHRSynchData.Get(pthrCurrent); - if (NULL == shridSynchData) - { - ERROR("Unable to allocate shared memory\n"); - palError = ERROR_NOT_ENOUGH_MEMORY; - goto POSD_exit; - } - - psdShared = SharedIDToTypePointer(CSynchData, shridSynchData); - _ASSERTE(NULL != psdShared); - - // - // Allocate shared memory WaitingThreadListNodes if there are - // any threads currently waiting on this object - // - - ulcWaitingThreads = psdLocal->GetWaitingThreadCount(); - if (0 < ulcWaitingThreads) - { - int i; - - rgshridWTLNodes = InternalNewArray(ulcWaitingThreads); - if (NULL == rgshridWTLNodes) - { - palError = ERROR_OUTOFMEMORY; - goto POSD_exit; - } - - i = m_cacheSHRWTListNodes.Get( - pthrCurrent, - ulcWaitingThreads, - rgshridWTLNodes - ); - - if (static_cast(i) != ulcWaitingThreads) - { - for (i -= 1; i >= 0; i -= 1) - { - m_cacheSHRWTListNodes.Add(pthrCurrent, rgshridWTLNodes[i]); - } - - palError = ERROR_OUTOFMEMORY; - goto POSD_exit; - } - } - - // - // If the synch data is for a process object we need to grab - // the monitored process list lock here - // - - pot = psdLocal->GetObjectType(); - _ASSERTE(NULL != pot); - - if (otiProcess == pot->GetId()) - { - InternalEnterCriticalSection(pthrCurrent, &s_csMonitoredProcessesLock); - } - - // - // Copy pertinent CSynchData info to the shared memory version (and - // initialize other members) - // - - psdShared->SetSharedThis(shridSynchData); - psdShared->SetObjectDomain(SharedObject); - psdShared->SetObjectType(psdLocal->GetObjectType()); - psdShared->SetSignalCount(psdLocal->GetSignalCount()); - -#ifdef SYNCH_STATISTICS - psdShared->SetStatContentionCount(psdLocal->GetStatContentionCount()); - psdShared->SetStatWaitCount(psdLocal->GetStatWaitCount()); -#endif - - // - // Rebuild the waiting thread list, and update the wait domain - // for the waiting threads - // - - psdShared->SetWTLHeadShrPtr(NULL); - psdShared->SetWTLTailShrPtr(NULL); - - if (0 < ulcWaitingThreads) - { - WaitingThreadsListNode *pwtlnOld; - WaitingThreadsListNode *pwtlnNew; - int i = 0; - - for (pwtlnOld = psdLocal->GetWTLHeadPtr(); - pwtlnOld != NULL; - pwtlnOld = pwtlnOld->ptrNext.ptr, i += 1) - { - pwtlnNew = SharedIDToTypePointer( - WaitingThreadsListNode, - rgshridWTLNodes[i] - ); - - _ASSERTE(NULL != pwtlnNew); - - pwtlnNew->shridSHRThis = rgshridWTLNodes[i]; - pwtlnNew->ptrOwnerObjSynchData.shrid = shridSynchData; - - pwtlnNew->dwThreadId = pwtlnOld->dwThreadId; - pwtlnNew->dwProcessId = pwtlnOld->dwProcessId; - pwtlnNew->dwObjIndex = pwtlnOld->dwObjIndex; - pwtlnNew->dwFlags = pwtlnOld->dwFlags | WTLN_FLAG_OWNER_OBJECT_IS_SHARED; - pwtlnNew->shridWaitingState = pwtlnOld->shridWaitingState; - pwtlnNew->ptwiWaitInfo = pwtlnOld->ptwiWaitInfo; - - psdShared->SharedWaiterEnqueue(rgshridWTLNodes[i], false); - psdShared->AddRef(); - - _ASSERTE(pwtlnOld = pwtlnOld->ptwiWaitInfo->rgpWTLNodes[pwtlnOld->dwObjIndex]); - pwtlnNew->ptwiWaitInfo->rgpWTLNodes[pwtlnNew->dwObjIndex] = pwtlnNew; - - pwtlnNew->ptwiWaitInfo->lSharedObjCount += 1; - if (pwtlnNew->ptwiWaitInfo->lSharedObjCount - == pwtlnNew->ptwiWaitInfo->lObjCount) - { - pwtlnNew->ptwiWaitInfo->wdWaitDomain = SharedWait; - } - else - { - _ASSERTE(pwtlnNew->ptwiWaitInfo->lSharedObjCount - < pwtlnNew->ptwiWaitInfo->lObjCount); - - pwtlnNew->ptwiWaitInfo->wdWaitDomain = MixedWait; - } - } - - _ASSERTE(psdShared->GetWaitingThreadCount() == ulcWaitingThreads); - } - - // - // If the object tracks ownership and has a current owner update - // the OwnedObjectsListNode to point to the shared memory synch - // data - // - - if (CObjectType::OwnershipTracked == pot->GetOwnershipSemantics()) - { - OwnedObjectsListNode *pooln; - - pooln = psdLocal->GetOwnershipListNode(); - if (NULL != pooln) - { - pooln->pPalObjSynchData = psdShared; - psdShared->SetOwnershipListNode(pooln); - psdShared->AddRef(); - - // - // Copy over other ownership info. - // - - psdShared->SetOwner(psdLocal->GetOwnerThread()); - psdShared->SetOwnershipCount(psdLocal->GetOwnershipCount()); - _ASSERTE(!psdShared->IsAbandoned()); - } - else - { - _ASSERTE(0 == psdLocal->GetOwnershipCount()); - _ASSERTE(0 == psdShared->GetOwnershipCount()); - psdShared->SetAbandoned(psdLocal->IsAbandoned()); - } - } - - // - // If the synch data is for a process object update the monitored - // process list nodes to point to the shared memory object data, - // and release the monitored process list lock - // - - if (otiProcess == pot->GetId()) - { - MonitoredProcessesListNode *pmpn; - - pmpn = m_pmplnMonitoredProcesses; - while (NULL != pmpn) - { - if (psdLocal == pmpn->psdSynchData) - { - pmpn->psdSynchData = psdShared; - psdShared->AddRef(); - } - - pmpn = pmpn->pNext; - } - - pmpn = m_pmplnExitedNodes; - while (NULL != pmpn) - { - if (psdLocal == pmpn->psdSynchData) - { - pmpn->psdSynchData = psdShared; - psdShared->AddRef(); - } - - pmpn = pmpn->pNext; - } - - InternalLeaveCriticalSection(pthrCurrent, &s_csMonitoredProcessesLock); - } - - *ppvSharedSynchData = reinterpret_cast(shridSynchData); - - // - // Free the local memory items to caches - // - - if (0 < ulcWaitingThreads) - { - WaitingThreadsListNode *pwtln; - - pwtln = psdLocal->GetWTLHeadPtr(); - while (NULL != pwtln) - { - WaitingThreadsListNode *pwtlnTemp; - - pwtlnTemp = pwtln; - pwtln = pwtln->ptrNext.ptr; - m_cacheWTListNodes.Add(pthrCurrent, pwtlnTemp); - } - } - - m_cacheSynchData.Add(pthrCurrent, psdLocal); - - POSD_exit: - - if (NULL != rgshridWTLNodes) - { - InternalDeleteArray(rgshridWTLNodes); - } - - return palError; - } - - - ///////////////////////////// - // // - // _ThreadNativeWaitData // - // // - ///////////////////////////// - - _ThreadNativeWaitData::~_ThreadNativeWaitData() - { - if (fInitialized) - { - fInitialized = false; - pthread_cond_destroy(&cond); - pthread_mutex_destroy(&mutex); - } - } - - - ////////////////////////////////// - // // - // CThreadSynchronizationInfo // - // // - ////////////////////////////////// - - CThreadSynchronizationInfo::CThreadSynchronizationInfo() : - m_tsThreadState(TS_IDLE), - m_shridWaitAwakened(NULL), - m_lLocalSynchLockCount(0), - m_lSharedSynchLockCount(0), - m_ownedNamedMutexListHead(nullptr) - { - InitializeListHead(&m_leOwnedObjsList); - InitializeCriticalSection(&m_ownedNamedMutexListLock); - -#ifdef SYNCHMGR_SUSPENSION_SAFE_CONDITION_SIGNALING - m_lPendingSignalingCount = 0; - InitializeListHead(&m_lePendingSignalingsOverflowList); -#endif // SYNCHMGR_SUSPENSION_SAFE_CONDITION_SIGNALING - } - - CThreadSynchronizationInfo::~CThreadSynchronizationInfo() - { - DeleteCriticalSection(&m_ownedNamedMutexListLock); - if (NULL != m_shridWaitAwakened) - { - free(m_shridWaitAwakened); - } - } - - void CThreadSynchronizationInfo::AcquireNativeWaitLock() - { -#if !SYNCHMGR_SUSPENSION_SAFE_CONDITION_SIGNALING - int iRet; - iRet = pthread_mutex_lock(&m_tnwdNativeData.mutex); - _ASSERT_MSG(0 == iRet, "pthread_mutex_lock failed with error=%d\n", iRet); -#endif // !SYNCHMGR_SUSPENSION_SAFE_CONDITION_SIGNALING - } - - void CThreadSynchronizationInfo::ReleaseNativeWaitLock() - { -#if !SYNCHMGR_SUSPENSION_SAFE_CONDITION_SIGNALING - int iRet; - iRet = pthread_mutex_unlock(&m_tnwdNativeData.mutex); - _ASSERT_MSG(0 == iRet, "pthread_mutex_unlock failed with error=%d\n", iRet); -#endif // !SYNCHMGR_SUSPENSION_SAFE_CONDITION_SIGNALING - } - - bool CThreadSynchronizationInfo::TryAcquireNativeWaitLock() - { - bool fRet = true; -#if !SYNCHMGR_SUSPENSION_SAFE_CONDITION_SIGNALING - int iRet; - iRet = pthread_mutex_trylock(&m_tnwdNativeData.mutex); - _ASSERT_MSG(0 == iRet || EBUSY == iRet, - "pthread_mutex_trylock failed with error=%d\n", iRet); - fRet = (0 == iRet); -#endif // !SYNCHMGR_SUSPENSION_SAFE_CONDITION_SIGNALING - return fRet; - } - - /*++ - Method: - CThreadSynchronizationInfo::InitializePreCreate - - Part of CThreadSynchronizationInfo's initialization to be carried out - before actual thread creation - --*/ - PAL_ERROR CThreadSynchronizationInfo::InitializePreCreate(void) - { - PAL_ERROR palErr = NO_ERROR; - DWORD * pdwWaitState = NULL; - int iRet; - const int MaxUnavailableResourceRetries = 10; - int iEagains; - pthread_condattr_t attrs; - pthread_condattr_t *attrsPtr = nullptr; - - m_shridWaitAwakened = malloc(sizeof(DWORD)); - if (NULL == m_shridWaitAwakened) - { - ERROR("Fail allocating thread wait status shared object\n"); - palErr = ERROR_NOT_ENOUGH_MEMORY; - goto IPrC_exit; - } - - pdwWaitState = SharedIDToTypePointer(DWORD, - m_shridWaitAwakened); - - _ASSERT_MSG(NULL != pdwWaitState, - "Unable to map shared wait state: bad shared ID [shrid=%p]\n", (VOID*)m_shridWaitAwakened); - - VolatileStore(pdwWaitState, TWS_ACTIVE); - m_tsThreadState = TS_STARTING; - -#if HAVE_CLOCK_MONOTONIC && HAVE_PTHREAD_CONDATTR_SETCLOCK - attrsPtr = &attrs; - iRet = pthread_condattr_init(&attrs); - if (0 != iRet) - { - ERROR("Failed to initialize thread synchronization condition attribute " - "[error=%d (%s)]\n", iRet, strerror(iRet)); - if (ENOMEM == iRet) - { - palErr = ERROR_NOT_ENOUGH_MEMORY; - } - else - { - palErr = ERROR_INTERNAL_ERROR; - } - goto IPrC_exit; - } - - // Ensure that the pthread_cond_timedwait will use CLOCK_MONOTONIC - iRet = pthread_condattr_setclock(&attrs, CLOCK_MONOTONIC); - if (0 != iRet) - { - ERROR("Failed set thread synchronization condition timed wait clock " - "[error=%d (%s)]\n", iRet, strerror(iRet)); - palErr = ERROR_INTERNAL_ERROR; - pthread_condattr_destroy(&attrs); - goto IPrC_exit; - } -#endif // HAVE_CLOCK_MONOTONIC && HAVE_PTHREAD_CONDATTR_SETCLOCK - - iEagains = 0; - Mutex_retry: - iRet = pthread_mutex_init(&m_tnwdNativeData.mutex, NULL); - if (0 != iRet) - { - ERROR("Failed creating thread synchronization mutex [error=%d (%s)]\n", iRet, strerror(iRet)); - if (EAGAIN == iRet && MaxUnavailableResourceRetries >= ++iEagains) - { - poll(NULL, 0, std::min(100,10*iEagains)); - goto Mutex_retry; - } - else if (ENOMEM == iRet) - { - palErr = ERROR_NOT_ENOUGH_MEMORY; - } - else - { - palErr = ERROR_INTERNAL_ERROR; - } - - goto IPrC_exit; - } - - iEagains = 0; - Cond_retry: - - iRet = pthread_cond_init(&m_tnwdNativeData.cond, attrsPtr); - - if (0 != iRet) - { - ERROR("Failed creating thread synchronization condition " - "[error=%d (%s)]\n", iRet, strerror(iRet)); - if (EAGAIN == iRet && MaxUnavailableResourceRetries >= ++iEagains) - { - poll(NULL, 0, std::min(100,10*iEagains)); - goto Cond_retry; - } - else if (ENOMEM == iRet) - { - palErr = ERROR_NOT_ENOUGH_MEMORY; - } - else - { - palErr = ERROR_INTERNAL_ERROR; - } - pthread_mutex_destroy(&m_tnwdNativeData.mutex); - goto IPrC_exit; - } - - m_tnwdNativeData.fInitialized = true; - - IPrC_exit: - if (attrsPtr != nullptr) - { - pthread_condattr_destroy(attrsPtr); - } - if (NO_ERROR != palErr) - { - m_tsThreadState = TS_FAILED; - } - return palErr; - } - - /*++ - Method: - CThreadSynchronizationInfo::InitializePostCreate - - Part of CThreadSynchronizationInfo's initialization to be carried out - after actual thread creation - --*/ - PAL_ERROR CThreadSynchronizationInfo::InitializePostCreate( - CPalThread *pthrCurrent, - SIZE_T threadId, - DWORD dwLwpId) - { - PAL_ERROR palErr = NO_ERROR; - - if (TS_FAILED == m_tsThreadState) - { - palErr = ERROR_INTERNAL_ERROR; - } - - m_twiWaitInfo.pthrOwner = pthrCurrent; - - return palErr; - } - - - /*++ - Method: - CThreadSynchronizationInfo::AddObjectToOwnedList - - Adds an object to the list of currently owned objects. - --*/ - void CThreadSynchronizationInfo::AddObjectToOwnedList(POwnedObjectsListNode pooln) - { - InsertTailList(&m_leOwnedObjsList, &pooln->Link); - } - - /*++ - Method: - CThreadSynchronizationInfo::RemoveObjectFromOwnedList - - Removes an object from the list of currently owned objects. - --*/ - void CThreadSynchronizationInfo::RemoveObjectFromOwnedList(POwnedObjectsListNode pooln) - { - RemoveEntryList(&pooln->Link); - } - - /*++ - Method: - CThreadSynchronizationInfo::RemoveFirstObjectFromOwnedList - - Removes the first object from the list of currently owned objects. - --*/ - POwnedObjectsListNode CThreadSynchronizationInfo::RemoveFirstObjectFromOwnedList() - { - OwnedObjectsListNode * poolnItem; - - if (IsListEmpty(&m_leOwnedObjsList)) - { - poolnItem = NULL; - } - else - { - PLIST_ENTRY pLink = RemoveHeadList(&m_leOwnedObjsList); - poolnItem = CONTAINING_RECORD(pLink, OwnedObjectsListNode, Link); - } - - return poolnItem; - } - - void CThreadSynchronizationInfo::AddOwnedNamedMutex(NamedMutexProcessData *processData) - { - _ASSERTE(processData != nullptr); - _ASSERTE(processData->GetNextInThreadOwnedNamedMutexList() == nullptr); - - EnterCriticalSection(&m_ownedNamedMutexListLock); - processData->SetNextInThreadOwnedNamedMutexList(m_ownedNamedMutexListHead); - m_ownedNamedMutexListHead = processData; - LeaveCriticalSection(&m_ownedNamedMutexListLock); - } - - void CThreadSynchronizationInfo::RemoveOwnedNamedMutex(NamedMutexProcessData *processData) - { - _ASSERTE(processData != nullptr); - - EnterCriticalSection(&m_ownedNamedMutexListLock); - if (m_ownedNamedMutexListHead == processData) - { - m_ownedNamedMutexListHead = processData->GetNextInThreadOwnedNamedMutexList(); - processData->SetNextInThreadOwnedNamedMutexList(nullptr); - } - else - { - bool found = false; - for (NamedMutexProcessData - *previous = m_ownedNamedMutexListHead, - *current = previous->GetNextInThreadOwnedNamedMutexList(); - current != nullptr; - previous = current, current = current->GetNextInThreadOwnedNamedMutexList()) - { - if (current == processData) - { - found = true; - previous->SetNextInThreadOwnedNamedMutexList(current->GetNextInThreadOwnedNamedMutexList()); - current->SetNextInThreadOwnedNamedMutexList(nullptr); - break; - } - } - _ASSERTE(found); - } - LeaveCriticalSection(&m_ownedNamedMutexListLock); - } - - NamedMutexProcessData *CThreadSynchronizationInfo::RemoveFirstOwnedNamedMutex() - { - EnterCriticalSection(&m_ownedNamedMutexListLock); - NamedMutexProcessData *processData = m_ownedNamedMutexListHead; - if (processData != nullptr) - { - m_ownedNamedMutexListHead = processData->GetNextInThreadOwnedNamedMutexList(); - processData->SetNextInThreadOwnedNamedMutexList(nullptr); - } - LeaveCriticalSection(&m_ownedNamedMutexListLock); - return processData; - } - - bool CThreadSynchronizationInfo::OwnsNamedMutex(NamedMutexProcessData *processData) - { - EnterCriticalSection(&m_ownedNamedMutexListLock); - bool found = false; - for (NamedMutexProcessData *current = m_ownedNamedMutexListHead; - current != nullptr; - current = current->GetNextInThreadOwnedNamedMutexList()) - { - if (current == processData) - { - found = true; - break; - } - } - LeaveCriticalSection(&m_ownedNamedMutexListLock); - return found; - } - -#if SYNCHMGR_SUSPENSION_SAFE_CONDITION_SIGNALING - - /*++ - Method: - CThreadSynchronizationInfo::RunDeferredThreadConditionSignalings - - Carries out all the pending condition signalings for the current thread. - --*/ - PAL_ERROR CThreadSynchronizationInfo::RunDeferredThreadConditionSignalings() - { - PAL_ERROR palErr = NO_ERROR; - - _ASSERTE(0 <= m_lPendingSignalingCount); - - if (0 < m_lPendingSignalingCount) - { - LONG lArrayPendingSignalingCount = std::min(PendingSignalingsArraySize, m_lPendingSignalingCount); - LONG lIdx = 0; - PAL_ERROR palTempErr; - - // Signal all the pending signalings from the array - for (lIdx = 0; lIdx < lArrayPendingSignalingCount; lIdx++) - { - // Do the actual signaling - palTempErr = CPalSynchronizationManager::SignalThreadCondition( - m_rgpthrPendingSignalings[lIdx]->synchronizationInfo.GetNativeData()); - if (NO_ERROR != palTempErr) - { - palErr = palTempErr; - } - - // Release the thread reference - m_rgpthrPendingSignalings[lIdx]->ReleaseThreadReference(); - } - - // Signal any pending signalings from the array overflow list - if (m_lPendingSignalingCount > PendingSignalingsArraySize) - { - PLIST_ENTRY pLink; - DeferredSignalingListNode * pdsln; - - while (!IsListEmpty(&m_lePendingSignalingsOverflowList)) - { - // Remove a node from the head of the queue - // Note: no need to synchronize the access to this list since - // it is meant to be accessed only by the owner thread. - pLink = RemoveHeadList(&m_lePendingSignalingsOverflowList); - pdsln = CONTAINING_RECORD(pLink, - DeferredSignalingListNode, - Link); - - // Do the actual signaling - palTempErr = CPalSynchronizationManager::SignalThreadCondition( - pdsln->pthrTarget->synchronizationInfo.GetNativeData()); - if (NO_ERROR != palTempErr) - { - palErr = palTempErr; - } - - // Release the thread reference - pdsln->pthrTarget->ReleaseThreadReference(); - - // Delete the node - InternalDelete(pdsln); - - lIdx += 1; - } - - _ASSERTE(lIdx == m_lPendingSignalingCount); - } - - // Reset the counter of pending signalings for this thread - m_lPendingSignalingCount = 0; - } - - return palErr; - } - -#endif // SYNCHMGR_SUSPENSION_SAFE_CONDITION_SIGNALING - - /*++ - Method: - CPalSynchronizationManager::HasProcessExited - - Tests whether or not a process has exited - --*/ - bool CPalSynchronizationManager::HasProcessExited( - DWORD dwPid, - DWORD * pdwExitCode, - bool * pfIsActualExitCode) - { - pid_t pidWaitRetval; - int iStatus; - bool fRet = false; - - TRACE("Looking for status of process; trying wait()\n"); - - while(1) - { - /* try to get state of process, using non-blocking call */ - pidWaitRetval = waitpid(dwPid, &iStatus, WNOHANG); - - if ((DWORD)pidWaitRetval == dwPid) - { - /* success; get the exit code */ - if (WIFEXITED(iStatus)) - { - *pdwExitCode = WEXITSTATUS(iStatus); - *pfIsActualExitCode = true; - TRACE("Exit code was %d\n", *pdwExitCode); - } - else - { - WARN("Process terminated without exiting; can't get exit " - "code. Assuming EXIT_FAILURE.\n"); - *pfIsActualExitCode = true; - *pdwExitCode = EXIT_FAILURE; - } - - fRet = true; - } - else if (0 == pidWaitRetval) - { - // The process is still running. - TRACE("Process %#x is still active.\n", dwPid); - } - else - { - // A legitimate cause of failure is EINTR; if this happens we - // have to try again. A second legitimate cause is ECHILD, which - // happens if we're trying to retrieve the status of a currently- - // running process that isn't a child of this process. - if(EINTR == errno) - { - TRACE("waitpid() failed with EINTR; re-waiting\n"); - continue; - } - else if (ECHILD == errno) - { - TRACE("waitpid() failed with ECHILD; calling kill instead\n"); - if (kill(dwPid, 0) != 0) - { - if (ESRCH == errno) - { - WARN("kill() failed with ESRCH, i.e. target " - "process exited and it wasn't a child, " - "so can't get the exit code, assuming " - "it was 0.\n"); - *pfIsActualExitCode = false; - *pdwExitCode = 0; - } - else - { - ERROR("kill(pid, 0) failed; errno is %d (%s)\n", - errno, strerror(errno)); - *pfIsActualExitCode = false; - *pdwExitCode = EXIT_FAILURE; - } - - fRet = true; - } - } - else - { - // Ignoring unexpected waitpid errno and assuming that - // the process is still running - ERROR("waitpid(pid=%u) failed with errno=%d (%s)\n", - dwPid, errno, strerror(errno)); - } - } - - // Break out of the loop in all cases except EINTR. - break; - } - - return fRet; - } - - /*++ - Method: - CPalSynchronizationManager::InterlockedAwaken - - Tries to change the target wait status to 'active' in an interlocked fashion - --*/ - bool CPalSynchronizationManager::InterlockedAwaken( - DWORD *pWaitState, - bool fAlertOnly) - { - DWORD dwPrevState; - - dwPrevState = InterlockedCompareExchange((LONG *)pWaitState, TWS_ACTIVE, TWS_ALERTABLE); - if (TWS_ALERTABLE != dwPrevState) - { - if (fAlertOnly) - { - return false; - } - - dwPrevState = InterlockedCompareExchange((LONG *)pWaitState, TWS_ACTIVE, TWS_WAITING); - if (TWS_WAITING == dwPrevState) - { - return true; - } - } - else - { - return true; - } - - return false; - } - - /*++ - Method: - CPalSynchronizationManager::GetAbsoluteTimeout - - Converts a relative timeout to an absolute one. - --*/ - PAL_ERROR CPalSynchronizationManager::GetAbsoluteTimeout(DWORD dwTimeout, struct timespec * ptsAbsTmo, BOOL fPreferMonotonicClock) - { - PAL_ERROR palErr = NO_ERROR; - int iRet; - -#if HAVE_CLOCK_MONOTONIC && HAVE_PTHREAD_CONDATTR_SETCLOCK - if (fPreferMonotonicClock) - { - iRet = clock_gettime(CLOCK_MONOTONIC, ptsAbsTmo); - } - else - { -#endif -#if HAVE_WORKING_CLOCK_GETTIME - // Not every platform implements a (working) clock_gettime - iRet = clock_gettime(CLOCK_REALTIME, ptsAbsTmo); -#elif HAVE_WORKING_GETTIMEOFDAY - // Not every platform implements a (working) gettimeofday - struct timeval tv; - iRet = gettimeofday(&tv, NULL); - if (0 == iRet) - { - ptsAbsTmo->tv_sec = tv.tv_sec; - ptsAbsTmo->tv_nsec = tv.tv_usec * tccMicroSecondsToNanoSeconds; - } -#else - #error "Don't know how to get hi-res current time on this platform" -#endif // HAVE_WORKING_CLOCK_GETTIME, HAVE_WORKING_GETTIMEOFDAY -#if HAVE_CLOCK_MONOTONIC && HAVE_PTHREAD_CONDATTR_SETCLOCK - } -#endif - if (0 == iRet) - { - ptsAbsTmo->tv_sec += dwTimeout / tccSecondsToMillieSeconds; - ptsAbsTmo->tv_nsec += (dwTimeout % tccSecondsToMillieSeconds) * tccMillieSecondsToNanoSeconds; - while (ptsAbsTmo->tv_nsec >= tccSecondsToNanoSeconds) - { - ptsAbsTmo->tv_sec += 1; - ptsAbsTmo->tv_nsec -= tccSecondsToNanoSeconds; - } - } - else - { - palErr = ERROR_INTERNAL_ERROR; - } - - return palErr; - } -} diff --git a/src/pal/src/synchmgr/synchmanager.hpp b/src/pal/src/synchmgr/synchmanager.hpp deleted file mode 100644 index 89e1d1356..000000000 --- a/src/pal/src/synchmgr/synchmanager.hpp +++ /dev/null @@ -1,1024 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*++ - - - -Module Name: - - synchmanager.hpp - -Abstract: - Private header file for synchronization manager and - controllers implementation - - - ---*/ -#ifndef _SYNCHMANAGER_HPP_ -#define _SYNCHMANAGER_HPP_ - -#include "pal/synchobjects.hpp" -#include "pal/synchcache.hpp" -#include "pal/cs.hpp" -#include "pal/corunix.hpp" -#include "pal/thread.hpp" -#include "pal/procobj.hpp" -#include "pal/init.h" -#include "pal/process.h" - -#include -#include -#if HAVE_KQUEUE -#include -#endif // HAVE_KQUEUE -#include "pal/dbgmsg.h" - -#ifdef _DEBUG -// #define SYNCH_OBJECT_VALIDATION -// #define SYNCH_STATISTICS -#endif - -#ifdef SYNCH_OBJECT_VALIDATION -#define VALIDATEOBJECT(obj) ((obj)->ValidateObject()) -#else -#define VALIDATEOBJECT(obj) -#endif - -namespace CorUnix -{ - const DWORD WTLN_FLAG_OWNER_OBJECT_IS_SHARED = 1<<0; - const DWORD WTLN_FLAG_WAIT_ALL = 1<<1; - const DWORD WTLN_FLAG_DELEGATED_OBJECT_SIGNALING_IN_PROGRESS = 1<<2; - -#ifdef SYNCH_OBJECT_VALIDATION - const DWORD HeadSignature = 0x48454144; - const DWORD TailSignature = 0x5441494C; - const DWORD EmptySignature = 0xBAADF00D; -#endif - - enum THREAD_WAIT_STATE - { - TWS_ACTIVE, - TWS_WAITING, - TWS_ALERTABLE, - TWS_EARLYDEATH, - }; - - enum WaitCompletionState - { - WaitIsNotSatisfied, - WaitIsSatisfied, - WaitMayBeSatisfied - }; - - typedef union _SynchDataGenrPtr - { - SharedID shrid; - CSynchData * ptr; - } SynchDataGenrPtr; - - typedef union _WTLNodeGenrPtr - { - SharedID shrid; - struct _WaitingThreadsListNode * ptr; - } WTLNodeGenrPtr; - - typedef struct _WaitingThreadsListNode - { -#ifdef SYNCH_OBJECT_VALIDATION - DWORD dwDebugHeadSignature; -#endif - WTLNodeGenrPtr ptrNext; - WTLNodeGenrPtr ptrPrev; - SharedID shridSHRThis; - - // Data - DWORD dwThreadId; - DWORD dwProcessId; - DWORD dwObjIndex; - DWORD dwFlags; - - // Pointers to related objects - SharedID shridWaitingState; - SynchDataGenrPtr ptrOwnerObjSynchData; - struct _ThreadWaitInfo * ptwiWaitInfo; // valid only in the - // target process -#ifdef SYNCH_OBJECT_VALIDATION - _WaitingThreadsListNode(); - ~_WaitingThreadsListNode(); - void ValidateObject(void); - void ValidateEmptyObject(void); - void InvalidateObject(void); - - DWORD dwDebugTailSignature; -#endif - } WaitingThreadsListNode; - - typedef struct _DeferredSignalingListNode - { - LIST_ENTRY Link; - CPalThread * pthrTarget; - } DeferredSignalingListNode; - - typedef struct _OwnedObjectsListNode - { - LIST_ENTRY Link; - CSynchData * pPalObjSynchData; - } OwnedObjectsListNode; - - typedef struct _ThreadApcInfoNode - { - struct _ThreadApcInfoNode * pNext; - PAPCFUNC pfnAPC; - ULONG_PTR pAPCData; - } ThreadApcInfoNode; - - class CPalSynchronizationManager; // fwd declaration - class CProcProcessLocalData; // fwd declaration - - class CSynchData - { -#ifdef SYNCH_OBJECT_VALIDATION - DWORD m_dwDebugHeadSignature; -#endif - // NB: For perforformance purposes this class is supposed - // to have no virtual methods, and no destructor. - - WTLNodeGenrPtr m_ptrWTLHead; - WTLNodeGenrPtr m_ptrWTLTail; - ULONG m_ulcWaitingThreads; - SharedID m_shridThis; - ObjectDomain m_odObjectDomain; - PalObjectTypeId m_otiObjectTypeId; - LONG m_lRefCount; - LONG m_lSignalCount; - - // Ownership data - LONG m_lOwnershipCount; - DWORD m_dwOwnerPid; - DWORD m_dwOwnerTid; // used only by remote processes - // (thread ids may be recycled) - CPalThread * m_pOwnerThread; // valid only on the target process - OwnedObjectsListNode * m_poolnOwnedObjectListNode; - bool m_fAbandoned; - -#ifdef SYNCH_STATISTICS - ULONG m_lStatWaitCount; - ULONG m_lStatContentionCount; -#endif - - public: - CSynchData() - : m_ulcWaitingThreads(0), m_shridThis(NULL), m_lRefCount(1), - m_lSignalCount(0), m_lOwnershipCount(0), m_dwOwnerPid(0), - m_dwOwnerTid(0), m_pOwnerThread(NULL), - m_poolnOwnedObjectListNode(NULL), m_fAbandoned(false) - { - // m_ptrWTLHead, m_ptrWTLTail, m_odObjectDomain - // and m_otiObjectTypeId are initialized by - // CPalSynchronizationManager::AllocateObjectSynchData -#ifdef SYNCH_STATISTICS - m_lStatWaitCount = 0; - m_lStatContentionCount = 0; -#endif -#ifdef SYNCH_OBJECT_VALIDATION - ValidateEmptyObject(); - m_dwDebugHeadSignature = HeadSignature;; - m_dwDebugTailSignature = TailSignature; -#endif - } - - LONG AddRef() - { - return InterlockedIncrement(&m_lRefCount); - } - - LONG Release(CPalThread * pthrCurrent); - - bool CanWaiterWaitWithoutBlocking( - CPalThread * pWaiterThread, - bool * pfAbandoned); - - PAL_ERROR ReleaseWaiterWithoutBlocking( - CPalThread * pthrCurrent, - CPalThread * pthrTarget); - - void WaiterEnqueue(WaitingThreadsListNode * pwtlnNewNode, bool fPrioritize); - void SharedWaiterEnqueue(SharedID shridNewNode, bool fPrioritize); - - // Object Domain accessor methods - ObjectDomain GetObjectDomain(void) - { - return m_odObjectDomain; - } - void SetObjectDomain(ObjectDomain odObjectDomain) - { - m_odObjectDomain = odObjectDomain; - } - - // Object Type accessor methods - CObjectType * GetObjectType(void) - { - return CObjectType::GetObjectTypeById(m_otiObjectTypeId); - } - PalObjectTypeId GetObjectTypeId(void) - { - return m_otiObjectTypeId; - } - void SetObjectType(CObjectType * pot) - { - m_otiObjectTypeId = pot->GetId(); - } - void SetObjectType(PalObjectTypeId oti) - { - m_otiObjectTypeId = oti; - } - - // Object shared 'this' pointer accessor methods - SharedID GetSharedThis (void) - { - return m_shridThis; - } - void SetSharedThis (SharedID shridThis) - { - m_shridThis = shridThis; - } - - void Signal( - CPalThread * pthrCurrent, - LONG lSignalCount, - bool fWorkerThread); - - bool ReleaseFirstWaiter( - CPalThread * pthrCurrent, - bool * pfDelegated, - bool fWorkerThread); - - LONG ReleaseAllLocalWaiters( - CPalThread * pthrCurrent); - - WaitCompletionState IsRestOfWaitAllSatisfied( - WaitingThreadsListNode * pwtlnNode); - - // Object signal count accessor methods - LONG GetSignalCount(void) - { - _ASSERTE(m_lSignalCount >= 0); - return m_lSignalCount; - } - void SetSignalCount(LONG lSignalCount) - { - _ASSERTE(m_lSignalCount >= 0); - _ASSERTE(lSignalCount >= 0); - m_lSignalCount = lSignalCount; - } - LONG DecrementSignalCount(void) - { - _ASSERTE(m_lSignalCount > 0); - return --m_lSignalCount; - } - - // Object ownership accessor methods - void SetOwner(CPalThread * pOwnerThread); - void ResetOwnership(void); - PAL_ERROR AssignOwnershipToThread( - CPalThread * pthrCurrent, - CPalThread * pthrTarget); - DWORD GetOwnerProcessID(void) - { - return m_dwOwnerPid; - } - DWORD GetOwnerThreadID(void) - { - return m_dwOwnerTid; - } - CPalThread * GetOwnerThread(void) - { - return m_pOwnerThread; - } - OwnedObjectsListNode * GetOwnershipListNode(void) - { - return m_poolnOwnedObjectListNode; - } - void SetOwnershipListNode(OwnedObjectsListNode * pooln) - { - m_poolnOwnedObjectListNode = pooln; - } - - // Object ownership count accessor methods - LONG GetOwnershipCount(void) - { - return m_lOwnershipCount; - } - void SetOwnershipCount(LONG lOwnershipCount) - { - m_lOwnershipCount = lOwnershipCount; - } - - // Object abandoned flag accessor methods - void SetAbandoned(bool fAbandoned) - { m_fAbandoned = fAbandoned; } - bool IsAbandoned(void) { return m_fAbandoned; } - - void IncrementWaitingThreadCount(void) - { - m_ulcWaitingThreads += 1; - } - void DecrementWaitingThreadCount(void) - { - m_ulcWaitingThreads -= 1; - } - ULONG GetWaitingThreadCount(void) - { - return m_ulcWaitingThreads; - } - - -#ifdef SYNCH_STATISTICS - void IncrementStatWaitCount(void) - { - m_lStatWaitCount++; - } - LONG GetStatWaitCount(void) - { - return m_lStatWaitCount; - } - void IncrementStatContentionCount(void) - { - m_lStatContentionCount++; - } - LONG GetStatContentionCount(void) - { - return m_lStatContentionCount; - } -#endif - // - // Wating threads list access methods - // - WaitingThreadsListNode * GetWTLHeadPtr(void) - { - return m_ptrWTLHead.ptr; - } - WaitingThreadsListNode * GetWTLTailPtr(void) - { - return m_ptrWTLTail.ptr; - } - SharedID GetWTLHeadShmPtr(void) - { - return m_ptrWTLHead.shrid; - } - SharedID GetWTLTailShmPtr(void) - { - return m_ptrWTLTail.shrid; - } - void SetWTLHeadPtr(WaitingThreadsListNode * p) - { - m_ptrWTLHead.ptr = p; - } - void SetWTLTailPtr(WaitingThreadsListNode * p) - { - m_ptrWTLTail.ptr = p; - } - void SetWTLHeadShrPtr(SharedID shrid) - { - m_ptrWTLHead.shrid = shrid; - } - void SetWTLTailShrPtr(SharedID shrid) - { - m_ptrWTLTail.shrid = shrid; - } -#ifdef SYNCH_OBJECT_VALIDATION - ~CSynchData(); - void ValidateObject(bool fDestructor = false); - void ValidateEmptyObject(void); - void InvalidateObject(void); - - DWORD m_dwDebugTailSignature; -#endif - }; - - - class CSynchControllerBase - { - friend class CPalSynchronizationManager; - - // NB: For perforformance purposes this class is supposed - // to have no virtual methods, contructor and - // destructor - public: - enum ControllerType { WaitController, StateController }; - - protected: - CPalThread * m_pthrOwner; - ControllerType m_ctCtrlrType; - ObjectDomain m_odObjectDomain; - CObjectType * m_potObjectType; - CSynchData * m_psdSynchData; - WaitDomain m_wdWaitDomain; - - PAL_ERROR Init( - CPalThread * pthrCurrent, - ControllerType ctCtrlrType, - ObjectDomain odObjectDomain, - CObjectType *potObjectType, - CSynchData * psdSynchData, - WaitDomain wdWaitDomain); - - void Release(void); - - void SetSynchData(CSynchData * psdSynchData) - { - m_psdSynchData = psdSynchData; - } - CSynchData * GetSynchData() - { - return m_psdSynchData; - } - }; - - class CSynchWaitController : public CSynchControllerBase, - public ISynchWaitController - { - // Per-object-type specific data - // - // Process (otiProcess) - IPalObject *m_pProcessObject; // process that owns m_pProcLocalData, this is stored without a reference - CProcProcessLocalData * m_pProcLocalData; - - public: - CSynchWaitController() : m_pProcessObject(NULL), m_pProcLocalData(NULL) {} - virtual ~CSynchWaitController() = default; - - // - // ISynchWaitController methods - // - virtual PAL_ERROR CanThreadWaitWithoutBlocking( - bool * pfCanWaitWithoutBlocking, - bool * pfAbandoned); - - virtual PAL_ERROR ReleaseWaitingThreadWithoutBlocking(void); - - virtual PAL_ERROR RegisterWaitingThread( - WaitType wtWaitType, - DWORD dwIndex, - bool fAlertable, - bool fPrioritize); - - virtual void ReleaseController(void); - - CProcProcessLocalData * GetProcessLocalData(void); - - void SetProcessData(IPalObject* pProcessObject, CProcProcessLocalData * pProcLocalData); - }; - - class CSynchStateController : public CSynchControllerBase, - public ISynchStateController - { - public: - // NB: For perforformance purposes this class is supposed - // to have no constructor - virtual ~CSynchStateController() = default; - - // - // ISynchStateController methods - // - virtual PAL_ERROR GetSignalCount(LONG *plSignalCount); - virtual PAL_ERROR SetSignalCount(LONG lNewCount); - virtual PAL_ERROR IncrementSignalCount(LONG lAmountToIncrement); - virtual PAL_ERROR DecrementSignalCount(LONG lAmountToDecrement); - virtual PAL_ERROR SetOwner(CPalThread *pNewOwningThread); - virtual PAL_ERROR DecrementOwnershipCount(void); - virtual void ReleaseController(void); - }; - - class CPalSynchronizationManager : public IPalSynchronizationManager - { - friend class CPalSynchMgrController; - template friend T *CorUnix::InternalNew(); - - public: - // types - typedef CSynchCache CSynchWaitControllerCache; - typedef CSynchCache CSynchStateControllerCache; - typedef CSynchCache CSynchDataCache; - typedef CSHRSynchCache CSHRSynchDataCache; - typedef CSynchCache CWaitingThreadsListNodeCache; - typedef CSHRSynchCache CSHRWaitingThreadsListNodeCache; - typedef CSynchCache CThreadApcInfoNodeCache; - typedef CSynchCache COwnedObjectsListNodeCache; - - private: - // types - enum InitStatus - { - SynchMgrStatusIdle, - SynchMgrStatusInitializing, - SynchMgrStatusRunning, - SynchMgrStatusShuttingDown, - SynchMgrStatusReadyForProcessShutDown, - SynchMgrStatusError - }; - enum SynchWorkerCmd - { - SynchWorkerCmdNop, - SynchWorkerCmdRemoteSignal, - SynchWorkerCmdDelegatedObjectSignaling, - SynchWorkerCmdShutdown, - SynchWorkerCmdTerminationRequest, - SynchWorkerCmdLast - }; - - typedef struct _MonitoredProcessesListNode - { - struct _MonitoredProcessesListNode * pNext; - LONG lRefCount; - CSynchData * psdSynchData; - DWORD dwPid; - DWORD dwExitCode; - bool fIsActualExitCode; - - // Object that owns pProcLocalData. This is stored, with a reference, to - // ensure that pProcLocalData is not deleted. - IPalObject *pProcessObject; - CProcProcessLocalData * pProcLocalData; - } MonitoredProcessesListNode; - - // constants - static const int CtrlrsCacheMaxSize = 256; - static const int SynchDataCacheMaxSize = 256; - static const int WTListNodeCacheMaxSize = 256; - static const int ApcInfoNodeCacheMaxSize = 32; - static const int OwnedObjectsListCacheMaxSize = 16; - static const int MaxWorkerConsecutiveEintrs = 128; - static const int MaxConsecutiveEagains = 128; - static const int WorkerThreadProcMonitoringTimeout = 250; // ms - static const int WorkerThreadShuttingDownTimeout = 1000; // ms - static const int WorkerCmdCompletionTimeout = 250; // ms - static const DWORD SecondNativeWaitTimeout = INFINITE; - static const DWORD WorkerThreadTerminationTimeout = 2000; // ms - - // static members - static CPalSynchronizationManager * s_pObjSynchMgr; - static Volatile s_lInitStatus; - static CRITICAL_SECTION s_csSynchProcessLock; - static CRITICAL_SECTION s_csMonitoredProcessesLock; - - // members - DWORD m_dwWorkerThreadTid; - IPalObject * m_pipoThread; - CPalThread * m_pthrWorker; - int m_iProcessPipeRead; - int m_iProcessPipeWrite; -#if HAVE_KQUEUE - int m_iKQueue; - struct kevent m_keProcessPipeEvent; -#endif // HAVE_KQUEUE - - MonitoredProcessesListNode * m_pmplnMonitoredProcesses; - LONG m_lMonitoredProcessesCount; - MonitoredProcessesListNode * m_pmplnExitedNodes; - - // caches - CSynchWaitControllerCache m_cacheWaitCtrlrs; - CSynchStateControllerCache m_cacheStateCtrlrs; - CSynchDataCache m_cacheSynchData; - CSHRSynchDataCache m_cacheSHRSynchData; - CWaitingThreadsListNodeCache m_cacheWTListNodes; - CSHRWaitingThreadsListNodeCache m_cacheSHRWTListNodes; - CThreadApcInfoNodeCache m_cacheThreadApcInfoNodes; - COwnedObjectsListNodeCache m_cacheOwnedObjectsListNodes; - - // static methods - static PAL_ERROR Initialize(); - static DWORD PALAPI WorkerThread(LPVOID pArg); - - protected: - CPalSynchronizationManager(); - - PAL_ERROR GetSynchControllersForObjects( - CPalThread *pthrCurrent, - IPalObject *rgObjects[], - DWORD dwObjectCount, - void ** ppvControllers, - CSynchControllerBase::ControllerType ctCtrlrType); - - private: - static IPalSynchronizationManager * CreatePalSynchronizationManager(); - static PAL_ERROR StartWorker(CPalThread * pthrCurrent); - static PAL_ERROR PrepareForShutdown(void); - - public: - virtual ~CPalSynchronizationManager(); - - static CPalSynchronizationManager * GetInstance(void) - { - // No need here to check for NULL and in case create the - // singleton, since its creation is enforced by the PAL - // initialization code. - return s_pObjSynchMgr; - } - - // - // Inline utility methods - // - static void AcquireLocalSynchLock(CPalThread * pthrCurrent) - { - _ASSERTE(0 <= pthrCurrent->synchronizationInfo.m_lLocalSynchLockCount); - - if (1 == ++pthrCurrent->synchronizationInfo.m_lLocalSynchLockCount) - { - InternalEnterCriticalSection(pthrCurrent, &s_csSynchProcessLock); - } - } - static void ReleaseLocalSynchLock(CPalThread * pthrCurrent) - { - _ASSERTE(0 < pthrCurrent->synchronizationInfo.m_lLocalSynchLockCount); - if (0 == --pthrCurrent->synchronizationInfo.m_lLocalSynchLockCount) - { - InternalLeaveCriticalSection(pthrCurrent, &s_csSynchProcessLock); - -#if SYNCHMGR_SUSPENSION_SAFE_CONDITION_SIGNALING - pthrCurrent->synchronizationInfo.RunDeferredThreadConditionSignalings(); -#endif // SYNCHMGR_SUSPENSION_SAFE_CONDITION_SIGNALING - } - } - static LONG ResetLocalSynchLock(CPalThread * pthrCurrent) - { - LONG lRet = pthrCurrent->synchronizationInfo.m_lLocalSynchLockCount; - - _ASSERTE(0 <= lRet); - if (0 < lRet) - { - pthrCurrent->synchronizationInfo.m_lLocalSynchLockCount = 0; - InternalLeaveCriticalSection(pthrCurrent, &s_csSynchProcessLock); - -#if SYNCHMGR_SUSPENSION_SAFE_CONDITION_SIGNALING - pthrCurrent->synchronizationInfo.RunDeferredThreadConditionSignalings(); -#endif // SYNCHMGR_SUSPENSION_SAFE_CONDITION_SIGNALING - } - return lRet; - } - static LONG GetLocalSynchLockCount(CPalThread * pthrCurrent) - { - _ASSERTE(0 <= pthrCurrent->synchronizationInfo.m_lLocalSynchLockCount); - return pthrCurrent->synchronizationInfo.m_lLocalSynchLockCount; - } - - static void AcquireSharedSynchLock(CPalThread * pthrCurrent) - { - _ASSERTE(0 <= pthrCurrent->synchronizationInfo.m_lSharedSynchLockCount); - _ASSERT_MSG(0 < pthrCurrent->synchronizationInfo.m_lLocalSynchLockCount, - "The local synch lock should be acquired before grabbing the " - "shared one.\n"); - if (1 == ++pthrCurrent->synchronizationInfo.m_lSharedSynchLockCount) - { - SHMLock(); - } - } - static void ReleaseSharedSynchLock(CPalThread * pthrCurrent) - { - _ASSERTE(0 < pthrCurrent->synchronizationInfo.m_lSharedSynchLockCount); - if (0 == --pthrCurrent->synchronizationInfo.m_lSharedSynchLockCount) - { - _ASSERT_MSG(0 < pthrCurrent->synchronizationInfo.m_lLocalSynchLockCount, - "Final release of the shared synch lock while not holding the " - "local one. Local synch lock should always be acquired first and " - "released last.\n"); - SHMRelease(); - } - } - static LONG ResetSharedSynchLock(CPalThread * pthrCurrent) - { - LONG lRet = pthrCurrent->synchronizationInfo.m_lSharedSynchLockCount; - - _ASSERTE(0 <= lRet); - _ASSERTE(0 == lRet || - 0 < pthrCurrent->synchronizationInfo.m_lLocalSynchLockCount); - if (0 < lRet) - { - pthrCurrent->synchronizationInfo.m_lSharedSynchLockCount = 0; - SHMRelease(); - } - return lRet; - } - static LONG GetSharedSynchLockCount(CPalThread * pthrCurrent) - { - _ASSERTE(0 <= pthrCurrent->synchronizationInfo.m_lSharedSynchLockCount); - _ASSERTE(0 == pthrCurrent->synchronizationInfo.m_lSharedSynchLockCount || - 0 < pthrCurrent->synchronizationInfo.m_lLocalSynchLockCount); - return pthrCurrent->synchronizationInfo.m_lSharedSynchLockCount; - } - - CSynchWaitController * CacheGetWaitCtrlr(CPalThread * pthrCurrent) - { - return m_cacheWaitCtrlrs.Get(pthrCurrent); - } - int CacheGetWaitCtrlr( - CPalThread * pthrCurrent, - int n, - CSynchWaitController * prgCtrlrs[]) - { - return m_cacheWaitCtrlrs.Get(pthrCurrent, n, prgCtrlrs); - } - void CacheAddWaitCtrlr( - CPalThread * pthrCurrent, - CSynchWaitController * pCtrlr) - { - m_cacheWaitCtrlrs.Add(pthrCurrent, pCtrlr); - } - CSynchStateController * CacheGetStateCtrlr(CPalThread * pthrCurrent) - { - return m_cacheStateCtrlrs.Get(pthrCurrent); - } - int CacheGetStateCtrlr( - CPalThread * pthrCurrent, - int n, - CSynchStateController * prgCtrlrs[]) - { - return m_cacheStateCtrlrs.Get(pthrCurrent, n, prgCtrlrs); - } - void CacheAddStateCtrlr( - CPalThread * pthrCurrent, - CSynchStateController * pCtrlr) - { - m_cacheStateCtrlrs.Add(pthrCurrent, pCtrlr); - } - - CSynchData * CacheGetLocalSynchData(CPalThread * pthrCurrent) - { - return m_cacheSynchData.Get(pthrCurrent); - } - void CacheAddLocalSynchData( - CPalThread * pthrCurrent, - CSynchData * psdSynchData) - { - m_cacheSynchData.Add(pthrCurrent, psdSynchData); - } - SharedID CacheGetSharedSynchData(CPalThread * pthrCurrent) - { - return m_cacheSHRSynchData.Get(pthrCurrent); - } - void CacheAddSharedSynchData( - CPalThread * pthrCurrent, - SharedID shridSData) - { - m_cacheSHRSynchData.Add(pthrCurrent, shridSData); - } - - WaitingThreadsListNode * CacheGetLocalWTListNode( - CPalThread * pthrCurrent) - { - return m_cacheWTListNodes.Get(pthrCurrent); - } - void CacheAddLocalWTListNode( - CPalThread * pthrCurrent, - WaitingThreadsListNode * pWTLNode) - { - m_cacheWTListNodes.Add(pthrCurrent, pWTLNode); - } - SharedID CacheGetSharedWTListNode(CPalThread * pthrCurrent) - { - return m_cacheSHRWTListNodes.Get(pthrCurrent); - } - void CacheAddSharedWTListNode( - CPalThread * pthrCurrent, - SharedID shridWTLNode) - { - m_cacheSHRWTListNodes.Add(pthrCurrent, shridWTLNode); - } - - ThreadApcInfoNode * CacheGetApcInfoNodes(CPalThread * pthrCurrent) - { - return m_cacheThreadApcInfoNodes.Get(pthrCurrent); - } - void CacheAddApcInfoNodes( - CPalThread * pthrCurrent, - ThreadApcInfoNode * pNode) - { - m_cacheThreadApcInfoNodes.Add(pthrCurrent, pNode); - } - - OwnedObjectsListNode * CacheGetOwnedObjsListNode( - CPalThread * pthrCurrent) - { - return m_cacheOwnedObjectsListNodes.Get(pthrCurrent); - } - void CacheAddOwnedObjsListNode( - CPalThread * pthrCurrent, - OwnedObjectsListNode * pNode) - { - m_cacheOwnedObjectsListNodes.Add(pthrCurrent, pNode); - } - - - // - // IPalSynchronizationManager methods - // - virtual PAL_ERROR BlockThread( - CPalThread *pthrCurrent, - DWORD dwTimeout, - bool fAlertable, - bool fIsSleep, - ThreadWakeupReason *ptwrWakeupReason, - DWORD *pdwSignaledObject); - - virtual PAL_ERROR AbandonObjectsOwnedByThread( - CPalThread *pthrCurrent, - CPalThread *pthrTarget); - - virtual PAL_ERROR GetSynchWaitControllersForObjects( - CPalThread *pthrCurrent, - IPalObject *rgObjects[], - DWORD dwObjectCount, - ISynchWaitController *rgControllers[]); - - virtual PAL_ERROR GetSynchStateControllersForObjects( - CPalThread *pthrCurrent, - IPalObject *rgObjects[], - DWORD dwObjectCount, - ISynchStateController *rgControllers[]); - - virtual PAL_ERROR AllocateObjectSynchData( - CObjectType *potObjectType, - ObjectDomain odObjectDomain, - VOID **ppvSynchData); - - virtual void FreeObjectSynchData( - CObjectType *potObjectType, - ObjectDomain odObjectDomain, - VOID *pvSynchData); - - virtual PAL_ERROR PromoteObjectSynchData( - CPalThread *pthrCurrent, - VOID *pvLocalSynchData, - VOID **ppvSharedSynchData); - - virtual PAL_ERROR CreateSynchStateController( - CPalThread *pthrCurrent, - CObjectType *potObjectType, - VOID *pvSynchData, - ObjectDomain odObjectDomain, - ISynchStateController **ppStateController); - - virtual PAL_ERROR CreateSynchWaitController( - CPalThread *pthrCurrent, - CObjectType *potObjectType, - VOID *pvSynchData, - ObjectDomain odObjectDomain, - ISynchWaitController **ppWaitController); - - virtual PAL_ERROR QueueUserAPC( - CPalThread * pthrCurrent, - CPalThread *pthrTarget, - PAPCFUNC pfnAPC, - ULONG_PTR uptrData); - - virtual PAL_ERROR SendTerminationRequestToWorkerThread(); - - virtual bool AreAPCsPending(CPalThread * pthrTarget); - - virtual PAL_ERROR DispatchPendingAPCs(CPalThread * pthrCurrent); - - virtual void AcquireProcessLock(CPalThread *pthrCurrent); - - virtual void ReleaseProcessLock(CPalThread *pthrCurrent); - - // - // Static helper methods - // - public: - static PAL_ERROR WakeUpLocalThread( - CPalThread * pthrCurrent, - CPalThread * pthrTarget, - ThreadWakeupReason twrWakeupReason, - DWORD dwObjectIndex); - - static PAL_ERROR SignalThreadCondition( - ThreadNativeWaitData * ptnwdNativeWaitData); - - static PAL_ERROR DeferThreadConditionSignaling( - CPalThread * pthrCurrent, - CPalThread * pthrTarget); - - static PAL_ERROR WakeUpRemoteThread( - SharedID shridWLNode); - - static PAL_ERROR DelegateSignalingToRemoteProcess( - CPalThread * pthrCurrent, - DWORD dwTargetProcessId, - SharedID shridSynchData); - - static PAL_ERROR SendMsgToRemoteWorker( - DWORD dwProcessId, - BYTE * pMsg, - int iMsgSize); - - static ThreadWaitInfo * GetThreadWaitInfo( - CPalThread * pthrCurrent); - - // - // The following methods must be called only by a Sync*Controller or - // while holding the required synchronization global locks - // - static void UnsignalRestOfLocalAwakeningWaitAll( - CPalThread * pthrCurrent, - CPalThread * pthrTarget, - WaitingThreadsListNode * pwtlnNode, - CSynchData * psdTgtObjectSynchData); - - static void MarkWaitForDelegatedObjectSignalingInProgress( - CPalThread * pthrCurrent, - WaitingThreadsListNode * pwtlnNode); - - static void UnmarkTWListForDelegatedObjectSignalingInProgress( - CSynchData * pTgtObjectSynchData); - - static PAL_ERROR ThreadNativeWait( - ThreadNativeWaitData * ptnwdNativeWaitData, - DWORD dwTimeout, - ThreadWakeupReason * ptwrWakeupReason, - DWORD * pdwSignaledObject); - - static void ThreadPrepareForShutdown(void); - -#ifndef CORECLR - static bool GetProcessPipeName( - LPSTR pDest, - int iDestSize, - DWORD dwPid); -#endif // !CORECLR - - // - // Non-static helper methods - // - private: - LONG DoMonitorProcesses(CPalThread * pthrCurrent); - - void DiscardMonitoredProcesses(CPalThread * pthrCurrent); - - PAL_ERROR ReadCmdFromProcessPipe( - int iPollTimeout, - SynchWorkerCmd * pswcWorkerCmd, - SharedID * pshridMarshaledData, - DWORD * pdwData); - - PAL_ERROR WakeUpLocalWorkerThread( - SynchWorkerCmd swcWorkerCmd); - - void DiscardAllPendingAPCs( - CPalThread * pthrCurrent, - CPalThread * pthrTarget); - - int ReadBytesFromProcessPipe( - int iTimeout, - BYTE * pRecvBuf, - LONG lBytes); - - bool CreateProcessPipe(); - - PAL_ERROR ShutdownProcessPipe(); - - public: - // - // The following methods must be called only by a Sync*Controller or - // while holding the required synchronization global locks - // - void UnRegisterWait( - CPalThread * pthrCurrent, - ThreadWaitInfo * ptwiWaitInfo, - bool fHaveSharedLock); - - PAL_ERROR RegisterProcessForMonitoring( - CPalThread * pthrCurrent, - CSynchData *psdSynchData, - IPalObject *pProcessObject, - CProcProcessLocalData * pProcLocalData); - - PAL_ERROR UnRegisterProcessForMonitoring( - CPalThread * pthrCurrent, - CSynchData *psdSynchData, - DWORD dwPid); - - // - // Utility static methods, no lock required - // - static bool HasProcessExited( - DWORD dwPid, - DWORD * pdwExitCode, - bool * pfIsActualExitCode); - - static bool InterlockedAwaken( - DWORD *pWaitState, - bool fAlertOnly); - - static PAL_ERROR GetAbsoluteTimeout( - DWORD dwTimeout, - struct timespec * ptsAbsTmo, - BOOL fPreferMonotonicClock); - }; -} - -#endif // _SYNCHMANAGER_HPP_ diff --git a/src/pal/src/synchmgr/wait.cpp b/src/pal/src/synchmgr/wait.cpp deleted file mode 100644 index 31153ae02..000000000 --- a/src/pal/src/synchmgr/wait.cpp +++ /dev/null @@ -1,896 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*++ - - - -Module Name: - - wait.cpp - -Abstract: - - Implementation of waiting functions as described in - the WIN32 API - -Revision History: - - - ---*/ - -#include "pal/thread.hpp" -#include "pal/synchobjects.hpp" -#include "pal/handlemgr.hpp" -#include "pal/event.hpp" -#include "pal/mutex.hpp" -#include "pal/semaphore.hpp" -#include "pal/malloc.hpp" -#include "pal/dbgmsg.h" - -SET_DEFAULT_DEBUG_CHANNEL(SYNC); - -#define MAXIMUM_STACK_WAITOBJ_ARRAY_SIZE (MAXIMUM_WAIT_OBJECTS / 4) - -using namespace CorUnix; - -static PalObjectTypeId sg_rgWaitObjectsIds[] = - { - otiAutoResetEvent, - otiManualResetEvent, - otiMutex, - otiNamedMutex, - otiSemaphore, - otiProcess, - otiThread - }; -static CAllowedObjectTypes sg_aotWaitObject(sg_rgWaitObjectsIds, - sizeof(sg_rgWaitObjectsIds)/sizeof(sg_rgWaitObjectsIds[0])); - -static PalObjectTypeId sg_rgSignalableObjectIds[] = -{ - otiAutoResetEvent, - otiManualResetEvent, - otiMutex, - otiNamedMutex, - otiSemaphore -}; -static CAllowedObjectTypes sg_aotSignalableObject(sg_rgSignalableObjectIds, _countof(sg_rgSignalableObjectIds)); - -/*++ -Function: - WaitForSingleObject - -See MSDN doc. ---*/ -DWORD -PALAPI -WaitForSingleObject(IN HANDLE hHandle, - IN DWORD dwMilliseconds) -{ - DWORD dwRet; - - PERF_ENTRY(WaitForSingleObject); - ENTRY("WaitForSingleObject(hHandle=%p, dwMilliseconds=%u)\n", - hHandle, dwMilliseconds); - - CPalThread * pThread = InternalGetCurrentThread(); - - dwRet = InternalWaitForMultipleObjectsEx(pThread, 1, &hHandle, FALSE, - dwMilliseconds, FALSE); - - LOGEXIT("WaitForSingleObject returns DWORD %u\n", dwRet); - PERF_EXIT(WaitForSingleObject); - return dwRet; -} - - -/*++ -Function: - WaitForSingleObjectPrioritized - -Similar to WaitForSingleObject, except uses a LIFO release policy for waiting threads by prioritizing new waiters (registering -them at the beginning of the wait queue rather than at the end). ---*/ -DWORD -PALAPI -PAL_WaitForSingleObjectPrioritized(IN HANDLE hHandle, - IN DWORD dwMilliseconds) -{ - DWORD dwRet; - - PERF_ENTRY(PAL_WaitForSingleObjectPrioritized); - ENTRY("PAL_WaitForSingleObjectPrioritized(hHandle=%p, dwMilliseconds=%u)\n", - hHandle, dwMilliseconds); - - CPalThread * pThread = InternalGetCurrentThread(); - - dwRet = InternalWaitForMultipleObjectsEx(pThread, 1, &hHandle, FALSE, - dwMilliseconds, FALSE, TRUE /* bPrioritize */); - - LOGEXIT("PAL_WaitForSingleObjectPrioritized returns DWORD %u\n", dwRet); - PERF_EXIT(PAL_WaitForSingleObjectPrioritized); - return dwRet; -} - - -/*++ -Function: - WaitForSingleObjectEx - -See MSDN doc. ---*/ -DWORD -PALAPI -WaitForSingleObjectEx(IN HANDLE hHandle, - IN DWORD dwMilliseconds, - IN BOOL bAlertable) -{ - DWORD dwRet; - - PERF_ENTRY(WaitForSingleObjectEx); - ENTRY("WaitForSingleObjectEx(hHandle=%p, dwMilliseconds=%u, bAlertable=%s)\n", - hHandle, dwMilliseconds, bAlertable ? "TRUE" : "FALSE"); - - CPalThread * pThread = InternalGetCurrentThread(); - - dwRet = InternalWaitForMultipleObjectsEx(pThread, 1, &hHandle, FALSE, - dwMilliseconds, bAlertable); - - LOGEXIT("WaitForSingleObjectEx returns DWORD %u\n", dwRet); - PERF_EXIT(WaitForSingleObjectEx); - return dwRet; -} - - -/*++ -Function: - WaitForMultipleObjects - -See MSDN doc. - ---*/ -DWORD -PALAPI -WaitForMultipleObjects(IN DWORD nCount, - IN CONST HANDLE *lpHandles, - IN BOOL bWaitAll, - IN DWORD dwMilliseconds) -{ - DWORD dwRet; - - PERF_ENTRY(WaitForMultipleObjects); - ENTRY("WaitForMultipleObjects(nCount=%d, lpHandles=%p," - " bWaitAll=%d, dwMilliseconds=%u)\n", - nCount, lpHandles, bWaitAll, dwMilliseconds); - - CPalThread * pThread = InternalGetCurrentThread(); - - dwRet = InternalWaitForMultipleObjectsEx(pThread, nCount, lpHandles, - bWaitAll, dwMilliseconds, FALSE); - - LOGEXIT("WaitForMultipleObjects returns DWORD %u\n", dwRet); - PERF_EXIT(WaitForMultipleObjects); - return dwRet; -} - -/*++ -Function: - WaitForMultipleObjectsEx - -See MSDN doc for info about this function. ---*/ -DWORD -PALAPI -WaitForMultipleObjectsEx(IN DWORD nCount, - IN CONST HANDLE *lpHandles, - IN BOOL bWaitAll, - IN DWORD dwMilliseconds, - IN BOOL bAlertable) -{ - DWORD dwRet; - - PERF_ENTRY(WaitForMultipleObjectsEx); - ENTRY("WaitForMultipleObjectsEx(nCount=%d, lpHandles=%p," - " bWaitAll=%d, dwMilliseconds=%u, bAlertable=%s)\n", - nCount, lpHandles, bWaitAll, dwMilliseconds, bAlertable ? "TRUE" : "FALSE"); - - CPalThread * pThread = InternalGetCurrentThread(); - - dwRet = InternalWaitForMultipleObjectsEx(pThread, nCount, lpHandles, bWaitAll, - dwMilliseconds, bAlertable); - - LOGEXIT("WaitForMultipleObjectsEx returns DWORD %u\n", dwRet); - PERF_EXIT(WaitForMultipleObjectsEx); - return dwRet; -} - -/*++ -Function: - SignalObjectAndWait - -See MSDN doc for info about this function. ---*/ -DWORD -PALAPI -SignalObjectAndWait( - IN HANDLE hObjectToSignal, - IN HANDLE hObjectToWaitOn, - IN DWORD dwMilliseconds, - IN BOOL bAlertable) -{ - PERF_ENTRY(SignalObjectAndWait); - ENTRY( - "SignalObjectAndWait(hObjectToSignal=%p, hObjectToWaitOn=%p, dwMilliseconds=%u, bAlertable=%s)\n", - hObjectToSignal, - hObjectToWaitOn, - dwMilliseconds, - bAlertable ? "TRUE" : "FALSE"); - - CPalThread *thread = InternalGetCurrentThread(); - DWORD result = InternalSignalObjectAndWait(thread, hObjectToSignal, hObjectToWaitOn, dwMilliseconds, bAlertable); - - LOGEXIT("SignalObjectAndWait returns DWORD %u\n", result); - PERF_EXIT(SignalObjectAndWait); - return result; -} - -/*++ -Function: - Sleep - -See MSDN doc. ---*/ -VOID -PALAPI -Sleep(IN DWORD dwMilliseconds) -{ - PERF_ENTRY(Sleep); - ENTRY("Sleep(dwMilliseconds=%u)\n", dwMilliseconds); - - CPalThread * pThread = InternalGetCurrentThread(); - - DWORD internalSleepRet = InternalSleepEx(pThread, dwMilliseconds, FALSE); - - if (internalSleepRet != 0) - { - ERROR("Sleep(dwMilliseconds=%u) failed [error=%u]\n", dwMilliseconds, internalSleepRet); - pThread->SetLastError(internalSleepRet); - } - - LOGEXIT("Sleep returns VOID\n"); - PERF_EXIT(Sleep); -} - - -/*++ -Function: - SleepEx - -See MSDN doc. ---*/ -DWORD -PALAPI -SleepEx(IN DWORD dwMilliseconds, - IN BOOL bAlertable) -{ - DWORD dwRet; - - PERF_ENTRY(SleepEx); - ENTRY("SleepEx(dwMilliseconds=%u, bAlertable=%d)\n", dwMilliseconds, bAlertable); - - CPalThread * pThread = InternalGetCurrentThread(); - - dwRet = InternalSleepEx(pThread, dwMilliseconds, bAlertable); - - LOGEXIT("SleepEx returns DWORD %u\n", dwRet); - PERF_EXIT(SleepEx); - - return dwRet; -} - -/*++ -Function: - QueueUserAPC - -See MSDN doc. ---*/ -DWORD -PALAPI -QueueUserAPC( - PAPCFUNC pfnAPC, - HANDLE hThread, - ULONG_PTR dwData) -{ - CPalThread * pCurrentThread = NULL; - CPalThread * pTargetThread = NULL; - IPalObject * pTargetThreadObject = NULL; - PAL_ERROR palErr; - DWORD dwRet; - - PERF_ENTRY(QueueUserAPC); - ENTRY("QueueUserAPC(pfnAPC=%p, hThread=%p, dwData=%#x)\n", - pfnAPC, hThread, dwData); - - /* NOTE: Windows does not check the validity of pfnAPC, even if it is - NULL. It just does an access violation later on when the APC call - is attempted */ - - pCurrentThread = InternalGetCurrentThread(); - - palErr = InternalGetThreadDataFromHandle( - pCurrentThread, - hThread, - 0, // THREAD_SET_CONTEXT - &pTargetThread, - &pTargetThreadObject - ); - - if (NO_ERROR != palErr) - { - ERROR("Unable to obtain thread data for handle %p (error %x)!\n", - hThread, palErr); - goto QueueUserAPC_exit; - } - - - palErr = g_pSynchronizationManager->QueueUserAPC(pCurrentThread, pTargetThread, - pfnAPC, dwData); - -QueueUserAPC_exit: - if (pTargetThreadObject) - { - pTargetThreadObject->ReleaseReference(pCurrentThread); - } - - dwRet = (NO_ERROR == palErr) ? 1 : 0; - - LOGEXIT("QueueUserAPC returns DWORD %d\n", dwRet); - PERF_EXIT(QueueUserAPC); - return dwRet; -} - -DWORD CorUnix::InternalWaitForMultipleObjectsEx( - CPalThread * pThread, - DWORD nCount, - CONST HANDLE *lpHandles, - BOOL bWaitAll, - DWORD dwMilliseconds, - BOOL bAlertable, - BOOL bPrioritize) -{ - DWORD dwRet = WAIT_FAILED; - PAL_ERROR palErr = NO_ERROR; - int i, iSignaledObjCount, iSignaledObjIndex = -1; - bool fWAll = (bool)bWaitAll, fNeedToBlock = false; - bool fAbandoned = false; - WaitType wtWaitType; - - IPalObject * pIPalObjStackArray[MAXIMUM_STACK_WAITOBJ_ARRAY_SIZE] = { NULL }; - ISynchWaitController * pISyncStackArray[MAXIMUM_STACK_WAITOBJ_ARRAY_SIZE] = { NULL }; - IPalObject ** ppIPalObjs = pIPalObjStackArray; - ISynchWaitController ** ppISyncWaitCtrlrs = pISyncStackArray; - - if ((nCount == 0) || (nCount > MAXIMUM_WAIT_OBJECTS)) - { - ppIPalObjs = NULL; // make delete at the end safe - ppISyncWaitCtrlrs = NULL; // make delete at the end safe - ERROR("Invalid object count=%d [range: 1 to %d]\n", - nCount, MAXIMUM_WAIT_OBJECTS) - pThread->SetLastError(ERROR_INVALID_PARAMETER); - goto WFMOExIntExit; - } - else if (nCount == 1) - { - fWAll = false; // makes no difference when nCount is 1 - wtWaitType = SingleObject; - } - else - { - wtWaitType = fWAll ? MultipleObjectsWaitAll : MultipleObjectsWaitOne; - if (nCount > MAXIMUM_STACK_WAITOBJ_ARRAY_SIZE) - { - ppIPalObjs = InternalNewArray(nCount); - ppISyncWaitCtrlrs = InternalNewArray(nCount); - if ((NULL == ppIPalObjs) || (NULL == ppISyncWaitCtrlrs)) - { - ERROR("Out of memory allocating internal structures\n"); - pThread->SetLastError(ERROR_NOT_ENOUGH_MEMORY); - goto WFMOExIntExit; - } - } - } - - palErr = g_pObjectManager->ReferenceMultipleObjectsByHandleArray(pThread, - (VOID **)lpHandles, - nCount, - &sg_aotWaitObject, - SYNCHRONIZE, - ppIPalObjs); - if (NO_ERROR != palErr) - { - ERROR("Unable to obtain object for some or all of the handles [error=%u]\n", - palErr); - if (palErr == ERROR_INVALID_HANDLE) - pThread->SetLastError(ERROR_INVALID_HANDLE); - else - pThread->SetLastError(ERROR_INTERNAL_ERROR); - goto WFMOExIntExit; - } - - if (nCount > 1) - { - // Check for any cross-process sync objects. "Wait for any" and "wait for all" operations are not supported on - // cross-process sync objects in the PAL. - for (DWORD i = 0; i < nCount; ++i) - { - if (ppIPalObjs[i]->GetObjectType()->GetId() == otiNamedMutex) - { - ERROR("Attempt to wait for any or all handles including a cross-process sync object", ERROR_NOT_SUPPORTED); - pThread->SetLastError(ERROR_NOT_SUPPORTED); - goto WFMOExIntCleanup; - } - } - } - else if (ppIPalObjs[0]->GetObjectType()->GetId() == otiNamedMutex) - { - SharedMemoryProcessDataHeader *processDataHeader = - SharedMemoryProcessDataHeader::PalObject_GetProcessDataHeader(ppIPalObjs[0]); - _ASSERTE(processDataHeader != nullptr); - try - { - MutexTryAcquireLockResult tryAcquireLockResult = - static_cast(processDataHeader->GetData())->TryAcquireLock(dwMilliseconds); - switch (tryAcquireLockResult) - { - case MutexTryAcquireLockResult::AcquiredLock: - dwRet = WAIT_OBJECT_0; - break; - - case MutexTryAcquireLockResult::AcquiredLockButMutexWasAbandoned: - dwRet = WAIT_ABANDONED_0; - break; - - case MutexTryAcquireLockResult::TimedOut: - dwRet = WAIT_TIMEOUT; - break; - - default: - _ASSERTE(false); - break; - } - } - catch (SharedMemoryException ex) - { - pThread->SetLastError(ex.GetErrorCode()); - } - goto WFMOExIntCleanup; - } - - if (fWAll) - { - // For a wait-all operation, check for duplicate wait objects in the array. This just uses a brute-force O(n^2) - // algorithm, but since MAXIMUM_WAIT_OBJECTS is small, the worst case is not so bad, and the average case would involve - // significantly fewer items. - for (DWORD i = 0; i < nCount - 1; ++i) - { - IPalObject *const objectToCheck = ppIPalObjs[i]; - for (DWORD j = i + 1; j < nCount; ++j) - { - if (ppIPalObjs[j] == objectToCheck) - { - ERROR("Duplicate handle provided for a wait-all operation [error=%u]\n", ERROR_INVALID_PARAMETER); - pThread->SetLastError(ERROR_INVALID_PARAMETER); - goto WFMOExIntCleanup; - } - } - } - } - - palErr = g_pSynchronizationManager->GetSynchWaitControllersForObjects( - pThread, ppIPalObjs, nCount, ppISyncWaitCtrlrs); - if (NO_ERROR != palErr) - { - ERROR("Unable to obtain ISynchWaitController interface for some or all " - "of the objects [error=%u]\n", palErr); - pThread->SetLastError(ERROR_INTERNAL_ERROR); - goto WFMOExIntCleanup; - } - - if (bAlertable) - { - // First check for pending APC. We need to do that while holding the global - // synch lock implicitely grabbed by GetSynchWaitControllersForObjects - if (g_pSynchronizationManager->AreAPCsPending(pThread)) - { - // If there is any pending APC we need to release the - // implicit global synch lock before calling into it - for (i = 0; (i < (int)nCount) && (NULL != ppISyncWaitCtrlrs[i]); i++) - { - ppISyncWaitCtrlrs[i]->ReleaseController(); - ppISyncWaitCtrlrs[i] = NULL; - } - palErr = g_pSynchronizationManager->DispatchPendingAPCs(pThread); - if (NO_ERROR == palErr) - { - dwRet = WAIT_IO_COMPLETION; - } - else - { - ASSERT("Awakened for APC, but no APC is pending\n"); - pThread->SetLastError(ERROR_INTERNAL_ERROR); - dwRet = WAIT_FAILED; - } - goto WFMOExIntCleanup; - } - } - - iSignaledObjCount = 0; - iSignaledObjIndex = -1; - for (i=0;i<(int)nCount;i++) - { - bool fValue; - palErr = ppISyncWaitCtrlrs[i]->CanThreadWaitWithoutBlocking(&fValue, &fAbandoned); - if (NO_ERROR != palErr) - { - ERROR("ISynchWaitController::CanThreadWaitWithoutBlocking() failed for " - "%d-th object [handle=%p error=%u]\n", i, lpHandles[i], palErr); - pThread->SetLastError(ERROR_INTERNAL_ERROR); - goto WFMOExIntReleaseControllers; - } - if (fValue) - { - iSignaledObjCount++; - iSignaledObjIndex = i; - if (!fWAll) - break; - } - } - - fNeedToBlock = (iSignaledObjCount == 0) || (fWAll && (iSignaledObjCount < (int)nCount)); - if (!fNeedToBlock) - { - // At least one object signaled, or bWaitAll==TRUE and all object signaled. - // No need to wait, let's unsignal the object(s) and return without blocking - int iStartIdx, iEndIdx; - - if (fWAll) - { - iStartIdx = 0; - iEndIdx = nCount; - } - else - { - iStartIdx = iSignaledObjIndex; - iEndIdx = iStartIdx + 1; - } - - // Unsignal objects - if( iStartIdx < 0 ) - { - ERROR("Buffer underflow due to iStartIdx < 0"); - pThread->SetLastError(ERROR_INTERNAL_ERROR); - dwRet = WAIT_FAILED; - goto WFMOExIntCleanup; - } - for (i = iStartIdx; i < iEndIdx; i++) - { - palErr = ppISyncWaitCtrlrs[i]->ReleaseWaitingThreadWithoutBlocking(); - if (NO_ERROR != palErr) - { - ERROR("ReleaseWaitingThreadWithoutBlocking() failed for %d-th " - "object [handle=%p error=%u]\n", - i, lpHandles[i], palErr); - pThread->SetLastError(palErr); - goto WFMOExIntReleaseControllers; - } - } - - dwRet = (fAbandoned ? WAIT_ABANDONED_0 : WAIT_OBJECT_0); - } - else if (0 == dwMilliseconds) - { - // Not enough objects signaled, but timeout is zero: no actual wait - dwRet = WAIT_TIMEOUT; - fNeedToBlock = false; - } - else - { - // Register the thread for waiting on all objects - for (i=0;i<(int)nCount;i++) - { - palErr = ppISyncWaitCtrlrs[i]->RegisterWaitingThread( - wtWaitType, - i, - (TRUE == bAlertable), - bPrioritize != FALSE); - if (NO_ERROR != palErr) - { - ERROR("RegisterWaitingThread() failed for %d-th object " - "[handle=%p error=%u]\n", i, lpHandles[i], palErr); - pThread->SetLastError(palErr); - goto WFMOExIntReleaseControllers; - } - } - } - -WFMOExIntReleaseControllers: - // Release all controllers before going to sleep - for (i = 0; i < (int)nCount; i++) - { - ppISyncWaitCtrlrs[i]->ReleaseController(); - ppISyncWaitCtrlrs[i] = NULL; - } - if (NO_ERROR != palErr) - goto WFMOExIntCleanup; - - if (fNeedToBlock) - { - ThreadWakeupReason twrWakeupReason; - - // - // Going to sleep - // - palErr = g_pSynchronizationManager->BlockThread(pThread, - dwMilliseconds, - (TRUE == bAlertable), - false, - &twrWakeupReason, - (DWORD *)&iSignaledObjIndex); - // - // Awakened - // - if (NO_ERROR != palErr) - { - ERROR("IPalSynchronizationManager::BlockThread failed for thread " - "pThread=%p [error=%u]\n", pThread, palErr); - pThread->SetLastError(palErr); - goto WFMOExIntCleanup; - } - switch (twrWakeupReason) - { - case WaitSucceeded: - dwRet = WAIT_OBJECT_0; // offset added later - break; - case MutexAbondoned: - dwRet = WAIT_ABANDONED_0; // offset added later - break; - case WaitTimeout: - dwRet = WAIT_TIMEOUT; - break; - case Alerted: - _ASSERT_MSG(bAlertable, - "Awakened for APC from a non-alertable wait\n"); - - dwRet = WAIT_IO_COMPLETION; - palErr = g_pSynchronizationManager->DispatchPendingAPCs(pThread); - - _ASSERT_MSG(NO_ERROR == palErr, - "Awakened for APC, but no APC is pending\n"); - break; - case WaitFailed: - default: - ERROR("Thread %p awakened with some failure\n", pThread); - dwRet = WAIT_FAILED; - break; - } - } - - if (!fWAll && ((WAIT_OBJECT_0 == dwRet) || (WAIT_ABANDONED_0 == dwRet))) - { - _ASSERT_MSG(0 <= iSignaledObjIndex, - "Failed to identify signaled/abandoned object\n"); - _ASSERT_MSG(iSignaledObjIndex >= 0 && nCount > static_cast(iSignaledObjIndex), - "SignaledObjIndex object out of range " - "[index=%d obj_count=%u\n", - iSignaledObjCount, nCount); - - if (iSignaledObjIndex < 0) - { - pThread->SetLastError(ERROR_INTERNAL_ERROR); - dwRet = WAIT_FAILED; - goto WFMOExIntCleanup; - } - dwRet += iSignaledObjIndex; - } - -WFMOExIntCleanup: - for (i = 0; i < (int)nCount; i++) - { - ppIPalObjs[i]->ReleaseReference(pThread); - ppIPalObjs[i] = NULL; - } - -WFMOExIntExit: - if (nCount > MAXIMUM_STACK_WAITOBJ_ARRAY_SIZE) - { - InternalDeleteArray(ppIPalObjs); - InternalDeleteArray(ppISyncWaitCtrlrs); - } - - return dwRet; -} - -DWORD CorUnix::InternalSignalObjectAndWait( - CPalThread *thread, - HANDLE hObjectToSignal, - HANDLE hObjectToWaitOn, - DWORD dwMilliseconds, - BOOL bAlertable) -{ - DWORD result = WAIT_FAILED; - PAL_ERROR palError = NO_ERROR; - IPalObject *objectToSignal = nullptr; - IPalObject *objectToWaitOn = nullptr; - - // Validate and add a reference to the object to signal - palError = - g_pObjectManager->ReferenceObjectByHandle( - thread, - hObjectToSignal, - &sg_aotSignalableObject, - 0, // should be MUTEX_MODIFY_STATE or equivalent for a signalable object, currently ignored (no Win32 security) - &objectToSignal); - if (palError != NO_ERROR) - { - ERROR("Unable to obtain object for handle %p (error %u)!\n", hObjectToSignal, palError); - goto InternalSignalObjectAndWait_Error; - } - - // Validate and add a reference to the object to wait on. Error checking is done before signaling. - palError = - g_pObjectManager->ReferenceObjectByHandle( - thread, - hObjectToWaitOn, - &sg_aotWaitObject, - SYNCHRONIZE, - &objectToWaitOn); - if (palError != NO_ERROR) - { - ERROR("Unable to obtain object for handle %p (error %u)!\n", hObjectToWaitOn, palError); - goto InternalSignalObjectAndWait_Error; - } - - // Signal - switch (objectToSignal->GetObjectType()->GetId()) - { - case otiAutoResetEvent: - case otiManualResetEvent: - palError = InternalSetEvent(thread, hObjectToSignal, true /* fSetEvent */); - break; - - case otiMutex: - case otiNamedMutex: - palError = InternalReleaseMutex(thread, hObjectToSignal); - break; - - case otiSemaphore: - palError = InternalReleaseSemaphore(thread, hObjectToSignal, 1 /* lReleaseCount */, nullptr /* lpPreviousCount */); - break; - - default: - palError = ERROR_INVALID_HANDLE; - break; - } - if (palError != NO_ERROR) - { - ERROR("Unable to signal object for handle %p (error %u)!\n", hObjectToSignal, palError); - goto InternalSignalObjectAndWait_Error; - } - objectToSignal->ReleaseReference(thread); - objectToSignal = nullptr; - - // Wait - result = - InternalWaitForMultipleObjectsEx( - thread, - 1 /* nCount */, - &hObjectToWaitOn, - false /* bWaitAll */, - dwMilliseconds, - bAlertable); - if (result == WAIT_FAILED) - { - ERROR("Unable to wait on object for handle %p (error %u)!\n", hObjectToWaitOn, palError); - goto InternalSignalObjectAndWait_Error; - } - objectToWaitOn->ReleaseReference(thread); - objectToWaitOn = nullptr; - - goto InternalSignalObjectAndWait_Exit; - -InternalSignalObjectAndWait_Error: - if (objectToSignal != nullptr) - { - objectToSignal->ReleaseReference(thread); - } - if (objectToWaitOn != nullptr) - { - objectToWaitOn->ReleaseReference(thread); - } - - if (palError != NO_ERROR) - { - _ASSERTE(result == WAIT_FAILED); - thread->SetLastError(palError); - } - -InternalSignalObjectAndWait_Exit: - LOGEXIT("InternalSignalObjectAndWait returns %u\n", result); - return result; -} - -DWORD CorUnix::InternalSleepEx ( - CPalThread * pThread, - DWORD dwMilliseconds, - BOOL bAlertable) -{ - PAL_ERROR palErr = NO_ERROR; - DWORD dwRet = WAIT_FAILED; - int iSignaledObjIndex; - - TRACE("Sleeping %u ms [bAlertable=%d]", dwMilliseconds, (int)bAlertable); - - if (bAlertable) - { - // In this case do not use AreAPCsPending. In fact, since we are - // not holding the synch lock(s) an APC posting may race with - // AreAPCsPending. - palErr = g_pSynchronizationManager->DispatchPendingAPCs(pThread); - if (NO_ERROR == palErr) - { - return WAIT_IO_COMPLETION; - } - } - - if (dwMilliseconds > 0) - { - ThreadWakeupReason twrWakeupReason; - palErr = g_pSynchronizationManager->BlockThread(pThread, - dwMilliseconds, - (TRUE == bAlertable), - true, - &twrWakeupReason, - (DWORD *)&iSignaledObjIndex); - if (NO_ERROR != palErr) - { - ERROR("IPalSynchronizationManager::BlockThread failed for thread " - "pThread=%p [error=%u]\n", pThread, palErr); - return dwRet; - } - - switch (twrWakeupReason) - { - case WaitSucceeded: - case WaitTimeout: - dwRet = 0; - break; - case Alerted: - _ASSERT_MSG(bAlertable, "Awakened for APC from a non-alertable wait\n"); - - dwRet = WAIT_IO_COMPLETION; - palErr = g_pSynchronizationManager->DispatchPendingAPCs(pThread); - _ASSERT_MSG(NO_ERROR == palErr, "Awakened for APC, but no APC is pending\n"); - - break; - case MutexAbondoned: - ASSERT("Thread %p awakened with reason=MutexAbondoned from a SleepEx\n", pThread); - break; - case WaitFailed: - default: - ERROR("Thread %p awakened with some failure\n", pThread); - break; - } - } - else - { - sched_yield(); - dwRet = 0; - } - - TRACE("Done sleeping %u ms [bAlertable=%d]", dwMilliseconds, (int)bAlertable); - return dwRet; -} - diff --git a/src/pal/src/synchobj/event.cpp b/src/pal/src/synchobj/event.cpp deleted file mode 100644 index 3db9a3a38..000000000 --- a/src/pal/src/synchobj/event.cpp +++ /dev/null @@ -1,545 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*++ - - - -Module Name: - - event.cpp - -Abstract: - - Implementation of event synchronization object as described in - the WIN32 API - -Revision History: - - - ---*/ - -#include "pal/event.hpp" -#include "pal/thread.hpp" -#include "pal/dbgmsg.h" - -using namespace CorUnix; - -/* ------------------- Definitions ------------------------------*/ -SET_DEFAULT_DEBUG_CHANNEL(SYNC); - -CObjectType CorUnix::otManualResetEvent( - otiManualResetEvent, - NULL, // No cleanup routine - NULL, // No initialization routine - 0, // No immutable data - NULL, // No immutable data copy routine - NULL, // No immutable data cleanup routine - 0, // No process local data - NULL, // No process local data cleanup routine - 0, // No shared data - EVENT_ALL_ACCESS, // Currently ignored (no Win32 security) - CObjectType::SecuritySupported, - CObjectType::SecurityInfoNotPersisted, - CObjectType::UnnamedObject, - CObjectType::LocalDuplicationOnly, - CObjectType::WaitableObject, - CObjectType::ObjectCanBeUnsignaled, - CObjectType::ThreadReleaseHasNoSideEffects, - CObjectType::NoOwner - ); - -CObjectType CorUnix::otAutoResetEvent( - otiAutoResetEvent, - NULL, // No cleanup routine - NULL, // No initialization routine - 0, // No immutable data - NULL, // No immutable data copy routine - NULL, // No immutable data cleanup routine - 0, // No process local data - NULL, // No process local data cleanup routine - 0, // No shared data - EVENT_ALL_ACCESS, // Currently ignored (no Win32 security) - CObjectType::SecuritySupported, - CObjectType::SecurityInfoNotPersisted, - CObjectType::UnnamedObject, - CObjectType::LocalDuplicationOnly, - CObjectType::WaitableObject, - CObjectType::ObjectCanBeUnsignaled, - CObjectType::ThreadReleaseAltersSignalCount, - CObjectType::NoOwner - ); - -PalObjectTypeId rgEventIds[] = {otiManualResetEvent, otiAutoResetEvent}; -CAllowedObjectTypes aotEvent(rgEventIds, sizeof(rgEventIds)/sizeof(rgEventIds[0])); - -/*++ -Function: - CreateEventA - -Note: - lpEventAttributes currentely ignored: - -- Win32 object security not supported - -- handles to event objects are not inheritable - -Parameters: - See MSDN doc. ---*/ - -HANDLE -PALAPI -CreateEventA( - IN LPSECURITY_ATTRIBUTES lpEventAttributes, - IN BOOL bManualReset, - IN BOOL bInitialState, - IN LPCSTR lpName) -{ - HANDLE hEvent = NULL; - CPalThread *pthr = NULL; - PAL_ERROR palError; - - PERF_ENTRY(CreateEventA); - ENTRY("CreateEventA(lpEventAttr=%p, bManualReset=%d, bInitialState=%d, lpName=%p (%s)\n", - lpEventAttributes, bManualReset, bInitialState, lpName, lpName?lpName:"NULL"); - - pthr = InternalGetCurrentThread(); - - if (lpName != nullptr) - { - ASSERT("lpName: Cross-process named objects are not supported in PAL"); - palError = ERROR_NOT_SUPPORTED; - } - else - { - palError = InternalCreateEvent( - pthr, - lpEventAttributes, - bManualReset, - bInitialState, - NULL, - &hEvent - ); - } - - // - // We always need to set last error, even on success: - // we need to protect ourselves from the situation - // where last error is set to ERROR_ALREADY_EXISTS on - // entry to the function - // - - pthr->SetLastError(palError); - - LOGEXIT("CreateEventA returns HANDLE %p\n", hEvent); - PERF_EXIT(CreateEventA); - return hEvent; -} - - -/*++ -Function: - CreateEventW - -Note: - lpEventAttributes currentely ignored: - -- Win32 object security not supported - -- handles to event objects are not inheritable - -Parameters: - See MSDN doc. ---*/ - -HANDLE -PALAPI -CreateEventW( - IN LPSECURITY_ATTRIBUTES lpEventAttributes, - IN BOOL bManualReset, - IN BOOL bInitialState, - IN LPCWSTR lpName) -{ - HANDLE hEvent = NULL; - PAL_ERROR palError; - CPalThread *pthr = NULL; - - PERF_ENTRY(CreateEventW); - ENTRY("CreateEventW(lpEventAttr=%p, bManualReset=%d, " - "bInitialState=%d, lpName=%p (%S)\n", lpEventAttributes, bManualReset, - bInitialState, lpName, lpName?lpName:W16_NULLSTRING); - - pthr = InternalGetCurrentThread(); - - palError = InternalCreateEvent( - pthr, - lpEventAttributes, - bManualReset, - bInitialState, - lpName, - &hEvent - ); - - // - // We always need to set last error, even on success: - // we need to protect ourselves from the situation - // where last error is set to ERROR_ALREADY_EXISTS on - // entry to the function - // - - pthr->SetLastError(palError); - - LOGEXIT("CreateEventW returns HANDLE %p\n", hEvent); - PERF_EXIT(CreateEventW); - return hEvent; -} - -/*++ -Function: - CreateEventExW - -Note: - lpEventAttributes and dwDesiredAccess are currently ignored: - -- Win32 object security not supported - -- handles to event objects are not inheritable - -- Access rights are not supported - -Parameters: - See MSDN doc. ---*/ - -HANDLE -PALAPI -CreateEventExW( - IN LPSECURITY_ATTRIBUTES lpEventAttributes, - IN LPCWSTR lpName, - IN DWORD dwFlags, - IN DWORD dwDesiredAccess) -{ - return - CreateEventW( - lpEventAttributes, - (dwFlags & CREATE_EVENT_MANUAL_RESET) != 0, - (dwFlags & CREATE_EVENT_INITIAL_SET) != 0, - lpName); -} - -/*++ -Function: - InternalCreateEvent - -Note: - lpEventAttributes currentely ignored: - -- Win32 object security not supported - -- handles to event objects are not inheritable - -Parameters: - pthr -- thread data for calling thread - phEvent -- on success, receives the allocated event handle - - See MSDN docs on CreateEvent for all other parameters ---*/ - -PAL_ERROR -CorUnix::InternalCreateEvent( - CPalThread *pthr, - LPSECURITY_ATTRIBUTES lpEventAttributes, - BOOL bManualReset, - BOOL bInitialState, - LPCWSTR lpName, - HANDLE *phEvent - ) -{ - CObjectAttributes oa(lpName, lpEventAttributes); - PAL_ERROR palError = NO_ERROR; - IPalObject *pobjEvent = NULL; - IPalObject *pobjRegisteredEvent = NULL; - - _ASSERTE(NULL != pthr); - _ASSERTE(NULL != phEvent); - - ENTRY("InternalCreateEvent(pthr=%p, lpEventAttributes=%p, bManualReset=%i, " - "bInitialState=%i, lpName=%p, phEvent=%p)\n", - pthr, - lpEventAttributes, - bManualReset, - bInitialState, - lpName, - phEvent - ); - - if (lpName != nullptr) - { - ASSERT("lpName: Cross-process named objects are not supported in PAL"); - palError = ERROR_NOT_SUPPORTED; - goto InternalCreateEventExit; - } - - palError = g_pObjectManager->AllocateObject( - pthr, - bManualReset ? &otManualResetEvent : &otAutoResetEvent, - &oa, - &pobjEvent - ); - - if (NO_ERROR != palError) - { - goto InternalCreateEventExit; - } - - if (bInitialState) - { - ISynchStateController *pssc; - - palError = pobjEvent->GetSynchStateController( - pthr, - &pssc - ); - - if (NO_ERROR == palError) - { - palError = pssc->SetSignalCount(1); - pssc->ReleaseController(); - } - - if (NO_ERROR != palError) - { - ASSERT("Unable to set new event state (%d)\n", palError); - goto InternalCreateEventExit; - } - } - - palError = g_pObjectManager->RegisterObject( - pthr, - pobjEvent, - &aotEvent, - EVENT_ALL_ACCESS, // Currently ignored (no Win32 security) - phEvent, - &pobjRegisteredEvent - ); - - // - // pobjEvent is invalidated by the call to RegisterObject, so NULL it - // out here to ensure that we don't try to release a reference on - // it down the line. - // - - pobjEvent = NULL; - -InternalCreateEventExit: - - if (NULL != pobjEvent) - { - pobjEvent->ReleaseReference(pthr); - } - - if (NULL != pobjRegisteredEvent) - { - pobjRegisteredEvent->ReleaseReference(pthr); - } - - LOGEXIT("InternalCreateEvent returns %i\n", palError); - - return palError; -} - - -/*++ -Function: - SetEvent - -See MSDN doc. ---*/ - -BOOL -PALAPI -SetEvent( - IN HANDLE hEvent) -{ - PAL_ERROR palError = NO_ERROR; - CPalThread *pthr = NULL; - - PERF_ENTRY(SetEvent); - ENTRY("SetEvent(hEvent=%p)\n", hEvent); - - pthr = InternalGetCurrentThread(); - - palError = InternalSetEvent(pthr, hEvent, TRUE); - - if (NO_ERROR != palError) - { - pthr->SetLastError(palError); - } - - LOGEXIT("SetEvent returns BOOL %d\n", (NO_ERROR == palError)); - PERF_EXIT(SetEvent); - return (NO_ERROR == palError); -} - - -/*++ -Function: - ResetEvent - -See MSDN doc. ---*/ - -BOOL -PALAPI -ResetEvent( - IN HANDLE hEvent) -{ - PAL_ERROR palError = NO_ERROR; - CPalThread *pthr = NULL; - - PERF_ENTRY(ResetEvent); - ENTRY("ResetEvent(hEvent=%p)\n", hEvent); - - pthr = InternalGetCurrentThread(); - - palError = InternalSetEvent(pthr, hEvent, FALSE); - - if (NO_ERROR != palError) - { - pthr->SetLastError(palError); - } - - LOGEXIT("ResetEvent returns BOOL %d\n", (NO_ERROR == palError)); - PERF_EXIT(ResetEvent); - return (NO_ERROR == palError); -} - -/*++ -Function: - InternalCreateEvent - -Parameters: - pthr -- thread data for calling thread - hEvent -- handle to the event to set - fSetEvent -- if TRUE, set the event; if FALSE, reset it ---*/ - -PAL_ERROR -CorUnix::InternalSetEvent( - CPalThread *pthr, - HANDLE hEvent, - BOOL fSetEvent - ) -{ - PAL_ERROR palError = NO_ERROR; - IPalObject *pobjEvent = NULL; - ISynchStateController *pssc = NULL; - - _ASSERTE(NULL != pthr); - - ENTRY("InternalSetEvent(pthr=%p, hEvent=%p, fSetEvent=%i\n", - pthr, - hEvent, - fSetEvent - ); - - palError = g_pObjectManager->ReferenceObjectByHandle( - pthr, - hEvent, - &aotEvent, - 0, // Should be EVENT_MODIFY_STATE; currently ignored (no Win32 security) - &pobjEvent - ); - - if (NO_ERROR != palError) - { - ERROR("Unable to obtain object for handle %p (error %d)!\n", hEvent, palError); - goto InternalSetEventExit; - } - - palError = pobjEvent->GetSynchStateController( - pthr, - &pssc - ); - - if (NO_ERROR != palError) - { - ASSERT("Error %d obtaining synch state controller\n", palError); - goto InternalSetEventExit; - } - - palError = pssc->SetSignalCount(fSetEvent ? 1 : 0); - - if (NO_ERROR != palError) - { - ASSERT("Error %d setting event state\n", palError); - goto InternalSetEventExit; - } - -InternalSetEventExit: - - if (NULL != pssc) - { - pssc->ReleaseController(); - } - - if (NULL != pobjEvent) - { - pobjEvent->ReleaseReference(pthr); - } - - LOGEXIT("InternalSetEvent returns %d\n", palError); - - return palError; -} - -// TODO: Implementation of OpenEventA() doesn't exist, do we need it? More generally, do we need the A versions at all? - -/*++ -Function: - OpenEventW - -Note: - dwDesiredAccess is currently ignored (no Win32 object security support) - bInheritHandle is currently ignored (handles to events are not inheritable) - -Parameters: - See MSDN doc. ---*/ - -HANDLE -PALAPI -OpenEventW( - IN DWORD dwDesiredAccess, - IN BOOL bInheritHandle, - IN LPCWSTR lpName) -{ - HANDLE hEvent = NULL; - PAL_ERROR palError = NO_ERROR; - CPalThread *pthr = NULL; - - PERF_ENTRY(OpenEventW); - ENTRY("OpenEventW(dwDesiredAccess=%#x, bInheritHandle=%d, lpName=%p (%S))\n", - dwDesiredAccess, bInheritHandle, lpName, lpName?lpName:W16_NULLSTRING); - - pthr = InternalGetCurrentThread(); - - /* validate parameters */ - if (lpName == nullptr) - { - ERROR("name is NULL\n"); - palError = ERROR_INVALID_PARAMETER; - goto OpenEventWExit; - } - else - { - ASSERT("lpName: Cross-process named objects are not supported in PAL"); - palError = ERROR_NOT_SUPPORTED; - } - -OpenEventWExit: - - if (NO_ERROR != palError) - { - pthr->SetLastError(palError); - } - - LOGEXIT("OpenEventW returns HANDLE %p\n", hEvent); - PERF_EXIT(OpenEventW); - - return hEvent; -} \ No newline at end of file diff --git a/src/pal/src/synchobj/mutex.cpp b/src/pal/src/synchobj/mutex.cpp deleted file mode 100644 index d5f4edd11..000000000 --- a/src/pal/src/synchobj/mutex.cpp +++ /dev/null @@ -1,1615 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*++ - - - -Module Name: - - mutex.ccpp - -Abstract: - - Implementation of mutex synchroniztion object as described in - the WIN32 API - -Revision History: - - - ---*/ - -#include "pal/dbgmsg.h" - -SET_DEFAULT_DEBUG_CHANNEL(SYNC); // some headers have code with asserts, so do this first - -#include "pal/mutex.hpp" -#include "pal/file.hpp" -#include "pal/thread.hpp" - -#include "../synchmgr/synchmanager.hpp" - -#include -#include - -#include -#include -#include - -#include "pal/sharedmemory.inl" - -using namespace CorUnix; - -/* ------------------- Definitions ------------------------------*/ - -CObjectType CorUnix::otMutex( - otiMutex, - NULL, // No cleanup routine - NULL, // No initialization routine - 0, // No immutable data - NULL, // No immutable data copy routine - NULL, // No immutable data cleanup routine - 0, // No process local data - NULL, // No process local data cleanup routine - 0, // No shared data - 0, // Should be MUTEX_ALL_ACCESS; currently ignored (no Win32 security) - CObjectType::SecuritySupported, - CObjectType::SecurityInfoNotPersisted, - CObjectType::UnnamedObject, - CObjectType::LocalDuplicationOnly, - CObjectType::WaitableObject, - CObjectType::ObjectCanBeUnsignaled, - CObjectType::ThreadReleaseAltersSignalCount, - CObjectType::OwnershipTracked - ); - -static CAllowedObjectTypes aotMutex(otiMutex); - -CObjectType CorUnix::otNamedMutex( - otiNamedMutex, - &SharedMemoryProcessDataHeader::PalObject_Close, // Cleanup routine - NULL, // No initialization routine - sizeof(SharedMemoryProcessDataHeader *), // Immutable data - NULL, // No immutable data copy routine - NULL, // No immutable data cleanup routine - 0, // No process local data - NULL, // No process local data cleanup routine - 0, // No shared data - 0, // Should be MUTEX_ALL_ACCESS; currently ignored (no Win32 security) - CObjectType::SecuritySupported, - CObjectType::SecurityInfoNotPersisted, - CObjectType::UnnamedObject, // PAL's naming infrastructure is not used - CObjectType::LocalDuplicationOnly, - CObjectType::UnwaitableObject, // PAL's waiting infrastructure is not used - CObjectType::SignalingNotApplicable, // PAL's signaling infrastructure is not used - CObjectType::ThreadReleaseNotApplicable, // PAL's signaling infrastructure is not used - CObjectType::OwnershipNotApplicable // PAL's ownership infrastructure is not used - ); - -static CAllowedObjectTypes aotNamedMutex(otiNamedMutex); - -static PalObjectTypeId anyMutexTypeIds[] = {otiMutex, otiNamedMutex}; -static CAllowedObjectTypes aotAnyMutex(anyMutexTypeIds, _countof(anyMutexTypeIds)); - -/*++ -Function: - CreateMutexA - -Note: - lpMutexAttributes currentely ignored: - -- Win32 object security not supported - -- handles to mutex objects are not inheritable - -Parameters: - See MSDN doc. ---*/ - -HANDLE -PALAPI -CreateMutexA( - IN LPSECURITY_ATTRIBUTES lpMutexAttributes, - IN BOOL bInitialOwner, - IN LPCSTR lpName) -{ - HANDLE hMutex = NULL; - CPalThread *pthr = NULL; - PAL_ERROR palError; - - PERF_ENTRY(CreateMutexA); - ENTRY("CreateMutexA(lpMutexAttr=%p, bInitialOwner=%d, lpName=%p (%s)\n", - lpMutexAttributes, bInitialOwner, lpName, lpName?lpName:"NULL"); - - pthr = InternalGetCurrentThread(); - - palError = InternalCreateMutex( - pthr, - lpMutexAttributes, - bInitialOwner, - lpName, - &hMutex - ); - - // - // We always need to set last error, even on success: - // we need to protect ourselves from the situation - // where last error is set to ERROR_ALREADY_EXISTS on - // entry to the function - // - - pthr->SetLastError(palError); - - LOGEXIT("CreateMutexA returns HANDLE %p\n", hMutex); - PERF_EXIT(CreateMutexA); - return hMutex; -} - - -/*++ -Function: - CreateMutexW - -Note: - lpMutexAttributes currentely ignored: - -- Win32 object security not supported - -- handles to mutex objects are not inheritable - -Parameters: - See MSDN doc. ---*/ - -HANDLE -PALAPI -CreateMutexW( - IN LPSECURITY_ATTRIBUTES lpMutexAttributes, - IN BOOL bInitialOwner, - IN LPCWSTR lpName) -{ - HANDLE hMutex = NULL; - PAL_ERROR palError; - CPalThread *pthr = NULL; - char utf8Name[SHARED_MEMORY_MAX_NAME_CHAR_COUNT + 1]; - - PERF_ENTRY(CreateMutexW); - ENTRY("CreateMutexW(lpMutexAttr=%p, bInitialOwner=%d, lpName=%p (%S)\n", - lpMutexAttributes, bInitialOwner, lpName, lpName?lpName:W16_NULLSTRING); - - pthr = InternalGetCurrentThread(); - - if (lpName != nullptr) - { - int bytesWritten = WideCharToMultiByte(CP_ACP, 0, lpName, -1, utf8Name, _countof(utf8Name), nullptr, nullptr); - if (bytesWritten == 0) - { - DWORD errorCode = GetLastError(); - if (errorCode == ERROR_INSUFFICIENT_BUFFER) - { - palError = static_cast(SharedMemoryError::NameTooLong); - } - else - { - ASSERT("WideCharToMultiByte failed (%u)\n", errorCode); - palError = errorCode; - } - goto CreateMutexWExit; - } - } - - palError = InternalCreateMutex( - pthr, - lpMutexAttributes, - bInitialOwner, - lpName == nullptr ? nullptr : utf8Name, - &hMutex - ); - -CreateMutexWExit: - // - // We always need to set last error, even on success: - // we need to protect ourselves from the situation - // where last error is set to ERROR_ALREADY_EXISTS on - // entry to the function - // - - pthr->SetLastError(palError); - - LOGEXIT("CreateMutexW returns HANDLE %p\n", hMutex); - PERF_EXIT(CreateMutexW); - return hMutex; -} - -/*++ -Function: -CreateMutexW - -Note: -lpMutexAttributes currentely ignored: --- Win32 object security not supported --- handles to mutex objects are not inheritable - -Parameters: -See MSDN doc. ---*/ - -HANDLE -PALAPI -CreateMutexExW( - IN LPSECURITY_ATTRIBUTES lpMutexAttributes, - IN LPCWSTR lpName, - IN DWORD dwFlags, - IN DWORD dwDesiredAccess) -{ - return CreateMutexW(lpMutexAttributes, (dwFlags & CREATE_MUTEX_INITIAL_OWNER) != 0, lpName); -} - -/*++ -Function: - InternalCreateMutex - -Note: - lpMutexAttributes currentely ignored: - -- Win32 object security not supported - -- handles to mutex objects are not inheritable - -Parameters: - pthr -- thread data for calling thread - phEvent -- on success, receives the allocated mutex handle - - See MSDN docs on CreateMutex for all other parameters ---*/ - -PAL_ERROR -CorUnix::InternalCreateMutex( - CPalThread *pthr, - LPSECURITY_ATTRIBUTES lpMutexAttributes, - BOOL bInitialOwner, - LPCSTR lpName, - HANDLE *phMutex - ) -{ - CObjectAttributes oa(nullptr, lpMutexAttributes); - PAL_ERROR palError = NO_ERROR; - IPalObject *pobjMutex = NULL; - IPalObject *pobjRegisteredMutex = NULL; - ISynchStateController *pssc = NULL; - HANDLE hMutex = nullptr; - - _ASSERTE(NULL != pthr); - _ASSERTE(NULL != phMutex); - - ENTRY("InternalCreateMutex(pthr=%p, lpMutexAttributes=%p, bInitialOwner=%d" - ", lpName=%p, phMutex=%p)\n", - pthr, - lpMutexAttributes, - bInitialOwner, - lpName, - phMutex - ); - - if (lpName != nullptr && lpName[0] == '\0') - { - // Empty name is treated as a request for an unnamed process-local mutex - lpName = nullptr; - } - - CObjectType *ot = lpName == nullptr ? &otMutex : &otNamedMutex; - CAllowedObjectTypes *aot = lpName == nullptr ? &aotMutex : &aotNamedMutex; - - palError = g_pObjectManager->AllocateObject( - pthr, - ot, - &oa, - &pobjMutex - ); - - if (NO_ERROR != palError) - { - goto InternalCreateMutexExit; - } - - if (lpName == nullptr) - { - palError = pobjMutex->GetSynchStateController( - pthr, - &pssc - ); - - if (NO_ERROR != palError) - { - ASSERT("Unable to create state controller (%d)\n", palError); - goto InternalCreateMutexExit; - } - - if (bInitialOwner) - { - palError = pssc->SetOwner(pthr); - } - else - { - palError = pssc->SetSignalCount(1); - } - - pssc->ReleaseController(); - - if (NO_ERROR != palError) - { - ASSERT("Unable to set initial mutex state (%d)\n", palError); - goto InternalCreateMutexExit; - } - } - - palError = g_pObjectManager->RegisterObject( - pthr, - pobjMutex, - aot, - 0, // should be MUTEX_ALL_ACCESS -- currently ignored (no Win32 security) - &hMutex, - &pobjRegisteredMutex - ); - - if (palError != NO_ERROR) - { - _ASSERTE(palError != ERROR_ALREADY_EXISTS); // PAL's naming infrastructure is not used for named mutexes - _ASSERTE(pobjRegisteredMutex == nullptr); - _ASSERTE(hMutex == nullptr); - goto InternalCreateMutexExit; - } - - // Now that the object has been registered successfully, it would have a reference associated with the handle, so release - // the initial reference. Any errors from now on need to revoke the handle. - _ASSERTE(pobjRegisteredMutex == pobjMutex); - _ASSERTE(hMutex != nullptr); - pobjMutex->ReleaseReference(pthr); - pobjRegisteredMutex = nullptr; - - if (lpName != nullptr) - { - SharedMemoryProcessDataHeader *processDataHeader; - bool created = false; - try - { - processDataHeader = NamedMutexProcessData::CreateOrOpen(lpName, !!bInitialOwner, &created); - } - catch (SharedMemoryException ex) - { - palError = ex.GetErrorCode(); - goto InternalCreateMutexExit; - } - SharedMemoryProcessDataHeader::PalObject_SetProcessDataHeader(pobjMutex, processDataHeader); - - if (!created) - { - // Indicate to the caller that an existing mutex was opened, and hence the caller will not have initial ownership - // of the mutex if requested through bInitialOwner - palError = ERROR_ALREADY_EXISTS; - } - } - - *phMutex = hMutex; - hMutex = nullptr; - pobjMutex = nullptr; - -InternalCreateMutexExit: - - _ASSERTE(pobjRegisteredMutex == nullptr); - if (hMutex != nullptr) - { - g_pObjectManager->RevokeHandle(pthr, hMutex); - } - else if (NULL != pobjMutex) - { - pobjMutex->ReleaseReference(pthr); - } - - LOGEXIT("InternalCreateMutex returns %i\n", palError); - - return palError; -} - -/*++ -Function: - ReleaseMutex - -Parameters: - See MSDN doc. ---*/ - -BOOL -PALAPI -ReleaseMutex( IN HANDLE hMutex ) -{ - PAL_ERROR palError = NO_ERROR; - CPalThread *pthr = NULL; - - PERF_ENTRY(ReleaseMutex); - ENTRY("ReleaseMutex(hMutex=%p)\n", hMutex); - - pthr = InternalGetCurrentThread(); - - palError = InternalReleaseMutex(pthr, hMutex); - - if (NO_ERROR != palError) - { - pthr->SetLastError(palError); - } - - LOGEXIT("ReleaseMutex returns BOOL %d\n", (NO_ERROR == palError)); - PERF_EXIT(ReleaseMutex); - return (NO_ERROR == palError); -} - -/*++ -Function: - InternalReleaseMutex - -Parameters: - pthr -- thread data for calling thread - - See MSDN docs on ReleaseMutex for all other parameters ---*/ - -PAL_ERROR -CorUnix::InternalReleaseMutex( - CPalThread *pthr, - HANDLE hMutex - ) -{ - PAL_ERROR palError = NO_ERROR; - IPalObject *pobjMutex = NULL; - ISynchStateController *pssc = NULL; - PalObjectTypeId objectTypeId; - - _ASSERTE(NULL != pthr); - - ENTRY("InternalReleaseMutex(pthr=%p, hMutex=%p)\n", - pthr, - hMutex - ); - - palError = g_pObjectManager->ReferenceObjectByHandle( - pthr, - hMutex, - &aotAnyMutex, - 0, // should be MUTEX_MODIFY_STATE -- current ignored (no Win32 security) - &pobjMutex - ); - - if (NO_ERROR != palError) - { - ERROR("Unable to obtain object for handle %p (error %d)!\n", hMutex, palError); - goto InternalReleaseMutexExit; - } - - objectTypeId = pobjMutex->GetObjectType()->GetId(); - if (objectTypeId == otiMutex) - { - palError = pobjMutex->GetSynchStateController( - pthr, - &pssc - ); - - if (NO_ERROR != palError) - { - ASSERT("Error %d obtaining synch state controller\n", palError); - goto InternalReleaseMutexExit; - } - - palError = pssc->DecrementOwnershipCount(); - - if (NO_ERROR != palError) - { - ERROR("Error %d decrementing mutex ownership count\n", palError); - goto InternalReleaseMutexExit; - } - } - else - { - _ASSERTE(objectTypeId == otiNamedMutex); - - SharedMemoryProcessDataHeader *processDataHeader = - SharedMemoryProcessDataHeader::PalObject_GetProcessDataHeader(pobjMutex); - _ASSERTE(processDataHeader != nullptr); - try - { - static_cast(processDataHeader->GetData())->ReleaseLock(); - } - catch (SharedMemoryException ex) - { - palError = ex.GetErrorCode(); - goto InternalReleaseMutexExit; - } - } - -InternalReleaseMutexExit: - - if (NULL != pssc) - { - pssc->ReleaseController(); - } - - if (NULL != pobjMutex) - { - pobjMutex->ReleaseReference(pthr); - } - - LOGEXIT("InternalReleaseMutex returns %i\n", palError); - - return palError; -} - -/*++ -Function: - OpenMutexA - -Note: - dwDesiredAccess is currently ignored (no Win32 object security support) - bInheritHandle is currently ignored (handles to mutexes are not inheritable) - -See MSDN doc. ---*/ - -HANDLE -PALAPI -OpenMutexA ( - IN DWORD dwDesiredAccess, - IN BOOL bInheritHandle, - IN LPCSTR lpName) -{ - HANDLE hMutex = NULL; - CPalThread *pthr = NULL; - PAL_ERROR palError; - - PERF_ENTRY(OpenMutexA); - ENTRY("OpenMutexA(dwDesiredAccess=%#x, bInheritHandle=%d, lpName=%p (%s))\n", - dwDesiredAccess, bInheritHandle, lpName, lpName?lpName:"NULL"); - - pthr = InternalGetCurrentThread(); - - /* validate parameters */ - if (lpName == nullptr) - { - ERROR("name is NULL\n"); - palError = ERROR_INVALID_PARAMETER; - goto OpenMutexAExit; - } - - palError = InternalOpenMutex(pthr, dwDesiredAccess, bInheritHandle, lpName, &hMutex); - -OpenMutexAExit: - if (NO_ERROR != palError) - { - pthr->SetLastError(palError); - } - - LOGEXIT("OpenMutexA returns HANDLE %p\n", hMutex); - PERF_EXIT(OpenMutexA); - return hMutex; -} - -/*++ -Function: - OpenMutexW - -Note: - dwDesiredAccess is currently ignored (no Win32 object security support) - bInheritHandle is currently ignored (handles to mutexes are not inheritable) - -See MSDN doc. ---*/ - -HANDLE -PALAPI -OpenMutexW( - IN DWORD dwDesiredAccess, - IN BOOL bInheritHandle, - IN LPCWSTR lpName) -{ - HANDLE hMutex = NULL; - PAL_ERROR palError = NO_ERROR; - CPalThread *pthr = NULL; - char utf8Name[SHARED_MEMORY_MAX_NAME_CHAR_COUNT + 1]; - - PERF_ENTRY(OpenMutexW); - ENTRY("OpenMutexW(dwDesiredAccess=%#x, bInheritHandle=%d, lpName=%p (%S))\n", - dwDesiredAccess, bInheritHandle, lpName, lpName?lpName:W16_NULLSTRING); - - pthr = InternalGetCurrentThread(); - - /* validate parameters */ - if (lpName == nullptr) - { - ERROR("name is NULL\n"); - palError = ERROR_INVALID_PARAMETER; - goto OpenMutexWExit; - } - - { - int bytesWritten = WideCharToMultiByte(CP_ACP, 0, lpName, -1, utf8Name, _countof(utf8Name), nullptr, nullptr); - if (bytesWritten == 0) - { - DWORD errorCode = GetLastError(); - if (errorCode == ERROR_INSUFFICIENT_BUFFER) - { - palError = static_cast(SharedMemoryError::NameTooLong); - } - else - { - ASSERT("WideCharToMultiByte failed (%u)\n", errorCode); - palError = errorCode; - } - goto OpenMutexWExit; - } - } - - palError = InternalOpenMutex(pthr, dwDesiredAccess, bInheritHandle, lpName == nullptr ? nullptr : utf8Name, &hMutex); - -OpenMutexWExit: - if (NO_ERROR != palError) - { - pthr->SetLastError(palError); - } - - LOGEXIT("OpenMutexW returns HANDLE %p\n", hMutex); - PERF_EXIT(OpenMutexW); - - return hMutex; -} - -/*++ -Function: - InternalOpenMutex - -Note: - dwDesiredAccess is currently ignored (no Win32 object security support) - bInheritHandle is currently ignored (handles to mutexes are not inheritable) - -Parameters: - pthr -- thread data for calling thread - phEvent -- on success, receives the allocated mutex handle - - See MSDN docs on OpenMutex for all other parameters. ---*/ - -PAL_ERROR -CorUnix::InternalOpenMutex( - CPalThread *pthr, - DWORD dwDesiredAccess, - BOOL bInheritHandle, - LPCSTR lpName, - HANDLE *phMutex - ) -{ - CObjectAttributes oa; - PAL_ERROR palError = NO_ERROR; - IPalObject *pobjMutex = NULL; - IPalObject *pobjRegisteredMutex = NULL; - HANDLE hMutex = nullptr; - - _ASSERTE(NULL != pthr); - _ASSERTE(NULL != lpName); - _ASSERTE(NULL != phMutex); - - ENTRY("InternalOpenMutex(pthr=%p, dwDesiredAcces=%d, bInheritHandle=%d, " - "lpName=%p, phMutex=%p)\n", - pthr, - dwDesiredAccess, - bInheritHandle, - lpName, - phMutex - ); - - palError = g_pObjectManager->AllocateObject( - pthr, - &otNamedMutex, - &oa, - &pobjMutex - ); - - if (NO_ERROR != palError) - { - goto InternalOpenMutexExit; - } - - palError = g_pObjectManager->RegisterObject( - pthr, - pobjMutex, - &aotNamedMutex, - dwDesiredAccess, - &hMutex, - &pobjRegisteredMutex - ); - - if (palError != NO_ERROR) - { - _ASSERTE(palError != ERROR_ALREADY_EXISTS); // PAL's naming infrastructure is not used for named mutexes - _ASSERTE(pobjRegisteredMutex == nullptr); - _ASSERTE(hMutex == nullptr); - goto InternalOpenMutexExit; - } - - // Now that the object has been registered successfully, it would have a reference associated with the handle, so release - // the initial reference. Any errors from now on need to revoke the handle. - _ASSERTE(pobjRegisteredMutex == pobjMutex); - _ASSERTE(hMutex != nullptr); - pobjMutex->ReleaseReference(pthr); - pobjRegisteredMutex = nullptr; - - { - SharedMemoryProcessDataHeader *processDataHeader; - try - { - processDataHeader = NamedMutexProcessData::Open(lpName); - } - catch (SharedMemoryException ex) - { - palError = ex.GetErrorCode(); - goto InternalOpenMutexExit; - } - if (processDataHeader == nullptr) - { - palError = ERROR_FILE_NOT_FOUND; - goto InternalOpenMutexExit; - } - SharedMemoryProcessDataHeader::PalObject_SetProcessDataHeader(pobjMutex, processDataHeader); - } - - *phMutex = hMutex; - hMutex = nullptr; - pobjMutex = nullptr; - -InternalOpenMutexExit: - - _ASSERTE(pobjRegisteredMutex == nullptr); - if (hMutex != nullptr) - { - g_pObjectManager->RevokeHandle(pthr, hMutex); - } - else if (NULL != pobjMutex) - { - pobjMutex->ReleaseReference(pthr); - } - - LOGEXIT("InternalCreateMutex returns %i\n", palError); - - return palError; -} - - -/* Basic spinlock implementation */ -void SPINLOCKAcquire (LONG * lock, unsigned int flags) -{ - size_t loop_seed = 1, loop_count = 0; - - if (flags & SYNCSPINLOCK_F_ASYMMETRIC) - { - loop_seed = ((size_t)pthread_self() % 10) + 1; - } - while (InterlockedCompareExchange(lock, 1, 0)) - { - if (!(flags & SYNCSPINLOCK_F_ASYMMETRIC) || (++loop_count % loop_seed)) - { -#if PAL_IGNORE_NORMAL_THREAD_PRIORITY - struct timespec tsSleepTime; - tsSleepTime.tv_sec = 0; - tsSleepTime.tv_nsec = 1; - nanosleep(&tsSleepTime, NULL); -#else - sched_yield(); -#endif - } - } - -} - -void SPINLOCKRelease (LONG * lock) -{ - *lock = 0; -} - -DWORD SPINLOCKTryAcquire (LONG * lock) -{ - return InterlockedCompareExchange(lock, 1, 0); - // only returns 0 or 1. -} - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// MutexHelpers - -#if NAMED_MUTEX_USE_PTHREAD_MUTEX -void MutexHelpers::InitializeProcessSharedRobustRecursiveMutex(pthread_mutex_t *mutex) -{ - _ASSERTE(mutex != nullptr); - - struct AutoCleanup - { - pthread_mutexattr_t *m_mutexAttributes; - - AutoCleanup() : m_mutexAttributes(nullptr) - { - } - - ~AutoCleanup() - { - if (m_mutexAttributes != nullptr) - { - int error = pthread_mutexattr_destroy(m_mutexAttributes); - _ASSERTE(error == 0); - } - } - } autoCleanup; - - pthread_mutexattr_t mutexAttributes; - int error = pthread_mutexattr_init(&mutexAttributes); - if (error != 0) - { - throw SharedMemoryException(static_cast(SharedMemoryError::OutOfMemory)); - } - autoCleanup.m_mutexAttributes = &mutexAttributes; - - error = pthread_mutexattr_setpshared(&mutexAttributes, PTHREAD_PROCESS_SHARED); - _ASSERTE(error == 0); - - error = pthread_mutexattr_setrobust(&mutexAttributes, PTHREAD_MUTEX_ROBUST); - _ASSERTE(error == 0); - - error = pthread_mutexattr_settype(&mutexAttributes, PTHREAD_MUTEX_RECURSIVE); - _ASSERTE(error == 0); - - error = pthread_mutex_init(mutex, &mutexAttributes); - if (error != 0) - { - throw SharedMemoryException(static_cast(error == EPERM ? SharedMemoryError::IO : SharedMemoryError::OutOfMemory)); - } -} - -void MutexHelpers::DestroyMutex(pthread_mutex_t *mutex) -{ - _ASSERTE(mutex != nullptr); - - int error = pthread_mutex_destroy(mutex); - _ASSERTE(error == 0 || error == EBUSY); // the error will be EBUSY if the mutex is locked -} - -MutexTryAcquireLockResult MutexHelpers::TryAcquireLock(pthread_mutex_t *mutex, DWORD timeoutMilliseconds) -{ - _ASSERTE(mutex != nullptr); - - int lockResult; - switch (timeoutMilliseconds) - { - case static_cast(-1): - lockResult = pthread_mutex_lock(mutex); - break; - - case 0: - lockResult = pthread_mutex_trylock(mutex); - break; - - default: - { - struct timespec timeoutTime; - PAL_ERROR palError = CPalSynchronizationManager::GetAbsoluteTimeout(timeoutMilliseconds, &timeoutTime, /*fPreferMonotonicClock*/ FALSE); - _ASSERTE(palError == NO_ERROR); - lockResult = pthread_mutex_timedlock(mutex, &timeoutTime); - break; - } - } - - switch (lockResult) - { - case 0: - return MutexTryAcquireLockResult::AcquiredLock; - - case EBUSY: - _ASSERTE(timeoutMilliseconds == 0); - return MutexTryAcquireLockResult::TimedOut; - - case ETIMEDOUT: - _ASSERTE(timeoutMilliseconds != static_cast(-1)); - _ASSERTE(timeoutMilliseconds != 0); - return MutexTryAcquireLockResult::TimedOut; - - case EOWNERDEAD: - { - int setConsistentResult = pthread_mutex_consistent(mutex); - _ASSERTE(setConsistentResult == 0); - return MutexTryAcquireLockResult::AcquiredLockButMutexWasAbandoned; - } - - case EAGAIN: - throw SharedMemoryException(static_cast(NamedMutexError::MaximumRecursiveLocksReached)); - - default: - throw SharedMemoryException(static_cast(NamedMutexError::Unknown)); - } -} - -void MutexHelpers::ReleaseLock(pthread_mutex_t *mutex) -{ - _ASSERTE(mutex != nullptr); - - int unlockResult = pthread_mutex_unlock(mutex); - _ASSERTE(unlockResult == 0); -} -#endif // NAMED_MUTEX_USE_PTHREAD_MUTEX - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// NamedMutexSharedData - -NamedMutexSharedData::NamedMutexSharedData() - : -#if !NAMED_MUTEX_USE_PTHREAD_MUTEX - m_timedWaiterCount(0), -#endif // !NAMED_MUTEX_USE_PTHREAD_MUTEX - m_lockOwnerProcessId(SharedMemoryHelpers::InvalidProcessId), - m_lockOwnerThreadId(SharedMemoryHelpers::InvalidSharedThreadId), - m_isAbandoned(false) -{ -#if !NAMED_MUTEX_USE_PTHREAD_MUTEX - static_assert_no_msg(sizeof(m_timedWaiterCount) == sizeof(LONG)); // for interlocked operations -#endif // NAMED_MUTEX_USE_PTHREAD_MUTEX - - _ASSERTE(SharedMemoryManager::IsCreationDeletionProcessLockAcquired()); - _ASSERTE(SharedMemoryManager::IsCreationDeletionFileLockAcquired()); - -#if NAMED_MUTEX_USE_PTHREAD_MUTEX - MutexHelpers::InitializeProcessSharedRobustRecursiveMutex(&m_lock); -#endif // NAMED_MUTEX_USE_PTHREAD_MUTEX -} - -NamedMutexSharedData::~NamedMutexSharedData() -{ - _ASSERTE(SharedMemoryManager::IsCreationDeletionProcessLockAcquired()); - _ASSERTE(SharedMemoryManager::IsCreationDeletionFileLockAcquired()); - -#if NAMED_MUTEX_USE_PTHREAD_MUTEX - MutexHelpers::DestroyMutex(&m_lock); -#endif // NAMED_MUTEX_USE_PTHREAD_MUTEX -} - -#if NAMED_MUTEX_USE_PTHREAD_MUTEX -pthread_mutex_t *NamedMutexSharedData::GetLock() -{ - return &m_lock; -} -#else // !NAMED_MUTEX_USE_PTHREAD_MUTEX -bool NamedMutexSharedData::HasAnyTimedWaiters() const -{ - return - InterlockedCompareExchange( - const_cast(reinterpret_cast(&m_timedWaiterCount)), - -1 /* Exchange */, - -1 /* Comparand */) != 0; -} - -void NamedMutexSharedData::IncTimedWaiterCount() -{ - ULONG newValue = InterlockedIncrement(reinterpret_cast(&m_timedWaiterCount)); - if (newValue == 0) - { - throw SharedMemoryException(static_cast(SharedMemoryError::OutOfMemory)); - } -} - -void NamedMutexSharedData::DecTimedWaiterCount() -{ - ULONG newValue = InterlockedDecrement(reinterpret_cast(&m_timedWaiterCount)); - _ASSERTE(newValue + 1 != 0); -} -#endif // NAMED_MUTEX_USE_PTHREAD_MUTEX - -bool NamedMutexSharedData::IsAbandoned() const -{ - _ASSERTE(IsLockOwnedByCurrentThread()); - return m_isAbandoned; -} - -void NamedMutexSharedData::SetIsAbandoned(bool isAbandoned) -{ - _ASSERTE(IsLockOwnedByCurrentThread()); - _ASSERTE(m_isAbandoned != isAbandoned); - - m_isAbandoned = isAbandoned; -} - -bool NamedMutexSharedData::IsLockOwnedByAnyThread() const -{ - return - m_lockOwnerProcessId != SharedMemoryHelpers::InvalidProcessId || - m_lockOwnerThreadId != SharedMemoryHelpers::InvalidSharedThreadId; -} - -bool NamedMutexSharedData::IsLockOwnedByCurrentThread() const -{ - return m_lockOwnerProcessId == GetCurrentProcessId() && m_lockOwnerThreadId == THREADSilentGetCurrentThreadId(); -} - -void NamedMutexSharedData::SetLockOwnerToCurrentThread() -{ - m_lockOwnerProcessId = GetCurrentProcessId(); - _ASSERTE(m_lockOwnerProcessId != SharedMemoryHelpers::InvalidProcessId); - m_lockOwnerThreadId = THREADSilentGetCurrentThreadId(); - _ASSERTE(m_lockOwnerThreadId != SharedMemoryHelpers::InvalidSharedThreadId); -} - -void NamedMutexSharedData::ClearLockOwner() -{ - _ASSERTE(IsLockOwnedByCurrentThread()); - - m_lockOwnerProcessId = SharedMemoryHelpers::InvalidProcessId; - m_lockOwnerThreadId = SharedMemoryHelpers::InvalidSharedThreadId; -} - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// NamedMutexProcessData - -// This value should only be incremented if a non-backward-compatible change to the sync system is made. A process would fail to -// open a mutex created with a different sync system version. -const UINT8 NamedMutexProcessData::SyncSystemVersion = 1; - -const DWORD NamedMutexProcessData::PollLoopMaximumSleepMilliseconds = 100; - -SharedMemoryProcessDataHeader *NamedMutexProcessData::CreateOrOpen(LPCSTR name, bool acquireLockIfCreated, bool *createdRef) -{ - return CreateOrOpen(name, true /* createIfNotExist */, acquireLockIfCreated, createdRef); -} - -SharedMemoryProcessDataHeader *NamedMutexProcessData::Open(LPCSTR name) -{ - return CreateOrOpen(name, false /* createIfNotExist */, false /* acquireLockIfCreated */, nullptr /* createdRef */); -} - -SharedMemoryProcessDataHeader *NamedMutexProcessData::CreateOrOpen( - LPCSTR name, - bool createIfNotExist, - bool acquireLockIfCreated, - bool *createdRef) -{ - _ASSERTE(name != nullptr); - _ASSERTE(createIfNotExist || !acquireLockIfCreated); - - struct AutoCleanup - { - bool m_acquiredCreationDeletionProcessLock; - bool m_acquiredCreationDeletionFileLock; - SharedMemoryProcessDataHeader *m_processDataHeader; - #if !NAMED_MUTEX_USE_PTHREAD_MUTEX - char *m_lockFilePath; - SIZE_T m_sessionDirectoryPathCharCount; - bool m_createdLockFile; - int m_lockFileDescriptor; - #endif // !NAMED_MUTEX_USE_PTHREAD_MUTEX - bool m_cancel; - - AutoCleanup() - : m_acquiredCreationDeletionProcessLock(false), - m_acquiredCreationDeletionFileLock(false), - m_processDataHeader(nullptr), - #if !NAMED_MUTEX_USE_PTHREAD_MUTEX - m_lockFilePath(nullptr), - m_sessionDirectoryPathCharCount(0), - m_createdLockFile(false), - m_lockFileDescriptor(-1), - #endif // !NAMED_MUTEX_USE_PTHREAD_MUTEX - m_cancel(false) - { - } - - ~AutoCleanup() - { - #if !NAMED_MUTEX_USE_PTHREAD_MUTEX - if (!m_cancel) - { - if (m_lockFileDescriptor != -1) - { - SharedMemoryHelpers::CloseFile(m_lockFileDescriptor); - } - - if (m_createdLockFile) - { - _ASSERTE(m_lockFilePath != nullptr); - unlink(m_lockFilePath); - } - - if (m_sessionDirectoryPathCharCount != 0) - { - _ASSERTE(m_lockFilePath != nullptr); - m_lockFilePath[m_sessionDirectoryPathCharCount] = '\0'; - rmdir(m_lockFilePath); - } - } - #endif // !NAMED_MUTEX_USE_PTHREAD_MUTEX - - if (m_acquiredCreationDeletionFileLock) - { - SharedMemoryManager::ReleaseCreationDeletionFileLock(); - } - - if (!m_cancel && m_processDataHeader != nullptr) - { - _ASSERTE(m_acquiredCreationDeletionProcessLock); - m_processDataHeader->DecRefCount(); - } - - if (m_acquiredCreationDeletionProcessLock) - { - SharedMemoryManager::ReleaseCreationDeletionProcessLock(); - } - } - } autoCleanup; - - SharedMemoryManager::AcquireCreationDeletionProcessLock(); - autoCleanup.m_acquiredCreationDeletionProcessLock = true; - - // Create or open the shared memory - bool created; - SharedMemoryProcessDataHeader *processDataHeader = - SharedMemoryProcessDataHeader::CreateOrOpen( - name, - SharedMemorySharedDataHeader(SharedMemoryType::Mutex, SyncSystemVersion), - sizeof(NamedMutexSharedData), - createIfNotExist, - &created); - if (createdRef != nullptr) - { - *createdRef = created; - } - if (created) - { - // If the shared memory file was created, the creation/deletion file lock would have been acquired so that we can - // initialize the shared data - _ASSERTE(SharedMemoryManager::IsCreationDeletionFileLockAcquired()); - autoCleanup.m_acquiredCreationDeletionFileLock = true; - } - if (processDataHeader == nullptr) - { - _ASSERTE(!createIfNotExist); - return nullptr; - } - autoCleanup.m_processDataHeader = processDataHeader; - - if (created) - { - // Initialize the shared data - new(processDataHeader->GetSharedDataHeader()->GetData()) NamedMutexSharedData; - } - - if (processDataHeader->GetData() == nullptr) - { - #if !NAMED_MUTEX_USE_PTHREAD_MUTEX - // Create the lock files directory - char lockFilePath[SHARED_MEMORY_MAX_FILE_PATH_CHAR_COUNT + 1]; - SIZE_T lockFilePathCharCount = - SharedMemoryHelpers::CopyString(lockFilePath, 0, SHARED_MEMORY_LOCK_FILES_DIRECTORY_PATH); - if (created) - { - SharedMemoryHelpers::EnsureDirectoryExists(lockFilePath, true /* isGlobalLockAcquired */); - } - - // Create the session directory - lockFilePath[lockFilePathCharCount++] = '/'; - SharedMemoryId *id = processDataHeader->GetId(); - lockFilePathCharCount = id->AppendSessionDirectoryName(lockFilePath, lockFilePathCharCount); - if (created) - { - SharedMemoryHelpers::EnsureDirectoryExists(lockFilePath, true /* isGlobalLockAcquired */); - autoCleanup.m_lockFilePath = lockFilePath; - autoCleanup.m_sessionDirectoryPathCharCount = lockFilePathCharCount; - } - - // Create or open the lock file - lockFilePath[lockFilePathCharCount++] = '/'; - lockFilePathCharCount = - SharedMemoryHelpers::CopyString(lockFilePath, lockFilePathCharCount, id->GetName(), id->GetNameCharCount()); - int lockFileDescriptor = SharedMemoryHelpers::CreateOrOpenFile(lockFilePath, created); - if (lockFileDescriptor == -1) - { - _ASSERTE(!created); - if (createIfNotExist) - { - throw SharedMemoryException(static_cast(SharedMemoryError::IO)); - } - return nullptr; - } - autoCleanup.m_createdLockFile = created; - autoCleanup.m_lockFileDescriptor = lockFileDescriptor; - #endif // !NAMED_MUTEX_USE_PTHREAD_MUTEX - - // Create the process data - void *processDataBuffer = SharedMemoryHelpers::Alloc(sizeof(NamedMutexProcessData)); - AutoFreeBuffer autoFreeProcessDataBuffer(processDataBuffer); - NamedMutexProcessData *processData = - new(processDataBuffer) - NamedMutexProcessData( - processDataHeader - #if !NAMED_MUTEX_USE_PTHREAD_MUTEX - , - lockFileDescriptor - #endif // !NAMED_MUTEX_USE_PTHREAD_MUTEX - ); - autoFreeProcessDataBuffer.Cancel(); - processDataHeader->SetData(processData); - - // If the mutex was created and if requested, acquire the lock initially while holding the creation/deletion locks - if (created && acquireLockIfCreated) - { - MutexTryAcquireLockResult tryAcquireLockResult = processData->TryAcquireLock(0); - _ASSERTE(tryAcquireLockResult == MutexTryAcquireLockResult::AcquiredLock); - } - } - - autoCleanup.m_cancel = true; - return processDataHeader; -} - -NamedMutexProcessData::NamedMutexProcessData( - SharedMemoryProcessDataHeader *processDataHeader -#if !NAMED_MUTEX_USE_PTHREAD_MUTEX - , - int sharedLockFileDescriptor -#endif // !NAMED_MUTEX_USE_PTHREAD_MUTEX -) - : - m_processDataHeader(processDataHeader), - m_lockCount(0), -#if !NAMED_MUTEX_USE_PTHREAD_MUTEX - m_sharedLockFileDescriptor(sharedLockFileDescriptor), -#endif // !NAMED_MUTEX_USE_PTHREAD_MUTEX - m_lockOwnerThread(nullptr), - m_nextInThreadOwnedNamedMutexList(nullptr) -{ - _ASSERTE(SharedMemoryManager::IsCreationDeletionProcessLockAcquired()); - _ASSERTE(processDataHeader != nullptr); - -#if !NAMED_MUTEX_USE_PTHREAD_MUTEX - _ASSERTE(sharedLockFileDescriptor != -1); - - m_processLockHandle = CreateMutex(nullptr /* lpMutexAttributes */, false /* bInitialOwner */, nullptr /* lpName */); - if (m_processLockHandle == nullptr) - { - throw SharedMemoryException(GetLastError()); - } -#endif // !NAMED_MUTEX_USE_PTHREAD_MUTEX -} - -void NamedMutexProcessData::Close(bool isAbruptShutdown, bool releaseSharedData) -{ - _ASSERTE(SharedMemoryManager::IsCreationDeletionProcessLockAcquired()); - _ASSERTE(!releaseSharedData || SharedMemoryManager::IsCreationDeletionFileLockAcquired()); - - // If the process is shutting down abruptly without having closed some mutexes, there could still be threads running with - // active references to the mutex. So when shutting down abruptly, don't clean up any object or global process-local state. - if (!isAbruptShutdown) - { - CPalThread *lockOwnerThread = m_lockOwnerThread; - if (lockOwnerThread != nullptr) - { - // The mutex was not released before it was closed. If the lock is owned by the current thread, abandon the mutex. - // In both cases, clean up the owner thread's list of owned mutexes. - lockOwnerThread->synchronizationInfo.RemoveOwnedNamedMutex(this); - if (lockOwnerThread == GetCurrentPalThread()) - { - Abandon(); - } - else - { - m_lockOwnerThread = nullptr; - } - } - - if (releaseSharedData) - { - GetSharedData()->~NamedMutexSharedData(); - } - } - -#if !NAMED_MUTEX_USE_PTHREAD_MUTEX - if (!isAbruptShutdown) - { - CloseHandle(m_processLockHandle); - SharedMemoryHelpers::CloseFile(m_sharedLockFileDescriptor); - } - - if (!releaseSharedData) - { - return; - } - - // Delete the lock file, and the session directory if it's not empty - char path[SHARED_MEMORY_MAX_FILE_PATH_CHAR_COUNT + 1]; - SIZE_T sessionDirectoryPathCharCount = SharedMemoryHelpers::CopyString(path, 0, SHARED_MEMORY_LOCK_FILES_DIRECTORY_PATH); - path[sessionDirectoryPathCharCount++] = '/'; - SharedMemoryId *id = m_processDataHeader->GetId(); - sessionDirectoryPathCharCount = id->AppendSessionDirectoryName(path, sessionDirectoryPathCharCount); - path[sessionDirectoryPathCharCount++] = '/'; - SharedMemoryHelpers::CopyString(path, sessionDirectoryPathCharCount, id->GetName(), id->GetNameCharCount()); - unlink(path); - path[sessionDirectoryPathCharCount] = '\0'; - rmdir(path); -#endif // !NAMED_MUTEX_USE_PTHREAD_MUTEX -} - -NamedMutexSharedData *NamedMutexProcessData::GetSharedData() const -{ - return reinterpret_cast(m_processDataHeader->GetSharedDataHeader()->GetData()); -} - -void NamedMutexProcessData::SetLockOwnerThread(CorUnix::CPalThread *lockOwnerThread) -{ - _ASSERTE(lockOwnerThread == nullptr || lockOwnerThread == GetCurrentPalThread()); - _ASSERTE(GetSharedData()->IsLockOwnedByCurrentThread()); - - m_lockOwnerThread = lockOwnerThread; -} - -NamedMutexProcessData *NamedMutexProcessData::GetNextInThreadOwnedNamedMutexList() const -{ - return m_nextInThreadOwnedNamedMutexList; -} - -void NamedMutexProcessData::SetNextInThreadOwnedNamedMutexList(NamedMutexProcessData *next) -{ - m_nextInThreadOwnedNamedMutexList = next; -} - -MutexTryAcquireLockResult NamedMutexProcessData::TryAcquireLock(DWORD timeoutMilliseconds) -{ - NamedMutexSharedData *sharedData = GetSharedData(); - -#if NAMED_MUTEX_USE_PTHREAD_MUTEX - MutexTryAcquireLockResult result = MutexHelpers::TryAcquireLock(sharedData->GetLock(), timeoutMilliseconds); - if (result == MutexTryAcquireLockResult::TimedOut) - { - return result; - } - - // Check if a recursive lock was just taken. The recursion level is tracked manually so that the lock owner can be cleared - // at the appropriate time, see ReleaseLock(). - if (m_lockCount != 0) - { - _ASSERTE(sharedData->IsLockOwnedByCurrentThread()); // otherwise, this thread would not have acquired the lock - _ASSERTE(GetCurrentPalThread()->synchronizationInfo.OwnsNamedMutex(this)); - - if (m_lockCount + 1 < m_lockCount) - { - MutexHelpers::ReleaseLock(sharedData->GetLock()); - throw SharedMemoryException(static_cast(NamedMutexError::MaximumRecursiveLocksReached)); - } - ++m_lockCount; - - // The lock is released upon acquiring a recursive lock from the thread that already owns the lock - MutexHelpers::ReleaseLock(sharedData->GetLock()); - - _ASSERTE(result != MutexTryAcquireLockResult::AcquiredLockButMutexWasAbandoned); - _ASSERTE(!sharedData->IsAbandoned()); - return result; - } - - // The non-recursive case is handled below (skip the #else and see below that) -#else // !NAMED_MUTEX_USE_PTHREAD_MUTEX - // If a timeout is specified, determine the start time - DWORD startTime = 0; - if (timeoutMilliseconds != static_cast(-1) && timeoutMilliseconds != 0) - { - startTime = GetTickCount(); - } - - // Acquire the process lock. A file lock can only be acquired once per file descriptor, so to synchronize the threads of - // this process, the process lock is used. - while (true) - { - DWORD waitResult = WaitForSingleObject(m_processLockHandle, timeoutMilliseconds); - switch (waitResult) - { - case WAIT_OBJECT_0: - case WAIT_ABANDONED: // abandoned state for the process lock is irrelevant, the shared lock will also have been abandoned - break; - - case WAIT_TIMEOUT: - return MutexTryAcquireLockResult::TimedOut; - - case WAIT_IO_COMPLETION: - continue; - - case WAIT_FAILED: - throw SharedMemoryException(GetLastError()); - - default: - _ASSERTE(false); - break; - } - break; - } - - struct AutoReleaseProcessLock - { - HANDLE m_processLockHandle; - bool m_cancel; - - AutoReleaseProcessLock(HANDLE processLockHandle) : m_processLockHandle(processLockHandle), m_cancel(false) - { - } - - ~AutoReleaseProcessLock() - { - if (!m_cancel) - { - ReleaseMutex(m_processLockHandle); - } - } - } autoReleaseProcessLock(m_processLockHandle); - - // Check if it's a recursive lock attempt - if (m_lockCount != 0) - { - _ASSERTE(sharedData->IsLockOwnedByCurrentThread()); // otherwise, this thread would not have acquired the process lock - _ASSERTE(GetCurrentPalThread()->synchronizationInfo.OwnsNamedMutex(this)); - - if (m_lockCount + 1 < m_lockCount) - { - throw SharedMemoryException(static_cast(NamedMutexError::MaximumRecursiveLocksReached)); - } - ++m_lockCount; - - // The process lock is released upon acquiring a recursive lock from the thread that already owns the lock - return MutexTryAcquireLockResult::AcquiredLock; - } - - switch (timeoutMilliseconds) - { - case static_cast(-1): - { - // The file lock API does not have a timeout on the wait, so timed waiters will poll the file lock in a loop, - // sleeping for a short duration in-between. Due to the polling nature of a timed wait, timed waiters will almost - // never acquire the file lock as long as there are also untimed waiters. So, in order to make the file lock - // acquisition reasonable, when there are timed waiters, have untimed waiters also use polling. - bool acquiredFileLock = false; - while (sharedData->HasAnyTimedWaiters()) - { - if (SharedMemoryHelpers::TryAcquireFileLock(m_sharedLockFileDescriptor, LOCK_EX | LOCK_NB)) - { - acquiredFileLock = true; - break; - } - Sleep(PollLoopMaximumSleepMilliseconds); - } - if (acquiredFileLock) - { - break; - } - - acquiredFileLock = SharedMemoryHelpers::TryAcquireFileLock(m_sharedLockFileDescriptor, LOCK_EX); - _ASSERTE(acquiredFileLock); - break; - } - - case 0: - if (!SharedMemoryHelpers::TryAcquireFileLock(m_sharedLockFileDescriptor, LOCK_EX | LOCK_NB)) - { - return MutexTryAcquireLockResult::TimedOut; - } - break; - - default: - { - // Try to acquire the file lock without waiting - if (SharedMemoryHelpers::TryAcquireFileLock(m_sharedLockFileDescriptor, LOCK_EX | LOCK_NB)) - { - break; - } - - // The file lock API does not have a timeout on the wait, so timed waiters need to poll the file lock in a loop, - // sleeping for a short duration in-between. Due to the polling nature of a timed wait, timed waiters will almost - // never acquire the file lock as long as there are also untimed waiters. So, in order to make the file lock - // acquisition reasonable, record that there is a timed waiter, to have untimed waiters also use polling. - sharedData->IncTimedWaiterCount(); - struct AutoDecTimedWaiterCount - { - NamedMutexSharedData *m_sharedData; - - AutoDecTimedWaiterCount(NamedMutexSharedData *sharedData) : m_sharedData(sharedData) - { - } - - ~AutoDecTimedWaiterCount() - { - m_sharedData->DecTimedWaiterCount(); - } - } autoDecTimedWaiterCount(sharedData); - - // Poll for the file lock - do - { - DWORD elapsedMilliseconds = GetTickCount() - startTime; - if (elapsedMilliseconds >= timeoutMilliseconds) - { - return MutexTryAcquireLockResult::TimedOut; - } - - DWORD remainingMilliseconds = timeoutMilliseconds - elapsedMilliseconds; - DWORD sleepMilliseconds = - remainingMilliseconds < PollLoopMaximumSleepMilliseconds - ? remainingMilliseconds - : PollLoopMaximumSleepMilliseconds; - Sleep(sleepMilliseconds); - } while (!SharedMemoryHelpers::TryAcquireFileLock(m_sharedLockFileDescriptor, LOCK_EX | LOCK_NB)); - break; - } - } - - // There cannot be any exceptions after this - autoReleaseProcessLock.m_cancel = true; - - // After acquiring the file lock, if we find that a lock owner is already designated, the process that previously owned the - // lock must have terminated while holding the lock. - MutexTryAcquireLockResult result = - sharedData->IsLockOwnedByAnyThread() - ? MutexTryAcquireLockResult::AcquiredLockButMutexWasAbandoned - : MutexTryAcquireLockResult::AcquiredLock; -#endif // NAMED_MUTEX_USE_PTHREAD_MUTEX - - sharedData->SetLockOwnerToCurrentThread(); - m_lockCount = 1; - CPalThread *currentThread = GetCurrentPalThread(); - SetLockOwnerThread(currentThread); - currentThread->synchronizationInfo.AddOwnedNamedMutex(this); - - if (sharedData->IsAbandoned()) - { - // The thread that previously owned the lock did not release it before exiting - sharedData->SetIsAbandoned(false); - result = MutexTryAcquireLockResult::AcquiredLockButMutexWasAbandoned; - } - return result; -} - -void NamedMutexProcessData::ReleaseLock() -{ - if (!GetSharedData()->IsLockOwnedByCurrentThread()) - { - throw SharedMemoryException(static_cast(NamedMutexError::ThreadHasNotAcquiredMutex)); - } - - _ASSERTE(GetCurrentPalThread()->synchronizationInfo.OwnsNamedMutex(this)); - - _ASSERTE(m_lockCount != 0); - --m_lockCount; - if (m_lockCount != 0) - { - return; - } - - GetCurrentPalThread()->synchronizationInfo.RemoveOwnedNamedMutex(this); - SetLockOwnerThread(nullptr); - ActuallyReleaseLock(); -} - -void NamedMutexProcessData::Abandon() -{ - NamedMutexSharedData *sharedData = GetSharedData(); - _ASSERTE(sharedData->IsLockOwnedByCurrentThread()); - _ASSERTE(m_lockCount != 0); - - sharedData->SetIsAbandoned(true); - m_lockCount = 0; - SetLockOwnerThread(nullptr); - ActuallyReleaseLock(); -} - -void NamedMutexProcessData::ActuallyReleaseLock() -{ - NamedMutexSharedData *sharedData = GetSharedData(); - _ASSERTE(sharedData->IsLockOwnedByCurrentThread()); - _ASSERTE(!GetCurrentPalThread()->synchronizationInfo.OwnsNamedMutex(this)); - _ASSERTE(m_lockCount == 0); - - sharedData->ClearLockOwner(); - -#if NAMED_MUTEX_USE_PTHREAD_MUTEX - MutexHelpers::ReleaseLock(sharedData->GetLock()); -#else // !NAMED_MUTEX_USE_PTHREAD_MUTEX - SharedMemoryHelpers::ReleaseFileLock(m_sharedLockFileDescriptor); - ReleaseMutex(m_processLockHandle); -#endif // NAMED_MUTEX_USE_PTHREAD_MUTEX -} diff --git a/src/pal/src/synchobj/semaphore.cpp b/src/pal/src/synchobj/semaphore.cpp deleted file mode 100644 index 499f84797..000000000 --- a/src/pal/src/synchobj/semaphore.cpp +++ /dev/null @@ -1,599 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*++ - - - -Module Name: - - semaphore.cpp - -Abstract: - - Implementation of the sempahore synchroniztion object as described in - the WIN32 API - -Revision History: - - - ---*/ - -#include "pal/semaphore.hpp" -#include "pal/thread.hpp" -#include "pal/dbgmsg.h" - -using namespace CorUnix; - -/* ------------------- Definitions ------------------------------*/ -SET_DEFAULT_DEBUG_CHANNEL(SYNC); - -CObjectType CorUnix::otSemaphore( - otiSemaphore, - NULL, // No cleanup routine - NULL, // No initialization routine - sizeof(SemaphoreImmutableData), - NULL, // No immutable data copy routine - NULL, // No immutable data cleanup routine - 0, // No process local data - NULL, // No process local data cleanup routine - 0, // No shared data - 0, // Should be SEMAPHORE_ALL_ACCESS; currently ignored (no Win32 security) - CObjectType::SecuritySupported, - CObjectType::SecurityInfoNotPersisted, - CObjectType::UnnamedObject, - CObjectType::LocalDuplicationOnly, - CObjectType::WaitableObject, - CObjectType::ObjectCanBeUnsignaled, - CObjectType::ThreadReleaseAltersSignalCount, - CObjectType::NoOwner - ); - -CAllowedObjectTypes aotSempahore(otiSemaphore); - -/*++ -Function: -CreateSemaphoreExA - -Note: -lpSemaphoreAttributes currently ignored: --- Win32 object security not supported --- handles to semaphore objects are not inheritable - -Parameters: -See MSDN doc. ---*/ - -HANDLE -PALAPI -CreateSemaphoreExA( - IN LPSECURITY_ATTRIBUTES lpSemaphoreAttributes, - IN LONG lInitialCount, - IN LONG lMaximumCount, - IN LPCSTR lpName, - IN /*_Reserved_*/ DWORD dwFlags, - IN DWORD dwDesiredAccess) -{ - // dwFlags is reserved and unused, and dwDesiredAccess is currently - // only ever used as SEMAPHORE_ALL_ACCESS. The other parameters - // all map to CreateSemaphoreA. - _ASSERTE(SEMAPHORE_ALL_ACCESS == dwDesiredAccess); - - return CreateSemaphoreA( - lpSemaphoreAttributes, - lInitialCount, - lMaximumCount, - lpName); -} - -/*++ -Function: - CreateSemaphoreA - -Note: - lpSemaphoreAttributes currently ignored: - -- Win32 object security not supported - -- handles to semaphore objects are not inheritable - -Parameters: - See MSDN doc. ---*/ - -HANDLE -PALAPI -CreateSemaphoreA( - IN LPSECURITY_ATTRIBUTES lpSemaphoreAttributes, - IN LONG lInitialCount, - IN LONG lMaximumCount, - IN LPCSTR lpName) -{ - HANDLE hSemaphore = NULL; - CPalThread *pthr = NULL; - PAL_ERROR palError; - - PERF_ENTRY(CreateSemaphoreA); - ENTRY("CreateSemaphoreA(lpSemaphoreAttributes=%p, lInitialCount=%d, " - "lMaximumCount=%d, lpName=%p (%s))\n", - lpSemaphoreAttributes, lInitialCount, lMaximumCount, lpName, lpName?lpName:"NULL"); - - pthr = InternalGetCurrentThread(); - - if (lpName != nullptr) - { - ASSERT("lpName: Cross-process named objects are not supported in PAL"); - palError = ERROR_NOT_SUPPORTED; - } - else - { - palError = InternalCreateSemaphore( - pthr, - lpSemaphoreAttributes, - lInitialCount, - lMaximumCount, - NULL, - &hSemaphore - ); - } - - // - // We always need to set last error, even on success: - // we need to protect ourselves from the situation - // where last error is set to ERROR_ALREADY_EXISTS on - // entry to the function - // - - pthr->SetLastError(palError); - - LOGEXIT("CreateSemaphoreA returns HANDLE %p\n", hSemaphore); - PERF_EXIT(CreateSemaphoreA); - return hSemaphore; -} - -/*++ -Function: -CreateSemaphoreExW - -Note: -lpSemaphoreAttributes currentely ignored: --- Win32 object security not supported --- handles to semaphore objects are not inheritable - -Parameters: -See MSDN doc. ---*/ - -HANDLE -PALAPI -CreateSemaphoreExW( - IN LPSECURITY_ATTRIBUTES lpSemaphoreAttributes, - IN LONG lInitialCount, - IN LONG lMaximumCount, - IN LPCWSTR lpName, - IN /*_Reserved_*/ DWORD dwFlags, - IN DWORD dwDesiredAccess) -{ - // dwFlags is reserved and unused - - return CreateSemaphoreW( - lpSemaphoreAttributes, - lInitialCount, - lMaximumCount, - lpName); -} - -/*++ -Function: - CreateSemaphoreW - -Note: - lpSemaphoreAttributes currentely ignored: - -- Win32 object security not supported - -- handles to semaphore objects are not inheritable - -Parameters: - See MSDN doc. ---*/ - -HANDLE -PALAPI -CreateSemaphoreW( - IN LPSECURITY_ATTRIBUTES lpSemaphoreAttributes, - IN LONG lInitialCount, - IN LONG lMaximumCount, - IN LPCWSTR lpName) -{ - HANDLE hSemaphore = NULL; - PAL_ERROR palError; - CPalThread *pthr = NULL; - - PERF_ENTRY(CreateSemaphoreW); - ENTRY("CreateSemaphoreW(lpSemaphoreAttributes=%p, lInitialCount=%d, " - "lMaximumCount=%d, lpName=%p (%S))\n", - lpSemaphoreAttributes, lInitialCount, lMaximumCount, - lpName, lpName?lpName:W16_NULLSTRING); - - pthr = InternalGetCurrentThread(); - - palError = InternalCreateSemaphore( - pthr, - lpSemaphoreAttributes, - lInitialCount, - lMaximumCount, - lpName, - &hSemaphore - ); - - // - // We always need to set last error, even on success: - // we need to protect ourselves from the situation - // where last error is set to ERROR_ALREADY_EXISTS on - // entry to the function - // - - pthr->SetLastError(palError); - - LOGEXIT("CreateSemaphoreW returns HANDLE %p\n", hSemaphore); - PERF_EXIT(CreateSemaphoreW); - return hSemaphore; -} - -/*++ -Function: - InternalCreateSemaphore - -Note: - lpSemaphoreAttributes currentely ignored: - -- Win32 object security not supported - -- handles to semaphore objects are not inheritable - -Parameters - pthr -- thread data for calling thread - phEvent -- on success, receives the allocated semaphore handle - - See MSDN docs on CreateSemaphore for all other parameters. ---*/ - -PAL_ERROR -CorUnix::InternalCreateSemaphore( - CPalThread *pthr, - LPSECURITY_ATTRIBUTES lpSemaphoreAttributes, - LONG lInitialCount, - LONG lMaximumCount, - LPCWSTR lpName, - HANDLE *phSemaphore - ) -{ - CObjectAttributes oa(lpName, lpSemaphoreAttributes); - PAL_ERROR palError = NO_ERROR; - IPalObject *pobjSemaphore = NULL; - IPalObject *pobjRegisteredSemaphore = NULL; - SemaphoreImmutableData *pSemaphoreData; - - _ASSERTE(NULL != pthr); - _ASSERTE(NULL != phSemaphore); - - ENTRY("InternalCreateSemaphore(pthr=%p, lpSemaphoreAttributes=%p, " - "lInitialCount=%d, lMaximumCount=%d, lpName=%p, phSemaphore=%p)\n", - pthr, - lpSemaphoreAttributes, - lInitialCount, - lMaximumCount, - lpName, - phSemaphore - ); - - if (lpName != nullptr) - { - ASSERT("lpName: Cross-process named objects are not supported in PAL"); - palError = ERROR_NOT_SUPPORTED; - goto InternalCreateSemaphoreExit; - } - - if (lMaximumCount <= 0) - { - ERROR("lMaximumCount is invalid (%d)\n", lMaximumCount); - palError = ERROR_INVALID_PARAMETER; - goto InternalCreateSemaphoreExit; - } - - if ((lInitialCount < 0) || (lInitialCount > lMaximumCount)) - { - ERROR("lInitialCount is invalid (%d)\n", lInitialCount); - palError = ERROR_INVALID_PARAMETER; - goto InternalCreateSemaphoreExit; - } - - palError = g_pObjectManager->AllocateObject( - pthr, - &otSemaphore, - &oa, - &pobjSemaphore - ); - - if (NO_ERROR != palError) - { - goto InternalCreateSemaphoreExit; - } - - palError = pobjSemaphore->GetImmutableData(reinterpret_cast(&pSemaphoreData)); - - if (NO_ERROR != palError) - { - ASSERT("Error %d obtaining object data\n", palError); - goto InternalCreateSemaphoreExit; - } - - pSemaphoreData->lMaximumCount = lMaximumCount; - - if (0 != lInitialCount) - { - ISynchStateController *pssc; - - palError = pobjSemaphore->GetSynchStateController( - pthr, - &pssc - ); - - if (NO_ERROR == palError) - { - palError = pssc->SetSignalCount(lInitialCount); - pssc->ReleaseController(); - } - - if (NO_ERROR != palError) - { - ASSERT("Unable to set new semaphore state (%d)\n", palError); - goto InternalCreateSemaphoreExit; - } - } - - palError = g_pObjectManager->RegisterObject( - pthr, - pobjSemaphore, - &aotSempahore, - 0, // Should be SEMAPHORE_ALL_ACCESS; currently ignored (no Win32 security) - phSemaphore, - &pobjRegisteredSemaphore - ); - - // - // pobjSemaphore is invalidated by the call to RegisterObject, so NULL it - // out here to ensure that we don't try to release a reference on - // it down the line. - // - - pobjSemaphore = NULL; - -InternalCreateSemaphoreExit: - - if (NULL != pobjSemaphore) - { - pobjSemaphore->ReleaseReference(pthr); - } - - if (NULL != pobjRegisteredSemaphore) - { - pobjRegisteredSemaphore->ReleaseReference(pthr); - } - - LOGEXIT("InternalCreateSemaphore returns %d\n", palError); - - return palError; -} - - -/*++ -Function: - ReleaseSemaphore - -Parameters: - See MSDN doc. ---*/ - -BOOL -PALAPI -ReleaseSemaphore( - IN HANDLE hSemaphore, - IN LONG lReleaseCount, - OUT LPLONG lpPreviousCount) -{ - PAL_ERROR palError = NO_ERROR; - CPalThread *pthr = NULL; - - PERF_ENTRY(ReleaseSemaphore); - ENTRY("ReleaseSemaphore(hSemaphore=%p, lReleaseCount=%d, " - "lpPreviousCount=%p)\n", - hSemaphore, lReleaseCount, lpPreviousCount); - - pthr = InternalGetCurrentThread(); - - palError = InternalReleaseSemaphore( - pthr, - hSemaphore, - lReleaseCount, - lpPreviousCount - ); - - if (NO_ERROR != palError) - { - pthr->SetLastError(palError); - } - - LOGEXIT ("ReleaseSemaphore returns BOOL %d\n", (NO_ERROR == palError)); - PERF_EXIT(ReleaseSemaphore); - return (NO_ERROR == palError); -} - -/*++ -Function: - InternalReleaseSemaphore - -Parameters: - pthr -- thread data for calling thread - - See MSDN docs on ReleaseSemaphore for all other parameters ---*/ - -PAL_ERROR -CorUnix::InternalReleaseSemaphore( - CPalThread *pthr, - HANDLE hSemaphore, - LONG lReleaseCount, - LPLONG lpPreviousCount - ) -{ - PAL_ERROR palError = NO_ERROR; - IPalObject *pobjSemaphore = NULL; - ISynchStateController *pssc = NULL; - SemaphoreImmutableData *pSemaphoreData; - LONG lOldCount; - - _ASSERTE(NULL != pthr); - - ENTRY("InternalReleaseSempahore(pthr=%p, hSemaphore=%p, lReleaseCount=%d, " - "lpPreviousCount=%p)\n", - pthr, - hSemaphore, - lReleaseCount, - lpPreviousCount - ); - - if (0 >= lReleaseCount) - { - palError = ERROR_INVALID_PARAMETER; - goto InternalReleaseSemaphoreExit; - } - - palError = g_pObjectManager->ReferenceObjectByHandle( - pthr, - hSemaphore, - &aotSempahore, - 0, // Should be SEMAPHORE_MODIFY_STATE; currently ignored (no Win32 security) - &pobjSemaphore - ); - - if (NO_ERROR != palError) - { - ERROR("Unable to obtain object for handle %p (error %d)!\n", hSemaphore, palError); - goto InternalReleaseSemaphoreExit; - } - - palError = pobjSemaphore->GetImmutableData(reinterpret_cast(&pSemaphoreData)); - - if (NO_ERROR != palError) - { - ASSERT("Error %d obtaining object data\n", palError); - goto InternalReleaseSemaphoreExit; - } - - palError = pobjSemaphore->GetSynchStateController( - pthr, - &pssc - ); - - if (NO_ERROR != palError) - { - ASSERT("Error %d obtaining synch state controller\n", palError); - goto InternalReleaseSemaphoreExit; - } - - palError = pssc->GetSignalCount(&lOldCount); - - if (NO_ERROR != palError) - { - ASSERT("Error %d obtaining current signal count\n", palError); - goto InternalReleaseSemaphoreExit; - } - - _ASSERTE(lOldCount <= pSemaphoreData->lMaximumCount); - if (lReleaseCount > pSemaphoreData->lMaximumCount - lOldCount) - { - palError = ERROR_TOO_MANY_POSTS; - goto InternalReleaseSemaphoreExit; - } - - palError = pssc->IncrementSignalCount(lReleaseCount); - - if (NO_ERROR != palError) - { - ASSERT("Error %d incrementing signal count\n", palError); - goto InternalReleaseSemaphoreExit; - } - - if (NULL != lpPreviousCount) - { - *lpPreviousCount = lOldCount; - } - -InternalReleaseSemaphoreExit: - - if (NULL != pssc) - { - pssc->ReleaseController(); - } - - if (NULL != pobjSemaphore) - { - pobjSemaphore->ReleaseReference(pthr); - } - - LOGEXIT("InternalReleaseSemaphore returns %d\n", palError); - - return palError; -} - -// TODO: Implementation of OpenSemaphoreA() doesn't exist, do we need it? More generally, do we need the A versions at all? - -/*++ -Function: - OpenSemaphoreW - -Note: - dwDesiredAccess is currently ignored (no Win32 object security support) - bInheritHandle is currently ignored (handles to semaphore are not inheritable) - -Parameters: - See MSDN doc. ---*/ - -HANDLE -PALAPI -OpenSemaphoreW( - IN DWORD dwDesiredAccess, - IN BOOL bInheritHandle, - IN LPCWSTR lpName) -{ - HANDLE hSemaphore = NULL; - PAL_ERROR palError = NO_ERROR; - CPalThread *pthr = NULL; - - PERF_ENTRY(OpenSemaphoreW); - ENTRY("OpenSemaphoreW(dwDesiredAccess=%#x, bInheritHandle=%d, lpName=%p (%S))\n", - dwDesiredAccess, bInheritHandle, lpName, lpName?lpName:W16_NULLSTRING); - - pthr = InternalGetCurrentThread(); - - /* validate parameters */ - if (lpName == nullptr) - { - ERROR("lpName is NULL\n"); - palError = ERROR_INVALID_PARAMETER; - } - else - { - ASSERT("lpName: Cross-process named objects are not supported in PAL"); - palError = ERROR_NOT_SUPPORTED; - } - - if (NO_ERROR != palError) - { - pthr->SetLastError(palError); - } - - LOGEXIT("OpenSemaphoreW returns HANDLE %p\n", hSemaphore); - PERF_EXIT(OpenSemaphoreW); - - return hSemaphore; -} diff --git a/src/pal/src/thread/context.cpp b/src/pal/src/thread/context.cpp deleted file mode 100644 index 12672e86f..000000000 --- a/src/pal/src/thread/context.cpp +++ /dev/null @@ -1,1468 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*++ - - - -Module Name: - - context.c - -Abstract: - - Implementation of GetThreadContext/SetThreadContext/DebugBreak. - There are a lot of architecture specifics here. - - - ---*/ - -#include "pal/dbgmsg.h" -SET_DEFAULT_DEBUG_CHANNEL(THREAD); // some headers have code with asserts, so do this first - -#include "pal/palinternal.h" -#include "pal/context.h" -#include "pal/debug.h" -#include "pal/thread.hpp" -#include "pal/utils.h" -#include "pal/virtual.h" - -#include -#include -#include - -extern PGET_GCMARKER_EXCEPTION_CODE g_getGcMarkerExceptionCode; - -#define CONTEXT_AREA_MASK 0xffff -#ifdef _X86_ -#define CONTEXT_ALL_FLOATING (CONTEXT_FLOATING_POINT | CONTEXT_EXTENDED_REGISTERS) -#elif defined(_AMD64_) -#define CONTEXT_ALL_FLOATING CONTEXT_FLOATING_POINT -#elif defined(_ARM_) -#define CONTEXT_ALL_FLOATING CONTEXT_FLOATING_POINT -#elif defined(_ARM64_) -#define CONTEXT_ALL_FLOATING CONTEXT_FLOATING_POINT -#else -#error Unexpected architecture. -#endif - -#if !HAVE_MACH_EXCEPTIONS - -#ifndef __GLIBC__ -typedef int __ptrace_request; -#endif - -#if HAVE_MACHINE_REG_H -#include -#endif // HAVE_MACHINE_REG_H -#if HAVE_MACHINE_NPX_H -#include -#endif // HAVE_MACHINE_NPX_H - -#if HAVE_PT_REGS -#include -#endif // HAVE_PT_REGS - -#ifdef _AMD64_ -#define ASSIGN_CONTROL_REGS \ - ASSIGN_REG(Rbp) \ - ASSIGN_REG(Rip) \ - ASSIGN_REG(SegCs) \ - ASSIGN_REG(EFlags) \ - ASSIGN_REG(Rsp) \ - -#define ASSIGN_INTEGER_REGS \ - ASSIGN_REG(Rdi) \ - ASSIGN_REG(Rsi) \ - ASSIGN_REG(Rbx) \ - ASSIGN_REG(Rdx) \ - ASSIGN_REG(Rcx) \ - ASSIGN_REG(Rax) \ - ASSIGN_REG(R8) \ - ASSIGN_REG(R9) \ - ASSIGN_REG(R10) \ - ASSIGN_REG(R11) \ - ASSIGN_REG(R12) \ - ASSIGN_REG(R13) \ - ASSIGN_REG(R14) \ - ASSIGN_REG(R15) \ - -#elif defined(_X86_) -#define ASSIGN_CONTROL_REGS \ - ASSIGN_REG(Ebp) \ - ASSIGN_REG(Eip) \ - ASSIGN_REG(SegCs) \ - ASSIGN_REG(EFlags) \ - ASSIGN_REG(Esp) \ - ASSIGN_REG(SegSs) \ - -#define ASSIGN_INTEGER_REGS \ - ASSIGN_REG(Edi) \ - ASSIGN_REG(Esi) \ - ASSIGN_REG(Ebx) \ - ASSIGN_REG(Edx) \ - ASSIGN_REG(Ecx) \ - ASSIGN_REG(Eax) \ - -#elif defined(_ARM_) -#define ASSIGN_CONTROL_REGS \ - ASSIGN_REG(Sp) \ - ASSIGN_REG(Lr) \ - ASSIGN_REG(Pc) \ - ASSIGN_REG(Cpsr) \ - -#define ASSIGN_INTEGER_REGS \ - ASSIGN_REG(R0) \ - ASSIGN_REG(R1) \ - ASSIGN_REG(R2) \ - ASSIGN_REG(R3) \ - ASSIGN_REG(R4) \ - ASSIGN_REG(R5) \ - ASSIGN_REG(R6) \ - ASSIGN_REG(R7) \ - ASSIGN_REG(R8) \ - ASSIGN_REG(R9) \ - ASSIGN_REG(R10) \ - ASSIGN_REG(R11) \ - ASSIGN_REG(R12) -#elif defined(_ARM64_) -#define ASSIGN_CONTROL_REGS \ - ASSIGN_REG(Cpsr) \ - ASSIGN_REG(Fp) \ - ASSIGN_REG(Sp) \ - ASSIGN_REG(Lr) \ - ASSIGN_REG(Pc) - -#define ASSIGN_INTEGER_REGS \ - ASSIGN_REG(X0) \ - ASSIGN_REG(X1) \ - ASSIGN_REG(X2) \ - ASSIGN_REG(X3) \ - ASSIGN_REG(X4) \ - ASSIGN_REG(X5) \ - ASSIGN_REG(X6) \ - ASSIGN_REG(X7) \ - ASSIGN_REG(X8) \ - ASSIGN_REG(X9) \ - ASSIGN_REG(X10) \ - ASSIGN_REG(X11) \ - ASSIGN_REG(X12) \ - ASSIGN_REG(X13) \ - ASSIGN_REG(X14) \ - ASSIGN_REG(X15) \ - ASSIGN_REG(X16) \ - ASSIGN_REG(X17) \ - ASSIGN_REG(X18) \ - ASSIGN_REG(X19) \ - ASSIGN_REG(X20) \ - ASSIGN_REG(X21) \ - ASSIGN_REG(X22) \ - ASSIGN_REG(X23) \ - ASSIGN_REG(X24) \ - ASSIGN_REG(X25) \ - ASSIGN_REG(X26) \ - ASSIGN_REG(X27) \ - ASSIGN_REG(X28) - -#else -#error Don't know how to assign registers on this architecture -#endif - -#define ASSIGN_ALL_REGS \ - ASSIGN_CONTROL_REGS \ - ASSIGN_INTEGER_REGS \ - -/*++ -Function: - CONTEXT_GetRegisters - -Abstract - retrieve the machine registers value of the indicated process. - -Parameter - processId: process ID - lpContext: context structure in which the machine registers value will be returned. -Return - returns TRUE if it succeeds, FALSE otherwise ---*/ -BOOL CONTEXT_GetRegisters(DWORD processId, LPCONTEXT lpContext) -{ -#if HAVE_BSD_REGS_T - int regFd = -1; -#endif // HAVE_BSD_REGS_T - BOOL bRet = FALSE; - - if (processId == GetCurrentProcessId()) - { - CONTEXT_CaptureContext(lpContext); - } - else - { - ucontext_t registers; -#if HAVE_PT_REGS - struct pt_regs ptrace_registers; - if (ptrace((__ptrace_request)PT_GETREGS, processId, (caddr_t) &ptrace_registers, 0) == -1) -#elif HAVE_BSD_REGS_T - struct reg ptrace_registers; - if (PAL_PTRACE(PT_GETREGS, processId, &ptrace_registers, 0) == -1) -#endif - { - ASSERT("Failed ptrace(PT_GETREGS, processId:%d) errno:%d (%s)\n", - processId, errno, strerror(errno)); - } - -#if HAVE_PT_REGS -#define ASSIGN_REG(reg) MCREG_##reg(registers.uc_mcontext) = PTREG_##reg(ptrace_registers); -#elif HAVE_BSD_REGS_T -#define ASSIGN_REG(reg) MCREG_##reg(registers.uc_mcontext) = BSDREG_##reg(ptrace_registers); -#else -#define ASSIGN_REG(reg) - ASSERT("Don't know how to get the context of another process on this platform!"); - return bRet; -#endif - ASSIGN_ALL_REGS -#undef ASSIGN_REG - - CONTEXTFromNativeContext(®isters, lpContext, lpContext->ContextFlags); - } - - bRet = TRUE; -#if HAVE_BSD_REGS_T - if (regFd != -1) - { - close(regFd); - } -#endif // HAVE_BSD_REGS_T - return bRet; -} - -/*++ -Function: - GetThreadContext - -See MSDN doc. ---*/ -BOOL -CONTEXT_GetThreadContext( - DWORD dwProcessId, - pthread_t self, - LPCONTEXT lpContext) -{ - BOOL ret = FALSE; - - if (lpContext == NULL) - { - ERROR("Invalid lpContext parameter value\n"); - SetLastError(ERROR_NOACCESS); - goto EXIT; - } - - /* How to consider the case when self is different from the current - thread of its owner process. Machine registers values could be retreived - by a ptrace(pid, ...) call or from the "/proc/%pid/reg" file content. - Unfortunately, these two methods only depend on process ID, not on - thread ID. */ - - if (dwProcessId == GetCurrentProcessId()) - { - if (self != pthread_self()) - { - DWORD flags; - // There aren't any APIs for this. We can potentially get the - // context of another thread by using per-thread signals, but - // on FreeBSD signal handlers that are called as a result - // of signals raised via pthread_kill don't get a valid - // sigcontext or ucontext_t. But we need this to return TRUE - // to avoid an assertion in the CLR in code that manages to - // cope reasonably well without a valid thread context. - // Given that, we'll zero out our structure and return TRUE. - ERROR("GetThreadContext on a thread other than the current " - "thread is returning TRUE\n"); - flags = lpContext->ContextFlags; - memset(lpContext, 0, sizeof(*lpContext)); - lpContext->ContextFlags = flags; - ret = TRUE; - goto EXIT; - } - - } - - if (lpContext->ContextFlags & - (CONTEXT_CONTROL | CONTEXT_INTEGER) & CONTEXT_AREA_MASK) - { - if (CONTEXT_GetRegisters(dwProcessId, lpContext) == FALSE) - { - SetLastError(ERROR_INTERNAL_ERROR); - goto EXIT; - } - } - - ret = TRUE; - -EXIT: - return ret; -} - -/*++ -Function: - SetThreadContext - -See MSDN doc. ---*/ -BOOL -CONTEXT_SetThreadContext( - DWORD dwProcessId, - pthread_t self, - CONST CONTEXT *lpContext) -{ - BOOL ret = FALSE; - -#if HAVE_PT_REGS - struct pt_regs ptrace_registers; -#elif HAVE_BSD_REGS_T - struct reg ptrace_registers; -#endif - - if (lpContext == NULL) - { - ERROR("Invalid lpContext parameter value\n"); - SetLastError(ERROR_NOACCESS); - goto EXIT; - } - - /* How to consider the case when self is different from the current - thread of its owner process. Machine registers values could be retreived - by a ptrace(pid, ...) call or from the "/proc/%pid/reg" file content. - Unfortunately, these two methods only depend on process ID, not on - thread ID. */ - - if (dwProcessId == GetCurrentProcessId()) - { -#ifdef FEATURE_PAL_SXS - // Need to implement SetThreadContext(current thread) for the IX architecture; look at common_signal_handler. - _ASSERT(FALSE); -#endif // FEATURE_PAL_SXS - ASSERT("SetThreadContext should be called for cross-process only.\n"); - SetLastError(ERROR_INVALID_PARAMETER); - goto EXIT; - } - - if (lpContext->ContextFlags & - (CONTEXT_CONTROL | CONTEXT_INTEGER) & CONTEXT_AREA_MASK) - { -#if HAVE_PT_REGS - if (ptrace((__ptrace_request)PT_GETREGS, dwProcessId, (caddr_t)&ptrace_registers, 0) == -1) -#elif HAVE_BSD_REGS_T - if (PAL_PTRACE(PT_GETREGS, dwProcessId, &ptrace_registers, 0) == -1) -#endif - { - ASSERT("Failed ptrace(PT_GETREGS, processId:%d) errno:%d (%s)\n", - dwProcessId, errno, strerror(errno)); - SetLastError(ERROR_INTERNAL_ERROR); - goto EXIT; - } - -#if HAVE_PT_REGS -#define ASSIGN_REG(reg) PTREG_##reg(ptrace_registers) = lpContext->reg; -#elif HAVE_BSD_REGS_T -#define ASSIGN_REG(reg) BSDREG_##reg(ptrace_registers) = lpContext->reg; -#else -#define ASSIGN_REG(reg) - ASSERT("Don't know how to set the context of another process on this platform!"); - return FALSE; -#endif - if (lpContext->ContextFlags & CONTEXT_CONTROL & CONTEXT_AREA_MASK) - { - ASSIGN_CONTROL_REGS - } - if (lpContext->ContextFlags & CONTEXT_INTEGER & CONTEXT_AREA_MASK) - { - ASSIGN_INTEGER_REGS - } -#undef ASSIGN_REG - -#if HAVE_PT_REGS - if (ptrace((__ptrace_request)PT_SETREGS, dwProcessId, (caddr_t)&ptrace_registers, 0) == -1) -#elif HAVE_BSD_REGS_T - if (PAL_PTRACE(PT_SETREGS, dwProcessId, &ptrace_registers, 0) == -1) -#endif - { - ASSERT("Failed ptrace(PT_SETREGS, processId:%d) errno:%d (%s)\n", - dwProcessId, errno, strerror(errno)); - SetLastError(ERROR_INTERNAL_ERROR); - goto EXIT; - } - } - - ret = TRUE; - EXIT: - return ret; -} - -/*++ -Function : - CONTEXTToNativeContext - - Converts a CONTEXT record to a native context. - -Parameters : - CONST CONTEXT *lpContext : CONTEXT to convert - native_context_t *native : native context to fill in - -Return value : - None - ---*/ -void CONTEXTToNativeContext(CONST CONTEXT *lpContext, native_context_t *native) -{ -#define ASSIGN_REG(reg) MCREG_##reg(native->uc_mcontext) = lpContext->reg; - if ((lpContext->ContextFlags & CONTEXT_CONTROL) == CONTEXT_CONTROL) - { - ASSIGN_CONTROL_REGS - } - - if ((lpContext->ContextFlags & CONTEXT_INTEGER) == CONTEXT_INTEGER) - { - ASSIGN_INTEGER_REGS - } -#undef ASSIGN_REG - -#if HAVE_GREGSET_T || HAVE_GREGSET_T -#if HAVE_GREGSET_T - if (native->uc_mcontext.fpregs == nullptr) -#elif HAVE___GREGSET_T - if (native->uc_mcontext.__fpregs == nullptr) -#endif - { - // If the pointer to the floating point state in the native context - // is not valid, we can't copy floating point registers regardless of - // whether CONTEXT_FLOATING_POINT is set in the CONTEXT's flags. - return; - } -#endif - - if ((lpContext->ContextFlags & CONTEXT_FLOATING_POINT) == CONTEXT_FLOATING_POINT) - { -#ifdef _AMD64_ - FPREG_ControlWord(native) = lpContext->FltSave.ControlWord; - FPREG_StatusWord(native) = lpContext->FltSave.StatusWord; - FPREG_TagWord(native) = lpContext->FltSave.TagWord; - FPREG_ErrorOffset(native) = lpContext->FltSave.ErrorOffset; - FPREG_ErrorSelector(native) = lpContext->FltSave.ErrorSelector; - FPREG_DataOffset(native) = lpContext->FltSave.DataOffset; - FPREG_DataSelector(native) = lpContext->FltSave.DataSelector; - FPREG_MxCsr(native) = lpContext->FltSave.MxCsr; - FPREG_MxCsr_Mask(native) = lpContext->FltSave.MxCsr_Mask; - - for (int i = 0; i < 8; i++) - { - FPREG_St(native, i) = lpContext->FltSave.FloatRegisters[i]; - } - - for (int i = 0; i < 16; i++) - { - FPREG_Xmm(native, i) = lpContext->FltSave.XmmRegisters[i]; - } -#endif - } - - // TODO: Enable for all Unix systems -#if defined(_AMD64_) && defined(XSTATE_SUPPORTED) - if ((lpContext->ContextFlags & CONTEXT_XSTATE) == CONTEXT_XSTATE) - { - _ASSERTE(FPREG_HasYmmRegisters(native)); - memcpy_s(FPREG_Xstate_Ymmh(native), sizeof(M128A) * 16, lpContext->VectorRegister, sizeof(M128A) * 16); - } -#endif //_AMD64_ && XSTATE_SUPPORTED -} - -/*++ -Function : - CONTEXTFromNativeContext - - Converts a native context to a CONTEXT record. - -Parameters : - const native_context_t *native : native context to convert - LPCONTEXT lpContext : CONTEXT to fill in - ULONG contextFlags : flags that determine which registers are valid in - native and which ones to set in lpContext - -Return value : - None - ---*/ -void CONTEXTFromNativeContext(const native_context_t *native, LPCONTEXT lpContext, - ULONG contextFlags) -{ - lpContext->ContextFlags = contextFlags; - -#define ASSIGN_REG(reg) lpContext->reg = MCREG_##reg(native->uc_mcontext); - if ((contextFlags & CONTEXT_CONTROL) == CONTEXT_CONTROL) - { - ASSIGN_CONTROL_REGS -#if defined(_ARM_) - // WinContext assumes that the least bit of Pc is always 1 (denoting thumb) - // although the pc value retrived from native context might not have set the least bit. - // This becomes especially problematic if the context is on the JIT_WRITEBARRIER. - lpContext->Pc |= 0x1; -#endif - } - - if ((contextFlags & CONTEXT_INTEGER) == CONTEXT_INTEGER) - { - ASSIGN_INTEGER_REGS - } -#undef ASSIGN_REG - -#if HAVE_GREGSET_T || HAVE___GREGSET_T -#if HAVE_GREGSET_T - if (native->uc_mcontext.fpregs == nullptr) -#elif HAVE___GREGSET_T - if (native->uc_mcontext.__fpregs == nullptr) -#endif - { - // Reset the CONTEXT_FLOATING_POINT bit(s) and the CONTEXT_XSTATE bit(s) so it's - // clear that the floating point and extended state data in the CONTEXT is not - // valid. Since these flags are defined as the architecture bit(s) OR'd with one - // or more other bits, we first get the bits that are unique to each by resetting - // the architecture bits. We determine what those are by inverting the union of - // CONTEXT_CONTROL and CONTEXT_INTEGER, both of which should also have the - // architecture bit(s) set. - const ULONG floatingPointFlags = CONTEXT_FLOATING_POINT & ~(CONTEXT_CONTROL & CONTEXT_INTEGER); - const ULONG xstateFlags = CONTEXT_XSTATE & ~(CONTEXT_CONTROL & CONTEXT_INTEGER); - - lpContext->ContextFlags &= ~(floatingPointFlags | xstateFlags); - - // Bail out regardless of whether the caller wanted CONTEXT_FLOATING_POINT or CONTEXT_XSTATE - return; - } -#endif - - if ((contextFlags & CONTEXT_FLOATING_POINT) == CONTEXT_FLOATING_POINT) - { -#ifdef _AMD64_ - lpContext->FltSave.ControlWord = FPREG_ControlWord(native); - lpContext->FltSave.StatusWord = FPREG_StatusWord(native); - lpContext->FltSave.TagWord = FPREG_TagWord(native); - lpContext->FltSave.ErrorOffset = FPREG_ErrorOffset(native); - lpContext->FltSave.ErrorSelector = FPREG_ErrorSelector(native); - lpContext->FltSave.DataOffset = FPREG_DataOffset(native); - lpContext->FltSave.DataSelector = FPREG_DataSelector(native); - lpContext->FltSave.MxCsr = FPREG_MxCsr(native); - lpContext->FltSave.MxCsr_Mask = FPREG_MxCsr_Mask(native); - - for (int i = 0; i < 8; i++) - { - lpContext->FltSave.FloatRegisters[i] = FPREG_St(native, i); - } - - for (int i = 0; i < 16; i++) - { - lpContext->FltSave.XmmRegisters[i] = FPREG_Xmm(native, i); - } -#endif - } - -#ifdef _AMD64_ - if ((contextFlags & CONTEXT_XSTATE) == CONTEXT_XSTATE) - { - // TODO: Enable for all Unix systems -#if XSTATE_SUPPORTED - if (FPREG_HasYmmRegisters(native)) - { - memcpy_s(lpContext->VectorRegister, sizeof(M128A) * 16, FPREG_Xstate_Ymmh(native), sizeof(M128A) * 16); - } - else -#endif // XSTATE_SUPPORTED - { - // Reset the CONTEXT_XSTATE bit(s) so it's clear that the extended state data in - // the CONTEXT is not valid. - const ULONG xstateFlags = CONTEXT_XSTATE & ~(CONTEXT_CONTROL & CONTEXT_INTEGER); - lpContext->ContextFlags &= ~xstateFlags; - } - } -#endif // _AMD64_ -} - -/*++ -Function : - GetNativeContextPC - - Returns the program counter from the native context. - -Parameters : - const native_context_t *native : native context - -Return value : - The program counter from the native context. - ---*/ -LPVOID GetNativeContextPC(const native_context_t *context) -{ -#ifdef _AMD64_ - return (LPVOID)MCREG_Rip(context->uc_mcontext); -#elif defined(_X86_) - return (LPVOID) MCREG_Eip(context->uc_mcontext); -#elif defined(_ARM_) - return (LPVOID) MCREG_Pc(context->uc_mcontext); -#elif defined(_ARM64_) - return (LPVOID) MCREG_Pc(context->uc_mcontext); -#else -# error implement me for this architecture -#endif -} - -/*++ -Function : - GetNativeContextSP - - Returns the stack pointer from the native context. - -Parameters : - const native_context_t *native : native context - -Return value : - The stack pointer from the native context. - ---*/ -LPVOID GetNativeContextSP(const native_context_t *context) -{ -#ifdef _AMD64_ - return (LPVOID)MCREG_Rsp(context->uc_mcontext); -#elif defined(_X86_) - return (LPVOID) MCREG_Esp(context->uc_mcontext); -#elif defined(_ARM_) - return (LPVOID) MCREG_Sp(context->uc_mcontext); -#elif defined(_ARM64_) - return (LPVOID) MCREG_Sp(context->uc_mcontext); -#else -# error implement me for this architecture -#endif -} - - -/*++ -Function : - CONTEXTGetExceptionCodeForSignal - - Translates signal and context information to a Win32 exception code. - -Parameters : - const siginfo_t *siginfo : signal information from a signal handler - const native_context_t *context : context information - -Return value : - The Win32 exception code that corresponds to the signal and context - information. - ---*/ -#ifdef ILL_ILLOPC -// If si_code values are available for all signals, use those. -DWORD CONTEXTGetExceptionCodeForSignal(const siginfo_t *siginfo, - const native_context_t *context) -{ - // IMPORTANT NOTE: This function must not call any signal unsafe functions - // since it is called from signal handlers. - // That includes ASSERT and TRACE macros. - - switch (siginfo->si_signo) - { - case SIGILL: - switch (siginfo->si_code) - { - case ILL_ILLOPC: // Illegal opcode - case ILL_ILLOPN: // Illegal operand - case ILL_ILLADR: // Illegal addressing mode - case ILL_ILLTRP: // Illegal trap - case ILL_COPROC: // Co-processor error - return EXCEPTION_ILLEGAL_INSTRUCTION; - case ILL_PRVOPC: // Privileged opcode - case ILL_PRVREG: // Privileged register - return EXCEPTION_PRIV_INSTRUCTION; - case ILL_BADSTK: // Internal stack error - return EXCEPTION_STACK_OVERFLOW; - default: - break; - } - break; - case SIGFPE: - switch (siginfo->si_code) - { - case FPE_INTDIV: - return EXCEPTION_INT_DIVIDE_BY_ZERO; - case FPE_INTOVF: - return EXCEPTION_INT_OVERFLOW; - case FPE_FLTDIV: - return EXCEPTION_FLT_DIVIDE_BY_ZERO; - case FPE_FLTOVF: - return EXCEPTION_FLT_OVERFLOW; - case FPE_FLTUND: - return EXCEPTION_FLT_UNDERFLOW; - case FPE_FLTRES: - return EXCEPTION_FLT_INEXACT_RESULT; - case FPE_FLTINV: - return EXCEPTION_FLT_INVALID_OPERATION; - case FPE_FLTSUB: - return EXCEPTION_FLT_INVALID_OPERATION; - default: - break; - } - break; - case SIGSEGV: - switch (siginfo->si_code) - { - case SI_USER: // User-generated signal, sometimes sent - // for SIGSEGV under normal circumstances - case SEGV_MAPERR: // Address not mapped to object - case SEGV_ACCERR: // Invalid permissions for mapped object - return EXCEPTION_ACCESS_VIOLATION; - -#ifdef SI_KERNEL - case SI_KERNEL: - { - // Identify privileged instructions that are not identified as such by the system - if (g_getGcMarkerExceptionCode != nullptr) - { - DWORD exceptionCode = g_getGcMarkerExceptionCode(GetNativeContextPC(context)); - if (exceptionCode != 0) - { - return exceptionCode; - } - } - return EXCEPTION_ACCESS_VIOLATION; - } -#endif - default: - break; - } - break; - case SIGBUS: - switch (siginfo->si_code) - { - case BUS_ADRALN: // Invalid address alignment - return EXCEPTION_DATATYPE_MISALIGNMENT; - case BUS_ADRERR: // Non-existent physical address - return EXCEPTION_ACCESS_VIOLATION; - case BUS_OBJERR: // Object-specific hardware error - default: - break; - } - case SIGTRAP: - switch (siginfo->si_code) - { -#ifdef SI_KERNEL - case SI_KERNEL: -#endif - case SI_USER: - case TRAP_BRKPT: // Process breakpoint - return EXCEPTION_BREAKPOINT; - case TRAP_TRACE: // Process trace trap - return EXCEPTION_SINGLE_STEP; - default: - // Got unknown SIGTRAP signal with code siginfo->si_code; - return EXCEPTION_ILLEGAL_INSTRUCTION; - } - default: - break; - } - - // Got unknown signal number siginfo->si_signo with code siginfo->si_code; - return EXCEPTION_ILLEGAL_INSTRUCTION; -} -#else // ILL_ILLOPC -DWORD CONTEXTGetExceptionCodeForSignal(const siginfo_t *siginfo, - const native_context_t *context) -{ - // IMPORTANT NOTE: This function must not call any signal unsafe functions - // since it is called from signal handlers. - // That includes ASSERT and TRACE macros. - - int trap; - - if (siginfo->si_signo == SIGFPE) - { - // Floating point exceptions are mapped by their si_code. - switch (siginfo->si_code) - { - case FPE_INTDIV : - return EXCEPTION_INT_DIVIDE_BY_ZERO; - case FPE_INTOVF : - return EXCEPTION_INT_OVERFLOW; - case FPE_FLTDIV : - return EXCEPTION_FLT_DIVIDE_BY_ZERO; - case FPE_FLTOVF : - return EXCEPTION_FLT_OVERFLOW; - case FPE_FLTUND : - return EXCEPTION_FLT_UNDERFLOW; - case FPE_FLTRES : - return EXCEPTION_FLT_INEXACT_RESULT; - case FPE_FLTINV : - return EXCEPTION_FLT_INVALID_OPERATION; - case FPE_FLTSUB :/* subscript out of range */ - return EXCEPTION_FLT_INVALID_OPERATION; - default: - // Got unknown signal code siginfo->si_code; - return 0; - } - } - - trap = context->uc_mcontext.mc_trapno; - switch (trap) - { - case T_PRIVINFLT : /* privileged instruction */ - return EXCEPTION_PRIV_INSTRUCTION; - case T_BPTFLT : /* breakpoint instruction */ - return EXCEPTION_BREAKPOINT; - case T_ARITHTRAP : /* arithmetic trap */ - return 0; /* let the caller pick an exception code */ -#ifdef T_ASTFLT - case T_ASTFLT : /* system forced exception : ^C, ^\. SIGINT signal - handler shouldn't be calling this function, since - it doesn't need an exception code */ - // Trap code T_ASTFLT received, shouldn't get here; - return 0; -#endif // T_ASTFLT - case T_PROTFLT : /* protection fault */ - return EXCEPTION_ACCESS_VIOLATION; - case T_TRCTRAP : /* debug exception (sic) */ - return EXCEPTION_SINGLE_STEP; - case T_PAGEFLT : /* page fault */ - return EXCEPTION_ACCESS_VIOLATION; - case T_ALIGNFLT : /* alignment fault */ - return EXCEPTION_DATATYPE_MISALIGNMENT; - case T_DIVIDE : - return EXCEPTION_INT_DIVIDE_BY_ZERO; - case T_NMI : /* non-maskable trap */ - return EXCEPTION_ILLEGAL_INSTRUCTION; - case T_OFLOW : - return EXCEPTION_INT_OVERFLOW; - case T_BOUND : /* bound instruction fault */ - return EXCEPTION_ARRAY_BOUNDS_EXCEEDED; - case T_DNA : /* device not available fault */ - return EXCEPTION_ILLEGAL_INSTRUCTION; - case T_DOUBLEFLT : /* double fault */ - return EXCEPTION_ILLEGAL_INSTRUCTION; - case T_FPOPFLT : /* fp coprocessor operand fetch fault */ - return EXCEPTION_FLT_INVALID_OPERATION; - case T_TSSFLT : /* invalid tss fault */ - return EXCEPTION_ILLEGAL_INSTRUCTION; - case T_SEGNPFLT : /* segment not present fault */ - return EXCEPTION_ACCESS_VIOLATION; - case T_STKFLT : /* stack fault */ - return EXCEPTION_STACK_OVERFLOW; - case T_MCHK : /* machine check trap */ - return EXCEPTION_ILLEGAL_INSTRUCTION; - case T_RESERVED : /* reserved (unknown) */ - return EXCEPTION_ILLEGAL_INSTRUCTION; - default: - // Got unknown trap code trap; - break; - } - return EXCEPTION_ILLEGAL_INSTRUCTION; -} -#endif // ILL_ILLOPC - -#else // !HAVE_MACH_EXCEPTIONS - -#include -#include -#include "../exception/machexception.h" - -/*++ -Function: - CONTEXT_GetThreadContextFromPort - - Helper for GetThreadContext that uses a mach_port ---*/ -kern_return_t -CONTEXT_GetThreadContextFromPort( - mach_port_t Port, - LPCONTEXT lpContext) -{ - // Extract the CONTEXT from the Mach thread. - - kern_return_t MachRet = KERN_SUCCESS; - mach_msg_type_number_t StateCount; - thread_state_flavor_t StateFlavor; - - if (lpContext->ContextFlags & (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS) & CONTEXT_AREA_MASK) - { -#ifdef _X86_ - x86_thread_state32_t State; - StateFlavor = x86_THREAD_STATE32; -#elif defined(_AMD64_) - x86_thread_state64_t State; - StateFlavor = x86_THREAD_STATE64; -#else -#error Unexpected architecture. -#endif - StateCount = sizeof(State) / sizeof(natural_t); - MachRet = thread_get_state(Port, StateFlavor, (thread_state_t)&State, &StateCount); - if (MachRet != KERN_SUCCESS) - { - ASSERT("thread_get_state(THREAD_STATE) failed: %d\n", MachRet); - goto exit; - } - - CONTEXT_GetThreadContextFromThreadState(StateFlavor, (thread_state_t)&State, lpContext); - } - - if (lpContext->ContextFlags & CONTEXT_ALL_FLOATING & CONTEXT_AREA_MASK) { -#ifdef _X86_ - x86_float_state32_t State; - StateFlavor = x86_FLOAT_STATE32; -#elif defined(_AMD64_) - x86_float_state64_t State; - StateFlavor = x86_FLOAT_STATE64; -#else -#error Unexpected architecture. -#endif - StateCount = sizeof(State) / sizeof(natural_t); - MachRet = thread_get_state(Port, StateFlavor, (thread_state_t)&State, &StateCount); - if (MachRet != KERN_SUCCESS) - { - ASSERT("thread_get_state(FLOAT_STATE) failed: %d\n", MachRet); - goto exit; - } - - CONTEXT_GetThreadContextFromThreadState(StateFlavor, (thread_state_t)&State, lpContext); - } - -#if defined(_AMD64_) && defined(XSTATE_SUPPORTED) - if (lpContext->ContextFlags & CONTEXT_XSTATE & CONTEXT_AREA_MASK) { - x86_avx_state64_t State; - StateFlavor = x86_AVX_STATE64; - StateCount = sizeof(State) / sizeof(natural_t); - MachRet = thread_get_state(Port, StateFlavor, (thread_state_t)&State, &StateCount); - if (MachRet != KERN_SUCCESS) - { - ASSERT("thread_get_state(XSTATE) failed: %d\n", MachRet); - goto exit; - } - - CONTEXT_GetThreadContextFromThreadState(StateFlavor, (thread_state_t)&State, lpContext); - } -#endif - -exit: - return MachRet; -} - -/*++ -Function: - CONTEXT_GetThreadContextFromThreadState - ---*/ -void -CONTEXT_GetThreadContextFromThreadState( - thread_state_flavor_t threadStateFlavor, - thread_state_t threadState, - LPCONTEXT lpContext) -{ - switch (threadStateFlavor) - { -#ifdef _X86_ - case x86_THREAD_STATE32: - if (lpContext->ContextFlags & (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS) & CONTEXT_AREA_MASK) - { - x86_thread_state32_t *pState = (x86_thread_state32_t *)threadState; - - lpContext->Eax = pState->eax; - lpContext->Ebx = pState->ebx; - lpContext->Ecx = pState->ecx; - lpContext->Edx = pState->edx; - lpContext->Edi = pState->edi; - lpContext->Esi = pState->esi; - lpContext->Ebp = pState->ebp; - lpContext->Esp = pState->esp; - lpContext->SegSs = pState->ss; - lpContext->EFlags = pState->eflags; - lpContext->Eip = pState->eip; - lpContext->SegCs = pState->cs; - lpContext->SegDs_PAL_Undefined = pState->ds; - lpContext->SegEs_PAL_Undefined = pState->es; - lpContext->SegFs_PAL_Undefined = pState->fs; - lpContext->SegGs_PAL_Undefined = pState->gs; - } - break; - - case x86_FLOAT_STATE32: - { - x86_float_state32_t *pState = (x86_float_state32_t *)threadState; - - if (lpContext->ContextFlags & CONTEXT_FLOATING_POINT & CONTEXT_AREA_MASK) - { - lpContext->FloatSave.ControlWord = *(DWORD*)&pState->fpu_fcw; - lpContext->FloatSave.StatusWord = *(DWORD*)&pState->fpu_fsw; - lpContext->FloatSave.TagWord = pState->fpu_ftw; - lpContext->FloatSave.ErrorOffset = pState->fpu_ip; - lpContext->FloatSave.ErrorSelector = pState->fpu_cs; - lpContext->FloatSave.DataOffset = pState->fpu_dp; - lpContext->FloatSave.DataSelector = pState->fpu_ds; - lpContext->FloatSave.Cr0NpxState = pState->fpu_mxcsr; - - // Windows stores the floating point registers in a packed layout (each 10-byte register end to end - // for a total of 80 bytes). But Mach returns each register in an 16-bit structure (presumably for - // alignment purposes). So we can't just memcpy the registers over in a single block, we need to copy - // them individually. - for (int i = 0; i < 8; i++) - memcpy(&lpContext->FloatSave.RegisterArea[i * 10], (&pState->fpu_stmm0)[i].mmst_reg, 10); - } - - if (lpContext->ContextFlags & CONTEXT_EXTENDED_REGISTERS & CONTEXT_AREA_MASK) - { - // The only extended register information that Mach will tell us about are the xmm register values. - // Both Windows and Mach store the registers in a packed layout (each of the 8 registers is 16 bytes) - // so we can simply memcpy them across. - memcpy(lpContext->ExtendedRegisters + CONTEXT_EXREG_XMM_OFFSET, &pState->fpu_xmm0, 8 * 16); - } - } - break; - -#elif defined(_AMD64_) - case x86_THREAD_STATE64: - if (lpContext->ContextFlags & (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS) & CONTEXT_AREA_MASK) - { - x86_thread_state64_t *pState = (x86_thread_state64_t *)threadState; - - lpContext->Rax = pState->__rax; - lpContext->Rbx = pState->__rbx; - lpContext->Rcx = pState->__rcx; - lpContext->Rdx = pState->__rdx; - lpContext->Rdi = pState->__rdi; - lpContext->Rsi = pState->__rsi; - lpContext->Rbp = pState->__rbp; - lpContext->Rsp = pState->__rsp; - lpContext->R8 = pState->__r8; - lpContext->R9 = pState->__r9; - lpContext->R10 = pState->__r10; - lpContext->R11 = pState->__r11; - lpContext->R12 = pState->__r12; - lpContext->R13 = pState->__r13; - lpContext->R14 = pState->__r14; - lpContext->R15 = pState->__r15; - lpContext->EFlags = pState->__rflags; - lpContext->Rip = pState->__rip; - lpContext->SegCs = pState->__cs; - // RtlRestoreContext uses the actual ss instead of this one - // to build the iret frame so just set it zero. - lpContext->SegSs = 0; - lpContext->SegDs = 0; - lpContext->SegEs = 0; - lpContext->SegFs = pState->__fs; - lpContext->SegGs = pState->__gs; - } - break; - - case x86_FLOAT_STATE64: - if (lpContext->ContextFlags & CONTEXT_FLOATING_POINT & CONTEXT_AREA_MASK) - { - x86_float_state64_t *pState = (x86_float_state64_t *)threadState; - - lpContext->FltSave.ControlWord = *(DWORD*)&pState->__fpu_fcw; - lpContext->FltSave.StatusWord = *(DWORD*)&pState->__fpu_fsw; - lpContext->FltSave.TagWord = pState->__fpu_ftw; - lpContext->FltSave.ErrorOffset = pState->__fpu_ip; - lpContext->FltSave.ErrorSelector = pState->__fpu_cs; - lpContext->FltSave.DataOffset = pState->__fpu_dp; - lpContext->FltSave.DataSelector = pState->__fpu_ds; - lpContext->FltSave.MxCsr = pState->__fpu_mxcsr; - lpContext->FltSave.MxCsr_Mask = pState->__fpu_mxcsrmask; // note: we don't save the mask for x86 - - // Windows stores the floating point registers in a packed layout (each 10-byte register end to end - // for a total of 80 bytes). But Mach returns each register in an 16-bit structure (presumably for - // alignment purposes). So we can't just memcpy the registers over in a single block, we need to copy - // them individually. - for (int i = 0; i < 8; i++) - memcpy(&lpContext->FltSave.FloatRegisters[i], (&pState->__fpu_stmm0)[i].__mmst_reg, 10); - - // AMD64's FLOATING_POINT includes the xmm registers. - memcpy(&lpContext->Xmm0, &pState->__fpu_xmm0, 16 * 16); - } - break; - -#ifdef XSTATE_SUPPORTED - case x86_AVX_STATE64: - if (lpContext->ContextFlags & CONTEXT_XSTATE & CONTEXT_AREA_MASK) - { - x86_avx_state64_t *pState = (x86_avx_state64_t *)threadState; - memcpy(&lpContext->VectorRegister, &pState->__fpu_ymmh0, 16 * 16); - } - break; -#endif -#else -#error Unexpected architecture. -#endif - case x86_THREAD_STATE: - { - x86_thread_state_t *pState = (x86_thread_state_t *)threadState; - CONTEXT_GetThreadContextFromThreadState((thread_state_flavor_t)pState->tsh.flavor, (thread_state_t)&pState->uts, lpContext); - } - break; - - case x86_FLOAT_STATE: - { - x86_float_state_t *pState = (x86_float_state_t *)threadState; - CONTEXT_GetThreadContextFromThreadState((thread_state_flavor_t)pState->fsh.flavor, (thread_state_t)&pState->ufs, lpContext); - } - break; - - default: - ASSERT("Invalid thread state flavor %d\n", threadStateFlavor); - break; - } -} - -/*++ -Function: - GetThreadContext - -See MSDN doc. ---*/ -BOOL -CONTEXT_GetThreadContext( - DWORD dwProcessId, - pthread_t self, - LPCONTEXT lpContext) -{ - BOOL ret = FALSE; - - if (lpContext == NULL) - { - ERROR("Invalid lpContext parameter value\n"); - SetLastError(ERROR_NOACCESS); - goto EXIT; - } - - if (GetCurrentProcessId() == dwProcessId) - { - if (self != pthread_self()) - { - // the target thread is in the current process, but isn't - // the current one: extract the CONTEXT from the Mach thread. - mach_port_t mptPort; - mptPort = pthread_mach_thread_np(self); - - ret = (CONTEXT_GetThreadContextFromPort(mptPort, lpContext) == KERN_SUCCESS); - } - else - { - CONTEXT_CaptureContext(lpContext); - ret = TRUE; - } - } - else - { - ASSERT("Cross-process GetThreadContext() is not supported on this platform\n"); - SetLastError(ERROR_NOACCESS); - } - -EXIT: - return ret; -} - -/*++ -Function: - SetThreadContextOnPort - - Helper for CONTEXT_SetThreadContext ---*/ -kern_return_t -CONTEXT_SetThreadContextOnPort( - mach_port_t Port, - IN CONST CONTEXT *lpContext) -{ - kern_return_t MachRet = KERN_SUCCESS; - mach_msg_type_number_t StateCount; - thread_state_flavor_t StateFlavor; - - if (lpContext->ContextFlags & (CONTEXT_CONTROL|CONTEXT_INTEGER) & CONTEXT_AREA_MASK) - { -#ifdef _X86_ - x86_thread_state32_t State; - StateFlavor = x86_THREAD_STATE32; - - State.eax = lpContext->Eax; - State.ebx = lpContext->Ebx; - State.ecx = lpContext->Ecx; - State.edx = lpContext->Edx; - State.edi = lpContext->Edi; - State.esi = lpContext->Esi; - State.ebp = lpContext->Ebp; - State.esp = lpContext->Esp; - State.ss = lpContext->SegSs; - State.eflags = lpContext->EFlags; - State.eip = lpContext->Eip; - State.cs = lpContext->SegCs; - State.ds = lpContext->SegDs_PAL_Undefined; - State.es = lpContext->SegEs_PAL_Undefined; - State.fs = lpContext->SegFs_PAL_Undefined; - State.gs = lpContext->SegGs_PAL_Undefined; -#elif defined(_AMD64_) - x86_thread_state64_t State; - StateFlavor = x86_THREAD_STATE64; - - State.__rax = lpContext->Rax; - State.__rbx = lpContext->Rbx; - State.__rcx = lpContext->Rcx; - State.__rdx = lpContext->Rdx; - State.__rdi = lpContext->Rdi; - State.__rsi = lpContext->Rsi; - State.__rbp = lpContext->Rbp; - State.__rsp = lpContext->Rsp; - State.__r8 = lpContext->R8; - State.__r9 = lpContext->R9; - State.__r10 = lpContext->R10; - State.__r11 = lpContext->R11; - State.__r12 = lpContext->R12; - State.__r13 = lpContext->R13; - State.__r14 = lpContext->R14; - State.__r15 = lpContext->R15; -// State.ss = lpContext->SegSs; - State.__rflags = lpContext->EFlags; - State.__rip = lpContext->Rip; - State.__cs = lpContext->SegCs; -// State.ds = lpContext->SegDs_PAL_Undefined; -// State.es = lpContext->SegEs_PAL_Undefined; - State.__fs = lpContext->SegFs; - State.__gs = lpContext->SegGs; -#else -#error Unexpected architecture. -#endif - - StateCount = sizeof(State) / sizeof(natural_t); - - MachRet = thread_set_state(Port, - StateFlavor, - (thread_state_t)&State, - StateCount); - if (MachRet != KERN_SUCCESS) - { - ASSERT("thread_set_state(THREAD_STATE) failed: %d\n", MachRet); - goto EXIT; - } - } - - if (lpContext->ContextFlags & CONTEXT_ALL_FLOATING & CONTEXT_AREA_MASK) - { - -#ifdef _X86_ - x86_float_state32_t State; - StateFlavor = x86_FLOAT_STATE32; - StateCount = sizeof(State) / sizeof(natural_t); -#elif defined(_AMD64_) -#ifdef XSTATE_SUPPORTED - // We're relying on the fact that the initial portion of - // x86_avx_state64_t is identical to x86_float_state64_t. - // Check a few fields to make sure the assumption is correct. - static_assert_no_msg(sizeof(x86_avx_state64_t) > sizeof(x86_float_state64_t)); - static_assert_no_msg(offsetof(x86_avx_state64_t, __fpu_fcw) == offsetof(x86_float_state64_t, __fpu_fcw)); - static_assert_no_msg(offsetof(x86_avx_state64_t, __fpu_xmm0) == offsetof(x86_float_state64_t, __fpu_xmm0)); - - x86_avx_state64_t State; - if (lpContext->ContextFlags & CONTEXT_XSTATE & CONTEXT_AREA_MASK) - { - StateFlavor = x86_AVX_STATE64; - StateCount = sizeof(State) / sizeof(natural_t); - } - else - { - StateFlavor = x86_FLOAT_STATE64; - StateCount = sizeof(x86_float_state64_t) / sizeof(natural_t); - } -#else - x86_float_state64_t State; - StateFlavor = x86_FLOAT_STATE64; - StateCount = sizeof(State) / sizeof(natural_t); -#endif -#else -#error Unexpected architecture. -#endif - - // If we're setting only one of the floating point or extended registers (of which Mach supports only - // the xmm values) then we don't have values for the other set. This is a problem since Mach only - // supports setting both groups as a single unit. So in this case we'll need to fetch the current - // values first. - if ((lpContext->ContextFlags & CONTEXT_ALL_FLOATING) != - CONTEXT_ALL_FLOATING) - { - mach_msg_type_number_t StateCountGet = StateCount; - MachRet = thread_get_state(Port, - StateFlavor, - (thread_state_t)&State, - &StateCountGet); - if (MachRet != KERN_SUCCESS) - { - ASSERT("thread_get_state(FLOAT_STATE) failed: %d\n", MachRet); - goto EXIT; - } - _ASSERTE(StateCountGet == StateCount); - } - - if (lpContext->ContextFlags & CONTEXT_FLOATING_POINT & CONTEXT_AREA_MASK) - { -#ifdef _X86_ - *(DWORD*)&State.fpu_fcw = lpContext->FloatSave.ControlWord; - *(DWORD*)&State.fpu_fsw = lpContext->FloatSave.StatusWord; - State.fpu_ftw = lpContext->FloatSave.TagWord; - State.fpu_ip = lpContext->FloatSave.ErrorOffset; - State.fpu_cs = lpContext->FloatSave.ErrorSelector; - State.fpu_dp = lpContext->FloatSave.DataOffset; - State.fpu_ds = lpContext->FloatSave.DataSelector; - State.fpu_mxcsr = lpContext->FloatSave.Cr0NpxState; - - // Windows stores the floating point registers in a packed layout (each 10-byte register end to - // end for a total of 80 bytes). But Mach returns each register in an 16-bit structure (presumably - // for alignment purposes). So we can't just memcpy the registers over in a single block, we need - // to copy them individually. - for (int i = 0; i < 8; i++) - memcpy((&State.fpu_stmm0)[i].mmst_reg, &lpContext->FloatSave.RegisterArea[i * 10], 10); -#elif defined(_AMD64_) - *(DWORD*)&State.__fpu_fcw = lpContext->FltSave.ControlWord; - *(DWORD*)&State.__fpu_fsw = lpContext->FltSave.StatusWord; - State.__fpu_ftw = lpContext->FltSave.TagWord; - State.__fpu_ip = lpContext->FltSave.ErrorOffset; - State.__fpu_cs = lpContext->FltSave.ErrorSelector; - State.__fpu_dp = lpContext->FltSave.DataOffset; - State.__fpu_ds = lpContext->FltSave.DataSelector; - State.__fpu_mxcsr = lpContext->FltSave.MxCsr; - State.__fpu_mxcsrmask = lpContext->FltSave.MxCsr_Mask; // note: we don't save the mask for x86 - - // Windows stores the floating point registers in a packed layout (each 10-byte register end to - // end for a total of 80 bytes). But Mach returns each register in an 16-bit structure (presumably - // for alignment purposes). So we can't just memcpy the registers over in a single block, we need - // to copy them individually. - for (int i = 0; i < 8; i++) - memcpy((&State.__fpu_stmm0)[i].__mmst_reg, &lpContext->FltSave.FloatRegisters[i], 10); - - memcpy(&State.__fpu_xmm0, &lpContext->Xmm0, 16 * 16); -#else -#error Unexpected architecture. -#endif - } - -#ifdef _X86_ - if (lpContext->ContextFlags & CONTEXT_EXTENDED_REGISTERS & CONTEXT_AREA_MASK) - { - // The only extended register information that Mach will tell us about are the xmm register - // values. Both Windows and Mach store the registers in a packed layout (each of the 8 registers - // is 16 bytes) so we can simply memcpy them across. - memcpy(&State.fpu_xmm0, lpContext->ExtendedRegisters + CONTEXT_EXREG_XMM_OFFSET, 8 * 16); - } -#endif // _X86_ - -#if defined(_AMD64_) && defined(XSTATE_SUPPORTED) - if (lpContext->ContextFlags & CONTEXT_XSTATE & CONTEXT_AREA_MASK) - { - memcpy(&State.__fpu_ymmh0, lpContext->VectorRegister, 16 * 16); - } -#endif - - MachRet = thread_set_state(Port, - StateFlavor, - (thread_state_t)&State, - StateCount); - if (MachRet != KERN_SUCCESS) - { - ASSERT("thread_set_state(FLOAT_STATE) failed: %d\n", MachRet); - goto EXIT; - } - } - -EXIT: - return MachRet; -} - -/*++ -Function: - SetThreadContext - -See MSDN doc. ---*/ -BOOL -CONTEXT_SetThreadContext( - DWORD dwProcessId, - pthread_t self, - CONST CONTEXT *lpContext) -{ - BOOL ret = FALSE; - - if (lpContext == NULL) - { - ERROR("Invalid lpContext parameter value\n"); - SetLastError(ERROR_NOACCESS); - goto EXIT; - } - - if (dwProcessId != GetCurrentProcessId()) - { - // GetThreadContext() of a thread in another process - ASSERT("Cross-process GetThreadContext() is not supported\n"); - SetLastError(ERROR_NOACCESS); - goto EXIT; - } - - if (self != pthread_self()) - { - // hThread is in the current process, but isn't the current - // thread. Extract the CONTEXT from the Mach thread. - - mach_port_t mptPort; - - mptPort = pthread_mach_thread_np(self); - - ret = (CONTEXT_SetThreadContextOnPort(mptPort, lpContext) == KERN_SUCCESS); - } - else - { - MachSetThreadContext(const_cast(lpContext)); - ASSERT("MachSetThreadContext should never return\n"); - } - -EXIT: - return ret; -} - -#endif // !HAVE_MACH_EXCEPTIONS - -/*++ -Function: - DBG_FlushInstructionCache: processor-specific portion of - FlushInstructionCache - -See MSDN doc. ---*/ -BOOL -DBG_FlushInstructionCache( - IN LPCVOID lpBaseAddress, - IN SIZE_T dwSize) -{ -#ifndef _ARM_ - // Intrinsic should do the right thing across all platforms (except Linux arm) - __builtin___clear_cache((char *)lpBaseAddress, (char *)((INT_PTR)lpBaseAddress + dwSize)); -#else // _ARM_ - // On Linux/arm (at least on 3.10) we found that there is a problem with __do_cache_op (arch/arm/kernel/traps.c) - // implementing cacheflush syscall. cacheflush flushes only the first page in range [lpBaseAddress, lpBaseAddress + dwSize) - // and leaves other pages in undefined state which causes random tests failures (often due to SIGSEGV) with no particular pattern. - // - // As a workaround, we call __builtin___clear_cache on each page separately. - - const SIZE_T pageSize = GetVirtualPageSize(); - INT_PTR begin = (INT_PTR)lpBaseAddress; - const INT_PTR end = begin + dwSize; - - while (begin < end) - { - INT_PTR endOrNextPageBegin = ALIGN_UP(begin + 1, pageSize); - if (endOrNextPageBegin > end) - endOrNextPageBegin = end; - - __builtin___clear_cache((char *)begin, (char *)endOrNextPageBegin); - begin = endOrNextPageBegin; - } -#endif // _ARM_ - return TRUE; -} diff --git a/src/pal/src/thread/process.cpp b/src/pal/src/thread/process.cpp deleted file mode 100644 index a1be42fa3..000000000 --- a/src/pal/src/thread/process.cpp +++ /dev/null @@ -1,4819 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*++ - - - -Module Name: - - process.cpp - -Abstract: - - Implementation of process object and functions related to processes. - - - ---*/ - -#include "pal/dbgmsg.h" -SET_DEFAULT_DEBUG_CHANNEL(PROCESS); // some headers have code with asserts, so do this first - -#include "pal/procobj.hpp" -#include "pal/thread.hpp" -#include "pal/file.hpp" -#include "pal/handlemgr.hpp" -#include "pal/module.h" -#include "procprivate.hpp" -#include "pal/palinternal.h" -#include "pal/process.h" -#include "pal/init.h" -#include "pal/critsect.h" -#include "pal/debug.h" -#include "pal/utils.h" -#include "pal/environ.h" -#include "pal/virtual.h" -#include "pal/stackstring.hpp" - -#include -#if HAVE_POLL -#include -#else -#include "pal/fakepoll.h" -#endif // HAVE_POLL - -#include -#include -#include -#include -#include -#if HAVE_PRCTL_H -#include -#include -#endif -#include -#include -#include -#include -#include -#include -#include - -#ifdef __APPLE__ -#include -#endif - -#ifdef __NetBSD__ -#include -#include -#include -#include -#endif - -extern char *g_szCoreCLRPath; - -using namespace CorUnix; - -CObjectType CorUnix::otProcess( - otiProcess, - NULL, // No cleanup routine - NULL, // No initialization routine - 0, // No immutable data - NULL, // No immutable data copy routine - NULL, // No immutable data cleanup routine - sizeof(CProcProcessLocalData), - NULL, // No process local data cleanup routine - 0, // No shared data - PROCESS_ALL_ACCESS, - CObjectType::SecuritySupported, - CObjectType::SecurityInfoNotPersisted, - CObjectType::UnnamedObject, - CObjectType::CrossProcessDuplicationAllowed, - CObjectType::WaitableObject, - CObjectType::SingleTransitionObject, - CObjectType::ThreadReleaseHasNoSideEffects, - CObjectType::NoOwner - ); - -// -// Helper memory page used by the FlushProcessWriteBuffers -// -static int* s_helperPage = 0; - -// -// Mutex to make the FlushProcessWriteBuffersMutex thread safe -// -pthread_mutex_t flushProcessWriteBuffersMutex; - -CAllowedObjectTypes aotProcess(otiProcess); - -// -// The representative IPalObject for this process -// -IPalObject* CorUnix::g_pobjProcess; - -// -// Critical section that protects process data (e.g., the -// list of active threads)/ -// -CRITICAL_SECTION g_csProcess; - -// -// List and count of active threads -// -CPalThread* CorUnix::pGThreadList; -DWORD g_dwThreadCount; - -// -// The command line and app name for the process -// -LPWSTR g_lpwstrCmdLine = NULL; -LPWSTR g_lpwstrAppDir = NULL; - -// Thread ID of thread that has started the ExitProcess process -Volatile terminator = 0; - -// Process and session ID of this process. -DWORD gPID = (DWORD) -1; -DWORD gSID = (DWORD) -1; - -// The lowest common supported semaphore length, including null character -// NetBSD-7.99.25: 15 characters -// MacOSX 10.11: 31 -- Core 1.0 RC2 compatibility -#if defined(__NetBSD__) -#define CLR_SEM_MAX_NAMELEN 15 -#else -#define CLR_SEM_MAX_NAMELEN (NAME_MAX - 4) -#endif - -// Function to call during PAL/process shutdown/abort -Volatile g_shutdownCallback = nullptr; - -// Crash dump generating program arguments. Initialized in PROCAbortInitialize(). -char* g_argvCreateDump[8] = { nullptr }; - -// -// Key used for associating CPalThread's with the underlying pthread -// (through pthread_setspecific) -// -pthread_key_t CorUnix::thObjKey; - -#define PROCESS_PELOADER_FILENAME "clix" - -static WCHAR W16_WHITESPACE[]= {0x0020, 0x0009, 0x000D, 0}; -static WCHAR W16_WHITESPACE_DQUOTE[]= {0x0020, 0x0009, 0x000D, '"', 0}; - -enum FILETYPE -{ - FILE_ERROR,/*ERROR*/ - FILE_PE, /*PE/COFF file*/ - FILE_UNIX, /*Unix Executable*/ - FILE_DIR /*Directory*/ -}; - -static -DWORD -PALAPI -StartupHelperThread( - LPVOID p); - -static -BOOL -GetProcessIdDisambiguationKey( - IN DWORD processId, - OUT UINT64 *disambiguationKey); - -PAL_ERROR -PROCGetProcessStatus( - CPalThread *pThread, - HANDLE hProcess, - PROCESS_STATE *pps, - DWORD *pdwExitCode); - -static BOOL getFileName(LPCWSTR lpApplicationName, LPWSTR lpCommandLine, PathCharString& lpFileName); -static char ** buildArgv(LPCWSTR lpCommandLine, PathCharString& lpAppPath, UINT *pnArg, BOOL prependLoader); -static BOOL getPath(PathCharString& lpFileName, PathCharString& lpPathFileName); -static int checkFileType(LPCSTR lpFileName); -static BOOL PROCEndProcess(HANDLE hProcess, UINT uExitCode, BOOL bTerminateUnconditionally); - -ProcessModules *GetProcessModulesFromHandle(IN HANDLE hProcess, OUT LPDWORD lpCount); -ProcessModules *CreateProcessModules(IN DWORD dwProcessId, OUT LPDWORD lpCount); -void DestroyProcessModules(IN ProcessModules *listHead); - -/*++ -Function: - GetCurrentProcessId - -See MSDN doc. ---*/ -DWORD -PALAPI -GetCurrentProcessId( - VOID) -{ - PERF_ENTRY(GetCurrentProcessId); - ENTRY("GetCurrentProcessId()\n" ); - - LOGEXIT("GetCurrentProcessId returns DWORD %#x\n", gPID); - PERF_EXIT(GetCurrentProcessId); - return gPID; -} - - -/*++ -Function: - GetCurrentSessionId - -See MSDN doc. ---*/ -DWORD -PALAPI -GetCurrentSessionId( - VOID) -{ - PERF_ENTRY(GetCurrentSessionId); - ENTRY("GetCurrentSessionId()\n" ); - - LOGEXIT("GetCurrentSessionId returns DWORD %#x\n", gSID); - PERF_EXIT(GetCurrentSessionId); - return gSID; -} - - -/*++ -Function: - GetCurrentProcess - -See MSDN doc. ---*/ -HANDLE -PALAPI -GetCurrentProcess( - VOID) -{ - PERF_ENTRY(GetCurrentProcess); - ENTRY("GetCurrentProcess()\n" ); - - LOGEXIT("GetCurrentProcess returns HANDLE %p\n", hPseudoCurrentProcess); - PERF_EXIT(GetCurrentProcess); - - /* return a pseudo handle */ - return hPseudoCurrentProcess; -} - -/*++ -Function: - CreateProcessA - -Note: - Only Standard handles need to be inherited. - Security attributes parameters are not used. - -See MSDN doc. ---*/ -BOOL -PALAPI -CreateProcessA( - IN LPCSTR lpApplicationName, - IN LPSTR lpCommandLine, - IN LPSECURITY_ATTRIBUTES lpProcessAttributes, - IN LPSECURITY_ATTRIBUTES lpThreadAttributes, - IN BOOL bInheritHandles, - IN DWORD dwCreationFlags, - IN LPVOID lpEnvironment, - IN LPCSTR lpCurrentDirectory, - IN LPSTARTUPINFOA lpStartupInfo, - OUT LPPROCESS_INFORMATION lpProcessInformation) -{ - PAL_ERROR palError = NO_ERROR; - CPalThread *pThread; - STARTUPINFOW StartupInfoW; - LPWSTR CommandLineW = NULL; - LPWSTR ApplicationNameW = NULL; - LPWSTR CurrentDirectoryW = NULL; - - int n; - - PERF_ENTRY(CreateProcessA); - ENTRY("CreateProcessA(lpAppName=%p (%s), lpCmdLine=%p (%s), lpProcessAttr=%p, " - "lpThreadAttr=%p, bInherit=%d, dwFlags=%#x, lpEnv=%p, " - "lpCurrentDir=%p (%s), lpStartupInfo=%p, lpProcessInfo=%p)\n", - lpApplicationName?lpApplicationName:"NULL", - lpApplicationName?lpApplicationName:"NULL", - lpCommandLine?lpCommandLine:"NULL", - lpCommandLine?lpCommandLine:"NULL", - lpProcessAttributes, lpThreadAttributes, bInheritHandles, - dwCreationFlags, lpEnvironment, - lpCurrentDirectory?lpCurrentDirectory:"NULL", - lpCurrentDirectory?lpCurrentDirectory:"NULL", - lpStartupInfo, lpProcessInformation); - - pThread = InternalGetCurrentThread(); - - if(lpStartupInfo == NULL) - { - ASSERT("lpStartupInfo is NULL!\n"); - palError = ERROR_INVALID_PARAMETER; - goto done; - } - - /* convert parameters to Unicode */ - - if(lpApplicationName) - { - n = MultiByteToWideChar(CP_ACP, 0, lpApplicationName, -1, NULL, 0); - if(0 == n) - { - ASSERT("MultiByteToWideChar failed!\n"); - palError = ERROR_INTERNAL_ERROR; - goto done; - } - ApplicationNameW = (LPWSTR)InternalMalloc(sizeof(WCHAR)*n); - if(!ApplicationNameW) - { - ERROR("malloc() failed!\n"); - palError = ERROR_NOT_ENOUGH_MEMORY; - goto done; - } - MultiByteToWideChar(CP_ACP, 0, lpApplicationName, -1, ApplicationNameW, - n); - } - - if(lpCommandLine) - { - n = MultiByteToWideChar(CP_ACP, 0, lpCommandLine, -1, NULL, 0); - if(0 == n) - { - ASSERT("MultiByteToWideChar failed!\n"); - palError = ERROR_INTERNAL_ERROR; - goto done; - } - CommandLineW = (LPWSTR)InternalMalloc(sizeof(WCHAR)*n); - if(!CommandLineW) - { - ERROR("malloc() failed!\n"); - palError = ERROR_NOT_ENOUGH_MEMORY; - goto done; - } - MultiByteToWideChar(CP_ACP, 0, lpCommandLine, -1, CommandLineW, n); - } - - if(lpCurrentDirectory) - { - n = MultiByteToWideChar(CP_ACP, 0, lpCurrentDirectory, -1, NULL, 0); - if(0 == n) - { - ASSERT("MultiByteToWideChar failed!\n"); - palError = ERROR_INTERNAL_ERROR; - goto done; - } - CurrentDirectoryW = (LPWSTR)InternalMalloc(sizeof(WCHAR)*n); - if(!CurrentDirectoryW) - { - ERROR("malloc() failed!\n"); - palError = ERROR_NOT_ENOUGH_MEMORY; - goto done; - } - MultiByteToWideChar(CP_ACP, 0, lpCurrentDirectory, -1, - CurrentDirectoryW, n); - } - - // lpEnvironment should remain ansi on the call to CreateProcessW - - StartupInfoW.cb = sizeof StartupInfoW; - StartupInfoW.dwFlags = lpStartupInfo->dwFlags; - StartupInfoW.hStdError = lpStartupInfo->hStdError; - StartupInfoW.hStdInput = lpStartupInfo->hStdInput; - StartupInfoW.hStdOutput = lpStartupInfo->hStdOutput; - /* all other members are PAL_Undefined, we can ignore them */ - - palError = InternalCreateProcess( - pThread, - ApplicationNameW, - CommandLineW, - lpProcessAttributes, - lpThreadAttributes, - bInheritHandles, - dwCreationFlags, - lpEnvironment, - CurrentDirectoryW, - &StartupInfoW, - lpProcessInformation - ); -done: - free(ApplicationNameW); - free(CommandLineW); - free(CurrentDirectoryW); - - if (NO_ERROR != palError) - { - pThread->SetLastError(palError); - } - - LOGEXIT("CreateProcessA returns BOOL %d\n", NO_ERROR == palError); - PERF_EXIT(CreateProcessA); - return NO_ERROR == palError; -} - - -/*++ -Function: - CreateProcessW - -Note: - Only Standard handles need to be inherited. - Security attributes parameters are not used. - -See MSDN doc. ---*/ -BOOL -PALAPI -CreateProcessW( - IN LPCWSTR lpApplicationName, - IN LPWSTR lpCommandLine, - IN LPSECURITY_ATTRIBUTES lpProcessAttributes, - IN LPSECURITY_ATTRIBUTES lpThreadAttributes, - IN BOOL bInheritHandles, - IN DWORD dwCreationFlags, - IN LPVOID lpEnvironment, - IN LPCWSTR lpCurrentDirectory, - IN LPSTARTUPINFOW lpStartupInfo, - OUT LPPROCESS_INFORMATION lpProcessInformation) -{ - PAL_ERROR palError = NO_ERROR; - CPalThread *pThread; - - PERF_ENTRY(CreateProcessW); - ENTRY("CreateProcessW(lpAppName=%p (%S), lpCmdLine=%p (%S), lpProcessAttr=%p," - "lpThreadAttr=%p, bInherit=%d, dwFlags=%#x, lpEnv=%p," - "lpCurrentDir=%p (%S), lpStartupInfo=%p, lpProcessInfo=%p)\n", - lpApplicationName?lpApplicationName:W16_NULLSTRING, - lpApplicationName?lpApplicationName:W16_NULLSTRING, - lpCommandLine?lpCommandLine:W16_NULLSTRING, - lpCommandLine?lpCommandLine:W16_NULLSTRING,lpProcessAttributes, - lpThreadAttributes, bInheritHandles, dwCreationFlags,lpEnvironment, - lpCurrentDirectory?lpCurrentDirectory:W16_NULLSTRING, - lpCurrentDirectory?lpCurrentDirectory:W16_NULLSTRING, - lpStartupInfo, lpProcessInformation); - - pThread = InternalGetCurrentThread(); - - palError = InternalCreateProcess( - pThread, - lpApplicationName, - lpCommandLine, - lpProcessAttributes, - lpThreadAttributes, - bInheritHandles, - dwCreationFlags, - lpEnvironment, - lpCurrentDirectory, - lpStartupInfo, - lpProcessInformation - ); - - if (NO_ERROR != palError) - { - pThread->SetLastError(palError); - } - - LOGEXIT("CreateProcessW returns BOOL %d\n", NO_ERROR == palError); - PERF_EXIT(CreateProcessW); - - return NO_ERROR == palError; -} - -PAL_ERROR -PrepareStandardHandle( - CPalThread *pThread, - HANDLE hFile, - IPalObject **ppobjFile, - int *piFd - ) -{ - PAL_ERROR palError = NO_ERROR; - IPalObject *pobjFile = NULL; - IDataLock *pDataLock = NULL; - CFileProcessLocalData *pLocalData = NULL; - int iError = 0; - - palError = g_pObjectManager->ReferenceObjectByHandle( - pThread, - hFile, - &aotFile, - 0, - &pobjFile - ); - - if (NO_ERROR != palError) - { - ERROR("Bad handle passed through CreateProcess\n"); - goto PrepareStandardHandleExit; - } - - palError = pobjFile->GetProcessLocalData( - pThread, - ReadLock, - &pDataLock, - reinterpret_cast(&pLocalData) - ); - - if (NO_ERROR != palError) - { - ASSERT("Unable to access file data\n"); - goto PrepareStandardHandleExit; - } - - // - // The passed in file needs to be inheritable - // - - if (!pLocalData->inheritable) - { - ERROR("Non-inheritable handle passed through CreateProcess\n"); - palError = ERROR_INVALID_HANDLE; - goto PrepareStandardHandleExit; - } - - iError = fcntl(pLocalData->unix_fd, F_SETFD, 0); - if (-1 == iError) - { - ERROR("Unable to remove close-on-exec for file (errno %i)\n", errno); - palError = ERROR_INVALID_HANDLE; - goto PrepareStandardHandleExit; - } - - *piFd = pLocalData->unix_fd; - pDataLock->ReleaseLock(pThread, FALSE); - pDataLock = NULL; - - // - // Transfer pobjFile reference to out parameter - // - - *ppobjFile = pobjFile; - pobjFile = NULL; - -PrepareStandardHandleExit: - - if (NULL != pDataLock) - { - pDataLock->ReleaseLock(pThread, FALSE); - } - - if (NULL != pobjFile) - { - pobjFile->ReleaseReference(pThread); - } - - return palError; -} - -PAL_ERROR -CorUnix::InternalCreateProcess( - CPalThread *pThread, - LPCWSTR lpApplicationName, - LPWSTR lpCommandLine, - LPSECURITY_ATTRIBUTES lpProcessAttributes, - LPSECURITY_ATTRIBUTES lpThreadAttributes, - BOOL bInheritHandles, - DWORD dwCreationFlags, - LPVOID lpEnvironment, - LPCWSTR lpCurrentDirectory, - LPSTARTUPINFOW lpStartupInfo, - LPPROCESS_INFORMATION lpProcessInformation - ) -{ - PAL_ERROR palError = NO_ERROR; - IPalObject *pobjProcess = NULL; - IPalObject *pobjProcessRegistered = NULL; - IDataLock *pLocalDataLock = NULL; - CProcProcessLocalData *pLocalData; - IDataLock *pSharedDataLock = NULL; - CPalThread *pDummyThread = NULL; - HANDLE hDummyThread = NULL; - HANDLE hProcess = NULL; - CObjectAttributes oa(NULL, lpProcessAttributes); - - IPalObject *pobjFileIn = NULL; - int iFdIn = -1; - IPalObject *pobjFileOut = NULL; - int iFdOut = -1; - IPalObject *pobjFileErr = NULL; - int iFdErr = -1; - - pid_t processId; - PathCharString lpFileNamePS; - char **lppArgv = NULL; - UINT nArg; - int iRet; - char **EnvironmentArray=NULL; - int child_blocking_pipe = -1; - int parent_blocking_pipe = -1; - - /* Validate parameters */ - - /* note : specs indicate lpApplicationName should always - be NULL; however support for it is already implemented. Leaving the code - in, specs can change; but rejecting non-NULL for now to conform to the - spec. */ - if( NULL != lpApplicationName ) - { - ASSERT("lpApplicationName should be NULL, but is %S instead\n", - lpApplicationName); - palError = ERROR_INVALID_PARAMETER; - goto InternalCreateProcessExit; - } - - if (0 != (dwCreationFlags & ~(CREATE_SUSPENDED|CREATE_NEW_CONSOLE))) - { - ASSERT("Unexpected creation flags (%#x)\n", dwCreationFlags); - palError = ERROR_INVALID_PARAMETER; - goto InternalCreateProcessExit; - } - - /* Security attributes parameters are ignored */ - if (lpProcessAttributes != NULL && - (lpProcessAttributes->lpSecurityDescriptor != NULL || - lpProcessAttributes->bInheritHandle != TRUE)) - { - ASSERT("lpProcessAttributes is invalid, parameter ignored (%p)\n", - lpProcessAttributes); - palError = ERROR_INVALID_PARAMETER; - goto InternalCreateProcessExit; - } - - if (lpThreadAttributes != NULL) - { - ASSERT("lpThreadAttributes parameter must be NULL (%p)\n", - lpThreadAttributes); - palError = ERROR_INVALID_PARAMETER; - goto InternalCreateProcessExit; - } - - /* note : Win32 crashes in this case */ - if(NULL == lpStartupInfo) - { - ERROR("lpStartupInfo is NULL\n"); - palError = ERROR_INVALID_PARAMETER; - goto InternalCreateProcessExit; - } - - /* Validate lpStartupInfo.cb field */ - if (lpStartupInfo->cb < sizeof(STARTUPINFOW)) - { - ASSERT("lpStartupInfo parameter structure size is invalid (%u)\n", - lpStartupInfo->cb); - palError = ERROR_INVALID_PARAMETER; - goto InternalCreateProcessExit; - } - - /* lpStartupInfo should be either zero or STARTF_USESTDHANDLES */ - if (lpStartupInfo->dwFlags & ~STARTF_USESTDHANDLES) - { - ASSERT("lpStartupInfo parameter invalid flags (%#x)\n", - lpStartupInfo->dwFlags); - palError = ERROR_INVALID_PARAMETER; - goto InternalCreateProcessExit; - } - - /* validate given standard handles if we have any */ - if (lpStartupInfo->dwFlags & STARTF_USESTDHANDLES) - { - palError = PrepareStandardHandle( - pThread, - lpStartupInfo->hStdInput, - &pobjFileIn, - &iFdIn - ); - - if (NO_ERROR != palError) - { - goto InternalCreateProcessExit; - } - - palError = PrepareStandardHandle( - pThread, - lpStartupInfo->hStdOutput, - &pobjFileOut, - &iFdOut - ); - - if (NO_ERROR != palError) - { - goto InternalCreateProcessExit; - } - - palError = PrepareStandardHandle( - pThread, - lpStartupInfo->hStdError, - &pobjFileErr, - &iFdErr - ); - - if (NO_ERROR != palError) - { - goto InternalCreateProcessExit; - } - } - - if (!getFileName(lpApplicationName, lpCommandLine, lpFileNamePS)) - { - ERROR("Can't find executable!\n"); - palError = ERROR_FILE_NOT_FOUND; - goto InternalCreateProcessExit; - } - - /* check type of file */ - iRet = checkFileType(lpFileNamePS); - - switch (iRet) - { - case FILE_ERROR: /* file not found, or not an executable */ - WARN ("File is not valid (%s)", lpFileNamePS.GetString()); - palError = ERROR_FILE_NOT_FOUND; - goto InternalCreateProcessExit; - - case FILE_PE: /* PE/COFF file */ - //Get the path name where the PAL DLL was loaded from - if ( PAL_GetPALDirectoryA( lpFileNamePS )) - { - if (lpFileNamePS.Append("/", 1) == FALSE || - lpFileNamePS.Append( PROCESS_PELOADER_FILENAME, strlen(PROCESS_PELOADER_FILENAME)) == FALSE) - { - ERROR("Append failed!\n"); - palError = ERROR_INTERNAL_ERROR; - goto InternalCreateProcessExit; - } - } - else - { - ASSERT("PAL_GetPALDirectoryA failed to return the" - "pal installation directory \n"); - palError = ERROR_INTERNAL_ERROR; - goto InternalCreateProcessExit; - } - - break; - - case FILE_UNIX: /* Unix binary file */ - break; /* nothing to do */ - - case FILE_DIR:/*Directory*/ - WARN ("File is a Directory (%s)", lpFileNamePS.GetString()); - palError = ERROR_ACCESS_DENIED; - goto InternalCreateProcessExit; - break; - - default: /* not supposed to get here */ - ASSERT ("Invalid return type from checkFileType"); - palError = ERROR_FILE_NOT_FOUND; - goto InternalCreateProcessExit; - } - - /* build Argument list, lppArgv is allocated in buildArgv function and - requires to be freed */ - lppArgv = buildArgv(lpCommandLine, lpFileNamePS, &nArg, iRet==1); - - /* set the Environment variable */ - if (lpEnvironment != NULL) - { - unsigned i; - // Since CREATE_UNICODE_ENVIRONMENT isn't supported we know the string is ansi - unsigned EnvironmentEntries = 0; - // Convert the environment block to array of strings - // Count the number of entries - // Is it a string that contains null terminated string, the end is delimited - // by two null in a row. - for (i = 0; ((char *)lpEnvironment)[i]!='\0'; i++) - { - EnvironmentEntries ++; - for (;((char *)lpEnvironment)[i]!='\0'; i++) - { - } - } - EnvironmentEntries++; - EnvironmentArray = (char **)InternalMalloc(EnvironmentEntries * sizeof(char *)); - - EnvironmentEntries = 0; - // Convert the environment block to array of strings - // Count the number of entries - // Is it a string that contains null terminated string, the end is delimited - // by two null in a row. - for (i = 0; ((char *)lpEnvironment)[i]!='\0'; i++) - { - EnvironmentArray[EnvironmentEntries] = &((char *)lpEnvironment)[i]; - EnvironmentEntries ++; - for (;((char *)lpEnvironment)[i]!='\0'; i++) - { - } - } - EnvironmentArray[EnvironmentEntries] = NULL; - } - - // - // Allocate and register the process object for the new process - // - - palError = g_pObjectManager->AllocateObject( - pThread, - &otProcess, - &oa, - &pobjProcess - ); - - if (NO_ERROR != palError) - { - ERROR("Unable to allocate object for new proccess\n"); - goto InternalCreateProcessExit; - } - - palError = g_pObjectManager->RegisterObject( - pThread, - pobjProcess, - &aotProcess, - PROCESS_ALL_ACCESS, - &hProcess, - &pobjProcessRegistered - ); - - // - // pobjProcess is invalidated by the above call, so - // NULL it out here - // - - pobjProcess = NULL; - - if (NO_ERROR != palError) - { - ERROR("Unable to register new process object\n"); - goto InternalCreateProcessExit; - } - - // - // Create a new "dummy" thread object - // - - palError = InternalCreateDummyThread( - pThread, - lpThreadAttributes, - &pDummyThread, - &hDummyThread - ); - - if (dwCreationFlags & CREATE_SUSPENDED) - { - int pipe_descs[2]; - - if (-1 == pipe(pipe_descs)) - { - ERROR("pipe() failed! error is %d (%s)\n", errno, strerror(errno)); - palError = ERROR_NOT_ENOUGH_MEMORY; - goto InternalCreateProcessExit; - } - - /* [0] is read end, [1] is write end */ - pDummyThread->suspensionInfo.SetBlockingPipe(pipe_descs[1]); - parent_blocking_pipe = pipe_descs[1]; - child_blocking_pipe = pipe_descs[0]; - } - - palError = pobjProcessRegistered->GetProcessLocalData( - pThread, - WriteLock, - &pLocalDataLock, - reinterpret_cast(&pLocalData) - ); - - if (NO_ERROR != palError) - { - ASSERT("Unable to obtain local data for new process object\n"); - goto InternalCreateProcessExit; - } - - - /* fork the new process */ - processId = fork(); - - if (processId == -1) - { - ASSERT("Unable to create a new process with fork()\n"); - if (-1 != child_blocking_pipe) - { - close(child_blocking_pipe); - close(parent_blocking_pipe); - } - - palError = ERROR_INTERNAL_ERROR; - goto InternalCreateProcessExit; - } - - /* From the time the child process begins running, to when it reaches execve, - the child process is not a real PAL process and does not own any PAL - resources, although it has access to the PAL resources of its parent process. - Thus, while the child process is in this window, it is dangerous for it to affect - its parent's PAL resources. As a consequence, no PAL code should be used - in this window; all code should make unix calls. Note the use of _exit - instead of exit to avoid calling PAL_Terminate and the lack of TRACE's and - ASSERT's. */ - - if (processId == 0) /* child process */ - { - // At this point, the PAL should be considered uninitialized for this child process. - - // Don't want to enter the init_critsec here since we're trying to avoid - // calling PAL functions. Furthermore, nothing should be changing - // the init_count in the child process at this point since this is the only - // thread executing. - init_count = 0; - - sigset_t sm; - - // - // Clear out the signal mask for the new process. - // - - sigemptyset(&sm); - iRet = sigprocmask(SIG_SETMASK, &sm, NULL); - if (iRet != 0) - { - _exit(EXIT_FAILURE); - } - - if (dwCreationFlags & CREATE_SUSPENDED) - { - BYTE resume_code = 0; - ssize_t read_ret; - - /* close the write end of the pipe, the child doesn't need it */ - close(parent_blocking_pipe); - - read_again: - /* block until ResumeThread writes something to the pipe */ - read_ret = read(child_blocking_pipe, &resume_code, sizeof(resume_code)); - if (sizeof(resume_code) != read_ret) - { - if (read_ret == -1 && EINTR == errno) - { - goto read_again; - } - else - { - /* note : read might return 0 (and return EAGAIN) if the other - end of the pipe gets closed - for example because the parent - process dies (very) abruptly */ - _exit(EXIT_FAILURE); - } - } - if (WAKEUPCODE != resume_code) - { - // resume_code should always equal WAKEUPCODE. - _exit(EXIT_FAILURE); - } - - close(child_blocking_pipe); - } - - /* Set the current directory */ - if (lpCurrentDirectory) - { - SetCurrentDirectoryW(lpCurrentDirectory); - } - - /* Set the standard handles to the incoming values */ - if (lpStartupInfo->dwFlags & STARTF_USESTDHANDLES) - { - /* For each handle, we need to duplicate the incoming unix - fd to the corresponding standard one. The API that I use, - dup2, will copy the source to the destination, automatically - closing the existing destination, in an atomic way */ - if (dup2(iFdIn, STDIN_FILENO) == -1) - { - // Didn't duplicate standard in. - _exit(EXIT_FAILURE); - } - - if (dup2(iFdOut, STDOUT_FILENO) == -1) - { - // Didn't duplicate standard out. - _exit(EXIT_FAILURE); - } - - if (dup2(iFdErr, STDERR_FILENO) == -1) - { - // Didn't duplicate standard error. - _exit(EXIT_FAILURE); - } - - /* now close the original FDs, we don't need them anymore */ - close(iFdIn); - close(iFdOut); - close(iFdErr); - } - - /* execute the new process */ - - if (EnvironmentArray) - { - execve(lpFileNamePS, lppArgv, EnvironmentArray); - } - else - { - execve(lpFileNamePS, lppArgv, palEnvironment); - } - - /* if we get here, it means the execve function call failed so just exit */ - _exit(EXIT_FAILURE); - } - - /* parent process */ - - /* close the read end of the pipe, the parent doesn't need it */ - close(child_blocking_pipe); - - /* Set the process ID */ - pLocalData->dwProcessId = processId; - pLocalDataLock->ReleaseLock(pThread, TRUE); - pLocalDataLock = NULL; - - // - // Release file handle info; we don't need them anymore. Note that - // this must happen after we've released the data locks, as - // otherwise a deadlock could result. - // - - if (lpStartupInfo->dwFlags & STARTF_USESTDHANDLES) - { - pobjFileIn->ReleaseReference(pThread); - pobjFileIn = NULL; - pobjFileOut->ReleaseReference(pThread); - pobjFileOut = NULL; - pobjFileErr->ReleaseReference(pThread); - pobjFileErr = NULL; - } - - /* fill PROCESS_INFORMATION strucutre */ - lpProcessInformation->hProcess = hProcess; - lpProcessInformation->hThread = hDummyThread; - lpProcessInformation->dwProcessId = processId; - lpProcessInformation->dwThreadId_PAL_Undefined = 0; - - - TRACE("New process created: id=%#x\n", processId); - -InternalCreateProcessExit: - - if (NULL != pLocalDataLock) - { - pLocalDataLock->ReleaseLock(pThread, FALSE); - } - - if (NULL != pSharedDataLock) - { - pSharedDataLock->ReleaseLock(pThread, FALSE); - } - - if (NULL != pobjProcess) - { - pobjProcess->ReleaseReference(pThread); - } - - if (NULL != pobjProcessRegistered) - { - pobjProcessRegistered->ReleaseReference(pThread); - } - - if (NO_ERROR != palError) - { - if (NULL != hProcess) - { - g_pObjectManager->RevokeHandle(pThread, hProcess); - } - - if (NULL != hDummyThread) - { - g_pObjectManager->RevokeHandle(pThread, hDummyThread); - } - } - - if (EnvironmentArray) - { - free(EnvironmentArray); - } - - /* if we still have the file structures at this point, it means we - encountered an error sometime between when we acquired them and when we - fork()ed. We not only have to release them, we have to give them back - their close-on-exec flag */ - if (NULL != pobjFileIn) - { - if(-1 == fcntl(iFdIn, F_SETFD, 1)) - { - WARN("couldn't restore close-on-exec flag to stdin descriptor! " - "errno is %d (%s)\n", errno, strerror(errno)); - } - pobjFileIn->ReleaseReference(pThread); - } - - if (NULL != pobjFileOut) - { - if(-1 == fcntl(iFdOut, F_SETFD, 1)) - { - WARN("couldn't restore close-on-exec flag to stdout descriptor! " - "errno is %d (%s)\n", errno, strerror(errno)); - } - pobjFileOut->ReleaseReference(pThread); - } - - if (NULL != pobjFileErr) - { - if(-1 == fcntl(iFdErr, F_SETFD, 1)) - { - WARN("couldn't restore close-on-exec flag to stderr descriptor! " - "errno is %d (%s)\n", errno, strerror(errno)); - } - pobjFileErr->ReleaseReference(pThread); - } - - /* free allocated memory */ - if (lppArgv) - { - free(*lppArgv); - free(lppArgv); - } - - return palError; -} - - -/*++ -Function: - GetExitCodeProcess - -See MSDN doc. ---*/ -BOOL -PALAPI -GetExitCodeProcess( - IN HANDLE hProcess, - IN LPDWORD lpExitCode) -{ - CPalThread *pThread; - PAL_ERROR palError = NO_ERROR; - DWORD dwExitCode; - PROCESS_STATE ps; - - PERF_ENTRY(GetExitCodeProcess); - ENTRY("GetExitCodeProcess(hProcess = %p, lpExitCode = %p)\n", - hProcess, lpExitCode); - - pThread = InternalGetCurrentThread(); - - if(NULL == lpExitCode) - { - WARN("Got NULL lpExitCode\n"); - palError = ERROR_INVALID_PARAMETER; - goto done; - } - - palError = PROCGetProcessStatus( - pThread, - hProcess, - &ps, - &dwExitCode - ); - - if (NO_ERROR != palError) - { - ASSERT("Couldn't get process status information!\n"); - goto done; - } - - if( PS_DONE == ps ) - { - *lpExitCode = dwExitCode; - } - else - { - *lpExitCode = STILL_ACTIVE; - } - -done: - - if (NO_ERROR != palError) - { - pThread->SetLastError(palError); - } - - LOGEXIT("GetExitCodeProcess returns BOOL %d\n", NO_ERROR == palError); - PERF_EXIT(GetExitCodeProcess); - - return NO_ERROR == palError; -} - -/*++ -Function: - ExitProcess - -See MSDN doc. ---*/ -PAL_NORETURN -VOID -PALAPI -ExitProcess( - IN UINT uExitCode) -{ - DWORD old_terminator; - - PERF_ENTRY_ONLY(ExitProcess); - ENTRY("ExitProcess(uExitCode=0x%x)\n", uExitCode ); - - old_terminator = InterlockedCompareExchange(&terminator, GetCurrentThreadId(), 0); - - if (GetCurrentThreadId() == old_terminator) - { - // This thread has already initiated termination. This can happen - // in two ways: - // 1) DllMain(DLL_PROCESS_DETACH) triggers a call to ExitProcess. - // 2) PAL_exit() is called after the last PALTerminate(). - // If the PAL is still initialized, we go straight through to - // PROCEndProcess. If it isn't, we simply exit. - if (!PALIsInitialized()) - { - exit(uExitCode); - ASSERT("exit has returned\n"); - } - else - { - WARN("thread re-called ExitProcess\n"); - PROCEndProcess(GetCurrentProcess(), uExitCode, FALSE); - } - } - else if (0 != old_terminator) - { - /* another thread has already initiated the termination process. we - could just block on the PALInitLock critical section, but then - PROCSuspendOtherThreads would hang... so sleep forever here, we're - terminating anyway - - Update: [TODO] PROCSuspendOtherThreads has been removed. Can this - code be changed? */ - WARN("termination already started from another thread; blocking.\n"); - poll(NULL, 0, INFTIM); - } - - /* ExitProcess may be called even if PAL is not initialized. - Verify if process structure exist - */ - if (PALInitLock() && PALIsInitialized()) - { - PROCEndProcess(GetCurrentProcess(), uExitCode, FALSE); - - /* Should not get here, because we terminate the current process */ - ASSERT("PROCEndProcess has returned\n"); - } - else - { - exit(uExitCode); - - /* Should not get here, because we terminate the current process */ - ASSERT("exit has returned\n"); - } - - /* this should never get executed */ - ASSERT("ExitProcess should not return!\n"); - for (;;); -} - -/*++ -Function: - TerminateProcess - -Note: - hProcess is a handle on the current process. - -See MSDN doc. ---*/ -BOOL -PALAPI -TerminateProcess( - IN HANDLE hProcess, - IN UINT uExitCode) -{ - BOOL ret; - - PERF_ENTRY(TerminateProcess); - ENTRY("TerminateProcess(hProcess=%p, uExitCode=%u)\n",hProcess, uExitCode ); - - ret = PROCEndProcess(hProcess, uExitCode, TRUE); - - LOGEXIT("TerminateProcess returns BOOL %d\n", ret); - PERF_EXIT(TerminateProcess); - return ret; -} - -/*++ -Function: - PROCEndProcess - - Called from TerminateProcess and ExitProcess. This does the work of - TerminateProcess, but also takes a flag that determines whether we - shut down unconditionally. If the flag is set, the PAL will do very - little extra work before exiting. Most importantly, it won't shut - down any DLLs that are loaded. - ---*/ -static BOOL PROCEndProcess(HANDLE hProcess, UINT uExitCode, BOOL bTerminateUnconditionally) -{ - DWORD dwProcessId; - BOOL ret = FALSE; - - dwProcessId = PROCGetProcessIDFromHandle(hProcess); - if (dwProcessId == 0) - { - SetLastError(ERROR_INVALID_HANDLE); - } - else if(dwProcessId != GetCurrentProcessId()) - { - if (uExitCode != 0) - WARN("exit code 0x%x ignored for external process.\n", uExitCode); - - if (kill(dwProcessId, SIGKILL) == 0) - { - ret = TRUE; - } - else - { - switch (errno) { - case ESRCH: - SetLastError(ERROR_INVALID_HANDLE); - break; - case EPERM: - SetLastError(ERROR_ACCESS_DENIED); - break; - default: - // Unexpected failure. - ASSERT(FALSE); - SetLastError(ERROR_INTERNAL_ERROR); - break; - } - } - } - else - { - // WARN/ERROR before starting the termination process and/or leaving the PAL. - if (bTerminateUnconditionally) - { - WARN("exit code 0x%x ignored for terminate.\n", uExitCode); - } - else if ((uExitCode & 0xff) != uExitCode) - { - // TODO: Convert uExitCodes into sysexits(3)? - ERROR("exit() only supports the lower 8-bits of an exit code. " - "status will only see error 0x%x instead of 0x%x.\n", uExitCode & 0xff, uExitCode); - } - - TerminateCurrentProcessNoExit(bTerminateUnconditionally); - - LOGEXIT("PROCEndProcess will not return\n"); - - // exit() runs atexit handlers possibly registered by foreign code. - // The right thing to do here is to leave the PAL. If our client - // registered our own PAL_Terminate with atexit(), the latter will - // explicitly re-enter us. - PAL_Leave(PAL_BoundaryBottom); - - if (bTerminateUnconditionally) - { - // abort() has the semantics that - // (1) it doesn't run atexit handlers - // (2) can invoke CrashReporter or produce a coredump, - // which is appropriate for TerminateProcess calls - PROCAbort(); - } - else - { - exit(uExitCode); - } - - ASSERT(FALSE); // we shouldn't get here - } - - return ret; -} - -/*++ -Function: - PAL_SetShutdownCallback - -Abstract: - Sets a callback that is executed when the PAL is shut down because of - ExitProcess, TerminateProcess or PAL_Shutdown but not PAL_Terminate/Ex. - - NOTE: Currently only one callback can be set at a time. ---*/ -PALIMPORT -VOID -PALAPI -PAL_SetShutdownCallback( - IN PSHUTDOWN_CALLBACK callback) -{ - _ASSERTE(g_shutdownCallback == nullptr); - g_shutdownCallback = callback; -} - -static bool IsCoreClrModule(const char* pModulePath) -{ - // Strip off everything up to and including the last slash in the path to get name - const char* pModuleName = pModulePath; - while (strchr(pModuleName, '/') != NULL) - { - pModuleName = strchr(pModuleName, '/'); - pModuleName++; // pass the slash - } - - return _stricmp(pModuleName, MAKEDLLNAME_A("coreclr")) == 0; -} - -// Build the semaphore names using the PID and a value that can be used for distinguishing -// between processes with the same PID (which ran at different times). This is to avoid -// cases where a prior process with the same PID exited abnormally without having a chance -// to clean up its semaphore. -// Note to anyone modifying these names in the future: Semaphore names on OS X are limited -// to SEM_NAME_LEN characters, including null. SEM_NAME_LEN is 31 (at least on OS X 10.11). -// NetBSD limits semaphore names to 15 characters, including null (at least up to 7.99.25). -// Keep 31 length for Core 1.0 RC2 compatibility -#if defined(__NetBSD__) -static const char* RuntimeStartupSemaphoreName = "/clrst%08llx"; -static const char* RuntimeContinueSemaphoreName = "/clrco%08llx"; -#else -static const char* RuntimeStartupSemaphoreName = "/clrst%08x%016llx"; -static const char* RuntimeContinueSemaphoreName = "/clrco%08x%016llx"; -#endif - -#if defined(__NetBSD__) -static uint64_t HashSemaphoreName(uint64_t a, uint64_t b) -{ - return (a ^ b) & 0xffffffff; -} -#else -#define HashSemaphoreName(a,b) a,b -#endif - -static const char* PipeNameFormat = "clr-debug-pipe-%d-%llu-%s"; - -class PAL_RuntimeStartupHelper -{ - LONG m_ref; - bool m_canceled; - PPAL_STARTUP_CALLBACK m_callback; - PVOID m_parameter; - DWORD m_threadId; - HANDLE m_threadHandle; - DWORD m_processId; - - // A value that, used in conjunction with the process ID, uniquely identifies a process. - // See the format we use for debugger semaphore names for why this is necessary. - UINT64 m_processIdDisambiguationKey; - - // Debugger waits on this semaphore and the runtime signals it on startup. - sem_t *m_startupSem; - - // Debuggee waits on this semaphore and the debugger signals it after the startup callback - // registered (m_callback) returns. - sem_t *m_continueSem; - -public: - PAL_RuntimeStartupHelper(DWORD dwProcessId, PPAL_STARTUP_CALLBACK pfnCallback, PVOID parameter) : - m_ref(1), - m_canceled(false), - m_callback(pfnCallback), - m_parameter(parameter), - m_threadId(0), - m_threadHandle(NULL), - m_processId(dwProcessId), - m_startupSem(SEM_FAILED), - m_continueSem(SEM_FAILED) - { - } - - ~PAL_RuntimeStartupHelper() - { - if (m_startupSem != SEM_FAILED) - { - char startupSemName[CLR_SEM_MAX_NAMELEN]; - sprintf_s(startupSemName, - sizeof(startupSemName), - RuntimeStartupSemaphoreName, - HashSemaphoreName(m_processId, - m_processIdDisambiguationKey)); - - sem_close(m_startupSem); - sem_unlink(startupSemName); - } - - if (m_continueSem != SEM_FAILED) - { - char continueSemName[CLR_SEM_MAX_NAMELEN]; - sprintf_s(continueSemName, - sizeof(continueSemName), - RuntimeContinueSemaphoreName, - HashSemaphoreName(m_processId, - m_processIdDisambiguationKey)); - - sem_close(m_continueSem); - sem_unlink(continueSemName); - } - - if (m_threadHandle != NULL) - { - CloseHandle(m_threadHandle); - } - } - - LONG AddRef() - { - LONG ref = InterlockedIncrement(&m_ref); - return ref; - } - - LONG Release() - { - LONG ref = InterlockedDecrement(&m_ref); - if (ref == 0) - { - delete this; - } - return ref; - } - - PAL_ERROR GetSemError() - { - PAL_ERROR pe; - switch (errno) - { - case ENOENT: - pe = ERROR_NOT_FOUND; - break; - case EACCES: - pe = ERROR_INVALID_ACCESS; - break; - case EINVAL: - case ENAMETOOLONG: - pe = ERROR_INVALID_NAME; - break; - case ENOMEM: - pe = ERROR_OUTOFMEMORY; - break; - case EEXIST: - pe = ERROR_ALREADY_EXISTS; - break; - case ENOSPC: - pe = ERROR_TOO_MANY_SEMAPHORES; - break; - default: - pe = ERROR_INVALID_PARAMETER; - break; - } - return pe; - } - - PAL_ERROR Register() - { - CPalThread *pThread = InternalGetCurrentThread(); - char startupSemName[CLR_SEM_MAX_NAMELEN]; - char continueSemName[CLR_SEM_MAX_NAMELEN]; - PAL_ERROR pe = NO_ERROR; - - // See semaphore name format for details about this value. We store it so that - // it can be used by the cleanup code that removes the semaphore with sem_unlink. - INDEBUG(BOOL disambiguationKeyRet = ) - GetProcessIdDisambiguationKey(m_processId, &m_processIdDisambiguationKey); - _ASSERTE(disambiguationKeyRet == TRUE || m_processIdDisambiguationKey == 0); - - sprintf_s(startupSemName, - sizeof(startupSemName), - RuntimeStartupSemaphoreName, - HashSemaphoreName(m_processId, - m_processIdDisambiguationKey)); - - sprintf_s(continueSemName, - sizeof(continueSemName), - RuntimeContinueSemaphoreName, - HashSemaphoreName(m_processId, - m_processIdDisambiguationKey)); - - TRACE("PAL_RuntimeStartupHelper.Register creating startup '%s' continue '%s'\n", startupSemName, continueSemName); - - // Create the continue semaphore first so we don't race with PAL_NotifyRuntimeStarted. This open will fail if another - // debugger is trying to attach to this process because the name will already exist. - m_continueSem = sem_open(continueSemName, O_CREAT | O_EXCL, S_IRWXU, 0); - if (m_continueSem == SEM_FAILED) - { - TRACE("sem_open(continue) failed: errno is %d (%s)\n", errno, strerror(errno)); - pe = GetSemError(); - goto exit; - } - - // Create the debuggee startup semaphore so the runtime (debuggee) knows to wait for a debugger connection. - m_startupSem = sem_open(startupSemName, O_CREAT | O_EXCL, S_IRWXU, 0); - if (m_startupSem == SEM_FAILED) - { - TRACE("sem_open(startup) failed: errno is %d (%s)\n", errno, strerror(errno)); - pe = GetSemError(); - goto exit; - } - - // Add a reference for the thread handler - AddRef(); - - pe = InternalCreateThread( - pThread, - NULL, - 0, - ::StartupHelperThread, - this, - 0, - UserCreatedThread, - &m_threadId, - &m_threadHandle); - - if (NO_ERROR != pe) - { - TRACE("InternalCreateThread failed %d\n", pe); - Release(); - goto exit; - } - - exit: - return pe; - } - - void Unregister() - { - m_canceled = true; - - // Tell the runtime to continue - if (sem_post(m_continueSem) != 0) - { - ASSERT("sem_post(continueSem) failed: errno is %d (%s)\n", errno, strerror(errno)); - } - - // Tell the worker thread to continue - if (sem_post(m_startupSem) != 0) - { - ASSERT("sem_post(startupSem) failed: errno is %d (%s)\n", errno, strerror(errno)); - } - - // Don't need to wait for the worker thread if unregister called on it - if (m_threadId != (DWORD)THREADSilentGetCurrentThreadId()) - { - // Wait for work thread to exit - if (WaitForSingleObject(m_threadHandle, INFINITE) != WAIT_OBJECT_0) - { - ASSERT("WaitForSingleObject\n"); - } - } - } - - // - // There are a couple race conditions that need to be considered here: - // - // * On launch, between the fork and execv in the PAL's CreateProcess where the target process - // may contain a coreclr module image if the debugger process is running managed code. This - // makes just checking if the coreclr module exists not enough. - // - // * On launch (after the execv) or attach when the coreclr is loaded but before the DAC globals - // table is initialized where it is too soon to use/initialize the DAC on the debugger side. - // - // They are both fixed by check if the one of transport pipe files has been created. - // - bool IsCoreClrProcessReady() - { - char pipeName[MAX_DEBUGGER_TRANSPORT_PIPE_NAME_LENGTH]; - - PAL_GetTransportPipeName(pipeName, m_processId, "in"); - - struct stat buf; - if (stat(pipeName, &buf) == 0) - { - TRACE("IsCoreClrProcessReady: stat(%s) SUCCEEDED\n", pipeName); - return true; - } - TRACE("IsCoreClrProcessReady: stat(%s) FAILED: errno is %d (%s)\n", pipeName, errno, strerror(errno)); - return false; - } - - PAL_ERROR InvokeStartupCallback() - { - ProcessModules *listHead = NULL; - PAL_ERROR pe = NO_ERROR; - DWORD count; - - if (m_canceled) - { - goto exit; - } - - // Enumerate all the modules in the process and invoke the callback - // for the coreclr module if found. - listHead = CreateProcessModules(m_processId, &count); - if (listHead == NULL) - { - TRACE("CreateProcessModules failed for pid %d\n", m_processId); - pe = ERROR_INVALID_PARAMETER; - goto exit; - } - - for (ProcessModules *entry = listHead; entry != NULL; entry = entry->Next) - { - if (IsCoreClrModule(entry->Name)) - { - PAL_CPP_TRY - { - TRACE("InvokeStartupCallback executing callback %p %s\n", entry->BaseAddress, entry->Name); - m_callback(entry->Name, entry->BaseAddress, m_parameter); - } - PAL_CPP_CATCH_ALL - { - } - PAL_CPP_ENDTRY - - // Currently only the first coreclr module in a process is supported - break; - } - } - - exit: - // Wake up the runtime - if (sem_post(m_continueSem) != 0) - { - ASSERT("sem_post(continueSem) failed: errno is %d (%s)\n", errno, strerror(errno)); - } - if (listHead != NULL) - { - DestroyProcessModules(listHead); - } - return pe; - } - - void StartupHelperThread() - { - PAL_ERROR pe = NO_ERROR; - - if (IsCoreClrProcessReady()) - { - pe = InvokeStartupCallback(); - } - else { - TRACE("sem_wait(startup)\n"); - - // Wait until the coreclr runtime (debuggee) starts up - if (sem_wait(m_startupSem) == 0) - { - pe = InvokeStartupCallback(); - } - else - { - TRACE("sem_wait(startup) failed: errno is %d (%s)\n", errno, strerror(errno)); - pe = GetSemError(); - } - } - - // Invoke the callback on errors - if (pe != NO_ERROR && !m_canceled) - { - SetLastError(pe); - m_callback(NULL, NULL, m_parameter); - } - } -}; - -static -DWORD -PALAPI -StartupHelperThread(LPVOID p) -{ - TRACE("PAL's StartupHelperThread starting\n"); - - PAL_RuntimeStartupHelper *helper = (PAL_RuntimeStartupHelper *)p; - helper->StartupHelperThread(); - helper->Release(); - return 0; -} - -/*++ - PAL_RegisterForRuntimeStartup - -Parameters: - dwProcessId - process id of runtime process - pfnCallback - function to callback for coreclr module found - parameter - data to pass to callback - ppUnregisterToken - pointer to put PAL_UnregisterForRuntimeStartup token. - -Return value: - PAL_ERROR - -Note: - If the modulePath or hModule is NULL when the callback is invoked, an error occured - and GetLastError() will return the Win32 error code. - - The callback is always invoked on a separate thread and this API returns immediately. - - Only the first coreclr module is currently supported. - ---*/ -DWORD -PALAPI -PAL_RegisterForRuntimeStartup( - IN DWORD dwProcessId, - IN PPAL_STARTUP_CALLBACK pfnCallback, - IN PVOID parameter, - OUT PVOID *ppUnregisterToken) -{ - _ASSERTE(pfnCallback != NULL); - _ASSERTE(ppUnregisterToken != NULL); - - PAL_RuntimeStartupHelper *helper = new PAL_RuntimeStartupHelper(dwProcessId, pfnCallback, parameter); - - // Create the debuggee startup semaphore so the runtime (debuggee) knows to wait for - // a debugger connection. - PAL_ERROR pe = helper->Register(); - if (NO_ERROR != pe) - { - helper->Release(); - helper = NULL; - } - - *ppUnregisterToken = helper; - return pe; -} - -/*++ - PAL_UnregisterForRuntimeStartup - - Stops/cancels startup notification. This API can be called in the startup callback. Otherwise, - it will block until the callback thread finishes and no more callbacks will be initiated after - this API returns. - -Parameters: - dwUnregisterToken - token from PAL_RegisterForRuntimeStartup or NULL. - -Return value: - PAL_ERROR ---*/ -DWORD -PALAPI -PAL_UnregisterForRuntimeStartup( - IN PVOID pUnregisterToken) -{ - if (pUnregisterToken != NULL) - { - PAL_RuntimeStartupHelper *helper = (PAL_RuntimeStartupHelper *)pUnregisterToken; - helper->Unregister(); - helper->Release(); - } - return NO_ERROR; -} - -/*++ - PAL_NotifyRuntimeStarted - - Signals the debugger waiting for runtime startup notification to continue and - waits until the debugger signals us to continue. - -Parameters: - None - -Return value: - TRUE - successfully launched by debugger, FALSE - not launched or some failure in the handshake ---*/ -BOOL -PALAPI -PAL_NotifyRuntimeStarted() -{ - char startupSemName[CLR_SEM_MAX_NAMELEN]; - char continueSemName[CLR_SEM_MAX_NAMELEN]; - sem_t *startupSem = SEM_FAILED; - sem_t *continueSem = SEM_FAILED; - BOOL launched = FALSE; - - UINT64 processIdDisambiguationKey = 0; - GetProcessIdDisambiguationKey(gPID, &processIdDisambiguationKey); - - sprintf_s(startupSemName, sizeof(startupSemName), RuntimeStartupSemaphoreName, HashSemaphoreName(gPID, processIdDisambiguationKey)); - sprintf_s(continueSemName, sizeof(continueSemName), RuntimeContinueSemaphoreName, HashSemaphoreName(gPID, processIdDisambiguationKey)); - - TRACE("PAL_NotifyRuntimeStarted opening continue '%s' startup '%s'\n", continueSemName, startupSemName); - - // Open the debugger startup semaphore. If it doesn't exists, then we do nothing and return - startupSem = sem_open(startupSemName, 0); - if (startupSem == SEM_FAILED) - { - TRACE("sem_open(%s) failed: %d (%s)\n", startupSemName, errno, strerror(errno)); - goto exit; - } - - continueSem = sem_open(continueSemName, 0); - if (continueSem == SEM_FAILED) - { - ASSERT("sem_open(%s) failed: %d (%s)\n", continueSemName, errno, strerror(errno)); - goto exit; - } - - // Wake up the debugger waiting for startup - if (sem_post(startupSem) != 0) - { - ASSERT("sem_post(startupSem) failed: errno is %d (%s)\n", errno, strerror(errno)); - goto exit; - } - - // Now wait until the debugger's runtime startup notification is finished - if (sem_wait(continueSem) != 0) - { - ASSERT("sem_wait(continueSem) failed: errno is %d (%s)\n", errno, strerror(errno)); - goto exit; - } - - // Returns that the runtime was successfully launched for debugging - launched = TRUE; - -exit: - if (startupSem != SEM_FAILED) - { - sem_close(startupSem); - } - if (continueSem != SEM_FAILED) - { - sem_close(continueSem); - } - return launched; -} - -/*++ - Function: - GetProcessIdDisambiguationKey - - Get a numeric value that can be used to disambiguate between processes with the same PID, - provided that one of them is still running. The numeric value can mean different things - on different platforms, so it should not be used for any other purpose. Under the hood, - it is implemented based on the creation time of the process. ---*/ -BOOL -GetProcessIdDisambiguationKey(DWORD processId, UINT64 *disambiguationKey) -{ - if (disambiguationKey == nullptr) - { - _ASSERTE(!"disambiguationKey argument cannot be null!"); - return FALSE; - } - - *disambiguationKey = 0; - -#if defined(__APPLE__) - - // On OS X, we return the process start time expressed in Unix time (the number of seconds - // since the start of the Unix epoch). - struct kinfo_proc info = {}; - size_t size = sizeof(info); - int mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_PID, processId }; - int ret = ::sysctl(mib, sizeof(mib)/sizeof(*mib), &info, &size, nullptr, 0); - - if (ret == 0) - { - timeval procStartTime = info.kp_proc.p_starttime; - long secondsSinceEpoch = procStartTime.tv_sec; - - *disambiguationKey = secondsSinceEpoch; - return TRUE; - } - else - { - _ASSERTE(!"Failed to get start time of a process."); - return FALSE; - } - -#elif defined(__NetBSD__) - - // On NetBSD, we return the process start time expressed in Unix time (the number of seconds - // since the start of the Unix epoch). - kvm_t *kd; - int cnt; - struct kinfo_proc2 *info; - - kd = kvm_open(nullptr, nullptr, nullptr, KVM_NO_FILES, "kvm_open"); - if (kd == nullptr) - { - _ASSERTE(!"Failed to get start time of a process."); - return FALSE; - } - - info = kvm_getproc2(kd, KERN_PROC_PID, processId, sizeof(struct kinfo_proc2), &cnt); - if (info == nullptr || cnt < 1) - { - kvm_close(kd); - _ASSERTE(!"Failed to get start time of a process."); - return FALSE; - } - - kvm_close(kd); - - long secondsSinceEpoch = info->p_ustart_sec; - *disambiguationKey = secondsSinceEpoch; - - return TRUE; - -#elif HAVE_PROCFS_STAT - - // Here we read /proc//stat file to get the start time for the process. - // We return this value (which is expressed in jiffies since boot time). - - // Making something like: /proc/123/stat - char statFileName[64]; - - INDEBUG(int chars = ) - snprintf(statFileName, sizeof(statFileName), "/proc/%d/stat", processId); - _ASSERTE(chars > 0 && chars <= sizeof(statFileName)); - - FILE *statFile = fopen(statFileName, "r"); - if (statFile == nullptr) - { - SetLastError(ERROR_INVALID_HANDLE); - return FALSE; - } - - char *line = nullptr; - size_t lineLen = 0; - if (getline(&line, &lineLen, statFile) == -1) - { - _ASSERTE(!"Failed to getline from the stat file for a process."); - return FALSE; - } - - unsigned long long starttime; - - // According to `man proc`, the second field in the stat file is the filename of the executable, - // in parentheses. Tokenizing the stat file using spaces as separators breaks when that name - // has spaces in it, so we start using sscanf_s after skipping everything up to and including the - // last closing paren and the space after it. - char *scanStartPosition = strrchr(line, ')') + 2; - - // All the format specifiers for the fields in the stat file are provided by 'man proc'. - int sscanfRet = sscanf_s(scanStartPosition, - "%*c %*d %*d %*d %*d %*d %*u %*lu %*lu %*lu %*lu %*lu %*lu %*ld %*ld %*ld %*ld %*ld %*ld %llu \n", - &starttime); - - if (sscanfRet != 1) - { - _ASSERTE(!"Failed to parse stat file contents with sscanf_s."); - return FALSE; - } - - free(line); - fclose(statFile); - - *disambiguationKey = starttime; - return TRUE; - -#else - // If this is not OS X and we don't have /proc, we just return FALSE. - WARN("GetProcessIdDisambiguationKey was called but is not implemented on this platform!"); - return FALSE; -#endif -} - -/*++ - Function: - PAL_GetTransportPipeName - - Builds the transport pipe names from the process id. ---*/ -VOID -PALAPI -PAL_GetTransportPipeName( - OUT char *name, - IN DWORD id, - IN const char *suffix) -{ - *name = '\0'; - DWORD dwRetVal = 0; - UINT64 disambiguationKey = 0; - char formatBuffer[MAX_DEBUGGER_TRANSPORT_PIPE_NAME_LENGTH]; - BOOL ret = GetProcessIdDisambiguationKey(id, &disambiguationKey); - - // If GetProcessIdDisambiguationKey failed for some reason, it should set the value - // to 0. We expect that anyone else making the pipe name will also fail and thus will - // also try to use 0 as the value. - _ASSERTE(ret == TRUE || disambiguationKey == 0); - - // Get a temp file location - dwRetVal = ::GetTempPathA(MAX_DEBUGGER_TRANSPORT_PIPE_NAME_LENGTH, formatBuffer); - if (dwRetVal == 0) - { - ERROR("GetTempPath failed (0x%08x)", ::GetLastError()); - return; - } - if (dwRetVal > MAX_DEBUGGER_TRANSPORT_PIPE_NAME_LENGTH) - { - ERROR("GetTempPath returned a path that was larger than MAX_DEBUGGER_TRANSPORT_PIPE_NAME_LENGTH"); - return; - } - - if (strncat_s(formatBuffer, _countof(formatBuffer), PipeNameFormat, strlen(PipeNameFormat)) == STRUNCATE) - { - ERROR("TransportPipeName was larger than MAX_DEBUGGER_TRANSPORT_PIPE_NAME_LENGTH"); - return; - } - - int chars = snprintf(name, MAX_DEBUGGER_TRANSPORT_PIPE_NAME_LENGTH, formatBuffer, id, disambiguationKey, suffix); - _ASSERTE(chars > 0 && chars < MAX_DEBUGGER_TRANSPORT_PIPE_NAME_LENGTH); -} - -/*++ -Function: - GetProcessTimes - -See MSDN doc. ---*/ -BOOL -PALAPI -GetProcessTimes( - IN HANDLE hProcess, - OUT LPFILETIME lpCreationTime, - OUT LPFILETIME lpExitTime, - OUT LPFILETIME lpKernelTime, - OUT LPFILETIME lpUserTime) -{ - BOOL retval = FALSE; - struct rusage resUsage; - __int64 calcTime; - const __int64 SECS_TO_NS = 1000000000; /* 10^9 */ - const __int64 USECS_TO_NS = 1000; /* 10^3 */ - - - PERF_ENTRY(GetProcessTimes); - ENTRY("GetProcessTimes(hProcess=%p, lpExitTime=%p, lpKernelTime=%p," - "lpUserTime=%p)\n", - hProcess, lpCreationTime, lpExitTime, lpKernelTime, lpUserTime ); - - /* Make sure hProcess is the current process, this is the only supported - case */ - if(PROCGetProcessIDFromHandle(hProcess)!=GetCurrentProcessId()) - { - ASSERT("GetProcessTimes() does not work on a process other than the " - "current process.\n"); - SetLastError(ERROR_INVALID_HANDLE); - goto GetProcessTimesExit; - } - - /* First, we need to actually retrieve the relevant statistics from the - OS */ - if (getrusage (RUSAGE_SELF, &resUsage) == -1) - { - ASSERT("Unable to get resource usage information for the current " - "process\n"); - SetLastError(ERROR_INTERNAL_ERROR); - goto GetProcessTimesExit; - } - - TRACE ("getrusage User: %ld sec,%ld microsec. Kernel: %ld sec,%ld" - " microsec\n", - resUsage.ru_utime.tv_sec, resUsage.ru_utime.tv_usec, - resUsage.ru_stime.tv_sec, resUsage.ru_stime.tv_usec); - - if (lpUserTime) - { - /* Get the time of user mode execution, in 100s of nanoseconds */ - calcTime = (__int64)resUsage.ru_utime.tv_sec * SECS_TO_NS; - calcTime += (__int64)resUsage.ru_utime.tv_usec * USECS_TO_NS; - calcTime /= 100; /* Produce the time in 100s of ns */ - /* Assign the time into lpUserTime */ - lpUserTime->dwLowDateTime = (DWORD)calcTime; - lpUserTime->dwHighDateTime = (DWORD)(calcTime >> 32); - } - - if (lpKernelTime) - { - /* Get the time of kernel mode execution, in 100s of nanoseconds */ - calcTime = (__int64)resUsage.ru_stime.tv_sec * SECS_TO_NS; - calcTime += (__int64)resUsage.ru_stime.tv_usec * USECS_TO_NS; - calcTime /= 100; /* Produce the time in 100s of ns */ - /* Assign the time into lpUserTime */ - lpKernelTime->dwLowDateTime = (DWORD)calcTime; - lpKernelTime->dwHighDateTime = (DWORD)(calcTime >> 32); - } - - retval = TRUE; - - -GetProcessTimesExit: - LOGEXIT("GetProcessTimes returns BOOL %d\n", retval); - PERF_EXIT(GetProcessTimes); - return (retval); -} - -#define FILETIME_TO_ULONGLONG(f) \ - (((ULONGLONG)(f).dwHighDateTime << 32) | ((ULONGLONG)(f).dwLowDateTime)) - -/*++ -Function: - PAL_GetCPUBusyTime - -The main purpose of this function is to compute the overall CPU utilization -for the CLR thread pool to regulate the number of I/O completion port -worker threads. -Since there is no consistent API on Unix to get the CPU utilization -from a user process, getrusage and gettimeofday are used to -compute the current process's CPU utilization instead. -This function emulates the ThreadpoolMgr::GetCPUBusyTime_NT function in -win32threadpool.cpp of the CLR. - -See MSDN doc for GetSystemTimes. ---*/ -INT -PALAPI -PAL_GetCPUBusyTime( - IN OUT PAL_IOCP_CPU_INFORMATION *lpPrevCPUInfo) -{ - ULONGLONG nLastRecordedCurrentTime = 0; - ULONGLONG nLastRecordedUserTime = 0; - ULONGLONG nLastRecordedKernelTime = 0; - ULONGLONG nKernelTime = 0; - ULONGLONG nUserTime = 0; - ULONGLONG nCurrentTime = 0; - ULONGLONG nCpuBusyTime = 0; - ULONGLONG nCpuTotalTime = 0; - DWORD nReading = 0; - struct rusage resUsage; - struct timeval tv; - static DWORD dwNumberOfProcessors = 0; - - if (dwNumberOfProcessors <= 0) - { - SYSTEM_INFO SystemInfo; - GetSystemInfo(&SystemInfo); - dwNumberOfProcessors = SystemInfo.dwNumberOfProcessors; - if (dwNumberOfProcessors <= 0) - { - return 0; - } - } - - if (getrusage(RUSAGE_SELF, &resUsage) == -1) - { - ASSERT("getrusage() failed; errno is %d (%s)\n", errno, strerror(errno)); - return 0; - } - else - { - nKernelTime = (ULONGLONG)resUsage.ru_stime.tv_sec*tccSecondsTo100NanoSeconds + - resUsage.ru_stime.tv_usec*tccMicroSecondsTo100NanoSeconds; - nUserTime = (ULONGLONG)resUsage.ru_utime.tv_sec*tccSecondsTo100NanoSeconds + - resUsage.ru_utime.tv_usec*tccMicroSecondsTo100NanoSeconds; - } - - if (gettimeofday(&tv, NULL) == -1) - { - ASSERT("gettimeofday() failed; errno is %d (%s)\n", errno, strerror(errno)); - return 0; - } - else - { - nCurrentTime = (ULONGLONG)tv.tv_sec*tccSecondsTo100NanoSeconds + - tv.tv_usec*tccMicroSecondsTo100NanoSeconds; - } - - nLastRecordedCurrentTime = FILETIME_TO_ULONGLONG(lpPrevCPUInfo->LastRecordedTime.ftLastRecordedCurrentTime); - nLastRecordedUserTime = FILETIME_TO_ULONGLONG(lpPrevCPUInfo->ftLastRecordedUserTime); - nLastRecordedKernelTime = FILETIME_TO_ULONGLONG(lpPrevCPUInfo->ftLastRecordedKernelTime); - - if (nCurrentTime > nLastRecordedCurrentTime) - { - nCpuTotalTime = (nCurrentTime - nLastRecordedCurrentTime); -#if HAVE_THREAD_SELF || HAVE__LWP_SELF || HAVE_VM_READ - // For systems that run multiple threads of a process on multiple processors, - // the accumulated userTime and kernelTime of this process may exceed - // the elapsed time. In this case, the cpuTotalTime needs to be adjusted - // according to number of processors so that the cpu utilization - // will not be greater than 100. - nCpuTotalTime *= dwNumberOfProcessors; -#endif // HAVE_THREAD_SELF || HAVE__LWP_SELF || HAVE_VM_READ - } - - if (nUserTime >= nLastRecordedUserTime && - nKernelTime >= nLastRecordedKernelTime) - { - nCpuBusyTime = - (nUserTime - nLastRecordedUserTime)+ - (nKernelTime - nLastRecordedKernelTime); - } - - if (nCpuTotalTime > 0 && nCpuBusyTime > 0) - { - nReading = (DWORD)((nCpuBusyTime*100)/nCpuTotalTime); - TRACE("PAL_GetCPUBusyTime: nCurrentTime=%lld, nKernelTime=%lld, nUserTime=%lld, nReading=%d\n", - nCurrentTime, nKernelTime, nUserTime, nReading); - } - - if (nReading > 100) - { - ERROR("cpu utilization(%d) > 100\n", nReading); - } - - lpPrevCPUInfo->LastRecordedTime.ftLastRecordedCurrentTime.dwLowDateTime = (DWORD)nCurrentTime; - lpPrevCPUInfo->LastRecordedTime.ftLastRecordedCurrentTime.dwHighDateTime = (DWORD)(nCurrentTime >> 32); - - lpPrevCPUInfo->ftLastRecordedUserTime.dwLowDateTime = (DWORD)nUserTime; - lpPrevCPUInfo->ftLastRecordedUserTime.dwHighDateTime = (DWORD)(nUserTime >> 32); - - lpPrevCPUInfo->ftLastRecordedKernelTime.dwLowDateTime = (DWORD)nKernelTime; - lpPrevCPUInfo->ftLastRecordedKernelTime.dwHighDateTime = (DWORD)(nKernelTime >> 32); - - return (DWORD)nReading; -} - -/*++ -Function: - GetCommandLineW - -See MSDN doc. ---*/ -LPWSTR -PALAPI -GetCommandLineW( - VOID) -{ - PERF_ENTRY(GetCommandLineW); - ENTRY("GetCommandLineW()\n"); - - LPWSTR lpwstr = g_lpwstrCmdLine ? g_lpwstrCmdLine : (LPWSTR)W(""); - - LOGEXIT("GetCommandLineW returns LPWSTR %p (%S)\n", - g_lpwstrCmdLine, - lpwstr); - PERF_EXIT(GetCommandLineW); - - return lpwstr; -} - -/*++ -Function: - OpenProcess - -See MSDN doc. - -Notes : -dwDesiredAccess is ignored (all supported operations will be allowed) -bInheritHandle is ignored (no inheritance) ---*/ -HANDLE -PALAPI -OpenProcess( - DWORD dwDesiredAccess, - BOOL bInheritHandle, - DWORD dwProcessId) -{ - PAL_ERROR palError; - CPalThread *pThread; - IPalObject *pobjProcess = NULL; - IPalObject *pobjProcessRegistered = NULL; - IDataLock *pDataLock; - CProcProcessLocalData *pLocalData; - CObjectAttributes oa; - HANDLE hProcess = NULL; - - PERF_ENTRY(OpenProcess); - ENTRY("OpenProcess(dwDesiredAccess=0x%08x, bInheritHandle=%d, " - "dwProcessId = 0x%08x)\n", - dwDesiredAccess, bInheritHandle, dwProcessId ); - - pThread = InternalGetCurrentThread(); - - if (0 == dwProcessId) - { - palError = ERROR_INVALID_PARAMETER; - goto OpenProcessExit; - } - - palError = g_pObjectManager->AllocateObject( - pThread, - &otProcess, - &oa, - &pobjProcess - ); - - if (NO_ERROR != palError) - { - goto OpenProcessExit; - } - - palError = pobjProcess->GetProcessLocalData( - pThread, - WriteLock, - &pDataLock, - reinterpret_cast(&pLocalData) - ); - - if (NO_ERROR != palError) - { - goto OpenProcessExit; - } - - pLocalData->dwProcessId = dwProcessId; - pDataLock->ReleaseLock(pThread, TRUE); - - palError = g_pObjectManager->RegisterObject( - pThread, - pobjProcess, - &aotProcess, - dwDesiredAccess, - &hProcess, - &pobjProcessRegistered - ); - - // - // pobjProcess was invalidated by the above call, so NULL - // it out here - // - - pobjProcess = NULL; - - // - // TODO: check to see if the process actually exists? - // - -OpenProcessExit: - - if (NULL != pobjProcess) - { - pobjProcess->ReleaseReference(pThread); - } - - if (NULL != pobjProcessRegistered) - { - pobjProcessRegistered->ReleaseReference(pThread); - } - - if (NO_ERROR != palError) - { - pThread->SetLastError(palError); - } - - LOGEXIT("OpenProcess returns HANDLE %p\n", hProcess); - PERF_EXIT(OpenProcess); - return hProcess; -} - -/*++ -Function: - EnumProcessModules - -Abstract - Returns a process's module list - -Return - TRUE if it succeeded, FALSE otherwise - -Notes - This API is tricky because the module handles are never closed/freed so there can't be any - allocations for the module handle or name strings, etc. The "handles" are actually the base - addresses of the modules. The module handles should only be used by GetModuleFileNameExW - below. ---*/ -BOOL -PALAPI -EnumProcessModules( - IN HANDLE hProcess, - OUT HMODULE *lphModule, - IN DWORD cb, - OUT LPDWORD lpcbNeeded) -{ - PERF_ENTRY(EnumProcessModules); - ENTRY("EnumProcessModules(hProcess=0x%08x, cb=%d)\n", hProcess, cb); - - BOOL result = TRUE; - DWORD count = 0; - ProcessModules *listHead = GetProcessModulesFromHandle(hProcess, &count); - if (listHead != NULL) - { - for (ProcessModules *entry = listHead; entry != NULL; entry = entry->Next) - { - if (cb <= 0) - { - break; - } - cb -= sizeof(HMODULE); - *lphModule = (HMODULE)entry->BaseAddress; - lphModule++; - } - } - else - { - result = FALSE; - } - - if (lpcbNeeded) - { - // This return value isn't exactly up to spec because it should return the actual - // number of modules in the process even if "cb" isn't big enough but for our use - // it works just fine. - (*lpcbNeeded) = count * sizeof(HMODULE); - } - - LOGEXIT("EnumProcessModules returns %d\n", result); - PERF_EXIT(EnumProcessModules); - return result; -} - -/*++ -Function: - GetModuleFileNameExW - - Used only with module handles returned from EnumProcessModule (for dbgshim). - ---*/ -DWORD -PALAPI -GetModuleFileNameExW( - IN HANDLE hProcess, - IN HMODULE hModule, - OUT LPWSTR lpFilename, - IN DWORD nSize -) -{ - DWORD result = 0; - DWORD count = 0; - - ProcessModules *listHead = GetProcessModulesFromHandle(hProcess, &count); - if (listHead != NULL) - { - for (ProcessModules *entry = listHead; entry != NULL; entry = entry->Next) - { - if ((HMODULE)entry->BaseAddress == hModule) - { - // Convert CHAR string into WCHAR string - result = MultiByteToWideChar(CP_ACP, 0, entry->Name, -1, lpFilename, nSize); - break; - } - } - } - - return result; -} - -/*++ -Function: - GetProcessModulesFromHandle - -Abstract - Returns a process's module list - -Return - ProcessModules * list - ---*/ -ProcessModules * -GetProcessModulesFromHandle( - IN HANDLE hProcess, - OUT LPDWORD lpCount) -{ - CPalThread* pThread = InternalGetCurrentThread(); - CProcProcessLocalData *pLocalData = NULL; - ProcessModules *listHead = NULL; - IPalObject *pobjProcess = NULL; - IDataLock *pDataLock = NULL; - PAL_ERROR palError = NO_ERROR; - DWORD dwProcessId = 0; - DWORD count = 0; - - _ASSERTE(lpCount != NULL); - - if (hPseudoCurrentProcess == hProcess) - { - pobjProcess = g_pobjProcess; - } - else - { - CAllowedObjectTypes aotProcess(otiProcess); - - palError = g_pObjectManager->ReferenceObjectByHandle( - pThread, - hProcess, - &aotProcess, - 0, - &pobjProcess); - - if (NO_ERROR != palError) - { - pThread->SetLastError(ERROR_INVALID_HANDLE); - goto exit; - } - } - - palError = pobjProcess->GetProcessLocalData( - pThread, - WriteLock, - &pDataLock, - reinterpret_cast(&pLocalData)); - - _ASSERTE(NO_ERROR == palError); - - dwProcessId = pLocalData->dwProcessId; - listHead = pLocalData->pProcessModules; - count = pLocalData->cProcessModules; - - // If the module list hasn't been created yet, create it now - if (listHead == NULL) - { - listHead = CreateProcessModules(dwProcessId, &count); - if (listHead == NULL) - { - pThread->SetLastError(ERROR_INVALID_PARAMETER); - goto exit; - } - - if (pLocalData != NULL) - { - pLocalData->pProcessModules = listHead; - pLocalData->cProcessModules = count; - } - } - -exit: - if (NULL != pDataLock) - { - pDataLock->ReleaseLock(pThread, TRUE); - } - if (NULL != pobjProcess) - { - pobjProcess->ReleaseReference(pThread); - } - - *lpCount = count; - return listHead; -} - -/*++ -Function: - CreateProcessModules - -Abstract - Returns a process's module list - -Return - ProcessModules * list - ---*/ -ProcessModules * -CreateProcessModules( - IN DWORD dwProcessId, - OUT LPDWORD lpCount) -{ - ProcessModules *listHead = NULL; - _ASSERTE(lpCount != NULL); - -#if defined(__APPLE__) - - // For OS X, the "vmmap" command outputs something similar to the /proc/*/maps file so popen the - // command and read the relevant lines: - // - // ... - // ==== regions for process 347 (non-writable and writable regions are interleaved) - // REGION TYPE START - END [ VSIZE] PRT/MAX SHRMOD REGION DETAIL - // __TEXT 000000010446d000-0000000104475000 [ 32K] r-x/rwx SM=COW /Users/mikem/coreclr/bin/Product/OSx.x64.Debug/corerun - // __DATA 0000000104475000-0000000104476000 [ 4K] rw-/rwx SM=PRV /Users/mikem/coreclr/bin/Product/OSx.x64.Debug/corerun - // __LINKEDIT 0000000104476000-000000010447a000 [ 16K] r--/rwx SM=COW /Users/mikem/coreclr/bin/Product/OSx.x64.Debug/corerun - // Kernel Alloc Once 000000010447a000-000000010447b000 [ 4K] rw-/rwx SM=PRV - // MALLOC (admin) 000000010447b000-000000010447c000 [ 4K] r--/rwx SM=ZER - // ... - // MALLOC (admin) 00000001044ab000-00000001044ac000 [ 4K] r--/rwx SM=PRV - // __TEXT 00000001044ac000-0000000104c84000 [ 8032K] r-x/rwx SM=COW /Users/mikem/coreclr/bin/Product/OSx.x64.Debug/libcoreclr.dylib - // __TEXT 0000000104c84000-0000000104c85000 [ 4K] rwx/rwx SM=PRV /Users/mikem/coreclr/bin/Product/OSx.x64.Debug/libcoreclr.dylib - // __TEXT 0000000104c85000-000000010513b000 [ 4824K] r-x/rwx SM=COW /Users/mikem/coreclr/bin/Product/OSx.x64.Debug/libcoreclr.dylib - // __TEXT 000000010513b000-000000010513c000 [ 4K] rwx/rwx SM=PRV /Users/mikem/coreclr/bin/Product/OSx.x64.Debug/libcoreclr.dylib - // __TEXT 000000010513c000-000000010516f000 [ 204K] r-x/rwx SM=COW /Users/mikem/coreclr/bin/Product/OSx.x64.Debug/libcoreclr.dylib - // __DATA 000000010516f000-00000001051ce000 [ 380K] rw-/rwx SM=COW /Users/mikem/coreclr/bin/Product/OSx.x64.Debug/libcoreclr.dylib - // __DATA 00000001051ce000-00000001051fa000 [ 176K] rw-/rwx SM=PRV /Users/mikem/coreclr/bin/Product/OSx.x64.Debug/libcoreclr.dylib - // __LINKEDIT 00000001051fa000-0000000105bac000 [ 9928K] r--/rwx SM=COW /Users/mikem/coreclr/bin/Product/OSx.x64.Debug/libcoreclr.dylib - // VM_ALLOCATE 0000000105bac000-0000000105bad000 [ 4K] r--/rw- SM=SHM - // MALLOC (admin) 0000000105bad000-0000000105bae000 [ 4K] r--/rwx SM=ZER - // MALLOC 0000000105bae000-0000000105baf000 [ 4K] rw-/rwx SM=ZER - - // OS X Sierra (10.12.4 Beta) - // REGION TYPE START - END [ VSIZE RSDNT DIRTY SWAP] PRT/MAX SHRMOD PURGE REGION DETAIL - // Stack 00007fff5a930000-00007fff5b130000 [ 8192K 32K 32K 0K] rw-/rwx SM=PRV thread 0 - // __TEXT 00007fffa4a0b000-00007fffa4a0d000 [ 8K 8K 0K 0K] r-x/r-x SM=COW /usr/lib/libSystem.B.dylib - // __TEXT 00007fffa4bbe000-00007fffa4c15000 [ 348K 348K 0K 0K] r-x/r-x SM=COW /usr/lib/libc++.1.dylib - char *line = NULL; - size_t lineLen = 0; - int count = 0; - ssize_t read; - - char vmmapCommand[100]; - int chars = snprintf(vmmapCommand, sizeof(vmmapCommand), "/usr/bin/vmmap -interleaved %d -wide", dwProcessId); - _ASSERTE(chars > 0 && chars <= sizeof(vmmapCommand)); - - FILE *vmmapFile = popen(vmmapCommand, "r"); - if (vmmapFile == NULL) - { - goto exit; - } - - // Reading maps file line by line - while ((read = getline(&line, &lineLen, vmmapFile)) != -1) - { - void *startAddress, *endAddress; - char moduleName[PATH_MAX]; - - if (sscanf_s(line, "__TEXT %p-%p [ %*[0-9K ]] %*[-/rwxsp] SM=%*[A-Z] %s\n", &startAddress, &endAddress, moduleName, _countof(moduleName)) == 3) - { - bool dup = false; - for (ProcessModules *entry = listHead; entry != NULL; entry = entry->Next) - { - if (strcmp(moduleName, entry->Name) == 0) - { - dup = true; - break; - } - } - - if (!dup) - { - int cbModuleName = strlen(moduleName) + 1; - ProcessModules *entry = (ProcessModules *)InternalMalloc(sizeof(ProcessModules) + cbModuleName); - if (entry == NULL) - { - DestroyProcessModules(listHead); - listHead = NULL; - count = 0; - break; - } - strcpy_s(entry->Name, cbModuleName, moduleName); - entry->BaseAddress = startAddress; - entry->Next = listHead; - listHead = entry; - count++; - } - } - } - - *lpCount = count; - - free(line); // We didn't allocate line, but as per contract of getline we should free it - pclose(vmmapFile); -exit: - -#elif HAVE_PROCFS_MAPS - - // Here we read /proc//maps file in order to parse it and figure out what it says - // about a library we are looking for. This file looks something like this: - // - // [address] [perms] [offset] [dev] [inode] [pathname] - HEADER is not preset in an actual file - // - // 35b1800000-35b1820000 r-xp 00000000 08:02 135522 /usr/lib64/ld-2.15.so - // 35b1a1f000-35b1a20000 r--p 0001f000 08:02 135522 /usr/lib64/ld-2.15.so - // 35b1a20000-35b1a21000 rw-p 00020000 08:02 135522 /usr/lib64/ld-2.15.so - // 35b1a21000-35b1a22000 rw-p 00000000 00:00 0 [heap] - // 35b1c00000-35b1dac000 r-xp 00000000 08:02 135870 /usr/lib64/libc-2.15.so - // 35b1dac000-35b1fac000 ---p 001ac000 08:02 135870 /usr/lib64/libc-2.15.so - // 35b1fac000-35b1fb0000 r--p 001ac000 08:02 135870 /usr/lib64/libc-2.15.so - // 35b1fb0000-35b1fb2000 rw-p 001b0000 08:02 135870 /usr/lib64/libc-2.15.so - - // Making something like: /proc/123/maps - char mapFileName[100]; - char *line = NULL; - size_t lineLen = 0; - int count = 0; - ssize_t read; - - INDEBUG(int chars = ) - snprintf(mapFileName, sizeof(mapFileName), "/proc/%d/maps", dwProcessId); - _ASSERTE(chars > 0 && chars <= sizeof(mapFileName)); - - FILE *mapsFile = fopen(mapFileName, "r"); - if (mapsFile == NULL) - { - goto exit; - } - - // Reading maps file line by line - while ((read = getline(&line, &lineLen, mapsFile)) != -1) - { - void *startAddress, *endAddress, *offset; - int devHi, devLo, inode; - char moduleName[PATH_MAX]; - - if (sscanf_s(line, "%p-%p %*[-rwxsp] %p %x:%x %d %s\n", &startAddress, &endAddress, &offset, &devHi, &devLo, &inode, moduleName, _countof(moduleName)) == 7) - { - if (inode != 0) - { - bool dup = false; - for (ProcessModules *entry = listHead; entry != NULL; entry = entry->Next) - { - if (strcmp(moduleName, entry->Name) == 0) - { - dup = true; - break; - } - } - - if (!dup) - { - int cbModuleName = strlen(moduleName) + 1; - ProcessModules *entry = (ProcessModules *)InternalMalloc(sizeof(ProcessModules) + cbModuleName); - if (entry == NULL) - { - DestroyProcessModules(listHead); - listHead = NULL; - count = 0; - break; - } - strcpy_s(entry->Name, cbModuleName, moduleName); - entry->BaseAddress = startAddress; - entry->Next = listHead; - listHead = entry; - count++; - } - } - } - } - - *lpCount = count; - - free(line); // We didn't allocate line, but as per contract of getline we should free it - fclose(mapsFile); -exit: - -#else - _ASSERTE(!"Not implemented on this platform"); -#endif - return listHead; -} - -/*++ -Function: - DestroyProcessModules - -Abstract - Cleans up the process module table. - -Return - None - ---*/ -VOID -DestroyProcessModules(IN ProcessModules *listHead) -{ - for (ProcessModules *entry = listHead; entry != NULL; ) - { - ProcessModules *next = entry->Next; - free(entry); - entry = next; - } -} - -/*++ -Function - PROCNotifyProcessShutdown - - Calls the abort handler to do any shutdown cleanup. Call be called - from the unhandled native exception handler. - -(no return value) ---*/ -__attribute__((destructor)) -VOID -PROCNotifyProcessShutdown() -{ - // Call back into the coreclr to clean up the debugger transport pipes - PSHUTDOWN_CALLBACK callback = InterlockedExchangePointer(&g_shutdownCallback, NULL); - if (callback != NULL) - { - callback(); - } -} - -/*++ -Function - PROCAbortInitialize() - -Abstract - Initialize the process abort crash dump program file path and - name. Doing all of this ahead of time so nothing is allocated - or copied in PROCAbort/signal handler. - -Return - TRUE - succeeds, FALSE - fails - ---*/ -BOOL -PROCAbortInitialize() -{ - char* enabled = getenv("COMPlus_DbgEnableMiniDump"); - if (enabled != nullptr && _stricmp(enabled, "1") == 0) - { - if (g_szCoreCLRPath == nullptr) - { - return FALSE; - } - const char* DumpGeneratorName = "createdump"; - int programLen = strlen(g_szCoreCLRPath) + strlen(DumpGeneratorName) + 1; - char* program = (char*)InternalMalloc(programLen); - if (program == nullptr) - { - return FALSE; - } - if (strcpy_s(program, programLen, g_szCoreCLRPath) != SAFECRT_SUCCESS) - { - return FALSE; - } - char *last = strrchr(program, '/'); - if (last != nullptr) - { - *(last + 1) = '\0'; - } - else - { - program[0] = '\0'; - } - if (strcat_s(program, programLen, DumpGeneratorName) != SAFECRT_SUCCESS) - { - return FALSE; - } - char* pidarg = (char*)InternalMalloc(128); - if (pidarg == nullptr) - { - return FALSE; - } - if (sprintf_s(pidarg, 128, "%d", gPID) == -1) - { - return FALSE; - } - const char** argv = (const char**)g_argvCreateDump; - *argv++ = program; - - char* envvar = getenv("COMPlus_DbgMiniDumpName"); - if (envvar != nullptr) - { - *argv++ = "--name"; - *argv++ = envvar; - } - - envvar = getenv("COMPlus_DbgMiniDumpType"); - if (envvar != nullptr) - { - if (strcmp(envvar, "1") == 0) - { - *argv++ = "--normal"; - } - else if (strcmp(envvar, "2") == 0) - { - *argv++ = "--withheap"; - } - else if (strcmp(envvar, "3") == 0) - { - *argv++ = "--triage"; - } - else if (strcmp(envvar, "4") == 0) - { - *argv++ = "--full"; - } - } - - envvar = getenv("COMPlus_CreateDumpDiagnostics"); - if (envvar != nullptr && strcmp(envvar, "1") == 0) - { - *argv++ = "--diag"; - } - - *argv++ = pidarg; - *argv = nullptr; - } - return TRUE; -} - -/*++ -Function: - PROCCreateCrashDumpIfEnabled - - Creates crash dump of the process (if enabled). Can be - called from the unhandled native exception handler. - -(no return value) ---*/ -VOID -PROCCreateCrashDumpIfEnabled() -{ -#if HAVE_PRCTL_H && HAVE_PR_SET_PTRACER - // If enabled, launch the create minidump utility and wait until it completes - if (g_argvCreateDump[0] == nullptr) - return; - - // Fork the core dump child process. - pid_t childpid = fork(); - - // If error, write an error to trace log and abort - if (childpid == -1) - { - ERROR("PROCAbort: fork() FAILED %d (%s)\n", errno, strerror(errno)); - } - else if (childpid == 0) - { - // Child process - if (execve(g_argvCreateDump[0], g_argvCreateDump, palEnvironment) == -1) - { - ERROR("PROCAbort: execve FAILED %d (%s)\n", errno, strerror(errno)); - } - } - else - { - // Gives the child process permission to use /proc//mem and ptrace - if (prctl(PR_SET_PTRACER, childpid, 0, 0, 0) == -1) - { - ERROR("PROCAbort: prctl() FAILED %d (%s)\n", errno, strerror(errno)); - } - // Parent waits until the child process is done - int wstatus; - int result = waitpid(childpid, &wstatus, 0); - if (result != childpid) - { - ERROR("PROCAbort: waitpid FAILED result %d wstatus %d errno %d (%s)\n", - result, wstatus, errno, strerror(errno)); - } - } -#endif // HAVE_PRCTL_H && HAVE_PR_SET_PTRACER -} - -/*++ -Function: - PROCAbort() - - Aborts the process after calling the shutdown cleanup handler. This function - should be called instead of calling abort() directly. - - Does not return ---*/ -PAL_NORETURN -VOID -PROCAbort() -{ - // Do any shutdown cleanup before aborting or creating a core dump - PROCNotifyProcessShutdown(); - - PROCCreateCrashDumpIfEnabled(); - - // Abort the process after waiting for the core dump to complete - abort(); -} - -/*++ -Function: - InitializeFlushProcessWriteBuffers - -Abstract - This function initializes data structures needed for the FlushProcessWriteBuffers -Return - TRUE if it succeeded, FALSE otherwise ---*/ -BOOL -InitializeFlushProcessWriteBuffers() -{ - _ASSERTE(s_helperPage == 0); - - s_helperPage = static_cast(mmap(0, GetVirtualPageSize(), PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0)); - - if(s_helperPage == MAP_FAILED) - { - return false; - } - - // Verify that the s_helperPage is really aligned to the GetVirtualPageSize() - _ASSERTE((((SIZE_T)s_helperPage) & (GetVirtualPageSize() - 1)) == 0); - - // Locking the page ensures that it stays in memory during the two mprotect - // calls in the FlushProcessWriteBuffers below. If the page was unmapped between - // those calls, they would not have the expected effect of generating IPI. - int status = mlock(s_helperPage, GetVirtualPageSize()); - - if (status != 0) - { - return FALSE; - } - - status = pthread_mutex_init(&flushProcessWriteBuffersMutex, NULL); - if (status != 0) - { - munlock(s_helperPage, GetVirtualPageSize()); - } - - return status == 0; -} - -#define FATAL_ASSERT(e, msg) \ - do \ - { \ - if (!(e)) \ - { \ - fprintf(stderr, "FATAL ERROR: " msg); \ - PROCAbort(); \ - } \ - } \ - while(0) - -/*++ -Function: - FlushProcessWriteBuffers - -See MSDN doc. ---*/ -VOID -PALAPI -FlushProcessWriteBuffers() -{ - int status = pthread_mutex_lock(&flushProcessWriteBuffersMutex); - FATAL_ASSERT(status == 0, "Failed to lock the flushProcessWriteBuffersMutex lock"); - - // Changing a helper memory page protection from read / write to no access - // causes the OS to issue IPI to flush TLBs on all processors. This also - // results in flushing the processor buffers. - status = mprotect(s_helperPage, GetVirtualPageSize(), PROT_READ | PROT_WRITE); - FATAL_ASSERT(status == 0, "Failed to change helper page protection to read / write"); - - // Ensure that the page is dirty before we change the protection so that - // we prevent the OS from skipping the global TLB flush. - InterlockedIncrement(s_helperPage); - - status = mprotect(s_helperPage, GetVirtualPageSize(), PROT_NONE); - FATAL_ASSERT(status == 0, "Failed to change helper page protection to no access"); - - status = pthread_mutex_unlock(&flushProcessWriteBuffersMutex); - FATAL_ASSERT(status == 0, "Failed to unlock the flushProcessWriteBuffersMutex lock"); -} - -/*++ -Function: - PROCGetProcessIDFromHandle - -Abstract - Return the process ID from a process handle - -Parameter - hProcess: process handle - -Return - Return the process ID, or 0 if it's not a valid handle ---*/ -DWORD -PROCGetProcessIDFromHandle( - HANDLE hProcess) -{ - PAL_ERROR palError; - IPalObject *pobjProcess = NULL; - CPalThread *pThread = InternalGetCurrentThread(); - - DWORD dwProcessId = 0; - - if (hPseudoCurrentProcess == hProcess) - { - dwProcessId = gPID; - goto PROCGetProcessIDFromHandleExit; - } - - - palError = g_pObjectManager->ReferenceObjectByHandle( - pThread, - hProcess, - &aotProcess, - 0, - &pobjProcess - ); - - if (NO_ERROR == palError) - { - IDataLock *pDataLock; - CProcProcessLocalData *pLocalData; - - palError = pobjProcess->GetProcessLocalData( - pThread, - ReadLock, - &pDataLock, - reinterpret_cast(&pLocalData) - ); - - if (NO_ERROR == palError) - { - dwProcessId = pLocalData->dwProcessId; - pDataLock->ReleaseLock(pThread, FALSE); - } - - pobjProcess->ReleaseReference(pThread); - } - -PROCGetProcessIDFromHandleExit: - - return dwProcessId; -} - -PAL_ERROR -CorUnix::InitializeProcessData( - void - ) -{ - PAL_ERROR palError = NO_ERROR; - bool fLockInitialized = FALSE; - - pGThreadList = NULL; - g_dwThreadCount = 0; - - InternalInitializeCriticalSection(&g_csProcess); - fLockInitialized = TRUE; - - if (NO_ERROR != palError) - { - if (fLockInitialized) - { - InternalDeleteCriticalSection(&g_csProcess); - } - } - - return palError; -} - -/*++ -Function - InitializeProcessCommandLine - -Abstract - Initializes (or re-initializes) the saved command line and exe path. - -Parameter - lpwstrCmdLine - lpwstrFullPath - -Return - PAL_ERROR - -Notes - This function takes ownership of lpwstrCmdLine, but not of lpwstrFullPath ---*/ - -PAL_ERROR -CorUnix::InitializeProcessCommandLine( - LPWSTR lpwstrCmdLine, - LPWSTR lpwstrFullPath -) -{ - PAL_ERROR palError = NO_ERROR; - LPWSTR initial_dir = NULL; - - // - // Save the command line and initial directory - // - - if (lpwstrFullPath) - { - LPWSTR lpwstr = PAL_wcsrchr(lpwstrFullPath, '/'); - lpwstr[0] = '\0'; - INT n = lstrlenW(lpwstrFullPath) + 1; - - int iLen = n; - initial_dir = reinterpret_cast(InternalMalloc(iLen*sizeof(WCHAR))); - if (NULL == initial_dir) - { - ERROR("malloc() failed! (initial_dir) \n"); - palError = ERROR_NOT_ENOUGH_MEMORY; - goto exit; - } - - if (wcscpy_s(initial_dir, iLen, lpwstrFullPath) != SAFECRT_SUCCESS) - { - ERROR("wcscpy_s failed!\n"); - free(initial_dir); - palError = ERROR_INTERNAL_ERROR; - goto exit; - } - - lpwstr[0] = '/'; - - free(g_lpwstrAppDir); - g_lpwstrAppDir = initial_dir; - } - - free(g_lpwstrCmdLine); - g_lpwstrCmdLine = lpwstrCmdLine; - -exit: - return palError; -} - - -/*++ -Function: - CreateInitialProcessAndThreadObjects - -Abstract - Creates the IPalObjects that represent the current process - and the initial thread - -Parameter - pThread - the initial thread - -Return - PAL_ERROR ---*/ - -PAL_ERROR -CorUnix::CreateInitialProcessAndThreadObjects( - CPalThread *pThread - ) -{ - PAL_ERROR palError = NO_ERROR; - HANDLE hThread; - IPalObject *pobjProcess = NULL; - IDataLock *pDataLock; - CProcProcessLocalData *pLocalData; - CObjectAttributes oa; - HANDLE hProcess; - - // - // Create initial thread object - // - - palError = CreateThreadObject(pThread, pThread, &hThread); - if (NO_ERROR != palError) - { - goto CreateInitialProcessAndThreadObjectsExit; - } - - // - // This handle isn't needed - // - - (void) g_pObjectManager->RevokeHandle(pThread, hThread); - - // - // Create and initialize process object - // - - palError = g_pObjectManager->AllocateObject( - pThread, - &otProcess, - &oa, - &pobjProcess - ); - - if (NO_ERROR != palError) - { - ERROR("Unable to allocate process object"); - goto CreateInitialProcessAndThreadObjectsExit; - } - - palError = pobjProcess->GetProcessLocalData( - pThread, - WriteLock, - &pDataLock, - reinterpret_cast(&pLocalData) - ); - - if (NO_ERROR != palError) - { - ASSERT("Unable to access local data"); - goto CreateInitialProcessAndThreadObjectsExit; - } - - pLocalData->dwProcessId = gPID; - pLocalData->ps = PS_RUNNING; - pDataLock->ReleaseLock(pThread, TRUE); - - palError = g_pObjectManager->RegisterObject( - pThread, - pobjProcess, - &aotProcess, - PROCESS_ALL_ACCESS, - &hProcess, - &g_pobjProcess - ); - - // - // pobjProcess is invalidated by the call to RegisterObject, so - // NULL it out here to prevent it from being released later - // - - pobjProcess = NULL; - - if (NO_ERROR != palError) - { - ASSERT("Failure registering process object"); - goto CreateInitialProcessAndThreadObjectsExit; - } - - // - // There's no need to keep this handle around, so revoke - // it now - // - - g_pObjectManager->RevokeHandle(pThread, hProcess); - -CreateInitialProcessAndThreadObjectsExit: - - if (NULL != pobjProcess) - { - pobjProcess->ReleaseReference(pThread); - } - - return palError; -} - - -/*++ -Function: - PROCCleanupInitialProcess - -Abstract - Cleanup all the structures for the initial process. - -Parameter - VOID - -Return - VOID - ---*/ -VOID -PROCCleanupInitialProcess(VOID) -{ - CPalThread *pThread = InternalGetCurrentThread(); - - InternalEnterCriticalSection(pThread, &g_csProcess); - - /* Free the application directory */ - free(g_lpwstrAppDir); - - /* Free the stored command line */ - free(g_lpwstrCmdLine); - - InternalLeaveCriticalSection(pThread, &g_csProcess); - - // - // Object manager shutdown will handle freeing the underlying - // thread and process data - // - -} - -/*++ -Function: - PROCAddThread - -Abstract - Add a thread to the thread list of the current process - -Parameter - pThread: Thread object - ---*/ -VOID -CorUnix::PROCAddThread( - CPalThread *pCurrentThread, - CPalThread *pTargetThread - ) -{ - /* protect the access of the thread list with critical section for - mutithreading access */ - InternalEnterCriticalSection(pCurrentThread, &g_csProcess); - - pTargetThread->SetNext(pGThreadList); - pGThreadList = pTargetThread; - g_dwThreadCount += 1; - - TRACE("Thread 0x%p (id %#x) added to the process thread list\n", - pTargetThread, pTargetThread->GetThreadId()); - - InternalLeaveCriticalSection(pCurrentThread, &g_csProcess); -} - - -/*++ -Function: - PROCRemoveThread - -Abstract - Remove a thread form the thread list of the current process - -Parameter - CPalThread *pThread : thread object to remove - -(no return value) ---*/ -VOID -CorUnix::PROCRemoveThread( - CPalThread *pCurrentThread, - CPalThread *pTargetThread - ) -{ - CPalThread *curThread, *prevThread; - - /* protect the access of the thread list with critical section for - mutithreading access */ - InternalEnterCriticalSection(pCurrentThread, &g_csProcess); - - curThread = pGThreadList; - - /* if thread list is empty */ - if (curThread == NULL) - { - ASSERT("Thread list is empty.\n"); - goto EXIT; - } - - /* do we remove the first thread? */ - if (curThread == pTargetThread) - { - pGThreadList = curThread->GetNext(); - TRACE("Thread 0x%p (id %#x) removed from the process thread list\n", - pTargetThread, pTargetThread->GetThreadId()); - goto EXIT; - } - - prevThread = curThread; - curThread = curThread->GetNext(); - /* find the thread to remove */ - while (curThread != NULL) - { - if (curThread == pTargetThread) - { - /* found, fix the chain list */ - prevThread->SetNext(curThread->GetNext()); - g_dwThreadCount -= 1; - TRACE("Thread %p removed from the process thread list\n", pTargetThread); - goto EXIT; - } - - prevThread = curThread; - curThread = curThread->GetNext(); - } - - WARN("Thread %p not removed (it wasn't found in the list)\n", pTargetThread); - -EXIT: - InternalLeaveCriticalSection(pCurrentThread, &g_csProcess); -} - - -/*++ -Function: - PROCGetNumberOfThreads - -Abstract - Return the number of threads in the thread list. - -Parameter - void - -Return - the number of threads. ---*/ -INT -CorUnix::PROCGetNumberOfThreads( - VOID) -{ - return g_dwThreadCount; -} - - -/*++ -Function: - PROCProcessLock - -Abstract - Enter the critical section associated to the current process - -Parameter - void - -Return - void ---*/ -VOID -PROCProcessLock( - VOID) -{ - CPalThread * pThread = - (PALIsThreadDataInitialized() ? InternalGetCurrentThread() : NULL); - - InternalEnterCriticalSection(pThread, &g_csProcess); -} - - -/*++ -Function: - PROCProcessUnlock - -Abstract - Leave the critical section associated to the current process - -Parameter - void - -Return - void ---*/ -VOID -PROCProcessUnlock( - VOID) -{ - CPalThread * pThread = - (PALIsThreadDataInitialized() ? InternalGetCurrentThread() : NULL); - - InternalLeaveCriticalSection(pThread, &g_csProcess); -} - -#if USE_SYSV_SEMAPHORES -/*++ -Function: - PROCCleanupThreadSemIds - -Abstract - Cleanup SysV semaphore ids for all threads - -(no parameters, no return value) ---*/ -VOID -PROCCleanupThreadSemIds(void) -{ - // - // When using SysV semaphores, the semaphore ids used by PAL threads must be removed - // so they can be used again. - // - - PROCProcessLock(); - - CPalThread *pTargetThread = pGThreadList; - while (NULL != pTargetThread) - { - pTargetThread->suspensionInfo.DestroySemaphoreIds(); - pTargetThread = pTargetThread->GetNext(); - } - - PROCProcessUnlock(); - -} -#endif // USE_SYSV_SEMAPHORES - -/*++ -Function: - TerminateCurrentProcessNoExit - -Abstract: - Terminate current Process, but leave the caller alive - -Parameters: - BOOL bTerminateUnconditionally - If this is set, the PAL will exit as - quickly as possible. In particular, it will not unload DLLs. - -Return value : - No return - -Note: - This function is used in ExitThread and TerminateProcess - ---*/ -VOID -CorUnix::TerminateCurrentProcessNoExit(BOOL bTerminateUnconditionally) -{ - BOOL locked; - DWORD old_terminator; - - old_terminator = InterlockedCompareExchange(&terminator, GetCurrentThreadId(), 0); - - if (0 != old_terminator && GetCurrentThreadId() != old_terminator) - { - /* another thread has already initiated the termination process. we - could just block on the PALInitLock critical section, but then - PROCSuspendOtherThreads would hang... so sleep forever here, we're - terminating anyway - - Update: [TODO] PROCSuspendOtherThreads has been removed. Can this - code be changed? */ - - /* note that if *this* thread has already started the termination - process, we want to proceed. the only way this can happen is if a - call to DllMain (from ExitProcess) brought us here (because DllMain - called ExitProcess, or TerminateProcess, or ExitThread); - TerminateProcess won't call DllMain, so there's no danger to get - caught in an infinite loop */ - WARN("termination already started from another thread; blocking.\n"); - poll(NULL, 0, INFTIM); - } - - /* Try to lock the initialization count to prevent multiple threads from - terminating/initializing the PAL simultaneously */ - - /* note : it's also important to take this lock before the process lock, - because Init/Shutdown take the init lock, and the functions they call - may take the process lock. We must do it in the same order to avoid - deadlocks */ - - locked = PALInitLock(); - if(locked && PALIsInitialized()) - { - PROCNotifyProcessShutdown(); - PALCommonCleanup(); - } -} - -/*++ -Function: - PROCGetProcessStatus - -Abstract: - Retrieve process state information (state & exit code). - -Parameters: - DWORD process_id : PID of process to retrieve state for - PROCESS_STATE *state : state of process (starting, running, done) - DWORD *exit_code : exit code of process (from ExitProcess, etc.) - -Return value : - TRUE on success ---*/ -PAL_ERROR -PROCGetProcessStatus( - CPalThread *pThread, - HANDLE hProcess, - PROCESS_STATE *pps, - DWORD *pdwExitCode - ) -{ - PAL_ERROR palError = NO_ERROR; - IPalObject *pobjProcess = NULL; - IDataLock *pDataLock; - CProcProcessLocalData *pLocalData; - pid_t wait_retval; - int status; - - // - // First, check if we already know the status of this process. This will be - // the case if this function has already been called for the same process. - // - - palError = g_pObjectManager->ReferenceObjectByHandle( - pThread, - hProcess, - &aotProcess, - 0, - &pobjProcess - ); - - if (NO_ERROR != palError) - { - goto PROCGetProcessStatusExit; - } - - palError = pobjProcess->GetProcessLocalData( - pThread, - WriteLock, - &pDataLock, - reinterpret_cast(&pLocalData) - ); - - if (PS_DONE == pLocalData->ps) - { - TRACE("We already called waitpid() on process ID %#x; process has " - "terminated, exit code is %d\n", - pLocalData->dwProcessId, pLocalData->dwExitCode); - - *pps = pLocalData->ps; - *pdwExitCode = pLocalData->dwExitCode; - - pDataLock->ReleaseLock(pThread, FALSE); - - goto PROCGetProcessStatusExit; - } - - /* By using waitpid(), we can even retrieve the exit code of a non-PAL - process. However, note that waitpid() can only provide the low 8 bits - of the exit code. This is all that is required for the PAL spec. */ - TRACE("Looking for status of process; trying wait()"); - - while(1) - { - /* try to get state of process, using non-blocking call */ - wait_retval = waitpid(pLocalData->dwProcessId, &status, WNOHANG); - - if ( wait_retval == (pid_t) pLocalData->dwProcessId ) - { - /* success; get the exit code */ - if ( WIFEXITED( status ) ) - { - *pdwExitCode = WEXITSTATUS(status); - TRACE("Exit code was %d\n", *pdwExitCode); - } - else - { - WARN("process terminated without exiting; can't get exit " - "code. faking it.\n"); - *pdwExitCode = EXIT_FAILURE; - } - *pps = PS_DONE; - } - else if (0 == wait_retval) - { - // The process is still running. - TRACE("Process %#x is still active.\n", pLocalData->dwProcessId); - *pps = PS_RUNNING; - *pdwExitCode = 0; - } - else if (-1 == wait_retval) - { - // This might happen if waitpid() had already been called, but - // this shouldn't happen - we call waitpid once, store the - // result, and use that afterwards. - // One legitimate cause of failure is EINTR; if this happens we - // have to try again. A second legitimate cause is ECHILD, which - // happens if we're trying to retrieve the status of a currently- - // running process that isn't a child of this process. - if(EINTR == errno) - { - TRACE("waitpid() failed with EINTR; re-waiting"); - continue; - } - else if (ECHILD == errno) - { - TRACE("waitpid() failed with ECHILD; calling kill instead"); - if (kill(pLocalData->dwProcessId, 0) != 0) - { - if(ESRCH == errno) - { - WARN("kill() failed with ESRCH, i.e. target " - "process exited and it wasn't a child, " - "so can't get the exit code, assuming " - "it was 0.\n"); - *pdwExitCode = 0; - } - else - { - ERROR("kill(pid, 0) failed; errno is %d (%s)\n", - errno, strerror(errno)); - *pdwExitCode = EXIT_FAILURE; - } - *pps = PS_DONE; - } - else - { - *pps = PS_RUNNING; - *pdwExitCode = 0; - } - } - else - { - // Ignoring unexpected waitpid errno and assuming that - // the process is still running - ERROR("waitpid(pid=%u) failed with unexpected errno=%d (%s)\n", - pLocalData->dwProcessId, errno, strerror(errno)); - *pps = PS_RUNNING; - *pdwExitCode = 0; - } - } - else - { - ASSERT("waitpid returned unexpected value %d\n",wait_retval); - *pdwExitCode = EXIT_FAILURE; - *pps = PS_DONE; - } - // Break out of the loop in all cases except EINTR. - break; - } - - // Save the exit code for future reference (waitpid will only work once). - if(PS_DONE == *pps) - { - pLocalData->ps = PS_DONE; - pLocalData->dwExitCode = *pdwExitCode; - } - - TRACE( "State of process 0x%08x : %d (exit code %d)\n", - pLocalData->dwProcessId, *pps, *pdwExitCode ); - - pDataLock->ReleaseLock(pThread, TRUE); - -PROCGetProcessStatusExit: - - if (NULL != pobjProcess) - { - pobjProcess->ReleaseReference(pThread); - } - - return palError; -} - -#ifdef _DEBUG -void PROCDumpThreadList() -{ - CPalThread *pThread; - - PROCProcessLock(); - - TRACE ("Threads:{\n"); - - pThread = pGThreadList; - while (NULL != pThread) - { - TRACE (" {pThr=0x%p tid=%#x lwpid=%#x state=%d finsusp=%d}\n", - pThread, (int)pThread->GetThreadId(), (int)pThread->GetLwpId(), - (int)pThread->synchronizationInfo.GetThreadState(), - (int)pThread->suspensionInfo.GetSuspendedForShutdown()); - - pThread = pThread->GetNext(); - } - TRACE ("Threads:}\n"); - - PROCProcessUnlock(); -} -#endif - -/* Internal function definitions **********************************************/ - -/*++ -Function: - getFileName - -Abstract: - Helper function for CreateProcessW, it retrieves the executable filename - from the application name, and the command line. - -Parameters: - IN lpApplicationName: first parameter from CreateProcessW (an unicode string) - IN lpCommandLine: second parameter from CreateProcessW (an unicode string) - OUT lpFileName: file to be executed (the new process) - -Return: - TRUE: if the file name is retrieved - FALSE: otherwise - ---*/ -static -BOOL -getFileName( - LPCWSTR lpApplicationName, - LPWSTR lpCommandLine, - PathCharString& lpPathFileName) -{ - LPWSTR lpEnd; - WCHAR wcEnd; - char * lpFileName; - PathCharString lpFileNamePS; - char *lpTemp; - - if (lpApplicationName) - { - int length = WideCharToMultiByte(CP_ACP, 0, lpApplicationName, -1, - NULL, 0, NULL, NULL); - - /* if only a file name is specified, prefix it with "./" */ - if ((*lpApplicationName != '.') && (*lpApplicationName != '/') && - (*lpApplicationName != '\\')) - { - length += 2; - lpTemp = lpPathFileName.OpenStringBuffer(length); - - if (strcpy_s(lpTemp, length, "./") != SAFECRT_SUCCESS) - { - ERROR("strcpy_s failed!\n"); - return FALSE; - } - lpTemp+=2; - - } - else - { - lpTemp = lpPathFileName.OpenStringBuffer(length); - } - - /* Convert to ASCII */ - length = WideCharToMultiByte(CP_ACP, 0, lpApplicationName, -1, - lpTemp, length, NULL, NULL); - if (length == 0) - { - lpPathFileName.CloseBuffer(0); - ASSERT("WideCharToMultiByte failure\n"); - return FALSE; - } - - lpPathFileName.CloseBuffer(length -1); - - /* Replace '\' by '/' */ - FILEDosToUnixPathA(lpTemp); - - return TRUE; - } - else - { - /* use the Command line */ - - /* filename should be the first token of the command line */ - - /* first skip all leading whitespace */ - lpCommandLine = UTIL_inverse_wcspbrk(lpCommandLine,W16_WHITESPACE); - if(NULL == lpCommandLine) - { - ERROR("CommandLine contains only whitespace!\n"); - return FALSE; - } - - /* check if it is starting with a quote (") character */ - if (*lpCommandLine == 0x0022) - { - lpCommandLine++; /* skip the quote */ - - /* file name ends with another quote */ - lpEnd = PAL_wcschr(lpCommandLine+1, 0x0022); - - /* if no quotes found, set lpEnd to the end of the Command line */ - if (lpEnd == NULL) - lpEnd = lpCommandLine + PAL_wcslen(lpCommandLine); - } - else - { - /* filename is end out by a whitespace */ - lpEnd = PAL_wcspbrk(lpCommandLine, W16_WHITESPACE); - - /* if no whitespace found, set lpEnd to end of the Command line */ - if (lpEnd == NULL) - { - lpEnd = lpCommandLine + PAL_wcslen(lpCommandLine); - } - } - - if (lpEnd == lpCommandLine) - { - ERROR("application name and command line are both empty!\n"); - return FALSE; - } - - /* replace the last character by a null */ - wcEnd = *lpEnd; - *lpEnd = 0x0000; - - /* Convert to ASCII */ - int size = 0; - int length = (PAL_wcslen(lpCommandLine)+1) * sizeof(WCHAR); - lpFileName = lpFileNamePS.OpenStringBuffer(length); - if (NULL == lpFileName) - { - ERROR("Not Enough Memory!\n"); - return FALSE; - } - if (!(size = WideCharToMultiByte(CP_ACP, 0, lpCommandLine, -1, - lpFileName, length, NULL, NULL))) - { - ASSERT("WideCharToMultiByte failure\n"); - return FALSE; - } - - lpFileNamePS.CloseBuffer(size - 1); - /* restore last character */ - *lpEnd = wcEnd; - - /* Replace '\' by '/' */ - FILEDosToUnixPathA(lpFileName); - - if (!getPath(lpFileNamePS, lpPathFileName)) - { - /* file is not in the path */ - return FALSE; - } - } - return TRUE; -} - -/*++ -Functions: VAL16 & VAL32 - Byte swapping functions for reading in little endian format files ---*/ -#ifdef BIGENDIAN - -static inline USHORT VAL16(USHORT x) -{ - return ( ((x & 0xFF00) >> 8) | ((x & 0x00FF) << 8) ); -} -static inline ULONG VAL32(DWORD x) -{ - return( ((x & 0xFF000000L) >> 24) | - ((x & 0x00FF0000L) >> 8) | - ((x & 0x0000FF00L) << 8) | - ((x & 0x000000FFL) << 24) ); -} -#else // BIGENDIAN -// For little-endian machines, do nothing -static __inline USHORT VAL16(unsigned short x) { return x; } -static __inline DWORD VAL32(DWORD x){ return x; } -#endif // BIGENDIAN - -static const DWORD IMAGE_DOS_SIGNATURE = 0x5A4D; -static const DWORD IMAGE_NT_SIGNATURE = 0x00004550; -static const DWORD IMAGE_SIZEOF_NT_OPTIONAL32_HEADER = 224; -static const DWORD IMAGE_NT_OPTIONAL_HDR32_MAGIC = 0x10b; -static const DWORD IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR = 14; - -typedef struct _IMAGE_DATA_DIRECTORY { - DWORD VirtualAddress; - DWORD Size; -} IMAGE_DATA_DIRECTORY, *PIMAGE_DATA_DIRECTORY; - -typedef struct _IMAGE_OPTIONAL_HEADER { - // - // Standard fields. - // - - WORD Magic; - BYTE MajorLinkerVersion; - BYTE MinorLinkerVersion; - DWORD SizeOfCode; - DWORD SizeOfInitializedData; - DWORD SizeOfUninitializedData; - DWORD AddressOfEntryPoint; - DWORD BaseOfCode; - DWORD BaseOfData; - - // - // NT additional fields. - // - - DWORD ImageBase; - DWORD SectionAlignment; - DWORD FileAlignment; - WORD MajorOperatingSystemVersion; - WORD MinorOperatingSystemVersion; - WORD MajorImageVersion; - WORD MinorImageVersion; - WORD MajorSubsystemVersion; - WORD MinorSubsystemVersion; - DWORD Win32VersionValue; - DWORD SizeOfImage; - DWORD SizeOfHeaders; - DWORD CheckSum; - WORD Subsystem; - WORD DllCharacteristics; - DWORD SizeOfStackReserve; - DWORD SizeOfStackCommit; - DWORD SizeOfHeapReserve; - DWORD SizeOfHeapCommit; - DWORD LoaderFlags; - DWORD NumberOfRvaAndSizes; - IMAGE_DATA_DIRECTORY DataDirectory[16]; -} IMAGE_OPTIONAL_HEADER32, *PIMAGE_OPTIONAL_HEADER32; - -typedef struct _IMAGE_FILE_HEADER { - WORD Machine; - WORD NumberOfSections; - DWORD TimeDateStamp; - DWORD PointerToSymbolTable; - DWORD NumberOfSymbols; - WORD SizeOfOptionalHeader; - WORD Characteristics; -} IMAGE_FILE_HEADER, *PIMAGE_FILE_HEADER; - -typedef struct _IMAGE_NT_HEADERS { - DWORD Signature; - IMAGE_FILE_HEADER FileHeader; - IMAGE_OPTIONAL_HEADER32 OptionalHeader; -} IMAGE_NT_HEADERS32, *PIMAGE_NT_HEADERS32; - -typedef struct _IMAGE_DOS_HEADER { /* DOS .EXE header*/ - WORD e_magic; /* Magic number*/ - WORD e_cblp; /* Bytes on last page of file*/ - WORD e_cp; /* Pages in file*/ - WORD e_crlc; /* Relocations*/ - WORD e_cparhdr; /* Size of header in paragraphs*/ - WORD e_minalloc; /* Minimum extra paragraphs needed*/ - WORD e_maxalloc; /* Maximum extra paragraphs needed*/ - WORD e_ss; /* Initial (relative) SS value*/ - WORD e_sp; /* Initial SP value*/ - WORD e_csum; /* Checksum*/ - WORD e_ip; /* Initial IP value*/ - WORD e_cs; /* Initial (relative) CS value*/ - WORD e_lfarlc; /* File address of relocation table*/ - WORD e_ovno; /* Overlay number*/ - WORD e_res[4]; /* Reserved words*/ - WORD e_oemid; /* OEM identifier (for e_oeminfo)*/ - WORD e_oeminfo; /* OEM information; e_oemid specific*/ - WORD e_res2[10]; /* Reserved words*/ - LONG e_lfanew; /* File address of new exe header*/ - } IMAGE_DOS_HEADER, *PIMAGE_DOS_HEADER; - - -/*++ -Function: - isManagedExecutable - -Determines if the passed in file is a managed executable - ---*/ -static -int -isManagedExecutable(LPCSTR lpFileName) -{ - HANDLE hFile = INVALID_HANDLE_VALUE; - DWORD cbRead; - IMAGE_DOS_HEADER dosheader; - IMAGE_NT_HEADERS32 NtHeaders; - BOOL ret = 0; - - /* then check if it is a PE/COFF file */ - if((hFile = CreateFileA(lpFileName, GENERIC_READ, FILE_SHARE_READ, NULL, - OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, - NULL)) == INVALID_HANDLE_VALUE) - { - goto isManagedExecutableExit; - } - - /* Open the file and read the IMAGE_DOS_HEADER structure */ - if(!ReadFile(hFile, &dosheader, sizeof(IMAGE_DOS_HEADER), &cbRead, NULL) || cbRead != sizeof(IMAGE_DOS_HEADER) ) - goto isManagedExecutableExit; - - /* check the DOS headers */ - if ( (dosheader.e_magic != VAL16(IMAGE_DOS_SIGNATURE)) || (VAL32(dosheader.e_lfanew) <= 0) ) - goto isManagedExecutableExit; - - /* Advance the file pointer to File address of new exe header */ - if( SetFilePointer(hFile, VAL32(dosheader.e_lfanew), NULL, FILE_BEGIN) == 0xffffffff) - goto isManagedExecutableExit; - - if( !ReadFile(hFile, &NtHeaders , sizeof(IMAGE_NT_HEADERS32), &cbRead, NULL) || cbRead != sizeof(IMAGE_NT_HEADERS32) ) - goto isManagedExecutableExit; - - /* check the NT headers */ - if ((NtHeaders.Signature != VAL32(IMAGE_NT_SIGNATURE)) || - (NtHeaders.FileHeader.SizeOfOptionalHeader != VAL16(IMAGE_SIZEOF_NT_OPTIONAL32_HEADER)) || - (NtHeaders.OptionalHeader.Magic != VAL16(IMAGE_NT_OPTIONAL_HDR32_MAGIC))) - goto isManagedExecutableExit; - - /* Check that the virtual address of IMAGE_DIRECTORY_ENTRY_COMHEADER is non-null */ - if ( NtHeaders.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR].VirtualAddress == 0 ) - goto isManagedExecutableExit; - - /* The file is a managed executable */ - ret = 1; - - isManagedExecutableExit: - /* Close the file handle if we opened it */ - if ( hFile != INVALID_HANDLE_VALUE ) - CloseHandle(hFile); - - return ret; -} - -/*++ -Function: - checkFileType - -Abstract: - Return the type of the file. - -Parameters: - IN lpFileName: file name - -Return: - FILE_DIR: Directory - FILE_UNIX: Unix executable file - FILE_PE: managed PE/COFF file - FILE_ERROR: Error ---*/ -static -int -checkFileType( LPCSTR lpFileName) -{ - struct stat stat_data; - - /* check if the file exist */ - if ( access(lpFileName, F_OK) != 0 ) - { - return FILE_ERROR; - } - - if( isManagedExecutable(lpFileName) ) - { - return FILE_PE; - } - - /* if it's not a PE/COFF file, check if it is executable */ - if ( -1 != stat( lpFileName, &stat_data ) ) - { - - if((stat_data.st_mode & S_IFMT) == S_IFDIR ) - { - /*The given file is a directory*/ - return FILE_DIR; - } - if ( UTIL_IsExecuteBitsSet( &stat_data ) ) - { - return FILE_UNIX; - } - else - { - return FILE_ERROR; - } - } - return FILE_ERROR; - -} - - -/*++ -Function: - buildArgv - -Abstract: - Helper function for CreateProcessW, it builds the array of argument in - a format than can be passed to execve function.lppArgv is allocated - in this function and must be freed by the caller. - -Parameters: - IN lpCommandLine: second parameter from CreateProcessW (an unicode string) - IN lpAppPath: cannonical name of the application to launched - OUT lppArgv: array of arguments to be passed to the new process - IN prependLoader: If True first argument should be the PE loader - -Return: - the number of arguments - -note: this doesn't yet match precisely the behavior of Windows, but should be -sufficient. -what's here: -1) stripping nonquoted whitespace -2) handling of quoted parameters and quoted "parts" of parameters, removal of - doublequotes ( becomes ) -3) \" as an escaped doublequote, both within doublequoted sequences and out -what's known missing : -1) \\ as an escaped backslash, but only if the string of '\' - is followed by a " (escaped or not) -2) "alternate" escape sequence : double-doublequote within a double-quoted - argument (<"aaa a""aa aaa">) expands to a single-doublequote() -note that there may be other special cases ---*/ -static -char ** -buildArgv( - LPCWSTR lpCommandLine, - PathCharString& lpAppPath, - UINT *pnArg, - BOOL prependLoader) -{ - CPalThread *pThread = NULL; - UINT iWlen; - char *lpAsciiCmdLine; - char *pChar; - char **lppArgv; - char **lppTemp; - UINT i,j; - - *pnArg = 0; - - iWlen = WideCharToMultiByte(CP_ACP,0,lpCommandLine,-1,NULL,0,NULL,NULL); - - if(0 == iWlen) - { - ASSERT("Can't determine length of command line\n"); - return NULL; - } - - pThread = InternalGetCurrentThread(); - /* make sure to allocate enough space, up for the worst case scenario */ - int iLength = (iWlen + strlen(PROCESS_PELOADER_FILENAME) + lpAppPath.GetCount() + 2); - lpAsciiCmdLine = (char *) InternalMalloc(iLength); - - if (lpAsciiCmdLine == NULL) - { - ERROR("Unable to allocate memory\n"); - return NULL; - } - - pChar = lpAsciiCmdLine; - - /* Prepend the PE loader, if it's required */ - if (prependLoader) - { - if ((strcpy_s(lpAsciiCmdLine, iLength, PROCESS_PELOADER_FILENAME) != SAFECRT_SUCCESS) || - (strcat_s(lpAsciiCmdLine, iLength, " ") != SAFECRT_SUCCESS)) - { - ERROR("strcpy_s/strcat_s failed!\n"); - return NULL; - } - - pChar = lpAsciiCmdLine + strlen (lpAsciiCmdLine); - - } - else - { - /* put the cannonical name of the application as the first parameter */ - if ((strcpy_s(lpAsciiCmdLine, iLength, "\"") != SAFECRT_SUCCESS) || - (strcat_s(lpAsciiCmdLine, iLength, lpAppPath) != SAFECRT_SUCCESS) || - (strcat_s(lpAsciiCmdLine, iLength, "\"") != SAFECRT_SUCCESS) || - (strcat_s(lpAsciiCmdLine, iLength, " ") != SAFECRT_SUCCESS)) - { - ERROR("strcpy_s/strcat_s failed!\n"); - return NULL; - } - - pChar = lpAsciiCmdLine + strlen (lpAsciiCmdLine); - - /* let's skip the first argument in the command line */ - - /* strip leading whitespace; function returns NULL if there's only - whitespace, so the if statement below will work correctly */ - lpCommandLine = UTIL_inverse_wcspbrk((LPWSTR)lpCommandLine, W16_WHITESPACE); - - if (lpCommandLine) - { - LPCWSTR stringstart = lpCommandLine; - - do - { - /* find first whitespace or dquote character */ - lpCommandLine = PAL_wcspbrk(lpCommandLine,W16_WHITESPACE_DQUOTE); - if(NULL == lpCommandLine) - { - /* no whitespace or dquote found : first arg is only arg */ - break; - } - else if('"' == *lpCommandLine) - { - /* got a dquote; skip over it if it's escaped; make sure we - don't try to look before the first character in the - string */ - if(lpCommandLine > stringstart && '\\' == lpCommandLine[-1]) - { - lpCommandLine++; - continue; - } - - /* found beginning of dquoted sequence, run to the end */ - /* don't stop if we hit an escaped dquote */ - lpCommandLine++; - while( *lpCommandLine ) - { - lpCommandLine = PAL_wcschr(lpCommandLine, '"'); - if(NULL == lpCommandLine) - { - /* no ending dquote, arg runs to end of string */ - break; - } - if('\\' != lpCommandLine[-1]) - { - /* dquote is not escaped, dquoted sequence is over*/ - break; - } - lpCommandLine++; - } - if(NULL == lpCommandLine || '\0' == *lpCommandLine) - { - /* no terminating dquote */ - break; - } - - /* step over dquote, keep looking for end of arg */ - lpCommandLine++; - } - else - { - /* found whitespace : end of arg. */ - lpCommandLine++; - break; - } - }while(lpCommandLine); - } - } - - /* Convert to ASCII */ - if (lpCommandLine) - { - if (!WideCharToMultiByte(CP_ACP, 0, lpCommandLine, -1, - pChar, iWlen+1, NULL, NULL)) - { - ASSERT("Unable to convert to a multibyte string\n"); - free(lpAsciiCmdLine); - return NULL; - } - } - - pChar = lpAsciiCmdLine; - - /* loops through all the arguments, to find out how many arguments there - are; while looping replace whitespace by \0 */ - - /* skip leading whitespace (and replace by '\0') */ - /* note : there shouldn't be any, command starts either with PE loader name - or computed application path, but this won't hurt */ - while (*pChar) - { - if (!isspace((unsigned char) *pChar)) - { - break; - } - WARN("unexpected whitespace in command line!\n"); - *pChar++ = '\0'; - } - - while (*pChar) - { - (*pnArg)++; - - /* find end of current arg */ - while(*pChar && !isspace((unsigned char) *pChar)) - { - if('"' == *pChar) - { - /* skip over dquote if it's escaped; make sure we don't try to - look before the start of the string for the \ */ - if(pChar > lpAsciiCmdLine && '\\' == pChar[-1]) - { - pChar++; - continue; - } - - /* found leading dquote : look for ending dquote */ - pChar++; - while (*pChar) - { - pChar = strchr(pChar,'"'); - if(NULL == pChar) - { - /* no ending dquote found : argument extends to the end - of the string*/ - break; - } - if('\\' != pChar[-1]) - { - /* found a dquote, and it's not escaped : quoted - sequence is over*/ - break; - } - /* found a dquote, but it was escaped : skip over it, keep - looking */ - pChar++; - } - if(NULL == pChar || '\0' == *pChar) - { - /* reached the end of the string : we're done */ - break; - } - } - pChar++; - } - if(NULL == pChar) - { - /* reached the end of the string : we're done */ - break; - } - /* reached end of arg; replace trailing whitespace by '\0', to split - arguments into separate strings */ - while (isspace((unsigned char) *pChar)) - { - *pChar++ = '\0'; - } - } - - /* allocate lppargv according to the number of arguments - in the command line */ - lppArgv = (char **) InternalMalloc((((*pnArg)+1) * sizeof(char *))); - - if (lppArgv == NULL) - { - free(lpAsciiCmdLine); - return NULL; - } - - lppTemp = lppArgv; - - /* at this point all parameters are separated by NULL - we need to fill the array of arguments; we must also remove all dquotes - from arguments (new process shouldn't see them) */ - for (i = *pnArg, pChar = lpAsciiCmdLine; i; i--) - { - /* skip NULLs */ - while (!*pChar) - { - pChar++; - } - - *lppTemp = pChar; - - /* go to the next parameter, removing dquotes as we go along */ - j = 0; - while (*pChar) - { - /* copy character if it's not a dquote */ - if('"' != *pChar) - { - /* if it's the \ of an escaped dquote, skip over it, we'll - copy the " instead */ - if( '\\' == pChar[0] && '"' == pChar[1] ) - { - pChar++; - } - (*lppTemp)[j++] = *pChar; - } - pChar++; - } - /* re-NULL terminate the argument */ - (*lppTemp)[j] = '\0'; - - lppTemp++; - } - - *lppTemp = NULL; - - return lppArgv; -} - - -/*++ -Function: - getPath - -Abstract: - Helper function for CreateProcessW, it looks in the path environment - variable to find where the process to executed is. - -Parameters: - IN lpFileName: file name to search in the path - OUT lpPathFileName: returned string containing the path and the filename - -Return: - TRUE if found - FALSE otherwise ---*/ -static -BOOL -getPath( - PathCharString& lpFileNameString, - PathCharString& lpPathFileName) -{ - LPSTR lpPath; - LPSTR lpNext; - LPSTR lpCurrent; - LPWSTR lpwstr; - INT n; - INT nextLen; - INT slashLen; - CPalThread *pThread = NULL; - LPCSTR lpFileName = lpFileNameString.GetString(); - - /* if a path is specified, only look there */ - if(strchr(lpFileName, '/')) - { - if (access (lpFileName, F_OK) == 0) - { - if (!lpPathFileName.Set(lpFileNameString)) - { - TRACE("Set of StackString failed!\n"); - return FALSE; - } - - TRACE("file %s exists\n", lpFileName); - return TRUE; - } - else - { - TRACE("file %s doesn't exist.\n", lpFileName); - return FALSE; - } - } - - /* first look in directory from which the application loaded */ - lpwstr = g_lpwstrAppDir; - - if (lpwstr) - { - /* convert path to multibyte, check buffer size */ - n = WideCharToMultiByte(CP_ACP, 0, lpwstr, -1, NULL, 0, - NULL, NULL); - - if (!lpPathFileName.Reserve(n + lpFileNameString.GetCount() + 1 )) - { - ERROR("StackString Reserve failed!\n"); - return FALSE; - } - - lpPath = lpPathFileName.OpenStringBuffer(n); - - n = WideCharToMultiByte(CP_ACP, 0, lpwstr, -1, lpPath, n, - NULL, NULL); - - if (n == 0) - { - lpPathFileName.CloseBuffer(0); - ASSERT("WideCharToMultiByte failure!\n"); - return FALSE; - } - - lpPathFileName.CloseBuffer(n - 1); - - lpPathFileName.Append("/", 1); - lpPathFileName.Append(lpFileNameString); - - if (access(lpPathFileName, F_OK) == 0) - { - TRACE("found %s in application directory (%s)\n", lpFileName, lpPathFileName.GetString()); - return TRUE; - } - } - - /* then try the current directory */ - if (!lpPathFileName.Reserve(lpFileNameString.GetCount() + 2)) - { - ERROR("StackString Reserve failed!\n"); - return FALSE; - } - - lpPathFileName.Set("./", 2); - lpPathFileName.Append(lpFileNameString); - - if (access (lpPathFileName, R_OK) == 0) - { - TRACE("found %s in current directory.\n", lpFileName); - return TRUE; - } - - pThread = InternalGetCurrentThread(); - - /* Then try to look in the path */ - lpPath = EnvironGetenv("PATH"); - - if (!lpPath) - { - ERROR("EnvironGetenv returned NULL for $PATH\n"); - return FALSE; - } - - lpNext = lpPath; - - /* search in every path directory */ - TRACE("looking for file %s in $PATH (%s)\n", lpFileName, lpPath); - while (lpNext) - { - /* skip all leading ':' */ - while(*lpNext==':') - { - lpNext++; - } - - /* search for ':' */ - lpCurrent = strchr(lpNext, ':'); - if (lpCurrent) - { - *lpCurrent++ = '\0'; - } - - nextLen = strlen(lpNext); - slashLen = (lpNext[nextLen-1] == '/') ? 0:1; - - if (!lpPathFileName.Reserve(nextLen + lpFileNameString.GetCount() + 1)) - { - free(lpPath); - ERROR("StackString ran out of memory for full path\n"); - return FALSE; - } - - lpPathFileName.Set(lpNext, nextLen); - - if( slashLen == 1) - { - /* append a '/' if there's no '/' at the end of the path */ - lpPathFileName.Append("/", 1); - } - - lpPathFileName.Append(lpFileNameString); - - if ( access (lpPathFileName, F_OK) == 0) - { - TRACE("Found %s in $PATH element %s\n", lpFileName, lpNext); - free(lpPath); - return TRUE; - } - - lpNext = lpCurrent; /* search in the next directory */ - } - - free(lpPath); - TRACE("File %s not found in $PATH\n", lpFileName); - return FALSE; -} - -/*++ -Function: - ~CProcProcessLocalData - -Process data destructor ---*/ -CorUnix::CProcProcessLocalData::~CProcProcessLocalData() -{ - if (pProcessModules != NULL) - { - DestroyProcessModules(pProcessModules); - } -} - diff --git a/src/pal/src/thread/procprivate.hpp b/src/pal/src/thread/procprivate.hpp deleted file mode 100644 index bd35b69fe..000000000 --- a/src/pal/src/thread/procprivate.hpp +++ /dev/null @@ -1,78 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*++ - - - -Module Name: - - thread/procprivate.hpp - -Abstract: - - Private process structures and routines - -Revision History: - - - ---*/ - -#ifndef _PAL_PROCPRIVATE_HPP_ -#define _PAL_PROCPRIVATE_HPP_ - -#include "pal/thread.hpp" - -namespace CorUnix -{ - - /*++ - Function: - PROCAddThread - - Abstract - Add a thread to the thread list of the current process - --*/ - void PROCAddThread(CPalThread *pCurrentThread, CPalThread *pTargetThread); - - extern CPalThread *pGThreadList; - - /*++ - Function: - PROCRemoveThread - - Abstract - Remove a thread form the thread list of the current process - --*/ - void PROCRemoveThread(CPalThread *pCurrentThread, CPalThread *pTargetThread); - - /*++ - Function: - PROCGetNumberOfThreads - - Abstract - Return the number of threads in the thread list. - --*/ - INT PROCGetNumberOfThreads(void); - - - /*++ - Function: - TerminateCurrentProcessNoExit - - Parameters: - BOOL bTerminateUnconditionally - If this is set, the PAL will exit as - quickly as possible. In particular, it will not unload DLLs. - - Abstract: - Terminate Current Process, but leave the caller alive - --*/ - void TerminateCurrentProcessNoExit(BOOL bTerminateUnconditionally); - -} - -#endif //_PAL_PROCPRIVATE_HPP_ - - diff --git a/src/pal/src/thread/thread.cpp b/src/pal/src/thread/thread.cpp index bc06d2f7d..175ff0ad6 100644 --- a/src/pal/src/thread/thread.cpp +++ b/src/pal/src/thread/thread.cpp @@ -22,21 +22,14 @@ Abstract: SET_DEFAULT_DEBUG_CHANNEL(THREAD); // some headers have code with asserts, so do this first #include "pal/corunix.hpp" -#include "pal/context.h" #include "pal/thread.hpp" -#include "pal/mutex.hpp" #include "pal/handlemgr.hpp" #include "pal/cs.hpp" -#include "pal/seh.hpp" -#include "pal/signal.hpp" - -#include "procprivate.hpp" #include "pal/process.h" #include "pal/module.h" #include "pal/environ.h" #include "pal/init.h" #include "pal/utils.h" -#include "pal/virtual.h" #if defined(__NetBSD__) && !HAVE_PTHREAD_GETCPUCLOCKID #include @@ -87,68 +80,6 @@ static Volatile free_threads_list = NULL; /* NOTE: can't use a CRITICAL_SECTION here (see comment in FreeTHREAD) */ int free_threads_spinlock = 0; -/* lock to access iEndingThreads counter, condition variable to signal shutdown -thread when any remaining threads have died, and count of exiting threads that -can't be suspended. */ -pthread_mutex_t ptmEndThread; -pthread_cond_t ptcEndThread; -static int iEndingThreads = 0; - -// Activation function that gets called when an activation is injected into a thread. -PAL_ActivationFunction g_activationFunction = NULL; -// Function to check if an activation can be safely injected at a specified context -PAL_SafeActivationCheckFunction g_safeActivationCheckFunction = NULL; - -void -ThreadCleanupRoutine( - CPalThread *pThread, - IPalObject *pObjectToCleanup, - bool fShutdown, - bool fCleanupSharedState - ); - -PAL_ERROR -ThreadInitializationRoutine( - CPalThread *pThread, - CObjectType *pObjectType, - void *pImmutableData, - void *pSharedData, - void *pProcessLocalData - ); - -void -IncrementEndingThreadCount( - void - ); - -void -DecrementEndingThreadCount( - void - ); - -CObjectType CorUnix::otThread( - otiThread, - ThreadCleanupRoutine, - ThreadInitializationRoutine, - 0, // sizeof(CThreadImmutableData), - NULL, // No immutable data copy routine - NULL, // No immutable data cleanup routine - sizeof(CThreadProcessLocalData), - NULL, // No process local data cleanup routine - 0, // sizeof(CThreadSharedData), - 0, // THREAD_ALL_ACCESS, - CObjectType::SecuritySupported, - CObjectType::SecurityInfoNotPersisted, - CObjectType::UnnamedObject, - CObjectType::LocalDuplicationOnly, - CObjectType::WaitableObject, - CObjectType::SingleTransitionObject, - CObjectType::ThreadReleaseHasNoSideEffects, - CObjectType::NoOwner - ); - -CAllowedObjectTypes aotThread(otiThread); - /*++ Function: InternalEndCurrentThreadWrapper @@ -169,7 +100,6 @@ static void InternalEndCurrentThreadWrapper(void *arg) // that the current thread is known to this PAL, and that pThread // actually is the current PAL thread, put it back in TLS temporarily. pthread_setspecific(thObjKey, pThread); - (void)PAL_Enter(PAL_BoundaryTop); /* Call entry point functions of every attached modules to indicate the thread is exiting */ @@ -177,14 +107,7 @@ static void InternalEndCurrentThreadWrapper(void *arg) will lock its own critical section */ LOADCallDllMain(DLL_THREAD_DETACH, NULL); - // PAL_Leave will be called just before we release the thread reference - // in InternalEndCurrentThread. - InternalEndCurrentThread(pThread); pthread_setspecific(thObjKey, NULL); - -#if !HAVE_MACH_EXCEPTIONS - FreeSignalAlternateStack(); -#endif // !HAVE_MACH_EXCEPTIONS } /*++ @@ -314,1398 +237,6 @@ static void FreeTHREAD(CPalThread *pThread) SPINLOCKRelease(&free_threads_spinlock); } - -/*++ -Function: - THREADGetThreadProcessId - -returns the process owner ID of the indicated hThread ---*/ -DWORD -THREADGetThreadProcessId( - HANDLE hThread - // UNIXTODO Should take pThread parameter here (modify callers) - ) -{ - CPalThread *pThread; - CPalThread *pTargetThread; - IPalObject *pobjThread = NULL; - PAL_ERROR palError = NO_ERROR; - - DWORD dwProcessId = 0; - - pThread = InternalGetCurrentThread(); - - palError = InternalGetThreadDataFromHandle( - pThread, - hThread, - 0, - &pTargetThread, - &pobjThread - ); - - if (NO_ERROR != palError) - { - if (!pThread->IsDummy()) - { - dwProcessId = GetCurrentProcessId(); - } - else - { - ASSERT("Dummy thread passed to THREADGetProcessId\n"); - } - - if (NULL != pobjThread) - { - pobjThread->ReleaseReference(pThread); - } - } - else - { - ERROR("Couldn't retreive the hThread:%p pid owner !\n", hThread); - } - - - return dwProcessId; -} - -/*++ -Function: - GetCurrentThreadId - -See MSDN doc. ---*/ -DWORD -PALAPI -GetCurrentThreadId( - VOID) -{ - DWORD dwThreadId; - - PERF_ENTRY(GetCurrentThreadId); - ENTRY("GetCurrentThreadId()\n"); - - // - // TODO: should do perf test to see how this compares - // with calling InternalGetCurrentThread (i.e., is our lookaside - // cache faster on average than pthread_self?) - // - - dwThreadId = (DWORD)THREADSilentGetCurrentThreadId(); - - LOGEXIT("GetCurrentThreadId returns DWORD %#x\n", dwThreadId); - PERF_EXIT(GetCurrentThreadId); - - return dwThreadId; -} - - - -/*++ -Function: - GetCurrentThread - -See MSDN doc. ---*/ -HANDLE -PALAPI -PAL_GetCurrentThread( - VOID) -{ - PERF_ENTRY(GetCurrentThread); - ENTRY("GetCurrentThread()\n"); - - LOGEXIT("GetCurrentThread returns HANDLE %p\n", hPseudoCurrentThread); - PERF_EXIT(GetCurrentThread); - - /* return a pseudo handle */ - return (HANDLE) hPseudoCurrentThread; -} - -/*++ -Function: - SwitchToThread - -See MSDN doc. ---*/ -BOOL -PALAPI -SwitchToThread( - VOID) -{ - BOOL ret; - - PERF_ENTRY(SwitchToThread); - ENTRY("SwitchToThread(VOID)\n"); - - /* sched_yield yields to another thread in the current process. This implementation - won't work well for cross-process synchronization. */ - ret = (sched_yield() == 0); - - LOGEXIT("SwitchToThread returns BOOL %d\n", ret); - PERF_EXIT(SwitchToThread); - - return ret; -} - -/*++ -Function: - CreateThread - -Note: - lpThreadAttributes could be ignored. - -See MSDN doc. - ---*/ -HANDLE -PALAPI -CreateThread( - IN LPSECURITY_ATTRIBUTES lpThreadAttributes, - IN DWORD dwStackSize, - IN LPTHREAD_START_ROUTINE lpStartAddress, - IN LPVOID lpParameter, - IN DWORD dwCreationFlags, - OUT LPDWORD lpThreadId) -{ - PAL_ERROR palError; - CPalThread *pThread; - HANDLE hNewThread = NULL; - - PERF_ENTRY(CreateThread); - ENTRY("CreateThread(lpThreadAttr=%p, dwStackSize=%u, lpStartAddress=%p, " - "lpParameter=%p, dwFlags=%#x, lpThreadId=%#x)\n", - lpThreadAttributes, dwStackSize, lpStartAddress, lpParameter, - dwCreationFlags, lpThreadId); - - pThread = InternalGetCurrentThread(); - - palError = InternalCreateThread( - pThread, - lpThreadAttributes, - dwStackSize, - lpStartAddress, - lpParameter, - dwCreationFlags, - UserCreatedThread, - lpThreadId, - &hNewThread - ); - - if (NO_ERROR != palError) - { - pThread->SetLastError(palError); - } - - LOGEXIT("CreateThread returns HANDLE %p\n", hNewThread); - PERF_EXIT(CreateThread); - - return hNewThread; -} - -PAL_ERROR -CorUnix::InternalCreateThread( - CPalThread *pThread, - LPSECURITY_ATTRIBUTES lpThreadAttributes, - DWORD dwStackSize, - LPTHREAD_START_ROUTINE lpStartAddress, - LPVOID lpParameter, - DWORD dwCreationFlags, - PalThreadType eThreadType, - LPDWORD lpThreadId, - HANDLE *phThread - ) -{ - PAL_ERROR palError; - CPalThread *pNewThread = NULL; - CObjectAttributes oa; - bool fAttributesInitialized = FALSE; - bool fThreadDataAddedToProcessList = FALSE; - HANDLE hNewThread = NULL; - - pthread_t pthread; - pthread_attr_t pthreadAttr; - size_t pthreadStackSize; -#if PTHREAD_CREATE_MODIFIES_ERRNO - int storedErrno; -#endif // PTHREAD_CREATE_MODIFIES_ERRNO - BOOL fHoldingProcessLock = FALSE; - int iError = 0; - size_t alignedStackSize; - - if (0 != terminator) - { - // - // Since the PAL is in the middle of shutting down we don't want to - // create any new threads (since it's possible for that new thread - // to create another thread before the shutdown thread gets around - // to suspending it, and so on). We don't want to return an error - // here, though, as some programs (in particular, build) do not - // handle CreateThread errors properly -- instead, we just put - // the calling thread to sleep (unless it is the shutdown thread, - // which could occur if a DllMain PROCESS_DETACH handler tried to - // create a new thread for some odd reason). - // - - ERROR("process is terminating, can't create new thread.\n"); - - if (pThread->GetThreadId() != static_cast(terminator)) - { - while (true) - { - poll(NULL, 0, INFTIM); - sched_yield(); - } - } - else - { - // - // This is the shutdown thread, so just return an error - // - - palError = ERROR_PROCESS_ABORTED; - goto EXIT; - } - } - - /* Validate parameters */ - - if (lpThreadAttributes != NULL) - { - ASSERT("lpThreadAttributes parameter must be NULL (%p)\n", - lpThreadAttributes); - palError = ERROR_INVALID_PARAMETER; - goto EXIT; - } - - alignedStackSize = dwStackSize; - if (alignedStackSize != 0) - { - // Some systems require the stack size to be aligned to the page size - if (sizeof(alignedStackSize) <= sizeof(dwStackSize) && alignedStackSize + (GetVirtualPageSize() - 1) < alignedStackSize) - { - // When coming here from the public API surface, the incoming value is originally a nonnegative signed int32, so - // this shouldn't happen - ASSERT( - "Couldn't align the requested stack size (%Iu) to the page size because the stack size was too large\n", - alignedStackSize); - palError = ERROR_INVALID_PARAMETER; - goto EXIT; - } - alignedStackSize = ALIGN_UP(alignedStackSize, GetVirtualPageSize()); - } - - // Ignore the STACK_SIZE_PARAM_IS_A_RESERVATION flag - dwCreationFlags &= ~STACK_SIZE_PARAM_IS_A_RESERVATION; - - if ((dwCreationFlags != 0) && (dwCreationFlags != CREATE_SUSPENDED)) - { - ASSERT("dwCreationFlags parameter is invalid (%#x)\n", dwCreationFlags); - palError = ERROR_INVALID_PARAMETER; - goto EXIT; - } - - // - // Create the CPalThread for the thread - // - - pNewThread = AllocTHREAD(); - if (NULL == pNewThread) - { - palError = ERROR_OUTOFMEMORY; - goto EXIT; - } - - palError = pNewThread->RunPreCreateInitializers(); - if (NO_ERROR != palError) - { - goto EXIT; - } - - pNewThread->m_lpStartAddress = lpStartAddress; - pNewThread->m_lpStartParameter = lpParameter; - pNewThread->m_bCreateSuspended = (dwCreationFlags & CREATE_SUSPENDED) == CREATE_SUSPENDED; - pNewThread->m_eThreadType = eThreadType; - - if (0 != pthread_attr_init(&pthreadAttr)) - { - ERROR("couldn't initialize pthread attributes\n"); - palError = ERROR_INTERNAL_ERROR; - goto EXIT; - } - - fAttributesInitialized = TRUE; - - if (alignedStackSize == 0) - { - // The thread is to be created with default stack size. Use the default stack size - // override that was determined during the PAL initialization. - alignedStackSize = g_defaultStackSize; - } - - /* adjust the stack size if necessary */ - if (alignedStackSize != 0) - { -#ifdef PTHREAD_STACK_MIN - size_t MinStackSize = ALIGN_UP(PTHREAD_STACK_MIN, GetVirtualPageSize()); -#else // !PTHREAD_STACK_MIN - size_t MinStackSize = 64 * 1024; // this value is typically accepted by pthread_attr_setstacksize() -#endif // PTHREAD_STACK_MIN - if (alignedStackSize < MinStackSize) - { - // Adjust the stack size to a minimum value that is likely to be accepted by pthread_attr_setstacksize(). If this - // function fails, typically the caller will end up throwing OutOfMemoryException under the assumption that the - // requested stack size is too large or the system does not have sufficient memory to create a thread. Try to - // prevent failing just just because the stack size value is too low. - alignedStackSize = MinStackSize; - } - - TRACE("setting thread stack size to %Iu\n", alignedStackSize); - if (0 != pthread_attr_setstacksize(&pthreadAttr, alignedStackSize)) - { - ERROR("couldn't set pthread stack size to %Iu\n", alignedStackSize); - palError = ERROR_INTERNAL_ERROR; - goto EXIT; - } - } - else - { - TRACE("using the system default thread stack size\n"); - } - -#if HAVE_THREAD_SELF || HAVE__LWP_SELF - /* Create new threads as "bound", so each pthread is permanently bound - to an LWP. Get/SetThreadContext() depend on this 1:1 mapping. */ - pthread_attr_setscope(&pthreadAttr, PTHREAD_SCOPE_SYSTEM); -#endif // HAVE_THREAD_SELF || HAVE__LWP_SELF - - // - // We never call pthread_join, so create the new thread as detached - // - - iError = pthread_attr_setdetachstate(&pthreadAttr, PTHREAD_CREATE_DETACHED); - _ASSERTE(0 == iError); - - // - // Create the IPalObject for the thread and store it in the object - // - - palError = CreateThreadObject( - pThread, - pNewThread, - &hNewThread); - - if (NO_ERROR != palError) - { - goto EXIT; - } - - // - // Add the thread to the process list - // - - // - // We use the process lock to ensure that we're not interrupted - // during the creation process. After adding the CPalThread reference - // to the process list, we want to make sure the actual thread has been - // started. Otherwise, there's a window where the thread can be found - // in the process list but doesn't yet exist in the system. - // - - PROCProcessLock(); - fHoldingProcessLock = TRUE; - - PROCAddThread(pThread, pNewThread); - fThreadDataAddedToProcessList = TRUE; - - // - // Spawn the new pthread - // - -#if PTHREAD_CREATE_MODIFIES_ERRNO - storedErrno = errno; -#endif // PTHREAD_CREATE_MODIFIES_ERRNO - -#ifdef FEATURE_PAL_SXS - _ASSERT_MSG(pNewThread->IsInPal(), "New threads we're about to spawn should always be in the PAL.\n"); -#endif // FEATURE_PAL_SXS - iError = pthread_create(&pthread, &pthreadAttr, CPalThread::ThreadEntry, pNewThread); - -#if PTHREAD_CREATE_MODIFIES_ERRNO - if (iError == 0) - { - // Restore errno if pthread_create succeeded. - errno = storedErrno; - } -#endif // PTHREAD_CREATE_MODIFIES_ERRNO - - if (0 != iError) - { - ERROR("pthread_create failed, error is %d (%s)\n", iError, strerror(iError)); - palError = ERROR_NOT_ENOUGH_MEMORY; - goto EXIT; - } - - // - // Wait for the new thread to finish its initial startup tasks - // (i.e., the ones that might fail) - // - if (pNewThread->WaitForStartStatus()) - { - // - // Everything succeeded. Store the handle for the new thread and - // the thread's ID in the out params - // - *phThread = hNewThread; - - if (NULL != lpThreadId) - { - *lpThreadId = pNewThread->GetThreadId(); - } - } - else - { - ERROR("error occurred in THREADEntry, thread creation failed.\n"); - palError = ERROR_INTERNAL_ERROR; - goto EXIT; - } - - // - // If we're here, then we've locked the process list and both pthread_create - // and WaitForStartStatus succeeded. Thus, we can now unlock the process list. - // Since palError == NO_ERROR, we won't call this again in the exit block. - // - PROCProcessUnlock(); - fHoldingProcessLock = FALSE; - -EXIT: - - if (fAttributesInitialized) - { - if (0 != pthread_attr_destroy(&pthreadAttr)) - { - WARN("pthread_attr_destroy() failed\n"); - } - } - - if (NO_ERROR != palError) - { - // - // We either were not able to create the new thread, or a failure - // occurred in the new thread's entry routine. Free up the associated - // resources here - // - - if (fThreadDataAddedToProcessList) - { - PROCRemoveThread(pThread, pNewThread); - } - // - // Once we remove the thread from the process list, we can call - // PROCProcessUnlock. - // - if (fHoldingProcessLock) - { - PROCProcessUnlock(); - } - fHoldingProcessLock = FALSE; - } - - _ASSERT_MSG(!fHoldingProcessLock, "Exiting InternalCreateThread while still holding the process critical section.\n"); - - return palError; -} - - - -/*++ -Function: - ExitThread - -See MSDN doc. ---*/ -PAL_NORETURN -VOID -PALAPI -ExitThread( - IN DWORD dwExitCode) -{ - CPalThread *pThread; - - ENTRY("ExitThread(dwExitCode=%u)\n", dwExitCode); - PERF_ENTRY_ONLY(ExitThread); - - pThread = InternalGetCurrentThread(); - - /* store the exit code */ - pThread->SetExitCode(dwExitCode); - - /* pthread_exit runs TLS destructors and cleanup routines, - possibly registered by foreign code. The right thing - to do here is to leave the PAL. Our own TLS destructor - re-enters us explicitly. */ - PAL_Leave(PAL_BoundaryTop); - - /* kill the thread (itself), resulting in a call to InternalEndCurrentThread */ - pthread_exit(NULL); - - ASSERT("pthread_exit should not return!\n"); - for (;;); -} - -/*++ -Function: - InternalEndCurrentThread - -Does any necessary memory clean up, signals waiting threads, and then forces -the current thread to exit. ---*/ - -VOID -CorUnix::InternalEndCurrentThread( - CPalThread *pThread - ) -{ - PAL_ERROR palError = NO_ERROR; - ISynchStateController *pSynchStateController = NULL; - -#ifdef PAL_PERF - PERFDisableThreadProfile(UserCreatedThread != pThread->GetThreadType()); -#endif - - // - // Abandon any objects owned by this thread - // - - palError = g_pSynchronizationManager->AbandonObjectsOwnedByThread( - pThread, - pThread - ); - - if (NO_ERROR != palError) - { - ERROR("Failure abandoning owned objects"); - } - - // - // Need to synchronize setting the thread state to TS_DONE since - // this is checked for in InternalSuspendThreadFromData. - // TODO: Is this still needed after removing InternalSuspendThreadFromData? - // - - pThread->suspensionInfo.AcquireSuspensionLock(pThread); - IncrementEndingThreadCount(); - pThread->synchronizationInfo.SetThreadState(TS_DONE); - pThread->suspensionInfo.ReleaseSuspensionLock(pThread); - - // - // Mark the thread object as signaled - // - - palError = pThread->GetThreadObject()->GetSynchStateController( - pThread, - &pSynchStateController - ); - - if (NO_ERROR == palError) - { - palError = pSynchStateController->SetSignalCount(1); - if (NO_ERROR != palError) - { - ASSERT("Unable to mark thread object as signaled"); - } - - pSynchStateController->ReleaseController(); - } - else - { - ASSERT("Unable to obtain state controller for thread"); - } - -#ifndef FEATURE_PAL_SXS - // If this is the last thread then delete the process' data, - // but don't exit because the application hosting the PAL - // might have its own threads. - if (PROCGetNumberOfThreads() == 1) - { - TRACE("Last thread is exiting\n"); - DecrementEndingThreadCount(); - TerminateCurrentProcessNoExit(FALSE); - } - else -#endif // !FEATURE_PAL_SXS - { - /* Do this ONLY if we aren't the last thread -> otherwise - it gets done by TerminateProcess-> - PROCCleanupProcess->PALShutdown->PAL_Terminate */ - - // - // Add a reference to the thread data before releasing the - // thread object, so we can still use it - // - - pThread->AddThreadReference(); - - // - // Release the reference to the IPalObject for this thread - // - - pThread->GetThreadObject()->ReleaseReference(pThread); - - /* Remove thread for the thread list of the process - (don't do if this is the last thread -> gets handled by - TerminateProcess->PROCCleanupProcess->PROCTerminateOtherThreads) */ - - PROCRemoveThread(pThread, pThread); - -#ifdef FEATURE_PAL_SXS - // Ensure that EH is disabled on the current thread - SEHDisable(pThread); - PAL_Leave(PAL_BoundaryTop); -#endif // FEATURE_PAL_SXS - - - // - // Now release our reference to the thread data. We cannot touch - // it after this point - // - - pThread->ReleaseThreadReference(); - DecrementEndingThreadCount(); - - } -} - -/*++ -Function: - GetThreadPriority - -See MSDN doc. ---*/ -int -PALAPI -GetThreadPriority( - IN HANDLE hThread) -{ - CPalThread *pThread; - PAL_ERROR palError; - int iPriority = THREAD_PRIORITY_ERROR_RETURN; - - PERF_ENTRY(GetThreadPriority); - ENTRY("GetThreadPriority(hThread=%p)\n", hThread); - - pThread = InternalGetCurrentThread(); - - palError = InternalGetThreadPriority( - pThread, - hThread, - &iPriority - ); - - if (NO_ERROR != palError) - { - pThread->SetLastError(palError); - } - - LOGEXIT("GetThreadPriorityExit returns int %d\n", iPriority); - PERF_EXIT(GetThreadPriority); - - return iPriority; -} - -PAL_ERROR -CorUnix::InternalGetThreadPriority( - CPalThread *pThread, - HANDLE hThread, - int *piPriority - ) -{ - PAL_ERROR palError = NO_ERROR; - CPalThread *pTargetThread; - IPalObject *pobjThread = NULL; - - palError = InternalGetThreadDataFromHandle( - pThread, - hThread, - 0, // THREAD_QUERY_INFORMATION - &pTargetThread, - &pobjThread - ); - - if (NO_ERROR != palError) - { - goto InternalGetThreadPriorityExit; - } - - pTargetThread->Lock(pThread); - - *piPriority = pTargetThread->GetThreadPriority(); - - pTargetThread->Unlock(pThread); - -InternalGetThreadPriorityExit: - - if (NULL != pobjThread) - { - pobjThread->ReleaseReference(pThread); - } - - return palError; -} - - -/*++ -Function: - SetThreadPriority - -See MSDN doc. ---*/ -BOOL -PALAPI -SetThreadPriority( - IN HANDLE hThread, - IN int nPriority) -{ - CPalThread *pThread; - PAL_ERROR palError = NO_ERROR; - - PERF_ENTRY(SetThreadPriority); - ENTRY("SetThreadPriority(hThread=%p, nPriority=%#x)\n", hThread, nPriority); - - pThread = InternalGetCurrentThread(); - - palError = InternalSetThreadPriority( - pThread, - hThread, - nPriority - ); - - if (NO_ERROR != palError) - { - pThread->SetLastError(palError); - } - - LOGEXIT("SetThreadPriority returns BOOL %d\n", NO_ERROR == palError); - PERF_EXIT(SetThreadPriority); - - return NO_ERROR == palError; -} - -PAL_ERROR -CorUnix::InternalSetThreadPriority( - CPalThread *pThread, - HANDLE hTargetThread, - int iNewPriority - ) -{ - PAL_ERROR palError = NO_ERROR; - CPalThread *pTargetThread = NULL; - IPalObject *pobjThread = NULL; - - int st; - int policy; - struct sched_param schedParam; - int max_priority; - int min_priority; - float posix_priority; - - - palError = InternalGetThreadDataFromHandle( - pThread, - hTargetThread, - 0, // THREAD_SET_INFORMATION - &pTargetThread, - &pobjThread - ); - - if (NO_ERROR != palError) - { - goto InternalSetThreadPriorityExit; - } - - pTargetThread->Lock(pThread); - - /* validate the requested priority */ - switch (iNewPriority) - { - case THREAD_PRIORITY_TIME_CRITICAL: /* fall through */ - case THREAD_PRIORITY_IDLE: - break; - - case THREAD_PRIORITY_HIGHEST: /* fall through */ - case THREAD_PRIORITY_ABOVE_NORMAL: /* fall through */ - case THREAD_PRIORITY_NORMAL: /* fall through */ - case THREAD_PRIORITY_BELOW_NORMAL: /* fall through */ - case THREAD_PRIORITY_LOWEST: -#if PAL_IGNORE_NORMAL_THREAD_PRIORITY - /* We aren't going to set the thread priority. Just record what it is, - and exit */ - pTargetThread->m_iThreadPriority = iNewPriority; - goto InternalSetThreadPriorityExit; -#endif - break; - - default: - ASSERT("Priority %d not supported\n", iNewPriority); - palError = ERROR_INVALID_PARAMETER; - goto InternalSetThreadPriorityExit; - } - - /* check if the thread is still running */ - if (TS_DONE == pTargetThread->synchronizationInfo.GetThreadState()) - { - /* the thread has exited, set the priority in the thread structure - and exit */ - pTargetThread->m_iThreadPriority = iNewPriority; - goto InternalSetThreadPriorityExit; - } - - /* get the previous thread schedule parameters. We need to know the - scheduling policy to determine the priority range */ - if (pthread_getschedparam( - pTargetThread->GetPThreadSelf(), - &policy, - &schedParam - ) != 0) - { - ASSERT("Unable to get current thread scheduling information\n"); - palError = ERROR_INTERNAL_ERROR; - goto InternalSetThreadPriorityExit; - } - -#if !HAVE_SCHED_OTHER_ASSIGNABLE - /* Defining thread priority for SCHED_OTHER is implementation defined. - Some platforms like NetBSD cannot reassign it as they are dynamic. - */ - if (policy == SCHED_OTHER) - { - TRACE("Pthread priority levels for SCHED_OTHER cannot be reassigned on this platform\n"); - goto InternalSetThreadPriorityExit; - } -#endif - -#if HAVE_SCHED_GET_PRIORITY - max_priority = sched_get_priority_max(policy); - min_priority = sched_get_priority_min(policy); - if( -1 == max_priority || -1 == min_priority) - { - ASSERT("sched_get_priority_min/max failed; error is %d (%s)\n", - errno, strerror(errno)); - palError = ERROR_INTERNAL_ERROR; - goto InternalSetThreadPriorityExit; - } -#else - max_priority = PAL_THREAD_PRIORITY_MAX; - min_priority = PAL_THREAD_PRIORITY_MIN; -#endif - - TRACE("Pthread priorities for policy %d must be in the range %d to %d\n", - policy, min_priority, max_priority); - - /* explanation for fancy maths below : - POSIX doesn't specify the range of thread priorities that can be used - with pthread_setschedparam. Instead, one must use sched_get_priority_min - and sched_get_priority_max to obtain the lower and upper bounds of this - range. Since the PAL also uses a range of values (from Idle [-15] to - Time Critical [+15]), we have to do a mapping from a known range to an - unknown (at compilation) range. - We do this by : - -substracting the minimal PAL priority from the desired priority. this - gives a value between 0 and the PAL priority range - -dividing this value by the PAL priority range. this allows us to - express the desired priority as a floating-point value between 0 and 1 - -multiplying this value by the PTHREAD priority range. This gives a - value between 0 and the PTHREAD priority range - -adding the minimal PTHREAD priority range. This will give us a value - between the minimal and maximla pthread priority, which should be - equivalent to the original PAL value. - - example : suppose a pthread range 100 to 200, and a desired priority - of 0 (halfway between PAL minimum and maximum) - 0 - (IDLE [-15]) = 15 - 15 / (TIMECRITICAL[15] - IDLE[-15]) = 0.5 - 0.5 * (pthreadmax[200]-pthreadmin[100]) = 50 - 50 + pthreadmin[100] = 150 -> halfway between pthread min and max - */ - posix_priority = (iNewPriority - THREAD_PRIORITY_IDLE); - posix_priority /= (THREAD_PRIORITY_TIME_CRITICAL - THREAD_PRIORITY_IDLE); - posix_priority *= (max_priority-min_priority); - posix_priority += min_priority; - - schedParam.sched_priority = (int)posix_priority; - - TRACE("PAL priority %d is mapped to pthread priority %d\n", - iNewPriority, schedParam.sched_priority); - - /* Finally, set the new priority into place */ - st = pthread_setschedparam(pTargetThread->GetPThreadSelf(), policy, &schedParam); - if (st != 0) - { -#if SET_SCHEDPARAM_NEEDS_PRIVS - if (EPERM == st) - { - // UNIXTODO: Should log a warning to the event log - TRACE("Caller does not have OS privileges to call pthread_setschedparam\n"); - pTargetThread->m_iThreadPriority = iNewPriority; - goto InternalSetThreadPriorityExit; - } -#endif - - ASSERT("Unable to set thread priority to %d (error %d)\n", (int)posix_priority, st); - palError = ERROR_INTERNAL_ERROR; - goto InternalSetThreadPriorityExit; - } - - pTargetThread->m_iThreadPriority = iNewPriority; - -InternalSetThreadPriorityExit: - - if (NULL != pTargetThread) - { - pTargetThread->Unlock(pThread); - } - - if (NULL != pobjThread) - { - pobjThread->ReleaseReference(pThread); - } - - return palError; -} - -BOOL -CorUnix::GetThreadTimesInternal( - IN HANDLE hThread, - OUT LPFILETIME lpKernelTime, - OUT LPFILETIME lpUserTime) -{ - __int64 calcTime; - BOOL retval = FALSE; - const __int64 SECS_TO_NS = 1000000000; /* 10^9 */ - const __int64 USECS_TO_NS = 1000; /* 10^3 */ - -#if HAVE_MACH_THREADS - thread_basic_info resUsage; - PAL_ERROR palError = NO_ERROR; - CPalThread *pthrCurrent = NULL; - CPalThread *pthrTarget = NULL; - IPalObject *pobjThread = NULL; - mach_msg_type_number_t resUsage_count = THREAD_BASIC_INFO_COUNT; - - pthrCurrent = InternalGetCurrentThread(); - palError = InternalGetThreadDataFromHandle( - pthrCurrent, - hThread, - 0, - &pthrTarget, - &pobjThread - ); - - if (palError != NO_ERROR) - { - ASSERT("Unable to get thread data from handle %p" - "thread\n", hThread); - SetLastError(ERROR_INTERNAL_ERROR); - goto SetTimesToZero; - } - - pthrTarget->Lock(pthrCurrent); - - mach_port_t mhThread; - mhThread = pthread_mach_thread_np(pthrTarget->GetPThreadSelf()); - - kern_return_t status; - status = thread_info( - mhThread, - THREAD_BASIC_INFO, - (thread_info_t)&resUsage, - &resUsage_count); - - pthrTarget->Unlock(pthrCurrent); - - if (status != KERN_SUCCESS) - { - ASSERT("Unable to get resource usage information for the current " - "thread\n"); - SetLastError(ERROR_INTERNAL_ERROR); - goto SetTimesToZero; - } - - /* Get the time of user mode execution, in nanoseconds */ - calcTime = (__int64)resUsage.user_time.seconds * SECS_TO_NS; - calcTime += (__int64)resUsage.user_time.microseconds * USECS_TO_NS; - /* Assign the time into lpUserTime */ - lpUserTime->dwLowDateTime = (DWORD)calcTime; - lpUserTime->dwHighDateTime = (DWORD)(calcTime >> 32); - - /* Get the time of kernel mode execution, in nanoseconds */ - calcTime = (__int64)resUsage.system_time.seconds * SECS_TO_NS; - calcTime += (__int64)resUsage.system_time.microseconds * USECS_TO_NS; - /* Assign the time into lpKernelTime */ - lpKernelTime->dwLowDateTime = (DWORD)calcTime; - lpKernelTime->dwHighDateTime = (DWORD)(calcTime >> 32); - - retval = TRUE; - - goto GetThreadTimesInternalExit; - -#elif defined(__NetBSD__) && !HAVE_PTHREAD_GETCPUCLOCKID /* Currently unimplemented */ - - PAL_ERROR palError; - CPalThread *pThread; - CPalThread *pTargetThread; - IPalObject *pobjThread = NULL; - kvm_t *kd; - int cnt, nlwps; - struct kinfo_lwp *klwp; - int i; - bool found = false; - - pThread = InternalGetCurrentThread(); - - palError = InternalGetThreadDataFromHandle( - pThread, - hThread, - 0, // THREAD_GET_CONTEXT - &pTargetThread, - &pobjThread - ); - if (palError != NO_ERROR) - { - ASSERT("Unable to get thread data from handle %p" - "thread\n", hThread); - SetLastError(ERROR_INTERNAL_ERROR); - goto SetTimesToZero; - } - - kd = kvm_open(NULL, NULL, NULL, KVM_NO_FILES, "kvm_open"); - if (kd == NULL) - { - ASSERT("kvm_open(3) error"); - SetLastError(ERROR_INTERNAL_ERROR); - goto SetTimesToZero; - } - - pTargetThread->Lock(pThread); - - klwp = kvm_getlwps(kd, getpid(), 0, sizeof(struct kinfo_lwp), &nlwps); - if (klwp == NULL || nlwps < 1) - { - kvm_close(kd); - ASSERT("Unable to get clock from %p thread\n", hThread); - SetLastError(ERROR_INTERNAL_ERROR); - pTargetThread->Unlock(pThread); - goto SetTimesToZero; - } - - for (i = 0; i < nlwps; i++) - { - if (klwp[i].l_lid == THREADSilentGetCurrentThreadId()) - { - found = true; - break; - } - } - - if (!found) - { - kvm_close(kd); - ASSERT("Unable to get clock from %p thread\n", hThread); - SetLastError(ERROR_INTERNAL_ERROR); - pTargetThread->Unlock(pThread); - goto SetTimesToZero; - } - - pTargetThread->Unlock(pThread); - - kvm_close(kd); - - calcTime = (__int64) klwp[i].l_rtime_sec * SECS_TO_NS; - calcTime += (__int64) klwp[i].l_rtime_usec * USECS_TO_NS; - lpUserTime->dwLowDateTime = (DWORD)calcTime; - lpUserTime->dwHighDateTime = (DWORD)(calcTime >> 32); - - /* NetBSD as of (7.0) doesn't differentiate used time in user/kernel for lwp */ - lpKernelTime->dwLowDateTime = 0; - lpKernelTime->dwHighDateTime = 0; - - retval = TRUE; - goto GetThreadTimesInternalExit; - -#else //HAVE_MACH_THREADS - - PAL_ERROR palError; - CPalThread *pThread; - CPalThread *pTargetThread; - IPalObject *pobjThread = NULL; - clockid_t cid; - - pThread = InternalGetCurrentThread(); - - palError = InternalGetThreadDataFromHandle( - pThread, - hThread, - 0, // THREAD_GET_CONTEXT - &pTargetThread, - &pobjThread - ); - if (palError != NO_ERROR) - { - ASSERT("Unable to get thread data from handle %p" - "thread\n", hThread); - SetLastError(ERROR_INTERNAL_ERROR); - goto SetTimesToZero; - } - - pTargetThread->Lock(pThread); - -#if HAVE_PTHREAD_GETCPUCLOCKID - if (pthread_getcpuclockid(pTargetThread->GetPThreadSelf(), &cid) != 0) -#endif - { - ASSERT("Unable to get clock from thread\n", hThread); - SetLastError(ERROR_INTERNAL_ERROR); - pTargetThread->Unlock(pThread); - goto SetTimesToZero; - } - - struct timespec ts; - if (clock_gettime(cid, &ts) != 0) - { - ASSERT("clock_gettime() failed; errno is %d (%s)\n", errno, strerror(errno)); - SetLastError(ERROR_INTERNAL_ERROR); - pTargetThread->Unlock(pThread); - goto SetTimesToZero; - } - - pTargetThread->Unlock(pThread); - - /* Calculate time in nanoseconds and assign to user time */ - calcTime = (__int64) ts.tv_sec * SECS_TO_NS; - calcTime += (__int64) ts.tv_nsec; - lpUserTime->dwLowDateTime = (DWORD)calcTime; - lpUserTime->dwHighDateTime = (DWORD)(calcTime >> 32); - - /* Set kernel time to zero, for now */ - lpKernelTime->dwLowDateTime = 0; - lpKernelTime->dwHighDateTime = 0; - - retval = TRUE; - goto GetThreadTimesInternalExit; - -#endif //HAVE_MACH_THREADS - -SetTimesToZero: - - lpUserTime->dwLowDateTime = 0; - lpUserTime->dwHighDateTime = 0; - lpKernelTime->dwLowDateTime = 0; - lpKernelTime->dwHighDateTime = 0; - goto GetThreadTimesInternalExit; - -GetThreadTimesInternalExit: - return retval; -} - -/*++ -Function: - GetThreadTimes - -See MSDN doc. ---*/ -BOOL -PALAPI -GetThreadTimes( - IN HANDLE hThread, - OUT LPFILETIME lpCreationTime, - OUT LPFILETIME lpExitTime, - OUT LPFILETIME lpKernelTime, - OUT LPFILETIME lpUserTime) -{ - PERF_ENTRY(GetThreadTimes); - ENTRY("GetThreadTimes(hThread=%p, lpExitTime=%p, lpKernelTime=%p," - "lpUserTime=%p)\n", - hThread, lpCreationTime, lpExitTime, lpKernelTime, lpUserTime ); - - FILETIME KernelTime, UserTime; - - BOOL retval = GetThreadTimesInternal(hThread, &KernelTime, &UserTime); - - /* Not sure if this still needs to be here */ - /* - TRACE ("thread_info User: %ld sec,%ld microsec. Kernel: %ld sec,%ld" - " microsec\n", - resUsage.user_time.seconds, resUsage.user_time.microseconds, - resUsage.system_time.seconds, resUsage.system_time.microseconds); - */ - - __int64 calcTime; - if (lpUserTime) - { - /* Produce the time in 100s of ns */ - calcTime = ((ULONG64)UserTime.dwHighDateTime << 32); - calcTime += (ULONG64)UserTime.dwLowDateTime; - calcTime /= 100; - lpUserTime->dwLowDateTime = (DWORD)calcTime; - lpUserTime->dwHighDateTime = (DWORD)(calcTime >> 32); - } - if (lpKernelTime) - { - /* Produce the time in 100s of ns */ - calcTime = ((ULONG64)KernelTime.dwHighDateTime << 32); - calcTime += (ULONG64)KernelTime.dwLowDateTime; - calcTime /= 100; - lpKernelTime->dwLowDateTime = (DWORD)calcTime; - lpKernelTime->dwHighDateTime = (DWORD)(calcTime >> 32); - } - //Set CreationTime and Exit time to zero for now - maybe change this later? - if (lpCreationTime) - { - lpCreationTime->dwLowDateTime = 0; - lpCreationTime->dwHighDateTime = 0; - } - - if (lpExitTime) - { - lpExitTime->dwLowDateTime = 0; - lpExitTime->dwHighDateTime = 0; - } - - LOGEXIT("GetThreadTimes returns BOOL %d\n", retval); - PERF_EXIT(GetThreadTimes); - return (retval); -} - - - -void * -CPalThread::ThreadEntry( - void *pvParam - ) -{ - PAL_ERROR palError; - CPalThread *pThread; - PTHREAD_START_ROUTINE pfnStartRoutine; - LPVOID pvPar; - DWORD retValue; - - pThread = reinterpret_cast(pvParam); - - if (NULL == pThread) - { - ASSERT("THREAD pointer is NULL!\n"); - goto fail; - } - -#if !HAVE_MACH_EXCEPTIONS - if (!EnsureSignalAlternateStack()) - { - ASSERT("Cannot allocate alternate stack for SIGSEGV!\n"); - goto fail; - } -#endif // !HAVE_MACH_EXCEPTIONS - -#if defined(FEATURE_PAL_SXS) && defined(_DEBUG) - // We cannot assert yet, as we haven't set in this thread into the TLS, and so __ASSERT_ENTER - // will fail if the assert fails and we'll crash. - //_ASSERT_MSG(pThread->m_fInPal == 1, "New threads should always be in the PAL upon ThreadEntry.\n"); - if (g_Dbg_asserts_enabled && pThread->m_fInPal != 1) - DebugBreak(); -#endif // FEATURE_PAL_SXS && _DEBUG - - pThread->m_threadId = THREADSilentGetCurrentThreadId(); - pThread->m_pthreadSelf = pthread_self(); -#if HAVE_MACH_THREADS - pThread->m_machPortSelf = pthread_mach_thread_np(pThread->m_pthreadSelf); -#endif -#if HAVE_THREAD_SELF - pThread->m_dwLwpId = (DWORD) thread_self(); -#elif HAVE__LWP_SELF - pThread->m_dwLwpId = (DWORD) _lwp_self(); -#else - pThread->m_dwLwpId = 0; -#endif - - palError = pThread->RunPostCreateInitializers(); - if (NO_ERROR != palError) - { - ASSERT("Error %i initializing thread data (post creation)\n", palError); - goto fail; - } - - // Check if the thread should be started suspended. - if (pThread->GetCreateSuspended()) - { - palError = pThread->suspensionInfo.InternalSuspendNewThreadFromData(pThread); - if (NO_ERROR != palError) - { - ASSERT("Error %i attempting to suspend new thread\n", palError); - goto fail; - } - - // - // We need to run any APCs that have already been queued for - // this thread. - // - - (void) g_pSynchronizationManager->DispatchPendingAPCs(pThread); - } - else - { - // - // All startup operations that might have failed have succeeded, - // so thread creation is successful. Let CreateThread return. - // - - pThread->SetStartStatus(TRUE); - } - - pThread->synchronizationInfo.SetThreadState(TS_RUNNING); - - if (UserCreatedThread == pThread->GetThreadType()) - { - /* Inform all loaded modules that a thread has been created */ - /* note : no need to take a critical section to serialize here; the loader - will take the module critical section */ - LOADCallDllMain(DLL_THREAD_ATTACH, NULL); - } - -#ifdef PAL_PERF - PERFAllocThreadInfo(); - PERFEnableThreadProfile(UserCreatedThread != pThread->GetThreadType()); -#endif - - /* call the startup routine */ - pfnStartRoutine = pThread->GetStartAddress(); - pvPar = pThread->GetStartParameter(); - - retValue = (*pfnStartRoutine)(pvPar); - - TRACE("Thread exited (%u)\n", retValue); - ExitThread(retValue); - - /* Note: never get here */ - ASSERT("ExitThread failed!\n"); - for (;;); - -fail: - - // - // Notify InternalCreateThread that a failure occurred - // - - if (NULL != pThread) - { - pThread->synchronizationInfo.SetThreadState(TS_FAILED); - pThread->SetStartStatus(FALSE); - } - - /* do not call ExitThread : we don't want to call DllMain(), and the thread - isn't in a clean state (e.g. lpThread isn't in TLS). the cleanup work - above should release all resources */ - return NULL; -} - /*++ Function: CreateThreadData @@ -1750,9 +281,6 @@ CorUnix::CreateThreadData( pThread->m_threadId = THREADSilentGetCurrentThreadId(); pThread->m_pthreadSelf = pthread_self(); -#if HAVE_MACH_THREADS - pThread->m_machPortSelf = pthread_mach_thread_np(pThread->m_pthreadSelf); -#endif #if HAVE_THREAD_SELF pThread->m_dwLwpId = (DWORD) thread_self(); #elif HAVE__LWP_SELF @@ -1784,316 +312,31 @@ CreateThreadDataExit: /*++ Function: - CreateThreadData + CreateCurrentThreadData Abstract: - Creates the IPalObject for a thread, storing - the reference in the CPalThread - -Parameters: - pThread - the thread data for the creating thread - pNewThread - the thread data for the thread being initialized + This function is called by the InternalGetOrCreateCurrentThread inlined + function to create the thread data when it is null meaning the thread has + never been in this PAL. -Return: - PAL_ERROR +Warning: + If the allocation fails, this function asserts and exits the process. --*/ - -PAL_ERROR -CorUnix::CreateThreadObject( - CPalThread *pThread, - CPalThread *pNewThread, - HANDLE *phThread - ) +extern "C" CPalThread * +CreateCurrentThreadData() { - PAL_ERROR palError = NO_ERROR; - IPalObject *pobjThread = NULL; - IDataLock *pDataLock; - HANDLE hThread = NULL; - CThreadProcessLocalData *pLocalData = NULL; - CObjectAttributes oa; - BOOL fThreadDataStoredInObject = FALSE; - IPalObject *pobjRegisteredThread = NULL; + CPalThread *pThread = NULL; - // - // Create the IPalObject for the thread - // - - palError = g_pObjectManager->AllocateObject( - pThread, - &otThread, - &oa, - &pobjThread - ); - - if (NO_ERROR != palError) - { - goto CreateThreadObjectExit; - } - - // - // Store the CPalThread inside of the IPalObject - // - - palError = pobjThread->GetProcessLocalData( - pThread, - WriteLock, - &pDataLock, - reinterpret_cast(&pLocalData) - ); - - if (NO_ERROR != palError) - { - goto CreateThreadObjectExit; - } - - pLocalData->pThread = pNewThread; - pDataLock->ReleaseLock(pThread, TRUE); - fThreadDataStoredInObject = TRUE; - - // - // Register the IPalObject (obtaining a handle) - // - - palError = g_pObjectManager->RegisterObject( - pThread, - pobjThread, - &aotThread, - 0, //THREAD_ALL_ACCESS, - &hThread, - &pobjRegisteredThread - ); - - // - // pobjThread is invalidated by the call to RegisterObject, so NULL - // it out here to prevent it from being released - // - - pobjThread = NULL; - - if (NO_ERROR != palError) - { - goto CreateThreadObjectExit; - } - - // - // Store the registered object inside of the thread object, - // adding a reference for the thread itself - // - - pNewThread->m_pThreadObject = pobjRegisteredThread; - pNewThread->m_pThreadObject->AddReference(); - - *phThread = hThread; - -CreateThreadObjectExit: - - if (NO_ERROR != palError) - { - if (NULL != hThread) + if (PALIsThreadDataInitialized()) { + PAL_ERROR palError = CreateThreadData(&pThread); + if (NO_ERROR != palError) { - g_pObjectManager->RevokeHandle(pThread, hThread); - } - - if (NULL != pNewThread->m_pThreadObject) - { - // - // Release the new thread's reference on the underlying thread - // object - // - - pNewThread->m_pThreadObject->ReleaseReference(pThread); - } - - if (!fThreadDataStoredInObject) - { - // - // The CPalThread for the new thread was never stored in - // an IPalObject instance, so we need to release the initial - // reference here. (If it has been stored it will get freed in - // the owning object's cleanup routine) - // - - pNewThread->ReleaseThreadReference(); + ASSERT("Unable to allocate pal thread: error %d - aborting\n", palError); + PROCAbort(); } } - if (NULL != pobjThread) - { - pobjThread->ReleaseReference(pThread); - } - - if (NULL != pobjRegisteredThread) - { - pobjRegisteredThread->ReleaseReference(pThread); - } - - return palError; -} - -PAL_ERROR -CorUnix::InternalCreateDummyThread( - CPalThread *pThread, - LPSECURITY_ATTRIBUTES lpThreadAttributes, - CPalThread **ppDummyThread, - HANDLE *phThread - ) -{ - PAL_ERROR palError = NO_ERROR; - CPalThread *pDummyThread = NULL; - IPalObject *pobjThread = NULL; - IPalObject *pobjThreadRegistered = NULL; - IDataLock *pDataLock; - CThreadProcessLocalData *pLocalData; - CObjectAttributes oa(NULL, lpThreadAttributes); - bool fThreadDataStoredInObject = FALSE; - - pDummyThread = AllocTHREAD(); - if (NULL == pDummyThread) - { - palError = ERROR_OUTOFMEMORY; - goto InternalCreateDummyThreadExit; - } - - pDummyThread->m_fIsDummy = TRUE; - - palError = g_pObjectManager->AllocateObject( - pThread, - &otThread, - &oa, - &pobjThread - ); - - if (NO_ERROR != palError) - { - goto InternalCreateDummyThreadExit; - } - - palError = pobjThread->GetProcessLocalData( - pThread, - WriteLock, - &pDataLock, - reinterpret_cast(&pLocalData) - ); - - if (NO_ERROR != palError) - { - goto InternalCreateDummyThreadExit; - } - - pLocalData->pThread = pDummyThread; - pDataLock->ReleaseLock(pThread, TRUE); - fThreadDataStoredInObject = TRUE; - - palError = g_pObjectManager->RegisterObject( - pThread, - pobjThread, - &aotThread, - 0, // THREAD_ALL_ACCESS - phThread, - &pobjThreadRegistered - ); - - // - // pobjThread is invalidated by the above call, so NULL - // it out here - // - - pobjThread = NULL; - - if (NO_ERROR != palError) - { - goto InternalCreateDummyThreadExit; - } - - // - // Note the we do NOT store the registered object for the - // thread w/in pDummyThread. Since this thread is not actually - // executing that reference would never be released (and thus - // the thread object would never be cleaned up...) - // - - *ppDummyThread = pDummyThread; - -InternalCreateDummyThreadExit: - - if (NULL != pobjThreadRegistered) - { - pobjThreadRegistered->ReleaseReference(pThread); - } - - if (NULL != pobjThread) - { - pobjThread->ReleaseReference(pThread); - } - - if (NO_ERROR != palError - && NULL != pDummyThread - && !fThreadDataStoredInObject) - { - pDummyThread->ReleaseThreadReference(); - } - - return palError; -} - -PAL_ERROR -CorUnix::InternalGetThreadDataFromHandle( - CPalThread *pThread, - HANDLE hThread, - DWORD dwRightsRequired, - CPalThread **ppTargetThread, - IPalObject **ppobjThread - ) -{ - PAL_ERROR palError = NO_ERROR; - IPalObject *pobj; - IDataLock *pLock; - CThreadProcessLocalData *pData; - - *ppobjThread = NULL; - - if (hPseudoCurrentThread == hThread) - { - *ppTargetThread = pThread; - } - else - { - palError = g_pObjectManager->ReferenceObjectByHandle( - pThread, - hThread, - &aotThread, - dwRightsRequired, - &pobj - ); - - if (NO_ERROR == palError) - { - palError = pobj->GetProcessLocalData( - pThread, - ReadLock, - &pLock, - reinterpret_cast(&pData) - ); - - if (NO_ERROR == palError) - { - *ppTargetThread = pData->pThread; - pLock->ReleaseLock(pThread, FALSE); - - // - // Transfer object reference to out param - // - - *ppobjThread = pobj; - } - else - { - pobj->ReleaseReference(pThread); - } - } - } - - return palError; + return pThread; } PAL_ERROR @@ -2109,57 +352,11 @@ CPalThread::RunPreCreateInitializers( // InternalInitializeCriticalSection(&m_csLock); - m_fLockInitialized = TRUE; - - iError = pthread_mutex_init(&m_startMutex, NULL); - if (0 != iError) - { - goto RunPreCreateInitializersExit; - } - - iError = pthread_cond_init(&m_startCond, NULL); - if (0 != iError) - { - pthread_mutex_destroy(&m_startMutex); - goto RunPreCreateInitializersExit; - } - - m_fStartItemsInitialized = TRUE; // // Call the pre-create initializers for embedded classes // - palError = synchronizationInfo.InitializePreCreate(); - if (NO_ERROR != palError) - { - goto RunPreCreateInitializersExit; - } - - palError = suspensionInfo.InitializePreCreate(); - if (NO_ERROR != palError) - { - goto RunPreCreateInitializersExit; - } - - palError = sehInfo.InitializePreCreate(); - if (NO_ERROR != palError) - { - goto RunPreCreateInitializersExit; - } - - palError = tlsInfo.InitializePreCreate(); - if (NO_ERROR != palError) - { - goto RunPreCreateInitializersExit; - } - - palError = apcInfo.InitializePreCreate(); - if (NO_ERROR != palError) - { - goto RunPreCreateInitializersExit; - } - palError = crtInfo.InitializePreCreate(); if (NO_ERROR != palError) { @@ -2187,17 +384,6 @@ CPalThread::~CPalThread() { InternalDeleteCriticalSection(&m_csLock); } - - if (m_fStartItemsInitialized) - { - int iError; - - iError = pthread_cond_destroy(&m_startCond); - _ASSERTE(0 == iError); - - iError = pthread_mutex_destroy(&m_startMutex); - _ASSERTE(0 == iError); - } } void @@ -2233,557 +419,50 @@ CPalThread::RunPostCreateInitializers( // Call the post-create initializers for embedded classes // - palError = synchronizationInfo.InitializePostCreate(this, m_threadId, m_dwLwpId); - if (NO_ERROR != palError) - { - goto RunPostCreateInitializersExit; - } - - palError = suspensionInfo.InitializePostCreate(this, m_threadId, m_dwLwpId); - if (NO_ERROR != palError) - { - goto RunPostCreateInitializersExit; - } - - palError = sehInfo.InitializePostCreate(this, m_threadId, m_dwLwpId); - if (NO_ERROR != palError) - { - goto RunPostCreateInitializersExit; - } - - palError = tlsInfo.InitializePostCreate(this, m_threadId, m_dwLwpId); - if (NO_ERROR != palError) - { - goto RunPostCreateInitializersExit; - } - - palError = apcInfo.InitializePostCreate(this, m_threadId, m_dwLwpId); - if (NO_ERROR != palError) - { - goto RunPostCreateInitializersExit; - } - palError = crtInfo.InitializePostCreate(this, m_threadId, m_dwLwpId); if (NO_ERROR != palError) { goto RunPostCreateInitializersExit; } -#ifdef FEATURE_PAL_SXS - _ASSERTE(m_fInPal); - palError = SEHEnable(this); - if (NO_ERROR != palError) - { - goto RunPostCreateInitializersExit; - } -#endif // FEATURE_PAL_SXS - RunPostCreateInitializersExit: return palError; } -void -CPalThread::SetStartStatus( - bool fStartSucceeded - ) +/* Basic spinlock implementation */ +void SPINLOCKAcquire (LONG * lock, unsigned int flags) { - int iError; + size_t loop_seed = 1, loop_count = 0; -#if _DEBUG - if (m_fStartStatusSet) + if (flags & SYNCSPINLOCK_F_ASYMMETRIC) { - ASSERT("Multiple calls to CPalThread::SetStartStatus\n"); + loop_seed = ((size_t)pthread_self() % 10) + 1; } -#endif - - // - // This routine may get called from CPalThread::ThreadEntry - // - // If we've reached this point there are no further thread - // suspensions that happen at creation time, so reset - // m_bCreateSuspended - // - - m_bCreateSuspended = FALSE; - - iError = pthread_mutex_lock(&m_startMutex); - if (0 != iError) + while (InterlockedCompareExchange(lock, 1, 0)) { - ASSERT("pthread primitive failure\n"); - // bugcheck? - } - - m_fStartStatus = fStartSucceeded; - m_fStartStatusSet = TRUE; - - iError = pthread_cond_signal(&m_startCond); - if (0 != iError) - { - ASSERT("pthread primitive failure\n"); - // bugcheck? - } - - iError = pthread_mutex_unlock(&m_startMutex); - if (0 != iError) - { - ASSERT("pthread primitive failure\n"); - // bugcheck? - } -} - -bool -CPalThread::WaitForStartStatus( - void - ) -{ - int iError; - - iError = pthread_mutex_lock(&m_startMutex); - if (0 != iError) - { - ASSERT("pthread primitive failure\n"); - // bugcheck? - } - - while (!m_fStartStatusSet) - { - iError = pthread_cond_wait(&m_startCond, &m_startMutex); - if (0 != iError) + if (!(flags & SYNCSPINLOCK_F_ASYMMETRIC) || (++loop_count % loop_seed)) { - ASSERT("pthread primitive failure\n"); - // bugcheck? +#if PAL_IGNORE_NORMAL_THREAD_PRIORITY + struct timespec tsSleepTime; + tsSleepTime.tv_sec = 0; + tsSleepTime.tv_nsec = 1; + nanosleep(&tsSleepTime, NULL); +#else + sched_yield(); +#endif } } - - iError = pthread_mutex_unlock(&m_startMutex); - if (0 != iError) - { - ASSERT("pthread primitive failure\n"); - // bugcheck? - } - - return m_fStartStatus; -} - -/* IncrementEndingThreadCount and DecrementEndingThreadCount are used -to control a global counter that indicates if any threads are about to die. -Once a thread's state is set to TS_DONE, it cannot be suspended. However, -the dying thread can still access PAL resources, which is dangerous if the -thread dies during PAL cleanup. To avoid this, the shutdown thread calls -WaitForEndingThreads after suspending all other threads. WaitForEndingThreads -uses a condition variable along with the global counter to wait for remaining -PAL threads to die before proceeding with cleanup. As threads die, they -decrement the counter and signal the condition variable. */ - -void -IncrementEndingThreadCount( - void - ) -{ - int iError; - - iError = pthread_mutex_lock(&ptmEndThread); - _ASSERT_MSG(iError == 0, "pthread_mutex_lock returned %d\n", iError); - - iEndingThreads++; - - iError = pthread_mutex_unlock(&ptmEndThread); - _ASSERT_MSG(iError == 0, "pthread_mutex_unlock returned %d\n", iError); -} - -void -DecrementEndingThreadCount( - void - ) -{ - int iError; - - iError = pthread_mutex_lock(&ptmEndThread); - _ASSERT_MSG(iError == 0, "pthread_mutex_lock returned %d\n", iError); - - iEndingThreads--; - _ASSERTE(iEndingThreads >= 0); - - if (iEndingThreads == 0) - { - iError = pthread_cond_signal(&ptcEndThread); - _ASSERT_MSG(iError == 0, "pthread_cond_signal returned %d\n", iError); - } - - iError = pthread_mutex_unlock(&ptmEndThread); - _ASSERT_MSG(iError == 0, "pthread_mutex_unlock returned %d\n", iError); -} - -void -WaitForEndingThreads( - void - ) -{ - int iError; - - iError = pthread_mutex_lock(&ptmEndThread); - _ASSERT_MSG(iError == 0, "pthread_mutex_lock returned %d\n", iError); - - while (iEndingThreads > 0) - { - iError = pthread_cond_wait(&ptcEndThread, &ptmEndThread); - _ASSERT_MSG(iError == 0, "pthread_cond_wait returned %d\n", iError); - } - - iError = pthread_mutex_unlock(&ptmEndThread); - _ASSERT_MSG(iError == 0, "pthread_mutex_unlock returned %d\n", iError); -} - -PAL_ERROR -CorUnix::InitializeEndingThreadsData( - void - ) -{ - PAL_ERROR palError = ERROR_INTERNAL_ERROR; - int iError; - - iError = pthread_mutex_init(&ptmEndThread, NULL); - if (0 != iError) - { - goto InitializeEndingThreadsDataExit; - } - - iError = pthread_cond_init(&ptcEndThread, NULL); - if (0 != iError) - { - // - // Don't bother checking the return value of pthread_mutex_destroy - // since PAL initialization will now fail. - // - - pthread_mutex_destroy(&ptmEndThread); - goto InitializeEndingThreadsDataExit; - } - - palError = NO_ERROR; - -InitializeEndingThreadsDataExit: - - return palError; -} - -void -ThreadCleanupRoutine( - CPalThread *pThread, - IPalObject *pObjectToCleanup, - bool fShutdown, - bool fCleanupSharedState - ) -{ - CThreadProcessLocalData *pThreadData = NULL; - CPalThread *pThreadToCleanup = NULL; - IDataLock *pDataLock = NULL; - PAL_ERROR palError = NO_ERROR; - - // - // Free the CPalThread data for the passed in thread - // - - palError = pObjectToCleanup->GetProcessLocalData( - pThread, - WriteLock, - &pDataLock, - reinterpret_cast(&pThreadData) - ); - - if (NO_ERROR == palError) - { - // - // Note that we may be cleaning up the data for the calling - // thread (i.e., pThread == pThreadToCleanup), so the release - // of the thread reference needs to be the last thing that - // we do (though in that case it's very likely that the person - // calling us will be holding an extra reference to allow - // for the thread data to be available while the rest of the - // object cleanup takes place). - // - - pThreadToCleanup = pThreadData->pThread; - pThreadData->pThread = NULL; - pDataLock->ReleaseLock(pThread, TRUE); - pThreadToCleanup->ReleaseThreadReference(); - } - else - { - ASSERT("Unable to obtain thread data"); - } } -PAL_ERROR -ThreadInitializationRoutine( - CPalThread *pThread, - CObjectType *pObjectType, - void *pImmutableData, - void *pSharedData, - void *pProcessLocalData - ) +void SPINLOCKRelease (LONG * lock) { - return NO_ERROR; + *lock = 0; } -// Get base address of the current thread's stack -void * -CPalThread::GetStackBase() +DWORD SPINLOCKTryAcquire (LONG * lock) { - void* stackBase; -#ifdef _TARGET_MAC64 - // This is a Mac specific method - stackBase = pthread_get_stackaddr_np(pthread_self()); -#else - pthread_attr_t attr; - void* stackAddr; - size_t stackSize; - int status; - - pthread_t thread = pthread_self(); - - status = pthread_attr_init(&attr); - _ASSERT_MSG(status == 0, "pthread_attr_init call failed"); - -#if HAVE_PTHREAD_ATTR_GET_NP - status = pthread_attr_get_np(thread, &attr); -#elif HAVE_PTHREAD_GETATTR_NP - status = pthread_getattr_np(thread, &attr); -#else -#error Dont know how to get thread attributes on this platform! -#endif - _ASSERT_MSG(status == 0, "pthread_getattr_np call failed"); - - status = pthread_attr_getstack(&attr, &stackAddr, &stackSize); - _ASSERT_MSG(status == 0, "pthread_attr_getstack call failed"); - - status = pthread_attr_destroy(&attr); - _ASSERT_MSG(status == 0, "pthread_attr_destroy call failed"); - - stackBase = (void*)((size_t)stackAddr + stackSize); -#endif - - return stackBase; + return InterlockedCompareExchange(lock, 1, 0); + // only returns 0 or 1. } - -// Get limit address of the current thread's stack -void * -CPalThread::GetStackLimit() -{ - void* stackLimit; -#ifdef _TARGET_MAC64 - // This is a Mac specific method - stackLimit = ((BYTE *)pthread_get_stackaddr_np(pthread_self()) - - pthread_get_stacksize_np(pthread_self())); -#else - pthread_attr_t attr; - size_t stackSize; - int status; - - pthread_t thread = pthread_self(); - - status = pthread_attr_init(&attr); - _ASSERT_MSG(status == 0, "pthread_attr_init call failed"); - -#if HAVE_PTHREAD_ATTR_GET_NP - status = pthread_attr_get_np(thread, &attr); -#elif HAVE_PTHREAD_GETATTR_NP - status = pthread_getattr_np(thread, &attr); -#else -#error Dont know how to get thread attributes on this platform! -#endif - _ASSERT_MSG(status == 0, "pthread_getattr_np call failed"); - - status = pthread_attr_getstack(&attr, &stackLimit, &stackSize); - _ASSERT_MSG(status == 0, "pthread_attr_getstack call failed"); - - status = pthread_attr_destroy(&attr); - _ASSERT_MSG(status == 0, "pthread_attr_destroy call failed"); -#endif - - return stackLimit; -} - -// Get cached base address of this thread's stack -// Can be called only for the current thread. -void * -CPalThread::GetCachedStackBase() -{ - _ASSERT_MSG(this == InternalGetCurrentThread(), "CPalThread::GetStackBase called from foreign thread"); - - if (m_stackBase == NULL) - { - m_stackBase = GetStackBase(); - } - - return m_stackBase; -} - -// Get cached limit address of this thread's stack. -// Can be called only for the current thread. -void * -CPalThread::GetCachedStackLimit() -{ - _ASSERT_MSG(this == InternalGetCurrentThread(), "CPalThread::GetCachedStackLimit called from foreign thread"); - - if (m_stackLimit == NULL) - { - m_stackLimit = GetStackLimit(); - } - - return m_stackLimit; -} - -void * -PALAPI -PAL_GetStackBase() -{ - CPalThread* thread = InternalGetCurrentThread(); - return thread->GetCachedStackBase(); -} - -void * -PALAPI -PAL_GetStackLimit() -{ - CPalThread* thread = InternalGetCurrentThread(); - return thread->GetCachedStackLimit(); -} - -PAL_ERROR InjectActivationInternal(CorUnix::CPalThread* pThread); - -/*++ -Function: - PAL_SetActivationFunction - - Register an activation function that gets called when an activation is injected - into a thread. - -Parameters: - pActivationFunction - activation function - pSafeActivationCheckFunction - function to check if an activation can be safely - injected at a specified context -Return value: - None ---*/ -PALIMPORT -VOID -PALAPI -PAL_SetActivationFunction( - IN PAL_ActivationFunction pActivationFunction, - IN PAL_SafeActivationCheckFunction pSafeActivationCheckFunction) -{ - g_activationFunction = pActivationFunction; - g_safeActivationCheckFunction = pSafeActivationCheckFunction; -} - -/*++ -Function: -PAL_InjectActivation - -Interrupt the specified thread and have it call an activation function registered -using the PAL_SetActivationFunction - -Parameters: -hThread - handle of the target thread - -Return: -TRUE if it succeeded, FALSE otherwise. ---*/ -BOOL -PALAPI -PAL_InjectActivation( - IN HANDLE hThread) -{ - PERF_ENTRY(PAL_InjectActivation); - ENTRY("PAL_InjectActivation(hThread=%p)\n", hThread); - - CPalThread *pCurrentThread; - CPalThread *pTargetThread; - IPalObject *pobjThread = NULL; - - pCurrentThread = InternalGetCurrentThread(); - - PAL_ERROR palError = InternalGetThreadDataFromHandle( - pCurrentThread, - hThread, - 0, - &pTargetThread, - &pobjThread - ); - - if (palError == NO_ERROR) - { - palError = InjectActivationInternal(pTargetThread); - } - - if (palError == NO_ERROR) - { - pCurrentThread->SetLastError(palError); - } - - if (pobjThread != NULL) - { - pobjThread->ReleaseReference(pCurrentThread); - } - - BOOL success = (palError == NO_ERROR); - LOGEXIT("PAL_InjectActivation returns:d\n", success); - PERF_EXIT(PAL_InjectActivation); - - return success; -} - -#if HAVE_MACH_EXCEPTIONS - -extern mach_port_t s_ExceptionPort; - -// Get handler details for a given type of exception. If successful the structure pointed at by pHandler is -// filled in and true is returned. Otherwise false is returned. -bool CorUnix::CThreadMachExceptionHandlers::GetHandler(exception_type_t eException, CorUnix::MachExceptionHandler *pHandler) -{ - exception_mask_t bmExceptionMask = (1 << eException); - int idxHandler = GetIndexOfHandler(bmExceptionMask); - - // Did we find a handler? - if (idxHandler == -1) - return false; - - // Found one, so initialize the output structure with the details. - pHandler->m_mask = m_masks[idxHandler]; - pHandler->m_handler = m_handlers[idxHandler]; - pHandler->m_behavior = m_behaviors[idxHandler]; - pHandler->m_flavor = m_flavors[idxHandler]; - - return true; -} - -// Look for a handler for the given exception within the given handler node. Return its index if successful or -// -1 otherwise. -int CorUnix::CThreadMachExceptionHandlers::GetIndexOfHandler(exception_mask_t bmExceptionMask) -{ - // Check all handler entries for one handling the exception mask. - for (mach_msg_type_number_t i = 0; i < m_nPorts; i++) - { - // Entry covers this exception type and the handler isn't null - if (m_masks[i] & bmExceptionMask && m_handlers[i] != MACH_PORT_NULL) - { - _ASSERTE(m_handlers[i] != s_ExceptionPort); - - // One more check; has the target handler port become dead? - mach_port_type_t ePortType; - if (mach_port_type(mach_task_self(), m_handlers[i], &ePortType) == KERN_SUCCESS && !(ePortType & MACH_PORT_TYPE_DEAD_NAME)) - { - // Got a matching entry. - return i; - } - } - } - - // Didn't find a handler. - return -1; -} - -#endif // HAVE_MACH_EXCEPTIONS diff --git a/src/pal/src/thread/threadsusp.cpp b/src/pal/src/thread/threadsusp.cpp deleted file mode 100644 index f8a435c02..000000000 --- a/src/pal/src/thread/threadsusp.cpp +++ /dev/null @@ -1,1046 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - - -/*++ - - - -Module Name: - - threadsusp.cpp - -Abstract: - - Implementation of functions related to threads. - -Revision History: - - - ---*/ - -#include "pal/corunix.hpp" -#include "pal/thread.hpp" -#include "pal/mutex.hpp" -#include "pal/seh.hpp" -#include "pal/init.h" -#include "pal/dbgmsg.h" - -#include -#include -#include -#include -#include -#include -#include - -using namespace CorUnix; - -/* ------------------- Definitions ------------------------------*/ -SET_DEFAULT_DEBUG_CHANNEL(THREAD); - -/* This code is written to the blocking pipe of a thread that was created - in suspended state in order to resume it. */ -CONST BYTE WAKEUPCODE=0x2A; - -// #define USE_GLOBAL_LOCK_FOR_SUSPENSION // Uncomment this define to use the global suspension lock. -/* The global suspension lock can be used in place of each thread having its own -suspension mutex or spinlock. The downside is that it restricts us to only -performing one suspension or resumption in the PAL at a time. */ -#ifdef USE_GLOBAL_LOCK_FOR_SUSPENSION -static LONG g_ssSuspensionLock = 0; -#endif - -/*++ -Function: - InternalSuspendNewThreadFromData - - On platforms where we use pipes for starting threads suspended, this - function sets the blocking pipe for the thread and blocks until the - wakeup code is written to the pipe by ResumeThread. - ---*/ -PAL_ERROR -CThreadSuspensionInfo::InternalSuspendNewThreadFromData( - CPalThread *pThread - ) -{ - PAL_ERROR palError = NO_ERROR; - - AcquireSuspensionLock(pThread); - pThread->suspensionInfo.SetSelfSusp(TRUE); - ReleaseSuspensionLock(pThread); - - int pipe_descs[2]; - int pipeRv = -#if HAVE_PIPE2 - pipe2(pipe_descs, O_CLOEXEC); -#else - pipe(pipe_descs); -#endif // HAVE_PIPE2 - if (pipeRv == -1) - { - ERROR("pipe() failed! error is %d (%s)\n", errno, strerror(errno)); - return ERROR_NOT_ENOUGH_MEMORY; - } -#if !HAVE_PIPE2 - fcntl(pipe_descs[0], F_SETFD, FD_CLOEXEC); // make pipe non-inheritable, if possible - fcntl(pipe_descs[1], F_SETFD, FD_CLOEXEC); -#endif // !HAVE_PIPE2 - - // [0] is the read end of the pipe, and [1] is the write end. - pThread->suspensionInfo.SetBlockingPipe(pipe_descs[1]); - pThread->SetStartStatus(TRUE); - - BYTE resume_code = 0; - ssize_t read_ret; - - // Block until ResumeThread writes something to the pipe - while ((read_ret = read(pipe_descs[0], &resume_code, sizeof(resume_code))) != sizeof(resume_code)) - { - if (read_ret != -1 || EINTR != errno) - { - // read might return 0 (with EAGAIN) if the other end of the pipe gets closed - palError = ERROR_INTERNAL_ERROR; - break; - } - } - - if (palError == NO_ERROR && resume_code != WAKEUPCODE) - { - // If we did read successfully but the byte didn't match WAKEUPCODE, we treat it as a failure. - palError = ERROR_INTERNAL_ERROR; - } - - if (palError == NO_ERROR) - { - AcquireSuspensionLock(pThread); - pThread->suspensionInfo.SetSelfSusp(FALSE); - ReleaseSuspensionLock(pThread); - } - - // Close the pipes regardless of whether we were successful. - close(pipe_descs[0]); - close(pipe_descs[1]); - - return palError; -} - -/*++ -Function: - - ResumeThread - -See MSDN doc. ---*/ -DWORD -PALAPI -ResumeThread( - IN HANDLE hThread - ) -{ - PAL_ERROR palError; - CPalThread *pthrResumer; - DWORD dwSuspendCount = (DWORD)-1; - - PERF_ENTRY(ResumeThread); - ENTRY("ResumeThread(hThread=%p)\n", hThread); - - pthrResumer = InternalGetCurrentThread(); - palError = InternalResumeThread( - pthrResumer, - hThread, - &dwSuspendCount - ); - - if (NO_ERROR != palError) - { - pthrResumer->SetLastError(palError); - dwSuspendCount = (DWORD) -1; - } - else - { - _ASSERT_MSG(dwSuspendCount != static_cast(-1), "InternalResumeThread returned success but dwSuspendCount did not change.\n"); - } - - LOGEXIT("ResumeThread returns DWORD %u\n", dwSuspendCount); - PERF_EXIT(ResumeThread); - return dwSuspendCount; -} - -/*++ -Function: - InternalResumeThread - -InternalResumeThread converts the handle of the target thread to a -CPalThread, and passes both the resumer and target thread references -to InternalResumeThreadFromData. A reference to the suspend count from -the resumption attempt is passed back to the caller of this function. ---*/ -PAL_ERROR -CorUnix::InternalResumeThread( - CPalThread *pthrResumer, - HANDLE hTargetThread, - DWORD *pdwSuspendCount - ) -{ - PAL_ERROR palError = NO_ERROR; - CPalThread *pthrTarget = NULL; - IPalObject *pobjThread = NULL; - - palError = InternalGetThreadDataFromHandle( - pthrResumer, - hTargetThread, - 0, // THREAD_SUSPEND_RESUME - &pthrTarget, - &pobjThread - ); - - if (NO_ERROR == palError) - { - palError = pthrResumer->suspensionInfo.InternalResumeThreadFromData( - pthrResumer, - pthrTarget, - pdwSuspendCount - ); - } - - if (NULL != pobjThread) - { - pobjThread->ReleaseReference(pthrResumer); - } - - return palError; -} - -/*++ -Function: - InternalResumeThreadFromData - -InternalResumeThreadFromData resumes the target thread. First, the suspension -mutexes of the threads are acquired. Next, there's a check to ensure that the -target thread was actually suspended. Finally, the resume attempt is made -and the suspension mutexes are released. The suspend count of the -target thread is passed back to the caller of this function. - -Note that ReleaseSuspensionLock(s) is called before hitting ASSERTs in error -paths. Currently, this seems unnecessary since asserting within -InternalResumeThreadFromData will not cause cleanup to occur. However, -this may change since it would be preferable to perform cleanup. Thus, calls -to release suspension locks remain in the error paths. ---*/ -PAL_ERROR -CThreadSuspensionInfo::InternalResumeThreadFromData( - CPalThread *pthrResumer, - CPalThread *pthrTarget, - DWORD *pdwSuspendCount - ) -{ - PAL_ERROR palError = NO_ERROR; - - int nWrittenBytes = -1; - - if (SignalHandlerThread == pthrTarget->GetThreadType()) - { - ASSERT("Attempting to resume the signal handling thread, which can never be suspended.\n"); - palError = ERROR_INVALID_HANDLE; - goto InternalResumeThreadFromDataExit; - } - - // Acquire suspension mutex - AcquireSuspensionLocks(pthrResumer, pthrTarget); - - // Check target thread's state to ensure it hasn't died. - // Setting a thread's state to TS_DONE is protected by the - // target's suspension mutex. - if (pthrTarget->synchronizationInfo.GetThreadState() == TS_DONE) - { - palError = ERROR_INVALID_HANDLE; - ReleaseSuspensionLocks(pthrResumer, pthrTarget); - goto InternalResumeThreadFromDataExit; - } - - // If this is a dummy thread, then it represents a process that was created with CREATE_SUSPENDED - // and it should have a blocking pipe set. If GetBlockingPipe returns -1 for a dummy thread, then - // something is wrong - either CREATE_SUSPENDED wasn't used or the process was already resumed. - if (pthrTarget->IsDummy() && -1 == pthrTarget->suspensionInfo.GetBlockingPipe()) - { - palError = ERROR_INVALID_HANDLE; - ERROR("Tried to wake up dummy thread without a blocking pipe.\n"); - ReleaseSuspensionLocks(pthrResumer, pthrTarget); - goto InternalResumeThreadFromDataExit; - } - - // If there is a blocking pipe on this thread, resume it by writing the wake up code to that pipe. - if (-1 != pthrTarget->suspensionInfo.GetBlockingPipe()) - { - // If write() is interrupted by a signal before writing data, - // it returns -1 and sets errno to EINTR. In this case, we - // attempt the write() again. - writeAgain: - nWrittenBytes = write(pthrTarget->suspensionInfo.GetBlockingPipe(), &WAKEUPCODE, sizeof(WAKEUPCODE)); - - // The size of WAKEUPCODE is 1 byte. If write returns 0, we'll treat it as an error. - if (sizeof(WAKEUPCODE) != nWrittenBytes) - { - // If we are here during process creation, this is most likely caused by the target - // process dying before reaching this point and thus breaking the pipe. - if (nWrittenBytes == -1 && EPIPE == errno) - { - palError = ERROR_INVALID_HANDLE; - ReleaseSuspensionLocks(pthrResumer, pthrTarget); - ERROR("Write failed with EPIPE\n"); - goto InternalResumeThreadFromDataExit; - } - else if (nWrittenBytes == 0 || (nWrittenBytes == -1 && EINTR == errno)) - { - TRACE("write() failed with EINTR; re-attempting write\n"); - goto writeAgain; - } - else - { - // Some other error occurred; need to release suspension mutexes before leaving ResumeThread. - palError = ERROR_INTERNAL_ERROR; - ReleaseSuspensionLocks(pthrResumer, pthrTarget); - ASSERT("Write() failed; error is %d (%s)\n", errno, strerror(errno)); - goto InternalResumeThreadFromDataExit; - } - } - - // Reset blocking pipe to -1 since we're done using it. - pthrTarget->suspensionInfo.SetBlockingPipe(-1); - - ReleaseSuspensionLocks(pthrResumer, pthrTarget); - goto InternalResumeThreadFromDataExit; - } - else - { - *pdwSuspendCount = 0; - palError = ERROR_BAD_COMMAND; - } - -InternalResumeThreadFromDataExit: - - if (NO_ERROR == palError) - { - *pdwSuspendCount = 1; - } - - return palError; -} - -/*++ -Function: - TryAcquireSuspensionLock - -TryAcquireSuspensionLock is a utility function that tries to acquire a thread's -suspension mutex or spinlock. If it succeeds, the function returns TRUE. -Otherwise, it returns FALSE. This function is used in AcquireSuspensionLocks. -Note that the global lock cannot be acquired in this function since it makes -no sense to do so. A thread holding the global lock is the only thread that -can perform suspend or resume operations so it doesn't need to acquire -a second lock. ---*/ -BOOL -CThreadSuspensionInfo::TryAcquireSuspensionLock( - CPalThread* pthrTarget - ) -{ - int iPthreadRet = 0; -#if DEADLOCK_WHEN_THREAD_IS_SUSPENDED_WHILE_BLOCKED_ON_MUTEX -{ - iPthreadRet = SPINLOCKTryAcquire(pthrTarget->suspensionInfo.GetSuspensionSpinlock()); -} -#else // DEADLOCK_WHEN_THREAD_IS_SUSPENDED_WHILE_BLOCKED_ON_MUTEX -{ - iPthreadRet = pthread_mutex_trylock(pthrTarget->suspensionInfo.GetSuspensionMutex()); - _ASSERT_MSG(iPthreadRet == 0 || iPthreadRet == EBUSY, "pthread_mutex_trylock returned %d\n", iPthreadRet); -} -#endif // DEADLOCK_WHEN_THREAD_IS_SUSPENDED_WHILE_BLOCKED_ON_MUTEX - - // If iPthreadRet is 0, lock acquisition was successful. Otherwise, it failed. - return (iPthreadRet == 0); -} - -/*++ -Function: - AcquireSuspensionLock - -AcquireSuspensionLock acquires a thread's suspension mutex or spinlock. -If USE_GLOBAL_LOCK_FOR_SUSPENSION is defined, it will acquire the global lock. -A thread in this function blocks until it acquires -its lock, unlike in TryAcquireSuspensionLock. ---*/ -void -CThreadSuspensionInfo::AcquireSuspensionLock( - CPalThread* pthrCurrent - ) -{ -#ifdef USE_GLOBAL_LOCK_FOR_SUSPENSION -{ - SPINLOCKAcquire(&g_ssSuspensionLock, 0); -} -#else // USE_GLOBAL_LOCK_FOR_SUSPENSION -{ - #if DEADLOCK_WHEN_THREAD_IS_SUSPENDED_WHILE_BLOCKED_ON_MUTEX - { - SPINLOCKAcquire(&pthrCurrent->suspensionInfo.m_nSpinlock, 0); - } - #else // DEADLOCK_WHEN_THREAD_IS_SUSPENDED_WHILE_BLOCKED_ON_MUTEX - { - INDEBUG(int iPthreadError = ) - pthread_mutex_lock(&pthrCurrent->suspensionInfo.m_ptmSuspmutex); - _ASSERT_MSG(iPthreadError == 0, "pthread_mutex_lock returned %d\n", iPthreadError); - } - #endif // DEADLOCK_WHEN_THREAD_IS_SUSPENDED_WHILE_BLOCKED_ON_MUTEX -} -#endif // USE_GLOBAL_LOCK_FOR_SUSPENSION -} - -/*++ -Function: - ReleaseSuspensionLock - -ReleaseSuspensionLock is a function that releases a thread's suspension mutex -or spinlock. If USE_GLOBAL_LOCK_FOR_SUSPENSION is defined, -it will release the global lock. ---*/ -void -CThreadSuspensionInfo::ReleaseSuspensionLock( - CPalThread* pthrCurrent - ) -{ -#ifdef USE_GLOBAL_LOCK_FOR_SUSPENSION -{ - SPINLOCKRelease(&g_ssSuspensionLock); -} -#else // USE_GLOBAL_LOCK_FOR_SUSPENSION -{ - #if DEADLOCK_WHEN_THREAD_IS_SUSPENDED_WHILE_BLOCKED_ON_MUTEX - { - SPINLOCKRelease(&pthrCurrent->suspensionInfo.m_nSpinlock); - } - #else // DEADLOCK_WHEN_THREAD_IS_SUSPENDED_WHILE_BLOCKED_ON_MUTEX - { - INDEBUG(int iPthreadError = ) - pthread_mutex_unlock(&pthrCurrent->suspensionInfo.m_ptmSuspmutex); - _ASSERT_MSG(iPthreadError == 0, "pthread_mutex_unlock returned %d\n", iPthreadError); - } - #endif // DEADLOCK_WHEN_THREAD_IS_SUSPENDED_WHILE_BLOCKED_ON_MUTEX -} -#endif // USE_GLOBAL_LOCK_FOR_SUSPENSION -} - -/*++ -Function: - AcquireSuspensionLocks - -AcquireSuspensionLocks is used to acquire the suspension locks -of a suspender (or resumer) and target thread. The thread will -perform a blocking call to acquire its own suspension lock -and will then try to acquire the target thread's lock without blocking. -If it fails to acquire the target's lock, it releases its own lock -and the thread will try to acquire both locks again. The key -is that both locks must be acquired together. - -Originally, only blocking calls were used to acquire the suspender -and the target lock. However, this was problematic since a thread -could acquire its own lock and then block on acquiring the target -lock. In the meantime, the target could have already acquired its -own lock and be attempting to suspend the suspender thread. This -clearly causes deadlock. A second approach used locking hierarchies, -where locks were acquired use thread id ordering. This was better but -suffered from the scenario where thread A acquires thread B's -suspension mutex first. In the meantime, thread C acquires thread A's -suspension mutex and its own. Thus, thread A is suspended while -holding thread B's mutex. This is problematic if thread C now wants -to suspend thread B. The issue here is that a thread can be -suspended while holding someone else's mutex but not holding its own. -In the end, the correct approach is to always acquire your suspension -mutex first. This prevents you from being suspended while holding the -target's mutex. Then, attempt to acquire the target's mutex. If the mutex -cannot be acquired, release your own and try again. This all or nothing -approach is the safest and avoids nasty race conditions. - -If USE_GLOBAL_LOCK_FOR_SUSPENSION is defined, the calling thread -will acquire the global lock when possible. ---*/ -VOID -CThreadSuspensionInfo::AcquireSuspensionLocks( - CPalThread *pthrSuspender, - CPalThread *pthrTarget - ) -{ - BOOL fReacquire = FALSE; - -#ifdef USE_GLOBAL_LOCK_FOR_SUSPENSION - AcquireSuspensionLock(pthrSuspender); -#else // USE_GLOBAL_LOCK_FOR_SUSPENSION - do - { - fReacquire = FALSE; - AcquireSuspensionLock(pthrSuspender); - if (!TryAcquireSuspensionLock(pthrTarget)) - { - // pthread_mutex_trylock returned EBUSY so release the first lock and try again. - ReleaseSuspensionLock(pthrSuspender); - fReacquire = TRUE; - sched_yield(); - } - } while (fReacquire); -#endif // USE_GLOBAL_LOCK_FOR_SUSPENSION - - // Whenever the native implementation for the wait subsystem's thread - // blocking requires a lock as protection (as pthread conditions do with - // the associated mutex), we need to grab that lock to prevent the target - // thread from being suspended while holding the lock. - // Failing to do so can lead to a multiple threads deadlocking such as the - // one described in VSW 363793. - // In general, in similar scenarios, we need to grab the protecting lock - // every time suspension safety/unsafety is unbalanced on the two sides - // using the same condition (or any other native blocking support which - // needs an associated native lock), i.e. when either the signaling - // thread(s) is(are) signaling from an unsafe area and the waiting - // thread(s) is(are) waiting from a safe one, or vice versa (the scenario - // described in VSW 363793 is a good example of the first type of - // unbalanced suspension safety/unsafety). - // Instead, whenever signaling and waiting sides are both marked safe or - // unsafe, the deadlock cannot take place since either the suspending - // thread will suspend them anyway (regardless of the native lock), or it - // won't suspend any of them, since they are both marked unsafe. - // Such a balanced scenario applies, for instance, to critical sections - // where depending on whether the target CS is internal or not, both the - // signaling and the waiting side will access the mutex/condition from - // respectively an unsafe or safe region. - - pthrTarget->AcquireNativeWaitLock(); -} - -/*++ -Function: - ReleaseSuspensionLocks - -ReleaseSuspensionLocks releases both thread's suspension mutexes. -Note that the locks are released in the opposite order they're acquired. -This prevents a suspending or resuming thread from being suspended -while holding the target's lock. -If USE_GLOBAL_LOCK_FOR_SUSPENSION is defined, it simply releases the global lock. ---*/ -VOID -CThreadSuspensionInfo::ReleaseSuspensionLocks( - CPalThread *pthrSuspender, - CPalThread *pthrTarget - ) -{ - // See comment in AcquireSuspensionLocks - pthrTarget->ReleaseNativeWaitLock(); - -#ifdef USE_GLOBAL_LOCK_FOR_SUSPENSION - ReleaseSuspensionLock(pthrSuspender); -#else // USE_GLOBAL_LOCK_FOR_SUSPENSION - ReleaseSuspensionLock(pthrTarget); - ReleaseSuspensionLock(pthrSuspender); -#endif // USE_GLOBAL_LOCK_FOR_SUSPENSION -} - -/*++ -Function: - PostOnSuspendSemaphore - -PostOnSuspendSemaphore is a utility function for a thread -to post on its POSIX or SysV suspension semaphore. ---*/ -void -CThreadSuspensionInfo::PostOnSuspendSemaphore() -{ -#if USE_POSIX_SEMAPHORES - if (sem_post(&m_semSusp) == -1) - { - ASSERT("sem_post returned -1 and set errno to %d (%s)\n", errno, strerror(errno)); - } -#elif USE_SYSV_SEMAPHORES - if (semop(m_nSemsuspid, &m_sbSempost, 1) == -1) - { - ASSERT("semop - post returned -1 and set errno to %d (%s)\n", errno, strerror(errno)); - } -#elif USE_PTHREAD_CONDVARS - int status; - - // The suspending thread may not have entered the wait yet, in which case the cond var - // signal below will be a no-op. To prevent the race condition we set m_fSuspended to - // TRUE first (which the suspender will take as an indication that no wait is required). - // But the setting of the flag and the signal must appear atomic to the suspender (as - // reading the flag and potentially waiting must appear to us) to avoid the race - // condition where the suspender reads the flag as FALSE, we set it and signal and the - // suspender then waits. - - // Acquire the suspend mutex. Once we enter the critical section the suspender has - // either gotten there before us (and is waiting for our signal) or is yet to even - // check the flag (so we can set it here to stop them attempting a wait). - status = pthread_mutex_lock(&m_mutexSusp); - if (status != 0) - { - ASSERT("pthread_mutex_lock returned %d (%s)\n", status, strerror(status)); - } - - m_fSuspended = TRUE; - - status = pthread_cond_signal(&m_condSusp); - if (status != 0) - { - ASSERT("pthread_cond_signal returned %d (%s)\n", status, strerror(status)); - } - - status = pthread_mutex_unlock(&m_mutexSusp); - if (status != 0) - { - ASSERT("pthread_mutex_unlock returned %d (%s)\n", status, strerror(status)); - } -#endif // USE_POSIX_SEMAPHORES -} - -/*++ -Function: - WaitOnSuspendSemaphore - -WaitOnSuspendSemaphore is a utility function for a thread -to wait on its POSIX or SysV suspension semaphore. ---*/ -void -CThreadSuspensionInfo::WaitOnSuspendSemaphore() -{ -#if USE_POSIX_SEMAPHORES - while (sem_wait(&m_semSusp) == -1) - { - ASSERT("sem_wait returned -1 and set errno to %d (%s)\n", errno, strerror(errno)); - } -#elif USE_SYSV_SEMAPHORES - while (semop(m_nSemsuspid, &m_sbSemwait, 1) == -1) - { - ASSERT("semop wait returned -1 and set errno to %d (%s)\n", errno, strerror(errno)); - } -#elif USE_PTHREAD_CONDVARS - int status; - - // By the time we wait the target thread may have already signalled its suspension (in - // which case m_fSuspended will be TRUE and we shouldn't wait on the cond var). But we - // must check the flag and potentially wait atomically to avoid the race where we read - // the flag and the target thread sets it and signals before we have a chance to wait. - - status = pthread_mutex_lock(&m_mutexSusp); - if (status != 0) - { - ASSERT("pthread_mutex_lock returned %d (%s)\n", status, strerror(status)); - } - - // If the target has already acknowledged the suspend we shouldn't wait. - while (!m_fSuspended) - { - // We got here before the target could signal. Wait on them (which atomically releases - // the mutex during the wait). - status = pthread_cond_wait(&m_condSusp, &m_mutexSusp); - if (status != 0) - { - ASSERT("pthread_cond_wait returned %d (%s)\n", status, strerror(status)); - } - } - - status = pthread_mutex_unlock(&m_mutexSusp); - if (status != 0) - { - ASSERT("pthread_mutex_unlock returned %d (%s)\n", status, strerror(status)); - } -#endif // USE_POSIX_SEMAPHORES -} - -/*++ -Function: - PostOnResumeSemaphore - -PostOnResumeSemaphore is a utility function for a thread -to post on its POSIX or SysV resume semaphore. ---*/ -void -CThreadSuspensionInfo::PostOnResumeSemaphore() -{ -#if USE_POSIX_SEMAPHORES - if (sem_post(&m_semResume) == -1) - { - ASSERT("sem_post returned -1 and set errno to %d (%s)\n", errno, strerror(errno)); - } -#elif USE_SYSV_SEMAPHORES - if (semop(m_nSemrespid, &m_sbSempost, 1) == -1) - { - ASSERT("semop - post returned -1 and set errno to %d (%s)\n", errno, strerror(errno)); - } -#elif USE_PTHREAD_CONDVARS - int status; - - // The resuming thread may not have entered the wait yet, in which case the cond var - // signal below will be a no-op. To prevent the race condition we set m_fResumed to - // TRUE first (which the resumer will take as an indication that no wait is required). - // But the setting of the flag and the signal must appear atomic to the resumer (as - // reading the flag and potentially waiting must appear to us) to avoid the race - // condition where the resumer reads the flag as FALSE, we set it and signal and the - // resumer then waits. - - // Acquire the resume mutex. Once we enter the critical section the resumer has - // either gotten there before us (and is waiting for our signal) or is yet to even - // check the flag (so we can set it here to stop them attempting a wait). - status = pthread_mutex_lock(&m_mutexResume); - if (status != 0) - { - ASSERT("pthread_mutex_lock returned %d (%s)\n", status, strerror(status)); - } - - m_fResumed = TRUE; - - status = pthread_cond_signal(&m_condResume); - if (status != 0) - { - ASSERT("pthread_cond_signal returned %d (%s)\n", status, strerror(status)); - } - - status = pthread_mutex_unlock(&m_mutexResume); - if (status != 0) - { - ASSERT("pthread_mutex_unlock returned %d (%s)\n", status, strerror(status)); - } -#endif // USE_POSIX_SEMAPHORES -} - -/*++ -Function: - WaitOnResumeSemaphore - -WaitOnResumeSemaphore is a utility function for a thread -to wait on its POSIX or SysV resume semaphore. ---*/ -void -CThreadSuspensionInfo::WaitOnResumeSemaphore() -{ -#if USE_POSIX_SEMAPHORES - while (sem_wait(&m_semResume) == -1) - { - ASSERT("sem_wait returned -1 and set errno to %d (%s)\n", errno, strerror(errno)); - } -#elif USE_SYSV_SEMAPHORES - while (semop(m_nSemrespid, &m_sbSemwait, 1) == -1) - { - ASSERT("semop wait returned -1 and set errno to %d (%s)\n", errno, strerror(errno)); - } -#elif USE_PTHREAD_CONDVARS - int status; - - // By the time we wait the target thread may have already signalled its resumption (in - // which case m_fResumed will be TRUE and we shouldn't wait on the cond var). But we - // must check the flag and potentially wait atomically to avoid the race where we read - // the flag and the target thread sets it and signals before we have a chance to wait. - - status = pthread_mutex_lock(&m_mutexResume); - if (status != 0) - { - ASSERT("pthread_mutex_lock returned %d (%s)\n", status, strerror(status)); - } - - // If the target has already acknowledged the resume we shouldn't wait. - while (!m_fResumed) - { - // We got here before the target could signal. Wait on them (which atomically releases - // the mutex during the wait). - status = pthread_cond_wait(&m_condResume, &m_mutexResume); - if (status != 0) - { - ASSERT("pthread_cond_wait returned %d (%s)\n", status, strerror(status)); - } - } - - status = pthread_mutex_unlock(&m_mutexResume); - if (status != 0) - { - ASSERT("pthread_mutex_unlock returned %d (%s)\n", status, strerror(status)); - } -#endif // USE_POSIX_SEMAPHORES -} - -/*++ -Function: - InitializeSuspensionLock - -InitializeSuspensionLock initializes a thread's suspension spinlock -or suspension mutex. It is called from the CThreadSuspensionInfo -constructor. ---*/ -VOID -CThreadSuspensionInfo::InitializeSuspensionLock() -{ -#if DEADLOCK_WHEN_THREAD_IS_SUSPENDED_WHILE_BLOCKED_ON_MUTEX - SPINLOCKInit(&m_nSpinlock); -#else - int iError = pthread_mutex_init(&m_ptmSuspmutex, NULL); - if (0 != iError ) - { - ASSERT("pthread_mutex_init(&suspmutex) returned %d\n", iError); - return; - } - m_fSuspmutexInitialized = TRUE; -#endif // DEADLOCK_WHEN_THREAD_IS_SUSPENDED_WHILE_BLOCKED_ON_MUTEX -} - -/*++ -Function: - InitializePreCreate - -InitializePreCreate initializes the semaphores and signal masks used -for thread suspension. At the end, it sets the calling thread's -signal mask to the default signal mask. ---*/ -PAL_ERROR -CThreadSuspensionInfo::InitializePreCreate() -{ - PAL_ERROR palError = ERROR_INTERNAL_ERROR; - int iError = 0; -#if SEM_INIT_MODIFIES_ERRNO - int nStoredErrno; -#endif // SEM_INIT_MODIFIES_ERRNO - -#if USE_POSIX_SEMAPHORES - -#if SEM_INIT_MODIFIES_ERRNO - nStoredErrno = errno; -#endif // SEM_INIT_MODIFIES_ERRNO - - // initialize suspension semaphore - iError = sem_init(&m_semSusp, 0, 0); - -#if SEM_INIT_MODIFIES_ERRNO - if (iError == 0) - { - // Restore errno if sem_init succeeded. - errno = nStoredErrno; - } -#endif // SEM_INIT_MODIFIES_ERRNO - - if (0 != iError ) - { - ASSERT("sem_init(&suspsem) returned %d\n", iError); - goto InitializePreCreateExit; - } - -#if SEM_INIT_MODIFIES_ERRNO - nStoredErrno = errno; -#endif // SEM_INIT_MODIFIES_ERRNO - - // initialize resume semaphore - iError = sem_init(&m_semResume, 0, 0); - -#if SEM_INIT_MODIFIES_ERRNO - if (iError == 0) - { - // Restore errno if sem_init succeeded. - errno = nStoredErrno; - } -#endif // SEM_INIT_MODIFIES_ERRNO - - if (0 != iError ) - { - ASSERT("sem_init(&suspsem) returned %d\n", iError); - sem_destroy(&m_semSusp); - goto InitializePreCreateExit; - } - - m_fSemaphoresInitialized = TRUE; - -#elif USE_SYSV_SEMAPHORES - // preparing to initialize the SysV semaphores. - union semun semunData; - m_nSemsuspid = semget(IPC_PRIVATE, 1, IPC_CREAT | 0666); - if (m_nSemsuspid == -1) - { - ASSERT("semget for suspension sem id returned -1 and set errno to %d (%s)\n", errno, strerror(errno)); - goto InitializePreCreateExit; - } - - m_nSemrespid = semget(IPC_PRIVATE, 1, IPC_CREAT | 0666); - if (m_nSemrespid == -1) - { - ASSERT("semget for resumption sem id returned -1 and set errno to %d (%s)\n", errno, strerror(errno)); - goto InitializePreCreateExit; - } - - if (m_nSemsuspid == m_nSemrespid) - { - ASSERT("Suspension and Resumption Semaphores have the same id\n"); - goto InitializePreCreateExit; - } - - semunData.val = 0; - iError = semctl(m_nSemsuspid, 0, SETVAL, semunData); - if (iError == -1) - { - ASSERT("semctl for suspension sem id returned -1 and set errno to %d (%s)\n", errno, strerror(errno)); - goto InitializePreCreateExit; - } - - semunData.val = 0; - iError = semctl(m_nSemrespid, 0, SETVAL, semunData); - if (iError == -1) - { - ASSERT("semctl for resumption sem id returned -1 and set errno to %d (%s)\n", errno, strerror(errno)); - goto InitializePreCreateExit; - } - - // initialize suspend semaphore - m_sbSemwait.sem_num = 0; - m_sbSemwait.sem_op = -1; - m_sbSemwait.sem_flg = 0; - - // initialize resume semaphore - m_sbSempost.sem_num = 0; - m_sbSempost.sem_op = 1; - m_sbSempost.sem_flg = 0; -#elif USE_PTHREAD_CONDVARS - iError = pthread_cond_init(&m_condSusp, NULL); - if (iError != 0) - { - ASSERT("pthread_cond_init for suspension returned %d (%s)\n", iError, strerror(iError)); - goto InitializePreCreateExit; - } - - iError = pthread_mutex_init(&m_mutexSusp, NULL); - if (iError != 0) - { - ASSERT("pthread_mutex_init for suspension returned %d (%s)\n", iError, strerror(iError)); - goto InitializePreCreateExit; - } - - iError = pthread_cond_init(&m_condResume, NULL); - if (iError != 0) - { - ASSERT("pthread_cond_init for resume returned %d (%s)\n", iError, strerror(iError)); - goto InitializePreCreateExit; - } - - iError = pthread_mutex_init(&m_mutexResume, NULL); - if (iError != 0) - { - ASSERT("pthread_mutex_init for resume returned %d (%s)\n", iError, strerror(iError)); - goto InitializePreCreateExit; - } - - m_fSemaphoresInitialized = TRUE; -#endif // USE_POSIX_SEMAPHORES - - // Initialization was successful. - palError = NO_ERROR; - -InitializePreCreateExit: - - if (NO_ERROR == palError && 0 != iError) - { - switch (iError) - { - case ENOMEM: - case EAGAIN: - { - palError = ERROR_OUTOFMEMORY; - break; - } - default: - { - ASSERT("A pthrSuspender init call returned %d (%s)\n", iError, strerror(iError)); - palError = ERROR_INTERNAL_ERROR; - } - } - } - - return palError; -} - -CThreadSuspensionInfo::~CThreadSuspensionInfo() -{ -#if !DEADLOCK_WHEN_THREAD_IS_SUSPENDED_WHILE_BLOCKED_ON_MUTEX - if (m_fSuspmutexInitialized) - { - INDEBUG(int iError = ) - pthread_mutex_destroy(&m_ptmSuspmutex); - _ASSERT_MSG(0 == iError, "pthread_mutex_destroy returned %d (%s)\n", iError, strerror(iError)); - } -#endif - -#if USE_POSIX_SEMAPHORES - if (m_fSemaphoresInitialized) - { - int iError; - - iError = sem_destroy(&m_semSusp); - _ASSERT_MSG(0 == iError, "sem_destroy failed and set errno to %d (%s)\n", errno, strerror(errno)); - - iError = sem_destroy(&m_semResume); - _ASSERT_MSG(0 == iError, "sem_destroy failed and set errno to %d (%s)\n", errno, strerror(errno)); - } -#elif USE_SYSV_SEMAPHORES - DestroySemaphoreIds(); -#elif USE_PTHREAD_CONDVARS - if (m_fSemaphoresInitialized) - { - int iError; - - iError = pthread_cond_destroy(&m_condSusp); - _ASSERT_MSG(0 == iError, "pthread_cond_destroy failed with %d (%s)\n", iError, strerror(iError)); - - iError = pthread_mutex_destroy(&m_mutexSusp); - _ASSERT_MSG(0 == iError, "pthread_mutex_destroy failed with %d (%s)\n", iError, strerror(iError)); - - iError = pthread_cond_destroy(&m_condResume); - _ASSERT_MSG(0 == iError, "pthread_cond_destroy failed with %d (%s)\n", iError, strerror(iError)); - - iError = pthread_mutex_destroy(&m_mutexResume); - _ASSERT_MSG(0 == iError, "pthread_mutex_destroy failed with %d (%s)\n", iError, strerror(iError)); - } -#endif // USE_POSIX_SEMAPHORES -} - -#if USE_SYSV_SEMAPHORES -/*++ -Function: - DestroySemaphoreIds - -DestroySemaphoreIds is called from the CThreadSuspensionInfo destructor and -from PROCCleanupThreadSemIds. If a thread exits before shutdown or is suspended -during shutdown, its destructor will be invoked and the semaphore ids destroyed. -In assert or exceptions situations that are suspension unsafe, -PROCCleanupThreadSemIds is called, which uses DestroySemaphoreIds. ---*/ -void -CThreadSuspensionInfo::DestroySemaphoreIds() -{ - union semun semunData; - if (m_nSemsuspid != 0) - { - semunData.val = 0; - if (0 != semctl(m_nSemsuspid, 0, IPC_RMID, semunData)) - { - ERROR("semctl(Semsuspid) failed and set errno to %d (%s)\n", errno, strerror(errno)); - } - else - { - m_nSemsuspid = 0; - } - } - if (this->m_nSemrespid) - { - semunData.val = 0; - if (0 != semctl(m_nSemrespid, 0, IPC_RMID, semunData)) - { - ERROR("semctl(Semrespid) failed and set errno to %d (%s)\n", errno, strerror(errno)); - } - else - { - m_nSemrespid = 0; - } - } -} -#endif // USE_SYSV_SEMAPHORES diff --git a/src/pal/src/thread/tls.cpp b/src/pal/src/thread/tls.cpp deleted file mode 100644 index ef6d02f00..000000000 --- a/src/pal/src/thread/tls.cpp +++ /dev/null @@ -1,226 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*++ - - - -Module Name: - - tls.cpp - -Abstract: - - Implementation of Thread local storage functions. - - - ---*/ - -#include "pal/thread.hpp" -#include "procprivate.hpp" - -#include - -#include "pal/dbgmsg.h" -#include "pal/misc.h" -#include "pal/virtual.h" -#include "pal/process.h" -#include "pal/init.h" -#include "pal/malloc.hpp" -#include "pal_endian.h" - -#include -using namespace CorUnix; - -SET_DEFAULT_DEBUG_CHANNEL(THREAD); - -// In safemath.h, Template SafeInt uses macro _ASSERTE, which need to use variable -// defdbgchan defined by SET_DEFAULT_DEBUG_CHANNEL. Therefore, the include statement -// should be placed after the SET_DEFAULT_DEBUG_CHANNEL(THREAD) -#include - -/* This tracks the slots that are used for TlsAlloc. Its size in bits - must be the same as TLS_SLOT_SIZE in pal/thread.h. Since this is - static, it is initialized to 0, which is what we want. */ -static unsigned __int64 sTlsSlotFields; - -/*++ -Function: - TlsAlloc - -See MSDN doc. ---*/ -DWORD -PALAPI -TlsAlloc( - VOID) -{ - DWORD dwIndex; - unsigned int i; - - PERF_ENTRY(TlsAlloc); - ENTRY("TlsAlloc()\n"); - - /* Yes, this could be ever so slightly improved. It's not - likely to be called enough to matter, though, so we won't - optimize here until or unless we need to. */ - - PROCProcessLock(); - - for(i = 0; i < sizeof(sTlsSlotFields) * 8; i++) - { - if ((sTlsSlotFields & ((unsigned __int64) 1 << i)) == 0) - { - sTlsSlotFields |= ((unsigned __int64) 1 << i); - break; - } - } - if (i == sizeof(sTlsSlotFields) * 8) - { - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - dwIndex = TLS_OUT_OF_INDEXES; - } - else - { - dwIndex = i; - } - - PROCProcessUnlock(); - - LOGEXIT("TlsAlloc returns DWORD %u\n", dwIndex); - PERF_EXIT(TlsAlloc); - return dwIndex; -} - - -/*++ -Function: - TlsGetValue - -See MSDN doc. ---*/ -LPVOID -PALAPI -TlsGetValue( - IN DWORD dwTlsIndex) -{ - CPalThread *pThread; - - PERF_ENTRY(TlsGetValue); - ENTRY("TlsGetValue()\n"); - - if (dwTlsIndex == (DWORD) -1 || dwTlsIndex >= TLS_SLOT_SIZE) - { - SetLastError(ERROR_INVALID_PARAMETER); - return 0; - } - - pThread = InternalGetCurrentThread(); - - /* From MSDN : "The TlsGetValue function calls SetLastError to clear a - thread's last error when it succeeds." */ - pThread->SetLastError(NO_ERROR); - - LOGEXIT("TlsGetValue \n" ); - PERF_EXIT(TlsGetValue); - - return pThread->tlsInfo.tlsSlots[dwTlsIndex]; -} - - -/*++ -Function: - TlsSetValue - -See MSDN doc. ---*/ -BOOL -PALAPI -TlsSetValue( - IN DWORD dwTlsIndex, - IN LPVOID lpTlsValue) -{ - CPalThread *pThread; - BOOL bRet = FALSE; - PERF_ENTRY(TlsSetValue); - ENTRY("TlsSetValue(dwTlsIndex=%u, lpTlsValue=%p)\n", dwTlsIndex, lpTlsValue); - - if (dwTlsIndex == (DWORD) -1 || dwTlsIndex >= TLS_SLOT_SIZE) - { - SetLastError(ERROR_INVALID_PARAMETER); - goto EXIT; - } - - pThread = InternalGetCurrentThread(); - pThread->tlsInfo.tlsSlots[dwTlsIndex] = lpTlsValue; - bRet = TRUE; - -EXIT: - LOGEXIT("TlsSetValue returns BOOL %d\n", bRet); - PERF_EXIT(TlsSetValue); - return bRet; -} - - -/*++ -Function: - TlsFree - -See MSDN doc. ---*/ -BOOL -PALAPI -TlsFree( - IN DWORD dwTlsIndex) -{ - CPalThread *pThread; - - PERF_ENTRY(TlsFree); - ENTRY("TlsFree(dwTlsIndex=%u)\n", dwTlsIndex); - - - if (dwTlsIndex == (DWORD) -1 || dwTlsIndex >= TLS_SLOT_SIZE) - { - SetLastError(ERROR_INVALID_PARAMETER); - LOGEXIT("TlsFree returns BOOL FALSE\n"); - PERF_EXIT(TlsFree); - return FALSE; - } - - PROCProcessLock(); - - /* Reset all threads' values to zero for this index. */ - for(pThread = pGThreadList; - pThread != NULL; pThread = pThread->GetNext()) - { - pThread->tlsInfo.tlsSlots[dwTlsIndex] = 0; - } - sTlsSlotFields &= ~((unsigned __int64) 1 << dwTlsIndex); - - PROCProcessUnlock(); - - LOGEXIT("TlsFree returns BOOL TRUE\n"); - PERF_EXIT(TlsFree); - return TRUE; -} - -PAL_ERROR -CThreadTLSInfo::InitializePostCreate( - CPalThread *pThread, - SIZE_T threadId, - DWORD dwLwpId - ) -{ - PAL_ERROR palError = NO_ERROR; - - if (pthread_setspecific(thObjKey, reinterpret_cast(pThread))) - { - ASSERT("Unable to set the thread object key's value\n"); - palError = ERROR_INTERNAL_ERROR; - } - - return palError; -} - diff --git a/src/pal/tests/CMakeLists.txt b/src/pal/tests/CMakeLists.txt deleted file mode 100644 index 39d585288..000000000 --- a/src/pal/tests/CMakeLists.txt +++ /dev/null @@ -1,41 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -if(CLR_CMAKE_PLATFORM_ARCH_I386) - set(PAL_CMAKE_PLATFORM_ARCH_I386 1) -elseif(CLR_CMAKE_PLATFORM_ARCH_AMD64) - set(PAL_CMAKE_PLATFORM_ARCH_AMD64 1) -elseif(CLR_CMAKE_PLATFORM_ARCH_ARM) - set(PAL_CMAKE_PLATFORM_ARCH_ARM 1) -elseif(CLR_CMAKE_PLATFORM_ARCH_ARM64) - set(PAL_CMAKE_PLATFORM_ARCH_ARM64 1) -endif() - -# Compile options -add_definitions(-DPLATFORM_UNIX=1) -add_definitions(-DLP64COMPATIBLE=1) -add_definitions(-DFEATURE_PAL=1) -add_definitions(-DCORECLR=1) -add_definitions(-DPIC=1) -if(PAL_CMAKE_PLATFORM_ARCH_I386) - add_definitions(-DBIT32=1) -elseif(PAL_CMAKE_PLATFORM_ARCH_AMD64) - add_definitions(-DBIT64=1) - add_definitions(-D_WIN64=1) -elseif(PAL_CMAKE_PLATFORM_ARCH_ARM) - add_definitions(-DBIT32=1) -elseif(PAL_CMAKE_PLATFORM_ARCH_ARM64) - add_definitions(-DBIT64=1) - add_definitions(-D_WIN64=1) -else() - message(FATAL_ERROR "Only ARM, ARM64, I386, and AMD64 is supported") -endif() - -# C++ emits errors and warnings for c-string literal fed into char* parameter -# this is just to take care of the warnings -add_compile_options(-Wno-writable-strings) - -add_compile_options(-Wno-empty-body) - -add_subdirectory(palsuite) - - diff --git a/src/pal/tests/palsuite/CMakeLists.txt b/src/pal/tests/palsuite/CMakeLists.txt deleted file mode 100644 index 6f36025d1..000000000 --- a/src/pal/tests/palsuite/CMakeLists.txt +++ /dev/null @@ -1,37 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -project(PALTESTSUITE) - -include_directories(${PALTESTSUITE_SOURCE_DIR}/common) - -# All test will link against these libraries: -# pthread and m are part of the Android C library (bionic), -# so we don't need to link them seperately -if(NOT CLR_CMAKE_PLATFORM_ANDROID) - list(APPEND COMMON_TEST_LIBRARIES pthread) - list(APPEND COMMON_TEST_LIBRARIES m) -endif() - -list(APPEND COMMON_TEST_LIBRARIES coreclrpal) - -add_compile_options(-Wno-incompatible-pointer-types-discards-qualifiers) -add_compile_options(-Wno-int-to-void-pointer-cast) - -# TODO: make these tests compile -# add_subdirectory(composite) -add_subdirectory(exception_handling) - -add_subdirectory(c_runtime) -add_subdirectory(debug_api) -add_subdirectory(filemapping_memmgt) -add_subdirectory(file_io) -add_subdirectory(loader) -add_subdirectory(locale_info) -add_subdirectory(miscellaneous) -add_subdirectory(pal_specific) -add_subdirectory(samples) -add_subdirectory(threading) - -if(FEATURE_EVENT_TRACE) - add_subdirectory(${GENERATED_EVENTING_DIR}/eventprovider/tests ${CMAKE_CURRENT_BINARY_DIR}/eventprovider) -endif(FEATURE_EVENT_TRACE) diff --git a/src/pal/tests/palsuite/DisabledTests.txt b/src/pal/tests/palsuite/DisabledTests.txt deleted file mode 100644 index b3ca37058..000000000 --- a/src/pal/tests/palsuite/DisabledTests.txt +++ /dev/null @@ -1,123 +0,0 @@ -Disabled Test Cases -~~~~~~~~~~~~~~~~~~~ - -Below is a list of all disabled test cases currently listed in -testconfig.dat and an explanation as to why they are disabled. - -debug_api/debugbreak/test1 -debug_api/outputdebugstringa/test1 -debug_api/outputdebugstringw/test1 -debug_api/writeprocessmemory/test1 -debug_api/writeprocessmemory/test2 -debug_api/writeprocessmemory/test3 -debug_api/writeprocessmemory/test4 -======================================= -The above testcases were disabled in the palsuite, because they depend heavily on -WaitForDebugEvent,DebugActiveProcess and ContinueDebugEvent, where these api's have been removed from the PAL and listed in the rotor_pal.doc (6.0) - - -file_io/gettempfilenamea/test2 : -======================================= -This test takes longer than 60 seconds to run. The test creates -about 65000 files and then deletes them. The test that takes longer -than 60 seconds will be flagged as an error and so in such a case -the test will have to be run manually. - -file_io/gettempfilenamew/test2 : -======================================= -This test takes longer than 60 seconds to run. The test creates -about 65000 files and then deletes them. The test that takes longer -than 60 seconds will be flagged as an error and so in such a case -the test will have to be run manually. - -locale_info/getcpinfo/test2: -======================================= -This test will be useful in future versions for testing various -languages (code pages). Currently only U.S. English (tested by - -test1) is supported. - -locale_info/getcpinfo/test3: -======================================= -This test will be useful in future versions for testing various -languages (code pages). Currently only U.S. English (tested by - -test1) is supported. - -locale_info/isvalidcodepage/test2: -======================================= -This test will be useful in future versions for testing various -languages (code pages). Currently only U.S. English (tested by - -test1) is supported. - -miscellaneous/getcalendarinfow/test2: -======================================= -Currently the only calendars that are supported are CAL_GREGORIAN -and CAL_GREGORIAN_US, which are tested by test1. This test will -be useful when full calendar support is implemented. - -miscellaneous/getdateformatw/test1: -=================================== -Currently the only calendars that are supported are CAL_GREGORIAN -and CAL_GREGORIAN_US. The GetDateFormatW function will only be -called when the calendar is CAL_TAIWAN. Since this calendar is not -currently supported in this release of the PAL, the GetDateFormatW -function is not implemented except to return an error. This test -will be useful when full calendar support is implemented. - -miscellaneous/getdateformatw/getdateformatw_neg1: -================================================ -Currently the only calendars that are supported are CAL_GREGORIAN -and CAL_GREGORIAN_US. The GetDateFormatW function will only be -called when the calendar is CAL_TAIWAN. Since this calendar is not -currently supported in this release of the PAL, the GetDateFormatW -function is not implemented except to return an error. This test -will be useful when full calendar support is implemented. - -miscellaneous/getdateformatw/getdateformatw_neg2: -================================================ -Currently the only calendars that are supported are CAL_GREGORIAN -and CAL_GREGORIAN_US. The GetDateFormatW function will only be -called when the calendar is CAL_TAIWAN. Since this calendar is not -currently supported in this release of the PAL, the GetDateFormatW -function is not implemented except to return an error. This test -will be useful when full calendar support is implemented. - - -pal_specific/pal_get_stdin/test1 : -======================================= -This test case should be run manually. Requires user input. - - -threading/setconsolectrlhandler/test1 -threading/setconsolectrlhandler/test2 -threading/setconsolectrlhandler/test3 -threading/setconsolectrlhandler/test4 -======================================= -These tests cases should be run manually. Requires user input. - -threading/getprocesstimes/test1 -======================================= -According to rotor_pal.doc, GetProcessTimes() should be supported for the current -process only. I've removed this test because it tests GetProcessTimes() with -invalid process handle value. - -threading/getthreadcontext/test1,1 -======================================= -According to rotor_pal.doc, when GetThreadContext is call for a thread within -the same process, it could only be called for te current thread. I've removed -this test, because it tests GetThreadContext() with a non current thread handle -belong the current procees. - -loader/loadlibrarya/test4 -loader/loadlibraryw/test4 -======================================= -PAL BSD should not append the .so extension in LoadLibrary if the extension is -omitted. -file_io/deletefilea/test3 -file_io/deletefilew/test3 -======================================= -No code in Rotor depends on DeleteFile[A/W] failing on readonly files so we -don't need to exactly emulate this feature of the Win32 filesystems on FreeBSD. - -filemapping_memmgt\MapViewOfFile\test1 -======================================= -Refer this github issue https://github.com/dotnet/coreclr/issues/5176 \ No newline at end of file diff --git a/src/pal/tests/palsuite/README.txt b/src/pal/tests/palsuite/README.txt deleted file mode 100644 index 1cc930b9b..000000000 --- a/src/pal/tests/palsuite/README.txt +++ /dev/null @@ -1,134 +0,0 @@ -; Licensed to the .NET Foundation under one or more agreements. -; The .NET Foundation licenses this file to you under the MIT license. -; See the LICENSE file in the project root for more information. - -=========================================================================== - - -1. ENVIRONMENT SETUP - -2. RUNNING THE SUITES - -3. ENVIRONMENT VARIABLES AND AUTOMATED TESTING SPECIFICS -3.1 PAL_DISABLE_MESSAGEBOX -3.2 Other Notes - -4. ADDITIONAL NOTES ON TESTING/SPECIFIC TEST CASE ISSUES - C_runtime: _fdopen testing issues - File_IO: getfilesize/test1, setfilepointer/test(5,6,7) - File_IO: gettempfilename(a,w)/test2 - File_IO: setfileattributesa/test(1,4), setfileattributesw/test(1,4) - Miscellaneous: messageboxw/test(1,2) - Pal_specific:: pal_get_stdin/test1, pal_get_stdout/test1, pal_get_stderr/test1 - Threading: setconsolectrlhandler/test(3,4) - - -=========================================================================== - -1. ENVIRONMENT SETUP -~~~~~~~~~~~~~~~~~~~~~ - -Within a Rotor build window (env.sh/env.csh/env.bat), no additional -configuration needs to be done. - - -2. RUNNING THE SUITES -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -Run %ROTOR_DIR%\tests\pvtrun.pl to launch the test suites. It will -display information about each test as it runs, then report a -summary of the results upon completion. - -The results are logged to %ROTOR_DIR%\tests\pvtResults.log. - - -3. ENVIRONMENT VARIABLES AND AUTOMATED TESTING SPECIFICS -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -3.1 PAL_DISABLE_MESSAGEBOX - -For automated testing on the WIN32 PAL, the following environment -variable is useful to prevent pop-up message boxes from interupting the -execution of the MessageBoxW test cases: - -set PAL_DISABLE_MESSAGEBOX=1 - - -3.2 Other Notes - -See notes in section 4 on the following test cases if running automated tests: - - Miscellaneous: messageboxw/test(1,2) - Threading: setconsolectrlhandler/test(3,4) - - -4. ADDITIONAL NOTES ON TESTING/SPECIFIC TEST CASE ISSUES -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -C Runtime: _fdopen testing issues - -There is a very specific manner in which _fdopen has been documented to work, -this will determine how the function will be tested. - -_fdopen takes a parameter of a c run-time file handle, to open a stream to the -file. This file handle can only be returned from the _open_osfhandle function. -The Rotor documentation states that _open_osfhandle will only return a -READ-ONLY file handle, from an operating-system file handle returned from -CreatePipe(). - -With these restrictions _fdopen will only be tested with a mode of read(r). -The other modes are not possible to test. _open_osfhandle returns an error -when attempting to open a write pipe handle in a mode of read-only. As well, -it is not possible to read and write to the same handle that is returned from -CreatePipe(). - -The modes that will not be tested are as follows: - - "w" - Opens an empty file for writing. - "a" - Opens for writing at the end of the file (appending). - "r+" - Opens for both reading and writing. - "w+" - Opens an empty file for both reading and writing. - "a+" - Opens for reading and appending. - - - -File_IO: getfilesize/test1, getfilesizeex/test1 setfilepointer/test(5,6,7) - -These tests cases create a large number of temporary files which require -ample disk space. On systems with less than 6Gb free disk space expect -these test cases to fail. - - -File_IO: gettempfilename(a,w)/test2 - -These test cases take longer than 60 seconds to run. Currently, the Test -Harness will timeout any test case that exceeds 60 seconds. - - -File_IO: setfileattributesa/test(1,4), SetFileAttributesW/test(1,4) - -These test cases ensure restricted file permissions are respected. Administrators -or super users (root) are not affected by file permissions and, as a result, these -test cases will fail for such users. - - -Miscellaneous: messageboxw/test(1,2) - -Setting PAL_MESSAGEBOX_DISABLE=1 for these test cases prevents message box pop -ups that occur during the tests' execution on Windows. For automated testing -where user interaction is not desired/possible, setting this environment -variable will prevent a pause in the automated test run. - - -ic: pal_get_stdin/test1, pal_get_stdout/test1, pal_get_stderr/test1 - -These test cases should be manually inspected to ensure the information being returned -is correct. The pal_get_stdin test case requires user input. The pal_get_stdout and -pal_get_stderr test cases do not require user input, but their output should be inspected -to verify that correct messages are being displayed. - - -Threading: setconsolectrlhandler/test(3,4) - -These test cases require user response in order to produce a meaningful results. -For automated testing, this test case is disabled. diff --git a/src/pal/tests/palsuite/c_runtime/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/CMakeLists.txt deleted file mode 100644 index ba11c9109..000000000 --- a/src/pal/tests/palsuite/c_runtime/CMakeLists.txt +++ /dev/null @@ -1,180 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(abs) -add_subdirectory(acos) -add_subdirectory(acosf) -add_subdirectory(acosh) -add_subdirectory(acoshf) -add_subdirectory(asin) -add_subdirectory(asinf) -add_subdirectory(asinh) -add_subdirectory(asinhf) -add_subdirectory(atan) -add_subdirectory(atan2) -add_subdirectory(atan2f) -add_subdirectory(atanf) -add_subdirectory(atanh) -add_subdirectory(atanhf) -add_subdirectory(atof) -add_subdirectory(atoi) -add_subdirectory(atol) -add_subdirectory(bsearch) -add_subdirectory(cbrt) -add_subdirectory(cbrtf) -add_subdirectory(ceil) -add_subdirectory(ceilf) -add_subdirectory(cos) -add_subdirectory(cosf) -add_subdirectory(cosh) -add_subdirectory(coshf) - -# TODO: make this test compile -# add_subdirectory(ctime) - -add_subdirectory(errno) -add_subdirectory(exit) -add_subdirectory(exp) -add_subdirectory(expf) -add_subdirectory(fabs) -add_subdirectory(fabsf) -add_subdirectory(fclose) -add_subdirectory(feof) -add_subdirectory(ferror) -add_subdirectory(fflush) -add_subdirectory(fgets) -add_subdirectory(floor) -add_subdirectory(floorf) -add_subdirectory(fmod) -add_subdirectory(fmodf) -add_subdirectory(fopen) -add_subdirectory(fprintf) -add_subdirectory(fputs) -add_subdirectory(fread) -add_subdirectory(free) -add_subdirectory(fseek) -add_subdirectory(ftell) -add_subdirectory(fwprintf) -add_subdirectory(fwrite) -add_subdirectory(getc) -add_subdirectory(getenv) -add_subdirectory(isalnum) -add_subdirectory(isalpha) -add_subdirectory(isdigit) -add_subdirectory(islower) -add_subdirectory(isprint) -add_subdirectory(isspace) -add_subdirectory(isupper) -add_subdirectory(iswdigit) -add_subdirectory(iswspace) -add_subdirectory(iswupper) -add_subdirectory(iswxdigit) -add_subdirectory(isxdigit) -add_subdirectory(labs) -add_subdirectory(llabs) -add_subdirectory(localtime) -add_subdirectory(log) -add_subdirectory(log10) -add_subdirectory(log10f) -add_subdirectory(logf) -add_subdirectory(malloc) -add_subdirectory(memchr) -add_subdirectory(memcmp) -add_subdirectory(memcpy) -add_subdirectory(memmove) -add_subdirectory(memset) -add_subdirectory(modf) -add_subdirectory(modff) -add_subdirectory(pow) -add_subdirectory(powf) -add_subdirectory(printf) -add_subdirectory(qsort) -add_subdirectory(rand_srand) -add_subdirectory(realloc) -add_subdirectory(sin) -add_subdirectory(sinf) -add_subdirectory(sinh) -add_subdirectory(sinhf) -add_subdirectory(sprintf_s) -add_subdirectory(sqrt) -add_subdirectory(sqrtf) -add_subdirectory(sscanf_s) -add_subdirectory(strcat) -add_subdirectory(strchr) -add_subdirectory(strcmp) -add_subdirectory(strcpy) -add_subdirectory(strcspn) -add_subdirectory(strlen) -add_subdirectory(strncat) -add_subdirectory(strncmp) -add_subdirectory(strncpy) -add_subdirectory(strpbrk) -add_subdirectory(strrchr) -add_subdirectory(strspn) -add_subdirectory(strstr) -add_subdirectory(strtod) -add_subdirectory(strtok) -add_subdirectory(strtoul) -add_subdirectory(swprintf) -add_subdirectory(swscanf) -add_subdirectory(tan) -add_subdirectory(tanf) -add_subdirectory(tanh) -add_subdirectory(tanhf) -add_subdirectory(time) -add_subdirectory(tolower) -add_subdirectory(toupper) -add_subdirectory(towlower) -add_subdirectory(towupper) -add_subdirectory(ungetc) -add_subdirectory(vfprintf) -add_subdirectory(vprintf) -add_subdirectory(vsprintf) -add_subdirectory(vswprintf) -add_subdirectory(wcscat) -add_subdirectory(wcschr) -add_subdirectory(wcscmp) -add_subdirectory(wcscpy) -add_subdirectory(wcslen) -add_subdirectory(wcsncat) -add_subdirectory(wcsncmp) -add_subdirectory(wcsncpy) -add_subdirectory(wcspbrk) -add_subdirectory(wcsrchr) -add_subdirectory(wcsstr) -add_subdirectory(wcstod) -add_subdirectory(wcstok) -add_subdirectory(wcstol) -add_subdirectory(wcstoul) -add_subdirectory(wprintf) -add_subdirectory(_alloca) -add_subdirectory(_fdopen) -add_subdirectory(_finite) -add_subdirectory(_finitef) -add_subdirectory(_fullpath) - -# TODO: make this test compile -# add_subdirectory(_gcvt) - -add_subdirectory(_isnan) -add_subdirectory(_isnanf) -add_subdirectory(_itow) -add_subdirectory(_mbsdec) -add_subdirectory(_mbsinc) -add_subdirectory(_mbsninc) -add_subdirectory(_open_osfhandle) -add_subdirectory(_putenv) -add_subdirectory(_rotl) -add_subdirectory(_rotr) -add_subdirectory(_snprintf_s) -add_subdirectory(_snwprintf_s) -add_subdirectory(_stricmp) -add_subdirectory(_strlwr) -add_subdirectory(_strnicmp) -add_subdirectory(_vsnprintf_s) -add_subdirectory(_vsnwprintf_s) -add_subdirectory(_wcsicmp) -add_subdirectory(_wcslwr) -add_subdirectory(_wcsnicmp) -add_subdirectory(_wfopen) -add_subdirectory(_wtoi) -add_subdirectory(__iscsym) diff --git a/src/pal/tests/palsuite/c_runtime/__iscsym/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/__iscsym/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/c_runtime/__iscsym/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/c_runtime/__iscsym/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/__iscsym/test1/CMakeLists.txt deleted file mode 100644 index 4dd4cf13f..000000000 --- a/src/pal/tests/palsuite/c_runtime/__iscsym/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - __iscsym.cpp -) - -add_executable(paltest_iscsym_test1 - ${SOURCES} -) - -add_dependencies(paltest_iscsym_test1 coreclrpal) - -target_link_libraries(paltest_iscsym_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/__iscsym/test1/__iscsym.cpp b/src/pal/tests/palsuite/c_runtime/__iscsym/test1/__iscsym.cpp deleted file mode 100644 index 9c8f1d0f2..000000000 --- a/src/pal/tests/palsuite/c_runtime/__iscsym/test1/__iscsym.cpp +++ /dev/null @@ -1,93 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: __iscsym.c -** -** Purpose: Positive test the __iscsym API. -** Call __iscsym to letter, digit and underscore -** -** -**============================================================*/ -#include - -int __cdecl main(int argc, char *argv[]) -{ - int err; - int index; - char non_letter_set[]= - {'~','`','!','@','#','$','%','^','&','*','(',')',')', - '-','+','=','|','\\',';',':','"','\'','<','>', - ',','.','?','/','\0'}; - char errBuffer[200]; - - /*Initialize the PAL environment*/ - err = PAL_Initialize(argc, argv); - if(0 != err) - { - return FAIL; - } - - /*To check if the parameter passed in is a character*/ - for(index = 'a'; index <= 'z'; index++) - { - err = __iscsym(index); - if(0 == err) - { - Fail("\n__iscsym failed to recognize a " - "lower-case letter:%c!\n", index); - } - } - - /*To check if the parameter passed in is a character*/ - for(index = 'A'; index <= 'Z'; index++) - { - err = __iscsym(index); - if(0 == err) - { - Fail("\n__iscsym failed to recognize an " - "upper-case letter: %c!\n", index); - } - } - - /*To check if the parameter passed in is a digit*/ - for(index = '0'; index <= '9'; index++) - { - err = __iscsym(index); - if(0 == err) - { - Fail("\n__iscsym failed to recognize a digit %c!\n", - index); - } - } - - /*To check if the parameter passed in is a underscore*/ - err = __iscsym('_'); - if(0 == err) - { - Fail("\n__iscsym failed to recognize an underscore!\n"); - } - - memset(errBuffer, 0, 200); - - for(index = 0; non_letter_set[index]; index++) - { - err = __iscsym(non_letter_set[index]); - if(0 != err) - { - strncat(errBuffer, &non_letter_set[index], 1); - strcat(errBuffer, ", "); - } - } - - if(strlen(errBuffer) > 0) - { - Fail("\n__iscsym failed to identify the characters '%s' " - "as not letters, digits " - "or underscores\n", errBuffer); - } - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/__iscsym/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/__iscsym/test1/testinfo.dat deleted file mode 100644 index e6668edcc..000000000 --- a/src/pal/tests/palsuite/c_runtime/__iscsym/test1/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = __iscsym -Name = Positive test for __iscsym to test letter, digit and underscore -TYPE = DEFAULT -EXE1 = __iscsym -Description -=Test the __iscsym to test letter, digit and underscore diff --git a/src/pal/tests/palsuite/c_runtime/_alloca/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_alloca/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/c_runtime/_alloca/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/c_runtime/_alloca/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_alloca/test1/CMakeLists.txt deleted file mode 100644 index 97a351c80..000000000 --- a/src/pal/tests/palsuite/c_runtime/_alloca/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_alloca_test1 - ${SOURCES} -) - -add_dependencies(paltest_alloca_test1 coreclrpal) - -target_link_libraries(paltest_alloca_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_alloca/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/_alloca/test1/test1.cpp deleted file mode 100644 index c533d8423..000000000 --- a/src/pal/tests/palsuite/c_runtime/_alloca/test1/test1.cpp +++ /dev/null @@ -1,62 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: Checks that _alloca allocates memory, and that the memory is -** readable and writeable. -** -** -**==========================================================================*/ - -#include - -int __cdecl main(int argc, char **argv) -{ - - char *testA = NULL; - int i = 0; - - /* - * Initialize the PAL and return FAIL if this fails - */ - if (0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - - /* check that _alloca really gives us addressable memory */ - testA = (char *)_alloca(20 * sizeof(char)); - if (testA == NULL) - { - Fail ("The call to _alloca failed\n"); - } - - memset(testA, 'a', 20); - - for (i = 0; i < 20; i++) - { - if (testA[i] != 'a') - { - Fail ("The memory returned by _alloca doesn't seem to be" - " properly allocated\n"); - } - } - - PAL_Terminate(); - return PASS; -} - - - - - - - - - - diff --git a/src/pal/tests/palsuite/c_runtime/_alloca/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_alloca/test1/testinfo.dat deleted file mode 100644 index e21562195..000000000 --- a/src/pal/tests/palsuite/c_runtime/_alloca/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = _alloca -Name = Positive Test for _alloca -TYPE = DEFAULT -EXE1 = test1 -Description -= Checks that _alloca allocates memory, and that the memory is -= readable and writeable. diff --git a/src/pal/tests/palsuite/c_runtime/_fdopen/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_fdopen/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/c_runtime/_fdopen/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/c_runtime/_fdopen/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_fdopen/test1/CMakeLists.txt deleted file mode 100644 index a389b8330..000000000 --- a/src/pal/tests/palsuite/c_runtime/_fdopen/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_fdopen_test1 - ${SOURCES} -) - -add_dependencies(paltest_fdopen_test1 coreclrpal) - -target_link_libraries(paltest_fdopen_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_fdopen/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/_fdopen/test1/test1.cpp deleted file mode 100644 index b88267c6e..000000000 --- a/src/pal/tests/palsuite/c_runtime/_fdopen/test1/test1.cpp +++ /dev/null @@ -1,112 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test1.c (fdopen) -** -** Purpose: Tests the PAL implementation of the fdopen function. -** This will test fdopen in r (read) mode. This test -** creates and opens a test pipe, to write and read -** from. fdopen requires a file handle(int), therefore -** _open_osfhandle is used to get that handle. -** _open_osfhandle is only used with CreatePipe. The -** test will write and read from the pipe comparing -** the results. -** -** See /tests/palsuite/README.txt for more information. -** -** -**===================================================================*/ - -#include - -const char* cTestString = "one fish, two fish, read fish, blue fish."; - -int __cdecl main(int argc, char **argv) -{ - HANDLE hReadPipe = NULL; - HANDLE hWritePipe = NULL; - BOOL bRetVal = FALSE; - int iFiledes = 0; - DWORD dwBytesWritten; - char buffer[45]; - FILE *fp; - - SECURITY_ATTRIBUTES lpPipeAttributes; - - /*Initialize the PAL*/ - if ((PAL_Initialize(argc, argv)) != 0) - { - return (FAIL); - } - - /*Setup SECURITY_ATTRIBUTES structure for CreatePipe*/ - lpPipeAttributes.nLength = sizeof(lpPipeAttributes); - lpPipeAttributes.lpSecurityDescriptor = NULL; - lpPipeAttributes.bInheritHandle = TRUE; - - /*Create a Pipe*/ - bRetVal = CreatePipe(&hReadPipe, // read handle - &hWritePipe, // write handle - &lpPipeAttributes, // security attributes - 0); // pipe size - - if (bRetVal == FALSE) - { - Fail("ERROR: unable to create pipe"); - } - - /*Write to the write pipe handle*/ - bRetVal = WriteFile(hWritePipe, // handle to file - cTestString, // data buffer - (DWORD)strlen(cTestString), // number of bytes to write - &dwBytesWritten, // number of bytes written - NULL); // overlapped buffer - - if (bRetVal == FALSE) - { - Fail("ERROR: unable to write to pipe write handle " - "hWritePipe=0x%lx", hWritePipe); - } - - /*Get a file descriptor for the read pipe handle*/ - iFiledes = _open_osfhandle((long)hReadPipe, _O_RDONLY); - - if (iFiledes == -1) - { - Fail("ERROR: _open_osfhandle failed to open " - " hReadPipe=0x%lx", hReadPipe); - } - - /*Open read pipe handle in read mode*/ - fp = _fdopen(iFiledes, "r"); - - if (fp == NULL) - { - Fail("ERROR: unable to fdopen file descriptor" - " iFiledes=%d", iFiledes); - } - - /*Read from the read pipe handle*/ - if((fread(buffer, sizeof(char), strlen(cTestString), fp)) == 0) - { - Fail("ERROR: Unable to read from file stream fp=0x%lx\n", fp); - } - - /*Compare what was read with what was written.*/ - if ((memcmp(cTestString, buffer, strlen(cTestString))) != 0) - { - Fail("ERROR: read \"%s\" expected \"%s\" \n", buffer, cTestString); - } - - /*Close the file handle*/ - if (_close(iFiledes) != 0) - { - Fail("ERROR: Unable to close file handle iFiledes=%d\n", iFiledes); - } - - PAL_Terminate(); - return (PASS); -} diff --git a/src/pal/tests/palsuite/c_runtime/_fdopen/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_fdopen/test1/testinfo.dat deleted file mode 100644 index 89e48bb4c..000000000 --- a/src/pal/tests/palsuite/c_runtime/_fdopen/test1/testinfo.dat +++ /dev/null @@ -1,23 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = fdopen -Name = test for fdopen and _close -TYPE = DEFAULT -EXE1 = test1 -Description -= Tests the PAL implementation of the fdopen function. -= This will test fdopen in r (read) mode. This test -= creates and opens a test pipe, to write and read -= from. fdopen requires a file handle(int), therefore -= _open_osfhandle is used to get that handle. -= _open_osfhandle is only used with CreatePipe. The -= test will write and read from the pipe comparing -= the results. -= As a secondary test, _close is tested since it needs -= the handle returned by _open_osfhandle. The handle is -= closed, then a read is attempted on the handle which -= should fail. diff --git a/src/pal/tests/palsuite/c_runtime/_finite/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_finite/CMakeLists.txt deleted file mode 100644 index 5e1ef7f28..000000000 --- a/src/pal/tests/palsuite/c_runtime/_finite/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) diff --git a/src/pal/tests/palsuite/c_runtime/_finite/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_finite/test1/CMakeLists.txt deleted file mode 100644 index a376d45be..000000000 --- a/src/pal/tests/palsuite/c_runtime/_finite/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_finite_test1 - ${SOURCES} -) - -add_dependencies(paltest_finite_test1 coreclrpal) - -target_link_libraries(paltest_finite_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_finite/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/_finite/test1/test1.cpp deleted file mode 100644 index c815055b3..000000000 --- a/src/pal/tests/palsuite/c_runtime/_finite/test1/test1.cpp +++ /dev/null @@ -1,119 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: Checks that _finite correctly classifies all types -** of floating point numbers (NaN, -Infinity, Infinity, -** finite nonzero, unnormalized, 0, and -0) -** -**==========================================================================*/ - -#include - -/* -The IEEE double precision floating point standard looks like this: - - S EEEEEEEEEEE FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF - 0 1 11 12 63 - -S is the sign bit. The E bits are the exponent, and the 52 F bits are -the fraction. These represent a value, V. - -If E=2047 and F is nonzero, then V=NaN ("Not a number") -If E=2047 and F is zero and S is 1, then V=-Infinity -If E=2047 and F is zero and S is 0, then V=Infinity -If 0 - -/* -The IEEE single precision floating point standard looks like this: - - S EEEEEEEE FFFFFFFFFFFFFFFFFFFFFFF - 0 1 8 9 31 - -S is the sign bit. The E bits are the exponent, and the 23 F bits are -the fraction. These represent a value, V. - -If E=255 and F is nonzero, then V=NaN ("Not a number") -If E=255 and F is zero and S is 1, then V=-Infinity -If E=255 and F is zero and S is 0, then V=Infinity -If 0 - -struct testcase -{ - char relPath[50]; /* relative path array */ - int maxLength; /* pathlength to pass */ - BOOL bRet; /* TRUE if testcase expects function to return NULL */ -}; - -int __cdecl main( int argc, char **argv ) -{ - - DWORD dwOrigDirLength; - DWORD dwNewDirLength; - DWORD dwRetStrLength; - BOOL bRet; - char *retPath; - char szAbsPath[_MAX_PATH + 1]; - char szDirNameOWD[_MAX_DIR]; - char szDirNameNWD[_MAX_DIR]; - int i; - - struct testcase testcases[]= - { - {"." , _MAX_PATH, FALSE}, - {".." , _MAX_PATH, FALSE}, - {"..\\..", _MAX_PATH, FALSE}, - {"..\\..\\..", _MAX_PATH, FALSE}, - {"..", 1, TRUE} - }; - - if(0 != (PAL_Initialize(argc, argv))) - { - return ( FAIL ); - } - - for (i = 0; i < sizeof(testcases)/sizeof(struct testcase) ; i++) - { - - /* reset variables */ - memset(szAbsPath, 0, _MAX_PATH + 1); - memset(szDirNameOWD, 0, _MAX_DIR); - memset(szDirNameNWD, 0, _MAX_DIR); - - dwOrigDirLength = 0; - dwNewDirLength = 0; - dwRetStrLength = 0; - - /* Get the current directory name */ - dwOrigDirLength = GetCurrentDirectory(_MAX_PATH, szDirNameOWD); - if (0 == dwOrigDirLength) - { - Fail ("PALSUITE ERROR: _fullpath (char *, %s, %d) test failed." - "\nGetCurrentDirectory (%d, %s) call failed. GetLastError" - " returned '%d'\n", testcases[i].relPath, - testcases[i].maxLength, _MAX_PATH, szDirNameOWD, - GetLastError()); - } - - /* - * Set the current directory to relPath. - */ - bRet = SetCurrentDirectory(testcases[i].relPath); - if (0 == bRet) - { - Fail ("PALSUITE ERROR: _fullpath (char *, %s, %d) test failed." - "\nSetCurrentDirectory (%s) call failed. GetLastError" - " returned '%d'\n", testcases[i].relPath, - testcases[i].maxLength, testcases[i].relPath, - GetLastError()); - } - - /* Get the new current directory name */ - dwNewDirLength = GetCurrentDirectory(_MAX_PATH, szDirNameNWD); - if (0 == dwNewDirLength) - { - Fail ("PALSUITE ERROR: _fullpath (char *, %s, %d) test failed." - "\nGetCurrentDirectory(%d, %s) call failed. GetLastError" - " returned '%d'\n", testcases[i].relPath, - testcases[i].maxLength, _MAX_PATH, szDirNameNWD, - GetLastError()); - } - - /* Set the current directory back to the original one */ - bRet = SetCurrentDirectory(szDirNameOWD); - if (0 == bRet) - { - Fail ("PALSUITE ERROR: _fullpath (char *, %s, %d) test failed." - "\nSetCurrentDirectory(%s) call failed. GetLastError" - " returned '%d'\n", testcases[i].relPath, - testcases[i].maxLength, szDirNameOWD, GetLastError()); - } - - retPath = _fullpath( szAbsPath, - testcases[i].relPath, - testcases[i].maxLength ); - - if ( NULL == retPath ) - { - /* The function returned NULL when a value was expected */ - if ( FALSE == testcases[i].bRet ) - { - Fail("PALSUITE ERROR: test failed.\n" - "_fullpath (char *, %s, %d) returned NULL\n" - "when '%s' was expected\n", testcases[i].relPath, - testcases[i].maxLength, szDirNameNWD ); - } - } - else - { - dwRetStrLength = strlen ( szAbsPath ); - - /* Check that the path lengths are identical. */ - if ( dwRetStrLength != dwNewDirLength ) - { - Fail ("PALSUITE ERROR: _fullpath (char *, %s, %d) test failed." - "\ndwRetStringLength '%d' is not equal to " - "dwNewDirLength '%d'.\nszAbsPath is '%s' retPath is '%s'\n" - "szDirNameNWD is '%s'\n" , testcases[i].relPath, - testcases[i].maxLength, dwRetStrLength ,dwNewDirLength - ,szAbsPath ,retPath ,szDirNameNWD); - } - - /* - * Perform a string comparison on the path provided by - * GetCurrentDirectory and the path provided by _fullpath - * to ensure they are identical. - */ - if ( 0 != strncmp( szDirNameNWD, szAbsPath, dwNewDirLength )) - { - Fail ("PALSUITE ERROR: _fullpath (char *, %s, %d) test failed." - "strncmp ( %s, %s, %d ) call failed.\n", - testcases[i].relPath, testcases[i].maxLength, - szDirNameNWD, szAbsPath, dwNewDirLength ); - } - - /* - * Perform a string comparison on both paths provided by - * _fullpath to ensure they are identical. - */ - if ( 0 != strncmp( retPath, szAbsPath, dwNewDirLength )) - { - Fail ("PALSUITE ERROR: _fullpath (char *, %s, %d) test failed." - "strncmp ( %s, %s, %d ) call failed.\n", - testcases[i].relPath, testcases[i].maxLength, - szDirNameNWD, szAbsPath, dwNewDirLength ); - } - } - } - - PAL_Terminate(); - return ( PASS ); -} - - - - - diff --git a/src/pal/tests/palsuite/c_runtime/_fullpath/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_fullpath/test1/testinfo.dat deleted file mode 100644 index cd4db831a..000000000 --- a/src/pal/tests/palsuite/c_runtime/_fullpath/test1/testinfo.dat +++ /dev/null @@ -1,23 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = c_runtime -Function = _fullpath -Name = Positive Test for _fullpath -TYPE = DEFAULT -EXE1 = test1 -Description -= Test to see if the _fullpath function returns the -= proper values. A check is done to ensure NULL is returned -= by _fullpath only for the condition where the length of the -= created absolute path name (absPath) is greater than -= maxLength. - - - - - - - diff --git a/src/pal/tests/palsuite/c_runtime/_gcvt/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_gcvt/CMakeLists.txt deleted file mode 100644 index ef14ea535..000000000 --- a/src/pal/tests/palsuite/c_runtime/_gcvt/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) - diff --git a/src/pal/tests/palsuite/c_runtime/_gcvt/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_gcvt/test1/CMakeLists.txt deleted file mode 100644 index 25c652dfc..000000000 --- a/src/pal/tests/palsuite/c_runtime/_gcvt/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - _gcvt.cpp -) - -add_executable(paltest_gcvt_test1 - ${SOURCES} -) - -add_dependencies(paltest_gcvt_test1 coreclrpal) - -target_link_libraries(paltest_gcvt_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_gcvt/test1/_gcvt.cpp b/src/pal/tests/palsuite/c_runtime/_gcvt/test1/_gcvt.cpp deleted file mode 100644 index ccfc28689..000000000 --- a/src/pal/tests/palsuite/c_runtime/_gcvt/test1/_gcvt.cpp +++ /dev/null @@ -1,58 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: _gcvt.c -** -** Purpose: Positive test the _gcvt API. -** Call _gcvt to convert a floatable value to a string -** with specified sigficant digits stored -** -** -**============================================================*/ -#include - -int __cdecl main(int argc, char *argv[]) -{ - int err; - double dValue = -3.1415926535; - char buffer[1024]; - char *pChar7 = "-3.141593"; - - /*Initialize the PAL environment*/ - err = PAL_Initialize(argc, argv); - if(0 != err) - { - return FAIL; - } - - - /* zero the buffer */ - memset(buffer, 0, 1024); - - - /* - - Testing - ======= - - To convert a floating-point value to - a string to save 7 significant digits - */ - _gcvt(dValue, 7, buffer); - if(strcmp(pChar7, buffer)) - { - Fail("\nFailed to call _gcvt to convert a floating-point value " - "to a string with 7 sigficants digits stored\n"); - } - - - /* - Clean up and exit - */ - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/_gcvt/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_gcvt/test1/testinfo.dat deleted file mode 100644 index d52741810..000000000 --- a/src/pal/tests/palsuite/c_runtime/_gcvt/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = _gcvt -Name = Positive test for _gcvt API to convert a floatable value to a string -TYPE = DEFAULT -EXE1 = _gcvt -Description -=Test the _gcvt to convert a floatable value to a string -=with specified sigficant digits stored diff --git a/src/pal/tests/palsuite/c_runtime/_gcvt/test2/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_gcvt/test2/CMakeLists.txt deleted file mode 100644 index b77bff9cd..000000000 --- a/src/pal/tests/palsuite/c_runtime/_gcvt/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test2.cpp -) - -add_executable(paltest_gcvt_test2 - ${SOURCES} -) - -add_dependencies(paltest_gcvt_test2 coreclrpal) - -target_link_libraries(paltest_gcvt_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_gcvt/test2/test2.cpp b/src/pal/tests/palsuite/c_runtime/_gcvt/test2/test2.cpp deleted file mode 100644 index 7ac9a4fcf..000000000 --- a/src/pal/tests/palsuite/c_runtime/_gcvt/test2/test2.cpp +++ /dev/null @@ -1,83 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test2.c -** -** Purpose: Call the _gcvt function on a number of cases. Check that it -** handles negatives, exponents and hex digits properly. Also check that -** the 'digit' specification works. (And that it doesn't truncate negative -** signs or decimals) -** -** -**===================================================================*/ - -#include - -struct testCase -{ - double Value; - int Digits; - char WinCorrectResult[128]; - char BsdCorrectResult[128]; /* for the odd case where bsd sprintf - varies from windows sprintf */ -}; - -int __cdecl main(int argc, char **argv) -{ - char result[128]; - int i=0; - - struct testCase testCases[] = - { - {1234567, 7, "1234567"}, - {1234.123, 7, "1234.123"}, - {1234.1234, 7, "1234.123"}, - {12.325678e+2, 7, "1232.568"}, - {-12.3233333, 8, "-12.323333"}, - {-12.32, 8, "-12.32"}, - {-12.32e+2, 8, "-1232.", "-1232" }, - {0x21DDFABC, 8, "5.6819577e+008", "5.6819577e+08" }, - {123456789012345.0, 15, "123456789012345" }, - {12340000.0, 8, "12340000"}, - {12340000000000000.0, 15, "1.234e+016", "1.234e+16" }, - {12340000000000000.0, 17, "12340000000000000" }, - - }; - - if (0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - /* Loop through each case. Call _gcvt on each test case and check the - result. - */ - - for(i = 0; i < sizeof(testCases) / sizeof(struct testCase); i++) - { - _gcvt(testCases[i].Value, testCases[i].Digits, result); - - if (strcmp(testCases[i].WinCorrectResult, result) != 0 && - - ( testCases[i].BsdCorrectResult && - strcmp(testCases[i].BsdCorrectResult, result) != 0 ) ) - { - Fail("ERROR: _gcvt attempted to convert %f with %d digits " - "signifigant, which resulted in " - "the string '%s' instead of the correct(Win) string '%s' or the" - "correct(bsd) string '%s'.\n", - testCases[i].Value, - testCases[i].Digits, - result, - testCases[i].WinCorrectResult, - testCases[i].BsdCorrectResult); - } - - memset(result, '\0', 128); - } - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/_gcvt/test2/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_gcvt/test2/testinfo.dat deleted file mode 100644 index e9e192849..000000000 --- a/src/pal/tests/palsuite/c_runtime/_gcvt/test2/testinfo.dat +++ /dev/null @@ -1,15 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = _gcvt -Name = Call _gcvt on normal values, negatives, exponents and hex digits. -TYPE = DEFAULT -EXE1 = test2 -Description -= Call the _gcvt function on a number of cases. Check that it -= handles negatives, exponents and hex digits properly. Also check that -= the 'digit' specification works. (And that it doesn't truncate negative -= signs or decimals) diff --git a/src/pal/tests/palsuite/c_runtime/_isnan/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_isnan/CMakeLists.txt deleted file mode 100644 index 5e1ef7f28..000000000 --- a/src/pal/tests/palsuite/c_runtime/_isnan/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) diff --git a/src/pal/tests/palsuite/c_runtime/_isnan/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_isnan/test1/CMakeLists.txt deleted file mode 100644 index 8c949ed00..000000000 --- a/src/pal/tests/palsuite/c_runtime/_isnan/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_isnan_test1 - ${SOURCES} -) - -add_dependencies(paltest_isnan_test1 coreclrpal) - -target_link_libraries(paltest_isnan_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_isnan/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/_isnan/test1/test1.cpp deleted file mode 100644 index d793c9b37..000000000 --- a/src/pal/tests/palsuite/c_runtime/_isnan/test1/test1.cpp +++ /dev/null @@ -1,115 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: -** Test _isnan with a number of trivial values, to ensure they indicated that -** they are numbers. Then try with Positive/Negative Infinite, which should -** also be numbers. Finally set the least and most significant bits of -** the fraction to positive and negative, at which point it should return -** the true value. -** -**==========================================================================*/ - -#include - -#define TO_DOUBLE(x) (*((double*)((void*)&x))) -#define TO_I64(x) (*((INT64*)((void*)&x))) - -/* - * NaN: any double with maximum exponent (0x7ff) and non-zero fraction - */ -int __cdecl main(int argc, char *argv[]) -{ - /* - * Initialize the PAL and return FAIL if this fails - */ - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - /* - * Try some trivial values - */ - if (_isnan(0.0)) - { - Fail("_isnan() incorrectly identified %f as NaN!\n", 0.0); - } - - if (_isnan(1.23456)) - { - Fail("_isnan() incorrectly identified %f as NaN!\n", 1.234567); - } - - if (_isnan(42.0)) - { - Fail("_isnan() incorrectly identified %f as NaN!\n", 42.0); - } - - UINT64 lneginf = UI64(0xfff0000000000000); - UINT64 lposinf = UI64(0x7ff0000000000000); - - double neginf = TO_DOUBLE(lneginf); - double posinf = TO_DOUBLE(lposinf); - - /* - * Try positive and negative infinity - */ - if (_isnan(neginf)) - { - Fail("_isnan() incorrectly identified negative infinity as NaN!\n"); - } - - if (_isnan(posinf)) - { - Fail("_isnan() incorrectly identified infinity as NaN!\n"); - } - - /* - * Try setting the least significant bit of the fraction, - * positive and negative - */ - UINT64 lsnan = UI64(0xfff0000000000001); - double snan = TO_DOUBLE(lsnan); - - if (!_isnan(snan)) - { - Fail("_isnan() failed to identify %I64x as NaN!\n", lsnan); - } - - UINT64 lqnan = UI64(0x7ff0000000000001); - double qnan = TO_DOUBLE(lqnan); - - if (!_isnan(qnan)) - { - Fail("_isnan() failed to identify %I64x as NaN!\n", lqnan); - } - - /* - * Try setting the most significant bit of the fraction, - * positive and negative - */ - lsnan = UI64(0xfff8000000000000); - snan = TO_DOUBLE(lsnan); - - if (!_isnan(snan)) - { - Fail ("_isnan() failed to identify %I64x as NaN!\n", lsnan); - } - - lqnan = UI64(0x7ff8000000000000); - qnan = TO_DOUBLE(lqnan); - - if (!_isnan(qnan)) - { - Fail ("_isnan() failed to identify %I64x as NaN!\n", lqnan); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/_isnan/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_isnan/test1/testinfo.dat deleted file mode 100644 index d5de17e21..000000000 --- a/src/pal/tests/palsuite/c_runtime/_isnan/test1/testinfo.dat +++ /dev/null @@ -1,16 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = _isnan -Name = Test #1 for _isnan -TYPE = DEFAULT -EXE1 = test1 -Description -= Test _isnan with a number of trivial values, to ensure they indicated that -= they are numbers. Then try with Positive/Negative Infinite, which should -= also be numbers. Finally set the least and most significant bits of -= the fraction to positive and negative, at which point it should return -= the true value. diff --git a/src/pal/tests/palsuite/c_runtime/_isnanf/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_isnanf/CMakeLists.txt deleted file mode 100644 index 5e1ef7f28..000000000 --- a/src/pal/tests/palsuite/c_runtime/_isnanf/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) diff --git a/src/pal/tests/palsuite/c_runtime/_isnanf/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_isnanf/test1/CMakeLists.txt deleted file mode 100644 index 485c30ec3..000000000 --- a/src/pal/tests/palsuite/c_runtime/_isnanf/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.c -) - -add_executable(paltest_isnanf_test1 - ${SOURCES} -) - -add_dependencies(paltest_isnanf_test1 coreclrpal) - -target_link_libraries(paltest_isnanf_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_isnanf/test1/test1.c b/src/pal/tests/palsuite/c_runtime/_isnanf/test1/test1.c deleted file mode 100644 index 9b75a7236..000000000 --- a/src/pal/tests/palsuite/c_runtime/_isnanf/test1/test1.c +++ /dev/null @@ -1,115 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: -** Test _isnanf with a number of trivial values, to ensure they indicated that -** they are numbers. Then try with Positive/Negative Infinite, which should -** also be numbers. Finally set the least and most significant bits of -** the fraction to positive and negative, at which point it should return -** the true value. -** -**==========================================================================*/ - -#include - -#define TO_FLOAT(x) (*((float*)((void*)&x))) -#define TO_I32(x) (*((INT32*)((void*)&x))) - -/* - * NaN: any float with maximum exponent (0x7f8) and non-zero fraction - */ -int __cdecl main(int argc, char *argv[]) -{ - /* - * Initialize the PAL and return FAIL if this fails - */ - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - /* - * Try some trivial values - */ - if (_isnanf(0.0f)) - { - Fail("_isnanf() incorrectly identified %f as NaN!\n", 0.0f); - } - - if (_isnanf(1.234567f)) - { - Fail("_isnanf() incorrectly identified %f as NaN!\n", 1.234567f); - } - - if (_isnanf(42.0f)) - { - Fail("_isnanf() incorrectly identified %f as NaN!\n", 42.0f); - } - - UINT32 lneginf = 0xff800000u; - UINT32 lposinf = 0x7f800000u; - - float neginf = TO_FLOAT(lneginf); - float posinf = TO_FLOAT(lposinf); - - /* - * Try positive and negative infinity - */ - if (_isnanf(neginf)) - { - Fail("_isnanf() incorrectly identified negative infinity as NaN!\n"); - } - - if (_isnanf(posinf)) - { - Fail("_isnanf() incorrectly identified infinity as NaN!\n"); - } - - /* - * Try setting the least significant bit of the fraction, - * positive and negative - */ - UINT32 lsnan = 0xff800001u; - float snan = TO_FLOAT(lsnan); - - if (!_isnanf(snan)) - { - Fail("_isnanf() failed to identify %I32x as NaN!\n", lsnan); - } - - UINT32 lqnan = 0x7f800001u; - float qnan = TO_FLOAT(lqnan); - - if (!_isnanf(qnan)) - { - Fail("_isnanf() failed to identify %I32x as NaN!\n", lqnan); - } - - /* - * Try setting the most significant bit of the fraction, - * positive and negative - */ - lsnan = 0xffc00000u; - snan = TO_FLOAT(lsnan); - - if (!_isnanf(snan)) - { - Fail ("_isnanf() failed to identify %I32x as NaN!\n", lsnan); - } - - lqnan = 0x7fc00000u; - qnan = TO_FLOAT(lqnan); - - if (!_isnanf(qnan)) - { - Fail ("_isnanf() failed to identify %I32x as NaN!\n", lqnan); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/_isnanf/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_isnanf/test1/testinfo.dat deleted file mode 100644 index 22b0edbd7..000000000 --- a/src/pal/tests/palsuite/c_runtime/_isnanf/test1/testinfo.dat +++ /dev/null @@ -1,16 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = _isnanf -Name = Test #1 for _isnanf -TYPE = DEFAULT -EXE1 = test1 -Description -= Test _isnanf with a number of trivial values, to ensure they indicated that -= they are numbers. Then try with Positive/Negative Infinite, which should -= also be numbers. Finally set the least and most significant bits of -= the fraction to positive and negative, at which point it should return -= the true value. diff --git a/src/pal/tests/palsuite/c_runtime/_itow/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_itow/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/c_runtime/_itow/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/c_runtime/_itow/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_itow/test1/CMakeLists.txt deleted file mode 100644 index bbeeb484e..000000000 --- a/src/pal/tests/palsuite/c_runtime/_itow/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_itow_test1 - ${SOURCES} -) - -add_dependencies(paltest_itow_test1 coreclrpal) - -target_link_libraries(paltest_itow_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_itow/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/_itow/test1/test1.cpp deleted file mode 100644 index 01f32f252..000000000 --- a/src/pal/tests/palsuite/c_runtime/_itow/test1/test1.cpp +++ /dev/null @@ -1,101 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test1.c -** -** Purpose: Tests the PAL implementation of the _itow_s function. -** Test a number of ints with different radix on each, -** to ensure that the string returned is correct. -** -** -**===================================================================*/ - -#define UNICODE - -#include - -struct testCase -{ - wchar_t *CorrectResult; - int value; - int radix; -}; - -int __cdecl main(int argc, char **argv) -{ - - wchar_t result[20]; - wchar_t *pResult = NULL; - char *PrintResult = NULL; /* Use with convertC so we can */ - char *PrintCorrectResult = NULL; /* print out the results */ - int i = 0; - - WCHAR case1[] = {'5','0','\0'}; - WCHAR case2[] = {'5','5','5','\0'}; - WCHAR case3[] = {'1','0','1','0','\0'}; - WCHAR case4[] = {'2','2','\0'}; - WCHAR case5[] = {'a','\0'}; - WCHAR case6[] = {'c','g','\0'}; - - /* Correct Result, Value to Convert, Radix to use */ - struct testCase testCases[] = - { - {case1, 50, 10}, - {case2,555,10}, - {case3,10,2}, - {case4,10,4}, - {case5,10,16}, - {case6,400,32} - }; - - /* - * Initialize the PAL and return FAIL if this fails - */ - if (0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - /* Loop through each case. Convert the ints to strings. Check - to ensure they were converted properly. - */ - - for(i = 0; i < sizeof(testCases) / sizeof(struct testCase); i++) - { - errno_t err = _itow_s(testCases[i].value, result, sizeof(result) / sizeof(result[0]), testCases[i].radix); - - if(err != 0) - { - Fail("ERROR: _itow_s didn't return success, error code %d.\n", err); - } - - if (0 != wcscmp(testCases[i].CorrectResult, result)) - { - PrintResult = convertC(pResult); - PrintCorrectResult = convertC(testCases[i].CorrectResult); - Fail("ERROR: _itow_s was called on %i, returning the string %s " - "when it should have returned the string %s.\n" - , testCases[i].value, PrintResult, PrintCorrectResult); - } - - } - - PAL_Terminate(); - return PASS; -} - - - - - - - - - - - - - diff --git a/src/pal/tests/palsuite/c_runtime/_itow/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_itow/test1/testinfo.dat deleted file mode 100644 index 91f0e62e0..000000000 --- a/src/pal/tests/palsuite/c_runtime/_itow/test1/testinfo.dat +++ /dev/null @@ -1,18 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = _itow_s -Name = Positive Test for _itow_s -TYPE = DEFAULT -EXE1 = test1 -Description -= Tests the PAL implementation of the _itow_s function. -= Test a number of ints with different radix on each, to ensure that the -= string returned is correct. - - - - diff --git a/src/pal/tests/palsuite/c_runtime/_mbsdec/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_mbsdec/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/c_runtime/_mbsdec/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/c_runtime/_mbsdec/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_mbsdec/test1/CMakeLists.txt deleted file mode 100644 index 96319ac3b..000000000 --- a/src/pal/tests/palsuite/c_runtime/_mbsdec/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_mbsdec_test1 - ${SOURCES} -) - -add_dependencies(paltest_mbsdec_test1 coreclrpal) - -target_link_libraries(paltest_mbsdec_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_mbsdec/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/_mbsdec/test1/test1.cpp deleted file mode 100644 index 1cd751329..000000000 --- a/src/pal/tests/palsuite/c_runtime/_mbsdec/test1/test1.cpp +++ /dev/null @@ -1,77 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: -** Ensure that this function moves the string pointer back one character. -** First do a basic test to check that the pointer gets moved back the one -** character, given str1 and str+1 as params. Then try with both -** params being the same pointer, which should return NULL. Also test -** when the first pointer is past the second pointer, which should -** return null. Finally try this function on an array of single bytes, -** which it assumes are characters and should work in the same fashion. -** -** -**==========================================================================*/ - -#include - -/* - * Note: it seems like these functions would only be useful if they - * didn't assume a character was equivalent to a single byte. Be that - * as it may, I haven't seen a way to get it to behave otherwise. - */ - -int __cdecl main(int argc, char *argv[]) -{ - unsigned char *str1 = (unsigned char*) "foo"; - unsigned char str2[] = {0xC0, 0x80, 0xC0, 0x80, 0}; - unsigned char str3[] = {0}; - unsigned char *ret = NULL; - - /* - * Initialize the PAL and return FAIL if this fails - */ - if (0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - ret = _mbsdec(str1,str1+1); - if (ret != str1) - { - Fail ("ERROR: _mbsdec returned %p. Expected %p\n", ret, str1); - } - - ret = _mbsdec(str1,str1); - if (ret != NULL) - { - Fail ("ERROR: _mbsdec returned %p. Expected %p\n", ret, NULL); - } - - ret = _mbsdec(str1+100,str1); - if (ret != NULL) - { - Fail ("ERROR: _mbsdec returned %p. Expected %p\n", ret, NULL); - } - - ret = _mbsdec(str2,str2+1); - if (ret != str2) - { - Fail ("ERROR: _mbsdec returned %p. Expected %p\n", ret, str2+1); - } - - ret = _mbsdec(str3,str3+10); - if (ret != str3+9) - { - Fail ("ERROR: _mbsdec returned %p. Expected %p\n", ret, str3+9); - } - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/c_runtime/_mbsdec/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_mbsdec/test1/testinfo.dat deleted file mode 100644 index ce2aa29aa..000000000 --- a/src/pal/tests/palsuite/c_runtime/_mbsdec/test1/testinfo.dat +++ /dev/null @@ -1,18 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = _mbsdec -Name = Positive Test for _mbsdec -TYPE = DEFAULT -EXE1 = test1 -Description -= Ensure that this function moves the string pointer back one character. -= First do a basic test to check that the pointer gets moved back the one -= character, given str1 and str+1 as params. Then try with both -= params being the same pointer, which should return NULL. Also test -= when the first pointer is past the second pointer, which should -= return null. Finally try this function on an array of single bytes, -= which it assumes are characters and should work in the same fashion. diff --git a/src/pal/tests/palsuite/c_runtime/_mbsinc/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_mbsinc/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/c_runtime/_mbsinc/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/c_runtime/_mbsinc/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_mbsinc/test1/CMakeLists.txt deleted file mode 100644 index 7e3a015e5..000000000 --- a/src/pal/tests/palsuite/c_runtime/_mbsinc/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_mbsinc_test1 - ${SOURCES} -) - -add_dependencies(paltest_mbsinc_test1 coreclrpal) - -target_link_libraries(paltest_mbsinc_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_mbsinc/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/_mbsinc/test1/test1.cpp deleted file mode 100644 index 95a5041af..000000000 --- a/src/pal/tests/palsuite/c_runtime/_mbsinc/test1/test1.cpp +++ /dev/null @@ -1,62 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: -** Ensure that this function moves the string pointer ahead one character. -** First do a basic test to check that the pointer gets moved ahead the one -** character. Then try with an array of bytes and a NULL array. Each of -** these should still work by returning a pointer to thePointer+1. -** -** -**==========================================================================*/ - -#include - -/* - * Note: it seems like these functions would only be useful if they - * didn't assume a character was equivalent to a single byte. Be that - * as it may, I haven't seen a way to get it to behave otherwise. - */ - -int __cdecl main(int argc, char *argv[]) -{ - unsigned char *str1 = (unsigned char*) "foo"; - unsigned char str2[] = {0xC0, 0x80, 0xC0, 0x80, 0}; - unsigned char str3[] = {0}; - unsigned char *ret=NULL; - - /* - * Initialize the PAL and return FAIL if this fails - */ - if (0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - ret = _mbsinc(str1); - if (ret != str1 + 1) - { - Fail ("ERROR: _mbsinc returned %p. Expected %p\n", ret, str1); - } - - ret = _mbsinc(str2); - if (ret != str2 + 1) - { - Fail ("ERROR: _mbsinc returned %p. Expected %p\n", ret, str1); - } - - ret = _mbsinc(str3); - if (ret != str3 + 1) - { - Fail ("ERROR: _mbsinc returned %p. Expected %p\n", ret, str1); - } - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/c_runtime/_mbsinc/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_mbsinc/test1/testinfo.dat deleted file mode 100644 index 3f3883fa3..000000000 --- a/src/pal/tests/palsuite/c_runtime/_mbsinc/test1/testinfo.dat +++ /dev/null @@ -1,15 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = _mbsinc -Name = Positive Test for _mbsinc -TYPE = DEFAULT -EXE1 = test1 -Description -= Ensure that this function moves the string pointer ahead one character. -= First do a basic test to check that the pointer gets moved ahead the one -= character. Then try with an array of bytes and a NULL array. Each of -= these should still work by returning a pointer to thePointer+1. diff --git a/src/pal/tests/palsuite/c_runtime/_mbsninc/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_mbsninc/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/c_runtime/_mbsninc/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/c_runtime/_mbsninc/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_mbsninc/test1/CMakeLists.txt deleted file mode 100644 index 26a44c901..000000000 --- a/src/pal/tests/palsuite/c_runtime/_mbsninc/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_mbsninc_test1 - ${SOURCES} -) - -add_dependencies(paltest_mbsninc_test1 coreclrpal) - -target_link_libraries(paltest_mbsninc_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_mbsninc/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/_mbsninc/test1/test1.cpp deleted file mode 100644 index 59ef50dcc..000000000 --- a/src/pal/tests/palsuite/c_runtime/_mbsninc/test1/test1.cpp +++ /dev/null @@ -1,65 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: -** Ensure that this functions increases a string pointer by n characters. -** Use a for loop, and increase the pointer by a different number of characters -** on each iteration, ensure that it is indeed pointing to the correct location -** each time. The second test checks to see if you attempt to increase the -** pointer past the end of the string, the pointer should just point at the -** last character. -** -** -**==========================================================================*/ - -#include - -/* - * Note: it seems like these functions would only be useful if they - * didn't assume a character was equivalent to a single byte. Be that - * as it may, I haven't seen a way to get it to behave otherwise. - */ - -int __cdecl main(int argc, char *argv[]) -{ - unsigned char str[] = {0xC0, 0x80, 0xC0, 0x80, 0}; - int i=0; - unsigned char *ret=NULL; - - /* - * Initialize the PAL and return FAIL if this fails - */ - if (0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - for (i=0; i<5; i++) - { - ret = _mbsninc(str, i); - if (ret != str + i) - { - Fail ("ERROR: _mbsninc returned %p. Expected %p\n", ret, str+i); - } - } - - /* - * trying to advance past the end of the string should just - * return the end. - */ - ret = _mbsninc(str, 5); - if (ret != str + 4) - { - Fail ("ERROR: _mbsninc returned %p. Expected %p\n", ret, str+4); - } - - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/c_runtime/_mbsninc/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_mbsninc/test1/testinfo.dat deleted file mode 100644 index b855222af..000000000 --- a/src/pal/tests/palsuite/c_runtime/_mbsninc/test1/testinfo.dat +++ /dev/null @@ -1,17 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = _mbsninc -Name = Positive Test for _mbsninc -TYPE = DEFAULT -EXE1 = test1 -Description -= Ensure that this functions increases a string pointer by n characters. -= Use a for loop, and increase the pointer by a different number of characters -= on each iteration, ensure that it is indeed pointing to the correct location -= each time. The second test checks to see if you attempt to increase the -= pointer past the end of the string, the pointer should just point at the -= last character. diff --git a/src/pal/tests/palsuite/c_runtime/_open_osfhandle/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_open_osfhandle/CMakeLists.txt deleted file mode 100644 index ef14ea535..000000000 --- a/src/pal/tests/palsuite/c_runtime/_open_osfhandle/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) - diff --git a/src/pal/tests/palsuite/c_runtime/_open_osfhandle/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_open_osfhandle/test1/CMakeLists.txt deleted file mode 100644 index 503a6d928..000000000 --- a/src/pal/tests/palsuite/c_runtime/_open_osfhandle/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_open_osfhandle_test1 - ${SOURCES} -) - -add_dependencies(paltest_open_osfhandle_test1 coreclrpal) - -target_link_libraries(paltest_open_osfhandle_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_open_osfhandle/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/_open_osfhandle/test1/test1.cpp deleted file mode 100644 index ee2c8ea41..000000000 --- a/src/pal/tests/palsuite/c_runtime/_open_osfhandle/test1/test1.cpp +++ /dev/null @@ -1,132 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test1.c (_open_osfhandle) -** -** Purpose: Tests the PAL implementation of the _open_osfhandle function. -** This API accepts a OS Handle returned from CreatePipe() and -** a flag of _O_RDONLY and returns a C Run-Time handle. The test -** will write to the pipe and pass the C Run-Time handle to _fdopen -** to open the Read Handle to compare what was written with what -** was wrote. They should be the same. -** -** Depends: CreatePipe -** WriteFile -** _fdopen -** fread -** memcmp -** fclose -** strlen -** CloseHandle -** -** -**===================================================================*/ - -#include - -const char* cTestString = "one fish, two fish, red fish, blue fish."; - -int __cdecl main(int argc, char **argv) -{ - HANDLE hReadPipe = NULL; - HANDLE hWritePipe = NULL; - BOOL bRetVal = FALSE; - int iFiledes = 0; - DWORD dwBytesWritten; - char buffer[45]; - FILE *fp; - size_t len; - - SECURITY_ATTRIBUTES lpPipeAttributes; - - /*Initialize the PAL*/ - if ((PAL_Initialize(argc, argv)) != 0) - { - return (FAIL); - } - - /*Setup SECURITY_ATTRIBUTES structure for CreatePipe*/ - lpPipeAttributes.nLength = sizeof(lpPipeAttributes); - lpPipeAttributes.lpSecurityDescriptor = NULL; - lpPipeAttributes.bInheritHandle = TRUE; - - /*Create a Pipe*/ - bRetVal = CreatePipe(&hReadPipe, /* read handle*/ - &hWritePipe, /* write handle */ - &lpPipeAttributes, /* security attributes*/ - 0); /* pipe size*/ - if (bRetVal == FALSE) - { - Fail("ERROR: unable to create pipe"); - } - - /*Write to the write pipe handle*/ - bRetVal = WriteFile(hWritePipe, /* handle to file*/ - cTestString, /* data buffer*/ - strlen(cTestString),/* number of bytes to write*/ - &dwBytesWritten, /* number of bytes written*/ - NULL); /* overlapped buffer*/ - if (bRetVal == FALSE) - { - Fail("ERROR: unable to write to pipe write handle " - "hWritePipe=0x%lx", hWritePipe); - } - - /*Test to see if the WriteFile wrote the correct amount*/ - if(dwBytesWritten != strlen(cTestString)) - { - Fail("Error: WriteFile wrote \"%d\", should have written \"%d\\n", - dwBytesWritten, strlen(cTestString)); - } - - /*Get a file descriptor for the read pipe handle. - *This is what we are testing.*/ - iFiledes = _open_osfhandle((long)hReadPipe, _O_RDONLY); - if (iFiledes == -1) - { - Fail("ERROR: _open_osfhandle failed to open " - " hReadPipe=0x%lx", hReadPipe); - } - - /*Open read pipe handle in read mode. - *Verify that we have returned a correct, - *C Run-time handle*/ - fp = _fdopen(iFiledes, "r"); - if (fp == NULL) - { - Fail("ERROR: unable to fdopen file descriptor" - " iFiledes=%d", iFiledes); - } - - /*Read from the read pipe handle*/ - len = fread(buffer, sizeof(char), strlen(cTestString), fp); - if((len == 0) || (len != strlen(cTestString))) - { - Fail("ERROR: Unable to read from file stream fp=0x%lx\n", fp); - } - - /*Compare what was read with what was written.*/ - if ((memcmp(cTestString, buffer, strlen(cTestString))) != 0) - { - Fail("ERROR: read \"%s\" expected \"%s\" \n", buffer, cTestString); - } - - /*Close write pipe handle*/ - if (CloseHandle(hWritePipe) == 0) - { - Fail("ERROR: Unable to close write pipe handle " - "hWritePipe=0x%lx", hWritePipe); - } - - if ((fclose(fp)) != 0) - { - Fail("ERROR: Unable to close C-Runtime handle " - "iFilesdes=%d", iFiledes); - } - - PAL_Terminate(); - return (PASS); -} diff --git a/src/pal/tests/palsuite/c_runtime/_open_osfhandle/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_open_osfhandle/test1/testinfo.dat deleted file mode 100644 index 16317bb18..000000000 --- a/src/pal/tests/palsuite/c_runtime/_open_osfhandle/test1/testinfo.dat +++ /dev/null @@ -1,17 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = _open_osfhandle -Name = Test for _open_osfhandle -TYPE = DEFAULT -EXE1 = test1 -Description -= Tests the PAL implementation of the _open_osfhandle function. -= This API accepts a OS Handle returned from CreatePipe() and -= a flag of _O_RDONLY and returns a C Run-Time handle. The test -= will write to the pipe and pass the C Run-Time handle to _fdopen -= to open the Read Handle to compare what was written with what -= was wrote. They should be the same. diff --git a/src/pal/tests/palsuite/c_runtime/_open_osfhandle/test2/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_open_osfhandle/test2/CMakeLists.txt deleted file mode 100644 index e37cec2db..000000000 --- a/src/pal/tests/palsuite/c_runtime/_open_osfhandle/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test2.cpp -) - -add_executable(paltest_open_osfhandle_test2 - ${SOURCES} -) - -add_dependencies(paltest_open_osfhandle_test2 coreclrpal) - -target_link_libraries(paltest_open_osfhandle_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_open_osfhandle/test2/test2.cpp b/src/pal/tests/palsuite/c_runtime/_open_osfhandle/test2/test2.cpp deleted file mode 100644 index 6c756b177..000000000 --- a/src/pal/tests/palsuite/c_runtime/_open_osfhandle/test2/test2.cpp +++ /dev/null @@ -1,86 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test2.c (_open_osfhandle) -** -** Purpose: Tests the PAL implementation of the _open_osfhandle function. -** This API accepts a OS Handle returned from CreatePipe() and -** a flag of _O_RDONLY and returns a C Run-Time handle. The test -** will pass a NULL handle, and unsupported flags. All cases -** should fail. -** -** Depends: CreatePipe -** CloseHandle -** -** -**===================================================================*/ - -#include - -int __cdecl main(int argc, char **argv) -{ - HANDLE hReadPipe = NULL; - HANDLE hWritePipe = NULL; - BOOL bRetVal = FALSE; - int iFiledes = 0; - - SECURITY_ATTRIBUTES lpPipeAttributes; - - /*Initialize the PAL*/ - if ((PAL_Initialize(argc, argv)) != 0) - { - return (FAIL); - } - - /*Setup SECURITY_ATTRIBUTES structure for CreatePipe*/ - lpPipeAttributes.nLength = sizeof(lpPipeAttributes); - lpPipeAttributes.lpSecurityDescriptor = NULL; - lpPipeAttributes.bInheritHandle = TRUE; - - /*Create a Pipe*/ - bRetVal = CreatePipe(&hReadPipe, /* read handle*/ - &hWritePipe, /* write handle */ - &lpPipeAttributes, /* security attributes*/ - 0); /* pipe size*/ - if (bRetVal == FALSE) - { - Fail("ERROR: unable to create pipe"); - } - - /*Close write pipe handle*/ - if (CloseHandle(hWritePipe) == 0) - { - Fail("ERROR: Unable to close write pipe handle " - "hWritePipe=0x%lx", hWritePipe); - } - - /*Close read pipe handle*/ - if (CloseHandle(hReadPipe) == 0) - { - Fail("ERROR: Unable to close read pipe handle " - "hReadPipe=0x%lx", hReadPipe); - } - - /*Test with a Closed handle and supported flag _O_RDONLY*/ - iFiledes = _open_osfhandle((long)hReadPipe, _O_RDONLY); - if (iFiledes != -1) - { - Fail("ERROR: _open_osfhandle successfullly opened " - " hReadPipe which was closed, with _O_RDONLY"); - } - - /*Test with a NULL handle and supported flag _O_RDONLY*/ - hReadPipe = NULL; - iFiledes = _open_osfhandle((long)hReadPipe, _O_RDONLY); - if (iFiledes != -1) - { - Fail("ERROR: _open_osfhandle successfullly opened " - " hReadPipe=NULL with _O_RDONLY"); - } - - PAL_Terminate(); - return (PASS); -} diff --git a/src/pal/tests/palsuite/c_runtime/_open_osfhandle/test2/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_open_osfhandle/test2/testinfo.dat deleted file mode 100644 index 822e23fed..000000000 --- a/src/pal/tests/palsuite/c_runtime/_open_osfhandle/test2/testinfo.dat +++ /dev/null @@ -1,16 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = _open_osfhandle -Name = Fail test for _open_osfhandle -TYPE = DEFAULT -EXE1 = test2 -Description -= Tests the PAL implementation of the _open_osfhandle function. -= This API accepts a OS Handle returned from CreatePipe() and -= a flag of _O_RDONLY and returns a C Run-Time handle. The test -= will pass a NULL handle, and unsupported flags. All cases -= should fail. diff --git a/src/pal/tests/palsuite/c_runtime/_putenv/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_putenv/CMakeLists.txt deleted file mode 100644 index a3847f8ca..000000000 --- a/src/pal/tests/palsuite/c_runtime/_putenv/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) -add_subdirectory(test3) -add_subdirectory(test4) - diff --git a/src/pal/tests/palsuite/c_runtime/_putenv/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_putenv/test1/CMakeLists.txt deleted file mode 100644 index e49d53f82..000000000 --- a/src/pal/tests/palsuite/c_runtime/_putenv/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_putenv_test1 - ${SOURCES} -) - -add_dependencies(paltest_putenv_test1 coreclrpal) - -target_link_libraries(paltest_putenv_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_putenv/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/_putenv/test1/test1.cpp deleted file mode 100644 index 2d096adc7..000000000 --- a/src/pal/tests/palsuite/c_runtime/_putenv/test1/test1.cpp +++ /dev/null @@ -1,99 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test1.c -** -** Purpose: Create an environment variable with _putenv and then use getenv -** to check it. Check that we get the expected errors with invalid input. -** -** -**===================================================================*/ - -#include - -struct TestElement -{ - char _putenvString[1024]; /* argument string sent to putenv */ - char varName[1024]; /* variable component of argument string */ - char varValue[1024]; /* value component of argument string */ - BOOL bValidString; /* valid argument string identifier */ -}; - -struct TestElement TestCases[] = -{ - {"PalTestingEnvironmentVariable=A value", "PalTestingEnvironmentVariable", - "A value", TRUE}, - {"AnotherVariable=", "AnotherVariable", "", TRUE}, - {"YetAnotherVariable", "", "", FALSE}, - {"=ADifferentVariable", "", "ADifferentVariable", FALSE}, - {"", "", "", FALSE} - -}; - -int __cdecl main(int argc, char **argv) -{ - - int i; - char *variableValue; - - if (0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - for (i = 0; i < (sizeof(TestCases)/sizeof(struct TestElement)) ; i++) - { - if((_putenv(TestCases[i]._putenvString) == -1) && - ( TestCases[i].bValidString == TRUE)) - { - Fail("ERROR: _putenv failed to set an environment " - "variable with a valid format.\n Call was" - "_putenv(%s)\n", TestCases[i]._putenvString); - } - /* - * For valid _putenvString values, check to see the variable was set - */ - if (TestCases[i].bValidString == TRUE) - { - variableValue = getenv(TestCases[i].varName); - - if (variableValue == NULL) - { - if (*TestCases[i].varValue != '\0') - { - Fail("ERROR: getenv(%s) call returned NULL.\nThe call " - "should have returned \"%s\"\n", TestCases[i].varName - , TestCases[i].varValue); - } - } - else if ( strcmp(variableValue, TestCases[i].varValue) != 0) - { - Fail("ERROR: _putenv(%s)\nshould have set the variable " - "%s\n to \"%s\".\nA subsequent call to getenv(%s)\n" - "returned \"%s\" instead.\n", TestCases[i]._putenvString - , TestCases[i].varName, TestCases[i].varValue - , TestCases[i].varName, variableValue); - } - } - else - /* - * Check to see that putenv fails for malformed _putenvString values - */ - { - variableValue = getenv(TestCases[i].varName); - - if (variableValue != NULL) - { - Fail("ERROR: getenv(%s) call should have returned NULL.\n" - "Instead it returned \"%s\".\n", TestCases[i].varName - , TestCases[i].varValue); - } - } - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/_putenv/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_putenv/test1/testinfo.dat deleted file mode 100644 index d0978184f..000000000 --- a/src/pal/tests/palsuite/c_runtime/_putenv/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = _putenv -Name = Positive test for _putenv -TYPE = DEFAULT -EXE1 = test1 -Description -= Create an environment variable with _putenv and then use getenv to -= check it. Check that we get the expected errors with invalid input. diff --git a/src/pal/tests/palsuite/c_runtime/_putenv/test2/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_putenv/test2/CMakeLists.txt deleted file mode 100644 index 6c6d139b7..000000000 --- a/src/pal/tests/palsuite/c_runtime/_putenv/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test2.cpp -) - -add_executable(paltest_putenv_test2 - ${SOURCES} -) - -add_dependencies(paltest_putenv_test2 coreclrpal) - -target_link_libraries(paltest_putenv_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_putenv/test2/test2.cpp b/src/pal/tests/palsuite/c_runtime/_putenv/test2/test2.cpp deleted file mode 100644 index 39be4f68b..000000000 --- a/src/pal/tests/palsuite/c_runtime/_putenv/test2/test2.cpp +++ /dev/null @@ -1,76 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test2.c -** -** Purpose: Create an environment variable with _putenv and then use getenv -** to check it. This test resets an environment variable. -** -** -**===================================================================*/ - -#include - -const char *_putenvString0 = "AnUnusualVariable=AnUnusualValue"; -const char *_putenvString1 = "AnUnusualVariable="; -const char *variable = "AnUnusualVariable"; -const char *value = "AnUnusualValue"; - -int __cdecl main(int argc, char **argv) -{ - - char *variableValue; - - if (0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - if(_putenv(_putenvString0) == -1) - { - Fail("ERROR: _putenv failed to set an environment " - "variable with a valid format.\n Call was" - "_putenv(%s)\n", _putenvString0); - } - - variableValue = getenv(variable); - - if (variableValue == NULL) - { - Fail("ERROR: getenv(%s) call returned NULL\nThe call " - "should have returned '%s'\n", variable, value); - } - else - { - if ( strcmp(variableValue, value) != 0 ) - { - Fail("ERROR: _putenv(%s)\nshould have set the variable " - "'%s'\n to '%s'.\nA subsequent call to getenv(%s)\n" - "returned '%s' instead.\n", _putenvString0, - variable, value, variable, variableValue); - } - else - { - if(_putenv(_putenvString1) == -1) - { - Fail("ERROR: _putenv failed to set an environment " - "variable with a valid format.\n Call was" - "_putenv(%s)\n", _putenvString1); - } - - variableValue = getenv(variable); - - if (variableValue != NULL) - { - Fail("ERROR: getenv(%s) call did not return NULL.\nThe call " - "returned '%s'.\n", variable, value); - } - } - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/_putenv/test2/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_putenv/test2/testinfo.dat deleted file mode 100644 index 8d3a6ced1..000000000 --- a/src/pal/tests/palsuite/c_runtime/_putenv/test2/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = _putenv -Name = Positive test for _putenv -TYPE = DEFAULT -EXE1 = test2 -Description -= Create an environment variable with _putenv and then use getenv to -= check it. This test resets an environment variable. diff --git a/src/pal/tests/palsuite/c_runtime/_putenv/test3/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_putenv/test3/CMakeLists.txt deleted file mode 100644 index 2d98fd18e..000000000 --- a/src/pal/tests/palsuite/c_runtime/_putenv/test3/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test3.cpp -) - -add_executable(paltest_putenv_test3 - ${SOURCES} -) - -add_dependencies(paltest_putenv_test3 coreclrpal) - -target_link_libraries(paltest_putenv_test3 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_putenv/test3/test3.cpp b/src/pal/tests/palsuite/c_runtime/_putenv/test3/test3.cpp deleted file mode 100644 index 8aa677730..000000000 --- a/src/pal/tests/palsuite/c_runtime/_putenv/test3/test3.cpp +++ /dev/null @@ -1,102 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test3.c -** -** Purpose: Create environment variables that differ only in Case, and -** verify that the BSD operating system treats the variables -** differently. -** -** -**===================================================================*/ - -#include - -int __cdecl main(int argc, char **argv) -{ -#if WIN32 - - return PASS; - -#else - - const char* FirstVariable = "PalTestingEnvironmentVariable=The value"; - const char* SecondVariable = "PALTESTINGEnvironmentVariable=Different value"; - const char* FirstVarName = "PalTestingEnvironmentVariable"; - const char* FirstVarValue = "The value"; - char* result; - - - if (0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - /* Use _putenv to set an environment variable. This ensures that the - variable we're testing on is always present. - */ - - if(_putenv(FirstVariable) != 0) - { - Fail("ERROR: _putenv failed to set an environment variable that " - "getenv will be using for testing.\n"); - } - - - /* Call getenv -- ensure it doesn't return NULL and the string it returns - is the value we set above. Also make sure that each environment variable, - differing only by case, returns it's own value. - */ - - result = getenv(FirstVarName); - if(result == NULL) - { - Fail("ERROR: The result of getenv on a valid Environment Variable " - "was NULL, which indicates the environment varaible was not " - "found.\n"); - } - - if(strcmp(result, FirstVarValue) != 0) - { - Fail("ERROR: The value obtained by getenv() was not equal to the " - "correct value of the environment variable. The correct " - "value is '%s' and the function returned '%s'.\n", - FirstVarValue, - result); - } - - /* Set the second environment variable, which only differs in Case */ - if(_putenv(SecondVariable) != 0) - { - Fail("ERROR: _putenv failed to set an environment variable that " - "getenv will be using for testing.\n"); - } - - /* Verify that the environment variables - */ - - result = getenv(FirstVarName); - if(result == NULL) - { - Fail("ERROR: The result of getenv on a valid Environment Variable " - "was NULL, which indicates the environment varaible was not " - "found.\n"); - } - - if(strcmp(result, FirstVarValue) != 0) - { - Fail("ERROR: The value obtained by getenv() was not equal to the " - "correct value of the environment variable. The correct " - "value is '%s' and the function returned '%s'.\n", - FirstVarValue, - result); - } - - PAL_Terminate(); - return PASS; - -#endif -} diff --git a/src/pal/tests/palsuite/c_runtime/_putenv/test3/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_putenv/test3/testinfo.dat deleted file mode 100644 index 2c6af1b5c..000000000 --- a/src/pal/tests/palsuite/c_runtime/_putenv/test3/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = _putenv -Name = Positive test for _putenv -TYPE = DEFAULT -EXE1 = test3 -Description -= Create environment variables that only differ by case -= and check that the BSD operating system treats them -= as two separate variables. diff --git a/src/pal/tests/palsuite/c_runtime/_putenv/test4/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_putenv/test4/CMakeLists.txt deleted file mode 100644 index 9bcd97355..000000000 --- a/src/pal/tests/palsuite/c_runtime/_putenv/test4/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test4.cpp -) - -add_executable(paltest_putenv_test4 - ${SOURCES} -) - -add_dependencies(paltest_putenv_test4 coreclrpal) - -target_link_libraries(paltest_putenv_test4 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_putenv/test4/test4.cpp b/src/pal/tests/palsuite/c_runtime/_putenv/test4/test4.cpp deleted file mode 100644 index 48d7ba963..000000000 --- a/src/pal/tests/palsuite/c_runtime/_putenv/test4/test4.cpp +++ /dev/null @@ -1,75 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test4.c -** -** Purpose: Create an environment variable and try to retrieve -** it using the same name but with different case. This -** is to show that the Win32 representation of _putenv -** is case insensitive. -** -** -**===================================================================*/ - -#include - -int __cdecl main(int argc, char **argv) -{ -#if WIN32 - - const char* FirstVariable = "PalTestingEnvironmentVariable=The value"; - const char* ModifiedName = "PALTESTINGEnvironmentVariable"; - const char* FirstVarValue = "The value"; - char* result; - - - if (0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - /* Use _putenv to set an environment variable. This ensures that the - variable we're testing on is always present. - */ - - if(_putenv(FirstVariable) != 0) - { - Fail("ERROR: _putenv failed to set an environment variable that " - "getenv will be using for testing.\n"); - } - - - /* Call getenv -- ensure it doesn't return NULL and the string it returns - is the value we set above. Also make sure that each environment variable, - differing only by case, doesn't affect the return value. - */ - - result = getenv(ModifiedName); - if(result == NULL) - { - Fail("ERROR: The result of getenv on a valid Environment Variable " - "was NULL, which indicates the environment varaible was not " - "found.\n"); - } - - if(strcmp(result, FirstVarValue) != 0) - { - Fail("ERROR: The value obtained by getenv() was not equal to the " - "correct value of the environment variable. The correct " - "value is '%s' and the function returned '%s'.\n", - FirstVarValue, - result); - } - - - PAL_Terminate(); - return PASS; - -#else - return PASS; - -#endif -} diff --git a/src/pal/tests/palsuite/c_runtime/_putenv/test4/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_putenv/test4/testinfo.dat deleted file mode 100644 index af1a01c2f..000000000 --- a/src/pal/tests/palsuite/c_runtime/_putenv/test4/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = _putenv -Name = Positive test for _putenv -TYPE = DEFAULT -EXE1 = test4 -Description -= Create an environment variable and check -= that trying to retrieve it using a name with different -= case, returns the correct value. diff --git a/src/pal/tests/palsuite/c_runtime/_rotl/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_rotl/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/c_runtime/_rotl/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/c_runtime/_rotl/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_rotl/test1/CMakeLists.txt deleted file mode 100644 index 8aed25d77..000000000 --- a/src/pal/tests/palsuite/c_runtime/_rotl/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_rotl_test1 - ${SOURCES} -) - -add_dependencies(paltest_rotl_test1 coreclrpal) - -target_link_libraries(paltest_rotl_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_rotl/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/_rotl/test1/test1.cpp deleted file mode 100644 index 3a3138889..000000000 --- a/src/pal/tests/palsuite/c_runtime/_rotl/test1/test1.cpp +++ /dev/null @@ -1,55 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test1.c (_rotl) -** -** Purpose: Tests the PAL implementation of the _rotl function. -** The _rotl function rotates the unsigned value. _rotl -** rotates the value left and "wraps" bits rotated off -** one end of value to the other end. -** This test compares the result to a previously determined -** value. -** -** -** -**===================================================================*/ -#include - -int __cdecl main(int argc, char **argv) -{ - unsigned results = 0; - int i,j; - - unsigned hTestNums[5][8] = { - {0x00ff, 0x01fe, 0x03fc, 0x07f8, 0x0ff0, 0x1fe0, 0x3fc0, 0x7f80}, - {0x0055, 0x00aa, 0x0154, 0x02a8, 0x0550, 0x0aa0, 0x1540, 0x2a80}, - {0x0099, 0x0132, 0x0264, 0x04c8, 0x0990, 0x1320, 0x2640, 0x4c80}, - {0x0036, 0x006c, 0x00d8, 0x01b0, 0x0360, 0x06c0, 0x0d80, 0x1b00}, - {0x008f, 0x011e, 0x023c, 0x0478, 0x08f0, 0x11e0, 0x23c0, 0x4780}}; - - if ((PAL_Initialize(argc, argv)) != 0) - { - return (FAIL); - } - - /*Loop through expected test results*/ - for (j = 0; j <= 4; j++) - { - for(i = 1; i <= 7; i++) - { - results = _rotl(hTestNums[j][0], i); - if (results != hTestNums[j][i]) - { - Fail("ERROR: \"0x%4.4x\" rotated bits to the left %d times" - " gave \"0x%4.4x\", expected \"0x%4.4x\"\n", - hTestNums[j][0], i, results, hTestNums[j][i]) ; - } - } - } - - PAL_Terminate(); - return (PASS); -} diff --git a/src/pal/tests/palsuite/c_runtime/_rotl/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_rotl/test1/testinfo.dat deleted file mode 100644 index 9c87473f8..000000000 --- a/src/pal/tests/palsuite/c_runtime/_rotl/test1/testinfo.dat +++ /dev/null @@ -1,17 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = _rtol -Name = Positive Test for _rotl -TYPE = DEFAULT -EXE1 = test1 -Description -= Tests the PAL implementation of the _rotl function. -= The _rotl function rotates the unsigned value. _rotl -= rotates the value left and "wraps" bits rotated off -= one end of value to the other end. -= This test compares the result to a previously determined -= value. diff --git a/src/pal/tests/palsuite/c_runtime/_rotr/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_rotr/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/c_runtime/_rotr/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/c_runtime/_rotr/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_rotr/test1/CMakeLists.txt deleted file mode 100644 index ff84c62fb..000000000 --- a/src/pal/tests/palsuite/c_runtime/_rotr/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_rotr_test1 - ${SOURCES} -) - -add_dependencies(paltest_rotr_test1 coreclrpal) - -target_link_libraries(paltest_rotr_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_rotr/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/_rotr/test1/test1.cpp deleted file mode 100644 index cf461c0a6..000000000 --- a/src/pal/tests/palsuite/c_runtime/_rotr/test1/test1.cpp +++ /dev/null @@ -1,60 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test1.c (_rotr) -** -** Purpose: Tests the PAL implementation of the _rotr function. -** The _rotr function rotates the unsigned value. _rotr -** rotates the value right and "wraps" bits rotated off -** one end of value to the other end. -** This test compares the result to a previously -** determined value. -** -** -**===================================================================*/ -#include - -int __cdecl main(int argc, char **argv) -{ - unsigned results = 0; - int i,j; - - unsigned hTestNums[5][8] = { - {0x00ff, 0x8000007f, 0xc000003f, 0xe000001f, - 0xf000000f, 0xf8000007, 0xfc000003, 0xfe000001}, - {0x0055, 0x8000002a, 0x40000015, 0xa000000a, - 0x50000005, 0xa8000002, 0x54000001, 0xaa000000}, - {0x0099, 0x8000004c, 0x40000026, 0x20000013, - 0x90000009, 0xc8000004, 0x64000002, 0x32000001}, - {0x0036, 0x001b, 0x8000000d, 0xc0000006, - 0x60000003, 0xb0000001, 0xd8000000, 0x6c000000}, - {0x008f, 0x80000047, 0xc0000023, 0xe0000011, - 0xf0000008, 0x78000004, 0x3c000002 ,0x1e000001}}; - - - if ((PAL_Initialize(argc, argv)) != 0) - { - return (FAIL); - } - - /*Loop through expected test results*/ - for (j = 0; j <= 4; j++) - { - for(i = 1; i <= 7; i++) - { - results = _rotr(hTestNums[j][0], i); - if (results != hTestNums[j][i]) - { - Fail("ERROR: \"0x%4.4x\" rotated bits to the left %d times" - " gave \"0x%4.4x\", expected \"0x%4.4x\"\n", - hTestNums[j][0], i, results, hTestNums[j][i]) ; - } - } - } - - PAL_Terminate(); - return (PASS); -} diff --git a/src/pal/tests/palsuite/c_runtime/_rotr/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_rotr/test1/testinfo.dat deleted file mode 100644 index 915f46766..000000000 --- a/src/pal/tests/palsuite/c_runtime/_rotr/test1/testinfo.dat +++ /dev/null @@ -1,17 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = _rtor -Name = Positive Test for _rotr -TYPE = DEFAULT -EXE1 = test1 -Description -= Tests the PAL implementation of the _rotr function. -= The _rotr function rotates the unsigned value. _rotr -= rotates the value right and "wraps" bits rotated off -= one end of value to the other end. -= This test compares the result to a previously determined -= value. diff --git a/src/pal/tests/palsuite/c_runtime/_snprintf_s/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_snprintf_s/CMakeLists.txt deleted file mode 100644 index 8fe1cb60a..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snprintf_s/CMakeLists.txt +++ /dev/null @@ -1,21 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test10) -add_subdirectory(test11) -add_subdirectory(test12) -add_subdirectory(test13) -add_subdirectory(test14) -add_subdirectory(test15) -add_subdirectory(test16) -add_subdirectory(test17) -add_subdirectory(test18) -add_subdirectory(test19) -add_subdirectory(test2) -add_subdirectory(test3) -add_subdirectory(test4) -add_subdirectory(test6) -add_subdirectory(test7) -add_subdirectory(test8) -add_subdirectory(test9) - diff --git a/src/pal/tests/palsuite/c_runtime/_snprintf_s/_snprintf_s.h b/src/pal/tests/palsuite/c_runtime/_snprintf_s/_snprintf_s.h deleted file mode 100644 index 9ed5209be..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snprintf_s/_snprintf_s.h +++ /dev/null @@ -1,194 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: sprintf_s.h -** -** Purpose: Containts common testing functions for sprintf_s -** -** -**==========================================================================*/ - -#ifndef __STRINGTEST_H__ -#define __STRINGTEST_H__ - -void DoStrTest(const char *formatstr, char* param, const char *checkstr) -{ - char buf[256] = { 0 }; - - _snprintf_s(buf, 256, _TRUNCATE, formatstr, param); - if (memcmp(buf, checkstr, strlen(checkstr) + 1) != 0) - { - Fail("ERROR: failed to insert string \"%s\" into \"%s\"\n" - "Expected \"%s\" got \"%s\".\n", - param, formatstr, checkstr, buf); - } -} - -void DoWStrTest(const char *formatstr, WCHAR* param, const char *checkstr) -{ - char buf[256] = { 0 }; - - _snprintf_s(buf, 256, _TRUNCATE, formatstr, param); - if (memcmp(buf, checkstr, strlen(checkstr) + 1) != 0) - { - Fail("ERROR: failed to insert wide string \"%s\" into \"%s\"\n" - "Expected \"%s\" got \"%s\".\n", - convertC(param), formatstr, checkstr, buf); - } -} - - -void DoPointerTest(const char *formatstr, void* param, char* paramstr, char - *checkstr1) -{ - char buf[256] = { 0 }; - - _snprintf_s(buf, 256, _TRUNCATE, formatstr, param); - if (memcmp(buf, checkstr1, strlen(checkstr1) + 1) != 0) - { - Fail("ERROR: failed to insert %s into \"%s\"\n" - "Expected \"%s\", got \"%s\".\n", - paramstr, formatstr, checkstr1, buf); - } -} - -void DoCountTest(const char *formatstr, int param, const char *checkstr) -{ - char buf[512] = { 0 }; - int n = -1; - - sprintf_s(buf, 512, formatstr, &n); - - if (n != param) - { - Fail("ERROR: Expected count parameter to resolve to %d, got %X\n", - param, n); - } - if (memcmp(buf, checkstr, strlen(checkstr) + 1) != 0) - { - Fail("ERROR: Expected \"%s\" got \"%s\".\n", checkstr, buf); - } -} - -void DoShortCountTest(const char *formatstr, int param, const char *checkstr) -{ - char buf[256] = { 0 }; - short int n = -1; - - _snprintf_s(buf, 256, _TRUNCATE, formatstr, &n); - - if (n != param) - { - Fail("ERROR: Expected count parameter to resolve to %d, got %X\n", - param, n); - } - if (memcmp(buf, checkstr, strlen(checkstr) + 1) != 0) - { - Fail("ERROR: Expected \"%s\" got \"%s\".\n", checkstr, buf); - } -} - -void DoCharTest(const char *formatstr, char param, const char *checkstr) -{ - char buf[256] = { 0 }; - - _snprintf_s(buf, 256, _TRUNCATE, formatstr, param); - if (memcmp(buf, checkstr, strlen(checkstr) + 1) != 0) - { - Fail("ERROR: failed to insert char \'%c\' (%d) into \"%s\"\n" - "Expected \"%s\" got \"%s\".\n", - param, param, formatstr, checkstr, buf); - } -} - -void DoWCharTest(const char *formatstr, WCHAR param, const char *checkstr) -{ - char buf[256] = { 0 }; - - _snprintf_s(buf, 256, _TRUNCATE, formatstr, param); - if (memcmp(buf, checkstr, strlen(checkstr) + 1) != 0) - { - Fail("ERROR: failed to insert wide char \'%c\' (%d) into \"%s\"\n" - "Expected \"%s\" got \"%s\".\n", - (char)param, param, formatstr, checkstr, buf); - } -} - -void DoNumTest(const char *formatstr, int value, const char *checkstr) -{ - char buf[256] = { 0 }; - - _snprintf_s(buf, 256, _TRUNCATE, formatstr, value); - if (memcmp(buf, checkstr, strlen(checkstr) + 1) != 0) - { - Fail("ERROR: failed to insert %#x into \"%s\"\n" - "Expected \"%s\" got \"%s\".\n", - value, formatstr, checkstr, buf); - } -} - -void DoI64Test(const char *formatstr, INT64 value, char *valuestr, const char *checkstr1) -{ - char buf[256] = { 0 }; - - _snprintf_s(buf, 256, _TRUNCATE, formatstr, value); - if (memcmp(buf, checkstr1, strlen(checkstr1) + 1) != 0) - { - Fail("ERROR: failed to insert %s into \"%s\"\n" - "Expected \"%s\", got \"%s\".\n", - valuestr, formatstr, checkstr1, buf); - } -} - -void DoDoubleTest(const char *formatstr, double value, const char *checkstr1, char -*checkstr2) -{ - char buf[256] = { 0 }; - - _snprintf_s(buf, 256, _TRUNCATE, formatstr, value); - if (memcmp(buf, checkstr1, strlen(checkstr1) + 1) != 0 - && memcmp(buf, checkstr2, strlen(checkstr2) + 1) != 0) - { - Fail("ERROR: failed to insert %f into \"%s\"\n" - "Expected \"%s\" or \"%s\", got \"%s\".\n", - value, formatstr, checkstr1, checkstr2, buf); - } -} - -void DoArgumentPrecTest(const char *formatstr, int precision, void *param, char -*paramstr, const char *checkstr1, const char *checkstr2) -{ - char buf[256]; - - _snprintf_s(buf, 256, _TRUNCATE, formatstr, precision, param); - if (memcmp(buf, checkstr1, strlen(checkstr1) + 1) != 0 && - memcmp(buf, checkstr2, strlen(checkstr2) + 1) != 0) - { - Fail("ERROR: failed to insert %s into \"%s\" with precision %d\n" - "Expected \"%s\" or \"%s\", got \"%s\".\n", - paramstr, formatstr, precision, checkstr1, checkstr2, buf); - } - -} - -void DoArgumentPrecDoubleTest(const char *formatstr, int precision, double param, -const char *checkstr1, const char *checkstr2) -{ - char buf[256]; - - _snprintf_s(buf, 256, _TRUNCATE, formatstr, precision, param); - if (memcmp(buf, checkstr1, strlen(checkstr1) + 1) != 0 && - memcmp(buf, checkstr2, strlen(checkstr2) + 1) != 0) - { - Fail("ERROR: failed to insert %f into \"%s\" with precision %d\n" - "Expected \"%s\" or \"%s\", got \"%s\".\n", - param, formatstr, precision, checkstr1, checkstr2, buf); - } - -} - -#endif - diff --git a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_snprintf_s/test1/CMakeLists.txt deleted file mode 100644 index 7ec4817f6..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_snprintf_test1 - ${SOURCES} -) - -add_dependencies(paltest_snprintf_test1 coreclrpal) - -target_link_libraries(paltest_snprintf_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/_snprintf_s/test1/test1.cpp deleted file mode 100644 index d180b05df..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test1/test1.cpp +++ /dev/null @@ -1,58 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: General test to see if sprintf_s works correctly -** -** -**==========================================================================*/ - - - -#include -#include "../_snprintf_s.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - -int __cdecl main(int argc, char *argv[]) -{ - char checkstr[] = "hello world"; - char buf[256] = { 0 }; - int ret; - - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - - _snprintf_s(buf, 256, _TRUNCATE, "hello world"); - if (memcmp(checkstr, buf, strlen(checkstr)+1) != 0) - { - Fail("ERROR: expected \"%s\" (up to %d chars), got \"%s\"\n", - checkstr, 256, buf); - } - - _snprintf_s(buf, 256, _TRUNCATE, "xxxxxxxxxxxxxxxxx"); - ret = _snprintf_s(buf, 8, _TRUNCATE, "hello world"); - - if (ret >= 0) - { - Fail("ERROR: expected negative return value, got %d", ret); - } - if (memcmp(checkstr, buf, 7) != 0 || buf[7] != 0 || buf[8] != 'x') - { - Fail("ERROR: expected %s (up to %d chars), got %s\n", - checkstr, 8, buf); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_snprintf_s/test1/testinfo.dat deleted file mode 100644 index 255c534cd..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test1/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = sprintf_s -Name = Positive Test for sprintf_s -TYPE = DEFAULT -EXE1 = test1 -Description -= General test to see if sprintf_s works correctly diff --git a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test10/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_snprintf_s/test10/CMakeLists.txt deleted file mode 100644 index 8a61bc45e..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test10/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test10.cpp -) - -add_executable(paltest_snprintf_test10 - ${SOURCES} -) - -add_dependencies(paltest_snprintf_test10 coreclrpal) - -target_link_libraries(paltest_snprintf_test10 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test10/test10.cpp b/src/pal/tests/palsuite/c_runtime/_snprintf_s/test10/test10.cpp deleted file mode 100644 index 7ecb9102e..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test10/test10.cpp +++ /dev/null @@ -1,55 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test10.c -** -** Purpose: Tests sprintf_s with octal numbers -** -** -**==========================================================================*/ - - - - -#include -#include "../_snprintf_s.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - -int __cdecl main(int argc, char *argv[]) -{ - int neg = -42; - int pos = 42; - INT64 l = 42; - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - - DoNumTest("foo %o", pos, "foo 52"); - DoNumTest("foo %lo", 0xFFFF, "foo 177777"); - DoNumTest("foo %ho", 0xFFFF, "foo 177777"); - DoNumTest("foo %Lo", pos, "foo 52"); - DoI64Test("foo %I64o", l, "42", "foo 52"); - DoNumTest("foo %3o", pos, "foo 52"); - DoNumTest("foo %-3o", pos, "foo 52 "); - DoNumTest("foo %.1o", pos, "foo 52"); - DoNumTest("foo %.3o", pos, "foo 052"); - DoNumTest("foo %03o", pos, "foo 052"); - DoNumTest("foo %#o", pos, "foo 052"); - DoNumTest("foo %+o", pos, "foo 52"); - DoNumTest("foo % o", pos, "foo 52"); - DoNumTest("foo %+o", neg, "foo 37777777726"); - DoNumTest("foo % o", neg, "foo 37777777726"); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test10/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_snprintf_s/test10/testinfo.dat deleted file mode 100644 index 25ed554ea..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test10/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = sprintf_s -Name = Positive Test for sprintf_s -TYPE = DEFAULT -EXE1 = test10 -Description -= Tests sprintf_s with octal numbers diff --git a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test11/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_snprintf_s/test11/CMakeLists.txt deleted file mode 100644 index 5fe253463..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test11/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test11.cpp -) - -add_executable(paltest_snprintf_test11 - ${SOURCES} -) - -add_dependencies(paltest_snprintf_test11 coreclrpal) - -target_link_libraries(paltest_snprintf_test11 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test11/test11.cpp b/src/pal/tests/palsuite/c_runtime/_snprintf_s/test11/test11.cpp deleted file mode 100644 index c2ac01569..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test11/test11.cpp +++ /dev/null @@ -1,54 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test11.c -** -** Purpose: Tests sprintf_s with unsigned numbers -** -** -**==========================================================================*/ - - - -#include -#include "../_snprintf_s.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - -int __cdecl main(int argc, char *argv[]) -{ - int neg = -42; - int pos = 42; - INT64 l = 42; - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - - DoNumTest("foo %u", pos, "foo 42"); - DoNumTest("foo %lu", 0xFFFF, "foo 65535"); - DoNumTest("foo %hu", 0xFFFF, "foo 65535"); - DoNumTest("foo %Lu", pos, "foo 42"); - DoI64Test("foo %I64u", l, "42", "foo 42"); - DoNumTest("foo %3u", pos, "foo 42"); - DoNumTest("foo %-3u", pos, "foo 42 "); - DoNumTest("foo %.1u", pos, "foo 42"); - DoNumTest("foo %.3u", pos, "foo 042"); - DoNumTest("foo %03u", pos, "foo 042"); - DoNumTest("foo %#u", pos, "foo 42"); - DoNumTest("foo %+u", pos, "foo 42"); - DoNumTest("foo % u", pos, "foo 42"); - DoNumTest("foo %+u", neg, "foo 4294967254"); - DoNumTest("foo % u", neg, "foo 4294967254"); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test11/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_snprintf_s/test11/testinfo.dat deleted file mode 100644 index 3144f1290..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test11/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = sprintf_s -Name = Positive Test for sprintf_s -TYPE = DEFAULT -EXE1 = test11 -Description -= Tests sprintf_s with unsigned numbers diff --git a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test12/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_snprintf_s/test12/CMakeLists.txt deleted file mode 100644 index 9eade5415..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test12/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test12.cpp -) - -add_executable(paltest_snprintf_test12 - ${SOURCES} -) - -add_dependencies(paltest_snprintf_test12 coreclrpal) - -target_link_libraries(paltest_snprintf_test12 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test12/test12.cpp b/src/pal/tests/palsuite/c_runtime/_snprintf_s/test12/test12.cpp deleted file mode 100644 index 52171838c..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test12/test12.cpp +++ /dev/null @@ -1,55 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test12.c -** -** Purpose: Tests sprintf_s with hex numbers (lowercase) -** -** -**==========================================================================*/ - - - -#include -#include "../_snprintf_s.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - - -int __cdecl main(int argc, char *argv[]) -{ - int neg = -42; - int pos = 0x1234ab; - INT64 l = I64(0x1234567887654321); - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - - DoNumTest("foo %x", pos, "foo 1234ab"); - DoNumTest("foo %lx", pos, "foo 1234ab"); - DoNumTest("foo %hx", pos, "foo 34ab"); - DoNumTest("foo %Lx", pos, "foo 1234ab"); - DoI64Test("foo %I64x", l, "0x1234567887654321", "foo 1234567887654321"); - DoNumTest("foo %7x", pos, "foo 1234ab"); - DoNumTest("foo %-7x", pos, "foo 1234ab "); - DoNumTest("foo %.1x", pos, "foo 1234ab"); - DoNumTest("foo %.7x", pos, "foo 01234ab"); - DoNumTest("foo %07x", pos, "foo 01234ab"); - DoNumTest("foo %#x", pos, "foo 0x1234ab"); - DoNumTest("foo %+x", pos, "foo 1234ab"); - DoNumTest("foo % x", pos, "foo 1234ab"); - DoNumTest("foo %+x", neg, "foo ffffffd6"); - DoNumTest("foo % x", neg, "foo ffffffd6"); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test12/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_snprintf_s/test12/testinfo.dat deleted file mode 100644 index ed91cecc4..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test12/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = sprintf_s -Name = Positive Test for sprintf_s -TYPE = DEFAULT -EXE1 = test12 -Description -= Tests sprintf_s with hex numbers (lowercase) diff --git a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test13/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_snprintf_s/test13/CMakeLists.txt deleted file mode 100644 index 1e31d2c94..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test13/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test13.cpp -) - -add_executable(paltest_snprintf_test13 - ${SOURCES} -) - -add_dependencies(paltest_snprintf_test13 coreclrpal) - -target_link_libraries(paltest_snprintf_test13 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test13/test13.cpp b/src/pal/tests/palsuite/c_runtime/_snprintf_s/test13/test13.cpp deleted file mode 100644 index 15e47558b..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test13/test13.cpp +++ /dev/null @@ -1,55 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test13.c -** -** Purpose: Tests sprintf_s with hex numbers (uppercase) -** -** -**==========================================================================*/ - - - -#include -#include "../_snprintf_s.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - - -int __cdecl main(int argc, char *argv[]) -{ - int neg = -42; - int pos = 0x1234AB; - INT64 l = I64(0x1234567887654321); - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - - DoNumTest("foo %X", pos, "foo 1234AB"); - DoNumTest("foo %lX", pos, "foo 1234AB"); - DoNumTest("foo %hX", pos, "foo 34AB"); - DoNumTest("foo %LX", pos, "foo 1234AB"); - DoI64Test("foo %I64X", l, "0x1234567887654321", "foo 1234567887654321"); - DoNumTest("foo %7X", pos, "foo 1234AB"); - DoNumTest("foo %-7X", pos, "foo 1234AB "); - DoNumTest("foo %.1X", pos, "foo 1234AB"); - DoNumTest("foo %.7X", pos, "foo 01234AB"); - DoNumTest("foo %07X", pos, "foo 01234AB"); - DoNumTest("foo %#X", pos, "foo 0X1234AB"); - DoNumTest("foo %+X", pos, "foo 1234AB"); - DoNumTest("foo % X", pos, "foo 1234AB"); - DoNumTest("foo %+X", neg, "foo FFFFFFD6"); - DoNumTest("foo % X", neg, "foo FFFFFFD6"); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test13/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_snprintf_s/test13/testinfo.dat deleted file mode 100644 index fd5f53017..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test13/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = sprintf_s -Name = Positive Test for sprintf_s -TYPE = DEFAULT -EXE1 = test13 -Description -= Tests sprintf_s with hex numbers (uppercase) diff --git a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test14/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_snprintf_s/test14/CMakeLists.txt deleted file mode 100644 index 1af6846df..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test14/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test14.cpp -) - -add_executable(paltest_snprintf_test14 - ${SOURCES} -) - -add_dependencies(paltest_snprintf_test14 coreclrpal) - -target_link_libraries(paltest_snprintf_test14 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test14/test14.cpp b/src/pal/tests/palsuite/c_runtime/_snprintf_s/test14/test14.cpp deleted file mode 100644 index 331475e96..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test14/test14.cpp +++ /dev/null @@ -1,57 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test14.c -** -** Purpose: Tests sprintf_s with exponential format doubles (lowercase) -** -** -**==========================================================================*/ - - - -#include -#include "../_snprintf_s.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - - -int __cdecl main(int argc, char *argv[]) -{ - double val = 256.0; - double neg = -256.0; - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - - DoDoubleTest("foo %e", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %le", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %he", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %Le", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %I64e", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %14e", val, "foo 2.560000e+002", - "foo 2.560000e+02"); - DoDoubleTest("foo %-14e", val, "foo 2.560000e+002 ", - "foo 2.560000e+02 "); - DoDoubleTest("foo %.1e", val, "foo 2.6e+002", "foo 2.6e+02"); - DoDoubleTest("foo %.8e", val, "foo 2.56000000e+002", - "foo 2.56000000e+02"); - DoDoubleTest("foo %014e", val, "foo 02.560000e+002", - "foo 002.560000e+02"); - DoDoubleTest("foo %#e", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %+e", val, "foo +2.560000e+002", "foo +2.560000e+02"); - DoDoubleTest("foo % e", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %+e", neg, "foo -2.560000e+002", "foo -2.560000e+02"); - DoDoubleTest("foo % e", neg, "foo -2.560000e+002", "foo -2.560000e+02"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test14/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_snprintf_s/test14/testinfo.dat deleted file mode 100644 index 23cf42335..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test14/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = sprintf_s -Name = Positive Test for sprintf_s -TYPE = DEFAULT -EXE1 = test14 -Description -= Tests sprintf_s with exponential format doubles (lowercase) diff --git a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test15/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_snprintf_s/test15/CMakeLists.txt deleted file mode 100644 index 8287fd37d..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test15/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test15.cpp -) - -add_executable(paltest_snprintf_test15 - ${SOURCES} -) - -add_dependencies(paltest_snprintf_test15 coreclrpal) - -target_link_libraries(paltest_snprintf_test15 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test15/test15.cpp b/src/pal/tests/palsuite/c_runtime/_snprintf_s/test15/test15.cpp deleted file mode 100644 index d43613b6c..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test15/test15.cpp +++ /dev/null @@ -1,56 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test15.c -** -** Purpose: Tests sprintf_s with exponential format doubles (uppercase) -** -** -**==========================================================================*/ - - - -#include -#include "../_snprintf_s.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - -int __cdecl main(int argc, char *argv[]) -{ - double val = 256.0; - double neg = -256.0; - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - - DoDoubleTest("foo %E", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %lE", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %hE", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %LE", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %I64E", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %14E", val, "foo 2.560000E+002", - "foo 2.560000E+02"); - DoDoubleTest("foo %-14E", val, "foo 2.560000E+002 ", - "foo 2.560000E+02 "); - DoDoubleTest("foo %.1E", val, "foo 2.6E+002", "foo 2.6E+02"); - DoDoubleTest("foo %.8E", val, "foo 2.56000000E+002", - "foo 2.56000000E+02"); - DoDoubleTest("foo %014E", val, "foo 02.560000E+002", - "foo 002.560000E+02"); - DoDoubleTest("foo %#E", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %+E", val, "foo +2.560000E+002", "foo +2.560000E+02"); - DoDoubleTest("foo % E", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %+E", neg, "foo -2.560000E+002", "foo -2.560000E+02"); - DoDoubleTest("foo % E", neg, "foo -2.560000E+002", "foo -2.560000E+02"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test15/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_snprintf_s/test15/testinfo.dat deleted file mode 100644 index 537e6d1db..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test15/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = sprintf_s -Name = Positive Test for sprintf_s -TYPE = DEFAULT -EXE1 = test15 -Description -= Tests sprintf_s with exponential format doubles (uppercase) diff --git a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test16/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_snprintf_s/test16/CMakeLists.txt deleted file mode 100644 index b45696e78..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test16/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test16.cpp -) - -add_executable(paltest_snprintf_test16 - ${SOURCES} -) - -add_dependencies(paltest_snprintf_test16 coreclrpal) - -target_link_libraries(paltest_snprintf_test16 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test16/test16.cpp b/src/pal/tests/palsuite/c_runtime/_snprintf_s/test16/test16.cpp deleted file mode 100644 index 21cbb1ed3..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test16/test16.cpp +++ /dev/null @@ -1,52 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test16.c -** -** Purpose: Test #15 for the sprintf_s function -** -** -**==========================================================================*/ - - - -#include -#include "../_snprintf_s.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - -int __cdecl main(int argc, char *argv[]) -{ - double val = 2560.001; - double neg = -2560.001; - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - - DoDoubleTest("foo %f", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %lf", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %hf", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %Lf", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %I64f", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %12f", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %-12f", val, "foo 2560.001000 ", "foo 2560.001000 "); - DoDoubleTest("foo %.1f", val, "foo 2560.0", "foo 2560.0"); - DoDoubleTest("foo %.8f", val, "foo 2560.00100000", "foo 2560.00100000"); - DoDoubleTest("foo %012f", val, "foo 02560.001000", "foo 02560.001000"); - DoDoubleTest("foo %#f", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %+f", val, "foo +2560.001000", "foo +2560.001000"); - DoDoubleTest("foo % f", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %+f", neg, "foo -2560.001000", "foo -2560.001000"); - DoDoubleTest("foo % f", neg, "foo -2560.001000", "foo -2560.001000"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test16/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_snprintf_s/test16/testinfo.dat deleted file mode 100644 index 4e98eccac..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test16/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = sprintf_s -Name = Positive Test for sprintf_s -TYPE = DEFAULT -EXE1 = test16 -Description -= Tests sprintf_s with decimal point format doubles diff --git a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test17/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_snprintf_s/test17/CMakeLists.txt deleted file mode 100644 index 60d34ebb4..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test17/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test17.cpp -) - -add_executable(paltest_snprintf_test17 - ${SOURCES} -) - -add_dependencies(paltest_snprintf_test17 coreclrpal) - -target_link_libraries(paltest_snprintf_test17 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test17/test17.cpp b/src/pal/tests/palsuite/c_runtime/_snprintf_s/test17/test17.cpp deleted file mode 100644 index d161270b8..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test17/test17.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test17.c -** -** Purpose: Tests sprintf_s with compact format doubles (lowercase) -** -** -**==========================================================================*/ - - - -#include -#include "../_snprintf_s.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - -int __cdecl main(int argc, char *argv[]) -{ - double val = 2560.001; - double neg = -2560.001; - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - - DoDoubleTest("foo %g", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %lg", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %hg", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %Lg", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %I64g", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %5g", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %-5g", val, "foo 2560 ", "foo 2560 "); - DoDoubleTest("foo %.1g", val, "foo 3e+003", "foo 3e+03"); - DoDoubleTest("foo %.2g", val, "foo 2.6e+003", "foo 2.6e+03"); - DoDoubleTest("foo %.12g", val, "foo 2560.001", "foo 2560.001"); - DoDoubleTest("foo %06g", val, "foo 002560", "foo 002560"); - DoDoubleTest("foo %#g", val, "foo 2560.00", "foo 2560.00"); - DoDoubleTest("foo %+g", val, "foo +2560", "foo +2560"); - DoDoubleTest("foo % g", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %+g", neg, "foo -2560", "foo -2560"); - DoDoubleTest("foo % g", neg, "foo -2560", "foo -2560"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test17/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_snprintf_s/test17/testinfo.dat deleted file mode 100644 index 5e41e20d4..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test17/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = sprintf_s -Name = Positive Test for sprintf_s -TYPE = DEFAULT -EXE1 = test17 -Description -= Tests sprintf_s with compact format doubles (lowercase) diff --git a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test18/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_snprintf_s/test18/CMakeLists.txt deleted file mode 100644 index 2bd5200e6..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test18/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test18.cpp -) - -add_executable(paltest_snprintf_test18 - ${SOURCES} -) - -add_dependencies(paltest_snprintf_test18 coreclrpal) - -target_link_libraries(paltest_snprintf_test18 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test18/test18.cpp b/src/pal/tests/palsuite/c_runtime/_snprintf_s/test18/test18.cpp deleted file mode 100644 index 46ec287cc..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test18/test18.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test18.c -** -** Purpose: Tests sprintf_s with compact format doubles (uppercase) -** -** -**==========================================================================*/ - - - -#include -#include "../_snprintf_s.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - -int __cdecl main(int argc, char *argv[]) -{ - double val = 2560.001; - double neg = -2560.001; - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - - DoDoubleTest("foo %G", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %lG", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %hG", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %LG", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %I64G", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %5G", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %-5G", val, "foo 2560 ", "foo 2560 "); - DoDoubleTest("foo %.1G", val, "foo 3E+003", "foo 3E+03"); - DoDoubleTest("foo %.2G", val, "foo 2.6E+003", "foo 2.6E+03"); - DoDoubleTest("foo %.12G", val, "foo 2560.001", "foo 2560.001"); - DoDoubleTest("foo %06G", val, "foo 002560", "foo 002560"); - DoDoubleTest("foo %#G", val, "foo 2560.00", "foo 2560.00"); - DoDoubleTest("foo %+G", val, "foo +2560", "foo +2560"); - DoDoubleTest("foo % G", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %+G", neg, "foo -2560", "foo -2560"); - DoDoubleTest("foo % G", neg, "foo -2560", "foo -2560"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test18/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_snprintf_s/test18/testinfo.dat deleted file mode 100644 index 06ae3a632..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test18/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = sprintf_s -Name = Positive Test for sprintf_s -TYPE = DEFAULT -EXE1 = test18 -Description -= Tests sprintf_s with compact format doubles (uppercase) diff --git a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test19/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_snprintf_s/test19/CMakeLists.txt deleted file mode 100644 index 1d9e283eb..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test19/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test19.cpp -) - -add_executable(paltest_snprintf_test19 - ${SOURCES} -) - -add_dependencies(paltest_snprintf_test19 coreclrpal) - -target_link_libraries(paltest_snprintf_test19 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test19/test19.cpp b/src/pal/tests/palsuite/c_runtime/_snprintf_s/test19/test19.cpp deleted file mode 100644 index 91b1dae58..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test19/test19.cpp +++ /dev/null @@ -1,70 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test19.c -** -** Purpose:Tests sprintf_s with argument specified precision -** -** -**==========================================================================*/ - - - -#include -#include "../_snprintf_s.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - - -int __cdecl main(int argc, char *argv[]) -{ - int n = -1; - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - DoArgumentPrecTest("%.*s", 2, (void*)"bar", "bar", "ba", "ba"); - DoArgumentPrecTest("%.*S", 2, (void*)convert("bar"), "bar", "ba", "ba"); - - DoArgumentPrecTest("%.*c", 0, (void*)'a', "a", "a", "a"); - DoArgumentPrecTest("%.*c", 4, (void*)'a', "a", "a", "a"); - DoArgumentPrecTest("%.*C", 0, (void*)'a', "a", "a", "a"); - DoArgumentPrecTest("%.*C", 4, (void*)'a', "a", "a", "a"); - DoArgumentPrecTest("%.*d", 1, (void*)42, "42", "42", "42"); - DoArgumentPrecTest("%.*d", 3, (void*)42, "42", "042", "042"); - DoArgumentPrecTest("%.*i", 1, (void*)42, "42", "42", "42"); - DoArgumentPrecTest("%.*i", 3, (void*)42, "42", "042", "042"); - DoArgumentPrecTest("%.*o", 1, (void*)42, "42", "52", "52"); - DoArgumentPrecTest("%.*o", 3, (void*)42, "42", "052", "052"); - DoArgumentPrecTest("%.*u", 1, (void*)42, "42", "42", "42"); - DoArgumentPrecTest("%.*u", 3, (void*)42, "42", "042", "042"); - DoArgumentPrecTest("%.*x", 1, (void*)0x42, "0x42", "42", "42"); - DoArgumentPrecTest("%.*x", 3, (void*)0x42, "0x42", "042", "042"); - DoArgumentPrecTest("%.*X", 1, (void*)0x42, "0x42", "42", "42") ; - DoArgumentPrecTest("%.*X", 3, (void*)0x42, "0x42", "042", "042"); - - - DoArgumentPrecDoubleTest("%.*e", 1, 2.01, "2.0e+000", "2.0e+00"); - DoArgumentPrecDoubleTest("%.*e", 3, 2.01, "2.010e+000", "2.010e+00"); - DoArgumentPrecDoubleTest("%.*E", 1, 2.01, "2.0E+000", "2.0E+00"); - DoArgumentPrecDoubleTest("%.*E", 3, 2.01, "2.010E+000", "2.010E+00"); - DoArgumentPrecDoubleTest("%.*f", 1, 2.01, "2.0", "2.0"); - DoArgumentPrecDoubleTest("%.*f", 3, 2.01, "2.010", "2.010"); - DoArgumentPrecDoubleTest("%.*g", 1, 256.01, "3e+002", "3e+02"); - DoArgumentPrecDoubleTest("%.*g", 3, 256.01, "256", "256"); - DoArgumentPrecDoubleTest("%.*g", 4, 256.01, "256", "256"); - DoArgumentPrecDoubleTest("%.*g", 6, 256.01, "256.01", "256.01"); - DoArgumentPrecDoubleTest("%.*G", 1, 256.01, "3E+002", "3E+02"); - DoArgumentPrecDoubleTest("%.*G", 3, 256.01, "256", "256"); - DoArgumentPrecDoubleTest("%.*G", 4, 256.01, "256", "256"); - DoArgumentPrecDoubleTest("%.*G", 6, 256.01, "256.01", "256.01"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test19/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_snprintf_s/test19/testinfo.dat deleted file mode 100644 index 7064c0177..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test19/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = sprintf_s -Name = Positive Test for sprintf_s -TYPE = DEFAULT -EXE1 = test19 -Description -= Tests sprintf_s with argument specified precision diff --git a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test2/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_snprintf_s/test2/CMakeLists.txt deleted file mode 100644 index 134aeaadd..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test2.cpp -) - -add_executable(paltest_snprintf_test2 - ${SOURCES} -) - -add_dependencies(paltest_snprintf_test2 coreclrpal) - -target_link_libraries(paltest_snprintf_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test2/test2.cpp b/src/pal/tests/palsuite/c_runtime/_snprintf_s/test2/test2.cpp deleted file mode 100644 index 54ef80bae..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test2/test2.cpp +++ /dev/null @@ -1,50 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test2.c -** -** Purpose:Tests sprintf_s with strings -** -** -**==========================================================================*/ - - - -#include -#include "../_snprintf_s.h" -/* - * Notes: memcmp is used, as is strlen. - */ - -int __cdecl main(int argc, char *argv[]) -{ - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - DoStrTest("foo %s", "bar", "foo bar"); - DoStrTest("foo %hs", "bar", "foo bar"); - DoWStrTest("foo %ls", convert("bar"), "foo bar"); - DoWStrTest("foo %ws", convert("bar"), "foo bar"); - DoStrTest("foo %Ls", "bar", "foo bar"); - DoStrTest("foo %I64s", "bar", "foo bar"); - DoStrTest("foo %5s", "bar", "foo bar"); - DoStrTest("foo %.2s", "bar", "foo ba"); - DoStrTest("foo %5.2s", "bar", "foo ba"); - DoStrTest("foo %-5s", "bar", "foo bar "); - DoStrTest("foo %05s", "bar", "foo 00bar"); - DoStrTest("foo %s", NULL, "foo (null)"); - DoStrTest("foo %hs", NULL, "foo (null)"); - DoWStrTest("foo %ls", NULL, "foo (null)"); - DoWStrTest("foo %ws", NULL, "foo (null)"); - DoStrTest("foo %Ls", NULL, "foo (null)"); - DoStrTest("foo %I64s", NULL, "foo (null)"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test2/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_snprintf_s/test2/testinfo.dat deleted file mode 100644 index cce2dc67e..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test2/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = sprintf_s -Name = Positive Test for sprintf_s -TYPE = DEFAULT -EXE1 = test2 -Description -= Tests sprintf_s with strings diff --git a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test3/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_snprintf_s/test3/CMakeLists.txt deleted file mode 100644 index 198f725a0..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test3/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test3.cpp -) - -add_executable(paltest_snprintf_test3 - ${SOURCES} -) - -add_dependencies(paltest_snprintf_test3 coreclrpal) - -target_link_libraries(paltest_snprintf_test3 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test3/test3.cpp b/src/pal/tests/palsuite/c_runtime/_snprintf_s/test3/test3.cpp deleted file mode 100644 index 99c25a654..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test3/test3.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test3.c -** -** Purpose: Tests sprintf_s with wide strings -** -** -**==========================================================================*/ - - - -#include -#include "../_snprintf_s.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - -int __cdecl main(int argc, char *argv[]) -{ - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - DoWStrTest("foo %S", convert("bar"), "foo bar"); - DoStrTest("foo %hS", "bar", "foo bar"); - DoWStrTest("foo %lS", convert("bar"), "foo bar"); - DoWStrTest("foo %wS", convert("bar"), "foo bar"); - DoWStrTest("foo %LS", convert("bar"), "foo bar"); - DoWStrTest("foo %I64S", convert("bar"), "foo bar"); - DoWStrTest("foo %5S", convert("bar"), "foo bar"); - DoWStrTest("foo %.2S", convert("bar"), "foo ba"); - DoWStrTest("foo %5.2S", convert("bar"), "foo ba"); - DoWStrTest("foo %-5S", convert("bar"), "foo bar "); - DoWStrTest("foo %05S", convert("bar"), "foo 00bar"); - DoWStrTest("foo %S", NULL, "foo (null)"); - DoStrTest("foo %hS", NULL, "foo (null)"); - DoWStrTest("foo %lS", NULL, "foo (null)"); - DoWStrTest("foo %wS", NULL, "foo (null)"); - DoWStrTest("foo %LS", NULL, "foo (null)"); - DoWStrTest("foo %I64S", NULL, "foo (null)"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test3/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_snprintf_s/test3/testinfo.dat deleted file mode 100644 index cc8de0eae..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test3/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = sprintf_s -Name = Positive Test for sprintf_s -TYPE = DEFAULT -EXE1 = test3 -Description -= Tests sprintf_s with wide strings diff --git a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test4/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_snprintf_s/test4/CMakeLists.txt deleted file mode 100644 index 81c3c1a0f..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test4/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test4.cpp -) - -add_executable(paltest_snprintf_test4 - ${SOURCES} -) - -add_dependencies(paltest_snprintf_test4 coreclrpal) - -target_link_libraries(paltest_snprintf_test4 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test4/test4.cpp b/src/pal/tests/palsuite/c_runtime/_snprintf_s/test4/test4.cpp deleted file mode 100644 index 7c0615213..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test4/test4.cpp +++ /dev/null @@ -1,69 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test4.c -** -** Purpose: Tests sprintf_s with pointers -** -** -**==========================================================================*/ - - - -#include -#include "../_snprintf_s.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - - -int __cdecl main(int argc, char *argv[]) -{ - void *ptr = (void*) 0x123456; - INT64 lptr = I64(0x1234567887654321); - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - /* - ** Run only on 64 bit platforms - */ - #if defined(BIT64) - Trace("Testing for 64 Bit Platforms \n"); - DoPointerTest("%p", NULL, "NULL", "0000000000000000"); - DoPointerTest("%p", ptr, "pointer to 0x123456", "0000000000123456"); - DoPointerTest("%17p", ptr, "pointer to 0x123456", " 0000000000123456"); - DoPointerTest("%17p", ptr, "pointer to 0x123456", " 0000000000123456"); - DoPointerTest("%-17p", ptr, "pointer to 0x123456", "0000000000123456 "); - DoPointerTest("%+p", ptr, "pointer to 0x123456", "0000000000123456"); - DoPointerTest("%#p", ptr, "pointer to 0x123456", "0X0000000000123456"); - DoPointerTest("%lp", ptr, "pointer to 0x123456", "00123456"); - DoPointerTest("%hp", ptr, "pointer to 0x123456", "00003456"); - DoPointerTest("%Lp", ptr, "pointer to 0x123456", "00123456"); - DoI64Test("%I64p", lptr, "pointer to 0x1234567887654321", - "1234567887654321"); - #else - Trace("Testing for Non 64 Bit Platforms \n"); - DoPointerTest("%p", NULL, "NULL", "00000000"); - DoPointerTest("%p", ptr, "pointer to 0x123456", "00123456"); - DoPointerTest("%9p", ptr, "pointer to 0x123456", " 00123456"); - DoPointerTest("%09p", ptr, "pointer to 0x123456", " 00123456"); - DoPointerTest("%-9p", ptr, "pointer to 0x123456", "00123456 "); - DoPointerTest("%+p", ptr, "pointer to 0x123456", "00123456"); - DoPointerTest("%#p", ptr, "pointer to 0x123456", "0X00123456"); - DoPointerTest("%lp", ptr, "pointer to 0x123456", "00123456"); - DoPointerTest("%hp", ptr, "pointer to 0x123456", "00003456"); - DoPointerTest("%Lp", ptr, "pointer to 0x123456", "00123456"); - DoI64Test("%I64p", lptr, "pointer to 0x1234567887654321", - "1234567887654321"); - #endif //defined(BIT64) - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test4/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_snprintf_s/test4/testinfo.dat deleted file mode 100644 index f53f78499..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test4/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = sprintf_s -Name = Positive Test for sprintf_s -TYPE = DEFAULT -EXE1 = test4 -Description -= Tests sprintf_s with pointers diff --git a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test6/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_snprintf_s/test6/CMakeLists.txt deleted file mode 100644 index 08ead969f..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test6/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test6.cpp -) - -add_executable(paltest_snprintf_test6 - ${SOURCES} -) - -add_dependencies(paltest_snprintf_test6 coreclrpal) - -target_link_libraries(paltest_snprintf_test6 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test6/test6.cpp b/src/pal/tests/palsuite/c_runtime/_snprintf_s/test6/test6.cpp deleted file mode 100644 index 45c9e2b79..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test6/test6.cpp +++ /dev/null @@ -1,47 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test6.c -** -** Purpose: Tests sprintf_s with characters -** -** -**==========================================================================*/ - - - -#include -#include "../_snprintf_s.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - -int __cdecl main(int argc, char *argv[]) -{ - WCHAR wc = (WCHAR) 'c'; - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - - DoCharTest("foo %c", 'b', "foo b"); - DoCharTest("foo %hc", 'b', "foo b"); - DoWCharTest("foo %lc", wc, "foo c"); - DoCharTest("foo %Lc", 'b', "foo b"); - DoCharTest("foo %I64c", 'b', "foo b"); - DoCharTest("foo %5c", 'b', "foo b"); - DoCharTest("foo %.0c", 'b', "foo b"); - DoCharTest("foo %-5c", 'b', "foo b "); - DoCharTest("foo %05c", 'b', "foo 0000b"); - DoCharTest("foo % c", 'b', "foo b"); - DoCharTest("foo %#c", 'b', "foo b"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test6/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_snprintf_s/test6/testinfo.dat deleted file mode 100644 index 06e31e85d..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test6/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = sprintf_s -Name =Positive Test for sprintf_s -TYPE = DEFAULT -EXE1 = test6 -Description -= Tests sprintf_s with characters diff --git a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test7/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_snprintf_s/test7/CMakeLists.txt deleted file mode 100644 index 71564eacf..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test7/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test7.cpp -) - -add_executable(paltest_snprintf_test7 - ${SOURCES} -) - -add_dependencies(paltest_snprintf_test7 coreclrpal) - -target_link_libraries(paltest_snprintf_test7 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test7/test7.cpp b/src/pal/tests/palsuite/c_runtime/_snprintf_s/test7/test7.cpp deleted file mode 100644 index 5c10fc8ea..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test7/test7.cpp +++ /dev/null @@ -1,47 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test7.c -** -** Purpose: Tests sprintf_s with wide characters -** -** -**==========================================================================*/ - - - -#include -#include "../_snprintf_s.h" -/* - * Notes: memcmp is used, as is strlen. - */ - - -int __cdecl main(int argc, char *argv[]) -{ - WCHAR wb = (WCHAR) 'b'; - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - - DoWCharTest("foo %C", wb, "foo b"); - DoWCharTest("foo %hC", wb, "foo b"); - DoCharTest("foo %lC", 'c', "foo c"); - DoWCharTest("foo %LC", wb, "foo b"); - DoWCharTest("foo %I64C", wb, "foo b"); - DoWCharTest("foo %5C", wb, "foo b"); - DoWCharTest("foo %.0C", wb, "foo b"); - DoWCharTest("foo %-5C", wb, "foo b "); - DoWCharTest("foo %05C", wb, "foo 0000b"); - DoWCharTest("foo % C", wb, "foo b"); - DoWCharTest("foo %#C", wb, "foo b"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test7/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_snprintf_s/test7/testinfo.dat deleted file mode 100644 index 647c9d80f..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test7/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = sprintf_s -Name = Positive Test for sprintf_s -TYPE = DEFAULT -EXE1 = test7 -Description -= Tests sprintf_s with wide characters diff --git a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test8/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_snprintf_s/test8/CMakeLists.txt deleted file mode 100644 index 377883308..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test8/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test8.cpp -) - -add_executable(paltest_snprintf_test8 - ${SOURCES} -) - -add_dependencies(paltest_snprintf_test8 coreclrpal) - -target_link_libraries(paltest_snprintf_test8 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test8/test8.cpp b/src/pal/tests/palsuite/c_runtime/_snprintf_s/test8/test8.cpp deleted file mode 100644 index 416e357e1..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test8/test8.cpp +++ /dev/null @@ -1,56 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test8.c -** -** Purpose: Tests sprintf_s with decimal numbers -** -** -**==========================================================================*/ - - - -#include -#include "../_snprintf_s.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - - -int __cdecl main(int argc, char *argv[]) -{ - int neg = -42; - int pos = 42; - INT64 l = 42; - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - - DoNumTest("foo %d", pos, "foo 42"); - DoNumTest("foo %ld", 0xFFFF, "foo 65535"); - DoNumTest("foo %hd", 0xFFFF, "foo -1"); - DoNumTest("foo %Ld", pos, "foo 42"); - DoI64Test("foo %I64d", l, "42", "foo 42"); - DoNumTest("foo %3d", pos, "foo 42"); - DoNumTest("foo %-3d", pos, "foo 42 "); - DoNumTest("foo %.1d", pos, "foo 42"); - DoNumTest("foo %.3d", pos, "foo 042"); - DoNumTest("foo %03d", pos, "foo 042"); - DoNumTest("foo %#d", pos, "foo 42"); - DoNumTest("foo %+d", pos, "foo +42"); - DoNumTest("foo % d", pos, "foo 42"); - DoNumTest("foo %+d", neg, "foo -42"); - DoNumTest("foo % d", neg, "foo -42"); - - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test8/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_snprintf_s/test8/testinfo.dat deleted file mode 100644 index 524834e53..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test8/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = sprintf_s -Name = Positive Test for sprintf_s -TYPE = DEFAULT -EXE1 = test8 -Description -= Tests sprintf_s with decimal numbers diff --git a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test9/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_snprintf_s/test9/CMakeLists.txt deleted file mode 100644 index 90a5403de..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test9/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test9.cpp -) - -add_executable(paltest_snprintf_test9 - ${SOURCES} -) - -add_dependencies(paltest_snprintf_test9 coreclrpal) - -target_link_libraries(paltest_snprintf_test9 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test9/test9.cpp b/src/pal/tests/palsuite/c_runtime/_snprintf_s/test9/test9.cpp deleted file mode 100644 index 18b1cb783..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test9/test9.cpp +++ /dev/null @@ -1,55 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test9.c -** -** Purpose: Tests sprintf_s with integer numbers -** -** -**==========================================================================*/ - - - -#include -#include "../_snprintf_s.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - - -int __cdecl main(int argc, char *argv[]) -{ - int neg = -42; - int pos = 42; - INT64 l = 42; - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - - DoNumTest("foo %i", pos, "foo 42"); - DoNumTest("foo %li", 0xFFFF, "foo 65535"); - DoNumTest("foo %hi", 0xFFFF, "foo -1"); - DoNumTest("foo %Li", pos, "foo 42"); - DoI64Test("foo %I64i", l, "42", "foo 42"); - DoNumTest("foo %3i", pos, "foo 42"); - DoNumTest("foo %-3i", pos, "foo 42 "); - DoNumTest("foo %.1i", pos, "foo 42"); - DoNumTest("foo %.3i", pos, "foo 042"); - DoNumTest("foo %03i", pos, "foo 042"); - DoNumTest("foo %#i", pos, "foo 42"); - DoNumTest("foo %+i", pos, "foo +42"); - DoNumTest("foo % i", pos, "foo 42"); - DoNumTest("foo %+i", neg, "foo -42"); - DoNumTest("foo % i", neg, "foo -42"); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test9/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_snprintf_s/test9/testinfo.dat deleted file mode 100644 index 7c51443a3..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snprintf_s/test9/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = sprintf_s -Name = Positive Test for sprintf_s -TYPE = DEFAULT -EXE1 = test9 -Description -= Tests sprintf_s with integer numbers diff --git a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_snwprintf_s/CMakeLists.txt deleted file mode 100644 index 8fe1cb60a..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/CMakeLists.txt +++ /dev/null @@ -1,21 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test10) -add_subdirectory(test11) -add_subdirectory(test12) -add_subdirectory(test13) -add_subdirectory(test14) -add_subdirectory(test15) -add_subdirectory(test16) -add_subdirectory(test17) -add_subdirectory(test18) -add_subdirectory(test19) -add_subdirectory(test2) -add_subdirectory(test3) -add_subdirectory(test4) -add_subdirectory(test6) -add_subdirectory(test7) -add_subdirectory(test8) -add_subdirectory(test9) - diff --git a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/_snwprintf_s.h b/src/pal/tests/palsuite/c_runtime/_snwprintf_s/_snwprintf_s.h deleted file mode 100644 index 19d192114..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/_snwprintf_s.h +++ /dev/null @@ -1,199 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: swprintf_s.h -** -** Purpose: Containts common testing functions for swprintf_s -** -** -**==========================================================================*/ - -#ifndef ___SNWPRINTF_H__ -#define ___SNWPRINTF_H__ - -void DoWStrTest(const WCHAR *formatstr, WCHAR *param, const WCHAR *checkstr) -{ - WCHAR buf[256] = { 0 }; - - _snwprintf_s(buf, 256, _TRUNCATE, formatstr, param); - - if (memcmp(buf, checkstr, wcslen(checkstr) * 2 + 2) != 0) - { - Fail("ERROR: failed to insert wide string \"%s\" into \"%s\".\n" - "Expected \"%s\", got \"%s\".\n", convertC(param), - convertC(formatstr), convertC(checkstr), convertC(buf)); - } -} - -void DoStrTest(const WCHAR *formatstr, char *param, const WCHAR *checkstr) -{ - WCHAR buf[256] = { 0 }; - - _snwprintf_s(buf, 256, _TRUNCATE, formatstr, param); - - if (memcmp(buf, checkstr, wcslen(checkstr) * 2 + 2) != 0) - { - Fail("ERROR: failed to insert wide string \"%s\" into \"%s\".\n" - "Expected \"%s\", got \"%s\".\n", - param, convertC(formatstr), convertC(checkstr), convertC(buf)); - } -} - -void DoPointerTest(const WCHAR *formatstr, void* param, const WCHAR *checkstr1) -{ - WCHAR buf[256] = { 0 }; - - _snwprintf_s(buf, 256, _TRUNCATE, formatstr, param); - if (memcmp(buf, checkstr1, wcslen(checkstr1)*2 + 2) != 0) - { - Fail("ERROR: failed to insert pointer to %#p into \"%s\"\n" - "Expected \"%s\", got \"%s\".\n", param, convertC(formatstr), - convertC(checkstr1), convertC(buf)); - } -} - -void DoCountTest(const WCHAR *formatstr, int param, const WCHAR *checkstr) -{ - WCHAR buf[512] = { 0 }; - int n = -1; - - swprintf_s(buf, 512, formatstr, &n); - - if (n != param) - { - Fail("ERROR: Expected count parameter to resolve to %d, got %d\n", - param, n); - } - - if (memcmp(buf, checkstr, wcslen(checkstr)*2 + 2) != 0) - { - Fail("ERROR: Expected \"%s\" got \"%s\".\n", - convertC(checkstr), convertC(buf)); - } -} - -void DoShortCountTest(const WCHAR *formatstr, int param, const WCHAR *checkstr) -{ - WCHAR buf[256] = { 0 }; - short int n = -1; - - _snwprintf_s(buf, 256, _TRUNCATE, formatstr, &n); - - if (n != param) - { - Fail("ERROR: Expected count parameter to resolve to %d, got %d\n", - param, n); - } - - if (memcmp(buf, checkstr, wcslen(checkstr)*2 + 2) != 0) - { - Fail("ERROR: Expected \"%s\" got \"%s\".\n", - convertC(checkstr), convertC(buf)); - } -} - -void DoCharTest(const WCHAR *formatstr, char param, const WCHAR *checkstr) -{ - WCHAR buf[256] = { 0 }; - - _snwprintf_s(buf, 256, _TRUNCATE, formatstr, param); - if (memcmp(buf, checkstr, wcslen(checkstr)*2 + 2) != 0) - { - Fail("ERROR: failed to insert char \'%c\' (%d) into \"%s\"\n" - "Expected \"%s\" got \"%s\".\n", param, param, - convertC(formatstr), convertC(checkstr), convertC(buf)); - } -} - -void DoWCharTest(const WCHAR *formatstr, WCHAR param, const WCHAR *checkstr) -{ - WCHAR buf[256] = { 0 }; - - _snwprintf_s(buf, 256, _TRUNCATE, formatstr, param); - if (memcmp(buf, checkstr, wcslen(checkstr)*2 + 2) != 0) - { - Fail("ERROR: failed to insert wide char \'%c\' (%d) into \"%s\"\n" - "Expected \"%s\" got \"%s\".\n", (char) param, param, - convertC(formatstr), convertC(checkstr), convertC(buf)); - } -} - -void DoNumTest(const WCHAR *formatstr, int value, const WCHAR *checkstr) -{ - WCHAR buf[256] = { 0 }; - - _snwprintf_s(buf, 256, _TRUNCATE, formatstr, value); - if (memcmp(buf, checkstr, wcslen(checkstr)* 2 + 2) != 0) - { - Fail("ERROR: failed to insert %#x into \"%s\"\n" - "Expected \"%s\" got \"%s\".\n", value, convertC(formatstr), - convertC(checkstr), convertC(buf)); - } -} - - -void DoI64Test(const WCHAR *formatstr, INT64 param, char *paramdesc, - const WCHAR *checkstr1) -{ - WCHAR buf[256] = { 0 }; - - _snwprintf_s(buf, 256, _TRUNCATE, formatstr, param); - if (memcmp(buf, checkstr1, wcslen(checkstr1)*2 + 2) != 0) - { - Fail("ERROR: failed to insert %s into \"%s\"\n" - "Expected \"%s\", got \"%s\".\n", paramdesc, - convertC(formatstr), convertC(checkstr1), convertC(buf)); - } -} - -void DoDoubleTest(const WCHAR *formatstr, double value, const WCHAR *checkstr1, - const WCHAR *checkstr2) -{ - WCHAR buf[256] = { 0 }; - - _snwprintf_s(buf, 256, _TRUNCATE, formatstr, value); - if (memcmp(buf, checkstr1, wcslen(checkstr1)*2 + 2) != 0 && - memcmp(buf, checkstr2, wcslen(checkstr2)*2 + 2) != 0) - { - Fail("ERROR: failed to insert %f into \"%s\"\n" - "Expected \"%s\" or \"%s\", got \"%s\".\n", - value, convertC(formatstr), convertC(checkstr1), - convertC(checkstr2), convertC(buf)); - } -} - -void DoArgumentPrecTest(const WCHAR *formatstr, int precision, void *param, - char *paramstr, const WCHAR *checkstr1, const WCHAR *checkstr2) -{ - WCHAR buf[256]; - - _snwprintf_s(buf, 256, _TRUNCATE, formatstr, precision, param); - if (memcmp(buf, checkstr1, wcslen(checkstr1) + 2) != 0 && - memcmp(buf, checkstr2, wcslen(checkstr2) + 2) != 0) - { - Fail("ERROR: failed to insert %s into \"%s\" with precision %d\n" - "Expected \"%s\" or \"%s\", got \"%s\".\n", - paramstr, convertC(formatstr), precision, - convertC(checkstr1), convertC(checkstr2) ,convertC(buf)); - } -} - -void DoArgumentPrecDoubleTest(const WCHAR *formatstr, int precision, double param, - const WCHAR *checkstr) -{ - WCHAR buf[256]; - - _snwprintf_s(buf, 256, _TRUNCATE, formatstr, precision, param); - if (memcmp(buf, checkstr, wcslen(checkstr) + 2) != 0) - { - Fail("ERROR: failed to insert %f into \"%s\" with precision %d\n" - "Expected \"%s\", got \"%s\".\n", param, convertC(formatstr), - precision, convertC(checkstr), convertC(buf)); - } -} - -#endif - diff --git a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test1/CMakeLists.txt deleted file mode 100644 index 89496c562..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_snwprintf_test1 - ${SOURCES} -) - -add_dependencies(paltest_snwprintf_test1 coreclrpal) - -target_link_libraries(paltest_snwprintf_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test1/test1.cpp deleted file mode 100644 index ba85103cb..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test1/test1.cpp +++ /dev/null @@ -1,62 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: General test to see if swprintf_s works correctly -** -** -**==========================================================================*/ - - - -#include -#include "../_snwprintf_s.h" - -/* memcmp is used to verify the results, so this test is dependent on it. */ -/* ditto with wcslen */ - - -int __cdecl main(int argc, char *argv[]) -{ - WCHAR *checkstr; - WCHAR buf[256] = { 0 }; - int ret; - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - checkstr = convert("hello world"); - _snwprintf_s(buf, 256, _TRUNCATE, checkstr); - if (memcmp(checkstr, buf, wcslen(checkstr)*2+2) != 0) - { - Fail("ERROR: Expected \"%s\", got \"%s\"\n", - convertC(checkstr), convertC(buf)); - } - - _snwprintf_s(buf, 256, _TRUNCATE, convert("xxxxxxxxxxxxxxxxx")); - ret = _snwprintf_s(buf, 8, _TRUNCATE, checkstr); - if ((memcmp(checkstr, buf, 14) != 0) || (buf[7] != 0)) - { - Fail("ERROR: Expected \"%8s\", got \"%8s\"\n", - convertC(checkstr), convertC(buf)); - } - if (ret >= 0) - { - Fail("ERROR: Expected negative return value, got %d.\n", ret); - } - if (buf[8] != (WCHAR) 'x') - { - Fail("ERROR: buffer overflow using \"%s\" with length 8.\n", - convertC(checkstr)); - } - - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test1/testinfo.dat deleted file mode 100644 index 96d7914ce..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test1/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = swprintf_s -Name = Positive Test for swprintf_s -TYPE = DEFAULT -EXE1 = test1 -Description -= General test to see if swprintf_s works correctly diff --git a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test10/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test10/CMakeLists.txt deleted file mode 100644 index 60703fa16..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test10/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test10.cpp -) - -add_executable(paltest_snwprintf_test10 - ${SOURCES} -) - -add_dependencies(paltest_snwprintf_test10 coreclrpal) - -target_link_libraries(paltest_snwprintf_test10 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test10/test10.cpp b/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test10/test10.cpp deleted file mode 100644 index 298f82b00..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test10/test10.cpp +++ /dev/null @@ -1,54 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test10.c -** -** Purpose: Tests swprintf_s with octal numbers -** -** -**==========================================================================*/ - - - -#include -#include "../_snwprintf_s.h" - -/* memcmp is used to verify the results, so this test is dependent on it. */ -/* ditto with wcslen */ - -int __cdecl main(int argc, char *argv[]) -{ - int neg = -42; - int pos = 42; - INT64 l = 42; - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - - DoNumTest(convert("foo %o"), pos, convert("foo 52")); - DoNumTest(convert("foo %lo"), 0xFFFF, convert("foo 177777")); - DoNumTest(convert("foo %ho"), 0xFFFF, convert("foo 177777")); - DoNumTest(convert("foo %Lo"), pos, convert("foo 52")); - DoI64Test(convert("foo %I64o"), l, "42", convert("foo 52")); - DoNumTest(convert("foo %3o"), pos, convert("foo 52")); - DoNumTest(convert("foo %-3o"), pos, convert("foo 52 ")); - DoNumTest(convert("foo %.1o"), pos, convert("foo 52")); - DoNumTest(convert("foo %.3o"), pos, convert("foo 052")); - DoNumTest(convert("foo %03o"), pos, convert("foo 052")); - DoNumTest(convert("foo %#o"), pos, convert("foo 052")); - DoNumTest(convert("foo %+o"), pos, convert("foo 52")); - DoNumTest(convert("foo % o"), pos, convert("foo 52")); - DoNumTest(convert("foo %+o"), neg, convert("foo 37777777726")); - DoNumTest(convert("foo % o"), neg, convert("foo 37777777726")); - - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test10/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test10/testinfo.dat deleted file mode 100644 index 887bbf76c..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test10/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = swprintf_s -Name = Positive Test for swprintf_s -TYPE = DEFAULT -EXE1 = test10 -Description -= Tests swprintf_s with octal numbers diff --git a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test11/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test11/CMakeLists.txt deleted file mode 100644 index c305c62f3..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test11/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test11.cpp -) - -add_executable(paltest_snwprintf_test11 - ${SOURCES} -) - -add_dependencies(paltest_snwprintf_test11 coreclrpal) - -target_link_libraries(paltest_snwprintf_test11 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test11/test11.cpp b/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test11/test11.cpp deleted file mode 100644 index 519668791..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test11/test11.cpp +++ /dev/null @@ -1,54 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test11.c -** -** Purpose: Tests swprintf_s with unsigned numbers -** -** -**==========================================================================*/ - - - -#include -#include "../_snwprintf_s.h" - -/* memcmp is used to verify the results, so this test is dependent on it. */ -/* ditto with wcslen */ - -int __cdecl main(int argc, char *argv[]) -{ - int neg = -42; - int pos = 42; - INT64 l = 42; - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - - DoNumTest(convert("foo %u"), pos, convert("foo 42")); - DoNumTest(convert("foo %lu"), 0xFFFF, convert("foo 65535")); - DoNumTest(convert("foo %hu"), 0xFFFF, convert("foo 65535")); - DoNumTest(convert("foo %Lu"), pos, convert("foo 42")); - DoI64Test(convert("foo %I64u"), l, "42", convert("foo 42")); - DoNumTest(convert("foo %3u"), pos, convert("foo 42")); - DoNumTest(convert("foo %-3u"), pos, convert("foo 42 ")); - DoNumTest(convert("foo %.1u"), pos, convert("foo 42")); - DoNumTest(convert("foo %.3u"), pos, convert("foo 042")); - DoNumTest(convert("foo %03u"), pos, convert("foo 042")); - DoNumTest(convert("foo %#u"), pos, convert("foo 42")); - DoNumTest(convert("foo %+u"), pos, convert("foo 42")); - DoNumTest(convert("foo % u"), pos, convert("foo 42")); - DoNumTest(convert("foo %+u"), neg, convert("foo 4294967254")); - DoNumTest(convert("foo % u"), neg, convert("foo 4294967254")); - - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test11/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test11/testinfo.dat deleted file mode 100644 index 3bda85e33..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test11/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = swprintf_s -Name = Positive Test for swprintf_s -TYPE = DEFAULT -EXE1 = test11 -Description -= Tests swprintf_s with unsigned numbers diff --git a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test12/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test12/CMakeLists.txt deleted file mode 100644 index 9532e6793..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test12/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test12.cpp -) - -add_executable(paltest_snwprintf_test12 - ${SOURCES} -) - -add_dependencies(paltest_snwprintf_test12 coreclrpal) - -target_link_libraries(paltest_snwprintf_test12 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test12/test12.cpp b/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test12/test12.cpp deleted file mode 100644 index 52780aff0..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test12/test12.cpp +++ /dev/null @@ -1,54 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test12.c -** -** Purpose: Tests swprintf_s with hex numbers (lowercase) -** -** -**==========================================================================*/ - - - -#include -#include "../_snwprintf_s.h" - -/* memcmp is used to verify the results, so this test is dependent on it. */ -/* ditto with wcslen */ - -int __cdecl main(int argc, char *argv[]) -{ - int neg = -42; - int pos = 0x1234ab; - INT64 l = I64(0x1234567887654321); - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - - DoNumTest(convert("foo %x"), pos, convert("foo 1234ab")); - DoNumTest(convert("foo %lx"), pos, convert("foo 1234ab")); - DoNumTest(convert("foo %hx"), pos, convert("foo 34ab")); - DoNumTest(convert("foo %Lx"), pos, convert("foo 1234ab")); - DoI64Test(convert("foo %I64x"), l, "0x1234567887654321", - convert("foo 1234567887654321")); - DoNumTest(convert("foo %7x"), pos, convert("foo 1234ab")); - DoNumTest(convert("foo %-7x"), pos, convert("foo 1234ab ")); - DoNumTest(convert("foo %.1x"), pos, convert("foo 1234ab")); - DoNumTest(convert("foo %.7x"), pos, convert("foo 01234ab")); - DoNumTest(convert("foo %07x"), pos, convert("foo 01234ab")); - DoNumTest(convert("foo %#x"), pos, convert("foo 0x1234ab")); - DoNumTest(convert("foo %+x"), pos, convert("foo 1234ab")); - DoNumTest(convert("foo % x"), pos, convert("foo 1234ab")); - DoNumTest(convert("foo %+x"), neg, convert("foo ffffffd6")); - DoNumTest(convert("foo % x"), neg, convert("foo ffffffd6")); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test12/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test12/testinfo.dat deleted file mode 100644 index d808a3b8f..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test12/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = swprintf_s -Name = Positive Test for swprintf_s -TYPE = DEFAULT -EXE1 = test12 -Description -= Tests swprintf_s with hex numbers (lowercase) diff --git a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test13/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test13/CMakeLists.txt deleted file mode 100644 index f1088003e..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test13/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test13.cpp -) - -add_executable(paltest_snwprintf_test13 - ${SOURCES} -) - -add_dependencies(paltest_snwprintf_test13 coreclrpal) - -target_link_libraries(paltest_snwprintf_test13 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test13/test13.cpp b/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test13/test13.cpp deleted file mode 100644 index fa948b3a1..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test13/test13.cpp +++ /dev/null @@ -1,54 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test13.c -** -** Purpose: Tests swprintf_s with hex numbers (uppercase) -** -** -**==========================================================================*/ - - - -#include -#include "../_snwprintf_s.h" - -/* memcmp is used to verify the results, so this test is dependent on it. */ -/* ditto with wcslen */ - -int __cdecl main(int argc, char *argv[]) -{ - int neg = -42; - int pos = 0x1234ab; - INT64 l = I64(0x1234567887654321); - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - - DoNumTest(convert("foo %X"), pos, convert("foo 1234AB")); - DoNumTest(convert("foo %lX"), pos, convert("foo 1234AB")); - DoNumTest(convert("foo %hX"), pos, convert("foo 34AB")); - DoNumTest(convert("foo %LX"), pos, convert("foo 1234AB")); - DoI64Test(convert("foo %I64X"), l, "0x1234567887654321", - convert("foo 1234567887654321")); - DoNumTest(convert("foo %7X"), pos, convert("foo 1234AB")); - DoNumTest(convert("foo %-7X"), pos, convert("foo 1234AB ")); - DoNumTest(convert("foo %.1X"), pos, convert("foo 1234AB")); - DoNumTest(convert("foo %.7X"), pos, convert("foo 01234AB")); - DoNumTest(convert("foo %07X"), pos, convert("foo 01234AB")); - DoNumTest(convert("foo %#X"), pos, convert("foo 0X1234AB")); - DoNumTest(convert("foo %+X"), pos, convert("foo 1234AB")); - DoNumTest(convert("foo % X"), pos, convert("foo 1234AB")); - DoNumTest(convert("foo %+X"), neg, convert("foo FFFFFFD6")); - DoNumTest(convert("foo % X"), neg, convert("foo FFFFFFD6")); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test13/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test13/testinfo.dat deleted file mode 100644 index 2e5800ec3..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test13/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = swprintf_s -Name = Positive Test for swprintf_s -TYPE = DEFAULT -EXE1 = test13 -Description -= Tests swprintf_s with hex numbers (uppercase) diff --git a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test14/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test14/CMakeLists.txt deleted file mode 100644 index 79a04329c..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test14/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test14.cpp -) - -add_executable(paltest_snwprintf_test14 - ${SOURCES} -) - -add_dependencies(paltest_snwprintf_test14 coreclrpal) - -target_link_libraries(paltest_snwprintf_test14 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test14/test14.cpp b/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test14/test14.cpp deleted file mode 100644 index aea289d1a..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test14/test14.cpp +++ /dev/null @@ -1,66 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test14.c -** -** Purpose: Tests swprintf_s with exponential format doubles (lowercase) -** -** -**==========================================================================*/ - - - -#include -#include "../_snwprintf_s.h" - -/* memcmp is used to verify the results, so this test is dependent on it. */ -/* ditto with wcslen */ - -int __cdecl main(int argc, char *argv[]) -{ - double val = 256.0; - double neg = -256.0; - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - - DoDoubleTest(convert("foo %e"), val, convert("foo 2.560000e+002"), - convert("foo 2.560000e+02")); - DoDoubleTest(convert("foo %le"), val, convert("foo 2.560000e+002"), - convert("foo 2.560000e+02")); - DoDoubleTest(convert("foo %he"), val, convert("foo 2.560000e+002"), - convert("foo 2.560000e+02")); - DoDoubleTest(convert("foo %Le"), val, convert("foo 2.560000e+002"), - convert("foo 2.560000e+02")); - DoDoubleTest(convert("foo %I64e"), val, convert("foo 2.560000e+002"), - convert("foo 2.560000e+02")); - DoDoubleTest(convert("foo %14e"), val, convert("foo 2.560000e+002"), - convert("foo 2.560000e+02")); - DoDoubleTest(convert("foo %-14e"), val, convert("foo 2.560000e+002 "), - convert("foo 2.560000e+02 ")); - DoDoubleTest(convert("foo %.1e"), val, convert("foo 2.6e+002"), - convert("foo 2.6e+02")); - DoDoubleTest(convert("foo %.8e"), val, convert("foo 2.56000000e+002"), - convert("foo 2.56000000e+02")); - DoDoubleTest(convert("foo %014e"), val, convert("foo 02.560000e+002"), - convert("foo 002.560000e+02")); - DoDoubleTest(convert("foo %#e"), val, convert("foo 2.560000e+002"), - convert("foo 2.560000e+02")); - DoDoubleTest(convert("foo %+e"), val, convert("foo +2.560000e+002"), - convert("foo +2.560000e+02")); - DoDoubleTest(convert("foo % e"), val, convert("foo 2.560000e+002"), - convert("foo 2.560000e+02")); - DoDoubleTest(convert("foo %+e"), neg, convert("foo -2.560000e+002"), - convert("foo -2.560000e+02")); - DoDoubleTest(convert("foo % e"), neg, convert("foo -2.560000e+002"), - convert("foo -2.560000e+02")); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test14/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test14/testinfo.dat deleted file mode 100644 index 25bd5099c..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test14/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = swprintf_s -Name = Positive Test for swprintf_s -TYPE = DEFAULT -EXE1 = test14 -Description -= Tests swprintf_s with exponential format doubles (lowercase) diff --git a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test15/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test15/CMakeLists.txt deleted file mode 100644 index c29ec7d92..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test15/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test15.cpp -) - -add_executable(paltest_snwprintf_test15 - ${SOURCES} -) - -add_dependencies(paltest_snwprintf_test15 coreclrpal) - -target_link_libraries(paltest_snwprintf_test15 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test15/test15.cpp b/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test15/test15.cpp deleted file mode 100644 index 14db14b49..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test15/test15.cpp +++ /dev/null @@ -1,67 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test15.c -** -** Purpose: Tests swprintf_s with exponential format doubles (uppercase) -** -** -**==========================================================================*/ - - - -#include -#include "../_snwprintf_s.h" - -/* memcmp is used to verify the results, so this test is dependent on it. */ -/* ditto with wcslen */ - - -int __cdecl main(int argc, char *argv[]) -{ - double val = 256.0; - double neg = -256.0; - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - - DoDoubleTest(convert("foo %E"), val, convert("foo 2.560000E+002"), - convert("foo 2.560000E+02")); - DoDoubleTest(convert("foo %lE"), val, convert("foo 2.560000E+002"), - convert("foo 2.560000E+02")); - DoDoubleTest(convert("foo %hE"), val, convert("foo 2.560000E+002"), - convert("foo 2.560000E+02")); - DoDoubleTest(convert("foo %LE"), val, convert("foo 2.560000E+002"), - convert("foo 2.560000E+02")); - DoDoubleTest(convert("foo %I64E"), val, convert("foo 2.560000E+002"), - convert("foo 2.560000E+02")); - DoDoubleTest(convert("foo %14E"), val, convert("foo 2.560000E+002"), - convert("foo 2.560000E+02")); - DoDoubleTest(convert("foo %-14E"), val, convert("foo 2.560000E+002 "), - convert("foo 2.560000E+02 ")); - DoDoubleTest(convert("foo %.1E"), val, convert("foo 2.6E+002"), - convert("foo 2.6E+02")); - DoDoubleTest(convert("foo %.8E"), val, convert("foo 2.56000000E+002"), - convert("foo 2.56000000E+02")); - DoDoubleTest(convert("foo %014E"), val, convert("foo 02.560000E+002"), - convert("foo 002.560000E+02")); - DoDoubleTest(convert("foo %#E"), val, convert("foo 2.560000E+002"), - convert("foo 2.560000E+02")); - DoDoubleTest(convert("foo %+E"), val, convert("foo +2.560000E+002"), - convert("foo +2.560000E+02")); - DoDoubleTest(convert("foo % E"), val, convert("foo 2.560000E+002"), - convert("foo 2.560000E+02")); - DoDoubleTest(convert("foo %+E"), neg, convert("foo -2.560000E+002"), - convert("foo -2.560000E+02")); - DoDoubleTest(convert("foo % E"), neg, convert("foo -2.560000E+002"), - convert("foo -2.560000E+02")); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test15/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test15/testinfo.dat deleted file mode 100644 index 95d90e82e..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test15/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = swprintf_s -Name = Positive Test for swprintf_s -TYPE = DEFAULT -EXE1 = test15 -Description -= Tests swprintf_s with exponential format doubles (uppercase) diff --git a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test16/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test16/CMakeLists.txt deleted file mode 100644 index d42726644..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test16/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test16.cpp -) - -add_executable(paltest_snwprintf_test16 - ${SOURCES} -) - -add_dependencies(paltest_snwprintf_test16 coreclrpal) - -target_link_libraries(paltest_snwprintf_test16 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test16/test16.cpp b/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test16/test16.cpp deleted file mode 100644 index 4d9a717f2..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test16/test16.cpp +++ /dev/null @@ -1,65 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test16.c -** -** Purpose: Tests swprintf_s with decimal point format doubles -** -** -**==========================================================================*/ - - -#include -#include "../_snwprintf_s.h" - -/* memcmp is used to verify the results, so this test is dependent on it. */ -/* ditto with wcslen */ - -int __cdecl main(int argc, char *argv[]) -{ - double val = 2560.001; - double neg = -2560.001; - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - - DoDoubleTest(convert("foo %f"), val, convert("foo 2560.001000"), - convert("foo 2560.001000")); - DoDoubleTest(convert("foo %lf"), val, convert("foo 2560.001000"), - convert("foo 2560.001000")); - DoDoubleTest(convert("foo %hf"), val, convert("foo 2560.001000"), - convert("foo 2560.001000")); - DoDoubleTest(convert("foo %Lf"), val, convert("foo 2560.001000"), - convert("foo 2560.001000")); - DoDoubleTest(convert("foo %I64f"), val, convert("foo 2560.001000"), - convert("foo 2560.001000")); - DoDoubleTest(convert("foo %12f"), val, convert("foo 2560.001000"), - convert("foo 2560.001000")); - DoDoubleTest(convert("foo %-12f"), val, convert("foo 2560.001000 "), - convert("foo 2560.001000 ")); - DoDoubleTest(convert("foo %.1f"), val, convert("foo 2560.0"), - convert("foo 2560.0")); - DoDoubleTest(convert("foo %.8f"), val, convert("foo 2560.00100000"), - convert("foo 2560.00100000")); - DoDoubleTest(convert("foo %012f"), val, convert("foo 02560.001000"), - convert("foo 02560.001000")); - DoDoubleTest(convert("foo %#f"), val, convert("foo 2560.001000"), - convert("foo 2560.001000")); - DoDoubleTest(convert("foo %+f"), val, convert("foo +2560.001000"), - convert("foo +2560.001000")); - DoDoubleTest(convert("foo % f"), val, convert("foo 2560.001000"), - convert("foo 2560.001000")); - DoDoubleTest(convert("foo %+f"), neg, convert("foo -2560.001000"), - convert("foo -2560.001000")); - DoDoubleTest(convert("foo % f"), neg, convert("foo -2560.001000"), - convert("foo -2560.001000")); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test16/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test16/testinfo.dat deleted file mode 100644 index b81c847c6..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test16/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = swprintf_s -Name = Positive Test for swprintf_s -TYPE = DEFAULT -EXE1 = test16 -Description -= Tests swprintf_s with decimal point format doubles diff --git a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test17/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test17/CMakeLists.txt deleted file mode 100644 index 37fb79012..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test17/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test17.cpp -) - -add_executable(paltest_snwprintf_test17 - ${SOURCES} -) - -add_dependencies(paltest_snwprintf_test17 coreclrpal) - -target_link_libraries(paltest_snwprintf_test17 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test17/test17.cpp b/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test17/test17.cpp deleted file mode 100644 index 6af1815b8..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test17/test17.cpp +++ /dev/null @@ -1,68 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test17.c -** -** Purpose: Tests swprintf_s with compact format doubles (lowercase) -** -** -**==========================================================================*/ - - - -#include -#include "../_snwprintf_s.h" - -/* memcmp is used to verify the results, so this test is dependent on it. */ -/* ditto with wcslen */ - -int __cdecl main(int argc, char *argv[]) -{ - double val = 2560.001; - double neg = -2560.001; - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - - DoDoubleTest(convert("foo %g"), val, convert("foo 2560"), - convert("foo 2560")); - DoDoubleTest(convert("foo %lg"), val, convert("foo 2560"), - convert("foo 2560")); - DoDoubleTest(convert("foo %hg"), val, convert("foo 2560"), - convert("foo 2560")); - DoDoubleTest(convert("foo %Lg"), val, convert("foo 2560"), - convert("foo 2560")); - DoDoubleTest(convert("foo %I64g"), val, convert("foo 2560"), - convert("foo 2560")); - DoDoubleTest(convert("foo %5g"), val, convert("foo 2560"), - convert("foo 2560")); - DoDoubleTest(convert("foo %-5g"), val, convert("foo 2560 "), - convert("foo 2560 ")); - DoDoubleTest(convert("foo %.1g"), val, convert("foo 3e+003"), - convert("foo 3e+03")); - DoDoubleTest(convert("foo %.2g"), val, convert("foo 2.6e+003"), - convert("foo 2.6e+03")); - DoDoubleTest(convert("foo %.12g"), val, convert("foo 2560.001"), - convert("foo 2560.001")); - DoDoubleTest(convert("foo %06g"), val, convert("foo 002560"), - convert("foo 002560")); - DoDoubleTest(convert("foo %#g"), val, convert("foo 2560.00"), - convert("foo 2560.00")); - DoDoubleTest(convert("foo %+g"), val, convert("foo +2560"), - convert("foo +2560")); - DoDoubleTest(convert("foo % g"), val, convert("foo 2560"), - convert("foo 2560")); - DoDoubleTest(convert("foo %+g"), neg, convert("foo -2560"), - convert("foo -2560")); - DoDoubleTest(convert("foo % g"), neg, convert("foo -2560"), - convert("foo -2560")); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test17/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test17/testinfo.dat deleted file mode 100644 index d64366702..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test17/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = swprintf_s -Name = Positive Test for swprintf_s -TYPE = DEFAULT -EXE1 = test17 -Description -= Tests swprintf_s with compact format doubles (lowercase) diff --git a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test18/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test18/CMakeLists.txt deleted file mode 100644 index a880738a9..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test18/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test18.cpp -) - -add_executable(paltest_snwprintf_test18 - ${SOURCES} -) - -add_dependencies(paltest_snwprintf_test18 coreclrpal) - -target_link_libraries(paltest_snwprintf_test18 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test18/test18.cpp b/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test18/test18.cpp deleted file mode 100644 index 020a88509..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test18/test18.cpp +++ /dev/null @@ -1,69 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test18.c -** -** Purpose: Tests swprintf_s with compact format doubles (uppercase) -** -** -**==========================================================================*/ - - - - -#include -#include "../_snwprintf_s.h" - -/* memcmp is used to verify the results, so this test is dependent on it. */ -/* ditto with wcslen */ - -int __cdecl main(int argc, char *argv[]) -{ - double val = 2560.001; - double neg = -2560.001; - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - - DoDoubleTest(convert("foo %G"), val, convert("foo 2560"), - convert("foo 2560")); - DoDoubleTest(convert("foo %lG"), val, convert("foo 2560"), - convert("foo 2560")); - DoDoubleTest(convert("foo %hG"), val, convert("foo 2560"), - convert("foo 2560")); - DoDoubleTest(convert("foo %LG"), val, convert("foo 2560"), - convert("foo 2560")); - DoDoubleTest(convert("foo %I64G"), val, convert("foo 2560"), - convert("foo 2560")); - DoDoubleTest(convert("foo %5G"), val, convert("foo 2560"), - convert("foo 2560")); - DoDoubleTest(convert("foo %-5G"), val, convert("foo 2560 "), - convert("foo 2560 ")); - DoDoubleTest(convert("foo %.1G"), val, convert("foo 3E+003"), - convert("foo 3E+03")); - DoDoubleTest(convert("foo %.2G"), val, convert("foo 2.6E+003"), - convert("foo 2.6E+03")); - DoDoubleTest(convert("foo %.12G"), val, convert("foo 2560.001"), - convert("foo 2560.001")); - DoDoubleTest(convert("foo %06G"), val, convert("foo 002560"), - convert("foo 002560")); - DoDoubleTest(convert("foo %#G"), val, convert("foo 2560.00"), - convert("foo 2560.00")); - DoDoubleTest(convert("foo %+G"), val, convert("foo +2560"), - convert("foo +2560")); - DoDoubleTest(convert("foo % G"), val, convert("foo 2560"), - convert("foo 2560")); - DoDoubleTest(convert("foo %+G"), neg, convert("foo -2560"), - convert("foo -2560")); - DoDoubleTest(convert("foo % G"), neg, convert("foo -2560"), - convert("foo -2560")); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test18/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test18/testinfo.dat deleted file mode 100644 index dfc2cd5f4..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test18/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = swprintf_s -Name = Positive Test for swprintf_s -TYPE = DEFAULT -EXE1 = test18 -Description -= Tests swprintf_s with compact format doubles (uppercase) diff --git a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test19/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test19/CMakeLists.txt deleted file mode 100644 index cb16e1e15..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test19/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test19.cpp -) - -add_executable(paltest_snwprintf_test19 - ${SOURCES} -) - -add_dependencies(paltest_snwprintf_test19 coreclrpal) - -target_link_libraries(paltest_snwprintf_test19 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test19/test19.cpp b/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test19/test19.cpp deleted file mode 100644 index d335d1d10..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test19/test19.cpp +++ /dev/null @@ -1,82 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test19.c -** -** Purpose: Tests swprintf_s with argument specified precision -** -** -**==========================================================================*/ - - - -#include -#include "../_snwprintf_s.h" - -int __cdecl main(int argc, char *argv[]) -{ - int n = -1; - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - DoArgumentPrecTest(convert("%.*s"), 2, (void*)convert("bar"), "bar", - convert("ba"), convert("ba")); - DoArgumentPrecTest(convert("%.*S"), 2, (void*)"bar", "bar", - convert("ba"), convert("ba")); - DoArgumentPrecTest(convert("%.*c"), 0, (void*)'a', "a", - convert("a"), convert("a")); - DoArgumentPrecTest(convert("%.*c"), 4, (void*)'a', "a", - convert("a"), convert("a")); - DoArgumentPrecTest(convert("%.*C"), 0, (void*)'a', "a", - convert("a"), convert("a")); - DoArgumentPrecTest(convert("%.*C"), 4, (void*)'a', "a", - convert("a"), convert("a")); - DoArgumentPrecTest(convert("%.*d"), 1, (void*)42, "42", - convert("42"), convert("42")); - DoArgumentPrecTest(convert("%.*d"), 3, (void*)42, "42", - convert("042"), convert("042")); - DoArgumentPrecTest(convert("%.*i"), 1, (void*)42, "42", - convert("42"), convert("42")); - DoArgumentPrecTest(convert("%.*i"), 3, (void*)42, "42", - convert("042"), convert("042")); - DoArgumentPrecTest(convert("%.*o"), 1, (void*)42, "42", - convert("52"), convert("52")); - DoArgumentPrecTest(convert("%.*o"), 3, (void*)42, "42", - convert("052"), convert("052")); - DoArgumentPrecTest(convert("%.*u"), 1, (void*)42, "42", - convert("42"), convert("42")); - DoArgumentPrecTest(convert("%.*u"), 3, (void*)42, "42", - convert("042"), convert("042")); - DoArgumentPrecTest(convert("%.*x"), 1, (void*)0x42, "0x42", - convert("42"), convert("42")); - DoArgumentPrecTest(convert("%.*x"), 3, (void*)0x42, "0x42", - convert("042"), convert("042")); - DoArgumentPrecTest(convert("%.*X"), 1, (void*)0x42, "0x42", - convert("42"), convert("42")); - DoArgumentPrecTest(convert("%.*X"), 3, (void*)0x42, "0x42", - convert("042"), convert("042")); - DoArgumentPrecDoubleTest(convert("%.*e"), 1, 2.01, convert("2.0e+000")); - DoArgumentPrecDoubleTest(convert("%.*e"), 3, 2.01, convert("2.010e+000")); - DoArgumentPrecDoubleTest(convert("%.*E"), 1, 2.01, convert("2.0E+000")); - DoArgumentPrecDoubleTest(convert("%.*E"), 3, 2.01, convert("2.010E+000")); - DoArgumentPrecDoubleTest(convert("%.*f"), 1, 2.01, convert("2.0")); - DoArgumentPrecDoubleTest(convert("%.*f"), 3, 2.01, convert("2.010")); - DoArgumentPrecDoubleTest(convert("%.*g"), 1, 256.01, convert("3e+002")); - DoArgumentPrecDoubleTest(convert("%.*g"), 3, 256.01, convert("256")); - DoArgumentPrecDoubleTest(convert("%.*g"), 4, 256.01, convert("256")); - DoArgumentPrecDoubleTest(convert("%.*g"), 6, 256.01, convert("256.01")); - DoArgumentPrecDoubleTest(convert("%.*G"), 1, 256.01, convert("3E+002")); - DoArgumentPrecDoubleTest(convert("%.*G"), 3, 256.01, convert("256")); - DoArgumentPrecDoubleTest(convert("%.*G"), 4, 256.01, convert("256")); - DoArgumentPrecDoubleTest(convert("%.*G"), 6, 256.01, convert("256.01")); - - PAL_Terminate(); - return PASS; - -} diff --git a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test19/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test19/testinfo.dat deleted file mode 100644 index 95269cdd3..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test19/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = swprintf_s -Name = Positive Test for swprintf_s -TYPE = DEFAULT -EXE1 = test19 -Description -= Tests swprintf_s with argument specified precision diff --git a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test2/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test2/CMakeLists.txt deleted file mode 100644 index 4307aa71c..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test2.cpp -) - -add_executable(paltest_snwprintf_test2 - ${SOURCES} -) - -add_dependencies(paltest_snwprintf_test2 coreclrpal) - -target_link_libraries(paltest_snwprintf_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test2/test2.cpp b/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test2/test2.cpp deleted file mode 100644 index 7d8dd65c3..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test2/test2.cpp +++ /dev/null @@ -1,50 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test2.c -** -** Purpose:Tests swprintf_s with strings -** -** -**==========================================================================*/ - - - -#include -#include "../_snwprintf_s.h" - -/* memcmp is used to verify the results, so this test is dependent on it. */ -/* ditto with wcslen */ - - -int __cdecl main(int argc, char *argv[]) -{ - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - DoWStrTest(convert("foo %s"), convert("bar"), convert("foo bar")); - DoStrTest(convert("foo %hs"), "bar", convert("foo bar")); - DoWStrTest(convert("foo %ls"), convert("bar"), convert("foo bar")); - DoWStrTest(convert("foo %ws"), convert("bar"), convert("foo bar")); - DoWStrTest(convert("foo %Ls"), convert("bar"), convert("foo bar")); - DoWStrTest(convert("foo %I64s"), convert("bar"), convert("foo bar")); - DoWStrTest(convert("foo %5s"), convert("bar"), convert("foo bar")); - DoWStrTest(convert("foo %.2s"), convert("bar"), convert("foo ba")); - DoWStrTest(convert("foo %5.2s"), convert("bar"), convert("foo ba")); - DoWStrTest(convert("foo %-5s"), convert("bar"), convert("foo bar ")); - DoWStrTest(convert("foo %05s"), convert("bar"), convert("foo 00bar")); - DoWStrTest(convert("foo %s"), NULL, convert("foo (null)")); - DoStrTest(convert("foo %hs"), NULL, convert("foo (null)")); - DoWStrTest(convert("foo %ls"), NULL, convert("foo (null)")); - DoWStrTest(convert("foo %ws"), NULL, convert("foo (null)")); - DoWStrTest(convert("foo %Ls"), NULL, convert("foo (null)")); - DoWStrTest(convert("foo %I64s"), NULL, convert("foo (null)")); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test2/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test2/testinfo.dat deleted file mode 100644 index 88f198160..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test2/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = swprintf_s -Name = Positive Test for swprintf_s -TYPE = DEFAULT -EXE1 = test2 -Description -= Tests swprintf_s with strings diff --git a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test3/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test3/CMakeLists.txt deleted file mode 100644 index c5278f487..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test3/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test3.cpp -) - -add_executable(paltest_snwprintf_test3 - ${SOURCES} -) - -add_dependencies(paltest_snwprintf_test3 coreclrpal) - -target_link_libraries(paltest_snwprintf_test3 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test3/test3.cpp b/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test3/test3.cpp deleted file mode 100644 index b4a4a32ae..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test3/test3.cpp +++ /dev/null @@ -1,50 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test3.c -** -** Purpose: Tests swprintf_s with wide strings -** -** -**==========================================================================*/ - - - -#include -#include "../_snwprintf_s.h" - -/* memcmp is used to verify the results, so this test is dependent on it. */ -/* ditto with wcslen */ - - -int __cdecl main(int argc, char *argv[]) -{ - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - DoStrTest(convert("foo %S"), "bar", convert("foo bar")); - DoStrTest(convert("foo %hS"), "bar", convert("foo bar")); - DoWStrTest(convert("foo %lS"), convert("bar"), convert("foo bar")); - DoWStrTest(convert("foo %wS"), convert("bar"), convert("foo bar")); - DoStrTest(convert("foo %LS"), "bar", convert("foo bar")); - DoStrTest(convert("foo %I64S"), "bar", convert("foo bar")); - DoStrTest(convert("foo %5S"), "bar", convert("foo bar")); - DoStrTest(convert("foo %.2S"), "bar", convert("foo ba")); - DoStrTest(convert("foo %5.2S"), "bar", convert("foo ba")); - DoStrTest(convert("foo %-5S"), "bar", convert("foo bar ")); - DoStrTest(convert("foo %05S"), "bar", convert("foo 00bar")); - DoStrTest(convert("foo %S"), NULL, convert("foo (null)")); - DoStrTest(convert("foo %hS"), NULL, convert("foo (null)")); - DoWStrTest(convert("foo %lS"), NULL, convert("foo (null)")); - DoWStrTest(convert("foo %wS"), NULL, convert("foo (null)")); - DoStrTest(convert("foo %LS"), NULL, convert("foo (null)")); - DoStrTest(convert("foo %I64S"), NULL, convert("foo (null)")); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test3/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test3/testinfo.dat deleted file mode 100644 index 5ed59e61a..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test3/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = swprintf_s -Name = Positive Test for swprintf_s -TYPE = DEFAULT -EXE1 = test3 -Description -= Tests swprintf_s with wide strings diff --git a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test4/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test4/CMakeLists.txt deleted file mode 100644 index 26229d719..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test4/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test4.cpp -) - -add_executable(paltest_snwprintf_test4 - ${SOURCES} -) - -add_dependencies(paltest_snwprintf_test4 coreclrpal) - -target_link_libraries(paltest_snwprintf_test4 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test4/test4.cpp b/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test4/test4.cpp deleted file mode 100644 index 0819a7e65..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test4/test4.cpp +++ /dev/null @@ -1,71 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test4.c -** -** Purpose: Tests swprintf_s with pointers -** -** -**==========================================================================*/ - - - -#include -#include "../_snwprintf_s.h" - -/* memcmp is used to verify the results, so this test is dependent on it. */ -/* ditto with wcslen */ - - -int __cdecl main(int argc, char *argv[]) -{ - void *ptr = (void*) 0x123456; - INT64 lptr = I64(0x1234567887654321); - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - -/* -** Run only on 64 bit platforms -*/ -#if defined(BIT64) - Trace("Testing for 64 Bit Platforms \n"); - DoPointerTest(convert("%p"), NULL, convert("0000000000000000")); - DoPointerTest(convert("%p"), ptr, convert("0000000000123456")); - DoPointerTest(convert("%17p"), ptr, convert(" 0000000000123456")); - DoPointerTest(convert("%17p"), ptr, convert(" 0000000000123456")); - DoPointerTest(convert("%-17p"), ptr, convert("0000000000123456 ")); - DoPointerTest(convert("%+p"), ptr, convert("0000000000123456")); - DoPointerTest(convert("% p"), ptr, convert("0000000000123456")); - DoPointerTest(convert("%#p"), ptr, convert("0X0000000000123456")); - DoPointerTest(convert("%lp"), ptr, convert("00123456")); - DoPointerTest(convert("%hp"), ptr, convert("00003456")); - DoPointerTest(convert("%Lp"), ptr, convert("00123456")); - DoI64Test(convert("%I64p"), lptr, "1234567887654321", - convert("1234567887654321")); -#else - Trace("Testing for Non 64 Bit Platforms \n"); - DoPointerTest(convert("%p"), NULL, convert("00000000")); - DoPointerTest(convert("%p"), ptr, convert("00123456")); - DoPointerTest(convert("%9p"), ptr, convert(" 00123456")); - DoPointerTest(convert("%09p"), ptr, convert(" 00123456")); - DoPointerTest(convert("%-9p"), ptr, convert("00123456 ")); - DoPointerTest(convert("%+p"), ptr, convert("00123456")); - DoPointerTest(convert("% p"), ptr, convert("00123456")); - DoPointerTest(convert("%#p"), ptr, convert("0X00123456")); - DoPointerTest(convert("%lp"), ptr, convert("00123456")); - DoPointerTest(convert("%hp"), ptr, convert("00003456")); - DoPointerTest(convert("%Lp"), ptr, convert("00123456")); - DoI64Test(convert("%I64p"), lptr, "1234567887654321", - convert("1234567887654321")); -#endif - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test4/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test4/testinfo.dat deleted file mode 100644 index 2b35f2d0d..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test4/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = swprintf_s -Name = Positive Test for swprintf_s -TYPE = DEFAULT -EXE1 = test4 -Description -= Tests swprintf_s with pointers diff --git a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test6/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test6/CMakeLists.txt deleted file mode 100644 index 542e943f8..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test6/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test6.cpp -) - -add_executable(paltest_snwprintf_test6 - ${SOURCES} -) - -add_dependencies(paltest_snwprintf_test6 coreclrpal) - -target_link_libraries(paltest_snwprintf_test6 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test6/test6.cpp b/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test6/test6.cpp deleted file mode 100644 index 576e061ac..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test6/test6.cpp +++ /dev/null @@ -1,46 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test6.c -** -** Purpose: Tests swprintf_s with characters -** -** -**==========================================================================*/ - - - -#include -#include "../_snwprintf_s.h" - -/* memcmp is used to verify the results, so this test is dependent on it. */ -/* ditto with wcslen */ - -int __cdecl main(int argc, char *argv[]) -{ - WCHAR wc = (WCHAR) 'c'; - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - - DoWCharTest(convert("foo %c"), wc, convert("foo c")); - DoCharTest(convert("foo %hc"), 'b', convert("foo b")); - DoWCharTest(convert("foo %lc"), wc, convert("foo c")); - DoWCharTest(convert("foo %Lc"), wc, convert("foo c")); - DoWCharTest(convert("foo %I64c"), wc, convert("foo c")); - DoWCharTest(convert("foo %5c"), wc, convert("foo c")); - DoWCharTest(convert("foo %.0c"), wc, convert("foo c")); - DoWCharTest(convert("foo %-5c"), wc, convert("foo c ")); - DoWCharTest(convert("foo %05c"), wc, convert("foo 0000c")); - DoWCharTest(convert("foo % c"), wc, convert("foo c")); - DoWCharTest(convert("foo %#c"), wc, convert("foo c")); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test6/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test6/testinfo.dat deleted file mode 100644 index d8db7f833..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test6/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = swprintf_s -Name = Positive Test for swprintf_s -TYPE = DEFAULT -EXE1 = test6 -Description -= Tests swprintf_s with characters diff --git a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test7/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test7/CMakeLists.txt deleted file mode 100644 index 0905c5d08..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test7/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test7.cpp -) - -add_executable(paltest_snwprintf_test7 - ${SOURCES} -) - -add_dependencies(paltest_snwprintf_test7 coreclrpal) - -target_link_libraries(paltest_snwprintf_test7 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test7/test7.cpp b/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test7/test7.cpp deleted file mode 100644 index 54dd32b43..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test7/test7.cpp +++ /dev/null @@ -1,46 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test7.c -** -** Purpose: Tests swprintf_s with wide characters -** -** -**==========================================================================*/ - - - -#include -#include "../_snwprintf_s.h" - -/* memcmp is used to verify the results, so this test is dependent on it. */ -/* ditto with wcslen */ - -int __cdecl main(int argc, char *argv[]) -{ - WCHAR wc = (WCHAR) 'c'; - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - - DoCharTest(convert("foo %C"), 'b', convert("foo b")); - DoWCharTest(convert("foo %hC"), wc, convert("foo c")); - DoCharTest(convert("foo %lC"), 'b', convert("foo b")); - DoCharTest(convert("foo %LC"), 'b', convert("foo b")); - DoCharTest(convert("foo %I64C"), 'b', convert("foo b")); - DoCharTest(convert("foo %5C"), 'b', convert("foo b")); - DoCharTest(convert("foo %.0C"), 'b', convert("foo b")); - DoCharTest(convert("foo %-5C"), 'b', convert("foo b ")); - DoCharTest(convert("foo %05C"), 'b', convert("foo 0000b")); - DoCharTest(convert("foo % C"), 'b', convert("foo b")); - DoCharTest(convert("foo %#C"), 'b', convert("foo b")); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test7/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test7/testinfo.dat deleted file mode 100644 index fa5bd3000..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test7/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = swprintf_s -Name = Positive Test for swprintf_s -TYPE = DEFAULT -EXE1 = test7 -Description -= Tests swprintf_s with wide characters diff --git a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test8/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test8/CMakeLists.txt deleted file mode 100644 index a31a7f9f8..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test8/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test8.cpp -) - -add_executable(paltest_snwprintf_test8 - ${SOURCES} -) - -add_dependencies(paltest_snwprintf_test8 coreclrpal) - -target_link_libraries(paltest_snwprintf_test8 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test8/test8.cpp b/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test8/test8.cpp deleted file mode 100644 index 9f1b555e3..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test8/test8.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test8.c -** -** Purpose: Tests swprintf_s with decimal numbers -** -** -**==========================================================================*/ - - - -#include -#include "../_snwprintf_s.h" - -/* memcmp is used to verify the results, so this test is dependent on it. */ -/* ditto with wcslen */ - -int __cdecl main(int argc, char *argv[]) -{ - int neg = -42; - int pos = 42; - INT64 l = 42; - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - - DoNumTest(convert("foo %d"), pos, convert("foo 42")); - DoNumTest(convert("foo %ld"), 0xFFFF, convert("foo 65535")); - DoNumTest(convert("foo %hd"), 0xFFFF, convert("foo -1")); - DoNumTest(convert("foo %Ld"), pos, convert("foo 42")); - DoI64Test(convert("foo %I64d"), l, "42", convert("foo 42")); - DoNumTest(convert("foo %3d"), pos, convert("foo 42")); - DoNumTest(convert("foo %-3d"), pos, convert("foo 42 ")); - DoNumTest(convert("foo %.1d"), pos, convert("foo 42")); - DoNumTest(convert("foo %.3d"), pos, convert("foo 042")); - DoNumTest(convert("foo %03d"), pos, convert("foo 042")); - DoNumTest(convert("foo %#d"), pos, convert("foo 42")); - DoNumTest(convert("foo %+d"), pos, convert("foo +42")); - DoNumTest(convert("foo % d"), pos, convert("foo 42")); - DoNumTest(convert("foo %+d"), neg, convert("foo -42")); - DoNumTest(convert("foo % d"), neg, convert("foo -42")); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test8/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test8/testinfo.dat deleted file mode 100644 index d76a421ea..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test8/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = swprintf_s -Name = Positive Test for swprintf_s -TYPE = DEFAULT -EXE1 = test8 -Description -= Tests swprintf_s with decimal numbers diff --git a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test9/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test9/CMakeLists.txt deleted file mode 100644 index 90157fdd0..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test9/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test9.cpp -) - -add_executable(paltest_snwprintf_test9 - ${SOURCES} -) - -add_dependencies(paltest_snwprintf_test9 coreclrpal) - -target_link_libraries(paltest_snwprintf_test9 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test9/test9.cpp b/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test9/test9.cpp deleted file mode 100644 index 76d60631a..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test9/test9.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test9.c -** -** Purpose: Tests swprintf_s with integer numbers -** -** -**==========================================================================*/ - - - -#include -#include "../_snwprintf_s.h" - -/* memcmp is used to verify the results, so this test is dependent on it. */ -/* ditto with wcslen */ - -int __cdecl main(int argc, char *argv[]) -{ - int neg = -42; - int pos = 42; - INT64 l = 42; - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - - DoNumTest(convert("foo %i"), pos, convert("foo 42")); - DoNumTest(convert("foo %li"), 0xFFFF, convert("foo 65535")); - DoNumTest(convert("foo %hi"), 0xFFFF, convert("foo -1")); - DoNumTest(convert("foo %Li"), pos, convert("foo 42")); - DoI64Test(convert("foo %I64i"), l, "42", convert("foo 42")); - DoNumTest(convert("foo %3i"), pos, convert("foo 42")); - DoNumTest(convert("foo %-3i"), pos, convert("foo 42 ")); - DoNumTest(convert("foo %.1i"), pos, convert("foo 42")); - DoNumTest(convert("foo %.3i"), pos, convert("foo 042")); - DoNumTest(convert("foo %03i"), pos, convert("foo 042")); - DoNumTest(convert("foo %#i"), pos, convert("foo 42")); - DoNumTest(convert("foo %+i"), pos, convert("foo +42")); - DoNumTest(convert("foo % i"), pos, convert("foo 42")); - DoNumTest(convert("foo %+i"), neg, convert("foo -42")); - DoNumTest(convert("foo % i"), neg, convert("foo -42")); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test9/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test9/testinfo.dat deleted file mode 100644 index b2a038df6..000000000 --- a/src/pal/tests/palsuite/c_runtime/_snwprintf_s/test9/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = swprintf_s -Name = Positive Test for swprintf_s -TYPE = DEFAULT -EXE1 = test9 -Description -= Tests swprintf_s with integer numbers diff --git a/src/pal/tests/palsuite/c_runtime/_stricmp/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_stricmp/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/c_runtime/_stricmp/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/c_runtime/_stricmp/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_stricmp/test1/CMakeLists.txt deleted file mode 100644 index a0380a440..000000000 --- a/src/pal/tests/palsuite/c_runtime/_stricmp/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_stricmp_test1 - ${SOURCES} -) - -add_dependencies(paltest_stricmp_test1 coreclrpal) - -target_link_libraries(paltest_stricmp_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_stricmp/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/_stricmp/test1/test1.cpp deleted file mode 100644 index 60e2f9eb8..000000000 --- a/src/pal/tests/palsuite/c_runtime/_stricmp/test1/test1.cpp +++ /dev/null @@ -1,70 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: Do a lower case compare. Check two strings, only different -** because they have different capitalization, and they should return 0. Try -** two strings which will return less than 0 (one is smaller than the other). -** Also try the opposite, to get a return value greater than 0. -** -** -**==========================================================================*/ - -#include - -/* - * Note: The _stricmp is dependent on the LC_CTYPE category of the locale, - * and this is ignored by these tests. - */ -int __cdecl main(int argc, char *argv[]) -{ - char *str1 = "foo"; - char *str2 = "fOo"; - char *str3 = "foo_bar"; - char *str4 = "foobar"; - - /* - * Initialize the PAL and return FAIL if this fails - */ - if (0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - if (_stricmp(str1, str2) != 0) - { - Fail ("ERROR: _stricmp returning incorrect value:\n" - "_stricmp(\"%s\", \"%s\") != 0\n", str1, str2); - } - - if (_stricmp(str2, str3) >= 0) - { - Fail ("ERROR: _stricmp returning incorrect value:\n" - "_stricmp(\"%s\", \"%s\") >= 0\n", str2, str3); - } - - if (_stricmp(str3, str4) >= 0) - { - Fail ("ERROR: _stricmp returning incorrect value:\n" - "_stricmp(\"%s\", \"%s\") >= 0\n", str3, str4); - } - - if (_stricmp(str4, str1) <= 0) - { - Fail ("ERROR: _stricmp returning incorrect value:\n" - "_stricmp(\"%s\", \"%s\") <= 0\n", str4, str1); - } - - if (_stricmp(str3, str2) <= 0) - { - Fail ("ERROR: _stricmp returning incorrect value:\n" - "_stricmp(\"%s\", \"%s\") <= 0\n", str2, str3); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/_stricmp/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_stricmp/test1/testinfo.dat deleted file mode 100644 index 89d4e0f57..000000000 --- a/src/pal/tests/palsuite/c_runtime/_stricmp/test1/testinfo.dat +++ /dev/null @@ -1,15 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = _stricmp -Name = Positive Test for _stricmp -TYPE = DEFAULT -EXE1 = test1 -Description -= Do a lower case compare. Check two strings, only different because they -= have different capitalization, and they should return 0. Try two strings -= which will return less than 0 (one is smaller than the other). Also try -= the opposite, to get a return value greater than 0. diff --git a/src/pal/tests/palsuite/c_runtime/_strlwr/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_strlwr/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/c_runtime/_strlwr/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/c_runtime/_strlwr/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_strlwr/test1/CMakeLists.txt deleted file mode 100644 index bef0a7ed6..000000000 --- a/src/pal/tests/palsuite/c_runtime/_strlwr/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_strlwr_test1 - ${SOURCES} -) - -add_dependencies(paltest_strlwr_test1 coreclrpal) - -target_link_libraries(paltest_strlwr_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_strlwr/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/_strlwr/test1/test1.cpp deleted file mode 100644 index 1c4015e3e..000000000 --- a/src/pal/tests/palsuite/c_runtime/_strlwr/test1/test1.cpp +++ /dev/null @@ -1,42 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: -** Using memcmp, check to see that after changing a string into all lowercase -** that it is the lowercase string that was expected. -** -** -**==========================================================================*/ - -#include - -int __cdecl main(int argc, char *argv[]) -{ - char string[] = "aASdff"; - char checkstr[] = "aasdff"; - char *ret=NULL; - - /* - * Initialize the PAL and return FAIL if this fails - */ - if (0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - ret = _strlwr(string); - - if (memcmp(ret, checkstr, sizeof(checkstr)) != 0) - { - Fail ("ERROR: _strlwr returning incorrect value\n" - "Expected %s, got %s\n", checkstr, ret); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/_strlwr/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_strlwr/test1/testinfo.dat deleted file mode 100644 index 4c2a1ad55..000000000 --- a/src/pal/tests/palsuite/c_runtime/_strlwr/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = _strlwr -Name = Positive Test for _strlwr -TYPE = DEFAULT -EXE1 = test1 -Description -= Using memcmp, check to see that after changing a string into all lowercase -= that it is the lowercase string that was expected. diff --git a/src/pal/tests/palsuite/c_runtime/_strnicmp/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_strnicmp/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/c_runtime/_strnicmp/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/c_runtime/_strnicmp/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_strnicmp/test1/CMakeLists.txt deleted file mode 100644 index 2429339a6..000000000 --- a/src/pal/tests/palsuite/c_runtime/_strnicmp/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_strnicmp_test1 - ${SOURCES} -) - -add_dependencies(paltest_strnicmp_test1 coreclrpal) - -target_link_libraries(paltest_strnicmp_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_strnicmp/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/_strnicmp/test1/test1.cpp deleted file mode 100644 index 3c915dc62..000000000 --- a/src/pal/tests/palsuite/c_runtime/_strnicmp/test1/test1.cpp +++ /dev/null @@ -1,85 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: Test #1 for the _strnicmp function -** -** -**==========================================================================*/ - -#include - - -int __cdecl main(int argc, char *argv[]) -{ - char str1[] = "foo"; - char str2[] = "foox"; - char str3[] = "fOo"; - char str4[] = "ABCDE"; - char str5[] = "ABCD["; - char str6[] = "abcde"; - char str7[] = "abcd^"; - - /* - * Initialize the PAL and return FAIL if this fails - */ - if (0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - if (_strnicmp(str1, str2, strlen(str2)) >= 0) - { - Fail ("ERROR: _strnicmp(\"%s\", \"%s\", %d) returned >= 0\n", - str1, str2, strlen(str2)); - } - - if (_strnicmp(str2, str1, strlen(str2)) <= 0) - { - Fail ("ERROR: _strnicmp(\"%s\", \"%s\", %d) returned <= 0\n", - str2, str1, strlen(str2)); - } - - if (_strnicmp(str1, str2, strlen(str1)) != 0) - { - Fail ("ERROR: _strnicmp(\"%s\", \"%s\", %d) returned != 0\n", - str1, str2, strlen(str1)); - } - - if (_strnicmp(str1, str3, strlen(str1)) != 0) - { - Fail ("ERROR: _strnicmp(\"%s\", \"%s\", %d) returned != 0\n", - str1, str3, strlen(str3)); - } - - if (_strnicmp(str3, str1, strlen(str1)) != 0) - { - Fail ("ERROR: _strnicmp(\"%s\", \"%s\", %d) returned != 0\n", - str3, str1, strlen(str1)); - } - - /* new testing */ - - /* str4 should be greater than str5 */ - if (_strnicmp(str4, str5, strlen(str4)) <= 0) - { - Fail ("ERROR: _strnicmp(\"%s\", \"%s\", %d) returned >= 0\n", - str4, str5, strlen(str4)); - } - - /* str6 should be greater than str7 */ - if (_strnicmp(str6, str7, strlen(str6)) <= 0) - { - Fail ("ERROR: _strnicmp(\"%s\", \"%s\", %d) returned <= 0\n", - str6, str7, strlen(str6)); - } - - - PAL_Terminate(); - - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/_strnicmp/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_strnicmp/test1/testinfo.dat deleted file mode 100644 index 86744c04d..000000000 --- a/src/pal/tests/palsuite/c_runtime/_strnicmp/test1/testinfo.dat +++ /dev/null @@ -1,18 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = _strnicmp -Name = Test #1 for _strnicmp -TYPE = DEFAULT -EXE1 = test1 -Description -= Take two strings and compare them, giving different lengths. -= Comparing str1 and str2 with str2 length, should return <0 -= Comparing str2 and str1 with str2 length, should return >0 -= Comparing str1 and str2 with str1 lenght, should return 0 -= Bring in str3, which has a capital, but this function is doing a lower -= case compare. Just ensure that two strings which differ only by capitals -= return 0. diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/CMakeLists.txt deleted file mode 100644 index 8fe1cb60a..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/CMakeLists.txt +++ /dev/null @@ -1,21 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test10) -add_subdirectory(test11) -add_subdirectory(test12) -add_subdirectory(test13) -add_subdirectory(test14) -add_subdirectory(test15) -add_subdirectory(test16) -add_subdirectory(test17) -add_subdirectory(test18) -add_subdirectory(test19) -add_subdirectory(test2) -add_subdirectory(test3) -add_subdirectory(test4) -add_subdirectory(test6) -add_subdirectory(test7) -add_subdirectory(test8) -add_subdirectory(test9) - diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/_vsnprintf_s.h b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/_vsnprintf_s.h deleted file mode 100644 index 7c81136f7..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/_vsnprintf_s.h +++ /dev/null @@ -1,124 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: _vsnprintf_s.h -** -** Purpose: Contains common testing functions for _vsnprintf -** -** -**==========================================================================*/ - -#ifndef __STRINGTEST_H__ -#define __STRINGTEST_H__ - -/* These functions leaks memory like crazy. C'est la vie. */ -int Testvsnprintf(char* buf, size_t count, const char* format, ...) -{ - int retVal; - va_list arglist; - - va_start(arglist, format); - retVal = _vsnprintf_s(buf, count, _TRUNCATE, format, arglist); - va_end(arglist); - - return (retVal); -} - - -void DoStrTest(const char *formatstr, char* param, const char *checkstr) -{ - char buf[256] = { 0 }; - - Testvsnprintf(buf, 256, formatstr, param); - if (memcmp(buf, checkstr, strlen(buf) + 1) != 0) - { - Fail("ERROR: failed to insert string \"%s\" into \"%s\"\n" - "Expected \"%s\" got \"%s\".\n", - param, formatstr, checkstr, buf); - } -} - -void DoWStrTest(const char *formatstr, WCHAR* param, const char *checkstr) -{ - char buf[256] = { 0 }; - - Testvsnprintf(buf, 256, formatstr, param); - if (memcmp(buf, checkstr, strlen(buf) + 1) != 0) - { - Fail("ERROR: failed to insert wide string \"%s\" into \"%s\"\n" - "Expected \"%s\" got \"%s\".\n", - convertC(param), formatstr, checkstr, buf); - } -} - - -void DoCharTest(const char *formatstr, char param, const char *checkstr) -{ - char buf[256] = { 0 }; - - Testvsnprintf(buf, 256, formatstr, param); - if (memcmp(buf, checkstr, strlen(buf) + 1) != 0) - { - Fail("ERROR: failed to insert char \'%c\' (%d) into \"%s\"\n" - "Expected \"%s\" got \"%s\".\n", - param, param, formatstr, checkstr, buf); - } -} - -void DoWCharTest(const char *formatstr, WCHAR param, const char *checkstr) -{ - char buf[256] = { 0 }; - - Testvsnprintf(buf, 256, formatstr, param); - if (memcmp(buf, checkstr, strlen(buf) + 1) != 0) - { - Fail("ERROR: failed to insert wide char \'%c\' (%d) into \"%s\"\n" - "Expected \"%s\" got \"%s\".\n", - (char)param, param, formatstr, checkstr, buf); - } -} - -void DoNumTest(const char *formatstr, int value, const char *checkstr) -{ - char buf[256] = { 0 }; - - Testvsnprintf(buf, 256, formatstr, value); - if (memcmp(buf, checkstr, strlen(buf) + 1) != 0) - { - Fail("ERROR: failed to insert %#x into \"%s\"\n" - "Expected \"%s\" got \"%s\".\n", - value, formatstr, checkstr, buf); - } -} - -void DoI64Test(const char *formatstr, INT64 value, char *valuestr, const char *checkstr) -{ - char buf[256] = { 0 }; - - Testvsnprintf(buf, 256, formatstr, value); - if (memcmp(buf, checkstr, strlen(buf) + 1) != 0) - { - Fail("ERROR: failed to insert %s into \"%s\"\n" - "Expected \"%s\" got \"%s\".\n", - valuestr, formatstr, checkstr, buf); - } -} -void DoDoubleTest(const char *formatstr, double value, const char *checkstr1, char - *checkstr2) -{ - char buf[256] = { 0 }; - - Testvsnprintf(buf,256, formatstr, value); - if (memcmp(buf, checkstr1, strlen(checkstr1) + 1) != 0 && - memcmp(buf, checkstr2, strlen(checkstr2) + 1) != 0) - { - Fail("ERROR: failed to insert %f into \"%s\"\n" - "Expected \"%s\" or \"%s\", got \"%s\".\n", - value, formatstr, checkstr1, checkstr2, buf); - } -} - -#endif diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test1/CMakeLists.txt deleted file mode 100644 index ee97f2bf1..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_vsnprintf_test1 - ${SOURCES} -) - -add_dependencies(paltest_vsnprintf_test1 coreclrpal) - -target_link_libraries(paltest_vsnprintf_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test1/test1.cpp deleted file mode 100644 index db70f5612..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test1/test1.cpp +++ /dev/null @@ -1,55 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test1.c -** -** Purpose: Test #1 for the _vsnprintf function. -** -** -**===================================================================*/ - -#include -#include "../_vsnprintf_s.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - -int __cdecl main(int argc, char *argv[]) -{ - char checkstr[] = "hello world"; - char buf[256] = { 0 }; - int ret; - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - Testvsnprintf(buf, 256, "hello world"); - - if (memcmp(checkstr, buf, strlen(checkstr)+1) != 0) - { - Fail("ERROR: expected \"%s\" (up to %d chars), got \"%s\"\n", - checkstr, 256, buf); - } - - Testvsnprintf(buf, 256, "xxxxxxxxxxxxxxxxx"); - - ret = Testvsnprintf(buf, 8, "hello world"); - - if (ret >= 0) - { - Fail("ERROR: expected negative return value, got %d", ret); - } - if (memcmp(checkstr, buf, 7) != 0 || buf[7] != 0) - { - Fail("ERROR: expected %s (up to %d chars), got %s\n", checkstr, 8, buf); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test1/testinfo.dat deleted file mode 100644 index f96bf084f..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = _vsnprintf -Name = Positive Test for _vsnprintf -TYPE = DEFAULT -EXE1 = test1 -Description -= Tests the PAL implementation of the _vsnprintf function. -= This test is modeled after sprintf_s. diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test10/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test10/CMakeLists.txt deleted file mode 100644 index ad067ccd7..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test10/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test10.cpp -) - -add_executable(paltest_vsnprintf_test10 - ${SOURCES} -) - -add_dependencies(paltest_vsnprintf_test10 coreclrpal) - -target_link_libraries(paltest_vsnprintf_test10 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test10/test10.cpp b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test10/test10.cpp deleted file mode 100644 index 707a91c04..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test10/test10.cpp +++ /dev/null @@ -1,50 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test10.c -** -** Purpose: Test #10 for the _vsnprintf function. -** -** -**===================================================================*/ - -#include -#include "../_vsnprintf_s.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - -int __cdecl main(int argc, char *argv[]) -{ - int neg = -42; - int pos = 42; - INT64 l = 42; - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoNumTest("foo %o", pos, "foo 52"); - DoNumTest("foo %lo", 0xFFFF, "foo 177777"); - DoNumTest("foo %ho", 0xFFFF, "foo 177777"); - DoNumTest("foo %Lo", pos, "foo 52"); - DoI64Test("foo %I64o", l, "42", "foo 52"); - DoNumTest("foo %3o", pos, "foo 52"); - DoNumTest("foo %-3o", pos, "foo 52 "); - DoNumTest("foo %.1o", pos, "foo 52"); - DoNumTest("foo %.3o", pos, "foo 052"); - DoNumTest("foo %03o", pos, "foo 052"); - DoNumTest("foo %#o", pos, "foo 052"); - DoNumTest("foo %+o", pos, "foo 52"); - DoNumTest("foo % o", pos, "foo 52"); - DoNumTest("foo %+o", neg, "foo 37777777726"); - DoNumTest("foo % o", neg, "foo 37777777726"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test10/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test10/testinfo.dat deleted file mode 100644 index a3d8eca54..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test10/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = _vsnprintf -Name = Positive Test for _vsnprintf -TYPE = DEFAULT -EXE1 = test10 -Description -= Tests the PAL implementation of the _vsnprintf function. -= Tests _vsnprintf with octal numbers. -= This test is modeled after sprintf_s. diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test11/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test11/CMakeLists.txt deleted file mode 100644 index 9fb2b903d..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test11/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test11.cpp -) - -add_executable(paltest_vsnprintf_test11 - ${SOURCES} -) - -add_dependencies(paltest_vsnprintf_test11 coreclrpal) - -target_link_libraries(paltest_vsnprintf_test11 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test11/test11.cpp b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test11/test11.cpp deleted file mode 100644 index 4c710e56b..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test11/test11.cpp +++ /dev/null @@ -1,50 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test11.c -** -** Purpose: Test #11 for the _vsnprintf function. -** -** -**===================================================================*/ - -#include -#include "../_vsnprintf_s.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - -int __cdecl main(int argc, char *argv[]) -{ - int neg = -42; - int pos = 42; - INT64 l = 42; - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoNumTest("foo %u", pos, "foo 42"); - DoNumTest("foo %lu", 0xFFFF, "foo 65535"); - DoNumTest("foo %hu", 0xFFFF, "foo 65535"); - DoNumTest("foo %Lu", pos, "foo 42"); - DoI64Test("foo %I64u", l, "42", "foo 42"); - DoNumTest("foo %3u", pos, "foo 42"); - DoNumTest("foo %-3u", pos, "foo 42 "); - DoNumTest("foo %.1u", pos, "foo 42"); - DoNumTest("foo %.3u", pos, "foo 042"); - DoNumTest("foo %03u", pos, "foo 042"); - DoNumTest("foo %#u", pos, "foo 42"); - DoNumTest("foo %+u", pos, "foo 42"); - DoNumTest("foo % u", pos, "foo 42"); - DoNumTest("foo %+u", neg, "foo 4294967254"); - DoNumTest("foo % u", neg, "foo 4294967254"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test11/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test11/testinfo.dat deleted file mode 100644 index 17e9f0494..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test11/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = _vsnprintf -Name = Positive Test for _vsnprintf -TYPE = DEFAULT -EXE1 = test11 -Description -= Tests the PAL implementation of the _vsnprintf function. -= Tests _vsnprintf with unsigned numbers. -= This test is modeled after sprintf_s. diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test12/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test12/CMakeLists.txt deleted file mode 100644 index f78711cfd..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test12/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test12.cpp -) - -add_executable(paltest_vsnprintf_test12 - ${SOURCES} -) - -add_dependencies(paltest_vsnprintf_test12 coreclrpal) - -target_link_libraries(paltest_vsnprintf_test12 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test12/test12.cpp b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test12/test12.cpp deleted file mode 100644 index 528e6582a..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test12/test12.cpp +++ /dev/null @@ -1,52 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test12.c -** -** Purpose: Test #12 for the _vsnprintf function. -** -** -**===================================================================*/ - -#include -#include "../_vsnprintf_s.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - - -int __cdecl main(int argc, char *argv[]) -{ - int neg = -42; - int pos = 0x1234ab; - INT64 l = I64(0x1234567887654321); - - if (PAL_Initialize(argc, argv) != 0) - { - return (FAIL); - } - - DoNumTest("foo %x", pos, "foo 1234ab"); - DoNumTest("foo %lx", pos, "foo 1234ab"); - DoNumTest("foo %hx", pos, "foo 34ab"); - DoNumTest("foo %Lx", pos, "foo 1234ab"); - DoI64Test("foo %I64x", l, "0x1234567887654321", - "foo 1234567887654321"); - DoNumTest("foo %7x", pos, "foo 1234ab"); - DoNumTest("foo %-7x", pos, "foo 1234ab "); - DoNumTest("foo %.1x", pos, "foo 1234ab"); - DoNumTest("foo %.7x", pos, "foo 01234ab"); - DoNumTest("foo %07x", pos, "foo 01234ab"); - DoNumTest("foo %#x", pos, "foo 0x1234ab"); - DoNumTest("foo %+x", pos, "foo 1234ab"); - DoNumTest("foo % x", pos, "foo 1234ab"); - DoNumTest("foo %+x", neg, "foo ffffffd6"); - DoNumTest("foo % x", neg, "foo ffffffd6"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test12/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test12/testinfo.dat deleted file mode 100644 index 82f58e437..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test12/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = _vsnprintf -Name = Positive Test for _vsnprintf -TYPE = DEFAULT -EXE1 = test12 -Description -= Tests the PAL implementation of the _vsnprintf function. -= Tests _vsnprintf with hex numbers (lowercase). -= This test is modeled after sprintf_s. diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test13/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test13/CMakeLists.txt deleted file mode 100644 index b37300c6d..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test13/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test13.cpp -) - -add_executable(paltest_vsnprintf_test13 - ${SOURCES} -) - -add_dependencies(paltest_vsnprintf_test13 coreclrpal) - -target_link_libraries(paltest_vsnprintf_test13 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test13/test13.cpp b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test13/test13.cpp deleted file mode 100644 index 645a11868..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test13/test13.cpp +++ /dev/null @@ -1,52 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test13.c -** -** Purpose: Test #13 for the _vsnprintf function. -** -** -**===================================================================*/ - -#include -#include "../_vsnprintf_s.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - - -int __cdecl main(int argc, char *argv[]) -{ - int neg = -42; - int pos = 0x1234AB; - INT64 l = I64(0x1234567887654321); - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoNumTest("foo %X", pos, "foo 1234AB"); - DoNumTest("foo %lX", pos, "foo 1234AB"); - DoNumTest("foo %hX", pos, "foo 34AB"); - DoNumTest("foo %LX", pos, "foo 1234AB"); - DoI64Test("foo %I64X", l, "0x1234567887654321", - "foo 1234567887654321"); - DoNumTest("foo %7X", pos, "foo 1234AB"); - DoNumTest("foo %-7X", pos, "foo 1234AB "); - DoNumTest("foo %.1X", pos, "foo 1234AB"); - DoNumTest("foo %.7X", pos, "foo 01234AB"); - DoNumTest("foo %07X", pos, "foo 01234AB"); - DoNumTest("foo %#X", pos, "foo 0X1234AB"); - DoNumTest("foo %+X", pos, "foo 1234AB"); - DoNumTest("foo % X", pos, "foo 1234AB"); - DoNumTest("foo %+X", neg, "foo FFFFFFD6"); - DoNumTest("foo % X", neg, "foo FFFFFFD6"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test13/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test13/testinfo.dat deleted file mode 100644 index d308edf87..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test13/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = _vsnprintf -Name = Positive Test for _vsnprintf -TYPE = DEFAULT -EXE1 = test13 -Description -= Tests the PAL implementation of the _vsnprintf function. -= Tests _vsnprintf with hex numbers (uppercase). -= This test is modeled after sprintf_s. diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test14/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test14/CMakeLists.txt deleted file mode 100644 index 97098d48c..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test14/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test14.cpp -) - -add_executable(paltest_vsnprintf_test14 - ${SOURCES} -) - -add_dependencies(paltest_vsnprintf_test14 coreclrpal) - -target_link_libraries(paltest_vsnprintf_test14 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test14/test14.cpp b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test14/test14.cpp deleted file mode 100644 index 05965f0ed..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test14/test14.cpp +++ /dev/null @@ -1,50 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test14.c -** -** Purpose: Test #14 for the _vsnprintf function. -** -** -**===================================================================*/ - -#include -#include "../_vsnprintf_s.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - - -int __cdecl main(int argc, char *argv[]) -{ - double val = 256.0; - double neg = -256.0; - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoDoubleTest("foo %e", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %le", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %he", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %Le", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %I64e", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %14e", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %-14e", val, "foo 2.560000e+002 ", "foo 2.560000e+02 "); - DoDoubleTest("foo %.1e", val, "foo 2.6e+002", "foo 2.6e+02"); - DoDoubleTest("foo %.8e", val, "foo 2.56000000e+002", "foo 2.56000000e+02"); - DoDoubleTest("foo %014e", val, "foo 02.560000e+002", "foo 002.560000e+02"); - DoDoubleTest("foo %#e", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %+e", val, "foo +2.560000e+002", "foo +2.560000e+02"); - DoDoubleTest("foo % e", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %+e", neg, "foo -2.560000e+002", "foo -2.560000e+02"); - DoDoubleTest("foo % e", neg, "foo -2.560000e+002", "foo -2.560000e+02"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test14/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test14/testinfo.dat deleted file mode 100644 index 8d11b1d6f..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test14/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = _vsnprintf -Name = Positive Test for _vsnprintf -TYPE = DEFAULT -EXE1 = test14 -Description -= Tests the PAL implementation of the _vsnprintf function. -= Tests _vsnprintf with exponential format doubles (lowercase). -= This test is modeled after sprintf_s. diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test15/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test15/CMakeLists.txt deleted file mode 100644 index 95e5a475f..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test15/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test15.cpp -) - -add_executable(paltest_vsnprintf_test15 - ${SOURCES} -) - -add_dependencies(paltest_vsnprintf_test15 coreclrpal) - -target_link_libraries(paltest_vsnprintf_test15 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test15/test15.cpp b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test15/test15.cpp deleted file mode 100644 index cd34f74e6..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test15/test15.cpp +++ /dev/null @@ -1,49 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test15.c -** -** Purpose: Test #15 for the _vsnprintf function. -** -** -**===================================================================*/ - -#include -#include "../_vsnprintf_s.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - -int __cdecl main(int argc, char *argv[]) -{ - double val = 256.0; - double neg = -256.0; - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoDoubleTest("foo %E", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %lE", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %hE", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %LE", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %I64E", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %14E", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %-14E", val, "foo 2.560000E+002 ", "foo 2.560000E+02 "); - DoDoubleTest("foo %.1E", val, "foo 2.6E+002", "foo 2.6E+02"); - DoDoubleTest("foo %.8E", val, "foo 2.56000000E+002", "foo 2.56000000E+02"); - DoDoubleTest("foo %014E", val, "foo 02.560000E+002", "foo 002.560000E+02"); - DoDoubleTest("foo %#E", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %+E", val, "foo +2.560000E+002", "foo +2.560000E+02"); - DoDoubleTest("foo % E", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %+E", neg, "foo -2.560000E+002", "foo -2.560000E+02"); - DoDoubleTest("foo % E", neg, "foo -2.560000E+002", "foo -2.560000E+02"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test15/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test15/testinfo.dat deleted file mode 100644 index 913912508..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test15/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = _vsnprintf -Name = Positive Test for _vsnprintf -TYPE = DEFAULT -EXE1 = test15 -Description -= Tests the PAL implementation of the _vsnprintf function. -= Tests _vsnprintf with exponential format doubles (uppercase). -= This test is modeled after sprintf_s. diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test16/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test16/CMakeLists.txt deleted file mode 100644 index 1fd88667d..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test16/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test16.cpp -) - -add_executable(paltest_vsnprintf_test16 - ${SOURCES} -) - -add_dependencies(paltest_vsnprintf_test16 coreclrpal) - -target_link_libraries(paltest_vsnprintf_test16 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test16/test16.cpp b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test16/test16.cpp deleted file mode 100644 index de9b74f9b..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test16/test16.cpp +++ /dev/null @@ -1,49 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test16.c -** -** Purpose: Test #16 for the _vsnprintf function. -** -** -**===================================================================*/ - -#include -#include "../_vsnprintf_s.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - -int __cdecl main(int argc, char *argv[]) -{ - double val = 2560.001; - double neg = -2560.001; - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoDoubleTest("foo %f", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %lf", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %hf", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %Lf", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %I64f", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %12f", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %-12f", val, "foo 2560.001000 ", "foo 2560.001000 "); - DoDoubleTest("foo %.1f", val, "foo 2560.0", "foo 2560.0"); - DoDoubleTest("foo %.8f", val, "foo 2560.00100000", "foo 2560.00100000"); - DoDoubleTest("foo %012f", val, "foo 02560.001000", "foo 02560.001000"); - DoDoubleTest("foo %#f", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %+f", val, "foo +2560.001000", "foo +2560.001000"); - DoDoubleTest("foo % f", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %+f", neg, "foo -2560.001000", "foo -2560.001000"); - DoDoubleTest("foo % f", neg, "foo -2560.001000", "foo -2560.001000"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test16/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test16/testinfo.dat deleted file mode 100644 index fc2f13071..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test16/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = _vsnprintf -Name = Positive Test for _vsnprintf -TYPE = DEFAULT -EXE1 = test16 -Description -= Tests the PAL implementation of the _vsnprintf function. -= Tests _vsnprintf with decimal point format doubles. -= This test is modeled after sprintf_s. diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test17/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test17/CMakeLists.txt deleted file mode 100644 index ffd52caa6..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test17/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test17.cpp -) - -add_executable(paltest_vsnprintf_test17 - ${SOURCES} -) - -add_dependencies(paltest_vsnprintf_test17 coreclrpal) - -target_link_libraries(paltest_vsnprintf_test17 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test17/test17.cpp b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test17/test17.cpp deleted file mode 100644 index 3304eda7f..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test17/test17.cpp +++ /dev/null @@ -1,50 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test17.c -** -** Purpose: Test #17 for the _vsnprintf function. -** -** -**===================================================================*/ - -#include -#include "../_vsnprintf_s.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - -int __cdecl main(int argc, char *argv[]) -{ - double val = 2560.001; - double neg = -2560.001; - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoDoubleTest("foo %g", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %lg", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %hg", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %Lg", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %I64g", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %5g", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %-5g", val, "foo 2560 ", "foo 2560 "); - DoDoubleTest("foo %.1g", val, "foo 3e+003", "foo 3e+03"); - DoDoubleTest("foo %.2g", val, "foo 2.6e+003", "foo 2.6e+03"); - DoDoubleTest("foo %.12g", val, "foo 2560.001", "foo 2560.001"); - DoDoubleTest("foo %06g", val, "foo 002560", "foo 002560"); - DoDoubleTest("foo %#g", val, "foo 2560.00", "foo 2560.00"); - DoDoubleTest("foo %+g", val, "foo +2560", "foo +2560"); - DoDoubleTest("foo % g", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %+g", neg, "foo -2560", "foo -2560"); - DoDoubleTest("foo % g", neg, "foo -2560", "foo -2560"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test17/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test17/testinfo.dat deleted file mode 100644 index aeb924495..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test17/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = _vsnprintf -Name = Positive Test for _vsnprintf -TYPE = DEFAULT -EXE1 = test17 -Description -= Tests the PAL implementation of the _vsnprintf function. -= Tests _vsnprintf with compact format doubles (lowercase). -= This test is modeled after sprintf_s. diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test18/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test18/CMakeLists.txt deleted file mode 100644 index 1bd8e3bc5..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test18/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test18.cpp -) - -add_executable(paltest_vsnprintf_test18 - ${SOURCES} -) - -add_dependencies(paltest_vsnprintf_test18 coreclrpal) - -target_link_libraries(paltest_vsnprintf_test18 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test18/test18.cpp b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test18/test18.cpp deleted file mode 100644 index 14ad8f583..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test18/test18.cpp +++ /dev/null @@ -1,50 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test18.c -** -** Purpose: Test #18 for the _vsnprintf function. -** -** -**===================================================================*/ - -#include -#include "../_vsnprintf_s.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - -int __cdecl main(int argc, char *argv[]) -{ - double val = 2560.001; - double neg = -2560.001; - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoDoubleTest("foo %G", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %lG", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %hG", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %LG", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %I64G", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %5G", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %-5G", val, "foo 2560 ", "foo 2560 "); - DoDoubleTest("foo %.1G", val, "foo 3E+003", "foo 3E+03"); - DoDoubleTest("foo %.2G", val, "foo 2.6E+003", "foo 2.6E+03"); - DoDoubleTest("foo %.12G", val, "foo 2560.001", "foo 2560.001"); - DoDoubleTest("foo %06G", val, "foo 002560", "foo 002560"); - DoDoubleTest("foo %#G", val, "foo 2560.00", "foo 2560.00"); - DoDoubleTest("foo %+G", val, "foo +2560", "foo +2560"); - DoDoubleTest("foo % G", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %+G", neg, "foo -2560", "foo -2560"); - DoDoubleTest("foo % G", neg, "foo -2560", "foo -2560"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test18/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test18/testinfo.dat deleted file mode 100644 index 57aaed595..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test18/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = _vsnprintf -Name = Positive Test for _vsnprintf -TYPE = DEFAULT -EXE1 = test18 -Description -= Tests the PAL implementation of the _vsnprintf function. -= Tests _vsnprintf with compact format doubles (uppercase). -= This test is modeled after sprintf_s. diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test19/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test19/CMakeLists.txt deleted file mode 100644 index 3848c130b..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test19/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test19.cpp -) - -add_executable(paltest_vsnprintf_test19 - ${SOURCES} -) - -add_dependencies(paltest_vsnprintf_test19 coreclrpal) - -target_link_libraries(paltest_vsnprintf_test19 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test19/test19.cpp b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test19/test19.cpp deleted file mode 100644 index 6f2aefa94..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test19/test19.cpp +++ /dev/null @@ -1,103 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test19.c -** -** Purpose: Test #19 for the _vsnprintf function. -** -** -**===================================================================*/ - -#include -#include "../_vsnprintf_s.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - -#define DOTEST(a,b,c,d,e) DoTest(a,b,(void*)c,d,e) - -void DoArgumentPrecTest(char *formatstr, int precision, void *param, - char *paramstr, char *checkstr1, char *checkstr2) -{ - char buf[256]; - - Testvsnprintf(buf,256,formatstr, precision, param); - if (memcmp(buf, checkstr1, strlen(checkstr1) + 1) != 0 && - memcmp(buf, checkstr2, strlen(checkstr2) + 1) != 0) - { - Fail("ERROR: failed to insert %s into \"%s\" with precision %d\n" - "Expected \"%s\" or \"%s\", got \"%s\".\n", - paramstr, formatstr, precision, checkstr1, checkstr2, buf); - } - -} - -void DoArgumentPrecDoubleTest(char *formatstr, int precision, double param, - char *checkstr1, char *checkstr2) -{ - char buf[256]; - - Testvsnprintf(buf,256,formatstr, precision, param); - if (memcmp(buf, checkstr1, strlen(checkstr1) + 1) != 0 && - memcmp(buf, checkstr2, strlen(checkstr2) + 1) != 0) - { - Fail("ERROR: failed to insert %f into \"%s\" with precision %d\n" - "Expected \"%s\" or \"%s\", got \"%s\".\n", - param, formatstr, precision, checkstr1, checkstr2, buf); - } - -} - - - -int __cdecl main(int argc, char *argv[]) -{ - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - - DoArgumentPrecTest("%.*s", 2, (void*)"bar", "bar", "ba", "ba"); - DoArgumentPrecTest("%.*S", 2, (void*)convert("bar"), "bar", "ba", "ba"); - DoArgumentPrecTest("%.*c", 0, (void*)'a', "a", "a", "a"); - DoArgumentPrecTest("%.*c", 4, (void*)'a', "a", "a", "a"); - DoArgumentPrecTest("%.*C", 0, (void*)'a', "a", "a", "a"); - DoArgumentPrecTest("%.*C", 4, (void*)'a', "a", "a", "a"); - DoArgumentPrecTest("%.*d", 1, (void*)42, "42", "42", "42"); - DoArgumentPrecTest("%.*d", 3, (void*)42, "42", "042", "042"); - DoArgumentPrecTest("%.*i", 1, (void*)42, "42", "42", "42"); - DoArgumentPrecTest("%.*i", 3, (void*)42, "42", "042", "042"); - DoArgumentPrecTest("%.*o", 1, (void*)42, "42", "52", "52"); - DoArgumentPrecTest("%.*o", 3, (void*)42, "42", "052", "052"); - DoArgumentPrecTest("%.*u", 1, (void*)42, "42", "42", "42"); - DoArgumentPrecTest("%.*u", 3, (void*)42, "42", "042", "042"); - DoArgumentPrecTest("%.*x", 1, (void*)0x42, "0x42", "42", "42"); - DoArgumentPrecTest("%.*x", 3, (void*)0x42, "0x42", "042", "042"); - DoArgumentPrecTest("%.*X", 1, (void*)0x42, "0x42", "42", "42"); - DoArgumentPrecTest("%.*X", 3, (void*)0x42, "0x42", "042", "042"); - - - DoArgumentPrecDoubleTest("%.*e", 1, 2.01, "2.0e+000", "2.0e+00"); - DoArgumentPrecDoubleTest("%.*e", 3, 2.01, "2.010e+000", "2.010e+00"); - DoArgumentPrecDoubleTest("%.*E", 1, 2.01, "2.0E+000", "2.0E+00"); - DoArgumentPrecDoubleTest("%.*E", 3, 2.01, "2.010E+000", "2.010E+00"); - DoArgumentPrecDoubleTest("%.*f", 1, 2.01, "2.0", "2.0"); - DoArgumentPrecDoubleTest("%.*f", 3, 2.01, "2.010", "2.010"); - DoArgumentPrecDoubleTest("%.*g", 1, 256.01, "3e+002", "3e+02"); - DoArgumentPrecDoubleTest("%.*g", 3, 256.01, "256", "256"); - DoArgumentPrecDoubleTest("%.*g", 4, 256.01, "256", "256"); - DoArgumentPrecDoubleTest("%.*g", 6, 256.01, "256.01", "256.01"); - DoArgumentPrecDoubleTest("%.*G", 1, 256.01, "3E+002", "3E+02"); - DoArgumentPrecDoubleTest("%.*G", 3, 256.01, "256", "256"); - DoArgumentPrecDoubleTest("%.*G", 4, 256.01, "256", "256"); - DoArgumentPrecDoubleTest("%.*G", 6, 256.01, "256.01", "256.01"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test19/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test19/testinfo.dat deleted file mode 100644 index cda896686..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test19/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = _vsnprintf -Name = Positive Test for _vsnprintf -TYPE = DEFAULT -EXE1 = test19 -Description -= Tests the PAL implementation of the _vsnprintf function. -= Tests _vsnprintf with argument specified precision. -= This test is modeled after sprintf_s. diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test2/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test2/CMakeLists.txt deleted file mode 100644 index 5bdf0acff..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test2.cpp -) - -add_executable(paltest_vsnprintf_test2 - ${SOURCES} -) - -add_dependencies(paltest_vsnprintf_test2 coreclrpal) - -target_link_libraries(paltest_vsnprintf_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test2/test2.cpp b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test2/test2.cpp deleted file mode 100644 index e5808f363..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test2/test2.cpp +++ /dev/null @@ -1,50 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test2.c -** -** Purpose: Test #2 for the _vsnprintf function. -** -** -**===================================================================*/ - -#include -#include "../_vsnprintf_s.h" -/* - * Notes: memcmp is used, as is strlen. - */ - -int __cdecl main(int argc, char *argv[]) -{ - WCHAR szwStr[] = {'b','a','r','\0'}; - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoStrTest("foo %s", "bar", "foo bar"); - DoStrTest("foo %hs", "bar", "foo bar"); - DoWStrTest("foo %ls", szwStr, "foo bar"); - DoWStrTest("foo %ws", szwStr, "foo bar"); - DoStrTest("foo %Ls", "bar", "foo bar"); - DoStrTest("foo %I64s", "bar", "foo bar"); - DoStrTest("foo %5s", "bar", "foo bar"); - DoStrTest("foo %.2s", "bar", "foo ba"); - DoStrTest("foo %5.2s", "bar", "foo ba"); - DoStrTest("foo %-5s", "bar", "foo bar "); - DoStrTest("foo %05s", "bar", "foo 00bar"); - DoStrTest("foo %s", NULL, "foo (null)"); - DoStrTest("foo %hs", NULL, "foo (null)"); - DoWStrTest("foo %ls", NULL, "foo (null)"); - DoWStrTest("foo %ws", NULL, "foo (null)"); - DoStrTest("foo %Ls", NULL, "foo (null)"); - DoStrTest("foo %I64s", NULL, "foo (null)"); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test2/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test2/testinfo.dat deleted file mode 100644 index 6e8f03e63..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test2/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = _vsnprintf -Name = Positive Test for _vsnprintf -TYPE = DEFAULT -EXE1 = test2 -Description -= Tests the PAL implementation of the _vsnprintf function. -= Tests _vsnprintf with strings. -= This test is modeled after sprintf_s. diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test3/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test3/CMakeLists.txt deleted file mode 100644 index 7268cf17f..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test3/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test3.cpp -) - -add_executable(paltest_vsnprintf_test3 - ${SOURCES} -) - -add_dependencies(paltest_vsnprintf_test3 coreclrpal) - -target_link_libraries(paltest_vsnprintf_test3 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test3/test3.cpp b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test3/test3.cpp deleted file mode 100644 index bb8b153b5..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test3/test3.cpp +++ /dev/null @@ -1,49 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test3.c -** -** Purpose: Test #3 for the _vsnprintf function. -** -** -**===================================================================*/ - -#include -#include "../_vsnprintf_s.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - -int __cdecl main(int argc, char *argv[]) -{ - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoWStrTest("foo %S", convert("bar"), "foo bar"); - DoStrTest("foo %hS", "bar", "foo bar"); - DoWStrTest("foo %lS", convert("bar"), "foo bar"); - DoWStrTest("foo %wS", convert("bar"), "foo bar"); - DoWStrTest("foo %LS", convert("bar"), "foo bar"); - DoWStrTest("foo %I64S", convert("bar"), "foo bar"); - DoWStrTest("foo %5S", convert("bar"), "foo bar"); - DoWStrTest("foo %.2S", convert("bar"), "foo ba"); - DoWStrTest("foo %5.2S", convert("bar"), "foo ba"); - DoWStrTest("foo %-5S", convert("bar"), "foo bar "); - DoWStrTest("foo %05S", convert("bar"), "foo 00bar"); - DoWStrTest("foo %S", NULL, "foo (null)"); - DoStrTest("foo %hS", NULL, "foo (null)"); - DoWStrTest("foo %lS", NULL, "foo (null)"); - DoWStrTest("foo %wS", NULL, "foo (null)"); - DoWStrTest("foo %LS", NULL, "foo (null)"); - DoWStrTest("foo %I64S", NULL, "foo (null)"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test3/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test3/testinfo.dat deleted file mode 100644 index 638cef69e..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test3/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = _vsnprintf -Name = Positive Test for _vsnprintf -TYPE = DEFAULT -EXE1 = test3 -Description -= Tests the PAL implementation of the _vsnprintf function. -= Tests _vsnprintf with wide strings. -= This test is modeled after sprintf_s. diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test4/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test4/CMakeLists.txt deleted file mode 100644 index f2419479f..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test4/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test4.cpp -) - -add_executable(paltest_vsnprintf_test4 - ${SOURCES} -) - -add_dependencies(paltest_vsnprintf_test4 coreclrpal) - -target_link_libraries(paltest_vsnprintf_test4 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test4/test4.cpp b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test4/test4.cpp deleted file mode 100644 index c4a77f957..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test4/test4.cpp +++ /dev/null @@ -1,98 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test4.c -** -** Purpose: Test #4 for the _vsnprintf function. -** -** -**===================================================================*/ - -#include -#include "../_vsnprintf_s.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - -static void DoPointerTest(char *formatstr, void* param, char* paramstr, - char *checkstr1) -{ - char buf[256] = { 0 }; - - Testvsnprintf(buf,256, formatstr, param); - if (memcmp(buf, checkstr1, strlen(checkstr1) + 1) != 0) - { - Fail("ERROR: failed to insert %s into \"%s\"\n" - "Expected \"%s\" got \"%s\".\n", - paramstr, formatstr, checkstr1, buf); - } -} - -static void DoI64DoubleTest(char *formatstr, INT64 value, char *valuestr, char -*checkstr1) -{ - char buf[256] = { 0 }; - - Testvsnprintf(buf,256,formatstr, value); - if (memcmp(buf, checkstr1, strlen(checkstr1) + 1) != 0) - { - Fail("ERROR: failed to insert %s into \"%s\"\n" - "Expected \"%s\", got \"%s\".\n", - valuestr, formatstr, checkstr1, buf); - } -} - -int __cdecl main(int argc, char *argv[]) -{ - void *ptr = (void*) 0x123456; - INT64 lptr = I64(0x1234567887654321); - - if (PAL_Initialize(argc, argv) != 0) - return(FAIL); - - - /* -** Run only on 64 bit platforms -*/ -#if defined(BIT64) - Trace("Testing for 64 Bit Platforms \n"); - DoPointerTest("%p", NULL, "NULL", "0000000000000000"); - DoPointerTest("%p", ptr, "pointer to 0x123456", "0000000000123456"); - DoPointerTest("%17p", ptr, "pointer to 0x123456", " 0000000000123456"); - DoPointerTest("%17p", ptr, "pointer to 0x123456", " 0000000000123456"); - DoPointerTest("%-17p", ptr, "pointer to 0x123456", "0000000000123456 "); - DoPointerTest("%+p", ptr, "pointer to 0x123456", "0000000000123456"); - DoPointerTest("%#p", ptr, "pointer to 0x123456", "0X0000000000123456"); - DoPointerTest("%lp", ptr, "pointer to 0x123456", "00123456"); - DoPointerTest("%hp", ptr, "pointer to 0x123456", "00003456"); - DoPointerTest("%Lp", ptr, "pointer to 0x123456", "00123456"); - DoI64DoubleTest("%I64p", lptr, "pointer to 0x1234567887654321", - "1234567887654321"); - -#else - Trace("Testing for Non 64 Bit Platforms \n"); - DoPointerTest("%p", NULL, "NULL", "00000000"); - DoPointerTest("%p", ptr, "pointer to 0x123456", "00123456"); - DoPointerTest("%9p", ptr, "pointer to 0x123456", " 00123456"); - DoPointerTest("%09p", ptr, "pointer to 0x123456", " 00123456"); - DoPointerTest("%-9p", ptr, "pointer to 0x123456", "00123456 "); - DoPointerTest("%+p", ptr, "pointer to 0x123456", "00123456"); - DoPointerTest("%#p", ptr, "pointer to 0x123456", "0X00123456"); - DoPointerTest("%lp", ptr, "pointer to 0x123456", "00123456"); - DoPointerTest("%hp", ptr, "pointer to 0x123456", "00003456"); - DoPointerTest("%Lp", ptr, "pointer to 0x123456", "00123456"); - DoI64DoubleTest("%I64p", lptr, "pointer to 0x1234567887654321", - "1234567887654321"); -#endif - - - - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test4/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test4/testinfo.dat deleted file mode 100644 index 03ff2931b..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test4/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = _vsnprintf -Name = Positive Test for _vsnprintf -TYPE = DEFAULT -EXE1 = test4 -Description -= Tests the PAL implementation of the _vsnprintf function. -= Tests _vsnprintf with pointers. -= This test is modeled after sprintf_s. diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test6/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test6/CMakeLists.txt deleted file mode 100644 index 3c6b43fe2..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test6/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test6.cpp -) - -add_executable(paltest_vsnprintf_test6 - ${SOURCES} -) - -add_dependencies(paltest_vsnprintf_test6 coreclrpal) - -target_link_libraries(paltest_vsnprintf_test6 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test6/test6.cpp b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test6/test6.cpp deleted file mode 100644 index cbcead88b..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test6/test6.cpp +++ /dev/null @@ -1,44 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test6.c -** -** Purpose: Test #6 for the _vsnprintf function. -** -** -**===================================================================*/ - -#include -#include "../_vsnprintf_s.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - -int __cdecl main(int argc, char *argv[]) -{ - WCHAR wc = (WCHAR) 'c'; - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoCharTest("foo %c", 'b', "foo b"); - DoCharTest("foo %hc", 'b', "foo b"); - DoWCharTest("foo %lc", wc, "foo c"); - DoCharTest("foo %Lc", 'b', "foo b"); - DoCharTest("foo %I64c", 'b', "foo b"); - DoCharTest("foo %5c", 'b', "foo b"); - DoCharTest("foo %.0c", 'b', "foo b"); - DoCharTest("foo %-5c", 'b', "foo b "); - DoCharTest("foo %05c", 'b', "foo 0000b"); - DoCharTest("foo % c", 'b', "foo b"); - DoCharTest("foo %#c", 'b', "foo b"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test6/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test6/testinfo.dat deleted file mode 100644 index e375f9238..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test6/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = _vsnprintf -Name = Positive Test for _vsnprintf -TYPE = DEFAULT -EXE1 = test6 -Description -= Tests the PAL implementation of the _vsnprintf function. -= Tests _vsnprintf with characters. -= This test is modeled after sprintf_s. diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test7/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test7/CMakeLists.txt deleted file mode 100644 index 6708b3900..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test7/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test7.cpp -) - -add_executable(paltest_vsnprintf_test7 - ${SOURCES} -) - -add_dependencies(paltest_vsnprintf_test7 coreclrpal) - -target_link_libraries(paltest_vsnprintf_test7 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test7/test7.cpp b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test7/test7.cpp deleted file mode 100644 index 4843d2759..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test7/test7.cpp +++ /dev/null @@ -1,44 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test7.c -** -** Purpose: Test #7 for the _vsnprintf function. -** -** -**===================================================================*/ - -#include -#include "../_vsnprintf_s.h" -/* - * Notes: memcmp is used, as is strlen. - */ - - -int __cdecl main(int argc, char *argv[]) -{ - WCHAR wb = (WCHAR) 'b'; - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoWCharTest("foo %c", wb, "foo b"); - DoWCharTest("foo %hc", wb, "foo b"); - DoCharTest("foo %lc", 'c', "foo c"); - DoWCharTest("foo %Lc", wb, "foo b"); - DoWCharTest("foo %I64c", wb, "foo b"); - DoWCharTest("foo %5c", wb, "foo b"); - DoWCharTest("foo %.0c", wb, "foo b"); - DoWCharTest("foo %-5c", wb, "foo b "); - DoWCharTest("foo %05c", wb, "foo 0000b"); - DoWCharTest("foo % c", wb, "foo b"); - DoWCharTest("foo %#c", wb, "foo b"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test7/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test7/testinfo.dat deleted file mode 100644 index 09eb481b5..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test7/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = _vsnprintf -Name = Positive Test for _vsnprintf -TYPE = DEFAULT -EXE1 = test7 -Description -= Tests the PAL implementation of the _vsnprintf function. -= Tests _vsnprintf with wide characters. -= This test is modeled after sprintf_s. diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test8/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test8/CMakeLists.txt deleted file mode 100644 index 8a396fdcf..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test8/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test8.cpp -) - -add_executable(paltest_vsnprintf_test8 - ${SOURCES} -) - -add_dependencies(paltest_vsnprintf_test8 coreclrpal) - -target_link_libraries(paltest_vsnprintf_test8 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test8/test8.cpp b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test8/test8.cpp deleted file mode 100644 index 8021a797c..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test8/test8.cpp +++ /dev/null @@ -1,52 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test8.c -** -** Purpose: Test #8 for the _vsnprintf function. -** -** -**===================================================================*/ - -#include -#include "../_vsnprintf_s.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - - -int __cdecl main(int argc, char *argv[]) -{ - int neg = -42; - int pos = 42; - INT64 l = 42; - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoNumTest("foo %d", pos, "foo 42"); - DoNumTest("foo %ld", 0xFFFF, "foo 65535"); - DoNumTest("foo %hd", 0xFFFF, "foo -1"); - DoNumTest("foo %Ld", pos, "foo 42"); - DoI64Test("foo %I64d", l, "42", "foo 42"); - DoNumTest("foo %3d", pos, "foo 42"); - DoNumTest("foo %-3d", pos, "foo 42 "); - DoNumTest("foo %.1d", pos, "foo 42"); - DoNumTest("foo %.3d", pos, "foo 042"); - DoNumTest("foo %03d", pos, "foo 042"); - DoNumTest("foo %#d", pos, "foo 42"); - DoNumTest("foo %+d", pos, "foo +42"); - DoNumTest("foo % d", pos, "foo 42"); - DoNumTest("foo %+d", neg, "foo -42"); - DoNumTest("foo % d", neg, "foo -42"); - - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test8/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test8/testinfo.dat deleted file mode 100644 index 1bdf41198..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test8/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = _vsnprintf -Name = Positive Test for _vsnprintf -TYPE = DEFAULT -EXE1 = test8 -Description -= Tests the PAL implementation of the _vsnprintf function. -= Tests _vsnprintf with decimal numbers. -= This test is modeled after sprintf_s. diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test9/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test9/CMakeLists.txt deleted file mode 100644 index 136856b64..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test9/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test9.cpp -) - -add_executable(paltest_vsnprintf_test9 - ${SOURCES} -) - -add_dependencies(paltest_vsnprintf_test9 coreclrpal) - -target_link_libraries(paltest_vsnprintf_test9 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test9/test9.cpp b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test9/test9.cpp deleted file mode 100644 index d36846e40..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test9/test9.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test9.c -** -** Purpose: Test #9 for the _vsnprintf function. -** -** -**===================================================================*/ - -#include -#include "../_vsnprintf_s.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - - -int __cdecl main(int argc, char *argv[]) -{ - int neg = -42; - int pos = 42; - INT64 l = 42; - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoNumTest("foo %i", pos, "foo 42"); - DoNumTest("foo %li", 0xFFFF, "foo 65535"); - DoNumTest("foo %hi", 0xFFFF, "foo -1"); - DoNumTest("foo %Li", pos, "foo 42"); - DoI64Test("foo %I64i", l, "42", "foo 42"); - DoNumTest("foo %3i", pos, "foo 42"); - DoNumTest("foo %-3i", pos, "foo 42 "); - DoNumTest("foo %.1i", pos, "foo 42"); - DoNumTest("foo %.3i", pos, "foo 042"); - DoNumTest("foo %03i", pos, "foo 042"); - DoNumTest("foo %#i", pos, "foo 42"); - DoNumTest("foo %+i", pos, "foo +42"); - DoNumTest("foo % i", pos, "foo 42"); - DoNumTest("foo %+i", neg, "foo -42"); - DoNumTest("foo % i", neg, "foo -42"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test9/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test9/testinfo.dat deleted file mode 100644 index bdaae87ce..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnprintf_s/test9/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = _vsnprintf -Name = Positive Test for _vsnprintf -TYPE = DEFAULT -EXE1 = test9 -Description -= Tests the PAL implementation of the _vsnprintf function. -= Tests _vsnprintf with integer numbers. -= This test is modeled after sprintf_s. diff --git a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/CMakeLists.txt deleted file mode 100644 index 8fe1cb60a..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/CMakeLists.txt +++ /dev/null @@ -1,21 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test10) -add_subdirectory(test11) -add_subdirectory(test12) -add_subdirectory(test13) -add_subdirectory(test14) -add_subdirectory(test15) -add_subdirectory(test16) -add_subdirectory(test17) -add_subdirectory(test18) -add_subdirectory(test19) -add_subdirectory(test2) -add_subdirectory(test3) -add_subdirectory(test4) -add_subdirectory(test6) -add_subdirectory(test7) -add_subdirectory(test8) -add_subdirectory(test9) - diff --git a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/_vsnwprintf_s.h b/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/_vsnwprintf_s.h deleted file mode 100644 index 34cf411c2..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/_vsnwprintf_s.h +++ /dev/null @@ -1,133 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: _vsnwprintf_s.h -** -** Purpose: Containts common testing functions for _vsnwprintf_s -** -** -**==========================================================================*/ - -#ifndef ___VSNWPRINTF_H__ -#define ___VSNWPRINTF_H__ - -/* These functions leaks memory like crazy. C'est la vie. */ -int TestVsnwprintf_s(wchar_t* buf, size_t count, const wchar_t* format, ...) -{ - int retVal = 0; - va_list arglist; - - va_start(arglist, format); - retVal = _vsnwprintf_s(buf, count, _TRUNCATE, format, arglist); - va_end(arglist); - - return( retVal); -} - - -void DoWStrTest(const WCHAR *formatstr, WCHAR *param, const WCHAR *checkstr) -{ - WCHAR buf[256] = { 0 }; - - TestVsnwprintf_s(buf, 256, formatstr, param); - - if (memcmp(buf, checkstr, wcslen(buf) * 2 + 2) != 0) - { - Fail("ERROR: failed to insert wide string \"%s\" into \"%s\".\n" - "Expected \"%s\", got \"%s\".\n", - convertC(param), convertC(formatstr), - convertC(checkstr), convertC(buf)); - } -} - -void DoStrTest(const WCHAR *formatstr, char *param, const WCHAR *checkstr) -{ - WCHAR buf[256] = { 0 }; - - TestVsnwprintf_s(buf, 256, formatstr, param); - - if (memcmp(buf, checkstr, wcslen(buf) * 2 + 2) != 0) - { - Fail("ERROR: failed to insert wide string \"%s\" into \"%s\".\n" - "Expected \"%s\", got \"%s\".\n", - param, convertC(formatstr), convertC(checkstr), - convertC(buf)); - } -} - -void DoCharTest(const WCHAR *formatstr, char param, const WCHAR *checkstr) -{ - WCHAR buf[256] = { 0 }; - - TestVsnwprintf_s(buf, 256, formatstr, param); - if (memcmp(buf, checkstr, wcslen(buf)*2 + 2) != 0) - { - Fail("ERROR: failed to insert char \'%c\' (%d) into \"%s\"\n" - "Expected \"%s\" got \"%s\".\n", - param, param, convertC(formatstr), convertC(checkstr), - convertC(buf)); - } -} - -void DoWCharTest(const WCHAR *formatstr, WCHAR param, const WCHAR *checkstr) -{ - WCHAR buf[256] = { 0 }; - - TestVsnwprintf_s(buf, 256, formatstr, param); - if (memcmp(buf, checkstr, wcslen(buf)*2 + 2) != 0) - { - Fail("ERROR: failed to insert wide char \'%c\' (%d) into \"%s\"\n" - "Expected \"%s\" got \"%s\".\n", - (char) param, param, convertC(formatstr), - convertC(checkstr), convertC(buf)); - } -} - -void DoNumTest(const WCHAR *formatstr, int value, const WCHAR *checkstr) -{ - WCHAR buf[256] = { 0 }; - - TestVsnwprintf_s(buf, 256, formatstr, value); - if (memcmp(buf, checkstr, wcslen(buf)* 2 + 2) != 0) - { - Fail("ERROR: failed to insert %#x into \"%s\"\n" - "Expected \"%s\" got \"%s\".\n", value, convertC(formatstr), - convertC(checkstr), convertC(buf)); - } -} - -void DoI64NumTest(const WCHAR *formatstr, INT64 value, char *valuestr, const WCHAR *checkstr) -{ - WCHAR buf[256] = { 0 }; - - TestVsnwprintf_s(buf, 256, formatstr, value); - if (memcmp(buf, checkstr, wcslen(buf)* 2 + 2) != 0) - { - Fail("ERROR: failed to insert %s into \"%s\"\n" - "Expected \"%s\" got \"%s\".\n", valuestr, convertC(formatstr), - convertC(checkstr), convertC(buf)); - } -} -void DoDoubleTest(const WCHAR *formatstr, double value, - const WCHAR *checkstr1, const WCHAR *checkstr2) -{ - WCHAR buf[256] = { 0 }; - - TestVsnwprintf_s(buf, 256, formatstr, value); - if (memcmp(buf, checkstr1, wcslen(checkstr1) + 2) != 0 && - memcmp(buf, checkstr2, wcslen(checkstr2) + 2) != 0) - { - Fail("ERROR: failed to insert %f into \"%s\"\n" - "Expected \"%s\" or \"%s\", got \"%s\".\n", - value, - convertC(formatstr), - convertC(checkstr1), - convertC(checkstr2), - convertC(buf)); - } -} - -#endif diff --git a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test1/CMakeLists.txt deleted file mode 100644 index 013811140..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_vsnwprintf_test1 - ${SOURCES} -) - -add_dependencies(paltest_vsnwprintf_test1 coreclrpal) - -target_link_libraries(paltest_vsnwprintf_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test1/test1.cpp deleted file mode 100644 index 4a7a02e77..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test1/test1.cpp +++ /dev/null @@ -1,60 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test1.c -** -** Purpose: Test #1 for the _vsnwprintf_s function. -** -** -**===================================================================*/ - -#include -#include "../_vsnwprintf_s.h" - -/* memcmp is used to verify the results, so this test is dependent on it. */ -/* ditto with wcslen */ - - -int __cdecl main(int argc, char *argv[]) -{ - WCHAR *checkstr; - WCHAR buf[256] = { 0 }; - int ret; - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - checkstr = convert("hello world"); - TestVsnwprintf_s(buf, 256, checkstr); - if (memcmp(checkstr, buf, wcslen(checkstr)*2+2) != 0) - { - Fail("ERROR: Expected \"%s\", got \"%s\"\n", - convertC(checkstr), convertC(buf)); - } - - TestVsnwprintf_s(buf, 256, convert("xxxxxxxxxxxxxxxxx")); - ret = TestVsnwprintf_s(buf, 8, checkstr); - if ((memcmp(checkstr, buf, 14)) != 0 || (buf[7] != 0)) - { - Fail("ERROR: Expected \"%8s\", got \"%8s\"\n", - convertC(checkstr), convertC(buf)); - } - if (ret >= 0) - { - Fail("ERROR: Expected negative return value, got %d.\n", ret); - } - if (buf[8] != (WCHAR) 'x') - { - Fail("ERROR: buffer overflow using \"%s\" with length 8.\n", - convertC(checkstr)); - } - - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test1/testinfo.dat deleted file mode 100644 index 450c5b903..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test1/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = _vsnwprintf_s -Name = Positive Test for _vsnwprintf_s -TYPE = DEFAULT -EXE1 = test1 -Description -= Tests the PAL implementation of the _vsnwprintf_s function. -= General test to see if _vsnwprintf_s works correctly. -= This test is modeled after _snwprintf. diff --git a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test10/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test10/CMakeLists.txt deleted file mode 100644 index e669b1e47..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test10/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test10.cpp -) - -add_executable(paltest_vsnwprintf_test10 - ${SOURCES} -) - -add_dependencies(paltest_vsnwprintf_test10 coreclrpal) - -target_link_libraries(paltest_vsnwprintf_test10 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test10/test10.cpp b/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test10/test10.cpp deleted file mode 100644 index e33f2281d..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test10/test10.cpp +++ /dev/null @@ -1,50 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test10.c -** -** Purpose: Test #10 for the _vsnwprintf_s function. -** -** -**===================================================================*/ - -#include -#include "../_vsnwprintf_s.h" - -/* memcmp is used to verify the results, so this test is dependent on it. */ -/* ditto with wcslen */ - -int __cdecl main(int argc, char *argv[]) -{ - int neg = -42; - int pos = 42; - INT64 l = 42; - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoNumTest(convert("foo %o"), pos, convert("foo 52")); - DoNumTest(convert("foo %lo"), 0xFFFF, convert("foo 177777")); - DoNumTest(convert("foo %ho"), 0xFFFF, convert("foo 177777")); - DoNumTest(convert("foo %Lo"), pos, convert("foo 52")); - DoI64NumTest(convert("foo %I64o"), l, "42", convert("foo 52")); - DoNumTest(convert("foo %3o"), pos, convert("foo 52")); - DoNumTest(convert("foo %-3o"), pos, convert("foo 52 ")); - DoNumTest(convert("foo %.1o"), pos, convert("foo 52")); - DoNumTest(convert("foo %.3o"), pos, convert("foo 052")); - DoNumTest(convert("foo %03o"), pos, convert("foo 052")); - DoNumTest(convert("foo %#o"), pos, convert("foo 052")); - DoNumTest(convert("foo %+o"), pos, convert("foo 52")); - DoNumTest(convert("foo % o"), pos, convert("foo 52")); - DoNumTest(convert("foo %+o"), neg, convert("foo 37777777726")); - DoNumTest(convert("foo % o"), neg, convert("foo 37777777726")); - - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test10/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test10/testinfo.dat deleted file mode 100644 index 59af082f4..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test10/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = _vsnwprintf_s -Name = Positive Test for _vsnwprintf_s -TYPE = DEFAULT -EXE1 = test10 -Description -= Tests the PAL implementation of the _vsnwprintf_s function. -= Tests _vsnwprintf_s with octal numbers. -= This test is modeled after _snwprintf. diff --git a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test11/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test11/CMakeLists.txt deleted file mode 100644 index acb914b93..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test11/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test11.cpp -) - -add_executable(paltest_vsnwprintf_test11 - ${SOURCES} -) - -add_dependencies(paltest_vsnwprintf_test11 coreclrpal) - -target_link_libraries(paltest_vsnwprintf_test11 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test11/test11.cpp b/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test11/test11.cpp deleted file mode 100644 index 4e860bbc2..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test11/test11.cpp +++ /dev/null @@ -1,50 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test11.c -** -** Purpose: Test #11 for the _vsnwprintf_s function. -** -** -**===================================================================*/ - -#include -#include "../_vsnwprintf_s.h" - -/* memcmp is used to verify the results, so this test is dependent on it. */ -/* ditto with wcslen */ - -int __cdecl main(int argc, char *argv[]) -{ - int neg = -42; - int pos = 42; - INT64 l = 42; - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoNumTest(convert("foo %u"), pos, convert("foo 42")); - DoNumTest(convert("foo %lu"), 0xFFFF, convert("foo 65535")); - DoNumTest(convert("foo %hu"), 0xFFFF, convert("foo 65535")); - DoNumTest(convert("foo %Lu"), pos, convert("foo 42")); - DoI64NumTest(convert("foo %I64u"), l, "42", convert("foo 42")); - DoNumTest(convert("foo %3u"), pos, convert("foo 42")); - DoNumTest(convert("foo %-3u"), pos, convert("foo 42 ")); - DoNumTest(convert("foo %.1u"), pos, convert("foo 42")); - DoNumTest(convert("foo %.3u"), pos, convert("foo 042")); - DoNumTest(convert("foo %03u"), pos, convert("foo 042")); - DoNumTest(convert("foo %#u"), pos, convert("foo 42")); - DoNumTest(convert("foo %+u"), pos, convert("foo 42")); - DoNumTest(convert("foo % u"), pos, convert("foo 42")); - DoNumTest(convert("foo %+u"), neg, convert("foo 4294967254")); - DoNumTest(convert("foo % u"), neg, convert("foo 4294967254")); - - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test11/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test11/testinfo.dat deleted file mode 100644 index 10c0014fc..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test11/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = _vsnwprintf_s -Name = Positive Test for _vsnwprintf_s -TYPE = DEFAULT -EXE1 = test11 -Description -= Tests the PAL implementation of the _vsnwprintf_s function. -= Tests _vsnwprintf_s with unsigned numbers. -= This test is modeled after _snwprintf. diff --git a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test12/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test12/CMakeLists.txt deleted file mode 100644 index 0d83d5be9..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test12/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test12.cpp -) - -add_executable(paltest_vsnwprintf_test12 - ${SOURCES} -) - -add_dependencies(paltest_vsnwprintf_test12 coreclrpal) - -target_link_libraries(paltest_vsnwprintf_test12 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test12/test12.cpp b/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test12/test12.cpp deleted file mode 100644 index 2dcfcf599..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test12/test12.cpp +++ /dev/null @@ -1,50 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test12.c -** -** Purpose: Test #12 for the _vsnwprintf_s function. -** -** -**===================================================================*/ - -#include -#include "../_vsnwprintf_s.h" - -/* memcmp is used to verify the results, so this test is dependent on it. */ -/* ditto with wcslen */ - -int __cdecl main(int argc, char *argv[]) -{ - int neg = -42; - int pos = 0x1234ab; - INT64 l = I64(0x1234567887654321); - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoNumTest(convert("foo %x"), pos, convert("foo 1234ab")); - DoNumTest(convert("foo %lx"), pos, convert("foo 1234ab")); - DoNumTest(convert("foo %hx"), pos, convert("foo 34ab")); - DoNumTest(convert("foo %Lx"), pos, convert("foo 1234ab")); - DoI64NumTest(convert("foo %I64x"), l, "0x1234567887654321", - convert("foo 1234567887654321")); - DoNumTest(convert("foo %7x"), pos, convert("foo 1234ab")); - DoNumTest(convert("foo %-7x"), pos, convert("foo 1234ab ")); - DoNumTest(convert("foo %.1x"), pos, convert("foo 1234ab")); - DoNumTest(convert("foo %.7x"), pos, convert("foo 01234ab")); - DoNumTest(convert("foo %07x"), pos, convert("foo 01234ab")); - DoNumTest(convert("foo %#x"), pos, convert("foo 0x1234ab")); - DoNumTest(convert("foo %+x"), pos, convert("foo 1234ab")); - DoNumTest(convert("foo % x"), pos, convert("foo 1234ab")); - DoNumTest(convert("foo %+x"), neg, convert("foo ffffffd6")); - DoNumTest(convert("foo % x"), neg, convert("foo ffffffd6")); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test12/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test12/testinfo.dat deleted file mode 100644 index de089895b..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test12/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = _vsnwprintf_s -Name = Positive Test for _vsnwprintf_s -TYPE = DEFAULT -EXE1 = test12 -Description -= Tests the PAL implementation of the _vsnwprintf_s function. -= Tests _vsnwprintf_s with hex numbers (lowercase). -= This test is modeled after _snwprintf. diff --git a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test13/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test13/CMakeLists.txt deleted file mode 100644 index 27f37405f..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test13/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test13.cpp -) - -add_executable(paltest_vsnwprintf_test13 - ${SOURCES} -) - -add_dependencies(paltest_vsnwprintf_test13 coreclrpal) - -target_link_libraries(paltest_vsnwprintf_test13 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test13/test13.cpp b/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test13/test13.cpp deleted file mode 100644 index c95278a56..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test13/test13.cpp +++ /dev/null @@ -1,50 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test13.c -** -** Purpose: Test #13 for the _vsnwprintf_s function. -** -** -**===================================================================*/ - -#include -#include "../_vsnwprintf_s.h" - -/* memcmp is used to verify the results, so this test is dependent on it. */ -/* ditto with wcslen */ - -int __cdecl main(int argc, char *argv[]) -{ - int neg = -42; - int pos = 0x1234ab; - INT64 l = I64(0x1234567887654321); - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoNumTest(convert("foo %X"), pos, convert("foo 1234AB")); - DoNumTest(convert("foo %lX"), pos, convert("foo 1234AB")); - DoNumTest(convert("foo %hX"), pos, convert("foo 34AB")); - DoNumTest(convert("foo %LX"), pos, convert("foo 1234AB")); - DoI64NumTest(convert("foo %I64X"), l, "0x1234567887654321", - convert("foo 1234567887654321")); - DoNumTest(convert("foo %7X"), pos, convert("foo 1234AB")); - DoNumTest(convert("foo %-7X"), pos, convert("foo 1234AB ")); - DoNumTest(convert("foo %.1X"), pos, convert("foo 1234AB")); - DoNumTest(convert("foo %.7X"), pos, convert("foo 01234AB")); - DoNumTest(convert("foo %07X"), pos, convert("foo 01234AB")); - DoNumTest(convert("foo %#X"), pos, convert("foo 0X1234AB")); - DoNumTest(convert("foo %+X"), pos, convert("foo 1234AB")); - DoNumTest(convert("foo % X"), pos, convert("foo 1234AB")); - DoNumTest(convert("foo %+X"), neg, convert("foo FFFFFFD6")); - DoNumTest(convert("foo % X"), neg, convert("foo FFFFFFD6")); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test13/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test13/testinfo.dat deleted file mode 100644 index 94479d527..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test13/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = _vsnwprintf_s -Name = Positive Test for _vsnwprintf_s -TYPE = DEFAULT -EXE1 = test13 -Description -= Tests the PAL implementation of the _vsnwprintf_s function. -= Tests _vsnwprintf_s with hex numbers (uppercase). -= This test is modeled after _snwprintf. diff --git a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test14/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test14/CMakeLists.txt deleted file mode 100644 index 6e0a35e8b..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test14/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test14.cpp -) - -add_executable(paltest_vsnwprintf_test14 - ${SOURCES} -) - -add_dependencies(paltest_vsnwprintf_test14 coreclrpal) - -target_link_libraries(paltest_vsnwprintf_test14 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test14/test14.cpp b/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test14/test14.cpp deleted file mode 100644 index cab1b247d..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test14/test14.cpp +++ /dev/null @@ -1,63 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test14.c -** -** Purpose: Test #14 for the _vsnwprintf_s function. -** -** -**===================================================================*/ - -#include -#include "../_vsnwprintf_s.h" - -/* memcmp is used to verify the results, so this test is dependent on it. */ -/* ditto with wcslen */ - -int __cdecl main(int argc, char *argv[]) -{ - double val = 256.0; - double neg = -256.0; - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoDoubleTest(convert("foo %e"), val, convert("foo 2.560000e+002"), - convert("foo 2.560000e+02")); - DoDoubleTest(convert("foo %le"), val, convert("foo 2.560000e+002"), - convert("foo 2.560000e+02")); - DoDoubleTest(convert("foo %he"), val, convert("foo 2.560000e+002"), - convert("foo 2.560000e+02")); - DoDoubleTest(convert("foo %Le"), val, convert("foo 2.560000e+002"), - convert("foo 2.560000e+02")); - DoDoubleTest(convert("foo %I64e"), val, convert("foo 2.560000e+002"), - convert("foo 2.560000e+02")); - DoDoubleTest(convert("foo %14e"), val, convert("foo 2.560000e+002"), - convert("foo 2.560000e+02")); - DoDoubleTest(convert("foo %-14e"), val, convert("foo 2.560000e+002 "), - convert("foo 2.560000e+02 ")); - DoDoubleTest(convert("foo %.1e"), val, convert("foo 2.6e+002"), - convert("foo 2.6e+02")); - DoDoubleTest(convert("foo %.8e"), val, convert("foo 2.56000000e+002"), - convert("foo 2.56000000e+02")); - DoDoubleTest(convert("foo %014e"), val, convert("foo 02.560000e+002"), - convert("foo 002.560000e+02")); - DoDoubleTest(convert("foo %#e"), val, convert("foo 2.560000e+002"), - convert("foo 2.560000e+02")); - DoDoubleTest(convert("foo %+e"), val, convert("foo +2.560000e+002"), - convert("foo +2.560000e+02")); - DoDoubleTest(convert("foo % e"), val, convert("foo 2.560000e+002"), - convert("foo 2.560000e+02")); - DoDoubleTest(convert("foo %+e"), neg, convert("foo -2.560000e+002"), - convert("foo -2.560000e+02")); - DoDoubleTest(convert("foo % e"), neg, convert("foo -2.560000e+002"), - convert("foo -2.560000e+02")); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test14/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test14/testinfo.dat deleted file mode 100644 index 0d46d9764..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test14/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = _vsnwprintf_s -Name = Positive Test for _vsnwprintf_s -TYPE = DEFAULT -EXE1 = test14 -Description -= Tests the PAL implementation of the _vsnwprintf_s function. -= Tests _vsnwprintf_s with exponential format doubles (lowercase). -= This test is modeled after _snwprintf. diff --git a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test15/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test15/CMakeLists.txt deleted file mode 100644 index f13b1f28b..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test15/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test15.cpp -) - -add_executable(paltest_vsnwprintf_test15 - ${SOURCES} -) - -add_dependencies(paltest_vsnwprintf_test15 coreclrpal) - -target_link_libraries(paltest_vsnwprintf_test15 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test15/test15.cpp b/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test15/test15.cpp deleted file mode 100644 index d5738991a..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test15/test15.cpp +++ /dev/null @@ -1,64 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test15.c -** -** Purpose: Test #15 for the _vsnwprintf_s function. -** -** -**===================================================================*/ - -#include -#include "../_vsnwprintf_s.h" - -/* memcmp is used to verify the results, so this test is dependent on it. */ -/* ditto with wcslen */ - - -int __cdecl main(int argc, char *argv[]) -{ - double val = 256.0; - double neg = -256.0; - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoDoubleTest(convert("foo %E"), val, convert("foo 2.560000E+002"), - convert("foo 2.560000E+02")); - DoDoubleTest(convert("foo %lE"), val, convert("foo 2.560000E+002"), - convert("foo 2.560000E+02")); - DoDoubleTest(convert("foo %hE"), val, convert("foo 2.560000E+002"), - convert("foo 2.560000E+02")); - DoDoubleTest(convert("foo %LE"), val, convert("foo 2.560000E+002"), - convert("foo 2.560000E+02")); - DoDoubleTest(convert("foo %I64E"), val, convert("foo 2.560000E+002"), - convert("foo 2.560000E+02")); - DoDoubleTest(convert("foo %14E"), val, convert("foo 2.560000E+002"), - convert("foo 2.560000E+02")); - DoDoubleTest(convert("foo %-14E"), val, convert("foo 2.560000E+002 "), - convert("foo 2.560000E+02 ")); - DoDoubleTest(convert("foo %.1E"), val, convert("foo 2.6E+002"), - convert("foo 2.6E+02")); - DoDoubleTest(convert("foo %.8E"), val, convert("foo 2.56000000E+002"), - convert("foo 2.56000000E+02")); - DoDoubleTest(convert("foo %014E"), val, convert("foo 02.560000E+002"), - convert("foo 002.560000E+02")); - DoDoubleTest(convert("foo %#E"), val, convert("foo 2.560000E+002"), - convert("foo 2.560000E+02")); - DoDoubleTest(convert("foo %+E"), val, convert("foo +2.560000E+002"), - convert("foo +2.560000E+02")); - DoDoubleTest(convert("foo % E"), val, convert("foo 2.560000E+002"), - convert("foo 2.560000E+02")); - DoDoubleTest(convert("foo %+E"), neg, convert("foo -2.560000E+002"), - convert("foo -2.560000E+02")); - DoDoubleTest(convert("foo % E"), neg, convert("foo -2.560000E+002"), - convert("foo -2.560000E+002")); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test15/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test15/testinfo.dat deleted file mode 100644 index 7737f49a3..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test15/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = _vsnwprintf_s -Name = Positive Test for _vsnwprintf_s -TYPE = DEFAULT -EXE1 = test15 -Description -= Tests the PAL implementation of the _vsnwprintf_s function. -= Tests _vsnwprintf_s with exponential format doubles (uppercase). -= This test is modeled after _snwprintf. diff --git a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test16/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test16/CMakeLists.txt deleted file mode 100644 index 2b45d4c77..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test16/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test16.cpp -) - -add_executable(paltest_vsnwprintf_test16 - ${SOURCES} -) - -add_dependencies(paltest_vsnwprintf_test16 coreclrpal) - -target_link_libraries(paltest_vsnwprintf_test16 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test16/test16.cpp b/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test16/test16.cpp deleted file mode 100644 index 72c546eb6..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test16/test16.cpp +++ /dev/null @@ -1,63 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test16.c -** -** Purpose: Test #16 for the _vsnwprintf_s function. -** -** -**===================================================================*/ - -#include -#include "../_vsnwprintf_s.h" - -/* memcmp is used to verify the results, so this test is dependent on it. */ -/* ditto with wcslen */ - -int __cdecl main(int argc, char *argv[]) -{ - double val = 2560.001; - double neg = -2560.001; - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoDoubleTest(convert("foo %f"), val, convert("foo 2560.001000"), - convert("foo 2560.001000")); - DoDoubleTest(convert("foo %lf"), val, convert("foo 2560.001000"), - convert("foo 2560.001000")); - DoDoubleTest(convert("foo %hf"), val, convert("foo 2560.001000"), - convert("foo 2560.001000")); - DoDoubleTest(convert("foo %Lf"), val, convert("foo 2560.001000"), - convert("foo 2560.001000")); - DoDoubleTest(convert("foo %I64f"), val, convert("foo 2560.001000"), - convert("foo 2560.001000")); - DoDoubleTest(convert("foo %12f"), val, convert("foo 2560.001000"), - convert("foo 2560.001000")); - DoDoubleTest(convert("foo %-12f"), val, convert("foo 2560.001000 "), - convert("foo 2560.001000 ")); - DoDoubleTest(convert("foo %.1f"), val, convert("foo 2560.0"), - convert("foo 2560.0")); - DoDoubleTest(convert("foo %.8f"), val, convert("foo 2560.00100000"), - convert("foo 2560.00100000")); - DoDoubleTest(convert("foo %012f"), val, convert("foo 02560.001000"), - convert("foo 02560.001000")); - DoDoubleTest(convert("foo %#f"), val, convert("foo 2560.001000"), - convert("foo 2560.001000")); - DoDoubleTest(convert("foo %+f"), val, convert("foo +2560.001000"), - convert("foo +2560.001000")); - DoDoubleTest(convert("foo % f"), val, convert("foo 2560.001000"), - convert("foo 2560.001000")); - DoDoubleTest(convert("foo %+f"), neg, convert("foo -2560.001000"), - convert("foo -2560.001000")); - DoDoubleTest(convert("foo % f"), neg, convert("foo -2560.001000"), - convert("foo -2560.001000")); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test16/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test16/testinfo.dat deleted file mode 100644 index 9aec1c008..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test16/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = _vsnwprintf_s -Name = Positive Test for _vsnwprintf_s -TYPE = DEFAULT -EXE1 = test16 -Description -= Tests the PAL implementation of the _vsnwprintf_s function. -= Tests _vsnwprintf_s with decimal point format doubles. -= This test is modeled after _snwprintf. diff --git a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test17/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test17/CMakeLists.txt deleted file mode 100644 index a4cc151d5..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test17/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test17.cpp -) - -add_executable(paltest_vsnwprintf_test17 - ${SOURCES} -) - -add_dependencies(paltest_vsnwprintf_test17 coreclrpal) - -target_link_libraries(paltest_vsnwprintf_test17 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test17/test17.cpp b/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test17/test17.cpp deleted file mode 100644 index e6860b930..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test17/test17.cpp +++ /dev/null @@ -1,65 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test17.c -** -** Purpose: Test #17 for the _vsnwprintf_s function. -** -** -**===================================================================*/ - -#include -#include "../_vsnwprintf_s.h" - -/* memcmp is used to verify the results, so this test is dependent on it. */ -/* ditto with wcslen */ - -int __cdecl main(int argc, char *argv[]) -{ - double val = 2560.001; - double neg = -2560.001; - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoDoubleTest(convert("foo %g"), val, convert("foo 2560"), - convert("foo 2560")); - DoDoubleTest(convert("foo %lg"), val, convert("foo 2560"), - convert("foo 2560")); - DoDoubleTest(convert("foo %hg"), val, convert("foo 2560"), - convert("foo 2560")); - DoDoubleTest(convert("foo %Lg"), val, convert("foo 2560"), - convert("foo 2560")); - DoDoubleTest(convert("foo %I64g"), val, convert("foo 2560"), - convert("foo 2560")); - DoDoubleTest(convert("foo %5g"), val, convert("foo 2560"), - convert("foo 2560")); - DoDoubleTest(convert("foo %-5g"), val, convert("foo 2560 "), - convert("foo 2560 ")); - DoDoubleTest(convert("foo %.1g"), val, convert("foo 3e+003"), - convert("foo 3e+03")); - DoDoubleTest(convert("foo %.2g"), val, convert("foo 2.6e+003"), - convert("foo 2.6e+03")); - DoDoubleTest(convert("foo %.12g"), val, convert("foo 2560.001"), - convert("foo 2560.001")); - DoDoubleTest(convert("foo %06g"), val, convert("foo 002560"), - convert("foo 002560")); - DoDoubleTest(convert("foo %#g"), val, convert("foo 2560.00"), - convert("foo 2560.00")); - DoDoubleTest(convert("foo %+g"), val, convert("foo +2560"), - convert("foo +2560")); - DoDoubleTest(convert("foo % g"), val, convert("foo 2560"), - convert("foo 2560")); - DoDoubleTest(convert("foo %+g"), neg, convert("foo -2560"), - convert("foo -2560")); - DoDoubleTest(convert("foo % g"), neg, convert("foo -2560"), - convert("foo -2560")); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test17/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test17/testinfo.dat deleted file mode 100644 index 1487b7a17..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test17/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = _vsnwprintf_s -Name = Positive Test for _vsnwprintf_s -TYPE = DEFAULT -EXE1 = test17 -Description -= Tests the PAL implementation of the _vsnwprintf_s function. -= Tests _vsnwprintf_s with compact format doubles (lowercase). -= This test is modeled after _snwprintf. diff --git a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test18/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test18/CMakeLists.txt deleted file mode 100644 index 9bf17f3e3..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test18/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test18.cpp -) - -add_executable(paltest_vsnwprintf_test18 - ${SOURCES} -) - -add_dependencies(paltest_vsnwprintf_test18 coreclrpal) - -target_link_libraries(paltest_vsnwprintf_test18 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test18/test18.cpp b/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test18/test18.cpp deleted file mode 100644 index a164edbc0..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test18/test18.cpp +++ /dev/null @@ -1,65 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test18.c -** -** Purpose: Test #18 for the _vsnwprintf_s function. -** -** -**===================================================================*/ - -#include -#include "../_vsnwprintf_s.h" - -/* memcmp is used to verify the results, so this test is dependent on it. */ -/* ditto with wcslen */ - -int __cdecl main(int argc, char *argv[]) -{ - double val = 2560.001; - double neg = -2560.001; - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoDoubleTest(convert("foo %G"), val, convert("foo 2560"), - convert("foo 2560")); - DoDoubleTest(convert("foo %lG"), val, convert("foo 2560"), - convert("foo 2560")); - DoDoubleTest(convert("foo %hG"), val, convert("foo 2560"), - convert("foo 2560")); - DoDoubleTest(convert("foo %LG"), val, convert("foo 2560"), - convert("foo 2560")); - DoDoubleTest(convert("foo %I64G"), val, convert("foo 2560"), - convert("foo 2560")); - DoDoubleTest(convert("foo %5G"), val, convert("foo 2560"), - convert("foo 2560")); - DoDoubleTest(convert("foo %-5G"), val, convert("foo 2560 "), - convert("foo 2560 ")); - DoDoubleTest(convert("foo %.1G"), val, convert("foo 3E+003"), - convert("foo 3E+03")); - DoDoubleTest(convert("foo %.2G"), val, convert("foo 2.6E+003"), - convert("foo 2.6E+03")); - DoDoubleTest(convert("foo %.12G"), val, convert("foo 2560.001"), - convert("foo 2560.001")); - DoDoubleTest(convert("foo %06G"), val, convert("foo 002560"), - convert("foo 002560")); - DoDoubleTest(convert("foo %#G"), val, convert("foo 2560.00"), - convert("foo 2560.00")); - DoDoubleTest(convert("foo %+G"), val, convert("foo +2560"), - convert("foo +2560")); - DoDoubleTest(convert("foo % G"), val, convert("foo 2560"), - convert("foo 2560")); - DoDoubleTest(convert("foo %+G"), neg, convert("foo -2560"), - convert("foo -2560")); - DoDoubleTest(convert("foo % G"), neg, convert("foo -2560"), - convert("foo -2560")); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test18/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test18/testinfo.dat deleted file mode 100644 index 54c4e87c8..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test18/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = _vsnwprintf_s -Name = Positive Test for _vsnwprintf_s -TYPE = DEFAULT -EXE1 = test18 -Description -= Tests the PAL implementation of the _vsnwprintf_s function. -= Tests _vsnwprintf_s with compact format doubles (uppercase). -= This test is modeled after _snwprintf. diff --git a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test19/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test19/CMakeLists.txt deleted file mode 100644 index 7f95eb142..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test19/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test19.cpp -) - -add_executable(paltest_vsnwprintf_test19 - ${SOURCES} -) - -add_dependencies(paltest_vsnwprintf_test19 coreclrpal) - -target_link_libraries(paltest_vsnwprintf_test19 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test19/test19.cpp b/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test19/test19.cpp deleted file mode 100644 index c2a85478a..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test19/test19.cpp +++ /dev/null @@ -1,139 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test18.c -** -** Purpose: Test #18 for the _vsnwprintf_s function. -** -** -**===================================================================*/ - -#include -#include "../_vsnwprintf_s.h" - -/* memcmp is used to verify the results, so this test is dependent on it. */ -/* ditto with wcslen */ - -#define DOTEST(a,b,c,d,e) DoTest(a,b,(void*)c,d,e) - -void DoArgumentPrecTest(WCHAR *formatstr, int precision, void *param, - WCHAR *paramstr, WCHAR *checkstr1, WCHAR *checkstr2) -{ - WCHAR buf[256]; - - TestVsnwprintf_s(buf, 256, formatstr, precision, param); - if (memcmp(buf, checkstr1, wcslen(checkstr1) + 2) != 0 && - memcmp(buf, checkstr2, wcslen(checkstr2) + 2) != 0) - { - Fail("ERROR: failed to insert %s into \"%s\" with precision %d\n" - "Expected \"%s\" or \"%s\", got \"%s\".\n", - paramstr, - convertC(formatstr), - precision, - convertC(checkstr1), - convertC(checkstr2), - convertC(buf)); - } -} -void DoArgumentPrecDoubleTest(WCHAR *formatstr, int precision, double param, - WCHAR *checkstr1, WCHAR *checkstr2) -{ - WCHAR buf[256]; - - TestVsnwprintf_s(buf, 256, formatstr, precision, param); - if (memcmp(buf, checkstr1, wcslen(checkstr1) + 2) != 0 && - memcmp(buf, checkstr2, wcslen(checkstr2) + 2) != 0) - { - Fail("ERROR: failed to insert %f into \"%s\" with precision %d\n" - "Expected \"%s\" or \"%s\", got \"%s\".\n", - param, convertC(formatstr), - precision, - convertC(checkstr1), - convertC(checkstr2), - convertC(buf)); - } -} - -/* - * Uses memcmp & wcslen - */ - -int __cdecl main(int argc, char *argv[]) -{ - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoArgumentPrecTest(convert("%.*s"), 2, (void*)convert("bar"), convert("bar"), - convert("ba"), convert("ba")); - DoArgumentPrecTest(convert("%.*c"), 0, (void*)'a', convert("a"), - convert("a"), convert("a")); - DoArgumentPrecTest(convert("%.*c"), 4, (void*)'a', convert("a"), - convert("a"), convert("a")); - DoArgumentPrecTest(convert("%.*C"), 0, (void*)'a', convert("a"), - convert("a"), convert("a")); - DoArgumentPrecTest(convert("%.*C"), 4, (void*)'a', convert("a"), - convert("a"), convert("a")); - DoArgumentPrecTest(convert("%.*d"), 1, (void*)42, convert("42"), - convert("42"), convert("42")); - DoArgumentPrecTest(convert("%.*d"), 3, (void*)42, convert("42"), - convert("042"), convert("042")); - DoArgumentPrecTest(convert("%.*i"), 1, (void*)42, convert("42"), - convert("42"), convert("42")); - DoArgumentPrecTest(convert("%.*i"), 3, (void*)42, convert("42"), - convert("042"), convert("042")); - DoArgumentPrecTest(convert("%.*o"), 1, (void*)42, convert("42"), - convert("52"), convert("52")); - DoArgumentPrecTest(convert("%.*o"), 3, (void*)42, convert("42"), - convert("052"), convert("052")); - DoArgumentPrecTest(convert("%.*u"), 1, (void*)42, convert("42"), - convert("42"), convert("42")); - DoArgumentPrecTest(convert("%.*u"), 3, (void*)42, convert("42"), - convert("042"), convert("042")); - DoArgumentPrecTest(convert("%.*x"), 1, (void*)0x42, convert("0x42"), - convert("42"), convert("42")); - DoArgumentPrecTest(convert("%.*x"), 3, (void*)0x42, convert("0x42"), - convert("042"), convert("042")); - DoArgumentPrecTest(convert("%.*X"), 1, (void*)0x42, convert("0x42"), - convert("42"), convert("42")); - DoArgumentPrecTest(convert("%.*X"), 3, (void*)0x42, convert("0x42"), - convert("042"), convert("042")); - - - DoArgumentPrecDoubleTest(convert("%.*e"), 1, 2.01, convert("2.0e+000"), - convert("2.0e+00")); - DoArgumentPrecDoubleTest(convert("%.*e"), 3, 2.01, convert("2.010e+000"), - convert("2.010e+00")); - DoArgumentPrecDoubleTest(convert("%.*E"), 1, 2.01, convert("2.0E+000"), - convert("2.0E+00")); - DoArgumentPrecDoubleTest(convert("%.*E"), 3, 2.01, convert("2.010E+000"), - convert("2.010E+00")); - DoArgumentPrecDoubleTest(convert("%.*f"), 1, 2.01, convert("2.0"), - convert("2.0")); - DoArgumentPrecDoubleTest(convert("%.*f"), 3, 2.01, convert("2.010"), - convert("2.010")); - DoArgumentPrecDoubleTest(convert("%.*g"), 1, 256.01, convert("3e+002"), - convert("3e+02")); - DoArgumentPrecDoubleTest(convert("%.*g"), 3, 256.01, convert("256"), - convert("256")); - DoArgumentPrecDoubleTest(convert("%.*g"), 4, 256.01, convert("256"), - convert("256")); - DoArgumentPrecDoubleTest(convert("%.*g"), 6, 256.01, convert("256.01"), - convert("256.01")); - DoArgumentPrecDoubleTest(convert("%.*G"), 1, 256.01, convert("3E+002"), - convert("3E+02")); - DoArgumentPrecDoubleTest(convert("%.*G"), 3, 256.01, convert("256"), - convert("256")); - DoArgumentPrecDoubleTest(convert("%.*G"), 4, 256.01, convert("256"), - convert("256")); - DoArgumentPrecDoubleTest(convert("%.*G"), 6, 256.01, convert("256.01"), - convert("256.01")); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test19/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test19/testinfo.dat deleted file mode 100644 index 2913e3040..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test19/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = _vsnwprintf_s -Name = Positive Test for _vsnwprintf_s -TYPE = DEFAULT -EXE1 = test19 -Description -= Tests the PAL implementation of the _vsnwprintf_s function. -= Tests _vsnwprintf_s with argument specified precision. -= This test is modeled after _snwprintf. diff --git a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test2/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test2/CMakeLists.txt deleted file mode 100644 index 27231e9de..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test2.cpp -) - -add_executable(paltest_vsnwprintf_test2 - ${SOURCES} -) - -add_dependencies(paltest_vsnwprintf_test2 coreclrpal) - -target_link_libraries(paltest_vsnwprintf_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test2/test2.cpp b/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test2/test2.cpp deleted file mode 100644 index b2958dfa8..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test2/test2.cpp +++ /dev/null @@ -1,46 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test2.c -** -** Purpose: Test #2 for the _vsnwprintf_s function. -** -** -**===================================================================*/ - -#include -#include "../_vsnwprintf_s.h" - -/* memcmp is used to verify the results, so this test is dependent on it. */ -/* ditto with wcslen */ - - -int __cdecl main(int argc, char *argv[]) -{ - if (PAL_Initialize(argc, argv) != 0) - return(FAIL); - - DoWStrTest(convert("foo %s"), convert("bar"), convert("foo bar")); - DoStrTest(convert("foo %hs"), "bar", convert("foo bar")); - DoWStrTest(convert("foo %ls"), convert("bar"), convert("foo bar")); - DoWStrTest(convert("foo %ws"), convert("bar"), convert("foo bar")); - DoWStrTest(convert("foo %Ls"), convert("bar"), convert("foo bar")); - DoWStrTest(convert("foo %I64s"), convert("bar"), convert("foo bar")); - DoWStrTest(convert("foo %5s"), convert("bar"), convert("foo bar")); - DoWStrTest(convert("foo %.2s"), convert("bar"), convert("foo ba")); - DoWStrTest(convert("foo %5.2s"), convert("bar"), convert("foo ba")); - DoWStrTest(convert("foo %-5s"), convert("bar"), convert("foo bar ")); - DoWStrTest(convert("foo %05s"), convert("bar"), convert("foo 00bar")); - DoWStrTest(convert("foo %s"), NULL, convert("foo (null)")); - DoStrTest(convert("foo %hs"), NULL, convert("foo (null)")); - DoWStrTest(convert("foo %ls"), NULL, convert("foo (null)")); - DoWStrTest(convert("foo %ws"), NULL, convert("foo (null)")); - DoWStrTest(convert("foo %Ls"), NULL, convert("foo (null)")); - DoWStrTest(convert("foo %I64s"), NULL, convert("foo (null)")); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test2/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test2/testinfo.dat deleted file mode 100644 index 5b9b6292d..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test2/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = _vsnwprintf_s -Name = Positive Test for _vsnwprintf_s -TYPE = DEFAULT -EXE1 = test2 -Description -= Tests the PAL implementation of the _vsnwprintf_s function. -= Tests _vsnwprintf_s with strings. -= This test is modeled after _snwprintf. diff --git a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test3/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test3/CMakeLists.txt deleted file mode 100644 index 205e5a527..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test3/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test3.cpp -) - -add_executable(paltest_vsnwprintf_test3 - ${SOURCES} -) - -add_dependencies(paltest_vsnwprintf_test3 coreclrpal) - -target_link_libraries(paltest_vsnwprintf_test3 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test3/test3.cpp b/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test3/test3.cpp deleted file mode 100644 index 657a911b5..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test3/test3.cpp +++ /dev/null @@ -1,46 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test3.c -** -** Purpose: Test #3 for the _vsnwprintf_s function. -** -** -**===================================================================*/ - -#include -#include "../_vsnwprintf_s.h" - -/* memcmp is used to verify the results, so this test is dependent on it. */ -/* ditto with wcslen */ - - -int __cdecl main(int argc, char *argv[]) -{ - if (PAL_Initialize(argc, argv) != 0) - return(FAIL); - - DoStrTest(convert("foo %S"), "bar", convert("foo bar")); - DoStrTest(convert("foo %hS"), "bar", convert("foo bar")); - DoWStrTest(convert("foo %lS"), convert("bar"), convert("foo bar")); - DoWStrTest(convert("foo %wS"), convert("bar"), convert("foo bar")); - DoStrTest(convert("foo %LS"), "bar", convert("foo bar")); - DoStrTest(convert("foo %I64S"), "bar", convert("foo bar")); - DoStrTest(convert("foo %5S"), "bar", convert("foo bar")); - DoStrTest(convert("foo %.2S"), "bar", convert("foo ba")); - DoStrTest(convert("foo %5.2S"), "bar", convert("foo ba")); - DoStrTest(convert("foo %-5S"), "bar", convert("foo bar ")); - DoStrTest(convert("foo %05S"), "bar", convert("foo 00bar")); - DoStrTest(convert("foo %S"), NULL, convert("foo (null)")); - DoStrTest(convert("foo %hS"), NULL, convert("foo (null)")); - DoWStrTest(convert("foo %lS"), NULL, convert("foo (null)")); - DoWStrTest(convert("foo %wS"), NULL, convert("foo (null)")); - DoStrTest(convert("foo %LS"), NULL, convert("foo (null)")); - DoStrTest(convert("foo %I64S"), NULL, convert("foo (null)")); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test3/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test3/testinfo.dat deleted file mode 100644 index 62160695e..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test3/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = _vsnwprintf_s -Name = Positive Test for _vsnwprintf_s -TYPE = DEFAULT -EXE1 = test3 -Description -= Tests the PAL implementation of the _vsnwprintf_s function. -= Tests _vsnwprintf_s with wide strings. -= This test is modeled after _snwprintf. diff --git a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test4/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test4/CMakeLists.txt deleted file mode 100644 index fd2666e97..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test4/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test4.cpp -) - -add_executable(paltest_vsnwprintf_test4 - ${SOURCES} -) - -add_dependencies(paltest_vsnwprintf_test4 coreclrpal) - -target_link_libraries(paltest_vsnwprintf_test4 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test4/test4.cpp b/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test4/test4.cpp deleted file mode 100644 index 006e154f7..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test4/test4.cpp +++ /dev/null @@ -1,121 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test4.c -** -** Purpose: Test #4 for the _vsnwprintf_s function. -** -** -**===================================================================*/ - -#include -#include "../_vsnwprintf_s.h" - -/* memcmp is used to verify the results, so this test is dependent on it. */ -/* ditto with wcslen */ -static void DoPointerTest(WCHAR *formatstr, void* param, WCHAR* paramstr, - WCHAR *checkstr1) -{ - WCHAR buf[256] = { 0 }; - - TestVsnwprintf_s(buf, 256, formatstr, param); - if (memcmp(buf, checkstr1, wcslen(checkstr1) + 2) != 0) - - { - Fail("ERROR: failed to insert pointer to %#p into \"%s\"\n" - "Expected \"%s\" got \"%s\".\n", - paramstr, - convertC(formatstr), - convertC(checkstr1), - convertC(buf)); - } -} - -static void DoI64DoubleTest(WCHAR *formatstr, INT64 value, WCHAR *valuestr, - WCHAR *checkstr1) -{ - WCHAR buf[256] = { 0 }; - - TestVsnwprintf_s(buf, 256, formatstr, value); - if (memcmp(buf, checkstr1, wcslen(checkstr1) + 2) != 0) - { - Fail("ERROR: failed to insert %s into \"%s\"\n" - "Expected \"%s\", got \"%s\".\n", - value, - convertC(formatstr), - convertC(checkstr1), - convertC(buf)); - } -} - -int __cdecl main(int argc, char *argv[]) -{ - void *ptr = (void*) 0x123456; - INT64 lptr = I64(0x1234567887654321); - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - -/* -** Run only on 64 bit platforms -*/ -#if defined(BIT64) - Trace("Testing for 64 Bit Platforms \n"); - DoPointerTest(convert("%p"), NULL, convert("NULL"), convert("00000000")); - DoPointerTest(convert("%p"), ptr, convert("pointer to 0x123456"), - convert("0000000000123456")); - DoPointerTest(convert("%17p"), ptr, convert("pointer to 0x123456"), - convert(" 0000000000123456")); - DoPointerTest(convert("%17p"), ptr, convert("pointer to 0x123456"), - convert(" 0000000000123456")); - DoPointerTest(convert("%-17p"), ptr, convert("pointer to 0x123456"), - convert("0000000000123456 ")); - DoPointerTest(convert("%+p"), ptr, convert("pointer to 0x123456"), - convert("0000000000123456")); - DoPointerTest(convert("%#p"), ptr, convert("pointer to 0x123456"), - convert("0X0000000000123456")); - DoPointerTest(convert("%lp"), ptr, convert("pointer to 0x123456"), - convert("00123456")); - DoPointerTest(convert("%hp"), ptr, convert("pointer to 0x123456"), - convert("00003456")); - DoPointerTest(convert("%Lp"), ptr, convert("pointer to 0x123456"), - convert("00123456")); - DoI64DoubleTest(convert("%I64p"), lptr, - convert("pointer to 0x1234567887654321"), - convert("1234567887654321")); - -#else - Trace("Testing for Non 64 Bit Platforms \n"); - DoPointerTest(convert("%p"), NULL, convert("NULL"), convert("00000000")); - DoPointerTest(convert("%p"), ptr, convert("pointer to 0x123456"), - convert("00123456")); - DoPointerTest(convert("%9p"), ptr, convert("pointer to 0x123456"), - convert(" 00123456")); - DoPointerTest(convert("%09p"), ptr, convert("pointer to 0x123456"), - convert(" 00123456")); - DoPointerTest(convert("%-9p"), ptr, convert("pointer to 0x123456"), - convert("00123456 ")); - DoPointerTest(convert("%+p"), ptr, convert("pointer to 0x123456"), - convert("00123456")); - DoPointerTest(convert("%#p"), ptr, convert("pointer to 0x123456"), - convert("0X00123456")); - DoPointerTest(convert("%lp"), ptr, convert("pointer to 0x123456"), - convert("00123456")); - DoPointerTest(convert("%hp"), ptr, convert("pointer to 0x123456"), - convert("00003456")); - DoPointerTest(convert("%Lp"), ptr, convert("pointer to 0x123456"), - convert("00123456")); - DoI64DoubleTest(convert("%I64p"), lptr, - convert("pointer to 0x1234567887654321"), - convert("1234567887654321")); -#endif - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test4/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test4/testinfo.dat deleted file mode 100644 index 9fbfcba5c..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test4/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = _vsnwprintf_s -Name = Positive Test for _vsnwprintf_s -TYPE = DEFAULT -EXE1 = test4 -Description -= Tests the PAL implementation of the _vsnwprintf_s function. -= Tests _vsnwprintf_s with pointers. -= This test is modeled after _snwprintf. diff --git a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test6/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test6/CMakeLists.txt deleted file mode 100644 index 1ff12213f..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test6/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test6.cpp -) - -add_executable(paltest_vsnwprintf_test6 - ${SOURCES} -) - -add_dependencies(paltest_vsnwprintf_test6 coreclrpal) - -target_link_libraries(paltest_vsnwprintf_test6 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test6/test6.cpp b/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test6/test6.cpp deleted file mode 100644 index ecba5853a..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test6/test6.cpp +++ /dev/null @@ -1,43 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test6.c -** -** Purpose: Test #6 for the _vsnwprintf_s function. -** -** -**===================================================================*/ - -#include -#include "../_vsnwprintf_s.h" - -/* memcmp is used to verify the results, so this test is dependent on it. */ -/* ditto with wcslen */ - -int __cdecl main(int argc, char *argv[]) -{ - WCHAR wc = (WCHAR) 'c'; - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoWCharTest(convert("foo %c"), wc, convert("foo c")); - DoCharTest(convert("foo %hc"), 'b', convert("foo b")); - DoWCharTest(convert("foo %lc"), wc, convert("foo c")); - DoWCharTest(convert("foo %Lc"), wc, convert("foo c")); - DoWCharTest(convert("foo %I64c"), wc, convert("foo c")); - DoWCharTest(convert("foo %5c"), wc, convert("foo c")); - DoWCharTest(convert("foo %.0c"), wc, convert("foo c")); - DoWCharTest(convert("foo %-5c"), wc, convert("foo c ")); - DoWCharTest(convert("foo %05c"), wc, convert("foo 0000c")); - DoWCharTest(convert("foo % c"), wc, convert("foo c")); - DoWCharTest(convert("foo %#c"), wc, convert("foo c")); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test6/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test6/testinfo.dat deleted file mode 100644 index 1b411d798..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test6/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = _vsnwprintf_s -Name = Positive Test for _vsnwprintf_s -TYPE = DEFAULT -EXE1 = test6 -Description -= Tests the PAL implementation of the _vsnwprintf_s function. -= Tests _vsnwprintf_s with characters. -= This test is modeled after _snwprintf. diff --git a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test7/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test7/CMakeLists.txt deleted file mode 100644 index fe46de483..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test7/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test7.cpp -) - -add_executable(paltest_vsnwprintf_test7 - ${SOURCES} -) - -add_dependencies(paltest_vsnwprintf_test7 coreclrpal) - -target_link_libraries(paltest_vsnwprintf_test7 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test7/test7.cpp b/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test7/test7.cpp deleted file mode 100644 index 519657a20..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test7/test7.cpp +++ /dev/null @@ -1,43 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test7.c -** -** Purpose: Test #7 for the _vsnwprintf_s function. -** -** -**===================================================================*/ - -#include -#include "../_vsnwprintf_s.h" - -/* memcmp is used to verify the results, so this test is dependent on it. */ -/* ditto with wcslen */ - -int __cdecl main(int argc, char *argv[]) -{ - WCHAR wc = (WCHAR) 'c'; - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoCharTest(convert("foo %C"), 'b', convert("foo b")); - DoWCharTest(convert("foo %hC"), wc, convert("foo c")); - DoCharTest(convert("foo %lC"), 'b', convert("foo b")); - DoCharTest(convert("foo %LC"), 'b', convert("foo b")); - DoCharTest(convert("foo %I64C"), 'b', convert("foo b")); - DoCharTest(convert("foo %5C"), 'b', convert("foo b")); - DoCharTest(convert("foo %.0C"), 'b', convert("foo b")); - DoCharTest(convert("foo %-5C"), 'b', convert("foo b ")); - DoCharTest(convert("foo %05C"), 'b', convert("foo 0000b")); - DoCharTest(convert("foo % C"), 'b', convert("foo b")); - DoCharTest(convert("foo %#C"), 'b', convert("foo b")); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test7/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test7/testinfo.dat deleted file mode 100644 index 8f2ccf0b5..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test7/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = _vsnwprintf_s -Name = Positive Test for _vsnwprintf_s -TYPE = DEFAULT -EXE1 = test7 -Description -= Tests the PAL implementation of the _vsnwprintf_s function. -= Tests _vsnwprintf_s with wide characters. -= This test is modeled after _snwprintf. diff --git a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test8/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test8/CMakeLists.txt deleted file mode 100644 index 7ce0aa81a..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test8/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test8.cpp -) - -add_executable(paltest_vsnwprintf_test8 - ${SOURCES} -) - -add_dependencies(paltest_vsnwprintf_test8 coreclrpal) - -target_link_libraries(paltest_vsnwprintf_test8 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test8/test8.cpp b/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test8/test8.cpp deleted file mode 100644 index 15641f7b9..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test8/test8.cpp +++ /dev/null @@ -1,49 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test8.c -** -** Purpose: Test #8 for the _vsnwprintf_s function. -** -** -**===================================================================*/ - -#include -#include "../_vsnwprintf_s.h" - -/* memcmp is used to verify the results, so this test is dependent on it. */ -/* ditto with wcslen */ - -int __cdecl main(int argc, char *argv[]) -{ - int neg = -42; - int pos = 42; - INT64 l = 42; - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoNumTest(convert("foo %d"), pos, convert("foo 42")); - DoNumTest(convert("foo %ld"), 0xFFFF, convert("foo 65535")); - DoNumTest(convert("foo %hd"), 0xFFFF, convert("foo -1")); - DoNumTest(convert("foo %Ld"), pos, convert("foo 42")); - DoI64NumTest(convert("foo %I64d"), l, "42", convert("foo 42")); - DoNumTest(convert("foo %3d"), pos, convert("foo 42")); - DoNumTest(convert("foo %-3d"), pos, convert("foo 42 ")); - DoNumTest(convert("foo %.1d"), pos, convert("foo 42")); - DoNumTest(convert("foo %.3d"), pos, convert("foo 042")); - DoNumTest(convert("foo %03d"), pos, convert("foo 042")); - DoNumTest(convert("foo %#d"), pos, convert("foo 42")); - DoNumTest(convert("foo %+d"), pos, convert("foo +42")); - DoNumTest(convert("foo % d"), pos, convert("foo 42")); - DoNumTest(convert("foo %+d"), neg, convert("foo -42")); - DoNumTest(convert("foo % d"), neg, convert("foo -42")); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test8/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test8/testinfo.dat deleted file mode 100644 index 905740c1b..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test8/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = _vsnwprintf_s -Name = Positive Test for _vsnwprintf_s -TYPE = DEFAULT -EXE1 = test8 -Description -= Tests the PAL implementation of the _vsnwprintf_s function. -= Tests _vsnwprintf_s with decimal numbers. -= This test is modeled after _snwprintf. diff --git a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test9/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test9/CMakeLists.txt deleted file mode 100644 index 69a9de3a5..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test9/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test9.cpp -) - -add_executable(paltest_vsnwprintf_test9 - ${SOURCES} -) - -add_dependencies(paltest_vsnwprintf_test9 coreclrpal) - -target_link_libraries(paltest_vsnwprintf_test9 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test9/test9.cpp b/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test9/test9.cpp deleted file mode 100644 index 38f6be21e..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test9/test9.cpp +++ /dev/null @@ -1,49 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test9.c -** -** Purpose: Test #9 for the _vsnwprintf_s function. -** -** -**===================================================================*/ - -#include -#include "../_vsnwprintf_s.h" - -/* memcmp is used to verify the results, so this test is dependent on it. */ -/* ditto with wcslen */ - -int __cdecl main(int argc, char *argv[]) -{ - int neg = -42; - int pos = 42; - INT64 l = 42; - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoNumTest(convert("foo %i"), pos, convert("foo 42")); - DoNumTest(convert("foo %li"), 0xFFFF, convert("foo 65535")); - DoNumTest(convert("foo %hi"), 0xFFFF, convert("foo -1")); - DoNumTest(convert("foo %Li"), pos, convert("foo 42")); - DoI64NumTest(convert("foo %I64i"), l, "42", convert("foo 42")); - DoNumTest(convert("foo %3i"), pos, convert("foo 42")); - DoNumTest(convert("foo %-3i"), pos, convert("foo 42 ")); - DoNumTest(convert("foo %.1i"), pos, convert("foo 42")); - DoNumTest(convert("foo %.3i"), pos, convert("foo 042")); - DoNumTest(convert("foo %03i"), pos, convert("foo 042")); - DoNumTest(convert("foo %#i"), pos, convert("foo 42")); - DoNumTest(convert("foo %+i"), pos, convert("foo +42")); - DoNumTest(convert("foo % i"), pos, convert("foo 42")); - DoNumTest(convert("foo %+i"), neg, convert("foo -42")); - DoNumTest(convert("foo % i"), neg, convert("foo -42")); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test9/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test9/testinfo.dat deleted file mode 100644 index 974efdb4c..000000000 --- a/src/pal/tests/palsuite/c_runtime/_vsnwprintf_s/test9/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = _vsnwprintf_s -Name = Positive Test for _vsnwprintf_s -TYPE = DEFAULT -EXE1 = test9 -Description -= Tests the PAL implementation of the _vsnwprintf_s function. -= Tests _vsnwprintf_s with integer numbers -= This test is modeled after _snwprintf. diff --git a/src/pal/tests/palsuite/c_runtime/_wcsicmp/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_wcsicmp/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/c_runtime/_wcsicmp/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/c_runtime/_wcsicmp/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_wcsicmp/test1/CMakeLists.txt deleted file mode 100644 index 1a70e342c..000000000 --- a/src/pal/tests/palsuite/c_runtime/_wcsicmp/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_wcsicmp_test1 - ${SOURCES} -) - -add_dependencies(paltest_wcsicmp_test1 coreclrpal) - -target_link_libraries(paltest_wcsicmp_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_wcsicmp/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/_wcsicmp/test1/test1.cpp deleted file mode 100644 index dd4bb5468..000000000 --- a/src/pal/tests/palsuite/c_runtime/_wcsicmp/test1/test1.cpp +++ /dev/null @@ -1,68 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: Tests that _wcsicmp correctly compares two strings with -** case insensitivity. -** -** -**==========================================================================*/ - -#include - -/* - * Note: The _wcsicmp is dependent on the LC_CTYPE category of the locale, - * and this is ignored by these tests. - */ -int __cdecl main(int argc, char *argv[]) -{ - WCHAR str1[] = {'f','o','o',0}; - WCHAR str2[] = {'f','O','o',0}; - WCHAR str3[] = {'f','o','o','_','b','a','r',0}; - WCHAR str4[] = {'f','o','o','b','a','r',0}; - - /* - * Initialize the PAL and return FAIL if this fails - */ - if (0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - if (_wcsicmp(str1, str2) != 0) - { - Fail ("ERROR: _wcsicmp returning incorrect value:\n" - "_wcsicmp(\"%S\", \"%S\") != 0\n", str1, str2); - } - - if (_wcsicmp(str2, str3) >= 0) - { - Fail ("ERROR: _wcsicmp returning incorrect value:\n" - "_wcsicmp(\"%S\", \"%S\") >= 0\n", str2, str3); - } - - if (_wcsicmp(str3, str4) >= 0) - { - Fail ("ERROR: _wcsicmp returning incorrect value:\n" - "_wcsicmp(\"%S\", \"%S\") >= 0\n", str3, str4); - } - - if (_wcsicmp(str4, str1) <= 0) - { - Fail ("ERROR: _wcsicmp returning incorrect value:\n" - "_wcsicmp(\"%S\", \"%S\") <= 0\n", str4, str1); - } - - if (_wcsicmp(str3, str2) <= 0) - { - Fail ("ERROR: _wcsicmp returning incorrect value:\n" - "_wcsicmp(\"%S\", \"%S\") <= 0\n", str2, str3); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/_wcsicmp/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_wcsicmp/test1/testinfo.dat deleted file mode 100644 index 9351a156e..000000000 --- a/src/pal/tests/palsuite/c_runtime/_wcsicmp/test1/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = _wcsicmp -Name = Test #1 for _wcsicmp -TYPE = DEFAULT -EXE1 = test1 -Description -= Tests that _wcsicmp correctly compares two strings with case insensitivity. diff --git a/src/pal/tests/palsuite/c_runtime/_wcslwr/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_wcslwr/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/c_runtime/_wcslwr/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/c_runtime/_wcslwr/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_wcslwr/test1/CMakeLists.txt deleted file mode 100644 index b10e14ceb..000000000 --- a/src/pal/tests/palsuite/c_runtime/_wcslwr/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_wcslwr_test1 - ${SOURCES} -) - -add_dependencies(paltest_wcslwr_test1 coreclrpal) - -target_link_libraries(paltest_wcslwr_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_wcslwr/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/_wcslwr/test1/test1.cpp deleted file mode 100644 index 3a758de39..000000000 --- a/src/pal/tests/palsuite/c_runtime/_wcslwr/test1/test1.cpp +++ /dev/null @@ -1,50 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: Using memcmp to check the result, convert a wide character string -** with capitals, to all lowercase using this function. Test #1 for the -** wcslwr function -** -** -**==========================================================================*/ - -#include - -/* uses memcmp,wcslen */ - -int __cdecl main(int argc, char *argv[]) -{ - WCHAR *test_str = NULL; - WCHAR *expect_str = NULL; - WCHAR *result_str = NULL; - - /* - * Initialize the PAL and return FAIL if this fails - */ - if (0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - test_str = convert("aSdF 1#"); - expect_str = convert("asdf 1#"); - - result_str = _wcslwr(test_str); - if (memcmp(result_str, expect_str, wcslen(expect_str)*2 + 2) != 0) - { - Fail ("ERROR: Expected to get \"%s\", got \"%s\".\n", - convertC(expect_str), convertC(result_str)); - } - - free(result_str); - free(expect_str); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/c_runtime/_wcslwr/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_wcslwr/test1/testinfo.dat deleted file mode 100644 index 5d691d84d..000000000 --- a/src/pal/tests/palsuite/c_runtime/_wcslwr/test1/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = _wcslwr -Name = Positive Test for _wcslwr -TYPE = DEFAULT -EXE1 = test1 -Description -= Using memcmp to check the result, convert a wide character string -= with capitals, to all lowercase using this function. - diff --git a/src/pal/tests/palsuite/c_runtime/_wcsnicmp/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_wcsnicmp/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/c_runtime/_wcsnicmp/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/c_runtime/_wcsnicmp/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_wcsnicmp/test1/CMakeLists.txt deleted file mode 100644 index 3fa3b3842..000000000 --- a/src/pal/tests/palsuite/c_runtime/_wcsnicmp/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_wcsnicmp_test1 - ${SOURCES} -) - -add_dependencies(paltest_wcsnicmp_test1 coreclrpal) - -target_link_libraries(paltest_wcsnicmp_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_wcsnicmp/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/_wcsnicmp/test1/test1.cpp deleted file mode 100644 index 0271bcc60..000000000 --- a/src/pal/tests/palsuite/c_runtime/_wcsnicmp/test1/test1.cpp +++ /dev/null @@ -1,95 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: Take two wide strings and compare them, giving different lengths. -** Comparing str1 and str2 with str2 length, should return <0 -** Comparing str2 and str1 with str2 length, should return >0 -** Comparing str1 and str2 with str1 lenght, should return 0 -** Bring in str3, which has a capital, but this function is doing a lower -** case compare. Just ensure that two strings which differ only by capitals -** return 0. -** -** -**==========================================================================*/ - -#include - -/* - * Notes: uses wcslen - */ - -int __cdecl main(int argc, char *argv[]) -{ - WCHAR str1[] = {'f','o','o',0}; - WCHAR str2[] = {'f','o','o','x',0}; - WCHAR str3[] = {'f','O','o',0}; - WCHAR str4[] = {'A','B','C','D','E',0}; - WCHAR str5[] = {'A','B','C','D',']',0}; - WCHAR str6[] = {'a','b','c','d','e',0}; - WCHAR str7[] = {'a','b','c','d',']',0}; - char cstr1[] = "foo"; - char cstr2[] = "foox"; - char cstr3[] = "fOo"; - char cstr4[] = "ABCDE"; - char cstr5[] = "ABCD]"; - char cstr6[] = "abcde"; - char cstr7[] = "abcd]"; - - - /* - * Initialize the PAL and return FAIL if this fails - */ - if (0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - if (_wcsnicmp(str1, str2, wcslen(str2)) >= 0) - { - Fail ("ERROR: wcsnicmp(\"%s\", \"%s\", %d) returned >= 0\n", cstr1, - cstr2, wcslen(str2)); - } - - if (_wcsnicmp(str2, str1, wcslen(str2)) <= 0) - { - Fail ("ERROR: wcsnicmp(\"%s\", \"%s\", %d) returned <= 0\n", cstr2, - cstr1, wcslen(str2)); - } - - if (_wcsnicmp(str1, str2, wcslen(str1)) != 0) - { - Fail ("ERROR: wcsnicmp(\"%s\", \"%s\", %d) returned != 0\n", cstr1, - cstr2, wcslen(str1)); - } - - if (_wcsnicmp(str1, str3, wcslen(str1)) != 0) - { - Fail ("ERROR: wcsnicmp(\"%s\", \"%s\", %d) returned != 0\n", cstr1, - cstr3, wcslen(str1)); - } - - /* new testing */ - - /* str4 should be greater than str5 */ - if (_wcsnicmp(str4, str5, wcslen(str4)) <= 0) - { - Fail ("ERROR: _wcsnicmp(\"%s\", \"%s\", %d) returned >= 0\n", - cstr4, cstr5, wcslen(str4)); - } - - /* str6 should be greater than str7 */ - if (_wcsnicmp(str6, str7, wcslen(str6)) <= 0) - { - Fail ("ERROR: _wcsnicmp(\"%s\", \"%s\", %d) returned <= 0\n", - cstr6, cstr7, wcslen(str6)); - } - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/c_runtime/_wcsnicmp/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_wcsnicmp/test1/testinfo.dat deleted file mode 100644 index df49cc1a9..000000000 --- a/src/pal/tests/palsuite/c_runtime/_wcsnicmp/test1/testinfo.dat +++ /dev/null @@ -1,18 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = _wcsnicmp -Name = Positive Test for _wcsnicmp -TYPE = DEFAULT -EXE1 = test1 -Description -= Take two wide strings and compare them, giving different lengths. -= Comparing str1 and str2 with str2 length, should return <0 -= Comparing str2 and str1 with str2 length, should return >0 -= Comparing str1 and str2 with str1 lenght, should return 0 -= Bring in str3, which has a capital, but this function is doing a lower -= case compare. Just ensure that two strings which differ only by capitals -= return 0. diff --git a/src/pal/tests/palsuite/c_runtime/_wfopen/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_wfopen/CMakeLists.txt deleted file mode 100644 index 19ee487a6..000000000 --- a/src/pal/tests/palsuite/c_runtime/_wfopen/CMakeLists.txt +++ /dev/null @@ -1,10 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) -add_subdirectory(test3) -add_subdirectory(test4) -add_subdirectory(test5) -add_subdirectory(test6) -add_subdirectory(test7) - diff --git a/src/pal/tests/palsuite/c_runtime/_wfopen/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_wfopen/test1/CMakeLists.txt deleted file mode 100644 index 35498c0ec..000000000 --- a/src/pal/tests/palsuite/c_runtime/_wfopen/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_wfopen_test1 - ${SOURCES} -) - -add_dependencies(paltest_wfopen_test1 coreclrpal) - -target_link_libraries(paltest_wfopen_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_wfopen/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/_wfopen/test1/test1.cpp deleted file mode 100644 index 81d2502cd..000000000 --- a/src/pal/tests/palsuite/c_runtime/_wfopen/test1/test1.cpp +++ /dev/null @@ -1,79 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test1.c -** -** Purpose: Tests the PAL implementation of the _wfopen function. -** This test simply attempts to open a number of files with -** different modes. It checks to ensure a valid file -** pointer is returned. It doesn't do any checking to -** ensure the mode is really what it claims. -** - -** -**===================================================================*/ - - -#define UNICODE -#include - -struct testCase -{ - int CorrectResult; - WCHAR mode[20]; -}; - -int __cdecl main(int argc, char **argv) -{ - - FILE *fp; - WCHAR name[128]; - WCHAR base[] = {'t','e','s','t','f','i','l','e','s','\0'}; - char * PrintResult; - int i; - - struct testCase testCases[] = - { - {0, {'r','\0' }}, {1, {'w','\0'}}, {1, {'a','\0'}}, - {0, {'r','+','\0'}}, {1, {'w','+','\0'}}, {1, {'a','+','\0'}}, - {1, {'w','t','\0'}}, {1, {'w','b','\0'}}, {1, {'w','S','\0'}}, - {1, {'w','c','\0'}}, {1, {'w','n','\0'}}, {1, {'w', 'R','\0'}}, - {1, {'w','T','\0'}}, {0, {'t','w','\0'}}, {0, {'.','\0'}} - }; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - - for(i = 0; i < sizeof(testCases) / sizeof(struct testCase); i++) - { - wcscpy(name,base); - wcscat(name,testCases[i].mode); - - fp = _wfopen(name,testCases[i].mode); - - if ((fp == 0 && testCases[i].CorrectResult != 0) || - (testCases[i].CorrectResult == 0 && fp != 0) ) - { - PrintResult = convertC(testCases[i].mode); - Fail("ERROR: fopen returned incorrectly " - "opening a file in %s mode. Perhaps it opened a " - "read only file which didn't exist and returned a correct " - "pointer?",PrintResult); - free(PrintResult); - } - - memset(name, '\0', 128); - } - - PAL_Terminate(); - return PASS; -} - - diff --git a/src/pal/tests/palsuite/c_runtime/_wfopen/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_wfopen/test1/testinfo.dat deleted file mode 100644 index 6514137c2..000000000 --- a/src/pal/tests/palsuite/c_runtime/_wfopen/test1/testinfo.dat +++ /dev/null @@ -1,15 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = _wfopen -Name = Positive Test for _wfopen -TYPE = DEFAULT -EXE1 = test1 -Description -= This test simply attempts to open a number of files with different -= modes. It checks to ensure a valid file pointer is returned. It -= doesn't do any checking to ensure the mode is really what it claims. - diff --git a/src/pal/tests/palsuite/c_runtime/_wfopen/test2/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_wfopen/test2/CMakeLists.txt deleted file mode 100644 index 5a049441b..000000000 --- a/src/pal/tests/palsuite/c_runtime/_wfopen/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test2.cpp -) - -add_executable(paltest_wfopen_test2 - ${SOURCES} -) - -add_dependencies(paltest_wfopen_test2 coreclrpal) - -target_link_libraries(paltest_wfopen_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_wfopen/test2/test2.cpp b/src/pal/tests/palsuite/c_runtime/_wfopen/test2/test2.cpp deleted file mode 100644 index 921ffef19..000000000 --- a/src/pal/tests/palsuite/c_runtime/_wfopen/test2/test2.cpp +++ /dev/null @@ -1,68 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test2.c -** -** Purpose: Tests the PAL implementation of the _wfopen function. -** Test to ensure that you can write to a 'w' mode file. -** And that you can't read from a 'w' mode file. -** -** Depends: -** fprintf -** fseek -** fgets -** - -** -**===================================================================*/ - -#define UNICODE -#include - -int __cdecl main(int argc, char **argv) -{ - - FILE *fp; - char buffer[128]; - WCHAR filename[] = {'t','e','s','t','f','i','l','e','\0'}; - WCHAR write[] = {'w','\0'}; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - if( (fp = _wfopen( filename, write )) == NULL ) - { - Fail( "ERROR: The file failed to open with 'w' mode.\n" ); - } - - /* Test that you can write */ - if(fprintf(fp,"%s","some text") <= 0) - { - Fail("ERROR: Attempted to WRITE to a file opened with 'w' mode " - "but fprintf failed. Either fopen or fprintf have problems."); - } - - if(fseek(fp, 0, SEEK_SET)) - { - Fail("ERROR: fseek failed, and this test depends on it."); - } - - /* Test that you can't read */ - if(fgets(buffer,10,fp) != NULL) - { - Fail("ERROR: Tried to READ from a file with only 'w' mode set. " - "This should fail, but fgets didn't return NULL. " - "Either fgets or fopen is broken."); - } - - PAL_Terminate(); - return PASS; -} - - diff --git a/src/pal/tests/palsuite/c_runtime/_wfopen/test2/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_wfopen/test2/testinfo.dat deleted file mode 100644 index 3ed2e3bbe..000000000 --- a/src/pal/tests/palsuite/c_runtime/_wfopen/test2/testinfo.dat +++ /dev/null @@ -1,15 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = _wfopen -Name = Positive Test for _wfopen -TYPE = DEFAULT -EXE1 = test2 -Description -= Test to ensure that you can write to a 'w' mode file. And that you can't -= read from a 'w' mode file. - - diff --git a/src/pal/tests/palsuite/c_runtime/_wfopen/test3/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_wfopen/test3/CMakeLists.txt deleted file mode 100644 index 1a1656ebf..000000000 --- a/src/pal/tests/palsuite/c_runtime/_wfopen/test3/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test3.cpp -) - -add_executable(paltest_wfopen_test3 - ${SOURCES} -) - -add_dependencies(paltest_wfopen_test3 coreclrpal) - -target_link_libraries(paltest_wfopen_test3 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_wfopen/test3/test3.cpp b/src/pal/tests/palsuite/c_runtime/_wfopen/test3/test3.cpp deleted file mode 100644 index 3b67818bc..000000000 --- a/src/pal/tests/palsuite/c_runtime/_wfopen/test3/test3.cpp +++ /dev/null @@ -1,70 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test3.c -** -** Purpose: Tests the PAL implementation of the _wfopen function. -** Test to ensure that you can write to a 'w+' mode file. -** And that you can read from a 'w+' mode file. -** -** Depends: -** fprintf -** fseek -** fgets -** - -** -**===================================================================*/ - -#define UNICODE - -#include - -int __cdecl main(int argc, char **argv) -{ - - FILE *fp; - char buffer[128]; - WCHAR filename[] = {'t','e','s','t','f','i','l','e','\0'}; - WCHAR writeplus[] = {'w','+','\0'}; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - /* Open a file with 'w+' mode */ - if( (fp = _wfopen( filename, writeplus )) == NULL ) - { - Fail( "ERROR: The file failed to open with 'w+' mode.\n" ); - } - - /* Write some text to the file */ - if(fprintf(fp,"%s","some text") <= 0) - { - Fail("ERROR: Attempted to WRITE to a file opened with 'w+' mode " - "but fprintf failed. Either fopen or fprintf have problems."); - } - - if(fseek(fp, 0, SEEK_SET)) - { - Fail("ERROR: fseek failed, and this test depends on it."); - } - - /* Attempt to read from the 'w+' only file, should pass */ - if(fgets(buffer,10,fp) == NULL) - { - Fail("ERROR: Tried to READ from a file with 'w+' mode set. " - "This should succeed, but fgets returned NULL. Either fgets " - "or fopen is broken."); - } - - PAL_Terminate(); - return PASS; -} - - diff --git a/src/pal/tests/palsuite/c_runtime/_wfopen/test3/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_wfopen/test3/testinfo.dat deleted file mode 100644 index 3dd23e794..000000000 --- a/src/pal/tests/palsuite/c_runtime/_wfopen/test3/testinfo.dat +++ /dev/null @@ -1,15 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = _wfopen -Name = Positive Test for _wfopen -TYPE = DEFAULT -EXE1 = test3 -Description -= Test to ensure that you can write to a 'w+' mode file. And that you can -= read from a 'w+' mode file. - - diff --git a/src/pal/tests/palsuite/c_runtime/_wfopen/test4/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_wfopen/test4/CMakeLists.txt deleted file mode 100644 index bc56cd950..000000000 --- a/src/pal/tests/palsuite/c_runtime/_wfopen/test4/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test4.cpp -) - -add_executable(paltest_wfopen_test4 - ${SOURCES} -) - -add_dependencies(paltest_wfopen_test4 coreclrpal) - -target_link_libraries(paltest_wfopen_test4 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_wfopen/test4/test4.cpp b/src/pal/tests/palsuite/c_runtime/_wfopen/test4/test4.cpp deleted file mode 100644 index 0948fa11c..000000000 --- a/src/pal/tests/palsuite/c_runtime/_wfopen/test4/test4.cpp +++ /dev/null @@ -1,87 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test4.c -** -** Purpose: Tests the PAL implementation of the _wfopen function. -** Test to ensure that you can't write to a 'r' mode file. -** And that you can read from a 'r' mode file. -** -** Depends: -** fprintf -** fclose -** fgets -** - -** -**===================================================================*/ - -#define UNICODE - -#include - -int __cdecl main(int argc, char **argv) -{ - - FILE *fp; - char buffer[128]; - WCHAR filename[] = {'t','e','s','t','f','i','l','e','\0'}; - WCHAR write[] = {'w','\0'}; - WCHAR read[] = {'r','\0'}; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - /* Open a file with 'w' mode */ - if( (fp = _wfopen( filename, write )) == NULL ) - { - Fail( "ERROR: The file failed to open with 'w' mode.\n" ); - } - - /* Write some text to the file */ - if(fprintf(fp,"%s","some text") <= 0) - { - Fail("ERROR: Attempted to WRITE to a file opened with 'w' mode " - "but fprintf failed. Either fopen or fprintf have problems."); - } - - if(fclose(fp)) - { - Fail("ERROR: Attempted to close a file, but fclose failed. " - "This test depends upon it."); - } - - /* Open a file with 'r' mode */ - if( (fp = _wfopen( filename, read )) == NULL ) - { - Fail( "ERROR: The file failed to open with 'r' mode.\n" ); - } - - /* Attempt to read from the 'r' only file, should pass */ - if(fgets(buffer,10,fp) == NULL) - { - Fail("ERROR: Tried to READ from a file with 'r' mode set. " - "This should succeed, but fgets returned NULL. Either fgets " - "or fopen is broken."); - } - - /* Write some text to the file */ - if(fprintf(fp,"%s","some text") > 0) - { - Fail("ERROR: Attempted to WRITE to a file opened with 'r' mode " - "but fprintf succeeded It should have failed. " - "Either fopen or fprintf have problems."); - } - - - PAL_Terminate(); - return PASS; -} - - diff --git a/src/pal/tests/palsuite/c_runtime/_wfopen/test4/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_wfopen/test4/testinfo.dat deleted file mode 100644 index de41d7731..000000000 --- a/src/pal/tests/palsuite/c_runtime/_wfopen/test4/testinfo.dat +++ /dev/null @@ -1,15 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = _wfopen -Name = Positive Test for _wfopen -TYPE = DEFAULT -EXE1 = test4 -Description -= Test to ensure that you can't write to a 'r' mode file. And that you can -= read from a 'r' mode file. - - diff --git a/src/pal/tests/palsuite/c_runtime/_wfopen/test5/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_wfopen/test5/CMakeLists.txt deleted file mode 100644 index 42caa2059..000000000 --- a/src/pal/tests/palsuite/c_runtime/_wfopen/test5/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test5.cpp -) - -add_executable(paltest_wfopen_test5 - ${SOURCES} -) - -add_dependencies(paltest_wfopen_test5 coreclrpal) - -target_link_libraries(paltest_wfopen_test5 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_wfopen/test5/test5.cpp b/src/pal/tests/palsuite/c_runtime/_wfopen/test5/test5.cpp deleted file mode 100644 index 21e5ec84e..000000000 --- a/src/pal/tests/palsuite/c_runtime/_wfopen/test5/test5.cpp +++ /dev/null @@ -1,82 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test5.c -** -** Purpose: Tests the PAL implementation of the _wfopen function. -** Test to ensure that you can write to a 'r+' mode file. -** And that you can read from a 'r+' mode file. -** -** Depends: -** fprintf -** fclose -** fgets -** fseek -** - -** -**===================================================================*/ -#define UNICODE - -#include - -int __cdecl main(int argc, char **argv) -{ - - FILE *fp; - char buffer[128]; - WCHAR filename[] = {'t','e','s','t','f','i','l','e','\0'}; - WCHAR write[] = {'w','\0'}; - WCHAR readplus[] = {'r','+','\0'}; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - /* Open a file with 'w' mode */ - if( (fp = _wfopen( filename,write )) == NULL ) - { - Fail( "ERROR: The file failed to open with 'w' mode.\n" ); - } - - if(fclose(fp)) - { - Fail("ERROR: Attempted to close a file, but fclose failed. " - "This test depends upon it."); - } - - if( (fp = _wfopen( filename, readplus )) == NULL ) - { - Fail( "ERROR: The file failed to open with 'r+' mode.\n" ); - } - - /* Write some text to the file */ - if(fprintf(fp,"%s","some text") <= 0) - { - Fail("ERROR: Attempted to WRITE to a file opened with 'r+' mode " - "but fprintf failed. Either fopen or fprintf have problems."); - } - - if(fseek(fp, 0, SEEK_SET)) - { - Fail("ERROR: fseek failed, and this test depends on it."); - } - - /* Attempt to read from the 'r+' only file, should pass */ - if(fgets(buffer,10,fp) == NULL) - { - Fail("ERROR: Tried to READ from a file with 'r+' mode set. " - "This should succeed, but fgets returned NULL. Either fgets " - "or fopen is broken."); - } - - PAL_Terminate(); - return PASS; -} - - diff --git a/src/pal/tests/palsuite/c_runtime/_wfopen/test5/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_wfopen/test5/testinfo.dat deleted file mode 100644 index 6be33cb2b..000000000 --- a/src/pal/tests/palsuite/c_runtime/_wfopen/test5/testinfo.dat +++ /dev/null @@ -1,15 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = _wfopen -Name = Positive Test for _wfopen -TYPE = DEFAULT -EXE1 = test5 -Description -= Test to ensure that you can write to a 'r+' mode file. And that you can -= read from a 'r+' mode file. - - diff --git a/src/pal/tests/palsuite/c_runtime/_wfopen/test6/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_wfopen/test6/CMakeLists.txt deleted file mode 100644 index c2fb9e7b8..000000000 --- a/src/pal/tests/palsuite/c_runtime/_wfopen/test6/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test6.cpp -) - -add_executable(paltest_wfopen_test6 - ${SOURCES} -) - -add_dependencies(paltest_wfopen_test6 coreclrpal) - -target_link_libraries(paltest_wfopen_test6 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_wfopen/test6/test6.cpp b/src/pal/tests/palsuite/c_runtime/_wfopen/test6/test6.cpp deleted file mode 100644 index 17d36a0c5..000000000 --- a/src/pal/tests/palsuite/c_runtime/_wfopen/test6/test6.cpp +++ /dev/null @@ -1,152 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test6.c -** -** Purpose: Tests the PAL implementation of the _wfopen function. -** Test to ensure that you can write to an 'a' mode file. -** And that you can't read from a 'a' mode file. -** -** Depends: -** fprintf -** fgets -** fseek -** - -** -**===================================================================*/ - -#include - -int __cdecl main(int argc, char **argv) -{ - FILE *fp; - char buffer[128]; - WCHAR filename[] = {'t','e','s','t','f','i','l','e','\0'}; - WCHAR filename2[] = {'t','e','s','t','f','i','l','e','2','\0'}; - WCHAR append[] = {'a','\0'}; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - /* Open a file with 'a' mode */ - if( (fp = _wfopen( filename, append )) == NULL ) - { - Fail( "ERROR: file failed to open with 'a' mode.\n" ); - } - - /* Write some text to the file */ - if(fprintf(fp,"%s","some text") <= 0) - { - Fail("ERROR: Attempted to WRITE to a file opened with 'a' mode " - "but fprintf failed. Either fopen or fprintf have problems."); - } - - if(fseek(fp, 0, SEEK_SET)) - { - Fail("ERROR: fseek failed, and this test depends on it."); - } - - /* Attempt to read from the 'a' only file, should fail */ - if(fgets(buffer,10,fp) != NULL) - { - Fail("ERROR: Tried to READ from a file with 'a' mode set. " - "This should fail, but fgets returned success. Either fgets " - "or fopen is broken."); - } - - // Delete the file now that we're done with it. - if (fclose(fp) != 0) - { - Fail("ERROR: fclose failed to close \"testfile\".\n"); - } - - if (!DeleteFileA("testfile")) - { - Fail("ERROR: Failed to delete \"testfile\".\n" - " Error is %d\n", - GetLastError()); - } - - /* Attempt to write to a file after using 'a' and fseek */ - fp = _wfopen(filename2, append); - if(fp == NULL) - { - Fail("ERROR: _wfopen failed to be created with 'a' mode.\n"); - } - - /* write text to the file initially */ - if(fprintf(fp,"%s","abcd") <= 0) - { - Fail("ERROR: Attempted to WRITE to a file opened with 'a' mode " - "but fprintf failed. Either fopen or fprintf have problems.\n"); - } - - /* set the pointer to the front of the file */ - if(fseek(fp, 0, SEEK_SET)) - { - Fail("ERROR: fseek failed, and this test depends on it.\n"); - } - - /* using 'a' should still write to the end of the file, not the front */ - if(fputs("efgh", fp) < 0) - { - Fail("ERROR: Attempt to WRITE with fputs to the beginning of a file " - "opened with 'a' mode succeeded.\n"); - } - - /* set the pointer to the front of the file */ - if(fseek(fp, 0, SEEK_SET)) - { - Fail("ERROR: fseek failed, and this test depends on it.\n"); - } - - /* a file with 'a' mode can only write, so close the file before reading */ - if(fclose(fp)) - { - Fail("ERROR: fclose failed when it should have succeeded.\n"); - } - - /* open the file again to read */ - fp = fopen("testfile2","r"); - if(fp == NULL) - { - Fail("ERROR: fopen failed to open the file using 'r' mode"); - } - - /* Attempt to read from the 'a' only file, should succeed */ - if(fgets(buffer,10,fp) == NULL) - { - Fail("ERROR: Tried to READ from a file with 'a' mode set. " - "This should pass, but fgets returned failure. Either fgets " - "or fopen is broken.\n"); - } - - /* Compare what was read and what should have been in the file */ - if(memcmp(buffer,"abcdefgh",8)) - { - Fail("ERROR: The string read should have equaled 'abcdefgh' " - "but instead it is %s\n", buffer); - } - - // Delete the file now that we're done with it. - if (fclose(fp) != 0) - { - Fail("ERROR: fclose failed to close \"testfile\".\n"); - } - - if (!DeleteFileA("testfile2")) - { - Fail("ERROR: Failed to delete \"testfile2\".\n"); - } - - PAL_Terminate(); - return PASS; -} - - diff --git a/src/pal/tests/palsuite/c_runtime/_wfopen/test6/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_wfopen/test6/testinfo.dat deleted file mode 100644 index 832f10241..000000000 --- a/src/pal/tests/palsuite/c_runtime/_wfopen/test6/testinfo.dat +++ /dev/null @@ -1,15 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = _wfopen -Name = Positive Test for _wfopen -TYPE = DEFAULT -EXE1 = test6 -Description -= Test to ensure that you can write to a 'a' mode file. And that you can't -= read from a 'a' mode file. - - diff --git a/src/pal/tests/palsuite/c_runtime/_wfopen/test7/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_wfopen/test7/CMakeLists.txt deleted file mode 100644 index 13f7b00a2..000000000 --- a/src/pal/tests/palsuite/c_runtime/_wfopen/test7/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test7.cpp -) - -add_executable(paltest_wfopen_test7 - ${SOURCES} -) - -add_dependencies(paltest_wfopen_test7 coreclrpal) - -target_link_libraries(paltest_wfopen_test7 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_wfopen/test7/test7.cpp b/src/pal/tests/palsuite/c_runtime/_wfopen/test7/test7.cpp deleted file mode 100644 index 0a889adc8..000000000 --- a/src/pal/tests/palsuite/c_runtime/_wfopen/test7/test7.cpp +++ /dev/null @@ -1,119 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test7.c -** -** Purpose: Tests the PAL implementation of the _wfopen function. -** Test to ensure that you can write to an 'a+' mode file. -** And that you can read from a 'a+' mode file. -** -** Depends: -** fprintf -** fgets -** fseek -** - -** -**===================================================================*/ -#define UNICODE - -#include - -int __cdecl main(int argc, char **argv) -{ - - FILE *fp; - char buffer[128]; - WCHAR filename[] = {'t','e','s','t','f','i','l','e','\0'}; - WCHAR filename2[] = {'t','e','s','t','f','i','l','e','2','\0'}; - WCHAR appendplus[] = {'a','+','\0'}; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - /* Open a file with 'a+' mode */ - if( (fp = _wfopen( filename, appendplus )) == NULL ) - { - Fail( "ERROR: The file failed to open with 'a+' mode.\n" ); - } - - /* Write some text to the file */ - if(fprintf(fp,"%s","some text") <= 0) - { - Fail("ERROR: Attempted to WRITE to a file opened with 'a+' mode " - "but fprintf failed. Either fopen or fprintf have problems."); - } - - if(fseek(fp, 0, SEEK_SET)) - { - Fail("ERROR: fseek failed, and this test depends on it."); - } - - /* Attempt to read from the 'a+' only file, should succeed */ - if(fgets(buffer,10,fp) == NULL) - { - Fail("ERROR: Tried to READ from a file with 'a+' mode set. " - "This should pass, but fgets returned failure. Either fgets " - "or fopen is broken."); - } - - - /* Attempt to write to a file after using 'a+' and fseek */ - fp = _wfopen(filename2, appendplus); - if(fp == NULL) - { - Fail("ERROR: _wfopen failed to be created with 'a+' mode.\n"); - } - - /* write text to the file initially */ - if(fprintf(fp,"%s","abcd") <= 0) - { - Fail("ERROR: Attempted to WRITE to a file opened with 'a+' mode " - "but fprintf failed. Either fopen or fprintf have problems.\n"); - } - - /* set the pointer to the front of the file */ - if(fseek(fp, 0, SEEK_SET)) - { - Fail("ERROR: fseek failed, and this test depends on it.\n"); - } - - /* using 'a+' should still write to the end of the file, not the front */ - if(fputs("efgh",fp) < 0) - { - Fail("ERROR: Attempted to WRITE to a file opened with 'a+' mode " - "but fputs failed.\n"); - } - - /* set the pointer to the front of the file */ - if(fseek(fp, 0, SEEK_SET)) - { - Fail("ERROR: fseek failed, and this test depends on it.\n"); - } - - /* Attempt to read from the 'a+' only file, should succeed */ - if(fgets(buffer,10,fp) == NULL) - { - Fail("ERROR: Tried to READ from a file with 'a+' mode set. " - "This should pass, but fgets returned failure. Either fgets " - "or fopen is broken.\n"); - } - - /* Compare what was read and what should have been in the file */ - if(memcmp(buffer,"abcdefgh",8)) - { - Fail("ERROR: The string read should have equaled 'abcdefgh' " - "but instead it is %s\n", buffer); - } - - PAL_Terminate(); - return PASS; -} - - diff --git a/src/pal/tests/palsuite/c_runtime/_wfopen/test7/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_wfopen/test7/testinfo.dat deleted file mode 100644 index 0c50efb75..000000000 --- a/src/pal/tests/palsuite/c_runtime/_wfopen/test7/testinfo.dat +++ /dev/null @@ -1,15 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = _wfopen -Name = Positive Test for _wfopen -TYPE = DEFAULT -EXE1 = test7 -Description -= Test to ensure that you can write to a 'a+' mode file. And that you can -= read from a 'a+' mode file. - - diff --git a/src/pal/tests/palsuite/c_runtime/_wtoi/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_wtoi/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/c_runtime/_wtoi/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/c_runtime/_wtoi/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/_wtoi/test1/CMakeLists.txt deleted file mode 100644 index b04d4abbe..000000000 --- a/src/pal/tests/palsuite/c_runtime/_wtoi/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_wtoi_test1 - ${SOURCES} -) - -add_dependencies(paltest_wtoi_test1 coreclrpal) - -target_link_libraries(paltest_wtoi_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/_wtoi/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/_wtoi/test1/test1.cpp deleted file mode 100644 index 0b14dedd6..000000000 --- a/src/pal/tests/palsuite/c_runtime/_wtoi/test1/test1.cpp +++ /dev/null @@ -1,79 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test1.c -** -** Purpose: Tests the PAL implementation of the _wtoi function. -** Check to ensure that the different ints are handled properly. -** Exponents and decimals should be treated as invalid characters, -** causing the conversion to quit. Whitespace before the int is valid. -** Check would-be octal/hex digits to ensure they're treated no -** differently than other strings. -** -** -**===================================================================*/ - -#include - - -struct testCase -{ - int IntValue; - char avalue[20]; -}; - -int __cdecl main(int argc, char **argv) -{ - - int result=0; - int i=0; - WCHAR* temp; - - struct testCase testCases[] = - { - {1234, "1234"}, - {-1234, "-1234"}, - {1234, "+1234"}, - {1234, "1234.44"}, - {1234, "1234e-5"}, - {1234, "1234e+5"}, - {1234, "1234E5"}, - {1234, "\t1234"}, - {0, "0x21"}, - {17, "017"}, - {1234, "1234.657e-8"}, - {1234567, " 1234567e-8 foo"}, - {0, "foo 32 bar"} - }; - - if (0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - /* Loop through each case. Convert the wide string to an int - and then compare to ensure that it is the correct value. - */ - - for(i = 0; i < sizeof(testCases) / sizeof(struct testCase); i++) - { - /* Convert to a wide string, then call _wtoi to convert to an int */ - temp = convert(testCases[i].avalue); - result = _wtoi(temp); - free(temp); - if (testCases[i].IntValue != result) - { - Fail("ERROR: _wtoi misinterpreted \"%s\" as %i instead of %i.\n", - testCases[i].avalue, - result, - testCases[i].IntValue); - } - - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/_wtoi/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/_wtoi/test1/testinfo.dat deleted file mode 100644 index 4a1f21d4b..000000000 --- a/src/pal/tests/palsuite/c_runtime/_wtoi/test1/testinfo.dat +++ /dev/null @@ -1,17 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = _wtoi -Name = Test _wtoi on valid and invalid ints in a variety of formats -TYPE = DEFAULT -EXE1 = test1 -Description -= Tests the PAL implementation of the _wtoi function. -= Check to ensure that the different ints are handled properly. -= Exponents and decimals should be treated as invalid characters, -= causing the conversion to quit. Whitespace before the int is valid. -= Check would-be octal/hex digits to ensure they're treated no -= differently than other strings. diff --git a/src/pal/tests/palsuite/c_runtime/abs/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/abs/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/c_runtime/abs/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/c_runtime/abs/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/abs/test1/CMakeLists.txt deleted file mode 100644 index c09c03939..000000000 --- a/src/pal/tests/palsuite/c_runtime/abs/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - abs.cpp -) - -add_executable(paltest_abs_test1 - ${SOURCES} -) - -add_dependencies(paltest_abs_test1 coreclrpal) - -target_link_libraries(paltest_abs_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/abs/test1/abs.cpp b/src/pal/tests/palsuite/c_runtime/abs/test1/abs.cpp deleted file mode 100644 index 233a5dcb3..000000000 --- a/src/pal/tests/palsuite/c_runtime/abs/test1/abs.cpp +++ /dev/null @@ -1,54 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: abs.c (test 1) -** -** Purpose: Tests the PAL implementation of the abs function. -** -** -**===================================================================*/ - -#include - -struct TESTS -{ - int nTest; - int nResult; -}; - -int __cdecl main(int argc, char *argv[]) -{ - int i = 0; - int nRc = 0; - struct TESTS testCase[] = - { - {0, 0}, - {1, 1}, - {-1, 1} - }; - - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - for (i = 0; i < (sizeof(testCase)/sizeof(struct TESTS)); i++) - { - nRc = abs(testCase[i].nTest); - if (nRc != testCase[i].nResult) - { - Fail("abs: ERROR -> abs(%d) returned %d " - "when it was expected to return %d \n", - testCase[i].nTest, - nRc, - testCase[i].nResult); - } - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/abs/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/abs/test1/testinfo.dat deleted file mode 100644 index 98e2af21d..000000000 --- a/src/pal/tests/palsuite/c_runtime/abs/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C runtime -Function = abs -Name = test for abs (test 1) -Type = DEFAULT -EXE1 = abs -Description -= Test abs by passing a list of values and ensuring the -= proper absolute value is returned. diff --git a/src/pal/tests/palsuite/c_runtime/acos/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/acos/CMakeLists.txt deleted file mode 100644 index 5e1ef7f28..000000000 --- a/src/pal/tests/palsuite/c_runtime/acos/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) diff --git a/src/pal/tests/palsuite/c_runtime/acos/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/acos/test1/CMakeLists.txt deleted file mode 100644 index 7f473d072..000000000 --- a/src/pal/tests/palsuite/c_runtime/acos/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_acos_test1 - ${SOURCES} -) - -add_dependencies(paltest_acos_test1 coreclrpal) - -target_link_libraries(paltest_acos_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/acos/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/acos/test1/test1.cpp deleted file mode 100644 index c6ed0692c..000000000 --- a/src/pal/tests/palsuite/c_runtime/acos/test1/test1.cpp +++ /dev/null @@ -1,130 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================= -** -** Source: test1.c -** -** Purpose: Test to ensure that acos return the correct values -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** Fail -** fabs -** -**===========================================================================*/ - -#include - -// binary64 (double) has a machine epsilon of 2^-52 (approx. 2.22e-16). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-50 (approx. 8.88e-16) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (15-17 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxxxxxxxxxx will use -// PAL_EPSILON for the variance, while an expected result in the format of 0.0xxxxxxxxxxxxxxxxx -// will use PAL_EPSILON / 10 and and expected result in the format of x.xxxxxxxxxxxxxxxx will -// use PAL_EPSILON * 10. -#define PAL_EPSILON 8.8817841970012523e-16 - -#define PAL_NAN sqrt(-1.0) -#define PAL_POSINF -log(0.0) -#define PAL_NEGINF log(0.0) - -/** - * Helper test structure - */ -struct test -{ - double value; /* value to test the function with */ - double expected; /* expected result */ - double variance; /* maximum delta between the expected and actual result */ -}; - -/** - * validate - * - * test validation function - */ -void __cdecl validate(double value, double expected, double variance) -{ - double result = acos(value); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - double delta = fabs(result - expected); - - if (delta > variance) - { - Fail("acos(%g) returned %20.17g when it should have returned %20.17g", - value, result, expected); - } -} - -/** - * validate - * - * test validation function for values returning NaN - */ -void __cdecl validate_isnan(double value) -{ - double result = acos(value); - - if (!_isnan(result)) - { - Fail("acos(%g) returned %20.17g when it should have returned %20.17g", - value, result, PAL_NAN); - } -} - -/** - * main - * - * executable entry point - */ -int __cdecl main(int argc, char **argv) -{ - struct test tests[] = - { - /* value expected variance */ - { -1, 3.1415926535897932, PAL_EPSILON * 10 }, // expected: pi - { -0.91173391478696510, 2.7182818284590452, PAL_EPSILON * 10 }, // expected: e - { -0.66820151019031295, 2.3025850929940457, PAL_EPSILON * 10 }, // expected: ln(10) - { 0, 1.5707963267948966, PAL_EPSILON * 10 }, // expected: pi / 2 - { 0.12775121753523991, 1.4426950408889634, PAL_EPSILON * 10 }, // expected: log2(e) - { 0.15594369476537447, 1.4142135623730950, PAL_EPSILON * 10 }, // expected: sqrt(2) - { 0.42812514788535792, 1.1283791670955126, PAL_EPSILON * 10 }, // expected: 2 / sqrt(pi) - { 0.54030230586813972, 1, PAL_EPSILON * 10 }, - { 0.70710678118654752, 0.78539816339744831, PAL_EPSILON }, // expected: pi / 4, value: 1 / sqrt(2) - { 0.76024459707563015, 0.70710678118654752, PAL_EPSILON }, // expected: 1 / sqrt(2) - { 0.76923890136397213, 0.69314718055994531, PAL_EPSILON }, // expected: ln(2) - { 0.80410982822879171, 0.63661977236758134, PAL_EPSILON }, // expected: 2 / pi - { 0.90716712923909839, 0.43429448190325183, PAL_EPSILON }, // expected: log10(e) - { 0.94976571538163866, 0.31830988618379067, PAL_EPSILON }, // expected: 1 / pi - { 1, 0, PAL_EPSILON }, - }; - - /* PAL initialization */ - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - validate(tests[i].value, tests[i].expected, tests[i].variance); - } - - validate_isnan(PAL_NEGINF); - validate_isnan(PAL_NAN); - validate_isnan(PAL_POSINF); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/acos/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/acos/test1/testinfo.dat deleted file mode 100644 index 4b43982fc..000000000 --- a/src/pal/tests/palsuite/c_runtime/acos/test1/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = acos -Name = Positive Test for acos -TYPE = DEFAULT -EXE1 = test1 -Description -= Passes a series of values to the acos() function, -= checking each for the expected result. Also checks -= for proper handling of out-of-range values. diff --git a/src/pal/tests/palsuite/c_runtime/acosf/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/acosf/CMakeLists.txt deleted file mode 100644 index 5e1ef7f28..000000000 --- a/src/pal/tests/palsuite/c_runtime/acosf/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) diff --git a/src/pal/tests/palsuite/c_runtime/acosf/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/acosf/test1/CMakeLists.txt deleted file mode 100644 index 095be954d..000000000 --- a/src/pal/tests/palsuite/c_runtime/acosf/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.c -) - -add_executable(paltest_acosf_test1 - ${SOURCES} -) - -add_dependencies(paltest_acosf_test1 coreclrpal) - -target_link_libraries(paltest_acosf_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/acosf/test1/test1.c b/src/pal/tests/palsuite/c_runtime/acosf/test1/test1.c deleted file mode 100644 index 3d8668ceb..000000000 --- a/src/pal/tests/palsuite/c_runtime/acosf/test1/test1.c +++ /dev/null @@ -1,129 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================= -** -** Source: test1.c -** -** Purpose: Test to ensure that acosf return the correct values -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** Fail -** fabs -** -**===========================================================================*/ - -#include - -// binary32 (float) has a machine epsilon of 2^-23 (approx. 1.19e-07). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-21 (approx. 4.76e-07) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (6-9 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxx will use PAL_EPSILON -// for the variance, while an expected result in the format of 0.0xxxxxxxxx will use -// PAL_EPSILON / 10 and and expected result in the format of x.xxxxxx will use PAL_EPSILON * 10. -#define PAL_EPSILON 4.76837158e-07 - -#define PAL_NAN sqrtf(-1.0f) -#define PAL_POSINF -logf(0.0f) -#define PAL_NEGINF logf(0.0f) - -/** - * Helper test structure - */ -struct test -{ - float value; /* value to test the function with */ - float expected; /* expected result */ - float variance; /* maximum delta between the expected and actual result */ -}; - -/** - * validate - * - * test validation function - */ -void __cdecl validate(float value, float expected, float variance) -{ - float result = acosf(value); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - float delta = fabsf(result - expected); - - if (delta > variance) - { - Fail("acosf(%g) returned %10.9g when it should have returned %10.9g", - value, result, expected); - } -} - -/** - * validate - * - * test validation function for values returning NaN - */ -void __cdecl validate_isnan(float value) -{ - float result = acosf(value); - - if (!_isnanf(result)) - { - Fail("acosf(%g) returned %10.9g when it should have returned %10.9g", - value, result, PAL_NAN); - } -} - -/** - * main - * - * executable entry point - */ -int __cdecl main(int argc, char **argv) -{ - struct test tests[] = - { - /* value expected variance */ - { -1, 3.14159265f, PAL_EPSILON * 10 }, // expected: pi - { -0.911733915f, 2.71828183f, PAL_EPSILON * 10 }, // expected: e - { -0.668201510f, 2.30258509f, PAL_EPSILON * 10 }, // expected: ln(10) - { 0, 1.57079633f, PAL_EPSILON * 10 }, // expected: pi / 2 - { 0.127751218f, 1.44269504f, PAL_EPSILON * 10 }, // expected: logf2(e) - { 0.155943695f, 1.41421356f, PAL_EPSILON * 10 }, // expected: sqrtf(2) - { 0.428125148f, 1.12837917f, PAL_EPSILON * 10 }, // expected: 2 / sqrtf(pi) - { 0.540302306f, 1, PAL_EPSILON * 10 }, - { 0.707106781f, 0.785398163f, PAL_EPSILON }, // expected: pi / 4, value: 1 / sqrtf(2) - { 0.760244597f, 0.707106781f, PAL_EPSILON }, // expected: 1 / sqrtf(2) - { 0.769238901f, 0.693147181f, PAL_EPSILON }, // expected: ln(2) - { 0.804109828f, 0.636619772f, PAL_EPSILON }, // expected: 2 / pi - { 0.907167129f, 0.434294482f, PAL_EPSILON }, // expected: logf10f(e) - { 0.949765715f, 0.318309886f, PAL_EPSILON }, // expected: 1 / pi - { 1, 0, PAL_EPSILON }, - }; - - /* PAL initialization */ - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - validate(tests[i].value, tests[i].expected, tests[i].variance); - } - - validate_isnan(PAL_NEGINF); - validate_isnan(PAL_NAN); - validate_isnan(PAL_POSINF); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/acosf/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/acosf/test1/testinfo.dat deleted file mode 100644 index 41cead33b..000000000 --- a/src/pal/tests/palsuite/c_runtime/acosf/test1/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = acosf -Name = Positive Test for acosf -TYPE = DEFAULT -EXE1 = test1 -Description -= Passes a series of values to the acosf() function, -= checking each for the expfected result. Also checks -= for proper handling of out-of-range values. diff --git a/src/pal/tests/palsuite/c_runtime/acosh/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/acosh/CMakeLists.txt deleted file mode 100644 index 5e1ef7f28..000000000 --- a/src/pal/tests/palsuite/c_runtime/acosh/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) diff --git a/src/pal/tests/palsuite/c_runtime/acosh/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/acosh/test1/CMakeLists.txt deleted file mode 100644 index 0c233d10e..000000000 --- a/src/pal/tests/palsuite/c_runtime/acosh/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_acosh_test1 - ${SOURCES} -) - -add_dependencies(paltest_acosh_test1 coreclrpal) - -target_link_libraries(paltest_acosh_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/acosh/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/acosh/test1/test1.cpp deleted file mode 100644 index 14ff430c0..000000000 --- a/src/pal/tests/palsuite/c_runtime/acosh/test1/test1.cpp +++ /dev/null @@ -1,129 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================= -** -** Source: test1.c -** -** Purpose: Test to ensure that acosh return the correct values -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** Fail -** fabs -** -**===========================================================================*/ - -#include - -// binary64 (double) has a machine epsilon of 2^-52 (approx. 2.22e-16). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-50 (approx. 8.88e-16) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (15-17 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxxxxxxxxxx will use -// PAL_EPSILON for the variance, while an expected result in the format of 0.0xxxxxxxxxxxxxxxxx -// will use PAL_EPSILON / 10 and and expected result in the format of x.xxxxxxxxxxxxxxxx will -// use PAL_EPSILON * 10. -#define PAL_EPSILON 8.8817841970012523e-16 - -#define PAL_NAN sqrt(-1.0) -#define PAL_POSINF -log(0.0) -#define PAL_NEGINF log(0.0) - -/** - * Helper test structure - */ -struct test -{ - double value; /* value to test the function with */ - double expected; /* expected result */ - double variance; /* maximum delta between the expected and actual result */ -}; - -/** - * validate - * - * test validation function - */ -void __cdecl validate(double value, double expected, double variance) -{ - double result = acosh(value); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - double delta = fabs(result - expected); - - if (delta > variance) - { - Fail("acosh(%g) returned %20.17g when it should have returned %20.17g", - value, result, expected); - } -} - -/** - * validate - * - * test validation function for values returning NaN - */ -void __cdecl validate_isnan(double value) -{ - double result = acosh(value); - - if (!_isnan(result)) - { - Fail("acosh(%g) returned %20.17g when it should have returned %20.17g", - value, result, PAL_NAN); - } -} - -/** - * main - * - * executable entry point - */ -int __cdecl main(int argc, char **argv) -{ - struct test tests[] = - { - /* value expected variance */ - { 1, 0, PAL_EPSILON }, - { 1.0510897883672876, 0.31830988618379067, PAL_EPSILON }, // expected: 1 / pi - { 1.0957974645564909, 0.43429448190325183, PAL_EPSILON }, // expected: log10(e) - { 1.2095794864199787, 0.63661977236758134, PAL_EPSILON }, // expected: 2 / pi - { 1.25, 0.69314718055994531, PAL_EPSILON }, // expected: ln(2) - { 1.2605918365213561, 0.70710678118654752, PAL_EPSILON }, // expected: 1 / sqrt(2) - { 1.3246090892520058, 0.78539816339744831, PAL_EPSILON }, // expected: pi / 4 - { 1.5430806348152438, 1, PAL_EPSILON * 10 }, - { 1.7071001431069344, 1.1283791670955126, PAL_EPSILON * 10 }, // expected: 2 / sqrt(pi) - { 2.1781835566085709, 1.4142135623730950, PAL_EPSILON * 10 }, // expected: sqrt(2) - { 2.2341880974508023, 1.4426950408889634, PAL_EPSILON * 10 }, // expected: log2(e) - { 2.5091784786580568, 1.5707963267948966, PAL_EPSILON * 10 }, // expected: pi / 2 - { 5.05, 2.3025850929940457, PAL_EPSILON * 10 }, // expected: ln(10) - { 7.6101251386622884, 2.7182818284590452, PAL_EPSILON * 10 }, // expected: e - { 11.591953275521521, 3.1415926535897932, PAL_EPSILON * 10 }, // expected: pi - { PAL_POSINF, PAL_POSINF, 0 }, - }; - - /* PAL initialization */ - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - validate(tests[i].value, tests[i].expected, tests[i].variance); - } - - validate_isnan(PAL_NAN); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/acosh/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/acosh/test1/testinfo.dat deleted file mode 100644 index 32d69ee47..000000000 --- a/src/pal/tests/palsuite/c_runtime/acosh/test1/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = acosh -Name = Positive Test for acosh -TYPE = DEFAULT -EXE1 = test1 -Description -= Passes a series of values to the acosh() function, -= checking each for the expected result. Also checks -= for proper handling of out-of-range values. diff --git a/src/pal/tests/palsuite/c_runtime/acoshf/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/acoshf/CMakeLists.txt deleted file mode 100644 index 5e1ef7f28..000000000 --- a/src/pal/tests/palsuite/c_runtime/acoshf/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) diff --git a/src/pal/tests/palsuite/c_runtime/acoshf/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/acoshf/test1/CMakeLists.txt deleted file mode 100644 index 5f3d42db4..000000000 --- a/src/pal/tests/palsuite/c_runtime/acoshf/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.c -) - -add_executable(paltest_acoshf_test1 - ${SOURCES} -) - -add_dependencies(paltest_acoshf_test1 coreclrpal) - -target_link_libraries(paltest_acoshf_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/acoshf/test1/test1.c b/src/pal/tests/palsuite/c_runtime/acoshf/test1/test1.c deleted file mode 100644 index 220999973..000000000 --- a/src/pal/tests/palsuite/c_runtime/acoshf/test1/test1.c +++ /dev/null @@ -1,128 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================= -** -** Source: test1.c -** -** Purpose: Test to ensure that acoshf return the correct values -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** Fail -** fabs -** -**===========================================================================*/ - -#include - -// binary32 (float) has a machine epsilon of 2^-23 (approx. 1.19e-07). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-21 (approx. 4.76e-07) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (6-9 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxx will use PAL_EPSILON -// for the variance, while an expected result in the format of 0.0xxxxxxxxx will use -// PAL_EPSILON / 10 and and expected result in the format of x.xxxxxx will use PAL_EPSILON * 10. -#define PAL_EPSILON 4.76837158e-07 - -#define PAL_NAN sqrtf(-1.0f) -#define PAL_POSINF -logf(0.0f) -#define PAL_NEGINF logf(0.0f) - -/** - * Helper test structure - */ -struct test -{ - float value; /* value to test the function with */ - float expected; /* expected result */ - float variance; /* maximum delta between the expected and actual result */ -}; - -/** - * validate - * - * test validation function - */ -void __cdecl validate(float value, float expected, float variance) -{ - float result = acoshf(value); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - float delta = fabsf(result - expected); - - if (delta > variance) - { - Fail("acoshf(%g) returned %10.9g when it should have returned %10.9g", - value, result, expected); - } -} - -/** - * validate - * - * test validation function for values returning NaN - */ -void __cdecl validate_isnan(float value) -{ - float result = acoshf(value); - - if (!_isnanf(result)) - { - Fail("acoshf(%g) returned %10.9g when it should have returned %10.9g", - value, result, PAL_NAN); - } -} - -/** - * main - * - * executable entry point - */ -int __cdecl main(int argc, char **argv) -{ - struct test tests[] = - { - /* value expected variance */ - { 1, 0, PAL_EPSILON }, - { 1.05108979f, 0.318309886f, PAL_EPSILON }, // expected: 1 / pi - { 1.09579746f, 0.434294482f, PAL_EPSILON }, // expected: log10f(e) - { 1.20957949f, 0.636619772f, PAL_EPSILON }, // expected: 2 / pi - { 1.25f, 0.693147181f, PAL_EPSILON }, // expected: ln(2) - { 1.26059184f, 0.707106781f, PAL_EPSILON }, // expected: 1 / sqrtf(2) - { 1.32460909f, 0.785398163f, PAL_EPSILON }, // expected: pi / 4 - { 1.54308063f, 1, PAL_EPSILON * 10 }, - { 1.70710014f, 1.12837917f, PAL_EPSILON * 10 }, // expected: 2 / sqrtf(pi) - { 2.17818356f, 1.41421356f, PAL_EPSILON * 10 }, // expected: sqrtf(2) - { 2.23418810f, 1.44269504f, PAL_EPSILON * 10 }, // expected: logf2(e) - { 2.50917848f, 1.57079633f, PAL_EPSILON * 10 }, // expected: pi / 2 - { 5.05f, 2.30258509f, PAL_EPSILON * 10 }, // expected: ln(10) - { 7.61012514f, 2.71828183f, PAL_EPSILON * 10 }, // expected: e - { 11.5919533f, 3.14159265f, PAL_EPSILON * 100 }, // expected: pi - { PAL_POSINF, PAL_POSINF, 0 }, - }; - - /* PAL initialization */ - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - validate(tests[i].value, tests[i].expected, tests[i].variance); - } - - validate_isnan(PAL_NAN); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/acoshf/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/acoshf/test1/testinfo.dat deleted file mode 100644 index 07d78ad10..000000000 --- a/src/pal/tests/palsuite/c_runtime/acoshf/test1/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = acoshf -Name = Positive Test for acoshf -TYPE = DEFAULT -EXE1 = test1 -Description -= Passes a series of values to the acoshf() function, -= checking each for the expfected result. Also checks -= for proper handling of out-of-range values. diff --git a/src/pal/tests/palsuite/c_runtime/asin/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/asin/CMakeLists.txt deleted file mode 100644 index 5e1ef7f28..000000000 --- a/src/pal/tests/palsuite/c_runtime/asin/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) diff --git a/src/pal/tests/palsuite/c_runtime/asin/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/asin/test1/CMakeLists.txt deleted file mode 100644 index 3537fe6ef..000000000 --- a/src/pal/tests/palsuite/c_runtime/asin/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_asin_test1 - ${SOURCES} -) - -add_dependencies(paltest_asin_test1 coreclrpal) - -target_link_libraries(paltest_asin_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/asin/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/asin/test1/test1.cpp deleted file mode 100644 index 0a63356ed..000000000 --- a/src/pal/tests/palsuite/c_runtime/asin/test1/test1.cpp +++ /dev/null @@ -1,146 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================= -** -** Source: test1.c -** -** Purpose: Test to ensure that asin return the correct values -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** Fail -** fabs -** -**===========================================================================*/ - -#include - -// binary64 (double) has a machine epsilon of 2^-52 (approx. 2.22e-16). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-50 (approx. 8.88e-16) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (15-17 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxxxxxxxxxx will use -// PAL_EPSILON for the variance, while an expected result in the format of 0.0xxxxxxxxxxxxxxxxx -// will use PAL_EPSILON / 10 and and expected result in the format of x.xxxxxxxxxxxxxxxx will -// use PAL_EPSILON * 10. -#define PAL_EPSILON 8.8817841970012523e-16 - -#define PAL_NAN sqrt(-1.0) -#define PAL_POSINF -log(0.0) -#define PAL_NEGINF log(0.0) - -/** - * Helper test structure - */ -struct test -{ - double value; /* value to test the function with */ - double expected; /* expected result */ - double variance; /* maximum delta between the expected and actual result */ -}; - -/** - * validate - * - * test validation function - */ -void __cdecl validate(double value, double expected, double variance) -{ - double result = asin(value); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - double delta = fabs(result - expected); - - if (delta > variance) - { - Fail("asin(%g) returned %20.17g when it should have returned %20.17g", - value, result, expected); - } -} - -/** - * validate - * - * test validation function for values returning NaN - */ -void __cdecl validate_isnan(double value) -{ - double result = asin(value); - - if (!_isnan(result)) - { - Fail("asin(%g) returned %20.17g when it should have returned %20.17g", - value, result, PAL_NAN); - } -} - -/** - * validate - * - * test validation function for values returning +INF - */ -void __cdecl validate_isinf_positive(double value) -{ - double result = asin(value); - - if (result != PAL_POSINF) - { - Fail("asin(%g) returned %20.17g when it should have returned %20.17g", - value, result, PAL_POSINF); - } -} - -/** - * main - * - * executable entry point - */ -int __cdecl main(int argc, char **argv) -{ - struct test tests[] = - { - /* value expected variance */ - { 0, 0, PAL_EPSILON }, - { 0.31296179620778659, 0.31830988618379067, PAL_EPSILON }, // expected: 1 / pi - { 0.41078129050290870, 0.42331082513074800, PAL_EPSILON }, // expected: pi - e - { 0.42077048331375735, 0.43429448190325183, PAL_EPSILON }, // expected: log10(e) - { 0.59448076852482208, 0.63661977236758134, PAL_EPSILON }, // expected: 2 / pi - { 0.63896127631363480, 0.69314718055994531, PAL_EPSILON }, // expected: ln(2) - { 0.64963693908006244, 0.70710678118654752, PAL_EPSILON }, // expected: 1 / sqrt(2) - { 0.70710678118654752, 0.78539816339744831, PAL_EPSILON }, // expected: pi / 4, value: 1 / sqrt(2) - { 0.74398033695749319, 0.83900756059574755, PAL_EPSILON }, // expected: pi - ln(10) - { 0.84147098480789651, 1, PAL_EPSILON * 10 }, - { 0.90371945743584630, 1.1283791670955126, PAL_EPSILON * 10 }, // expected: 2 / sqrt(pi) - { 0.98776594599273553, 1.4142135623730950, PAL_EPSILON * 10 }, // expected: sqrt(2) - { 0.99180624439366372, 1.4426950408889634, PAL_EPSILON * 10 }, // expected: log2(e) - { 1, 1.5707963267948966, PAL_EPSILON * 10 }, // expected: pi / 2 - }; - - /* PAL initialization */ - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - validate( tests[i].value, tests[i].expected, tests[i].variance); - validate(-tests[i].value, -tests[i].expected, tests[i].variance); - } - - validate_isnan(PAL_NEGINF); - validate_isnan(PAL_NAN); - validate_isnan(PAL_POSINF); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/asin/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/asin/test1/testinfo.dat deleted file mode 100644 index fba9f95a2..000000000 --- a/src/pal/tests/palsuite/c_runtime/asin/test1/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = asin -Name = Positive Test for asin -TYPE = DEFAULT -EXE1 = test1 -Description -= Passes a series of values to the asin() function, -= checking each for the expected result. Also checks -= for proper handling of out-of-range values. diff --git a/src/pal/tests/palsuite/c_runtime/asinf/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/asinf/CMakeLists.txt deleted file mode 100644 index 5e1ef7f28..000000000 --- a/src/pal/tests/palsuite/c_runtime/asinf/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) diff --git a/src/pal/tests/palsuite/c_runtime/asinf/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/asinf/test1/CMakeLists.txt deleted file mode 100644 index 46661a745..000000000 --- a/src/pal/tests/palsuite/c_runtime/asinf/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.c -) - -add_executable(paltest_asinf_test1 - ${SOURCES} -) - -add_dependencies(paltest_asinf_test1 coreclrpal) - -target_link_libraries(paltest_asinf_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/asinf/test1/test1.c b/src/pal/tests/palsuite/c_runtime/asinf/test1/test1.c deleted file mode 100644 index 773015eec..000000000 --- a/src/pal/tests/palsuite/c_runtime/asinf/test1/test1.c +++ /dev/null @@ -1,145 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================= -** -** Source: test1.c -** -** Purpose: Test to ensure that asinf return the correct values -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** Fail -** fabs -** -**===========================================================================*/ - -#include - -// binary32 (float) has a machine epsilon of 2^-23 (approx. 1.19e-07). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-21 (approx. 4.76e-07) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (6-9 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxx will use PAL_EPSILON -// for the variance, while an expected result in the format of 0.0xxxxxxxxx will use -// PAL_EPSILON / 10 and and expected result in the format of x.xxxxxx will use PAL_EPSILON * 10. -#define PAL_EPSILON 4.76837158e-07 - -#define PAL_NAN sqrtf(-1.0f) -#define PAL_POSINF -logf(0.0f) -#define PAL_NEGINF logf(0.0f) - -/** - * Helper test structure - */ -struct test -{ - float value; /* value to test the function with */ - float expected; /* expected result */ - float variance; /* maximum delta between the expected and actual result */ -}; - -/** - * validate - * - * test validation function - */ -void __cdecl validate(float value, float expected, float variance) -{ - float result = asinf(value); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - float delta = fabsf(result - expected); - - if (delta > variance) - { - Fail("asinf(%g) returned %10.9g when it should have returned %10.9g", - value, result, expected); - } -} - -/** - * validate - * - * test validation function for values returning NaN - */ -void __cdecl validate_isnan(float value) -{ - float result = asinf(value); - - if (!_isnanf(result)) - { - Fail("asinf(%g) returned %10.9g when it should have returned %10.9g", - value, result, PAL_NAN); - } -} - -/** - * validate - * - * test validation function for values returning +INF - */ -void __cdecl validate_isinf_positive(float value) -{ - float result = asinf(value); - - if (result != PAL_POSINF) - { - Fail("asinf(%g) returned %10.9g when it should have returned %10.9g", - value, result, PAL_POSINF); - } -} - -/** - * main - * - * executable entry point - */ -int __cdecl main(int argc, char **argv) -{ - struct test tests[] = - { - /* value expected variance */ - { 0, 0, PAL_EPSILON }, - { 0.312961796f, 0.318309886f, PAL_EPSILON }, // expected: 1 / pi - { 0.410781291f, 0.423310825f, PAL_EPSILON }, // expected: pi - e - { 0.420770483f, 0.434294482f, PAL_EPSILON }, // expected: logf10f(e) - { 0.594480769f, 0.636619772f, PAL_EPSILON }, // expected: 2 / pi - { 0.638961276f, 0.693147181f, PAL_EPSILON }, // expected: ln(2) - { 0.649636939f, 0.707106781f, PAL_EPSILON }, // expected: 1 / sqrtf(2) - { 0.707106781f, 0.785398163f, PAL_EPSILON }, // expected: pi / 4, value: 1 / sqrtf(2) - { 0.743980337f, 0.839007561f, PAL_EPSILON }, // expected: pi - ln(10) - { 0.841470985f, 1, PAL_EPSILON * 10 }, - { 0.903719457f, 1.12837917f, PAL_EPSILON * 10 }, // expected: 2 / sqrtf(pi) - { 0.987765946f, 1.41421356f, PAL_EPSILON * 10 }, // expected: sqrtf(2) - { 0.991806244f, 1.44269504f, PAL_EPSILON * 10 }, // expected: logf2(e) - { 1, 1.57079633f, PAL_EPSILON * 10 }, // expected: pi / 2 - }; - - /* PAL initialization */ - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - validate( tests[i].value, tests[i].expected, tests[i].variance); - validate(-tests[i].value, -tests[i].expected, tests[i].variance); - } - - validate_isnan(PAL_NEGINF); - validate_isnan(PAL_NAN); - validate_isnan(PAL_POSINF); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/asinf/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/asinf/test1/testinfo.dat deleted file mode 100644 index ca2dd4215..000000000 --- a/src/pal/tests/palsuite/c_runtime/asinf/test1/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = asinf -Name = Positive Test for asinf -TYPE = DEFAULT -EXE1 = test1 -Description -= Passes a series of values to the asinf() function, -= checking each for the expected result. Also checks -= for proper handling of out-of-range values. diff --git a/src/pal/tests/palsuite/c_runtime/asinh/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/asinh/CMakeLists.txt deleted file mode 100644 index 5e1ef7f28..000000000 --- a/src/pal/tests/palsuite/c_runtime/asinh/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) diff --git a/src/pal/tests/palsuite/c_runtime/asinh/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/asinh/test1/CMakeLists.txt deleted file mode 100644 index c4e07c28b..000000000 --- a/src/pal/tests/palsuite/c_runtime/asinh/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_asinh_test1 - ${SOURCES} -) - -add_dependencies(paltest_asinh_test1 coreclrpal) - -target_link_libraries(paltest_asinh_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/asinh/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/asinh/test1/test1.cpp deleted file mode 100644 index 64c1e4a74..000000000 --- a/src/pal/tests/palsuite/c_runtime/asinh/test1/test1.cpp +++ /dev/null @@ -1,146 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================= -** -** Source: test1.c -** -** Purpose: Test to ensure that asinh return the correct values -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** Fail -** fabs -** -**===========================================================================*/ - -#include - -// binary64 (double) has a machine epsilon of 2^-52 (approx. 2.22e-16). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-50 (approx. 8.88e-16) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (15-17 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxxxxxxxxxx will use -// PAL_EPSILON for the variance, while an expected result in the format of 0.0xxxxxxxxxxxxxxxxx -// will use PAL_EPSILON / 10 and and expected result in the format of x.xxxxxxxxxxxxxxxx will -// use PAL_EPSILON * 10. -#define PAL_EPSILON 8.8817841970012523e-16 - -#define PAL_NAN sqrt(-1.0) -#define PAL_POSINF -log(0.0) -#define PAL_NEGINF log(0.0) - -/** - * Helper test structure - */ -struct test -{ - double value; /* value to test the function with */ - double expected; /* expected result */ - double variance; /* maximum delta between the expected and actual result */ -}; - -/** - * validate - * - * test validation function - */ -void __cdecl validate(double value, double expected, double variance) -{ - double result = asinh(value); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - double delta = fabs(result - expected); - - if (delta > variance) - { - Fail("asinh(%g) returned %20.17g when it should have returned %20.17g", - value, result, expected); - } -} - -/** - * validate - * - * test validation function for values returning NaN - */ -void __cdecl validate_isnan(double value) -{ - double result = asinh(value); - - if (!_isnan(result)) - { - Fail("asinh(%g) returned %20.17g when it should have returned %20.17g", - value, result, PAL_NAN); - } -} - -/** - * validate - * - * test validation function for values returning +INF - */ -void __cdecl validate_isinf_positive(double value) -{ - double result = asinh(value); - - if (result != PAL_POSINF) - { - Fail("asinh(%g) returned %20.17g when it should have returned %20.17g", - value, result, PAL_POSINF); - } -} - -/** - * main - * - * executable entry point - */ -int __cdecl main(int argc, char **argv) -{ - struct test tests[] = - { - /* value expected variance */ - { 0, 0, PAL_EPSILON }, - { 0.32371243907207108, 0.31830988618379067, PAL_EPSILON }, // expected: 1 / pi - { 0.44807597941469025, 0.43429448190325183, PAL_EPSILON }, // expected: log10(e) - { 0.68050167815224332, 0.63661977236758134, PAL_EPSILON }, // expected: 2 / pi - { 0.75, 0.69314718055994531, PAL_EPSILON }, // expected: ln(2) - { 0.76752314512611633, 0.70710678118654752, PAL_EPSILON }, // expected: 1 / sqrt(2) - { 0.86867096148600961, 0.78539816339744831, PAL_EPSILON }, // expected: pi / 4 - { 1.1752011936438015, 1, PAL_EPSILON * 10 }, - { 1.3835428792038633, 1.1283791670955126, PAL_EPSILON * 10 }, // expected: 2 / sqrt(pi) - { 1.9350668221743567, 1.4142135623730950, PAL_EPSILON * 10 }, // expected: sqrt(2) - { 1.9978980091062796, 1.4426950408889634, PAL_EPSILON * 10 }, // expected: log2(e) - { 2.3012989023072949, 1.5707963267948966, PAL_EPSILON * 10 }, // expected: pi / 2 - { 4.95, 2.3025850929940457, PAL_EPSILON * 10 }, // expected: ln(10) - { 7.5441371028169758, 2.7182818284590452, PAL_EPSILON * 10 }, // expected: e - { 11.548739357257748, 3.1415926535897932, PAL_EPSILON * 10 }, // expected: pi - { PAL_POSINF, PAL_POSINF, 0 }, - }; - - /* PAL initialization */ - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - validate( tests[i].value, tests[i].expected, tests[i].variance); - validate(-tests[i].value, -tests[i].expected, tests[i].variance); - } - - validate_isnan(PAL_NAN); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/asinh/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/asinh/test1/testinfo.dat deleted file mode 100644 index c5e9530d9..000000000 --- a/src/pal/tests/palsuite/c_runtime/asinh/test1/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = asinh -Name = Positive Test for asinh -TYPE = DEFAULT -EXE1 = test1 -Description -= Passes a series of values to the asinh() function, -= checking each for the expected result. Also checks -= for proper handling of out-of-range values. diff --git a/src/pal/tests/palsuite/c_runtime/asinhf/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/asinhf/CMakeLists.txt deleted file mode 100644 index 5e1ef7f28..000000000 --- a/src/pal/tests/palsuite/c_runtime/asinhf/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) diff --git a/src/pal/tests/palsuite/c_runtime/asinhf/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/asinhf/test1/CMakeLists.txt deleted file mode 100644 index 9e20ba52d..000000000 --- a/src/pal/tests/palsuite/c_runtime/asinhf/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.c -) - -add_executable(paltest_asinhf_test1 - ${SOURCES} -) - -add_dependencies(paltest_asinhf_test1 coreclrpal) - -target_link_libraries(paltest_asinhf_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/asinhf/test1/test1.c b/src/pal/tests/palsuite/c_runtime/asinhf/test1/test1.c deleted file mode 100644 index 6ecb8d93c..000000000 --- a/src/pal/tests/palsuite/c_runtime/asinhf/test1/test1.c +++ /dev/null @@ -1,145 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================= -** -** Source: test1.c -** -** Purpose: Test to ensure that asinhf return the correct values -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** Fail -** fabs -** -**===========================================================================*/ - -#include - -// binary32 (float) has a machine epsilon of 2^-23 (approx. 1.19e-07). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-21 (approx. 4.76e-07) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (6-9 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxx will use PAL_EPSILON -// for the variance, while an expected result in the format of 0.0xxxxxxxxx will use -// PAL_EPSILON / 10 and and expected result in the format of x.xxxxxx will use PAL_EPSILON * 10. -#define PAL_EPSILON 4.76837158e-07 - -#define PAL_NAN sqrtf(-1.0f) -#define PAL_POSINF -logf(0.0f) -#define PAL_NEGINF logf(0.0f) - -/** - * Helper test structure - */ -struct test -{ - float value; /* value to test the function with */ - float expected; /* expected result */ - float variance; /* maximum delta between the expected and actual result */ -}; - -/** - * validate - * - * test validation function - */ -void __cdecl validate(float value, float expected, float variance) -{ - float result = asinhf(value); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - float delta = fabsf(result - expected); - - if (delta > variance) - { - Fail("asinhf(%g) returned %10.9g when it should have returned %10.9g", - value, result, expected); - } -} - -/** - * validate - * - * test validation function for values returning NaN - */ -void __cdecl validate_isnan(float value) -{ - float result = asinhf(value); - - if (!_isnanf(result)) - { - Fail("asinhf(%g) returned %10.9g when it should have returned %10.9g", - value, result, PAL_NAN); - } -} - -/** - * validate - * - * test validation function for values returning +INF - */ -void __cdecl validate_isinf_positive(float value) -{ - float result = asinhf(value); - - if (result != PAL_POSINF) - { - Fail("asinhf(%g) returned %10.9g when it should have returned %10.9g", - value, result, PAL_POSINF); - } -} - -/** - * main - * - * executable entry point - */ -int __cdecl main(int argc, char **argv) -{ - struct test tests[] = - { - /* value expected variance */ - { 0, 0, PAL_EPSILON }, - { 0.323712439f, 0.318309886f, PAL_EPSILON }, // expected: 1 / pi - { 0.448075979f, 0.434294482f, PAL_EPSILON }, // expected: log10f(e) - { 0.680501678f, 0.636619772f, PAL_EPSILON }, // expected: 2 / pi - { 0.75, 0.693147181f, PAL_EPSILON }, // expected: ln(2) - { 0.767523145f, 0.707106781f, PAL_EPSILON }, // expected: 1 / sqrtf(2) - { 0.868670961f, 0.785398163f, PAL_EPSILON }, // expected: pi / 4 - { 1.17520119f, 1, PAL_EPSILON * 10 }, - { 1.38354288f, 1.12837917f, PAL_EPSILON * 10 }, // expected: 2 / sqrtf(pi) - { 1.93506682f, 1.41421356f, PAL_EPSILON * 10 }, // expected: sqrtf(2) - { 1.99789801f, 1.44269504f, PAL_EPSILON * 10 }, // expected: logf2(e) - { 2.30129890f, 1.57079633f, PAL_EPSILON * 10 }, // expected: pi / 2 - { 4.95f, 2.30258509f, PAL_EPSILON * 10 }, // expected: ln(10) - { 7.54413710f, 2.71828183f, PAL_EPSILON * 10 }, // expected: e - { 11.5487394f, 3.14159265f, PAL_EPSILON * 10 }, // expected: pi - { PAL_POSINF, PAL_POSINF, 0 }, - }; - - /* PAL initialization */ - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - validate( tests[i].value, tests[i].expected, tests[i].variance); - validate(-tests[i].value, -tests[i].expected, tests[i].variance); - } - - validate_isnan(PAL_NAN); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/asinhf/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/asinhf/test1/testinfo.dat deleted file mode 100644 index 023796b14..000000000 --- a/src/pal/tests/palsuite/c_runtime/asinhf/test1/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = asinhf -Name = Positive Test for asinhf -TYPE = DEFAULT -EXE1 = test1 -Description -= Passes a series of values to the asinhf() function, -= checking each for the expected result. Also checks -= for proper handling of out-of-range values. diff --git a/src/pal/tests/palsuite/c_runtime/atan/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/atan/CMakeLists.txt deleted file mode 100644 index 5e1ef7f28..000000000 --- a/src/pal/tests/palsuite/c_runtime/atan/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) diff --git a/src/pal/tests/palsuite/c_runtime/atan/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/atan/test1/CMakeLists.txt deleted file mode 100644 index ef6cca78d..000000000 --- a/src/pal/tests/palsuite/c_runtime/atan/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_atan_test1 - ${SOURCES} -) - -add_dependencies(paltest_atan_test1 coreclrpal) - -target_link_libraries(paltest_atan_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/atan/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/atan/test1/test1.cpp deleted file mode 100644 index 6840d4617..000000000 --- a/src/pal/tests/palsuite/c_runtime/atan/test1/test1.cpp +++ /dev/null @@ -1,128 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================= -** -** Source: test1.c -** -** Purpose: Test to ensure that atan return the correct values -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** Fail -** fabs -** -**===========================================================================*/ - -#include - -// binary64 (double) has a machine epsilon of 2^-52 (approx. 2.22e-16). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-50 (approx. 8.88e-16) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (15-17 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxxxxxxxxxx will use -// PAL_EPSILON for the variance, while an expected result in the format of 0.0xxxxxxxxxxxxxxxxx -// will use PAL_EPSILON / 10 and and expected result in the format of x.xxxxxxxxxxxxxxxx will -// use PAL_EPSILON * 10. -#define PAL_EPSILON 8.8817841970012523e-16 - -#define PAL_NAN sqrt(-1.0) -#define PAL_POSINF -log(0.0) -#define PAL_NEGINF log(0.0) - -/** - * Helper test structure - */ -struct test -{ - double value; /* value to test the function with */ - double expected; /* expected result */ - double variance; /* maximum delta between the expected and actual result */ -}; - -/** - * validate - * - * test validation function - */ -void __cdecl validate(double value, double expected, double variance) -{ - double result = atan(value); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - double delta = fabs(result - expected); - - if (delta > variance) - { - Fail("atan(%g) returned %20.17g when it should have returned %20.17g", - value, result, expected); - } -} - -/** - * validate - * - * test validation function for values returning NaN - */ -void __cdecl validate_isnan(double value) -{ - double result = atan(value); - - if (!_isnan(result)) - { - Fail("atan(%g) returned %20.17g when it should have returned %20.17g", - value, result, PAL_NAN); - } -} - -/** - * main - * - * executable entry point - */ -int __cdecl main(int argc, char **argv) -{ - struct test tests[] = - { - /* value expected variance */ - { 0, 0, PAL_EPSILON }, - { 0.32951473309607836, 0.31830988618379067, PAL_EPSILON }, // expected: 1 / pi - { 0.45054953406980750, 0.42331082513074800, PAL_EPSILON }, // expected: pi - e - { 0.46382906716062964, 0.43429448190325183, PAL_EPSILON }, // expected: log10(e) - { 0.73930295048660405, 0.63661977236758134, PAL_EPSILON }, // expected: 2 / pi - { 0.83064087786078395, 0.69314718055994531, PAL_EPSILON }, // expected: ln(2) - { 0.85451043200960189, 0.70710678118654752, PAL_EPSILON }, // expected: 1 / sqrt(2) - { 1, 0.78539816339744831, PAL_EPSILON }, // expected: pi / 4 - { 1.1134071468135374, 0.83900756059574755, PAL_EPSILON }, // expected: pi - ln(10) - { 1.5574077246549022, 1, PAL_EPSILON * 10 }, - { 2.1108768356626451, 1.1283791670955126, PAL_EPSILON * 10 }, // expected: 2 / sqrt(pi) - { 6.3341191670421916, 1.4142135623730950, PAL_EPSILON * 10 }, // expected: sqrt(2) - { 7.7635756709721848, 1.4426950408889634, PAL_EPSILON * 10 }, // expected: log2(e) - { PAL_POSINF, 1.5707963267948966, PAL_EPSILON * 10 }, // expected: pi / 2 - }; - - /* PAL initialization */ - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - validate( tests[i].value, tests[i].expected, tests[i].variance); - validate(-tests[i].value, -tests[i].expected, tests[i].variance); - } - - validate_isnan(PAL_NAN); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/atan/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/atan/test1/testinfo.dat deleted file mode 100644 index 8a181b8a9..000000000 --- a/src/pal/tests/palsuite/c_runtime/atan/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = atan -Name = Positive Test for atan -TYPE = DEFAULT -EXE1 = test1 -Description -= Passes a series of values to the atan() function, -= checking each for the expected result. diff --git a/src/pal/tests/palsuite/c_runtime/atan2/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/atan2/CMakeLists.txt deleted file mode 100644 index 5e1ef7f28..000000000 --- a/src/pal/tests/palsuite/c_runtime/atan2/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) diff --git a/src/pal/tests/palsuite/c_runtime/atan2/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/atan2/test1/CMakeLists.txt deleted file mode 100644 index 4246b3730..000000000 --- a/src/pal/tests/palsuite/c_runtime/atan2/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_atan2_test1 - ${SOURCES} -) - -add_dependencies(paltest_atan2_test1 coreclrpal) - -target_link_libraries(paltest_atan2_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/atan2/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/atan2/test1/test1.cpp deleted file mode 100644 index 15aa8f53b..000000000 --- a/src/pal/tests/palsuite/c_runtime/atan2/test1/test1.cpp +++ /dev/null @@ -1,148 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test1.c -** -** Purpose: Tests that atan2 returns correct values for a subset of values. -** Tests with positive and negative values of x and y to ensure -** atan2 is returning results from the correct quadrant. -** -**===================================================================*/ - -#include - -// binary64 (double) has a machine epsilon of 2^-52 (approx. 2.22e-16). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-50 (approx. 8.88e-16) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (15-17 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxxxxxxxxxx will use -// PAL_EPSILON for the variance, while an expected result in the format of 0.0xxxxxxxxxxxxxxxxx -// will use PAL_EPSILON / 10 and and expected result in the format of x.xxxxxxxxxxxxxxxx will -// use PAL_EPSILON * 10. -#define PAL_EPSILON 8.8817841970012523e-16 - -#define PAL_NAN sqrt(-1.0) -#define PAL_POSINF -log(0.0) -#define PAL_NEGINF log(0.0) - -struct test -{ - double y; /* second component of the value to test the function with */ - double x; /* first component of the value to test the function with */ - double expected; /* expected result */ - double variance; /* maximum delta between the expected and actual result */ -}; - -/** - * validate - * - * test validation function - */ -void __cdecl validate(double y, double x, double expected, double variance) -{ - double result = atan2(y, x); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - double delta = fabs(result - expected); - - if (delta > variance) - { - Fail("atan2(%g, %g) returned %20.17g when it should have returned %20.17g", - y, x, result, expected); - } -} - -/** - * validate - * - * test validation function for values returning NaN - */ -void __cdecl validate_isnan(double y, double x) -{ - double result = atan2(y, x); - - if (!_isnan(result)) - { - Fail("atan2(%g, %g) returned %20.17g when it should have returned %20.17g", - y, x, result, PAL_NAN); - } -} - -/** - * main - * - * executable entry point - */ -int __cdecl main(int argc, char **argv) -{ - struct test tests[] = - { - /* y x expected variance */ - { 0, PAL_POSINF, 0, PAL_EPSILON }, - { 0, 0, 0, PAL_EPSILON }, - { 0.31296179620778659, 0.94976571538163866, 0.31830988618379067, PAL_EPSILON }, // expected: 1 / pi - { 0.42077048331375735, 0.90716712923909839, 0.43429448190325183, PAL_EPSILON }, // expected: log10(e) - { 0.59448076852482208, 0.80410982822879171, 0.63661977236758134, PAL_EPSILON }, // expected: 2 / pi - { 0.63896127631363480, 0.76923890136397213, 0.69314718055994531, PAL_EPSILON }, // expected: ln(2) - { 0.64963693908006244, 0.76024459707563015, 0.70710678118654752, PAL_EPSILON }, // expected: 1 / sqrt(2) - { 0.70710678118654752, 0.70710678118654752, 0.78539816339744831, PAL_EPSILON }, // expected: pi / 4, value: 1 / sqrt(2) - { 1, 1, 0.78539816339744831, PAL_EPSILON }, // expected: pi / 4 - { PAL_POSINF, PAL_POSINF, 0.78539816339744831, PAL_EPSILON }, // expected: pi / 4 - { 0.84147098480789651, 0.54030230586813972, 1, PAL_EPSILON * 10 }, - { 0.90371945743584630, 0.42812514788535792, 1.1283791670955126, PAL_EPSILON * 10 }, // expected: 2 / sqrt(pi) - { 0.98776594599273553, 0.15594369476537447, 1.4142135623730950, PAL_EPSILON * 10 }, // expected: sqrt(2) - { 0.99180624439366372, 0.12775121753523991, 1.4426950408889634, PAL_EPSILON * 10 }, // expected: log2(e) - { 1, 0, 1.5707963267948966, PAL_EPSILON * 10 }, // expected: pi / 2 - { PAL_POSINF, 0, 1.5707963267948966, PAL_EPSILON * 10 }, // expected: pi / 2 - { PAL_POSINF, 1, 1.5707963267948966, PAL_EPSILON * 10 }, // expected: pi / 2 - { 0.74398033695749319, -0.66820151019031295, 2.3025850929940457, PAL_EPSILON * 10 }, // expected: ln(10) - { 0.41078129050290870, -0.91173391478696510, 2.7182818284590452, PAL_EPSILON * 10 }, // expected: e - { 0, -1, 3.1415926535897932, PAL_EPSILON * 10 }, // expected: pi - { 1, PAL_POSINF, 0, PAL_EPSILON }, - }; - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - const double pi = 3.1415926535897932; - - validate( tests[i].y, tests[i].x, tests[i].expected, tests[i].variance); - validate(-tests[i].y, tests[i].x, -tests[i].expected, tests[i].variance); - validate( tests[i].y, -tests[i].x, pi - tests[i].expected, tests[i].variance); - validate(-tests[i].y, -tests[i].x, tests[i].expected - pi, tests[i].variance); - } - - validate_isnan(PAL_NEGINF, PAL_NAN); - validate_isnan(PAL_NAN, PAL_NEGINF); - validate_isnan(PAL_NAN, PAL_POSINF); - validate_isnan(PAL_POSINF, PAL_NAN); - - validate_isnan(PAL_NAN, -1); - validate_isnan(PAL_NAN, -0.0); - validate_isnan(PAL_NAN, 0); - validate_isnan(PAL_NAN, 1); - - validate_isnan(-1, PAL_NAN); - validate_isnan(-0.0, PAL_NAN); - validate_isnan( 0, PAL_NAN); - validate_isnan( 1, PAL_NAN); - - validate_isnan(PAL_NAN, PAL_NAN); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/atan2/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/atan2/test1/testinfo.dat deleted file mode 100644 index 78fb09118..000000000 --- a/src/pal/tests/palsuite/c_runtime/atan2/test1/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = atan2 -Name = Test #1 for atan2 -Type = DEFAULT -EXE1 = test1 -Description -=Tests that atan2 returns correct values for a subset of values. -=Tests with positive and negative values of x and y to ensure -=atan2 is returning results from the correct quadrant. diff --git a/src/pal/tests/palsuite/c_runtime/atan2f/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/atan2f/CMakeLists.txt deleted file mode 100644 index 5e1ef7f28..000000000 --- a/src/pal/tests/palsuite/c_runtime/atan2f/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) diff --git a/src/pal/tests/palsuite/c_runtime/atan2f/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/atan2f/test1/CMakeLists.txt deleted file mode 100644 index d70946ea8..000000000 --- a/src/pal/tests/palsuite/c_runtime/atan2f/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.c -) - -add_executable(paltest_atan2f_test1 - ${SOURCES} -) - -add_dependencies(paltest_atan2f_test1 coreclrpal) - -target_link_libraries(paltest_atan2f_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/atan2f/test1/test1.c b/src/pal/tests/palsuite/c_runtime/atan2f/test1/test1.c deleted file mode 100644 index 2ee641e8d..000000000 --- a/src/pal/tests/palsuite/c_runtime/atan2f/test1/test1.c +++ /dev/null @@ -1,147 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test1.c -** -** Purpose: Tests that atan2f returns correct values for a subset of values. -** Tests with positive and negative values of x and y to ensure -** atan2f is returning results from the correct quadrant. -** -**===================================================================*/ - -#include - -// binary32 (float) has a machine epsilon of 2^-23 (approx. 1.19e-07). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-21 (approx. 4.76e-07) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (6-9 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxx will use PAL_EPSILON -// for the variance, while an expected result in the format of 0.0xxxxxxxxx will use -// PAL_EPSILON / 10 and and expected result in the format of x.xxxxxx will use PAL_EPSILON * 10. -#define PAL_EPSILON 4.76837158e-07 - -#define PAL_NAN sqrtf(-1.0f) -#define PAL_POSINF -logf(0.0f) -#define PAL_NEGINF logf(0.0f) - -struct test -{ - float y; /* second component of the value to test the function with */ - float x; /* first component of the value to test the function with */ - float expected; /* expected result */ - float variance; /* maximum delta between the expected and actual result */ -}; - -/** - * validate - * - * test validation function - */ -void __cdecl validate(float y, float x, float expected, float variance) -{ - float result = atan2f(y, x); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - float delta = fabsf(result - expected); - - if (delta > variance) - { - Fail("atan2f(%g, %g) returned %10.9g when it should have returned %10.9g", - y, x, result, expected); - } -} - -/** - * validate - * - * test validation function for values returning NaN - */ -void __cdecl validate_isnan(float y, float x) -{ - float result = atan2f(y, x); - - if (!_isnanf(result)) - { - Fail("atan2f(%g, %g) returned %10.9g when it should have returned %10.9g", - y, x, result, PAL_NAN); - } -} - -/** - * main - * - * executable entry point - */ -int __cdecl main(int argc, char **argv) -{ - struct test tests[] = - { - /* y x expected variance */ - { 0, PAL_POSINF, 0, PAL_EPSILON }, - { 0, 0, 0, PAL_EPSILON }, - { 0.312961796f, 0.949765715f, 0.318309886f, PAL_EPSILON }, // expected: 1 / pi - { 0.420770483f, 0.907167129f, 0.434294482f, PAL_EPSILON }, // expected: logf10f(e) - { 0.594480769f, 0.804109828f, 0.636619772f, PAL_EPSILON }, // expected: 2 / pi - { 0.638961276f, 0.769238901f, 0.693147181f, PAL_EPSILON }, // expected: ln(2) - { 0.649636939f, 0.760244597f, 0.707106781f, PAL_EPSILON }, // expected: 1 / sqrtf(2) - { 0.707106781f, 0.707106781f, 0.785398163f, PAL_EPSILON }, // expected: pi / 4, value: 1 / sqrtf(2) - { 1, 1, 0.785398163f, PAL_EPSILON }, // expected: pi / 4 - { PAL_POSINF, PAL_POSINF, 0.785398163f, PAL_EPSILON }, // expected: pi / 4 - { 0.841470985f, 0.540302306f, 1, PAL_EPSILON * 10 }, - { 0.903719457f, 0.428125148f, 1.12837917f, PAL_EPSILON * 10 }, // expected: 2 / sqrtf(pi) - { 0.987765946f, 0.155943695f, 1.41421356f, PAL_EPSILON * 10 }, // expected: sqrtf(2) - { 0.991806244f, 0.127751218f, 1.44269504f, PAL_EPSILON * 10 }, // expected: logf2(e) - { 1, 0, 1.57079633f, PAL_EPSILON * 10 }, // expected: pi / 2 - { PAL_POSINF, 0, 1.57079633f, PAL_EPSILON * 10 }, // expected: pi / 2 - { PAL_POSINF, 1, 1.57079633f, PAL_EPSILON * 10 }, // expected: pi / 2 - { 0.743980337f, -0.668201510f, 2.30258509f, PAL_EPSILON * 10 }, // expected: ln(10) - { 0.410781291f, -0.911733915f, 2.71828183f, PAL_EPSILON * 10 }, // expected: e - { 0, -1, 3.14159265f, PAL_EPSILON * 10 }, // expected: pi - { 1, PAL_POSINF, 0, PAL_EPSILON }, - }; - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - const float pi = 3.14159265f; - - validate( tests[i].y, tests[i].x, tests[i].expected, tests[i].variance); - validate(-tests[i].y, tests[i].x, -tests[i].expected, tests[i].variance); - validate( tests[i].y, -tests[i].x, pi - tests[i].expected, tests[i].variance); - validate(-tests[i].y, -tests[i].x, tests[i].expected - pi, tests[i].variance); - } - - validate_isnan(PAL_NEGINF, PAL_NAN); - validate_isnan(PAL_NAN, PAL_NEGINF); - validate_isnan(PAL_NAN, PAL_POSINF); - validate_isnan(PAL_POSINF, PAL_NAN); - - validate_isnan(PAL_NAN, -1); - validate_isnan(PAL_NAN, -0.0f); - validate_isnan(PAL_NAN, 0); - validate_isnan(PAL_NAN, 1); - - validate_isnan(-1, PAL_NAN); - validate_isnan(-0.0f, PAL_NAN); - validate_isnan( 0, PAL_NAN); - validate_isnan( 1, PAL_NAN); - - validate_isnan(PAL_NAN, PAL_NAN); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/atan2f/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/atan2f/test1/testinfo.dat deleted file mode 100644 index bd9a9d9b9..000000000 --- a/src/pal/tests/palsuite/c_runtime/atan2f/test1/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = atan2f -Name = Test #1 for atan2f -Type = DEFAULT -EXE1 = test1 -Description -=Tests that atan2f returns correct values for a subset of values. -=Tests with positive and negative values of x and y to ensure -=atan2f is returning results from the correct quadrant. diff --git a/src/pal/tests/palsuite/c_runtime/atanf/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/atanf/CMakeLists.txt deleted file mode 100644 index 5e1ef7f28..000000000 --- a/src/pal/tests/palsuite/c_runtime/atanf/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) diff --git a/src/pal/tests/palsuite/c_runtime/atanf/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/atanf/test1/CMakeLists.txt deleted file mode 100644 index 2a08f6d73..000000000 --- a/src/pal/tests/palsuite/c_runtime/atanf/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.c -) - -add_executable(paltest_atanf_test1 - ${SOURCES} -) - -add_dependencies(paltest_atanf_test1 coreclrpal) - -target_link_libraries(paltest_atanf_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/atanf/test1/test1.c b/src/pal/tests/palsuite/c_runtime/atanf/test1/test1.c deleted file mode 100644 index 543a0a816..000000000 --- a/src/pal/tests/palsuite/c_runtime/atanf/test1/test1.c +++ /dev/null @@ -1,127 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================= -** -** Source: test1.c -** -** Purpose: Test to ensure that atanf return the correct values -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** Fail -** fabs -** -**===========================================================================*/ - -#include - -// binary32 (float) has a machine epsilon of 2^-23 (approx. 1.19e-07). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-21 (approx. 4.76e-07) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (6-9 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxx will use PAL_EPSILON -// for the variance, while an expected result in the format of 0.0xxxxxxxxx will use -// PAL_EPSILON / 10 and and expected result in the format of x.xxxxxx will use PAL_EPSILON * 10. -#define PAL_EPSILON 4.76837158e-07 - -#define PAL_NAN sqrtf(-1.0f) -#define PAL_POSINF -logf(0.0f) -#define PAL_NEGINF logf(0.0f) - -/** - * Helper test structure - */ -struct test -{ - float value; /* value to test the function with */ - float expected; /* expected result */ - float variance; /* maximum delta between the expected and actual result */ -}; - -/** - * validate - * - * test validation function - */ -void __cdecl validate(float value, float expected, float variance) -{ - float result = atanf(value); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - float delta = fabsf(result - expected); - - if (delta > variance) - { - Fail("atanf(%g) returned %10.9g when it should have returned %10.9g", - value, result, expected); - } -} - -/** - * validate - * - * test validation function for values returning NaN - */ -void __cdecl validate_isnan(float value) -{ - float result = atanf(value); - - if (!_isnanf(result)) - { - Fail("atanf(%g) returned %10.9g when it should have returned %10.9g", - value, result, PAL_NAN); - } -} - -/** - * main - * - * executable entry point - */ -int __cdecl main(int argc, char **argv) -{ - struct test tests[] = - { - /* value expected variance */ - { 0, 0, PAL_EPSILON }, - { 0.329514733f, 0.318309886f, PAL_EPSILON }, // expected: 1 / pi - { 0.450549534f, 0.423310825f, PAL_EPSILON }, // expected: pi - e - { 0.463829067f, 0.434294482f, PAL_EPSILON }, // expected: logf10f(e) - { 0.739302950f, 0.636619772f, PAL_EPSILON }, // expected: 2 / pi - { 0.830640878f, 0.693147181f, PAL_EPSILON }, // expected: ln(2) - { 0.854510432f, 0.707106781f, PAL_EPSILON }, // expected: 1 / sqrtf(2) - { 1, 0.785398163f, PAL_EPSILON }, // expected: pi / 4 - { 1.11340715f, 0.839007561f, PAL_EPSILON }, // expected: pi - ln(10) - { 1.55740772f, 1, PAL_EPSILON * 10 }, - { 2.11087684f, 1.12837917f, PAL_EPSILON * 10 }, // expected: 2 / sqrtf(pi) - { 6.33411917f, 1.41421356f, PAL_EPSILON * 10 }, // expected: sqrtf(2) - { 7.76357567f, 1.44269504f, PAL_EPSILON * 10 }, // expected: logf2(e) - { PAL_POSINF, 1.57079633f, PAL_EPSILON * 10 }, // expected: pi / 2 - }; - - /* PAL initialization */ - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - validate( tests[i].value, tests[i].expected, tests[i].variance); - validate(-tests[i].value, -tests[i].expected, tests[i].variance); - } - - validate_isnan(PAL_NAN); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/atanf/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/atanf/test1/testinfo.dat deleted file mode 100644 index 0d184272a..000000000 --- a/src/pal/tests/palsuite/c_runtime/atanf/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = atanf -Name = Positive Test for atanf -TYPE = DEFAULT -EXE1 = test1 -Description -= Passes a series of values to the atanf() function, -= checking each for the expected result. diff --git a/src/pal/tests/palsuite/c_runtime/atanh/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/atanh/CMakeLists.txt deleted file mode 100644 index 5e1ef7f28..000000000 --- a/src/pal/tests/palsuite/c_runtime/atanh/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) diff --git a/src/pal/tests/palsuite/c_runtime/atanh/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/atanh/test1/CMakeLists.txt deleted file mode 100644 index 62b76943f..000000000 --- a/src/pal/tests/palsuite/c_runtime/atanh/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_atanh_test1 - ${SOURCES} -) - -add_dependencies(paltest_atanh_test1 coreclrpal) - -target_link_libraries(paltest_atanh_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/atanh/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/atanh/test1/test1.cpp deleted file mode 100644 index d454f3272..000000000 --- a/src/pal/tests/palsuite/c_runtime/atanh/test1/test1.cpp +++ /dev/null @@ -1,130 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================= -** -** Source: test1.c -** -** Purpose: Test to ensure that atanh return the correct values -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** Fail -** fabs -** -**===========================================================================*/ - -#include - -// binary64 (double) has a machine epsilon of 2^-52 (approx. 2.22e-16). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-50 (approx. 8.88e-16) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (15-17 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxxxxxxxxxx will use -// PAL_EPSILON for the variance, while an expected result in the format of 0.0xxxxxxxxxxxxxxxxx -// will use PAL_EPSILON / 10 and and expected result in the format of x.xxxxxxxxxxxxxxxx will -// use PAL_EPSILON * 10. -#define PAL_EPSILON 8.8817841970012523e-16 - -#define PAL_NAN sqrt(-1.0) -#define PAL_POSINF -log(0.0) -#define PAL_NEGINF log(0.0) - -/** - * Helper test structure - */ -struct test -{ - double value; /* value to test the function with */ - double expected; /* expected result */ - double variance; /* maximum delta between the expected and actual result */ -}; - -/** - * validate - * - * test validation function - */ -void __cdecl validate(double value, double expected, double variance) -{ - double result = atanh(value); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - double delta = fabs(result - expected); - - if (delta > variance) - { - Fail("atanh(%g) returned %20.17g when it should have returned %20.17g", - value, result, expected); - } -} - -/** - * validate - * - * test validation function for values returning NaN - */ -void __cdecl validate_isnan(double value) -{ - double result = atanh(value); - - if (!_isnan(result)) - { - Fail("atanh(%g) returned %20.17g when it should have returned %20.17g", - value, result, PAL_NAN); - } -} - -/** - * main - * - * executable entry point - */ -int __cdecl main(int argc, char **argv) -{ - struct test tests[] = - { - /* value expected variance */ - { 0, 0, PAL_EPSILON }, - { 0.30797791269089433, 0.31830988618379067, PAL_EPSILON }, // expected: 1 / pi - { 0.40890401183401433, 0.43429448190325183, PAL_EPSILON }, // expected: log10(e) - { 0.56259360033158334, 0.63661977236758134, PAL_EPSILON }, // expected: 2 / pi - { 0.6, 0.69314718055994531, PAL_EPSILON }, // expected: ln(2) - { 0.60885936501391381, 0.70710678118654752, PAL_EPSILON }, // expected: 1 / sqrt(2) - { 0.65579420263267244, 0.78539816339744831, PAL_EPSILON }, // expected: pi / 4 - { 0.76159415595576489, 1, PAL_EPSILON * 10 }, - { 0.81046380599898809, 1.1283791670955126, PAL_EPSILON * 10 }, // expected: 2 / sqrt(pi) - { 0.88838556158566054, 1.4142135623730950, PAL_EPSILON * 10 }, // expected: sqrt(2) - { 0.89423894585503855, 1.4426950408889634, PAL_EPSILON * 10 }, // expected: log2(e) - { 0.91715233566727435, 1.5707963267948966, PAL_EPSILON * 10 }, // expected: pi / 2 - { 0.98019801980198020, 2.3025850929940457, PAL_EPSILON * 10 }, // expected: ln(10) - { 0.99132891580059984, 2.7182818284590452, PAL_EPSILON * 10 }, // expected: e - { 0.99627207622074994, 3.1415926535897932, PAL_EPSILON * 10 }, // expected: pi - { 1, PAL_POSINF, PAL_EPSILON * 10 } - }; - - /* PAL initialization */ - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - validate( tests[i].value, tests[i].expected, tests[i].variance); - validate(-tests[i].value, -tests[i].expected, tests[i].variance); - } - - validate_isnan(PAL_NAN); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/atanh/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/atanh/test1/testinfo.dat deleted file mode 100644 index 55e1db7c0..000000000 --- a/src/pal/tests/palsuite/c_runtime/atanh/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = atanh -Name = Positive Test for atanh -TYPE = DEFAULT -EXE1 = test1 -Description -= Passes a series of values to the atanh() function, -= checking each for the expected result. diff --git a/src/pal/tests/palsuite/c_runtime/atanhf/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/atanhf/CMakeLists.txt deleted file mode 100644 index 5e1ef7f28..000000000 --- a/src/pal/tests/palsuite/c_runtime/atanhf/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) diff --git a/src/pal/tests/palsuite/c_runtime/atanhf/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/atanhf/test1/CMakeLists.txt deleted file mode 100644 index 07809ee52..000000000 --- a/src/pal/tests/palsuite/c_runtime/atanhf/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.c -) - -add_executable(paltest_atanhf_test1 - ${SOURCES} -) - -add_dependencies(paltest_atanhf_test1 coreclrpal) - -target_link_libraries(paltest_atanhf_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/atanhf/test1/test1.c b/src/pal/tests/palsuite/c_runtime/atanhf/test1/test1.c deleted file mode 100644 index 3fd3ab8bd..000000000 --- a/src/pal/tests/palsuite/c_runtime/atanhf/test1/test1.c +++ /dev/null @@ -1,129 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================= -** -** Source: test1.c -** -** Purpose: Test to ensure that atanhf return the correct values -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** Fail -** fabs -** -**===========================================================================*/ - -#include - -// binary32 (float) has a machine epsilon of 2^-23 (approx. 1.19e-07). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-21 (approx. 4.76e-07) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (6-9 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxx will use PAL_EPSILON -// for the variance, while an expected result in the format of 0.0xxxxxxxxx will use -// PAL_EPSILON / 10 and and expected result in the format of x.xxxxxx will use PAL_EPSILON * 10. -#define PAL_EPSILON 4.76837158e-07 - -#define PAL_NAN sqrtf(-1.0f) -#define PAL_POSINF -logf(0.0f) -#define PAL_NEGINF logf(0.0f) - -/** - * Helper test structure - */ -struct test -{ - float value; /* value to test the function with */ - float expected; /* expected result */ - float variance; /* maximum delta between the expected and actual result */ -}; - -/** - * validate - * - * test validation function - */ -void __cdecl validate(float value, float expected, float variance) -{ - float result = atanhf(value); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - float delta = fabsf(result - expected); - - if (delta > variance) - { - Fail("atanhf(%g) returned %10.9g when it should have returned %10.9g", - value, result, expected); - } -} - -/** - * validate - * - * test validation function for values returning NaN - */ -void __cdecl validate_isnan(float value) -{ - float result = atanhf(value); - - if (!_isnanf(result)) - { - Fail("atanhf(%g) returned %10.9g when it should have returned %10.9g", - value, result, PAL_NAN); - } -} - -/** - * main - * - * executable entry point - */ -int __cdecl main(int argc, char **argv) -{ - struct test tests[] = - { - /* value expected variance */ - { 0, 0, PAL_EPSILON }, - { 0.307977913f, 0.318309886f, PAL_EPSILON }, // expected: 1 / pi - { 0.408904012f, 0.434294482f, PAL_EPSILON }, // expected: log10f(e) - { 0.562593600f, 0.636619772f, PAL_EPSILON }, // expected: 2 / pi - { 0.6f, 0.693147181f, PAL_EPSILON }, // expected: ln(2) - { 0.608859365f, 0.707106781f, PAL_EPSILON }, // expected: 1 / sqrtf(2) - { 0.655794203f, 0.785398163f, PAL_EPSILON }, // expected: pi / 4 - { 0.761594156f, 1, PAL_EPSILON * 10 }, - { 0.810463806f, 1.12837917f, PAL_EPSILON * 10 }, // expected: 2 / sqrtf(pi) - { 0.888385562f, 1.41421356f, PAL_EPSILON * 10 }, // expected: sqrtf(2) - { 0.894238946f, 1.44269504f, PAL_EPSILON * 10 }, // expected: logf2(e) - { 0.917152336f, 1.57079633f, PAL_EPSILON * 10 }, // expected: pi / 2 - { 0.980198020f, 2.30258509f, PAL_EPSILON * 10 }, // expected: ln(10) - { 0.991328916f, 2.71828183f, PAL_EPSILON * 10 }, // expected: e - { 0.996272076f, 3.14159265f, PAL_EPSILON * 10 }, // expected: pi - { 1, PAL_POSINF, PAL_EPSILON * 10 } - }; - - /* PAL initialization */ - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - validate( tests[i].value, tests[i].expected, tests[i].variance); - validate(-tests[i].value, -tests[i].expected, tests[i].variance); - } - - validate_isnan(PAL_NAN); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/atanhf/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/atanhf/test1/testinfo.dat deleted file mode 100644 index 842c0d9ec..000000000 --- a/src/pal/tests/palsuite/c_runtime/atanhf/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = atanhf -Name = Positive Test for atanhf -TYPE = DEFAULT -EXE1 = test1 -Description -= Passes a series of values to the atanhf() function, -= checking each for the expected result. diff --git a/src/pal/tests/palsuite/c_runtime/atof/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/atof/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/c_runtime/atof/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/c_runtime/atof/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/atof/test1/CMakeLists.txt deleted file mode 100644 index 4917e424d..000000000 --- a/src/pal/tests/palsuite/c_runtime/atof/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_atof_test1 - ${SOURCES} -) - -add_dependencies(paltest_atof_test1 coreclrpal) - -target_link_libraries(paltest_atof_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/atof/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/atof/test1/test1.cpp deleted file mode 100644 index a973133f9..000000000 --- a/src/pal/tests/palsuite/c_runtime/atof/test1/test1.cpp +++ /dev/null @@ -1,75 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: Passes to atof() a series of strings containing floats, -** checking that each one is correctly extracted. -** -** -**==========================================================================*/ - -#include -#include - -struct testCase -{ - float fvalue; - char avalue[20]; -}; - -int __cdecl main(int argc, char **argv) -{ - int i = 0; - double f = 0; - struct testCase testCases[] = - { - {1234, "1234"}, - {-1234, "-1234"}, - {1234e-5, "1234e-5"}, - {1234e+5, "1234e+5"}, - {1234e5, "1234E5"}, - {1234.567e-8, "1234.567e-8"}, - {1234.567e-8, " 1234.567e-8 foo"}, - {0,"a12"} - }; - - /* - * Initialize the PAL and return FAIL if this fails - */ - if (0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - for(i = 0; i < sizeof(testCases) / sizeof(struct testCase); i++) - { - /*Convert the string to a float.*/ - f = atof(testCases[i].avalue); - double result = f - testCases[i].fvalue; - - if (fabs(result) > FLT_EPSILON) - { - Fail ("atof misinterpreted \"%s\" as %g instead of %g. result %g fabs %g\n", - testCases[i].avalue, f, testCases[i].fvalue, result, fabs(result)); - } - } - PAL_Terminate(); - return PASS; -} - - - - - - - - - - - - - diff --git a/src/pal/tests/palsuite/c_runtime/atof/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/atof/test1/testinfo.dat deleted file mode 100644 index 7f37affb9..000000000 --- a/src/pal/tests/palsuite/c_runtime/atof/test1/testinfo.dat +++ /dev/null @@ -1,16 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = atof -Name = Positive Test for atof -TYPE = DEFAULT -EXE1 = test1 -Description -= Passes to atof() a series of strings containing floats, checking that -= each one is correctly extracted. - - - diff --git a/src/pal/tests/palsuite/c_runtime/atoi/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/atoi/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/c_runtime/atoi/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/c_runtime/atoi/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/atoi/test1/CMakeLists.txt deleted file mode 100644 index d545811b9..000000000 --- a/src/pal/tests/palsuite/c_runtime/atoi/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_atoi_test1 - ${SOURCES} -) - -add_dependencies(paltest_atoi_test1 coreclrpal) - -target_link_libraries(paltest_atoi_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/atoi/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/atoi/test1/test1.cpp deleted file mode 100644 index 2554d4c35..000000000 --- a/src/pal/tests/palsuite/c_runtime/atoi/test1/test1.cpp +++ /dev/null @@ -1,86 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test1.c -** -** Purpose: Tests the PAL implementation of the atoi function. -** Check to ensure that the different ints (normal, -** negative, decimal,exponent), all work as expected with -** this function. -** -** -**===================================================================*/ - -#include - - -struct testCase -{ - int IntValue; - char avalue[20]; -}; - -int __cdecl main(int argc, char **argv) -{ - - int result=0; - int i=0; - - struct testCase testCases[] = - { - {1234, "1234"}, - {-1234, "-1234"}, - {1234, "1234.44"}, - {1234, "1234e-5"}, - {1234, "1234e+5"}, - {1234, "1234E5"}, - {1234, "1234.657e-8"}, - {1234567, " 1234567e-8 foo"}, - {0, "aaa 32 test"} - }; - - /* - * Initialize the PAL and return FAIL if this fails - */ - if (0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - /* Loop through each case. Convert the string to an int - and then compare to ensure that it is the correct value. - */ - - for(i = 0; i < sizeof(testCases) / sizeof(struct testCase); i++) - { - /*Convert the string to an int.*/ - result = atoi(testCases[i].avalue); - - if (testCases[i].IntValue != result) - { - Fail("ERROR: atoi misinterpreted \"%s\" as %i instead of %i.\n" - , testCases[i].avalue, result, testCases[i].IntValue); - } - - } - - - PAL_Terminate(); - return PASS; -} - - - - - - - - - - - - - diff --git a/src/pal/tests/palsuite/c_runtime/atoi/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/atoi/test1/testinfo.dat deleted file mode 100644 index 36a1a4499..000000000 --- a/src/pal/tests/palsuite/c_runtime/atoi/test1/testinfo.dat +++ /dev/null @@ -1,17 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = atoi -Name = Positive Test for atoi -TYPE = DEFAULT -EXE1 = test1 -Description -= Tests the PAL implementation of the atoi function. -= Check to ensure that the different ints (normal, negative, decimal, -= exponent), all work as expected with this function. - - - diff --git a/src/pal/tests/palsuite/c_runtime/atol/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/atol/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/c_runtime/atol/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/c_runtime/atol/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/atol/test1/CMakeLists.txt deleted file mode 100644 index 0335137eb..000000000 --- a/src/pal/tests/palsuite/c_runtime/atol/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_atol_test1 - ${SOURCES} -) - -add_dependencies(paltest_atol_test1 coreclrpal) - -target_link_libraries(paltest_atol_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/atol/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/atol/test1/test1.cpp deleted file mode 100644 index 5ad85d873..000000000 --- a/src/pal/tests/palsuite/c_runtime/atol/test1/test1.cpp +++ /dev/null @@ -1,88 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test1.c -** -** Purpose: Tests the PAL implementation of the atol function. -** Check to ensure that the different ints (normal, -** negative, decimal,exponent), all work as expected with -** this function. -** -** -**===================================================================*/ - -#include - -struct testCase -{ - LONG LongValue; - char avalue[20]; -}; - -int __cdecl main(int argc, char **argv) -{ - - LONG result=0; - int i=0; - - struct testCase testCases[] = - { - {1234, "1234"}, - {-1234, "-1234"}, - {1234, "1234.44"}, - {1234, "1234e-5"}, - {1234, "1234e+5"}, - {1234, "1234E5"}, - {1234, "1234.657e-8"}, - {1234, "1234d-5"}, - {1234, "1234d+5"}, - {1234, "1234D5"}, - {1234567, " 1234567e-8 foo"}, - {0, "aaa 32 test"} - }; - - /* - * Initialize the PAL and return FAIL if this fails - */ - if (0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - /* Loop through each case. Convert the string to a LONG - and then compare to ensure that it is the correct value. - */ - - for(i = 0; i < sizeof(testCases) / sizeof(struct testCase); i++) - { - /*Convert the string to a LONG.*/ - result = atol(testCases[i].avalue); - - if (testCases[i].LongValue != result) - { - Fail("ERROR: atol misinterpreted \"%s\" as %d instead of %d.\n" - , testCases[i].avalue, result, testCases[i].LongValue); - } - - } - - - PAL_Terminate(); - return PASS; -} - - - - - - - - - - - - - diff --git a/src/pal/tests/palsuite/c_runtime/atol/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/atol/test1/testinfo.dat deleted file mode 100644 index 962a1676a..000000000 --- a/src/pal/tests/palsuite/c_runtime/atol/test1/testinfo.dat +++ /dev/null @@ -1,17 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = atol -Name = Positive Test for atol -TYPE = DEFAULT -EXE1 = test1 -Description -= Tests the PAL implementation of the atol function. -= Check to ensure that the different ints (normal, negative, decimal, -= exponent), all work as expected with this function. - - - diff --git a/src/pal/tests/palsuite/c_runtime/bsearch/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/bsearch/CMakeLists.txt deleted file mode 100644 index ef14ea535..000000000 --- a/src/pal/tests/palsuite/c_runtime/bsearch/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) - diff --git a/src/pal/tests/palsuite/c_runtime/bsearch/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/bsearch/test1/CMakeLists.txt deleted file mode 100644 index a1242e6a3..000000000 --- a/src/pal/tests/palsuite/c_runtime/bsearch/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_bsearch_test1 - ${SOURCES} -) - -add_dependencies(paltest_bsearch_test1 coreclrpal) - -target_link_libraries(paltest_bsearch_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/bsearch/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/bsearch/test1/test1.cpp deleted file mode 100644 index c4b91738e..000000000 --- a/src/pal/tests/palsuite/c_runtime/bsearch/test1/test1.cpp +++ /dev/null @@ -1,48 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: Calls bsearch to find a character in a sorted buffer, and -** verifies that the correct position is returned. -** -** -**==========================================================================*/ - -#include - -int __cdecl charcmp(const void *pa, const void *pb) -{ - return memcmp(pa, pb, 1); -} - -int __cdecl main(int argc, char **argv) -{ - - const char array[] = "abcdefghij"; - char * found=NULL; - - /* - * Initialize the PAL and return FAIL if this fails - */ - if (0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - found = (char *)bsearch(&"d", array, sizeof(array) - 1, (sizeof(char)) - , charcmp); - if (found != array + 3) - { - Fail ("bsearch was unable to find a specified character in a " - "sorted list.\n"); - } - PAL_Terminate(); - return PASS; -} - - - diff --git a/src/pal/tests/palsuite/c_runtime/bsearch/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/bsearch/test1/testinfo.dat deleted file mode 100644 index 3eb7369ac..000000000 --- a/src/pal/tests/palsuite/c_runtime/bsearch/test1/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = bsearch -Name = Positive Test for bsearch -TYPE = DEFAULT -EXE1 = test1 -Description -= Calls bsearch to find a character in a sorted buffer, and -= verifies that the correct position is returned. - diff --git a/src/pal/tests/palsuite/c_runtime/bsearch/test2/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/bsearch/test2/CMakeLists.txt deleted file mode 100644 index 167b8aac6..000000000 --- a/src/pal/tests/palsuite/c_runtime/bsearch/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test2.cpp -) - -add_executable(paltest_bsearch_test2 - ${SOURCES} -) - -add_dependencies(paltest_bsearch_test2 coreclrpal) - -target_link_libraries(paltest_bsearch_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/bsearch/test2/test2.cpp b/src/pal/tests/palsuite/c_runtime/bsearch/test2/test2.cpp deleted file mode 100644 index 6de1b3fad..000000000 --- a/src/pal/tests/palsuite/c_runtime/bsearch/test2/test2.cpp +++ /dev/null @@ -1,57 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: Calls bsearch to find a character in a sorted buffer, -** that does not exist. -** -** -**==========================================================================*/ - -#include - -int __cdecl charcmp(const void *pa, const void *pb) -{ - return *(const char *)pa - *(const char *)pb; -} - -int __cdecl main(int argc, char **argv) -{ - - const char array[] = "abcefghij"; - const char missing[] = "0dz"; - char * found=NULL; - const char * candidate = missing; - - /* - * Initialize the PAL and return FAIL if this fails - */ - if (0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - while (*candidate) { - found = (char *)bsearch(candidate, array, sizeof(array) - 1, - (sizeof(char)), charcmp); - if (found != NULL) - { - Fail ("ERROR: bsearch was able to find a specified character '%c' " - "in a sorted list '%s' as '%c' " - "even though the character is not in the list.\n", - *candidate, array, *found); - } - - candidate++; - } - - PAL_Terminate(); - return PASS; -} - - - diff --git a/src/pal/tests/palsuite/c_runtime/bsearch/test2/testinfo.dat b/src/pal/tests/palsuite/c_runtime/bsearch/test2/testinfo.dat deleted file mode 100644 index faa9dc1be..000000000 --- a/src/pal/tests/palsuite/c_runtime/bsearch/test2/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = bsearch -Name = Negative Test for bsearch -TYPE = DEFAULT -EXE1 = test2 -Description -= Calls bsearch to find a character in a sorted buffer, -= that does not exist. - diff --git a/src/pal/tests/palsuite/c_runtime/cbrt/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/cbrt/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/c_runtime/cbrt/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/c_runtime/cbrt/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/cbrt/test1/CMakeLists.txt deleted file mode 100644 index 3d100e566..000000000 --- a/src/pal/tests/palsuite/c_runtime/cbrt/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_cbrt_test1 - ${SOURCES} -) - -add_dependencies(paltest_cbrt_test1 coreclrpal) - -target_link_libraries(paltest_cbrt_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/cbrt/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/cbrt/test1/test1.cpp deleted file mode 100644 index 471b6a464..000000000 --- a/src/pal/tests/palsuite/c_runtime/cbrt/test1/test1.cpp +++ /dev/null @@ -1,123 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test1.c -** -** Purpose: Call the cbrt function on a positive value, a positive value -** with a decimal and on the maxium possible double value. -** -** -**===================================================================*/ - -#include - -// binary64 (double) has a machine epsilon of 2^-52 (approx. 2.22e-16). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-50 (approx. 8.88e-16) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (15-17 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxxxxxxxxxx will use -// PAL_EPSILON for the variance, while an expected result in the format of 0.0xxxxxxxxxxxxxxxxx -// will use PAL_EPSILON / 10 and and expected result in the format of x.xxxxxxxxxxxxxxxx will -// use PAL_EPSILON * 10. -#define PAL_EPSILON 8.8817841970012523e-16 - -#define PAL_NAN sqrt(-1.0) -#define PAL_POSINF -log(0.0) -#define PAL_NEGINF log(0.0) - -/** - * Helper test structure - */ -struct test -{ - double value; /* value to test the function with */ - double expected; /* expected result */ - double variance; /* maximum delta between the expected and actual result */ -}; - -/** - * validate - * - * test validation function - */ -void __cdecl validate(double value, double expected, double variance) -{ - double result = cbrt(value); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - double delta = fabs(result - expected); - - if (delta > variance) - { - Fail("cbrt(%g) returned %20.17g when it should have returned %20.17g", - value, result, expected); - } -} - -/** - * validate - * - * test validation function for values returning NaN - */ -void __cdecl validate_isnan(double value) -{ - double result = cbrt(value); - - if (!_isnan(result)) - { - Fail("cbrt(%g) returned %20.17g when it should have returned %20.17g", - value, result, PAL_NAN); - } -} - -int __cdecl main(int argc, char **argv) -{ - struct test tests[] = - { - /* value expected variance */ - { 0.31830988618379067, 0.68278406325529568, PAL_EPSILON }, // value: 1 / pi - { 0.43429448190325183, 0.75728863133090766, PAL_EPSILON }, // value: log10(e) - { 0.63661977236758134, 0.86025401382809963, PAL_EPSILON }, // value: 2 / pi - { 0.69314718055994531, 0.88499704450051772, PAL_EPSILON }, // value: ln(2) - { 0.70710678118654752, 0.89089871814033930, PAL_EPSILON }, // value: 1 / sqrt(2) - { 0.78539816339744831, 0.92263507432201421, PAL_EPSILON }, // value: pi / 4 - { 1, 1, PAL_EPSILON * 10 }, - { 1.1283791670955126, 1.0410821966965807, PAL_EPSILON * 10 }, // value: 2 / sqrt(pi) - { 1.4142135623730950, 1.1224620483093730, PAL_EPSILON * 10 }, // value: sqrt(2) - { 1.4426950408889634, 1.1299472763373901, PAL_EPSILON * 10 }, // value: log2(e) - { 1.5707963267948966, 1.1624473515096265, PAL_EPSILON * 10 }, // value: pi / 2 - { 2.3025850929940457, 1.3205004784536852, PAL_EPSILON * 10 }, // value: ln(10) - { 2.7182818284590452, 1.3956124250860895, PAL_EPSILON * 10 }, // value: e - { 3.1415926535897932, 1.4645918875615233, PAL_EPSILON * 10 }, // value: pi - }; - - /* PAL initialization */ - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - validate(-0.0, -0.0, PAL_EPSILON); - validate( 0.0, 0.0, PAL_EPSILON); - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - validate(tests[i].value, tests[i].expected, tests[i].variance); - validate(-tests[i].value, -tests[i].expected, tests[i].variance); - } - - validate_isnan(PAL_NAN); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/cbrt/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/cbrt/test1/testinfo.dat deleted file mode 100644 index ddb926ae1..000000000 --- a/src/pal/tests/palsuite/c_runtime/cbrt/test1/testinfo.dat +++ /dev/null @@ -1,17 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = cbrt -Name = Call cbrt on positive values and zero. -TYPE = DEFAULT -EXE1 = test1 -Description -= Call the cbrt function on a positive value, a positive value -= with a decimal and on the maxium possible double value. - - - - diff --git a/src/pal/tests/palsuite/c_runtime/cbrtf/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/cbrtf/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/c_runtime/cbrtf/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/c_runtime/cbrtf/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/cbrtf/test1/CMakeLists.txt deleted file mode 100644 index c83aa325f..000000000 --- a/src/pal/tests/palsuite/c_runtime/cbrtf/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.c -) - -add_executable(paltest_cbrtf_test1 - ${SOURCES} -) - -add_dependencies(paltest_cbrtf_test1 coreclrpal) - -target_link_libraries(paltest_cbrtf_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/cbrtf/test1/test1.c b/src/pal/tests/palsuite/c_runtime/cbrtf/test1/test1.c deleted file mode 100644 index b13d829fb..000000000 --- a/src/pal/tests/palsuite/c_runtime/cbrtf/test1/test1.c +++ /dev/null @@ -1,122 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test1.c -** -** Purpose: Call the cbrtf function on a positive value, a positive value -** with a decimal and on the maxium possible float value. -** -** -**===================================================================*/ - -#include - -// binary32 (float) has a machine epsilon of 2^-23 (approx. 1.19e-07). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-21 (approx. 4.76e-07) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (6-9 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxx will use PAL_EPSILON -// for the variance, while an expected result in the format of 0.0xxxxxxxxx will use -// PAL_EPSILON / 10 and and expected result in the format of x.xxxxxx will use PAL_EPSILON * 10. -#define PAL_EPSILON 4.76837158e-07 - -#define PAL_NAN sqrtf(-1.0f) -#define PAL_POSINF -logf(0.0f) -#define PAL_NEGINF logf(0.0f) - -/** - * Helper test structure - */ -struct test -{ - float value; /* value to test the function with */ - float expected; /* expected result */ - float variance; /* maximum delta between the expected and actual result */ -}; - -/** - * validate - * - * test validation function - */ -void __cdecl validate(float value, float expected, float variance) -{ - float result = cbrtf(value); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - float delta = fabsf(result - expected); - - if (delta > variance) - { - Fail("cbrtf(%g) returned %10.9g when it should have returned %10.9g", - value, result, expected); - } -} - -/** - * validate - * - * test validation function for values returning NaN - */ -void __cdecl validate_isnan(float value) -{ - float result = cbrtf(value); - - if (!_isnanf(result)) - { - Fail("cbrtf(%g) returned %10.9g when it should have returned %10.9g", - value, result, PAL_NAN); - } -} - -int __cdecl main(int argc, char **argv) -{ - struct test tests[] = - { - /* value expected variance */ - { 0.318309886f, 0.682784063f, PAL_EPSILON }, // value: 1 / pi - { 0.434294482f, 0.757288631f, PAL_EPSILON }, // value: log10f(e) - { 0.636619772f, 0.860254014f, PAL_EPSILON }, // value: 2 / pi - { 0.693147181f, 0.884997045f, PAL_EPSILON }, // value: ln(2) - { 0.707106781f, 0.890898718f, PAL_EPSILON }, // value: 1 / sqrtf(2) - { 0.785398163f, 0.922635074f, PAL_EPSILON }, // value: pi / 4 - { 1, 1, PAL_EPSILON * 10 }, - { 1.12837917f, 1.04108220f, PAL_EPSILON * 10 }, // value: 2 / sqrtf(pi) - { 1.41421356f, 1.12246205f, PAL_EPSILON * 10 }, // value: sqrtf(2) - { 1.44269504f, 1.12994728f, PAL_EPSILON * 10 }, // value: logf2(e) - { 1.57079633f, 1.16244735f, PAL_EPSILON * 10 }, // value: pi / 2 - { 2.30258509f, 1.32050048f, PAL_EPSILON * 10 }, // value: ln(10) - { 2.71828183f, 1.39561243f, PAL_EPSILON * 10 }, // value: e - { 3.14159265f, 1.46459189f, PAL_EPSILON * 10 }, // value: pi - }; - - /* PAL initialization */ - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - validate(-0.0f, -0.0f, PAL_EPSILON); - validate( 0.0f, 0.0f, PAL_EPSILON); - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - validate(tests[i].value, tests[i].expected, tests[i].variance); - validate(-tests[i].value, -tests[i].expected, tests[i].variance); - } - - validate_isnan(PAL_NAN); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/cbrtf/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/cbrtf/test1/testinfo.dat deleted file mode 100644 index e42cf2659..000000000 --- a/src/pal/tests/palsuite/c_runtime/cbrtf/test1/testinfo.dat +++ /dev/null @@ -1,17 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = cbrtf -Name = Call cbrtf on positive values and zero. -TYPE = DEFAULT -EXE1 = test1 -Description -= Call the cbrtf function on a positive value, a positive value -= with a decimal and on the maxium possible float value. - - - - diff --git a/src/pal/tests/palsuite/c_runtime/ceil/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/ceil/CMakeLists.txt deleted file mode 100644 index 5e1ef7f28..000000000 --- a/src/pal/tests/palsuite/c_runtime/ceil/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) diff --git a/src/pal/tests/palsuite/c_runtime/ceil/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/ceil/test1/CMakeLists.txt deleted file mode 100644 index c1473daa9..000000000 --- a/src/pal/tests/palsuite/c_runtime/ceil/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_ceil_test1 - ${SOURCES} -) - -add_dependencies(paltest_ceil_test1 coreclrpal) - -target_link_libraries(paltest_ceil_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/ceil/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/ceil/test1/test1.cpp deleted file mode 100644 index e6e36e6e3..000000000 --- a/src/pal/tests/palsuite/c_runtime/ceil/test1/test1.cpp +++ /dev/null @@ -1,132 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: Tests ceil with simple positive and negative values. Also tests -** extreme cases like extremely small values and positive and -** negative infinity. Makes sure that calling ceil on NaN returns -** NaN -** -**==========================================================================*/ - -#include - -// binary64 (double) has a machine epsilon of 2^-52 (approx. 2.22e-16). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-50 (approx. 8.88e-16) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (15-17 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxxxxxxxxxx will use -// PAL_EPSILON for the variance, while an expected result in the format of 0.0xxxxxxxxxxxxxxxxx -// will use PAL_EPSILON / 10 and and expected result in the format of x.xxxxxxxxxxxxxxxx will -// use PAL_EPSILON * 10. -#define PAL_EPSILON 8.8817841970012523e-16 - -#define PAL_NAN sqrt(-1.0) -#define PAL_POSINF -log(0.0) -#define PAL_NEGINF log(0.0) - -/** - * Helper test structure - */ -struct test -{ - double value; /* value to test the function with */ - double expected; /* expected result */ - double variance; /* maximum delta between the expected and actual result */ -}; - -/** - * validate - * - * test validation function - */ -void __cdecl validate(double value, double expected, double variance) -{ - double result = ceil(value); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - double delta = fabs(result - expected); - - if (delta > variance) - { - Fail("ceil(%g) returned %20.17g when it should have returned %20.17g", - value, result, expected); - } -} - -/** - * validate - * - * test validation function for values returning NaN - */ -void __cdecl validate_isnan(double value) -{ - double result = ceil(value); - - if (!_isnan(result)) - { - Fail("ceil(%g) returned %20.17g when it should have returned %20.17g", - value, result, PAL_NAN); - } -} - -/** - * main - * - * executable entry point - */ -int __cdecl main(int argc, char *argv[]) -{ - struct test tests[] = - { - /* value expected variance */ - { 0.31830988618379067, 1, PAL_EPSILON * 10 }, // value: 1 / pi - { 0.43429448190325183, 1, PAL_EPSILON * 10 }, // value: log10(e) - { 0.63661977236758134, 1, PAL_EPSILON * 10 }, // value: 2 / pi - { 0.69314718055994531, 1, PAL_EPSILON * 10 }, // value: ln(2) - { 0.70710678118654752, 1, PAL_EPSILON * 10 }, // value: 1 / sqrt(2) - { 0.78539816339744831, 1, PAL_EPSILON * 10 }, // value: pi / 4 - { 1.1283791670955126, 2, PAL_EPSILON * 10 }, // value: 2 / sqrt(pi) - { 1.4142135623730950, 2, PAL_EPSILON * 10 }, // value: sqrt(2) - { 1.4426950408889634, 2, PAL_EPSILON * 10 }, // value: log2(e) - { 1.5707963267948966, 2, PAL_EPSILON * 10 }, // value: pi / 2 - { 2.3025850929940457, 3, PAL_EPSILON * 10 }, // value: ln(10) - { 2.7182818284590452, 3, PAL_EPSILON * 10 }, // value: e - { 3.1415926535897932, 4, PAL_EPSILON * 10 }, // value: pi - { PAL_POSINF, PAL_POSINF, 0 } - }; - - /* PAL initialization */ - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - validate( 0, 0, PAL_EPSILON); - validate(-0.0, 0, PAL_EPSILON); - - validate( 1, 1, PAL_EPSILON * 10); - validate(-1.0, -1, PAL_EPSILON * 10); - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - validate( tests[i].value, tests[i].expected, tests[i].variance); - validate(-tests[i].value, 1 - tests[i].expected, tests[i].variance); - } - - validate_isnan(PAL_NAN); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/ceil/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/ceil/test1/testinfo.dat deleted file mode 100644 index 84e80a9cb..000000000 --- a/src/pal/tests/palsuite/c_runtime/ceil/test1/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = ceil -Name = Test #1 for ceil -TYPE = DEFAULT -EXE1 = test1 -Description -=Tests ceil with simple positive and negative values. Also tests -=extreme cases like extremely small values and positive and negative -=infinity. Makes sure that calling ceil on NaN returns NaN diff --git a/src/pal/tests/palsuite/c_runtime/ceilf/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/ceilf/CMakeLists.txt deleted file mode 100644 index 5e1ef7f28..000000000 --- a/src/pal/tests/palsuite/c_runtime/ceilf/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) diff --git a/src/pal/tests/palsuite/c_runtime/ceilf/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/ceilf/test1/CMakeLists.txt deleted file mode 100644 index b1fbe0710..000000000 --- a/src/pal/tests/palsuite/c_runtime/ceilf/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.c -) - -add_executable(paltest_ceilf_test1 - ${SOURCES} -) - -add_dependencies(paltest_ceilf_test1 coreclrpal) - -target_link_libraries(paltest_ceilf_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/ceilf/test1/test1.c b/src/pal/tests/palsuite/c_runtime/ceilf/test1/test1.c deleted file mode 100644 index 4939fb7cc..000000000 --- a/src/pal/tests/palsuite/c_runtime/ceilf/test1/test1.c +++ /dev/null @@ -1,131 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: Tests ceilf with simple positive and negative values. Also tests -** extreme cases like extremely small values and positive and -** negative infinity. Makes sure that calling ceilf on NaN returns -** NaN -** -**==========================================================================*/ - -#include - -// binary32 (float) has a machine epsilon of 2^-23 (approx. 1.19e-07). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-21 (approx. 4.76e-07) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (6-9 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxx will use PAL_EPSILON -// for the variance, while an expected result in the format of 0.0xxxxxxxxx will use -// PAL_EPSILON / 10 and and expected result in the format of x.xxxxxx will use PAL_EPSILON * 10. -#define PAL_EPSILON 4.76837158e-07 - -#define PAL_NAN sqrtf(-1.0f) -#define PAL_POSINF -logf(0.0f) -#define PAL_NEGINF logf(0.0f) - -/** - * Helper test structure - */ -struct test -{ - float value; /* value to test the function with */ - float expected; /* expected result */ - float variance; /* maximum delta between the expected and actual result */ -}; - -/** - * validate - * - * test validation function - */ -void __cdecl validate(float value, float expected, float variance) -{ - float result = ceilf(value); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - float delta = fabsf(result - expected); - - if (delta > variance) - { - Fail("ceilf(%g) returned %10.9g when it should have returned %10.9g", - value, result, expected); - } -} - -/** - * validate - * - * test validation function for values returning NaN - */ -void __cdecl validate_isnan(float value) -{ - float result = ceilf(value); - - if (!_isnanf(result)) - { - Fail("ceilf(%g) returned %10.9g when it should have returned %10.9g", - value, result, PAL_NAN); - } -} - -/** - * main - * - * executable entry point - */ -int __cdecl main(int argc, char *argv[]) -{ - struct test tests[] = - { - /* value expected variance */ - { 0.318309886f, 1, PAL_EPSILON * 10 }, // value: 1 / pi - { 0.434294482f, 1, PAL_EPSILON * 10 }, // value: log10f(e) - { 0.636619772f, 1, PAL_EPSILON * 10 }, // value: 2 / pi - { 0.693147181f, 1, PAL_EPSILON * 10 }, // value: ln(2) - { 0.707106781f, 1, PAL_EPSILON * 10 }, // value: 1 / sqrtf(2) - { 0.785398163f, 1, PAL_EPSILON * 10 }, // value: pi / 4 - { 1.12837917f, 2, PAL_EPSILON * 10 }, // value: 2 / sqrtf(pi) - { 1.41421356f, 2, PAL_EPSILON * 10 }, // value: sqrtf(2) - { 1.44269504f, 2, PAL_EPSILON * 10 }, // value: logf2(e) - { 1.57079633f, 2, PAL_EPSILON * 10 }, // value: pi / 2 - { 2.30258509f, 3, PAL_EPSILON * 10 }, // value: ln(10) - { 2.71828183f, 3, PAL_EPSILON * 10 }, // value: e - { 3.14159265f, 4, PAL_EPSILON * 10 }, // value: pi - { PAL_POSINF, PAL_POSINF, 0 } - }; - - /* PAL initialization */ - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - validate( 0, 0, PAL_EPSILON); - validate(-0.0f, 0, PAL_EPSILON); - - validate( 1, 1, PAL_EPSILON * 10); - validate(-1.0f, -1, PAL_EPSILON * 10); - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - validate( tests[i].value, tests[i].expected, tests[i].variance); - validate(-tests[i].value, 1 - tests[i].expected, tests[i].variance); - } - - validate_isnan(PAL_NAN); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/ceilf/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/ceilf/test1/testinfo.dat deleted file mode 100644 index 095b8b216..000000000 --- a/src/pal/tests/palsuite/c_runtime/ceilf/test1/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = ceilf -Name = Test #1 for ceilf -TYPE = DEFAULT -EXE1 = test1 -Description -=Tests ceilf with simple positive and negative values. Also tests -=extreme cases like extremely small values and positive and negative -=infinity. Makes sure that calling ceilf on NaN returns NaN diff --git a/src/pal/tests/palsuite/c_runtime/cos/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/cos/CMakeLists.txt deleted file mode 100644 index 5e1ef7f28..000000000 --- a/src/pal/tests/palsuite/c_runtime/cos/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) diff --git a/src/pal/tests/palsuite/c_runtime/cos/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/cos/test1/CMakeLists.txt deleted file mode 100644 index 936a876c3..000000000 --- a/src/pal/tests/palsuite/c_runtime/cos/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_cos_test1 - ${SOURCES} -) - -add_dependencies(paltest_cos_test1 coreclrpal) - -target_link_libraries(paltest_cos_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/cos/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/cos/test1/test1.cpp deleted file mode 100644 index 8c1c7300e..000000000 --- a/src/pal/tests/palsuite/c_runtime/cos/test1/test1.cpp +++ /dev/null @@ -1,131 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================= -** -** Source: test1.c -** -** Purpose: Test to ensure that cos return the correct values -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** Fail -** fabs -** -**===========================================================================*/ - -#include - -// binary64 (double) has a machine epsilon of 2^-52 (approx. 2.22e-16). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-50 (approx. 8.88e-16) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (15-17 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxxxxxxxxxx will use -// PAL_EPSILON for the variance, while an expected result in the format of 0.0xxxxxxxxxxxxxxxxx -// will use PAL_EPSILON / 10 and and expected result in the format of x.xxxxxxxxxxxxxxxx will -// use PAL_EPSILON * 10. -#define PAL_EPSILON 8.8817841970012523e-16 - -#define PAL_NAN sqrt(-1.0) -#define PAL_POSINF -log(0.0) -#define PAL_NEGINF log(0.0) - -/** - * Helper test structure - */ -struct test -{ - double value; /* value to test the function with */ - double expected; /* expected result */ - double variance; /* maximum delta between the expected and actual result */ -}; - -/** - * validate - * - * test validation function - */ -void __cdecl validate(double value, double expected, double variance) -{ - double result = cos(value); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - double delta = fabs(result - expected); - - if (delta > variance) - { - Fail("cos(%g) returned %20.17g when it should have returned %20.17g", - value, result, expected); - } -} - -/** - * validate - * - * test validation function for values returning NaN - */ -void __cdecl validate_isnan(double value) -{ - double result = cos(value); - - if (!_isnan(result)) - { - Fail("cos(%g) returned %20.17g when it should have returned %20.17g", - value, result, PAL_NAN); - } -} - -/** - * main - * - * executable entry point - */ -int __cdecl main(int argc, char **argv) -{ - struct test tests[] = - { - /* value expected variance */ - { 0, 1, PAL_EPSILON * 10 }, - { 0.31830988618379067, 0.94976571538163866, PAL_EPSILON }, // value: 1 / pi - { 0.43429448190325183, 0.90716712923909839, PAL_EPSILON }, // value: log10(e) - { 0.63661977236758134, 0.80410982822879171, PAL_EPSILON }, // value: 2 / pi - { 0.69314718055994531, 0.76923890136397213, PAL_EPSILON }, // value: ln(2) - { 0.70710678118654752, 0.76024459707563015, PAL_EPSILON }, // value: 1 / sqrt(2) - { 0.78539816339744831, 0.70710678118654752, PAL_EPSILON }, // value: pi / 4, expected: 1 / sqrt(2) - { 1, 0.54030230586813972, PAL_EPSILON }, - { 1.1283791670955126, 0.42812514788535792, PAL_EPSILON }, // value: 2 / sqrt(pi) - { 1.4142135623730950, 0.15594369476537447, PAL_EPSILON }, // value: sqrt(2) - { 1.4426950408889634, 0.12775121753523991, PAL_EPSILON }, // value: log2(e) - { 1.5707963267948966, 0, PAL_EPSILON }, // value: pi / 2 - { 2.3025850929940457, -0.66820151019031295, PAL_EPSILON }, // value: ln(10) - { 2.7182818284590452, -0.91173391478696510, PAL_EPSILON }, // value: e - { 3.1415926535897932, -1, PAL_EPSILON * 10 }, // value: pi - }; - - /* PAL initialization */ - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - validate( tests[i].value, tests[i].expected, tests[i].variance); - validate(-tests[i].value, tests[i].expected, tests[i].variance); - } - - validate_isnan(PAL_NEGINF); - validate_isnan(PAL_NAN); - validate_isnan(PAL_POSINF); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/cos/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/cos/test1/testinfo.dat deleted file mode 100644 index 9e57b7f8a..000000000 --- a/src/pal/tests/palsuite/c_runtime/cos/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = cos -Name = Positive Test for cos -TYPE = DEFAULT -EXE1 = test1 -Description -= Passes to cos() a series of angle value, checking that -= each one return the correct value. diff --git a/src/pal/tests/palsuite/c_runtime/cosf/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/cosf/CMakeLists.txt deleted file mode 100644 index 5e1ef7f28..000000000 --- a/src/pal/tests/palsuite/c_runtime/cosf/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) diff --git a/src/pal/tests/palsuite/c_runtime/cosf/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/cosf/test1/CMakeLists.txt deleted file mode 100644 index db4efe4ac..000000000 --- a/src/pal/tests/palsuite/c_runtime/cosf/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.c -) - -add_executable(paltest_cosf_test1 - ${SOURCES} -) - -add_dependencies(paltest_cosf_test1 coreclrpal) - -target_link_libraries(paltest_cosf_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/cosf/test1/test1.c b/src/pal/tests/palsuite/c_runtime/cosf/test1/test1.c deleted file mode 100644 index 210851a2f..000000000 --- a/src/pal/tests/palsuite/c_runtime/cosf/test1/test1.c +++ /dev/null @@ -1,130 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================= -** -** Source: test1.c -** -** Purpose: Test to ensure that cosf return the correct values -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** Fail -** fabs -** -**===========================================================================*/ - -#include - -// binary32 (float) has a machine epsilon of 2^-23 (approx. 1.19e-07). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-21 (approx. 4.76e-07) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (6-9 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxx will use PAL_EPSILON -// for the variance, while an expected result in the format of 0.0xxxxxxxxx will use -// PAL_EPSILON / 10 and and expected result in the format of x.xxxxxx will use PAL_EPSILON * 10. -#define PAL_EPSILON 4.76837158e-07 - -#define PAL_NAN sqrtf(-1.0f) -#define PAL_POSINF -logf(0.0f) -#define PAL_NEGINF logf(0.0f) - -/** - * Helper test structure - */ -struct test -{ - float value; /* value to test the function with */ - float expected; /* expected result */ - float variance; /* maximum delta between the expected and actual result */ -}; - -/** - * validate - * - * test validation function - */ -void __cdecl validate(float value, float expected, float variance) -{ - float result = cosf(value); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - float delta = fabsf(result - expected); - - if (delta > variance) - { - Fail("cosf(%g) returned %10.9g when it should have returned %10.9g", - value, result, expected); - } -} - -/** - * validate - * - * test validation function for values returning NaN - */ -void __cdecl validate_isnan(float value) -{ - float result = cosf(value); - - if (!_isnanf(result)) - { - Fail("cosf(%g) returned %10.9g when it should have returned %10.9g", - value, result, PAL_NAN); - } -} - -/** - * main - * - * executable entry point - */ -int __cdecl main(int argc, char **argv) -{ - struct test tests[] = - { - /* value expected variance */ - { 0, 1, PAL_EPSILON * 10 }, - { 0.318309886f, 0.949765715f, PAL_EPSILON }, // value: 1 / pi - { 0.434294482f, 0.907167129f, PAL_EPSILON }, // value: log10f(e) - { 0.636619772f, 0.804109828f, PAL_EPSILON }, // value: 2 / pi - { 0.693147181f, 0.769238901f, PAL_EPSILON }, // value: ln(2) - { 0.707106781f, 0.760244597f, PAL_EPSILON }, // value: 1 / sqrtf(2) - { 0.785398163f, 0.707106781f, PAL_EPSILON }, // value: pi / 4, expected: 1 / sqrtf(2) - { 1, 0.540302306f, PAL_EPSILON }, - { 1.12837917f, 0.428125148f, PAL_EPSILON }, // value: 2 / sqrtf(pi) - { 1.41421356f, 0.155943695f, PAL_EPSILON }, // value: sqrtf(2) - { 1.44269504f, 0.127751218f, PAL_EPSILON }, // value: logf2(e) - { 1.57079633f, 0, PAL_EPSILON }, // value: pi / 2 - { 2.30258509f, -0.668201510f, PAL_EPSILON }, // value: ln(10) - { 2.71828183f, -0.911733918f, PAL_EPSILON }, // value: e - { 3.14159265f, -1, PAL_EPSILON * 10 }, // value: pi - }; - - /* PAL initialization */ - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - validate( tests[i].value, tests[i].expected, tests[i].variance); - validate(-tests[i].value, tests[i].expected, tests[i].variance); - } - - validate_isnan(PAL_NEGINF); - validate_isnan(PAL_NAN); - validate_isnan(PAL_POSINF); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/cosf/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/cosf/test1/testinfo.dat deleted file mode 100644 index a0265add2..000000000 --- a/src/pal/tests/palsuite/c_runtime/cosf/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = cosf -Name = Positive Test for cosf -TYPE = DEFAULT -EXE1 = test1 -Description -= Passes to cosf() a series of angle value, checking that -= each one return the correct value. diff --git a/src/pal/tests/palsuite/c_runtime/cosh/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/cosh/CMakeLists.txt deleted file mode 100644 index 5e1ef7f28..000000000 --- a/src/pal/tests/palsuite/c_runtime/cosh/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) diff --git a/src/pal/tests/palsuite/c_runtime/cosh/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/cosh/test1/CMakeLists.txt deleted file mode 100644 index ec8038a16..000000000 --- a/src/pal/tests/palsuite/c_runtime/cosh/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_cosh_test1 - ${SOURCES} -) - -add_dependencies(paltest_cosh_test1 coreclrpal) - -target_link_libraries(paltest_cosh_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/cosh/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/cosh/test1/test1.cpp deleted file mode 100644 index 40c2fca85..000000000 --- a/src/pal/tests/palsuite/c_runtime/cosh/test1/test1.cpp +++ /dev/null @@ -1,130 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================= -** -** Source: test1.c -** -** Purpose: Test to ensure that cosh return the correct values -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** Fail -** fabs -** -**===========================================================================*/ - -#include - -// binary64 (double) has a machine epsilon of 2^-52 (approx. 2.22e-16). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-50 (approx. 8.88e-16) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (15-17 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxxxxxxxxxx will use -// PAL_EPSILON for the variance, while an expected result in the format of 0.0xxxxxxxxxxxxxxxxx -// will use PAL_EPSILON / 10 and and expected result in the format of x.xxxxxxxxxxxxxxxx will -// use PAL_EPSILON * 10. -#define PAL_EPSILON 8.8817841970012523e-16 - -#define PAL_NAN sqrt(-1.0) -#define PAL_POSINF -log(0.0) -#define PAL_NEGINF log(0.0) - -/** - * Helper test structure - */ -struct test -{ - double value; /* value to test the function with */ - double expected; /* expected result */ - double variance; /* maximum delta between the expected and actual result */ -}; - -/** - * validate - * - * test validation function - */ -void __cdecl validate(double value, double expected, double variance) -{ - double result = cosh(value); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - double delta = fabs(result - expected); - - if (delta > variance) - { - Fail("cosh(%g) returned %20.17g when it should have returned %20.17g", - value, result, expected); - } -} - -/** - * validate - * - * test validation function for values returning PAL_NAN - */ -void __cdecl validate_isnan(double value) -{ - double result = cosh(value); - - if (!_isnan(result)) - { - Fail("cosh(%g) returned %20.17g when it should have returned %20.17g", - value, result, PAL_NAN); - } -} - -/** - * main - * - * executable entry point - */ -int __cdecl main(int argc, char **argv) -{ - struct test tests[] = - { - /* value expected variance */ - { 0, 1, PAL_EPSILON * 10 }, - { 0.31830988618379067, 1.0510897883672876, PAL_EPSILON * 10 }, // value: 1 / pi - { 0.43429448190325183, 1.0957974645564909, PAL_EPSILON * 10 }, // value: log10(e) - { 0.63661977236758134, 1.2095794864199787, PAL_EPSILON * 10 }, // value: 2 / pi - { 0.69314718055994531, 1.25, PAL_EPSILON * 10 }, // value: ln(2) - { 0.70710678118654752, 1.2605918365213561, PAL_EPSILON * 10 }, // value: 1 / sqrt(2) - { 0.78539816339744831, 1.3246090892520058, PAL_EPSILON * 10 }, // value: pi / 4 - { 1, 1.5430806348152438, PAL_EPSILON * 10 }, - { 1.1283791670955126, 1.7071001431069344, PAL_EPSILON * 10 }, // value: 2 / sqrt(pi) - { 1.4142135623730950, 2.1781835566085709, PAL_EPSILON * 10 }, // value: sqrt(2) - { 1.4426950408889634, 2.2341880974508023, PAL_EPSILON * 10 }, // value: log2(e) - { 1.5707963267948966, 2.5091784786580568, PAL_EPSILON * 10 }, // value: pi / 2 - { 2.3025850929940457, 5.05, PAL_EPSILON * 10 }, // value: ln(10) - { 2.7182818284590452, 7.6101251386622884, PAL_EPSILON * 10 }, // value: e - { 3.1415926535897932, 11.591953275521521, PAL_EPSILON * 100 }, // value: pi - { PAL_POSINF, PAL_POSINF, 0 }, - }; - - /* PAL initialization */ - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - validate( tests[i].value, tests[i].expected, tests[i].variance); - validate(-tests[i].value, tests[i].expected, tests[i].variance); - } - - validate_isnan(PAL_NAN); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/cosh/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/cosh/test1/testinfo.dat deleted file mode 100644 index 131512289..000000000 --- a/src/pal/tests/palsuite/c_runtime/cosh/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = cosh -Name = Positive Test for cosh -TYPE = DEFAULT -EXE1 = test1 -Description -= Passes to cosh() a series of angle value, checking that -= each one return to correct value. diff --git a/src/pal/tests/palsuite/c_runtime/coshf/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/coshf/CMakeLists.txt deleted file mode 100644 index 5e1ef7f28..000000000 --- a/src/pal/tests/palsuite/c_runtime/coshf/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) diff --git a/src/pal/tests/palsuite/c_runtime/coshf/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/coshf/test1/CMakeLists.txt deleted file mode 100644 index 3b873eec9..000000000 --- a/src/pal/tests/palsuite/c_runtime/coshf/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.c -) - -add_executable(paltest_coshf_test1 - ${SOURCES} -) - -add_dependencies(paltest_coshf_test1 coreclrpal) - -target_link_libraries(paltest_coshf_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/coshf/test1/test1.c b/src/pal/tests/palsuite/c_runtime/coshf/test1/test1.c deleted file mode 100644 index e1ab745ac..000000000 --- a/src/pal/tests/palsuite/c_runtime/coshf/test1/test1.c +++ /dev/null @@ -1,129 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================= -** -** Source: test1.c -** -** Purpose: Test to ensure that coshf return the correct values -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** Fail -** fabs -** -**===========================================================================*/ - -#include - -// binary32 (float) has a machine epsilon of 2^-23 (approx. 1.19e-07). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-21 (approx. 4.76e-07) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (6-9 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxx will use PAL_EPSILON -// for the variance, while an expected result in the format of 0.0xxxxxxxxx will use -// PAL_EPSILON / 10 and and expected result in the format of x.xxxxxx will use PAL_EPSILON * 10. -#define PAL_EPSILON 4.76837158e-07 - -#define PAL_NAN sqrtf(-1.0f) -#define PAL_POSINF -logf(0.0f) -#define PAL_NEGINF logf(0.0f) - -/** - * Helper test structure - */ -struct test -{ - float value; /* value to test the function with */ - float expected; /* expected result */ - float variance; /* maximum delta between the expected and actual result */ -}; - -/** - * validate - * - * test validation function - */ -void __cdecl validate(float value, float expected, float variance) -{ - float result = coshf(value); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - float delta = fabsf(result - expected); - - if (delta > variance) - { - Fail("coshf(%g) returned %10.9g when it should have returned %10.9g", - value, result, expected); - } -} - -/** - * validate - * - * test validation function for values returning PAL_NAN - */ -void __cdecl validate_isnan(float value) -{ - float result = coshf(value); - - if (!_isnanf(result)) - { - Fail("coshf(%g) returned %10.9g when it should have returned %10.9g", - value, result, PAL_NAN); - } -} - -/** - * main - * - * executable entry point - */ -int __cdecl main(int argc, char **argv) -{ - struct test tests[] = - { - /* value expected variance */ - { 0, 1, PAL_EPSILON * 10 }, - { 0.318309886f, 1.05108979f, PAL_EPSILON * 10 }, // value: 1 / pi - { 0.434294482f, 1.09579746f, PAL_EPSILON * 10 }, // value: log10f(e) - { 0.636619772f, 1.20957949f, PAL_EPSILON * 10 }, // value: 2 / pi - { 0.693147181f, 1.25f, PAL_EPSILON * 10 }, // value: ln(2) - { 0.707106781f, 1.26059184f, PAL_EPSILON * 10 }, // value: 1 / sqrtf(2) - { 0.785398163f, 1.32460909f, PAL_EPSILON * 10 }, // value: pi / 4 - { 1, 1.54308063f, PAL_EPSILON * 10 }, - { 1.12837917f, 1.70710014f, PAL_EPSILON * 10 }, // value: 2 / sqrtf(pi) - { 1.41421356f, 2.17818356f, PAL_EPSILON * 10 }, // value: sqrtf(2) - { 1.44269504f, 2.23418810f, PAL_EPSILON * 10 }, // value: logf2(e) - { 1.57079633f, 2.50917848f, PAL_EPSILON * 10 }, // value: pi / 2 - { 2.30258509f, 5.05f, PAL_EPSILON * 10 }, // value: ln(10) - { 2.71828183f, 7.61012514f, PAL_EPSILON * 10 }, // value: e - { 3.14159265f, 11.5919533f, PAL_EPSILON * 100 }, // value: pi - { PAL_POSINF, PAL_POSINF, 0 }, - }; - - /* PAL initialization */ - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - validate( tests[i].value, tests[i].expected, tests[i].variance); - validate(-tests[i].value, tests[i].expected, tests[i].variance); - } - - validate_isnan(PAL_NAN); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/coshf/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/coshf/test1/testinfo.dat deleted file mode 100644 index 814ed9869..000000000 --- a/src/pal/tests/palsuite/c_runtime/coshf/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = coshf -Name = Positive Test for coshf -TYPE = DEFAULT -EXE1 = test1 -Description -= Passes to coshf() a series of angle value, checking that -= each one return to correct value. diff --git a/src/pal/tests/palsuite/c_runtime/ctime/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/ctime/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/c_runtime/ctime/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/c_runtime/ctime/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/ctime/test1/CMakeLists.txt deleted file mode 100644 index b7d1b99b2..000000000 --- a/src/pal/tests/palsuite/c_runtime/ctime/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_ctime_test1 - ${SOURCES} -) - -add_dependencies(paltest_ctime_test1 coreclrpal) - -target_link_libraries(paltest_ctime_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/ctime/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/ctime/test1/test1.cpp deleted file mode 100644 index 5d5e22ce8..000000000 --- a/src/pal/tests/palsuite/c_runtime/ctime/test1/test1.cpp +++ /dev/null @@ -1,154 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================= -** -** Source: test1.c -** -** Purpose: Test to ensure that ctime return a valid -** string when it received a valid number of second. -** Test to ensure that ctime return null when it -** receives a invalid number of second. -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** Fail -** IsBadReadPtr -** strcmp -** - -** -**===========================================================================*/ - -#include - -/* - * Date strings generated under win2000/WinXP, times & Strings are GMT - */ -const time_t VAL_SUN_JAN_17_2038 = 2147383647; -const char *STR_SUN_JAN_17_2038 = "Sun Jan 17 23:27:27 2038\n"; - -/* Note, there are two acceptable strings for this date. */ -/* The day can have a leading 0 under Windows. */ -const time_t VAL_FRI_JAN_02_1970 = 100000; -const char *STR_FRI_JAN_02_1970 = "Fri Jan 02 03:46:40 1970\n"; -const char *STR_FRI_JAN__2_1970 = "Fri Jan 2 03:46:40 1970\n"; - -const int STR_TIME_SIZE = 26; /* returned date size in byte*/ - - - -int __cdecl main(int argc, char **argv) -{ - time_t LTime; - char *DateResult; - TIME_ZONE_INFORMATION tzInformation; - - /* - * Initialize the PAL and return FAILURE if this fails - */ - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - // Get the current timezone information - GetTimeZoneInformation(&tzInformation); - - /* - * Test #1 - */ - - /* set the valid date in time_t format, adjusted for current time zone*/ - LTime = VAL_SUN_JAN_17_2038 + (tzInformation.Bias * 60); - - /* convert it to string using ctime*/ - DateResult = ctime( <ime ); - - /* if it's null, ctime failed*/ - if (DateResult == NULL) - { - Fail ("ERROR: (Test #1) ctime returned NULL. Expected string\n"); - } - - /* test if the entire string can ba access normaly */ - if(IsBadReadPtr(DateResult, STR_TIME_SIZE)==0) - { - /* compare result with win2000 result */ - if(strcmp( DateResult, STR_SUN_JAN_17_2038)!=0) - { - Fail("ERROR: (Test #1) ctime returned an unexpected string " - "%s, expexted string is %s\n" - ,DateResult, STR_SUN_JAN_17_2038); - } - } - else - { - Fail ("ERROR: (Test #1) ctime returned a bad pointer.\n"); - } - - - /* - * Test #2 - */ - - /* Set the valid date in time_t format, adjusted for current time zone */ - LTime = VAL_FRI_JAN_02_1970 + (tzInformation.Bias * 60); - - /* convert it to string using ctime */ - DateResult = ctime( <ime ); - - /* if it's null, ctime failed*/ - if (DateResult == NULL) - { - Fail ("ERROR: (Test #2) ctime returned NULL. Expected string\n"); - } - - /* test if the entire string can ba access normaly */ - if(IsBadReadPtr(DateResult, STR_TIME_SIZE)==0) - { - /* compare result with win2000 result */ - if (strcmp(DateResult, STR_FRI_JAN_02_1970) != 0 - && strcmp(DateResult, STR_FRI_JAN__2_1970) != 0) - { - Fail("ERROR: (Test #2) ctime returned an unexpected string " - "%s, expected string is %s\n" - ,DateResult, STR_FRI_JAN_02_1970); - } - } - else - { - Fail ("ERROR: (Test #2) ctime returned a bad pointer.\n"); - } - - - - /* - * Test #3 - */ - - /* specify an invalid time */ - LTime = -1; - - /* try to convert it */ - DateResult = ctime( <ime ); - - /* Check the result for errors, should fail in this case */ - if (DateResult != NULL) - { - Fail ("ERROR: (Test #3) ctime returned something different from NULL.:" - "Expected NULL\n"); - } - - - PAL_Terminate(); - return PASS; -} - - - - - - diff --git a/src/pal/tests/palsuite/c_runtime/ctime/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/ctime/test1/testinfo.dat deleted file mode 100644 index c5aa3df65..000000000 --- a/src/pal/tests/palsuite/c_runtime/ctime/test1/testinfo.dat +++ /dev/null @@ -1,15 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = ctime -Name = Positive Test for ctime -TYPE = DEFAULT -EXE1 = test1 -Description -= Call ctime with a valid number of second in it's t_time parameter -= and expect a non-null char* as a return value. -= Call ctime with a invalid number of second (-1) and expect -= a null char* as a return value. diff --git a/src/pal/tests/palsuite/c_runtime/errno/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/errno/CMakeLists.txt deleted file mode 100644 index ef14ea535..000000000 --- a/src/pal/tests/palsuite/c_runtime/errno/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) - diff --git a/src/pal/tests/palsuite/c_runtime/errno/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/errno/test1/CMakeLists.txt deleted file mode 100644 index 8c27c78d6..000000000 --- a/src/pal/tests/palsuite/c_runtime/errno/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_errno_test1 - ${SOURCES} -) - -add_dependencies(paltest_errno_test1 coreclrpal) - -target_link_libraries(paltest_errno_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/errno/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/errno/test1/test1.cpp deleted file mode 100644 index 3ae25fb02..000000000 --- a/src/pal/tests/palsuite/c_runtime/errno/test1/test1.cpp +++ /dev/null @@ -1,43 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: Test that errno begins as 0, and sets to ERANGE when that -** error is forced with wcstoul. -** -** -**==========================================================================*/ - -#include - -int __cdecl main(int argc, char *argv[]) -{ - WCHAR overstr[] = {'4','2','9','4','9','6','7','2','9','6',0}; - WCHAR *end; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - /* - From rotor.doc: The only value that must be supported is - ERANGE, in the event that wcstoul() fails due to overflow. - */ - - wcstoul(overstr, &end, 10); - - if (errno != ERANGE) - { - Fail("ERROR: wcstoul did not set errno to ERANGE. Instead " - "the value of errno is %d\n", errno); - } - - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/errno/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/errno/test1/testinfo.dat deleted file mode 100644 index 3291dbc60..000000000 --- a/src/pal/tests/palsuite/c_runtime/errno/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = errno -Name = Positive Test for errno -TYPE = DEFAULT -EXE1 = test1 -Description -= Test that errno begins as 0, and sets to ERANGE when that -= error is forced with wcstoul. diff --git a/src/pal/tests/palsuite/c_runtime/errno/test2/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/errno/test2/CMakeLists.txt deleted file mode 100644 index e66c35920..000000000 --- a/src/pal/tests/palsuite/c_runtime/errno/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test2.cpp -) - -add_executable(paltest_errno_test2 - ${SOURCES} -) - -add_dependencies(paltest_errno_test2 coreclrpal) - -target_link_libraries(paltest_errno_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/errno/test2/test2.cpp b/src/pal/tests/palsuite/c_runtime/errno/test2/test2.cpp deleted file mode 100644 index f418d2f19..000000000 --- a/src/pal/tests/palsuite/c_runtime/errno/test2/test2.cpp +++ /dev/null @@ -1,76 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test2.c -** -** Purpose: Test that errno is 'per-thread' as noted in the documentation. -** -** -**==========================================================================*/ - -#include - -/* - This thread function just checks that errno is initially 0 and then sets - it to a new value before returning. -*/ -DWORD PALAPI ThreadFunc( LPVOID lpParam ) -{ - - if(errno != 0) - { - *((DWORD*)lpParam) = 1; - } - - errno = 20; - - return 0; -} - - -int __cdecl main(int argc, char *argv[]) -{ - DWORD dwThreadId, dwThrdParam = 0; - HANDLE hThread; - - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - /* Set errno to a value within this thread */ - - errno = 50; - - hThread = CreateThread(NULL, 0, ThreadFunc, &dwThrdParam, 0, &dwThreadId); - - if (hThread == NULL) - { - Fail("ERROR: CreateThread failed to create a thread. " - "GetLastError() returned %d.\n",GetLastError()); - } - - WaitForSingleObject(hThread, INFINITE); - - /* This checks the result of calling the thread */ - if(dwThrdParam) - { - Fail("ERROR: errno was not set to 0 in the new thread. Each " - "thread should have its own value for errno.\n"); - } - - /* Check to make sure errno is still set to 50 */ - if(errno != 50) - { - Fail("ERROR: errno should be 50 in the main thread, even though " - "it was set to 20 in another thread. Currently it is %d.\n", - errno); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/errno/test2/testinfo.dat b/src/pal/tests/palsuite/c_runtime/errno/test2/testinfo.dat deleted file mode 100644 index 90c232866..000000000 --- a/src/pal/tests/palsuite/c_runtime/errno/test2/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = errno -Name = Positive Test for errno -TYPE = DEFAULT -EXE1 = test2 -Description -= Test that errno is 'per-thread' as noted in the documentation. diff --git a/src/pal/tests/palsuite/c_runtime/exit/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/exit/CMakeLists.txt deleted file mode 100644 index ef14ea535..000000000 --- a/src/pal/tests/palsuite/c_runtime/exit/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) - diff --git a/src/pal/tests/palsuite/c_runtime/exit/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/exit/test1/CMakeLists.txt deleted file mode 100644 index 3f34da6fd..000000000 --- a/src/pal/tests/palsuite/c_runtime/exit/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_exit_test1 - ${SOURCES} -) - -add_dependencies(paltest_exit_test1 coreclrpal) - -target_link_libraries(paltest_exit_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/exit/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/exit/test1/test1.cpp deleted file mode 100644 index 87c9d22b8..000000000 --- a/src/pal/tests/palsuite/c_runtime/exit/test1/test1.cpp +++ /dev/null @@ -1,37 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: Calls exit, and verifies that it actually stops program execution. -** -** -**==========================================================================*/ - -#include - -int __cdecl main(int argc, char **argv) -{ - /* - * Initialize the PAL and return FAIL if this fails - */ - if (0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - /*should return 0*/ - exit(0); - - Fail ("Exit didn't actually stop execution.\n"); - - return FAIL; -} - - - - - diff --git a/src/pal/tests/palsuite/c_runtime/exit/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/exit/test1/testinfo.dat deleted file mode 100644 index 3d9583bf9..000000000 --- a/src/pal/tests/palsuite/c_runtime/exit/test1/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = exit -Name = Positive Test for exit -TYPE = DEFAULT -EXE1 = test1 -Description -= Calls exit, and verifies that it actually stops program execution. diff --git a/src/pal/tests/palsuite/c_runtime/exit/test2/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/exit/test2/CMakeLists.txt deleted file mode 100644 index 5327b5789..000000000 --- a/src/pal/tests/palsuite/c_runtime/exit/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test2.cpp -) - -add_executable(paltest_exit_test2 - ${SOURCES} -) - -add_dependencies(paltest_exit_test2 coreclrpal) - -target_link_libraries(paltest_exit_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/exit/test2/test2.cpp b/src/pal/tests/palsuite/c_runtime/exit/test2/test2.cpp deleted file mode 100644 index 16fbdfed2..000000000 --- a/src/pal/tests/palsuite/c_runtime/exit/test2/test2.cpp +++ /dev/null @@ -1,38 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test2.c -** -** Purpose: Calls exit on fail, and verifies that it actually -** stops program execution and return 1. - -** -**==========================================================================*/ - -#include - -int __cdecl main(int argc, char **argv) -{ - /* - * Initialize the PAL and return FAIL if this fails - */ - if (0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - /*should return 1*/ - exit(1); - -} - - - - - - - - diff --git a/src/pal/tests/palsuite/c_runtime/exit/test2/testinfo.dat b/src/pal/tests/palsuite/c_runtime/exit/test2/testinfo.dat deleted file mode 100644 index 6887f27c3..000000000 --- a/src/pal/tests/palsuite/c_runtime/exit/test2/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = exit -Name = Positive Test for exit -TYPE = DEFAULT -EXE1 = test2 -Description -= Calls exit on fail, and verifies that it actually stops program execution, -= and return 1. diff --git a/src/pal/tests/palsuite/c_runtime/exp/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/exp/CMakeLists.txt deleted file mode 100644 index 5e1ef7f28..000000000 --- a/src/pal/tests/palsuite/c_runtime/exp/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) diff --git a/src/pal/tests/palsuite/c_runtime/exp/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/exp/test1/CMakeLists.txt deleted file mode 100644 index a28565835..000000000 --- a/src/pal/tests/palsuite/c_runtime/exp/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_exp_test1 - ${SOURCES} -) - -add_dependencies(paltest_exp_test1 coreclrpal) - -target_link_libraries(paltest_exp_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/exp/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/exp/test1/test1.cpp deleted file mode 100644 index 20e071aa6..000000000 --- a/src/pal/tests/palsuite/c_runtime/exp/test1/test1.cpp +++ /dev/null @@ -1,138 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test1.c -** -** Purpose: Tests exp with a normal set of values. -** -**===================================================================*/ - -#include - -// binary64 (double) has a machine epsilon of 2^-52 (approx. 2.22e-16). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-50 (approx. 8.88e-16) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (15-17 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxxxxxxxxxx will use -// PAL_EPSILON for the variance, while an expected result in the format of 0.0xxxxxxxxxxxxxxxxx -// will use PAL_EPSILON / 10 and and expected result in the format of x.xxxxxxxxxxxxxxxx will -// use PAL_EPSILON * 10. -#define PAL_EPSILON 8.8817841970012523e-16 - -#define PAL_NAN sqrt(-1.0) -#define PAL_POSINF -log(0.0) -#define PAL_NEGINF log(0.0) - -/** - * Helper test structure - */ -struct test -{ - double value; /* value to test the function with */ - double expected; /* expected result */ - double variance; /* maximum delta between the expected and actual result */ -}; - -/** - * validate - * - * test validation function - */ -void __cdecl validate(double value, double expected, double variance) -{ - double result = exp(value); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - double delta = fabs(result - expected); - - if (delta > variance) - { - Fail("exp(%g) returned %20.17g when it should have returned %20.17g", - value, result, expected); - } -} - -/** - * validate - * - * test validation function for values returning NaN - */ -void __cdecl validate_isnan(double value) -{ - double result = exp(value); - - if (!_isnan(result)) - { - Fail("exp(%g) returned %20.17g when it should have returned %20.17g", - value, result, PAL_NAN); - } -} - -/** - * main - * - * executable entry point - */ -int __cdecl main(int argc, char **argv) -{ - struct test tests[] = - { - /* value expected variance */ - { PAL_NEGINF, 0, PAL_EPSILON }, - { -3.1415926535897932, 0.043213918263772250, PAL_EPSILON / 10 }, // value: -(pi) - { -2.7182818284590452, 0.065988035845312537, PAL_EPSILON / 10 }, // value: -(e) - { -2.3025850929940457, 0.1, PAL_EPSILON }, // value: -(ln(10)) - { -1.5707963267948966, 0.20787957635076191, PAL_EPSILON }, // value: -(pi / 2) - { -1.4426950408889634, 0.23629008834452270, PAL_EPSILON }, // value: -(log2(e)) - { -1.4142135623730950, 0.24311673443421421, PAL_EPSILON }, // value: -(sqrt(2)) - { -1.1283791670955126, 0.32355726390307110, PAL_EPSILON }, // value: -(2 / sqrt(pi)) - { -1, 0.36787944117144232, PAL_EPSILON }, // value: -(1) - { -0.78539816339744831, 0.45593812776599624, PAL_EPSILON }, // value: -(pi / 4) - { -0.70710678118654752, 0.49306869139523979, PAL_EPSILON }, // value: -(1 / sqrt(2)) - { -0.69314718055994531, 0.5, PAL_EPSILON }, // value: -(ln(2)) - { -0.63661977236758134, 0.52907780826773535, PAL_EPSILON }, // value: -(2 / pi) - { -0.43429448190325183, 0.64772148514180065, PAL_EPSILON }, // value: -(log10(e)) - { -0.31830988618379067, 0.72737734929521647, PAL_EPSILON }, // value: -(1 / pi) - { 0, 1, PAL_EPSILON * 10 }, - { 0.31830988618379067, 1.3748022274393586, PAL_EPSILON * 10 }, // value: 1 / pi - { 0.43429448190325183, 1.5438734439711811, PAL_EPSILON * 10 }, // value: log10(e) - { 0.63661977236758134, 1.8900811645722220, PAL_EPSILON * 10 }, // value: 2 / pi - { 0.69314718055994531, 2, PAL_EPSILON * 10 }, // value: ln(2) - { 0.70710678118654752, 2.0281149816474725, PAL_EPSILON * 10 }, // value: 1 / sqrt(2) - { 0.78539816339744831, 2.1932800507380155, PAL_EPSILON * 10 }, // value: pi / 4 - { 1, 2.7182818284590452, PAL_EPSILON * 10 }, // expected: e - { 1.1283791670955126, 3.0906430223107976, PAL_EPSILON * 10 }, // value: 2 / sqrt(pi) - { 1.4142135623730950, 4.1132503787829275, PAL_EPSILON * 10 }, // value: sqrt(2) - { 1.4426950408889634, 4.2320861065570819, PAL_EPSILON * 10 }, // value: log2(e) - { 1.5707963267948966, 4.8104773809653517, PAL_EPSILON * 10 }, // value: pi / 2 - { 2.3025850929940457, 10, PAL_EPSILON * 100 }, // value: ln(10) - { 2.7182818284590452, 15.154262241479264, PAL_EPSILON * 100 }, // value: e - { 3.1415926535897932, 23.140692632779269, PAL_EPSILON * 100 }, // value: pi - { PAL_POSINF, PAL_POSINF, 0 }, - }; - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - validate(tests[i].value, tests[i].expected, tests[i].variance); - } - - validate_isnan(PAL_NAN); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/exp/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/exp/test1/testinfo.dat deleted file mode 100644 index 65fc192cd..000000000 --- a/src/pal/tests/palsuite/c_runtime/exp/test1/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = exp -Name = Test #1 for exp -Type = DEFAULT -EXE1 = test1 -Description -=Tests exp with a normal set of values. diff --git a/src/pal/tests/palsuite/c_runtime/expf/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/expf/CMakeLists.txt deleted file mode 100644 index 5e1ef7f28..000000000 --- a/src/pal/tests/palsuite/c_runtime/expf/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) diff --git a/src/pal/tests/palsuite/c_runtime/expf/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/expf/test1/CMakeLists.txt deleted file mode 100644 index 5ff0d09d8..000000000 --- a/src/pal/tests/palsuite/c_runtime/expf/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.c -) - -add_executable(paltest_expf_test1 - ${SOURCES} -) - -add_dependencies(paltest_expf_test1 coreclrpal) - -target_link_libraries(paltest_expf_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/expf/test1/test1.c b/src/pal/tests/palsuite/c_runtime/expf/test1/test1.c deleted file mode 100644 index 32f4e8d26..000000000 --- a/src/pal/tests/palsuite/c_runtime/expf/test1/test1.c +++ /dev/null @@ -1,137 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test1.c -** -** Purpose: Tests expf with a normal set of values. -** -**===================================================================*/ - -#include - -// binary32 (float) has a machine epsilon of 2^-23 (approx. 1.19e-07). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-21 (approx. 4.76e-07) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (6-9 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxx will use PAL_EPSILON -// for the variance, while an expected result in the format of 0.0xxxxxxxxx will use -// PAL_EPSILON / 10 and and expected result in the format of x.xxxxxx will use PAL_EPSILON * 10. -#define PAL_EPSILON 4.76837158e-07 - -#define PAL_NAN sqrtf(-1.0f) -#define PAL_POSINF -logf(0.0f) -#define PAL_NEGINF logf(0.0f) - -/** - * Helper test structure - */ -struct test -{ - float value; /* value to test the function with */ - float expected; /* expected result */ - float variance; /* maximum delta between the expected and actual result */ -}; - -/** - * validate - * - * test validation function - */ -void __cdecl validate(float value, float expected, float variance) -{ - float result = expf(value); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - float delta = fabsf(result - expected); - - if (delta > variance) - { - Fail("expf(%g) returned %10.9g when it should have returned %10.9g", - value, result, expected); - } -} - -/** - * validate - * - * test validation function for values returning NaN - */ -void __cdecl validate_isnan(float value) -{ - float result = expf(value); - - if (!_isnanf(result)) - { - Fail("expf(%g) returned %10.9g when it should have returned %10.9g", - value, result, PAL_NAN); - } -} - -/** - * main - * - * executable entry point - */ -int __cdecl main(int argc, char **argv) -{ - struct test tests[] = - { - /* value expected variance */ - { PAL_NEGINF, 0, PAL_EPSILON }, - { -3.14159265f, 0.0432139183f, PAL_EPSILON / 10 }, // value: -(pi) - { -2.71828183f, 0.0659880358f, PAL_EPSILON / 10 }, // value: -(e) - { -2.30258509f, 0.1f, PAL_EPSILON }, // value: -(ln(10)) - { -1.57079633f, 0.207879576f, PAL_EPSILON }, // value: -(pi / 2) - { -1.44269504f, 0.236290088f, PAL_EPSILON }, // value: -(logf2(e)) - { -1.41421356f, 0.243116734f, PAL_EPSILON }, // value: -(sqrtf(2)) - { -1.12837917f, 0.323557264f, PAL_EPSILON }, // value: -(2 / sqrtf(pi)) - { -1, 0.367879441f, PAL_EPSILON }, // value: -(1) - { -0.785398163f, 0.455938128f, PAL_EPSILON }, // value: -(pi / 4) - { -0.707106781f, 0.493068691f, PAL_EPSILON }, // value: -(1 / sqrtf(2)) - { -0.693147181f, 0.5f, PAL_EPSILON }, // value: -(ln(2)) - { -0.636619772f, 0.529077808f, PAL_EPSILON }, // value: -(2 / pi) - { -0.434294482f, 0.647721485f, PAL_EPSILON }, // value: -(log10f(e)) - { -0.318309886f, 0.727377349f, PAL_EPSILON }, // value: -(1 / pi) - { 0, 1, PAL_EPSILON * 10 }, - { 0.318309886f, 1.37480223f, PAL_EPSILON * 10 }, // value: 1 / pi - { 0.434294482f, 1.54387344f, PAL_EPSILON * 10 }, // value: log10f(e) - { 0.636619772f, 1.89008116f, PAL_EPSILON * 10 }, // value: 2 / pi - { 0.693147181f, 2, PAL_EPSILON * 10 }, // value: ln(2) - { 0.707106781f, 2.02811498f, PAL_EPSILON * 10 }, // value: 1 / sqrtf(2) - { 0.785398163f, 2.19328005f, PAL_EPSILON * 10 }, // value: pi / 4 - { 1, 2.71828183f, PAL_EPSILON * 10 }, // expected: e - { 1.12837917f, 3.09064302f, PAL_EPSILON * 10 }, // value: 2 / sqrtf(pi) - { 1.41421356f, 4.11325038f, PAL_EPSILON * 10 }, // value: sqrtf(2) - { 1.44269504f, 4.23208611f, PAL_EPSILON * 10 }, // value: logf2(e) - { 1.57079633f, 4.81047738f, PAL_EPSILON * 10 }, // value: pi / 2 - { 2.30258509f, 10, PAL_EPSILON * 100 }, // value: ln(10) - { 2.71828183f, 15.1542622f, PAL_EPSILON * 100 }, // value: e - { 3.14159265f, 23.1406926f, PAL_EPSILON * 100 }, // value: pi - { PAL_POSINF, PAL_POSINF, 0 }, - }; - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - validate(tests[i].value, tests[i].expected, tests[i].variance); - } - - validate_isnan(PAL_NAN); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/expf/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/expf/test1/testinfo.dat deleted file mode 100644 index c35928501..000000000 --- a/src/pal/tests/palsuite/c_runtime/expf/test1/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = expf -Name = Test #1 for expf -Type = DEFAULT -EXE1 = test1 -Description -=Tests expf with a normal set of values. diff --git a/src/pal/tests/palsuite/c_runtime/fabs/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/fabs/CMakeLists.txt deleted file mode 100644 index 5e1ef7f28..000000000 --- a/src/pal/tests/palsuite/c_runtime/fabs/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) diff --git a/src/pal/tests/palsuite/c_runtime/fabs/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/fabs/test1/CMakeLists.txt deleted file mode 100644 index 9dab6796f..000000000 --- a/src/pal/tests/palsuite/c_runtime/fabs/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_fabs_test1 - ${SOURCES} -) - -add_dependencies(paltest_fabs_test1 coreclrpal) - -target_link_libraries(paltest_fabs_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/fabs/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/fabs/test1/test1.cpp deleted file mode 100644 index 0a74d5c1c..000000000 --- a/src/pal/tests/palsuite/c_runtime/fabs/test1/test1.cpp +++ /dev/null @@ -1,130 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================= -** -** Source: test1.c -** -** Purpose: Test to ensure that fabs return the correct values -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** Fail -** -**===========================================================================*/ - -#include - -// binary64 (double) has a machine epsilon of 2^-52 (approx. 2.22e-16). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-50 (approx. 8.88e-16) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (15-17 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxxxxxxxxxx will use -// PAL_EPSILON for the variance, while an expected result in the format of 0.0xxxxxxxxxxxxxxxxx -// will use PAL_EPSILON / 10 and and expected result in the format of x.xxxxxxxxxxxxxxxx will -// use PAL_EPSILON * 10. -#define PAL_EPSILON 8.8817841970012523e-16 - -#define PAL_NAN sqrt(-1.0) -#define PAL_POSINF -log(0.0) -#define PAL_NEGINF log(0.0) - -/** - * Helper test structure - */ -struct test -{ - double value; /* value to test the function with */ - double expected; /* expected result */ - double variance; /* maximum delta between the expected and actual result */ -}; - -/** - * validate - * - * test validation function - */ -void __cdecl validate(double value, double expected, double variance) -{ - double result = fabs(value); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - double delta = fabs(result - expected); - - if (delta > variance) - { - Fail("fabs(%g) returned %20.17g when it should have returned %20.17g", - value, result, expected); - } -} - -/** - * validate - * - * test validation function for values returning NaN - */ -void __cdecl validate_isnan(double value) -{ - double result = fabs(value); - - if (!_isnan(result)) - { - Fail("fabs(%g) returned %20.17g when it should have returned %20.17g", - value, result, PAL_NAN); - } -} - -/** - * main - * - * executable entry point - */ -INT __cdecl main(INT argc, CHAR **argv) -{ - struct test tests[] = - { - /* value expected variance */ - { PAL_NEGINF, PAL_POSINF, 0 }, - { -3.1415926535897932, 3.1415926535897932, PAL_EPSILON * 10 }, // value: -(pi) expected: pi - { -2.7182818284590452, 2.7182818284590452, PAL_EPSILON * 10 }, // value: -(e) expected: e - { -2.3025850929940457, 2.3025850929940457, PAL_EPSILON * 10 }, // value: -(ln(10)) expected: ln(10) - { -1.5707963267948966, 1.5707963267948966, PAL_EPSILON * 10 }, // value: -(pi / 2) expected: pi / 2 - { -1.4426950408889634, 1.4426950408889634, PAL_EPSILON * 10 }, // value: -(log2(e)) expected: log2(e) - { -1.4142135623730950, 1.4142135623730950, PAL_EPSILON * 10 }, // value: -(sqrt(2)) expected: sqrt(2) - { -1.1283791670955126, 1.1283791670955126, PAL_EPSILON * 10 }, // value: -(2 / sqrt(pi)) expected: 2 / sqrt(pi) - { -1, 1, PAL_EPSILON * 10 }, - { -0.78539816339744831, 0.78539816339744831, PAL_EPSILON }, // value: -(pi / 4) expected: pi / 4 - { -0.70710678118654752, 0.70710678118654752, PAL_EPSILON }, // value: -(1 / sqrt(2)) expected: 1 / sqrt(2) - { -0.69314718055994531, 0.69314718055994531, PAL_EPSILON }, // value: -(ln(2)) expected: ln(2) - { -0.63661977236758134, 0.63661977236758134, PAL_EPSILON }, // value: -(2 / pi) expected: 2 / pi - { -0.43429448190325183, 0.43429448190325183, PAL_EPSILON }, // value: -(log10(e)) expected: log10(e) - { -0.31830988618379067, 0.31830988618379067, PAL_EPSILON }, // value: -(1 / pi) expected: 1 / pi - { -0.0, 0, PAL_EPSILON }, - }; - - - // PAL initialization - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - validate( tests[i].value, tests[i].expected, tests[i].variance); - validate(-tests[i].value, tests[i].expected, tests[i].variance); - } - - validate_isnan(PAL_NAN); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/fabs/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/fabs/test1/testinfo.dat deleted file mode 100644 index d5b2321ed..000000000 --- a/src/pal/tests/palsuite/c_runtime/fabs/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = fabs -Name = Positive Test for fabs -TYPE = DEFAULT -EXE1 = test1 -Description -= Passes to fabs() a series of values, checking that -= each one return to correct value. diff --git a/src/pal/tests/palsuite/c_runtime/fabsf/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/fabsf/CMakeLists.txt deleted file mode 100644 index 5e1ef7f28..000000000 --- a/src/pal/tests/palsuite/c_runtime/fabsf/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) diff --git a/src/pal/tests/palsuite/c_runtime/fabsf/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/fabsf/test1/CMakeLists.txt deleted file mode 100644 index dc46a2335..000000000 --- a/src/pal/tests/palsuite/c_runtime/fabsf/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_fabsf_test1 - ${SOURCES} -) - -add_dependencies(paltest_fabsf_test1 coreclrpal) - -target_link_libraries(paltest_fabsf_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/fabsf/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/fabsf/test1/test1.cpp deleted file mode 100644 index 0b020729b..000000000 --- a/src/pal/tests/palsuite/c_runtime/fabsf/test1/test1.cpp +++ /dev/null @@ -1,130 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================= -** -** Source: test1.c -** -** Purpose: Test to ensure that fabsf return the correct values -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** Fail -** -**===========================================================================*/ - -#include - -// binary32 (float) has a machine epsilon of 2^-23 (approx. 1.19e-07). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-21 (approx. 4.76e-07) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (6-9 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxx will use PAL_EPSILON -// for the variance, while an expected result in the format of 0.0xxxxxxxxx will use -// PAL_EPSILON / 10 and and expected result in the format of x.xxxxxx will use PAL_EPSILON * 10. -#define PAL_EPSILON 4.76837158e-07 - - -#define PAL_NAN sqrt(-1.0) -#define PAL_POSINF -log(0.0) -#define PAL_NEGINF log(0.0) - -/** - * Helper test structure - */ -struct test -{ - float value; /* value to test the function with */ - float expected; /* expected result */ - float variance; /* maximum delta between the expected and actual result */ -}; - -/** - * validate - * - * test validation function - */ -void __cdecl validate(float value, float expected, float variance) -{ - float result = fabsf(value); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - float delta = fabsf(result - expected); - - if (delta > variance) - { - Fail("fabsf(%g) returned %10.9g when it should have returned %10.9g", - value, result, expected); - } -} - -/** - * validate - * - * test validation function for values returning NaN - */ -void __cdecl validate_isnan(float value) -{ - float result = fabsf(value); - - if (!_isnan(result)) - { - Fail("fabsf(%g) returned %10.9g when it should have returned %10.9g", - value, result, PAL_NAN); - } -} - -/** - * main - * - * executable entry point - */ -INT __cdecl main(INT argc, CHAR **argv) -{ - struct test tests[] = - { - /* value expected variance */ - { PAL_NEGINF, PAL_POSINF, 0 }, - { -3.14159265f, 3.14159265f, PAL_EPSILON * 10 }, // value: -(pi) expected: pi - { -2.71828183f, 2.71828183f, PAL_EPSILON * 10 }, // value: -(e) expected: e - { -2.30258509f, 2.30258509f, PAL_EPSILON * 10 }, // value: -(ln(10)) expected: ln(10) - { -1.57079633f, 1.57079633f, PAL_EPSILON * 10 }, // value: -(pi / 2) expected: pi / 2 - { -1.44269504f, 1.44269504f, PAL_EPSILON * 10 }, // value: -(log2(e)) expected: log2(e) - { -1.41421356f, 1.41421356f, PAL_EPSILON * 10 }, // value: -(sqrt(2)) expected: sqrt(2) - { -1.12837917f, 1.12837917f, PAL_EPSILON * 10 }, // value: -(2 / sqrt(pi)) expected: 2 / sqrt(pi) - { -1, 1, PAL_EPSILON * 10 }, - { -0.785398163f, 0.785398163f, PAL_EPSILON }, // value: -(pi / 4) expected: pi / 4 - { -0.707106781f, 0.707106781f, PAL_EPSILON }, // value: -(1 / sqrt(2)) expected: 1 / sqrt(2) - { -0.693147181f, 0.693147181f, PAL_EPSILON }, // value: -(ln(2)) expected: ln(2) - { -0.636619772f, 0.636619772f, PAL_EPSILON }, // value: -(2 / pi) expected: 2 / pi - { -0.434294482f, 0.434294482f, PAL_EPSILON }, // value: -(log10(e)) expected: log10(e) - { -0.318309886f, 0.318309886f, PAL_EPSILON }, // value: -(1 / pi) expected: 1 / pi - { -0.0f, 0, PAL_EPSILON }, - }; - - - // PAL initialization - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - validate( tests[i].value, tests[i].expected, tests[i].variance); - validate(-tests[i].value, tests[i].expected, tests[i].variance); - } - - validate_isnan(PAL_NAN); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/fabsf/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/fabsf/test1/testinfo.dat deleted file mode 100644 index a927f1e3d..000000000 --- a/src/pal/tests/palsuite/c_runtime/fabsf/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = fabsf -Name = Positive Test for fabsf -TYPE = DEFAULT -EXE1 = test1 -Description -= Passes to fabsf() a series of values, checking that -= each one return to correct value. diff --git a/src/pal/tests/palsuite/c_runtime/fclose/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/fclose/CMakeLists.txt deleted file mode 100644 index ef14ea535..000000000 --- a/src/pal/tests/palsuite/c_runtime/fclose/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) - diff --git a/src/pal/tests/palsuite/c_runtime/fclose/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/fclose/test1/CMakeLists.txt deleted file mode 100644 index 5fe80e02b..000000000 --- a/src/pal/tests/palsuite/c_runtime/fclose/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_fclose_test1 - ${SOURCES} -) - -add_dependencies(paltest_fclose_test1 coreclrpal) - -target_link_libraries(paltest_fclose_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/fclose/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/fclose/test1/test1.cpp deleted file mode 100644 index 0a8463823..000000000 --- a/src/pal/tests/palsuite/c_runtime/fclose/test1/test1.cpp +++ /dev/null @@ -1,79 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test1.c (fclose) -** -** Purpose: Tests the PAL implementation of the fclose function. -** This test will use fdopen to create a file stream, -** that will be used to test fclose. fclose will also -** be passed a closed file handle to make sure it handle -** it accordingly. -** -** -**===================================================================*/ - -#include - -int __cdecl main(int argc, char **argv) -{ - HANDLE hReadPipe = NULL; - HANDLE hWritePipe = NULL; - BOOL bRetVal = FALSE; - int iFiledes = 0; - FILE *fp; - - SECURITY_ATTRIBUTES lpPipeAttributes; - - /*Initialize the PAL*/ - if ((PAL_Initialize(argc, argv)) != 0) - { - return (FAIL); - } - - /*Setup SECURITY_ATTRIBUTES structure for CreatePipe*/ - lpPipeAttributes.nLength = sizeof(lpPipeAttributes); - lpPipeAttributes.lpSecurityDescriptor = NULL; - lpPipeAttributes.bInheritHandle = TRUE; - - /*Create a Pipe*/ - bRetVal = CreatePipe(&hReadPipe, // read handle - &hWritePipe, // write handle - &lpPipeAttributes,// security attributes - 0); // pipe size - - if (bRetVal == FALSE) - { - Fail("ERROR: Unable to create pipe; returned error code %ld" - , GetLastError()); - } - - /*Get a file descriptor for the read pipe handle*/ - iFiledes = _open_osfhandle((long)hReadPipe,_O_RDONLY); - - if (iFiledes == -1) - { - Fail("ERROR: _open_osfhandle failed to open " - " hReadPipe=0x%lx", hReadPipe); - } - - /*Open read pipe handle in read mode*/ - fp = _fdopen(iFiledes, "r"); - - if (fp == NULL) - { - Fail("ERROR: unable to fdopen file descriptor" - " iFiledes=%d", iFiledes); - } - - /*Attempt to close the file stream*/ - if (fclose(fp) != 0) - { - Fail("ERROR: Unable to fclose file stream fp=0x%lx\n",fp); - } - - PAL_Terminate(); - return (PASS); -} diff --git a/src/pal/tests/palsuite/c_runtime/fclose/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/fclose/test1/testinfo.dat deleted file mode 100644 index 0904c4fa9..000000000 --- a/src/pal/tests/palsuite/c_runtime/fclose/test1/testinfo.dat +++ /dev/null @@ -1,18 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = fclose -Name = Test for fclose -TYPE = DEFAULT -EXE1 = test1 -Description -= Tests the PAL implementation of the fclose function. -= This test will use fdopen to create a file stream, -= that will be used to test fclose. fclose will also -= be passed a closed file handle to make sure it handle -= it accordingly. - - diff --git a/src/pal/tests/palsuite/c_runtime/fclose/test2/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/fclose/test2/CMakeLists.txt deleted file mode 100644 index efe4c8520..000000000 --- a/src/pal/tests/palsuite/c_runtime/fclose/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test2.cpp -) - -add_executable(paltest_fclose_test2 - ${SOURCES} -) - -add_dependencies(paltest_fclose_test2 coreclrpal) - -target_link_libraries(paltest_fclose_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/fclose/test2/test2.cpp b/src/pal/tests/palsuite/c_runtime/fclose/test2/test2.cpp deleted file mode 100644 index f4da53553..000000000 --- a/src/pal/tests/palsuite/c_runtime/fclose/test2/test2.cpp +++ /dev/null @@ -1,77 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test2.c (fclose) -** -** Purpose: Tests the PAL implementation of the fclose function. -** fclose will be passed a closed file handle to make -** sure it handles it accordingly. -** -** -**===================================================================*/ - -#include - -int __cdecl main(int argc, char **argv) -{ - HANDLE hReadPipe = NULL; - HANDLE hWritePipe = NULL; - BOOL bRetVal = FALSE; - int iFiledes = 0; - FILE *fp; - - SECURITY_ATTRIBUTES lpPipeAttributes; - - /*Initialize the PAL*/ - if ((PAL_Initialize(argc, argv)) != 0) - { - return (FAIL); - } - - /*Setup SECURITY_ATTRIBUTES structure for CreatePipe*/ - lpPipeAttributes.nLength = sizeof(lpPipeAttributes); - lpPipeAttributes.lpSecurityDescriptor = NULL; - lpPipeAttributes.bInheritHandle = TRUE; - - /*Create a Pipe*/ - bRetVal = CreatePipe(&hReadPipe, /* read handle */ - &hWritePipe, /* write handle */ - &lpPipeAttributes,/* security attributes */ - 0); /* pipe size */ - - if (bRetVal == FALSE) - { - Fail("ERROR: Unable to create pipe; returned error code %ld" - , GetLastError()); - } - - /*Get a file descriptor for the read pipe handle*/ - iFiledes = _open_osfhandle((long)hReadPipe,_O_RDONLY); - - if (iFiledes == -1) - { - Fail("ERROR: _open_osfhandle failed to open " - " hReadPipe=0x%lx", hReadPipe); - } - - /*Open read pipe handle in read mode*/ - fp = _fdopen(iFiledes, "r"); - - if (fp == NULL) - { - Fail("ERROR: unable to fdopen file descriptor" - " iFiledes=%d", iFiledes); - } - - /*Attempt to close the file stream*/ - if (fclose(fp) != 0) - { - Fail("ERROR: Unable to fclose file stream fp=0x%lx\n", fp); - } - - PAL_Terminate(); - return (PASS); -} diff --git a/src/pal/tests/palsuite/c_runtime/fclose/test2/testinfo.dat b/src/pal/tests/palsuite/c_runtime/fclose/test2/testinfo.dat deleted file mode 100644 index 192b8d2f6..000000000 --- a/src/pal/tests/palsuite/c_runtime/fclose/test2/testinfo.dat +++ /dev/null @@ -1,15 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = fclose -Name = Test for fclose -TYPE = DEFAULT -EXE1 = test2 -LANG = cpp -Description -= Tests the PAL implementation of the fclose function. -= fclose will be passed a closed file handle to -= make sure it handles it accordingly. diff --git a/src/pal/tests/palsuite/c_runtime/feof/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/feof/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/c_runtime/feof/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/c_runtime/feof/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/feof/test1/CMakeLists.txt deleted file mode 100644 index e87003845..000000000 --- a/src/pal/tests/palsuite/c_runtime/feof/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_feof_test1 - ${SOURCES} -) - -add_dependencies(paltest_feof_test1 coreclrpal) - -target_link_libraries(paltest_feof_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/feof/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/feof/test1/test1.cpp deleted file mode 100644 index ba018aa91..000000000 --- a/src/pal/tests/palsuite/c_runtime/feof/test1/test1.cpp +++ /dev/null @@ -1,88 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test1.c -** -** Purpose: Tests the PAL implementation of the feof function. -** Open a file, and read some characters. Check that -** feof states that it hasn't gone by the EOF. Then -** read enough characters to go beyond the EOF, and check -** that feof states this is so. -** -** Depends: -** fopen -** fread -** -** -** -**===================================================================*/ - -/* The file 'testfile' should exist with 15 characters in it. If not, - something has been lost ... -*/ - -#include - -int __cdecl main(int argc, char **argv) -{ - const char filename[] = "testfile"; - char buffer[128]; - FILE * fp = NULL; - int result; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - /* Open a file in READ mode */ - - if((fp = fopen(filename, "r")) == NULL) - { - Fail("Unable to open a file for reading. Is the file " - "in the directory? It should be."); - } - - /* Read 10 characters from the file. The file has 15 - characters in it. - */ - - if((result = fread(buffer,1,10,fp)) == 0) - { - Fail("ERROR: Zero characters read from the file. It should have " - "read 10 character in it."); - } - - if(feof(fp)) - { - Fail("ERROR: feof returned a value greater than 0. No read " - "operation has gone beyond the EOF yet, and feof should " - "return 0 still."); - } - - /* Read 10 characters from the file. The file has 15 - characters in it. The file pointer should have no passed - the end of file. - */ - - if((result = fread(buffer,1,10,fp)) == 0) - { - Fail("ERROR: Zero characters read from the file. It should have " - "read 5 character in it."); - } - - if(feof(fp) == 0) - { - Fail("ERROR: feof returned 0. The file pointer has gone beyond " - "the EOF and this function should return positive now."); - } - - PAL_Terminate(); - return PASS; -} - - diff --git a/src/pal/tests/palsuite/c_runtime/feof/test1/testfile b/src/pal/tests/palsuite/c_runtime/feof/test1/testfile deleted file mode 100644 index 273c1a9ff..000000000 --- a/src/pal/tests/palsuite/c_runtime/feof/test1/testfile +++ /dev/null @@ -1 +0,0 @@ -This is a test. \ No newline at end of file diff --git a/src/pal/tests/palsuite/c_runtime/feof/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/feof/test1/testinfo.dat deleted file mode 100644 index e14044ee1..000000000 --- a/src/pal/tests/palsuite/c_runtime/feof/test1/testinfo.dat +++ /dev/null @@ -1,16 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = feof -Name = Positive Test for feof -TYPE = DEFAULT -EXE1 = test1 -Description -= Tests the PAL implementation of the feof function. -= Open a file, and read some characters. Check that feof states that -= it hasn't gone by the EOF. Then read enough characters to go beyond -= the EOF, and check that feof states this is so. - diff --git a/src/pal/tests/palsuite/c_runtime/ferror/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/ferror/CMakeLists.txt deleted file mode 100644 index ef14ea535..000000000 --- a/src/pal/tests/palsuite/c_runtime/ferror/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) - diff --git a/src/pal/tests/palsuite/c_runtime/ferror/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/ferror/test1/CMakeLists.txt deleted file mode 100644 index e8a282f6b..000000000 --- a/src/pal/tests/palsuite/c_runtime/ferror/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_ferror_test1 - ${SOURCES} -) - -add_dependencies(paltest_ferror_test1 coreclrpal) - -target_link_libraries(paltest_ferror_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/ferror/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/ferror/test1/test1.cpp deleted file mode 100644 index 516f2531e..000000000 --- a/src/pal/tests/palsuite/c_runtime/ferror/test1/test1.cpp +++ /dev/null @@ -1,74 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test1.c -** -** Purpose: Tests the PAL implementation of the ferror function. -** -** Depends: -** fopen -** fread -** fclose -** -** -** -**===================================================================*/ - -#include - -int __cdecl main(int argc, char **argv) -{ - const char filename[] = "testfile"; - char buffer[128]; - FILE * fp = NULL; - int result; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - /* Open a file in READ mode */ - - if((fp = fopen(filename, "r")) == NULL) - { - Fail("Unable to open a file for reading. Is the file " - "in the directory? It should be."); - } - - /* Read 10 characters from the file. The file has 15 - characters in it. - */ - - if((result = fread(buffer,1,10,fp)) == 0) - { - Fail("ERROR: Zero characters read from the file. It should have " - "read 10 character in from a 15 character file."); - } - - if(ferror(fp) != 0) - { - Fail("ERROR: ferror returned a value not equal to 0. The read " - "operation shouldn't have caused an error, and ferror should " - "return 0 still."); - } - - /* - Close the open file and end the test. - */ - - if(fclose(fp) != 0) - { - Fail("ERROR: fclose failed when trying to close a file pointer. " - "This test depends on fclose working properly."); - } - - PAL_Terminate(); - return PASS; -} - - diff --git a/src/pal/tests/palsuite/c_runtime/ferror/test1/testfile b/src/pal/tests/palsuite/c_runtime/ferror/test1/testfile deleted file mode 100644 index 273c1a9ff..000000000 --- a/src/pal/tests/palsuite/c_runtime/ferror/test1/testfile +++ /dev/null @@ -1 +0,0 @@ -This is a test. \ No newline at end of file diff --git a/src/pal/tests/palsuite/c_runtime/ferror/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/ferror/test1/testinfo.dat deleted file mode 100644 index 32e55a3b0..000000000 --- a/src/pal/tests/palsuite/c_runtime/ferror/test1/testinfo.dat +++ /dev/null @@ -1,16 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = ferror -Name = Positive Test for ferror -TYPE = DEFAULT -EXE1 = test1 -Description -= Tests the PAL implementation of the ferror function. -= Open a file, and read some characters. Check that ferror states that -= no error has occurred. Then close the file pointer. Attempt to read -= some more. Check ferror now, and it should indicate that an error has -= occurred. diff --git a/src/pal/tests/palsuite/c_runtime/ferror/test2/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/ferror/test2/CMakeLists.txt deleted file mode 100644 index deb3f1f92..000000000 --- a/src/pal/tests/palsuite/c_runtime/ferror/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test2.cpp -) - -add_executable(paltest_ferror_test2 - ${SOURCES} -) - -add_dependencies(paltest_ferror_test2 coreclrpal) - -target_link_libraries(paltest_ferror_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/ferror/test2/test2.cpp b/src/pal/tests/palsuite/c_runtime/ferror/test2/test2.cpp deleted file mode 100644 index fdf9e032c..000000000 --- a/src/pal/tests/palsuite/c_runtime/ferror/test2/test2.cpp +++ /dev/null @@ -1,69 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test2.c -** -** Purpose: Open a read-only file and attempt to write some data to it. -** Check to ensure that an ferror occurs. -** -** Depends: -** fopen -** fwrite -** fclose -** -** -** -**===================================================================*/ - -#include - -int __cdecl main(int argc, char **argv) -{ - const char filename[] = "testfile"; - FILE * fp = NULL; - int result; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - /* Open a file in READONLY mode */ - - if((fp = fopen(filename, "r")) == NULL) - { - Fail("Unable to open a file for reading."); - } - - /* Attempt to write 14 characters to the file. */ - - if((result = fwrite("This is a test",1,14,fp)) != 0) - { - Fail("ERROR: %d characters written. 0 characters should " - "have been written, since this file is read-only.", result); - } - - if(ferror(fp) == 0) - { - Fail("ERROR: ferror should have generated an error when " - "write was called on a read-only file. But, it " - "retured 0, indicating no error.\n"); - } - - /* Close the file. */ - - if(fclose(fp) != 0) - { - Fail("ERROR: fclose failed when trying to close a file pointer. " - "This test depends on fclose working properly."); - } - - - PAL_Terminate(); - return PASS; -} - - diff --git a/src/pal/tests/palsuite/c_runtime/ferror/test2/testfile b/src/pal/tests/palsuite/c_runtime/ferror/test2/testfile deleted file mode 100644 index 0135842a0..000000000 --- a/src/pal/tests/palsuite/c_runtime/ferror/test2/testfile +++ /dev/null @@ -1 +0,0 @@ -This is a test file. This needs to be kept in CVS. \ No newline at end of file diff --git a/src/pal/tests/palsuite/c_runtime/ferror/test2/testinfo.dat b/src/pal/tests/palsuite/c_runtime/ferror/test2/testinfo.dat deleted file mode 100644 index d724a4c4e..000000000 --- a/src/pal/tests/palsuite/c_runtime/ferror/test2/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = ferror -Name = Positive Test for ferror, call write on a readonly file. -TYPE = DEFAULT -EXE1 = test2 -Description -= Open a read-only file and attempt to write some data to it. -= Check to ensure that an ferror occurs. diff --git a/src/pal/tests/palsuite/c_runtime/fflush/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/fflush/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/c_runtime/fflush/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/c_runtime/fflush/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/fflush/test1/CMakeLists.txt deleted file mode 100644 index ef13ca419..000000000 --- a/src/pal/tests/palsuite/c_runtime/fflush/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_fflush_test1 - ${SOURCES} -) - -add_dependencies(paltest_fflush_test1 coreclrpal) - -target_link_libraries(paltest_fflush_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/fflush/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/fflush/test1/test1.cpp deleted file mode 100644 index 7baf9ba5b..000000000 --- a/src/pal/tests/palsuite/c_runtime/fflush/test1/test1.cpp +++ /dev/null @@ -1,80 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: Tests to see that fflush is working properly. Flushes a couple -** buffers and checks the return value. Can't figure out a way to test -** and ensure it is really dropping the buffers, since the system -** does this automatically most of the time ... -** -** -**==========================================================================*/ - -/* This function is really tough to test. Right now it just tests - a bunch of return values. No solid way to ensure that it is really - flushing a buffer or not -- might have to be a manual test someday. -*/ - -#include - - -int __cdecl main(int argc, char **argv) -{ - - int TheReturn; - FILE* TheFile; - FILE* AnotherFile = NULL; - - PAL_Initialize(argc,argv); - - TheFile = fopen("theFile","w+"); - - if(TheFile == NULL) - { - Fail("ERROR: fopen failed. Test depends on this function."); - } - - TheReturn = fwrite("foo",3,3,TheFile); - - if(TheReturn != 3) - { - Fail("ERROR: fwrite failed. Test depends on this function."); - } - - /* Test to see that FlushFileBuffers returns a success value */ - TheReturn = fflush(TheFile); - - if(TheReturn != 0) - { - Fail("ERROR: The fflush function returned non-zero, which " - "indicates failure, when trying to flush a buffer."); - } - - /* Test to see that FlushFileBuffers returns a success value */ - TheReturn = fflush(NULL); - - if(TheReturn != 0) - { - Fail("ERROR: The fflush function returned non-zero, which " - "indicates failure, when trying to flush all buffers."); - } - - /* Test to see that FlushFileBuffers returns a success value */ - TheReturn = fflush(AnotherFile); - - if(TheReturn != 0) - { - Fail("ERROR: The fflush function returned non-zero, which " - "indicates failure, when trying to flush a stream not " - "associated with a file."); - } - - PAL_Terminate(); - return PASS; -} - - diff --git a/src/pal/tests/palsuite/c_runtime/fflush/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/fflush/test1/testinfo.dat deleted file mode 100644 index 1cff5a94a..000000000 --- a/src/pal/tests/palsuite/c_runtime/fflush/test1/testinfo.dat +++ /dev/null @@ -1,15 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = fflush -Name = Positive Test for fflush -TYPE = DEFAULT -EXE1 = test1 -Description -= Tests to see that fflush is working properly. Flushes a couple -= buffers and checks the return value. Can't figure out a way to test -= and ensure it is really dropping the buffers, since the system -= does this automatically most of the time ... diff --git a/src/pal/tests/palsuite/c_runtime/fgets/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/fgets/CMakeLists.txt deleted file mode 100644 index 1962ade35..000000000 --- a/src/pal/tests/palsuite/c_runtime/fgets/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) -add_subdirectory(test3) - diff --git a/src/pal/tests/palsuite/c_runtime/fgets/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/fgets/test1/CMakeLists.txt deleted file mode 100644 index 40f9c6587..000000000 --- a/src/pal/tests/palsuite/c_runtime/fgets/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_fgets_test1 - ${SOURCES} -) - -add_dependencies(paltest_fgets_test1 coreclrpal) - -target_link_libraries(paltest_fgets_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/fgets/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/fgets/test1/test1.cpp deleted file mode 100644 index 5e0e62dec..000000000 --- a/src/pal/tests/palsuite/c_runtime/fgets/test1/test1.cpp +++ /dev/null @@ -1,102 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: Writes a simple file and calls fgets() to get a string shorter -** than the first line of the file. Verifies that the correct -** string is returned. -** -** -**==========================================================================*/ - -#include - -int __cdecl main(int argc, char **argv) -{ - const char outBuf1[] = "This is a test.\n"; - const char outBuf2[] = "This is too."; - char inBuf[sizeof(outBuf1) + sizeof(outBuf2)]; - const char filename[] = "testfile.tmp"; - const int offset = 5; /* value chosen arbitrarily */ - int actualLen; - int expectedLen; - FILE * fp; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - /*write the file that we will use to test */ - fp = fopen(filename, "w"); - if (fp == NULL) - { - Fail("Unable to open file for write.\n"); - } - - fwrite(outBuf1, sizeof(outBuf1[0]), sizeof(outBuf1), fp); - fwrite(outBuf2, sizeof(outBuf2[0]), sizeof(outBuf2), fp); - - if (fclose(fp) != 0) - { - Fail("Error closing a file opened for write.\n"); - } - - - /*now read back the entire first string*/ - fp = fopen(filename, "r"); - if (fp == NULL) - { - Fail("Unable to open file for read.\n"); - } - - /*note: +1 because strlen() returns the length of a string _not_ - including the NULL, while fgets() returns a string of specified - maximum length _including_ the NULL.*/ - if (fgets(inBuf, strlen(outBuf1) - offset + 1, fp) != inBuf) - { - Fail("Error reading from file using fgets.\n"); - } - - - expectedLen = strlen(outBuf1) - offset; - actualLen = strlen(inBuf); - - if (actualLen < expectedLen) - { - Fail("fgets() was asked to read a one-line string and given the " - "length of the string as a parameter. The string it has " - "read is too short.\n"); - } - if (actualLen > expectedLen) - { - Fail("fgets() was asked to read a one-line string and given the " - "length of the string as a parameter. The string it has " - "read is too long.\n"); - } - if (memcmp(inBuf, outBuf1, actualLen) != 0) - { - /*We didn't read back exactly outBuf1*/ - Fail("fgets() was asked to read a one-line string, and given the " - "length of the string as an parameter. It has returned a " - "string of the correct length, but the contents are not " - "correct.\n"); - } - - if (fclose(fp) != 0) - { - Fail("Error closing file after using fgets().\n"); - } - - - PAL_Terminate(); - return PASS; - -} - - diff --git a/src/pal/tests/palsuite/c_runtime/fgets/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/fgets/test1/testinfo.dat deleted file mode 100644 index 70ea6690c..000000000 --- a/src/pal/tests/palsuite/c_runtime/fgets/test1/testinfo.dat +++ /dev/null @@ -1,15 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = fgets -Name = Positive Test for fgets -TYPE = DEFAULT -EXE1 = test1 -Description -= Writes a simple file and calls fgets() to get a string shorter than -= the first line of the file. Verifies that the correct string is -= returned. - diff --git a/src/pal/tests/palsuite/c_runtime/fgets/test2/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/fgets/test2/CMakeLists.txt deleted file mode 100644 index a2d2563df..000000000 --- a/src/pal/tests/palsuite/c_runtime/fgets/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test2.cpp -) - -add_executable(paltest_fgets_test2 - ${SOURCES} -) - -add_dependencies(paltest_fgets_test2 coreclrpal) - -target_link_libraries(paltest_fgets_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/fgets/test2/test2.cpp b/src/pal/tests/palsuite/c_runtime/fgets/test2/test2.cpp deleted file mode 100644 index fa37cdbc1..000000000 --- a/src/pal/tests/palsuite/c_runtime/fgets/test2/test2.cpp +++ /dev/null @@ -1,97 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test2.c -** -** Purpose: Calls fgets to read a full line from a file. A maximum length -** parameter greater than the length of the line is passed. -** -** -**==========================================================================*/ - -#include - -int __cdecl main(int argc, char **argv) -{ - const char outBuf1[] = "This is a test.\n"; - const char outBuf2[] = "This is too."; - - char inBuf[sizeof(outBuf1) + sizeof(outBuf2)]; - const char filename[] = "testfile.tmp"; - const int offset = 5; /*value chosen arbitrarily*/ - int expectedLen; - int actualLen; - - FILE * fp; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - /*write the file that we will use to test */ - fp = fopen(filename, "w"); - if (fp == NULL) - { - Fail("Unable to open file for write.\n"); - } - - fwrite(outBuf1, sizeof(outBuf1[0]), sizeof(outBuf1), fp); - fwrite(outBuf2, sizeof(outBuf2[0]), sizeof(outBuf2), fp); - - if (fclose(fp) != 0) - { - Fail("error closing stream opened for write.\n"); - } - - /*Read until the first linebreak*/ - fp = fopen(filename, "r"); - if (fp == NULL) - { - Fail("Unable to open file for read.\n"); - } - - - if (fgets(inBuf, sizeof(outBuf1) + offset , fp) != inBuf) - { - Fail("Error reading from file using fgets.\n"); - } - - /*note: -1 because strlen returns the length of a string _not_ - including the NULL, while fgets returns a string of specified - maximum length _including_ the NULL.*/ - expectedLen = strlen(outBuf1); - actualLen = strlen(inBuf); - if (actualLen > expectedLen) - { - Fail("fgets() was asked to read the first line of a file, but did " - "not stop at the end of the line.\n"); - } - else if (actualLen < expectedLen) - { - Fail("fgets() was asked to read the first line of a file, but did " - "not read the entire line.\n"); - } - else if (memcmp(inBuf, outBuf1, actualLen) != 0) - { - /*We didn't read back exactly outBuf1*/ - Fail("fgets() was asked to read the first line of a file. It " - "has read back a string of the correct length, but the" - " contents are not correct.\n"); - } - - if (fclose(fp) != 0) - { - Fail("Error closing file after using fgets().\n"); - } - - PAL_Terminate(); - return PASS; - -} - - diff --git a/src/pal/tests/palsuite/c_runtime/fgets/test2/testinfo.dat b/src/pal/tests/palsuite/c_runtime/fgets/test2/testinfo.dat deleted file mode 100644 index d282dbaa6..000000000 --- a/src/pal/tests/palsuite/c_runtime/fgets/test2/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = fgets -Name = Positive Test for fgets -TYPE = DEFAULT -EXE1 = test2 -Description -= Calls fgets to read a full line from a file. A maximum length -= parameter greater than the length of the line is passed. - diff --git a/src/pal/tests/palsuite/c_runtime/fgets/test3/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/fgets/test3/CMakeLists.txt deleted file mode 100644 index 37398b834..000000000 --- a/src/pal/tests/palsuite/c_runtime/fgets/test3/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test3.cpp -) - -add_executable(paltest_fgets_test3 - ${SOURCES} -) - -add_dependencies(paltest_fgets_test3 coreclrpal) - -target_link_libraries(paltest_fgets_test3 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/fgets/test3/test3.cpp b/src/pal/tests/palsuite/c_runtime/fgets/test3/test3.cpp deleted file mode 100644 index 525ba9327..000000000 --- a/src/pal/tests/palsuite/c_runtime/fgets/test3/test3.cpp +++ /dev/null @@ -1,73 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test3.c -** -** Purpose: Tries to read from an empty file using fgets(), to verify -** handling of EOF condition. -** -** -**==========================================================================*/ - -#include - -int __cdecl main(int argc, char **argv) -{ - char inBuf[10]; - const char filename[] = "testfile.tmp"; - - FILE * fp; - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - /*write the empty file that we will use to test */ - fp = fopen(filename, "w"); - if (fp == NULL) - { - Fail("Unable to open file for write.\n"); - } - - /*Don't write anything*/ - - if (fclose(fp) != 0) - { - Fail("Error closing stream opened for write.\n"); - } - - - /*Open the file and try to read.*/ - fp = fopen(filename, "r"); - if (fp == NULL) - { - Fail("Unable to open file for read.\n"); - } - - - if (fgets(inBuf, sizeof(inBuf) , fp) != NULL) - { - /*NULL could also mean an error condition, but since the PAL - doesn't supply feof or ferror, we can't distinguish between - the two.*/ - Fail("fgets doesn't handle EOF properly. When asked to read from " - "an empty file, it didn't return NULL as it should have.\n"); - } - - if (fclose(fp) != 0) - { - Fail("Error closing an empty file after trying to use fgets().\n"); - } - PAL_Terminate(); - return PASS; - -} - - - - - diff --git a/src/pal/tests/palsuite/c_runtime/fgets/test3/testinfo.dat b/src/pal/tests/palsuite/c_runtime/fgets/test3/testinfo.dat deleted file mode 100644 index e10cf8996..000000000 --- a/src/pal/tests/palsuite/c_runtime/fgets/test3/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = fgets -Name = Positive Test for fgets -TYPE = DEFAULT -EXE1 = test3 -Description -= Tries to read from an empty file using fgets(), to verify handling of -= EOF condition. - diff --git a/src/pal/tests/palsuite/c_runtime/floor/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/floor/CMakeLists.txt deleted file mode 100644 index 5e1ef7f28..000000000 --- a/src/pal/tests/palsuite/c_runtime/floor/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) diff --git a/src/pal/tests/palsuite/c_runtime/floor/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/floor/test1/CMakeLists.txt deleted file mode 100644 index 4324626b8..000000000 --- a/src/pal/tests/palsuite/c_runtime/floor/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_floor_test1 - ${SOURCES} -) - -add_dependencies(paltest_floor_test1 coreclrpal) - -target_link_libraries(paltest_floor_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/floor/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/floor/test1/test1.cpp deleted file mode 100644 index dba320919..000000000 --- a/src/pal/tests/palsuite/c_runtime/floor/test1/test1.cpp +++ /dev/null @@ -1,132 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: Tests floor with simple positive and negative values. Also tests -** extreme cases like extremely small values and positive and -** negative infinity. Makes sure that calling floor on NaN returns -** NaN -** -**==========================================================================*/ - -#include - -// binary64 (double) has a machine epsilon of 2^-52 (approx. 2.22e-16). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-50 (approx. 8.88e-16) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (15-17 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxxxxxxxxxx will use -// PAL_EPSILON for the variance, while an expected result in the format of 0.0xxxxxxxxxxxxxxxxx -// will use PAL_EPSILON / 10 and and expected result in the format of x.xxxxxxxxxxxxxxxx will -// use PAL_EPSILON * 10. -#define PAL_EPSILON 8.8817841970012523e-16 - -#define PAL_NAN sqrt(-1.0) -#define PAL_POSINF -log(0.0) -#define PAL_NEGINF log(0.0) - -/** - * Helper test structure - */ -struct test -{ - double value; /* value to test the function with */ - double expected; /* expected result */ - double variance; /* maximum delta between the expected and actual result */ -}; - -/** - * validate - * - * test validation function - */ -void __cdecl validate(double value, double expected, double variance) -{ - double result = floor(value); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - double delta = fabs(result - expected); - - if (delta > variance) - { - Fail("floor(%g) returned %20.17g when it should have returned %20.17g", - value, result, expected); - } -} - -/** - * validate - * - * test validation function for values returning NaN - */ -void __cdecl validate_isnan(double value) -{ - double result = floor(value); - - if (!_isnan(result)) - { - Fail("floor(%g) returned %20.17g when it should have returned %20.17g", - value, result, PAL_NAN); - } -} - -/** - * main - * - * executable entry point - */ -int __cdecl main(int argc, char *argv[]) -{ - struct test tests[] = - { - /* value expected variance */ - { 0.31830988618379067, 0, PAL_EPSILON }, // value: 1 / pi - { 0.43429448190325183, 0, PAL_EPSILON }, // value: log10(e) - { 0.63661977236758134, 0, PAL_EPSILON }, // value: 2 / pi - { 0.69314718055994531, 0, PAL_EPSILON }, // value: ln(2) - { 0.70710678118654752, 0, PAL_EPSILON }, // value: 1 / sqrt(2) - { 0.78539816339744831, 0, PAL_EPSILON }, // value: pi / 4 - { 1.1283791670955126, 1, PAL_EPSILON * 10 }, // value: 2 / sqrt(pi) - { 1.4142135623730950, 1, PAL_EPSILON * 10 }, // value: sqrt(2) - { 1.4426950408889634, 1, PAL_EPSILON * 10 }, // value: log2(e) - { 1.5707963267948966, 1, PAL_EPSILON * 10 }, // value: pi / 2 - { 2.3025850929940457, 2, PAL_EPSILON * 10 }, // value: ln(10) - { 2.7182818284590452, 2, PAL_EPSILON * 10 }, // value: e - { 3.1415926535897932, 3, PAL_EPSILON * 10 }, // value: pi - { PAL_POSINF, PAL_POSINF, 0 } - }; - - /* PAL initialization */ - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - validate( 0, 0, PAL_EPSILON); - validate(-0.0, 0, PAL_EPSILON); - - validate( 1, 1, PAL_EPSILON * 10); - validate(-1.0, -1, PAL_EPSILON * 10); - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - validate( tests[i].value, tests[i].expected, tests[i].variance); - validate(-tests[i].value, -(tests[i].expected + 1), tests[i].variance); - } - - validate_isnan(PAL_NAN); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/floor/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/floor/test1/testinfo.dat deleted file mode 100644 index 90543ea7a..000000000 --- a/src/pal/tests/palsuite/c_runtime/floor/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = floor -Name = Positive Test for floor -TYPE = DEFAULT -EXE1 = test1 -Description -= Passes to floor() a series of value, checking that -= each one return to correct value. diff --git a/src/pal/tests/palsuite/c_runtime/floorf/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/floorf/CMakeLists.txt deleted file mode 100644 index 5e1ef7f28..000000000 --- a/src/pal/tests/palsuite/c_runtime/floorf/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) diff --git a/src/pal/tests/palsuite/c_runtime/floorf/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/floorf/test1/CMakeLists.txt deleted file mode 100644 index 8834f4dfa..000000000 --- a/src/pal/tests/palsuite/c_runtime/floorf/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.c -) - -add_executable(paltest_floorf_test1 - ${SOURCES} -) - -add_dependencies(paltest_floorf_test1 coreclrpal) - -target_link_libraries(paltest_floorf_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/floorf/test1/test1.c b/src/pal/tests/palsuite/c_runtime/floorf/test1/test1.c deleted file mode 100644 index 57dca2138..000000000 --- a/src/pal/tests/palsuite/c_runtime/floorf/test1/test1.c +++ /dev/null @@ -1,131 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: Tests floorf with simple positive and negative values. Also tests -** extreme cases like extremely small values and positive and -** negative infinity. Makes sure that calling floorf on NaN returns -** NaN -** -**==========================================================================*/ - -#include - -// binary32 (float) has a machine epsilon of 2^-23 (approx. 1.19e-07). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-21 (approx. 4.76e-07) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (6-9 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxx will use PAL_EPSILON -// for the variance, while an expected result in the format of 0.0xxxxxxxxx will use -// PAL_EPSILON / 10 and and expected result in the format of x.xxxxxx will use PAL_EPSILON * 10. -#define PAL_EPSILON 4.76837158e-07 - -#define PAL_NAN sqrtf(-1.0f) -#define PAL_POSINF -logf(0.0f) -#define PAL_NEGINF logf(0.0f) - -/** - * Helper test structure - */ -struct test -{ - float value; /* value to test the function with */ - float expected; /* expected result */ - float variance; /* maximum delta between the expected and actual result */ -}; - -/** - * validate - * - * test validation function - */ -void __cdecl validate(float value, float expected, float variance) -{ - float result = floorf(value); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - float delta = fabsf(result - expected); - - if (delta > variance) - { - Fail("floorf(%g) returned %10.9g when it should have returned %10.9g", - value, result, expected); - } -} - -/** - * validate - * - * test validation function for values returning NaN - */ -void __cdecl validate_isnan(float value) -{ - float result = floorf(value); - - if (!_isnanf(result)) - { - Fail("floorf(%g) returned %10.9g when it should have returned %10.9g", - value, result, PAL_NAN); - } -} - -/** - * main - * - * executable entry point - */ -int __cdecl main(int argc, char *argv[]) -{ - struct test tests[] = - { - /* value expected variance */ - { 0.318309886f, 0, PAL_EPSILON }, // value: 1 / pi - { 0.434294482f, 0, PAL_EPSILON }, // value: log10f(e) - { 0.636619772f, 0, PAL_EPSILON }, // value: 2 / pi - { 0.693147181f, 0, PAL_EPSILON }, // value: ln(2) - { 0.707106781f, 0, PAL_EPSILON }, // value: 1 / sqrtf(2) - { 0.785398163f, 0, PAL_EPSILON }, // value: pi / 4 - { 1.12837917f, 1, PAL_EPSILON * 10 }, // value: 2 / sqrtf(pi) - { 1.41421356f, 1, PAL_EPSILON * 10 }, // value: sqrtf(2) - { 1.44269504f, 1, PAL_EPSILON * 10 }, // value: logf2(e) - { 1.57079633f, 1, PAL_EPSILON * 10 }, // value: pi / 2 - { 2.30258509f, 2, PAL_EPSILON * 10 }, // value: ln(10) - { 2.71828183f, 2, PAL_EPSILON * 10 }, // value: e - { 3.14159265f, 3, PAL_EPSILON * 10 }, // value: pi - { PAL_POSINF, PAL_POSINF, 0 } - }; - - /* PAL initialization */ - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - validate( 0, 0, PAL_EPSILON); - validate(-0.0f, 0, PAL_EPSILON); - - validate( 1, 1, PAL_EPSILON * 10); - validate(-1.0f, -1, PAL_EPSILON * 10); - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - validate( tests[i].value, tests[i].expected, tests[i].variance); - validate(-tests[i].value, -(tests[i].expected + 1), tests[i].variance); - } - - validate_isnan(PAL_NAN); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/floorf/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/floorf/test1/testinfo.dat deleted file mode 100644 index 006540141..000000000 --- a/src/pal/tests/palsuite/c_runtime/floorf/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = floorf -Name = Positive Test for floorf -TYPE = DEFAULT -EXE1 = test1 -Description -= Passes to floorf() a series of value, checking that -= each one return to correct value. diff --git a/src/pal/tests/palsuite/c_runtime/fmod/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/fmod/CMakeLists.txt deleted file mode 100644 index 5e1ef7f28..000000000 --- a/src/pal/tests/palsuite/c_runtime/fmod/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) diff --git a/src/pal/tests/palsuite/c_runtime/fmod/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/fmod/test1/CMakeLists.txt deleted file mode 100644 index 22bcd3a00..000000000 --- a/src/pal/tests/palsuite/c_runtime/fmod/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_fmod_test1 - ${SOURCES} -) - -add_dependencies(paltest_fmod_test1 coreclrpal) - -target_link_libraries(paltest_fmod_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/fmod/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/fmod/test1/test1.cpp deleted file mode 100644 index fd69ca52c..000000000 --- a/src/pal/tests/palsuite/c_runtime/fmod/test1/test1.cpp +++ /dev/null @@ -1,157 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================= -** -** Source: test1.c -** -** Purpose: Test to ensure that fmod return the correct values -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** Fail -** fabs -** -**===========================================================================*/ - -#include - -// binary64 (double) has a machine epsilon of 2^-52 (approx. 2.22e-16). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-50 (approx. 8.88e-16) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (15-17 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxxxxxxxxxx will use -// PAL_EPSILON for the variance, while an expected result in the format of 0.0xxxxxxxxxxxxxxxxx -// will use PAL_EPSILON / 10 and and expected result in the format of x.xxxxxxxxxxxxxxxx will -// use PAL_EPSILON * 10. -#define PAL_EPSILON 8.8817841970012523e-16 - -#define PAL_NAN sqrt(-1.0) -#define PAL_POSINF -log(0.0) -#define PAL_NEGINF log(0.0) - -/** - * Helper test structure - */ -struct test -{ - double numerator; /* second component of the value to test the function with */ - double denominator; /* first component of the value to test the function with */ - double expected; /* expected result */ - double variance; /* maximum delta between the expected and actual result */ -}; - -/** - * validate - * - * test validation function - */ -void __cdecl validate(double numerator, double denominator, double expected, double variance) -{ - double result = fmod(numerator, denominator); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - double delta = fabs(result - expected); - - if (delta > variance) - { - Fail("fmod(%g, %g) returned %20.17g when it should have returned %20.17g", - numerator, denominator, result, expected); - } -} - -/** - * validate - * - * test validation function for values returning NaN - */ -void __cdecl validate_isnan(double numerator, double denominator) -{ - double result = fmod(numerator, denominator); - - if (!_isnan(result)) - { - Fail("fmod(%g, %g) returned %20.17g when it should have returned %20.17g", - numerator, denominator, result, PAL_NAN); - } -} - -/** - * main - * - * executable entry point - */ -INT __cdecl main(INT argc, CHAR **argv) -{ - struct test tests[] = - { - /* numerator denominator expected variance */ - { 0, PAL_POSINF, 0, PAL_EPSILON }, - { 0.31296179620778659, 0.94976571538163866, 0.31296179620778658, PAL_EPSILON }, - { 0.42077048331375735, 0.90716712923909839, 0.42077048331375733, PAL_EPSILON }, - { 0.59448076852482208, 0.80410982822879171, 0.59448076852482212, PAL_EPSILON }, - { 0.63896127631363480, 0.76923890136397213, 0.63896127631363475, PAL_EPSILON }, - { 0.64963693908006244, 0.76024459707563015, 0.64963693908006248, PAL_EPSILON }, - { 0.70710678118654752, 0.70710678118654752, 0, PAL_EPSILON }, - { 1, 1, 0, PAL_EPSILON }, - { 0.84147098480789651, 0.54030230586813972, 0.30116867893975674, PAL_EPSILON }, - { 0.90371945743584630, 0.42812514788535792, 0.047469161665130377, PAL_EPSILON / 10 }, - { 0.98776594599273553, 0.15594369476537447, 0.052103777400488605, PAL_EPSILON / 10 }, - { 0.99180624439366372, 0.12775121753523991, 0.097547721646984359, PAL_EPSILON / 10 }, - { 0.74398033695749319, -0.66820151019031295, 0.075778826767180285, PAL_EPSILON / 10 }, - { 0.41078129050290870, -0.91173391478696510, 0.41078129050290868, PAL_EPSILON }, - { 0, -1, 0, PAL_EPSILON }, - { 1, PAL_POSINF, 1, PAL_EPSILON * 10 }, - }; - - - // PAL initialization - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - validate( tests[i].numerator, tests[i].denominator, tests[i].expected, tests[i].variance); - validate(-tests[i].numerator, tests[i].denominator, -tests[i].expected, tests[i].variance); - validate( tests[i].numerator, -tests[i].denominator, tests[i].expected, tests[i].variance); - validate(-tests[i].numerator, -tests[i].denominator, -tests[i].expected, tests[i].variance); - } - - validate_isnan( 0, 0); - validate_isnan(-0.0, 0); - validate_isnan( 0, -0.0); - validate_isnan(-0.0, -0.0); - - validate_isnan( 1, 0); - validate_isnan(-1.0, 0); - validate_isnan( 1, -0.0); - validate_isnan(-1.0, -0.0); - - validate_isnan(PAL_POSINF, PAL_POSINF); - validate_isnan(PAL_NEGINF, PAL_POSINF); - validate_isnan(PAL_POSINF, PAL_NEGINF); - validate_isnan(PAL_NEGINF, PAL_NEGINF); - - validate_isnan(PAL_POSINF, 0); - validate_isnan(PAL_NEGINF, 0); - validate_isnan(PAL_POSINF, -0.0); - validate_isnan(PAL_NEGINF, -0.0); - - validate_isnan(PAL_POSINF, 1); - validate_isnan(PAL_NEGINF, 1); - validate_isnan(PAL_POSINF, -1.0); - validate_isnan(PAL_NEGINF, -1.0); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/fmod/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/fmod/test1/testinfo.dat deleted file mode 100644 index 0a81fd80e..000000000 --- a/src/pal/tests/palsuite/c_runtime/fmod/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = fmod -Name = Positive Test for fmod -TYPE = DEFAULT -EXE1 = test1 -Description -= Passes to fmod() a series of values, checking that -= each one return to correct value. diff --git a/src/pal/tests/palsuite/c_runtime/fmodf/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/fmodf/CMakeLists.txt deleted file mode 100644 index 5e1ef7f28..000000000 --- a/src/pal/tests/palsuite/c_runtime/fmodf/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) diff --git a/src/pal/tests/palsuite/c_runtime/fmodf/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/fmodf/test1/CMakeLists.txt deleted file mode 100644 index 861f3d721..000000000 --- a/src/pal/tests/palsuite/c_runtime/fmodf/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_fmodf_test1 - ${SOURCES} -) - -add_dependencies(paltest_fmodf_test1 coreclrpal) - -target_link_libraries(paltest_fmodf_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/fmodf/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/fmodf/test1/test1.cpp deleted file mode 100644 index 31b45d360..000000000 --- a/src/pal/tests/palsuite/c_runtime/fmodf/test1/test1.cpp +++ /dev/null @@ -1,156 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================= -** -** Source: test1.c -** -** Purpose: Test to ensure that fmodf return the correct values -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** Fail -** fabsf -** -**===========================================================================*/ - -#include - -// binary32 (float) has a machine epsilon of 2^-23 (approx. 1.19e-07). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-21 (approx. 4.76e-07) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (6-9 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxx will use PAL_EPSILON -// for the variance, while an expected result in the format of 0.0xxxxxxxxx will use -// PAL_EPSILON / 10 and and expected result in the format of x.xxxxxx will use PAL_EPSILON * 10. -#define PAL_EPSILON 4.76837158e-07 - -#define PAL_NAN sqrt(-1.0) -#define PAL_POSINF -log(0.0) -#define PAL_NEGINF log(0.0) - -/** - * Helper test structure - */ -struct test -{ - float numerator; /* second component of the value to test the function with */ - float denominator; /* first component of the value to test the function with */ - float expected; /* expected result */ - float variance; /* maximum delta between the expected and actual result */ -}; - -/** - * validate - * - * test validation function - */ -void __cdecl validate(float numerator, float denominator, float expected, float variance) -{ - float result = fmodf(numerator, denominator); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - float delta = fabsf(result - expected); - - if (delta > variance) - { - Fail("fmodf(%g, %g) returned %10.9g when it should have returned %10.9g", - numerator, denominator, result, expected); - } -} - -/** - * validate - * - * test validation function for values returning NaN - */ -void __cdecl validate_isnan(float numerator, float denominator) -{ - float result = fmodf(numerator, denominator); - - if (!_isnan(result)) - { - Fail("fmodf(%g, %g) returned %10.9g when it should have returned %10.9g", - numerator, denominator, result, PAL_NAN); - } -} - -/** - * main - * - * executable entry point - */ -INT __cdecl main(INT argc, CHAR **argv) -{ - struct test tests[] = - { - /* numerator denominator expected variance */ - { 0, PAL_POSINF, 0, PAL_EPSILON }, - { 0.312961796f, 0.949765715f, 0.312961796f, PAL_EPSILON }, - { 0.420770483f, 0.907167129f, 0.420770483f, PAL_EPSILON }, - { 0.594480769f, 0.804109828f, 0.594480769f, PAL_EPSILON }, - { 0.638961276f, 0.769238901f, 0.638961276f, PAL_EPSILON }, - { 0.649636939f, 0.760244597f, 0.649636939f, PAL_EPSILON }, - { 0.707106781f, 0.707106781f, 0, PAL_EPSILON }, - { 1, 1, 0, PAL_EPSILON }, - { 0.841470985f, 0.540302306f, 0.301168679f, PAL_EPSILON }, - { 0.903719457f, 0.428125148f, 0.0474691617f, PAL_EPSILON / 10 }, - { 0.987765946f, 0.155943695f, 0.0521037774f, PAL_EPSILON / 10 }, - { 0.991806244f, 0.127751218f, 0.0975477216f, PAL_EPSILON / 10 }, - { 0.743980337f, -0.668201510f, 0.0757788268f, PAL_EPSILON / 10 }, - { 0.410781291f, -0.911733915f, 0.410781291f, PAL_EPSILON }, - { 0, -1, 0, PAL_EPSILON }, - { 1, PAL_POSINF, 1, PAL_EPSILON * 10 }, - }; - - - // PAL initialization - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - validate( tests[i].numerator, tests[i].denominator, tests[i].expected, tests[i].variance); - validate(-tests[i].numerator, tests[i].denominator, -tests[i].expected, tests[i].variance); - validate( tests[i].numerator, -tests[i].denominator, tests[i].expected, tests[i].variance); - validate(-tests[i].numerator, -tests[i].denominator, -tests[i].expected, tests[i].variance); - } - - validate_isnan( 0, 0); - validate_isnan(-0.0f, 0); - validate_isnan( 0, -0.0f); - validate_isnan(-0.0f, -0.0f); - - validate_isnan( 1, 0); - validate_isnan(-1, 0); - validate_isnan( 1, -0.0f); - validate_isnan(-1, -0.0f); - - validate_isnan(PAL_POSINF, PAL_POSINF); - validate_isnan(PAL_NEGINF, PAL_POSINF); - validate_isnan(PAL_POSINF, PAL_NEGINF); - validate_isnan(PAL_NEGINF, PAL_NEGINF); - - validate_isnan(PAL_POSINF, 0); - validate_isnan(PAL_NEGINF, 0); - validate_isnan(PAL_POSINF, -0.0f); - validate_isnan(PAL_NEGINF, -0.0f); - - validate_isnan(PAL_POSINF, 1); - validate_isnan(PAL_NEGINF, 1); - validate_isnan(PAL_POSINF, -1); - validate_isnan(PAL_NEGINF, -1); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/fmodf/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/fmodf/test1/testinfo.dat deleted file mode 100644 index 11c797892..000000000 --- a/src/pal/tests/palsuite/c_runtime/fmodf/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = fmodf -Name = Positive Test for fmodf -TYPE = DEFAULT -EXE1 = test1 -Description -= Passes to fmodf() a series of values, checking that -= each one return to correct value. diff --git a/src/pal/tests/palsuite/c_runtime/fopen/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/fopen/CMakeLists.txt deleted file mode 100644 index 19ee487a6..000000000 --- a/src/pal/tests/palsuite/c_runtime/fopen/CMakeLists.txt +++ /dev/null @@ -1,10 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) -add_subdirectory(test3) -add_subdirectory(test4) -add_subdirectory(test5) -add_subdirectory(test6) -add_subdirectory(test7) - diff --git a/src/pal/tests/palsuite/c_runtime/fopen/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/fopen/test1/CMakeLists.txt deleted file mode 100644 index 955979a6a..000000000 --- a/src/pal/tests/palsuite/c_runtime/fopen/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_fopen_test1 - ${SOURCES} -) - -add_dependencies(paltest_fopen_test1 coreclrpal) - -target_link_libraries(paltest_fopen_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/fopen/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/fopen/test1/test1.cpp deleted file mode 100644 index 565b4eb77..000000000 --- a/src/pal/tests/palsuite/c_runtime/fopen/test1/test1.cpp +++ /dev/null @@ -1,82 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test1.c -** -** Purpose: Tests the PAL implementation of the fopen function. -** This test simply attempts to open a number of files -** with different modes. It checks to ensure a valid -** file pointer is returned. It doesn't do any checking -** to ensure the mode is really what it claims. And checks -** for a NULL pointer when attempts to open a directory. -** - -** -**===================================================================*/ - -#include - -struct testCase -{ - int CorrectResult; - char mode[20]; -}; - -int __cdecl main(int argc, char **argv) -{ - - FILE *fp; - char name[128]; - int i; - - struct testCase testCases[] = - { - {0, "r"}, {1, "w"}, {1, "a"}, - {0, "r+"}, {1, "w+"}, {1, "a+"}, - {1, "wt"}, {1, "wb"}, {1, "wS"}, - {1, "w+c"}, {1, "w+n"}, {1, "wR"}, - {1, "wT"}, {0, "tw"} - }; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - - for(i = 0; i < sizeof(testCases) / sizeof(struct testCase); i++) - { - strcpy(name,"testfiles"); - strcat(name,testCases[i].mode); - - fp = fopen(name,testCases[i].mode); - - if ((fp == 0 && testCases[i].CorrectResult != 0) || - (testCases[i].CorrectResult == 0 && fp != 0) ) - { - Fail("ERROR: fopen returned incorrectly " - "opening a file in %s mode. Perhaps it opened a " - "read only file which didn't exist and returned a correct " - "pointer?",testCases[i].mode); - } - - memset(name, '\0', 128); - - } - - /* When attempt to open a directory fopen should returned NULL */ - if ( fopen(".", "r") != NULL) - { - Fail("ERROR: fopen returned non-NULL when trying to open a directory" - " the returned value was %d\n", fp); - } - - PAL_Terminate(); - return PASS; -} - - diff --git a/src/pal/tests/palsuite/c_runtime/fopen/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/fopen/test1/testinfo.dat deleted file mode 100644 index d9908549e..000000000 --- a/src/pal/tests/palsuite/c_runtime/fopen/test1/testinfo.dat +++ /dev/null @@ -1,15 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = fopen -Name = Positive Test for fopen -TYPE = DEFAULT -EXE1 = test1 -Description -= This test simply attempts to open a number of files with different -= modes. It checks to ensure a valid file pointer is returned. It -= doesn't do any checking to ensure the mode is really what it claims. -= Checks for returned value when attempts to open a directory. diff --git a/src/pal/tests/palsuite/c_runtime/fopen/test2/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/fopen/test2/CMakeLists.txt deleted file mode 100644 index 3738f86fa..000000000 --- a/src/pal/tests/palsuite/c_runtime/fopen/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test2.cpp -) - -add_executable(paltest_fopen_test2 - ${SOURCES} -) - -add_dependencies(paltest_fopen_test2 coreclrpal) - -target_link_libraries(paltest_fopen_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/fopen/test2/test2.cpp b/src/pal/tests/palsuite/c_runtime/fopen/test2/test2.cpp deleted file mode 100644 index 4026efe89..000000000 --- a/src/pal/tests/palsuite/c_runtime/fopen/test2/test2.cpp +++ /dev/null @@ -1,65 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test2.c -** -** Purpose: Tests the PAL implementation of the fopen function. -** Test to ensure that you can write to a 'w' mode file. -** And that you can't read from a 'w' mode file. -** -** Depends: -** fprintf -** fseek -** fgets -** - -** -**===================================================================*/ - -#include - -int __cdecl main(int argc, char **argv) -{ - - FILE *fp; - char buffer[128]; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - if( (fp = fopen( "testfile", "w" )) == NULL ) - { - Fail( "ERROR: The file failed to open with 'w' mode.\n" ); - } - - /* Test that you can write */ - if(fprintf(fp,"%s","some text") <= 0) - { - Fail("ERROR: Attempted to WRITE to a file opened with 'w' mode " - "but fprintf failed. Either fopen or fprintf have problems."); - } - - if(fseek(fp, 0, SEEK_SET)) - { - Fail("ERROR: fseek failed, and this test depends on it."); - } - - /* Test that you can't read */ - if(fgets(buffer,10,fp) != NULL) - { - Fail("ERROR: Tried to READ from a file with only 'w' mode set. " - "This should fail, but fgets didn't return NULL. Either " - "fgets or fopen is broken."); - } - - PAL_Terminate(); - return PASS; -} - - diff --git a/src/pal/tests/palsuite/c_runtime/fopen/test2/testinfo.dat b/src/pal/tests/palsuite/c_runtime/fopen/test2/testinfo.dat deleted file mode 100644 index 4c1a0095f..000000000 --- a/src/pal/tests/palsuite/c_runtime/fopen/test2/testinfo.dat +++ /dev/null @@ -1,15 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = fopen -Name = Positive Test for fopen -TYPE = DEFAULT -EXE1 = test2 -Description -= Test to ensure that you can write to a 'w' mode file. And that you can't -= read from a 'w' mode file. - - diff --git a/src/pal/tests/palsuite/c_runtime/fopen/test3/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/fopen/test3/CMakeLists.txt deleted file mode 100644 index 88df51d41..000000000 --- a/src/pal/tests/palsuite/c_runtime/fopen/test3/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test3.cpp -) - -add_executable(paltest_fopen_test3 - ${SOURCES} -) - -add_dependencies(paltest_fopen_test3 coreclrpal) - -target_link_libraries(paltest_fopen_test3 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/fopen/test3/test3.cpp b/src/pal/tests/palsuite/c_runtime/fopen/test3/test3.cpp deleted file mode 100644 index f3af42dc8..000000000 --- a/src/pal/tests/palsuite/c_runtime/fopen/test3/test3.cpp +++ /dev/null @@ -1,66 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test3.c -** -** Purpose: Tests the PAL implementation of the fopen function. -** Test to ensure that you can write to a 'w+' mode file. -** And that you can read from a 'w+' mode file. -** -** Depends: -** fprintf -** fseek -** fgets -** - -** -**===================================================================*/ - -#include - -int __cdecl main(int argc, char **argv) -{ - - FILE *fp; - char buffer[128]; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - /* Open a file with 'w+' mode */ - if( (fp = fopen( "testfile", "w+" )) == NULL ) - { - Fail( "ERROR: The file failed to open with 'w+' mode.\n" ); - } - - /* Write some text to the file */ - if(fprintf(fp,"%s","some text") <= 0) - { - Fail("ERROR: Attempted to WRITE to a file opened with 'w+' mode " - "but fprintf failed. Either fopen or fprintf have problems."); - } - - if(fseek(fp, 0, SEEK_SET)) - { - Fail("ERROR: fseek failed, and this test depends on it."); - } - - /* Attempt to read from the 'w+' only file, should pass */ - if(fgets(buffer,10,fp) == NULL) - { - Fail("ERROR: Tried to READ from a file with 'w+' mode set. " - "This should succeed, but fgets returned NULL. Either fgets " - "or fopen is broken."); - } - - PAL_Terminate(); - return PASS; -} - - diff --git a/src/pal/tests/palsuite/c_runtime/fopen/test3/testinfo.dat b/src/pal/tests/palsuite/c_runtime/fopen/test3/testinfo.dat deleted file mode 100644 index c458c1196..000000000 --- a/src/pal/tests/palsuite/c_runtime/fopen/test3/testinfo.dat +++ /dev/null @@ -1,15 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = fopen -Name = Positive Test for fopen -TYPE = DEFAULT -EXE1 = test3 -Description -= Test to ensure that you can write to a 'w+' mode file. And that you can -= read from a 'w+' mode file. - - diff --git a/src/pal/tests/palsuite/c_runtime/fopen/test4/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/fopen/test4/CMakeLists.txt deleted file mode 100644 index f31c5d1e5..000000000 --- a/src/pal/tests/palsuite/c_runtime/fopen/test4/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test4.cpp -) - -add_executable(paltest_fopen_test4 - ${SOURCES} -) - -add_dependencies(paltest_fopen_test4 coreclrpal) - -target_link_libraries(paltest_fopen_test4 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/fopen/test4/test4.cpp b/src/pal/tests/palsuite/c_runtime/fopen/test4/test4.cpp deleted file mode 100644 index 04683d52c..000000000 --- a/src/pal/tests/palsuite/c_runtime/fopen/test4/test4.cpp +++ /dev/null @@ -1,82 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test4.c -** -** Purpose: Tests the PAL implementation of the fopen function. -** Test to ensure that you can't write to a 'r' mode file. -** And that you can read from a 'r' mode file. -** -** Depends: -** fprintf -** fclose -** fgets -** - -** -**===================================================================*/ - -#include - -int __cdecl main(int argc, char **argv) -{ - - FILE *fp; - char buffer[128]; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - /* Open a file with 'w' mode */ - if( (fp = fopen( "testfile", "w" )) == NULL ) - { - Fail( "ERROR: The file failed to open with 'w' mode.\n" ); - } - - /* Write some text to the file */ - if(fprintf(fp,"%s","some text") <= 0) - { - Fail("ERROR: Attempted to WRITE to a file opened with 'w' mode " - "but fprintf failed. Either fopen or fprintf have problems."); - } - - if(fclose(fp)) - { - Fail("ERROR: Attempted to close a file, but fclose failed. " - "This test depends upon it."); - } - - /* Open a file with 'r' mode */ - if( (fp = fopen( "testfile", "r" )) == NULL ) - { - Fail( "ERROR: The file failed to open with 'r' mode.\n" ); - } - - /* Attempt to read from the 'r' only file, should pass */ - if(fgets(buffer,10,fp) == NULL) - { - Fail("ERROR: Tried to READ from a file with 'r' mode set. " - "This should succeed, but fgets returned NULL. Either fgets " - "or fopen is broken."); - } - - /* Write some text to the file */ - if(fprintf(fp,"%s","some text") > 0) - { - Fail("ERROR: Attempted to WRITE to a file opened with 'r' mode " - "but fprintf succeeded It should have failed. " - "Either fopen or fprintf have problems."); - } - - - PAL_Terminate(); - return PASS; -} - - diff --git a/src/pal/tests/palsuite/c_runtime/fopen/test4/testinfo.dat b/src/pal/tests/palsuite/c_runtime/fopen/test4/testinfo.dat deleted file mode 100644 index a1ecaf959..000000000 --- a/src/pal/tests/palsuite/c_runtime/fopen/test4/testinfo.dat +++ /dev/null @@ -1,15 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = fopen -Name = Positive Test for fopen -TYPE = DEFAULT -EXE1 = test4 -Description -= Test to ensure that you can't write to a 'r' mode file. And that you can -= read from a 'r' mode file. - - diff --git a/src/pal/tests/palsuite/c_runtime/fopen/test5/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/fopen/test5/CMakeLists.txt deleted file mode 100644 index 975351d39..000000000 --- a/src/pal/tests/palsuite/c_runtime/fopen/test5/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test5.cpp -) - -add_executable(paltest_fopen_test5 - ${SOURCES} -) - -add_dependencies(paltest_fopen_test5 coreclrpal) - -target_link_libraries(paltest_fopen_test5 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/fopen/test5/test5.cpp b/src/pal/tests/palsuite/c_runtime/fopen/test5/test5.cpp deleted file mode 100644 index 0a760314e..000000000 --- a/src/pal/tests/palsuite/c_runtime/fopen/test5/test5.cpp +++ /dev/null @@ -1,78 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test5.c -** -** Purpose: Tests the PAL implementation of the fopen function. -** Test to ensure that you can write to a 'r+' mode file. -** And that you can read from a 'r+' mode file. -** -** Depends: -** fprintf -** fclose -** fgets -** fseek -** - -** -**===================================================================*/ - -#include - -int __cdecl main(int argc, char **argv) -{ - - FILE *fp; - char buffer[128]; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - /* Open a file with 'w' mode */ - if( (fp = fopen( "testfile", "w" )) == NULL ) - { - Fail( "ERROR: The file failed to open with 'w' mode.\n" ); - } - - if(fclose(fp)) - { - Fail("ERROR: Attempted to close a file, but fclose failed. " - "This test depends upon it."); - } - - if( (fp = fopen( "testfile", "r+" )) == NULL ) - { - Fail( "ERROR: The file failed to open with 'r+' mode.\n" ); - } - - /* Write some text to the file */ - if(fprintf(fp,"%s","some text") <= 0) - { - Fail("ERROR: Attempted to WRITE to a file opened with 'r+' mode " - "but fprintf failed. Either fopen or fprintf have problems."); - } - - if(fseek(fp, 0, SEEK_SET)) - { - Fail("ERROR: fseek failed, and this test depends on it."); - } - - /* Attempt to read from the 'r+' only file, should pass */ - if(fgets(buffer,10,fp) == NULL) - { - Fail("ERROR: Tried to READ from a file with 'r+' mode set. " - "This should succeed, but fgets returned NULL. Either fgets " - "or fopen is broken."); - } - - PAL_Terminate(); - return PASS; -} - - diff --git a/src/pal/tests/palsuite/c_runtime/fopen/test5/testinfo.dat b/src/pal/tests/palsuite/c_runtime/fopen/test5/testinfo.dat deleted file mode 100644 index 8f8f5d950..000000000 --- a/src/pal/tests/palsuite/c_runtime/fopen/test5/testinfo.dat +++ /dev/null @@ -1,15 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = fopen -Name = Positive Test for fopen -TYPE = DEFAULT -EXE1 = test5 -Description -= Test to ensure that you can write to a 'r+' mode file. And that you can -= read from a 'r+' mode file. - - diff --git a/src/pal/tests/palsuite/c_runtime/fopen/test6/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/fopen/test6/CMakeLists.txt deleted file mode 100644 index 1e235856b..000000000 --- a/src/pal/tests/palsuite/c_runtime/fopen/test6/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test6.cpp -) - -add_executable(paltest_fopen_test6 - ${SOURCES} -) - -add_dependencies(paltest_fopen_test6 coreclrpal) - -target_link_libraries(paltest_fopen_test6 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/fopen/test6/test6.cpp b/src/pal/tests/palsuite/c_runtime/fopen/test6/test6.cpp deleted file mode 100644 index 03b6067fd..000000000 --- a/src/pal/tests/palsuite/c_runtime/fopen/test6/test6.cpp +++ /dev/null @@ -1,131 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test6.c -** -** Purpose: Tests the PAL implementation of the fopen function. -** Test to ensure that you can write to an 'a' mode file. -** And that you can't read from a 'a' mode file. Also ensure -** that you can use fseek and still write to the end of a file. -** -** Depends: -** fprintf -** fgets -** fseek -** fclose -** - -** -**===================================================================*/ - -#include - -int __cdecl main(int argc, char **argv) -{ - - FILE *fp; - char buffer[128]; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - /* Open a file with 'a+' mode */ - if( (fp = fopen( "testfile", "a" )) == NULL ) - { - Fail( "ERROR: The file failed to open with 'a' mode.\n" ); - } - - /* Write some text to the file */ - if(fprintf(fp,"%s","some text") <= 0) - { - Fail("ERROR: Attempted to WRITE to a file opened with 'a' mode " - "but fprintf failed. Either fopen or fprintf have problems."); - } - - if(fseek(fp, 0, SEEK_SET)) - { - Fail("ERROR: fseek failed, and this test depends on it."); - } - - /* Attempt to read from the 'a' only file, should fail */ - if(fgets(buffer,10,fp) != NULL) - { - Fail("ERROR: Tried to READ from a file with 'a' mode set. " - "This should fail, but fgets returned success. Either fgets " - "or fopen is broken."); - } - - - /* Attempt to write to a file after using 'a' and fseek */ - fp = fopen("testfile2", "a"); - if(fp == NULL) - { - Fail("ERROR: The file failed to be created with 'a' mode.\n"); - } - - /* write text to the file initially */ - if(fprintf(fp,"%s","abcd") <= 0) - { - Fail("ERROR: Attempted to WRITE to a file opened with 'a' mode " - "but fprintf failed. Either fopen or fprintf have problems.\n"); - } - - /* set the pointer to the front of the file */ - if(fseek(fp, 0, SEEK_SET)) - { - Fail("ERROR: fseek failed, and this test depends on it.\n"); - } - - /* using 'a' should still write to the end of the file, not the front */ - if(fputs("efgh",fp) < 0) - { - Fail("ERROR: Attempted to WRITE to a file opened with 'a' mode " - "but fputs failed.\n"); - } - - /* set the pointer to the front of the file */ - if(fseek(fp, 0, SEEK_SET)) - { - Fail("ERROR: fseek failed, and this test depends on it.\n"); - } - - /* a file with 'a' mode can only write, so close the file before reading */ - if(fclose(fp)) - { - Fail("ERROR: fclose failed when it should have succeeded.\n"); - } - - /* open the file again to read */ - fp = fopen("testfile2","r"); - if(fp == NULL) - { - Fail("ERROR: fopen failed to open the file using 'r' mode"); - } - - /* Attempt to read from the 'a' only file, should succeed */ - if(fgets(buffer,10,fp) == NULL) - { - Fail("ERROR: Tried to READ from a file with 'a' mode set. " - "This should pass, but fgets returned failure. Either fgets " - "or fopen is broken.\n"); - } - - /* Compare what was read and what should have been in the file */ - if(memcmp(buffer,"abcdefgh",8)) - { - Fail("ERROR: The string read should have equaled 'abcdefgh' " - "but instead it is %s\n", buffer); - } - - - PAL_Terminate(); - return PASS; -} - - diff --git a/src/pal/tests/palsuite/c_runtime/fopen/test6/testinfo.dat b/src/pal/tests/palsuite/c_runtime/fopen/test6/testinfo.dat deleted file mode 100644 index 5edd94416..000000000 --- a/src/pal/tests/palsuite/c_runtime/fopen/test6/testinfo.dat +++ /dev/null @@ -1,15 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = fopen -Name = Positive Test for fopen -TYPE = DEFAULT -EXE1 = test6 -Description -= Test to ensure that you can write to a 'a' mode file. And that you can't -= read from a 'a' mode file. - - diff --git a/src/pal/tests/palsuite/c_runtime/fopen/test7/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/fopen/test7/CMakeLists.txt deleted file mode 100644 index dd81aa928..000000000 --- a/src/pal/tests/palsuite/c_runtime/fopen/test7/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test7.cpp -) - -add_executable(paltest_fopen_test7 - ${SOURCES} -) - -add_dependencies(paltest_fopen_test7 coreclrpal) - -target_link_libraries(paltest_fopen_test7 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/fopen/test7/test7.cpp b/src/pal/tests/palsuite/c_runtime/fopen/test7/test7.cpp deleted file mode 100644 index 3ef8602dd..000000000 --- a/src/pal/tests/palsuite/c_runtime/fopen/test7/test7.cpp +++ /dev/null @@ -1,117 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test7.c -** -** Purpose: Tests the PAL implementation of the fopen function. -** Test to ensure that you can write to an 'a+' mode file. -** And that you can read from a 'a+' mode file. Also ensure -** that you can use fseek and still write to the end of a file. -** -** Depends: -** fprintf -** fgets -** fseek -** fclose -** - -** -**===================================================================*/ - -#include - -int __cdecl main(int argc, char **argv) -{ - - FILE *fp; - char buffer[128]; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - /* Open a file with 'a+' mode */ - if( (fp = fopen( "testfile", "a+" )) == NULL ) - { - Fail( "ERROR: The file failed to open with 'a+' mode.\n" ); - } - - /* Write some text to the file */ - if(fprintf(fp,"%s","some text") <= 0) - { - Fail("ERROR: Attempted to WRITE to a file opened with 'a+' mode " - "but fprintf failed. Either fopen or fprintf have problems.\n"); - } - - if(fseek(fp, 0, SEEK_SET)) - { - Fail("ERROR: fseek failed, and this test depends on it.\n"); - } - - /* Attempt to read from the 'a+' only file, should succeed */ - if(fgets(buffer,10,fp) == NULL) - { - Fail("ERROR: Tried to READ from a file with 'a+' mode set. " - "This should pass, but fgets returned failure. Either fgets " - "or fopen is broken.\n"); - } - - - /* Attempt to write to a file after using 'a+' and fseek */ - fp = fopen("testfile2", "a+"); - if(fp == NULL) - { - Fail("ERROR: The file failed to be created with 'a+' mode.\n"); - } - - /* write text to the file initially */ - if(fprintf(fp,"%s","abcd") <= 0) - { - Fail("ERROR: Attempted to WRITE to a file opened with 'a+' mode " - "but fprintf failed. Either fopen or fprintf have problems.\n"); - } - - /* set the pointer to the front of the file */ - if(fseek(fp, 0, SEEK_SET)) - { - Fail("ERROR: fseek failed, and this test depends on it.\n"); - } - - /* using 'a+' should still write to the end of the file, not the front */ - if(fputs("efgh",fp) < 0) - { - Fail("ERROR: Attempted to WRITE to a file opened with 'a+' mode " - "but fputs failed.\n"); - } - - /* set the pointer to the front of the file */ - if(fseek(fp, 0, SEEK_SET)) - { - Fail("ERROR: fseek failed, and this test depends on it.\n"); - } - - /* Attempt to read from the 'a+' only file, should succeed */ - if(fgets(buffer,10,fp) == NULL) - { - Fail("ERROR: Tried to READ from a file with 'a+' mode set. " - "This should pass, but fgets returned failure. Either fgets " - "or fopen is broken.\n"); - } - - /* Compare what was read and what should have been in the file */ - if(memcmp(buffer,"abcdefgh",8)) - { - Fail("ERROR: The string read should have equaled 'abcdefgh' " - "but instead it is %s\n", buffer); - } - - PAL_Terminate(); - return PASS; -} - - diff --git a/src/pal/tests/palsuite/c_runtime/fopen/test7/testinfo.dat b/src/pal/tests/palsuite/c_runtime/fopen/test7/testinfo.dat deleted file mode 100644 index e4bc99c91..000000000 --- a/src/pal/tests/palsuite/c_runtime/fopen/test7/testinfo.dat +++ /dev/null @@ -1,15 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = fopen -Name = Positive Test for fopen -TYPE = DEFAULT -EXE1 = test7 -Description -= Test to ensure that you can write to a 'a+' mode file. And that you can -= read from a 'a+' mode file. - - diff --git a/src/pal/tests/palsuite/c_runtime/fprintf/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/fprintf/CMakeLists.txt deleted file mode 100644 index cafb9536b..000000000 --- a/src/pal/tests/palsuite/c_runtime/fprintf/CMakeLists.txt +++ /dev/null @@ -1,22 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test10) -add_subdirectory(test11) -add_subdirectory(test12) -add_subdirectory(test13) -add_subdirectory(test14) -add_subdirectory(test15) -add_subdirectory(test16) -add_subdirectory(test17) -add_subdirectory(test18) -add_subdirectory(test19) -add_subdirectory(test2) -add_subdirectory(test3) -add_subdirectory(test4) -add_subdirectory(test5) -add_subdirectory(test6) -add_subdirectory(test7) -add_subdirectory(test8) -add_subdirectory(test9) - diff --git a/src/pal/tests/palsuite/c_runtime/fprintf/fprintf.h b/src/pal/tests/palsuite/c_runtime/fprintf/fprintf.h deleted file mode 100644 index 87ee0d123..000000000 --- a/src/pal/tests/palsuite/c_runtime/fprintf/fprintf.h +++ /dev/null @@ -1,177 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*NOTE: -The creation of the test file within each function is because the FILE -structure is not defined within pal.h. Therefore, unable to have -function with this as a return type. -*/ - -#ifndef __FPRINTF_H__ -#define __FPRINTF_H__ - -void DoStrTest(const char *formatstr, char* param, const char *checkstr) -{ - FILE *fp; - char buf[256] = { 0 }; - - if ((fp = fopen("testfile.txt", "w+")) == NULL ) - Fail("ERROR: fopen failed to create testfile\n"); - if ((fprintf(fp, formatstr, param)) < 0) - Fail("ERROR: fprintf failed\n"); - if ((fseek(fp, 0, SEEK_SET)) != 0) - Fail("ERROR: fseek failed\n"); - if ((fgets(buf, 100, fp)) == NULL) - Fail("ERROR: fseek failed\n"); - - if (memcmp(buf, checkstr, strlen(buf) + 1) != 0) - { - Fail("ERROR: failed to insert string \"%s\" into \"%s\"\n" - "Expected \"%s\" got \"%s\".\n", - param, formatstr, checkstr, buf); - } - fclose(fp); -} - -void DoWStrTest(const char *formatstr, WCHAR* param, const char *checkstr) -{ - FILE *fp; - char buf[256] = { 0 }; - - if ((fp = fopen("testfile.txt", "w+")) == NULL ) - Fail("ERROR: fopen failed to create testfile\n"); - if ((fprintf(fp, formatstr, param)) < 0) - Fail("ERROR: fprintf failed\n"); - if ((fseek(fp, 0, SEEK_SET)) != 0) - Fail("ERROR: fseek failed\n"); - if ((fgets(buf, 100, fp)) == NULL) - Fail("ERROR: fseek failed\n"); - - if (memcmp(buf, checkstr, strlen(buf) + 1) != 0) - { - Fail("ERROR: failed to insert wide string \"%s\" into \"%s\"\n" - "Expected \"%s\" got \"%s\".\n", - convertC(param), formatstr, checkstr, buf); - } - fclose(fp); -} - - -void DoCharTest(const char *formatstr, char param, const char *checkstr) -{ - FILE *fp; - char buf[256] = { 0 }; - - if ((fp = fopen("testfile.txt", "w+")) == NULL ) - Fail("ERROR: fopen failed to create testfile\n"); - if ((fprintf(fp, formatstr, param)) < 0) - Fail("ERROR: fprintf failed\n"); - if ((fseek(fp, 0, SEEK_SET)) != 0) - Fail("ERROR: fseek failed\n"); - if ((fgets(buf, 100, fp)) == NULL) - Fail("ERROR: fseek failed\n"); - - if (memcmp(buf, checkstr, strlen(buf) + 1) != 0) - { - Fail("ERROR: failed to insert char \'%c\' (%d) into \"%s\"\n" - "Expected \"%s\" got \"%s\".\n", - param, param, formatstr, checkstr, buf); - } - fclose(fp); -} - -void DoWCharTest(const char *formatstr, WCHAR param, const char *checkstr) -{ - FILE *fp; - char buf[256] = { 0 }; - - if ((fp = fopen("testfile.txt", "w+")) == NULL ) - Fail("ERROR: fopen failed to create testfile\n"); - if ((fprintf(fp, formatstr, param)) < 0) - Fail("ERROR: fprintf failed\n"); - if ((fseek(fp, 0, SEEK_SET)) != 0) - Fail("ERROR: fseek failed\n"); - if ((fgets(buf, 100, fp)) == NULL) - Fail("ERROR: fseek failed\n"); - - if (memcmp(buf, checkstr, strlen(buf) + 1) != 0) - { - Fail("ERROR: failed to insert wide char \'%c\' (%d) into \"%s\"\n" - "Expected \"%s\" got \"%s\".\n", - (char)param, param, formatstr, checkstr, buf); - } - fclose(fp); -} - -void DoNumTest(const char *formatstr, int value, const char *checkstr) -{ - FILE *fp; - char buf[256] = { 0 }; - - if ((fp = fopen("testfile.txt", "w+")) == NULL ) - Fail("ERROR: fopen failed to create testfile\n"); - if ((fprintf(fp, formatstr, value)) < 0) - Fail("ERROR: fprintf failed\n"); - if ((fseek(fp, 0, SEEK_SET)) != 0) - Fail("ERROR: fseek failed\n"); - if ((fgets(buf, 100, fp)) == NULL) - Fail("ERROR: fseek failed\n"); - - if (memcmp(buf, checkstr, strlen(buf) + 1) != 0) - { - Fail("ERROR: failed to insert %#x into \"%s\"\n" - "Expected \"%s\" got \"%s\".\n", - value, formatstr, checkstr, buf); - } - fclose(fp); -} - -void DoI64Test(const char *formatstr, INT64 value, char *valuestr, const char *checkstr1, const char *checkstr2) -{ - FILE *fp; - char buf[256] = { 0 }; - - if ((fp = fopen("testfile.txt", "w+")) == NULL ) - Fail("ERROR: fopen failed to create testfile\n"); - if ((fprintf(fp, formatstr, value)) < 0) - Fail("ERROR: fprintf failed\n"); - if ((fseek(fp, 0, SEEK_SET)) != 0) - Fail("ERROR: fseek failed\n"); - if ((fgets(buf, 100, fp)) == NULL) - Fail("ERROR: fseek failed\n"); - - if (memcmp(buf, checkstr1, strlen(buf) + 1) != 0 && - memcmp(buf, checkstr2, strlen(buf) + 1) != 0) - { - Fail("ERROR: failed to insert %s into \"%s\"\n" - "Expected \"%s\" or \"%s\", got \"%s\".\n", - valuestr, formatstr, checkstr1, checkstr2, buf); - } - fclose(fp); -} - -void DoDoubleTest(const char *formatstr, double value, const char *checkstr1, const char *checkstr2) -{ - FILE *fp; - char buf[256] = { 0 }; - - if ((fp = fopen("testfile.txt", "w+")) == NULL ) - Fail("ERROR: fopen failed to create testfile\n"); - if ((fprintf(fp, formatstr, value)) < 0) - Fail("ERROR: fprintf failed\n"); - if ((fseek(fp, 0, SEEK_SET)) != 0) - Fail("ERROR: fseek failed\n"); - if ((fgets(buf, 100, fp)) == NULL) - Fail("ERROR: fseek failed\n"); - - if (memcmp(buf, checkstr1, strlen(buf) + 1) != 0 && - memcmp(buf, checkstr2, strlen(buf) + 1) != 0) - { - Fail("ERROR: failed to insert %f into \"%s\"\n" - "Expected \"%s\" or \"%s\", got \"%s\".\n", - value, formatstr, checkstr1, checkstr2, buf); - } - fclose(fp); -} -#endif diff --git a/src/pal/tests/palsuite/c_runtime/fprintf/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/fprintf/test1/CMakeLists.txt deleted file mode 100644 index 277cee42a..000000000 --- a/src/pal/tests/palsuite/c_runtime/fprintf/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_fprintf_test1 - ${SOURCES} -) - -add_dependencies(paltest_fprintf_test1 coreclrpal) - -target_link_libraries(paltest_fprintf_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/fprintf/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/fprintf/test1/test1.cpp deleted file mode 100644 index d55fc2534..000000000 --- a/src/pal/tests/palsuite/c_runtime/fprintf/test1/test1.cpp +++ /dev/null @@ -1,80 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test1.c (fprintf) -** -** Purpose: A single, basic, test case with no formatting. -** Test modeled after the sprintf series. -** - -** -**==========================================================================*/ - -#include - -/* - * Depends on memcmp, strlen, fopen, fgets, fseek and fclose. - */ - -int __cdecl main(int argc, char *argv[]) -{ - FILE *fp; - char testfile[] = "testfile.txt"; - char checkstr[] = "hello world"; - char buf[256]; - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - if ((fp = fopen(testfile, "w+")) == NULL) - { - Fail("ERROR: fopen failed to create \"%s\"\n", testfile); - } - - if ((fprintf(fp, "hello world")) < 0) - { - Fail("ERROR: fprintf failed to print to \"%s\"\n", testfile); - } - - if ((fseek( fp, 0, SEEK_SET)) != 0) - - { - - Fail("ERROR: Fseek failed to set pointer to beginning of file\n" ); - - } - - - - if ((fgets( buf, 100, fp )) == NULL) - - { - - Fail("ERROR: fgets failed\n"); - - } - - - if (memcmp(checkstr, buf, strlen(checkstr)+1) != 0) - { - Fail("ERROR: expected %s, got %s\n", checkstr, buf); - } - - - - if ((fclose( fp )) != 0) - - { - - Fail("ERROR: fclose failed to close \"%s\"\n", testfile); - - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/fprintf/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/fprintf/test1/testinfo.dat deleted file mode 100644 index be3bf4b78..000000000 --- a/src/pal/tests/palsuite/c_runtime/fprintf/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = fprintf -Name = Positive Test for fprintf -TYPE = DEFAULT -EXE1 = test1 -Description -= A single, basic, test case with no formatting. -= Test modeled after the sprintf series. diff --git a/src/pal/tests/palsuite/c_runtime/fprintf/test10/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/fprintf/test10/CMakeLists.txt deleted file mode 100644 index 7f9dd41db..000000000 --- a/src/pal/tests/palsuite/c_runtime/fprintf/test10/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test10.cpp -) - -add_executable(paltest_fprintf_test10 - ${SOURCES} -) - -add_dependencies(paltest_fprintf_test10 coreclrpal) - -target_link_libraries(paltest_fprintf_test10 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/fprintf/test10/test10.cpp b/src/pal/tests/palsuite/c_runtime/fprintf/test10/test10.cpp deleted file mode 100644 index 5988e8da7..000000000 --- a/src/pal/tests/palsuite/c_runtime/fprintf/test10/test10.cpp +++ /dev/null @@ -1,49 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test10.c (fprintf) -** -** Purpose: Tests the octal specifier (%o). -** This test is modeled after the fprintf series. -** -** -**==========================================================================*/ - -#include -#include "../fprintf.h" - -/* - * Depends on memcmp, strlen, fopen, fseek and fgets. - */ - -int __cdecl main(int argc, char *argv[]) -{ - int neg = -42; - int pos = 42; - INT64 l = 42; - - if (PAL_Initialize(argc, argv) != 0) - return(FAIL); - - DoNumTest("foo %o", pos, "foo 52"); - DoNumTest("foo %lo", 0xFFFF, "foo 177777"); - DoNumTest("foo %ho", 0xFFFF, "foo 177777"); - DoNumTest("foo %Lo", pos, "foo 52"); - DoI64Test("foo %I64o", l, "42", "foo 52", "foo 52"); - DoNumTest("foo %3o", pos, "foo 52"); - DoNumTest("foo %-3o", pos, "foo 52 "); - DoNumTest("foo %.1o", pos, "foo 52"); - DoNumTest("foo %.3o", pos, "foo 052"); - DoNumTest("foo %03o", pos, "foo 052"); - DoNumTest("foo %#o", pos, "foo 052"); - DoNumTest("foo %+o", pos, "foo 52"); - DoNumTest("foo % o", pos, "foo 52"); - DoNumTest("foo %+o", neg, "foo 37777777726"); - DoNumTest("foo % o", neg, "foo 37777777726"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/fprintf/test10/testinfo.dat b/src/pal/tests/palsuite/c_runtime/fprintf/test10/testinfo.dat deleted file mode 100644 index 7afffeaf7..000000000 --- a/src/pal/tests/palsuite/c_runtime/fprintf/test10/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = fprintf -Name = Positive Test for fprintf -TYPE = DEFAULT -EXE1 = test10 -Description -= Tests the octal specifier (%o). -= This test is modeled after the fprintf series. diff --git a/src/pal/tests/palsuite/c_runtime/fprintf/test11/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/fprintf/test11/CMakeLists.txt deleted file mode 100644 index a5365b4fc..000000000 --- a/src/pal/tests/palsuite/c_runtime/fprintf/test11/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test11.cpp -) - -add_executable(paltest_fprintf_test11 - ${SOURCES} -) - -add_dependencies(paltest_fprintf_test11 coreclrpal) - -target_link_libraries(paltest_fprintf_test11 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/fprintf/test11/test11.cpp b/src/pal/tests/palsuite/c_runtime/fprintf/test11/test11.cpp deleted file mode 100644 index 01880552b..000000000 --- a/src/pal/tests/palsuite/c_runtime/fprintf/test11/test11.cpp +++ /dev/null @@ -1,49 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test11.c (fprintf) -** -** Purpose: Test the unsigned int specifier (%u). -** This test is modeled after the fprintf series. -** -** -**==========================================================================*/ - -#include -#include "../fprintf.h" - -/* - * Depends on memcmp, strlen, fopen, fseek and fgets. - */ - -int __cdecl main(int argc, char *argv[]) -{ - int neg = -42; - int pos = 42; - INT64 l = 42; - - if (PAL_Initialize(argc, argv) != 0) - return(FAIL); - - DoNumTest("foo %u", pos, "foo 42"); - DoNumTest("foo %lu", 0xFFFF, "foo 65535"); - DoNumTest("foo %hu", 0xFFFF, "foo 65535"); - DoNumTest("foo %Lu", pos, "foo 42"); - DoI64Test("foo %I64u", l, "42", "foo 42", "foo 42"); - DoNumTest("foo %3u", pos, "foo 42"); - DoNumTest("foo %-3u", pos, "foo 42 "); - DoNumTest("foo %.1u", pos, "foo 42"); - DoNumTest("foo %.3u", pos, "foo 042"); - DoNumTest("foo %03u", pos, "foo 042"); - DoNumTest("foo %#u", pos, "foo 42"); - DoNumTest("foo %+u", pos, "foo 42"); - DoNumTest("foo % u", pos, "foo 42"); - DoNumTest("foo %+u", neg, "foo 4294967254"); - DoNumTest("foo % u", neg, "foo 4294967254"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/fprintf/test11/testinfo.dat b/src/pal/tests/palsuite/c_runtime/fprintf/test11/testinfo.dat deleted file mode 100644 index 8275f0f7c..000000000 --- a/src/pal/tests/palsuite/c_runtime/fprintf/test11/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = fprintf -Name = Positive Test for fprintf -TYPE = DEFAULT -EXE1 = test11 -Description -= Test the unsigned int specifier (%u). -= This test is modeled after the fprintf series. diff --git a/src/pal/tests/palsuite/c_runtime/fprintf/test12/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/fprintf/test12/CMakeLists.txt deleted file mode 100644 index 40425217e..000000000 --- a/src/pal/tests/palsuite/c_runtime/fprintf/test12/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test12.cpp -) - -add_executable(paltest_fprintf_test12 - ${SOURCES} -) - -add_dependencies(paltest_fprintf_test12 coreclrpal) - -target_link_libraries(paltest_fprintf_test12 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/fprintf/test12/test12.cpp b/src/pal/tests/palsuite/c_runtime/fprintf/test12/test12.cpp deleted file mode 100644 index 0292e1501..000000000 --- a/src/pal/tests/palsuite/c_runtime/fprintf/test12/test12.cpp +++ /dev/null @@ -1,50 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test12.c -** -** Purpose: Tests the (lowercase) hexadecimal specifier (%x). -** This test is modeled after the fprintf series. -** -** -**==========================================================================*/ - -#include -#include "../fprintf.h" - -/* - * Depends on memcmp, strlen, fopen, fseek and fgets. - */ - -int __cdecl main(int argc, char *argv[]) -{ - int neg = -42; - int pos = 0x1234ab; - INT64 l = I64(0x1234567887654321); - - if (PAL_Initialize(argc, argv) != 0) - return(FAIL); - - DoNumTest("foo %x", pos, "foo 1234ab"); - DoNumTest("foo %lx", pos, "foo 1234ab"); - DoNumTest("foo %hx", pos, "foo 34ab"); - DoNumTest("foo %Lx", pos, "foo 1234ab"); - DoI64Test("foo %I64x", l, "0x1234567887654321", - "foo 1234567887654321", "foo 0x1234567887654321"); - DoNumTest("foo %7x", pos, "foo 1234ab"); - DoNumTest("foo %-7x", pos, "foo 1234ab "); - DoNumTest("foo %.1x", pos, "foo 1234ab"); - DoNumTest("foo %.7x", pos, "foo 01234ab"); - DoNumTest("foo %07x", pos, "foo 01234ab"); - DoNumTest("foo %#x", pos, "foo 0x1234ab"); - DoNumTest("foo %+x", pos, "foo 1234ab"); - DoNumTest("foo % x", pos, "foo 1234ab"); - DoNumTest("foo %+x", neg, "foo ffffffd6"); - DoNumTest("foo % x", neg, "foo ffffffd6"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/fprintf/test12/testinfo.dat b/src/pal/tests/palsuite/c_runtime/fprintf/test12/testinfo.dat deleted file mode 100644 index 4b44cfc31..000000000 --- a/src/pal/tests/palsuite/c_runtime/fprintf/test12/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = fprintf -Name = Positive Test for fprintf -TYPE = DEFAULT -EXE1 = test12 -Description -= Tests the (lowercase) hexadecimal specifier (%x). -= This test is modeled after the fprintf series. diff --git a/src/pal/tests/palsuite/c_runtime/fprintf/test13/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/fprintf/test13/CMakeLists.txt deleted file mode 100644 index 47ba3cb5b..000000000 --- a/src/pal/tests/palsuite/c_runtime/fprintf/test13/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test13.cpp -) - -add_executable(paltest_fprintf_test13 - ${SOURCES} -) - -add_dependencies(paltest_fprintf_test13 coreclrpal) - -target_link_libraries(paltest_fprintf_test13 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/fprintf/test13/test13.cpp b/src/pal/tests/palsuite/c_runtime/fprintf/test13/test13.cpp deleted file mode 100644 index e171aeacc..000000000 --- a/src/pal/tests/palsuite/c_runtime/fprintf/test13/test13.cpp +++ /dev/null @@ -1,50 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test13.c (fprintf) -** -** Purpose: Tests the (uppercase) hexadecimal specifier (%X). -** This test is modeled after the fprintf series. -** -** -**==========================================================================*/ - -#include -#include "../fprintf.h" - -/* - * Depends on memcmp, strlen, fopen, fseek and fgets. - */ - -int __cdecl main(int argc, char *argv[]) -{ - int neg = -42; - int pos = 0x1234AB; - INT64 l = I64(0x1234567887654321); - - if (PAL_Initialize(argc, argv) != 0) - return(FAIL); - - DoNumTest("foo %X", pos, "foo 1234AB"); - DoNumTest("foo %lX", pos, "foo 1234AB"); - DoNumTest("foo %hX", pos, "foo 34AB"); - DoNumTest("foo %LX", pos, "foo 1234AB"); - DoI64Test("foo %I64X", l, "0x1234567887654321", - "foo 1234567887654321", "foo 0x1234567887654321"); - DoNumTest("foo %7X", pos, "foo 1234AB"); - DoNumTest("foo %-7X", pos, "foo 1234AB "); - DoNumTest("foo %.1X", pos, "foo 1234AB"); - DoNumTest("foo %.7X", pos, "foo 01234AB"); - DoNumTest("foo %07X", pos, "foo 01234AB"); - DoNumTest("foo %#X", pos, "foo 0X1234AB"); - DoNumTest("foo %+X", pos, "foo 1234AB"); - DoNumTest("foo % X", pos, "foo 1234AB"); - DoNumTest("foo %+X", neg, "foo FFFFFFD6"); - DoNumTest("foo % X", neg, "foo FFFFFFD6"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/fprintf/test13/testinfo.dat b/src/pal/tests/palsuite/c_runtime/fprintf/test13/testinfo.dat deleted file mode 100644 index ae983ec78..000000000 --- a/src/pal/tests/palsuite/c_runtime/fprintf/test13/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = fprintf -Name = Positive Test for fprintf -TYPE = DEFAULT -EXE1 = test13 -Description -= Tests the (uppercase) hexadecimal specifier (%X). -= This test is modeled after the fprintf series. diff --git a/src/pal/tests/palsuite/c_runtime/fprintf/test14/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/fprintf/test14/CMakeLists.txt deleted file mode 100644 index dc3186c74..000000000 --- a/src/pal/tests/palsuite/c_runtime/fprintf/test14/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test14.cpp -) - -add_executable(paltest_fprintf_test14 - ${SOURCES} -) - -add_dependencies(paltest_fprintf_test14 coreclrpal) - -target_link_libraries(paltest_fprintf_test14 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/fprintf/test14/test14.cpp b/src/pal/tests/palsuite/c_runtime/fprintf/test14/test14.cpp deleted file mode 100644 index 5d7d77387..000000000 --- a/src/pal/tests/palsuite/c_runtime/fprintf/test14/test14.cpp +++ /dev/null @@ -1,49 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test14.c (fprintf) -** -** Purpose: Tests the lowercase exponential -** notation double specifier (%e). -** This test is modeled after the fprintf series. -** -** -**==========================================================================*/ - -#include -#include "../fprintf.h" - -/* - * Depends on memcmp, strlen, fopen, fseek and fgets. - */ - -int __cdecl main(int argc, char *argv[]) -{ - double val = 256.0; - double neg = -256.0; - - if (PAL_Initialize(argc, argv) != 0) - return(FAIL); - - DoDoubleTest("foo %e", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %le", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %he", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %Le", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %I64e", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %14e", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %-14e", val, "foo 2.560000e+002 ", "foo 2.560000e+02 "); - DoDoubleTest("foo %.1e", val, "foo 2.6e+002", "foo 2.6e+02"); - DoDoubleTest("foo %.8e", val, "foo 2.56000000e+002", "foo 2.56000000e+02"); - DoDoubleTest("foo %014e", val, "foo 02.560000e+002", "foo 002.560000e+02"); - DoDoubleTest("foo %#e", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %+e", val, "foo +2.560000e+002", "foo +2.560000e+02"); - DoDoubleTest("foo % e", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %+e", neg, "foo -2.560000e+002", "foo -2.560000e+02"); - DoDoubleTest("foo % e", neg, "foo -2.560000e+002", "foo -2.560000e+02"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/fprintf/test14/testinfo.dat b/src/pal/tests/palsuite/c_runtime/fprintf/test14/testinfo.dat deleted file mode 100644 index f0a843f48..000000000 --- a/src/pal/tests/palsuite/c_runtime/fprintf/test14/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = fprintf -Name = Positive Test for fprintf -TYPE = DEFAULT -EXE1 = test14 -Description -= Tests the lowercase exponential -= notation double specifier (%e). -= This test is modeled after the fprintf series. diff --git a/src/pal/tests/palsuite/c_runtime/fprintf/test15/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/fprintf/test15/CMakeLists.txt deleted file mode 100644 index 91718eeed..000000000 --- a/src/pal/tests/palsuite/c_runtime/fprintf/test15/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test15.cpp -) - -add_executable(paltest_fprintf_test15 - ${SOURCES} -) - -add_dependencies(paltest_fprintf_test15 coreclrpal) - -target_link_libraries(paltest_fprintf_test15 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/fprintf/test15/test15.cpp b/src/pal/tests/palsuite/c_runtime/fprintf/test15/test15.cpp deleted file mode 100644 index d024bdbd8..000000000 --- a/src/pal/tests/palsuite/c_runtime/fprintf/test15/test15.cpp +++ /dev/null @@ -1,49 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test15.c (fprintf) -** -** Purpose: Tests the uppercase exponential -** notation double specifier (%E). -** This test is modeled after the fprintf series. -** -** -**==========================================================================*/ - -#include -#include "../fprintf.h" - -/* - * Depends on memcmp, strlen, fopen, fseek and fgets. - */ - -int __cdecl main(int argc, char *argv[]) -{ - double val = 256.0; - double neg = -256.0; - - if (PAL_Initialize(argc, argv) != 0) - return(FAIL); - - DoDoubleTest("foo %E", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %lE", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %hE", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %LE", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %I64E", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %14E", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %-14E", val, "foo 2.560000E+002 ", "foo 2.560000E+02 "); - DoDoubleTest("foo %.1E", val, "foo 2.6E+002", "foo 2.6E+02"); - DoDoubleTest("foo %.8E", val, "foo 2.56000000E+002", "foo 2.56000000E+02"); - DoDoubleTest("foo %014E", val, "foo 02.560000E+002", "foo 002.560000E+02"); - DoDoubleTest("foo %#E", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %+E", val, "foo +2.560000E+002", "foo +2.560000E+02"); - DoDoubleTest("foo % E", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %+E", neg, "foo -2.560000E+002", "foo -2.560000E+02"); - DoDoubleTest("foo % E", neg, "foo -2.560000E+002", "foo -2.560000E+02"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/fprintf/test15/testinfo.dat b/src/pal/tests/palsuite/c_runtime/fprintf/test15/testinfo.dat deleted file mode 100644 index fedabca3c..000000000 --- a/src/pal/tests/palsuite/c_runtime/fprintf/test15/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = fprintf -Name = Positive Test for fprintf -TYPE = DEFAULT -EXE1 = test15 -Description -= Tests the uppercase exponential -= notation double specifier (%E). -= This test is modeled after the fprintf series. diff --git a/src/pal/tests/palsuite/c_runtime/fprintf/test16/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/fprintf/test16/CMakeLists.txt deleted file mode 100644 index 26dc1f8f5..000000000 --- a/src/pal/tests/palsuite/c_runtime/fprintf/test16/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test16.cpp -) - -add_executable(paltest_fprintf_test16 - ${SOURCES} -) - -add_dependencies(paltest_fprintf_test16 coreclrpal) - -target_link_libraries(paltest_fprintf_test16 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/fprintf/test16/test16.cpp b/src/pal/tests/palsuite/c_runtime/fprintf/test16/test16.cpp deleted file mode 100644 index 079faeaf5..000000000 --- a/src/pal/tests/palsuite/c_runtime/fprintf/test16/test16.cpp +++ /dev/null @@ -1,48 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test16.c (fprintf) -** -** Purpose: Tests the decimal notation double specifier (%f). -** This test is modeled after the fprintf series. -** -** -**==========================================================================*/ - -#include -#include "../fprintf.h" - -/* - * Depends on memcmp, strlen, fopen, fseek and fgets. - */ - -int __cdecl main(int argc, char *argv[]) -{ - double val = 2560.001; - double neg = -2560.001; - - if (PAL_Initialize(argc, argv) != 0) - return(FAIL); - - DoDoubleTest("foo %f", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %lf", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %hf", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %Lf", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %I64f", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %12f", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %-12f", val, "foo 2560.001000 ", "foo 2560.001000 "); - DoDoubleTest("foo %.1f", val, "foo 2560.0", "foo 2560.0"); - DoDoubleTest("foo %.8f", val, "foo 2560.00100000", "foo 2560.00100000"); - DoDoubleTest("foo %012f", val, "foo 02560.001000", "foo 02560.001000"); - DoDoubleTest("foo %#f", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %+f", val, "foo +2560.001000", "foo +2560.001000"); - DoDoubleTest("foo % f", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %+f", neg, "foo -2560.001000", "foo -2560.001000"); - DoDoubleTest("foo % f", neg, "foo -2560.001000", "foo -2560.001000"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/fprintf/test16/testinfo.dat b/src/pal/tests/palsuite/c_runtime/fprintf/test16/testinfo.dat deleted file mode 100644 index ef93c7c05..000000000 --- a/src/pal/tests/palsuite/c_runtime/fprintf/test16/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = fprintf -Name = Positive Test for fprintf -TYPE = DEFAULT -EXE1 = test16 -Description -= Tests the decimal notation double specifier (%f). -= This test is modeled after the fprintf series. diff --git a/src/pal/tests/palsuite/c_runtime/fprintf/test17/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/fprintf/test17/CMakeLists.txt deleted file mode 100644 index 9493f5496..000000000 --- a/src/pal/tests/palsuite/c_runtime/fprintf/test17/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test17.cpp -) - -add_executable(paltest_fprintf_test17 - ${SOURCES} -) - -add_dependencies(paltest_fprintf_test17 coreclrpal) - -target_link_libraries(paltest_fprintf_test17 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/fprintf/test17/test17.cpp b/src/pal/tests/palsuite/c_runtime/fprintf/test17/test17.cpp deleted file mode 100644 index 7bd817d7d..000000000 --- a/src/pal/tests/palsuite/c_runtime/fprintf/test17/test17.cpp +++ /dev/null @@ -1,49 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test17.c (fprintf) -** -** Purpose: Tests the lowercase shorthand notation double specifier (%g). -** This test is modeled after the fprintf series. -** -** -**==========================================================================*/ - -#include -#include "../fprintf.h" - -/* - * Depends on memcmp, strlen, fopen, fseek and fgets. - */ - -int __cdecl main(int argc, char *argv[]) -{ - double val = 2560.001; - double neg = -2560.001; - - if (PAL_Initialize(argc, argv) != 0) - return(FAIL); - - DoDoubleTest("foo %g", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %lg", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %hg", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %Lg", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %I64g", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %5g", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %-5g", val, "foo 2560 ", "foo 2560 "); - DoDoubleTest("foo %.1g", val, "foo 3e+003", "foo 3e+03"); - DoDoubleTest("foo %.2g", val, "foo 2.6e+003", "foo 2.6e+03"); - DoDoubleTest("foo %.12g", val, "foo 2560.001", "foo 2560.001"); - DoDoubleTest("foo %06g", val, "foo 002560", "foo 002560"); - DoDoubleTest("foo %#g", val, "foo 2560.00", "foo 2560.00"); - DoDoubleTest("foo %+g", val, "foo +2560", "foo +2560"); - DoDoubleTest("foo % g", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %+g", neg, "foo -2560", "foo -2560"); - DoDoubleTest("foo % g", neg, "foo -2560", "foo -2560"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/fprintf/test17/testinfo.dat b/src/pal/tests/palsuite/c_runtime/fprintf/test17/testinfo.dat deleted file mode 100644 index 420703c66..000000000 --- a/src/pal/tests/palsuite/c_runtime/fprintf/test17/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = fprintf -Name = Positive Test for fprintf -TYPE = DEFAULT -EXE1 = test17 -Description -= Tests the lowercase shorthand notation double specifier (%g). -= This test is modeled after the fprintf series. diff --git a/src/pal/tests/palsuite/c_runtime/fprintf/test18/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/fprintf/test18/CMakeLists.txt deleted file mode 100644 index 21a2e8788..000000000 --- a/src/pal/tests/palsuite/c_runtime/fprintf/test18/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test18.cpp -) - -add_executable(paltest_fprintf_test18 - ${SOURCES} -) - -add_dependencies(paltest_fprintf_test18 coreclrpal) - -target_link_libraries(paltest_fprintf_test18 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/fprintf/test18/test18.cpp b/src/pal/tests/palsuite/c_runtime/fprintf/test18/test18.cpp deleted file mode 100644 index 6582c41e0..000000000 --- a/src/pal/tests/palsuite/c_runtime/fprintf/test18/test18.cpp +++ /dev/null @@ -1,49 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test18.c (fprintf) -** -** Purpose: Tests the uppercase shorthand notation double specifier (%G). -** This test is modeled after the fprintf series. -** -** -**==========================================================================*/ - -#include -#include "../fprintf.h" - -/* - * Depends on memcmp, strlen, fopen, fseek and fgets. - */ - -int __cdecl main(int argc, char *argv[]) -{ - double val = 2560.001; - double neg = -2560.001; - - if (PAL_Initialize(argc, argv) != 0) - return(FAIL); - - DoDoubleTest("foo %G", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %lG", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %hG", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %LG", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %I64G", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %5G", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %-5G", val, "foo 2560 ", "foo 2560 "); - DoDoubleTest("foo %.1G", val, "foo 3E+003", "foo 3E+03"); - DoDoubleTest("foo %.2G", val, "foo 2.6E+003", "foo 2.6E+03"); - DoDoubleTest("foo %.12G", val, "foo 2560.001", "foo 2560.001"); - DoDoubleTest("foo %06G", val, "foo 002560", "foo 002560"); - DoDoubleTest("foo %#G", val, "foo 2560.00", "foo 2560.00"); - DoDoubleTest("foo %+G", val, "foo +2560", "foo +2560"); - DoDoubleTest("foo % G", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %+G", neg, "foo -2560", "foo -2560"); - DoDoubleTest("foo % G", neg, "foo -2560", "foo -2560"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/fprintf/test18/testinfo.dat b/src/pal/tests/palsuite/c_runtime/fprintf/test18/testinfo.dat deleted file mode 100644 index 129febec2..000000000 --- a/src/pal/tests/palsuite/c_runtime/fprintf/test18/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = fprintf -Name = Positive Test for fprintf -TYPE = DEFAULT -EXE1 = test18 -Description -= Tests the uppercase shorthand notation double specifier (%G). -= This test is modeled after the fprintf series. diff --git a/src/pal/tests/palsuite/c_runtime/fprintf/test19/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/fprintf/test19/CMakeLists.txt deleted file mode 100644 index 419d180fc..000000000 --- a/src/pal/tests/palsuite/c_runtime/fprintf/test19/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test19.cpp -) - -add_executable(paltest_fprintf_test19 - ${SOURCES} -) - -add_dependencies(paltest_fprintf_test19 coreclrpal) - -target_link_libraries(paltest_fprintf_test19 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/fprintf/test19/test19.cpp b/src/pal/tests/palsuite/c_runtime/fprintf/test19/test19.cpp deleted file mode 100644 index 9d9a28c32..000000000 --- a/src/pal/tests/palsuite/c_runtime/fprintf/test19/test19.cpp +++ /dev/null @@ -1,153 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test19.c (fprintf) -** -** Purpose: Tests the variable length precision argument. -** This test is modeled after the fprintf series. -** -** -**==========================================================================*/ - -#include -#include "../fprintf.h" - -/* - * Depends on memcmp, strlen, fopen, fseek and fgets. - */ - -#define DOTEST(a,b,c,d,e,f) DoTest(a,b,(void*)c,d,e,f) - -void DoTest(char *formatstr, int precision, void *param, - char *paramstr, char *checkstr1, char *checkstr2) -{ - FILE *fp; - char buf[256]; - - if ((fp = fopen("testfile.txt", "w+")) == NULL ) - { - Fail("ERROR: fopen failed to create testfile\n"); - } - - if ((fprintf(fp, formatstr, precision, param)) < 0) - { - Fail("ERROR: fprintf failed\n"); - } - - if ((fseek(fp, 0, SEEK_SET)) != 0) - { - Fail("ERROR: fseek failed\n"); - } - - if ((fgets(buf, 100, fp)) == NULL) - { - Fail("ERROR: fseek failed\n"); - } - - if (memcmp(buf, checkstr1, strlen(buf) + 1) != 0 && - memcmp(buf, checkstr2, strlen(buf) + 1) != 0) - { - Fail("ERROR: failed to insert %s into \"%s\" with precision %d\n" - "Expected \"%s\" or \"%s\", got \"%s\".\n", paramstr, formatstr, - precision, - checkstr1, checkstr2, buf); - } - - if ((fclose( fp )) != 0) - - { - Fail("ERROR: fclose failed to close \"testfile.txt\"\n"); - } - -} - -void DoublePrecTest(char *formatstr, int precision, - double param, char *checkstr1, char *checkstr2) -{ - FILE *fp; - char buf[256]; - - if ((fp = fopen("testfile.txt", "w+")) == NULL ) - { - Fail("ERROR: fopen failed to create testfile\n"); - } - - if ((fprintf(fp, formatstr, precision, param)) < 0) - { - Fail("ERROR: fprintf failed\n"); - } - - if ((fseek(fp, 0, SEEK_SET)) != 0) - { - Fail("ERROR: fseek failed\n"); - } - - if ((fgets(buf, 100, fp)) == NULL) - { - Fail("ERROR: fseek failed\n"); - } - - if (memcmp(buf, checkstr1, strlen(buf) + 1) != 0 && - memcmp(buf, checkstr2, strlen(buf) + 1) != 0) - { - Fail("ERROR: failed to insert %f into \"%s\" with precision %d\n" - "Expected \"%s\" or \"%s\", got \"%s\".\n", - param, formatstr, precision, checkstr1, checkstr2, buf); - } - - if ((fclose( fp )) != 0) - { - Fail("ERROR: fclose failed to close \"testfile.txt\"\n"); - } - -} - -int __cdecl main(int argc, char *argv[]) -{ - - if (PAL_Initialize(argc, argv) != 0) - return(FAIL); - - DOTEST("%.*s", 2, "bar", "bar", "ba", "ba"); - DOTEST("%.*S", 2, convert("bar"), "bar", "ba", "ba"); - - //DOTEST("%.*n", 4, 2, "2", "0002"); - DOTEST("%.*c", 0, 'a', "a", "a", "a"); - DOTEST("%.*c", 4, 'a', "a", "a", "a"); - DOTEST("%.*C", 0, (WCHAR)'a', "a", "a", "a"); - DOTEST("%.*C", 4, (WCHAR)'a', "a", "a", "a"); - DOTEST("%.*d", 1, 42, "42", "42", "42"); - DOTEST("%.*d", 3, 42, "42", "042", "042"); - DOTEST("%.*i", 1, 42, "42", "42", "42"); - DOTEST("%.*i", 3, 42, "42", "042", "042"); - DOTEST("%.*o", 1, 42, "42", "52", "52"); - DOTEST("%.*o", 3, 42, "42", "052", "052"); - DOTEST("%.*u", 1, 42, "42", "42", "42"); - DOTEST("%.*u", 3, 42, "42", "042", "042"); - DOTEST("%.*x", 1, 0x42, "0x42", "42", "42"); - DOTEST("%.*x", 3, 0x42, "0x42", "042", "042"); - DOTEST("%.*X", 1, 0x42, "0x42", "42", "42"); - DOTEST("%.*X", 3, 0x42, "0x42", "042", "042"); - - - DoublePrecTest("%.*e", 1, 2.01, "2.0e+000", "2.0e+00"); - DoublePrecTest("%.*e", 3, 2.01, "2.010e+000", "2.010e+00"); - DoublePrecTest("%.*E", 1, 2.01, "2.0E+000", "2.0E+00"); - DoublePrecTest("%.*E", 3, 2.01, "2.010E+000", "2.010E+00"); - DoublePrecTest("%.*f", 1, 2.01, "2.0", "2.0"); - DoublePrecTest("%.*f", 3, 2.01, "2.010", "2.010"); - DoublePrecTest("%.*g", 1, 256.01, "3e+002", "3e+02"); - DoublePrecTest("%.*g", 3, 256.01, "256", "256"); - DoublePrecTest("%.*g", 4, 256.01, "256", "256"); - DoublePrecTest("%.*g", 6, 256.01, "256.01", "256.01"); - DoublePrecTest("%.*G", 1, 256.01, "3E+002", "3E+02"); - DoublePrecTest("%.*G", 3, 256.01, "256", "256"); - DoublePrecTest("%.*G", 4, 256.01, "256", "256"); - DoublePrecTest("%.*G", 6, 256.01, "256.01", "256.01"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/fprintf/test19/testinfo.dat b/src/pal/tests/palsuite/c_runtime/fprintf/test19/testinfo.dat deleted file mode 100644 index 25025b920..000000000 --- a/src/pal/tests/palsuite/c_runtime/fprintf/test19/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = fprintf -Name = Positive Test for fprintf -TYPE = DEFAULT -EXE1 = test19 -Description -= Tests the variable length precision argument. -= This test is modeled after the fprintf series. diff --git a/src/pal/tests/palsuite/c_runtime/fprintf/test2/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/fprintf/test2/CMakeLists.txt deleted file mode 100644 index 88bd04c75..000000000 --- a/src/pal/tests/palsuite/c_runtime/fprintf/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test2.cpp -) - -add_executable(paltest_fprintf_test2 - ${SOURCES} -) - -add_dependencies(paltest_fprintf_test2 coreclrpal) - -target_link_libraries(paltest_fprintf_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/fprintf/test2/test2.cpp b/src/pal/tests/palsuite/c_runtime/fprintf/test2/test2.cpp deleted file mode 100644 index 144182748..000000000 --- a/src/pal/tests/palsuite/c_runtime/fprintf/test2/test2.cpp +++ /dev/null @@ -1,49 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test2.c (fprintf) -** -** Purpose: Tests the string specifier (%s). -** This test is modeled after the fprintf series. -** -** -**==========================================================================*/ - -#include -#include "../fprintf.h" - -/* - * Depends on memcmp, strlen, fopen, fseek and fgets. - */ - -int __cdecl main(int argc, char *argv[]) -{ - - if (PAL_Initialize(argc, argv) != 0) - return(FAIL); - - DoStrTest("foo %s", "bar", "foo bar"); - DoStrTest("foo %hs", "bar", "foo bar"); - DoWStrTest("foo %ls", convert("bar"), "foo bar"); - DoWStrTest("foo %ws", convert("bar"), "foo bar"); - DoStrTest("foo %Ls", "bar", "foo bar"); - DoStrTest("foo %I64s", "bar", "foo bar"); - DoStrTest("foo %5s", "bar", "foo bar"); - DoStrTest("foo %.2s", "bar", "foo ba"); - DoStrTest("foo %5.2s", "bar", "foo ba"); - DoStrTest("foo %-5s", "bar", "foo bar "); - DoStrTest("foo %05s", "bar", "foo 00bar"); - DoStrTest("foo %s", NULL, "foo (null)"); - DoStrTest("foo %hs", NULL, "foo (null)"); - DoWStrTest("foo %ls", NULL, "foo (null)"); - DoWStrTest("foo %ws", NULL, "foo (null)"); - DoStrTest("foo %Ls", NULL, "foo (null)"); - DoStrTest("foo %I64s", NULL, "foo (null)"); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/c_runtime/fprintf/test2/testinfo.dat b/src/pal/tests/palsuite/c_runtime/fprintf/test2/testinfo.dat deleted file mode 100644 index d4c7dbff4..000000000 --- a/src/pal/tests/palsuite/c_runtime/fprintf/test2/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = fprintf -Name = Positive Test for fprintf -TYPE = DEFAULT -EXE1 = test2 -Description -= Tests the string specifier (%s). -= This test is modeled after the fprintf series. diff --git a/src/pal/tests/palsuite/c_runtime/fprintf/test3/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/fprintf/test3/CMakeLists.txt deleted file mode 100644 index 42d3977e0..000000000 --- a/src/pal/tests/palsuite/c_runtime/fprintf/test3/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test3.cpp -) - -add_executable(paltest_fprintf_test3 - ${SOURCES} -) - -add_dependencies(paltest_fprintf_test3 coreclrpal) - -target_link_libraries(paltest_fprintf_test3 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/fprintf/test3/test3.cpp b/src/pal/tests/palsuite/c_runtime/fprintf/test3/test3.cpp deleted file mode 100644 index dd34c0853..000000000 --- a/src/pal/tests/palsuite/c_runtime/fprintf/test3/test3.cpp +++ /dev/null @@ -1,49 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test3.c (fprintf) -** -** Purpose: Tests the wide string specifier (%S). -** This test is modeled after the fprintf series. -** -** -**==========================================================================*/ - -#include -#include "../fprintf.h" - -/* - * Depends on memcmp, strlen, fopen, fseek and fgets. - */ - -int __cdecl main(int argc, char *argv[]) -{ - if (PAL_Initialize(argc, argv) != 0) - return(FAIL); - - DoWStrTest("foo %S", convert("bar"), "foo bar"); - DoStrTest("foo %hS", "bar", "foo bar"); - DoWStrTest("foo %lS", convert("bar"), "foo bar"); - DoWStrTest("foo %wS", convert("bar"), "foo bar"); - DoWStrTest("foo %LS", convert("bar"), "foo bar"); - DoWStrTest("foo %I64S", convert("bar"), "foo bar"); - DoWStrTest("foo %5S", convert("bar"), "foo bar"); - DoWStrTest("foo %.2S", convert("bar"), "foo ba"); - DoWStrTest("foo %5.2S", convert("bar"), "foo ba"); - DoWStrTest("foo %-5S", convert("bar"), "foo bar "); - DoWStrTest("foo %05S", convert("bar"), "foo 00bar"); - DoWStrTest("foo %S", NULL, "foo (null)"); - DoStrTest("foo %hS", NULL, "foo (null)"); - DoWStrTest("foo %lS", NULL, "foo (null)"); - DoWStrTest("foo %wS", NULL, "foo (null)"); - DoWStrTest("foo %LS", NULL, "foo (null)"); - DoWStrTest("foo %I64S", NULL, "foo (null)"); - - PAL_Terminate(); - return PASS; -} - - diff --git a/src/pal/tests/palsuite/c_runtime/fprintf/test3/testinfo.dat b/src/pal/tests/palsuite/c_runtime/fprintf/test3/testinfo.dat deleted file mode 100644 index 88a1b03a7..000000000 --- a/src/pal/tests/palsuite/c_runtime/fprintf/test3/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = fprintf -Name = Positive Test for fprintf -TYPE = DEFAULT -EXE1 = test3 -Description -= Tests the wide string specifier (%S). -= This test is modeled after the fprintf series. diff --git a/src/pal/tests/palsuite/c_runtime/fprintf/test4/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/fprintf/test4/CMakeLists.txt deleted file mode 100644 index 7e6cc18f1..000000000 --- a/src/pal/tests/palsuite/c_runtime/fprintf/test4/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test4.cpp -) - -add_executable(paltest_fprintf_test4 - ${SOURCES} -) - -add_dependencies(paltest_fprintf_test4 coreclrpal) - -target_link_libraries(paltest_fprintf_test4 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/fprintf/test4/test4.cpp b/src/pal/tests/palsuite/c_runtime/fprintf/test4/test4.cpp deleted file mode 100644 index ef3108d86..000000000 --- a/src/pal/tests/palsuite/c_runtime/fprintf/test4/test4.cpp +++ /dev/null @@ -1,110 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test4.c (fprintf) -** -** Purpose: Tests the pointer specifier (%p). -** This test is modeled after the fprintf series. -** -** -**==========================================================================*/ - -#include -#include "../fprintf.h" - -/* - * Depends on memcmp, strlen, fopen, fseek and fgets. - */ - -static void DoTest(char *formatstr, void* param, char* paramstr, - char *checkstr1, char *checkstr2) -{ - FILE *fp; - char buf[256] = { 0 }; - - if ((fp = fopen("testfile.txt", "w+")) == NULL ) - { - Fail("ERROR: fopen failed to create testfile\n"); - } - - if ((fprintf(fp, formatstr, param)) < 0) - { - Fail("ERROR: fprintf failed\n"); - } - - if ((fseek(fp, 0, SEEK_SET)) != 0) - { - Fail("ERROR: fseek failed\n"); - } - - if ((fgets(buf, 100, fp)) == NULL) - { - Fail("ERROR: fseek failed\n"); - } - - if (memcmp(buf, checkstr1, strlen(buf) + 1) != 0 && - memcmp(buf, checkstr2, strlen(buf) + 1) != 0 ) - { - Fail("ERROR: failed to insert %s into \"%s\"\n" - "Expected \"%s\" or \"%s\" got \"%s\".\n", - paramstr, formatstr, checkstr1, checkstr2, buf); - } - - if ((fclose( fp )) != 0) - - { - - Fail("ERROR: fclose failed to close \"testfile.txt\"\n"); - - } -} - - -int __cdecl main(int argc, char *argv[]) -{ - void *ptr = (void*) 0x123456; - INT64 lptr = I64(0x1234567887654321); - - if (PAL_Initialize(argc, argv) != 0) - return(FAIL); - - -/* -** Run only on 64 bit platforms -*/ -#if defined(BIT64) - Trace("Testing for 64 Bit Platforms \n"); - DoTest("%p", NULL, "NULL", "0000000000000000", "0x0"); - DoTest("%p", ptr, "pointer to 0x123456", "0000000000123456", "0x123456"); - DoTest("%17p", ptr, "pointer to 0x123456", " 0000000000123456", " 0x123456"); - DoTest("%17p", ptr, "pointer to 0x123456", " 0000000000123456", "0x0123456"); - DoTest("%-17p", ptr, "pointer to 0x123456", "0000000000123456 ", "0x123456 "); - DoTest("%+p", ptr, "pointer to 0x123456", "0000000000123456", "0x123456"); - DoTest("%#p", ptr, "pointer to 0x123456", "0X0000000000123456", "0x123456"); - DoTest("%lp", ptr, "pointer to 0x123456", "00123456", "0x123456"); - DoTest("%hp", ptr, "pointer to 0x123456", "00003456", "0x3456"); - DoTest("%Lp", ptr, "pointer to 0x123456", "00123456", "0x123456"); - DoI64Test("%I64p", lptr, "pointer to 0x1234567887654321", - "1234567887654321", "0x1234567887654321"); -#else - Trace("Testing for Non 64 Bit Platforms \n"); - DoTest("%p", NULL, "NULL", "00000000", "0x0"); - DoTest("%p", ptr, "pointer to 0x123456", "00123456", "0x123456"); - DoTest("%9p", ptr, "pointer to 0x123456", " 00123456", " 0x123456"); - DoTest("%09p", ptr, "pointer to 0x123456", " 00123456", "0x0123456"); - DoTest("%-9p", ptr, "pointer to 0x123456", "00123456 ", "0x123456 "); - DoTest("%+p", ptr, "pointer to 0x123456", "00123456", "0x123456"); - DoTest("%#p", ptr, "pointer to 0x123456", "0X00123456", "0x123456"); - DoTest("%lp", ptr, "pointer to 0x123456", "00123456", "0x123456"); - DoTest("%hp", ptr, "pointer to 0x123456", "00003456", "0x3456"); - DoTest("%Lp", ptr, "pointer to 0x123456", "00123456", "0x123456"); - DoI64Test("%I64p", lptr, "pointer to 0x1234567887654321", - "1234567887654321", "0x1234567887654321"); -#endif - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/fprintf/test4/testinfo.dat b/src/pal/tests/palsuite/c_runtime/fprintf/test4/testinfo.dat deleted file mode 100644 index 5f373ac23..000000000 --- a/src/pal/tests/palsuite/c_runtime/fprintf/test4/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = fprintf -Name = Positive Test for fprintf -TYPE = DEFAULT -EXE1 = test4 -Description -= Tests the pointer specifier (%p). -= This test is modeled after the fprintf series. diff --git a/src/pal/tests/palsuite/c_runtime/fprintf/test5/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/fprintf/test5/CMakeLists.txt deleted file mode 100644 index 6cea5197a..000000000 --- a/src/pal/tests/palsuite/c_runtime/fprintf/test5/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test5.cpp -) - -add_executable(paltest_fprintf_test5 - ${SOURCES} -) - -add_dependencies(paltest_fprintf_test5 coreclrpal) - -target_link_libraries(paltest_fprintf_test5 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/fprintf/test5/test5.cpp b/src/pal/tests/palsuite/c_runtime/fprintf/test5/test5.cpp deleted file mode 100644 index c53e3f45b..000000000 --- a/src/pal/tests/palsuite/c_runtime/fprintf/test5/test5.cpp +++ /dev/null @@ -1,131 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test5.c (fprintf) -** -** Purpose: Tests the count specifier (%n). -** This test is modeled after the fprintf series. -** -** -**==========================================================================*/ - -#include -#include "../fprintf.h" - -/* - * Depends on memcmp, strlen, fopen, fseek and fgets. - */ - -static void DoTest(char *formatstr, int param, char *checkstr) -{ - FILE *fp; - char buf[256] = { 0 }; - int n = -1; - - if ((fp = fopen("testfile.txt", "w+")) == NULL ) - { - Fail("ERROR: fopen failed to create testfile\n"); - } - - if ((fprintf(fp, formatstr, &n)) < 0) - { - Fail("ERROR: fprintf failed\n"); - } - - if ((fseek(fp, 0, SEEK_SET)) != 0) - { - Fail("ERROR: fseek failed\n"); - } - - if ((fgets(buf, 100, fp)) == NULL) - { - Fail("ERROR: fseek failed\n"); - } - - if (n != param) - { - Fail("ERROR: Expected count parameter to resolve to %d, got %X\n", - param, n); - } - - if (memcmp(buf, checkstr, strlen(buf) + 1) != 0) - { - Fail("ERROR: Expected \"%s\" got \"%s\".\n", checkstr, buf); - } - - - if ((fclose( fp )) != 0) - - { - - Fail("ERROR: fclose failed to close \"testfile.txt\"\n"); - - } -} - -static void DoShortTest(char *formatstr, int param, char *checkstr) -{ - FILE *fp; - char buf[256] = { 0 }; - short int n = -1; - - if ((fp = fopen("testfile.txt", "w+")) == NULL ) - { - Fail("ERROR: fopen failed to create testfile\n"); - } - - if ((fprintf(fp, formatstr, &n)) < 0) - { - Fail("ERROR: fprintf failed\n"); - } - - if ((fseek(fp, 0, SEEK_SET)) != 0) - { - Fail("ERROR: fseek failed\n"); - } - - if ((fgets(buf, 100, fp)) == NULL) - { - Fail("ERROR: fseek failed\n"); - } - - if (n != param) - { - Fail("ERROR: Expected count parameter to resolve to %d, got %X\n", - param, n); - } - - if (memcmp(buf, checkstr, strlen(buf) + 1) != 0) - { - Fail("ERROR: Expected \"%s\" got \"%s\".\n", checkstr, buf); - } - - if ((fclose( fp )) != 0) - { - Fail("ERROR: fclose failed to close \"testfile.txt\"\n"); - } -} - -int __cdecl main(int argc, char *argv[]) -{ - if (PAL_Initialize(argc, argv) != 0) - return(FAIL); - - DoTest("foo %n bar", 4, "foo bar"); - DoTest("foo %#n bar", 4, "foo bar"); - DoTest("foo % n bar", 4, "foo bar"); - DoTest("foo %+n bar", 4, "foo bar"); - DoTest("foo %-n bar", 4, "foo bar"); - DoTest("foo %0n bar", 4, "foo bar"); - DoShortTest("foo %hn bar", 4, "foo bar"); - DoTest("foo %ln bar", 4, "foo bar"); - DoTest("foo %Ln bar", 4, "foo bar"); - DoTest("foo %I64n bar", 4, "foo bar"); - DoTest("foo %20.3n bar", 4, "foo bar"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/fprintf/test5/testinfo.dat b/src/pal/tests/palsuite/c_runtime/fprintf/test5/testinfo.dat deleted file mode 100644 index b4d0e8177..000000000 --- a/src/pal/tests/palsuite/c_runtime/fprintf/test5/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = fprintf -Name = Positive Test for fprintf -TYPE = DEFAULT -EXE1 = test5 -Description -= Tests the count specifier (%n). -= This test is modeled after the fprintf series. diff --git a/src/pal/tests/palsuite/c_runtime/fprintf/test6/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/fprintf/test6/CMakeLists.txt deleted file mode 100644 index 9e3cf0139..000000000 --- a/src/pal/tests/palsuite/c_runtime/fprintf/test6/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test6.cpp -) - -add_executable(paltest_fprintf_test6 - ${SOURCES} -) - -add_dependencies(paltest_fprintf_test6 coreclrpal) - -target_link_libraries(paltest_fprintf_test6 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/fprintf/test6/test6.cpp b/src/pal/tests/palsuite/c_runtime/fprintf/test6/test6.cpp deleted file mode 100644 index 0a8bc6b10..000000000 --- a/src/pal/tests/palsuite/c_runtime/fprintf/test6/test6.cpp +++ /dev/null @@ -1,46 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test6.c (fprintf) -** -** Purpose: Tests the char specifier (%c). -** This test is modeled after the fprintf series. -** -** -**==========================================================================*/ - -#include -#include "../fprintf.h" - -/* - * Depends on memcmp, strlen, fopen, fseek and fgets. - */ - -int __cdecl main(int argc, char *argv[]) -{ - WCHAR wc = (WCHAR) 'c'; - - if (PAL_Initialize(argc, argv) != 0) - return(FAIL); - - DoCharTest("foo %c", 'b', "foo b"); - DoCharTest("foo %hc", 'b', "foo b"); - DoWCharTest("foo %lc", wc, "foo c"); - DoCharTest("foo %Lc", 'b', "foo b"); - DoCharTest("foo %I64c", 'b', "foo b"); - DoCharTest("foo %5c", 'b', "foo b"); - DoCharTest("foo %.0c", 'b', "foo b"); - DoCharTest("foo %-5c", 'b', "foo b "); - DoCharTest("foo %05c", 'b', "foo 0000b"); - DoCharTest("foo % c", 'b', "foo b"); - DoCharTest("foo %#c", 'b', "foo b"); - - PAL_Terminate(); - return PASS; -} - - - diff --git a/src/pal/tests/palsuite/c_runtime/fprintf/test6/testinfo.dat b/src/pal/tests/palsuite/c_runtime/fprintf/test6/testinfo.dat deleted file mode 100644 index a8a071ca2..000000000 --- a/src/pal/tests/palsuite/c_runtime/fprintf/test6/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = fprintf -Name = Positive Test for fprintf -TYPE = DEFAULT -EXE1 = test6 -Description -= Tests the char specifier (%c). -= This test is modeled after the fprintf series. diff --git a/src/pal/tests/palsuite/c_runtime/fprintf/test7/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/fprintf/test7/CMakeLists.txt deleted file mode 100644 index 92dd50ab3..000000000 --- a/src/pal/tests/palsuite/c_runtime/fprintf/test7/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test7.cpp -) - -add_executable(paltest_fprintf_test7 - ${SOURCES} -) - -add_dependencies(paltest_fprintf_test7 coreclrpal) - -target_link_libraries(paltest_fprintf_test7 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/fprintf/test7/test7.cpp b/src/pal/tests/palsuite/c_runtime/fprintf/test7/test7.cpp deleted file mode 100644 index 088e328de..000000000 --- a/src/pal/tests/palsuite/c_runtime/fprintf/test7/test7.cpp +++ /dev/null @@ -1,44 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test7.c (fprintf) -** -** Purpose: Tests the wide char specifier (%C). -** This test is modeled after the fprintf series. -** -** -**==========================================================================*/ - -#include -#include "../fprintf.h" - -/* - * Depends on memcmp, strlen, fopen, fseek and fgets. - */ - -int __cdecl main(int argc, char *argv[]) -{ - WCHAR wb = (WCHAR) 'b'; - - if (PAL_Initialize(argc, argv) != 0) - return(FAIL); - - DoWCharTest("foo %C", wb, "foo b"); - DoWCharTest("foo %hC", wb, "foo b"); - DoCharTest("foo %lC", 'c', "foo c"); - DoWCharTest("foo %LC", wb, "foo b"); - DoWCharTest("foo %I64C", wb, "foo b"); - DoWCharTest("foo %5C", wb, "foo b"); - DoWCharTest("foo %.0C", wb, "foo b"); - DoWCharTest("foo %-5C", wb, "foo b "); - DoWCharTest("foo %05C", wb, "foo 0000b"); - DoWCharTest("foo % C", wb, "foo b"); - DoWCharTest("foo %#C", wb, "foo b"); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/c_runtime/fprintf/test7/testinfo.dat b/src/pal/tests/palsuite/c_runtime/fprintf/test7/testinfo.dat deleted file mode 100644 index fc1271806..000000000 --- a/src/pal/tests/palsuite/c_runtime/fprintf/test7/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = fprintf -Name = Positive Test for fprintf -TYPE = DEFAULT -EXE1 = test7 -Description -= Tests the wide char specifier (%C). -= This test is modeled after the fprintf series. diff --git a/src/pal/tests/palsuite/c_runtime/fprintf/test8/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/fprintf/test8/CMakeLists.txt deleted file mode 100644 index 9aa9af821..000000000 --- a/src/pal/tests/palsuite/c_runtime/fprintf/test8/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test8.cpp -) - -add_executable(paltest_fprintf_test8 - ${SOURCES} -) - -add_dependencies(paltest_fprintf_test8 coreclrpal) - -target_link_libraries(paltest_fprintf_test8 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/fprintf/test8/test8.cpp b/src/pal/tests/palsuite/c_runtime/fprintf/test8/test8.cpp deleted file mode 100644 index c781abc96..000000000 --- a/src/pal/tests/palsuite/c_runtime/fprintf/test8/test8.cpp +++ /dev/null @@ -1,49 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test8.c (fprintf) -** -** Purpose: Tests the decimal specifier (%d). -** This test is modeled after the fprintf series. -** -** -**==========================================================================*/ - -#include -#include "../fprintf.h" - -/* - * Depends on memcmp, strlen, fopen, fseek and fgets. - */ - -int __cdecl main(int argc, char *argv[]) -{ - int neg = -42; - int pos = 42; - INT64 l = 42; - - if (PAL_Initialize(argc, argv) != 0) - return(FAIL); - - DoNumTest("foo %d", pos, "foo 42"); - DoNumTest("foo %ld", 0xFFFF, "foo 65535"); - DoNumTest("foo %hd", 0xFFFF, "foo -1"); - DoNumTest("foo %Ld", pos, "foo 42"); - DoI64Test("foo %I64d", l, "42", "foo 42", "foo 42"); - DoNumTest("foo %3d", pos, "foo 42"); - DoNumTest("foo %-3d", pos, "foo 42 "); - DoNumTest("foo %.1d", pos, "foo 42"); - DoNumTest("foo %.3d", pos, "foo 042"); - DoNumTest("foo %03d", pos, "foo 042"); - DoNumTest("foo %#d", pos, "foo 42"); - DoNumTest("foo %+d", pos, "foo +42"); - DoNumTest("foo % d", pos, "foo 42"); - DoNumTest("foo %+d", neg, "foo -42"); - DoNumTest("foo % d", neg, "foo -42"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/fprintf/test8/testinfo.dat b/src/pal/tests/palsuite/c_runtime/fprintf/test8/testinfo.dat deleted file mode 100644 index 260926078..000000000 --- a/src/pal/tests/palsuite/c_runtime/fprintf/test8/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = fprintf -Name = Positive Test for fprintf -TYPE = DEFAULT -EXE1 = test8 -Description -= Tests the decimal specifier (%d). -= This test is modeled after the fprintf series. diff --git a/src/pal/tests/palsuite/c_runtime/fprintf/test9/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/fprintf/test9/CMakeLists.txt deleted file mode 100644 index 6a7bb4de3..000000000 --- a/src/pal/tests/palsuite/c_runtime/fprintf/test9/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test9.cpp -) - -add_executable(paltest_fprintf_test9 - ${SOURCES} -) - -add_dependencies(paltest_fprintf_test9 coreclrpal) - -target_link_libraries(paltest_fprintf_test9 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/fprintf/test9/test9.cpp b/src/pal/tests/palsuite/c_runtime/fprintf/test9/test9.cpp deleted file mode 100644 index 3b06daec4..000000000 --- a/src/pal/tests/palsuite/c_runtime/fprintf/test9/test9.cpp +++ /dev/null @@ -1,49 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test9.c (fprintf) -** -** Purpose: Tests the integer specifier (%i). -** This test is modeled after the fprintf series. -** -** -**==========================================================================*/ - -#include -#include "../fprintf.h" - -/* - * Depends on memcmp, strlen, fopen, fseek and fgets. - */ - -int __cdecl main(int argc, char *argv[]) -{ - int neg = -42; - int pos = 42; - INT64 l = 42; - - if (PAL_Initialize(argc, argv) != 0) - return(FAIL); - - DoNumTest("foo %i", pos, "foo 42"); - DoNumTest("foo %li", 0xFFFF, "foo 65535"); - DoNumTest("foo %hi", 0xFFFF, "foo -1"); - DoNumTest("foo %Li", pos, "foo 42"); - DoI64Test("foo %I64i", l, "42", "foo 42", "foo 42"); - DoNumTest("foo %3i", pos, "foo 42"); - DoNumTest("foo %-3i", pos, "foo 42 "); - DoNumTest("foo %.1i", pos, "foo 42"); - DoNumTest("foo %.3i", pos, "foo 042"); - DoNumTest("foo %03i", pos, "foo 042"); - DoNumTest("foo %#i", pos, "foo 42"); - DoNumTest("foo %+i", pos, "foo +42"); - DoNumTest("foo % i", pos, "foo 42"); - DoNumTest("foo %+i", neg, "foo -42"); - DoNumTest("foo % i", neg, "foo -42"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/fprintf/test9/testinfo.dat b/src/pal/tests/palsuite/c_runtime/fprintf/test9/testinfo.dat deleted file mode 100644 index e502af70b..000000000 --- a/src/pal/tests/palsuite/c_runtime/fprintf/test9/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = fprintf -Name = Positive Test for fprintf -TYPE = DEFAULT -EXE1 = test9 -Description -= Tests the integer specifier (%i). -= This test is modeled after the fprintf series. diff --git a/src/pal/tests/palsuite/c_runtime/fputs/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/fputs/CMakeLists.txt deleted file mode 100644 index ef14ea535..000000000 --- a/src/pal/tests/palsuite/c_runtime/fputs/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) - diff --git a/src/pal/tests/palsuite/c_runtime/fputs/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/fputs/test1/CMakeLists.txt deleted file mode 100644 index 1e0fbcb60..000000000 --- a/src/pal/tests/palsuite/c_runtime/fputs/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_fputs_test1 - ${SOURCES} -) - -add_dependencies(paltest_fputs_test1 coreclrpal) - -target_link_libraries(paltest_fputs_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/fputs/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/fputs/test1/test1.cpp deleted file mode 100644 index b90ea082e..000000000 --- a/src/pal/tests/palsuite/c_runtime/fputs/test1/test1.cpp +++ /dev/null @@ -1,100 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test1.c -** -** Purpose: Call fputs twice and write two strings to a file. Then -** call fread on the file and check that the data which was written is what -** we expect it to be. -** - -** -**===================================================================*/ - - -#include - - -int __cdecl main(int argc, char **argv) -{ - - FILE* TheFile; - char* StringOne = "FooBar"; - char* StringTwo = "BarFoo"; - char* CompleteString = "FooBarBarFoo"; - char ReadBuffer[64]; - int ret; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - /* Open the file that we'll be working with */ - - TheFile = fopen("TestFile", "w+"); - - if(TheFile == NULL) - { - Fail("ERROR: fopen failed to open the file 'TestFile' in read/write " - "mode.\n"); - } - - /* Call fputs twice to write two strings to the file stream */ - - if(fputs(StringOne, TheFile) < 0) - { - Fail("ERROR: fputs returned a negative value when attempting to " - "put the string '%s' to the file.\n",StringOne); - } - - if(fputs(StringTwo, TheFile) < 0) - { - Fail("ERROR: fputs returned a negative value when attempting to " - "put the string '%s' to the file.\n",StringTwo); - } - - /* Flush the buffers */ - if(fflush(TheFile) != 0) - { - Fail("ERROR: fflush failed to properly flush the buffers.\n"); - } - - /* Now read from the file to ensure the data was written correctly. - Note: We read more than what was written to make sure nothing extra - was written. - */ - - if(fseek(TheFile, 0, SEEK_SET) != 0) - { - Fail("ERROR: fseek failed to set the file pointer back to the start " - "of the file.\n"); - } - - - if((ret = fread(ReadBuffer, 1, 20, TheFile)) != 12) - { - Fail("ERROR: fread should have returned that it read in 12 characters " - "from the file, but instead it returned %d.\n", ret); - } - - ReadBuffer[ret] = '\0'; - - if(strcmp(ReadBuffer, CompleteString) != 0) - { - Fail("ERROR: The data read back from the file is not exactly the same " - "as the data that was written by fputs. The file contains '%s' " - "instead of '%s'.\n",ReadBuffer, CompleteString); - } - - if(fclose(TheFile) != 0) - { - Fail("ERROR: fclose failed to close the file stream.\n"); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/fputs/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/fputs/test1/testinfo.dat deleted file mode 100644 index bdef09c60..000000000 --- a/src/pal/tests/palsuite/c_runtime/fputs/test1/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = fputs -Name = Check that fputs writes correctly to a valid stream -TYPE = DEFAULT -EXE1 = test1 -Description -= Call fputs twice and write two strings to a file. Then -= call fread on the file and check that the data which was written is what -= we expect it to be. diff --git a/src/pal/tests/palsuite/c_runtime/fputs/test2/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/fputs/test2/CMakeLists.txt deleted file mode 100644 index 074500bb2..000000000 --- a/src/pal/tests/palsuite/c_runtime/fputs/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test2.cpp -) - -add_executable(paltest_fputs_test2 - ${SOURCES} -) - -add_dependencies(paltest_fputs_test2 coreclrpal) - -target_link_libraries(paltest_fputs_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/fputs/test2/test2.cpp b/src/pal/tests/palsuite/c_runtime/fputs/test2/test2.cpp deleted file mode 100644 index b8e2f410b..000000000 --- a/src/pal/tests/palsuite/c_runtime/fputs/test2/test2.cpp +++ /dev/null @@ -1,88 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test2.c -** -** Purpose: Check to see that fputs fails and returns EOF when called on -** a closed file stream and a read-only file stream. -** - -** -**===================================================================*/ - -#include - -int __cdecl main(int argc, char **argv) -{ - - FILE* TheFile; - char* StringOne = "FooBar"; - int ret; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - /* Create a file with read/write access */ - - TheFile = fopen("TestFile", "w+"); - - if(TheFile == NULL) - { - Fail("ERROR: fopen failed to open the file 'TestFile' in read/write " - "mode.\n"); - } - - /* Then close that file we just opened */ - - if(fclose(TheFile) != 0) - { - Fail("ERROR: fclose failed to close the file.\n"); - } - - /* Check that calling fputs on this closed file stream fails. */ - - if((ret = fputs(StringOne, TheFile)) >= 0) - { - Fail("ERROR: fputs should have failed to write to a closed " - "file stream, but it didn't return a negative value.\n"); - } - - if(ret != EOF) - { - Fail("ERROR: fputs should have returned EOF on an error, but instead " - "returned %d.\n",ret); - } - - /* Open a file as Readonly */ - - TheFile = fopen("TestFile", "r"); - - if(TheFile == NULL) - { - Fail("ERROR: fopen failed to open the file 'TestFile' in read/write " - "mode.\n"); - } - - /* Check that fputs fails when trying to write to a read-only stream */ - - if((ret = fputs(StringOne, TheFile)) >= 0) - { - Fail("ERROR: fputs should have failed to write to a read-only " - "file stream, but it didn't return a negative value.\n"); - } - - if(ret != EOF) - { - Fail("ERROR: fputs should have returned EOF when writing to a " - "read-only filestream, but instead " - "returned %d.\n",ret); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/fputs/test2/testinfo.dat b/src/pal/tests/palsuite/c_runtime/fputs/test2/testinfo.dat deleted file mode 100644 index 0e2abbdc3..000000000 --- a/src/pal/tests/palsuite/c_runtime/fputs/test2/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = fputs -Name = Check that fputs returns EOF when called on closed/readonly streams -TYPE = DEFAULT -EXE1 = test2 -Description -= Check to see that fputs fails and returns EOF when called on -= a closed file stream and a read-only file stream. diff --git a/src/pal/tests/palsuite/c_runtime/fread/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/fread/CMakeLists.txt deleted file mode 100644 index 1962ade35..000000000 --- a/src/pal/tests/palsuite/c_runtime/fread/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) -add_subdirectory(test3) - diff --git a/src/pal/tests/palsuite/c_runtime/fread/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/fread/test1/CMakeLists.txt deleted file mode 100644 index 71204c079..000000000 --- a/src/pal/tests/palsuite/c_runtime/fread/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_fread_test1 - ${SOURCES} -) - -add_dependencies(paltest_fread_test1 coreclrpal) - -target_link_libraries(paltest_fread_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/fread/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/fread/test1/test1.cpp deleted file mode 100644 index b706b2e91..000000000 --- a/src/pal/tests/palsuite/c_runtime/fread/test1/test1.cpp +++ /dev/null @@ -1,135 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test1.c -** -** Purpose: Tests the PAL implementation of the fread function. -** Open a file in READ mode, and then try to read all -** the characters, more than all the characters, -** 0 characters and 0 sized characters and check that -** the return values are correct. -** -** Depends: -** fopen -** fseek -** fclose -** -** -**===================================================================*/ - -/* Note: testfile should exist in the directory with 15 characters - in it ... something got lost if it isn't here. -*/ - -/* Note: Under win32, fread() crashes when passed NULL. The test to ensure that - it returns 0 has been removed to reflect this. -*/ - -#include - -int __cdecl main(int argc, char **argv) -{ - const char filename[] = "testfile"; - char buffer[128]; - FILE * fp = NULL; - int result; - - if (0 != PAL_Initialize(argc, argv)) - { - return FAIL; - } - - /* Open a file in READ mode */ - - if((fp = fopen(filename, "r")) == NULL) - { - Fail("Unable to open a file for reading. Is the file " - "in the directory? It should be."); - } - - /* Read 15 characters from the file. The file has exactly this many - in it. - */ - if((result = fread(buffer,1,15,fp)) == 0) - { - Fail("ERROR: Zero characters read from the file. It should have " - "15 characters in it."); - } - - if(result != 15) - { - Fail("ERROR: The fread function should have returned that it read " - "in 15 characters from the file. But it indicates having " - "read %i characters.",result); - } - - /* Go back to the start of the file */ - - if(fseek(fp, 0, SEEK_SET)) - { - Fail("ERROR: fseek failed, and this test depends on it."); - } - - /* Attempt to read 17 characters, the return should still be 15 */ - - if((result = fread(buffer,1,17,fp)) == 0) - { - Fail("ERROR: Zero characters read from the file. It should have " - "15 characters in it. Though, it attempted to read 17."); - } - - if(result != 15) - { - Fail("ERROR: The fread function should have returned that it read " - "in 15 characters from the file. " - "But it indicates having read %i characters.",result); - } - - /* Back to the start of the file */ - - if(fseek(fp, 0, SEEK_SET)) - { - Fail("ERROR: fseek failed, and this test depends on it."); - } - - /* Read 0 characters and ensure the function returns 0 */ - - if((result = fread(buffer,1,0,fp)) != 0) - { - Fail("ERROR: The return value should be 0, as we attempted to " - "read 0 characters."); - } - - /* Read characters of 0 size and ensure the return value is 0 */ - - if((result = fread(buffer,0,5,fp)) != 0) - { - Fail("ERROR: The return value should be 0, as we attempted to " - "read 0 sized data."); - } - - /* Close the file */ - - if(fclose(fp)) - { - Fail("ERROR: fclose failed. Test depends on it."); - } - - /* Read 5 characters of 1 size from a closed file pointer - and ensure the return value is 0 - */ - - if((result = fread(buffer,1,5,fp)) != 0) - { - Fail("ERROR: The return value should be 0, as we attempted to " - "read data from a closed file pointer."); - } - - PAL_Terminate(); - return PASS; -} - - diff --git a/src/pal/tests/palsuite/c_runtime/fread/test1/testfile b/src/pal/tests/palsuite/c_runtime/fread/test1/testfile deleted file mode 100644 index 273c1a9ff..000000000 --- a/src/pal/tests/palsuite/c_runtime/fread/test1/testfile +++ /dev/null @@ -1 +0,0 @@ -This is a test. \ No newline at end of file diff --git a/src/pal/tests/palsuite/c_runtime/fread/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/fread/test1/testinfo.dat deleted file mode 100644 index 0f8b86061..000000000 --- a/src/pal/tests/palsuite/c_runtime/fread/test1/testinfo.dat +++ /dev/null @@ -1,15 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = fread -Name = Positive Test for fread -TYPE = DEFAULT -EXE1 = test1 -Description -= Tests the PAL implementation of the fread function. -= Open a file in READ mode, and then try to read all the characters, -= more than all the characters, 0 characters and 0 sized characters and -= check that the return values are correct. diff --git a/src/pal/tests/palsuite/c_runtime/fread/test2/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/fread/test2/CMakeLists.txt deleted file mode 100644 index 1bae93e43..000000000 --- a/src/pal/tests/palsuite/c_runtime/fread/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test2.cpp -) - -add_executable(paltest_fread_test2 - ${SOURCES} -) - -add_dependencies(paltest_fread_test2 coreclrpal) - -target_link_libraries(paltest_fread_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/fread/test2/test2.cpp b/src/pal/tests/palsuite/c_runtime/fread/test2/test2.cpp deleted file mode 100644 index d7262a932..000000000 --- a/src/pal/tests/palsuite/c_runtime/fread/test2/test2.cpp +++ /dev/null @@ -1,143 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test2.c -** -** Purpose: Tests the PAL implementation of the fread function. -** Open a file in READ mode, and then try to read all -** the characters, more than all the characters, -** 0 characters and 0 sized characters and check that -** the strings read in are correct. -** -** Depends: -** fopen -** fseek -** fclose -** strcmp -** memset -** -** -**===================================================================*/ - -/* Note: testfile should exist in the directory with 15 characters - in it ... something got lost if it isn't here. -*/ - -/* Note: The behaviour in win32 is to crash if a NULL pointer is passed to - fread, so the test to check that it returns 0 has been removed. -*/ - -#include - -int __cdecl main(int argc, char **argv) -{ - const char filename[] = "testfile"; - char buffer[128]; - FILE * fp = NULL; - - if (0 != PAL_Initialize(argc, argv)) - { - return FAIL; - } - - /* Open a file in READ mode */ - - if((fp = fopen(filename, "r")) == NULL) - { - Fail("Unable to open a file for reading. Is the file " - "in the directory? It should be."); - } - - /* Read 15 characters from the file. The file has exactly this many - in it. Then check to see that the data read in is correct. - Note: The 'testfile' should have "This is a test." written in it. - */ - memset(buffer,'\0',128); - fread(buffer,1,15,fp); - - if(strcmp(buffer,"This is a test.") != 0) - { - Fail("ERROR: The data read in should have been " - "'This is a test.' but, the buffer contains '%s'.", - buffer); - } - - /* Go back to the start of the file */ - - if(fseek(fp, 0, SEEK_SET)) - { - Fail("ERROR: fseek failed, and this test depends on it."); - } - - /* Attempt to read 17 characters. The same 15 characters should - be in the buffer. - */ - - memset(buffer,'\0',128); - fread(buffer,1,17,fp); - - if(strcmp(buffer,"This is a test.") != 0) - { - Fail("ERROR: The data read in should have been " - "'This is a test.' but, the buffer contains '%s'.", - buffer); - } - - /* Back to the start of the file */ - - if(fseek(fp, 0, SEEK_SET)) - { - Fail("ERROR: fseek failed, and this test depends on it."); - } - - /* Read 0 characters and ensure the buffer is empty */ - - memset(buffer,'\0',128); - fread(buffer,1,0,fp); - - if(strcmp(buffer,"\0") != 0) - { - Fail("ERROR: The data read in should have been " - "NULL but, the buffer contains '%s'.", - buffer); - } - - /* Read characters of 0 size and ensure the buffer is empty */ - - memset(buffer,'\0',128); - fread(buffer,0,5,fp); - - if(strcmp(buffer,"\0") != 0) - { - Fail("ERROR: The data read in should have been " - "NULL but, the buffer contains '%s'.", - buffer); - } - - /* Close the file */ - - if(fclose(fp)) - { - Fail("ERROR: fclose failed. Test depends on it."); - } - - /* Read 5 characters of 1 size from a closed file pointer - and ensure the buffer is empty - */ - memset(buffer,'\0',128); - fread(buffer,1,5,fp); - if(strcmp(buffer,"\0") != 0) - { - Fail("ERROR: The data read in should have been " - "NULL but, the buffer contains '%s'.", - buffer); - } - - PAL_Terminate(); - return PASS; -} - - diff --git a/src/pal/tests/palsuite/c_runtime/fread/test2/testfile b/src/pal/tests/palsuite/c_runtime/fread/test2/testfile deleted file mode 100644 index 273c1a9ff..000000000 --- a/src/pal/tests/palsuite/c_runtime/fread/test2/testfile +++ /dev/null @@ -1 +0,0 @@ -This is a test. \ No newline at end of file diff --git a/src/pal/tests/palsuite/c_runtime/fread/test2/testinfo.dat b/src/pal/tests/palsuite/c_runtime/fread/test2/testinfo.dat deleted file mode 100644 index a73c0ecf9..000000000 --- a/src/pal/tests/palsuite/c_runtime/fread/test2/testinfo.dat +++ /dev/null @@ -1,16 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = fread -Name = Positive Test for fread -TYPE = DEFAULT -EXE1 = test2 -Description -= Tests the PAL implementation of the fread function. -= Open a file in READ mode, and then try to read all -= the characters, more than all the characters, -= 0 characters and 0 sized characters and check that -= the strings read in are correct. diff --git a/src/pal/tests/palsuite/c_runtime/fread/test3/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/fread/test3/CMakeLists.txt deleted file mode 100644 index a678e2e11..000000000 --- a/src/pal/tests/palsuite/c_runtime/fread/test3/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test3.cpp -) - -add_executable(paltest_fread_test3 - ${SOURCES} -) - -add_dependencies(paltest_fread_test3 coreclrpal) - -target_link_libraries(paltest_fread_test3 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/fread/test3/test3.cpp b/src/pal/tests/palsuite/c_runtime/fread/test3/test3.cpp deleted file mode 100644 index 8c79bee58..000000000 --- a/src/pal/tests/palsuite/c_runtime/fread/test3/test3.cpp +++ /dev/null @@ -1,131 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test3.c -** -** Purpose: Tests the PAL implementation of the fread function. -** Open a file in READ mode, then try to read from the file with -** different 'size' params. Check to ensure the return values and -** the text in the buffer is correct. -** -** Depends: -** fopen -** fseek -** strcmp -** memset -** -** -**===================================================================*/ - -/* Note: testfile should exist in the directory with 15 characters - in it ... something got lost if it isn't here. -*/ - -#include - -int __cdecl main(int argc, char **argv) -{ - const char filename[] = "testfile"; - char buffer[128]; - FILE * fp = NULL; - int result; - - if (0 != PAL_Initialize(argc, argv)) - { - return FAIL; - } - - /* Open a file in READ mode */ - - if((fp = fopen(filename, "r")) == NULL) - { - Fail("Unable to open a file for reading. Is the file " - "in the directory? It should be."); - } - - memset(buffer,'x',128); - - /* Put the null one character past the end of the text that was read - in, to ensure that it wasn't reading in 0 - */ - - buffer[16] = '\0'; - - /* Attempt to read in 5 bytes at a time. This should return 3 and - contain the full string in the buffer. - */ - - if((result = fread(buffer,5,3,fp)) != 3) - { - Fail("ERROR: Attempted to read in data of size 5. The file has " - "15 bytes in it so 3 items should have been read. But the value " - "returned was %d.",result); - } - - if(strcmp(buffer, "This is a test.x") != 0) - { - Fail("ERROR: The buffer should have contained the text " - "'This is a test.x' but instead contained '%s'.",buffer); - } - - memset(buffer,'x',128); - - if(fseek(fp, 0, SEEK_SET)) - { - Fail("ERROR: fseek failed, and this test depends on it."); - } - - buffer[16] = '\0'; - - /* Attempt to read in 6 bytes at a time. The return should be 2. The - full string should still be in the buffer. - */ - - if((result = fread(buffer,6,3,fp)) != 2) - { - Fail("ERROR: Attempted to read in data of size 6. The file has " - "15 bytes in it, so 2 items should have been read. But the " - "value returned was %d.",result); - } - - if(strcmp(buffer, "This is a test.x") != 0) - { - Fail("ERROR: The buffer should have contained the text " - "'This is a test.x' but instead contained '%s'.",buffer); - } - - memset(buffer,'x',128); - - buffer[7] = '\0'; - - if(fseek(fp, 0, SEEK_SET)) - { - Fail("ERROR: fseek failed, and this test depends on it."); - } - - /* Attempt to read in 6 bytes at a time but only one item max. - The return should be 1. The first 6 characters should be in the - buffer. - */ - - if((result = fread(buffer,6,1,fp)) != 1) - { - Fail("ERROR: Attempted to read in data of size 6 with a max count " - "of 1. Thus, one item should have been read, but the " - "value returned was %d.",result); - } - - if(strcmp(buffer, "This ix") != 0) - { - Fail("ERROR: The buffer should have contained the text " - "'This ix.' but instead contained '%s'.",buffer); - } - - PAL_Terminate(); - return PASS; -} - - diff --git a/src/pal/tests/palsuite/c_runtime/fread/test3/testfile b/src/pal/tests/palsuite/c_runtime/fread/test3/testfile deleted file mode 100644 index 273c1a9ff..000000000 --- a/src/pal/tests/palsuite/c_runtime/fread/test3/testfile +++ /dev/null @@ -1 +0,0 @@ -This is a test. \ No newline at end of file diff --git a/src/pal/tests/palsuite/c_runtime/fread/test3/testinfo.dat b/src/pal/tests/palsuite/c_runtime/fread/test3/testinfo.dat deleted file mode 100644 index 95bc30ebc..000000000 --- a/src/pal/tests/palsuite/c_runtime/fread/test3/testinfo.dat +++ /dev/null @@ -1,15 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = fread -Name = Positive Test for fread -TYPE = DEFAULT -EXE1 = test3 -Description -= Tests the PAL implementation of the fread function. -= Open a file in READ mode, then try to read from the file with -= different 'size' params. Check to ensure the return values and -= the text in the buffer is correct diff --git a/src/pal/tests/palsuite/c_runtime/free/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/free/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/c_runtime/free/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/c_runtime/free/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/free/test1/CMakeLists.txt deleted file mode 100644 index 66c0b568d..000000000 --- a/src/pal/tests/palsuite/c_runtime/free/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_free_test1 - ${SOURCES} -) - -add_dependencies(paltest_free_test1 coreclrpal) - -target_link_libraries(paltest_free_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/free/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/free/test1/test1.cpp deleted file mode 100644 index 4ff8dfb09..000000000 --- a/src/pal/tests/palsuite/c_runtime/free/test1/test1.cpp +++ /dev/null @@ -1,62 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: Repeatedly allocates and frees a chunk of memory, to verify -** that free is really returning memory to the heap -** -** -**==========================================================================*/ - -#include - -int __cdecl main(int argc, char **argv) -{ - - char *testA; - - long i; - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - /* check that free really returns memory to the heap. */ - for(i=1; i<1000000; i++) - { - testA = (char *)malloc(1000*sizeof(char)); - if (testA==NULL) - { - Fail("Either free is failing to return memory to the heap, or" - " the system is running out of memory for some other " - "reason.\n"); - } - free(testA); - } - - free(NULL); /*should do nothing*/ - PAL_Terminate(); - return PASS; -} - - - - - - - - - - - - - - - - - diff --git a/src/pal/tests/palsuite/c_runtime/free/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/free/test1/testinfo.dat deleted file mode 100644 index 5bf400ce2..000000000 --- a/src/pal/tests/palsuite/c_runtime/free/test1/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = free -Name = Positive Test for free -TYPE = DEFAULT -EXE1 = test1 -Description -= Repeatedly allocates and frees a chunk of memory, to verify that free -= is really returning memory to the heap - diff --git a/src/pal/tests/palsuite/c_runtime/fseek/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/fseek/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/c_runtime/fseek/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/c_runtime/fseek/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/fseek/test1/CMakeLists.txt deleted file mode 100644 index 906a935f1..000000000 --- a/src/pal/tests/palsuite/c_runtime/fseek/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_fseek_test1 - ${SOURCES} -) - -add_dependencies(paltest_fseek_test1 coreclrpal) - -target_link_libraries(paltest_fseek_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/fseek/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/fseek/test1/test1.cpp deleted file mode 100644 index dd1e87ea8..000000000 --- a/src/pal/tests/palsuite/c_runtime/fseek/test1/test1.cpp +++ /dev/null @@ -1,193 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: Call fseek to move a file pointer to the start of a file, -** a position offset from the start, a position offset from the -** current position, and a position offset from the end of the -** file. Check that the file pointer is at the correct position -** after each seek. -** -** -**==========================================================================*/ - -#include - -const char filename[] = "testfile.txt"; - -static BOOL Cleanup(HANDLE hFile) -{ - BOOL result= TRUE; - - if (fclose((PAL_FILE*)hFile)) - { - Trace("fseek: ERROR -> Unable to close file \"%s\".\n", - filename); - result= FALSE; - } - if (!DeleteFileA(filename)) - { - result= FALSE; - Trace("fseek: ERROR -> Unable to delete file \"%s\". ", - "GetLastError returned %u.\n", - filename, - GetLastError()); - } - return result; -} - -int __cdecl main(int argc, char **argv) -{ - char outBuf[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - char inBuf[20]; - FILE * fp; - int size = ( sizeof(outBuf)/sizeof(char) ) - 1; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - /*create the file*/ - fp = fopen(filename, "w"); - if (fp == NULL) - { - Fail("Unable to open a file for write.\n"); - } - if(fprintf(fp, outBuf) != size) - { - Trace("Unable to write to %s.\n", filename); - Cleanup(fp); - Fail(""); - } - - if (fclose(fp) != 0) - { - Trace("Unable to close newly written file.\n"); - if (!DeleteFileA(filename)) - { - Trace("fseek: ERROR -> Unable to delete file \"%s\". ", - "GetLastError returned %u.\n", - filename, - GetLastError()); - } - Fail(""); - } - - fp = fopen(filename, "r"); - if (fp == NULL) - { - if (!DeleteFileA(filename)) - { - Trace("_putw: ERROR -> Unable to delete file \"%s\". ", - "GetLastError returned %u.\n", - filename, - GetLastError()); - } - Fail("Unable to open a file for read.\n"); - } - - /*seek to the start*/ - if (fseek(fp, 0, SEEK_SET) != 0) - { - Cleanup(fp); - Fail("fseek failed when seeking the start of a file.\n"); - } - if (fgets(inBuf, 11, fp) != inBuf) - { - Cleanup(fp); - Fail("Unable to read from file after using fseek to move to the start.\n"); - } - if (strncmp(inBuf, outBuf, 10) != 0) - { - Cleanup(fp); - Fail("fseek was asked to seek the start of a file," - "but didn't get there.\n"); - } - - /*Seek with an offset from the start*/ - - if (fseek(fp, 10, SEEK_SET) != 0) - { - Cleanup(fp); - Fail("fseek failed when called with SEEK_SET and a positive offset.\n"); - } - - if (fgets(inBuf, 6, fp) != inBuf) - { - Cleanup(fp); - Fail("fgets failed after feek was called with SEEK_SET" - "and a positive offset.\n"); - } - - - if (strncmp(inBuf, "ABCDE", 5) != 0) - { - Cleanup(fp); - Fail("fseek did not move to the correct position when passed SEEK_SET" - " and a positive offset.\n"); - } - - /*now move backwards and read the same string*/ - if (fseek(fp, -5, SEEK_CUR) != 0) - { - Cleanup(fp); - Fail("fseek failed when passed SEEK_CUR and a negative offset.\n"); - } - - if (fgets(inBuf, 6, fp) != inBuf) - { - Cleanup(fp); - Fail("fgets failed after fseek was called with SEEK_CUR and a " - "negative offset.\n"); - } - - if (strncmp(inBuf, "ABCDE", 5) != 0) - { - Cleanup(fp); - Fail("fseek did not move to the correct position when called with" - " SEEK_CUR and a negative offset.\n"); - } - - /*Try seeking relative to the end of the file.*/ - if (fseek(fp, -10, SEEK_END) != 0) - { - Cleanup(fp); - Fail("fseek failed when called with SEEK_END and a negative" - " offset.\n"); - } - if (fgets(inBuf, 2, fp) != inBuf) - { - Cleanup(fp); - Fail("fgets failed after fseek was called with SEEK_END and a " - "negative offset\n"); - } - - if (strncmp(inBuf, "Q", 1) != 0) - { - Cleanup(fp); - Fail("fseek did not move to the correct position when called with " - "SEEK_END and a negative offset.\n"); - } - - - /*close the file*/ - if(!Cleanup(fp)) - { - Fail(""); - } - - PAL_Terminate(); - return PASS; -} - - - - - - diff --git a/src/pal/tests/palsuite/c_runtime/fseek/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/fseek/test1/testinfo.dat deleted file mode 100644 index 788f8d4be..000000000 --- a/src/pal/tests/palsuite/c_runtime/fseek/test1/testinfo.dat +++ /dev/null @@ -1,15 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = fseek -Name = Positive Test for fseek -TYPE = DEFAULT -EXE1 = test1 -Description -= Call seek to move a file pointer to the start of a file, a position -= offset from the start, a position offset from the current position, and -= a position offset from the end of the file. Check that the file -= pointer is at the correct position after each seek. diff --git a/src/pal/tests/palsuite/c_runtime/ftell/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/ftell/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/c_runtime/ftell/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/c_runtime/ftell/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/ftell/test1/CMakeLists.txt deleted file mode 100644 index e7900f65a..000000000 --- a/src/pal/tests/palsuite/c_runtime/ftell/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - ftell.cpp -) - -add_executable(paltest_ftell_test1 - ${SOURCES} -) - -add_dependencies(paltest_ftell_test1 coreclrpal) - -target_link_libraries(paltest_ftell_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/ftell/test1/ftell.cpp b/src/pal/tests/palsuite/c_runtime/ftell/test1/ftell.cpp deleted file mode 100644 index 66e085484..000000000 --- a/src/pal/tests/palsuite/c_runtime/ftell/test1/ftell.cpp +++ /dev/null @@ -1,145 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: ftell.c (test 1) -** -** Purpose: Tests the PAL implementation of the ftell function. -** -** -**===================================================================*/ - -#include - -FILE* pFile; -struct TESTS -{ - long lDist; - int nFrom; - long lPosition; -}; - - -/************************************************* -** -** Validate -** -** Purpose: -** Tests whether the move was successful. If -** it passes, it returns TRUE. If it fails -** it outputs some error messages and returns -** FALSE. -** -*************************************************/ -BOOL Validate(long lExpected) -{ - long lPos = -2; - - if (((lPos = ftell(pFile)) == -1) || (lPos != lExpected)) - { - Trace("ftell: ERROR -> ftell returned %ld when expecting %ld.\n", - lPos, - lExpected); - if (fclose(pFile) != 0) - { - Trace("ftell: ERROR -> fclose failed to close the file.\n"); - } - return FALSE; - } - return TRUE; -} - - -/************************************************* -** -** MovePointer -** -** Purpose: -** Accepts the distance to move and the -** distance and calls fseek to move the file -** pointer. If the fseek fails, error messages -** are displayed and FALSE is returned. TRUE -** is returned on a successful fseek. -** -*************************************************/ -BOOL MovePointer(long lDist, int nFrom) -{ - /* move the file pointer*/ - if (fseek(pFile, lDist, nFrom) != 0) - { - Trace("ftell: ERROR -> fseek failed to move the file pointer " - "%l characters.\n", - lDist); - if (fclose(pFile) != 0) - { - Trace("ftell: ERROR -> fclose failed to close the file.\n"); - } - return FALSE; - } - return TRUE; -} - - - -int __cdecl main(int argc, char *argv[]) -{ - const char szFileName[] = {"testfile.txt"}; - long lPos = -1; - int i; - char szTempBuffer[256]; - struct TESTS testCase[] = - { - {0, SEEK_SET, 0}, - {10, SEEK_CUR, 10}, - {-5, SEEK_CUR, 5}, - {-2, SEEK_END, 50} - }; - - - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - memset(szTempBuffer, 0, 256); - - - /* open the test file */ - pFile = fopen(szFileName, "r"); - if (pFile == NULL) - { - Fail("ftell: ERROR -> fopen failed to open the file \"%s\".\n"); - } - - /* loop through the test cases */ - for (i = 0; i < (sizeof(testCase)/sizeof(struct TESTS)); i++) - { - if (MovePointer(testCase[i].lDist, testCase[i].nFrom) != TRUE) - { - Fail(""); - } - else if (Validate(testCase[i].lPosition) != TRUE) - { - Fail(""); - } - } - - if (fclose(pFile) != 0) - { - Fail("ftell: ERROR -> fclose failed to close the file.\n"); - } - - /* lets just see if we can find out where we are in a closed stream... */ - if ((lPos = ftell(pFile)) != -1) - { - Fail("ftell: ERROR -> ftell returned a valid position (%ld) on a " - "closed file handle\n", - lPos); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/ftell/test1/testfile.txt b/src/pal/tests/palsuite/c_runtime/ftell/test1/testfile.txt deleted file mode 100644 index dd0fe15fe..000000000 --- a/src/pal/tests/palsuite/c_runtime/ftell/test1/testfile.txt +++ /dev/null @@ -1 +0,0 @@ -The quick brown fox jumped over the lazy dog's back. \ No newline at end of file diff --git a/src/pal/tests/palsuite/c_runtime/ftell/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/ftell/test1/testinfo.dat deleted file mode 100644 index c17ec9ad9..000000000 --- a/src/pal/tests/palsuite/c_runtime/ftell/test1/testinfo.dat +++ /dev/null @@ -1,16 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = c_runtime -Function = ftell -Name = test for ftell (test 1) -Type = DEFAULT -EXE1 = ftell -Description -= Use fseek and a static list of distances to move, direction -= to move and expected results to test the ftell function. A typical -= test will move the file pointer with fseek then call ftell. The -= results from ftell will then be compared to the expected result to -= determine whether the test passed or failed. diff --git a/src/pal/tests/palsuite/c_runtime/fwprintf/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/fwprintf/CMakeLists.txt deleted file mode 100644 index cafb9536b..000000000 --- a/src/pal/tests/palsuite/c_runtime/fwprintf/CMakeLists.txt +++ /dev/null @@ -1,22 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test10) -add_subdirectory(test11) -add_subdirectory(test12) -add_subdirectory(test13) -add_subdirectory(test14) -add_subdirectory(test15) -add_subdirectory(test16) -add_subdirectory(test17) -add_subdirectory(test18) -add_subdirectory(test19) -add_subdirectory(test2) -add_subdirectory(test3) -add_subdirectory(test4) -add_subdirectory(test5) -add_subdirectory(test6) -add_subdirectory(test7) -add_subdirectory(test8) -add_subdirectory(test9) - diff --git a/src/pal/tests/palsuite/c_runtime/fwprintf/fwprintf.h b/src/pal/tests/palsuite/c_runtime/fwprintf/fwprintf.h deleted file mode 100644 index eed0e7648..000000000 --- a/src/pal/tests/palsuite/c_runtime/fwprintf/fwprintf.h +++ /dev/null @@ -1,453 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: fwprintf.h -** -** Purpose: Containts common testing functions for fwprintf -** -** -**==========================================================================*/ - -#ifndef __fwprintf_H__ -#define __fwprintf_H__ - -void DoStrTest(const WCHAR *formatstr, char* param, const char *checkstr) -{ - FILE *fp; - char buf[256] = { 0 }; - - if ((fp = fopen("testfile.txt", "w+")) == NULL ) - { - Fail("ERROR: fopen failed to create testfile\n"); - } - if ((fwprintf(fp, formatstr, param)) < 0) - { - Fail("ERROR: fwprintf failed\n"); - } - if ((fseek(fp, 0, SEEK_SET)) != 0) - { - Fail("ERROR: fseek failed\n"); - } - if ((fgets(buf, 100, fp)) == NULL) - { - Fail("ERROR: fseek failed\n"); - } - - if (memcmp(buf, checkstr, strlen(checkstr) + 1) != 0) - { - Fail("ERROR: failed to insert string \"%\" into \"%S\"\n" - "Expected \"%s\" got \"%s\".\n", - param, formatstr, checkstr, buf); - } - fclose(fp); -} - -void DoWStrTest(const WCHAR *formatstr, WCHAR* param, const char *checkstr) -{ - FILE *fp; - char buf[256] = { 0 }; - - if ((fp = fopen("testfile.txt", "w+")) == NULL ) - { - Fail("ERROR: fopen failed to create testfile\n"); - } - if ((fwprintf(fp, formatstr, param)) < 0) - { - Fail("ERROR: fwprintf failed\n"); - } - if ((fseek(fp, 0, SEEK_SET)) != 0) - { - Fail("ERROR: fseek failed\n"); - } - if ((fgets(buf, 100, fp)) == NULL) - { - Fail("ERROR: fseek failed\n"); - } - - if (memcmp(buf, checkstr, strlen(checkstr) + 1) != 0) - { - Fail("ERROR: failed to insert wide string \"%s\" into \"%S\"\n" - "Expected \"%s\" got \"%s\".\n", - convertC(param), formatstr, checkstr, buf); - } - fclose(fp); -} - - -void DoPointerTest(const WCHAR *formatstr, void* param, char* paramstr, - const char *checkstr1, const char *checkstr2) -{ - FILE *fp; - char buf[256] = { 0 }; - - if ((fp = fopen("testfile.txt", "w+")) == NULL ) - { - Fail("ERROR: fopen failed to create testfile\n"); - } - - if ((fwprintf(fp, formatstr, param)) < 0) - { - Fail("ERROR: fwprintf failed\n"); - } - - if ((fseek(fp, 0, SEEK_SET)) != 0) - { - Fail("ERROR: fseek failed\n"); - } - - if ((fgets(buf, 100, fp)) == NULL) - { - Fail("ERROR: fseek failed\n"); - } - - if (memcmp(buf, checkstr1, strlen(checkstr1) + 1) != 0 && - memcmp(buf, checkstr2, strlen(checkstr2) + 1) != 0 ) - { - Fail("ERROR: failed to insert %s into \"%s\"\n" - "Expected \"%s\" or \"%s\" got \"%s\".\n", - paramstr, formatstr, checkstr1, checkstr2, buf); - } - - if ((fclose( fp )) != 0) - { - Fail("ERROR: fclose failed to close \"testfile.txt\"\n"); - } -} - - - -void DoCountTest(const WCHAR *formatstr, int param, const char *checkstr) -{ - FILE *fp; - char buf[512] = { 0 }; - int n = -1; - - if ((fp = fopen("testfile.txt", "w+")) == NULL ) - { - Fail("ERROR: fopen failed to create testfile\n"); - } - - if ((fwprintf(fp, formatstr, &n)) < 0) - { - Fail("ERROR: fwprintf failed\n"); - } - - if ((fseek(fp, 0, SEEK_SET)) != 0) - { - Fail("ERROR: fseek failed\n"); - } - - if ((fgets(buf, sizeof(buf), fp)) == NULL) - { - Fail("ERROR: fseek failed\n"); - } - - if (n != param) - { - Fail("ERROR: Expected count parameter to resolve to %d, got %X\n", - param, n); - } - - if (memcmp(buf, checkstr, strlen(checkstr) + 1) != 0) - { - Fail("ERROR: Expected \"%s\" got \"%s\".\n", checkstr, buf); - } - - if ((fclose( fp )) != 0) - { - Fail("ERROR: fclose failed to close \"testfile.txt\"\n"); - } -} - -void DoShortCountTest(const WCHAR *formatstr, int param, const char *checkstr) -{ - FILE *fp; - char buf[512] = { 0 }; - short int n = -1; - - if ((fp = fopen("testfile.txt", "w+")) == NULL ) - { - Fail("ERROR: fopen failed to create testfile\n"); - } - - if ((fwprintf(fp, formatstr, &n)) < 0) - { - Fail("ERROR: fwprintf failed\n"); - } - - if ((fseek(fp, 0, SEEK_SET)) != 0) - { - Fail("ERROR: fseek failed\n"); - } - - if ((fgets(buf, 100, fp)) == NULL) - { - Fail("ERROR: fseek failed\n"); - } - - if (n != param) - { - Fail("ERROR: Expected count parameter to resolve to %d, got %X\n", - param, n); - } - - if (memcmp(buf, checkstr, strlen(checkstr) + 1) != 0) - { - Fail("ERROR: Expected \"%s\" got \"%s\".\n", checkstr, buf); - } - - if ((fclose( fp )) != 0) - { - Fail("ERROR: fclose failed to close \"testfile.txt\"\n"); - } -} - - -void DoCharTest(const WCHAR *formatstr, char param, const char *checkstr) -{ - FILE *fp; - char buf[256] = { 0 }; - - if ((fp = fopen("testfile.txt", "w+")) == NULL ) - { - Fail("ERROR: fopen failed to create testfile\n"); - } - if ((fwprintf(fp, formatstr, param)) < 0) - { - Fail("ERROR: fwprintf failed\n"); - } - if ((fseek(fp, 0, SEEK_SET)) != 0) - { - Fail("ERROR: fseek failed\n"); - } - if ((fgets(buf, 100, fp)) == NULL) - { - Fail("ERROR: fseek failed\n"); - } - - if (memcmp(buf, checkstr, strlen(checkstr) + 1) != 0) - { - Fail("ERROR: failed to insert char \'%c\' (%d) into \"%S\"\n" - "Expected \"%s\" got \"%s\".\n", - param, param, formatstr, checkstr, buf); - } - fclose(fp); -} - -void DoWCharTest(const WCHAR *formatstr, WCHAR param, const char *checkstr) -{ - FILE *fp; - char buf[256] = { 0 }; - - if ((fp = fopen("testfile.txt", "w+")) == NULL ) - { - Fail("ERROR: fopen failed to create testfile\n"); - } - if ((fwprintf(fp, formatstr, param)) < 0) - { - Fail("ERROR: fwprintf failed\n"); - } - if ((fseek(fp, 0, SEEK_SET)) != 0) - { - Fail("ERROR: fseek failed\n"); - } - if ((fgets(buf, 100, fp)) == NULL) - { - Fail("ERROR: fseek failed\n"); - } - - if (memcmp(buf, checkstr, strlen(checkstr) + 1) != 0) - { - Fail("ERROR: failed to insert wide char \'%c\' (%d) into \"%S\"\n" - "Expected \"%s\" got \"%s\".\n", - (char)param, param, formatstr, checkstr, buf); - } - fclose(fp); -} - -void DoNumTest(const WCHAR *formatstr, int value, const char *checkstr) -{ - FILE *fp; - char buf[256] = { 0 }; - - if ((fp = fopen("testfile.txt", "w+")) == NULL ) - { - Fail("ERROR: fopen failed to create testfile\n"); - } - if ((fwprintf(fp, formatstr, value)) < 0) - { - Fail("ERROR: fwprintf failed\n"); - } - if ((fseek(fp, 0, SEEK_SET)) != 0) - { - Fail("ERROR: fseek failed\n"); - } - if ((fgets(buf, 100, fp)) == NULL) - { - Fail("ERROR: fseek failed\n"); - } - - if (memcmp(buf, checkstr, strlen(checkstr) + 1) != 0) - { - Fail("ERROR: failed to insert %#x into \"%S\"\n" - "Expected \"%s\" got \"%s\".\n", - value, formatstr, checkstr, buf); - } - fclose(fp); -} - -void DoI64Test(const WCHAR *formatstr, INT64 value, char *valuestr, const char *checkstr1, - const char *checkstr2) -{ - FILE *fp; - char buf[256] = { 0 }; - - if ((fp = fopen("testfile.txt", "w+")) == NULL ) - { - Fail("ERROR: fopen failed to create testfile\n"); - } - if ((fwprintf(fp, formatstr, value)) < 0) - { - Fail("ERROR: fwprintf failed\n"); - } - if ((fseek(fp, 0, SEEK_SET)) != 0) - { - Fail("ERROR: fseek failed\n"); - } - if ((fgets(buf, 100, fp)) == NULL) - { - Fail("ERROR: fseek failed\n"); - } - - if (memcmp(buf, checkstr1, strlen(checkstr1) + 1) != 0 && - memcmp(buf, checkstr2, strlen(checkstr2) + 1) != 0) - { - Fail("ERROR: failed to insert %s into \"%S\"\n" - "Expected \"%s\" or \"%s\", got \"%s\".\n", - valuestr, formatstr, checkstr1, checkstr2, buf); - } - fclose(fp); -} - -void DoDoubleTest(const WCHAR *formatstr, double value, const char *checkstr1, - const char *checkstr2) -{ - FILE *fp; - char buf[256] = { 0 }; - - if ((fp = fopen("testfile.txt", "w+")) == NULL ) - { - Fail("ERROR: fopen failed to create testfile\n"); - } - - if ((fwprintf(fp, formatstr, value)) < 0) - { - Fail("ERROR: fwprintf failed\n"); - } - if ((fseek(fp, 0, SEEK_SET)) != 0) - { - Fail("ERROR: fseek failed\n"); - } - if ((fgets(buf, 100, fp)) == NULL) - { - Fail("ERROR: fseek failed\n"); - } - - if (memcmp(buf, checkstr1, strlen(checkstr1) + 1) != 0 && - memcmp(buf, checkstr2, strlen(checkstr2) + 1) != 0) - { - Fail("ERROR: failed to insert %f into \"%S\"\n" - "Expected \"%s\" or \"%s\", got \"%s\".\n", - value, formatstr, checkstr1, checkstr2, buf); - } - fclose(fp); -} - - -void DoArgumentPrecTest(const WCHAR *formatstr, int precision, void *param, - char *paramstr, const char *checkstr1, const char *checkstr2) -{ - FILE *fp; - char buf[256]; - - if ((fp = fopen("testfile.txt", "w+")) == NULL ) - { - Fail("ERROR: fopen failed to create testfile\n"); - } - - if ((fwprintf(fp, formatstr, precision, param)) < 0) - { - Fail("ERROR: fwprintf failed\n"); - } - - if ((fseek(fp, 0, SEEK_SET)) != 0) - { - Fail("ERROR: fseek failed\n"); - } - - if ((fgets(buf, 100, fp)) == NULL) - { - Fail("ERROR: fseek failed\n"); - } - - if (memcmp(buf, checkstr1, strlen(checkstr1) + 1) != 0 && - memcmp(buf, checkstr2, strlen(checkstr2) + 1) != 0) - { - Fail("ERROR: failed to insert %s into \"%s\" with precision %d\n" - "Expected \"%s\" or \"%s\", got \"%s\".\n", paramstr, formatstr, - precision, checkstr1, checkstr2, buf); - } - - - if ((fclose( fp )) != 0) - { - Fail("ERROR: fclose failed to close \"testfile.txt\"\n"); - } - -} - -void DoArgumentPrecDoubleTest(const WCHAR *formatstr, int precision, double param, - const char *checkstr1, const char *checkstr2) -{ - FILE *fp; - char buf[256]; - - if ((fp = fopen("testfile.txt", "w+")) == NULL ) - { - Fail("ERROR: fopen failed to create testfile\n"); - } - - if ((fwprintf(fp, formatstr, precision, param)) < 0) - { - Fail("ERROR: fwprintf failed\n"); - } - - if ((fseek(fp, 0, SEEK_SET)) != 0) - { - Fail("ERROR: fseek failed\n"); - } - - if ((fgets(buf, 100, fp)) == NULL) - { - Fail("ERROR: fseek failed\n"); - } - - if (memcmp(buf, checkstr1, strlen(checkstr1) + 1) != 0 && - memcmp(buf, checkstr2, strlen(checkstr2) + 1) != 0) - { - Fail("ERROR: failed to insert %f into \"%s\" with precision %d\n" - "Expected \"%s\" or \"%s\", got \"%s\".\n", param, formatstr, - precision, checkstr1, checkstr2, buf); - } - - if ((fclose( fp )) != 0) - { - Fail("ERROR: fclose failed to close \"testfile.txt\"\n"); - } - -} - -#endif diff --git a/src/pal/tests/palsuite/c_runtime/fwprintf/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/fwprintf/test1/CMakeLists.txt deleted file mode 100644 index 4c5835667..000000000 --- a/src/pal/tests/palsuite/c_runtime/fwprintf/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_fwprintf_test1 - ${SOURCES} -) - -add_dependencies(paltest_fwprintf_test1 coreclrpal) - -target_link_libraries(paltest_fwprintf_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/fwprintf/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/fwprintf/test1/test1.cpp deleted file mode 100644 index 8a171db52..000000000 --- a/src/pal/tests/palsuite/c_runtime/fwprintf/test1/test1.cpp +++ /dev/null @@ -1,71 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: A single, basic, test case with no formatting. -** Test modeled after the sprintf series. -** - -** -**==========================================================================*/ - -#include - -/* - * Depends on memcmp, strlen, fopen, fgets, fseek and fclose. - */ - -int __cdecl main(int argc, char *argv[]) -{ - FILE *fp; - char testfile[] = "testfile.txt"; - - WCHAR *outstr; - char checkstr[] = "hello world"; - char buf[256]; - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - outstr = convert(checkstr); - if ((fp = fopen(testfile, "w+")) == NULL) - { - Fail("ERROR: fopen failed to create \"%s\"\n", testfile); - } - - if ((fwprintf(fp, outstr)) < 0) - { - Fail("ERROR: fwprintf failed to print to \"%s\"\n", testfile); - } - - if ((fseek( fp, 0, SEEK_SET)) != 0) - { - Fail("ERROR: Fseek failed to set pointer to beginning of file\n" ); - } - - - if ((fgets( buf, 100, fp )) == NULL) - { - Fail("ERROR: fgets failed\n"); - } - - if (memcmp(checkstr, buf, strlen(checkstr)+1) != 0) - { - Fail("ERROR: expected %s, got %s\n", checkstr, buf); - } - - - if ((fclose( fp )) != 0) - { - Fail("ERROR: fclose failed to close \"%s\"\n", testfile); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/fwprintf/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/fwprintf/test1/testinfo.dat deleted file mode 100644 index 3bef5c638..000000000 --- a/src/pal/tests/palsuite/c_runtime/fwprintf/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = fwprintf -Name = Positive Test for fwprintf -TYPE = DEFAULT -EXE1 = test1 -Description -= A single, basic, test case with no formatting. -= Test modeled after the sprintf series. diff --git a/src/pal/tests/palsuite/c_runtime/fwprintf/test10/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/fwprintf/test10/CMakeLists.txt deleted file mode 100644 index 994cd5e27..000000000 --- a/src/pal/tests/palsuite/c_runtime/fwprintf/test10/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test10.cpp -) - -add_executable(paltest_fwprintf_test10 - ${SOURCES} -) - -add_dependencies(paltest_fwprintf_test10 coreclrpal) - -target_link_libraries(paltest_fwprintf_test10 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/fwprintf/test10/test10.cpp b/src/pal/tests/palsuite/c_runtime/fwprintf/test10/test10.cpp deleted file mode 100644 index 3aa2c45c7..000000000 --- a/src/pal/tests/palsuite/c_runtime/fwprintf/test10/test10.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test10.c -** -** Purpose: Tests the octal specifier (%o). -** This test is modeled after the sprintf series. -** -** -**==========================================================================*/ - -#include -#include "../fwprintf.h" - -/* - * Depends on memcmp, strlen, fopen, fseek and fgets. - */ - -int __cdecl main(int argc, char *argv[]) -{ - int neg = -42; - int pos = 42; - INT64 l = 42; - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoNumTest(convert("foo %o"), pos, "foo 52"); - DoNumTest(convert("foo %lo"), 0xFFFF, "foo 177777"); - DoNumTest(convert("foo %ho"), 0xFFFF, "foo 177777"); - DoNumTest(convert("foo %Lo"), pos, "foo 52"); - DoI64Test(convert("foo %I64o"), l, "42", "foo 52", "foo 52"); - DoNumTest(convert("foo %3o"), pos, "foo 52"); - DoNumTest(convert("foo %-3o"), pos, "foo 52 "); - DoNumTest(convert("foo %.1o"), pos, "foo 52"); - DoNumTest(convert("foo %.3o"), pos, "foo 052"); - DoNumTest(convert("foo %03o"), pos, "foo 052"); - DoNumTest(convert("foo %#o"), pos, "foo 052"); - DoNumTest(convert("foo %+o"), pos, "foo 52"); - DoNumTest(convert("foo % o"), pos, "foo 52"); - DoNumTest(convert("foo %+o"), neg, "foo 37777777726"); - DoNumTest(convert("foo % o"), neg, "foo 37777777726"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/fwprintf/test10/testinfo.dat b/src/pal/tests/palsuite/c_runtime/fwprintf/test10/testinfo.dat deleted file mode 100644 index 17902cb7f..000000000 --- a/src/pal/tests/palsuite/c_runtime/fwprintf/test10/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = fwprintf -Name = Positive Test for fwprintf -TYPE = DEFAULT -EXE1 = test10 -Description -= Tests the octal specifier (%o). -= This test is modeled after the sprintf series. diff --git a/src/pal/tests/palsuite/c_runtime/fwprintf/test11/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/fwprintf/test11/CMakeLists.txt deleted file mode 100644 index a2bc58527..000000000 --- a/src/pal/tests/palsuite/c_runtime/fwprintf/test11/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test11.cpp -) - -add_executable(paltest_fwprintf_test11 - ${SOURCES} -) - -add_dependencies(paltest_fwprintf_test11 coreclrpal) - -target_link_libraries(paltest_fwprintf_test11 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/fwprintf/test11/test11.cpp b/src/pal/tests/palsuite/c_runtime/fwprintf/test11/test11.cpp deleted file mode 100644 index 5867cd64f..000000000 --- a/src/pal/tests/palsuite/c_runtime/fwprintf/test11/test11.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test11.c -** -** Purpose: Test the unsigned int specifier (%u). -** This test is modeled after the sprintf series. -** -** -**==========================================================================*/ - -#include -#include "../fwprintf.h" - -/* - * Depends on memcmp, strlen, fopen, fseek and fgets. - */ - -int __cdecl main(int argc, char *argv[]) -{ - int neg = -42; - int pos = 42; - INT64 l = 42; - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoNumTest(convert("foo %u"), pos, "foo 42"); - DoNumTest(convert("foo %lu"), 0xFFFF, "foo 65535"); - DoNumTest(convert("foo %hu"), 0xFFFF, "foo 65535"); - DoNumTest(convert("foo %Lu"), pos, "foo 42"); - DoI64Test(convert("foo %I64u"), l, "42", "foo 42", "foo 42"); - DoNumTest(convert("foo %3u"), pos, "foo 42"); - DoNumTest(convert("foo %-3u"), pos, "foo 42 "); - DoNumTest(convert("foo %.1u"), pos, "foo 42"); - DoNumTest(convert("foo %.3u"), pos, "foo 042"); - DoNumTest(convert("foo %03u"), pos, "foo 042"); - DoNumTest(convert("foo %#u"), pos, "foo 42"); - DoNumTest(convert("foo %+u"), pos, "foo 42"); - DoNumTest(convert("foo % u"), pos, "foo 42"); - DoNumTest(convert("foo %+u"), neg, "foo 4294967254"); - DoNumTest(convert("foo % u"), neg, "foo 4294967254"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/fwprintf/test11/testinfo.dat b/src/pal/tests/palsuite/c_runtime/fwprintf/test11/testinfo.dat deleted file mode 100644 index beda0cc3a..000000000 --- a/src/pal/tests/palsuite/c_runtime/fwprintf/test11/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = fwprintf -Name = Positive Test for fwprintf -TYPE = DEFAULT -EXE1 = test11 -Description -= Test the unsigned int specifier (%u). -= This test is modeled after the sprintf series. diff --git a/src/pal/tests/palsuite/c_runtime/fwprintf/test12/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/fwprintf/test12/CMakeLists.txt deleted file mode 100644 index 33006f439..000000000 --- a/src/pal/tests/palsuite/c_runtime/fwprintf/test12/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test12.cpp -) - -add_executable(paltest_fwprintf_test12 - ${SOURCES} -) - -add_dependencies(paltest_fwprintf_test12 coreclrpal) - -target_link_libraries(paltest_fwprintf_test12 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/fwprintf/test12/test12.cpp b/src/pal/tests/palsuite/c_runtime/fwprintf/test12/test12.cpp deleted file mode 100644 index 48a612342..000000000 --- a/src/pal/tests/palsuite/c_runtime/fwprintf/test12/test12.cpp +++ /dev/null @@ -1,52 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test12.c -** -** Purpose: Tests the (lowercase) hexadecimal specifier (%x). -** This test is modeled after the sprintf series. -** -** -**==========================================================================*/ - -#include -#include "../fwprintf.h" - -/* - * Depends on memcmp, strlen, fopen, fseek and fgets. - */ - -int __cdecl main(int argc, char *argv[]) -{ - int neg = -42; - int pos = 0x1234ab; - INT64 l = I64(0x1234567887654321); - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoNumTest(convert("foo %x"), pos, "foo 1234ab"); - DoNumTest(convert("foo %lx"), pos, "foo 1234ab"); - DoNumTest(convert("foo %hx"), pos, "foo 34ab"); - DoNumTest(convert("foo %Lx"), pos, "foo 1234ab"); - DoI64Test(convert("foo %I64x"), l, "0x1234567887654321", - "foo 1234567887654321", "foo 0x1234567887654321"); - DoNumTest(convert("foo %7x"), pos, "foo 1234ab"); - DoNumTest(convert("foo %-7x"), pos, "foo 1234ab "); - DoNumTest(convert("foo %.1x"), pos, "foo 1234ab"); - DoNumTest(convert("foo %.7x"), pos, "foo 01234ab"); - DoNumTest(convert("foo %07x"), pos, "foo 01234ab"); - DoNumTest(convert("foo %#x"), pos, "foo 0x1234ab"); - DoNumTest(convert("foo %+x"), pos, "foo 1234ab"); - DoNumTest(convert("foo % x"), pos, "foo 1234ab"); - DoNumTest(convert("foo %+x"), neg, "foo ffffffd6"); - DoNumTest(convert("foo % x"), neg, "foo ffffffd6"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/fwprintf/test12/testinfo.dat b/src/pal/tests/palsuite/c_runtime/fwprintf/test12/testinfo.dat deleted file mode 100644 index 3d0bf4c8f..000000000 --- a/src/pal/tests/palsuite/c_runtime/fwprintf/test12/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = fwprintf -Name = Positive Test for fwprintf -TYPE = DEFAULT -EXE1 = test12 -Description -= Tests the (lowercase) hexadecimal specifier (%x). -= This test is modeled after the sprintf series. diff --git a/src/pal/tests/palsuite/c_runtime/fwprintf/test13/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/fwprintf/test13/CMakeLists.txt deleted file mode 100644 index fef3d08d5..000000000 --- a/src/pal/tests/palsuite/c_runtime/fwprintf/test13/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test13.cpp -) - -add_executable(paltest_fwprintf_test13 - ${SOURCES} -) - -add_dependencies(paltest_fwprintf_test13 coreclrpal) - -target_link_libraries(paltest_fwprintf_test13 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/fwprintf/test13/test13.cpp b/src/pal/tests/palsuite/c_runtime/fwprintf/test13/test13.cpp deleted file mode 100644 index 6eabec6c7..000000000 --- a/src/pal/tests/palsuite/c_runtime/fwprintf/test13/test13.cpp +++ /dev/null @@ -1,52 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test13.c -** -** Purpose: Tests the (uppercase) hexadecimal specifier (%X). -** This test is modeled after the sprintf series. -** -** -**==========================================================================*/ - -#include -#include "../fwprintf.h" - -/* - * Depends on memcmp, strlen, fopen, fseek and fgets. - */ - -int __cdecl main(int argc, char *argv[]) -{ - int neg = -42; - int pos = 0x1234AB; - INT64 l = I64(0x1234567887654321); - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoNumTest(convert("foo %X"), pos, "foo 1234AB"); - DoNumTest(convert("foo %lX"), pos, "foo 1234AB"); - DoNumTest(convert("foo %hX"), pos, "foo 34AB"); - DoNumTest(convert("foo %LX"), pos, "foo 1234AB"); - DoI64Test(convert("foo %I64X"), l, "0x1234567887654321", - "foo 1234567887654321", "foo 0x1234567887654321"); - DoNumTest(convert("foo %7X"), pos, "foo 1234AB"); - DoNumTest(convert("foo %-7X"), pos, "foo 1234AB "); - DoNumTest(convert("foo %.1X"), pos, "foo 1234AB"); - DoNumTest(convert("foo %.7X"), pos, "foo 01234AB"); - DoNumTest(convert("foo %07X"), pos, "foo 01234AB"); - DoNumTest(convert("foo %#X"), pos, "foo 0X1234AB"); - DoNumTest(convert("foo %+X"), pos, "foo 1234AB"); - DoNumTest(convert("foo % X"), pos, "foo 1234AB"); - DoNumTest(convert("foo %+X"), neg, "foo FFFFFFD6"); - DoNumTest(convert("foo % X"), neg, "foo FFFFFFD6"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/fwprintf/test13/testinfo.dat b/src/pal/tests/palsuite/c_runtime/fwprintf/test13/testinfo.dat deleted file mode 100644 index c3222e7c9..000000000 --- a/src/pal/tests/palsuite/c_runtime/fwprintf/test13/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = fwprintf -Name = Positive Test for fwprintf -TYPE = DEFAULT -EXE1 = test13 -Description -= Tests the (uppercase) hexadecimal specifier (%X). -= This test is modeled after the sprintf series. diff --git a/src/pal/tests/palsuite/c_runtime/fwprintf/test14/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/fwprintf/test14/CMakeLists.txt deleted file mode 100644 index 6e37e4fb8..000000000 --- a/src/pal/tests/palsuite/c_runtime/fwprintf/test14/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test14.cpp -) - -add_executable(paltest_fwprintf_test14 - ${SOURCES} -) - -add_dependencies(paltest_fwprintf_test14 coreclrpal) - -target_link_libraries(paltest_fwprintf_test14 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/fwprintf/test14/test14.cpp b/src/pal/tests/palsuite/c_runtime/fwprintf/test14/test14.cpp deleted file mode 100644 index 001cf7268..000000000 --- a/src/pal/tests/palsuite/c_runtime/fwprintf/test14/test14.cpp +++ /dev/null @@ -1,66 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test14.c -** -** Purpose: Tests the lowercase exponential -** notation double specifier (%e). -** This test is modeled after the sprintf series. -** -** -**==========================================================================*/ - -#include -#include "../fwprintf.h" - -/* - * Depends on memcmp, strlen, fopen, fseek and fgets. - */ - -int __cdecl main(int argc, char *argv[]) -{ - double val = 256.0; - double neg = -256.0; - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoDoubleTest(convert("foo %e"), val, "foo 2.560000e+002", - "foo 2.560000e+02"); - DoDoubleTest(convert("foo %le"), val, "foo 2.560000e+002", - "foo 2.560000e+02"); - DoDoubleTest(convert("foo %he"), val, "foo 2.560000e+002", - "foo 2.560000e+02"); - DoDoubleTest(convert("foo %Le"), val, "foo 2.560000e+002", - "foo 2.560000e+02"); - DoDoubleTest(convert("foo %I64e"), val, "foo 2.560000e+002", - "foo 2.560000e+02"); - DoDoubleTest(convert("foo %14e"), val, "foo 2.560000e+002", - "foo 2.560000e+02"); - DoDoubleTest(convert("foo %-14e"), val, "foo 2.560000e+002 ", - "foo 2.560000e+02 "); - DoDoubleTest(convert("foo %.1e"), val, "foo 2.6e+002", - "foo 2.6e+02"); - DoDoubleTest(convert("foo %.8e"), val, "foo 2.56000000e+002", - "foo 2.56000000e+02"); - DoDoubleTest(convert("foo %014e"), val, "foo 02.560000e+002", - "foo 002.560000e+02"); - DoDoubleTest(convert("foo %#e"), val, "foo 2.560000e+002", - "foo 2.560000e+02"); - DoDoubleTest(convert("foo %+e"), val, "foo +2.560000e+002", - "foo +2.560000e+02"); - DoDoubleTest(convert("foo % e"), val, "foo 2.560000e+002", - "foo 2.560000e+02"); - DoDoubleTest(convert("foo %+e"), neg, "foo -2.560000e+002", - "foo -2.560000e+02"); - DoDoubleTest(convert("foo % e"), neg, "foo -2.560000e+002", - "foo -2.560000e+02"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/fwprintf/test14/testinfo.dat b/src/pal/tests/palsuite/c_runtime/fwprintf/test14/testinfo.dat deleted file mode 100644 index a723f7608..000000000 --- a/src/pal/tests/palsuite/c_runtime/fwprintf/test14/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = fwprintf -Name = Positive Test for fwprintf -TYPE = DEFAULT -EXE1 = test14 -Description -= Tests the lowercase exponential -= notation double specifier (%e). -= This test is modeled after the sprintf series. diff --git a/src/pal/tests/palsuite/c_runtime/fwprintf/test15/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/fwprintf/test15/CMakeLists.txt deleted file mode 100644 index 5f1513d64..000000000 --- a/src/pal/tests/palsuite/c_runtime/fwprintf/test15/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test15.cpp -) - -add_executable(paltest_fwprintf_test15 - ${SOURCES} -) - -add_dependencies(paltest_fwprintf_test15 coreclrpal) - -target_link_libraries(paltest_fwprintf_test15 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/fwprintf/test15/test15.cpp b/src/pal/tests/palsuite/c_runtime/fwprintf/test15/test15.cpp deleted file mode 100644 index 9dfe82ecc..000000000 --- a/src/pal/tests/palsuite/c_runtime/fwprintf/test15/test15.cpp +++ /dev/null @@ -1,66 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test15.c -** -** Purpose: Tests the uppercase exponential -** notation double specifier (%E). -** This test is modeled after the sprintf series. -** -** -**==========================================================================*/ - -#include -#include "../fwprintf.h" - -/* - * Depends on memcmp, strlen, fopen, fseek and fgets. - */ - -int __cdecl main(int argc, char *argv[]) -{ - double val = 256.0; - double neg = -256.0; - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoDoubleTest(convert("foo %E"), val, "foo 2.560000E+002", - "foo 2.560000E+02"); - DoDoubleTest(convert("foo %lE"), val, "foo 2.560000E+002", - "foo 2.560000E+02"); - DoDoubleTest(convert("foo %hE"), val, "foo 2.560000E+002", - "foo 2.560000E+02"); - DoDoubleTest(convert("foo %LE"), val, "foo 2.560000E+002", - "foo 2.560000E+02"); - DoDoubleTest(convert("foo %I64E"), val, "foo 2.560000E+002", - "foo 2.560000E+02"); - DoDoubleTest(convert("foo %14E"), val, "foo 2.560000E+002", - "foo 2.560000E+02"); - DoDoubleTest(convert("foo %-14E"), val, "foo 2.560000E+002 ", - "foo 2.560000E+02 "); - DoDoubleTest(convert("foo %.1E"), val, "foo 2.6E+002", - "foo 2.6E+02"); - DoDoubleTest(convert("foo %.8E"), val, "foo 2.56000000E+002", - "foo 2.56000000E+02"); - DoDoubleTest(convert("foo %014E"), val, "foo 02.560000E+002", - "foo 002.560000E+02"); - DoDoubleTest(convert("foo %#E"), val, "foo 2.560000E+002", - "foo 2.560000E+02"); - DoDoubleTest(convert("foo %+E"), val, "foo +2.560000E+002", - "foo +2.560000E+02"); - DoDoubleTest(convert("foo % E"), val, "foo 2.560000E+002", - "foo 2.560000E+02"); - DoDoubleTest(convert("foo %+E"), neg, "foo -2.560000E+002", - "foo -2.560000E+02"); - DoDoubleTest(convert("foo % E"), neg, "foo -2.560000E+002", - "foo -2.560000E+02"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/fwprintf/test15/testinfo.dat b/src/pal/tests/palsuite/c_runtime/fwprintf/test15/testinfo.dat deleted file mode 100644 index 246072f79..000000000 --- a/src/pal/tests/palsuite/c_runtime/fwprintf/test15/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = fwprintf -Name = Positive Test for fwprintf -TYPE = DEFAULT -EXE1 = test15 -Description -= Tests the uppercase exponential -= notation double specifier (%E). -= This test is modeled after the sprintf series. diff --git a/src/pal/tests/palsuite/c_runtime/fwprintf/test16/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/fwprintf/test16/CMakeLists.txt deleted file mode 100644 index f77b35530..000000000 --- a/src/pal/tests/palsuite/c_runtime/fwprintf/test16/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test16.cpp -) - -add_executable(paltest_fwprintf_test16 - ${SOURCES} -) - -add_dependencies(paltest_fwprintf_test16 coreclrpal) - -target_link_libraries(paltest_fwprintf_test16 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/fwprintf/test16/test16.cpp b/src/pal/tests/palsuite/c_runtime/fwprintf/test16/test16.cpp deleted file mode 100644 index 1969be182..000000000 --- a/src/pal/tests/palsuite/c_runtime/fwprintf/test16/test16.cpp +++ /dev/null @@ -1,65 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test16.c -** -** Purpose: Tests the decimal notation double specifier (%f). -** This test is modeled after the sprintf series. -** -** -**==========================================================================*/ - -#include -#include "../fwprintf.h" - -/* - * Depends on memcmp, strlen, fopen, fseek and fgets. - */ - -int __cdecl main(int argc, char *argv[]) -{ - double val = 2560.001; - double neg = -2560.001; - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoDoubleTest(convert("foo %f"), val, "foo 2560.001000", - "foo 2560.001000"); - DoDoubleTest(convert("foo %lf"), val, "foo 2560.001000", - "foo 2560.001000"); - DoDoubleTest(convert("foo %hf"), val, "foo 2560.001000", - "foo 2560.001000"); - DoDoubleTest(convert("foo %Lf"), val, "foo 2560.001000", - "foo 2560.001000"); - DoDoubleTest(convert("foo %I64f"), val, "foo 2560.001000", - "foo 2560.001000"); - DoDoubleTest(convert("foo %12f"), val, "foo 2560.001000", - "foo 2560.001000"); - DoDoubleTest(convert("foo %-12f"), val, "foo 2560.001000 ", - "foo 2560.001000 "); - DoDoubleTest(convert("foo %.1f"), val, "foo 2560.0", - "foo 2560.0"); - DoDoubleTest(convert("foo %.8f"), val, "foo 2560.00100000", - "foo 2560.00100000"); - DoDoubleTest(convert("foo %012f"), val, "foo 02560.001000", - "foo 02560.001000"); - DoDoubleTest(convert("foo %#f"), val, "foo 2560.001000", - "foo 2560.001000"); - DoDoubleTest(convert("foo %+f"), val, "foo +2560.001000", - "foo +2560.001000"); - DoDoubleTest(convert("foo % f"), val, "foo 2560.001000", - "foo 2560.001000"); - DoDoubleTest(convert("foo %+f"), neg, "foo -2560.001000", - "foo -2560.001000"); - DoDoubleTest(convert("foo % f"), neg, "foo -2560.001000", - "foo -2560.001000"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/fwprintf/test16/testinfo.dat b/src/pal/tests/palsuite/c_runtime/fwprintf/test16/testinfo.dat deleted file mode 100644 index 9e5faf9ba..000000000 --- a/src/pal/tests/palsuite/c_runtime/fwprintf/test16/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = fwprintf -Name = Positive Test for fwprintf -TYPE = DEFAULT -EXE1 = test16 -Description -= Tests the decimal notation double specifier (%f). -= This test is modeled after the sprintf series. diff --git a/src/pal/tests/palsuite/c_runtime/fwprintf/test17/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/fwprintf/test17/CMakeLists.txt deleted file mode 100644 index 5a4a58e7d..000000000 --- a/src/pal/tests/palsuite/c_runtime/fwprintf/test17/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test17.cpp -) - -add_executable(paltest_fwprintf_test17 - ${SOURCES} -) - -add_dependencies(paltest_fwprintf_test17 coreclrpal) - -target_link_libraries(paltest_fwprintf_test17 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/fwprintf/test17/test17.cpp b/src/pal/tests/palsuite/c_runtime/fwprintf/test17/test17.cpp deleted file mode 100644 index 66b12716d..000000000 --- a/src/pal/tests/palsuite/c_runtime/fwprintf/test17/test17.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test17.c -** -** Purpose: Tests the lowercase shorthand notation double specifier (%g). -** This test is modeled after the sprintf series. -** -** -**==========================================================================*/ - -#include -#include "../fwprintf.h" - -/* - * Depends on memcmp, strlen, fopen, fseek and fgets. - */ - -int __cdecl main(int argc, char *argv[]) -{ - double val = 2560.001; - double neg = -2560.001; - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoDoubleTest(convert("foo %g"), val, "foo 2560", "foo 2560"); - DoDoubleTest(convert("foo %lg"), val, "foo 2560", "foo 2560"); - DoDoubleTest(convert("foo %hg"), val, "foo 2560", "foo 2560"); - DoDoubleTest(convert("foo %Lg"), val, "foo 2560", "foo 2560"); - DoDoubleTest(convert("foo %I64g"), val, "foo 2560", "foo 2560"); - DoDoubleTest(convert("foo %5g"), val, "foo 2560", "foo 2560"); - DoDoubleTest(convert("foo %-5g"), val, "foo 2560 ", "foo 2560 "); - DoDoubleTest(convert("foo %.1g"), val, "foo 3e+003", "foo 3e+03"); - DoDoubleTest(convert("foo %.2g"), val, "foo 2.6e+003", "foo 2.6e+03"); - DoDoubleTest(convert("foo %.12g"), val, "foo 2560.001", "foo 2560.001"); - DoDoubleTest(convert("foo %06g"), val, "foo 002560", "foo 002560"); - DoDoubleTest(convert("foo %#g"), val, "foo 2560.00", "foo 2560.00"); - DoDoubleTest(convert("foo %+g"), val, "foo +2560", "foo +2560"); - DoDoubleTest(convert("foo % g"), val, "foo 2560", "foo 2560"); - DoDoubleTest(convert("foo %+g"), neg, "foo -2560", "foo -2560"); - DoDoubleTest(convert("foo % g"), neg, "foo -2560", "foo -2560"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/fwprintf/test17/testinfo.dat b/src/pal/tests/palsuite/c_runtime/fwprintf/test17/testinfo.dat deleted file mode 100644 index fe637d744..000000000 --- a/src/pal/tests/palsuite/c_runtime/fwprintf/test17/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = fwprintf -Name = Positive Test for fwprintf -TYPE = DEFAULT -EXE1 = test17 -Description -= Tests the lowercase shorthand notation double specifier (%g). -= This test is modeled after the sprintf series. diff --git a/src/pal/tests/palsuite/c_runtime/fwprintf/test18/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/fwprintf/test18/CMakeLists.txt deleted file mode 100644 index 9839b9fb3..000000000 --- a/src/pal/tests/palsuite/c_runtime/fwprintf/test18/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test18.cpp -) - -add_executable(paltest_fwprintf_test18 - ${SOURCES} -) - -add_dependencies(paltest_fwprintf_test18 coreclrpal) - -target_link_libraries(paltest_fwprintf_test18 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/fwprintf/test18/test18.cpp b/src/pal/tests/palsuite/c_runtime/fwprintf/test18/test18.cpp deleted file mode 100644 index a33dea39b..000000000 --- a/src/pal/tests/palsuite/c_runtime/fwprintf/test18/test18.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test18.c -** -** Purpose: Tests the uppercase shorthand notation double specifier (%G). -** This test is modeled after the sprintf series. -** -** -**==========================================================================*/ - -#include -#include "../fwprintf.h" - -/* - * Depends on memcmp, strlen, fopen, fseek and fgets. - */ - -int __cdecl main(int argc, char *argv[]) -{ - double val = 2560.001; - double neg = -2560.001; - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoDoubleTest(convert("foo %G"), val, "foo 2560", "foo 2560"); - DoDoubleTest(convert("foo %lG"), val, "foo 2560", "foo 2560"); - DoDoubleTest(convert("foo %hG"), val, "foo 2560", "foo 2560"); - DoDoubleTest(convert("foo %LG"), val, "foo 2560", "foo 2560"); - DoDoubleTest(convert("foo %I64G"), val, "foo 2560", "foo 2560"); - DoDoubleTest(convert("foo %5G"), val, "foo 2560", "foo 2560"); - DoDoubleTest(convert("foo %-5G"), val, "foo 2560 ", "foo 2560 "); - DoDoubleTest(convert("foo %.1G"), val, "foo 3E+003", "foo 3E+03"); - DoDoubleTest(convert("foo %.2G"), val, "foo 2.6E+003", "foo 2.6E+03"); - DoDoubleTest(convert("foo %.12G"), val, "foo 2560.001", "foo 2560.001"); - DoDoubleTest(convert("foo %06G"), val, "foo 002560", "foo 002560"); - DoDoubleTest(convert("foo %#G"), val, "foo 2560.00", "foo 2560.00"); - DoDoubleTest(convert("foo %+G"), val, "foo +2560", "foo +2560"); - DoDoubleTest(convert("foo % G"), val, "foo 2560", "foo 2560"); - DoDoubleTest(convert("foo %+G"), neg, "foo -2560", "foo -2560"); - DoDoubleTest(convert("foo % G"), neg, "foo -2560", "foo -2560"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/fwprintf/test18/testinfo.dat b/src/pal/tests/palsuite/c_runtime/fwprintf/test18/testinfo.dat deleted file mode 100644 index 23f621733..000000000 --- a/src/pal/tests/palsuite/c_runtime/fwprintf/test18/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = fwprintf -Name = Positive Test for fwprintf -TYPE = DEFAULT -EXE1 = test18 -Description -= Tests the uppercase shorthand notation double specifier (%G). -= This test is modeled after the sprintf series. diff --git a/src/pal/tests/palsuite/c_runtime/fwprintf/test19/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/fwprintf/test19/CMakeLists.txt deleted file mode 100644 index e7ac859f1..000000000 --- a/src/pal/tests/palsuite/c_runtime/fwprintf/test19/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test19.cpp -) - -add_executable(paltest_fwprintf_test19 - ${SOURCES} -) - -add_dependencies(paltest_fwprintf_test19 coreclrpal) - -target_link_libraries(paltest_fwprintf_test19 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/fwprintf/test19/test19.cpp b/src/pal/tests/palsuite/c_runtime/fwprintf/test19/test19.cpp deleted file mode 100644 index a407c9f4b..000000000 --- a/src/pal/tests/palsuite/c_runtime/fwprintf/test19/test19.cpp +++ /dev/null @@ -1,81 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test19.c -** -** Purpose: Tests the variable length precision argument. -** This test is modeled after the sprintf series. -** -** -**==========================================================================*/ - -#include -#include "../fwprintf.h" - -/* - * Depends on memcmp, strlen, fopen, fseek and fgets. - */ - - - -int __cdecl main(int argc, char *argv[]) -{ - int n = -1; - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoArgumentPrecTest(convert("%.*s"), 2, (void*)convert("bar"), "bar", "ba", "ba"); - DoArgumentPrecTest(convert("%.*S"), 2, (void*)"bar", "bar", "ba", "ba"); - DoArgumentPrecTest(convert("foo %.*n"), 3, (void*)&n, "pointer to int", "foo ", - "foo "); - if (n != 4) - { - Fail("ERROR: Expected count parameter to resolve to %d, got %X\n", - 4, n); - } - - DoArgumentPrecTest(convert("%.*c"), 0, (void*)'a', "a", "a", "a"); - DoArgumentPrecTest(convert("%.*c"), 4, (void*)'a', "a", "a", "a"); - DoArgumentPrecTest(convert("%.*C"), 0, (void*)'a', "a", "a", "a"); - DoArgumentPrecTest(convert("%.*C"), 4, (void*)'a', "a", "a", "a"); - DoArgumentPrecTest(convert("%.*d"), 1, (void*)42, "42", "42", "42"); - DoArgumentPrecTest(convert("%.*d"), 3, (void*)42, "42", "042", "042"); - DoArgumentPrecTest(convert("%.*i"), 1, (void*)42, "42", "42", "42"); - DoArgumentPrecTest(convert("%.*i"), 3, (void*)42, "42", "042", "042"); - DoArgumentPrecTest(convert("%.*o"), 1, (void*)42, "42", "52", "52"); - DoArgumentPrecTest(convert("%.*o"), 3, (void*)42, "42", "052", "052"); - DoArgumentPrecTest(convert("%.*u"), 1, (void*)42, "42", "42", "42"); - DoArgumentPrecTest(convert("%.*u"), 3, (void*)42, "42", "042", "042"); - DoArgumentPrecTest(convert("%.*x"), 1, (void*)0x42, "0x42", "42", "42"); - DoArgumentPrecTest(convert("%.*x"), 3, (void*)0x42, "0x42", "042", "042"); - DoArgumentPrecTest(convert("%.*X"), 1, (void*)0x42, "0x42", "42", "42"); - DoArgumentPrecTest(convert("%.*X"), 3, (void*)0x42, "0x42", "042", "042"); - - - DoArgumentPrecDoubleTest(convert("%.*e"), 1, 2.01, "2.0e+000", "2.0e+00"); - DoArgumentPrecDoubleTest(convert("%.*e"), 3, 2.01, "2.010e+000", - "2.010e+00"); - DoArgumentPrecDoubleTest(convert("%.*E"), 1, 2.01, "2.0E+000", "2.0E+00"); - DoArgumentPrecDoubleTest(convert("%.*E"), 3, 2.01, "2.010E+000", - "2.010E+00"); - DoArgumentPrecDoubleTest(convert("%.*f"), 1, 2.01, "2.0", "2.0"); - DoArgumentPrecDoubleTest(convert("%.*f"), 3, 2.01, "2.010", "2.010"); - DoArgumentPrecDoubleTest(convert("%.*g"), 1, 256.01, "3e+002", "3e+02"); - DoArgumentPrecDoubleTest(convert("%.*g"), 3, 256.01, "256", "256"); - DoArgumentPrecDoubleTest(convert("%.*g"), 4, 256.01, "256", "256"); - DoArgumentPrecDoubleTest(convert("%.*g"), 6, 256.01, "256.01", "256.01"); - DoArgumentPrecDoubleTest(convert("%.*G"), 1, 256.01, "3E+002", "3E+02"); - DoArgumentPrecDoubleTest(convert("%.*G"), 3, 256.01, "256", "256"); - DoArgumentPrecDoubleTest(convert("%.*G"), 4, 256.01, "256", "256"); - DoArgumentPrecDoubleTest(convert("%.*G"), 6, 256.01, "256.01", "256.01"); - - PAL_Terminate(); - - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/fwprintf/test19/testinfo.dat b/src/pal/tests/palsuite/c_runtime/fwprintf/test19/testinfo.dat deleted file mode 100644 index 24aa8778c..000000000 --- a/src/pal/tests/palsuite/c_runtime/fwprintf/test19/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = fwprintf -Name = Positive Test for fwprintf -TYPE = DEFAULT -EXE1 = test19 -Description -= Tests the variable length precision argument. -= This test is modeled after the sprintf series. diff --git a/src/pal/tests/palsuite/c_runtime/fwprintf/test2/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/fwprintf/test2/CMakeLists.txt deleted file mode 100644 index e589a068c..000000000 --- a/src/pal/tests/palsuite/c_runtime/fwprintf/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test2.cpp -) - -add_executable(paltest_fwprintf_test2 - ${SOURCES} -) - -add_dependencies(paltest_fwprintf_test2 coreclrpal) - -target_link_libraries(paltest_fwprintf_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/fwprintf/test2/test2.cpp b/src/pal/tests/palsuite/c_runtime/fwprintf/test2/test2.cpp deleted file mode 100644 index 1e0314761..000000000 --- a/src/pal/tests/palsuite/c_runtime/fwprintf/test2/test2.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test2.c -** -** Purpose: Tests the string specifier (%s). -** This test is modeled after the sprintf series. -** -** -**==========================================================================*/ - -#include -#include "../fwprintf.h" - -/* - * Depends on memcmp, strlen, fopen, fseek and fgets. - */ - -int __cdecl main(int argc, char *argv[]) -{ - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoWStrTest(convert("foo %s"), convert("bar"), "foo bar"); - DoStrTest(convert("foo %hs"), "bar", "foo bar"); - DoWStrTest(convert("foo %ls"), convert("bar"), "foo bar"); - DoWStrTest(convert("foo %ws"), convert("bar"), "foo bar"); - DoWStrTest(convert("foo %Ls"), convert("bar"), "foo bar"); - DoWStrTest(convert("foo %I64s"), convert("bar"), "foo bar"); - DoWStrTest(convert("foo %5s"), convert("bar"), "foo bar"); - DoWStrTest(convert("foo %.2s"), convert("bar"), "foo ba"); - DoWStrTest(convert("foo %5.2s"), convert("bar"), "foo ba"); - DoWStrTest(convert("foo %-5s"), convert("bar"), "foo bar "); - DoWStrTest(convert("foo %05s"), convert("bar"), "foo 00bar"); - DoWStrTest(convert("foo %s"), NULL, "foo (null)"); - DoStrTest(convert("foo %hs"), NULL, "foo (null)"); - DoWStrTest(convert("foo %ls"), NULL, "foo (null)"); - DoWStrTest(convert("foo %ws"), NULL, "foo (null)"); - DoWStrTest(convert("foo %Ls"), NULL, "foo (null)"); - DoWStrTest(convert("foo %I64s"), NULL, "foo (null)"); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/c_runtime/fwprintf/test2/testinfo.dat b/src/pal/tests/palsuite/c_runtime/fwprintf/test2/testinfo.dat deleted file mode 100644 index 1933682f2..000000000 --- a/src/pal/tests/palsuite/c_runtime/fwprintf/test2/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = fwprintf -Name = Positive Test for fwprintf -TYPE = DEFAULT -EXE1 = test2 -Description -= Tests the string specifier (%s). -= This test is modeled after the sprintf series. diff --git a/src/pal/tests/palsuite/c_runtime/fwprintf/test3/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/fwprintf/test3/CMakeLists.txt deleted file mode 100644 index f583d40ac..000000000 --- a/src/pal/tests/palsuite/c_runtime/fwprintf/test3/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test3.cpp -) - -add_executable(paltest_fwprintf_test3 - ${SOURCES} -) - -add_dependencies(paltest_fwprintf_test3 coreclrpal) - -target_link_libraries(paltest_fwprintf_test3 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/fwprintf/test3/test3.cpp b/src/pal/tests/palsuite/c_runtime/fwprintf/test3/test3.cpp deleted file mode 100644 index ff24aa715..000000000 --- a/src/pal/tests/palsuite/c_runtime/fwprintf/test3/test3.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test3.c -** -** Purpose: Tests the wide string specifier (%S). -** This test is modeled after the sprintf series. -** -** -**==========================================================================*/ - -#include -#include "../fwprintf.h" - -/* - * Depends on memcmp, strlen, fopen, fseek and fgets. - */ - -int __cdecl main(int argc, char *argv[]) -{ - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoStrTest(convert("foo %S"), "bar", "foo bar"); - DoStrTest(convert("foo %hS"), "bar", "foo bar"); - DoWStrTest(convert("foo %lS"), convert("bar"), "foo bar"); - DoWStrTest(convert("foo %wS"), convert("bar"), "foo bar"); - DoStrTest(convert("foo %LS"), "bar", "foo bar"); - DoStrTest(convert("foo %I64S"), "bar", "foo bar"); - DoStrTest(convert("foo %5S"), "bar", "foo bar"); - DoStrTest(convert("foo %.2S"), "bar", "foo ba"); - DoStrTest(convert("foo %5.2S"),"bar", "foo ba"); - DoStrTest(convert("foo %-5S"), "bar", "foo bar "); - DoStrTest(convert("foo %05S"), "bar", "foo 00bar"); - DoStrTest(convert("foo %S"), NULL, "foo (null)"); - DoStrTest(convert("foo %hS"), NULL, "foo (null)"); - DoWStrTest(convert("foo %lS"), NULL, "foo (null)"); - DoWStrTest(convert("foo %wS"), NULL, "foo (null)"); - DoStrTest(convert("foo %LS"), NULL, "foo (null)"); - DoStrTest(convert("foo %I64S"), NULL, "foo (null)"); - - PAL_Terminate(); - return PASS; -} - - diff --git a/src/pal/tests/palsuite/c_runtime/fwprintf/test3/testinfo.dat b/src/pal/tests/palsuite/c_runtime/fwprintf/test3/testinfo.dat deleted file mode 100644 index fa8a0bcf7..000000000 --- a/src/pal/tests/palsuite/c_runtime/fwprintf/test3/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = fwprintf -Name = Positive Test for fwprintf -TYPE = DEFAULT -EXE1 = test3 -Description -= Tests the wide string specifier (%S). -= This test is modeled after the sprintf series. diff --git a/src/pal/tests/palsuite/c_runtime/fwprintf/test4/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/fwprintf/test4/CMakeLists.txt deleted file mode 100644 index 166938445..000000000 --- a/src/pal/tests/palsuite/c_runtime/fwprintf/test4/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test4.cpp -) - -add_executable(paltest_fwprintf_test4 - ${SOURCES} -) - -add_dependencies(paltest_fwprintf_test4 coreclrpal) - -target_link_libraries(paltest_fwprintf_test4 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/fwprintf/test4/test4.cpp b/src/pal/tests/palsuite/c_runtime/fwprintf/test4/test4.cpp deleted file mode 100644 index a894120f9..000000000 --- a/src/pal/tests/palsuite/c_runtime/fwprintf/test4/test4.cpp +++ /dev/null @@ -1,85 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test4.c -** -** Purpose: Tests the pointer specifier (%p). -** This test is modeled after the sprintf series. -** -** -**==========================================================================*/ - -#include -#include "../fwprintf.h" - -/* - * Depends on memcmp, strlen, fopen, fseek and fgets. - */ - -int __cdecl main(int argc, char *argv[]) -{ - void *ptr = (void*) 0x123456; - INT64 lptr = I64(0x1234567887654321); - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - -/* -** Run only on 64 bit platforms -*/ -#if defined(BIT64) - Trace("Testing for 64 Bit Platforms \n"); - DoPointerTest(convert("%p"), NULL, "NULL", "0000000000000000", "0x0"); - DoPointerTest(convert("%p"), ptr, "pointer to 0x123456", "0000000000123456", - "0x123456"); - DoPointerTest(convert("%17p"), ptr, "pointer to 0x123456", " 0000000000123456", - " 0x123456"); - DoPointerTest(convert("%17p"), ptr, "pointer to 0x123456", " 0000000000123456", - "0x0123456"); - DoPointerTest(convert("%-17p"), ptr, "pointer to 0x123456", "0000000000123456 ", - "0x123456 "); - DoPointerTest(convert("%+p"), ptr, "pointer to 0x123456", "0000000000123456", - "0x123456"); - DoPointerTest(convert("%#p"), ptr, "pointer to 0x123456", "0X0000000000123456", - "0x123456"); - DoPointerTest(convert("%lp"), ptr, "pointer to 0x123456", "00123456", - "0x123456"); - DoPointerTest(convert("%hp"), ptr, "pointer to 0x123456", "00003456", - "0x3456"); - DoPointerTest(convert("%Lp"), ptr, "pointer to 0x123456", "00123456", - "0x123456"); - DoI64Test(convert("%I64p"), lptr, "pointer to 0x1234567887654321", - "1234567887654321", "0x1234567887654321"); -#else - Trace("Testing for Non 64 Bit Platforms \n"); - DoPointerTest(convert("%p"), NULL, "NULL", "00000000", "0x0"); - DoPointerTest(convert("%p"), ptr, "pointer to 0x123456", "00123456", - "0x123456"); - DoPointerTest(convert("%9p"), ptr, "pointer to 0x123456", " 00123456", - " 0x123456"); - DoPointerTest(convert("%09p"), ptr, "pointer to 0x123456", " 00123456", - "0x0123456"); - DoPointerTest(convert("%-9p"), ptr, "pointer to 0x123456", "00123456 ", - "0x123456 "); - DoPointerTest(convert("%+p"), ptr, "pointer to 0x123456", "00123456", - "0x123456"); - DoPointerTest(convert("%#p"), ptr, "pointer to 0x123456", "0X00123456", - "0x123456"); - DoPointerTest(convert("%lp"), ptr, "pointer to 0x123456", "00123456", - "0x123456"); - DoPointerTest(convert("%hp"), ptr, "pointer to 0x123456", "00003456", - "0x3456"); - DoPointerTest(convert("%Lp"), ptr, "pointer to 0x123456", "00123456", - "0x123456"); - DoI64Test(convert("%I64p"), lptr, "pointer to 0x1234567887654321", - "1234567887654321", "0x1234567887654321"); -#endif - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/fwprintf/test4/testinfo.dat b/src/pal/tests/palsuite/c_runtime/fwprintf/test4/testinfo.dat deleted file mode 100644 index 92140c29b..000000000 --- a/src/pal/tests/palsuite/c_runtime/fwprintf/test4/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = fwprintf -Name = Positive Test for fwprintf -TYPE = DEFAULT -EXE1 = test4 -Description -= Tests the pointer specifier (%p). -= This test is modeled after the sprintf series. diff --git a/src/pal/tests/palsuite/c_runtime/fwprintf/test5/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/fwprintf/test5/CMakeLists.txt deleted file mode 100644 index 4611c7fbc..000000000 --- a/src/pal/tests/palsuite/c_runtime/fwprintf/test5/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test5.cpp -) - -add_executable(paltest_fwprintf_test5 - ${SOURCES} -) - -add_dependencies(paltest_fwprintf_test5 coreclrpal) - -target_link_libraries(paltest_fwprintf_test5 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/fwprintf/test5/test5.cpp b/src/pal/tests/palsuite/c_runtime/fwprintf/test5/test5.cpp deleted file mode 100644 index 9d9598909..000000000 --- a/src/pal/tests/palsuite/c_runtime/fwprintf/test5/test5.cpp +++ /dev/null @@ -1,63 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test5.c -** -** Purpose: Tests the count specifier (%n). -** This test is modeled after the sprintf series. -** -** -**==========================================================================*/ - -#include -#include "../fwprintf.h" - -/* - * Depends on memcmp, strlen, fopen, fseek and fgets. - */ - -int __cdecl main(int argc, char *argv[]) -{ - WCHAR *longStr; - char *longResult = - "really-long-string-that-just-keeps-going-on-and-on-and-on.." - "..................useless-filler.................................." - "..................useless-filler.................................." - "..................useless-filler.................................." - " bar"; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - longStr = - convert("really-long-string-that-just-keeps-going-on-and-on-and-on.." - "..................useless-filler.................................." - "..................useless-filler.................................." - "..................useless-filler.................................." - "%n bar"); - DoCountTest(convert("foo %n bar"), 4, "foo bar"); - DoCountTest(longStr, 257, longResult); - DoCountTest(convert("fo%n bar"), 2, "fo bar"); - DoCountTest(convert("%n foo"), 0, " foo"); - DoCountTest(convert("foo %#n bar"), 4, "foo bar"); - DoCountTest(convert("foo % n bar"), 4, "foo bar"); - DoCountTest(convert("foo %+n bar"), 4, "foo bar"); - DoCountTest(convert("foo %-n bar"), 4, "foo bar"); - DoCountTest(convert("foo %0n bar"), 4, "foo bar"); - DoShortCountTest(convert("foo %hn bar"), 4, "foo bar"); - DoCountTest(convert("foo %ln bar"), 4, "foo bar"); - DoCountTest(convert("foo %Ln bar"), 4, "foo bar"); - DoCountTest(convert("foo %I64n bar"), 4, "foo bar"); - DoCountTest(convert("foo %20.3n bar"), 4, "foo bar"); - - PAL_Terminate(); - - free(longStr); - - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/fwprintf/test5/testinfo.dat b/src/pal/tests/palsuite/c_runtime/fwprintf/test5/testinfo.dat deleted file mode 100644 index 152f56334..000000000 --- a/src/pal/tests/palsuite/c_runtime/fwprintf/test5/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = fwprintf -Name = Positive Test for fwprintf -TYPE = DEFAULT -EXE1 = test5 -Description -= Tests the count specifier (%n). -= This test is modeled after the sprintf series. diff --git a/src/pal/tests/palsuite/c_runtime/fwprintf/test6/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/fwprintf/test6/CMakeLists.txt deleted file mode 100644 index f692baaf1..000000000 --- a/src/pal/tests/palsuite/c_runtime/fwprintf/test6/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test6.cpp -) - -add_executable(paltest_fwprintf_test6 - ${SOURCES} -) - -add_dependencies(paltest_fwprintf_test6 coreclrpal) - -target_link_libraries(paltest_fwprintf_test6 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/fwprintf/test6/test6.cpp b/src/pal/tests/palsuite/c_runtime/fwprintf/test6/test6.cpp deleted file mode 100644 index 160ff524e..000000000 --- a/src/pal/tests/palsuite/c_runtime/fwprintf/test6/test6.cpp +++ /dev/null @@ -1,48 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test6.c -** -** Purpose: Tests the char specifier (%c). -** This test is modeled after the sprintf series. -** -** -**==========================================================================*/ - -#include -#include "../fwprintf.h" - -/* - * Depends on memcmp, strlen, fopen, fseek and fgets. - */ - -int __cdecl main(int argc, char *argv[]) -{ - WCHAR wb = (WCHAR) 'b'; - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoWCharTest(convert("foo %c"), wb, "foo b"); - DoCharTest(convert("foo %hc"), 'c', "foo c"); - DoWCharTest(convert("foo %lc"), wb, "foo b"); - DoWCharTest(convert("foo %Lc"), wb, "foo b"); - DoWCharTest(convert("foo %I64c"), wb, "foo b"); - DoWCharTest(convert("foo %5c"), wb, "foo b"); - DoWCharTest(convert("foo %.0c"), wb, "foo b"); - DoWCharTest(convert("foo %-5c"), wb, "foo b "); - DoWCharTest(convert("foo %05c"), wb, "foo 0000b"); - DoWCharTest(convert("foo % c"), wb, "foo b"); - DoWCharTest(convert("foo %#c"), wb, "foo b"); - - PAL_Terminate(); - return PASS; -} - - - diff --git a/src/pal/tests/palsuite/c_runtime/fwprintf/test6/testinfo.dat b/src/pal/tests/palsuite/c_runtime/fwprintf/test6/testinfo.dat deleted file mode 100644 index cc968bdf7..000000000 --- a/src/pal/tests/palsuite/c_runtime/fwprintf/test6/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = fwprintf -Name = Positive Test for fwprintf -TYPE = DEFAULT -EXE1 = test6 -Description -= Tests the char specifier (%c). -= This test is modeled after the sprintf series. diff --git a/src/pal/tests/palsuite/c_runtime/fwprintf/test7/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/fwprintf/test7/CMakeLists.txt deleted file mode 100644 index 18b6673c8..000000000 --- a/src/pal/tests/palsuite/c_runtime/fwprintf/test7/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test7.cpp -) - -add_executable(paltest_fwprintf_test7 - ${SOURCES} -) - -add_dependencies(paltest_fwprintf_test7 coreclrpal) - -target_link_libraries(paltest_fwprintf_test7 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/fwprintf/test7/test7.cpp b/src/pal/tests/palsuite/c_runtime/fwprintf/test7/test7.cpp deleted file mode 100644 index c5515a864..000000000 --- a/src/pal/tests/palsuite/c_runtime/fwprintf/test7/test7.cpp +++ /dev/null @@ -1,47 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test7.c -** -** Purpose: Tests the wide char specifier (%C). -** This test is modeled after the sprintf series. -** -** -**==========================================================================*/ - -#include -#include "../fwprintf.h" - -/* - * Depends on memcmp, strlen, fopen, fseek and fgets. - */ - -int __cdecl main(int argc, char *argv[]) -{ - WCHAR wb = (WCHAR) 'b'; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - DoCharTest(convert("foo %C"), 'c', "foo c"); - DoWCharTest(convert("foo %hc"), wb, "foo b"); - DoCharTest(convert("foo %lC"), 'c', "foo c"); - DoCharTest(convert("foo %LC"), 'c', "foo c"); - DoCharTest(convert("foo %I64C"), 'c', "foo c"); - DoCharTest(convert("foo %5C"), 'c', "foo c"); - DoCharTest(convert("foo %.0C"), 'c', "foo c"); - DoCharTest(convert("foo %-5C"), 'c', "foo c "); - DoCharTest(convert("foo %05C"), 'c', "foo 0000c"); - DoCharTest(convert("foo % C"), 'c', "foo c"); - DoCharTest(convert("foo %#C"), 'c', "foo c"); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/c_runtime/fwprintf/test7/testinfo.dat b/src/pal/tests/palsuite/c_runtime/fwprintf/test7/testinfo.dat deleted file mode 100644 index 46cb35cf4..000000000 --- a/src/pal/tests/palsuite/c_runtime/fwprintf/test7/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = fwprintf -Name = Positive Test for fwprintf -TYPE = DEFAULT -EXE1 = test7 -Description -= Tests the wide char specifier (%C). -= This test is modeled after the sprintf series. diff --git a/src/pal/tests/palsuite/c_runtime/fwprintf/test8/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/fwprintf/test8/CMakeLists.txt deleted file mode 100644 index dfb8814bd..000000000 --- a/src/pal/tests/palsuite/c_runtime/fwprintf/test8/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test8.cpp -) - -add_executable(paltest_fwprintf_test8 - ${SOURCES} -) - -add_dependencies(paltest_fwprintf_test8 coreclrpal) - -target_link_libraries(paltest_fwprintf_test8 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/fwprintf/test8/test8.cpp b/src/pal/tests/palsuite/c_runtime/fwprintf/test8/test8.cpp deleted file mode 100644 index efc81a954..000000000 --- a/src/pal/tests/palsuite/c_runtime/fwprintf/test8/test8.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test8.c -** -** Purpose: Tests the decimal specifier (%d). -** This test is modeled after the sprintf series. -** -** -**==========================================================================*/ - -#include -#include "../fwprintf.h" - -/* - * Depends on memcmp, strlen, fopen, fseek and fgets. - */ - -int __cdecl main(int argc, char *argv[]) -{ - int neg = -42; - int pos = 42; - INT64 l = 42; - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoNumTest(convert("foo %d"), pos, "foo 42"); - DoNumTest(convert("foo %ld"), 0xFFFF, "foo 65535"); - DoNumTest(convert("foo %hd"), 0xFFFF, "foo -1"); - DoNumTest(convert("foo %Ld"), pos, "foo 42"); - DoI64Test(convert("foo %I64d"), l, "42", "foo 42", "foo 42"); - DoNumTest(convert("foo %3d"), pos, "foo 42"); - DoNumTest(convert("foo %-3d"), pos, "foo 42 "); - DoNumTest(convert("foo %.1d"), pos, "foo 42"); - DoNumTest(convert("foo %.3d"), pos, "foo 042"); - DoNumTest(convert("foo %03d"), pos, "foo 042"); - DoNumTest(convert("foo %#d"), pos, "foo 42"); - DoNumTest(convert("foo %+d"), pos, "foo +42"); - DoNumTest(convert("foo % d"), pos, "foo 42"); - DoNumTest(convert("foo %+d"), neg, "foo -42"); - DoNumTest(convert("foo % d"), neg, "foo -42"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/fwprintf/test8/testinfo.dat b/src/pal/tests/palsuite/c_runtime/fwprintf/test8/testinfo.dat deleted file mode 100644 index c8ce33acb..000000000 --- a/src/pal/tests/palsuite/c_runtime/fwprintf/test8/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = fwprintf -Name = Positive Test for fwprintf -TYPE = DEFAULT -EXE1 = test8 -Description -= Tests the decimal specifier (%d). -= This test is modeled after the sprintf series. diff --git a/src/pal/tests/palsuite/c_runtime/fwprintf/test9/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/fwprintf/test9/CMakeLists.txt deleted file mode 100644 index 3e0867773..000000000 --- a/src/pal/tests/palsuite/c_runtime/fwprintf/test9/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test9.cpp -) - -add_executable(paltest_fwprintf_test9 - ${SOURCES} -) - -add_dependencies(paltest_fwprintf_test9 coreclrpal) - -target_link_libraries(paltest_fwprintf_test9 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/fwprintf/test9/test9.cpp b/src/pal/tests/palsuite/c_runtime/fwprintf/test9/test9.cpp deleted file mode 100644 index 23db2d897..000000000 --- a/src/pal/tests/palsuite/c_runtime/fwprintf/test9/test9.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test9.c -** -** Purpose: Tests the integer specifier (%i). -** This test is modeled after the sprintf series. -** -** -**==========================================================================*/ - -#include -#include "../fwprintf.h" - -/* - * Depends on memcmp, strlen, fopen, fseek and fgets. - */ - -int __cdecl main(int argc, char *argv[]) -{ - int neg = -42; - int pos = 42; - INT64 l = 42; - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoNumTest(convert("foo %i"), pos, "foo 42"); - DoNumTest(convert("foo %li"), 0xFFFF, "foo 65535"); - DoNumTest(convert("foo %hi"), 0xFFFF, "foo -1"); - DoNumTest(convert("foo %Li"), pos, "foo 42"); - DoI64Test(convert("foo %I64i"), l, "42", "foo 42", "foo 42"); - DoNumTest(convert("foo %3i"), pos, "foo 42"); - DoNumTest(convert("foo %-3i"), pos, "foo 42 "); - DoNumTest(convert("foo %.1i"), pos, "foo 42"); - DoNumTest(convert("foo %.3i"), pos, "foo 042"); - DoNumTest(convert("foo %03i"), pos, "foo 042"); - DoNumTest(convert("foo %#i"), pos, "foo 42"); - DoNumTest(convert("foo %+i"), pos, "foo +42"); - DoNumTest(convert("foo % i"), pos, "foo 42"); - DoNumTest(convert("foo %+i"), neg, "foo -42"); - DoNumTest(convert("foo % i"), neg, "foo -42"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/fwprintf/test9/testinfo.dat b/src/pal/tests/palsuite/c_runtime/fwprintf/test9/testinfo.dat deleted file mode 100644 index 5c2ec25ab..000000000 --- a/src/pal/tests/palsuite/c_runtime/fwprintf/test9/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = fwprintf -Name = Positive Test for fwprintf -TYPE = DEFAULT -EXE1 = test9 -Description -= Tests the integer specifier (%i). -= This test is modeled after the sprintf series. diff --git a/src/pal/tests/palsuite/c_runtime/fwrite/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/fwrite/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/c_runtime/fwrite/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/c_runtime/fwrite/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/fwrite/test1/CMakeLists.txt deleted file mode 100644 index 084c1fc41..000000000 --- a/src/pal/tests/palsuite/c_runtime/fwrite/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_fwrite_test1 - ${SOURCES} -) - -add_dependencies(paltest_fwrite_test1 coreclrpal) - -target_link_libraries(paltest_fwrite_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/fwrite/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/fwrite/test1/test1.cpp deleted file mode 100644 index 392522879..000000000 --- a/src/pal/tests/palsuite/c_runtime/fwrite/test1/test1.cpp +++ /dev/null @@ -1,104 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: Write a short string to a file and check that it was written -** properly. -** -** -**==========================================================================*/ - -#include - -int __cdecl main(int argc, char **argv) -{ - const char filename[] = "testfile.tmp"; - const char outBuffer[] = "This is a test."; - char inBuffer[sizeof(outBuffer) + 10]; - int itemsExpected; - int itemsWritten; - FILE * fp = NULL; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - if((fp = fopen(filename, "w")) == NULL) - { - Fail("Unable to open a file for write.\n"); - } - - itemsExpected = sizeof(outBuffer); - itemsWritten = fwrite(outBuffer, - sizeof(outBuffer[0]), - sizeof(outBuffer), - fp); - - if (itemsWritten == 0) - { - if(fclose(fp) != 0) - { - Fail("fwrite: Error occurred during the closing of a file.\n"); - } - - Fail("fwrite() couldn't write to a stream at all\n"); - } - else if (itemsWritten != itemsExpected) - { - if(fclose(fp) != 0) - { - Fail("fwrite: Error occurred during the closing of a file.\n"); - } - - Fail("fwrite() produced errors writing to a stream.\n"); - } - - if(fclose(fp) != 0) - { - Fail("fwrite: Error occurred during the closing of a file.\n"); - } - - /* open the file to verify what was written to the file */ - if ((fp = fopen(filename, "r")) == NULL) - { - Fail("Couldn't open newly written file for read.\n"); - } - - if (fgets(inBuffer, sizeof(inBuffer), fp) == NULL) - { - if(fclose(fp) != 0) - { - Fail("fwrite: Error occurred during the closing of a file.\n"); - } - - Fail("We wrote something to a file using fwrite() and got errors" - " when we tried to read it back using fgets(). Either " - "fwrite() or fgets() is broken.\n"); - } - - if (strcmp(inBuffer, outBuffer) != 0) - { - if(fclose(fp) != 0) - { - Fail("fwrite: Error occurred during the closing of a file.\n"); - } - - Fail("fwrite() (or fgets()) is broken. The string read back from" - " the file does not match the string written.\n"); - } - - if(fclose(fp) != 0) - { - Fail("fwrite: Error occurred during the closing of a file.\n"); - } - - PAL_Terminate(); - return PASS; -} - - diff --git a/src/pal/tests/palsuite/c_runtime/fwrite/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/fwrite/test1/testinfo.dat deleted file mode 100644 index 75ad9ed05..000000000 --- a/src/pal/tests/palsuite/c_runtime/fwrite/test1/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = fwrite -Name = Positive Test for fwrite -TYPE = DEFAULT -EXE1 = test1 -Description -= Write a short string to a file and check that it was written properly. diff --git a/src/pal/tests/palsuite/c_runtime/getc/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/getc/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/c_runtime/getc/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/c_runtime/getc/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/getc/test1/CMakeLists.txt deleted file mode 100644 index 92f6f31e1..000000000 --- a/src/pal/tests/palsuite/c_runtime/getc/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - getc.cpp -) - -add_executable(paltest_getc_test1 - ${SOURCES} -) - -add_dependencies(paltest_getc_test1 coreclrpal) - -target_link_libraries(paltest_getc_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/getc/test1/getc.cpp b/src/pal/tests/palsuite/c_runtime/getc/test1/getc.cpp deleted file mode 100644 index dfe10d616..000000000 --- a/src/pal/tests/palsuite/c_runtime/getc/test1/getc.cpp +++ /dev/null @@ -1,152 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: getc.c (test 1) -** -** Purpose: Tests the PAL implementation of the getc function. -** -** -**===================================================================*/ - -#include - - -int __cdecl main(int argc, char *argv[]) -{ - const char szFileName[] = {"testfile.tmp"}; - const char szTestString[] = - {"The quick brown fox jumped over the lazy dog's back."}; - FILE* pFile = NULL; - int nCount = 0; - int nChar = 0; - char szBuiltString[256]; - - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - memset(szBuiltString, 0, 256); - - - /* create/open a file for read and write */ - pFile = fopen(szFileName, "w+"); - if (pFile == NULL) - { - Fail("getc: ERROR -> fopen failed to create the file %s with the " - "error code %ld\n", - szFileName, - GetLastError()); - } - - /* try reading from an empty file */ - if ((nChar = getc(pFile)) != EOF) - { - Trace("getc: ERROR -> getc returned \"%c\" when run on " - "an empty file.\n", nChar); - if (fclose(pFile) != 0) - { - Trace("getc: ERROR -> fclose failed to close the file. " - "GetLastError returned %ld\n", - GetLastError()); - } - Fail(""); - } - - // Move the file pointer back to the beginning of the file. Some - // platforms require an fseek() between a getc() that returns EOF - // and any subsequent output to the file. - if (fseek(pFile, 0, SEEK_SET) != 0) - { - Trace("getc: ERROR -> fseek failed to move the file pointer to the " - "beginning of the file. GetLastError returned %ld\n", - GetLastError()); - if (fclose(pFile) != 0) - { - Trace("getc: ERROR -> fclose failed to close the file. " - "GetLastError returned %ld\n", - GetLastError()); - } - Fail(""); - } - - /* populate the file with a known string */ - nCount = fprintf(pFile, szTestString); - if (nCount != strlen(szTestString)) - { - Fail("getc: ERROR -> fprintf failed to write %s. The string is %d " - "characters long but fprintf apparently only wrote %d characters." - " GetLastError returned %ld\n", - szTestString, - strlen(szTestString), - nCount, - GetLastError()); - } - - /* move the file pointer back to the beginning of the file */ - if (fseek(pFile, 0, SEEK_SET) != 0) - { - Trace("getc: ERROR -> fseek failed to move the file pointer to the " - "beginning of the file. GetLastError returned %ld\n", - GetLastError()); - if (fclose(pFile) != 0) - { - Trace("getc: ERROR -> fclose failed to close the file. " - "GetLastError returned %ld\n", - GetLastError()); - } - Fail(""); - } - - /* now get the characters one at a time */ - nCount = 0; - while ((nChar = getc(pFile)) != EOF) - { - szBuiltString[nCount++] = nChar; - } - - /* now, let's see if it worked */ - if (strcmp(szBuiltString, szTestString) != 0) - { - Trace("getc: ERROR -> Reading one char at a time, getc built \"%s\" " - "however it should have built \"%s\".\n", - szBuiltString, - szTestString); - if (fclose(pFile) != 0) - { - Trace("getc: ERROR -> fclose failed to close the file. " - "GetLastError returned %ld\n", - GetLastError()); - } - Fail(""); - } - - /* with the file pointer at EOF, try reading past EOF*/ - if ((nChar = getc(pFile)) != EOF) - { - Trace("getc: ERROR -> getc returned \"%c\" when reading past " - "the end of the file.\n", nChar); - if (fclose(pFile) != 0) - { - Trace("getc: ERROR -> fclose failed to close the file. " - "GetLastError returned %ld\n", - GetLastError()); - } - Fail(""); - } - - if (fclose(pFile) != 0) - { - Fail("getc: ERROR -> fclose failed to close the file. " - "GetLastError returned %ld\n", - GetLastError()); - } - - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/getc/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/getc/test1/testinfo.dat deleted file mode 100644 index 19a0c1ee1..000000000 --- a/src/pal/tests/palsuite/c_runtime/getc/test1/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = getc -Name = test for getc (test 1) -Type = DEFAULT -EXE1 = getc -Description -= Write a string to a file, read it in one character -= at a time with getc and compare with the original string. -= It also verifies that getc can't read past EOF. diff --git a/src/pal/tests/palsuite/c_runtime/getenv/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/getenv/CMakeLists.txt deleted file mode 100644 index 1962ade35..000000000 --- a/src/pal/tests/palsuite/c_runtime/getenv/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) -add_subdirectory(test3) - diff --git a/src/pal/tests/palsuite/c_runtime/getenv/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/getenv/test1/CMakeLists.txt deleted file mode 100644 index 8cb87b119..000000000 --- a/src/pal/tests/palsuite/c_runtime/getenv/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_getenv_test1 - ${SOURCES} -) - -add_dependencies(paltest_getenv_test1 coreclrpal) - -target_link_libraries(paltest_getenv_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/getenv/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/getenv/test1/test1.cpp deleted file mode 100644 index 0fb9025c8..000000000 --- a/src/pal/tests/palsuite/c_runtime/getenv/test1/test1.cpp +++ /dev/null @@ -1,78 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test1.c -** -** Purpose: Create an environment variable and then use getenv to get -** a pointer to it. Check that the pointer is valid and that the string -** is what we expected. Also check that searching for a non-existent -** variable will cause getenv to return NULL. Also check that function -** passes when the parameter has it's casing changed (e.g upper case) -** -** -**===================================================================*/ - -#include - -int __cdecl main(int argc, char **argv) -{ - - const char* SetVariable = "PalTestingEnvironmentVariable=The value"; - const char* VariableName = "PalTestingEnvironmentVariable"; - const char* VariableValue = "The value"; - char* result; - - - if (0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - /* Use _putenv to set an environment variable. This ensures that the - variable we're testing on is always present. - */ - - if(_putenv(SetVariable) == -1) - { - Fail("ERROR: _putenv failed to set an environment variable that " - "getenv will be using for testing.\n"); - } - - /* Call getenv -- ensure it doesn't return NULL and the string it returns - is the value we set above. - */ - - result = getenv(VariableName); - if(result == NULL) - { - Fail("ERROR: The result of getenv on a valid Environment Variable " - "was NULL, which indicates the environment varaible was not " - "found.\n"); - } - - if(strcmp(result, VariableValue) != 0) - { - Fail("ERROR: The value obtained by getenv() was not equal to the " - "correct value of the environment variable. The correct " - "value is '%s' and the function returned '%s'.\n", - VariableValue, - result); - } - - /* Try calling getenv on an environment variable which doesn't - exist. - */ - result = getenv("SomeEnvironmentVariableThatReallyDoesNotExist"); - - if(result != NULL) - { - Fail("ERROR: Called getenv on an environment variable which " - "doesn't exist and it returned '%s' instead of NULL.\n",result); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/getenv/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/getenv/test1/testinfo.dat deleted file mode 100644 index b9cbf7198..000000000 --- a/src/pal/tests/palsuite/c_runtime/getenv/test1/testinfo.dat +++ /dev/null @@ -1,16 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = getenv -Name = Test retrieval of variables correctly, and failure if they don't exist -TYPE = DEFAULT -EXE1 = test1 -Description -= Create an environment variable and then use getenv to get -= a pointer to it. Check that the pointer is valid and that the string -= is what we expected. Also check that searching for a non-existent -= variable will cause getenv to return NULL. Also check that changing -= the case (upper or lower) of a variable does not effect functionality. diff --git a/src/pal/tests/palsuite/c_runtime/getenv/test2/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/getenv/test2/CMakeLists.txt deleted file mode 100644 index de8bc27cd..000000000 --- a/src/pal/tests/palsuite/c_runtime/getenv/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test2.cpp -) - -add_executable(paltest_getenv_test2 - ${SOURCES} -) - -add_dependencies(paltest_getenv_test2 coreclrpal) - -target_link_libraries(paltest_getenv_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/getenv/test2/test2.cpp b/src/pal/tests/palsuite/c_runtime/getenv/test2/test2.cpp deleted file mode 100644 index 26f245fcc..000000000 --- a/src/pal/tests/palsuite/c_runtime/getenv/test2/test2.cpp +++ /dev/null @@ -1,101 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test2.c -** -** Purpose: Create environment variables that differ only in Case, and -** verify that the BSD operating system treats the variables -** differently. -** -** -**===================================================================*/ - -#include - -int __cdecl main(int argc, char **argv) -{ -#if WIN32 - - return PASS; - -#else - - const char* FirstVariable = "PalTestingEnvironmentVariable=The value"; - const char* SecondVariable = "PALTESTINGEnvironmentVariable=Different value"; - const char* FirstVarName = "PalTestingEnvironmentVariable"; - const char* SecondVarName = "PALTESTINGEnvironmentVariable"; - const char* FirstVarValue = "The value"; - const char* SecondVarValue = "Different value"; - char* result; - - - if (0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - /* Use _putenv to set the environment variables. This ensures that the - variables we're testing with are always present. - */ - if(_putenv(FirstVariable) != 0) - { - Fail("ERROR: _putenv failed to set an environment variable that " - "getenv will be using for testing.\n"); - } - - if(_putenv(SecondVariable) != 0) - { - Fail("ERROR: _putenv failed to set an environment variable that " - "getenv will be using for testing.\n"); - } - - - /* Call getenv -- ensure it doesn't return NULL and the string it returns - is the value we set above. Also make sure that each environment variable, - differing only by case, returns it's own value. - */ - - result = getenv(FirstVarName); - if(result == NULL) - { - Fail("ERROR: The result of getenv on a valid Environment Variable " - "was NULL, which indicates the environment varaible was not " - "found.\n"); - } - - if(strcmp(result, FirstVarValue) != 0) - { - Fail("ERROR: The value obtained by getenv() was not equal to the " - "correct value of the environment variable. The correct " - "value is '%s' and the function returned '%s'.\n", - FirstVarValue, - result); - } - - - result = getenv(SecondVarName); - if(result == NULL) - { - Fail("ERROR: The result of getenv on a valid Environment Variable " - "was NULL, which indicates the environment varaible was not " - "found.\n"); - } - - if(strcmp(result, SecondVarValue) != 0) - { - Fail("ERROR: The value obtained by getenv() was not equal to the " - "correct value of the environment variable. The correct " - "value is '%s' and the function returned '%s'.\n", - SecondVarValue, - result); - } - - - PAL_Terminate(); - return PASS; - -#endif -} diff --git a/src/pal/tests/palsuite/c_runtime/getenv/test2/testinfo.dat b/src/pal/tests/palsuite/c_runtime/getenv/test2/testinfo.dat deleted file mode 100644 index 90a4ac5af..000000000 --- a/src/pal/tests/palsuite/c_runtime/getenv/test2/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = getenv -Name = Test retrieval of variables differing only by case. -TYPE = DEFAULT -EXE1 = test2 -Description -= Check that environment variables differing only by their -= case are interpreted as separate variables by the BSD Operationg -= System. diff --git a/src/pal/tests/palsuite/c_runtime/getenv/test3/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/getenv/test3/CMakeLists.txt deleted file mode 100644 index 48d3b117d..000000000 --- a/src/pal/tests/palsuite/c_runtime/getenv/test3/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test3.cpp -) - -add_executable(paltest_getenv_test3 - ${SOURCES} -) - -add_dependencies(paltest_getenv_test3 coreclrpal) - -target_link_libraries(paltest_getenv_test3 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/getenv/test3/test3.cpp b/src/pal/tests/palsuite/c_runtime/getenv/test3/test3.cpp deleted file mode 100644 index 1eefd9d40..000000000 --- a/src/pal/tests/palsuite/c_runtime/getenv/test3/test3.cpp +++ /dev/null @@ -1,75 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test3.c -** -** Purpose: Create an environment variable and try to retrieve -** it using the same name but with different case. This -** is to show that the Win32 representation of getenv -** is case insensitive. -** -** -**===================================================================*/ - -#include - -int __cdecl main(int argc, char **argv) -{ -#if WIN32 - - const char* FirstVariable = "PalTestingEnvironmentVariable=The value"; - const char* ModifiedName = "PALTESTINGEnvironmentVariable"; - const char* FirstVarValue = "The value"; - char* result; - - - if (0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - /* Use _putenv to set an environment variable. This ensures that the - variable we're testing on is always present. - */ - - if(_putenv(FirstVariable) != 0) - { - Fail("ERROR: _putenv failed to set an environment variable that " - "getenv will be using for testing.\n"); - } - - - /* Call getenv -- ensure it doesn't return NULL and the string it returns - is the value we set above. Also make sure that each environment variable, - differing only by case, doesn't affect the return value. - */ - - result = getenv(ModifiedName); - if(result == NULL) - { - Fail("ERROR: The result of getenv on a valid Environment Variable " - "was NULL, which indicates the environment varaible was not " - "found.\n"); - } - - if(strcmp(result, FirstVarValue) != 0) - { - Fail("ERROR: The value obtained by getenv() was not equal to the " - "correct value of the environment variable. The correct " - "value is '%s' and the function returned '%s'.\n", - FirstVarValue, - result); - } - - - PAL_Terminate(); - return PASS; - -#else - return PASS; - -#endif -} diff --git a/src/pal/tests/palsuite/c_runtime/getenv/test3/testinfo.dat b/src/pal/tests/palsuite/c_runtime/getenv/test3/testinfo.dat deleted file mode 100644 index 6e12fc438..000000000 --- a/src/pal/tests/palsuite/c_runtime/getenv/test3/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = getenv -Name = Test retrieval of variables differing only by case. -TYPE = DEFAULT -EXE1 = test3 -Description -= Check that environment variables differing only by their -= case are interpreted as the same variables in the WIN32 -= platform. diff --git a/src/pal/tests/palsuite/c_runtime/isalnum/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/isalnum/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/c_runtime/isalnum/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/c_runtime/isalnum/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/isalnum/test1/CMakeLists.txt deleted file mode 100644 index 033f58d91..000000000 --- a/src/pal/tests/palsuite/c_runtime/isalnum/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_isalnum_test1 - ${SOURCES} -) - -add_dependencies(paltest_isalnum_test1 coreclrpal) - -target_link_libraries(paltest_isalnum_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/isalnum/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/isalnum/test1/test1.cpp deleted file mode 100644 index d9cdfcadf..000000000 --- a/src/pal/tests/palsuite/c_runtime/isalnum/test1/test1.cpp +++ /dev/null @@ -1,88 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test1.c -** -** Purpose: Tests the PAL implementation of the isalnum function -** Check that a number of characters return the correct -** values for whether they are alpha/numeric or not. -** -** -**===================================================================*/ - -#include - - -struct testCase -{ - int CorrectResult; - int character; -}; - -int __cdecl main(int argc, char **argv) -{ - - int result; - int i; - - struct testCase testCases[] = - { - {1, 'a'}, - {1, 'z'}, - {1, 'B'}, - {1, '5'}, - {1, '0'}, - {0, '?'}, - {0, 230} - }; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - /* Loop through each case. Check to see if each is alpha/numeric or - not. - */ - - for(i = 0; i < sizeof(testCases) / sizeof(struct testCase); i++) - { - - result = isalnum(testCases[i].character); - - /* The return value is 'non-zero' for success. This if condition - * will still work if that non-zero isn't just 1 - */ - if ( ((testCases[i].CorrectResult == 1) && (result == 0)) || - ( (testCases[i].CorrectResult == 0) && (result != 0) )) - { - Fail("ERROR: isalnum returned %i instead of %i for character " - " %c.\n", - result, - testCases[i].CorrectResult, - testCases[i].character); - } - - } - - - PAL_Terminate(); - return PASS; -} - - - - - - - - - - - - - diff --git a/src/pal/tests/palsuite/c_runtime/isalnum/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/isalnum/test1/testinfo.dat deleted file mode 100644 index ba8f07a72..000000000 --- a/src/pal/tests/palsuite/c_runtime/isalnum/test1/testinfo.dat +++ /dev/null @@ -1,19 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = isalnum -Name = Positive Test for isalnum -TYPE = DEFAULT -EXE1 = test1 -Description -= Tests the PAL implementation of the isalnum function -= Check that a number of characters return the correct values for whether -= they are alpha/numeric or not. - - - - - diff --git a/src/pal/tests/palsuite/c_runtime/isalpha/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/isalpha/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/c_runtime/isalpha/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/c_runtime/isalpha/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/isalpha/test1/CMakeLists.txt deleted file mode 100644 index 8033ae07f..000000000 --- a/src/pal/tests/palsuite/c_runtime/isalpha/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_isalpha_test1 - ${SOURCES} -) - -add_dependencies(paltest_isalpha_test1 coreclrpal) - -target_link_libraries(paltest_isalpha_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/isalpha/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/isalpha/test1/test1.cpp deleted file mode 100644 index b494d14a9..000000000 --- a/src/pal/tests/palsuite/c_runtime/isalpha/test1/test1.cpp +++ /dev/null @@ -1,86 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test1.c -** -** Purpose: Tests the PAL implementation of the isalpha function -** Check that a number of characters return the correct -** values for whether they are alpha or not. -** -** -**===================================================================*/ - -#include - -struct testCase -{ - int CorrectResult; - int character; -}; - -int __cdecl main(int argc, char **argv) -{ - - int result; - int i; - - struct testCase testCases[] = - { - {1, 'a'}, - {1, 'z'}, - {1, 'B'}, - {0, '5'}, - {0, '?'}, - {0, 230} - }; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - /* Loop through each case. Check to see if each is alpha or - not. - */ - - for(i = 0; i < sizeof(testCases) / sizeof(struct testCase); i++) - { - - result = isalpha(testCases[i].character); - - /* The return value is 'non-zero' for success. This if condition - * will still work if that non-zero isn't just 1 - */ - if ( ((testCases[i].CorrectResult == 1) && (result == 0)) || - ( (testCases[i].CorrectResult == 0) && (result != 0) )) - { - Fail("ERROR: isalpha returned %i instead of %i for character " - "%c.\n", - result, - testCases[i].CorrectResult, - testCases[i].character); - } - - } - - - PAL_Terminate(); - return PASS; -} - - - - - - - - - - - - - diff --git a/src/pal/tests/palsuite/c_runtime/isalpha/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/isalpha/test1/testinfo.dat deleted file mode 100644 index 7d508366e..000000000 --- a/src/pal/tests/palsuite/c_runtime/isalpha/test1/testinfo.dat +++ /dev/null @@ -1,19 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = isalpha -Name = Positive Test for isalpha -TYPE = DEFAULT -EXE1 = test1 -Description -= Tests the PAL implementation of the isalpha function -= Check that a number of characters return the correct values for whether -= they are alpha or not. - - - - - diff --git a/src/pal/tests/palsuite/c_runtime/isdigit/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/isdigit/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/c_runtime/isdigit/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/c_runtime/isdigit/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/isdigit/test1/CMakeLists.txt deleted file mode 100644 index 8f74b2d0c..000000000 --- a/src/pal/tests/palsuite/c_runtime/isdigit/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_isdigit_test1 - ${SOURCES} -) - -add_dependencies(paltest_isdigit_test1 coreclrpal) - -target_link_libraries(paltest_isdigit_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/isdigit/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/isdigit/test1/test1.cpp deleted file mode 100644 index ad2344827..000000000 --- a/src/pal/tests/palsuite/c_runtime/isdigit/test1/test1.cpp +++ /dev/null @@ -1,47 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: Checks every character against the known range of digits. -** -** -**==========================================================================*/ - - -#include - -int __cdecl main(int argc, char *argv[]) -{ - int i; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - for (i=0; i<256; i++) - { - if (isdigit(i)) - { - if (i < '0' || i > '9') - { - Fail("ERROR: isdigit returned true for '%c' (%d)!\n", i, i); - } - } - else - { - if (i >= '0' && i <= '9') - { - Fail("ERROR: isdigit returned false for '%c' (%d)!\n", i, i); - } - } - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/isdigit/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/isdigit/test1/testinfo.dat deleted file mode 100644 index eb2373916..000000000 --- a/src/pal/tests/palsuite/c_runtime/isdigit/test1/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = isdigit -Name = Test #1 for isdigit -TYPE = DEFAULT -EXE1 = test1 -Description -=Checks every character against the known range of digits. diff --git a/src/pal/tests/palsuite/c_runtime/islower/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/islower/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/c_runtime/islower/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/c_runtime/islower/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/islower/test1/CMakeLists.txt deleted file mode 100644 index a02dc7088..000000000 --- a/src/pal/tests/palsuite/c_runtime/islower/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_islower_test1 - ${SOURCES} -) - -add_dependencies(paltest_islower_test1 coreclrpal) - -target_link_libraries(paltest_islower_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/islower/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/islower/test1/test1.cpp deleted file mode 100644 index c8e877b70..000000000 --- a/src/pal/tests/palsuite/c_runtime/islower/test1/test1.cpp +++ /dev/null @@ -1,85 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test1.c -** -** Purpose: Tests the PAL implementation of the islower function -** Check that a number of characters return the correct -** values for whether they are lower case or not. -** -** -**===================================================================*/ - -#include - -struct testCase -{ - int CorrectResult; - int character; -}; - -int __cdecl main(int argc, char **argv) -{ - - int result; - int i; - - struct testCase testCases[] = - { - {1, 'a'}, /* Basic cases */ - {1, 'z'}, - {0, 'B'}, /* Lower case */ - {0, '?'}, /* Characters without case */ - {0, 230}, - {0, '5'} - }; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - /* Loop through each case. Check to see if each is lower case or - not. - */ - - for(i = 0; i < sizeof(testCases) / sizeof(struct testCase); i++) - { - - result = islower(testCases[i].character); - - /* The return value is 'non-zero' for success. This if condition - * will still work if that non-zero isn't just 1 - */ - if ( ((testCases[i].CorrectResult == 1) && (result == 0)) || - ( (testCases[i].CorrectResult == 0) && (result != 0) )) - { - Fail("ERROR: islower returned %i instead of %i for " - "character %c.\n", - result, testCases[i].CorrectResult, - testCases[i].character); - } - - } - - - PAL_Terminate(); - return PASS; -} - - - - - - - - - - - - - diff --git a/src/pal/tests/palsuite/c_runtime/islower/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/islower/test1/testinfo.dat deleted file mode 100644 index 49a6fb761..000000000 --- a/src/pal/tests/palsuite/c_runtime/islower/test1/testinfo.dat +++ /dev/null @@ -1,19 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = islower -Name = Positive Test for islower -TYPE = DEFAULT -EXE1 = test1 -Description -= Tests the PAL implementation of the islower function -= Check that a number of characters return the correct values for whether -= they are lower case or not. - - - - - diff --git a/src/pal/tests/palsuite/c_runtime/isprint/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/isprint/CMakeLists.txt deleted file mode 100644 index ef14ea535..000000000 --- a/src/pal/tests/palsuite/c_runtime/isprint/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) - diff --git a/src/pal/tests/palsuite/c_runtime/isprint/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/isprint/test1/CMakeLists.txt deleted file mode 100644 index 6e47a8f69..000000000 --- a/src/pal/tests/palsuite/c_runtime/isprint/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - isprint.cpp -) - -add_executable(paltest_isprint_test1 - ${SOURCES} -) - -add_dependencies(paltest_isprint_test1 coreclrpal) - -target_link_libraries(paltest_isprint_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/isprint/test1/isprint.cpp b/src/pal/tests/palsuite/c_runtime/isprint/test1/isprint.cpp deleted file mode 100644 index 54db666bf..000000000 --- a/src/pal/tests/palsuite/c_runtime/isprint/test1/isprint.cpp +++ /dev/null @@ -1,42 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: isprint.c -** -** Purpose: Positive test the isprint API. -** Call isprint to test if a character is printable -** -** -**============================================================*/ -#include - -int __cdecl main(int argc, char *argv[]) -{ - int err; - int index; - - /*Initialize the PAL environment*/ - err = PAL_Initialize(argc, argv); - if(0 != err) - { - return FAIL; - } - - /*check if the character is printable*/ - for(index = 0x20; index<=0x7E;index++) - { - err = isprint(index); - if(0 == err) - { - Fail("\nFailed to call isprint API to check " - "printable character from 0x20 to 0x7E!\n"); - } - } - - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/isprint/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/isprint/test1/testinfo.dat deleted file mode 100644 index c9b9ec07e..000000000 --- a/src/pal/tests/palsuite/c_runtime/isprint/test1/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = miscellaneous -Function = isprint -Name = Positive test for isprint API to check if a character is printable -TYPE = DEFAULT -EXE1 = isprint -Description -=Test the isprint to check if a character is printable diff --git a/src/pal/tests/palsuite/c_runtime/isprint/test2/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/isprint/test2/CMakeLists.txt deleted file mode 100644 index bcecac10f..000000000 --- a/src/pal/tests/palsuite/c_runtime/isprint/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test2.cpp -) - -add_executable(paltest_isprint_test2 - ${SOURCES} -) - -add_dependencies(paltest_isprint_test2 coreclrpal) - -target_link_libraries(paltest_isprint_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/isprint/test2/test2.cpp b/src/pal/tests/palsuite/c_runtime/isprint/test2/test2.cpp deleted file mode 100644 index 2170c47a1..000000000 --- a/src/pal/tests/palsuite/c_runtime/isprint/test2/test2.cpp +++ /dev/null @@ -1,59 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: isprint.c -** -** Purpose: Negative test for the isprint API. Call isprint -** to test if out of range characters are -** not printable. -** -** -**============================================================*/ -#include - -int __cdecl main(int argc, char *argv[]) -{ - int err; - - /*Initialize the PAL environment*/ - err = PAL_Initialize(argc, argv); - if(0 != err) - { - return FAIL; - } - - /*check that function fails for values that are not printable*/ - err = isprint(0x15); - if(err) - { - Fail("\nSucceeded when it should have failed because 0x15 " - "is not in the range of printable characters\n"); - } - - err = isprint(0xAA); - if(err) - { - Fail("\nSucceeded when it should have failed because 0xAA " - "is not in the range of printable characters\n"); - } - - /* check carriage return */ - if(0 != isprint(0x0d)) - { - Fail("\nSucceeded when it should have failed because 0x0d " - "is not in the range of printable characters\n"); - } - - /* check line feed */ - if(0 != isprint(0x0a)) - { - Fail("\nSucceeded when it should have failed because 0x0a " - "is not in the range of printable characters\n"); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/isprint/test2/testinfo.dat b/src/pal/tests/palsuite/c_runtime/isprint/test2/testinfo.dat deleted file mode 100644 index e115278ed..000000000 --- a/src/pal/tests/palsuite/c_runtime/isprint/test2/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = miscellaneous -Function = isprint -Name = Test isprint API to check if out of range characters are not printable. -TYPE = DEFAULT -EXE1 = test2 -Description -=Test the isprint function to verify that out of range characters -=are not printable. diff --git a/src/pal/tests/palsuite/c_runtime/isspace/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/isspace/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/c_runtime/isspace/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/c_runtime/isspace/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/isspace/test1/CMakeLists.txt deleted file mode 100644 index ee6c8f3ef..000000000 --- a/src/pal/tests/palsuite/c_runtime/isspace/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_isspace_test1 - ${SOURCES} -) - -add_dependencies(paltest_isspace_test1 coreclrpal) - -target_link_libraries(paltest_isspace_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/isspace/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/isspace/test1/test1.cpp deleted file mode 100644 index 6cd1ce878..000000000 --- a/src/pal/tests/palsuite/c_runtime/isspace/test1/test1.cpp +++ /dev/null @@ -1,82 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: Test #1 for the isspace function -** -** -**==========================================================================*/ - - - -#include - -struct testCase -{ - long result; - char avalue; -}; - - - -int __cdecl main(int argc, char *argv[]) -{ - int i=0; - long result = 0; - - /* - * A structures of the testcases to be tested with - * isspace function - */ - struct testCase testCases[] = - { - {1,'\n'}, - {1,'\t'}, - {1,'\r'}, - {1,'\v'}, - {1,'\f'}, - {1,' '}, - {0,'a'}, - {0,'A'}, - {0,'z'}, - {0,'Z'}, - {0,'r'}, - {0,'R'}, - {0,'0'}, - {0,'*'}, - {0,3} - }; - - /* - * Initialize the PAL - */ - if ( 0 != PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - /* Loop through the testcases */ - for (i=0; i0, check through a list of the known space characters to ensure that it -= is really a space. Also, when it returns <=0, ensure that that character -= isn't a space. diff --git a/src/pal/tests/palsuite/c_runtime/isupper/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/isupper/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/c_runtime/isupper/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/c_runtime/isupper/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/isupper/test1/CMakeLists.txt deleted file mode 100644 index 96742792c..000000000 --- a/src/pal/tests/palsuite/c_runtime/isupper/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_isupper_test1 - ${SOURCES} -) - -add_dependencies(paltest_isupper_test1 coreclrpal) - -target_link_libraries(paltest_isupper_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/isupper/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/isupper/test1/test1.cpp deleted file mode 100644 index b88bcc4a7..000000000 --- a/src/pal/tests/palsuite/c_runtime/isupper/test1/test1.cpp +++ /dev/null @@ -1,88 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test1.c -** -** Purpose: Tests the PAL implementation of the isupper function -** Check that a number of characters return the correct -** values for whether they are upper case or not. -** -** -**===================================================================*/ - -#include - -struct testCase -{ - int CorrectResult; - int character; -}; - -int __cdecl main(int argc, char **argv) -{ - - int result; - int i; - - /* Note: 1 iff char = A..Z - 0 iff char =~ A..Z - */ - - struct testCase testCases[] = - { - {1, 'A'}, /* Basic cases */ - {1, 'Z'}, - {0, 'b'}, /* Lower case */ - {0, '?'}, /* Characters without case */ - {0, 230}, - {0, '5'} - }; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - /* Loop through each case. Check to see if each is upper case or - not. - */ - - for(i = 0; i < sizeof(testCases) / sizeof(struct testCase); i++) - { - result = isupper(testCases[i].character); - - /* The return value is 'non-zero' for success. This if condition - * will still work if that non-zero isn't just 1 - */ - if ( ((testCases[i].CorrectResult == 1) && (result == 0)) || - ( (testCases[i].CorrectResult == 0) && (result != 0) )) - { - Fail("ERROR: isupper returned %i instead of %i for " - "character %c.\n", - result,testCases[i].CorrectResult, - testCases[i].character); - } - - } - - - PAL_Terminate(); - return PASS; -} - - - - - - - - - - - - - diff --git a/src/pal/tests/palsuite/c_runtime/isupper/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/isupper/test1/testinfo.dat deleted file mode 100644 index fb2648a52..000000000 --- a/src/pal/tests/palsuite/c_runtime/isupper/test1/testinfo.dat +++ /dev/null @@ -1,19 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = isupper -Name = Positive Test for isupper -TYPE = DEFAULT -EXE1 = test1 -Description -= Tests the PAL implementation of the isupper function -= Check that a number of characters return the correct values for whether -= they are upper case or not. - - - - - diff --git a/src/pal/tests/palsuite/c_runtime/iswdigit/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/iswdigit/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/c_runtime/iswdigit/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/c_runtime/iswdigit/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/iswdigit/test1/CMakeLists.txt deleted file mode 100644 index 723a26a5b..000000000 --- a/src/pal/tests/palsuite/c_runtime/iswdigit/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_iswdigit_test1 - ${SOURCES} -) - -add_dependencies(paltest_iswdigit_test1 coreclrpal) - -target_link_libraries(paltest_iswdigit_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/iswdigit/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/iswdigit/test1/test1.cpp deleted file mode 100644 index 1cf94c5d1..000000000 --- a/src/pal/tests/palsuite/c_runtime/iswdigit/test1/test1.cpp +++ /dev/null @@ -1,69 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test1.c (iswdigit) -** -** Purpose: Tests the PAL implementation of the iswdigit function. -** Tests the passed parameter to iswdigit for being a -** digit ('0' - '9'). Also passes non-digits to make sure -** iswdigit picks them up. -** NOTE: There are three ASCII values that under Windows, -** iswdigit will return non-zero, indicating a digit. -** These values are quite apparently not digits: -** 178, 179, 185. -** These are not tested. -** -** -**===================================================================*/ - -#include - -int __cdecl main(int argc, char **argv) -{ - - int result; - int i; - - wchar_t passTestCases[] = {'1','2','3','4','5','6','7','8','9'}; - wchar_t failTestCases[] = {'a','b','p','$','?',234}; - - if ((PAL_Initialize(argc, argv)) != 0) - { - return (FAIL); - } - - /* Loop through each case. Testing if each is a digit. */ - for(i = 0; i < sizeof(passTestCases) / sizeof(wchar_t); i++) - { - result = iswdigit(passTestCases[i]); - - /* The return value is 'non-zero' indicates digit*/ - if (result == 0) - { - Fail("ERROR: iswdigit returned \"%d\" instead indicating" - " \"%c\" is not a digit\n", - result, - passTestCases[i]); - } - } - - /* Loop through each case. Testing if each is a not a digit. */ - for(i = 0; i < sizeof(failTestCases) / sizeof(wchar_t); i++) - { - result = iswdigit(failTestCases[i]); - - /* The return value is 'zero' indicates non-digit*/ - if (result != 0) - { - Fail("ERROR: iswdigit returned \"%d\", indicating" - " \"%c\" is a digit\n", - result, - failTestCases[i]); - } - } - PAL_Terminate(); - return (PASS); -} diff --git a/src/pal/tests/palsuite/c_runtime/iswdigit/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/iswdigit/test1/testinfo.dat deleted file mode 100644 index 345c9d566..000000000 --- a/src/pal/tests/palsuite/c_runtime/iswdigit/test1/testinfo.dat +++ /dev/null @@ -1,19 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = iswdigit -Name = Positive Test for iswdigit -TYPE = DEFAULT -EXE1 = test1 -Description -= Tests the PAL implementation of the iswdigit function. -= Tests the passed parameter to iswdigit for being a -= digit ('0' - '9'). Also passes non-digits to make sure -= iswdigit picks them up. -= NOTE: There are three ASCII values that under Windows, -= iswdigit will return non-zero, indicating a digit. -= These values are quite apparently not digits: -= 178, 179, 185. These are not tested. diff --git a/src/pal/tests/palsuite/c_runtime/iswprint/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/iswprint/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/c_runtime/iswprint/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/c_runtime/iswprint/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/iswprint/test1/CMakeLists.txt deleted file mode 100644 index 50c6f741f..000000000 --- a/src/pal/tests/palsuite/c_runtime/iswprint/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_iswprint_test1 - ${SOURCES} -) - -add_dependencies(paltest_iswprint_test1 coreclrpal) - -target_link_libraries(paltest_iswprint_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/iswprint/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/iswprint/test1/test1.cpp deleted file mode 100644 index 08a985b2d..000000000 --- a/src/pal/tests/palsuite/c_runtime/iswprint/test1/test1.cpp +++ /dev/null @@ -1,59 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test1.c -** -** Purpose: Tests iswprint with all wide characters, ensuring they are -** consistent with GetStringTypeExW. -** -** -**===================================================================*/ - -#include - -int __cdecl main(int argc, char **argv) -{ - WORD Info; - int ret; - int i; - WCHAR ch; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - for (i=0; i<=0xFFFF; i++) - { - ch = i; - ret = GetStringTypeExW(LOCALE_USER_DEFAULT, CT_CTYPE1, &ch, 1, &Info); - if (!ret) - { - Fail("GetStringTypeExW failed to get information for %#X!\n", ch); - } - - ret = iswprint(ch); - if (Info & (C1_BLANK|C1_PUNCT|C1_ALPHA|C1_DIGIT)) - { - if (!ret) - { - Fail("iswprint returned incorrect results for %#X: " - "expected printable\n", ch); - } - } - else - { - if (ret) - { - Fail("iswprint returned incorrect results for %#X: " - "expected non-printable\n", ch); - } - } - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/iswprint/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/iswprint/test1/testinfo.dat deleted file mode 100644 index c425967b9..000000000 --- a/src/pal/tests/palsuite/c_runtime/iswprint/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = iswprint -Name = Positive Test for iswprint -TYPE = DEFAULT -EXE1 = test1 -Description -=Tests iswprint with all wide characters, ensuring they are -=consistent with GetStringTypeExW. diff --git a/src/pal/tests/palsuite/c_runtime/iswspace/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/iswspace/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/c_runtime/iswspace/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/c_runtime/iswspace/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/iswspace/test1/CMakeLists.txt deleted file mode 100644 index 02f6acd72..000000000 --- a/src/pal/tests/palsuite/c_runtime/iswspace/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_iswspace_test1 - ${SOURCES} -) - -add_dependencies(paltest_iswspace_test1 coreclrpal) - -target_link_libraries(paltest_iswspace_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/iswspace/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/iswspace/test1/test1.cpp deleted file mode 100644 index c58997812..000000000 --- a/src/pal/tests/palsuite/c_runtime/iswspace/test1/test1.cpp +++ /dev/null @@ -1,78 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: Tests iswspace with a range of wide characters. -** -** -** -**==========================================================================*/ - - - -#include - -int __cdecl main(int argc, char *argv[]) -{ - int ret; - int i; - - struct testChars - { - WCHAR charValue; - int result; - }; - - /* create an array of chars that test the range of possible characters */ - struct testChars testChars1[] = - { - {0x00,0}, /* null */ - {0x09,1}, /* open circle */ - {0x0D,1}, /* musical note */ - {0x20,1}, /* space */ - {0x3F,0}, /* ? */ - {0x5E,0}, /* ^ */ - {0x7B,0}, /* { */ - {0x86,0}, /* a with circle on top */ - {0x9F,0}, /* slanted f */ - {0xC4,0}, /* long dash */ - {0xE5,0} /* sigma */ - }; - - if (0 != PAL_Initialize(argc, argv)) - { - return FAIL; - } - - for (i = 0; i < (sizeof(testChars1) / sizeof(struct testChars)); i++) - { - - ret = iswspace(testChars1[i].charValue); - - if((ret==0) && (testChars1[i].result != 0)) - { - Fail("ERROR: wide character %#X IS considered a space, " - "but iswspace did NOT indicate it was one with error %u.\n", - testChars1[i].charValue, - GetLastError()); - } - - if((ret!=0) && (testChars1[i].result == 0)) - { - Fail("ERROR: wide character %#X is NOT considered a space, " - "but iswspace DID indicate it was a space with error %u.\n", - testChars1[i].charValue, - GetLastError()); - } - } - - - PAL_Terminate(); - - return PASS; -} - diff --git a/src/pal/tests/palsuite/c_runtime/iswspace/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/iswspace/test1/testinfo.dat deleted file mode 100644 index 0368052b9..000000000 --- a/src/pal/tests/palsuite/c_runtime/iswspace/test1/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = iswspace -Name = Positive Test for iswspace -TYPE = DEFAULT -EXE1 = test1 -Description -=Tests iswspace with a range of wide characters. diff --git a/src/pal/tests/palsuite/c_runtime/iswupper/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/iswupper/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/c_runtime/iswupper/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/c_runtime/iswupper/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/iswupper/test1/CMakeLists.txt deleted file mode 100644 index 301bd145d..000000000 --- a/src/pal/tests/palsuite/c_runtime/iswupper/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_iswupper_test1 - ${SOURCES} -) - -add_dependencies(paltest_iswupper_test1 coreclrpal) - -target_link_libraries(paltest_iswupper_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/iswupper/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/iswupper/test1/test1.cpp deleted file mode 100644 index a01686be4..000000000 --- a/src/pal/tests/palsuite/c_runtime/iswupper/test1/test1.cpp +++ /dev/null @@ -1,91 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test1.c -** -** Purpose: Tests the PAL implementation of the iswupper function -** Check that a number of characters return the correct -** values for whether they are upper case or not. -** -** -**===================================================================*/ - -#define UNICODE -#include - - -struct testCase -{ - int CorrectResult; - WCHAR character; -}; - -int __cdecl main(int argc, char **argv) -{ - - int result; - int i; - - /* Note: 1 iff char = A..Z - 0 iff char =~ A..Z - */ - - struct testCase testCases[] = - { - {1, 'A'}, /* Basic cases */ - {1, 'Z'}, - {0, 'b'}, /* Lower case */ - {0, '?'}, /* Characters without case */ - {0, 230} - }; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - /* Loop through each case. Check to see if each is upper case or - not. - */ - - for(i = 0; i < sizeof(testCases) / sizeof(struct testCase); i++) - { - - result = iswupper(testCases[i].character); - - /* The return value is 'non-zero' for success. This if condition - * will still work if that non-zero isn't just 1 - */ - if ( ((testCases[i].CorrectResult == 1) && (result == 0)) || - ( (testCases[i].CorrectResult == 0) && (result != 0) )) - { - Fail("ERROR: iswupper returned %i instead of %i for " - "character %c.\n", - result, - testCases[i].CorrectResult, - testCases[i].character); - } - - } - - - PAL_Terminate(); - return PASS; -} - - - - - - - - - - - - - diff --git a/src/pal/tests/palsuite/c_runtime/iswupper/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/iswupper/test1/testinfo.dat deleted file mode 100644 index 22131e40a..000000000 --- a/src/pal/tests/palsuite/c_runtime/iswupper/test1/testinfo.dat +++ /dev/null @@ -1,19 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = isupper -Name = Positive Test for iswupper -TYPE = DEFAULT -EXE1 = test1 -Description -= Tests the PAL implementation of the iswupper function -= Check that a number of characters return the correct values for whether -= they are upper case or not. - - - - - diff --git a/src/pal/tests/palsuite/c_runtime/iswxdigit/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/iswxdigit/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/c_runtime/iswxdigit/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/c_runtime/iswxdigit/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/iswxdigit/test1/CMakeLists.txt deleted file mode 100644 index 6809f5a2d..000000000 --- a/src/pal/tests/palsuite/c_runtime/iswxdigit/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_iswxdigit_test1 - ${SOURCES} -) - -add_dependencies(paltest_iswxdigit_test1 coreclrpal) - -target_link_libraries(paltest_iswxdigit_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/iswxdigit/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/iswxdigit/test1/test1.cpp deleted file mode 100644 index 73ad49585..000000000 --- a/src/pal/tests/palsuite/c_runtime/iswxdigit/test1/test1.cpp +++ /dev/null @@ -1,61 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test1.c -** -** Purpose: Tests iswxdigit with every possible wide character, ensuring it -** returns the correct results. -** -** -**===================================================================*/ - -#include - -/* - * These are the only wide characters Win2000 recogonizes as valid hex digits. - */ -WCHAR ValidHexDigits[] = -{ - 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70, 97, 98, 99, 100, - 101, 102, 65296, 65297, 65298, 65299, 65300, 65301, 65302, 65303, 65304, 65305, - 65313, 65314, 65315, 65316, 65317, 65318, 65345, 65346, 65347, 65348, 65349, 65350, - 0 -}; - -int __cdecl main(int argc, char **argv) -{ - int i; - WCHAR c; - int ret; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - for (i=0; i<=0xFFFF; i++) - { - ret = iswxdigit(i); - c = (WCHAR) i; - - if (ret) - { - if (wcschr(ValidHexDigits, c) == NULL) - { - /* iswxdigit says its a hex digit. We know better */ - Fail("iswxdigit incorrectly found %#x to be a hex digit!\n", c); - } - } - else if (wcschr(ValidHexDigits, c) != NULL && c != 0) - { - /* iswxdigit says it isn't a hex digit. We know better */ - Fail("iswxdigit failed to find %#x to be a hex digit!\n", c); - } - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/iswxdigit/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/iswxdigit/test1/testinfo.dat deleted file mode 100644 index 2b683c4eb..000000000 --- a/src/pal/tests/palsuite/c_runtime/iswxdigit/test1/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = iswxdigit -Name = iswxdigit test #1 -TYPE = DEFAULT -EXE1 = test1 -Description -=Tests iswxdigit with every possible wide character, ensuring it -=returns the correct results. - diff --git a/src/pal/tests/palsuite/c_runtime/isxdigit/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/isxdigit/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/c_runtime/isxdigit/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/c_runtime/isxdigit/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/isxdigit/test1/CMakeLists.txt deleted file mode 100644 index cfb0e91e9..000000000 --- a/src/pal/tests/palsuite/c_runtime/isxdigit/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_isxdigit_test1 - ${SOURCES} -) - -add_dependencies(paltest_isxdigit_test1 coreclrpal) - -target_link_libraries(paltest_isxdigit_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/isxdigit/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/isxdigit/test1/test1.cpp deleted file mode 100644 index be25af233..000000000 --- a/src/pal/tests/palsuite/c_runtime/isxdigit/test1/test1.cpp +++ /dev/null @@ -1,58 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: Run through every possible character. For each time that -** isxdigit returns: -** 1, check through a list of the known hex characters to ensure that it -** is really a hex char. Also, when it returns 0, ensure that that character -** isn't a hex character. -** -** -**==========================================================================*/ - - - -#include - - -int __cdecl main(int argc, char *argv[]) -{ - int i; - - /* Initialize the PAL */ - if ( 0 != PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - /* Loop through each character and call isxdigit for each character */ - for (i=1; i<256; i++) - { - - if (isxdigit(i) == 0) - { - if( ((i>=48) && (i<=57)) || ((i>=97) && (i<=102)) || - ((i>=65) && (i<=70)) ) - { - Fail("ERROR: isxdigit() returns true for '%c' (%d)\n", i, i); - } - } - else - { - if( ((i<48) && (i>58)) || ((i<97) && (i>102)) || - ((i<65) && (i>70)) ) - { - Fail("ERROR: isxdigit() returns false for '%c' (%d)\n", i, i); - } - } - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/isxdigit/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/isxdigit/test1/testinfo.dat deleted file mode 100644 index fd031f076..000000000 --- a/src/pal/tests/palsuite/c_runtime/isxdigit/test1/testinfo.dat +++ /dev/null @@ -1,15 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = isxdigit -Name = Positive Test for isxdigit -TYPE = DEFAULT -EXE1 = test1 -Description -= Run through every possible character. For each time that isxdigit returns -= 1, check through a list of the known hex characters to ensure that it -= is really a hex char. Also, when it returns 0, ensure that that character -= isn't a hex character. diff --git a/src/pal/tests/palsuite/c_runtime/labs/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/labs/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/c_runtime/labs/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/c_runtime/labs/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/labs/test1/CMakeLists.txt deleted file mode 100644 index 70d1b5ee6..000000000 --- a/src/pal/tests/palsuite/c_runtime/labs/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_labs_test1 - ${SOURCES} -) - -add_dependencies(paltest_labs_test1 coreclrpal) - -target_link_libraries(paltest_labs_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/labs/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/labs/test1/test1.cpp deleted file mode 100644 index 41f85226e..000000000 --- a/src/pal/tests/palsuite/c_runtime/labs/test1/test1.cpp +++ /dev/null @@ -1,65 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test1.c -** -** Purpose: Call labs on a series of values -- negative, positive, zero, -** and the largest negative value of a LONG. Ensure that they are all -** changed properly to their absoulte value. -** -** -**===================================================================*/ - -#include - -struct testCase -{ - LONG LongValue; - LONG AbsoluteLongValue; -}; - -int __cdecl main(int argc, char **argv) -{ - - LONG result=0; - int i=0; - - struct testCase testCases[] = - { - {1234, 1234}, - {-1234, 1234}, - {0, 0}, - {-2147483647, 2147483647}, /* Max value to abs */ - {2147483647, 2147483647} - }; - - if (0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - /* Loop through each case. Call labs on each LONG and ensure that - the resulting value is correct. - */ - - for(i = 0; i < sizeof(testCases) / sizeof(struct testCase); i++) - { - /* Absolute value on a LONG */ - result = labs(testCases[i].LongValue); - - if (testCases[i].AbsoluteLongValue != result) - { - Fail("ERROR: labs took the absoulte value of '%d' to be '%d' " - "instead of %d.\n", - testCases[i].LongValue, - result, - testCases[i].AbsoluteLongValue); - } - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/labs/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/labs/test1/testinfo.dat deleted file mode 100644 index c385aa76b..000000000 --- a/src/pal/tests/palsuite/c_runtime/labs/test1/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = labs -Name = Series of tests for labs: positive, negative, zero, maximum long value. -TYPE = DEFAULT -EXE1 = test1 -Description -= Call labs on a series of values -- negative, positive, zero, -= and the largest negative value of a long. Ensure that they are all -= changed properly to their absoulte value. diff --git a/src/pal/tests/palsuite/c_runtime/llabs/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/llabs/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/c_runtime/llabs/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/c_runtime/llabs/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/llabs/test1/CMakeLists.txt deleted file mode 100644 index 2885109b5..000000000 --- a/src/pal/tests/palsuite/c_runtime/llabs/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_llabs_test1 - ${SOURCES} -) - -add_dependencies(paltest_llabs_test1 coreclrpal) - -target_link_libraries(paltest_llabs_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/llabs/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/llabs/test1/test1.cpp deleted file mode 100644 index 044e22f13..000000000 --- a/src/pal/tests/palsuite/c_runtime/llabs/test1/test1.cpp +++ /dev/null @@ -1,65 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test1.c -** -** Purpose: Call llabs on a series of values -- negative, positive, -** zero, and the largest negative value of an __int64. Ensure that -** they are all changed properly to their absoulte value. -** -** -**===================================================================*/ - -#include - -struct testCase -{ - __int64 LongLongValue; - __int64 AbsoluteLongLongValue; -}; - -int __cdecl main(int argc, char **argv) -{ - - __int64 result=0; - int i=0; - - struct testCase testCases[] = - { - {1234, 1234}, - {-1234, 1234}, - {0, 0}, - {-9223372036854775807LL, 9223372036854775807LL}, /* Max value to abs */ - {9223372036854775807LL, 9223372036854775807LL} - }; - - if (0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - /* Loop through each case. Call llabs on each __int64 and ensure that - the resulting value is correct. - */ - - for(i = 0; i < sizeof(testCases) / sizeof(struct testCase); i++) - { - /* Absolute value on an __int64 */ - result = llabs(testCases[i].LongLongValue); - - if (testCases[i].AbsoluteLongLongValue != result) - { - Fail("ERROR: llabs took the absoulte value of '%d' to be '%d' " - "instead of %d.\n", - testCases[i].LongLongValue, - result, - testCases[i].AbsoluteLongLongValue); - } - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/llabs/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/llabs/test1/testinfo.dat deleted file mode 100644 index b1b76377b..000000000 --- a/src/pal/tests/palsuite/c_runtime/llabs/test1/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = labs -Name = Series of tests for labs: positive, negative, zero, maximum __int64 value. -TYPE = DEFAULT -EXE1 = test1 -Description -= Call llabs on a series of values -- negative, positive, zero, -= and the largest negative value of an __int64. Ensure that they are all -= changed properly to their absoulte value. diff --git a/src/pal/tests/palsuite/c_runtime/localtime/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/localtime/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/c_runtime/localtime/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/c_runtime/localtime/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/localtime/test1/CMakeLists.txt deleted file mode 100644 index 55b42585c..000000000 --- a/src/pal/tests/palsuite/c_runtime/localtime/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_localtime_test1 - ${SOURCES} -) - -add_dependencies(paltest_localtime_test1 coreclrpal) - -target_link_libraries(paltest_localtime_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/localtime/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/localtime/test1/test1.cpp deleted file mode 100644 index a993a17f6..000000000 --- a/src/pal/tests/palsuite/c_runtime/localtime/test1/test1.cpp +++ /dev/null @@ -1,69 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test1.c (localtime) -** -** Purpose: Tests the PAL implementation of the localtime function. -** localtime() is passed a date in seconds, since January 01 -** 1970 midnight, UTC. localtime() converts the time to the -** tm struct, those values are tested for validity. -** -** -**===================================================================*/ -#include - -int __cdecl main(int argc, char **argv) -{ - time_t dates[] ={1003327482, // Oct 17, 2001 10:04:42 am - 701307301, // March 22, 1992 6:35:01 pm - 973620900, // Nov 07, 2000 1:15:00 pm - 924632589, // April 20, 1999 2:23:09 pm - 951934989}; // March 01, 2000 1:23:09 pm - struct tm * converted_date; - int i; - - if (PAL_Initialize(argc, argv) != 0) - - return (FAIL); - - /*Convert from time_t to struct tm*/ - for ( i=0; i < (sizeof(dates)/sizeof(time_t)); i++) - { - converted_date = localtime(&dates[i]); - - if ((converted_date->tm_hour < 0) || (converted_date->tm_hour > 23)) - { - Fail("ERROR: localtime returned %d for tm_hour\n", converted_date->tm_hour); - } - if ((converted_date->tm_mday < 1) || (converted_date->tm_mday > 31)) - { - Fail("ERROR: localtime returned %d for tm_mday\n",converted_date->tm_mday); - } - if ((converted_date->tm_min < 0) || (converted_date->tm_min > 59)) - { - Fail("ERROR: localtime returned %d for tm_min\n",converted_date->tm_min); - } - if ((converted_date->tm_mon < 0) || (converted_date->tm_mon > 11)) - { - Fail("ERROR: localtime returned %d for tm_mon\n",converted_date->tm_mon); - } - if ((converted_date->tm_sec < 0) || (converted_date->tm_sec > 59)) - { - Fail("ERROR: localtime returned %d for tm_sec\n",converted_date->tm_sec); - } - if ((converted_date->tm_wday < 0) || (converted_date->tm_wday > 6 )) - { - Fail("ERROR: localtime returned %d for tm_wday\n",converted_date->tm_wday); - } - if ((converted_date->tm_yday < 0) || (converted_date->tm_yday > 365)) - { - Fail("ERROR: localtime returned %d for tm_yday\n",converted_date->tm_yday); - } - } - - PAL_Terminate(); - return (PASS); -} diff --git a/src/pal/tests/palsuite/c_runtime/localtime/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/localtime/test1/testinfo.dat deleted file mode 100644 index 63f7fcda9..000000000 --- a/src/pal/tests/palsuite/c_runtime/localtime/test1/testinfo.dat +++ /dev/null @@ -1,15 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = localtime -Name = Positive Test for localtime -TYPE = DEFAULT -EXE1 = test1 -Description -= Tests the PAL implementation of the localtime function. -= localtime() is passed a date in seconds, since January 01 -= 1970 midnight, UTC. localtime() converts the time to the -= tm struct, those values are tested for validity. diff --git a/src/pal/tests/palsuite/c_runtime/log/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/log/CMakeLists.txt deleted file mode 100644 index 5e1ef7f28..000000000 --- a/src/pal/tests/palsuite/c_runtime/log/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) diff --git a/src/pal/tests/palsuite/c_runtime/log/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/log/test1/CMakeLists.txt deleted file mode 100644 index 15a45edb6..000000000 --- a/src/pal/tests/palsuite/c_runtime/log/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_log_test1 - ${SOURCES} -) - -add_dependencies(paltest_log_test1 coreclrpal) - -target_link_libraries(paltest_log_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/log/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/log/test1/test1.cpp deleted file mode 100644 index eea592dd4..000000000 --- a/src/pal/tests/palsuite/c_runtime/log/test1/test1.cpp +++ /dev/null @@ -1,140 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test1.c -** -** Purpose: Tests log with a normal set of values. -** -**===================================================================*/ - -#include - -// binary64 (double) has a machine epsilon of 2^-52 (approx. 2.22e-16). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-50 (approx. 8.88e-16) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (15-17 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxxxxxxxxxx will use -// PAL_EPSILON for the variance, while an expected result in the format of 0.0xxxxxxxxxxxxxxxxx -// will use PAL_EPSILON / 10 and and expected result in the format of x.xxxxxxxxxxxxxxxx will -// use PAL_EPSILON * 10. -#define PAL_EPSILON 8.8817841970012523e-16 - -#define PAL_NAN sqrt(-1.0) -#define PAL_POSINF -log(0.0) -#define PAL_NEGINF log(0.0) - -/** - * Helper test structure - */ -struct test -{ - double value; /* value to test the function with */ - double expected; /* expected result */ - double variance; /* maximum delta between the expected and actual result */ -}; - -/** - * validate - * - * test validation function - */ -void __cdecl validate(double value, double expected, double variance) -{ - double result = log(value); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - double delta = fabs(result - expected); - - if (delta > variance) - { - Fail("log(%g) returned %20.17g when it should have returned %20.17g", - value, result, expected); - } -} - -/** - * validate - * - * test validation function for values returning NaN - */ -void __cdecl validate_isnan(double value) -{ - double result = log(value); - - if (!_isnan(result)) - { - Fail("log(%g) returned %20.17g when it should have returned %20.17g", - value, result, PAL_NAN); - } -} - -/** - * main - * - * executable entry point - */ -int __cdecl main(int argc, char **argv) -{ - struct test tests[] = - { - /* value expected variance */ - { 0, PAL_NEGINF, 0 }, - { 0.043213918263772250, -3.1415926535897932, PAL_EPSILON * 10 }, // expected: -(pi) - { 0.065988035845312537, -2.7182818284590452, PAL_EPSILON * 10 }, // expected: -(e) - { 0.1, -2.3025850929940457, PAL_EPSILON * 10 }, // expected: -(ln(10)) - { 0.20787957635076191, -1.5707963267948966, PAL_EPSILON * 10 }, // expected: -(pi / 2) - { 0.23629008834452270, -1.4426950408889634, PAL_EPSILON * 10 }, // expected: -(log2(e)) - { 0.24311673443421421, -1.4142135623730950, PAL_EPSILON * 10 }, // expected: -(sqrt(2)) - { 0.32355726390307110, -1.1283791670955126, PAL_EPSILON * 10 }, // expected: -(2 / sqrt(pi)) - { 0.36787944117144232, -1, PAL_EPSILON * 10 }, // expected: -(1) - { 0.45593812776599624, -0.78539816339744831, PAL_EPSILON }, // expected: -(pi / 4) - { 0.49306869139523979, -0.70710678118654752, PAL_EPSILON }, // expected: -(1 / sqrt(2)) - { 0.5, -0.69314718055994531, PAL_EPSILON }, // expected: -(ln(2)) - { 0.52907780826773535, -0.63661977236758134, PAL_EPSILON }, // expected: -(2 / pi) - { 0.64772148514180065, -0.43429448190325183, PAL_EPSILON }, // expected: -(log10(e)) - { 0.72737734929521647, -0.31830988618379067, PAL_EPSILON }, // expected: -(1 / pi) - { 1, 0, PAL_EPSILON }, - { 1.3748022274393586, 0.31830988618379067, PAL_EPSILON }, // expected: 1 / pi - { 1.5438734439711811, 0.43429448190325183, PAL_EPSILON }, // expected: log10(e) - { 1.8900811645722220, 0.63661977236758134, PAL_EPSILON }, // expected: 2 / pi - { 2, 0.69314718055994531, PAL_EPSILON }, // expected: ln(2) - { 2.0281149816474725, 0.70710678118654752, PAL_EPSILON }, // expected: 1 / sqrt(2) - { 2.1932800507380155, 0.78539816339744831, PAL_EPSILON }, // expected: pi / 4 - { 2.7182818284590452, 1, PAL_EPSILON * 10 }, // value: e - { 3.0906430223107976, 1.1283791670955126, PAL_EPSILON * 10 }, // expected: 2 / sqrt(pi) - { 4.1132503787829275, 1.4142135623730950, PAL_EPSILON * 10 }, // expected: sqrt(2) - { 4.2320861065570819, 1.4426950408889634, PAL_EPSILON * 10 }, // expected: log2(e) - { 4.8104773809653517, 1.5707963267948966, PAL_EPSILON * 10 }, // expected: pi / 2 - { 10, 2.3025850929940457, PAL_EPSILON * 10 }, // expected: ln(10) - { 15.154262241479264, 2.7182818284590452, PAL_EPSILON * 10 }, // expected: e - { 23.140692632779269, 3.1415926535897932, PAL_EPSILON * 10 }, // expected: pi - { PAL_POSINF, PAL_POSINF, 0 }, - }; - - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - validate(tests[i].value, tests[i].expected, tests[i].variance); - } - - validate_isnan(PAL_NEGINF); - validate_isnan(PAL_NAN); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/log/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/log/test1/testinfo.dat deleted file mode 100644 index 6b984f6eb..000000000 --- a/src/pal/tests/palsuite/c_runtime/log/test1/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = log -Name = Positive Test for log -TYPE = DEFAULT -EXE1 = test1 -Description -= Passes a series of values to the log() function, -= checking each for the expected result. Also checks -= for proper handling of out-of-range values. diff --git a/src/pal/tests/palsuite/c_runtime/log10/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/log10/CMakeLists.txt deleted file mode 100644 index 5e1ef7f28..000000000 --- a/src/pal/tests/palsuite/c_runtime/log10/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) diff --git a/src/pal/tests/palsuite/c_runtime/log10/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/log10/test1/CMakeLists.txt deleted file mode 100644 index 17c87301e..000000000 --- a/src/pal/tests/palsuite/c_runtime/log10/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_log10_test1 - ${SOURCES} -) - -add_dependencies(paltest_log10_test1 coreclrpal) - -target_link_libraries(paltest_log10_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/log10/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/log10/test1/test1.cpp deleted file mode 100644 index 13711a752..000000000 --- a/src/pal/tests/palsuite/c_runtime/log10/test1/test1.cpp +++ /dev/null @@ -1,146 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================= -** -** Source: test1.c -** -** Purpose: Test to ensure that log10 returns correct values. -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** Fail -** fabs -** _isnan -** -**===========================================================================*/ - -#include - -// binary64 (double) has a machine epsilon of 2^-52 (approx. 2.22e-16). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-50 (approx. 8.88e-16) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (15-17 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxxxxxxxxxx will use -// PAL_EPSILON for the variance, while an expected result in the format of 0.0xxxxxxxxxxxxxxxxx -// will use PAL_EPSILON / 10 and and expected result in the format of x.xxxxxxxxxxxxxxxx will -// use PAL_EPSILON * 10. -#define PAL_EPSILON 8.8817841970012523e-16 - -#define PAL_NAN sqrt(-1.0) -#define PAL_POSINF -log(0.0) -#define PAL_NEGINF log(0.0) - -/** - * Helper test structure - */ -struct test -{ - double value; /* value to test the function with */ - double expected; /* expected result */ - double variance; /* maximum delta between the expected and actual result */ -}; - -/** - * validate - * - * test validation function - */ -void __cdecl validate(double value, double expected, double variance) -{ - double result = log10(value); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - double delta = fabs(result - expected); - - if (delta > variance) - { - Fail("log10(%g) returned %20.17g when it should have returned %20.17g", - value, result, expected); - } -} - -/** - * validate - * - * test validation function for values returning NaN - */ -void __cdecl validate_isnan(double value) -{ - double result = log10(value); - - if (!_isnan(result)) - { - Fail("log10(%g) returned %20.17g when it should have returned %20.17g", - value, result, PAL_NAN); - } -} - -/** - * main - * - * executable entry point - */ -int __cdecl main(int argc, char **argv) -{ - struct test tests[] = - { - /* value expected variance */ - { 0, PAL_NEGINF, 0 }, - { 0.00072178415907472774, -3.1415926535897932, PAL_EPSILON * 10 }, // expected: -(pi) - { 0.0019130141022243176, -2.7182818284590452, PAL_EPSILON * 10 }, // expected: -(e) - { 0.0049821282964407206, -2.3025850929940457, PAL_EPSILON * 10 }, // expected: -(ln(10)) - { 0.026866041001136132, -1.5707963267948966, PAL_EPSILON * 10 }, // expected: -(pi / 2) - { 0.036083192820787210, -1.4426950408889634, PAL_EPSILON * 10 }, // expected: -(log2(e)) - { 0.038528884700322026, -1.4142135623730950, PAL_EPSILON * 10 }, // expected: -(sqrt(2)) - { 0.074408205860642723, -1.1283791670955126, PAL_EPSILON * 10 }, // expected: -(2 / sqrt(pi)) - { 0.1, -1, PAL_EPSILON * 10 }, // expected: -(1) - { 0.16390863613957665, -0.78539816339744831, PAL_EPSILON }, // expected: -(pi / 4) - { 0.19628775993505562, -0.70710678118654752, PAL_EPSILON }, // expected: -(1 / sqrt(2)) - { 0.20269956628651730, -0.69314718055994531, PAL_EPSILON }, // expected: -(ln(2)) - { 0.23087676451600055, -0.63661977236758134, PAL_EPSILON }, // expected: -(2 / pi) - { 0.36787944117144232, -0.43429448190325183, PAL_EPSILON }, // expected: -(log10(e)) - { 0.48049637305186868, -0.31830988618379067, PAL_EPSILON }, // expected: -(1 / pi) - { 1, 0, PAL_EPSILON }, - { 2.0811811619898573, 0.31830988618379067, PAL_EPSILON }, // expected: 1 / pi - { 2.7182818284590452, 0.43429448190325183, PAL_EPSILON }, // expected: log10(e) value: e - { 4.3313150290214525, 0.63661977236758134, PAL_EPSILON }, // expected: 2 / pi - { 4.9334096679145963, 0.69314718055994531, PAL_EPSILON }, // expected: ln(2) - { 5.0945611704512962, 0.70710678118654752, PAL_EPSILON }, // expected: 1 / sqrt(2) - { 6.1009598002416937, 0.78539816339744831, PAL_EPSILON }, // expected: pi / 4 - { 10, 1, PAL_EPSILON * 10 }, - { 13.439377934644400, 1.1283791670955126, PAL_EPSILON * 10 }, // expected: 2 / sqrt(pi) - { 25.954553519470081, 1.4142135623730950, PAL_EPSILON * 10 }, // expected: sqrt(2) - { 27.713733786437790, 1.4426950408889634, PAL_EPSILON * 10 }, // expected: log2(e) - { 37.221710484165167, 1.5707963267948966, PAL_EPSILON * 10 }, // expected: pi / 2 - { 200.71743249053009, 2.3025850929940457, PAL_EPSILON * 10 }, // expected: ln(10) - { 522.73529967043665, 2.7182818284590452, PAL_EPSILON * 10 }, // expected: e - { 1385.4557313670111, 3.1415926535897932, PAL_EPSILON * 10 }, // expected: pi - { PAL_POSINF, PAL_POSINF, 0 }, - }; - - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - validate(tests[i].value, tests[i].expected, tests[i].variance); - } - - validate_isnan(PAL_NEGINF); - validate_isnan(PAL_NAN); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/log10/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/log10/test1/testinfo.dat deleted file mode 100644 index 887bace69..000000000 --- a/src/pal/tests/palsuite/c_runtime/log10/test1/testinfo.dat +++ /dev/null @@ -1,17 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = log10 -Name = Positive Test for log10 -TYPE = DEFAULT -EXE1 = test1 -Description -= Passes a series of values to the log10() function, -= checking each for the expected result. Also checks -= for proper handling of out-of-range values. - - - diff --git a/src/pal/tests/palsuite/c_runtime/log10f/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/log10f/CMakeLists.txt deleted file mode 100644 index 5e1ef7f28..000000000 --- a/src/pal/tests/palsuite/c_runtime/log10f/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) diff --git a/src/pal/tests/palsuite/c_runtime/log10f/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/log10f/test1/CMakeLists.txt deleted file mode 100644 index 6f3358b86..000000000 --- a/src/pal/tests/palsuite/c_runtime/log10f/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.c -) - -add_executable(paltest_log10f_test1 - ${SOURCES} -) - -add_dependencies(paltest_log10f_test1 coreclrpal) - -target_link_libraries(paltest_log10f_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/log10f/test1/test1.c b/src/pal/tests/palsuite/c_runtime/log10f/test1/test1.c deleted file mode 100644 index e7c8c2f28..000000000 --- a/src/pal/tests/palsuite/c_runtime/log10f/test1/test1.c +++ /dev/null @@ -1,144 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================= -** -** Source: test1.c -** -** Purpose: Test to ensure that log10f returns correct values. -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** Fail -** fabs -** _isnanf -** -**===========================================================================*/ - -#include - -// binary32 (float) has a machine epsilon of 2^-23 (approx. 1.19e-07). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-21 (approx. 4.76e-07) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (6-9 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxx will use PAL_EPSILON -// for the variance, while an expected result in the format of 0.0xxxxxxxxx will use -// PAL_EPSILON / 10 and and expected result in the format of x.xxxxxx will use PAL_EPSILON * 10. -#define PAL_EPSILON 4.76837158e-07 - -#define PAL_NAN sqrtf(-1.0f) -#define PAL_POSINF -logf(0.0f) -#define PAL_NEGINF logf(0.0f) - -/** - * Helper test structure - */ -struct test -{ - float value; /* value to test the function with */ - float expected; /* expected result */ - float variance; /* maximum delta between the expected and actual result */ -}; - -/** - * validate - * - * test validation function - */ -void __cdecl validate(float value, float expected, float variance) -{ - float result = log10f(value); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - float delta = fabsf(result - expected); - - if (delta > variance) - { - Fail("log10f(%g) returned %10.9g when it should have returned %10.9g", - value, result, expected); - } -} - -/** - * validate - * - * test validation function for values returning NaN - */ -void __cdecl validate_isnan(float value) -{ - float result = log10f(value); - - if (!_isnanf(result)) - { - Fail("log10f(%g) returned %10.9g when it should have returned %10.9g", - value, result, PAL_NAN); - } -} - -/** - * main - * - * executable entry point - */ -int __cdecl main(int argc, char **argv) -{ - struct test tests[] = - { - /* value expected variance */ - { 0, PAL_NEGINF, 0 }, - { 0.000721784159f, -3.14159265f, PAL_EPSILON * 10 }, // expected: -(pi) - { 0.00191301410f, -2.71828183f, PAL_EPSILON * 10 }, // expected: -(e) - { 0.00498212830f, -2.30258509f, PAL_EPSILON * 10 }, // expected: -(ln(10)) - { 0.0268660410f, -1.57079633f, PAL_EPSILON * 10 }, // expected: -(pi / 2) - { 0.0360831928f, -1.44269504f, PAL_EPSILON * 10 }, // expected: -(logf2(e)) - { 0.0385288847f, -1.41421356f, PAL_EPSILON * 10 }, // expected: -(sqrtf(2)) - { 0.0744082059f, -1.12837917f, PAL_EPSILON * 10 }, // expected: -(2 / sqrtf(pi)) - { 0.1f, -1, PAL_EPSILON * 10 }, // expected: -(1) - { 0.163908636f, -0.785398163f, PAL_EPSILON }, // expected: -(pi / 4) - { 0.196287760f, -0.707106781f, PAL_EPSILON }, // expected: -(1 / sqrtf(2)) - { 0.202699566f, -0.693147181f, PAL_EPSILON }, // expected: -(ln(2)) - { 0.230876765f, -0.636619772f, PAL_EPSILON }, // expected: -(2 / pi) - { 0.367879441f, -0.434294482f, PAL_EPSILON }, // expected: -(log10f(e)) - { 0.480496373f, -0.318309886f, PAL_EPSILON }, // expected: -(1 / pi) - { 1, 0, PAL_EPSILON }, - { 2.08118116f, 0.318309886f, PAL_EPSILON }, // expected: 1 / pi - { 2.71828183f, 0.434294482f, PAL_EPSILON }, // expected: log10f(e) value: e - { 4.33131503f, 0.636619772f, PAL_EPSILON }, // expected: 2 / pi - { 4.93340967f, 0.693147181f, PAL_EPSILON }, // expected: ln(2) - { 5.09456117f, 0.707106781f, PAL_EPSILON }, // expected: 1 / sqrtf(2) - { 6.10095980f, 0.785398163f, PAL_EPSILON }, // expected: pi / 4 - { 10, 1, PAL_EPSILON * 10 }, - { 13.4393779f, 1.12837917f, PAL_EPSILON * 10 }, // expected: 2 / sqrtf(pi) - { 25.9545535f, 1.41421356f, PAL_EPSILON * 10 }, // expected: sqrtf(2) - { 27.7137338f, 1.44269504f, PAL_EPSILON * 10 }, // expected: logf2(e) - { 37.2217105f, 1.57079633f, PAL_EPSILON * 10 }, // expected: pi / 2 - { 200.717432f, 2.30258509f, PAL_EPSILON * 10 }, // expected: ln(10) - { 522.735300f, 2.71828183f, PAL_EPSILON * 10 }, // expected: e - { 1385.45573f, 3.14159265f, PAL_EPSILON * 10 }, // expected: pi - { PAL_POSINF, PAL_POSINF, 0 }, - }; - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - validate(tests[i].value, tests[i].expected, tests[i].variance); - } - - validate_isnan(PAL_NEGINF); - validate_isnan(PAL_NAN); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/log10f/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/log10f/test1/testinfo.dat deleted file mode 100644 index 175ee3ab0..000000000 --- a/src/pal/tests/palsuite/c_runtime/log10f/test1/testinfo.dat +++ /dev/null @@ -1,17 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = log10f -Name = Positive Test for log10f -TYPE = DEFAULT -EXE1 = test1 -Description -= Passes a series of values to the log10f() function, -= checking each for the expected result. Also checks -= for proper handling of out-of-range values. - - - diff --git a/src/pal/tests/palsuite/c_runtime/logf/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/logf/CMakeLists.txt deleted file mode 100644 index 5e1ef7f28..000000000 --- a/src/pal/tests/palsuite/c_runtime/logf/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) diff --git a/src/pal/tests/palsuite/c_runtime/logf/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/logf/test1/CMakeLists.txt deleted file mode 100644 index 2dcfdefde..000000000 --- a/src/pal/tests/palsuite/c_runtime/logf/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.c -) - -add_executable(paltest_logf_test1 - ${SOURCES} -) - -add_dependencies(paltest_logf_test1 coreclrpal) - -target_link_libraries(paltest_logf_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/logf/test1/test1.c b/src/pal/tests/palsuite/c_runtime/logf/test1/test1.c deleted file mode 100644 index 499778e99..000000000 --- a/src/pal/tests/palsuite/c_runtime/logf/test1/test1.c +++ /dev/null @@ -1,139 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test1.c -** -** Purpose: Tests logf with a normal set of values. -** -**===================================================================*/ - -#include - -// binary32 (float) has a machine epsilon of 2^-23 (approx. 1.19e-07). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-21 (approx. 4.76e-07) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (6-9 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxx will use PAL_EPSILON -// for the variance, while an expected result in the format of 0.0xxxxxxxxx will use -// PAL_EPSILON / 10 and and expected result in the format of x.xxxxxx will use PAL_EPSILON * 10. -#define PAL_EPSILON 4.76837158e-07 - -#define PAL_NAN sqrtf(-1.0f) -#define PAL_POSINF -logf(0.0f) -#define PAL_NEGINF logf(0.0f) - -/** - * Helper test structure - */ -struct test -{ - float value; /* value to test the function with */ - float expected; /* expected result */ - float variance; /* maximum delta between the expected and actual result */ -}; - -/** - * validate - * - * test validation function - */ -void __cdecl validate(float value, float expected, float variance) -{ - float result = logf(value); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - float delta = fabsf(result - expected); - - if (delta > variance) - { - Fail("logf(%g) returned %10.9g when it should have returned %10.9g", - value, result, expected); - } -} - -/** - * validate - * - * test validation function for values returning NaN - */ -void __cdecl validate_isnan(float value) -{ - float result = logf(value); - - if (!_isnanf(result)) - { - Fail("logf(%g) returned %10.9g when it should have returned %10.9g", - value, result, PAL_NAN); - } -} - -/** - * main - * - * executable entry point - */ -int __cdecl main(int argc, char **argv) -{ - struct test tests[] = - { - /* value expected variance */ - { 0, PAL_NEGINF, 0 }, - { 0.0432139183f, -3.14159265f, PAL_EPSILON * 10 }, // expected: -(pi) - { 0.0659880358f, -2.71828183f, PAL_EPSILON * 10 }, // expected: -(e) - { 0.1f, -2.30258509f, PAL_EPSILON * 10 }, // expected: -(ln(10)) - { 0.207879576f, -1.57079633f, PAL_EPSILON * 10 }, // expected: -(pi / 2) - { 0.236290088f, -1.44269504f, PAL_EPSILON * 10 }, // expected: -(logf2(e)) - { 0.243116734f, -1.41421356f, PAL_EPSILON * 10 }, // expected: -(sqrtf(2)) - { 0.323557264f, -1.12837917f, PAL_EPSILON * 10 }, // expected: -(2 / sqrtf(pi)) - { 0.367879441f, -1, PAL_EPSILON * 10 }, // expected: -(1) - { 0.455938128f, -0.785398163f, PAL_EPSILON }, // expected: -(pi / 4) - { 0.493068691f, -0.707106781f, PAL_EPSILON }, // expected: -(1 / sqrtf(2)) - { 0.5f, -0.693147181f, PAL_EPSILON }, // expected: -(ln(2)) - { 0.529077808f, -0.636619772f, PAL_EPSILON }, // expected: -(2 / pi) - { 0.647721485f, -0.434294482f, PAL_EPSILON }, // expected: -(log10f(e)) - { 0.727377349f, -0.318309886f, PAL_EPSILON }, // expected: -(1 / pi) - { 1, 0, PAL_EPSILON }, - { 1.37480223f, 0.318309886f, PAL_EPSILON }, // expected: 1 / pi - { 1.54387344f, 0.434294482f, PAL_EPSILON }, // expected: log10f(e) - { 1.89008116f, 0.636619772f, PAL_EPSILON }, // expected: 2 / pi - { 2, 0.693147181f, PAL_EPSILON }, // expected: ln(2) - { 2.02811498f, 0.707106781f, PAL_EPSILON }, // expected: 1 / sqrtf(2) - { 2.19328005f, 0.785398163f, PAL_EPSILON }, // expected: pi / 4 - { 2.71828183f, 1, PAL_EPSILON * 10 }, // value: e - { 3.09064302f, 1.12837917f, PAL_EPSILON * 10 }, // expected: 2 / sqrtf(pi) - { 4.11325038f, 1.41421356f, PAL_EPSILON * 10 }, // expected: sqrtf(2) - { 4.23208611f, 1.44269504f, PAL_EPSILON * 10 }, // expected: logf2(e) - { 4.81047738f, 1.57079633f, PAL_EPSILON * 10 }, // expected: pi / 2 - { 10, 2.30258509f, PAL_EPSILON * 10 }, // expected: ln(10) - { 15.1542622f, 2.71828183f, PAL_EPSILON * 10 }, // expected: e - { 23.1406926f, 3.14159265f, PAL_EPSILON * 10 }, // expected: pi - { PAL_POSINF, PAL_POSINF, 0 }, - }; - - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - validate(tests[i].value, tests[i].expected, tests[i].variance); - } - - validate_isnan(PAL_NEGINF); - validate_isnan(PAL_NAN); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/logf/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/logf/test1/testinfo.dat deleted file mode 100644 index aadfee6c1..000000000 --- a/src/pal/tests/palsuite/c_runtime/logf/test1/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = logf -Name = Positive Test for logf -TYPE = DEFAULT -EXE1 = test1 -Description -= Passes a series of values to the logf() function, -= checking each for the expected result. Also checks -= for proper handling of out-of-range values. diff --git a/src/pal/tests/palsuite/c_runtime/malloc/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/malloc/CMakeLists.txt deleted file mode 100644 index ef14ea535..000000000 --- a/src/pal/tests/palsuite/c_runtime/malloc/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) - diff --git a/src/pal/tests/palsuite/c_runtime/malloc/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/malloc/test1/CMakeLists.txt deleted file mode 100644 index b08685d16..000000000 --- a/src/pal/tests/palsuite/c_runtime/malloc/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_malloc_test1 - ${SOURCES} -) - -add_dependencies(paltest_malloc_test1 coreclrpal) - -target_link_libraries(paltest_malloc_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/malloc/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/malloc/test1/test1.cpp deleted file mode 100644 index 7ea4dd068..000000000 --- a/src/pal/tests/palsuite/c_runtime/malloc/test1/test1.cpp +++ /dev/null @@ -1,52 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: Test that malloc returns useable memory -** -** -**==========================================================================*/ - -#include - - -int __cdecl main(int argc, char **argv) -{ - - char *testA; - int i; - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - /* check that malloc really gives us addressable memory */ - testA = (char *)malloc(20 * sizeof(char)); - if (testA == NULL) - { - Fail("Call to malloc failed.\n"); - } - for (i = 0; i < 20; i++) - { - testA[i] = 'a'; - } - for (i = 0; i < 20; i++) - { - if (testA[i] != 'a') - { - Fail("The memory doesn't seem to be properly allocated.\n"); - } - } - free(testA); - - PAL_Terminate(); - - return PASS; -} - - - diff --git a/src/pal/tests/palsuite/c_runtime/malloc/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/malloc/test1/testinfo.dat deleted file mode 100644 index 9060bc628..000000000 --- a/src/pal/tests/palsuite/c_runtime/malloc/test1/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = malloc -Name = Positive Test for malloc -TYPE = DEFAULT -EXE1 = test1 -Description -= Tests that malloc properly allocates memory. diff --git a/src/pal/tests/palsuite/c_runtime/malloc/test2/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/malloc/test2/CMakeLists.txt deleted file mode 100644 index 1b72ab8e6..000000000 --- a/src/pal/tests/palsuite/c_runtime/malloc/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test2.cpp -) - -add_executable(paltest_malloc_test2 - ${SOURCES} -) - -add_dependencies(paltest_malloc_test2 coreclrpal) - -target_link_libraries(paltest_malloc_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/malloc/test2/test2.cpp b/src/pal/tests/palsuite/c_runtime/malloc/test2/test2.cpp deleted file mode 100644 index 5deee0edd..000000000 --- a/src/pal/tests/palsuite/c_runtime/malloc/test2/test2.cpp +++ /dev/null @@ -1,41 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test2.c -** -** Purpose: Test that malloc(0) returns non-zero value -** -**==========================================================================*/ - -#include - - -int __cdecl main(int argc, char **argv) -{ - - char *testA; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - /* check that malloc(0) returns non-zero value */ - testA = (char *)malloc(0); - if (testA == NULL) - { - Fail("Call to malloc(0) failed.\n"); - } - - free(testA); - - PAL_Terminate(); - - return PASS; -} - - - diff --git a/src/pal/tests/palsuite/c_runtime/malloc/test2/testinfo.dat b/src/pal/tests/palsuite/c_runtime/malloc/test2/testinfo.dat deleted file mode 100644 index 1212a8f8f..000000000 --- a/src/pal/tests/palsuite/c_runtime/malloc/test2/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = malloc -Name = Positive Test for malloc -TYPE = DEFAULT -EXE1 = test2 -Description -= Test that malloc(0) returns non-zero value diff --git a/src/pal/tests/palsuite/c_runtime/memchr/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/memchr/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/c_runtime/memchr/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/c_runtime/memchr/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/memchr/test1/CMakeLists.txt deleted file mode 100644 index 1f6fc0856..000000000 --- a/src/pal/tests/palsuite/c_runtime/memchr/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_memchr_test1 - ${SOURCES} -) - -add_dependencies(paltest_memchr_test1 coreclrpal) - -target_link_libraries(paltest_memchr_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/memchr/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/memchr/test1/test1.cpp deleted file mode 100644 index 043a6789d..000000000 --- a/src/pal/tests/palsuite/c_runtime/memchr/test1/test1.cpp +++ /dev/null @@ -1,122 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test1.c -** -** Purpose: Tests the PAL implementation of the memchr function. -** Create a string buffer, and check for a number of -** characters in it. Test to ensure it returns NULL if -** it can't find the character, and that the size argument -** works properly. -** -** -**===================================================================*/ - -#include - -struct testCase -{ - char *result; - char string[50]; - int character; - int length; -}; - - -int __cdecl main(int argc, char *argv[]) -{ - int i = 0; - char *result = NULL; - - /* - * this structure includes several strings to be tested with - * memchr function and the expected results - */ - - struct testCase testCases[]= - { - {"st","corn cup cat cream coast",'s',23}, - /* single instance of char */ - {"st","corn cup cat cream coast",'s',24}, - /* single inst, inst< exact length */ - {"q","corn cup cat cream coastq",'q',25}, - /* single inst at end, inst=exact length */ - {"q","corn cup cat cream coastq",'q',26}, - /* single inst at end, instlen(string) */ - {"st","corn cup cat cream coast",115,24}, - /* single int inst, instlength */ - }; - - - /* Initialize the PAL */ - if ( 0 != PAL_Initialize(argc, argv)) - { - return FAIL; - } - - /* Loop through the testcases in the structure */ - for (i=0; i< sizeof(testCases)/sizeof(struct testCase); i++) - { - /* Need to type cast function in order to compare the result */ - result = (char *)memchr(testCases[i].string, - testCases[i].character,testCases[i].length); - - if (result==NULL) - { - if (testCases[i].result != NULL) - { - Fail("ERROR: Expected memcmp to return \"%s\" instead of" - " NULL\n", testCases[i].result); - } - } - else - { - if (strcmp(result,testCases[i].result)!=0 ) - - { - Fail("ERROR: Expected memcmp to return \"%s\" instead of" - " \"%s\"\n", testCases[i].result, result); - } - - } - } - - PAL_Terminate(); - - return PASS; -} - - - - - - - - - - - - - diff --git a/src/pal/tests/palsuite/c_runtime/memchr/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/memchr/test1/testinfo.dat deleted file mode 100644 index fc2a8e95d..000000000 --- a/src/pal/tests/palsuite/c_runtime/memchr/test1/testinfo.dat +++ /dev/null @@ -1,19 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = memchr -Name = Positive Test for memchr -TYPE = DEFAULT -EXE1 = test1 -Description -= Create a string buffer, and check for a number of characters in it. -= Test to ensure it returns NULL if it can't find the character, and that -= the size argument works properly. - - - - - diff --git a/src/pal/tests/palsuite/c_runtime/memcmp/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/memcmp/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/c_runtime/memcmp/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/c_runtime/memcmp/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/memcmp/test1/CMakeLists.txt deleted file mode 100644 index 24aa40a56..000000000 --- a/src/pal/tests/palsuite/c_runtime/memcmp/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_memcmp_test1 - ${SOURCES} -) - -add_dependencies(paltest_memcmp_test1 coreclrpal) - -target_link_libraries(paltest_memcmp_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/memcmp/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/memcmp/test1/test1.cpp deleted file mode 100644 index 7b63173e2..000000000 --- a/src/pal/tests/palsuite/c_runtime/memcmp/test1/test1.cpp +++ /dev/null @@ -1,57 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: Check that memcmp find identical buffers to be identical, -** and that it correctly orders different buffers. -** -** -**==========================================================================*/ - -#include - -int __cdecl main(int argc, char **argv) -{ - - char testA[] = "aaaaaaaaaaaaaaaaaaaa"; - char testB[] = "aaaaaaaaaaaaaaaaaaaa"; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - if (!(memcmp(testA, testB, 20) == 0)) - { - Fail("memcmp compared two identical buffers and found them to " - "differ.\n"); - } - testB[3] = 'b'; - - if (!(memcmp(testA, testB, 20) < 0) - || !(memcmp(testB, testA, 20) >0 )) - { - Fail("memcmp compared two buffers with different contents, and" - " did not order them correctly.\n"); - } - - if (memcmp(testA, testB, 0) != 0) - { - Fail("memcmp didn't return 0 when comparing buffers of length 0.\n"); - } - - PAL_Terminate(); - return PASS; -} - - - - - - - diff --git a/src/pal/tests/palsuite/c_runtime/memcmp/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/memcmp/test1/testinfo.dat deleted file mode 100644 index 2de36b2dd..000000000 --- a/src/pal/tests/palsuite/c_runtime/memcmp/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = memcmp -Name = Positive Test for memcmp -TYPE = DEFAULT -EXE1 = test1 -Description -= Check that memcmp find identical buffers to be identical, -= and that it correctly orders different buffers. diff --git a/src/pal/tests/palsuite/c_runtime/memcpy/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/memcpy/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/c_runtime/memcpy/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/c_runtime/memcpy/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/memcpy/test1/CMakeLists.txt deleted file mode 100644 index 982433f7e..000000000 --- a/src/pal/tests/palsuite/c_runtime/memcpy/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_memcpy_test1 - ${SOURCES} -) - -add_dependencies(paltest_memcpy_test1 coreclrpal) - -target_link_libraries(paltest_memcpy_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/memcpy/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/memcpy/test1/test1.cpp deleted file mode 100644 index 9da98d657..000000000 --- a/src/pal/tests/palsuite/c_runtime/memcpy/test1/test1.cpp +++ /dev/null @@ -1,87 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: Calls memcpy and verifies that the buffer was copied correctly. -** -** -**==========================================================================*/ - -#include - -int __cdecl main(int argc, char **argv) -{ - char testA[20]; - char testB[20]; - void *retVal; - long i; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - memset(testA, 'a', 20); - memset(testB, 'b', 20); - - retVal = (char *)memcpy(testB, testA, 0); - if (retVal != testB) - { - Fail("memcpy should return a pointer to the destination buffer, " - "but doesn't.\n"); - } - for(i = 0; i<20; i++) - { - if (testB[i]!= 'b') - { - Fail("The destination buffer overflowed by memcpy.\n"); - } - } - - retVal = (char *)memcpy(testB+1, testA, 18); - if (retVal != testB+1) - { - Fail("memcpy should return a pointer to the destination buffer, " - "but doesn't.\n"); - } - - if (testB[0] != 'b' || testB[19] != 'b') - { - Fail("The destination buffer was written out of bounds by memcpy!\n"); - } - - for(i = 1; i<19; i++) - { - if (testB[i]!= 'a') - { - Fail("The destination buffer copied to by memcpy doesn't match " - "the source buffer.\n"); - } - } - - PAL_Terminate(); - - return PASS; -} - - - - - - - - - - - - - - - - - diff --git a/src/pal/tests/palsuite/c_runtime/memcpy/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/memcpy/test1/testinfo.dat deleted file mode 100644 index 157da6cf8..000000000 --- a/src/pal/tests/palsuite/c_runtime/memcpy/test1/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = memcpy -Name = Positive Test for memcpy -TYPE = DEFAULT -EXE1 = test1 -Description -= Calls memcpy and verifies that the buffer was copied correctly. diff --git a/src/pal/tests/palsuite/c_runtime/memmove/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/memmove/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/c_runtime/memmove/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/c_runtime/memmove/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/memmove/test1/CMakeLists.txt deleted file mode 100644 index 979408591..000000000 --- a/src/pal/tests/palsuite/c_runtime/memmove/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_memmove_test1 - ${SOURCES} -) - -add_dependencies(paltest_memmove_test1 coreclrpal) - -target_link_libraries(paltest_memmove_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/memmove/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/memmove/test1/test1.cpp deleted file mode 100644 index 8279d6713..000000000 --- a/src/pal/tests/palsuite/c_runtime/memmove/test1/test1.cpp +++ /dev/null @@ -1,116 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: Test that memmove correctly copies text from one buffer -** to another even when the buffers overlap. -** -** -**==========================================================================*/ - -#include - -int __cdecl main(int argc, char **argv) -{ - char testA[11] = "abcdefghij"; - char testB[15] = "aabbccddeeffgg"; - char testC[15] = "aabbccddeeffgg"; - char testD[15] = "aabbccddeeffgg"; - char insString[4] = "zzz"; - char *retVal; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - /* move a string onto itself */ - retVal = (char *)memmove(testA + 2, testA, 8); - if (retVal != testA + 2) - { - Fail("The return value should have been the value of the destination" - "pointer, but wasn't\n"); - } - - /*Check the most likely error*/ - if (memcmp(testA, "ababababab", 11) == 0) - { - Fail("memmove should have saved the characters in the region of" - " overlap between source and destination, but didn't.\n"); - } - - if (memcmp(testA, "ababcdefgh", 11) != 0) - { - /* not sure what exactly went wrong. */ - Fail("memmove was called on a region containing the characters" - " \"abcdefghij\". It was to move the first 8 positions to" - " the last 8 positions, giving the result \"ababcdefgh\". " - " Instead, it gave the result \"%s\".\n", testA); - } - - /* move a string to the front of testB */ - retVal = (char *)memmove(testB, insString, 3); - if(retVal != testB) - { - Fail("memmove: The function did not return the correct " - "string.\n"); - } - - if(memcmp(testB, "zzzbccddeeffgg",15) != 0) - { - Fail("memmove: The function failed to move the string " - "correctly.\n"); - } - - - /* move a string to the middle of testC */ - retVal = (char*)memmove(testC+5, insString, 3); - if(retVal != testC+5) - { - Fail("memmove: The function did not return the correct " - "string.\n"); - } - - if(memcmp(testC, "aabbczzzeeffgg",15) != 0) - { - Fail("memmove: The function failed to move the string " - "correctly.\n"); - } - - - /* move a string to the end of testD */ - retVal = (char*)memmove(testD+11, insString, 3); - if(retVal != testD+11) - { - Fail("memmove: The function did not return the correct " - "string.\n"); - } - - if(memcmp(testD, "aabbccddeefzzz",15) != 0) - { - Fail("memmove: The function failed to move the string " - "correctly.\n"); - } - - PAL_Terminate(); - return PASS; - -} - - - - - - - - - - - - - - diff --git a/src/pal/tests/palsuite/c_runtime/memmove/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/memmove/test1/testinfo.dat deleted file mode 100644 index d8d4c0ead..000000000 --- a/src/pal/tests/palsuite/c_runtime/memmove/test1/testinfo.dat +++ /dev/null @@ -1,19 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = memmove -Name = Positive Test for memmove -TYPE = DEFAULT -EXE1 = test1 -Description -= Test that memmove correctly copies text from one buffer to another -= even when the buffers overlap. - - - - - - diff --git a/src/pal/tests/palsuite/c_runtime/memset/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/memset/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/c_runtime/memset/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/c_runtime/memset/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/memset/test1/CMakeLists.txt deleted file mode 100644 index 3f3c5614e..000000000 --- a/src/pal/tests/palsuite/c_runtime/memset/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_memset_test1 - ${SOURCES} -) - -add_dependencies(paltest_memset_test1 coreclrpal) - -target_link_libraries(paltest_memset_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/memset/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/memset/test1/test1.cpp deleted file mode 100644 index 67cde8756..000000000 --- a/src/pal/tests/palsuite/c_runtime/memset/test1/test1.cpp +++ /dev/null @@ -1,60 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: Check that memset correctly fills a destination buffer -** without overflowing it. -** -** -**==========================================================================*/ - -#include - -int __cdecl main(int argc, char **argv) -{ - - char testA[22] = "bbbbbbbbbbbbbbbbbbbbb"; - char *retVal; - - int i; - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - retVal = (char *)memset(testA, 'a', 20); - if (retVal != testA) - { - Fail("memset should have returned the value of the destination" - "pointer, but didn't"); - } - - for(i = 0; i<20; i++) - { - if (testA[i]!= 'a') - { - Fail("memset didn't set the destination bytes.\n"); - } - } - if (testA[20] == 'a') - { - Fail("memset overfilled the destination buffer.\n"); - } - - PAL_Terminate(); - return PASS; -} - - - - - - - - - - diff --git a/src/pal/tests/palsuite/c_runtime/memset/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/memset/test1/testinfo.dat deleted file mode 100644 index cab02fb4b..000000000 --- a/src/pal/tests/palsuite/c_runtime/memset/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = memset -Name = Positive Test for memset -TYPE = DEFAULT -EXE1 = test1 -Description -= Check that memset correctly fills a destination buffer without overflowing it. - diff --git a/src/pal/tests/palsuite/c_runtime/modf/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/modf/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/c_runtime/modf/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/c_runtime/modf/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/modf/test1/CMakeLists.txt deleted file mode 100644 index 303ce629d..000000000 --- a/src/pal/tests/palsuite/c_runtime/modf/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_modf_test1 - ${SOURCES} -) - -add_dependencies(paltest_modf_test1 coreclrpal) - -target_link_libraries(paltest_modf_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/modf/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/modf/test1/test1.cpp deleted file mode 100644 index 389d07925..000000000 --- a/src/pal/tests/palsuite/c_runtime/modf/test1/test1.cpp +++ /dev/null @@ -1,136 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================= -** -** Source: test1.c (modf) -** -** Purpose: Test to ensure that modf return the correct values -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** Fail -** fabs -** -**===========================================================================*/ - -#include - -// binary64 (double) has a machine epsilon of 2^-52 (approx. 2.22e-16). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-50 (approx. 8.88e-16) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (15-17 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxxxxxxxxxx will use -// PAL_EPSILON for the variance, while an expected result in the format of 0.0xxxxxxxxxxxxxxxxx -// will use PAL_EPSILON / 10 and and expected result in the format of x.xxxxxxxxxxxxxxxx will -// use PAL_EPSILON * 10. -#define PAL_EPSILON 8.8817841970012523e-16 - -#define PAL_NAN sqrt(-1.0) -#define PAL_POSINF -log(0.0) -#define PAL_NEGINF log(0.0) - -/** - * Helper test structure - */ -struct test -{ - double value; /* value to test the function with */ - double expected; /* expected result */ - double variance; /* maximum delta between the expected and actual result */ - double expected_intpart; /* expected result */ - double variance_intpart; /* maximum delta between the expected and actual result */ -}; - -/** - * validate - * - * test validation function - */ -void __cdecl validate(double value, double expected, double variance, double expected_intpart, double variance_intpart) -{ - double result_intpart; - double result = modf(value, &result_intpart); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - double delta = fabs(result - expected); - double delta_intpart = fabs(result_intpart - expected_intpart); - - if ((delta > variance) || (delta_intpart > variance_intpart)) - { - Fail("modf(%g) returned %20.17g with an intpart of %20.17g when it should have returned %20.17g with an intpart of %20.17g", - value, result, result_intpart, expected, expected_intpart); - } -} - -/** - * validate - * - * test validation function for values returning NaN - */ -void __cdecl validate_isnan(double value) -{ - double result_intpart; - double result = modf(value, &result_intpart); - - if (!_isnan(result) || !_isnan(result_intpart)) - { - Fail("modf(%g) returned %20.17g with an intpart of %20.17g when it should have returned %20.17g with an intpart of %20.17g", - value, result, result_intpart, PAL_NAN, PAL_NAN); - } -} - -/** - * main - * - * executable entry point - */ -int __cdecl main(int argc, char **argv) -{ - struct test tests[] = - { - /* value expected variance expected_intpart variance_intpart */ - { 0, 0, PAL_EPSILON, 0, PAL_EPSILON }, - { 0.31830988618379067, 0.31830988618379067, PAL_EPSILON, 0, PAL_EPSILON }, // value: 1 / pi - { 0.43429448190325183, 0.43429448190325183, PAL_EPSILON, 0, PAL_EPSILON }, // value: log10(e) - { 0.63661977236758134, 0.63661977236758134, PAL_EPSILON, 0, PAL_EPSILON }, // value: 2 / pi - { 0.69314718055994531, 0.69314718055994531, PAL_EPSILON, 0, PAL_EPSILON }, // value: ln(2) - { 0.70710678118654752, 0.70710678118654752, PAL_EPSILON, 0, PAL_EPSILON }, // value: 1 / sqrt(2) - { 0.78539816339744831, 0.78539816339744831, PAL_EPSILON, 0, PAL_EPSILON }, // value: pi / 4 - { 1, 0, PAL_EPSILON, 1, PAL_EPSILON * 10 }, - { 1.1283791670955126, 0.1283791670955126, PAL_EPSILON, 1, PAL_EPSILON * 10 }, // value: 2 / sqrt(pi) - { 1.4142135623730950, 0.4142135623730950, PAL_EPSILON, 1, PAL_EPSILON * 10 }, // value: sqrt(2) - { 1.4426950408889634, 0.4426950408889634, PAL_EPSILON, 1, PAL_EPSILON * 10 }, // value: log2(e) - { 1.5707963267948966, 0.5707963267948966, PAL_EPSILON, 1, PAL_EPSILON * 10 }, // value: pi / 2 - { 2.3025850929940457, 0.3025850929940457, PAL_EPSILON, 2, PAL_EPSILON * 10 }, // value: ln(10) - { 2.7182818284590452, 0.7182818284590452, PAL_EPSILON, 2, PAL_EPSILON * 10 }, // value: e - { 3.1415926535897932, 0.1415926535897932, PAL_EPSILON, 3, PAL_EPSILON * 10 }, // value: pi - { PAL_POSINF, 0, PAL_EPSILON, PAL_POSINF, 0 } - - }; - - /* PAL initialization */ - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - validate( tests[i].value, tests[i].expected, tests[i].variance, tests[i].expected_intpart, tests[i].variance_intpart); - validate(-tests[i].value, -tests[i].expected, tests[i].variance, -tests[i].expected_intpart, tests[i].variance_intpart); - } - - validate_isnan(PAL_NAN); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/modf/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/modf/test1/testinfo.dat deleted file mode 100644 index 203b553e2..000000000 --- a/src/pal/tests/palsuite/c_runtime/modf/test1/testinfo.dat +++ /dev/null @@ -1,16 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = modf -Name = Positive Test for modf -TYPE = DEFAULT -EXE1 = test1 -Description -= Passes to modf() a series of values, checking that -= each one return to correct value. - - - diff --git a/src/pal/tests/palsuite/c_runtime/modff/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/modff/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/c_runtime/modff/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/c_runtime/modff/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/modff/test1/CMakeLists.txt deleted file mode 100644 index b3831c8e6..000000000 --- a/src/pal/tests/palsuite/c_runtime/modff/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_modff_test1 - ${SOURCES} -) - -add_dependencies(paltest_modff_test1 coreclrpal) - -target_link_libraries(paltest_modff_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/modff/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/modff/test1/test1.cpp deleted file mode 100644 index 6b7a50be3..000000000 --- a/src/pal/tests/palsuite/c_runtime/modff/test1/test1.cpp +++ /dev/null @@ -1,135 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================= -** -** Source: test1.c (modf) -** -** Purpose: Test to ensure that modf return the correct values -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** Fail -** fabs -** -**===========================================================================*/ - -#include - -// binary32 (float) has a machine epsilon of 2^-23 (approx. 1.19e-07). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-21 (approx. 4.76e-07) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (6-9 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxx will use PAL_EPSILON -// for the variance, while an expected result in the format of 0.0xxxxxxxxx will use -// PAL_EPSILON / 10 and and expected result in the format of x.xxxxxx will use PAL_EPSILON * 10. -#define PAL_EPSILON 4.76837158e-07 - -#define PAL_NAN sqrt(-1.0) -#define PAL_POSINF -log(0.0) -#define PAL_NEGINF log(0.0) - -/** - * Helper test structure - */ -struct test -{ - float value; /* value to test the function with */ - float expected; /* expected result */ - float variance; /* maximum delta between the expected and actual result */ - float expected_intpart; /* expected result */ - float variance_intpart; /* maximum delta between the expected and actual result */ -}; - -/** - * validate - * - * test validation function - */ -void __cdecl validate(float value, float expected, float variance, float expected_intpart, float variance_intpart) -{ - float result_intpart; - float result = modff(value, &result_intpart); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - float delta = fabsf(result - expected); - float delta_intpart = fabsf(result_intpart - expected_intpart); - - if ((delta > variance) || (delta_intpart > variance_intpart)) - { - Fail("modff(%g) returned %10.9g with an intpart of %10.9g when it should have returned %10.9g with an intpart of %10.9g", - value, result, result_intpart, expected, expected_intpart); - } -} - -/** - * validate - * - * test validation function for values returning NaN - */ -void __cdecl validate_isnan(float value) -{ - float result_intpart; - float result = modff(value, &result_intpart); - - if (!_isnan(result) || !_isnan(result_intpart)) - { - Fail("modff(%g) returned %10.9g with an intpart of %10.9g when it should have returned %10.9g with an intpart of %10.9g", - value, result, result_intpart, PAL_NAN, PAL_NAN); - } -} - -/** - * main - * - * executable entry point - */ -int __cdecl main(int argc, char **argv) -{ - struct test tests[] = - { - /* value expected variance expected_intpart variance_intpart */ - { 0, 0, PAL_EPSILON, 0, PAL_EPSILON }, - { 0.318309886f, 0.318309886f, PAL_EPSILON, 0, PAL_EPSILON }, // value: 1 / pi - { 0.434294482f, 0.434294482f, PAL_EPSILON, 0, PAL_EPSILON }, // value: log10(e) - { 0.636619772f, 0.636619772f, PAL_EPSILON, 0, PAL_EPSILON }, // value: 2 / pi - { 0.693147181f, 0.693147181f, PAL_EPSILON, 0, PAL_EPSILON }, // value: ln(2) - { 0.707106781f, 0.707106781f, PAL_EPSILON, 0, PAL_EPSILON }, // value: 1 / sqrt(2) - { 0.785398163f, 0.785398163f, PAL_EPSILON, 0, PAL_EPSILON }, // value: pi / 4 - { 1, 0, PAL_EPSILON, 1, PAL_EPSILON * 10 }, - { 1.12837917f, 0.128379167f, PAL_EPSILON, 1, PAL_EPSILON * 10 }, // value: 2 / sqrt(pi) - { 1.41421356f, 0.414213562f, PAL_EPSILON, 1, PAL_EPSILON * 10 }, // value: sqrt(2) - { 1.44269504f, 0.442695041f, PAL_EPSILON, 1, PAL_EPSILON * 10 }, // value: log2(e) - { 1.57079633f, 0.570796327f, PAL_EPSILON, 1, PAL_EPSILON * 10 }, // value: pi / 2 - { 2.30258509f, 0.302585093f, PAL_EPSILON, 2, PAL_EPSILON * 10 }, // value: ln(10) - { 2.71828183f, 0.718281828f, PAL_EPSILON, 2, PAL_EPSILON * 10 }, // value: e - { 3.14159265f, 0.141592654f, PAL_EPSILON, 3, PAL_EPSILON * 10 }, // value: pi - { PAL_POSINF, 0, PAL_EPSILON, PAL_POSINF, 0 } - - }; - - /* PAL initialization */ - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - validate( tests[i].value, tests[i].expected, tests[i].variance, tests[i].expected_intpart, tests[i].variance_intpart); - validate(-tests[i].value, -tests[i].expected, tests[i].variance, -tests[i].expected_intpart, tests[i].variance_intpart); - } - - validate_isnan(PAL_NAN); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/modff/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/modff/test1/testinfo.dat deleted file mode 100644 index 392491e3b..000000000 --- a/src/pal/tests/palsuite/c_runtime/modff/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = modff -Name = Positive Test for modff -TYPE = DEFAULT -EXE1 = test1 -Description -= Passes to modff() a series of values, checking that -= each one return to correct value. diff --git a/src/pal/tests/palsuite/c_runtime/pow/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/pow/CMakeLists.txt deleted file mode 100644 index 5e1ef7f28..000000000 --- a/src/pal/tests/palsuite/c_runtime/pow/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) diff --git a/src/pal/tests/palsuite/c_runtime/pow/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/pow/test1/CMakeLists.txt deleted file mode 100644 index 339b7a3ee..000000000 --- a/src/pal/tests/palsuite/c_runtime/pow/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_pow_test1 - ${SOURCES} -) - -add_dependencies(paltest_pow_test1 coreclrpal) - -target_link_libraries(paltest_pow_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/pow/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/pow/test1/test1.cpp deleted file mode 100644 index 7eea316e6..000000000 --- a/src/pal/tests/palsuite/c_runtime/pow/test1/test1.cpp +++ /dev/null @@ -1,230 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test1.c -** -** Purpose: Tests that atan2 returns correct values for a subset of values. -** Tests with positive and negative values of x and y to ensure -** atan2 is returning results from the correct quadrant. -** -**===================================================================*/ - -#include - -// binary64 (double) has a machine epsilon of 2^-52 (approx. 2.22e-16). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-50 (approx. 8.88e-16) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (15-17 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxxxxxxxxxx will use -// PAL_EPSILON for the variance, while an expected result in the format of 0.0xxxxxxxxxxxxxxxxx -// will use PAL_EPSILON / 10 and and expected result in the format of x.xxxxxxxxxxxxxxxx will -// use PAL_EPSILON * 10. -#define PAL_EPSILON 8.8817841970012523e-16 - -#define PAL_NAN sqrt(-1.0) -#define PAL_POSINF -log(0.0) -#define PAL_NEGINF log(0.0) - -/** - * Helper test structure - */ -struct test -{ - double x; /* first component of the value to test the function with */ - double y; /* second component of the value to test the function with */ - double expected; /* expected result */ - double variance; /* maximum delta between the expected and actual result */ -}; - -/** - * validate - * - * test validation function - */ -void __cdecl validate(double x, double y, double expected, double variance) -{ - double result = pow(x, y); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - double delta = fabs(result - expected); - - if (delta > variance) - { - Fail("pow(%g, %g) returned %20.17g when it should have returned %20.17g", - x, y, result, expected); - } -} - -/** - * validate - * - * test validation function for values returning NaN - */ -void __cdecl validate_isnan(double x, double y) -{ - double result = pow(x, y); - - if (!_isnan(result)) - { - Fail("pow(%g, %g) returned %20.17g when it should have returned %20.17g", - x, y, result, PAL_NAN); - } -} - -/** - * main - * - * executable entry point - */ -int __cdecl main(int argc, char **argv) -{ - struct test tests[] = - { - /* x y expected variance */ - { PAL_NEGINF, PAL_NEGINF, 0, PAL_EPSILON }, - { PAL_NEGINF, PAL_POSINF, PAL_POSINF, 0 }, - - { -10, PAL_NEGINF, 0, PAL_EPSILON }, - { -10, -1, -0.1, PAL_EPSILON }, - { -10, 0, 1, PAL_EPSILON * 10 }, - { -10, 1, -10, PAL_EPSILON * 100 }, - { -10, PAL_POSINF, PAL_POSINF, 0 }, - - { -2.7182818284590452, PAL_NEGINF, 0, PAL_EPSILON }, // x: -(e) - { -2.7182818284590452, -1, -0.36787944117144232, PAL_EPSILON }, // x: -(e) - { -2.7182818284590452, 0, 1, PAL_EPSILON * 10 }, // x: -(e) - { -2.7182818284590452, 1, -2.7182818284590452, PAL_EPSILON * 10 }, // x: -(e) expected: e - { -2.7182818284590452, PAL_POSINF, PAL_POSINF, 0 }, // x: -(e) - - { -1.0, PAL_NEGINF, 1.0, PAL_EPSILON * 10 }, - { -1.0, PAL_POSINF, 1.0, PAL_EPSILON * 10 }, - - { -0.0, PAL_NEGINF, PAL_POSINF, 0 }, - { -0.0, -1, PAL_NEGINF, 0 }, - { -0.0, -0.0, 1, PAL_EPSILON * 10 }, - { -0.0, 0, 1, PAL_EPSILON * 10 }, - { -0.0, 1, -0.0, PAL_EPSILON }, - { -0.0, PAL_POSINF, 0, PAL_EPSILON }, - - { PAL_NAN, -0.0, 1.0, PAL_EPSILON * 10 }, - { PAL_NAN, 0, 1.0, PAL_EPSILON * 10 }, - - { 0.0, PAL_NEGINF, PAL_POSINF, 0 }, - { 0.0, -1, PAL_POSINF, 0 }, - { 0, -0.0, 1, PAL_EPSILON * 10 }, - { 0, 0, 1, PAL_EPSILON * 10 }, - { 0.0, 1, 0, PAL_EPSILON }, - { 0.0, PAL_POSINF, 0, PAL_EPSILON }, - - { 1, PAL_NEGINF, 1, PAL_EPSILON * 10 }, - { 1, PAL_POSINF, 1, PAL_EPSILON * 10 }, - - { 2.7182818284590452, PAL_NEGINF, 0, PAL_EPSILON }, - { 2.7182818284590452, -3.1415926535897932, 0.043213918263772250, PAL_EPSILON / 10 }, // x: e y: -(pi) - { 2.7182818284590452, -2.7182818284590452, 0.065988035845312537, PAL_EPSILON / 10 }, // x: e y: -(e) - { 2.7182818284590452, -2.3025850929940457, 0.1, PAL_EPSILON }, // x: e y: -(ln(10)) - { 2.7182818284590452, -1.5707963267948966, 0.20787957635076191, PAL_EPSILON }, // x: e y: -(pi / 2) - { 2.7182818284590452, -1.4426950408889634, 0.23629008834452270, PAL_EPSILON }, // x: e y: -(log2(e)) - { 2.7182818284590452, -1.4142135623730950, 0.24311673443421421, PAL_EPSILON }, // x: e y: -(sqrt(2)) - { 2.7182818284590452, -1.1283791670955126, 0.32355726390307110, PAL_EPSILON }, // x: e y: -(2 / sqrt(pi)) - { 2.7182818284590452, -1, 0.36787944117144232, PAL_EPSILON }, // x: e y: -(1) - { 2.7182818284590452, -0.78539816339744831, 0.45593812776599624, PAL_EPSILON }, // x: e y: -(pi / 4) - { 2.7182818284590452, -0.70710678118654752, 0.49306869139523979, PAL_EPSILON }, // x: e y: -(1 / sqrt(2)) - { 2.7182818284590452, -0.69314718055994531, 0.5, PAL_EPSILON }, // x: e y: -(ln(2)) - { 2.7182818284590452, -0.63661977236758134, 0.52907780826773535, PAL_EPSILON }, // x: e y: -(2 / pi) - { 2.7182818284590452, -0.43429448190325183, 0.64772148514180065, PAL_EPSILON }, // x: e y: -(log10(e)) - { 2.7182818284590452, -0.31830988618379067, 0.72737734929521647, PAL_EPSILON }, // x: e y: -(1 / pi) - { 2.7182818284590452, 0, 1, PAL_EPSILON * 10 }, // x: e - { 2.7182818284590452, 0.31830988618379067, 1.3748022274393586, PAL_EPSILON * 10 }, // x: e y: 1 / pi - { 2.7182818284590452, 0.43429448190325183, 1.5438734439711811, PAL_EPSILON * 10 }, // x: e y: log10(e) - { 2.7182818284590452, 0.63661977236758134, 1.8900811645722220, PAL_EPSILON * 10 }, // x: e y: 2 / pi - { 2.7182818284590452, 0.69314718055994531, 2, PAL_EPSILON * 10 }, // x: e y: ln(2) - { 2.7182818284590452, 0.70710678118654752, 2.0281149816474725, PAL_EPSILON * 10 }, // x: e y: 1 / sqrt(2) - { 2.7182818284590452, 0.78539816339744831, 2.1932800507380155, PAL_EPSILON * 10 }, // x: e y: pi / 4 - { 2.7182818284590452, 1, 2.7182818284590452, PAL_EPSILON * 10 }, // x: e expected: e - { 2.7182818284590452, 1.1283791670955126, 3.0906430223107976, PAL_EPSILON * 10 }, // x: e y: 2 / sqrt(pi) - { 2.7182818284590452, 1.4142135623730950, 4.1132503787829275, PAL_EPSILON * 10 }, // x: e y: sqrt(2) - { 2.7182818284590452, 1.4426950408889634, 4.2320861065570819, PAL_EPSILON * 10 }, // x: e y: log2(e) - { 2.7182818284590452, 1.5707963267948966, 4.8104773809653517, PAL_EPSILON * 10 }, // x: e y: pi / 2 - { 2.7182818284590452, 2.3025850929940457, 10, PAL_EPSILON * 100 }, // x: e y: ln(10) - { 2.7182818284590452, 2.7182818284590452, 15.154262241479264, PAL_EPSILON * 100 }, // x: e y: e - { 2.7182818284590452, 3.1415926535897932, 23.140692632779269, PAL_EPSILON * 100 }, // x: e y: pi - { 2.7182818284590452, PAL_POSINF, PAL_POSINF, 0 }, // x: e - - { 10, PAL_NEGINF, 0, 0 }, - { 10, -3.1415926535897932, 0.00072178415907472774, PAL_EPSILON / 1000 }, // y: -(pi) - { 10, -2.7182818284590452, 0.0019130141022243176, PAL_EPSILON / 100 }, // y: -(e) - { 10, -2.3025850929940457, 0.0049821282964407206, PAL_EPSILON / 100 }, // y: -(ln(10)) - { 10, -1.5707963267948966, 0.026866041001136132, PAL_EPSILON / 10 }, // y: -(pi / 2) - { 10, -1.4426950408889634, 0.036083192820787210, PAL_EPSILON / 10 }, // y: -(log2(e)) - { 10, -1.4142135623730950, 0.038528884700322026, PAL_EPSILON / 10 }, // y: -(sqrt(2)) - { 10, -1.1283791670955126, 0.074408205860642723, PAL_EPSILON / 10 }, // y: -(2 / sqrt(pi)) - { 10, -1, 0.1, PAL_EPSILON }, // y: -(1) - { 10, -0.78539816339744831, 0.16390863613957665, PAL_EPSILON }, // y: -(pi / 4) - { 10, -0.70710678118654752, 0.19628775993505562, PAL_EPSILON }, // y: -(1 / sqrt(2)) - { 10, -0.69314718055994531, 0.20269956628651730, PAL_EPSILON }, // y: -(ln(2)) - { 10, -0.63661977236758134, 0.23087676451600055, PAL_EPSILON }, // y: -(2 / pi) - { 10, -0.43429448190325183, 0.36787944117144232, PAL_EPSILON }, // y: -(log10(e)) - { 10, -0.31830988618379067, 0.48049637305186868, PAL_EPSILON }, // y: -(1 / pi) - { 10, 0, 1, PAL_EPSILON * 10 }, - { 10, 0.31830988618379067, 2.0811811619898573, PAL_EPSILON * 10 }, // y: 1 / pi - { 10, 0.43429448190325183, 2.7182818284590452, PAL_EPSILON * 10 }, // y: log10(e) expected: e - { 10, 0.63661977236758134, 4.3313150290214525, PAL_EPSILON * 10 }, // y: 2 / pi - { 10, 0.69314718055994531, 4.9334096679145963, PAL_EPSILON * 10 }, // y: ln(2) - { 10, 0.70710678118654752, 5.0945611704512962, PAL_EPSILON * 10 }, // y: 1 / sqrt(2) - { 10, 0.78539816339744831, 6.1009598002416937, PAL_EPSILON * 10 }, // y: pi / 4 - { 10, 1, 10, PAL_EPSILON * 100 }, - { 10, 1.1283791670955126, 13.439377934644400, PAL_EPSILON * 100 }, // y: 2 / sqrt(pi) - { 10, 1.4142135623730950, 25.954553519470081, PAL_EPSILON * 100 }, // y: sqrt(2) - { 10, 1.4426950408889634, 27.713733786437790, PAL_EPSILON * 100 }, // y: log2(e) - { 10, 1.5707963267948966, 37.221710484165167, PAL_EPSILON * 100 }, // y: pi / 2 - { 10, 2.3025850929940457, 200.71743249053009, PAL_EPSILON * 1000 }, // y: ln(10) - { 10, 2.7182818284590452, 522.73529967043665, PAL_EPSILON * 1000 }, // y: e - { 10, 3.1415926535897932, 1385.4557313670111, PAL_EPSILON * 10000 }, // y: pi - { 10, PAL_POSINF, PAL_POSINF, 0 }, - - { PAL_POSINF, PAL_NEGINF, 0, PAL_EPSILON }, - { PAL_POSINF, PAL_POSINF, PAL_POSINF, 0 }, - }; - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - validate(tests[i].x, tests[i].y, tests[i].expected, tests[i].variance); - } - - validate_isnan(-10, -1.5707963267948966); // y: -(pi / 2) - validate_isnan(-10, -0.78539816339744828); // y: -(pi / 4) - validate_isnan(-10, 0.78539816339744828); // y: pi / 4 - validate_isnan(-10, 1.5707963267948966); // y: pi / 2 - - validate_isnan(-2.7182818284590452, -1.5707963267948966); // x: -(e) y: -(pi / 2) - validate_isnan(-2.7182818284590452, -0.78539816339744828); // x: -(e) y: -(pi / 4) - validate_isnan(-2.7182818284590452, 0.78539816339744828); // x: -(e) y: pi / 4 - validate_isnan(-2.7182818284590452, 1.5707963267948966); // x: -(e) y: pi / 2 - - validate_isnan(PAL_NEGINF, PAL_NAN); - validate_isnan(PAL_NAN, PAL_NEGINF); - - validate_isnan(PAL_POSINF, PAL_NAN); - validate_isnan(PAL_NAN, PAL_POSINF); - - validate_isnan(PAL_NAN, PAL_NAN); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/pow/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/pow/test1/testinfo.dat deleted file mode 100644 index cf106d90e..000000000 --- a/src/pal/tests/palsuite/c_runtime/pow/test1/testinfo.dat +++ /dev/null @@ -1,17 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = pow -Name = Call pow with some std input/output. -TYPE = DEFAULT -EXE1 = test1 -Description -= Call the pow function with various num/exponent pairs -= that should produce std answers. - - - - diff --git a/src/pal/tests/palsuite/c_runtime/powf/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/powf/CMakeLists.txt deleted file mode 100644 index 5e1ef7f28..000000000 --- a/src/pal/tests/palsuite/c_runtime/powf/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) diff --git a/src/pal/tests/palsuite/c_runtime/powf/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/powf/test1/CMakeLists.txt deleted file mode 100644 index 2b8e2bcff..000000000 --- a/src/pal/tests/palsuite/c_runtime/powf/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.c -) - -add_executable(paltest_powf_test1 - ${SOURCES} -) - -add_dependencies(paltest_powf_test1 coreclrpal) - -target_link_libraries(paltest_powf_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/powf/test1/test1.c b/src/pal/tests/palsuite/c_runtime/powf/test1/test1.c deleted file mode 100644 index e8933c5ce..000000000 --- a/src/pal/tests/palsuite/c_runtime/powf/test1/test1.c +++ /dev/null @@ -1,229 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test1.c -** -** Purpose: Tests that atan2f returns correct values for a subset of values. -** Tests with positive and negative values of x and y to ensure -** atan2f is returning results from the correct quadrant. -** -**===================================================================*/ - -#include - -// binary32 (float) has a machine epsilon of 2^-23 (approx. 1.19e-07). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-21 (approx. 4.76e-07) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (6-9 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxx will use PAL_EPSILON -// for the variance, while an expected result in the format of 0.0xxxxxxxxx will use -// PAL_EPSILON / 10 and and expected result in the format of x.xxxxxx will use PAL_EPSILON * 10. -#define PAL_EPSILON 4.76837158e-07 - -#define PAL_NAN sqrtf(-1.0f) -#define PAL_POSINF -logf(0.0f) -#define PAL_NEGINF logf(0.0f) - -/** - * Helper test structure - */ -struct test -{ - float x; /* first component of the value to test the function with */ - float y; /* second component of the value to test the function with */ - float expected; /* expected result */ - float variance; /* maximum delta between the expected and actual result */ -}; - -/** - * validate - * - * test validation function - */ -void __cdecl validate(float x, float y, float expected, float variance) -{ - float result = powf(x, y); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - float delta = fabsf(result - expected); - - if (delta > variance) - { - Fail("powf(%g, %g) returned %10.9g when it should have returned %10.9g", - x, y, result, expected); - } -} - -/** - * validate - * - * test validation function for values returning NaN - */ -void __cdecl validate_isnan(float x, float y) -{ - float result = powf(x, y); - - if (!_isnanf(result)) - { - Fail("powf(%g, %g) returned %10.9g when it should have returned %10.9g", - x, y, result, PAL_NAN); - } -} - -/** - * main - * - * executable entry point - */ -int __cdecl main(int argc, char **argv) -{ - struct test tests[] = - { - /* x y expected variance */ - { PAL_NEGINF, PAL_NEGINF, 0, PAL_EPSILON }, - { PAL_NEGINF, PAL_POSINF, PAL_POSINF, 0 }, - - { -10, PAL_NEGINF, 0, PAL_EPSILON }, - { -10, -1, -0.1f, PAL_EPSILON }, - { -10, 0, 1, PAL_EPSILON * 10 }, - { -10, 1, -10, PAL_EPSILON * 100 }, - { -10, PAL_POSINF, PAL_POSINF, 0 }, - - { -2.71828183f, PAL_NEGINF, 0, PAL_EPSILON }, // x: -(e) - { -2.71828183f, -1, -0.367879441f, PAL_EPSILON }, // x: -(e) - { -2.71828183f, 0, 1, PAL_EPSILON * 10 }, // x: -(e) - { -2.71828183f, 1, -2.71828183f, PAL_EPSILON * 10 }, // x: -(e) expected: e - { -2.71828183f, PAL_POSINF, PAL_POSINF, 0 }, // x: -(e) - - { -1.0, PAL_NEGINF, 1.0, PAL_EPSILON * 10 }, - { -1.0, PAL_POSINF, 1.0, PAL_EPSILON * 10 }, - - { -0.0, PAL_NEGINF, PAL_POSINF, 0 }, - { -0.0, -1, PAL_NEGINF, 0 }, - { -0.0f, -0.0f, 1, PAL_EPSILON * 10 }, - { -0.0f, 0, 1, PAL_EPSILON * 10 }, - { -0.0, 1, -0.0, PAL_EPSILON }, - { -0.0, PAL_POSINF, 0, PAL_EPSILON }, - - { PAL_NAN, -0.0, 1.0, PAL_EPSILON * 10 }, - { PAL_NAN, 0, 1.0, PAL_EPSILON * 10 }, - - { 0.0, PAL_NEGINF, PAL_POSINF, 0 }, - { 0.0, -1, PAL_POSINF, 0 }, - { 0, -0.0f, 1, PAL_EPSILON * 10 }, - { 0, 0, 1, PAL_EPSILON * 10 }, - { 0.0, 1, 0, PAL_EPSILON }, - { 0.0, PAL_POSINF, 0, PAL_EPSILON }, - - { 1, PAL_NEGINF, 1, PAL_EPSILON * 10 }, - { 1, PAL_POSINF, 1, PAL_EPSILON * 10 }, - - { 2.71828183f, PAL_NEGINF, 0, PAL_EPSILON }, - { 2.71828183f, -3.14159265f, 0.0432139183f, PAL_EPSILON / 10 }, // x: e y: -(pi) - { 2.71828183f, -2.71828183f, 0.0659880358f, PAL_EPSILON / 10 }, // x: e y: -(e) - { 2.71828183f, -2.30258509f, 0.1f, PAL_EPSILON }, // x: e y: -(ln(10)) - { 2.71828183f, -1.57079633f, 0.207879576f, PAL_EPSILON }, // x: e y: -(pi / 2) - { 2.71828183f, -1.44269504f, 0.236290088f, PAL_EPSILON }, // x: e y: -(logf2(e)) - { 2.71828183f, -1.41421356f, 0.243116734f, PAL_EPSILON }, // x: e y: -(sqrtf(2)) - { 2.71828183f, -1.12837917f, 0.323557264f, PAL_EPSILON }, // x: e y: -(2 / sqrtf(pi)) - { 2.71828183f, -1, 0.367879441f, PAL_EPSILON }, // x: e y: -(1) - { 2.71828183f, -0.785398163f, 0.455938128f, PAL_EPSILON }, // x: e y: -(pi / 4) - { 2.71828183f, -0.707106781f, 0.493068691f, PAL_EPSILON }, // x: e y: -(1 / sqrtf(2)) - { 2.71828183f, -0.693147181f, 0.5f, PAL_EPSILON }, // x: e y: -(ln(2)) - { 2.71828183f, -0.636619772f, 0.529077808f, PAL_EPSILON }, // x: e y: -(2 / pi) - { 2.71828183f, -0.434294482f, 0.647721485f, PAL_EPSILON }, // x: e y: -(log10f(e)) - { 2.71828183f, -0.318309886f, 0.727377349f, PAL_EPSILON }, // x: e y: -(1 / pi) - { 2.71828183f, 0, 1, PAL_EPSILON * 10 }, // x: e - { 2.71828183f, 0.318309886f, 1.37480223f, PAL_EPSILON * 10 }, // x: e y: 1 / pi - { 2.71828183f, 0.434294482f, 1.54387344f, PAL_EPSILON * 10 }, // x: e y: log10f(e) - { 2.71828183f, 0.636619772f, 1.89008116f, PAL_EPSILON * 10 }, // x: e y: 2 / pi - { 2.71828183f, 0.693147181f, 2, PAL_EPSILON * 10 }, // x: e y: ln(2) - { 2.71828183f, 0.707106781f, 2.02811498f, PAL_EPSILON * 10 }, // x: e y: 1 / sqrtf(2) - { 2.71828183f, 0.785398163f, 2.19328005f, PAL_EPSILON * 10 }, // x: e y: pi / 4 - { 2.71828183f, 1, 2.71828183f, PAL_EPSILON * 10 }, // x: e expected: e - { 2.71828183f, 1.12837917f, 3.09064302f, PAL_EPSILON * 10 }, // x: e y: 2 / sqrtf(pi) - { 2.71828183f, 1.41421356f, 4.11325038f, PAL_EPSILON * 10 }, // x: e y: sqrtf(2) - { 2.71828183f, 1.44269504f, 4.23208611f, PAL_EPSILON * 10 }, // x: e y: logf2(e) - { 2.71828183f, 1.57079633f, 4.81047738f, PAL_EPSILON * 10 }, // x: e y: pi / 2 - { 2.71828183f, 2.30258509f, 10, PAL_EPSILON * 100 }, // x: e y: ln(10) - { 2.71828183f, 2.71828183f, 15.1542622f, PAL_EPSILON * 100 }, // x: e y: e - { 2.71828183f, 3.14159265f, 23.1406926f, PAL_EPSILON * 100 }, // x: e y: pi - { 2.71828183f, PAL_POSINF, PAL_POSINF, 0 }, // x: e - - { 10, PAL_NEGINF, 0, 0 }, - { 10, -3.14159265f, 0.000721784159f, PAL_EPSILON / 1000 }, // y: -(pi) - { 10, -2.71828183f, 0.00191301410f, PAL_EPSILON / 100 }, // y: -(e) - { 10, -2.30258509f, 0.00498212830f, PAL_EPSILON / 100 }, // y: -(ln(10)) - { 10, -1.57079633f, 0.0268660410f, PAL_EPSILON / 10 }, // y: -(pi / 2) - { 10, -1.44269504f, 0.0360831928f, PAL_EPSILON / 10 }, // y: -(logf2(e)) - { 10, -1.41421356f, 0.0385288847f, PAL_EPSILON / 10 }, // y: -(sqrtf(2)) - { 10, -1.12837917f, 0.0744082059f, PAL_EPSILON / 10 }, // y: -(2 / sqrtf(pi)) - { 10, -1, 0.1f, PAL_EPSILON }, // y: -(1) - { 10, -0.785398163f, 0.163908636f, PAL_EPSILON }, // y: -(pi / 4) - { 10, -0.707106781f, 0.196287760f, PAL_EPSILON }, // y: -(1 / sqrtf(2)) - { 10, -0.693147181f, 0.202699566f, PAL_EPSILON }, // y: -(ln(2)) - { 10, -0.636619772f, 0.230876765f, PAL_EPSILON }, // y: -(2 / pi) - { 10, -0.434294482f, 0.367879441f, PAL_EPSILON }, // y: -(log10f(e)) - { 10, -0.318309886f, 0.480496373f, PAL_EPSILON }, // y: -(1 / pi) - { 10, 0, 1, PAL_EPSILON * 10 }, - { 10, 0.318309886f, 2.08118116f, PAL_EPSILON * 10 }, // y: 1 / pi - { 10, 0.434294482f, 2.71828183f, PAL_EPSILON * 10 }, // y: log10f(e) expected: e - { 10, 0.636619772f, 4.33131503f, PAL_EPSILON * 10 }, // y: 2 / pi - { 10, 0.693147181f, 4.93340967f, PAL_EPSILON * 10 }, // y: ln(2) - { 10, 0.707106781f, 5.09456117f, PAL_EPSILON * 10 }, // y: 1 / sqrtf(2) - { 10, 0.785398163f, 6.10095980f, PAL_EPSILON * 10 }, // y: pi / 4 - { 10, 1, 10, PAL_EPSILON * 100 }, - { 10, 1.12837917f, 13.4393779f, PAL_EPSILON * 100 }, // y: 2 / sqrtf(pi) - { 10, 1.41421356f, 25.9545535f, PAL_EPSILON * 100 }, // y: sqrtf(2) - { 10, 1.44269504f, 27.7137338f, PAL_EPSILON * 100 }, // y: logf2(e) - { 10, 1.57079633f, 37.2217105f, PAL_EPSILON * 100 }, // y: pi / 2 - { 10, 2.30258509f, 200.717432f, PAL_EPSILON * 1000 }, // y: ln(10) - { 10, 2.71828183f, 522.735300f, PAL_EPSILON * 1000 }, // y: e - { 10, 3.14159265f, 1385.45573f, PAL_EPSILON * 10000 }, // y: pi - { 10, PAL_POSINF, PAL_POSINF, 0 }, - - { PAL_POSINF, PAL_NEGINF, 0, PAL_EPSILON }, - { PAL_POSINF, PAL_POSINF, PAL_POSINF, 0 }, - }; - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - validate(tests[i].x, tests[i].y, tests[i].expected, tests[i].variance); - } - - validate_isnan(-10, -1.57079633f); // y: -(pi / 2) - validate_isnan(-10, -0.785398163f); // y: -(pi / 4) - validate_isnan(-10, 0.785398163f); // y: pi / 4 - validate_isnan(-10, 1.57079633f); // y: pi / 2 - - validate_isnan(-2.71828183f, -1.57079633f); // x: -(e) y: -(pi / 2) - validate_isnan(-2.71828183f, -0.785398163f); // x: -(e) y: -(pi / 4) - validate_isnan(-2.71828183f, 0.785398163f); // x: -(e) y: pi / 4 - validate_isnan(-2.71828183f, 1.57079633f); // x: -(e) y: pi / 2 - - validate_isnan(PAL_NEGINF, PAL_NAN); - validate_isnan(PAL_NAN, PAL_NEGINF); - - validate_isnan(PAL_POSINF, PAL_NAN); - validate_isnan(PAL_NAN, PAL_POSINF); - - validate_isnan(PAL_NAN, PAL_NAN); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/powf/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/powf/test1/testinfo.dat deleted file mode 100644 index 778c04202..000000000 --- a/src/pal/tests/palsuite/c_runtime/powf/test1/testinfo.dat +++ /dev/null @@ -1,17 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = powf -Name = Call powf with some std input/output. -TYPE = DEFAULT -EXE1 = test1 -Description -= Call the powf function with various num/expfonent pairs -= that should produce std answers. - - - - diff --git a/src/pal/tests/palsuite/c_runtime/printf/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/printf/CMakeLists.txt deleted file mode 100644 index cafb9536b..000000000 --- a/src/pal/tests/palsuite/c_runtime/printf/CMakeLists.txt +++ /dev/null @@ -1,22 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test10) -add_subdirectory(test11) -add_subdirectory(test12) -add_subdirectory(test13) -add_subdirectory(test14) -add_subdirectory(test15) -add_subdirectory(test16) -add_subdirectory(test17) -add_subdirectory(test18) -add_subdirectory(test19) -add_subdirectory(test2) -add_subdirectory(test3) -add_subdirectory(test4) -add_subdirectory(test5) -add_subdirectory(test6) -add_subdirectory(test7) -add_subdirectory(test8) -add_subdirectory(test9) - diff --git a/src/pal/tests/palsuite/c_runtime/printf/printf.h b/src/pal/tests/palsuite/c_runtime/printf/printf.h deleted file mode 100644 index 8ef725f30..000000000 --- a/src/pal/tests/palsuite/c_runtime/printf/printf.h +++ /dev/null @@ -1,182 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: printf.h -** -** Purpose: Containts common testing functions for printf -** -** -**==========================================================================*/ - -#ifndef __printf_H__ -#define __printf_H__ - -void DoStrTest(const char *formatstr, char* param, const char *checkstr) -{ - int ret; - - ret = printf(formatstr, param); - if (ret != strlen(checkstr)) - { - Fail("Expected printf to return %d, got %d.\n", - strlen(checkstr), ret); - } -} - -void DoWStrTest(const char *formatstr, WCHAR* param, const char *checkstr) -{ - int ret; - - ret = printf(formatstr, param); - if (ret != strlen(checkstr)) - { - Fail("Expected printf to return %d, got %d.\n", - strlen(checkstr), ret); - } -} - -void DoPointerTest(const char *formatstr, void* param, char* paramstr, - const char *checkstr1) -{ - int ret; - - ret = printf(formatstr, param); - if (ret != strlen(checkstr1)) - { - Fail("Expected printf to return %d, got %d.\n", - strlen(checkstr1), ret); - } -} - -void DoCountTest(const char *formatstr, int param, const char *checkstr) -{ - int ret; - int n = -1; - - ret = printf(formatstr, &n); - - if (n != param) - { - Fail("Expected count parameter to resolve to %d, got %d\n", param, n); - } - - if (ret != strlen(checkstr)) - { - Fail("Expected printf to return %d, got %d.\n", - strlen(checkstr), ret); - } -} - -void DoShortCountTest(const char *formatstr, int param, const char *checkstr) -{ - int ret; - short int n = -1; - - ret = printf(formatstr, &n); - - if (n != param) - { - Fail("Expected count parameter to resolve to %d, got %d\n", param, n); - } - - if (ret != strlen(checkstr)) - { - Fail("Expected printf to return %d, got %d.\n", - strlen(checkstr), ret); - } -} - - -void DoCharTest(const char *formatstr, char param, const char *checkstr) -{ - int ret; - - ret = printf(formatstr, param); - if (ret != strlen(checkstr)) - { - Fail("Expected printf to return %d, got %d.\n", - strlen(checkstr), ret); - } -} - -void DoWCharTest(const char *formatstr, WCHAR param, const char *checkstr) -{ - int ret; - - ret = printf(formatstr, param); - if (ret != strlen(checkstr)) - { - Fail("Expected printf to return %d, got %d.\n", - strlen(checkstr), ret); - } -} - -void DoNumTest(const char *formatstr, int param, const char *checkstr) -{ - int ret; - - ret = printf(formatstr, param); - if (ret != strlen(checkstr)) - { - Fail("Expected printf to return %d, got %d.\n", - strlen(checkstr), ret); - } -} - -void DoI64Test(const char *formatstr, INT64 param, char *valuestr, - const char *checkstr1) -{ - int ret; - - ret = printf(formatstr, param); - if (ret != strlen(checkstr1)) - { - Fail("Expected printf to return %d, got %d.\n", - strlen(checkstr1), ret); - } -} - -void DoDoubleTest(const char *formatstr, double param, - const char *checkstr1, const char *checkstr2) -{ - int ret; - - ret = printf(formatstr, param); - if (ret != strlen(checkstr1) && ret != strlen(checkstr2)) - { - Fail("Expected printf to return %d or %d, got %d.\n", - strlen(checkstr1), strlen(checkstr2), ret); - } -} - -void DoArgumentPrecTest(const char *formatstr, int precision, void *param, - char *paramstr, const char *checkstr1, const char *checkstr2) -{ - int ret; - - ret = printf(formatstr, precision, param); - if (ret != strlen(checkstr1) && ret != strlen(checkstr2)) - { - Fail("Expected printf to return %d or %d, got %d.\n", - strlen(checkstr1), strlen(checkstr2), ret); - } -} - -void DoArgumentPrecDoubleTest(const char *formatstr, int precision, double param, - const char *checkstr1, const char *checkstr2) -{ - int ret; - - ret = printf(formatstr, precision, param); - if (ret != strlen(checkstr1) && ret != strlen(checkstr2)) - { - Fail("Expected printf to return %d or %d, got %d.\n", - strlen(checkstr1), strlen(checkstr2), ret); - } -} - -#endif - diff --git a/src/pal/tests/palsuite/c_runtime/printf/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/printf/test1/CMakeLists.txt deleted file mode 100644 index 0938d8fb7..000000000 --- a/src/pal/tests/palsuite/c_runtime/printf/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_printf_test1 - ${SOURCES} -) - -add_dependencies(paltest_printf_test1 coreclrpal) - -target_link_libraries(paltest_printf_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/printf/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/printf/test1/test1.cpp deleted file mode 100644 index 31b701434..000000000 --- a/src/pal/tests/palsuite/c_runtime/printf/test1/test1.cpp +++ /dev/null @@ -1,43 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: Test #1 for the printf function. A single, basic, test -** case with no formatting. -** -** -**==========================================================================*/ - - - -#include -#include "../printf.h" - -int __cdecl main(int argc, char *argv[]) -{ - char checkstr[] = "hello world"; - int ret; - - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - ret = printf("hello world"); - - if (ret != strlen(checkstr)) - { - Fail("Expected printf to return %d, got %d.\n", - strlen(checkstr), ret); - - } - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/c_runtime/printf/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/printf/test1/testinfo.dat deleted file mode 100644 index fe8bee680..000000000 --- a/src/pal/tests/palsuite/c_runtime/printf/test1/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = printf -Name = Positive Test for printf -TYPE = DEFAULT -EXE1 = test1 -Description -= General test to see if printf works correctly diff --git a/src/pal/tests/palsuite/c_runtime/printf/test10/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/printf/test10/CMakeLists.txt deleted file mode 100644 index f2a284b2a..000000000 --- a/src/pal/tests/palsuite/c_runtime/printf/test10/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test10.cpp -) - -add_executable(paltest_printf_test10 - ${SOURCES} -) - -add_dependencies(paltest_printf_test10 coreclrpal) - -target_link_libraries(paltest_printf_test10 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/printf/test10/test10.cpp b/src/pal/tests/palsuite/c_runtime/printf/test10/test10.cpp deleted file mode 100644 index 5e69175b0..000000000 --- a/src/pal/tests/palsuite/c_runtime/printf/test10/test10.cpp +++ /dev/null @@ -1,52 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test10.c -** -** Purpose: Test #10 for the printf function. Tests the octal specifier -** (%o). -** -** -**==========================================================================*/ - - - -#include -#include "../printf.h" - - -int __cdecl main(int argc, char *argv[]) -{ - int neg = -42; - int pos = 42; - INT64 l = 42; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - DoNumTest("foo %o", pos, "foo 52"); - DoNumTest("foo %lo", 0xFFFF, "foo 177777"); - DoNumTest("foo %ho", 0xFFFF, "foo 177777"); - DoNumTest("foo %Lo", pos, "foo 52"); - DoI64Test("foo %I64o", l, "42", "foo 52"); - DoNumTest("foo %3o", pos, "foo 52"); - DoNumTest("foo %-3o", pos, "foo 52 "); - DoNumTest("foo %.1o", pos, "foo 52"); - DoNumTest("foo %.3o", pos, "foo 052"); - DoNumTest("foo %03o", pos, "foo 052"); - DoNumTest("foo %#o", pos, "foo 052"); - DoNumTest("foo %+o", pos, "foo 52"); - DoNumTest("foo % o", pos, "foo 52"); - DoNumTest("foo %+o", neg, "foo 37777777726"); - DoNumTest("foo % o", neg, "foo 37777777726"); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/c_runtime/printf/test10/testinfo.dat b/src/pal/tests/palsuite/c_runtime/printf/test10/testinfo.dat deleted file mode 100644 index 7667a0f46..000000000 --- a/src/pal/tests/palsuite/c_runtime/printf/test10/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = printf -Name = Positive Test for printf -TYPE = DEFAULT -EXE1 = test10 -Description -= Tests printf with octal numbers diff --git a/src/pal/tests/palsuite/c_runtime/printf/test11/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/printf/test11/CMakeLists.txt deleted file mode 100644 index 8eb44b5e4..000000000 --- a/src/pal/tests/palsuite/c_runtime/printf/test11/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test11.cpp -) - -add_executable(paltest_printf_test11 - ${SOURCES} -) - -add_dependencies(paltest_printf_test11 coreclrpal) - -target_link_libraries(paltest_printf_test11 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/printf/test11/test11.cpp b/src/pal/tests/palsuite/c_runtime/printf/test11/test11.cpp deleted file mode 100644 index 788be8b2d..000000000 --- a/src/pal/tests/palsuite/c_runtime/printf/test11/test11.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test11.c -** -** Purpose: Test #11 for the printf function. Test the unsigned int -** specifier (%u). -** -** -**==========================================================================*/ - - - -#include -#include "../printf.h" - -int __cdecl main(int argc, char *argv[]) -{ - int neg = -42; - int pos = 42; - INT64 l = 42; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - DoNumTest("foo %u", pos, "foo 42"); - DoNumTest("foo %lu", 0xFFFF, "foo 65535"); - DoNumTest("foo %hu", 0xFFFF, "foo 65535"); - DoNumTest("foo %Lu", pos, "foo 42"); - DoI64Test("foo %I64u", l, "42", "foo 42"); - DoNumTest("foo %3u", pos, "foo 42"); - DoNumTest("foo %-3u", pos, "foo 42 "); - DoNumTest("foo %.1u", pos, "foo 42"); - DoNumTest("foo %.3u", pos, "foo 042"); - DoNumTest("foo %03u", pos, "foo 042"); - DoNumTest("foo %#u", pos, "foo 42"); - DoNumTest("foo %+u", pos, "foo 42"); - DoNumTest("foo % u", pos, "foo 42"); - DoNumTest("foo %+u", neg, "foo 4294967254"); - DoNumTest("foo % u", neg, "foo 4294967254"); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/c_runtime/printf/test11/testinfo.dat b/src/pal/tests/palsuite/c_runtime/printf/test11/testinfo.dat deleted file mode 100644 index a88e0d8fc..000000000 --- a/src/pal/tests/palsuite/c_runtime/printf/test11/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = printf -Name = Positive Test for printf -TYPE = DEFAULT -EXE1 = test11 -Description -= Tests printf with unsigned numbers diff --git a/src/pal/tests/palsuite/c_runtime/printf/test12/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/printf/test12/CMakeLists.txt deleted file mode 100644 index 17c4a5381..000000000 --- a/src/pal/tests/palsuite/c_runtime/printf/test12/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test12.cpp -) - -add_executable(paltest_printf_test12 - ${SOURCES} -) - -add_dependencies(paltest_printf_test12 coreclrpal) - -target_link_libraries(paltest_printf_test12 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/printf/test12/test12.cpp b/src/pal/tests/palsuite/c_runtime/printf/test12/test12.cpp deleted file mode 100644 index b4006f240..000000000 --- a/src/pal/tests/palsuite/c_runtime/printf/test12/test12.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test12.c -** -** Purpose: Test #12 for the printf function. Tests the (lowercase) -** hexadecimal specifier (%x) -** -** -**==========================================================================*/ - - - -#include -#include "../printf.h" - - -int __cdecl main(int argc, char *argv[]) -{ - int neg = -42; - int pos = 0x1234ab; - INT64 l = I64(0x1234567887654321); - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - DoNumTest("foo %x", pos, "foo 1234ab"); - DoNumTest("foo %lx", pos, "foo 1234ab"); - DoNumTest("foo %hx", pos, "foo 34ab"); - DoNumTest("foo %Lx", pos, "foo 1234ab"); - DoI64Test("foo %I64x", l, "0x1234567887654321", - "foo 1234567887654321"); - DoNumTest("foo %7x", pos, "foo 1234ab"); - DoNumTest("foo %-7x", pos, "foo 1234ab "); - DoNumTest("foo %.1x", pos, "foo 1234ab"); - DoNumTest("foo %.7x", pos, "foo 01234ab"); - DoNumTest("foo %07x", pos, "foo 01234ab"); - DoNumTest("foo %#x", pos, "foo 0x1234ab"); - DoNumTest("foo %+x", pos, "foo 1234ab"); - DoNumTest("foo % x", pos, "foo 1234ab"); - DoNumTest("foo %+x", neg, "foo ffffffd6"); - DoNumTest("foo % x", neg, "foo ffffffd6"); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/c_runtime/printf/test12/testinfo.dat b/src/pal/tests/palsuite/c_runtime/printf/test12/testinfo.dat deleted file mode 100644 index a6e317f90..000000000 --- a/src/pal/tests/palsuite/c_runtime/printf/test12/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = printf -Name = Positive Test for printf -TYPE = DEFAULT -EXE1 = test12 -Description -= Tests printf with hex numbers (lowercase) diff --git a/src/pal/tests/palsuite/c_runtime/printf/test13/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/printf/test13/CMakeLists.txt deleted file mode 100644 index 13b0f6318..000000000 --- a/src/pal/tests/palsuite/c_runtime/printf/test13/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test13.cpp -) - -add_executable(paltest_printf_test13 - ${SOURCES} -) - -add_dependencies(paltest_printf_test13 coreclrpal) - -target_link_libraries(paltest_printf_test13 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/printf/test13/test13.cpp b/src/pal/tests/palsuite/c_runtime/printf/test13/test13.cpp deleted file mode 100644 index ccd16b50d..000000000 --- a/src/pal/tests/palsuite/c_runtime/printf/test13/test13.cpp +++ /dev/null @@ -1,54 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test13.c -** -** Purpose: Test #13 for the printf function. Tests the (uppercase) -** hexadecimal specifier (%X) -** -** -**==========================================================================*/ - - - -#include -#include "../printf.h" - - - -int __cdecl main(int argc, char *argv[]) -{ - int neg = -42; - int pos = 0x1234AB; - INT64 l = I64(0x1234567887654321); - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - DoNumTest("foo %X", pos, "foo 1234AB"); - DoNumTest("foo %lX", pos, "foo 1234AB"); - DoNumTest("foo %hX", pos, "foo 34AB"); - DoNumTest("foo %LX", pos, "foo 1234AB"); - DoI64Test("foo %I64X", l, "0x1234567887654321", - "foo 1234567887654321"); - DoNumTest("foo %7X", pos, "foo 1234AB"); - DoNumTest("foo %-7X", pos, "foo 1234AB "); - DoNumTest("foo %.1X", pos, "foo 1234AB"); - DoNumTest("foo %.7X", pos, "foo 01234AB"); - DoNumTest("foo %07X", pos, "foo 01234AB"); - DoNumTest("foo %#X", pos, "foo 0X1234AB"); - DoNumTest("foo %+X", pos, "foo 1234AB"); - DoNumTest("foo % X", pos, "foo 1234AB"); - DoNumTest("foo %+X", neg, "foo FFFFFFD6"); - DoNumTest("foo % X", neg, "foo FFFFFFD6"); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/c_runtime/printf/test13/testinfo.dat b/src/pal/tests/palsuite/c_runtime/printf/test13/testinfo.dat deleted file mode 100644 index e814040b3..000000000 --- a/src/pal/tests/palsuite/c_runtime/printf/test13/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = printf -Name = Positive Test for printf -TYPE = DEFAULT -EXE1 = test13 -Description -= Tests printf with hex numbers (uppercase) diff --git a/src/pal/tests/palsuite/c_runtime/printf/test14/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/printf/test14/CMakeLists.txt deleted file mode 100644 index 22fd9ab76..000000000 --- a/src/pal/tests/palsuite/c_runtime/printf/test14/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test14.cpp -) - -add_executable(paltest_printf_test14 - ${SOURCES} -) - -add_dependencies(paltest_printf_test14 coreclrpal) - -target_link_libraries(paltest_printf_test14 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/printf/test14/test14.cpp b/src/pal/tests/palsuite/c_runtime/printf/test14/test14.cpp deleted file mode 100644 index 10577db67..000000000 --- a/src/pal/tests/palsuite/c_runtime/printf/test14/test14.cpp +++ /dev/null @@ -1,54 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test14.c -** -** Purpose: Test #14 for the printf function. Tests the lowercase -** exponential notation double specifier (%e) -** -** -**==========================================================================*/ - - - -#include -#include "../printf.h" - - - -int __cdecl main(int argc, char *argv[]) -{ - double val = 256.0; - double neg = -256.0; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - DoDoubleTest("foo %e", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %le", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %he", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %Le", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %I64e", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %14e", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %-14e", val, "foo 2.560000e+002 ", - "foo 2.560000e+02 "); - DoDoubleTest("foo %.1e", val, "foo 2.6e+002", "foo 2.6e+02"); - DoDoubleTest("foo %.8e", val, "foo 2.56000000e+002", - "foo 2.56000000e+02"); - DoDoubleTest("foo %014e", val, "foo 02.560000e+002", - "foo 002.560000e+02"); - DoDoubleTest("foo %#e", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %+e", val, "foo +2.560000e+002", "foo +2.560000e+02"); - DoDoubleTest("foo % e", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %+e", neg, "foo -2.560000e+002", "foo -2.560000e+02"); - DoDoubleTest("foo % e", neg, "foo -2.560000e+002", "foo -2.560000e+02"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/printf/test14/testinfo.dat b/src/pal/tests/palsuite/c_runtime/printf/test14/testinfo.dat deleted file mode 100644 index 5cb22c1fc..000000000 --- a/src/pal/tests/palsuite/c_runtime/printf/test14/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = printf -Name = Positive Test for printf -TYPE = DEFAULT -EXE1 = test14 -Description -= Tests printf with exponential format doubles (lowercase) diff --git a/src/pal/tests/palsuite/c_runtime/printf/test15/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/printf/test15/CMakeLists.txt deleted file mode 100644 index cc350a5e5..000000000 --- a/src/pal/tests/palsuite/c_runtime/printf/test15/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test15.cpp -) - -add_executable(paltest_printf_test15 - ${SOURCES} -) - -add_dependencies(paltest_printf_test15 coreclrpal) - -target_link_libraries(paltest_printf_test15 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/printf/test15/test15.cpp b/src/pal/tests/palsuite/c_runtime/printf/test15/test15.cpp deleted file mode 100644 index 2acfc436a..000000000 --- a/src/pal/tests/palsuite/c_runtime/printf/test15/test15.cpp +++ /dev/null @@ -1,54 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test15.c -** -** Purpose: Test #15 for the printf function. Tests the uppercase -** exponential notation double specifier (%E) -** -** -**==========================================================================*/ - - - -#include -#include "../printf.h" - - - -int __cdecl main(int argc, char *argv[]) -{ - double val = 256.0; - double neg = -256.0; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - DoDoubleTest("foo %E", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %lE", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %hE", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %LE", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %I64E", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %14E", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %-14E", val, "foo 2.560000E+002 ", - "foo 2.560000E+02 "); - DoDoubleTest("foo %.1E", val, "foo 2.6E+002", "foo 2.6E+02"); - DoDoubleTest("foo %.8E", val, "foo 2.56000000E+002", - "foo 2.56000000E+02"); - DoDoubleTest("foo %014E", val, "foo 02.560000E+002", - "foo 002.560000E+02"); - DoDoubleTest("foo %#E", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %+E", val, "foo +2.560000E+002", "foo +2.560000E+02"); - DoDoubleTest("foo % E", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %+E", neg, "foo -2.560000E+002", "foo -2.560000E+02"); - DoDoubleTest("foo % E", neg, "foo -2.560000E+002", "foo -2.560000E+02"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/printf/test15/testinfo.dat b/src/pal/tests/palsuite/c_runtime/printf/test15/testinfo.dat deleted file mode 100644 index bdfa2cc3b..000000000 --- a/src/pal/tests/palsuite/c_runtime/printf/test15/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = printf -Name = Positive Test for printf -TYPE = DEFAULT -EXE1 = test15 -Description -= Tests printf with exponential format doubles (uppercase) diff --git a/src/pal/tests/palsuite/c_runtime/printf/test16/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/printf/test16/CMakeLists.txt deleted file mode 100644 index a61b5a0bd..000000000 --- a/src/pal/tests/palsuite/c_runtime/printf/test16/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test16.cpp -) - -add_executable(paltest_printf_test16 - ${SOURCES} -) - -add_dependencies(paltest_printf_test16 coreclrpal) - -target_link_libraries(paltest_printf_test16 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/printf/test16/test16.cpp b/src/pal/tests/palsuite/c_runtime/printf/test16/test16.cpp deleted file mode 100644 index 50c952f95..000000000 --- a/src/pal/tests/palsuite/c_runtime/printf/test16/test16.cpp +++ /dev/null @@ -1,50 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test16.c -** -** Purpose: Test #16 for the printf function. Tests the decimal notation -** double specifier (%f) -** -** -**==========================================================================*/ - - -#include -#include "../printf.h" - - - -int __cdecl main(int argc, char *argv[]) -{ - double val = 2560.001; - double neg = -2560.001; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - DoDoubleTest("foo %f", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %lf", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %hf", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %Lf", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %I64f", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %12f", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %-12f", val, "foo 2560.001000 ", "foo 2560.001000 "); - DoDoubleTest("foo %.1f", val, "foo 2560.0", "foo 2560.0"); - DoDoubleTest("foo %.8f", val, "foo 2560.00100000", "foo 2560.00100000"); - DoDoubleTest("foo %012f", val, "foo 02560.001000", "foo 02560.001000"); - DoDoubleTest("foo %#f", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %+f", val, "foo +2560.001000", "foo +2560.001000"); - DoDoubleTest("foo % f", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %+f", neg, "foo -2560.001000", "foo -2560.001000"); - DoDoubleTest("foo % f", neg, "foo -2560.001000", "foo -2560.001000"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/printf/test16/testinfo.dat b/src/pal/tests/palsuite/c_runtime/printf/test16/testinfo.dat deleted file mode 100644 index afb9a21b3..000000000 --- a/src/pal/tests/palsuite/c_runtime/printf/test16/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = printf -Name = Positive Test for printf -TYPE = DEFAULT -EXE1 = test16 -Description -= Tests printf with decimal point format doubles diff --git a/src/pal/tests/palsuite/c_runtime/printf/test17/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/printf/test17/CMakeLists.txt deleted file mode 100644 index f8c1754d8..000000000 --- a/src/pal/tests/palsuite/c_runtime/printf/test17/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test17.cpp -) - -add_executable(paltest_printf_test17 - ${SOURCES} -) - -add_dependencies(paltest_printf_test17 coreclrpal) - -target_link_libraries(paltest_printf_test17 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/printf/test17/test17.cpp b/src/pal/tests/palsuite/c_runtime/printf/test17/test17.cpp deleted file mode 100644 index 96ddd5c1e..000000000 --- a/src/pal/tests/palsuite/c_runtime/printf/test17/test17.cpp +++ /dev/null @@ -1,52 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test17.c -** -** Purpose: Test #17 for the printf function. Tests the lowercase -** shorthand notation double specifier (%g) -** -** -**==========================================================================*/ - - - -#include -#include "../printf.h" - - - -int __cdecl main(int argc, char *argv[]) -{ - double val = 2560.001; - double neg = -2560.001; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - DoDoubleTest("foo %g", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %lg", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %hg", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %Lg", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %I64g", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %5g", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %-5g", val, "foo 2560 ", "foo 2560 "); - DoDoubleTest("foo %.1g", val, "foo 3e+003", "foo 3e+03"); - DoDoubleTest("foo %.2g", val, "foo 2.6e+003", "foo 2.6e+03"); - DoDoubleTest("foo %.12g", val, "foo 2560.001", "foo 2560.001"); - DoDoubleTest("foo %06g", val, "foo 002560", "foo 002560"); - DoDoubleTest("foo %#g", val, "foo 2560.00", "foo 2560.00"); - DoDoubleTest("foo %+g", val, "foo +2560", "foo +2560"); - DoDoubleTest("foo % g", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %+g", neg, "foo -2560", "foo -2560"); - DoDoubleTest("foo % g", neg, "foo -2560", "foo -2560"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/printf/test17/testinfo.dat b/src/pal/tests/palsuite/c_runtime/printf/test17/testinfo.dat deleted file mode 100644 index a8545d954..000000000 --- a/src/pal/tests/palsuite/c_runtime/printf/test17/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = printf -Name = Positive Test for printf -TYPE = DEFAULT -EXE1 = test17 -Description -= Tests printf with compact format doubles (lowercase) diff --git a/src/pal/tests/palsuite/c_runtime/printf/test18/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/printf/test18/CMakeLists.txt deleted file mode 100644 index c83c096e9..000000000 --- a/src/pal/tests/palsuite/c_runtime/printf/test18/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test18.cpp -) - -add_executable(paltest_printf_test18 - ${SOURCES} -) - -add_dependencies(paltest_printf_test18 coreclrpal) - -target_link_libraries(paltest_printf_test18 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/printf/test18/test18.cpp b/src/pal/tests/palsuite/c_runtime/printf/test18/test18.cpp deleted file mode 100644 index 6c05e40f4..000000000 --- a/src/pal/tests/palsuite/c_runtime/printf/test18/test18.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test18.c -** -** Purpose: Test #18 for the printf function. Tests the uppercase -** shorthand notation double specifier (%G) -** -** -**==========================================================================*/ - - -#include -#include "../printf.h" - - - -int __cdecl main(int argc, char *argv[]) -{ - double val = 2560.001; - double neg = -2560.001; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - DoDoubleTest("foo %G", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %lG", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %hG", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %LG", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %I64G", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %5G", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %-5G", val, "foo 2560 ", "foo 2560 "); - DoDoubleTest("foo %.1G", val, "foo 3E+003", "foo 3E+03"); - DoDoubleTest("foo %.2G", val, "foo 2.6E+003", "foo 2.6E+03"); - DoDoubleTest("foo %.12G", val, "foo 2560.001", "foo 2560.001"); - DoDoubleTest("foo %06G", val, "foo 002560", "foo 002560"); - DoDoubleTest("foo %#G", val, "foo 2560.00", "foo 2560.00"); - DoDoubleTest("foo %+G", val, "foo +2560", "foo +2560"); - DoDoubleTest("foo % G", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %+G", neg, "foo -2560", "foo -2560"); - DoDoubleTest("foo % G", neg, "foo -2560", "foo -2560"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/printf/test18/testinfo.dat b/src/pal/tests/palsuite/c_runtime/printf/test18/testinfo.dat deleted file mode 100644 index bd5c90b0c..000000000 --- a/src/pal/tests/palsuite/c_runtime/printf/test18/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = printf -Name = Positive Test for printf -TYPE = DEFAULT -EXE1 = test18 -Description -= Tests printf with compact format doubles (uppercase) diff --git a/src/pal/tests/palsuite/c_runtime/printf/test19/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/printf/test19/CMakeLists.txt deleted file mode 100644 index 4d3fe5f79..000000000 --- a/src/pal/tests/palsuite/c_runtime/printf/test19/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test19.cpp -) - -add_executable(paltest_printf_test19 - ${SOURCES} -) - -add_dependencies(paltest_printf_test19 coreclrpal) - -target_link_libraries(paltest_printf_test19 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/printf/test19/test19.cpp b/src/pal/tests/palsuite/c_runtime/printf/test19/test19.cpp deleted file mode 100644 index a3ce0e7ad..000000000 --- a/src/pal/tests/palsuite/c_runtime/printf/test19/test19.cpp +++ /dev/null @@ -1,76 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test19.c -** -** Purpose: Test #19 for the printf function. Tests the variable length -** precision argument. -** -** -**==========================================================================*/ - - -#include -#include "../printf.h" - - - - -int __cdecl main(int argc, char *argv[]) -{ - int n = -1; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - DoArgumentPrecTest("%.*s", 2, (void*)"bar", "bar", "ba", "ba"); - DoArgumentPrecTest("%.*S", 2, (void*)convert("bar"), "bar", "ba", "ba"); - - DoArgumentPrecTest("%.*n", 3, (void*)&n, "pointer to int", "", ""); - if (n != 0) - { - Fail("ERROR: Expected count parameter to resolve to %d, got %X\n", - 0, n); - } - - DoArgumentPrecTest("%.*c", 0, (void*)'a', "a", "a", "a"); - DoArgumentPrecTest("%.*c", 4, (void*)'a', "a", "a", "a"); - DoArgumentPrecTest("%.*C", 0, (void*)'a', "a", "a", "a"); - DoArgumentPrecTest("%.*C", 4, (void*)'a', "a", "a", "a"); - DoArgumentPrecTest("%.*d", 1, (void*)42, "42", "42", "42"); - DoArgumentPrecTest("%.*d", 3, (void*)42, "42", "042", "042"); - DoArgumentPrecTest("%.*i", 1, (void*)42, "42", "42", "42"); - DoArgumentPrecTest("%.*i", 3, (void*)42, "42", "042", "042"); - DoArgumentPrecTest("%.*o", 1, (void*)42, "42", "52", "52"); - DoArgumentPrecTest("%.*o", 3, (void*)42, "42", "052", "052"); - DoArgumentPrecTest("%.*u", 1, (void*)42, "42", "42", "42"); - DoArgumentPrecTest("%.*u", 3, (void*)42, "42", "042", "042"); - DoArgumentPrecTest("%.*x", 1, (void*)0x42, "0x42", "42", "42"); - DoArgumentPrecTest("%.*x", 3, (void*)0x42, "0x42", "042", "042"); - DoArgumentPrecTest("%.*X", 1, (void*)0x42, "0x42", "42", "42"); - DoArgumentPrecTest("%.*X", 3, (void*)0x42, "0x42", "042", "042"); - - - DoArgumentPrecDoubleTest("%.*e", 1, 2.01, "2.0e+000", "2.0e+00"); - DoArgumentPrecDoubleTest("%.*e", 3, 2.01, "2.010e+000", "2.010e+00"); - DoArgumentPrecDoubleTest("%.*E", 1, 2.01, "2.0E+000", "2.0E+00"); - DoArgumentPrecDoubleTest("%.*E", 3, 2.01, "2.010E+000", "2.010E+00"); - DoArgumentPrecDoubleTest("%.*f", 1, 2.01, "2.0", "2.0"); - DoArgumentPrecDoubleTest("%.*f", 3, 2.01, "2.010", "2.010"); - DoArgumentPrecDoubleTest("%.*g", 1, 256.01, "3e+002", "3e+02"); - DoArgumentPrecDoubleTest("%.*g", 3, 256.01, "256", "256"); - DoArgumentPrecDoubleTest("%.*g", 4, 256.01, "256", "256"); - DoArgumentPrecDoubleTest("%.*g", 6, 256.01, "256.01", "256.01"); - DoArgumentPrecDoubleTest("%.*G", 1, 256.01, "3E+002", "3E+02"); - DoArgumentPrecDoubleTest("%.*G", 3, 256.01, "256", "256"); - DoArgumentPrecDoubleTest("%.*G", 4, 256.01, "256", "256"); - DoArgumentPrecDoubleTest("%.*G", 6, 256.01, "256.01", "256.01"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/printf/test19/testinfo.dat b/src/pal/tests/palsuite/c_runtime/printf/test19/testinfo.dat deleted file mode 100644 index 6ad18f759..000000000 --- a/src/pal/tests/palsuite/c_runtime/printf/test19/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = printf -Name = Positive Test for printf -TYPE = DEFAULT -EXE1 = test19 -Description -= Tests printf with argument specified precision diff --git a/src/pal/tests/palsuite/c_runtime/printf/test2/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/printf/test2/CMakeLists.txt deleted file mode 100644 index d45c7727c..000000000 --- a/src/pal/tests/palsuite/c_runtime/printf/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test2.cpp -) - -add_executable(paltest_printf_test2 - ${SOURCES} -) - -add_dependencies(paltest_printf_test2 coreclrpal) - -target_link_libraries(paltest_printf_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/printf/test2/test2.cpp b/src/pal/tests/palsuite/c_runtime/printf/test2/test2.cpp deleted file mode 100644 index 1c61b1d86..000000000 --- a/src/pal/tests/palsuite/c_runtime/printf/test2/test2.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test2.c -** -** Purpose: Test #2 for the printf function. Tests the string specifier -** (%s). -** -** -**==========================================================================*/ - - -#include -#include "../printf.h" - - - -int __cdecl main(int argc, char *argv[]) -{ - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - DoStrTest("foo %s", "bar", "foo bar"); - DoStrTest("foo %hs", "bar", "foo bar"); - DoWStrTest("foo %ls", convert("bar"), "foo bar"); - DoWStrTest("foo %ws", convert("bar"), "foo bar"); - DoStrTest("foo %Ls", "bar", "foo bar"); - DoStrTest("foo %I64s", "bar", "foo bar"); - DoStrTest("foo %5s", "bar", "foo bar"); - DoStrTest("foo %.2s", "bar", "foo ba"); - DoStrTest("foo %5.2s", "bar", "foo ba"); - DoStrTest("foo %-5s", "bar", "foo bar "); - DoStrTest("foo %05s", "bar", "foo 00bar"); - DoStrTest("foo %s", NULL, "foo (null)"); - DoStrTest("foo %hs", NULL, "foo (null)"); - DoWStrTest("foo %ls", NULL, "foo (null)"); - DoWStrTest("foo %ws", NULL, "foo (null)"); - DoStrTest("foo %Ls", NULL, "foo (null)"); - DoStrTest("foo %I64s", NULL, "foo (null)"); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/c_runtime/printf/test2/testinfo.dat b/src/pal/tests/palsuite/c_runtime/printf/test2/testinfo.dat deleted file mode 100644 index 3ff71c749..000000000 --- a/src/pal/tests/palsuite/c_runtime/printf/test2/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = printf -Name = Positive Test for printf -TYPE = DEFAULT -EXE1 = test2 -Description -= Tests printf with strings diff --git a/src/pal/tests/palsuite/c_runtime/printf/test3/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/printf/test3/CMakeLists.txt deleted file mode 100644 index b6d9ce2e6..000000000 --- a/src/pal/tests/palsuite/c_runtime/printf/test3/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test3.cpp -) - -add_executable(paltest_printf_test3 - ${SOURCES} -) - -add_dependencies(paltest_printf_test3 coreclrpal) - -target_link_libraries(paltest_printf_test3 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/printf/test3/test3.cpp b/src/pal/tests/palsuite/c_runtime/printf/test3/test3.cpp deleted file mode 100644 index 79fe7213b..000000000 --- a/src/pal/tests/palsuite/c_runtime/printf/test3/test3.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test3.c -** -** Purpose: Test #3 for the printf function. Tests the wide string -** specifier (%S). -** -** -**==========================================================================*/ - - - -#include -#include "../printf.h" - - - -int __cdecl main(int argc, char *argv[]) -{ - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - DoWStrTest("foo %S", convert("bar"), "foo bar"); - DoStrTest("foo %hS", "bar", "foo bar"); - DoWStrTest("foo %lS", convert("bar"), "foo bar"); - DoWStrTest("foo %wS", convert("bar"), "foo bar"); - DoWStrTest("foo %LS", convert("bar"), "foo bar"); - DoWStrTest("foo %I64S", convert("bar"), "foo bar"); - DoWStrTest("foo %5S", convert("bar"), "foo bar"); - DoWStrTest("foo %.2S", convert("bar"), "foo ba"); - DoWStrTest("foo %5.2S", convert("bar"), "foo ba"); - DoWStrTest("foo %-5S", convert("bar"), "foo bar "); - DoWStrTest("foo %05S", convert("bar"), "foo 00bar"); - DoWStrTest("foo %S", NULL, "foo (null)"); - DoStrTest("foo %hS", NULL, "foo (null)"); - DoWStrTest("foo %lS", NULL, "foo (null)"); - DoWStrTest("foo %wS", NULL, "foo (null)"); - DoWStrTest("foo %LS", NULL, "foo (null)"); - DoWStrTest("foo %I64S", NULL, "foo (null)"); - - PAL_Terminate(); - return PASS; -} - - diff --git a/src/pal/tests/palsuite/c_runtime/printf/test3/testinfo.dat b/src/pal/tests/palsuite/c_runtime/printf/test3/testinfo.dat deleted file mode 100644 index 295c172f0..000000000 --- a/src/pal/tests/palsuite/c_runtime/printf/test3/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = printf -Name = Positive Test for printf -TYPE = DEFAULT -EXE1 = test3 -Description -= Tests printf with wide strings diff --git a/src/pal/tests/palsuite/c_runtime/printf/test4/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/printf/test4/CMakeLists.txt deleted file mode 100644 index 621c103cc..000000000 --- a/src/pal/tests/palsuite/c_runtime/printf/test4/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test4.cpp -) - -add_executable(paltest_printf_test4 - ${SOURCES} -) - -add_dependencies(paltest_printf_test4 coreclrpal) - -target_link_libraries(paltest_printf_test4 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/printf/test4/test4.cpp b/src/pal/tests/palsuite/c_runtime/printf/test4/test4.cpp deleted file mode 100644 index 7b0178cd2..000000000 --- a/src/pal/tests/palsuite/c_runtime/printf/test4/test4.cpp +++ /dev/null @@ -1,66 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test4.c -** -** Purpose: Test #4 for the printf function. Tests the pointer -** specifier (%p). -** -** -**==========================================================================*/ - - - -#include -#include "../printf.h" - -int __cdecl main(int argc, char *argv[]) -{ - void *ptr = (void*) 0x123456; - INT64 lptr = I64(0x1234567887654321); - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } -/* -** Run only on 64 bit platforms -*/ -#if defined(BIT64) - Trace("Testing for 64 Bit Platforms \n"); - DoPointerTest("%p", NULL, "NULL", "0000000000000000"); - DoPointerTest("%p", ptr, "pointer to 0x123456", "0000000000123456"); - DoPointerTest("%17p", ptr, "pointer to 0x123456", " 0000000000123456"); - DoPointerTest("%17p", ptr, "pointer to 0x123456", " 0000000000123456"); - DoPointerTest("%-17p", ptr, "pointer to 0x123456", "0000000000123456 "); - DoPointerTest("%+p", ptr, "pointer to 0x123456", "0000000000123456"); - DoPointerTest("%#p", ptr, "pointer to 0x123456", "0X0000000000123456"); - DoPointerTest("%lp", ptr, "pointer to 0x123456", "00123456"); - DoPointerTest("%hp", ptr, "pointer to 0x123456", "00003456"); - DoPointerTest("%Lp", ptr, "pointer to 0x123456", "00123456"); - DoI64Test("%I64p", lptr, "pointer to 0x1234567887654321", - "1234567887654321"); -#else - Trace("Testing for Non 64 Bit Platforms \n"); - DoPointerTest("%p", NULL, "NULL", "00000000"); - DoPointerTest("%p", ptr, "pointer to 0x123456", "00123456"); - DoPointerTest("%9p", ptr, "pointer to 0x123456", " 00123456"); - DoPointerTest("%09p", ptr, "pointer to 0x123456", " 00123456"); - DoPointerTest("%-9p", ptr, "pointer to 0x123456", "00123456 "); - DoPointerTest("%+p", ptr, "pointer to 0x123456", "00123456"); - DoPointerTest("%#p", ptr, "pointer to 0x123456", "0X00123456"); - DoPointerTest("%lp", ptr, "pointer to 0x123456", "00123456"); - DoPointerTest("%hp", ptr, "pointer to 0x123456", "00003456"); - DoPointerTest("%Lp", ptr, "pointer to 0x123456", "00123456"); - DoI64Test("%I64p", lptr, "pointer to 0x1234567887654321", - "1234567887654321"); - -#endif - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/c_runtime/printf/test4/testinfo.dat b/src/pal/tests/palsuite/c_runtime/printf/test4/testinfo.dat deleted file mode 100644 index 0c55e0ed3..000000000 --- a/src/pal/tests/palsuite/c_runtime/printf/test4/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = printf -Name = Positive Test for printf -TYPE = DEFAULT -EXE1 = test4 -Description -= Tests printf with pointers diff --git a/src/pal/tests/palsuite/c_runtime/printf/test5/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/printf/test5/CMakeLists.txt deleted file mode 100644 index 73e8b7dbf..000000000 --- a/src/pal/tests/palsuite/c_runtime/printf/test5/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test5.cpp -) - -add_executable(paltest_printf_test5 - ${SOURCES} -) - -add_dependencies(paltest_printf_test5 coreclrpal) - -target_link_libraries(paltest_printf_test5 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/printf/test5/test5.cpp b/src/pal/tests/palsuite/c_runtime/printf/test5/test5.cpp deleted file mode 100644 index 9f8baa74d..000000000 --- a/src/pal/tests/palsuite/c_runtime/printf/test5/test5.cpp +++ /dev/null @@ -1,60 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test5.c -** -** Purpose: Test #5 for the printf function. Tests the count specifier (%n). -** -** -**==========================================================================*/ - - - -#include -#include "../printf.h" - - - - -int __cdecl main(int argc, char *argv[]) -{ - char *longStr = - "really-long-string-that-just-keeps-going-on-and-on-and-on.." - "..................useless-filler.................................." - "..................useless-filler.................................." - "..................useless-filler.................................." - "%n bar"; - char *longResult = - "really-long-string-that-just-keeps-going-on-and-on-and-on.." - "..................useless-filler.................................." - "..................useless-filler.................................." - "..................useless-filler.................................." - " bar"; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - DoCountTest("foo %n bar", 4, "foo bar"); - DoCountTest(longStr, 257, longResult); - DoCountTest("fo%n bar", 2, "fo bar"); - DoCountTest("%n", 0, ""); - DoCountTest("foo %#n bar", 4, "foo bar"); - DoCountTest("foo % n bar", 4, "foo bar"); - DoCountTest("foo %+n bar", 4, "foo bar"); - DoCountTest("foo %-n bar", 4, "foo bar"); - DoCountTest("foo %0n bar", 4, "foo bar"); - DoShortCountTest("foo %hn bar", 4, "foo bar"); - DoCountTest("foo %ln bar", 4, "foo bar"); - DoCountTest("foo %Ln bar", 4, "foo bar"); - DoCountTest("foo %I64n bar", 4, "foo bar"); - DoCountTest("foo %20.3n bar", 4, "foo bar"); - - PAL_Terminate(); - - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/printf/test5/testinfo.dat b/src/pal/tests/palsuite/c_runtime/printf/test5/testinfo.dat deleted file mode 100644 index a7c7400f5..000000000 --- a/src/pal/tests/palsuite/c_runtime/printf/test5/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = printf -Name = Positive Test for printf -TYPE = DEFAULT -EXE1 = test5 -Description -= Tests printf with the count specifier diff --git a/src/pal/tests/palsuite/c_runtime/printf/test6/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/printf/test6/CMakeLists.txt deleted file mode 100644 index 07639c633..000000000 --- a/src/pal/tests/palsuite/c_runtime/printf/test6/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test6.cpp -) - -add_executable(paltest_printf_test6 - ${SOURCES} -) - -add_dependencies(paltest_printf_test6 coreclrpal) - -target_link_libraries(paltest_printf_test6 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/printf/test6/test6.cpp b/src/pal/tests/palsuite/c_runtime/printf/test6/test6.cpp deleted file mode 100644 index edc65b6b9..000000000 --- a/src/pal/tests/palsuite/c_runtime/printf/test6/test6.cpp +++ /dev/null @@ -1,48 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test6.c -** -** Purpose: Test #6 for the printf function. Tests the char specifier (%c). -** -** -**==========================================================================*/ - - - -#include -#include "../printf.h" - - - -int __cdecl main(int argc, char *argv[]) -{ - WCHAR wc = (WCHAR) 'c'; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - DoCharTest("foo %c", 'b', "foo b"); - DoCharTest("foo %hc", 'b', "foo b"); - DoWCharTest("foo %lc", wc, "foo c"); - DoCharTest("foo %Lc", 'b', "foo b"); - DoCharTest("foo %I64c", 'b', "foo b"); - DoCharTest("foo %5c", 'b', "foo b"); - DoCharTest("foo %.0c", 'b', "foo b"); - DoCharTest("foo %-5c", 'b', "foo b "); - DoCharTest("foo %05c", 'b', "foo 0000b"); - DoCharTest("foo % c", 'b', "foo b"); - DoCharTest("foo %#c", 'b', "foo b"); - - PAL_Terminate(); - return PASS; -} - - - diff --git a/src/pal/tests/palsuite/c_runtime/printf/test6/testinfo.dat b/src/pal/tests/palsuite/c_runtime/printf/test6/testinfo.dat deleted file mode 100644 index fd8a98529..000000000 --- a/src/pal/tests/palsuite/c_runtime/printf/test6/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = printf -Name = Positive Test for printf -TYPE = DEFAULT -EXE1 = test6 -Description -= Tests printf with characters diff --git a/src/pal/tests/palsuite/c_runtime/printf/test7/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/printf/test7/CMakeLists.txt deleted file mode 100644 index 72bc2858b..000000000 --- a/src/pal/tests/palsuite/c_runtime/printf/test7/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test7.cpp -) - -add_executable(paltest_printf_test7 - ${SOURCES} -) - -add_dependencies(paltest_printf_test7 coreclrpal) - -target_link_libraries(paltest_printf_test7 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/printf/test7/test7.cpp b/src/pal/tests/palsuite/c_runtime/printf/test7/test7.cpp deleted file mode 100644 index 3aeb58f7d..000000000 --- a/src/pal/tests/palsuite/c_runtime/printf/test7/test7.cpp +++ /dev/null @@ -1,47 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test7.c -** -** Purpose: Test #7 for the printf function. Tests the wide char -** specifier (%C). -** -** -**==========================================================================*/ - - - -#include -#include "../printf.h" - - - -int __cdecl main(int argc, char *argv[]) -{ - WCHAR wb = (WCHAR) 'b'; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - DoWCharTest("foo %C", wb, "foo b"); - DoWCharTest("foo %hC", wb, "foo b"); - DoCharTest("foo %lC", 'c', "foo c"); - DoWCharTest("foo %LC", wb, "foo b"); - DoWCharTest("foo %I64C", wb, "foo b"); - DoWCharTest("foo %5C", wb, "foo b"); - DoWCharTest("foo %.0C", wb, "foo b"); - DoWCharTest("foo %-5C", wb, "foo b "); - DoWCharTest("foo %05C", wb, "foo 0000b"); - DoWCharTest("foo % C", wb, "foo b"); - DoWCharTest("foo %#C", wb, "foo b"); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/c_runtime/printf/test7/testinfo.dat b/src/pal/tests/palsuite/c_runtime/printf/test7/testinfo.dat deleted file mode 100644 index 6d2b1cf84..000000000 --- a/src/pal/tests/palsuite/c_runtime/printf/test7/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = printf -Name = Positive Test for printf -TYPE = DEFAULT -EXE1 = test7 -Description -= Tests printf with wide characters diff --git a/src/pal/tests/palsuite/c_runtime/printf/test8/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/printf/test8/CMakeLists.txt deleted file mode 100644 index 78ce601ca..000000000 --- a/src/pal/tests/palsuite/c_runtime/printf/test8/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test8.cpp -) - -add_executable(paltest_printf_test8 - ${SOURCES} -) - -add_dependencies(paltest_printf_test8 coreclrpal) - -target_link_libraries(paltest_printf_test8 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/printf/test8/test8.cpp b/src/pal/tests/palsuite/c_runtime/printf/test8/test8.cpp deleted file mode 100644 index daa4674b9..000000000 --- a/src/pal/tests/palsuite/c_runtime/printf/test8/test8.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test8.c -** -** Purpose: Test #8 for the printf function. Tests the decimal -** specifier (%d). -** -** -**==========================================================================*/ - - - -#include -#include "../printf.h" - - - -int __cdecl main(int argc, char *argv[]) -{ - int neg = -42; - int pos = 42; - INT64 l = 42; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - DoNumTest("foo %d", pos, "foo 42"); - DoNumTest("foo %ld", 0xFFFF, "foo 65535"); - DoNumTest("foo %hd", 0xFFFF, "foo -1"); - DoNumTest("foo %Ld", pos, "foo 42"); - DoI64Test("foo %I64d", l, "42", "foo 42"); - DoNumTest("foo %3d", pos, "foo 42"); - DoNumTest("foo %-3d", pos, "foo 42 "); - DoNumTest("foo %.1d", pos, "foo 42"); - DoNumTest("foo %.3d", pos, "foo 042"); - DoNumTest("foo %03d", pos, "foo 042"); - DoNumTest("foo %#d", pos, "foo 42"); - DoNumTest("foo %+d", pos, "foo +42"); - DoNumTest("foo % d", pos, "foo 42"); - DoNumTest("foo %+d", neg, "foo -42"); - DoNumTest("foo % d", neg, "foo -42"); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/c_runtime/printf/test8/testinfo.dat b/src/pal/tests/palsuite/c_runtime/printf/test8/testinfo.dat deleted file mode 100644 index 6367235aa..000000000 --- a/src/pal/tests/palsuite/c_runtime/printf/test8/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = printf -Name = Positive Test for printf -TYPE = DEFAULT -EXE1 = test8 -Description -= Tests printf with decimal numbers diff --git a/src/pal/tests/palsuite/c_runtime/printf/test9/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/printf/test9/CMakeLists.txt deleted file mode 100644 index dfc2a8316..000000000 --- a/src/pal/tests/palsuite/c_runtime/printf/test9/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test9.cpp -) - -add_executable(paltest_printf_test9 - ${SOURCES} -) - -add_dependencies(paltest_printf_test9 coreclrpal) - -target_link_libraries(paltest_printf_test9 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/printf/test9/test9.cpp b/src/pal/tests/palsuite/c_runtime/printf/test9/test9.cpp deleted file mode 100644 index 22c60d04f..000000000 --- a/src/pal/tests/palsuite/c_runtime/printf/test9/test9.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test9.c -** -** Purpose: Test #9 for the printf function. Tests the integer -** specifier (%i). -** -** -**==========================================================================*/ - - - -#include -#include "../printf.h" - - - -int __cdecl main(int argc, char *argv[]) -{ - int neg = -42; - int pos = 42; - INT64 l = 42; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - DoNumTest("foo %i", pos, "foo 42"); - DoNumTest("foo %li", 0xFFFF, "foo 65535"); - DoNumTest("foo %hi", 0xFFFF, "foo -1"); - DoNumTest("foo %Li", pos, "foo 42"); - DoI64Test("foo %I64i", l, "42", "foo 42"); - DoNumTest("foo %3i", pos, "foo 42"); - DoNumTest("foo %-3i", pos, "foo 42 "); - DoNumTest("foo %.1i", pos, "foo 42"); - DoNumTest("foo %.3i", pos, "foo 042"); - DoNumTest("foo %03i", pos, "foo 042"); - DoNumTest("foo %#i", pos, "foo 42"); - DoNumTest("foo %+i", pos, "foo +42"); - DoNumTest("foo % i", pos, "foo 42"); - DoNumTest("foo %+i", neg, "foo -42"); - DoNumTest("foo % i", neg, "foo -42"); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/c_runtime/printf/test9/testinfo.dat b/src/pal/tests/palsuite/c_runtime/printf/test9/testinfo.dat deleted file mode 100644 index 3208cb44a..000000000 --- a/src/pal/tests/palsuite/c_runtime/printf/test9/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = printf -Name = Positive Test for printf -TYPE = DEFAULT -EXE1 = test9 -Description -= Tests printf with integer numbers diff --git a/src/pal/tests/palsuite/c_runtime/qsort/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/qsort/CMakeLists.txt deleted file mode 100644 index ef14ea535..000000000 --- a/src/pal/tests/palsuite/c_runtime/qsort/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) - diff --git a/src/pal/tests/palsuite/c_runtime/qsort/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/qsort/test1/CMakeLists.txt deleted file mode 100644 index f41f4099f..000000000 --- a/src/pal/tests/palsuite/c_runtime/qsort/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_qsort_test1 - ${SOURCES} -) - -add_dependencies(paltest_qsort_test1 coreclrpal) - -target_link_libraries(paltest_qsort_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/qsort/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/qsort/test1/test1.cpp deleted file mode 100644 index c65fb18e6..000000000 --- a/src/pal/tests/palsuite/c_runtime/qsort/test1/test1.cpp +++ /dev/null @@ -1,48 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: Calls qsort to sort a buffer, and verifies that it has done -** the job correctly. -** -** -**==========================================================================*/ - -#include - -int __cdecl charcmp(const void *pa, const void *pb) -{ - return memcmp(pa, pb, 1); -} - -int __cdecl main(int argc, char **argv) -{ - char before[] = "cgaiehdbjf"; - const char after[] = "abcdefghij"; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - qsort(before, sizeof(before) - 1, sizeof(char), charcmp); - - if (memcmp(before, after, sizeof(before)) != 0) - { - Fail("qsort did not correctly sort an array of characters.\n"); - } - - PAL_Terminate(); - return PASS; - -} - - - - - diff --git a/src/pal/tests/palsuite/c_runtime/qsort/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/qsort/test1/testinfo.dat deleted file mode 100644 index 7e3b4b87c..000000000 --- a/src/pal/tests/palsuite/c_runtime/qsort/test1/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = qsort -Name = Positive Test for qsort -TYPE = DEFAULT -EXE1 = test1 -Description -= Calls qsort to sort a buffer, and verifies that it has done the job correctly. diff --git a/src/pal/tests/palsuite/c_runtime/qsort/test2/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/qsort/test2/CMakeLists.txt deleted file mode 100644 index 16e5c4422..000000000 --- a/src/pal/tests/palsuite/c_runtime/qsort/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test2.cpp -) - -add_executable(paltest_qsort_test2 - ${SOURCES} -) - -add_dependencies(paltest_qsort_test2 coreclrpal) - -target_link_libraries(paltest_qsort_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/qsort/test2/test2.cpp b/src/pal/tests/palsuite/c_runtime/qsort/test2/test2.cpp deleted file mode 100644 index 8110dcd2c..000000000 --- a/src/pal/tests/palsuite/c_runtime/qsort/test2/test2.cpp +++ /dev/null @@ -1,49 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test2.c -** -** Purpose: Calls qsort to sort a buffer, and verifies that it has done -** the job correctly. -** -** -**==========================================================================*/ - -#include - -int __cdecl twocharcmp(const void *pa, const void *pb) -{ - return memcmp(pa, pb, 2); -} - -int __cdecl main(int argc, char **argv) -{ - char before[] = "ccggaaiieehhddbbjjff"; - const char after[] = "aabbccddeeffgghhiijj"; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - qsort(before, (sizeof(before) - 1) / 2, 2 * sizeof(char), twocharcmp); - - if (memcmp(before, after, sizeof(before)) != 0) - { - Fail("qsort did not correctly sort an array of 2-character " - "buffers.\n"); - } - - PAL_Terminate(); - return PASS; - -} - - - - - diff --git a/src/pal/tests/palsuite/c_runtime/qsort/test2/testinfo.dat b/src/pal/tests/palsuite/c_runtime/qsort/test2/testinfo.dat deleted file mode 100644 index 35f5f0607..000000000 --- a/src/pal/tests/palsuite/c_runtime/qsort/test2/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = qsort -Name = Positive Test for qsort -TYPE = DEFAULT -EXE1 = test2 -Description -= Calls qsort to sort a buffer, and verifies that it has done the job correctly. diff --git a/src/pal/tests/palsuite/c_runtime/rand_srand/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/rand_srand/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/c_runtime/rand_srand/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/c_runtime/rand_srand/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/rand_srand/test1/CMakeLists.txt deleted file mode 100644 index 0afb6504c..000000000 --- a/src/pal/tests/palsuite/c_runtime/rand_srand/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_rand_srand_test1 - ${SOURCES} -) - -add_dependencies(paltest_rand_srand_test1 coreclrpal) - -target_link_libraries(paltest_rand_srand_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/rand_srand/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/rand_srand/test1/test1.cpp deleted file mode 100644 index 34154cb6d..000000000 --- a/src/pal/tests/palsuite/c_runtime/rand_srand/test1/test1.cpp +++ /dev/null @@ -1,100 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================= -** -** Source: test1.c -** -** Purpose: Test to ensure that srand provide random -** number to rand. Also make sure that rand result from a -** srand with seed 1 and no call to srand are the same. -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** Fail -** srand() -** - -** -**===========================================================================*/ - -#include - - -int __cdecl main(int argc, char **argv) -{ - int RandNumber[10]; - int TempRandNumber; - int i; - int SRAND_SEED; - int SRAND_REINIT = 1; - - /* - * Initialize the PAL and return FAILURE if this fails - */ - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - SRAND_SEED = time(NULL); - - /* does not initialize srand and call rand. */ - for (i=0; i<10; i++) - { - /* keep the value in a array */ - RandNumber[i]=rand(); - if (RandNumber[i] < 0 || RandNumber[i] > RAND_MAX) - { - Fail("1) ERROR: random generated an invalid value: %d", RandNumber[i]); - } - } - - - /* initialize random generator */ - srand(SRAND_SEED); - - - /* choose 10 numbers with a different seed. - the numbers should be different than - those the previously generated one */ - for(i = 0; i < 10; i++) - { - TempRandNumber=rand(); - if (TempRandNumber < 0 || TempRandNumber > RAND_MAX) - { - Fail("2) ERROR: random generated an invalid value: %d", TempRandNumber); - } - } - - - - /* renitialize the srand with 1 */ - srand(SRAND_REINIT); - - - - /* choose 10 numbers with seed 1, - the number should be the same as those we kept in the array. */ - for( i = 0; i < 10;i++ ) - { - /* pick the random number*/ - TempRandNumber=rand(); - /* test if it is the same number generated in the first sequences*/ - if(RandNumber[i]!=TempRandNumber) - { - Fail ("ERROR: rand should return the same value when srand " - "is initialized with 1 or not initialized at all"); - } - if (TempRandNumber < 0 || TempRandNumber > RAND_MAX) - { - Fail("3) ERROR: random generated an invalid value: %d", TempRandNumber); - } - } - - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/rand_srand/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/rand_srand/test1/testinfo.dat deleted file mode 100644 index cf1b42dbf..000000000 --- a/src/pal/tests/palsuite/c_runtime/rand_srand/test1/testinfo.dat +++ /dev/null @@ -1,16 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = rand and srand -Name = Positive Test for rand and srand -TYPE = DEFAULT -EXE1 = test1 -Description -= Call rand without srand and get 10 random number batch 1. -= call srand with seed 2, get 10 other random number and verify -= that numbers are different from the batch 1. -= Set the seed to 1, get 10 other random number and verify -= that the generated number are the same as batch 1. diff --git a/src/pal/tests/palsuite/c_runtime/realloc/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/realloc/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/c_runtime/realloc/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/c_runtime/realloc/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/realloc/test1/CMakeLists.txt deleted file mode 100644 index 0c263d5b5..000000000 --- a/src/pal/tests/palsuite/c_runtime/realloc/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_realloc_test1 - ${SOURCES} -) - -add_dependencies(paltest_realloc_test1 coreclrpal) - -target_link_libraries(paltest_realloc_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/realloc/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/realloc/test1/test1.cpp deleted file mode 100644 index 64a9270ea..000000000 --- a/src/pal/tests/palsuite/c_runtime/realloc/test1/test1.cpp +++ /dev/null @@ -1,66 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: Uses realloc to allocate and realloate memory, checking -** that memory contents are copied when the memory is reallocated. -** -** -**==========================================================================*/ - -#include - -int __cdecl main(int argc, char **argv) -{ - char *testA; - const int len1 = 10; - const char str1[] = "aaaaaaaaaa"; - - const int len2 = 20; - const char str2[] = "bbbbbbbbbbbbbbbbbbbb"; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - /* this should work like malloc */ - testA = (char *)realloc(NULL, len1*sizeof(char)); - memcpy(testA, str1, len1); - if (testA == NULL) - { - Fail("We ran out of memory (unlikely), or realloc is broken.\n"); - } - - if (memcmp(testA, str1, len1) != 0) - { - Fail("realloc doesn't properly allocate new memory.\n"); - } - - testA = (char *)realloc(testA, len2*sizeof(char)); - if (memcmp(testA, str1, len1) != 0) - { - Fail("realloc doesn't move the contents of the original memory " - "block to the newly allocated block.\n"); - } - - memcpy(testA, str2, len2); - if (memcmp(testA, str2, len2) != 0) - { - Fail("Couldn't write to memory allocated by realloc.\n"); - } - - /* free the buffer */ - testA = (char*)realloc(testA, 0); - if (testA != NULL) - { - Fail("Realloc didn't return NULL when called with a length " - "of zero.\n"); - } - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/realloc/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/realloc/test1/testinfo.dat deleted file mode 100644 index 5d2a32224..000000000 --- a/src/pal/tests/palsuite/c_runtime/realloc/test1/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = realloc -Name = Positive Test for realloc -TYPE = DEFAULT -EXE1 = test1 -Description -= Uses realloc to allocate and realloate memory, checking that memory -= contents are copied when the memory is reallocated. - diff --git a/src/pal/tests/palsuite/c_runtime/sin/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/sin/CMakeLists.txt deleted file mode 100644 index 5e1ef7f28..000000000 --- a/src/pal/tests/palsuite/c_runtime/sin/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) diff --git a/src/pal/tests/palsuite/c_runtime/sin/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/sin/test1/CMakeLists.txt deleted file mode 100644 index c46aaeccb..000000000 --- a/src/pal/tests/palsuite/c_runtime/sin/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_sin_test1 - ${SOURCES} -) - -add_dependencies(paltest_sin_test1 coreclrpal) - -target_link_libraries(paltest_sin_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/sin/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/sin/test1/test1.cpp deleted file mode 100644 index bec58d4dd..000000000 --- a/src/pal/tests/palsuite/c_runtime/sin/test1/test1.cpp +++ /dev/null @@ -1,131 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================= -** -** Source: test1.c -** -** Purpose: Test to ensure that sin return the correct values -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** Fail -** fabs -** -**===========================================================================*/ - -#include - -// binary64 (double) has a machine epsilon of 2^-52 (approx. 2.22e-16). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-50 (approx. 8.88e-16) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (15-17 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxxxxxxxxxx will use -// PAL_EPSILON for the variance, while an expected result in the format of 0.0xxxxxxxxxxxxxxxxx -// will use PAL_EPSILON / 10 and and expected result in the format of x.xxxxxxxxxxxxxxxx will -// use PAL_EPSILON * 10. -#define PAL_EPSILON 8.8817841970012523e-16 - -#define PAL_NAN sqrt(-1.0) -#define PAL_POSINF -log(0.0) -#define PAL_NEGINF log(0.0) - -/** - * Helper test structure - */ -struct test -{ - double value; /* value to test the function with */ - double expected; /* expected result */ - double variance; /* maximum delta between the expected and actual result */ -}; - -/** - * validate - * - * test validation function - */ -void __cdecl validate(double value, double expected, double variance) -{ - double result = sin(value); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - double delta = fabs(result - expected); - - if (delta > variance) - { - Fail("sin(%g) returned %20.17g when it should have returned %20.17g", - value, result, expected); - } -} - -/** - * validate - * - * test validation function for values returning NaN - */ -void __cdecl validate_isnan(double value) -{ - double result = sin(value); - - if (!_isnan(result)) - { - Fail("sin(%g) returned %20.17g when it should have returned %20.17g", - value, result, PAL_NAN); - } -} - -/** - * main - * - * executable entry point - */ -int __cdecl main(int argc, char **argv) -{ - struct test tests[] = - { - /* value expected variance */ - { 0, 0, PAL_EPSILON }, - { 0.31830988618379067, 0.31296179620778659, PAL_EPSILON }, // value: 1 / pi - { 0.43429448190325183, 0.42077048331375735, PAL_EPSILON }, // value: log10(e) - { 0.63661977236758134, 0.59448076852482208, PAL_EPSILON }, // value: 2 / pi - { 0.69314718055994531, 0.63896127631363480, PAL_EPSILON }, // value: ln(2) - { 0.70710678118654752, 0.64963693908006244, PAL_EPSILON }, // value: 1 / sqrt(2) - { 0.78539816339744831, 0.70710678118654752, PAL_EPSILON }, // value: pi / 4, expected: 1 / sqrt(2) - { 1, 0.84147098480789651, PAL_EPSILON }, - { 1.1283791670955126, 0.90371945743584630, PAL_EPSILON }, // value: 2 / sqrt(pi) - { 1.4142135623730950, 0.98776594599273553, PAL_EPSILON }, // value: sqrt(2) - { 1.4426950408889634, 0.99180624439366372, PAL_EPSILON }, // value: log2(e) - { 1.5707963267948966, 1, PAL_EPSILON * 10 }, // value: pi / 2 - { 2.3025850929940457, 0.74398033695749319, PAL_EPSILON }, // value: ln(10) - { 2.7182818284590452, 0.41078129050290870, PAL_EPSILON }, // value: e - { 3.1415926535897932, 0, PAL_EPSILON }, // value: pi - }; - - /* PAL initialization */ - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - validate( tests[i].value, tests[i].expected, tests[i].variance); - validate(-tests[i].value, -tests[i].expected, tests[i].variance); - } - - validate_isnan(PAL_NEGINF); - validate_isnan(PAL_NAN); - validate_isnan(PAL_POSINF); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/sin/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/sin/test1/testinfo.dat deleted file mode 100644 index 57eae6bfd..000000000 --- a/src/pal/tests/palsuite/c_runtime/sin/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = sin -Name = Positive Test for sin -TYPE = DEFAULT -EXE1 = test1 -Description -= Passes to sin() a series of angle value, checking that -= each one return to correct value. diff --git a/src/pal/tests/palsuite/c_runtime/sinf/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/sinf/CMakeLists.txt deleted file mode 100644 index 5e1ef7f28..000000000 --- a/src/pal/tests/palsuite/c_runtime/sinf/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) diff --git a/src/pal/tests/palsuite/c_runtime/sinf/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/sinf/test1/CMakeLists.txt deleted file mode 100644 index 9e0313046..000000000 --- a/src/pal/tests/palsuite/c_runtime/sinf/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.c -) - -add_executable(paltest_sinf_test1 - ${SOURCES} -) - -add_dependencies(paltest_sinf_test1 coreclrpal) - -target_link_libraries(paltest_sinf_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/sinf/test1/test1.c b/src/pal/tests/palsuite/c_runtime/sinf/test1/test1.c deleted file mode 100644 index d5bd24893..000000000 --- a/src/pal/tests/palsuite/c_runtime/sinf/test1/test1.c +++ /dev/null @@ -1,130 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================= -** -** Source: test1.c -** -** Purpose: Test to ensure that sinf return the correct values -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** Fail -** fabs -** -**===========================================================================*/ - -#include - -// binary32 (float) has a machine epsilon of 2^-23 (approx. 1.19e-07). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-21 (approx. 4.76e-07) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (6-9 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxx will use PAL_EPSILON -// for the variance, while an expected result in the format of 0.0xxxxxxxxx will use -// PAL_EPSILON / 10 and and expected result in the format of x.xxxxxx will use PAL_EPSILON * 10. -#define PAL_EPSILON 4.76837158e-07 - -#define PAL_NAN sqrtf(-1.0f) -#define PAL_POSINF -logf(0.0f) -#define PAL_NEGINF logf(0.0f) - -/** - * Helper test structure - */ -struct test -{ - float value; /* value to test the function with */ - float expected; /* expected result */ - float variance; /* maximum delta between the expected and actual result */ -}; - -/** - * validate - * - * test validation function - */ -void __cdecl validate(float value, float expected, float variance) -{ - float result = sinf(value); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - float delta = fabsf(result - expected); - - if (delta > variance) - { - Fail("sinf(%g) returned %10.9g when it should have returned %10.9g", - value, result, expected); - } -} - -/** - * validate - * - * test validation function for values returning NaN - */ -void __cdecl validate_isnan(float value) -{ - float result = sinf(value); - - if (!_isnanf(result)) - { - Fail("sinf(%g) returned %10.9g when it should have returned %10.9g", - value, result, PAL_NAN); - } -} - -/** - * main - * - * executable entry point - */ -int __cdecl main(int argc, char **argv) -{ - struct test tests[] = - { - /* value expected variance */ - { 0, 0, PAL_EPSILON }, - { 0.318309886f, 0.312961796f, PAL_EPSILON }, // value: 1 / pi - { 0.434294482f, 0.420770483f, PAL_EPSILON }, // value: log10f(e) - { 0.636619772f, 0.594480769f, PAL_EPSILON }, // value: 2 / pi - { 0.693147181f, 0.638961276f, PAL_EPSILON }, // value: ln(2) - { 0.707106781f, 0.649636939f, PAL_EPSILON }, // value: 1 / sqrtf(2) - { 0.785398163f, 0.707106781f, PAL_EPSILON }, // value: pi / 4, expected: 1 / sqrtf(2) - { 1, 0.841470985f, PAL_EPSILON }, - { 1.12837917f, 0.903719457f, PAL_EPSILON }, // value: 2 / sqrtf(pi) - { 1.41421356f, 0.987765946f, PAL_EPSILON }, // value: sqrtf(2) - { 1.44269504f, 0.991806244f, PAL_EPSILON }, // value: logf2(e) - { 1.57079633f, 1, PAL_EPSILON * 10 }, // value: pi / 2 - { 2.30258509f, 0.743980337f, PAL_EPSILON }, // value: ln(10) - { 2.71828183f, 0.410781291f, PAL_EPSILON }, // value: e - { 3.14159265f, 0, PAL_EPSILON }, // value: pi - }; - - /* PAL initialization */ - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - validate( tests[i].value, tests[i].expected, tests[i].variance); - validate(-tests[i].value, -tests[i].expected, tests[i].variance); - } - - validate_isnan(PAL_NEGINF); - validate_isnan(PAL_NAN); - validate_isnan(PAL_POSINF); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/sinf/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/sinf/test1/testinfo.dat deleted file mode 100644 index 08ff6026c..000000000 --- a/src/pal/tests/palsuite/c_runtime/sinf/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = sinf -Name = Positive Test for sinf -TYPE = DEFAULT -EXE1 = test1 -Description -= Passes to sinf() a series of angle value, checking that -= each one return to correct value. diff --git a/src/pal/tests/palsuite/c_runtime/sinh/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/sinh/CMakeLists.txt deleted file mode 100644 index 5e1ef7f28..000000000 --- a/src/pal/tests/palsuite/c_runtime/sinh/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) diff --git a/src/pal/tests/palsuite/c_runtime/sinh/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/sinh/test1/CMakeLists.txt deleted file mode 100644 index 1c99bfa89..000000000 --- a/src/pal/tests/palsuite/c_runtime/sinh/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_sinh_test1 - ${SOURCES} -) - -add_dependencies(paltest_sinh_test1 coreclrpal) - -target_link_libraries(paltest_sinh_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/sinh/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/sinh/test1/test1.cpp deleted file mode 100644 index e790b16fb..000000000 --- a/src/pal/tests/palsuite/c_runtime/sinh/test1/test1.cpp +++ /dev/null @@ -1,130 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================= -** -** Source: test1.c -** -** Purpose: Test to ensure that sinh return the correct values -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** Fail -** fabs -** -**===========================================================================*/ - -#include - -// binary64 (double) has a machine epsilon of 2^-52 (approx. 2.22e-16). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-50 (approx. 8.88e-16) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (15-17 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxxxxxxxxxx will use -// PAL_EPSILON for the variance, while an expected result in the format of 0.0xxxxxxxxxxxxxxxxx -// will use PAL_EPSILON / 10 and and expected result in the format of x.xxxxxxxxxxxxxxxx will -// use PAL_EPSILON * 10. -#define PAL_EPSILON 8.8817841970012523e-16 - -#define PAL_NAN sqrt(-1.0) -#define PAL_POSINF -log(0.0) -#define PAL_NEGINF log(0.0) - -/** - * Helper test structure - */ -struct test -{ - double value; /* value to test the function with */ - double expected; /* expected result */ - double variance; /* maximum delta between the expected and actual result */ -}; - -/** - * validate - * - * test validation function - */ -void __cdecl validate(double value, double expected, double variance) -{ - double result = sinh(value); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - double delta = fabs(result - expected); - - if (delta > variance) - { - Fail("sinh(%g) returned %20.17g when it should have returned %20.17g", - value, result, expected); - } -} - -/** - * validate - * - * test validation function for values returning NaN - */ -void __cdecl validate_isnan(double value) -{ - double result = sinh(value); - - if (!_isnan(result)) - { - Fail("sinh(%g) returned %20.17g when it should have returned %20.17g", - value, result, PAL_NAN); - } -} - -/** - * main - * - * executable entry point - */ -int __cdecl main(int argc, char **argv) -{ - struct test tests[] = - { - /* value expected variance */ - { 0, 0, PAL_EPSILON }, - { 0.31830988618379067, 0.32371243907207108, PAL_EPSILON }, // value: 1 / pi - { 0.43429448190325183, 0.44807597941469025, PAL_EPSILON }, // value: log10(e) - { 0.63661977236758134, 0.68050167815224332, PAL_EPSILON }, // value: 2 / pi - { 0.69314718055994531, 0.75, PAL_EPSILON }, // value: ln(2) - { 0.70710678118654752, 0.76752314512611633, PAL_EPSILON }, // value: 1 / sqrt(2) - { 0.78539816339744831, 0.86867096148600961, PAL_EPSILON }, // value: pi / 4 - { 1, 1.1752011936438015, PAL_EPSILON * 10 }, - { 1.1283791670955126, 1.3835428792038633, PAL_EPSILON * 10 }, // value: 2 / sqrt(pi) - { 1.4142135623730950, 1.9350668221743567, PAL_EPSILON * 10 }, // value: sqrt(2) - { 1.4426950408889634, 1.9978980091062796, PAL_EPSILON * 10 }, // value: log2(e) - { 1.5707963267948966, 2.3012989023072949, PAL_EPSILON * 10 }, // value: pi / 2 - { 2.3025850929940457, 4.95, PAL_EPSILON * 10 }, // value: ln(10) - { 2.7182818284590452, 7.5441371028169758, PAL_EPSILON * 10 }, // value: e - { 3.1415926535897932, 11.548739357257748, PAL_EPSILON * 100 }, // value: pi - { PAL_POSINF, PAL_POSINF, 0 }, - }; - - /* PAL initialization */ - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - validate( tests[i].value, tests[i].expected, tests[i].variance); - validate(-tests[i].value, -tests[i].expected, tests[i].variance); - } - - validate_isnan(PAL_NAN); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/sinh/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/sinh/test1/testinfo.dat deleted file mode 100644 index f7aee4020..000000000 --- a/src/pal/tests/palsuite/c_runtime/sinh/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = sinh -Name = Positive Test for sinh -TYPE = DEFAULT -EXE1 = test1 -Description -= Passes to sinh() a series of angle value, checking that -= each one return to correct value. diff --git a/src/pal/tests/palsuite/c_runtime/sinhf/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/sinhf/CMakeLists.txt deleted file mode 100644 index 5e1ef7f28..000000000 --- a/src/pal/tests/palsuite/c_runtime/sinhf/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) diff --git a/src/pal/tests/palsuite/c_runtime/sinhf/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/sinhf/test1/CMakeLists.txt deleted file mode 100644 index 60208d4e1..000000000 --- a/src/pal/tests/palsuite/c_runtime/sinhf/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.c -) - -add_executable(paltest_sinhf_test1 - ${SOURCES} -) - -add_dependencies(paltest_sinhf_test1 coreclrpal) - -target_link_libraries(paltest_sinhf_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/sinhf/test1/test1.c b/src/pal/tests/palsuite/c_runtime/sinhf/test1/test1.c deleted file mode 100644 index 4e706a2f7..000000000 --- a/src/pal/tests/palsuite/c_runtime/sinhf/test1/test1.c +++ /dev/null @@ -1,129 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================= -** -** Source: test1.c -** -** Purpose: Test to ensure that sinhf return the correct values -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** Fail -** fabs -** -**===========================================================================*/ - -#include - -// binary32 (float) has a machine epsilon of 2^-23 (approx. 1.19e-07). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-21 (approx. 4.76e-07) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (6-9 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxx will use PAL_EPSILON -// for the variance, while an expected result in the format of 0.0xxxxxxxxx will use -// PAL_EPSILON / 10 and and expected result in the format of x.xxxxxx will use PAL_EPSILON * 10. -#define PAL_EPSILON 4.76837158e-07 - -#define PAL_NAN sqrtf(-1.0f) -#define PAL_POSINF -logf(0.0f) -#define PAL_NEGINF logf(0.0f) - -/** - * Helper test structure - */ -struct test -{ - float value; /* value to test the function with */ - float expected; /* expected result */ - float variance; /* maximum delta between the expected and actual result */ -}; - -/** - * validate - * - * test validation function - */ -void __cdecl validate(float value, float expected, float variance) -{ - float result = sinhf(value); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - float delta = fabsf(result - expected); - - if (delta > variance) - { - Fail("sinhf(%g) returned %10.9g when it should have returned %10.9g", - value, result, expected); - } -} - -/** - * validate - * - * test validation function for values returning NaN - */ -void __cdecl validate_isnan(float value) -{ - float result = sinhf(value); - - if (!_isnanf(result)) - { - Fail("sinhf(%g) returned %10.9g when it should have returned %10.9g", - value, result, PAL_NAN); - } -} - -/** - * main - * - * executable entry point - */ -int __cdecl main(int argc, char **argv) -{ - struct test tests[] = - { - /* value expected variance */ - { 0, 0, PAL_EPSILON }, - { 0.318309886f, 0.323712439f, PAL_EPSILON }, // value: 1 / pi - { 0.434294482f, 0.448075979f, PAL_EPSILON }, // value: log10f(e) - { 0.636619772f, 0.680501678f, PAL_EPSILON }, // value: 2 / pi - { 0.693147181f, 0.75, PAL_EPSILON }, // value: ln(2) - { 0.707106781f, 0.767523145f, PAL_EPSILON }, // value: 1 / sqrtf(2) - { 0.785398163f, 0.868670961f, PAL_EPSILON }, // value: pi / 4 - { 1, 1.17520119f, PAL_EPSILON * 10 }, - { 1.12837917f, 1.38354288f, PAL_EPSILON * 10 }, // value: 2 / sqrtf(pi) - { 1.41421356f, 1.93506682f, PAL_EPSILON * 10 }, // value: sqrtf(2) - { 1.44269504f, 1.99789801f, PAL_EPSILON * 10 }, // value: logf2(e) - { 1.57079633f, 2.30129890f, PAL_EPSILON * 10 }, // value: pi / 2 - { 2.30258509f, 4.95f, PAL_EPSILON * 10 }, // value: ln(10) - { 2.71828183f, 7.54413710f, PAL_EPSILON * 10 }, // value: e - { 3.14159265f, 11.5487394f, PAL_EPSILON * 100 }, // value: pi - { PAL_POSINF, PAL_POSINF, 0 }, - }; - - /* PAL initialization */ - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - validate( tests[i].value, tests[i].expected, tests[i].variance); - validate(-tests[i].value, -tests[i].expected, tests[i].variance); - } - - validate_isnan(PAL_NAN); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/sinhf/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/sinhf/test1/testinfo.dat deleted file mode 100644 index cfb27f542..000000000 --- a/src/pal/tests/palsuite/c_runtime/sinhf/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = sinhf -Name = Positive Test for sinhf -TYPE = DEFAULT -EXE1 = test1 -Description -= Passes to sinhf() a series of angle value, checking that -= each one return to correct value. diff --git a/src/pal/tests/palsuite/c_runtime/sprintf_s/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/sprintf_s/CMakeLists.txt deleted file mode 100644 index 8fe1cb60a..000000000 --- a/src/pal/tests/palsuite/c_runtime/sprintf_s/CMakeLists.txt +++ /dev/null @@ -1,21 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test10) -add_subdirectory(test11) -add_subdirectory(test12) -add_subdirectory(test13) -add_subdirectory(test14) -add_subdirectory(test15) -add_subdirectory(test16) -add_subdirectory(test17) -add_subdirectory(test18) -add_subdirectory(test19) -add_subdirectory(test2) -add_subdirectory(test3) -add_subdirectory(test4) -add_subdirectory(test6) -add_subdirectory(test7) -add_subdirectory(test8) -add_subdirectory(test9) - diff --git a/src/pal/tests/palsuite/c_runtime/sprintf_s/sprintf_s.h b/src/pal/tests/palsuite/c_runtime/sprintf_s/sprintf_s.h deleted file mode 100644 index 129b9db72..000000000 --- a/src/pal/tests/palsuite/c_runtime/sprintf_s/sprintf_s.h +++ /dev/null @@ -1,195 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: sprintf_s.h -** -** Purpose: Containts common testing functions for sprintf_s -** -** -**==========================================================================*/ - -#ifndef __SPRINTF_S_H__ -#define __SPRINTF_S_H__ - -void DoStrTest(const char *formatstr, char* param, const char *checkstr) -{ - char buf[256] = { 0 }; - - sprintf_s(buf, _countof(buf), formatstr, param); - if (memcmp(buf, checkstr, strlen(checkstr) + 1) != 0) - { - Fail("ERROR: failed to insert string \"%s\" into \"%s\"\n" - "Expected \"%s\" got \"%s\".\n", - param, formatstr, checkstr, buf); - } -} - -void DoWStrTest(const char *formatstr, WCHAR* param, const char *checkstr) -{ - char buf[256] = { 0 }; - - sprintf_s(buf, _countof(buf), formatstr, param); - if (memcmp(buf, checkstr, strlen(checkstr) + 1) != 0) - { - Fail("ERROR: failed to insert wide string \"%s\" into \"%s\"\n" - "Expected \"%s\" got \"%s\".\n", - convertC(param), formatstr, checkstr, buf); - } -} - -void DoPointerTest(const char *formatstr, void* param, char* paramstr, - const char *checkstr1) -{ - char buf[256] = { 0 }; - - sprintf_s(buf, _countof(buf), formatstr, param); - if (memcmp(buf, checkstr1, strlen(checkstr1) + 1) != 0) - { - Fail("ERROR: failed to insert %s into \"%s\"\n" - "Expected \"%s\" got \"%s\".\n", - paramstr, formatstr, checkstr1, buf); - } -} - -void DoCountTest(const char *formatstr, int param, const char *checkstr) -{ - char buf[512] = { 0 }; - int n = -1; - - sprintf_s(buf, _countof(buf), formatstr, &n); - - if (n != param) - { - Fail("ERROR: Expected count parameter to resolve to %d, got %X\n", - param, n); - } - if (memcmp(buf, checkstr, strlen(checkstr) + 1) != 0) - { - Fail("ERROR: Expected \"%s\" got \"%s\".\n", checkstr, buf); - } -} - -void DoShortCountTest(const char *formatstr, int param, const char *checkstr) -{ - char buf[256] = { 0 }; - short int n = -1; - - sprintf_s(buf, _countof(buf), formatstr, &n); - - if (n != param) - { - Fail("ERROR: Expected count parameter to resolve to %d, got %X\n", - param, n); - } - if (memcmp(buf, checkstr, strlen(checkstr) + 1) != 0) - { - Fail("ERROR: Expected \"%s\" got \"%s\".\n", checkstr, buf); - } -} - - -void DoCharTest(const char *formatstr, char param, const char *checkstr) -{ - char buf[256] = { 0 }; - - sprintf_s(buf, _countof(buf), formatstr, param); - if (memcmp(buf, checkstr, strlen(checkstr) + 1) != 0) - { - Fail("ERROR: failed to insert char \'%c\' (%d) into \"%s\"\n" - "Expected \"%s\" got \"%s\".\n", - param, param, formatstr, checkstr, buf); - } -} - -void DoWCharTest(const char *formatstr, WCHAR param, const char *checkstr) -{ - char buf[256] = { 0 }; - - sprintf_s(buf, _countof(buf), formatstr, param); - if (memcmp(buf, checkstr, strlen(checkstr) + 1) != 0) - { - Fail("ERROR: failed to insert wide char \'%c\' (%d) into \"%s\"\n" - "Expected \"%s\" got \"%s\".\n", - (char)param, param, formatstr, checkstr, buf); - } -} - -void DoNumTest(const char *formatstr, int value, const char *checkstr) -{ - char buf[256] = { 0 }; - - sprintf_s(buf, _countof(buf), formatstr, value); - if (memcmp(buf, checkstr, strlen(checkstr) + 1) != 0) - { - Fail("ERROR: failed to insert %#x into \"%s\"\n" - "Expected \"%s\" got \"%s\".\n", - value, formatstr, checkstr, buf); - } -} - -void DoI64Test(const char *formatstr, INT64 value, char *valuestr, const char *checkstr1) -{ - char buf[256] = { 0 }; - - sprintf_s(buf, _countof(buf), formatstr, value); - if (memcmp(buf, checkstr1, strlen(checkstr1) + 1) != 0) - { - Fail("ERROR: failed to insert %s into \"%s\"\n" - "Expected \"%s\", got \"%s\".\n", - valuestr, formatstr, checkstr1, buf); - } -} - -void DoDoubleTest(const char *formatstr, double value, const char *checkstr1, - const char *checkstr2) -{ - char buf[256] = { 0 }; - - sprintf_s(buf, _countof(buf), formatstr, value); - if (memcmp(buf, checkstr1, strlen(checkstr1) + 1) != 0 && - memcmp(buf, checkstr2, strlen(checkstr2) + 1) != 0) - { - Fail("ERROR: failed to insert %f into \"%s\"\n" - "Expected \"%s\" or \"%s\", got \"%s\".\n", - value, formatstr, checkstr1, checkstr2, buf); - } -} - -void DoArgumentPrecTest(const char *formatstr, int precision, void *param, - char *paramstr, const char *checkstr1, const char *checkstr2) -{ - char buf[256]; - - sprintf_s(buf, _countof(buf), formatstr, precision, param); - if (memcmp(buf, checkstr1, strlen(checkstr1) + 1) != 0 && - memcmp(buf, checkstr2, strlen(checkstr2) + 1) != 0) - { - Fail("ERROR: failed to insert %s into \"%s\" with precision %d\n" - "Expected \"%s\" or \"%s\", got \"%s\".\n", paramstr, formatstr, - precision, checkstr1, checkstr2, buf); - } - -} - -void DoArgumentPrecDoubleTest(const char *formatstr, int precision, double param, - const char *checkstr1, const char *checkstr2) -{ - char buf[256]; - - sprintf_s(buf, _countof(buf), formatstr, precision, param); - if (memcmp(buf, checkstr1, strlen(checkstr1) + 1) != 0 && - memcmp(buf, checkstr2, strlen(checkstr2) + 1) != 0) - { - Fail("ERROR: failed to insert %f into \"%s\" with precision %d\n" - "Expected \"%s\" or \"%s\", got \"%s\".\n", param, formatstr, - precision, checkstr1, checkstr2, buf); - } - -} - -#endif - - diff --git a/src/pal/tests/palsuite/c_runtime/sprintf_s/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/sprintf_s/test1/CMakeLists.txt deleted file mode 100644 index 5de43c73a..000000000 --- a/src/pal/tests/palsuite/c_runtime/sprintf_s/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_sprintf_test1 - ${SOURCES} -) - -add_dependencies(paltest_sprintf_test1 coreclrpal) - -target_link_libraries(paltest_sprintf_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/sprintf_s/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/sprintf_s/test1/test1.cpp deleted file mode 100644 index a289c0771..000000000 --- a/src/pal/tests/palsuite/c_runtime/sprintf_s/test1/test1.cpp +++ /dev/null @@ -1,45 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: Test #1 for the sprintf_s function. A single, basic, test -** case with no formatting. -** -** -**==========================================================================*/ - - - -#include -#include "../sprintf_s.h" - -/* - * Depends on memcmp and strlen - */ - -int __cdecl main(int argc, char *argv[]) -{ - char checkstr[] = "hello world"; - char buf[256]; - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - - sprintf_s(buf, _countof(buf), "hello world"); - - if (memcmp(checkstr, buf, strlen(checkstr)+1) != 0) - { - Fail("ERROR: expected %s, got %s\n", checkstr, buf); - } - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/c_runtime/sprintf_s/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/sprintf_s/test1/testinfo.dat deleted file mode 100644 index 255c534cd..000000000 --- a/src/pal/tests/palsuite/c_runtime/sprintf_s/test1/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = sprintf_s -Name = Positive Test for sprintf_s -TYPE = DEFAULT -EXE1 = test1 -Description -= General test to see if sprintf_s works correctly diff --git a/src/pal/tests/palsuite/c_runtime/sprintf_s/test10/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/sprintf_s/test10/CMakeLists.txt deleted file mode 100644 index 54bc9c08d..000000000 --- a/src/pal/tests/palsuite/c_runtime/sprintf_s/test10/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test10.cpp -) - -add_executable(paltest_sprintf_test10 - ${SOURCES} -) - -add_dependencies(paltest_sprintf_test10 coreclrpal) - -target_link_libraries(paltest_sprintf_test10 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/sprintf_s/test10/test10.cpp b/src/pal/tests/palsuite/c_runtime/sprintf_s/test10/test10.cpp deleted file mode 100644 index bbda15a33..000000000 --- a/src/pal/tests/palsuite/c_runtime/sprintf_s/test10/test10.cpp +++ /dev/null @@ -1,55 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test10.c -** -** Purpose: Test #10 for the sprintf_s function. Tests the octal specifier -** (%o). -** -** -**==========================================================================*/ - - - -#include -#include "../sprintf_s.h" - -/* - * Depends on memcmp and strlen - */ - -int __cdecl main(int argc, char *argv[]) -{ - int neg = -42; - int pos = 42; - INT64 l = 42; - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - - DoNumTest("foo %o", pos, "foo 52"); - DoNumTest("foo %lo", 0xFFFF, "foo 177777"); - DoNumTest("foo %ho", 0xFFFF, "foo 177777"); - DoNumTest("foo %Lo", pos, "foo 52"); - DoI64Test("foo %I64o", l, "42", "foo 52"); - DoNumTest("foo %3o", pos, "foo 52"); - DoNumTest("foo %-3o", pos, "foo 52 "); - DoNumTest("foo %.1o", pos, "foo 52"); - DoNumTest("foo %.3o", pos, "foo 052"); - DoNumTest("foo %03o", pos, "foo 052"); - DoNumTest("foo %#o", pos, "foo 052"); - DoNumTest("foo %+o", pos, "foo 52"); - DoNumTest("foo % o", pos, "foo 52"); - DoNumTest("foo %+o", neg, "foo 37777777726"); - DoNumTest("foo % o", neg, "foo 37777777726"); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/c_runtime/sprintf_s/test10/testinfo.dat b/src/pal/tests/palsuite/c_runtime/sprintf_s/test10/testinfo.dat deleted file mode 100644 index 25ed554ea..000000000 --- a/src/pal/tests/palsuite/c_runtime/sprintf_s/test10/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = sprintf_s -Name = Positive Test for sprintf_s -TYPE = DEFAULT -EXE1 = test10 -Description -= Tests sprintf_s with octal numbers diff --git a/src/pal/tests/palsuite/c_runtime/sprintf_s/test11/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/sprintf_s/test11/CMakeLists.txt deleted file mode 100644 index 6eac95623..000000000 --- a/src/pal/tests/palsuite/c_runtime/sprintf_s/test11/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test11.cpp -) - -add_executable(paltest_sprintf_test11 - ${SOURCES} -) - -add_dependencies(paltest_sprintf_test11 coreclrpal) - -target_link_libraries(paltest_sprintf_test11 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/sprintf_s/test11/test11.cpp b/src/pal/tests/palsuite/c_runtime/sprintf_s/test11/test11.cpp deleted file mode 100644 index 7f4fca9f3..000000000 --- a/src/pal/tests/palsuite/c_runtime/sprintf_s/test11/test11.cpp +++ /dev/null @@ -1,55 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test11.c -** -** Purpose: Test #11 for the sprintf_s function. Test the unsigned int -** specifier (%u). -** -** -**==========================================================================*/ - - - -#include -#include "../sprintf_s.h" - -/* - * Depends on memcmp and strlen - */ - -int __cdecl main(int argc, char *argv[]) -{ - int neg = -42; - int pos = 42; - INT64 l = 42; - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - - DoNumTest("foo %u", pos, "foo 42"); - DoNumTest("foo %lu", 0xFFFF, "foo 65535"); - DoNumTest("foo %hu", 0xFFFF, "foo 65535"); - DoNumTest("foo %Lu", pos, "foo 42"); - DoI64Test("foo %I64u", l, "42", "foo 42"); - DoNumTest("foo %3u", pos, "foo 42"); - DoNumTest("foo %-3u", pos, "foo 42 "); - DoNumTest("foo %.1u", pos, "foo 42"); - DoNumTest("foo %.3u", pos, "foo 042"); - DoNumTest("foo %03u", pos, "foo 042"); - DoNumTest("foo %#u", pos, "foo 42"); - DoNumTest("foo %+u", pos, "foo 42"); - DoNumTest("foo % u", pos, "foo 42"); - DoNumTest("foo %+u", neg, "foo 4294967254"); - DoNumTest("foo % u", neg, "foo 4294967254"); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/c_runtime/sprintf_s/test11/testinfo.dat b/src/pal/tests/palsuite/c_runtime/sprintf_s/test11/testinfo.dat deleted file mode 100644 index 3144f1290..000000000 --- a/src/pal/tests/palsuite/c_runtime/sprintf_s/test11/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = sprintf_s -Name = Positive Test for sprintf_s -TYPE = DEFAULT -EXE1 = test11 -Description -= Tests sprintf_s with unsigned numbers diff --git a/src/pal/tests/palsuite/c_runtime/sprintf_s/test12/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/sprintf_s/test12/CMakeLists.txt deleted file mode 100644 index a49975993..000000000 --- a/src/pal/tests/palsuite/c_runtime/sprintf_s/test12/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test12.cpp -) - -add_executable(paltest_sprintf_test12 - ${SOURCES} -) - -add_dependencies(paltest_sprintf_test12 coreclrpal) - -target_link_libraries(paltest_sprintf_test12 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/sprintf_s/test12/test12.cpp b/src/pal/tests/palsuite/c_runtime/sprintf_s/test12/test12.cpp deleted file mode 100644 index 759a41105..000000000 --- a/src/pal/tests/palsuite/c_runtime/sprintf_s/test12/test12.cpp +++ /dev/null @@ -1,56 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test12.c -** -** Purpose: Test #12 for the sprintf_s function. Tests the (lowercase) -** hexadecimal specifier (%x) -** -** -**==========================================================================*/ - - - -#include -#include "../sprintf_s.h" - -/* - * Depends on memcmp and strlen - */ - -int __cdecl main(int argc, char *argv[]) -{ - int neg = -42; - int pos = 0x1234ab; - INT64 l = I64(0x1234567887654321); - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - - DoNumTest("foo %x", pos, "foo 1234ab"); - DoNumTest("foo %lx", pos, "foo 1234ab"); - DoNumTest("foo %hx", pos, "foo 34ab"); - DoNumTest("foo %Lx", pos, "foo 1234ab"); - DoI64Test("foo %I64x", l, "0x1234567887654321", - "foo 1234567887654321"); - DoNumTest("foo %7x", pos, "foo 1234ab"); - DoNumTest("foo %-7x", pos, "foo 1234ab "); - DoNumTest("foo %.1x", pos, "foo 1234ab"); - DoNumTest("foo %.7x", pos, "foo 01234ab"); - DoNumTest("foo %07x", pos, "foo 01234ab"); - DoNumTest("foo %#x", pos, "foo 0x1234ab"); - DoNumTest("foo %+x", pos, "foo 1234ab"); - DoNumTest("foo % x", pos, "foo 1234ab"); - DoNumTest("foo %+x", neg, "foo ffffffd6"); - DoNumTest("foo % x", neg, "foo ffffffd6"); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/c_runtime/sprintf_s/test12/testinfo.dat b/src/pal/tests/palsuite/c_runtime/sprintf_s/test12/testinfo.dat deleted file mode 100644 index ed91cecc4..000000000 --- a/src/pal/tests/palsuite/c_runtime/sprintf_s/test12/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = sprintf_s -Name = Positive Test for sprintf_s -TYPE = DEFAULT -EXE1 = test12 -Description -= Tests sprintf_s with hex numbers (lowercase) diff --git a/src/pal/tests/palsuite/c_runtime/sprintf_s/test13/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/sprintf_s/test13/CMakeLists.txt deleted file mode 100644 index 4d66713fb..000000000 --- a/src/pal/tests/palsuite/c_runtime/sprintf_s/test13/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test13.cpp -) - -add_executable(paltest_sprintf_test13 - ${SOURCES} -) - -add_dependencies(paltest_sprintf_test13 coreclrpal) - -target_link_libraries(paltest_sprintf_test13 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/sprintf_s/test13/test13.cpp b/src/pal/tests/palsuite/c_runtime/sprintf_s/test13/test13.cpp deleted file mode 100644 index 76250d058..000000000 --- a/src/pal/tests/palsuite/c_runtime/sprintf_s/test13/test13.cpp +++ /dev/null @@ -1,56 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test13.c -** -** Purpose: Test #13 for the sprintf_s function. Tests the (uppercase) -** hexadecimal specifier (%X) -** -** -**==========================================================================*/ - - - -#include -#include "../sprintf_s.h" - -/* - * Depends on memcmp and strlen - */ - -int __cdecl main(int argc, char *argv[]) -{ - int neg = -42; - int pos = 0x1234AB; - INT64 l = I64(0x1234567887654321); - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - - DoNumTest("foo %X", pos, "foo 1234AB"); - DoNumTest("foo %lX", pos, "foo 1234AB"); - DoNumTest("foo %hX", pos, "foo 34AB"); - DoNumTest("foo %LX", pos, "foo 1234AB"); - DoI64Test("foo %I64X", l, "0x1234567887654321", - "foo 1234567887654321"); - DoNumTest("foo %7X", pos, "foo 1234AB"); - DoNumTest("foo %-7X", pos, "foo 1234AB "); - DoNumTest("foo %.1X", pos, "foo 1234AB"); - DoNumTest("foo %.7X", pos, "foo 01234AB"); - DoNumTest("foo %07X", pos, "foo 01234AB"); - DoNumTest("foo %#X", pos, "foo 0X1234AB"); - DoNumTest("foo %+X", pos, "foo 1234AB"); - DoNumTest("foo % X", pos, "foo 1234AB"); - DoNumTest("foo %+X", neg, "foo FFFFFFD6"); - DoNumTest("foo % X", neg, "foo FFFFFFD6"); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/c_runtime/sprintf_s/test13/testinfo.dat b/src/pal/tests/palsuite/c_runtime/sprintf_s/test13/testinfo.dat deleted file mode 100644 index fd5f53017..000000000 --- a/src/pal/tests/palsuite/c_runtime/sprintf_s/test13/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = sprintf_s -Name = Positive Test for sprintf_s -TYPE = DEFAULT -EXE1 = test13 -Description -= Tests sprintf_s with hex numbers (uppercase) diff --git a/src/pal/tests/palsuite/c_runtime/sprintf_s/test14/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/sprintf_s/test14/CMakeLists.txt deleted file mode 100644 index ce41b8a95..000000000 --- a/src/pal/tests/palsuite/c_runtime/sprintf_s/test14/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test14.cpp -) - -add_executable(paltest_sprintf_test14 - ${SOURCES} -) - -add_dependencies(paltest_sprintf_test14 coreclrpal) - -target_link_libraries(paltest_sprintf_test14 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/sprintf_s/test14/test14.cpp b/src/pal/tests/palsuite/c_runtime/sprintf_s/test14/test14.cpp deleted file mode 100644 index 668edda43..000000000 --- a/src/pal/tests/palsuite/c_runtime/sprintf_s/test14/test14.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test14.c -** -** Purpose: Test #14 for the sprintf_s function. Tests the lowercase -** exponential notation double specifier (%e) -** -** -**==========================================================================*/ - - - -#include -#include "../sprintf_s.h" - -/* - * Depends on memcmp and strlen - */ - -int __cdecl main(int argc, char *argv[]) -{ - double val = 256.0; - double neg = -256.0; - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - - DoDoubleTest("foo %e", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %le", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %he", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %Le", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %I64e", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %14e", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %-14e", val, "foo 2.560000e+002 ", "foo 2.560000e+02 "); - DoDoubleTest("foo %.1e", val, "foo 2.6e+002", "foo 2.6e+02"); - DoDoubleTest("foo %.8e", val, "foo 2.56000000e+002", "foo 2.56000000e+02"); - DoDoubleTest("foo %014e", val, "foo 02.560000e+002", "foo 002.560000e+02"); - DoDoubleTest("foo %#e", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %+e", val, "foo +2.560000e+002", "foo +2.560000e+02"); - DoDoubleTest("foo % e", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %+e", neg, "foo -2.560000e+002", "foo -2.560000e+02"); - DoDoubleTest("foo % e", neg, "foo -2.560000e+002", "foo -2.560000e+02"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/sprintf_s/test14/testinfo.dat b/src/pal/tests/palsuite/c_runtime/sprintf_s/test14/testinfo.dat deleted file mode 100644 index 23cf42335..000000000 --- a/src/pal/tests/palsuite/c_runtime/sprintf_s/test14/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = sprintf_s -Name = Positive Test for sprintf_s -TYPE = DEFAULT -EXE1 = test14 -Description -= Tests sprintf_s with exponential format doubles (lowercase) diff --git a/src/pal/tests/palsuite/c_runtime/sprintf_s/test15/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/sprintf_s/test15/CMakeLists.txt deleted file mode 100644 index d20c4d07e..000000000 --- a/src/pal/tests/palsuite/c_runtime/sprintf_s/test15/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test15.cpp -) - -add_executable(paltest_sprintf_test15 - ${SOURCES} -) - -add_dependencies(paltest_sprintf_test15 coreclrpal) - -target_link_libraries(paltest_sprintf_test15 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/sprintf_s/test15/test15.cpp b/src/pal/tests/palsuite/c_runtime/sprintf_s/test15/test15.cpp deleted file mode 100644 index 61e0e362a..000000000 --- a/src/pal/tests/palsuite/c_runtime/sprintf_s/test15/test15.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test15.c -** -** Purpose: Test #15 for the sprintf_s function. Tests the uppercase -** exponential notation double specifier (%E) -** -** -**==========================================================================*/ - - - -#include -#include "../sprintf_s.h" - -/* - * Depends on memcmp and strlen - */ - -int __cdecl main(int argc, char *argv[]) -{ - double val = 256.0; - double neg = -256.0; - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - - DoDoubleTest("foo %E", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %lE", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %hE", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %LE", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %I64E", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %14E", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %-14E", val, "foo 2.560000E+002 ", "foo 2.560000E+02 "); - DoDoubleTest("foo %.1E", val, "foo 2.6E+002", "foo 2.6E+02"); - DoDoubleTest("foo %.8E", val, "foo 2.56000000E+002", "foo 2.56000000E+02"); - DoDoubleTest("foo %014E", val, "foo 02.560000E+002", "foo 002.560000E+02"); - DoDoubleTest("foo %#E", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %+E", val, "foo +2.560000E+002", "foo +2.560000E+02"); - DoDoubleTest("foo % E", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %+E", neg, "foo -2.560000E+002", "foo -2.560000E+02"); - DoDoubleTest("foo % E", neg, "foo -2.560000E+002", "foo -2.560000E+02"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/sprintf_s/test15/testinfo.dat b/src/pal/tests/palsuite/c_runtime/sprintf_s/test15/testinfo.dat deleted file mode 100644 index 537e6d1db..000000000 --- a/src/pal/tests/palsuite/c_runtime/sprintf_s/test15/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = sprintf_s -Name = Positive Test for sprintf_s -TYPE = DEFAULT -EXE1 = test15 -Description -= Tests sprintf_s with exponential format doubles (uppercase) diff --git a/src/pal/tests/palsuite/c_runtime/sprintf_s/test16/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/sprintf_s/test16/CMakeLists.txt deleted file mode 100644 index 2ca1ffd2e..000000000 --- a/src/pal/tests/palsuite/c_runtime/sprintf_s/test16/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test16.cpp -) - -add_executable(paltest_sprintf_test16 - ${SOURCES} -) - -add_dependencies(paltest_sprintf_test16 coreclrpal) - -target_link_libraries(paltest_sprintf_test16 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/sprintf_s/test16/test16.cpp b/src/pal/tests/palsuite/c_runtime/sprintf_s/test16/test16.cpp deleted file mode 100644 index b237c98d5..000000000 --- a/src/pal/tests/palsuite/c_runtime/sprintf_s/test16/test16.cpp +++ /dev/null @@ -1,52 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test16.c -** -** Purpose: Test #16 for the sprintf_s function. Tests the decimal notation -** double specifier (%f) -** -** -**==========================================================================*/ - - -#include -#include "../sprintf_s.h" - -/* - * Depends on memcmp and strlen - */ - -int __cdecl main(int argc, char *argv[]) -{ - double val = 2560.001; - double neg = -2560.001; - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - - DoDoubleTest("foo %f", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %lf", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %hf", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %Lf", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %I64f", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %12f", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %-12f", val, "foo 2560.001000 ", "foo 2560.001000 "); - DoDoubleTest("foo %.1f", val, "foo 2560.0", "foo 2560.0"); - DoDoubleTest("foo %.8f", val, "foo 2560.00100000", "foo 2560.00100000"); - DoDoubleTest("foo %012f", val, "foo 02560.001000", "foo 02560.001000"); - DoDoubleTest("foo %#f", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %+f", val, "foo +2560.001000", "foo +2560.001000"); - DoDoubleTest("foo % f", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %+f", neg, "foo -2560.001000", "foo -2560.001000"); - DoDoubleTest("foo % f", neg, "foo -2560.001000", "foo -2560.001000"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/sprintf_s/test16/testinfo.dat b/src/pal/tests/palsuite/c_runtime/sprintf_s/test16/testinfo.dat deleted file mode 100644 index 4e98eccac..000000000 --- a/src/pal/tests/palsuite/c_runtime/sprintf_s/test16/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = sprintf_s -Name = Positive Test for sprintf_s -TYPE = DEFAULT -EXE1 = test16 -Description -= Tests sprintf_s with decimal point format doubles diff --git a/src/pal/tests/palsuite/c_runtime/sprintf_s/test17/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/sprintf_s/test17/CMakeLists.txt deleted file mode 100644 index 0c17cbfc3..000000000 --- a/src/pal/tests/palsuite/c_runtime/sprintf_s/test17/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test17.cpp -) - -add_executable(paltest_sprintf_test17 - ${SOURCES} -) - -add_dependencies(paltest_sprintf_test17 coreclrpal) - -target_link_libraries(paltest_sprintf_test17 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/sprintf_s/test17/test17.cpp b/src/pal/tests/palsuite/c_runtime/sprintf_s/test17/test17.cpp deleted file mode 100644 index 220555e5d..000000000 --- a/src/pal/tests/palsuite/c_runtime/sprintf_s/test17/test17.cpp +++ /dev/null @@ -1,54 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test17.c -** -** Purpose: Test #17 for the sprintf_s function. Tests the lowercase -** shorthand notation double specifier (%g) -** -** -**==========================================================================*/ - - - -#include -#include "../sprintf_s.h" - -/* - * Depends on memcmp and strlen - */ - -int __cdecl main(int argc, char *argv[]) -{ - double val = 2560.001; - double neg = -2560.001; - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - - DoDoubleTest("foo %g", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %lg", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %hg", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %Lg", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %I64g", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %5g", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %-5g", val, "foo 2560 ", "foo 2560 "); - DoDoubleTest("foo %.1g", val, "foo 3e+003", "foo 3e+03"); - DoDoubleTest("foo %.2g", val, "foo 2.6e+003", "foo 2.6e+03"); - DoDoubleTest("foo %.12g", val, "foo 2560.001", "foo 2560.001"); - DoDoubleTest("foo %06g", val, "foo 002560", "foo 002560"); - DoDoubleTest("foo %#g", val, "foo 2560.00", "foo 2560.00"); - DoDoubleTest("foo %+g", val, "foo +2560", "foo +2560"); - DoDoubleTest("foo % g", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %+g", neg, "foo -2560", "foo -2560"); - DoDoubleTest("foo % g", neg, "foo -2560", "foo -2560"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/sprintf_s/test17/testinfo.dat b/src/pal/tests/palsuite/c_runtime/sprintf_s/test17/testinfo.dat deleted file mode 100644 index 5e41e20d4..000000000 --- a/src/pal/tests/palsuite/c_runtime/sprintf_s/test17/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = sprintf_s -Name = Positive Test for sprintf_s -TYPE = DEFAULT -EXE1 = test17 -Description -= Tests sprintf_s with compact format doubles (lowercase) diff --git a/src/pal/tests/palsuite/c_runtime/sprintf_s/test18/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/sprintf_s/test18/CMakeLists.txt deleted file mode 100644 index afc3e8f01..000000000 --- a/src/pal/tests/palsuite/c_runtime/sprintf_s/test18/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test18.cpp -) - -add_executable(paltest_sprintf_test18 - ${SOURCES} -) - -add_dependencies(paltest_sprintf_test18 coreclrpal) - -target_link_libraries(paltest_sprintf_test18 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/sprintf_s/test18/test18.cpp b/src/pal/tests/palsuite/c_runtime/sprintf_s/test18/test18.cpp deleted file mode 100644 index 2135a6f1e..000000000 --- a/src/pal/tests/palsuite/c_runtime/sprintf_s/test18/test18.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test18.c -** -** Purpose: Test #18 for the sprintf_s function. Tests the uppercase -** shorthand notation double specifier (%G) -** -** -**==========================================================================*/ - - -#include -#include "../sprintf_s.h" - -/* - * Depends on memcmp and strlen - */ - -int __cdecl main(int argc, char *argv[]) -{ - double val = 2560.001; - double neg = -2560.001; - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - - DoDoubleTest("foo %G", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %lG", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %hG", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %LG", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %I64G", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %5G", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %-5G", val, "foo 2560 ", "foo 2560 "); - DoDoubleTest("foo %.1G", val, "foo 3E+003", "foo 3E+03"); - DoDoubleTest("foo %.2G", val, "foo 2.6E+003", "foo 2.6E+03"); - DoDoubleTest("foo %.12G", val, "foo 2560.001", "foo 2560.001"); - DoDoubleTest("foo %06G", val, "foo 002560", "foo 002560"); - DoDoubleTest("foo %#G", val, "foo 2560.00", "foo 2560.00"); - DoDoubleTest("foo %+G", val, "foo +2560", "foo +2560"); - DoDoubleTest("foo % G", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %+G", neg, "foo -2560", "foo -2560"); - DoDoubleTest("foo % G", neg, "foo -2560", "foo -2560"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/sprintf_s/test18/testinfo.dat b/src/pal/tests/palsuite/c_runtime/sprintf_s/test18/testinfo.dat deleted file mode 100644 index 06ae3a632..000000000 --- a/src/pal/tests/palsuite/c_runtime/sprintf_s/test18/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = sprintf_s -Name = Positive Test for sprintf_s -TYPE = DEFAULT -EXE1 = test18 -Description -= Tests sprintf_s with compact format doubles (uppercase) diff --git a/src/pal/tests/palsuite/c_runtime/sprintf_s/test19/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/sprintf_s/test19/CMakeLists.txt deleted file mode 100644 index 7553aede9..000000000 --- a/src/pal/tests/palsuite/c_runtime/sprintf_s/test19/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test19.cpp -) - -add_executable(paltest_sprintf_test19 - ${SOURCES} -) - -add_dependencies(paltest_sprintf_test19 coreclrpal) - -target_link_libraries(paltest_sprintf_test19 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/sprintf_s/test19/test19.cpp b/src/pal/tests/palsuite/c_runtime/sprintf_s/test19/test19.cpp deleted file mode 100644 index 483c7167b..000000000 --- a/src/pal/tests/palsuite/c_runtime/sprintf_s/test19/test19.cpp +++ /dev/null @@ -1,71 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test19.c -** -** Purpose: Test #19 for the sprintf_s function. Tests the variable length -** precision argument. -** -** -**==========================================================================*/ - - -#include -#include "../sprintf_s.h" - -/* - * Depends on memcmp and strlen - */ - - -int __cdecl main(int argc, char *argv[]) -{ - int n = -1; - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - DoArgumentPrecTest("%.*s", 2, (void*)"bar", "bar", "ba", "ba"); - DoArgumentPrecTest("%.*S", 2, (void*)convert("bar"), "bar", "ba", "ba"); - - DoArgumentPrecTest("%.*c", 0, (void*)'a', "a", "a", "a"); - DoArgumentPrecTest("%.*c", 4, (void*)'a', "a", "a", "a"); - DoArgumentPrecTest("%.*C", 0, (void*)'a', "a", "a", "a"); - DoArgumentPrecTest("%.*C", 4, (void*)'a', "a", "a", "a"); - DoArgumentPrecTest("%.*d", 1, (void*)42, "42", "42", "42"); - DoArgumentPrecTest("%.*d", 3, (void*)42, "42", "042", "042"); - DoArgumentPrecTest("%.*i", 1, (void*)42, "42", "42", "42"); - DoArgumentPrecTest("%.*i", 3, (void*)42, "42", "042", "042"); - DoArgumentPrecTest("%.*o", 1, (void*)42, "42", "52", "52"); - DoArgumentPrecTest("%.*o", 3, (void*)42, "42", "052", "052"); - DoArgumentPrecTest("%.*u", 1, (void*)42, "42", "42", "42"); - DoArgumentPrecTest("%.*u", 3, (void*)42, "42", "042", "042"); - DoArgumentPrecTest("%.*x", 1, (void*)0x42, "0x42", "42", "42"); - DoArgumentPrecTest("%.*x", 3, (void*)0x42, "0x42", "042", "042"); - DoArgumentPrecTest("%.*X", 1, (void*)0x42, "0x42", "42", "42"); - DoArgumentPrecTest("%.*X", 3, (void*)0x42, "0x42", "042", "042"); - - - DoArgumentPrecDoubleTest("%.*e", 1, 2.01, "2.0e+000", "2.0e+00"); - DoArgumentPrecDoubleTest("%.*e", 3, 2.01, "2.010e+000", "2.010e+00"); - DoArgumentPrecDoubleTest("%.*E", 1, 2.01, "2.0E+000", "2.0E+00"); - DoArgumentPrecDoubleTest("%.*E", 3, 2.01, "2.010E+000", "2.010E+00"); - DoArgumentPrecDoubleTest("%.*f", 1, 2.01, "2.0", "2.0"); - DoArgumentPrecDoubleTest("%.*f", 3, 2.01, "2.010", "2.010"); - DoArgumentPrecDoubleTest("%.*g", 1, 256.01, "3e+002", "3e+02"); - DoArgumentPrecDoubleTest("%.*g", 3, 256.01, "256", "256"); - DoArgumentPrecDoubleTest("%.*g", 4, 256.01, "256", "256"); - DoArgumentPrecDoubleTest("%.*g", 6, 256.01, "256.01", "256.01"); - DoArgumentPrecDoubleTest("%.*G", 1, 256.01, "3E+002", "3E+02"); - DoArgumentPrecDoubleTest("%.*G", 3, 256.01, "256", "256"); - DoArgumentPrecDoubleTest("%.*G", 4, 256.01, "256", "256"); - DoArgumentPrecDoubleTest("%.*G", 6, 256.01, "256.01", "256.01"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/sprintf_s/test19/testinfo.dat b/src/pal/tests/palsuite/c_runtime/sprintf_s/test19/testinfo.dat deleted file mode 100644 index 7064c0177..000000000 --- a/src/pal/tests/palsuite/c_runtime/sprintf_s/test19/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = sprintf_s -Name = Positive Test for sprintf_s -TYPE = DEFAULT -EXE1 = test19 -Description -= Tests sprintf_s with argument specified precision diff --git a/src/pal/tests/palsuite/c_runtime/sprintf_s/test2/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/sprintf_s/test2/CMakeLists.txt deleted file mode 100644 index a4b0b007b..000000000 --- a/src/pal/tests/palsuite/c_runtime/sprintf_s/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test2.cpp -) - -add_executable(paltest_sprintf_test2 - ${SOURCES} -) - -add_dependencies(paltest_sprintf_test2 coreclrpal) - -target_link_libraries(paltest_sprintf_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/sprintf_s/test2/test2.cpp b/src/pal/tests/palsuite/c_runtime/sprintf_s/test2/test2.cpp deleted file mode 100644 index a3eb71dd1..000000000 --- a/src/pal/tests/palsuite/c_runtime/sprintf_s/test2/test2.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test2.c -** -** Purpose: Test #2 for the sprintf_s function. Tests the string specifier -** (%s). -** -** -**==========================================================================*/ - - -#include -#include "../sprintf_s.h" - -/* - * Depends on memcmp and strlen - */ - -int __cdecl main(int argc, char *argv[]) -{ - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - - DoStrTest("foo %s", "bar", "foo bar"); - DoStrTest("foo %hs", "bar", "foo bar"); - DoWStrTest("foo %ls", convert("bar"), "foo bar"); - DoWStrTest("foo %ws", convert("bar"), "foo bar"); - DoStrTest("foo %Ls", "bar", "foo bar"); - DoStrTest("foo %I64s", "bar", "foo bar"); - DoStrTest("foo %5s", "bar", "foo bar"); - DoStrTest("foo %.2s", "bar", "foo ba"); - DoStrTest("foo %5.2s", "bar", "foo ba"); - DoStrTest("foo %-5s", "bar", "foo bar "); - DoStrTest("foo %05s", "bar", "foo 00bar"); - DoStrTest("foo %s", NULL, "foo (null)"); - DoStrTest("foo %hs", NULL, "foo (null)"); - DoWStrTest("foo %ls", NULL, "foo (null)"); - DoWStrTest("foo %ws", NULL, "foo (null)"); - DoStrTest("foo %Ls", NULL, "foo (null)"); - DoStrTest("foo %I64s", NULL, "foo (null)"); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/c_runtime/sprintf_s/test2/testinfo.dat b/src/pal/tests/palsuite/c_runtime/sprintf_s/test2/testinfo.dat deleted file mode 100644 index cce2dc67e..000000000 --- a/src/pal/tests/palsuite/c_runtime/sprintf_s/test2/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = sprintf_s -Name = Positive Test for sprintf_s -TYPE = DEFAULT -EXE1 = test2 -Description -= Tests sprintf_s with strings diff --git a/src/pal/tests/palsuite/c_runtime/sprintf_s/test3/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/sprintf_s/test3/CMakeLists.txt deleted file mode 100644 index 825c79c03..000000000 --- a/src/pal/tests/palsuite/c_runtime/sprintf_s/test3/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test3.cpp -) - -add_executable(paltest_sprintf_test3 - ${SOURCES} -) - -add_dependencies(paltest_sprintf_test3 coreclrpal) - -target_link_libraries(paltest_sprintf_test3 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/sprintf_s/test3/test3.cpp b/src/pal/tests/palsuite/c_runtime/sprintf_s/test3/test3.cpp deleted file mode 100644 index dd6e59026..000000000 --- a/src/pal/tests/palsuite/c_runtime/sprintf_s/test3/test3.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test3.c -** -** Purpose: Test #3 for the sprintf_s function. Tests the wide string -** specifier (%S). -** -** -**==========================================================================*/ - - - -#include -#include "../sprintf_s.h" - -/* - * Depends on memcmp and strlen - */ - -int __cdecl main(int argc, char *argv[]) -{ - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - DoWStrTest("foo %S", convert("bar"), "foo bar"); - DoStrTest("foo %hS", "bar", "foo bar"); - DoWStrTest("foo %lS", convert("bar"), "foo bar"); - DoWStrTest("foo %wS", convert("bar"), "foo bar"); - DoWStrTest("foo %LS", convert("bar"), "foo bar"); - DoWStrTest("foo %I64S", convert("bar"), "foo bar"); - DoWStrTest("foo %5S", convert("bar"), "foo bar"); - DoWStrTest("foo %.2S", convert("bar"), "foo ba"); - DoWStrTest("foo %5.2S", convert("bar"), "foo ba"); - DoWStrTest("foo %-5S", convert("bar"), "foo bar "); - DoWStrTest("foo %05S", convert("bar"), "foo 00bar"); - DoWStrTest("foo %S", NULL, "foo (null)"); - DoStrTest("foo %hS", NULL, "foo (null)"); - DoWStrTest("foo %lS", NULL, "foo (null)"); - DoWStrTest("foo %wS", NULL, "foo (null)"); - DoWStrTest("foo %LS", NULL, "foo (null)"); - DoWStrTest("foo %I64S", NULL, "foo (null)"); - - PAL_Terminate(); - return PASS; -} - - diff --git a/src/pal/tests/palsuite/c_runtime/sprintf_s/test3/testinfo.dat b/src/pal/tests/palsuite/c_runtime/sprintf_s/test3/testinfo.dat deleted file mode 100644 index cc8de0eae..000000000 --- a/src/pal/tests/palsuite/c_runtime/sprintf_s/test3/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = sprintf_s -Name = Positive Test for sprintf_s -TYPE = DEFAULT -EXE1 = test3 -Description -= Tests sprintf_s with wide strings diff --git a/src/pal/tests/palsuite/c_runtime/sprintf_s/test4/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/sprintf_s/test4/CMakeLists.txt deleted file mode 100644 index 0bde37c23..000000000 --- a/src/pal/tests/palsuite/c_runtime/sprintf_s/test4/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test4.cpp -) - -add_executable(paltest_sprintf_test4 - ${SOURCES} -) - -add_dependencies(paltest_sprintf_test4 coreclrpal) - -target_link_libraries(paltest_sprintf_test4 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/sprintf_s/test4/test4.cpp b/src/pal/tests/palsuite/c_runtime/sprintf_s/test4/test4.cpp deleted file mode 100644 index bb3a6d818..000000000 --- a/src/pal/tests/palsuite/c_runtime/sprintf_s/test4/test4.cpp +++ /dev/null @@ -1,69 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test4.c -** -** Purpose: Test #4 for the sprintf_s function. Tests the pointer -** specifier (%p). -** -** -**==========================================================================*/ - - - -#include -#include "../sprintf_s.h" -/* - * Depends on memcmp and strlen - */ - -int __cdecl main(int argc, char *argv[]) -{ - void *ptr = (void*) 0x123456; - INT64 lptr = I64(0x1234567887654321); - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - -/* -** Run only on 64 bit platforms -*/ -#if defined(BIT64) - Trace("Testing for 64 Bit Platforms \n"); - DoPointerTest("%p", NULL, "NULL", "0000000000000000"); - DoPointerTest("%p", ptr, "pointer to 0x123456", "0000000000123456"); - DoPointerTest("%17p", ptr, "pointer to 0x123456", " 0000000000123456"); - DoPointerTest("%17p", ptr, "pointer to 0x123456", " 0000000000123456"); - DoPointerTest("%-17p", ptr, "pointer to 0x123456", "0000000000123456 "); - DoPointerTest("%+p", ptr, "pointer to 0x123456", "0000000000123456"); - DoPointerTest("%#p", ptr, "pointer to 0x123456", "0X0000000000123456"); - DoPointerTest("%lp", ptr, "pointer to 0x123456", "00123456"); - DoPointerTest("%hp", ptr, "pointer to 0x123456", "00003456"); - DoPointerTest("%Lp", ptr, "pointer to 0x123456", "00123456"); - DoI64Test("%I64p", lptr, "pointer to 0x1234567887654321", - "1234567887654321"); -#else - Trace("Testing for Non 64 Bit Platforms \n"); - DoPointerTest("%p", NULL, "NULL", "00000000"); - DoPointerTest("%p", ptr, "pointer to 0x123456", "00123456"); - DoPointerTest("%9p", ptr, "pointer to 0x123456", " 00123456"); - DoPointerTest("%09p", ptr, "pointer to 0x123456", " 00123456"); - DoPointerTest("%-9p", ptr, "pointer to 0x123456", "00123456 "); - DoPointerTest("%+p", ptr, "pointer to 0x123456", "00123456"); - DoPointerTest("%#p", ptr, "pointer to 0x123456", "0X00123456"); - DoPointerTest("%lp", ptr, "pointer to 0x123456", "00123456"); - DoPointerTest("%hp", ptr, "pointer to 0x123456", "00003456"); - DoPointerTest("%Lp", ptr, "pointer to 0x123456", "00123456"); - DoI64Test("%I64p", lptr, "pointer to 0x1234567887654321", - "1234567887654321"); -#endif - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/c_runtime/sprintf_s/test4/testinfo.dat b/src/pal/tests/palsuite/c_runtime/sprintf_s/test4/testinfo.dat deleted file mode 100644 index f53f78499..000000000 --- a/src/pal/tests/palsuite/c_runtime/sprintf_s/test4/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = sprintf_s -Name = Positive Test for sprintf_s -TYPE = DEFAULT -EXE1 = test4 -Description -= Tests sprintf_s with pointers diff --git a/src/pal/tests/palsuite/c_runtime/sprintf_s/test6/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/sprintf_s/test6/CMakeLists.txt deleted file mode 100644 index 495c256b4..000000000 --- a/src/pal/tests/palsuite/c_runtime/sprintf_s/test6/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test6.cpp -) - -add_executable(paltest_sprintf_test6 - ${SOURCES} -) - -add_dependencies(paltest_sprintf_test6 coreclrpal) - -target_link_libraries(paltest_sprintf_test6 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/sprintf_s/test6/test6.cpp b/src/pal/tests/palsuite/c_runtime/sprintf_s/test6/test6.cpp deleted file mode 100644 index c5fc80407..000000000 --- a/src/pal/tests/palsuite/c_runtime/sprintf_s/test6/test6.cpp +++ /dev/null @@ -1,50 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test6.c -** -** Purpose: Test #6 for the sprintf_s function. Tests the char specifier (%c). -** -** -**==========================================================================*/ - - - -#include -#include "../sprintf_s.h" - -/* - * Depends on memcmp and strlen - */ - -int __cdecl main(int argc, char *argv[]) -{ - WCHAR wc = (WCHAR) 'c'; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - DoCharTest("foo %c", 'b', "foo b"); - DoCharTest("foo %hc", 'b', "foo b"); - DoWCharTest("foo %lc", wc, "foo c"); - DoCharTest("foo %Lc", 'b', "foo b"); - DoCharTest("foo %I64c", 'b', "foo b"); - DoCharTest("foo %5c", 'b', "foo b"); - DoCharTest("foo %.0c", 'b', "foo b"); - DoCharTest("foo %-5c", 'b', "foo b "); - DoCharTest("foo %05c", 'b', "foo 0000b"); - DoCharTest("foo % c", 'b', "foo b"); - DoCharTest("foo %#c", 'b', "foo b"); - - PAL_Terminate(); - return PASS; -} - - - diff --git a/src/pal/tests/palsuite/c_runtime/sprintf_s/test6/testinfo.dat b/src/pal/tests/palsuite/c_runtime/sprintf_s/test6/testinfo.dat deleted file mode 100644 index c5b93fc78..000000000 --- a/src/pal/tests/palsuite/c_runtime/sprintf_s/test6/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = sprintf_s -Name = Positive Test for sprintf_s -TYPE = DEFAULT -EXE1 = test6 -Description -= Tests sprintf_s with characters diff --git a/src/pal/tests/palsuite/c_runtime/sprintf_s/test7/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/sprintf_s/test7/CMakeLists.txt deleted file mode 100644 index 2fabe0b65..000000000 --- a/src/pal/tests/palsuite/c_runtime/sprintf_s/test7/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test7.cpp -) - -add_executable(paltest_sprintf_test7 - ${SOURCES} -) - -add_dependencies(paltest_sprintf_test7 coreclrpal) - -target_link_libraries(paltest_sprintf_test7 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/sprintf_s/test7/test7.cpp b/src/pal/tests/palsuite/c_runtime/sprintf_s/test7/test7.cpp deleted file mode 100644 index fd46ae967..000000000 --- a/src/pal/tests/palsuite/c_runtime/sprintf_s/test7/test7.cpp +++ /dev/null @@ -1,49 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test7.c -** -** Purpose: Test #7 for the sprintf_s function. Tests the wide char -** specifier (%C). -** -** -**==========================================================================*/ - - - -#include -#include "../sprintf_s.h" - -/* - * Depends on memcmp and strlen - */ - -int __cdecl main(int argc, char *argv[]) -{ - WCHAR wb = (WCHAR) 'b'; - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - - DoWCharTest("foo %C", wb, "foo b"); - DoWCharTest("foo %hC", wb, "foo b"); - DoCharTest("foo %lC", 'c', "foo c"); - DoWCharTest("foo %LC", wb, "foo b"); - DoWCharTest("foo %I64C", wb, "foo b"); - DoWCharTest("foo %5C", wb, "foo b"); - DoWCharTest("foo %.0C", wb, "foo b"); - DoWCharTest("foo %-5C", wb, "foo b "); - DoWCharTest("foo %05C", wb, "foo 0000b"); - DoWCharTest("foo % C", wb, "foo b"); - DoWCharTest("foo %#C", wb, "foo b"); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/c_runtime/sprintf_s/test7/testinfo.dat b/src/pal/tests/palsuite/c_runtime/sprintf_s/test7/testinfo.dat deleted file mode 100644 index 647c9d80f..000000000 --- a/src/pal/tests/palsuite/c_runtime/sprintf_s/test7/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = sprintf_s -Name = Positive Test for sprintf_s -TYPE = DEFAULT -EXE1 = test7 -Description -= Tests sprintf_s with wide characters diff --git a/src/pal/tests/palsuite/c_runtime/sprintf_s/test8/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/sprintf_s/test8/CMakeLists.txt deleted file mode 100644 index cb67e89df..000000000 --- a/src/pal/tests/palsuite/c_runtime/sprintf_s/test8/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test8.cpp -) - -add_executable(paltest_sprintf_test8 - ${SOURCES} -) - -add_dependencies(paltest_sprintf_test8 coreclrpal) - -target_link_libraries(paltest_sprintf_test8 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/sprintf_s/test8/test8.cpp b/src/pal/tests/palsuite/c_runtime/sprintf_s/test8/test8.cpp deleted file mode 100644 index db02627bb..000000000 --- a/src/pal/tests/palsuite/c_runtime/sprintf_s/test8/test8.cpp +++ /dev/null @@ -1,55 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test8.c -** -** Purpose: Test #8 for the sprintf_s function. Tests the decimal -** specifier (%d). -** -** -**==========================================================================*/ - - - -#include -#include "../sprintf_s.h" - -/* - * Depends on memcmp and strlen - */ - -int __cdecl main(int argc, char *argv[]) -{ - int neg = -42; - int pos = 42; - INT64 l = 42; - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - - DoNumTest("foo %d", pos, "foo 42"); - DoNumTest("foo %ld", 0xFFFF, "foo 65535"); - DoNumTest("foo %hd", 0xFFFF, "foo -1"); - DoNumTest("foo %Ld", pos, "foo 42"); - DoI64Test("foo %I64d", l, "42", "foo 42"); - DoNumTest("foo %3d", pos, "foo 42"); - DoNumTest("foo %-3d", pos, "foo 42 "); - DoNumTest("foo %.1d", pos, "foo 42"); - DoNumTest("foo %.3d", pos, "foo 042"); - DoNumTest("foo %03d", pos, "foo 042"); - DoNumTest("foo %#d", pos, "foo 42"); - DoNumTest("foo %+d", pos, "foo +42"); - DoNumTest("foo % d", pos, "foo 42"); - DoNumTest("foo %+d", neg, "foo -42"); - DoNumTest("foo % d", neg, "foo -42"); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/c_runtime/sprintf_s/test8/testinfo.dat b/src/pal/tests/palsuite/c_runtime/sprintf_s/test8/testinfo.dat deleted file mode 100644 index 524834e53..000000000 --- a/src/pal/tests/palsuite/c_runtime/sprintf_s/test8/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = sprintf_s -Name = Positive Test for sprintf_s -TYPE = DEFAULT -EXE1 = test8 -Description -= Tests sprintf_s with decimal numbers diff --git a/src/pal/tests/palsuite/c_runtime/sprintf_s/test9/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/sprintf_s/test9/CMakeLists.txt deleted file mode 100644 index 005a23d4e..000000000 --- a/src/pal/tests/palsuite/c_runtime/sprintf_s/test9/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test9.cpp -) - -add_executable(paltest_sprintf_test9 - ${SOURCES} -) - -add_dependencies(paltest_sprintf_test9 coreclrpal) - -target_link_libraries(paltest_sprintf_test9 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/sprintf_s/test9/test9.cpp b/src/pal/tests/palsuite/c_runtime/sprintf_s/test9/test9.cpp deleted file mode 100644 index 2e1c78ce6..000000000 --- a/src/pal/tests/palsuite/c_runtime/sprintf_s/test9/test9.cpp +++ /dev/null @@ -1,55 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test9.c -** -** Purpose: Test #9 for the sprintf_s function. Tests the integer -** specifier (%i). -** -** -**==========================================================================*/ - - - -#include -#include "../sprintf_s.h" - -/* - * Depends on memcmp and strlen - */ - -int __cdecl main(int argc, char *argv[]) -{ - int neg = -42; - int pos = 42; - INT64 l = 42; - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - - DoNumTest("foo %i", pos, "foo 42"); - DoNumTest("foo %li", 0xFFFF, "foo 65535"); - DoNumTest("foo %hi", 0xFFFF, "foo -1"); - DoNumTest("foo %Li", pos, "foo 42"); - DoI64Test("foo %I64i", l, "42", "foo 42"); - DoNumTest("foo %3i", pos, "foo 42"); - DoNumTest("foo %-3i", pos, "foo 42 "); - DoNumTest("foo %.1i", pos, "foo 42"); - DoNumTest("foo %.3i", pos, "foo 042"); - DoNumTest("foo %03i", pos, "foo 042"); - DoNumTest("foo %#i", pos, "foo 42"); - DoNumTest("foo %+i", pos, "foo +42"); - DoNumTest("foo % i", pos, "foo 42"); - DoNumTest("foo %+i", neg, "foo -42"); - DoNumTest("foo % i", neg, "foo -42"); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/c_runtime/sprintf_s/test9/testinfo.dat b/src/pal/tests/palsuite/c_runtime/sprintf_s/test9/testinfo.dat deleted file mode 100644 index 7c51443a3..000000000 --- a/src/pal/tests/palsuite/c_runtime/sprintf_s/test9/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = sprintf_s -Name = Positive Test for sprintf_s -TYPE = DEFAULT -EXE1 = test9 -Description -= Tests sprintf_s with integer numbers diff --git a/src/pal/tests/palsuite/c_runtime/sqrt/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/sqrt/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/c_runtime/sqrt/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/c_runtime/sqrt/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/sqrt/test1/CMakeLists.txt deleted file mode 100644 index 4680e2359..000000000 --- a/src/pal/tests/palsuite/c_runtime/sqrt/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_sqrt_test1 - ${SOURCES} -) - -add_dependencies(paltest_sqrt_test1 coreclrpal) - -target_link_libraries(paltest_sqrt_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/sqrt/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/sqrt/test1/test1.cpp deleted file mode 100644 index 62d2251d6..000000000 --- a/src/pal/tests/palsuite/c_runtime/sqrt/test1/test1.cpp +++ /dev/null @@ -1,123 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test1.c -** -** Purpose: Call the sqrt function on a positive value, a positive value -** with a decimal and on the maxium possible double value. -** -** -**===================================================================*/ - -#include - -// binary64 (double) has a machine epsilon of 2^-52 (approx. 2.22e-16). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-50 (approx. 8.88e-16) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (15-17 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxxxxxxxxxx will use -// PAL_EPSILON for the variance, while an expected result in the format of 0.0xxxxxxxxxxxxxxxxx -// will use PAL_EPSILON / 10 and and expected result in the format of x.xxxxxxxxxxxxxxxx will -// use PAL_EPSILON * 10. -#define PAL_EPSILON 8.8817841970012523e-16 - -#define PAL_NAN sqrt(-1.0) -#define PAL_POSINF -log(0.0) -#define PAL_NEGINF log(0.0) - -/** - * Helper test structure - */ -struct test -{ - double value; /* value to test the function with */ - double expected; /* expected result */ - double variance; /* maximum delta between the expected and actual result */ -}; - -/** - * validate - * - * test validation function - */ -void __cdecl validate(double value, double expected, double variance) -{ - double result = sqrt(value); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - double delta = fabs(result - expected); - - if (delta > variance) - { - Fail("sqrt(%g) returned %20.17g when it should have returned %20.17g", - value, result, expected); - } -} - -/** - * validate - * - * test validation function for values returning NaN - */ -void __cdecl validate_isnan(double value) -{ - double result = sqrt(value); - - if (!_isnan(result)) - { - Fail("sqrt(%g) returned %20.17g when it should have returned %20.17g", - value, result, PAL_NAN); - } -} - -int __cdecl main(int argc, char **argv) -{ - struct test tests[] = - { - /* value expected variance */ - { 0.31830988618379067, 0.56418958354775629, PAL_EPSILON }, // value: 1 / pi - { 0.43429448190325183, 0.65901022898226081, PAL_EPSILON }, // value: log10(e) - { 0.63661977236758134, 0.79788456080286536, PAL_EPSILON }, // value: 2 / pi - { 0.69314718055994531, 0.83255461115769776, PAL_EPSILON }, // value: ln(2) - { 0.70710678118654752, 0.84089641525371454, PAL_EPSILON }, // value: 1 / sqrt(2) - { 0.78539816339744831, 0.88622692545275801, PAL_EPSILON }, // value: pi / 4 - { 1, 1, PAL_EPSILON * 10 }, - { 1.1283791670955126, 1.0622519320271969, PAL_EPSILON * 10 }, // value: 2 / sqrt(pi) - { 1.4142135623730950, 1.1892071150027211, PAL_EPSILON * 10 }, // value: sqrt(2) - { 1.4426950408889634, 1.2011224087864498, PAL_EPSILON * 10 }, // value: log2(e) - { 1.5707963267948966, 1.2533141373155003, PAL_EPSILON * 10 }, // value: pi / 2 - { 2.3025850929940457, 1.5174271293851464, PAL_EPSILON * 10 }, // value: ln(10) - { 2.7182818284590452, 1.6487212707001281, PAL_EPSILON * 10 }, // value: e - { 3.1415926535897932, 1.7724538509055160, PAL_EPSILON * 10 }, // value: pi - }; - - /* PAL initialization */ - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - validate(-0.0, -0.0, PAL_EPSILON); - validate( 0.0, 0.0, PAL_EPSILON); - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - validate(tests[i].value, tests[i].expected, tests[i].variance); - validate_isnan(-tests[i].value); - } - - validate_isnan(PAL_NAN); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/sqrt/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/sqrt/test1/testinfo.dat deleted file mode 100644 index 804fef088..000000000 --- a/src/pal/tests/palsuite/c_runtime/sqrt/test1/testinfo.dat +++ /dev/null @@ -1,17 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = sqrt -Name = Call sqrt on positive values and zero. -TYPE = DEFAULT -EXE1 = test1 -Description -= Call the sqrt function on a positive value, a positive value -= with a decimal and on the maxium possible double value. - - - - diff --git a/src/pal/tests/palsuite/c_runtime/sqrtf/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/sqrtf/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/c_runtime/sqrtf/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/c_runtime/sqrtf/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/sqrtf/test1/CMakeLists.txt deleted file mode 100644 index 51b76aeac..000000000 --- a/src/pal/tests/palsuite/c_runtime/sqrtf/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.c -) - -add_executable(paltest_sqrtf_test1 - ${SOURCES} -) - -add_dependencies(paltest_sqrtf_test1 coreclrpal) - -target_link_libraries(paltest_sqrtf_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/sqrtf/test1/test1.c b/src/pal/tests/palsuite/c_runtime/sqrtf/test1/test1.c deleted file mode 100644 index cb1ac9e7d..000000000 --- a/src/pal/tests/palsuite/c_runtime/sqrtf/test1/test1.c +++ /dev/null @@ -1,122 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test1.c -** -** Purpose: Call the sqrtf function on a positive value, a positive value -** with a decimal and on the maxium possible float value. -** -** -**===================================================================*/ - -#include - -// binary32 (float) has a machine epsilon of 2^-23 (approx. 1.19e-07). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-21 (approx. 4.76e-07) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (6-9 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxx will use PAL_EPSILON -// for the variance, while an expected result in the format of 0.0xxxxxxxxx will use -// PAL_EPSILON / 10 and and expected result in the format of x.xxxxxx will use PAL_EPSILON * 10. -#define PAL_EPSILON 4.76837158e-07 - -#define PAL_NAN sqrtf(-1.0f) -#define PAL_POSINF -logf(0.0f) -#define PAL_NEGINF logf(0.0f) - -/** - * Helper test structure - */ -struct test -{ - float value; /* value to test the function with */ - float expected; /* expected result */ - float variance; /* maximum delta between the expected and actual result */ -}; - -/** - * validate - * - * test validation function - */ -void __cdecl validate(float value, float expected, float variance) -{ - float result = sqrtf(value); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - float delta = fabsf(result - expected); - - if (delta > variance) - { - Fail("sqrtf(%g) returned %10.9g when it should have returned %10.9g", - value, result, expected); - } -} - -/** - * validate - * - * test validation function for values returning NaN - */ -void __cdecl validate_isnan(float value) -{ - float result = sqrtf(value); - - if (!_isnanf(result)) - { - Fail("sqrtf(%g) returned %10.9g when it should have returned %10.9g", - value, result, PAL_NAN); - } -} - -int __cdecl main(int argc, char **argv) -{ - struct test tests[] = - { - /* value expected variance */ - { 0.318309886f, 0.564189584f, PAL_EPSILON }, // value: 1 / pi - { 0.434294482f, 0.659010229f, PAL_EPSILON }, // value: log10f(e) - { 0.636619772f, 0.797884561f, PAL_EPSILON }, // value: 2 / pi - { 0.693147181f, 0.832554611f, PAL_EPSILON }, // value: ln(2) - { 0.707106781f, 0.840896415f, PAL_EPSILON }, // value: 1 / sqrtf(2) - { 0.785398163f, 0.886226925f, PAL_EPSILON }, // value: pi / 4 - { 1, 1, PAL_EPSILON * 10 }, - { 1.12837917f, 1.06225193f, PAL_EPSILON * 10 }, // value: 2 / sqrtf(pi) - { 1.41421356f, 1.18920712f, PAL_EPSILON * 10 }, // value: sqrtf(2) - { 1.44269504f, 1.20112241f, PAL_EPSILON * 10 }, // value: logf2(e) - { 1.57079633f, 1.25331414f, PAL_EPSILON * 10 }, // value: pi / 2 - { 2.30258509f, 1.51742713f, PAL_EPSILON * 10 }, // value: ln(10) - { 2.71828183f, 1.64872127f, PAL_EPSILON * 10 }, // value: e - { 3.14159265f, 1.77245385F, PAL_EPSILON * 10 }, // value: pi - }; - - /* PAL initialization */ - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - validate(-0.0f, -0.0f, PAL_EPSILON); - validate( 0.0f, 0.0f, PAL_EPSILON); - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - validate(tests[i].value, tests[i].expected, tests[i].variance); - validate_isnan(-tests[i].value); - } - - validate_isnan(PAL_NAN); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/sqrtf/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/sqrtf/test1/testinfo.dat deleted file mode 100644 index 00d8ab2e4..000000000 --- a/src/pal/tests/palsuite/c_runtime/sqrtf/test1/testinfo.dat +++ /dev/null @@ -1,17 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = sqrtf -Name = Call sqrtf on positive values and zero. -TYPE = DEFAULT -EXE1 = test1 -Description -= Call the sqrtf function on a positive value, a positive value -= with a decimal and on the maxium possible float value. - - - - diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/sscanf_s/CMakeLists.txt deleted file mode 100644 index 59f39a5f5..000000000 --- a/src/pal/tests/palsuite/c_runtime/sscanf_s/CMakeLists.txt +++ /dev/null @@ -1,20 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test10) -add_subdirectory(test11) -add_subdirectory(test12) -add_subdirectory(test13) -add_subdirectory(test14) -add_subdirectory(test15) -add_subdirectory(test16) -add_subdirectory(test17) -add_subdirectory(test2) -add_subdirectory(test3) -add_subdirectory(test4) -add_subdirectory(test5) -add_subdirectory(test6) -add_subdirectory(test7) -add_subdirectory(test8) -add_subdirectory(test9) - diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/sscanf_s.h b/src/pal/tests/palsuite/c_runtime/sscanf_s/sscanf_s.h deleted file mode 100644 index 8a99d87cb..000000000 --- a/src/pal/tests/palsuite/c_runtime/sscanf_s/sscanf_s.h +++ /dev/null @@ -1,246 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: sscanf_s.h -** -** Purpose: Contains common testing functions for sscanf_s -** -** -**==========================================================================*/ - -#ifndef __SSCANF_S_H__ -#define __SSCANF_S_H__ - -void DoVoidTest(char *inputstr, const char *formatstr) -{ - char buf[256] = { 0 }; - int i; - int ret; - - ret = sscanf_s(inputstr, formatstr, buf); - if (ret != 0) - { - Fail("ERROR: Expected sscanf_s to return 0, got %d.\n" - "Using \"%s\" in \"%s\".\n", ret, inputstr, formatstr); - } - - for (i=0; i<256; i++) - { - if (buf[i] != 0) - { - Fail("ERROR: Parameter unexpectedly modified scanning \"%s\" " - "using \"%s\".\n", inputstr, formatstr); - } - } - -} - -void DoStrTest(char *inputstr, const char *formatstr, const char *checkstr) -{ - char buf[256] = { 0 }; - int ret; - - ret = sscanf_s(inputstr, formatstr, buf, _countof(buf)); - if (ret != 1) - { - Fail("ERROR: Expected sscanf_s to return 1, got %d.\n" - "Using \"%s\" in \"%s\".\n", ret, inputstr, formatstr); - } - - if (memcmp(checkstr, buf, strlen(checkstr) + 1) != 0) - { - Fail("ERROR: scanned string incorrectly from \"%s\" using \"%s\".\n" - "Expected \"%s\", got \"%s\".\n", inputstr, formatstr, checkstr, - buf); - } - -} - -void DoWStrTest(char *inputstr, const char *formatstr, const WCHAR *checkstr) -{ - WCHAR buf[256] = { 0 }; - int ret; - - ret = sscanf_s(inputstr, formatstr, buf, _countof(buf)); - if (ret != 1) - { - Fail("ERROR: Expected sscanf_s to return 1, got %d.\n" - "Using \"%s\" in \"%s\".\n", ret, inputstr, formatstr); - } - - if (memcmp(checkstr, buf, wcslen(checkstr)*2 + 2) != 0) - { - Fail("ERROR: scanned wide string incorrectly from \"%s\" using \"%s\".\n" - "Expected \"%s\", got \"%s\".\n", inputstr, formatstr, - convertC(checkstr), convertC(buf)); - } - -} - -void DoNumTest(char *inputstr, const char *formatstr, int checknum) -{ - int num; - int ret; - - ret = sscanf_s(inputstr, formatstr, &num); - if (ret != 1) - { - Fail("ERROR: Expected sscanf_s to return 1, got %d.\n" - "Using \"%s\" in \"%s\".\n", ret, inputstr, formatstr); - } - - if (checknum != num) - { - Fail("ERROR: scanned number incorrectly from \"%s\" using \"%s\".\n" - "Expected %d, got %d.\n", inputstr, formatstr, checknum, num); - } -} - -void DoShortNumTest(char *inputstr, const char *formatstr, short checknum) -{ - short num; - int ret; - - ret = sscanf_s(inputstr, formatstr, &num); - if (ret != 1) - { - Fail("ERROR: Expected sscanf_s to return 1, got %d.\n" - "Using \"%s\" in \"%s\".\n", ret, inputstr, formatstr); - } - - if (checknum != num) - { - Fail("ERROR: scanned number incorrectly from \"%s\" using \"%s\".\n" - "Expected %hd, got %hd.\n", inputstr, formatstr, checknum, num); - } -} - -void DoI64NumTest(char *inputstr, const char *formatstr, INT64 checknum) -{ - char buf[256]; - char check[256]; - INT64 num; - int ret; - - ret = sscanf_s(inputstr, formatstr, &num); - if (ret != 1) - { - Fail("ERROR: Expected sscanf_s to return 1, got %d.\n" - "Using \"%s\" in \"%s\".\n", ret, inputstr, formatstr); - } - - if (checknum != num) - { - sprintf_s(buf, _countof(buf), "%I64d", num); - sprintf_s(check, _countof(check), "%I64d", checknum); - Fail("ERROR: scanned I64 number incorrectly from \"%s\" using \"%s\".\n" - "Expected %s, got %s.\n", inputstr, formatstr, check, buf); - } -} - -void DoCharTest(char *inputstr, const char *formatstr, char* checkchars, int numchars) -{ - char buf[256]; - int ret; - int i; - - for (i=0; i<256; i++) - buf[i] = (char)-1; - - ret = sscanf_s(inputstr, formatstr, buf, _countof(buf)); - if (ret != 1) - { - Fail("ERROR: Expected sscanf_s to return 1, got %d.\n" - "Using \"%s\" in \"%s\".\n", ret, inputstr, formatstr); - } - - if (memcmp(buf, checkchars, numchars) != 0) - { - buf[numchars] = 0; - - Fail("ERROR: scanned character(s) incorrectly from \"%s\" using \"%s\".\n" - "Expected %s, got %s.\n", inputstr, formatstr, checkchars, - buf); - } - - if (buf[numchars] != (char)-1) - { - Fail("ERROR: overflow occurred in scanning character(s) from \"%s\" " - "using \"%s\".\nExpected %d character(s)\n", inputstr, formatstr, - numchars); - } -} - -void DoWCharTest(char *inputstr, const char *formatstr, WCHAR* checkchars, int numchars) -{ - WCHAR buf[256]; - int ret; - int i; - - for (i=0; i<256; i++) - buf[i] = (WCHAR)-1; - - ret = sscanf_s(inputstr, formatstr, buf, _countof(buf)); - if (ret != 1) - { - Fail("ERROR: Expected sscanf_s to return 1, got %d.\n" - "Using \"%s\" in \"%s\".\n", ret, inputstr, formatstr); - } - - if (memcmp(buf, checkchars, numchars) != 0) - { - buf[numchars] = 0; - - Fail("ERROR: scanned wide character(s) incorrectly from \"%s\" using \"%s\".\n" - "Expected %s, got %s.\n", inputstr, formatstr, convertC(checkchars), - convertC(buf)); - } - - if (buf[numchars] != (WCHAR)-1) - { - Fail("ERROR: overflow occurred in scanning wide character(s) from \"%s\" " - "using \"%s\".\nExpected %d character(s)\n", inputstr, formatstr, - numchars); - } -} - - -void DoFloatTest(char *inputstr, const char *formatstr, float checkval) -{ - char buf[256] = { 0 }; - float val; - int ret; - int i; - - for (i=0; i<256; i++) - buf[i] = (char)-1; - - ret = sscanf_s(inputstr, formatstr, buf); - val = *(float*)buf; - - if (ret != 1) - { - Fail("ERROR: Expected sscanf_s to return 1, got %d.\n" - "Using \"%s\" in \"%s\".\n", ret, inputstr, formatstr); - } - - if (val != checkval) - { - Fail("ERROR: scanned float incorrectly from \"%s\" using \"%s\".\n" - "Expected \"%f\", got \"%f\".\n", inputstr, formatstr, checkval, - val); - } - - if (buf[4] != (char)-1) - { - Fail("ERROR: overflow occurred in scanning float from \"%s\" " - "using \"%s\".\n", inputstr, formatstr); - - } -} - - -#endif diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/sscanf_s/test1/CMakeLists.txt deleted file mode 100644 index 82a0e703b..000000000 --- a/src/pal/tests/palsuite/c_runtime/sscanf_s/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_sscanf_test1 - ${SOURCES} -) - -add_dependencies(paltest_sscanf_test1 coreclrpal) - -target_link_libraries(paltest_sscanf_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/sscanf_s/test1/test1.cpp deleted file mode 100644 index 61313146e..000000000 --- a/src/pal/tests/palsuite/c_runtime/sscanf_s/test1/test1.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: General test of sscanf_s -** -** -**==========================================================================*/ - - - -#include -#include "../sscanf_s.h" - - -int __cdecl main(int argc, char *argv[]) -{ - int num; - int ret; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - DoVoidTest("foo bar", "foo "); - DoVoidTest("foo bar", "baz"); - DoVoidTest("foo bar", "foo %*s"); - - DoStrTest("foo % bar", "foo %% %s", "bar"); - DoStrTest("foo bar baz", "foo %bar %s", "baz"); - - DoVoidTest("foo bar baz", "foo % bar %s"); - DoVoidTest("foo baz bar", "foo% baz %s"); - - ret = sscanf_s("foo bar baz", "foo bar %n", &num); - if (ret != 0 || num != 8) - { - Fail("ERROR: Got incorrect values in scanning \"%s\" using \"%s\".\n" - "Expected to get a value of %d with return value of %d, " - "got %d with return %d\n", "foo bar baz", "foo bar %n", 8, 0, - num, ret); - - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/sscanf_s/test1/testinfo.dat deleted file mode 100644 index 76f592769..000000000 --- a/src/pal/tests/palsuite/c_runtime/sscanf_s/test1/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = sscanf_s -Name = Positive Test for sscanf_s -TYPE = DEFAULT -EXE1 = test1 -Description -= General test of sscanf_s diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test10/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/sscanf_s/test10/CMakeLists.txt deleted file mode 100644 index c85e1b031..000000000 --- a/src/pal/tests/palsuite/c_runtime/sscanf_s/test10/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test10.cpp -) - -add_executable(paltest_sscanf_test10 - ${SOURCES} -) - -add_dependencies(paltest_sscanf_test10 coreclrpal) - -target_link_libraries(paltest_sscanf_test10 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test10/test10.cpp b/src/pal/tests/palsuite/c_runtime/sscanf_s/test10/test10.cpp deleted file mode 100644 index 0c63c864e..000000000 --- a/src/pal/tests/palsuite/c_runtime/sscanf_s/test10/test10.cpp +++ /dev/null @@ -1,37 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test10.c -** -** Purpose: Tests sscanf_s with wide characters -** -** -**==========================================================================*/ - - - -#include -#include "../sscanf_s.h" - -int __cdecl main(int argc, char *argv[]) -{ - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - DoWCharTest("1234d", "%C", convert("1"), 1); - DoWCharTest("1234d", "%C", convert("1"), 1); - DoWCharTest("abc", "%2C", convert("ab"), 2); - DoWCharTest(" ab", "%C", convert(" "), 1); - DoCharTest("ab", "%hC", "a", 1); - DoWCharTest("ab", "%lC", convert("a"), 1); - DoWCharTest("ab", "%LC", convert("a"), 1); - DoWCharTest("ab", "%I64C", convert("a"), 1); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test10/testinfo.dat b/src/pal/tests/palsuite/c_runtime/sscanf_s/test10/testinfo.dat deleted file mode 100644 index e048e700a..000000000 --- a/src/pal/tests/palsuite/c_runtime/sscanf_s/test10/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = sscanf_s -Name = Positive Test for sscanf_s -TYPE = DEFAULT -EXE1 = test10 -Description -= Tests sscanf_s with wide characters diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test11/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/sscanf_s/test11/CMakeLists.txt deleted file mode 100644 index 2c7f0e29e..000000000 --- a/src/pal/tests/palsuite/c_runtime/sscanf_s/test11/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test11.cpp -) - -add_executable(paltest_sscanf_test11 - ${SOURCES} -) - -add_dependencies(paltest_sscanf_test11 coreclrpal) - -target_link_libraries(paltest_sscanf_test11 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test11/test11.cpp b/src/pal/tests/palsuite/c_runtime/sscanf_s/test11/test11.cpp deleted file mode 100644 index 8279f4b3f..000000000 --- a/src/pal/tests/palsuite/c_runtime/sscanf_s/test11/test11.cpp +++ /dev/null @@ -1,36 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test11.c -** -** Purpose: Tests sscanf_s with strings -** -** -**==========================================================================*/ - - - -#include -#include "../sscanf_s.h" - -int __cdecl main(int argc, char *argv[]) -{ - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - DoStrTest("foo bar", "foo %s", "bar"); - DoStrTest("foo bar", "foo %2s", "ba"); - DoStrTest("foo bar", "foo %hs", "bar"); - DoWStrTest("foo bar", "foo %ls", convert("bar")); - DoStrTest("foo bar", "foo %Ls", "bar"); - DoStrTest("foo bar", "foo %I64s", "bar"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test11/testinfo.dat b/src/pal/tests/palsuite/c_runtime/sscanf_s/test11/testinfo.dat deleted file mode 100644 index 5a906ddf5..000000000 --- a/src/pal/tests/palsuite/c_runtime/sscanf_s/test11/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = sscanf_s -Name = Positive Test for sscanf_s -TYPE = DEFAULT -EXE1 = test11 -Description -= Tests sscanf_s with strings diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test12/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/sscanf_s/test12/CMakeLists.txt deleted file mode 100644 index af2355643..000000000 --- a/src/pal/tests/palsuite/c_runtime/sscanf_s/test12/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test12.cpp -) - -add_executable(paltest_sscanf_test12 - ${SOURCES} -) - -add_dependencies(paltest_sscanf_test12 coreclrpal) - -target_link_libraries(paltest_sscanf_test12 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test12/test12.cpp b/src/pal/tests/palsuite/c_runtime/sscanf_s/test12/test12.cpp deleted file mode 100644 index e59953427..000000000 --- a/src/pal/tests/palsuite/c_runtime/sscanf_s/test12/test12.cpp +++ /dev/null @@ -1,35 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test12.c -** -** Purpose: Tests sscanf_s with wide strings -** -** -**==========================================================================*/ - - - -#include -#include "../sscanf_s.h" - -int __cdecl main(int argc, char *argv[]) -{ - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - DoWStrTest("foo bar", "foo %S", convert("bar")); - DoWStrTest("foo bar", "foo %2S", convert("ba")); - DoStrTest("foo bar", "foo %hS", "bar"); - DoWStrTest("foo bar", "foo %lS", convert("bar")); - DoWStrTest("foo bar", "foo %LS", convert("bar")); - DoWStrTest("foo bar", "foo %I64S", convert("bar")); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test12/testinfo.dat b/src/pal/tests/palsuite/c_runtime/sscanf_s/test12/testinfo.dat deleted file mode 100644 index 569be983c..000000000 --- a/src/pal/tests/palsuite/c_runtime/sscanf_s/test12/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = sscanf_s -Name = Positive Test for sscanf_s -TYPE = DEFAULT -EXE1 = test12 -Description -= Tests sscanf_s with wide strings diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test13/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/sscanf_s/test13/CMakeLists.txt deleted file mode 100644 index 7f9b3a165..000000000 --- a/src/pal/tests/palsuite/c_runtime/sscanf_s/test13/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test13.cpp -) - -add_executable(paltest_sscanf_test13 - ${SOURCES} -) - -add_dependencies(paltest_sscanf_test13 coreclrpal) - -target_link_libraries(paltest_sscanf_test13 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test13/test13.cpp b/src/pal/tests/palsuite/c_runtime/sscanf_s/test13/test13.cpp deleted file mode 100644 index 4fc12bb75..000000000 --- a/src/pal/tests/palsuite/c_runtime/sscanf_s/test13/test13.cpp +++ /dev/null @@ -1,37 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test13.c -** -** Purpose: Tests sscanf_s with floats (decimal notation) -** -** -**==========================================================================*/ - - - -#include -#include "../sscanf_s.h" - -int __cdecl main(int argc, char *argv[]) -{ - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - DoFloatTest("123.0", "%f", 123.0f); - DoFloatTest("123.0", "%2f", 12.0f); - DoFloatTest("10E1", "%f", 100.0f); - DoFloatTest("-12.01e-2", "%f", -0.1201f); - DoFloatTest("+12.01e-2", "%f", 0.1201f); - DoFloatTest("-12.01e+2", "%f", -1201.0f); - DoFloatTest("+12.01e+2", "%f", 1201.0f); - DoFloatTest("1234567890.0123456789f", "%f", 1234567936); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test13/testinfo.dat b/src/pal/tests/palsuite/c_runtime/sscanf_s/test13/testinfo.dat deleted file mode 100644 index 651577bef..000000000 --- a/src/pal/tests/palsuite/c_runtime/sscanf_s/test13/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = sscanf_s -Name = Positive Test for sscanf_s -TYPE = DEFAULT -EXE1 = test13 -Description -= Tests sscanf_s with floats (decimal notation) diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test14/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/sscanf_s/test14/CMakeLists.txt deleted file mode 100644 index c195b12ca..000000000 --- a/src/pal/tests/palsuite/c_runtime/sscanf_s/test14/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test14.cpp -) - -add_executable(paltest_sscanf_test14 - ${SOURCES} -) - -add_dependencies(paltest_sscanf_test14 coreclrpal) - -target_link_libraries(paltest_sscanf_test14 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test14/test14.cpp b/src/pal/tests/palsuite/c_runtime/sscanf_s/test14/test14.cpp deleted file mode 100644 index fc2fa2ee1..000000000 --- a/src/pal/tests/palsuite/c_runtime/sscanf_s/test14/test14.cpp +++ /dev/null @@ -1,36 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test14.c -** -** Purpose: Tests sscanf_s with floats (exponential notation, lowercase) -** -** -**==========================================================================*/ - - - -#include -#include "../sscanf_s.h" - -int __cdecl main(int argc, char *argv[]) -{ - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - DoFloatTest("123.0", "%e", 123.0f); - DoFloatTest("123.0", "%2e", 12.0f); - DoFloatTest("10E1", "%e", 100.0f); - DoFloatTest("-12.01e-2", "%e", -0.1201f); - DoFloatTest("+12.01e-2", "%e", 0.1201f); - DoFloatTest("-12.01e+2", "%e", -1201.0f); - DoFloatTest("+12.01e+2", "%e", 1201.0f); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test14/testinfo.dat b/src/pal/tests/palsuite/c_runtime/sscanf_s/test14/testinfo.dat deleted file mode 100644 index 8e7338fd4..000000000 --- a/src/pal/tests/palsuite/c_runtime/sscanf_s/test14/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = sscanf_s -Name = Positive Test for sscanf_s -TYPE = DEFAULT -EXE1 = test14 -Description -= Tests sscanf_s with floats (exponential notation, lowercase) diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test15/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/sscanf_s/test15/CMakeLists.txt deleted file mode 100644 index 0c8967d82..000000000 --- a/src/pal/tests/palsuite/c_runtime/sscanf_s/test15/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test15.cpp -) - -add_executable(paltest_sscanf_test15 - ${SOURCES} -) - -add_dependencies(paltest_sscanf_test15 coreclrpal) - -target_link_libraries(paltest_sscanf_test15 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test15/test15.cpp b/src/pal/tests/palsuite/c_runtime/sscanf_s/test15/test15.cpp deleted file mode 100644 index 1eff995b8..000000000 --- a/src/pal/tests/palsuite/c_runtime/sscanf_s/test15/test15.cpp +++ /dev/null @@ -1,36 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test15.c -** -** Purpose: Tests sscanf_s with floats (exponential notation, uppercase -** -** -**==========================================================================*/ - - - -#include -#include "../sscanf_s.h" - -int __cdecl main(int argc, char *argv[]) -{ - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - DoFloatTest("123.0", "%E", 123.0f); - DoFloatTest("123.0", "%2E", 12.0f); - DoFloatTest("10E1", "%E", 100.0f); - DoFloatTest("-12.01e-2", "%E", -0.1201f); - DoFloatTest("+12.01e-2", "%E", 0.1201f); - DoFloatTest("-12.01e+2", "%E", -1201.0f); - DoFloatTest("+12.01e+2", "%E", 1201.0f); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test15/testinfo.dat b/src/pal/tests/palsuite/c_runtime/sscanf_s/test15/testinfo.dat deleted file mode 100644 index d713a73d8..000000000 --- a/src/pal/tests/palsuite/c_runtime/sscanf_s/test15/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = sscanf_s -Name = Positive Test for sscanf_s -TYPE = DEFAULT -EXE1 = test15 -Description -= Tests sscanf_s with floats (exponential notation, uppercase) diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test16/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/sscanf_s/test16/CMakeLists.txt deleted file mode 100644 index 10a6cc8a4..000000000 --- a/src/pal/tests/palsuite/c_runtime/sscanf_s/test16/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test16.cpp -) - -add_executable(paltest_sscanf_test16 - ${SOURCES} -) - -add_dependencies(paltest_sscanf_test16 coreclrpal) - -target_link_libraries(paltest_sscanf_test16 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test16/test16.cpp b/src/pal/tests/palsuite/c_runtime/sscanf_s/test16/test16.cpp deleted file mode 100644 index f20276744..000000000 --- a/src/pal/tests/palsuite/c_runtime/sscanf_s/test16/test16.cpp +++ /dev/null @@ -1,37 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test16.c -** -** Purpose:Tests sscanf_s with floats (compact notation, lowercase) -** -** -**==========================================================================*/ - - - -#include -#include "../sscanf_s.h" - -int __cdecl main(int argc, char *argv[]) -{ - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - DoFloatTest("123.0", "%g", 123.0f); - DoFloatTest("123.0", "%2g", 12.0f); - DoFloatTest("10E1", "%g", 100.0f); - DoFloatTest("-12.01e-2", "%g", -0.1201f); - DoFloatTest("+12.01e-2", "%g", 0.1201f); - DoFloatTest("-12.01e+2", "%g", -1201.0f); - DoFloatTest("+12.01e+2", "%g", 1201.0f); - DoFloatTest("1234567890.0123456789g", "%g", 1234567936); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test16/testinfo.dat b/src/pal/tests/palsuite/c_runtime/sscanf_s/test16/testinfo.dat deleted file mode 100644 index 669611945..000000000 --- a/src/pal/tests/palsuite/c_runtime/sscanf_s/test16/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = sscanf_s -Name = Positive Test for sscanf_s -TYPE = DEFAULT -EXE1 = test16 -Description -= Tests sscanf_s with floats (compact notation, lowercase) diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test17/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/sscanf_s/test17/CMakeLists.txt deleted file mode 100644 index 84832a848..000000000 --- a/src/pal/tests/palsuite/c_runtime/sscanf_s/test17/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test17.cpp -) - -add_executable(paltest_sscanf_test17 - ${SOURCES} -) - -add_dependencies(paltest_sscanf_test17 coreclrpal) - -target_link_libraries(paltest_sscanf_test17 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test17/test17.cpp b/src/pal/tests/palsuite/c_runtime/sscanf_s/test17/test17.cpp deleted file mode 100644 index a18c3caff..000000000 --- a/src/pal/tests/palsuite/c_runtime/sscanf_s/test17/test17.cpp +++ /dev/null @@ -1,37 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test17.c -** -** Purpose: Tests sscanf_s with floats (compact notation, uppercase) -** -** -**==========================================================================*/ - - - -#include -#include "../sscanf_s.h" - -int __cdecl main(int argc, char *argv[]) -{ - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - DoFloatTest("123.0", "%G", 123.0f); - DoFloatTest("123.0", "%2G", 12.0f); - DoFloatTest("10E1", "%G", 100.0f); - DoFloatTest("-12.01e-2", "%G", -0.1201f); - DoFloatTest("+12.01e-2", "%G", 0.1201f); - DoFloatTest("-12.01e+2", "%G", -1201.0f); - DoFloatTest("+12.01e+2", "%G", 1201.0f); - DoFloatTest("1234567890.0123456789G", "%G", 1234567936); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test17/testinfo.dat b/src/pal/tests/palsuite/c_runtime/sscanf_s/test17/testinfo.dat deleted file mode 100644 index 8ce4e93e1..000000000 --- a/src/pal/tests/palsuite/c_runtime/sscanf_s/test17/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = sscanf_s -Name = Positive Test for sscanf_s -TYPE = DEFAULT -EXE1 = test17 -Description -= Tests sscanf_s with floats (compact notation, uppercase) diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test2/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/sscanf_s/test2/CMakeLists.txt deleted file mode 100644 index a79492bf4..000000000 --- a/src/pal/tests/palsuite/c_runtime/sscanf_s/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test2.cpp -) - -add_executable(paltest_sscanf_test2 - ${SOURCES} -) - -add_dependencies(paltest_sscanf_test2 coreclrpal) - -target_link_libraries(paltest_sscanf_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test2/test2.cpp b/src/pal/tests/palsuite/c_runtime/sscanf_s/test2/test2.cpp deleted file mode 100644 index c9c79f67e..000000000 --- a/src/pal/tests/palsuite/c_runtime/sscanf_s/test2/test2.cpp +++ /dev/null @@ -1,44 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test2.c -** -** Purpose: Test to see if sscanf_s handles whitespace correctly -** -** -**==========================================================================*/ - - - -#include -#include "../sscanf_s.h" - - -/* - * Tests out how it handles whitespace. Seems to accept anything that qualifies - * as isspace (space, tab, vertical tab, line feed, carriage return and form - * feed), even if it says it only wants spaces tabs and newlines. - */ - -int __cdecl main(int argc, char *argv[]) -{ - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - DoStrTest("foo bar", "foo %s", "bar"); - DoStrTest("foo\tbar", "foo %s", "bar"); - DoStrTest("foo\nbar", "foo %s", "bar"); - DoStrTest("foo\rbar", "foo %s", "bar"); - DoStrTest("foo\vbar", "foo %s", "bar"); - DoStrTest("foo\fbar", "foo %s", "bar"); - DoStrTest("foo \t\n\r\v\fbar", "foo %s", "bar"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test2/testinfo.dat b/src/pal/tests/palsuite/c_runtime/sscanf_s/test2/testinfo.dat deleted file mode 100644 index 85fed244f..000000000 --- a/src/pal/tests/palsuite/c_runtime/sscanf_s/test2/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = sscanf_s -Name = Positive Test for sscanf_s -TYPE = DEFAULT -EXE1 = test2 -Description -= Test to see if sscanf_s handles whitespace correctly diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test3/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/sscanf_s/test3/CMakeLists.txt deleted file mode 100644 index ba1a5286a..000000000 --- a/src/pal/tests/palsuite/c_runtime/sscanf_s/test3/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test3.cpp -) - -add_executable(paltest_sscanf_test3 - ${SOURCES} -) - -add_dependencies(paltest_sscanf_test3 coreclrpal) - -target_link_libraries(paltest_sscanf_test3 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test3/test3.cpp b/src/pal/tests/palsuite/c_runtime/sscanf_s/test3/test3.cpp deleted file mode 100644 index e1e45bdd7..000000000 --- a/src/pal/tests/palsuite/c_runtime/sscanf_s/test3/test3.cpp +++ /dev/null @@ -1,35 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test3.c -** -** Purpose: Tests sscanf_s with bracketed set strings -** -** -**==========================================================================*/ - - - -#include -#include "../sscanf_s.h" - -int __cdecl main(int argc, char *argv[]) -{ - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - DoStrTest("bar1", "%[a-z]", "bar"); - DoStrTest("bar1", "%[z-a]", "bar"); - DoStrTest("bar1", "%[ab]", "ba"); - DoStrTest("bar1", "%[ar1b]", "bar1"); - DoStrTest("bar1", "%[^4]", "bar1"); - DoStrTest("bar1", "%[^4a]", "b"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test3/testinfo.dat b/src/pal/tests/palsuite/c_runtime/sscanf_s/test3/testinfo.dat deleted file mode 100644 index 523d31e82..000000000 --- a/src/pal/tests/palsuite/c_runtime/sscanf_s/test3/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = sscanf_s -Name = Positive Test for sscanf_s -TYPE = DEFAULT -EXE1 = test3 -Description -= Tests sscanf_s with bracketed set strings diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test4/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/sscanf_s/test4/CMakeLists.txt deleted file mode 100644 index 456fce018..000000000 --- a/src/pal/tests/palsuite/c_runtime/sscanf_s/test4/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test4.cpp -) - -add_executable(paltest_sscanf_test4 - ${SOURCES} -) - -add_dependencies(paltest_sscanf_test4 coreclrpal) - -target_link_libraries(paltest_sscanf_test4 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test4/test4.cpp b/src/pal/tests/palsuite/c_runtime/sscanf_s/test4/test4.cpp deleted file mode 100644 index f8413ea7f..000000000 --- a/src/pal/tests/palsuite/c_runtime/sscanf_s/test4/test4.cpp +++ /dev/null @@ -1,44 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test4.c -** -** Purpose: Tests sscanf_s with decimal numbers -** -** -**==========================================================================*/ - - - -#include -#include "../sscanf_s.h" - - -int __cdecl main(int argc, char *argv[]) -{ - int n65535 = 65535; /* Walkaround compiler strictness */ - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - DoNumTest("1234d", "%d", 1234); - DoNumTest("1234d", "%2d", 12); - DoNumTest("-1", "%d", -1); - DoNumTest("0x1234", "%d", 0); - DoNumTest("012", "%d", 12); - DoShortNumTest("-1", "%hd", n65535); - DoShortNumTest("65536", "%hd", 0); - DoNumTest("-1", "%ld", -1); - DoNumTest("65536", "%ld", 65536); - DoNumTest("-1", "%Ld", -1); - DoNumTest("65536", "%Ld", 65536); - DoI64NumTest("4294967296", "%I64d", I64(4294967296)); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test4/testinfo.dat b/src/pal/tests/palsuite/c_runtime/sscanf_s/test4/testinfo.dat deleted file mode 100644 index 2065f2bea..000000000 --- a/src/pal/tests/palsuite/c_runtime/sscanf_s/test4/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = sscanf_s -Name = Positive Test for sscanf_s -TYPE = DEFAULT -EXE1 = test4 -Description -= Tests sscanf_s with decimal numbers diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test5/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/sscanf_s/test5/CMakeLists.txt deleted file mode 100644 index b4075037a..000000000 --- a/src/pal/tests/palsuite/c_runtime/sscanf_s/test5/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test5.cpp -) - -add_executable(paltest_sscanf_test5 - ${SOURCES} -) - -add_dependencies(paltest_sscanf_test5 coreclrpal) - -target_link_libraries(paltest_sscanf_test5 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test5/test5.cpp b/src/pal/tests/palsuite/c_runtime/sscanf_s/test5/test5.cpp deleted file mode 100644 index cdfefd860..000000000 --- a/src/pal/tests/palsuite/c_runtime/sscanf_s/test5/test5.cpp +++ /dev/null @@ -1,43 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test5.c -** -** Purpose: Tests sscanf_s with integer numbers -** -** -**==========================================================================*/ - - - -#include -#include "../sscanf_s.h" - -int __cdecl main(int argc, char *argv[]) -{ - int n65535 = 65535; /* Walkaround compiler strictness */ - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - DoNumTest("1234d", "%i", 1234); - DoNumTest("1234d", "%2i", 12); - DoNumTest("-1", "%i", -1); - DoNumTest("0x1234", "%i", 0x1234); - DoNumTest("012", "%i", 10); - DoShortNumTest("-1", "%hi", n65535); - DoShortNumTest("65536", "%hi", 0); - DoNumTest("-1", "%li", -1); - DoNumTest("65536", "%li", 65536); - DoNumTest("-1", "%Li", -1); - DoNumTest("65536", "%Li", 65536); - DoI64NumTest("4294967296", "%I64i", I64(4294967296)); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test5/testinfo.dat b/src/pal/tests/palsuite/c_runtime/sscanf_s/test5/testinfo.dat deleted file mode 100644 index cb687c15c..000000000 --- a/src/pal/tests/palsuite/c_runtime/sscanf_s/test5/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = sscanf_s -Name = Positive Test for sscanf_s -TYPE = DEFAULT -EXE1 = test5 -Description -= Tests sscanf_s with integer numbers diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test6/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/sscanf_s/test6/CMakeLists.txt deleted file mode 100644 index f9815123d..000000000 --- a/src/pal/tests/palsuite/c_runtime/sscanf_s/test6/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test6.cpp -) - -add_executable(paltest_sscanf_test6 - ${SOURCES} -) - -add_dependencies(paltest_sscanf_test6 coreclrpal) - -target_link_libraries(paltest_sscanf_test6 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test6/test6.cpp b/src/pal/tests/palsuite/c_runtime/sscanf_s/test6/test6.cpp deleted file mode 100644 index 507b100e1..000000000 --- a/src/pal/tests/palsuite/c_runtime/sscanf_s/test6/test6.cpp +++ /dev/null @@ -1,43 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test6.c -** -** Purpose: Tests sscanf_s with octal numbers -** -** -**==========================================================================*/ - - - -#include -#include "../sscanf_s.h" - -int __cdecl main(int argc, char *argv[]) -{ - int n65535 = 65535; /* Walkaround compiler strictness */ - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - DoNumTest("1234d", "%o", 668); - DoNumTest("1234d", "%2o", 10); - DoNumTest("-1", "%o", -1); - DoNumTest("0x1234", "%o", 0); - DoNumTest("012", "%o", 10); - DoShortNumTest("-1", "%ho", n65535); - DoShortNumTest("200000", "%ho", 0); - DoNumTest("-1", "%lo", -1); - DoNumTest("200000", "%lo", 65536); - DoNumTest("-1", "%Lo", -1); - DoNumTest("200000", "%Lo", 65536); - DoI64NumTest("40000000000", "%I64o", I64(4294967296)); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test6/testinfo.dat b/src/pal/tests/palsuite/c_runtime/sscanf_s/test6/testinfo.dat deleted file mode 100644 index 9e518dddf..000000000 --- a/src/pal/tests/palsuite/c_runtime/sscanf_s/test6/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = sscanf_s -Name = Positive Test for sscanf_s -TYPE = DEFAULT -EXE1 = test6 -Description -= Tests sscanf_s with octal numbers diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test7/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/sscanf_s/test7/CMakeLists.txt deleted file mode 100644 index ba2913626..000000000 --- a/src/pal/tests/palsuite/c_runtime/sscanf_s/test7/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test7.cpp -) - -add_executable(paltest_sscanf_test7 - ${SOURCES} -) - -add_dependencies(paltest_sscanf_test7 coreclrpal) - -target_link_libraries(paltest_sscanf_test7 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test7/test7.cpp b/src/pal/tests/palsuite/c_runtime/sscanf_s/test7/test7.cpp deleted file mode 100644 index 4093e009e..000000000 --- a/src/pal/tests/palsuite/c_runtime/sscanf_s/test7/test7.cpp +++ /dev/null @@ -1,43 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test7.c -** -** Purpose: Tests sscanf_s with hex numbers (lowercase) -** -** -**==========================================================================*/ - - - -#include -#include "../sscanf_s.h" - -int __cdecl main(int argc, char *argv[]) -{ - int n65535 = 65535; /* Walkaround compiler strictness */ - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - DoNumTest("1234i", "%x", 0x1234); - DoNumTest("1234i", "%2x", 0x12); - DoNumTest("-1", "%x", -1); - DoNumTest("0x1234", "%x", 0x1234); - DoNumTest("012", "%x", 0x12); - DoShortNumTest("-1", "%hx", n65535); - DoShortNumTest("10000", "%hx", 0); - DoNumTest("-1", "%lx", -1); - DoNumTest("10000", "%lx", 65536); - DoNumTest("-1", "%Lx", -1); - DoNumTest("10000", "%Lx", 65536); - DoI64NumTest("100000000", "%I64x", I64(4294967296)); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test7/testinfo.dat b/src/pal/tests/palsuite/c_runtime/sscanf_s/test7/testinfo.dat deleted file mode 100644 index 8d6c182c9..000000000 --- a/src/pal/tests/palsuite/c_runtime/sscanf_s/test7/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = sscanf_s -Name = Positive Test for sscanf_s -TYPE = DEFAULT -EXE1 = test7 -Description -= Tests sscanf_s with hex numbers (lowercase) diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test8/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/sscanf_s/test8/CMakeLists.txt deleted file mode 100644 index 2437679c0..000000000 --- a/src/pal/tests/palsuite/c_runtime/sscanf_s/test8/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test8.cpp -) - -add_executable(paltest_sscanf_test8 - ${SOURCES} -) - -add_dependencies(paltest_sscanf_test8 coreclrpal) - -target_link_libraries(paltest_sscanf_test8 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test8/test8.cpp b/src/pal/tests/palsuite/c_runtime/sscanf_s/test8/test8.cpp deleted file mode 100644 index 23ef22a56..000000000 --- a/src/pal/tests/palsuite/c_runtime/sscanf_s/test8/test8.cpp +++ /dev/null @@ -1,43 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test8.c -** -** Purpose:Tests sscanf_s with unsigned number -** -** -**==========================================================================*/ - - - -#include -#include "../sscanf_s.h" - -int __cdecl main(int argc, char *argv[]) -{ - int n65535 = 65535; /* Walkaround compiler strictness */ - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - DoNumTest("1234d", "%u", 1234); - DoNumTest("1234d", "%2u", 12); - DoNumTest("-1", "%u", -1); - DoNumTest("0x1234", "%u", 0); - DoNumTest("012", "%u", 12); - DoShortNumTest("-1", "%hu", n65535); - DoShortNumTest("65536", "%hu", 0); - DoNumTest("-1", "%lu", -1); - DoNumTest("65536", "%lu", 65536); - DoNumTest("-1", "%Lu", -1); - DoNumTest("65536", "%Lu", 65536); - DoI64NumTest("4294967296", "%I64u", I64(4294967296)); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test8/testinfo.dat b/src/pal/tests/palsuite/c_runtime/sscanf_s/test8/testinfo.dat deleted file mode 100644 index 0287a495d..000000000 --- a/src/pal/tests/palsuite/c_runtime/sscanf_s/test8/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = sscanf_s -Name = Positive Test for sscanf_s -TYPE = DEFAULT -EXE1 = test8 -Description -= Tests sscanf_s with unsigned numbers diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test9/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/sscanf_s/test9/CMakeLists.txt deleted file mode 100644 index a3df87279..000000000 --- a/src/pal/tests/palsuite/c_runtime/sscanf_s/test9/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test9.cpp -) - -add_executable(paltest_sscanf_test9 - ${SOURCES} -) - -add_dependencies(paltest_sscanf_test9 coreclrpal) - -target_link_libraries(paltest_sscanf_test9 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test9/test9.cpp b/src/pal/tests/palsuite/c_runtime/sscanf_s/test9/test9.cpp deleted file mode 100644 index 2c99c40e5..000000000 --- a/src/pal/tests/palsuite/c_runtime/sscanf_s/test9/test9.cpp +++ /dev/null @@ -1,38 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test9.c -** -** Purpose: Tests sscanf_s with characters -** -** -**==========================================================================*/ - - - -#include -#include "../sscanf_s.h" - - -int __cdecl main(int argc, char *argv[]) -{ - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - DoCharTest("1234d", "%c", "1", 1); - DoCharTest("1234d", "%c", "1", 1); - DoCharTest("abc", "%2c", "ab", 2); - DoCharTest(" ab", "%c", " ", 1); - DoCharTest("ab", "%hc", "a", 1); - DoWCharTest("ab", "%lc", convert("a"), 1); - DoCharTest("ab", "%Lc", "a", 1); - DoCharTest("ab", "%I64c", "a", 1); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/sscanf_s/test9/testinfo.dat b/src/pal/tests/palsuite/c_runtime/sscanf_s/test9/testinfo.dat deleted file mode 100644 index 95f6c74ee..000000000 --- a/src/pal/tests/palsuite/c_runtime/sscanf_s/test9/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section =C Runtime -Function = sscanf_s -Name = Positive Test for sscanf_s -TYPE = DEFAULT -EXE1 = test9 -Description -= Tests sscanf_s with characters diff --git a/src/pal/tests/palsuite/c_runtime/strcat/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/strcat/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/c_runtime/strcat/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/c_runtime/strcat/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/strcat/test1/CMakeLists.txt deleted file mode 100644 index 29d25f10e..000000000 --- a/src/pal/tests/palsuite/c_runtime/strcat/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_strcat_test1 - ${SOURCES} -) - -add_dependencies(paltest_strcat_test1 coreclrpal) - -target_link_libraries(paltest_strcat_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/strcat/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/strcat/test1/test1.cpp deleted file mode 100644 index 532d84621..000000000 --- a/src/pal/tests/palsuite/c_runtime/strcat/test1/test1.cpp +++ /dev/null @@ -1,66 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: -** Concatenate three strings into one string. Each time, check to ensure -** the pointer returned was what we expected. When finished, compare the -** newly formed string to what it should be to ensure no characters were -** lost. -** -** -**==========================================================================*/ - -#include - - -int __cdecl main(int argc, char *argv[]) -{ - char dest[80]; - char *test = "foo bar baz"; - char *str1 = "foo "; - char *str2 = "bar "; - char *str3 = "baz"; - char *ptr; - - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - dest[0] = 0; - - ptr = strcat(dest, str1); - if (ptr != dest) - { - Fail("ERROR: Expected strcat to return ptr to %p, got %p", dest, ptr); - } - - ptr = strcat(dest, str2); - if (ptr != dest) - { - Fail("ERROR: Expected strcat to return ptr to %p, got %p", dest, ptr); - } - - ptr = strcat(dest, str3); - if (ptr != dest) - { - Fail("ERROR: Expected strcat to return ptr to %p, got %p", dest, ptr); - } - - if (strcmp(dest, test) != 0) - { - Fail("ERROR: Expected strcat to give \"%s\", got \"%s\"\n", - test, dest); - } - - PAL_Terminate(); - - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/strcat/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/strcat/test1/testinfo.dat deleted file mode 100644 index 6d67ffa18..000000000 --- a/src/pal/tests/palsuite/c_runtime/strcat/test1/testinfo.dat +++ /dev/null @@ -1,15 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = strcat -Name = Test #1 for strcat -TYPE = DEFAULT -EXE1 = test1 -Description -= Concatenate three strings into one string. Each time, check to ensure -= the pointer returned was what we expected. When finished, compare the -= newly formed string to what it should be to ensure no characters were -= lost. diff --git a/src/pal/tests/palsuite/c_runtime/strchr/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/strchr/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/c_runtime/strchr/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/c_runtime/strchr/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/strchr/test1/CMakeLists.txt deleted file mode 100644 index 507d2e040..000000000 --- a/src/pal/tests/palsuite/c_runtime/strchr/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_strchr_test1 - ${SOURCES} -) - -add_dependencies(paltest_strchr_test1 coreclrpal) - -target_link_libraries(paltest_strchr_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/strchr/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/strchr/test1/test1.cpp deleted file mode 100644 index 9190c4f7c..000000000 --- a/src/pal/tests/palsuite/c_runtime/strchr/test1/test1.cpp +++ /dev/null @@ -1,86 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: -** Test this on a character which is in a string, and ensure the pointer -** points to that character. Then check the string for the null character, -** which the return pointer should point to. Then search for a character not -** in the string and check that the return value is NULL. -** -** -**==========================================================================*/ - -#include - -struct testCase -{ - int result; - char string[50]; - int character; -}; - - - -int __cdecl main(int argc, char *argv[]) -{ - int i = 0; - char *result; - - /* - * this structure includes several strings to be tested with - * strchr function and the expected results - */ - - struct testCase testCases[]= - { - {22,"corn cup cat cream coast",'s'}, - {10,"corn cup cat cream coast",'a'}, - {2,"This is a test",'i'}, - {10,"This is a test",'t'}, - {'\0',"This is a test",'b'},/* zero used instead of NULL */ - {'\0',"This is a test",121},/* zero used instead of NULL */ - {4,"This is a test of the function",' '}, - {25,"This is a test of the function",'c'}, - {'\0',"This is a test of the function",'C'}, - {24,"corn cup cat cream coast", '\0'}/* zero used instead of NULL */ - }; - - if (0 != PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - /* Loop through the structure and test each case */ - - for (i=0; i< sizeof(testCases)/sizeof(struct testCase); i++) - { - result = strchr(testCases[i].string,testCases[i].character); - if (result==NULL) - { - if (testCases[i].result != (int) NULL) - { - Fail("Expected strchr() to return \"%s\" instead of NULL!\n", - testCases[i].string + testCases[i].result); - } - } - else - { - if (result != testCases[i].string + testCases[i].result) - { - Fail("Expected strchr() to return \"%s\" instead of \"%s\"!\n", - testCases[i].string + testCases[i].result, result); - } - } - - } - - PAL_Terminate(); - - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/strchr/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/strchr/test1/testinfo.dat deleted file mode 100644 index 4985c4754..000000000 --- a/src/pal/tests/palsuite/c_runtime/strchr/test1/testinfo.dat +++ /dev/null @@ -1,15 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = strchr -Name = Test #1 for strchr -TYPE = DEFAULT -EXE1 = test1 -Description -= Test this on a character which is in a string, and ensure the pointer -= points to that character. Then check the string for the null character, -= which the return pointer should point to. Then search for a character not -= in the string and check that the return value is NULL. diff --git a/src/pal/tests/palsuite/c_runtime/strcmp/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/strcmp/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/c_runtime/strcmp/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/c_runtime/strcmp/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/strcmp/test1/CMakeLists.txt deleted file mode 100644 index 6a0e9f13f..000000000 --- a/src/pal/tests/palsuite/c_runtime/strcmp/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_strcmp_test1 - ${SOURCES} -) - -add_dependencies(paltest_strcmp_test1 coreclrpal) - -target_link_libraries(paltest_strcmp_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/strcmp/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/strcmp/test1/test1.cpp deleted file mode 100644 index 49428fd62..000000000 --- a/src/pal/tests/palsuite/c_runtime/strcmp/test1/test1.cpp +++ /dev/null @@ -1,73 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: -** Compare a number of different strings against each other, ensure that the -** three return values are given at the appropriate times. -** -** -**==========================================================================*/ - -#include - -typedef struct -{ - int result; - char string1[50]; - char string2[50]; -} testCase; - -testCase testCases[]= -{ - {0,"Hello","Hello"}, - {1,"hello","Hello"}, - {-1,"Hello","hello"}, - {0,"0Test","0Test"}, - {0,"***???","***???"}, - {0,"Testing the string for string comparison","Testing the string for " - "string comparison"}, - {-1,"Testing the string for string comparison","Testing the string for " - "string comparsioa"}, - {1,"Testing the string for string comparison","Testing the string for " - "comparison"}, - {-1,"aaaabbbbb","aabcdefeccg"} -}; - -int __cdecl main(int argc, char *argv[]) -{ - int i = 0; - int result = 0; - - /* - * Initialize the PAL - */ - if (0 != PAL_Initialize(argc, argv)) - { - return FAIL; - } - - /* Loop through structure and test each case */ - for (i=0; i < sizeof(testCases)/sizeof(testCase); i++) - { - result = strcmp(testCases[i].string1,testCases[i].string2); - - /* Compare returned value */ - if( ((result == 0) && (testCases[i].result !=0)) || - ((result <0) && (testCases[i].result !=-1)) || - ((result >0) && (testCases[i].result !=1)) ) - { - Fail("ERROR: strcmp returned %d instead of %d\n", - result, testCases[i].result); - } - - } - - PAL_Terminate(); - - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/strcmp/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/strcmp/test1/testinfo.dat deleted file mode 100644 index 174cb4be8..000000000 --- a/src/pal/tests/palsuite/c_runtime/strcmp/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = strcmp -Name = Test #1 for strcmp -TYPE = DEFAULT -EXE1 = test1 -Description -= Compare a number of different strings against each other, ensure that the -= three return values are given at the appropriate times. diff --git a/src/pal/tests/palsuite/c_runtime/strcpy/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/strcpy/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/c_runtime/strcpy/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/c_runtime/strcpy/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/strcpy/test1/CMakeLists.txt deleted file mode 100644 index cecb08603..000000000 --- a/src/pal/tests/palsuite/c_runtime/strcpy/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_strcpy_test1 - ${SOURCES} -) - -add_dependencies(paltest_strcpy_test1 coreclrpal) - -target_link_libraries(paltest_strcpy_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/strcpy/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/strcpy/test1/test1.cpp deleted file mode 100644 index 43069e59a..000000000 --- a/src/pal/tests/palsuite/c_runtime/strcpy/test1/test1.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: -** Call the function to copy into an empty buffer. Check that the return value -** is pointing at the destination buffer. Also compare the string copied to -** the origional string, to ensure they are the same. -** -** -**==========================================================================*/ - -#include - - -int __cdecl main(int argc, char *argv[]) -{ - char dest[80]; - char *result = "foo"; - char str[] = {'f','o','o',0,'b','a','r',0}; - char *ret; - - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - ret = strcpy(dest, str); - - if (ret != dest) - { - Fail("Expected strcpy to return %p, got %p!\n", dest, ret); - - } - - if (strcmp(dest, result) != 0) - { - Fail("Expected strcpy to give \"%s\", got \"%s\"!\n", result, dest); - } - - - PAL_Terminate(); - - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/strcpy/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/strcpy/test1/testinfo.dat deleted file mode 100644 index 700b12492..000000000 --- a/src/pal/tests/palsuite/c_runtime/strcpy/test1/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = strcpy -Name = Test #1 for strcpy -TYPE = DEFAULT -EXE1 = test1 -Description -= Call the function to copy into an empty buffer. Check that the return value -= is pointing at the destination buffer. Also compare the string copied to -= the origional string, to ensure they are the same. diff --git a/src/pal/tests/palsuite/c_runtime/strcspn/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/strcspn/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/c_runtime/strcspn/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/c_runtime/strcspn/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/strcspn/test1/CMakeLists.txt deleted file mode 100644 index 4b1ea6789..000000000 --- a/src/pal/tests/palsuite/c_runtime/strcspn/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_strcspn_test1 - ${SOURCES} -) - -add_dependencies(paltest_strcspn_test1 coreclrpal) - -target_link_libraries(paltest_strcspn_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/strcspn/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/strcspn/test1/test1.cpp deleted file mode 100644 index ddc566757..000000000 --- a/src/pal/tests/palsuite/c_runtime/strcspn/test1/test1.cpp +++ /dev/null @@ -1,59 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: Tests strcspn with a character set that should give an index into -** the middle of the original string. Also tests with character sets -** that are not in the string at all, and character sets that match -** with the very first character. -** -** -**==========================================================================*/ - -#include - -struct testCase -{ - long result; - char *string1; - char *string2; -}; - -int __cdecl main(int argc, char *argv[]) -{ - int i=0; - long TheResult = 0; - - struct testCase testCases[]= - { - {4,"abcdefg12345678hijklmnopqrst","t8m1sBe"}, - {23,"This is a test, testing", "X\tylM"}, - {0,"foobar","tzkfb"}, - }; - - /* - * Initialize the PAL - */ - if (0 != PAL_Initialize(argc, argv)) - { - return FAIL; - } - - for (i=0; i - -int __cdecl main(int argc, char *argv[]) -{ - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - if (strlen("foo") != 3) - Fail("ERROR: strlen(\"foo\") != 3\n"); - - if (strlen("") != 0) - Fail("ERROR: strlen(\"\") != 0\n"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/strlen/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/strlen/test1/testinfo.dat deleted file mode 100644 index ac5c3aec0..000000000 --- a/src/pal/tests/palsuite/c_runtime/strlen/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = strlen -Name = Positive Test for strlen -TYPE = DEFAULT -EXE1 = test1 -Description -= Check the length of a string and the length of a 0 character string to -= see that this function returns the correct values for each. diff --git a/src/pal/tests/palsuite/c_runtime/strncat/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/strncat/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/c_runtime/strncat/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/c_runtime/strncat/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/strncat/test1/CMakeLists.txt deleted file mode 100644 index bf2363387..000000000 --- a/src/pal/tests/palsuite/c_runtime/strncat/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_strncat_test1 - ${SOURCES} -) - -add_dependencies(paltest_strncat_test1 coreclrpal) - -target_link_libraries(paltest_strncat_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/strncat/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/strncat/test1/test1.cpp deleted file mode 100644 index 000d1685b..000000000 --- a/src/pal/tests/palsuite/c_runtime/strncat/test1/test1.cpp +++ /dev/null @@ -1,77 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: -** Concatenate a few strings together, setting different lengths to be -** used for each one. Check to ensure the pointers which are returned are -** correct, and that the final string is what was expected. -** -** -**==========================================================================*/ - -#include - - -int __cdecl main(int argc, char *argv[]) -{ - char dest[80]; - char *test = "foo barbaz"; - char *str1 = "foo "; - char *str2 = "bar "; - char *str3 = "baz"; - char *ptr; - int i; - - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - dest[0] = 0; - for (i=1; i<80; i++) - { - dest[i] = 'x'; - } - - ptr = strncat(dest, str1, strlen(str1)); - if (ptr != dest) - { - Fail("ERROR: Expected strncat to return ptr to %p, got %p", dest, ptr); - } - - ptr = strncat(dest, str2, 3); - if (ptr != dest) - { - Fail("ERROR: Expected strncat to return ptr to %p, got %p", dest, ptr); - } - if (dest[7] != 0) - { - Fail("ERROR: strncat did not place a terminating NULL!"); - } - - ptr = strncat(dest, str3, 20); - if (ptr != dest) - { - Fail("ERROR: Expected strncat to return ptr to %p, got %p", dest, ptr); - } - if (strcmp(dest, test) != 0) - { - Fail("ERROR: Expected strncat to give \"%s\", got \"%s\"\n", - test, dest); - } - if (dest[strlen(test)+1] != 'x') - { - Fail("strncat went out of bounds!\n"); - } - - PAL_Terminate(); - - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/strncat/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/strncat/test1/testinfo.dat deleted file mode 100644 index 4aaedbf40..000000000 --- a/src/pal/tests/palsuite/c_runtime/strncat/test1/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = strncat -Name = Test #1 for strncat -TYPE = DEFAULT -EXE1 = test1 -Description -= Concatenate a few strings together, setting different lengths to be -= used for each one. Check to ensure the pointers which are returned are -= correct, and that the final string is what was expected. diff --git a/src/pal/tests/palsuite/c_runtime/strncmp/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/strncmp/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/c_runtime/strncmp/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/c_runtime/strncmp/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/strncmp/test1/CMakeLists.txt deleted file mode 100644 index b76ff5eea..000000000 --- a/src/pal/tests/palsuite/c_runtime/strncmp/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_strncmp_test1 - ${SOURCES} -) - -add_dependencies(paltest_strncmp_test1 coreclrpal) - -target_link_libraries(paltest_strncmp_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/strncmp/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/strncmp/test1/test1.cpp deleted file mode 100644 index 7326c3b61..000000000 --- a/src/pal/tests/palsuite/c_runtime/strncmp/test1/test1.cpp +++ /dev/null @@ -1,80 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: -** Test to ensure all three possible return values are given under the -** appropriate circumstance. Also, uses different sizes, to only compare -** portions of strings, checking to make sure these return the correct value. -** -** -**==========================================================================*/ - -#include - -typedef struct -{ - int result; - char string1[50]; - char string2[50]; - int number; -} testCase; - -testCase testCases[]= -{ - {0,"Hello","Hello",5}, - {1,"hello","Hello",3}, - {-1,"Hello","hello",5}, - {0,"heLLo","heLLo",5}, - {1,"hello","heLlo",5}, - {-1,"heLlo","hello",5}, - {0,"0Test","0Test",5}, - {0,"***???","***???",6}, - {0,"Testing the string for string comparison","Testing the string for " - "string comparison",40}, - {-1,"Testing the string for string comparison","Testing the string for " - "string comparsioa",40}, - {1,"Testing the string for string comparison","Testing the string for " - "comparison",34}, - {0,"aaaabbbbb","aabcdefeccg",2}, - {0,"abcd","abcd",10} -}; - - -int __cdecl main(int argc, char *argv[]) -{ - int i=0; - int iresult=0; - - /* - * Initialize the PAL - */ - if (0 != PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - for (i=0; i< sizeof(testCases)/sizeof(testCase); i++) - { - iresult = strncmp(testCases[i].string1,testCases[i].string2, - testCases[i].number); - - if( ((iresult == 0) && (testCases[i].result !=0)) || - ((iresult <0) && (testCases[i].result !=-1)) || - ((iresult >0) && (testCases[i].result !=1)) ) - - { - Fail("ERROR: strncmp returned %d instead of %d\n", - iresult, testCases[i].result); - } - - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/strncmp/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/strncmp/test1/testinfo.dat deleted file mode 100644 index 8e95311f3..000000000 --- a/src/pal/tests/palsuite/c_runtime/strncmp/test1/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = strncmp -Name = Test #1 for strncmp -TYPE = DEFAULT -EXE1 = test1 -Description -= Test to ensure all three possible return values are given under the -= appropriate circumstance. Also, uses different sizes, to only compare -= portions of strings, checking to make sure these return the correct value. diff --git a/src/pal/tests/palsuite/c_runtime/strncpy/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/strncpy/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/c_runtime/strncpy/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/c_runtime/strncpy/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/strncpy/test1/CMakeLists.txt deleted file mode 100644 index 9b8ed3ff8..000000000 --- a/src/pal/tests/palsuite/c_runtime/strncpy/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_strncpy_test1 - ${SOURCES} -) - -add_dependencies(paltest_strncpy_test1 coreclrpal) - -target_link_libraries(paltest_strncpy_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/strncpy/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/strncpy/test1/test1.cpp deleted file mode 100644 index 62baf61ba..000000000 --- a/src/pal/tests/palsuite/c_runtime/strncpy/test1/test1.cpp +++ /dev/null @@ -1,85 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: -** Test to see that you can copy a portion of a string into a new buffer. -** Also check that the strncpy function doesn't overflow when it is used. -** Finally check that if the number of characters given is greater than the -** amount to copy, that the destination buffer is padded with NULLs. -** -** -**==========================================================================*/ - -#include - - -int __cdecl main(int argc, char *argv[]) -{ - char dest[80]; - char *result = "foobar"; - char *str = "foobar\0baz"; - char *ret; - int i; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - for (i=0; i<80; i++) - { - dest[i] = 'x'; - } - - ret = strncpy(dest, str, 3); - if (ret != dest) - { - Fail("Expected strncpy to return %p, got %p!\n", dest, ret); - } - - if (strncmp(dest, result, 3) != 0) - { - Fail("Expected strncpy to give \"%s\", got \"%s\"!\n", result, dest); - } - - if (dest[3] != 'x') - { - Fail("strncpy overflowed!\n"); - } - - ret = strncpy(dest, str, 40); - if (ret != dest) - { - Fail("Expected strncpy to return %p, got %p!\n", dest, ret); - } - - if (strcmp(dest, result) != 0) - { - Fail("Expected strncpy to give \"%s\", got \"%s\"!\n", result, dest); - } - - for (i=strlen(str); i<40; i++) - { - if (dest[i] != 0) - { - Fail("strncpy failed to pad the destination with NULLs!\n"); - } - } - - if (dest[40] != 'x') - { - Fail("strncpy overflowed!\n"); - } - - - - PAL_Terminate(); - - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/strncpy/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/strncpy/test1/testinfo.dat deleted file mode 100644 index c402adb1c..000000000 --- a/src/pal/tests/palsuite/c_runtime/strncpy/test1/testinfo.dat +++ /dev/null @@ -1,15 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = strncpy -Name = Test #1 for strncpy -TYPE = DEFAULT -EXE1 = test1 -Description -= Test to see that you can copy a portion of a string into a new buffer. -= Also check that the strncpy function doesn't overflow when it is used. -= Finally check that if the number of characters given is greater than the -= amount to copy, that the destination buffer is padded with NULLs. diff --git a/src/pal/tests/palsuite/c_runtime/strpbrk/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/strpbrk/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/c_runtime/strpbrk/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/c_runtime/strpbrk/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/strpbrk/test1/CMakeLists.txt deleted file mode 100644 index 239b36c94..000000000 --- a/src/pal/tests/palsuite/c_runtime/strpbrk/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_strpbrk_test1 - ${SOURCES} -) - -add_dependencies(paltest_strpbrk_test1 coreclrpal) - -target_link_libraries(paltest_strpbrk_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/strpbrk/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/strpbrk/test1/test1.cpp deleted file mode 100644 index a42b80f31..000000000 --- a/src/pal/tests/palsuite/c_runtime/strpbrk/test1/test1.cpp +++ /dev/null @@ -1,85 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: -** Search a string for characters in a given character set and ensure the -** pointer returned points to the first occurance. Check to see that the -** function returns NULL if the character is not found. -** -** -**==========================================================================*/ - -#include - -struct testCase -{ - char *result; - char *string1; - char *string2; -}; - -int __cdecl main(int argc, char *argv[]) -{ - char *ptr = NULL; - int i = 0; - - /* - * this structure includes several strings to be tested with - * strpbk function and the expected results - */ - - struct testCase testCases[] = - { - {"t cream coast","corn cup cat cream coast","sit"}, - {"eam coast","corn cup cat cream coast","like"}, - {"is is a test","This is a test","circle"}, - {"a test","This is a test","way"}, - {NULL,"This is a test","boo"}, - {NULL,"This is a test","123"}, - {" is a test of the function","This is a test of the function", - "zzz xx"} - }; - - - if (0 != PAL_Initialize(argc, argv)) - { - return FAIL; - } - - /* A loop to go through the testcases in the structure */ - - for (i=0; i< sizeof(testCases)/sizeof(struct testCase); i++) - { - ptr = strpbrk(testCases[i].string1,testCases[i].string2); - if (ptr==NULL) - { - if (testCases[i].result != NULL) - { - Fail("Expected strpbrk() to return %s, got NULL!\n", - testCases[i].result); - } - } - else - { - if (strcmp(ptr,testCases[i].result)!=0 ) - - { - Fail("Expected strpbrk() to return %s, got %s!\n", - testCases[i].result,ptr); - } - - } - - } - - - PAL_Terminate(); - - return PASS; -} - diff --git a/src/pal/tests/palsuite/c_runtime/strpbrk/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/strpbrk/test1/testinfo.dat deleted file mode 100644 index 1bef6a7b9..000000000 --- a/src/pal/tests/palsuite/c_runtime/strpbrk/test1/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = strpbrk -Name = Test #1 for strpbrk -TYPE = DEFAULT -EXE1 = test1 -Description -= Search a string for characters in a given character set and ensure the -= pointer returned points to the first occurance. Check to see that the -= function returns NULL if the character is not found. diff --git a/src/pal/tests/palsuite/c_runtime/strrchr/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/strrchr/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/c_runtime/strrchr/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/c_runtime/strrchr/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/strrchr/test1/CMakeLists.txt deleted file mode 100644 index 19bdd4e1d..000000000 --- a/src/pal/tests/palsuite/c_runtime/strrchr/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_strrchr_test1 - ${SOURCES} -) - -add_dependencies(paltest_strrchr_test1 coreclrpal) - -target_link_libraries(paltest_strrchr_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/strrchr/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/strrchr/test1/test1.cpp deleted file mode 100644 index a5c147eec..000000000 --- a/src/pal/tests/palsuite/c_runtime/strrchr/test1/test1.cpp +++ /dev/null @@ -1,55 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: \ -** Search a string for a given character. Search for a character contained -** in the string, and ensure the pointer returned points to it. Then search -** for the null character, and ensure the pointer points to that. Finally -** search for a character which is not in the string and ensure that it -** returns NULL. -** -** -**==========================================================================*/ - -#include - - -int __cdecl main(int argc, char *argv[]) -{ - char *str = "foo bar baz"; - char *ptr; - - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - ptr = strrchr(str, 'b'); - if (ptr != str + 8) - { - Fail("Expected strrchr() to return %p, got %p!\n", str + 8, ptr); - } - - ptr = strrchr(str, 0); - if (ptr != str + 11) - { - Fail("Expected strrchr() to return %p, got %p!\n", str + 11, ptr); - } - - ptr = strrchr(str, 'x'); - if (ptr != NULL) - { - Fail("Expected strrchr() to return NULL, got %p!\n", ptr); - } - - PAL_Terminate(); - - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/strrchr/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/strrchr/test1/testinfo.dat deleted file mode 100644 index 45b27aecf..000000000 --- a/src/pal/tests/palsuite/c_runtime/strrchr/test1/testinfo.dat +++ /dev/null @@ -1,16 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = strrchr -Name = Test #1 for strrchr -TYPE = DEFAULT -EXE1 = test1 -Description -= Search a string for a given character. Search for a character contained -= in the string, and ensure the pointer returned points to it. Then search -= for the null character, and ensure the pointer points to that. Finally -= search for a character which is not in the string and ensure that it -= returns NULL. diff --git a/src/pal/tests/palsuite/c_runtime/strspn/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/strspn/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/c_runtime/strspn/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/c_runtime/strspn/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/strspn/test1/CMakeLists.txt deleted file mode 100644 index 324690034..000000000 --- a/src/pal/tests/palsuite/c_runtime/strspn/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_strspn_test1 - ${SOURCES} -) - -add_dependencies(paltest_strspn_test1 coreclrpal) - -target_link_libraries(paltest_strspn_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/strspn/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/strspn/test1/test1.cpp deleted file mode 100644 index 78d248843..000000000 --- a/src/pal/tests/palsuite/c_runtime/strspn/test1/test1.cpp +++ /dev/null @@ -1,60 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: -** Check a character set against a string to see that the function returns -** the length of the substring which consists of all characters in the string. -** Also check that if the character set doesn't match the string at all, that -** the value is 0. -** -** -**==========================================================================*/ - -#include - -struct testCase -{ - long result; - char *string1; - char *string2; -}; - -int __cdecl main(int argc, char *argv[]) -{ - int i=0; - long TheResult = 0; - - struct testCase testCases[]= - { - {4,"abcdefg12345678hijklmnopqrst","a2bjk341cd"}, - {14,"This is a test, testing", "aeioTts rh"}, - {0,"foobar","kpzt"} - }; - - /* - * Initialize the PAL - */ - if (0 != PAL_Initialize(argc, argv)) - { - return FAIL; - } - - for (i=0; i - - -struct testCase -{ - char *result; - char *string1; - char *string2; - -}; - -int __cdecl main(int argc, char *argv[]) -{ - int i=0; - char *ptr=NULL; - - struct testCase testCases[]= - { - {"is is a test", "This is a test","is"}, - {"fghijkl","abcdefghijkl","fgh"}, - {NULL,"aabbccddeeffgg","h"}, - {NULL,"aabb", "eeeeeee"}, - {"AAA", "BBddfdaaaaAAA","A"}, - {"fdaaaaAAA", "BBddfdaaaaAAA","f"}, - {"aadfsadfas","aadfsadfas",""}, - {NULL,"","ccc"} - }; - - /* - * Initialize the PAL - */ - if (0 != PAL_Initialize(argc, argv)) - { - return FAIL; - } - - for (i=0; i - - -struct testCase -{ - double CorrectResult; /* The returned double value */ - char ResultString[20]; /* The remainder string */ - char string[20]; /* The test string */ -}; - - -int __cdecl main(int argc, char **argv) -{ - - char * endptr; - double result; - int i; - - struct testCase testCases[] = - { - {1234,"","1234"}, - {-1234,"","-1234"}, - {1234.44,"","1234.44"}, - {1234e-5,"","1234e-5"}, - {1234e+5,"","1234e+5"}, - {12345E5,"","12345e5"}, - {1234.657e-8,"","1234.657e-8"}, - {1234567e-8,"foo","1234567e-8foo"}, - {999,"foo","999 foo"}, - {7,"foo"," 7foo"}, - {0,"a7","a7"}, - {-777777,"z zz","-777777z zz"} - }; - - /* - * Initialize the PAL - */ - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - /* Loop through the structure to test each case */ - for(i = 0; i < sizeof(testCases) / sizeof(struct testCase); i++) - { - result = strtod(testCases[i].string,&endptr); - - /* need to check the result and the endptr result */ - if ((testCases[i].CorrectResult != result) && - (strcmp(testCases[i].ResultString,endptr)!=0)) - { - Fail("ERROR: strtod returned %f instead of %f and " - "\"%s\" instead of \"%s\" for the test of \"%s\"\n", - result, - testCases[i].CorrectResult, - endptr, - testCases[i].ResultString, - testCases[i].string); - } - - } - - PAL_Terminate(); - return PASS; -} - - - - - - - - - - - - - diff --git a/src/pal/tests/palsuite/c_runtime/strtod/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/strtod/test1/testinfo.dat deleted file mode 100644 index 2c98d2eaf..000000000 --- a/src/pal/tests/palsuite/c_runtime/strtod/test1/testinfo.dat +++ /dev/null @@ -1,17 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = strtod -Name = Positive Test for strtod -TYPE = DEFAULT -EXE1 = test1 -Description -= Purpose: Tests the PAL implementation of the strtod function. -= Convert a number of strings to doubles. Ensure they convert correctly. - - - - diff --git a/src/pal/tests/palsuite/c_runtime/strtod/test2/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/strtod/test2/CMakeLists.txt deleted file mode 100644 index 581e4de3e..000000000 --- a/src/pal/tests/palsuite/c_runtime/strtod/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test2.cpp -) - -add_executable(paltest_strtod_test2 - ${SOURCES} -) - -add_dependencies(paltest_strtod_test2 coreclrpal) - -target_link_libraries(paltest_strtod_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/strtod/test2/test2.cpp b/src/pal/tests/palsuite/c_runtime/strtod/test2/test2.cpp deleted file mode 100644 index 0eaf4f53b..000000000 --- a/src/pal/tests/palsuite/c_runtime/strtod/test2/test2.cpp +++ /dev/null @@ -1,65 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test2.c -** -** Purpose: Tests strtod with overflows -** -** -**===================================================================*/ - -#include - -int __cdecl main(int argc, char **argv) -{ - /* Representation of positive infinty for a IEEE 64-bit double */ - INT64 PosInifity = (INT64)(0x7ff00000) << 32; - double HugeVal = *(double*) &PosInifity; - char *PosStr = "1E+10000"; - char *NegStr = "-1E+10000"; - double result; - - - if (PAL_Initialize(argc,argv)) - { - return FAIL; - } - - result = strtod(PosStr, NULL); - - if (result != HugeVal) - { - Fail("ERROR: wcstod interpreted \"%s\" as %g instead of %g\n", - PosStr, result, HugeVal); - } - - result = strtod(NegStr, NULL); - - if (result != -HugeVal) - { - Fail("ERROR: wcstod interpreted \"%s\" as %g instead of %g\n", - NegStr, result, -HugeVal); - } - - PAL_Terminate(); - - return PASS; -} - - - - - - - - - - - - - - - diff --git a/src/pal/tests/palsuite/c_runtime/strtod/test2/testinfo.dat b/src/pal/tests/palsuite/c_runtime/strtod/test2/testinfo.dat deleted file mode 100644 index a50c07b8b..000000000 --- a/src/pal/tests/palsuite/c_runtime/strtod/test2/testinfo.dat +++ /dev/null @@ -1,16 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = strtod -Name = Negative test for strtod with overflows -TYPE = DEFAULT -EXE1 = test2 -Description -= Test strtod with overflows. - - - - diff --git a/src/pal/tests/palsuite/c_runtime/strtok/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/strtok/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/c_runtime/strtok/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/c_runtime/strtok/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/strtok/test1/CMakeLists.txt deleted file mode 100644 index 098a6640f..000000000 --- a/src/pal/tests/palsuite/c_runtime/strtok/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_strtok_test1 - ${SOURCES} -) - -add_dependencies(paltest_strtok_test1 coreclrpal) - -target_link_libraries(paltest_strtok_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/strtok/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/strtok/test1/test1.cpp deleted file mode 100644 index f1dec7038..000000000 --- a/src/pal/tests/palsuite/c_runtime/strtok/test1/test1.cpp +++ /dev/null @@ -1,78 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: -** Search for a number of tokens within strings. Check that the return values -** are what is expect, and also that the strings match up with our expected -** results. -** -** -**==========================================================================*/ - -#include - - -int __cdecl main(int argc, char *argv[]) -{ - char str[] = "foo bar baz"; - char *result1= "foo \0ar baz"; - char *result2= "foo \0a\0 baz"; - int len = strlen(str) + 1; - char *ptr; - - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - ptr = strtok(str, "bz"); - if (ptr != str) - { - Fail("Expected strtok() to return %p, got %p!\n", str, ptr); - } - if (memcmp(str, result1, len) != 0) - { - Fail("strtok altered the string in an unexpeced way!\n"); - } - - ptr = strtok(NULL, "r "); - if (ptr != str + 5) - { - Fail("Expected strtok() to return %p, got %p!\n", str+5, ptr); - } - if (memcmp(str, result2, len) != 0) - { - Fail("strtok altered the string in an unexpeced way!\n"); - } - - - ptr = strtok(NULL, "X"); - if (ptr != str + 7) - { - Fail("Expected strtok() to return %p, got %p!\n", str + 7, ptr); - } - if (memcmp(str, result2, len) != 0) - { - Fail("strtok altered the string in an unexpeced way!\n"); - } - - ptr = strtok(NULL, "X"); - if (ptr != NULL) - { - Fail("Expected strtok() to return %p, got %p!\n", NULL, ptr); - } - if (memcmp(str, result2, len) != 0) - { - Fail("strtok altered the string in an unexpeced way!\n"); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/strtok/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/strtok/test1/testinfo.dat deleted file mode 100644 index f3773514c..000000000 --- a/src/pal/tests/palsuite/c_runtime/strtok/test1/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = strtok -Name = Test #1 for strtok -TYPE = DEFAULT -EXE1 = test1 -Description -= Search for a number of tokens within strings. Check that the return values -= are what is expect, and also that the strings match up with our expected -= results. diff --git a/src/pal/tests/palsuite/c_runtime/strtoul/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/strtoul/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/c_runtime/strtoul/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/c_runtime/strtoul/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/strtoul/test1/CMakeLists.txt deleted file mode 100644 index bdf4497ca..000000000 --- a/src/pal/tests/palsuite/c_runtime/strtoul/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_strtoul_test1 - ${SOURCES} -) - -add_dependencies(paltest_strtoul_test1 coreclrpal) - -target_link_libraries(paltest_strtoul_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/strtoul/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/strtoul/test1/test1.cpp deleted file mode 100644 index 344671b5c..000000000 --- a/src/pal/tests/palsuite/c_runtime/strtoul/test1/test1.cpp +++ /dev/null @@ -1,73 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: -** Tests stroul with different bases and overflows, as well as valid input. -** Makes sure that the end pointer is correct. -** -** -**==========================================================================*/ - -#include - -char teststr1[] = "12345"; -char teststr2[] = "Z"; -char teststr3[] = "4294967295"; -char teststr4[] = "4294967296"; - -typedef struct -{ - char *str; - char *end; - int base; - ULONG result; -} TestCase; - -TestCase TestCases[] = -{ - { teststr1, teststr1 + 3, 4, 27}, - { teststr1, teststr1 + 5, 10, 12345}, - { teststr2, teststr2, 10, 0}, - { teststr3, teststr3+10, 10, 4294967295ul}, - { teststr4, teststr4+10, 10, 4294967295ul} -}; - -int NumCases = sizeof(TestCases) / sizeof(TestCases[0]); - - -int __cdecl main(int argc, char *argv[]) -{ - char *end; - ULONG l; - int i; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - for (i=0; i -#include "../swprintf.h" - -/* - * Uses memcmp & wcslen - */ - -int __cdecl main(int argc, char *argv[]) -{ - WCHAR *checkstr; - WCHAR buf[256]; - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - checkstr = convert("hello world"); - swprintf_s(buf, _countof(buf), convert("hello world")); - - if (memcmp(checkstr, buf, wcslen(checkstr)*2+2) != 0) - { - Fail("ERROR: Expected \"%s\", got \"%s\".\n", "hello world", - convertC(buf)); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/swprintf/test1/testinfo.dat deleted file mode 100644 index f43d462da..000000000 --- a/src/pal/tests/palsuite/c_runtime/swprintf/test1/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = swprintf -Name = Positive Test for swprintf -TYPE = DEFAULT -EXE1 = test1 -Description -= General test to see if swprintf works correctly diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test10/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/swprintf/test10/CMakeLists.txt deleted file mode 100644 index 70581d16a..000000000 --- a/src/pal/tests/palsuite/c_runtime/swprintf/test10/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test10.cpp -) - -add_executable(paltest_swprintf_test10 - ${SOURCES} -) - -add_dependencies(paltest_swprintf_test10 coreclrpal) - -target_link_libraries(paltest_swprintf_test10 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test10/test10.cpp b/src/pal/tests/palsuite/c_runtime/swprintf/test10/test10.cpp deleted file mode 100644 index 61aef593a..000000000 --- a/src/pal/tests/palsuite/c_runtime/swprintf/test10/test10.cpp +++ /dev/null @@ -1,55 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test10.c -** -** Purpose:Tests swprintf with octal numbers -** -** -**==========================================================================*/ - - - -#include -#include "../swprintf.h" - -/* - * Uses memcmp & wcslen - */ - -int __cdecl main(int argc, char *argv[]) -{ - int neg = -42; - int pos = 42; - INT64 l = 42; - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - - DoNumTest(convert("foo %o"), pos, convert("foo 52")); - DoNumTest(convert("foo %lo"), 0xFFFF, convert("foo 177777")); - DoNumTest(convert("foo %ho"), 0xFFFF, convert("foo 177777")); - DoNumTest(convert("foo %Lo"), pos, convert("foo 52")); - DoI64Test(convert("foo %I64o"), l, "0x0000000000000042", - convert("foo 52")); - DoNumTest(convert("foo %3o"), pos, convert("foo 52")); - DoNumTest(convert("foo %-3o"), pos, convert("foo 52 ")); - DoNumTest(convert("foo %.1o"), pos, convert("foo 52")); - DoNumTest(convert("foo %.3o"), pos, convert("foo 052")); - DoNumTest(convert("foo %03o"), pos, convert("foo 052")); - DoNumTest(convert("foo %#o"), pos, convert("foo 052")); - DoNumTest(convert("foo %+o"), pos, convert("foo 52")); - DoNumTest(convert("foo % o"), pos, convert("foo 52")); - DoNumTest(convert("foo %+o"), neg, convert("foo 37777777726")); - DoNumTest(convert("foo % o"), neg, convert("foo 37777777726")); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test10/testinfo.dat b/src/pal/tests/palsuite/c_runtime/swprintf/test10/testinfo.dat deleted file mode 100644 index e860bb26e..000000000 --- a/src/pal/tests/palsuite/c_runtime/swprintf/test10/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = swprintf -Name = Positive Test for swprintf -TYPE = DEFAULT -EXE1 = test10 -Description -= Tests swprintf with octal numbers diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test11/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/swprintf/test11/CMakeLists.txt deleted file mode 100644 index 4d5191754..000000000 --- a/src/pal/tests/palsuite/c_runtime/swprintf/test11/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test11.cpp -) - -add_executable(paltest_swprintf_test11 - ${SOURCES} -) - -add_dependencies(paltest_swprintf_test11 coreclrpal) - -target_link_libraries(paltest_swprintf_test11 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test11/test11.cpp b/src/pal/tests/palsuite/c_runtime/swprintf/test11/test11.cpp deleted file mode 100644 index 216f9acdb..000000000 --- a/src/pal/tests/palsuite/c_runtime/swprintf/test11/test11.cpp +++ /dev/null @@ -1,55 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test11.c -** -** Purpose: Tests swprintf with unsigned numbers -** -** -**==========================================================================*/ - - - -#include -#include "../swprintf.h" - -/* - * Uses memcmp & wcslen - */ - -int __cdecl main(int argc, char *argv[]) -{ - int neg = -42; - int pos = 42; - INT64 l = 42; - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - - DoNumTest(convert("foo %u"), pos, convert("foo 42")); - DoNumTest(convert("foo %lu"), 0xFFFF, convert("foo 65535")); - DoNumTest(convert("foo %hu"), 0xFFFF, convert("foo 65535")); - DoNumTest(convert("foo %Lu"), pos, convert("foo 42")); - DoI64Test(convert("foo %I64u"), l, "0x0000000000000042", - convert("foo 42")); - DoNumTest(convert("foo %3u"), pos, convert("foo 42")); - DoNumTest(convert("foo %-3u"), pos, convert("foo 42 ")); - DoNumTest(convert("foo %.1u"), pos, convert("foo 42")); - DoNumTest(convert("foo %.3u"), pos, convert("foo 042")); - DoNumTest(convert("foo %03u"), pos, convert("foo 042")); - DoNumTest(convert("foo %#u"), pos, convert("foo 42")); - DoNumTest(convert("foo %+u"), pos, convert("foo 42")); - DoNumTest(convert("foo % u"), pos, convert("foo 42")); - DoNumTest(convert("foo %+u"), neg, convert("foo 4294967254")); - DoNumTest(convert("foo % u"), neg, convert("foo 4294967254")); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test11/testinfo.dat b/src/pal/tests/palsuite/c_runtime/swprintf/test11/testinfo.dat deleted file mode 100644 index 430a777e7..000000000 --- a/src/pal/tests/palsuite/c_runtime/swprintf/test11/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = swprintf -Name = Positive Test for swprintf -TYPE = DEFAULT -EXE1 = test11 -Description -= Tests swprintf with unsigned numbers diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test12/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/swprintf/test12/CMakeLists.txt deleted file mode 100644 index 57cce1679..000000000 --- a/src/pal/tests/palsuite/c_runtime/swprintf/test12/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test12.cpp -) - -add_executable(paltest_swprintf_test12 - ${SOURCES} -) - -add_dependencies(paltest_swprintf_test12 coreclrpal) - -target_link_libraries(paltest_swprintf_test12 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test12/test12.cpp b/src/pal/tests/palsuite/c_runtime/swprintf/test12/test12.cpp deleted file mode 100644 index a41b0ddbd..000000000 --- a/src/pal/tests/palsuite/c_runtime/swprintf/test12/test12.cpp +++ /dev/null @@ -1,56 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test12.c -** -** Purpose: Tests swprintf with hex numbers (lowercase) -** -** -**==========================================================================*/ - - - -#include -#include "../swprintf.h" - -/* - * Uses memcmp & wcslen - */ - -int __cdecl main(int argc, char *argv[]) -{ - int neg = -42; - int pos = 0x1234ab; - INT64 l = I64(0x1234567887654321); - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - - DoNumTest(convert("foo %x"), pos, convert("foo 1234ab")); - DoNumTest(convert("foo %lx"), pos, convert("foo 1234ab")); - DoNumTest(convert("foo %hx"), pos, convert("foo 34ab")); - DoNumTest(convert("foo %Lx"), pos, convert("foo 1234ab")); - DoI64Test(convert("foo %I64x"), l, "0x1234567887654321", - convert("foo 1234567887654321")); - DoNumTest(convert("foo %7x"), pos, convert("foo 1234ab")); - DoNumTest(convert("foo %-7x"), pos, convert("foo 1234ab ")); - DoNumTest(convert("foo %.1x"), pos, convert("foo 1234ab")); - DoNumTest(convert("foo %.7x"), pos, convert("foo 01234ab")); - DoNumTest(convert("foo %07x"), pos, convert("foo 01234ab")); - DoNumTest(convert("foo %#x"), pos, convert("foo 0x1234ab")); - DoNumTest(convert("foo %+x"), pos, convert("foo 1234ab")); - DoNumTest(convert("foo % x"), pos, convert("foo 1234ab")); - DoNumTest(convert("foo %+x"), neg, convert("foo ffffffd6")); - DoNumTest(convert("foo % x"), neg, convert("foo ffffffd6")); - - PAL_Terminate(); - return PASS; -} - - diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test12/testinfo.dat b/src/pal/tests/palsuite/c_runtime/swprintf/test12/testinfo.dat deleted file mode 100644 index d53582644..000000000 --- a/src/pal/tests/palsuite/c_runtime/swprintf/test12/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = swprintf -Name = Positive Test for swprintf -TYPE = DEFAULT -EXE1 = test12 -Description -= Tests swprintf with hex numbers (lowercase) diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test13/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/swprintf/test13/CMakeLists.txt deleted file mode 100644 index 5b6c63585..000000000 --- a/src/pal/tests/palsuite/c_runtime/swprintf/test13/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test13.cpp -) - -add_executable(paltest_swprintf_test13 - ${SOURCES} -) - -add_dependencies(paltest_swprintf_test13 coreclrpal) - -target_link_libraries(paltest_swprintf_test13 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test13/test13.cpp b/src/pal/tests/palsuite/c_runtime/swprintf/test13/test13.cpp deleted file mode 100644 index b99232f7e..000000000 --- a/src/pal/tests/palsuite/c_runtime/swprintf/test13/test13.cpp +++ /dev/null @@ -1,55 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test13.c -** -** Purpose: Tests swprintf with hex numbers (uppercase) -** -** -**==========================================================================*/ - - - -#include -#include "../swprintf.h" - -/* - * Uses memcmp & wcslen - */ - -int __cdecl main(int argc, char *argv[]) -{ - int neg = -42; - int pos = 0x1234ab; - INT64 l = I64(0x1234567887654321); - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - - DoNumTest(convert("foo %X"), pos, convert("foo 1234AB")); - DoNumTest(convert("foo %lX"), pos, convert("foo 1234AB")); - DoNumTest(convert("foo %hX"), pos, convert("foo 34AB")); - DoNumTest(convert("foo %LX"), pos, convert("foo 1234AB")); - DoI64Test(convert("foo %I64X"), l, "0X1234567887654321", - convert("foo 1234567887654321")); - DoNumTest(convert("foo %7X"), pos, convert("foo 1234AB")); - DoNumTest(convert("foo %-7X"), pos, convert("foo 1234AB ")); - DoNumTest(convert("foo %.1X"), pos, convert("foo 1234AB")); - DoNumTest(convert("foo %.7X"), pos, convert("foo 01234AB")); - DoNumTest(convert("foo %07X"), pos, convert("foo 01234AB")); - DoNumTest(convert("foo %#X"), pos, convert("foo 0X1234AB")); - DoNumTest(convert("foo %+X"), pos, convert("foo 1234AB")); - DoNumTest(convert("foo % X"), pos, convert("foo 1234AB")); - DoNumTest(convert("foo %+X"), neg, convert("foo FFFFFFD6")); - DoNumTest(convert("foo % X"), neg, convert("foo FFFFFFD6")); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test13/testinfo.dat b/src/pal/tests/palsuite/c_runtime/swprintf/test13/testinfo.dat deleted file mode 100644 index 1ce172414..000000000 --- a/src/pal/tests/palsuite/c_runtime/swprintf/test13/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = swprintf -Name = Positive Test for swprintf -TYPE = DEFAULT -EXE1 = test13 -Description -= Tests swprintf with hex numbers (uppercase) diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test14/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/swprintf/test14/CMakeLists.txt deleted file mode 100644 index 88334d67a..000000000 --- a/src/pal/tests/palsuite/c_runtime/swprintf/test14/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test14.cpp -) - -add_executable(paltest_swprintf_test14 - ${SOURCES} -) - -add_dependencies(paltest_swprintf_test14 coreclrpal) - -target_link_libraries(paltest_swprintf_test14 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test14/test14.cpp b/src/pal/tests/palsuite/c_runtime/swprintf/test14/test14.cpp deleted file mode 100644 index bcfd6a7c2..000000000 --- a/src/pal/tests/palsuite/c_runtime/swprintf/test14/test14.cpp +++ /dev/null @@ -1,67 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test14.c -** -** Purpose: Tests swprintf with exponential format doubles (lowercase) -** -** -**==========================================================================*/ - - - -#include -#include "../swprintf.h" - -/* - * Uses memcmp & wcslen - */ - -int __cdecl main(int argc, char *argv[]) -{ - double val = 256.0; - double neg = -256.0; - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - - DoDoubleTest(convert("foo %e"), val, convert("foo 2.560000e+002"), - convert("foo 2.560000e+02")); - DoDoubleTest(convert("foo %le"), val, convert("foo 2.560000e+002"), - convert("foo 2.560000e+02")); - DoDoubleTest(convert("foo %he"), val, convert("foo 2.560000e+002"), - convert("foo 2.560000e+02")); - DoDoubleTest(convert("foo %Le"), val, convert("foo 2.560000e+002"), - convert("foo 2.560000e+02")); - DoDoubleTest(convert("foo %I64e"), val, convert("foo 2.560000e+002"), - convert("foo 2.560000e+02")); - DoDoubleTest(convert("foo %14e"), val, convert("foo 2.560000e+002"), - convert("foo 2.560000e+02")); - DoDoubleTest(convert("foo %-14e"), val, convert("foo 2.560000e+002 "), - convert("foo 2.560000e+02 ")); - DoDoubleTest(convert("foo %.1e"), val, convert("foo 2.6e+002"), - convert("foo 2.6e+02")); - DoDoubleTest(convert("foo %.8e"), val, convert("foo 2.56000000e+002"), - convert("foo 2.56000000e+02")); - DoDoubleTest(convert("foo %014e"), val, convert("foo 02.560000e+002"), - convert("foo 002.560000e+02")); - DoDoubleTest(convert("foo %#e"), val, convert("foo 2.560000e+002"), - convert("foo 2.560000e+02")); - DoDoubleTest(convert("foo %+e"), val, convert("foo +2.560000e+002"), - convert("foo +2.560000e+02")); - DoDoubleTest(convert("foo % e"), val, convert("foo 2.560000e+002"), - convert("foo 2.560000e+02")); - DoDoubleTest(convert("foo %+e"), neg, convert("foo -2.560000e+002"), - convert("foo -2.560000e+02")); - DoDoubleTest(convert("foo % e"), neg, convert("foo -2.560000e+002"), - convert("foo -2.560000e+02")); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test14/testinfo.dat b/src/pal/tests/palsuite/c_runtime/swprintf/test14/testinfo.dat deleted file mode 100644 index 7f3451820..000000000 --- a/src/pal/tests/palsuite/c_runtime/swprintf/test14/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = swprintf -Name = Positive Test for swprintf -TYPE = DEFAULT -EXE1 = test14 -Description -= Tests swprintf with exponential format doubles (lowercase) diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test15/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/swprintf/test15/CMakeLists.txt deleted file mode 100644 index 5387060b2..000000000 --- a/src/pal/tests/palsuite/c_runtime/swprintf/test15/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test15.cpp -) - -add_executable(paltest_swprintf_test15 - ${SOURCES} -) - -add_dependencies(paltest_swprintf_test15 coreclrpal) - -target_link_libraries(paltest_swprintf_test15 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test15/test15.cpp b/src/pal/tests/palsuite/c_runtime/swprintf/test15/test15.cpp deleted file mode 100644 index 215afbe09..000000000 --- a/src/pal/tests/palsuite/c_runtime/swprintf/test15/test15.cpp +++ /dev/null @@ -1,67 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test15.c -** -** Purpose:Tests swprintf with exponential format doubles (uppercase) -** -** -**==========================================================================*/ - - - -#include -#include "../swprintf.h" - -/* - * Uses memcmp & wcslen - */ - -int __cdecl main(int argc, char *argv[]) -{ - double val = 256.0; - double neg = -256.0; - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - - DoDoubleTest(convert("foo %E"), val, convert("foo 2.560000E+002"), - convert("foo 2.560000E+02")); - DoDoubleTest(convert("foo %lE"), val, convert("foo 2.560000E+002"), - convert("foo 2.560000E+02")); - DoDoubleTest(convert("foo %hE"), val, convert("foo 2.560000E+002"), - convert("foo 2.560000E+02")); - DoDoubleTest(convert("foo %LE"), val, convert("foo 2.560000E+002"), - convert("foo 2.560000E+02")); - DoDoubleTest(convert("foo %I64E"), val, convert("foo 2.560000E+002"), - convert("foo 2.560000E+02")); - DoDoubleTest(convert("foo %14E"), val, convert("foo 2.560000E+002"), - convert("foo 2.560000E+02")); - DoDoubleTest(convert("foo %-14E"), val, convert("foo 2.560000E+002 "), - convert("foo 2.560000E+02 ")); - DoDoubleTest(convert("foo %.1E"), val, convert("foo 2.6E+002"), - convert("foo 2.6E+02")); - DoDoubleTest(convert("foo %.8E"), val, convert("foo 2.56000000E+002"), - convert("foo 2.56000000E+02")); - DoDoubleTest(convert("foo %014E"), val, convert("foo 02.560000E+002"), - convert("foo 002.560000E+02")); - DoDoubleTest(convert("foo %#E"), val, convert("foo 2.560000E+002"), - convert("foo 2.560000E+02")); - DoDoubleTest(convert("foo %+E"), val, convert("foo +2.560000E+002"), - convert("foo +2.560000E+02")); - DoDoubleTest(convert("foo % E"), val, convert("foo 2.560000E+002"), - convert("foo 2.560000E+02")); - DoDoubleTest(convert("foo %+E"), neg, convert("foo -2.560000E+002"), - convert("foo -2.560000E+02")); - DoDoubleTest(convert("foo % E"), neg, convert("foo -2.560000E+002"), - convert("foo -2.560000E+02")); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test15/testinfo.dat b/src/pal/tests/palsuite/c_runtime/swprintf/test15/testinfo.dat deleted file mode 100644 index a6044e7bc..000000000 --- a/src/pal/tests/palsuite/c_runtime/swprintf/test15/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = swprintf -Name = Positive Test for swprintf -TYPE = DEFAULT -EXE1 = test15 -Description -= Tests swprintf with exponential format doubles (uppercase) diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test16/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/swprintf/test16/CMakeLists.txt deleted file mode 100644 index 4f66beaa2..000000000 --- a/src/pal/tests/palsuite/c_runtime/swprintf/test16/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test16.cpp -) - -add_executable(paltest_swprintf_test16 - ${SOURCES} -) - -add_dependencies(paltest_swprintf_test16 coreclrpal) - -target_link_libraries(paltest_swprintf_test16 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test16/test16.cpp b/src/pal/tests/palsuite/c_runtime/swprintf/test16/test16.cpp deleted file mode 100644 index 859afed8d..000000000 --- a/src/pal/tests/palsuite/c_runtime/swprintf/test16/test16.cpp +++ /dev/null @@ -1,67 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test16.c -** -** Purpose:Tests swprintf with decimal point format doubles -** -** -**==========================================================================*/ - - - -#include -#include "../swprintf.h" - -/* - * Uses memcmp & wcslen - */ - -int __cdecl main(int argc, char *argv[]) -{ - double val = 2560.001; - double neg = -2560.001; - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - - DoDoubleTest(convert("foo %f"), val, convert("foo 2560.001000"), - convert("foo 2560.001000")); - DoDoubleTest(convert("foo %lf"), val, convert("foo 2560.001000"), - convert("foo 2560.001000")); - DoDoubleTest(convert("foo %hf"), val, convert("foo 2560.001000"), - convert("foo 2560.001000")); - DoDoubleTest(convert("foo %Lf"), val, convert("foo 2560.001000"), - convert("foo 2560.001000")); - DoDoubleTest(convert("foo %I64f"), val, convert("foo 2560.001000"), - convert("foo 2560.001000")); - DoDoubleTest(convert("foo %12f"), val, convert("foo 2560.001000"), - convert("foo 2560.001000")); - DoDoubleTest(convert("foo %-12f"), val, convert("foo 2560.001000 "), - convert("foo 2560.001000 ")); - DoDoubleTest(convert("foo %.1f"), val, convert("foo 2560.0"), - convert("foo 2560.0")); - DoDoubleTest(convert("foo %.8f"), val, convert("foo 2560.00100000"), - convert("foo 2560.00100000")); - DoDoubleTest(convert("foo %012f"), val, convert("foo 02560.001000"), - convert("foo 02560.001000")); - DoDoubleTest(convert("foo %#f"), val, convert("foo 2560.001000"), - convert("foo 2560.001000")); - DoDoubleTest(convert("foo %+f"), val, convert("foo +2560.001000"), - convert("foo +2560.001000")); - DoDoubleTest(convert("foo % f"), val, convert("foo 2560.001000"), - convert("foo 2560.001000")); - DoDoubleTest(convert("foo %+f"), neg, convert("foo -2560.001000"), - convert("foo -2560.001000")); - DoDoubleTest(convert("foo % f"), neg, convert("foo -2560.001000"), - convert("foo -2560.001000")); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test16/testinfo.dat b/src/pal/tests/palsuite/c_runtime/swprintf/test16/testinfo.dat deleted file mode 100644 index d2f9a125c..000000000 --- a/src/pal/tests/palsuite/c_runtime/swprintf/test16/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = swprintf -Name = Positive Test for swprintf -TYPE = DEFAULT -EXE1 = test16 -Description -= Tests swprintf with decimal point format doubles diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test17/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/swprintf/test17/CMakeLists.txt deleted file mode 100644 index ace16a18f..000000000 --- a/src/pal/tests/palsuite/c_runtime/swprintf/test17/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test17.cpp -) - -add_executable(paltest_swprintf_test17 - ${SOURCES} -) - -add_dependencies(paltest_swprintf_test17 coreclrpal) - -target_link_libraries(paltest_swprintf_test17 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test17/test17.cpp b/src/pal/tests/palsuite/c_runtime/swprintf/test17/test17.cpp deleted file mode 100644 index 480f2b2fe..000000000 --- a/src/pal/tests/palsuite/c_runtime/swprintf/test17/test17.cpp +++ /dev/null @@ -1,69 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test17.c -** -** Purpose:Tests swprintf with compact format doubles (lowercase) -** -** -**==========================================================================*/ - - - -#include -#include "../swprintf.h" - -/* - * Uses memcmp & wcslen - */ - -int __cdecl main(int argc, char *argv[]) -{ - double val = 2560.001; - double neg = -2560.001; - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - - DoDoubleTest(convert("foo %g"), val, convert("foo 2560"), - convert("foo 2560")); - DoDoubleTest(convert("foo %lg"), val, convert("foo 2560"), - convert("foo 2560")); - DoDoubleTest(convert("foo %hg"), val, convert("foo 2560"), - convert("foo 2560")); - DoDoubleTest(convert("foo %Lg"), val, convert("foo 2560"), - convert("foo 2560")); - DoDoubleTest(convert("foo %I64g"), val, convert("foo 2560"), - convert("foo 2560")); - DoDoubleTest(convert("foo %5g"), val, convert("foo 2560"), - convert("foo 2560")); - DoDoubleTest(convert("foo %-5g"), val, convert("foo 2560 "), - convert("foo 2560 ")); - DoDoubleTest(convert("foo %.1g"), val, convert("foo 3e+003"), - convert("foo 3e+03")); - DoDoubleTest(convert("foo %.2g"), val, convert("foo 2.6e+003"), - convert("foo 2.6e+03")); - DoDoubleTest(convert("foo %.12g"), val, convert("foo 2560.001"), - convert("foo 2560.001")); - DoDoubleTest(convert("foo %06g"), val, convert("foo 002560"), - convert("foo 002560")); - DoDoubleTest(convert("foo %#g"), val, convert("foo 2560.00"), - convert("foo 2560.00")); - DoDoubleTest(convert("foo %+g"), val, convert("foo +2560"), - convert("foo +2560")); - DoDoubleTest(convert("foo % g"), val, convert("foo 2560"), - convert("foo 2560")); - DoDoubleTest(convert("foo %+g"), neg, convert("foo -2560"), - convert("foo -2560")); - DoDoubleTest(convert("foo % g"), neg, convert("foo -2560"), - convert("foo -2560")); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test17/testinfo.dat b/src/pal/tests/palsuite/c_runtime/swprintf/test17/testinfo.dat deleted file mode 100644 index f26029c65..000000000 --- a/src/pal/tests/palsuite/c_runtime/swprintf/test17/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = swprintf -Name = Positive Test for swprintf -TYPE = DEFAULT -EXE1 = test17 -Description -= Tests swprintf with compact format doubles (lowercase) diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test18/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/swprintf/test18/CMakeLists.txt deleted file mode 100644 index ddce25626..000000000 --- a/src/pal/tests/palsuite/c_runtime/swprintf/test18/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test18.cpp -) - -add_executable(paltest_swprintf_test18 - ${SOURCES} -) - -add_dependencies(paltest_swprintf_test18 coreclrpal) - -target_link_libraries(paltest_swprintf_test18 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test18/test18.cpp b/src/pal/tests/palsuite/c_runtime/swprintf/test18/test18.cpp deleted file mode 100644 index 1ed8cd00d..000000000 --- a/src/pal/tests/palsuite/c_runtime/swprintf/test18/test18.cpp +++ /dev/null @@ -1,69 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test18.c -** -** Purpose: Tests swprintf with compact format doubles (uppercase) -** -** -**==========================================================================*/ - - - -#include -#include "../swprintf.h" - -/* - * Uses memcmp & wcslen - */ - -int __cdecl main(int argc, char *argv[]) -{ - double val = 2560.001; - double neg = -2560.001; - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - - DoDoubleTest(convert("foo %G"), val, convert("foo 2560"), - convert("foo 2560")); - DoDoubleTest(convert("foo %lG"), val, convert("foo 2560"), - convert("foo 2560")); - DoDoubleTest(convert("foo %hG"), val, convert("foo 2560"), - convert("foo 2560")); - DoDoubleTest(convert("foo %LG"), val, convert("foo 2560"), - convert("foo 2560")); - DoDoubleTest(convert("foo %I64G"), val, convert("foo 2560"), - convert("foo 2560")); - DoDoubleTest(convert("foo %5G"), val, convert("foo 2560"), - convert("foo 2560")); - DoDoubleTest(convert("foo %-5G"), val, convert("foo 2560 "), - convert("foo 2560 ")); - DoDoubleTest(convert("foo %.1G"), val, convert("foo 3E+003"), - convert("foo 3E+03")); - DoDoubleTest(convert("foo %.2G"), val, convert("foo 2.6E+003"), - convert("foo 2.6E+03")); - DoDoubleTest(convert("foo %.12G"), val, convert("foo 2560.001"), - convert("foo 2560.001")); - DoDoubleTest(convert("foo %06G"), val, convert("foo 002560"), - convert("foo 002560")); - DoDoubleTest(convert("foo %#G"), val, convert("foo 2560.00"), - convert("foo 2560.00")); - DoDoubleTest(convert("foo %+G"), val, convert("foo +2560"), - convert("foo +2560")); - DoDoubleTest(convert("foo % G"), val, convert("foo 2560"), - convert("foo 2560")); - DoDoubleTest(convert("foo %+G"), neg, convert("foo -2560"), - convert("foo -2560")); - DoDoubleTest(convert("foo % G"), neg, convert("foo -2560"), - convert("foo -2560")); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test18/testinfo.dat b/src/pal/tests/palsuite/c_runtime/swprintf/test18/testinfo.dat deleted file mode 100644 index 6a8ca702f..000000000 --- a/src/pal/tests/palsuite/c_runtime/swprintf/test18/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = swprintf -Name = Positive Test for swprintf -TYPE = DEFAULT -EXE1 = test18 -Description -= Tests swprintf with compact format doubles (uppercase) diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test19/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/swprintf/test19/CMakeLists.txt deleted file mode 100644 index 8d48ce438..000000000 --- a/src/pal/tests/palsuite/c_runtime/swprintf/test19/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test19.cpp -) - -add_executable(paltest_swprintf_test19 - ${SOURCES} -) - -add_dependencies(paltest_swprintf_test19 coreclrpal) - -target_link_libraries(paltest_swprintf_test19 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test19/test19.cpp b/src/pal/tests/palsuite/c_runtime/swprintf/test19/test19.cpp deleted file mode 100644 index 0967bc8f4..000000000 --- a/src/pal/tests/palsuite/c_runtime/swprintf/test19/test19.cpp +++ /dev/null @@ -1,101 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test19.c -** -** Purpose: Tests swprintf with argument specified precision -** -** -**==========================================================================*/ - - - -#include -#include "../swprintf.h" - -/* - * Uses memcmp & wcslen - */ - -int __cdecl main(int argc, char *argv[]) -{ - int n = -1; - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - DoArgumentPrecTest(convert("%.*s"), 2, (void*)convert("bar"), "bar", - convert("ba"), convert("ba")); - DoArgumentPrecTest(convert("%.*S"), 2, (void*)"bar", "bar", convert("ba"), - convert("ba")); - DoArgumentPrecTest(convert("%.*c"), 0, (void*)'a', "a", convert("a"), - convert("a")); - DoArgumentPrecTest(convert("%.*c"), 4, (void*)'a', "a", convert("a"), - convert("a")); - DoArgumentPrecTest(convert("%.*C"), 0, (void*)'a', "a", convert("a"), - convert("a")); - DoArgumentPrecTest(convert("%.*C"), 4, (void*)'a', "a", convert("a"), - convert("a")); - DoArgumentPrecTest(convert("%.*d"), 1, (void*)42, "42", convert("42"), - convert("42")); - DoArgumentPrecTest(convert("%.*d"), 3, (void*)42, "42", convert("042"), - convert("042")); - DoArgumentPrecTest(convert("%.*i"), 1, (void*)42, "42", convert("42"), - convert("42")); - DoArgumentPrecTest(convert("%.*i"), 3, (void*)42, "42", convert("042"), - convert("042")); - DoArgumentPrecTest(convert("%.*o"), 1, (void*)42, "42", convert("52"), - convert("52")); - DoArgumentPrecTest(convert("%.*o"), 3, (void*)42, "42", convert("052"), - convert("052")); - DoArgumentPrecTest(convert("%.*u"), 1, (void*)42, "42", convert("42"), - convert("42")); - DoArgumentPrecTest(convert("%.*u"), 3, (void*)42, "42", convert("042"), - convert("042")); - DoArgumentPrecTest(convert("%.*x"), 1, (void*)0x42, "0x42", convert("42"), - convert("42")); - DoArgumentPrecTest(convert("%.*x"), 3, (void*)0x42, "0x42", convert("042"), - convert("042")); - DoArgumentPrecTest(convert("%.*X"), 1, (void*)0x42, "0x42", convert("42"), - convert("42")); - DoArgumentPrecTest(convert("%.*X"), 3, (void*)0x42, "0x42", convert("042"), - convert("042")); - - - DoArgumentPrecDoubleTest(convert("%.*e"), 1, 2.01, convert("2.0e+000"), - convert("2.0e+000")); - DoArgumentPrecDoubleTest(convert("%.*e"), 3, 2.01, convert("2.010e+000"), - convert("2.010e+000")); - DoArgumentPrecDoubleTest(convert("%.*E"), 1, 2.01, convert("2.0E+000"), - convert("2.0E+000")); - DoArgumentPrecDoubleTest(convert("%.*E"), 3, 2.01, convert("2.010E+000"), - convert("2.010E+000")); - DoArgumentPrecDoubleTest(convert("%.*f"), 1, 2.01, convert("2.0"), - convert("2.0")); - DoArgumentPrecDoubleTest(convert("%.*f"), 3, 2.01, convert("2.010"), - convert("2.010")); - DoArgumentPrecDoubleTest(convert("%.*g"), 1, 256.01, convert("3e+002"), - convert("3e+002")); - DoArgumentPrecDoubleTest(convert("%.*g"), 3, 256.01, convert("256"), - convert("256")); - DoArgumentPrecDoubleTest(convert("%.*g"), 4, 256.01, convert("256"), - convert("256")); - DoArgumentPrecDoubleTest(convert("%.*g"), 6, 256.01, convert("256.01"), - convert("256.01")); - DoArgumentPrecDoubleTest(convert("%.*G"), 1, 256.01, convert("3E+002"), - convert("3E+002")); - DoArgumentPrecDoubleTest(convert("%.*G"), 3, 256.01, convert("256"), - convert("256")); - DoArgumentPrecDoubleTest(convert("%.*G"), 4, 256.01, convert("256"), - convert("256")); - DoArgumentPrecDoubleTest(convert("%.*G"), 6, 256.01, convert("256.01"), - convert("256.01")); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test19/testinfo.dat b/src/pal/tests/palsuite/c_runtime/swprintf/test19/testinfo.dat deleted file mode 100644 index cbd572a35..000000000 --- a/src/pal/tests/palsuite/c_runtime/swprintf/test19/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = swprintf -Name = Positive Test for swprintf -TYPE = DEFAULT -EXE1 = test19 -Description -= Tests swprintf with argument specified precision diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test2/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/swprintf/test2/CMakeLists.txt deleted file mode 100644 index fcf713679..000000000 --- a/src/pal/tests/palsuite/c_runtime/swprintf/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test2.cpp -) - -add_executable(paltest_swprintf_test2 - ${SOURCES} -) - -add_dependencies(paltest_swprintf_test2 coreclrpal) - -target_link_libraries(paltest_swprintf_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test2/test2.cpp b/src/pal/tests/palsuite/c_runtime/swprintf/test2/test2.cpp deleted file mode 100644 index 1c2f420fe..000000000 --- a/src/pal/tests/palsuite/c_runtime/swprintf/test2/test2.cpp +++ /dev/null @@ -1,52 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test2.c -** -** Purpose: Tests swprintf with strings -** -** -**==========================================================================*/ - - - -#include -#include "../swprintf.h" - -/* - * Uses memcmp & wcslen - */ - - -int __cdecl main(int argc, char *argv[]) -{ - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - DoWStrTest(convert("foo %s"), convert("bar"), convert("foo bar")); - DoStrTest(convert("foo %hs"), "bar", convert("foo bar")); - DoWStrTest(convert("foo %ws"), convert("bar"), convert("foo bar")); - DoWStrTest(convert("foo %ls"), convert("bar"), convert("foo bar")); - DoWStrTest(convert("foo %Ls"), convert("bar"), convert("foo bar")); - DoWStrTest(convert("foo %I64s"), convert("bar"), convert("foo bar")); - DoWStrTest(convert("foo %5s"), convert("bar"), convert("foo bar")); - DoWStrTest(convert("foo %.2s"), convert("bar"), convert("foo ba")); - DoWStrTest(convert("foo %5.2s"), convert("bar"), convert("foo ba")); - DoWStrTest(convert("foo %-5s"), convert("bar"), convert("foo bar ")); - DoWStrTest(convert("foo %05s"), convert("bar"), convert("foo 00bar")); - DoWStrTest(convert("foo %s"), NULL, convert("foo (null)")); - DoStrTest(convert("foo %hs"), NULL, convert("foo (null)")); - DoWStrTest(convert("foo %ls"), NULL, convert("foo (null)")); - DoWStrTest(convert("foo %ws"), NULL, convert("foo (null)")); - DoWStrTest(convert("foo %Ls"), NULL, convert("foo (null)")); - DoWStrTest(convert("foo %I64s"), NULL, convert("foo (null)")); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test2/testinfo.dat b/src/pal/tests/palsuite/c_runtime/swprintf/test2/testinfo.dat deleted file mode 100644 index d93fa7b40..000000000 --- a/src/pal/tests/palsuite/c_runtime/swprintf/test2/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = swprintf -Name = Positive Test for swprintf -TYPE = DEFAULT -EXE1 = test2 -Description -= Tests swprintf with strings diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test3/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/swprintf/test3/CMakeLists.txt deleted file mode 100644 index cc79c2d1d..000000000 --- a/src/pal/tests/palsuite/c_runtime/swprintf/test3/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test3.cpp -) - -add_executable(paltest_swprintf_test3 - ${SOURCES} -) - -add_dependencies(paltest_swprintf_test3 coreclrpal) - -target_link_libraries(paltest_swprintf_test3 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test3/test3.cpp b/src/pal/tests/palsuite/c_runtime/swprintf/test3/test3.cpp deleted file mode 100644 index 8c6c38c96..000000000 --- a/src/pal/tests/palsuite/c_runtime/swprintf/test3/test3.cpp +++ /dev/null @@ -1,49 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test3.c -** -** Purpose: Tests swprintf with wide strings -** -** -**==========================================================================*/ - - - -#include -#include "../swprintf.h" - -/* - * Uses memcmp & wcslen - */ - -int __cdecl main(int argc, char *argv[]) -{ - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - DoStrTest(convert("foo %S"), "bar", convert("foo bar")); - DoStrTest(convert("foo %hS"), "bar", convert("foo bar")); - DoWStrTest(convert("foo %lS"), convert("bar"), convert("foo bar")); - DoWStrTest(convert("foo %wS"), convert("bar"), convert("foo bar")); - DoStrTest(convert("foo %LS"), "bar", convert("foo bar")); - DoStrTest(convert("foo %I64S"), "bar", convert("foo bar")); - DoStrTest(convert("foo %5S"), "bar", convert("foo bar")); - DoStrTest(convert("foo %.2S"), "bar", convert("foo ba")); - DoStrTest(convert("foo %5.2S"),"bar", convert("foo ba")); - DoStrTest(convert("foo %-5S"), "bar", convert("foo bar ")); - DoStrTest(convert("foo %05S"), "bar", convert("foo 00bar")); - DoStrTest(convert("foo %S"), NULL, convert("foo (null)")); - DoStrTest(convert("foo %hS"), NULL, convert("foo (null)")); - DoWStrTest(convert("foo %lS"), NULL, convert("foo (null)")); - DoWStrTest(convert("foo %wS"), NULL, convert("foo (null)")); - DoStrTest(convert("foo %LS"), NULL, convert("foo (null)")); - DoStrTest(convert("foo %I64S"), NULL, convert("foo (null)")); - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test3/testinfo.dat b/src/pal/tests/palsuite/c_runtime/swprintf/test3/testinfo.dat deleted file mode 100644 index 923a8f0ef..000000000 --- a/src/pal/tests/palsuite/c_runtime/swprintf/test3/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = swprintf -Name = Positive Test for swprintf -TYPE = DEFAULT -EXE1 = test3 -Description -= Tests swprintf with wide strings diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test4/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/swprintf/test4/CMakeLists.txt deleted file mode 100644 index c5d92462a..000000000 --- a/src/pal/tests/palsuite/c_runtime/swprintf/test4/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test4.cpp -) - -add_executable(paltest_swprintf_test4 - ${SOURCES} -) - -add_dependencies(paltest_swprintf_test4 coreclrpal) - -target_link_libraries(paltest_swprintf_test4 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test4/test4.cpp b/src/pal/tests/palsuite/c_runtime/swprintf/test4/test4.cpp deleted file mode 100644 index 9a68bdaac..000000000 --- a/src/pal/tests/palsuite/c_runtime/swprintf/test4/test4.cpp +++ /dev/null @@ -1,71 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test4.c -** -** Purpose: Tests swprintf with pointers -** -** -**==========================================================================*/ - - - -#include -#include "../swprintf.h" - -/* - * Uses memcmp & wcslen - */ - - -int __cdecl main(int argc, char *argv[]) -{ - void *ptr = (void*) 0x123456; - INT64 lptr = I64(0x1234567887654321); - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } -/* -** Run only on 64 bit platforms -*/ -#if defined(BIT64) - Trace("Testing for 64 Bit Platforms \n"); - DoPointerTest(convert("%p"), NULL, convert("0000000000000000")); - DoPointerTest(convert("%p"), ptr, convert("0000000000123456")); - DoPointerTest(convert("%17p"), ptr, convert(" 0000000000123456")); - DoPointerTest(convert("%17p"), ptr, convert(" 0000000000123456")); - DoPointerTest(convert("%-17p"), ptr, convert("0000000000123456 ")); - DoPointerTest(convert("%+p"), ptr, convert("0000000000123456")); - DoPointerTest(convert("% p"), ptr, convert("0000000000123456")); - DoPointerTest(convert("%#p"), ptr, convert("0X0000000000123456")); - DoPointerTest(convert("%lp"), ptr, convert("00123456")); - DoPointerTest(convert("%hp"), ptr, convert("00003456")); - DoPointerTest(convert("%Lp"), ptr, convert("00123456")); - DoI64Test(convert("%I64p"), lptr, "pointer to 0X1234567887654321", - convert("1234567887654321")); -#else - Trace("Testing for Non 64 Bit Platforms \n"); - DoPointerTest(convert("%p"), NULL, convert("00000000")); - DoPointerTest(convert("%p"), ptr, convert("00123456")); - DoPointerTest(convert("%9p"), ptr, convert(" 00123456")); - DoPointerTest(convert("%09p"), ptr, convert(" 00123456")); - DoPointerTest(convert("%-9p"), ptr, convert("00123456 ")); - DoPointerTest(convert("%+p"), ptr, convert("00123456")); - DoPointerTest(convert("% p"), ptr, convert("00123456")); - DoPointerTest(convert("%#p"), ptr, convert("0X00123456")); - DoPointerTest(convert("%lp"), ptr, convert("00123456")); - DoPointerTest(convert("%hp"), ptr, convert("00003456")); - DoPointerTest(convert("%Lp"), ptr, convert("00123456")); - DoI64Test(convert("%I64p"), lptr, "pointer to 0X1234567887654321", - convert("1234567887654321")); -#endif - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test4/testinfo.dat b/src/pal/tests/palsuite/c_runtime/swprintf/test4/testinfo.dat deleted file mode 100644 index dc481d32f..000000000 --- a/src/pal/tests/palsuite/c_runtime/swprintf/test4/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = swprintf -Name = Positive Test for swprintf -TYPE = DEFAULT -EXE1 = test4 -Description -= Tests swprintf with pointers diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test6/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/swprintf/test6/CMakeLists.txt deleted file mode 100644 index 044029dd6..000000000 --- a/src/pal/tests/palsuite/c_runtime/swprintf/test6/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test6.cpp -) - -add_executable(paltest_swprintf_test6 - ${SOURCES} -) - -add_dependencies(paltest_swprintf_test6 coreclrpal) - -target_link_libraries(paltest_swprintf_test6 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test6/test6.cpp b/src/pal/tests/palsuite/c_runtime/swprintf/test6/test6.cpp deleted file mode 100644 index ecd637426..000000000 --- a/src/pal/tests/palsuite/c_runtime/swprintf/test6/test6.cpp +++ /dev/null @@ -1,47 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test6.c -** -** Purpose: Tests swprintf with character -** -** -**==========================================================================*/ - - - -#include -#include "../swprintf.h" - -/* - * Uses memcmp & wcslen - */ - -int __cdecl main(int argc, char *argv[]) -{ - WCHAR wb = (WCHAR) 'b'; - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - - DoWCharTest(convert("foo %c"), wb, convert("foo b")); - DoCharTest(convert("foo %hc"), 'c', convert("foo c")); - DoWCharTest(convert("foo %lc"), wb, convert("foo b")); - DoWCharTest(convert("foo %Lc"), wb, convert("foo b")); - DoWCharTest(convert("foo %I64c"), wb, convert("foo b")); - DoWCharTest(convert("foo %5c"), wb, convert("foo b")); - DoWCharTest(convert("foo %.0c"), wb, convert("foo b")); - DoWCharTest(convert("foo %-5c"), wb, convert("foo b ")); - DoWCharTest(convert("foo %05c"), wb, convert("foo 0000b")); - DoWCharTest(convert("foo % c"), wb, convert("foo b")); - DoWCharTest(convert("foo %#c"), wb, convert("foo b")); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test6/testinfo.dat b/src/pal/tests/palsuite/c_runtime/swprintf/test6/testinfo.dat deleted file mode 100644 index 4224d1951..000000000 --- a/src/pal/tests/palsuite/c_runtime/swprintf/test6/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = swprintf -Name = Positive Test for swprintf -TYPE = DEFAULT -EXE1 = test6 -Description -= Tests swprintf with characters diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test7/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/swprintf/test7/CMakeLists.txt deleted file mode 100644 index 3ee7139ec..000000000 --- a/src/pal/tests/palsuite/c_runtime/swprintf/test7/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test7.cpp -) - -add_executable(paltest_swprintf_test7 - ${SOURCES} -) - -add_dependencies(paltest_swprintf_test7 coreclrpal) - -target_link_libraries(paltest_swprintf_test7 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test7/test7.cpp b/src/pal/tests/palsuite/c_runtime/swprintf/test7/test7.cpp deleted file mode 100644 index e231ada3d..000000000 --- a/src/pal/tests/palsuite/c_runtime/swprintf/test7/test7.cpp +++ /dev/null @@ -1,48 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test7.c -** -** Purpose: Tests swprintf with wide characters -** -** -**==========================================================================*/ - - - -#include -#include "../swprintf.h" - -/* - * Uses memcmp & wcslen - */ - - -int __cdecl main(int argc, char *argv[]) -{ - WCHAR wb = (WCHAR) 'b'; - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - - DoCharTest(convert("foo %C"), 'c', convert("foo c")); - DoWCharTest(convert("foo %hc"), wb, convert("foo b")); - DoCharTest(convert("foo %lC"), 'c', convert("foo c")); - DoCharTest(convert("foo %LC"), 'c', convert("foo c")); - DoCharTest(convert("foo %I64C"), 'c', convert("foo c")); - DoCharTest(convert("foo %5C"), 'c', convert("foo c")); - DoCharTest(convert("foo %.0C"), 'c', convert("foo c")); - DoCharTest(convert("foo %-5C"), 'c', convert("foo c ")); - DoCharTest(convert("foo %05C"), 'c', convert("foo 0000c")); - DoCharTest(convert("foo % C"), 'c', convert("foo c")); - DoCharTest(convert("foo %#C"), 'c', convert("foo c")); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test7/testinfo.dat b/src/pal/tests/palsuite/c_runtime/swprintf/test7/testinfo.dat deleted file mode 100644 index 7facc90b5..000000000 --- a/src/pal/tests/palsuite/c_runtime/swprintf/test7/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = swprintf -Name = Positive Test for swprintf -TYPE = DEFAULT -EXE1 = test7 -Description -= Tests swprintf with wide characters diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test8/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/swprintf/test8/CMakeLists.txt deleted file mode 100644 index 55ac85c16..000000000 --- a/src/pal/tests/palsuite/c_runtime/swprintf/test8/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test8.cpp -) - -add_executable(paltest_swprintf_test8 - ${SOURCES} -) - -add_dependencies(paltest_swprintf_test8 coreclrpal) - -target_link_libraries(paltest_swprintf_test8 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test8/test8.cpp b/src/pal/tests/palsuite/c_runtime/swprintf/test8/test8.cpp deleted file mode 100644 index b4be28e78..000000000 --- a/src/pal/tests/palsuite/c_runtime/swprintf/test8/test8.cpp +++ /dev/null @@ -1,55 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test8.c -** -** Purpose: Tests swprintf with decimal numbers -** -** -**==========================================================================*/ - - - -#include -#include "../swprintf.h" - -/* - * Uses memcmp & wcslen - */ - -int __cdecl main(int argc, char *argv[]) -{ - int neg = -42; - int pos = 42; - INT64 l = 42; - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - - DoNumTest(convert("foo %d"), pos, convert("foo 42")); - DoNumTest(convert("foo %ld"), 0xFFFF, convert("foo 65535")); - DoNumTest(convert("foo %hd"), 0xFFFF, convert("foo -1")); - DoNumTest(convert("foo %Ld"), pos, convert("foo 42")); - DoI64Test(convert("foo %I64d"), l, "0x0000000000000042", - convert("foo 42")); - DoNumTest(convert("foo %3d"), pos, convert("foo 42")); - DoNumTest(convert("foo %-3d"), pos, convert("foo 42 ")); - DoNumTest(convert("foo %.1d"), pos, convert("foo 42")); - DoNumTest(convert("foo %.3d"), pos, convert("foo 042")); - DoNumTest(convert("foo %03d"), pos, convert("foo 042")); - DoNumTest(convert("foo %#d"), pos, convert("foo 42")); - DoNumTest(convert("foo %+d"), pos, convert("foo +42")); - DoNumTest(convert("foo % d"), pos, convert("foo 42")); - DoNumTest(convert("foo %+d"), neg, convert("foo -42")); - DoNumTest(convert("foo % d"), neg, convert("foo -42")); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test8/testinfo.dat b/src/pal/tests/palsuite/c_runtime/swprintf/test8/testinfo.dat deleted file mode 100644 index d5858b2cf..000000000 --- a/src/pal/tests/palsuite/c_runtime/swprintf/test8/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = swprintf -Name = Positive Test for swprintf -TYPE = DEFAULT -EXE1 = test8 -Description -= Tests swprintf with decimal numbers diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test9/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/swprintf/test9/CMakeLists.txt deleted file mode 100644 index 7d7f524f6..000000000 --- a/src/pal/tests/palsuite/c_runtime/swprintf/test9/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test9.cpp -) - -add_executable(paltest_swprintf_test9 - ${SOURCES} -) - -add_dependencies(paltest_swprintf_test9 coreclrpal) - -target_link_libraries(paltest_swprintf_test9 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test9/test9.cpp b/src/pal/tests/palsuite/c_runtime/swprintf/test9/test9.cpp deleted file mode 100644 index 2f5429e5f..000000000 --- a/src/pal/tests/palsuite/c_runtime/swprintf/test9/test9.cpp +++ /dev/null @@ -1,55 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test9.c -** -** Purpose: Tests swprintf with integer numbers -** -** -**==========================================================================*/ - - - -#include -#include "../swprintf.h" - -/* - * Uses memcmp & wcslen - */ - -int __cdecl main(int argc, char *argv[]) -{ - int neg = -42; - int pos = 42; - INT64 l = 42; - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - - DoNumTest(convert("foo %i"), pos, convert("foo 42")); - DoNumTest(convert("foo %li"), 0xFFFF, convert("foo 65535")); - DoNumTest(convert("foo %hi"), 0xFFFF, convert("foo -1")); - DoNumTest(convert("foo %Li"), pos, convert("foo 42")); - DoI64Test(convert("foo %I64i"), l, "0x0000000000000042", - convert("foo 42")); - DoNumTest(convert("foo %3i"), pos, convert("foo 42")); - DoNumTest(convert("foo %-3i"), pos, convert("foo 42 ")); - DoNumTest(convert("foo %.1i"), pos, convert("foo 42")); - DoNumTest(convert("foo %.3i"), pos, convert("foo 042")); - DoNumTest(convert("foo %03i"), pos, convert("foo 042")); - DoNumTest(convert("foo %#i"), pos, convert("foo 42")); - DoNumTest(convert("foo %+i"), pos, convert("foo +42")); - DoNumTest(convert("foo % i"), pos, convert("foo 42")); - DoNumTest(convert("foo %+i"), neg, convert("foo -42")); - DoNumTest(convert("foo % i"), neg, convert("foo -42")); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/c_runtime/swprintf/test9/testinfo.dat b/src/pal/tests/palsuite/c_runtime/swprintf/test9/testinfo.dat deleted file mode 100644 index 7ef9eed13..000000000 --- a/src/pal/tests/palsuite/c_runtime/swprintf/test9/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = swprintf -Name = Positive Test for swprintf -TYPE = DEFAULT -EXE1 = test9 -Description -= Tests swprintf with integer numbers diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/swscanf/CMakeLists.txt deleted file mode 100644 index 59f39a5f5..000000000 --- a/src/pal/tests/palsuite/c_runtime/swscanf/CMakeLists.txt +++ /dev/null @@ -1,20 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test10) -add_subdirectory(test11) -add_subdirectory(test12) -add_subdirectory(test13) -add_subdirectory(test14) -add_subdirectory(test15) -add_subdirectory(test16) -add_subdirectory(test17) -add_subdirectory(test2) -add_subdirectory(test3) -add_subdirectory(test4) -add_subdirectory(test5) -add_subdirectory(test6) -add_subdirectory(test7) -add_subdirectory(test8) -add_subdirectory(test9) - diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/swscanf.h b/src/pal/tests/palsuite/c_runtime/swscanf/swscanf.h deleted file mode 100644 index 6349b7dcd..000000000 --- a/src/pal/tests/palsuite/c_runtime/swscanf/swscanf.h +++ /dev/null @@ -1,262 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: swscanf.h -** -** Purpose: Contains common testing functions for swscanf.h -** -** -**==========================================================================*/ - -#ifndef __SWSCANF_H__ -#define __SWSCANF_H__ - -void DoVoidTest(WCHAR *inputstr, const WCHAR *formatstr) -{ - char buf[256] = { 0 }; - int i; - int ret; - - ret = swscanf(inputstr, formatstr, buf); - if (ret != 0) - { - Fail("ERROR: Expected sscanf to return 0, got %d.\n" - "Using \"%s\" in \"%s\".\n", ret, convertC(inputstr), - convertC(formatstr)); - } - - for (i=0; i<256; i++) - { - if (buf[i] != 0) - { - Fail("ERROR: Parameter unexpectedly modified scanning \"%s\" " - "using \"%s\".\n", convertC(inputstr), - convertC(formatstr)); - } - } - -} - -void DoStrTest(WCHAR *inputstr, const WCHAR *formatstr, const char *checkstr) -{ - char buf[256] = { 0 }; - int ret; - - ret = swscanf(inputstr, formatstr, buf); - if (ret != 1) - { - Fail("ERROR: Expected swscanf to return 1, got %d.\n" - "Using \"%s\" in \"%s\".\n", ret, convertC(inputstr), - convertC(formatstr)); - } - - if (memcmp(checkstr, buf, strlen(checkstr) + 1) != 0) - { - Fail("ERROR: scanned string incorrectly from \"%s\" using \"%s\".\n" - "Expected \"%s\", got \"%s\".\n", convertC(inputstr), - convertC(formatstr), checkstr, - buf); - } - -} - -void DoWStrTest(WCHAR *inputstr, const WCHAR *formatstr, const WCHAR *checkstr) -{ - WCHAR buf[256] = { 0 }; - int ret; - - ret = swscanf(inputstr, formatstr, buf); - if (ret != 1) - { - Fail("ERROR: Expected swscanf to return 1, got %d.\n" - "Using \"%s\" in \"%s\".\n", ret, convertC(inputstr), - convertC(formatstr)); - } - - if (memcmp(checkstr, buf, wcslen(checkstr)*2 + 2) != 0) - { - Fail("ERROR: scanned wide string incorrectly from \"%s\" using \"%s\".\n" - "Expected \"%s\", got \"%s\".\n", convertC(inputstr), - convertC(formatstr), convertC(checkstr), - convertC(buf)); - } - -} - -void DoNumTest(WCHAR *inputstr, const WCHAR *formatstr, int checknum) -{ - int num = 0; - int ret; - - ret = swscanf(inputstr, formatstr, &num); - if (ret != 1) - { - Fail("ERROR: Expected swscanf to return 1, got %d.\n" - "Using \"%s\" in \"%s\".\n", ret, convertC(inputstr), - convertC(formatstr)); - } - - if (checknum != num) - { - Fail("ERROR: scanned number incorrectly from \"%s\" using \"%s\".\n" - "Expected %d, got %d.\n", convertC(inputstr), - convertC(formatstr), checknum, num); - } -} - -void DoShortNumTest(WCHAR *inputstr, const WCHAR *formatstr, short checknum) -{ - short num = 0; - int ret; - - ret = swscanf(inputstr, formatstr, &num); - if (ret != 1) - { - Fail("ERROR: Expected swscanf to return 1, got %d.\n" - "Using \"%s\" in \"%s\".\n", ret, convertC(inputstr), - convertC(formatstr)); - } - - if (checknum != num) - { - Fail("ERROR: scanned number incorrectly from \"%s\" using \"%s\".\n" - "Expected %hd, got %hd.\n", convertC(inputstr), - convertC(formatstr), checknum, num); - } -} - -void DoI64NumTest(WCHAR *inputstr, const WCHAR *formatstr, INT64 checknum) -{ - char buf[256]; - char check[256]; - INT64 num; - int ret; - - ret = swscanf(inputstr, formatstr, &num); - if (ret != 1) - { - Fail("ERROR: Expected swscanf to return 1, got %d.\n" - "Using \"%s\" in \"%s\".\n", ret, convertC(inputstr), - convertC(formatstr)); - } - - if (checknum != num) - { - sprintf_s(buf, _countof(buf), "%I64d", num); - sprintf_s(check, _countof(check), "%I64d", checknum); - Fail("ERROR: scanned I64 number incorrectly from \"%s\" using \"%s\".\n" - "Expected %s, got %s.\n", convertC(inputstr), - convertC(formatstr), check, buf); - } -} - -void DoCharTest(WCHAR *inputstr, const WCHAR *formatstr, char* checkchars, int numchars) -{ - char buf[256]; - int ret; - int i; - - for (i=0; i<256; i++) - buf[i] = (char)-1; - - ret = swscanf(inputstr, formatstr, buf); - if (ret != 1) - { - Fail("ERROR: Expected swscanf to return 1, got %d.\n" - "Using \"%s\" in \"%s\".\n", ret, convertC(inputstr), - convertC(formatstr)); - } - - if (memcmp(buf, checkchars, numchars) != 0) - { - buf[numchars] = 0; - - Fail("ERROR: scanned character(s) incorrectly from \"%s\" using \"%s\".\n" - "Expected %s, got %s.\n", convertC(inputstr), - convertC(formatstr), checkchars, buf); - } - - if (buf[numchars] != (char)-1) - { - Fail("ERROR: overflow occurred in scanning character(s) from \"%s\" " - "using \"%s\".\nExpected %d character(s)\n", - convertC(inputstr), convertC(formatstr), numchars); - } -} - -void DoWCharTest(WCHAR *inputstr, const WCHAR *formatstr, const WCHAR *checkchars, int numchars) -{ - WCHAR buf[256]; - int ret; - int i; - - for (i=0; i<256; i++) - buf[i] = (WCHAR)-1; - - ret = swscanf(inputstr, formatstr, buf); - if (ret != 1) - { - Fail("ERROR: Expected swscanf to return 1, got %d.\n" - "Using \"%s\" in \"%s\".\n", ret, convertC(inputstr), - convertC(formatstr)); - } - - if (memcmp(buf, checkchars, numchars*2) != 0) - { - buf[numchars] = 0; - - Fail("ERROR: scanned wide character(s) incorrectly from \"%s\" using \"%s\".\n" - "Expected %s, got %s.\n", convertC(inputstr), - convertC(formatstr), convertC(checkchars), - convertC(buf)); - } - - if (buf[numchars] != (WCHAR)-1) - { - Fail("ERROR: overflow occurred in scanning wide character(s) from \"%s\" " - "using \"%s\".\nExpected %d character(s)\n", - convertC(inputstr), convertC(formatstr), numchars); - } -} - - -void DoFloatTest(WCHAR *inputstr, const WCHAR *formatstr, float checkval) -{ - char buf[256] = { 0 }; - float val; - int ret; - int i; - - for (i=0; i<256; i++) - buf[i] = (char)-1; - - ret = swscanf(inputstr, formatstr, buf); - val = *(float*)buf; - - if (ret != 1) - { - Fail("ERROR: Expected swscanf to return 1, got %d.\n" - "Using \"%s\" in \"%s\".\n", ret, convertC(inputstr), - convertC(formatstr)); - } - - if (val != checkval) - { - Fail("ERROR: scanned float incorrectly from \"%s\" using \"%s\".\n" - "Expected \"%f\", got \"%f\".\n", convertC(inputstr), - convertC(formatstr), checkval, val); - } - - if (buf[4] != (char)-1) - { - Fail("ERROR: overflow occurred in scanning float from \"%s\" " - "using \"%s\".\n", convertC(inputstr), convertC(formatstr)); - - } -} - - -#endif diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/swscanf/test1/CMakeLists.txt deleted file mode 100644 index ae2366e81..000000000 --- a/src/pal/tests/palsuite/c_runtime/swscanf/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_swscanf_test1 - ${SOURCES} -) - -add_dependencies(paltest_swscanf_test1 coreclrpal) - -target_link_libraries(paltest_swscanf_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/swscanf/test1/test1.cpp deleted file mode 100644 index 66136e57c..000000000 --- a/src/pal/tests/palsuite/c_runtime/swscanf/test1/test1.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: General test of swscanf -** -** -**==========================================================================*/ - - - -#include -#include "../swscanf.h" - - -int __cdecl main(int argc, char *argv[]) -{ - int num; - int ret; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - DoVoidTest(convert("foo bar"), convert("foo")); - DoVoidTest(convert("foo bar"), convert("baz")); - DoVoidTest(convert("foo bar"), convert("foo %*s")); - - DoStrTest(convert("foo % bar"), convert("foo %% %S"), "bar"); - DoStrTest(convert("foo bar baz"), convert("foo %bar %S"), "baz"); - - DoVoidTest(convert("foo bar baz"), convert("foo % bar %S")); - DoVoidTest(convert("foo bar baz"), convert("foo% bar %S")); - - - ret = swscanf(convert("foo bar baz"), convert("foo bar %n"), &num); - if (ret != 0 || num != 8) - { - Fail("ERROR: Got incorrect values in scanning \"%s\" using \"%s\".\n" - "Expected to get a value of %d with return value of %d, " - "got %d with return %d\n", "foo bar baz", "foo bar %n", 8, 0, - num, ret); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/swscanf/test1/testinfo.dat deleted file mode 100644 index b6366a73d..000000000 --- a/src/pal/tests/palsuite/c_runtime/swscanf/test1/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = swscanf -Name = Positive Test for swscanf -TYPE = DEFAULT -EXE1 = test1 -Description -= General test of swscanf diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test10/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/swscanf/test10/CMakeLists.txt deleted file mode 100644 index 313b4f469..000000000 --- a/src/pal/tests/palsuite/c_runtime/swscanf/test10/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test10.cpp -) - -add_executable(paltest_swscanf_test10 - ${SOURCES} -) - -add_dependencies(paltest_swscanf_test10 coreclrpal) - -target_link_libraries(paltest_swscanf_test10 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test10/test10.cpp b/src/pal/tests/palsuite/c_runtime/swscanf/test10/test10.cpp deleted file mode 100644 index a8628e0de..000000000 --- a/src/pal/tests/palsuite/c_runtime/swscanf/test10/test10.cpp +++ /dev/null @@ -1,36 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test10.c -** -** Purpose:Tests swscanf with wide characters -** -** -**==========================================================================*/ - - - -#include -#include "../swscanf.h" - -int __cdecl main(int argc, char *argv[]) -{ - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - DoCharTest(convert("1234"), convert("%C"), "1", 1); - DoCharTest(convert("abc"), convert("%2C"), "ab", 2); - DoCharTest(convert(" ab"), convert("%C"), " ", 1); - DoCharTest(convert("ab"), convert("%hC"), "a", 1); - DoWCharTest(convert("ab"), convert("%lC"), convert("a"), 1); - DoCharTest(convert("ab"), convert("%LC"), "a", 1); - DoCharTest(convert("ab"), convert("%I64C"), "a", 1); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test10/testinfo.dat b/src/pal/tests/palsuite/c_runtime/swscanf/test10/testinfo.dat deleted file mode 100644 index 2f8890db2..000000000 --- a/src/pal/tests/palsuite/c_runtime/swscanf/test10/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = swscanf -Name = Positive Test for swscanf -TYPE = DEFAULT -EXE1 = test10 -Description -= Tests swscanf with wide characters diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test11/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/swscanf/test11/CMakeLists.txt deleted file mode 100644 index 79703e598..000000000 --- a/src/pal/tests/palsuite/c_runtime/swscanf/test11/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test11.cpp -) - -add_executable(paltest_swscanf_test11 - ${SOURCES} -) - -add_dependencies(paltest_swscanf_test11 coreclrpal) - -target_link_libraries(paltest_swscanf_test11 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test11/test11.cpp b/src/pal/tests/palsuite/c_runtime/swscanf/test11/test11.cpp deleted file mode 100644 index f7eb4af46..000000000 --- a/src/pal/tests/palsuite/c_runtime/swscanf/test11/test11.cpp +++ /dev/null @@ -1,35 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test11.c -** -** Purpose: Tests swscanf with strings -** -** -**==========================================================================*/ - - - -#include -#include "../swscanf.h" - -int __cdecl main(int argc, char *argv[]) -{ - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - DoWStrTest(convert("foo bar"), convert("foo %s"), convert("bar")); - DoWStrTest(convert("foo bar"), convert("foo %2s"), convert("ba")); - DoStrTest(convert("foo bar"), convert("foo %hs"), "bar"); - DoWStrTest(convert("foo bar"), convert("foo %ls"), convert("bar")); - DoWStrTest(convert("foo bar"), convert("foo %Ls"), convert("bar")); - DoWStrTest(convert("foo bar"), convert("foo %I64s"), convert("bar")); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test11/testinfo.dat b/src/pal/tests/palsuite/c_runtime/swscanf/test11/testinfo.dat deleted file mode 100644 index 5bbc2e433..000000000 --- a/src/pal/tests/palsuite/c_runtime/swscanf/test11/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = swscanf -Name = Positive Test for swscanf -TYPE = DEFAULT -EXE1 = test11 -Description -= Tests swscanf with strings diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test12/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/swscanf/test12/CMakeLists.txt deleted file mode 100644 index 8c6754f44..000000000 --- a/src/pal/tests/palsuite/c_runtime/swscanf/test12/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test12.cpp -) - -add_executable(paltest_swscanf_test12 - ${SOURCES} -) - -add_dependencies(paltest_swscanf_test12 coreclrpal) - -target_link_libraries(paltest_swscanf_test12 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test12/test12.cpp b/src/pal/tests/palsuite/c_runtime/swscanf/test12/test12.cpp deleted file mode 100644 index f5f8bbdf8..000000000 --- a/src/pal/tests/palsuite/c_runtime/swscanf/test12/test12.cpp +++ /dev/null @@ -1,35 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test12.c -** -** Purpose: Tests swscanf with wide strings -** -** -**==========================================================================*/ - - - -#include -#include "../swscanf.h" - -int __cdecl main(int argc, char *argv[]) -{ - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - DoStrTest(convert("foo bar"), convert("foo %S"), "bar"); - DoStrTest(convert("foo bar"), convert("foo %2S"), "ba"); - DoStrTest(convert("foo bar"), convert("foo %hS"), "bar"); - DoWStrTest(convert("foo bar"), convert("foo %lS"), convert("bar")); - DoStrTest(convert("foo bar"), convert("foo %LS"), "bar"); - DoStrTest(convert("foo bar"), convert("foo %I64S"), "bar"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test12/testinfo.dat b/src/pal/tests/palsuite/c_runtime/swscanf/test12/testinfo.dat deleted file mode 100644 index 06bf26af9..000000000 --- a/src/pal/tests/palsuite/c_runtime/swscanf/test12/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = swscanf -Name = Positive Test for swscanf -TYPE = DEFAULT -EXE1 = test12 -Description -= Tests swscanf with wide strings diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test13/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/swscanf/test13/CMakeLists.txt deleted file mode 100644 index 8072390bd..000000000 --- a/src/pal/tests/palsuite/c_runtime/swscanf/test13/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test13.cpp -) - -add_executable(paltest_swscanf_test13 - ${SOURCES} -) - -add_dependencies(paltest_swscanf_test13 coreclrpal) - -target_link_libraries(paltest_swscanf_test13 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test13/test13.cpp b/src/pal/tests/palsuite/c_runtime/swscanf/test13/test13.cpp deleted file mode 100644 index 1bb0b7b21..000000000 --- a/src/pal/tests/palsuite/c_runtime/swscanf/test13/test13.cpp +++ /dev/null @@ -1,37 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test13.c -** -** Purpose: Tests swscanf with floats (decimal notation) -** -** -**==========================================================================*/ - - - -#include -#include "../swscanf.h" - -int __cdecl main(int argc, char *argv[]) -{ - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - DoFloatTest(convert("123.0"), convert("%f"), 123.0f); - DoFloatTest(convert("123.0"), convert("%2f"), 12.0f); - DoFloatTest(convert("10E1"), convert("%f"), 100.0f); - DoFloatTest(convert("-12.01e-2"), convert("%f"), -0.1201f); - DoFloatTest(convert("+12.01e-2"), convert("%f"), 0.1201f); - DoFloatTest(convert("-12.01e+2"), convert("%f"), -1201.0f); - DoFloatTest(convert("+12.01e+2"), convert("%f"), 1201.0f); - DoFloatTest(convert("1234567890.0123456789f"), convert("%f"), 1234567936); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test13/testinfo.dat b/src/pal/tests/palsuite/c_runtime/swscanf/test13/testinfo.dat deleted file mode 100644 index a3c01c5d7..000000000 --- a/src/pal/tests/palsuite/c_runtime/swscanf/test13/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = swscanf -Name = Positive Test for swscanf -TYPE = DEFAULT -EXE1 = test13 -Description -= Tests swscanf with floats (decimal notation) diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test14/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/swscanf/test14/CMakeLists.txt deleted file mode 100644 index 723b68f44..000000000 --- a/src/pal/tests/palsuite/c_runtime/swscanf/test14/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test14.cpp -) - -add_executable(paltest_swscanf_test14 - ${SOURCES} -) - -add_dependencies(paltest_swscanf_test14 coreclrpal) - -target_link_libraries(paltest_swscanf_test14 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test14/test14.cpp b/src/pal/tests/palsuite/c_runtime/swscanf/test14/test14.cpp deleted file mode 100644 index 80581b726..000000000 --- a/src/pal/tests/palsuite/c_runtime/swscanf/test14/test14.cpp +++ /dev/null @@ -1,38 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test14.c -** -** Purpose: Tests swscanf with floats (exponential notation, lowercase) -** -** -**==========================================================================*/ - - - -#include -#include "../swscanf.h" - - -int __cdecl main(int argc, char *argv[]) -{ - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - DoFloatTest(convert("123.0"), convert("%e"), 123.0f); - DoFloatTest(convert("123.0"), convert("%2e"), 12.0f); - DoFloatTest(convert("10E1"), convert("%e"), 100.0f); - DoFloatTest(convert("-12.01e-2"), convert("%e"), -0.1201f); - DoFloatTest(convert("+12.01e-2"), convert("%e"), 0.1201f); - DoFloatTest(convert("-12.01e+2"), convert("%e"), -1201.0f); - DoFloatTest(convert("+12.01e+2"), convert("%e"), 1201.0f); - DoFloatTest(convert("1234567890.0123456789f"), convert("%e"), 1234567936); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test14/testinfo.dat b/src/pal/tests/palsuite/c_runtime/swscanf/test14/testinfo.dat deleted file mode 100644 index 184a3e7fb..000000000 --- a/src/pal/tests/palsuite/c_runtime/swscanf/test14/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = swscanf -Name = Positive Test for swscanf -TYPE = DEFAULT -EXE1 = test14 -Description -= Tests swscanf with floats (exponential notation, lowercase) diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test15/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/swscanf/test15/CMakeLists.txt deleted file mode 100644 index e0b7fd8d2..000000000 --- a/src/pal/tests/palsuite/c_runtime/swscanf/test15/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test15.cpp -) - -add_executable(paltest_swscanf_test15 - ${SOURCES} -) - -add_dependencies(paltest_swscanf_test15 coreclrpal) - -target_link_libraries(paltest_swscanf_test15 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test15/test15.cpp b/src/pal/tests/palsuite/c_runtime/swscanf/test15/test15.cpp deleted file mode 100644 index 9b7d277e1..000000000 --- a/src/pal/tests/palsuite/c_runtime/swscanf/test15/test15.cpp +++ /dev/null @@ -1,37 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test15.c -** -** Purpose: Tests swscanf with floats (exponential notation, uppercase) -** -** -**==========================================================================*/ - - - -#include -#include "../swscanf.h" - -int __cdecl main(int argc, char *argv[]) -{ - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - DoFloatTest(convert("123.0"), convert("%E"), 123.0f); - DoFloatTest(convert("123.0"), convert("%2E"), 12.0f); - DoFloatTest(convert("10E1"), convert("%E"), 100.0f); - DoFloatTest(convert("-12.01e-2"), convert("%E"), -0.1201f); - DoFloatTest(convert("+12.01e-2"), convert("%E"), 0.1201f); - DoFloatTest(convert("-12.01e+2"), convert("%E"), -1201.0f); - DoFloatTest(convert("+12.01e+2"), convert("%E"), 1201.0f); - DoFloatTest(convert("1234567890.0123456789f"), convert("%E"), 1234567936); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test15/testinfo.dat b/src/pal/tests/palsuite/c_runtime/swscanf/test15/testinfo.dat deleted file mode 100644 index ab20463ec..000000000 --- a/src/pal/tests/palsuite/c_runtime/swscanf/test15/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = swscanf -Name = Positive Test for swscanf -TYPE = DEFAULT -EXE1 = test15 -Description -= Tests swscanf with floats (exponential notation, uppercase) diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test16/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/swscanf/test16/CMakeLists.txt deleted file mode 100644 index a593fd119..000000000 --- a/src/pal/tests/palsuite/c_runtime/swscanf/test16/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test16.cpp -) - -add_executable(paltest_swscanf_test16 - ${SOURCES} -) - -add_dependencies(paltest_swscanf_test16 coreclrpal) - -target_link_libraries(paltest_swscanf_test16 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test16/test16.cpp b/src/pal/tests/palsuite/c_runtime/swscanf/test16/test16.cpp deleted file mode 100644 index c83b64468..000000000 --- a/src/pal/tests/palsuite/c_runtime/swscanf/test16/test16.cpp +++ /dev/null @@ -1,37 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test16.c -** -** Purpose: Tests swscanf with floats (compact notation, lowercase) -** -** -**==========================================================================*/ - - - -#include -#include "../swscanf.h" - -int __cdecl main(int argc, char *argv[]) -{ - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - DoFloatTest(convert("123.0"), convert("%g"), 123.0f); - DoFloatTest(convert("123.0"), convert("%2g"), 12.0f); - DoFloatTest(convert("10E1"), convert("%g"), 100.0f); - DoFloatTest(convert("-12.01e-2"), convert("%g"), -0.1201f); - DoFloatTest(convert("+12.01e-2"), convert("%g"), 0.1201f); - DoFloatTest(convert("-12.01e+2"), convert("%g"), -1201.0f); - DoFloatTest(convert("+12.01e+2"), convert("%g"), 1201.0f); - DoFloatTest(convert("1234567890.0123456789f"), convert("%g"), 1234567936); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test16/testinfo.dat b/src/pal/tests/palsuite/c_runtime/swscanf/test16/testinfo.dat deleted file mode 100644 index 0cfa37d63..000000000 --- a/src/pal/tests/palsuite/c_runtime/swscanf/test16/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = swscanf -Name = Positive Test for swscanf -TYPE = DEFAULT -EXE1 = test16 -Description -= Tests swscanf with floats (compact notation, lowercase) diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test17/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/swscanf/test17/CMakeLists.txt deleted file mode 100644 index 890d9a4e6..000000000 --- a/src/pal/tests/palsuite/c_runtime/swscanf/test17/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test17.cpp -) - -add_executable(paltest_swscanf_test17 - ${SOURCES} -) - -add_dependencies(paltest_swscanf_test17 coreclrpal) - -target_link_libraries(paltest_swscanf_test17 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test17/test17.cpp b/src/pal/tests/palsuite/c_runtime/swscanf/test17/test17.cpp deleted file mode 100644 index 9023f7020..000000000 --- a/src/pal/tests/palsuite/c_runtime/swscanf/test17/test17.cpp +++ /dev/null @@ -1,37 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test17.c -** -** Purpose: Tests swscanf with floats (compact notation, uppercase) -** -** -**==========================================================================*/ - - - -#include -#include "../swscanf.h" - -int __cdecl main(int argc, char *argv[]) -{ - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - DoFloatTest(convert("123.0"), convert("%G"), 123.0f); - DoFloatTest(convert("123.0"), convert("%2G"), 12.0f); - DoFloatTest(convert("10E1"), convert("%G"), 100.0f); - DoFloatTest(convert("-12.01e-2"), convert("%G"), -0.1201f); - DoFloatTest(convert("+12.01e-2"), convert("%G"), 0.1201f); - DoFloatTest(convert("-12.01e+2"), convert("%G"), -1201.0f); - DoFloatTest(convert("+12.01e+2"), convert("%G"), 1201.0f); - DoFloatTest(convert("1234567890.0123456789f"), convert("%G"), 1234567936); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test17/testinfo.dat b/src/pal/tests/palsuite/c_runtime/swscanf/test17/testinfo.dat deleted file mode 100644 index f0489dfa4..000000000 --- a/src/pal/tests/palsuite/c_runtime/swscanf/test17/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = swscanf -Name = Positive Test for swscanf -TYPE = DEFAULT -EXE1 = test17 -Description -= Tests swscanf with floats (compact notation, uppercase) diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test2/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/swscanf/test2/CMakeLists.txt deleted file mode 100644 index e6d17b385..000000000 --- a/src/pal/tests/palsuite/c_runtime/swscanf/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test2.cpp -) - -add_executable(paltest_swscanf_test2 - ${SOURCES} -) - -add_dependencies(paltest_swscanf_test2 coreclrpal) - -target_link_libraries(paltest_swscanf_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test2/test2.cpp b/src/pal/tests/palsuite/c_runtime/swscanf/test2/test2.cpp deleted file mode 100644 index 8fbd3f86b..000000000 --- a/src/pal/tests/palsuite/c_runtime/swscanf/test2/test2.cpp +++ /dev/null @@ -1,43 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test2.c -** -** Purpose: Test to see if swscanf handles whitespace correctly -** -** -**==========================================================================*/ - - - -#include -#include "../swscanf.h" - -/* - * Tests out how it handles whitespace. Seems to accept anything that qualifies - * as isspace (space, tab, vertical tab, line feed, carriage return and form - * feed), even if it says it only wants spaces tabs and newlines. - */ - -int __cdecl main(int argc, char *argv[]) -{ - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - DoStrTest(convert("foo bar"), convert("foo %S"), "bar"); - DoStrTest(convert("foo\tbar"), convert("foo %S"), "bar"); - DoStrTest(convert("foo\nbar"), convert("foo %S"), "bar"); - DoStrTest(convert("foo\rbar"), convert("foo %S"), "bar"); - DoStrTest(convert("foo\vbar"), convert("foo %S"), "bar"); - DoStrTest(convert("foo\fbar"), convert("foo %S"), "bar"); - DoStrTest(convert("foo \t\n\r\v\fbar"), convert("foo %S"), "bar"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test2/testinfo.dat b/src/pal/tests/palsuite/c_runtime/swscanf/test2/testinfo.dat deleted file mode 100644 index 88768ca46..000000000 --- a/src/pal/tests/palsuite/c_runtime/swscanf/test2/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = swscanf -Name = Positive Test for swscanf -TYPE = DEFAULT -EXE1 = test2 -Description -= Test to see if swscanf handles whitespace correctly diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test3/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/swscanf/test3/CMakeLists.txt deleted file mode 100644 index 72be68114..000000000 --- a/src/pal/tests/palsuite/c_runtime/swscanf/test3/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test3.cpp -) - -add_executable(paltest_swscanf_test3 - ${SOURCES} -) - -add_dependencies(paltest_swscanf_test3 coreclrpal) - -target_link_libraries(paltest_swscanf_test3 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test3/test3.cpp b/src/pal/tests/palsuite/c_runtime/swscanf/test3/test3.cpp deleted file mode 100644 index 8b05df20f..000000000 --- a/src/pal/tests/palsuite/c_runtime/swscanf/test3/test3.cpp +++ /dev/null @@ -1,36 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test3.c -** -** Purpose: Tests swscanf with bracketed set strings -** -** -**==========================================================================*/ - - - -#include -#include "../swscanf.h" - - -int __cdecl main(int argc, char *argv[]) -{ - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - DoWStrTest(convert("bar1"), convert("%[a-z]"), convert("bar")); - DoWStrTest(convert("bar1"), convert("%[z-a]"), convert("bar")); - DoWStrTest(convert("bar1"), convert("%[ab]"), convert("ba")); - DoWStrTest(convert("bar1"), convert("%[ar1b]"), convert("bar1")); - DoWStrTest(convert("bar1"), convert("%[^4]"), convert("bar1")); - DoWStrTest(convert("bar1"), convert("%[^4a]"), convert("b")); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test3/testinfo.dat b/src/pal/tests/palsuite/c_runtime/swscanf/test3/testinfo.dat deleted file mode 100644 index 998cba8b6..000000000 --- a/src/pal/tests/palsuite/c_runtime/swscanf/test3/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = swscanf -Name = Positive Test for swscanf -TYPE = DEFAULT -EXE1 = test3 -Description -= Tests swscanf with bracketed set strings diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test4/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/swscanf/test4/CMakeLists.txt deleted file mode 100644 index 3581ec141..000000000 --- a/src/pal/tests/palsuite/c_runtime/swscanf/test4/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test4.cpp -) - -add_executable(paltest_swscanf_test4 - ${SOURCES} -) - -add_dependencies(paltest_swscanf_test4 coreclrpal) - -target_link_libraries(paltest_swscanf_test4 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test4/test4.cpp b/src/pal/tests/palsuite/c_runtime/swscanf/test4/test4.cpp deleted file mode 100644 index d63d25b7d..000000000 --- a/src/pal/tests/palsuite/c_runtime/swscanf/test4/test4.cpp +++ /dev/null @@ -1,44 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test4.c -** -** Purpose:Tests swscanf with decimal numbers -** -** -**==========================================================================*/ - - - -#include -#include "../swscanf.h" - - -int __cdecl main(int argc, char *argv[]) -{ - int n65535 = 65535; /* Walkaround compiler strictness */ - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - DoNumTest(convert("1234d"), convert("%d"), 1234); - DoNumTest(convert("1234d"), convert("%2d"), 12); - DoNumTest(convert("-1"), convert("%d"), -1); - DoNumTest(convert("0x1234"), convert("%d"), 0); - DoNumTest(convert("012"), convert("%d"), 12); - DoShortNumTest(convert("-1"), convert("%hd"), n65535); - DoShortNumTest(convert("65536"), convert("%hd"), 0); - DoNumTest(convert("-1"), convert("%ld"), -1); - DoNumTest(convert("65536"), convert("%ld"), 65536); - DoNumTest(convert("-1"), convert("%Ld"), -1); - DoNumTest(convert("65536"), convert("%Ld"), 65536); - DoI64NumTest(convert("4294967296"), convert("%I64d"), I64(4294967296)); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test4/testinfo.dat b/src/pal/tests/palsuite/c_runtime/swscanf/test4/testinfo.dat deleted file mode 100644 index e6102872d..000000000 --- a/src/pal/tests/palsuite/c_runtime/swscanf/test4/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = swscanf -Name = Positive Test for swscanf -TYPE = DEFAULT -EXE1 = test4 -Description -= Tests swscanf with decimal numbers diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test5/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/swscanf/test5/CMakeLists.txt deleted file mode 100644 index 8ade17ac6..000000000 --- a/src/pal/tests/palsuite/c_runtime/swscanf/test5/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test5.cpp -) - -add_executable(paltest_swscanf_test5 - ${SOURCES} -) - -add_dependencies(paltest_swscanf_test5 coreclrpal) - -target_link_libraries(paltest_swscanf_test5 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test5/test5.cpp b/src/pal/tests/palsuite/c_runtime/swscanf/test5/test5.cpp deleted file mode 100644 index 8ae2d81da..000000000 --- a/src/pal/tests/palsuite/c_runtime/swscanf/test5/test5.cpp +++ /dev/null @@ -1,44 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test5.c -** -** Purpose: Tests swscanf with integer numbers -** -** -**==========================================================================*/ - - - -#include -#include "../swscanf.h" - - -int __cdecl main(int argc, char *argv[]) -{ - int n65535 = 65535; /* Walkaround compiler strictness */ - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - DoNumTest(convert("1234d"), convert("%i"), 1234); - DoNumTest(convert("1234d"), convert("%2i"), 12); - DoNumTest(convert("-1"), convert("%i"), -1); - DoNumTest(convert("0x1234"), convert("%i"), 0x1234); - DoNumTest(convert("012"), convert("%i"), 10); - DoShortNumTest(convert("-1"), convert("%hi"), n65535); - DoShortNumTest(convert("65536"), convert("%hi"), 0); - DoNumTest(convert("-1"), convert("%li"), -1); - DoNumTest(convert("65536"), convert("%li"), 65536); - DoNumTest(convert("-1"), convert("%Li"), -1); - DoNumTest(convert("65536"), convert("%Li"), 65536); - DoI64NumTest(convert("4294967296"), convert("%I64i"), I64(4294967296)); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test5/testinfo.dat b/src/pal/tests/palsuite/c_runtime/swscanf/test5/testinfo.dat deleted file mode 100644 index 999128640..000000000 --- a/src/pal/tests/palsuite/c_runtime/swscanf/test5/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = swscanf -Name = Positive Test for swscanf -TYPE = DEFAULT -EXE1 = test5 -Description -= Tests swscanf with integer numbers diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test6/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/swscanf/test6/CMakeLists.txt deleted file mode 100644 index d43cc30a7..000000000 --- a/src/pal/tests/palsuite/c_runtime/swscanf/test6/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test6.cpp -) - -add_executable(paltest_swscanf_test6 - ${SOURCES} -) - -add_dependencies(paltest_swscanf_test6 coreclrpal) - -target_link_libraries(paltest_swscanf_test6 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test6/test6.cpp b/src/pal/tests/palsuite/c_runtime/swscanf/test6/test6.cpp deleted file mode 100644 index 982f799cf..000000000 --- a/src/pal/tests/palsuite/c_runtime/swscanf/test6/test6.cpp +++ /dev/null @@ -1,44 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test6.c -** -** Purpose:Tests swscanf with octal numbers -** -** -**==========================================================================*/ - - - -#include -#include "../swscanf.h" - - -int __cdecl main(int argc, char *argv[]) -{ - int n65535 = 65535; /* Walkaround compiler strictness */ - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - DoNumTest(convert("1234d"), convert("%o"), 668); - DoNumTest(convert("1234d"), convert("%2o"), 10); - DoNumTest(convert("-1"), convert("%o"), -1); - DoNumTest(convert("0x1234"), convert("%o"), 0); - DoNumTest(convert("012"), convert("%o"), 10); - DoShortNumTest(convert("-1"), convert("%ho"), n65535); - DoShortNumTest(convert("200000"), convert("%ho"), 0); - DoNumTest(convert("-1"), convert("%lo"), -1); - DoNumTest(convert("200000"), convert("%lo"), 65536); - DoNumTest(convert("-1"), convert("%Lo"), -1); - DoNumTest(convert("200000"), convert("%Lo"), 65536); - DoI64NumTest(convert("40000000000"), convert("%I64o"), I64(4294967296)); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test6/testinfo.dat b/src/pal/tests/palsuite/c_runtime/swscanf/test6/testinfo.dat deleted file mode 100644 index ca7870e96..000000000 --- a/src/pal/tests/palsuite/c_runtime/swscanf/test6/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = swscanf -Name = Positive Test for swscanf -TYPE = DEFAULT -EXE1 = test6 -Description -= Tests swscanf with octal numbers diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test7/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/swscanf/test7/CMakeLists.txt deleted file mode 100644 index 3ac9f9d63..000000000 --- a/src/pal/tests/palsuite/c_runtime/swscanf/test7/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test7.cpp -) - -add_executable(paltest_swscanf_test7 - ${SOURCES} -) - -add_dependencies(paltest_swscanf_test7 coreclrpal) - -target_link_libraries(paltest_swscanf_test7 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test7/test7.cpp b/src/pal/tests/palsuite/c_runtime/swscanf/test7/test7.cpp deleted file mode 100644 index 45e940054..000000000 --- a/src/pal/tests/palsuite/c_runtime/swscanf/test7/test7.cpp +++ /dev/null @@ -1,44 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test7.c -** -** Purpose: Test #6 for the swscanf function -** -** -**==========================================================================*/ - - - -#include -#include "../swscanf.h" - - -int __cdecl main(int argc, char *argv[]) -{ - int n65535 = 65535; /* Walkaround compiler strictness */ - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - DoNumTest(convert("1234d"), convert("%x"), 0x1234d); - DoNumTest(convert("1234d"), convert("%2x"), 0x12); - DoNumTest(convert("-1"), convert("%x"), -1); - DoNumTest(convert("0x1234"), convert("%x"), 0x1234); - DoNumTest(convert("012"), convert("%x"), 0x12); - DoShortNumTest(convert("-1"), convert("%hx"), n65535); - DoShortNumTest(convert("10000"), convert("%hx"), 0); - DoNumTest(convert("-1"), convert("%lx"), -1); - DoNumTest(convert("10000"), convert("%lx"), 65536); - DoNumTest(convert("-1"), convert("%Lx"), -1); - DoNumTest(convert("10000"), convert("%Lx"), 65536); - DoI64NumTest(convert("100000000"), convert("%I64x"), I64(4294967296)); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test7/testinfo.dat b/src/pal/tests/palsuite/c_runtime/swscanf/test7/testinfo.dat deleted file mode 100644 index 43ff8108d..000000000 --- a/src/pal/tests/palsuite/c_runtime/swscanf/test7/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = swscanf -Name = Positive Test for swscanf -TYPE = DEFAULT -EXE1 = test7 -Description -= Tests swscanf with hex numbers (lowercase) diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test8/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/swscanf/test8/CMakeLists.txt deleted file mode 100644 index 4e312edc1..000000000 --- a/src/pal/tests/palsuite/c_runtime/swscanf/test8/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test8.cpp -) - -add_executable(paltest_swscanf_test8 - ${SOURCES} -) - -add_dependencies(paltest_swscanf_test8 coreclrpal) - -target_link_libraries(paltest_swscanf_test8 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test8/test8.cpp b/src/pal/tests/palsuite/c_runtime/swscanf/test8/test8.cpp deleted file mode 100644 index a244de748..000000000 --- a/src/pal/tests/palsuite/c_runtime/swscanf/test8/test8.cpp +++ /dev/null @@ -1,44 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test8.c -** -** Purpose: Tests swscanf with unsigned numbers -** -** -**==========================================================================*/ - - - -#include -#include "../swscanf.h" - - -int __cdecl main(int argc, char *argv[]) -{ - int n65535 = 65535; /* Walkaround compiler strictness */ - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - DoNumTest(convert("1234d"), convert("%u"), 1234); - DoNumTest(convert("1234d"), convert("%2u"), 12); - DoNumTest(convert("-1"), convert("%u"), -1); - DoNumTest(convert("0x1234"), convert("%u"), 0); - DoNumTest(convert("012"), convert("%u"), 12); - DoShortNumTest(convert("-1"), convert("%hu"), n65535); - DoShortNumTest(convert("65536"), convert("%hu"), 0); - DoNumTest(convert("-1"), convert("%lu"), -1); - DoNumTest(convert("65536"), convert("%lu"), 65536); - DoNumTest(convert("-1"), convert("%Lu"), -1); - DoNumTest(convert("65536"), convert("%Lu"), 65536); - DoI64NumTest(convert("4294967296"), convert("%I64u"), I64(4294967296)); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test8/testinfo.dat b/src/pal/tests/palsuite/c_runtime/swscanf/test8/testinfo.dat deleted file mode 100644 index 0edefb075..000000000 --- a/src/pal/tests/palsuite/c_runtime/swscanf/test8/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = swscanf -Name = Positive Test for swscanf -TYPE = DEFAULT -EXE1 = test8 -Description -= Tests swscanf with unsigned numbers diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test9/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/swscanf/test9/CMakeLists.txt deleted file mode 100644 index ca2128347..000000000 --- a/src/pal/tests/palsuite/c_runtime/swscanf/test9/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test9.cpp -) - -add_executable(paltest_swscanf_test9 - ${SOURCES} -) - -add_dependencies(paltest_swscanf_test9 coreclrpal) - -target_link_libraries(paltest_swscanf_test9 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test9/test9.cpp b/src/pal/tests/palsuite/c_runtime/swscanf/test9/test9.cpp deleted file mode 100644 index e289d26f5..000000000 --- a/src/pal/tests/palsuite/c_runtime/swscanf/test9/test9.cpp +++ /dev/null @@ -1,37 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test9.c -** -** Purpose: Tests swscanf with characters -** -** -**==========================================================================*/ - - - -#include -#include "../swscanf.h" - -int __cdecl main(int argc, char *argv[]) -{ - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - DoWCharTest(convert("1234"), convert("%c"), convert("1"), 1); - DoWCharTest(convert("1234"), convert("%c"), convert("1"), 1); - DoWCharTest(convert("abc"), convert("%2c"), convert("ab"), 2); - DoWCharTest(convert(" ab"), convert("%c"), convert(" "), 1); - DoCharTest(convert("ab"), convert("%hc"), "a", 1); - DoWCharTest(convert("ab"), convert("%lc"), convert("a"), 1); - DoWCharTest(convert("ab"), convert("%Lc"), convert("a"), 1); - DoWCharTest(convert("ab"), convert("%I64c"), convert("a"), 1); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/swscanf/test9/testinfo.dat b/src/pal/tests/palsuite/c_runtime/swscanf/test9/testinfo.dat deleted file mode 100644 index 955b62b12..000000000 --- a/src/pal/tests/palsuite/c_runtime/swscanf/test9/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = swscanf -Name = Positive Test for swscanf -TYPE = DEFAULT -EXE1 = test9 -Description -= Tests swscanf with characters diff --git a/src/pal/tests/palsuite/c_runtime/tan/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/tan/CMakeLists.txt deleted file mode 100644 index 5e1ef7f28..000000000 --- a/src/pal/tests/palsuite/c_runtime/tan/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) diff --git a/src/pal/tests/palsuite/c_runtime/tan/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/tan/test1/CMakeLists.txt deleted file mode 100644 index 64b90265b..000000000 --- a/src/pal/tests/palsuite/c_runtime/tan/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_tan_test1 - ${SOURCES} -) - -add_dependencies(paltest_tan_test1 coreclrpal) - -target_link_libraries(paltest_tan_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/tan/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/tan/test1/test1.cpp deleted file mode 100644 index 443e5da6d..000000000 --- a/src/pal/tests/palsuite/c_runtime/tan/test1/test1.cpp +++ /dev/null @@ -1,137 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================= -** -** Source: test1.c -** -** Purpose: Test to ensure that tan return the correct values -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** Fail -** fabs -** -**===========================================================================*/ - -#include - -// binary64 (double) has a machine epsilon of 2^-52 (approx. 2.22e-16). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-50 (approx. 8.88e-16) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (15-17 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxxxxxxxxxx will use -// PAL_EPSILON for the variance, while an expected result in the format of 0.0xxxxxxxxxxxxxxxxx -// will use PAL_EPSILON / 10 and and expected result in the format of x.xxxxxxxxxxxxxxxx will -// use PAL_EPSILON * 10. -#define PAL_EPSILON 8.8817841970012523e-16 - -#define PAL_NAN sqrt(-1.0) -#define PAL_POSINF -log(0.0) -#define PAL_NEGINF log(0.0) - -/** - * Helper test structure - */ -struct test -{ - double value; /* value to test the function with */ - double expected; /* expected result */ - double variance; /* maximum delta between the expected and actual result */ -}; - -/** - * validate - * - * test validation function - */ -void __cdecl validate(double value, double expected, double variance) -{ - double result = tan(value); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - double delta = fabs(result - expected); - - if (delta > variance) - { - Fail("tan(%g) returned %20.17g when it should have returned %20.17g", - value, result, expected); - } -} - -/** - * validate - * - * test validation function for values returning NaN - */ -void __cdecl validate_isnan(double value) -{ - double result = tan(value); - - if (!_isnan(result)) - { - Fail("tan(%g) returned %20.17g when it should have returned %20.17g", - value, result, PAL_NAN); - } -} - -/** - * main - * - * executable entry point - */ -int __cdecl main(int argc, char **argv) -{ - struct test tests[] = - { - /* value expected variance */ - { 0, 0, PAL_EPSILON }, - { 0.31830988618379067, 0.32951473309607836, PAL_EPSILON }, // value: 1 / pi - { 0.43429448190325183, 0.46382906716062964, PAL_EPSILON }, // value: log10(e) - { 0.63661977236758134, 0.73930295048660405, PAL_EPSILON }, // value: 2 / pi - { 0.69314718055994531, 0.83064087786078395, PAL_EPSILON }, // value: ln(2) - { 0.70710678118654752, 0.85451043200960189, PAL_EPSILON }, // value: 1 / sqrt(2) - { 0.78539816339744831, 1, PAL_EPSILON * 10 }, // value: pi / 4 - { 1, 1.5574077246549022, PAL_EPSILON * 10 }, - { 1.1283791670955126, 2.1108768356626451, PAL_EPSILON * 10 }, // value: 2 / sqrt(pi) - { 1.4142135623730950, 6.3341191670421916, PAL_EPSILON * 10 }, // value: sqrt(2) - { 1.4426950408889634, 7.7635756709721848, PAL_EPSILON * 10 }, // value: log2(e) - // SEE BELOW -- { 1.5707963267948966, PAL_POSINF, 0 }, // value: pi / 2 - { 2.3025850929940457, -1.1134071468135374, PAL_EPSILON * 10 }, // value: ln(10) - { 2.7182818284590452, -0.45054953406980750, PAL_EPSILON }, // value: e - { 3.1415926535897932, 0, PAL_EPSILON }, // value: pi - }; - - /* PAL initialization */ - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - validate( tests[i].value, tests[i].expected, tests[i].variance); - validate(-tests[i].value, -tests[i].expected, tests[i].variance); - } - - // -- SPECIAL CASE -- - // Normally, tan(pi / 2) would return PAL_POSINF (atan2(PAL_POSINF) does return (pi / 2)). - // However, it seems instead (on all supported systems), we get a different number entirely. - validate( 1.5707963267948966, 16331239353195370.0, 0); - validate(-1.5707963267948966, -16331239353195370.0, 0); - - validate_isnan(PAL_NEGINF); - validate_isnan(PAL_NAN); - validate_isnan(PAL_POSINF); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/tan/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/tan/test1/testinfo.dat deleted file mode 100644 index 05d6cfeb7..000000000 --- a/src/pal/tests/palsuite/c_runtime/tan/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = tan -Name = Positive Test for tan -TYPE = DEFAULT -EXE1 = test1 -Description -= Passes to tan() a series of angle value, checking that -= each one return to correct value. diff --git a/src/pal/tests/palsuite/c_runtime/tanf/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/tanf/CMakeLists.txt deleted file mode 100644 index 5e1ef7f28..000000000 --- a/src/pal/tests/palsuite/c_runtime/tanf/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) diff --git a/src/pal/tests/palsuite/c_runtime/tanf/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/tanf/test1/CMakeLists.txt deleted file mode 100644 index 6883041a2..000000000 --- a/src/pal/tests/palsuite/c_runtime/tanf/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.c -) - -add_executable(paltest_tanf_test1 - ${SOURCES} -) - -add_dependencies(paltest_tanf_test1 coreclrpal) - -target_link_libraries(paltest_tanf_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/tanf/test1/test1.c b/src/pal/tests/palsuite/c_runtime/tanf/test1/test1.c deleted file mode 100644 index 18d5c4e59..000000000 --- a/src/pal/tests/palsuite/c_runtime/tanf/test1/test1.c +++ /dev/null @@ -1,136 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================= -** -** Source: test1.c -** -** Purpose: Test to ensure that tanf return the correct values -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** Fail -** fabs -** -**===========================================================================*/ - -#include - -// binary32 (float) has a machine epsilon of 2^-23 (approx. 1.19e-07). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-21 (approx. 4.76e-07) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (6-9 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxx will use PAL_EPSILON -// for the variance, while an expected result in the format of 0.0xxxxxxxxx will use -// PAL_EPSILON / 10 and and expected result in the format of x.xxxxxx will use PAL_EPSILON * 10. -#define PAL_EPSILON 4.76837158e-07 - -#define PAL_NAN sqrtf(-1.0f) -#define PAL_POSINF -logf(0.0f) -#define PAL_NEGINF logf(0.0f) - -/** - * Helper test structure - */ -struct test -{ - float value; /* value to test the function with */ - float expected; /* expected result */ - float variance; /* maximum delta between the expected and actual result */ -}; - -/** - * validate - * - * test validation function - */ -void __cdecl validate(float value, float expected, float variance) -{ - float result = tanf(value); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - float delta = fabsf(result - expected); - - if (delta > variance) - { - Fail("tanf(%g) returned %10.9g when it should have returned %10.9g", - value, result, expected); - } -} - -/** - * validate - * - * test validation function for values returning NaN - */ -void __cdecl validate_isnan(float value) -{ - float result = tanf(value); - - if (!_isnanf(result)) - { - Fail("tanf(%g) returned %10.9g when it should have returned %10.9g", - value, result, PAL_NAN); - } -} - -/** - * main - * - * executable entry point - */ -int __cdecl main(int argc, char **argv) -{ - struct test tests[] = - { - /* value expected variance */ - { 0, 0, PAL_EPSILON }, - { 0.318309886f, 0.329514733f, PAL_EPSILON }, // value: 1 / pi - { 0.434294482f, 0.463829067f, PAL_EPSILON }, // value: log10f(e) - { 0.636619772f, 0.739302950f, PAL_EPSILON }, // value: 2 / pi - { 0.693147181f, 0.830640878f, PAL_EPSILON }, // value: ln(2) - { 0.707106781f, 0.854510432f, PAL_EPSILON }, // value: 1 / sqrtf(2) - { 0.785398163f, 1, PAL_EPSILON * 10 }, // value: pi / 4 - { 1, 1.55740772f, PAL_EPSILON * 10 }, - { 1.12837917f, 2.11087684f, PAL_EPSILON * 10 }, // value: 2 / sqrtf(pi) - { 1.41421356f, 6.33411917f, PAL_EPSILON * 10 }, // value: sqrtf(2) - { 1.44269504f, 7.76357567f, PAL_EPSILON * 10 }, // value: logf2(e) - // SEE BELOW -- { 1.57079633f, PAL_POSINF, 0 }, // value: pi / 2 - { 2.30258509f, -1.11340715f, PAL_EPSILON * 10 }, // value: ln(10) - { 2.71828183f, -0.450549534f, PAL_EPSILON }, // value: e - { 3.14159265f, 0, PAL_EPSILON }, // value: pi - }; - - /* PAL initialization */ - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - validate( tests[i].value, tests[i].expected, tests[i].variance); - validate(-tests[i].value, -tests[i].expected, tests[i].variance); - } - - // -- SPECIAL CASE -- - // Normally, tanf(pi / 2) would return PAL_POSINF (atan2f(PAL_POSINF) does return (pi / 2)). - // However, it seems instead (on all supported systems), we get a different number entirely. - validate( 1.57079633f, -22877332.0, PAL_EPSILON * 100000000); - validate(-1.57079633f, 22877332.0, PAL_EPSILON * 100000000); - - validate_isnan(PAL_NEGINF); - validate_isnan(PAL_NAN); - validate_isnan(PAL_POSINF); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/tanf/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/tanf/test1/testinfo.dat deleted file mode 100644 index aa33232ad..000000000 --- a/src/pal/tests/palsuite/c_runtime/tanf/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = tanf -Name = Positive Test for tanf -TYPE = DEFAULT -EXE1 = test1 -Description -= Passes to tanf() a series of angle value, checking that -= each one return to correct value. diff --git a/src/pal/tests/palsuite/c_runtime/tanh/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/tanh/CMakeLists.txt deleted file mode 100644 index 5e1ef7f28..000000000 --- a/src/pal/tests/palsuite/c_runtime/tanh/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) diff --git a/src/pal/tests/palsuite/c_runtime/tanh/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/tanh/test1/CMakeLists.txt deleted file mode 100644 index f8cb99c26..000000000 --- a/src/pal/tests/palsuite/c_runtime/tanh/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_tanh_test1 - ${SOURCES} -) - -add_dependencies(paltest_tanh_test1 coreclrpal) - -target_link_libraries(paltest_tanh_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/tanh/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/tanh/test1/test1.cpp deleted file mode 100644 index 3b8f87964..000000000 --- a/src/pal/tests/palsuite/c_runtime/tanh/test1/test1.cpp +++ /dev/null @@ -1,130 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================= -** -** Source: test1.c -** -** Purpose: Test to ensure that tanh return the correct values -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** Fail -** fabs -** -**===========================================================================*/ - -#include - -// binary64 (double) has a machine epsilon of 2^-52 (approx. 2.22e-16). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-50 (approx. 8.88e-16) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (15-17 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxxxxxxxxxx will use -// PAL_EPSILON for the variance, while an expected result in the format of 0.0xxxxxxxxxxxxxxxxx -// will use PAL_EPSILON / 10 and and expected result in the format of x.xxxxxxxxxxxxxxxx will -// use PAL_EPSILON * 10. -#define PAL_EPSILON 8.8817841970012523e-16 - -#define PAL_NAN sqrt(-1.0) -#define PAL_POSINF -log(0.0) -#define PAL_NEGINF log(0.0) - -/** - * Helper test structure - */ -struct test -{ - double value; /* value to test the function with */ - double expected; /* expected result */ - double variance; /* maximum delta between the expected and actual result */ -}; - -/** - * validate - * - * test validation function - */ -void __cdecl validate(double value, double expected, double variance) -{ - double result = tanh(value); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - double delta = fabs(result - expected); - - if (delta > variance) - { - Fail("tanh(%g) returned %20.17g when it should have returned %20.17g", - value, result, expected); - } -} - -/** - * validate - * - * test validation function for values returning NaN - */ -void __cdecl validate_isnan(double value) -{ - double result = tanh(value); - - if (!_isnan(result)) - { - Fail("tanh(%g) returned %20.17g when it should have returned %20.17g", - value, result, PAL_NAN); - } -} - -/** - * main - * - * executable entry point - */ -int __cdecl main(int argc, char **argv) -{ - struct test tests[] = - { - /* value expected variance */ - { 0, 0, PAL_EPSILON }, - { 0.31830988618379067, 0.30797791269089433, PAL_EPSILON }, // value: 1 / pi - { 0.43429448190325183, 0.40890401183401433, PAL_EPSILON }, // value: log10(e) - { 0.63661977236758134, 0.56259360033158334, PAL_EPSILON }, // value: 2 / pi - { 0.69314718055994531, 0.6, PAL_EPSILON }, // value: ln(2) - { 0.70710678118654752, 0.60885936501391381, PAL_EPSILON }, // value: 1 / sqrt(2) - { 0.78539816339744831, 0.65579420263267244, PAL_EPSILON }, // value: pi / 4 - { 1, 0.76159415595576489, PAL_EPSILON }, - { 1.1283791670955126, 0.81046380599898809, PAL_EPSILON }, // value: 2 / sqrt(pi) - { 1.4142135623730950, 0.88838556158566054, PAL_EPSILON }, // value: sqrt(2) - { 1.4426950408889634, 0.89423894585503855, PAL_EPSILON }, // value: log2(e) - { 1.5707963267948966, 0.91715233566727435, PAL_EPSILON }, // value: pi / 2 - { 2.3025850929940457, 0.98019801980198020, PAL_EPSILON }, // value: ln(10) - { 2.7182818284590452, 0.99132891580059984, PAL_EPSILON }, // value: e - { 3.1415926535897932, 0.99627207622074994, PAL_EPSILON }, // value: pi - { PAL_POSINF, 1, PAL_EPSILON * 10 } - }; - - /* PAL initialization */ - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - validate( tests[i].value, tests[i].expected, tests[i].variance); - validate(-tests[i].value, -tests[i].expected, tests[i].variance); - } - - validate_isnan(PAL_NAN); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/tanh/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/tanh/test1/testinfo.dat deleted file mode 100644 index 1b2bc91b2..000000000 --- a/src/pal/tests/palsuite/c_runtime/tanh/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = tanh -Name = Positive Test for tanh -TYPE = DEFAULT -EXE1 = test1 -Description -= Passes to tanh() a series of angle value, checking that -= each one return to correct value. diff --git a/src/pal/tests/palsuite/c_runtime/tanhf/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/tanhf/CMakeLists.txt deleted file mode 100644 index 5e1ef7f28..000000000 --- a/src/pal/tests/palsuite/c_runtime/tanhf/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) diff --git a/src/pal/tests/palsuite/c_runtime/tanhf/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/tanhf/test1/CMakeLists.txt deleted file mode 100644 index 83e2612fa..000000000 --- a/src/pal/tests/palsuite/c_runtime/tanhf/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.c -) - -add_executable(paltest_tanhf_test1 - ${SOURCES} -) - -add_dependencies(paltest_tanhf_test1 coreclrpal) - -target_link_libraries(paltest_tanhf_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/tanhf/test1/test1.c b/src/pal/tests/palsuite/c_runtime/tanhf/test1/test1.c deleted file mode 100644 index 904729a2c..000000000 --- a/src/pal/tests/palsuite/c_runtime/tanhf/test1/test1.c +++ /dev/null @@ -1,129 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================= -** -** Source: test1.c -** -** Purpose: Test to ensure that tanhf return the correct values -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** Fail -** fabs -** -**===========================================================================*/ - -#include - -// binary32 (float) has a machine epsilon of 2^-23 (approx. 1.19e-07). However, this -// is slightly too accurate when writing tests meant to run against libm implementations -// for various platforms. 2^-21 (approx. 4.76e-07) seems to be as accurate as we can get. -// -// The tests themselves will take PAL_EPSILON and adjust it according to the expected result -// so that the delta used for comparison will compare the most significant digits and ignore -// any digits that are outside the double precision range (6-9 digits). - -// For example, a test with an expect result in the format of 0.xxxxxxxxx will use PAL_EPSILON -// for the variance, while an expected result in the format of 0.0xxxxxxxxx will use -// PAL_EPSILON / 10 and and expected result in the format of x.xxxxxx will use PAL_EPSILON * 10. -#define PAL_EPSILON 4.76837158e-07 - -#define PAL_NAN sqrtf(-1.0f) -#define PAL_POSINF -logf(0.0f) -#define PAL_NEGINF logf(0.0f) - -/** - * Helper test structure - */ -struct test -{ - float value; /* value to test the function with */ - float expected; /* expected result */ - float variance; /* maximum delta between the expected and actual result */ -}; - -/** - * validate - * - * test validation function - */ -void __cdecl validate(float value, float expected, float variance) -{ - float result = tanhf(value); - - /* - * The test is valid when the difference between result - * and expected is less than or equal to variance - */ - float delta = fabsf(result - expected); - - if (delta > variance) - { - Fail("tanhf(%g) returned %10.9g when it should have returned %10.9g", - value, result, expected); - } -} - -/** - * validate - * - * test validation function for values returning NaN - */ -void __cdecl validate_isnan(float value) -{ - float result = tanhf(value); - - if (!_isnanf(result)) - { - Fail("tanhf(%g) returned %10.9g when it should have returned %10.9g", - value, result, PAL_NAN); - } -} - -/** - * main - * - * executable entry point - */ -int __cdecl main(int argc, char **argv) -{ - struct test tests[] = - { - /* value expected variance */ - { 0, 0, PAL_EPSILON }, - { 0.318309886f, 0.307977913f, PAL_EPSILON }, // value: 1 / pi - { 0.434294482f, 0.408904012f, PAL_EPSILON }, // value: log10f(e) - { 0.636619772f, 0.562593600f, PAL_EPSILON }, // value: 2 / pi - { 0.693147181f, 0.6f, PAL_EPSILON }, // value: ln(2) - { 0.707106781f, 0.608859365f, PAL_EPSILON }, // value: 1 / sqrtf(2) - { 0.785398163f, 0.655794203f, PAL_EPSILON }, // value: pi / 4 - { 1, 0.761594156f, PAL_EPSILON }, - { 1.12837917f, 0.810463806f, PAL_EPSILON }, // value: 2 / sqrtf(pi) - { 1.41421356f, 0.888385562f, PAL_EPSILON }, // value: sqrtf(2) - { 1.44269504f, 0.894238946f, PAL_EPSILON }, // value: logf2(e) - { 1.57079633f, 0.917152336f, PAL_EPSILON }, // value: pi / 2 - { 2.30258509f, 0.980198020f, PAL_EPSILON }, // value: ln(10) - { 2.71828183f, 0.991328916f, PAL_EPSILON }, // value: e - { 3.14159265f, 0.996272076f, PAL_EPSILON }, // value: pi - { PAL_POSINF, 1, PAL_EPSILON * 10 } - }; - - /* PAL initialization */ - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++) - { - validate( tests[i].value, tests[i].expected, tests[i].variance); - validate(-tests[i].value, -tests[i].expected, tests[i].variance); - } - - validate_isnan(PAL_NAN); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/tanhf/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/tanhf/test1/testinfo.dat deleted file mode 100644 index 6c7594fc5..000000000 --- a/src/pal/tests/palsuite/c_runtime/tanhf/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = tanhf -Name = Positive Test for tanhf -TYPE = DEFAULT -EXE1 = test1 -Description -= Passes to tanhf() a series of angle value, checking that -= each one return to correct value. diff --git a/src/pal/tests/palsuite/c_runtime/time/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/time/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/c_runtime/time/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/c_runtime/time/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/time/test1/CMakeLists.txt deleted file mode 100644 index d3605e8c7..000000000 --- a/src/pal/tests/palsuite/c_runtime/time/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_time_test1 - ${SOURCES} -) - -add_dependencies(paltest_time_test1 coreclrpal) - -target_link_libraries(paltest_time_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/time/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/time/test1/test1.cpp deleted file mode 100644 index c668bf38e..000000000 --- a/src/pal/tests/palsuite/c_runtime/time/test1/test1.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: Calls the time function and verifies that the time returned -** is at least a positive value. -** -** -**==========================================================================*/ - -#include - -int __cdecl main(int argc, char **argv) -{ - time_t t = 0; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - time(&t); - /*I was going to test that the time returned didn't exceed some - reasonable value, but decided not to, for fear of creating my own - little Y2K-style disaster.*/ - - if (t <= 0) - { - Fail("time() function doesn't return a time.\n"); - } - t = 0; - t = time(NULL); - if (t <= 0) - { - Fail("time() function doesn't return a time.\n"); - } - PAL_Terminate(); - return PASS; -} - - - - - - - diff --git a/src/pal/tests/palsuite/c_runtime/time/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/time/test1/testinfo.dat deleted file mode 100644 index 40134c762..000000000 --- a/src/pal/tests/palsuite/c_runtime/time/test1/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = time -Name = Positive Test for time -TYPE = DEFAULT -EXE1 = test1 -Description -= Calls the time function and verifies that the time returned is at -= least a positive value. - diff --git a/src/pal/tests/palsuite/c_runtime/tolower/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/tolower/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/c_runtime/tolower/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/c_runtime/tolower/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/tolower/test1/CMakeLists.txt deleted file mode 100644 index 90a3b9882..000000000 --- a/src/pal/tests/palsuite/c_runtime/tolower/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_tolower_test1 - ${SOURCES} -) - -add_dependencies(paltest_tolower_test1 coreclrpal) - -target_link_libraries(paltest_tolower_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/tolower/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/tolower/test1/test1.cpp deleted file mode 100644 index cab623d3f..000000000 --- a/src/pal/tests/palsuite/c_runtime/tolower/test1/test1.cpp +++ /dev/null @@ -1,79 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test1.c -** -** Purpose: Tests the PAL implementation of the tolower function. -** Check that the tolower function makes capital character -** lower case. Also check that it has no effect on lower -** case letters and special characters. -** -** -**===================================================================*/ - -#include - -struct testCase -{ - int lower; - int start; -}; - -int __cdecl main(int argc, char **argv) -{ - - int result; - int i; - - struct testCase testCases[] = - { - {'a', 'A'}, /* Basic cases */ - {'z', 'Z'}, - {'b', 'b'}, /* Lower case */ - {'?', '?'}, /* Characters without case */ - {230, 230} - }; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - /* Loop through each case. Convert each character to lower case - and then compare to ensure that it is the correct value. - */ - - for(i = 0; i < sizeof(testCases) / sizeof(struct testCase); i++) - { - /*Convert to lower case*/ - result = tolower(testCases[i].start); - - if (testCases[i].lower != result) - { - Fail("ERROR: tolower lowered \"%i\" to %i instead of %i.\n", - testCases[i].start, result, testCases[i].lower); - } - - } - - - PAL_Terminate(); - return PASS; -} - - - - - - - - - - - - - diff --git a/src/pal/tests/palsuite/c_runtime/tolower/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/tolower/test1/testinfo.dat deleted file mode 100644 index 90f1c729c..000000000 --- a/src/pal/tests/palsuite/c_runtime/tolower/test1/testinfo.dat +++ /dev/null @@ -1,19 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = tolower -Name = Positive Test for tolower -TYPE = DEFAULT -EXE1 = test1 -Description -= Tests the PAL implementation of the tolower function. -= Check that the tolower function makes capital character lower case. -= Also check that it has no effect on lower case letters and special -= characters. - - - - diff --git a/src/pal/tests/palsuite/c_runtime/toupper/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/toupper/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/c_runtime/toupper/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/c_runtime/toupper/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/toupper/test1/CMakeLists.txt deleted file mode 100644 index 2d6473118..000000000 --- a/src/pal/tests/palsuite/c_runtime/toupper/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_toupper_test1 - ${SOURCES} -) - -add_dependencies(paltest_toupper_test1 coreclrpal) - -target_link_libraries(paltest_toupper_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/toupper/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/toupper/test1/test1.cpp deleted file mode 100644 index c580699e3..000000000 --- a/src/pal/tests/palsuite/c_runtime/toupper/test1/test1.cpp +++ /dev/null @@ -1,64 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test1.c (toupper) -** -** -** Purpose: Tests the PAL implementation of the toupper function. -** Check that the toupper function makes lower case -** character a capital. Also check that it has no effect -** on upper case letters and special characters. -** -** -**===================================================================*/ - -#include - -struct testCase -{ - int upper; - int start; -}; - -int __cdecl main(int argc, char **argv) -{ - - int result; - int i; - - struct testCase testCases[] = - { - {'A', 'a'}, /* Basic cases */ - {'Z', 'z'}, - {'B', 'B'}, /* Upper case */ - {'%', '%'}, /* Characters without case */ - {157, 157} - }; - - if ((PAL_Initialize(argc, argv)) != 0) - { - return FAIL; - } - - - /* Loop through each case. Convert each character to upper case - and then compare to ensure that it is the correct value. - */ - for(i = 0; i < sizeof(testCases) / sizeof(struct testCase); i++) - { - /*Convert to upper case*/ - result = toupper(testCases[i].start); - - if (testCases[i].upper != result) - { - Fail("ERROR: toupper capitalized \"%c\" to %c instead of %c.\n", - testCases[i].start, result, testCases[i].upper); - } - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/toupper/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/toupper/test1/testinfo.dat deleted file mode 100644 index bde7affa4..000000000 --- a/src/pal/tests/palsuite/c_runtime/toupper/test1/testinfo.dat +++ /dev/null @@ -1,19 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = toupper -Name = Positive Test for toupper -TYPE = DEFAULT -EXE1 = test1 -Description -= Tests the PAL implementation of the toupper function. -= Check that the toupper function makes lower case character a capital. -= Also check that it has no effect on upper case letters and special -= characters. - - - - diff --git a/src/pal/tests/palsuite/c_runtime/towlower/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/towlower/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/c_runtime/towlower/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/c_runtime/towlower/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/towlower/test1/CMakeLists.txt deleted file mode 100644 index e5da389de..000000000 --- a/src/pal/tests/palsuite/c_runtime/towlower/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_towlower_test1 - ${SOURCES} -) - -add_dependencies(paltest_towlower_test1 coreclrpal) - -target_link_libraries(paltest_towlower_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/towlower/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/towlower/test1/test1.cpp deleted file mode 100644 index 5f2457a5f..000000000 --- a/src/pal/tests/palsuite/c_runtime/towlower/test1/test1.cpp +++ /dev/null @@ -1,79 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test1.c -** -** Purpose: Tests the PAL implementation of the towlower function. -** Check that the tolower function makes capital character -** lower case. Also check that it has no effect on lower -** case letters and special characters. -** -** -**===================================================================*/ - -#include - -struct testCase -{ - WCHAR lower; - WCHAR start; -}; - -int __cdecl main(int argc, char **argv) -{ - - int result; - int i; - - struct testCase testCases[] = - { - {'a', 'A'}, /* Basic cases */ - {'z', 'Z'}, - {'b', 'b'}, /* Lower case */ - {'?', '?'}, /* Characters without case */ - {230, 230} - }; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - /* Loop through each case. Convert each character to lower case - and then compare to ensure that it is the correct value. - */ - - for(i = 0; i < sizeof(testCases) / sizeof(struct testCase); i++) - { - /*Convert to lower case*/ - result = towlower(testCases[i].start); - - if (testCases[i].lower != result) - { - Fail("ERROR: towlower lowered \"%c\" to %c instead of %c.\n", - testCases[i].start, result, testCases[i].lower); - } - - } - - - PAL_Terminate(); - return PASS; -} - - - - - - - - - - - - - diff --git a/src/pal/tests/palsuite/c_runtime/towlower/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/towlower/test1/testinfo.dat deleted file mode 100644 index 2df179a8b..000000000 --- a/src/pal/tests/palsuite/c_runtime/towlower/test1/testinfo.dat +++ /dev/null @@ -1,19 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = towlower -Name = Positive Test for towlower -TYPE = DEFAULT -EXE1 = test1 -Description -= Tests the PAL implementation of the towlower function. -= Check that the tolower function makes capital character lower case. -= Also check that it has no effect on lower case letters and special -= characters. - - - - diff --git a/src/pal/tests/palsuite/c_runtime/towupper/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/towupper/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/c_runtime/towupper/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/c_runtime/towupper/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/towupper/test1/CMakeLists.txt deleted file mode 100644 index a09dca8f8..000000000 --- a/src/pal/tests/palsuite/c_runtime/towupper/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_towupper_test1 - ${SOURCES} -) - -add_dependencies(paltest_towupper_test1 coreclrpal) - -target_link_libraries(paltest_towupper_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/towupper/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/towupper/test1/test1.cpp deleted file mode 100644 index 63f051fa6..000000000 --- a/src/pal/tests/palsuite/c_runtime/towupper/test1/test1.cpp +++ /dev/null @@ -1,65 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test1.c(towupper) -** -** -** Purpose: Tests the PAL implementation of the towupper function. -** Check that the towupper function makes lower case -** character a capital. Also check that it has no effect -** on upper case letters and special characters. -** -** -**===================================================================*/ - -#include - -struct testCase -{ - WCHAR upper; - WCHAR start; -}; - -int __cdecl main(int argc, char **argv) -{ - - int result; - int i; - - struct testCase testCases[] = - { - {'A', 'a'}, /* Basic cases */ - {'Z', 'z'}, - {'B', 'B'}, /* Upper case */ - {'%', '%'}, /* Characters without case */ - {157, 157} - }; - - if ((PAL_Initialize(argc, argv)) != 0) - { - return FAIL; - } - - - /* Loop through each case. Convert each character to upper case - and then compare to ensure that it is the correct value. - */ - - for(i = 0; i < sizeof(testCases) / sizeof(struct testCase); i++) - { - /*Convert to upper case*/ - result = towupper(testCases[i].start); - - if (testCases[i].upper != result) - { - Fail("ERROR: towupper capitalized \"%c\" to %c instead of %c.\n", - testCases[i].start, result, testCases[i].upper); - } - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/towupper/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/towupper/test1/testinfo.dat deleted file mode 100644 index 40b6fadd5..000000000 --- a/src/pal/tests/palsuite/c_runtime/towupper/test1/testinfo.dat +++ /dev/null @@ -1,19 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = towupper -Name = Positive Test for towupper -TYPE = DEFAULT -EXE1 = test1 -Description -= Tests the PAL implementation of the towupper function. -= Check that the towupper function makes lower case character a capital. -= Also check that it has no effect on upper case letters and special -= characters. - - - - diff --git a/src/pal/tests/palsuite/c_runtime/ungetc/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/ungetc/CMakeLists.txt deleted file mode 100644 index ef14ea535..000000000 --- a/src/pal/tests/palsuite/c_runtime/ungetc/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) - diff --git a/src/pal/tests/palsuite/c_runtime/ungetc/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/ungetc/test1/CMakeLists.txt deleted file mode 100644 index 9db3fce59..000000000 --- a/src/pal/tests/palsuite/c_runtime/ungetc/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - ungetc.cpp -) - -add_executable(paltest_ungetc_test1 - ${SOURCES} -) - -add_dependencies(paltest_ungetc_test1 coreclrpal) - -target_link_libraries(paltest_ungetc_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/ungetc/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/ungetc/test1/testinfo.dat deleted file mode 100644 index 08d5b0699..000000000 --- a/src/pal/tests/palsuite/c_runtime/ungetc/test1/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = c_runtime -Function = ungetc -Name = test for ungetc (test 1) -Type = DEFAULT -EXE1 = ungetc -Description -= Test how ungetc handles a write-only file (should fail) diff --git a/src/pal/tests/palsuite/c_runtime/ungetc/test1/ungetc.cpp b/src/pal/tests/palsuite/c_runtime/ungetc/test1/ungetc.cpp deleted file mode 100644 index 397e42ac6..000000000 --- a/src/pal/tests/palsuite/c_runtime/ungetc/test1/ungetc.cpp +++ /dev/null @@ -1,130 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: ungetc.c (test 1) -** -** Purpose: Tests the PAL implementation of the ungetc function by calling -** the function on a write-only file. -** -** Dependencies: -** fopen -** fclose -** fseek -** -** -**===================================================================*/ - -#include - - -int __cdecl main(int argc, char *argv[]) -{ - char szFileName[] = {"test1.tmp"}; - const char text[] = - {"The quick brown fox jumped over the lazy dog's back."}; - FILE* pFile = NULL; - int nChar = 65; /* 'A' */ - int nRc = 0; - int itemsExpected; - int itemsWritten; - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - /* create the file */ - pFile = fopen(szFileName, "w"); - if (pFile == NULL) - { - Fail("ungetc: ERROR -> fopen failed to create the file \"%s\"" - " as write-only.\n", - szFileName); - } - - /* write to the file */ - itemsExpected = sizeof(text); - itemsWritten = fwrite(text, sizeof(text[0]), sizeof(text), pFile); - if (itemsWritten == 0) - { - Trace("ungetc: ERROR -> fwrite failed to write to the file \"%s\"\n", - szFileName); - - if (fclose(pFile) != 0) - { - Fail("ungetc: ERROR -> fclose failed to close the file.\n"); - } - Fail(""); - - } - else if (itemsWritten != itemsExpected) - { - Trace("ungetc: ERROR -> fwrite failed to write the correct number " - "of characters to the file \"%s\"\n", - szFileName); - - if (fclose(pFile) != 0) - { - Fail("ungetc: ERROR -> fclose failed to close the file.\n"); - } - Fail(""); - } - - /* Close the file */ - if (fclose(pFile) != 0) - { - Fail("ungetc: ERROR -> fclose failed to close the file.\n"); - } - - /* - ** open the file in write only mode and - ** attempt to push an unread character back on the stream - */ - - - /* open the file write-only */ - pFile = fopen(szFileName, "a"); - if (pFile == NULL) - { - Fail("ungetc: ERROR -> fopen failed to open the file \"%s\"" - " as write-only.\n", - szFileName); - } - - /* move the file pointer back to the beginning of the file */ - if (fseek(pFile, 1, SEEK_SET) != 0) - { - - Trace("ungetc: ERROR -> fseek failed to move the file pointer to the " - "beginning of the file.\n"); - if (fclose(pFile) != 0) - { - Trace("ungetc: ERROR -> fclose failed to close the file.\n"); - } - Fail(""); - } - - /* call ungetc on a write-only file which should fail */ - if ((nRc = ungetc(nChar, pFile)) != EOF) - { - Trace("ungetc: ERROR -> ungetc returned \"%c\" when run on " - "an write-only file.\n", nChar); - if (fclose(pFile) != 0) - { - Trace("ungetc: ERROR -> fclose failed to close the file.\n"); - } - Fail(""); - } - - if (fclose(pFile) != 0) - { - Fail("ungetc: ERROR -> fclose failed to close the file.\n"); - } - - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/ungetc/test2/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/ungetc/test2/CMakeLists.txt deleted file mode 100644 index f4a2c733d..000000000 --- a/src/pal/tests/palsuite/c_runtime/ungetc/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - ungetc.cpp -) - -add_executable(paltest_ungetc_test2 - ${SOURCES} -) - -add_dependencies(paltest_ungetc_test2 coreclrpal) - -target_link_libraries(paltest_ungetc_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/ungetc/test2/test2.txt b/src/pal/tests/palsuite/c_runtime/ungetc/test2/test2.txt deleted file mode 100644 index 96c906756..000000000 --- a/src/pal/tests/palsuite/c_runtime/ungetc/test2/test2.txt +++ /dev/null @@ -1 +0,0 @@ -foo bar \ No newline at end of file diff --git a/src/pal/tests/palsuite/c_runtime/ungetc/test2/testinfo.dat b/src/pal/tests/palsuite/c_runtime/ungetc/test2/testinfo.dat deleted file mode 100644 index b942c931f..000000000 --- a/src/pal/tests/palsuite/c_runtime/ungetc/test2/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = c_runtime -Function = ungetc -Name = test for ungetc (test 2) -Type = DEFAULT -EXE1 = ungetc -Description -= Push characters back onto the stream and verify diff --git a/src/pal/tests/palsuite/c_runtime/ungetc/test2/ungetc.cpp b/src/pal/tests/palsuite/c_runtime/ungetc/test2/ungetc.cpp deleted file mode 100644 index cbc8102ee..000000000 --- a/src/pal/tests/palsuite/c_runtime/ungetc/test2/ungetc.cpp +++ /dev/null @@ -1,188 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: ungetc.c (test 2) -** -** Purpose: Tests the PAL implementation of the ungetc function -** -** Dependencies: -** fopen -** fread -** fclose -** fseek -** getc -** -** -**===================================================================*/ - -#include - - -int __cdecl main(int argc, char *argv[]) -{ - const char szFileName[] = {"test2.txt"}; - const char szNewString[] = {"bar bar"}; - char szBuffer[MAX_PATH]; - FILE* pFile = NULL; - int nChar = 32; /* space */ - int i = 0; - int nRc = 0; - size_t nCount = 0; - - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - - memset(szBuffer, 0, MAX_PATH); - - /* - ** open the file in write only mode, populate it and - ** attempt to push an unread character back on the stream - */ - - - /* open the file for read */ - pFile = fopen(szFileName, "r"); - if (pFile == NULL) - { - Fail("ungetc: ERROR -> fopen failed to open the file \"%s\"" - " as read-only.n", - szFileName); - } - - - /* - ** Call getc to get the first char and ungetc to put - ** it back. getc should read it again. - */ - - /* read a character */ - if ((nChar = getc(pFile)) == EOF) - { - Trace("ungetc: ERROR -> getc encountered an error reading.\n"); - if (fclose(pFile) != 0) - { - Trace("ungetc: ERROR -> fclose failed to close the file.\n"); - } - Fail(""); - } - - /* put it back */ - if ((nRc = ungetc(nChar, pFile)) == EOF) - { - Trace("ungetc: ERROR -> ungetc failed to push '%c' back onto the" - " stream.\n"); - if (fclose(pFile) != 0) - { - Trace("ungetc: ERROR -> fclose failed to close the file.\n"); - } - Fail(""); - } - - /* read it again... hopefully */ - if (((nChar = getc(pFile)) == EOF) || (nChar != nRc)) - { - Trace("ungetc: ERROR -> getc encountered an error reading.\n"); - if (fclose(pFile) != 0) - { - Trace("ungetc: ERROR -> fclose failed to close the file.\n"); - } - Fail(""); - } - - /* - ** test multiple ungetcs by replacing "foo" in the stream with "bar" - */ - - /* move the file pointer back to the beginning of the file */ - if (fseek(pFile, 0, SEEK_SET) != 0) - { - Trace("ungetc: ERROR -> fseek failed to move the file pointer to the " - "beginning of the file. GetLastError returned %ld\n", - GetLastError()); - if (fclose(pFile) != 0) - { - Trace("ungetc: ERROR -> fclose failed to close the file.\n"); - } - Fail(""); - } - - /* read a few characters */ - for (i = 0; i < 3; i++) - { - if (getc(pFile) == EOF) - { - Trace("ungetc: ERROR -> getc encountered an error reading. " - "GetLastError returned %ld\n", - GetLastError()); - if (fclose(pFile) != 0) - { - Trace("ungetc: ERROR -> fclose failed to close the file.\n"); - } - Fail(""); - } - } - - /* we just read "foo" so push "bar" back on the stream */ - for (i = 2; i >= 0; i--) - { - if ((nRc = ungetc(szNewString[i], pFile)) == EOF) - { - Trace("ungetc: ERROR -> ungetc failed to push '%c' back onto the" - " stream.\n"); - if (fclose(pFile) != 0) - { - Trace("ungetc: ERROR -> fclose failed to close the file.\n"); - } - Fail(""); - } - } - - - /* read the new and improved stream - I use szNewString because it - is correct length */ - nCount = fread(szBuffer, sizeof(char), strlen(szNewString), pFile); - - /* did we get the right number of characters?*/ - if (nCount != strlen(szNewString)) - { - Trace("ungetc: ERROR -> fread read %d characters from the stream but" - " %d characters were expected\n", - nRc, - strlen(szNewString)); - if (fclose(pFile) != 0) - { - Trace("ungetc: ERROR -> fclose failed to close the file.\n"); - } - Fail(""); - } - - /* did we get the right string? */ - if (strcmp(szBuffer, szNewString) != 0) - { - Trace("ungetc: ERROR -> fread returned \"%s\" but \"%s\" was " - "expected\n", - szBuffer, - szNewString); - if (fclose(pFile) != 0) - { - Trace("ungetc: ERROR -> fclose failed to close the file.\n"); - } - Fail(""); - } - - if (fclose(pFile) != 0) - { - Fail("ungetc: ERROR -> fclose failed to close the file.\n"); - } - - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vfprintf/CMakeLists.txt deleted file mode 100644 index cafb9536b..000000000 --- a/src/pal/tests/palsuite/c_runtime/vfprintf/CMakeLists.txt +++ /dev/null @@ -1,22 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test10) -add_subdirectory(test11) -add_subdirectory(test12) -add_subdirectory(test13) -add_subdirectory(test14) -add_subdirectory(test15) -add_subdirectory(test16) -add_subdirectory(test17) -add_subdirectory(test18) -add_subdirectory(test19) -add_subdirectory(test2) -add_subdirectory(test3) -add_subdirectory(test4) -add_subdirectory(test5) -add_subdirectory(test6) -add_subdirectory(test7) -add_subdirectory(test8) -add_subdirectory(test9) - diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vfprintf/test1/CMakeLists.txt deleted file mode 100644 index 138615a40..000000000 --- a/src/pal/tests/palsuite/c_runtime/vfprintf/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_vfprintf_test1 - ${SOURCES} -) - -add_dependencies(paltest_vfprintf_test1 coreclrpal) - -target_link_libraries(paltest_vfprintf_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/vfprintf/test1/test1.cpp deleted file mode 100644 index 302c914e3..000000000 --- a/src/pal/tests/palsuite/c_runtime/vfprintf/test1/test1.cpp +++ /dev/null @@ -1,68 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: Test #1 for the vfprintf function. A single, basic, test -** case with no formatting. -** -** -**==========================================================================*/ - - - -#include -#include "../vfprintf.h" - -int __cdecl main(int argc, char *argv[]) -{ - FILE *fp; - char testfile[] = "testfile.txt"; - char buf[256]; - char checkstr[] = "hello world"; - int ret; - - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - if ((fp = fopen(testfile, "w+")) == NULL) - { - Fail("ERROR: fopen failed to create \"%s\"\n", testfile); - } - - ret = DoVfprintf(fp, "hello world"); - - if (ret != strlen(checkstr)) - { - Fail("Expected vfprintf to return %d, got %d.\n", - strlen(checkstr), ret); - - } - - if ((fseek(fp, 0, SEEK_SET)) != 0) - { - Fail("ERROR: Fseek failed to set pointer to beginning of file\n" ); - } - - if ((fgets(buf, 100, fp)) == NULL) - { - Fail("ERROR: fgets failed\n"); - } - if (memcmp(checkstr, buf, strlen(checkstr)+1) != 0) - { - Fail("ERROR: expected %s, got %s\n", checkstr, buf); - } - if ((fclose(fp)) != 0) - { - Fail("ERROR: fclose failed to close \"%s\"\n", testfile); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vfprintf/test1/testinfo.dat deleted file mode 100644 index 8359de8e3..000000000 --- a/src/pal/tests/palsuite/c_runtime/vfprintf/test1/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = vfprintf -Name = Positive Test for vfprintf -TYPE = DEFAULT -EXE1 = test1 -Description -= General test to see if vfprintf works correctly diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test10/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vfprintf/test10/CMakeLists.txt deleted file mode 100644 index 824d1466a..000000000 --- a/src/pal/tests/palsuite/c_runtime/vfprintf/test10/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test10.cpp -) - -add_executable(paltest_vfprintf_test10 - ${SOURCES} -) - -add_dependencies(paltest_vfprintf_test10 coreclrpal) - -target_link_libraries(paltest_vfprintf_test10 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test10/test10.cpp b/src/pal/tests/palsuite/c_runtime/vfprintf/test10/test10.cpp deleted file mode 100644 index ecb4b0314..000000000 --- a/src/pal/tests/palsuite/c_runtime/vfprintf/test10/test10.cpp +++ /dev/null @@ -1,52 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test10.c -** -** Purpose: Test #10 for the vfprintf function. Tests the octal specifier -** (%o). -** -** -**==========================================================================*/ - - - -#include -#include "../vfprintf.h" - - -int __cdecl main(int argc, char *argv[]) -{ - int neg = -42; - int pos = 42; - INT64 l = 42; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - DoNumTest("foo %o", pos, "foo 52"); - DoNumTest("foo %lo", 0xFFFF, "foo 177777"); - DoNumTest("foo %ho", 0xFFFF, "foo 177777"); - DoNumTest("foo %Lo", pos, "foo 52"); - DoI64Test("foo %I64o", l, "42", "foo 52"); - DoNumTest("foo %3o", pos, "foo 52"); - DoNumTest("foo %-3o", pos, "foo 52 "); - DoNumTest("foo %.1o", pos, "foo 52"); - DoNumTest("foo %.3o", pos, "foo 052"); - DoNumTest("foo %03o", pos, "foo 052"); - DoNumTest("foo %#o", pos, "foo 052"); - DoNumTest("foo %+o", pos, "foo 52"); - DoNumTest("foo % o", pos, "foo 52"); - DoNumTest("foo %+o", neg, "foo 37777777726"); - DoNumTest("foo % o", neg, "foo 37777777726"); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test10/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vfprintf/test10/testinfo.dat deleted file mode 100644 index 034610a7d..000000000 --- a/src/pal/tests/palsuite/c_runtime/vfprintf/test10/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = vfprintf -Name = Positive Test for vfprintf -TYPE = DEFAULT -EXE1 = test10 -Description -= Tests vfprintf with octal numbers diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test11/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vfprintf/test11/CMakeLists.txt deleted file mode 100644 index 492e8502a..000000000 --- a/src/pal/tests/palsuite/c_runtime/vfprintf/test11/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test11.cpp -) - -add_executable(paltest_vfprintf_test11 - ${SOURCES} -) - -add_dependencies(paltest_vfprintf_test11 coreclrpal) - -target_link_libraries(paltest_vfprintf_test11 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test11/test11.cpp b/src/pal/tests/palsuite/c_runtime/vfprintf/test11/test11.cpp deleted file mode 100644 index 5f7bc118c..000000000 --- a/src/pal/tests/palsuite/c_runtime/vfprintf/test11/test11.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test11.c -** -** Purpose: Test #11 for the vfprintf function. Test the unsigned int -** specifier (%u). -** -** -**==========================================================================*/ - - - -#include -#include "../vfprintf.h" - -int __cdecl main(int argc, char *argv[]) -{ - int neg = -42; - int pos = 42; - INT64 l = 42; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - DoNumTest("foo %u", pos, "foo 42"); - DoNumTest("foo %lu", 0xFFFF, "foo 65535"); - DoNumTest("foo %hu", 0xFFFF, "foo 65535"); - DoNumTest("foo %Lu", pos, "foo 42"); - DoI64Test("foo %I64u", l, "42", "foo 42"); - DoNumTest("foo %3u", pos, "foo 42"); - DoNumTest("foo %-3u", pos, "foo 42 "); - DoNumTest("foo %.1u", pos, "foo 42"); - DoNumTest("foo %.3u", pos, "foo 042"); - DoNumTest("foo %03u", pos, "foo 042"); - DoNumTest("foo %#u", pos, "foo 42"); - DoNumTest("foo %+u", pos, "foo 42"); - DoNumTest("foo % u", pos, "foo 42"); - DoNumTest("foo %+u", neg, "foo 4294967254"); - DoNumTest("foo % u", neg, "foo 4294967254"); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test11/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vfprintf/test11/testinfo.dat deleted file mode 100644 index 4050bd610..000000000 --- a/src/pal/tests/palsuite/c_runtime/vfprintf/test11/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = vfprintf -Name = Positive Test for vfprintf -TYPE = DEFAULT -EXE1 = test11 -Description -= Tests vfprintf with unsigned numbers diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test12/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vfprintf/test12/CMakeLists.txt deleted file mode 100644 index 5837e1f2b..000000000 --- a/src/pal/tests/palsuite/c_runtime/vfprintf/test12/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test12.cpp -) - -add_executable(paltest_vfprintf_test12 - ${SOURCES} -) - -add_dependencies(paltest_vfprintf_test12 coreclrpal) - -target_link_libraries(paltest_vfprintf_test12 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test12/test12.cpp b/src/pal/tests/palsuite/c_runtime/vfprintf/test12/test12.cpp deleted file mode 100644 index 0bf61d3ec..000000000 --- a/src/pal/tests/palsuite/c_runtime/vfprintf/test12/test12.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test12.c -** -** Purpose: Test #12 for the vfprintf function. Tests the (lowercase) -** hexadecimal specifier (%x) -** -** -**==========================================================================*/ - - - -#include -#include "../vfprintf.h" - - -int __cdecl main(int argc, char *argv[]) -{ - int neg = -42; - int pos = 0x1234ab; - INT64 l = I64(0x1234567887654321); - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - DoNumTest("foo %x", pos, "foo 1234ab"); - DoNumTest("foo %lx", pos, "foo 1234ab"); - DoNumTest("foo %hx", pos, "foo 34ab"); - DoNumTest("foo %Lx", pos, "foo 1234ab"); - DoI64Test("foo %I64x", l, "0x1234567887654321", - "foo 1234567887654321"); - DoNumTest("foo %7x", pos, "foo 1234ab"); - DoNumTest("foo %-7x", pos, "foo 1234ab "); - DoNumTest("foo %.1x", pos, "foo 1234ab"); - DoNumTest("foo %.7x", pos, "foo 01234ab"); - DoNumTest("foo %07x", pos, "foo 01234ab"); - DoNumTest("foo %#x", pos, "foo 0x1234ab"); - DoNumTest("foo %+x", pos, "foo 1234ab"); - DoNumTest("foo % x", pos, "foo 1234ab"); - DoNumTest("foo %+x", neg, "foo ffffffd6"); - DoNumTest("foo % x", neg, "foo ffffffd6"); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test12/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vfprintf/test12/testinfo.dat deleted file mode 100644 index 640af62af..000000000 --- a/src/pal/tests/palsuite/c_runtime/vfprintf/test12/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = vfprintf -Name = Positive Test for vfprintf -TYPE = DEFAULT -EXE1 = test12 -Description -= Tests vfprintf with hex numbers (lowercase) diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test13/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vfprintf/test13/CMakeLists.txt deleted file mode 100644 index 2a9ec0b6b..000000000 --- a/src/pal/tests/palsuite/c_runtime/vfprintf/test13/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test13.cpp -) - -add_executable(paltest_vfprintf_test13 - ${SOURCES} -) - -add_dependencies(paltest_vfprintf_test13 coreclrpal) - -target_link_libraries(paltest_vfprintf_test13 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test13/test13.cpp b/src/pal/tests/palsuite/c_runtime/vfprintf/test13/test13.cpp deleted file mode 100644 index 1e42ce9e8..000000000 --- a/src/pal/tests/palsuite/c_runtime/vfprintf/test13/test13.cpp +++ /dev/null @@ -1,54 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test13.c -** -** Purpose: Test #13 for the vfprintf function. Tests the (uppercase) -** hexadecimal specifier (%X) -** -** -**==========================================================================*/ - - - -#include -#include "../vfprintf.h" - - - -int __cdecl main(int argc, char *argv[]) -{ - int neg = -42; - int pos = 0x1234AB; - INT64 l = I64(0x1234567887654321); - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - DoNumTest("foo %X", pos, "foo 1234AB"); - DoNumTest("foo %lX", pos, "foo 1234AB"); - DoNumTest("foo %hX", pos, "foo 34AB"); - DoNumTest("foo %LX", pos, "foo 1234AB"); - DoI64Test("foo %I64X", l, "0x1234567887654321", - "foo 1234567887654321"); - DoNumTest("foo %7X", pos, "foo 1234AB"); - DoNumTest("foo %-7X", pos, "foo 1234AB "); - DoNumTest("foo %.1X", pos, "foo 1234AB"); - DoNumTest("foo %.7X", pos, "foo 01234AB"); - DoNumTest("foo %07X", pos, "foo 01234AB"); - DoNumTest("foo %#X", pos, "foo 0X1234AB"); - DoNumTest("foo %+X", pos, "foo 1234AB"); - DoNumTest("foo % X", pos, "foo 1234AB"); - DoNumTest("foo %+X", neg, "foo FFFFFFD6"); - DoNumTest("foo % X", neg, "foo FFFFFFD6"); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test13/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vfprintf/test13/testinfo.dat deleted file mode 100644 index 26c7db052..000000000 --- a/src/pal/tests/palsuite/c_runtime/vfprintf/test13/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = vfprintf -Name = Positive Test for vfprintf -TYPE = DEFAULT -EXE1 = test13 -Description -= Tests vfprintf with hex numbers (uppercase) diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test14/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vfprintf/test14/CMakeLists.txt deleted file mode 100644 index 21c90bf7a..000000000 --- a/src/pal/tests/palsuite/c_runtime/vfprintf/test14/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test14.cpp -) - -add_executable(paltest_vfprintf_test14 - ${SOURCES} -) - -add_dependencies(paltest_vfprintf_test14 coreclrpal) - -target_link_libraries(paltest_vfprintf_test14 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test14/test14.cpp b/src/pal/tests/palsuite/c_runtime/vfprintf/test14/test14.cpp deleted file mode 100644 index 82f247430..000000000 --- a/src/pal/tests/palsuite/c_runtime/vfprintf/test14/test14.cpp +++ /dev/null @@ -1,54 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test14.c -** -** Purpose: Test #14 for the vfprintf function. Tests the lowercase -** exponential notation double specifier (%e) -** -** -**==========================================================================*/ - - - -#include -#include "../vfprintf.h" - - - -int __cdecl main(int argc, char *argv[]) -{ - double val = 256.0; - double neg = -256.0; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - DoDoubleTest("foo %e", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %le", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %he", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %Le", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %I64e", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %14e", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %-14e", val, "foo 2.560000e+002 ", - "foo 2.560000e+02 "); - DoDoubleTest("foo %.1e", val, "foo 2.6e+002", "foo 2.6e+02"); - DoDoubleTest("foo %.8e", val, "foo 2.56000000e+002", - "foo 2.56000000e+02"); - DoDoubleTest("foo %014e", val, "foo 02.560000e+002", - "foo 002.560000e+02"); - DoDoubleTest("foo %#e", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %+e", val, "foo +2.560000e+002", "foo +2.560000e+02"); - DoDoubleTest("foo % e", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %+e", neg, "foo -2.560000e+002", "foo -2.560000e+02"); - DoDoubleTest("foo % e", neg, "foo -2.560000e+002", "foo -2.560000e+02"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test14/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vfprintf/test14/testinfo.dat deleted file mode 100644 index fa3631931..000000000 --- a/src/pal/tests/palsuite/c_runtime/vfprintf/test14/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = vfprintf -Name = Positive Test for vfprintf -TYPE = DEFAULT -EXE1 = test14 -Description -= Tests vfprintf with exponential format doubles (lowercase) diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test15/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vfprintf/test15/CMakeLists.txt deleted file mode 100644 index 7ec560b77..000000000 --- a/src/pal/tests/palsuite/c_runtime/vfprintf/test15/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test15.cpp -) - -add_executable(paltest_vfprintf_test15 - ${SOURCES} -) - -add_dependencies(paltest_vfprintf_test15 coreclrpal) - -target_link_libraries(paltest_vfprintf_test15 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test15/test15.cpp b/src/pal/tests/palsuite/c_runtime/vfprintf/test15/test15.cpp deleted file mode 100644 index 53cc2ceb8..000000000 --- a/src/pal/tests/palsuite/c_runtime/vfprintf/test15/test15.cpp +++ /dev/null @@ -1,54 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test15.c -** -** Purpose: Test #15 for the vfprintf function. Tests the uppercase -** exponential notation double specifier (%E) -** -** -**==========================================================================*/ - - - -#include -#include "../vfprintf.h" - - - -int __cdecl main(int argc, char *argv[]) -{ - double val = 256.0; - double neg = -256.0; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - DoDoubleTest("foo %E", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %lE", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %hE", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %LE", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %I64E", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %14E", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %-14E", val, "foo 2.560000E+002 ", - "foo 2.560000E+02 "); - DoDoubleTest("foo %.1E", val, "foo 2.6E+002", "foo 2.6E+02"); - DoDoubleTest("foo %.8E", val, "foo 2.56000000E+002", - "foo 2.56000000E+02"); - DoDoubleTest("foo %014E", val, "foo 02.560000E+002", - "foo 002.560000E+02"); - DoDoubleTest("foo %#E", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %+E", val, "foo +2.560000E+002", "foo +2.560000E+02"); - DoDoubleTest("foo % E", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %+E", neg, "foo -2.560000E+002", "foo -2.560000E+02"); - DoDoubleTest("foo % E", neg, "foo -2.560000E+002", "foo -2.560000E+02"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test15/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vfprintf/test15/testinfo.dat deleted file mode 100644 index f51f72c12..000000000 --- a/src/pal/tests/palsuite/c_runtime/vfprintf/test15/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = vfprintf -Name = Positive Test for vfprintf -TYPE = DEFAULT -EXE1 = test15 -Description -= Tests vfprintf with exponential format doubles (uppercase) diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test16/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vfprintf/test16/CMakeLists.txt deleted file mode 100644 index 8dac2ede0..000000000 --- a/src/pal/tests/palsuite/c_runtime/vfprintf/test16/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test16.cpp -) - -add_executable(paltest_vfprintf_test16 - ${SOURCES} -) - -add_dependencies(paltest_vfprintf_test16 coreclrpal) - -target_link_libraries(paltest_vfprintf_test16 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test16/test16.cpp b/src/pal/tests/palsuite/c_runtime/vfprintf/test16/test16.cpp deleted file mode 100644 index 2b7674bb9..000000000 --- a/src/pal/tests/palsuite/c_runtime/vfprintf/test16/test16.cpp +++ /dev/null @@ -1,50 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test16.c -** -** Purpose: Test #16 for the vfprintf function. Tests the decimal notation -** double specifier (%f) -** -** -**==========================================================================*/ - - -#include -#include "../vfprintf.h" - - - -int __cdecl main(int argc, char *argv[]) -{ - double val = 2560.001; - double neg = -2560.001; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - DoDoubleTest("foo %f", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %lf", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %hf", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %Lf", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %I64f", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %12f", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %-12f", val, "foo 2560.001000 ", "foo 2560.001000 "); - DoDoubleTest("foo %.1f", val, "foo 2560.0", "foo 2560.0"); - DoDoubleTest("foo %.8f", val, "foo 2560.00100000", "foo 2560.00100000"); - DoDoubleTest("foo %012f", val, "foo 02560.001000", "foo 02560.001000"); - DoDoubleTest("foo %#f", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %+f", val, "foo +2560.001000", "foo +2560.001000"); - DoDoubleTest("foo % f", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %+f", neg, "foo -2560.001000", "foo -2560.001000"); - DoDoubleTest("foo % f", neg, "foo -2560.001000", "foo -2560.001000"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test16/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vfprintf/test16/testinfo.dat deleted file mode 100644 index f91d9f429..000000000 --- a/src/pal/tests/palsuite/c_runtime/vfprintf/test16/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = vfprintf -Name = Positive Test for vfprintf -TYPE = DEFAULT -EXE1 = test16 -Description -= Tests vfprintf with decimal point format doubles diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test17/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vfprintf/test17/CMakeLists.txt deleted file mode 100644 index 170851867..000000000 --- a/src/pal/tests/palsuite/c_runtime/vfprintf/test17/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test17.cpp -) - -add_executable(paltest_vfprintf_test17 - ${SOURCES} -) - -add_dependencies(paltest_vfprintf_test17 coreclrpal) - -target_link_libraries(paltest_vfprintf_test17 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test17/test17.cpp b/src/pal/tests/palsuite/c_runtime/vfprintf/test17/test17.cpp deleted file mode 100644 index 956be15f6..000000000 --- a/src/pal/tests/palsuite/c_runtime/vfprintf/test17/test17.cpp +++ /dev/null @@ -1,52 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test17.c -** -** Purpose: Test #17 for the vfprintf function. Tests the lowercase -** shorthand notation double specifier (%g) -** -** -**==========================================================================*/ - - - -#include -#include "../vfprintf.h" - - - -int __cdecl main(int argc, char *argv[]) -{ - double val = 2560.001; - double neg = -2560.001; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - DoDoubleTest("foo %g", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %lg", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %hg", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %Lg", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %I64g", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %5g", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %-5g", val, "foo 2560 ", "foo 2560 "); - DoDoubleTest("foo %.1g", val, "foo 3e+003", "foo 3e+03"); - DoDoubleTest("foo %.2g", val, "foo 2.6e+003", "foo 2.6e+03"); - DoDoubleTest("foo %.12g", val, "foo 2560.001", "foo 2560.001"); - DoDoubleTest("foo %06g", val, "foo 002560", "foo 002560"); - DoDoubleTest("foo %#g", val, "foo 2560.00", "foo 2560.00"); - DoDoubleTest("foo %+g", val, "foo +2560", "foo +2560"); - DoDoubleTest("foo % g", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %+g", neg, "foo -2560", "foo -2560"); - DoDoubleTest("foo % g", neg, "foo -2560", "foo -2560"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test17/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vfprintf/test17/testinfo.dat deleted file mode 100644 index 623846465..000000000 --- a/src/pal/tests/palsuite/c_runtime/vfprintf/test17/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = vfprintf -Name = Positive Test for vfprintf -TYPE = DEFAULT -EXE1 = test17 -Description -= Tests vfprintf with compact format doubles (lowercase) diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test18/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vfprintf/test18/CMakeLists.txt deleted file mode 100644 index 7c40561ab..000000000 --- a/src/pal/tests/palsuite/c_runtime/vfprintf/test18/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test18.cpp -) - -add_executable(paltest_vfprintf_test18 - ${SOURCES} -) - -add_dependencies(paltest_vfprintf_test18 coreclrpal) - -target_link_libraries(paltest_vfprintf_test18 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test18/test18.cpp b/src/pal/tests/palsuite/c_runtime/vfprintf/test18/test18.cpp deleted file mode 100644 index c61c8cbda..000000000 --- a/src/pal/tests/palsuite/c_runtime/vfprintf/test18/test18.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test18.c -** -** Purpose: Test #18 for the vfprintf function. Tests the uppercase -** shorthand notation double specifier (%G) -** -** -**==========================================================================*/ - - -#include -#include "../vfprintf.h" - - - -int __cdecl main(int argc, char *argv[]) -{ - double val = 2560.001; - double neg = -2560.001; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - DoDoubleTest("foo %G", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %lG", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %hG", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %LG", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %I64G", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %5G", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %-5G", val, "foo 2560 ", "foo 2560 "); - DoDoubleTest("foo %.1G", val, "foo 3E+003", "foo 3E+03"); - DoDoubleTest("foo %.2G", val, "foo 2.6E+003", "foo 2.6E+03"); - DoDoubleTest("foo %.12G", val, "foo 2560.001", "foo 2560.001"); - DoDoubleTest("foo %06G", val, "foo 002560", "foo 002560"); - DoDoubleTest("foo %#G", val, "foo 2560.00", "foo 2560.00"); - DoDoubleTest("foo %+G", val, "foo +2560", "foo +2560"); - DoDoubleTest("foo % G", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %+G", neg, "foo -2560", "foo -2560"); - DoDoubleTest("foo % G", neg, "foo -2560", "foo -2560"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test18/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vfprintf/test18/testinfo.dat deleted file mode 100644 index 44ddab30b..000000000 --- a/src/pal/tests/palsuite/c_runtime/vfprintf/test18/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = vfprintf -Name = Positive Test for vfprintf -TYPE = DEFAULT -EXE1 = test18 -Description -= Tests vfprintf with compact format doubles (uppercase) diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test19/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vfprintf/test19/CMakeLists.txt deleted file mode 100644 index 2a985eb43..000000000 --- a/src/pal/tests/palsuite/c_runtime/vfprintf/test19/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test19.cpp -) - -add_executable(paltest_vfprintf_test19 - ${SOURCES} -) - -add_dependencies(paltest_vfprintf_test19 coreclrpal) - -target_link_libraries(paltest_vfprintf_test19 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test19/test19.cpp b/src/pal/tests/palsuite/c_runtime/vfprintf/test19/test19.cpp deleted file mode 100644 index d8e8f9301..000000000 --- a/src/pal/tests/palsuite/c_runtime/vfprintf/test19/test19.cpp +++ /dev/null @@ -1,76 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test19.c -** -** Purpose: Test #19 for the vfprintf function. Tests the variable length -** precision argument. -** -** -**==========================================================================*/ - - -#include -#include "../vfprintf.h" - - - - -int __cdecl main(int argc, char *argv[]) -{ - int n = -1; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - DoArgumentPrecTest("%.*s", 2, (void*)"bar", "bar", "ba", "ba"); - DoArgumentPrecTest("%.*S", 2, (void*)convert("bar"), "bar", "ba", "ba"); - - DoArgumentPrecTest("%.*n ", 3, (void*)&n, "pointer to int", " ", " "); - if (n != 0) - { - Fail("ERROR: Expected count parameter to resolve to %d, got %X\n", - 0, n); - } - - DoArgumentPrecTest("%.*c", 0, (void*)'a', "a", "a", "a"); - DoArgumentPrecTest("%.*c", 4, (void*)'a', "a", "a", "a"); - DoArgumentPrecTest("%.*C", 0, (void*)'a', "a", "a", "a"); - DoArgumentPrecTest("%.*C", 4, (void*)'a', "a", "a", "a"); - DoArgumentPrecTest("%.*d", 1, (void*)42, "42", "42", "42"); - DoArgumentPrecTest("%.*d", 3, (void*)42, "42", "042", "042"); - DoArgumentPrecTest("%.*i", 1, (void*)42, "42", "42", "42"); - DoArgumentPrecTest("%.*i", 3, (void*)42, "42", "042", "042"); - DoArgumentPrecTest("%.*o", 1, (void*)42, "42", "52", "52"); - DoArgumentPrecTest("%.*o", 3, (void*)42, "42", "052", "052"); - DoArgumentPrecTest("%.*u", 1, (void*)42, "42", "42", "42"); - DoArgumentPrecTest("%.*u", 3, (void*)42, "42", "042", "042"); - DoArgumentPrecTest("%.*x", 1, (void*)0x42, "0x42", "42", "42"); - DoArgumentPrecTest("%.*x", 3, (void*)0x42, "0x42", "042", "042"); - DoArgumentPrecTest("%.*X", 1, (void*)0x42, "0x42", "42", "42"); - DoArgumentPrecTest("%.*X", 3, (void*)0x42, "0x42", "042", "042"); - - - DoArgumentPrecDoubleTest("%.*e", 1, 2.01, "2.0e+000", "2.0e+00"); - DoArgumentPrecDoubleTest("%.*e", 3, 2.01, "2.010e+000", "2.010e+00"); - DoArgumentPrecDoubleTest("%.*E", 1, 2.01, "2.0E+000", "2.0E+00"); - DoArgumentPrecDoubleTest("%.*E", 3, 2.01, "2.010E+000", "2.010E+00"); - DoArgumentPrecDoubleTest("%.*f", 1, 2.01, "2.0", "2.0"); - DoArgumentPrecDoubleTest("%.*f", 3, 2.01, "2.010", "2.010"); - DoArgumentPrecDoubleTest("%.*g", 1, 256.01, "3e+002", "3e+02"); - DoArgumentPrecDoubleTest("%.*g", 3, 256.01, "256", "256"); - DoArgumentPrecDoubleTest("%.*g", 4, 256.01, "256", "256"); - DoArgumentPrecDoubleTest("%.*g", 6, 256.01, "256.01", "256.01"); - DoArgumentPrecDoubleTest("%.*G", 1, 256.01, "3E+002", "3E+02"); - DoArgumentPrecDoubleTest("%.*G", 3, 256.01, "256", "256"); - DoArgumentPrecDoubleTest("%.*G", 4, 256.01, "256", "256"); - DoArgumentPrecDoubleTest("%.*G", 6, 256.01, "256.01", "256.01"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test19/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vfprintf/test19/testinfo.dat deleted file mode 100644 index 729c27960..000000000 --- a/src/pal/tests/palsuite/c_runtime/vfprintf/test19/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = vfprintf -Name = Positive Test for vfprintf -TYPE = DEFAULT -EXE1 = test19 -Description -= Tests vfprintf with argument specified precision diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test2/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vfprintf/test2/CMakeLists.txt deleted file mode 100644 index c374fa6e2..000000000 --- a/src/pal/tests/palsuite/c_runtime/vfprintf/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test2.cpp -) - -add_executable(paltest_vfprintf_test2 - ${SOURCES} -) - -add_dependencies(paltest_vfprintf_test2 coreclrpal) - -target_link_libraries(paltest_vfprintf_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test2/test2.cpp b/src/pal/tests/palsuite/c_runtime/vfprintf/test2/test2.cpp deleted file mode 100644 index 022873452..000000000 --- a/src/pal/tests/palsuite/c_runtime/vfprintf/test2/test2.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test2.c -** -** Purpose: Test #2 for the vfprintf function. Tests the string specifier -** (%s). -** -** -**==========================================================================*/ - - -#include -#include "../vfprintf.h" - - - -int __cdecl main(int argc, char *argv[]) -{ - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - DoStrTest("foo %s", "bar", "foo bar"); - DoStrTest("foo %hs", "bar", "foo bar"); - DoWStrTest("foo %ls", convert("bar"), "foo bar"); - DoWStrTest("foo %ws", convert("bar"), "foo bar"); - DoStrTest("foo %Ls", "bar", "foo bar"); - DoStrTest("foo %I64s", "bar", "foo bar"); - DoStrTest("foo %5s", "bar", "foo bar"); - DoStrTest("foo %.2s", "bar", "foo ba"); - DoStrTest("foo %5.2s", "bar", "foo ba"); - DoStrTest("foo %-5s", "bar", "foo bar "); - DoStrTest("foo %05s", "bar", "foo 00bar"); - DoStrTest("foo %s", NULL, "foo (null)"); - DoStrTest("foo %hs", NULL, "foo (null)"); - DoStrTest("foo %ls", NULL, "foo (null)"); - DoStrTest("foo %ws", NULL, "foo (null)"); - DoStrTest("foo %Ls", NULL, "foo (null)"); - DoStrTest("foo %I64s", NULL, "foo (null)"); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test2/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vfprintf/test2/testinfo.dat deleted file mode 100644 index 6d2f23156..000000000 --- a/src/pal/tests/palsuite/c_runtime/vfprintf/test2/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = vfprintf -Name = Positive Test for vfprintf -TYPE = DEFAULT -EXE1 = test2 -Description -= Tests vfprintf with strings diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test3/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vfprintf/test3/CMakeLists.txt deleted file mode 100644 index a618fc9b7..000000000 --- a/src/pal/tests/palsuite/c_runtime/vfprintf/test3/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test3.cpp -) - -add_executable(paltest_vfprintf_test3 - ${SOURCES} -) - -add_dependencies(paltest_vfprintf_test3 coreclrpal) - -target_link_libraries(paltest_vfprintf_test3 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test3/test3.cpp b/src/pal/tests/palsuite/c_runtime/vfprintf/test3/test3.cpp deleted file mode 100644 index 879446f85..000000000 --- a/src/pal/tests/palsuite/c_runtime/vfprintf/test3/test3.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test3.c -** -** Purpose: Test #3 for the vfprintf function. Tests the wide string -** specifier (%S). -** -** -**==========================================================================*/ - - - -#include -#include "../vfprintf.h" - - - -int __cdecl main(int argc, char *argv[]) -{ - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - DoWStrTest("foo %S", convert("bar"), "foo bar"); - DoStrTest("foo %hS", "bar", "foo bar"); - DoWStrTest("foo %lS", convert("bar"), "foo bar"); - DoWStrTest("foo %wS", convert("bar"), "foo bar"); - DoWStrTest("foo %LS", convert("bar"), "foo bar"); - DoWStrTest("foo %I64S", convert("bar"), "foo bar"); - DoWStrTest("foo %5S", convert("bar"), "foo bar"); - DoWStrTest("foo %.2S", convert("bar"), "foo ba"); - DoWStrTest("foo %5.2S", convert("bar"), "foo ba"); - DoWStrTest("foo %-5S", convert("bar"), "foo bar "); - DoWStrTest("foo %05S", convert("bar"), "foo 00bar"); - DoWStrTest("foo %S", NULL, "foo (null)"); - DoStrTest("foo %hS", NULL, "foo (null)"); - DoWStrTest("foo %lS", NULL, "foo (null)"); - DoWStrTest("foo %wS", NULL, "foo (null)"); - DoWStrTest("foo %LS", NULL, "foo (null)"); - DoWStrTest("foo %I64S", NULL, "foo (null)"); - - PAL_Terminate(); - return PASS; -} - - diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test3/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vfprintf/test3/testinfo.dat deleted file mode 100644 index b5aa1e2f0..000000000 --- a/src/pal/tests/palsuite/c_runtime/vfprintf/test3/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = vfprintf -Name = Positive Test for vfprintf -TYPE = DEFAULT -EXE1 = test3 -Description -= Tests vfprintf with wide strings diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test4/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vfprintf/test4/CMakeLists.txt deleted file mode 100644 index 941bade25..000000000 --- a/src/pal/tests/palsuite/c_runtime/vfprintf/test4/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test4.cpp -) - -add_executable(paltest_vfprintf_test4 - ${SOURCES} -) - -add_dependencies(paltest_vfprintf_test4 coreclrpal) - -target_link_libraries(paltest_vfprintf_test4 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test4/test4.cpp b/src/pal/tests/palsuite/c_runtime/vfprintf/test4/test4.cpp deleted file mode 100644 index 75d11f641..000000000 --- a/src/pal/tests/palsuite/c_runtime/vfprintf/test4/test4.cpp +++ /dev/null @@ -1,70 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test4.c -** -** Purpose: Test #4 for the vfprintf function. Tests the pointer -** specifier (%p). -** -** -**==========================================================================*/ - - - -#include -#include "../vfprintf.h" - - - -int __cdecl main(int argc, char *argv[]) -{ - void *ptr = (void*) 0x123456; - INT64 lptr = I64(0x1234567887654321); - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - -/* -** Run only on 64 bit platforms -*/ -#if defined(BIT64) - Trace("Testing for 64 Bit Platforms \n"); - DoPointerTest("%p", NULL, "NULL", "0000000000000000"); - DoPointerTest("%p", ptr, "pointer to 0x123456", "0000000000123456"); - DoPointerTest("%17p", ptr, "pointer to 0x123456", " 0000000000123456"); - DoPointerTest("%17p", ptr, "pointer to 0x123456", " 0000000000123456"); - DoPointerTest("%-17p", ptr, "pointer to 0x123456", "0000000000123456 "); - DoPointerTest("%+p", ptr, "pointer to 0x123456", "0000000000123456"); - DoPointerTest("%#p", ptr, "pointer to 0x123456", "0X0000000000123456"); - DoPointerTest("%lp", ptr, "pointer to 0x123456", "00123456"); - DoPointerTest("%hp", ptr, "pointer to 0x123456", "00003456"); - DoPointerTest("%Lp", ptr, "pointer to 0x123456", "00123456"); - DoI64Test("%I64p", lptr, "pointer to 0x1234567887654321", - "1234567887654321"); - -#else - Trace("Testing for Non 64 Bit Platforms \n"); - DoPointerTest("%p", NULL, "NULL", "00000000"); - DoPointerTest("%p", ptr, "pointer to 0x123456", "00123456"); - DoPointerTest("%9p", ptr, "pointer to 0x123456", " 00123456"); - DoPointerTest("%09p", ptr, "pointer to 0x123456", " 00123456"); - DoPointerTest("%-9p", ptr, "pointer to 0x123456", "00123456 "); - DoPointerTest("%+p", ptr, "pointer to 0x123456", "00123456"); - DoPointerTest("%#p", ptr, "pointer to 0x123456", "0X00123456"); - DoPointerTest("%lp", ptr, "pointer to 0x123456", "00123456"); - DoPointerTest("%hp", ptr, "pointer to 0x123456", "00003456"); - DoPointerTest("%Lp", ptr, "pointer to 0x123456", "00123456"); - DoI64Test("%I64p", lptr, "pointer to 0x1234567887654321", - "1234567887654321"); - -#endif - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test4/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vfprintf/test4/testinfo.dat deleted file mode 100644 index d08928a8b..000000000 --- a/src/pal/tests/palsuite/c_runtime/vfprintf/test4/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = vfprintf -Name = Positive Test for vfprintf -TYPE = DEFAULT -EXE1 = test4 -Description -= Tests vfprintf with pointers diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test5/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vfprintf/test5/CMakeLists.txt deleted file mode 100644 index 608935283..000000000 --- a/src/pal/tests/palsuite/c_runtime/vfprintf/test5/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test5.cpp -) - -add_executable(paltest_vfprintf_test5 - ${SOURCES} -) - -add_dependencies(paltest_vfprintf_test5 coreclrpal) - -target_link_libraries(paltest_vfprintf_test5 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test5/test5.cpp b/src/pal/tests/palsuite/c_runtime/vfprintf/test5/test5.cpp deleted file mode 100644 index 44f21b61d..000000000 --- a/src/pal/tests/palsuite/c_runtime/vfprintf/test5/test5.cpp +++ /dev/null @@ -1,60 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test5.c -** -** Purpose: Test #5 for the vfprintf function. Tests the count specifier (%n). -** -** -**==========================================================================*/ - - - -#include -#include "../vfprintf.h" - - - - -int __cdecl main(int argc, char *argv[]) -{ - char *longStr = - "really-long-string-that-just-keeps-going-on-and-on-and-on.." - "..................useless-filler.................................." - "..................useless-filler.................................." - "..................useless-filler.................................." - "%n bar"; - char *longResult = - "really-long-string-that-just-keeps-going-on-and-on-and-on.." - "..................useless-filler.................................." - "..................useless-filler.................................." - "..................useless-filler.................................." - " bar"; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - DoCountTest("foo %n bar", 4, "foo bar"); - DoCountTest(longStr, 257, longResult); - DoCountTest("fo%n bar", 2, "fo bar"); - DoCountTest("%n ", 0, " "); - DoCountTest("foo %#n bar", 4, "foo bar"); - DoCountTest("foo % n bar", 4, "foo bar"); - DoCountTest("foo %+n bar", 4, "foo bar"); - DoCountTest("foo %-n bar", 4, "foo bar"); - DoCountTest("foo %0n bar", 4, "foo bar"); - DoShortCountTest("foo %hn bar", 4, "foo bar"); - DoCountTest("foo %ln bar", 4, "foo bar"); - DoCountTest("foo %Ln bar", 4, "foo bar"); - DoCountTest("foo %I64n bar", 4, "foo bar"); - DoCountTest("foo %20.3n bar", 4, "foo bar"); - - PAL_Terminate(); - - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test5/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vfprintf/test5/testinfo.dat deleted file mode 100644 index 73feaa020..000000000 --- a/src/pal/tests/palsuite/c_runtime/vfprintf/test5/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = vfprintf -Name = Positive Test for vfprintf -TYPE = DEFAULT -EXE1 = test5 -Description -= Tests vfprintf with the count specifier diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test6/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vfprintf/test6/CMakeLists.txt deleted file mode 100644 index 77c2bb17d..000000000 --- a/src/pal/tests/palsuite/c_runtime/vfprintf/test6/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test6.cpp -) - -add_executable(paltest_vfprintf_test6 - ${SOURCES} -) - -add_dependencies(paltest_vfprintf_test6 coreclrpal) - -target_link_libraries(paltest_vfprintf_test6 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test6/test6.cpp b/src/pal/tests/palsuite/c_runtime/vfprintf/test6/test6.cpp deleted file mode 100644 index 36c6fe51c..000000000 --- a/src/pal/tests/palsuite/c_runtime/vfprintf/test6/test6.cpp +++ /dev/null @@ -1,48 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test6.c -** -** Purpose: Test #6 for the vfprintf function. Tests the char specifier (%c). -** -** -**==========================================================================*/ - - - -#include -#include "../vfprintf.h" - - - -int __cdecl main(int argc, char *argv[]) -{ - WCHAR wc = (WCHAR) 'c'; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - DoCharTest("foo %c", 'b', "foo b"); - DoCharTest("foo %hc", 'b', "foo b"); - DoWCharTest("foo %lc", wc, "foo c"); - DoCharTest("foo %Lc", 'b', "foo b"); - DoCharTest("foo %I64c", 'b', "foo b"); - DoCharTest("foo %5c", 'b', "foo b"); - DoCharTest("foo %.0c", 'b', "foo b"); - DoCharTest("foo %-5c", 'b', "foo b "); - DoCharTest("foo %05c", 'b', "foo 0000b"); - DoCharTest("foo % c", 'b', "foo b"); - DoCharTest("foo %#c", 'b', "foo b"); - - PAL_Terminate(); - return PASS; -} - - - diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test6/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vfprintf/test6/testinfo.dat deleted file mode 100644 index cb1337dfd..000000000 --- a/src/pal/tests/palsuite/c_runtime/vfprintf/test6/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = vfprintf -Name = Positive Test for vfprintf -TYPE = DEFAULT -EXE1 = test6 -Description -= Tests vfprintf with characters diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test7/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vfprintf/test7/CMakeLists.txt deleted file mode 100644 index de0010538..000000000 --- a/src/pal/tests/palsuite/c_runtime/vfprintf/test7/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test7.cpp -) - -add_executable(paltest_vfprintf_test7 - ${SOURCES} -) - -add_dependencies(paltest_vfprintf_test7 coreclrpal) - -target_link_libraries(paltest_vfprintf_test7 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test7/test7.cpp b/src/pal/tests/palsuite/c_runtime/vfprintf/test7/test7.cpp deleted file mode 100644 index a9cfe319b..000000000 --- a/src/pal/tests/palsuite/c_runtime/vfprintf/test7/test7.cpp +++ /dev/null @@ -1,47 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test7.c -** -** Purpose: Test #7 for the vfprintf function. Tests the wide char -** specifier (%C). -** -** -**==========================================================================*/ - - - -#include -#include "../vfprintf.h" - - - -int __cdecl main(int argc, char *argv[]) -{ - WCHAR wb = (WCHAR) 'b'; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - DoWCharTest("foo %C", wb, "foo b"); - DoWCharTest("foo %hC", wb, "foo b"); - DoCharTest("foo %lC", 'c', "foo c"); - DoWCharTest("foo %LC", wb, "foo b"); - DoWCharTest("foo %I64C", wb, "foo b"); - DoWCharTest("foo %5C", wb, "foo b"); - DoWCharTest("foo %.0C", wb, "foo b"); - DoWCharTest("foo %-5C", wb, "foo b "); - DoWCharTest("foo %05C", wb, "foo 0000b"); - DoWCharTest("foo % C", wb, "foo b"); - DoWCharTest("foo %#C", wb, "foo b"); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test7/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vfprintf/test7/testinfo.dat deleted file mode 100644 index c86134484..000000000 --- a/src/pal/tests/palsuite/c_runtime/vfprintf/test7/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = vfprintf -Name = Positive Test for vfprintf -TYPE = DEFAULT -EXE1 = test7 -Description -= Tests vfprintf with wide characters diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test8/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vfprintf/test8/CMakeLists.txt deleted file mode 100644 index 3129aeb18..000000000 --- a/src/pal/tests/palsuite/c_runtime/vfprintf/test8/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test8.cpp -) - -add_executable(paltest_vfprintf_test8 - ${SOURCES} -) - -add_dependencies(paltest_vfprintf_test8 coreclrpal) - -target_link_libraries(paltest_vfprintf_test8 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test8/test8.cpp b/src/pal/tests/palsuite/c_runtime/vfprintf/test8/test8.cpp deleted file mode 100644 index 5cef99741..000000000 --- a/src/pal/tests/palsuite/c_runtime/vfprintf/test8/test8.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test8.c -** -** Purpose: Test #8 for the vfprintf function. Tests the decimal -** specifier (%d). -** -** -**==========================================================================*/ - - - -#include -#include "../vfprintf.h" - - - -int __cdecl main(int argc, char *argv[]) -{ - int neg = -42; - int pos = 42; - INT64 l = 42; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - DoNumTest("foo %d", pos, "foo 42"); - DoNumTest("foo %ld", 0xFFFF, "foo 65535"); - DoNumTest("foo %hd", 0xFFFF, "foo -1"); - DoNumTest("foo %Ld", pos, "foo 42"); - DoI64Test("foo %I64d", l, "42", "foo 42"); - DoNumTest("foo %3d", pos, "foo 42"); - DoNumTest("foo %-3d", pos, "foo 42 "); - DoNumTest("foo %.1d", pos, "foo 42"); - DoNumTest("foo %.3d", pos, "foo 042"); - DoNumTest("foo %03d", pos, "foo 042"); - DoNumTest("foo %#d", pos, "foo 42"); - DoNumTest("foo %+d", pos, "foo +42"); - DoNumTest("foo % d", pos, "foo 42"); - DoNumTest("foo %+d", neg, "foo -42"); - DoNumTest("foo % d", neg, "foo -42"); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test8/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vfprintf/test8/testinfo.dat deleted file mode 100644 index e96723378..000000000 --- a/src/pal/tests/palsuite/c_runtime/vfprintf/test8/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = vfprintf -Name = Positive Test for vfprintf -TYPE = DEFAULT -EXE1 = test8 -Description -= Tests vfprintf with decimal numbers diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test9/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vfprintf/test9/CMakeLists.txt deleted file mode 100644 index 9cfaa584e..000000000 --- a/src/pal/tests/palsuite/c_runtime/vfprintf/test9/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test9.cpp -) - -add_executable(paltest_vfprintf_test9 - ${SOURCES} -) - -add_dependencies(paltest_vfprintf_test9 coreclrpal) - -target_link_libraries(paltest_vfprintf_test9 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test9/test9.cpp b/src/pal/tests/palsuite/c_runtime/vfprintf/test9/test9.cpp deleted file mode 100644 index 45d0dc7a9..000000000 --- a/src/pal/tests/palsuite/c_runtime/vfprintf/test9/test9.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test9.c -** -** Purpose: Test #9 for the vfprintf function. Tests the integer -** specifier (%i). -** -** -**==========================================================================*/ - - - -#include -#include "../vfprintf.h" - - - -int __cdecl main(int argc, char *argv[]) -{ - int neg = -42; - int pos = 42; - INT64 l = 42; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - DoNumTest("foo %i", pos, "foo 42"); - DoNumTest("foo %li", 0xFFFF, "foo 65535"); - DoNumTest("foo %hi", 0xFFFF, "foo -1"); - DoNumTest("foo %Li", pos, "foo 42"); - DoI64Test("foo %I64i", l, "42", "foo 42"); - DoNumTest("foo %3i", pos, "foo 42"); - DoNumTest("foo %-3i", pos, "foo 42 "); - DoNumTest("foo %.1i", pos, "foo 42"); - DoNumTest("foo %.3i", pos, "foo 042"); - DoNumTest("foo %03i", pos, "foo 042"); - DoNumTest("foo %#i", pos, "foo 42"); - DoNumTest("foo %+i", pos, "foo +42"); - DoNumTest("foo % i", pos, "foo 42"); - DoNumTest("foo %+i", neg, "foo -42"); - DoNumTest("foo % i", neg, "foo -42"); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/test9/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vfprintf/test9/testinfo.dat deleted file mode 100644 index 48621773c..000000000 --- a/src/pal/tests/palsuite/c_runtime/vfprintf/test9/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = vfprintf -Name = Positive Test for vfprintf -TYPE = DEFAULT -EXE1 = test9 -Description -= Tests vfprintf with integer numbers diff --git a/src/pal/tests/palsuite/c_runtime/vfprintf/vfprintf.h b/src/pal/tests/palsuite/c_runtime/vfprintf/vfprintf.h deleted file mode 100644 index 7901b08b0..000000000 --- a/src/pal/tests/palsuite/c_runtime/vfprintf/vfprintf.h +++ /dev/null @@ -1,463 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: vfprintf.h -** -** Purpose: Contains common testing functions for vfprintf -** -** -**==========================================================================*/ - -#ifndef __vfprintf_H__ -#define __vfprintf_H__ - -int DoVfprintf(FILE *fp, const char *format, ...) -{ - int retVal; - va_list arglist; - - va_start(arglist, format); - retVal = vfprintf(fp, format, arglist); - va_end(arglist); - - return (retVal); -} - -void DoStrTest(const char *formatstr, char* param, const char *checkstr) -{ - FILE *fp; - char buf[256] = { 0 }; - - if ((fp = fopen("testfile.txt", "w+")) == NULL ) - { - Fail("ERROR: fopen failed to create testfile\n"); - } - if ((DoVfprintf(fp, formatstr, param)) < 0) - { - Fail("ERROR: vfprintf failed\n"); - } - if ((fseek(fp, 0, SEEK_SET)) != 0) - { - Fail("ERROR: fseek failed\n"); - } - if ((fgets(buf, 100, fp)) == NULL) - { - Fail("ERROR: fgets failed\n"); - } - - if (memcmp(buf, checkstr, strlen(checkstr) + 1) != 0) - { - Fail("ERROR: failed to insert string \"%s\" into \"%s\"\n" - "Expected \"%s\" got \"%s\".\n", - param, formatstr, checkstr, buf); - } - fclose(fp); -} - -void DoWStrTest(const char *formatstr, WCHAR* param, const char *checkstr) -{ - FILE *fp; - char buf[256] = { 0 }; - - if ((fp = fopen("testfile.txt", "w+")) == NULL ) - { - Fail("ERROR: fopen failed to create testfile\n"); - } - if ((DoVfprintf(fp, formatstr, param)) < 0) - { - Fail("ERROR: vfprintf failed\n"); - } - if ((fseek(fp, 0, SEEK_SET)) != 0) - { - Fail("ERROR: fseek failed\n"); - } - if ((fgets(buf, 100, fp)) == NULL) - { - Fail("ERROR: fgets failed\n"); - } - - if (memcmp(buf, checkstr, strlen(checkstr) + 1) != 0) - { - Fail("ERROR: failed to insert wide string \"%S\" into \"%s\"\n" - "Expected \"%s\" got \"%s\".\n", - param, formatstr, checkstr, buf); - } - fclose(fp); -} - - -void DoPointerTest(const char *formatstr, void* param, char* paramstr, - const char *checkstr1) -{ - FILE *fp; - char buf[256] = { 0 }; - - if ((fp = fopen("testfile.txt", "w+")) == NULL ) - { - Fail("ERROR: fopen failed to create testfile\n"); - } - - if ((DoVfprintf(fp, formatstr, param)) < 0) - { - Fail("ERROR: vfprintf failed\n"); - } - - if ((fseek(fp, 0, SEEK_SET)) != 0) - { - Fail("ERROR: fseek failed\n"); - } - - if ((fgets(buf, 100, fp)) == NULL) - { - Fail("ERROR: fgets failed\n"); - } - - if (memcmp(buf, checkstr1, strlen(checkstr1) + 1) != 0) - { - Fail("ERROR: failed to insert %s into \"%s\"\n" - "Expected \"%s\" got \"%s\".\n", - paramstr, formatstr, checkstr1, buf); - } - - if ((fclose( fp )) != 0) - { - Fail("ERROR: fclose failed to close \"testfile.txt\"\n"); - } -} - - - -void DoCountTest(const char *formatstr, int param, const char *checkstr) -{ - FILE *fp; - char buf[512] = { 0 }; - int n = -1; - - if ((fp = fopen("testfile.txt", "w+")) == NULL ) - { - Fail("ERROR: fopen failed to create testfile\n"); - } - - if ((DoVfprintf(fp, formatstr, &n)) < 0) - { - Fail("ERROR: vfprintf failed\n"); - } - - if ((fseek(fp, 0, SEEK_SET)) != 0) - { - Fail("ERROR: fseek failed\n"); - } - - if ((fgets(buf, sizeof(buf), fp)) == NULL) - { - Fail("ERROR: fgets failed\n"); - } - - if (n != param) - { - Fail("ERROR: Expected count parameter to resolve to %d, got %X\n", - param, n); - } - - if (memcmp(buf, checkstr, strlen(checkstr) + 1) != 0) - { - Fail("ERROR: Expected \"%s\" got \"%s\".\n", checkstr, buf); - } - - if ((fclose( fp )) != 0) - { - Fail("ERROR: fclose failed to close \"testfile.txt\"\n"); - } -} - -void DoShortCountTest(const char *formatstr, int param, const char *checkstr) -{ - FILE *fp; - char buf[512] = { 0 }; - short int n = -1; - - if ((fp = fopen("testfile.txt", "w+")) == NULL ) - { - Fail("ERROR: fopen failed to create testfile\n"); - } - - if ((DoVfprintf(fp, formatstr, &n)) < 0) - { - Fail("ERROR: vfprintf failed\n"); - } - - if ((fseek(fp, 0, SEEK_SET)) != 0) - { - Fail("ERROR: fseek failed\n"); - } - - if ((fgets(buf, 100, fp)) == NULL) - { - Fail("ERROR: fgets failed\n"); - } - - if (n != param) - { - Fail("ERROR: Expected count parameter to resolve to %d, got %X\n", - param, n); - } - - if (memcmp(buf, checkstr, strlen(checkstr) + 1) != 0) - { - Fail("ERROR: Expected \"%s\" got \"%s\".\n", checkstr, buf); - } - - if ((fclose( fp )) != 0) - { - Fail("ERROR: fclose failed to close \"testfile.txt\"\n"); - } -} - - -void DoCharTest(const char *formatstr, char param, const char *checkstr) -{ - FILE *fp; - char buf[256] = { 0 }; - - if ((fp = fopen("testfile.txt", "w+")) == NULL ) - { - Fail("ERROR: fopen failed to create testfile\n"); - } - if ((DoVfprintf(fp, formatstr, param)) < 0) - { - Fail("ERROR: vfprintf failed\n"); - } - if ((fseek(fp, 0, SEEK_SET)) != 0) - { - Fail("ERROR: fseek failed\n"); - } - if ((fgets(buf, 100, fp)) == NULL) - { - Fail("ERROR: fgets failed\n"); - } - - if (memcmp(buf, checkstr, strlen(checkstr) + 1) != 0) - { - Fail("ERROR: failed to insert char \'%c\' (%d) into \"%s\"\n" - "Expected \"%s\" got \"%s\".\n", - param, param, formatstr, checkstr, buf); - } - fclose(fp); -} - -void DoWCharTest(const char *formatstr, WCHAR param, const char *checkstr) -{ - FILE *fp; - char buf[256] = { 0 }; - - if ((fp = fopen("testfile.txt", "w+")) == NULL ) - { - Fail("ERROR: fopen failed to create testfile\n"); - } - if ((DoVfprintf(fp, formatstr, param)) < 0) - { - Fail("ERROR: vfprintf failed\n"); - } - if ((fseek(fp, 0, SEEK_SET)) != 0) - { - Fail("ERROR: fseek failed\n"); - } - if ((fgets(buf, 100, fp)) == NULL) - { - Fail("ERROR: fgets failed\n"); - } - - if (memcmp(buf, checkstr, strlen(checkstr) + 1) != 0) - { - Fail("ERROR: failed to insert wide char \'%c\' (%d) into \"%s\"\n" - "Expected \"%s\" got \"%s\".\n", - (char)param, param, formatstr, checkstr, buf); - } - fclose(fp); -} - -void DoNumTest(const char *formatstr, int value, const char *checkstr) -{ - FILE *fp; - char buf[256] = { 0 }; - - if ((fp = fopen("testfile.txt", "w+")) == NULL ) - { - Fail("ERROR: fopen failed to create testfile\n"); - } - if ((DoVfprintf(fp, formatstr, value)) < 0) - { - Fail("ERROR: vfprintf failed\n"); - } - if ((fseek(fp, 0, SEEK_SET)) != 0) - { - Fail("ERROR: fseek failed\n"); - } - if ((fgets(buf, 100, fp)) == NULL) - { - Fail("ERROR: fgets failed\n"); - } - - if (memcmp(buf, checkstr, strlen(checkstr) + 1) != 0) - { - Fail("ERROR: failed to insert %#x into \"%s\"\n" - "Expected \"%s\" got \"%s\".\n", - value, formatstr, checkstr, buf); - } - fclose(fp); -} - -void DoI64Test(const char *formatstr, INT64 value, char *valuestr, const char *checkstr1) -{ - FILE *fp; - char buf[256] = { 0 }; - - if ((fp = fopen("testfile.txt", "w+")) == NULL ) - { - Fail("ERROR: fopen failed to create testfile\n"); - } - if ((DoVfprintf(fp, formatstr, value)) < 0) - { - Fail("ERROR: vfprintf failed\n"); - } - if ((fseek(fp, 0, SEEK_SET)) != 0) - { - Fail("ERROR: fseek failed\n"); - } - if ((fgets(buf, 100, fp)) == NULL) - { - Fail("ERROR: fgets failed\n"); - } - - if (memcmp(buf, checkstr1, strlen(checkstr1) + 1) != 0) - { - Fail("ERROR: failed to insert %s into \"%s\"\n" - "Expected \"%s\", got \"%s\".\n", - valuestr, formatstr, checkstr1, buf); - } - fclose(fp); -} - -void DoDoubleTest(const char *formatstr, double value, const char *checkstr1, - const char *checkstr2) -{ - FILE *fp; - char buf[256] = { 0 }; - - if ((fp = fopen("testfile.txt", "w+")) == NULL ) - { - Fail("ERROR: fopen failed to create testfile\n"); - } - - if ((DoVfprintf(fp, formatstr, value)) < 0) - { - Fail("ERROR: vfprintf failed\n"); - } - if ((fseek(fp, 0, SEEK_SET)) != 0) - { - Fail("ERROR: fseek failed\n"); - } - if ((fgets(buf, 100, fp)) == NULL) - { - Fail("ERROR: fgets failed\n"); - } - - if (memcmp(buf, checkstr1, strlen(checkstr1) + 1) != 0 && - memcmp(buf, checkstr2, strlen(checkstr2) + 1) != 0) - { - Fail("ERROR: failed to insert %f into \"%s\"\n" - "Expected \"%s\" or \"%s\", got \"%s\".\n", - value, formatstr, checkstr1, checkstr2, buf); - } - fclose(fp); -} - - -void DoArgumentPrecTest(const char *formatstr, int precision, void *param, - char *paramstr, const char *checkstr1, const char *checkstr2) -{ - FILE *fp; - char buf[256]; - - if ((fp = fopen("testfile.txt", "w+")) == NULL ) - { - Fail("ERROR: fopen failed to create testfile\n"); - } - - if ((DoVfprintf(fp, formatstr, precision, param)) < 0) - { - Fail("ERROR: vfprintf failed\n"); - } - - if ((fseek(fp, 0, SEEK_SET)) != 0) - { - Fail("ERROR: fseek failed\n"); - } - - if ((fgets(buf, 100, fp)) == NULL) - { - Fail("ERROR: fgets failed\n"); - } - - if (memcmp(buf, checkstr1, strlen(checkstr1) + 1) != 0 && - memcmp(buf, checkstr2, strlen(checkstr2) + 1) != 0) - { - Fail("ERROR: failed to insert %s into \"%s\" with precision %d\n" - "Expected \"%s\" or \"%s\", got \"%s\".\n", paramstr, formatstr, - precision, checkstr1, checkstr2, buf); - } - - - if ((fclose( fp )) != 0) - { - Fail("ERROR: fclose failed to close \"testfile.txt\"\n"); - } - -} - -void DoArgumentPrecDoubleTest(const char *formatstr, int precision, double param, - const char *checkstr1, const char *checkstr2) -{ - FILE *fp; - char buf[256]; - - if ((fp = fopen("testfile.txt", "w+")) == NULL ) - { - Fail("ERROR: fopen failed to create testfile\n"); - } - - if ((DoVfprintf(fp, formatstr, precision, param)) < 0) - { - Fail("ERROR: vfprintf failed\n"); - } - - if ((fseek(fp, 0, SEEK_SET)) != 0) - { - Fail("ERROR: fseek failed\n"); - } - - if ((fgets(buf, 100, fp)) == NULL) - { - Fail("ERROR: fgets failed\n"); - } - - if (memcmp(buf, checkstr1, strlen(checkstr1) + 1) != 0 && - memcmp(buf, checkstr2, strlen(checkstr2) + 1) != 0) - { - Fail("ERROR: failed to insert %f into \"%s\" with precision %d\n" - "Expected \"%s\" or \"%s\", got \"%s\".\n", param, formatstr, - precision, checkstr1, checkstr2, buf); - } - - if ((fclose( fp )) != 0) - { - Fail("ERROR: fclose failed to close \"testfile.txt\"\n"); - } - -} - -#endif - diff --git a/src/pal/tests/palsuite/c_runtime/vprintf/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vprintf/CMakeLists.txt deleted file mode 100644 index c7e7647ea..000000000 --- a/src/pal/tests/palsuite/c_runtime/vprintf/CMakeLists.txt +++ /dev/null @@ -1,23 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -# This test fails to build on ARM -#add_subdirectory(test1) -add_subdirectory(test10) -add_subdirectory(test11) -add_subdirectory(test12) -add_subdirectory(test13) -add_subdirectory(test14) -add_subdirectory(test15) -add_subdirectory(test16) -add_subdirectory(test17) -add_subdirectory(test18) -add_subdirectory(test19) -add_subdirectory(test2) -add_subdirectory(test3) -add_subdirectory(test4) -add_subdirectory(test5) -add_subdirectory(test6) -add_subdirectory(test7) -add_subdirectory(test8) -add_subdirectory(test9) - diff --git a/src/pal/tests/palsuite/c_runtime/vprintf/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vprintf/test1/CMakeLists.txt deleted file mode 100644 index db1d273da..000000000 --- a/src/pal/tests/palsuite/c_runtime/vprintf/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_vprintf_test1 - ${SOURCES} -) - -add_dependencies(paltest_vprintf_test1 coreclrpal) - -target_link_libraries(paltest_vprintf_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/vprintf/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/vprintf/test1/test1.cpp deleted file mode 100644 index 404d7a0dc..000000000 --- a/src/pal/tests/palsuite/c_runtime/vprintf/test1/test1.cpp +++ /dev/null @@ -1,43 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: Test #1 for the vprintf function. A single, basic, test -** case with no formatting. -** -** -**==========================================================================*/ - - - -#include -#include "../vprintf.h" - -int __cdecl main(int argc, char *argv[]) -{ - char checkstr[] = "hello world"; - int ret; - - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - ret = vprintf("hello world", NULL); - - if (ret != strlen(checkstr)) - { - Fail("Expected vprintf to return %d, got %d.\n", - strlen(checkstr), ret); - - } - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/c_runtime/vprintf/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vprintf/test1/testinfo.dat deleted file mode 100644 index ac5de8634..000000000 --- a/src/pal/tests/palsuite/c_runtime/vprintf/test1/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = vprintf -Name = Positive Test for vprintf -TYPE = DEFAULT -EXE1 = test1 -Description -= General test to see if vprintf works correctly diff --git a/src/pal/tests/palsuite/c_runtime/vprintf/test10/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vprintf/test10/CMakeLists.txt deleted file mode 100644 index 89cd486f1..000000000 --- a/src/pal/tests/palsuite/c_runtime/vprintf/test10/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test10.cpp -) - -add_executable(paltest_vprintf_test10 - ${SOURCES} -) - -add_dependencies(paltest_vprintf_test10 coreclrpal) - -target_link_libraries(paltest_vprintf_test10 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/vprintf/test10/test10.cpp b/src/pal/tests/palsuite/c_runtime/vprintf/test10/test10.cpp deleted file mode 100644 index b363d7c02..000000000 --- a/src/pal/tests/palsuite/c_runtime/vprintf/test10/test10.cpp +++ /dev/null @@ -1,52 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test10.c -** -** Purpose: Test #10 for the vprintf function. Tests the octal specifier -** (%o). -** -** -**==========================================================================*/ - - - -#include -#include "../vprintf.h" - - -int __cdecl main(int argc, char *argv[]) -{ - int neg = -42; - int pos = 42; - INT64 l = 42; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - DoNumTest("foo %o", pos, "foo 52"); - DoNumTest("foo %lo", 0xFFFF, "foo 177777"); - DoNumTest("foo %ho", 0xFFFF, "foo 177777"); - DoNumTest("foo %Lo", pos, "foo 52"); - DoI64Test("foo %I64o", l, "42", "foo 52"); - DoNumTest("foo %3o", pos, "foo 52"); - DoNumTest("foo %-3o", pos, "foo 52 "); - DoNumTest("foo %.1o", pos, "foo 52"); - DoNumTest("foo %.3o", pos, "foo 052"); - DoNumTest("foo %03o", pos, "foo 052"); - DoNumTest("foo %#o", pos, "foo 052"); - DoNumTest("foo %+o", pos, "foo 52"); - DoNumTest("foo % o", pos, "foo 52"); - DoNumTest("foo %+o", neg, "foo 37777777726"); - DoNumTest("foo % o", neg, "foo 37777777726"); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/c_runtime/vprintf/test10/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vprintf/test10/testinfo.dat deleted file mode 100644 index 449402430..000000000 --- a/src/pal/tests/palsuite/c_runtime/vprintf/test10/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = vprintf -Name = Positive Test for vprintf -TYPE = DEFAULT -EXE1 = test10 -Description -= Tests vprintf with octal numbers diff --git a/src/pal/tests/palsuite/c_runtime/vprintf/test11/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vprintf/test11/CMakeLists.txt deleted file mode 100644 index a91ea25b7..000000000 --- a/src/pal/tests/palsuite/c_runtime/vprintf/test11/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test11.cpp -) - -add_executable(paltest_vprintf_test11 - ${SOURCES} -) - -add_dependencies(paltest_vprintf_test11 coreclrpal) - -target_link_libraries(paltest_vprintf_test11 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/vprintf/test11/test11.cpp b/src/pal/tests/palsuite/c_runtime/vprintf/test11/test11.cpp deleted file mode 100644 index f5157ac99..000000000 --- a/src/pal/tests/palsuite/c_runtime/vprintf/test11/test11.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test11.c -** -** Purpose: Test #11 for the vprintf function. Test the unsigned int -** specifier (%u). -** -** -**==========================================================================*/ - - - -#include -#include "../vprintf.h" - -int __cdecl main(int argc, char *argv[]) -{ - int neg = -42; - int pos = 42; - INT64 l = 42; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - DoNumTest("foo %u", pos, "foo 42"); - DoNumTest("foo %lu", 0xFFFF, "foo 65535"); - DoNumTest("foo %hu", 0xFFFF, "foo 65535"); - DoNumTest("foo %Lu", pos, "foo 42"); - DoI64Test("foo %I64u", l, "42", "foo 42"); - DoNumTest("foo %3u", pos, "foo 42"); - DoNumTest("foo %-3u", pos, "foo 42 "); - DoNumTest("foo %.1u", pos, "foo 42"); - DoNumTest("foo %.3u", pos, "foo 042"); - DoNumTest("foo %03u", pos, "foo 042"); - DoNumTest("foo %#u", pos, "foo 42"); - DoNumTest("foo %+u", pos, "foo 42"); - DoNumTest("foo % u", pos, "foo 42"); - DoNumTest("foo %+u", neg, "foo 4294967254"); - DoNumTest("foo % u", neg, "foo 4294967254"); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/c_runtime/vprintf/test11/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vprintf/test11/testinfo.dat deleted file mode 100644 index c504c70e8..000000000 --- a/src/pal/tests/palsuite/c_runtime/vprintf/test11/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = vprintf -Name = Positive Test for vprintf -TYPE = DEFAULT -EXE1 = test11 -Description -= Tests vprintf with unsigned numbers diff --git a/src/pal/tests/palsuite/c_runtime/vprintf/test12/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vprintf/test12/CMakeLists.txt deleted file mode 100644 index 0e3c5c9d0..000000000 --- a/src/pal/tests/palsuite/c_runtime/vprintf/test12/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test12.cpp -) - -add_executable(paltest_vprintf_test12 - ${SOURCES} -) - -add_dependencies(paltest_vprintf_test12 coreclrpal) - -target_link_libraries(paltest_vprintf_test12 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/vprintf/test12/test12.cpp b/src/pal/tests/palsuite/c_runtime/vprintf/test12/test12.cpp deleted file mode 100644 index 703a8c4fd..000000000 --- a/src/pal/tests/palsuite/c_runtime/vprintf/test12/test12.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test12.c -** -** Purpose: Test #12 for the vprintf function. Tests the (lowercase) -** hexadecimal specifier (%x) -** -** -**==========================================================================*/ - - - -#include -#include "../vprintf.h" - - -int __cdecl main(int argc, char *argv[]) -{ - int neg = -42; - int pos = 0x1234ab; - INT64 l = I64(0x1234567887654321); - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - DoNumTest("foo %x", pos, "foo 1234ab"); - DoNumTest("foo %lx", pos, "foo 1234ab"); - DoNumTest("foo %hx", pos, "foo 34ab"); - DoNumTest("foo %Lx", pos, "foo 1234ab"); - DoI64Test("foo %I64x", l, "0x1234567887654321", - "foo 1234567887654321"); - DoNumTest("foo %7x", pos, "foo 1234ab"); - DoNumTest("foo %-7x", pos, "foo 1234ab "); - DoNumTest("foo %.1x", pos, "foo 1234ab"); - DoNumTest("foo %.7x", pos, "foo 01234ab"); - DoNumTest("foo %07x", pos, "foo 01234ab"); - DoNumTest("foo %#x", pos, "foo 0x1234ab"); - DoNumTest("foo %+x", pos, "foo 1234ab"); - DoNumTest("foo % x", pos, "foo 1234ab"); - DoNumTest("foo %+x", neg, "foo ffffffd6"); - DoNumTest("foo % x", neg, "foo ffffffd6"); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/c_runtime/vprintf/test12/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vprintf/test12/testinfo.dat deleted file mode 100644 index 558ce37c8..000000000 --- a/src/pal/tests/palsuite/c_runtime/vprintf/test12/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = vprintf -Name = Positive Test for vprintf -TYPE = DEFAULT -EXE1 = test12 -Description -= Tests vprintf with hex numbers (lowercase) diff --git a/src/pal/tests/palsuite/c_runtime/vprintf/test13/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vprintf/test13/CMakeLists.txt deleted file mode 100644 index 877387f73..000000000 --- a/src/pal/tests/palsuite/c_runtime/vprintf/test13/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test13.cpp -) - -add_executable(paltest_vprintf_test13 - ${SOURCES} -) - -add_dependencies(paltest_vprintf_test13 coreclrpal) - -target_link_libraries(paltest_vprintf_test13 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/vprintf/test13/test13.cpp b/src/pal/tests/palsuite/c_runtime/vprintf/test13/test13.cpp deleted file mode 100644 index ecb83ba38..000000000 --- a/src/pal/tests/palsuite/c_runtime/vprintf/test13/test13.cpp +++ /dev/null @@ -1,54 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test13.c -** -** Purpose: Test #13 for the vprintf function. Tests the (uppercase) -** hexadecimal specifier (%X) -** -** -**==========================================================================*/ - - - -#include -#include "../vprintf.h" - - - -int __cdecl main(int argc, char *argv[]) -{ - int neg = -42; - int pos = 0x1234AB; - INT64 l = I64(0x1234567887654321); - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - DoNumTest("foo %X", pos, "foo 1234AB"); - DoNumTest("foo %lX", pos, "foo 1234AB"); - DoNumTest("foo %hX", pos, "foo 34AB"); - DoNumTest("foo %LX", pos, "foo 1234AB"); - DoI64Test("foo %I64X", l, "0x1234567887654321", - "foo 1234567887654321"); - DoNumTest("foo %7X", pos, "foo 1234AB"); - DoNumTest("foo %-7X", pos, "foo 1234AB "); - DoNumTest("foo %.1X", pos, "foo 1234AB"); - DoNumTest("foo %.7X", pos, "foo 01234AB"); - DoNumTest("foo %07X", pos, "foo 01234AB"); - DoNumTest("foo %#X", pos, "foo 0X1234AB"); - DoNumTest("foo %+X", pos, "foo 1234AB"); - DoNumTest("foo % X", pos, "foo 1234AB"); - DoNumTest("foo %+X", neg, "foo FFFFFFD6"); - DoNumTest("foo % X", neg, "foo FFFFFFD6"); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/c_runtime/vprintf/test13/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vprintf/test13/testinfo.dat deleted file mode 100644 index 33822958d..000000000 --- a/src/pal/tests/palsuite/c_runtime/vprintf/test13/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = vprintf -Name = Positive Test for vprintf -TYPE = DEFAULT -EXE1 = test13 -Description -= Tests vprintf with hex numbers (uppercase) diff --git a/src/pal/tests/palsuite/c_runtime/vprintf/test14/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vprintf/test14/CMakeLists.txt deleted file mode 100644 index 8dcc4c97f..000000000 --- a/src/pal/tests/palsuite/c_runtime/vprintf/test14/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test14.cpp -) - -add_executable(paltest_vprintf_test14 - ${SOURCES} -) - -add_dependencies(paltest_vprintf_test14 coreclrpal) - -target_link_libraries(paltest_vprintf_test14 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/vprintf/test14/test14.cpp b/src/pal/tests/palsuite/c_runtime/vprintf/test14/test14.cpp deleted file mode 100644 index 536c1950e..000000000 --- a/src/pal/tests/palsuite/c_runtime/vprintf/test14/test14.cpp +++ /dev/null @@ -1,54 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test14.c -** -** Purpose: Test #14 for the vprintf function. Tests the lowercase -** exponential notation double specifier (%e) -** -** -**==========================================================================*/ - - - -#include -#include "../vprintf.h" - - - -int __cdecl main(int argc, char *argv[]) -{ - double val = 256.0; - double neg = -256.0; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - DoDoubleTest("foo %e", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %le", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %he", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %Le", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %I64e", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %14e", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %-14e", val, "foo 2.560000e+002 ", - "foo 2.560000e+02 "); - DoDoubleTest("foo %.1e", val, "foo 2.6e+002", "foo 2.6e+02"); - DoDoubleTest("foo %.8e", val, "foo 2.56000000e+002", - "foo 2.56000000e+02"); - DoDoubleTest("foo %014e", val, "foo 02.560000e+002", - "foo 002.560000e+02"); - DoDoubleTest("foo %#e", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %+e", val, "foo +2.560000e+002", "foo +2.560000e+02"); - DoDoubleTest("foo % e", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %+e", neg, "foo -2.560000e+002", "foo -2.560000e+02"); - DoDoubleTest("foo % e", neg, "foo -2.560000e+002", "foo -2.560000e+02"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/vprintf/test14/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vprintf/test14/testinfo.dat deleted file mode 100644 index d2633fca4..000000000 --- a/src/pal/tests/palsuite/c_runtime/vprintf/test14/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = vprintf -Name = Positive Test for vprintf -TYPE = DEFAULT -EXE1 = test14 -Description -= Tests vprintf with exponential format doubles (lowercase) diff --git a/src/pal/tests/palsuite/c_runtime/vprintf/test15/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vprintf/test15/CMakeLists.txt deleted file mode 100644 index 7c050494f..000000000 --- a/src/pal/tests/palsuite/c_runtime/vprintf/test15/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test15.cpp -) - -add_executable(paltest_vprintf_test15 - ${SOURCES} -) - -add_dependencies(paltest_vprintf_test15 coreclrpal) - -target_link_libraries(paltest_vprintf_test15 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/vprintf/test15/test15.cpp b/src/pal/tests/palsuite/c_runtime/vprintf/test15/test15.cpp deleted file mode 100644 index 9aff6e457..000000000 --- a/src/pal/tests/palsuite/c_runtime/vprintf/test15/test15.cpp +++ /dev/null @@ -1,54 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test15.c -** -** Purpose: Test #15 for the vprintf function. Tests the uppercase -** exponential notation double specifier (%E) -** -** -**==========================================================================*/ - - - -#include -#include "../vprintf.h" - - - -int __cdecl main(int argc, char *argv[]) -{ - double val = 256.0; - double neg = -256.0; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - DoDoubleTest("foo %E", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %lE", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %hE", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %LE", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %I64E", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %14E", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %-14E", val, "foo 2.560000E+002 ", - "foo 2.560000E+02 "); - DoDoubleTest("foo %.1E", val, "foo 2.6E+002", "foo 2.6E+02"); - DoDoubleTest("foo %.8E", val, "foo 2.56000000E+002", - "foo 2.56000000E+02"); - DoDoubleTest("foo %014E", val, "foo 02.560000E+002", - "foo 002.560000E+02"); - DoDoubleTest("foo %#E", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %+E", val, "foo +2.560000E+002", "foo +2.560000E+02"); - DoDoubleTest("foo % E", val, "foo 2.560000E+002", "foo 2.560000E+02"); - DoDoubleTest("foo %+E", neg, "foo -2.560000E+002", "foo -2.560000E+02"); - DoDoubleTest("foo % E", neg, "foo -2.560000E+002", "foo -2.560000E+02"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/vprintf/test15/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vprintf/test15/testinfo.dat deleted file mode 100644 index c1e00520a..000000000 --- a/src/pal/tests/palsuite/c_runtime/vprintf/test15/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = vprintf -Name = Positive Test for vprintf -TYPE = DEFAULT -EXE1 = test15 -Description -= Tests vprintf with exponential format doubles (uppercase) diff --git a/src/pal/tests/palsuite/c_runtime/vprintf/test16/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vprintf/test16/CMakeLists.txt deleted file mode 100644 index 2280f6696..000000000 --- a/src/pal/tests/palsuite/c_runtime/vprintf/test16/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test16.cpp -) - -add_executable(paltest_vprintf_test16 - ${SOURCES} -) - -add_dependencies(paltest_vprintf_test16 coreclrpal) - -target_link_libraries(paltest_vprintf_test16 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/vprintf/test16/test16.cpp b/src/pal/tests/palsuite/c_runtime/vprintf/test16/test16.cpp deleted file mode 100644 index 66e9afe2d..000000000 --- a/src/pal/tests/palsuite/c_runtime/vprintf/test16/test16.cpp +++ /dev/null @@ -1,50 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test16.c -** -** Purpose: Test #16 for the vprintf function. Tests the decimal notation -** double specifier (%f) -** -** -**==========================================================================*/ - - -#include -#include "../vprintf.h" - - - -int __cdecl main(int argc, char *argv[]) -{ - double val = 2560.001; - double neg = -2560.001; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - DoDoubleTest("foo %f", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %lf", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %hf", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %Lf", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %I64f", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %12f", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %-12f", val, "foo 2560.001000 ", "foo 2560.001000 "); - DoDoubleTest("foo %.1f", val, "foo 2560.0", "foo 2560.0"); - DoDoubleTest("foo %.8f", val, "foo 2560.00100000", "foo 2560.00100000"); - DoDoubleTest("foo %012f", val, "foo 02560.001000", "foo 02560.001000"); - DoDoubleTest("foo %#f", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %+f", val, "foo +2560.001000", "foo +2560.001000"); - DoDoubleTest("foo % f", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %+f", neg, "foo -2560.001000", "foo -2560.001000"); - DoDoubleTest("foo % f", neg, "foo -2560.001000", "foo -2560.001000"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/vprintf/test16/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vprintf/test16/testinfo.dat deleted file mode 100644 index 8b17d2f71..000000000 --- a/src/pal/tests/palsuite/c_runtime/vprintf/test16/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = vprintf -Name = Positive Test for vprintf -TYPE = DEFAULT -EXE1 = test16 -Description -= Tests vprintf with decimal point format doubles diff --git a/src/pal/tests/palsuite/c_runtime/vprintf/test17/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vprintf/test17/CMakeLists.txt deleted file mode 100644 index 99c3adf0a..000000000 --- a/src/pal/tests/palsuite/c_runtime/vprintf/test17/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test17.cpp -) - -add_executable(paltest_vprintf_test17 - ${SOURCES} -) - -add_dependencies(paltest_vprintf_test17 coreclrpal) - -target_link_libraries(paltest_vprintf_test17 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/vprintf/test17/test17.cpp b/src/pal/tests/palsuite/c_runtime/vprintf/test17/test17.cpp deleted file mode 100644 index d36a08490..000000000 --- a/src/pal/tests/palsuite/c_runtime/vprintf/test17/test17.cpp +++ /dev/null @@ -1,52 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test17.c -** -** Purpose: Test #17 for the vprintf function. Tests the lowercase -** shorthand notation double specifier (%g) -** -** -**==========================================================================*/ - - - -#include -#include "../vprintf.h" - - - -int __cdecl main(int argc, char *argv[]) -{ - double val = 2560.001; - double neg = -2560.001; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - DoDoubleTest("foo %g", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %lg", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %hg", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %Lg", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %I64g", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %5g", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %-5g", val, "foo 2560 ", "foo 2560 "); - DoDoubleTest("foo %.1g", val, "foo 3e+003", "foo 3e+03"); - DoDoubleTest("foo %.2g", val, "foo 2.6e+003", "foo 2.6e+03"); - DoDoubleTest("foo %.12g", val, "foo 2560.001", "foo 2560.001"); - DoDoubleTest("foo %06g", val, "foo 002560", "foo 002560"); - DoDoubleTest("foo %#g", val, "foo 2560.00", "foo 2560.00"); - DoDoubleTest("foo %+g", val, "foo +2560", "foo +2560"); - DoDoubleTest("foo % g", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %+g", neg, "foo -2560", "foo -2560"); - DoDoubleTest("foo % g", neg, "foo -2560", "foo -2560"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/vprintf/test17/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vprintf/test17/testinfo.dat deleted file mode 100644 index 9f40fb03a..000000000 --- a/src/pal/tests/palsuite/c_runtime/vprintf/test17/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = vprintf -Name = Positive Test for vprintf -TYPE = DEFAULT -EXE1 = test17 -Description -= Tests vprintf with compact format doubles (lowercase) diff --git a/src/pal/tests/palsuite/c_runtime/vprintf/test18/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vprintf/test18/CMakeLists.txt deleted file mode 100644 index 88c81e3a9..000000000 --- a/src/pal/tests/palsuite/c_runtime/vprintf/test18/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test18.cpp -) - -add_executable(paltest_vprintf_test18 - ${SOURCES} -) - -add_dependencies(paltest_vprintf_test18 coreclrpal) - -target_link_libraries(paltest_vprintf_test18 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/vprintf/test18/test18.cpp b/src/pal/tests/palsuite/c_runtime/vprintf/test18/test18.cpp deleted file mode 100644 index 6fde79b5f..000000000 --- a/src/pal/tests/palsuite/c_runtime/vprintf/test18/test18.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test18.c -** -** Purpose: Test #18 for the vprintf function. Tests the uppercase -** shorthand notation double specifier (%G) -** -** -**==========================================================================*/ - - -#include -#include "../vprintf.h" - - - -int __cdecl main(int argc, char *argv[]) -{ - double val = 2560.001; - double neg = -2560.001; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - DoDoubleTest("foo %G", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %lG", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %hG", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %LG", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %I64G", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %5G", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %-5G", val, "foo 2560 ", "foo 2560 "); - DoDoubleTest("foo %.1G", val, "foo 3E+003", "foo 3E+03"); - DoDoubleTest("foo %.2G", val, "foo 2.6E+003", "foo 2.6E+03"); - DoDoubleTest("foo %.12G", val, "foo 2560.001", "foo 2560.001"); - DoDoubleTest("foo %06G", val, "foo 002560", "foo 002560"); - DoDoubleTest("foo %#G", val, "foo 2560.00", "foo 2560.00"); - DoDoubleTest("foo %+G", val, "foo +2560", "foo +2560"); - DoDoubleTest("foo % G", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %+G", neg, "foo -2560", "foo -2560"); - DoDoubleTest("foo % G", neg, "foo -2560", "foo -2560"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/vprintf/test18/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vprintf/test18/testinfo.dat deleted file mode 100644 index b41f8c63e..000000000 --- a/src/pal/tests/palsuite/c_runtime/vprintf/test18/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = vprintf -Name = Positive Test for vprintf -TYPE = DEFAULT -EXE1 = test18 -Description -= Tests vprintf with compact format doubles (uppercase) diff --git a/src/pal/tests/palsuite/c_runtime/vprintf/test19/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vprintf/test19/CMakeLists.txt deleted file mode 100644 index 59da1ea11..000000000 --- a/src/pal/tests/palsuite/c_runtime/vprintf/test19/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test19.cpp -) - -add_executable(paltest_vprintf_test19 - ${SOURCES} -) - -add_dependencies(paltest_vprintf_test19 coreclrpal) - -target_link_libraries(paltest_vprintf_test19 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/vprintf/test19/test19.cpp b/src/pal/tests/palsuite/c_runtime/vprintf/test19/test19.cpp deleted file mode 100644 index a3e087736..000000000 --- a/src/pal/tests/palsuite/c_runtime/vprintf/test19/test19.cpp +++ /dev/null @@ -1,76 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test19.c -** -** Purpose: Test #19 for the vprintf function. Tests the variable length -** precision argument. -** -** -**==========================================================================*/ - - -#include -#include "../vprintf.h" - - - - -int __cdecl main(int argc, char *argv[]) -{ - int n = -1; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - DoArgumentPrecTest("%.*s", 2, (void*)"bar", "bar", "ba", "ba"); - DoArgumentPrecTest("%.*S", 2, (void*)convert("bar"), "bar", "ba", "ba"); - - DoArgumentPrecTest("%.*n", 3, (void*)&n, "pointer to int", "", ""); - if (n != 0) - { - Fail("ERROR: Expected count parameter to resolve to %d, got %X\n", - 0, n); - } - - DoArgumentPrecTest("%.*c", 0, (void*)'a', "a", "a", "a"); - DoArgumentPrecTest("%.*c", 4, (void*)'a', "a", "a", "a"); - DoArgumentPrecTest("%.*C", 0, (void*)'a', "a", "a", "a"); - DoArgumentPrecTest("%.*C", 4, (void*)'a', "a", "a", "a"); - DoArgumentPrecTest("%.*d", 1, (void*)42, "42", "42", "42"); - DoArgumentPrecTest("%.*d", 3, (void*)42, "42", "042", "042"); - DoArgumentPrecTest("%.*i", 1, (void*)42, "42", "42", "42"); - DoArgumentPrecTest("%.*i", 3, (void*)42, "42", "042", "042"); - DoArgumentPrecTest("%.*o", 1, (void*)42, "42", "52", "52"); - DoArgumentPrecTest("%.*o", 3, (void*)42, "42", "052", "052"); - DoArgumentPrecTest("%.*u", 1, (void*)42, "42", "42", "42"); - DoArgumentPrecTest("%.*u", 3, (void*)42, "42", "042", "042"); - DoArgumentPrecTest("%.*x", 1, (void*)0x42, "0x42", "42", "42"); - DoArgumentPrecTest("%.*x", 3, (void*)0x42, "0x42", "042", "042"); - DoArgumentPrecTest("%.*X", 1, (void*)0x42, "0x42", "42", "42"); - DoArgumentPrecTest("%.*X", 3, (void*)0x42, "0x42", "042", "042"); - - - DoArgumentPrecDoubleTest("%.*e", 1, 2.01, "2.0e+000", "2.0e+00"); - DoArgumentPrecDoubleTest("%.*e", 3, 2.01, "2.010e+000", "2.010e+00"); - DoArgumentPrecDoubleTest("%.*E", 1, 2.01, "2.0E+000", "2.0E+00"); - DoArgumentPrecDoubleTest("%.*E", 3, 2.01, "2.010E+000", "2.010E+00"); - DoArgumentPrecDoubleTest("%.*f", 1, 2.01, "2.0", "2.0"); - DoArgumentPrecDoubleTest("%.*f", 3, 2.01, "2.010", "2.010"); - DoArgumentPrecDoubleTest("%.*g", 1, 256.01, "3e+002", "3e+02"); - DoArgumentPrecDoubleTest("%.*g", 3, 256.01, "256", "256"); - DoArgumentPrecDoubleTest("%.*g", 4, 256.01, "256", "256"); - DoArgumentPrecDoubleTest("%.*g", 6, 256.01, "256.01", "256.01"); - DoArgumentPrecDoubleTest("%.*G", 1, 256.01, "3E+002", "3E+02"); - DoArgumentPrecDoubleTest("%.*G", 3, 256.01, "256", "256"); - DoArgumentPrecDoubleTest("%.*G", 4, 256.01, "256", "256"); - DoArgumentPrecDoubleTest("%.*G", 6, 256.01, "256.01", "256.01"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/vprintf/test19/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vprintf/test19/testinfo.dat deleted file mode 100644 index 03c3afa69..000000000 --- a/src/pal/tests/palsuite/c_runtime/vprintf/test19/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = vprintf -Name = Positive Test for vprintf -TYPE = DEFAULT -EXE1 = test19 -Description -= Tests vprintf with argument specified precision diff --git a/src/pal/tests/palsuite/c_runtime/vprintf/test2/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vprintf/test2/CMakeLists.txt deleted file mode 100644 index c89c81e0e..000000000 --- a/src/pal/tests/palsuite/c_runtime/vprintf/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test2.cpp -) - -add_executable(paltest_vprintf_test2 - ${SOURCES} -) - -add_dependencies(paltest_vprintf_test2 coreclrpal) - -target_link_libraries(paltest_vprintf_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/vprintf/test2/test2.cpp b/src/pal/tests/palsuite/c_runtime/vprintf/test2/test2.cpp deleted file mode 100644 index 72b79e596..000000000 --- a/src/pal/tests/palsuite/c_runtime/vprintf/test2/test2.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test2.c -** -** Purpose: Test #2 for the vprintf function. Tests the string specifier -** (%s). -** -** -**==========================================================================*/ - - -#include -#include "../vprintf.h" - - - -int __cdecl main(int argc, char *argv[]) -{ - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - DoStrTest("foo %s", "bar", "foo bar"); - DoStrTest("foo %hs", "bar", "foo bar"); - DoWStrTest("foo %ls", convert("bar"), "foo bar"); - DoWStrTest("foo %ws", convert("bar"), "foo bar"); - DoStrTest("foo %Ls", "bar", "foo bar"); - DoStrTest("foo %I64s", "bar", "foo bar"); - DoStrTest("foo %5s", "bar", "foo bar"); - DoStrTest("foo %.2s", "bar", "foo ba"); - DoStrTest("foo %5.2s", "bar", "foo ba"); - DoStrTest("foo %-5s", "bar", "foo bar "); - DoStrTest("foo %05s", "bar", "foo 00bar"); - DoStrTest("foo %s", NULL, "foo (null)"); - DoStrTest("foo %hs", NULL, "foo (null)"); - DoWStrTest("foo %ls", NULL, "foo (null)"); - DoWStrTest("foo %ws", NULL, "foo (null)"); - DoStrTest("foo %Ls", NULL, "foo (null)"); - DoStrTest("foo %I64s", NULL, "foo (null)"); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/c_runtime/vprintf/test2/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vprintf/test2/testinfo.dat deleted file mode 100644 index 32c1d70d9..000000000 --- a/src/pal/tests/palsuite/c_runtime/vprintf/test2/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = vprintf -Name = Positive Test for vprintf -TYPE = DEFAULT -EXE1 = test2 -Description -= Tests vprintf with strings diff --git a/src/pal/tests/palsuite/c_runtime/vprintf/test3/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vprintf/test3/CMakeLists.txt deleted file mode 100644 index 0e69b5371..000000000 --- a/src/pal/tests/palsuite/c_runtime/vprintf/test3/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test3.cpp -) - -add_executable(paltest_vprintf_test3 - ${SOURCES} -) - -add_dependencies(paltest_vprintf_test3 coreclrpal) - -target_link_libraries(paltest_vprintf_test3 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/vprintf/test3/test3.cpp b/src/pal/tests/palsuite/c_runtime/vprintf/test3/test3.cpp deleted file mode 100644 index 66cd509d9..000000000 --- a/src/pal/tests/palsuite/c_runtime/vprintf/test3/test3.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test3.c -** -** Purpose: Test #3 for the vprintf function. Tests the wide string -** specifier (%S). -** -** -**==========================================================================*/ - - - -#include -#include "../vprintf.h" - - - -int __cdecl main(int argc, char *argv[]) -{ - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - DoWStrTest("foo %S", convert("bar"), "foo bar"); - DoStrTest("foo %hS", "bar", "foo bar"); - DoWStrTest("foo %lS", convert("bar"), "foo bar"); - DoWStrTest("foo %wS", convert("bar"), "foo bar"); - DoWStrTest("foo %LS", convert("bar"), "foo bar"); - DoWStrTest("foo %I64S", convert("bar"), "foo bar"); - DoWStrTest("foo %5S", convert("bar"), "foo bar"); - DoWStrTest("foo %.2S", convert("bar"), "foo ba"); - DoWStrTest("foo %5.2S", convert("bar"), "foo ba"); - DoWStrTest("foo %-5S", convert("bar"), "foo bar "); - DoWStrTest("foo %05S", convert("bar"), "foo 00bar"); - DoWStrTest("foo %S", NULL, "foo (null)"); - DoStrTest("foo %hS", NULL, "foo (null)"); - DoWStrTest("foo %lS", NULL, "foo (null)"); - DoWStrTest("foo %wS", NULL, "foo (null)"); - DoWStrTest("foo %LS", NULL, "foo (null)"); - DoWStrTest("foo %I64S", NULL, "foo (null)"); - - PAL_Terminate(); - return PASS; -} - - diff --git a/src/pal/tests/palsuite/c_runtime/vprintf/test3/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vprintf/test3/testinfo.dat deleted file mode 100644 index c3b385e8f..000000000 --- a/src/pal/tests/palsuite/c_runtime/vprintf/test3/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = vprintf -Name = Positive Test for vprintf -TYPE = DEFAULT -EXE1 = test3 -Description -= Tests vprintf with wide strings diff --git a/src/pal/tests/palsuite/c_runtime/vprintf/test4/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vprintf/test4/CMakeLists.txt deleted file mode 100644 index a06c2b757..000000000 --- a/src/pal/tests/palsuite/c_runtime/vprintf/test4/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test4.cpp -) - -add_executable(paltest_vprintf_test4 - ${SOURCES} -) - -add_dependencies(paltest_vprintf_test4 coreclrpal) - -target_link_libraries(paltest_vprintf_test4 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/vprintf/test4/test4.cpp b/src/pal/tests/palsuite/c_runtime/vprintf/test4/test4.cpp deleted file mode 100644 index 2cbdb35cc..000000000 --- a/src/pal/tests/palsuite/c_runtime/vprintf/test4/test4.cpp +++ /dev/null @@ -1,70 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test4.c -** -** Purpose: Test #4 for the vprintf function. Tests the pointer -** specifier (%p). -** -** -**==========================================================================*/ - - - -#include -#include "../vprintf.h" - - - - -int __cdecl main(int argc, char *argv[]) -{ - void *ptr = (void*) 0x123456; - INT64 lptr = I64(0x1234567887654321); - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } -/* -** Run only on 64 bit platforms -*/ -#if defined(BIT64) - Trace("Testing for 64 Bit Platforms \n"); - DoPointerTest("%p", NULL, "NULL", "0000000000000000"); - DoPointerTest("%p", ptr, "pointer to 0x123456", "0000000000123456"); - DoPointerTest("%17p", ptr, "pointer to 0x123456", " 0000000000123456"); - DoPointerTest("%17p", ptr, "pointer to 0x123456", " 0000000000123456"); - DoPointerTest("%-17p", ptr, "pointer to 0x123456", "0000000000123456 "); - DoPointerTest("%+p", ptr, "pointer to 0x123456", "0000000000123456"); - DoPointerTest("%#p", ptr, "pointer to 0x123456", "0X0000000000123456"); - DoPointerTest("%lp", ptr, "pointer to 0x123456", "00123456"); - DoPointerTest("%hp", ptr, "pointer to 0x123456", "00003456"); - DoPointerTest("%Lp", ptr, "pointer to 0x123456", "00123456"); - DoI64Test("%I64p", lptr, "pointer to 0x1234567887654321", - "1234567887654321"); - -#else - Trace("Testing for Non 64 Bit Platforms \n"); - DoPointerTest("%p", NULL, "NULL", "00000000"); - DoPointerTest("%p", ptr, "pointer to 0x123456", "00123456"); - DoPointerTest("%9p", ptr, "pointer to 0x123456", " 00123456"); - DoPointerTest("%09p", ptr, "pointer to 0x123456", " 00123456"); - DoPointerTest("%-9p", ptr, "pointer to 0x123456", "00123456 "); - DoPointerTest("%+p", ptr, "pointer to 0x123456", "00123456"); - DoPointerTest("%#p", ptr, "pointer to 0x123456", "0X00123456"); - DoPointerTest("%lp", ptr, "pointer to 0x123456", "00123456"); - DoPointerTest("%hp", ptr, "pointer to 0x123456", "00003456"); - DoPointerTest("%Lp", ptr, "pointer to 0x123456", "00123456"); - DoI64Test("%I64p", lptr, "pointer to 0x1234567887654321", - "1234567887654321"); - -#endif - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/c_runtime/vprintf/test4/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vprintf/test4/testinfo.dat deleted file mode 100644 index 74c4ce932..000000000 --- a/src/pal/tests/palsuite/c_runtime/vprintf/test4/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = vprintf -Name = Positive Test for vprintf -TYPE = DEFAULT -EXE1 = test4 -Description -= Tests vprintf with pointers diff --git a/src/pal/tests/palsuite/c_runtime/vprintf/test5/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vprintf/test5/CMakeLists.txt deleted file mode 100644 index 0124cc3b3..000000000 --- a/src/pal/tests/palsuite/c_runtime/vprintf/test5/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test5.cpp -) - -add_executable(paltest_vprintf_test5 - ${SOURCES} -) - -add_dependencies(paltest_vprintf_test5 coreclrpal) - -target_link_libraries(paltest_vprintf_test5 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/vprintf/test5/test5.cpp b/src/pal/tests/palsuite/c_runtime/vprintf/test5/test5.cpp deleted file mode 100644 index c9e290123..000000000 --- a/src/pal/tests/palsuite/c_runtime/vprintf/test5/test5.cpp +++ /dev/null @@ -1,60 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test5.c -** -** Purpose: Test #5 for the vprintf function. Tests the count specifier (%n). -** -** -**==========================================================================*/ - - - -#include -#include "../vprintf.h" - - - - -int __cdecl main(int argc, char *argv[]) -{ - char *longStr = - "really-long-string-that-just-keeps-going-on-and-on-and-on.." - "..................useless-filler.................................." - "..................useless-filler.................................." - "..................useless-filler.................................." - "%n bar"; - char *longResult = - "really-long-string-that-just-keeps-going-on-and-on-and-on.." - "..................useless-filler.................................." - "..................useless-filler.................................." - "..................useless-filler.................................." - " bar"; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - DoCountTest("foo %n bar", 4, "foo bar"); - DoCountTest(longStr, 257, longResult); - DoCountTest("fo%n bar", 2, "fo bar"); - DoCountTest("%n", 0, ""); - DoCountTest("foo %#n bar", 4, "foo bar"); - DoCountTest("foo % n bar", 4, "foo bar"); - DoCountTest("foo %+n bar", 4, "foo bar"); - DoCountTest("foo %-n bar", 4, "foo bar"); - DoCountTest("foo %0n bar", 4, "foo bar"); - DoShortCountTest("foo %hn bar", 4, "foo bar"); - DoCountTest("foo %ln bar", 4, "foo bar"); - DoCountTest("foo %Ln bar", 4, "foo bar"); - DoCountTest("foo %I64n bar", 4, "foo bar"); - DoCountTest("foo %20.3n bar", 4, "foo bar"); - - PAL_Terminate(); - - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/vprintf/test5/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vprintf/test5/testinfo.dat deleted file mode 100644 index 01ff86420..000000000 --- a/src/pal/tests/palsuite/c_runtime/vprintf/test5/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = vprintf -Name = Positive Test for vprintf -TYPE = DEFAULT -EXE1 = test5 -Description -= Tests vprintf with the count specifier diff --git a/src/pal/tests/palsuite/c_runtime/vprintf/test6/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vprintf/test6/CMakeLists.txt deleted file mode 100644 index b25f46d6c..000000000 --- a/src/pal/tests/palsuite/c_runtime/vprintf/test6/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test6.cpp -) - -add_executable(paltest_vprintf_test6 - ${SOURCES} -) - -add_dependencies(paltest_vprintf_test6 coreclrpal) - -target_link_libraries(paltest_vprintf_test6 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/vprintf/test6/test6.cpp b/src/pal/tests/palsuite/c_runtime/vprintf/test6/test6.cpp deleted file mode 100644 index 6a83cccea..000000000 --- a/src/pal/tests/palsuite/c_runtime/vprintf/test6/test6.cpp +++ /dev/null @@ -1,48 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test6.c -** -** Purpose: Test #6 for the vprintf function. Tests the char specifier (%c). -** -** -**==========================================================================*/ - - - -#include -#include "../vprintf.h" - - - -int __cdecl main(int argc, char *argv[]) -{ - WCHAR wc = (WCHAR) 'c'; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - DoCharTest("foo %c", 'b', "foo b"); - DoCharTest("foo %hc", 'b', "foo b"); - DoWCharTest("foo %lc", wc, "foo c"); - DoCharTest("foo %Lc", 'b', "foo b"); - DoCharTest("foo %I64c", 'b', "foo b"); - DoCharTest("foo %5c", 'b', "foo b"); - DoCharTest("foo %.0c", 'b', "foo b"); - DoCharTest("foo %-5c", 'b', "foo b "); - DoCharTest("foo %05c", 'b', "foo 0000b"); - DoCharTest("foo % c", 'b', "foo b"); - DoCharTest("foo %#c", 'b', "foo b"); - - PAL_Terminate(); - return PASS; -} - - - diff --git a/src/pal/tests/palsuite/c_runtime/vprintf/test6/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vprintf/test6/testinfo.dat deleted file mode 100644 index ce450183f..000000000 --- a/src/pal/tests/palsuite/c_runtime/vprintf/test6/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = vprintf -Name = Positive Test for vprintf -TYPE = DEFAULT -EXE1 = test6 -Description -= Tests vprintf with characters diff --git a/src/pal/tests/palsuite/c_runtime/vprintf/test7/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vprintf/test7/CMakeLists.txt deleted file mode 100644 index b24e241cb..000000000 --- a/src/pal/tests/palsuite/c_runtime/vprintf/test7/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test7.cpp -) - -add_executable(paltest_vprintf_test7 - ${SOURCES} -) - -add_dependencies(paltest_vprintf_test7 coreclrpal) - -target_link_libraries(paltest_vprintf_test7 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/vprintf/test7/test7.cpp b/src/pal/tests/palsuite/c_runtime/vprintf/test7/test7.cpp deleted file mode 100644 index 5096ace42..000000000 --- a/src/pal/tests/palsuite/c_runtime/vprintf/test7/test7.cpp +++ /dev/null @@ -1,47 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test7.c -** -** Purpose: Test #7 for the vprintf function. Tests the wide char -** specifier (%C). -** -** -**==========================================================================*/ - - - -#include -#include "../vprintf.h" - - - -int __cdecl main(int argc, char *argv[]) -{ - WCHAR wb = (WCHAR) 'b'; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - DoWCharTest("foo %C", wb, "foo b"); - DoWCharTest("foo %hC", wb, "foo b"); - DoCharTest("foo %lC", 'c', "foo c"); - DoWCharTest("foo %LC", wb, "foo b"); - DoWCharTest("foo %I64C", wb, "foo b"); - DoWCharTest("foo %5C", wb, "foo b"); - DoWCharTest("foo %.0C", wb, "foo b"); - DoWCharTest("foo %-5C", wb, "foo b "); - DoWCharTest("foo %05C", wb, "foo 0000b"); - DoWCharTest("foo % C", wb, "foo b"); - DoWCharTest("foo %#C", wb, "foo b"); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/c_runtime/vprintf/test7/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vprintf/test7/testinfo.dat deleted file mode 100644 index 254e31e5f..000000000 --- a/src/pal/tests/palsuite/c_runtime/vprintf/test7/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = vprintf -Name = Positive Test for vprintf -TYPE = DEFAULT -EXE1 = test7 -Description -= Tests vprintf with wide characters diff --git a/src/pal/tests/palsuite/c_runtime/vprintf/test8/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vprintf/test8/CMakeLists.txt deleted file mode 100644 index d7b4b0150..000000000 --- a/src/pal/tests/palsuite/c_runtime/vprintf/test8/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test8.cpp -) - -add_executable(paltest_vprintf_test8 - ${SOURCES} -) - -add_dependencies(paltest_vprintf_test8 coreclrpal) - -target_link_libraries(paltest_vprintf_test8 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/vprintf/test8/test8.cpp b/src/pal/tests/palsuite/c_runtime/vprintf/test8/test8.cpp deleted file mode 100644 index 2683339ec..000000000 --- a/src/pal/tests/palsuite/c_runtime/vprintf/test8/test8.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test8.c -** -** Purpose: Test #8 for the vprintf function. Tests the decimal -** specifier (%d). -** -** -**==========================================================================*/ - - - -#include -#include "../vprintf.h" - - - -int __cdecl main(int argc, char *argv[]) -{ - int neg = -42; - int pos = 42; - INT64 l = 42; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - DoNumTest("foo %d", pos, "foo 42"); - DoNumTest("foo %ld", 0xFFFF, "foo 65535"); - DoNumTest("foo %hd", 0xFFFF, "foo -1"); - DoNumTest("foo %Ld", pos, "foo 42"); - DoI64Test("foo %I64d", l, "42", "foo 42"); - DoNumTest("foo %3d", pos, "foo 42"); - DoNumTest("foo %-3d", pos, "foo 42 "); - DoNumTest("foo %.1d", pos, "foo 42"); - DoNumTest("foo %.3d", pos, "foo 042"); - DoNumTest("foo %03d", pos, "foo 042"); - DoNumTest("foo %#d", pos, "foo 42"); - DoNumTest("foo %+d", pos, "foo +42"); - DoNumTest("foo % d", pos, "foo 42"); - DoNumTest("foo %+d", neg, "foo -42"); - DoNumTest("foo % d", neg, "foo -42"); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/c_runtime/vprintf/test8/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vprintf/test8/testinfo.dat deleted file mode 100644 index 73f287b9f..000000000 --- a/src/pal/tests/palsuite/c_runtime/vprintf/test8/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = vprintf -Name = Positive Test for vprintf -TYPE = DEFAULT -EXE1 = test8 -Description -= Tests vprintf with decimal numbers diff --git a/src/pal/tests/palsuite/c_runtime/vprintf/test9/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vprintf/test9/CMakeLists.txt deleted file mode 100644 index b9fd6106b..000000000 --- a/src/pal/tests/palsuite/c_runtime/vprintf/test9/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test9.cpp -) - -add_executable(paltest_vprintf_test9 - ${SOURCES} -) - -add_dependencies(paltest_vprintf_test9 coreclrpal) - -target_link_libraries(paltest_vprintf_test9 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/vprintf/test9/test9.cpp b/src/pal/tests/palsuite/c_runtime/vprintf/test9/test9.cpp deleted file mode 100644 index 8545bc760..000000000 --- a/src/pal/tests/palsuite/c_runtime/vprintf/test9/test9.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test9.c -** -** Purpose: Test #9 for the vprintf function. Tests the integer -** specifier (%i). -** -** -**==========================================================================*/ - - - -#include -#include "../vprintf.h" - - - -int __cdecl main(int argc, char *argv[]) -{ - int neg = -42; - int pos = 42; - INT64 l = 42; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - DoNumTest("foo %i", pos, "foo 42"); - DoNumTest("foo %li", 0xFFFF, "foo 65535"); - DoNumTest("foo %hi", 0xFFFF, "foo -1"); - DoNumTest("foo %Li", pos, "foo 42"); - DoI64Test("foo %I64i", l, "42", "foo 42"); - DoNumTest("foo %3i", pos, "foo 42"); - DoNumTest("foo %-3i", pos, "foo 42 "); - DoNumTest("foo %.1i", pos, "foo 42"); - DoNumTest("foo %.3i", pos, "foo 042"); - DoNumTest("foo %03i", pos, "foo 042"); - DoNumTest("foo %#i", pos, "foo 42"); - DoNumTest("foo %+i", pos, "foo +42"); - DoNumTest("foo % i", pos, "foo 42"); - DoNumTest("foo %+i", neg, "foo -42"); - DoNumTest("foo % i", neg, "foo -42"); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/c_runtime/vprintf/test9/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vprintf/test9/testinfo.dat deleted file mode 100644 index c4c77b9d1..000000000 --- a/src/pal/tests/palsuite/c_runtime/vprintf/test9/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = vprintf -Name = Positive Test for vprintf -TYPE = DEFAULT -EXE1 = test9 -Description -= Tests vprintf with integer numbers diff --git a/src/pal/tests/palsuite/c_runtime/vprintf/vprintf.h b/src/pal/tests/palsuite/c_runtime/vprintf/vprintf.h deleted file mode 100644 index fcd8f8037..000000000 --- a/src/pal/tests/palsuite/c_runtime/vprintf/vprintf.h +++ /dev/null @@ -1,193 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: vprintf.h -** -** Purpose: Containts common testing functions for vprintf -** -** -**==========================================================================*/ - -#ifndef __vprintf_H__ -#define __vprintf_H__ - -int DoVprintf(const char *format, ...) -{ - int retVal; - va_list arglist; - - va_start(arglist, format); - retVal = vprintf(format, arglist); - va_end(arglist); - - return (retVal); -} - -void DoStrTest(const char *formatstr, char* param, const char *checkstr) -{ - int ret; - - ret = DoVprintf(formatstr, param); - if (ret != strlen(checkstr)) - { - Fail("Expected vprintf to return %d, got %d.\n", - strlen(checkstr), ret); - } -} - -void DoWStrTest(const char *formatstr, WCHAR* param, const char *checkstr) -{ - int ret; - - ret = DoVprintf(formatstr, param); - if (ret != strlen(checkstr)) - { - Fail("Expected vprintf to return %d, got %d.\n", - strlen(checkstr), ret); - } -} - -void DoPointerTest(const char *formatstr, void* param, char* paramstr, - const char *checkstr1) -{ - int ret; - - ret = DoVprintf(formatstr, param); - if (ret != strlen(checkstr1)) - { - Fail("Expected vprintf to return %d, got %d.\n", - strlen(checkstr1), ret); - } -} - -void DoCountTest(const char *formatstr, int param, const char *checkstr) -{ - int ret; - int n = -1; - - ret = DoVprintf(formatstr, &n); - - if (n != param) - { - Fail("Expected count parameter to resolve to %d, got %d\n", param, n); - } - - if (ret != strlen(checkstr)) - { - Fail("Expected vprintf to return %d, got %d.\n", - strlen(checkstr), ret); - } -} - -void DoShortCountTest(const char *formatstr, int param, const char *checkstr) -{ - int ret; - short int n = -1; - - ret = DoVprintf(formatstr, &n); - - if (n != param) - { - Fail("Expected count parameter to resolve to %d, got %d\n", param, n); - } - - if (ret != strlen(checkstr)) - { - Fail("Expected vprintf to return %d, got %d.\n", - strlen(checkstr), ret); - } -} - - -void DoCharTest(const char *formatstr, char param, const char *checkstr) -{ - int ret; - - ret = DoVprintf(formatstr, param); - if (ret != strlen(checkstr)) - { - Fail("Expected vprintf to return %d, got %d.\n", - strlen(checkstr), ret); - } -} - -void DoWCharTest(const char *formatstr, WCHAR param, const char *checkstr) -{ - int ret; - - ret = DoVprintf(formatstr, param); - if (ret != strlen(checkstr)) - { - Fail("Expected vprintf to return %d, got %d.\n", - strlen(checkstr), ret); - } -} - -void DoNumTest(const char *formatstr, int param, const char *checkstr) -{ - int ret; - - ret = DoVprintf(formatstr, param); - if (ret != strlen(checkstr)) - { - Fail("Expected vprintf to return %d, got %d.\n", - strlen(checkstr), ret); - } -} - -void DoI64Test(const char *formatstr, INT64 param, char *valuestr, const char *checkstr1) -{ - int ret; - - ret = DoVprintf(formatstr, param); - if (ret != strlen(checkstr1)) - { - Fail("Expected vprintf to return %d, got %d.\n", - strlen(checkstr1), ret); - } -} - -void DoDoubleTest(const char *formatstr, double param, const char *checkstr1, - const char *checkstr2) -{ - int ret; - - ret = DoVprintf(formatstr, param); - if (ret != strlen(checkstr1) && ret != strlen(checkstr2)) - { - Fail("Expected vprintf to return %d or %d, got %d.\n", - strlen(checkstr1), strlen(checkstr2), ret); - } -} - -void DoArgumentPrecTest(const char *formatstr, int precision, void *param, - char *paramstr, const char *checkstr1, const char *checkstr2) -{ - int ret; - - ret = DoVprintf(formatstr, precision, param); - if (ret != strlen(checkstr1) && ret != strlen(checkstr2)) - { - Fail("Expected vprintf to return %d or %d, got %d.\n", - strlen(checkstr1), strlen(checkstr2), ret); - } -} - -void DoArgumentPrecDoubleTest(const char *formatstr, int precision, double param, - const char *checkstr1, const char *checkstr2) -{ - int ret; - - ret = DoVprintf(formatstr, precision, param); - if (ret != strlen(checkstr1) && ret != strlen(checkstr2)) - { - Fail("Expected vprintf to return %d or %d, got %d.\n", - strlen(checkstr1), strlen(checkstr2), ret); - } -} - -#endif - diff --git a/src/pal/tests/palsuite/c_runtime/vsprintf/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vsprintf/CMakeLists.txt deleted file mode 100644 index 8fe1cb60a..000000000 --- a/src/pal/tests/palsuite/c_runtime/vsprintf/CMakeLists.txt +++ /dev/null @@ -1,21 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test10) -add_subdirectory(test11) -add_subdirectory(test12) -add_subdirectory(test13) -add_subdirectory(test14) -add_subdirectory(test15) -add_subdirectory(test16) -add_subdirectory(test17) -add_subdirectory(test18) -add_subdirectory(test19) -add_subdirectory(test2) -add_subdirectory(test3) -add_subdirectory(test4) -add_subdirectory(test6) -add_subdirectory(test7) -add_subdirectory(test8) -add_subdirectory(test9) - diff --git a/src/pal/tests/palsuite/c_runtime/vsprintf/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vsprintf/test1/CMakeLists.txt deleted file mode 100644 index 34d8ad9f9..000000000 --- a/src/pal/tests/palsuite/c_runtime/vsprintf/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_vsprintf_test1 - ${SOURCES} -) - -add_dependencies(paltest_vsprintf_test1 coreclrpal) - -target_link_libraries(paltest_vsprintf_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/vsprintf/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/vsprintf/test1/test1.cpp deleted file mode 100644 index 18c8c0ea1..000000000 --- a/src/pal/tests/palsuite/c_runtime/vsprintf/test1/test1.cpp +++ /dev/null @@ -1,55 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test1.c -** -** Purpose: Test #1 for the vsprintf function. -** -** -**===================================================================*/ - -#include -#include "../vsprintf.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - -int __cdecl main(int argc, char *argv[]) -{ - char checkstr[] = "hello world"; - char buf[256] = { 0 }; - int ret; - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - testvsp(buf, _countof(buf), "hello world"); - - if (memcmp(checkstr, buf, strlen(checkstr)+1) != 0) - { - Fail("ERROR: expected \"%s\" (up to %d chars), got \"%s\"\n", - checkstr, 256, buf); - } - - testvsp(buf, _countof(buf), "xxxxxxxxxxxxxxxxx"); - ret = testvsp(buf, _countof(buf), "hello world"); - - if (ret != strlen(checkstr)) - { - Fail("ERROR: expected negative return value, got %d", ret); - } - - if (memcmp(checkstr, buf, ret) != 0) - { - Fail("ERROR: expected %s, got %s\n", checkstr, buf); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/vsprintf/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vsprintf/test1/testinfo.dat deleted file mode 100644 index 996364f36..000000000 --- a/src/pal/tests/palsuite/c_runtime/vsprintf/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = vsprintf -Name = Positive Test for vsprintf -TYPE = DEFAULT -EXE1 = test1 -Description -= Tests the PAL implementation of the vsprintf function. -= This test is modeled after _snprintf. diff --git a/src/pal/tests/palsuite/c_runtime/vsprintf/test10/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vsprintf/test10/CMakeLists.txt deleted file mode 100644 index 3b0477a2c..000000000 --- a/src/pal/tests/palsuite/c_runtime/vsprintf/test10/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test10.cpp -) - -add_executable(paltest_vsprintf_test10 - ${SOURCES} -) - -add_dependencies(paltest_vsprintf_test10 coreclrpal) - -target_link_libraries(paltest_vsprintf_test10 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/vsprintf/test10/test10.cpp b/src/pal/tests/palsuite/c_runtime/vsprintf/test10/test10.cpp deleted file mode 100644 index 791213fcc..000000000 --- a/src/pal/tests/palsuite/c_runtime/vsprintf/test10/test10.cpp +++ /dev/null @@ -1,50 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test10.c -** -** Purpose: Test #10 for the vsprintf function. -** -** -**===================================================================*/ - -#include -#include "../vsprintf.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - -int __cdecl main(int argc, char *argv[]) -{ - int neg = -42; - int pos = 42; - INT64 l = 42; - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoNumTest("foo %o", pos, "foo 52"); - DoNumTest("foo %lo", 0xFFFF, "foo 177777"); - DoNumTest("foo %ho", 0xFFFF, "foo 177777"); - DoNumTest("foo %Lo", pos, "foo 52"); - DoI64Test("foo %I64o", l, "42", "foo 52"); - DoNumTest("foo %3o", pos, "foo 52"); - DoNumTest("foo %-3o", pos, "foo 52 "); - DoNumTest("foo %.1o", pos, "foo 52"); - DoNumTest("foo %.3o", pos, "foo 052"); - DoNumTest("foo %03o", pos, "foo 052"); - DoNumTest("foo %#o", pos, "foo 052"); - DoNumTest("foo %+o", pos, "foo 52"); - DoNumTest("foo % o", pos, "foo 52"); - DoNumTest("foo %+o", neg, "foo 37777777726"); - DoNumTest("foo % o", neg, "foo 37777777726"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/vsprintf/test10/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vsprintf/test10/testinfo.dat deleted file mode 100644 index 1a1f4ef21..000000000 --- a/src/pal/tests/palsuite/c_runtime/vsprintf/test10/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = vsprintf -Name = Positive Test for vsprintf -TYPE = DEFAULT -EXE1 = test10 -Description -= Tests the PAL implementation of the vsprintf function. -= Tests vsprintf with octal numbers. -= This test is modeled after _snprintf. diff --git a/src/pal/tests/palsuite/c_runtime/vsprintf/test11/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vsprintf/test11/CMakeLists.txt deleted file mode 100644 index 723fa6b7f..000000000 --- a/src/pal/tests/palsuite/c_runtime/vsprintf/test11/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test11.cpp -) - -add_executable(paltest_vsprintf_test11 - ${SOURCES} -) - -add_dependencies(paltest_vsprintf_test11 coreclrpal) - -target_link_libraries(paltest_vsprintf_test11 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/vsprintf/test11/test11.cpp b/src/pal/tests/palsuite/c_runtime/vsprintf/test11/test11.cpp deleted file mode 100644 index e0af94981..000000000 --- a/src/pal/tests/palsuite/c_runtime/vsprintf/test11/test11.cpp +++ /dev/null @@ -1,50 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test11.c -** -** Purpose: Test #11 for the vsprintf function. -** -** -**===================================================================*/ - -#include -#include "../vsprintf.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - -int __cdecl main(int argc, char *argv[]) -{ - int neg = -42; - int pos = 42; - INT64 l = 42; - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoNumTest("foo %u", pos, "foo 42"); - DoNumTest("foo %lu", 0xFFFF, "foo 65535"); - DoNumTest("foo %hu", 0xFFFF, "foo 65535"); - DoNumTest("foo %Lu", pos, "foo 42"); - DoI64Test("foo %I64u", l, "42", "foo 42"); - DoNumTest("foo %3u", pos, "foo 42"); - DoNumTest("foo %-3u", pos, "foo 42 "); - DoNumTest("foo %.1u", pos, "foo 42"); - DoNumTest("foo %.3u", pos, "foo 042"); - DoNumTest("foo %03u", pos, "foo 042"); - DoNumTest("foo %#u", pos, "foo 42"); - DoNumTest("foo %+u", pos, "foo 42"); - DoNumTest("foo % u", pos, "foo 42"); - DoNumTest("foo %+u", neg, "foo 4294967254"); - DoNumTest("foo % u", neg, "foo 4294967254"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/vsprintf/test11/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vsprintf/test11/testinfo.dat deleted file mode 100644 index d44167e25..000000000 --- a/src/pal/tests/palsuite/c_runtime/vsprintf/test11/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = vsprintf -Name = Positive Test for vsprintf -TYPE = DEFAULT -EXE1 = test11 -Description -= Tests the PAL implementation of the vsprintf function. -= Tests vsprintf with unsigned numbers. -= This test is modeled after _snprintf. diff --git a/src/pal/tests/palsuite/c_runtime/vsprintf/test12/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vsprintf/test12/CMakeLists.txt deleted file mode 100644 index b58d47edd..000000000 --- a/src/pal/tests/palsuite/c_runtime/vsprintf/test12/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test12.cpp -) - -add_executable(paltest_vsprintf_test12 - ${SOURCES} -) - -add_dependencies(paltest_vsprintf_test12 coreclrpal) - -target_link_libraries(paltest_vsprintf_test12 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/vsprintf/test12/test12.cpp b/src/pal/tests/palsuite/c_runtime/vsprintf/test12/test12.cpp deleted file mode 100644 index f86ddcade..000000000 --- a/src/pal/tests/palsuite/c_runtime/vsprintf/test12/test12.cpp +++ /dev/null @@ -1,52 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test12.c -** -** Purpose: Test #12 for the vsprintf function. -** -** -**===================================================================*/ - -#include -#include "../vsprintf.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - - -int __cdecl main(int argc, char *argv[]) -{ - int neg = -42; - int pos = 0x1234ab; - INT64 l = I64(0x1234567887654321); - - if (PAL_Initialize(argc, argv) != 0) - { - return (FAIL); - } - - DoNumTest("foo %x", pos, "foo 1234ab"); - DoNumTest("foo %lx", pos, "foo 1234ab"); - DoNumTest("foo %hx", pos, "foo 34ab"); - DoNumTest("foo %Lx", pos, "foo 1234ab"); - DoI64Test("foo %I64x", l, "0x1234567887654321", - "foo 1234567887654321"); - DoNumTest("foo %7x", pos, "foo 1234ab"); - DoNumTest("foo %-7x", pos, "foo 1234ab "); - DoNumTest("foo %.1x", pos, "foo 1234ab"); - DoNumTest("foo %.7x", pos, "foo 01234ab"); - DoNumTest("foo %07x", pos, "foo 01234ab"); - DoNumTest("foo %#x", pos, "foo 0x1234ab"); - DoNumTest("foo %+x", pos, "foo 1234ab"); - DoNumTest("foo % x", pos, "foo 1234ab"); - DoNumTest("foo %+x", neg, "foo ffffffd6"); - DoNumTest("foo % x", neg, "foo ffffffd6"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/vsprintf/test12/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vsprintf/test12/testinfo.dat deleted file mode 100644 index 781fb9cae..000000000 --- a/src/pal/tests/palsuite/c_runtime/vsprintf/test12/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = vsprintf -Name = Positive Test for vsprintf -TYPE = DEFAULT -EXE1 = test12 -Description -= Tests the PAL implementation of the vsprintf function. -= Tests vsprintf with hex numbers (lowercase). -= This test is modeled after _snprintf. diff --git a/src/pal/tests/palsuite/c_runtime/vsprintf/test13/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vsprintf/test13/CMakeLists.txt deleted file mode 100644 index 33ea47937..000000000 --- a/src/pal/tests/palsuite/c_runtime/vsprintf/test13/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test13.cpp -) - -add_executable(paltest_vsprintf_test13 - ${SOURCES} -) - -add_dependencies(paltest_vsprintf_test13 coreclrpal) - -target_link_libraries(paltest_vsprintf_test13 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/vsprintf/test13/test13.cpp b/src/pal/tests/palsuite/c_runtime/vsprintf/test13/test13.cpp deleted file mode 100644 index 36e782553..000000000 --- a/src/pal/tests/palsuite/c_runtime/vsprintf/test13/test13.cpp +++ /dev/null @@ -1,52 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test13.c -** -** Purpose: Test #13 for the vsprintf function. -** -** -**===================================================================*/ - -#include -#include "../vsprintf.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - - -int __cdecl main(int argc, char *argv[]) -{ - int neg = -42; - int pos = 0x1234AB; - INT64 l = I64(0x1234567887654321); - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoNumTest("foo %X", pos, "foo 1234AB"); - DoNumTest("foo %lX", pos, "foo 1234AB"); - DoNumTest("foo %hX", pos, "foo 34AB"); - DoNumTest("foo %LX", pos, "foo 1234AB"); - DoI64Test("foo %I64X", l, "0x1234567887654321", - "foo 1234567887654321"); - DoNumTest("foo %7X", pos, "foo 1234AB"); - DoNumTest("foo %-7X", pos, "foo 1234AB "); - DoNumTest("foo %.1X", pos, "foo 1234AB"); - DoNumTest("foo %.7X", pos, "foo 01234AB"); - DoNumTest("foo %07X", pos, "foo 01234AB"); - DoNumTest("foo %#X", pos, "foo 0X1234AB"); - DoNumTest("foo %+X", pos, "foo 1234AB"); - DoNumTest("foo % X", pos, "foo 1234AB"); - DoNumTest("foo %+X", neg, "foo FFFFFFD6"); - DoNumTest("foo % X", neg, "foo FFFFFFD6"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/vsprintf/test13/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vsprintf/test13/testinfo.dat deleted file mode 100644 index 7b28a91e6..000000000 --- a/src/pal/tests/palsuite/c_runtime/vsprintf/test13/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = vsprintf -Name = Positive Test for vsprintf -TYPE = DEFAULT -EXE1 = test13 -Description -= Tests the PAL implementation of the vsprintf function. -= Tests vsprintf with hex numbers (uppercase). -= This test is modeled after _snprintf. diff --git a/src/pal/tests/palsuite/c_runtime/vsprintf/test14/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vsprintf/test14/CMakeLists.txt deleted file mode 100644 index b1a078498..000000000 --- a/src/pal/tests/palsuite/c_runtime/vsprintf/test14/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test14.cpp -) - -add_executable(paltest_vsprintf_test14 - ${SOURCES} -) - -add_dependencies(paltest_vsprintf_test14 coreclrpal) - -target_link_libraries(paltest_vsprintf_test14 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/vsprintf/test14/test14.cpp b/src/pal/tests/palsuite/c_runtime/vsprintf/test14/test14.cpp deleted file mode 100644 index 360fafc37..000000000 --- a/src/pal/tests/palsuite/c_runtime/vsprintf/test14/test14.cpp +++ /dev/null @@ -1,50 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test14.c -** -** Purpose: Test #14 for the vsprintf function. -** -** -**===================================================================*/ - -#include -#include "../vsprintf.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - - -int __cdecl main(int argc, char *argv[]) -{ - double val = 256.0; - double neg = -256.0; - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoDoubleTest("foo %e", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %le", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %he", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %Le", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %I64e", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %14e", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %-14e", val, "foo 2.560000e+002 ", "foo 2.560000e+02 "); - DoDoubleTest("foo %.1e", val, "foo 2.6e+002", "foo 2.6e+02"); - DoDoubleTest("foo %.8e", val, "foo 2.56000000e+002", "foo 2.56000000e+02"); - DoDoubleTest("foo %014e", val, "foo 02.560000e+002", "foo 002.560000e+02"); - DoDoubleTest("foo %#e", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %+e", val, "foo +2.560000e+002", "foo +2.560000e+02"); - DoDoubleTest("foo % e", val, "foo 2.560000e+002", "foo 2.560000e+02"); - DoDoubleTest("foo %+e", neg, "foo -2.560000e+002", "foo -2.560000e+02"); - DoDoubleTest("foo % e", neg, "foo -2.560000e+002", "foo -2.560000e+02"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/vsprintf/test14/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vsprintf/test14/testinfo.dat deleted file mode 100644 index a0934096c..000000000 --- a/src/pal/tests/palsuite/c_runtime/vsprintf/test14/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = vsprintf -Name = Positive Test for vsprintf -TYPE = DEFAULT -EXE1 = test14 -Description -= Tests the PAL implementation of the vsprintf function. -= Tests vsprintf with exponential format doubles (lowercase). -= This test is modeled after _snprintf. diff --git a/src/pal/tests/palsuite/c_runtime/vsprintf/test15/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vsprintf/test15/CMakeLists.txt deleted file mode 100644 index b6642eddb..000000000 --- a/src/pal/tests/palsuite/c_runtime/vsprintf/test15/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test15.cpp -) - -add_executable(paltest_vsprintf_test15 - ${SOURCES} -) - -add_dependencies(paltest_vsprintf_test15 coreclrpal) - -target_link_libraries(paltest_vsprintf_test15 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/vsprintf/test15/test15.cpp b/src/pal/tests/palsuite/c_runtime/vsprintf/test15/test15.cpp deleted file mode 100644 index a5b4c9422..000000000 --- a/src/pal/tests/palsuite/c_runtime/vsprintf/test15/test15.cpp +++ /dev/null @@ -1,64 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test15.c -** -** Purpose: Test #15 for the vsprintf function. -** -** -**===================================================================*/ - -#include -#include "../vsprintf.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - -int __cdecl main(int argc, char *argv[]) -{ - double val = 256.0; - double neg = -256.0; - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoDoubleTest("foo %E", val, "foo 2.560000E+002", - "foo 2.560000E+02"); - DoDoubleTest("foo %lE", val, "foo 2.560000E+002", - "foo 2.560000E+02"); - DoDoubleTest("foo %hE", val, "foo 2.560000E+002", - "foo 2.560000E+02"); - DoDoubleTest("foo %LE", val, "foo 2.560000E+002", - "foo 2.560000E+02"); - DoDoubleTest("foo %I64E", val, "foo 2.560000E+002", - "foo 2.560000E+02"); - DoDoubleTest("foo %14E", val, "foo 2.560000E+002", - "foo 2.560000E+02"); - DoDoubleTest("foo %-14E", val, "foo 2.560000E+002 ", - "foo 2.560000E+02 "); - DoDoubleTest("foo %.1E", val, "foo 2.6E+002", - "foo 2.6E+02"); - DoDoubleTest("foo %.8E", val, "foo 2.56000000E+002", - "foo 2.56000000E+02"); - DoDoubleTest("foo %014E", val, "foo 02.560000E+002", - "foo 002.560000E+02"); - DoDoubleTest("foo %#E", val, "foo 2.560000E+002", - "foo 2.560000E+02"); - DoDoubleTest("foo %+E", val, "foo +2.560000E+002", - "foo +2.560000E+02"); - DoDoubleTest("foo % E", val, "foo 2.560000E+002", - "foo 2.560000E+02"); - DoDoubleTest("foo %+E", neg, "foo -2.560000E+002", - "foo -2.560000E+02"); - DoDoubleTest("foo % E", neg, "foo -2.560000E+002", - "foo -2.560000E+02"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/vsprintf/test15/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vsprintf/test15/testinfo.dat deleted file mode 100644 index c3b8ebd29..000000000 --- a/src/pal/tests/palsuite/c_runtime/vsprintf/test15/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = vsprintf -Name = Positive Test for vsprintf -TYPE = DEFAULT -EXE1 = test15 -Description -= Tests the PAL implementation of the vsprintf function. -= Tests vsprintf with exponential format doubles (uppercase). -= This test is modeled after _snprintf. diff --git a/src/pal/tests/palsuite/c_runtime/vsprintf/test16/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vsprintf/test16/CMakeLists.txt deleted file mode 100644 index c587798c6..000000000 --- a/src/pal/tests/palsuite/c_runtime/vsprintf/test16/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test16.cpp -) - -add_executable(paltest_vsprintf_test16 - ${SOURCES} -) - -add_dependencies(paltest_vsprintf_test16 coreclrpal) - -target_link_libraries(paltest_vsprintf_test16 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/vsprintf/test16/test16.cpp b/src/pal/tests/palsuite/c_runtime/vsprintf/test16/test16.cpp deleted file mode 100644 index a7258db9d..000000000 --- a/src/pal/tests/palsuite/c_runtime/vsprintf/test16/test16.cpp +++ /dev/null @@ -1,49 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test16.c -** -** Purpose: Test #16 for the vsprintf function. -** -** -**===================================================================*/ - -#include -#include "../vsprintf.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - -int __cdecl main(int argc, char *argv[]) -{ - double val = 2560.001; - double neg = -2560.001; - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoDoubleTest("foo %f", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %lf", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %hf", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %Lf", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %I64f", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %12f", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %-12f", val, "foo 2560.001000 ", "foo 2560.001000 "); - DoDoubleTest("foo %.1f", val, "foo 2560.0", "foo 2560.0"); - DoDoubleTest("foo %.8f", val, "foo 2560.00100000", "foo 2560.00100000"); - DoDoubleTest("foo %012f", val, "foo 02560.001000", "foo 02560.001000"); - DoDoubleTest("foo %#f", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %+f", val, "foo +2560.001000", "foo +2560.001000"); - DoDoubleTest("foo % f", val, "foo 2560.001000", "foo 2560.001000"); - DoDoubleTest("foo %+f", neg, "foo -2560.001000", "foo -2560.001000"); - DoDoubleTest("foo % f", neg, "foo -2560.001000", "foo -2560.001000"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/vsprintf/test16/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vsprintf/test16/testinfo.dat deleted file mode 100644 index d29634e3e..000000000 --- a/src/pal/tests/palsuite/c_runtime/vsprintf/test16/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = vsprintf -Name = Positive Test for vsprintf -TYPE = DEFAULT -EXE1 = test16 -Description -= Tests the PAL implementation of the vsprintf function. -= Tests vsprintf with decimal point format doubles. -= This test is modeled after _snprintf. diff --git a/src/pal/tests/palsuite/c_runtime/vsprintf/test17/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vsprintf/test17/CMakeLists.txt deleted file mode 100644 index edc5b334d..000000000 --- a/src/pal/tests/palsuite/c_runtime/vsprintf/test17/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test17.cpp -) - -add_executable(paltest_vsprintf_test17 - ${SOURCES} -) - -add_dependencies(paltest_vsprintf_test17 coreclrpal) - -target_link_libraries(paltest_vsprintf_test17 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/vsprintf/test17/test17.cpp b/src/pal/tests/palsuite/c_runtime/vsprintf/test17/test17.cpp deleted file mode 100644 index 0ad246a1a..000000000 --- a/src/pal/tests/palsuite/c_runtime/vsprintf/test17/test17.cpp +++ /dev/null @@ -1,50 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test17.c -** -** Purpose: Test #17 for the vsprintf function. -** -** -**===================================================================*/ - -#include -#include "../vsprintf.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - -int __cdecl main(int argc, char *argv[]) -{ - double val = 2560.001; - double neg = -2560.001; - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoDoubleTest("foo %g", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %lg", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %hg", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %Lg", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %I64g", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %5g", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %-5g", val, "foo 2560 ", "foo 2560 "); - DoDoubleTest("foo %.1g", val, "foo 3e+003", "foo 3e+03"); - DoDoubleTest("foo %.2g", val, "foo 2.6e+003", "foo 2.6e+03"); - DoDoubleTest("foo %.12g", val, "foo 2560.001", "foo 2560.001"); - DoDoubleTest("foo %06g", val, "foo 002560", "foo 002560"); - DoDoubleTest("foo %#g", val, "foo 2560.00", "foo 2560.00"); - DoDoubleTest("foo %+g", val, "foo +2560", "foo +2560"); - DoDoubleTest("foo % g", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %+g", neg, "foo -2560", "foo -2560"); - DoDoubleTest("foo % g", neg, "foo -2560", "foo -2560"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/vsprintf/test17/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vsprintf/test17/testinfo.dat deleted file mode 100644 index 0dcd3c869..000000000 --- a/src/pal/tests/palsuite/c_runtime/vsprintf/test17/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = vsprintf -Name = Positive Test for vsprintf -TYPE = DEFAULT -EXE1 = test17 -Description -= Tests the PAL implementation of the vsprintf function. -= Tests vsprintf with compact format doubles (lowercase). -= This test is modeled after _snprintf. diff --git a/src/pal/tests/palsuite/c_runtime/vsprintf/test18/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vsprintf/test18/CMakeLists.txt deleted file mode 100644 index c9f20d5d5..000000000 --- a/src/pal/tests/palsuite/c_runtime/vsprintf/test18/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test18.cpp -) - -add_executable(paltest_vsprintf_test18 - ${SOURCES} -) - -add_dependencies(paltest_vsprintf_test18 coreclrpal) - -target_link_libraries(paltest_vsprintf_test18 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/vsprintf/test18/test18.cpp b/src/pal/tests/palsuite/c_runtime/vsprintf/test18/test18.cpp deleted file mode 100644 index 9a4530556..000000000 --- a/src/pal/tests/palsuite/c_runtime/vsprintf/test18/test18.cpp +++ /dev/null @@ -1,50 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test18.c -** -** Purpose: Test #18 for the vsprintf function. -** -** -**===================================================================*/ - -#include -#include "../vsprintf.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - -int __cdecl main(int argc, char *argv[]) -{ - double val = 2560.001; - double neg = -2560.001; - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoDoubleTest("foo %G", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %lG", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %hG", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %LG", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %I64G", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %5G", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %-5G", val, "foo 2560 ", "foo 2560 "); - DoDoubleTest("foo %.1G", val, "foo 3E+003", "foo 3E+03"); - DoDoubleTest("foo %.2G", val, "foo 2.6E+003", "foo 2.6E+03"); - DoDoubleTest("foo %.12G", val, "foo 2560.001", "foo 2560.001"); - DoDoubleTest("foo %06G", val, "foo 002560", "foo 002560"); - DoDoubleTest("foo %#G", val, "foo 2560.00", "foo 2560.00"); - DoDoubleTest("foo %+G", val, "foo +2560", "foo +2560"); - DoDoubleTest("foo % G", val, "foo 2560", "foo 2560"); - DoDoubleTest("foo %+G", neg, "foo -2560", "foo -2560"); - DoDoubleTest("foo % G", neg, "foo -2560", "foo -2560"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/vsprintf/test18/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vsprintf/test18/testinfo.dat deleted file mode 100644 index 43299968c..000000000 --- a/src/pal/tests/palsuite/c_runtime/vsprintf/test18/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = vsprintf -Name = Positive Test for vsprintf -TYPE = DEFAULT -EXE1 = test18 -Description -= Tests the PAL implementation of the vsprintf function. -= Tests vsprintf with compact format doubles (uppercase). -= This test is modeled after _snprintf. diff --git a/src/pal/tests/palsuite/c_runtime/vsprintf/test19/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vsprintf/test19/CMakeLists.txt deleted file mode 100644 index 886f867de..000000000 --- a/src/pal/tests/palsuite/c_runtime/vsprintf/test19/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test19.cpp -) - -add_executable(paltest_vsprintf_test19 - ${SOURCES} -) - -add_dependencies(paltest_vsprintf_test19 coreclrpal) - -target_link_libraries(paltest_vsprintf_test19 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/vsprintf/test19/test19.cpp b/src/pal/tests/palsuite/c_runtime/vsprintf/test19/test19.cpp deleted file mode 100644 index 698ff36e3..000000000 --- a/src/pal/tests/palsuite/c_runtime/vsprintf/test19/test19.cpp +++ /dev/null @@ -1,67 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test19.c -** -** Purpose: Test #19 for the vsprintf function. -** -** -**===================================================================*/ - -#include -#include "../vsprintf.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - -int __cdecl main(int argc, char *argv[]) -{ - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - - DoArgumentPrecTest("%.*s", 2, (void*)"bar", "bar", "ba", "ba"); - DoArgumentPrecTest("%.*S", 2, (void*)convert("bar"), "bar", "ba", "ba"); - DoArgumentPrecTest("%.*c", 0, (void*)'a', "a", "a", "a"); - DoArgumentPrecTest("%.*c", 4, (void*)'a', "a", "a", "a"); - DoArgumentPrecTest("%.*C", 0, (void*)'a', "a", "a", "a"); - DoArgumentPrecTest("%.*C", 4, (void*)'a', "a", "a", "a"); - DoArgumentPrecTest("%.*d", 1, (void*)42, "42", "42", "42"); - DoArgumentPrecTest("%.*d", 3, (void*)42, "42", "042", "042"); - DoArgumentPrecTest("%.*i", 1, (void*)42, "42", "42", "42"); - DoArgumentPrecTest("%.*i", 3, (void*)42, "42", "042", "042"); - DoArgumentPrecTest("%.*o", 1, (void*)42, "42", "52", "52"); - DoArgumentPrecTest("%.*o", 3, (void*)42, "42", "052", "052"); - DoArgumentPrecTest("%.*u", 1, (void*)42, "42", "42", "42"); - DoArgumentPrecTest("%.*u", 3, (void*)42, "42", "042", "042"); - DoArgumentPrecTest("%.*x", 1, (void*)0x42, "0x42", "42", "42"); - DoArgumentPrecTest("%.*x", 3, (void*)0x42, "0x42", "042", "042"); - DoArgumentPrecTest("%.*X", 1, (void*)0x42, "0x42", "42", "42"); - DoArgumentPrecTest("%.*X", 3, (void*)0x42, "0x42", "042", "042"); - - - DoArgumentPrecDoubleTest("%.*e", 1, 2.01, "2.0e+000", "2.0e+00"); - DoArgumentPrecDoubleTest("%.*e", 3, 2.01, "2.010e+000", "2.010e+00"); - DoArgumentPrecDoubleTest("%.*E", 1, 2.01, "2.0E+000", "2.0E+00"); - DoArgumentPrecDoubleTest("%.*E", 3, 2.01, "2.010E+000", "2.010E+00"); - DoArgumentPrecDoubleTest("%.*f", 1, 2.01, "2.0", "2.0"); - DoArgumentPrecDoubleTest("%.*f", 3, 2.01, "2.010", "2.010"); - DoArgumentPrecDoubleTest("%.*g", 1, 256.01, "3e+002", "3e+02"); - DoArgumentPrecDoubleTest("%.*g", 3, 256.01, "256", "256"); - DoArgumentPrecDoubleTest("%.*g", 4, 256.01, "256", "256"); - DoArgumentPrecDoubleTest("%.*g", 6, 256.01, "256.01", "256.01"); - DoArgumentPrecDoubleTest("%.*G", 1, 256.01, "3E+002", "3E+02"); - DoArgumentPrecDoubleTest("%.*G", 3, 256.01, "256", "256"); - DoArgumentPrecDoubleTest("%.*G", 4, 256.01, "256", "256"); - DoArgumentPrecDoubleTest("%.*G", 6, 256.01, "256.01", "256.01"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/vsprintf/test19/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vsprintf/test19/testinfo.dat deleted file mode 100644 index 1e7bc7615..000000000 --- a/src/pal/tests/palsuite/c_runtime/vsprintf/test19/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = vsprintf -Name = Positive Test for vsprintf -TYPE = DEFAULT -EXE1 = test19 -Description -= Tests the PAL implementation of the vsprintf function. -= Tests vsprintf with argument specified precision. -= This test is modeled after _snprintf. diff --git a/src/pal/tests/palsuite/c_runtime/vsprintf/test2/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vsprintf/test2/CMakeLists.txt deleted file mode 100644 index c9fca91c1..000000000 --- a/src/pal/tests/palsuite/c_runtime/vsprintf/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test2.cpp -) - -add_executable(paltest_vsprintf_test2 - ${SOURCES} -) - -add_dependencies(paltest_vsprintf_test2 coreclrpal) - -target_link_libraries(paltest_vsprintf_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/vsprintf/test2/test2.cpp b/src/pal/tests/palsuite/c_runtime/vsprintf/test2/test2.cpp deleted file mode 100644 index fc9163e97..000000000 --- a/src/pal/tests/palsuite/c_runtime/vsprintf/test2/test2.cpp +++ /dev/null @@ -1,48 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test2.c -** -** Purpose: Test #2 for the vsprintf function. -** -** -**===================================================================*/ - -#include -#include "../vsprintf.h" -/* - * Notes: memcmp is used, as is strlen. - */ - -int __cdecl main(int argc, char *argv[]) -{ - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoStrTest("foo %s", "bar", "foo bar"); - DoStrTest("foo %hs", "bar", "foo bar"); - DoWStrTest("foo %ls", convert("bar"), "foo bar"); - DoWStrTest("foo %ws", convert("bar"), "foo bar"); - DoStrTest("foo %Ls", "bar", "foo bar"); - DoStrTest("foo %I64s", "bar", "foo bar"); - DoStrTest("foo %5s", "bar", "foo bar"); - DoStrTest("foo %.2s", "bar", "foo ba"); - DoStrTest("foo %5.2s", "bar", "foo ba"); - DoStrTest("foo %-5s", "bar", "foo bar "); - DoStrTest("foo %05s", "bar", "foo 00bar"); - DoStrTest("foo %s", NULL, "foo (null)"); - DoStrTest("foo %hs", NULL, "foo (null)"); - DoWStrTest("foo %ls", NULL, "foo (null)"); - DoWStrTest("foo %ws", NULL, "foo (null)"); - DoStrTest("foo %Ls", NULL, "foo (null)"); - DoStrTest("foo %I64s", NULL, "foo (null)"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/vsprintf/test2/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vsprintf/test2/testinfo.dat deleted file mode 100644 index 7958c1ad9..000000000 --- a/src/pal/tests/palsuite/c_runtime/vsprintf/test2/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = vsprintf -Name = Positive Test for vsprintf -TYPE = DEFAULT -EXE1 = test2 -Description -= Tests the PAL implementation of the vsprintf function. -= Tests vsprintf with strings. -= This test is modeled after _snprintf. diff --git a/src/pal/tests/palsuite/c_runtime/vsprintf/test3/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vsprintf/test3/CMakeLists.txt deleted file mode 100644 index 7e4598968..000000000 --- a/src/pal/tests/palsuite/c_runtime/vsprintf/test3/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test3.cpp -) - -add_executable(paltest_vsprintf_test3 - ${SOURCES} -) - -add_dependencies(paltest_vsprintf_test3 coreclrpal) - -target_link_libraries(paltest_vsprintf_test3 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/vsprintf/test3/test3.cpp b/src/pal/tests/palsuite/c_runtime/vsprintf/test3/test3.cpp deleted file mode 100644 index 4656bf3a9..000000000 --- a/src/pal/tests/palsuite/c_runtime/vsprintf/test3/test3.cpp +++ /dev/null @@ -1,49 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test3.c -** -** Purpose: Test #3 for the vsprintf function. -** -** -**===================================================================*/ - -#include -#include "../vsprintf.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - -int __cdecl main(int argc, char *argv[]) -{ - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoWStrTest("foo %S", convert("bar"), "foo bar"); - DoStrTest("foo %hS", "bar", "foo bar"); - DoWStrTest("foo %lS", convert("bar"), "foo bar"); - DoWStrTest("foo %wS", convert("bar"), "foo bar"); - DoWStrTest("foo %LS", convert("bar"), "foo bar"); - DoWStrTest("foo %I64S", convert("bar"), "foo bar"); - DoWStrTest("foo %5S", convert("bar"), "foo bar"); - DoWStrTest("foo %.2S", convert("bar"), "foo ba"); - DoWStrTest("foo %5.2S", convert("bar"), "foo ba"); - DoWStrTest("foo %-5S", convert("bar"), "foo bar "); - DoWStrTest("foo %05S", convert("bar"), "foo 00bar"); - DoWStrTest("foo %S", NULL, "foo (null)"); - DoStrTest("foo %hS", NULL, "foo (null)"); - DoWStrTest("foo %lS", NULL, "foo (null)"); - DoWStrTest("foo %wS", NULL, "foo (null)"); - DoWStrTest("foo %LS", NULL, "foo (null)"); - DoWStrTest("foo %I64S", NULL, "foo (null)"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/vsprintf/test3/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vsprintf/test3/testinfo.dat deleted file mode 100644 index afeb7da95..000000000 --- a/src/pal/tests/palsuite/c_runtime/vsprintf/test3/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = vsprintf -Name = Positive Test for vsprintf -TYPE = DEFAULT -EXE1 = test3 -Description -= Tests the PAL implementation of the vsprintf function. -= Tests vsprintf with wide strings. -= This test is modeled after _snprintf. diff --git a/src/pal/tests/palsuite/c_runtime/vsprintf/test4/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vsprintf/test4/CMakeLists.txt deleted file mode 100644 index 9571f586c..000000000 --- a/src/pal/tests/palsuite/c_runtime/vsprintf/test4/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test4.cpp -) - -add_executable(paltest_vsprintf_test4 - ${SOURCES} -) - -add_dependencies(paltest_vsprintf_test4 coreclrpal) - -target_link_libraries(paltest_vsprintf_test4 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/vsprintf/test4/test4.cpp b/src/pal/tests/palsuite/c_runtime/vsprintf/test4/test4.cpp deleted file mode 100644 index e052d8ee6..000000000 --- a/src/pal/tests/palsuite/c_runtime/vsprintf/test4/test4.cpp +++ /dev/null @@ -1,72 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test4.c -** -** Purpose: Test #4 for the vsprintf function. -** -** -**===================================================================*/ - -#include -#include "../vsprintf.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - - -int __cdecl main(int argc, char *argv[]) -{ - void *ptr = (void*) 0x123456; - INT64 lptr = I64(0x1234567887654321); - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } -/* -** Run only on 64 bit platforms -*/ -#if defined(BIT64) - Trace("Testing for 64 Bit Platforms \n"); - DoPointerTest("%p", NULL, "NULL", "0000000000000000"); - DoPointerTest("%p", ptr, "pointer to 0x123456", "0000000000123456"); - DoPointerTest("%17p", ptr, "pointer to 0x123456", " 0000000000123456"); - DoPointerTest("%17p", ptr, "pointer to 0x123456", " 0000000000123456"); - DoPointerTest("%-17p", ptr, "pointer to 0x123456", "0000000000123456 "); - DoPointerTest("%+p", ptr, "pointer to 0x123456", "0000000000123456"); - DoPointerTest("%#p", ptr, "pointer to 0x123456", "0X0000000000123456"); - DoPointerTest("%lp", ptr, "pointer to 0x123456", "00123456"); - DoPointerTest("%hp", ptr, "pointer to 0x123456", "00003456"); - DoPointerTest("%Lp", ptr, "pointer to 0x123456", "00123456"); - DoI64DoubleTest("%I64p", lptr, "pointer to 0x1234567887654321", - "1234567887654321"); -#else - Trace("Testing for Non 64 Bit Platforms \n"); - DoPointerTest("%p", NULL, "NULL", "00000000"); - DoPointerTest("%p", ptr, "pointer to 0x123456", "00123456"); - DoPointerTest("%9p", ptr, "pointer to 0x123456", " 00123456"); - DoPointerTest("%09p", ptr, "pointer to 0x123456", " 00123456"); - DoPointerTest("%-9p", ptr, "pointer to 0x123456", "00123456 "); - DoPointerTest("%+p", ptr, "pointer to 0x123456", "00123456"); - DoPointerTest("%#p", ptr, "pointer to 0x123456", "0X00123456"); - DoPointerTest("%lp", ptr, "pointer to 0x123456", "00123456"); - DoPointerTest("%hp", ptr, "pointer to 0x123456", "00003456"); - DoPointerTest("%Lp", ptr, "pointer to 0x123456", "00123456"); - DoI64DoubleTest("%I64p", lptr, "pointer to 0x1234567887654321", - "1234567887654321"); -#endif - - - - - - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/c_runtime/vsprintf/test4/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vsprintf/test4/testinfo.dat deleted file mode 100644 index 7331c2037..000000000 --- a/src/pal/tests/palsuite/c_runtime/vsprintf/test4/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = vsprintf -Name = Positive Test for vsprintf -TYPE = DEFAULT -EXE1 = test4 -Description -= Tests the PAL implementation of the vsprintf function. -= Tests vsprintf with pointers. -= This test is modeled after _snprintf. diff --git a/src/pal/tests/palsuite/c_runtime/vsprintf/test6/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vsprintf/test6/CMakeLists.txt deleted file mode 100644 index 7dc7e1d62..000000000 --- a/src/pal/tests/palsuite/c_runtime/vsprintf/test6/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test6.cpp -) - -add_executable(paltest_vsprintf_test6 - ${SOURCES} -) - -add_dependencies(paltest_vsprintf_test6 coreclrpal) - -target_link_libraries(paltest_vsprintf_test6 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/vsprintf/test6/test6.cpp b/src/pal/tests/palsuite/c_runtime/vsprintf/test6/test6.cpp deleted file mode 100644 index 0d38a3a11..000000000 --- a/src/pal/tests/palsuite/c_runtime/vsprintf/test6/test6.cpp +++ /dev/null @@ -1,44 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test6.c -** -** Purpose: Test #6 for the vsprintf function. -** -** -**===================================================================*/ - -#include -#include "../vsprintf.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - -int __cdecl main(int argc, char *argv[]) -{ - WCHAR wc = (WCHAR) 'c'; - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoCharTest("foo %c", 'b', "foo b"); - DoCharTest("foo %hc", 'b', "foo b"); - DoWCharTest("foo %lc", wc, "foo c"); - DoCharTest("foo %Lc", 'b', "foo b"); - DoCharTest("foo %I64c", 'b', "foo b"); - DoCharTest("foo %5c", 'b', "foo b"); - DoCharTest("foo %.0c", 'b', "foo b"); - DoCharTest("foo %-5c", 'b', "foo b "); - DoCharTest("foo %05c", 'b', "foo 0000b"); - DoCharTest("foo % c", 'b', "foo b"); - DoCharTest("foo %#c", 'b', "foo b"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/vsprintf/test6/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vsprintf/test6/testinfo.dat deleted file mode 100644 index d76c5bf1a..000000000 --- a/src/pal/tests/palsuite/c_runtime/vsprintf/test6/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = vsprintf -Name = Positive Test for vsprintf -TYPE = DEFAULT -EXE1 = test6 -Description -= Tests the PAL implementation of the vsprintf function. -= Tests vsprintf with characters. -= This test is modeled after _snprintf. diff --git a/src/pal/tests/palsuite/c_runtime/vsprintf/test7/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vsprintf/test7/CMakeLists.txt deleted file mode 100644 index 7b05fbeb5..000000000 --- a/src/pal/tests/palsuite/c_runtime/vsprintf/test7/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test7.cpp -) - -add_executable(paltest_vsprintf_test7 - ${SOURCES} -) - -add_dependencies(paltest_vsprintf_test7 coreclrpal) - -target_link_libraries(paltest_vsprintf_test7 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/vsprintf/test7/test7.cpp b/src/pal/tests/palsuite/c_runtime/vsprintf/test7/test7.cpp deleted file mode 100644 index c9f87d434..000000000 --- a/src/pal/tests/palsuite/c_runtime/vsprintf/test7/test7.cpp +++ /dev/null @@ -1,44 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test7.c -** -** Purpose: Test #7 for the vsprintf function. -** -** -**===================================================================*/ - -#include -#include "../vsprintf.h" -/* - * Notes: memcmp is used, as is strlen. - */ - - -int __cdecl main(int argc, char *argv[]) -{ - WCHAR wb = (WCHAR) 'b'; - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoWCharTest("foo %c", wb, "foo b"); - DoWCharTest("foo %hc", wb, "foo b"); - DoCharTest("foo %lc", 'c', "foo c"); - DoWCharTest("foo %Lc", wb, "foo b"); - DoWCharTest("foo %I64c", wb, "foo b"); - DoWCharTest("foo %5c", wb, "foo b"); - DoWCharTest("foo %.0c", wb, "foo b"); - DoWCharTest("foo %-5c", wb, "foo b "); - DoWCharTest("foo %05c", wb, "foo 0000b"); - DoWCharTest("foo % c", wb, "foo b"); - DoWCharTest("foo %#c", wb, "foo b"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/vsprintf/test7/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vsprintf/test7/testinfo.dat deleted file mode 100644 index facf60d6a..000000000 --- a/src/pal/tests/palsuite/c_runtime/vsprintf/test7/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = vsprintf -Name = Positive Test for vsprintf -TYPE = DEFAULT -EXE1 = test7 -Description -= Tests the PAL implementation of the vsprintf function. -= Tests vsprintf with wide characters. -= This test is modeled after _snprintf. diff --git a/src/pal/tests/palsuite/c_runtime/vsprintf/test8/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vsprintf/test8/CMakeLists.txt deleted file mode 100644 index 36231aa95..000000000 --- a/src/pal/tests/palsuite/c_runtime/vsprintf/test8/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test8.cpp -) - -add_executable(paltest_vsprintf_test8 - ${SOURCES} -) - -add_dependencies(paltest_vsprintf_test8 coreclrpal) - -target_link_libraries(paltest_vsprintf_test8 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/vsprintf/test8/test8.cpp b/src/pal/tests/palsuite/c_runtime/vsprintf/test8/test8.cpp deleted file mode 100644 index e741d1da8..000000000 --- a/src/pal/tests/palsuite/c_runtime/vsprintf/test8/test8.cpp +++ /dev/null @@ -1,52 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test8.c -** -** Purpose: Test #8 for the vsprintf function. -** -** -**===================================================================*/ - -#include -#include "../vsprintf.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - - -int __cdecl main(int argc, char *argv[]) -{ - int neg = -42; - int pos = 42; - INT64 l = 42; - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoNumTest("foo %d", pos, "foo 42"); - DoNumTest("foo %ld", 0xFFFF, "foo 65535"); - DoNumTest("foo %hd", 0xFFFF, "foo -1"); - DoNumTest("foo %Ld", pos, "foo 42"); - DoI64Test("foo %I64d", l, "42", "foo 42"); - DoNumTest("foo %3d", pos, "foo 42"); - DoNumTest("foo %-3d", pos, "foo 42 "); - DoNumTest("foo %.1d", pos, "foo 42"); - DoNumTest("foo %.3d", pos, "foo 042"); - DoNumTest("foo %03d", pos, "foo 042"); - DoNumTest("foo %#d", pos, "foo 42"); - DoNumTest("foo %+d", pos, "foo +42"); - DoNumTest("foo % d", pos, "foo 42"); - DoNumTest("foo %+d", neg, "foo -42"); - DoNumTest("foo % d", neg, "foo -42"); - - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/vsprintf/test8/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vsprintf/test8/testinfo.dat deleted file mode 100644 index 05f84f499..000000000 --- a/src/pal/tests/palsuite/c_runtime/vsprintf/test8/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = vsprintf -Name = Positive Test for vsprintf -TYPE = DEFAULT -EXE1 = test8 -Description -= Tests the PAL implementation of the vsprintf function. -= Tests vsprintf with decimal numbers. -= This test is modeled after _snprintf. diff --git a/src/pal/tests/palsuite/c_runtime/vsprintf/test9/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vsprintf/test9/CMakeLists.txt deleted file mode 100644 index ca74546b0..000000000 --- a/src/pal/tests/palsuite/c_runtime/vsprintf/test9/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test9.cpp -) - -add_executable(paltest_vsprintf_test9 - ${SOURCES} -) - -add_dependencies(paltest_vsprintf_test9 coreclrpal) - -target_link_libraries(paltest_vsprintf_test9 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/vsprintf/test9/test9.cpp b/src/pal/tests/palsuite/c_runtime/vsprintf/test9/test9.cpp deleted file mode 100644 index e1f7c8419..000000000 --- a/src/pal/tests/palsuite/c_runtime/vsprintf/test9/test9.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test9.c -** -** Purpose: Test #9 for the vsprintf function. -** -** -**===================================================================*/ - -#include -#include "../vsprintf.h" - -/* - * Notes: memcmp is used, as is strlen. - */ - - -int __cdecl main(int argc, char *argv[]) -{ - int neg = -42; - int pos = 42; - INT64 l = 42; - - if (PAL_Initialize(argc, argv) != 0) - { - return(FAIL); - } - - DoNumTest("foo %i", pos, "foo 42"); - DoNumTest("foo %li", 0xFFFF, "foo 65535"); - DoNumTest("foo %hi", 0xFFFF, "foo -1"); - DoNumTest("foo %Li", pos, "foo 42"); - DoI64Test("foo %I64i", l, "42", "foo 42"); - DoNumTest("foo %3i", pos, "foo 42"); - DoNumTest("foo %-3i", pos, "foo 42 "); - DoNumTest("foo %.1i", pos, "foo 42"); - DoNumTest("foo %.3i", pos, "foo 042"); - DoNumTest("foo %03i", pos, "foo 042"); - DoNumTest("foo %#i", pos, "foo 42"); - DoNumTest("foo %+i", pos, "foo +42"); - DoNumTest("foo % i", pos, "foo 42"); - DoNumTest("foo %+i", neg, "foo -42"); - DoNumTest("foo % i", neg, "foo -42"); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/vsprintf/test9/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vsprintf/test9/testinfo.dat deleted file mode 100644 index 3bc0057c9..000000000 --- a/src/pal/tests/palsuite/c_runtime/vsprintf/test9/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = vsprintf -Name = Positive Test for vsprintf -TYPE = DEFAULT -EXE1 = test9 -Description -= Tests the PAL implementation of the vsprintf function. -= Tests vsprintf with integer numbers. -= This test is modeled after _snprintf. diff --git a/src/pal/tests/palsuite/c_runtime/vsprintf/vsprintf.h b/src/pal/tests/palsuite/c_runtime/vsprintf/vsprintf.h deleted file mode 100644 index 22bf53e53..000000000 --- a/src/pal/tests/palsuite/c_runtime/vsprintf/vsprintf.h +++ /dev/null @@ -1,218 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: vsprintf.h -** -** Purpose: Helper functions for the vsprintf tests. -** -** -**===================================================================*/ -#ifndef __VSPRINTF_H__ -#define __VSPRINTF_H__ - -/* These functions leaks memory like crazy. C'est la vie. */ -int testvsp(char* buf, size_t buffSize, const char* format, ...) -{ - int retVal; - va_list arglist; - - va_start(arglist, format); - retVal = _vsnprintf_s(buf, buffSize, _TRUNCATE, format, arglist); - va_end(arglist); - - return (retVal); -} - -void DoStrTest(const char *formatstr, char* param, const char *checkstr) -{ - char buf[256] = { 0 }; - - testvsp(buf, _countof(buf), formatstr, param); - if (memcmp(buf, checkstr, strlen(buf) + 1) != 0) - { - Fail("ERROR: failed to insert string \"%s\" into \"%s\"\n" - "Expected \"%s\" got \"%s\".\n", - param, formatstr, checkstr, buf); - } -} - -void DoWStrTest(const char *formatstr, WCHAR* param, const char *checkstr) -{ - char buf[256] = { 0 }; - - testvsp(buf, _countof(buf), formatstr, param); - if (memcmp(buf, checkstr, strlen(buf) + 1) != 0) - { - Fail("ERROR: failed to insert wide string \"%s\" into \"%s\"\n" - "Expected \"%s\" got \"%s\".\n", - convertC(param), formatstr, checkstr, buf); - } -} - - -void DoCharTest(const char *formatstr, char param, const char *checkstr) -{ - char buf[256] = { 0 }; - - testvsp(buf, _countof(buf), formatstr, param); - if (memcmp(buf, checkstr, strlen(buf) + 1) != 0) - { - Fail("ERROR: failed to insert char \'%c\' (%d) into \"%s\"\n" - "Expected \"%s\" got \"%s\".\n", - param, param, formatstr, checkstr, buf); - } -} - -void DoWCharTest(const char *formatstr, WCHAR param, const char *checkstr) -{ - char buf[256] = { 0 }; - - testvsp(buf, _countof(buf), formatstr, param); - if (memcmp(buf, checkstr, strlen(buf) + 1) != 0) - { - Fail("ERROR: failed to insert wide char \'%c\' (%d) into \"%s\"\n" - "Expected \"%s\" got \"%s\".\n", - (char)param, param, formatstr, checkstr, buf); - } -} - -void DoNumTest(const char *formatstr, int value, const char *checkstr) -{ - char buf[256] = { 0 }; - - testvsp(buf, _countof(buf), formatstr, value); - if (memcmp(buf, checkstr, strlen(buf) + 1) != 0) - { - Fail("ERROR: failed to insert %#x into \"%s\"\n" - "Expected \"%s\" got \"%s\".\n", - value, formatstr, checkstr, buf); - } -} - -void DoI64Test(const char *formatstr, INT64 value, char *valuestr, const char *checkstr) -{ - char buf[256] = { 0 }; - - testvsp(buf, _countof(buf), formatstr, value); - if (memcmp(buf, checkstr, strlen(buf) + 1) != 0) - { - Fail("ERROR: failed to insert %s into \"%s\"\n" - "Expected \"%s\" got \"%s\".\n", - valuestr, formatstr, checkstr, buf); - } -} -void DoDoubleTest(const char *formatstr, double value, const char *checkstr1, char -*checkstr2) -{ - char buf[256] = { 0 }; - - testvsp(buf, _countof(buf), formatstr, value); - if (memcmp(buf, checkstr1, strlen(checkstr1) + 1) != 0 && - memcmp(buf, checkstr2, strlen(checkstr2) + 1) != 0) - { - Fail("ERROR: failed to insert %f into \"%s\"\n" - "Expected \"%s\" or \"%s\", got \"%s\".\n", - value, formatstr, checkstr1, checkstr2, buf); - } -} -/*FROM TEST 9*/ -void DoArgumentPrecTest(const char *formatstr, int precision, void *param, - char *paramstr, const char *checkstr1, const char *checkstr2) -{ - char buf[256]; - - testvsp(buf, _countof(buf), formatstr, precision, param); - if (memcmp(buf, checkstr1, strlen(checkstr1) + 1) != 0 && - memcmp(buf, checkstr2, strlen(checkstr2) + 1) != 0) - { - Fail("ERROR: failed to insert %s into \"%s\" with precision %d\n" - "Expected \"%s\" or \"%s\", got \"%s\".\n", paramstr, formatstr, - precision, checkstr1, checkstr2, buf); - } - -} - -void DoArgumentPrecDoubleTest(const char *formatstr, int precision, double param, - const char *checkstr1, const char *checkstr2) -{ - char buf[256]; - - testvsp(buf, _countof(buf), formatstr, precision, param); - if (memcmp(buf, checkstr1, strlen(checkstr1) + 1) != 0 && - memcmp(buf, checkstr2, strlen(checkstr2) + 1) != 0) - { - Fail("ERROR: failed to insert %f into \"%s\" with precision %d\n" - "Expected \"%s\" or \"%s\", got \"%s\".\n", param, formatstr, - precision, checkstr1, checkstr2, buf); - } -} -/*FROM TEST4*/ -void DoPointerTest(const char *formatstr, void* param, char* paramstr, - const char *checkstr1) -{ - char buf[256] = { 0 }; - - testvsp(buf, _countof(buf), formatstr, param); - if (memcmp(buf, checkstr1, strlen(checkstr1) + 1)) - { - Fail("ERROR: failed to insert %s into \"%s\"\n" - "Expected \"%s\" got \"%s\".\n", - paramstr, formatstr, checkstr1, buf); - } -} - -void DoI64DoubleTest(const char *formatstr, INT64 value, char *valuestr, - const char *checkstr1) -{ - char buf[256] = { 0 }; - - testvsp(buf, _countof(buf), formatstr, value); - if (memcmp(buf, checkstr1, strlen(checkstr1) + 1) != 0) - { - Fail("ERROR: failed to insert %s into \"%s\"\n" - "Expected \"%s\", got \"%s\".\n", - valuestr, formatstr, checkstr1, buf); - } -} - -void DoTest(const char *formatstr, int param, const char *checkstr) -{ - char buf[256] = { 0 }; - int n = -1; - - testvsp(buf, _countof(buf), formatstr, &n); - - if (n != param) - { - Fail("ERROR: Expected count parameter to resolve to %d, got %X\n", - param, n); - } - if (memcmp(buf, checkstr, strlen(buf) + 1) != 0) - { - Fail("ERROR: Expected \"%s\" got \"%s\".\n", checkstr, buf); - } -} - -void DoShortTest(const char *formatstr, int param, const char *checkstr) -{ - char buf[256] = { 0 }; - short int n = -1; - - testvsp(buf, _countof(buf), formatstr, &n); - - if (n != param) - { - Fail("ERROR: Expected count parameter to resolve to %d, got %X\n", - param, n); - } - if (memcmp(buf, checkstr, strlen(buf) + 1) != 0) - { - Fail("ERROR: Expected \"%s\" got \"%s\".\n", checkstr, buf); - } -} - -#endif - diff --git a/src/pal/tests/palsuite/c_runtime/vswprintf/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vswprintf/CMakeLists.txt deleted file mode 100644 index 8fe1cb60a..000000000 --- a/src/pal/tests/palsuite/c_runtime/vswprintf/CMakeLists.txt +++ /dev/null @@ -1,21 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test10) -add_subdirectory(test11) -add_subdirectory(test12) -add_subdirectory(test13) -add_subdirectory(test14) -add_subdirectory(test15) -add_subdirectory(test16) -add_subdirectory(test17) -add_subdirectory(test18) -add_subdirectory(test19) -add_subdirectory(test2) -add_subdirectory(test3) -add_subdirectory(test4) -add_subdirectory(test6) -add_subdirectory(test7) -add_subdirectory(test8) -add_subdirectory(test9) - diff --git a/src/pal/tests/palsuite/c_runtime/vswprintf/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vswprintf/test1/CMakeLists.txt deleted file mode 100644 index 6b23e5034..000000000 --- a/src/pal/tests/palsuite/c_runtime/vswprintf/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_vswprintf_test1 - ${SOURCES} -) - -add_dependencies(paltest_vswprintf_test1 coreclrpal) - -target_link_libraries(paltest_vswprintf_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/vswprintf/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/vswprintf/test1/test1.cpp deleted file mode 100644 index 968f8a5c6..000000000 --- a/src/pal/tests/palsuite/c_runtime/vswprintf/test1/test1.cpp +++ /dev/null @@ -1,41 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test1.c -** -** Purpose: Test #1 for the vswprintf function. -** -** -**===================================================================*/ - -#include -#include "../vswprintf.h" - -/* memcmp is used to verify the results, so this test is dependent on it. */ -/* ditto with wcslen */ - - -int __cdecl main(int argc, char *argv[]) -{ - WCHAR *checkstr = NULL; - WCHAR buf[256] = { 0 }; - - if (PAL_Initialize(argc, argv) != 0) - return(FAIL); - - checkstr = convert("hello world"); - testvswp(buf, _countof(buf), checkstr); - - if (memcmp(checkstr, buf, wcslen(checkstr)*2+2) != 0) - { - Fail("ERROR: Expected \"%s\", got \"%s\"\n", - convertC(checkstr), convertC(buf)); - } - - free(checkstr); - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/vswprintf/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vswprintf/test1/testinfo.dat deleted file mode 100644 index 6161190d4..000000000 --- a/src/pal/tests/palsuite/c_runtime/vswprintf/test1/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = vswprintf -Name = Positive Test for vswprintf -TYPE = DEFAULT -EXE1 = test1 -Description -= Tests the PAL implementation of the vswprintf function. -= General test to see if vswprintf works correctly. -= This test is modeled after _snwprintf. diff --git a/src/pal/tests/palsuite/c_runtime/vswprintf/test10/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vswprintf/test10/CMakeLists.txt deleted file mode 100644 index 4e6171ec6..000000000 --- a/src/pal/tests/palsuite/c_runtime/vswprintf/test10/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test10.cpp -) - -add_executable(paltest_vswprintf_test10 - ${SOURCES} -) - -add_dependencies(paltest_vswprintf_test10 coreclrpal) - -target_link_libraries(paltest_vswprintf_test10 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/vswprintf/test10/test10.cpp b/src/pal/tests/palsuite/c_runtime/vswprintf/test10/test10.cpp deleted file mode 100644 index 7f316e28f..000000000 --- a/src/pal/tests/palsuite/c_runtime/vswprintf/test10/test10.cpp +++ /dev/null @@ -1,48 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test10.c -** -** Purpose: Test #10 for the vswprintf function. -** -** -**===================================================================*/ - -#include -#include "../vswprintf.h" - -/* memcmp is used to verify the results, so this test is dependent on it. */ -/* ditto with wcslen */ - -int __cdecl main(int argc, char *argv[]) -{ - int neg = -42; - int pos = 42; - INT64 l = 42; - - if (PAL_Initialize(argc, argv) != 0) - return(FAIL); - - DoNumTest(convert("foo %o"), pos, convert("foo 52")); - DoNumTest(convert("foo %lo"), 0xFFFF, convert("foo 177777")); - DoNumTest(convert("foo %ho"), 0xFFFF, convert("foo 177777")); - DoNumTest(convert("foo %Lo"), pos, convert("foo 52")); - DoI64NumTest(convert("foo %I64o"), l, "42", convert("foo 52")); - DoNumTest(convert("foo %3o"), pos, convert("foo 52")); - DoNumTest(convert("foo %-3o"), pos, convert("foo 52 ")); - DoNumTest(convert("foo %.1o"), pos, convert("foo 52")); - DoNumTest(convert("foo %.3o"), pos, convert("foo 052")); - DoNumTest(convert("foo %03o"), pos, convert("foo 052")); - DoNumTest(convert("foo %#o"), pos, convert("foo 052")); - DoNumTest(convert("foo %+o"), pos, convert("foo 52")); - DoNumTest(convert("foo % o"), pos, convert("foo 52")); - DoNumTest(convert("foo %+o"), neg, convert("foo 37777777726")); - DoNumTest(convert("foo % o"), neg, convert("foo 37777777726")); - - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/vswprintf/test10/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vswprintf/test10/testinfo.dat deleted file mode 100644 index 81fbce5e4..000000000 --- a/src/pal/tests/palsuite/c_runtime/vswprintf/test10/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = vswprintf -Name = Positive Test for vswprintf -TYPE = DEFAULT -EXE1 = test10 -Description -= Tests the PAL implementation of the vswprintf function. -= Tests vswprintf with octal numbers. -= This test is modeled after _snwprintf. diff --git a/src/pal/tests/palsuite/c_runtime/vswprintf/test11/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vswprintf/test11/CMakeLists.txt deleted file mode 100644 index 9e37b63b1..000000000 --- a/src/pal/tests/palsuite/c_runtime/vswprintf/test11/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test11.cpp -) - -add_executable(paltest_vswprintf_test11 - ${SOURCES} -) - -add_dependencies(paltest_vswprintf_test11 coreclrpal) - -target_link_libraries(paltest_vswprintf_test11 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/vswprintf/test11/test11.cpp b/src/pal/tests/palsuite/c_runtime/vswprintf/test11/test11.cpp deleted file mode 100644 index 608069f82..000000000 --- a/src/pal/tests/palsuite/c_runtime/vswprintf/test11/test11.cpp +++ /dev/null @@ -1,48 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test11.c -** -** Purpose: Test #11 for the vswprintf function. -** -** -**===================================================================*/ - -#include -#include "../vswprintf.h" - -/* memcmp is used to verify the results, so this test is dependent on it. */ -/* ditto with wcslen */ - -int __cdecl main(int argc, char *argv[]) -{ - int neg = -42; - int pos = 42; - INT64 l = 42; - - if (PAL_Initialize(argc, argv) != 0) - return(FAIL); - - DoNumTest(convert("foo %u"), pos, convert("foo 42")); - DoNumTest(convert("foo %lu"), 0xFFFF, convert("foo 65535")); - DoNumTest(convert("foo %hu"), 0xFFFF, convert("foo 65535")); - DoNumTest(convert("foo %Lu"), pos, convert("foo 42")); - DoI64NumTest(convert("foo %I64u"), l, "42", convert("foo 42")); - DoNumTest(convert("foo %3u"), pos, convert("foo 42")); - DoNumTest(convert("foo %-3u"), pos, convert("foo 42 ")); - DoNumTest(convert("foo %.1u"), pos, convert("foo 42")); - DoNumTest(convert("foo %.3u"), pos, convert("foo 042")); - DoNumTest(convert("foo %03u"), pos, convert("foo 042")); - DoNumTest(convert("foo %#u"), pos, convert("foo 42")); - DoNumTest(convert("foo %+u"), pos, convert("foo 42")); - DoNumTest(convert("foo % u"), pos, convert("foo 42")); - DoNumTest(convert("foo %+u"), neg, convert("foo 4294967254")); - DoNumTest(convert("foo % u"), neg, convert("foo 4294967254")); - - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/vswprintf/test11/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vswprintf/test11/testinfo.dat deleted file mode 100644 index 13585cc94..000000000 --- a/src/pal/tests/palsuite/c_runtime/vswprintf/test11/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = vswprintf -Name = Positive Test for vswprintf -TYPE = DEFAULT -EXE1 = test11 -Description -= Tests the PAL implementation of the vswprintf function. -= Tests vswprintf with unsigned numbers. -= This test is modeled after _snwprintf. diff --git a/src/pal/tests/palsuite/c_runtime/vswprintf/test12/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vswprintf/test12/CMakeLists.txt deleted file mode 100644 index 2747ebf46..000000000 --- a/src/pal/tests/palsuite/c_runtime/vswprintf/test12/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test12.cpp -) - -add_executable(paltest_vswprintf_test12 - ${SOURCES} -) - -add_dependencies(paltest_vswprintf_test12 coreclrpal) - -target_link_libraries(paltest_vswprintf_test12 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/vswprintf/test12/test12.cpp b/src/pal/tests/palsuite/c_runtime/vswprintf/test12/test12.cpp deleted file mode 100644 index 36b203853..000000000 --- a/src/pal/tests/palsuite/c_runtime/vswprintf/test12/test12.cpp +++ /dev/null @@ -1,48 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test12.c -** -** Purpose: Test #12 for the vswprintf function. -** -** -**===================================================================*/ - -#include -#include "../vswprintf.h" - -/* memcmp is used to verify the results, so this test is dependent on it. */ -/* ditto with wcslen */ - -int __cdecl main(int argc, char *argv[]) -{ - int neg = -42; - int pos = 0x1234ab; - INT64 l = I64(0x1234567887654321); - - if (PAL_Initialize(argc, argv) != 0) - return(FAIL); - - DoNumTest(convert("foo %x"), pos, convert("foo 1234ab")); - DoNumTest(convert("foo %lx"), pos, convert("foo 1234ab")); - DoNumTest(convert("foo %hx"), pos, convert("foo 34ab")); - DoNumTest(convert("foo %Lx"), pos, convert("foo 1234ab")); - DoI64NumTest(convert("foo %I64x"), l, "0x1234567887654321", - convert("foo 1234567887654321")); - DoNumTest(convert("foo %7x"), pos, convert("foo 1234ab")); - DoNumTest(convert("foo %-7x"), pos, convert("foo 1234ab ")); - DoNumTest(convert("foo %.1x"), pos, convert("foo 1234ab")); - DoNumTest(convert("foo %.7x"), pos, convert("foo 01234ab")); - DoNumTest(convert("foo %07x"), pos, convert("foo 01234ab")); - DoNumTest(convert("foo %#x"), pos, convert("foo 0x1234ab")); - DoNumTest(convert("foo %+x"), pos, convert("foo 1234ab")); - DoNumTest(convert("foo % x"), pos, convert("foo 1234ab")); - DoNumTest(convert("foo %+x"), neg, convert("foo ffffffd6")); - DoNumTest(convert("foo % x"), neg, convert("foo ffffffd6")); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/vswprintf/test12/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vswprintf/test12/testinfo.dat deleted file mode 100644 index d42e9a180..000000000 --- a/src/pal/tests/palsuite/c_runtime/vswprintf/test12/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = vswprintf -Name = Positive Test for vswprintf -TYPE = DEFAULT -EXE1 = test12 -Description -= Tests the PAL implementation of the vswprintf function. -= Tests vswprintf with hex numbers (lowercase). -= This test is modeled after _snwprintf. diff --git a/src/pal/tests/palsuite/c_runtime/vswprintf/test13/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vswprintf/test13/CMakeLists.txt deleted file mode 100644 index 4c96d3fec..000000000 --- a/src/pal/tests/palsuite/c_runtime/vswprintf/test13/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test13.cpp -) - -add_executable(paltest_vswprintf_test13 - ${SOURCES} -) - -add_dependencies(paltest_vswprintf_test13 coreclrpal) - -target_link_libraries(paltest_vswprintf_test13 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/vswprintf/test13/test13.cpp b/src/pal/tests/palsuite/c_runtime/vswprintf/test13/test13.cpp deleted file mode 100644 index 63dc36a96..000000000 --- a/src/pal/tests/palsuite/c_runtime/vswprintf/test13/test13.cpp +++ /dev/null @@ -1,48 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test13.c -** -** Purpose: Test #13 for the vswprintf function. -** -** -**===================================================================*/ - -#include -#include "../vswprintf.h" - -/* memcmp is used to verify the results, so this test is dependent on it. */ -/* ditto with wcslen */ - -int __cdecl main(int argc, char *argv[]) -{ - int neg = -42; - int pos = 0x1234ab; - INT64 l = I64(0x1234567887654321); - - if (PAL_Initialize(argc, argv) != 0) - return(FAIL); - - DoNumTest(convert("foo %X"), pos, convert("foo 1234AB")); - DoNumTest(convert("foo %lX"), pos, convert("foo 1234AB")); - DoNumTest(convert("foo %hX"), pos, convert("foo 34AB")); - DoNumTest(convert("foo %LX"), pos, convert("foo 1234AB")); - DoI64NumTest(convert("foo %I64X"), l, "0x1234567887654321", - convert("foo 1234567887654321")); - DoNumTest(convert("foo %7X"), pos, convert("foo 1234AB")); - DoNumTest(convert("foo %-7X"), pos, convert("foo 1234AB ")); - DoNumTest(convert("foo %.1X"), pos, convert("foo 1234AB")); - DoNumTest(convert("foo %.7X"), pos, convert("foo 01234AB")); - DoNumTest(convert("foo %07X"), pos, convert("foo 01234AB")); - DoNumTest(convert("foo %#X"), pos, convert("foo 0X1234AB")); - DoNumTest(convert("foo %+X"), pos, convert("foo 1234AB")); - DoNumTest(convert("foo % X"), pos, convert("foo 1234AB")); - DoNumTest(convert("foo %+X"), neg, convert("foo FFFFFFD6")); - DoNumTest(convert("foo % X"), neg, convert("foo FFFFFFD6")); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/vswprintf/test13/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vswprintf/test13/testinfo.dat deleted file mode 100644 index f7c6756e3..000000000 --- a/src/pal/tests/palsuite/c_runtime/vswprintf/test13/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = vswprintf -Name = Positive Test for vswprintf -TYPE = DEFAULT -EXE1 = test13 -Description -= Tests the PAL implementation of the vswprintf function. -= Tests vswprintf with hex numbers (uppercase). -= This test is modeled after _snwprintf. diff --git a/src/pal/tests/palsuite/c_runtime/vswprintf/test14/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vswprintf/test14/CMakeLists.txt deleted file mode 100644 index 62a9efc66..000000000 --- a/src/pal/tests/palsuite/c_runtime/vswprintf/test14/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test14.cpp -) - -add_executable(paltest_vswprintf_test14 - ${SOURCES} -) - -add_dependencies(paltest_vswprintf_test14 coreclrpal) - -target_link_libraries(paltest_vswprintf_test14 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/vswprintf/test14/test14.cpp b/src/pal/tests/palsuite/c_runtime/vswprintf/test14/test14.cpp deleted file mode 100644 index bb4ab16a5..000000000 --- a/src/pal/tests/palsuite/c_runtime/vswprintf/test14/test14.cpp +++ /dev/null @@ -1,61 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test14.c -** -** Purpose: Test #14 for the vswprintf function. -** -** -**===================================================================*/ - -#include -#include "../vswprintf.h" - -/* memcmp is used to verify the results, so this test is dependent on it. */ -/* ditto with wcslen */ - -int __cdecl main(int argc, char *argv[]) -{ - double val = 256.0; - double neg = -256.0; - - if (PAL_Initialize(argc, argv) != 0) - return(FAIL); - - DoDoubleTest(convert("foo %e"), val, convert("foo 2.560000e+002"), - convert("foo 2.560000e+02")); - DoDoubleTest(convert("foo %le"), val, convert("foo 2.560000e+002"), - convert("foo 2.560000e+02")); - DoDoubleTest(convert("foo %he"), val, convert("foo 2.560000e+002"), - convert("foo 2.560000e+02")); - DoDoubleTest(convert("foo %Le"), val, convert("foo 2.560000e+002"), - convert("foo 2.560000e+02")); - DoDoubleTest(convert("foo %I64e"), val, convert("foo 2.560000e+002"), - convert("foo 2.560000e+02")); - DoDoubleTest(convert("foo %14e"), val, convert("foo 2.560000e+002"), - convert("foo 2.560000e+02")); - DoDoubleTest(convert("foo %-14e"), val, convert("foo 2.560000e+002 "), - convert("foo 2.560000e+02 ")); - DoDoubleTest(convert("foo %.1e"), val, convert("foo 2.6e+002"), - convert("foo 2.6e+02")); - DoDoubleTest(convert("foo %.8e"), val, convert("foo 2.56000000e+002"), - convert("foo 2.56000000e+02")); - DoDoubleTest(convert("foo %014e"), val, convert("foo 02.560000e+002"), - convert("foo 002.560000e+02")); - DoDoubleTest(convert("foo %#e"), val, convert("foo 2.560000e+002"), - convert("foo 2.560000e+02")); - DoDoubleTest(convert("foo %+e"), val, convert("foo +2.560000e+002"), - convert("foo +2.560000e+02")); - DoDoubleTest(convert("foo % e"), val, convert("foo 2.560000e+002"), - convert("foo 2.560000e+02")); - DoDoubleTest(convert("foo %+e"), neg, convert("foo -2.560000e+002"), - convert("foo -2.560000e+02")); - DoDoubleTest(convert("foo % e"), neg, convert("foo -2.560000e+002"), - convert("foo -2.560000e+02")); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/vswprintf/test14/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vswprintf/test14/testinfo.dat deleted file mode 100644 index e9615f906..000000000 --- a/src/pal/tests/palsuite/c_runtime/vswprintf/test14/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = vswprintf -Name = Positive Test for vswprintf -TYPE = DEFAULT -EXE1 = test14 -Description -= Tests the PAL implementation of the vswprintf function. -= Tests vswprintf with exponential format doubles (lowercase). -= This test is modeled after _snwprintf. diff --git a/src/pal/tests/palsuite/c_runtime/vswprintf/test15/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vswprintf/test15/CMakeLists.txt deleted file mode 100644 index 2142c5304..000000000 --- a/src/pal/tests/palsuite/c_runtime/vswprintf/test15/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test15.cpp -) - -add_executable(paltest_vswprintf_test15 - ${SOURCES} -) - -add_dependencies(paltest_vswprintf_test15 coreclrpal) - -target_link_libraries(paltest_vswprintf_test15 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/vswprintf/test15/test15.cpp b/src/pal/tests/palsuite/c_runtime/vswprintf/test15/test15.cpp deleted file mode 100644 index 6296220c4..000000000 --- a/src/pal/tests/palsuite/c_runtime/vswprintf/test15/test15.cpp +++ /dev/null @@ -1,62 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test15.c -** -** Purpose: Test #15 for the vswprintf function. -** -** -**===================================================================*/ - -#include -#include "../vswprintf.h" - -/* memcmp is used to verify the results, so this test is dependent on it. */ -/* ditto with wcslen */ - - -int __cdecl main(int argc, char *argv[]) -{ - double val = 256.0; - double neg = -256.0; - - if (PAL_Initialize(argc, argv) != 0) - return(FAIL); - - DoDoubleTest(convert("foo %E"), val, convert("foo 2.560000E+002"), - convert("foo 2.560000E+02")); - DoDoubleTest(convert("foo %lE"), val, convert("foo 2.560000E+002"), - convert("foo 2.560000E+02")); - DoDoubleTest(convert("foo %hE"), val, convert("foo 2.560000E+002"), - convert("foo 2.560000E+02")); - DoDoubleTest(convert("foo %LE"), val, convert("foo 2.560000E+002"), - convert("foo 2.560000E+02")); - DoDoubleTest(convert("foo %I64E"), val, convert("foo 2.560000E+002"), - convert("foo 2.560000E+02")); - DoDoubleTest(convert("foo %14E"), val, convert("foo 2.560000E+002"), - convert("foo 2.560000E+02")); - DoDoubleTest(convert("foo %-14E"), val, convert("foo 2.560000E+002 "), - convert("foo 2.560000E+02 ")); - DoDoubleTest(convert("foo %.1E"), val, convert("foo 2.6E+002"), - convert("foo 2.6E+02")); - DoDoubleTest(convert("foo %.8E"), val, convert("foo 2.56000000E+002"), - convert("foo 2.56000000E+02")); - DoDoubleTest(convert("foo %014E"), val, convert("foo 02.560000E+002"), - convert("foo 002.560000E+02")); - DoDoubleTest(convert("foo %#E"), val, convert("foo 2.560000E+002"), - convert("foo 2.560000E+02")); - DoDoubleTest(convert("foo %+E"), val, convert("foo +2.560000E+002"), - convert("foo +2.560000E+02")); - DoDoubleTest(convert("foo % E"), val, convert("foo 2.560000E+002"), - convert("foo 2.560000E+02")); - DoDoubleTest(convert("foo %+E"), neg, convert("foo -2.560000E+002"), - convert("foo -2.560000E+02")); - DoDoubleTest(convert("foo % E"), neg, convert("foo -2.560000E+002"), - convert("foo -2.560000E+002")); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/vswprintf/test15/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vswprintf/test15/testinfo.dat deleted file mode 100644 index 24ff03b11..000000000 --- a/src/pal/tests/palsuite/c_runtime/vswprintf/test15/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = vswprintf -Name = Positive Test for vswprintf -TYPE = DEFAULT -EXE1 = test15 -Description -= Tests the PAL implementation of the vswprintf function. -= Tests vswprintf with exponential format doubles (uppercase). -= This test is modeled after _snwprintf. diff --git a/src/pal/tests/palsuite/c_runtime/vswprintf/test16/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vswprintf/test16/CMakeLists.txt deleted file mode 100644 index 44fd1145b..000000000 --- a/src/pal/tests/palsuite/c_runtime/vswprintf/test16/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test16.cpp -) - -add_executable(paltest_vswprintf_test16 - ${SOURCES} -) - -add_dependencies(paltest_vswprintf_test16 coreclrpal) - -target_link_libraries(paltest_vswprintf_test16 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/vswprintf/test16/test16.cpp b/src/pal/tests/palsuite/c_runtime/vswprintf/test16/test16.cpp deleted file mode 100644 index 3a2059a49..000000000 --- a/src/pal/tests/palsuite/c_runtime/vswprintf/test16/test16.cpp +++ /dev/null @@ -1,61 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test16.c -** -** Purpose: Test #16 for the vswprintf function. -** -** -**===================================================================*/ - -#include -#include "../vswprintf.h" - -/* memcmp is used to verify the results, so this test is dependent on it. */ -/* ditto with wcslen */ - -int __cdecl main(int argc, char *argv[]) -{ - double val = 2560.001; - double neg = -2560.001; - - if (PAL_Initialize(argc, argv) != 0) - return(FAIL); - - DoDoubleTest(convert("foo %f"), val, convert("foo 2560.001000"), - convert("foo 2560.001000")); - DoDoubleTest(convert("foo %lf"), val, convert("foo 2560.001000"), - convert("foo 2560.001000")); - DoDoubleTest(convert("foo %hf"), val, convert("foo 2560.001000"), - convert("foo 2560.001000")); - DoDoubleTest(convert("foo %Lf"), val, convert("foo 2560.001000"), - convert("foo 2560.001000")); - DoDoubleTest(convert("foo %I64f"), val, convert("foo 2560.001000"), - convert("foo 2560.001000")); - DoDoubleTest(convert("foo %12f"), val, convert("foo 2560.001000"), - convert("foo 2560.001000")); - DoDoubleTest(convert("foo %-12f"), val, convert("foo 2560.001000 "), - convert("foo 2560.001000 ")); - DoDoubleTest(convert("foo %.1f"), val, convert("foo 2560.0"), - convert("foo 2560.0")); - DoDoubleTest(convert("foo %.8f"), val, convert("foo 2560.00100000"), - convert("foo 2560.00100000")); - DoDoubleTest(convert("foo %012f"), val, convert("foo 02560.001000"), - convert("foo 02560.001000")); - DoDoubleTest(convert("foo %#f"), val, convert("foo 2560.001000"), - convert("foo 2560.001000")); - DoDoubleTest(convert("foo %+f"), val, convert("foo +2560.001000"), - convert("foo +2560.001000")); - DoDoubleTest(convert("foo % f"), val, convert("foo 2560.001000"), - convert("foo 2560.001000")); - DoDoubleTest(convert("foo %+f"), neg, convert("foo -2560.001000"), - convert("foo -2560.001000")); - DoDoubleTest(convert("foo % f"), neg, convert("foo -2560.001000"), - convert("foo -2560.001000")); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/vswprintf/test16/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vswprintf/test16/testinfo.dat deleted file mode 100644 index 6dc45f4c7..000000000 --- a/src/pal/tests/palsuite/c_runtime/vswprintf/test16/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = vswprintf -Name = Positive Test for vswprintf -TYPE = DEFAULT -EXE1 = test16 -Description -= Tests the PAL implementation of the vswprintf function. -= Tests vswprintf with decimal point format doubles. -= This test is modeled after _snwprintf. diff --git a/src/pal/tests/palsuite/c_runtime/vswprintf/test17/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vswprintf/test17/CMakeLists.txt deleted file mode 100644 index 2d1d8cd85..000000000 --- a/src/pal/tests/palsuite/c_runtime/vswprintf/test17/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test17.cpp -) - -add_executable(paltest_vswprintf_test17 - ${SOURCES} -) - -add_dependencies(paltest_vswprintf_test17 coreclrpal) - -target_link_libraries(paltest_vswprintf_test17 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/vswprintf/test17/test17.cpp b/src/pal/tests/palsuite/c_runtime/vswprintf/test17/test17.cpp deleted file mode 100644 index 95e3bd999..000000000 --- a/src/pal/tests/palsuite/c_runtime/vswprintf/test17/test17.cpp +++ /dev/null @@ -1,63 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test17.c -** -** Purpose: Test #17 for the vswprintf function. -** -** -**===================================================================*/ - -#include -#include "../vswprintf.h" - -/* memcmp is used to verify the results, so this test is dependent on it. */ -/* ditto with wcslen */ - -int __cdecl main(int argc, char *argv[]) -{ - double val = 2560.001; - double neg = -2560.001; - - if (PAL_Initialize(argc, argv) != 0) - return(FAIL); - - DoDoubleTest(convert("foo %g"), val, convert("foo 2560"), - convert("foo 2560")); - DoDoubleTest(convert("foo %lg"), val, convert("foo 2560"), - convert("foo 2560")); - DoDoubleTest(convert("foo %hg"), val, convert("foo 2560"), - convert("foo 2560")); - DoDoubleTest(convert("foo %Lg"), val, convert("foo 2560"), - convert("foo 2560")); - DoDoubleTest(convert("foo %I64g"), val, convert("foo 2560"), - convert("foo 2560")); - DoDoubleTest(convert("foo %5g"), val, convert("foo 2560"), - convert("foo 2560")); - DoDoubleTest(convert("foo %-5g"), val, convert("foo 2560 "), - convert("foo 2560 ")); - DoDoubleTest(convert("foo %.1g"), val, convert("foo 3e+003"), - convert("foo 3e+03")); - DoDoubleTest(convert("foo %.2g"), val, convert("foo 2.6e+003"), - convert("foo 2.6e+03")); - DoDoubleTest(convert("foo %.12g"), val, convert("foo 2560.001"), - convert("foo 2560.001")); - DoDoubleTest(convert("foo %06g"), val, convert("foo 002560"), - convert("foo 002560")); - DoDoubleTest(convert("foo %#g"), val, convert("foo 2560.00"), - convert("foo 2560.00")); - DoDoubleTest(convert("foo %+g"), val, convert("foo +2560"), - convert("foo +2560")); - DoDoubleTest(convert("foo % g"), val, convert("foo 2560"), - convert("foo 2560")); - DoDoubleTest(convert("foo %+g"), neg, convert("foo -2560"), - convert("foo -2560")); - DoDoubleTest(convert("foo % g"), neg, convert("foo -2560"), - convert("foo -2560")); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/vswprintf/test17/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vswprintf/test17/testinfo.dat deleted file mode 100644 index 815e57ddf..000000000 --- a/src/pal/tests/palsuite/c_runtime/vswprintf/test17/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = vswprintf -Name = Positive Test for vswprintf -TYPE = DEFAULT -EXE1 = test17 -Description -= Tests the PAL implementation of the vswprintf function. -= Tests vswprintf with compact format doubles (lowercase). -= This test is modeled after _snwprintf. diff --git a/src/pal/tests/palsuite/c_runtime/vswprintf/test18/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vswprintf/test18/CMakeLists.txt deleted file mode 100644 index d561baef8..000000000 --- a/src/pal/tests/palsuite/c_runtime/vswprintf/test18/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test18.cpp -) - -add_executable(paltest_vswprintf_test18 - ${SOURCES} -) - -add_dependencies(paltest_vswprintf_test18 coreclrpal) - -target_link_libraries(paltest_vswprintf_test18 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/vswprintf/test18/test18.cpp b/src/pal/tests/palsuite/c_runtime/vswprintf/test18/test18.cpp deleted file mode 100644 index ae7ae4c44..000000000 --- a/src/pal/tests/palsuite/c_runtime/vswprintf/test18/test18.cpp +++ /dev/null @@ -1,63 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test18.c -** -** Purpose: Test #18 for the vswprintf function. -** -** -**===================================================================*/ - -#include -#include "../vswprintf.h" - -/* memcmp is used to verify the results, so this test is dependent on it. */ -/* ditto with wcslen */ - -int __cdecl main(int argc, char *argv[]) -{ - double val = 2560.001; - double neg = -2560.001; - - if (PAL_Initialize(argc, argv) != 0) - return(FAIL); - - DoDoubleTest(convert("foo %G"), val, convert("foo 2560"), - convert("foo 2560")); - DoDoubleTest(convert("foo %lG"), val, convert("foo 2560"), - convert("foo 2560")); - DoDoubleTest(convert("foo %hG"), val, convert("foo 2560"), - convert("foo 2560")); - DoDoubleTest(convert("foo %LG"), val, convert("foo 2560"), - convert("foo 2560")); - DoDoubleTest(convert("foo %I64G"), val, convert("foo 2560"), - convert("foo 2560")); - DoDoubleTest(convert("foo %5G"), val, convert("foo 2560"), - convert("foo 2560")); - DoDoubleTest(convert("foo %-5G"), val, convert("foo 2560 "), - convert("foo 2560 ")); - DoDoubleTest(convert("foo %.1G"), val, convert("foo 3E+003"), - convert("foo 3E+03")); - DoDoubleTest(convert("foo %.2G"), val, convert("foo 2.6E+003"), - convert("foo 2.6E+03")); - DoDoubleTest(convert("foo %.12G"), val, convert("foo 2560.001"), - convert("foo 2560.001")); - DoDoubleTest(convert("foo %06G"), val, convert("foo 002560"), - convert("foo 002560")); - DoDoubleTest(convert("foo %#G"), val, convert("foo 2560.00"), - convert("foo 2560.00")); - DoDoubleTest(convert("foo %+G"), val, convert("foo +2560"), - convert("foo +2560")); - DoDoubleTest(convert("foo % G"), val, convert("foo 2560"), - convert("foo 2560")); - DoDoubleTest(convert("foo %+G"), neg, convert("foo -2560"), - convert("foo -2560")); - DoDoubleTest(convert("foo % G"), neg, convert("foo -2560"), - convert("foo -2560")); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/vswprintf/test18/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vswprintf/test18/testinfo.dat deleted file mode 100644 index b5165999a..000000000 --- a/src/pal/tests/palsuite/c_runtime/vswprintf/test18/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = vswprintf -Name = Positive Test for vswprintf -TYPE = DEFAULT -EXE1 = test18 -Description -= Tests the PAL implementation of the vswprintf function. -= Tests vswprintf with compact format doubles (uppercase). -= This test is modeled after _snwprintf. diff --git a/src/pal/tests/palsuite/c_runtime/vswprintf/test19/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vswprintf/test19/CMakeLists.txt deleted file mode 100644 index e2e6001cc..000000000 --- a/src/pal/tests/palsuite/c_runtime/vswprintf/test19/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test19.cpp -) - -add_executable(paltest_vswprintf_test19 - ${SOURCES} -) - -add_dependencies(paltest_vswprintf_test19 coreclrpal) - -target_link_libraries(paltest_vswprintf_test19 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/vswprintf/test19/test19.cpp b/src/pal/tests/palsuite/c_runtime/vswprintf/test19/test19.cpp deleted file mode 100644 index 12f2b7ba9..000000000 --- a/src/pal/tests/palsuite/c_runtime/vswprintf/test19/test19.cpp +++ /dev/null @@ -1,137 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test18.c -** -** Purpose: Test #18 for the vswprintf function. -** -** -**===================================================================*/ - -#include -#include "../vswprintf.h" - -/* memcmp is used to verify the results, so this test is dependent on it. */ -/* ditto with wcslen */ - -#define DOTEST(a,b,c,d,e) DoTest(a,b,(void*)c,d,e) - -void DoArgumentPrecTest(WCHAR *formatstr, int precision, void *param, - WCHAR *paramstr, WCHAR *checkstr1, WCHAR *checkstr2) -{ - WCHAR buf[256]; - - testvswp(buf, _countof(buf), formatstr, precision, param); - if (memcmp(buf, checkstr1, wcslen(checkstr1) + 2) != 0 && - memcmp(buf, checkstr2, wcslen(checkstr2) + 2) != 0) - { - Fail("ERROR: failed to insert %s into \"%s\" with precision %d\n" - "Expected \"%s\" or \"%s\", got \"%s\".\n", - paramstr, - convertC(formatstr), - precision, - convertC(checkstr1), - convertC(checkstr2), - convertC(buf)); - } -} -void DoArgumentPrecDoubleTest(WCHAR *formatstr, int precision, double param, - WCHAR *checkstr1, WCHAR *checkstr2) -{ - WCHAR buf[256]; - - testvswp(buf, _countof(buf), formatstr, precision, param); - if (memcmp(buf, checkstr1, wcslen(checkstr1) + 2) != 0 && - memcmp(buf, checkstr2, wcslen(checkstr2) + 2) != 0) - { - Fail("ERROR: failed to insert %f into \"%s\" with precision %d\n" - "Expected \"%s\" or \"%s\", got \"%s\".\n", - param, convertC(formatstr), - precision, - convertC(checkstr1), - convertC(checkstr2), - convertC(buf)); - } -} - -/* - * Uses memcmp & wcslen - */ - -int __cdecl main(int argc, char *argv[]) -{ - - if (PAL_Initialize(argc, argv) != 0) - return(FAIL); - - DoArgumentPrecTest(convert("%.*s"), 2, (void*)convert("bar"), convert("bar"), - convert("ba"), convert("ba")); - DoArgumentPrecTest(convert("%.*c"), 0, (void*)'a', convert("a"), - convert("a"), convert("a")); - DoArgumentPrecTest(convert("%.*c"), 4, (void*)'a', convert("a"), - convert("a"), convert("a")); - DoArgumentPrecTest(convert("%.*C"), 0, (void*)'a', convert("a"), - convert("a"), convert("a")); - DoArgumentPrecTest(convert("%.*C"), 4, (void*)'a', convert("a"), - convert("a"), convert("a")); - DoArgumentPrecTest(convert("%.*d"), 1, (void*)42, convert("42"), - convert("42"), convert("42")); - DoArgumentPrecTest(convert("%.*d"), 3, (void*)42, convert("42"), - convert("042"), convert("042")); - DoArgumentPrecTest(convert("%.*i"), 1, (void*)42, convert("42"), - convert("42"), convert("42")); - DoArgumentPrecTest(convert("%.*i"), 3, (void*)42, convert("42"), - convert("042"), convert("042")); - DoArgumentPrecTest(convert("%.*o"), 1, (void*)42, convert("42"), - convert("52"), convert("52")); - DoArgumentPrecTest(convert("%.*o"), 3, (void*)42, convert("42"), - convert("052"), convert("052")); - DoArgumentPrecTest(convert("%.*u"), 1, (void*)42, convert("42"), - convert("42"), convert("42")); - DoArgumentPrecTest(convert("%.*u"), 3, (void*)42, convert("42"), - convert("042"), convert("042")); - DoArgumentPrecTest(convert("%.*x"), 1, (void*)0x42, convert("0x42"), - convert("42"), convert("42")); - DoArgumentPrecTest(convert("%.*x"), 3, (void*)0x42, convert("0x42"), - convert("042"), convert("042")); - DoArgumentPrecTest(convert("%.*X"), 1, (void*)0x42, convert("0x42"), - convert("42"), convert("42")); - DoArgumentPrecTest(convert("%.*X"), 3, (void*)0x42, convert("0x42"), - convert("042"), convert("042")); - - - DoArgumentPrecDoubleTest(convert("%.*e"), 1, 2.01, convert("2.0e+000"), - convert("2.0e+00")); - DoArgumentPrecDoubleTest(convert("%.*e"), 3, 2.01, convert("2.010e+000"), - convert("2.010e+00")); - DoArgumentPrecDoubleTest(convert("%.*E"), 1, 2.01, convert("2.0E+000"), - convert("2.0E+00")); - DoArgumentPrecDoubleTest(convert("%.*E"), 3, 2.01, convert("2.010E+000"), - convert("2.010E+00")); - DoArgumentPrecDoubleTest(convert("%.*f"), 1, 2.01, convert("2.0"), - convert("2.0")); - DoArgumentPrecDoubleTest(convert("%.*f"), 3, 2.01, convert("2.010"), - convert("2.010")); - DoArgumentPrecDoubleTest(convert("%.*g"), 1, 256.01, convert("3e+002"), - convert("3e+02")); - DoArgumentPrecDoubleTest(convert("%.*g"), 3, 256.01, convert("256"), - convert("256")); - DoArgumentPrecDoubleTest(convert("%.*g"), 4, 256.01, convert("256"), - convert("256")); - DoArgumentPrecDoubleTest(convert("%.*g"), 6, 256.01, convert("256.01"), - convert("256.01")); - DoArgumentPrecDoubleTest(convert("%.*G"), 1, 256.01, convert("3E+002"), - convert("3E+02")); - DoArgumentPrecDoubleTest(convert("%.*G"), 3, 256.01, convert("256"), - convert("256")); - DoArgumentPrecDoubleTest(convert("%.*G"), 4, 256.01, convert("256"), - convert("256")); - DoArgumentPrecDoubleTest(convert("%.*G"), 6, 256.01, convert("256.01"), - convert("256.01")); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/vswprintf/test19/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vswprintf/test19/testinfo.dat deleted file mode 100644 index ccc08cd7b..000000000 --- a/src/pal/tests/palsuite/c_runtime/vswprintf/test19/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = vswprintf -Name = Positive Test for vswprintf -TYPE = DEFAULT -EXE1 = test19 -Description -= Tests the PAL implementation of the vswprintf function. -= Tests vswprintf with argument specified precision. -= This test is modeled after _snwprintf. diff --git a/src/pal/tests/palsuite/c_runtime/vswprintf/test2/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vswprintf/test2/CMakeLists.txt deleted file mode 100644 index b1dee38b4..000000000 --- a/src/pal/tests/palsuite/c_runtime/vswprintf/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test2.cpp -) - -add_executable(paltest_vswprintf_test2 - ${SOURCES} -) - -add_dependencies(paltest_vswprintf_test2 coreclrpal) - -target_link_libraries(paltest_vswprintf_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/vswprintf/test2/test2.cpp b/src/pal/tests/palsuite/c_runtime/vswprintf/test2/test2.cpp deleted file mode 100644 index a7b1b3a33..000000000 --- a/src/pal/tests/palsuite/c_runtime/vswprintf/test2/test2.cpp +++ /dev/null @@ -1,46 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test2.c -** -** Purpose: Test #2 for the vswprintf function. -** -** -**===================================================================*/ - -#include -#include "../vswprintf.h" - -/* memcmp is used to verify the results, so this test is dependent on it. */ -/* ditto with wcslen */ - - -int __cdecl main(int argc, char *argv[]) -{ - if (PAL_Initialize(argc, argv) != 0) - return(FAIL); - - DoWStrTest(convert("foo %s"), convert("bar"), convert("foo bar")); - DoStrTest(convert("foo %hs"), "bar", convert("foo bar")); - DoWStrTest(convert("foo %ls"), convert("bar"), convert("foo bar")); - DoWStrTest(convert("foo %ws"), convert("bar"), convert("foo bar")); - DoWStrTest(convert("foo %Ls"), convert("bar"), convert("foo bar")); - DoWStrTest(convert("foo %I64s"), convert("bar"), convert("foo bar")); - DoWStrTest(convert("foo %5s"), convert("bar"), convert("foo bar")); - DoWStrTest(convert("foo %.2s"), convert("bar"), convert("foo ba")); - DoWStrTest(convert("foo %5.2s"), convert("bar"), convert("foo ba")); - DoWStrTest(convert("foo %-5s"), convert("bar"), convert("foo bar ")); - DoWStrTest(convert("foo %05s"), convert("bar"), convert("foo 00bar")); - DoWStrTest(convert("foo %s"), NULL, convert("foo (null)")); - DoStrTest(convert("foo %hs"), NULL, convert("foo (null)")); - DoWStrTest(convert("foo %ls"), NULL, convert("foo (null)")); - DoWStrTest(convert("foo %ws"), NULL, convert("foo (null)")); - DoWStrTest(convert("foo %Ls"), NULL, convert("foo (null)")); - DoWStrTest(convert("foo %I64s"), NULL, convert("foo (null)")); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/vswprintf/test2/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vswprintf/test2/testinfo.dat deleted file mode 100644 index d6d7c3e8b..000000000 --- a/src/pal/tests/palsuite/c_runtime/vswprintf/test2/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = vswprintf -Name = Positive Test for vswprintf -TYPE = DEFAULT -EXE1 = test2 -Description -= Tests the PAL implementation of the vswprintf function. -= Tests vswprintf with strings. -= This test is modeled after _snwprintf. diff --git a/src/pal/tests/palsuite/c_runtime/vswprintf/test3/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vswprintf/test3/CMakeLists.txt deleted file mode 100644 index 4d49a107b..000000000 --- a/src/pal/tests/palsuite/c_runtime/vswprintf/test3/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test3.cpp -) - -add_executable(paltest_vswprintf_test3 - ${SOURCES} -) - -add_dependencies(paltest_vswprintf_test3 coreclrpal) - -target_link_libraries(paltest_vswprintf_test3 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/vswprintf/test3/test3.cpp b/src/pal/tests/palsuite/c_runtime/vswprintf/test3/test3.cpp deleted file mode 100644 index 40c7d2afc..000000000 --- a/src/pal/tests/palsuite/c_runtime/vswprintf/test3/test3.cpp +++ /dev/null @@ -1,46 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test3.c -** -** Purpose: Test #3 for the vswprintf function. -** -** -**===================================================================*/ - -#include -#include "../vswprintf.h" - -/* memcmp is used to verify the results, so this test is dependent on it. */ -/* ditto with wcslen */ - - -int __cdecl main(int argc, char *argv[]) -{ - if (PAL_Initialize(argc, argv) != 0) - return(FAIL); - - DoStrTest(convert("foo %S"), "bar", convert("foo bar")); - DoStrTest(convert("foo %hS"), "bar", convert("foo bar")); - DoWStrTest(convert("foo %lS"), convert("bar"), convert("foo bar")); - DoWStrTest(convert("foo %wS"), convert("bar"), convert("foo bar")); - DoStrTest(convert("foo %LS"), "bar", convert("foo bar")); - DoStrTest(convert("foo %I64S"), "bar", convert("foo bar")); - DoStrTest(convert("foo %5S"), "bar", convert("foo bar")); - DoStrTest(convert("foo %.2S"), "bar", convert("foo ba")); - DoStrTest(convert("foo %5.2S"), "bar", convert("foo ba")); - DoStrTest(convert("foo %-5S"), "bar", convert("foo bar ")); - DoStrTest(convert("foo %05S"), "bar", convert("foo 00bar")); - DoStrTest(convert("foo %S"), NULL, convert("foo (null)")); - DoStrTest(convert("foo %hS"), NULL, convert("foo (null)")); - DoWStrTest(convert("foo %lS"), NULL, convert("foo (null)")); - DoWStrTest(convert("foo %wS"), NULL, convert("foo (null)")); - DoStrTest(convert("foo %LS"), NULL, convert("foo (null)")); - DoStrTest(convert("foo %I64S"), NULL, convert("foo (null)")); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/vswprintf/test3/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vswprintf/test3/testinfo.dat deleted file mode 100644 index 8fb9dc806..000000000 --- a/src/pal/tests/palsuite/c_runtime/vswprintf/test3/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = vswprintf -Name = Positive Test for vswprintf -TYPE = DEFAULT -EXE1 = test3 -Description -= Tests the PAL implementation of the vswprintf function. -= Tests vswprintf with wide strings. -= This test is modeled after _snwprintf. diff --git a/src/pal/tests/palsuite/c_runtime/vswprintf/test4/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vswprintf/test4/CMakeLists.txt deleted file mode 100644 index d38b9cd82..000000000 --- a/src/pal/tests/palsuite/c_runtime/vswprintf/test4/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test4.cpp -) - -add_executable(paltest_vswprintf_test4 - ${SOURCES} -) - -add_dependencies(paltest_vswprintf_test4 coreclrpal) - -target_link_libraries(paltest_vswprintf_test4 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/vswprintf/test4/test4.cpp b/src/pal/tests/palsuite/c_runtime/vswprintf/test4/test4.cpp deleted file mode 100644 index c54fe6aab..000000000 --- a/src/pal/tests/palsuite/c_runtime/vswprintf/test4/test4.cpp +++ /dev/null @@ -1,118 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test4.c -** -** Purpose: Test #4 for the vswprintf function. -** -** -**===================================================================*/ - -#include -#include "../vswprintf.h" - -/* memcmp is used to verify the results, so this test is dependent on it. */ -/* ditto with wcslen */ -static void DoPointerTest(WCHAR *formatstr, void* param, WCHAR* paramstr, - WCHAR *checkstr1) -{ - WCHAR buf[256] = { 0 }; - - testvswp(buf, _countof(buf), formatstr, param); - if (memcmp(buf, checkstr1, wcslen(checkstr1) + 2) != 0) - - { - Fail("ERROR: failed to insert pointer to %#p into \"%s\"\n" - "Expected \"%s\" got \"%s\".\n", - paramstr, - convertC(formatstr), - convertC(checkstr1), - convertC(buf)); - } -} - -static void DoI64DoubleTest(WCHAR *formatstr, INT64 value, WCHAR *valuestr, - WCHAR *checkstr1) -{ - WCHAR buf[256] = { 0 }; - - testvswp(buf, _countof(buf), formatstr, value); - if (memcmp(buf, checkstr1, wcslen(checkstr1) + 2) != 0) - { - Fail("ERROR: failed to insert %s into \"%s\"\n" - "Expected \"%s\", got \"%s\".\n", - value, - convertC(formatstr), - convertC(checkstr1), - convertC(buf)); - } -} - -int __cdecl main(int argc, char *argv[]) -{ - void *ptr = (void*) 0x123456; - INT64 lptr = I64(0x1234567887654321); - - if (PAL_Initialize(argc, argv) != 0) - return(FAIL); - -/* -** Run only on 64 bit platforms -*/ -#if defined(BIT64) - Trace("Testing for 64 Bit Platforms \n"); - DoPointerTest(convert("%p"), NULL, convert("NULL"), convert("0000000000000000")); - DoPointerTest(convert("%p"), ptr, convert("pointer to 0x123456"), - convert("0000000000123456")); - DoPointerTest(convert("%17p"), ptr, convert("pointer to 0x123456"), - convert(" 0000000000123456")); - DoPointerTest(convert("%17p"), ptr, convert("pointer to 0x123456"), - convert(" 0000000000123456")); - DoPointerTest(convert("%-17p"), ptr, convert("pointer to 0x123456"), - convert("0000000000123456 ")); - DoPointerTest(convert("%+p"), ptr, convert("pointer to 0x123456"), - convert("0000000000123456")); - DoPointerTest(convert("%#p"), ptr, convert("pointer to 0x123456"), - convert("0X0000000000123456")); - DoPointerTest(convert("%lp"), ptr, convert("pointer to 0x123456"), - convert("00123456")); - DoPointerTest(convert("%hp"), ptr, convert("pointer to 0x123456"), - convert("00003456")); - DoPointerTest(convert("%Lp"), ptr, convert("pointer to 0x123456"), - convert("00123456")); - DoI64DoubleTest(convert("%I64p"), lptr, - convert("pointer to 0x1234567887654321"), convert("1234567887654321")); - -#else - Trace("Testing for Non 64 Bit Platforms \n"); - DoPointerTest(convert("%p"), NULL, convert("NULL"), convert("00000000")); - DoPointerTest(convert("%p"), ptr, convert("pointer to 0x123456"), - convert("00123456")); - DoPointerTest(convert("%9p"), ptr, convert("pointer to 0x123456"), - convert(" 00123456")); - DoPointerTest(convert("%09p"), ptr, convert("pointer to 0x123456"), - convert(" 00123456")); - DoPointerTest(convert("%-9p"), ptr, convert("pointer to 0x123456"), - convert("00123456 ")); - DoPointerTest(convert("%+p"), ptr, convert("pointer to 0x123456"), - convert("00123456")); - DoPointerTest(convert("%#p"), ptr, convert("pointer to 0x123456"), - convert("0X00123456")); - DoPointerTest(convert("%lp"), ptr, convert("pointer to 0x123456"), - convert("00123456")); - DoPointerTest(convert("%hp"), ptr, convert("pointer to 0x123456"), - convert("00003456")); - DoPointerTest(convert("%Lp"), ptr, convert("pointer to 0x123456"), - convert("00123456")); - DoI64DoubleTest(convert("%I64p"), lptr, - convert("pointer to 0x1234567887654321"), convert("1234567887654321")); - -#endif - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/c_runtime/vswprintf/test4/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vswprintf/test4/testinfo.dat deleted file mode 100644 index 435f9703c..000000000 --- a/src/pal/tests/palsuite/c_runtime/vswprintf/test4/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = vswprintf -Name = Positive Test for vswprintf -TYPE = DEFAULT -EXE1 = test4 -Description -= Tests the PAL implementation of the vswprintf function. -= Tests vswprintf with pointers. -= This test is modeled after _snwprintf. diff --git a/src/pal/tests/palsuite/c_runtime/vswprintf/test6/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vswprintf/test6/CMakeLists.txt deleted file mode 100644 index 0caa96ed7..000000000 --- a/src/pal/tests/palsuite/c_runtime/vswprintf/test6/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test6.cpp -) - -add_executable(paltest_vswprintf_test6 - ${SOURCES} -) - -add_dependencies(paltest_vswprintf_test6 coreclrpal) - -target_link_libraries(paltest_vswprintf_test6 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/vswprintf/test6/test6.cpp b/src/pal/tests/palsuite/c_runtime/vswprintf/test6/test6.cpp deleted file mode 100644 index 51e99267a..000000000 --- a/src/pal/tests/palsuite/c_runtime/vswprintf/test6/test6.cpp +++ /dev/null @@ -1,41 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test6.c -** -** Purpose: Test #6 for the vswprintf function. -** -** -**===================================================================*/ - -#include -#include "../vswprintf.h" - -/* memcmp is used to verify the results, so this test is dependent on it. */ -/* ditto with wcslen */ - -int __cdecl main(int argc, char *argv[]) -{ - WCHAR wc = (WCHAR) 'c'; - - if (PAL_Initialize(argc, argv) != 0) - return(FAIL); - - DoWCharTest(convert("foo %c"), wc, convert("foo c")); - DoCharTest(convert("foo %hc"), 'b', convert("foo b")); - DoWCharTest(convert("foo %lc"), wc, convert("foo c")); - DoWCharTest(convert("foo %Lc"), wc, convert("foo c")); - DoWCharTest(convert("foo %I64c"), wc, convert("foo c")); - DoWCharTest(convert("foo %5c"), wc, convert("foo c")); - DoWCharTest(convert("foo %.0c"), wc, convert("foo c")); - DoWCharTest(convert("foo %-5c"), wc, convert("foo c ")); - DoWCharTest(convert("foo %05c"), wc, convert("foo 0000c")); - DoWCharTest(convert("foo % c"), wc, convert("foo c")); - DoWCharTest(convert("foo %#c"), wc, convert("foo c")); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/vswprintf/test6/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vswprintf/test6/testinfo.dat deleted file mode 100644 index f4ad2e954..000000000 --- a/src/pal/tests/palsuite/c_runtime/vswprintf/test6/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = vswprintf -Name = Positive Test for vswprintf -TYPE = DEFAULT -EXE1 = test6 -Description -= Tests the PAL implementation of the vswprintf function. -= Tests vswprintf with characters. -= This test is modeled after _snwprintf. diff --git a/src/pal/tests/palsuite/c_runtime/vswprintf/test7/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vswprintf/test7/CMakeLists.txt deleted file mode 100644 index 324457681..000000000 --- a/src/pal/tests/palsuite/c_runtime/vswprintf/test7/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test7.cpp -) - -add_executable(paltest_vswprintf_test7 - ${SOURCES} -) - -add_dependencies(paltest_vswprintf_test7 coreclrpal) - -target_link_libraries(paltest_vswprintf_test7 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/vswprintf/test7/test7.cpp b/src/pal/tests/palsuite/c_runtime/vswprintf/test7/test7.cpp deleted file mode 100644 index 6037cb0fe..000000000 --- a/src/pal/tests/palsuite/c_runtime/vswprintf/test7/test7.cpp +++ /dev/null @@ -1,41 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test7.c -** -** Purpose: Test #7 for the vswprintf function. -** -** -**===================================================================*/ - -#include -#include "../vswprintf.h" - -/* memcmp is used to verify the results, so this test is dependent on it. */ -/* ditto with wcslen */ - -int __cdecl main(int argc, char *argv[]) -{ - WCHAR wc = (WCHAR) 'c'; - - if (PAL_Initialize(argc, argv) != 0) - return(FAIL); - - DoCharTest(convert("foo %C"), 'b', convert("foo b")); - DoWCharTest(convert("foo %hC"), wc, convert("foo c")); - DoCharTest(convert("foo %lC"), 'b', convert("foo b")); - DoCharTest(convert("foo %LC"), 'b', convert("foo b")); - DoCharTest(convert("foo %I64C"), 'b', convert("foo b")); - DoCharTest(convert("foo %5C"), 'b', convert("foo b")); - DoCharTest(convert("foo %.0C"), 'b', convert("foo b")); - DoCharTest(convert("foo %-5C"), 'b', convert("foo b ")); - DoCharTest(convert("foo %05C"), 'b', convert("foo 0000b")); - DoCharTest(convert("foo % C"), 'b', convert("foo b")); - DoCharTest(convert("foo %#C"), 'b', convert("foo b")); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/vswprintf/test7/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vswprintf/test7/testinfo.dat deleted file mode 100644 index ed0a474f7..000000000 --- a/src/pal/tests/palsuite/c_runtime/vswprintf/test7/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = vswprintf -Name = Positive Test for vswprintf -TYPE = DEFAULT -EXE1 = test7 -Description -= Tests the PAL implementation of the vswprintf function. -= Tests vswprintf with wide characters. -= This test is modeled after _snwprintf. diff --git a/src/pal/tests/palsuite/c_runtime/vswprintf/test8/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vswprintf/test8/CMakeLists.txt deleted file mode 100644 index f972c0006..000000000 --- a/src/pal/tests/palsuite/c_runtime/vswprintf/test8/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test8.cpp -) - -add_executable(paltest_vswprintf_test8 - ${SOURCES} -) - -add_dependencies(paltest_vswprintf_test8 coreclrpal) - -target_link_libraries(paltest_vswprintf_test8 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/vswprintf/test8/test8.cpp b/src/pal/tests/palsuite/c_runtime/vswprintf/test8/test8.cpp deleted file mode 100644 index baba52465..000000000 --- a/src/pal/tests/palsuite/c_runtime/vswprintf/test8/test8.cpp +++ /dev/null @@ -1,47 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test8.c -** -** Purpose: Test #8 for the vswprintf function. -** -** -**===================================================================*/ - -#include -#include "../vswprintf.h" - -/* memcmp is used to verify the results, so this test is dependent on it. */ -/* ditto with wcslen */ - -int __cdecl main(int argc, char *argv[]) -{ - int neg = -42; - int pos = 42; - INT64 l = 42; - - if (PAL_Initialize(argc, argv) != 0) - return(FAIL); - - DoNumTest(convert("foo %d"), pos, convert("foo 42")); - DoNumTest(convert("foo %ld"), 0xFFFF, convert("foo 65535")); - DoNumTest(convert("foo %hd"), 0xFFFF, convert("foo -1")); - DoNumTest(convert("foo %Ld"), pos, convert("foo 42")); - DoI64NumTest(convert("foo %I64d"), l, "42", convert("foo 42")); - DoNumTest(convert("foo %3d"), pos, convert("foo 42")); - DoNumTest(convert("foo %-3d"), pos, convert("foo 42 ")); - DoNumTest(convert("foo %.1d"), pos, convert("foo 42")); - DoNumTest(convert("foo %.3d"), pos, convert("foo 042")); - DoNumTest(convert("foo %03d"), pos, convert("foo 042")); - DoNumTest(convert("foo %#d"), pos, convert("foo 42")); - DoNumTest(convert("foo %+d"), pos, convert("foo +42")); - DoNumTest(convert("foo % d"), pos, convert("foo 42")); - DoNumTest(convert("foo %+d"), neg, convert("foo -42")); - DoNumTest(convert("foo % d"), neg, convert("foo -42")); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/vswprintf/test8/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vswprintf/test8/testinfo.dat deleted file mode 100644 index 4c5114bd2..000000000 --- a/src/pal/tests/palsuite/c_runtime/vswprintf/test8/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = vswprintf -Name = Positive Test for vswprintf -TYPE = DEFAULT -EXE1 = test8 -Description -= Tests the PAL implementation of the vswprintf function. -= Tests vswprintf with decimal numbers. -= This test is modeled after _snwprintf. diff --git a/src/pal/tests/palsuite/c_runtime/vswprintf/test9/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/vswprintf/test9/CMakeLists.txt deleted file mode 100644 index ee9c04d7e..000000000 --- a/src/pal/tests/palsuite/c_runtime/vswprintf/test9/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test9.cpp -) - -add_executable(paltest_vswprintf_test9 - ${SOURCES} -) - -add_dependencies(paltest_vswprintf_test9 coreclrpal) - -target_link_libraries(paltest_vswprintf_test9 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/vswprintf/test9/test9.cpp b/src/pal/tests/palsuite/c_runtime/vswprintf/test9/test9.cpp deleted file mode 100644 index 5de004f5e..000000000 --- a/src/pal/tests/palsuite/c_runtime/vswprintf/test9/test9.cpp +++ /dev/null @@ -1,47 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test9.c -** -** Purpose: Test #9 for the vswprintf function. -** -** -**===================================================================*/ - -#include -#include "../vswprintf.h" - -/* memcmp is used to verify the results, so this test is dependent on it. */ -/* ditto with wcslen */ - -int __cdecl main(int argc, char *argv[]) -{ - int neg = -42; - int pos = 42; - INT64 l = 42; - - if (PAL_Initialize(argc, argv) != 0) - return(FAIL); - - DoNumTest(convert("foo %i"), pos, convert("foo 42")); - DoNumTest(convert("foo %li"), 0xFFFF, convert("foo 65535")); - DoNumTest(convert("foo %hi"), 0xFFFF, convert("foo -1")); - DoNumTest(convert("foo %Li"), pos, convert("foo 42")); - DoI64NumTest(convert("foo %I64i"), l, "42", convert("foo 42")); - DoNumTest(convert("foo %3i"), pos, convert("foo 42")); - DoNumTest(convert("foo %-3i"), pos, convert("foo 42 ")); - DoNumTest(convert("foo %.1i"), pos, convert("foo 42")); - DoNumTest(convert("foo %.3i"), pos, convert("foo 042")); - DoNumTest(convert("foo %03i"), pos, convert("foo 042")); - DoNumTest(convert("foo %#i"), pos, convert("foo 42")); - DoNumTest(convert("foo %+i"), pos, convert("foo +42")); - DoNumTest(convert("foo % i"), pos, convert("foo 42")); - DoNumTest(convert("foo %+i"), neg, convert("foo -42")); - DoNumTest(convert("foo % i"), neg, convert("foo -42")); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/vswprintf/test9/testinfo.dat b/src/pal/tests/palsuite/c_runtime/vswprintf/test9/testinfo.dat deleted file mode 100644 index 3c2bcdf3e..000000000 --- a/src/pal/tests/palsuite/c_runtime/vswprintf/test9/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = vswprintf -Name = Positive Test for vswprintf -TYPE = DEFAULT -EXE1 = test9 -Description -= Tests the PAL implementation of the vswprintf function. -= Tests vswprintf with integer numbers -= This test is modeled after _snwprintf. diff --git a/src/pal/tests/palsuite/c_runtime/vswprintf/vswprintf.h b/src/pal/tests/palsuite/c_runtime/vswprintf/vswprintf.h deleted file mode 100644 index 36895d207..000000000 --- a/src/pal/tests/palsuite/c_runtime/vswprintf/vswprintf.h +++ /dev/null @@ -1,132 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: vswprintf.h -** -** Purpose: Containts common testing functions for vswprintf -** -** -**==========================================================================*/ - -#ifndef __vswprintf_H__ -#define __vswprintf_H__ - -/* These functions leaks memory like crazy. C'est la vie. */ -int testvswp(wchar_t* buf, size_t buffSize, const wchar_t* format, ...) -{ - int retVal = 0; - va_list arglist; - - va_start(arglist, format); - retVal = _vsnwprintf_s(buf, buffSize, _TRUNCATE, format, arglist); - va_end(arglist); - - return( retVal); -} - -void DoWStrTest(const WCHAR *formatstr, WCHAR *param, const WCHAR *checkstr) -{ - WCHAR buf[256] = { 0 }; - - testvswp(buf, _countof(buf), formatstr, param); - - if (memcmp(buf, checkstr, wcslen(buf) * 2 + 2) != 0) - { - Fail("ERROR: failed to insert wide string \"%s\" into \"%s\".\n" - "Expected \"%s\", got \"%s\".\n", - convertC(param), convertC(formatstr), - convertC(checkstr), convertC(buf)); - } -} - -void DoStrTest(const WCHAR *formatstr, char *param, const WCHAR *checkstr) -{ - WCHAR buf[256] = { 0 }; - - testvswp(buf, _countof(buf), formatstr, param); - - if (memcmp(buf, checkstr, wcslen(buf) * 2 + 2) != 0) - { - Fail("ERROR: failed to insert wide string \"%s\" into \"%s\".\n" - "Expected \"%s\", got \"%s\".\n", - param, convertC(formatstr), convertC(checkstr), - convertC(buf)); - } -} - -void DoCharTest(const WCHAR *formatstr, char param, const WCHAR *checkstr) -{ - WCHAR buf[256] = { 0 }; - - testvswp(buf, _countof(buf), formatstr, param); - if (memcmp(buf, checkstr, wcslen(buf)*2 + 2) != 0) - { - Fail("ERROR: failed to insert char \'%c\' (%d) into \"%s\"\n" - "Expected \"%s\" got \"%s\".\n", - param, param, convertC(formatstr), convertC(checkstr), - convertC(buf)); - } -} - -void DoWCharTest(const WCHAR *formatstr, WCHAR param, const WCHAR *checkstr) -{ - WCHAR buf[256] = { 0 }; - - testvswp(buf, _countof(buf), formatstr, param); - if (memcmp(buf, checkstr, wcslen(buf)*2 + 2) != 0) - { - Fail("ERROR: failed to insert wide char \'%c\' (%d) into \"%s\"\n" - "Expected \"%s\" got \"%s\".\n", - (char) param, param, convertC(formatstr), convertC(checkstr), - convertC(buf)); - } -} - -void DoNumTest(const WCHAR *formatstr, int value, const WCHAR *checkstr) -{ - WCHAR buf[256] = { 0 }; - - testvswp(buf, _countof(buf), formatstr, value); - if (memcmp(buf, checkstr, wcslen(buf)* 2 + 2) != 0) - { - Fail("ERROR: failed to insert %#x into \"%s\"\n" - "Expected \"%s\" got \"%s\".\n", value, convertC(formatstr), - convertC(checkstr), convertC(buf)); - } -} - -void DoI64NumTest(const WCHAR *formatstr, INT64 value, char *valuestr, const WCHAR *checkstr) -{ - WCHAR buf[256] = { 0 }; - - testvswp(buf, _countof(buf), formatstr, value); - if (memcmp(buf, checkstr, wcslen(buf)* 2 + 2) != 0) - { - Fail("ERROR: failed to insert %s into \"%s\"\n" - "Expected \"%s\" got \"%s\".\n", valuestr, convertC(formatstr), - convertC(checkstr), convertC(buf)); - } -} -void DoDoubleTest(const WCHAR *formatstr, double value, const WCHAR *checkstr1, WCHAR - *checkstr2) -{ - WCHAR buf[256] = { 0 }; - - testvswp(buf, _countof(buf), formatstr, value); - if (memcmp(buf, checkstr1, wcslen(checkstr1) + 2) != 0 && - memcmp(buf, checkstr2, wcslen(checkstr2) + 2) != 0) - { - Fail("ERROR: failed to insert %f into \"%s\"\n" - "Expected \"%s\" or \"%s\", got \"%s\".\n", - value, - convertC(formatstr), - convertC(checkstr1), - convertC(checkstr2), - convertC(buf)); - } -} - -#endif diff --git a/src/pal/tests/palsuite/c_runtime/wcscat/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/wcscat/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/c_runtime/wcscat/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/c_runtime/wcscat/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/wcscat/test1/CMakeLists.txt deleted file mode 100644 index 8ee3b694b..000000000 --- a/src/pal/tests/palsuite/c_runtime/wcscat/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_wcscat_test1 - ${SOURCES} -) - -add_dependencies(paltest_wcscat_test1 coreclrpal) - -target_link_libraries(paltest_wcscat_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/wcscat/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/wcscat/test1/test1.cpp deleted file mode 100644 index e9a79d388..000000000 --- a/src/pal/tests/palsuite/c_runtime/wcscat/test1/test1.cpp +++ /dev/null @@ -1,71 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: -** Test to that wcscat correctly concatanates wide strings, including placing -** null pointers. -** -** -**==========================================================================*/ - - - -#include - -/* - * Notes: uses memcmp and the (pal) sprintf_s - */ - -int __cdecl main(int argc, char *argv[]) -{ - WCHAR dest[80]; - WCHAR test[] = {'f','o','o',' ','b','a','r',' ','b','a','z',0}; - WCHAR str1[] = {'f','o','o',' ',0}; - WCHAR str2[] = {'b','a','r',' ',0}; - WCHAR str3[] = {'b','a','z',0}; - WCHAR *ptr; - char buffer[256]; - - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - dest[0] = 0; - - ptr = wcscat(dest, str1); - if (ptr != dest) - { - Fail("ERROR: Expected wcscat to return ptr to %p, got %p", dest, ptr); - } - - ptr = wcscat(dest, str2); - if (ptr != dest) - { - Fail("ERROR: Expected wcscat to return ptr to %p, got %p", dest, ptr); - } - - ptr = wcscat(dest, str3); - if (ptr != dest) - { - Fail("ERROR: Expected wcscat to return ptr to %p, got %p", dest, ptr); - } - - if (memcmp(dest, test, sizeof(test)) != 0) - { - sprintf_s(buffer, _countof(buffer), "%S", dest); - Fail("ERROR: Expected wcscat to give \"%s\", got \"%s\"\n", - "foo bar baz", buffer); - } - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/c_runtime/wcscat/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/wcscat/test1/testinfo.dat deleted file mode 100644 index 878c44625..000000000 --- a/src/pal/tests/palsuite/c_runtime/wcscat/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = wcscat -Name = Positive Test for wcscat -TYPE = DEFAULT -EXE1 = test1 -Description -= Test to that wcscat correctly concatanates wide strings, including placing -= null pointers diff --git a/src/pal/tests/palsuite/c_runtime/wcschr/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/wcschr/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/c_runtime/wcschr/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/c_runtime/wcschr/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/wcschr/test1/CMakeLists.txt deleted file mode 100644 index f054ae795..000000000 --- a/src/pal/tests/palsuite/c_runtime/wcschr/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_wcschr_test1 - ${SOURCES} -) - -add_dependencies(paltest_wcschr_test1 coreclrpal) - -target_link_libraries(paltest_wcschr_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/wcschr/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/wcschr/test1/test1.cpp deleted file mode 100644 index a4963672f..000000000 --- a/src/pal/tests/palsuite/c_runtime/wcschr/test1/test1.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: -** Tests that wcschr correctly finds the first occurrence of a character in a -** string -** -** -**==========================================================================*/ - - - -#include - -int __cdecl main(int argc, char *argv[]) -{ - WCHAR str[] = {'f','o','o',' ','b','a','r',' ',0}; - WCHAR c = (WCHAR)' '; - WCHAR c2 = (WCHAR)'$'; - WCHAR *ptr; - - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - ptr = wcschr(str, c); - if (ptr != str + 3) - { - Fail("ERROR: expected wcschr to return pointer to %p, got %p\n", - str + 3, ptr); - } - - ptr = wcschr(str, c2); - if (ptr != NULL) - { - Fail("ERROR: expected wcschr to return pointer to %p, got %p\n", - NULL, ptr); - } - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/c_runtime/wcschr/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/wcschr/test1/testinfo.dat deleted file mode 100644 index 40a166d61..000000000 --- a/src/pal/tests/palsuite/c_runtime/wcschr/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = wcschr -Name = Positive Test for wcschr -TYPE = DEFAULT -EXE1 = test1 -Description -= Tests that wcschr correctly finds the first occurrence of a character in a -= string. diff --git a/src/pal/tests/palsuite/c_runtime/wcscmp/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/wcscmp/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/c_runtime/wcscmp/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/c_runtime/wcscmp/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/wcscmp/test1/CMakeLists.txt deleted file mode 100644 index 8f97a6386..000000000 --- a/src/pal/tests/palsuite/c_runtime/wcscmp/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_wcscmp_test1 - ${SOURCES} -) - -add_dependencies(paltest_wcscmp_test1 coreclrpal) - -target_link_libraries(paltest_wcscmp_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/wcscmp/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/wcscmp/test1/test1.cpp deleted file mode 100644 index 1c38dd6d5..000000000 --- a/src/pal/tests/palsuite/c_runtime/wcscmp/test1/test1.cpp +++ /dev/null @@ -1,57 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: Tests that wcscmp correctly compares two strings with -** case sensitivity. -** -** -**==========================================================================*/ - -#include - - -int __cdecl main(int argc, char *argv[]) -{ - WCHAR str1[] = {'f','o','o',0}; - WCHAR str2[] = {'f','o','o','x',0}; - WCHAR str3[] = {'f','O','o',0}; - char cstr1[] = "foo"; - char cstr2[] = "foox"; - char cstr3[] = "fOo"; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - - if (wcscmp(str1, str2) >= 0) - { - Fail("ERROR: wcscmp(\"%s\", \"%s\") returned >= 0\n", cstr1, cstr2); - } - - if (wcscmp(str2, str1) <= 0) - { - Fail("ERROR: wcscmp(\"%s\", \"%s\") returned <= 0\n", cstr2, cstr1); - } - - if (wcscmp(str1, str3) <= 0) - { - Fail("ERROR: wcscmp(\"%s\", \"%s\") returned >= 0\n", cstr1, cstr3); - } - - if (wcscmp(str3, str1) >= 0) - { - Fail("ERROR: wcscmp(\"%s\", \"%s\") returned >= 0\n", cstr3, cstr1); - } - - PAL_Terminate(); - - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/wcscmp/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/wcscmp/test1/testinfo.dat deleted file mode 100644 index 0fe696fbe..000000000 --- a/src/pal/tests/palsuite/c_runtime/wcscmp/test1/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = wcscmp -Name = Test #1 for wcscmp -TYPE = DEFAULT -EXE1 = test1 -Description -= Tests that wcscmp correctly compares two strings with case sensitivity. diff --git a/src/pal/tests/palsuite/c_runtime/wcscpy/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/wcscpy/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/c_runtime/wcscpy/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/c_runtime/wcscpy/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/wcscpy/test1/CMakeLists.txt deleted file mode 100644 index c7fdcb837..000000000 --- a/src/pal/tests/palsuite/c_runtime/wcscpy/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_wcscpy_test1 - ${SOURCES} -) - -add_dependencies(paltest_wcscpy_test1 coreclrpal) - -target_link_libraries(paltest_wcscpy_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/wcscpy/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/wcscpy/test1/test1.cpp deleted file mode 100644 index 2ecafa830..000000000 --- a/src/pal/tests/palsuite/c_runtime/wcscpy/test1/test1.cpp +++ /dev/null @@ -1,47 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: Tests that wcscpy correctly copies a null-terminated wide string. -** -** -**==========================================================================*/ - - -#include - -/* - * Notes: uses memcmp and sprintf_s. - */ - -int __cdecl main(int argc, char *argv[]) -{ - WCHAR str[] = {'f','o','o',0,'b','a','r',0}; - WCHAR dest[80]; - WCHAR result[] = {'f','o','o',0}; - WCHAR *ret; - char buffer[256]; - - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - ret = wcscpy(dest, str); - - if (ret != dest || memcmp(dest, result, sizeof(result)) != 0) - { - sprintf_s(buffer, _countof(buffer), "%S", dest); - Fail("Expected wcscpy to give \"%s\" with a return value of %p, got \"%s\" " - "with a return value of %p.\n", "foo", dest, buffer, ret); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/wcscpy/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/wcscpy/test1/testinfo.dat deleted file mode 100644 index ef9c58ecc..000000000 --- a/src/pal/tests/palsuite/c_runtime/wcscpy/test1/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = wcscpy -Name = Positive Test for wcscpy -TYPE = DEFAULT -EXE1 = test1 -Description -= Tests that wcscpy correctly copies a null-terminated wide string. diff --git a/src/pal/tests/palsuite/c_runtime/wcslen/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/wcslen/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/c_runtime/wcslen/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/c_runtime/wcslen/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/wcslen/test1/CMakeLists.txt deleted file mode 100644 index e68496d34..000000000 --- a/src/pal/tests/palsuite/c_runtime/wcslen/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_wcslen_test1 - ${SOURCES} -) - -add_dependencies(paltest_wcslen_test1 coreclrpal) - -target_link_libraries(paltest_wcslen_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/wcslen/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/wcslen/test1/test1.cpp deleted file mode 100644 index 17d032762..000000000 --- a/src/pal/tests/palsuite/c_runtime/wcslen/test1/test1.cpp +++ /dev/null @@ -1,49 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: -** Tests that wcslen correctly returns the length (in wide characters, -** not byte) of a wide string -** -** -**==========================================================================*/ - - - -#include - -int __cdecl main(int argc, char *argv[]) -{ - WCHAR str1[] = {'f','o','o',' ',0}; - WCHAR str2[] = {0}; - int ret; - - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - ret = wcslen(str1); - if (ret != 4) - { - Fail("ERROR: Expected wcslen of \"foo \" to be 4, got %d\n", ret); - } - - ret = wcslen(str2); - if (ret != 0) - { - Fail("ERROR: Expected wcslen of \"\" to be 0, got %d\n", ret); - } - - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/c_runtime/wcslen/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/wcslen/test1/testinfo.dat deleted file mode 100644 index cfdef4819..000000000 --- a/src/pal/tests/palsuite/c_runtime/wcslen/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = wcslen -Name = Positive Test for wcslen -TYPE = DEFAULT -EXE1 = test1 -Description -= Tests that wcslen correctly returns the length (in wide characters, not byte) -= of a wide string diff --git a/src/pal/tests/palsuite/c_runtime/wcsncat/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/wcsncat/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/c_runtime/wcsncat/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/c_runtime/wcsncat/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/wcsncat/test1/CMakeLists.txt deleted file mode 100644 index 8eba7a7c8..000000000 --- a/src/pal/tests/palsuite/c_runtime/wcsncat/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_wcsncat_test1 - ${SOURCES} -) - -add_dependencies(paltest_wcsncat_test1 coreclrpal) - -target_link_libraries(paltest_wcsncat_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/wcsncat/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/wcsncat/test1/test1.cpp deleted file mode 100644 index 0cd5c3e15..000000000 --- a/src/pal/tests/palsuite/c_runtime/wcsncat/test1/test1.cpp +++ /dev/null @@ -1,77 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: -** Tests that wcsncat correctly appends wide strings, making sure it handles -** count argument correctly (appending no more than count characters, always -** placing a null, and padding the string if necessary). -** -** -**==========================================================================*/ - -#include - - -int __cdecl main(int argc, char *argv[]) -{ - WCHAR dest[80]; - WCHAR test[] = {'f','o','o',' ','b','a','r','b','a','z',0}; - WCHAR str1[] = {'f','o','o',' ',0}; - WCHAR str2[] = {'b','a','r',' ',0}; - WCHAR str3[] = {'b','a','z',0}; - WCHAR *ptr; - int i; - - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - dest[0] = 0; - for (i=1; i<80; i++) - { - dest[i] = (WCHAR)'x'; - } - - ptr = wcsncat(dest, str1, wcslen(str1)); - if (ptr != dest) - { - Fail("ERROR: Expected wcsncat to return ptr to %p, got %p", dest, ptr); - } - - ptr = wcsncat(dest, str2, 3); - if (ptr != dest) - { - Fail("ERROR: Expected wcsncat to return ptr to %p, got %p", dest, ptr); - } - if (dest[7] != 0) - { - Fail("ERROR: wcsncat did not place a terminating NULL!"); - } - - ptr = wcsncat(dest, str3, 20); - if (ptr != dest) - { - Fail("ERROR: Expected wcsncat to return ptr to %p, got %p", dest, ptr); - } - if (wcscmp(dest, test) != 0) - { - Fail("ERROR: Expected wcsncat to give \"%S\", got \"%S\"\n", - test, dest); - } - if (dest[wcslen(test)+1] != (WCHAR)'x') - { - Fail("wcsncat went out of bounds!\n"); - } - - PAL_Terminate(); - - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/wcsncat/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/wcsncat/test1/testinfo.dat deleted file mode 100644 index 39077a237..000000000 --- a/src/pal/tests/palsuite/c_runtime/wcsncat/test1/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = wcsncat -Name = Test #1 for wcsncat -TYPE = DEFAULT -EXE1 = test1 -Description -= Tests that wcsncat correctly appends wide strings, making sure it handles -= count argument correctly (appending no more than count characters, always -= placing a null, and padding the string if necessary). diff --git a/src/pal/tests/palsuite/c_runtime/wcsncmp/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/wcsncmp/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/c_runtime/wcsncmp/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/c_runtime/wcsncmp/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/wcsncmp/test1/CMakeLists.txt deleted file mode 100644 index 4fc815585..000000000 --- a/src/pal/tests/palsuite/c_runtime/wcsncmp/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_wcsncmp_test1 - ${SOURCES} -) - -add_dependencies(paltest_wcsncmp_test1 coreclrpal) - -target_link_libraries(paltest_wcsncmp_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/wcsncmp/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/wcsncmp/test1/test1.cpp deleted file mode 100644 index 4e4488f5a..000000000 --- a/src/pal/tests/palsuite/c_runtime/wcsncmp/test1/test1.cpp +++ /dev/null @@ -1,73 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: -** Tests that wcsncmp case-sensitively compares wide strings, making sure that -** the count argument is handled correctly. -** -** -**==========================================================================*/ - - - -#include - -/* - * Notes: uses wcslen. - */ - -int __cdecl main(int argc, char *argv[]) -{ - WCHAR str1[] = {'f','o','o',0}; - WCHAR str2[] = {'f','o','o','x',0}; - WCHAR str3[] = {'f','O','o',0}; - char cstr1[] = "foo"; - char cstr2[] = "foox"; - char cstr3[] = "fOo"; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - - if (wcsncmp(str1, str2, wcslen(str2)) >= 0) - { - Fail("ERROR: wcsncmp(\"%s\", \"%s\", %d) returned >= 0\n", cstr1, - cstr2, wcslen(str2)); - } - - if (wcsncmp(str2, str1, wcslen(str2)) <= 0) - { - Fail("ERROR: wcsncmp(\"%s\", \"%s\", %d) returned <= 0\n", cstr2, - cstr1, wcslen(str2)); - } - - if (wcsncmp(str1, str2, wcslen(str1)) != 0) - { - Fail("ERROR: wcsncmp(\"%s\", \"%s\", %d) returned != 0\n", cstr1, - cstr2, wcslen(str1)); - } - - if (wcsncmp(str1, str3, wcslen(str1)) <= 0) - { - Fail("ERROR: wcsncmp(\"%s\", \"%s\", %d) returned >= 0\n", cstr1, - cstr3, wcslen(str1)); - } - - if (wcsncmp(str3, str1, wcslen(str1)) >= 0) - { - Fail("ERROR: wcsncmp(\"%s\", \"%s\", %d) returned >= 0\n", cstr3, - cstr1, wcslen(str1)); - } - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/c_runtime/wcsncmp/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/wcsncmp/test1/testinfo.dat deleted file mode 100644 index 1f8b50874..000000000 --- a/src/pal/tests/palsuite/c_runtime/wcsncmp/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = wcsncmp -Name = Positive Test for wcsncmp -TYPE = DEFAULT -EXE1 = test1 -Description -= Tests that wcsncmp case-sensitively compares wide strings, making sure that -= the count argument is handled correctly. diff --git a/src/pal/tests/palsuite/c_runtime/wcsncpy/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/wcsncpy/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/c_runtime/wcsncpy/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/c_runtime/wcsncpy/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/wcsncpy/test1/CMakeLists.txt deleted file mode 100644 index d157bf29e..000000000 --- a/src/pal/tests/palsuite/c_runtime/wcsncpy/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_wcsncpy_test1 - ${SOURCES} -) - -add_dependencies(paltest_wcsncpy_test1 coreclrpal) - -target_link_libraries(paltest_wcsncpy_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/wcsncpy/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/wcsncpy/test1/test1.cpp deleted file mode 100644 index 50d97b0e9..000000000 --- a/src/pal/tests/palsuite/c_runtime/wcsncpy/test1/test1.cpp +++ /dev/null @@ -1,84 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: -** Tests to see that wcsncpy correctly copies wide strings, including handling -** the count argument correctly (copying no more that count characters, not -** automatically adding a null, and padding if necessary). -** -** -**==========================================================================*/ - -#include - - -int __cdecl main(int argc, char *argv[]) -{ - WCHAR dest[80]; - WCHAR result[] = {'f','o','o','b','a','r',0}; - WCHAR str[] = {'f','o','o','b','a','r',0,'b','a','z',0}; - WCHAR *ret; - int i; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - for (i=0; i<80; i++) - { - dest[i] = 'x'; - } - - ret = wcsncpy(dest, str, 3); - if (ret != dest) - { - Fail("Expected wcsncpy to return %p, got %p!\n", dest, ret); - } - - if (wcsncmp(dest, result, 3) != 0) - { - Fail("Expected wcsncpy to give \"%S\", got \"%S\"!\n", result, dest); - } - - if (dest[3] != (WCHAR)'x') - { - Fail("wcsncpy overflowed!\n"); - } - - ret = wcsncpy(dest, str, 40); - if (ret != dest) - { - Fail("Expected wcsncpy to return %p, got %p!\n", dest, ret); - } - - if (wcscmp(dest, result) != 0) - { - Fail("Expected wcsncpy to give \"%S\", got \"%S\"!\n", result, dest); - } - - for (i=wcslen(str); i<40; i++) - { - if (dest[i] != 0) - { - Fail("wcsncpy failed to pad the destination with NULLs!\n"); - } - } - - if (dest[40] != (WCHAR)'x') - { - Fail("wcsncpy overflowed!\n"); - } - - - - PAL_Terminate(); - - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/wcsncpy/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/wcsncpy/test1/testinfo.dat deleted file mode 100644 index b8b0ddb3f..000000000 --- a/src/pal/tests/palsuite/c_runtime/wcsncpy/test1/testinfo.dat +++ /dev/null @@ -1,15 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = wcsncpy -Name = Test #1 for wcsncpy -TYPE = DEFAULT -EXE1 = test1 -Description -= Tests to see that wcsncpy correctly copies wide strings, including handling -= the count argument correctly (copying no more that count characters, not -= automatically adding a null, and padding if necessary). - diff --git a/src/pal/tests/palsuite/c_runtime/wcspbrk/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/wcspbrk/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/c_runtime/wcspbrk/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/c_runtime/wcspbrk/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/wcspbrk/test1/CMakeLists.txt deleted file mode 100644 index 2a9434442..000000000 --- a/src/pal/tests/palsuite/c_runtime/wcspbrk/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_wcspbrk_test1 - ${SOURCES} -) - -add_dependencies(paltest_wcspbrk_test1 coreclrpal) - -target_link_libraries(paltest_wcspbrk_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/wcspbrk/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/wcspbrk/test1/test1.cpp deleted file mode 100644 index b0432f781..000000000 --- a/src/pal/tests/palsuite/c_runtime/wcspbrk/test1/test1.cpp +++ /dev/null @@ -1,61 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: -** Tests that wcspbrk returns a pointer to the first element in the first -** string that matches a character in the second (or NULL). -** -** -**==========================================================================*/ - -#include - -int __cdecl main(int argc, char *argv[]) -{ - WCHAR *string; - WCHAR *key1; - WCHAR *key2; - WCHAR key3[] = {0}; - WCHAR *result; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - string = convert("foo bar baz bar"); - key1 = convert("z "); - key2 = convert("Q"); - - result = wcspbrk(string, key1); - if (result != string + 3) - { - Fail("ERROR: Got incorrect result in scanning \"%s\" with the set \"%s\".\n" - "Expected to get pointer to %#p, got %#p\n", convertC(string), - convertC(key1), string + 3, result); - } - - result = wcspbrk(string, key2); - if (result != NULL) - { - Fail("ERROR: Got incorrect result in scanning \"%s\" with the set \"%s\".\n" - "Expected to get pointer to %#p, got %#p\n", convertC(string), - convertC(key2), NULL, result); - } - - result = wcspbrk(string, key3); - if (result != NULL) - { - Fail("ERROR: Got incorrect result in scanning \"%s\" with the set \"%s\".\n" - "Expected to get pointer to %#p, got %#p\n", convertC(string), - convertC(key3), NULL, result); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/wcspbrk/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/wcspbrk/test1/testinfo.dat deleted file mode 100644 index 7044197b7..000000000 --- a/src/pal/tests/palsuite/c_runtime/wcspbrk/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = wcspbrk -Name = Positive Test for wcspbrk -TYPE = DEFAULT -EXE1 = test1 -Description -= Tests that wcspbrk returns a pointer to the first element in the first -= string that matches a character in the second (or NULL). diff --git a/src/pal/tests/palsuite/c_runtime/wcsrchr/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/wcsrchr/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/c_runtime/wcsrchr/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/c_runtime/wcsrchr/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/wcsrchr/test1/CMakeLists.txt deleted file mode 100644 index 3d808e1e7..000000000 --- a/src/pal/tests/palsuite/c_runtime/wcsrchr/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_wcsrchr_test1 - ${SOURCES} -) - -add_dependencies(paltest_wcsrchr_test1 coreclrpal) - -target_link_libraries(paltest_wcsrchr_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/wcsrchr/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/wcsrchr/test1/test1.cpp deleted file mode 100644 index ae8765776..000000000 --- a/src/pal/tests/palsuite/c_runtime/wcsrchr/test1/test1.cpp +++ /dev/null @@ -1,50 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: -** Tests to see that wcsrchr correctly returns a pointer to the last occurence -** of a character in a a string. -** -** -**==========================================================================*/ - - - -#include - -int __cdecl main(int argc, char *argv[]) -{ - WCHAR str[] = {'f','o','o',' ','b','a','r',' ','b','a','z',0}; - WCHAR c = (WCHAR)' '; - WCHAR c2 = (WCHAR)'$'; - WCHAR *ptr; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - ptr = wcsrchr(str, c); - if (ptr != str + 7) - { - Fail("ERROR: expected wcsrchr to return pointer to %p, got %p\n", - str + 7, ptr); - } - - ptr = wcsrchr(str, c2); - if (ptr != NULL) - { - Fail("ERROR: expected wcsrchr to return pointer to %p, got %p\n", - NULL, ptr); - } - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/c_runtime/wcsrchr/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/wcsrchr/test1/testinfo.dat deleted file mode 100644 index 984df9a3f..000000000 --- a/src/pal/tests/palsuite/c_runtime/wcsrchr/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = wcsrchr -Name = Positive Test for wcsrchr -TYPE = DEFAULT -EXE1 = test1 -Description -= Tests to see that wcsrchr correctly returns a pointer to the last occurence -= of a character in a a string. diff --git a/src/pal/tests/palsuite/c_runtime/wcsstr/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/wcsstr/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/c_runtime/wcsstr/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/c_runtime/wcsstr/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/wcsstr/test1/CMakeLists.txt deleted file mode 100644 index bc09f7598..000000000 --- a/src/pal/tests/palsuite/c_runtime/wcsstr/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_wcsstr_test1 - ${SOURCES} -) - -add_dependencies(paltest_wcsstr_test1 coreclrpal) - -target_link_libraries(paltest_wcsstr_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/wcsstr/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/wcsstr/test1/test1.cpp deleted file mode 100644 index 16005a9f8..000000000 --- a/src/pal/tests/palsuite/c_runtime/wcsstr/test1/test1.cpp +++ /dev/null @@ -1,72 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: -** Tests that wcsstr correctly find substrings in wide stings, including -** returning NULL when the substring can't be found. -** -** -**==========================================================================*/ - -#include - -int __cdecl main(int argc, char *argv[]) -{ - WCHAR *string; - WCHAR *key1; - WCHAR *key2; - WCHAR key3[] = { 0 }; - WCHAR *key4; - WCHAR *result; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - string = convert("foo bar baz bar"); - key1 = convert("bar"); - key2 = convert("Bar"); - key4 = convert("arggggh!"); - - result = wcsstr(string, key1); - if (result != string + 4) - { - Fail("ERROR: Got incorrect result in scanning \"%s\" for \"%s\".\n" - "Expected to get pointer to %#p, got %#p\n", convertC(string), - convertC(key1), string + 4, result); - } - - - result = wcsstr(string, key2); - if (result != NULL) - { - Fail("ERROR: Got incorrect result in scanning \"%s\" for \"%s\".\n" - "Expected to get pointer to %#p, got %#p\n", convertC(string), - convertC(key2), NULL, result); - } - - result = wcsstr(string, key3); - if (result != string) - { - Fail("ERROR: Got incorrect result in scanning \"%s\" for \"%s\".\n" - "Expected to get pointer to %#p, got %#p\n", convertC(string), - convertC(key3), string, result); - } - - result = wcsstr(string, key4); - if (result != nullptr) - { - Fail("ERROR: Got incorrect result in scanning \"%s\" for \"%s\".\n" - "Expected to get pointer to null, got %#p\n", convertC(string), - convertC(key4), result); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/wcsstr/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/wcsstr/test1/testinfo.dat deleted file mode 100644 index e42fd8c9e..000000000 --- a/src/pal/tests/palsuite/c_runtime/wcsstr/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = wcsstr -Name = Positive Test for wcsstr -TYPE = DEFAULT -EXE1 = test1 -Description -= Tests that wcsstr correctly find substrings in wide stings, including -= returning NULL when the substring can't be found. diff --git a/src/pal/tests/palsuite/c_runtime/wcstod/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/wcstod/CMakeLists.txt deleted file mode 100644 index ef14ea535..000000000 --- a/src/pal/tests/palsuite/c_runtime/wcstod/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) - diff --git a/src/pal/tests/palsuite/c_runtime/wcstod/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/wcstod/test1/CMakeLists.txt deleted file mode 100644 index 2370ee8aa..000000000 --- a/src/pal/tests/palsuite/c_runtime/wcstod/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_wcstod_test1 - ${SOURCES} -) - -add_dependencies(paltest_wcstod_test1 coreclrpal) - -target_link_libraries(paltest_wcstod_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/wcstod/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/wcstod/test1/test1.cpp deleted file mode 100644 index e41e92e96..000000000 --- a/src/pal/tests/palsuite/c_runtime/wcstod/test1/test1.cpp +++ /dev/null @@ -1,79 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test1.c -** -** Purpose: Tests wcstod with a number of sample strings. -** -** -**===================================================================*/ - -#include - -struct testCase -{ - double CorrectResult; - char string[20]; - int stopChar; -}; - -struct testCase testCases[] = -{ - {1234,"1234", 4}, - {-1234,"-1234", 5}, - {1234.44,"1234.44", 7}, - {1234e-5,"1234e-5", 7}, - {1234e+5,"1234e+5", 7}, - {1234E5,"1234E5", 6}, - {1234.657e-8, "1234.657e-8", 11}, - {0, "1e-800", 6}, - {0, "-1e-800", 7}, - {1234567e-8, " 1234567e-8 foo", 13}, - {0, " foo 32 bar", 0}, -}; - -int __cdecl main(int argc, char **argv) -{ - WCHAR *wideStr; - WCHAR *endptr; - double result; - int i; - - if (PAL_Initialize(argc,argv)) - { - return FAIL; - } - - for(i = 0; i < sizeof(testCases) / sizeof(struct testCase); i++) - { - wideStr = convert(testCases[i].string); - result = wcstod(wideStr, &endptr); - - if (testCases[i].CorrectResult != result) - { - free(wideStr); - Fail("ERROR: wcstod misinterpreted \"%s\" as %g instead of " - "%g.\n", - testCases[i].string, - result, - testCases[i].CorrectResult); - } - - if (endptr != wideStr + testCases[i].stopChar) - { - free(wideStr); - Fail("ERROR: wcstod stopped scanning \"%s\" at %p, " - "instead of %p!\n", testCases[i].string, endptr, - wideStr + testCases[i].stopChar); - } - - free(wideStr); - } - - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/wcstod/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/wcstod/test1/testinfo.dat deleted file mode 100644 index 19da0b5a4..000000000 --- a/src/pal/tests/palsuite/c_runtime/wcstod/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = wcstod -Name = Positive Test for wcstod -TYPE = DEFAULT -EXE1 = test1 -Description -= Tests wcstod with a number of sample strings. - diff --git a/src/pal/tests/palsuite/c_runtime/wcstod/test2/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/wcstod/test2/CMakeLists.txt deleted file mode 100644 index 1251c2c9c..000000000 --- a/src/pal/tests/palsuite/c_runtime/wcstod/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test2.cpp -) - -add_executable(paltest_wcstod_test2 - ${SOURCES} -) - -add_dependencies(paltest_wcstod_test2 coreclrpal) - -target_link_libraries(paltest_wcstod_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/wcstod/test2/test2.cpp b/src/pal/tests/palsuite/c_runtime/wcstod/test2/test2.cpp deleted file mode 100644 index 8f9b5cbf5..000000000 --- a/src/pal/tests/palsuite/c_runtime/wcstod/test2/test2.cpp +++ /dev/null @@ -1,59 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test2.c -** -** Purpose: Tests wcstod with overflows -** -** -**===================================================================*/ - -#include - -int __cdecl main(int argc, char **argv) -{ - /* Representation of positive infinty for a IEEE 64-bit double */ - INT64 PosInifity = (INT64)(0x7ff00000) << 32; - double HugeVal = *(double*) &PosInifity; - char *PosStr = "1E+10000"; - char *NegStr = "-1E+10000"; - WCHAR *wideStr; - double result; - - - if (PAL_Initialize(argc,argv)) - { - return FAIL; - } - - wideStr = convert(PosStr); - result = wcstod(wideStr, NULL); - free(wideStr); - - if (result != HugeVal) - { - Fail("ERROR: wcstod interpreted \"%s\" as %g instead of %g\n", - PosStr, result, HugeVal); - } - - - - wideStr = convert(NegStr); - result = wcstod(wideStr, NULL); - free(wideStr); - - if (result != -HugeVal) - { - Fail("ERROR: wcstod interpreted \"%s\" as %g instead of %g\n", - NegStr, result, -HugeVal); - } - - - PAL_Terminate(); - - return PASS; -} - diff --git a/src/pal/tests/palsuite/c_runtime/wcstod/test2/testinfo.dat b/src/pal/tests/palsuite/c_runtime/wcstod/test2/testinfo.dat deleted file mode 100644 index bf41e9707..000000000 --- a/src/pal/tests/palsuite/c_runtime/wcstod/test2/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = wcstod -Name = Positive Test for wcstod -TYPE = DEFAULT -EXE1 = test2 -Description -= Tests wcstod with overflows - diff --git a/src/pal/tests/palsuite/c_runtime/wcstok/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/wcstok/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/c_runtime/wcstok/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/c_runtime/wcstok/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/wcstok/test1/CMakeLists.txt deleted file mode 100644 index 0f63a7bf6..000000000 --- a/src/pal/tests/palsuite/c_runtime/wcstok/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_wcstok_test1 - ${SOURCES} -) - -add_dependencies(paltest_wcstok_test1 coreclrpal) - -target_link_libraries(paltest_wcstok_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/wcstok/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/wcstok/test1/test1.cpp deleted file mode 100644 index 76d7dc02b..000000000 --- a/src/pal/tests/palsuite/c_runtime/wcstok/test1/test1.cpp +++ /dev/null @@ -1,114 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: -** Search for a number of tokens within strings. Check that the return values -** are what is expected, and also that the strings match up with our expected -** results. -** -** -**==========================================================================*/ - -#include - -int __cdecl main(int argc, char *argv[]) -{ - /* foo bar baz */ - WCHAR str[] = {'f','o','o',' ','b','a','r',' ','b','a','z','\0'}; - - /* foo \0ar baz */ - WCHAR result1[] = {'f','o','o',' ','\0','a','r',' ','b','a','z','\0'}; - - /* foo \0a\0 baz */ - WCHAR result2[] = {'f','o','o',' ','\0','a','\0',' ','b','a','z','\0'}; - - WCHAR* tempString; - int len = 0; - WCHAR *ptr; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - len = (wcslen(str)*sizeof(WCHAR)) + 2; - - /* Tokenize 'str'. It will hit the 'b' delimiter first. Check to see - that the ptr is pointing to the start of the string and do a compare - to ensure the tokenized string is what we expected. - */ - - tempString = convert("bz"); - ptr = wcstok(str, tempString); - free(tempString); - - if (ptr != str) - { - Fail("ERROR: Expected wcstok() to return %p, got %p!\n", str, ptr); - } - - if (memcmp(str, result1, len) != 0) - { - Fail("ERROR: wcstok altered the string in an unexpected fashion."); - } - - /* If NULL is passed as the first parameter, wcstok will continue - tokenizing the same string. Test that this works properly. - */ - tempString = convert("r "); - ptr = wcstok(NULL, tempString); - free(tempString); - - if (ptr != str + 5) - { - Fail("ERROR: Expected wcstok() to return %p, got %p!\n", str+5, ptr); - } - - if (memcmp(str, result2, len) != 0) - { - Fail("ERROR: wcstok altered the string in an unexpected fashion."); - } - - /* Continue onward, and search for 'X' now, which won't be found. The - pointer should point just after the last NULL in the string. And - the string itself shouldn't have changed. - */ - tempString = convert("X"); - ptr = wcstok(NULL, tempString); - free(tempString); - - if (ptr != str + 7) - { - Fail("ERROR: Expected wcstok() to return %p, got %p!\n", str + 7, ptr); - } - - if (memcmp(str, result2, len) != 0) - { - Fail("ERROR: wcstok altered the string in an unexpeced fashion.\n"); - } - - /* Call wcstok again. Now the ptr should point to the end of the - string at NULL. And the string itself shouldn't have changed. - */ - tempString = convert("X"); - ptr = wcstok(NULL, tempString); - free(tempString); - - if (ptr != NULL) - { - Fail("ERROR: Expected wcstok() to return %p, got %p!\n", NULL, ptr); - } - - if (memcmp(str, result2, len) != 0) - { - Fail("ERROR: wcstok altered the string in an unexpeced fashion.\n"); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/wcstok/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/wcstok/test1/testinfo.dat deleted file mode 100644 index cc00844c6..000000000 --- a/src/pal/tests/palsuite/c_runtime/wcstok/test1/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = wcstok -Name = wcstok test- tokenize a string and ensure the string takes correct form. -TYPE = DEFAULT -EXE1 = test1 -Description -= Search for a number of tokens within strings. Check that the return values -= are what is expect, and also that the strings match up with our expected -= results. diff --git a/src/pal/tests/palsuite/c_runtime/wcstol/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/wcstol/CMakeLists.txt deleted file mode 100644 index 7c2017935..000000000 --- a/src/pal/tests/palsuite/c_runtime/wcstol/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) -add_subdirectory(test3) -add_subdirectory(test4) -add_subdirectory(test5) -add_subdirectory(test6) - diff --git a/src/pal/tests/palsuite/c_runtime/wcstol/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/wcstol/test1/CMakeLists.txt deleted file mode 100644 index fc81ee402..000000000 --- a/src/pal/tests/palsuite/c_runtime/wcstol/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_wcstol_test1 - ${SOURCES} -) - -add_dependencies(paltest_wcstol_test1 coreclrpal) - -target_link_libraries(paltest_wcstol_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/wcstol/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/wcstol/test1/test1.cpp deleted file mode 100644 index d84ba66ad..000000000 --- a/src/pal/tests/palsuite/c_runtime/wcstol/test1/test1.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: Test #1 for the wcstol function. Does a simple test with radix 4. -** -** -**==========================================================================*/ - - - -#include - - -/* - * Notes: wcstol should depend on the current locale's LC_NUMERIC category, - * this is not currently tested. - */ - - -int __cdecl main(int argc, char *argv[]) -{ - WCHAR *end; - WCHAR teststr[] = {'1','2','3','4','5',0}; - LONG result = 27; - LONG l; - - if ( 0 != PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - l = wcstol(teststr, &end, 4); - - if (l != result) - { - Fail("ERROR: Expected wcstol to return %d, got %d\n", result, l); - } - - if (end != teststr + 3) - { - Fail("ERROR: Expected wcstol to give an end value of %p, got %p\n", - teststr + 3, end); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/wcstol/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/wcstol/test1/testinfo.dat deleted file mode 100644 index 48108f22b..000000000 --- a/src/pal/tests/palsuite/c_runtime/wcstol/test1/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = wcstol -Name = Positive Test for wcstol -TYPE = DEFAULT -EXE1 = test1 -Description -= Tests wcstol with base 4 and a string that includes some invalid characters. diff --git a/src/pal/tests/palsuite/c_runtime/wcstol/test2/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/wcstol/test2/CMakeLists.txt deleted file mode 100644 index 4f7ad5372..000000000 --- a/src/pal/tests/palsuite/c_runtime/wcstol/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test2.cpp -) - -add_executable(paltest_wcstol_test2 - ${SOURCES} -) - -add_dependencies(paltest_wcstol_test2 coreclrpal) - -target_link_libraries(paltest_wcstol_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/wcstol/test2/test2.cpp b/src/pal/tests/palsuite/c_runtime/wcstol/test2/test2.cpp deleted file mode 100644 index 58309be6b..000000000 --- a/src/pal/tests/palsuite/c_runtime/wcstol/test2/test2.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test2.c -** -** Purpose: Test #2 for the wcstol function. Does a simple test with radix -** 10. -** -** -**==========================================================================*/ - - - -#include - - -/* - * Notes: wcstol should depend on the current locale's LC_NUMERIC category, - * this is not currently tested. - */ - -int __cdecl main(int argc, char *argv[]) -{ - WCHAR *end; - WCHAR teststr[] = {'1','2','3','4','5',0}; - LONG result = 12345; - LONG l; - - if (0 != PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - l = wcstol(teststr, &end, 10); - - if (l != result) - { - Fail("ERROR: Expected wcstol to return %d, got %d\n", result, l); - } - - if (end != teststr + 5) - { - Fail("ERROR: Expected wcstol to give an end value of %p, got %p\n", - teststr + 5, end); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/wcstol/test2/testinfo.dat b/src/pal/tests/palsuite/c_runtime/wcstol/test2/testinfo.dat deleted file mode 100644 index 8dd146001..000000000 --- a/src/pal/tests/palsuite/c_runtime/wcstol/test2/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = wcstol -Name = Positive Test for wcstol -TYPE = DEFAULT -EXE1 = test2 -Description -= Tests wcstol with base 10 and a completely valid string. diff --git a/src/pal/tests/palsuite/c_runtime/wcstol/test3/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/wcstol/test3/CMakeLists.txt deleted file mode 100644 index df2d5ef60..000000000 --- a/src/pal/tests/palsuite/c_runtime/wcstol/test3/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test3.cpp -) - -add_executable(paltest_wcstol_test3 - ${SOURCES} -) - -add_dependencies(paltest_wcstol_test3 coreclrpal) - -target_link_libraries(paltest_wcstol_test3 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/wcstol/test3/test3.cpp b/src/pal/tests/palsuite/c_runtime/wcstol/test3/test3.cpp deleted file mode 100644 index 8b5ce6943..000000000 --- a/src/pal/tests/palsuite/c_runtime/wcstol/test3/test3.cpp +++ /dev/null @@ -1,52 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test3.c -** -** Purpose: Test #3 for the wcstol function. Tests an invalid string -** -** -**==========================================================================*/ - - - -#include - - -/* - * Notes: wcstol should depend on the current locale's LC_NUMERIC category, - * this is not currently tested. - */ - - -int __cdecl main(int argc, char *argv[]) -{ - WCHAR str[] = {'Z',0}; - WCHAR *end; - LONG l; - - if (0 != PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - l = wcstol(str, &end, 10); - - if (l != 0) - { - Fail("ERROR: Expected wcstol to return %d, got %d\n", 0, l); - } - - if (end != str) - { - Fail("ERROR: Expected wcstol to give an end value of %p, got %p\n", - str + 3, end); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/wcstol/test3/testinfo.dat b/src/pal/tests/palsuite/c_runtime/wcstol/test3/testinfo.dat deleted file mode 100644 index 0e851d865..000000000 --- a/src/pal/tests/palsuite/c_runtime/wcstol/test3/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = wcstol -Name = Positive Test for wcstol -TYPE = DEFAULT -EXE1 = test3 -Description -= Tests wcstol with a completely invalid string (base 10). diff --git a/src/pal/tests/palsuite/c_runtime/wcstol/test4/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/wcstol/test4/CMakeLists.txt deleted file mode 100644 index 9af9af8be..000000000 --- a/src/pal/tests/palsuite/c_runtime/wcstol/test4/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test4.cpp -) - -add_executable(paltest_wcstol_test4 - ${SOURCES} -) - -add_dependencies(paltest_wcstol_test4 coreclrpal) - -target_link_libraries(paltest_wcstol_test4 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/wcstol/test4/test4.cpp b/src/pal/tests/palsuite/c_runtime/wcstol/test4/test4.cpp deleted file mode 100644 index a5e65946e..000000000 --- a/src/pal/tests/palsuite/c_runtime/wcstol/test4/test4.cpp +++ /dev/null @@ -1,77 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test4.c -** -** Purpose: Test #4 for the wcstol function. Tests the limits of the -** conversions. -** -** -**==========================================================================*/ - - - -#include - - -/* - * Notes: wcstol should depend on the current locale's LC_NUMERIC category, - * this is not currently tested. - */ - -int __cdecl main(int argc, char *argv[]) -{ - WCHAR maxstr[] = {'2','1','4','7','4','8','3','6','4','7',0}; - LONG max = 2147483647; - WCHAR minstr[] = {'-','2','1','4','7','4','8','3','6','4','8',0}; - LONG min = 0x80000000; /* putting -2147483648 gives a warning */ - WCHAR *end; - LONG l; - - if ( 0 != PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - errno = 0; - - l = wcstol(maxstr, &end, 10); - - if (l != max) - { - Fail("ERROR: Expected wcstol to return %d, got %d\n", max, l); - } - if (end != maxstr + 10) - { - Fail("ERROR: Expected wcstol to give an end value of %p, got %p\n", - maxstr + 10, end); - } - if (errno != 0) - { - Fail("ERROR: wcstol set errno to non-zero (%d)\n", errno); - } - - - l = wcstol(minstr, &end, 10); - - if (l != min) - { - Fail("ERROR: Expected wcstol to return %d, got %d\n", min, l); - } - if (end != minstr + 11) - { - Fail("ERROR: Expected wcstol to give an end value of %p, got %p\n", - minstr + 11, end); - } - if (errno != 0) - { - Fail("ERROR: wcstol set errno to non-zero (%d)\n", errno); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/wcstol/test4/testinfo.dat b/src/pal/tests/palsuite/c_runtime/wcstol/test4/testinfo.dat deleted file mode 100644 index d2c5652e6..000000000 --- a/src/pal/tests/palsuite/c_runtime/wcstol/test4/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = wcstol -Name = Positive Test for wcstol -TYPE = DEFAULT -EXE1 = test4 -Description -= Tests wcstol with base 10 and the highest and lowest possible values. diff --git a/src/pal/tests/palsuite/c_runtime/wcstol/test5/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/wcstol/test5/CMakeLists.txt deleted file mode 100644 index 6134216d5..000000000 --- a/src/pal/tests/palsuite/c_runtime/wcstol/test5/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test5.cpp -) - -add_executable(paltest_wcstol_test5 - ${SOURCES} -) - -add_dependencies(paltest_wcstol_test5 coreclrpal) - -target_link_libraries(paltest_wcstol_test5 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/wcstol/test5/test5.cpp b/src/pal/tests/palsuite/c_runtime/wcstol/test5/test5.cpp deleted file mode 100644 index 62f0a895a..000000000 --- a/src/pal/tests/palsuite/c_runtime/wcstol/test5/test5.cpp +++ /dev/null @@ -1,76 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test5.c -** -** Purpose: Test #5 for the wcstol function. Tests over and under flowing. -** -** -**==========================================================================*/ - - - -#include - - -/* - * Notes: wcstol should depend on the current locale's LC_NUMERIC category, - * this is not currently tested. - */ - - -int __cdecl main(int argc, char *argv[]) -{ - WCHAR overstr[] = {'2','1','4','7','4','8','3','6','4','8',0}; - WCHAR understr[] = {'-','2','1','4','7','4','8','3','6','4','9',0}; - WCHAR *end; - LONG l; - - if (0 != PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - errno = 0; - - l = wcstol(overstr, &end, 10); - - if (l != LONG_MAX) - { - Fail("ERROR: Expected wcstol to return %u, got %u\n", LONG_MAX, l); - } - if (end != overstr + 10) - { - Fail("ERROR: Expected wcstol to give an end value of %p, got %p\n", - overstr + 10, end); - } - if (errno != ERANGE) - { - Fail("ERROR: wcstol did not set errno to ERANGE (%d)\n", errno); - } - - - errno = 0; - l = wcstol(understr, &end, 10); - - if (l != LONG_MIN) - { - Fail("ERROR: Expected wcstol to return %u, got %u\n", LONG_MIN, l); - } - if (end != understr + 11) - { - Fail("ERROR: Expected wcstol to give an end value of %p, got %p\n", - understr + 11, end); - } - if (errno != ERANGE) - { - Fail("ERROR: wcstol did not set errno to ERANGE (%d)\n", errno); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/wcstol/test5/testinfo.dat b/src/pal/tests/palsuite/c_runtime/wcstol/test5/testinfo.dat deleted file mode 100644 index 18b4478e3..000000000 --- a/src/pal/tests/palsuite/c_runtime/wcstol/test5/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = wcstol -Name = Positive Test for wcstol -TYPE = DEFAULT -EXE1 = test5 -Description -= Tests wcstol (base 10) with underflowing and overflowing. -= Chesks that errno gets set to ERANGE. diff --git a/src/pal/tests/palsuite/c_runtime/wcstol/test6/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/wcstol/test6/CMakeLists.txt deleted file mode 100644 index ae7efe8d4..000000000 --- a/src/pal/tests/palsuite/c_runtime/wcstol/test6/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test6.cpp -) - -add_executable(paltest_wcstol_test6 - ${SOURCES} -) - -add_dependencies(paltest_wcstol_test6 coreclrpal) - -target_link_libraries(paltest_wcstol_test6 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/wcstol/test6/test6.cpp b/src/pal/tests/palsuite/c_runtime/wcstol/test6/test6.cpp deleted file mode 100644 index 14f620823..000000000 --- a/src/pal/tests/palsuite/c_runtime/wcstol/test6/test6.cpp +++ /dev/null @@ -1,86 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test6.c -** -** Purpose: Test #6 for the wcstol function. Tests strings with octal/hex -** number specifers -** -** -**==========================================================================*/ - - - -#include - - -/* - * Notes: wcstol should depend on the current locale's LC_NUMERIC category, - * this is not currently tested. - */ - - -int __cdecl main(int argc, char *argv[]) -{ - WCHAR test1[] = {'0','x','1','2', 0}; - WCHAR test2[] = {'0','1','2',0}; - WCHAR *end; - LONG l; - - if (0 != PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - l = wcstol(test1, &end, 16); - if (l != 0x12) - { - Fail("ERROR: Expected wcstol to return %d, got %d\n", 0x12, l); - } - if (end != test1 + 4) - { - Fail("ERROR: Expected wcstol to give an end value of %p, got %p\n", - test1 + 4, end); - } - - l = wcstol(test1, &end, 10); - if (l != 0) - { - Fail("ERROR: Expected wcstol to return %d, got %d\n", 0, l); - } - if (end != test1+1) - { - Fail("ERROR: Expected wcstol to give an end value of %p, got %p\n", - test1+1, end); - } - - l = wcstol(test2, &end, 8); - if (l != 10) - { - Fail("ERROR: Expected wcstol to return %d, got %d\n", 10, l); - } - if (end != test2 + 3) - { - Fail("ERROR: Expected wcstol to give an end value of %p, got %p\n", - test2 + 3, end); - } - - l = wcstol(test2, &end, 10); - if (l != 12) - { - Fail("ERROR: Expected wcstol to return %d, got %d\n", 12, l); - } - - if (end != test2 + 3) - { - Fail("ERROR: Expected wcstol to give an end value of %p, got %p\n", - test2 + 3, end); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/wcstol/test6/testinfo.dat b/src/pal/tests/palsuite/c_runtime/wcstol/test6/testinfo.dat deleted file mode 100644 index 0e10761e4..000000000 --- a/src/pal/tests/palsuite/c_runtime/wcstol/test6/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = wcstol -Name = Positive Test for wcstol -TYPE = DEFAULT -EXE1 = test6 -Description -= Tests wcstol with hex and octal strings, with different bases. diff --git a/src/pal/tests/palsuite/c_runtime/wcstoul/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/wcstoul/CMakeLists.txt deleted file mode 100644 index 7c2017935..000000000 --- a/src/pal/tests/palsuite/c_runtime/wcstoul/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) -add_subdirectory(test3) -add_subdirectory(test4) -add_subdirectory(test5) -add_subdirectory(test6) - diff --git a/src/pal/tests/palsuite/c_runtime/wcstoul/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/wcstoul/test1/CMakeLists.txt deleted file mode 100644 index bcdcd7cc7..000000000 --- a/src/pal/tests/palsuite/c_runtime/wcstoul/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_wcstoul_test1 - ${SOURCES} -) - -add_dependencies(paltest_wcstoul_test1 coreclrpal) - -target_link_libraries(paltest_wcstoul_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/wcstoul/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/wcstoul/test1/test1.cpp deleted file mode 100644 index 5274905e3..000000000 --- a/src/pal/tests/palsuite/c_runtime/wcstoul/test1/test1.cpp +++ /dev/null @@ -1,49 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: Test #1 for the wcstoul function -** -** -**==========================================================================*/ -#include - -/* - * Notes: wcstoul should depend on the current locale's LC_NUMERIC category, - * this is not currently tested. - */ - - -int __cdecl main(int argc, char *argv[]) -{ - WCHAR teststr[] = {'1','2','3','4','5',0}; - WCHAR *end; - ULONG result = 27; - ULONG l; - - if (0 != PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - l = wcstoul(teststr, &end, 4); - - if (l != result) - { - Fail("ERROR: Expected wcstoul to return %u, got %u\n", result, l); - } - - if (end != teststr + 3) - { - Fail("ERROR: Expected wcstoul to give an end value of %p, got %p\n", - teststr + 3, end); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/wcstoul/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/wcstoul/test1/testinfo.dat deleted file mode 100644 index af4fb7e55..000000000 --- a/src/pal/tests/palsuite/c_runtime/wcstoul/test1/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = wcstoul -Name = Positive Test for wcstoul -TYPE = DEFAULT -EXE1 = test1 -Description -= Tests wcstoul with base 4 and a string that includes some invalid characters. diff --git a/src/pal/tests/palsuite/c_runtime/wcstoul/test2/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/wcstoul/test2/CMakeLists.txt deleted file mode 100644 index 4259cef22..000000000 --- a/src/pal/tests/palsuite/c_runtime/wcstoul/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test2.cpp -) - -add_executable(paltest_wcstoul_test2 - ${SOURCES} -) - -add_dependencies(paltest_wcstoul_test2 coreclrpal) - -target_link_libraries(paltest_wcstoul_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/wcstoul/test2/test2.cpp b/src/pal/tests/palsuite/c_runtime/wcstoul/test2/test2.cpp deleted file mode 100644 index 2ab2dbf5d..000000000 --- a/src/pal/tests/palsuite/c_runtime/wcstoul/test2/test2.cpp +++ /dev/null @@ -1,49 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test2.c -** -** Purpose: Test #2 for the wcstoul function -** -** -**==========================================================================*/ -#include - -/* - * Notes: wcstoul should depend on the current locale's LC_NUMERIC category, - * this is not currently tested. - */ - - -int __cdecl main(int argc, char *argv[]) -{ - WCHAR teststr[] = {'1','2','3','4','5',0}; - WCHAR *end; - ULONG result = 12345; - ULONG l; - - if (0 != PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - l = wcstoul((wchar_t*)teststr, &end, 10); - - if (l != result) - { - Fail("ERROR: Expected wcstoul to return %u, got %u\n", result, l); - } - - if (end != teststr + 5) - { - Fail("ERROR: Expected wcstoul to give an end value of %p, got %p\n", - teststr + 5, end); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/wcstoul/test2/testinfo.dat b/src/pal/tests/palsuite/c_runtime/wcstoul/test2/testinfo.dat deleted file mode 100644 index b7e301f42..000000000 --- a/src/pal/tests/palsuite/c_runtime/wcstoul/test2/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = wcstoul -Name = Positive Test for wcstoul -TYPE = DEFAULT -EXE1 = test2 -Description -= Tests wcstoul with base 10 and a completely valid string. diff --git a/src/pal/tests/palsuite/c_runtime/wcstoul/test3/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/wcstoul/test3/CMakeLists.txt deleted file mode 100644 index 758c43726..000000000 --- a/src/pal/tests/palsuite/c_runtime/wcstoul/test3/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test3.cpp -) - -add_executable(paltest_wcstoul_test3 - ${SOURCES} -) - -add_dependencies(paltest_wcstoul_test3 coreclrpal) - -target_link_libraries(paltest_wcstoul_test3 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/wcstoul/test3/test3.cpp b/src/pal/tests/palsuite/c_runtime/wcstoul/test3/test3.cpp deleted file mode 100644 index eac46615e..000000000 --- a/src/pal/tests/palsuite/c_runtime/wcstoul/test3/test3.cpp +++ /dev/null @@ -1,49 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test3.c -** -** Purpose: Test #3 for the wcstoul function -** -** -**==========================================================================*/ -#include - -/* - * Notes: wcstoul should depend on the current locale's LC_NUMERIC category, - * this is not currently tested. - */ - - -int __cdecl main(int argc, char *argv[]) -{ - WCHAR str[] = {'Z',0}; - WCHAR *end; - ULONG l; - - if (0 != PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - l = wcstoul(str, &end, 10); - - if (l != 0) - { - Fail("ERROR: Expected wcstoul to return %u, got %u\n", 0, l); - } - - if (end != str) - { - Fail("ERROR: Expected wcstoul to give an end value of %p, got %p\n", - str, end); - } - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/c_runtime/wcstoul/test3/testinfo.dat b/src/pal/tests/palsuite/c_runtime/wcstoul/test3/testinfo.dat deleted file mode 100644 index f7f6302d7..000000000 --- a/src/pal/tests/palsuite/c_runtime/wcstoul/test3/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = wcstoul -Name = Positive Test for wcstoul -TYPE = DEFAULT -EXE1 = test3 -Description -= Tests wcstoul with a completely invalid string (base 10). diff --git a/src/pal/tests/palsuite/c_runtime/wcstoul/test4/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/wcstoul/test4/CMakeLists.txt deleted file mode 100644 index 151d372d1..000000000 --- a/src/pal/tests/palsuite/c_runtime/wcstoul/test4/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test4.cpp -) - -add_executable(paltest_wcstoul_test4 - ${SOURCES} -) - -add_dependencies(paltest_wcstoul_test4 coreclrpal) - -target_link_libraries(paltest_wcstoul_test4 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/wcstoul/test4/test4.cpp b/src/pal/tests/palsuite/c_runtime/wcstoul/test4/test4.cpp deleted file mode 100644 index 0261da427..000000000 --- a/src/pal/tests/palsuite/c_runtime/wcstoul/test4/test4.cpp +++ /dev/null @@ -1,52 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test4.c -** -** Purpose: Test #4 for the wcstoul function -** -** -**==========================================================================*/ -#include - -/* - * Notes: wcstoul should depend on the current locale's LC_NUMERIC category, - * this is not currently tested. - */ - -int __cdecl main(int argc, char *argv[]) -{ - WCHAR maxstr[] = {'4','2','9','4','9','6','7','2','9','5',0}; - ULONG max = 4294967295ul; - WCHAR *end; - ULONG l; - - if (0 != PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - errno = 0; - - l = wcstoul(maxstr, &end, 10); - if (l != max) - { - Fail("ERROR: Expected wcstoul to return %u, got %u\n", max, l); - } - if (end != maxstr + 10) - { - Fail("ERROR: Expected wcstoul to give an end value of %p, got %p\n", - maxstr + 10, end); - } - if (errno != 0) - { - Fail("ERROR: wcstoul set errno to non-zero (%d)\n", errno); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/wcstoul/test4/testinfo.dat b/src/pal/tests/palsuite/c_runtime/wcstoul/test4/testinfo.dat deleted file mode 100644 index 301178be3..000000000 --- a/src/pal/tests/palsuite/c_runtime/wcstoul/test4/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = wcstoul -Name = Positive Test for wcstoul -TYPE = DEFAULT -EXE1 = test4 -Description -= Tests wcstoul with base 10 and the highest possible value. diff --git a/src/pal/tests/palsuite/c_runtime/wcstoul/test5/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/wcstoul/test5/CMakeLists.txt deleted file mode 100644 index 97b1e91e6..000000000 --- a/src/pal/tests/palsuite/c_runtime/wcstoul/test5/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test5.cpp -) - -add_executable(paltest_wcstoul_test5 - ${SOURCES} -) - -add_dependencies(paltest_wcstoul_test5 coreclrpal) - -target_link_libraries(paltest_wcstoul_test5 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/wcstoul/test5/test5.cpp b/src/pal/tests/palsuite/c_runtime/wcstoul/test5/test5.cpp deleted file mode 100644 index 00287cf7f..000000000 --- a/src/pal/tests/palsuite/c_runtime/wcstoul/test5/test5.cpp +++ /dev/null @@ -1,69 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test5.c -** -** Purpose: Test #5 for the wcstoul function -** -** -**==========================================================================*/ -#include - -/* - * Notes: wcstoul should depend on the current locale's LC_NUMERIC category, - * this is not currently tested. - */ - - -int __cdecl main(int argc, char *argv[]) -{ - WCHAR overstr[] = {'4','2','9','4','9','6','7','2','9','6',0}; - WCHAR understr[] = {'-','1',0}; - WCHAR *end; - ULONG l; - - if (0 != PAL_Initialize(argc, argv)) - { - return FAIL; - } - - errno = 0; - l = wcstoul(overstr, &end, 10); - - if (l != ULONG_MAX) - { - Fail("ERROR: Expected wcstoul to return %u, got %u\n", ULONG_MAX, l); - } - if (end != overstr + 10) - { - Fail("ERROR: Expected wcstoul to give an end value of %p, got %p\n", - overstr + 10, end); - } - if (errno != ERANGE) - { - Fail("ERROR: wcstoul did not set errno to ERANGE (%d)\n", errno); - } - - errno = 0; - l = wcstoul(understr, &end, 10); - - if (l != ULONG_MAX) - { - Fail("ERROR: Expected wcstoul to return %u, got %u\n", ULONG_MAX, l); - } - if (end != understr + 2) - { - Fail("ERROR: Expected wcstoul to give an end value of %p, got %p\n", - understr + 2, end); - } - if (errno != 0) - { - Fail("ERROR: wcstoul set errno to non-zero (%d)\n", errno); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/wcstoul/test5/testinfo.dat b/src/pal/tests/palsuite/c_runtime/wcstoul/test5/testinfo.dat deleted file mode 100644 index bf7b2b6fe..000000000 --- a/src/pal/tests/palsuite/c_runtime/wcstoul/test5/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = wcstoul -Name = Positive Test for wcstoul -TYPE = DEFAULT -EXE1 = test5 -Description -= Tests wcstoul (base 10) with underflowing and overflowing. -= Chesks that errno gets set to ERANGE. diff --git a/src/pal/tests/palsuite/c_runtime/wcstoul/test6/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/wcstoul/test6/CMakeLists.txt deleted file mode 100644 index b678e2ae0..000000000 --- a/src/pal/tests/palsuite/c_runtime/wcstoul/test6/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test6.cpp -) - -add_executable(paltest_wcstoul_test6 - ${SOURCES} -) - -add_dependencies(paltest_wcstoul_test6 coreclrpal) - -target_link_libraries(paltest_wcstoul_test6 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/wcstoul/test6/test6.cpp b/src/pal/tests/palsuite/c_runtime/wcstoul/test6/test6.cpp deleted file mode 100644 index 28397ec73..000000000 --- a/src/pal/tests/palsuite/c_runtime/wcstoul/test6/test6.cpp +++ /dev/null @@ -1,83 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test6.c -** -** Purpose: Test #6 for the wcstoul function. Tests strings with octal/hex -** number specifers -** -** -**==========================================================================*/ -#include - - -/* - * Notes: wcstoul should depend on the current locale's LC_NUMERIC category, - * this is not currently tested. - */ - - -int __cdecl main(int argc, char *argv[]) -{ - WCHAR test1[] = {'0','x','1','2', 0}; - WCHAR test2[] = {'0','1','2',0}; - WCHAR *end; - ULONG l; - - if (0 != PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - l = wcstoul(test1, &end, 16); - if (l != 0x12) - { - Fail("ERROR: Expected wcstoul to return %u, got %u\n", 0x12, l); - } - if (end != test1 + 4) - { - Fail("ERROR: Expected wcstoul to give an end value of %p, got %p\n", - test1 + 4, end); - } - - l = wcstoul(test1, &end, 10); - if (l != 0) - { - Fail("ERROR: Expected wcstoul to return %u, got %u\n", 0, l); - } - if (end != test1+1) - { - Fail("ERROR: Expected wcstoul to give an end value of %p, got %p\n", - test1+1, end); - } - - l = wcstoul(test2, &end, 8); - if (l != 10) - { - Fail("ERROR: Expected wcstoul to return %u, got %u\n", 10, l); - } - if (end != test2 + 3) - { - Fail("ERROR: Expected wcstoul to give an end value of %p, got %p\n", - test2 + 3, end); - } - - l = wcstoul(test2, &end, 10); - if (l != 12) - { - Fail("ERROR: Expected wcstoul to return %u, got %u\n", 12, l); - } - - if (end != test2 + 3) - { - Fail("ERROR: Expected wcstoul to give an end value of %p, got %p\n", - test2 + 3, end); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/c_runtime/wcstoul/test6/testinfo.dat b/src/pal/tests/palsuite/c_runtime/wcstoul/test6/testinfo.dat deleted file mode 100644 index 40e18d540..000000000 --- a/src/pal/tests/palsuite/c_runtime/wcstoul/test6/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = wcstoul -Name = Positive Test for wcstoul -TYPE = DEFAULT -EXE1 = test6 -Description -= Tests wcstoul with hex and octal strings, with different bases. diff --git a/src/pal/tests/palsuite/c_runtime/wprintf/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/wprintf/CMakeLists.txt deleted file mode 100644 index ef14ea535..000000000 --- a/src/pal/tests/palsuite/c_runtime/wprintf/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) - diff --git a/src/pal/tests/palsuite/c_runtime/wprintf/test1/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/wprintf/test1/CMakeLists.txt deleted file mode 100644 index 8d3ab28ca..000000000 --- a/src/pal/tests/palsuite/c_runtime/wprintf/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_wprintf_test1 - ${SOURCES} -) - -add_dependencies(paltest_wprintf_test1 coreclrpal) - -target_link_libraries(paltest_wprintf_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/wprintf/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/wprintf/test1/test1.cpp deleted file mode 100644 index d99dc8cf9..000000000 --- a/src/pal/tests/palsuite/c_runtime/wprintf/test1/test1.cpp +++ /dev/null @@ -1,47 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: Test #1 for the wprintf function. A single, basic, test -** case with no formatting. -** -** -**==========================================================================*/ - - - -#include -#include "../wprintf.h" - -int __cdecl main(int argc, char *argv[]) -{ - char checkstr[] = "hello world"; - WCHAR *wcheckstr; - int ret; - - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - wcheckstr = convert(checkstr); - - ret = wprintf(wcheckstr); - - if (ret != wcslen(wcheckstr)) - { - Fail("Expected wprintf to return %d, got %d.\n", - wcslen(wcheckstr), ret); - - } - - free(wcheckstr); - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/c_runtime/wprintf/test1/testinfo.dat b/src/pal/tests/palsuite/c_runtime/wprintf/test1/testinfo.dat deleted file mode 100644 index 02946361b..000000000 --- a/src/pal/tests/palsuite/c_runtime/wprintf/test1/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = wprintf -Name = Positive Test for wprintf -TYPE = DEFAULT -EXE1 = test1 -Description -= General test to see if wprintf works correctly diff --git a/src/pal/tests/palsuite/c_runtime/wprintf/test2/CMakeLists.txt b/src/pal/tests/palsuite/c_runtime/wprintf/test2/CMakeLists.txt deleted file mode 100644 index 311948970..000000000 --- a/src/pal/tests/palsuite/c_runtime/wprintf/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test2.cpp -) - -add_executable(paltest_wprintf_test2 - ${SOURCES} -) - -add_dependencies(paltest_wprintf_test2 coreclrpal) - -target_link_libraries(paltest_wprintf_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/c_runtime/wprintf/test2/test2.cpp b/src/pal/tests/palsuite/c_runtime/wprintf/test2/test2.cpp deleted file mode 100644 index 4e54d452e..000000000 --- a/src/pal/tests/palsuite/c_runtime/wprintf/test2/test2.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test2.c -** -** Purpose: Test #2 for the wprintf function. Tests the string specifier -** (%s). -** -** -**==========================================================================*/ - - -#include -#include "../wprintf.h" - - - -int __cdecl main(int argc, char *argv[]) -{ - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - DoStrTest(u"foo %s", u"bar", u"foo bar"); - DoStrTest(u"foo %ws", u"bar", u"foo bar"); - DoStrTest(u"foo %ls", u"bar", u"foo bar"); - DoStrTest(u"foo %ws", u"bar", u"foo bar"); - DoStrTest(u"foo %Ls", u"bar", u"foo bar"); - DoStrTest(u"foo %I64s", u"bar", u"foo bar"); - DoStrTest(u"foo %5s", u"bar", u"foo bar"); - DoStrTest(u"foo %.2s", u"bar", u"foo ba"); - DoStrTest(u"foo %5.2s", u"bar", u"foo ba"); - DoStrTest(u"foo %-5s", u"bar", u"foo bar "); - DoStrTest(u"foo %05s", u"bar", u"foo 00bar"); - DoStrTest(u"foo %s", NULL, u"foo (null)"); - DoStrTest(u"foo %hs", NULL, u"foo (null)"); - DoStrTest(u"foo %ls", NULL, u"foo (null)"); - DoStrTest(u"foo %ws", NULL, u"foo (null)"); - DoStrTest(u"foo %Ls", NULL, u"foo (null)"); - DoStrTest(u"foo %I64s", NULL, u"foo (null)"); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/c_runtime/wprintf/test2/testinfo.dat b/src/pal/tests/palsuite/c_runtime/wprintf/test2/testinfo.dat deleted file mode 100644 index 7808c069d..000000000 --- a/src/pal/tests/palsuite/c_runtime/wprintf/test2/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = wprintf -Name = Positive Test for wprintf -TYPE = DEFAULT -EXE1 = test2 -Description -= Tests wprintf with strings diff --git a/src/pal/tests/palsuite/c_runtime/wprintf/wprintf.h b/src/pal/tests/palsuite/c_runtime/wprintf/wprintf.h deleted file mode 100644 index 3a96248c3..000000000 --- a/src/pal/tests/palsuite/c_runtime/wprintf/wprintf.h +++ /dev/null @@ -1,171 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: wprintf.h -** -** Purpose: Containts common testing functions for wprintf -** -** -**==========================================================================*/ - -#ifndef __wprintf_H__ -#define __wprintf_H__ - -void DoStrTest(const WCHAR *formatstr, const WCHAR *param, const WCHAR *checkstr) -{ - int ret; - - ret = wprintf(formatstr, param); - if (ret != wcslen(checkstr)) - { - Fail("DoStrTest:Expected wprintf to return %d, got %d.\n", - wcslen(checkstr), ret); - } -} - - -void DoPointerTest(const WCHAR *formatstr, void* param, WCHAR* paramstr, - const WCHAR *checkstr1) -{ - int ret; - - ret = wprintf(formatstr, param); - if (ret != wcslen(checkstr1)) - { - Fail("DoPointerTest:Expected wprintf to return %d, got %d.\n", - wcslen(checkstr1), ret); - } -} - -void DoCountTest(const WCHAR *formatstr, int param, const WCHAR *checkstr) -{ - int ret; - int n = -1; - - ret = wprintf(formatstr, &n); - - if (n != param) - { - Fail("DoCountTest:Expected count parameter to resolve to %d, got %d\n", param, n); - } - - if (ret != wcslen(checkstr)) - { - Fail("DoCountTest:Expected wprintf to return %d, got %d.\n", - wcslen(checkstr), ret); - } -} - -void DoShortCountTest(const WCHAR *formatstr, int param, const WCHAR *checkstr) -{ - int ret; - short int n = -1; - - ret = wprintf(formatstr, &n); - - if (n != param) - { - Fail("DoShortCountTest:Expected count parameter to resolve to %d, got %d\n", param, n); - } - - if (ret != wcslen(checkstr)) - { - Fail("DoShortCountTest:Expected wprintf to return %d, got %d.\n", - wcslen(checkstr), ret); - } -} - - -void DoCharTest(const WCHAR *formatstr, WCHAR param, const WCHAR *checkstr) -{ - int ret; - - ret = wprintf(formatstr, param); - if (ret != wcslen(checkstr)) - { - Fail("DoCharTest:Expected wprintf to return %d, got %d.\n", - wcslen(checkstr), ret); - } -} - -void DoWCharTest(const WCHAR *formatstr, WCHAR param, const WCHAR *checkstr) -{ - int ret; - - ret = wprintf(formatstr, param); - if (ret != wcslen(checkstr)) - { - Fail("DoWCharTest:Expected wprintf to return %d, got %d.\n", - wcslen(checkstr), ret); - } -} - -void DoNumTest(const WCHAR *formatstr, int param, const WCHAR *checkstr) -{ - int ret; - - ret = wprintf(formatstr, param); - if (ret != wcslen(checkstr)) - { - Fail("DoNumTest:Expected wprintf to return %d, got %d.\n", - wcslen(checkstr), ret); - } -} - -void DoI64Test(const WCHAR *formatstr, INT64 param, const WCHAR *valuestr, - const WCHAR *checkstr1) -{ - int ret; - - ret = wprintf(formatstr, param); - if (ret != wcslen(checkstr1)) - { - Fail("DoI64Test:Expected wprintf to return %d, got %d.\n", - wcslen(checkstr1), ret); - } -} - -void DoDoubleTest(const WCHAR *formatstr, double param, - const WCHAR *checkstr1, const WCHAR *checkstr2) -{ - int ret; - - ret = wprintf(formatstr, param); - if (ret != wcslen(checkstr1) && ret != wcslen(checkstr2)) - { - Fail("DoDoubleTest:Expected wprintf to return %d or %d, got %d.\n", - wcslen(checkstr1), wcslen(checkstr2), ret); - } -} - -void DoArgumentPrecTest(const WCHAR *formatstr, int precision, void *param, - WCHAR *paramstr, const WCHAR *checkstr1, const WCHAR *checkstr2) -{ - int ret; - - ret = wprintf(formatstr, precision, param); - if (ret != wcslen(checkstr1) && ret != wcslen(checkstr2)) - { - Fail("DoArgumentPrecTest:Expected wprintf to return %d or %d, got %d.\n", - wcslen(checkstr1), wcslen(checkstr2), ret); - } -} - -void DoArgumentPrecDoubleTest(const WCHAR *formatstr, int precision, double param, - const WCHAR *checkstr1, const WCHAR *checkstr2) -{ - int ret; - - ret = wprintf(formatstr, precision, param); - if (ret != wcslen(checkstr1) && ret != wcslen(checkstr2)) - { - Fail("DoArgumentPrecDoubleTest:Expected wprintf to return %d or %d, got %d.\n", - wcslen(checkstr1), wcslen(checkstr2), ret); - } -} - -#endif - diff --git a/src/pal/tests/palsuite/common/ResultBuffer.cpp b/src/pal/tests/palsuite/common/ResultBuffer.cpp deleted file mode 100644 index e38c32418..000000000 --- a/src/pal/tests/palsuite/common/ResultBuffer.cpp +++ /dev/null @@ -1,69 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -//#include "stdafx.h" -#include "resultbuffer.h" -// -//#using -// -//using namespace System; - - -ResultBuffer:: ResultBuffer(int ThreadCount, int ThreadLogSize) - { - // Declare an internal status variable - int Status=0; - - // Update the maximum thread count - MaxThreadCount = ThreadCount; - - // Allocate the memory buffer based on the passed in thread and process counts - // and the specified size of the thread specific buffer - buffer = NULL; - buffer = (char*)malloc(ThreadCount*ThreadLogSize); - // Check to see if the buffer memory was allocated - if (buffer == NULL) - Status = -1; - // Initialize the buffer to 0 to prevent bogus data - memset(buffer,0,ThreadCount*ThreadLogSize); - - // The ThreadOffset is equal to the total number of bytes that will be stored per thread - ThreadOffset = ThreadLogSize; - - } - - - int ResultBuffer::LogResult(int Thread, char* Data) - { - // Declare an internal status flad - int status = 0; - - // Declare an object to store the offset address into the buffer - int Offset; - - // Check to make sure the Thread index is not out of range - if(Thread > MaxThreadCount) - { - Trace("Thread index is out of range, Value of Thread[%d], Value of MaxThreadCount[%d]\n", Thread, MaxThreadCount); - status = -1; - return(status); - } - - // Caculate the offset into the shared buffer based on the process and thread indices - Offset = (Thread)*ThreadOffset; - - // Write the passed in data to the reserved buffer - memcpy(buffer+Offset,Data,ThreadOffset); - - return(status); - } - - - char* ResultBuffer::getResultBuffer(int threadId) - { - - return (buffer + threadId*ThreadOffset); - - } - diff --git a/src/pal/tests/palsuite/common/ResultBuffer.h b/src/pal/tests/palsuite/common/ResultBuffer.h deleted file mode 100644 index c59d421e2..000000000 --- a/src/pal/tests/palsuite/common/ResultBuffer.h +++ /dev/null @@ -1,43 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -//#include -//#include -//#include -#ifndef _RESULT_BUFFER_H_ -#define _RESULT_BUFFER_H_ - -#include - -struct ResultData -{ - int value; - int size; -// ResultData* NextResult; -}; - - class ResultBuffer -{ - // Declare a pointer to a memory buffer to store the logged results - char* buffer; - // Declare an object to store the maximum Thread count - int MaxThreadCount; - // Declare and internal data object to store the calculated offset between adjacent threads data sets - int ThreadOffset; - - // Declare a linked list object to store the parameter values -public: - - // Declare a constructor for the single process case - ResultBuffer(int ThreadCount, int ThreadLogSize); - // Declare a method to log data for the single process instance - int LogResult(int Thread, char* Data); - - char* getResultBuffer(int threadId); -}; - -#include "resultbuffer.cpp" -#endif // _RESULT_BUFFER_H_ - - diff --git a/src/pal/tests/palsuite/common/ResultTime.h b/src/pal/tests/palsuite/common/ResultTime.h deleted file mode 100644 index 82daeb83c..000000000 --- a/src/pal/tests/palsuite/common/ResultTime.h +++ /dev/null @@ -1,83 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#ifndef _RESULT_TIME_H_ -#define _RESULT_TIME_H_ - -#include - -#define DWORD_MAX ((DWORD) 0xFFFFFFFF) -const char *szDotNetInstallEnvVar = "DOTNET_INSTALL"; -const char *szQASupportDirEnvVar = "QA_SUPPORT_DIR"; - -#define SEPERATOR "/" -char *getBuildNumber() -{ - char *szBuildFileName = "buildinfo.txt"; - char *pDirectoryName = NULL; - char szBuildFileLoc[256]; - - char szTemp[100]; - // buildinfo.txt contains information in key/value pair - char szTempKey[100]; - char *szTempValue; - FILE *fp; - - szTempValue = (char *) malloc (sizeof(char) *100); - if (szTempValue == NULL) - { - Fail("ERROR: Couldn't allocate enough memory to potentially store build number\n"); - } - - pDirectoryName = getenv(szQASupportDirEnvVar); - if (pDirectoryName == NULL) - { - Trace("WARNING: Coriolis Test Environment may not be setup correctly. Variable QA_SUPPORT_DIR not set\n"); - _snprintf(szTempValue, 99, "0000.00"); - return szTempValue; - } - - // To avoid buffer overruns for pDirectoryName - _snprintf(szBuildFileLoc, MAX_PATH, "%s/../1.0%s%s", pDirectoryName, SEPERATOR, szBuildFileName); - fp = fopen( szBuildFileLoc, "r"); - if( fp == NULL) - { - Trace("WARNING: Couldn't open szBuildFileLoc [%s]\n", szBuildFileLoc); - _snprintf(szTempValue, 99, "0000.00"); - return szTempValue; - } - - while( fgets( szTemp, 100, fp ) != NULL) - { - sscanf(szTemp, "%s %s\n", szTempKey, szTempValue); - if(strcmp(szTempKey, "Build-Number:") == 0) - { - fclose(fp); - return szTempValue; - } - } - - fclose(fp); - return szTempValue; - -} - -DWORD GetTimeDiff( DWORD dwStartTime) -{ - DWORD dwDiffTime = 0; - DWORD dwEndTime = GetTickCount(); - - if( dwEndTime < dwStartTime) - { - // To account for overflow, we add one - dwDiffTime = dwEndTime + (DWORD_MAX - dwStartTime) + 1; - } - else - { - dwDiffTime = dwEndTime - dwStartTime; - } - - return dwDiffTime; -} -#endif // _RESULT_TIME_H_ diff --git a/src/pal/tests/palsuite/common/pal_stdclib.h b/src/pal/tests/palsuite/common/pal_stdclib.h deleted file mode 100644 index 61963db67..000000000 --- a/src/pal/tests/palsuite/common/pal_stdclib.h +++ /dev/null @@ -1,24 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: pal_stdlib.h -** -** Purpose: -** -** -**==========================================================================*/ - - -#ifndef __PAL_STDCLIB_H__ -#define __PAL_STDCLIB_H__ - -/* - * definitions & functions - */ - -#define EOF (-1) - -#endif // __PAL_STDCLIB_H__ diff --git a/src/pal/tests/palsuite/common/palsuite.h b/src/pal/tests/palsuite/common/palsuite.h deleted file mode 100644 index b77ca2ead..000000000 --- a/src/pal/tests/palsuite/common/palsuite.h +++ /dev/null @@ -1,182 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: palsuite.h -** -** Purpose: Define constants and implement functions that are useful to -** multiple function categories. If common functions are useful -** only amongst the test cases for a particular function, a separate -** header file is placed in the root of those test cases. -** -** -**==========================================================================*/ - -#ifndef __PALSUITE_H__ -#define __PALSUITE_H__ - -#include -#include -#include - -enum -{ - PASS = 0, - FAIL = 1 -}; - - -void Trace(const char *format, ...) -{ - va_list arglist; - - va_start(arglist, format); - - vprintf(format, arglist); - - va_end(arglist); -} - -void Fail(const char *format, ...) -{ - va_list arglist; - - va_start(arglist, format); - - vprintf(format, arglist); - - va_end(arglist); - printf("\n"); - - // This will exit the test process - PAL_TerminateEx(FAIL); -} - -#ifdef PAL_PERF - -int __cdecl Test_Main(int argc, char **argv); -int PAL_InitializeResult = 0; -static const char PALTEST_LOOP_ENV[]="PALTEST_LOOP_COUNT"; - -int __cdecl main(int argc, char **argv) -{ - int lastMainResult=0; - - int loopCount=1; // default: run the test's main once - int loopIndex=0; - char *szPerfLoopEnv = NULL; - - // Run PAL_Initialize once, save off the result. Any failures here - // will be detected later by calls to PAL_Initialize in the test's main. - PAL_InitializeResult = PAL_Initialize(argc, argv); - - // Check the environment to see if we need to run the test's main - // multiple times. Ideally, we want to do this before PAL_Initialize so - // that the overhead of checking the environment is not included in the - // time between PAL_Initialize and PAL_Terminate. However, getenv in PAL - // can be run only after PAL_Initialize. - szPerfLoopEnv = getenv(PALTEST_LOOP_ENV); - if (szPerfLoopEnv != NULL) - { - loopCount = atoi(szPerfLoopEnv); - if (loopCount <= 0) loopCount = 1; - } - - // call the test's actual main in a loop - for(loopIndex=0; loopIndex> 24) | - ((x & 0x00FF0000L) >> 8) | - ((x & 0x0000FF00L) << 8) | - ((x & 0x000000FFL) << 24) ); -} -#define th_htons(w) (w) -#else // BIGENDIAN -#define VAL32(x) (x) -#define th_htons(w) (((w) >> 8) | ((w) << 8)) -#endif // BIGENDIAN - -#define _countof(_array) (sizeof(_array)/sizeof(_array[0])) - -WCHAR* convert(const char * aString) -{ - int size; - WCHAR* wideBuffer; - - size = MultiByteToWideChar(CP_ACP,0,aString,-1,NULL,0); - wideBuffer = (WCHAR*) malloc(size*sizeof(WCHAR)); - if (wideBuffer == NULL) - { - Fail("ERROR: Unable to allocate memory!\n"); - } - MultiByteToWideChar(CP_ACP,0,aString,-1,wideBuffer,size); - return wideBuffer; -} - -char* convertC(const WCHAR * wString) -{ - int size; - char * MultiBuffer = NULL; - - size = WideCharToMultiByte(CP_ACP,0,wString,-1,MultiBuffer,0,NULL,NULL); - MultiBuffer = (char*) malloc(size); - if (MultiBuffer == NULL) - { - Fail("ERROR: Unable to allocate memory!\n"); - } - WideCharToMultiByte(CP_ACP,0,wString,-1,MultiBuffer,size,NULL,NULL); - return MultiBuffer; -} - -UINT64 GetHighPrecisionTimeStamp(LARGE_INTEGER performanceFrequency) -{ - LARGE_INTEGER ts; - if (!QueryPerformanceCounter(&ts)) - { - Fail("ERROR: Unable to query performance counter!\n"); - } - - return ts.QuadPart / (performanceFrequency.QuadPart / 1000); -} - -#endif - - - diff --git a/src/pal/tests/palsuite/composite/CMakeLists.txt b/src/pal/tests/palsuite/composite/CMakeLists.txt deleted file mode 100644 index 220b8cc18..000000000 --- a/src/pal/tests/palsuite/composite/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(object_management) -add_subdirectory(synchronization) -add_subdirectory(threading) -add_subdirectory(wfmo) - diff --git a/src/pal/tests/palsuite/composite/object_management/CMakeLists.txt b/src/pal/tests/palsuite/composite/object_management/CMakeLists.txt deleted file mode 100644 index 5fd88b004..000000000 --- a/src/pal/tests/palsuite/composite/object_management/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(event) -add_subdirectory(mutex) -add_subdirectory(semaphore) - diff --git a/src/pal/tests/palsuite/composite/object_management/event/CMakeLists.txt b/src/pal/tests/palsuite/composite/object_management/event/CMakeLists.txt deleted file mode 100644 index 2534564f9..000000000 --- a/src/pal/tests/palsuite/composite/object_management/event/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(nonshared) -add_subdirectory(shared) - diff --git a/src/pal/tests/palsuite/composite/object_management/event/nonshared/CMakeLists.txt b/src/pal/tests/palsuite/composite/object_management/event/nonshared/CMakeLists.txt deleted file mode 100644 index 276d9a47c..000000000 --- a/src/pal/tests/palsuite/composite/object_management/event/nonshared/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - event.cpp - main.cpp -) - -add_executable(paltest_event_nonshared - ${SOURCES} -) - -add_dependencies(paltest_event_nonshared coreclrpal) - -target_link_libraries(paltest_event_nonshared - ${COMMON_TEST_LIBRARIES} - rt -) diff --git a/src/pal/tests/palsuite/composite/object_management/event/nonshared/event.cpp b/src/pal/tests/palsuite/composite/object_management/event/nonshared/event.cpp deleted file mode 100644 index 69ad9a30e..000000000 --- a/src/pal/tests/palsuite/composite/object_management/event/nonshared/event.cpp +++ /dev/null @@ -1,358 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source Code: main.c and event.c -** main.c creates process and waits for all processes to get over -** event.c creates a event and then calls threads which will contend for the event -** -** This test is for Object Management Test case for event where Object type is shareable. -** Algorithm -** o Main Process Creates OBJECT_TYPE Object -** o Create PROCESS_COUNT processes aware of the Shared Object -** -** Author: ShamitP -** -** -**============================================================ -*/ - -#include -#include "resultbuffer.h" -#include "resulttime.h" - -#define TIMEOUT 5000 -/* Test Input Variables */ -unsigned int USE_PROCESS_COUNT = 0; -unsigned int THREAD_COUNT = 0; -unsigned int REPEAT_COUNT = 0; -unsigned int RELATION_ID= 0; - -/* Event variables */ -//unsigned long lInitialCount = 1; /* Signaled */ -//unsigned long lMaximumCount = 1; /* Maximum value of 1 */ - -/* Capture statistics at per thread basis */ -struct statistics{ - unsigned int processId; - unsigned int operationsFailed; - unsigned int operationsPassed; - unsigned int operationsTotal; - DWORD operationTime; - unsigned int relationId; -}; - -struct ProcessStats{ - unsigned int processId; - DWORD operationTime; - unsigned int relationId; -}; - -HANDLE StartTestsEvHandle = NULL; -HANDLE hEventHandle = NULL; - -/* Results Buffer */ -ResultBuffer *resultBuffer = NULL; - -int testStatus; - -const char sTmpEventName[MAX_PATH_FNAME] = "StartTestEvent"; - -void PALAPI Run_Thread(LPVOID lpParam); - -int GetParameters( int argc, char **argv) -{ - if( (argc != 5) || ((argc == 1) && !strcmp(argv[1],"/?")) - || !strcmp(argv[1],"/h") || !strcmp(argv[1],"/H")) - { - printf("PAL -Composite Object Management Event Test\n"); - printf("Usage:\n"); - printf("Event\n\t[USE_PROCESS_COUNT [greater than 1] \n"); - printf("\t[THREAD_COUNT [greater than 1] \n"); - printf("\t[REPEAT_COUNT [greater than 1]\n"); - printf("\t[RELATION_ID [greater than or Equal to 1]\n"); - - return -1; - } - - // Trace("Args 1 is [%s], Arg 2 is [%s], Arg 3 is [%s]\n", argv[1], argv[2], argv[3]); - - USE_PROCESS_COUNT = atoi(argv[1]); - if( USE_PROCESS_COUNT < 0) - { - printf("\nInvalid USE_PROCESS_COUNT number, Pass greater than 1\n"); - return -1; - } - - THREAD_COUNT = atoi(argv[2]); - if( (THREAD_COUNT < 1) || (THREAD_COUNT > MAXIMUM_WAIT_OBJECTS) ) - { - printf("\nInvalid THREAD_COUNT number, Pass greater than 1 and less than %d\n", MAXIMUM_WAIT_OBJECTS); - return -1; - } - - REPEAT_COUNT = atoi(argv[3]); - if( REPEAT_COUNT < 1) - { - printf("\nInvalid REPEAT_COUNT number, Pass greater than 1\n"); - return -1; - } - - RELATION_ID = atoi(argv[4]); - if( RELATION_ID < 1) - { - printf("\nMain Process:Invalid RELATION_ID number, Pass greater than 1\n"); - return -1; - } - - - return 0; -} - - int __cdecl main(INT argc, CHAR **argv) -{ - unsigned int i = 0; - HANDLE hThread[MAXIMUM_WAIT_OBJECTS]; - DWORD threadId[MAXIMUM_WAIT_OBJECTS]; - int returnCode = 0; - - DWORD dwParam = 0; - - /* Variables to capture the file name and the file pointer at thread level*/ - char fileName[MAX_LONGPATH]; - FILE *pFile = NULL; - struct statistics* buffer = NULL; - int statisticsSize = 0; - - /* Variables to capture the file name and the file pointer at process level*/ - char processFileName[MAX_LONGPATH]; - FILE *pProcessFile = NULL; - struct ProcessStats processStats; - DWORD dwStartTime; - - testStatus = PASS; - - if(0 != (PAL_Initialize(argc, argv))) - { - return ( FAIL ); - } - - if(GetParameters(argc, argv)) - { - Fail("Error in obtaining the parameters\n"); - } -// Trace("Process created, value of process count is [%d]\n", USE_PROCESS_COUNT); - - /* Register the start time */ - dwStartTime = GetTickCount(); - processStats.relationId = RELATION_ID; - processStats.processId = USE_PROCESS_COUNT; - - _snprintf(processFileName, MAX_LONGPATH, "%d_process_event_%d_.txt", USE_PROCESS_COUNT, RELATION_ID); - pProcessFile = fopen(processFileName, "w+"); - if(pProcessFile == NULL) - { - Fail("Error in opening process File file for write for process [%d]\n", USE_PROCESS_COUNT); - } - - statisticsSize = sizeof(struct statistics); - - _snprintf(fileName, MAX_LONGPATH, "%d_thread_event_%d_.txt", USE_PROCESS_COUNT, RELATION_ID); - pFile = fopen(fileName, "w+"); - - if(pFile == NULL) - { - Fail("Error in opening thread File for write for process [%d]\n", USE_PROCESS_COUNT); - } - // For each thread we will log operations failed (int), passed (int), total (int) - // and number of ticks (DWORD) for the operations - resultBuffer = new ResultBuffer( THREAD_COUNT, statisticsSize); - - StartTestsEvHandle = CreateEvent( - NULL, /* lpEventAttributes*/ - TRUE, /* bManualReset */ - FALSE, /* bInitialState */ - NULL /* name of Event */ - ); - - if( StartTestsEvHandle == NULL ) - { - Fail("Error:%d: Unexpected failure " - "to create %s Event for process count %d\n", GetLastError(), sTmpEventName, USE_PROCESS_COUNT ); - - } - - /* Create StartTest Event */ - - hEventHandle = CreateEvent( - NULL, /* lpEventAttributes, inheritable to child processes*/ - TRUE, /* bAutomaticReset */ - TRUE, /* bInitialState */ - NULL - ); - - if( hEventHandle == NULL) - { - Fail("Unable to create Event handle for process id [%d], returned error [%d]\n", i, GetLastError()); - } - /* We already assume that the Event was created previously*/ - - for( i = 0; i < THREAD_COUNT; i++ ) - { - dwParam = (int) i; - //Create thread - hThread[i] = CreateThread( - NULL, /* no security attributes */ - 0, /* use default stack size */ - (LPTHREAD_START_ROUTINE)Run_Thread,/* thread function */ - (LPVOID)dwParam, /* argument to thread function */ - 0, /* use default creation flags */ - &threadId[i] /* returns the thread identifier*/ - ); - - - if(hThread[i] == NULL) - { - Fail("Create Thread failed for %d process, and GetLastError value is %d\n", USE_PROCESS_COUNT, GetLastError()); - } - - } - - if (!SetEvent(StartTestsEvHandle)) - { - Fail("Set Event for Start Tests failed for %d process, and GetLastError value is %d\n", USE_PROCESS_COUNT, GetLastError()); - } - /* Test running */ - returnCode = WaitForMultipleObjects( THREAD_COUNT, hThread, TRUE, INFINITE); - - if( WAIT_OBJECT_0 != returnCode ) - { - Trace("Wait for Object(s) for %d process returned %d, and GetLastError value is %d\n", USE_PROCESS_COUNT, returnCode, GetLastError()); - testStatus = FAIL; - } - - processStats.operationTime = GetTimeDiff(dwStartTime); - - /* Write to a file*/ - if(pFile!= NULL) - { - for( i = 0; i < THREAD_COUNT; i++ ) - { - buffer = (struct statistics *)resultBuffer->getResultBuffer(i); - returnCode = fprintf(pFile, "%d,%d,%d,%d,%lu,%d\n", buffer->processId, buffer->operationsFailed, buffer->operationsPassed, buffer->operationsTotal, buffer->operationTime, buffer->relationId ); - //Trace("Iteration %d over\n", i); - - } - } - if(fclose(pFile)) - { - Trace("Error: fclose failed for pFile\n"); - testStatus = FAIL; - } - - fprintf(pProcessFile, "%d,%d,%d\n", USE_PROCESS_COUNT, processStats.operationTime, processStats.relationId ); - if(fclose(pProcessFile)) - { - Trace("Error: fclose failed for pProcessFile at Process %d\n", USE_PROCESS_COUNT); - testStatus = FAIL; - } - - /* Logging for the test case over, clean up the handles */ - -// Trace("Test Thread %d done\n", USE_PROCESS_COUNT); - /* Clean Up */ - for( i = 0; i < THREAD_COUNT; i++ ) - { - if(!CloseHandle(hThread[i]) ) - { - Trace("Error:%d: CloseHandle failed for Process [%d] hThread[%d]\n", GetLastError(), USE_PROCESS_COUNT, i); - testStatus = FAIL; - } - } - - if(!CloseHandle(StartTestsEvHandle)) - { - Trace("Error:%d: CloseHandle failed for Process [%d] StartTestsEvHandle\n", GetLastError(), USE_PROCESS_COUNT); - testStatus = FAIL; - } - - if(!CloseHandle(hEventHandle)) - { - Trace("Error:%d: CloseHandle failed for Process [%d] hEventHandle\n", GetLastError(), USE_PROCESS_COUNT); - testStatus = FAIL; - } - - PAL_Terminate(); - return testStatus; - -} - -void PALAPI Run_Thread (LPVOID lpParam) -{ - unsigned int i = 0; - DWORD dwWaitResult; - - struct statistics stats; - DWORD dwStartTime; - - stats.relationId = RELATION_ID; - stats.processId = USE_PROCESS_COUNT; - stats.operationsFailed = 0; - stats.operationsPassed = 0; - stats.operationsTotal = 0; - stats.operationTime = 0; - - int Id=(int)lpParam; - - dwWaitResult = WaitForSingleObject( - StartTestsEvHandle, // handle to start test handle - TIMEOUT); - - if(dwWaitResult != WAIT_OBJECT_0) - { - Fail("Error while waiting for StartTest Event@ thread %d, RC is %d, Error is %d\n", Id, dwWaitResult, GetLastError()); - } - - dwStartTime = GetTickCount(); - - for( i = 0; i < REPEAT_COUNT; i++ ) - { - dwWaitResult = WaitForSingleObject( - hEventHandle, // handle to Event - TIMEOUT); - - if(dwWaitResult != WAIT_OBJECT_0) - { -// Trace("Error while waiting for onject @ thread %d, # iter %d, RC is %d, Error is %d\n", Id, i, dwWaitResult, GetLastError()); - stats.operationsFailed += 1; - stats.operationsTotal += 1; - testStatus = FAIL; - continue; - } - - if (! SetEvent(hEventHandle)) - { - // Deal with error. -// Trace("Error while setting Event @ thread %d # iter %d\n", Id, i); - stats.operationsFailed += 1; - stats.operationsTotal += 1; - // Do we need to have while true loop to attempt to set event? - testStatus = FAIL; - continue; - } - - stats.operationsTotal += 1; - stats.operationsPassed += 1; -// Trace("Successs while setting Event @ iteration %d -> thread %d -> Process %d\n", i, Id, USE_PROCESS_COUNT); - - } - - stats.operationTime = GetTimeDiff(dwStartTime); - if(resultBuffer->LogResult(Id, (char *)&stats)) - { - Fail("Error:%d: while writing to shared memory, Thread Id is[%d] and Process id is [%d]\n", GetLastError(), Id, USE_PROCESS_COUNT); - } - //Trace("Thread %d over for process %d\n", Id, USE_PROCESS_COUNT); -} diff --git a/src/pal/tests/palsuite/composite/object_management/event/nonshared/main.cpp b/src/pal/tests/palsuite/composite/object_management/event/nonshared/main.cpp deleted file mode 100644 index 7b61e9173..000000000 --- a/src/pal/tests/palsuite/composite/object_management/event/nonshared/main.cpp +++ /dev/null @@ -1,228 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source Code: main.c and event.c -** main.c creates process and waits for all processes to get over -** event.c creates a event and then calls threads which will contend for the event -** -** This test is for Object Management Test case for event where Object type is not shareable. -** Algorithm -** o Create PROCESS_COUNT processes. -** o Main Thread of each process creates OBJECT_TYPE Object -** -** Author: ShamitP -**============================================================ -*/ - -#include -#include "resulttime.h" - -/* Test Input Variables */ -unsigned int PROCESS_COUNT = 10; -unsigned int THREAD_COUNT = 20; -unsigned int REPEAT_COUNT = 20000; -unsigned int RELATION_ID = 1001; - - -struct TestStats{ - DWORD operationTime; - unsigned int relationId; - unsigned int processCount; - unsigned int threadCount; - unsigned int repeatCount; - char* buildNumber; - -}; - - -int GetParameters( int argc, char **argv) -{ - if( (argc != 5) || ((argc == 1) && !strcmp(argv[1],"/?")) - || !strcmp(argv[1],"/h") || !strcmp(argv[1],"/H")) - { - printf("PAL -Composite Object Management event Test\n"); - printf("Usage:\n"); - printf("main\n\t[PROCESS_COUNT [greater than 1] \n"); - printf("\t[THREAD_COUNT [greater than 1] \n"); - printf("\t[REPEAT_COUNT [greater than 1]\n"); - printf("\t[RELATION_ID [greater than or Equal to 1]\n"); - return -1; - } - - PROCESS_COUNT = atoi(argv[1]); - if( (PROCESS_COUNT < 1) || (PROCESS_COUNT > MAXIMUM_WAIT_OBJECTS) ) - { - printf("\nMain Process:Invalid PROCESS_COUNT number, Pass greater than 1 and less than PROCESS_COUNT %d\n", MAXIMUM_WAIT_OBJECTS); - return -1; - } - - THREAD_COUNT = atoi(argv[2]); - if( (THREAD_COUNT < 1) || (THREAD_COUNT > MAXIMUM_WAIT_OBJECTS) ) - { - printf("\nInvalid THREAD_COUNT number, Pass greater than 1 and less than %d\n", MAXIMUM_WAIT_OBJECTS); - return -1; - } - - REPEAT_COUNT = atoi(argv[3]); - if( REPEAT_COUNT < 1) - { - printf("\nMain Process:Invalid REPEAT_COUNT number, Pass greater than 1\n"); - return -1; - } - - RELATION_ID = atoi(argv[4]); - if( RELATION_ID < 1) - { - printf("\nMain Process:Invalid RELATION_ID number, Pass greater than 1\n"); - return -1; - } - - - return 0; -} - - int __cdecl main(INT argc, CHAR **argv) -{ - unsigned int i = 0; - HANDLE hProcess[MAXIMUM_WAIT_OBJECTS]; - - STARTUPINFO si[MAXIMUM_WAIT_OBJECTS]; - PROCESS_INFORMATION pi[MAXIMUM_WAIT_OBJECTS]; - - char lpCommandLine[MAX_LONGPATH] = ""; - const char *ObjName = "Event"; - - int returnCode = 0; - DWORD processReturnCode = 0; - int testReturnCode = PASS; - - char fileName[MAX_LONGPATH]; - FILE *pFile = NULL; - DWORD dwStartTime = 0; - struct TestStats testStats; - - if(0 != (PAL_Initialize(argc, argv))) - { - return ( FAIL ); - } - - if(GetParameters(argc, argv)) - { - Fail("Error in obtaining the parameters\n"); - } - - /* Register the start time */ - dwStartTime = GetTickCount(); - testStats.relationId = RELATION_ID; - testStats.processCount = PROCESS_COUNT; - testStats.threadCount = THREAD_COUNT; - testStats.repeatCount = REPEAT_COUNT; - testStats.buildNumber = getBuildNumber(); - - - _snprintf(fileName, MAX_LONGPATH, "main_event_%d_.txt", RELATION_ID); - pFile = fopen(fileName, "w+"); - if(pFile == NULL) - { - Fail("Error in opening main file for write\n"); - } - - for( i = 0; i < PROCESS_COUNT; i++ ) - { - - ZeroMemory( lpCommandLine, MAX_PATH ); - if ( _snprintf( lpCommandLine, MAX_LONGPATH-1, "event %d %d %d %d", i, THREAD_COUNT, REPEAT_COUNT, RELATION_ID) < 0 ) - { - Fail ("Error: Insufficient Event name string length for %s for iteration [%d]\n", ObjName, i); - } - - /* Zero the data structure space */ - ZeroMemory ( &pi[i], sizeof(pi[i]) ); - ZeroMemory ( &si[i], sizeof(si[i]) ); - - /* Set the process flags and standard io handles */ - si[i].cb = sizeof(si[i]); - - //Create Process - if(!CreateProcess( NULL, /* lpApplicationName*/ - lpCommandLine, /* lpCommandLine */ - NULL, /* lpProcessAttributes */ - NULL, /* lpThreadAttributes */ - TRUE, /* bInheritHandles */ - 0, /* dwCreationFlags, */ - NULL, /* lpEnvironment */ - NULL, /* pCurrentDirectory */ - &si[i], /* lpStartupInfo */ - &pi[i] /* lpProcessInformation */ - )) - { - Fail("Process Not created for [%d], the error code is [%d]\n", i, GetLastError()); - } - else - { - hProcess[i] = pi[i].hProcess; - //Trace("Process created for [%d]\n", i); - - } - - } - - returnCode = WaitForMultipleObjects( PROCESS_COUNT, hProcess, TRUE, INFINITE); - if( WAIT_OBJECT_0 != returnCode ) - { - Trace("Wait for Object(s) @ Main thread for %d processes returned %d, and GetLastError value is %d\n", PROCESS_COUNT, returnCode, GetLastError()); - testReturnCode = FAIL; - } - - for( i = 0; i < PROCESS_COUNT; i++ ) - { - /* check the exit code from the process */ - if( ! GetExitCodeProcess( pi[i].hProcess, &processReturnCode ) ) - { - Trace( "GetExitCodeProcess call failed for iteration %d with error code %u\n", - i, GetLastError() ); - - testReturnCode = FAIL; - } - - if(processReturnCode == FAIL) - { - Trace( "Process [%d] failed and returned FAIL\n", i); - testReturnCode = FAIL; - } - - if(!CloseHandle(pi[i].hThread)) - { - Trace("Error:%d: CloseHandle failed for Process [%d] hThread\n", GetLastError(), i); - testReturnCode = FAIL; - } - - if(!CloseHandle(pi[i].hProcess) ) - { - Trace("Error:%d: CloseHandle failed for Process [%d] hProcess\n", GetLastError(), i); - testReturnCode = FAIL; - } - } - - testStats.operationTime = GetTimeDiff(dwStartTime); - fprintf(pFile, "%d,%d,%d,%d,%d,%s\n", testStats.operationTime, testStats.relationId, testStats.processCount, testStats.threadCount, testStats.repeatCount, testStats.buildNumber); - if(fclose(pFile)) - { - Trace("Error: fclose failed for pFile\n"); - testReturnCode = FAIL; - } - - if( testReturnCode == PASS) - { - Trace("Test Passed\n"); - } - else - { - Trace("Test Failed\n"); - } - PAL_Terminate(); - return testReturnCode; -} diff --git a/src/pal/tests/palsuite/composite/object_management/event/shared/CMakeLists.txt b/src/pal/tests/palsuite/composite/object_management/event/shared/CMakeLists.txt deleted file mode 100644 index 92ad5b0c1..000000000 --- a/src/pal/tests/palsuite/composite/object_management/event/shared/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - event.cpp - main.cpp -) - -add_executable(paltest_event_shared - ${SOURCES} -) - -add_dependencies(paltest_event_shared coreclrpal) - -target_link_libraries(paltest_event_shared - ${COMMON_TEST_LIBRARIES} - rt -) diff --git a/src/pal/tests/palsuite/composite/object_management/event/shared/event.cpp b/src/pal/tests/palsuite/composite/object_management/event/shared/event.cpp deleted file mode 100644 index 83d5fce27..000000000 --- a/src/pal/tests/palsuite/composite/object_management/event/shared/event.cpp +++ /dev/null @@ -1,373 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source Code: main.c and event.c -** main.c creates process and waits for all processes to get over -** event.c creates a event and then calls threads which will contend for the event -** -** This test is for Object Management Test case for event where Object type is shareable. -** Algorithm -** o Main Process Creates OBJECT_TYPE Object -** o Create PROCESS_COUNT processes aware of the Shared Object -** -** Author: ShamitP -** Author: ShamitP -** -** -**============================================================ -*/ - -#include -#include "resultbuffer.h" -#include "resulttime.h" - -#define TIMEOUT 5000 -/* Test Input Variables */ -unsigned int USE_PROCESS_COUNT = 0; -unsigned int THREAD_COUNT = 0; -unsigned int REPEAT_COUNT = 0; -unsigned int RELATION_ID = 0; - -/* Capture statistics at per thread basis */ -struct statistics{ - unsigned int processId; - unsigned int operationsFailed; - unsigned int operationsPassed; - unsigned int operationsTotal; - DWORD operationTime; - unsigned int relationId; -}; - -struct ProcessStats{ - unsigned int processId; - DWORD operationTime; - unsigned int relationId; -}; - -HANDLE StartTestsEvHandle = NULL; -HANDLE hEventHandle = NULL; - -/* Results Buffer */ -ResultBuffer *resultBuffer= NULL; - -int testStatus; - -const char sTmpEventName[MAX_PATH] = "StartTestEvent"; -char objectSuffix[MAX_PATH]; - -void PALAPI Run_Thread(LPVOID lpParam); - -int GetParameters( int argc, char **argv) -{ - if( (!((argc == 5) || (argc == 6) ) )|| ((argc == 1) && !strcmp(argv[1],"/?")) - || !strcmp(argv[1],"/h") || !strcmp(argv[1],"/H")) - { - printf("PAL -Composite Object Management event Test\n"); - printf("Usage:\n"); - printf("main\n\t[USE_PROCESS_COUNT (greater than 1)] \n"); - printf("\t[THREAD_COUNT (greater than 1)] \n"); - printf("\t[REPEAT_COUNT (greater than 1)]\n"); - printf("\t[RELATION_ID [greater than or equal to 1]\n"); - printf("\t[Object Name Suffix]\n"); - - return -1; - } - - // Trace("Args 1 is [%s], Arg 2 is [%s], Arg 3 is [%s]\n", argv[1], argv[2], argv[3]); - - USE_PROCESS_COUNT = atoi(argv[1]); - if( USE_PROCESS_COUNT < 0) - { - printf("\nInvalid USE_PROCESS_COUNT number, Pass greater than 1\n"); - return -1; - } - - THREAD_COUNT = atoi(argv[2]); - if( (THREAD_COUNT < 1) || (THREAD_COUNT > MAXIMUM_WAIT_OBJECTS) ) - { - printf("\nInvalid THREAD_COUNT number, Pass greater than 1 and less than %d\n", MAXIMUM_WAIT_OBJECTS); - return -1; - } - - REPEAT_COUNT = atoi(argv[3]); - if( REPEAT_COUNT < 1) - { - printf("\nInvalid REPEAT_COUNT number, Pass greater than 1\n"); - return -1; - } - - RELATION_ID = atoi(argv[4]); - if( RELATION_ID < 1) - { - printf("\nMain Process:Invalid RELATION_ID number, Pass greater than 1\n"); - return -1; - } - - if(argc == 6) - { - strncpy(objectSuffix, argv[5], MAX_PATH-1); - } - - return 0; -} - - int __cdecl main(INT argc, CHAR **argv) -{ - unsigned int i = 0; - HANDLE hThread[MAXIMUM_WAIT_OBJECTS]; - DWORD threadId[MAXIMUM_WAIT_OBJECTS]; - - WCHAR *wcObjName = NULL; - - char ObjName[MAX_PATH] = "SHARED_EVENT"; - DWORD dwParam = 0; - - int returnCode = 0; - - /* Variables to capture the file name and the file pointer at thread level*/ - char fileName[MAX_PATH]; - FILE *pFile = NULL; - struct statistics* buffer = NULL; - int statisticsSize = 0; - - /* Variables to capture the file name and the file pointer at process level*/ - char processFileName[MAX_PATH]; - FILE *pProcessFile = NULL; - struct ProcessStats processStats; - DWORD dwStartTime; - - testStatus = PASS; - - if(0 != (PAL_Initialize(argc, argv))) - { - return ( FAIL ); - } - - ZeroMemory( objectSuffix, MAX_PATH ); - - if(GetParameters(argc, argv)) - { - Fail("Error in obtaining the parameters\n"); - } -// Trace("Process created, value of process count is [%d]\n", USE_PROCESS_COUNT); - - if(argc == 5) - { - strncat(ObjName, objectSuffix, MAX_PATH - (sizeof(ObjName) + 1) ); - } - - /* Register the start time */ - dwStartTime = GetTickCount(); - processStats.relationId = RELATION_ID; - processStats.processId = USE_PROCESS_COUNT; - - _snprintf(processFileName, MAX_PATH, "%d_process_event_%d_.txt", USE_PROCESS_COUNT, RELATION_ID); - pProcessFile = fopen(processFileName, "w+"); - if(pProcessFile == NULL) - { - Fail("Error:%d: in opening Process File for write for process [%d]\n", GetLastError(), USE_PROCESS_COUNT); - } - - statisticsSize = sizeof(struct statistics); - - _snprintf(fileName, MAX_PATH, "%d_thread_event_%d_.txt", USE_PROCESS_COUNT, RELATION_ID); - pFile = fopen(fileName, "w+"); - - if(pFile == NULL) - { - Fail("Error:%d: in opening thread file for write for process [%d]\n", GetLastError(), USE_PROCESS_COUNT); - } - // For each thread we will log operations failed (int), passed (int), total (int) - // and number of ticks (DWORD) for the operations - resultBuffer = new ResultBuffer( THREAD_COUNT, statisticsSize); - - wcObjName = convert(ObjName); - - StartTestsEvHandle = CreateEvent( NULL, /* lpEventAttributes*/ - TRUE, /* bManualReset */ - FALSE, /* bInitialState */ - NULL); /* name of Event */ - - if( StartTestsEvHandle == NULL ) - { - Fail("Error:%d: Unexpected failure " - "to create %s Event for process count %d\n", GetLastError(), sTmpEventName, USE_PROCESS_COUNT ); - - } - - /* Create StartTest Event */ - - hEventHandle = OpenEventW( - EVENT_ALL_ACCESS, /* lpEventAttributes, inheritable to child processes*/ - FALSE, /* bAutomaticReset */ - wcObjName - ); - - if( hEventHandle == NULL) - { - Fail("Unable to create Event handle for process id [%d], returned error [%d]\n", i, GetLastError()); - } - /* We already assume that the Event was created previously*/ - - for( i = 0; i < THREAD_COUNT; i++ ) - { - dwParam = (int) i; - //Create thread - hThread[i] = CreateThread( - NULL, /* no security attributes */ - 0, /* use default stack size */ - (LPTHREAD_START_ROUTINE)Run_Thread,/* thread function */ - (LPVOID)dwParam, /* argument to thread function */ - 0, /* use default creation flags */ - &threadId[i] /* returns the thread identifier*/ - ); - - if(hThread[i] == NULL) - { - Fail("Create Thread failed for %d process, and GetLastError value is %d\n", USE_PROCESS_COUNT, GetLastError()); - } - - } - - if (!SetEvent(StartTestsEvHandle)) - { - Fail("Set Event for Start Tests failed for %d process, and GetLastError value is %d\n", USE_PROCESS_COUNT, GetLastError()); - } - - /* Test running */ - returnCode = WaitForMultipleObjects( THREAD_COUNT, hThread, TRUE, INFINITE); - - if( WAIT_OBJECT_0 != returnCode ) - { - Trace("Wait for Object(s) for %d process returned %d, and GetLastError value is %d\n", USE_PROCESS_COUNT, returnCode, GetLastError()); - testStatus = FAIL; - } - - processStats.operationTime = GetTimeDiff(dwStartTime); - - /* Write to a file*/ - if(pFile!= NULL) - { - for( i = 0; i < THREAD_COUNT; i++ ) - { - buffer = (struct statistics *)resultBuffer->getResultBuffer(i); - returnCode = fprintf(pFile, "%d,%d,%d,%d,%lu,%d\n", buffer->processId, buffer->operationsFailed, buffer->operationsPassed, buffer->operationsTotal, buffer->operationTime, buffer->relationId ); -// Trace("Iteration %d over\n", i); - - } - } - - if(fclose(pFile)) - { - Trace("Error: fclose failed for pFile at Process %d\n", USE_PROCESS_COUNT); - testStatus = FAIL; - } - - fprintf(pProcessFile, "%d,%d,%d\n", USE_PROCESS_COUNT, processStats.operationTime, processStats.relationId ); - if(fclose(pProcessFile)) - { - Trace("Error: fclose failed for pProcessFile at Process %d\n", USE_PROCESS_COUNT); - testStatus = FAIL; - } - /* Logging for the test case over, clean up the handles */ - -// Trace("Test Thread %d done\n", USE_PROCESS_COUNT); - - for( i = 0; i < THREAD_COUNT; i++ ) - { - if(!CloseHandle(hThread[i]) ) - { - Trace("Error:%d: CloseHandle failed for Process [%d] hThread[%d]\n", GetLastError(), USE_PROCESS_COUNT, i); - testStatus = FAIL; - } - } - - if(!CloseHandle(StartTestsEvHandle)) - { - Trace("Error:%d: CloseHandle failed for Process [%d] StartTestsEvHandle\n", GetLastError(), USE_PROCESS_COUNT); - testStatus = FAIL; - } - - if(!CloseHandle(hEventHandle)) - { - Trace("Error:%d: CloseHandle failed for Process [%d] hEventHandle\n", GetLastError(), USE_PROCESS_COUNT); - testStatus = FAIL; - } - - free(wcObjName); - PAL_Terminate(); - return testStatus; -} - -void PALAPI Run_Thread (LPVOID lpParam) -{ - unsigned int i = 0; - DWORD dwWaitResult; - - struct statistics stats; - DWORD dwStartTime; - - stats.relationId = RELATION_ID; - stats.processId = USE_PROCESS_COUNT; - stats.operationsFailed = 0; - stats.operationsPassed = 0; - stats.operationsTotal = 0; - stats.operationTime = 0; - - int Id=(int)lpParam; - - dwWaitResult = WaitForSingleObject( - StartTestsEvHandle, // handle to start test handle - TIMEOUT); - - if(dwWaitResult != WAIT_OBJECT_0) - { - Trace("Error:%d: while waiting for StartTest Event@ thread %d\n", GetLastError(), Id); - testStatus = FAIL; - } - - dwStartTime = GetTickCount(); - - for( i = 0; i < REPEAT_COUNT; i++ ) - { - dwWaitResult = WaitForSingleObject( - hEventHandle, // handle to Event - TIMEOUT); - - if(dwWaitResult != WAIT_OBJECT_0) - { - //Trace("Error:%d: while waiting for onject @ thread %d, # iter %d\n", GetLastError(), Id, i); - stats.operationsFailed += 1; - stats.operationsTotal += 1; - testStatus = FAIL; - continue; - } - - if (! SetEvent(hEventHandle)) - { - // Deal with error. -// Trace("Error while setting Event @ thread %d # iter %d\n", Id, i); - stats.operationsFailed += 1; - stats.operationsTotal += 1; - // do we need to have while true loop to attempt to set event...? - testStatus = FAIL; - continue; - } - - stats.operationsTotal += 1; - stats.operationsPassed += 1; - // Trace("Successs while setting Event @ iteration %d -> thread %d -> Process %d for handle %d\n", i, Id, USE_PROCESS_COUNT, hEventHandle); - - } - - stats.operationTime = GetTimeDiff(dwStartTime); - //Trace("OPeration time is %d", stats.operationTime ); - if(resultBuffer->LogResult(Id, (char *)&stats)) - { - Fail("Error:%d: while writing to shared memory, Thread Id is[%d] and Process id is [%d]\n", GetLastError(), Id, USE_PROCESS_COUNT); - } - //Trace("Thread %d over for process %d\n", Id, USE_PROCESS_COUNT); -} diff --git a/src/pal/tests/palsuite/composite/object_management/event/shared/main.cpp b/src/pal/tests/palsuite/composite/object_management/event/shared/main.cpp deleted file mode 100644 index c4a4067b5..000000000 --- a/src/pal/tests/palsuite/composite/object_management/event/shared/main.cpp +++ /dev/null @@ -1,265 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source Code: main.c and event.c -** main.c creates process and waits for all processes to get over -** event.c creates a event and then calls threads which will contend for the event -** -** This test is for Object Management Test case for event where Object type is shareable. -** Algorithm -** o Main Process Creates OBJECT_TYPE Object -** o Create PROCESS_COUNT processes aware of the Shared Object -** -** Author: ShamitP -** -** -**============================================================ -*/ -#include -#include "resulttime.h" - -/* Test Input Variables */ -unsigned int PROCESS_COUNT = 2; -unsigned int THREAD_COUNT = 20; -unsigned int REPEAT_COUNT = 200; -unsigned int RELATION_ID = 1001; - - -char objectSuffix[MAX_PATH_FNAME]; - -struct TestStats{ - DWORD operationTime; - unsigned int relationId; - unsigned int processCount; - unsigned int threadCount; - unsigned int repeatCount; - char* buildNumber; - -}; - -int GetParameters( int argc, char **argv) -{ - if( (!((argc == 5) || (argc == 6) ) )|| ((argc == 1) && !strcmp(argv[1],"/?")) - || !strcmp(argv[1],"/h") || !strcmp(argv[1],"/H")) - { - printf("PAL -Composite Object Management event Test\n"); - printf("Usage:\n"); - printf("main\n\t[PROCESS_COUNT (greater than 1)] \n"); - printf("\t[THREAD_COUNT (greater than 1)] \n"); - printf("\t[REPEAT_COUNT (greater than 1)]\n"); - printf("\t[RELATION_ID [greater than or equal to 1]\n"); - printf("\t[Object Name Suffix]\n"); - return -1; - } - - PROCESS_COUNT = atoi(argv[1]); - if( (PROCESS_COUNT < 1) || (PROCESS_COUNT > MAXIMUM_WAIT_OBJECTS) ) - { - printf("\nMain Process:Invalid PROCESS_COUNT number, Pass greater than 1 and less than PROCESS_COUNT %d\n", MAXIMUM_WAIT_OBJECTS); - return -1; - } - - THREAD_COUNT = atoi(argv[2]); - if( (THREAD_COUNT < 1) || (THREAD_COUNT > MAXIMUM_WAIT_OBJECTS) ) - { - printf("\nInvalid THREAD_COUNT number, Pass greater than 1 and less than %d\n", MAXIMUM_WAIT_OBJECTS); - return -1; - } - - REPEAT_COUNT = atoi(argv[3]); - if( REPEAT_COUNT < 1) - { - printf("\nMain Process:Invalid REPEAT_COUNT number, Pass greater than 1\n"); - return -1; - } - - RELATION_ID = atoi(argv[4]); - if( RELATION_ID < 1) - { - printf("\nMain Process:Invalid RELATION_ID number, Pass greater than 1\n"); - return -1; - } - - - if(argc == 6) - { - strncpy(objectSuffix, argv[5], MAX_PATH_FNAME-1); - } - - return 0; -} - - int __cdecl main(INT argc, CHAR **argv) -{ - unsigned int i = 0; - HANDLE hProcess[MAXIMUM_WAIT_OBJECTS]; - HANDLE hEventHandle; - - STARTUPINFO si[MAXIMUM_WAIT_OBJECTS]; - PROCESS_INFORMATION pi[MAXIMUM_WAIT_OBJECTS]; - - char lpCommandLine[MAX_LONGPATH] = ""; - char ObjName[MAX_PATH_FNAME] = "SHARED_EVENT"; - - int returnCode = 0; - DWORD processReturnCode = 0; - int testReturnCode = PASS; - - char fileName[MAX_PATH_FNAME]; - FILE *pFile = NULL; - DWORD dwStartTime; - struct TestStats testStats; - - if(0 != (PAL_Initialize(argc, argv))) - { - return ( FAIL ); - } - - ZeroMemory( objectSuffix, MAX_PATH_FNAME ); - - if(GetParameters(argc, argv)) - { - Fail("Error in obtaining the parameters\n"); - } - - if(argc == 5) - { - strncat(ObjName, objectSuffix, MAX_PATH_FNAME - (sizeof(ObjName) + 1) ); - } - - /* Register the start time */ - dwStartTime = GetTickCount(); - testStats.relationId = RELATION_ID; - testStats.processCount = PROCESS_COUNT; - testStats.threadCount = THREAD_COUNT; - testStats.repeatCount = REPEAT_COUNT; - testStats.buildNumber = getBuildNumber(); - - - _snprintf(fileName, MAX_PATH_FNAME, "main_event_%d_.txt", RELATION_ID); - pFile = fopen(fileName, "w+"); - if(pFile == NULL) - { - Fail("Error in opening main file for write\n"); - } - - hEventHandle = CreateEvent( - NULL, /* lpEventAttributes, inheritable to child processes*/ - TRUE, /* bAutomaticReset */ - TRUE, /* bInitialState */ - ObjName - ); - - if( hEventHandle == NULL) - { - Fail("Unable to create Event handle, returned error [%d]\n", GetLastError()); - } - - for( i = 0; i < PROCESS_COUNT; i++ ) - { - - ZeroMemory( lpCommandLine, MAX_PATH_FNAME ); - if ( _snprintf( lpCommandLine, MAX_PATH_FNAME-1, "event %d %d %d %d %s", i, THREAD_COUNT, REPEAT_COUNT, RELATION_ID, objectSuffix) < 0 ) - { - Fail ("Error: Insufficient Event name string length for %s for iteration [%d]\n", ObjName, i); - } - - /* Zero the data structure space */ - ZeroMemory ( &pi[i], sizeof(pi[i]) ); - ZeroMemory ( &si[i], sizeof(si[i]) ); - - /* Set the process flags and standard io handles */ - si[i].cb = sizeof(si[i]); - - if(!CreateProcess( NULL, /* lpApplicationName*/ - lpCommandLine, /* lpCommandLine */ - NULL, /* lpProcessAttributes */ - NULL, /* lpThreadAttributes */ - TRUE, /* bInheritHandles */ - 0, /* dwCreationFlags, */ - NULL, /* lpEnvironment */ - NULL, /* pCurrentDirectory */ - &si[i], /* lpStartupInfo */ - &pi[i] /* lpProcessInformation */ - )) - { - Fail("Process Not created for [%d], the error code is [%d]\n", i, GetLastError()); - } - else - { - hProcess[i] = pi[i].hProcess; -// Trace("Process created for [%d]\n", i); - - } - - //Create Process - - } - - returnCode = WaitForMultipleObjects( PROCESS_COUNT, hProcess, TRUE, INFINITE); - if( WAIT_OBJECT_0 != returnCode ) - { - Trace("Wait for Object(s) @ Main thread for %d processes returned %d, and GetLastError value is %d\n", PROCESS_COUNT, returnCode, GetLastError()); - testReturnCode = FAIL; - } - -// Trace("Test over\n"); - for( i = 0; i < PROCESS_COUNT; i++ ) - { - /* check the exit code from the process */ - if( ! GetExitCodeProcess( pi[i].hProcess, &processReturnCode ) ) - { - Trace( "GetExitCodeProcess call failed for iteration %d with error code %u\n", - i, GetLastError() ); - - testReturnCode = FAIL; - } - - if(processReturnCode == FAIL) - { - Trace( "Process [%d] failed and returned FAIL\n", i); - testReturnCode = FAIL; - } - - if(!CloseHandle(pi[i].hThread)) - { - Trace("Error:%d: CloseHandle failed for Process [%d] hThread\n", GetLastError(), i); - testReturnCode = FAIL; - } - - if(!CloseHandle(pi[i].hProcess) ) - { - Trace("Error:%d: CloseHandle failed for Process [%d] hProcess\n", GetLastError(), i); - testReturnCode = FAIL; - } - } - - testStats.operationTime = GetTimeDiff(dwStartTime); - fprintf(pFile, "%d,%d,%d,%d,%d,%s\n", testStats.operationTime, testStats.relationId, testStats.processCount, testStats.threadCount, testStats.repeatCount, testStats.buildNumber); - if(fclose(pFile)) - { - Trace("Error: fclose failed for pFile\n"); - testReturnCode = FAIL; - } - - if(!CloseHandle(hEventHandle)) - { - Trace("Error:%d: CloseHandle failed for hEventHandle\n", GetLastError()); - testReturnCode = FAIL; - } - - if( testReturnCode == PASS) - { - Trace("Test Passed\n"); - } - else - { - Trace("Test Failed\n"); - } - - PAL_Terminate(); - return testReturnCode; -} diff --git a/src/pal/tests/palsuite/composite/object_management/mutex/CMakeLists.txt b/src/pal/tests/palsuite/composite/object_management/mutex/CMakeLists.txt deleted file mode 100644 index 2534564f9..000000000 --- a/src/pal/tests/palsuite/composite/object_management/mutex/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(nonshared) -add_subdirectory(shared) - diff --git a/src/pal/tests/palsuite/composite/object_management/mutex/nonshared/CMakeLists.txt b/src/pal/tests/palsuite/composite/object_management/mutex/nonshared/CMakeLists.txt deleted file mode 100644 index 8ddce815d..000000000 --- a/src/pal/tests/palsuite/composite/object_management/mutex/nonshared/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - main.cpp - mutex.cpp -) - -add_executable(paltest_mutex_nonshared - ${SOURCES} -) - -add_dependencies(paltest_mutex_nonshared coreclrpal) - -target_link_libraries(paltest_mutex_nonshared - ${COMMON_TEST_LIBRARIES} - rt -) diff --git a/src/pal/tests/palsuite/composite/object_management/mutex/nonshared/main.cpp b/src/pal/tests/palsuite/composite/object_management/mutex/nonshared/main.cpp deleted file mode 100644 index 80f31aad6..000000000 --- a/src/pal/tests/palsuite/composite/object_management/mutex/nonshared/main.cpp +++ /dev/null @@ -1,230 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source Code: main.c and mutex.c -** main.c creates process and waits for all processes to get over -** mutex.c creates a mutex and then calls threads which will contend for the mutex -** -** This test is for Object Management Test case for Mutex where Object type is not shareable. -** Algorithm -** o Create PROCESS_COUNT processes. -** o Main Thread of each process creates OBJECT_TYPE Object -** -** Author: ShamitP -**============================================================ -*/ - -#include -#include "resulttime.h" - -/* Test Input Variables */ -unsigned int PROCESS_COUNT = 2; -unsigned int THREAD_COUNT = 20; -unsigned int REPEAT_COUNT = 4000; -unsigned int RELATION_ID = 1001; - - -struct TestStats{ - DWORD operationTime; - unsigned int relationId; - unsigned int processCount; - unsigned int threadCount; - unsigned int repeatCount; - char* buildNumber; - -}; - -int GetParameters( int argc, char **argv) -{ - if( (argc != 5) || ((argc == 1) && !strcmp(argv[1],"/?")) - || !strcmp(argv[1],"/h") || !strcmp(argv[1],"/H")) - { - printf("PAL -Composite Object Management Mutex Test\n"); - printf("Usage:\n"); - printf("main\n\t[PROCESS_COUNT [greater than 1] \n"); - printf("\t[THREAD_COUNT [greater than 1] \n"); - printf("\t[REPEAT_COUNT [greater than 1]\n"); - printf("\t[RELATION_ID [greater than 1]\n"); - - - return -1; - } - - PROCESS_COUNT = atoi(argv[1]); - if( (PROCESS_COUNT < 1) || (PROCESS_COUNT > MAXIMUM_WAIT_OBJECTS) ) - { - printf("\nMain Process:Invalid PROCESS_COUNT number, Pass greater than 1 and less than PROCESS_COUNT %d\n", MAXIMUM_WAIT_OBJECTS); - return -1; - } - - THREAD_COUNT = atoi(argv[2]); - if( (THREAD_COUNT < 1) || (THREAD_COUNT > MAXIMUM_WAIT_OBJECTS) ) - { - printf("\nInvalid THREAD_COUNT number, Pass greater than 1 and less than %d\n", MAXIMUM_WAIT_OBJECTS); - return -1; - } - - REPEAT_COUNT = atoi(argv[3]); - if( REPEAT_COUNT < 1) - { - printf("\nMain Process:Invalid REPEAT_COUNT number, Pass greater than 1\n"); - return -1; - } - - RELATION_ID = atoi(argv[4]); - if( RELATION_ID < 1) - { - printf("\nMain Process:Invalid RELATION_ID number, Pass greater than 1\n"); - return -1; - } - - return 0; -} - - int __cdecl main(INT argc, CHAR **argv) -{ - unsigned int i = 0; - HANDLE hProcess[MAXIMUM_WAIT_OBJECTS]; - HANDLE hMutexHandle[MAXIMUM_WAIT_OBJECTS]; - - STARTUPINFO si[MAXIMUM_WAIT_OBJECTS]; - PROCESS_INFORMATION pi[MAXIMUM_WAIT_OBJECTS]; - - const char *ObjName = "Mutex"; - char lpCommandLine[MAX_PATH] = ""; - - int returnCode = 0; - DWORD processReturnCode = 0; - int testReturnCode = PASS; - - char fileName[MAX_PATH]; - FILE *pFile = NULL; - DWORD dwStartTime; - struct TestStats testStats; - - if(0 != (PAL_Initialize(argc, argv))) - { - return ( FAIL ); - } - - if(GetParameters(argc, argv)) - { - Fail("Error in obtaining the parameters\n"); - } - - /* Register the start time */ - dwStartTime = GetTickCount(); - testStats.relationId = RELATION_ID; - testStats.processCount = PROCESS_COUNT; - testStats.threadCount = THREAD_COUNT; - testStats.repeatCount = REPEAT_COUNT; - testStats.buildNumber = getBuildNumber(); - - - _snprintf(fileName, MAX_PATH, "main_mutex_%d_.txt", RELATION_ID); - pFile = fopen(fileName, "w+"); - if(pFile == NULL) - { - Fail("Error in opening main file for write\n"); - } - - for( i = 0; i < PROCESS_COUNT; i++ ) - { - ZeroMemory( lpCommandLine, MAX_PATH ); - if ( _snprintf( lpCommandLine, MAX_PATH-1, "mutex %d %d %d %d", i, THREAD_COUNT, REPEAT_COUNT, RELATION_ID) < 0 ) - { - Fail("Error Insufficient mutex name string length for %s for iteration [%d]\n", ObjName, i); - } - - /* Zero the data structure space */ - ZeroMemory ( &pi[i], sizeof(pi[i]) ); - ZeroMemory ( &si[i], sizeof(si[i]) ); - - /* Set the process flags and standard io handles */ - si[i].cb = sizeof(si[i]); - - if(!CreateProcess( NULL, /* lpApplicationName*/ - lpCommandLine, /* lpCommandLine */ - NULL, /* lpProcessAttributes */ - NULL, /* lpThreadAttributes */ - TRUE, /* bInheritHandles */ - 0, /* dwCreationFlags, */ - NULL, /* lpEnvironment */ - NULL, /* pCurrentDirectory */ - &si[i], /* lpStartupInfo */ - &pi[i] /* lpProcessInformation */ - )) - { - Fail("Process Not created for [%d], the error code is [%d]\n", i, GetLastError()); - } - else - { - hProcess[i] = pi[i].hProcess; -// Trace("Process created for [%d]\n", i); - - } - - //Create Process - - } - - returnCode = WaitForMultipleObjects( PROCESS_COUNT, hProcess, TRUE, INFINITE); - if( WAIT_OBJECT_0 != returnCode ) - { - Trace("Wait for Object(s) @ Main thread for %d processes returned %d, and GetLastError value is %d\n", PROCESS_COUNT, returnCode, GetLastError()); - testReturnCode = FAIL; - } - - for( i = 0; i < PROCESS_COUNT; i++ ) - { - /* check the exit code from the process */ - if( ! GetExitCodeProcess( pi[i].hProcess, &processReturnCode ) ) - { - Trace( "GetExitCodeProcess call failed for iteration %d with error code %u\n", - i, GetLastError() ); - - testReturnCode = FAIL; - } - - if(processReturnCode == FAIL) - { - Trace( "Process [%d] failed and returned FAIL\n", i); - testReturnCode = FAIL; - } - - if(!CloseHandle(pi[i].hThread)) - { - Trace("Error:%d: CloseHandle failed for Process [%d] hThread\n", GetLastError(), i); - testReturnCode = FAIL; - } - - if(!CloseHandle(pi[i].hProcess) ) - { - Trace("Error:%d: CloseHandle failed for Process [%d] hProcess\n", GetLastError(), i); - testReturnCode = FAIL; - } - } - - testStats.operationTime = GetTimeDiff(dwStartTime); - fprintf(pFile, "%d,%d,%d,%d,%d,%s\n", testStats.operationTime, testStats.relationId, testStats.processCount, testStats.threadCount, testStats.repeatCount, testStats.buildNumber); - if(fclose(pFile)) - { - Trace("Error: fclose failed for pFile\n"); - testReturnCode = FAIL; - } - - if( testReturnCode == PASS) - { - Trace("Test Passed\n"); - } - else - { - Trace("Test Failed\n"); - } - - PAL_Terminate(); - return testReturnCode; -} diff --git a/src/pal/tests/palsuite/composite/object_management/mutex/nonshared/mutex.cpp b/src/pal/tests/palsuite/composite/object_management/mutex/nonshared/mutex.cpp deleted file mode 100644 index 7f1f659f9..000000000 --- a/src/pal/tests/palsuite/composite/object_management/mutex/nonshared/mutex.cpp +++ /dev/null @@ -1,340 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source Code: main.c and mutex.c -** main.c creates process and waits for all processes to get over -** mutex.c creates a mutex and then calls threads which will contend for the mutex -** -** This test is for Object Management Test case for Mutex where Object type is not shareable. -** Algorithm -** o Create PROCESS_COUNT processes. -** o Main Thread of each process creates OBJECT_TYPE Object -** -** Author: ShamitP -**============================================================ -*/ - -#include -#include "resultbuffer.h" -#include "resulttime.h" - -#define TIMEOUT 5000 -/* Test Input Variables */ -unsigned int USE_PROCESS_COUNT = 0; -unsigned int THREAD_COUNT = 0; -unsigned int REPEAT_COUNT = 0; -unsigned int RELATION_ID = 1001; - -/* Capture statistics at per thread basis */ -struct statistics{ - unsigned int processId; - unsigned int operationsFailed; - unsigned int operationsPassed; - unsigned int operationsTotal; - DWORD operationTime; - unsigned int relationId; -}; - -struct ProcessStats{ - unsigned int processId; - DWORD operationTime; - unsigned int relationId; -}; - -HANDLE StartTestsEvHandle = NULL; -HANDLE hMutexHandle = NULL; - -/* Results Buffer */ -ResultBuffer *resultBuffer = NULL; - -int testStatus; - -void PALAPI Run_Thread(LPVOID lpParam); - -int GetParameters( int argc, char **argv) -{ - if( (argc != 5) || ((argc == 1) && !strcmp(argv[1],"/?")) - || !strcmp(argv[1],"/h") || !strcmp(argv[1],"/H")) - { - printf("PAL -Composite Object Management Mutex Test\n"); - printf("Usage:\n"); - printf("mutex\n\t[USE_PROCESS_COUNT ( greater than 1] \n"); - printf("\t[THREAD_COUNT ( greater than 1] \n"); - printf("\t[REPEAT_COUNT ( greater than 1]\n"); - printf("\t[RELATION_ID [greater than 1]\n"); - return -1; - } - - // Trace("Args 1 is [%s], Arg 2 is [%s], Arg 3 is [%s]\n", argv[1], argv[2], argv[3]); - - USE_PROCESS_COUNT = atoi(argv[1]); - if( USE_PROCESS_COUNT < 0) - { - printf("\nInvalid USE_PROCESS_COUNT number, Pass greater than 1\n"); - return -1; - } - - THREAD_COUNT = atoi(argv[2]); - if( (THREAD_COUNT < 1) || (THREAD_COUNT > MAXIMUM_WAIT_OBJECTS) ) - { - printf("\nInvalid THREAD_COUNT number, Pass greater than 1 and less than %d\n", MAXIMUM_WAIT_OBJECTS); - return -1; - } - - REPEAT_COUNT = atoi(argv[3]); - if( REPEAT_COUNT < 1) - { - printf("\nInvalid REPEAT_COUNT number, Pass greater than 1\n"); - return -1; - } - - RELATION_ID = atoi(argv[4]); - if( RELATION_ID < 1) - { - printf("\nMain Process:Invalid RELATION_ID number, Pass greater than 1\n"); - return -1; - } - - return 0; -} - - int __cdecl main(INT argc, CHAR **argv) -{ - unsigned int i = 0; - HANDLE hThread[MAXIMUM_WAIT_OBJECTS]; - DWORD threadId[MAXIMUM_WAIT_OBJECTS]; - - const char sTmpEventName[MAX_PATH] = "StartTestEvent"; - - DWORD dwParam = 0; - - int returnCode = 0; - - /* Variables to capture the file name and the file pointer at thread level*/ - char fileName[MAX_PATH]; - FILE *pFile = NULL; - struct statistics* buffer = NULL; - int statisticsSize = 0; - - /* Variables to capture the file name and the file pointer at process level*/ - char processFileName[MAX_PATH]; - FILE *pProcessFile = NULL; - struct ProcessStats processStats; - DWORD dwStartTime; - - testStatus = PASS; - - if(0 != (PAL_Initialize(argc, argv))) - { - return ( FAIL ); - } - - if(GetParameters(argc, argv)) - { - Fail("Error in obtaining the parameters\n"); - } -// Trace("Process created, value of process count is [%d]\n", USE_PROCESS_COUNT); - - /* Register the start time */ - dwStartTime = GetTickCount(); - processStats.relationId = RELATION_ID; - processStats.processId = USE_PROCESS_COUNT; - - _snprintf(processFileName, MAX_PATH, "%d_process_mutex_%d_.txt", USE_PROCESS_COUNT,RELATION_ID); - pProcessFile = fopen(processFileName, "w+"); - if(pProcessFile == NULL) - { - Fail("Error in opening process File file for write for process [%d]\n", USE_PROCESS_COUNT); - } - - statisticsSize = sizeof(struct statistics); - - _snprintf(fileName, MAX_PATH, "%d_thread_mutex_%d_.txt", USE_PROCESS_COUNT, RELATION_ID); - pFile = fopen(fileName, "w+"); - if(pFile == NULL) - { - Fail("Error in opening file for write for process [%d]\n", USE_PROCESS_COUNT); - } - // For each thread we will log operations failed (int), passed (int), total (int) - // and number of ticks (DWORD) for the operations - resultBuffer = new ResultBuffer( THREAD_COUNT, statisticsSize); - - StartTestsEvHandle = CreateEvent( NULL, /* lpEventAttributes*/ - TRUE, /* bManualReset */ - FALSE, /* bInitialState */ - NULL - ); /* name of Event */ - - if( StartTestsEvHandle == NULL ) - { - Fail("Error:%d: Unexpected failure " - "to create %s Event for process count %d\n", GetLastError(), sTmpEventName, USE_PROCESS_COUNT ); - - } - - /* Create StartTest Event */ - - hMutexHandle = CreateMutex( - NULL, - FALSE, /* bInitialOwner, owns initially */ - NULL - ); - - if( hMutexHandle == NULL) - { - Fail("Unable to create Mutex handle for process id [%d], returned error [%d]\n", i, GetLastError()); - } - /* We already assume that the mutex was created previously*/ - - for( i = 0; i < THREAD_COUNT; i++ ) - { - dwParam = (int) i; - //Create thread - hThread[i] = CreateThread( - NULL, /* no security attributes */ - 0, /* use default stack size */ - (LPTHREAD_START_ROUTINE)Run_Thread,/* thread function */ - (LPVOID)dwParam, /* argument to thread function */ - 0, /* use default creation flags */ - &threadId[i] /* returns the thread identifier*/ - ); - - if(hThread[i] == NULL) - { - Fail("Create Thread failed for %d process, and GetLastError value is %d\n", USE_PROCESS_COUNT, GetLastError()); - } - - } - - if (!SetEvent(StartTestsEvHandle)) - { - Fail("Set Event for Start Tests failed for %d process, and GetLastError value is %d\n", USE_PROCESS_COUNT, GetLastError()); - } - - /* Test running */ - returnCode = WaitForMultipleObjects( THREAD_COUNT, hThread, TRUE, INFINITE); - - if( WAIT_OBJECT_0 != returnCode ) - { - Trace("Wait for Object(s) for %d process returned %d, and GetLastError value is %d\n", USE_PROCESS_COUNT, returnCode, GetLastError()); - testStatus = FAIL; - } - - processStats.operationTime = GetTimeDiff(dwStartTime); - - /* Write to a file*/ - if(pFile!= NULL) - { - for( i = 0; i < THREAD_COUNT; i++ ) - { - buffer = (struct statistics *)resultBuffer->getResultBuffer(i); - returnCode = fprintf(pFile, "%d,%d,%d,%d,%lu,%d\n", buffer->processId, buffer->operationsFailed, buffer->operationsPassed, buffer->operationsTotal, buffer->operationTime, buffer->relationId ); -// Trace("Iteration %d over\n", i); - - } - } - fclose(pFile); - - fprintf(pProcessFile, "%d,%d,%d\n", USE_PROCESS_COUNT, processStats.operationTime, processStats.relationId ); - fclose(pProcessFile); - - /* Logging for the test case over, clean up the handles */ - -// Trace("Test Thread %d done\n", USE_PROCESS_COUNT); - - - for( i = 0; i < THREAD_COUNT; i++ ) - { - if(!CloseHandle(hThread[i]) ) - { - Trace("Error:%d: CloseHandle failed for Process [%d] hThread[%d]\n", GetLastError(), USE_PROCESS_COUNT, i); - testStatus = FAIL; - } - } - - if(!CloseHandle(StartTestsEvHandle)) - { - Trace("Error:%d: CloseHandle failed for Process [%d] StartTestsEvHandle\n", GetLastError(), USE_PROCESS_COUNT); - testStatus = FAIL; - } - - if(!CloseHandle(hMutexHandle)) - { - Trace("Error:%d: CloseHandle failed for Process [%d] hMutexHandle\n", GetLastError(), USE_PROCESS_COUNT); - testStatus = FAIL; - } - - PAL_Terminate(); - return testStatus; -} - -void PALAPI Run_Thread (LPVOID lpParam) -{ - unsigned int i = 0; - DWORD dwWaitResult; - - struct statistics stats; - DWORD dwStartTime; - - stats.relationId = RELATION_ID; - stats.processId = USE_PROCESS_COUNT; - stats.operationsFailed = 0; - stats.operationsPassed = 0; - stats.operationsTotal = 0; - stats.operationTime = 0; - - int Id=(int)lpParam; - - dwWaitResult = WaitForSingleObject( - StartTestsEvHandle, // handle to mutex - TIMEOUT); - - if(dwWaitResult != WAIT_OBJECT_0) - { - Trace("Error while waiting for StartTest Event@ thread %d\n", Id); - testStatus = FAIL; - } - - dwStartTime = GetTickCount(); - - for( i = 0; i < REPEAT_COUNT; i++ ) - { - dwWaitResult = WaitForSingleObject( - hMutexHandle, // handle to mutex - TIMEOUT); - - if(dwWaitResult != WAIT_OBJECT_0) - { -// Trace("Error while waiting for onject @ thread %d, # iter %d\n", Id, i); - stats.operationsFailed += 1; - stats.operationsTotal += 1; - testStatus = FAIL; - continue; - } - if (! ReleaseMutex(hMutexHandle)) - { - // Deal with error. -// Trace("Error while releasing mutex @ thread %d # iter %d\n", Id, i); - stats.operationsFailed += 1; - stats.operationsTotal += 1; - // Probably need to have while true loop to attempt to release mutex... - testStatus = FAIL; - continue; - } - - stats.operationsTotal += 1; - stats.operationsPassed += 1; - // Trace("Successs while releasing mutex @ iteration %d -> thread %d -> Process %d\n", i, Id, USE_PROCESS_COUNT); - - } - - stats.operationTime = GetTimeDiff(dwStartTime); - //Trace("OPeration time is %d", stats.operationTime ); - if(resultBuffer->LogResult(Id, (char *)&stats)) - { - Fail("Error:%d: while writing to shared memory, Thread Id is[%d] and Process id is [%d]\n", GetLastError(), Id, USE_PROCESS_COUNT); - } -} diff --git a/src/pal/tests/palsuite/composite/object_management/mutex/shared/CMakeLists.txt b/src/pal/tests/palsuite/composite/object_management/mutex/shared/CMakeLists.txt deleted file mode 100644 index 0436f263f..000000000 --- a/src/pal/tests/palsuite/composite/object_management/mutex/shared/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - main.cpp - mutex.cpp -) - -add_executable(paltest_mutex_shared - ${SOURCES} -) - -add_dependencies(paltest_mutex_shared coreclrpal) - -target_link_libraries(paltest_mutex_shared - ${COMMON_TEST_LIBRARIES} - rt -) diff --git a/src/pal/tests/palsuite/composite/object_management/mutex/shared/main.cpp b/src/pal/tests/palsuite/composite/object_management/mutex/shared/main.cpp deleted file mode 100644 index aa9885556..000000000 --- a/src/pal/tests/palsuite/composite/object_management/mutex/shared/main.cpp +++ /dev/null @@ -1,265 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** This test is for Object Management Test case for Mutex where Object type is shareable. -** -** Source Code: main.c and mutex.c -** main.c creates a mutex, creates processes and waits for all processes to get over -** mutex.c create threads which will contend for the mutex -** -** This test is for Object Management Test case for Mutex where Object type is not shareable. -** Algorithm -** o Main Process Creates OBJECT_TYPE Object -** o Create PROCESS_COUNT processes aware of the Shared Object -** -** Author: ShamitP -** -** -**============================================================ -*/ - -#include -#include "resulttime.h" - -/* Test Input Variables */ -unsigned int PROCESS_COUNT = 2; -unsigned int THREAD_COUNT = 2; -unsigned int REPEAT_COUNT = 40000; -unsigned int RELATION_ID = 1001; - - -char objectSuffix[MAX_PATH]; - -struct TestStats{ - DWORD operationTime; - unsigned int relationId; - unsigned int processCount; - unsigned int threadCount; - unsigned int repeatCount; - char* buildNumber; - -}; - -int GetParameters( int argc, char **argv) -{ - if( (!((argc == 5) || (argc == 6) ) )|| ((argc == 1) && !strcmp(argv[1],"/?")) - || !strcmp(argv[1],"/h") || !strcmp(argv[1],"/H")) - { - printf("PAL -Composite Object Management event Test\n"); - printf("Usage:\n"); - printf("main\n\t[PROCESS_COUNT (greater than 1)] \n"); - printf("\t[THREAD_COUNT (greater than 1)] \n"); - printf("\t[REPEAT_COUNT (greater than 1)]\n"); - printf("\t[RELATION_ID [greater than 1]\n"); - printf("\t[Object Name Suffix]\n"); - return -1; - } - - PROCESS_COUNT = atoi(argv[1]); - if( (PROCESS_COUNT < 1) || (PROCESS_COUNT > MAXIMUM_WAIT_OBJECTS) ) - { - printf("\nMain Process:Invalid PROCESS_COUNT number, Pass greater than 1 and less than PROCESS_COUNT %d\n", MAXIMUM_WAIT_OBJECTS); - return -1; - } - - THREAD_COUNT = atoi(argv[2]); - if( (THREAD_COUNT < 1) || (THREAD_COUNT > MAXIMUM_WAIT_OBJECTS) ) - { - printf("\nInvalid THREAD_COUNT number, Pass greater than 1 and less than %d\n", MAXIMUM_WAIT_OBJECTS); - return -1; - } - - REPEAT_COUNT = atoi(argv[3]); - if( REPEAT_COUNT < 1) - { - printf("\nMain Process:Invalid REPEAT_COUNT number, Pass greater than 1\n"); - return -1; - } - - RELATION_ID = atoi(argv[4]); - if( RELATION_ID < 1) - { - printf("\nMain Process:Invalid RELATION_ID number, Pass greater than 1\n"); - return -1; - } - - if(argc == 6) - { - strncpy(objectSuffix, argv[5], MAX_PATH-1); - } - - return 0; -} - - int __cdecl main(INT argc, CHAR **argv) -{ - unsigned int i = 0; - HANDLE hProcess[MAXIMUM_WAIT_OBJECTS]; - HANDLE hMutexHandle; - - STARTUPINFO si[MAXIMUM_WAIT_OBJECTS]; - PROCESS_INFORMATION pi[MAXIMUM_WAIT_OBJECTS]; - - char ObjName[MAX_PATH] = "SHARED_MUTEX"; - char lpCommandLine[MAX_PATH] = ""; - - int returnCode = 0; - DWORD processReturnCode = 0; - int testReturnCode = PASS; - - char fileName[MAX_PATH]; - FILE *pFile = NULL; - DWORD dwStartTime; - struct TestStats testStats; - - if(0 != (PAL_Initialize(argc, argv))) - { - return ( FAIL ); - } - - ZeroMemory( objectSuffix, MAX_PATH ); - - if(GetParameters(argc, argv)) - { - Fail("Error in obtaining the parameters\n"); - } - - if(argc == 5) - { - strncat(ObjName, objectSuffix, MAX_PATH - (sizeof(ObjName) + 1) ); - } - - /* Register the start time */ - dwStartTime = GetTickCount(); - testStats.relationId = RELATION_ID; - testStats.processCount = PROCESS_COUNT; - testStats.threadCount = THREAD_COUNT; - testStats.repeatCount = REPEAT_COUNT; - testStats.buildNumber = getBuildNumber(); - - - _snprintf(fileName, MAX_PATH, "main_mutex_%d_.txt", RELATION_ID); - pFile = fopen(fileName, "w+"); - if(pFile == NULL) - { - Fail("Error in opening main file for write\n"); - } - - hMutexHandle = CreateMutex( - NULL, - FALSE, /* bInitialOwner, owns initially */ - ObjName - ); - - if( hMutexHandle == NULL) - { - Fail("Unable to create Mutex handle for Main thread returned error [%d]\n", GetLastError()); - } - - for( i = 0; i < PROCESS_COUNT; i++ ) - { - ZeroMemory( lpCommandLine, MAX_PATH ); - if ( _snprintf( lpCommandLine, MAX_PATH-1, "mutex %d %d %d %d %s", i, THREAD_COUNT, REPEAT_COUNT, RELATION_ID, objectSuffix) < 0 ) - { - Fail ("Error Insufficient mutex name string length for %s for iteration [%d]\n", ObjName, i); - } - - - /* Zero the data structure space */ - ZeroMemory ( &pi[i], sizeof(pi[i]) ); - ZeroMemory ( &si[i], sizeof(si[i]) ); - - /* Set the process flags and standard io handles */ - si[i].cb = sizeof(si[i]); - - //Create Process - if(!CreateProcess( NULL, /* lpApplicationName*/ - lpCommandLine, /* lpCommandLine */ - NULL, /* lpProcessAttributes */ - NULL, /* lpThreadAttributes */ - TRUE, /* bInheritHandles */ - 0, /* dwCreationFlags, */ - NULL, /* lpEnvironment */ - NULL, /* pCurrentDirectory */ - &si[i], /* lpStartupInfo */ - &pi[i] /* lpProcessInformation */ - )) - { - Fail("Process Not created for [%d], the error code is [%d]\n", i, GetLastError()); - } - else - { - hProcess[i] = pi[i].hProcess; -// Trace("Process created for [%d]\n", i); - - } - } - - returnCode = WaitForMultipleObjects( PROCESS_COUNT, hProcess, TRUE, INFINITE); - if( WAIT_OBJECT_0 != returnCode ) - { - Trace("Wait for Object(s) @ Main thread for %d processes returned %d, and GetLastError value is %d\n", PROCESS_COUNT, returnCode, GetLastError()); - testReturnCode = FAIL; - } - - for( i = 0; i < PROCESS_COUNT; i++ ) - { - /* check the exit code from the process */ - if( ! GetExitCodeProcess( pi[i].hProcess, &processReturnCode ) ) - { - Trace( "GetExitCodeProcess call failed for iteration %d with error code %u\n", - i, GetLastError() ); - - testReturnCode = FAIL; - } - - if(processReturnCode == FAIL) - { - Trace( "Process [%d] failed and returned FAIL\n", i); - testReturnCode = FAIL; - } - - if(!CloseHandle(pi[i].hThread)) - { - Trace("Error:%d: CloseHandle failed for Process [%d] hThread\n", GetLastError(), i); - testReturnCode = FAIL; - } - - if(!CloseHandle(pi[i].hProcess) ) - { - Trace("Error:%d: CloseHandle failed for Process [%d] hProcess\n", GetLastError(), i); - testReturnCode = FAIL; - } - } - - testStats.operationTime = GetTimeDiff(dwStartTime); - fprintf(pFile, "%d,%d,%d,%d,%d,%s\n", testStats.operationTime, testStats.relationId, testStats.processCount, testStats.threadCount, testStats.repeatCount, testStats.buildNumber ); - if(fclose(pFile)) - { - Trace("Error: fclose failed for pFile\n"); - testReturnCode = FAIL; - } - - if(!CloseHandle(hMutexHandle)) - { - Trace("Error:%d: CloseHandle failed for hMutexHandle\n", GetLastError()); - testReturnCode = FAIL; - - } - - if( testReturnCode == PASS) - { - Trace("Test Passed\n"); - } - else - { - Trace("Test Failed\n"); - } - - PAL_Terminate(); - return testReturnCode; -} - diff --git a/src/pal/tests/palsuite/composite/object_management/mutex/shared/mutex.cpp b/src/pal/tests/palsuite/composite/object_management/mutex/shared/mutex.cpp deleted file mode 100644 index ec5d9b37a..000000000 --- a/src/pal/tests/palsuite/composite/object_management/mutex/shared/mutex.cpp +++ /dev/null @@ -1,354 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** This test is for Object Management Test case for Mutex where Object type is shareable. -** -** Source Code: main.c and mutex.c -** main.c creates a mutex, creates processes and waits for all processes to get over -** mutex.c create threads which will contend for the mutex -** -** This test is for Object Management Test case for Mutex where Object type is not shareable. -** Algorithm -** o Main Process Creates OBJECT_TYPE Object -** o Create PROCESS_COUNT processes aware of the Shared Object -** -** Author: ShamitP -** -** -**============================================================ -*/ - -#include -#include "resultbuffer.h" -#include "resulttime.h" - -#define TIMEOUT 5000 -/* Test Input Variables */ -unsigned int USE_PROCESS_COUNT = 0; -unsigned int THREAD_COUNT = 0; -unsigned int REPEAT_COUNT = 0; -unsigned int RELATION_ID = 0; - - -/* Capture statistics at per thread basis */ -struct statistics{ - unsigned int processId; - unsigned int operationsFailed; - unsigned int operationsPassed; - unsigned int operationsTotal; - DWORD operationTime; - unsigned int relationId; -}; - -struct ProcessStats{ - unsigned int processId; - DWORD operationTime; - unsigned int relationId; -}; - -HANDLE StartTestsEvHandle = NULL; -HANDLE hMutexHandle = NULL; - -/* Results Buffer */ -ResultBuffer *resultBuffer = NULL; - -int testStatus; - -const char sTmpEventName[MAX_PATH] = "StartTestEvent"; -char objectSuffix[MAX_PATH]; - -void PALAPI Run_Thread(LPVOID lpParam); - -int GetParameters( int argc, char **argv) -{ - if( (!((argc == 5) || (argc == 6) ) )|| ((argc == 1) && !strcmp(argv[1],"/?")) - || !strcmp(argv[1],"/h") || !strcmp(argv[1],"/H")) - { - printf("PAL -Composite Object Management event Test\n"); - printf("Usage:\n"); - printf("main\n\t[USE_PROCESS_COUNT (greater than 1)] \n"); - printf("\t[THREAD_COUNT (greater than 1)] \n"); - printf("\t[REPEAT_COUNT (greater than 1)]\n"); - printf("\t[RELATION_ID [greater than 1]\n"); - printf("\t[Object Name Suffix]\n"); - - return -1; - } - - // Trace("Args 1 is [%s], Arg 2 is [%s], Arg 3 is [%s]\n", argv[1], argv[2], argv[3]); - - USE_PROCESS_COUNT = atoi(argv[1]); - if( USE_PROCESS_COUNT < 0) - { - printf("\nInvalid USE_PROCESS_COUNT number, Pass greater than 1\n"); - return -1; - } - - THREAD_COUNT = atoi(argv[2]); - if( (THREAD_COUNT < 1) || (THREAD_COUNT > MAXIMUM_WAIT_OBJECTS) ) - { - printf("\nInvalid THREAD_COUNT number, Pass greater than 1 and less than %d\n", MAXIMUM_WAIT_OBJECTS); - return -1; - } - - REPEAT_COUNT = atoi(argv[3]); - if( REPEAT_COUNT < 1) - { - printf("\nInvalid REPEAT_COUNT number, Pass greater than 1\n"); - return -1; - } - - RELATION_ID = atoi(argv[4]); - if( RELATION_ID < 1) - { - printf("\nMain Process:Invalid RELATION_ID number, Pass greater than 1\n"); - return -1; - } - - if(argc == 6) - { - strncpy(objectSuffix, argv[5], MAX_PATH-1); - } - - return 0; -} - - int __cdecl main(INT argc, CHAR **argv) -{ - unsigned int i = 0; - HANDLE hThread[MAXIMUM_WAIT_OBJECTS]; - DWORD threadId[MAXIMUM_WAIT_OBJECTS]; - - char ObjName[MAX_PATH] = "SHARED_MUTEX"; - DWORD dwParam = 0; - - int returnCode = 0; - - /* Variables to capture the file name and the file pointer*/ - char fileName[MAX_PATH]; - FILE *pFile = NULL; - struct statistics* buffer = NULL; - int statisticsSize = 0; - - /* Variables to capture the file name and the file pointer at process level*/ - char processFileName[MAX_PATH]; - FILE *pProcessFile = NULL; - struct ProcessStats processStats; - DWORD dwStartTime; - - testStatus = PASS; - - if(0 != (PAL_Initialize(argc, argv))) - { - return ( FAIL ); - } - - ZeroMemory( objectSuffix, MAX_PATH ); - - if(GetParameters(argc, argv)) - { - Fail("Error in obtaining the parameters\n"); - } -// Trace("Process created, value of process count is [%d]\n", USE_PROCESS_COUNT); - - if(argc == 5) - { - strncat(ObjName, objectSuffix, MAX_PATH - (sizeof(ObjName) + 1) ); - } - - /* Register the start time */ - dwStartTime = GetTickCount(); - processStats.relationId = RELATION_ID; - processStats.processId = USE_PROCESS_COUNT; - - _snprintf(processFileName, MAX_PATH, "%d_process_mutex_%d_.txt", USE_PROCESS_COUNT, RELATION_ID); - pProcessFile = fopen(processFileName, "w+"); - if(pProcessFile == NULL) - { - Fail("Error in opening process File file for write for process [%d]\n", USE_PROCESS_COUNT); - } statisticsSize = sizeof(struct statistics); - - _snprintf(fileName, MAX_PATH, "%d_thread_mutex_%d_.txt", USE_PROCESS_COUNT, RELATION_ID); - pFile = fopen(fileName, "w+"); - if(pFile == NULL) - { - Fail("Error in opening file for write for process [%d]\n", USE_PROCESS_COUNT); - } - // For each thread we will log operations failed (int), passed (int), total (int) - // and number of ticks (DWORD) for the operations - resultBuffer = new ResultBuffer( THREAD_COUNT, statisticsSize); - - /* Create StartTest Event */ - StartTestsEvHandle = CreateEvent( NULL, /* lpEventAttributes*/ - TRUE, /* bManualReset */ - FALSE, /* bInitialState */ - NULL); /* name of Event */ - - if( StartTestsEvHandle == NULL ) - { - Fail("Error:%d: Unexpected failure " - "to create %s Event for process count %d\n", GetLastError(), sTmpEventName, USE_PROCESS_COUNT ); - - } - - hMutexHandle = CreateMutex( - NULL, - FALSE, /* bInitialOwner, owns initially */ - ObjName - ); - - if( (hMutexHandle == NULL)|| (GetLastError() != ERROR_ALREADY_EXISTS)) - { - Fail("Unable to create Mutex handle for process id [%d], returned error [%d], expected ERROR_ALREADY_EXISTS\n", i, GetLastError()); - } - /* We already assume that the mutex was created previously*/ - - for( i = 0; i < THREAD_COUNT; i++ ) - { - dwParam = (int) i; - //Create thread - hThread[i] = CreateThread( - NULL, /* no security attributes */ - 0, /* use default stack size */ - (LPTHREAD_START_ROUTINE)Run_Thread,/* thread function */ - (LPVOID)dwParam, /* argument to thread function */ - 0, /* use default creation flags */ - &threadId[i] /* returns the thread identifier*/ - ); - - if(hThread[i] == NULL) - { - Fail("Create Thread failed for %d process, and GetLastError value is %d\n", USE_PROCESS_COUNT, GetLastError()); - } - - } - - if (!SetEvent(StartTestsEvHandle)) - { - Fail("Set Event for Start Tests failed for %d process, and GetLastError value is %d\n", USE_PROCESS_COUNT, GetLastError()); - } - - /* Test running */ - returnCode = WaitForMultipleObjects( THREAD_COUNT, hThread, TRUE, INFINITE); - - if( WAIT_OBJECT_0 != returnCode ) - { - Trace("Wait for Object(s) for %d process returned %d, and GetLastError value is %d\n", USE_PROCESS_COUNT, returnCode, GetLastError()); - testStatus = FAIL; - } - - processStats.operationTime = GetTimeDiff(dwStartTime); - - /* Write to a file*/ - if(pFile!= NULL) - { - for( i = 0; i < THREAD_COUNT; i++ ) - { - buffer = (struct statistics *)resultBuffer->getResultBuffer(i); - returnCode = fprintf(pFile, "%d,%d,%d,%d,%lu,%d\n", buffer->processId, buffer->operationsFailed, buffer->operationsPassed, buffer->operationsTotal, buffer->operationTime, buffer->relationId ); -// Trace("Iteration %d over\n", i); - - } - } - fclose(pFile); - - fprintf(pProcessFile, "%d,%d,%d\n", USE_PROCESS_COUNT, processStats.operationTime, processStats.relationId ); - fclose(pProcessFile); - - /* Logging for the test case over, clean up the handles */ - -// Trace("Process Count %d over\n",USE_PROCESS_COUNT); - - for( i = 0; i < THREAD_COUNT; i++ ) - { - if(!CloseHandle(hThread[i]) ) - { - Trace("Error:%d: CloseHandle failed for Process [%d] hThread[%d]\n", GetLastError(), USE_PROCESS_COUNT, i); - testStatus = FAIL; - } - } - - if(!CloseHandle(StartTestsEvHandle)) - { - Trace("Error:%d: CloseHandle failed for Process [%d] StartTestsEvHandle\n", GetLastError(), USE_PROCESS_COUNT); - testStatus = FAIL; - } - - if(!CloseHandle(hMutexHandle)) - { - Trace("Error:%d: CloseHandle failed for Process [%d] hMutexHandle\n", GetLastError(), USE_PROCESS_COUNT); - testStatus = FAIL; - } - - PAL_Terminate(); - return testStatus; -} - -void PALAPI Run_Thread (LPVOID lpParam) -{ - unsigned int i = 0; - DWORD dwWaitResult; - - struct statistics stats; - DWORD dwStartTime; - - stats.relationId = RELATION_ID; - stats.processId = USE_PROCESS_COUNT; - stats.operationsFailed = 0; - stats.operationsPassed = 0; - stats.operationsTotal = 0; - stats.operationTime = 0; - - int Id=(int)lpParam; - - dwWaitResult = WaitForSingleObject( - StartTestsEvHandle, // handle to mutex - TIMEOUT); - - if(dwWaitResult != WAIT_OBJECT_0) - { - Trace("Error while waiting for StartTest Event@ thread %d\n", Id); - testStatus = FAIL; - } - - dwStartTime = GetTickCount(); - - for( i = 0; i < REPEAT_COUNT; i++ ) - { - dwWaitResult = WaitForSingleObject( - hMutexHandle, // handle to mutex - TIMEOUT); - - if(dwWaitResult != WAIT_OBJECT_0) - { -// Trace("Error while waiting for onject @ thread %d, # iter %d, Error Returned [%d]\n", Id, i, GetLastError()); - stats.operationsFailed += 1; - stats.operationsTotal += 1; - testStatus = FAIL; - continue; - } - if (! ReleaseMutex(hMutexHandle)) - { - // Deal with error. -// Trace("Error while releasing mutex @ thread %d # iter %d\n", Id, i); - stats.operationsFailed += 1; - stats.operationsTotal += 1; - // Probably need to have while true loop to attempt to release mutex... - testStatus = FAIL; - continue; - } - - stats.operationsTotal += 1; - stats.operationsPassed += 1; -// Trace("Successs while releasing mutex @ iteration %d -> thread %d -> Process count %d\n", i, Id, USE_PROCESS_COUNT); - - } - stats.operationTime = GetTimeDiff(dwStartTime); - if(resultBuffer->LogResult(Id, (char *)&stats)) - { - Fail("Error:%d: while writing to shared memory, Thread Id is[%d] and Process id is [%d]\n", GetLastError(), Id, USE_PROCESS_COUNT); - } -} diff --git a/src/pal/tests/palsuite/composite/object_management/readme.txt b/src/pal/tests/palsuite/composite/object_management/readme.txt deleted file mode 100644 index 6bae5f105..000000000 --- a/src/pal/tests/palsuite/composite/object_management/readme.txt +++ /dev/null @@ -1,29 +0,0 @@ -To compile: - -1) create a dat file (say object_management.dat) with contents: - -PAL,Composite,palsuite\composite\object_management\mutex\nonshared,mutex=main.c mutex.c,,, -PAL,Composite,palsuite\composite\object_management\mutex\shared,mutex=main.c mutex.c,,, -PAL,Composite,palsuite\composite\object_management\semaphore\nonshared,semaphore=main.c semaphore.c,,, -PAL,Composite,palsuite\composite\object_management\semaphore\shared,semaphore=main.c semaphore.c,,, -PAL,Composite,palsuite\composite\object_management\event\nonshared,event=main.c event.c,,, -PAL,Composite,palsuite\composite\object_management\event\shared,event=main.c event.c,,, - - -2) perl rrunmod.pl -r object_management.dat - - -To execute: -For each of the test cases, -main [PROCESS_COUNT] [THREAD_COUNT] [REPEAT_COUNT] - - -Output: -The performance numbers will be in _[event|semaphore|mutex].txt -(will be at palsuite\composite\object_management\[mutex|event|semaphore]\[shared|nonshared]\obj[r|c|d] directory if u use rrunmod.pl) - -So if process_count is 3, you will have files 0_mutex.txt, 1_mutex.txt and so on… - -For each process txt file created, -each row represents a thread data (process id, number of failures, number of pass, total number of repeated operations and an integer that will be used to identify a run -(currently zero)). diff --git a/src/pal/tests/palsuite/composite/object_management/semaphore/CMakeLists.txt b/src/pal/tests/palsuite/composite/object_management/semaphore/CMakeLists.txt deleted file mode 100644 index 2534564f9..000000000 --- a/src/pal/tests/palsuite/composite/object_management/semaphore/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(nonshared) -add_subdirectory(shared) - diff --git a/src/pal/tests/palsuite/composite/object_management/semaphore/nonshared/CMakeLists.txt b/src/pal/tests/palsuite/composite/object_management/semaphore/nonshared/CMakeLists.txt deleted file mode 100644 index f17c6737b..000000000 --- a/src/pal/tests/palsuite/composite/object_management/semaphore/nonshared/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - main.cpp - semaphore.cpp -) - -add_executable(paltest_semaphore_nonshared - ${SOURCES} -) - -add_dependencies(paltest_semaphore_nonshared coreclrpal) - -target_link_libraries(paltest_semaphore_nonshared - ${COMMON_TEST_LIBRARIES} - rt -) diff --git a/src/pal/tests/palsuite/composite/object_management/semaphore/nonshared/main.cpp b/src/pal/tests/palsuite/composite/object_management/semaphore/nonshared/main.cpp deleted file mode 100644 index 854809c8f..000000000 --- a/src/pal/tests/palsuite/composite/object_management/semaphore/nonshared/main.cpp +++ /dev/null @@ -1,228 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source Code: main.c and semaphore.c -** main.c creates process and waits for all processes to get over -** semaphore.c creates a semaphore and then calls threads which will contend for the semaphore -** -** This test is for Object Management Test case for semaphore where Object type is not shareable. -** Algorithm -** o Create PROCESS_COUNT processes. -** o Main Thread of each process creates OBJECT_TYPE Object -** -** Author: ShamitP -** -** -**============================================================ -*/ - -#include -#include "resulttime.h" - -/* Test Input Variables */ -unsigned int PROCESS_COUNT = 2; -unsigned int THREAD_COUNT = 15; -unsigned int REPEAT_COUNT = 40000; -unsigned int RELATION_ID = 1001; - - - -struct TestStats{ - DWORD operationTime; - unsigned int relationId; - unsigned int processCount; - unsigned int threadCount; - unsigned int repeatCount; - char* buildNumber; -}; - -int GetParameters( int argc, char **argv) -{ - if( (argc != 5) || ((argc == 1) && !strcmp(argv[1],"/?")) - || !strcmp(argv[1],"/h") || !strcmp(argv[1],"/H")) - { - printf("PAL -Composite Object Management Semaphore Test\n"); - printf("Usage:\n"); - printf("main\n\t[PROCESS_COUNT [greater than 1] \n"); - printf("\t[THREAD_COUNT [greater than 1] \n"); - printf("\t[REPEAT_COUNT [greater than 1]\n"); - printf("\t[RELATION_ID [greater than 1]\n"); - return -1; - } - - PROCESS_COUNT = atoi(argv[1]); - if( (PROCESS_COUNT < 1) || (PROCESS_COUNT > MAXIMUM_WAIT_OBJECTS) ) - { - printf("\nMain Process:Invalid PROCESS_COUNT number, Pass greater than 1 and less than PROCESS_COUNT %d\n", MAXIMUM_WAIT_OBJECTS); - return -1; - } - - THREAD_COUNT = atoi(argv[2]); - if( (THREAD_COUNT < 1) || (THREAD_COUNT > MAXIMUM_WAIT_OBJECTS) ) - { - printf("\nInvalid THREAD_COUNT number, Pass greater than 1 and less than %d\n", MAXIMUM_WAIT_OBJECTS); - return -1; - } - - REPEAT_COUNT = atoi(argv[3]); - if( REPEAT_COUNT < 1) - { - printf("\nMain Process:Invalid REPEAT_COUNT number, Pass greater than 1\n"); - return -1; - } - - RELATION_ID = atoi(argv[4]); - if( RELATION_ID < 1) - { - printf("\nMain Process:Invalid RELATION_ID number, Pass greater than or Equal to 1\n"); - return -1; - } - - return 0; -} - - int __cdecl main(INT argc, CHAR **argv) -{ - unsigned int i = 0; - HANDLE hProcess[MAXIMUM_WAIT_OBJECTS]; - HANDLE hSemaphoreHandle[MAXIMUM_WAIT_OBJECTS]; - - STARTUPINFO si[MAXIMUM_WAIT_OBJECTS]; - PROCESS_INFORMATION pi[MAXIMUM_WAIT_OBJECTS]; - - const char *ObjName = "Semaphore"; - char lpCommandLine[MAX_PATH] = ""; - - int returnCode = 0; - DWORD processReturnCode = 0; - int testReturnCode = PASS; - - char fileName[MAX_PATH]; - FILE *pFile = NULL; - DWORD dwStartTime; - struct TestStats testStats; - - if(0 != (PAL_Initialize(argc, argv))) - { - return ( FAIL ); - } - - if(GetParameters(argc, argv)) - { - Fail("Error in obtaining the parameters\n"); - } - - /* Register the start time */ - dwStartTime = GetTickCount(); - testStats.relationId = RELATION_ID; - testStats.processCount = PROCESS_COUNT; - testStats.threadCount = THREAD_COUNT; - testStats.repeatCount = REPEAT_COUNT; - testStats.buildNumber = getBuildNumber(); - - - _snprintf(fileName, MAX_PATH, "main_semaphore_%d_.txt", RELATION_ID); - pFile = fopen(fileName, "w+"); - if(pFile == NULL) - { - Fail("Error in opening main file for write\n"); - } - - for( i = 0; i < PROCESS_COUNT; i++ ) - { - ZeroMemory( lpCommandLine, MAX_PATH ); - if ( _snprintf( lpCommandLine, MAX_PATH-1, "semaphore %d %d %d %d", i, THREAD_COUNT, REPEAT_COUNT, RELATION_ID) < 0 ) - { - Fail("Error Insufficient semaphore name string length for %s for iteration [%d]\n", ObjName, i); - } - - /* Zero the data structure space */ - ZeroMemory ( &pi[i], sizeof(pi[i]) ); - ZeroMemory ( &si[i], sizeof(si[i]) ); - - /* Set the process flags and standard io handles */ - si[i].cb = sizeof(si[i]); - - //Create Process - if(!CreateProcess( NULL, /* lpApplicationName*/ - lpCommandLine, /* lpCommandLine */ - NULL, /* lpProcessAttributes */ - NULL, /* lpThreadAttributes */ - TRUE, /* bInheritHandles */ - 0, /* dwCreationFlags, */ - NULL, /* lpEnvironment */ - NULL, /* pCurrentDirectory */ - &si[i], /* lpStartupInfo */ - &pi[i] /* lpProcessInformation */ - )) - { - Fail("Process Not created for [%d], the error code is [%d]\n", i, GetLastError()); - } - else - { - hProcess[i] = pi[i].hProcess; -// Trace("Process created for [%d]\n", i); - - } - } - - returnCode = WaitForMultipleObjects( PROCESS_COUNT, hProcess, TRUE, INFINITE); - if( WAIT_OBJECT_0 != returnCode ) - { - Trace("Wait for Object(s) @ Main thread for %d processes returned %d, and GetLastError value is %d\n", PROCESS_COUNT, returnCode, GetLastError()); - testReturnCode = FAIL; - } - - for( i = 0; i < PROCESS_COUNT; i++ ) - { - /* check the exit code from the process */ - if( ! GetExitCodeProcess( pi[i].hProcess, &processReturnCode ) ) - { - Trace( "GetExitCodeProcess call failed for iteration %d with error code %u\n", - i, GetLastError() ); - - testReturnCode = FAIL; - } - - if(processReturnCode == FAIL) - { - Trace( "Process [%d] failed and returned FAIL\n", i); - testReturnCode = FAIL; - } - - if(!CloseHandle(pi[i].hThread)) - { - Trace("Error:%d: CloseHandle failed for Process [%d] hThread\n", GetLastError(), i); - testReturnCode = FAIL; - } - - if(!CloseHandle(pi[i].hProcess) ) - { - Trace("Error:%d: CloseHandle failed for Process [%d] hProcess\n", GetLastError(), i); - testReturnCode = FAIL; - } - } - - testStats.operationTime = GetTimeDiff(dwStartTime); - fprintf(pFile, "%d,%d,%d,%d,%d,%s\n", testStats.operationTime, testStats.relationId,testStats.processCount, testStats.threadCount, testStats.repeatCount, testStats.buildNumber ); - if(fclose(pFile)) - { - Trace("Error: fclose failed for pFile\n"); - testReturnCode = FAIL; - } - - if( testReturnCode == PASS) - { - Trace("Test Passed\n"); - } - else - { - Trace("Test Failed\n"); - } - - PAL_Terminate(); - return testReturnCode; -} diff --git a/src/pal/tests/palsuite/composite/object_management/semaphore/nonshared/semaphore.cpp b/src/pal/tests/palsuite/composite/object_management/semaphore/nonshared/semaphore.cpp deleted file mode 100644 index 0e487f2c1..000000000 --- a/src/pal/tests/palsuite/composite/object_management/semaphore/nonshared/semaphore.cpp +++ /dev/null @@ -1,342 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source Code: main.c and semaphore.c -** main.c creates process and waits for all processes to get over -** semaphore.c creates a semaphore and then calls threads which will contend for the semaphore -** -** This test is for Object Management Test case for semaphore where Object type is not shareable. -** Algorithm -** o Create PROCESS_COUNT processes. -** o Main Thread of each process creates OBJECT_TYPE Object -** -** Author: ShamitP -** -** -**============================================================ -*/ - -#include -#include "resultbuffer.h" -#include "resulttime.h" - -#define TIMEOUT 5000 -/* Test Input Variables */ -unsigned int USE_PROCESS_COUNT = 0; -unsigned int THREAD_COUNT = 0; -unsigned int REPEAT_COUNT = 0; -unsigned int RELATION_ID = 0; - -/* Capture statistics at per thread basis */ -struct statistics{ - unsigned int processId; - unsigned int operationsFailed; - unsigned int operationsPassed; - unsigned int operationsTotal; - DWORD operationTime; - unsigned int relationId; -}; - -struct ProcessStats{ - unsigned int processId; - DWORD operationTime; - unsigned int relationId; -}; - -/* Semaphore variables */ -unsigned long lInitialCount = 1; /* Signaled */ -unsigned long lMaximumCount = 1; /* Maximum value of 1 */ - -HANDLE StartTestsEvHandle = NULL; -HANDLE hSemaphoreHandle = NULL; - -/* Results Buffer */ -ResultBuffer *resultBuffer = NULL; - -int testStatus; - -const char sTmpEventName[MAX_PATH] = "StartTestEvent"; - -void PALAPI Run_Thread(LPVOID lpParam); - -int GetParameters( int argc, char **argv) -{ - if( (argc != 5) || ((argc == 1) && !strcmp(argv[1],"/?")) - || !strcmp(argv[1],"/h") || !strcmp(argv[1],"/H")) - { - printf("PAL -Composite Object Management Semaphore Test\n"); - printf("Usage:\n"); - printf("semaphore\n\t[USE_PROCESS_COUNT ( greater than 1] \n"); - printf("\t[THREAD_COUNT ( greater than 1] \n"); - printf("\t[REPEAT_COUNT ( greater than 1]\n"); - printf("\t[RELATION_ID [greater than 1]\n"); - return -1; - } - - // Trace("Args 1 is [%s], Arg 2 is [%s], Arg 3 is [%s]\n", argv[1], argv[2], argv[3]); - - USE_PROCESS_COUNT = atoi(argv[1]); - if( USE_PROCESS_COUNT < 0) - { - printf("\nInvalid USE_PROCESS_COUNT number, Pass greater than 1\n"); - return -1; - } - - THREAD_COUNT = atoi(argv[2]); - if( (THREAD_COUNT < 1) || (THREAD_COUNT > MAXIMUM_WAIT_OBJECTS) ) - { - printf("\nInvalid THREAD_COUNT number, Pass greater than 1 and less than %d\n", MAXIMUM_WAIT_OBJECTS); - return -1; - } - - REPEAT_COUNT = atoi(argv[3]); - if( REPEAT_COUNT < 1) - { - printf("\nInvalid REPEAT_COUNT number, Pass greater than 1\n"); - return -1; - } - - RELATION_ID = atoi(argv[4]); - if( RELATION_ID < 1) - { - printf("\nMain Process:Invalid RELATION_ID number, Pass greater than or Equal to 1\n"); - return -1; - } - - return 0; -} - - int __cdecl main(INT argc, CHAR **argv) -{ - unsigned int i = 0; - HANDLE hThread[MAXIMUM_WAIT_OBJECTS]; - DWORD threadId[MAXIMUM_WAIT_OBJECTS]; - - const char *ObjName = "Semaphore"; - - DWORD dwParam = 0; - - int returnCode = 0; - - /* Variables to capture the file name and the file pointer at thread level*/ - char fileName[MAX_PATH]; - FILE *pFile = NULL; - struct statistics* buffer = NULL; - int statisticsSize = 0; - - /* Variables to capture the file name and the file pointer at process level*/ - char processFileName[MAX_PATH]; - FILE *pProcessFile = NULL; - struct ProcessStats processStats; - DWORD dwStartTime; - - testStatus = PASS; - - if(0 != (PAL_Initialize(argc, argv))) - { - return ( FAIL ); - } - - if(GetParameters(argc, argv)) - { - Fail("Error in obtaining the parameters\n"); - } - // Trace("Process created, value of process count is [%d]\n", USE_PROCESS_COUNT); - - /* Register the start time */ - dwStartTime = GetTickCount(); - processStats.relationId = RELATION_ID; - processStats.processId = USE_PROCESS_COUNT; - - _snprintf(processFileName, MAX_PATH, "%d_process_semaphore_%d_.txt", USE_PROCESS_COUNT, RELATION_ID); - pProcessFile = fopen(processFileName, "w+"); - if(pProcessFile == NULL) - { - Fail("Error in opening process File file for write for process [%d]\n", USE_PROCESS_COUNT); - } - - statisticsSize = sizeof(struct statistics); - - _snprintf(fileName, MAX_PATH, "%d_thread_semaphore_%d_.txt", USE_PROCESS_COUNT, RELATION_ID); - pFile = fopen(fileName, "w+"); - if(pFile == NULL) - { - Fail("Error in opening file for write for process [%d]\n", USE_PROCESS_COUNT); - } - // For each thread we will log operations failed (int), passed (int), total (int) - // and number of ticks (DWORD) for the operations - resultBuffer = new ResultBuffer( THREAD_COUNT, statisticsSize); - - StartTestsEvHandle = CreateEvent( NULL, /* lpEventAttributes*/ - TRUE, /* bManualReset */ - FALSE, /* bInitialState */ - NULL); /* name of Event */ - - if( StartTestsEvHandle == NULL ) - { - Fail("Error:%d: Unexpected failure " - "to create %s Event for process count %d\n", GetLastError(), sTmpEventName, USE_PROCESS_COUNT ); - - } - - /* Create StartTest Event */ - hSemaphoreHandle = CreateSemaphore( - NULL, /* lpSemaphoreAttributes */ - lInitialCount, /*lInitialCount*/ - lMaximumCount, /*lMaximumCount */ - NULL - ); - - if( hSemaphoreHandle == NULL) - { - Fail("Unable to create Semaphore handle for process id [%d], returned error [%d]\n", i, GetLastError()); - } - /* We already assume that the Semaphore was created previously*/ - - for( i = 0; i < THREAD_COUNT; i++ ) - { - dwParam = (int) i; - //Create thread - hThread[i] = CreateThread( - NULL, /* no security attributes */ - 0, /* use default stack size */ - (LPTHREAD_START_ROUTINE)Run_Thread,/* thread function */ - (LPVOID)dwParam, /* argument to thread function */ - 0, /* use default creation flags */ - &threadId[i] /* returns the thread identifier*/ - ); - - - if(hThread[i] == NULL) - { - Fail("Create Thread failed for %d process, and GetLastError value is %d\n", USE_PROCESS_COUNT, GetLastError()); - } - - } - - if (!SetEvent(StartTestsEvHandle)) - { - Fail("Set Event for Start Tests failed for %d process, and GetLastError value is %d\n", USE_PROCESS_COUNT, GetLastError()); - } - - /* Test running */ - returnCode = WaitForMultipleObjects( THREAD_COUNT, hThread, TRUE, INFINITE); - - if( WAIT_OBJECT_0 != returnCode ) - { - Trace("Wait for Object(s) for %d process returned %d, and GetLastError value is %d\n", USE_PROCESS_COUNT, returnCode, GetLastError()); - testStatus = FAIL; - } - - processStats.operationTime = GetTimeDiff(dwStartTime); - - /* Write to a file*/ - if(pFile!= NULL) - { - for( i = 0; i < THREAD_COUNT; i++ ) - { - buffer = (struct statistics *)resultBuffer->getResultBuffer(i); - returnCode = fprintf(pFile, "%d,%d,%d,%d,%lu,%d\n", buffer->processId, buffer->operationsFailed, buffer->operationsPassed, buffer->operationsTotal, buffer->operationTime, buffer->relationId ); - //Trace("Iteration %d over\n", i); - - } - } - fclose(pFile); - /* Logging for the test case over, clean up the handles */ - -// Trace("Test Thread %d done\n", USE_PROCESS_COUNT); - - for( i = 0; i < THREAD_COUNT; i++ ) - { - if(!CloseHandle(hThread[i]) ) - { - Trace("Error:%d: CloseHandle failed for Process [%d] hThread[%d]\n", GetLastError(), USE_PROCESS_COUNT, i); - testStatus = FAIL; - } - } - - if(!CloseHandle(StartTestsEvHandle)) - { - Trace("Error:%d: CloseHandle failed for Process [%d] StartTestsEvHandle\n", GetLastError(), USE_PROCESS_COUNT); - testStatus = FAIL; - } - - if(!CloseHandle(hSemaphoreHandle)) - { - Trace("Error:%d: CloseHandle failed for Process [%d] hSemaphoreHandle\n", GetLastError(), USE_PROCESS_COUNT); - testStatus = FAIL; - } - - PAL_Terminate(); - return PASS; -} - -void PALAPI Run_Thread (LPVOID lpParam) -{ - unsigned int i = 0; - DWORD dwWaitResult; - - int Id=(int)lpParam; - - struct statistics stats; - DWORD dwStartTime; - - stats.relationId = RELATION_ID; - stats.processId = USE_PROCESS_COUNT; - stats.operationsFailed = 0; - stats.operationsPassed = 0; - stats.operationsTotal = 0; - stats.operationTime = 0; - - dwWaitResult = WaitForSingleObject( - StartTestsEvHandle, // handle to start test handle - TIMEOUT); - - if(dwWaitResult != WAIT_OBJECT_0) - { - Fail("Error while waiting for StartTest Event@ thread %d, RC is %d, Error is %d\n", Id, dwWaitResult, GetLastError()); - } - - dwStartTime = GetTickCount(); - - for( i = 0; i < REPEAT_COUNT; i++ ) - { - dwWaitResult = WaitForSingleObject( - hSemaphoreHandle, // handle to Semaphore - TIMEOUT); - - if(dwWaitResult != WAIT_OBJECT_0) - { -// Trace("Error while waiting for onject @ thread %d, # iter %d, RC is %d, Error is %d\n", Id, i, dwWaitResult, GetLastError()); - stats.operationsFailed += 1; - stats.operationsTotal += 1; - testStatus = FAIL; - continue; - } - if (! ReleaseSemaphore(hSemaphoreHandle, 1, NULL)) - { - // Deal with error. - // Trace("Error while releasing Semaphore @ thread %d # iter %d\n", Id, i); - stats.operationsFailed += 1; - stats.operationsTotal += 1; - // Probably need to have while true loop to attempt to release semaphore... - testStatus = FAIL; - continue; - } - - stats.operationsTotal += 1; - stats.operationsPassed += 1; -// Trace("Successs while releasing Semaphore @ iteration %d -> thread %d -> Process %d\n", i, Id, USE_PROCESS_COUNT); - - } - - stats.operationTime = GetTimeDiff(dwStartTime); - if(resultBuffer->LogResult(Id, (char *)&stats)) - { - Fail("Error:%d: while writing to shared memory, Thread Id is[%d] and Process id is [%d]\n", GetLastError(), Id, USE_PROCESS_COUNT); - } - // Trace("Thread %d over for process %d\n", Id, USE_PROCESS_COUNT); -} diff --git a/src/pal/tests/palsuite/composite/object_management/semaphore/shared/CMakeLists.txt b/src/pal/tests/palsuite/composite/object_management/semaphore/shared/CMakeLists.txt deleted file mode 100644 index 24327bea4..000000000 --- a/src/pal/tests/palsuite/composite/object_management/semaphore/shared/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - main.cpp - semaphore.cpp -) - -add_executable(paltest_semaphore_shared - ${SOURCES} -) - -add_dependencies(paltest_semaphore_shared coreclrpal) - -target_link_libraries(paltest_semaphore_shared - ${COMMON_TEST_LIBRARIES} - rt -) diff --git a/src/pal/tests/palsuite/composite/object_management/semaphore/shared/main.cpp b/src/pal/tests/palsuite/composite/object_management/semaphore/shared/main.cpp deleted file mode 100644 index d3cfa762b..000000000 --- a/src/pal/tests/palsuite/composite/object_management/semaphore/shared/main.cpp +++ /dev/null @@ -1,275 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source Code: main.c and semaphore.c -** main.c creates process and waits for all processes to get over -** semaphore.c creates a semaphore and then calls threads which will contend for the semaphore -** -** This test is for Object Management Test case for semaphore where Object type is shareable. -** Algorithm -** o Main Process Creates OBJECT_TYPE Object -** o Create PROCESS_COUNT processes aware of the Shared Object -** -** -** -**============================================================ -*/ - -#include -#include "resulttime.h" - -/* Test Input Variables */ -unsigned int PROCESS_COUNT = 1; -unsigned int THREAD_COUNT = 1; -unsigned int REPEAT_COUNT = 4; -unsigned int RELATION_ID = 1001; - - -unsigned long lInitialCount = 1; /* Signaled */ -unsigned long lMaximumCount = 1; /* Maximum value of 1 */ - -char objectSuffix[MAX_PATH]; - -struct TestStats{ - DWORD operationTime; - unsigned int relationId; - unsigned int processCount; - unsigned int threadCount; - unsigned int repeatCount; - char* buildNumber; - -}; - -int GetParameters( int argc, char **argv) -{ - if( (!((argc == 5) || (argc == 6) ) )|| ((argc == 1) && !strcmp(argv[1],"/?")) - || !strcmp(argv[1],"/h") || !strcmp(argv[1],"/H")) - { - printf("PAL -Composite Object Management event Test\n"); - printf("Usage:\n"); - printf("main\n\t[PROCESS_COUNT (greater than 1)] \n"); - printf("\t[THREAD_COUNT (greater than 1)] \n"); - printf("\t[REPEAT_COUNT (greater than 1)]\n"); - printf("\t[RELATION_ID [greater than or equal to 1]\n"); - printf("\t[Object Name Suffix]\n"); - return -1; - } - - PROCESS_COUNT = atoi(argv[1]); - if( (PROCESS_COUNT < 1) || (PROCESS_COUNT > MAXIMUM_WAIT_OBJECTS) ) - { - printf("\nMain Process:Invalid PROCESS_COUNT number, Pass greater than 1 and less than PROCESS_COUNT %d\n", MAXIMUM_WAIT_OBJECTS); - return -1; - } - - THREAD_COUNT = atoi(argv[2]); - if( (THREAD_COUNT < 1) || (THREAD_COUNT > MAXIMUM_WAIT_OBJECTS) ) - { - printf("\nInvalid THREAD_COUNT number, Pass greater than 1 and less than %d\n", MAXIMUM_WAIT_OBJECTS); - return -1; - } - - REPEAT_COUNT = atoi(argv[3]); - if( REPEAT_COUNT < 1) - { - printf("\nMain Process:Invalid REPEAT_COUNT number, Pass greater than 1\n"); - return -1; - } - - RELATION_ID = atoi(argv[4]); - if( RELATION_ID < 1) - { - printf("\nMain Process:Invalid RELATION_ID number, Pass greater than 1\n"); - return -1; - } - - - if(argc == 6) - { - strncpy(objectSuffix, argv[5], MAX_PATH-1); - } - - return 0; -} - - int __cdecl main(INT argc, CHAR **argv) -{ - unsigned int i = 0; - HANDLE hProcess[MAXIMUM_WAIT_OBJECTS]; - HANDLE hSemaphoreHandle; - - STARTUPINFO si[MAXIMUM_WAIT_OBJECTS]; - PROCESS_INFORMATION pi[MAXIMUM_WAIT_OBJECTS]; - - char lpCommandLine[MAX_PATH] = ""; - char ObjName[MAX_PATH] = "SHARED_SEMAPHORE"; - - int returnCode = 0; - DWORD processReturnCode = 0; - int testReturnCode = PASS; - - char fileName[MAX_PATH]; - FILE *pFile = NULL; - DWORD dwStartTime; - struct TestStats testStats; - - if(0 != (PAL_Initialize(argc, argv))) - { - return ( FAIL ); - } - -/* -"While the new PAL does support named semaphore it's unclear -if we should change the Windows PAL, since we share that w/ Rotor -and they are still using the old PAL. For the time being it may -make the most sense to just skip the named semaphore test on Windows -- from an object management perspective it doesn't really gain -us anything over what we already have." -*/ - ZeroMemory( objectSuffix, MAX_PATH ); - - if(GetParameters(argc, argv)) - { - Fail("Error in obtaining the parameters\n"); - } - - if(argc == 6) - { - strncat(ObjName, objectSuffix, MAX_PATH - (sizeof(ObjName) + 1) ); - } - - /* Register the start time */ - dwStartTime = GetTickCount(); - testStats.relationId = RELATION_ID; - testStats.processCount = PROCESS_COUNT; - testStats.threadCount = THREAD_COUNT; - testStats.repeatCount = REPEAT_COUNT; - testStats.buildNumber = getBuildNumber(); - - _snprintf(fileName, MAX_PATH, "main_semaphore_%d_.txt", RELATION_ID); - pFile = fopen(fileName, "w+"); - if(pFile == NULL) - { - Fail("Error in opening main file for write\n"); - } - - hSemaphoreHandle = CreateSemaphore( - NULL, /* lpSemaphoreAttributes */ - lInitialCount, /*lInitialCount*/ - lMaximumCount, /*lMaximumCount */ - ObjName - ); - - if( hSemaphoreHandle == NULL) - { - Fail("Unable to create shared Semaphore handle @ Main returned error [%d]\n", GetLastError()); - } - - for( i = 0; i < PROCESS_COUNT; i++ ) - { - - - ZeroMemory( lpCommandLine, MAX_PATH ); - if ( _snprintf( lpCommandLine, MAX_PATH-1, "semaphore %d %d %d %d %s", i, THREAD_COUNT, REPEAT_COUNT, RELATION_ID, objectSuffix) < 0 ) - { - Fail("Error: Insufficient semaphore name string length for %s for iteration [%d]\n", ObjName, i); - } - - - /* Zero the data structure space */ - ZeroMemory ( &pi[i], sizeof(pi[i]) ); - ZeroMemory ( &si[i], sizeof(si[i]) ); - - /* Set the process flags and standard io handles */ - si[i].cb = sizeof(si[i]); - - if(!CreateProcess( NULL, /* lpApplicationName*/ - lpCommandLine, /* lpCommandLine */ - NULL, /* lpProcessAttributes */ - NULL, /* lpThreadAttributes */ - TRUE, /* bInheritHandles */ - 0, /* dwCreationFlags, */ - NULL, /* lpEnvironment */ - NULL, /* pCurrentDirectory */ - &si[i], /* lpStartupInfo */ - &pi[i] /* lpProcessInformation */ - )) - { - Fail("Process Not created for [%d], the error code is [%d]\n", i, GetLastError()); - } - else - { - hProcess[i] = pi[i].hProcess; -// Trace("Process created for [%d]\n", i); - - } - - } - - returnCode = WaitForMultipleObjects( PROCESS_COUNT, hProcess, TRUE, INFINITE); - if( WAIT_OBJECT_0 != returnCode ) - { - Trace("Wait for Object(s) @ Main thread for %d processes returned %d, and GetLastError value is %d\n", PROCESS_COUNT, returnCode, GetLastError()); - testReturnCode = FAIL; - } - - for( i = 0; i < PROCESS_COUNT; i++ ) - { - /* check the exit code from the process */ - if( ! GetExitCodeProcess( pi[i].hProcess, &processReturnCode ) ) - { - Trace( "GetExitCodeProcess call failed for iteration %d with error code %u\n", - i, GetLastError() ); - - testReturnCode = FAIL; - } - - if(processReturnCode == FAIL) - { - Trace( "Process [%d] failed and returned FAIL\n", i); - testReturnCode = FAIL; - } - - if(!CloseHandle(pi[i].hThread)) - { - Trace("Error:%d: CloseHandle failed for Process [%d] hThread\n", GetLastError(), i); - testReturnCode = FAIL; - } - - if(!CloseHandle(pi[i].hProcess) ) - { - Trace("Error:%d: CloseHandle failed for Process [%d] hProcess\n", GetLastError(), i); - testReturnCode = FAIL; - } - } - - testStats.operationTime = GetTimeDiff(dwStartTime); - fprintf(pFile, "%d,%d,%d,%d,%d,%s\n", testStats.operationTime, testStats.relationId, testStats.processCount, testStats.threadCount, testStats.repeatCount, testStats.buildNumber); - if(fclose(pFile)) - { - Trace("Error: fclose failed for pFile\n"); - testReturnCode = FAIL; - }; - - if(!CloseHandle(hSemaphoreHandle)) - { - Trace("Error:%d: CloseHandle failed for hSemaphoreHandle\n", GetLastError()); - testReturnCode = FAIL; - - } - - if( testReturnCode == PASS) - { - Trace("Test Passed\n"); - } - else - { - Trace("Test Failed\n"); - } - - PAL_Terminate(); - return testReturnCode; -} diff --git a/src/pal/tests/palsuite/composite/object_management/semaphore/shared/semaphore.cpp b/src/pal/tests/palsuite/composite/object_management/semaphore/shared/semaphore.cpp deleted file mode 100644 index 5143c5514..000000000 --- a/src/pal/tests/palsuite/composite/object_management/semaphore/shared/semaphore.cpp +++ /dev/null @@ -1,351 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source Code: main.c and semaphore.c -** main.c creates process and waits for all processes to get over -** semaphore.c creates a semaphore and then calls threads which will contend for the semaphore -** -** This test is for Object Management Test case for semaphore where Object type is shareable. -** Algorithm -** o Main Process Creates OBJECT_TYPE Object -** o Create PROCESS_COUNT processes aware of the Shared Object -** -** -** -**============================================================ -*/ - -#include -#include "resultbuffer.h" -#include "resulttime.h" - -#define TIMEOUT 5000 -/* Test Input Variables */ -unsigned int USE_PROCESS_COUNT = 0; -unsigned int THREAD_COUNT = 0; -unsigned int REPEAT_COUNT = 0; -unsigned int RELATION_ID= 0; - -/* Capture statistics at per thread basis */ -struct statistics{ - unsigned int processId; - unsigned int operationsFailed; - unsigned int operationsPassed; - unsigned int operationsTotal; - DWORD operationTime; - unsigned int relationId; -}; - -struct ProcessStats{ - unsigned int processId; - DWORD operationTime; - unsigned int relationId; -}; - -/* Semaphore variables */ -unsigned long lInitialCount = 1; /* Signaled */ -unsigned long lMaximumCount = 1; /* Maximum value of 1 */ - -HANDLE StartTestsEvHandle = NULL; -HANDLE hSemaphoreHandle = NULL; - -/* Results Buffer */ -ResultBuffer *resultBuffer = NULL; - -int testStatus; - -const char sTmpEventName[MAX_PATH] = "StartTestEvent"; -char objectSuffix[MAX_PATH]; - -void PALAPI Run_Thread(LPVOID lpParam); - -int GetParameters( int argc, char **argv) -{ - if( (!((argc == 5) || (argc == 6) ) )|| ((argc == 1) && !strcmp(argv[1],"/?")) - || !strcmp(argv[1],"/h") || !strcmp(argv[1],"/H")) - { - printf("PAL -Composite Object Management event Test\n"); - printf("Usage:\n"); - printf("main\n\t[PROCESS_COUNT (greater than 1)] \n"); - printf("\t[THREAD_COUNT (greater than 1)] \n"); - printf("\t[REPEAT_COUNT (greater than 1)]\n"); - printf("\t[RELATION_ID [greater than or equal to 1]\n"); - printf("\t[Object Name Suffix]\n"); - return -1; - } - - USE_PROCESS_COUNT = atoi(argv[1]); - if(USE_PROCESS_COUNT < 0) - { - printf("\nMain Process:Invalid PROCESS_COUNT number, Pass greater than 0 \n"); - return -1; - } - - THREAD_COUNT = atoi(argv[2]); - if( (THREAD_COUNT < 1) || (THREAD_COUNT > MAXIMUM_WAIT_OBJECTS) ) - { - printf("\nInvalid THREAD_COUNT number, Pass greater than 1 and less than %d\n", MAXIMUM_WAIT_OBJECTS); - return -1; - } - - REPEAT_COUNT = atoi(argv[3]); - if( REPEAT_COUNT < 1) - { - printf("\nMain Process:Invalid REPEAT_COUNT number, Pass greater than 1\n"); - return -1; - } - - RELATION_ID = atoi(argv[4]); - if( RELATION_ID < 1) - { - printf("\nMain Process:Invalid RELATION_ID number, Pass greater than 1\n"); - return -1; - } - - if(argc == 6) - { - strncpy(objectSuffix, argv[5], MAX_PATH-1); - } - - return 0; -} - - int __cdecl main(INT argc, CHAR **argv) -{ - unsigned int i = 0; - HANDLE hThread[MAXIMUM_WAIT_OBJECTS]; - DWORD threadId[MAXIMUM_WAIT_OBJECTS]; - - char ObjName[MAX_PATH] = "SHARED_SEMAPHORE"; - DWORD dwParam = 0; - - int returnCode = 0; - - /* Variables to capture the file name and the file pointer at thread level*/ - char fileName[MAX_PATH]; - FILE *pFile = NULL; - struct statistics* buffer = NULL; - int statisticsSize = 0; - - /* Variables to capture the file name and the file pointer at process level*/ - char processFileName[MAX_PATH]; - FILE *pProcessFile = NULL; - struct ProcessStats processStats; - DWORD dwStartTime; - - testStatus = PASS; - - ZeroMemory( objectSuffix, MAX_PATH ); - - if(0 != (PAL_Initialize(argc, argv))) - { - return ( FAIL ); - } - - if(GetParameters(argc, argv)) - { - Fail("Error in obtaining the parameters\n"); - } -// Trace("Process created, value of process count is [%d]\n", USE_PROCESS_COUNT); - - if(argc == 6) - { - strncat(ObjName , objectSuffix, MAX_PATH - (sizeof(ObjName) + 1) ); - } - - /* Register the start time */ - dwStartTime = GetTickCount(); - processStats.relationId = RELATION_ID; - processStats.processId = USE_PROCESS_COUNT; - - _snprintf(processFileName, MAX_PATH, "%d_process_semaphore_%d_.txt", USE_PROCESS_COUNT, RELATION_ID); - pProcessFile = fopen(processFileName, "w+"); - if(pProcessFile == NULL) - { - Fail("Error in opening process File file for write for process [%d]\n", USE_PROCESS_COUNT); - } - - statisticsSize = sizeof(struct statistics); - - _snprintf(fileName, MAX_PATH, "%d_thread_semaphore_%d_.txt", USE_PROCESS_COUNT, RELATION_ID); - pFile = fopen(fileName, "w+"); - if(pFile == NULL) - { - Fail("Error in opening file for write for process [%d]\n", USE_PROCESS_COUNT); - } - // For each thread we will log operations failed (int), passed (int), total (int) - // and number of ticks (DWORD) for the operations - resultBuffer = new ResultBuffer( THREAD_COUNT, statisticsSize); - - /* Create Start Tests event */ - StartTestsEvHandle = CreateEvent( NULL, /* lpEventAttributes*/ - TRUE, /* bManualReset */ - FALSE, /* bInitialState */ - NULL); /* name of Event */ - - if( StartTestsEvHandle == NULL ) - { - Fail("Error:%d: Unexpected failure " - "to create %s Event for process count %d\n", GetLastError(), sTmpEventName, USE_PROCESS_COUNT ); - - } - - hSemaphoreHandle = CreateSemaphore( - NULL, /* lpSemaphoreAttributes */ - lInitialCount, /*lInitialCount*/ - lMaximumCount, /*lMaximumCount */ - ObjName - ); - - - if( (hSemaphoreHandle == NULL) || (GetLastError() != ERROR_ALREADY_EXISTS) ) - { - Fail("Unable to create Semaphore handle for process id [%d], returned error [%d], expected ERROR_ALREADY_EXISTS\n", i, GetLastError()); - } - - /* We already assume that the Semaphore was created previously*/ - - for( i = 0; i < THREAD_COUNT; i++ ) - { - dwParam = (int) i; - //Create thread - hThread[i] = CreateThread( - NULL, /* no security attributes */ - 0, /* use default stack size */ - (LPTHREAD_START_ROUTINE)Run_Thread,/* thread function */ - (LPVOID)dwParam, /* argument to thread function */ - 0, /* use default creation flags */ - &threadId[i] /* returns the thread identifier*/ - ); - - if(hThread[i] == NULL) - { - Fail("Create Thread failed for %d process, and GetLastError value is %d\n", USE_PROCESS_COUNT, GetLastError()); - } - } - - if (!SetEvent(StartTestsEvHandle)) - { - Fail("Set Event for Start Tests failed for %d process, and GetLastError value is %d\n", USE_PROCESS_COUNT, GetLastError()); - } - - /* Test running */ - returnCode = WaitForMultipleObjects( THREAD_COUNT, hThread, TRUE, INFINITE); - - if( WAIT_OBJECT_0 != returnCode ) - { - Trace("Wait for Object(s) for %d process returned %d, and GetLastError value is %d\n", USE_PROCESS_COUNT, returnCode, GetLastError()); - testStatus = FAIL; - } - - processStats.operationTime = GetTimeDiff(dwStartTime); - - /* Write to a file*/ - if(pFile!= NULL) - { - for( i = 0; i < THREAD_COUNT; i++ ) - { - buffer = (struct statistics *)resultBuffer->getResultBuffer(i); - returnCode = fprintf(pFile, "%d,%d,%d,%d,%lu,%d\n", buffer->processId, buffer->operationsFailed, buffer->operationsPassed, buffer->operationsTotal, buffer->operationTime, buffer->relationId ); -// Trace("Iteration %d over\n", i); - - } - } - fclose(pFile); - /* Logging for the test case over, clean up the handles */ - -// Trace("Test Thread %d done\n", USE_PROCESS_COUNT); - for( i = 0; i < THREAD_COUNT; i++ ) - { - if(!CloseHandle(hThread[i]) ) - { - Trace("Error:%d: CloseHandle failed for Process [%d] hThread[%d]\n", GetLastError(), USE_PROCESS_COUNT, i); - testStatus = FAIL; - } - } - - if(!CloseHandle(StartTestsEvHandle)) - { - Trace("Error:%d: CloseHandle failed for Process [%d] StartTestsEvHandle\n", GetLastError(), USE_PROCESS_COUNT); - testStatus = FAIL; - } - - if(!CloseHandle(hSemaphoreHandle)) - { - Trace("Error:%d: CloseHandle failed for Process [%d] hSemaphoreHandle\n", GetLastError(), USE_PROCESS_COUNT); - testStatus = FAIL; - } - - PAL_Terminate(); - return PASS; -} - -void PALAPI Run_Thread (LPVOID lpParam) -{ - unsigned int i = 0; - DWORD dwWaitResult; - - int Id=(int)lpParam; - - struct statistics stats; - DWORD dwStartTime; - - stats.relationId = RELATION_ID; - stats.processId = USE_PROCESS_COUNT; - stats.operationsFailed = 0; - stats.operationsPassed = 0; - stats.operationsTotal = 0; - stats.operationTime = 0; - - dwWaitResult = WaitForSingleObject( - StartTestsEvHandle, // handle to start test handle - TIMEOUT); - - if(dwWaitResult != WAIT_OBJECT_0) - { - Fail("Error while waiting for StartTest Event@ thread %d, RC is %d, Error is %d\n", Id, dwWaitResult, GetLastError()); - } - - dwStartTime = GetTickCount(); - - for( i = 0; i < REPEAT_COUNT; i++ ) - { - dwWaitResult = WaitForSingleObject( - hSemaphoreHandle, // handle to Semaphore - TIMEOUT); - - if(dwWaitResult != WAIT_OBJECT_0) - { -// Trace("Error while waiting for onject @ thread %d, # iter %d, RC is %d, Error is %d\n", Id, i, dwWaitResult, GetLastError()); - stats.operationsFailed += 1; - stats.operationsTotal += 1; - testStatus = FAIL; - continue; - } - if (! ReleaseSemaphore(hSemaphoreHandle, 1, NULL)) - { - // Deal with error. - // Trace("Error while releasing Semaphore @ thread %d # iter %d\n", Id, i); - stats.operationsFailed += 1; - stats.operationsTotal += 1; - // Probably need to have while true loop to attempt to release semaphore.. - testStatus = FAIL; - continue; - } - - stats.operationsTotal += 1; - stats.operationsPassed += 1; -// Trace("Successs while releasing Semaphore @ iteration %d -> thread %d -> Process %d\n", i, Id, USE_PROCESS_COUNT); - - } - - stats.operationTime = GetTimeDiff(dwStartTime); - if(resultBuffer->LogResult(Id, (char *)&stats)) - { - Fail("Error:%d: while writing to shared memory, Thread Id is[%d] and Process id is [%d]\n", GetLastError(), Id, USE_PROCESS_COUNT); - } - // Trace("Thread %d over for process %d\n", Id, USE_PROCESS_COUNT); -} diff --git a/src/pal/tests/palsuite/composite/synchronization/CMakeLists.txt b/src/pal/tests/palsuite/composite/synchronization/CMakeLists.txt deleted file mode 100644 index cffb4f78a..000000000 --- a/src/pal/tests/palsuite/composite/synchronization/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(criticalsection) -add_subdirectory(nativecriticalsection) -add_subdirectory(nativecs_interlocked) - diff --git a/src/pal/tests/palsuite/composite/synchronization/criticalsection/CMakeLists.txt b/src/pal/tests/palsuite/composite/synchronization/criticalsection/CMakeLists.txt deleted file mode 100644 index e6b6b0c80..000000000 --- a/src/pal/tests/palsuite/composite/synchronization/criticalsection/CMakeLists.txt +++ /dev/null @@ -1,18 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - criticalsection.cpp - mainWrapper.cpp -) - -add_executable(paltest_synchronization_criticalsection - ${SOURCES} -) - -add_dependencies(paltest_synchronization_criticalsection coreclrpal) - -target_link_libraries(paltest_synchronization_criticalsection - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/composite/synchronization/criticalsection/criticalsection.cpp b/src/pal/tests/palsuite/composite/synchronization/criticalsection/criticalsection.cpp deleted file mode 100644 index 2fcd363e8..000000000 --- a/src/pal/tests/palsuite/composite/synchronization/criticalsection/criticalsection.cpp +++ /dev/null @@ -1,418 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source: criticalsection.c -** -** Purpose: Test Critical Section Reengineering PAL Effort -** -** PseudoCode: - Preparation: - Create PROCESS_COUNT processes. - In each process create a Critical Section - - Test: - Create THREAD_COUNT threads. - In a loop repeated REPEAT_COUNT times: - Enter Critical Section - Do Work - Leave Critical Section - The main thread waits for all of the created threads to exit (WFMO wait all on the created thread handles) and call DeleteCriticalSection - - Parameters: - PROCESS_COUNT: Number of processes - THREAD_COUNT: Number of threads in each process - REPEAT_COUNT: The number of times to execute the loop.. - - Statistics Captured: - Total elapsed time - MTBF - - Scenario: - Single Process with Multiple threads. Main thread creates critical section. - All other threads call EnterCriticalSection. When thread enters critical section - it does some work and leaves critical section. - -** Dependencies: - CreateThread -** InitializeCriticalSection -** EnterCriticalSection -** LeaveCriticalSection -** DeleteCriticalSection -** WaitForSingleObject -** -** Author: rameshg -** -** -**=========================================================*/ - -#include -#include "resultbuffer.h" - -//Global Variables -DWORD dwThreadId; -long long GLOBAL_COUNTER ; -HANDLE g_hEvent; - -/* Test Input Variables */ -unsigned int USE_PROCESS_COUNT = 0; -unsigned int THREAD_COUNT = 0; -unsigned int REPEAT_COUNT = 0; -unsigned int SLEEP_LENGTH = 0; -unsigned int RELATION_ID = 0; - - -CRITICAL_SECTION CriticalSectionM; /* Critical Section Object (used as mutex) */ - - -/* Capture statistics for each worker thread */ -struct statistics{ - unsigned int processId; - unsigned int operationsFailed; - unsigned int operationsPassed; - unsigned int operationsTotal; - DWORD operationTime; //Milliseconds - unsigned int relationId; -}; - - -/*Capture Statistics at a Process level*/ -struct processStatistics{ - unsigned int processId; - DWORD operationTime; //Milliseconds - unsigned int relationId; -}; - - -ResultBuffer *resultBuffer; - -//function declarations -int GetParameters( int , char **); -void setup (void); -void cleanup(void); -void incrementCounter(void); -DWORD PALAPI enterandleavecs( LPVOID ); - - -/* -*Setup for the test case -*/ - -VOID -setup(VOID) -{ - -g_hEvent = CreateEvent(NULL,TRUE,FALSE, NULL); -if(g_hEvent == NULL) -{ - Fail("Create Event Failed\n" - "GetLastError returned %d\n", GetLastError()); -} - -GLOBAL_COUNTER=0; -/* -* Create mutual exclusion mechanisms -*/ -InitializeCriticalSection ( &CriticalSectionM ); - -} - - -/* -* Cleanup for the test case -*/ -VOID -cleanup(VOID) -{ - /* - * Clean up Critical Section object - */ - DeleteCriticalSection(&CriticalSectionM); - PAL_Terminate(); -} - - -/*function that increments a counter*/ -VOID -incrementCounter(VOID) -{ - - if (INT_MAX==GLOBAL_COUNTER) - GLOBAL_COUNTER=0; - - GLOBAL_COUNTER++; - -} - -/* - * Enter and Leave Critical Section - */ -DWORD -PALAPI -enterandleavecs( LPVOID lpParam ) -{ - - struct statistics stats; - int loopcount = REPEAT_COUNT; - int i; - DWORD dwStart =0; - - int Id=(int)lpParam; - - //initialize strucutre to hold thread level statistics - stats.relationId = RELATION_ID; - stats.processId = USE_PROCESS_COUNT; - stats.operationsFailed = 0; - stats.operationsPassed = 0; - stats.operationsTotal = 0; - stats.operationTime = 0; - - //Wait for main thread to signal event - if (WAIT_OBJECT_0 != WaitForSingleObject(g_hEvent,INFINITE)) - { - Fail ("readfile: Wait for Single Object (g_hEvent) failed. Failing test.\n" - "GetLastError returned %d\n", GetLastError()); - } - - //Collect operation start time - dwStart = GetTickCount(); - - //Operation starts loopcount times - for(i = 0; i < loopcount; i++) - { - - EnterCriticalSection(&CriticalSectionM); - /* - *Do Some Thing once you enter critical section - */ - incrementCounter(); - LeaveCriticalSection(&CriticalSectionM); - - stats.operationsPassed++; - stats.operationsTotal++; - } - //collect operation end time - stats.operationTime = GetTickCount() - dwStart; - - /*Trace("\n\n\n\nOperation Time %d\n", stats.operationTime); - Trace("Operation Passed %d\n", stats.operationsPassed); - Trace("Operation Total %d\n", stats.operationsTotal); - Trace("Operation Failed %d\n", stats.operationsFailed); */ - - if(resultBuffer->LogResult(Id, (char *)&stats)) - { - Fail("Error while writing to shared memory, Thread Id is[%d] and Process id is [%d]\n", Id, USE_PROCESS_COUNT); - } - - - return 0; -} - - -int __cdecl main (int argc, char **argv) -{ - -/* -* Parameter to the threads that will be created -*/ -DWORD dwThrdParam = 0; -HANDLE hThread[64]; -unsigned int i = 0; -DWORD dwStart; - -/* Variables to capture the file name and the file pointer*/ -char fileName[MAX_PATH_FNAME]; -char processFileName[MAX_PATH_FNAME]; -FILE *hFile,*hProcessFile; -struct processStatistics processStats; - -struct statistics* buffer; -int statisticsSize = 0; - -/* -* PAL Initialize -*/ -if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - -if(GetParameters(argc, argv)) - { - Fail("Error in obtaining the parameters\n"); - } - - -/*setup file for process result collection */ -_snprintf(processFileName, MAX_PATH_FNAME, "%d_process_criticalsection_%d_.txt", USE_PROCESS_COUNT, RELATION_ID); -hProcessFile = fopen(processFileName, "w+"); -if(hProcessFile == NULL) - { - Fail("Error in opening file to write process results for process [%d]\n", USE_PROCESS_COUNT); - } - -//Initialize Process Stats Variables -processStats.operationTime = 0; -processStats.processId = USE_PROCESS_COUNT; -processStats.relationId = RELATION_ID; //Will change later - -//Start Process Time Capture -dwStart = GetTickCount(); - -//setup file for thread result collection -statisticsSize = sizeof(struct statistics); -_snprintf(fileName, MAX_PATH_FNAME, "%d_thread_criticalsection_%d_.txt", USE_PROCESS_COUNT, RELATION_ID); -hFile = fopen(fileName, "w+"); -if(hFile == NULL) -{ - Fail("Error in opening file for write for process [%d]\n", USE_PROCESS_COUNT); -} - -// For each thread we will log operations failed (int), passed (int), total (int) -// and number of ticks (DWORD) for the operations -resultBuffer = new ResultBuffer( THREAD_COUNT, statisticsSize); - -/* -* Call the Setup Routine -*/ -setup(); - -//Create Thread Count Worker Threads - -while (i< THREAD_COUNT) -{ - dwThrdParam = i; - - hThread[i] = CreateThread( - NULL, - 0, - enterandleavecs, - (LPVOID)dwThrdParam, - 0, - &dwThreadId); - - if ( NULL == hThread[i] ) - { - Fail ( "CreateThread() returned NULL. Failing test.\n" - "GetLastError returned %d\n", GetLastError()); - } - i++; -} - -/* -* Set Event to signal all threads to start using the CS -*/ - -if (0==SetEvent(g_hEvent)) -{ - Fail ( "SetEvent returned Zero. Failing test.\n" - "GetLastError returned %d\n", GetLastError()); -} - -/* - * Wait for worker threads to complete - * - */ -if ( WAIT_OBJECT_0 != WaitForMultipleObjects (THREAD_COUNT,hThread,TRUE, INFINITE)) -{ - Fail ( "WaitForMultipleObject Failed. Failing test.\n" - "GetLastError returned %d\n", GetLastError()); -} - - -//Get the end time of the process -processStats.operationTime = GetTickCount() - dwStart; - -//Write Process Result Contents to File -if(hProcessFile!= NULL) - { - fprintf(hProcessFile, "%d,%lu,%d\n", processStats.processId, processStats.operationTime, processStats.relationId ); - } - -if (0!=fclose(hProcessFile)) -{ - Fail("Unable to write process results to file" - "GetLastError returned %d\n", GetLastError()); -} - - -/*Write Threads Results to a file*/ -if(hFile!= NULL) -{ - for( i = 0; i < THREAD_COUNT; i++ ) - { - buffer = (struct statistics *)resultBuffer->getResultBuffer(i); - fprintf(hFile, "%d,%d,%d,%d,%lu,%d\n", buffer->processId, buffer->operationsFailed, buffer->operationsPassed, buffer->operationsTotal, buffer->operationTime, buffer->relationId ); - //Trace("Iteration %d over\n", i); - } -} - -if (0!=fclose(hFile)) -{ - Fail("Unable to write thread results to file" - "GetLastError returned %d\n", GetLastError()); -} - - /* Logging for the test case over, clean up the handles */ - //Trace("Contents of the buffer are [%s]\n", resultBuffer->getResultBuffer()); - - -//Call Cleanup for Test Case -cleanup(); - -//Trace("Value of GLOBAL COUNTER %d \n", GLOBAL_COUNTER); -return (PASS); - -} - - -int GetParameters( int argc, char **argv) -{ - - if( (argc != 5) || ((argc == 1) && !strcmp(argv[1],"/?")) - || !strcmp(argv[1],"/h") || !strcmp(argv[1],"/H")) - { - printf("PAL -Composite Critical Section Test\n"); - printf("Usage:\n"); - printf("\t[PROCESS_COUNT] Greater than or Equal to 1 \n"); - printf("\t[WORKER_THREAD_MULTIPLIER_COUNT] Greater than or Equal to 1 and Less than or Equal to 64 \n"); - printf("\t[REPEAT_COUNT] Greater than or Equal to 1\n"); - printf("\t[RELATION_ID [Greater than or Equal to 1]\n"); - return -1; - } - -// Trace("Args 1 is [%s], Arg 2 is [%s], Arg 3 is [%s]\n", argv[1], argv[2], argv[3]); - - USE_PROCESS_COUNT = atoi(argv[1]); - if( USE_PROCESS_COUNT < 0) - { - printf("\nPROCESS_COUNT to greater than or equal to 1\n"); - return -1; - } - - THREAD_COUNT = atoi(argv[2]); - if( THREAD_COUNT < 1 || THREAD_COUNT > 64) - { - printf("\nTHREAD_COUNT to be greater than or equal to 1 or less than or equal to 64\n"); - return -1; - } - - REPEAT_COUNT = atoi(argv[3]); - if( REPEAT_COUNT < 1) - { - printf("\nREPEAT_COUNT to greater than or equal to 1\n"); - return -1; - } - - RELATION_ID = atoi(argv[4]); - if( RELATION_ID < 1) - { - printf("\nMain Process:Invalid RELATION_ID number, Pass greater than 1\n"); - return -1; - } - - return 0; -} - diff --git a/src/pal/tests/palsuite/composite/synchronization/criticalsection/mainWrapper.cpp b/src/pal/tests/palsuite/composite/synchronization/criticalsection/mainWrapper.cpp deleted file mode 100644 index 4bc2f3d83..000000000 --- a/src/pal/tests/palsuite/composite/synchronization/criticalsection/mainWrapper.cpp +++ /dev/null @@ -1,255 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/* -Source Code: mainWrapper.c - -mainWrapper.c creates Composite Test Case Processes and waits for all processes to get over - -Algorithm -o Create PROCESS_COUNT processes. - -Author: RameshG -*/ - -#include -#include "resulttime.h" - -/* Test Input Variables */ -unsigned int USE_PROCESS_COUNT = 0; //default -unsigned int THREAD_COUNT = 0; //default -unsigned int REPEAT_COUNT = 0; //default -unsigned int SLEEP_LENGTH = 0; //default -unsigned int RELATION_ID = 1001; - - -//Strucuture to capture application wide statistics -struct applicationStatistics{ - DWORD operationTime; - unsigned int relationId; - unsigned int processCount; - unsigned int threadCount; - unsigned int repeatCount; - char* buildNumber; - -}; - - -//Get parameters from the commandline -int GetParameters( int argc, char **argv) -{ - - if( (argc != 5) || ((argc == 1) && !strcmp(argv[1],"/?")) - || !strcmp(argv[1],"/h") || !strcmp(argv[1],"/H")) - { - printf("Main Wrapper PAL -Composite Critical Section Test\n"); - printf("Usage:\n"); - printf("\t[PROCESS_COUNT] Greater than or Equal to 1 \n"); - printf("\t[THREAD_COUNT] Greater than or Equal to 1 and Less than or Equal to 64 \n"); - printf("\t[REPEAT_COUNT] Greater than or Equal to 1\n"); - printf("\t[RELATION_ID [Greater than or Equal to 1]\n"); - - return -1; - } - - USE_PROCESS_COUNT = atoi(argv[1]); - if( USE_PROCESS_COUNT < 0) - { - printf("\nPROCESS_COUNT to greater than or equal to 1\n"); - return -1; - } - - THREAD_COUNT = atoi(argv[2]); - if( THREAD_COUNT < 1 || THREAD_COUNT > 64) - { - printf("\nTHREAD_COUNT to be greater than or equal to 1 or less than or equal to 64\n"); - return -1; - } - - REPEAT_COUNT = atoi(argv[3]); - if( REPEAT_COUNT < 1) - { - printf("\nREPEAT_COUNT to greater than or equal to 1\n"); - return -1; - } - - RELATION_ID = atoi(argv[4]); - if( RELATION_ID < 1) - { - printf("\nMain Process:Invalid RELATION_ID number, Pass greater than 1\n"); - return -1; - } - - - - - return 0; -} - -//Main entry point for the application - int __cdecl main(INT argc, CHAR **argv) -{ - unsigned int i = 0; - HANDLE hProcess[MAXIMUM_WAIT_OBJECTS]; //Array to hold Process handles - DWORD processReturnCode = 0; - int testReturnCode = PASS; - STARTUPINFO si[MAXIMUM_WAIT_OBJECTS]; - PROCESS_INFORMATION pi[MAXIMUM_WAIT_OBJECTS]; - FILE *hFile; //handle to application results file - char fileName[MAX_PATH]; //file name of the application results file - struct applicationStatistics appStats; - DWORD dwStart=0; //to store the tick count - char lpCommandLine[MAX_PATH] = ""; - int returnCode = 0; - - if(0 != (PAL_Initialize(argc, argv))) - { - return ( FAIL ); - } - - - - - if(GetParameters(argc, argv)) - { - Fail("Error in obtaining the parameters\n"); - } - - //Initialize Application Statistics Strucuture - appStats.operationTime=0; - appStats.relationId = RELATION_ID; - appStats.processCount = USE_PROCESS_COUNT; - appStats.threadCount = THREAD_COUNT; - appStats.repeatCount = REPEAT_COUNT; - appStats.buildNumber = getBuildNumber(); - - -_snprintf(fileName, MAX_PATH, "main_criticalsection_%d_.txt", RELATION_ID); - -hFile = fopen(fileName, "w+"); - -if(hFile == NULL) - { - Fail("Error in opening file to write application results for Critical Section Test, and error code is %d\n", GetLastError()); - } - -//Start Process Time Capture -dwStart = GetTickCount(); - -for( i = 0; i < USE_PROCESS_COUNT; i++ ) - { - - ZeroMemory( lpCommandLine, MAX_PATH ); - if ( _snprintf( lpCommandLine, MAX_PATH-1, "criticalsection %d %d %d %d", i, THREAD_COUNT, REPEAT_COUNT, RELATION_ID) < 0 ) - { - Trace ("Error: Insufficient commandline string length for for iteration [%d]\n", i); - } - - /* Zero the data structure space */ - ZeroMemory ( &pi[i], sizeof(pi[i]) ); - ZeroMemory ( &si[i], sizeof(si[i]) ); - - /* Set the process flags and standard io handles */ - si[i].cb = sizeof(si[i]); - - //Printing the Command Line - //Trace("Command Line \t %s \n", lpCommandLine); - - //Create Process - if(!CreateProcess( NULL, /* lpApplicationName*/ - lpCommandLine, /* lpCommandLine */ - NULL, /* lpProcessAttributes */ - NULL, /* lpThreadAttributes */ - TRUE, /* bInheritHandles */ - 0, /* dwCreationFlags, */ - NULL, /* lpEnvironment */ - NULL, /* pCurrentDirectory */ - &si[i], /* lpStartupInfo */ - &pi[i] /* lpProcessInformation */ - )) - { - Fail("Process Not created for [%d] and failed with error code %d\n", i, GetLastError()); - } - else - { - hProcess[i] = pi[i].hProcess; - //Trace("Process created for [%d]\n", i); - } - - } - - returnCode = WaitForMultipleObjects( USE_PROCESS_COUNT, hProcess, TRUE, INFINITE); - if( WAIT_OBJECT_0 != returnCode ) - { - Trace("Wait for Object(s) @ Main thread for %d processes returned %d, and GetLastError value is %d\n", USE_PROCESS_COUNT, returnCode, GetLastError()); - testReturnCode = FAIL; - } - - for( i = 0; i < USE_PROCESS_COUNT; i++ ) - { - /* check the exit code from the process */ - if( ! GetExitCodeProcess( pi[i].hProcess, &processReturnCode ) ) - { - Trace( "GetExitCodeProcess call failed for iteration %d with error code %u\n", - i, GetLastError() ); - - testReturnCode = FAIL; - } - - if(processReturnCode == FAIL) - { - Trace( "Process [%d] failed and returned FAIL\n", i); - testReturnCode = FAIL; - } - - if(!CloseHandle(pi[i].hThread)) - { - Trace("Error:%d: CloseHandle failed for Process [%d] hThread\n", GetLastError(), i); - testReturnCode = FAIL; - } - - if(!CloseHandle(pi[i].hProcess) ) - { - Trace("Error:%d: CloseHandle failed for Process [%d] hProcess\n", GetLastError(), i); - testReturnCode = FAIL; - } - } - -//Get the end time of the process -appStats.operationTime = GetTickCount() - dwStart; - -if( testReturnCode == PASS) - { - Trace("Test Passed\n"); - - } - else - { - Fail("Test Failed\n"); - - } - -//Write Process Result Contents to File -if(hFile!= NULL) - { - fprintf(hFile, "%lu,%d,%d,%d,%d,%s\n", appStats.operationTime, appStats.relationId,appStats.processCount, appStats.threadCount, appStats.repeatCount, appStats.buildNumber); - } - -if (0!=fclose(hFile)) -{ - Trace("Error:%d: fclose failed for file %s\n", GetLastError(), fileName); -} - - PAL_Terminate(); - -if( testReturnCode == PASS) -{ - return PASS; -} -else -{ - return FAIL; -} - -} diff --git a/src/pal/tests/palsuite/composite/synchronization/criticalsection/readme.txt b/src/pal/tests/palsuite/composite/synchronization/criticalsection/readme.txt deleted file mode 100644 index af6ef5d23..000000000 --- a/src/pal/tests/palsuite/composite/synchronization/criticalsection/readme.txt +++ /dev/null @@ -1,11 +0,0 @@ -To compile: - -1) create a dat file (say criticalsection.dat) with contents: -PAL,Composite,palsuite\composite\syncronization\criticalsection,criticalsection=mainWrapper.c,criticalsection.c,,, - -2) perl rrunmod.pl -r criticalsection.dat - - -To execute: -mainwrapper [PROCESS_COUNT] [WORKER_THREAD_MULTIPLIER_COUNT] [REPEAT_COUNT] - diff --git a/src/pal/tests/palsuite/composite/synchronization/nativecriticalsection/CMakeLists.txt b/src/pal/tests/palsuite/composite/synchronization/nativecriticalsection/CMakeLists.txt deleted file mode 100644 index 5a2a50313..000000000 --- a/src/pal/tests/palsuite/composite/synchronization/nativecriticalsection/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - mtx_critsect.cpp - pal_composite_native_cs.cpp - resultbuffer.cpp -) - -add_executable(paltest_synchronization_nativecriticalsection - ${SOURCES} -) - -add_dependencies(paltest_synchronization_nativecriticalsection coreclrpal) - -target_link_libraries(paltest_synchronization_nativecriticalsection - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/composite/synchronization/nativecriticalsection/mtx_critsect.cpp b/src/pal/tests/palsuite/composite/synchronization/nativecriticalsection/mtx_critsect.cpp deleted file mode 100644 index 790c89f96..000000000 --- a/src/pal/tests/palsuite/composite/synchronization/nativecriticalsection/mtx_critsect.cpp +++ /dev/null @@ -1,111 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -//#include -#include -#include "mtx_critsect.h" - -CsWaiterReturnState MTXWaitOnCS(LPCRITICAL_SECTION lpCriticalSection); -void MTXDoActualWait(LPCRITICAL_SECTION lpCriticalSection); -void MTXWakeUpWaiter(LPCRITICAL_SECTION lpCriticalSection); - -/*extern "C" { - LONG InterlockedCompareExchange( - LONG volatile *Destination, - LONG Exchange, - LONG Comperand); -} -*/ -int MTXInitializeCriticalSection(LPCRITICAL_SECTION lpCriticalSection) -{ - int retcode = 0; - - lpCriticalSection->DebugInfo = NULL; - lpCriticalSection->LockCount = 0; - lpCriticalSection->RecursionCount = 0; - lpCriticalSection->SpinCount = 0; - lpCriticalSection->OwningThread = NULL; - - lpCriticalSection->LockSemaphore = (HANDLE)&lpCriticalSection->NativeData; - - if (0!= pthread_mutex_init(&lpCriticalSection->NativeData.Mutex, NULL)) - { - printf("Error Initializing Critical Section\n"); - retcode = -1; - } - - - lpCriticalSection->InitCount = CS_INITIALIZED; - return retcode; -} - -int MTXDeleteCriticalSection(LPCRITICAL_SECTION lpCriticalSection) -{ - int retcode = 0; - - if (lpCriticalSection->InitCount == CS_INITIALIZED) - { - - if (0!=pthread_mutex_destroy(&lpCriticalSection->NativeData.Mutex)) - { - printf("Error Deleting Critical Section\n"); - retcode = -1; - } - } - - lpCriticalSection->InitCount = CS_NOT_INIZIALIZED; - return retcode; -} - -int MTXEnterCriticalSection(LPCRITICAL_SECTION lpCriticalSection) -{ - - DWORD thread_id; - int retcode = 0; - - thread_id = (DWORD)THREADSilentGetCurrentThreadId(); - - /* check if the current thread already owns the criticalSection */ - if (lpCriticalSection->OwningThread == (HANDLE)thread_id) - { - lpCriticalSection->RecursionCount++; - //Check if this is a failure condition - return 0; - } - - if (0!= pthread_mutex_lock(&lpCriticalSection->NativeData.Mutex)) - { - //Error Condition - printf("Error Entering Critical Section\n"); - retcode = -1; - } - else - { - lpCriticalSection->OwningThread = (HANDLE)thread_id; - lpCriticalSection->RecursionCount = 1; - } - - return retcode; -} - -int MTXLeaveCriticalSection(LPCRITICAL_SECTION lpCriticalSection) -{ - int retcode = 0; - - if (--lpCriticalSection->RecursionCount > 0) - //*****check this ***** - return 0; - - lpCriticalSection->OwningThread = 0; - - if (0!= pthread_mutex_unlock(&lpCriticalSection->NativeData.Mutex)) - { - //Error Condition - printf("Error Leaving Critical Section\n"); - retcode = -1; - } - - return retcode; -} - diff --git a/src/pal/tests/palsuite/composite/synchronization/nativecriticalsection/mtx_critsect.h b/src/pal/tests/palsuite/composite/synchronization/nativecriticalsection/mtx_critsect.h deleted file mode 100644 index bc44ad8ec..000000000 --- a/src/pal/tests/palsuite/composite/synchronization/nativecriticalsection/mtx_critsect.h +++ /dev/null @@ -1,51 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#include - -typedef void VOID; -typedef unsigned long DWORD; -typedef long LONG; -typedef unsigned long ULONG; -typedef void* HANDLE; -typedef unsigned long ULONG_PTR; - -#define FALSE 0 -#define TRUE 1 - -#define CSBIT_CS_IS_LOCKED 1 -#define CSBIT_NEW_WAITER 2 - -typedef enum CsInitState { CS_NOT_INIZIALIZED, CS_INITIALIZED, CS_FULLY_INITIALIZED } CsInitState; -typedef enum _CsWaiterReturnState { CS_WAITER_WOKEN_UP, CS_WAITER_DIDNT_WAIT } CsWaiterReturnState; - -typedef struct _CRITICAL_SECTION_DEBUG_INFO { - LONG volatile ContentionCount; - LONG volatile InternalContentionCount; - ULONG volatile AcquireCount; - ULONG volatile EnterCount; -} CRITICAL_SECTION_DEBUG_INFO, *PCRITICAL_SECTION_DEBUG_INFO; - -typedef struct _CRITICAL_SECTION_NATIVE_DATA { - pthread_mutex_t Mutex; -} CRITICAL_SECTION_NATIVE_DATA, *PCRITICAL_SECTION_NATIVE_DATA; - -typedef struct _CRITICAL_SECTION { - - CsInitState InitCount; - PCRITICAL_SECTION_DEBUG_INFO DebugInfo; - LONG LockCount; - LONG RecursionCount; - HANDLE OwningThread; - HANDLE LockSemaphore; - ULONG_PTR SpinCount; - CRITICAL_SECTION_NATIVE_DATA NativeData; - -} CRITICAL_SECTION, *PCRITICAL_SECTION, *LPCRITICAL_SECTION; - -int MTXInitializeCriticalSection(LPCRITICAL_SECTION lpCriticalSection); -int MTXDeleteCriticalSection(LPCRITICAL_SECTION lpCriticalSection); -int MTXEnterCriticalSection(LPCRITICAL_SECTION lpCriticalSection); -int MTXLeaveCriticalSection(LPCRITICAL_SECTION lpCriticalSection); - diff --git a/src/pal/tests/palsuite/composite/synchronization/nativecriticalsection/pal_composite_native_cs.cpp b/src/pal/tests/palsuite/composite/synchronization/nativecriticalsection/pal_composite_native_cs.cpp deleted file mode 100644 index 0ccd5c941..000000000 --- a/src/pal/tests/palsuite/composite/synchronization/nativecriticalsection/pal_composite_native_cs.cpp +++ /dev/null @@ -1,467 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#include -#include -#include -#include -#include -//#include -#include "mtx_critsect.cpp" -//#include "mtx_critsect.h" -#include "resultbuffer.h" - - - -#define LONGLONG long long -#define ULONGLONG unsigned LONGLONG -/*Defining Global Variables*/ - -int THREAD_COUNT=0; -int REPEAT_COUNT=0; -int GLOBAL_COUNTER=0; -int USE_PROCESS_COUNT = 0; -int RELATION_ID =0; -int g_counter = 0; -int MAX_PATH = 256; -LONGLONG callibrationValue = 0; - -pthread_mutex_t g_mutex = PTHREAD_MUTEX_INITIALIZER; -pthread_cond_t g_cv = PTHREAD_COND_INITIALIZER; -pthread_cond_t g_cv2 = PTHREAD_COND_INITIALIZER; -CRITICAL_SECTION g_cs; - -/* Capture statistics for each worker thread */ -struct statistics{ - unsigned int processId; - unsigned int operationsFailed; - unsigned int operationsPassed; - unsigned int operationsTotal; - DWORD operationTime; - unsigned int relationId; -}; - - -struct applicationStatistics{ - DWORD operationTime; - unsigned int relationId; - unsigned int processCount; - unsigned int threadCount; - unsigned int repeatCount; - char* buildNumber; - -}; - -ResultBuffer *resultBuffer; - - -void* waitforworkerthreads(void*); -void starttests(int); -int setuptest(void); -int cleanuptest(void); -int GetParameters( int , char **); -void incrementCounter(void); -ULONGLONG GetTicks(void); -ULONGLONG getPerfCallibrationValue(void); - - - -extern int main(int argc, char **argv) - { - //Variable Declaration - pthread_t pthreads[640]; - int threadID[640]; - int i=0; - int j=0; - int rtn=0; - ULONGLONG startTicks = 0; - - /* Variables to capture the file name and the file pointer*/ - char fileName[MAX_PATH]; - FILE *hFile; - struct statistics* buffer; - int statisticsSize = 0; - - /*Variable to Captutre Information at the Application Level*/ - struct applicationStatistics appStats; - char mainFileName[MAX_PATH]; - FILE *hMainFile; - - //Get perfCallibrationValue - - callibrationValue = getPerfCallibrationValue(); - printf("Callibration Value for this Platform %llu \n", callibrationValue); - - - //Get Parameters - if(GetParameters(argc, argv)) - { - printf("Error in obtaining the parameters\n"); - exit(-1); - } - - //Assign Values to Application Statistics Members - appStats.relationId=RELATION_ID; - appStats.operationTime=0; - appStats.buildNumber = "999.99"; - appStats.processCount = USE_PROCESS_COUNT; - appStats.threadCount = THREAD_COUNT; - appStats.repeatCount = REPEAT_COUNT; - - printf("RELATION ID : %d\n", appStats.relationId); - printf("Process Count : %d\n", appStats.processCount); - printf("Thread Count : %d\n", appStats.threadCount); - printf("Repeat Count : %d\n", appStats.repeatCount); - - - //Open file for Application Statistics Collection - snprintf(mainFileName, MAX_PATH, "main_nativecriticalsection_%d_.txt",appStats.relationId); - hMainFile = fopen(mainFileName, "w+"); - - if(hMainFile == NULL) - { - printf("Error in opening main file for write\n"); - } - - - for (i=0;igetResultBuffer(i); - fprintf(hFile, "%d,%d,%d,%d,%lu,%d\n", buffer->processId, buffer->operationsFailed, buffer->operationsPassed, buffer->operationsTotal, buffer->operationTime, buffer->relationId ); - //printf("Iteration %d over\n", i); - } - } - fclose(hFile); - - - - //Call Test Case Cleanup Routine - if (0!=cleanuptest()) - { - //Error Condition - printf("Error Cleaning up Test Case"); - exit(-1); - } - - - if(hMainFile!= NULL) - { - printf("Writing to Main File \n"); - fprintf(hMainFile, "%lu,%d,%d,%d,%d,%s\n", appStats.operationTime, appStats.relationId, appStats.processCount, appStats.threadCount, appStats.repeatCount, appStats.buildNumber); - - } - fclose(hMainFile); - return 0; - } - -void * waitforworkerthreads(void * threadId) -{ - - int *threadParam = (int*) threadId; - -// printf("Thread ID : %d \n", *threadParam); - - //Accquire Lock - if (0!=pthread_mutex_lock(&g_mutex)) - { - //Error Condition - printf("Error Accquiring Mutex Lock in Wait for Worker Thread\n"); - exit(-1); - } - - //Increment Global Counter - GLOBAL_COUNTER++; - - - //If global counter is equal to thread count then signal main thread - if (GLOBAL_COUNTER == THREAD_COUNT) - { - if (0!=pthread_cond_signal(&g_cv2)) - { - //Error Condition - printf("Error in setting conditional variable\n"); - exit(-1); - } - } - - //Wait for main thread to signal - if (0!=pthread_cond_wait(&g_cv,&g_mutex)) - { - //Error Condition - printf("Error waiting on conditional variable in Worker Thread\n"); - exit(-1); - } - - //Release the mutex lock - if (0!=pthread_mutex_unlock(&g_mutex)) - { - //Error Condition - printf("Error Releasing Mutex Lock in Worker Thread\n"); - exit(-1); - } - - //Start the test - starttests(*threadParam); - -} - -void starttests(int threadID) -{ - /*All threads beign executing tests cases*/ - int i = 0; - int Id = threadID; - struct statistics stats; - ULONGLONG startTime = 0; - ULONGLONG endTime = 0; - - - stats.relationId = RELATION_ID; - stats.processId = USE_PROCESS_COUNT; - stats.operationsFailed = 0; - stats.operationsPassed = 0; - stats.operationsTotal = 0; - stats.operationTime = 0; - - //Enter and Leave Critical Section in a loop REPEAT_COUNT Times - - startTime = GetTicks(); - - for (i=0;iLogResult(Id, (char *)&stats)) - { - printf("Error while writing to shared memory, Thread Id is[??] and Process id is [%d]\n", USE_PROCESS_COUNT); - } - -} - -int setuptest(void) -{ - - //Initalize Critical Section - if (0!=MTXInitializeCriticalSection( &g_cs)) - { - return -1; - } - return 0; -} - -int cleanuptest(void) -{ - - //Delete Critical Section - if (0!=MTXDeleteCriticalSection(&g_cs)) - { - return -1; - } - return 0; -} - -int GetParameters( int argc, char **argv) -{ - - if( (argc != 5) || ((argc == 1) && !strcmp(argv[1],"/?")) - || !strcmp(argv[1],"/h") || !strcmp(argv[1],"/H")) - { - printf("PAL -Composite Native Critical Section Test\n"); - printf("Usage:\n"); - printf("\t[PROCESS_ID ( greater than 1] \n"); - printf("\t[THREAD_COUNT ( greater than 1] \n"); - printf("\t[REPEAT_COUNT ( greater than 1]\n"); - printf("\t[RELATION_ID [greater than or Equal to 1]\n"); - return -1; - } - - - USE_PROCESS_COUNT = atoi(argv[1]); - if( USE_PROCESS_COUNT < 0) - { - printf("\nInvalid THREAD_COUNT number, Pass greater than 1\n"); - return -1; - } - - THREAD_COUNT = atoi(argv[2]); - if( THREAD_COUNT < 1) - { - printf("\nInvalid THREAD_COUNT number, Pass greater than 1\n"); - return -1; - } - - REPEAT_COUNT = atoi(argv[3]); - if( REPEAT_COUNT < 1) - { - printf("\nInvalid REPEAT_COUNT number, Pass greater than 1\n"); - return -1; - } - - RELATION_ID = atoi(argv[4]); - if( RELATION_ID < 1) - { - printf("\nInvalid RELATION_ID number, Pass greater than 1\n"); - return -1; - } - - - return 0; -} - -void incrementCounter(void) -{ - g_counter ++; -} - - -//Implementation borrowed from pertrace.c -ULONGLONG GetTicks(void) -{ -#ifdef i386 - unsigned long a, d; - asm volatile("rdtsc":"=a" (a), "=d" (d)); - return ((ULONGLONG)((unsigned int)(d)) << 32) | (unsigned int)(a); -#else - // #error Don''t know how to get ticks on this platform - return (ULONGLONG)gethrtime(); -#endif // i386 -} - - -/**/ -ULONGLONG getPerfCallibrationValue(void) -{ - ULONGLONG startTicks; - ULONGLONG endTicks; - - startTicks = GetTicks(); - sleep(1); - endTicks = GetTicks(); - - return ((endTicks-startTicks)/1000); //Return number of Ticks in One Milliseconds - -} - diff --git a/src/pal/tests/palsuite/composite/synchronization/nativecriticalsection/readme.txt b/src/pal/tests/palsuite/composite/synchronization/nativecriticalsection/readme.txt deleted file mode 100644 index 8d83bf794..000000000 --- a/src/pal/tests/palsuite/composite/synchronization/nativecriticalsection/readme.txt +++ /dev/null @@ -1,19 +0,0 @@ -To compile: - -For FReeBSD Platform use the following to compile: -gcc -pthread -lm -lgcc -lstdc++ -xc++ -Di386 pal_composite_native_cs.c - -For Solaris Platform use the following to compile: -gcc -lpthread -lm -lgcc -lstdc++ -xc++ -D__sparc__ pal_composite_native_cs.c - -For HPUX Platform use the following to compile: -gcc -lpthread -mlp64 -lm -lgcc -lstdc++ -xc++ -D_HPUX_ -D__ia64__ pal_composite_native_cs.c - -To execute: -./a.out [PROCESS_COUNT] [THREAD_COUNT] [REPEAT_COUNT] - - - ./a.out 1 32 1000000 4102406 - - - diff --git a/src/pal/tests/palsuite/composite/synchronization/nativecriticalsection/resultbuffer.cpp b/src/pal/tests/palsuite/composite/synchronization/nativecriticalsection/resultbuffer.cpp deleted file mode 100644 index c9ed9435f..000000000 --- a/src/pal/tests/palsuite/composite/synchronization/nativecriticalsection/resultbuffer.cpp +++ /dev/null @@ -1,69 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -//#include "stdafx.h" -#include "resultbuffer.h" -// -//#using -// -//using namespace System; - - -ResultBuffer:: ResultBuffer(int ThreadCount, int ThreadLogSize) - { - // Declare an internal status variable - int Status=0; - - // Update the maximum thread count - MaxThreadCount = ThreadCount; - - // Allocate the memory buffer based on the passed in thread and process counts - // and the specified size of the thread specific buffer - buffer = NULL; - buffer = (char*)malloc(ThreadCount*ThreadLogSize); - // Check to see if the buffer memory was allocated - if (buffer == NULL) - Status = -1; - // Initialize the buffer to 0 to prevent bogus data - memset(buffer,0,ThreadCount*ThreadLogSize); - - // The ThreadOffset is equal to the total number of bytes that will be stored per thread - ThreadOffset = ThreadLogSize; - - } - - - int ResultBuffer::LogResult(int Thread, char* Data) - { - // Declare an internal status flad - int status = 0; - - // Declare an object to store the offset address into the buffer - int Offset; - - // Check to make sure the Thread index is not out of range - if(Thread > MaxThreadCount) - { - printf("Thread index is out of range, Value of Thread[%d], Value of MaxThreadCount[%d]\n", Thread, MaxThreadCount); - status = -1; - return(status); - } - - // Caculate the offset into the shared buffer based on the process and thread indices - Offset = (Thread)*ThreadOffset; - - // Write the passed in data to the reserved buffer - memcpy(buffer+Offset,Data,ThreadOffset); - - return(status); - } - - - char* ResultBuffer::getResultBuffer(int threadId) - { - - return (buffer + threadId*ThreadOffset); - - } - diff --git a/src/pal/tests/palsuite/composite/synchronization/nativecriticalsection/resultbuffer.h b/src/pal/tests/palsuite/composite/synchronization/nativecriticalsection/resultbuffer.h deleted file mode 100644 index 892095810..000000000 --- a/src/pal/tests/palsuite/composite/synchronization/nativecriticalsection/resultbuffer.h +++ /dev/null @@ -1,43 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#include -#include -//#include -#ifndef _RESULT_BUFFER_H_ -#define _RESULT_BUFFER_H_ - -//#include - -struct ResultData -{ - int value; - int size; -// ResultData* NextResult; -}; - - class ResultBuffer -{ - // Declare a pointer to a memory buffer to store the logged results - char* buffer; - // Declare an object to store the maximum Thread count - int MaxThreadCount; - // Declare and internal data object to store the calculated offset between adjacent threads data sets - int ThreadOffset; - - // Declare a linked list object to store the parameter values -public: - - // Declare a constructor for the single process case - ResultBuffer(int ThreadCount, int ThreadLogSize); - // Declare a method to log data for the single process instance - int LogResult(int Thread, char* Data); - - char* getResultBuffer(int threadId); -}; - -#include "resultbuffer.cpp" -#endif // _RESULT_BUFFER_H_ - - diff --git a/src/pal/tests/palsuite/composite/synchronization/nativecs_interlocked/CMakeLists.txt b/src/pal/tests/palsuite/composite/synchronization/nativecs_interlocked/CMakeLists.txt deleted file mode 100644 index b94209636..000000000 --- a/src/pal/tests/palsuite/composite/synchronization/nativecs_interlocked/CMakeLists.txt +++ /dev/null @@ -1,20 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - interlocked.cpp - mtx_critsect.cpp - pal_composite_native_cs.cpp - resultbuffer.cpp -) - -add_executable(paltest_synchronization_nativecs_interlocked - ${SOURCES} -) - -add_dependencies(paltest_synchronization_nativecs_interlocked coreclrpal) - -target_link_libraries(paltest_synchronization_nativecs_interlocked - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/composite/synchronization/nativecs_interlocked/hpitinterlock.s b/src/pal/tests/palsuite/composite/synchronization/nativecs_interlocked/hpitinterlock.s deleted file mode 100644 index 062f4ebe6..000000000 --- a/src/pal/tests/palsuite/composite/synchronization/nativecs_interlocked/hpitinterlock.s +++ /dev/null @@ -1,168 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*++ - - - -Module Name: - - interlock.s - -Abstract: - - Implementation of Interlocked functions (32 and 64 bits) for the HPUX/Itanium - platform. These functions are processor dependent. - See the i386 implementations for more information. - ---*/ - .file "interlock.s" - .section .text, "ax", "progbits" - .align 16 - .global InterlockedExchangeAdd# - .proc InterlockedExchangeAdd# -InterlockedExchangeAdd: - .body - ld4.nt1 r8 = [r32] - ;; -Iea10: - mov ar.ccv = r8 - add r15 = r33, r8 - mov r14 = r8 - ;; - cmpxchg4.acq r8 = [r32], r15, ar.ccv - ;; - cmp.ne p6,p7 = r8, r14 // check if the target changes? -(p6)br.cond.spnt.few Iea10 // if yes, go back to do it again -(p7)br.ret.sptk.clr b0 - ;; - .endp InterlockedExchangeAdd# - - .align 16 - .global InterlockedIncrement# - .proc InterlockedIncrement# -InterlockedIncrement: - .body - fetchadd4.acq r8 = [r32], 1 - ;; - adds r8 = 1, r8 - br.ret.sptk b0 - ;; - .endp InterlockedIncrement# - - .align 16 - .global InterlockedIncrement64# - .proc InterlockedIncrement64# -InterlockedIncrement64: - .body - fetchadd8.acq r8 = [r32], 1 - ;; - adds r8 = 1, r8 - br.ret.sptk b0 - ;; - .endp InterlockedIncrement64# - - .align 16 - .global InterlockedDecrement# - .proc InterlockedDecrement# -InterlockedDecrement: - .body - fetchadd4.acq r8 = [r32], -1 - ;; - adds r8 = -1, r8 - br.ret.sptk b0 - ;; - .endp InterlockedDecrement# - - .align 16 - .global InterlockedDecrement64# - .proc InterlockedDecrement64# -InterlockedDecrement64: - .body - fetchadd8.acq r8 = [r32], -1 - ;; - adds r8 = -1, r8 - br.ret.sptk b0 - ;; - .endp InterlockedDecrement64# - - .align 16 - .global InterlockedExchange# - .proc InterlockedExchange# -InterlockedExchange: - .body - mf - zxt4 r33 = r33 // sanitize the upper 32 bits - ;; - xchg4 r8 = [r32], r33 - br.ret.sptk b0 - ;; - .endp InterlockedExchange# - - .align 16 - .global InterlockedExchange64# - .proc InterlockedExchange64# -InterlockedExchange64: - .body - mf - xchg8 r8 = [r32], r33 - br.ret.sptk b0 - ;; - .endp InterlockedExchange64# - - .align 16 - .global InterlockedCompareExchange# - .proc InterlockedCompareExchange# -InterlockedCompareExchange: - .body - mf - zxt4 r33 = r33 // sanitize the upper 32 bits - zxt4 r34 = r34 // sanitize the upper 32 bits - ;; - mov ar.ccv = r34 - ;; - cmpxchg4.acq r8 = [r32], r33, ar.ccv - br.ret.sptk.clr b0 - ;; - .endp InterlockedCompareExchange# - - .align 16 - .global InterlockedCompareExchange64# - .proc InterlockedCompareExchange64# -InterlockedCompareExchange64: - .body - mf - mov ar.ccv = r34 - ;; - cmpxchg8.acq r8 = [r32], r33, ar.ccv - br.ret.sptk.clr b0 - ;; - .endp InterlockedCompareExchange64# - -/*++ - DBG_DebugBreak is extracted from DbgBreakPoint function - in debugstb.s from win64. ---*/ - BREAKPOINT_STOP = 0x80016 - .align 16 - .global DBG_DebugBreak# - .proc DBG_DebugBreak# -DBG_DebugBreak: - .body - flushrs - ;; - break.i BREAKPOINT_STOP - br.ret.sptk.clr b0 - ;; - .endp DBG_DebugBreak# - - .align 16 - .global MemoryBarrier# - .proc MemoryBarrier# -MemoryBarrier: - .body - mf - br.ret.sptk.clr b0 - ;; - .endp MemoryBarrier# diff --git a/src/pal/tests/palsuite/composite/synchronization/nativecs_interlocked/interlocked.cpp b/src/pal/tests/palsuite/composite/synchronization/nativecs_interlocked/interlocked.cpp deleted file mode 100644 index b6c1dd7a8..000000000 --- a/src/pal/tests/palsuite/composite/synchronization/nativecs_interlocked/interlocked.cpp +++ /dev/null @@ -1,27 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - - -typedef long LONG; - -extern "C" { -LONG InterlockedCompareExchange( - LONG volatile *Destination, - LONG Exchange, - LONG Comperand) -{ -#ifdef i386 - LONG result; - - __asm__ __volatile__( - "lock; cmpxchgl %2,(%1)" - : "=a" (result) - : "r" (Destination), "r" (Exchange), "0" (Comperand) - : "memory" - ); - - return result; -#endif -} -} diff --git a/src/pal/tests/palsuite/composite/synchronization/nativecs_interlocked/makefile b/src/pal/tests/palsuite/composite/synchronization/nativecs_interlocked/makefile deleted file mode 100644 index 376745aaf..000000000 --- a/src/pal/tests/palsuite/composite/synchronization/nativecs_interlocked/makefile +++ /dev/null @@ -1,70 +0,0 @@ -# -# Use gmake to build this project -# - - -OSNAME=$(shell uname -s) -OSVER=$(shell uname -r | cut -c1-3) -BASEOBJDIR=./obj -TGTDIR=$(BASEOBJDIR)/$(shell uname -m) -COMP=gcc -DEBUGOPT=-D_DEBUG -g -# DEBUGOPT=-DNDEBUG - - -ifeq ($(OSNAME),SunOS) -COPT=-DSUNOS -O2 -finline-functions $(DEBUGOPT) -xc++ -LOPT=-lpthread -lrt -O2 -finline-functions $(DEBUGOPT) -INTERLOCK_OBJ=sparcinterloc.o -else - ifeq ($(OSNAME),FreeBSD) - ifeq ($(OSVER),5.2) - COMP=g++ - COPT=-DFREEBSD -Di386 -O2 -finline-functions $(DEBUGOPT) -xc++ - LOPT=-lkse -O2 -finline-functions $(DEBUGOPT) - else - COPT=-DFREEBSD -Di386 -O2 -finline-functions $(DEBUGOPT) - LOPT=-pthread -O2 -finline-functions $(DEBUGOPT) - endif - INTERLOCK_OBJ=interlocked.o - else - ifeq ($(OSNAME),HP-UX) - COMP=g++ - INTERLOCK_OBJ=hpitinterlock.o - COPT=-DHPUX -O2 -mlp64 -finline -fPIC -DPIC -DBIT64 -D_WIN64 -DLP64COMPATIBLE \ - -D_POSIX_C_SOURCE=199506L -D_HPUX_ -D_XOPEN_SOURCE_EXTENDED -DBIT64 \ - -DBIGENDIAN -D_WIN64 $(DEBUGOPT) -xc++ - LOPT=-O2 -mlp64 -DBIT64 -D_WIN64 -lgcc -lpthread /usr/lib/hpux64/libunwind.so - endif - endif -endif - - -TARGET0=$(TGTDIR)/native_cs_interlocked - -all: dirs $(TARGET0) $(TARGET1) $(TARGET2) $(TARGET3) $(TARGET4) - -dirs: - @echo Target dir: $(TGTDIR) - @if [ \! -d $(BASEOBJDIR) ]; then mkdir $(BASEOBJDIR); fi - @if [ \! -d $(TGTDIR) ]; then mkdir $(TGTDIR); fi - -$(TGTDIR)/native_cs_interlocked: $(TGTDIR)/$(INTERLOCK_OBJ) $(TGTDIR)/native_cs_interlocked.o - $(COMP) $(LOPT) -o $(TARGET0) $(TGTDIR)/native_cs_interlocked.o $(TGTDIR)/$(INTERLOCK_OBJ) - -$(TGTDIR)/native_cs_interlocked.o: pal_composite_native_cs.c - $(COMP) $(COPT) -DFULL_CSIMPL -o $(TGTDIR)/native_cs_interlocked.o -c pal_composite_native_cs.c - -$(TGTDIR)/interlocked.o: interlocked.cpp - $(COMP) $(COPT) -c -o $(TGTDIR)/interlocked.o interlocked.cpp - -$(TGTDIR)/sparcinterloc.o: sparcinterloc.s - $(COMP) -x assembler-with-cpp -c -Wa,-Av9 -o $(TGTDIR)/sparcinterloc.o sparcinterloc.s - -$(TGTDIR)/hpitinterlock.o: hpitinterlock.s - $(COMP) $(COPT) -x assembler-with-cpp -c -fno-strict-aliasing -o $(TGTDIR)/hpitinterlock.o hpitinterlock.s - -clean: - @echo Cleaning - @rm -f $(TGTDIR)/*.o $(TARGET0) $(TARGET1) $(TARGET2) $(TARGET3) $(TARGET4) - @if [ -d $(TGTDIR) ]; then rmdir $(TGTDIR); fi diff --git a/src/pal/tests/palsuite/composite/synchronization/nativecs_interlocked/mtx_critsect.cpp b/src/pal/tests/palsuite/composite/synchronization/nativecs_interlocked/mtx_critsect.cpp deleted file mode 100644 index 69c10e907..000000000 --- a/src/pal/tests/palsuite/composite/synchronization/nativecs_interlocked/mtx_critsect.cpp +++ /dev/null @@ -1,112 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#include - -#include -#include "mtx_critsect.h" - -CsWaiterReturnState MTXWaitOnCS(LPCRITICAL_SECTION lpCriticalSection); -void MTXDoActualWait(LPCRITICAL_SECTION lpCriticalSection); -void MTXWakeUpWaiter(LPCRITICAL_SECTION lpCriticalSection); - -/*extern "C" { - LONG InterlockedCompareExchange( - LONG volatile *Destination, - LONG Exchange, - LONG Comperand); -} -*/ -int MTXInitializeCriticalSection(LPCRITICAL_SECTION lpCriticalSection) -{ - int retcode = 0; - - lpCriticalSection->DebugInfo = NULL; - lpCriticalSection->LockCount = 0; - lpCriticalSection->RecursionCount = 0; - lpCriticalSection->SpinCount = 0; - lpCriticalSection->OwningThread = NULL; - - lpCriticalSection->LockSemaphore = (HANDLE)&lpCriticalSection->NativeData; - - if (0!= pthread_mutex_init(&lpCriticalSection->NativeData.Mutex, NULL)) - { - printf("Error Initializing Critical Section\n"); - retcode = -1; - } - - - lpCriticalSection->InitCount = CS_INITIALIZED; - return retcode; -} - -int MTXDeleteCriticalSection(LPCRITICAL_SECTION lpCriticalSection) -{ - int retcode = 0; - - if (lpCriticalSection->InitCount == CS_INITIALIZED) - { - - if (0!=pthread_mutex_destroy(&lpCriticalSection->NativeData.Mutex)) - { - printf("Error Deleting Critical Section\n"); - retcode = -1; - } - } - - lpCriticalSection->InitCount = CS_NOT_INIZIALIZED; - return retcode; -} - -int MTXEnterCriticalSection(LPCRITICAL_SECTION lpCriticalSection) -{ - - DWORD thread_id; - int retcode = 0; - - thread_id = (DWORD)THREADSilentGetCurrentThreadId(); - - /* check if the current thread already owns the criticalSection */ - if (lpCriticalSection->OwningThread == (HANDLE)thread_id) - { - lpCriticalSection->RecursionCount++; - //Check if this is a failure condition - return 0; - } - - if (0!= pthread_mutex_lock(&lpCriticalSection->NativeData.Mutex)) - { - //Error Condition - printf("Error Entering Critical Section\n"); - retcode = -1; - } - else - { - lpCriticalSection->OwningThread = (HANDLE)thread_id; - lpCriticalSection->RecursionCount = 1; - } - - return retcode; -} - -int MTXLeaveCriticalSection(LPCRITICAL_SECTION lpCriticalSection) -{ - int retcode = 0; - - if (--lpCriticalSection->RecursionCount > 0) - //*****check this ***** - return 0; - - lpCriticalSection->OwningThread = 0; - - if (0!= pthread_mutex_unlock(&lpCriticalSection->NativeData.Mutex)) - { - //Error Condition - printf("Error Leaving Critical Section\n"); - retcode = -1; - } - - return retcode; -} - diff --git a/src/pal/tests/palsuite/composite/synchronization/nativecs_interlocked/mtx_critsect.h b/src/pal/tests/palsuite/composite/synchronization/nativecs_interlocked/mtx_critsect.h deleted file mode 100644 index becbf6f0c..000000000 --- a/src/pal/tests/palsuite/composite/synchronization/nativecs_interlocked/mtx_critsect.h +++ /dev/null @@ -1,67 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#include - -typedef void VOID; -typedef void* HANDLE; -typedef unsigned long ULONG_PTR; - -#ifdef HPUX - typedef unsigned int DWORD; - typedef int LONG; - typedef unsigned int ULONG; -#else - typedef unsigned long DWORD; - typedef long LONG; - typedef unsigned long ULONG; -#endif - - - - -#define FALSE 0 -#define TRUE 1 - -#define CSBIT_CS_IS_LOCKED 1 -#define CSBIT_NEW_WAITER 2 - -typedef enum CsInitState { CS_NOT_INIZIALIZED, CS_INITIALIZED, CS_FULLY_INITIALIZED } CsInitState; -typedef enum _CsWaiterReturnState { CS_WAITER_WOKEN_UP, CS_WAITER_DIDNT_WAIT } CsWaiterReturnState; - -typedef struct _CRITICAL_SECTION_DEBUG_INFO { - LONG volatile ContentionCount; - LONG volatile InternalContentionCount; - ULONG volatile AcquireCount; - ULONG volatile EnterCount; -} CRITICAL_SECTION_DEBUG_INFO, *PCRITICAL_SECTION_DEBUG_INFO; - -typedef struct _CRITICAL_SECTION_NATIVE_DATA { - pthread_mutex_t Mutex; -} CRITICAL_SECTION_NATIVE_DATA, *PCRITICAL_SECTION_NATIVE_DATA; - -typedef struct _CRITICAL_SECTION { - - CsInitState InitCount; - PCRITICAL_SECTION_DEBUG_INFO DebugInfo; - LONG LockCount; - LONG RecursionCount; - HANDLE OwningThread; - HANDLE LockSemaphore; - ULONG_PTR SpinCount; - CRITICAL_SECTION_NATIVE_DATA NativeData; - -} CRITICAL_SECTION, *PCRITICAL_SECTION, *LPCRITICAL_SECTION; - -int MTXInitializeCriticalSection(LPCRITICAL_SECTION lpCriticalSection); -int MTXDeleteCriticalSection(LPCRITICAL_SECTION lpCriticalSection); -int MTXEnterCriticalSection(LPCRITICAL_SECTION lpCriticalSection); -int MTXLeaveCriticalSection(LPCRITICAL_SECTION lpCriticalSection); - -extern "C" { - LONG InterlockedCompareExchange( - LONG volatile *Destination, - LONG Exchange, - LONG Comperand); -} diff --git a/src/pal/tests/palsuite/composite/synchronization/nativecs_interlocked/notes.txt b/src/pal/tests/palsuite/composite/synchronization/nativecs_interlocked/notes.txt deleted file mode 100644 index 4882c3bd0..000000000 --- a/src/pal/tests/palsuite/composite/synchronization/nativecs_interlocked/notes.txt +++ /dev/null @@ -1,15 +0,0 @@ -gcc -O2 -finline-functions -D_DEBUG -g -DFULL_CSIMPL -o ./obj/sun4u/critsecttest.o -c critsecttest.cpp -gcc -O2 -finline-functions -D_DEBUG -g -c -o ./obj/sun4u/cs.o cs.cpp -gcc -x assembler-with-cpp -c -Wa,-Av9 -o ./obj/sun4u/sparcinterloc.o sparcinterloc.s -gcc -lpthread -lrt -O2 -finline-functions -D_DEBUG -g -o ./obj/sun4u/critsecttest ./obj/sun4u/critsecttest.o ./obj/sun4u/cs.o ./obj/sun4u/sparcinterloc.o -gcc -O2 -finline-functions -D_DEBUG -g -DCXNG_CSIMPL -o ./obj/sun4u/cxngtest.o -c critsecttest.cpp -gcc -O2 -finline-functions -D_DEBUG -g -c -o ./obj/sun4u/cxng_critsect.o cxng_critsect.cpp -gcc -lpthread -lrt -O2 -finline-functions -D_DEBUG -g -o ./obj/sun4u/cxngtest ./obj/sun4u/cxngtest.o ./obj/sun4u/cxng_critsect.o ./obj/sun4u/sparcinterloc.o -gcc -O2 -finline-functions -D_DEBUG -g -DMTX_CSIMPL -o ./obj/sun4u/mtxtest.o -c critsecttest.cpp -gcc -O2 -finline-functions -D_DEBUG -g -c -o ./obj/sun4u/mtx_critsect.o mtx_critsect.cpp -gcc -lpthread -lrt -O2 -finline-functions -D_DEBUG -g -o ./obj/sun4u/mtxtest ./obj/sun4u/mtxtest.o ./obj/sun4u/mtx_critsect.o ./obj/sun4u/sparcinterloc.o -gcc -O2 -finline-functions -D_DEBUG -g -DRECMTX_CSIMPL -o ./obj/sun4u/recmtxtest.o -c critsecttest.cpp -gcc -O2 -finline-functions -D_DEBUG -g -c -o ./obj/sun4u/recmtx_critsect.o recmtx_critsect.cpp -gcc -lpthread -lrt -O2 -finline-functions -D_DEBUG -g -o ./obj/sun4u/recmtxtest ./obj/sun4u/recmtxtest.o ./obj/sun4u/recmtx_critsect.o ./obj/sun4u/sparcinterloc.o -gcc -O2 -finline-functions -D_DEBUG -g -DINLRECMTX_CSIMPL -o ./obj/sun4u/inlrecmtxtest.o -c critsecttest.cpp -gcc -lpthread -lrt -O2 -finline-functions -D_DEBUG -g -o ./obj/sun4u/inlrecmtxtest ./obj/sun4u/inlrecmtxtest.o ./obj/sun4u/sparcinterloc.o diff --git a/src/pal/tests/palsuite/composite/synchronization/nativecs_interlocked/pal_composite_native_cs.cpp b/src/pal/tests/palsuite/composite/synchronization/nativecs_interlocked/pal_composite_native_cs.cpp deleted file mode 100644 index ec5c1c365..000000000 --- a/src/pal/tests/palsuite/composite/synchronization/nativecs_interlocked/pal_composite_native_cs.cpp +++ /dev/null @@ -1,471 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#include -#include -#include -#include -#include -//#include -//#include "mtx_critsect.cpp" -#include "mtx_critsect.h" -#include "resultbuffer.h" - - - -#define LONGLONG long long -#define ULONGLONG unsigned LONGLONG -/*Defining Global Variables*/ - -int THREAD_COUNT=0; -int REPEAT_COUNT=0; -int GLOBAL_COUNTER=0; -int USE_PROCESS_COUNT = 0; -int RELATION_ID =0; -int g_counter = 0; -int MAX_PATH = 256; -LONGLONG callibrationValue = 0; - -pthread_mutex_t g_mutex = PTHREAD_MUTEX_INITIALIZER; -pthread_cond_t g_cv = PTHREAD_COND_INITIALIZER; -pthread_cond_t g_cv2 = PTHREAD_COND_INITIALIZER; -CRITICAL_SECTION g_cs; - -/* Capture statistics for each worker thread */ -struct statistics{ - unsigned int processId; - unsigned int operationsFailed; - unsigned int operationsPassed; - unsigned int operationsTotal; - DWORD operationTime; - unsigned int relationId; -}; - - -struct applicationStatistics{ - DWORD operationTime; - unsigned int relationId; - unsigned int processCount; - unsigned int threadCount; - unsigned int repeatCount; - char* buildNumber; - -}; - -ResultBuffer *resultBuffer; - - -void* waitforworkerthreads(void*); -void starttests(int); -int setuptest(void); -int cleanuptest(void); -int GetParameters( int , char **); -void incrementCounter(void); -ULONGLONG GetTicks(void); -ULONGLONG getPerfCallibrationValue(void); - - - -extern int main(int argc, char **argv) - { - //Variable Declaration - pthread_t pthreads[640]; - int threadID[640]; - int i=0; - int j=0; - int rtn=0; - ULONGLONG startTicks = 0; - - /* Variables to capture the file name and the file pointer*/ - char fileName[MAX_PATH]; - FILE *hFile; - struct statistics* buffer; - int statisticsSize = 0; - - /*Variable to Captutre Information at the Application Level*/ - struct applicationStatistics appStats; - char mainFileName[MAX_PATH]; - FILE *hMainFile; - - //Get perfCallibrationValue - - callibrationValue = getPerfCallibrationValue(); - printf("Callibration Value for this Platform %llu \n", callibrationValue); - - - //Get Parameters - if(GetParameters(argc, argv)) - { - printf("Error in obtaining the parameters\n"); - exit(-1); - } - - //Assign Values to Application Statistics Members - appStats.relationId=RELATION_ID; - appStats.operationTime=0; - appStats.buildNumber = "999.99"; - appStats.processCount = USE_PROCESS_COUNT; - appStats.threadCount = THREAD_COUNT; - appStats.repeatCount = REPEAT_COUNT; - - printf("RELATION ID : %d\n", appStats.relationId); - printf("Process Count : %d\n", appStats.processCount); - printf("Thread Count : %d\n", appStats.threadCount); - printf("Repeat Count : %d\n", appStats.repeatCount); - - - //Open file for Application Statistics Collection - snprintf(mainFileName, MAX_PATH, "main_nativecriticalsection_%d_.txt",appStats.relationId); - hMainFile = fopen(mainFileName, "w+"); - - if(hMainFile == NULL) - { - printf("Error in opening main file for write\n"); - } - - - for (i=0;igetResultBuffer(i); - fprintf(hFile, "%d,%d,%d,%d,%lu,%d\n", buffer->processId, buffer->operationsFailed, buffer->operationsPassed, buffer->operationsTotal, buffer->operationTime, buffer->relationId ); - //printf("Iteration %d over\n", i); - } - } - fclose(hFile); - - - - //Call Test Case Cleanup Routine - if (0!=cleanuptest()) - { - //Error Condition - printf("Error Cleaning up Test Case"); - exit(-1); - } - - - if(hMainFile!= NULL) - { - printf("Writing to Main File \n"); - fprintf(hMainFile, "%lu,%d,%d,%d,%d,%s\n", appStats.operationTime, appStats.relationId, appStats.processCount, appStats.threadCount, appStats.repeatCount, appStats.buildNumber); - - } - fclose(hMainFile); - return 0; - } - -void * waitforworkerthreads(void * threadId) -{ - - int *threadParam = (int*) threadId; - -// printf("Thread ID : %d \n", *threadParam); - - //Accquire Lock - if (0!=pthread_mutex_lock(&g_mutex)) - { - //Error Condition - printf("Error Accquiring Mutex Lock in Wait for Worker Thread\n"); - exit(-1); - } - - //Increment Global Counter - GLOBAL_COUNTER++; - - - //If global counter is equal to thread count then signal main thread - if (GLOBAL_COUNTER == THREAD_COUNT) - { - if (0!=pthread_cond_signal(&g_cv2)) - { - //Error Condition - printf("Error in setting conditional variable\n"); - exit(-1); - } - } - - //Wait for main thread to signal - if (0!=pthread_cond_wait(&g_cv,&g_mutex)) - { - //Error Condition - printf("Error waiting on conditional variable in Worker Thread\n"); - exit(-1); - } - - //Release the mutex lock - if (0!=pthread_mutex_unlock(&g_mutex)) - { - //Error Condition - printf("Error Releasing Mutex Lock in Worker Thread\n"); - exit(-1); - } - - //Start the test - starttests(*threadParam); - -} - -void starttests(int threadID) -{ - /*All threads beign executing tests cases*/ - int i = 0; - int Id = threadID; - struct statistics stats; - ULONGLONG startTime = 0; - ULONGLONG endTime = 0; - - LONG volatile Destination; - LONG Exchange; - LONG Comperand; - LONG result; - - stats.relationId = RELATION_ID; - stats.processId = USE_PROCESS_COUNT; - stats.operationsFailed = 0; - stats.operationsPassed = 0; - stats.operationsTotal = 0; - stats.operationTime = 0; - - //Enter and Leave Critical Section in a loop REPEAT_COUNT Times - - - startTime = GetTicks(); - - for (i=0;iLogResult(Id, (char *)&stats)) - { - printf("Error while writing to shared memory, Thread Id is[??] and Process id is [%d]\n", USE_PROCESS_COUNT); - } - -} - -int setuptest(void) -{ - - //Initalize Critical Section - /* - if (0!=MTXInitializeCriticalSection( &g_cs)) - { - return -1; - } - */ - return 0; -} - -int cleanuptest(void) -{ - - //Delete Critical Section - /* - if (0!=MTXDeleteCriticalSection(&g_cs)) - { - return -1; - } - */ - return 0; -} - -int GetParameters( int argc, char **argv) -{ - - if( (argc != 5) || ((argc == 1) && !strcmp(argv[1],"/?")) - || !strcmp(argv[1],"/h") || !strcmp(argv[1],"/H")) - { - printf("PAL -Composite Native Critical Section Test\n"); - printf("Usage:\n"); - printf("\t[PROCESS_ID ( greater than 1] \n"); - printf("\t[THREAD_COUNT ( greater than 1] \n"); - printf("\t[REPEAT_COUNT ( greater than 1]\n"); - printf("\t[RELATION_ID [greater than or Equal to 1]\n"); - return -1; - } - - - USE_PROCESS_COUNT = atoi(argv[1]); - if( USE_PROCESS_COUNT < 0) - { - printf("\nInvalid THREAD_COUNT number, Pass greater than 1\n"); - return -1; - } - - THREAD_COUNT = atoi(argv[2]); - if( THREAD_COUNT < 1) - { - printf("\nInvalid THREAD_COUNT number, Pass greater than 1\n"); - return -1; - } - - REPEAT_COUNT = atoi(argv[3]); - if( REPEAT_COUNT < 1) - { - printf("\nInvalid REPEAT_COUNT number, Pass greater than 1\n"); - return -1; - } - - RELATION_ID = atoi(argv[4]); - if( RELATION_ID < 1) - { - printf("\nInvalid RELATION_ID number, Pass greater than 1\n"); - return -1; - } - - - return 0; -} - -void incrementCounter(void) -{ - g_counter ++; -} - - -//Implementation borrowed from pertrace.c -ULONGLONG GetTicks(void) -{ -#ifdef i386 - unsigned long a, d; - asm volatile("rdtsc":"=a" (a), "=d" (d)); - return ((ULONGLONG)((unsigned int)(d)) << 32) | (unsigned int)(a); -#else - // #error Don''t know how to get ticks on this platform - return (ULONGLONG)gethrtime(); -#endif // i386 -} - - -/**/ -ULONGLONG getPerfCallibrationValue(void) -{ - ULONGLONG startTicks; - ULONGLONG endTicks; - - startTicks = GetTicks(); - sleep(1); - endTicks = GetTicks(); - - return ((endTicks-startTicks)/1000); //Return number of Ticks in One Milliseconds - -} - diff --git a/src/pal/tests/palsuite/composite/synchronization/nativecs_interlocked/readme.txt b/src/pal/tests/palsuite/composite/synchronization/nativecs_interlocked/readme.txt deleted file mode 100644 index a407e9f8b..000000000 --- a/src/pal/tests/palsuite/composite/synchronization/nativecs_interlocked/readme.txt +++ /dev/null @@ -1,39 +0,0 @@ -To compile: - -For FReeBSD Platform use the following to compile: -gcc -pthread -lm -lgcc -lstdc++ -xc++ -Di386 pal_composite_native_cs.c - - --------------------------------------------------------- -For Solaris Platform use the following to compile: - gcc -lpthread -lm -lgcc -lstdc++ -xc++ -D__sparc__ -mimpure-text -shared -o critsect.so mtx_critsect.cpp interlock.s -gcc -lpthread -lm -lgcc -lstdc++ -xc++ -D__sparc__ pal_composite_native_cs.c - - -setenv LD_LIBRARY_PATH /usr/lib/lwp:/usr/local/lib:/usr/lib:/opt/sfw/lib:. - gcc -lpthread -lm -lgcc -lstdc++ -lcritsect -xc++ -D__sparc__ pal_composite_native_cs.c - gcc -lpthread -lm -lgcc -lstdc++ -xc++ -D__sparc__ -mimpure-text -shared -o critsect.so mtx_critsect.cpp - -(pts/2):{4}% ldd critsect.so - libpthread.so.1 => /usr/lib/libpthread.so.1 - libm.so.1 => /usr/lib/libm.so.1 - libstdc++.so.2.10.0 => /usr/local/lib/libstdc++.so.2.10.0 - libc.so.1 => /usr/lib/libc.so.1 - libdl.so.1 => /usr/lib/libdl.so.1 - libthread.so.1 => /usr/lib/libthread.so.1 - /usr/platform/SUNW,Serverblade1/lib/libc_psr.so.1 - - --------------------------------------------------------- -For HPUX Platform use the following to compile: -gcc -lpthread -mlp64 -lm -lgcc -lstdc++ -xc++ -D_HPUX_ -D__ia64__ pal_composite_native_cs.c - --------------------------------------------------------- -To execute: -./a.out [PROCESS_COUNT] [THREAD_COUNT] [REPEAT_COUNT] - - - ./a.out 1 32 1000000 4102406 - - - diff --git a/src/pal/tests/palsuite/composite/synchronization/nativecs_interlocked/resultbuffer.cpp b/src/pal/tests/palsuite/composite/synchronization/nativecs_interlocked/resultbuffer.cpp deleted file mode 100644 index c9ed9435f..000000000 --- a/src/pal/tests/palsuite/composite/synchronization/nativecs_interlocked/resultbuffer.cpp +++ /dev/null @@ -1,69 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -//#include "stdafx.h" -#include "resultbuffer.h" -// -//#using -// -//using namespace System; - - -ResultBuffer:: ResultBuffer(int ThreadCount, int ThreadLogSize) - { - // Declare an internal status variable - int Status=0; - - // Update the maximum thread count - MaxThreadCount = ThreadCount; - - // Allocate the memory buffer based on the passed in thread and process counts - // and the specified size of the thread specific buffer - buffer = NULL; - buffer = (char*)malloc(ThreadCount*ThreadLogSize); - // Check to see if the buffer memory was allocated - if (buffer == NULL) - Status = -1; - // Initialize the buffer to 0 to prevent bogus data - memset(buffer,0,ThreadCount*ThreadLogSize); - - // The ThreadOffset is equal to the total number of bytes that will be stored per thread - ThreadOffset = ThreadLogSize; - - } - - - int ResultBuffer::LogResult(int Thread, char* Data) - { - // Declare an internal status flad - int status = 0; - - // Declare an object to store the offset address into the buffer - int Offset; - - // Check to make sure the Thread index is not out of range - if(Thread > MaxThreadCount) - { - printf("Thread index is out of range, Value of Thread[%d], Value of MaxThreadCount[%d]\n", Thread, MaxThreadCount); - status = -1; - return(status); - } - - // Caculate the offset into the shared buffer based on the process and thread indices - Offset = (Thread)*ThreadOffset; - - // Write the passed in data to the reserved buffer - memcpy(buffer+Offset,Data,ThreadOffset); - - return(status); - } - - - char* ResultBuffer::getResultBuffer(int threadId) - { - - return (buffer + threadId*ThreadOffset); - - } - diff --git a/src/pal/tests/palsuite/composite/synchronization/nativecs_interlocked/resultbuffer.h b/src/pal/tests/palsuite/composite/synchronization/nativecs_interlocked/resultbuffer.h deleted file mode 100644 index 892095810..000000000 --- a/src/pal/tests/palsuite/composite/synchronization/nativecs_interlocked/resultbuffer.h +++ /dev/null @@ -1,43 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#include -#include -//#include -#ifndef _RESULT_BUFFER_H_ -#define _RESULT_BUFFER_H_ - -//#include - -struct ResultData -{ - int value; - int size; -// ResultData* NextResult; -}; - - class ResultBuffer -{ - // Declare a pointer to a memory buffer to store the logged results - char* buffer; - // Declare an object to store the maximum Thread count - int MaxThreadCount; - // Declare and internal data object to store the calculated offset between adjacent threads data sets - int ThreadOffset; - - // Declare a linked list object to store the parameter values -public: - - // Declare a constructor for the single process case - ResultBuffer(int ThreadCount, int ThreadLogSize); - // Declare a method to log data for the single process instance - int LogResult(int Thread, char* Data); - - char* getResultBuffer(int threadId); -}; - -#include "resultbuffer.cpp" -#endif // _RESULT_BUFFER_H_ - - diff --git a/src/pal/tests/palsuite/composite/synchronization/nativecs_interlocked/sparcinterloc.s b/src/pal/tests/palsuite/composite/synchronization/nativecs_interlocked/sparcinterloc.s deleted file mode 100644 index b9708bc77..000000000 --- a/src/pal/tests/palsuite/composite/synchronization/nativecs_interlocked/sparcinterloc.s +++ /dev/null @@ -1,73 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*++ - - - - Module Name: - - interlock.s - -Abstract: - - Implementation of Interlocked functions for the SPARC - platform. These functions are processor dependent. - See the i386 implementations for more information. - - --*/ - - // A handy macro for declaring a public function - // The first argument is the function name. - #define ASMFUNC(n,typename); \ - .align 4 ; \ - .global n ; \ - .type n,typename ; \ -n: ; - - .text - ASMFUNC(InterlockedIncrement,#function) - ld [%o0], %o1 -loopI: - mov %o1, %o2 - add %o1, 1, %o1 - cas [%o0], %o2, %o1 - cmp %o2, %o1 - bne loopI - nop - retl - add %o1, 1, %o0 - - - ASMFUNC(InterlockedDecrement,#function) - ld [%o0], %o1 -loopD: - mov %o1, %o2 - sub %o1, 1, %o1 - cas [%o0], %o2, %o1 - cmp %o2, %o1 - bne loopD - nop - retl - sub %o1, 1, %o0 - - - ASMFUNC(InterlockedExchange,#function) - swap [%o0], %o1 - retl - mov %o1, %o0 - - ASMFUNC(InterlockedCompareExchange,#function) - cas [%o0], %o2, %o1 - retl - mov %o1, %o0 - - ASMFUNC(MemoryBarrier,#function) - // ROTORTODO: SPARC - retl - nop - - ASMFUNC(YieldProcessor,#function) - retl - nop diff --git a/src/pal/tests/palsuite/composite/threading/CMakeLists.txt b/src/pal/tests/palsuite/composite/threading/CMakeLists.txt deleted file mode 100644 index 793f86c05..000000000 --- a/src/pal/tests/palsuite/composite/threading/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(threadsuspension) -add_subdirectory(threadsuspension_switchthread) - diff --git a/src/pal/tests/palsuite/composite/threading/threadsuspension/CMakeLists.txt b/src/pal/tests/palsuite/composite/threading/threadsuspension/CMakeLists.txt deleted file mode 100644 index a01fbd655..000000000 --- a/src/pal/tests/palsuite/composite/threading/threadsuspension/CMakeLists.txt +++ /dev/null @@ -1,18 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - mainWrapper.cpp - threadsuspension.cpp -) - -add_executable(paltest_threading_threadsuspension - ${SOURCES} -) - -add_dependencies(paltest_threading_threadsuspension coreclrpal) - -target_link_libraries(paltest_threading_threadsuspension - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/composite/threading/threadsuspension/mainWrapper.cpp b/src/pal/tests/palsuite/composite/threading/threadsuspension/mainWrapper.cpp deleted file mode 100644 index 05a71191c..000000000 --- a/src/pal/tests/palsuite/composite/threading/threadsuspension/mainWrapper.cpp +++ /dev/null @@ -1,274 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/* -Source Code: mainWrapper.c - -mainWrapper.c creates Composite Test Case Processes and waits for all processes to get over - -Algorithm -o Create PROCESS_COUNT processes. - -Author: RameshG -*/ - -#include -#include "resulttime.h" - -/* Test Input Variables */ -unsigned int USE_PROCESS_COUNT = 0; //default -unsigned int WORKER_THREAD_MULTIPLIER_COUNT = 0; //default -unsigned int REPEAT_COUNT = 0; //default -unsigned int SLEEP_LENGTH = 0; //default -unsigned int RELATION_ID = 0;//default -unsigned int THREAD_COUNT = 1; //There is only one suspender and resume thread for this test case - -char *testCaseName; - - -struct applicationStatistics{ - DWORD operationTime; - unsigned int relationId; - unsigned int processCount; - unsigned int threadCount; - unsigned int repeatCount; - char* buildNumber; - -}; - - -int GetParameters( int argc, char **argv) -{ - - if( (argc != 5) || ((argc == 1) && !strcmp(argv[1],"/?")) - || !strcmp(argv[1],"/h") || !strcmp(argv[1],"/H")) - { - printf("PAL -Composite Thread Suspension Test\n"); - printf("Usage:\n"); - printf("\t[PROCESS_COUNT] Greater than or Equal to 1 \n"); - printf("\t[WORKER_THREAD_MULTIPLIER_COUNT] Greater than or Equal to 1 and Less than or Equal to %d \n", MAXIMUM_WAIT_OBJECTS); - printf("\t[REPEAT_COUNT] Greater than or Equal to 1\n"); - printf("\t[RELATION_ID [greater than or Equal to 1]\n"); - return -1; - } - - // Trace("Args 1 is [%s], Arg 2 is [%s], Arg 3 is [%s]\n", argv[1], argv[2], argv[3]); - - USE_PROCESS_COUNT = atoi(argv[1]); - if( USE_PROCESS_COUNT < 0) - { - printf("\nPROCESS_COUNT to greater than or equal to 1\n"); - return -1; - } - - WORKER_THREAD_MULTIPLIER_COUNT = atoi(argv[2]); - if( WORKER_THREAD_MULTIPLIER_COUNT < 1 || WORKER_THREAD_MULTIPLIER_COUNT > 64) - { - printf("\nWORKER_THREAD_MULTIPLIER_COUNT to be greater than or equal to 1 or less than or equal to 64\n"); - return -1; - } - - REPEAT_COUNT = atoi(argv[3]); - if( REPEAT_COUNT < 1) - { - printf("\nREPEAT_COUNT to greater than or equal to 1\n"); - return -1; - } - - RELATION_ID = atoi(argv[4]); - if( RELATION_ID < 1) - { - printf("\nRELATION_ID to be greater than or equal to 1\n"); - return -1; - } - - - - return 0; -} - - int __cdecl main(INT argc, CHAR **argv) -{ - unsigned int i = 0; - HANDLE hProcess[MAXIMUM_WAIT_OBJECTS]; - DWORD processReturnCode = 0; - int testReturnCode = PASS; - STARTUPINFO si[MAXIMUM_WAIT_OBJECTS]; - PROCESS_INFORMATION pi[MAXIMUM_WAIT_OBJECTS]; - - FILE *hFile; - char fileName[MAX_PATH]; - struct applicationStatistics appStats; - - DWORD dwStart=0; - - char lpCommandLine[MAX_PATH] = ""; - - char build[] ="0000.00"; - int returnCode = 0; - - if(0 != (PAL_Initialize(argc, argv))) - { - return ( FAIL ); - } - - //Initialize Application Statistics Strucuture - appStats.relationId=RELATION_ID; - appStats.operationTime=0; - appStats.buildNumber = getBuildNumber(); - //appStats.buildNumber = build; - appStats.processCount = 0; - appStats.threadCount = 0; - appStats.repeatCount = 0; - - - - - -//Start Process Time Capture -dwStart = GetTickCount(); - - if(GetParameters(argc, argv)) - { - Fail("Error in obtaining the parameters\n"); - } - -//Assign Correct Values to the Application Stats Structure - appStats.relationId=RELATION_ID; - appStats.processCount = USE_PROCESS_COUNT; - appStats.threadCount = THREAD_COUNT ; - appStats.repeatCount = REPEAT_COUNT; - - Trace("Relation ID: %d \n", RELATION_ID); - Trace("USE_PROCESS_COUNT: %d \n", USE_PROCESS_COUNT); - Trace("WORKER_THREAD_MULTIPLIER_COUNT: %d \n", WORKER_THREAD_MULTIPLIER_COUNT); - Trace("REPEAT_COUNT: %d \n", REPEAT_COUNT); - - -_snprintf(fileName, MAX_PATH, "main_threadsuspension_%d_.txt",appStats.relationId); - - hFile = fopen(fileName, "w+"); -if(hFile == NULL) - { - Fail("Error in opening file to write application results for Thread Suspension Test with error code %d \n", GetLastError() ); - } - - - - for( i = 0; i < USE_PROCESS_COUNT; i++ ) - { - - ZeroMemory( lpCommandLine, MAX_PATH ); - if ( _snprintf( lpCommandLine, MAX_PATH-1, "threadsuspension %d %d %d %d", i, WORKER_THREAD_MULTIPLIER_COUNT, REPEAT_COUNT, RELATION_ID) < 0 ) - { - Trace ("Error: Insufficient commandline string length for for iteration [%d]\n", i); - } - - /* Zero the data structure space */ - ZeroMemory ( &pi[i], sizeof(pi[i]) ); - ZeroMemory ( &si[i], sizeof(si[i]) ); - - /* Set the process flags and standard io handles */ - si[i].cb = sizeof(si[i]); - - //Printing the Command Line - //Trace("Command Line \t %s \n", lpCommandLine); - - //Create Process - if(!CreateProcess( NULL, /* lpApplicationName*/ - lpCommandLine, /* lpCommandLine */ - NULL, /* lpProcessAttributes */ - NULL, /* lpThreadAttributes */ - TRUE, /* bInheritHandles */ - 0, /* dwCreationFlags, */ - NULL, /* lpEnvironment */ - NULL, /* pCurrentDirectory */ - &si[i], /* lpStartupInfo */ - &pi[i] /* lpProcessInformation */ - )) - { - Fail("Process Not created for [%d] and GetLastError value is %d\n", i, GetLastError()); - - } - else - { - hProcess[i] = pi[i].hProcess; - //Trace("Process created for [%d]\n", i); - } - - } - - returnCode = WaitForMultipleObjects( USE_PROCESS_COUNT, hProcess, TRUE, INFINITE); - if( WAIT_OBJECT_0 != returnCode ) - { - Trace("Wait for Object(s) @ Main thread for %d processes returned %d, and GetLastError value is %d\n", USE_PROCESS_COUNT, returnCode, GetLastError()); - testReturnCode = FAIL; - } - - for( i = 0; i < USE_PROCESS_COUNT; i++ ) - { - /* check the exit code from the process */ - if( ! GetExitCodeProcess( pi[i].hProcess, &processReturnCode ) ) - { - Trace( "GetExitCodeProcess call failed for iteration %d with error code %u\n", - i, GetLastError() ); - - testReturnCode = FAIL; - } - - if(processReturnCode == FAIL) - { - Trace( "Process [%d] failed and returned FAIL\n", i); - testReturnCode = FAIL; - } - - if(!CloseHandle(pi[i].hThread)) - { - Trace("Error:%d: CloseHandle failed for Process [%d] hThread\n", GetLastError(), i); - testReturnCode = FAIL; - } - - if(!CloseHandle(pi[i].hProcess) ) - { - Trace("Error:%d: CloseHandle failed for Process [%d] hProcess\n", GetLastError(), i); - testReturnCode = FAIL; - } - } - -//Get the end time of the process -appStats.operationTime = GetTickCount() - dwStart; - -if( testReturnCode == PASS) - { - Trace("Test Passed\n"); - } - else - { - Trace("Test Failed\n"); - } - -//Write Process Result Contents to File -if(hFile!= NULL) - { - fprintf(hFile, "%lu,%d,%d,%d,%d,%s\n", appStats.operationTime, appStats.relationId, appStats.processCount, appStats.threadCount, appStats.repeatCount, appStats.buildNumber); - } - -if (0!=fclose(hFile)) -{ - Trace("Error:%d: fclose failed for file %s\n", GetLastError(), fileName); -} - PAL_Terminate(); - - -if( testReturnCode == PASS) - { - return PASS; - } - else - { - return FAIL; - - } - -} diff --git a/src/pal/tests/palsuite/composite/threading/threadsuspension/readme.txt b/src/pal/tests/palsuite/composite/threading/threadsuspension/readme.txt deleted file mode 100644 index d722f1d12..000000000 --- a/src/pal/tests/palsuite/composite/threading/threadsuspension/readme.txt +++ /dev/null @@ -1,11 +0,0 @@ -To compile: - -1) create a dat file (say threadsuspension.dat) with contents: -PAL,Composite,palsuite\composite\threading\threadsuspension,wfmo=mainWrapper.c threadsuspension.c,,, - -2) perl rrunmod.pl -r threadsuspension.dat - - -To execute: -mainWrapper [PROCESS_COUNT] [THREAD_COUNT] [REPEAT_COUNT] - diff --git a/src/pal/tests/palsuite/composite/threading/threadsuspension/samplefile.dat b/src/pal/tests/palsuite/composite/threading/threadsuspension/samplefile.dat deleted file mode 100644 index d6505f254..000000000 --- a/src/pal/tests/palsuite/composite/threading/threadsuspension/samplefile.dat +++ /dev/null @@ -1,5124 +0,0 @@ -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense blackasdf dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. diff --git a/src/pal/tests/palsuite/composite/threading/threadsuspension/threadsuspension.cpp b/src/pal/tests/palsuite/composite/threading/threadsuspension/threadsuspension.cpp deleted file mode 100644 index 86ee4e2fc..000000000 --- a/src/pal/tests/palsuite/composite/threading/threadsuspension/threadsuspension.cpp +++ /dev/null @@ -1,907 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source: \composite\threading\threadsuspension\threadsuspension.c -** -** Purpose: To verify Thread Suspension Reegneering effort for this milestone - - PsedoCode: - - Preparation: - Create PROCESS_COUNT processes. - Test: - Create Worker Thread - Start Reading and writing to a File - - Create Worker Thread - In an infinite loop do the following - Enter Critical Section - Increment Counter - Leave Critical Section - - Create Worker Thread - Allocate Memory and Free Memory - - Create Worker Thread - In a tight loop add numbers - - In a loop repeated REPEAT_COUNT times - - Create Thread - - Suspend all worker threads - Resume all worker threads - - At the end of the loop call PAL_Shutdown - - Parameters: - PROCESS_COUNT: Number of processes - WORKER_THREAD_MULTIPLIER_COUNT: Number of instances of worker threads in each process - REPEAT_COUNT: The number of times to execute the loop. - - Statistics Captured: - Total elapsed time - MTBF - - - Scenario: -** - One thread suspends all remaining threads which are in the middle of doing some work and resume all threads - Thread 1: Reading and Writing File - Thread 2: Enter and Leave Critical Section - Thread 3: Allocating chunks of memory - Thread 4: Perform Unsafe Operation (printf, malloc) - Thread 5: Suspends Thread 1 to Thread 4 and resumes them - -** -** -** -** Dependencies: -** -** - -** -**=========================================================*/ - -#include -#include "resultbuffer.h" - -#define BUFSIZE 4096 -#define NUMBER_OF_WORKER_THREAD_TYPES 4 -#define THREAD_MAX 64 - -#define TEST_FAIL 1 -#define TEST_PASS 0 - - -DWORD GLOBAL_COUNTER ; -DWORD UNIQUE_FILE_NUMBER=0; -HANDLE g_hEvent; - -bool failFlag = false; //To Track failure at the Operation Level - -// 2 dimensional array to hold thread handles for each worker thread -HANDLE hThread[NUMBER_OF_WORKER_THREAD_TYPES][THREAD_MAX]; - -/*unsigned int g_readfileoperation; -unsigned int g_enterleavecsoperation; -unsigned int g_allocatefreeoperation; -unsigned int g_doworintightloop; -*/ - -int TYPES_OF_WORKER_THREAD = NUMBER_OF_WORKER_THREAD_TYPES; - -int testStatus=TEST_PASS; //Indicates test failure - - -struct statistics{ - unsigned int processId; - unsigned int operationsFailed; - unsigned int operationsPassed; - unsigned int operationsTotal; - DWORD operationTime; - unsigned int relationId; -}; - -struct processStatistics{ - unsigned int processId; - DWORD operationTime; - unsigned int relationId; -}; - -/* Results Buffer */ -ResultBuffer *resultBuffer; - - -/* Test Input Variables */ -unsigned int USE_PROCESS_COUNT = 0; //Identifies the Process number. There could potentially -unsigned int WORKER_THREAD_MULTIPLIER_COUNT = 0; //In this test case this represents the number of worker thread instances -unsigned int REPEAT_COUNT = 0; //Number of Suspend Resume operation of worker threads -unsigned int RELATION_ID = 0; - - - -CRITICAL_SECTION CriticalSectionM; /* Critical Section Object (used as mutex) */ -CRITICAL_SECTION g_csUniqueFileName; - -void PALAPI setup(void); -void PALAPI cleanup(void); -void PALAPI incrementCounter(void); -DWORD PALAPI readfile( LPVOID); -DWORD PALAPI enterandleave_cs( LPVOID); -DWORD PALAPI allocateandfree_memory( LPVOID); -DWORD PALAPI doworkintightloop_cs( LPVOID); -DWORD PALAPI suspendandresumethreads( LPVOID); -int GetParameters(int, char * *); - - -//Main Entry for the Thread Suspension Test Case -int __cdecl main (int argc, char **argv) -{ - -/* -* Parameter to the threads that will be created -*/ - - -DWORD dwThrdParam = 0; -DWORD dwStart; - -/* Variables to capture the file name and the file pointer*/ -char fileName[MAX_PATH]; -char processFileName[MAX_PATH]; - -FILE *hFile, *hProcessFile; -struct statistics* buffer; -struct processStatistics *processBuffer; - -struct processStatistics processStats; - -struct statistics* tmpBuf = NULL; -int statisticsSize = 0; - -DWORD dwThreadId=0; -HANDLE hMainThread; -unsigned int i = 0; -int j = 0; - - -/* -* PAL Initialize -*/ - -if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - -//Get Parameters -if(GetParameters(argc, argv)) - { - Fail("Error in obtaining the parameters\n"); - } - - -//Setup for Process Result Collection -statisticsSize = sizeof(struct statistics); -_snprintf(processFileName, MAX_PATH, "%d_process_threadsuspension_%d_.txt", USE_PROCESS_COUNT, RELATION_ID); -hProcessFile = fopen(processFileName, "w+"); - -if(hProcessFile == NULL) - { - Fail("Error in opening file to write process results for process [%d]\n", USE_PROCESS_COUNT); - } - -//Initialize Process Stats Variables -processStats.operationTime = 0; -processStats.processId = USE_PROCESS_COUNT; -processStats.relationId = RELATION_ID; - -//Start Process Time Capture -dwStart = GetTickCount(); - -//Setup for Thread Result Collection -statisticsSize = sizeof(struct statistics); -_snprintf(fileName, MAX_PATH, "%d_thread_threadsuspension_%d_.txt", USE_PROCESS_COUNT,RELATION_ID); -hFile = fopen(fileName, "w+"); - -if(hFile == NULL) - { - Fail("Error in opening file to write thread results for process [%d]\n", USE_PROCESS_COUNT); - } - -// For each thread we will log relationid (int), processid (int), operations failed (int), passed (int), total (int) -// and number of ticks (DWORD) for the operations -resultBuffer = new ResultBuffer( 1, statisticsSize); - -/* -* Call the Setup Routine -*/ -setup(); - -Trace("WORKER_THREAD_MULTIPLIER_COUNT: %d \n", WORKER_THREAD_MULTIPLIER_COUNT); - -//Create WORKER_THREAD_MULTIPLIER_COUNT Instances of each type of worker thread -for (i=0;igetResultBuffer(i); - fprintf(hFile, "%d,%d,%d,%d,%lu,%d\n", buffer->processId, buffer->operationsFailed, buffer->operationsPassed, buffer->operationsTotal, buffer->operationTime, buffer->relationId ); - } - } - -if (0!=fclose(hFile)) -{ - Fail("Unable to write thread results to file" - "GetLastError returned %d\n", GetLastError()); -} - -cleanup(); - -if (failFlag == TRUE) -{ - return FAIL; -} -else -{ - return PASS; -} -} - - -/* -* Setup for the test case -*/ - -VOID -setup(VOID) -{ - /*Delete All Temporary Files Created by the previous execution of the test case*/ - HANDLE hSearch; - BOOL fFinished = FALSE; - WIN32_FIND_DATA FileData; - - //Start searching for .tmp files in the current directory. - hSearch = FindFirstFile("*.tmp*", &FileData); - if (hSearch == INVALID_HANDLE_VALUE) - { - //No Files That Matched Criteria - fFinished = TRUE; - } - - //Delete all files that match the pattern - while (!fFinished) - { - if (!DeleteFile(FileData.cFileName)) - { - Trace("Setup: Could not delete temporary file %s\n",FileData.cFileName ); - Fail ("GetLastError returned %d\n", GetLastError()); - } - if (!FindNextFile(hSearch, &FileData)) - { - if (GetLastError() == ERROR_NO_MORE_FILES) - { - fFinished = TRUE; - } - else - { - Fail("Unable to Delete Temporary Files, GetLastError is %d \n", GetLastError()); - } - } - } - - // Close the search handle, only if HANDLE is Valid - if (hSearch != INVALID_HANDLE_VALUE) - { - if (!FindClose(hSearch)) - { - Trace("Setup: Could not close search handle \n"); - Fail ("GetLastError returned %d\n", GetLastError()); - } - } - - g_hEvent = CreateEvent(NULL,TRUE,FALSE, NULL); - if(g_hEvent == NULL) - { - Fail("Create Event Failed\n" - "GetLastError returned %d\n", GetLastError()); - } - - InitializeCriticalSection ( &g_csUniqueFileName); -} - -/* -* Cleanup for the test case -*/ - -VOID -cleanup(VOID) -{ - //DeleteCriticalSection(&g_csUniqueFileName); - PAL_Terminate(); -} - - -VOID -incrementCounter(VOID) -{ - - if (INT_MAX == GLOBAL_COUNTER) - { - GLOBAL_COUNTER = 0; - } - - GLOBAL_COUNTER++; -} - -/* - * Worker Thread - * Read File: Read from a file and write to a temporary file and then delete the temp file - */ -DWORD -PALAPI -readfile( LPVOID lpParam ) -{ - - // Declaring Local Variables - HANDLE hFile,hTempfile; - char buffer[BUFSIZE]; - DWORD dwBytesRead, dwBytesWritten, dwBufSize=BUFSIZE; - DWORD dwWaitResult=0; - char filename[MAX_PATH]; - - //Wait for event to signal to start test - dwWaitResult = WaitForSingleObject(g_hEvent,INFINITE); - if (WAIT_OBJECT_0 != dwWaitResult) - { - Fail ("readfile: Wait for Single Object (g_hEvent) failed. Failing test.\n" - "GetLastError returned %d\n", GetLastError()); - } - - - /*Start Operation*/ - - // Open the existing file. - while(TRUE) - { - - hFile = CreateFile("samplefile.dat", // file name - GENERIC_READ, // open for reading - FILE_SHARE_READ, // Share the file for read - NULL, // default security - OPEN_EXISTING, // existing file only - FILE_ATTRIBUTE_NORMAL, // normal file - NULL); // no template - - if (hFile == INVALID_HANDLE_VALUE) - { - Trace("Could not open file \n"); - Fail ( "GetLastError returned %d\n", GetLastError()); - } - - //Generate Unique File Name to Write - //Enter CS - EnterCriticalSection(&g_csUniqueFileName); - - //Increment Number and assign to local variable - UNIQUE_FILE_NUMBER++; - _snprintf(filename, MAX_PATH, "%d_%d_tempfile.tmp", USE_PROCESS_COUNT,UNIQUE_FILE_NUMBER); - //filename = itoa(UNIQUE_FILE_NUMBER); - //Leave CS - LeaveCriticalSection(&g_csUniqueFileName); - - - // Create a temporary file with name generate above - hTempfile = CreateFile(filename, // file name - GENERIC_WRITE, // open for read/write - 0, // do not share - NULL, // default security - CREATE_ALWAYS, // overwrite existing file - FILE_ATTRIBUTE_NORMAL, // normal file - NULL); // no template - - - if (hTempfile == INVALID_HANDLE_VALUE) - { - Trace("Could not create temporary file\n"); - Fail ( "GetLastError returned %d\n", GetLastError()); - } - - // Read 4K blocks to the buffer. - // Change all characters in the buffer to upper case. - // Write the buffer to the temporary file. - - do - { - if (ReadFile(hFile, buffer, 4096, - &dwBytesRead, NULL)) - { - - WriteFile(hTempfile, buffer, dwBytesRead, - &dwBytesWritten, NULL); - } - } while (dwBytesRead == BUFSIZE); - - - - // Close both files. - if (0==CloseHandle(hFile)) - { - Trace("Could not handle hFile\n"); - Fail ( "GetLastError returned %d\n", GetLastError()); - } - - if (0==CloseHandle(hTempfile)) - { - Trace("Could not handle hTempFile\n"); - Fail ( "GetLastError returned %d\n", GetLastError()); - } - - //Delete the file that was created - if (!DeleteFile(filename)) - { - Trace("Could not delete temporary file %s\n", filename); - Fail ( "GetLastError returned %d\n", GetLastError()); - - } - - //g_readfileoperation++; - } - -/*End Operation*/ - - return 0; -} - - -/* Worker Thread - * Enter and Leave Nested Critical Sections - */ -DWORD -PALAPI -enterandleave_cs( LPVOID lpParam ) -{ - - //Declare Local Variables - - CRITICAL_SECTION lcs; - CRITICAL_SECTION lcsNested; - - DWORD dwWaitResult; - - //Intialize Critical Section Structures - InitializeCriticalSection ( &lcs); - InitializeCriticalSection ( &lcsNested); - - - //Wait for event to signal to start test - dwWaitResult = WaitForSingleObject(g_hEvent,INFINITE); - if (WAIT_OBJECT_0 != dwWaitResult) - { - Fail ("enterandleave_cs: Wait for Single Object (g_hEvent) failed. Failing test.\n" - "GetLastError returned %d\n", GetLastError()); - } - - //Trace("Critical Section Started\n"); - - while(TRUE) - { - EnterCriticalSection(&lcs); - - EnterCriticalSection(&lcsNested); - - incrementCounter(); - - LeaveCriticalSection(&lcsNested); - - LeaveCriticalSection(&lcs); - //g_enterleavecsoperation++; - } - - //Delete Critical Section Structures - - DeleteCriticalSection(&lcs); - DeleteCriticalSection(&lcsNested); - - - return 0; -} - - -/* - * Allocate and Free Memory - */ -DWORD -PALAPI -allocateandfree_memory( LPVOID lpParam ) -{ - - - int i; - char *textArrPtr[64]; - DWORD dwWaitResult; - - //Wait for event to signal to start test - dwWaitResult = WaitForSingleObject(g_hEvent,INFINITE); - if (WAIT_OBJECT_0 != dwWaitResult) - { - Fail ("allocateandfree_memory: Wait for Single Object (g_hEvent) failed. Failing test.\n" - "GetLastError returned %d\n", GetLastError()); - } - - - while(TRUE) - { - - //do allocate and free operation - - for (i=0;i<64;i++) - { - textArrPtr[i] = (char*) malloc(BUFSIZE); - if (textArrPtr[i] == NULL) - { - Fail("Insufficient Memory Available, GetLastError is %d \n", GetLastError()); - testStatus = TEST_FAIL; - } - } - - for (i=0;i<64;i++) - { - free(textArrPtr[i]); - } - //g_allocatefreeoperation++; - } - - - - - return 0; -} - -/* - * Do work in a tight loop - */ -DWORD -PALAPI -doworkintightloop_cs( LPVOID lpParam ) -{ - - unsigned int i; - DWORD dwWaitResult; - - //Wait for event to signal to start test - dwWaitResult = WaitForSingleObject(g_hEvent,INFINITE); - if (WAIT_OBJECT_0 != dwWaitResult) - { - Fail ("doworkintightloop_cs: Wait for Single Object (g_hEvent) failed. Failing test.\n" - "GetLastError returned %d\n", GetLastError()); - } - - i= 0; - while (TRUE) - { - - if (INT_MAX == i) - i =0; - i++; - //g_doworintightloop++; - } - - return 0; -} - - -/* - * Main Test Case worker thread which will suspend and resume all other worker threads - */ -DWORD -PALAPI -suspendandresumethreads( LPVOID lpParam ) -{ - - unsigned int loopcount = REPEAT_COUNT; - int Id=(int)lpParam; - unsigned int i,j,k; - DWORD dwStart; - DWORD dwWaitResult=0; - DWORD dwLastError = 0; - struct statistics stats; - struct statistics* buffer; - - - - //Initialize the Statistics Structure - stats.relationId = RELATION_ID; - stats.processId = USE_PROCESS_COUNT; - stats.operationsFailed = 0; - stats.operationsPassed = 0; - stats.operationsTotal = 0; - stats.operationTime = 0; - - - - //Wait for event to signal to start test - WaitForSingleObject(g_hEvent,INFINITE); - if (WAIT_OBJECT_0 != dwWaitResult) - { - Fail ("suspendandresumethreads: Wait for Single Object (g_hEvent) failed. Failing test.\n" - "GetLastError returned %d\n", GetLastError()); - } - - - //Capture Start Import - dwStart = GetTickCount(); - - for(i = 0; i < loopcount; i++) - { - - failFlag = false; - - //Suspend Worker Threads - for (k=0;kLogResult(Id, (char *)&stats)) - { - Fail("Error while writing to shared memory, Thread Id is[%d] and Process id is [%d]\n", Id, USE_PROCESS_COUNT); - } - - buffer = (struct statistics *)resultBuffer->getResultBuffer(Id); - //Trace("\n%d,%d,%d,%lu\n", buffer->operationsFailed, buffer->operationsPassed, buffer->operationsTotal, buffer->operationTime ); - - - return 0; -} - - - -int GetParameters( int argc, char **argv) -{ - - if( (argc != 5) || ((argc == 1) && !strcmp(argv[1],"/?")) - || !strcmp(argv[1],"/h") || !strcmp(argv[1],"/H")) - { - Trace("PAL -Composite Thread Suspension Test\n"); - Trace("Usage:\n"); - Trace("\t[PROCESS_COUNT] Greater than or Equal to 1 \n"); - Trace("\t[WORKER_THREAD_MULTIPLIER_COUNT] Greater than or Equal to 1 and Less than or Equal to 64 \n"); - Trace("\t[REPEAT_COUNT] Greater than or Equal to 1\n"); - Trace("\t[RELATION_ID [greater than or Equal to 1]\n"); - return -1; - } - -// Trace("Args 1 is [%s], Arg 2 is [%s], Arg 3 is [%s]\n", argv[1], argv[2], argv[3]); - - USE_PROCESS_COUNT = atoi(argv[1]); - if( USE_PROCESS_COUNT < 0) - { - Trace("\nPROCESS_COUNT to greater than or equal to 1\n"); - return -1; - } - - WORKER_THREAD_MULTIPLIER_COUNT = atoi(argv[2]); - if( WORKER_THREAD_MULTIPLIER_COUNT < 1 || WORKER_THREAD_MULTIPLIER_COUNT > 64) - { - Trace("\nWORKER_THREAD_MULTIPLIER_COUNT to be greater than or equal to 1 or less than or equal to 64\n"); - return -1; - } - - REPEAT_COUNT = atoi(argv[3]); - if( REPEAT_COUNT < 1) - { - Trace("\nREPEAT_COUNT to greater than or equal to 1\n"); - return -1; - } - - RELATION_ID = atoi(argv[4]); - if( RELATION_ID < 1) - { - Trace("\nRELATION_ID to be greater than or equal to 1\n"); - return -1; - } - return 0; -} diff --git a/src/pal/tests/palsuite/composite/threading/threadsuspension_switchthread/CMakeLists.txt b/src/pal/tests/palsuite/composite/threading/threadsuspension_switchthread/CMakeLists.txt deleted file mode 100644 index c3fb80714..000000000 --- a/src/pal/tests/palsuite/composite/threading/threadsuspension_switchthread/CMakeLists.txt +++ /dev/null @@ -1,18 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - mainWrapper.cpp - threadsuspension.cpp -) - -add_executable(paltest_threading_threadsuspension_switchthread - ${SOURCES} -) - -add_dependencies(paltest_threading_threadsuspension_switchthread coreclrpal) - -target_link_libraries(paltest_threading_threadsuspension_switchthread - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/composite/threading/threadsuspension_switchthread/mainWrapper.cpp b/src/pal/tests/palsuite/composite/threading/threadsuspension_switchthread/mainWrapper.cpp deleted file mode 100644 index 05a71191c..000000000 --- a/src/pal/tests/palsuite/composite/threading/threadsuspension_switchthread/mainWrapper.cpp +++ /dev/null @@ -1,274 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/* -Source Code: mainWrapper.c - -mainWrapper.c creates Composite Test Case Processes and waits for all processes to get over - -Algorithm -o Create PROCESS_COUNT processes. - -Author: RameshG -*/ - -#include -#include "resulttime.h" - -/* Test Input Variables */ -unsigned int USE_PROCESS_COUNT = 0; //default -unsigned int WORKER_THREAD_MULTIPLIER_COUNT = 0; //default -unsigned int REPEAT_COUNT = 0; //default -unsigned int SLEEP_LENGTH = 0; //default -unsigned int RELATION_ID = 0;//default -unsigned int THREAD_COUNT = 1; //There is only one suspender and resume thread for this test case - -char *testCaseName; - - -struct applicationStatistics{ - DWORD operationTime; - unsigned int relationId; - unsigned int processCount; - unsigned int threadCount; - unsigned int repeatCount; - char* buildNumber; - -}; - - -int GetParameters( int argc, char **argv) -{ - - if( (argc != 5) || ((argc == 1) && !strcmp(argv[1],"/?")) - || !strcmp(argv[1],"/h") || !strcmp(argv[1],"/H")) - { - printf("PAL -Composite Thread Suspension Test\n"); - printf("Usage:\n"); - printf("\t[PROCESS_COUNT] Greater than or Equal to 1 \n"); - printf("\t[WORKER_THREAD_MULTIPLIER_COUNT] Greater than or Equal to 1 and Less than or Equal to %d \n", MAXIMUM_WAIT_OBJECTS); - printf("\t[REPEAT_COUNT] Greater than or Equal to 1\n"); - printf("\t[RELATION_ID [greater than or Equal to 1]\n"); - return -1; - } - - // Trace("Args 1 is [%s], Arg 2 is [%s], Arg 3 is [%s]\n", argv[1], argv[2], argv[3]); - - USE_PROCESS_COUNT = atoi(argv[1]); - if( USE_PROCESS_COUNT < 0) - { - printf("\nPROCESS_COUNT to greater than or equal to 1\n"); - return -1; - } - - WORKER_THREAD_MULTIPLIER_COUNT = atoi(argv[2]); - if( WORKER_THREAD_MULTIPLIER_COUNT < 1 || WORKER_THREAD_MULTIPLIER_COUNT > 64) - { - printf("\nWORKER_THREAD_MULTIPLIER_COUNT to be greater than or equal to 1 or less than or equal to 64\n"); - return -1; - } - - REPEAT_COUNT = atoi(argv[3]); - if( REPEAT_COUNT < 1) - { - printf("\nREPEAT_COUNT to greater than or equal to 1\n"); - return -1; - } - - RELATION_ID = atoi(argv[4]); - if( RELATION_ID < 1) - { - printf("\nRELATION_ID to be greater than or equal to 1\n"); - return -1; - } - - - - return 0; -} - - int __cdecl main(INT argc, CHAR **argv) -{ - unsigned int i = 0; - HANDLE hProcess[MAXIMUM_WAIT_OBJECTS]; - DWORD processReturnCode = 0; - int testReturnCode = PASS; - STARTUPINFO si[MAXIMUM_WAIT_OBJECTS]; - PROCESS_INFORMATION pi[MAXIMUM_WAIT_OBJECTS]; - - FILE *hFile; - char fileName[MAX_PATH]; - struct applicationStatistics appStats; - - DWORD dwStart=0; - - char lpCommandLine[MAX_PATH] = ""; - - char build[] ="0000.00"; - int returnCode = 0; - - if(0 != (PAL_Initialize(argc, argv))) - { - return ( FAIL ); - } - - //Initialize Application Statistics Strucuture - appStats.relationId=RELATION_ID; - appStats.operationTime=0; - appStats.buildNumber = getBuildNumber(); - //appStats.buildNumber = build; - appStats.processCount = 0; - appStats.threadCount = 0; - appStats.repeatCount = 0; - - - - - -//Start Process Time Capture -dwStart = GetTickCount(); - - if(GetParameters(argc, argv)) - { - Fail("Error in obtaining the parameters\n"); - } - -//Assign Correct Values to the Application Stats Structure - appStats.relationId=RELATION_ID; - appStats.processCount = USE_PROCESS_COUNT; - appStats.threadCount = THREAD_COUNT ; - appStats.repeatCount = REPEAT_COUNT; - - Trace("Relation ID: %d \n", RELATION_ID); - Trace("USE_PROCESS_COUNT: %d \n", USE_PROCESS_COUNT); - Trace("WORKER_THREAD_MULTIPLIER_COUNT: %d \n", WORKER_THREAD_MULTIPLIER_COUNT); - Trace("REPEAT_COUNT: %d \n", REPEAT_COUNT); - - -_snprintf(fileName, MAX_PATH, "main_threadsuspension_%d_.txt",appStats.relationId); - - hFile = fopen(fileName, "w+"); -if(hFile == NULL) - { - Fail("Error in opening file to write application results for Thread Suspension Test with error code %d \n", GetLastError() ); - } - - - - for( i = 0; i < USE_PROCESS_COUNT; i++ ) - { - - ZeroMemory( lpCommandLine, MAX_PATH ); - if ( _snprintf( lpCommandLine, MAX_PATH-1, "threadsuspension %d %d %d %d", i, WORKER_THREAD_MULTIPLIER_COUNT, REPEAT_COUNT, RELATION_ID) < 0 ) - { - Trace ("Error: Insufficient commandline string length for for iteration [%d]\n", i); - } - - /* Zero the data structure space */ - ZeroMemory ( &pi[i], sizeof(pi[i]) ); - ZeroMemory ( &si[i], sizeof(si[i]) ); - - /* Set the process flags and standard io handles */ - si[i].cb = sizeof(si[i]); - - //Printing the Command Line - //Trace("Command Line \t %s \n", lpCommandLine); - - //Create Process - if(!CreateProcess( NULL, /* lpApplicationName*/ - lpCommandLine, /* lpCommandLine */ - NULL, /* lpProcessAttributes */ - NULL, /* lpThreadAttributes */ - TRUE, /* bInheritHandles */ - 0, /* dwCreationFlags, */ - NULL, /* lpEnvironment */ - NULL, /* pCurrentDirectory */ - &si[i], /* lpStartupInfo */ - &pi[i] /* lpProcessInformation */ - )) - { - Fail("Process Not created for [%d] and GetLastError value is %d\n", i, GetLastError()); - - } - else - { - hProcess[i] = pi[i].hProcess; - //Trace("Process created for [%d]\n", i); - } - - } - - returnCode = WaitForMultipleObjects( USE_PROCESS_COUNT, hProcess, TRUE, INFINITE); - if( WAIT_OBJECT_0 != returnCode ) - { - Trace("Wait for Object(s) @ Main thread for %d processes returned %d, and GetLastError value is %d\n", USE_PROCESS_COUNT, returnCode, GetLastError()); - testReturnCode = FAIL; - } - - for( i = 0; i < USE_PROCESS_COUNT; i++ ) - { - /* check the exit code from the process */ - if( ! GetExitCodeProcess( pi[i].hProcess, &processReturnCode ) ) - { - Trace( "GetExitCodeProcess call failed for iteration %d with error code %u\n", - i, GetLastError() ); - - testReturnCode = FAIL; - } - - if(processReturnCode == FAIL) - { - Trace( "Process [%d] failed and returned FAIL\n", i); - testReturnCode = FAIL; - } - - if(!CloseHandle(pi[i].hThread)) - { - Trace("Error:%d: CloseHandle failed for Process [%d] hThread\n", GetLastError(), i); - testReturnCode = FAIL; - } - - if(!CloseHandle(pi[i].hProcess) ) - { - Trace("Error:%d: CloseHandle failed for Process [%d] hProcess\n", GetLastError(), i); - testReturnCode = FAIL; - } - } - -//Get the end time of the process -appStats.operationTime = GetTickCount() - dwStart; - -if( testReturnCode == PASS) - { - Trace("Test Passed\n"); - } - else - { - Trace("Test Failed\n"); - } - -//Write Process Result Contents to File -if(hFile!= NULL) - { - fprintf(hFile, "%lu,%d,%d,%d,%d,%s\n", appStats.operationTime, appStats.relationId, appStats.processCount, appStats.threadCount, appStats.repeatCount, appStats.buildNumber); - } - -if (0!=fclose(hFile)) -{ - Trace("Error:%d: fclose failed for file %s\n", GetLastError(), fileName); -} - PAL_Terminate(); - - -if( testReturnCode == PASS) - { - return PASS; - } - else - { - return FAIL; - - } - -} diff --git a/src/pal/tests/palsuite/composite/threading/threadsuspension_switchthread/readme.txt b/src/pal/tests/palsuite/composite/threading/threadsuspension_switchthread/readme.txt deleted file mode 100644 index d722f1d12..000000000 --- a/src/pal/tests/palsuite/composite/threading/threadsuspension_switchthread/readme.txt +++ /dev/null @@ -1,11 +0,0 @@ -To compile: - -1) create a dat file (say threadsuspension.dat) with contents: -PAL,Composite,palsuite\composite\threading\threadsuspension,wfmo=mainWrapper.c threadsuspension.c,,, - -2) perl rrunmod.pl -r threadsuspension.dat - - -To execute: -mainWrapper [PROCESS_COUNT] [THREAD_COUNT] [REPEAT_COUNT] - diff --git a/src/pal/tests/palsuite/composite/threading/threadsuspension_switchthread/samplefile.dat b/src/pal/tests/palsuite/composite/threading/threadsuspension_switchthread/samplefile.dat deleted file mode 100644 index d6505f254..000000000 --- a/src/pal/tests/palsuite/composite/threading/threadsuspension_switchthread/samplefile.dat +++ /dev/null @@ -1,5124 +0,0 @@ -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense blackasdf dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. -By Patricia Reaney -LONDON (Reuters) - Europe, Africa and the Middle East are the best vantage points to see the first transit of Venus across the sun in more than a century on Tuesday, scientists said. - -Mostly clear skies are forecast in many parts of the three regions, but people were urged to be careful if they watch the rare event when it begins at 1:19 a.m. EDT because it could cause blindness. Views will be restricted from Asia and the Americas. - -Unlike a solar eclipse by the moon that is over in two or three minutes, Venus's transit -- which last occurred in 1882 -- will go on for six hours. - -The planet will appear as an intense black dot on the solar disc. - -Most of the sun will be visible as Venus crosses to the right from the bottom left side of the solar disc. Venus will be 26.7 million miles from earth. - -"Venus will be about 1/30 the size of the diameter of the sun, but it will be much darker and more intense than sunspots," said Dr Robert Walsh, of the University of Central Lancashire's Center for Astrophysics in northern England. - -Scientists recommend some form of indirect projection as the safest way to observe the phenomenon. - -"Never ever look directly at the sun with the naked eye or any sort of optical equipment -- telescope, binoculars or even digital camera," said Walsh. - -"Even if you glance at the sun for a short period of time you can damage your eye and lose some of your sight," he said. - -Internet sites will be covering the transit and observatories around the world have organized viewings. - -"Mainly Western Europe could see some high cloud that might prevent people from seeing it," said a spokesman for Britain's Meteorological Office. "The rest of Europe shouldn't be too bad. It should be fine." - -German astronomer Johannes Kepler first predicted a transit of Venus in 1627 but he died before he could witness one. English astronomer Jeremiah Horrocks first observed it in 1639. - -The transit occurs four times in every 243 years. There are two December transits, eight years apart, and then 121.5 years later there are two June transits, also eight years apart. After another 105.5 years the cycle begins again. - -The next transit will occur in 2012 when it will be visible from parts of Asia and the Pacific but not Europe. diff --git a/src/pal/tests/palsuite/composite/threading/threadsuspension_switchthread/threadsuspension.cpp b/src/pal/tests/palsuite/composite/threading/threadsuspension_switchthread/threadsuspension.cpp deleted file mode 100644 index a117b8617..000000000 --- a/src/pal/tests/palsuite/composite/threading/threadsuspension_switchthread/threadsuspension.cpp +++ /dev/null @@ -1,914 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source: \composite\threading\threadsuspension\threadsuspension.c -** -** Purpose: To verify Thread Suspension Reegneering effort for this milestone - - PsedoCode: - - Preparation: - Create PROCESS_COUNT processes. - Test: - Create Worker Thread - Start Reading and writing to a File - - Create Worker Thread - In an infinite loop do the following - Enter Critical Section - Increment Counter - Leave Critical Section - - Create Worker Thread - Allocate Memory and Free Memory - - Create Worker Thread - In a tight loop add numbers - - In a loop repeated REPEAT_COUNT times - - Create Thread - - Suspend all worker threads - Resume all worker threads - - At the end of the loop call PAL_Shutdown - - Parameters: - PROCESS_COUNT: Number of processes - WORKER_THREAD_MULTIPLIER_COUNT: Number of instances of worker threads in each process - REPEAT_COUNT: The number of times to execute the loop. - - Statistics Captured: - Total elapsed time - MTBF - - - Scenario: -** - One thread suspends all remaining threads which are in the middle of doing some work and resume all threads - Thread 1: Reading and Writing File - Thread 2: Enter and Leave Critical Section - Thread 3: Allocating chunks of memory - Thread 4: Perform Unsafe Operation (printf, malloc) - Thread 5: Suspends Thread 1 to Thread 4 and resumes them - -** -** -** -** Dependencies: -** -** - -** -**=========================================================*/ - -#include -#include "resultbuffer.h" - -#define BUFSIZE 4096 -#define NUMBER_OF_WORKER_THREAD_TYPES 4 -#define THREAD_MAX 64 - -#define TEST_FAIL 1 -#define TEST_PASS 0 - - -DWORD GLOBAL_COUNTER ; -DWORD UNIQUE_FILE_NUMBER=0; -HANDLE g_hEvent; - -bool failFlag = false; //To Track failure at the Operation Level - -// 2 dimensional array to hold thread handles for each worker thread -HANDLE hThread[NUMBER_OF_WORKER_THREAD_TYPES][THREAD_MAX]; - -/*unsigned int g_readfileoperation; -unsigned int g_enterleavecsoperation; -unsigned int g_allocatefreeoperation; -unsigned int g_doworintightloop; -*/ - -int TYPES_OF_WORKER_THREAD = NUMBER_OF_WORKER_THREAD_TYPES; - -int testStatus=TEST_PASS; //Indicates test failure - - -struct statistics{ - unsigned int processId; - unsigned int operationsFailed; - unsigned int operationsPassed; - unsigned int operationsTotal; - DWORD operationTime; - unsigned int relationId; -}; - -struct processStatistics{ - unsigned int processId; - DWORD operationTime; - unsigned int relationId; -}; - -/* Results Buffer */ -ResultBuffer *resultBuffer; - - -/* Test Input Variables */ -unsigned int USE_PROCESS_COUNT = 0; //Identifies the Process number. There could potentially -unsigned int WORKER_THREAD_MULTIPLIER_COUNT = 0; //In this test case this represents the number of worker thread instances -unsigned int REPEAT_COUNT = 0; //Number of Suspend Resume operation of worker threads -unsigned int RELATION_ID = 0; - - - -CRITICAL_SECTION CriticalSectionM; /* Critical Section Object (used as mutex) */ -CRITICAL_SECTION g_csUniqueFileName; - -void PALAPI setup(void); -void PALAPI cleanup(void); -void PALAPI incrementCounter(void); -DWORD PALAPI readfile( LPVOID); -DWORD PALAPI enterandleave_cs( LPVOID); -DWORD PALAPI allocateandfree_memory( LPVOID); -DWORD PALAPI doworkintightloop_cs( LPVOID); -DWORD PALAPI suspendandresumethreads( LPVOID); -int GetParameters(int, char * *); - - -//Main Entry for the Thread Suspension Test Case -int __cdecl main (int argc, char **argv) -{ - -/* -* Parameter to the threads that will be created -*/ - - -DWORD dwThrdParam = 0; -DWORD dwStart; - -/* Variables to capture the file name and the file pointer*/ -char fileName[MAX_PATH]; -char processFileName[MAX_PATH]; - -FILE *hFile, *hProcessFile; -struct statistics* buffer; -struct processStatistics *processBuffer; - -struct processStatistics processStats; - -struct statistics* tmpBuf = NULL; -int statisticsSize = 0; - -DWORD dwThreadId=0; -HANDLE hMainThread; -unsigned int i = 0; -int j = 0; - - -/* -* PAL Initialize -*/ - -if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - -//Get Parameters -if(GetParameters(argc, argv)) - { - Fail("Error in obtaining the parameters\n"); - } - - -//Setup for Process Result Collection -statisticsSize = sizeof(struct statistics); -_snprintf(processFileName, MAX_PATH, "%d_process_threadsuspension_%d_.txt", USE_PROCESS_COUNT, RELATION_ID); -hProcessFile = fopen(processFileName, "w+"); - -if(hProcessFile == NULL) - { - Fail("Error in opening file to write process results for process [%d]\n", USE_PROCESS_COUNT); - } - -//Initialize Process Stats Variables -processStats.operationTime = 0; -processStats.processId = USE_PROCESS_COUNT; -processStats.relationId = RELATION_ID; - -//Start Process Time Capture -dwStart = GetTickCount(); - -//Setup for Thread Result Collection -statisticsSize = sizeof(struct statistics); -_snprintf(fileName, MAX_PATH, "%d_thread_threadsuspension_%d_.txt", USE_PROCESS_COUNT,RELATION_ID); -hFile = fopen(fileName, "w+"); - -if(hFile == NULL) - { - Fail("Error in opening file to write thread results for process [%d]\n", USE_PROCESS_COUNT); - } - -// For each thread we will log relationid (int), processid (int), operations failed (int), passed (int), total (int) -// and number of ticks (DWORD) for the operations -resultBuffer = new ResultBuffer( 1, statisticsSize); - -/* -* Call the Setup Routine -*/ -setup(); - -Trace("WORKER_THREAD_MULTIPLIER_COUNT: %d \n", WORKER_THREAD_MULTIPLIER_COUNT); - -//Create WORKER_THREAD_MULTIPLIER_COUNT Instances of each type of worker thread -for (i=0;igetResultBuffer(i); - fprintf(hFile, "%d,%d,%d,%d,%lu,%d\n", buffer->processId, buffer->operationsFailed, buffer->operationsPassed, buffer->operationsTotal, buffer->operationTime, buffer->relationId ); - } - } - -if (0!=fclose(hFile)) -{ - Fail("Unable to write thread results to file" - "GetLastError returned %d\n", GetLastError()); -} - -cleanup(); - -if (failFlag == TRUE) -{ - return FAIL; -} -else -{ - return PASS; -} -} - - -/* -* Setup for the test case -*/ - -VOID -setup(VOID) -{ - /*Delete All Temporary Files Created by the previous execution of the test case*/ - HANDLE hSearch; - BOOL fFinished = FALSE; - WIN32_FIND_DATA FileData; - - //Start searching for .tmp files in the current directory. - hSearch = FindFirstFile("*.tmp*", &FileData); - if (hSearch == INVALID_HANDLE_VALUE) - { - //No Files That Matched Criteria - fFinished = TRUE; - } - - //Delete all files that match the pattern - while (!fFinished) - { - if (!DeleteFile(FileData.cFileName)) - { - Trace("Setup: Could not delete temporary file %s\n",FileData.cFileName ); - Fail ("GetLastError returned %d\n", GetLastError()); - } - if (!FindNextFile(hSearch, &FileData)) - { - if (GetLastError() == ERROR_NO_MORE_FILES) - { - fFinished = TRUE; - } - else - { - Fail("Unable to Delete Temporary Files, GetLastError is %d \n", GetLastError()); - } - } - } - - // Close the search handle, only if HANDLE is Valid - if (hSearch != INVALID_HANDLE_VALUE) - { - if (!FindClose(hSearch)) - { - Trace("Setup: Could not close search handle \n"); - Fail ("GetLastError returned %d\n", GetLastError()); - } - } - - g_hEvent = CreateEvent(NULL,TRUE,FALSE, NULL); - if(g_hEvent == NULL) - { - Fail("Create Event Failed\n" - "GetLastError returned %d\n", GetLastError()); - } - - InitializeCriticalSection ( &g_csUniqueFileName); -} - -/* -* Cleanup for the test case -*/ - -VOID -cleanup(VOID) -{ - //DeleteCriticalSection(&g_csUniqueFileName); - PAL_Terminate(); -} - - -VOID -incrementCounter(VOID) -{ - - if (INT_MAX == GLOBAL_COUNTER) - { - GLOBAL_COUNTER = 0; - } - - GLOBAL_COUNTER++; -} - -/* - * Worker Thread - * Read File: Read from a file and write to a temporary file and then delete the temp file - */ -DWORD -PALAPI -readfile( LPVOID lpParam ) -{ - - // Declaring Local Variables - HANDLE hFile,hTempfile; - char buffer[BUFSIZE]; - DWORD dwBytesRead, dwBytesWritten, dwBufSize=BUFSIZE; - DWORD dwWaitResult=0; - char filename[MAX_PATH]; - - //Wait for event to signal to start test - dwWaitResult = WaitForSingleObject(g_hEvent,INFINITE); - if (WAIT_OBJECT_0 != dwWaitResult) - { - Fail ("readfile: Wait for Single Object (g_hEvent) failed. Failing test.\n" - "GetLastError returned %d\n", GetLastError()); - } - - - /*Start Operation*/ - - // Open the existing file. - while(TRUE) - { - - hFile = CreateFile("samplefile.dat", // file name - GENERIC_READ, // open for reading - FILE_SHARE_READ, // Share the file for read - NULL, // default security - OPEN_EXISTING, // existing file only - FILE_ATTRIBUTE_NORMAL, // normal file - NULL); // no template - - if (hFile == INVALID_HANDLE_VALUE) - { - Trace("Could not open file \n"); - Fail ( "GetLastError returned %d\n", GetLastError()); - } - - //Generate Unique File Name to Write - //Enter CS - EnterCriticalSection(&g_csUniqueFileName); - - //Increment Number and assign to local variable - UNIQUE_FILE_NUMBER++; - _snprintf(filename, MAX_PATH, "%d_%d_tempfile.tmp", USE_PROCESS_COUNT,UNIQUE_FILE_NUMBER); - //filename = itoa(UNIQUE_FILE_NUMBER); - //Leave CS - LeaveCriticalSection(&g_csUniqueFileName); - - - // Create a temporary file with name generate above - hTempfile = CreateFile(filename, // file name - GENERIC_WRITE, // open for read/write - 0, // do not share - NULL, // default security - CREATE_ALWAYS, // overwrite existing file - FILE_ATTRIBUTE_NORMAL, // normal file - NULL); // no template - - - if (hTempfile == INVALID_HANDLE_VALUE) - { - Trace("Could not create temporary file\n"); - Fail ( "GetLastError returned %d\n", GetLastError()); - } - - // Read 4K blocks to the buffer. - // Change all characters in the buffer to upper case. - // Write the buffer to the temporary file. - - do - { - if (ReadFile(hFile, buffer, 4096, - &dwBytesRead, NULL)) - { - - WriteFile(hTempfile, buffer, dwBytesRead, - &dwBytesWritten, NULL); - } - } while (dwBytesRead == BUFSIZE); - - - - // Close both files. - if (0==CloseHandle(hFile)) - { - Trace("Could not handle hFile\n"); - Fail ( "GetLastError returned %d\n", GetLastError()); - } - - if (0==CloseHandle(hTempfile)) - { - Trace("Could not handle hTempFile\n"); - Fail ( "GetLastError returned %d\n", GetLastError()); - } - - //Delete the file that was created - if (!DeleteFile(filename)) - { - Trace("Could not delete temporary file %s\n", filename); - Fail ( "GetLastError returned %d\n", GetLastError()); - - } - - SwitchToThread(); - //g_readfileoperation++; - } - -/*End Operation*/ - - return 0; -} - - -/* Worker Thread - * Enter and Leave Nested Critical Sections - */ -DWORD -PALAPI -enterandleave_cs( LPVOID lpParam ) -{ - - //Declare Local Variables - - CRITICAL_SECTION lcs; - CRITICAL_SECTION lcsNested; - - DWORD dwWaitResult; - - //Intialize Critical Section Structures - InitializeCriticalSection ( &lcs); - InitializeCriticalSection ( &lcsNested); - - - //Wait for event to signal to start test - dwWaitResult = WaitForSingleObject(g_hEvent,INFINITE); - if (WAIT_OBJECT_0 != dwWaitResult) - { - Fail ("enterandleave_cs: Wait for Single Object (g_hEvent) failed. Failing test.\n" - "GetLastError returned %d\n", GetLastError()); - } - - //Trace("Critical Section Started\n"); - - while(TRUE) - { - EnterCriticalSection(&lcs); - - EnterCriticalSection(&lcsNested); - - incrementCounter(); - - LeaveCriticalSection(&lcsNested); - - LeaveCriticalSection(&lcs); - - SwitchToThread(); - //g_enterleavecsoperation++; - } - - //Delete Critical Section Structures - - DeleteCriticalSection(&lcs); - DeleteCriticalSection(&lcsNested); - - - return 0; -} - - -/* - * Allocate and Free Memory - */ -DWORD -PALAPI -allocateandfree_memory( LPVOID lpParam ) -{ - - - int i; - char *textArrPtr[64]; - DWORD dwWaitResult; - - //Wait for event to signal to start test - dwWaitResult = WaitForSingleObject(g_hEvent,INFINITE); - if (WAIT_OBJECT_0 != dwWaitResult) - { - Fail ("allocateandfree_memory: Wait for Single Object (g_hEvent) failed. Failing test.\n" - "GetLastError returned %d\n", GetLastError()); - } - - - while(TRUE) - { - - //do allocate and free operation - - for (i=0;i<64;i++) - { - textArrPtr[i] = (char*) malloc(BUFSIZE); - if (textArrPtr[i] == NULL) - { - Fail("Insufficient Memory Available, GetLastError is %d \n", GetLastError()); - testStatus = TEST_FAIL; - } - } - - for (i=0;i<64;i++) - { - free(textArrPtr[i]); - } - - SwitchToThread(); - //g_allocatefreeoperation++; - } - - - - - return 0; -} - -/* - * Do work in a tight loop - */ -DWORD -PALAPI -doworkintightloop_cs( LPVOID lpParam ) -{ - - unsigned int i; - DWORD dwWaitResult; - - //Wait for event to signal to start test - dwWaitResult = WaitForSingleObject(g_hEvent,INFINITE); - if (WAIT_OBJECT_0 != dwWaitResult) - { - Fail ("doworkintightloop_cs: Wait for Single Object (g_hEvent) failed. Failing test.\n" - "GetLastError returned %d\n", GetLastError()); - } - - i= 0; - while (TRUE) - { - - if (INT_MAX == i) - i =0; - i++; - //g_doworintightloop++; - - SwitchToThread(); - } - - return 0; -} - - -/* - * Main Test Case worker thread which will suspend and resume all other worker threads - */ -DWORD -PALAPI -suspendandresumethreads( LPVOID lpParam ) -{ - - unsigned int loopcount = REPEAT_COUNT; - int Id=(int)lpParam; - unsigned int i,j,k; - DWORD dwStart; - DWORD dwWaitResult=0; - DWORD dwLastError = 0; - struct statistics stats; - struct statistics* buffer; - - - - //Initialize the Statistics Structure - stats.relationId = RELATION_ID; - stats.processId = USE_PROCESS_COUNT; - stats.operationsFailed = 0; - stats.operationsPassed = 0; - stats.operationsTotal = 0; - stats.operationTime = 0; - - - - //Wait for event to signal to start test - WaitForSingleObject(g_hEvent,INFINITE); - if (WAIT_OBJECT_0 != dwWaitResult) - { - Fail ("suspendandresumethreads: Wait for Single Object (g_hEvent) failed. Failing test.\n" - "GetLastError returned %d\n", GetLastError()); - } - - - //Capture Start Import - dwStart = GetTickCount(); - - for(i = 0; i < loopcount; i++) - { - - failFlag = false; - - //Suspend Worker Threads - for (k=0;kLogResult(Id, (char *)&stats)) - { - Fail("Error while writing to shared memory, Thread Id is[%d] and Process id is [%d]\n", Id, USE_PROCESS_COUNT); - } - - buffer = (struct statistics *)resultBuffer->getResultBuffer(Id); - //Trace("\n%d,%d,%d,%lu\n", buffer->operationsFailed, buffer->operationsPassed, buffer->operationsTotal, buffer->operationTime ); - - - return 0; -} - - - -int GetParameters( int argc, char **argv) -{ - - if( (argc != 5) || ((argc == 1) && !strcmp(argv[1],"/?")) - || !strcmp(argv[1],"/h") || !strcmp(argv[1],"/H")) - { - Trace("PAL -Composite Thread Suspension Test\n"); - Trace("Usage:\n"); - Trace("\t[PROCESS_COUNT] Greater than or Equal to 1 \n"); - Trace("\t[WORKER_THREAD_MULTIPLIER_COUNT] Greater than or Equal to 1 and Less than or Equal to 64 \n"); - Trace("\t[REPEAT_COUNT] Greater than or Equal to 1\n"); - Trace("\t[RELATION_ID [greater than or Equal to 1]\n"); - return -1; - } - -// Trace("Args 1 is [%s], Arg 2 is [%s], Arg 3 is [%s]\n", argv[1], argv[2], argv[3]); - - USE_PROCESS_COUNT = atoi(argv[1]); - if( USE_PROCESS_COUNT < 0) - { - Trace("\nPROCESS_COUNT to greater than or equal to 1\n"); - return -1; - } - - WORKER_THREAD_MULTIPLIER_COUNT = atoi(argv[2]); - if( WORKER_THREAD_MULTIPLIER_COUNT < 1 || WORKER_THREAD_MULTIPLIER_COUNT > 64) - { - Trace("\nWORKER_THREAD_MULTIPLIER_COUNT to be greater than or equal to 1 or less than or equal to 64\n"); - return -1; - } - - REPEAT_COUNT = atoi(argv[3]); - if( REPEAT_COUNT < 1) - { - Trace("\nREPEAT_COUNT to greater than or equal to 1\n"); - return -1; - } - - RELATION_ID = atoi(argv[4]); - if( RELATION_ID < 1) - { - Trace("\nRELATION_ID to be greater than or equal to 1\n"); - return -1; - } - return 0; -} diff --git a/src/pal/tests/palsuite/composite/wfmo/CMakeLists.txt b/src/pal/tests/palsuite/composite/wfmo/CMakeLists.txt deleted file mode 100644 index 3f497d76c..000000000 --- a/src/pal/tests/palsuite/composite/wfmo/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - main.cpp - mutex.cpp -) - -add_executable(paltest_composite_wfmo - ${SOURCES} -) - -add_dependencies(paltest_composite_wfmo coreclrpal) - -target_link_libraries(paltest_composite_wfmo - ${COMMON_TEST_LIBRARIES} - rt -) diff --git a/src/pal/tests/palsuite/composite/wfmo/main.cpp b/src/pal/tests/palsuite/composite/wfmo/main.cpp deleted file mode 100644 index d186aa7b8..000000000 --- a/src/pal/tests/palsuite/composite/wfmo/main.cpp +++ /dev/null @@ -1,239 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** Source Code: main.c and mutex.c -** main.c creates process and waits for all processes to get over -** mutex.c creates a mutex and then calls threads which will contend for the mutex -** -** This test is for WFMO Test case for Mutex -** Algorithm -** o Create PROCESS_COUNT processes. -** o Main Thread of each process creates OBJECT_TYPE Object -** -** Author: ShamitP -** -** -**============================================================ -*/ - -#include -#include "resulttime.h" - -/* Test Input Variables */ -unsigned int PROCESS_COUNT = 3; -unsigned int THREAD_COUNT = 30; -unsigned int REPEAT_COUNT = 40; -unsigned int SLEEP_LENGTH = 4; -unsigned int RELATION_ID = 1001; - - - -struct TestStats{ - DWORD operationTime; - unsigned int relationId; - unsigned int processCount; - unsigned int threadCount; - unsigned int repeatCount; - char* buildNumber; - -}; - -int GetParameters( int argc, char **argv) -{ - if( (argc != 6) || ((argc == 1) && !strcmp(argv[1],"/?")) - || !strcmp(argv[1],"/h") || !strcmp(argv[1],"/H")) - { - printf("PAL -Composite WFMO Test\n"); - printf("Usage:\n"); - printf("main\n\t[PROCESS_COUNT [greater than 0] \n"); - printf("\t[THREAD_COUNT [greater than 0] \n"); - printf("\t[REPEAT_COUNT [greater than 0]\n"); - printf("\t[SLEEP_LENGTH [greater than 0]\n"); - printf("\t[RELATION_ID [greater than 0]\n"); - - - - return -1; - } - - PROCESS_COUNT = atoi(argv[1]); - if( (PROCESS_COUNT < 1) || (PROCESS_COUNT > MAXIMUM_WAIT_OBJECTS) ) - { - printf("\nMain Process:Invalid PROCESS_COUNT number, Pass greater than 1 and less than PROCESS_COUNT %d\n", MAXIMUM_WAIT_OBJECTS); - return -1; - } - - THREAD_COUNT = atoi(argv[2]); - if( (THREAD_COUNT < 1) || (THREAD_COUNT > MAXIMUM_WAIT_OBJECTS) ) - { - printf("\nInvalid THREAD_COUNT number, Pass greater than 1 and less than %d\n", MAXIMUM_WAIT_OBJECTS); - return -1; - } - - REPEAT_COUNT = atoi(argv[3]); - if( REPEAT_COUNT < 1) - { - printf("\nMain Process:Invalid REPEAT_COUNT number, Pass greater than 1\n"); - return -1; - } - - SLEEP_LENGTH = atoi(argv[4]); - if( SLEEP_LENGTH < 1) - { - printf("\nMain Process:Invalid SLEEP_LENGTH number, Pass greater than 1\n"); - return -1; - } - - RELATION_ID = atoi(argv[5]); - if( RELATION_ID < 1) - { - printf("\nMain Process:Invalid RELATION_ID number, Pass greater than 1\n"); - return -1; - } - - - - return 0; -} - - int __cdecl main(INT argc, CHAR **argv) -{ - unsigned int i = 0; - HANDLE hProcess[MAXIMUM_WAIT_OBJECTS]; - - STARTUPINFO si[MAXIMUM_WAIT_OBJECTS]; - PROCESS_INFORMATION pi[MAXIMUM_WAIT_OBJECTS]; - - char lpCommandLine[MAX_PATH] = ""; - - int returnCode = 0; - DWORD processReturnCode = 0; - int testReturnCode = PASS; - - char fileName[MAX_PATH]; - FILE *pFile = NULL; - DWORD dwStartTime; - struct TestStats testStats; - - if(0 != (PAL_Initialize(argc, argv))) - { - return ( FAIL ); - } - - if(GetParameters(argc, argv)) - { - Fail("Error in obtaining the parameters\n"); - } - - /* Register the start time */ - dwStartTime = GetTickCount(); - testStats.relationId = 0; - testStats.relationId = RELATION_ID; - testStats.processCount = PROCESS_COUNT; - testStats.threadCount = THREAD_COUNT; - testStats.repeatCount = REPEAT_COUNT; - testStats.buildNumber = getBuildNumber(); - - - - _snprintf(fileName, MAX_PATH, "main_wfmo_%d_.txt",testStats.relationId); - pFile = fopen(fileName, "w+"); - if(pFile == NULL) - { - Fail("Error in opening main file for write\n"); - } - - for( i = 0; i < PROCESS_COUNT; i++ ) - { - - ZeroMemory( lpCommandLine, MAX_PATH ); - if ( _snprintf( lpCommandLine, MAX_PATH-1, "mutex %d %d %d %d %d", i, THREAD_COUNT, REPEAT_COUNT, SLEEP_LENGTH, RELATION_ID) < 0 ) - { - Trace ("Error: Insufficient commandline string length for for iteration [%d]\n", i); - } - - /* Zero the data structure space */ - ZeroMemory ( &pi[i], sizeof(pi[i]) ); - ZeroMemory ( &si[i], sizeof(si[i]) ); - - /* Set the process flags and standard io handles */ - si[i].cb = sizeof(si[i]); - - //Create Process - if(!CreateProcess( NULL, /* lpApplicationName*/ - lpCommandLine, /* lpCommandLine */ - NULL, /* lpProcessAttributes */ - NULL, /* lpThreadAttributes */ - TRUE, /* bInheritHandles */ - 0, /* dwCreationFlags, */ - NULL, /* lpEnvironment */ - NULL, /* pCurrentDirectory */ - &si[i], /* lpStartupInfo */ - &pi[i] /* lpProcessInformation */ - )) - { - Fail("Process Not created for [%d], the error code is [%d]\n", i, GetLastError()); - } - else - { - hProcess[i] = pi[i].hProcess; - // Trace("Process created for [%d]\n", i); - } - - } - - returnCode = WaitForMultipleObjects( PROCESS_COUNT, hProcess, TRUE, INFINITE); - if( WAIT_OBJECT_0 != returnCode ) - { - Trace("Wait for Object(s) @ Main thread for %d processes returned %d, and GetLastError value is %d\n", PROCESS_COUNT, returnCode, GetLastError()); - } - - for( i = 0; i < PROCESS_COUNT; i++ ) - { - /* check the exit code from the process */ - if( ! GetExitCodeProcess( pi[i].hProcess, &processReturnCode ) ) - { - Trace( "GetExitCodeProcess call failed for iteration %d with error code %u\n", - i, GetLastError() ); - - testReturnCode = FAIL; - } - - if(processReturnCode == FAIL) - { - Trace( "Process [%d] failed and returned FAIL\n", i); - testReturnCode = FAIL; - } - - if(!CloseHandle(pi[i].hThread)) - { - Trace("Error:%d: CloseHandle failed for Process [%d] hThread\n", GetLastError(), i); - } - - if(!CloseHandle(pi[i].hProcess) ) - { - Trace("Error:%d: CloseHandle failed for Process [%d] hProcess\n", GetLastError(), i); - } - } - - testStats.operationTime = GetTimeDiff(dwStartTime); - fprintf(pFile, "%d,%d,%d,%d,%d,%s\n", testStats.operationTime, testStats.relationId, testStats.processCount, testStats.threadCount, testStats.repeatCount, testStats.buildNumber); - if(fclose(pFile)) - { - Trace("Error: fclose failed for pFile\n"); - testReturnCode = FAIL; - } - - if( testReturnCode == PASS) - { - Trace("Test Passed\n"); - } - else - { - Trace("Test Failed\n"); - } - PAL_Terminate(); - return testReturnCode; -} diff --git a/src/pal/tests/palsuite/composite/wfmo/mutex.cpp b/src/pal/tests/palsuite/composite/wfmo/mutex.cpp deleted file mode 100644 index c8ed01426..000000000 --- a/src/pal/tests/palsuite/composite/wfmo/mutex.cpp +++ /dev/null @@ -1,365 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -**Source Code: main.c and mutex.c -** main.c creates process and waits for all processes to get over -** mutex.c creates a mutex and then calls threads which will -** contend for the mutex -** -** This test is for WFMO Test case for Mutex -** Algorithm -** o Create PROCESS_COUNT processes. -** o Main Thread of each process creates OBJECT_TYPE Object -** -** Author: ShamitP -** -** -**============================================================ -*/ - -#include -#include "resultbuffer.h" -#include "resulttime.h" - -/* Test Input Variables */ -unsigned int USE_PROCESS_COUNT = 0; -unsigned int THREAD_COUNT = 0; -unsigned int REPEAT_COUNT = 0; -unsigned int SLEEP_LENGTH = 0; -unsigned int RELATION_ID = 1001; - - -/* Capture statistics at per thread basis */ -struct statistics{ - unsigned int processId; - unsigned int operationsFailed; - unsigned int operationsPassed; - unsigned int operationsTotal; - DWORD operationTime; - unsigned int relationId; - -}; - -struct ProcessStats{ - unsigned int processId; - DWORD operationTime; - unsigned int relationId; -}; - -/* Handle to signal threads to start the tests */ -HANDLE StartTestsEvHandle = NULL; -/* Handle to mutex which will be contended by threads */ -HANDLE hMutexHandle = NULL; -/* Results Buffer */ -ResultBuffer *resultBuffer = NULL; - -int testStatus; - -void PALAPI Run_Thread(LPVOID lpParam); - -int GetParameters( int argc, char **argv) -{ - if( (argc != 6) || ((argc == 1) && !strcmp(argv[1],"/?")) - || !strcmp(argv[1],"/h") || !strcmp(argv[1],"/H")) - { - printf("PAL -Composite WFMO Test\n"); - printf("Usage:\n"); - printf("mutex\n\t[USE_PROCESS_COUNT [greater than 0] \n"); - printf("\t[THREAD_COUNT [greater than 0] \n"); - printf("\t[REPEAT_COUNT [greater than 0]\n"); - printf("\t[SLEEP_LENGTH [greater than 0]\n"); - printf("\t[RELATION_ID [greater than 0]\n"); - - - return -1; - } - - // Trace("Args 1 is [%s], Arg 2 is [%s], Arg 3 is [%s]\n", argv[1], argv[2], argv[3]); - - USE_PROCESS_COUNT = atoi(argv[1]); - if( USE_PROCESS_COUNT < 0) - { - printf("\nInvalid USE_PROCESS_COUNT number, Pass greater than 1\n"); - return -1; - } - - THREAD_COUNT = atoi(argv[2]); - if( (THREAD_COUNT < 1) || (THREAD_COUNT > MAXIMUM_WAIT_OBJECTS) ) - { - printf("\nInvalid THREAD_COUNT number, Pass greater than 1 and less than %d\n", MAXIMUM_WAIT_OBJECTS); - return -1; - } - - REPEAT_COUNT = atoi(argv[3]); - if( REPEAT_COUNT < 1) - { - printf("\nInvalid REPEAT_COUNT number, Pass greater than 1\n"); - return -1; - } - - SLEEP_LENGTH = atoi(argv[4]); - if( SLEEP_LENGTH < 1) - { - printf("\nMain Process:Invalid SLEEP_LENGTH number, Pass greater than 1\n"); - return -1; - } - - RELATION_ID = atoi(argv[5]); - if( RELATION_ID < 1) - { - printf("\nMain Process:Invalid RELATION_ID number, Pass greater than 1\n"); - return -1; - } - - return 0; -} - - int __cdecl main(INT argc, CHAR **argv) -{ - unsigned int i = 0; - HANDLE hThread[MAXIMUM_WAIT_OBJECTS]; - DWORD threadId[MAXIMUM_WAIT_OBJECTS]; - int returnCode = 0; - - DWORD dwParam = 0; - - /* Variables to capture the file name and the file pointer at thread level*/ - char fileName[MAX_PATH]; - FILE *pFile = NULL; - struct statistics* buffer = NULL; - int statisticsSize = 0; - - /* Variables to capture the file name and the file pointer at process level*/ - char processFileName[MAX_PATH]; - FILE *pProcessFile = NULL; - struct ProcessStats processStats; - DWORD dwStartTime; - - testStatus = PASS; - - if(0 != (PAL_Initialize(argc, argv))) - { - return ( FAIL ); - } - - if(GetParameters(argc, argv)) - { - Fail("Error in obtaining the parameters\n"); - } -// Trace("Process created, value of process count is [%d] and no. of threads is [%d]\n", USE_PROCESS_COUNT, THREAD_COUNT); - - /* Register the start time */ - dwStartTime = GetTickCount(); - processStats.relationId = RELATION_ID; - processStats.processId = USE_PROCESS_COUNT; - - _snprintf(processFileName, MAX_PATH, "%d_process_wfmo_%d_.txt", USE_PROCESS_COUNT, RELATION_ID); - pProcessFile = fopen(processFileName, "w+"); - if(pProcessFile == NULL) - { - Fail("Error:%d: in opening Process File for write for process [%d]\n", GetLastError(), USE_PROCESS_COUNT); - } - - statisticsSize = sizeof(struct statistics); - - _snprintf(fileName, MAX_PATH, "%d_thread_wfmo_%d_.txt", USE_PROCESS_COUNT, RELATION_ID); - pFile = fopen(fileName, "w+"); - if(pFile == NULL) - { - Fail("Error in opening file for write for process [%d], error [%d]\n", USE_PROCESS_COUNT, GetLastError()); - } - // For each thread we will log operations failed (int), passed (int), total (int) - // and number of ticks (DWORD) for the operations - resultBuffer = new ResultBuffer( THREAD_COUNT, statisticsSize); - - StartTestsEvHandle = CreateEvent( NULL, /* lpEventAttributes*/ - TRUE, /* bManualReset */ - FALSE, /* bInitialState */ - NULL); /* name of Event */ - - if( StartTestsEvHandle == NULL ) - { - Fail("Error:%d: Unexpected failure " - "to create start tests Event for process count %d\n", GetLastError(), USE_PROCESS_COUNT ); - - } - - /* Create StartTest Event */ - hMutexHandle = CreateMutex( - NULL, - FALSE, /* bInitialOwner, owns initially */ - NULL - ); - - if( hMutexHandle == NULL) - { - Fail("Unable to create Mutex handle for process id [%d], returned error [%d]\n", i, GetLastError()); - } - - /* We already assume that the mutex was created previously*/ - for( i = 0; i < THREAD_COUNT; i++ ) - { - dwParam = (int) i; - //Create thread - hThread[i] = CreateThread( - NULL, /* no security attributes */ - 0, /* use default stack size */ - (LPTHREAD_START_ROUTINE)Run_Thread,/* thread function */ - (LPVOID)dwParam, /* argument to thread function */ - 0, /* use default creation flags */ - &threadId[i] /* returns the thread identifier*/ - ); - - if(hThread[i] == NULL) - { - Fail("Create Thread failed for %d process, and GetLastError value is %d\n", USE_PROCESS_COUNT, GetLastError()); - } - - } - - if (!SetEvent(StartTestsEvHandle)) - { - Fail("Set Event for Start Tests failed for %d process, and GetLastError value is %d\n", USE_PROCESS_COUNT, GetLastError()); - } - /* Test running */ - - if( THREAD_COUNT != 1 ) - { - returnCode = WaitForMultipleObjects(THREAD_COUNT, hThread, TRUE, INFINITE); - } - else - { - returnCode = WaitForSingleObject(hThread[0], INFINITE); - } - - if( WAIT_OBJECT_0 != returnCode ) - { - Trace("Wait for Object(s) for %d process returned %d, and GetLastError value is %d\n", USE_PROCESS_COUNT, returnCode, GetLastError()); - testStatus = FAIL; - } - - processStats.operationTime = GetTimeDiff(dwStartTime); - - /* Write to a file*/ - if(pFile!= NULL) - { - for( i = 0; i < THREAD_COUNT; i++ ) - { - buffer = (struct statistics *)resultBuffer->getResultBuffer(i); - returnCode = fprintf(pFile, "%d,%d,%d,%d,%lu,%d\n", buffer->processId, buffer->operationsFailed, buffer->operationsPassed, buffer->operationsTotal, buffer->operationTime, buffer->relationId ); - //Trace("Iteration %d over\n", i); - - } - } - if(fclose(pFile)) - { - Trace("Error: fclose failed for pFile at Process %d\n", USE_PROCESS_COUNT); - testStatus = FAIL; - } - - fprintf(pProcessFile, "%d,%d,%d\n", USE_PROCESS_COUNT, processStats.operationTime, processStats.relationId ); - if(fclose(pProcessFile)) - { - Trace("Error: fclose failed for pProcessFile at Process %d\n", USE_PROCESS_COUNT); - testStatus = FAIL; - } - - /* Logging for the test case over, clean up the handles */ - // Trace("Test Process %d done\n", USE_PROCESS_COUNT); - //Trace("Contents of the buffer are [%s]\n", resultBuffer->getResultBuffer()); - for( i = 0; i < THREAD_COUNT; i++ ) - { - if(!CloseHandle(hThread[i]) ) - { - Trace("Error:%d: CloseHandle failed for Process [%d] hThread[%d]\n", GetLastError(), USE_PROCESS_COUNT, i); - testStatus = FAIL; - } - } - - if(!CloseHandle(StartTestsEvHandle)) - { - Trace("Error:%d: CloseHandle failed for Process [%d] StartTestsEvHandle\n", GetLastError(), USE_PROCESS_COUNT); - testStatus = FAIL; - } - - PAL_Terminate(); - return testStatus; -} - -void PALAPI Run_Thread (LPVOID lpParam) -{ - unsigned int i = 0; - struct statistics stats; - - DWORD dwWaitResult; - DWORD dwStartTime; - - stats.relationId = RELATION_ID; - stats.processId = USE_PROCESS_COUNT; - stats.operationsFailed = 0; - stats.operationsPassed = 0; - stats.operationsTotal = 0; - stats.operationTime = 0; - - int Id=(int)lpParam; - - dwWaitResult = WaitForSingleObject( - StartTestsEvHandle, // handle to mutex - INFINITE); - - if(dwWaitResult != WAIT_OBJECT_0) - { - Trace("Error:%d: while waiting for StartTest Event@ thread %d\n", GetLastError(), Id); - testStatus = FAIL; - } - - /* Register the start time */ - dwStartTime = GetTickCount(); - - /* Run the tests repeat count times */ - for( i = 0; i < REPEAT_COUNT; i++ ) - { - dwWaitResult = WaitForSingleObject( - hMutexHandle, // handle to mutex - INFINITE); - - if(dwWaitResult != WAIT_OBJECT_0) - { - Trace("Error:%d: while waiting for onject @ thread %d, # iter %d\n", GetLastError(), Id, i); - stats.operationsFailed += 1; - stats.operationsTotal += 1; - testStatus = FAIL; - continue; - } - - Sleep(SLEEP_LENGTH); - - if (!ReleaseMutex(hMutexHandle)) - { - // Deal with error. - Trace("Error:%d: while releasing mutex @ thread %d # iter %d\n", GetLastError(), Id, i); - stats.operationsFailed += 1; - stats.operationsTotal += 1; - // do we need to have while true loop to attempt to release mutex...? - testStatus = FAIL; - continue; - } - - stats.operationsTotal += 1; - stats.operationsPassed += 1; - -// Trace("Successs while releasing mutex @ iteration %d -> thread %d -> Process %d\n", i, Id, USE_PROCESS_COUNT); - - } - - stats.operationTime = GetTimeDiff(dwStartTime); - // Trace("Operation Time %lu, Process Count [%d], ThreadCount[%d]\n", stats.operationTime, USE_PROCESS_COUNT, Id); - - if(resultBuffer->LogResult(Id, (char *)&stats)) - { - Fail("Error:%d: while writing to shared memory, Thread Id is[%d] and Process id is [%d]\n", GetLastError(), Id, USE_PROCESS_COUNT); - } - // Trace("Contents of the buffer are after thread [%d]\n", Id); -} diff --git a/src/pal/tests/palsuite/composite/wfmo/readme.txt b/src/pal/tests/palsuite/composite/wfmo/readme.txt deleted file mode 100644 index 6be55d8ff..000000000 --- a/src/pal/tests/palsuite/composite/wfmo/readme.txt +++ /dev/null @@ -1,22 +0,0 @@ -To compile: - -1) create a dat file (say wfmo.dat) with contents: -PAL,Composite,palsuite\composite\wfmo,wfmo=main.c mutex.c,,, - -2) perl rrunmod.pl -r wfmo.dat - - -To execute: -main [PROCESS_COUNT] [THREAD_COUNT] [REPEAT_COUNT] [SLEEP_LENGTH] - -Output: -The performance numbers will be in _wfmo.txt -(will be at palsuite\composite\wfmo\obj[r|c|d] directory if u use rrunmod.pl) - -So if process_count is 3, you will have files 0_wfmo.txt, 1_wfmo.txt and so on… - -For each process txt file created, -each row represents a thread data (process id, number of failures, number of pass, total number of repeated operations and an integer that will be used to identify a run -(currently zero)). - - diff --git a/src/pal/tests/palsuite/debug_api/CMakeLists.txt b/src/pal/tests/palsuite/debug_api/CMakeLists.txt deleted file mode 100644 index a568131d3..000000000 --- a/src/pal/tests/palsuite/debug_api/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -# TODO: make these tests compile -# add_subdirectory(DebugBreak) -# add_subdirectory(WriteProcessMemory) - -add_subdirectory(OutputDebugStringA) -add_subdirectory(OutputDebugStringW) - diff --git a/src/pal/tests/palsuite/debug_api/DebugBreak/CMakeLists.txt b/src/pal/tests/palsuite/debug_api/DebugBreak/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/debug_api/DebugBreak/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/debug_api/DebugBreak/test1/CMakeLists.txt b/src/pal/tests/palsuite/debug_api/DebugBreak/test1/CMakeLists.txt deleted file mode 100644 index 5eba74f9f..000000000 --- a/src/pal/tests/palsuite/debug_api/DebugBreak/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_debugbreak_test1 - ${SOURCES} -) - -add_dependencies(paltest_debugbreak_test1 coreclrpal) - -target_link_libraries(paltest_debugbreak_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/debug_api/DebugBreak/test1/test1.cpp b/src/pal/tests/palsuite/debug_api/DebugBreak/test1/test1.cpp deleted file mode 100644 index 2b10b9ad9..000000000 --- a/src/pal/tests/palsuite/debug_api/DebugBreak/test1/test1.cpp +++ /dev/null @@ -1,47 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: test1.c -** -** Purpose: Tests that DebugBreak works in the grossest fashion. -** -** -**============================================================*/ - -#include - -int __cdecl main(int argc, char *argv[]) -{ - BOOL bTry = FALSE; - - if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - PAL_TRY - { - DebugBreak(); - if (!bTry) - { - Fail("DebugBreak: Continued in Try block.\n"); - } - } - PAL_EXCEPT(EXCEPTION_EXECUTE_HANDLER) - { - bTry = TRUE; - } - PAL_ENDTRY; - - if (!bTry) - { - Fail("DebugBreak: Did not reach the exception block.\n"); - } - - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/debug_api/DebugBreak/test1/testinfo.dat b/src/pal/tests/palsuite/debug_api/DebugBreak/test1/testinfo.dat deleted file mode 100644 index 25c480ecc..000000000 --- a/src/pal/tests/palsuite/debug_api/DebugBreak/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Debug -Function = DebugBreak -Name = DebugBreak test #1 -TYPE = DEFAULT -EXE1 = test1 -Description -= Tests that DebugBreak "works". This will require case by case -= manual interpretation. diff --git a/src/pal/tests/palsuite/debug_api/OutputDebugStringA/CMakeLists.txt b/src/pal/tests/palsuite/debug_api/OutputDebugStringA/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/debug_api/OutputDebugStringA/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/debug_api/OutputDebugStringA/test1/CMakeLists.txt b/src/pal/tests/palsuite/debug_api/OutputDebugStringA/test1/CMakeLists.txt deleted file mode 100644 index 46a870c11..000000000 --- a/src/pal/tests/palsuite/debug_api/OutputDebugStringA/test1/CMakeLists.txt +++ /dev/null @@ -1,34 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(TESTSOURCES - test1.cpp -) - -add_executable(paltest_outputdebugstringa_test1 - ${TESTSOURCES} -) - -add_dependencies(paltest_outputdebugstringa_test1 coreclrpal) - -target_link_libraries(paltest_outputdebugstringa_test1 - ${COMMON_TEST_LIBRARIES} -) - - -set(HELPERSOURCES - helper.cpp -) - -add_executable(paltest_outputdebugstringa_test1_helper - ${HELPERSOURCES} -) - -add_dependencies(paltest_outputdebugstringa_test1_helper coreclrpal) - -target_link_libraries(paltest_outputdebugstringa_test1_helper - ${COMMON_TEST_LIBRARIES} -) - - diff --git a/src/pal/tests/palsuite/debug_api/OutputDebugStringA/test1/helper.cpp b/src/pal/tests/palsuite/debug_api/OutputDebugStringA/test1/helper.cpp deleted file mode 100644 index 90073dfed..000000000 --- a/src/pal/tests/palsuite/debug_api/OutputDebugStringA/test1/helper.cpp +++ /dev/null @@ -1,35 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: helper.c -** -** Purpose: Intended to be the child process of a debugger. Calls -** OutputDebugStringA once with a normal string, once with an empty -** string -** -** -**============================================================*/ - -#include - -int __cdecl main(int argc, char *argv[]) -{ - if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - OutputDebugStringA("Foo!\n"); - - OutputDebugStringA(""); - - /* give a chance to the debugger process to read the debug string before - exiting */ - Sleep(1000); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/debug_api/OutputDebugStringA/test1/test1.cpp b/src/pal/tests/palsuite/debug_api/OutputDebugStringA/test1/test1.cpp deleted file mode 100644 index 080c6ac53..000000000 --- a/src/pal/tests/palsuite/debug_api/OutputDebugStringA/test1/test1.cpp +++ /dev/null @@ -1,94 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: test1.c -** -** Purpose: Debugs the helper application. Checks that certain events, in -** particular the OUTPUT_DEBUG_STRING_EVENT, is generated correctly -** and gives the correct values. -** -** -**============================================================*/ - -#include - -const int DELAY_MS = 2000; - -struct OutputCheck -{ - DWORD ExpectedEventCode; - DWORD ExpectedUnicode; - char *ExpectedStr; -}; - -int __cdecl main(int argc, char *argv[]) -{ - - PROCESS_INFORMATION pi; - STARTUPINFO si; - - if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - ZeroMemory( &si, sizeof(si) ); - si.cb = sizeof(si); - ZeroMemory( &pi, sizeof(pi) ); - - /* Create a new process. This is the process to be Debugged */ - if(!CreateProcess( NULL, "helper", NULL, NULL, - FALSE, 0, NULL, NULL, &si, &pi)) - { - Fail("ERROR: CreateProcess failed to load executable 'helper'. " - "GetLastError() returned %d.\n",GetLastError()); - } - - /* This is the main loop. It exits when the process which is being - debugged is finished executing. - */ - - while(1) - { - DWORD dwRet = 0; - dwRet = WaitForSingleObject(pi.hProcess, - DELAY_MS /* Wait for 2 seconds max*/ - ); - - if (dwRet != WAIT_OBJECT_0) - { - Trace("WaitForSingleObjectTest:WaitForSingleObject " - "failed (%x) after waiting %d seconds for the helper\n", - GetLastError(), DELAY_MS / 1000); - } - else - { - DWORD dwExitCode; - - /* check the exit code from the process */ - if( ! GetExitCodeProcess( pi.hProcess, &dwExitCode ) ) - { - DWORD dwError; - - dwError = GetLastError(); - CloseHandle ( pi.hProcess ); - CloseHandle ( pi.hThread ); - Fail( "GetExitCodeProcess call failed with error code %d\n", - dwError ); - } - - if(dwExitCode != STILL_ACTIVE) { - CloseHandle(pi.hThread); - CloseHandle(pi.hProcess); - break; - } - Trace("still executing %d..\n", dwExitCode); - } - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/debug_api/OutputDebugStringA/test1/testinfo.dat b/src/pal/tests/palsuite/debug_api/OutputDebugStringA/test1/testinfo.dat deleted file mode 100644 index d49e9048d..000000000 --- a/src/pal/tests/palsuite/debug_api/OutputDebugStringA/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Debug -Function = OutputDebugStringA -Name = OutputDebugStringA test #1 -TYPE = DEFAULT -EXE1 = test1 -EXE2 = helper -Description -=Tests that OutputDebugString generates the correct debugging event behaviour. diff --git a/src/pal/tests/palsuite/debug_api/OutputDebugStringW/CMakeLists.txt b/src/pal/tests/palsuite/debug_api/OutputDebugStringW/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/debug_api/OutputDebugStringW/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/debug_api/OutputDebugStringW/test1/CMakeLists.txt b/src/pal/tests/palsuite/debug_api/OutputDebugStringW/test1/CMakeLists.txt deleted file mode 100644 index 802de0ee9..000000000 --- a/src/pal/tests/palsuite/debug_api/OutputDebugStringW/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_outputdebugstringw_test1 - ${SOURCES} -) - -add_dependencies(paltest_outputdebugstringw_test1 coreclrpal) - -target_link_libraries(paltest_outputdebugstringw_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/debug_api/OutputDebugStringW/test1/test1.cpp b/src/pal/tests/palsuite/debug_api/OutputDebugStringW/test1/test1.cpp deleted file mode 100644 index 88b55427b..000000000 --- a/src/pal/tests/palsuite/debug_api/OutputDebugStringW/test1/test1.cpp +++ /dev/null @@ -1,41 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: test1.c -** -** Purpose: Intended to be the child process of a debugger. Calls -** OutputDebugStringW once with a normal string, once with an empty -** string -** -** -**============================================================*/ - -#define UNICODE -#include - -int __cdecl main(int argc, char *argv[]) -{ - WCHAR *str1; - WCHAR *str2; - - if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - str1 = convert("Foo!"); - str2 = convert(""); - - OutputDebugStringW(str1); - - OutputDebugStringW(str2); - - free(str1); - free(str2); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/debug_api/OutputDebugStringW/test1/testinfo.dat b/src/pal/tests/palsuite/debug_api/OutputDebugStringW/test1/testinfo.dat deleted file mode 100644 index d6bc4ac5a..000000000 --- a/src/pal/tests/palsuite/debug_api/OutputDebugStringW/test1/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Debug -Function = OutputDebugStringW -Name = OutputDebugStringW test #1 -TYPE = DEFAULT -EXE1 = test1 -Description -=Tests that OutputDebugString generates the correct debugging event behaviour. diff --git a/src/pal/tests/palsuite/debug_api/WriteProcessMemory/CMakeLists.txt b/src/pal/tests/palsuite/debug_api/WriteProcessMemory/CMakeLists.txt deleted file mode 100644 index 078b55691..000000000 --- a/src/pal/tests/palsuite/debug_api/WriteProcessMemory/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test3) -add_subdirectory(test4) - diff --git a/src/pal/tests/palsuite/debug_api/WriteProcessMemory/test1/CMakeLists.txt b/src/pal/tests/palsuite/debug_api/WriteProcessMemory/test1/CMakeLists.txt deleted file mode 100644 index af19587ff..000000000 --- a/src/pal/tests/palsuite/debug_api/WriteProcessMemory/test1/CMakeLists.txt +++ /dev/null @@ -1,32 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(TESTSOURCES - test1.cpp -) - -add_executable(paltest_writeprocessmemory_test1 - ${TESTSOURCES} -) - -add_dependencies(paltest_writeprocessmemory_test1 coreclrpal) - -target_link_libraries(paltest_writeprocessmemory_test1 - ${COMMON_TEST_LIBRARIES} -) - - -set(HELPERSOURCES - helper.cpp -) - -add_executable(paltest_writeprocessmemory_test1_helper - ${HELPERSOURCES} -) - -add_dependencies(paltest_writeprocessmemory_test1_helper coreclrpal) - -target_link_libraries(paltest_writeprocessmemory_test1_helper - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/debug_api/WriteProcessMemory/test1/commonconsts.h b/src/pal/tests/palsuite/debug_api/WriteProcessMemory/test1/commonconsts.h deleted file mode 100644 index eb7d51153..000000000 --- a/src/pal/tests/palsuite/debug_api/WriteProcessMemory/test1/commonconsts.h +++ /dev/null @@ -1,46 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: commonconsts.h -** -** -**============================================================*/ - -#ifndef _COMMONCONSTS_H_ -#define _COMMONCONSTS_H_ - -#include - -const int TIMEOUT = 40000; - -const WCHAR szcToHelperEvName[] = { 'T', 'o', '\0' }; -const WCHAR szcFromHelperEvName[] = { 'F', 'r', 'o', 'm', '\0' }; - -const char initialValue = '-'; -const char nextValue = '|'; -const char guardValue = '*'; -const char *commsFileName = "AddrNLen.dat"; - -/* PEDANTIC and PEDANTIC0 is a helper macro that just grumps about any - * zero return codes in a generic way. with little typing */ -#define PEDANTIC(function, parameters) \ -{ \ - if (! (function parameters) ) \ - { \ - Trace("%s: NonFatal failure of %s%s for reasons %u and %u\n", \ - __FILE__, #function, #parameters, GetLastError(), errno); \ - } \ -} -#define PEDANTIC1(function, parameters) \ -{ \ - if ( (function parameters) ) \ - { \ - Trace("%s: NonFatal failure of %s%s for reasons %u and %u\n", \ - __FILE__, #function, #parameters, GetLastError(), errno); \ - } \ -} - -#endif diff --git a/src/pal/tests/palsuite/debug_api/WriteProcessMemory/test1/helper.cpp b/src/pal/tests/palsuite/debug_api/WriteProcessMemory/test1/helper.cpp deleted file mode 100644 index d965ca7a5..000000000 --- a/src/pal/tests/palsuite/debug_api/WriteProcessMemory/test1/helper.cpp +++ /dev/null @@ -1,243 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: helper.c -** -** Purpose: This helper process sets up a several blocks of memory, -** then uses a file to tell its parent process where that memory is -** So it can do a WriteProcessMemory on it. When the parent process is done -** we check here that it was written properly. -** -** -**============================================================*/ - -#include "commonconsts.h" - -#include - -struct allhandles_t -{ - HANDLE hEvToHelper; - HANDLE hEvFromHelper; - char *valuesFileName; -}; - - -/* function: wpmDoIt - * - * This is a general WriteProcessMemory testing function that sets up - * the RAM pointed to and tells the companion process on the other end - * of the handles in 'Comms' to attempt to alter 'lenDest' bytes at - * '*pDest'. - * - * '*pBuffer'[0..'lenBuffer'] is expected to be a guard region - * surrounding the '*pDest'[0..'lenDest'] region so that this function - * can verify that only the proper bytes were altered. - */ - -int wpmDoIt(struct allhandles_t Comms, - char * pBuffer, unsigned int lenBuffer, - char * pDest, unsigned int lenDest, - const char* storageDescription) -{ - char *pCurr; - FILE *commsFile; - DWORD dwRet; - - if (pBuffer > pDest || lenDest > lenBuffer) - { - Trace("WriteProcessMemory::DoIt() test implementation: " - "(pBuffer > pDest || lenDest > lenBuffer)\n"); - return FALSE; - } - - /* set up the storage */ - memset(pBuffer, guardValue, lenBuffer); - memset(pDest, initialValue, lenDest); - - /* tell the parent what RAM to adjust */ - if(!(commsFile = fopen(Comms.valuesFileName, "w"))) - { - Trace("WriteProcessMemory: fopen of '%S' failed (%u). \n", - Comms.valuesFileName, GetLastError()); - return FALSE; - } - if (!fprintf(commsFile, "%u %u '%s'\n", - pDest, lenDest, storageDescription)) - { - Trace("WriteProcessMemory: fprintf to '%S' failed (%u). \n", - Comms.valuesFileName, GetLastError()); - return FALSE; - } - PEDANTIC1(fclose, (commsFile)); - - /* Tell the parent the data is ready for it to adjust */ - PEDANTIC(ResetEvent, (Comms.hEvToHelper)); - PEDANTIC(SetEvent, (Comms.hEvFromHelper)); - - dwRet = WaitForSingleObject(Comms.hEvToHelper, TIMEOUT); /* parent is done */ - if (dwRet != WAIT_OBJECT_0) - { - Trace("helper WaitForSingleObjectTest: WaitForSingleObject " - "failed (%u)\n", GetLastError()); - return FALSE; - } - - /* check the stuff that SHOULD have changed */ - for (pCurr = pDest; pCurr < (pDest + lenDest); pCurr++) - { - if ( *pCurr != nextValue) - { - Trace("When testing '%s': alteration test failed " - "at %u offset %u. Found '%c' instead of '%c'\n.", - storageDescription, pDest, pCurr - pDest, *pCurr, nextValue); - Trace(" 'Altered' string: '%.*s'\n",lenBuffer, pBuffer); - return FALSE; - } - } - /* check the stuff that should NOT have changed */ - for (pCurr = pBuffer; pCurr < pDest; pCurr++ ) - { - if ( *pCurr != guardValue) - { - Trace("When testing '%s': leading guard zone test failed " - "at %u offset %u. Found '%c' instead of '%c'\n.", - storageDescription, pDest, pCurr - pBuffer, *pCurr, guardValue); - Trace(" 'Altered' string: '%.*s'\n",lenBuffer, pBuffer); - return FALSE; - } - } - for (pCurr = pDest + lenDest; pCurr < (pBuffer + lenBuffer); pCurr++ ) - { - if ( *pCurr != guardValue) - { - Trace("When testing '%s': trailing guard zone test failed " - "at %u offset %u. Found '%c' instead of '%c'\n.", - storageDescription, pDest + lenDest, pCurr - pBuffer, *pCurr, guardValue); - Trace(" 'Altered' string: '%.*s'\n",lenBuffer, pBuffer); - return FALSE; - } - } - - return TRUE; -} - -int __cdecl main(int argc, char *argv[]) -{ - - BOOL success = TRUE; /* assume success */ - struct allhandles_t Comms = {0,0,0} ; - - /* variables to track storage to alter */ - char *pTarget = NULL; - unsigned int sizeTarget; - - if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - /* hook up with the events created by the parent */ - Comms.hEvToHelper = OpenEventW(EVENT_ALL_ACCESS, 0, szcToHelperEvName); - if (!Comms.hEvToHelper) - { - Fail("WriteProcessMemory: OpenEvent of '%S' failed (%u). " - "(the event should already exist!)\n", - szcToHelperEvName, GetLastError()); - } - Comms.hEvFromHelper = OpenEventW(EVENT_ALL_ACCESS, 0, szcFromHelperEvName); - if (!Comms.hEvToHelper) - { - Trace("WriteProcessMemory: OpenEvent of '%S' failed (%u). " - "(the event should already exist!)\n", - szcFromHelperEvName, GetLastError()); - success = FALSE; - goto EXIT; - } - Comms.valuesFileName = argv[1]; - - { - char autoAllocatedOnStack[51]; - - /* Get the parent process to write to the local stack */ - success &= wpmDoIt(Comms, autoAllocatedOnStack, - sizeof(autoAllocatedOnStack), - autoAllocatedOnStack + sizeof(int), - sizeof(autoAllocatedOnStack) - 2 * sizeof(int), - "const size array on stack with int sized guards"); - } - - /* Get the parent process to write to stuff on the heap */ - sizeTarget = 2 * sizeof(int) + 23 ; /* 23 is just a random prime > 16 */ - if (!(pTarget = (char*)malloc(sizeTarget))) - { - Trace("WriteProcessMemory helper: unable to allocate '%s'->%d bytes of memory" - "(%u).\n", - argv[3], sizeTarget, GetLastError()); - success = FALSE; - goto EXIT; - - } - success &= wpmDoIt(Comms, pTarget, sizeTarget, - pTarget + sizeof(int), - sizeTarget - 2 * sizeof(int), - "array on heap with int sized guards"); - - /* just to be nice try something 16 - 2 * sizeof(int) bytes long */ - { - char autoAllocatedOnStack[16]; - - /* Get the parent process to write to the local stack */ - success &= wpmDoIt(Comms, autoAllocatedOnStack, - sizeof(autoAllocatedOnStack), - autoAllocatedOnStack + sizeof(int), - sizeof(autoAllocatedOnStack) - 2 * sizeof(int), - "another 16 byte array on stack with int sized guards inside"); - } - - /* NOTE: Don't try 0 bytes long. Win32 WriteProcessMemory claims - * it writes 8 bytes in that case! */ - - /* and 1 byte long... */ - { - char autoAllocatedOnStack[1+ 2 * sizeof(int)]; - - /* Get the parent process to write to the local stack */ - success &= wpmDoIt(Comms, autoAllocatedOnStack, - sizeof(autoAllocatedOnStack), - autoAllocatedOnStack + sizeof(int), - 1, - "no bytes with int sized guards outside on stack"); - } - - -EXIT: - /* Tell the parent that we are done */ - if (!DeleteFile(Comms.valuesFileName)) - { - Trace("helper: DeleteFile failed so parent (test1) is unlikely " - "to exit cleanly\n"); - } - PEDANTIC(ResetEvent, (Comms.hEvToHelper)); - if (!SetEvent(Comms.hEvFromHelper)) - { - Trace("helper: SetEvent failed so parent (test1) is unlikely " - "to exit cleanly\n"); - } - - free(pTarget); - PEDANTIC(CloseHandle, (Comms.hEvToHelper)); - PEDANTIC(CloseHandle, (Comms.hEvFromHelper)); - - if (!success) - { - Fail(""); - } - - PAL_Terminate(); - - return success ? PASS : FAIL; -} diff --git a/src/pal/tests/palsuite/debug_api/WriteProcessMemory/test1/test1.cpp b/src/pal/tests/palsuite/debug_api/WriteProcessMemory/test1/test1.cpp deleted file mode 100644 index f390c10c7..000000000 --- a/src/pal/tests/palsuite/debug_api/WriteProcessMemory/test1/test1.cpp +++ /dev/null @@ -1,189 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: test1.c -** -** Purpose: Create a child process and some events for communications with it. -** When the child gets back to us with a memory location and a length, -** Call WriteProcessMemory on this location and check to see that it -** writes successfully. -** -** -**============================================================*/ - -#define UNICODE - -#include "commonconsts.h" - -#include - -int __cdecl main(int argc, char *argv[]) -{ - - PROCESS_INFORMATION pi; - STARTUPINFO si; - HANDLE hEvToHelper; - HANDLE hEvFromHelper; - DWORD dwExitCode; - - - DWORD dwRet; - char cmdComposeBuf[MAX_PATH]; - PWCHAR uniString; - - if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - /* Create the signals we need for cross process communication */ - hEvToHelper = CreateEvent(NULL, TRUE, FALSE, szcToHelperEvName); - if (!hEvToHelper) - { - Fail("WriteProcessMemory: CreateEvent of '%S' failed. " - "GetLastError() returned %d.\n", szcToHelperEvName, - GetLastError()); - } - if (GetLastError() == ERROR_ALREADY_EXISTS) - { - Fail("WriteProcessMemory: CreateEvent of '%S' failed. " - "(already exists!)\n", szcToHelperEvName); - } - hEvFromHelper = CreateEvent(NULL, TRUE, FALSE, szcFromHelperEvName); - if (!hEvToHelper) - { - Fail("WriteProcessMemory: CreateEvent of '%S' failed. " - "GetLastError() returned %d.\n", szcFromHelperEvName, - GetLastError()); - } - if (GetLastError() == ERROR_ALREADY_EXISTS) - { - Fail("WriteProcessMemory: CreateEvent of '%S' failed. " - "(already exists!)\n", szcFromHelperEvName); - } - ResetEvent(hEvFromHelper); - ResetEvent(hEvToHelper); - - if (!sprintf_s(cmdComposeBuf, _countof(cmdComposeBuf), "helper %s", commsFileName)) - { - Fail("Could not convert command line\n"); - } - uniString = convert(cmdComposeBuf); - - ZeroMemory( &si, sizeof(si) ); - si.cb = sizeof(si); - ZeroMemory( &pi, sizeof(pi) ); - - /* Create a new process. This is the process that will ask for - * memory munging */ - if(!CreateProcess( NULL, uniString, NULL, NULL, - FALSE, 0, NULL, NULL, &si, &pi)) - { - Trace("ERROR: CreateProcess failed to load executable '%S'. " - "GetLastError() returned %u.\n", - uniString, GetLastError()); - free(uniString); - Fail(""); - } - free(uniString); - - while(1) - { - FILE *commsFile; - char* pSrcMemory; - char* pDestMemory; - int Count; - SIZE_T wpmCount; - char incomingCMDBuffer[MAX_PATH + 1]; - - /* wait until the helper tells us that it has given us - * something to do */ - dwRet = WaitForSingleObject(hEvFromHelper, TIMEOUT); - if (dwRet != WAIT_OBJECT_0) - { - Trace("test1 WaitForSingleObjectTest: WaitForSingleObject " - "failed (%u)\n", GetLastError()); - break; /* no more work incoming */ - } - - /* get the parameters to test WriteProcessMemory with */ - if (!(commsFile = fopen(commsFileName, "r"))) - { - /* no file means there is no more work */ - break; - } - if ( NULL == fgets(incomingCMDBuffer, MAX_PATH, commsFile)) - { - Fail ("unable to read from communication file %s " - "for reasons %u & %u\n", - errno, GetLastError()); - } - PEDANTIC1(fclose,(commsFile)); - sscanf(incomingCMDBuffer, "%u %u", &pDestMemory, &Count); - if (argc > 1) - { - Trace("Preparing to write to %u bytes @ %u ('%s')\n", - Count, pDestMemory, incomingCMDBuffer); - } - - /* compose some data to write to the client process */ - if (!(pSrcMemory = (char*)malloc(Count))) - { - Trace("could not dynamically allocate memory to copy from " - "for reasons %u & %u\n", - errno, GetLastError()); - goto doneIteration; - } - memset(pSrcMemory, nextValue, Count); - - /* do the work */ - dwRet = WriteProcessMemory(pi.hProcess, - pDestMemory, - pSrcMemory, - Count, - &wpmCount); - if (!dwRet) - { - Trace("%s: Problem: on a write to %u bytes @ %u ('%s')\n", - argv[0], Count, pDestMemory, incomingCMDBuffer); - Trace("test1 WriteProcessMemory returned a%u(!=0) (GLE=%u)\n", - GetLastError()); - } - if(Count != wpmCount) - { - Trace("%s: Problem: on a write to %u bytes @ %u ('%s')\n", - argv[0], Count, pDestMemory, incomingCMDBuffer); - Trace("The number of bytes written should have been " - "%u, but was reported as %u.\n", Count, wpmCount); - } - free(pSrcMemory); - - doneIteration: - PEDANTIC(ResetEvent, (hEvFromHelper)); - PEDANTIC(SetEvent, (hEvToHelper)); - } - - /* wait for the child process to complete */ - WaitForSingleObject ( pi.hProcess, TIMEOUT ); - /* this may return a failure code on a success path */ - - /* check the exit code from the process */ - if( ! GetExitCodeProcess( pi.hProcess, &dwExitCode ) ) - { - Trace( "GetExitCodeProcess call failed with error code %u\n", - GetLastError() ); - dwExitCode = FAIL; - } - - - PEDANTIC(CloseHandle, (hEvToHelper)); - PEDANTIC(CloseHandle, (hEvFromHelper)); - PEDANTIC(CloseHandle, (pi.hThread)); - PEDANTIC(CloseHandle, (pi.hProcess)); - - PAL_TerminateEx(dwExitCode); - return dwExitCode; -} diff --git a/src/pal/tests/palsuite/debug_api/WriteProcessMemory/test1/testinfo.dat b/src/pal/tests/palsuite/debug_api/WriteProcessMemory/test1/testinfo.dat deleted file mode 100644 index 0946f8f13..000000000 --- a/src/pal/tests/palsuite/debug_api/WriteProcessMemory/test1/testinfo.dat +++ /dev/null @@ -1,16 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Debug -Function = WriteProcessMemory -Name = Check that writing text to process memory succeeds. -TYPE = DEFAULT -EXE1 = test1 -EXE2 = helper -Description -= Create a child process and attempt to write to its memory -= at the places and lengths it specifies via a data file. -= the child verifies that all the specified memory was altered -= with no overruns. diff --git a/src/pal/tests/palsuite/debug_api/WriteProcessMemory/test3/CMakeLists.txt b/src/pal/tests/palsuite/debug_api/WriteProcessMemory/test3/CMakeLists.txt deleted file mode 100644 index d6e11a683..000000000 --- a/src/pal/tests/palsuite/debug_api/WriteProcessMemory/test3/CMakeLists.txt +++ /dev/null @@ -1,32 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(TESTSOURCES - test3.cpp -) - -add_executable(paltest_writeprocessmemory_test3 - ${TESTSOURCES} -) - -add_dependencies(paltest_writeprocessmemory_test3 coreclrpal) - -target_link_libraries(paltest_writeprocessmemory_test3 - ${COMMON_TEST_LIBRARIES} -) - - -set(HELPERSOURCES - helper.cpp -) - -add_executable(paltest_writeprocessmemory_test3_helper - ${HELPERSOURCES} -) - -add_dependencies(paltest_writeprocessmemory_test3_helper coreclrpal) - -target_link_libraries(paltest_writeprocessmemory_test3_helper - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/debug_api/WriteProcessMemory/test3/commonconsts.h b/src/pal/tests/palsuite/debug_api/WriteProcessMemory/test3/commonconsts.h deleted file mode 100644 index c1cec18e2..000000000 --- a/src/pal/tests/palsuite/debug_api/WriteProcessMemory/test3/commonconsts.h +++ /dev/null @@ -1,50 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Header: commonconsts.h -** -** -==============================================================*/ - -#ifndef _COMMONCONSTS_H_ -#define _COMMONCONSTS_H_ - -#include - -const int TIMEOUT = 40000; - -const WCHAR szcToHelperEvName[] = { 'T', 'o', '\0' }; -const WCHAR szcFromHelperEvName[] = { 'F', 'r', 'o', 'm', '\0' }; - -const char initialValue = '-'; -const char nextValue = '|'; -const char guardValue = '*'; -const char *commsFileName = "AddrNLen.dat"; - -/* PEDANTIC and PEDANTIC0 is a helper macro that just grumps about any - * zero return codes in a generic way. with little typing */ -#define PEDANTIC(function, parameters) \ -{ \ - unsigned int retval = (function parameters); \ - if ( !retval ) \ - { \ - Trace("%s: NonFatal failure of %s%s (returned %u) " \ - "for reasons %u and %u.\n", \ - __FILE__, #function, #parameters, retval, GetLastError(), errno); \ - } \ -} -#define PEDANTIC1(function, parameters) \ -{ \ - unsigned int retval = (function parameters); \ - if ( retval ) \ - { \ - Trace("%s: NonFatal failure of %s%s (returned %u) " \ - "for reasons %u and %u\n", \ - __FILE__, #function, #parameters, retval, GetLastError(), errno); \ - } \ -} - -#endif diff --git a/src/pal/tests/palsuite/debug_api/WriteProcessMemory/test3/helper.cpp b/src/pal/tests/palsuite/debug_api/WriteProcessMemory/test3/helper.cpp deleted file mode 100644 index 170e2064c..000000000 --- a/src/pal/tests/palsuite/debug_api/WriteProcessMemory/test3/helper.cpp +++ /dev/null @@ -1,256 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: helper.c - -** -==============================================================*/ - - -/* -** -** Purpose: This helper process sets up a several blocks of memory -** that should be unwritable from the parent process, then uses a file -** to tell its parent process where that memory is so it can attempt a -** WriteProcessMemory on it. When the parent process is done we check -** here that it was (properly) unable to change the contents of the -** memory. -*/ - -#include "commonconsts.h" - -#include - -struct allhandles_t -{ - HANDLE hEvToHelper; - HANDLE hEvFromHelper; - char *valuesFileName; -}; - - -/* function: wpmVerifyCant - * - * This is a general WriteProcessMemory testing function that sets up - * the RAM pointed to and tells the companion process on the other end - * of the handles in 'Comms' to attempt to alter 'lenDest' bytes at - * '*pDest'. - * - * However, the memory at pDest[0..lenDest] is expected to be unwritable by - * the companion process. The companion is expects this. This function - * verifies that no bytes were affected - */ - -int wpmVerifyCant(struct allhandles_t Comms, - char * pDest, unsigned int lenDest, - unsigned int lenLegitDest, - DWORD dwExpectedErrorCode, - const char* storageDescription) -{ - char *pCurr; - FILE *commsFile; - DWORD dwRet; - - unsigned int lenSafe = min(lenDest, lenLegitDest); - - PAL_TRY - { - memset(pDest, initialValue, lenSafe); - } - PAL_EXCEPT_EX (setup, EXCEPTION_EXECUTE_HANDLER) - { - Trace("WriteProcessMemory: bug in test values for '%s' (%p, %u, %u), " - "the initial memset threw an exception.\n", - storageDescription, pDest, lenDest, lenSafe); - } - PAL_ENDTRY; - - /* tell the parent what RAM to attempt to adjust */ - if(!(commsFile = fopen(Comms.valuesFileName, "w"))) - { - Trace("WriteProcessMemory: fopen of '%S' failed (%u). \n", - Comms.valuesFileName, GetLastError()); - return FALSE; - } - if (!fprintf(commsFile, "%u %u %u '%s'\n", - pDest, lenDest, dwExpectedErrorCode, storageDescription)) - { - Trace("WriteProcessMemory: fprintf to '%S' failed (%u). \n", - Comms.valuesFileName, GetLastError()); - return FALSE; - } - PEDANTIC1(fclose, (commsFile)); - - /* Tell the parent the data is ready for it to adjust */ - PEDANTIC(ResetEvent, (Comms.hEvToHelper)); - PEDANTIC(SetEvent, (Comms.hEvFromHelper)); - - dwRet = WaitForSingleObject(Comms.hEvToHelper, TIMEOUT); - if (dwRet != WAIT_OBJECT_0) - { - Trace("helper WaitForSingleObjectTest: WaitForSingleObject " - "failed (%u)\n", GetLastError()); - return FALSE; - } - - PAL_TRY - { - /* check the stuff (as much as we can) that should NOT have changed */ - for (pCurr = pDest; pCurr < (pDest + lenSafe); pCurr++ ) - { - if ( *pCurr != initialValue) - { - Trace("When testing '%s': real memory values preservation failed " - "at %u offset %u. Found '%c' instead of '%c'\n.", - storageDescription, pDest, pCurr - pDest, - *pCurr, initialValue); - return FALSE; - } - } - } - PAL_EXCEPT_EX (testing, EXCEPTION_EXECUTE_HANDLER) - { - Trace("WriteProcessMemory: bug in test values for '%s' (%p, %u, %u), " - "the verification pass threw an exception.\n", - storageDescription, pDest, lenDest, lenSafe); - } - PAL_ENDTRY; - - return TRUE; -} - -int __cdecl main(int argc, char *argv[]) -{ - BOOL success = TRUE; /* assume success */ - struct allhandles_t Comms = {0,0,0} ; - - SYSTEM_INFO sysinfo; - - char* Memory; - - if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - /* hook up with the events created by the parent */ - Comms.hEvToHelper = OpenEventW(EVENT_ALL_ACCESS, 0, szcToHelperEvName); - if (!Comms.hEvToHelper) - { - Fail("WriteProcessMemory: OpenEvent of '%S' failed (%u). " - "(the event should already exist!)\n", - szcToHelperEvName, GetLastError()); - success = FALSE; - goto EXIT; - } - Comms.hEvFromHelper = OpenEventW(EVENT_ALL_ACCESS, 0, szcFromHelperEvName); - if (!Comms.hEvToHelper) - { - Trace("WriteProcessMemory: OpenEvent of '%S' failed (%u). " - "(the event should already exist!)\n", - szcFromHelperEvName, GetLastError()); - success = FALSE; - goto EXIT; - } - Comms.valuesFileName = argv[1]; - - /* test setup */ - GetSystemInfo(&sysinfo); - - { - unsigned int allocSize = sysinfo.dwPageSize * 2; - unsigned int writeLen = allocSize * 2; - - /* First test: overrun the allocated memory */ - Memory = (char*)VirtualAlloc(NULL, allocSize, - MEM_COMMIT, PAGE_READWRITE); - - if(Memory == NULL) - { - Fail("ERROR: Attempted to commit two pages, but the " - " VirtualAlloc call failed. " - "GetLastError() returned %u.\n",GetLastError()); - } - success &= wpmVerifyCant(Comms, Memory, writeLen, allocSize, - ERROR_INVALID_ADDRESS, - "should not write beyond committed allocation"); - - PEDANTIC1(VirtualFree, (Memory, allocSize, - MEM_DECOMMIT | MEM_RELEASE)); - } - - { - /* Allocate the memory as readonly */ - unsigned int allocSize = sysinfo.dwPageSize * 2; - unsigned int writeLen = allocSize; - - Memory = (char*)VirtualAlloc(NULL, allocSize, - MEM_COMMIT, PAGE_READONLY); - - if(Memory == NULL) - { - Fail("ERROR: Attempted to commit two pages readonly, but the " - " VirtualAlloc call failed. " - "GetLastError() returned %u.\n",GetLastError()); - } - success &= wpmVerifyCant(Comms, Memory, writeLen, 0, - ERROR_NOACCESS, - "should not write in READONLY allocation"); - - PEDANTIC1(VirtualFree, (Memory, allocSize, - MEM_DECOMMIT | MEM_RELEASE)); - } - - - { - /* attempt to write to memory that is not committed yet */ - unsigned int allocSize = sysinfo.dwPageSize * 2; - unsigned int writeLen = allocSize; - - Memory = (char*)VirtualAlloc(NULL, allocSize, - MEM_RESERVE, PAGE_NOACCESS); - - if(Memory == NULL) - { - Fail("ERROR: Attempted to reserve two pages, but the " - " VirtualAlloc call failed. " - "GetLastError() returned %u.\n",GetLastError()); - } - success &= wpmVerifyCant(Comms, Memory, writeLen, 0, - ERROR_INVALID_ADDRESS, - "should not write in memory that is" - " RESERVED but not COMMITTED"); - - PEDANTIC1(VirtualFree, (Memory, allocSize, MEM_RELEASE)); - } - - -EXIT: - /* Tell the parent that we are done */ - if (!DeleteFile(Comms.valuesFileName)) - { - Trace("helper: DeleteFile failed so parent (test1) is unlikely " - "to exit cleanly\n"); - } - PEDANTIC(ResetEvent, (Comms.hEvToHelper)); - if (!SetEvent(Comms.hEvFromHelper)) - { - Trace("helper: SetEvent failed so parent (test1) is unlikely " - "to exit cleanly\n"); - } - - PEDANTIC(CloseHandle, (Comms.hEvToHelper)); - PEDANTIC(CloseHandle, (Comms.hEvFromHelper)); - - if (!success) - { - Fail(""); - } - - PAL_Terminate(); - - return success ? PASS : FAIL; -} diff --git a/src/pal/tests/palsuite/debug_api/WriteProcessMemory/test3/test3.cpp b/src/pal/tests/palsuite/debug_api/WriteProcessMemory/test3/test3.cpp deleted file mode 100644 index 15b4b3f79..000000000 --- a/src/pal/tests/palsuite/debug_api/WriteProcessMemory/test3/test3.cpp +++ /dev/null @@ -1,205 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: test3.c -** -** Purpose: Create a child process and debug it. When the child -** raises an exception, it sends back a memory location. Call -** WriteProcessMemory on the memory location, but attempt to write -** more than the memory allows. This should cause an error and the -** data should be unchanged. -** -** -==============================================================*/ - -#define UNICODE - -#include "commonconsts.h" - -#include - -int __cdecl main(int argc, char *argv[]) -{ - - PROCESS_INFORMATION pi; - STARTUPINFO si; - HANDLE hEvToHelper; - HANDLE hEvFromHelper; - DWORD dwExitCode; - - - DWORD dwRet; - BOOL success = TRUE; /* assume success */ - char cmdComposeBuf[MAX_PATH]; - PWCHAR uniString; - - if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - /* Create the signals we need for cross process communication */ - hEvToHelper = CreateEvent(NULL, TRUE, FALSE, szcToHelperEvName); - if (!hEvToHelper) - { - Fail("WriteProcessMemory: CreateEvent of '%S' failed. " - "GetLastError() returned %u.\n", szcToHelperEvName, - GetLastError()); - } - if (GetLastError() == ERROR_ALREADY_EXISTS) - { - Fail("WriteProcessMemory: CreateEvent of '%S' failed. " - "(already exists!)\n", szcToHelperEvName); - } - hEvFromHelper = CreateEvent(NULL, TRUE, FALSE, szcFromHelperEvName); - if (!hEvToHelper) - { - Fail("WriteProcessMemory: CreateEvent of '%S' failed. " - "GetLastError() returned %u.\n", szcFromHelperEvName, - GetLastError()); - } - if (GetLastError() == ERROR_ALREADY_EXISTS) - { - Fail("WriteProcessMemory: CreateEvent of '%S' failed. " - "(already exists!)\n", szcFromHelperEvName); - } - - if (!sprintf_s(cmdComposeBuf, _countof(cmdComposeBuf), "helper %s", commsFileName)) - { - Fail("Could not convert command line\n"); - } - uniString = convert(cmdComposeBuf); - - ZeroMemory( &si, sizeof(si) ); - si.cb = sizeof(si); - ZeroMemory( &pi, sizeof(pi) ); - - /* Create a new process. This is the process that will ask for - * memory munging */ - if(!CreateProcess( NULL, uniString, NULL, NULL, - FALSE, 0, NULL, NULL, &si, &pi)) - { - Trace("ERROR: CreateProcess failed to load executable '%S'. " - "GetLastError() returned %u.\n", - uniString, GetLastError()); - free(uniString); - Fail(""); - } - free(uniString); - - while(1) - { - FILE *commsFile; - char* pSrcMemory; - char* pDestMemory; - int Count; - SIZE_T wpmCount; - DWORD dwExpectedErrorCode; - - char incomingCMDBuffer[MAX_PATH + 1]; - - /* wait until the helper tells us that it has given us - * something to do */ - dwRet = WaitForSingleObject(hEvFromHelper, TIMEOUT); - if (dwRet != WAIT_OBJECT_0) - { - Trace("test1 WaitForSingleObjectTest: WaitForSingleObject " - "failed (%u)\n", GetLastError()); - break; /* no more work incoming */ - } - - /* get the parameters to test WriteProcessMemory with */ - if (!(commsFile = fopen(commsFileName, "r"))) - { - /* no file means there is no more work */ - break; - } - if ( NULL == fgets(incomingCMDBuffer, MAX_PATH, commsFile)) - { - Trace ("unable to read from communication file %s " - "for reasons %u & %u\n", - errno, GetLastError()); - success = FALSE; - PEDANTIC1(fclose,(commsFile)); - /* it's not worth continuing this trial */ - goto doneIteration; - } - PEDANTIC1(fclose,(commsFile)); - sscanf(incomingCMDBuffer, "%u %u %u", - &pDestMemory, &Count, &dwExpectedErrorCode); - if (argc > 1) - { - Trace("Preparing to write to %u bytes @ %u ('%s')\n", - Count, pDestMemory, incomingCMDBuffer); - } - - /* compose some data to write to the client process */ - if (!(pSrcMemory = (char*)malloc(Count))) - { - Trace("could not dynamically allocate memory to copy from " - "for reasons %u & %u\n", - errno, GetLastError()); - success = FALSE; - goto doneIteration; - } - memset(pSrcMemory, nextValue, Count); - - /* do the work */ - dwRet = WriteProcessMemory(pi.hProcess, - pDestMemory, - pSrcMemory, - Count, - &wpmCount); - - if(dwRet != 0) - { - Trace("ERROR: Situation: '%s', return code: %u, bytes 'written': %u\n", - incomingCMDBuffer, dwRet, wpmCount); - Trace("ERROR: WriteProcessMemory did not fail as it should, as " - "it attempted to write to a range of memory which was " - "not completely accessible.\n"); - success = FALSE; - } - - if(GetLastError() != dwExpectedErrorCode) - { - Trace("ERROR: GetLastError() should have returned " - "%u , but instead it returned %u.\n", - dwExpectedErrorCode, GetLastError()); - success = FALSE; - } - free(pSrcMemory); - - doneIteration: - PEDANTIC(ResetEvent, (hEvFromHelper)); - PEDANTIC(SetEvent, (hEvToHelper)); - } - - - /* wait for the child process to complete */ - WaitForSingleObject ( pi.hProcess, TIMEOUT ); - /* this may return a failure code on a success path */ - - /* check the exit code from the process */ - if( ! GetExitCodeProcess( pi.hProcess, &dwExitCode ) ) - { - Trace( "GetExitCodeProcess call failed with error code %u\n", - GetLastError() ); - dwExitCode = FAIL; - } - if(!success) - { - dwExitCode = FAIL; - } - - PEDANTIC(CloseHandle, (hEvToHelper)); - PEDANTIC(CloseHandle, (hEvFromHelper)); - PEDANTIC(CloseHandle, (pi.hThread)); - PEDANTIC(CloseHandle, (pi.hProcess)); - - PAL_Terminate(dwExitCode); - return dwExitCode; -} diff --git a/src/pal/tests/palsuite/debug_api/WriteProcessMemory/test3/testinfo.dat b/src/pal/tests/palsuite/debug_api/WriteProcessMemory/test3/testinfo.dat deleted file mode 100644 index 23ad3ae56..000000000 --- a/src/pal/tests/palsuite/debug_api/WriteProcessMemory/test3/testinfo.dat +++ /dev/null @@ -1,17 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Debug -Function = WriteProcessMemory -Name = Check that you can't write from writable to protected memory. -TYPE = DEFAULT -EXE1 = test3 -EXE2 = helper -Description -= Create a child process and debug it. When the child -= raises an exception, it sends back a memory location. Call -= WriteProcessMemory on the memory location, but attempt to write -= more than the memory allows. This should cause an error and the -= data should be unchanged. diff --git a/src/pal/tests/palsuite/debug_api/WriteProcessMemory/test4/CMakeLists.txt b/src/pal/tests/palsuite/debug_api/WriteProcessMemory/test4/CMakeLists.txt deleted file mode 100644 index 9eec2bd78..000000000 --- a/src/pal/tests/palsuite/debug_api/WriteProcessMemory/test4/CMakeLists.txt +++ /dev/null @@ -1,32 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(TESTSOURCES - test4.cpp -) - -add_executable(paltest_writeprocessmemory_test4 - ${TESTSOURCES} -) - -add_dependencies(paltest_writeprocessmemory_test4 coreclrpal) - -target_link_libraries(paltest_writeprocessmemory_test4 - ${COMMON_TEST_LIBRARIES} -) - - -set(HELPERSOURCES - helper.cpp -) - -add_executable(paltest_writeprocessmemory_test4_helper - ${HELPERSOURCES} -) - -add_dependencies(paltest_writeprocessmemory_test4_helper coreclrpal) - -target_link_libraries(paltest_writeprocessmemory_test4_helper - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/debug_api/WriteProcessMemory/test4/helper.cpp b/src/pal/tests/palsuite/debug_api/WriteProcessMemory/test4/helper.cpp deleted file mode 100644 index b653ea505..000000000 --- a/src/pal/tests/palsuite/debug_api/WriteProcessMemory/test4/helper.cpp +++ /dev/null @@ -1,67 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: helper.c -** -** Purpose: This helper process sets up a block of memory, then -** raises an exception to pass that memory location back to the -** parent process. When the parent process is done calling WriteProcessMemory -** we check here that it was written properly. -** -** -**============================================================*/ - -#include -const int MY_EXCEPTION=999; - -int __cdecl main(int argc, char *argv[]) -{ - - char* Memory; - char* TheArray[1]; - int i; - - if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - Memory = (char*)VirtualAlloc(NULL, 4096, MEM_COMMIT, PAGE_READONLY); - - if(Memory == NULL) - { - Fail("ERROR: Attempted to allocate two pages, but the VirtualAlloc " - "call failed. GetLastError() returned %d.\n",GetLastError()); - } - - - TheArray[0] = Memory; - - - /* Need to sleep for a couple seconds. Otherwise this process - won't be being debugged when the first exception is raised. - */ - Sleep(4000); - - RaiseException(MY_EXCEPTION, 0, 1, (ULONG_PTR*)TheArray); - - for(i=0; i<4096; ++i) - { - if(Memory[i] != '\0') - { - Fail("ERROR: The memory should be unchanged after the " - "invalid call to WriteProcessMemory, but the char " - "at index %d has changed.\n",i); - } - } - - - - - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/debug_api/WriteProcessMemory/test4/test4.cpp b/src/pal/tests/palsuite/debug_api/WriteProcessMemory/test4/test4.cpp deleted file mode 100644 index 51db23499..000000000 --- a/src/pal/tests/palsuite/debug_api/WriteProcessMemory/test4/test4.cpp +++ /dev/null @@ -1,124 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: test4.c -** -** Purpose: Create a child process and debug it. When the child -** raises an exception, it sends back a memory location. Call -** WriteProcessMemory on a restricted memory location and ensure that -** it fails. -** -** -**============================================================*/ - -#include -const int MY_EXCEPTION=999; - -int __cdecl main(int argc, char *argv[]) -{ - - PROCESS_INFORMATION pi; - STARTUPINFO si; - DEBUG_EVENT DebugEv; - DWORD dwContinueStatus = DBG_CONTINUE; - int Count, ret; - char* DataBuffer[4096]; - char* Memory; - - if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - ZeroMemory( &si, sizeof(si) ); - si.cb = sizeof(si); - ZeroMemory( &pi, sizeof(pi) ); - - memset(DataBuffer, 'z', 4096); - - /* Create a new process. This is the process to be Debugged */ - if(!CreateProcess( NULL, "helper", NULL, NULL, - FALSE, 0, NULL, NULL, &si, &pi)) - { - Fail("ERROR: CreateProcess failed to load executable 'helper'. " - "GetLastError() returned %d.\n",GetLastError()); - } - - /* Call DebugActiveProcess, because the process wasn't created as a - debug process. - */ - if(DebugActiveProcess(pi.dwProcessId) == 0) - { - Fail("ERROR: Failed calling DebugActiveProcess on the process " - "which was created to debug. GetLastError() returned %d.\n", - GetLastError()); - } - - - /* Call WaitForDebugEvent, which will wait until the helper process - raises an exception. - */ - - while(1) - { - if(WaitForDebugEvent(&DebugEv, INFINITE) == 0) - { - Fail("ERROR: WaitForDebugEvent returned 0, indicating failure. " - "GetLastError() returned %d.\n",GetLastError()); - } - - /* We're waiting for the helper process to send this exception. - When it does, we call WriteProcess. If it gets called more than - once, it is ignored. - */ - - if(DebugEv.u.Exception.ExceptionRecord.ExceptionCode == MY_EXCEPTION) - { - - Memory = (LPVOID) - DebugEv.u.Exception.ExceptionRecord.ExceptionInformation[0]; - - /* Write to this memory which we have no access to. */ - - ret = WriteProcessMemory(pi.hProcess, - Memory, - DataBuffer, - 4096, - &Count); - - if(ret != 0) - { - Fail("ERROR: WriteProcessMemory should have failed, as " - "it attempted to write to a range of memory which was " - "not accessible.\n"); - } - - if(GetLastError() != ERROR_NOACCESS) - { - Fail("ERROR: GetLastError() should have returned " - "ERROR_NOACCESS , but intead it returned " - "%d.\n",GetLastError()); - } - } - - if(DebugEv.dwDebugEventCode == EXIT_PROCESS_DEBUG_EVENT) - { - break; - } - - if(ContinueDebugEvent(DebugEv.dwProcessId, - DebugEv.dwThreadId, dwContinueStatus) == 0) - { - Fail("ERROR: ContinueDebugEvent failed to continue the thread " - "which had a debug event. GetLastError() returned %d.\n", - GetLastError()); - } - } - - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/debug_api/WriteProcessMemory/test4/testinfo.dat b/src/pal/tests/palsuite/debug_api/WriteProcessMemory/test4/testinfo.dat deleted file mode 100644 index c6f4edb5d..000000000 --- a/src/pal/tests/palsuite/debug_api/WriteProcessMemory/test4/testinfo.dat +++ /dev/null @@ -1,17 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Debug -Function = WriteProcessMemory -Name = Check that you can't write to protected memory. -TYPE = DEFAULT -EXE1 = test4 -EXE2 = helper -Description -= Create a child process and debug it. When the child -= raises an exception, it sends back a memory location. Call -= WriteProcessMemory on a restricted memory location and ensure that -= it fails. - diff --git a/src/pal/tests/palsuite/exception_handling/CMakeLists.txt b/src/pal/tests/palsuite/exception_handling/CMakeLists.txt deleted file mode 100644 index d0de33542..000000000 --- a/src/pal/tests/palsuite/exception_handling/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(pal_sxs) -#add_subdirectory(pal_except) -#add_subdirectory(PAL_EXCEPT_FILTER) -#add_subdirectory(PAL_EXCEPT_FILTER_EX) -#add_subdirectory(pal_finally) -#add_subdirectory(PAL_TRY_EXCEPT) -#add_subdirectory(PAL_TRY_EXCEPT_EX) -#add_subdirectory(PAL_TRY_LEAVE_FINALLY) -add_subdirectory(RaiseException) -#add_subdirectory(SetUnhandledExceptionFilter) - diff --git a/src/pal/tests/palsuite/exception_handling/PAL_EXCEPT_FILTER/CMakeLists.txt b/src/pal/tests/palsuite/exception_handling/PAL_EXCEPT_FILTER/CMakeLists.txt deleted file mode 100644 index 1962ade35..000000000 --- a/src/pal/tests/palsuite/exception_handling/PAL_EXCEPT_FILTER/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) -add_subdirectory(test3) - diff --git a/src/pal/tests/palsuite/exception_handling/PAL_EXCEPT_FILTER/test1/CMakeLists.txt b/src/pal/tests/palsuite/exception_handling/PAL_EXCEPT_FILTER/test1/CMakeLists.txt deleted file mode 100644 index 336eafd71..000000000 --- a/src/pal/tests/palsuite/exception_handling/PAL_EXCEPT_FILTER/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - PAL_EXCEPT_FILTER.cpp -) - -add_executable(paltest_pal_except_filter_test1 - ${SOURCES} -) - -add_dependencies(paltest_pal_except_filter_test1 coreclrpal) - -target_link_libraries(paltest_pal_except_filter_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/exception_handling/PAL_EXCEPT_FILTER/test1/PAL_EXCEPT_FILTER.cpp b/src/pal/tests/palsuite/exception_handling/PAL_EXCEPT_FILTER/test1/PAL_EXCEPT_FILTER.cpp deleted file mode 100644 index ee65f43d2..000000000 --- a/src/pal/tests/palsuite/exception_handling/PAL_EXCEPT_FILTER/test1/PAL_EXCEPT_FILTER.cpp +++ /dev/null @@ -1,118 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: pal_except_filter.c (test 1) -** -** Purpose: Tests the PAL implementation of the PAL_EXCEPT_FILTER. An -** exception is forced and a known value is passed to the filter -** fuction. The known value as well as booleans are tested to -** ensure proper functioning. -** -** -**===================================================================*/ - - - -#include - -BOOL bFilter = FALSE; -BOOL bTry = FALSE; -const int nValidator = 12321; - -LONG ExitFilter(EXCEPTION_POINTERS* ep, LPVOID pnTestInt) -{ - int nTestInt = *(int *)pnTestInt; - - /* let the main know we've hit the filter function */ - bFilter = TRUE; - - if (!bTry) - { - Fail("PAL_EXCEPT_FILTER: ERROR -> Something weird is going on." - " The filter was hit without PAL_TRY being hit.\n"); - } - - /* was the correct value passed? */ - if (nValidator != nTestInt) - { - Fail("PAL_EXCEPT_FILTER: ERROR -> Parameter passed to filter function" - " should have been \"%d\" but was \"%d\".\n", - nValidator, - nTestInt); - } - return EXCEPTION_EXECUTE_HANDLER; -} - - -int __cdecl main(int argc, char *argv[]) -{ - int* p = 0x00000000; /* pointer to NULL */ - BOOL bExcept = FALSE; - - if (0 != PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - /* - ** test to make sure we get into the exception block - */ - - PAL_TRY - { - if (bExcept) - { - Fail("PAL_EXCEPT_FILTER: ERROR -> Something weird is going on." - " PAL_EXCEPT_FILTER was hit before PAL_TRY.\n"); - } - bTry = TRUE; /* indicate we hit the PAL_TRY block */ - *p = 13; /* causes an access violation exception */ - - Fail("PAL_EXCEPT_FILTER: ERROR -> code was executed after the " - "access violation.\n"); - } - PAL_EXCEPT_FILTER(ExitFilter, (LPVOID)&nValidator) - { - if (!bTry) - { - Fail("PAL_EXCEPT_FILTER: ERROR -> Something weird is going on." - " PAL_EXCEPT_FILTER was hit without PAL_TRY being hit.\n"); - } - bExcept = TRUE; /* indicate we hit the PAL_EXCEPT_FILTER block */ - } - PAL_ENDTRY; - - if (!bTry) - { - Trace("PAL_EXCEPT_FILTER: ERROR -> It appears the code in the PAL_TRY" - " block was not executed.\n"); - } - - if (!bExcept) - { - Trace("PAL_EXCEPT_FILTER: ERROR -> It appears the code in the " - "PAL_EXCEPT_FILTER block was not executed.\n"); - } - - if (!bFilter) - { - Trace("PAL_EXCEPT_FILTER: ERROR -> It appears the code in the filter" - " function was not executed.\n"); - } - - - /* did we hit all the code blocks? */ - if(!bTry || !bExcept || !bFilter) - { - Fail(""); - } - - - PAL_Terminate(); - return PASS; - -} diff --git a/src/pal/tests/palsuite/exception_handling/PAL_EXCEPT_FILTER/test1/testinfo.dat b/src/pal/tests/palsuite/exception_handling/PAL_EXCEPT_FILTER/test1/testinfo.dat deleted file mode 100644 index b0b90d3ab..000000000 --- a/src/pal/tests/palsuite/exception_handling/PAL_EXCEPT_FILTER/test1/testinfo.dat +++ /dev/null @@ -1,16 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = exception_handling -Function = PAL_EXCEPT_FILTER -Name = Test for PAL_EXCEPT_FILTER -Type = DEFAULT -EXE1 = pal_except_filter -LANG = cpp -Description -= Tests the PAL implementation of the PAL_EXCEPT_FILTER. An -= exception is forced and a known value is passed to the filter -= fuction. The known value as well as booleans are tested to -= ensure proper functioning. diff --git a/src/pal/tests/palsuite/exception_handling/PAL_EXCEPT_FILTER/test2/CMakeLists.txt b/src/pal/tests/palsuite/exception_handling/PAL_EXCEPT_FILTER/test2/CMakeLists.txt deleted file mode 100644 index e9c57b44c..000000000 --- a/src/pal/tests/palsuite/exception_handling/PAL_EXCEPT_FILTER/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - pal_except_filter.cpp -) - -add_executable(paltest_pal_except_filter_test2 - ${SOURCES} -) - -add_dependencies(paltest_pal_except_filter_test2 coreclrpal) - -target_link_libraries(paltest_pal_except_filter_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/exception_handling/PAL_EXCEPT_FILTER/test2/pal_except_filter.cpp b/src/pal/tests/palsuite/exception_handling/PAL_EXCEPT_FILTER/test2/pal_except_filter.cpp deleted file mode 100644 index ccf53fb0b..000000000 --- a/src/pal/tests/palsuite/exception_handling/PAL_EXCEPT_FILTER/test2/pal_except_filter.cpp +++ /dev/null @@ -1,154 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: pal_except_filter.c (test 2) -** -** Purpose: Tests the PAL implementation of the PAL_EXCEPT_FILTER. An -** exception is forced and the filter returns -** EXCEPTION_CONTINUE_EXECUTION to allow execution to continue. -** -** -**===================================================================*/ - - -#include - -char* p; /* pointer to be abused */ - -BOOL bFilter = FALSE; -BOOL bTry = FALSE; -BOOL bTry2 = FALSE; -BOOL bContinued = FALSE; -const int nValidator = 12321; - -LONG ExitFilter(EXCEPTION_POINTERS* ep, LPVOID pnTestInt) -{ - int nTestInt = *(int *)pnTestInt; - void *Temp; - - /* let the main know we've hit the filter function */ - bFilter = TRUE; - - if (!bTry) - { - Fail("PAL_EXCEPT_FILTER: ERROR -> Something weird is going on." - " The filter was hit without PAL_TRY being hit.\n"); - } - - /* was the correct value passed? */ - if (nValidator != nTestInt) - { - Fail("PAL_EXCEPT_FILTER: ERROR -> Parameter passed to filter function" - " should have been \"%d\" but was \"%d\".\n", - nValidator, - nTestInt); - } - - /* Are we dealing with the exception we expected? */ - if (EXCEPTION_ACCESS_VIOLATION != ep->ExceptionRecord->ExceptionCode) - { - Fail("PAL_EXCEPT_FILTER: ERROR -> Unexpected Exception" - " should have been \"%x\" but was \"%x\".\n", - EXCEPTION_ACCESS_VIOLATION, - ep->ExceptionRecord->ExceptionCode); - } - - /* attempt to correct the problem by commiting the page at address 'p' */ - Temp= VirtualAlloc(p, 1, MEM_COMMIT, PAGE_READWRITE); - if (!Temp) - { - Fail("EXCEPTION_CONTINUE_EXECUTION: last error = %u - probably " - "out of memory. Unable to continue, not proof of exception " - "failure\n", - GetLastError()); - } - /* The memory that 'p' points to is now valid */ - - return EXCEPTION_CONTINUE_EXECUTION; -} - - -int __cdecl main(int argc, char *argv[]) -{ - BOOL bExcept = FALSE; - - if (0 != PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - /* - ** test to make sure we get into the exception block - */ - - PAL_TRY - { - if (bExcept) - { - Fail("PAL_EXCEPT_FILTER: ERROR -> Something weird is going on." - " PAL_EXCEPT_FILTER was hit before PAL_TRY.\n"); - } - bTry = TRUE; /* indicate we hit the PAL_TRY block */ - - /* reserve an address chunk for p to point to */ - p = (char*) VirtualAlloc(0, 1, MEM_RESERVE, PAGE_READONLY); - if (!p) - { - Fail("EXCEPTION_CONTINUE_EXECUTION: test setup via " - "VirtualAlloc failed.\n"); - } - - *p = 13; /* causes an access violation exception */ - - bTry2 = TRUE; - - - } - PAL_EXCEPT_FILTER(ExitFilter, (LPVOID)&nValidator) - { - bExcept = TRUE; /* indicate we hit the PAL_EXCEPT_FILTER block */ - Fail("PAL_EXCEPT_FILTER: ERROR -> in handler despite filter's " - "continue choice\n"); - } - PAL_ENDTRY; - - if (!bTry) - { - Trace("PAL_EXCEPT_FILTER: ERROR -> It appears the code in the PAL_TRY" - " block was not executed.\n"); - } - - if (bExcept) - { - Trace("PAL_EXCEPT_FILTER: ERROR -> It appears the code in the " - "PAL_EXCEPT_FILTER block was executed.\n"); - } - - if (!bFilter) - { - Trace("PAL_EXCEPT_FILTER: ERROR -> It appears the code in the filter" - " function was not executed.\n"); - } - - - if (!bTry2) - { - Trace("PAL_EXCEPT_FILTER: ERROR -> It appears the code in the PAL_TRY" - " block after the exception causing statements was not executed.\n"); - } - - /* did we hit all the code blocks? */ - if(!bTry || bExcept || !bFilter) - { - Fail(""); - } - - - PAL_Terminate(); - return PASS; - -} diff --git a/src/pal/tests/palsuite/exception_handling/PAL_EXCEPT_FILTER/test2/testinfo.dat b/src/pal/tests/palsuite/exception_handling/PAL_EXCEPT_FILTER/test2/testinfo.dat deleted file mode 100644 index 729d2a4c4..000000000 --- a/src/pal/tests/palsuite/exception_handling/PAL_EXCEPT_FILTER/test2/testinfo.dat +++ /dev/null @@ -1,15 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = exception_handling -Function = PAL_EXCEPT_FILTER -Name = Test for PAL_EXCEPT_FILTER -Type = DEFAULT -EXE1 = pal_except_filter -LANG = cpp -Description -= Tests the PAL implementation of the PAL_EXCEPT_FILTER. An -= exception is forced and the filter returns -= EXCEPTION_CONTINUE_EXECUTION to allow execution to continue. diff --git a/src/pal/tests/palsuite/exception_handling/PAL_EXCEPT_FILTER/test3/CMakeLists.txt b/src/pal/tests/palsuite/exception_handling/PAL_EXCEPT_FILTER/test3/CMakeLists.txt deleted file mode 100644 index 45286ac19..000000000 --- a/src/pal/tests/palsuite/exception_handling/PAL_EXCEPT_FILTER/test3/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - pal_except_filter.cpp -) - -add_executable(paltest_pal_except_filter_test3 - ${SOURCES} -) - -add_dependencies(paltest_pal_except_filter_test3 coreclrpal) - -target_link_libraries(paltest_pal_except_filter_test3 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/exception_handling/PAL_EXCEPT_FILTER/test3/pal_except_filter.cpp b/src/pal/tests/palsuite/exception_handling/PAL_EXCEPT_FILTER/test3/pal_except_filter.cpp deleted file mode 100644 index 20c36840b..000000000 --- a/src/pal/tests/palsuite/exception_handling/PAL_EXCEPT_FILTER/test3/pal_except_filter.cpp +++ /dev/null @@ -1,206 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: pal_except_filter.c (test 3) -** -** Purpose: Tests the PAL implementation of the PAL_EXCEPT_FILTER in the -** presence of a call stack. An -** exception is forced and passed to two nested exception filters for -** consideration. The first filter returns EXCEPTION_CONTINUE_SEARCH -** so the second can run and return EXCEPTION_EXECUTE_HANDLER. The -** initial exception handler should be skipped, and the second -** executed -** -** -**===================================================================*/ - - - -#include - -BOOL bFilterCS = FALSE; -BOOL bFilterEE = FALSE; -BOOL bTry1 = FALSE; -BOOL bTry2 = FALSE; -BOOL bExcept1 = FALSE; -BOOL bExcept2 = FALSE; -BOOL bContinued = FALSE; -const int nValidator = 12321; - -LONG ContSearchFilter(EXCEPTION_POINTERS* ep, LPVOID pnTestInt) -{ - - /* let the main know we've hit the filter function */ - bFilterCS = TRUE; - - if (!bTry1 || !bTry2) - { - Fail("PAL_EXCEPT_FILTER: ERROR -> Something weird is going on." - " The ContSearch filter was hit without PAL_TRY being hit.\n"); - } - - if (bFilterEE) - { - Fail("PAL_EXCEPT_FILTER: ERROR -> Something weird is going on." - " The ContSearch filter was hit after the ExecuteException " - "filter.\n"); - } - - return EXCEPTION_CONTINUE_SEARCH; -} - -LONG ExecExeptionFilter(EXCEPTION_POINTERS* ep, LPVOID pnTestInt) -{ - /* let the main know we've hit the filter function */ - bFilterEE = TRUE; - - if (!bTry1 || !bTry2) - { - Fail("PAL_EXCEPT_FILTER: ERROR -> Something weird is going on." - " The ContSearch filter was hit without PAL_TRY being hit.\n"); - } - - if (!bFilterCS) - { - Fail("PAL_EXCEPT_FILTER: ERROR -> Something weird is going on." - " The ExecExeption filter was hit before the ContSearch " - "filter.\n"); - } - return EXCEPTION_EXECUTE_HANDLER; -} - -void NestedFunc1 (void) -{ - int* p = 0x00000000; /* pointer to NULL */ - - PAL_TRY - { - if (bExcept1 || bExcept2) - { - Fail("PAL_EXCEPT_FILTER: ERROR -> Something weird is going on." - " PAL_EXCEPT_FILTER was hit before PAL_TRY.\n"); - } - bTry2 = TRUE; /* indicate we hit the inner PAL_TRY block */ - *p = 13; /* causes an access violation exception */ - - Fail("PAL_EXCEPT_FILTER: ERROR -> Something weird is going on." - " We executed beyond the trapping code.\n"); - } - PAL_EXCEPT_FILTER(ContSearchFilter, (LPVOID)&nValidator) - { - Fail("PAL_EXCEPT_FILTER: ERROR -> Something weird is going on." - " The dummy handler was " - "being hit.\n"); - bExcept2 = TRUE; /* indicate we hit the inner block */ - } - PAL_ENDTRY; - -} - -void NestedFunc2 (void) -{ - NestedFunc1(); -} - -int __cdecl main(int argc, char *argv[]) -{ - if (0 != PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - /* - ** test to make sure we get into the second exception block only based - ** on the return codes of the filters - */ - - PAL_TRY - { - if (bExcept1 || bExcept2) - { - Fail("PAL_EXCEPT_FILTER: ERROR -> Something weird is going on." - " PAL_EXCEPT_FILTER was hit before PAL_TRY.\n"); - } - bTry1 = TRUE; /* indicate we hit the outer PAL_TRY block */ - - NestedFunc2(); - - Fail("PAL_EXCEPT_FILTER: ERROR -> Something weird is going on." - " We executed beyond the trapping code.\n"); - } - PAL_EXCEPT_FILTER(ExecExeptionFilter, (LPVOID)&nValidator) - { - if (!bTry1) - { - Fail("PAL_EXCEPT_FILTER: ERROR -> Something weird is going on." - " PAL_EXCEPT_FILTER's handler was hit without PAL_TRY's code " - "being hit.\n"); - } - if (!bTry2) - { - Fail("PAL_EXCEPT_FILTER: ERROR -> Something weird is going on." - " PAL_EXCEPT_FILTER's handler was hit without PAL_TRY's code " - "being hit.\n"); - } - if (!bFilterCS) - { - Fail("PAL_EXCEPT_FILTER: ERROR -> Something weird is going on." - " PAL_EXCEPT_FILTER's handler was hit without the inner filter " - "being hit.\n"); - } - if (!bFilterEE) - { - Fail("PAL_EXCEPT_FILTER: ERROR -> Something weird is going on." - " PAL_EXCEPT_FILTER's handler was hit without the outer filter " - "being hit.\n"); - } - bExcept1 = TRUE; /* indicate we hit the outer block */ - } - PAL_ENDTRY; - - if (!bTry1) - { - Trace("PAL_EXCEPT_FILTER: ERROR -> It appears the code in the outer" - " PAL_TRY block was not executed.\n"); - } - - if (bExcept2) - { - Trace("PAL_EXCEPT_FILTER: ERROR -> It appears the code in the " - "inner PAL_EXCEPT_FILTER block was executed.\n"); - } - if (!bExcept1) - { - Trace("PAL_EXCEPT_FILTER: ERROR -> It appears the code in the " - "outer PAL_EXCEPT_FILTER block was not executed.\n"); - } - - if (!bFilterCS) - { - Trace("PAL_EXCEPT_FILTER: ERROR -> It appears the code in the " - "search continuing filter" - " function was not executed.\n"); - } - if (!bFilterEE) - { - Trace("PAL_EXCEPT_FILTER: ERROR -> It appears the code in the " - "execute handler filter" - " function was not executed.\n"); - } - - - /* did we hit all the code blocks? */ - if(!bTry1 || !bTry2 || !bExcept1 || bExcept2 || !bFilterEE || !bFilterCS ) - { - Fail(""); - } - - - PAL_Terminate(); - return PASS; - -} diff --git a/src/pal/tests/palsuite/exception_handling/PAL_EXCEPT_FILTER/test3/testinfo.dat b/src/pal/tests/palsuite/exception_handling/PAL_EXCEPT_FILTER/test3/testinfo.dat deleted file mode 100644 index d2df39939..000000000 --- a/src/pal/tests/palsuite/exception_handling/PAL_EXCEPT_FILTER/test3/testinfo.dat +++ /dev/null @@ -1,19 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = exception_handling -Function = PAL_EXCEPT_FILTER_EX -Name = Test for nested PAL_EXCEPT_FILTER functions & EXCEPTION_CONTINUE_SEARCH -Type = DEFAULT -EXE1 = pal_except_filter -LANG = cpp -Description -= Tests the PAL implementation of the PAL_EXCEPT_FILTER with nested -= functions to build a call stack. An -= exception is forced and passed to two nested exception filters for -= consideration. The first filter returns EXCEPTION_CONTINUE_SEARCH -= so the second can run and return EXCEPTION_EXECUTE_HANDLER. The -= initial exception handler should be skipped, and the second -= executed diff --git a/src/pal/tests/palsuite/exception_handling/PAL_EXCEPT_FILTER_EX/CMakeLists.txt b/src/pal/tests/palsuite/exception_handling/PAL_EXCEPT_FILTER_EX/CMakeLists.txt deleted file mode 100644 index 1962ade35..000000000 --- a/src/pal/tests/palsuite/exception_handling/PAL_EXCEPT_FILTER_EX/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) -add_subdirectory(test3) - diff --git a/src/pal/tests/palsuite/exception_handling/PAL_EXCEPT_FILTER_EX/test1/CMakeLists.txt b/src/pal/tests/palsuite/exception_handling/PAL_EXCEPT_FILTER_EX/test1/CMakeLists.txt deleted file mode 100644 index be9ab1aa6..000000000 --- a/src/pal/tests/palsuite/exception_handling/PAL_EXCEPT_FILTER_EX/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - PAL_EXCEPT_FILTER_EX.cpp -) - -add_executable(paltest_pal_except_filter_ex_test1 - ${SOURCES} -) - -add_dependencies(paltest_pal_except_filter_ex_test1 coreclrpal) - -target_link_libraries(paltest_pal_except_filter_ex_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/exception_handling/PAL_EXCEPT_FILTER_EX/test1/PAL_EXCEPT_FILTER_EX.cpp b/src/pal/tests/palsuite/exception_handling/PAL_EXCEPT_FILTER_EX/test1/PAL_EXCEPT_FILTER_EX.cpp deleted file mode 100644 index 91f392d8d..000000000 --- a/src/pal/tests/palsuite/exception_handling/PAL_EXCEPT_FILTER_EX/test1/PAL_EXCEPT_FILTER_EX.cpp +++ /dev/null @@ -1,197 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: PAL_EXCEPT_FILTER_EX.c (test 1) -** -** Purpose: Tests the PAL implementation of the PAL_EXCEPT_FILTER_EX. -** There are two try blocks in this test. The first forces an -** exception error to force hitting the first filter. The second -** doesn't to make sure we don't hit the filter. A value is also -** passed into the filter program and it is validated to make sure -** it was passed correctly. -** -** -**===================================================================*/ - -#include - -BOOL bFilter = FALSE; -BOOL bTry = FALSE; -const int nValidator = 12321; - - -/** -** -** Filter function for the first try block -** -**/ - -LONG Filter_01(EXCEPTION_POINTERS* ep, VOID *pnTestInt) -{ - int nTestInt = *(int *)pnTestInt; - - /* let the main know we've hit the filter function */ - bFilter = TRUE; - - if (!bTry) - { - Fail("PAL_EXCEPT_FILTER_EX: ERROR -> Something weird is going on." - " The filter was hit without PAL_TRY being hit.\n"); - } - - /* was the correct value passed? */ - if (nValidator != nTestInt) - { - Fail("PAL_EXCEPT_FILTER_EX: ERROR -> Parameter passed to filter" - " function should have been \"%d\" but was \"%d\".\n", - nValidator, - nTestInt); - } - - return EXCEPTION_EXECUTE_HANDLER; -} - - -/** -** -** Filter function for the second try block. We shouldn't -** hit this function. -** -**/ - -LONG Filter_02(EXCEPTION_POINTERS* ep, VOID *pnTestInt) -{ - /* let the main know we've hit the filter function */ - bFilter = TRUE; - - return EXCEPTION_EXECUTE_HANDLER; -} - - -int __cdecl main(int argc, char *argv[]) -{ - int* p = 0x00000000; - BOOL bExcept = FALSE; - - if (0 != PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - /* - ** test to make sure we get into the exception block - */ - - PAL_TRY - { - if (bExcept) - { - Fail("PAL_EXCEPT_FILTER_EX: ERROR -> Something weird is going on." - " The first PAL_EXCEPT_FILTER_EX was hit before PAL_TRY.\n"); - } - - bTry = TRUE; /* indicate we hit the PAL_TRY block */ - *p = 13; /* causes an access violation exception */ - - Fail("PAL_EXCEPT_FILTER_EX: ERROR -> code was executed after the " - "access violation.\n"); - } - PAL_EXCEPT_FILTER(Filter_01, (LPVOID)&nValidator) - { - if (!bTry) - { - Fail("PAL_EXCEPT_FILTER_EX: ERROR -> Something weird is going on." - " PAL_EXCEPT_FILTER_EX was hit without PAL_TRY being hit.\n"); - } - bExcept = TRUE; /* indicate we hit the PAL_EXCEPT_FILTER_EX block */ - } - PAL_ENDTRY; - - if (!bTry) - { - Trace("PAL_EXCEPT_FILTER_EX: ERROR -> It appears the code in the " - "first PAL_TRY block was not executed.\n"); - } - - if (!bExcept) - { - Trace("PAL_EXCEPT_FILTER_EX: ERROR -> It appears the code in the " - "first PAL_EXCEPT_FILTER_EX block was not executed.\n"); - } - - if (!bFilter) - { - Trace("PAL_EXCEPT_FILTER_EX: ERROR -> It appears the code in the first" - " filter function was not executed.\n"); - } - - - /* did we hit all the code blocks? */ - if(!bTry || !bExcept || !bFilter) - { - Fail(""); - } - - bTry = bExcept = bFilter = FALSE; - - - /* - ** test to make sure we skip the exception block - */ - - PAL_TRY - { - if (bExcept) - { - Fail("PAL_EXCEPT_FILTER_EX: ERROR -> Something weird is going on." - " Second PAL_EXCEPT_FILTER_EX was hit before PAL_TRY.\n"); - } - bTry = TRUE; /* indicate we hit the PAL_TRY block */ - } - PAL_EXCEPT_FILTER(Filter_02, (LPVOID)&nValidator) - { - if (!bTry) - { - Fail("PAL_EXCEPT_FILTER_EX: ERROR -> Something weird is going on." - " PAL_EXCEPT_FILTER_EX was hit without PAL_TRY being hit.\n"); - } - bExcept = TRUE; /* indicate we hit the PAL_EXCEPT_FILTER_EX block */ - } - PAL_ENDTRY; - - if (!bTry) - { - Trace("PAL_EXCEPT_FILTER_EX: ERROR -> It appears the code in the " - "second PAL_TRY block was not executed.\n"); - } - - if (bExcept) - { - Trace("PAL_EXCEPT_FILTER_EX: ERROR -> It appears the code in the " - "second PAL_EXCEPT_FILTER_EX block was executed even though an" - " exception was not triggered.\n"); - } - - if (bFilter) - { - Trace("PAL_EXCEPT_FILTER_EX: ERROR -> It appears the code in the second" - " filter function was executed even though an exception was" - " not triggered.\n"); - } - - - /* did we hit all the correct code blocks? */ - if(!bTry || bExcept || bFilter) - { - Fail(""); - } - - - PAL_Terminate(); - return PASS; - -} diff --git a/src/pal/tests/palsuite/exception_handling/PAL_EXCEPT_FILTER_EX/test1/testinfo.dat b/src/pal/tests/palsuite/exception_handling/PAL_EXCEPT_FILTER_EX/test1/testinfo.dat deleted file mode 100644 index 1d8f8f600..000000000 --- a/src/pal/tests/palsuite/exception_handling/PAL_EXCEPT_FILTER_EX/test1/testinfo.dat +++ /dev/null @@ -1,18 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = exception_handling -Function = PAL_EXCEPT_FILTER_EX -Name = Test for PAL_EXCEPT_FILTER_EX -Type = DEFAULT -EXE1 = pal_except_filter_ex -LANG = cpp -Description -= Tests the PAL implementation of the PAL_EXCEPT_FILTER_EX. -= There are two try blocks in this test. The first forces an -= exception error to force hitting the first filter. The second -= doesn't to make sure we don't hit the filter. A value is also -= passed into the filter program and it is validated to make sure -= it was passed correctly. diff --git a/src/pal/tests/palsuite/exception_handling/PAL_EXCEPT_FILTER_EX/test2/CMakeLists.txt b/src/pal/tests/palsuite/exception_handling/PAL_EXCEPT_FILTER_EX/test2/CMakeLists.txt deleted file mode 100644 index 4d90c711c..000000000 --- a/src/pal/tests/palsuite/exception_handling/PAL_EXCEPT_FILTER_EX/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - pal_except_filter_ex.cpp -) - -add_executable(paltest_pal_except_filter_ex_test2 - ${SOURCES} -) - -add_dependencies(paltest_pal_except_filter_ex_test2 coreclrpal) - -target_link_libraries(paltest_pal_except_filter_ex_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/exception_handling/PAL_EXCEPT_FILTER_EX/test2/pal_except_filter_ex.cpp b/src/pal/tests/palsuite/exception_handling/PAL_EXCEPT_FILTER_EX/test2/pal_except_filter_ex.cpp deleted file mode 100644 index ab25c4973..000000000 --- a/src/pal/tests/palsuite/exception_handling/PAL_EXCEPT_FILTER_EX/test2/pal_except_filter_ex.cpp +++ /dev/null @@ -1,142 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: PAL_EXCEPT_FILTER_EX.c (test 2) -** -** Purpose: Tests the PAL implementation of the PAL_EXCEPT_FILTER_EX. -** There is a nested try blocks in this test. The nested -** PAL_TRY creates an exception and the FILTER creates another. -** This test makes sure that this case does not end in a -** infinite loop. -** -** -**===================================================================*/ - -#include - -BOOL bFilter = FALSE; -BOOL bTry = FALSE; -BOOL bTry2 = FALSE; -const int nValidator = 12321; - -/* Filter function for the first try block. - */ -LONG Filter_01(EXCEPTION_POINTERS* ep, VOID *pnTestInt) -{ - int nTestInt = *(int *)pnTestInt; - - /* Signal main() that filter has been executed. */ - bFilter = TRUE; - - if (!bTry) - { - Fail("ERROR: The filter was executed without " - "entering the first PAL_TRY.\n"); - } - - if (!bTry2) - { - Fail("ERROR: The filter was executed without " - "entering the second PAL_TRY.\n"); - } - - /* Was the correct value passed? */ - if (nValidator != nTestInt) - { - Fail("ERROR: Parameter passed to filter function " - "should have been \"%d\" but was \"%d\".\n", - nValidator, - nTestInt); - } - - return EXCEPTION_EXECUTE_HANDLER; -} - -int __cdecl main(int argc, char *argv[]) -{ - int* p = 0x00000000; - BOOL bExcept = FALSE; - BOOL bExcept2 = FALSE; - - /* Initalize the PAL. - */ - if (0 != PAL_Initialize(argc, argv)) - { - return FAIL; - } - - /* Test a nested PAL_Try block. - */ - PAL_TRY - { - /* Signal entry into first PAL_TRY block.*/ - bTry = TRUE; - - PAL_TRY - { - /* Signal entry into second PAL_TRY block.*/ - bTry2 = TRUE; - /* Cause an exception.*/ - *p = 13; - } - PAL_EXCEPT_FILTER(Filter_01, (LPVOID)&nValidator) - { - /* Signal entry into second PAL_EXCEPT filter.*/ - bExcept = TRUE; - /* Cause another exception.*/ - *p = 13; - } - PAL_ENDTRY - - } - PAL_EXCEPT_FILTER(Filter_01, (LPVOID)&nValidator) - { - /* Signal entry into second PAL_EXCEPT filter.*/ - bExcept2 = TRUE; - } - PAL_ENDTRY; - - if (!bTry) - { - Trace("ERROR: The code in the first " - "PAL_TRY block was not executed.\n"); - } - - if (!bTry2) - { - Trace("ERROR: The code in the nested " - "PAL_TRY block was not executed.\n"); - } - - if (!bExcept) - { - Trace("ERROR: The code in the first " - "PAL_EXCEPT_FILTER_EX block was not executed.\n"); - } - - if (!bExcept2) - { - Trace("ERROR: The code in the second " - "PAL_EXCEPT_FILTER_EX block was not executed.\n"); - } - - if (!bFilter) - { - Trace("ERROR: The code in the first " - "filter function was not executed.\n"); - } - - if(!bTry || !bTry2 || !bExcept || !bExcept2 || !bFilter ) - { - Fail(""); - } - - /* Terminate the PAL. - */ - PAL_Terminate(); - return PASS; - -} diff --git a/src/pal/tests/palsuite/exception_handling/PAL_EXCEPT_FILTER_EX/test2/testinfo.dat b/src/pal/tests/palsuite/exception_handling/PAL_EXCEPT_FILTER_EX/test2/testinfo.dat deleted file mode 100644 index 0343d133e..000000000 --- a/src/pal/tests/palsuite/exception_handling/PAL_EXCEPT_FILTER_EX/test2/testinfo.dat +++ /dev/null @@ -1,17 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = exception_handling -Function = PAL_EXCEPT_FILTER_EX -Name = Test for PAL_EXCEPT_FILTER_EX -Type = DEFAULT -EXE1 = pal_except_filter_ex -LANG = cpp -Description -= Tests the PAL implementation of the PAL_EXCEPT_FILTER_EX. -= There is a nested try blocks in this test. The nested -= PAL_TRY creates an exception and the FILTER creates another. -= This test makes sure that this case does not end in a -= infinite loop. diff --git a/src/pal/tests/palsuite/exception_handling/PAL_EXCEPT_FILTER_EX/test3/CMakeLists.txt b/src/pal/tests/palsuite/exception_handling/PAL_EXCEPT_FILTER_EX/test3/CMakeLists.txt deleted file mode 100644 index 6a5214515..000000000 --- a/src/pal/tests/palsuite/exception_handling/PAL_EXCEPT_FILTER_EX/test3/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - pal_except_filter.cpp -) - -add_executable(paltest_pal_except_filter_ex_test3 - ${SOURCES} -) - -add_dependencies(paltest_pal_except_filter_ex_test3 coreclrpal) - -target_link_libraries(paltest_pal_except_filter_ex_test3 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/exception_handling/PAL_EXCEPT_FILTER_EX/test3/pal_except_filter.cpp b/src/pal/tests/palsuite/exception_handling/PAL_EXCEPT_FILTER_EX/test3/pal_except_filter.cpp deleted file mode 100644 index a17cb4f6b..000000000 --- a/src/pal/tests/palsuite/exception_handling/PAL_EXCEPT_FILTER_EX/test3/pal_except_filter.cpp +++ /dev/null @@ -1,208 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: pal_except_filter_ex.c (test 3) -** -** Purpose: Tests the PAL implementation of the PAL_EXCEPT_FILTER_EX. An -** exception is forced and passed to two nested exception filters for -** consideration. The first filter returns EXCEPTION_CONTINUE_SEARCH -** so the second can run and return EXCEPTION_EXECUTE_HANDLER. The -** initial exception handler should be skipped, and the second -** executed -** -** -**===================================================================*/ - - - -#include - -BOOL bFilterCS = FALSE; -BOOL bFilterEE = FALSE; -BOOL bTry1 = FALSE; -BOOL bTry2 = FALSE; -BOOL bContinued = FALSE; -const int nValidator = 12321; - -LONG ContSearchFilter(EXCEPTION_POINTERS* ep, LPVOID pnTestInt) -{ - - /* let the main know we've hit the filter function */ - bFilterCS = TRUE; - - if (!bTry1 || !bTry2) - { - Fail("PAL_EXCEPT_FILTER: ERROR -> Something weird is going on." - " The ContSearch filter was hit without PAL_TRY being hit.\n"); - } - - if (bFilterEE) - { - Fail("PAL_EXCEPT_FILTER: ERROR -> Something weird is going on." - " The ContSearch filter was hit after the ExecuteException " - "filter.\n"); - } - - return EXCEPTION_CONTINUE_SEARCH; -} - -LONG ExecExeptionFilter(EXCEPTION_POINTERS* ep, LPVOID pnTestInt) -{ - /* let the main know we've hit the filter function */ - bFilterEE = TRUE; - - if (!bTry1 || !bTry2) - { - Fail("PAL_EXCEPT_FILTER: ERROR -> Something weird is going on." - " The ContSearch filter was hit without PAL_TRY being hit.\n"); - } - - if (!bFilterCS) - { - Fail("PAL_EXCEPT_FILTER: ERROR -> Something weird is going on." - " The ExecExeption filter was hit before the ContSearch " - "filter.\n"); - } - return EXCEPTION_EXECUTE_HANDLER; -} - -int __cdecl main(int argc, char *argv[]) -{ - int* p = 0x00000000; /* pointer to NULL */ - BOOL bExcept1 = FALSE; - BOOL bExcept2 = FALSE; - - if (0 != PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - /* - ** test to make sure we get into the second exception block only based - ** on the return codes of the filters - */ - - PAL_TRY - { - if (bExcept1 || bExcept2) - { - Fail("PAL_EXCEPT_FILTER: ERROR -> Something weird is going on." - " PAL_EXCEPT_FILTER was hit before PAL_TRY.\n"); - } - bTry1 = TRUE; /* indicate we hit the outer PAL_TRY block */ - - PAL_TRY - { - if (bExcept1 || bExcept2) - { - Fail("PAL_EXCEPT_FILTER: ERROR -> Something weird is going on." - " PAL_EXCEPT_FILTER was hit before PAL_TRY.\n"); - } - bTry2 = TRUE; /* indicate we hit the inner PAL_TRY block */ - *p = 13; /* causes an access violation exception */ - - Fail("PAL_EXCEPT_FILTER: ERROR -> Something weird is going on." - " We executed beyond the trapping code.\n"); - } - - PAL_EXCEPT_FILTER(ContSearchFilter, (LPVOID)&nValidator) - { - Fail("PAL_EXCEPT_FILTER: ERROR -> Something weird is going on." - " The dummy handler was " - "being hit.\n"); - } - PAL_ENDTRY; - - bExcept2 = TRUE; /* indicate we hit the inner block */ - } - PAL_EXCEPT_FILTER(ExecExeptionFilter, (LPVOID)&nValidator) - { - if (!bTry1) - { - Fail("PAL_EXCEPT_FILTER: ERROR -> Something weird is going on." - " PAL_EXCEPT_FILTER's handler was hit without PAL_TRY's code " - "being hit.\n"); - } - if (!bTry2) - { - Fail("PAL_EXCEPT_FILTER: ERROR -> Something weird is going on." - " PAL_EXCEPT_FILTER's handler was hit without PAL_TRY's code " - "being hit.\n"); - } - if (!bFilterCS) - { - Fail("PAL_EXCEPT_FILTER: ERROR -> Something weird is going on. " - "PAL_EXCEPT_FILTER's handler was hit without " - "the inner filter being hit.\n"); - } - if (!bFilterEE) - { - Fail("PAL_EXCEPT_FILTER: ERROR -> Something weird is going on. " - "PAL_EXCEPT_FILTER's handler was hit without " - "the outer filter being hit.\n"); - } - bExcept1 = TRUE; /* indicate we hit the outer block */ - } - PAL_ENDTRY; - - if (!bTry1) - { - Trace("PAL_EXCEPT_FILTER: ERROR -> It appears the code in the outer" - " PAL_TRY block was not executed.\n"); - } - - if (!bTry2) - { - Trace("PAL_EXCEPT_FILTER: ERROR -> It appears the code in the inner" - " PAL_TRY block was not executed.\n"); - } - - if (bExcept2) - { - Trace("PAL_EXCEPT_FILTER: ERROR -> It appears the code in the " - "inner PAL_EXCEPT_FILTER block was executed.\n"); - } - if (!bExcept1) - { - Trace("PAL_EXCEPT_FILTER: ERROR -> It appears the code in the " - "outer PAL_EXCEPT_FILTER block was not executed.\n"); - } - - if (!bFilterCS) - { - Trace("PAL_EXCEPT_FILTER: ERROR -> It appears the code in the " - "search continuing filter" - " function was not executed.\n"); - } - if (!bFilterEE) - { - Trace("PAL_EXCEPT_FILTER: ERROR -> It appears the code in the " - "execute handler filter" - " function was not executed.\n"); - } - - - if (!bTry2) - { - Trace("PAL_EXCEPT_FILTER: ERROR -> It appears the code in the PAL_TRY " - "block after the exception causing statements " - "was not executed.\n"); - } - - /* did we hit all the code blocks? */ - if(!bTry1 || !bTry2 || !bExcept1 || bExcept2 || !bFilterEE || !bFilterCS ) - { - Fail(""); - } - - - PAL_Terminate(); - return PASS; - -} - - diff --git a/src/pal/tests/palsuite/exception_handling/PAL_EXCEPT_FILTER_EX/test3/testinfo.dat b/src/pal/tests/palsuite/exception_handling/PAL_EXCEPT_FILTER_EX/test3/testinfo.dat deleted file mode 100644 index 568296c39..000000000 --- a/src/pal/tests/palsuite/exception_handling/PAL_EXCEPT_FILTER_EX/test3/testinfo.dat +++ /dev/null @@ -1,18 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = exception_handling -Function = PAL_EXCEPT_FILTER_EX -Name = Test for nested PAL_EXCEPT_FILTER_EX & EXCEPTION_CONTINUE_SEARCH -Type = DEFAULT -EXE1 = pal_except_filter -LANG = cpp -Description -= Tests the PAL implementation of the PAL_EXCEPT_FILTER_EX. An -= exception is forced and passed to two nested exception filters for -= consideration. The first filter returns EXCEPTION_CONTINUE_SEARCH -= so the second can run and return EXCEPTION_EXECUTE_HANDLER. The -= initial exception handler should be skipped, and the second -= executed diff --git a/src/pal/tests/palsuite/exception_handling/PAL_TRY_EXCEPT/CMakeLists.txt b/src/pal/tests/palsuite/exception_handling/PAL_TRY_EXCEPT/CMakeLists.txt deleted file mode 100644 index ef14ea535..000000000 --- a/src/pal/tests/palsuite/exception_handling/PAL_TRY_EXCEPT/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) - diff --git a/src/pal/tests/palsuite/exception_handling/PAL_TRY_EXCEPT/test1/CMakeLists.txt b/src/pal/tests/palsuite/exception_handling/PAL_TRY_EXCEPT/test1/CMakeLists.txt deleted file mode 100644 index ad208751f..000000000 --- a/src/pal/tests/palsuite/exception_handling/PAL_TRY_EXCEPT/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - PAL_TRY_EXCEPT.cpp -) - -add_executable(paltest_pal_try_except_test1 - ${SOURCES} -) - -add_dependencies(paltest_pal_try_except_test1 coreclrpal) - -target_link_libraries(paltest_pal_try_except_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/exception_handling/PAL_TRY_EXCEPT/test1/PAL_TRY_EXCEPT.cpp b/src/pal/tests/palsuite/exception_handling/PAL_TRY_EXCEPT/test1/PAL_TRY_EXCEPT.cpp deleted file mode 100644 index 4fb09bd27..000000000 --- a/src/pal/tests/palsuite/exception_handling/PAL_TRY_EXCEPT/test1/PAL_TRY_EXCEPT.cpp +++ /dev/null @@ -1,82 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: PAL_TRY_EXCEPT.c (test 1) -** -** Purpose: Tests the PAL implementation of the PAL_TRY and -** PAL_EXCEPT functions. An exception is forced to ensure -** the exception block is hit. -** -** -**===================================================================*/ - - - -#include - - -int __cdecl main(int argc, char *argv[]) -{ - int* p = 0x00000000; /* NULL pointer */ - BOOL bTry = FALSE; - BOOL bExcept = FALSE; - - if (0 != PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - /* - ** test to make sure we get into the exception block - */ - - PAL_TRY - { - if (bExcept) - { - Fail("PAL_TRY_EXCEPT: ERROR -> Something weird is going on." - " PAL_EXCEPT was hit before PAL_TRY.\n"); - } - bTry = TRUE; /* indicate we hit the PAL_TRY block */ - *p = 13; /* causes an access violation exception */ - Fail("PAL_TRY_EXCEPT: ERROR -> code was executed after the " - "access violation.\n"); - } - PAL_EXCEPT(EXCEPTION_EXECUTE_HANDLER) - { - if (!bTry) - { - Fail("PAL_TRY_EXCEPT: ERROR -> Something weird is going on." - " PAL_EXCEPT was hit without PAL_TRY being hit.\n"); - } - bExcept = TRUE; /* indicate we hit the PAL_EXCEPT block */ - } - PAL_ENDTRY; - - if (!bTry) - { - Trace("PAL_TRY_EXCEPT: ERROR -> It appears the code in the PAL_TRY" - " block was not executed.\n"); - } - - if (!bExcept) - { - Trace("PAL_TRY_EXCEPT: ERROR -> It appears the code in the PAL_EXCEPT" - " block was not executed.\n"); - } - - /* did we hit all the code blocks? */ - if(!bTry || !bExcept) - { - Fail(""); - } - - - PAL_Terminate(); - return PASS; - -} diff --git a/src/pal/tests/palsuite/exception_handling/PAL_TRY_EXCEPT/test1/testinfo.dat b/src/pal/tests/palsuite/exception_handling/PAL_TRY_EXCEPT/test1/testinfo.dat deleted file mode 100644 index 1f663a8bc..000000000 --- a/src/pal/tests/palsuite/exception_handling/PAL_TRY_EXCEPT/test1/testinfo.dat +++ /dev/null @@ -1,16 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = exception_handling -Function = PAL_TRY and PAL_EXCEPT -Name = Test for PAL_TRY and PAL_EXCEPT -Type = DEFAULT -EXE1 = pal_try_except -LANG = cpp -Description -= Since these two are so closely connected, they are tested together. -= In the PAL_TRY block, an access violation is forced to gain -= access to the PAL_EXCEPT block. Booleans are used to ensure -= each of the code blocks are hit. diff --git a/src/pal/tests/palsuite/exception_handling/PAL_TRY_EXCEPT/test2/CMakeLists.txt b/src/pal/tests/palsuite/exception_handling/PAL_TRY_EXCEPT/test2/CMakeLists.txt deleted file mode 100644 index da34fb23f..000000000 --- a/src/pal/tests/palsuite/exception_handling/PAL_TRY_EXCEPT/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - PAL_TRY_EXCEPT.cpp -) - -add_executable(paltest_pal_try_except_test2 - ${SOURCES} -) - -add_dependencies(paltest_pal_try_except_test2 coreclrpal) - -target_link_libraries(paltest_pal_try_except_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/exception_handling/PAL_TRY_EXCEPT/test2/PAL_TRY_EXCEPT.cpp b/src/pal/tests/palsuite/exception_handling/PAL_TRY_EXCEPT/test2/PAL_TRY_EXCEPT.cpp deleted file mode 100644 index eb7b9d125..000000000 --- a/src/pal/tests/palsuite/exception_handling/PAL_TRY_EXCEPT/test2/PAL_TRY_EXCEPT.cpp +++ /dev/null @@ -1,68 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: PAL_TRY_EXCEPT.c (test 2) -** -** Purpose: Tests the PAL implementation of the PAL_TRY and -** PAL_EXCEPT functions. Tests that the EXCEPTION block -** is missed if no exceptions happen -** -** -**===================================================================*/ - - - -#include - - -int __cdecl main(int argc, char *argv[]) -{ - BOOL bTry = FALSE; - BOOL bExcept = FALSE; - - if (0 != PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - /* - ** Test to make sure we skip the exception block. - */ - - PAL_TRY - { - bTry = TRUE; /* indicate we hit the PAL_TRY block */ - } - PAL_EXCEPT(EXCEPTION_EXECUTE_HANDLER) - { - bExcept = TRUE; /* indicate we hit the PAL_EXCEPT block */ - } - PAL_ENDTRY; - - if (!bTry) - { - Trace("PAL_TRY_EXCEPT: ERROR -> It appears the code in the PAL_TRY" - " block was not executed.\n"); - } - - if (bExcept) - { - Trace("PAL_TRY_EXCEPT: ERROR -> It appears the code in the PAL_EXCEPT" - " block was executed even though no exception was supposed to" - " happen.\n"); - } - - /* did we hit the correct code blocks? */ - if(!bTry || bExcept) - { - Fail(""); - } - - PAL_Terminate(); - return PASS; - -} diff --git a/src/pal/tests/palsuite/exception_handling/PAL_TRY_EXCEPT/test2/testinfo.dat b/src/pal/tests/palsuite/exception_handling/PAL_TRY_EXCEPT/test2/testinfo.dat deleted file mode 100644 index a5815f572..000000000 --- a/src/pal/tests/palsuite/exception_handling/PAL_TRY_EXCEPT/test2/testinfo.dat +++ /dev/null @@ -1,15 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = exception_handling -Function = PAL_TRY and PAL_EXCEPT (test 2) -Name = Test for PAL_TRY and PAL_EXCEPT -Type = DEFAULT -EXE1 = pal_try_except -LANG = cpp -Description -= Since these two are so closely connected, they are tested together. -= In this test, no exceptions are forced to ensure the EXCEPTION block -= isn't hit. Booleans are used to ensure the proper code blocks are hit. diff --git a/src/pal/tests/palsuite/exception_handling/PAL_TRY_EXCEPT_EX/CMakeLists.txt b/src/pal/tests/palsuite/exception_handling/PAL_TRY_EXCEPT_EX/CMakeLists.txt deleted file mode 100644 index 1962ade35..000000000 --- a/src/pal/tests/palsuite/exception_handling/PAL_TRY_EXCEPT_EX/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) -add_subdirectory(test3) - diff --git a/src/pal/tests/palsuite/exception_handling/PAL_TRY_EXCEPT_EX/test1/CMakeLists.txt b/src/pal/tests/palsuite/exception_handling/PAL_TRY_EXCEPT_EX/test1/CMakeLists.txt deleted file mode 100644 index 2ab8a2567..000000000 --- a/src/pal/tests/palsuite/exception_handling/PAL_TRY_EXCEPT_EX/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - PAL_TRY_EXCEPT_EX.cpp -) - -add_executable(paltest_pal_try_except_ex_test1 - ${SOURCES} -) - -add_dependencies(paltest_pal_try_except_ex_test1 coreclrpal) - -target_link_libraries(paltest_pal_try_except_ex_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/exception_handling/PAL_TRY_EXCEPT_EX/test1/PAL_TRY_EXCEPT_EX.cpp b/src/pal/tests/palsuite/exception_handling/PAL_TRY_EXCEPT_EX/test1/PAL_TRY_EXCEPT_EX.cpp deleted file mode 100644 index 8b4dd7b43..000000000 --- a/src/pal/tests/palsuite/exception_handling/PAL_TRY_EXCEPT_EX/test1/PAL_TRY_EXCEPT_EX.cpp +++ /dev/null @@ -1,133 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: PAL_TRY_EXCEPT.c (test 1) -** -** Purpose: Tests the PAL implementation of the PAL_TRY and -** PAL_EXCEPT functions. Exceptions are forced to ensure -** the exception blocks are hit. -** -** -**===================================================================*/ - - - -#include - - -int __cdecl main(int argc, char *argv[]) -{ - int* p = 0x00000000; /* NULL pointer */ - BOOL bTry = FALSE; - BOOL bExcept = FALSE; - BOOL bTestA = TRUE; - - if (0 != PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - /* - ** test to make sure we get into the exception block - */ - - PAL_TRY - { - if (!bTestA) - { - Fail("PAL_TRY_EXCEPT: ERROR ->" - " It appears the first try block was hit a second time.\n"); - } - bTry = TRUE; /* indicate we hit the PAL_TRY block */ - *p = 13; /* causes an access violation exception */ - Fail("PAL_TRY_EXCEPT: ERROR -> code was executed after the " - "access violation.\n"); - } - PAL_EXCEPT(EXCEPTION_EXECUTE_HANDLER) - { - if (!bTestA) - { - Fail("PAL_TRY_EXCEPT: ERROR ->" - " It appears the first except block was hit a second time.\n"); - } - bExcept = TRUE; /* indicate we hit the PAL_EXCEPT block */ - } - PAL_ENDTRY; - - if (!bTry) - { - Trace("PAL_TRY_EXCEPT: ERROR -> It appears the code in the PAL_TRY" - " block was not executed.\n"); - } - - if (!bExcept) - { - Trace("PAL_TRY_EXCEPT: ERROR -> It appears the code in the first" - " PAL_EXCEPT block was not executed.\n"); - } - - /* did we hit all the code blocks? */ - if(!bTry || !bExcept) - { - Fail(""); - } - - - /* - ** test to make sure we get into the second exception block - */ - - bTry = FALSE; - bExcept = FALSE; - bTestA = FALSE; /* we are now going into the second block test */ - - - PAL_TRY - { - if (bTestA) - { - Fail("PAL_TRY_EXCEPT: ERROR -> It appears" - " the second try block was hit too early.\n"); - } - bTry = TRUE; /* indicate we hit the PAL_TRY block */ - *p = 13; /* causes an access violation exception */ - Fail("PAL_TRY_EXCEPT: ERROR -> code was executed after the " - "access violation.\n"); - } - PAL_EXCEPT(EXCEPTION_EXECUTE_HANDLER) - { - if (bTestA) - { - Fail("PAL_TRY_EXCEPT: ERROR -> It appears" - " the second except block was hit too early.\n"); - } - bExcept = TRUE; /* indicate we hit the PAL_EXCEPT block */ - } - PAL_ENDTRY; - - if (!bTry) - { - Trace("PAL_TRY_EXCEPT: ERROR -> It appears the code in the second" - " PAL_TRY block was not executed."); - } - - if (!bExcept) - { - Trace("PAL_TRY_EXCEPT: ERROR -> It appears the code in the PAL_EXCEPT" - " block was not executed."); - } - - /* did we hit all the code blocks? */ - if(!bTry || !bExcept) - { - Fail("\n"); - } - - PAL_Terminate(); - return PASS; - -} diff --git a/src/pal/tests/palsuite/exception_handling/PAL_TRY_EXCEPT_EX/test1/testinfo.dat b/src/pal/tests/palsuite/exception_handling/PAL_TRY_EXCEPT_EX/test1/testinfo.dat deleted file mode 100644 index b57142793..000000000 --- a/src/pal/tests/palsuite/exception_handling/PAL_TRY_EXCEPT_EX/test1/testinfo.dat +++ /dev/null @@ -1,16 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = exception_handling -Function = PAL_TRY and PAL_EXCEPT_EX -Name = Test for PAL_TRY and PAL_EXCEPT_EX -Type = DEFAULT -EXE1 = pal_try_except_ex -LANG = cpp -Description -= Since these two are so closely connected, they are tested together. -= In the PAL_TRY block, an access violation is forced to gain -= access to the PAL_EXCEPT block. Booleans are used to ensure -= each of the code blocks are hit. diff --git a/src/pal/tests/palsuite/exception_handling/PAL_TRY_EXCEPT_EX/test2/CMakeLists.txt b/src/pal/tests/palsuite/exception_handling/PAL_TRY_EXCEPT_EX/test2/CMakeLists.txt deleted file mode 100644 index 80d90dd9b..000000000 --- a/src/pal/tests/palsuite/exception_handling/PAL_TRY_EXCEPT_EX/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - PAL_TRY_EXCEPT_EX.cpp -) - -add_executable(paltest_pal_try_except_ex_test2 - ${SOURCES} -) - -add_dependencies(paltest_pal_try_except_ex_test2 coreclrpal) - -target_link_libraries(paltest_pal_try_except_ex_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/exception_handling/PAL_TRY_EXCEPT_EX/test2/PAL_TRY_EXCEPT_EX.cpp b/src/pal/tests/palsuite/exception_handling/PAL_TRY_EXCEPT_EX/test2/PAL_TRY_EXCEPT_EX.cpp deleted file mode 100644 index 5ab4a95ce..000000000 --- a/src/pal/tests/palsuite/exception_handling/PAL_TRY_EXCEPT_EX/test2/PAL_TRY_EXCEPT_EX.cpp +++ /dev/null @@ -1,123 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: PAL_TRY_EXCEPT.c (test 2) -** -** Purpose: Tests the PAL implementation of the PAL_TRY and -** PAL_EXCEPT functions. Exceptions are not forced to ensure -** the proper blocks are hit. -** -** -**===================================================================*/ - - - -#include - - -int __cdecl main(int argc, char *argv[]) -{ - BOOL bTry = FALSE; - BOOL bExcept = FALSE; - BOOL bTestA = TRUE; - - if (0 != PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - /* - ** test to make sure we get into the exception block - */ - - PAL_TRY - { - if (!bTestA) - { - Fail("PAL_TRY_EXCEPT: ERROR ->" - " It appears the first try block was hit a second time.\n"); - } - bTry = TRUE; /* indicate we hit the PAL_TRY block */ - } - PAL_EXCEPT(EXCEPTION_EXECUTE_HANDLER) - { - bExcept = TRUE; /* indicate we hit the PAL_EXCEPT block */ - } - PAL_ENDTRY; - - if (!bTry) - { - Trace("PAL_TRY_EXCEPT: ERROR -> It appears the code in the PAL_TRY" - " block was not executed.\n"); - } - - if (bExcept) - { - Trace("PAL_TRY_EXCEPT: ERROR -> It appears the code in the first" - " PAL_EXCEPT block was executed even though no exceptions were " - "encountered.\n"); - } - - /* did we hit all the proper code blocks? */ - if(!bTry || bExcept) - { - Fail(""); - } - - - /* - ** test to make sure we skip the second exception block - */ - - bTry = FALSE; - bExcept = FALSE; - bTestA = FALSE; /* we are now going into the second block test */ - - - PAL_TRY - { - if (bTestA) - { - Fail("PAL_TRY_EXCEPT: ERROR -> It appears" - " the second try block was hit too early.\n"); - } - bTry = TRUE; /* indicate we hit the PAL_TRY block */ - } - PAL_EXCEPT(EXCEPTION_EXECUTE_HANDLER) - { - if (bTestA) - { - Fail("PAL_TRY_EXCEPT: ERROR -> It appears" - " the second except block was hit too early.\n"); - } - bExcept = TRUE; /* indicate we hit the PAL_TRY block */ - } - PAL_ENDTRY; - - if (!bTry) - { - Trace("PAL_TRY_EXCEPT: ERROR -> It appears the code in the second" - " PAL_TRY block was not executed.\n"); - } - - if (bExcept) - { - Trace("PAL_TRY_EXCEPT: ERROR -> It appears the code in the second" - " PAL_EXCEPT block was executed even though no exceptions were " - "encountered.\n"); - } - - /* did we hit all the proper code blocks? */ - if(!bTry || bExcept) - { - Fail("\n"); - } - - PAL_Terminate(); - return PASS; - -} diff --git a/src/pal/tests/palsuite/exception_handling/PAL_TRY_EXCEPT_EX/test2/testinfo.dat b/src/pal/tests/palsuite/exception_handling/PAL_TRY_EXCEPT_EX/test2/testinfo.dat deleted file mode 100644 index f71964da1..000000000 --- a/src/pal/tests/palsuite/exception_handling/PAL_TRY_EXCEPT_EX/test2/testinfo.dat +++ /dev/null @@ -1,15 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = exception_handling -Function = PAL_TRY and PAL_EXCEPT_EX (test 2) -Name = Test for PAL_TRY and PAL_EXCEPT_EX -Type = DEFAULT -EXE1 = pal_try_except_ex -LANG = cpp -Description -= Since these two are so closely connected, they are tested together. -= In this test, no exceptions are forced to ensure the EXCEPTION block -= isn't hit. Booleans are used to ensure the proper code blocks are hit. diff --git a/src/pal/tests/palsuite/exception_handling/PAL_TRY_EXCEPT_EX/test3/CMakeLists.txt b/src/pal/tests/palsuite/exception_handling/PAL_TRY_EXCEPT_EX/test3/CMakeLists.txt deleted file mode 100644 index d9507b046..000000000 --- a/src/pal/tests/palsuite/exception_handling/PAL_TRY_EXCEPT_EX/test3/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - PAL_TRY_EXCEPT_EX.cpp -) - -add_executable(paltest_pal_try_except_ex_test3 - ${SOURCES} -) - -add_dependencies(paltest_pal_try_except_ex_test3 coreclrpal) - -target_link_libraries(paltest_pal_try_except_ex_test3 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/exception_handling/PAL_TRY_EXCEPT_EX/test3/PAL_TRY_EXCEPT_EX.cpp b/src/pal/tests/palsuite/exception_handling/PAL_TRY_EXCEPT_EX/test3/PAL_TRY_EXCEPT_EX.cpp deleted file mode 100644 index d6a948926..000000000 --- a/src/pal/tests/palsuite/exception_handling/PAL_TRY_EXCEPT_EX/test3/PAL_TRY_EXCEPT_EX.cpp +++ /dev/null @@ -1,130 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: PAL_TRY_EXCEPT.c (test 3) -** -** Purpose: Tests the PAL implementation of the PAL_TRY and -** PAL_EXCEPT functions. Force an exception in only one block -** to ensure the proper exception block is hit. -** -** -**===================================================================*/ - - - -#include - - -int __cdecl main(int argc, char *argv[]) -{ - int* p = 0x00000000; /* NULL pointer */ - BOOL bTry = FALSE; - BOOL bExcept = FALSE; - BOOL bTestA = TRUE; - - if (0 != PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - /* - ** test to make sure we get into the exception block - */ - - PAL_TRY - { - if (!bTestA) - { - Fail("PAL_TRY_EXCEPT: ERROR ->" - " It appears the first try block was hit a second time.\n"); - } - bTry = TRUE; /* indicate we hit the PAL_TRY block */ - *p = 13; /* causes an access violation exception */ - Fail("PAL_TRY_EXCEPT: ERROR -> code was executed after the " - "access violation.\n"); - } - PAL_EXCEPT(EXCEPTION_EXECUTE_HANDLER) - { - if (!bTestA) - { - Fail("PAL_TRY_EXCEPT: ERROR ->" - " It appears the first except block was hit a second time.\n"); - } - bExcept = TRUE; /* indicate we hit the PAL_EXCEPT block */ - } - PAL_ENDTRY; - - if (!bTry) - { - Trace("PAL_TRY_EXCEPT: ERROR -> It appears the code in the PAL_TRY" - " block was not executed.\n"); - } - - if (!bExcept) - { - Trace("PAL_TRY_EXCEPT: ERROR -> It appears the code in the first" - " PAL_EXCEPT block was not executed.\n"); - } - - /* did we hit all the code blocks? */ - if(!bTry || !bExcept) - { - Fail("\n"); - } - - - /* - ** test to make sure we get into the second exception block - */ - - bTry = FALSE; - bExcept = FALSE; - bTestA = FALSE; /* we are now going into the second block test */ - - - PAL_TRY - { - if (bTestA) - { - Fail("PAL_TRY_EXCEPT: ERROR -> It appears" - " the second try block was hit too early.\n"); - } - bTry = TRUE; /* indicate we hit the PAL_TRY block */ - } - PAL_EXCEPT(EXCEPTION_EXECUTE_HANDLER) - { - if (bTestA) - { - Fail("PAL_TRY_EXCEPT: ERROR -> It appears" - " the second except block was hit too early.\n"); - } - bExcept = TRUE; /* indicate we hit the PAL_EXCEPT block */ - } - PAL_ENDTRY; - - if (!bTry) - { - Trace("PAL_TRY_EXCEPT: ERROR -> It appears the code in the second" - " PAL_TRY block was not executed.\n"); - } - - if (bExcept) - { - Trace("PAL_TRY_EXCEPT: ERROR -> It appears the code in the second " - " PAL_EXCEPT block was executed for some reason.\n"); - } - - /* did we hit all the correct code blocks? */ - if(!bTry || bExcept) - { - Fail("\n"); - } - - PAL_Terminate(); - return PASS; - -} diff --git a/src/pal/tests/palsuite/exception_handling/PAL_TRY_EXCEPT_EX/test3/testinfo.dat b/src/pal/tests/palsuite/exception_handling/PAL_TRY_EXCEPT_EX/test3/testinfo.dat deleted file mode 100644 index a24544708..000000000 --- a/src/pal/tests/palsuite/exception_handling/PAL_TRY_EXCEPT_EX/test3/testinfo.dat +++ /dev/null @@ -1,16 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = exception_handling -Function = PAL_TRY and PAL_EXCEPT_EX (test3) -Name = Test for PAL_TRY and PAL_EXCEPT_EX -Type = DEFAULT -EXE1 = pal_try_except_ex -LANG = cpp -Description -= Since these two are so closely connected, they are tested together. -= Only one of the PAL_TRY blocks will force and exception to ensure the -= correct PAL_EXCEPT_EX block is hit. Booleans are used to ensure -= the correct code blocks are hit. diff --git a/src/pal/tests/palsuite/exception_handling/PAL_TRY_LEAVE_FINALLY/CMakeLists.txt b/src/pal/tests/palsuite/exception_handling/PAL_TRY_LEAVE_FINALLY/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/exception_handling/PAL_TRY_LEAVE_FINALLY/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/exception_handling/PAL_TRY_LEAVE_FINALLY/test1/CMakeLists.txt b/src/pal/tests/palsuite/exception_handling/PAL_TRY_LEAVE_FINALLY/test1/CMakeLists.txt deleted file mode 100644 index 6b34c1d62..000000000 --- a/src/pal/tests/palsuite/exception_handling/PAL_TRY_LEAVE_FINALLY/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - PAL_TRY_LEAVE_FINALLY.cpp -) - -add_executable(paltest_pal_try_leave_finally_test1 - ${SOURCES} -) - -add_dependencies(paltest_pal_try_leave_finally_test1 coreclrpal) - -target_link_libraries(paltest_pal_try_leave_finally_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/exception_handling/PAL_TRY_LEAVE_FINALLY/test1/PAL_TRY_LEAVE_FINALLY.cpp b/src/pal/tests/palsuite/exception_handling/PAL_TRY_LEAVE_FINALLY/test1/PAL_TRY_LEAVE_FINALLY.cpp deleted file mode 100644 index 675c2a594..000000000 --- a/src/pal/tests/palsuite/exception_handling/PAL_TRY_LEAVE_FINALLY/test1/PAL_TRY_LEAVE_FINALLY.cpp +++ /dev/null @@ -1,77 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: pal_try_leave_finally.c -** -** Purpose: Tests the PAL implementation of the PAL_TRY, PAL_LEAVE -** and PAL_FINALLY functions. -** -** -**===================================================================*/ - - - -#include - - -int __cdecl main(int argc, char *argv[]) -{ - BOOL bTry = FALSE; - BOOL bFinally = FALSE; - BOOL bLeave = TRUE; - - if (0 != PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - PAL_TRY - { - bTry = TRUE; /* indicate we hit the PAL_TRY block */ - - goto Done; - - bLeave = FALSE; /* indicate we stuck around */ - Done: ; - } - PAL_FINALLY - { - bFinally = TRUE; /* indicate we hit the PAL_FINALLY block */ - } - PAL_ENDTRY; - - /* did we go where we were meant to go */ - if (!bTry) - { - Trace("PAL_TRY_FINALLY: ERROR -> It appears the code in the PAL_TRY" - " block was not executed.\n"); - } - - if (!bLeave) - { - Trace("PAL_TRY_FINALLY: ERROR -> It appears code was executed after " - "PAL_LEAVE was called. It should have jumped directly to the " - "PAL_FINALLY block.\n"); - } - - if (!bFinally) - { - Trace("PAL_TRY_FINALLY: ERROR -> It appears the code in the PAL_FINALLY" - " block was not executed.\n"); - } - - /* did we hit all the code blocks? */ - if(!bTry || !bLeave || !bFinally) - { - Fail(""); - } - - - PAL_Terminate(); - return PASS; - -} diff --git a/src/pal/tests/palsuite/exception_handling/PAL_TRY_LEAVE_FINALLY/test1/testinfo.dat b/src/pal/tests/palsuite/exception_handling/PAL_TRY_LEAVE_FINALLY/test1/testinfo.dat deleted file mode 100644 index 8a90ef392..000000000 --- a/src/pal/tests/palsuite/exception_handling/PAL_TRY_LEAVE_FINALLY/test1/testinfo.dat +++ /dev/null @@ -1,17 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = PAL_TRY, PAL_LEAVE and PAL_FINALLY -Name = Test for PAL_TRY, PAL_LEAVE and PAL_EXCEPT -Type = DEFAULT -EXE1 = pal_try_leave_finally -LANG = cpp -Description -= Since these three are so closely connected, they are tested together. -= The PAL_TRY block contains a PAL_LEAVE which kicks execution to -= the PAL_FINALLY block. Booleans are used to ensure each of the -= code blocks are properly hit. - diff --git a/src/pal/tests/palsuite/exception_handling/RaiseException/CMakeLists.txt b/src/pal/tests/palsuite/exception_handling/RaiseException/CMakeLists.txt deleted file mode 100644 index 1962ade35..000000000 --- a/src/pal/tests/palsuite/exception_handling/RaiseException/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) -add_subdirectory(test3) - diff --git a/src/pal/tests/palsuite/exception_handling/RaiseException/test1/CMakeLists.txt b/src/pal/tests/palsuite/exception_handling/RaiseException/test1/CMakeLists.txt deleted file mode 100644 index dcc47db93..000000000 --- a/src/pal/tests/palsuite/exception_handling/RaiseException/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_raiseexception_test1 - ${SOURCES} -) - -add_dependencies(paltest_raiseexception_test1 coreclrpal) - -target_link_libraries(paltest_raiseexception_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/exception_handling/RaiseException/test1/test1.cpp b/src/pal/tests/palsuite/exception_handling/RaiseException/test1/test1.cpp deleted file mode 100644 index 9130bc362..000000000 --- a/src/pal/tests/palsuite/exception_handling/RaiseException/test1/test1.cpp +++ /dev/null @@ -1,130 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: test1.c -** -** Purpose: Tests that RaiseException throws a catchable exception -** and Tests the behaviour of RaiseException with -** PAL_FINALLY -** -** -**============================================================*/ - - -#include - -BOOL bExcept = FALSE; -BOOL bTry = FALSE; -BOOL bFinally = FALSE; - -int __cdecl main(int argc, char *argv[]) -{ - - if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - /********************************************************* - * Tests that RaiseException throws a catchable exception - */ - PAL_TRY(VOID*, unused, NULL) - { - bTry = TRUE; - RaiseException(0,0,0,0); - - Fail("RaiseException: ERROR -> code was executed after the " - "exception was raised.\n"); - } - PAL_EXCEPT(EXCEPTION_EXECUTE_HANDLER) - { - bExcept = TRUE; - } - PAL_ENDTRY; - - if (!bTry) - { - Trace("RaiseException: ERROR -> It appears the code in the " - "PAL_TRY block was not executed.\n"); - } - - if (!bExcept) - { - Trace("RaiseException: ERROR -> It appears the code in the " - "PAL_EXCEPT_FILTER_EX block was not executed.\n"); - } - - /* did we hit all the code blocks? */ - if(!bTry || !bExcept) - { - Fail(""); - } - - /* Reinit flags */ - bTry = bExcept = FALSE; - - - /********************************************************* - * Tests the behaviour of RaiseException with - * PAL_FINALLY - * (bFinally should be set before bExcept) - */ - PAL_TRY(VOID*, unused, NULL) - { - PAL_TRY(VOID*, unused, NULL) - { - bTry = TRUE; - RaiseException(0,0,0,0); - - Fail("RaiseException: ERROR -> code was executed after the " - "exception was raised.\n"); - } - PAL_FINALLY - { - bFinally = TRUE; - } - PAL_ENDTRY; - } - PAL_EXCEPT(EXCEPTION_EXECUTE_HANDLER) - { - if( bFinally == FALSE ) - { - Fail("RaiseException: ERROR -> It appears the code in the " - "PAL_EXCEPT executed before the code in PAL_FINALLY.\n"); - } - - bExcept = TRUE; - } - - PAL_ENDTRY; - - if (!bTry) - { - Trace("RaiseException: ERROR -> It appears the code in the " - "PAL_TRY block was not executed.\n"); - } - - if (!bExcept) - { - Trace("RaiseException: ERROR -> It appears the code in the " - "PAL_EXCEPT block was not executed.\n"); - } - - if (!bFinally) - { - Trace("RaiseException: ERROR -> It appears the code in the " - "PAL_FINALLY block was not executed.\n"); - } - - /* did we hit all the code blocks? */ - if(!bTry || !bExcept || !bFinally) - { - Fail(""); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/exception_handling/RaiseException/test1/testinfo.dat b/src/pal/tests/palsuite/exception_handling/RaiseException/test1/testinfo.dat deleted file mode 100644 index 890b5efec..000000000 --- a/src/pal/tests/palsuite/exception_handling/RaiseException/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = exception_handling -Function = RaiseException -Name = RaiseException test #1 -TYPE = DEFAULT -EXE1 = test1 -LANG = cpp -Description -=Tests that RaiseException throws a catchable exception diff --git a/src/pal/tests/palsuite/exception_handling/RaiseException/test2/CMakeLists.txt b/src/pal/tests/palsuite/exception_handling/RaiseException/test2/CMakeLists.txt deleted file mode 100644 index 5c9ba2cee..000000000 --- a/src/pal/tests/palsuite/exception_handling/RaiseException/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test2.cpp -) - -add_executable(paltest_raiseexception_test2 - ${SOURCES} -) - -add_dependencies(paltest_raiseexception_test2 coreclrpal) - -target_link_libraries(paltest_raiseexception_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/exception_handling/RaiseException/test2/test2.cpp b/src/pal/tests/palsuite/exception_handling/RaiseException/test2/test2.cpp deleted file mode 100644 index f8db573ac..000000000 --- a/src/pal/tests/palsuite/exception_handling/RaiseException/test2/test2.cpp +++ /dev/null @@ -1,224 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: test2.c (exception_handling\raiseexception\test2) -** -** Purpose: Tests that the correct arguments are passed -** to the filter by RaiseException and tests that -** the number of arguments never exceeds -** EXCEPTION_MAXIMUM_PARAMETERS, even though we -** pass a greater number of arguments -** -** -**============================================================*/ - - -#include - -BOOL bFilter; -BOOL bTry; -BOOL bExcept; - -ULONG_PTR lpArguments_test1[EXCEPTION_MAXIMUM_PARAMETERS]; -DWORD nArguments_test1 = EXCEPTION_MAXIMUM_PARAMETERS; - -ULONG_PTR lpArguments_test2[EXCEPTION_MAXIMUM_PARAMETERS+1]; -DWORD nArguments_test2 = EXCEPTION_MAXIMUM_PARAMETERS+1; - - -/** -** -** Filter function that checks for the parameters -** -**/ -LONG Filter_test1(EXCEPTION_POINTERS* ep, VOID *unused) -{ - int i; - - /* let the main know we've hit the filter function */ - bFilter = TRUE; - - if (!bTry) - { - Fail("PAL_EXCEPT_FILTER_EX: ERROR -> Something weird is going on." - " The filter was hit without PAL_TRY being hit.\n"); - } - - - /* was the correct number of arguments passed */ - if (ep->ExceptionRecord->NumberParameters != (DWORD) nArguments_test1) - { - Fail("RaiseException: ERROR -> Number of arguments passed to filter" - " was %d when it should have been %d", - ep->ExceptionRecord->NumberParameters, - nArguments_test1); - - } - - /* were the correct arguments passed */ - for( i=0; ((DWORD)i)ExceptionRecord->ExceptionInformation[i] - != lpArguments_test1[i]) - { - Fail("RaiseException: ERROR -> Argument %d passed to filter" - " was %d when it should have been %d", - i, - ep->ExceptionRecord->ExceptionInformation[i], - lpArguments_test1[i]); - } - } - - return EXCEPTION_EXECUTE_HANDLER; -} - -/** -** -** Filter function that checks for the maximum parameters -** -**/ -LONG Filter_test2(EXCEPTION_POINTERS* ep, VOID* unused) -{ - /* let the main know we've hit the filter function */ - bFilter = TRUE; - - if (ep->ExceptionRecord->NumberParameters > EXCEPTION_MAXIMUM_PARAMETERS) - { - Fail("RaiseException: ERROR -> Number of arguments passed to filter" - " was %d which is greater than the maximum allowed of %d\n", - ep->ExceptionRecord->NumberParameters, - EXCEPTION_MAXIMUM_PARAMETERS); - } - - return EXCEPTION_EXECUTE_HANDLER; -} - -int __cdecl main(int argc, char *argv[]) -{ - bExcept = FALSE; - - if (0 != PAL_Initialize(argc, argv)) - { - return FAIL; - } - - /******************************************************** - * Test that the correct arguments are passed - * to the filter by RaiseException - */ - PAL_TRY(VOID*, unused, NULL) - { - bTry = TRUE; /* indicate we hit the PAL_TRY block */ - - /* Initialize arguments to pass to filter */ - for(int i = 0; ((DWORD)i) < nArguments_test1; i++ ) - { - lpArguments_test1[i] = i; - } - - RaiseException(0,0,nArguments_test1,lpArguments_test1); - - Fail("RaiseException: ERROR -> code was executed after the " - "exception was raised.\n"); - } - PAL_EXCEPT_FILTER(Filter_test1) - { - if (!bTry) - { - Fail("RaiseException: ERROR -> Something weird is going on." - " PAL_EXCEPT_FILTER was hit without PAL_TRY being hit.\n"); - } - bExcept = TRUE; /* indicate we hit the PAL_EXCEPT_FILTER_EX block */ - } - PAL_ENDTRY; - - if (!bTry) - { - Trace("RaiseException: ERROR -> It appears the code in the " - "PAL_TRY block was not executed.\n"); - } - - if (!bExcept) - { - Trace("RaiseException: ERROR -> It appears the code in the " - "PAL_EXCEPT_FILTER_EX block was not executed.\n"); - } - - if (!bFilter) - { - Trace("RaiseException: ERROR -> It appears the code in the" - " filter function was not executed.\n"); - } - - /* did we hit all the code blocks? */ - if(!bTry || !bExcept || !bFilter) - { - Fail(""); - } - - - /* Reinit flags */ - bTry = bExcept = bFilter = FALSE; - - /******************************************************** - * Test that the number of arguments never - * exceeds EXCEPTION_MAXIMUM_PARAMETERS, even though we - * pass a greater number of arguments - */ - PAL_TRY(VOID*, unused, NULL) - { - bTry = TRUE; /* indicate we hit the PAL_TRY block */ - - /* Initialize arguments to pass to filter */ - for(int i = 0; ((DWORD)i) < nArguments_test2; i++ ) - { - lpArguments_test2[i] = i; - } - - RaiseException(0,0,nArguments_test2,lpArguments_test2); - - Fail("RaiseException: ERROR -> code was executed after the " - "exception was raised.\n"); - } - PAL_EXCEPT_FILTER(Filter_test2) - { - if (!bTry) - { - Fail("RaiseException: ERROR -> Something weird is going on." - " PAL_EXCEPT_FILTER was hit without PAL_TRY being hit.\n"); - } - bExcept = TRUE; /* indicate we hit the PAL_EXCEPT_FILTER_EX block */ - } - PAL_ENDTRY; - - if (!bTry) - { - Trace("RaiseException: ERROR -> It appears the code in the " - "PAL_TRY block was not executed.\n"); - } - - if (!bExcept) - { - Trace("RaiseException: ERROR -> It appears the code in the " - "PAL_EXCEPT_FILTER_EX block was not executed.\n"); - } - - if (!bFilter) - { - Trace("RaiseException: ERROR -> It appears the code in the" - " filter function was not executed.\n"); - } - - /* did we hit all the code blocks? */ - if(!bTry || !bExcept || !bFilter) - { - Fail(""); - } - - PAL_Terminate(); - return PASS; - -} diff --git a/src/pal/tests/palsuite/exception_handling/RaiseException/test2/testinfo.dat b/src/pal/tests/palsuite/exception_handling/RaiseException/test2/testinfo.dat deleted file mode 100644 index ce85e67ac..000000000 --- a/src/pal/tests/palsuite/exception_handling/RaiseException/test2/testinfo.dat +++ /dev/null @@ -1,28 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 - -Section = exception_handling - -Function = RaiseException - -Name = RaiseException test #2 - -TYPE = DEFAULT - -EXE1 = test2 -LANG = cpp - -Description - -=Tests that the correct arguments are passed - -=to the filter by RaiseException and tests that - -=the number of arguments never exceeds - -=EXCEPTION_MAXIMUM_PARAMETERS, even though we - -=pass a greater number of arguments diff --git a/src/pal/tests/palsuite/exception_handling/RaiseException/test3/CMakeLists.txt b/src/pal/tests/palsuite/exception_handling/RaiseException/test3/CMakeLists.txt deleted file mode 100644 index a16f832a4..000000000 --- a/src/pal/tests/palsuite/exception_handling/RaiseException/test3/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test.cpp -) - -add_executable(paltest_raiseexception_test3 - ${SOURCES} -) - -add_dependencies(paltest_raiseexception_test3 coreclrpal) - -target_link_libraries(paltest_raiseexception_test3 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/exception_handling/RaiseException/test3/test.cpp b/src/pal/tests/palsuite/exception_handling/RaiseException/test3/test.cpp deleted file mode 100644 index 5278ad177..000000000 --- a/src/pal/tests/palsuite/exception_handling/RaiseException/test3/test.cpp +++ /dev/null @@ -1,115 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: test.c (exception_handling\raiseexception\test3) -** -** Purpose: Tests that the correct ExceptionCode is passed -** to the filter by RaiseException -** -** -**============================================================*/ - - -#include - -BOOL bFilter = FALSE; -BOOL bTry = FALSE; -BOOL bExcept = FALSE; - -/** -** -** Filter function that checks for the parameters -** -**/ -LONG Filter_test1(EXCEPTION_POINTERS* ep, VOID* unused) -{ - /* let the main know we've hit the filter function */ - bFilter = TRUE; - - if (!bTry) - { - Fail("PAL_EXCEPT_FILTER_EX: ERROR -> Something weird is going on." - " The filter was hit without PAL_TRY being hit.\n"); - } - - - /* was the correct exception code passed? */ - if (ep->ExceptionRecord->ExceptionCode != EXCEPTION_ARRAY_BOUNDS_EXCEEDED) - { - Fail("RaiseException: ERROR -> ep->ExceptionRecord->ExceptionCode" - " was %x when it was expected to be %x\n", - ep->ExceptionRecord->ExceptionCode, - EXCEPTION_ARRAY_BOUNDS_EXCEEDED); - - } - - return EXCEPTION_EXECUTE_HANDLER; -} - -int __cdecl main(int argc, char *argv[]) -{ - bExcept = FALSE; - - if (0 != PAL_Initialize(argc, argv)) - { - return FAIL; - } - - /******************************************************** - * Test that the correct arguments are passed - * to the filter by RaiseException - */ - PAL_TRY(VOID*, unused, NULL) - { - bTry = TRUE; /* indicate we hit the PAL_TRY block */ - - RaiseException(EXCEPTION_ARRAY_BOUNDS_EXCEEDED, - 0, - 0,NULL); - - Fail("RaiseException: ERROR -> code was executed after the " - "exception was raised.\n"); - } - PAL_EXCEPT_FILTER(Filter_test1) - { - if (!bTry) - { - Fail("RaiseException: ERROR -> Something weird is going on." - " PAL_EXCEPT_FILTER was hit without PAL_TRY being hit.\n"); - } - bExcept = TRUE; /* indicate we hit the PAL_EXCEPT_FILTER_EX block */ - } - PAL_ENDTRY; - - if (!bTry) - { - Trace("RaiseException: ERROR -> It appears the code in the " - "PAL_TRY block was not executed.\n"); - } - - if (!bExcept) - { - Trace("RaiseException: ERROR -> It appears the code in the " - "PAL_EXCEPT_FILTER_EX block was not executed.\n"); - } - - if (!bFilter) - { - Trace("RaiseException: ERROR -> It appears the code in the" - " filter function was not executed.\n"); - } - - /* did we hit all the code blocks? */ - if(!bTry || !bExcept || !bFilter) - { - Fail(""); - } - - - PAL_Terminate(); - return PASS; - -} diff --git a/src/pal/tests/palsuite/exception_handling/RaiseException/test3/testinfo.dat b/src/pal/tests/palsuite/exception_handling/RaiseException/test3/testinfo.dat deleted file mode 100644 index 12a56f0ef..000000000 --- a/src/pal/tests/palsuite/exception_handling/RaiseException/test3/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = exception_handling -Function = RaiseException -Name = RaiseException test #3 -TYPE = DEFAULT -EXE1 = test -LANG = cpp -Description -= Tests that the exception code passed to -= RaiseException makes it to the filter. diff --git a/src/pal/tests/palsuite/exception_handling/SetUnhandledExceptionFilter/CMakeLists.txt b/src/pal/tests/palsuite/exception_handling/SetUnhandledExceptionFilter/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/exception_handling/SetUnhandledExceptionFilter/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/exception_handling/SetUnhandledExceptionFilter/test1/CMakeLists.txt b/src/pal/tests/palsuite/exception_handling/SetUnhandledExceptionFilter/test1/CMakeLists.txt deleted file mode 100644 index bff5e893e..000000000 --- a/src/pal/tests/palsuite/exception_handling/SetUnhandledExceptionFilter/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_setunhandledexceptionfilter_test1 - ${SOURCES} -) - -add_dependencies(paltest_setunhandledexceptionfilter_test1 coreclrpal) - -target_link_libraries(paltest_setunhandledexceptionfilter_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/exception_handling/SetUnhandledExceptionFilter/test1/test1.cpp b/src/pal/tests/palsuite/exception_handling/SetUnhandledExceptionFilter/test1/test1.cpp deleted file mode 100644 index 5a067f935..000000000 --- a/src/pal/tests/palsuite/exception_handling/SetUnhandledExceptionFilter/test1/test1.cpp +++ /dev/null @@ -1,82 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: test1.c -** -** Purpose: Sets up a new unhandled exception filter, and makes sure it -** returns the previous filter. Raises an unhandled exception and -** makes sure this reaches the filter. -** -** -**============================================================*/ - - -#include - -/* This isn't defined in the pal, so copied from win32 */ -#define EXCEPTION_EXECUTE_HANDLER 1 -#define EXCEPTION_CONTINUE_EXECUTION -1 - - -int InFilter = FALSE; - -LONG PALAPI FirstFilter(LPEXCEPTION_POINTERS p) -{ - return EXCEPTION_EXECUTE_HANDLER; -} - -LONG PALAPI ContinueFilter(LPEXCEPTION_POINTERS p) -{ - InFilter = TRUE; - - Trace("This test has succeeded as far at the automated checks can " - "tell. Manual verification is now required to be completely sure.\n"); - Trace("Now the PAL's handling of application errors will be tested " - "with an exception code of %u.\n", - p->ExceptionRecord->ExceptionCode); - Trace("Please verify that the actions that the PAL now takes are " - "as specified for it.\n"); - - return EXCEPTION_CONTINUE_SEARCH; -} - -int __cdecl main(int argc, char *argv[]) -{ - LPTOP_LEVEL_EXCEPTION_FILTER OldFilter; - - if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - - SetUnhandledExceptionFilter(FirstFilter); - - OldFilter = SetUnhandledExceptionFilter(ContinueFilter); - if (OldFilter != FirstFilter) - { - Fail("SetUnhandledExceptionFilter did not return a pointer to the " - "previous filter!\n"); - } - - /* - * Raise an unhandled exception. This should cause our filter to be - * excecuted and the program to exit with a code the same as the - * exception code. - */ - RaiseException(3,0,0,0); - - - /* - * This code should not be executed because the toplevelhandler is - * expected to "just" set the exit code and abend the program - */ - Fail("An unhandled exception did not cause the program to abend with" - "the exit code == the ExceptionCode!\n"); - - PAL_Terminate(); - return FAIL; -} diff --git a/src/pal/tests/palsuite/exception_handling/SetUnhandledExceptionFilter/test1/testinfo.dat b/src/pal/tests/palsuite/exception_handling/SetUnhandledExceptionFilter/test1/testinfo.dat deleted file mode 100644 index 2af29a299..000000000 --- a/src/pal/tests/palsuite/exception_handling/SetUnhandledExceptionFilter/test1/testinfo.dat +++ /dev/null @@ -1,15 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = exception_handling -Function = SetUnhandledExceptionFilter -Name = SetUnhandledExceptionFilter test #1 -TYPE = DEFAULT -EXE1 = test1 -LANG = cpp -Description -=Sets up a new unhandled exception filter, and makes sure it -=returns the previous filter. Raises an unhandled exception and -=makes sure this reaches the filter. diff --git a/src/pal/tests/palsuite/exception_handling/pal_except/CMakeLists.txt b/src/pal/tests/palsuite/exception_handling/pal_except/CMakeLists.txt deleted file mode 100644 index 19ee487a6..000000000 --- a/src/pal/tests/palsuite/exception_handling/pal_except/CMakeLists.txt +++ /dev/null @@ -1,10 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) -add_subdirectory(test3) -add_subdirectory(test4) -add_subdirectory(test5) -add_subdirectory(test6) -add_subdirectory(test7) - diff --git a/src/pal/tests/palsuite/exception_handling/pal_except/test1/CMakeLists.txt b/src/pal/tests/palsuite/exception_handling/pal_except/test1/CMakeLists.txt deleted file mode 100644 index a34f67330..000000000 --- a/src/pal/tests/palsuite/exception_handling/pal_except/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_pal_except_test1 - ${SOURCES} -) - -add_dependencies(paltest_pal_except_test1 coreclrpal) - -target_link_libraries(paltest_pal_except_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/exception_handling/pal_except/test1/test1.cpp b/src/pal/tests/palsuite/exception_handling/pal_except/test1/test1.cpp deleted file mode 100644 index 0fe48e7fc..000000000 --- a/src/pal/tests/palsuite/exception_handling/pal_except/test1/test1.cpp +++ /dev/null @@ -1,67 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test1.c (exception_handling\pal_except\test1) -** -** Purpose: Test to make sure the PAL_EXCEPT block is executed -** after an exception occurs in the PAL_TRY block -** -** -**===================================================================*/ -#include - -/* Execution flags */ -BOOL bTry = FALSE; -BOOL bExcept = FALSE; - -int __cdecl main(int argc, char *argv[]) -{ - if (0 != PAL_Initialize(argc, argv)) - { - return FAIL; - } - - PAL_TRY - { - int* p = 0x00000000; /* NULL pointer */ - - bTry = TRUE; /* indicate we hit the PAL_TRY block */ - *p = 13; /* causes an access violation exception */ - - Fail("ERROR: code was executed after the access violation.\n"); - } - PAL_EXCEPT(EXCEPTION_EXECUTE_HANDLER) - { - if (!bTry) - { - Fail("ERROR: PAL_EXCEPT was hit without PAL_TRY being hit.\n"); - } - - bExcept = TRUE; /* indicate we hit the PAL_EXCEPT block */ - } - PAL_ENDTRY; - - if (!bTry) - { - Trace("ERROR: the code in the PAL_TRY block was not executed.\n"); - } - - if (!bExcept) - { - Trace("ERROR: the code in the PAL_EXCEPT block was not executed.\n"); - } - - /* did we hit all the code blocks? */ - if(!bTry || !bExcept) - { - Fail(""); - } - - - PAL_Terminate(); - return PASS; - -} diff --git a/src/pal/tests/palsuite/exception_handling/pal_except/test1/testinfo.dat b/src/pal/tests/palsuite/exception_handling/pal_except/test1/testinfo.dat deleted file mode 100644 index 246553a9c..000000000 --- a/src/pal/tests/palsuite/exception_handling/pal_except/test1/testinfo.dat +++ /dev/null @@ -1,23 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 - -Section = exception_handling - -Function = PAL_TRY and PAL_EXCEPT - -Name = Test for PAL_TRY and PAL_EXCEPT - -Type = DEFAULT - -EXE1 = test1 - -LANG = cpp - -Description - -= Test to make sure the PAL_EXCEPT block is executed - -= after an exception occurs in the PAL_TRY block diff --git a/src/pal/tests/palsuite/exception_handling/pal_except/test2/CMakeLists.txt b/src/pal/tests/palsuite/exception_handling/pal_except/test2/CMakeLists.txt deleted file mode 100644 index a40910eca..000000000 --- a/src/pal/tests/palsuite/exception_handling/pal_except/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test2.cpp -) - -add_executable(paltest_pal_except_test2 - ${SOURCES} -) - -add_dependencies(paltest_pal_except_test2 coreclrpal) - -target_link_libraries(paltest_pal_except_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/exception_handling/pal_except/test2/test2.cpp b/src/pal/tests/palsuite/exception_handling/pal_except/test2/test2.cpp deleted file mode 100644 index bc0d4e300..000000000 --- a/src/pal/tests/palsuite/exception_handling/pal_except/test2/test2.cpp +++ /dev/null @@ -1,111 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test2.c (exception_handling\pal_except\test2) -** -** Purpose: Test to make sure the PAL_EXCEPT block is executed -** after an exception occurs in the PAL_TRY block -** that contains another PAL_TRY-PAL_EXCEPT block -** -** -**===================================================================*/ -#include - -/* Execution flags */ -BOOL bTry = FALSE; -BOOL bExcept = FALSE; -BOOL bTry_nested = FALSE; -BOOL bExcept_nested = FALSE; - -int __cdecl main(int argc, char *argv[]) -{ - if (0 != PAL_Initialize(argc, argv)) - { - return FAIL; - } - - PAL_TRY - { - int* p = 0x00000000; /* NULL pointer */ - - bTry = TRUE; /* indicate we hit the PAL_TRY block */ - - - /* Nested PAL_TRY */ - PAL_TRY - { - bTry_nested = TRUE; - - *p = 13; /* causes an access violation exception */ - - Fail("ERROR: code was executed after the nested access violation.\n"); - - } - PAL_EXCEPT(EXCEPTION_EXECUTE_HANDLER) - { - if (!bTry) - { - Fail("ERROR: Nested PAL_EXCEPT was hit without " - "nested PAL_TRY being hit.\n"); - } - bExcept_nested = TRUE; - } - PAL_ENDTRY; - - *p = 13; /* causes an access violation exception */ - - Fail("ERROR: code was executed after the access violation.\n"); - } - PAL_EXCEPT(EXCEPTION_EXECUTE_HANDLER) - { - if (!bTry) - { - Fail("ERROR: PAL_EXCEPT was hit without PAL_TRY being hit.\n"); - } - if (!bExcept_nested) - { - Fail("ERROR: PAL_EXCEPT was hit without " - "nested PAL_EXCEPT being hit.\n"); - } - - bExcept = TRUE; /* indicate we hit the PAL_EXCEPT block */ - } - PAL_ENDTRY; - - if (!bTry) - { - Trace("ERROR: the code in the PAL_TRY block was not executed.\n"); - } - - if (!bExcept) - { - Trace("ERROR: the code in the PAL_EXCEPT block was not executed.\n"); - } - - if (!bTry_nested) - { - Trace("ERROR: the code in the " - "nested PAL_TRY block was not executed.\n"); - } - - if (!bExcept_nested) - { - Trace("ERROR: the code in the " - "nested PAL_EXCEPT block was not executed.\n"); - } - - /* did we hit all the code blocks? */ - if(!bTry || !bExcept || - !bTry_nested || !bExcept_nested) - { - Fail(""); - } - - - PAL_Terminate(); - return PASS; - -} diff --git a/src/pal/tests/palsuite/exception_handling/pal_except/test2/testinfo.dat b/src/pal/tests/palsuite/exception_handling/pal_except/test2/testinfo.dat deleted file mode 100644 index 39a628b16..000000000 --- a/src/pal/tests/palsuite/exception_handling/pal_except/test2/testinfo.dat +++ /dev/null @@ -1,25 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 - -Section = exception_handling - -Function = PAL_TRY and PAL_EXCEPT_EX - -Name = Test for PAL_TRY and PAL_EXCEPT_EX - -Type = DEFAULT - -EXE1 = test2 - -LANG = cpp - -Description - -= Test to make sure the PAL_EXCEPT_EX block is executed - -= after an exception occurs in the PAL_TRY block - -= that contains another PAL_TRY-PAL_EXCEPT_EX block diff --git a/src/pal/tests/palsuite/exception_handling/pal_except/test3/CMakeLists.txt b/src/pal/tests/palsuite/exception_handling/pal_except/test3/CMakeLists.txt deleted file mode 100644 index 6f9e100fb..000000000 --- a/src/pal/tests/palsuite/exception_handling/pal_except/test3/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test3.cpp -) - -add_executable(paltest_pal_except_test3 - ${SOURCES} -) - -add_dependencies(paltest_pal_except_test3 coreclrpal) - -target_link_libraries(paltest_pal_except_test3 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/exception_handling/pal_except/test3/test3.cpp b/src/pal/tests/palsuite/exception_handling/pal_except/test3/test3.cpp deleted file mode 100644 index 013769777..000000000 --- a/src/pal/tests/palsuite/exception_handling/pal_except/test3/test3.cpp +++ /dev/null @@ -1,120 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test3.c (exception_handling\pal_except\test3) -** -** Purpose: Test to make sure the PAL_EXCEPT block is executed -** after an exception occurs in the PAL_TRY block -** that calls a function that contains -** another PAL_TRY-PAL_EXCEPT block -** -** -**===================================================================*/ -#include - -/* Execution flags */ -BOOL bTry = FALSE; -BOOL bExcept = FALSE; -BOOL bTry_function = FALSE; -BOOL bExcept_function = FALSE; - -/* - * Helper function that contains a PAL_TRY-PAL_EXCEPT block - */ -void Helper() -{ - /* Nested PAL_TRY */ - PAL_TRY - { - int *lp = 0x00000000; - - bTry_function = TRUE; - - *lp = 13; /* causes an access violation exception */ - - Fail("ERROR: code was executed after the function's access violation.\n"); - - } - PAL_EXCEPT(EXCEPTION_EXECUTE_HANDLER) - { - if (!bTry) - { - Fail("ERROR: Nested PAL_EXCEPT was hit without " - "the function's PAL_TRY being hit.\n"); - } - bExcept_function = TRUE; - } - PAL_ENDTRY; -} - -int __cdecl main(int argc, char *argv[]) -{ - if (0 != PAL_Initialize(argc, argv)) - { - return FAIL; - } - - PAL_TRY - { - int* p = 0x00000000; /* NULL pointer */ - - bTry = TRUE; /* indicate we hit the PAL_TRY block */ - - Helper(); - - *p = 13; /* causes an access violation exception */ - - Fail("ERROR: code was executed after the access violation.\n"); - } - PAL_EXCEPT(EXCEPTION_EXECUTE_HANDLER) - { - if (!bTry) - { - Fail("ERROR: PAL_EXCEPT was hit without PAL_TRY being hit.\n"); - } - if (!bExcept_function) - { - Fail("ERROR: PAL_EXCEPT was hit without " - "function's PAL_EXCEPT being hit.\n"); - } - - bExcept = TRUE; /* indicate we hit the PAL_EXCEPT block */ - } - PAL_ENDTRY; - - if (!bTry) - { - Trace("ERROR: the code in the PAL_TRY block was not executed.\n"); - } - - if (!bExcept) - { - Trace("ERROR: the code in the PAL_EXCEPT block was not executed.\n"); - } - - if (!bTry_function) - { - Trace("ERROR: the code in the " - "function's PAL_TRY block was not executed.\n"); - } - - if (!bExcept_function) - { - Trace("ERROR: the code in the " - "function's PAL_EXCEPT block was not executed.\n"); - } - - /* did we hit all the code blocks? */ - if(!bTry || !bExcept || - !bTry_function || !bExcept_function) - { - Fail(""); - } - - PAL_Terminate(); - return PASS; - -} diff --git a/src/pal/tests/palsuite/exception_handling/pal_except/test3/testinfo.dat b/src/pal/tests/palsuite/exception_handling/pal_except/test3/testinfo.dat deleted file mode 100644 index 07da444a5..000000000 --- a/src/pal/tests/palsuite/exception_handling/pal_except/test3/testinfo.dat +++ /dev/null @@ -1,27 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 - -Section = exception_handling - -Function = PAL_TRY and PAL_EXCEPT - -Name = Test for PAL_TRY and PAL_EXCEPT - -Type = DEFAULT - -EXE1 = test3 - -LANG = cpp - -Description - -= Test to make sure the PAL_EXCEPT block is executed - -= after an exception occurs in the PAL_TRY block - -= that calls a function that contains - -= another PAL_TRY-PAL_EXCEPT block diff --git a/src/pal/tests/palsuite/exception_handling/pal_except/test4/CMakeLists.txt b/src/pal/tests/palsuite/exception_handling/pal_except/test4/CMakeLists.txt deleted file mode 100644 index fb51d9890..000000000 --- a/src/pal/tests/palsuite/exception_handling/pal_except/test4/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test4.cpp -) - -add_executable(paltest_pal_except_test4 - ${SOURCES} -) - -add_dependencies(paltest_pal_except_test4 coreclrpal) - -target_link_libraries(paltest_pal_except_test4 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/exception_handling/pal_except/test4/test4.cpp b/src/pal/tests/palsuite/exception_handling/pal_except/test4/test4.cpp deleted file mode 100644 index 87844973b..000000000 --- a/src/pal/tests/palsuite/exception_handling/pal_except/test4/test4.cpp +++ /dev/null @@ -1,105 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test4.c (exception_handling\pal_except\test4) -** -** Purpose: Test to make sure the PAL_EXCEPT block is executed -** after an exception occurs in the PAL_TRY block -** if the PAL_EXCEPT block contains a nested -** PAL_TRY-PAL_EXCEPT block -** -** -**===================================================================*/ -#include - -/* Execution flags */ -BOOL bTry = FALSE; -BOOL bExcept = FALSE; -BOOL bTry_nested = FALSE; -BOOL bExcept_nested = FALSE; - -int __cdecl main(int argc, char *argv[]) -{ - if (0 != PAL_Initialize(argc, argv)) - { - return FAIL; - } - - PAL_TRY - { - int* p = 0x00000000; /* NULL pointer */ - - bTry = TRUE; /* indicate we hit the PAL_TRY block */ - *p = 13; /* causes an access violation exception */ - - Fail("ERROR: code was executed after the access violation.\n"); - } - PAL_EXCEPT(EXCEPTION_EXECUTE_HANDLER) - { - if (!bTry) - { - Fail("ERROR: PAL_EXCEPT was hit without PAL_TRY being hit.\n"); - } - - PAL_TRY - { - int *lp = 0x00000000; - - bTry_nested = TRUE; - *lp = 13; /* causes an access violation exception */ - - Fail("ERROR: code was executed after the " - "nested access violation.\n"); - } - PAL_EXCEPT(EXCEPTION_EXECUTE_HANDLER) - { - if (!bTry_nested) - { - Fail("ERROR: PAL_EXCEPT was hit without PAL_TRY being hit " - "in the nested block.\n"); - } - bExcept_nested = TRUE; - } - PAL_ENDTRY; - - bExcept = TRUE; /* indicate we hit the PAL_EXCEPT block */ - } - PAL_ENDTRY; - - if (!bTry) - { - Trace("ERROR: the code in the PAL_TRY block was not executed.\n"); - } - - if (!bExcept) - { - Trace("ERROR: the code in the PAL_EXCEPT block was not executed.\n"); - } - - if (!bTry_nested) - { - Trace("ERROR: the code in the nested " - "PAL_TRY block was not executed.\n"); - } - - if (!bExcept_nested) - { - Trace("ERROR: the code in the nested " - "PAL_EXCEPT block was not executed.\n"); - } - - /* did we hit all the code blocks? */ - if(!bTry || !bExcept || - !bTry_nested || !bExcept_nested) - { - Fail(""); - } - - - PAL_Terminate(); - return PASS; - -} diff --git a/src/pal/tests/palsuite/exception_handling/pal_except/test4/testinfo.dat b/src/pal/tests/palsuite/exception_handling/pal_except/test4/testinfo.dat deleted file mode 100644 index d658cc85f..000000000 --- a/src/pal/tests/palsuite/exception_handling/pal_except/test4/testinfo.dat +++ /dev/null @@ -1,27 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 - -Section = exception_handling - -Function = PAL_TRY and PAL_EXCEPT - -Name = Test for PAL_TRY and PAL_EXCEPT - -Type = DEFAULT - -EXE1 = test4 - -LANG = cpp - -Description - -= Test to make sure the PAL_EXCEPT block is executed - -= after an exception occurs in the PAL_TRY block - -= if the PAL_EXCEPT block contains a nested - -= PAL_TRY-PAL_EXCEPT block diff --git a/src/pal/tests/palsuite/exception_handling/pal_except/test5/CMakeLists.txt b/src/pal/tests/palsuite/exception_handling/pal_except/test5/CMakeLists.txt deleted file mode 100644 index 4ec8c6995..000000000 --- a/src/pal/tests/palsuite/exception_handling/pal_except/test5/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test5.cpp -) - -add_executable(paltest_pal_except_test5 - ${SOURCES} -) - -add_dependencies(paltest_pal_except_test5 coreclrpal) - -target_link_libraries(paltest_pal_except_test5 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/exception_handling/pal_except/test5/test5.cpp b/src/pal/tests/palsuite/exception_handling/pal_except/test5/test5.cpp deleted file mode 100644 index f9faf4440..000000000 --- a/src/pal/tests/palsuite/exception_handling/pal_except/test5/test5.cpp +++ /dev/null @@ -1,112 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test5.c (exception_handling\pal_except\test5) -** -** Purpose: Test to make sure the PAL_EXCEPT block is executed -** after an exception occurs in the PAL_TRY block -** if the PAL_EXCEPT block calls a function that contains -** another PAL_TRY-PAL_EXCEPT block -** -** -**===================================================================*/ -#include - -/* Execution flags */ -BOOL bTry = FALSE; -BOOL bExcept = FALSE; -BOOL bTry_nested = FALSE; -BOOL bExcept_nested = FALSE; - -int __cdecl main(int argc, char *argv[]) -{ - if (0 != PAL_Initialize(argc, argv)) - { - return FAIL; - } - - PAL_TRY - { - int* p = 0x00000000; /* NULL pointer */ - - bTry = TRUE; /* indicate we hit the PAL_TRY block */ - - - /* Nested PAL_TRY */ - PAL_TRY - { - bTry_nested = TRUE; - - *p = 13; /* causes an access violation exception */ - - Fail("ERROR: code was executed after the nested access violation.\n"); - - } - PAL_EXCEPT(EXCEPTION_EXECUTE_HANDLER) - { - if (!bTry) - { - Fail("ERROR: Nested PAL_EXCEPT was hit without " - "nested PAL_TRY being hit.\n"); - } - bExcept_nested = TRUE; - } - PAL_ENDTRY; - - *p = 13; /* causes an access violation exception */ - - Fail("ERROR: code was executed after the access violation.\n"); - } - PAL_EXCEPT(EXCEPTION_EXECUTE_HANDLER) - { - if (!bTry) - { - Fail("ERROR: PAL_EXCEPT was hit without PAL_TRY being hit.\n"); - } - if (!bExcept_nested) - { - Fail("ERROR: PAL_EXCEPT was hit without " - "nested PAL_EXCEPT being hit.\n"); - } - - bExcept = TRUE; /* indicate we hit the PAL_EXCEPT block */ - } - PAL_ENDTRY; - - if (!bTry) - { - Trace("ERROR: the code in the PAL_TRY block was not executed.\n"); - } - - if (!bExcept) - { - Trace("ERROR: the code in the PAL_EXCEPT block was not executed.\n"); - } - - if (!bTry_nested) - { - Trace("ERROR: the code in the " - "nested PAL_TRY block was not executed.\n"); - } - - if (!bExcept_nested) - { - Trace("ERROR: the code in the " - "nested PAL_EXCEPT block was not executed.\n"); - } - - /* did we hit all the code blocks? */ - if(!bTry || !bExcept || - !bTry_nested || !bExcept_nested) - { - Fail(""); - } - - - PAL_Terminate(); - return PASS; - -} diff --git a/src/pal/tests/palsuite/exception_handling/pal_except/test5/testinfo.dat b/src/pal/tests/palsuite/exception_handling/pal_except/test5/testinfo.dat deleted file mode 100644 index 2e12d0c64..000000000 --- a/src/pal/tests/palsuite/exception_handling/pal_except/test5/testinfo.dat +++ /dev/null @@ -1,27 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 - -Section = exception_handling - -Function = PAL_TRY and PAL_EXCEPT - -Name = Test for PAL_TRY and PAL_EXCEPT - -Type = DEFAULT - -EXE1 = test5 - -LANG = cpp - -Description - -= Test to make sure the PAL_EXCEPT block is executed - -= after an exception occurs in the PAL_TRY block - -= if the PAL_EXCEPT block calls a function that contains - -= another PAL_TRY-PAL_EXCEPT block diff --git a/src/pal/tests/palsuite/exception_handling/pal_except/test6/CMakeLists.txt b/src/pal/tests/palsuite/exception_handling/pal_except/test6/CMakeLists.txt deleted file mode 100644 index bc1742c17..000000000 --- a/src/pal/tests/palsuite/exception_handling/pal_except/test6/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test6.cpp -) - -add_executable(paltest_pal_except_test6 - ${SOURCES} -) - -add_dependencies(paltest_pal_except_test6 coreclrpal) - -target_link_libraries(paltest_pal_except_test6 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/exception_handling/pal_except/test6/test6.cpp b/src/pal/tests/palsuite/exception_handling/pal_except/test6/test6.cpp deleted file mode 100644 index 44b0ba1bc..000000000 --- a/src/pal/tests/palsuite/exception_handling/pal_except/test6/test6.cpp +++ /dev/null @@ -1,160 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test6.c (exception_handling\pal_except\test6) -** -** Purpose: Test to make sure the PAL_EXCEPT block is executed -** after an exception occurs in the PAL_TRY block -** that contains multiple PAL_TRY-PAL_EXCEPT blocks -** -** -**===================================================================*/ -#include - -/* Execution flags */ -BOOL bTry = FALSE; -BOOL bExcept = FALSE; -BOOL bTry_nested = FALSE; -BOOL bExcept_nested = FALSE; -BOOL bTry_nested2 = FALSE; -BOOL bExcept_nested2 = FALSE; - - -int __cdecl main(int argc, char *argv[]) -{ - if (0 != PAL_Initialize(argc, argv)) - { - return FAIL; - } - - /* First block */ - PAL_TRY - { - int* p = 0x00000000; /* NULL pointer */ - - bTry = TRUE; /* indicate we hit the PAL_TRY block */ - - /* Second PAL_TRY block */ - PAL_TRY - { - bTry_nested = TRUE; - - /* Third PAL_TRY block*/ - PAL_TRY - { - bTry_nested2 = TRUE; - - *p = 13; /* causes an access violation exception */ - - Fail("ERROR: code was executed after the nested access violation.\n"); - - } - PAL_EXCEPT(EXCEPTION_EXECUTE_HANDLER) - { - if (!bTry_nested2) - { - Fail("ERROR: Third PAL_EXCEPT was hit without " - "third PAL_TRY being hit.\n"); - } - bExcept_nested2 = TRUE; - } - PAL_ENDTRY; - - *p = 13; /* causes an access violation exception */ - - Fail("ERROR: code was executed after the nested access violation.\n"); - - } - PAL_EXCEPT(EXCEPTION_EXECUTE_HANDLER) - { - if (!bTry_nested) - { - Fail("ERROR: Second PAL_EXCEPT was hit without " - "second PAL_TRY being hit.\n"); - } - if (!bExcept_nested2) - { - Fail("ERROR: second PAL_EXCEPT was hit without " - "third PAL_EXCEPT being hit.\n"); - } - bExcept_nested = TRUE; - } - PAL_ENDTRY; - - *p = 13; /* causes an access violation exception */ - - Fail("ERROR: code was executed after the access violation.\n"); - } - PAL_EXCEPT(EXCEPTION_EXECUTE_HANDLER) - { - if (!bTry) - { - Fail("ERROR: PAL_EXCEPT was hit without PAL_TRY being hit.\n"); - } - if (!bExcept_nested) - { - Fail("ERROR: first PAL_EXCEPT was hit without " - "second PAL_EXCEPT being hit.\n"); - } - if (!bExcept_nested2) - { - Fail("ERROR: first PAL_EXCEPT was hit without " - "third PAL_EXCEPT being hit.\n"); - } - - bExcept = TRUE; /* indicate we hit the PAL_EXCEPT block */ - } - PAL_ENDTRY; - - if (!bTry) - { - Trace("ERROR: the code in the " - "first PAL_TRY block was not executed.\n"); - } - - if (!bExcept) - { - Trace("ERROR: the code in the " - "first PAL_EXCEPT block was not executed.\n"); - } - - if (!bTry_nested) - { - Trace("ERROR: the code in the " - "second PAL_TRY block was not executed.\n"); - } - - if (!bExcept_nested) - { - Trace("ERROR: the code in the " - "second PAL_EXCEPT block was not executed.\n"); - } - - if (!bTry_nested2) - { - Trace("ERROR: the code in the " - "third PAL_TRY block was not executed.\n"); - } - - if (!bExcept_nested2) - { - Trace("ERROR: the code in the " - "third PAL_EXCEPT block was not executed.\n"); - } - - /* did we hit all the code blocks? */ - if(!bTry || !bExcept || - !bTry_nested || !bExcept_nested || - !bTry_nested2 || !bExcept_nested2) - { - Fail(""); - } - - - PAL_Terminate(); - return PASS; - -} diff --git a/src/pal/tests/palsuite/exception_handling/pal_except/test6/testinfo.dat b/src/pal/tests/palsuite/exception_handling/pal_except/test6/testinfo.dat deleted file mode 100644 index f8901a7f5..000000000 --- a/src/pal/tests/palsuite/exception_handling/pal_except/test6/testinfo.dat +++ /dev/null @@ -1,25 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 - -Section = exception_handling - -Function = PAL_TRY and PAL_EXCEPT_EX - -Name = Test for PAL_TRY and PAL_EXCEPT_EX - -Type = DEFAULT - -EXE1 = test6 - -LANG = cpp - -Description - -= Test to make sure the PAL_EXCEPT_EX block is executed - -= after an exception occurs in the PAL_TRY block - -= that contains multiple PAL_TRY-PAL_EXCEPT_EX blocks diff --git a/src/pal/tests/palsuite/exception_handling/pal_except/test7/CMakeLists.txt b/src/pal/tests/palsuite/exception_handling/pal_except/test7/CMakeLists.txt deleted file mode 100644 index 7cb6be8d9..000000000 --- a/src/pal/tests/palsuite/exception_handling/pal_except/test7/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test7.cpp -) - -add_executable(paltest_pal_except_test7 - ${SOURCES} -) - -add_dependencies(paltest_pal_except_test7 coreclrpal) - -target_link_libraries(paltest_pal_except_test7 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/exception_handling/pal_except/test7/test7.cpp b/src/pal/tests/palsuite/exception_handling/pal_except/test7/test7.cpp deleted file mode 100644 index a8dc8331c..000000000 --- a/src/pal/tests/palsuite/exception_handling/pal_except/test7/test7.cpp +++ /dev/null @@ -1,67 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test7.c (exception_handling\pal_except\test7) -** -** Purpose: Tests the PAL implementation of the PAL_TRY and -** PAL_EXCEPT functions. Tests that the EXCEPTION block -** is missed if no exceptions happen -** -** -**===================================================================*/ - - - -#include - - -int __cdecl main(int argc, char *argv[]) -{ - BOOL bTry = FALSE; - BOOL bExcept = FALSE; - - if (0 != PAL_Initialize(argc, argv)) - { - return FAIL; - } - - /* - ** Test to make sure we skip the exception block. - */ - - PAL_TRY - { - bTry = TRUE; /* indicate we hit the PAL_TRY block */ - } - PAL_EXCEPT(EXCEPTION_EXECUTE_HANDLER) - { - bExcept = TRUE; /* indicate we hit the PAL_EXCEPT block */ - } - PAL_ENDTRY; - - if (!bTry) - { - Trace("PAL_TRY_EXCEPT: ERROR -> It appears the code in the PAL_TRY" - " block was not executed.\n"); - } - - if (bExcept) - { - Trace("PAL_TRY_EXCEPT: ERROR -> It appears the code in the PAL_EXCEPT" - " block was executed even though no exception was supposed to" - " happen.\n"); - } - - /* did we hit the correct code blocks? */ - if(!bTry || bExcept) - { - Fail(""); - } - - PAL_Terminate(); - return PASS; - -} diff --git a/src/pal/tests/palsuite/exception_handling/pal_except/test7/testinfo.dat b/src/pal/tests/palsuite/exception_handling/pal_except/test7/testinfo.dat deleted file mode 100644 index 546d64cde..000000000 --- a/src/pal/tests/palsuite/exception_handling/pal_except/test7/testinfo.dat +++ /dev/null @@ -1,24 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 - -Section = exception_handling - -Function = PAL_TRY and PAL_EXCEPT - -Name = Test for PAL_TRY and PAL_EXCEPT - -Type = DEFAULT - -EXE1 = test7 - -LANG = cpp - -Description - -= In this test, no exceptions are forced to ensure the EXCEPTION block - -= isn't hit. - diff --git a/src/pal/tests/palsuite/exception_handling/pal_finally/CMakeLists.txt b/src/pal/tests/palsuite/exception_handling/pal_finally/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/exception_handling/pal_finally/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/exception_handling/pal_finally/test1/CMakeLists.txt b/src/pal/tests/palsuite/exception_handling/pal_finally/test1/CMakeLists.txt deleted file mode 100644 index fe1cbbe0b..000000000 --- a/src/pal/tests/palsuite/exception_handling/pal_finally/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - pal_finally.cpp -) - -add_executable(paltest_pal_finally_test1 - ${SOURCES} -) - -add_dependencies(paltest_pal_finally_test1 coreclrpal) - -target_link_libraries(paltest_pal_finally_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/exception_handling/pal_finally/test1/pal_finally.cpp b/src/pal/tests/palsuite/exception_handling/pal_finally/test1/pal_finally.cpp deleted file mode 100644 index f278f9895..000000000 --- a/src/pal/tests/palsuite/exception_handling/pal_finally/test1/pal_finally.cpp +++ /dev/null @@ -1,302 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: pal_finally.c (test 3) -** -** Purpose: Tests the PAL implementation of the PAL_FINALLY in the -** presence of a call stack. An exception is forced and -** passed to two nested exception filters for consideration. -** The first filter returns EXCEPTION_CONTINUE_SEARCH so the -** second can run and return EXCEPTION_EXECUTE_HANDLER. The -** initial exception handler should be skipped, and the -** second executed, and all the PAL_FINALLY blocks handled -** -** -**===================================================================*/ -#include - -BOOL bFilterCS = FALSE; -BOOL bFilterEE = FALSE; -BOOL bFinally1 = FALSE; -BOOL bFinally2 = FALSE; -BOOL bFinally3 = FALSE; -BOOL bFinally4 = FALSE; -BOOL bTry1 = FALSE; -BOOL bTry2 = FALSE; -BOOL bExcept1 = FALSE; -BOOL bExcept2 = FALSE; -BOOL bContinued = FALSE; -const int nValidator = 12321; - -LONG ContSearchFilter(EXCEPTION_POINTERS* ep, LPVOID pnTestInt) -{ - - /* let the main know we've hit the filter function */ - bFilterCS = TRUE; - - if (!bTry1 || !bTry2) - { - Fail("PAL_EXCEPT_FILTER: ERROR -> Something weird is going on." - " The ContSearch filter was hit without PAL_TRY being hit.\n"); - } - - if (bFilterEE) - { - Fail("PAL_EXCEPT_FILTER: ERROR -> Something weird is going on." - " The ContSearch filter was hit after the ExecuteException " - "filter.\n"); - } - - return EXCEPTION_CONTINUE_SEARCH; -} - -LONG ExecExeptionFilter(EXCEPTION_POINTERS* ep, LPVOID pnTestInt) -{ - /* let the main know we've hit the filter function */ - bFilterEE = TRUE; - - if (!bTry1 || !bTry2) - { - Fail("PAL_EXCEPT_FILTER: ERROR -> Something weird is going on." - " The ContSearch filter was hit without PAL_TRY being hit.\n"); - } - - if (!bFilterCS) - { - Fail("PAL_EXCEPT_FILTER: ERROR -> Something weird is going on." - " The ExecExeption filter was hit before the ContSearch " - "filter.\n"); - } - return EXCEPTION_EXECUTE_HANDLER; -} - -void NestedFunc1 (void) -{ - int* p = 0x00000000; /* pointer to NULL */ - - PAL_TRY - { - PAL_TRY - { - - if (bExcept1 || bExcept2) - { - Fail("PAL_EXCEPT_FILTER: ERROR -> Something weird is going on." - " PAL_EXCEPT_FILTER was hit before PAL_TRY.\n"); - } - bTry2 = TRUE; /* indicate we hit the inner PAL_TRY block */ - *p = 13; /* causes an access violation exception */ - - Fail("PAL_EXCEPT_FILTER: ERROR -> Something weird is going on." - " We executed beyond the trapping code.\n"); - } - PAL_FINALLY - { - if (!bTry1) - { - Fail("PAL_EXCEPT_FILTER: ERROR -> Something weird is going on." - " The first finally handler was hit without the outer " - "PAL_TRY's code being hit.\n"); - } - if (!bTry2) - { - Fail("PAL_EXCEPT_FILTER: ERROR -> Something weird is going on." - " The first finally handler was hit without the inner " - "PAL_TRY's code being hit.\n"); - } - if (!bFilterCS) - { - Fail("PAL_EXCEPT_FILTER: ERROR -> Something weird is going on." - " The first finally handler was hit without the inner " - "filter being hit.\n"); - } - if (!bFilterEE) - { - Fail("PAL_EXCEPT_FILTER: ERROR -> Something weird is going on." - " The first finally handler handler was hit without the " - "outer filter being hit.\n"); - } - bFinally1 = TRUE; /* indicate we hit the first finally block */ - } - PAL_ENDTRY; - } - PAL_EXCEPT_FILTER(ContSearchFilter, (LPVOID)&nValidator) - { - Fail("PAL_EXCEPT_FILTER: ERROR -> Something weird is going on." - " The dummy handler was " - "being hit.\n"); - bExcept2 = TRUE; /* indicate we hit the inner block */ - } - PAL_ENDTRY; - -} - -void NestedFunc2 (void) -{ - PAL_TRY - { - NestedFunc1(); - } - PAL_FINALLY - { - if (!bFinally1) - { - Fail("PAL_EXCEPT_FILTER: ERROR -> Something weird is going on." - " The second finally handler handler was hit without the " - " top level one being hit.\n"); - } - bFinally2 = TRUE; - } - PAL_ENDTRY ; -} - -int __cdecl main(int argc, char *argv[]) -{ - if (0 != PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - /* - ** test to make sure we get into the second exception block only based - ** on the return codes of the filters - */ - - PAL_TRY - { - PAL_TRY - { - PAL_TRY - { - if (bExcept1 || bExcept2) - { - Fail("PAL_EXCEPT_FILTER: ERROR -> Something weird is going" - " on. PAL_EXCEPT_FILTER was hit before PAL_TRY.\n"); - } - bTry1 = TRUE; /* indicate we hit the outer PAL_TRY block */ - - NestedFunc2(); - - Fail("PAL_EXCEPT_FILTER: ERROR -> Something weird is going on." - " We executed beyond the trapping code.\n"); - } - PAL_FINALLY - { - if (!bFinally2) - { - Fail("PAL_EXCEPT_FILTER: ERROR -> Something weird is going" - " on. Finally handlers hit out of order (2->3)\n"); - } - bFinally3 = TRUE; - } - PAL_ENDTRY; - } - PAL_EXCEPT_FILTER(ExecExeptionFilter, (LPVOID)&nValidator) - { - if (!bTry1) - { - Fail("PAL_EXCEPT_FILTER: ERROR -> Something weird is going on." - " PAL_EXCEPT_FILTER's handler was hit without the outer " - "PAL_TRY's code being hit.\n"); - } - if (!bTry2) - { - Fail("PAL_EXCEPT_FILTER: ERROR -> Something weird is going on." - " PAL_EXCEPT_FILTER's handler was hit without the inner " - "PAL_TRY's code being hit.\n"); - } - if (!bFilterCS) - { - Fail("PAL_EXCEPT_FILTER: ERROR -> Something weird is going on." - " PAL_EXCEPT_FILTER's handler was hit without the inner " - "filter being hit.\n"); - } - if (!bFilterEE) - { - Fail("PAL_EXCEPT_FILTER: ERROR -> Something weird is going on." - " PAL_EXCEPT_FILTER's handler was hit without the outer " - "filter being hit.\n"); - } - bExcept1 = TRUE; /* indicate we hit the outer block */ - } - PAL_ENDTRY; - - if (bFinally4) - { - Fail("PAL_EXCEPT_FILTER: ERROR -> Something weird is going on." - " Finally handler # 4 executed before it should be \n"); - } - } - PAL_FINALLY - { - if (!bExcept1 || bExcept2) - { - Fail("PAL_EXCEPT_FILTER: ERROR -> Something weird is going on." - " Exceptions handlers hit in wierd ways\n"); - } - if (!bFinally3) - { - Fail("PAL_EXCEPT_FILTER: ERROR -> Something weird is going on." - " Finally handlers hit out of order 3->4)\n"); - } - - bFinally4 = TRUE; - } - PAL_ENDTRY; - - if (!bTry1) - { - Trace("PAL_EXCEPT_FILTER: ERROR -> It appears the code in the outer" - " PAL_TRY block was not executed.\n"); - } - - if (!bTry2) - { - Trace("PAL_EXCEPT_FILTER: ERROR -> It appears the code in the inner" - " PAL_TRY block was not executed.\n"); - } - - if (bExcept2) - { - Trace("PAL_EXCEPT_FILTER: ERROR -> It appears the code in the " - "inner PAL_EXCEPT_FILTER block was executed.\n"); - } - if (!bExcept1) - { - Trace("PAL_EXCEPT_FILTER: ERROR -> It appears the code in the " - "outer PAL_EXCEPT_FILTER block was not executed.\n"); - } - - if (!bFilterCS) - { - Trace("PAL_EXCEPT_FILTER: ERROR -> It appears the code in the " - "search continuing filter" - " function was not executed.\n"); - } - if (!bFilterEE) - { - Trace("PAL_EXCEPT_FILTER: ERROR -> It appears the code in the " - "execute handler filter" - " function was not executed.\n"); - } - - /* did we hit all the code blocks? */ - if (!bFinally1 || !bFinally2 || !bFinally3 || !bFinally4) - { - Fail(""); - } - if(!bTry1 || !bTry2 || !bExcept1 || bExcept2 || !bFilterEE || !bFilterCS ) - { - Fail(""); - } - - - PAL_Terminate(); - return PASS; - -} - diff --git a/src/pal/tests/palsuite/exception_handling/pal_finally/test1/testinfo.dat b/src/pal/tests/palsuite/exception_handling/pal_finally/test1/testinfo.dat deleted file mode 100644 index 5c2624343..000000000 --- a/src/pal/tests/palsuite/exception_handling/pal_finally/test1/testinfo.dat +++ /dev/null @@ -1,19 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = exception_handling -Function = PAL_FINALLY -Name = Test for nested PAL_FINALLY -Type = DEFAULT -EXE1 = pal_finally -LANG = cpp -Description -= Tests the PAL implementation of the PAL_FINALLY in the presence -= of a call stack. An exception is forced and passed to two nested -= exception filters for consideration. The first filter returns -= EXCEPTION_CONTINUE_SEARCH so the second can run and return -= EXCEPTION_EXECUTE_HANDLER. The initial exception handler should -= be skipped, and the second executed, and all the PAL_FINALLY -= blocks handled. diff --git a/src/pal/tests/palsuite/exception_handling/pal_sxs/CMakeLists.txt b/src/pal/tests/palsuite/exception_handling/pal_sxs/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/exception_handling/pal_sxs/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/exception_handling/pal_sxs/test1/CMakeLists.txt b/src/pal/tests/palsuite/exception_handling/pal_sxs/test1/CMakeLists.txt deleted file mode 100644 index 4a3abc2d6..000000000 --- a/src/pal/tests/palsuite/exception_handling/pal_sxs/test1/CMakeLists.txt +++ /dev/null @@ -1,94 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -if(CLR_CMAKE_PLATFORM_UNIX) - add_compile_options(-fPIC) - add_definitions(-DFEATURE_ENABLE_HARDWARE_EXCEPTIONS) -endif(CLR_CMAKE_PLATFORM_UNIX) - -# Set the RPATH of paltest_pal_sxs_test1 so that it can find dependencies without needing to set LD_LIBRARY -# For more information: http://www.cmake.org/Wiki/CMake_RPATH_handling. -if(CORECLR_SET_RPATH) - if(CLR_CMAKE_PLATFORM_LINUX) - set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) - set(CMAKE_INSTALL_RPATH "\$ORIGIN") - endif(CLR_CMAKE_PLATFORM_LINUX) -endif(CORECLR_SET_RPATH) - -# Test DLL1 - -set(DEF_SOURCES1 dlltest1.src) -convert_to_absolute_path(DEF_SOURCES1 ${DEF_SOURCES1}) -set(EXPORTS_FILE1 ${CMAKE_CURRENT_BINARY_DIR}/dlltest1.exports) -generate_exports_file(${DEF_SOURCES1} ${EXPORTS_FILE1}) - -if(CMAKE_SYSTEM_NAME STREQUAL Linux OR CMAKE_SYSTEM_NAME STREQUAL FreeBSD OR CMAKE_SYSTEM_NAME STREQUAL NetBSD) - set(EXPORTS_LINKER_OPTION1 -Wl,--version-script=${EXPORTS_FILE1}) -endif(CMAKE_SYSTEM_NAME STREQUAL Linux OR CMAKE_SYSTEM_NAME STREQUAL FreeBSD OR CMAKE_SYSTEM_NAME STREQUAL NetBSD) - -if(CMAKE_SYSTEM_NAME STREQUAL Darwin) - set(EXPORTS_LINKER_OPTION1 -Wl,-exported_symbols_list,${EXPORTS_FILE1}) -endif(CMAKE_SYSTEM_NAME STREQUAL Darwin) - -set(DLL1SOURCES dlltest1.cpp) -add_library(paltest_pal_sxs_test1_dll1 SHARED ${DLL1SOURCES}) -add_custom_target(dlltest1_exports DEPENDS ${EXPORTS_FILE1}) -set_property(TARGET paltest_pal_sxs_test1_dll1 APPEND_STRING PROPERTY LINK_FLAGS ${EXPORTS_LINKER_OPTION1}) -set_property(TARGET paltest_pal_sxs_test1_dll1 APPEND_STRING PROPERTY LINK_DEPENDS ${EXPORTS_FILE1}) - -add_dependencies(paltest_pal_sxs_test1_dll1 - dlltest1_exports - coreclrpal -) - -target_link_libraries(paltest_pal_sxs_test1_dll1 - ${COMMON_TEST_LIBRARIES} - m - coreclrpal -) - -# Test DLL2 - -set(DEF_SOURCES2 dlltest2.src) -convert_to_absolute_path(DEF_SOURCES2 ${DEF_SOURCES2}) -set(EXPORTS_FILE2 ${CMAKE_CURRENT_BINARY_DIR}/dlltest2.exports) -generate_exports_file(${DEF_SOURCES2} ${EXPORTS_FILE2}) - -if(CMAKE_SYSTEM_NAME STREQUAL Linux OR CMAKE_SYSTEM_NAME STREQUAL FreeBSD OR CMAKE_SYSTEM_NAME STREQUAL NetBSD) - set(EXPORTS_LINKER_OPTION2 -Wl,--version-script=${EXPORTS_FILE2}) -endif(CMAKE_SYSTEM_NAME STREQUAL Linux OR CMAKE_SYSTEM_NAME STREQUAL FreeBSD OR CMAKE_SYSTEM_NAME STREQUAL NetBSD) - -if(CMAKE_SYSTEM_NAME STREQUAL Darwin) - set(EXPORTS_LINKER_OPTION2 -Wl,-exported_symbols_list,${EXPORTS_FILE2}) -endif(CMAKE_SYSTEM_NAME STREQUAL Darwin) - -set(DLL2SOURCES dlltest2.cpp) -add_library(paltest_pal_sxs_test1_dll2 SHARED ${DLL2SOURCES}) -add_custom_target(dlltest2_exports DEPENDS ${EXPORTS_FILE2}) -set_property(TARGET paltest_pal_sxs_test1_dll2 APPEND_STRING PROPERTY LINK_FLAGS ${EXPORTS_LINKER_OPTION2}) -set_property(TARGET paltest_pal_sxs_test1_dll2 APPEND_STRING PROPERTY LINK_DEPENDS ${EXPORTS_FILE2}) - -add_dependencies(paltest_pal_sxs_test1_dll2 - dlltest2_exports -) - -target_link_libraries(paltest_pal_sxs_test1_dll2 - ${COMMON_TEST_LIBRARIES} -) - -# Main program - -set(TESTSOURCES exceptionsxs.cpp) - -add_executable(paltest_pal_sxs_test1 ${TESTSOURCES}) - -add_dependencies(paltest_pal_sxs_test1 - paltest_pal_sxs_test1_dll1 - paltest_pal_sxs_test1_dll2 -) - -target_link_libraries(paltest_pal_sxs_test1 - paltest_pal_sxs_test1_dll1 - paltest_pal_sxs_test1_dll2 -) diff --git a/src/pal/tests/palsuite/exception_handling/pal_sxs/test1/dlltest1.cpp b/src/pal/tests/palsuite/exception_handling/pal_sxs/test1/dlltest1.cpp deleted file mode 100644 index 000ed6271..000000000 --- a/src/pal/tests/palsuite/exception_handling/pal_sxs/test1/dlltest1.cpp +++ /dev/null @@ -1,87 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: dlltest1.c (exception_handling\pal_sxs\test1) -** -** Purpose: Test to make sure the PAL_EXCEPT block is executed -** after an exception occurs in the PAL_TRY block with -** multiple PALs in the process. -** -** -**===================================================================*/ -#include - -extern "C" -int InitializeDllTest1() -{ - return PAL_InitializeDLL(); -} - -__attribute__((noinline,optnone)) -static void FailingFunction(volatile int *p) -{ - if (p == NULL) - { - throw PAL_SEHException(); - } - - *p = 1; // Causes an access violation exception -} - -BOOL bTry = FALSE; -BOOL bExcept = FALSE; - -extern "C" -int DllTest1() -{ - Trace("Starting pal_sxs test1 DllTest1\n"); - - PAL_TRY(VOID*, unused, NULL) - { - volatile int* p = (volatile int *)0x11; // Invalid pointer - - bTry = TRUE; // Indicate we hit the PAL_TRY block - FailingFunction(p); // Throw in function to fool C++ runtime into handling - // h/w exception - - Fail("ERROR: code was executed after the access violation.\n"); - } - PAL_EXCEPT(EXCEPTION_EXECUTE_HANDLER) - { - if (!bTry) - { - Fail("ERROR: PAL_EXCEPT was hit without PAL_TRY being hit.\n"); - } - - // Validate that the faulting address is correct; the contents of "p" (0x11). - if (ex.GetExceptionRecord()->ExceptionInformation[1] != 0x11) - { - Fail("ERROR: PAL_EXCEPT ExceptionInformation[1] != 0x11\n"); - } - - bExcept = TRUE; // Indicate we hit the PAL_EXCEPT block - } - PAL_ENDTRY; - - if (!bTry) - { - Trace("ERROR: the code in the PAL_TRY block was not executed.\n"); - } - - if (!bExcept) - { - Trace("ERROR: the code in the PAL_EXCEPT block was not executed.\n"); - } - - // Did we hit all the code blocks? - if(!bTry || !bExcept) - { - Fail("DllTest1 FAILED\n"); - } - - Trace("DLLTest1 PASSED\n"); - return PASS; -} diff --git a/src/pal/tests/palsuite/exception_handling/pal_sxs/test1/dlltest1.src b/src/pal/tests/palsuite/exception_handling/pal_sxs/test1/dlltest1.src deleted file mode 100644 index 0a0a6ee44..000000000 --- a/src/pal/tests/palsuite/exception_handling/pal_sxs/test1/dlltest1.src +++ /dev/null @@ -1,3 +0,0 @@ -InitializeDllTest1 -DllTest1 - diff --git a/src/pal/tests/palsuite/exception_handling/pal_sxs/test1/dlltest2.cpp b/src/pal/tests/palsuite/exception_handling/pal_sxs/test1/dlltest2.cpp deleted file mode 100644 index 27fc213e4..000000000 --- a/src/pal/tests/palsuite/exception_handling/pal_sxs/test1/dlltest2.cpp +++ /dev/null @@ -1,87 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: dlltest2.c (exception_handling\pal_sxs\test1) -** -** Purpose: Test to make sure the PAL_EXCEPT block is executed -** after an exception occurs in the PAL_TRY block with -** multiple PALs in the process. -** -** -**===================================================================*/ -#include - -extern "C" -int InitializeDllTest2() -{ - return PAL_InitializeDLL(); -} - -__attribute__((noinline,optnone)) -static void FailingFunction(volatile int *p) -{ - if (p == NULL) - { - throw PAL_SEHException(); - } - - *p = 1; // Causes an access violation exception -} - -BOOL bTry = FALSE; -BOOL bExcept = FALSE; - -extern "C" -int DllTest2() -{ - Trace("Starting pal_sxs test1 DllTest2\n"); - - PAL_TRY(VOID*, unused, NULL) - { - volatile int* p = (volatile int *)0x22; // Invalid pointer - - bTry = TRUE; // Indicate we hit the PAL_TRY block - FailingFunction(p); // Throw in function to fool C++ runtime into handling - // h/w exception - - Fail("ERROR: code was executed after the access violation.\n"); - } - PAL_EXCEPT(EXCEPTION_EXECUTE_HANDLER) - { - if (!bTry) - { - Fail("ERROR: PAL_EXCEPT was hit without PAL_TRY being hit.\n"); - } - - // Validate that the faulting address is correct; the contents of "p" (0x22). - if (ex.GetExceptionRecord()->ExceptionInformation[1] != 0x22) - { - Fail("ERROR: PAL_EXCEPT ExceptionInformation[1] != 0x22\n"); - } - - bExcept = TRUE; // Indicate we hit the PAL_EXCEPT block - } - PAL_ENDTRY; - - if (!bTry) - { - Trace("ERROR: the code in the PAL_TRY block was not executed.\n"); - } - - if (!bExcept) - { - Trace("ERROR: the code in the PAL_EXCEPT block was not executed.\n"); - } - - // Did we hit all the code blocks? - if(!bTry || !bExcept) - { - Fail("DllTest2 FAILED\n"); - } - - Trace("DLLTest2 PASSED\n"); - return PASS; -} diff --git a/src/pal/tests/palsuite/exception_handling/pal_sxs/test1/dlltest2.src b/src/pal/tests/palsuite/exception_handling/pal_sxs/test1/dlltest2.src deleted file mode 100644 index 433419bc5..000000000 --- a/src/pal/tests/palsuite/exception_handling/pal_sxs/test1/dlltest2.src +++ /dev/null @@ -1,3 +0,0 @@ -InitializeDllTest2 -DllTest2 - diff --git a/src/pal/tests/palsuite/exception_handling/pal_sxs/test1/exceptionsxs.cpp b/src/pal/tests/palsuite/exception_handling/pal_sxs/test1/exceptionsxs.cpp deleted file mode 100644 index 97a963c12..000000000 --- a/src/pal/tests/palsuite/exception_handling/pal_sxs/test1/exceptionsxs.cpp +++ /dev/null @@ -1,117 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: exceptionsxs.c (exception_handling\pal_sxs\test1) -** -** Purpose: Test to make sure the PAL_EXCEPT block is executed -** after an exception occurs in the PAL_TRY block with -** multiple PALs in the process. -** -** -**===================================================================*/ - -#include -#include -#include -#include -#include -#include - -enum -{ - PASS = 0, - FAIL = 1 -}; - -extern "C" int InitializeDllTest1(); -extern "C" int InitializeDllTest2(); -extern "C" int DllTest1(); -extern "C" int DllTest2(); - -bool bSignal = false; -bool bCatch = false; -bool bHandler = false; - -void sigsegv_handler(int code, siginfo_t *siginfo, void *context) -{ - printf("pal_sxs test1: signal handler called\n"); - bHandler = true; // Mark that the signal handler was executed - - if (!bSignal) - { - printf("ERROR: executed signal handler NOT from try/catch\n"); - _exit(FAIL); - } - - // Validate that the faulting address is correct; the contents of "p" (0x22). - if (siginfo->si_addr != (void *)0x33) - { - printf("ERROR: signal handler faulting address != 0x33\n"); - _exit(FAIL); - } - - // Unmask signal so we can receive it again - sigset_t signal_set; - sigemptyset(&signal_set); - sigaddset(&signal_set, SIGSEGV); - if (-1 == sigprocmask(SIG_UNBLOCK, &signal_set, NULL)) - { - printf("ERROR: sigprocmask failed; error is %d\n", errno); - _exit(FAIL); - } - - printf("Signal chaining PASSED\n"); - _exit(PASS); -} - -int main(int argc, char *argv[]) -{ - struct sigaction newAction; - struct sigaction oldAction; - newAction.sa_flags = SA_SIGINFO | SA_RESTART; - newAction.sa_handler = NULL; - newAction.sa_sigaction = sigsegv_handler; - sigemptyset(&newAction.sa_mask); - - if (-1 == sigaction(SIGSEGV, &newAction, &oldAction)) - { - printf("ERROR: sigaction failed; error is %d\n", errno); - return FAIL; - } - - printf("PAL_SXS test1 SIGSEGV handler %p\n", oldAction.sa_sigaction); - - if (0 != InitializeDllTest1()) - { - return FAIL; - } - - if (0 != InitializeDllTest2()) - { - return FAIL; - } - - // Test catching exceptions in other PAL instances - DllTest2(); - DllTest1(); - DllTest2(); - - if (bHandler) - { - printf("ERROR: signal handler called by PAL sxs tests\n"); - return FAIL; - } - - printf("Starting PAL_SXS test1 signal chaining\n"); - - bSignal = true; - - volatile int* p = (volatile int *)0x33; // Invalid pointer - *p = 3; // Causes an access violation exception - - printf("ERROR: code was executed after the access violation.\n"); - return FAIL; -} diff --git a/src/pal/tests/palsuite/exception_handling/pal_sxs/test1/testinfo.dat b/src/pal/tests/palsuite/exception_handling/pal_sxs/test1/testinfo.dat deleted file mode 100644 index c0cf1ddfc..000000000 --- a/src/pal/tests/palsuite/exception_handling/pal_sxs/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = exception_handling -Function = test1 -Name = pal_sxs test #1 -TYPE = DEFAULT -EXE1 = test1 -LANG = cpp -Description -=Tests that exceptions across multiples pals work correctly diff --git a/src/pal/tests/palsuite/file_io/CMakeLists.txt b/src/pal/tests/palsuite/file_io/CMakeLists.txt deleted file mode 100644 index 09fb686c1..000000000 --- a/src/pal/tests/palsuite/file_io/CMakeLists.txt +++ /dev/null @@ -1,52 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(CompareFileTime) -add_subdirectory(CopyFileA) -add_subdirectory(CopyFileW) -add_subdirectory(CreateDirectoryA) -add_subdirectory(CreateDirectoryW) -add_subdirectory(CreateFileA) -add_subdirectory(CreateFileW) -add_subdirectory(DeleteFileA) -add_subdirectory(DeleteFileW) -add_subdirectory(errorpathnotfound) -add_subdirectory(FILECanonicalizePath) -add_subdirectory(FindClose) -add_subdirectory(FindFirstFileA) -add_subdirectory(FindFirstFileW) -add_subdirectory(FindNextFileA) -add_subdirectory(FindNextFileW) -add_subdirectory(FlushFileBuffers) -add_subdirectory(GetConsoleOutputCP) -add_subdirectory(GetCurrentDirectoryA) -add_subdirectory(GetCurrentDirectoryW) -add_subdirectory(GetFileAttributesA) -add_subdirectory(GetFileAttributesExW) -add_subdirectory(GetFileAttributesW) -add_subdirectory(GetFileSize) -add_subdirectory(GetFileSizeEx) -add_subdirectory(GetFullPathNameA) -add_subdirectory(GetFullPathNameW) -add_subdirectory(GetLongPathNameW) -add_subdirectory(GetStdHandle) -add_subdirectory(GetSystemTime) -add_subdirectory(GetSystemTimeAsFileTime) -add_subdirectory(GetTempFileNameA) -add_subdirectory(GetTempFileNameW) -add_subdirectory(gettemppatha) -add_subdirectory(GetTempPathW) -add_subdirectory(MoveFileExA) -add_subdirectory(MoveFileExW) -add_subdirectory(ReadFile) -add_subdirectory(RemoveDirectoryA) -add_subdirectory(RemoveDirectoryW) -add_subdirectory(SearchPathA) -add_subdirectory(SearchPathW) -add_subdirectory(SetCurrentDirectoryA) -add_subdirectory(SetCurrentDirectoryW) -add_subdirectory(SetEndOfFile) -add_subdirectory(SetFileAttributesA) -add_subdirectory(SetFileAttributesW) -add_subdirectory(SetFilePointer) -add_subdirectory(WriteFile) - diff --git a/src/pal/tests/palsuite/file_io/CompareFileTime/CMakeLists.txt b/src/pal/tests/palsuite/file_io/CompareFileTime/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/file_io/CompareFileTime/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/file_io/CompareFileTime/test1/CMakeLists.txt b/src/pal/tests/palsuite/file_io/CompareFileTime/test1/CMakeLists.txt deleted file mode 100644 index 4883aee38..000000000 --- a/src/pal/tests/palsuite/file_io/CompareFileTime/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - CompareFileTime.cpp -) - -add_executable(paltest_comparefiletime_test1 - ${SOURCES} -) - -add_dependencies(paltest_comparefiletime_test1 coreclrpal) - -target_link_libraries(paltest_comparefiletime_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/CompareFileTime/test1/CompareFileTime.cpp b/src/pal/tests/palsuite/file_io/CompareFileTime/test1/CompareFileTime.cpp deleted file mode 100644 index 3758f7e4e..000000000 --- a/src/pal/tests/palsuite/file_io/CompareFileTime/test1/CompareFileTime.cpp +++ /dev/null @@ -1,68 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: CompareFileTime.c -** -** Purpose: Tests the PAL implementation of the CompareFileTime function. -** Defines a large and small file time, and compares them in all fashions -** to ensure proper return values. -** -** -**===================================================================*/ - -#include - - - -int __cdecl main(int argc, char **argv) -{ - - FILETIME SmallTime, BigTime; - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - /* Set a Big and Small time. These were generated using - GetFileTime on a file, with a recent creation time and an old - modify time, to get a bigger and smaller value. - */ - - BigTime.dwLowDateTime = -755748832; - BigTime.dwHighDateTime = 29436941; - - SmallTime.dwLowDateTime = -459754240; - SmallTime.dwHighDateTime = 29436314; - - /* Check to see that SmallTime is less than Big Time */ - - if(CompareFileTime(&SmallTime,&BigTime) != -1) - { - Fail("ERROR: The first time is less than the second time, so " - "-1 should have been returned to indicate this."); - } - - /* Check that BigTime is greater than SmallTime */ - - if(CompareFileTime(&BigTime,&SmallTime) != 1) - { - Fail("ERROR: The first time is greater than the second time, so " - "1 should have been returned to indicate this."); - } - - /* Check that BigTime is equal to BigTime */ - - if(CompareFileTime(&BigTime,&BigTime) != 0) - { - Fail("ERROR: The first time is equal to the second time, so " - "0 should have been returned to indicate this."); - } - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/file_io/CompareFileTime/test1/testinfo.dat b/src/pal/tests/palsuite/file_io/CompareFileTime/test1/testinfo.dat deleted file mode 100644 index 4ff1b4c98..000000000 --- a/src/pal/tests/palsuite/file_io/CompareFileTime/test1/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = CompareFileTime -Name = Positive Test for CompareFileTime -TYPE = DEFAULT -EXE1 = comparefiletime -Description -= Test the CompareFileTime function. -= Defines a large and small file time, and compares them in all fashions -= to ensure proper return values. diff --git a/src/pal/tests/palsuite/file_io/CopyFileA/CMakeLists.txt b/src/pal/tests/palsuite/file_io/CopyFileA/CMakeLists.txt deleted file mode 100644 index a3847f8ca..000000000 --- a/src/pal/tests/palsuite/file_io/CopyFileA/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) -add_subdirectory(test3) -add_subdirectory(test4) - diff --git a/src/pal/tests/palsuite/file_io/CopyFileA/test1/CMakeLists.txt b/src/pal/tests/palsuite/file_io/CopyFileA/test1/CMakeLists.txt deleted file mode 100644 index 0890ebe2e..000000000 --- a/src/pal/tests/palsuite/file_io/CopyFileA/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - CopyFileA.cpp -) - -add_executable(paltest_copyfilea_test1 - ${SOURCES} -) - -add_dependencies(paltest_copyfilea_test1 coreclrpal) - -target_link_libraries(paltest_copyfilea_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/CopyFileA/test1/CopyFileA.cpp b/src/pal/tests/palsuite/file_io/CopyFileA/test1/CopyFileA.cpp deleted file mode 100644 index bfea85b7c..000000000 --- a/src/pal/tests/palsuite/file_io/CopyFileA/test1/CopyFileA.cpp +++ /dev/null @@ -1,159 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: CopyFileA.c -** -** Purpose: Tests the PAL implementation of the CopyFileA function -** -** -**===================================================================*/ - -/* - 1. copy an existing file to existing with overwrite true - 2. copy an existing file to existing with overwrite false - 3. copy an existing file to non-existant with overwrite true - 4. copy an existing file to non-existant with overwrite false - 5. copy non-existant file to existing with overwrite true - 6. copy non-existant file to existing with overwrite false - 7. copy non-existant file to non-existant with overwrite true - 8. copy non-existant file to non-existant with overwrite false -*/ - -#include - -struct TESTS{ - char* lpSource; - char* lpDestination; - BOOL bFailIfExists; - int nResult; - }; - - -int __cdecl main(int argc, char *argv[]) -{ - char szSrcExisting[] = {"src_existing.tmp"}; - char szSrcNonExistant[] = {"src_non-existant.tmp"}; - char szDstExisting[] = {"dst_existing.tmp"}; - char szDstNonExistant[] = {"dst_non-existant.tmp"}; - BOOL bRc = TRUE; - BOOL bSuccess = TRUE; - FILE* tempFile = NULL; - int i; - struct TESTS testCase[] = - { - {szSrcExisting, szDstExisting, FALSE, 1}, - {szSrcExisting, szDstExisting, TRUE, 0}, - {szSrcExisting, szDstNonExistant, FALSE, 1}, - {szSrcExisting, szDstNonExistant, TRUE, 1}, - {szSrcNonExistant, szDstExisting, FALSE, 0}, - {szSrcNonExistant, szDstExisting, TRUE, 0}, - {szSrcNonExistant, szDstNonExistant, FALSE, 0}, - {szSrcNonExistant, szDstNonExistant, TRUE, 0} - }; - - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - /* create the src_existing file */ - tempFile = fopen(szSrcExisting, "w"); - if (tempFile != NULL) - { - fprintf(tempFile, "CopyFileA test file: src_existing.tmp\n"); - fclose(tempFile); - } - else - { - Fail("CopyFileA: ERROR-> Couldn't create \"src_existing.tmp\" with " - "error %ld\n", - GetLastError()); - } - - /* create the dst_existing file */ - tempFile = fopen(szDstExisting, "w"); - if (tempFile != NULL) - { - fprintf(tempFile, "CopyFileA test file: dst_existing.tmp\n"); - fclose(tempFile); - } - else - { - Fail("CopyFileA: ERROR-> Couldn't create \"dst_existing.tmp\" with " - "error %ld\n", - GetLastError()); - } - - - - for (i = 0; i < (sizeof(testCase) / sizeof(struct TESTS)); i++) - { - bRc = CopyFileA(testCase[i].lpSource, - testCase[i].lpDestination, - testCase[i].bFailIfExists); - if (!bRc) - { - if (testCase[i].nResult == 1) - { - Trace("CopyFileA: FAILED: %s -> %s with bFailIfExists = %d " - "with error %ld\n", - testCase[i].lpSource, - testCase[i].lpDestination, - testCase[i].bFailIfExists, - GetLastError()); - bSuccess = FALSE; - } - } - else - { - if (testCase[i].nResult == 0) - { - Trace("CopyFileA: FAILED: %s -> %s with bFailIfExists = %d\n", - testCase[i].lpSource, - testCase[i].lpDestination, - testCase[i].bFailIfExists); - bSuccess = FALSE; - } - else - { - /* verify the file was moved */ - if (GetFileAttributesA(testCase[i].lpDestination) == -1) - { - Trace("CopyFileA: GetFileAttributes of destination file " - "failed with error code %ld. \n", - GetLastError()); - bSuccess = FALSE; - } - else if (GetFileAttributesA(testCase[i].lpSource) == -1) - { - Trace("CopyFileA: GetFileAttributes of source file " - "failed with error code %ld. \n", - GetLastError()); - bSuccess = FALSE; - } - else - { - /* verify attributes of destination file to source file*/ - if(GetFileAttributes(testCase[i].lpSource) != - GetFileAttributes(testCase[i].lpDestination)) - { - Trace("CopyFileA : The file attributes of the " - "destination file do not match the file " - "attributes of the source file.\n"); - bSuccess = FALSE; - } - } - } - } - /* delete file file but don't worry if it fails */ - DeleteFileA(szDstNonExistant); - } - - int exitCode = bSuccess ? PASS : FAIL; - PAL_TerminateEx(exitCode); - return exitCode; -} diff --git a/src/pal/tests/palsuite/file_io/CopyFileA/test1/testinfo.dat b/src/pal/tests/palsuite/file_io/CopyFileA/test1/testinfo.dat deleted file mode 100644 index 88b9c73cb..000000000 --- a/src/pal/tests/palsuite/file_io/CopyFileA/test1/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = CopyFileA -Name = Test for CopyFileA (test 1) -Type = DEFAULT -EXE1 = copyfilea -Description -= Test the CopyFileA function diff --git a/src/pal/tests/palsuite/file_io/CopyFileA/test2/CMakeLists.txt b/src/pal/tests/palsuite/file_io/CopyFileA/test2/CMakeLists.txt deleted file mode 100644 index 8844af3f8..000000000 --- a/src/pal/tests/palsuite/file_io/CopyFileA/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test2.cpp -) - -add_executable(paltest_copyfilea_test2 - ${SOURCES} -) - -add_dependencies(paltest_copyfilea_test2 coreclrpal) - -target_link_libraries(paltest_copyfilea_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/CopyFileA/test2/test2.cpp b/src/pal/tests/palsuite/file_io/CopyFileA/test2/test2.cpp deleted file mode 100644 index 56618d0a5..000000000 --- a/src/pal/tests/palsuite/file_io/CopyFileA/test2/test2.cpp +++ /dev/null @@ -1,120 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test2.c -** -** Purpose: Tests the PAL implementation of the CopyFileA function -** to see if a file can be copied to itself -** -** -**===================================================================*/ - - -#include - -int __cdecl main(int argc, char *argv[]) -{ - - BOOL bRc = TRUE; - char* szSrcExisting = "src_existing.tmp"; - FILE* tempFile = NULL; - DWORD temp; - int retCode; - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - /* create the src_existing file */ - tempFile = fopen(szSrcExisting, "w"); - if (tempFile != NULL) - { - retCode = fputs("CopyFileA test file: src_existing.tmp ", tempFile); - if(retCode < 0) - { - Fail("CopyFileA: ERROR-> Couldn't write to %s with error " - "%u.\n", szSrcExisting, GetLastError()); - } - retCode = fclose(tempFile); - if(retCode != 0) - { - Fail("CopyFileA: ERROR-> Couldn't close file: %s with error " - "%u.\n", szSrcExisting, GetLastError()); - } - - } - else - { - Fail("CopyFileA: ERROR-> Couldn't create %s with " - "error %ld\n",szSrcExisting,GetLastError()); - } - - /* Get file attributes of source */ - temp = GetFileAttributes(szSrcExisting); - if (temp == -1) - { - Fail("CopyFileA: GetFileAttributes of source file " - "failed with error code %ld. \n", - GetLastError()); - } - - /* make sure a file can't copy to itself - first testing with IfFileExists flag set to true */ - bRc = CopyFileA(szSrcExisting,szSrcExisting,TRUE); - if(bRc) - { - Fail("ERROR: Cannot copy a file to itself, %u",GetLastError()); - } - - /* try to get file attributes of desitnation */ - if (GetFileAttributesA(szSrcExisting) == -1) - { - Fail("CopyFileA: GetFileAttributes of destination file " - "failed with error code %ld. \n", - GetLastError()); - } - else - { - /* verify attributes of destination file to source file*/ - - if(temp != GetFileAttributes(szSrcExisting)) - { - Fail("CopyFileA : The file attributes of the " - "destination file do not match the file " - "attributes of the source file.\n"); - } - } - - /* testing with IfFileExists flags set to false - should fail in Windows and pass in UNIX */ - bRc = CopyFileA(szSrcExisting,szSrcExisting,FALSE); - if(bRc && (GetLastError() != ERROR_ALREADY_EXISTS)) - { - Fail("ERROR: Cannot copy a file to itself, %u",GetLastError()); - } - - if (GetFileAttributesA(szSrcExisting) == -1) - { - Fail("CopyFileA: GetFileAttributes of destination file " - "failed with error code %ld. \n", - GetLastError()); - } - else - { - /* verify attributes of destination file to source file*/ - - if(temp != GetFileAttributes(szSrcExisting)) - { - Fail("CopyFileA : The file attributes of the " - "destination file do not match the file " - "attributes of the source file.\n"); - } - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/file_io/CopyFileA/test2/testinfo.dat b/src/pal/tests/palsuite/file_io/CopyFileA/test2/testinfo.dat deleted file mode 100644 index 31143842e..000000000 --- a/src/pal/tests/palsuite/file_io/CopyFileA/test2/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = CopyFileA -Name = CopyFileA - checking copying to itself (test2) -Type = DEFAULT -EXE1 = test2 -Description -= Test the CopyFileA function's behaviour -= for copying a file to itself. - diff --git a/src/pal/tests/palsuite/file_io/CopyFileA/test3/CMakeLists.txt b/src/pal/tests/palsuite/file_io/CopyFileA/test3/CMakeLists.txt deleted file mode 100644 index 3fbdc3e18..000000000 --- a/src/pal/tests/palsuite/file_io/CopyFileA/test3/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test3.cpp -) - -add_executable(paltest_copyfilea_test3 - ${SOURCES} -) - -add_dependencies(paltest_copyfilea_test3 coreclrpal) - -target_link_libraries(paltest_copyfilea_test3 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/CopyFileA/test3/test3.cpp b/src/pal/tests/palsuite/file_io/CopyFileA/test3/test3.cpp deleted file mode 100644 index 18c8ce80d..000000000 --- a/src/pal/tests/palsuite/file_io/CopyFileA/test3/test3.cpp +++ /dev/null @@ -1,141 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test3.c -** -** Purpose: Tests the PAL implementation of the CopyFileA function -** to see if a file can be copied to itself -** -** -**===================================================================*/ - -#include - -int __cdecl main(int argc, char *argv[]) -{ - - BOOL bRc = TRUE; - char* szSrcExisting = "src_existing.tmp"; - char* szDest = "src_dest.tmp"; - FILE* tempFile = NULL; - int retCode; - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - /* create the src_existing file */ - tempFile = fopen(szSrcExisting, "w"); - if (tempFile != NULL) - { - retCode = fputs("CopyFileA test file: src_existing.tmp ", tempFile); - if(retCode < 0) - { - retCode = fclose(tempFile); - if(retCode != 0) - { - Trace("CopyFileA: ERROR-> Couldn't close file: %s with error " - "%u.\n", szSrcExisting, GetLastError()); - } - - Fail("CopyFileA: ERROR-> Couldn't write to %s with error " - "%u.\n", szSrcExisting, GetLastError()); - } - retCode = fclose(tempFile); - if(retCode != 0) - { - Fail("CopyFileA: ERROR-> Couldn't close file: %s with error " - "%u.\n", szSrcExisting, GetLastError()); - } - - } - else - { - Fail("CopyFileA: ERROR-> Couldn't create %s with " - "error %ld\n",szSrcExisting,GetLastError()); - } - - /* set the file attributes of the source file to readonly */ - bRc = SetFileAttributes(szSrcExisting, FILE_ATTRIBUTE_READONLY); - if(!bRc) - { - Fail("CopyFileA: ERROR-> Couldn't set file attributes for " - "file %s with error %u\n", szSrcExisting, GetLastError()); - } - - // Check the file attributes to make sure SetFileAttributes() above actually succeeded - DWORD fileAttributes = GetFileAttributesA(szSrcExisting); - if (fileAttributes == INVALID_FILE_ATTRIBUTES) - { - Fail("CopyFileA: Failed to get file attributes for source file, %u\n", GetLastError()); - } - if ((fileAttributes & FILE_ATTRIBUTE_READONLY) == 0) - { - Fail("CopyFileA: SetFileAttributes(read-only) on source file returned success but did not make it read-only.\n"); - } - - /* copy the file */ - bRc = CopyFileA(szSrcExisting,szDest,TRUE); - if(!bRc) - { - Fail("CopyFileA: Cannot copy a file with error, %u",GetLastError()); - } - - - /* try to get file attributes of destination file */ - fileAttributes = GetFileAttributesA(szDest); - if (fileAttributes == INVALID_FILE_ATTRIBUTES) - { - Fail("CopyFileA: GetFileAttributes of destination file " - "failed with error code %ld. \n", - GetLastError()); - } - - /* verify attributes of destination file to source file*/ - if((fileAttributes & FILE_ATTRIBUTE_READONLY) != FILE_ATTRIBUTE_READONLY) - { - Fail("CopyFileA : The file attributes of the " - "destination file do not match the file " - "attributes of the source file.\n"); - } - - /* set the attributes of the destination file to normal again */ - bRc = SetFileAttributesA(szDest, FILE_ATTRIBUTE_NORMAL); - if(!bRc) - { - Fail("CopyFileA: ERROR-> Couldn't set file attributes for " - "file %s with error %u\n", szDest, GetLastError()); - } - - /* delete the newly copied file */ - bRc = DeleteFile(szDest); - if(!bRc) - { - Fail("CopyFileA: DeleteFile failed to delete the" - "file correctly with error,%u.\n",GetLastError()); - } - - /* set the attributes of the source file to normal again */ - bRc = SetFileAttributesA(szSrcExisting, FILE_ATTRIBUTE_NORMAL); - if(!bRc) - { - Fail("CopyFileA: ERROR-> Couldn't set file attributes for " - "file %s with error %u\n", szSrcExisting, GetLastError()); - } - - /* delete the original file */ - bRc = DeleteFile(szSrcExisting); - if(!bRc) - { - Fail("CopyFileA: DeleteFile failed to delete the" - "file correctly with error,%u.\n",GetLastError()); - } - - PAL_Terminate(); - return PASS; - -} diff --git a/src/pal/tests/palsuite/file_io/CopyFileA/test3/testinfo.dat b/src/pal/tests/palsuite/file_io/CopyFileA/test3/testinfo.dat deleted file mode 100644 index 5a9775d14..000000000 --- a/src/pal/tests/palsuite/file_io/CopyFileA/test3/testinfo.dat +++ /dev/null @@ -1,16 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = CopyFileA -Name = CopyFileA - checking file attributes maintained (test2) -Type = DEFAULT -EXE1 = test3 -Description -= Test the CopyFileA function's behaviour -= for copying a file and verifying that -= the copied file has the same file attributes -= as the original. - diff --git a/src/pal/tests/palsuite/file_io/CopyFileA/test4/CMakeLists.txt b/src/pal/tests/palsuite/file_io/CopyFileA/test4/CMakeLists.txt deleted file mode 100644 index 0bb3a3277..000000000 --- a/src/pal/tests/palsuite/file_io/CopyFileA/test4/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test4.cpp -) - -add_executable(paltest_copyfilea_test4 - ${SOURCES} -) - -add_dependencies(paltest_copyfilea_test4 coreclrpal) - -target_link_libraries(paltest_copyfilea_test4 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/CopyFileA/test4/test4.cpp b/src/pal/tests/palsuite/file_io/CopyFileA/test4/test4.cpp deleted file mode 100644 index 1ae69f5e1..000000000 --- a/src/pal/tests/palsuite/file_io/CopyFileA/test4/test4.cpp +++ /dev/null @@ -1,180 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test4.c -** -** Purpose: Tests the PAL implementation of the CopyFileA function -** to see if a file can through different users belonging to -** different groups. -** - -=====================================================================*/ - -/* USECASE - Copy a file from a different user, belonging to a different group to - the the current user, who is a member of the current group. Then check - to see that the current user has the basic access rights to the copied - file. - - Thie original file used is the passwd file in the etc directory of a - BSD machine. This file should exist on all machines. -*/ - -#include - -int __cdecl main(int argc, char *argv[]) -{ - -#if WIN32 - return PASS; - -#else - - BOOL bRc = TRUE; - char* szSrcExisting = "/etc/passwd"; - char* szDest = "temp.tmp"; - char* szStringTest = "Marry had a little lamb"; - char szStringRead[30]; /* large enough for string szStringTest */ - - HANDLE hFile = NULL; - DWORD dwBytesWritten=0; - DWORD dwBytesRead=0; - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - /* copy the file */ - bRc = CopyFileA(szSrcExisting,szDest,TRUE); - if(!bRc) - { - Fail("CopyFileA: Cannot copy a file with error, %u",GetLastError()); - } - - /* try to get file attributes of destination file */ - if (GetFileAttributesA(szDest) == -1) - { - Fail("CopyFileA: GetFileAttributes of destination file " - "failed with error code %u. \n", - GetLastError()); - } - - /* set the attributes of the destination file to normal again */ - bRc = SetFileAttributes(szDest, FILE_ATTRIBUTE_NORMAL); - if(!bRc) - { - Fail("CopyFileA: ERROR-> Couldn't set file attributes for " - "file %s with error %u\n", szDest, GetLastError()); - } - - /* open the file for write purposes */ - hFile = CreateFile(szDest, - GENERIC_WRITE, - 0, - NULL, - OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL, - NULL); - - if(hFile == INVALID_HANDLE_VALUE) - { - Fail("CopyFileA: ERROR -> Unable to create file \"%s\".\n", - szDest); - } - - /* Attempt to write to the file */ - bRc = WriteFile(hFile, szStringTest, strlen(szStringTest), &dwBytesWritten, NULL); - if (!bRc) - { - Trace("CopyFileA: ERROR -> Unable to write to copied file with error " - "%u.\n", GetLastError()); - bRc = CloseHandle(hFile); - if (!bRc) - { - Fail("CopyFileA: ERROR -> Unable to close file \"%s\" with " - "error %u.\n",szDest, GetLastError()); - } - Fail(""); - - } - - /* Close the file handle */ - bRc = CloseHandle(hFile); - if (!bRc) - { - Fail("CopyFileA: ERROR -> Unable to close file \"%s\" with error %u " - ".\n",szDest,GetLastError()); - } - - - /* open the file for read purposes */ - hFile = CreateFile(szDest, - GENERIC_READ, - 0, - NULL, - OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL, - NULL); - - if(hFile == INVALID_HANDLE_VALUE) - { - Fail("CopyFileA: ERROR -> Unable to create file \"%s\".\n", - szDest); - } - - /* Attempt to read from the file */ - bRc = ReadFile(hFile, szStringRead, strlen(szStringTest), &dwBytesRead, NULL); - if (!bRc) - { - Trace("CopyFileA: ERROR -> Unable to read from copied file with " - "error %u.\n",GetLastError()); - bRc = CloseHandle(hFile); - if (!bRc) - { - Fail("CopyFileA: ERROR -> Unable to close file \"%s\" with " - "error %u.\n",szDest, GetLastError()); - } - Fail(""); - - } - - if(strncmp(szStringTest,szStringRead, strlen(szStringTest)) != 0) - { - Trace("CopyFileA: ERROR -> The string which was written '%s' does not " - "match the string '%s' which was read from the copied file.\n", - szStringTest,szStringRead); - bRc = CloseHandle(hFile); - if (!bRc) - { - Fail("CopyFileA: ERROR -> Unable to close file \"%s\" with " - "error %u.\n",szDest, GetLastError()); - } - Fail(""); - } - - /* Close the file handle */ - bRc = CloseHandle(hFile); - if (!bRc) - { - Fail("CopyFileA: ERROR -> Unable to close file \"%s\" with error %u " - ".\n",szDest,GetLastError()); - } - - /* Remove the temporary file */ - bRc = DeleteFile(szDest); - if(!bRc) - { - Fail("CopyFileA: Could not remove copied file with error %u\n", - GetLastError()); - } - - PAL_Terminate(); - return PASS; - -#endif - -} diff --git a/src/pal/tests/palsuite/file_io/CopyFileA/test4/testinfo.dat b/src/pal/tests/palsuite/file_io/CopyFileA/test4/testinfo.dat deleted file mode 100644 index 42187b760..000000000 --- a/src/pal/tests/palsuite/file_io/CopyFileA/test4/testinfo.dat +++ /dev/null @@ -1,16 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = CopyFileA -Name = CopyFileA - checking file attributes maintained (test4) -Type = DEFAULT -EXE1 = test4 -Description -= Copy a file from a different user, belonging to a different group to -= the the current user, who is a member of the current group. Then check -= to see that the current user has the basic access rights to the copied -= file. - diff --git a/src/pal/tests/palsuite/file_io/CopyFileW/CMakeLists.txt b/src/pal/tests/palsuite/file_io/CopyFileW/CMakeLists.txt deleted file mode 100644 index 1962ade35..000000000 --- a/src/pal/tests/palsuite/file_io/CopyFileW/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) -add_subdirectory(test3) - diff --git a/src/pal/tests/palsuite/file_io/CopyFileW/test1/CMakeLists.txt b/src/pal/tests/palsuite/file_io/CopyFileW/test1/CMakeLists.txt deleted file mode 100644 index 70ff478e3..000000000 --- a/src/pal/tests/palsuite/file_io/CopyFileW/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - CopyFileW.cpp -) - -add_executable(paltest_copyfilew_test1 - ${SOURCES} -) - -add_dependencies(paltest_copyfilew_test1 coreclrpal) - -target_link_libraries(paltest_copyfilew_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/CopyFileW/test1/CopyFileW.cpp b/src/pal/tests/palsuite/file_io/CopyFileW/test1/CopyFileW.cpp deleted file mode 100644 index 6127cc21b..000000000 --- a/src/pal/tests/palsuite/file_io/CopyFileW/test1/CopyFileW.cpp +++ /dev/null @@ -1,155 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: CopyFileW.c -** -** Purpose: Tests the PAL implementation of the CopyFileW function -** -** -**===================================================================*/ - -/* -1. copy an existing file to non-existant with overwrite true -2. copy an existing file to non-existant with overwrite false -3. copy an existing file to existing with overwrite true -4. copy an existing file to existing with overwrite false -5. copy non-existant file to non-existant with overwrite true -6. copy non-existant file to non-existant with overwrite false -7. copy non-existant file to existing with overwrite true -8. copy non-existant file to existing with overwrite false -*/ - -#include - -int __cdecl main(int argc, char *argv[]) -{ - LPSTR lpSource[2] = {"src_existing.tmp", "src_non-existant.tmp"}; - LPSTR lpDestination[2] = {"dst_existing.tmp", "dst_non-existant.tmp"}; - WCHAR* wcSource; - WCHAR* wcDest; - BOOL bFailIfExists[3] = {FALSE, TRUE}; - BOOL bRc = TRUE; - BOOL bSuccess = TRUE; - char results[20]; - FILE* resultsFile = NULL; - FILE* tempFile = NULL; - int nCounter = 0; - int i, j, k; - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - /* load the expected results */ - resultsFile = fopen("expectedresults.txt", "r"); - memset (results, 0, 20); - fgets(results, 20, resultsFile); - fclose(resultsFile); - - nCounter = 0; - - /* create the src_existing file */ - tempFile = fopen(lpSource[0], "w"); - if (tempFile != NULL) - { - fprintf(tempFile, "CopyFileW test file: src_existing.tmp\n"); - fclose(tempFile); - } - else - { - Fail("CopyFileW: ERROR-> Couldn't create \"src_existing.tmp\"\n"); - } - - /* create the dst_existing file */ - tempFile = fopen(lpDestination[0], "w"); - if (tempFile != NULL) - { - fprintf(tempFile, "CopyFileW test file: dst_existing.tmp\n"); - fclose(tempFile); - } - else - { - Fail("CopyFileW: ERROR-> Couldn't create \"dst_existing.tmp\"\n"); - } - - - /* lpSource loop */ - for (i = 0; i < 2; i++) - { - /* lpDestination loop */ - for (j = 0; j < 2; j++) - { - /* bFailIfExists loop */ - for (k = 0; k < 2; k++) - { - wcSource = convert(lpSource[i]); - wcDest = convert(lpDestination[j]); - bRc = CopyFileW(wcSource, - wcDest, - bFailIfExists[k]); - free(wcSource); - free(wcDest); - if (!bRc) - { - if (results[nCounter] == '1') - { - Trace("CopyFileW: FAILED: test[%d][%d][%d]\n", i, j, k); - bSuccess = FALSE; - } - } - else - { - if (results[nCounter] == '0') - { - Trace("CopyFileW: FAILED: test[%d][%d][%d]\n", i, j, k); - bSuccess = FALSE; - } - else - { - /* verify the file was moved */ - if (GetFileAttributesA(lpDestination[j]) == -1) - { - Trace("CopyFileW: GetFileAttributes of destination" - "file failed on test[%d][%d][%d] with error " - "code %ld. \n",i,j,k,GetLastError()); - bSuccess = FALSE; - } - else if (GetFileAttributesA(lpSource[i]) == -1) - { - Trace("CopyFileW: GetFileAttributes of source file " - "file failed on test[%d][%d][%d] with error " - "code %ld. \n",i,j,k,GetLastError()); - bSuccess = FALSE; - } - else - { - /* verify attributes of destination file to - source file*/ - if(GetFileAttributes(lpSource[i]) != - GetFileAttributes(lpDestination[j])) - { - Trace("CopyFileW : The file attributes of the " - "destination file do not match the file " - "attributes of the source file on test " - "[%d][%d][%d].\n",i,j,k); - bSuccess = FALSE; - } - } - } - - } - nCounter++; - /* delete file file but don't worry if it fails */ - DeleteFileA(lpDestination[1]); - } - } - } - - int exitCode = bSuccess ? PASS : FAIL; - PAL_TerminateEx(exitCode); - return exitCode; -} diff --git a/src/pal/tests/palsuite/file_io/CopyFileW/test1/ExpectedResults.txt b/src/pal/tests/palsuite/file_io/CopyFileW/test1/ExpectedResults.txt deleted file mode 100644 index 535a89fe5..000000000 --- a/src/pal/tests/palsuite/file_io/CopyFileW/test1/ExpectedResults.txt +++ /dev/null @@ -1 +0,0 @@ -10110000 \ No newline at end of file diff --git a/src/pal/tests/palsuite/file_io/CopyFileW/test1/testinfo.dat b/src/pal/tests/palsuite/file_io/CopyFileW/test1/testinfo.dat deleted file mode 100644 index b7ff6de2f..000000000 --- a/src/pal/tests/palsuite/file_io/CopyFileW/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = CopyFileW -Name = Tests CopyFileW functionality. -Type = DEFAULT -EXE1 = copyfilew -Description -= Test the CopyFileW function - diff --git a/src/pal/tests/palsuite/file_io/CopyFileW/test2/CMakeLists.txt b/src/pal/tests/palsuite/file_io/CopyFileW/test2/CMakeLists.txt deleted file mode 100644 index beebf1b86..000000000 --- a/src/pal/tests/palsuite/file_io/CopyFileW/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test2.cpp -) - -add_executable(paltest_copyfilew_test2 - ${SOURCES} -) - -add_dependencies(paltest_copyfilew_test2 coreclrpal) - -target_link_libraries(paltest_copyfilew_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/CopyFileW/test2/test2.cpp b/src/pal/tests/palsuite/file_io/CopyFileW/test2/test2.cpp deleted file mode 100644 index 5380a181c..000000000 --- a/src/pal/tests/palsuite/file_io/CopyFileW/test2/test2.cpp +++ /dev/null @@ -1,124 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test2.c -** -** Purpose: Tests the PAL implementation of the CopyFileW function -** Attempt to copy a file to itself -** -** -**===================================================================*/ - -#include - -int __cdecl main(int argc, char *argv[]) -{ - LPSTR szSrcExisting = "src_existing.tmp"; - WCHAR* wcSource; - BOOL bRc = TRUE; - FILE* tempFile = NULL; - DWORD temp; - int retCode; - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - /* create the src_existing file */ - tempFile = fopen(szSrcExisting, "w"); - if (tempFile != NULL) - { - retCode = fputs("CopyFileA test file: src_existing.tmp ", tempFile); - if(retCode < 0) - { - Fail("CopyFileW: ERROR-> Couldn't write to %s with error " - "%u.\n", szSrcExisting, GetLastError()); - } - retCode = fclose(tempFile); - if(retCode != 0) - { - Fail("CopyFileW: ERROR-> Couldn't close file: %s with error " - "%u.\n", szSrcExisting, GetLastError()); - } - } - else - { - Fail("CopyFileW: ERROR-> Couldn't create %s.\n", szSrcExisting); - } - - /* convert source string to wide character */ - wcSource = convert(szSrcExisting); - - /* Get file attributes of source */ - temp = GetFileAttributes(szSrcExisting); - if (temp == -1) - { - free(wcSource); - Fail("CopyFileW: GetFileAttributes of source file " - "failed with error code %ld. \n", - GetLastError()); - } - - /* make sure a file can't copy to itself - first testing with IfFileExists flag set to true */ - bRc = CopyFileW(wcSource,wcSource,TRUE); - if(bRc) - { - free(wcSource); - Fail("ERROR: Cannot copy a file to itself, %u",GetLastError()); - } - - /* try to get file attributes of desitnation */ - if (GetFileAttributesA(szSrcExisting) == -1) - { - free(wcSource); - Fail("CopyFileW: GetFileAttributes of destination file " - "failed with error code %ld. \n", - GetLastError()); - } - else - { - /* verify attributes of destination file to source file*/ - if(temp != GetFileAttributes(szSrcExisting)) - { - free(wcSource); - Fail("CopyFileW : The file attributes of the " - "destination file do not match the file " - "attributes of the source file.\n"); - } - } - - /* testing with IfFileExists flags set to false - should fail in Windows and pass in UNIX */ - bRc = CopyFileW(wcSource,wcSource,FALSE); - free(wcSource); - if(bRc && (GetLastError() != ERROR_ALREADY_EXISTS)) - { - Fail("ERROR: Cannot copy a file to itself, %u",GetLastError()); - } - - if (GetFileAttributesA(szSrcExisting) == -1) - { - Fail("CopyFileW: GetFileAttributes of destination file " - "failed with error code %ld. \n", - GetLastError()); - } - else - { - /* verify attributes of destination file to source file*/ - - if(temp != GetFileAttributes(szSrcExisting)) - { - Fail("CopyFileW : The file attributes of the " - "destination file do not match the file " - "attributes of the source file.\n"); - } - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/file_io/CopyFileW/test2/testinfo.dat b/src/pal/tests/palsuite/file_io/CopyFileW/test2/testinfo.dat deleted file mode 100644 index 7e1591dd7..000000000 --- a/src/pal/tests/palsuite/file_io/CopyFileW/test2/testinfo.dat +++ /dev/null @@ -1,15 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = CopyFileW -Name = Tests CopyFileW to check if file can be copied to itself. (test2) -Type = DEFAULT -EXE1 = test2 -Description -= Test the CopyFileW function -= to see the effect of copying a -= file to itself. - diff --git a/src/pal/tests/palsuite/file_io/CopyFileW/test3/CMakeLists.txt b/src/pal/tests/palsuite/file_io/CopyFileW/test3/CMakeLists.txt deleted file mode 100644 index 9e18a308e..000000000 --- a/src/pal/tests/palsuite/file_io/CopyFileW/test3/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test3.cpp -) - -add_executable(paltest_copyfilew_test3 - ${SOURCES} -) - -add_dependencies(paltest_copyfilew_test3 coreclrpal) - -target_link_libraries(paltest_copyfilew_test3 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/CopyFileW/test3/test3.cpp b/src/pal/tests/palsuite/file_io/CopyFileW/test3/test3.cpp deleted file mode 100644 index a2eb04c44..000000000 --- a/src/pal/tests/palsuite/file_io/CopyFileW/test3/test3.cpp +++ /dev/null @@ -1,196 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test4.c -** -** Purpose: Tests the PAL implementation of the CopyFileW function -** to see if a file can through different users belonging to -** different groups. -** - -=====================================================================*/ - -/* USECASE - Copy a file from a different user, belonging to a different group to - the the current user, who is a member of the current group. Then check - to see that the current user has the basic access rights to the copied - file. - - Thie original file used is the passwd file in the etc directory of a - BSD machine. This file should exist on all machines. -*/ - -#include - -int __cdecl main(int argc, char *argv[]) -{ - -#if WIN32 - return PASS; - -#else - - BOOL bRc = TRUE; - WCHAR szSrcExisting[] = {'/','e','t','c','/','p','a','s','s','w','d','\0'}; - WCHAR szDest[] = {'t','e','m','p','.','t','m','p','\0'}; - WCHAR szStringTest[] = {'M','a','r','r','y',' ','h','a','d',' ','a',' ', - 'l','i','t','t','l','e',' ','l','a','m','b','\0'}; - WCHAR szStringRead[30]; /* large enough for string szStringTest */ - - HANDLE hFile = NULL; - DWORD dwBytesWritten=0; - DWORD dwBytesRead=0; - int size=0; - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - /* copy the file */ - bRc = CopyFileW(szSrcExisting,szDest,TRUE); - if(!bRc) - { - Fail("CopyFileW: Cannot copy a file with error, %u",GetLastError()); - } - - /* try to get file attributes of destination file */ - if (GetFileAttributesW(szDest) == -1) - { - Fail("CopyFileW: GetFileAttributes of destination file " - "failed with error code %u. \n", - GetLastError()); - } - - /* set the attributes of the destination file to normal again */ - bRc = SetFileAttributesW(szDest, FILE_ATTRIBUTE_NORMAL); - if(!bRc) - { - Fail("CopyFileW: ERROR-> Couldn't set file attributes for " - "file %S with error %u\n", szDest, GetLastError()); - } - - /* open the file for write purposes */ - hFile = CreateFileW((WCHAR *)szDest, - GENERIC_WRITE, - 0, - NULL, - OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL, - NULL); - - if(hFile == INVALID_HANDLE_VALUE) - { - Fail("CopyFileW: ERROR -> Unable to create file \"%S\".\n", - szDest); - } - - /* To account for the size of a WCHAR is twice that of a char */ - size = wcslen(szStringTest); - size = size*sizeof(WCHAR); - - /* Attempt to write to the file */ - bRc = WriteFile(hFile, - szStringTest, - size, - &dwBytesWritten, - NULL); - - if (!bRc) - { - Trace("CopyFileW: ERROR -> Unable to write to copied file with error " - "%u.\n", GetLastError()); - bRc = CloseHandle(hFile); - if (!bRc) - { - Fail("CopyFileW: ERROR -> Unable to close file \"%S\" with " - "error %u.\n",szDest, GetLastError()); - } - Fail(""); - - } - - /* Close the file handle */ - bRc = CloseHandle(hFile); - if (!bRc) - { - Fail("CopyFileW: ERROR -> Unable to close file \"%S\" with error %u " - ".\n",szDest,GetLastError()); - } - - - /* open the file for read purposes */ - hFile = CreateFileW((WCHAR *)szDest, - GENERIC_READ, - 0, - NULL, - OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL, - NULL); - - if(hFile == INVALID_HANDLE_VALUE) - { - Fail("CopyFileW: ERROR -> Unable to create file \"%S\".\n", - szDest); - } - - /* Attempt to read from the file */ - bRc = ReadFile(hFile, - szStringRead, - size, - &dwBytesRead, - NULL); - - if (!bRc) - { - Trace("CopyFileW: ERROR -> Unable to read from copied file with " - "error %u.\n",GetLastError()); - bRc = CloseHandle(hFile); - if (!bRc) - { - Fail("CopyFileW: ERROR -> Unable to close file \"%S\" with " - "error %u.\n",szDest, GetLastError()); - } - Fail(""); - - } - - if(wcsncmp(szStringTest,szStringRead, wcslen(szStringTest)) != 0) - { - Trace("CopyFileW: ERROR -> The string which was written '%S' does not " - "match the string '%S' which was read from the copied file.\n", - szStringTest,szStringRead); - bRc = CloseHandle(hFile); - if (!bRc) - { - Fail("CopyFileW: ERROR -> Unable to close file \"%S\" with " - "error %u.\n",szDest, GetLastError()); - } - Fail(""); - } - - /* Close the file handle */ - bRc = CloseHandle(hFile); - if (!bRc) - { - Fail("CopyFileW: ERROR -> Unable to close file \"%S\" with error %u " - ".\n",szDest,GetLastError()); - } - - /* Remove the temporary file */ - bRc = DeleteFileW(szDest); - if(!bRc) - { - Fail("CopyFileW: Could not remove copied file with error %u.\n", - GetLastError()); - } - - PAL_Terminate(); - return PASS; - -#endif - -} diff --git a/src/pal/tests/palsuite/file_io/CopyFileW/test3/testinfo.dat b/src/pal/tests/palsuite/file_io/CopyFileW/test3/testinfo.dat deleted file mode 100644 index 9fd185dad..000000000 --- a/src/pal/tests/palsuite/file_io/CopyFileW/test3/testinfo.dat +++ /dev/null @@ -1,16 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = CopyFileW -Name = CopyFileW - checking file attributes maintained (test3) -Type = DEFAULT -EXE1 = test3 -Description -= Copy a file from a different user, belonging to a different group to -= the the current user, who is a member of the current group. Then check -= to see that the current user has the basic access rights to the copied -= file. - diff --git a/src/pal/tests/palsuite/file_io/CreateDirectoryA/CMakeLists.txt b/src/pal/tests/palsuite/file_io/CreateDirectoryA/CMakeLists.txt deleted file mode 100644 index ef14ea535..000000000 --- a/src/pal/tests/palsuite/file_io/CreateDirectoryA/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) - diff --git a/src/pal/tests/palsuite/file_io/CreateDirectoryA/test1/CMakeLists.txt b/src/pal/tests/palsuite/file_io/CreateDirectoryA/test1/CMakeLists.txt deleted file mode 100644 index 57ac44026..000000000 --- a/src/pal/tests/palsuite/file_io/CreateDirectoryA/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - CreateDirectoryA.cpp -) - -add_executable(paltest_createdirectorya_test1 - ${SOURCES} -) - -add_dependencies(paltest_createdirectorya_test1 coreclrpal) - -target_link_libraries(paltest_createdirectorya_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/CreateDirectoryA/test1/CreateDirectoryA.cpp b/src/pal/tests/palsuite/file_io/CreateDirectoryA/test1/CreateDirectoryA.cpp deleted file mode 100644 index 4082d38b3..000000000 --- a/src/pal/tests/palsuite/file_io/CreateDirectoryA/test1/CreateDirectoryA.cpp +++ /dev/null @@ -1,296 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: CreateDirectoryA.c -** -** Purpose: Tests the PAL implementation of the CreateDirectoryA function. -** -** Depends on: -** RemoveDirectoryW (since RemoveDirectoryA is unavailable) -** GetCurrentDirectoryA -** -** -**===================================================================*/ - -#include - - -/* apparently, under WIN32 the max path size is 248 but under - BSD it is _MAX_PATH */ -#if WIN32 -#define CREATE_MAX_PATH_SIZE 248 -#else -#define CREATE_MAX_PATH_SIZE _MAX_PATH -#endif - - -int __cdecl main(int argc, char *argv[]) -{ - const char* szTestDir = {"test_directory"}; - const char* szDotDir = {".dotDirectory"}; - BOOL bRc = FALSE; - BOOL bSuccess = FALSE; - const int buf_size = CREATE_MAX_PATH_SIZE + 10; - char szDirName[CREATE_MAX_PATH_SIZE + 10]; - char buffer[CREATE_MAX_PATH_SIZE + 10]; - WCHAR* pTemp = NULL; - DWORD curDirLen; - DWORD curDirectory = 1024; - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - - /* directory does not exist */ - bRc = CreateDirectoryA(szTestDir, NULL); - if (bRc == FALSE) - { - Fail("CreateDirectoryA: Failed to create \"%s\" with error code %ld\n", - szTestDir, - GetLastError()); - } - - - /* directory exists should fail */ - bRc = CreateDirectoryA(szTestDir, NULL); - if (bRc == TRUE) - { - pTemp = convert((LPSTR)szTestDir); - bRc = RemoveDirectoryW(pTemp); - free(pTemp); - if (!bRc) - { - Trace("CreateDirectoryA: RemoveDirectoryW failed to remove " - "\"%s\" with the error code %ld.\n", - szTestDir, - GetLastError()); - } - Fail("CreateDirectoryA: Succeeded creating the directory" - "\"%s\" when it exists already.\n", - szTestDir); - } - else - { - pTemp = convert((LPSTR)szTestDir); - bRc = RemoveDirectoryW(pTemp); - free(pTemp); - if (!bRc) - { - Fail("CreateDirectoryA: RemoveDirectoryW failed to remove " - "\"%s\" with the error code %ld.\n", - szTestDir, - GetLastError()); - } - } - - - /* long directory names (CREATE_MAX_PATH_SIZE - 1, CREATE_MAX_PATH_SIZE - and CREATE_MAX_PATH_SIZE + 1 characters - including terminating null char) */ - - curDirLen = GetCurrentDirectoryA(0, NULL); - - memset(szDirName, 0, buf_size); - memset(szDirName, 'a', CREATE_MAX_PATH_SIZE - 2 - curDirLen); - bRc = CreateDirectoryA(szDirName, NULL); - if (bRc == FALSE) - { - Fail("CreateDirectoryA: Failed to create a directory" - " name %d chars long with the error code %ld\n", - strlen(szDirName), - GetLastError()); - } - else - { - /* Check to see if it's possible to navigate to directory */ - GetCurrentDirectoryA(curDirectory, buffer); - bSuccess = SetCurrentDirectoryA(szDirName); - if(!bSuccess) - { - Fail("CreateDirectoryA: SetCurrentDirectoryA failed to " - "navigate to the newly created directory with error " - "code %u.\n", GetLastError()); - } - - /* Set directory back to initial directory */ - SetCurrentDirectoryA(buffer); - - pTemp = convert((LPSTR)szDirName); - bRc = RemoveDirectoryW(pTemp); - free(pTemp); - if (!bRc) - { - Fail("CreateDirectoryA: RemoveDirectoryW failed to remove " - "\"%s\" with the error code %ld.\n", - szDirName, - GetLastError()); - } - } - - - memset(szDirName, 0, buf_size); - memset(szDirName, 'a', CREATE_MAX_PATH_SIZE - 1 - curDirLen); - bRc = CreateDirectoryA(szDirName, NULL); - if (bRc == FALSE) - { - Fail("CreateDirectoryA: Failed to create a directory" - " name %d chars long with error code %ld\n", - strlen(szDirName), - GetLastError()); - } - else - { - /* Check to see if it's possible to navigate to directory */ - GetCurrentDirectoryA(curDirectory, buffer); - bSuccess = SetCurrentDirectoryA(szDirName); - if(!bSuccess) - { - Fail("CreateDirectoryA: SetCurrentDirectoryA failed to " - "navigate to the newly created directory with error " - "code %u.\n", GetLastError()); - } - - /* Set Directroy back to initial directory */ - SetCurrentDirectoryA(buffer); - - pTemp = convert(szDirName); - bRc = RemoveDirectoryW(pTemp); - free(pTemp); - if (!bRc) - { - Fail("CreateDirectoryA: RemoveDirectoryW failed to remove " - "\"%s\" with the error code %ld.\n", - szDirName, - GetLastError()); - } - } - - memset(szDirName, 0, buf_size); - memset(szDirName, 'a', CREATE_MAX_PATH_SIZE - curDirLen); - bRc = CreateDirectoryA(szDirName, NULL); - if (bRc != FALSE) - { - /* Check to see if it's possible to navigate to directory */ - GetCurrentDirectoryA(curDirectory, buffer); - bSuccess = SetCurrentDirectoryA(szDirName); - if(!bSuccess) - { - Fail("CreateDirectoryA: SetCurrentDirectoryA failed to " - "navigate to the newly created directory with error " - "code %u.\n", GetLastError()); - } - - /* set directory back to initial directory */ - SetCurrentDirectoryA(buffer); - - pTemp = convert(szDirName); - bRc = RemoveDirectoryW(pTemp); - free(pTemp); - if (!bRc) - { - Trace("CreateDirectoryA: RemoveDirectoryW failed to remove " - "\"%s\" with the error code %ld.\n", - szDirName, - GetLastError()); - } - if (strlen(szDirName) > CREATE_MAX_PATH_SIZE) - { - Fail("CreateDirectoryA: Failed because it created a directory" - " name 1 character longer (%d chars) than the max dir size " - "allowed\n", - strlen(szDirName)); - } - } - - - /* long directory name CREATE_MAX_PATH_SIZE + 3 chars including "..\" - (real path length <= CREATE_MAX_PATH_SIZE) */ - memset(szDirName, 0, buf_size); - memset(szDirName, 'a', CREATE_MAX_PATH_SIZE + 3 - 1 - curDirLen); - szDirName[0] = '.'; - szDirName[1] = '.'; - szDirName[2] = '\\'; - bRc = CreateDirectoryA(szDirName, NULL); - if (bRc == FALSE) - { - Fail("CreateDirectoryA: Failed to create a directory name more " - "than %d chars long and its real path name is less " - "than %d chars, error %u\n", - CREATE_MAX_PATH_SIZE, - CREATE_MAX_PATH_SIZE, GetLastError()); - } - else - { - /* Check to see if it's possible to navigate to directory */ - GetCurrentDirectoryA(curDirectory, buffer); - bSuccess = SetCurrentDirectoryA(szDirName); - if(!bSuccess) - { - Fail("CreateDirectoryA: SetCurrentDirectoryA failed to " - "navigate to the newly created directory with error " - "code %u.\n", GetLastError()); - } - - /* set directory back to initial directory */ - SetCurrentDirectoryA(buffer); - - pTemp = convert(szDirName); - bRc = RemoveDirectoryW(pTemp); - free(pTemp); - if (!bRc) - { - Fail("CreateDirectoryA: RemoveDirectoryW failed to remove " - " \"%s\" with the error code %ld.\n", - szDirName, - GetLastError()); - } - } - - - /* directories with dots */ - memset(szDirName, 0, buf_size); - sprintf_s(szDirName, _countof(szDirName), szDotDir); - bRc = CreateDirectoryA(szDirName, NULL); - if (bRc == FALSE) - { - Fail("CreateDirectoryA: Failed to create \"%s\" with error code %ld\n", - szDotDir, - GetLastError()); - } - else - { - - /* Check to see if it's possible to navigate to directory */ - GetCurrentDirectoryA(curDirectory, buffer); - bSuccess = SetCurrentDirectoryA(szDirName); - if(!bSuccess) - { - Fail("CreateDirectoryA: SetCurrentDirectoryA failed to " - "navigate to the newly created directory with error " - "code %u.\n", GetLastError()); - } - - /* set directory back to initial directory */ - SetCurrentDirectoryA(buffer); - - pTemp = convert((LPSTR)szDotDir); - bRc = RemoveDirectoryW(pTemp); - free(pTemp); - if (!bRc) - { - Fail("CreateDirectoryA: RemoveDirectoryW failed to remove " - " \"%s\" with the error code %ld.\n", - szDotDir, - GetLastError()); - } - } - - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/file_io/CreateDirectoryA/test1/testinfo.dat b/src/pal/tests/palsuite/file_io/CreateDirectoryA/test1/testinfo.dat deleted file mode 100644 index 562d76d7b..000000000 --- a/src/pal/tests/palsuite/file_io/CreateDirectoryA/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = CreateDirectoryA -Name = Test for CreateDirectoryA -Type = DEFAULT -EXE1 = createdirectorya -Description -= Create a directory that exists (should fail) and create -= a directory that doesn't exist and verify results. diff --git a/src/pal/tests/palsuite/file_io/CreateDirectoryA/test2/CMakeLists.txt b/src/pal/tests/palsuite/file_io/CreateDirectoryA/test2/CMakeLists.txt deleted file mode 100644 index b76414585..000000000 --- a/src/pal/tests/palsuite/file_io/CreateDirectoryA/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - createdirectorya.cpp -) - -add_executable(paltest_createdirectorya_test2 - ${SOURCES} -) - -add_dependencies(paltest_createdirectorya_test2 coreclrpal) - -target_link_libraries(paltest_createdirectorya_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/CreateDirectoryA/test2/createdirectorya.cpp b/src/pal/tests/palsuite/file_io/CreateDirectoryA/test2/createdirectorya.cpp deleted file mode 100644 index fc1bc967b..000000000 --- a/src/pal/tests/palsuite/file_io/CreateDirectoryA/test2/createdirectorya.cpp +++ /dev/null @@ -1,335 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: createdirectorya.c -** -** Purpose: Tests the PAL implementation of the CreateDirectoryA function. -** Test creating a directory in a directory path that does not exist. -** Test creating directory with trailing slashes. -** -** Depends on: -** RemoveDirectoryW (since RemoveDirectoryA is unavailable) -** -** -**==========================================================================*/ - - - -#include - -int main(int argc, char *argv[]) -{ - -#if WIN32 - const char* szTestRootDir = {"/at_root_directory_PALTEST"}; -#endif - - const char* szTestDir = {"test_ directory"}; - const char* szTestSubDir = - {".\\./././../test2/./../../////////createdirectorya" - "\\\\/test2/test_ directory\\sub"}; - const char* szTest2SubDir = {"test_ directory/sub\\sub_sub"}; - const char* szTest2SubDirWinSlash = - {"test_ directory/sub\\sub_sub\\"}; - const char* szTest2SubDirUnixSlash = - {"test_ directory/sub\\sub_sub/////"}; - BOOL bRc = FALSE; - BOOL clean = TRUE; - WCHAR* pTemp = NULL; - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - /* platform dependent cases */ - /* test for WIN32, create directory at the root." - * using '/directory_name ' format */ -#if WIN32 - - bRc = CreateDirectoryA(szTestRootDir, NULL); - - if (bRc != TRUE) - { - Fail("CreateDirectoryA: Failed creating the directory " - "\"%s\" with the error code %ld.\n", - szTestRootDir,GetLastError()); - } - - /* clean szTestRootDir */ - pTemp = convert((LPSTR) szTestRootDir); - bRc = RemoveDirectoryW(pTemp); - free(pTemp); - - if (! bRc) - { - clean=bRc; - Trace("CreateDirectoryA: RemoveDirectoryW failed to remove " - "\"%s\" with the error code %ld.\n", - szTestRootDir, - GetLastError()); - } - -#endif - - - /* - * create subdirectory "test_directory//sub//sub_sub" - * while parent directory does not exist. - */ - bRc = CreateDirectoryA(szTest2SubDir, NULL); - if (bRc == TRUE) - { - pTemp = convert((LPSTR)szTest2SubDir); - bRc = RemoveDirectoryW(pTemp); - free(pTemp); - if (!bRc) - { - Trace("CreateDirectoryA: RemoveDirectoryW failed to remove " - "\"%s\" with the error code %ld.\n", - szTest2SubDir, - GetLastError()); - } - Fail("CreateDirectoryA: Succeeded creating the directory\"%s\" while" - " its parent directory does not exists. It should fail.\n", - szTest2SubDir); - - } - - - /* create directory tree one by one - * first create "test_dir" - */ - bRc = CreateDirectoryA(szTestDir, NULL); - - if (bRc != TRUE)/*failed creating the path*/ - { - Fail("CreateDirectoryA: Failed creating the directory " - "\"%s\" with the error code %ld.\n", szTestDir,GetLastError()); - } - - /* create the sub directory test_directory//sub */ - bRc = CreateDirectoryA(szTestSubDir, NULL); - - if (bRc != TRUE)/*failed creating the path*/ - { - Trace("CreateDirectoryA: Failed creating the directory " - "\"%s\" with the error code %ld.\n", - szTestSubDir , GetLastError()); - - /* cleaning... remove parent directory */ - pTemp = convert((LPSTR)szTestDir); - bRc = RemoveDirectoryW(pTemp); - free(pTemp); - if (!bRc) - { - Trace("CreateDirectoryA: RemoveDirectoryW failed to remove " - "\"%s\" with an error code %ld.\n", - szTestDir, - GetLastError()); - } - Fail(""); - } - - /* - * the director structure is test_directory//sub - * test creating directory " test_directory//sub//sub_sub" - */ - bRc = CreateDirectoryA(szTest2SubDir, NULL); - if (bRc != TRUE) - { - Trace("CreateDirectoryA: Failed creating the directory " - "\"%s\" with the error code %ld.\n", - szTest2SubDir , GetLastError()); - - /* remove parent directory test_directory//sub */ - pTemp = convert((LPSTR)szTestSubDir); - bRc = RemoveDirectoryW(pTemp); - free(pTemp); - if (!bRc) - { - Trace("CreateDirectoryA: RemoveDirectoryW failed to remove " - "\"%s\" with the error code %ld.\n", - szTestSubDir, - GetLastError()); - } - - /* remove parent directory test_directory */ - pTemp = convert((LPSTR)szTestDir); - bRc = RemoveDirectoryW(pTemp); - free(pTemp); - if (! bRc) - { - Trace("CreateDirectoryA: RemoveDirectoryW failed to remove " - "\"%s\" with the error code %ld.\n", - szTestDir, - GetLastError()); - } - Fail(""); - - } - - /* RemoveDirectiryW szTest2SubDir */ - pTemp = convert((LPSTR)szTest2SubDir); - bRc = RemoveDirectoryW(pTemp); - free(pTemp); - - if (! bRc) - { - clean=bRc; - Trace("CreateDirectoryA: RemoveDirectoryW failed to remove " - "\"%s\" with the error code %ld.\n", - szTest2SubDir, - GetLastError()); - } - - - /* - * the director structure is test_directory//sub - * test creating directory " test_directory//sub//sub_sub\\" - */ - bRc = CreateDirectoryA(szTest2SubDirWinSlash, NULL); - if (bRc != TRUE) - { - Trace("CreateDirectoryA: Failed creating the directory " - "\"%s\" with the error code %ld.\n", - szTest2SubDirWinSlash , GetLastError()); - - /* remove parent directory test_directory//sub */ - pTemp = convert((LPSTR)szTestSubDir); - bRc = RemoveDirectoryW(pTemp); - free(pTemp); - if (! bRc) - { - Trace("CreateDirectoryA: RemoveDirectoryW failed to remove " - "\"%s\" with the error code %ld.\n", - szTestSubDir, - GetLastError()); - } - - /* remove parent directory test_directory */ - pTemp = convert((LPSTR)szTestDir); - bRc = RemoveDirectoryW(pTemp); - free(pTemp); - if (! bRc) - { - Trace("CreateDirectoryA: RemoveDirectoryW failed to remove " - "\"%s\" with the error code %ld.\n", - szTestDir, - GetLastError()); - } - Fail(""); - - } - - /* RemoveDirectiryW szTest2SubDirWinSlash */ - pTemp = convert((LPSTR)szTest2SubDirWinSlash); - bRc = RemoveDirectoryW(pTemp); - free(pTemp); - - if (! bRc) - { - clean=bRc; - Trace("CreateDirectoryA: RemoveDirectoryW failed to remove " - "\"%s\" with the error code %ld.\n", - szTest2SubDirWinSlash, - GetLastError()); - } - - /* - * the director structure is test_directory//sub - * test creating directory " test_directory//sub//sub_sub/////" - */ - bRc = CreateDirectoryA(szTest2SubDirUnixSlash, NULL); - if (bRc != TRUE) - { - Trace("CreateDirectoryA: Failed creating the directory " - "\"%s\" with the error code %ld.\n", - szTest2SubDirUnixSlash , GetLastError()); - - /* remove parent directory test_directory//sub */ - pTemp = convert((LPSTR)szTestSubDir); - bRc = RemoveDirectoryW(pTemp); - free(pTemp); - if (! bRc) - { - Trace("CreateDirectoryA: RemoveDirectoryW failed to remove " - "\"%s\" with the error code %ld.\n", - szTestSubDir, - GetLastError()); - } - - /* remove parent directory test_directory */ - pTemp = convert((LPSTR)szTestDir); - bRc = RemoveDirectoryW(pTemp); - free(pTemp); - if (! bRc) - { - Trace("CreateDirectoryA: RemoveDirectoryW failed to remove " - "\"%s\" with the error code %ld.\n", - szTestDir, - GetLastError()); - } - Fail(""); - - } - - /* RemoveDirectiryW will return false if directory does not exist. - * if it returns true then test is completed and the directory path - * is clean for running the test again. - */ - pTemp = convert((LPSTR)szTest2SubDirUnixSlash); - bRc = RemoveDirectoryW(pTemp); - free(pTemp); - - if (! bRc) - { - clean=bRc; - Trace("CreateDirectoryA: RemoveDirectoryW failed to remove " - "\"%s\" with the error code %ld.\n", - szTest2SubDirUnixSlash, - GetLastError()); - } - - - - - /*clean parent szTestSubDir */ - pTemp = convert((LPSTR)szTestSubDir); - bRc = RemoveDirectoryW(pTemp); - free(pTemp); - - if (! bRc) - { - clean = bRc; - Trace("CreateDirectoryA: RemoveDirectoryW failed to remove " - "\"%s\" with the error code %ld.\n", - szTestSubDir, - GetLastError()); - } - - /*clean parent szTestDir */ - pTemp = convert((LPSTR)szTestDir); - bRc = RemoveDirectoryW(pTemp); - free(pTemp); - - if (! bRc) - { - clean = bRc; - Trace("CreateDirectoryA: RemoveDirectoryW failed to remove " - "\"%s\" with the error code %ld.\n", - szTestDir, - GetLastError()); - } - - if(! clean) - { - Fail(""); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/file_io/CreateDirectoryA/test2/testinfo.dat b/src/pal/tests/palsuite/file_io/CreateDirectoryA/test2/testinfo.dat deleted file mode 100644 index 1e2ae774d..000000000 --- a/src/pal/tests/palsuite/file_io/CreateDirectoryA/test2/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = CreateDirectoryA -Name = Test for CreateDirectoryA -Type = DEFAULT -EXE1 = createdirectorya -Description -= Call CreateDirectoryA with a path in which more than just -= the last component doesn't exist. diff --git a/src/pal/tests/palsuite/file_io/CreateDirectoryW/CMakeLists.txt b/src/pal/tests/palsuite/file_io/CreateDirectoryW/CMakeLists.txt deleted file mode 100644 index ef14ea535..000000000 --- a/src/pal/tests/palsuite/file_io/CreateDirectoryW/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) - diff --git a/src/pal/tests/palsuite/file_io/CreateDirectoryW/test1/CMakeLists.txt b/src/pal/tests/palsuite/file_io/CreateDirectoryW/test1/CMakeLists.txt deleted file mode 100644 index 1fd09ea82..000000000 --- a/src/pal/tests/palsuite/file_io/CreateDirectoryW/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - CreateDirectoryW.cpp -) - -add_executable(paltest_createdirectoryw_test1 - ${SOURCES} -) - -add_dependencies(paltest_createdirectoryw_test1 coreclrpal) - -target_link_libraries(paltest_createdirectoryw_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/CreateDirectoryW/test1/CreateDirectoryW.cpp b/src/pal/tests/palsuite/file_io/CreateDirectoryW/test1/CreateDirectoryW.cpp deleted file mode 100644 index bbaedda74..000000000 --- a/src/pal/tests/palsuite/file_io/CreateDirectoryW/test1/CreateDirectoryW.cpp +++ /dev/null @@ -1,347 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: CreateDirectoryW.c -** -** Purpose: Tests the PAL implementation of the CreateDirectoryW function. -** -** -**===================================================================*/ - -#include - - -/* apparently, under WIN32 the max path size is 248 but under - BSD it is _MAX_PATH */ -#if WIN32 -#define CREATE_MAX_PATH_SIZE 248 -#else -#define CREATE_MAX_PATH_SIZE _MAX_PATH -#endif - - -int __cdecl main(int argc, char *argv[]) -{ - BOOL bRc = FALSE; - BOOL bSuccess = FALSE; - const int buf_size = CREATE_MAX_PATH_SIZE + 10; - char szDirName[CREATE_MAX_PATH_SIZE + 10]; - char buffer[CREATE_MAX_PATH_SIZE + 10]; - WCHAR* pTemp = NULL; - DWORD curDirLen; - DWORD curDirectory = 1024; - - - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - /* directory does not exist */ - pTemp = convert("test_directory"); - bRc = CreateDirectoryW(pTemp, NULL); - free(pTemp); - if (bRc == FALSE) - { - Fail("CreateDirectoryW: Failed to create \"test_directory\"\n"); - } - - /* directory exists */ - pTemp = convert("test_directory"); - bRc = CreateDirectoryW(pTemp, NULL); - if (bRc == TRUE) - { - bRc = RemoveDirectoryW(pTemp); - if(!bRc) - { - free(pTemp); - Fail("CreateDirectoryW: RemoveDirectoryW failed to " - "delete the directory with error %u.\n", - GetLastError()); - } - free(pTemp); - Fail("CreateDirectoryW: Succeeded creating the directory" - " \"test_directory\" when it exists already.\n"); - } - - bRc = RemoveDirectoryW(pTemp); - if(!bRc) - { - free(pTemp); - Fail("CreateDirectoryW: RemoveDirectoryW failed to " - "delete the directory with error %u.\n", - GetLastError()); - } - free(pTemp); - - /* long directory names (CREATE_MAX_PATH_SIZE - 1, CREATE_MAX_PATH_SIZE - and CREATE_MAX_PATH_SIZE + 1 characters - including terminating null char) */ - - curDirLen = GetCurrentDirectoryA(0, NULL); - - memset(szDirName, 0, buf_size); - memset(szDirName, 'a', CREATE_MAX_PATH_SIZE - 2 - curDirLen); - pTemp = convert((LPSTR)szDirName); - bRc = CreateDirectoryW(pTemp, NULL); - if (bRc == FALSE) - { - free(pTemp); - Fail("CreateDirectoryW: Failed to create a directory" - " name (%d) chars long with the error code %ld\n", - CREATE_MAX_PATH_SIZE - 1, - GetLastError()); - } - else - { - - /* Check to see if it's possible to navigate to directory */ - GetCurrentDirectoryA(curDirectory, buffer); - bSuccess = SetCurrentDirectoryA(szDirName); - if(!bSuccess) - { - Trace("CreateDirectoryW: SetCurrentDirectoryA failed to " - "navigate to the newly created directory with error " - "code %u.\n", GetLastError()); - bRc = RemoveDirectoryW(pTemp); - if(!bRc) - { - free(pTemp); - Fail("CreateDirectoryW: RemoveDirectoryW failed to " - "delete the directory with error %u.\n", - GetLastError()); - } - free(pTemp); - Fail(""); - - } - - /* Set directory back to initial directory */ - bRc = SetCurrentDirectoryA(buffer); - if(!bRc) - { - free(pTemp); - Fail("CreateDirectoryW: SetCurrentDirectoryA failed to " - "change the directory with error %u.\n", - GetLastError()); - } - - bRc = RemoveDirectoryW(pTemp); - if(!bRc) - { - free(pTemp); - Fail("CreateDirectoryW: RemoveDirectoryW failed to " - "delete the directory with error %u.\n", - GetLastError()); - } - free(pTemp); - } - - - memset(szDirName, 0, buf_size); - memset(szDirName, 'a', CREATE_MAX_PATH_SIZE - 1 - curDirLen); - pTemp = convert(szDirName); - bRc = CreateDirectoryW(pTemp, NULL); - if (bRc == FALSE) - { - free(pTemp); - Fail("CreateDirectoryW: Failed to create a directory" - " name %d chars long with error code %ld\n", - strlen(szDirName), - GetLastError()); - } - else - { - /* Check to see if it's possible to navigate to directory */ - GetCurrentDirectoryA(curDirectory, buffer); - bSuccess = SetCurrentDirectoryA(szDirName); - if(!bSuccess) - { - Trace("CreateDirectoryW: SetCurrentDirectoryA failed to " - "navigate to the newly created directory with error " - "code %u.\n", GetLastError()); - - bRc = RemoveDirectoryW(pTemp); - if(!bRc) - { - free(pTemp); - Fail("CreateDirectoryW: RemoveDirectoryW failed to " - "delete the directory with error %u.\n", - GetLastError()); - } - free(pTemp); - Fail(""); - } - - /* Set directory back to initial directory */ - bRc = SetCurrentDirectoryA(buffer); - if(!bRc) - { - free(pTemp); - Fail("CreateDirectoryW: SetCurrentDirectoryA failed to " - "change the directory with error %u.\n", - GetLastError()); - } - - - bRc = RemoveDirectoryW(pTemp); - if(!bRc) - { - free(pTemp); - Fail("CreateDirectoryW: RemoveDirectoryW failed to " - "delete the directory with error %u.\n", - GetLastError()); - } - free(pTemp); - } - - memset(szDirName, 0, buf_size); - memset(szDirName, 'a', CREATE_MAX_PATH_SIZE - curDirLen); - pTemp = convert(szDirName); - bRc = CreateDirectoryW(pTemp, NULL); - - if (bRc != FALSE) - { - RemoveDirectoryW(pTemp); - if(!bRc) - { - free(pTemp); - Fail("CreateDirectoryW: RemoveDirectoryW failed to " - "delete the directory with error %u.\n", - GetLastError()); - } - if (strlen(szDirName) > CREATE_MAX_PATH_SIZE) - { - free(pTemp); - Fail("CreateDirectoryW: Failed because it created a directory" - " name 1 character longer (%d chars) than the max dir size" - " allowed\n", - strlen(szDirName)); - } - } - - free(pTemp); - - /* long directory name CREATE_MAX_PATH_SIZE + 3 chars including "..\" - (real path length <= CREATE_MAX_PATH_SIZE) */ - memset(szDirName, 0, buf_size); - memset(szDirName, 'a', CREATE_MAX_PATH_SIZE + 3 - 1 - curDirLen); - szDirName[0] = '.'; - szDirName[1] = '.'; - szDirName[2] = '\\'; - pTemp = convert(szDirName); - bRc = CreateDirectoryW(pTemp, NULL); - if (bRc == FALSE) - { - free(pTemp); - Fail("CreateDirectoryW: Failed to create a directory name more " - "than %d chars long and its real path name is less " - "than %d chars\n", - CREATE_MAX_PATH_SIZE, - CREATE_MAX_PATH_SIZE); - } - else - { - /* Check to see if it's possible to navigate to directory */ - GetCurrentDirectoryA(curDirectory, buffer); - bSuccess = SetCurrentDirectoryA(szDirName); - if(!bSuccess) - { - Trace("CreateDirectoryW: SetCurrentDirectoryA failed to " - "navigate to the newly created directory with error " - "code %u.\n", GetLastError()); - bRc = RemoveDirectoryW(pTemp); - if(!bRc) - { - free(pTemp); - Fail("CreateDirectoryW: RemoveDirectoryW failed to " - "delete the directory with error %u.\n", - GetLastError()); - } - free(pTemp); - Fail(""); - } - - /* Set directory back to initial directory */ - bRc = SetCurrentDirectoryA(buffer); - if(!bRc) - { - free(pTemp); - Fail("CreateDirectoryW: SetCurrentDirectoryA failed to " - "change the directory with error %u.\n", - GetLastError()); - } - - bRc = RemoveDirectoryW(pTemp); - if(!bRc) - { - free(pTemp); - Fail("CreateDirectoryW: RemoveDirectoryW failed to " - "delete the directory with error %u.\n", - GetLastError()); - } - free(pTemp); - } - - /* directories with dots */ - memset(szDirName, 0, 252); - sprintf_s(szDirName, _countof(szDirName), ".dotDirectory"); - pTemp = convert(szDirName); - bRc = CreateDirectoryW(pTemp, NULL); - if (bRc == FALSE) - { - free(pTemp); - Fail("CreateDirectoryW: Failed to create a dot directory\n"); - } - else - { - /* Check to see if it's possible to navigate to directory */ - GetCurrentDirectoryA(curDirectory, buffer); - bSuccess = SetCurrentDirectoryA(szDirName); - if(!bSuccess) - { - Trace("CreateDirectoryW: SetCurrentDirectoryA failed to " - "navigate to the newly created directory with error " - "code %u.\n", GetLastError()); - - bRc = RemoveDirectoryW(pTemp); - if(!bRc) - { - free(pTemp); - Fail("CreateDirectoryW: RemoveDirectoryW failed to " - "delete the directory with error %u.\n", - GetLastError()); - } - free(pTemp); - Fail(""); - } - - /* Set directory back to initial directory */ - bRc = SetCurrentDirectoryA(buffer); - if(!bRc) - { - free(pTemp); - Fail("CreateDirectoryW: SetCurrentDirectoryA failed to " - "change the directory with error %u.\n", - GetLastError()); - } - - bRc = RemoveDirectoryW(pTemp); - if(!bRc) - { - free(pTemp); - Fail("CreateDirectoryW: RemoveDirectoryW failed to " - "delete the directory with error %u.\n", - GetLastError()); - } - free(pTemp); - } - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/file_io/CreateDirectoryW/test1/testinfo.dat b/src/pal/tests/palsuite/file_io/CreateDirectoryW/test1/testinfo.dat deleted file mode 100644 index bc664892b..000000000 --- a/src/pal/tests/palsuite/file_io/CreateDirectoryW/test1/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = CreateDirectoryW -Name = Positive Test for CreateDirectoryW -Type = DEFAULT -EXE1 = createdirectoryw -Description -= Test the CreateDirctoryW function diff --git a/src/pal/tests/palsuite/file_io/CreateDirectoryW/test2/CMakeLists.txt b/src/pal/tests/palsuite/file_io/CreateDirectoryW/test2/CMakeLists.txt deleted file mode 100644 index 2dcfe6d49..000000000 --- a/src/pal/tests/palsuite/file_io/CreateDirectoryW/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - createdirectoryw.cpp -) - -add_executable(paltest_createdirectoryw_test2 - ${SOURCES} -) - -add_dependencies(paltest_createdirectoryw_test2 coreclrpal) - -target_link_libraries(paltest_createdirectoryw_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/CreateDirectoryW/test2/createdirectoryw.cpp b/src/pal/tests/palsuite/file_io/CreateDirectoryW/test2/createdirectoryw.cpp deleted file mode 100644 index 20fac5a87..000000000 --- a/src/pal/tests/palsuite/file_io/CreateDirectoryW/test2/createdirectoryw.cpp +++ /dev/null @@ -1,345 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: createdirectoryw.c -** -** Purpose: Tests the PAL implementation of the CreateDirectoryW function. -** Test creating a directory in a directory path that does not exist. -** Test creating directory with trailing slashes. -** -** Depends on: -** RemoveDirectoryW. -** -** -**==========================================================================*/ - -#include - -#if WIN32 -WCHAR* szTestRootDir = NULL; -#endif - -WCHAR* szTestDir = NULL; -WCHAR* szTestSubDir = NULL; -WCHAR* szTest2SubDir = NULL; -WCHAR* szTest2SubDirWinSlash = NULL; -WCHAR* szTest2SubDirUnixSlash = NULL; - - -/* Free the memory allocated by convert(...) function*/ -static void CleanMemory(){ - -#if WIN32 - free(szTestRootDir); -#endif - - free( szTestDir); - free( szTestSubDir); - free( szTest2SubDir); - free( szTest2SubDirWinSlash); - free( szTest2SubDirUnixSlash); - -} - - -int main(int argc, char *argv[]) -{ - BOOL bRc = FALSE; - BOOL clean = TRUE; - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - /* initialize strings */ - -#if WIN32 - szTestRootDir = convert("/at_root_directory_PALTEST"); -#endif - - szTestDir = convert("test_ directory"); - szTestSubDir = convert( - ".\\./././../test2/./../../////////createdirectoryw" - "\\\\/test2/test_ directory\\sub"); - szTest2SubDir = convert("test_ directory/sub\\sub_sub"); - szTest2SubDirWinSlash = convert("test_ directory/sub\\sub_sub\\\\"); - szTest2SubDirUnixSlash = convert("test_ directory/sub\\sub_sub///"); - - - /* Platform dependent cases:- - * test for WIN32, create directory at the root. - * using /directory_name format - */ -#if WIN32 - - bRc = CreateDirectoryW(szTestRootDir, NULL); - - if (bRc != TRUE) - { - - Trace("CreateDirectoryW: Failed creating the directory " - "\"%S\" with the error code %ld.\n", - szTestRootDir,GetLastError()); - CleanMemory(); - Fail(""); - } - - /*clean szTestRootDir */ - bRc = RemoveDirectoryW(szTestRootDir); - - if (! bRc) - { - clean = bRc; - Trace("CreateDirectoryW: RemoveDirectoryW failed to remove " - "\"%S\" with the error code %ld.\n", - szTestRootDir, - GetLastError()); - } - -#endif - - - /* - * create subdirectory "test_directory//sub//sub_sub" - * while parent directory does not exist. - */ - bRc = CreateDirectoryW(szTest2SubDir, NULL); - if (bRc == TRUE) - { - bRc = RemoveDirectoryW(szTest2SubDir); - - if (! bRc ) - { - Trace("CreateDirectoryW: RemoveDirectoryW failed to remove " - "\"%S\" with the error code %ld.\n", - szTest2SubDir, - GetLastError()); - } - - Trace("CreateDirectoryW: Succeeded creating the directory\"%S\" while" - " its parent directory does not exists. It should fail.\n", - szTest2SubDir); - CleanMemory(); - Fail(""); - - } - - - /* create directory tree one by one - * first create "test_dir" - */ - bRc = CreateDirectoryW(szTestDir, NULL); - - - if (bRc != TRUE)/*failed creating the path*/ - { - - Trace("CreateDirectoryW: Failed creating the directory " - "\"%S\" with the error code %ld.\n", szTestDir,GetLastError()); - CleanMemory(); - Fail(""); - } - - /* create the sub directory test_directory//sub */ - bRc = CreateDirectoryW(szTestSubDir, NULL); - - if (bRc != TRUE)/*failed creating the path*/ - { - Trace("CreateDirectoryW: Failed creating the directory " - "\"%S\" with the error code %ld.\n", - szTestSubDir , GetLastError()); - - /* cleaning... remove parent directory */ - bRc = RemoveDirectoryW(szTestDir); - if (! bRc) - { - Trace("CreateDirectoryW: RemoveDirectoryW failed to remove " - "\"%S\" with an error code %ld.\n", - szTestDir, - GetLastError()); - } - CleanMemory(); - Fail(""); - } - - /* - * the director structure is test_directory//sub - * test creating directory " test_directory//sub//sub_sub" - */ - bRc = CreateDirectoryW(szTest2SubDir, NULL); - if (bRc != TRUE) - { - Trace("CreateDirectoryW: Failed creating the directory " - "\"%S\" with the error code %ld.\n", - szTest2SubDir , GetLastError()); - - /* remove parent directory test_directory//sub */ - bRc = RemoveDirectoryW(szTestSubDir); - if (! bRc) - { - Trace("CreateDirectoryW: RemoveDirectoryW failed to remove " - "\"%S\" with the error code %ld.\n", - szTestSubDir, - GetLastError()); - } - - /* remove parent directory test_directory */ - bRc = RemoveDirectoryW(szTestDir); - if (! bRc) - { - Trace("CreateDirectoryW: RemoveDirectoryW failed to remove " - "\"%S\" with the error code %ld.\n", - szTestDir, - GetLastError()); - } - CleanMemory(); - Fail(""); - - } - - /* Remove Directiry szTest2SubDir*/ - bRc = RemoveDirectoryW(szTest2SubDir); - - if (! bRc) - { - clean = bRc; - Trace("CreateDirectoryW: RemoveDirectoryW failed to remove " - "\"%S\" with the error code %ld.\n", - szTest2SubDir, - GetLastError()); - } - - /* - * the director structure is test_directory//sub - * test creating directory " test_directory//sub//sub_sub\\\\" - */ - bRc = CreateDirectoryW(szTest2SubDirWinSlash, NULL); - if (bRc != TRUE) - { - Trace("CreateDirectoryW: Failed creating the directory " - "\"%S\" with the error code %ld.\n", - szTest2SubDirWinSlash , GetLastError()); - - /* remove parent directory test_directory//sub */ - bRc = RemoveDirectoryW(szTestSubDir); - if (! bRc) - { - Trace("CreateDirectoryW: RemoveDirectoryW failed to remove " - "\"%S\" with the error code %ld.\n", - szTestSubDir, - GetLastError()); - } - - /* remove parent directory test_directory */ - bRc = RemoveDirectoryW(szTestDir); - if (! bRc) - { - Trace("CreateDirectoryW: RemoveDirectoryW failed to remove " - "\"%S\" with the error code %ld.\n", - szTestDir, - GetLastError()); - } - CleanMemory(); - Fail(""); - - } - - /* Remove Directiry szTest2SubDirWinSlash */ - bRc = RemoveDirectoryW(szTest2SubDirWinSlash); - - if (! bRc) - { - clean = bRc; - Trace("CreateDirectoryW: RemoveDirectoryW failed to remove " - "\"%S\" with the error code %ld.\n", - szTest2SubDirWinSlash, - GetLastError()); - } - - /* - * the director structure is test_directory//sub - * test creating directory " test_directory//sub//sub_sub///" - */ - bRc = CreateDirectoryW(szTest2SubDirUnixSlash, NULL); - if (bRc != TRUE) - { - Trace("CreateDirectoryW: Failed creating the directory " - "\"%S\" with the error code %ld.\n", - szTest2SubDirUnixSlash , GetLastError()); - - /* remove parent directory test_directory//sub */ - bRc = RemoveDirectoryW(szTestSubDir); - if (! bRc) - { - Trace("CreateDirectoryW: RemoveDirectoryW failed to remove " - "\"%S\" with the error code %ld.\n", - szTestSubDir, - GetLastError()); - } - - /* remove parent directory test_directory */ - bRc = RemoveDirectoryW(szTestDir); - if (! bRc) - { - Trace("CreateDirectoryW: RemoveDirectoryW failed to remove " - "\"%S\" with the error code %ld.\n", - szTestDir, - GetLastError()); - } - CleanMemory(); - Fail(""); - - } - - /* Remove Directiry szTest2SubDirUnixSlash.*/ - bRc = RemoveDirectoryW(szTest2SubDirUnixSlash); - - if (! bRc) - { - clean = bRc; - Trace("CreateDirectoryW: RemoveDirectoryW failed to remove " - "\"%S\" with the error code %ld.\n", - szTest2SubDirUnixSlash, - GetLastError()); - } - - /*clean parent szTestSubDir */ - bRc = RemoveDirectoryW(szTestSubDir); - - if (! bRc) - { - clean = bRc; - Trace("CreateDirectoryW: RemoveDirectoryW failed to remove " - "\"%S\" with the error code %ld.\n", - szTestSubDir, - GetLastError()); - } - - /*clean parent szTestDir */ - bRc = RemoveDirectoryW(szTestDir); - - - if (! bRc) - { - clean = bRc; - Trace("CreateDirectoryW: RemoveDirectoryW failed to remove " - "\"%S\" with the error code %ld.\n", - szTestDir, - GetLastError()); - } - - if(! clean) - { - CleanMemory(); - Fail(""); - } - - CleanMemory(); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/file_io/CreateDirectoryW/test2/testinfo.dat b/src/pal/tests/palsuite/file_io/CreateDirectoryW/test2/testinfo.dat deleted file mode 100644 index 0d98a5f3b..000000000 --- a/src/pal/tests/palsuite/file_io/CreateDirectoryW/test2/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = CreateDirectoryW -Name = Test for CreateDirectoryW -Type = DEFAULT -EXE1 = createdirectoryW -Description -= Call CreateDirectoryW with a path in which more than just -= the last component doesn't exist. diff --git a/src/pal/tests/palsuite/file_io/CreateFileA/CMakeLists.txt b/src/pal/tests/palsuite/file_io/CreateFileA/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/file_io/CreateFileA/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/file_io/CreateFileA/test1/CMakeLists.txt b/src/pal/tests/palsuite/file_io/CreateFileA/test1/CMakeLists.txt deleted file mode 100644 index dec8c3055..000000000 --- a/src/pal/tests/palsuite/file_io/CreateFileA/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - CreateFileA.cpp -) - -add_executable(paltest_createfilea_test1 - ${SOURCES} -) - -add_dependencies(paltest_createfilea_test1 coreclrpal) - -target_link_libraries(paltest_createfilea_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/CreateFileA/test1/CreateFileA.cpp b/src/pal/tests/palsuite/file_io/CreateFileA/test1/CreateFileA.cpp deleted file mode 100644 index f98fc5b9c..000000000 --- a/src/pal/tests/palsuite/file_io/CreateFileA/test1/CreateFileA.cpp +++ /dev/null @@ -1,145 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: CreateFileA.c -** -** Purpose: Test the PAL implementation of the CreateFileA function -** -** -**===================================================================*/ - -#include - -BOOL Cleanup(void) -{ - char FileName[20]; - int i; - BOOL bRet = TRUE; // assume success - - // loop through all accesses, modes, dispositions and flags - for (i=0; i<4*8*4*5; ++i) { - sprintf_s(FileName, _countof(FileName), "test%03d.txt", i); - if (DeleteFileA(FileName) == FALSE) { - if (GetLastError() != ERROR_FILE_NOT_FOUND) { - bRet = FALSE; - } - } - } - return bRet; -} - - -int __cdecl main(int argc, char *argv[]) -{ - BOOL bSuccess = TRUE; - int nCounter = 0; - HANDLE hFile; - char lpFileName[20]; - FILE *outFile = NULL; - char results[1024]; - int i, j, k, l; - DWORD dwDesiredAccess[4] = {0, // 0 - GENERIC_READ, // 1 - GENERIC_WRITE, // 2 - GENERIC_READ | GENERIC_WRITE}; // 3 - DWORD dwShareMode[8] = {0, // 0 - FILE_SHARE_READ, // 1 - FILE_SHARE_WRITE, // 2 - FILE_SHARE_DELETE, // 3 - FILE_SHARE_READ | FILE_SHARE_WRITE, // 4 - FILE_SHARE_READ | FILE_SHARE_DELETE, // 5 - FILE_SHARE_WRITE | FILE_SHARE_DELETE, // 6 - FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE}; // 7 - LPSECURITY_ATTRIBUTES lpAttr = NULL; - DWORD dwCreationDisp[4] = {CREATE_NEW, // 0 - CREATE_ALWAYS, // 1 - OPEN_EXISTING, // 2 - OPEN_ALWAYS}; // 3 - DWORD dwFlagsAttrib[5] = {FILE_ATTRIBUTE_NORMAL, // 0 - FILE_FLAG_SEQUENTIAL_SCAN, // 1 - FILE_FLAG_WRITE_THROUGH, // 2 - FILE_FLAG_NO_BUFFERING, // 3 - FILE_FLAG_RANDOM_ACCESS}; // 4 - HANDLE hTemplate = NULL; - - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - if (!Cleanup()) { - Trace("Pre-test Cleanup() failed. LastError=%d\n", GetLastError()); - return FAIL; - } - - /* open the file to read the expected results */ - outFile = fopen("winoutput", "r"); - memset (results, 0, 1024); - - fgets(results, 1024, outFile); - nCounter = (int)strlen(results); - fclose(outFile); - - nCounter = 0; - - // desired access loop - for (i = 0; i < 4; i++) - { - // share mode loop - for (j = 0; j < 8; j++) - { - // security attributes loop - for (k = 0; k < 4; k++) - { - // creation disp loop - for (l = 0; l < 5; l++) - { - sprintf_s(lpFileName, _countof(lpFileName), "test%03d.txt", nCounter); - hFile = CreateFile(lpFileName, - dwDesiredAccess[i], - dwShareMode[j], - lpAttr, - dwCreationDisp[k], - dwFlagsAttrib[l], - hTemplate); - if (hFile == INVALID_HANDLE_VALUE) - { - if (results[nCounter] == '1') - { - Trace("CreateFile: ERROR: Failed when expected " - "to pass %s [%d][%d][%d][%d]\n", - lpFileName, i, j, k, l); - bSuccess = FALSE; - } - } - else - { - CloseHandle(hFile); - if (results[nCounter] == '0') - { - Trace("CreateFile: ERROR: Passed when expected " - "to fail %s [%d][%d][%d][%d]\n", - lpFileName, i, j, k, l); - bSuccess = FALSE; - } - } - nCounter ++; - } - } - } - } - - if (!Cleanup()) - { - Trace("Post-test Cleanup() failed. LastError=%d\n", GetLastError()); - return FAIL; - } - - int exitCode = bSuccess ? PASS : FAIL; - PAL_TerminateEx(exitCode); - return exitCode; -} diff --git a/src/pal/tests/palsuite/file_io/CreateFileA/test1/testinfo.dat b/src/pal/tests/palsuite/file_io/CreateFileA/test1/testinfo.dat deleted file mode 100644 index bb872806e..000000000 --- a/src/pal/tests/palsuite/file_io/CreateFileA/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = CreateFileA -Name = test for CreateFileA -Type = DEFAULT -EXE1 = createfilea -Description -= Attempts to create files based on all combinations of -= options of CreateFileA diff --git a/src/pal/tests/palsuite/file_io/CreateFileA/test1/winoutput b/src/pal/tests/palsuite/file_io/CreateFileA/test1/winoutput deleted file mode 100644 index 3913b9942..000000000 --- a/src/pal/tests/palsuite/file_io/CreateFileA/test1/winoutput +++ /dev/null @@ -1 +0,0 @@ -1111111111000001111111111111110000011111111111111100000111111111111111000001111111111111110000011111111111111100000111111111111111000001111111111111110000011111111111111100000111111111111111000001111111111111110000011111111111111100000111111111111111000001111111111111110000011111111111111100000111111111111111000001111111111111110000011111111111111100000111111111111111000001111111111111110000011111111111111100000111111111111111000001111111111111110000011111111111111100000111111111111111000001111111111111110000011111111111111100000111111111111111000001111111111111110000011111111111111100000111111111111111000001111111111111110000011111 \ No newline at end of file diff --git a/src/pal/tests/palsuite/file_io/CreateFileW/CMakeLists.txt b/src/pal/tests/palsuite/file_io/CreateFileW/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/file_io/CreateFileW/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/file_io/CreateFileW/test1/CMakeLists.txt b/src/pal/tests/palsuite/file_io/CreateFileW/test1/CMakeLists.txt deleted file mode 100644 index d437410a1..000000000 --- a/src/pal/tests/palsuite/file_io/CreateFileW/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - CreateFileW.cpp -) - -add_executable(paltest_createfilew_test1 - ${SOURCES} -) - -add_dependencies(paltest_createfilew_test1 coreclrpal) - -target_link_libraries(paltest_createfilew_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/CreateFileW/test1/CreateFileW.cpp b/src/pal/tests/palsuite/file_io/CreateFileW/test1/CreateFileW.cpp deleted file mode 100644 index 0619f5b4a..000000000 --- a/src/pal/tests/palsuite/file_io/CreateFileW/test1/CreateFileW.cpp +++ /dev/null @@ -1,152 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: CreateFileW.c -** -** Purpose: Test the PAL implementation of the CreateFileW function -** -** -**===================================================================*/ - -#include - -BOOL Cleanup(void) -{ - char FileName[20]; - int i; - BOOL bRet = TRUE; // assume success - - // loop through all accesses, modes, dispositions and flags - for (i=0; i<4*8*4*5; ++i) { - sprintf_s(FileName, _countof(FileName), "test%03d.txt", i); - if (DeleteFileA(FileName) == FALSE) { - if (GetLastError() != ERROR_FILE_NOT_FOUND) { - bRet = FALSE; - } - } - } - return bRet; -} - - -int __cdecl main(int argc, char *argv[]) -{ - BOOL bSuccess = TRUE; - int nCounter = 0; - HANDLE hFile = NULL; - WCHAR *lpFileName = NULL; - char* pTemp = NULL; - char string[40]; - FILE *outFile = NULL; - char results[1024]; - int i, j, k, l; - DWORD dwDesiredAccess[4] = {0, // 0 - GENERIC_READ, // 1 - GENERIC_WRITE, // 2 - GENERIC_READ | GENERIC_WRITE}; // 3 - DWORD dwShareMode[8] = {0, // 0 - FILE_SHARE_READ, // 1 - FILE_SHARE_WRITE, // 2 - FILE_SHARE_DELETE, // 3 - FILE_SHARE_READ | FILE_SHARE_WRITE, // 4 - FILE_SHARE_READ | FILE_SHARE_DELETE, // 5 - FILE_SHARE_WRITE | FILE_SHARE_DELETE, // 6 - FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE}; // 7 - LPSECURITY_ATTRIBUTES lpAttr = NULL; - DWORD dwCreationDisp[4] = {CREATE_NEW, // 0 - CREATE_ALWAYS, // 1 - OPEN_EXISTING, // 2 - OPEN_ALWAYS}; // 3 - DWORD dwFlagsAttrib[5] = {FILE_ATTRIBUTE_NORMAL, // 0 - FILE_FLAG_SEQUENTIAL_SCAN, // 1 - FILE_FLAG_WRITE_THROUGH, // 2 - FILE_FLAG_NO_BUFFERING, // 3 - FILE_FLAG_RANDOM_ACCESS}; // 4 - HANDLE hTemplate = NULL; - - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - if (!Cleanup()) { - Trace("Pre-test Cleanup() failed. LastError=%d\n", GetLastError()); - return FAIL; - } - - /* open the file to read the expected results */ - outFile = fopen("winoutput", "r"); - memset (results, 0, 1024); - - fgets(results, 1024, outFile); - fclose(outFile); - - nCounter = 0; - - // desired access loop - for (i = 0; i < 4; i++) - { - // share mode loop - for (j = 0; j < 8; j++) - { - // security attributes loop - for (k = 0; k < 4; k++) - { - // creation disp loop - for (l = 0; l < 5; l++) - { - sprintf_s(string, _countof(string), "test%03d.txt", nCounter); - lpFileName = convert(string); - hFile = CreateFileW(lpFileName, - dwDesiredAccess[i], - dwShareMode[j], - lpAttr, - dwCreationDisp[k], - dwFlagsAttrib[l], - hTemplate); - free(lpFileName); - if (hFile == INVALID_HANDLE_VALUE) - { - if (results[nCounter] == '1') - { - pTemp = convertC(lpFileName); - Trace("CreateFile: ERROR: Failed when expected " - "to pass %s [%d][%d][%d][%d]\n", - pTemp, i, j, k, l); - free(pTemp); - bSuccess = FALSE; - } - } - else - { - CloseHandle(hFile); - if (results[nCounter] == '0') - { - pTemp = convertC(lpFileName); - Trace("CreateFile: ERROR: Passed when expected " - "to fail %s [%d][%d][%d][%d]\n", - pTemp, i, j, k, l); - free(pTemp); - bSuccess = FALSE; - } - } - nCounter ++; - } - } - } - } - - if (!Cleanup()) - { - Trace("Post-test Cleanup() failed. LastError=%d\n", GetLastError()); - return FAIL; - } - - int exitCode = bSuccess ? PASS : FAIL; - PAL_TerminateEx(exitCode); - return exitCode; -} diff --git a/src/pal/tests/palsuite/file_io/CreateFileW/test1/testinfo.dat b/src/pal/tests/palsuite/file_io/CreateFileW/test1/testinfo.dat deleted file mode 100644 index 2dbf15999..000000000 --- a/src/pal/tests/palsuite/file_io/CreateFileW/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = CreateFileW -Name = test for CreateFileW -Type = DEFAULT -EXE1 = createfilew -Description -= Attempts to create files based on all combinations of -= options of CreateFileW diff --git a/src/pal/tests/palsuite/file_io/CreateFileW/test1/winoutput b/src/pal/tests/palsuite/file_io/CreateFileW/test1/winoutput deleted file mode 100644 index 3913b9942..000000000 --- a/src/pal/tests/palsuite/file_io/CreateFileW/test1/winoutput +++ /dev/null @@ -1 +0,0 @@ -1111111111000001111111111111110000011111111111111100000111111111111111000001111111111111110000011111111111111100000111111111111111000001111111111111110000011111111111111100000111111111111111000001111111111111110000011111111111111100000111111111111111000001111111111111110000011111111111111100000111111111111111000001111111111111110000011111111111111100000111111111111111000001111111111111110000011111111111111100000111111111111111000001111111111111110000011111111111111100000111111111111111000001111111111111110000011111111111111100000111111111111111000001111111111111110000011111111111111100000111111111111111000001111111111111110000011111 \ No newline at end of file diff --git a/src/pal/tests/palsuite/file_io/DeleteFileA/CMakeLists.txt b/src/pal/tests/palsuite/file_io/DeleteFileA/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/file_io/DeleteFileA/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/file_io/DeleteFileA/test1/CMakeLists.txt b/src/pal/tests/palsuite/file_io/DeleteFileA/test1/CMakeLists.txt deleted file mode 100644 index a07a00076..000000000 --- a/src/pal/tests/palsuite/file_io/DeleteFileA/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - DeleteFileA.cpp -) - -add_executable(paltest_deletefilea_test1 - ${SOURCES} -) - -add_dependencies(paltest_deletefilea_test1 coreclrpal) - -target_link_libraries(paltest_deletefilea_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/DeleteFileA/test1/DeleteFileA.cpp b/src/pal/tests/palsuite/file_io/DeleteFileA/test1/DeleteFileA.cpp deleted file mode 100644 index a8eb71dec..000000000 --- a/src/pal/tests/palsuite/file_io/DeleteFileA/test1/DeleteFileA.cpp +++ /dev/null @@ -1,182 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: DeleteFileA.c -** -** Purpose: Tests the PAL implementation of the DeleteFileA function. -** -** -**===================================================================*/ - -// delete an existing file -// delete a non-existant file -// delete an open file -// delete files using wild cards -// delete a hidden file -// delete a file without proper permissions -// - -#define PAL_STDCPP_COMPAT -#include -#undef PAL_STDCPP_COMPAT - -#include -#include - - -int __cdecl main(int argc, char *argv[]) -{ - FILE *tempFile = NULL; - BOOL bRc = FALSE; - - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - // - // create a test file - // - tempFile = fopen("testFile01.txt", "w"); - if (tempFile == NULL) - { - Fail ("DeleteFileA: ERROR: Couldn't create \"DeleteFileA's" - " testFile01.txt\"\n"); - } - - fprintf(tempFile, "DeleteFileA test file.\n"); - if (fclose(tempFile) != 0) - { - Fail ("DeleteFileA: ERROR: Couldn't close \"DeleteFileA's" - " testFile01.txt\"\n"); - } - - // - // delete a symlink to an existing file - // - if (symlink("testFile01.txt", "testFile01_symlink") != 0) - { - Fail("DeleteFileA: ERROR: Failed to create a symlink to testFile01.txt.\n"); - } - - bRc = DeleteFileA("testFile01_symlink"); - if (bRc != TRUE) - { - Fail ("DeleteFileA: ERROR: Couldn't delete symlink!\n Error is %d\n", GetLastError()); - } - - struct stat statBuffer; - if (lstat("testFile01.txt", &statBuffer) != 0) - { - Fail("DeleteFileA: ERROR: Deleting a symlink deleted the file it was pointing to.\n"); - } - - if (lstat("testFile01_symlink", &statBuffer) == 0) - { - Fail("DeleteFileA: ERROR: Failed to delete a symlink.\n"); - } - - // - // deleting an existing file - // - bRc = DeleteFileA("testFile01.txt"); - if (bRc != TRUE) - { - Fail ("DeleteFileA: ERROR: Couldn't delete DeleteFileA's" - " \"testFile01.txt\"\n" - " Error is %d\n", GetLastError()); - } - - - // - // deleting a non-existant file : should fail - // - - bRc = DeleteFileA("testFile02.txt"); - if (bRc != FALSE) - { - Fail ("DeleteFileA: ERROR: Was able to delete the non-existant" - " file \"testFile02.txt\"\n"); - } - - - - - // - // deleting an open file - // - tempFile = fopen("testFile03.txt", "w"); - if (tempFile == NULL) - { - Fail("DeleteFileA: ERROR: Couldn't create \"DeleteFileA's" - " testFile03.txt\"\n"); - } - - fprintf(tempFile, "DeleteFileA test file.\n"); - if (fclose(tempFile) != 0) - { - Fail ("DeleteFileA: ERROR: Couldn't close \"DeleteFileA's" - " testFile03.txt\"\n"); - } - - bRc = DeleteFileA("testFile03.txt"); - if (bRc != TRUE) - { - Fail("DeleteFileA: ERROR: Couldn't delete DeleteFileA's" - " \"testFile03.txt\"\n" - " Error is %d\n", GetLastError()); - } - bRc = DeleteFileA("testFile03.txt"); - - - - - // - // delete using wild cards - // - - // create the test file - tempFile = fopen("testFile04.txt", "w"); - if (tempFile == NULL) - { - Fail("DeleteFileA: ERROR: Couldn't create DeleteFileA's" - " \"testFile04.txt\"\n"); - } - fprintf(tempFile, "DeleteFileA test file.\n"); - if (fclose(tempFile) != 0) - { - Fail ("DeleteFileA: ERROR: Couldn't close \"DeleteFileA's" - " testFile04.txt\"\n"); - } - - // delete using '?' - bRc = DeleteFileA("testFile0?.txt"); - if (bRc == TRUE) - { - Fail("DeleteFileA: ERROR: Was able to delete using the" - " \'?\' wildcard\n"); - } - - // delete using '*' - bRc = DeleteFileA("testFile*.txt"); - if (bRc == TRUE) - { - Fail("DeleteFileA: ERROR: Was able to delete using the" - " \'*\' wildcard\n"); - } - - bRc = DeleteFileA("testFile04.txt"); - if (bRc != TRUE) - { - Fail ("DeleteFileA: ERROR: Couldn't delete DeleteFileA's" - " \"testFile04.txt\"\n" - " Error is %d\n", GetLastError()); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/file_io/DeleteFileA/test1/testinfo.dat b/src/pal/tests/palsuite/file_io/DeleteFileA/test1/testinfo.dat deleted file mode 100644 index 24283ed93..000000000 --- a/src/pal/tests/palsuite/file_io/DeleteFileA/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = DeleteFileA -Name = Test for DeleteFileA (test 1) -Type = DEFAULT -EXE1 = deletefilea -Description -= Attempt to delete various files. - diff --git a/src/pal/tests/palsuite/file_io/DeleteFileW/CMakeLists.txt b/src/pal/tests/palsuite/file_io/DeleteFileW/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/file_io/DeleteFileW/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/file_io/DeleteFileW/test1/CMakeLists.txt b/src/pal/tests/palsuite/file_io/DeleteFileW/test1/CMakeLists.txt deleted file mode 100644 index 7aff64ccf..000000000 --- a/src/pal/tests/palsuite/file_io/DeleteFileW/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - DeleteFileW.cpp -) - -add_executable(paltest_deletefilew_test1 - ${SOURCES} -) - -add_dependencies(paltest_deletefilew_test1 coreclrpal) - -target_link_libraries(paltest_deletefilew_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/DeleteFileW/test1/DeleteFileW.cpp b/src/pal/tests/palsuite/file_io/DeleteFileW/test1/DeleteFileW.cpp deleted file mode 100644 index fca96d1e0..000000000 --- a/src/pal/tests/palsuite/file_io/DeleteFileW/test1/DeleteFileW.cpp +++ /dev/null @@ -1,164 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: DeleteFileW.c -** -** Purpose: Tests the PAL implementation of the DeleteFileW function. -** -** -**===================================================================*/ - -// delete an existing file -// delete a non-existant file -// delete an open file -// delete files using wild cards -// delete a hidden file -// delete a file without proper permissions -// - - -#include - - -int __cdecl main(int argc, char *argv[]) -{ - FILE *tempFile = NULL; - BOOL bRc = FALSE; - WCHAR* pTemp = NULL; - - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - // - // deleting an existing file - // - tempFile = fopen("testFile01.tmp", "w"); - if (tempFile == NULL) - { - Fail ("DeleteFileW: ERROR: Couldn't create \"DeleteFileW's" - " testFile01.tmp\"\n"); - } - - fprintf(tempFile, "DeleteFileW test file.\n"); - if (fclose(tempFile) != 0) - { - Fail ("DeleteFileA: ERROR: Couldn't close \"DeleteFileW's" - " testFile01.tmp\"\n"); - } - - pTemp = convert("testFile01.tmp"); - bRc = DeleteFileW(pTemp); - free(pTemp); - if (bRc != TRUE) - { - Fail ("DeleteFileW: ERROR: Couldn't delete DeleteFileW's" - " \"testFile01.tmp\"\n" - " Error is %d\n", GetLastError()); - } - - - // - // deleting a non-existant file : should fail - // - - pTemp = convert("testFile02.tmp"); - bRc = DeleteFileW(pTemp); - free(pTemp); - if (bRc != FALSE) - { - Fail ("DeleteFileW: ERROR: Was able to delete the non-existant" - " file \"testFile02.tmp\"\n"); - } - - - - - // - // deleting an open file - // - tempFile = fopen("testFile03.tmp", "w"); - if (tempFile == NULL) - { - Fail("DeleteFileW: ERROR: Couldn't create \"DeleteFileW's" - " testFile03.tmp\"\n"); - } - - fprintf(tempFile, "DeleteFileW test file.\n"); - if (fclose(tempFile) != 0) - { - Fail ("DeleteFileA: ERROR: Couldn't close \"DeleteFileW's" - " testFile03.tmp\"\n"); - } - - pTemp = convert("testFile03.tmp"); - bRc = DeleteFileW(pTemp); - if (bRc != TRUE) - { - Fail("DeleteFileW: ERROR: Couldn't delete DeleteFileW's" - " \"testFile03.tmp\"\n" - " Error is %d\n", GetLastError()); - free(pTemp); - } - bRc = DeleteFileW(pTemp); - free(pTemp); - - - - - // - // delete using wild cards - // - - // create the test file - tempFile = fopen("testFile04.tmp", "w"); - if (tempFile == NULL) - { - Fail("DeleteFileW: ERROR: Couldn't create DeleteFileW's" - " \"testFile04.tmp\"\n"); - } - fprintf(tempFile, "DeleteFileW test file.\n"); - if (fclose(tempFile) != 0) - { - Fail ("DeleteFileA: ERROR: Couldn't close \"DeleteFileW's" - " testFile04.tmp\"\n"); - } - - // delete using '?' - pTemp = convert("testFile0?.tmp"); - bRc = DeleteFileW(pTemp); - free(pTemp); - if (bRc == TRUE) - { - Fail("DeleteFileW: ERROR: Was able to delete using the" - " \'?\' wildcard\n"); - } - - // delete using '*' - pTemp = convert("testFile*.tmp"); - bRc = DeleteFileW(pTemp); - free(pTemp); - if (bRc == TRUE) - { - Fail("DeleteFileW: ERROR: Was able to delete using the" - " \'*\' wildcard\n"); - } - - pTemp = convert("testFile04.tmp"); - bRc = DeleteFileW(pTemp); - free(pTemp); - if (bRc != TRUE) - { - Fail ("DeleteFileW: ERROR: Couldn't delete DeleteFileW's" - " \"testFile04.tmp\"\n" - " Error is %d\n", GetLastError()); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/file_io/DeleteFileW/test1/testinfo.dat b/src/pal/tests/palsuite/file_io/DeleteFileW/test1/testinfo.dat deleted file mode 100644 index db44f998f..000000000 --- a/src/pal/tests/palsuite/file_io/DeleteFileW/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = DeleteFileW -Name = Test for DeleteFileW (test 1) -Type = DEFAULT -EXE1 = deletefilew -Description -= Tests DeleteFileW on various file names - diff --git a/src/pal/tests/palsuite/file_io/FILECanonicalizePath/CMakeLists.txt b/src/pal/tests/palsuite/file_io/FILECanonicalizePath/CMakeLists.txt deleted file mode 100644 index 7c6629d24..000000000 --- a/src/pal/tests/palsuite/file_io/FILECanonicalizePath/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - FILECanonicalizePath.cpp -) - -add_executable(paltest_filecanonicalizepath_test1 - ${SOURCES} -) - -add_dependencies(paltest_filecanonicalizepath_test1 coreclrpal) - -target_link_libraries(paltest_filecanonicalizepath_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/FILECanonicalizePath/FILECanonicalizePath.cpp b/src/pal/tests/palsuite/file_io/FILECanonicalizePath/FILECanonicalizePath.cpp deleted file mode 100644 index 3a1758aa3..000000000 --- a/src/pal/tests/palsuite/file_io/FILECanonicalizePath/FILECanonicalizePath.cpp +++ /dev/null @@ -1,83 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: FILECanonicalizePath.c (test 1) -** -** Purpose: Tests the PAL implementation of the FILECanonicalizePath function. -** -** -**===================================================================*/ - -#include - -extern "C" void FILECanonicalizePath(LPSTR lpUnixPath); - -void TestCase(LPSTR input, LPSTR expectedOutput); - -int __cdecl main(int argc, char *argv[]) -{ - if (PAL_Initialize(argc,argv) != 0) - { - return FAIL; - } - - // Case 01: / should not change - TestCase("/Test", "/Test"); - - // Case 02: // should not change - TestCase("/Test/Foo", "/Test/Foo"); - - // Case 03: // transforms to / - TestCase("//", "/"); - - // Case 04: /./ transforms to / - TestCase("/./", "/"); - - // Case 05: //../ transforms to / - TestCase("/Test/../", "/"); - - // Case 06: /Test/Foo/.. transforms to /Test - TestCase("/Test/Foo/..", "/Test"); - - // Case 07: /Test/.. transforms to / - TestCase("/Test/..", "/"); - - // Case 08: /. transforms to / - TestCase("/.", "/"); - - // Case 09: / - TestCase("/Test/.", "/Test"); - - // Case 10: //../. transforms to / - TestCase("/Test/../.", "/"); - - // Case 11: /.. transforms to / - TestCase("/..", "/"); - - PAL_Terminate(); - return PASS; -} - -void TestCase(LPSTR input, LPSTR expectedOutput) -{ - // Save the input for debug logging since the input is edited in-place - char* pOriginalInput = (char*)malloc(strlen(input) * sizeof(char) + 1); - strcpy(pOriginalInput, input); - - char* pInput = (char*)malloc(strlen(input) * sizeof(char) + 1); - strcpy(pInput, pOriginalInput); - - FILECanonicalizePath(pInput); - if (strcmp(pInput, expectedOutput) != 0) - { - free(pOriginalInput); - free(pInput); - Fail("FILECanonicalizePath error: input %s did not match expected output %s; got %s instead", pOriginalInput, expectedOutput, pInput); - } - - free(pOriginalInput); - free(pInput); -} diff --git a/src/pal/tests/palsuite/file_io/FILECanonicalizePath/testinfo.dat b/src/pal/tests/palsuite/file_io/FILECanonicalizePath/testinfo.dat deleted file mode 100644 index 033ad78b4..000000000 --- a/src/pal/tests/palsuite/file_io/FILECanonicalizePath/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = FILECanonicalizePath -Name = Test for FILECanonicalizePath (test 1) -Type = DEFAULT -EXE1 = filecanonicalizepath -Description -= Canonicalizes paths and verifies the results diff --git a/src/pal/tests/palsuite/file_io/FindClose/CMakeLists.txt b/src/pal/tests/palsuite/file_io/FindClose/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/file_io/FindClose/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/file_io/FindClose/test1/CMakeLists.txt b/src/pal/tests/palsuite/file_io/FindClose/test1/CMakeLists.txt deleted file mode 100644 index d5a92fa40..000000000 --- a/src/pal/tests/palsuite/file_io/FindClose/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - FindClose.cpp -) - -add_executable(paltest_findclose_test1 - ${SOURCES} -) - -add_dependencies(paltest_findclose_test1 coreclrpal) - -target_link_libraries(paltest_findclose_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/FindClose/test1/FindClose.cpp b/src/pal/tests/palsuite/file_io/FindClose/test1/FindClose.cpp deleted file mode 100644 index 3d53806e4..000000000 --- a/src/pal/tests/palsuite/file_io/FindClose/test1/FindClose.cpp +++ /dev/null @@ -1,275 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: FindClose.c -** -** Purpose: Tests the PAL implementation of the FindClose function. -** -** -**===================================================================*/ - - -#include - - - -const WCHAR szFindName[] = {'t','e', 's', 't', '0', '1', '.', 't', 'x', 't', '\0'}; -const WCHAR szFindName_02[] = {'t','e', 's', 't', '0', '2', '.', 't', 'x', 't', '\0'}; -const WCHAR szFindName_03[] = {'t','e', 's', 't', '0', '3', '.', 't', 'x', 't', '\0'}; -const WCHAR szFindNameWldCard_01[] = {'t','e', 's', 't', '0', '?', '.', 't', 'x', 't', '\0'}; -const WCHAR szFindNameWldCard_02[] = {'*', '.', 't', 'x', 't', '\0'}; -const WCHAR szDirName[] = {'t','e', 's', 't', '_', 'd', 'i', 'r', '\0'}; -const WCHAR szDirName_02[] = {'t','e', 's', 't', '_', 'd', 'i', 'r', '0', '2', '\0'}; -const WCHAR szDirNameWldCard[] = {'t','e', 's', 't', '_', '*', '\0'}; - - - -BOOL createTestFile(const WCHAR* szName) -{ - FILE *pFile = NULL; - char* pTemp = NULL; - - pTemp = convertC((WCHAR*)szName); - pFile = fopen(pTemp, "w"); - if (pFile == NULL) - { - Trace("FindClose: ERROR -> Unable to create file \"%s\".\n", pTemp); - free(pTemp); - return FALSE; - } - else - { - fprintf(pFile, "FindClose test file, \"%s\".\n", pTemp); - free(pTemp); - fclose(pFile); - } - return TRUE; -} - - -void removeAll() -{ - RemoveDirectoryW(szDirName); - RemoveDirectoryW(szDirName_02); - - DeleteFileW(szFindName); - DeleteFileW(szFindName_02); - DeleteFileW(szFindName_03); -} - - -int __cdecl main(int argc, char *argv[]) -{ - WIN32_FIND_DATAW findFileData; - WIN32_FIND_DATAW findFileData_02; - HANDLE hFind = NULL; - BOOL bRc = FALSE; - char* pTemp = NULL; - - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - /* do some clean up just to be sure */ - removeAll(); - - /* FindClose a null handle */ - if(FindClose(NULL)!=0) - { - Fail("FindClose: ERROR -> Closing a NULL handle succeeded.\n"); - } - - /* find a file that exists */ - if(createTestFile(szFindName) == FALSE) - { - removeAll(); - PAL_TerminateEx(FAIL); - return FAIL; - } - if(createTestFile(szFindName_02) == FALSE) - { - removeAll(); - PAL_TerminateEx(FAIL); - return FAIL; - } - if(createTestFile(szFindName_03) == FALSE) - { - removeAll(); - PAL_TerminateEx(FAIL); - return FAIL; - } - - // close a FindFirstFileW handle - hFind = FindFirstFileW(szFindName, &findFileData); - if (hFind == INVALID_HANDLE_VALUE) - { - pTemp = convertC((WCHAR*)szFindName); - Trace("FindClose: ERROR -> Unable to find \"%s\"\n", pTemp); - free(pTemp); - removeAll(); - PAL_TerminateEx(FAIL); - return FAIL; - } - else - { - bRc = FindClose(hFind); - if (bRc == FALSE) - { - removeAll(); - Fail("FindClose: ERROR -> Unable to close a valid" - " FindFirstFileW handle.\n"); - } - } - hFind = FindFirstFileW(szFindName, &findFileData); - if (hFind == INVALID_HANDLE_VALUE) - { - pTemp = convertC((WCHAR*)szFindName); - Trace("FindClose: ERROR -> Unable to find \"%s\"\n", pTemp); - free(pTemp); - removeAll(); - PAL_TerminateEx(FAIL); - return FAIL; - } - else - { - bRc = FindNextFileW(hFind, &findFileData); - if (bRc != FALSE) - { - removeAll(); - Fail("FindClose: ERROR -> Found a file that doesn't exist.\n"); - } - else - { - bRc = FindClose(hFind); - if (bRc == FALSE) - { - removeAll(); - Fail("FindClose: ERROR -> Unable to close a valid " - "FindNextFileW handle.\n"); - } - } - } - - /* find a directory that exists */ - bRc = CreateDirectoryW(szDirName, NULL); - if (bRc == FALSE) - { - pTemp = convertC((WCHAR*)szDirName); - Trace("FindClose: ERROR -> Failed to create the directory \"%s\"\n", - pTemp); - free(pTemp); - removeAll(); - PAL_TerminateEx(FAIL); - return FAIL; - } - - bRc = CreateDirectoryW(szDirName_02, NULL); - if (bRc == FALSE) - { - pTemp = convertC((WCHAR*)szDirName_02); - Trace("FindClose: ERROR -> Failed to create the directory \"%s\"\n", - pTemp); - free(pTemp); - removeAll(); - PAL_TerminateEx(FAIL); - return FAIL; - } - - hFind = FindFirstFileW(szDirName, &findFileData); - if (hFind == INVALID_HANDLE_VALUE) - { - pTemp = convertC((WCHAR*)szDirName); - Trace("FindClose: ERROR. FindFirstFileW was unable to find \"%s\"\n", - pTemp); - free(pTemp); - removeAll(); - PAL_TerminateEx(FAIL); - return FAIL; - } - else - { - bRc = FindClose(hFind); - if (bRc == FALSE) - { - removeAll(); - Fail("FindClose: ERROR -> Unable to close a valid" - " FindFirstFileW handle of a directory.\n"); - } - } - - /* find a file using wild cards */ - hFind = FindFirstFileW(szFindNameWldCard_01, &findFileData); - if (hFind == INVALID_HANDLE_VALUE) - { - pTemp = convertC((WCHAR*)szFindNameWldCard_01); - Trace("FindClose: ERROR -> FindFirstFileW was unable to find \"%s\"\n", - pTemp); - free(pTemp); - removeAll(); - PAL_TerminateEx(FAIL); - return FAIL; - } - else - { - bRc = FindNextFileW(hFind, &findFileData_02); - if (bRc == FALSE) - { - removeAll(); - Fail("FindClose: ERROR -> Unable to find another file.\n"); - } - else - { - bRc = FindClose(hFind); - if (bRc == FALSE) - { - removeAll(); - Fail("FindClose: ERROR -> Unable to close a valid" - " FindNextFileW handle.\n"); - } - } - } - - /* find a directory using wild cards */ - hFind = FindFirstFileW(szDirNameWldCard, &findFileData); - if (hFind == INVALID_HANDLE_VALUE) - { - pTemp = convertC((WCHAR*)szDirNameWldCard); - Trace("FindClose: ERROR -> Unable to find \"%s\"\n", - pTemp); - free(pTemp); - removeAll(); - PAL_TerminateEx(FAIL); - return FAIL; - } - else - { - bRc = FindNextFileW(hFind, &findFileData_02); - if (bRc == FALSE) - { - removeAll(); - Fail("FindClose: ERROR -> Unable to find another directory.\n"); - } - else - { - bRc = FindClose(hFind); - if (bRc == FALSE) - { - removeAll(); - Fail("FindClose: ERROR -> Unable to close a valid" - " FindNextFileW handle of a directory.\n"); - } - } - } - - - removeAll(); - PAL_Terminate(); - - return PASS; -} - diff --git a/src/pal/tests/palsuite/file_io/FindClose/test1/testinfo.dat b/src/pal/tests/palsuite/file_io/FindClose/test1/testinfo.dat deleted file mode 100644 index b59bcbf57..000000000 --- a/src/pal/tests/palsuite/file_io/FindClose/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = FindClose -Name = Test for FindClose (test 1) -Type = DEFAULT -EXE1 = findclose -Description -= Test the FindClose on handles opened using the Find functions - diff --git a/src/pal/tests/palsuite/file_io/FindFirstFileA/CMakeLists.txt b/src/pal/tests/palsuite/file_io/FindFirstFileA/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/file_io/FindFirstFileA/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/file_io/FindFirstFileA/test1/CMakeLists.txt b/src/pal/tests/palsuite/file_io/FindFirstFileA/test1/CMakeLists.txt deleted file mode 100644 index c485edbba..000000000 --- a/src/pal/tests/palsuite/file_io/FindFirstFileA/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - FindFirstFileA.cpp -) - -add_executable(paltest_findfirstfilea_test1 - ${SOURCES} -) - -add_dependencies(paltest_findfirstfilea_test1 coreclrpal) - -target_link_libraries(paltest_findfirstfilea_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/FindFirstFileA/test1/FindFirstFileA.cpp b/src/pal/tests/palsuite/file_io/FindFirstFileA/test1/FindFirstFileA.cpp deleted file mode 100644 index 6ceb6a974..000000000 --- a/src/pal/tests/palsuite/file_io/FindFirstFileA/test1/FindFirstFileA.cpp +++ /dev/null @@ -1,206 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: FindFirstFileA.c -** -** Purpose: Tests the PAL implementation of the FindFirstFileA function. -** -** -**===================================================================*/ - - -#include - - -const char* szNoFileName = "333asdf.x77t"; -const char* szFindName = "test01.txt"; -const char* szFindNameWldCard_01 = "test0?.txt"; -const char* szFindNameWldCard_02 = "*.txt"; -const char* szDirName = "test_dir"; -const char* szDirNameSlash = "test_dir\\"; -const char* szDirNameWldCard_01 = "?est_dir"; -const char* szDirNameWldCard_02 = "test_*"; -/* Longer than MAX_LONGPATH characters */ -char szLongFindName[MAX_LONGPATH+1]; - -BOOL CleanUp() -{ - DWORD dwAtt; - BOOL result = TRUE; - - dwAtt = GetFileAttributesA(szFindName); - if( dwAtt != INVALID_FILE_ATTRIBUTES ) - { - if(!SetFileAttributesA (szFindName, FILE_ATTRIBUTE_NORMAL)) - { - result = FALSE; - Trace("ERROR:%d: Error setting attributes [%s][%d]\n", szFindName, FILE_ATTRIBUTE_NORMAL); - } - if(!DeleteFileA (szFindName)) - { - result = FALSE; - Trace("ERROR:%d: Error deleting file [%s][%d]\n", GetLastError(), szFindName, dwAtt); - } - } - - dwAtt = GetFileAttributesA(szDirName); - if( dwAtt != INVALID_FILE_ATTRIBUTES ) - { - if(!RemoveDirectoryA (szDirName)) - { - result = FALSE; - Trace("ERROR:%d: Error deleting file [%s][%d]\n", GetLastError(), szDirName, dwAtt); - } - } - - return result; -} - -int __cdecl main(int argc, char *argv[]) -{ - WIN32_FIND_DATA findFileData; - HANDLE hFind = NULL; - FILE *pFile = NULL; - BOOL bRc = FALSE; - WCHAR* szwTemp = NULL; - - memset(szLongFindName, 'a', MAX_LONGPATH+1); - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - - if(!CleanUp()) - { - Fail("FindFirstFileW: ERROR : Initial Clean Up failed\n"); - } - - // - // find a file with a NULL pointer - // - hFind = FindFirstFileA(NULL, &findFileData); - if (hFind != INVALID_HANDLE_VALUE) - { - Fail ("FindFirstFileA: ERROR -> Found invalid NULL file"); - } - - - // - // find a file that doesn't exist - // - hFind = FindFirstFileA(szNoFileName, &findFileData); - if (hFind != INVALID_HANDLE_VALUE) - { - Fail ("FindFirstFileA: ERROR -> Found invalid NULL file"); - } - - - // - // find a file that exists - // - pFile = fopen(szFindName, "w"); - if (pFile == NULL) - { - Fail("FindFirstFileA: ERROR -> Unable to create a test file\n"); - } - else - { - fclose(pFile); - } - hFind = FindFirstFileA(szFindName, &findFileData); - if (hFind == INVALID_HANDLE_VALUE) - { - Fail ("FindFirstFileA: ERROR -> Unable to find \"%s\"\n", szFindName); - } - else - { - // validate we found the correct file - if (strcmp(szFindName, findFileData.cFileName) != 0) - { - Fail ("FindFirstFileA: ERROR -> Found the wrong file\n"); - } - } - - - // - // find a directory that exists - // - szwTemp = convert((LPSTR)szDirName); - bRc = CreateDirectoryW(szwTemp, NULL); - free(szwTemp); - if (bRc == FALSE) - { - Fail("FindFirstFileA: ERROR -> Failed to create the directory " - "\"%s\"\n", - szDirName); - } - - hFind = FindFirstFileA(szDirName, &findFileData); - if (hFind == INVALID_HANDLE_VALUE) - { - Fail ("FindFirstFileA: ERROR. Unable to find \"%s\"\n", szDirName); - } - else - { - // validate we found the correct directory - if (strcmp(szDirName, findFileData.cFileName) != 0) - { - Fail ("FindFirstFileA: ERROR -> Found the wrong directory\n"); - } - } - - - // - // find a directory using a trailing '\' on the directory name: should fail - // - hFind = FindFirstFileA(szDirNameSlash, &findFileData); - if (hFind != INVALID_HANDLE_VALUE) - { - Fail ("FindFirstFileA: ERROR -> Able to find \"%s\": trailing " - "slash should have failed.\n", - szDirNameSlash); - } - - // find a file using wild cards - hFind = FindFirstFileA(szFindNameWldCard_01, &findFileData); - if (hFind == INVALID_HANDLE_VALUE) - { - Fail ("FindFirstFileA: ERROR -> Unable to find \"%s\"\n", - szFindNameWldCard_01); - } - - hFind = FindFirstFileA(szFindNameWldCard_02, &findFileData); - if (hFind == INVALID_HANDLE_VALUE) - { - Fail ("FindFirstFileA: ERROR -> Unable to find \"%s\"\n", szFindNameWldCard_02); - } - - - // - // find a directory using wild cards - // - hFind = FindFirstFileA(szDirNameWldCard_01, &findFileData); - if (hFind == INVALID_HANDLE_VALUE) - { - Fail ("FindFirstFileA: ERROR -> Unable to find \"%s\"\n", szDirNameWldCard_01); - } - - hFind = FindFirstFileA(szDirNameWldCard_02, &findFileData); - if (hFind == INVALID_HANDLE_VALUE) - { - Fail ("FindFirstFileA: ERROR -> Unable to find \"%s\"\n", szDirNameWldCard_02); - } - - if(!CleanUp()) - { - Fail("FindFirstFileW: ERROR : Final Clean Up failed\n"); - } - - PAL_Terminate(); - - return PASS; -} diff --git a/src/pal/tests/palsuite/file_io/FindFirstFileA/test1/testinfo.dat b/src/pal/tests/palsuite/file_io/FindFirstFileA/test1/testinfo.dat deleted file mode 100644 index 5b92f8c64..000000000 --- a/src/pal/tests/palsuite/file_io/FindFirstFileA/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = FindFirstFileA -Name = Test for FindFirstFileA (test 1) -Type = DEFAULT -EXE1 = findfirstfilea -Description -= Create a number of files and try to find them - diff --git a/src/pal/tests/palsuite/file_io/FindFirstFileW/CMakeLists.txt b/src/pal/tests/palsuite/file_io/FindFirstFileW/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/file_io/FindFirstFileW/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/file_io/FindFirstFileW/test1/CMakeLists.txt b/src/pal/tests/palsuite/file_io/FindFirstFileW/test1/CMakeLists.txt deleted file mode 100644 index 191e42d5c..000000000 --- a/src/pal/tests/palsuite/file_io/FindFirstFileW/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - FindFirstFileW.cpp -) - -add_executable(paltest_findfirstfilew_test1 - ${SOURCES} -) - -add_dependencies(paltest_findfirstfilew_test1 coreclrpal) - -target_link_libraries(paltest_findfirstfilew_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/FindFirstFileW/test1/FindFirstFileW.cpp b/src/pal/tests/palsuite/file_io/FindFirstFileW/test1/FindFirstFileW.cpp deleted file mode 100644 index f69a62597..000000000 --- a/src/pal/tests/palsuite/file_io/FindFirstFileW/test1/FindFirstFileW.cpp +++ /dev/null @@ -1,212 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: FindFirstFileW.c -** -** Purpose: Tests the PAL implementation of the FindFirstFileW function. -** -** -**===================================================================*/ - - -#include - - -const char* szNoFileName = "333asdf.x77t"; -const char* szFindName = "test01.txt"; -const char* szFindNameWldCard_01 = "test0?.txt"; -const char* szFindNameWldCard_02 = "*.txt"; -const char* szDirName = "test_dir"; -const char* szDirNameSlash = "test_dir\\"; -const char* szDirNameWldCard_01 = "?est_dir"; -const char* szDirNameWldCard_02 = "test_*"; - - -BOOL CleanUp() -{ - DWORD dwAtt; - BOOL result = TRUE; - - dwAtt = GetFileAttributesA(szFindName); - if( dwAtt != INVALID_FILE_ATTRIBUTES ) - { - if(!SetFileAttributesA (szFindName, FILE_ATTRIBUTE_NORMAL)) - { - result = FALSE; - Trace("ERROR:%d: Error setting attributes [%s][%d]\n", szFindName, FILE_ATTRIBUTE_NORMAL); - } - if(!DeleteFileA (szFindName)) - { - result = FALSE; - Trace("ERROR:%d: Error deleting file [%s][%d]\n", GetLastError(), szFindName, dwAtt); - } - } - - dwAtt = GetFileAttributesA(szDirName); - if( dwAtt != INVALID_FILE_ATTRIBUTES ) - { - if(!RemoveDirectoryA (szDirName)) - { - result = FALSE; - Trace("ERROR:%d: Error deleting file [%s][%d]\n", GetLastError(), szDirName, dwAtt); - } - } - - return result; -} - -int __cdecl main(int argc, char *argv[]) -{ - WIN32_FIND_DATAW findFileData; - HANDLE hFind = NULL; - FILE *pFile = NULL; - BOOL bRc = FALSE; - WCHAR* pTemp = NULL; - - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - if(!CleanUp()) - { - Fail("FindFirstFileW: ERROR : Initial Clean Up failed\n"); - } - - // - // find a file that doesn't exist - // - pTemp = convert((LPSTR)szNoFileName); - hFind = FindFirstFileW(pTemp, &findFileData); - free(pTemp); - if (hFind != INVALID_HANDLE_VALUE) - { - Fail ("FindFirstFileW: ERROR -> Found invalid NULL file\n"); - } - - - // - // find a file that exists - // - pFile = fopen(szFindName, "w"); - if (pFile == NULL) - { - Fail("FindFirstFileW: ERROR -> Unable to create a test file\n"); - } - else - { - fclose(pFile); - } - pTemp = convert((LPSTR)szFindName); - hFind = FindFirstFileW(pTemp, &findFileData); - if (hFind == INVALID_HANDLE_VALUE) - { - free(pTemp); - Fail ("FindFirstFileW: ERROR -> Unable to find \"%s\"\n", szFindName); - } - else - { - // validate we found the correct file - if (wcscmp(pTemp, findFileData.cFileName) != 0) - { - free(pTemp); - Fail ("FindFirstFileW: ERROR -> Found the wrong file\n"); - } - } - free(pTemp); - - // - // find a directory that exists - // - pTemp = convert((LPSTR)szDirName); - bRc = CreateDirectoryW(pTemp, NULL); - if (bRc == FALSE) - { - Fail("FindFirstFileW: ERROR[%u] -> Failed to create the directory \"%s\"\n", - GetLastError(), szDirName); - } - - hFind = FindFirstFileW(pTemp, &findFileData); - if (hFind == INVALID_HANDLE_VALUE) - { - free(pTemp); - Fail("FindFirstFileW: ERROR. Unable to find \"%s\"\n", szDirName); - } - else - { - // validate we found the correct directory - if (wcscmp(pTemp, findFileData.cFileName) != 0) - { - free(pTemp); - Fail("FindFirstFileW: ERROR -> Found the wrong directory\n"); - } - } - free(pTemp); - - // - // find a directory using a trailing '\' on the directory name: should fail - // - pTemp = convert((LPSTR)szDirNameSlash); - hFind = FindFirstFileW(pTemp, &findFileData); - free(pTemp); - if (hFind != INVALID_HANDLE_VALUE) - { - Fail("FindFirstFileW: ERROR -> Able to find \"%s\": trailing " - "slash should have failed.\n", - szDirNameSlash); - } - - // find a file using wild cards - pTemp = convert((LPSTR)szFindNameWldCard_01); - hFind = FindFirstFileW(pTemp, &findFileData); - free(pTemp); - if (hFind == INVALID_HANDLE_VALUE) - { - Fail("FindFirstFileW: ERROR -> Unable to find \"%s\"\n", - szFindNameWldCard_01); - } - - pTemp = convert((LPSTR)szFindNameWldCard_02); - hFind = FindFirstFileW(pTemp, &findFileData); - free(pTemp); - if (hFind == INVALID_HANDLE_VALUE) - { - Fail("FindFirstFileW: ERROR -> Unable to find \"%s\"\n", - szFindNameWldCard_02); - } - - - // - // find a directory using wild cards - // - - pTemp = convert((LPSTR)szDirNameWldCard_01); - hFind = FindFirstFileW(pTemp, &findFileData); - free(pTemp); - if (hFind == INVALID_HANDLE_VALUE) - { - Fail("FindFirstFileW: ERROR -> Unable to find \"%s\"\n", - szDirNameWldCard_01); - } - - pTemp = convert((LPSTR)szDirNameWldCard_02); - hFind = FindFirstFileW(pTemp, &findFileData); - free(pTemp); - if (hFind == INVALID_HANDLE_VALUE) - { - Fail("FindFirstFileW: ERROR -> Unable to find \"%s\"\n", - szDirNameWldCard_02); - } - - if(!CleanUp()) - { - Fail("FindFirstFileW: ERROR : Final Clean Up failed\n"); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/file_io/FindFirstFileW/test1/testinfo.dat b/src/pal/tests/palsuite/file_io/FindFirstFileW/test1/testinfo.dat deleted file mode 100644 index c088c04cb..000000000 --- a/src/pal/tests/palsuite/file_io/FindFirstFileW/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = FindFirstFileW -Name = Test for FindFirstFileW (test 1) -Type = DEFAULT -EXE1 = findfirstfilew -Description -= Create a number of files and try to find them - diff --git a/src/pal/tests/palsuite/file_io/FindNextFileA/CMakeLists.txt b/src/pal/tests/palsuite/file_io/FindNextFileA/CMakeLists.txt deleted file mode 100644 index ef14ea535..000000000 --- a/src/pal/tests/palsuite/file_io/FindNextFileA/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) - diff --git a/src/pal/tests/palsuite/file_io/FindNextFileA/test1/CMakeLists.txt b/src/pal/tests/palsuite/file_io/FindNextFileA/test1/CMakeLists.txt deleted file mode 100644 index 4dcaa9998..000000000 --- a/src/pal/tests/palsuite/file_io/FindNextFileA/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - FindNextFileA.cpp -) - -add_executable(paltest_findnextfilea_test1 - ${SOURCES} -) - -add_dependencies(paltest_findnextfilea_test1 coreclrpal) - -target_link_libraries(paltest_findnextfilea_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/FindNextFileA/test1/FindNextFileA.cpp b/src/pal/tests/palsuite/file_io/FindNextFileA/test1/FindNextFileA.cpp deleted file mode 100644 index 578fa0054..000000000 --- a/src/pal/tests/palsuite/file_io/FindNextFileA/test1/FindNextFileA.cpp +++ /dev/null @@ -1,243 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: FindNextFileA.c -** -** Purpose: Tests the PAL implementation of the FindNextFileA function. -** -** -**===================================================================*/ - -#include - - -const char* szFindName = "test01.txt"; -const char* szFindName_02 = "test02.txt"; -const char* szFindNameWldCard_01 = "test0?.txt"; -const char* szFindNameWldCard_02 = "*.txt"; -const char* szDirName = "test_dir"; -const char* szDirName_02 = "test_dir_02"; -const char* szDirNameWldCard = "test_*"; - - - -void removeAll() -{ - WCHAR* wTempPtr = NULL; - - wTempPtr = convert((LPSTR)szDirName); - RemoveDirectoryW(wTempPtr); - free (wTempPtr); - wTempPtr = convert((LPSTR)szDirName_02); - RemoveDirectoryW(wTempPtr); - free (wTempPtr); - DeleteFile(szFindName); - DeleteFile(szFindName_02); -} - - - -BOOL createTestFile(const char* szName) -{ - FILE *pFile = NULL; - - pFile = fopen(szName, "w"); - if (pFile == NULL) - { - Trace("FindNextFile: ERROR -> Unable to create file \"%s\".\n", - szName); - removeAll(); - return FALSE; - } - else - { - fprintf(pFile, "FindNextFile test file, \"%s\".\n", szFindName); - fclose(pFile); - } - return TRUE; -} - - - -int __cdecl main(int argc, char *argv[]) -{ - WIN32_FIND_DATA findFileData; - WIN32_FIND_DATA findFileData_02; - HANDLE hFind = NULL; - BOOL bRc = FALSE; - DWORD dwBytesWritten; - WCHAR* wTempPtr = NULL; - - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - removeAll(); - - - // - // find a file with a NULL pointer - // - hFind = FindFirstFileA(NULL, &findFileData); - if (hFind != INVALID_HANDLE_VALUE) - { - Fail("FindNextFile: ERROR -> Found invalid NULL file"); - } - - bRc = FindNextFile(hFind, &findFileData); - if (bRc == TRUE) - { - Fail("FindNextFile: ERROR -> Found a file based on an invalid handle"); - } - - - // - // find a file that exists - // - if(createTestFile(szFindName) == FALSE) - { - PAL_TerminateEx(FAIL); - return FAIL; - } - if(createTestFile(szFindName_02) == FALSE) - { - PAL_TerminateEx(FAIL); - return FAIL; - } - - hFind = FindFirstFileA(szFindName, &findFileData); - if (hFind == INVALID_HANDLE_VALUE) - { - removeAll(); - Fail("FindNextFile: ERROR -> Unable to find \"%s\"\n", szFindName); - } - else - { - bRc = FindNextFile(hFind, &findFileData); - if (bRc != FALSE) - { - removeAll(); - Fail("FindNextFile: ERROR -> Found a file that doesn't exist.\n"); - } - } - - - // - // find a directory that exists - // - wTempPtr = convert((LPSTR)szDirName); - bRc = CreateDirectoryW(wTempPtr, NULL); - free (wTempPtr); - if (bRc == FALSE) - { - removeAll(); - Fail("FindNextFile: ERROR -> Failed to create the directory \"%s\"\n", - szDirName); - } - wTempPtr = convert((LPSTR)szDirName_02); - bRc = CreateDirectoryW(wTempPtr, NULL); - free (wTempPtr); - if (bRc == FALSE) - { - removeAll(); - Fail("FindNextFile: ERROR -> Failed to create the directory \"%s\"\n", - szDirName_02); - } - - hFind = FindFirstFileA(szDirName, &findFileData); - if (hFind == INVALID_HANDLE_VALUE) - { - removeAll(); - Fail("FindNextFile: ERROR. FindFirstFileA was unable to find \"%s\"\n", - szDirName); - } - else - { - bRc = FindNextFile(hFind, &findFileData); - if (bRc != FALSE) - { - removeAll(); - Fail("FindNextFile: ERROR -> Found a directory that doesn't exist.\n"); - } - } - - - // - // find a file using wild cards - // - hFind = FindFirstFileA(szFindNameWldCard_01, &findFileData); - if (hFind == INVALID_HANDLE_VALUE) - { - removeAll(); - Fail("FindNextFile: ERROR -> FindFirstFileA was unable to find \"%s\"\n", - szFindNameWldCard_01); - } - else - { - bRc = FindNextFile(hFind, &findFileData_02); - if (bRc == FALSE) - { - removeAll(); - Fail("FindNextFile: ERROR -> Unable to find another file.\n"); - } - else - { - // validate we found the correct file - if (strcmp(findFileData_02.cFileName, findFileData.cFileName) == 0) - { - removeAll(); - Fail("FindNextFile: ERROR -> Found the same file \"%s\".\n", - findFileData.cFileName); - } - } - } - - - // - // find a directory using wild cards - // - hFind = FindFirstFileA(szDirNameWldCard, &findFileData); - if (hFind == INVALID_HANDLE_VALUE) - { - removeAll(); - Fail("FindNextFile: ERROR -> Unable to find \"%s\"\n", - szDirNameWldCard); - } - else - { - bRc = FindNextFile(hFind, &findFileData_02); - if (bRc == FALSE) - { - removeAll(); - Fail("FindNextFile: ERROR -> Unable to find another directory.\n"); - } - else - { - // validate we found the correct directory - if (strcmp(findFileData_02.cFileName, findFileData.cFileName) == 0) - { - removeAll(); - Fail("FindNextFile: ERROR -> Found the same directory \"%s\".\n", - findFileData.cFileName); - } - } - } - - // - // attempt to write to the hFind handle (which should fail) - // - bRc = WriteFile(hFind, "this is a test", 10, &dwBytesWritten, NULL); - removeAll(); - if (bRc == TRUE) - { - Fail("FindNextFile: ERROR -> Able to write to a FindNextFile handle.\n"); - } - - PAL_Terminate(); - - return PASS; -} diff --git a/src/pal/tests/palsuite/file_io/FindNextFileA/test1/testinfo.dat b/src/pal/tests/palsuite/file_io/FindNextFileA/test1/testinfo.dat deleted file mode 100644 index e1027eff3..000000000 --- a/src/pal/tests/palsuite/file_io/FindNextFileA/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = FindNextFileA -Name = Test for FindNextFileA (test 1) -Type = DEFAULT -EXE1 = findnextfilea -Description -= Create test files and directories to verify FindNextFileA - diff --git a/src/pal/tests/palsuite/file_io/FindNextFileA/test2/CMakeLists.txt b/src/pal/tests/palsuite/file_io/FindNextFileA/test2/CMakeLists.txt deleted file mode 100644 index d5871a400..000000000 --- a/src/pal/tests/palsuite/file_io/FindNextFileA/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - findnextfilea.cpp -) - -add_executable(paltest_findnextfilea_test2 - ${SOURCES} -) - -add_dependencies(paltest_findnextfilea_test2 coreclrpal) - -target_link_libraries(paltest_findnextfilea_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/FindNextFileA/test2/findnextfilea.cpp b/src/pal/tests/palsuite/file_io/FindNextFileA/test2/findnextfilea.cpp deleted file mode 100644 index c841a4d49..000000000 --- a/src/pal/tests/palsuite/file_io/FindNextFileA/test2/findnextfilea.cpp +++ /dev/null @@ -1,107 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: findnextfilea.c -** -** Purpose: Tests the PAL implementation of the FindNextFileA function. -** Tests '*' and '*.*' to ensure that '.' and '..' are -** returned in the expected order -** -** -**===================================================================*/ - -#include - - -const char* szDot = "."; -const char* szDotDot = ".."; -const char* szStar = "*"; -const char* szStarDotStar = "*.*"; - - -static void DoTest(const char* szDir, - const char* szResult1, - const char* szResult2) -{ - HANDLE hFind; - WIN32_FIND_DATA findFileData; - - /* - ** find the first - */ - if ((hFind = FindFirstFileA(szDir, &findFileData)) == INVALID_HANDLE_VALUE) - { - Fail("FindNextFileA: ERROR -> FindFirstFileA(\"%s\") failed. " - "GetLastError returned %u.\n", - szStar, - GetLastError()); - } - - /* did we find the expected */ - if (strcmp(szResult1, findFileData.cFileName) != 0) - { - if (!FindClose(hFind)) - { - Trace("FindNextFileA: ERROR -> Failed to close the find handle. " - "GetLastError returned %u.\n", - GetLastError()); - } - Fail("FindNextFileA: ERROR -> FindFirstFile(\"%s\") didn't find" - " the expected \"%s\" but found \"%s\" instead.\n", - szDir, - szResult1, - findFileData.cFileName); - } - - /* we found the first expected, let's see if we find the next expected*/ - if (!FindNextFileA(hFind, &findFileData)) - { - Trace("FindNextFileA: ERROR -> FindNextFileA should have found \"%s\"" - " but failed. GetLastError returned %u.\n", - szResult2, - GetLastError()); - if (!FindClose(hFind)) - { - Trace("FindNextFileA: ERROR -> Failed to close the find handle. " - "GetLastError returned %u.\n", - GetLastError()); - } - Fail(""); - } - - /* we found something, but was it '.' */ - if (strcmp(szResult2, findFileData.cFileName) != 0) - { - if (!FindClose(hFind)) - { - Trace("FindNextFileA: ERROR -> Failed to close the find handle. " - "GetLastError returned %u.\n", - GetLastError()); - } - Fail("FindNextFileA: ERROR -> FindNextFileA based on \"%s\" didn't find" - " the expected \"%s\" but found \"%s\" instead.\n", - szDir, - szResult2, - findFileData.cFileName); - } -} - -int __cdecl main(int argc, char *argv[]) -{ - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - DoTest(szStar, szDot, szDotDot); - DoTest(szStarDotStar, szDot, szDotDot); - - - PAL_Terminate(); - - return PASS; -} diff --git a/src/pal/tests/palsuite/file_io/FindNextFileA/test2/testinfo.dat b/src/pal/tests/palsuite/file_io/FindNextFileA/test2/testinfo.dat deleted file mode 100644 index dd6c1e48b..000000000 --- a/src/pal/tests/palsuite/file_io/FindNextFileA/test2/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = FindNextFileA -Name = Test for FindNextFileA (test 2) -Type = DEFAULT -EXE1 = findnextfilea -Description -= Tests the PAL implementation of the FindNextFileA function. -= Tests '*' and '*.*' to ensure that '.' and '..' are -= returned in the expected order diff --git a/src/pal/tests/palsuite/file_io/FindNextFileW/CMakeLists.txt b/src/pal/tests/palsuite/file_io/FindNextFileW/CMakeLists.txt deleted file mode 100644 index ef14ea535..000000000 --- a/src/pal/tests/palsuite/file_io/FindNextFileW/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) - diff --git a/src/pal/tests/palsuite/file_io/FindNextFileW/test1/CMakeLists.txt b/src/pal/tests/palsuite/file_io/FindNextFileW/test1/CMakeLists.txt deleted file mode 100644 index 62bf2f860..000000000 --- a/src/pal/tests/palsuite/file_io/FindNextFileW/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - FindNextFileW.cpp -) - -add_executable(paltest_findnextfilew_test1 - ${SOURCES} -) - -add_dependencies(paltest_findnextfilew_test1 coreclrpal) - -target_link_libraries(paltest_findnextfilew_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/FindNextFileW/test1/FindNextFileW.cpp b/src/pal/tests/palsuite/file_io/FindNextFileW/test1/FindNextFileW.cpp deleted file mode 100644 index 42e2e5580..000000000 --- a/src/pal/tests/palsuite/file_io/FindNextFileW/test1/FindNextFileW.cpp +++ /dev/null @@ -1,249 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: FindNextFileW.c -** -** Purpose: Tests the PAL implementation of the FindNextFileW function. -** -** -**===================================================================*/ - -#include - - -const char* szFindName = "test01.txt"; -const char* szFindName_02 = "test02.txt"; -const char* szFindNameWldCard_01 = "test0?.txt"; -const char* szFindNameWldCard_02 = "*.txt"; -const char* szDirName = "test_dir"; -const char* szDirName_02 = "test_dir_02"; -const char* szDirNameWldCard = "test_*"; - - - -void removeAll() -{ - WCHAR* wTempPtr = NULL; - - wTempPtr = convert((LPSTR)szDirName); - RemoveDirectoryW(wTempPtr); - free(wTempPtr); - - wTempPtr = convert((LPSTR)szDirName_02); - RemoveDirectoryW(wTempPtr); - free(wTempPtr); - - wTempPtr = convert((LPSTR)szFindName); - DeleteFileW(wTempPtr); - free(wTempPtr); - - wTempPtr = convert((LPSTR)szFindName_02); - DeleteFileW(wTempPtr); - free(wTempPtr); -} - - - -BOOL createTestFile(const char* szName) -{ - FILE *pFile = NULL; - - pFile = fopen(szName, "w"); - if (pFile == NULL) - { - Trace("FindNextFileW: ERROR -> Unable to create file \"%s\".\n", szName); - removeAll(); - return FALSE; - } - else - { - fprintf(pFile, "FindNextFileW test file, \"%s\".\n", szFindName); - fclose(pFile); - } - - return TRUE; -} - - - -int __cdecl main(int argc, char *argv[]) -{ - WIN32_FIND_DATAW findFileData; - WIN32_FIND_DATAW findFileData_02; - HANDLE hFind = NULL; - BOOL bRc = FALSE; - DWORD dwBytesWritten; - WCHAR* wTempPtr = NULL; - - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - removeAll(); - - - // - // find a file that exists - // - if(createTestFile(szFindName) == FALSE) - { - PAL_TerminateEx(FAIL); - return FAIL; - } - if(createTestFile(szFindName_02) == FALSE) - { - PAL_TerminateEx(FAIL); - return FAIL; - } - - wTempPtr = convert((LPSTR)szFindName); - hFind = FindFirstFileW(wTempPtr, &findFileData); - free(wTempPtr); - if (hFind == INVALID_HANDLE_VALUE) - { - removeAll(); - Fail("FindNextFileW: ERROR -> Unable to find \"%s\"\n", szFindName); - } - else - { - bRc = FindNextFileW(hFind, &findFileData); - if (bRc != FALSE) - { - removeAll(); - Fail("FindNextFileW: ERROR -> Found a file that doesn't exist.\n"); - } - } - - - // - // find a directory that exists - // - wTempPtr = convert((LPSTR)szDirName); - bRc = CreateDirectoryW(wTempPtr, NULL); - free (wTempPtr); - if (bRc == FALSE) - { - removeAll(); - Fail("FindNextFileW: ERROR -> Failed to create the directory \"%s\"\n", - szDirName); - } - wTempPtr = convert((LPSTR)szDirName_02); - bRc = CreateDirectoryW(wTempPtr, NULL); - free (wTempPtr); - if (bRc == FALSE) - { - removeAll(); - Fail("FindNextFileW: ERROR -> Failed to create the directory " - "\"%s\"\n", - szDirName_02); - } - - wTempPtr = convert((LPSTR)szDirName); - hFind = FindFirstFileW(wTempPtr, &findFileData); - free (wTempPtr); - if (hFind == INVALID_HANDLE_VALUE) - { - removeAll(); - Fail("FindNextFileW: ERROR. FindFirstFileW was unable " - "to find \"%s\"\n", - szDirName); - } - else - { - bRc = FindNextFileW(hFind, &findFileData); - if (bRc != FALSE) - { - removeAll(); - Fail("FindNextFileW: ERROR -> Found a directory that " - "doesn't exist.\n"); - } - } - - - // - // find a file using wild cards - // - wTempPtr = convert((LPSTR)szFindNameWldCard_01); - hFind = FindFirstFileW(wTempPtr, &findFileData); - free(wTempPtr); - if (hFind == INVALID_HANDLE_VALUE) - { - removeAll(); - Fail("FindNextFileW: ERROR -> FindFirstFileW was unable to " - "find \"%s\"\n", - szFindNameWldCard_01); - } - else - { - bRc = FindNextFileW(hFind, &findFileData_02); - if (bRc == FALSE) - { - removeAll(); - Fail("FindNextFileW: ERROR -> Unable to find another file.\n"); - } - else - { - // validate we found the correct file - if (wcscmp(findFileData_02.cFileName, findFileData.cFileName) == 0) - { - removeAll(); - Fail("FindNextFileW: ERROR -> Found the same file \"%S\".\n", - findFileData.cFileName); - } - } - } - - - // - // find a directory using wild cards - // - wTempPtr = convert((LPSTR)szDirNameWldCard); - hFind = FindFirstFileW(wTempPtr, &findFileData); - free(wTempPtr); - if (hFind == INVALID_HANDLE_VALUE) - { - removeAll(); - Fail("FindNextFileW: ERROR -> Unable to find \"%s\"\n", - szDirNameWldCard); - } - else - { - bRc = FindNextFileW(hFind, &findFileData_02); - if (bRc == FALSE) - { - removeAll(); - Fail("FindNextFileW: ERROR -> Unable to find another directory.\n"); - } - else - { - // validate we found the correct directory - if (wcscmp(findFileData_02.cFileName, findFileData.cFileName) == 0) - { - removeAll(); - Fail("FindNextFileW: ERROR -> Found the same directory " - "\"%S\".\n", - findFileData.cFileName); - } - } - } - - // - // attempt to write to the hFind handle (which should fail) - // - bRc = WriteFile(hFind, "this is a test", 10, &dwBytesWritten, NULL); - if (bRc == TRUE) - { - removeAll(); - Fail("FindNextFileW: ERROR -> Able to write to a FindNextFileW " - "handle.\n"); - } - - removeAll(); - PAL_Terminate(); - - return PASS; -} diff --git a/src/pal/tests/palsuite/file_io/FindNextFileW/test1/testinfo.dat b/src/pal/tests/palsuite/file_io/FindNextFileW/test1/testinfo.dat deleted file mode 100644 index 3eaebef43..000000000 --- a/src/pal/tests/palsuite/file_io/FindNextFileW/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = FindNextFileW -Name = Test for FindNextFileW (test 1) -Type = DEFAULT -EXE1 = findnextfilew -Description -= Create test files and directories to verify FindNextFileW - diff --git a/src/pal/tests/palsuite/file_io/FindNextFileW/test2/CMakeLists.txt b/src/pal/tests/palsuite/file_io/FindNextFileW/test2/CMakeLists.txt deleted file mode 100644 index 2b9a43f8f..000000000 --- a/src/pal/tests/palsuite/file_io/FindNextFileW/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - findnextfilew.cpp -) - -add_executable(paltest_findnextfilew_test2 - ${SOURCES} -) - -add_dependencies(paltest_findnextfilew_test2 coreclrpal) - -target_link_libraries(paltest_findnextfilew_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/FindNextFileW/test2/findnextfilew.cpp b/src/pal/tests/palsuite/file_io/FindNextFileW/test2/findnextfilew.cpp deleted file mode 100644 index 3e806c257..000000000 --- a/src/pal/tests/palsuite/file_io/FindNextFileW/test2/findnextfilew.cpp +++ /dev/null @@ -1,107 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: FindNextFileW.c -** -** Purpose: Tests the PAL implementation of the FindNextFileW function. -** Tests '*' and '*.*' to ensure that '.' and '..' are -** returned in the expected order -** -** -**===================================================================*/ - -#include - - -const WCHAR szwDot[] = {'.','\0'}; -const WCHAR szwDotDot[] = {'.','.','\0'}; -const WCHAR szwStar[] = {'*','\0'}; -const WCHAR szwStarDotStar[] = {'*','.','*','\0'}; - - -static void DoTest(const WCHAR* szwDir, - const WCHAR* szwResult1, - const WCHAR* szwResult2) -{ - HANDLE hFind; - WIN32_FIND_DATAW findFileData; - - /* - ** find the first - */ - if ((hFind = FindFirstFileW(szwDir, &findFileData)) == INVALID_HANDLE_VALUE) - { - Fail("FindNextFileW: ERROR -> FindFirstFileW(\"%S\") failed. " - "GetLastError returned %u.\n", - szwStar, - GetLastError()); - } - - /* did we find the expected */ - if (wcscmp(szwResult1, findFileData.cFileName) != 0) - { - if (!FindClose(hFind)) - { - Trace("FindNextFileW: ERROR -> Failed to close the find handle. " - "GetLastError returned %u.\n", - GetLastError()); - } - Fail("FindNextFileW: ERROR -> FindFirstFile(\"%S\") didn't find" - " the expected \"%S\" but found \"%S\" instead.\n", - szwDir, - szwResult1, - findFileData.cFileName); - } - - /* we found the first expected, let's see if we find the next expected*/ - if (!FindNextFileW(hFind, &findFileData)) - { - Trace("FindNextFileW: ERROR -> FindNextFileW should have found \"%S\"" - " but failed. GetLastError returned %u.\n", - szwResult2, - GetLastError()); - if (!FindClose(hFind)) - { - Trace("FindNextFileW: ERROR -> Failed to close the find handle. " - "GetLastError returned %u.\n", - GetLastError()); - } - Fail(""); - } - - /* we found something, but was it '.' */ - if (wcscmp(szwResult2, findFileData.cFileName) != 0) - { - if (!FindClose(hFind)) - { - Trace("FindNextFileW: ERROR -> Failed to close the find handle. " - "GetLastError returned %u.\n", - GetLastError()); - } - Fail("FindNextFileW: ERROR -> FindNextFileW based on \"%S\" didn't find" - " the expected \"%S\" but found \"%S\" instead.\n", - szwDir, - szwResult2, - findFileData.cFileName); - } -} - -int __cdecl main(int argc, char *argv[]) -{ - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - DoTest(szwStar, szwDot, szwDotDot); - DoTest(szwStarDotStar, szwDot, szwDotDot); - - - PAL_Terminate(); - - return PASS; -} diff --git a/src/pal/tests/palsuite/file_io/FindNextFileW/test2/testinfo.dat b/src/pal/tests/palsuite/file_io/FindNextFileW/test2/testinfo.dat deleted file mode 100644 index 98bd5e779..000000000 --- a/src/pal/tests/palsuite/file_io/FindNextFileW/test2/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = FindNextFileW -Name = Test for FindNextFileW (test 2) -Type = DEFAULT -EXE1 = findnextfilew -Description -= Tests the PAL implementation of the FindNextFileW function. -= Tests '*' and '*.*' to ensure that '.' and '..' are -= returned in the expected order diff --git a/src/pal/tests/palsuite/file_io/FlushFileBuffers/CMakeLists.txt b/src/pal/tests/palsuite/file_io/FlushFileBuffers/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/file_io/FlushFileBuffers/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/file_io/FlushFileBuffers/test1/CMakeLists.txt b/src/pal/tests/palsuite/file_io/FlushFileBuffers/test1/CMakeLists.txt deleted file mode 100644 index 433e89bbf..000000000 --- a/src/pal/tests/palsuite/file_io/FlushFileBuffers/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - FlushFileBuffers.cpp -) - -add_executable(paltest_flushfilebuffers_test1 - ${SOURCES} -) - -add_dependencies(paltest_flushfilebuffers_test1 coreclrpal) - -target_link_libraries(paltest_flushfilebuffers_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/FlushFileBuffers/test1/FlushFileBuffers.cpp b/src/pal/tests/palsuite/file_io/FlushFileBuffers/test1/FlushFileBuffers.cpp deleted file mode 100644 index 246be6484..000000000 --- a/src/pal/tests/palsuite/file_io/FlushFileBuffers/test1/FlushFileBuffers.cpp +++ /dev/null @@ -1,130 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: FlushFileBuffers.c -** -** Purpose: Tests the PAL implementation of the FlushFileBuffers function -** This tests checks the return values of FlushFileBuffers -- once on an -** open handle and once on a closed handle. -** -** Depends: -** CreateFile -** WriteFile -** CloseHandle -** DeleteFileA -** -** -**===================================================================*/ - -#include - - -int __cdecl main(int argc, char **argv) -{ - - int TheReturn; - HANDLE TheFileHandle; - DWORD temp; - DWORD originalSize=10000; - DWORD finalSize=10000; - const char* fileName="the_file"; - - /* 1 2 3 4*/ - char * SomeText = "1234567890123456789012345678901234567890"; - - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - - /* Open the file to get a HANDLE */ - TheFileHandle = - CreateFile( - fileName, - GENERIC_READ|GENERIC_WRITE, - FILE_SHARE_READ, - NULL, - OPEN_ALWAYS, - FILE_ATTRIBUTE_NORMAL, - NULL); - - if(TheFileHandle == INVALID_HANDLE_VALUE) - { - Fail("ERROR: CreateFile failed. Test depends on this function."); - } - - /* get the file size */ - originalSize = GetFileSize (TheFileHandle, NULL) ; - if(originalSize == INVALID_FILE_SIZE) - { - Fail("ERROR: call to GetFileSize faild with error " - "The GetLastError is %d.",GetLastError()); - } - - /* Write something too the HANDLE. Should be buffered */ - TheReturn = WriteFile(TheFileHandle, - SomeText, - strlen(SomeText), - &temp, - NULL); - - if(TheReturn == 0) - { - Fail("ERROR: WriteFile failed. Test depends on this function."); - } - - /* Test to see that FlushFileBuffers returns a success value */ - TheReturn = FlushFileBuffers(TheFileHandle); - if(TheReturn == 0) - { - Fail("ERROR: The FlushFileBuffers function returned 0, which " - "indicates failure, when trying to flush a valid HANDLE. " - "The GetLastError is %d.",GetLastError()); - } - - /* test if flush modified the file */ - finalSize = GetFileSize (TheFileHandle, NULL) ; - if(finalSize==INVALID_FILE_SIZE) - { - Fail("ERROR: call to GetFileSize faild with error " - "The GetLastError is %d.",GetLastError()); - } - if(finalSize!=(originalSize+strlen(SomeText))) - { - Fail("ERROR: FlushFileBuffers failed. data was not written to the file"); - } - - - /* Close the Handle */ - TheReturn = CloseHandle(TheFileHandle); - if(TheReturn == 0) - { - Fail("ERROR: CloseHandle failed. This function depends " - "upon it."); - } - - - /* Test to see that FlushFileBuffers returns a failure value */ - TheReturn = FlushFileBuffers(TheFileHandle); - if(TheReturn != 0) - { - Fail("ERROR: The FlushFileBuffers function returned non-zero, " - "which indicates success, when trying to flush an invalid " - "HANDLE."); - } - - /* make sure file does not exist */ - if(DeleteFileA(fileName)== 0 ) - { - Fail("ERROR: call to DeleteFileA faild with error " - "The GetLastError is %d.",GetLastError()); - } - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/file_io/FlushFileBuffers/test1/testinfo.dat b/src/pal/tests/palsuite/file_io/FlushFileBuffers/test1/testinfo.dat deleted file mode 100644 index 3a0da6918..000000000 --- a/src/pal/tests/palsuite/file_io/FlushFileBuffers/test1/testinfo.dat +++ /dev/null @@ -1,17 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = FlushFileBuffers -Name = Positive Test for FlushFileBuffers -TYPE = DEFAULT -EXE1 = flushfilebuffers -Description -= Test the FlushFileBuffers -= Test the return values -- ensure that the correct values are -= returned for success and failure. -= This test does not prove that flush worked, -= there is no way of stopping the OS from flushing -= the file by itself. diff --git a/src/pal/tests/palsuite/file_io/GetConsoleOutputCP/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetConsoleOutputCP/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/file_io/GetConsoleOutputCP/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/file_io/GetConsoleOutputCP/test1/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetConsoleOutputCP/test1/CMakeLists.txt deleted file mode 100644 index 5784789af..000000000 --- a/src/pal/tests/palsuite/file_io/GetConsoleOutputCP/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - GetConsoleOutputCP.cpp -) - -add_executable(paltest_getconsoleoutputcp_test1 - ${SOURCES} -) - -add_dependencies(paltest_getconsoleoutputcp_test1 coreclrpal) - -target_link_libraries(paltest_getconsoleoutputcp_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/GetConsoleOutputCP/test1/GetConsoleOutputCP.cpp b/src/pal/tests/palsuite/file_io/GetConsoleOutputCP/test1/GetConsoleOutputCP.cpp deleted file mode 100644 index 3deaebf68..000000000 --- a/src/pal/tests/palsuite/file_io/GetConsoleOutputCP/test1/GetConsoleOutputCP.cpp +++ /dev/null @@ -1,35 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: GetConsoleOutputCP.c (test 1) -** -** Purpose: Tests the PAL implementation of the GetConsoleOutputCP function. -** -** -**===================================================================*/ - -#include - - -int __cdecl main(int argc, char *argv[]) -{ - UINT uiCP = 0; - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - uiCP = GetConsoleOutputCP(); - if ((uiCP != CP_ACP) && (uiCP != GetACP()) && (uiCP != 437)) /*437 for MSDOS*/ - { - Fail("GetConsoleOutputCP: ERROR -> The invalid code page %d was returned.\n", - uiCP); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/file_io/GetConsoleOutputCP/test1/testinfo.dat b/src/pal/tests/palsuite/file_io/GetConsoleOutputCP/test1/testinfo.dat deleted file mode 100644 index 9ad624eaf..000000000 --- a/src/pal/tests/palsuite/file_io/GetConsoleOutputCP/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = GetConsoleOutputCP -Name = Positive Test for GetConsoleOutputCP (test 1) -Type = DEFAULT -EXE1 = getconsoleoutputcp -Description -= Test GetConsoleOutputCP. Apparently there are only two possible -= return values: CP_ACP or 1252 diff --git a/src/pal/tests/palsuite/file_io/GetCurrentDirectoryA/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetCurrentDirectoryA/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/file_io/GetCurrentDirectoryA/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/file_io/GetCurrentDirectoryA/test1/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetCurrentDirectoryA/test1/CMakeLists.txt deleted file mode 100644 index dad46b6f6..000000000 --- a/src/pal/tests/palsuite/file_io/GetCurrentDirectoryA/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - GetCurrentDirectoryA.cpp -) - -add_executable(paltest_getcurrentdirectorya_test1 - ${SOURCES} -) - -add_dependencies(paltest_getcurrentdirectorya_test1 coreclrpal) - -target_link_libraries(paltest_getcurrentdirectorya_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/GetCurrentDirectoryA/test1/GetCurrentDirectoryA.cpp b/src/pal/tests/palsuite/file_io/GetCurrentDirectoryA/test1/GetCurrentDirectoryA.cpp deleted file mode 100644 index b09e8a104..000000000 --- a/src/pal/tests/palsuite/file_io/GetCurrentDirectoryA/test1/GetCurrentDirectoryA.cpp +++ /dev/null @@ -1,97 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: GetCurrentDirectoryA.c (test 1) -** -** Purpose: Tests the PAL implementation of the GetCurrentDirectoryA function. -** -** -**===================================================================*/ - -#include - -const char* szFileName = "blah"; - - -int __cdecl main(int argc, char *argv[]) -{ - DWORD dwRc = 0; - DWORD dwRc2 = 0; - char szReturnedPath[_MAX_PATH+1]; - char szCurrentDir[_MAX_PATH+1]; - LPSTR pPathPtr; - size_t nCount = 0; - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - // use GetFullPathName to to get the current path by stripping - // the file name off the end - memset(szReturnedPath, 0, sizeof(char)*(_MAX_PATH+1)); - dwRc = GetFullPathNameA(szFileName, _MAX_PATH, szReturnedPath, &pPathPtr); - if (dwRc == 0) - { - // GetFullPathName failed - Fail("GetCurrentDirectoryA: ERROR -> GetFullPathNameA failed " - "with error code: %ld.\n", GetLastError()); - } - else if(dwRc > _MAX_PATH) - { - Fail("GetCurrentDirectoryA: ERROR -> The path name GetFullPathNameA " - "returned is longer than _MAX_PATH characters.\n"); - } - - - // strip the file name from the full path to get the current path - nCount = strlen(szReturnedPath) - strlen(szFileName) - 1; - memset(szCurrentDir, 0, sizeof(char)*(_MAX_PATH+1)); - strncpy(szCurrentDir, szReturnedPath, nCount); - - // compare the results of GetCurrentDirectoryA with the above - memset(szReturnedPath, 0, sizeof(char)*(_MAX_PATH+1)); - dwRc = GetCurrentDirectoryA((sizeof(char)*(_MAX_PATH+1)), szReturnedPath); - if (dwRc == 0) - { - Fail("GetCurrentDirectoryA: ERROR -> GetCurrentDirectoryA failed " - "with error code: %ld.\n", GetLastError()); - } - else if(dwRc > _MAX_PATH) - { - Fail("GetCurrentDirectoryA: ERROR -> The path name " - "returned is longer than _MAX_PATH characters.\n"); - } - - - /* test case the passed buffer size is not big enough - * function should return the size required + 1 a terminating null character - */ - - /* good buffer size */ - dwRc = GetCurrentDirectoryA((sizeof(CHAR)*(_MAX_PATH+1)), szReturnedPath); - - /* small buffer (0 size)*/ - dwRc2 = GetCurrentDirectoryA(0, szReturnedPath); - if (dwRc2 != (dwRc+1) ) - { - Fail("GetCurrentDirectoryA: ERROR -> failed to give the correct " - "return value when passed a buffer not big enough. " - "Expected %u while result is %u \n",(dwRc+1),dwRc2); - - } - - if (strcmp(szReturnedPath, szCurrentDir) != 0) - { - Fail("GetCurrentDirectoryA: ERROR -> The computed and returned " - "directories do not compare.\n"); - } - - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/file_io/GetCurrentDirectoryA/test1/testinfo.dat b/src/pal/tests/palsuite/file_io/GetCurrentDirectoryA/test1/testinfo.dat deleted file mode 100644 index c14eb42b2..000000000 --- a/src/pal/tests/palsuite/file_io/GetCurrentDirectoryA/test1/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = GetCurrentDirectoryA -Name = Test for GetCurrentDirectoryA (test 1) -Type = DEFAULT -EXE1 = getcurrentdirectorya -Description -= Calculate the current directory name and compare to that -= returned by GetCurrentDirectoryA - diff --git a/src/pal/tests/palsuite/file_io/GetCurrentDirectoryW/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetCurrentDirectoryW/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/file_io/GetCurrentDirectoryW/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/file_io/GetCurrentDirectoryW/test1/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetCurrentDirectoryW/test1/CMakeLists.txt deleted file mode 100644 index 96b148c1b..000000000 --- a/src/pal/tests/palsuite/file_io/GetCurrentDirectoryW/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - GetCurrentDirectoryW.cpp -) - -add_executable(paltest_getcurrentdirectoryw_test1 - ${SOURCES} -) - -add_dependencies(paltest_getcurrentdirectoryw_test1 coreclrpal) - -target_link_libraries(paltest_getcurrentdirectoryw_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/GetCurrentDirectoryW/test1/GetCurrentDirectoryW.cpp b/src/pal/tests/palsuite/file_io/GetCurrentDirectoryW/test1/GetCurrentDirectoryW.cpp deleted file mode 100644 index 4f4697b0a..000000000 --- a/src/pal/tests/palsuite/file_io/GetCurrentDirectoryW/test1/GetCurrentDirectoryW.cpp +++ /dev/null @@ -1,106 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: GetCurrentDirectoryW.c (test 1) -** -** Purpose: Tests the PAL implementation of the GetCurrentDirectoryW function. -** -** -**===================================================================*/ - -#include - - -int __cdecl main(int argc, char *argv[]) -{ - DWORD dwRc = 0; - DWORD dwRc2 = 0; - WCHAR szwReturnedPath[_MAX_PATH+1]; - WCHAR szwCurrentDir[_MAX_PATH+1]; - WCHAR szwFileName[_MAX_PATH] = {'b','l','a','h','\0'}; - LPWSTR pPathPtr; - size_t nCount = 0; - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - /* use GetFullPathName to to get the current path by stripping - * the file name off the end */ - memset(szwReturnedPath, 0, sizeof(WCHAR)*(_MAX_PATH+1)); - dwRc = GetFullPathNameW(szwFileName, _MAX_PATH, szwReturnedPath, &pPathPtr); - if (dwRc == 0) - { - /* GetFullPathName failed */ - Fail("GetCurrentDirectoryW: ERROR -> GetFullPathNameW failed " - "with error code: %ld.\n", GetLastError()); - } - else if(dwRc >_MAX_PATH) - { - Fail("GetCurrentDirectoryW: ERROR -> The path name GetFullPathNameW " - "returned is longer than _MAX_PATH characters.\n"); - } - - /* strip the file name from the full path to get the current path */ - nCount = wcslen(szwReturnedPath) - wcslen(szwFileName) - 1; - memset(szwCurrentDir, 0, sizeof(WCHAR)*(_MAX_PATH+1)); - memcpy(szwCurrentDir, szwReturnedPath, nCount*sizeof(WCHAR)); - - /* compare the results of GetCurrentDirectoryW with the above */ - memset(szwReturnedPath, 0, sizeof(WCHAR)*(_MAX_PATH+1)); - dwRc = GetCurrentDirectoryW((sizeof(WCHAR)*(_MAX_PATH+1)), szwReturnedPath); - if (dwRc == 0) - { - Fail("GetCurrentDirectoryW: ERROR -> GetCurrentDirectoryW failed " - "with error code: %ld.\n", GetLastError()); - } - else if(dwRc >_MAX_PATH) - { - Fail("GetCurrentDirectoryW: ERROR -> The path name " - "returned is longer than _MAX_PATH characters.\n"); - } - - /* check to see whether the length of the returned string is equal to - * the DWORD returned by GetCurrentDirectoryW. - */ - if(wcslen(szwReturnedPath) != dwRc) - { - Fail("GetCurrentDirectoryW: ERROR -> The Length of the path name " - "returned \"%u\" is not equal to the return value of the " - "function \"%u\".\n" , wcslen(szwReturnedPath), dwRc); - } - - - - /* test case the passed buffer size is not big enough - * function should return the size required + 1 for a terminating null character - */ - - /* good buffer size */ - dwRc = GetCurrentDirectoryW((sizeof(WCHAR)*(_MAX_PATH+1)), szwReturnedPath); - - /* small buffer (0 size)*/ - dwRc2 = GetCurrentDirectoryW(0, szwReturnedPath); - if (dwRc2 != (dwRc+1) ) - { - Fail("GetCurrentDirectoryW: ERROR -> failed to give the correct " - "return value when passed a buffer not big enough. " - "Expected %u while result is %u ",(dwRc+1),dwRc2); - - } - - if (wcsncmp(szwReturnedPath, szwCurrentDir, wcslen(szwReturnedPath)) != 0) - { - Fail("GetCurrentDirectoryW: ERROR -> The computed and returned " - "directories do not compare.\n"); - } - - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/file_io/GetCurrentDirectoryW/test1/testinfo.dat b/src/pal/tests/palsuite/file_io/GetCurrentDirectoryW/test1/testinfo.dat deleted file mode 100644 index 4443a7983..000000000 --- a/src/pal/tests/palsuite/file_io/GetCurrentDirectoryW/test1/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = GetCurrentDirectoryW -Name = Test for GetCurrentDirectoryW (test 1) -Type = DEFAULT -EXE1 = getcurrentdirectoryw -Description -= Compute the current directory and compare with the results -= from GetCurrentDirectoryW - diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesA/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFileAttributesA/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/file_io/GetFileAttributesA/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/.hidden_directory/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/.hidden_directory/CMakeLists.txt deleted file mode 100644 index a8fd22740..000000000 --- a/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/.hidden_directory/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/.hidden_directory/keepme b/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/.hidden_directory/keepme deleted file mode 100644 index 31eade721..000000000 --- a/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/.hidden_directory/keepme +++ /dev/null @@ -1 +0,0 @@ -Make CVS checkout this directory even with -p option. \ No newline at end of file diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/.hidden_file b/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/.hidden_file deleted file mode 100644 index 0d1ac31cf..000000000 --- a/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/.hidden_file +++ /dev/null @@ -1 +0,0 @@ -Hidden file \ No newline at end of file diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/.hidden_ro_directory/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/.hidden_ro_directory/CMakeLists.txt deleted file mode 100644 index a8fd22740..000000000 --- a/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/.hidden_ro_directory/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/.hidden_ro_directory/keepme b/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/.hidden_ro_directory/keepme deleted file mode 100644 index 31eade721..000000000 --- a/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/.hidden_ro_directory/keepme +++ /dev/null @@ -1 +0,0 @@ -Make CVS checkout this directory even with -p option. \ No newline at end of file diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/.hidden_ro_file b/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/.hidden_ro_file deleted file mode 100644 index 8f78fcb43..000000000 --- a/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/.hidden_ro_file +++ /dev/null @@ -1 +0,0 @@ -.hidden_ro_file diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/CMakeLists.txt deleted file mode 100644 index fa2182242..000000000 --- a/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/CMakeLists.txt +++ /dev/null @@ -1,24 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - GetFileAttributesA.cpp -) - -add_executable(paltest_getfileattributesa_test1 - ${SOURCES} -) - -add_dependencies(paltest_getfileattributesa_test1 coreclrpal) - -target_link_libraries(paltest_getfileattributesa_test1 - ${COMMON_TEST_LIBRARIES} -) -add_subdirectory(.hidden_directory) -add_subdirectory(.hidden_ro_directory) -add_subdirectory(normal_test_directory) -add_subdirectory(no_directory) -add_subdirectory(ro_test_directory) -add_subdirectory(rw_directory) - diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/GetFileAttributesA.cpp b/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/GetFileAttributesA.cpp deleted file mode 100644 index ff6bd0b8e..000000000 --- a/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/GetFileAttributesA.cpp +++ /dev/null @@ -1,340 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================= -** -** Source: GetFileAttributesA.c -** -** Purpose: Tests the PAL implementation of the GetFileAttributesA function by -** checking the attributes of: -** - a normal directory and file -** - a read only directory and file -** - a read write directory and file -** - a hidden directory and file -** - a read only hidden directory and file -** - a directory and a file with no attributes -** - an invalid file name -** -** -**===========================================================================*/ -#include - -const int TYPE_DIR = 0; -const int TYPE_FILE = 1; -/* Structure defining a test case */ -typedef struct -{ - char *name; /* name of the file/directory */ - DWORD expectedAttribs; /* expected attributes */ - HANDLE hFile; /* Handle to the file */ - int isFile; /* is file (1) or dir (0) */ -}TestCaseFile; - -typedef struct -{ - char *name; /* name of the file/directory */ - DWORD expectedAttribs; /* expected attributes */ - HANDLE hFile; /* Handle to the file */ - int isFile; /* is file (1) or dir (0) */ -}TestCaseDir; - -DWORD desiredAccessFile = GENERIC_READ | GENERIC_WRITE; -DWORD shareModeFile = FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE; -LPSECURITY_ATTRIBUTES lpAttrFile = NULL; -DWORD dwCreationDispFile = CREATE_NEW; -DWORD dwFlagsAttribFile = FILE_ATTRIBUTE_NORMAL; -HANDLE hTemplateFile = NULL; - -int numFileTests = 6; -TestCaseFile gfaTestsFile[6]; /* GetFileAttributes tests list */ - -int numDirTests = 6; -TestCaseDir gfaTestsDir[6]; /* GetFileAttributes tests list */ - -BOOL CleanUpFiles() -{ - DWORD dwAtt; - int i; - BOOL result = TRUE; - for (i = 0; i < numFileTests -1 ; i++ ) - { - dwAtt = GetFileAttributesA(gfaTestsFile[i].name); - - if( dwAtt != INVALID_FILE_ATTRIBUTES ) - { - //Trace("Files iteration %d\n", i); - if(!SetFileAttributesA (gfaTestsFile[i].name, FILE_ATTRIBUTE_NORMAL)) - { - result = FALSE; - Trace("ERROR:%d: Error setting attributes [%s][%d]\n", GetLastError(), gfaTestsFile[i].name, FILE_ATTRIBUTE_NORMAL); - } - - if(!DeleteFileA (gfaTestsFile[i].name)) - { - result = FALSE; - Trace("ERROR:%d: Error deleting file [%s][%d]\n", GetLastError(), gfaTestsFile[i].name, dwAtt); - } - - } - } -// Trace("Value of result is %d\n", result); - return result; -} -BOOL SetUpFiles() -{ - int i = 0; - BOOL result = TRUE; - for (i = 0; i < numFileTests -1; i++ ) - { - gfaTestsFile[i].hFile = CreateFile(gfaTestsFile[i].name, - desiredAccessFile, - shareModeFile, - lpAttrFile, - dwCreationDispFile, - dwFlagsAttribFile, - hTemplateFile); - - if( gfaTestsFile[i].hFile == NULL ) - { - Fail("Error while creating files for iteration %d\n", i); - } - - if(!SetFileAttributesA (gfaTestsFile[i].name, gfaTestsFile[i].expectedAttribs)) - { - result = FALSE; - Trace("ERROR:%d: Error setting attributes [%s][%d]\n", GetLastError(), gfaTestsFile[i].name, gfaTestsFile[i].expectedAttribs); - } - } - - return result; -} - -BOOL CleanUpDirs() -{ - DWORD dwAtt; - int i; - BOOL result = TRUE; - for (i = 0; i < numDirTests -1 ; i++ ) - { - dwAtt = GetFileAttributesA(gfaTestsDir[i].name); - - if( dwAtt != INVALID_FILE_ATTRIBUTES ) - { - - if(!SetFileAttributesA (gfaTestsDir[i].name, FILE_ATTRIBUTE_DIRECTORY)) - { - result = FALSE; - Trace("ERROR:%d: Error setting attributes [%s][%d]\n", GetLastError(), gfaTestsDir[i].name, (FILE_ATTRIBUTE_NORMAL | FILE_ATTRIBUTE_DIRECTORY)); - } - - if(!RemoveDirectoryA (gfaTestsDir[i].name)) - { - result = FALSE; - Trace("ERROR:%d: Error deleting file [%s][%d]\n", GetLastError(), gfaTestsDir[i].name, dwAtt); - } - - } - } - - return result; -} - -BOOL SetUpDirs() -{ - int i = 0; - BOOL result = TRUE; - DWORD ret = 0; - for (i = 0; i < numDirTests - 1 ; i++ ) - { - result = CreateDirectory(gfaTestsDir[i].name, - NULL); - - if(!result ) - { - result = FALSE; - Fail("Error while creating directory for iteration %d\n", i); - } - - if(!SetFileAttributesA (gfaTestsDir[i].name, gfaTestsDir[i].expectedAttribs)) - { - result = FALSE; - Trace("ERROR:%d: Error setting attributes [%s][%d]\n", GetLastError(), gfaTestsDir[i].name, gfaTestsDir[i].expectedAttribs); - } - - ret = GetFileAttributesA (gfaTestsDir[i].name); - if(ret != gfaTestsDir[i].expectedAttribs) - { - result = FALSE; - Trace("ERROR: Error setting attributes [%s][%d]\n", gfaTestsDir[i].name, gfaTestsDir[i].expectedAttribs); - } - //Trace("Setup Dir setting attr [%d], returned [%d]\n", gfaTestsDir[i].expectedAttribs, ret); - - } - //Trace("Setup dirs returning %d\n", result); - return result; -} -int __cdecl main(int argc, char **argv) -{ - int i; - BOOL bFailed = FALSE; - DWORD result; - - char * NormalDirectoryName = "normal_test_directory"; - char * ReadOnlyDirectoryName = "ro_test_directory"; - char * ReadWriteDirectoryName = "rw_directory"; - char * HiddenDirectoryName = ".hidden_directory"; - char * HiddenReadOnlyDirectoryName = ".hidden_ro_directory"; - char * NoDirectoryName = "no_directory"; - - char * NormalFileName = "normal_test_file"; - char * ReadOnlyFileName = "ro_test_file"; - char * ReadWriteFileName = "rw_file"; - char * HiddenFileName = ".hidden_file"; - char * HiddenReadOnlyFileName = ".hidden_ro_file"; - char * NotReallyAFileName = "not_really_a_file"; - - /* Tests on directory */ - gfaTestsDir[0].name = NormalDirectoryName; - gfaTestsDir[0].expectedAttribs = FILE_ATTRIBUTE_DIRECTORY; - gfaTestsDir[0].isFile = TYPE_DIR; - - gfaTestsDir[1].name = ReadOnlyDirectoryName; - gfaTestsDir[1].expectedAttribs = FILE_ATTRIBUTE_DIRECTORY | - FILE_ATTRIBUTE_READONLY; - gfaTestsDir[1].isFile = TYPE_DIR; - - gfaTestsDir[2].name = ReadWriteDirectoryName; - gfaTestsDir[2].expectedAttribs = FILE_ATTRIBUTE_DIRECTORY; - gfaTestsDir[2].isFile = TYPE_DIR; - - gfaTestsDir[3].name = HiddenDirectoryName; - gfaTestsDir[3].expectedAttribs = FILE_ATTRIBUTE_DIRECTORY; //| - //FILE_ATTRIBUTE_HIDDEN; - gfaTestsDir[3].isFile = TYPE_DIR; - - gfaTestsDir[4].name = HiddenReadOnlyDirectoryName; - gfaTestsDir[4].expectedAttribs = FILE_ATTRIBUTE_DIRECTORY | - FILE_ATTRIBUTE_READONLY; //| - //FILE_ATTRIBUTE_HIDDEN; - gfaTestsDir[4].isFile = TYPE_DIR; - - gfaTestsDir[5].name = NoDirectoryName; - gfaTestsDir[5].expectedAttribs = INVALID_FILE_ATTRIBUTES; - gfaTestsDir[5].isFile = TYPE_DIR; - - /* Tests on file */ - gfaTestsFile[0].name = NormalFileName; - gfaTestsFile[0].expectedAttribs = FILE_ATTRIBUTE_NORMAL; - gfaTestsFile[0].isFile = TYPE_FILE; - - - gfaTestsFile[1].name = ReadOnlyFileName; - gfaTestsFile[1].expectedAttribs = FILE_ATTRIBUTE_READONLY; - gfaTestsFile[1].isFile = TYPE_FILE; - - gfaTestsFile[2].name = ReadWriteFileName; - gfaTestsFile[2].expectedAttribs = FILE_ATTRIBUTE_NORMAL; - gfaTestsFile[2].isFile = TYPE_FILE; - - gfaTestsFile[3].name = HiddenFileName; - gfaTestsFile[3].expectedAttribs = FILE_ATTRIBUTE_NORMAL; //FILE_ATTRIBUTE_HIDDEN; - gfaTestsFile[3].isFile = TYPE_FILE; - - gfaTestsFile[4].name = HiddenReadOnlyFileName; - gfaTestsFile[4].expectedAttribs = FILE_ATTRIBUTE_READONLY; //| - //FILE_ATTRIBUTE_HIDDEN; - gfaTestsFile[4].isFile = TYPE_FILE; - - - gfaTestsFile[5].name = NotReallyAFileName; - gfaTestsFile[5].expectedAttribs = INVALID_FILE_ATTRIBUTES; - gfaTestsFile[5].isFile = TYPE_FILE; - - /* Initialize PAL environment */ - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - if(!CleanUpFiles()) - { - Fail("GetFileAttributesA: Pre-Clean Up Files Failed\n"); - } - - if(0 == SetUpFiles()) - { - Fail("GetFileAttributesA: SetUp Files Failed\n"); - } - - if(!CleanUpDirs()) - { - Fail("GetFileAttributesA: Pre-Clean Up Directories Failed\n"); - } - - if(!SetUpDirs()) - { - Fail("GetFileAttributesA: SetUp Directories Failed\n"); - } - - /* - * Go through all the test cases above, - * call GetFileAttributesA on the name and - * make sure the return value is the one expected - */ - for( i = 0; i < numFileTests; i++ ) - { - result = GetFileAttributesA(gfaTestsFile[i].name); - - if( result != gfaTestsFile[i].expectedAttribs ) - { - bFailed = TRUE; - - Trace("ERROR: GetFileAttributesA Test#%u on %s " - "returned %u instead of %u. \n", - i, - gfaTestsFile[i].name, - result, - gfaTestsFile[i].expectedAttribs); - - } - } - - - for( i = 0; i < numDirTests; i++ ) - { - result = GetFileAttributesA(gfaTestsDir[i].name); - - if( result != gfaTestsDir[i].expectedAttribs ) - { - bFailed = TRUE; - - Trace("ERROR: GetFileAttributesA on Directories Test#%u on %s " - "returned %u instead of %u. \n", - i, - gfaTestsDir[i].name, - result, - gfaTestsDir[i].expectedAttribs); - - } - } - - if(!CleanUpFiles()) - { - Fail("GetFileAttributesA: Post-Clean Up Files Failed\n"); - } - - if(!CleanUpDirs()) - { - Fail("GetFileAttributesA: Post-Clean Up Directories Failed\n"); - } - - /* If any errors, just call Fail() */ - if( bFailed ) - { - Fail(""); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/no_directory/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/no_directory/CMakeLists.txt deleted file mode 100644 index a8fd22740..000000000 --- a/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/no_directory/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/no_directory/keepme b/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/no_directory/keepme deleted file mode 100644 index 31eade721..000000000 --- a/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/no_directory/keepme +++ /dev/null @@ -1 +0,0 @@ -Make CVS checkout this directory even with -p option. \ No newline at end of file diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/no_file b/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/no_file deleted file mode 100644 index 3d631e810..000000000 --- a/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/no_file +++ /dev/null @@ -1 +0,0 @@ -No attribs file \ No newline at end of file diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/normal_test_directory/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/normal_test_directory/CMakeLists.txt deleted file mode 100644 index a8fd22740..000000000 --- a/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/normal_test_directory/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/normal_test_directory/keepme b/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/normal_test_directory/keepme deleted file mode 100644 index 31eade721..000000000 --- a/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/normal_test_directory/keepme +++ /dev/null @@ -1 +0,0 @@ -Make CVS checkout this directory even with -p option. \ No newline at end of file diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/normal_test_file b/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/normal_test_file deleted file mode 100644 index a6e1e627a..000000000 --- a/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/normal_test_file +++ /dev/null @@ -1,6 +0,0 @@ -file_io -CopyFileW -Positive Test for CopyFileW -test the CopyFileW function -DEFAULT -CopyFileW \ No newline at end of file diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/ro_test_directory/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/ro_test_directory/CMakeLists.txt deleted file mode 100644 index a8fd22740..000000000 --- a/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/ro_test_directory/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/ro_test_directory/keepme b/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/ro_test_directory/keepme deleted file mode 100644 index 31eade721..000000000 --- a/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/ro_test_directory/keepme +++ /dev/null @@ -1 +0,0 @@ -Make CVS checkout this directory even with -p option. \ No newline at end of file diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/ro_test_file b/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/ro_test_file deleted file mode 100644 index a6e1e627a..000000000 --- a/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/ro_test_file +++ /dev/null @@ -1,6 +0,0 @@ -file_io -CopyFileW -Positive Test for CopyFileW -test the CopyFileW function -DEFAULT -CopyFileW \ No newline at end of file diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/rw_directory/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/rw_directory/CMakeLists.txt deleted file mode 100644 index a8fd22740..000000000 --- a/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/rw_directory/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/rw_directory/keepme b/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/rw_directory/keepme deleted file mode 100644 index 31eade721..000000000 --- a/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/rw_directory/keepme +++ /dev/null @@ -1 +0,0 @@ -Make CVS checkout this directory even with -p option. \ No newline at end of file diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/rw_file b/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/rw_file deleted file mode 100644 index 39d66f036..000000000 --- a/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/rw_file +++ /dev/null @@ -1 +0,0 @@ -Read Write file \ No newline at end of file diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/testinfo.dat b/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/testinfo.dat deleted file mode 100644 index 2053220bf..000000000 --- a/src/pal/tests/palsuite/file_io/GetFileAttributesA/test1/testinfo.dat +++ /dev/null @@ -1,20 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 - -Section = file_io - -Function = GetFileAttributesA - -Name = Positive Test for GetFileAttributesA - -TYPE = DEFAULT - -EXE1 = getfileattributesa - -Description - -= Test the GetFileAttributesA function - diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesExW/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFileAttributesExW/CMakeLists.txt deleted file mode 100644 index ef14ea535..000000000 --- a/src/pal/tests/palsuite/file_io/GetFileAttributesExW/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) - diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesExW/test1/.hidden_directory/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFileAttributesExW/test1/.hidden_directory/CMakeLists.txt deleted file mode 100644 index a8fd22740..000000000 --- a/src/pal/tests/palsuite/file_io/GetFileAttributesExW/test1/.hidden_directory/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesExW/test1/.hidden_directory/anchor.txt b/src/pal/tests/palsuite/file_io/GetFileAttributesExW/test1/.hidden_directory/anchor.txt deleted file mode 100644 index 9a277fa04..000000000 --- a/src/pal/tests/palsuite/file_io/GetFileAttributesExW/test1/.hidden_directory/anchor.txt +++ /dev/null @@ -1,2 +0,0 @@ -This file is here so this directory gets checked out even with the -P -option. \ No newline at end of file diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesExW/test1/.hidden_file b/src/pal/tests/palsuite/file_io/GetFileAttributesExW/test1/.hidden_file deleted file mode 100644 index 0d1ac31cf..000000000 --- a/src/pal/tests/palsuite/file_io/GetFileAttributesExW/test1/.hidden_file +++ /dev/null @@ -1 +0,0 @@ -Hidden file \ No newline at end of file diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesExW/test1/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFileAttributesExW/test1/CMakeLists.txt deleted file mode 100644 index 41f08e15d..000000000 --- a/src/pal/tests/palsuite/file_io/GetFileAttributesExW/test1/CMakeLists.txt +++ /dev/null @@ -1,21 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_getfileattributesexw_test1 - ${SOURCES} -) - -add_dependencies(paltest_getfileattributesexw_test1 coreclrpal) - -target_link_libraries(paltest_getfileattributesexw_test1 - ${COMMON_TEST_LIBRARIES} -) -add_subdirectory(.hidden_directory) -add_subdirectory(normal_test_directory) -add_subdirectory(ro_test_directory) - diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesExW/test1/normal_test_directory/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFileAttributesExW/test1/normal_test_directory/CMakeLists.txt deleted file mode 100644 index a8fd22740..000000000 --- a/src/pal/tests/palsuite/file_io/GetFileAttributesExW/test1/normal_test_directory/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesExW/test1/normal_test_directory/keepme b/src/pal/tests/palsuite/file_io/GetFileAttributesExW/test1/normal_test_directory/keepme deleted file mode 100644 index 31eade721..000000000 --- a/src/pal/tests/palsuite/file_io/GetFileAttributesExW/test1/normal_test_directory/keepme +++ /dev/null @@ -1 +0,0 @@ -Make CVS checkout this directory even with -p option. \ No newline at end of file diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesExW/test1/normal_test_file b/src/pal/tests/palsuite/file_io/GetFileAttributesExW/test1/normal_test_file deleted file mode 100644 index ab7622ffb..000000000 --- a/src/pal/tests/palsuite/file_io/GetFileAttributesExW/test1/normal_test_file +++ /dev/null @@ -1,6 +0,0 @@ -file_io -CopyFileW -Positive Test for CopyFileW -test the CopyFileW function -DEFAULT -CopyFileW \ No newline at end of file diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesExW/test1/ro_test_directory/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFileAttributesExW/test1/ro_test_directory/CMakeLists.txt deleted file mode 100644 index a8fd22740..000000000 --- a/src/pal/tests/palsuite/file_io/GetFileAttributesExW/test1/ro_test_directory/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesExW/test1/ro_test_directory/keepme b/src/pal/tests/palsuite/file_io/GetFileAttributesExW/test1/ro_test_directory/keepme deleted file mode 100644 index 31eade721..000000000 --- a/src/pal/tests/palsuite/file_io/GetFileAttributesExW/test1/ro_test_directory/keepme +++ /dev/null @@ -1 +0,0 @@ -Make CVS checkout this directory even with -p option. \ No newline at end of file diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesExW/test1/ro_test_file b/src/pal/tests/palsuite/file_io/GetFileAttributesExW/test1/ro_test_file deleted file mode 100644 index ab7622ffb..000000000 --- a/src/pal/tests/palsuite/file_io/GetFileAttributesExW/test1/ro_test_file +++ /dev/null @@ -1,6 +0,0 @@ -file_io -CopyFileW -Positive Test for CopyFileW -test the CopyFileW function -DEFAULT -CopyFileW \ No newline at end of file diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesExW/test1/test1.cpp b/src/pal/tests/palsuite/file_io/GetFileAttributesExW/test1/test1.cpp deleted file mode 100644 index af279ed1e..000000000 --- a/src/pal/tests/palsuite/file_io/GetFileAttributesExW/test1/test1.cpp +++ /dev/null @@ -1,176 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test1.c -** -** Purpose: Tests the PAL implementation of the GetFileAttributesExW function. -** Call the function on a normal directory and file and a read-only directory -** and file and a hidden file and directory. -** Ensure that the returned attributes and file sizes are correct. -** -** -**===================================================================*/ - -#define UNICODE -#include - -typedef enum Item -{ - IS_DIR, - IS_FILE -}ItemType; - -/* This function takes a structure and checks that the information - within the structure is correct. The 'Attribs' are the expected - file attributes, 'TheType' is IS_DIR or IS_FILE and the 'Name' is the - name of the file/directory in question. -*/ -void VerifyInfo(WIN32_FILE_ATTRIBUTE_DATA InfoStruct, - DWORD Attribs, ItemType TheType, WCHAR* Name) -{ - HANDLE hFile; - FILETIME CorrectCreation, CorrectAccess, CorrectModify; - WCHAR CopyName[64]; - - wcscpy(CopyName,Name); - free(Name); - - /* Check to see that the file attributes were recorded */ - if(InfoStruct.dwFileAttributes != Attribs) - { - Fail("ERROR: The file attributes on the file/directory were " - "recorded as being %d instead of %d.\n", - InfoStruct.dwFileAttributes, - Attribs); - } - - /* Note: We can't open a handle to a directory in windows. This - block of tests will only be run on files. - */ - if(TheType == IS_FILE) - { - - /* Get a handle to the file */ - hFile = CreateFile(CopyName, - 0, - 0, - NULL, - OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL, - NULL); - - if (hFile == INVALID_HANDLE_VALUE) - { - Fail("ERROR: Could not open a handle to the file " - "'%S'. GetLastError() returned %d.",CopyName, - GetLastError()); - } - - - if(InfoStruct.nFileSizeLow != GetFileSize(hFile,NULL)) - { - Fail("ERROR: The file size reported by GetFileAttributesEx " - "did not match the file size given by GetFileSize.\n"); - } - - if(CloseHandle(hFile) == 0) - { - Fail("ERROR: Failed to properly close the handle to the " - "file we're testing. GetLastError() returned %d.\n", - GetLastError()); - - } - - } - - -} - -/* Given a file/directory name, the expected attribs and whether or not it - is a file or directory, call GetFileAttributesEx and verify the - results are correct. -*/ - -void RunTest(char* Name, DWORD Attribs, ItemType TheType ) -{ - WCHAR* TheName; - WIN32_FILE_ATTRIBUTE_DATA InfoStruct; - DWORD TheResult; - - TheName = convert(Name); - - TheResult = GetFileAttributesEx(TheName, - GetFileExInfoStandard, - &InfoStruct); - if(TheResult == 0) - { - free(TheName); - Fail("ERROR: GetFileAttributesEx returned 0, indicating failure. " - "GetLastError returned %d.\n",GetLastError()); - } - - VerifyInfo(InfoStruct, Attribs, TheType, TheName); - -} - -int __cdecl main(int argc, char **argv) -{ - DWORD TheResult; - WCHAR* FileName; - WIN32_FILE_ATTRIBUTE_DATA InfoStruct; - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - /* Test a Directroy */ - RunTest("normal_test_directory", FILE_ATTRIBUTE_DIRECTORY, IS_DIR); - - - /* Test a Normal File */ - - RunTest("normal_test_file", FILE_ATTRIBUTE_NORMAL, IS_FILE); - - /* Test a Read-Only Directroy */ - - RunTest("ro_test_directory", - FILE_ATTRIBUTE_READONLY|FILE_ATTRIBUTE_DIRECTORY, IS_DIR); - - /* Test a Read-Only File */ - - RunTest("ro_test_file", FILE_ATTRIBUTE_READONLY, IS_FILE); - - /* Test a Hidden File */ - - RunTest(".hidden_file", FILE_ATTRIBUTE_HIDDEN, IS_FILE); - - /* Test a Hidden Directroy */ - - RunTest(".hidden_directory", - FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_DIRECTORY, IS_DIR); - - /* Test a Non-Existant File */ - - FileName = convert("nonexistent_test_file"); - - TheResult = GetFileAttributesEx(FileName, - GetFileExInfoStandard, - &InfoStruct); - - if(TheResult != 0) - { - free(FileName); - Fail("ERROR: GetFileAttributesEx returned non-zero, indicating " - "success when it should have failed. It was called on a " - "non-existent file."); - } - - free(FileName); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesExW/test1/testinfo.dat b/src/pal/tests/palsuite/file_io/GetFileAttributesExW/test1/testinfo.dat deleted file mode 100644 index fbc397eac..000000000 --- a/src/pal/tests/palsuite/file_io/GetFileAttributesExW/test1/testinfo.dat +++ /dev/null @@ -1,16 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = GetFileAttributesExW -Name = Test with normal file/dir and readonly file/dir and hidden file/dir -TYPE = DEFAULT -EXE1 = test1 -Description -= Tests the PAL implementation of the GetFileAttributesExW function. -= Call the function on a normal directory and file and a read-only directory -= and file and a hidden file and directory. -= Ensure that the attributes returned are correct, and the -= file times and file sizes. diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesExW/test2/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFileAttributesExW/test2/CMakeLists.txt deleted file mode 100644 index 193b4a514..000000000 --- a/src/pal/tests/palsuite/file_io/GetFileAttributesExW/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test2.cpp -) - -add_executable(paltest_getfileattributesexw_test2 - ${SOURCES} -) - -add_dependencies(paltest_getfileattributesexw_test2 coreclrpal) - -target_link_libraries(paltest_getfileattributesexw_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesExW/test2/test2.cpp b/src/pal/tests/palsuite/file_io/GetFileAttributesExW/test2/test2.cpp deleted file mode 100644 index f244a3bf6..000000000 --- a/src/pal/tests/palsuite/file_io/GetFileAttributesExW/test2/test2.cpp +++ /dev/null @@ -1,170 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: getfileattributesexw.c (getfileattributesexw\test2) -** -** Purpose: Tests the PAL implementation of GetFileAttributesExW. -** First get a file's attributes, modify the file, -** re-get its attributes -** and compare the two sets of attributes. -** -** -**===================================================================*/ -#include - -/** - * This is a helper function which takes two FILETIME structures and - * checks that the second time isn't before the first. - */ -static int IsFileTimeOk(FILETIME FirstTime, FILETIME SecondTime) -{ - - ULONG64 TimeOne, TimeTwo; - - TimeOne = ((((ULONG64)FirstTime.dwHighDateTime)<<32) | - ((ULONG64)FirstTime.dwLowDateTime)); - - TimeTwo = ((((ULONG64)SecondTime.dwHighDateTime)<<32) | - ((ULONG64)SecondTime.dwLowDateTime)); - - return(TimeOne <= TimeTwo); -} - -int __cdecl main(int argc, char **argv) -{ - DWORD res; - char fileName[MAX_PATH] = "test_file"; - WCHAR *wFileName; - WIN32_FILE_ATTRIBUTE_DATA beforeAttribs; - WIN32_FILE_ATTRIBUTE_DATA afterAttribs; - FILE *testFile; - ULONG64 beforeFileSize; - ULONG64 afterFileSize; - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - /* Create the file */ - testFile = fopen(fileName, "w+"); - if( NULL == testFile ) - { - Fail("Unexpected error: Unable to open file %S " - "with fopen. \n", - fileName); - } - - if( EOF == fputs( "testing", testFile ) ) - { - Fail("Unexpected error: Unable to write to file %S " - "with fputs. \n", - fileName); - } - - if( 0 != fclose(testFile) ) - { - Fail("Unexpected error: Unable to close file %S " - "with fclose. \n", - fileName); - } - - /* Test the Values returned by GetFileAttributesExW - * before and after manipulating a file shouldn't be the same. - */ - - wFileName = convert(fileName); - - res = GetFileAttributesExW(wFileName, - GetFileExInfoStandard, - &beforeAttribs); - - if(res == 0) - { - Fail("ERROR: unable to get initial file attributes with " - "GetFileAttributesEx that returned 0 with error %d.\n", - GetLastError()); - } - - /* Make sure the time are different */ - Sleep(500); - - testFile = fopen(fileName, "w+"); - if( NULL == testFile ) - { - Fail("Unexpected error: Unable to open file %S " - "with fopen. \n", - fileName); - } - - if( EOF == fputs( "testing GetFileAttributesExW", testFile ) ) - { - Fail("Unexpected error: Unable to write to file %S " - "with fputs. \n", - fileName); - } - - if( 0 != fclose(testFile) ) - { - Fail("Unexpected error: Unable to close file %S " - "with fclose. \n", - fileName); - } - - res = GetFileAttributesExW(wFileName, - GetFileExInfoStandard, - &afterAttribs); - - if(res == 0) - { - Fail("ERROR: unable to get file attributes after operations with " - "GetFileAttributesEx that returned 0 with error %d.\n", - GetLastError()); - } - - /* Check the creation time */ - if(!IsFileTimeOk(beforeAttribs.ftCreationTime, - afterAttribs.ftCreationTime)) - { - Fail("ERROR: Creation time after the fputs operation " - "is earlier than the creation time before the fputs.\n"); - } - - /* Check the last access time */ - if(!IsFileTimeOk(beforeAttribs.ftLastAccessTime, - afterAttribs.ftLastAccessTime)) - { - Fail("ERROR: Last access time after the fputs operation " - "is earlier than the last access time before the fputs.\n"); - } - - /* Check the last write time */ - if(!IsFileTimeOk(beforeAttribs.ftLastWriteTime, - afterAttribs.ftLastWriteTime)) - { - Fail("ERROR: Last write time after the fputs operation " - "is earlier than the last write time before the fputs.\n"); - } - - beforeFileSize = ((ULONG64)beforeAttribs.nFileSizeHigh)<< 32 | - ((ULONG64)beforeAttribs.nFileSizeLow); - - afterFileSize = ((ULONG64)afterAttribs.nFileSizeHigh)<< 32 | - ((ULONG64)afterAttribs.nFileSizeLow); - - /* Check the file size */ - if( afterFileSize <= beforeFileSize ) - { - Fail("ERROR: the file should have had a bigger size " - "after(%d) the operations than before(%d)\n", - afterAttribs.nFileSizeLow, - beforeAttribs.nFileSizeLow); - } - - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesExW/test2/testinfo.dat b/src/pal/tests/palsuite/file_io/GetFileAttributesExW/test2/testinfo.dat deleted file mode 100644 index 560e3f626..000000000 --- a/src/pal/tests/palsuite/file_io/GetFileAttributesExW/test2/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = GetFileAttributesExW -Name = Test for GetFileAttributesExW -TYPE = DEFAULT -EXE1 = test2 -Description -= Tests the PAL implementation of the GetFileAttributesExW function. -= First get a file's attributes, modify the file, re-get its attributes -= and compare the two sets of attributes diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesW/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFileAttributesW/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/file_io/GetFileAttributesW/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/.hidden_directory/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/.hidden_directory/CMakeLists.txt deleted file mode 100644 index a8fd22740..000000000 --- a/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/.hidden_directory/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/.hidden_directory/keepme b/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/.hidden_directory/keepme deleted file mode 100644 index 31eade721..000000000 --- a/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/.hidden_directory/keepme +++ /dev/null @@ -1 +0,0 @@ -Make CVS checkout this directory even with -p option. \ No newline at end of file diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/.hidden_file b/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/.hidden_file deleted file mode 100644 index 0d1ac31cf..000000000 --- a/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/.hidden_file +++ /dev/null @@ -1 +0,0 @@ -Hidden file \ No newline at end of file diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/.hidden_ro_directory/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/.hidden_ro_directory/CMakeLists.txt deleted file mode 100644 index a8fd22740..000000000 --- a/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/.hidden_ro_directory/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/.hidden_ro_directory/keepme b/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/.hidden_ro_directory/keepme deleted file mode 100644 index 31eade721..000000000 --- a/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/.hidden_ro_directory/keepme +++ /dev/null @@ -1 +0,0 @@ -Make CVS checkout this directory even with -p option. \ No newline at end of file diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/.hidden_ro_file b/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/.hidden_ro_file deleted file mode 100644 index 8f78fcb43..000000000 --- a/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/.hidden_ro_file +++ /dev/null @@ -1 +0,0 @@ -.hidden_ro_file diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/CMakeLists.txt deleted file mode 100644 index d64a455a8..000000000 --- a/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/CMakeLists.txt +++ /dev/null @@ -1,24 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - GetFileAttributesW.cpp -) - -add_executable(paltest_getfileattributesw_test1 - ${SOURCES} -) - -add_dependencies(paltest_getfileattributesw_test1 coreclrpal) - -target_link_libraries(paltest_getfileattributesw_test1 - ${COMMON_TEST_LIBRARIES} -) -add_subdirectory(.hidden_directory) -add_subdirectory(.hidden_ro_directory) -add_subdirectory(normal_test_directory) -add_subdirectory(no_directory) -add_subdirectory(ro_test_directory) -add_subdirectory(rw_test_directory) - diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/GetFileAttributesW.cpp b/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/GetFileAttributesW.cpp deleted file mode 100644 index 9d00da4bd..000000000 --- a/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/GetFileAttributesW.cpp +++ /dev/null @@ -1,345 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================= -** -** Source: GetFileAttributesW.c -** -** Purpose: Tests the PAL implementation of the GetFileAttributesW function by -** checking the attributes of: -** - a normal directory and file -** - a read only directory and file -** - a read write directory and file -** - a hidden directory and file -** - a read only hidden directory and file -** - a directory and a file with no attributes -** - an invalid file name -** -** -**===========================================================================*/ -#include - -const int TYPE_DIR = 0; -const int TYPE_FILE = 1; -/* Structure defining a test case */ -typedef struct -{ - char *name; /* name of the file/directory */ - DWORD expectedAttribs; /* expected attributes */ - HANDLE hFile; /* Handle to the file */ - int isFile; /* is file (1) or dir (0) */ -}TestCaseFile; - -typedef struct -{ - char *name; /* name of the file/directory */ - DWORD expectedAttribs; /* expected attributes */ - HANDLE hFile; /* Handle to the file */ - int isFile; /* is file (1) or dir (0) */ -}TestCaseDir; - -DWORD desiredAccessFile = GENERIC_READ | GENERIC_WRITE; -DWORD shareModeFile = FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE; -LPSECURITY_ATTRIBUTES lpAttrFile = NULL; -DWORD dwCreationDispFile = CREATE_NEW; -DWORD dwFlagsAttribFile = FILE_ATTRIBUTE_NORMAL; -HANDLE hTemplateFile = NULL; - -int numFileTests = 6; -TestCaseFile gfaTestsFile[6]; /* GetFileAttributes tests list */ - -int numDirTests = 6; -TestCaseDir gfaTestsDir[6]; /* GetFileAttributes tests list */ - -BOOL CleanUpFiles() -{ - DWORD dwAtt; - int i; - BOOL result = TRUE; - for (i = 0; i < numFileTests - 1 ; i++ ) - { - dwAtt = GetFileAttributesA(gfaTestsFile[i].name); - - if( dwAtt != INVALID_FILE_ATTRIBUTES ) - { - //Trace("Files iteration %d\n", i); - if(!SetFileAttributesA (gfaTestsFile[i].name, FILE_ATTRIBUTE_NORMAL)) - { - result = FALSE; - Trace("ERROR:%d: Error setting attributes [%s][%d]\n", GetLastError(), gfaTestsFile[i].name, FILE_ATTRIBUTE_NORMAL); - } - - if(!DeleteFileA (gfaTestsFile[i].name)) - { - result = FALSE; - Trace("ERROR:%d: Error deleting file [%s][%d]\n", GetLastError(), gfaTestsFile[i].name, dwAtt); - } - - } - } -// Trace("Value of result is %d\n", result); - return result; -} -BOOL SetUpFiles() -{ - int i = 0; - BOOL result = TRUE; - for (i = 0; i < numFileTests - 1 ; i++ ) - { - gfaTestsFile[i].hFile = CreateFile(gfaTestsFile[i].name, - desiredAccessFile, - shareModeFile, - lpAttrFile, - dwCreationDispFile, - dwFlagsAttribFile, - hTemplateFile); - - if( gfaTestsFile[i].hFile == NULL ) - { - Fail("Error while creating files for iteration %d\n", i); - } - - if(!SetFileAttributesA (gfaTestsFile[i].name, gfaTestsFile[i].expectedAttribs)) - { - result = FALSE; - Trace("ERROR:%d: Error setting attributes [%s][%d]\n", GetLastError(), gfaTestsFile[i].name, gfaTestsFile[i].expectedAttribs); - } - } - - return result; -} - -BOOL CleanUpDirs() -{ - DWORD dwAtt; - int i; - BOOL result = TRUE; - for (i = 0; i < numDirTests - 1; i++ ) - { - dwAtt = GetFileAttributesA(gfaTestsDir[i].name); - - if( dwAtt != INVALID_FILE_ATTRIBUTES ) - { - - if(!SetFileAttributesA (gfaTestsDir[i].name, FILE_ATTRIBUTE_DIRECTORY)) - { - result = FALSE; - Trace("ERROR:%d: Error setting attributes [%s][%d]\n", GetLastError(), gfaTestsDir[i].name, (FILE_ATTRIBUTE_NORMAL | FILE_ATTRIBUTE_DIRECTORY)); - } - - if(!RemoveDirectoryA (gfaTestsDir[i].name)) - { - result = FALSE; - Trace("ERROR:%d: Error deleting file [%s][%d]\n", GetLastError(), gfaTestsDir[i].name, dwAtt); - } - - } - } - - return result; -} - -BOOL SetUpDirs() -{ - int i = 0; - BOOL result = TRUE; - DWORD ret = 0; - for (i = 0; i < numDirTests - 1; i++ ) - { - result = CreateDirectory(gfaTestsDir[i].name, - NULL); - - if(!result ) - { - result = FALSE; - Fail("Error while creating directory for iteration %d\n", i); - } - - if(!SetFileAttributesA (gfaTestsDir[i].name, gfaTestsDir[i].expectedAttribs)) - { - result = FALSE; - Trace("ERROR:%d: Error setting attributes [%s][%d]\n", GetLastError(), gfaTestsDir[i].name, gfaTestsDir[i].expectedAttribs); - } - - ret = GetFileAttributesA (gfaTestsDir[i].name); - if(ret != gfaTestsDir[i].expectedAttribs) - { - result = FALSE; - Trace("ERROR: Error setting attributes [%s][%d]\n", gfaTestsDir[i].name, gfaTestsDir[i].expectedAttribs); - } - // Trace("Setup Dir setting attr [%d], returned [%d]\n", gfaTestsDir[i].expectedAttribs, ret); - - } -// Trace("Setup dirs returning %d\n", result); - return result; -} -int __cdecl main(int argc, char **argv) -{ - int i; - BOOL bFailed = FALSE; - DWORD result; - - char * NormalDirectoryName = "normal_test_directory"; - char * ReadOnlyDirectoryName = "ro_test_directory"; - char * ReadWriteDirectoryName = "rw_directory"; - char * HiddenDirectoryName = ".hidden_directory"; - char * HiddenReadOnlyDirectoryName = ".hidden_ro_directory"; - char * NoDirectoryName = "no_directory"; - - char * NormalFileName = "normal_test_file"; - char * ReadOnlyFileName = "ro_test_file"; - char * ReadWriteFileName = "rw_file"; - char * HiddenFileName = ".hidden_file"; - char * HiddenReadOnlyFileName = ".hidden_ro_file"; - char * NotReallyAFileName = "not_really_a_file"; - - WCHAR *WStr; - /* Tests on directory */ - gfaTestsDir[0].name = NormalDirectoryName; - gfaTestsDir[0].expectedAttribs = FILE_ATTRIBUTE_DIRECTORY; - gfaTestsDir[0].isFile = TYPE_DIR; - - gfaTestsDir[1].name = ReadOnlyDirectoryName; - gfaTestsDir[1].expectedAttribs = FILE_ATTRIBUTE_DIRECTORY | - FILE_ATTRIBUTE_READONLY; - gfaTestsDir[1].isFile = TYPE_DIR; - - gfaTestsDir[2].name = ReadWriteDirectoryName; - gfaTestsDir[2].expectedAttribs = FILE_ATTRIBUTE_DIRECTORY; - gfaTestsDir[2].isFile = TYPE_DIR; - - gfaTestsDir[3].name = HiddenDirectoryName; - gfaTestsDir[3].expectedAttribs = FILE_ATTRIBUTE_DIRECTORY; //| - //FILE_ATTRIBUTE_HIDDEN; - gfaTestsDir[3].isFile = TYPE_DIR; - - gfaTestsDir[4].name = HiddenReadOnlyDirectoryName; - gfaTestsDir[4].expectedAttribs = FILE_ATTRIBUTE_DIRECTORY | - FILE_ATTRIBUTE_READONLY; //| - //FILE_ATTRIBUTE_HIDDEN; - gfaTestsDir[4].isFile = TYPE_DIR; - - gfaTestsDir[5].name = NoDirectoryName; - gfaTestsDir[5].expectedAttribs = INVALID_FILE_ATTRIBUTES; - gfaTestsDir[5].isFile = TYPE_DIR; - - /* Tests on file */ - gfaTestsFile[0].name = NormalFileName; - gfaTestsFile[0].expectedAttribs = FILE_ATTRIBUTE_NORMAL; - gfaTestsFile[0].isFile = TYPE_FILE; - - - gfaTestsFile[1].name = ReadOnlyFileName; - gfaTestsFile[1].expectedAttribs = FILE_ATTRIBUTE_READONLY; - gfaTestsFile[1].isFile = TYPE_FILE; - - gfaTestsFile[2].name = ReadWriteFileName; - gfaTestsFile[2].expectedAttribs = FILE_ATTRIBUTE_NORMAL; - gfaTestsFile[2].isFile = TYPE_FILE; - - gfaTestsFile[3].name = HiddenFileName; - gfaTestsFile[3].expectedAttribs = FILE_ATTRIBUTE_NORMAL; //FILE_ATTRIBUTE_HIDDEN; - gfaTestsFile[3].isFile = TYPE_FILE; - - gfaTestsFile[4].name = HiddenReadOnlyFileName; - gfaTestsFile[4].expectedAttribs = FILE_ATTRIBUTE_READONLY; //| - //FILE_ATTRIBUTE_HIDDEN; - gfaTestsFile[4].isFile = TYPE_FILE; - - - gfaTestsFile[5].name = NotReallyAFileName; - gfaTestsFile[5].expectedAttribs = INVALID_FILE_ATTRIBUTES; - gfaTestsFile[5].isFile = TYPE_FILE; - - /* Initialize PAL environment */ - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - if(!CleanUpFiles()) - { - Fail("GetFileAttributesW: Pre-Clean Up Files Failed\n"); - } - - if(0 == SetUpFiles()) - { - Fail("GetFileAttributesW: SetUp Files Failed\n"); - } - - if(!CleanUpDirs()) - { - Fail("GetFileAttributesW: Pre-Clean Up Directories Failed\n"); - } - - if(!SetUpDirs()) - { - Fail("GetFileAttributesW: SetUp Directories Failed\n"); - } - - /* - * Go through all the test cases above, - * call GetFileAttributesW on the name and - * make sure the return value is the one expected - */ - for( i = 0; i < numFileTests; i++ ) - { - WStr = convert(gfaTestsFile[i].name); - result = GetFileAttributesW(WStr); - - if( result != gfaTestsFile[i].expectedAttribs ) - { - bFailed = TRUE; - - Trace("ERROR: GetFileAttributesW Test#%u on %s " - "returned %u instead of %u. \n", - i, - gfaTestsFile[i].name, - result, - gfaTestsFile[i].expectedAttribs); - - } - free(WStr); - } - - - for( i = 0; i < numDirTests; i++ ) - { - WStr = convert(gfaTestsDir[i].name); - result = GetFileAttributesW(WStr); - - if( result != gfaTestsDir[i].expectedAttribs ) - { - bFailed = TRUE; - - Trace("ERROR: GetFileAttributesW on Directories Test#%u on %s " - "returned %u instead of %u. \n", - i, - gfaTestsDir[i].name, - result, - gfaTestsDir[i].expectedAttribs); - - } - free(WStr); - } - - if(!CleanUpFiles()) - { - Fail("GetFileAttributesW: Post-Clean Up Files Failed\n"); - } - - if(!CleanUpDirs()) - { - Fail("GetFileAttributesW: Post-Clean Up Directories Failed\n"); - } - - /* If any errors, just call Fail() */ - if( bFailed ) - { - Fail(""); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/no_directory/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/no_directory/CMakeLists.txt deleted file mode 100644 index a8fd22740..000000000 --- a/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/no_directory/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/no_directory/keepme b/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/no_directory/keepme deleted file mode 100644 index 31eade721..000000000 --- a/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/no_directory/keepme +++ /dev/null @@ -1 +0,0 @@ -Make CVS checkout this directory even with -p option. \ No newline at end of file diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/no_file b/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/no_file deleted file mode 100644 index 3d631e810..000000000 --- a/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/no_file +++ /dev/null @@ -1 +0,0 @@ -No attribs file \ No newline at end of file diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/normal_test_directory/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/normal_test_directory/CMakeLists.txt deleted file mode 100644 index a8fd22740..000000000 --- a/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/normal_test_directory/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/normal_test_directory/keepme b/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/normal_test_directory/keepme deleted file mode 100644 index 31eade721..000000000 --- a/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/normal_test_directory/keepme +++ /dev/null @@ -1 +0,0 @@ -Make CVS checkout this directory even with -p option. \ No newline at end of file diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/normal_test_file b/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/normal_test_file deleted file mode 100644 index a6e1e627a..000000000 --- a/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/normal_test_file +++ /dev/null @@ -1,6 +0,0 @@ -file_io -CopyFileW -Positive Test for CopyFileW -test the CopyFileW function -DEFAULT -CopyFileW \ No newline at end of file diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/ro_test_directory/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/ro_test_directory/CMakeLists.txt deleted file mode 100644 index a8fd22740..000000000 --- a/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/ro_test_directory/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/ro_test_directory/keepme b/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/ro_test_directory/keepme deleted file mode 100644 index 31eade721..000000000 --- a/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/ro_test_directory/keepme +++ /dev/null @@ -1 +0,0 @@ -Make CVS checkout this directory even with -p option. \ No newline at end of file diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/ro_test_file b/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/ro_test_file deleted file mode 100644 index a6e1e627a..000000000 --- a/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/ro_test_file +++ /dev/null @@ -1,6 +0,0 @@ -file_io -CopyFileW -Positive Test for CopyFileW -test the CopyFileW function -DEFAULT -CopyFileW \ No newline at end of file diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/rw_file b/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/rw_file deleted file mode 100644 index 39d66f036..000000000 --- a/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/rw_file +++ /dev/null @@ -1 +0,0 @@ -Read Write file \ No newline at end of file diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/rw_test_directory/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/rw_test_directory/CMakeLists.txt deleted file mode 100644 index a8fd22740..000000000 --- a/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/rw_test_directory/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/rw_test_directory/keepme b/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/rw_test_directory/keepme deleted file mode 100644 index 31eade721..000000000 --- a/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/rw_test_directory/keepme +++ /dev/null @@ -1 +0,0 @@ -Make CVS checkout this directory even with -p option. \ No newline at end of file diff --git a/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/testinfo.dat b/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/testinfo.dat deleted file mode 100644 index 1a8089a0f..000000000 --- a/src/pal/tests/palsuite/file_io/GetFileAttributesW/test1/testinfo.dat +++ /dev/null @@ -1,20 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 - -Section = file_io - -Function = GetFileAttributesW - -Name = Positive Test for GetFileAttributesW - -TYPE = DEFAULT - -EXE1 = getfileattributesw - -Description - -= Test the GetFileAttributesW function - diff --git a/src/pal/tests/palsuite/file_io/GetFileSize/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFileSize/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/file_io/GetFileSize/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/file_io/GetFileSize/test1/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFileSize/test1/CMakeLists.txt deleted file mode 100644 index 122004188..000000000 --- a/src/pal/tests/palsuite/file_io/GetFileSize/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - GetFileSize.cpp -) - -add_executable(paltest_getfilesize_test1 - ${SOURCES} -) - -add_dependencies(paltest_getfilesize_test1 coreclrpal) - -target_link_libraries(paltest_getfilesize_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/GetFileSize/test1/GetFileSize.cpp b/src/pal/tests/palsuite/file_io/GetFileSize/test1/GetFileSize.cpp deleted file mode 100644 index fac01c98c..000000000 --- a/src/pal/tests/palsuite/file_io/GetFileSize/test1/GetFileSize.cpp +++ /dev/null @@ -1,173 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: GetFileSize.c (test 1) -** -** Purpose: Tests the PAL implementation of the GetFileSize function. -** -** -**===================================================================*/ - -#include - -const char* szTextFile = "text.txt"; - -void CleanUp(HANDLE hFile) -{ - if (CloseHandle(hFile) != TRUE) - { - Fail("GetFileSize: ERROR -> Unable to close file \"%s\".\n", - szTextFile); - } - if (!DeleteFileA(szTextFile)) - { - Fail("GetFileSize: ERROR -> Unable to delete file \"%s\".\n", - szTextFile); - } -} - -void CheckFileSize(HANDLE hFile, DWORD dwOffset, DWORD dwHighOrder) -{ - DWORD dwRc = 0; - DWORD dwReturnedHighOrder = 0; - DWORD dwReturnedOffset = 0; - - dwRc = SetFilePointer(hFile, dwOffset, (PLONG)&dwHighOrder, FILE_BEGIN); - if (dwRc == INVALID_SET_FILE_POINTER) - { - Trace("GetFileSize: ERROR -> Call to SetFilePointer failed with %ld.\n", - GetLastError()); - CleanUp(hFile); - Fail(""); - } - else - { - if (!SetEndOfFile(hFile)) - { - Trace("GetFileSize: ERROR -> Call to SetEndOfFile failed with %ld.\n", - GetLastError()); - CleanUp(hFile); - Fail(""); - } - dwReturnedOffset = GetFileSize(hFile, &dwReturnedHighOrder); - if ((dwReturnedOffset != dwOffset) || - (dwReturnedHighOrder != dwHighOrder)) - { - CleanUp(hFile); - Fail("GetFileSize: ERROR -> File sizes do not match up.\n"); - } - } -} - - -int __cdecl main(int argc, char *argv[]) -{ - HANDLE hFile = NULL; - DWORD dwRc = 0; - DWORD dwRc2 = 0; - DWORD dwHighOrder = 0; - DWORD lpNumberOfBytesWritten; - char * data = "1234567890"; - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - - /* test on a null file handle */ - dwRc = GetFileSize(hFile, NULL); - if (dwRc != INVALID_FILE_SIZE) - { - Fail("GetFileSize: ERROR -> A file size was returned for " - "a null handle.\n"); - } - - /* test on a null file handle using the high order option */ - dwRc = GetFileSize(hFile, &dwHighOrder); - if (dwRc != INVALID_FILE_SIZE) - { - Fail("GetFileSize: ERROR -> A file size was returned for " - "a null handle.\n"); - } - - /* test on an invalid file handle */ - dwRc = GetFileSize(INVALID_HANDLE_VALUE, NULL); - if (dwRc != INVALID_FILE_SIZE) - { - Fail("GetFileSize: ERROR -> A file size was returned for " - "an invalid handle.\n"); - } - - /* test on an invalid file handle using the high order option */ - dwRc = GetFileSize(INVALID_HANDLE_VALUE, &dwHighOrder); - if (dwRc != INVALID_FILE_SIZE) - { - Fail("GetFileSize: ERROR -> A file size was returned for " - "an invalid handle.\n"); - } - - - /* create a test file */ - hFile = CreateFile(szTextFile, - GENERIC_READ | GENERIC_WRITE, - FILE_SHARE_READ | FILE_SHARE_WRITE, - NULL, - CREATE_ALWAYS, - FILE_ATTRIBUTE_NORMAL, - NULL); - - if(hFile == INVALID_HANDLE_VALUE) - { - Fail("GetFileSize: ERROR -> Unable to create file \"%s\".\n", - szTextFile); - } - - /* give the file a size */ - CheckFileSize(hFile, 256, 0); - - /* make the file large using the high order option */ - CheckFileSize(hFile, 256, 1); - - - /* set the file size to zero */ - CheckFileSize(hFile, 0, 0); - - /* test if file size changes by writing to it. */ - /* get file size */ - dwRc = GetFileSize(hFile, NULL); - - /* test writing to the file */ - if(WriteFile(hFile, data, strlen(data), &lpNumberOfBytesWritten, NULL)==0) - { - Trace("GetFileSize: ERROR -> Call to WriteFile failed with %ld.\n", - GetLastError()); - CleanUp(hFile); - Fail(""); - } - - /* make sure the buffer flushed.*/ - if(FlushFileBuffers(hFile)==0) - { - Trace("GetFileSize: ERROR -> Call to FlushFileBuffers failed with %ld.\n", - GetLastError()); - CleanUp(hFile); - Fail(""); - } - - /* get file size after writing some chars */ - dwRc2 = GetFileSize(hFile, NULL); - if((dwRc2-dwRc) !=strlen(data)) - { - CleanUp(hFile); - Fail("GetFileSize: ERROR -> File size did not increase properly after.\n" - "writing %d chars\n", strlen(data)); - } - - CleanUp(hFile); - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/file_io/GetFileSize/test1/testinfo.dat b/src/pal/tests/palsuite/file_io/GetFileSize/test1/testinfo.dat deleted file mode 100644 index 38258572d..000000000 --- a/src/pal/tests/palsuite/file_io/GetFileSize/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = GetFileSize -Name = Positive Test for GetFileSize (test 1) -Type = DEFAULT -EXE1 = getfilesize -Description -= Test GetFileSize on a NULL handle and valid file handles - diff --git a/src/pal/tests/palsuite/file_io/GetFileSizeEx/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFileSizeEx/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/file_io/GetFileSizeEx/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/file_io/GetFileSizeEx/test1/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFileSizeEx/test1/CMakeLists.txt deleted file mode 100644 index 51e7412bd..000000000 --- a/src/pal/tests/palsuite/file_io/GetFileSizeEx/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - GetFileSizeEx.cpp -) - -add_executable(paltest_getfilesizeex_test1 - ${SOURCES} -) - -add_dependencies(paltest_getfilesizeex_test1 coreclrpal) - -target_link_libraries(paltest_getfilesizeex_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/GetFileSizeEx/test1/GetFileSizeEx.cpp b/src/pal/tests/palsuite/file_io/GetFileSizeEx/test1/GetFileSizeEx.cpp deleted file mode 100644 index ef5afd0e6..000000000 --- a/src/pal/tests/palsuite/file_io/GetFileSizeEx/test1/GetFileSizeEx.cpp +++ /dev/null @@ -1,173 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: GetFileSizeEx.c (test 1) -** -** Purpose: Tests the PAL implementation of the GetFileSizeEx function. -** -** -**===================================================================*/ - -#include - -const char* szTextFile = "text.txt"; - -void CleanUp(HANDLE hFile) -{ - if (CloseHandle(hFile) != TRUE) - { - Fail("GetFileSizeEx: ERROR -> Unable to close file \"%s\".\n" - " Error is %d\n", - szTextFile, GetLastError()); - } - if (!DeleteFileA(szTextFile)) - { - Fail("GetFileSizeEx: ERROR -> Unable to delete file \"%s\".\n" - " Error is %d\n", - szTextFile, GetLastError()); - } -} - -void CheckFileSize(HANDLE hFile, DWORD dwOffset, DWORD dwHighOrder) -{ - DWORD dwRc = 0; - DWORD dwError = 0; - LARGE_INTEGER qwFileSize; - - dwRc = SetFilePointer(hFile, dwOffset, (PLONG)&dwHighOrder, FILE_BEGIN); - if (dwRc == INVALID_SET_FILE_POINTER) - { - Trace("GetFileSizeEx: ERROR -> Call to SetFilePointer failed with %ld.\n", - GetLastError()); - CleanUp(hFile); - Fail(""); - } - else - { - if (!SetEndOfFile(hFile)) - { - dwError = GetLastError(); - CleanUp(hFile); - if (dwError == 112) - { - Fail("GetFileSizeEx: ERROR -> SetEndOfFile failed due to lack of " - "disk space\n"); - } - else - { - Fail("GetFileSizeEx: ERROR -> SetEndOfFile call failed " - "with error %ld\n", dwError); - } - } - else - { - GetFileSizeEx(hFile, &qwFileSize); - if ((qwFileSize.u.LowPart != dwOffset) || - (qwFileSize.u.HighPart != dwHighOrder)) - { - CleanUp(hFile); - Fail("GetFileSizeEx: ERROR -> File sizes do not match up.\n"); - } - } - } -} - -int __cdecl main(int argc, char *argv[]) -{ - HANDLE hFile = NULL; - BOOL bRc = FALSE; - DWORD lpNumberOfBytesWritten; - LARGE_INTEGER qwFileSize; - LARGE_INTEGER qwFileSize2; - char * data = "1234567890"; - - qwFileSize.QuadPart = 0; - qwFileSize2.QuadPart = 0; - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - - /* test on a null file */ - bRc = GetFileSizeEx(NULL, &qwFileSize); - if (bRc != FALSE) - { - Fail("GetFileSizeEx: ERROR -> Returned status as TRUE for " - "a null handle.\n"); - } - - - /* test on an invalid file */ - bRc = GetFileSizeEx(INVALID_HANDLE_VALUE, &qwFileSize); - if (bRc != FALSE) - { - Fail("GetFileSizeEx: ERROR -> Returned status as TRUE for " - "an invalid handle.\n"); - } - - - /* create a test file */ - hFile = CreateFile(szTextFile, - GENERIC_READ | GENERIC_WRITE, - FILE_SHARE_READ | FILE_SHARE_WRITE, - NULL, - CREATE_ALWAYS, - FILE_ATTRIBUTE_NORMAL, - NULL); - - if(hFile == INVALID_HANDLE_VALUE) - { - Fail("GetFileSizeEx: ERROR -> Unable to create file \"%s\".\n", - szTextFile); - } - - /* give the file a size */ - CheckFileSize(hFile, 256, 0); - - /* make the file large using the high order option */ - CheckFileSize(hFile, 256, 1); - - - /* set the file size to zero */ - CheckFileSize(hFile, 0, 0); - - /* test if file size changes by writing to it. */ - /* get file size */ - GetFileSizeEx(hFile, &qwFileSize); - - /* test writing to the file */ - if(WriteFile(hFile, data, strlen(data), &lpNumberOfBytesWritten, NULL)==0) - { - Trace("GetFileSizeEx: ERROR -> Call to WriteFile failed with %ld.\n", - GetLastError()); - CleanUp(hFile); - Fail(""); - } - - /* make sure the buffer flushed.*/ - if(FlushFileBuffers(hFile)==0) - { - Trace("GetFileSizeEx: ERROR -> Call to FlushFileBuffers failed with %ld.\n", - GetLastError()); - CleanUp(hFile); - Fail(""); - } - - /* get file size after writing some chars */ - GetFileSizeEx(hFile, &qwFileSize2); - if((qwFileSize2.QuadPart-qwFileSize.QuadPart) !=strlen(data)) - { - CleanUp(hFile); - Fail("GetFileSizeEx: ERROR -> File size did not increase properly after.\n" - "writing %d chars\n", strlen(data)); - } - - CleanUp(hFile); - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/file_io/GetFileSizeEx/test1/testinfo.dat b/src/pal/tests/palsuite/file_io/GetFileSizeEx/test1/testinfo.dat deleted file mode 100644 index 5968fe727..000000000 --- a/src/pal/tests/palsuite/file_io/GetFileSizeEx/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = GetFileSizeEx -Name = Positive Test for GetFileSizeEx (test 1) -Type = DEFAULT -EXE1 = getfilesizeex -Description -= Test GetFileSizeEx on a NULL handle and valid file handles - diff --git a/src/pal/tests/palsuite/file_io/GetFullPathNameA/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFullPathNameA/CMakeLists.txt deleted file mode 100644 index a3847f8ca..000000000 --- a/src/pal/tests/palsuite/file_io/GetFullPathNameA/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) -add_subdirectory(test3) -add_subdirectory(test4) - diff --git a/src/pal/tests/palsuite/file_io/GetFullPathNameA/test1/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFullPathNameA/test1/CMakeLists.txt deleted file mode 100644 index 4370c1b15..000000000 --- a/src/pal/tests/palsuite/file_io/GetFullPathNameA/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - GetFullPathNameA.cpp -) - -add_executable(paltest_getfullpathnamea_test1 - ${SOURCES} -) - -add_dependencies(paltest_getfullpathnamea_test1 coreclrpal) - -target_link_libraries(paltest_getfullpathnamea_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/GetFullPathNameA/test1/GetFullPathNameA.cpp b/src/pal/tests/palsuite/file_io/GetFullPathNameA/test1/GetFullPathNameA.cpp deleted file mode 100644 index de9a266f5..000000000 --- a/src/pal/tests/palsuite/file_io/GetFullPathNameA/test1/GetFullPathNameA.cpp +++ /dev/null @@ -1,122 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: GetFullPathNameA.c (test 1) -** -** Purpose: Tests the PAL implementation of the GetFullPathNameA function. -** -** -**===================================================================*/ - -#include - -const char* szFileName = "testing.tmp"; - -int __cdecl main(int argc, char *argv[]) -{ - DWORD dwRc = 0; - char szReturnedPath[_MAX_DIR+1]; - char szShortBuff[2]; - LPSTR pPathPtr; - HANDLE hFile = NULL; - - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - /* perform a short buffer test */ - if (GetFullPathNameA(szFileName, 2, szShortBuff, &pPathPtr) <= 2) - { - /* this test should have failed but didn't */ - Fail("GetFullPathNameA: ERROR -> The API was passed a buffer that was" - " too small for the path name and yet it apparently passed.\n"); - } - - memset(szReturnedPath, 0, _MAX_DIR+1); - dwRc = GetFullPathNameA(szFileName, - _MAX_DIR, - szReturnedPath, - &pPathPtr); - - if (dwRc == 0) - { - // this test should have passed but didn't - Fail("GetFullPathNameA: ERROR -> Function failed for the " - "file \"%s\" with error code: %ld.\n", szFileName, GetLastError()); - } - - // the returned value should be the current directory with the - // file name appended - hFile = CreateFileA(szFileName, - GENERIC_READ, - FILE_SHARE_READ, - NULL, - CREATE_ALWAYS, - FILE_ATTRIBUTE_NORMAL, - NULL); - if (hFile == INVALID_HANDLE_VALUE) - { - Fail("GetFullPathNameA: ERROR -> CreateFileA failed to create " - "file \"%s\" with error code: %ld.\n", - szFileName, - GetLastError()); - } - if (CloseHandle(hFile) != TRUE) - { - Fail("GetFullPathNameA: ERROR -> CloseHandle failed with error " - "code: %ld.\n", GetLastError()); - } - - // now try to create the file based on the returned value with the - // CREATE_NEW option which should fail since the file should - // already exist - hFile = CreateFileA(szReturnedPath, - GENERIC_READ, - FILE_SHARE_READ, - NULL, - CREATE_NEW, - FILE_ATTRIBUTE_NORMAL, - NULL); - if (hFile != INVALID_HANDLE_VALUE) - { - Fail("GetFullPathNameA: ERROR -> CreateFileA was able to " - "CREATE_NEW the returned file \"%s\". The returned file " - "name is therefore apparently wrong.\n", - szReturnedPath); - if (CloseHandle(hFile) != TRUE) - { - Fail("GetFullPathNameA: ERROR -> CloseHandle failed with " - "error code: %ld.\n", GetLastError()); - } - if ((DeleteFileA(szReturnedPath) != TRUE) || - (DeleteFileA(szFileName) != TRUE)) - { - Fail("GetFullPathNameA: ERROR -> DeleteFileA failed to " - "delete the test files with error code: %ld.\n", - GetLastError()); - } - } - - // now make sure the pPathPtr is the same as the file name - if (strcmp(pPathPtr, szFileName) != 0) - { - Fail("GetFullPathNameA: ERROR -> %s != %s\n", - pPathPtr, szFileName); - } - if (DeleteFileA(szFileName) != TRUE) - { - Fail("GetFullPathNameA: ERROR -> DeleteFileA failed to " - "delete \"%s\" with error code: %ld.\n", - szFileName, - GetLastError()); - } - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/file_io/GetFullPathNameA/test1/testinfo.dat b/src/pal/tests/palsuite/file_io/GetFullPathNameA/test1/testinfo.dat deleted file mode 100644 index a4ccc9534..000000000 --- a/src/pal/tests/palsuite/file_io/GetFullPathNameA/test1/testinfo.dat +++ /dev/null @@ -1,15 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = GetFullPathNameA -Name = Test for GetFullPathNameA (test 1) -Type = DEFAULT -EXE1 = getfullpathnamea -Description -= Get the full path for a file name and verify the results. -= Also, attempt to call GetFullPathNameA with a buffer that is -= too small for the returned path and verify the results. - diff --git a/src/pal/tests/palsuite/file_io/GetFullPathNameA/test2/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFullPathNameA/test2/CMakeLists.txt deleted file mode 100644 index 157ca6946..000000000 --- a/src/pal/tests/palsuite/file_io/GetFullPathNameA/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test2.cpp -) - -add_executable(paltest_getfullpathnamea_test2 - ${SOURCES} -) - -add_dependencies(paltest_getfullpathnamea_test2 coreclrpal) - -target_link_libraries(paltest_getfullpathnamea_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/GetFullPathNameA/test2/test2.cpp b/src/pal/tests/palsuite/file_io/GetFullPathNameA/test2/test2.cpp deleted file mode 100644 index 95a149733..000000000 --- a/src/pal/tests/palsuite/file_io/GetFullPathNameA/test2/test2.cpp +++ /dev/null @@ -1,143 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test2.c -** -** Purpose: Tests the PAL implementation of the GetFullPathNameA API. -** GetFullPathA will be passed a directory that contains '..'. -** To add to this test, we will also call SetCurrentDirectory to -** ensure this is handled properly. -** The test will create a file with in the parent directory -** to verify that the returned directory is valid. -** -** -**===================================================================*/ - -#include - -const char* szDotDot = "..\\"; -const char* szFileName = "testing.tmp"; - -int __cdecl main(int argc, char *argv[]) -{ - DWORD dwRc = 0; - char szReturnedPath[_MAX_DIR+1]; - char szFullFileName[_MAX_DIR+1]; - LPSTR pPathPtr; - HANDLE hFile = NULL; - - /* Initialize the PAL. - */ - if (0 != PAL_Initialize(argc,argv)) - { - return (FAIL); - } - - /* change the directory */ - if (!SetCurrentDirectoryA(szDotDot)) - { - Fail("ERROR: SetCurrentDirectoryA failed with error code %u" - " when passed \"%s\".\n", - GetLastError(), - szDotDot); - } - - /* Initialize the receiving char buffers. - */ - memset(szReturnedPath, 0, _MAX_DIR+1); - memset(szFullFileName, 0, _MAX_DIR+1); - - /* Create Full filename to pass, will include '..\' - * as a pre-fix. */ - strcat(szFullFileName, szDotDot); - strcat(szFullFileName, szFileName); - - /* Get the full path to the filename. - */ - dwRc = GetFullPathNameA(szFullFileName, - _MAX_DIR, - szReturnedPath, - &pPathPtr); - if (dwRc == 0) - { - Fail("ERROR :%ld: GetFullPathName failed to " - "retrieve the path of \"%s\".\n", - GetLastError(), - szFileName); - } - - /* The returned value should be the parent directory with the - * file name appended. */ - hFile = CreateFileA(szReturnedPath, - GENERIC_READ, - FILE_SHARE_READ, - NULL, - CREATE_ALWAYS, - FILE_ATTRIBUTE_NORMAL, - NULL); - - if (hFile == INVALID_HANDLE_VALUE) - { - Fail("ERROR :%ld: CreateFileA failed to create \"%s\".\n", - GetLastError(), - szReturnedPath); - } - - /* Close the handle to the created file. - */ - if (CloseHandle(hFile) != TRUE) - { - Trace("ERROR :%ld: CloseHandle failed close hFile=0x%lx.\n", - GetLastError()); - goto terminate; - } - - /* Verify that the file was created, attempt to create - * the file again. */ - hFile = CreateFileA(szReturnedPath, - GENERIC_READ, - FILE_SHARE_READ, - NULL, - CREATE_NEW, - FILE_ATTRIBUTE_NORMAL, - NULL); - if ((hFile != INVALID_HANDLE_VALUE) && - (GetLastError() != ERROR_ALREADY_EXISTS)) - { - Fail("ERROR :%ld: CreateFileA succeeded to create file " - "\"%s\", that already existed.\n", - GetLastError(), - szFullFileName); - } - - - /* Verify that the returned filename is the same as the supplied. - */ - if (strcmp(pPathPtr, szFileName) != 0) - { - Trace("ERROR : Returned filename \"%s\" is not equal to " - "supplied filename \"%s\".\n", - pPathPtr, - szFileName); - goto terminate; - } - -terminate: - /* Delete the create file. - */ - if (DeleteFileA(szReturnedPath) != TRUE) - { - Fail("ERROR :%ld: DeleteFileA failed to delete \"%s\".\n", - GetLastError(), - szFileName); - } - - /* Terminate the PAL.*/ - PAL_Terminate(); - return PASS; -} - - diff --git a/src/pal/tests/palsuite/file_io/GetFullPathNameA/test2/testinfo.dat b/src/pal/tests/palsuite/file_io/GetFullPathNameA/test2/testinfo.dat deleted file mode 100644 index b75f48114..000000000 --- a/src/pal/tests/palsuite/file_io/GetFullPathNameA/test2/testinfo.dat +++ /dev/null @@ -1,18 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = GetFullPathNameA -Name = Test for GetFullPathNameA -Type = DEFAULT -EXE1 = test2 -Description -= Tests the PAL implementation of the GetFullPathNameA API. -= GetFullPathA will be passed a directory that contains '..'. -= To add to this test, we will also call SetCurrentDirectory to -= ensure this is handled properly. -= The test will create a file with in the parent directory -= to verify that the returned directory is valid. - diff --git a/src/pal/tests/palsuite/file_io/GetFullPathNameA/test3/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFullPathNameA/test3/CMakeLists.txt deleted file mode 100644 index 74c96185c..000000000 --- a/src/pal/tests/palsuite/file_io/GetFullPathNameA/test3/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test3.cpp -) - -add_executable(paltest_getfullpathnamea_test3 - ${SOURCES} -) - -add_dependencies(paltest_getfullpathnamea_test3 coreclrpal) - -target_link_libraries(paltest_getfullpathnamea_test3 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/GetFullPathNameA/test3/test3.cpp b/src/pal/tests/palsuite/file_io/GetFullPathNameA/test3/test3.cpp deleted file mode 100644 index 0cc39e730..000000000 --- a/src/pal/tests/palsuite/file_io/GetFullPathNameA/test3/test3.cpp +++ /dev/null @@ -1,241 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test3.c -** -** Purpose: Tests the PAL implementation of the GetFullPathNameA API. -** GetFullPathA will be passed a directory that contains '..'. -** Example: test_directory\level1\..\testing.tmp. -** To add to this test, we will also call SetCurrentDirectory to -** ensure this is handled properly. -** The test will create a file with in the parent directory -** to verify that the returned directory is valid. -** -** Depends: SetCurrentDirectory, -** CreateDirectory, -** strcat, -** memset, -** CreateFile, -** CloseHandle, -** strcmp, -** DeleteFileA, -** RemoveDirectory. -** - -** -**===================================================================*/ - -#include - -#ifdef WIN32 - const char* szSeperator = "\\"; -#else - const char* szSeperator = "//"; -#endif - -const char* szDotDot = "..\\"; -const char* szFileName = "testing.tmp"; - -int __cdecl main(int argc, char *argv[]) -{ - DWORD dwRc = 0; - char szReturnedPath[_MAX_DIR+1]; - char szFullFileName[_MAX_DIR+1]; - char szDirectory[256]; - char* szCreatedDir = {"test_directory"}; - char* szCreatedNextDir = {"level1"}; - WCHAR *szCreatedDirW; - LPSTR pPathPtr; - HANDLE hFile = NULL; - BOOL bRetVal = FAIL; - - /* Initialize the PAL. - */ - if (0 != PAL_Initialize(argc,argv)) - { - return (FAIL); - } - - /* Initialize the buffer. - */ - memset(szDirectory, '\0', 256); - - /* Change the current working directory. - */ - if (!SetCurrentDirectoryA(szDotDot)) - { - Fail("ERROR: SetCurrentDirectoryA failed with error code %u" - " when passed \"%s\".\n", - GetLastError(), - szDotDot); - } - - /* Create the path to the next level of directory to create. - */ - strcat( szDirectory, szCreatedDir ); - - - /* Create a test directory. - */ - if ( !CreateDirectoryA( szDirectory, NULL ) ) - { - Fail("ERROR:%u: Unable to create directories \"%s\".\n", - GetLastError(), - szDirectory); - } - - /* Create the path to the next level of directory to create. - */ - strcat( szDirectory, szSeperator ); - strcat( szDirectory, szCreatedNextDir ); - - /* Create a test directory. - */ - if ( !CreateDirectoryA( szDirectory, NULL ) ) - { - Trace("ERROR:%u: Unable to create directories \"%s\".\n", - GetLastError(), - szDirectory); - bRetVal = FAIL; - goto cleanUpOne; - } - - /* Initialize the receiving char buffers. - */ - memset(szReturnedPath, 0, _MAX_DIR+1); - memset(szFullFileName, 0, _MAX_DIR+1); - - /* Create Full filename to pass, will include '..\' - * in the middle of the path. - */ - strcat(szFullFileName, szCreatedDir); - strcat(szFullFileName, szDotDot); - strcat(szFullFileName, szFileName); - - /* Get the full path to the filename. - */ - dwRc = GetFullPathNameA(szFullFileName, - _MAX_DIR, - szReturnedPath, - &pPathPtr); - if (dwRc == 0) - { - Trace("ERROR :%ld: GetFullPathName failed to " - "retrieve the path of \"%s\".\n", - GetLastError(), - szFileName); - bRetVal = FAIL; - goto cleanUpTwo; - } - - /* The returned value should be the parent directory with the - * file name appended. */ - hFile = CreateFileA(szReturnedPath, - GENERIC_READ, - FILE_SHARE_READ, - NULL, - CREATE_ALWAYS, - FILE_ATTRIBUTE_NORMAL, - NULL); - - if (hFile == INVALID_HANDLE_VALUE) - { - Trace("ERROR :%ld: CreateFileA failed to create \"%s\".\n", - GetLastError(), - szReturnedPath); - bRetVal = FAIL; - goto cleanUpTwo; - } - - /* Close the handle to the created file. - */ - if (CloseHandle(hFile) != TRUE) - { - Trace("ERROR :%ld: CloseHandle failed close hFile=0x%lx.\n", - GetLastError()); - bRetVal = FAIL; - goto cleanUpThree; - } - - /* Verify that the file was created, attempt to create - * the file again. */ - hFile = CreateFileA(szReturnedPath, - GENERIC_READ, - FILE_SHARE_READ, - NULL, - CREATE_NEW, - FILE_ATTRIBUTE_NORMAL, - NULL); - if ((hFile != INVALID_HANDLE_VALUE) && - (GetLastError() != ERROR_ALREADY_EXISTS)) - { - Trace("ERROR :%ld: CreateFileA succeeded to create file " - "\"%s\", that already existed.\n", - GetLastError(), - szFullFileName); - bRetVal = FAIL; - goto cleanUpThree; - } - - /* Verify that the returned filename is the same as the supplied. - */ - if (strcmp(pPathPtr, szFileName) != 0) - { - Trace("ERROR : Returned filename \"%s\" is not equal to " - "supplied filename \"%s\".\n", - pPathPtr, - szFileName); - bRetVal = FAIL; - goto cleanUpThree; - } - - /* Successful test. - */ - bRetVal = PASS; - -cleanUpThree: - - /* Delete the create file. - */ - if (DeleteFileA(szReturnedPath) != TRUE) - { - Fail("ERROR :%ld: DeleteFileA failed to delete \"%s\".\n", - GetLastError(), - szFileName); - } - -cleanUpTwo: - - /* Remove the empty directory. - */ - szCreatedDirW = convert((LPSTR)szDirectory); - if (!RemoveDirectoryW(szCreatedDirW)) - { - free (szCreatedDirW); - Fail("ERROR:%u: Unable to remove directory \"%s\".\n", - GetLastError(), - szCreatedDir); - } - free (szCreatedDirW); - -cleanUpOne: - - /* Remove the empty directory. - */ - szCreatedDirW = convert((LPSTR)szCreatedDir); - if (!RemoveDirectoryW(szCreatedDirW)) - { - free (szCreatedDirW); - Fail("ERROR:%u: Unable to remove directory \"%s\".\n", - GetLastError(), - szCreatedDir); - } - free (szCreatedDirW); - - /* Terminate the PAL.*/ - PAL_Terminate(); - return bRetVal; -} diff --git a/src/pal/tests/palsuite/file_io/GetFullPathNameA/test3/testinfo.dat b/src/pal/tests/palsuite/file_io/GetFullPathNameA/test3/testinfo.dat deleted file mode 100644 index 3991744d4..000000000 --- a/src/pal/tests/palsuite/file_io/GetFullPathNameA/test3/testinfo.dat +++ /dev/null @@ -1,19 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = GetFullPathNameA -Name = Test for GetFullPathNameA -Type = DEFAULT -EXE1 = test3 -Description -= Tests the PAL implementation of the GetFullPathNameA API. -= GetFullPathA will be passed a directory that contains '..'. -= Example: test_directory\level1\..\testing.tmp. -= To add to this test, we will also call SetCurrentDirectory to -= ensure this is handled properly. -= The test will create a file with in the parent directory -= to verify that the returned directory is valid. - diff --git a/src/pal/tests/palsuite/file_io/GetFullPathNameA/test4/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFullPathNameA/test4/CMakeLists.txt deleted file mode 100644 index bda34bdc2..000000000 --- a/src/pal/tests/palsuite/file_io/GetFullPathNameA/test4/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test4.cpp -) - -add_executable(paltest_getfullpathnamea_test4 - ${SOURCES} -) - -add_dependencies(paltest_getfullpathnamea_test4 coreclrpal) - -target_link_libraries(paltest_getfullpathnamea_test4 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/GetFullPathNameA/test4/test4.cpp b/src/pal/tests/palsuite/file_io/GetFullPathNameA/test4/test4.cpp deleted file mode 100644 index fb22c1f07..000000000 --- a/src/pal/tests/palsuite/file_io/GetFullPathNameA/test4/test4.cpp +++ /dev/null @@ -1,203 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test4.c -** -** Purpose: Tests the PAL implementation of the GetFullPathNameA API. -** GetFullPathA will be passed a directory that begins with '..'. -** Example: ..\test_directory\testing.tmp. -** To add to this test, we will also call SetCurrentDirectory to -** ensure this is handled properly. -** The test will create a file with in the parent directory -** to verify that the returned directory is valid. -** -** Depends: SetCurrentDirectory, -** CreateDirectory, -** strcat, -** memset, -** CreateFile, -** CloseHandle, -** strcmp, -** DeleteFileA, -** RemoveDirectory. -** - -** -**===================================================================*/ - -#include - -#ifdef WIN32 - const char* szSeperator = "\\"; -#else - const char* szSeperator = "//"; -#endif - -const char* szDotDot = ".."; -const char* szFileName = "testing.tmp"; - -int __cdecl main(int argc, char *argv[]) -{ - DWORD dwRc = 0; - char szReturnedPath[_MAX_DIR+1]; - char szFullFileName[_MAX_DIR+1]; - char szDirectory[256]; - char* szCreatedDir = {"test_directory"}; - WCHAR *szCreatedDirW; - LPSTR pPathPtr; - HANDLE hFile = NULL; - BOOL bRetVal = FAIL; - - /* Initialize the PAL. - */ - if (0 != PAL_Initialize(argc,argv)) - { - return (FAIL); - } - - /* Initialize the buffer. - */ - memset(szDirectory, '\0', 256); - - /* Create the path to the next level of directory to create. - */ - strcat( szDirectory, szDotDot ); /* .. */ - strcat( szDirectory, szSeperator ); /* ../ */ - strcat( szDirectory, szCreatedDir ); /* ../test_directory */ - - /* Create a test directory. - */ - if ( !CreateDirectoryA( szDirectory, NULL ) ) - { - Fail("ERROR:%u: Unable to create directories \"%s\".\n", - GetLastError(), - szDirectory); - } - - /* Initialize the receiving char buffers. - */ - memset(szReturnedPath, 0, _MAX_DIR+1); - memset(szFullFileName, 0, _MAX_DIR+1); - - /* Create Full filename to pass, will include '..\' - * in the middle of the path. - */ - strcat( szFullFileName, szDotDot ); /* .. */ - strcat( szFullFileName, szSeperator ); /* ../ */ - strcat( szFullFileName, szCreatedDir ); /* ../test_directory */ - strcat( szFullFileName, szSeperator ); /* ../test_directory/ */ - strcat( szFullFileName, szFileName ); /* ../test_directory/testing.tmp */ - - /* Get the full path to the filename. - */ - dwRc = GetFullPathNameA(szFullFileName, - _MAX_DIR, - szReturnedPath, - &pPathPtr); - if (dwRc == 0) - { - Trace("ERROR :%ld: GetFullPathName failed to " - "retrieve the path of \"%s\".\n", - GetLastError(), - szFileName); - bRetVal = FAIL; - goto cleanUpOne; - } - - /* The returned value should be the parent directory with the - * file name appended. */ - hFile = CreateFileA(szReturnedPath, - GENERIC_READ, - FILE_SHARE_READ, - NULL, - CREATE_ALWAYS, - FILE_ATTRIBUTE_NORMAL, - NULL); - - if (hFile == INVALID_HANDLE_VALUE) - { - Trace("ERROR :%ld: CreateFileA failed to create \"%s\".\n", - GetLastError(), - szReturnedPath); - bRetVal = FAIL; - goto cleanUpOne; - } - - /* Close the handle to the created file. - */ - if (CloseHandle(hFile) != TRUE) - { - Trace("ERROR :%ld: CloseHandle failed close hFile=0x%lx.\n", - GetLastError()); - bRetVal = FAIL; - goto cleanUpTwo; - } - - /* Verify that the file was created, attempt to create - * the file again. */ - hFile = CreateFileA(szReturnedPath, - GENERIC_READ, - FILE_SHARE_READ, - NULL, - CREATE_NEW, - FILE_ATTRIBUTE_NORMAL, - NULL); - if ((hFile != INVALID_HANDLE_VALUE) && - (GetLastError() != ERROR_ALREADY_EXISTS)) - { - Trace("ERROR :%ld: CreateFileA succeeded to create file " - "\"%s\", that already existed.\n", - GetLastError(), - szFullFileName); - bRetVal = FAIL; - goto cleanUpTwo; - } - - /* Verify that the returned filename is the same as the supplied. - */ - if (strcmp(pPathPtr, szFileName) != 0) - { - Trace("ERROR : Returned filename \"%s\" is not equal to " - "supplied filename \"%s\".\n", - pPathPtr, - szFileName); - bRetVal = FAIL; - goto cleanUpTwo; - } - - /* Successful test. - */ - bRetVal = PASS; - -cleanUpTwo: - - /* Delete the create file. - */ - if (DeleteFileA(szReturnedPath) != TRUE) - { - Fail("ERROR :%ld: DeleteFileA failed to delete \"%s\".\n", - GetLastError(), - szFileName); - } - -cleanUpOne: - - /* Remove the empty directory. - */ - szCreatedDirW = convert((LPSTR)szDirectory); - if (!RemoveDirectoryW(szCreatedDirW)) - { - free (szCreatedDirW); - Fail("ERROR:%u: Unable to remove directory \"%s\".\n", - GetLastError(), - szCreatedDir); - } - free (szCreatedDirW); - - /* Terminate the PAL.*/ - PAL_Terminate(); - return bRetVal; -} diff --git a/src/pal/tests/palsuite/file_io/GetFullPathNameA/test4/testinfo.dat b/src/pal/tests/palsuite/file_io/GetFullPathNameA/test4/testinfo.dat deleted file mode 100644 index 8a7b3b35d..000000000 --- a/src/pal/tests/palsuite/file_io/GetFullPathNameA/test4/testinfo.dat +++ /dev/null @@ -1,19 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = GetFullPathNameA -Name = Test for GetFullPathNameA -Type = DEFAULT -EXE1 = test4 -Description -= Tests the PAL implementation of the GetFullPathNameA API. -= GetFullPathA will be passed a directory that begins with '..'. -= Example: ..\test_directory\level1\testing.tmp. -= To add to this test, we will also call SetCurrentDirectory to -= ensure this is handled properly. -= The test will create a file with in the parent directory -= to verify that the returned directory is valid. - diff --git a/src/pal/tests/palsuite/file_io/GetFullPathNameW/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFullPathNameW/CMakeLists.txt deleted file mode 100644 index a3847f8ca..000000000 --- a/src/pal/tests/palsuite/file_io/GetFullPathNameW/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) -add_subdirectory(test3) -add_subdirectory(test4) - diff --git a/src/pal/tests/palsuite/file_io/GetFullPathNameW/test1/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFullPathNameW/test1/CMakeLists.txt deleted file mode 100644 index 524201502..000000000 --- a/src/pal/tests/palsuite/file_io/GetFullPathNameW/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - GetFullPathNameW.cpp -) - -add_executable(paltest_getfullpathnamew_test1 - ${SOURCES} -) - -add_dependencies(paltest_getfullpathnamew_test1 coreclrpal) - -target_link_libraries(paltest_getfullpathnamew_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/GetFullPathNameW/test1/GetFullPathNameW.cpp b/src/pal/tests/palsuite/file_io/GetFullPathNameW/test1/GetFullPathNameW.cpp deleted file mode 100644 index 592d3ad4c..000000000 --- a/src/pal/tests/palsuite/file_io/GetFullPathNameW/test1/GetFullPathNameW.cpp +++ /dev/null @@ -1,157 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: GetFullPathNameW.c (test 1) -** -** Purpose: Tests the PAL implementation of the GetFullPathNameW function. -** -** -**===================================================================*/ - -#include - -const char* szFileName = "testing.tmp"; - -int __cdecl main(int argc, char *argv[]) -{ - DWORD dwRc = 0; - WCHAR szwReturnedPath[_MAX_DIR+1]; - WCHAR szwShortBuff[2]; - LPWSTR pPathPtr; - HANDLE hFile = NULL; - WCHAR* szwFileName = NULL; - - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - szwFileName = convert((char*)szFileName); - - /* perform a short buffer test */ - if (GetFullPathNameW(szwFileName, 2, szwShortBuff, &pPathPtr) <= 2) - { - free(szwFileName); - /* this test should have failed but didn't */ - Fail("GetFullPathNameW: ERROR -> The API was passed a buffer that was" - " too small for the path name and yet it apparently passed.\n"); - } - - - memset(szwReturnedPath, 0, _MAX_DIR+1); - dwRc = GetFullPathNameW(szwFileName, - _MAX_DIR, - szwReturnedPath, - &pPathPtr); - - if (dwRc == 0) - { - /* this test should have passed but didn't */ - free(szwFileName); - Fail("GetFullPathNameW: ERROR -> Function failed for the " - "file \"%s\" with error code: %ld.\n", szFileName, GetLastError()); - } - /* - * the returned value should be the current directory with the - * file name appended - */ - hFile = CreateFileW(szwFileName, - GENERIC_READ, - FILE_SHARE_READ, - NULL, - CREATE_ALWAYS, - FILE_ATTRIBUTE_NORMAL, - NULL); - if (hFile == INVALID_HANDLE_VALUE) - { - free(szwFileName); - Fail("GetFullPathNameW: ERROR -> CreateFileW failed to create " - "file \"%s\" with error code: %ld.\n", - szFileName, - GetLastError()); - } - if (CloseHandle(hFile) != TRUE) - { - free(szwFileName); - Trace("GetFullPathNameW: ERROR -> CloseHandle failed with error " - "code: %ld.\n", GetLastError()); - if (DeleteFileA(szFileName) != TRUE) - { - Trace("GetFullPathNameW: ERROR -> DeleteFileW failed to " - "delete the test file with error code: %ld.\n", - GetLastError()); - } - PAL_TerminateEx(FAIL); - return FAIL; - } - - /* - * now try to create the file based on the returned value with the - * CREATE_NEW option which should fail since the file should - * already exist - */ - hFile = CreateFileW(szwReturnedPath, - GENERIC_READ, - FILE_SHARE_READ, - NULL, - CREATE_NEW, - FILE_ATTRIBUTE_NORMAL, - NULL); - if (hFile != INVALID_HANDLE_VALUE) - { - Trace("GetFullPathNameW: ERROR -> CreateFileW was able to " - "CREATE_NEW the returned file \"%s\". The returned file " - "name is therefore apparently wrong.\n", - szwReturnedPath); - if (CloseHandle(hFile) != TRUE) - { - Trace("GetFullPathNameW: ERROR -> CloseHandle failed with " - "error code: %ld.\n", GetLastError()); - } - if ((DeleteFileW(szwReturnedPath) != TRUE) || - (DeleteFileW(szwFileName) != TRUE)) - { - Trace("GetFullPathNameW: ERROR -> DeleteFileW failed to " - "delete the test files with error code: %ld.\n", - GetLastError()); - } - free(szwFileName); - PAL_TerminateEx(FAIL); - return FAIL; - } - - /* now make sure the pPathPtr is the same as the file name */ - if (wcsncmp(pPathPtr, szwFileName, wcslen(szwFileName)) != 0) - { - Trace("GetFullPathNameW: ERROR -> %s != %s\n", - pPathPtr, szFileName); - if ((DeleteFileW(szwReturnedPath) != TRUE) || - (DeleteFileW(szwFileName) != TRUE)) - { - Trace("GetFullPathNameW: ERROR -> DeleteFileW failed to " - "delete the test files with error code: %ld.\n", - GetLastError()); - } - free(szwFileName); - PAL_TerminateEx(FAIL); - return FAIL; - } - - /* clean up */ - free(szwFileName); - if (DeleteFileA(szFileName) != TRUE) - { - Fail("GetFullPathNameW: ERROR -> DeleteFileW failed to " - "delete \"%s\" with error code: %ld.\n", - szFileName, - GetLastError()); - } - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/file_io/GetFullPathNameW/test1/testinfo.dat b/src/pal/tests/palsuite/file_io/GetFullPathNameW/test1/testinfo.dat deleted file mode 100644 index 4f70617d4..000000000 --- a/src/pal/tests/palsuite/file_io/GetFullPathNameW/test1/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = GetFullPathNameW -Name = Test for GetFullPathNameW (test 1) -Type = DEFAULT -EXE1 = getfullpathnamew -Description -= Get the full path for a file name and verify the results. -= Also, attempt to call GetFullPathNameW with a buffer that is -= too small for the returned path and verify the results. diff --git a/src/pal/tests/palsuite/file_io/GetFullPathNameW/test2/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFullPathNameW/test2/CMakeLists.txt deleted file mode 100644 index 33e04d1a3..000000000 --- a/src/pal/tests/palsuite/file_io/GetFullPathNameW/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test2.cpp -) - -add_executable(paltest_getfullpathnamew_test2 - ${SOURCES} -) - -add_dependencies(paltest_getfullpathnamew_test2 coreclrpal) - -target_link_libraries(paltest_getfullpathnamew_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/GetFullPathNameW/test2/test2.cpp b/src/pal/tests/palsuite/file_io/GetFullPathNameW/test2/test2.cpp deleted file mode 100644 index fae042d22..000000000 --- a/src/pal/tests/palsuite/file_io/GetFullPathNameW/test2/test2.cpp +++ /dev/null @@ -1,159 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test2.c -** -** Purpose: Tests the PAL implementation of the GetFullPathNameW function. -** Get the full path for a file name and verify the results. -** This test will use a relative path, containing '..\'. To -** add to this test, we will also call SetCurrentDirectory to -** ensure this is handled properly. -** -** -**===================================================================*/ - -#include - -WCHAR szwDotDot[] = {'.','.','\\','\0'}; -WCHAR szwFileName[] = {'t','e','s','t','i','n','g','.','t','m','p','\0'}; - -int __cdecl main(int argc, char *argv[]) -{ - DWORD dwRc = 0; - WCHAR szwReturnedPath[_MAX_DIR+1]; - WCHAR szwFullFileName[_MAX_DIR+1]; - char *szReturnedPath; - char *szFileName; - LPWSTR pPathPtr; - HANDLE hFile = NULL; - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - /* change the directory */ - if (!SetCurrentDirectoryW(szwDotDot)) - { - Fail("ERROR: SetCurrentDirectoryW failed with error code %u" - " when passed \"%S\".\n", - GetLastError(), - szwDotDot); - } - - /* Initialize the receiving char buffers. - */ - memset(szwReturnedPath, 0, _MAX_DIR+1); - memset(szwFullFileName, 0, _MAX_DIR+1); - - /* Create Full filename to pass, will include '..\' - * as a pre-fix. */ - wcscat(szwFullFileName, szwDotDot); - wcscat(szwFullFileName, szwFileName); - - /* Convert wide char strings to multibyte, to us - * incase of error messages.*/ - szFileName = convertC(szwFileName); - - /* Get the full path to the filename. - */ - dwRc = GetFullPathNameW(szwFullFileName, - _MAX_DIR, - szwReturnedPath, - &pPathPtr); - - szReturnedPath = convertC(szwReturnedPath); - - if (dwRc == 0) - { - Trace("ERROR :%ld: Failed to get path to \"%s\".\n", - GetLastError(), - szReturnedPath); - free(szReturnedPath); - free(szFileName); - Fail(""); - } - - /* - * The returned value should be the parent directory with the - * file name appended. - */ - hFile = CreateFileW(szwReturnedPath, - GENERIC_READ, - FILE_SHARE_READ, - NULL, - CREATE_ALWAYS, - FILE_ATTRIBUTE_NORMAL, - NULL); - if (hFile == INVALID_HANDLE_VALUE) - { - Trace("ERROR :%ld: CreateFileW failed to create file \"%s\".\n", - GetLastError(), - szReturnedPath); - free(szFileName); - free(szReturnedPath); - Fail(""); - } - - /* Close the handle to the create file.*/ - if (CloseHandle(hFile) != TRUE) - { - Trace("ERROR :%ld: Failed to close handle hFile=0x%lx.\n", - GetLastError(), - hFile); - goto terminate; - } - - /* Verify that the file was created, attempt to create - * the file again. */ - hFile = CreateFileW(szwReturnedPath, - GENERIC_READ, - FILE_SHARE_READ, - NULL, - CREATE_NEW, - FILE_ATTRIBUTE_NORMAL, - NULL); - if ((hFile != INVALID_HANDLE_VALUE) && - (GetLastError() != ERROR_ALREADY_EXISTS)) - { - Trace("ERROR :%ld: CreateFileW succeeded to create file " - "\"%s\", that already existed.\n", - GetLastError(), - szReturnedPath); - goto terminate; - } - - /* Verify that the returned filename is the same as the supplied. - */ - if (wcsncmp(pPathPtr, szwFileName, wcslen(szwFileName)) != 0) - { - Trace("ERROR : Returned filename is not equal to \"%s\".\n", - szFileName); - goto terminate; - } - -terminate: - /* Delete the create file. - */ - if (DeleteFileW(szwFullFileName) != TRUE) - { - Trace("ERROR :%ld: DeleteFileW failed to delete \"%s\".\n", - szFileName, - GetLastError()); - free(szFileName); - free(szReturnedPath); - Fail(""); - } - - free(szFileName); - free(szReturnedPath); - - /* Terminate the PAL. - */ - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/file_io/GetFullPathNameW/test2/testinfo.dat b/src/pal/tests/palsuite/file_io/GetFullPathNameW/test2/testinfo.dat deleted file mode 100644 index b8460e0b7..000000000 --- a/src/pal/tests/palsuite/file_io/GetFullPathNameW/test2/testinfo.dat +++ /dev/null @@ -1,15 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = GetFullPathNameW -Name = Test for GetFullPathNameW (test 2) -Type = DEFAULT -EXE1 = test2 -Description -= Get the full path for a file name and verify the results. -= This test will use a relative path, containing '..\'. To -= add to this test, we will also call SetCurrentDirectory to -= ensure this is handled properly. diff --git a/src/pal/tests/palsuite/file_io/GetFullPathNameW/test3/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFullPathNameW/test3/CMakeLists.txt deleted file mode 100644 index eaf63760f..000000000 --- a/src/pal/tests/palsuite/file_io/GetFullPathNameW/test3/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test3.cpp -) - -add_executable(paltest_getfullpathnamew_test3 - ${SOURCES} -) - -add_dependencies(paltest_getfullpathnamew_test3 coreclrpal) - -target_link_libraries(paltest_getfullpathnamew_test3 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/GetFullPathNameW/test3/test3.cpp b/src/pal/tests/palsuite/file_io/GetFullPathNameW/test3/test3.cpp deleted file mode 100644 index ba80cf222..000000000 --- a/src/pal/tests/palsuite/file_io/GetFullPathNameW/test3/test3.cpp +++ /dev/null @@ -1,240 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test3.c -** -** Purpose: Tests the PAL implementation of the GetFullPathNameW API. -** GetFullPathW will be passed a directory that contains '..'. -** Example: test_directory\level1\..\testing.tmp. -** To add to this test, we will also call SetCurrentDirectory to -** ensure this is handled properly. -** The test will create a file with in the parent directory -** to verify that the returned directory is valid. -** -** Depends: SetCurrentDirectory, -** CreateDirectory, -** strcat, -** memset, -** CreateFile, -** CloseHandle, -** strcmp, -** DeleteFileW, -** RemoveDirectory. -** - -** -**===================================================================*/ -#define UNICODE -#include - -#ifdef WIN32 -const WCHAR szSeperator[] = {'\\','\\','\0'}; -#else -const WCHAR szSeperator[] = {'/','/','\0'}; -#endif - -const WCHAR szDotDot[] = {'.','.','\0'}; -const WCHAR szFileName[] = {'t','e','s','t','i','n','g','.','t','m','p','\0'}; - -int __cdecl main(int argc, char *argv[]) -{ - DWORD dwRc = 0; - - WCHAR szReturnedPath[_MAX_DIR+1]; - WCHAR szFullFileName[_MAX_DIR+1]; - WCHAR szDirectory[256]; - WCHAR szCreatedDir[] = {'t','e','s','t','_','d','i','r','\0'}; - WCHAR szCreatedNextDir[] = {'l','e','v','e','l','1','\0'}; - - LPWSTR pPathPtr; - HANDLE hFile = NULL; - BOOL bRetVal = FAIL; - - /* Initialize the PAL. - */ - if ( 0 != PAL_Initialize(argc,argv) ) - { - return (FAIL); - } - - /* Initialize the buffer. - */ - memset( szDirectory, '\0', 256 ); - - /* Change the current working directory. - */ - if ( !SetCurrentDirectoryW(szDotDot) ) - { - Fail("ERROR: SetCurrentDirectoryA failed with error code %u " - "when passed \"%S\".\n", - GetLastError(), - szDotDot); - } - - /* Create the path to the next level of directory to create. - */ - wcscat(szDirectory, szCreatedDir); /* test_dir */ - - - /* Create a test directory. - */ - if (!CreateDirectoryW(szDirectory, NULL)) - { - Fail("ERROR:%u: Unable to create directories \"%S\".\n", - GetLastError(), - szDirectory); - } - - /* Create the path to the next level of directory to create. - */ - wcscat(szDirectory, szSeperator); /* / */ - wcscat(szDirectory, szCreatedNextDir); /* /level1 */ - - /* Create a test directory. - */ - if (!CreateDirectoryW(szDirectory, NULL)) - { - Trace("ERROR:%u: Unable to create directories \"%S\".\n", - GetLastError(), - szDirectory); - bRetVal = FAIL; - goto cleanUpOne; - } - - /* Initialize the receiving char buffers. - */ - memset(szReturnedPath, 0, _MAX_DIR+1); - memset(szFullFileName, 0, _MAX_DIR+1); - - /* Create Full filename to pass, will include '..\' - * in the middle of the path. - */ - wcscat(szFullFileName, szCreatedDir); /*test_dir */ - wcscat(szFullFileName, szSeperator); /*test_dir/ */ - wcscat(szFullFileName, szCreatedNextDir);/*test_dir/level1 */ - wcscat(szFullFileName, szSeperator); /*test_dir/level1/ */ - wcscat(szFullFileName, szDotDot); /*test_dir/level1/.. */ - wcscat(szFullFileName, szSeperator); /*test_dir/level1/../ */ - wcscat(szFullFileName, szFileName); /*test_dir/level1/../testing.tmp */ - - /* Get the full path to the filename. - */ - dwRc = GetFullPathNameW(szFullFileName, - _MAX_DIR, - szReturnedPath, - &pPathPtr); - if (dwRc == 0) - { - Trace("ERROR :%ld: GetFullPathNameW failed to " - "retrieve the path of \"%S\".\n", - GetLastError(), - szFileName); - bRetVal = FAIL; - goto cleanUpTwo; - } - - /* The returned value should be the parent directory with the - * file name appended. */ - hFile = CreateFileW(szReturnedPath, - GENERIC_READ, - FILE_SHARE_READ, - NULL, - CREATE_ALWAYS, - FILE_ATTRIBUTE_NORMAL, - NULL); - - if (hFile == INVALID_HANDLE_VALUE) - { - Trace("ERROR :%ld: CreateFileA failed to create \"%S\".\n", - GetLastError(), - szReturnedPath); - bRetVal = FAIL; - goto cleanUpTwo; - } - - /* Close the handle to the created file. - */ - if (CloseHandle(hFile) != TRUE) - { - Trace("ERROR :%ld: CloseHandle failed close hFile=0x%lx.\n", - GetLastError()); - bRetVal = FAIL; - goto cleanUpThree; - } - - /* Verify that the file was created, attempt to create - * the file again. */ - hFile = CreateFileW(szReturnedPath, - GENERIC_READ, - FILE_SHARE_READ, - NULL, - CREATE_NEW, - FILE_ATTRIBUTE_NORMAL, - NULL); - if ((hFile != INVALID_HANDLE_VALUE) && - (GetLastError() != ERROR_ALREADY_EXISTS)) - { - Trace("ERROR :%ld: CreateFileA succeeded to create file " - "\"%S\", that already existed.\n", - GetLastError(), - szFullFileName); - bRetVal = FAIL; - goto cleanUpThree; - } - - /* Verify that the returned filename is the same as the supplied. - */ - if (wcscmp(pPathPtr, szFileName) != 0) - { - Trace("ERROR : Returned filename \"%s\" is not equal to " - "supplied filename \"%s\".\n", - pPathPtr, - szFileName); - bRetVal = FAIL; - goto cleanUpThree; - } - - /* Successful test. - */ - bRetVal = PASS; - -cleanUpThree: - - /* Delete the create file. - */ - if (DeleteFileW(szReturnedPath) != TRUE) - { - Fail("ERROR :%ld: DeleteFileA failed to delete \"%S\".\n", - GetLastError(), - szFileName); - } - -cleanUpTwo: - - /* Remove the empty directory. - */ - if (!RemoveDirectoryW(szDirectory)) - { - Fail("ERROR:%u: Unable to remove directory \"%S\".\n", - GetLastError(), - szCreatedDir); - } - -cleanUpOne: - - /* Remove the empty directory. - */ - if (!RemoveDirectoryW(szCreatedDir)) - { - Fail("ERROR:%u: Unable to remove directory \"%s\".\n", - GetLastError(), - szCreatedDir); - } - - /* Terminate the PAL.*/ - PAL_TerminateEx(bRetVal); - return bRetVal; -} diff --git a/src/pal/tests/palsuite/file_io/GetFullPathNameW/test3/testinfo.dat b/src/pal/tests/palsuite/file_io/GetFullPathNameW/test3/testinfo.dat deleted file mode 100644 index 1eb6a27ad..000000000 --- a/src/pal/tests/palsuite/file_io/GetFullPathNameW/test3/testinfo.dat +++ /dev/null @@ -1,19 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = GetFullPathNameW -Name = Test for GetFullPathNameW -Type = DEFAULT -EXE1 = test3 -Description -= Tests the PAL implementation of the GetFullPathNameW API. -= GetFullPathW will be passed a directory that contains '..'. -= Example: test_directory\level1\..\testing.tmp. -= To add to this test, we will also call SetCurrentDirectory to -= ensure this is handled properly. -= The test will create a file with in the parent directory -= to verify that the returned directory is valid. - diff --git a/src/pal/tests/palsuite/file_io/GetFullPathNameW/test4/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetFullPathNameW/test4/CMakeLists.txt deleted file mode 100644 index 6398e9207..000000000 --- a/src/pal/tests/palsuite/file_io/GetFullPathNameW/test4/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test4.cpp -) - -add_executable(paltest_getfullpathnamew_test4 - ${SOURCES} -) - -add_dependencies(paltest_getfullpathnamew_test4 coreclrpal) - -target_link_libraries(paltest_getfullpathnamew_test4 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/GetFullPathNameW/test4/test4.cpp b/src/pal/tests/palsuite/file_io/GetFullPathNameW/test4/test4.cpp deleted file mode 100644 index 25eb10d65..000000000 --- a/src/pal/tests/palsuite/file_io/GetFullPathNameW/test4/test4.cpp +++ /dev/null @@ -1,201 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test4.c -** -** Purpose: Tests the PAL implementation of the GetFullPathNameW API. -** GetFullPathNameW will be passed a directory that begins with '..'. -** Example: ..\test_directory\testing.tmp. -** To add to this test, we will also call SetCurrentDirectory to -** ensure this is handled properly. -** The test will create a file with in the parent directory -** to verify that the returned directory is valid. -** -** Depends: SetCurrentDirectory, -** CreateDirectory, -** strcat, -** memset, -** CreateFile, -** CloseHandle, -** strcmp, -** DeleteFileW, -** RemoveDirectory. -** - -** -**===================================================================*/ -#define UNICODE -#include - -#ifdef WIN32 - const WCHAR szSeperator[] = {'\\','\\','\0'}; -#else - const WCHAR szSeperator[] = {'/','/','\0'}; -#endif - -const WCHAR szDotDot[] = {'.','.','\0'}; -const WCHAR szFileName[] = {'t','e','s','t','i','n','g','.','t','m','p','\0'}; - -int __cdecl main(int argc, char *argv[]) -{ - DWORD dwRc = 0; - - WCHAR szReturnedPath[_MAX_DIR+1]; - WCHAR szFullFileName[_MAX_DIR+1]; - WCHAR szDirectory[256]; - WCHAR szCreatedDir[] = {'t','e','s','t','_','d','i','r','\0'}; - - LPWSTR pPathPtr; - HANDLE hFile = NULL; - BOOL bRetVal = FAIL; - - /* Initialize the PAL. - */ - if (0 != PAL_Initialize(argc,argv)) - { - return (FAIL); - } - - /* Initialize the buffer. - */ - memset(szDirectory, '\0', 256); - - /* Create the path to the next level of directory to create. - */ - wcscat(szDirectory, szDotDot); /* .. */ - wcscat(szDirectory, szSeperator); /* ../ */ - wcscat(szDirectory, szCreatedDir); /* ../test_directory */ - - /* Create a test directory. - */ - if (!CreateDirectoryW(szDirectory, NULL)) - { - Fail("ERROR:%u: Unable to create directories \"%S\".\n", - GetLastError(), - szDirectory); - } - - /* Initialize the receiving char buffers. - */ - memset(szReturnedPath, 0, _MAX_DIR+1); - memset(szFullFileName, 0, _MAX_DIR+1); - - /* Create Full filename to pass, will include '..\' - * in the middle of the path. - */ - wcscat( szFullFileName, szDotDot ); /* .. */ - wcscat( szFullFileName, szSeperator ); /* ../ */ - wcscat( szFullFileName, szCreatedDir ); /* ../test_directory */ - wcscat( szFullFileName, szSeperator ); /* ../test_directory/ */ - wcscat( szFullFileName, szFileName ); /* ../test_directory/testing.tmp */ - - /* Get the full path to the filename. - */ - dwRc = GetFullPathNameW(szFullFileName, - _MAX_DIR, - szReturnedPath, - &pPathPtr); - if (dwRc == 0) - { - Trace("ERROR :%ld: GetFullPathName failed to " - "retrieve the path of \"%S\".\n", - GetLastError(), - szFileName); - bRetVal = FAIL; - goto cleanUpOne; - } - - /* The returned value should be the parent directory with the - * file name appended. */ - hFile = CreateFileW(szReturnedPath, - GENERIC_READ, - FILE_SHARE_READ, - NULL, - CREATE_ALWAYS, - FILE_ATTRIBUTE_NORMAL, - NULL); - - if (hFile == INVALID_HANDLE_VALUE) - { - Trace("ERROR :%ld: CreateFileA failed to create \"%S\".\n", - GetLastError(), - szReturnedPath); - bRetVal = FAIL; - goto cleanUpOne; - } - - /* Close the handle to the created file. - */ - if (CloseHandle(hFile) != TRUE) - { - Trace("ERROR :%ld: CloseHandle failed close hFile=0x%lx.\n", - GetLastError()); - bRetVal = FAIL; - goto cleanUpTwo; - } - - /* Verify that the file was created, attempt to create - * the file again. */ - hFile = CreateFileW(szReturnedPath, - GENERIC_READ, - FILE_SHARE_READ, - NULL, - CREATE_NEW, - FILE_ATTRIBUTE_NORMAL, - NULL); - if ((hFile != INVALID_HANDLE_VALUE) && - (GetLastError() != ERROR_ALREADY_EXISTS)) - { - Trace("ERROR :%ld: CreateFileA succeeded to create file " - "\"%S\", that already existed.\n", - GetLastError(), - szFullFileName); - bRetVal = FAIL; - goto cleanUpTwo; - } - - /* Verify that the returned filename is the same as the supplied. - */ - if (wcscmp(pPathPtr, szFileName) != 0) - { - Trace("ERROR : Returned filename \"%S\" is not equal to " - "supplied filename \"%S\".\n", - pPathPtr, - szFileName); - bRetVal = FAIL; - goto cleanUpTwo; - } - - /* Successful test. - */ - bRetVal = PASS; - -cleanUpTwo: - - /* Delete the create file. - */ - if (DeleteFileW(szReturnedPath) != TRUE) - { - Fail("ERROR :%ld: DeleteFileA failed to delete \"%S\".\n", - GetLastError(), - szFileName); - } - -cleanUpOne: - - /* Remove the empty directory. - */ - if (!RemoveDirectoryW(szDirectory)) - { - Fail("ERROR:%u: Unable to remove directory \"%s\".\n", - GetLastError(), - szCreatedDir); - } - - /* Terminate the PAL.*/ - PAL_TerminateEx(bRetVal); - return bRetVal; -} diff --git a/src/pal/tests/palsuite/file_io/GetFullPathNameW/test4/testinfo.dat b/src/pal/tests/palsuite/file_io/GetFullPathNameW/test4/testinfo.dat deleted file mode 100644 index 8a7b3b35d..000000000 --- a/src/pal/tests/palsuite/file_io/GetFullPathNameW/test4/testinfo.dat +++ /dev/null @@ -1,19 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = GetFullPathNameA -Name = Test for GetFullPathNameA -Type = DEFAULT -EXE1 = test4 -Description -= Tests the PAL implementation of the GetFullPathNameA API. -= GetFullPathA will be passed a directory that begins with '..'. -= Example: ..\test_directory\level1\testing.tmp. -= To add to this test, we will also call SetCurrentDirectory to -= ensure this is handled properly. -= The test will create a file with in the parent directory -= to verify that the returned directory is valid. - diff --git a/src/pal/tests/palsuite/file_io/GetLongPathNameW/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetLongPathNameW/CMakeLists.txt deleted file mode 100644 index ef14ea535..000000000 --- a/src/pal/tests/palsuite/file_io/GetLongPathNameW/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) - diff --git a/src/pal/tests/palsuite/file_io/GetLongPathNameW/test1/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetLongPathNameW/test1/CMakeLists.txt deleted file mode 100644 index ec5b70bff..000000000 --- a/src/pal/tests/palsuite/file_io/GetLongPathNameW/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - GetLongPathNameW.cpp -) - -add_executable(paltest_getlongpathnamew_test1 - ${SOURCES} -) - -add_dependencies(paltest_getlongpathnamew_test1 coreclrpal) - -target_link_libraries(paltest_getlongpathnamew_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/GetLongPathNameW/test1/GetLongPathNameW.cpp b/src/pal/tests/palsuite/file_io/GetLongPathNameW/test1/GetLongPathNameW.cpp deleted file mode 100644 index 22831dda1..000000000 --- a/src/pal/tests/palsuite/file_io/GetLongPathNameW/test1/GetLongPathNameW.cpp +++ /dev/null @@ -1,280 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: GetLongPathNameW.c Win32 version(test 1) -** -** Purpose: Tests the PAL implementation of the GetLongPathNameW function. -** as expected under Win32 -** -** Depends on: -** CreateDirectoryA -** RemoveDirectoryW -** -** -**===================================================================*/ -/* -tests: - - test invalid path names - - test an already short path name - - test a long path name - - test with buffer size too small -*/ - -#include - - -int __cdecl main(int argc, char *argv[]) -{ -/* Since GetLongPathNameW operates differently under FreeBSD and Win32 this test - is for Win32 only. It runs the same tests as the FreeBSD version but checks for - different results -*/ - -#if WIN32 - DWORD dwRc = 0; - WCHAR szwReturnedPath[MAX_LONGPATH]; - WCHAR szwSmallBuff[3]; - const char szShortPathName[] = {"testing"}; - const char szLongPathName[] = {"This_is_a_long_directory_name"}; - const char szShortenedPathName[] = {"THIS_I~1"}; - WCHAR* wLongPathPtr = NULL; - WCHAR* wShortPathPtr = NULL; - - - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - memset(szwReturnedPath, 0, MAX_LONGPATH*sizeof(WCHAR)); - memset(szwSmallBuff, 0, 3*sizeof(WCHAR)); - wLongPathPtr = convert((char*)szLongPathName); - wShortPathPtr = convert((char*)szShortenedPathName); - - /* do some clean up just to be safe */ - RemoveDirectoryW(wLongPathPtr); - RemoveDirectoryW(wShortPathPtr); - - - /* attempt call on an invalid short path name */ - dwRc = GetLongPathNameW(wShortPathPtr, szwReturnedPath, MAX_LONGPATH); - if (dwRc != 0) - { - Trace("GetLongPathNameW: ERROR -> Call made with an invalid short " - "path \"%S\" returned \"%S\"\n", - wShortPathPtr, - szwReturnedPath); - free (wLongPathPtr); - free (wShortPathPtr); - Fail(""); - } - - - /* attempt call on an invalid long path name */ - dwRc = GetLongPathNameW(wLongPathPtr, szwReturnedPath, MAX_LONGPATH); - if (dwRc != 0) - { - Trace("GetLongPathNameW: ERROR -> Call made with an invalid long " - "path \"%S\" returned \"%S\"\n", - wLongPathPtr, - szwReturnedPath); - free (wLongPathPtr); - free (wShortPathPtr); - Fail(""); - } - - - /* create a long directory name */ - if (TRUE != CreateDirectoryW(wLongPathPtr, NULL)) - { - free(wLongPathPtr); - free(wShortPathPtr); - Fail("GetLongPathNameW: ERROR -> CreateDirectoryW failed with an error" - " code of %ld when asked to create a directory called \"%s\".\n", - GetLastError(), - szLongPathName); - } - - - /* get the long path name */ - memset(szwReturnedPath, 0, MAX_LONGPATH*sizeof(WCHAR)); - dwRc = GetLongPathNameW(wShortPathPtr, szwReturnedPath, MAX_LONGPATH); - if (dwRc == 0) - { - Trace("GetLongPathNameW: ERROR -> failed with an error" - " code of %ld when asked for the long version of \"%s\".\n", - GetLastError(), - szShortenedPathName); - if (RemoveDirectoryW(wLongPathPtr) != TRUE) - { - Trace("GetLongPathNameW: ERROR -> RemoveDirectoryW failed to " - " remove the directory \"%S\" with an error code of %ld.\n", - wLongPathPtr, - GetLastError()); - } - free(wLongPathPtr); - free(wShortPathPtr); - Fail(""); - } - - /* does the returned match the expected */ - if (wcsncmp(wLongPathPtr, szwReturnedPath, wcslen(wLongPathPtr)) || - (wcslen(wLongPathPtr) != wcslen(szwReturnedPath))) - { - if (RemoveDirectoryW(wLongPathPtr) != TRUE) - { - Trace("GetLongPathNameW: ERROR -> RemoveDirectoryW failed to " - " remove the directory \"%S\" with an error code of %ld.\n", - wLongPathPtr, - GetLastError()); - } - free(wLongPathPtr); - free(wShortPathPtr); - Fail("GetLongPathNameW: ERROR -> The returned path, \"%S\" doesn't " - "match the expected return, \"%s\".\n", - szwReturnedPath, - szLongPathName); - } - - /* does the length returned match the actual length */ - if (dwRc != wcslen(szwReturnedPath)) - { - if (RemoveDirectoryW(wLongPathPtr) != TRUE) - { - Trace("GetLongPathNameW: ERROR -> RemoveDirectoryW failed to " - " remove the directory \"%S\" with an error code of %ld.\n", - wLongPathPtr, - GetLastError()); - } - free(wLongPathPtr); - free(wShortPathPtr); - Fail("GetLongPathNameW: ERROR -> The returned length, %ld, doesn't " - "match the string length, %ld.\n", - dwRc, - wcslen(szwReturnedPath)); - } - - if (RemoveDirectoryW(wLongPathPtr) != TRUE) - { - Trace("GetLongPathNameW: ERROR -> RemoveDirectoryW failed to " - " remove the directory \"%S\" with an error code of %ld.\n", - wLongPathPtr, - GetLastError()); - free(wShortPathPtr); - free(wLongPathPtr); - Fail(""); - } - free(wShortPathPtr); - free(wLongPathPtr); - - - /* test an actual short name */ - /* create a long directory name */ - wShortPathPtr = convert((char*)szShortPathName); - RemoveDirectoryW(wShortPathPtr); - - if (TRUE != CreateDirectoryW(wShortPathPtr, NULL)) - { - Trace("GetLongPathNameW: ERROR -> CreateDirectoryW failed with an error" - " code of %ld when asked to create a directory called \"%s\".\n", - GetLastError(), - szShortPathName); - free(wShortPathPtr); - Fail(""); - } - - - /* get the long path name */ - memset(szwReturnedPath, 0, MAX_LONGPATH*sizeof(WCHAR)); - dwRc = GetLongPathNameW(wShortPathPtr, szwReturnedPath, MAX_LONGPATH); - if (dwRc == 0) - { - Trace("GetLongPathNameW: ERROR -> failed with an error" - " code of %ld when asked for the long version of \"%s\".\n", - GetLastError(), - szShortenedPathName); - if (RemoveDirectoryW(wShortPathPtr) != TRUE) - { - Trace("GetLongPathNameW: ERROR -> RemoveDirectoryW failed to " - " remove the directory \"%S\" with an error code of %ld.\n", - wShortPathPtr, - GetLastError()); - } - free(wShortPathPtr); - Fail(""); - } - - /* does the returned match the expected */ - if (wcsncmp(wShortPathPtr, szwReturnedPath, wcslen(wShortPathPtr)) || - (wcslen(wShortPathPtr) != wcslen(szwReturnedPath))) - { - if (RemoveDirectoryW(wShortPathPtr) != TRUE) - { - Trace("GetLongPathNameW: ERROR -> RemoveDirectoryW failed to " - " remove the directory \"%S\" with an error code of %ld.\n", - wShortPathPtr, - GetLastError()); - } - free(wShortPathPtr); - Fail("GetLongPathNameW: ERROR -> The returned path, \"%S\" doesn't " - "match the expected return, \"%s\".\n", - szwReturnedPath, - szShortPathName); - } - - /* does the length returned match the actual length */ - if (dwRc != wcslen(szwReturnedPath)) - { - if (RemoveDirectoryW(wShortPathPtr) != TRUE) - { - Trace("GetLongPathNameW: ERROR -> RemoveDirectoryW failed to " - " remove the directory \"%S\" with an error code of %ld.\n", - wShortPathPtr, - GetLastError()); - } - free(wShortPathPtr); - Fail("GetLongPathNameW: ERROR -> The returned length, %ld, doesn't " - "match the string length, %ld.\n", - dwRc, - wcslen(szwReturnedPath)); - } - - /* test using a too small return buffer */ - dwRc = GetLongPathNameW(wShortPathPtr, szwSmallBuff, 3); - if ((dwRc != (strlen(szShortPathName)+1)) || /* +1 for the required NULL */ - szwSmallBuff[0] != '\0') - { - if (RemoveDirectoryW(wShortPathPtr) != TRUE) - { - Trace("GetLongPathNameW: ERROR -> RemoveDirectoryW failed to " - " remove the directory \"%S\" with an error code of %ld.\n", - wShortPathPtr, - GetLastError()); - } - free(wShortPathPtr); - Fail("GetLongPathNameW: ERROR -> using a return buffer that was too" - " small was not handled properly.\n"); - } - - if (RemoveDirectoryW(wShortPathPtr) != TRUE) - { - Trace("GetLongPathNameW: ERROR -> RemoveDirectoryW failed to " - " remove the directory \"%S\" with an error code of %ld.\n", - wShortPathPtr, - GetLastError()); - free(wShortPathPtr); - Fail(""); - } - free(wShortPathPtr); - - PAL_Terminate(); - -#endif /* WIN32 */ - - return PASS; -} - diff --git a/src/pal/tests/palsuite/file_io/GetLongPathNameW/test1/testinfo.dat b/src/pal/tests/palsuite/file_io/GetLongPathNameW/test1/testinfo.dat deleted file mode 100644 index f730300c4..000000000 --- a/src/pal/tests/palsuite/file_io/GetLongPathNameW/test1/testinfo.dat +++ /dev/null @@ -1,16 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = GetLongPathNameW -Name = Test for GetLongPathNameW Win32 (test 1) -Type = DEFAULT -EXE1 = getlongpathnamew -Description -= Tests invalid path names. Tests conversion of short to long -= path names as well as passing it a path name that is already short. -= Under BSD, there isn't a shortened version of directory names so -= I just use a long path name as the short path name to ensure it returns -= the same thing. diff --git a/src/pal/tests/palsuite/file_io/GetLongPathNameW/test2/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetLongPathNameW/test2/CMakeLists.txt deleted file mode 100644 index 8d7c40b3b..000000000 --- a/src/pal/tests/palsuite/file_io/GetLongPathNameW/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - getlongpathnamew.cpp -) - -add_executable(paltest_getlongpathnamew_test2 - ${SOURCES} -) - -add_dependencies(paltest_getlongpathnamew_test2 coreclrpal) - -target_link_libraries(paltest_getlongpathnamew_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/GetLongPathNameW/test2/getlongpathnamew.cpp b/src/pal/tests/palsuite/file_io/GetLongPathNameW/test2/getlongpathnamew.cpp deleted file mode 100644 index 3b033e9a6..000000000 --- a/src/pal/tests/palsuite/file_io/GetLongPathNameW/test2/getlongpathnamew.cpp +++ /dev/null @@ -1,266 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: GetLongPathNameW.c FreeBSD version(test 2) -** -** Purpose: Tests the PAL implementation of the GetLongPathNameW function -** as expected under FreeBSD -** -** Depends on: -** CreateDirectoryA -** RemoveDirectoryW -** -** -**===================================================================*/ -/* -tests: - - test invalid path names - - test an already short path name - - test a long path name - - test with buffer size too small -*/ - -#include - - -int __cdecl main(int argc, char *argv[]) -{ -/* Since GetLongPathNameW operates differently under FreeBSD and Win32 this test - is for freeBSD only. It runs the same tests as the Win32 version but checks for - different results -*/ -#if !(WIN32) /* Only execute if the is Free BSD */ - - DWORD dwRc = 0; - WCHAR szwReturnedPath[MAX_LONGPATH]; - WCHAR szwSmallBuff[3]; - const char szShortPathName[] = {"testing"}; - const char szLongPathName[] = {"This_is_a_long_directory_name"}; - /* since BSD doesn't shorten long dir names, it will only use the long name */ - const char szShortenedPathName[] = {"This_is_a_long_directory_name"}; - WCHAR* wLongPathPtr = NULL; - WCHAR* wShortPathPtr = NULL; - int StringLen = 0; - - - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - memset(szwReturnedPath, 0, MAX_LONGPATH*sizeof(WCHAR)); - memset(szwSmallBuff, 0, 3*sizeof(WCHAR)); - wLongPathPtr = convert((char*)szLongPathName); - wShortPathPtr = convert((char*)szShortenedPathName); - - - /* do some clean up just to be safe */ - RemoveDirectoryW(wLongPathPtr); - RemoveDirectoryW(wShortPathPtr); - - - /* attempt call on an invalid short path name */ - dwRc = GetLongPathNameW(wShortPathPtr, szwReturnedPath, MAX_LONGPATH); - if (dwRc != 0) - { - Trace("GetLongPathNameW: ERROR -> Call made with an invalid short " - "path \"%S\" returned \"%S\"\n", - wShortPathPtr, - szwReturnedPath); - free (wLongPathPtr); - free (wShortPathPtr); - Fail(""); - } - - - /* attempt call on an invalid long path name */ - dwRc = GetLongPathNameW(wLongPathPtr, szwReturnedPath, MAX_LONGPATH); - if (dwRc != 0) - { - Trace("GetLongPathNameW: ERROR -> Call made with an invalid long " - "path \"%S\" returned \"%S\"\n", - wLongPathPtr, - szwReturnedPath); - free (wLongPathPtr); - free (wShortPathPtr); - Fail(""); - } - - - /* create a long directory name */ - if (TRUE != CreateDirectoryW(wLongPathPtr, NULL)) - { - free(wLongPathPtr); - free(wShortPathPtr); - Fail("GetLongPathNameW: ERROR -> CreateDirectoryW failed with an error" - " code of %ld when asked to create a directory called \"%s\".\n", - GetLastError(), - szLongPathName); - } - - - /* get the long path name */ - memset(szwReturnedPath, 0, MAX_LONGPATH*sizeof(WCHAR)); - dwRc = GetLongPathNameW(wShortPathPtr, szwReturnedPath, MAX_LONGPATH); - StringLen = wcslen(wShortPathPtr); - - if (dwRc != StringLen) - { - Trace("GetLongPathNameW: ERROR -> Under FreeBSD, this test should" - " have returned %d but instead returned %d.\n", - StringLen, dwRc); - if (RemoveDirectoryW(wLongPathPtr) != TRUE) - { - Trace("GetLongPathNameW: ERROR -> RemoveDirectoryW failed to " - " remove the directory \"%S\" with an error code of %ld.\n", - wLongPathPtr, - GetLastError()); - } - free(wLongPathPtr); - free(wShortPathPtr); - Fail(""); - } - if (wcsncmp(wShortPathPtr,szwReturnedPath, StringLen) != 0) - { - Trace("GetLongPathNameW: ERROR -> Under Unix," - "the lpszLongPath \"%s\" should have been," - "but was \"%s\".\n", - wShortPathPtr, szwReturnedPath); - - if (RemoveDirectoryW(wLongPathPtr) != TRUE) - { - Trace("GetLongPathNameW: ERROR -> RemoveDirectoryW failed to " - " remove the directory \"%S\" with an error code of %ld.\n", - wLongPathPtr, - GetLastError()); - } - free(wLongPathPtr); - free(wShortPathPtr); - Fail(""); - } - - if (RemoveDirectoryW(wLongPathPtr) != TRUE) - { - Trace("GetLongPathNameW: ERROR -> RemoveDirectoryW failed to " - " remove the directory \"%S\" with an error code of %ld.\n", - wLongPathPtr, - GetLastError()); - free(wLongPathPtr); - free(wShortPathPtr); - Fail(""); - } - free(wShortPathPtr); - free(wLongPathPtr); - - - /* test an actual short name */ - /* create a long directory name */ - wShortPathPtr = convert((char*)szShortPathName); - RemoveDirectoryW(wShortPathPtr); - - if (TRUE != CreateDirectoryW(wShortPathPtr, NULL)) - { - free(wShortPathPtr); - Fail("GetLongPathNameW: ERROR -> CreateDirectoryW failed with an error" - " code of %ld when asked to create a directory called \"%s\".\n", - GetLastError(), - szShortPathName); - } - - - /* get the long path name */ - memset(szwReturnedPath, 0, MAX_LONGPATH*sizeof(WCHAR)); - dwRc = GetLongPathNameW(wShortPathPtr, szwReturnedPath, MAX_LONGPATH); - StringLen = wcslen (wShortPathPtr); - - if (dwRc != StringLen) - { - Trace("GetLongPathNameW: ERROR -> Under FreeBSD, this test should" - " have returned %d but instead returned %d.\n", - StringLen, dwRc); - if (RemoveDirectoryW(wShortPathPtr) != TRUE) - { - Trace("GetLongPathNameW: ERROR -> RemoveDirectoryW failed to " - " remove the directory \"%S\" with an error code of %ld.\n", - wShortPathPtr, - GetLastError()); - } - free(wShortPathPtr); - Fail(""); - } - if (wcsncmp(wShortPathPtr, szwReturnedPath, StringLen) != 0) - { - Trace("GetLongPathNameW: ERROR -> Under Unix, the lpszLongPath" - "\"%s\" should have been," - "but was \"%s\".\n", - wShortPathPtr, szwReturnedPath); - - if (RemoveDirectoryW(wShortPathPtr) != TRUE) - { - Trace("GetLongPathNameW: ERROR -> RemoveDirectoryW failed to " - " remove the directory \"%S\" with an error code of %ld.\n", - wShortPathPtr, - GetLastError()); - } - free(wShortPathPtr); - Fail(""); - } - - - /* test using a too small return buffer */ - dwRc = GetLongPathNameW(wShortPathPtr, szwSmallBuff, 3); - StringLen = wcslen (wShortPathPtr); - - - if (dwRc != (StringLen + 1)) //Return size includes NULL char - { - Trace("GetLongPathNameW: ERROR -> Under FreeBSD, this test should" - " have returned %d but instead returned %d.\n", - StringLen, dwRc); - if (RemoveDirectoryW(wShortPathPtr) != TRUE) - { - Trace("GetLongPathNameW: ERROR -> RemoveDirectoryW failed to " - " remove the directory \"%S\" with an error code of %ld.\n", - wShortPathPtr, - GetLastError()); - } - free(wShortPathPtr); - Fail(""); - } - if (szwSmallBuff[0] != 0) - { - Trace("GetLongPathNameW: ERROR -> Under FreeBSD, this test should" - " not have touched lpszLongPath but instead it returned\"%s\".\n", - szwReturnedPath); - if (RemoveDirectoryW(wShortPathPtr) != TRUE) - { - Trace("GetLongPathNameW: ERROR -> RemoveDirectoryW failed to " - " remove the directory \"%S\" with an error code of %ld.\n", - wShortPathPtr, - GetLastError()); - } - free(wShortPathPtr); - Fail(""); - } - - /* clean up */ - if (RemoveDirectoryW(wShortPathPtr) != TRUE) - { - Trace("GetLongPathNameW: ERROR -> RemoveDirectoryW failed to " - " remove the directory \"%S\" with an error code of %ld.\n", - wShortPathPtr, - GetLastError()); - free(wShortPathPtr); - Fail(""); - } - free(wShortPathPtr); - - PAL_Terminate(); - -#endif /* Free BSD */ - return PASS; -} - diff --git a/src/pal/tests/palsuite/file_io/GetLongPathNameW/test2/testinfo.dat b/src/pal/tests/palsuite/file_io/GetLongPathNameW/test2/testinfo.dat deleted file mode 100644 index 5144a35b1..000000000 --- a/src/pal/tests/palsuite/file_io/GetLongPathNameW/test2/testinfo.dat +++ /dev/null @@ -1,16 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = GetLongPathNameW -Name = Test for GetLongPathNameW FreeBSD version (test 2) -Type = DEFAULT -EXE1 = getlongpathnamew -Description -= Tests invalid path names. Tests conversion of short to long -= path names as well as passing it a path name that is already short. -= Under BSD, there isn't a shortened version of directory names so -= I just use a long path name as the short path name to ensure it returns -= the same thing. diff --git a/src/pal/tests/palsuite/file_io/GetStdHandle/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetStdHandle/CMakeLists.txt deleted file mode 100644 index ef14ea535..000000000 --- a/src/pal/tests/palsuite/file_io/GetStdHandle/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) - diff --git a/src/pal/tests/palsuite/file_io/GetStdHandle/test1/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetStdHandle/test1/CMakeLists.txt deleted file mode 100644 index 7a299015b..000000000 --- a/src/pal/tests/palsuite/file_io/GetStdHandle/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - GetStdHandle.cpp -) - -add_executable(paltest_getstdhandle_test1 - ${SOURCES} -) - -add_dependencies(paltest_getstdhandle_test1 coreclrpal) - -target_link_libraries(paltest_getstdhandle_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/GetStdHandle/test1/GetStdHandle.cpp b/src/pal/tests/palsuite/file_io/GetStdHandle/test1/GetStdHandle.cpp deleted file mode 100644 index 47b1eba59..000000000 --- a/src/pal/tests/palsuite/file_io/GetStdHandle/test1/GetStdHandle.cpp +++ /dev/null @@ -1,123 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: GetStdHandle.c (test 1) -** -** Purpose: Tests the PAL implementation of the GetStdHandle function. -** -** -**===================================================================*/ - -#include - - -int __cdecl main(int argc, char *argv[]) -{ - HANDLE hFile = NULL; - DWORD dwBytesWritten = 0; - DWORD dwFileType; - BOOL bRc = FALSE; - const char* szText = "this is a test of GetStdHandle\n"; - - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - /* - * attempt to get an invalid handle - */ - hFile = GetStdHandle(-2); - if (hFile != INVALID_HANDLE_VALUE) - { - Fail("GetStdHandle: ERROR -> A request for the STD_INPUT_HANDLE " - "returned an invalid handle.\n"); - } - - - /* - * test the STD_INPUT_HANDLE handle - */ - hFile = GetStdHandle(STD_INPUT_HANDLE); - if (hFile == INVALID_HANDLE_VALUE) - { - Fail("GetStdHandle: ERROR -> A request for the STD_INPUT_HANDLE " - "returned an invalid handle.\n"); - } - - /* an attempt to write to the input handle should fail */ - /* I don't know how to automate a read from the input handle */ - bRc = WriteFile(hFile, szText, (DWORD)strlen(szText), &dwBytesWritten, NULL); - if (bRc != FALSE) - { - Fail("GetStdHandle: ERROR -> WriteFile was able to write to " - "STD_INPUT_HANDLE when it should have failed.\n"); - } - - - /* - * test the STD_OUTPUT_HANDLE handle - */ - hFile = GetStdHandle(STD_OUTPUT_HANDLE); - if (hFile == INVALID_HANDLE_VALUE) - { - Fail("GetStdHandle: ERROR -> A request for the STD_OUTPUT_HANDLE " - "returned an invalid handle.\n"); - } - - /* try to write to the output handle */ - bRc = WriteFile(hFile, szText, (DWORD)strlen(szText), &dwBytesWritten, NULL); - if (bRc != TRUE) - { - Fail("GetStdHandle: ERROR -> WriteFile failed to write to " - "STD_OUTPUT_HANDLE with the error %ld\n", - GetLastError()); - } - - - /* test the STD_ERROR_HANDLE handle */ - hFile = GetStdHandle(STD_ERROR_HANDLE); - if (hFile == INVALID_HANDLE_VALUE) - { - Fail("GetStdHandle: ERROR -> A request for the STD_ERROR_HANDLE " - "returned an invalid handle.\n"); - } - - /* try to write to the error handle */ - bRc = WriteFile(hFile, szText, (DWORD)strlen(szText), &dwBytesWritten, NULL); - if (bRc != TRUE) - { - Fail("GetStdHandle: ERROR -> WriteFile failed to write to " - "STD_ERROR_HANDLE with the error %ld\n", - GetLastError()); - } - - /* check to see if we can CloseHandle works on the STD_ERROR_HANDLE */ - if (!CloseHandle(hFile)) - { - Fail("GetStdHandle: ERROR -> CloseHandle failed. GetLastError " - "returned %u.\n", - GetLastError()); - } - - /* try to write to the closed error handle */ - bRc = WriteFile(hFile, - szText, - (DWORD)strlen(szText), - &dwBytesWritten, - NULL); - if (bRc) - { - Fail("GetStdHandle: ERROR -> WriteFile was able to write to the closed" - " STD_ERROR_HANDLE handle.\n"); - } - - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/file_io/GetStdHandle/test1/testinfo.dat b/src/pal/tests/palsuite/file_io/GetStdHandle/test1/testinfo.dat deleted file mode 100644 index 3f7dbf5f4..000000000 --- a/src/pal/tests/palsuite/file_io/GetStdHandle/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = GetStdHandle -Name = Positive Test for GetStdHandle (test 1) -Type = DEFAULT -EXE1 = getstdhandle -Description -= Test GetStdHandle on a valid/invalid std handles - diff --git a/src/pal/tests/palsuite/file_io/GetStdHandle/test2/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetStdHandle/test2/CMakeLists.txt deleted file mode 100644 index 5a4d2ba15..000000000 --- a/src/pal/tests/palsuite/file_io/GetStdHandle/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - GetStdHandle.cpp -) - -add_executable(paltest_getstdhandle_test2 - ${SOURCES} -) - -add_dependencies(paltest_getstdhandle_test2 coreclrpal) - -target_link_libraries(paltest_getstdhandle_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/GetStdHandle/test2/GetStdHandle.cpp b/src/pal/tests/palsuite/file_io/GetStdHandle/test2/GetStdHandle.cpp deleted file mode 100644 index 45f5ddd24..000000000 --- a/src/pal/tests/palsuite/file_io/GetStdHandle/test2/GetStdHandle.cpp +++ /dev/null @@ -1,79 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: GetStdHandle.c (test 2) -** -** Purpose: Smoke Tests the PAL implementation of the GetStdHandle function. -** -** -**===================================================================*/ - -#include - - -int __cdecl main(int argc, char *argv[]) -{ - HANDLE hFile = NULL; - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - /* - * attempt to get an invalid handle - */ - hFile = GetStdHandle(-2); - if (hFile != INVALID_HANDLE_VALUE) - { - Fail("GetStdHandle: ERROR -> A request for the STD_INPUT_HANDLE " - "returned an invalid handle.\n"); - } - - - /* - * test the STD_INPUT_HANDLE handle - */ - hFile = GetStdHandle(STD_INPUT_HANDLE); - if (hFile == INVALID_HANDLE_VALUE) - { - Fail("GetStdHandle: ERROR -> A request for the STD_INPUT_HANDLE " - "returned an invalid handle.\n"); - } - - - /* - * test the STD_OUTPUT_HANDLE handle - */ - hFile = GetStdHandle(STD_OUTPUT_HANDLE); - if (hFile == INVALID_HANDLE_VALUE) - { - Fail("GetStdHandle: ERROR -> A request for the STD_OUTPUT_HANDLE " - "returned an invalid handle.\n"); - } - - /* test the STD_ERROR_HANDLE handle */ - hFile = GetStdHandle(STD_ERROR_HANDLE); - if (hFile == INVALID_HANDLE_VALUE) - { - Fail("GetStdHandle: ERROR -> A request for the STD_ERROR_HANDLE " - "returned an invalid handle.\n"); - } - - - /* check to see if we can CloseHandle works on the STD_ERROR_HANDLE */ - if (!CloseHandle(hFile)) - { - Fail("GetStdHandle: ERROR -> CloseHandle failed. GetLastError " - "returned %u.\n", - GetLastError()); - } - - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/file_io/GetStdHandle/test2/testinfo.dat b/src/pal/tests/palsuite/file_io/GetStdHandle/test2/testinfo.dat deleted file mode 100644 index dcd498c6e..000000000 --- a/src/pal/tests/palsuite/file_io/GetStdHandle/test2/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = GetStdHandle -Name = Positive Test for GetStdHandle (test 2) -Type = DEFAULT -EXE1 = getstdhandle -Description -= Smoke Test GetStdHandle on a valid/invalid std handles - diff --git a/src/pal/tests/palsuite/file_io/GetSystemTime/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetSystemTime/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/file_io/GetSystemTime/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/file_io/GetSystemTime/test1/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetSystemTime/test1/CMakeLists.txt deleted file mode 100644 index 7135abf62..000000000 --- a/src/pal/tests/palsuite/file_io/GetSystemTime/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test.cpp -) - -add_executable(paltest_getsystemtime_test1 - ${SOURCES} -) - -add_dependencies(paltest_getsystemtime_test1 coreclrpal) - -target_link_libraries(paltest_getsystemtime_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/GetSystemTime/test1/test.cpp b/src/pal/tests/palsuite/file_io/GetSystemTime/test1/test.cpp deleted file mode 100644 index 361dbef33..000000000 --- a/src/pal/tests/palsuite/file_io/GetSystemTime/test1/test.cpp +++ /dev/null @@ -1,124 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source: test.c -** -** Purpose: Test for GetSystemTime() function -** -** -**=========================================================*/ - -/* Note: Some of the range comparisons only check - * the high end of the range. Since the structure - * contains WORDs, negative values can never be included, - * so there is no reason to check and see if the lower - * end of the spectrum is <0 -*/ - -#include - - -int __cdecl main(int argc, char *argv[]) -{ - SYSTEMTIME TheTime; - SYSTEMTIME firstTime; - SYSTEMTIME secondTime; - - WORD avgDeltaFileTime = 0; - - int i=0; - - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - GetSystemTime(&TheTime); - - /* Go through each item in the structure and ensure it is a valid value. - We can't ensure they have the exact values of the current time, but - at least that they have been set to a valid range of values for that - item. - */ - - /* Year */ - if(TheTime.wYear < (WORD)2001) - { - Fail("ERROR: The year is %d, when it should be at least 2001.", - TheTime.wYear); - } - - /* Month */ - if(TheTime.wMonth > (WORD)12 || TheTime.wMonth < (WORD)1) - { - Fail("ERROR: The month should be between 1 and 12, and it is " - "showing up as %d.",TheTime.wMonth); - } - - /* Weekday */ - if(TheTime.wDayOfWeek > 6) - { - Fail("ERROR: The day of the week should be between 0 and 6, " - "and it is showing up as %d.",TheTime.wDayOfWeek); - } - - /* Day of the Month */ - if(TheTime.wDay > 31 || TheTime.wDay < 1) - { - Fail("ERROR: The day of the month should be between 1 and " - "31, and it is showing up as %d.",TheTime.wDay); - } - - /* Hour */ - if(TheTime.wHour > 23) - { - Fail("ERROR: The hour should be between 0 and 23, and it is " - "showing up as %d.",TheTime.wHour); - } - - /* Minute */ - if(TheTime.wMinute > 59) - { - Fail("ERROR: The minute should be between 0 and 59 and it is " - "showing up as %d.",TheTime.wMinute); - } - - /* Second */ - if(TheTime.wSecond > 59) - { - Fail("ERROR: The second should be between 0 and 59 and it is" - " showing up as %d.",TheTime.wSecond); - } - - /* Millisecond */ - if(TheTime.wMilliseconds > 999) - { - Fail("ERROR: The milliseconds should be between 0 and 999 " - "and it is currently showing %d.",TheTime.wMilliseconds); - } - - /* check if two consecutive calls to system time return */ - /* correct time in ms after sleep() call. */ - for (i = 0; i<5 ;i++) - { - GetSystemTime(&firstTime); - Sleep(1000); - GetSystemTime(&secondTime); - avgDeltaFileTime += abs(firstTime.wSecond - secondTime.wSecond ); - - } - - if( (avgDeltaFileTime/5) < 1.0) - { - Fail("ERROR: 2 calls for GetSystemTime interrupted" - " by a 1000 ms sleep failed Value[%f]", avgDeltaFileTime/5 ); - } - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/file_io/GetSystemTime/test1/testinfo.dat b/src/pal/tests/palsuite/file_io/GetSystemTime/test1/testinfo.dat deleted file mode 100644 index 05169f65c..000000000 --- a/src/pal/tests/palsuite/file_io/GetSystemTime/test1/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Miscellaneous -Function = GetSystemTime -Name = Positive test of GetSystemTime -Type = DEFAULT -EXE1 = test -Description -= Tests the PAL implementation of the GetSystemTime API diff --git a/src/pal/tests/palsuite/file_io/GetSystemTimeAsFileTime/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetSystemTimeAsFileTime/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/file_io/GetSystemTimeAsFileTime/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/file_io/GetSystemTimeAsFileTime/test1/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetSystemTimeAsFileTime/test1/CMakeLists.txt deleted file mode 100644 index d7421b91c..000000000 --- a/src/pal/tests/palsuite/file_io/GetSystemTimeAsFileTime/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - GetSystemTimeAsFileTime.cpp -) - -add_executable(paltest_getsystemtimeasfiletime_test1 - ${SOURCES} -) - -add_dependencies(paltest_getsystemtimeasfiletime_test1 coreclrpal) - -target_link_libraries(paltest_getsystemtimeasfiletime_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/GetSystemTimeAsFileTime/test1/GetSystemTimeAsFileTime.cpp b/src/pal/tests/palsuite/file_io/GetSystemTimeAsFileTime/test1/GetSystemTimeAsFileTime.cpp deleted file mode 100644 index bd7e856ab..000000000 --- a/src/pal/tests/palsuite/file_io/GetSystemTimeAsFileTime/test1/GetSystemTimeAsFileTime.cpp +++ /dev/null @@ -1,86 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: GetSystemTimeAsFileTime.c -** -** Purpose: Tests the PAL implementation of GetSystemTimeAsFileTime -** Take two times, three seconds apart, and ensure that the time is -** increasing, and that it has increased at least 3 seconds. -** -** -** -**===================================================================*/ - -#include - - -int __cdecl main(int argc, char **argv) -{ - - FILETIME TheFirstTime, TheSecondTime; - ULONG64 FullFirstTime, FullSecondTime; - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - /* Get two times, 3 seconds apart */ - - GetSystemTimeAsFileTime( &TheFirstTime ); - - Sleep( 3000 ); - - GetSystemTimeAsFileTime( &TheSecondTime ); - - /* Convert them to ULONG64 to work with */ - - FullFirstTime = ((( (ULONG64)TheFirstTime.dwHighDateTime )<<32) | - ( (ULONG64)TheFirstTime.dwLowDateTime )); - - FullSecondTime = ((( (ULONG64)TheSecondTime.dwHighDateTime )<<32) | - ( (ULONG64)TheSecondTime.dwLowDateTime )); - - /* Test to ensure the second value is larger than the first */ - - if( FullSecondTime <= FullFirstTime ) - { - Fail("ERROR: The system time didn't increase in the last " - "three seconds. The second time tested was less than " - "or equal to the first."); - } - - /* Note: The 30000000 magic number is 3 seconds in hundreds of nano - seconds. This test checks to ensure at least 3 seconds passed - between the readings. - */ - - if( ( (LONG64)( FullSecondTime - FullFirstTime ) - 30000000 ) < 0 ) - { - ULONG64 TimeError; - - /* Note: This test used to compare the difference between full times - in terms of hundreds of nanoseconds. But the x86 clock seems to be - precise only to the level of about 10000 nanoseconds, so we would - fail the comparison depending on when we took time slices. - - To fix this, we just check that we're within a millisecond of - sleeping 3000 milliseconds. We're not currently ensuring that we - haven't slept much more than 3000 ms. We may want to do that. - */ - TimeError = 30000000 - ( FullSecondTime - FullFirstTime ); - if ( TimeError > 10000) - { - Fail("ERROR: Two system times were tested, with a sleep of 3 " - "seconds between. The time passed should have been at least " - "3 seconds. But, it was less according to the function."); - } - } - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/file_io/GetSystemTimeAsFileTime/test1/testinfo.dat b/src/pal/tests/palsuite/file_io/GetSystemTimeAsFileTime/test1/testinfo.dat deleted file mode 100644 index 3318d1386..000000000 --- a/src/pal/tests/palsuite/file_io/GetSystemTimeAsFileTime/test1/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = GetSystemTimeAsFileTime -Name = Positive Test for GetSystemTimeAsFileTime -TYPE = DEFAULT -EXE1 = getsystemtimeasfiletime -Description -= Test the GetSystemTimeAsFileTime function. -= Take two times, three seconds apart, and ensure that the time is -= increasing, and that it has increased at least 3 seconds. diff --git a/src/pal/tests/palsuite/file_io/GetTempFileNameA/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetTempFileNameA/CMakeLists.txt deleted file mode 100644 index 1962ade35..000000000 --- a/src/pal/tests/palsuite/file_io/GetTempFileNameA/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) -add_subdirectory(test3) - diff --git a/src/pal/tests/palsuite/file_io/GetTempFileNameA/test1/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetTempFileNameA/test1/CMakeLists.txt deleted file mode 100644 index 38fdb4977..000000000 --- a/src/pal/tests/palsuite/file_io/GetTempFileNameA/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - GetTempFileNameA.cpp -) - -add_executable(paltest_gettempfilenamea_test1 - ${SOURCES} -) - -add_dependencies(paltest_gettempfilenamea_test1 coreclrpal) - -target_link_libraries(paltest_gettempfilenamea_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/GetTempFileNameA/test1/GetTempFileNameA.cpp b/src/pal/tests/palsuite/file_io/GetTempFileNameA/test1/GetTempFileNameA.cpp deleted file mode 100644 index bea8e2776..000000000 --- a/src/pal/tests/palsuite/file_io/GetTempFileNameA/test1/GetTempFileNameA.cpp +++ /dev/null @@ -1,125 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: GetTempFileNameA.c (test 1) -** -** Purpose: Tests the PAL implementation of the GetTempFileNameA function. -** -** Depends on: -** GetFileAttributesA -** DeleteFileA -** -** -**===================================================================*/ - -#include - - - -int __cdecl main(int argc, char *argv[]) -{ - UINT uiError = 0; - const UINT uUnique = 0; - const char* szDot = {"."}; - const char* szValidPrefix = {"cfr"}; - const char* szLongValidPrefix = {"cfrwxyz"}; - char szReturnedName[256]; - char szTempString[256]; - - if (0 != PAL_Initialize(argc, argv)) - { - return FAIL; - } - - /* valid path with null prefix */ - uiError = GetTempFileNameA(szDot, NULL, uUnique, szReturnedName); - if (uiError == 0) - { - Fail("GetTempFileNameA: ERROR -> Call failed with a valid path " - "with the error code: %ld\n", GetLastError()); - } - else - { - /* verify temp file was created */ - if (GetFileAttributesA(szReturnedName) == -1) - { - Fail("GetTempFileNameA: ERROR -> GetFileAttributes failed on the " - "returned temp file \"%s\" with error code: %ld.\n", - szReturnedName, - GetLastError()); - } - if (DeleteFileA(szReturnedName) != TRUE) - { - Fail("GetTempFileNameA: ERROR -> DeleteFileW failed to delete" - "the created temp file with error code: %ld.\n", GetLastError()); - } - } - - - /* valid path with valid prefix */ - uiError = GetTempFileNameA(szDot, szValidPrefix, uUnique, szReturnedName); - if (uiError == 0) - { - Fail("GetTempFileNameA: ERROR -> Call failed with a valid path and " - "prefix with the error code: %ld\n", GetLastError()); - } - else - { - /* verify temp file was created */ - if (GetFileAttributesA(szReturnedName) == -1) - { - Fail("GetTempFileNameA: ERROR -> GetFileAttributes failed on the " - "returned temp file \"%s\" with error code: %ld.\n", - szReturnedName, - GetLastError()); - } - if (DeleteFileA(szReturnedName) != TRUE) - { - Fail("GetTempFileNameA: ERROR -> DeleteFileW failed to delete" - "the created temp \"%s\" file with error code: %ld.\n", - szReturnedName, - GetLastError()); - } - } - - /* valid path with long prefix */ - uiError = GetTempFileNameA(szDot, szLongValidPrefix, uUnique, szReturnedName); - if (uiError == 0) - { - Fail("GetTempFileNameA: ERROR -> Call failed with a valid path and " - "prefix with the error code: %ld\n", GetLastError()); - } - else - { - /* verify temp file was created */ - if (GetFileAttributesA(szReturnedName) == -1) - { - Fail("GetTempFileNameA: ERROR -> GetFileAttributes failed on the " - "returned temp file \"%s\" with error code: %ld.\n", - szReturnedName, - GetLastError()); - } - - /* now verify that it only used the first 3 characters of the prefix */ - sprintf_s(szTempString, _countof(szTempString), "%s\\%s", szDot, szLongValidPrefix); - if (strncmp(szTempString, szReturnedName, 6) == 0) - { - Fail("GetTempFileNameA: ERROR -> It appears that an improper prefix " - "was used.\n"); - } - - if (DeleteFileA(szReturnedName) != TRUE) - { - Fail("GetTempFileNameA: ERROR -> DeleteFileW failed to delete" - "the created temp file \"%s\" with error code: %ld.\n", - szReturnedName, - GetLastError()); - } - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/file_io/GetTempFileNameA/test1/testinfo.dat b/src/pal/tests/palsuite/file_io/GetTempFileNameA/test1/testinfo.dat deleted file mode 100644 index 4bf0000b9..000000000 --- a/src/pal/tests/palsuite/file_io/GetTempFileNameA/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = GetTempFileNameA -Name = Test for GetTempFileNameA (test 1) -Type = DEFAULT -EXE1 = gettempfilenamea -Description -= Tests the PAL implimentation of GetTempFileNameA by testing -= various combinations of path and prefix names. diff --git a/src/pal/tests/palsuite/file_io/GetTempFileNameA/test2/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetTempFileNameA/test2/CMakeLists.txt deleted file mode 100644 index 1c302acd9..000000000 --- a/src/pal/tests/palsuite/file_io/GetTempFileNameA/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - GetTempFileNameA.cpp -) - -add_executable(paltest_gettempfilenamea_test2 - ${SOURCES} -) - -add_dependencies(paltest_gettempfilenamea_test2 coreclrpal) - -target_link_libraries(paltest_gettempfilenamea_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/GetTempFileNameA/test2/GetTempFileNameA.cpp b/src/pal/tests/palsuite/file_io/GetTempFileNameA/test2/GetTempFileNameA.cpp deleted file mode 100644 index 861a8b87e..000000000 --- a/src/pal/tests/palsuite/file_io/GetTempFileNameA/test2/GetTempFileNameA.cpp +++ /dev/null @@ -1,80 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: GetTempFileNameA.c (test 2) -** -** Purpose: Tests the number of files GetTempFileNameA can create. -** -** Depends on: -** GetFileAttributesA -** oodles of free disk space (>4.07GB) -** -** -**===================================================================*/ - -#include - - - -int __cdecl main(int argc, char *argv[]) -{ - UINT uiError = 0; - DWORD dwError = 0; - const UINT uUnique = 0; - const char* szDot = {"."}; - const char* szValidPrefix = {"cfr"}; - char szReturnedName[256]; - DWORD i; - - if (0 != PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - /* test the number of temp files that can be created */ - for (i = 0; i < 0x10005; i++) - { - uiError = GetTempFileNameA(szDot, szValidPrefix, uUnique, szReturnedName); - if (uiError == 0) - { - dwError = GetLastError(); - if (dwError == ERROR_FILE_EXISTS) - { - /* file already existes so break out of the loop */ - i--; /* decrement the count because it wasn't successful */ - break; - } - else - { - /* it was something other than the file already existing? */ - Fail("GetTempFileNameA: ERROR -> Call failed with a valid " - "path and prefix with the error code: %ld\n", GetLastError()); - } - } - else - { - /* verify temp file was created */ - if (GetFileAttributesA(szReturnedName) == -1) - { - Fail("GetTempFileNameA: ERROR -> GetFileAttributes failed " - "on the returned temp file \"%s\" with error code: %ld.\n", - szReturnedName, - GetLastError()); - } - } - } - - /* did it create more than 0xffff files */ - if (i > 0xffff) - { - Fail("GetTempFileNameA: ERROR -> Was able to create more than 0xffff" - " temp files.\n"); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/file_io/GetTempFileNameA/test2/testinfo.dat b/src/pal/tests/palsuite/file_io/GetTempFileNameA/test2/testinfo.dat deleted file mode 100644 index ca46f6d84..000000000 --- a/src/pal/tests/palsuite/file_io/GetTempFileNameA/test2/testinfo.dat +++ /dev/null @@ -1,17 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = GetTempFileNameA -Name = Test for GetTempFileNameA (test 2) -Type = DEFAULT -EXE1 = gettempfilenamea -Description -= Test the number of files that can be created. Since -= GetTempFileNameA only handles 8.3 file names, the test -= attempts to create more than the maximum temp files possible -= with a 3 character prefix. Since this test takes so long, it -= is not to be included in the standard test harness. -= This test will also need more than 4.07 GB free disk space. diff --git a/src/pal/tests/palsuite/file_io/GetTempFileNameA/test3/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetTempFileNameA/test3/CMakeLists.txt deleted file mode 100644 index ec18937e0..000000000 --- a/src/pal/tests/palsuite/file_io/GetTempFileNameA/test3/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - gettempfilenamea.cpp -) - -add_executable(paltest_gettempfilenamea_test3 - ${SOURCES} -) - -add_dependencies(paltest_gettempfilenamea_test3 coreclrpal) - -target_link_libraries(paltest_gettempfilenamea_test3 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/GetTempFileNameA/test3/gettempfilenamea.cpp b/src/pal/tests/palsuite/file_io/GetTempFileNameA/test3/gettempfilenamea.cpp deleted file mode 100644 index 8eccc3d2e..000000000 --- a/src/pal/tests/palsuite/file_io/GetTempFileNameA/test3/gettempfilenamea.cpp +++ /dev/null @@ -1,159 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: GetTempFileNameA.c (test 3) -** -** Purpose: Tests the PAL implementation of the GetTempFileNameA function. -** Checks the file attributes and ensures that getting a file name, -** deleting the file and getting another doesn't produce the same -** as the just deleted file. Also checks the file size is 0. -** -** Depends on: -** GetFileAttributesA -** CloseHandle -** DeleteFileA -** CreateFileA -** GetFileSize -** -** -**===================================================================*/ - -#include - - - -int __cdecl main(int argc, char *argv[]) -{ - const UINT uUnique = 0; - UINT uiError; - const char* szDot = {"."}; - char szReturnedName[MAX_LONGPATH]; - char szReturnedName_02[MAX_LONGPATH]; - DWORD dwFileSize = 0; - HANDLE hFile; - - if (0 != PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - /* valid path with null prefix */ - uiError = GetTempFileNameA(szDot, NULL, uUnique, szReturnedName); - if (uiError == 0) - { - Fail("GetTempFileNameA: ERROR -> Call failed with a valid path " - "with the error code: %u.\n", - GetLastError()); - } - - /* verify temp file was created */ - if (GetFileAttributesA(szReturnedName) == -1) - { - Fail("GetTempFileNameA: ERROR -> GetFileAttributes failed on the " - "returned temp file \"%s\" with error code: %u.\n", - szReturnedName, - GetLastError()); - } - - /* - ** verify that the file size is 0 bytes - */ - - hFile = CreateFileA(szReturnedName, - GENERIC_READ, - FILE_SHARE_READ, - NULL, - OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL, - NULL); - if (hFile == INVALID_HANDLE_VALUE) - { - Trace("GetTempFileNameA: ERROR -> CreateFileA failed to open" - " the created temp file with error code: %u.\n", - GetLastError()); - if (!DeleteFileA(szReturnedName)) - { - Trace("GetTempFileNameA: ERROR -> DeleteFileA failed to delete" - " the created temp file with error code: %u.\n", - GetLastError()); - } - Fail(""); - } - - if ((dwFileSize = GetFileSize(hFile, NULL)) != (DWORD)0) - { - Trace("GetTempFileNameA: ERROR -> GetFileSize returned %u whereas" - "it should have returned 0.\n", - dwFileSize); - if (!CloseHandle(hFile)) - { - Trace("GetTempFileNameA: ERROR -> CloseHandle failed. " - "GetLastError returned: %u.\n", - GetLastError()); - } - if (!DeleteFileA(szReturnedName)) - { - Trace("GetTempFileNameA: ERROR -> DeleteFileA failed to delete" - " the created temp file with error code: %u.\n", - GetLastError()); - } - Fail(""); - } - - - if (!CloseHandle(hFile)) - { - Fail("GetTempFileNameA: ERROR -> CloseHandle failed. " - "GetLastError returned: %u.\n", - GetLastError()); - } - - if (DeleteFileA(szReturnedName) != TRUE) - { - Fail("GetTempFileNameA: ERROR -> DeleteFileA failed to delete" - " the created temp file with error code: %u.\n", - GetLastError()); - } - - /* get another and make sure it's not the same as the last */ - uiError = GetTempFileNameA(szDot, NULL, uUnique, szReturnedName_02); - if (uiError == 0) - { - Fail("GetTempFileNameA: ERROR -> Call failed with a valid path " - "with the error code: %u.\n", - GetLastError()); - } - - /* did we get different names? */ - if (strcmp(szReturnedName, szReturnedName_02) == 0) - { - Trace("GetTempFileNameA: ERROR -> The first call returned \"%s\". " - "The second call returned \"%s\" and the two should not be" - " the same.\n", - szReturnedName, - szReturnedName_02); - if (!DeleteFileA(szReturnedName_02)) - { - Trace("GetTempFileNameA: ERROR -> DeleteFileA failed to delete" - " the created temp file with error code: %u.\n", - GetLastError()); - } - Fail(""); - } - - /* clean up */ - if (!DeleteFileA(szReturnedName_02)) - { - Fail("GetTempFileNameA: ERROR -> DeleteFileA failed to delete" - " the created temp file with error code: %u.\n", - GetLastError()); - } - - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/file_io/GetTempFileNameA/test3/testinfo.dat b/src/pal/tests/palsuite/file_io/GetTempFileNameA/test3/testinfo.dat deleted file mode 100644 index f1f5bf576..000000000 --- a/src/pal/tests/palsuite/file_io/GetTempFileNameA/test3/testinfo.dat +++ /dev/null @@ -1,15 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = GetTempFileNameA -Name = Test for GetTempFileNameA (test 3) -Type = DEFAULT -EXE1 = gettempfilenamea -Description -= Tests the PAL implementation of the GetTempFileNameA function. -= Checks the file attributes and ensures that getting a file name, -= deleting the file and getting another doesn't produce the same -= as the just deleted file. Also checks the file size is 0. diff --git a/src/pal/tests/palsuite/file_io/GetTempFileNameW/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetTempFileNameW/CMakeLists.txt deleted file mode 100644 index 1962ade35..000000000 --- a/src/pal/tests/palsuite/file_io/GetTempFileNameW/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) -add_subdirectory(test3) - diff --git a/src/pal/tests/palsuite/file_io/GetTempFileNameW/test1/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetTempFileNameW/test1/CMakeLists.txt deleted file mode 100644 index 96ad10bb3..000000000 --- a/src/pal/tests/palsuite/file_io/GetTempFileNameW/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - GetTempFileNameW.cpp -) - -add_executable(paltest_gettempfilenamew_test1 - ${SOURCES} -) - -add_dependencies(paltest_gettempfilenamew_test1 coreclrpal) - -target_link_libraries(paltest_gettempfilenamew_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/GetTempFileNameW/test1/GetTempFileNameW.cpp b/src/pal/tests/palsuite/file_io/GetTempFileNameW/test1/GetTempFileNameW.cpp deleted file mode 100644 index ebc4d25bc..000000000 --- a/src/pal/tests/palsuite/file_io/GetTempFileNameW/test1/GetTempFileNameW.cpp +++ /dev/null @@ -1,129 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: GetTempFileNameW.c (test 1) -** -** Purpose: Tests the PAL implementation of the GetTempFileNameW function. -** -** -**===================================================================*/ - -#include - - - -int __cdecl main(int argc, char *argv[]) -{ - UINT uiError = 0; - const UINT uUnique = 0; - WCHAR* wPrefix = NULL; - WCHAR* wPath = NULL; - WCHAR wReturnedName[256]; - WCHAR wTempString[256]; - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - - // valid path with null ext - wPath = convert("."); - uiError = GetTempFileNameW(wPath, wPrefix, uUnique, wReturnedName); - free (wPath); - if (uiError == 0) - { - Fail("GetTempFileNameW: ERROR -> Call failed with a valid path " - "with the error code: %ld\n", GetLastError()); - } - else - { - // verify temp file was created - if (GetFileAttributesW(wReturnedName) == -1) - { - Fail("GetTempFileNameW: ERROR -> GetFileAttributes failed on the " - "returned temp file with error code: %ld.\n", GetLastError()); - } - if (DeleteFileW(wReturnedName) != TRUE) - { - Fail("GetTempFileNameW: ERROR -> DeleteFileW failed to delete" - "the created temp file with error code: %lld.\n", GetLastError()); - } - } - - - // valid path with valid prefix - wPath = convert("."); - wPrefix = convert("cfr"); - uiError = GetTempFileNameW(wPath, wPrefix, uUnique, wReturnedName); - free (wPath); - free (wPrefix); - if (uiError == 0) - { - Fail("GetTempFileNameW: ERROR -> Call failed with a valid path and " - "prefix with the error code: %ld\n", GetLastError()); - } - else - { - // verify temp file was created - if (GetFileAttributesW(wReturnedName) == -1) - { - Fail("GetTempFileNameW: ERROR -> GetFileAttributes failed on the " - "returned temp file with error code: %ld.\n", GetLastError()); - } - if (DeleteFileW(wReturnedName) != TRUE) - { - Fail("GetTempFileNameW: ERROR -> DeleteFileW failed to delete" - "the created temp file with error code: %lld.\n", GetLastError()); - } - } - - // valid path with long prefix - wPath = convert("."); - wPrefix = convert("cfrwxyz"); - uiError = GetTempFileNameW(wPath, wPrefix, uUnique, wReturnedName); - if (uiError == 0) - { - free (wPath); - free (wPrefix); - Fail("GetTempFileNameW: ERROR -> Call failed with a valid path and " - "prefix with the error code: %ld\n", GetLastError()); - } - else - { - // verify temp file was created - if (GetFileAttributesW(wReturnedName) == -1) - { - free (wPath); - free (wPrefix); - Fail("GetTempFileNameW: ERROR -> GetFileAttributes failed on the " - "returned temp file with error code: %ld.\n", GetLastError()); - } - - // now verify that it only used the first 3 characters of the prefix - swprintf_s(wTempString, _countof(wTempString), convert("%s\\%s"), wPath, wPrefix); - if (memcmp(wTempString, wReturnedName, wcslen(wTempString)*sizeof(WCHAR)) == 0) - { - free (wPath); - free (wPrefix); - Fail("GetTempFileNameW: ERROR -> It appears that an improper prefix " - "was used.\n"); - } - - if (DeleteFileW(wReturnedName) != TRUE) - { - free (wPath); - free (wPrefix); - Fail("GetTempFileNameW: ERROR -> DeleteFileW failed to delete" - "the created temp file with error code: %lld.\n", GetLastError()); - } - } - - free (wPath); - free (wPrefix); - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/file_io/GetTempFileNameW/test1/testinfo.dat b/src/pal/tests/palsuite/file_io/GetTempFileNameW/test1/testinfo.dat deleted file mode 100644 index 72af6930d..000000000 --- a/src/pal/tests/palsuite/file_io/GetTempFileNameW/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = GetTempFileNameW -Name = Test for GetTempFileNameW (test 1) -Type = DEFAULT -EXE1 = gettempfilenamew -Description -= Test all the different options of GetTempFileNameW - diff --git a/src/pal/tests/palsuite/file_io/GetTempFileNameW/test2/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetTempFileNameW/test2/CMakeLists.txt deleted file mode 100644 index bc97c2bc4..000000000 --- a/src/pal/tests/palsuite/file_io/GetTempFileNameW/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - GetTempFileNameW.cpp -) - -add_executable(paltest_gettempfilenamew_test2 - ${SOURCES} -) - -add_dependencies(paltest_gettempfilenamew_test2 coreclrpal) - -target_link_libraries(paltest_gettempfilenamew_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/GetTempFileNameW/test2/GetTempFileNameW.cpp b/src/pal/tests/palsuite/file_io/GetTempFileNameW/test2/GetTempFileNameW.cpp deleted file mode 100644 index 2c8b19e08..000000000 --- a/src/pal/tests/palsuite/file_io/GetTempFileNameW/test2/GetTempFileNameW.cpp +++ /dev/null @@ -1,84 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: GetTempFileNameW.c (test 2) -** -** Purpose: Tests the PAL implementation of the GetTempFileNameW function. -** -** -**===================================================================*/ - -#include - - - -int __cdecl main(int argc, char *argv[]) -{ - UINT uiError = 0; - DWORD dwError = 0; - const UINT uUnique = 0; - WCHAR* wPrefix = NULL; - WCHAR* wPath = NULL; - WCHAR wReturnedName[256]; - DWORD i; - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - - // test the number of temp files that can be created - wPrefix = convert("cfr"); - wPath = convert("."); - for (i = 0; i < 0x10005; i++) - { - uiError = GetTempFileNameW(wPath, wPrefix, uUnique, wReturnedName); - if (uiError == 0) - { - dwError = GetLastError(); - if (dwError == ERROR_FILE_EXISTS) - { - // file already existes so break out of the loop - i--; // decrement the count because it wasn't successful - break; - } - else - { - // it was something other than the file already existing? - free (wPath); - free (wPrefix); - Fail("GetTempFileNameW: ERROR -> Call failed with a valid " - "path and prefix with the error code: %ld\n", GetLastError()); - } - } - else - { - // verify temp file was created - if (GetFileAttributesW(wReturnedName) == -1) - { - free (wPath); - free (wPrefix); - Fail("GetTempFileNameW: ERROR -> GetFileAttributes failed " - "on the returned temp file with error code: %ld.\n", - GetLastError()); - } - } - } - - free (wPath); - free (wPrefix); - - // did it create more than 0xffff files - if (i > 0xffff) - { - Fail("GetTempFileNameW: ERROR -> Was able to create more than 0xffff" - " temp files.\n"); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/file_io/GetTempFileNameW/test2/testinfo.dat b/src/pal/tests/palsuite/file_io/GetTempFileNameW/test2/testinfo.dat deleted file mode 100644 index 72500111a..000000000 --- a/src/pal/tests/palsuite/file_io/GetTempFileNameW/test2/testinfo.dat +++ /dev/null @@ -1,15 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = GetTempFileNameW -Name = Test for GetTempFileNameW (test 2) -Type = DEFAULT -EXE1 = gettempfilenamew -Description -= This test attempts to create over 65000 files and will -= have to be run manually because it will take longer than -= the maximum 60 seconds allowed per test - diff --git a/src/pal/tests/palsuite/file_io/GetTempFileNameW/test3/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetTempFileNameW/test3/CMakeLists.txt deleted file mode 100644 index 50794c3e3..000000000 --- a/src/pal/tests/palsuite/file_io/GetTempFileNameW/test3/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - gettempfilenamew.cpp -) - -add_executable(paltest_gettempfilenamew_test3 - ${SOURCES} -) - -add_dependencies(paltest_gettempfilenamew_test3 coreclrpal) - -target_link_libraries(paltest_gettempfilenamew_test3 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/GetTempFileNameW/test3/gettempfilenamew.cpp b/src/pal/tests/palsuite/file_io/GetTempFileNameW/test3/gettempfilenamew.cpp deleted file mode 100644 index 96d8e6641..000000000 --- a/src/pal/tests/palsuite/file_io/GetTempFileNameW/test3/gettempfilenamew.cpp +++ /dev/null @@ -1,161 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: GetTempFileNameW.c (test 3) -** -** Purpose: Tests the PAL implementation of the GetTempFileNameW function. -** Checks the file attributes and ensures that getting a file name, -** deleting the file and getting another doesn't produce the same -** as the just deleted file. Also checks the file size is 0. -** -** Depends on: -** GetFileAttributesW -** DeleteFileW -** CreateFileW -** GetFileSize -** CloseHandle -** -** -**===================================================================*/ - -#include - - - -int __cdecl main(int argc, char *argv[]) -{ - const UINT uUnique = 0; - UINT uiError; - WCHAR szwReturnedName[MAX_LONGPATH]; - WCHAR szwReturnedName_02[MAX_LONGPATH]; - DWORD dwFileSize = 0; - HANDLE hFile; - const WCHAR szwDot[] = {'.','\0'}; - const WCHAR szwPre[] = {'c','\0'}; - - if (0 != PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - /* valid path with null prefix */ - uiError = GetTempFileNameW(szwDot, szwPre, uUnique, szwReturnedName); - if (uiError == 0) - { - Fail("GetTempFileNameW: ERROR -> Call failed with a valid path " - "with the error code: %u.\n", - GetLastError()); - } - - /* verify temp file was created */ - if (GetFileAttributesW(szwReturnedName) == -1) - { - Fail("GetTempFileNameW: ERROR -> GetFileAttributes failed on the " - "returned temp file \"%S\" with error code: %u.\n", - szwReturnedName, - GetLastError()); - } - - /* - ** verify that the file size is 0 bytes - */ - - hFile = CreateFileW(szwReturnedName, - GENERIC_READ, - FILE_SHARE_READ, - NULL, - OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL, - NULL); - if (hFile == INVALID_HANDLE_VALUE) - { - Trace("GetTempFileNameW: ERROR -> CreateFileW failed to open" - " the created temp file with error code: %u.\n", - GetLastError()); - if (!DeleteFileW(szwReturnedName)) - { - Trace("GetTempFileNameW: ERROR -> DeleteFileW failed to delete" - " the created temp file with error code: %u.\n", - GetLastError()); - } - Fail(""); - } - - if ((dwFileSize = GetFileSize(hFile, NULL)) != (DWORD)0) - { - Trace("GetTempFileNameW: ERROR -> GetFileSize returned %u whereas" - "it should have returned 0.\n", - dwFileSize); - if (!CloseHandle(hFile)) - { - Trace("GetTempFileNameW: ERROR -> CloseHandle was unable to close the " - "opened file. GetLastError returned %u.\n", - GetLastError()); - } - if (!DeleteFileW(szwReturnedName)) - { - Trace("GetTempFileNameW: ERROR -> DeleteFileW failed to delete" - " the created temp file with error code: %u.\n", - GetLastError()); - } - Fail(""); - } - - if (!CloseHandle(hFile)) - { - Fail("GetTempFileNameW: ERROR -> CloseHandle was unable to close the " - "opened file. GetLastError returned %u.\n", - GetLastError()); - } - - - /* delete the file to see if we get the same name next time around */ - if (DeleteFileW(szwReturnedName) != TRUE) - { - Fail("GetTempFileNameW: ERROR -> DeleteFileW failed to delete" - " the created temp file with error code: %u.\n", - GetLastError()); - } - - /* get another and make sure it's not the same as the last */ - uiError = GetTempFileNameW(szwDot, szwPre, uUnique, szwReturnedName_02); - if (uiError == 0) - { - Fail("GetTempFileNameW: ERROR -> Call failed with a valid path " - "with the error code: %u.\n", - GetLastError()); - } - - /* did we get different names? */ - if (wcsncmp(szwReturnedName, szwReturnedName_02, wcslen(szwReturnedName)) == 0) - { - Fail("GetTempFileNameW: ERROR -> The first call returned \"%S\". " - "The second call returned \"%S\" and the two should not be" - " the same.\n", - szwReturnedName, - szwReturnedName_02); - if (!DeleteFileW(szwReturnedName_02)) - { - Trace("GetTempFileNameW: ERROR -> DeleteFileW failed to delete" - " the created temp file with error code: %u.\n", - GetLastError()); - } - Fail(""); - } - - /* clean up */ - if (!DeleteFileW(szwReturnedName_02)) - { - Fail("GetTempFileNameW: ERROR -> DeleteFileW failed to delete" - " the created temp file with error code: %u.\n", - GetLastError()); - } - - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/file_io/GetTempFileNameW/test3/testinfo.dat b/src/pal/tests/palsuite/file_io/GetTempFileNameW/test3/testinfo.dat deleted file mode 100644 index dd482dbde..000000000 --- a/src/pal/tests/palsuite/file_io/GetTempFileNameW/test3/testinfo.dat +++ /dev/null @@ -1,15 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = GetTempFileNameW -Name = Test for GetTempFileNameW (test 3) -Type = DEFAULT -EXE1 = gettempfilenamew -Description -= Tests the PAL implementation of the GetTempFileNameW function. -= Checks the file attributes and ensures that getting a file name, -= deleting the file and getting another doesn't produce the same -= as the just deleted file. Also checks the file size is 0. diff --git a/src/pal/tests/palsuite/file_io/GetTempPathW/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetTempPathW/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/file_io/GetTempPathW/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/file_io/GetTempPathW/test1/CMakeLists.txt b/src/pal/tests/palsuite/file_io/GetTempPathW/test1/CMakeLists.txt deleted file mode 100644 index 093c8803d..000000000 --- a/src/pal/tests/palsuite/file_io/GetTempPathW/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - GetTempPathW.cpp -) - -add_executable(paltest_gettemppathw_test1 - ${SOURCES} -) - -add_dependencies(paltest_gettemppathw_test1 coreclrpal) - -target_link_libraries(paltest_gettemppathw_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/GetTempPathW/test1/GetTempPathW.cpp b/src/pal/tests/palsuite/file_io/GetTempPathW/test1/GetTempPathW.cpp deleted file mode 100644 index bf997def7..000000000 --- a/src/pal/tests/palsuite/file_io/GetTempPathW/test1/GetTempPathW.cpp +++ /dev/null @@ -1,103 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: GetTempPathW.c (test 1) -** -** Purpose: Tests the PAL implementation of the GetTempPathW function. -** -** -**===================================================================*/ - -#include - -static void SetTmpDir(const WCHAR path[]) -{ - DWORD result = SetEnvironmentVariableW(W("TMPDIR"), path); - if (!result) - { - Fail("ERROR -> SetEnvironmentVariableW failed with result %d and error code %d.\n", - result, GetLastError()); - } -} - -static void SetAndCompare(const WCHAR tmpDirPath[], const WCHAR expected[]) -{ - DWORD dwBufferLength = _MAX_DIR; - WCHAR path[dwBufferLength]; - - SetTmpDir(tmpDirPath); - - DWORD dwResultLen = GetTempPathW(dwBufferLength, path); - if (dwResultLen <= 0) - { - Fail("ERROR: GetTempPathW returned %d with error code %d.\n", dwResultLen, GetLastError()); - } - if (dwResultLen >= dwBufferLength) - { - Fail("ERROR: Buffer of length %d passed to GetTempPathA was too small to hold %d chars..\n", dwBufferLength, dwResultLen); - } - if (wcscmp(expected, path) != 0) - { - Fail("ERROR: GetTempPathW expected to get '%S' but instead got '%S'.\n", expected, path); - } - if (expected[dwResultLen - 1] != '/') - { - Fail("ERROR: GetTempPathW returned '%S', which should have ended in '/'.\n", path); - } -} - -static void SetAndCheckLength(const WCHAR tmpDirPath [], int bufferLength, int expectedResultLength) -{ - WCHAR path[bufferLength]; - - SetTmpDir(tmpDirPath); - DWORD dwResultLen = GetTempPathW(bufferLength, path); - - if (dwResultLen != expectedResultLength) - { - Fail("GetTempPathW(%d, %S) expected to return %d but returned %d.\n", - bufferLength, tmpDirPath?tmpDirPath:W("NULL"), expectedResultLength, dwResultLen); - } -} - -int __cdecl main(int argc, char *argv[]) -{ - if (0 != PAL_Initialize(argc, argv)) - { - return FAIL; - } - - SetAndCompare(W("/tmp"), W("/tmp/")); - SetAndCompare(W("/tmp/"), W("/tmp/")); - SetAndCompare(W(""), W("/tmp/")); - SetAndCompare(NULL, W("/tmp/")); - SetAndCompare(W("/"), W("/")); - SetAndCompare(W("/var/tmp"), W("/var/tmp/")); - SetAndCompare(W("/var/tmp/"), W("/var/tmp/")); - SetAndCompare(W("~"), W("~/")); - SetAndCompare(W("~/"), W("~/")); - SetAndCompare(W(".tmp"), W(".tmp/")); - SetAndCompare(W("./tmp"), W("./tmp/")); - SetAndCompare(W("/home/someuser/sometempdir"), W("/home/someuser/sometempdir/")); - SetAndCompare(NULL, W("/tmp/")); - - DWORD dwResultLen = GetTempPathA(0, NULL); - if (dwResultLen != 0 || GetLastError() != ERROR_INVALID_PARAMETER) - { - Fail("GetTempPathW(NULL, ...) returned %d with error code %d but " - "should have failed with ERROR_INVALID_PARAMETER (%d).\n", - dwResultLen, GetLastError(), ERROR_INVALID_PARAMETER); - } - - SetAndCheckLength(W("abc/"), 5, 4); - SetAndCheckLength(W("abcd"), 5, 6); - SetAndCheckLength(W("abcde"), 5, 7); - SetAndCheckLength(W("abcdef/"), 5, 9); - SetAndCheckLength(NULL, 5, 6); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/file_io/GetTempPathW/test1/testinfo.dat b/src/pal/tests/palsuite/file_io/GetTempPathW/test1/testinfo.dat deleted file mode 100644 index 84dc33832..000000000 --- a/src/pal/tests/palsuite/file_io/GetTempPathW/test1/testinfo.dat +++ /dev/null @@ -1,15 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = GetTempPathW -Name = Test for GetTempPathW (test 1) -Type = DEFAULT -EXE1 = gettemppathw -Description -= Calls GetTempPathW and verifies by passing the returned -= value to CreateDirectoryW. If the returned path exists, -= CreateDirectoryW will fail. - diff --git a/src/pal/tests/palsuite/file_io/MoveFileExA/CMakeLists.txt b/src/pal/tests/palsuite/file_io/MoveFileExA/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/file_io/MoveFileExA/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/file_io/MoveFileExA/test1/CMakeLists.txt b/src/pal/tests/palsuite/file_io/MoveFileExA/test1/CMakeLists.txt deleted file mode 100644 index ac5ea7463..000000000 --- a/src/pal/tests/palsuite/file_io/MoveFileExA/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - MoveFileExA.cpp -) - -add_executable(paltest_movefileexa_test1 - ${SOURCES} -) - -add_dependencies(paltest_movefileexa_test1 coreclrpal) - -target_link_libraries(paltest_movefileexa_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/MoveFileExA/test1/ExpectedResults.txt b/src/pal/tests/palsuite/file_io/MoveFileExA/test1/ExpectedResults.txt deleted file mode 100644 index 684b8a536..000000000 --- a/src/pal/tests/palsuite/file_io/MoveFileExA/test1/ExpectedResults.txt +++ /dev/null @@ -1 +0,0 @@ -01110011000000000111001100000000 diff --git a/src/pal/tests/palsuite/file_io/MoveFileExA/test1/MoveFileExA.cpp b/src/pal/tests/palsuite/file_io/MoveFileExA/test1/MoveFileExA.cpp deleted file mode 100644 index 0bce2b08d..000000000 --- a/src/pal/tests/palsuite/file_io/MoveFileExA/test1/MoveFileExA.cpp +++ /dev/null @@ -1,360 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: MoveFileExA.c -** -** Purpose: Tests the PAL implementation of the MoveFileExA function. -** -** -**===================================================================*/ - -#include - - -LPSTR lpSource[4] = { - "src_existing.tmp", - "src_non-existant.tmp", - "src_dir_existing", - "src_dir_non-existant" - }; -LPSTR lpDestination[4]={ - "dst_existing.tmp", - "dst_non-existant.tmp", - "dst_dir_existing", - "dst_dir_non-existant" - }; - -LPSTR lpFiles[14] ={ - "src_dir_existing\\test01.tmp", - "src_dir_existing\\test02.tmp", - "dst_dir_existing\\test01.tmp", - "dst_dir_existing\\test02.tmp", - "src_dir_non-existant\\test01.tmp", - "src_dir_non-existant\\test02.tmp", - "dst_existing.tmp\\test01.tmp", - "dst_existing.tmp\\test02.tmp", - "dst_non-existant.tmp\\test01.tmp", - "dst_non-existant.tmp\\test02.tmp", - "dst_dir_existing\\test01.tmp", - "dst_dir_existing\\test02.tmp", - "dst_dir_non-existant\\test01.tmp", - "dst_dir_non-existant\\test02.tmp" - }; - -DWORD dwFlag[2] = {MOVEFILE_COPY_ALLOWED, MOVEFILE_REPLACE_EXISTING}; - - - - -int createExisting(void) -{ - HANDLE tempFile = NULL; - HANDLE tempFile2 = NULL; - - /* create the src_existing file and dst_existing file */ - tempFile = CreateFileA(lpSource[0], GENERIC_WRITE, 0, 0, CREATE_ALWAYS, - FILE_ATTRIBUTE_NORMAL, 0); - tempFile2 = CreateFileA(lpDestination[0], GENERIC_WRITE, 0, 0, CREATE_ALWAYS, - FILE_ATTRIBUTE_NORMAL, 0); - CloseHandle(tempFile2); - CloseHandle(tempFile); - - if ((tempFile == NULL) || (tempFile2 == NULL)) - { - Trace("ERROR[%ul]: couldn't create %S or %S\n", GetLastError(), lpSource[0], - lpDestination[0]); - return FAIL; - } - - /* create the src_dir_existing and dst_dir_existing directory and files */ - CreateDirectoryA(lpSource[2], NULL); - - tempFile = CreateFileA(lpFiles[0], GENERIC_WRITE, 0, 0, CREATE_ALWAYS, - FILE_ATTRIBUTE_NORMAL, 0); - tempFile2 = CreateFileA(lpFiles[1], GENERIC_WRITE, 0, 0, CREATE_ALWAYS, - FILE_ATTRIBUTE_NORMAL, 0); - CloseHandle(tempFile2); - CloseHandle(tempFile); - - if ((tempFile == NULL) || (tempFile2 == NULL)) - { - Trace("ERROR[%ul]: couldn't create src_dir_existing\\test01.tmp\n", GetLastError()); - return FAIL; - } - - CreateDirectoryA(lpDestination[2], NULL); - tempFile = CreateFileA(lpFiles[2], GENERIC_WRITE, 0, 0, CREATE_ALWAYS, - FILE_ATTRIBUTE_NORMAL, 0); - tempFile2 = CreateFileA(lpFiles[3], GENERIC_WRITE, 0, 0, CREATE_ALWAYS, - FILE_ATTRIBUTE_NORMAL, 0); - CloseHandle(tempFile2); - CloseHandle(tempFile); - - if ((tempFile == NULL) || (tempFile2 == NULL)) - { - Trace("ERROR[%ul]: couldn't create dst_dir_existing\\test01.tmp\n" , GetLastError()); - return FAIL; - } - return PASS; - -} - -void removeDirectoryHelper(LPSTR dir, int location) -{ - DWORD dwAtt = GetFileAttributesA(dir); - - if (( dwAtt != INVALID_FILE_ATTRIBUTES ) && ( dwAtt & FILE_ATTRIBUTE_DIRECTORY) ) - { - if(!RemoveDirectoryA(dir)) - { - Fail("ERROR: Failed to remove Directory [%s], Error Code [%d], location [%d]\n", dir, GetLastError(), location); - } - } -} - -void removeFileHelper(LPSTR pfile, int location) -{ - FILE *fp; - fp = fopen( pfile, "r"); - - if (fp != NULL) - { - if(fclose(fp)) - { - Fail("ERROR: Failed to close the file [%s], Error Code [%d], location [%d]\n", pfile, GetLastError(), location); - } - - if(!DeleteFileA(pfile)) - { - Fail("ERROR: Failed to delete file [%s], Error Code [%d], location [%d]\n", pfile, GetLastError(), location); - } - } - -} - -void removeAll(void) -{ - DWORD dwAtt; - /* get rid of destination dirs and files */ - removeFileHelper(lpSource[0], 11); - removeFileHelper(lpSource[1], 12); - removeFileHelper(lpFiles[0], 13); - removeFileHelper(lpFiles[1], 14); - - removeDirectoryHelper(lpSource[2], 101); - removeFileHelper(lpFiles[4], 15); - removeFileHelper(lpFiles[5], 16); - removeDirectoryHelper(lpSource[3], 102); - - /* get rid of destination dirs and files */ - dwAtt = GetFileAttributesA(lpDestination[0]); - if (( dwAtt != INVALID_FILE_ATTRIBUTES ) && ( dwAtt & FILE_ATTRIBUTE_DIRECTORY) ) - { - removeFileHelper(lpFiles[6], 18); - removeFileHelper(lpFiles[7], 19); - removeDirectoryHelper(lpDestination[0], 103); - } - else - { - removeFileHelper(lpDestination[0], 17); - } - - dwAtt = GetFileAttributesA(lpDestination[1]); - if (( dwAtt != INVALID_FILE_ATTRIBUTES ) && ( dwAtt & FILE_ATTRIBUTE_DIRECTORY) ) - { - removeFileHelper(lpFiles[8], 21); - removeFileHelper(lpFiles[9], 22); - removeDirectoryHelper(lpDestination[1], 104); - } - else - { - removeFileHelper(lpDestination[1], 19); - } - - dwAtt = GetFileAttributesA(lpDestination[2]); - if (( dwAtt != INVALID_FILE_ATTRIBUTES ) && ( dwAtt & FILE_ATTRIBUTE_DIRECTORY) ) - { - removeFileHelper(lpFiles[10], 24); - removeFileHelper(lpFiles[11], 25); - removeDirectoryHelper(lpDestination[2], 105); - } - else - { - removeFileHelper(lpDestination[2], 23); - } - - dwAtt = GetFileAttributesA(lpDestination[3]); - if (( dwAtt != INVALID_FILE_ATTRIBUTES ) && ( dwAtt & FILE_ATTRIBUTE_DIRECTORY) ) - { - removeFileHelper(lpFiles[12], 26); - removeFileHelper(lpFiles[13], 27); - removeDirectoryHelper(lpDestination[3], 106); - } - else - { - removeFileHelper(lpDestination[3], 107); - } - -} - -int __cdecl main(int argc, char *argv[]) -{ - BOOL bRc = TRUE; - char results[40]; - FILE* resultsFile = NULL; - int i, j, k, nCounter = 0; - int res = FAIL; - char tempSource[] = {'t','e','m','p','k','.','t','m','p','\0'}; - char tempDest[] = {'t','e','m','p','2','.','t','m','p','\0'}; - HANDLE hFile; - DWORD result; - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - /* read in the expected results to compare with actual results */ - memset (results, 0, 34); - resultsFile = fopen("expectedresults.txt", "r"); - if (resultsFile == NULL) - { - Trace("MoveFileExA ERROR: Unable to open \"expectedresults.txt\"\n"); - goto EXIT; - } - - fgets(results, 34, resultsFile); - fclose(resultsFile); - - nCounter = 0; - - - /* clean the slate */ - removeAll(); - if (createExisting() != PASS) - { - goto EXIT; - } - - /* lpSource loop */ - for (i = 0; i < 4; i++) - { - /* lpDestination loop */ - for (j = 0; j < 4; j++) - { - /* dwFlag loop */ - for (k = 0; k < 2; k++) - { - - /* move the file to the new location */ - bRc = MoveFileExA(lpSource[i], lpDestination[j], dwFlag[k]); - - if (!( - ((bRc == TRUE) && (results[nCounter] == '1')) - || - ((bRc == FALSE ) && (results[nCounter] == '0')) ) - ) - { - Trace("MoveFileExA(%s, %s, %s): Values of i[%d], j[%d], k [%d] and results[%d]=%c LastError[%d]Flag[%d]FAILED\n", - lpSource[i], lpDestination[j], - k == 1 ? - "MOVEFILE_REPLACE_EXISTING":"MOVEFILE_COPY_ALLOWED", i, j, k, nCounter, results[nCounter], GetLastError(), bRc); - goto EXIT; - } - - /* undo the last move */ - removeAll(); - if (createExisting() != PASS) - { - goto EXIT; - } - nCounter++; - } - } - } - - /* create the temp source file */ - hFile = CreateFileA(tempSource, GENERIC_WRITE, 0, 0, CREATE_ALWAYS, - FILE_ATTRIBUTE_NORMAL, 0); - - if( hFile == INVALID_HANDLE_VALUE ) - { - Trace("MoveFileExA: CreateFile failed to " - "create the file correctly.\n"); - goto EXIT; - } - - bRc = CloseHandle(hFile); - if(!bRc) - { - Trace("MoveFileExA: CloseHandle failed to close the " - "handle correctly. yo %u\n",GetLastError()); - goto EXIT; - } - - /* set the file attributes to be readonly */ - bRc = SetFileAttributesA(tempSource, FILE_ATTRIBUTE_READONLY); - if(!bRc) - { - Trace("MoveFileExA: SetFileAttributes failed to set file " - "attributes correctly. ERROR:%u\n",GetLastError()); - goto EXIT; - } - - /* move the file to the new location */ - bRc = MoveFileExA(tempSource, tempDest, MOVEFILE_COPY_ALLOWED ); - if(!bRc) - { - Trace("MoveFileExA(%S, %S, %s): GetFileAttributes " - "failed to get the file's attributes.\n", - tempSource, tempDest, "MOVEFILE_COPY_ALLOWED"); - goto EXIT; - } - - /* check that the newly moved file has the same file attributes - as the original */ - result = GetFileAttributesA(tempDest); - if(result == 0) - { - Trace("MoveFileExA: GetFileAttributes failed to get " - "the file's attributes.\n"); - goto EXIT; - } - - if((result & FILE_ATTRIBUTE_READONLY) != FILE_ATTRIBUTE_READONLY) - { - Trace("MoveFileExA: GetFileAttributes failed to get " - "the correct file attributes.\n"); - goto EXIT; - } - - /* set the file attributes back to normal, to be deleted */ - bRc = SetFileAttributesA(tempDest, FILE_ATTRIBUTE_NORMAL); - if(!bRc) - { - Trace("MoveFileExA: SetFileAttributes " - "failed to set file attributes correctly.\n"); - goto EXIT; - } - - /* delete the newly moved file */ - bRc = DeleteFileA(tempDest); - if(!bRc) - { - Trace("MoveFileExA: DeleteFileA failed to delete the" - "file correctly.\n"); - goto EXIT; - } - - res = PASS; - -EXIT: - removeAll(); - - PAL_TerminateEx(res); - return res; -} - diff --git a/src/pal/tests/palsuite/file_io/MoveFileExA/test1/testinfo.dat b/src/pal/tests/palsuite/file_io/MoveFileExA/test1/testinfo.dat deleted file mode 100644 index d8d19af88..000000000 --- a/src/pal/tests/palsuite/file_io/MoveFileExA/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = MoveFileExA -Name = Test for MoveFileExA (test 1) -Type = DEFAULT -EXE1 = movefileexa -Description -= Creates a number of files/directories and attempts to move them. - diff --git a/src/pal/tests/palsuite/file_io/MoveFileExW/CMakeLists.txt b/src/pal/tests/palsuite/file_io/MoveFileExW/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/file_io/MoveFileExW/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/file_io/MoveFileExW/test1/CMakeLists.txt b/src/pal/tests/palsuite/file_io/MoveFileExW/test1/CMakeLists.txt deleted file mode 100644 index bbe3d5aa3..000000000 --- a/src/pal/tests/palsuite/file_io/MoveFileExW/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - MoveFileExW.cpp -) - -add_executable(paltest_movefileexw_test1 - ${SOURCES} -) - -add_dependencies(paltest_movefileexw_test1 coreclrpal) - -target_link_libraries(paltest_movefileexw_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/MoveFileExW/test1/ExpectedResults.txt b/src/pal/tests/palsuite/file_io/MoveFileExW/test1/ExpectedResults.txt deleted file mode 100644 index 684b8a536..000000000 --- a/src/pal/tests/palsuite/file_io/MoveFileExW/test1/ExpectedResults.txt +++ /dev/null @@ -1 +0,0 @@ -01110011000000000111001100000000 diff --git a/src/pal/tests/palsuite/file_io/MoveFileExW/test1/MoveFileExW.cpp b/src/pal/tests/palsuite/file_io/MoveFileExW/test1/MoveFileExW.cpp deleted file mode 100644 index 4f5b72dcf..000000000 --- a/src/pal/tests/palsuite/file_io/MoveFileExW/test1/MoveFileExW.cpp +++ /dev/null @@ -1,431 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: MoveFileExW.c -** -** Purpose: Tests the PAL implementation of the MoveFileExW function. -** -** -**===================================================================*/ - -#include - - -LPWSTR lpSource[4]; -LPWSTR lpDestination[4]; -LPWSTR lpFiles[14]; - -DWORD dwFlag[2] = {MOVEFILE_COPY_ALLOWED, MOVEFILE_REPLACE_EXISTING}; - - - -int createExisting(void) -{ - HANDLE tempFile = NULL; - HANDLE tempFile2 = NULL; - - /* create the src_existing file and dst_existing file */ - tempFile = CreateFileW(lpSource[0], GENERIC_WRITE, 0, 0, CREATE_ALWAYS, - FILE_ATTRIBUTE_NORMAL, 0); - tempFile2 = CreateFileW(lpDestination[0], GENERIC_WRITE, 0, 0, CREATE_ALWAYS, - FILE_ATTRIBUTE_NORMAL, 0); - CloseHandle(tempFile2); - CloseHandle(tempFile); - - if ((tempFile == NULL) || (tempFile2 == NULL)) - { - Trace("ERROR: couldn't create %S or %S\n", lpSource[0], - lpDestination[0]); - return FAIL; - } - - /* create the src_dir_existing and dst_dir_existing directory and files */ - CreateDirectoryW(lpSource[2], NULL); - - tempFile = CreateFileW(lpFiles[0], GENERIC_WRITE, 0, 0, CREATE_ALWAYS, - FILE_ATTRIBUTE_NORMAL, 0); - tempFile2 = CreateFileW(lpFiles[1], GENERIC_WRITE, 0, 0, CREATE_ALWAYS, - FILE_ATTRIBUTE_NORMAL, 0); - CloseHandle(tempFile2); - CloseHandle(tempFile); - - if ((tempFile == NULL) || (tempFile2 == NULL)) - { - Trace("ERROR: couldn't create src_dir_existing\\test01.tmp\n"); - return FAIL; - } - - CreateDirectoryW(lpDestination[2], NULL); - tempFile = CreateFileW(lpFiles[2], GENERIC_WRITE, 0, 0, CREATE_ALWAYS, - FILE_ATTRIBUTE_NORMAL, 0); - tempFile2 = CreateFileW(lpFiles[3], GENERIC_WRITE, 0, 0, CREATE_ALWAYS, - FILE_ATTRIBUTE_NORMAL, 0); - CloseHandle(tempFile2); - CloseHandle(tempFile); - - if ((tempFile == NULL) || (tempFile2 == NULL)) - { - Trace("ERROR: couldn't create dst_dir_existing\\test01.tmp\n"); - return FAIL; - } - return PASS; -} - -void removeDirectoryHelper(LPWSTR dir, int location) -{ - DWORD dwAtt = GetFileAttributesW(dir); -// Trace(" Value of location[%d], and directorye [%S]\n", location, dir); - - if (( dwAtt != INVALID_FILE_ATTRIBUTES ) && ( dwAtt & FILE_ATTRIBUTE_DIRECTORY) ) - { - if(!RemoveDirectoryW(dir)) - { - Fail("ERROR: Failed to remove Directory [%S], Error Code [%d], location [%d]\n", dir, GetLastError(), location); - } - } -} - -void removeFileHelper(LPWSTR wfile, int location) -{ - FILE *fp; - char * pfile = convertC(wfile); - -// Trace(" Value of location[%d], and file [%s]\n", location, pfile); - fp = fopen( pfile, "r"); - - if (fp != NULL) - { - if(fclose(fp)) - { - Fail("ERROR: Failed to close the file [%S], Error Code [%d], location [%d]\n", wfile, GetLastError(), location); - } - - if(!DeleteFileW(wfile)) - { - Fail("ERROR: Failed to delete file [%S], Error Code [%d], location [%d]\n", wfile, GetLastError(), location); - } - else - { - // Trace("Success: deleted file [%S], Error Code [%d], location [%d]\n", wfile, GetLastError(), location); - } - } - - free(pfile); -} - -void removeAll(void) -{ - DWORD dwAtt; - /* get rid of destination dirs and files */ - removeFileHelper(lpSource[0], 11); -// lpSource[0] = convert("src_existing.tmp"); - - removeFileHelper(lpSource[1], 12); - //lpSource[1] = convert("src_non-existant.tmp"); - - removeFileHelper(lpFiles[0], 13); -// lpFiles[0] = convert("src_dir_existing\\test01.tmp"); - - removeFileHelper(lpFiles[1], 14); -// lpFiles[1] = convert("src_dir_existing\\test02.tmp"); - - removeDirectoryHelper(lpSource[2], 101); -// lpSource[2] = convert("src_dir_existing"); - - removeFileHelper(lpFiles[4], 15); -// lpFiles[4] = convert("src_dir_non-existant\\test01.tmp"); - - removeFileHelper(lpFiles[5], 16); -// lpFiles[5] = convert("src_dir_non-existant\\test02.tmp"); - - removeDirectoryHelper(lpSource[3], 102); -// lpSource[3] = convert("src_dir_non-existant"); - - /* get rid of destination dirs and files */ - dwAtt = GetFileAttributesW(lpDestination[0]); - if (( dwAtt != INVALID_FILE_ATTRIBUTES ) && ( dwAtt & FILE_ATTRIBUTE_DIRECTORY) ) - { - removeFileHelper(lpFiles[6], 18); - // lpFiles[6] = convert("dst_existing.tmp\\test01.tmp"); - removeFileHelper(lpFiles[7], 19); - // lpFiles[7] = convert("dst_existing.tmp\\test02.tmp"); - removeDirectoryHelper(lpDestination[0], 103); - // lpDestination[0] = convert("dst_existing.tmp"); - - } - else - { - removeFileHelper(lpDestination[0], 17); - // lpDestination[0] = convert("dst_existing.tmp"); - } - - dwAtt = GetFileAttributesW(lpDestination[1]); - if (( dwAtt != INVALID_FILE_ATTRIBUTES ) && ( dwAtt & FILE_ATTRIBUTE_DIRECTORY) ) - { - removeFileHelper(lpFiles[8], 21); - // lpFiles[8] = convert("dst_non-existant.tmp\\test01.tmp"); - removeFileHelper(lpFiles[9], 22); - // lpFiles[9] = convert("dst_non-existant.tmp\\test02.tmp"); - removeDirectoryHelper(lpDestination[1], 104); - // lpDestination[1] = convert("dst_non-existant.tmp"); - - } - else - { - removeFileHelper(lpDestination[1], 19); - //lpDestination[1] = convert("dst_non-existant.tmp"); - } - - dwAtt = GetFileAttributesW(lpDestination[2]); - if (( dwAtt != INVALID_FILE_ATTRIBUTES ) && ( dwAtt & FILE_ATTRIBUTE_DIRECTORY) ) - { - removeFileHelper(lpFiles[10], 24); - // lpFiles[10] = convert("dst_dir_existing\\test01.tmp"); - removeFileHelper(lpFiles[11], 25); - // lpFiles[11] = convert("dst_dir_existing\\test02.tmp"); - removeDirectoryHelper(lpDestination[2], 105); - // lpDestination[2] = convert("dst_dir_existing"); - - } - else - { - removeFileHelper(lpDestination[2], 23); - // lpDestination[2] = convert("dst_dir_existing"); - - } - - dwAtt = GetFileAttributesW(lpDestination[3]); - if (( dwAtt != INVALID_FILE_ATTRIBUTES ) && ( dwAtt & FILE_ATTRIBUTE_DIRECTORY) ) - { - removeFileHelper(lpFiles[12], 26); - // lpFiles[12] = convert("dst_dir_non-existant\\test01.tmp"); - removeFileHelper(lpFiles[13], 27); - // lpFiles[13] = convert("dst_dir_non-existant\\test02.tmp"); - removeDirectoryHelper(lpDestination[3], 106); - // lpDestination[3] = convert("dst_dir_non-existant"); - - } - else - { - removeFileHelper(lpDestination[3], 107); - // lpDestination[3] = convert("dst_dir_non-existant"); - - } - -} - -int __cdecl main(int argc, char *argv[]) -{ - BOOL bRc = TRUE; - char results[40]; - FILE* resultsFile = NULL; - int i, j, k, nCounter = 0; - int res = FAIL; - WCHAR tempSource[] = {'t','e','m','p','k','.','t','m','p','\0'}; - WCHAR tempDest[] = {'t','e','m','p','2','.','t','m','p','\0'}; - HANDLE hFile; - DWORD result; - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - lpSource[0] = convert("src_existing.tmp"); - lpSource[1] = convert("src_non-existant.tmp"); - lpSource[2] = convert("src_dir_existing"); - lpSource[3] = convert("src_dir_non-existant"); - - lpDestination[0] = convert("dst_existing.tmp"); - lpDestination[1] = convert("dst_non-existant.tmp"); - lpDestination[2] = convert("dst_dir_existing"); - lpDestination[3] = convert("dst_dir_non-existant"); - - lpFiles[0] = convert("src_dir_existing\\test01.tmp"); - lpFiles[1] = convert("src_dir_existing\\test02.tmp"); - lpFiles[2] = convert("dst_dir_existing\\test01.tmp"); - lpFiles[3] = convert("dst_dir_existing\\test02.tmp"); - lpFiles[4] = convert("src_dir_non-existant\\test01.tmp"); - lpFiles[5] = convert("src_dir_non-existant\\test02.tmp"); - - lpFiles[6] = convert("dst_existing.tmp\\test01.tmp"); - lpFiles[7] = convert("dst_existing.tmp\\test02.tmp"); - - lpFiles[8] = convert("dst_non-existant.tmp\\test01.tmp"); - lpFiles[9] = convert("dst_non-existant.tmp\\test02.tmp"); - - lpFiles[10] = convert("dst_dir_existing\\test01.tmp"); - lpFiles[11] = convert("dst_dir_existing\\test02.tmp"); - - lpFiles[12] = convert("dst_dir_non-existant\\test01.tmp"); - lpFiles[13] = convert("dst_dir_non-existant\\test02.tmp"); - - /* read in the expected results to compare with actual results */ - memset (results, 0, 34); - resultsFile = fopen("expectedresults.txt", "r"); - if (resultsFile == NULL) - { - Trace("MoveFileExW ERROR: Unable to open \"expectedresults.txt\"\n"); - goto EXIT; - } - - fgets(results, 34, resultsFile); - fclose(resultsFile); - -// Trace("Value of results[%]=%s\n", i, results); - for( i = 0; i < 32; i++) - { - Trace("Value of results[%d]=%c\n", i, results[i]); - } - nCounter = 0; - - - /* clean the slate */ - removeAll(); - if (createExisting() != PASS) - { - goto EXIT; - } - - /* lpSource loop */ - for (i = 0; i < 4; i++) - { - /* lpDestination loop */ - for (j = 0; j < 4; j++) - { - /* dwFlag loop */ - for (k = 0; k < 2; k++) - { - - //if(nCounter == 22) - //{ - //exit(1); - //} - /* move the file to the new location */ - bRc = MoveFileExW(lpSource[i], lpDestination[j], dwFlag[k]); - - if (!( - ((bRc == TRUE) && (results[nCounter] == '1')) - || - ((bRc == FALSE ) && (results[nCounter] == '0')) ) - ) - { - Trace("MoveFileExW(%S, %S, %s): Values of i[%d], j[%d], k [%d] and results[%d]=%c LastError[%d]Flag[%d]FAILED\n", - lpSource[i], lpDestination[j], - k == 1 ? - "MOVEFILE_REPLACE_EXISTING":"MOVEFILE_COPY_ALLOWED", i, j, k, nCounter, results[nCounter], GetLastError(), bRc); - goto EXIT; - } - - //Trace("MoveFileExW(%S, %S, %s): Values of i[%d], j[%d], k [%d] and results[%d]=%c \n", - // lpSource[i], lpDestination[j], - // k == 1 ? - // "MOVEFILE_REPLACE_EXISTING":"MOVEFILE_COPY_ALLOWED", i, j, k, nCounter, results[nCounter]); - - - /* undo the last move */ - removeAll(); - if (createExisting() != PASS) - { - goto EXIT; - } - //Trace("Counter [%d] over \n", nCounter); - nCounter++; - } - } - } - - /* create the temp source file */ - hFile = CreateFileW(tempSource, GENERIC_WRITE, 0, 0, CREATE_ALWAYS, - FILE_ATTRIBUTE_NORMAL, 0); - - if( hFile == INVALID_HANDLE_VALUE ) - { - Trace("MoveFileExW: CreateFile failed to " - "create the file correctly.\n"); - goto EXIT; - } - - bRc = CloseHandle(hFile); - if(!bRc) - { - Trace("MoveFileExW: CloseHandle failed to close the " - "handle correctly. yo %u\n",GetLastError()); - goto EXIT; - } - - /* set the file attributes to be readonly */ - bRc = SetFileAttributesW(tempSource, FILE_ATTRIBUTE_READONLY); - if(!bRc) - { - Trace("MoveFileExW: SetFileAttributes failed to set file " - "attributes correctly. ERROR:%u\n",GetLastError()); - goto EXIT; - } - - /* move the file to the new location */ - bRc = MoveFileExW(tempSource, tempDest, MOVEFILE_COPY_ALLOWED ); - if(!bRc) - { - Trace("MoveFileExW(%S, %S, %s): GetFileAttributes " - "failed to get the file's attributes.\n", - tempSource, tempDest, "MOVEFILE_COPY_ALLOWED"); - goto EXIT; - } - - /* check that the newly moved file has the same file attributes - as the original */ - result = GetFileAttributesW(tempDest); - if(result == 0) - { - Trace("MoveFileExW: GetFileAttributes failed to get " - "the file's attributes.\n"); - goto EXIT; - } - - if((result & FILE_ATTRIBUTE_READONLY) != FILE_ATTRIBUTE_READONLY) - { - Trace("MoveFileExW: GetFileAttributes failed to get " - "the correct file attributes.\n"); - goto EXIT; - } - - /* set the file attributes back to normal, to be deleted */ - bRc = SetFileAttributesW(tempDest, FILE_ATTRIBUTE_NORMAL); - if(!bRc) - { - Trace("MoveFileExW: SetFileAttributes " - "failed to set file attributes correctly.\n"); - goto EXIT; - } - - /* delete the newly moved file */ - bRc = DeleteFileW(tempDest); - if(!bRc) - { - Trace("MoveFileExW: DeleteFileW failed to delete the" - "file correctly.\n"); - goto EXIT; - } - - res = PASS; - -EXIT: - removeAll(); - for (i=0; i<4; i++) - { - free(lpSource[i]); - free(lpDestination[i]); - } - for (i=0; i<14; i++) - { - free(lpFiles[i]); - } - - PAL_TerminateEx(res); - return res; -} - diff --git a/src/pal/tests/palsuite/file_io/MoveFileExW/test1/testinfo.dat b/src/pal/tests/palsuite/file_io/MoveFileExW/test1/testinfo.dat deleted file mode 100644 index 9b001b5c3..000000000 --- a/src/pal/tests/palsuite/file_io/MoveFileExW/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = MoveFileExW -Name = Test for MoveFileExW (test 1) -Type = DEFAULT -EXE1 = movefileexw -Description -= Creates a number of files/directories and attempts to move them. - diff --git a/src/pal/tests/palsuite/file_io/ReadFile/CMakeLists.txt b/src/pal/tests/palsuite/file_io/ReadFile/CMakeLists.txt deleted file mode 100644 index a3847f8ca..000000000 --- a/src/pal/tests/palsuite/file_io/ReadFile/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) -add_subdirectory(test3) -add_subdirectory(test4) - diff --git a/src/pal/tests/palsuite/file_io/ReadFile/test1/CMakeLists.txt b/src/pal/tests/palsuite/file_io/ReadFile/test1/CMakeLists.txt deleted file mode 100644 index 8fe1f1d2e..000000000 --- a/src/pal/tests/palsuite/file_io/ReadFile/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - ReadFile.cpp -) - -add_executable(paltest_readfile_test1 - ${SOURCES} -) - -add_dependencies(paltest_readfile_test1 coreclrpal) - -target_link_libraries(paltest_readfile_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/ReadFile/test1/NonReadableFile.txt b/src/pal/tests/palsuite/file_io/ReadFile/test1/NonReadableFile.txt deleted file mode 100644 index a8a940627..000000000 --- a/src/pal/tests/palsuite/file_io/ReadFile/test1/NonReadableFile.txt +++ /dev/null @@ -1 +0,0 @@ -this is a test \ No newline at end of file diff --git a/src/pal/tests/palsuite/file_io/ReadFile/test1/ReadFile.cpp b/src/pal/tests/palsuite/file_io/ReadFile/test1/ReadFile.cpp deleted file mode 100644 index a59e29212..000000000 --- a/src/pal/tests/palsuite/file_io/ReadFile/test1/ReadFile.cpp +++ /dev/null @@ -1,82 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: ReadFile.c (test 1) -** -** Purpose: Tests the PAL implementation of the ReadFile function. -** This test will attempt to read from a NULL handle and from -** a file without read permissions set. -** -** -**===================================================================*/ - -#include - - -int __cdecl main(int argc, char *argv[]) -{ - HANDLE hFile = NULL; - DWORD dwByteCount = 0; - DWORD dwBytesRead = 0; - BOOL bRc = FALSE; - char szBuffer[256]; - char* szNonReadableFile = {"nonreadablefile.txt"}; - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - memset(szBuffer, 0, 256); - - /* Read from a NULL handle - */ - - bRc = ReadFile(hFile, szBuffer, 20, &dwBytesRead, NULL); - - if (bRc == TRUE) - { - Fail("ReadFile: ERROR -> Able to read from a NULL handle\n"); - } - - - /* Read from a file without read permissions - */ - -#if WIN32 - -#else - /* attempt to read from the unreadable file - * open a file without read permissions - */ - hFile = CreateFile(szNonReadableFile, - GENERIC_WRITE, - FILE_SHARE_WRITE, - NULL, - OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL, - NULL); - - if(hFile == INVALID_HANDLE_VALUE) - { - dwByteCount = GetLastError(); - Fail("ReadFile: ERROR -> Unable to create file \"%s\".\n", - szNonReadableFile); - } - - bRc = ReadFile(hFile, szBuffer, 20, &dwBytesRead, NULL); - - if (bRc == TRUE) - { - Fail("ReadFile: ERROR -> Able to read from a file without read " - "permissions\n"); - } -#endif - - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/file_io/ReadFile/test1/testinfo.dat b/src/pal/tests/palsuite/file_io/ReadFile/test1/testinfo.dat deleted file mode 100644 index b0df11a3a..000000000 --- a/src/pal/tests/palsuite/file_io/ReadFile/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = ReadFile -Name = Positive Test for ReadFile -Type = DEFAULT -EXE1 = readfile -Description -=Attempt to read from a NULL handle and a file without read permissions - diff --git a/src/pal/tests/palsuite/file_io/ReadFile/test2/CMakeLists.txt b/src/pal/tests/palsuite/file_io/ReadFile/test2/CMakeLists.txt deleted file mode 100644 index 2113d6762..000000000 --- a/src/pal/tests/palsuite/file_io/ReadFile/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - ReadFile.cpp -) - -add_executable(paltest_readfile_test2 - ${SOURCES} -) - -add_dependencies(paltest_readfile_test2 coreclrpal) - -target_link_libraries(paltest_readfile_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/ReadFile/test2/ReadFile.cpp b/src/pal/tests/palsuite/file_io/ReadFile/test2/ReadFile.cpp deleted file mode 100644 index 789e00170..000000000 --- a/src/pal/tests/palsuite/file_io/ReadFile/test2/ReadFile.cpp +++ /dev/null @@ -1,194 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: ReadFile.c (test 2) -** -** Purpose: Tests the PAL implementation of the ReadFile function. -** Creates a test file and performs an array of read tests. -** -** Assumes successful: -** CreateFile -** CloseHandle -** WriteFile -** GetLastError -** -** -**===================================================================*/ - - -#include - - -const char* szStringTest = "The quick fox jumped over the lazy dog's back.\0"; -const char* szEmptyString = ""; -const char* szReadableFile = "Readable.txt"; -const char* szResultsFile = "Results.txt"; - -//Previously number of tests was 6, now 4 refer VSW 312690 -#define NOOFTESTS 4 - -const int PAGESIZE = 4096; - -char *readBuffer; - -BOOL validateResults(const char* szString, // string read - DWORD dwByteCount, // amount requested - DWORD dwBytesRead) // amount read -{ - // were the correct number of bytes read? - if (dwBytesRead > dwByteCount) - { - Trace("bytes read > bytes asked for\n"); - return FALSE; - } - if (dwBytesRead != strlen(szString)) - { - Trace("bytes read != length of read string\n"); - return FALSE; - } - - // - // compare results - // - - if (memcmp(szString, szStringTest, dwBytesRead) != 0) - { - Trace("read = %s string = %s", szString, szStringTest); - return FALSE; - } - - return TRUE; -} - -BOOL readTest(DWORD dwByteCount, char cResult) -{ - HANDLE hFile = NULL; - DWORD dwBytesRead; - BOOL bRc = FALSE; - - // open the test file - hFile = CreateFile(szReadableFile, - GENERIC_READ, - FILE_SHARE_READ, - NULL, - OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL, - NULL); - if(hFile == INVALID_HANDLE_VALUE) - { - Trace("ReadFile: ERROR -> Unable to open file \"%s\".\n", - szReadableFile); - return FALSE; - } - - memset(readBuffer, 0, PAGESIZE); - - bRc = ReadFile(hFile, readBuffer, dwByteCount, &dwBytesRead, NULL); - - if (bRc == FALSE) - { - // if it failed, was it supposed to fail? - if (cResult == '1') - { - Trace("\nbRc = %d\n", bRc); - Trace("readBuffer = [%s] dwByteCount = %d dwBytesRead = %d\n", readBuffer, dwByteCount, dwBytesRead); - Trace("cresult = 1\n"); - Trace("getlasterror = %d\n", GetLastError()); - CloseHandle(hFile); - return FALSE; - } - } - else - { - CloseHandle(hFile); - // if it passed, was it supposed to pass? - if (cResult == '0') - { - Trace("cresult = 0\n"); - return FALSE; - } - else - { - return (validateResults(readBuffer, dwByteCount, dwBytesRead)); - } - } - - CloseHandle(hFile); - return TRUE; -} - -int __cdecl main(int argc, char *argv[]) -{ - HANDLE hFile = NULL; - const int BUFFER_SIZE = 2 * PAGESIZE; - - DWORD dwByteCount[] = { 0, - 10, - strlen(szStringTest), - PAGESIZE - // Commented out two negative test cases : Refer VSW 312690 - // 2 * PAGESIZE, - // -1 - }; - - DWORD oldProt; - char szResults[] = "1111"; // Was "111100": Refer VSW 312690 - int i; - BOOL bRc = FALSE; - DWORD dwBytesWritten = 0; - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - /* aloocate read-write memery for readBuffer */ - if (!(readBuffer = (char*) VirtualAlloc(NULL, BUFFER_SIZE, MEM_COMMIT, PAGE_READWRITE))) - { - Fail("VirtualAlloc failed: GetLastError returns %d\n", GetLastError()); - return FAIL; - } - - /* write protect the second page of readBuffer */ - if (!VirtualProtect(&readBuffer[PAGESIZE], PAGESIZE, PAGE_NOACCESS, &oldProt)) - { - Fail("VirtualProtect failed: GetLastError returns %d\n", GetLastError()); - return FAIL; - } - - // create the test file - hFile = CreateFile(szReadableFile, - GENERIC_WRITE, - FILE_SHARE_WRITE, - NULL, - CREATE_ALWAYS, - FILE_ATTRIBUTE_NORMAL, - NULL); - - if(hFile == INVALID_HANDLE_VALUE) - { - Fail("ReadFile: ERROR -> Unable to create file \"%s\" (%d).\n", - szReadableFile, GetLastError()); - } - - bRc = WriteFile(hFile, szStringTest, strlen(szStringTest), &dwBytesWritten, NULL); - CloseHandle(hFile); - - - for (i = 0; i< NOOFTESTS; i++) - { - bRc = readTest(dwByteCount[i], szResults[i]); - if (bRc != TRUE) - { - Fail("ReadFile: ERROR -> Failed on test[%d]\n", i); - } - } - - VirtualFree(readBuffer, BUFFER_SIZE, MEM_RELEASE); - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/file_io/ReadFile/test2/testinfo.dat b/src/pal/tests/palsuite/file_io/ReadFile/test2/testinfo.dat deleted file mode 100644 index 82b632617..000000000 --- a/src/pal/tests/palsuite/file_io/ReadFile/test2/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = ReadFile -Name = Positive Test for ReadFile -Type = DEFAULT -EXE1 = readfile -Description -=Multiple tests of reads of varying sizes with verification - diff --git a/src/pal/tests/palsuite/file_io/ReadFile/test3/CMakeLists.txt b/src/pal/tests/palsuite/file_io/ReadFile/test3/CMakeLists.txt deleted file mode 100644 index d76a72674..000000000 --- a/src/pal/tests/palsuite/file_io/ReadFile/test3/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - ReadFile.cpp -) - -add_executable(paltest_readfile_test3 - ${SOURCES} -) - -add_dependencies(paltest_readfile_test3 coreclrpal) - -target_link_libraries(paltest_readfile_test3 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/ReadFile/test3/ReadFile.cpp b/src/pal/tests/palsuite/file_io/ReadFile/test3/ReadFile.cpp deleted file mode 100644 index c5d6b1d15..000000000 --- a/src/pal/tests/palsuite/file_io/ReadFile/test3/ReadFile.cpp +++ /dev/null @@ -1,184 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: ReadFile.c (test 3) -** -** Purpose: Tests the PAL implementation of the ReadFile function. -** Creates a test file and performs an array of sequential read -** tests. -** -** Assumes successful: -** CreateFile -** CloseHandle -** memset -** WriteFile -** CreateFile -** CloseHandle -** GetLastError -** -** -**===================================================================*/ - -#include - -const char* szStringTest = "The quick fox jumped over the lazy dog's back.\0"; -const char* szEmptyString = ""; -const char* szReadableFile = "Readable.txt"; -const char* szResultsFile = "Results.txt"; - - -BOOL validateResults(const char* szString, // string read - DWORD dwByteCount, // amount requested - DWORD dwBytesRead) // amount read -{ - // were the correct number of bytes read? - if (dwBytesRead > dwByteCount) - { - Trace("bytes read > bytes asked for\n"); - return FALSE; - } - if (dwBytesRead != strlen(szString)) - { - Trace("bytes read != length of read string\n"); - return FALSE; - } - - - // - // compare results - // - - if (memcmp(szString, szStringTest, dwByteCount) != 0) - { - Trace("read = %s string = %s", szString, szStringTest); - return FALSE; - } - - return TRUE; -} - - - - -BOOL readTest(DWORD dwByteCount, char cResult) -{ - HANDLE hFile = NULL; - DWORD dwBytesRead = 0; - DWORD dwTotal = 0; - DWORD dwRequested = 0; - BOOL bRc = FALSE; - char szString[100]; - char* szPtr = szString; - int i = 0; - - // open the test file - hFile = CreateFile(szReadableFile, - GENERIC_READ, - FILE_SHARE_READ, - NULL, - OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL, - NULL); - if(hFile == INVALID_HANDLE_VALUE) - { - Trace("ReadFile: ERROR -> Unable to open file \"%s\".\n", - szReadableFile); - return FALSE; - } - - memset(szString, 0, 100); - - for (i = 0; i < 5; i++) - { - bRc = ReadFile(hFile, szPtr, dwByteCount, &dwBytesRead, NULL); - szPtr += dwByteCount; - dwTotal += dwBytesRead; - dwRequested += dwByteCount; - } - - if (bRc == FALSE) - { - // if it failed, was it supposed to fail? - if (cResult == '1') - { - Trace("\nbRc = %d\n", bRc); - Trace("szString = [%s] dwByteCount = %d dwBytesRead = %d\n", - szString, - dwByteCount, - dwBytesRead); - Trace ("cresult = 1\n"); - Trace ("getlasterror = %d\n", GetLastError()); - CloseHandle(hFile); - return FALSE; - } - } - else - { - CloseHandle(hFile); - // if it passed, was it supposed to pass? - if (cResult == '0') - { - Trace ("cresult = 0\n"); - return FALSE; - } - else - { - return (validateResults(szString, dwRequested, dwTotal)); - } - } - - CloseHandle(hFile); - return TRUE; -} - - - -int __cdecl main(int argc, char **argv) -{ - HANDLE hFile = NULL; - DWORD dwByteCount[4] = {0, 1, 2, 3}; - char szResults[4] = {'1', '1', '1', '1'}; - int i; - BOOL bRc = FALSE; - DWORD dwBytesWritten = 0; - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - - // create the test file - hFile = CreateFile(szReadableFile, - GENERIC_WRITE, - FILE_SHARE_WRITE, - NULL, - CREATE_ALWAYS, - FILE_ATTRIBUTE_NORMAL, - NULL); - if(hFile == INVALID_HANDLE_VALUE) - { - Fail("ReadFile: ERROR -> Unable to create file \"%s\".\n", - szReadableFile); - } - - bRc = WriteFile(hFile, szStringTest, strlen(szStringTest), - &dwBytesWritten, - NULL); - CloseHandle(hFile); - - for (i = 0; i < 4; i++) - { - bRc = readTest(dwByteCount[i], szResults[i]); - if (bRc != TRUE) - { - Fail("ReadFile: ERROR -> Failed on test[%d]\n", i); - } - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/file_io/ReadFile/test3/testinfo.dat b/src/pal/tests/palsuite/file_io/ReadFile/test3/testinfo.dat deleted file mode 100644 index 82b632617..000000000 --- a/src/pal/tests/palsuite/file_io/ReadFile/test3/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = ReadFile -Name = Positive Test for ReadFile -Type = DEFAULT -EXE1 = readfile -Description -=Multiple tests of reads of varying sizes with verification - diff --git a/src/pal/tests/palsuite/file_io/ReadFile/test4/CMakeLists.txt b/src/pal/tests/palsuite/file_io/ReadFile/test4/CMakeLists.txt deleted file mode 100644 index 2550a2117..000000000 --- a/src/pal/tests/palsuite/file_io/ReadFile/test4/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - readfile.cpp -) - -add_executable(paltest_readfile_test4 - ${SOURCES} -) - -add_dependencies(paltest_readfile_test4 coreclrpal) - -target_link_libraries(paltest_readfile_test4 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/ReadFile/test4/readfile.cpp b/src/pal/tests/palsuite/file_io/ReadFile/test4/readfile.cpp deleted file mode 100644 index 3ec939f63..000000000 --- a/src/pal/tests/palsuite/file_io/ReadFile/test4/readfile.cpp +++ /dev/null @@ -1,147 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: ReadFile.c (test 4) -** -** Purpose: Tests the PAL implementation of the ReadFile function. -** Creates a file and writes a small string to it, attempt -** to read many more characters that exist. The returned -** number of chars should be the amount written originally -** not the number requested. -** -** -**===================================================================*/ -#include - -int __cdecl main(int argc, char *argv[]) -{ - HANDLE hFile = NULL; - DWORD dwBytesWritten; - BOOL bRc = FALSE; - char szBuffer[256]; - DWORD dwBytesRead = 0; - int szRequestSize = 256; - char testFile[] = "testfile.tmp"; - char testString[] = "people stop and stare"; - DWORD res = 0; - - /* Initialize the PAL. - */ - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - /* Initialize the buffer. - */ - memset(szBuffer, 0, 256); - - /* Create a file to test with. - */ - hFile = CreateFile(testFile, - GENERIC_WRITE|GENERIC_READ, - FILE_SHARE_WRITE|FILE_SHARE_READ, - NULL, - CREATE_ALWAYS, - FILE_ATTRIBUTE_NORMAL, - NULL); - - if(hFile == INVALID_HANDLE_VALUE) - { - Fail("ERROR:%u: Unable to create file \"%s\".\n", - GetLastError(), - testFile); - } - - /* Write to the File handle. - */ - bRc = WriteFile(hFile, - testString, - strlen(testString), - &dwBytesWritten, - NULL); - - if (bRc == FALSE) - { - Trace("ERROR:%u: Unable to write to file handle " - "hFile=0x%lx\n", - GetLastError(), - hFile); - if (!CloseHandle(hFile)) - { - Trace("ERROR:%u%: Unable to close handle 0x%lx.\n", - GetLastError(), - hFile); - } - Fail(""); - } - - /* Set the file pointer to beginning of file. - */ - res = SetFilePointer(hFile, (LONG)NULL, NULL, FILE_BEGIN); - - if( (res == INVALID_SET_FILE_POINTER) && - (GetLastError() != NO_ERROR)) - { - Trace("ERROR:%u: Unable to set file pointer to the beginning of file.", - GetLastError()); - - if (!CloseHandle(hFile)) - { - Trace("ERROR:%u%: Unable to close handle 0x%lx.\n", - GetLastError(), - hFile); - } - Fail(""); - } - - - /* Attempt to read 256 characters from a file - * that does not contain that many. - */ - bRc = ReadFile(hFile, - szBuffer, - szRequestSize, - &dwBytesRead, - NULL); - - if (bRc == FALSE) - { - Trace("ERROR:%u: Unable to read from file handle 0x%lx.\n", - GetLastError(), - hFile); - if (!CloseHandle(hFile)) - { - Trace("ERROR:%u%: Unable to close handle 0x%lx.\n", - GetLastError(), - hFile); - } - Fail(""); - } - - /* Confirm the number of bytes read with that requested. - */ - if (dwBytesRead != strlen(testString)) - { - Trace("ERROR: The number of bytes read \"%d\" is not equal to the " - "number originally written \"%d\" to the file.\n", - dwBytesRead, - strlen(testString)); - if (!CloseHandle(hFile)) - { - Trace("ERROR:%u%: Unable to close handle 0x%lx.\n", - GetLastError(), - hFile); - } - Fail(""); - } - - /* Terminate the PAL. - */ - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/file_io/ReadFile/test4/testinfo.dat b/src/pal/tests/palsuite/file_io/ReadFile/test4/testinfo.dat deleted file mode 100644 index 6f3267d59..000000000 --- a/src/pal/tests/palsuite/file_io/ReadFile/test4/testinfo.dat +++ /dev/null @@ -1,17 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = ReadFile -Name = Positive Test for ReadFile -Type = DEFAULT -EXE1 = readfile -Description -= Tests the PAL implementation of the ReadFile function. -= Creates a file and writes a small string to it, attempt -= to read many more characters that exist. The returned -= number of chars should be the amount written originally -= not the number requested. - diff --git a/src/pal/tests/palsuite/file_io/RemoveDirectoryA/CMakeLists.txt b/src/pal/tests/palsuite/file_io/RemoveDirectoryA/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/file_io/RemoveDirectoryA/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/file_io/RemoveDirectoryA/test1/CMakeLists.txt b/src/pal/tests/palsuite/file_io/RemoveDirectoryA/test1/CMakeLists.txt deleted file mode 100644 index 31a57791b..000000000 --- a/src/pal/tests/palsuite/file_io/RemoveDirectoryA/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - RemoveDirectoryA.cpp -) - -add_executable(paltest_removedirectorya_test1 - ${SOURCES} -) - -add_dependencies(paltest_removedirectorya_test1 coreclrpal) - -target_link_libraries(paltest_removedirectorya_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/RemoveDirectoryA/test1/RemoveDirectoryA.cpp b/src/pal/tests/palsuite/file_io/RemoveDirectoryA/test1/RemoveDirectoryA.cpp deleted file mode 100644 index 4eb53d0d0..000000000 --- a/src/pal/tests/palsuite/file_io/RemoveDirectoryA/test1/RemoveDirectoryA.cpp +++ /dev/null @@ -1,315 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: RemoveDirectoryA.c -** -** Purpose: Tests the PAL implementation of the RemoveDirectoryA function. -** -** -**===================================================================*/ - - -#define PAL_STDCPP_COMPAT -#include -#undef PAL_STDCPP_COMPAT - -#include - - -int __cdecl main(int argc, char *argv[]) -{ - BOOL bRc = FALSE; - char szDirName[252]; - DWORD curDirLen; - char *szTemp = NULL; - char *szTemp2 = NULL; - char szwCurrentDir[MAX_PATH]; - char szwSubDir[MAX_PATH]; - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - /* - * remove a NULL directory - */ - bRc = RemoveDirectoryA(NULL); - if (bRc != FALSE) - { - Fail("Error[%ul]:RemoveDirectoryA: Failed since it was able to remove a" - " NULL directory name\n", GetLastError()); - } - - /* - * remove a directory that does not exist - */ - szTemp = (char *) malloc (sizeof("test_directory")); - sprintf_s(szTemp, sizeof("test_directory"), "test_directory"); - bRc = RemoveDirectoryA(szTemp); - if (bRc != FALSE) - { - free(szTemp); - Fail("Error[%ul]:RemoveDirectoryA: Failed since it was able to remove" - " the non-existant directory \"test_directory\"\n", GetLastError()); - } - - /* - * remove a symlink to a directory - */ - bRc = CreateDirectoryA(szTemp, NULL); - if (bRc != TRUE) - { - free(szTemp); - Fail("Error[%ul]:RemoveDirectoryA: Failed to create the directory " - "\"test_directory\".\n", GetLastError()); - } - - char *szSymlinkName = (char *) malloc (sizeof("test_directory_symlink")); - sprintf_s(szSymlinkName, sizeof("test_directory_symlink"), "test_directory_symlink"); - if (symlink(szTemp, szSymlinkName) != 0) - { - Fail("Error:RemoveDirectoryA: Failed to create a symlink to the directory \"test_directory\".\n"); - } - - bRc = RemoveDirectoryA(szSymlinkName); - if (bRc != FALSE) - { - Fail("Error:RemoveDirectoryA: RemoveDirectoryA should return FALSE when passed a symlink.\n"); - } - - unlink(szSymlinkName); - - /* - * remove a directory that exists - */ - bRc = RemoveDirectoryA(szTemp); - if (bRc == FALSE) - { - free(szTemp); - Fail("Error[%ul]:RemoveDirectoryW: Failed to remove the directory " - "\"test_directory\"\n", - GetLastError()); - } - /* Make sure the directory was removed */ - if( -1 != GetFileAttributesA(szTemp) ) - { - free(szTemp); - Fail("Error[%ul]:RemoveDirectoryA: Able to get the attributes of " - "the removed directory\n" , GetLastError()); - } - free(szTemp); - - /* - * remove long directory names (245 characters) - */ - curDirLen = GetCurrentDirectoryA(0, NULL) + 1; - memset(szDirName, 0, 252); - memset(szDirName, 'a', 245 - curDirLen); - szTemp = (char *) malloc (sizeof(szDirName)); - szTemp = strncpy(szTemp, szDirName, strlen(szDirName) + 1); - - bRc = CreateDirectoryA(szTemp, NULL); - if (bRc == FALSE) - { - free(szTemp); - Fail("Error[%ul]:RemoveDirectoryA: Failed to create a directory name " - "245 chars long\n" , GetLastError()); - } - bRc = RemoveDirectoryA(szTemp); - if (bRc == FALSE) - { - free(szTemp); - Fail("Error[%ul]:RemoveDirectoryA: Failed to remove a 245 char " - "long directory\n", GetLastError()); - } - - /* Make sure the directory was removed */ - if( -1 != GetFileAttributesA(szTemp) ) - { - free(szTemp); - Fail("Error[%ul]:RemoveDirectoryA: Able to get the attributes of " - "the removed directory\n", GetLastError()); - } - free(szTemp); - - /* - * directories with dots - */ - memset(szDirName, 0, 252); - sprintf_s(szDirName, _countof(szDirName), ".dotDirectory"); - szTemp = (char *) malloc (sizeof(szDirName)); - szTemp = strncpy(szTemp, szDirName, strlen(szDirName) + 1); - - bRc = CreateDirectoryA(szTemp, NULL); - if (bRc == FALSE) - { - free(szTemp); - Fail("Error[%ul]:RemoveDirectoryA: Failed to create \"%s\"\n", GetLastError(), szDirName); - } - bRc = RemoveDirectoryA(szTemp); - if (bRc == FALSE) - { - free(szTemp); - Fail("Error[%ul]:RemoveDirectoryA: Failed to remove \"%s\"\n", GetLastError(), szDirName); - } - - /* Make sure the directory was removed */ - if( -1 != GetFileAttributesA(szTemp) ) - { - free(szTemp); - Fail("Error[%ul]:RemoveDirectoryA: Able to get the attributes of " - "the removed directory\n", GetLastError()); - } - free(szTemp); - - /* - * Try calling RemoveDirectory with a file name - */ - memset(szDirName, 0, 252); - sprintf_s(szDirName, _countof(szDirName), "removedirectoryw.c"); - szTemp = (char *) malloc (sizeof(szDirName)); - szTemp = strncpy(szTemp, szDirName, strlen(szDirName) + 1); - - bRc = RemoveDirectoryA(szTemp); - free(szTemp); - if (bRc != FALSE) - { - Fail("Error[%ul]:RemoveDirectoryA: should have failed when " - "called with a valid file name", GetLastError() ); - } - - /* - * remove a non empty directory - * - * To test that, we'll first create non_empty_dir, we'll - * set the current dir to non_empty_dir in which we'll - * create sub_dir. We'll go back to the root of non_empty_dir - * and we'll try to delete it (it shouldn't work). - * After that we'll cleanup sub_dir and non_empty_dir - */ - - /* Get the current directory so it is easy to get back - to it later */ - if( 0 == GetCurrentDirectoryA(MAX_PATH, szwCurrentDir) ) - { - Fail("RemoveDirectoryA: Failed to get current directory " - "with GetCurrentDirectoryA.\n"); - } - - /* Create non_empty_dir */ - sprintf_s(szDirName, _countof(szDirName), "non_empty_dir"); - szTemp = (char *) malloc (sizeof(szDirName)); - szTemp = strncpy(szTemp, szDirName, strlen(szDirName) + 1); - bRc = CreateDirectoryA(szTemp, NULL); - if (bRc != TRUE) - { - free(szTemp); - Fail("Error[%ul]:RemoveDirectoryA: Failed to create the directory " - "\"non_empty_dir\" when it exists already.\n", GetLastError()); - } - - if( 0 == SetCurrentDirectoryA(szTemp) ) - { - free(szTemp); - Fail("Error[%ul]:RemoveDirectoryA: Failed to set current directory to " - "\"non_empty_dir\" with SetCurrentDirectoryA.\n", GetLastError()); - } - - /* Get the directory full path so it is easy to get back - to it later */ - if( 0 == GetCurrentDirectoryA(MAX_PATH, szwSubDir) ) - { - free(szTemp); - Fail("Error[%ul]:RemoveDirectoryA: Failed to get current directory " - "with GetCurrentDirectoryA.\n", GetLastError()); - } - - /* Create sub_dir */ - sprintf_s(szDirName, _countof(szDirName), "sub_dir"); - szTemp2 = (char *) malloc (sizeof(szDirName)); - szTemp2 = strncpy(szTemp2, szDirName, strlen(szDirName) + 1); - bRc = CreateDirectoryA(szTemp2, NULL); - if (bRc != TRUE) - { - free(szTemp); - free(szTemp2); - Fail("Error[%ul]:RemoveDirectoryA: Failed to create the directory " - "\"sub_dir\" when it exists already.\n", GetLastError()); - } - - /* Set the current dir to the parent of non_empty_dir/sub_dir */ - if( 0 == SetCurrentDirectoryA(szwCurrentDir) ) - { - free(szTemp); - free(szTemp2); - Fail("Error[%ul]:RemoveDirectoryA: Failed to set current directory to " - "\"non_empty_dir\" with SetCurrentDirectoryA.\n", GetLastError()); - } - - /* Try to remove non_empty_dir (shouldn't work) */ - bRc = RemoveDirectoryA(szTemp); - if (bRc == TRUE) - { - free(szTemp); - free(szTemp2); - Fail("Error[%ul]:RemoveDirectoryA: shouldn't have been able to remove " - "the non empty directory \"non_empty_dir\"\n", GetLastError()); - } - - /* Go back to non_empty_dir and remove sub_dir */ - if( 0 == SetCurrentDirectoryA(szwSubDir) ) - { - free(szTemp); - free(szTemp2); - Fail("Error[%ul]:RemoveDirectoryA: Failed to set current directory to " - "\"non_empty_dir\" with SetCurrentDirectoryA.\n", GetLastError()); - } - - bRc = RemoveDirectoryA(szTemp2); - if (bRc == FALSE) - { - free(szTemp); - free(szTemp2); - Fail("Error[%ul]:RemoveDirectoryA: unable to remove " - "directory \"sub_dir\" \n", - GetLastError()); - } - /* Make sure the directory was removed */ - if( -1 != GetFileAttributesA(szTemp2) ) - { - Fail("Error[%ul]RemoveDirectoryA: Able to get the attributes of " - "the removed directory\n", GetLastError()); - } - free(szTemp2); - - /* Go back to parent of non_empty_dir and remove non_empty_dir */ - if( 0 == SetCurrentDirectoryA(szwCurrentDir) ) - { - free(szTemp); - Fail("Error[%ul]:RemoveDirectoryA: Failed to set current directory to " - "\"..\non_empty_dir\" with SetCurrentDirectoryA.\n", GetLastError()); - } - bRc = RemoveDirectoryA(szTemp); - if (bRc == FALSE) - { - free(szTemp); - Fail("Error[%ul]RemoveDirectoryA: unable to remove " - "the directory \"non_empty_dir\"\n", - GetLastError()); - } - /* Make sure the directory was removed */ - if( -1 != GetFileAttributesA(szTemp) ) - { - Fail("Error[%ul]:RemoveDirectoryA: Able to get the attributes of " - "the removed directory\n", GetLastError()); - } - free(szTemp); - - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/file_io/RemoveDirectoryA/test1/testinfo.dat b/src/pal/tests/palsuite/file_io/RemoveDirectoryA/test1/testinfo.dat deleted file mode 100644 index 6d8f72d27..000000000 --- a/src/pal/tests/palsuite/file_io/RemoveDirectoryA/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = RemoveDirectoryA -Name = Test for RemoveDirectoryA (test 1) -Type = DEFAULT -EXE1 = removedirectorya -Description -= Create directories and attempt to remove them. - diff --git a/src/pal/tests/palsuite/file_io/RemoveDirectoryW/CMakeLists.txt b/src/pal/tests/palsuite/file_io/RemoveDirectoryW/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/file_io/RemoveDirectoryW/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/file_io/RemoveDirectoryW/test1/CMakeLists.txt b/src/pal/tests/palsuite/file_io/RemoveDirectoryW/test1/CMakeLists.txt deleted file mode 100644 index f995a0e1c..000000000 --- a/src/pal/tests/palsuite/file_io/RemoveDirectoryW/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - RemoveDirectoryW.cpp -) - -add_executable(paltest_removedirectoryw_test1 - ${SOURCES} -) - -add_dependencies(paltest_removedirectoryw_test1 coreclrpal) - -target_link_libraries(paltest_removedirectoryw_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/RemoveDirectoryW/test1/RemoveDirectoryW.cpp b/src/pal/tests/palsuite/file_io/RemoveDirectoryW/test1/RemoveDirectoryW.cpp deleted file mode 100644 index ec9052806..000000000 --- a/src/pal/tests/palsuite/file_io/RemoveDirectoryW/test1/RemoveDirectoryW.cpp +++ /dev/null @@ -1,282 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: RemoveDirectoryW.c -** -** Purpose: Tests the PAL implementation of the RemoveDirectoryW function. -** -** -**===================================================================*/ - - -#include - - -int __cdecl main(int argc, char *argv[]) -{ - BOOL bRc = FALSE; - char szDirName[252]; - DWORD curDirLen; - WCHAR *szwTemp = NULL; - WCHAR *szwTemp2 = NULL; - WCHAR szwCurrentDir[MAX_PATH]; - WCHAR szwSubDir[MAX_PATH]; - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - /* - * remove a NULL directory - */ - bRc = RemoveDirectoryW(NULL); - if (bRc != FALSE) - { - Fail("RemoveDirectoryW: Failed since it was able to remove a" - " NULL directory name\n"); - } - - /* - * remove a directory that does not exist - */ - szwTemp = convert("test_directory"); - bRc = RemoveDirectoryW(szwTemp); - if (bRc != FALSE) - { - free(szwTemp); - Fail("RemoveDirectoryW: Failed since it was able to remove" - " the non-existant directory \"test_directory\"\n"); - } - - /* - * remove a directory that exists - */ - bRc = CreateDirectoryW(szwTemp, NULL); - if (bRc != TRUE) - { - free(szwTemp); - Fail("RemoveDirectoryW: Failed to create the directory " - "\"test_directory\" when it exists already.\n"); - } - bRc = RemoveDirectoryW(szwTemp); - if (bRc == FALSE) - { - free(szwTemp); - Fail("RemoveDirectoryW: Failed to remove the directory " - "\"test_directory\" (error code %d)\n", - GetLastError()); - } - /* Make sure the directory was removed */ - if( -1 != GetFileAttributesW(szwTemp) ) - { - free(szwTemp); - Fail("RemoveDirectoryW: Able to get the attributes of " - "the removed directory\n"); - } - free(szwTemp); - - /* - * remove long directory names (245 characters) - */ - curDirLen = GetCurrentDirectoryA(0, NULL) + 1; - memset(szDirName, 0, 252); - memset(szDirName, 'a', 245 - curDirLen); - szwTemp = convert(szDirName); - bRc = CreateDirectoryW(szwTemp, NULL); - if (bRc == FALSE) - { - free(szwTemp); - Fail("RemoveDirectoryW: Failed to create a directory name " - "245 chars long\n"); - } - bRc = RemoveDirectoryW(szwTemp); - if (bRc == FALSE) - { - free(szwTemp); - Fail("RemoveDirectoryW: Failed to remove a 245 char " - "long directory\n"); - } - - /* Make sure the directory was removed */ - if( -1 != GetFileAttributesW(szwTemp) ) - { - free(szwTemp); - Fail("RemoveDirectoryW: Able to get the attributes of " - "the removed directory\n"); - } - free(szwTemp); - - /* - * directories with dots - */ - memset(szDirName, 0, 252); - sprintf_s(szDirName, _countof(szDirName), ".dotDirectory"); - szwTemp = convert(szDirName); - bRc = CreateDirectoryW(szwTemp, NULL); - if (bRc == FALSE) - { - free(szwTemp); - Fail("RemoveDirectoryW: Failed to create \"%s\"\n", szDirName); - } - bRc = RemoveDirectoryW(szwTemp); - if (bRc == FALSE) - { - free(szwTemp); - Fail("RemoveDirectoryW: Failed to remove \"%s\"\n", szDirName); - } - - /* Make sure the directory was removed */ - if( -1 != GetFileAttributesW(szwTemp) ) - { - free(szwTemp); - Fail("RemoveDirectoryW: Able to get the attributes of " - "the removed directory\n"); - } - free(szwTemp); - - /* - * Try calling RemoveDirectory with a file name - */ - memset(szDirName, 0, 252); - sprintf_s(szDirName, _countof(szDirName), "removedirectoryw.c"); - szwTemp = convert(szDirName); - - bRc = RemoveDirectoryW(szwTemp); - free(szwTemp); - if (bRc != FALSE) - { - Fail("RemoveDirectoryW: should have failed when " - "called with a valid file name" ); - } - - /* - * remove a non empty directory - * - * To test that, we'll first create non_empty_dir, we'll - * set the current dir to non_empty_dir in which we'll - * create sub_dir. We'll go back to the root of non_empty_dir - * and we'll try to delete it (it shouldn't work). - * After that we'll cleanup sub_dir and non_empty_dir - */ - - /* Get the current directory so it is easy to get back - to it later */ - if( 0 == GetCurrentDirectoryW(MAX_PATH, szwCurrentDir) ) - { - Fail("RemoveDirectoryW: Failed to get current directory " - "with GetCurrentDirectoryW.\n"); - } - - /* Create non_empty_dir */ - szwTemp = convert("non_empty_dir"); - bRc = CreateDirectoryW(szwTemp, NULL); - if (bRc != TRUE) - { - free(szwTemp); - Fail("RemoveDirectoryW: Failed to create the directory " - "\"non_empty_dir\" when it exists already.\n"); - } - - if( 0 == SetCurrentDirectoryW(szwTemp) ) - { - free(szwTemp); - Fail("RemoveDirectoryW: Failed to set current directory to " - "\"non_empty_dir\" with SetCurrentDirectoryW.\n"); - } - - /* Get the directory full path so it is easy to get back - to it later */ - if( 0 == GetCurrentDirectoryW(MAX_PATH, szwSubDir) ) - { - free(szwTemp); - Fail("RemoveDirectoryW: Failed to get current directory " - "with GetCurrentDirectoryW.\n"); - } - - /* Create sub_dir */ - szwTemp2 = convert("sub_dir"); - bRc = CreateDirectoryW(szwTemp2, NULL); - if (bRc != TRUE) - { - free(szwTemp); - free(szwTemp2); - Fail("RemoveDirectoryW: Failed to create the directory " - "\"sub_dir\" when it exists already.\n"); - } - - /* Set the current dir to the parent of non_empty_dir/sub_dir */ - if( 0 == SetCurrentDirectoryW(szwCurrentDir) ) - { - free(szwTemp); - free(szwTemp2); - Fail("RemoveDirectoryW: Failed to set current directory to " - "\"non_empty_dir\" with SetCurrentDirectoryW.\n"); - } - - /* Try to remove non_empty_dir (shouldn't work) */ - bRc = RemoveDirectoryW(szwTemp); - if (bRc == TRUE) - { - free(szwTemp); - free(szwTemp2); - Fail("RemoveDirectoryW: shouldn't have been able to remove " - "the non empty directory \"non_empty_dir\"\n"); - } - - /* Go back to non_empty_dir and remove sub_dir */ - if( 0 == SetCurrentDirectoryW(szwSubDir) ) - { - free(szwTemp); - free(szwTemp2); - Fail("RemoveDirectoryW: Failed to set current directory to " - "\"non_empty_dir\" with SetCurrentDirectoryW.\n"); - } - - bRc = RemoveDirectoryW(szwTemp2); - if (bRc == FALSE) - { - free(szwTemp); - free(szwTemp2); - Fail("RemoveDirectoryW: unable to remove " - "directory \"sub_dir\"(error code %d)\n", - GetLastError()); - } - /* Make sure the directory was removed */ - if( -1 != GetFileAttributesW(szwTemp2) ) - { - Fail("RemoveDirectoryW: Able to get the attributes of " - "the removed directory\n"); - } - free(szwTemp2); - - /* Go back to parent of non_empty_dir and remove non_empty_dir */ - if( 0 == SetCurrentDirectoryW(szwCurrentDir) ) - { - free(szwTemp); - Fail("RemoveDirectoryW: Failed to set current directory to " - "\"..\non_empty_dir\" with SetCurrentDirectoryW.\n"); - } - bRc = RemoveDirectoryW(szwTemp); - if (bRc == FALSE) - { - free(szwTemp); - Fail("RemoveDirectoryW: unable to remove " - "the directory \"non_empty_dir\"(error code %d)\n", - GetLastError()); - } - /* Make sure the directory was removed */ - if( -1 != GetFileAttributesW(szwTemp) ) - { - Fail("RemoveDirectoryW: Able to get the attributes of " - "the removed directory\n"); - } - free(szwTemp); - - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/file_io/RemoveDirectoryW/test1/testinfo.dat b/src/pal/tests/palsuite/file_io/RemoveDirectoryW/test1/testinfo.dat deleted file mode 100644 index f94b9b244..000000000 --- a/src/pal/tests/palsuite/file_io/RemoveDirectoryW/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = RemoveDirectoryW -Name = Test for RemoveDirectoryW (test 1) -Type = DEFAULT -EXE1 = removedirectoryw -Description -= Create directories and attempt to remove them. - diff --git a/src/pal/tests/palsuite/file_io/SearchPathA/CMakeLists.txt b/src/pal/tests/palsuite/file_io/SearchPathA/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/file_io/SearchPathA/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/file_io/SearchPathA/test1/CMakeLists.txt b/src/pal/tests/palsuite/file_io/SearchPathA/test1/CMakeLists.txt deleted file mode 100644 index 8de22aebd..000000000 --- a/src/pal/tests/palsuite/file_io/SearchPathA/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - SearchPathA.cpp -) - -add_executable(paltest_searchpatha_test1 - ${SOURCES} -) - -add_dependencies(paltest_searchpatha_test1 coreclrpal) - -target_link_libraries(paltest_searchpatha_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/SearchPathA/test1/SearchPathA.cpp b/src/pal/tests/palsuite/file_io/SearchPathA/test1/SearchPathA.cpp deleted file mode 100644 index 57afdefc7..000000000 --- a/src/pal/tests/palsuite/file_io/SearchPathA/test1/SearchPathA.cpp +++ /dev/null @@ -1,139 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: SearchPathA.c -** -** Purpose: Tests the PAL implementation of the SearchFileA function. -** -** -** TODO: Write a test where complete path is passed (say c:\?) -**===================================================================*/ -//SearchPath -// -//The SearchPath function searches for the specified file in the specified path. -// - - -#include -char* szDir = "."; - -char* szNoFileName = "333asdf"; -char* szNoFileNameExt = ".x77t"; - -char* szFileNameExists = "searchfile"; -char* szFileNameExtExists = ".txt"; - -char* szFileNameExistsWithExt = "searchfile.txt"; -char fileloc[_MAX_PATH]; - -void removeFileHelper(LPSTR pfile, int location) -{ - FILE *fp; - fp = fopen( pfile, "r"); - - if (fp != NULL) - { - if(fclose(fp)) - { - Fail("ERROR: Failed to close the file [%s], Error Code [%d], location [%d]\n", pfile, GetLastError(), location); - } - - if(!DeleteFileA(pfile)) - { - Fail("ERROR: Failed to delete file [%s], Error Code [%d], location [%d]\n", pfile, GetLastError(), location); - } - } - -} - - -void RemoveAll() -{ - removeFileHelper(fileloc, 1); -} - -int __cdecl main(int argc, char *argv[]) { - - char* lpPath = NULL; - char* lpFileName = NULL; - char* lpExtension = NULL; - DWORD nBufferLength = 0; - char lpBuffer[_MAX_PATH]; - char** lpFilePart = NULL; - DWORD error = 0; - DWORD result = 0; - - HANDLE hsearchfile; - char fname[_MAX_FNAME]; - char ext[_MAX_EXT]; - char fullPath[_MAX_DIR]; - char drive[_MAX_DRIVE]; - char dir[_MAX_DIR]; - - - if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - - /* Initalize the buffer. - */ - memset(fullPath, 0, _MAX_DIR); - - if (GetTempPathA(_MAX_DIR, fullPath) == 0) - { - Fail("ERROR: GetTempPathA failed to get a path\n"); - } - - memset(fileloc, 0, _MAX_PATH); - sprintf_s(fileloc, _countof(fileloc), "%s%s", fullPath, szFileNameExistsWithExt); - - RemoveAll(); - - hsearchfile = CreateFileA(fileloc, GENERIC_WRITE, 0, 0, CREATE_ALWAYS, - FILE_ATTRIBUTE_NORMAL, 0); - - if (hsearchfile == INVALID_HANDLE_VALUE) - { - Trace("ERROR[%ul]: couldn't create %s\n", GetLastError(), fileloc); - return FAIL; - } - - CloseHandle(hsearchfile); - - // - // find a file that doesn't exist - // - ZeroMemory( lpBuffer, sizeof(lpBuffer)); - lpPath = fullPath; - lpFileName = szNoFileName; - lpExtension = NULL; - - if( SearchPathA( lpPath, lpFileName, lpExtension, nBufferLength, lpBuffer, lpFilePart) != 0 ){ - error = GetLastError(); - Fail ("SearchPathA: ERROR1 -> Found invalid file[%s][%s][%s][%d]\n", lpPath, szNoFileName, szNoFileNameExt, error); - } - - // - // find a file that exists, when path is mentioned explicitly - // - ZeroMemory( lpBuffer, sizeof(lpBuffer)); - lpPath = fullPath; - lpFileName = szFileNameExistsWithExt; - lpExtension = NULL; - - result = SearchPathA( lpPath, lpFileName, lpExtension, nBufferLength, lpBuffer, lpFilePart); - - if( result == 0 ){ - error = GetLastError(); - Fail ("SearchPathA: ERROR2 -> Did not Find valid file[%s][%s][%d]\n", lpPath, szFileNameExistsWithExt, error); - } - - RemoveAll(); - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/file_io/SearchPathA/test1/testinfo.dat b/src/pal/tests/palsuite/file_io/SearchPathA/test1/testinfo.dat deleted file mode 100644 index 82401eeeb..000000000 --- a/src/pal/tests/palsuite/file_io/SearchPathA/test1/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = SearchPathA -Name = Test #1 for SearchPathA -TYPE = DEFAULT -EXE1 = test1 -Description -=Tests the PAL implementation of the SearchFileA function diff --git a/src/pal/tests/palsuite/file_io/SearchPathW/CMakeLists.txt b/src/pal/tests/palsuite/file_io/SearchPathW/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/file_io/SearchPathW/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/file_io/SearchPathW/test1/CMakeLists.txt b/src/pal/tests/palsuite/file_io/SearchPathW/test1/CMakeLists.txt deleted file mode 100644 index d7539a8ac..000000000 --- a/src/pal/tests/palsuite/file_io/SearchPathW/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - SearchPathW.cpp -) - -add_executable(paltest_searchpathw_test1 - ${SOURCES} -) - -add_dependencies(paltest_searchpathw_test1 coreclrpal) - -target_link_libraries(paltest_searchpathw_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/SearchPathW/test1/SearchPathW.cpp b/src/pal/tests/palsuite/file_io/SearchPathW/test1/SearchPathW.cpp deleted file mode 100644 index 6880a864c..000000000 --- a/src/pal/tests/palsuite/file_io/SearchPathW/test1/SearchPathW.cpp +++ /dev/null @@ -1,193 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: SearchPathW.c -** -** Purpose: Tests the PAL implementation of the SearchFileW function. -** -** -** TODO: Write a test where complete path is passed (say c:\?) -**===================================================================*/ -//SearchPath -// -//The SearchPath function searches for the specified file in the specified path. -// -// -//DWORD SearchPath( -// LPCTSTR lpPath, -// LPCTSTR lpFileName, -// LPCTSTR lpExtension, -// DWORD nBufferLength, -// LPTSTR lpBuffer, -// LPTSTR* lpFilePart -//); -// -//Parameters -//lpPath -//[in] Pointer to a null-terminated string that specifies the path to be searched for the file. If this parameter is NULL, the function searches for a matching file in the following directories in the following sequence: -//The directory from which the application loaded. -//The current directory. -//The system directory. Use the GetSystemDirectory function to get the path of this directory. -//The 16-bit system directory. There is no function that retrieves the path of this directory, but it is searched. -//The Windows directory. Use the GetWindowsDirectory function to get the path of this directory. -//The directories that are listed in the PATH environment variable. - -//lpFileName -//[in] Pointer to a null-terminated string that specifies the name of the file to search for. - -//lpExtension -//[in] Pointer to a null-terminated string that specifies an extension to be added to the file name when searching for the file. The first character of the file name extension must be a period (.). The extension is added only if the specified file name does not end with an extension. -//If a file name extension is not required or if the file name contains an extension, this parameter can be NULL. -// -//nBufferLength -//[in] Size of the buffer that receives the valid path and file name, in TCHARs. - -//lpBuffer -//[out] Pointer to the buffer that receives the path and file name of the file found. - -//lpFilePart -//[out] Pointer to the variable that receives the address (within lpBuffer) of the last component of the valid path and file name, which is the address of the character immediately following the final backslash (\) in the path. - -//Return Values -//If the function succeeds, the value returned is the length, in TCHARs, of the string copied to the buffer, not including the terminating null character. If the return value is greater than nBufferLength, the value returned is the size of the buffer required to hold the path. -// -//If the function fails, the return value is zero. To get extended error information, call GetLastError. - - -#include -const char* szDir = "."; - -const char* szNoFileName = "333asdf"; -const char* szNoFileNameExt = ".x77t"; - -const char* szFileNameExists = "searchpathw"; -const char* szFileNameExtExists = ".c"; - -const char* szFileNameExistsWithExt = "searchpathw.c"; - -char fileloc[_MAX_PATH]; - -void removeFileHelper(LPSTR pfile, int location) -{ - FILE *fp; - fp = fopen( pfile, "r"); - - if (fp != NULL) - { - if(fclose(fp)) - { - Fail("ERROR: Failed to close the file [%s], Error Code [%d], location [%d]\n", pfile, GetLastError(), location); - } - - if(!DeleteFileA(pfile)) - { - Fail("ERROR: Failed to delete file [%s], Error Code [%d], location [%d]\n", pfile, GetLastError(), location); - } - else - { - // Trace("Success: deleted file [%S], Error Code [%d], location [%d]\n", wfile, GetLastError(), location); - } - } - -} - -void RemoveAll() -{ - removeFileHelper(fileloc, 1); -} - -int __cdecl main(int argc, char *argv[]) { - - WCHAR* lpPath = NULL; - WCHAR* lpFileName = NULL; - WCHAR* lpExtension = NULL; - DWORD nBufferLength = 0; - WCHAR lpBuffer[_MAX_PATH]; - WCHAR** lpFilePart = NULL; - DWORD error = 0; - DWORD result = 0; - - HANDLE hsearchfile; - char fname[_MAX_FNAME]; - char ext[_MAX_EXT]; - char fullPath[_MAX_DIR]; - char drive[_MAX_DRIVE]; - char dir[_MAX_DIR]; - - - if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - /* Initalize the buffer. - */ - memset(fullPath, 0, _MAX_DIR); - - if (GetTempPathA(_MAX_DIR, fullPath) == 0) - { - Fail("ERROR: GetTempPathA failed to get a path\n"); - } - - memset(fileloc, 0, _MAX_PATH); - sprintf_s(fileloc, _countof(fileloc), "%s%s", fullPath, szFileNameExistsWithExt); - - RemoveAll(); - - hsearchfile = CreateFileA(fileloc, GENERIC_WRITE, 0, 0, CREATE_ALWAYS, - FILE_ATTRIBUTE_NORMAL, 0); - - if (hsearchfile == NULL) - { - Trace("ERROR[%ul]: couldn't create %s\n", GetLastError(), fileloc); - return FAIL; - } - - CloseHandle(hsearchfile); - - // - // find a file that doesn't exist - // - ZeroMemory( lpBuffer, sizeof(lpBuffer)); - lpPath = convert((LPSTR)fullPath); - lpFileName = convert((LPSTR)szNoFileName); - lpExtension = NULL; - - if( SearchPathW( lpPath, lpFileName, lpExtension, nBufferLength, lpBuffer, lpFilePart) != 0 ){ - error = GetLastError(); - free(lpPath); - free(lpFileName); - Fail ("SearchPathW: ERROR1 -> Found invalid file[%s][%s][%s][%d]\n", lpPath, szNoFileName, szNoFileNameExt, error); - } - - free(lpPath); - free(lpFileName); - - // - // find a file that exists, when path is mentioned explicitly - // - ZeroMemory( lpBuffer, sizeof(lpBuffer)); - lpPath = convert((LPSTR)fullPath); - lpFileName = convert((LPSTR)szFileNameExistsWithExt); - lpExtension = NULL; - - result = SearchPathW( lpPath, lpFileName, lpExtension, nBufferLength, lpBuffer, lpFilePart); - - if( result == 0 ){ - error = GetLastError(); - free(lpPath); - free(lpFileName); - Fail ("SearchPathA: ERROR2 -> Did not Find valid file[%s][%s][%d]\n", lpPath, szFileNameExistsWithExt, error); - } - - free(lpPath); - free(lpFileName); - - RemoveAll(); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/file_io/SearchPathW/test1/testinfo.dat b/src/pal/tests/palsuite/file_io/SearchPathW/test1/testinfo.dat deleted file mode 100644 index f7a36eb53..000000000 --- a/src/pal/tests/palsuite/file_io/SearchPathW/test1/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = SearchPathW -Name = Test #1 for SearchPathW -TYPE = DEFAULT -EXE1 = test1 -Description -=Tests the PAL implementation of the SearchFileW function diff --git a/src/pal/tests/palsuite/file_io/SetCurrentDirectoryA/CMakeLists.txt b/src/pal/tests/palsuite/file_io/SetCurrentDirectoryA/CMakeLists.txt deleted file mode 100644 index 1962ade35..000000000 --- a/src/pal/tests/palsuite/file_io/SetCurrentDirectoryA/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) -add_subdirectory(test3) - diff --git a/src/pal/tests/palsuite/file_io/SetCurrentDirectoryA/test1/CMakeLists.txt b/src/pal/tests/palsuite/file_io/SetCurrentDirectoryA/test1/CMakeLists.txt deleted file mode 100644 index e6fb80f04..000000000 --- a/src/pal/tests/palsuite/file_io/SetCurrentDirectoryA/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - SetCurrentDirectoryA.cpp -) - -add_executable(paltest_setcurrentdirectorya_test1 - ${SOURCES} -) - -add_dependencies(paltest_setcurrentdirectorya_test1 coreclrpal) - -target_link_libraries(paltest_setcurrentdirectorya_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/SetCurrentDirectoryA/test1/SetCurrentDirectoryA.cpp b/src/pal/tests/palsuite/file_io/SetCurrentDirectoryA/test1/SetCurrentDirectoryA.cpp deleted file mode 100644 index f227aa326..000000000 --- a/src/pal/tests/palsuite/file_io/SetCurrentDirectoryA/test1/SetCurrentDirectoryA.cpp +++ /dev/null @@ -1,215 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: SetCurrentDirectoryA.c (test 1) -** -** Purpose: Tests the PAL implementation of the SetCurrentDirectoryA function. -** -** -**===================================================================*/ - -#include - - - -/* In order to avoid the "chicken and egg" scenario, this is another - method of getting the current directory. GetFullPathNameA is called with - a dummy file name and then the file name is stripped off leaving the - current working directory -*/ - -BOOL GetCurrentDir(char* szCurrentDir) -{ - const char* szFileName = "blah"; - DWORD dwRc = 0; - char szReturnedPath[_MAX_DIR+1]; - LPSTR pPathPtr; - size_t nCount = 0; - - /* use GetFullPathNameA to to get the current path by stripping - the file name off the end */ - memset(szReturnedPath, 0, (_MAX_DIR+1)); - dwRc = GetFullPathNameA(szFileName, - _MAX_DIR, - szReturnedPath, - &pPathPtr); - - if (dwRc == 0) - { - /* GetFullPathNameA failed */ - Trace("SetCurrentDirectoryA: ERROR -> GetFullPathNameA failed " - "with error code: %ld.\n", GetLastError()); - return(FALSE); - } - - /* now strip the file name from the full path to get the current path */ - nCount = strlen(szReturnedPath) - strlen(szFileName); - memset(szCurrentDir, 0, (_MAX_DIR+1)); - strncpy(szCurrentDir, szReturnedPath, nCount); - - return(TRUE); -} - - - -int __cdecl main(int argc, char *argv[]) -{ - const char* szDirName = "testing"; - /* directory name longer than MAX_PATH characters */ - char szLongDirName[MAX_LONGPATH+1]; - char szNewDir[_MAX_DIR+1]; - char szBuiltDir[_MAX_DIR+1]; - char szHomeDir[_MAX_DIR+1]; - WCHAR* szwPtr = NULL; - - memset(szLongDirName, 'a', MAX_LONGPATH+1); - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - /* remove the directory just in case a previous run of the test didn't */ - szwPtr = convert((LPSTR)szDirName); - - /* clean up. Remove the directory - * if it exists */ - RemoveDirectoryW(szwPtr); - - /* create a temp directory off the current directory */ - if (CreateDirectoryA(szDirName, NULL) != TRUE) - { - free(szwPtr); - Fail("SetCurrentDirectoryA: ERROR -> CreateDirectoryW failed " - "with error code: %ld.\n", GetLastError()); - } - - /* find out what the current "home" directory is */ - memset(szHomeDir, 0, (_MAX_DIR+1)); - if(GetCurrentDir(szHomeDir) != TRUE) - { - if (!RemoveDirectoryW(szwPtr)) - { - Trace("SetCurrentDirectoryA: ERROR -> RemoveDirectoryW failed " - "with error code: %ld.\n", GetLastError()); - } - free(szwPtr); - PAL_TerminateEx(FAIL); - return FAIL; - } - - /* set the current directory to the temp directory */ - - if (SetCurrentDirectoryA(szDirName) != TRUE) - { - Trace("SetCurrentDirectoryA: ERROR -> Unable to set current " - "directory. Failed with error code: %ld.\n", GetLastError()); - if (!RemoveDirectoryW(szwPtr)) - { - Trace("SetCurrentDirectoryA: ERROR -> RemoveDirectoryW failed " - "with error code: %ld.\n", GetLastError()); - } - free(szwPtr); - Fail(""); - } - - /* append the temp name to the "home" directory */ - memset(szBuiltDir, 0, (_MAX_DIR+1)); -#if WIN32 - sprintf_s(szBuiltDir, _countof(szBuiltDir),"%s%s\\", szHomeDir, szDirName); -#else - sprintf_s(szBuiltDir, _countof(szBuiltDir),"%s%s/", szHomeDir, szDirName); -#endif - - /* get the new current directory */ - memset(szNewDir, 0, (_MAX_DIR+1)); - if(GetCurrentDir(szNewDir) != TRUE) - { - if (!RemoveDirectoryW(szwPtr)) - { - Trace("SetCurrentDirectoryA: ERROR -> RemoveDirectoryW failed " - "with error code: %ld.\n", GetLastError()); - } - free(szwPtr); - PAL_TerminateEx(FAIL); - return FAIL; - } - - /*compare the new current dir to the compiled current dir */ - if (strncmp(szNewDir, szBuiltDir, strlen(szNewDir)) != 0) - { - if (!RemoveDirectoryW(szwPtr)) - { - Trace("SetCurrentDirectoryA: ERROR -> RemoveDirectoryW failed " - "with error code: %ld.\n", GetLastError()); - } - free(szwPtr); - Fail("SetCurrentDirectoryA: ERROR -> The set directory \"%s\" does not" - " compare to the built directory \"%s\".\n", - szNewDir, - szBuiltDir); - } - - - - /* set the current dir back to the original */ - if (SetCurrentDirectoryA(szHomeDir) != TRUE) - { - Trace("SetCurrentDirectoryA: ERROR -> Unable to set current " - "directory. Failed with error code: %ld.\n", GetLastError()); - if (!RemoveDirectoryW(szwPtr)) - { - Trace("SetCurrentDirectoryA: ERROR -> RemoveDirectoryW failed " - "with error code: %ld.\n", GetLastError()); - } - free(szwPtr); - Fail(""); - } - - - /* get the new current directory */ - memset(szNewDir, 0, sizeof(char)*(_MAX_DIR+1)); - if(GetCurrentDir(szNewDir) != TRUE) - { - if (!RemoveDirectoryW(szwPtr)) - { - Trace("SetCurrentDirectoryA: ERROR -> RemoveDirectoryW failed " - "with error code: %ld.\n", GetLastError()); - } - free(szwPtr); - PAL_TerminateEx(FAIL); - return FAIL; - } - - /* ensure it compares to the "home" directory which is where - we should be now */ - if (strncmp(szNewDir, szHomeDir, strlen(szNewDir)) != 0) - { - if (!RemoveDirectoryW(szwPtr)) - { - Trace("SetCurrentDirectoryA: ERROR -> RemoveDirectoryW failed " - "with error code: %ld.\n", GetLastError()); - } - free(szwPtr); - Fail("SetCurrentDirectoryA: ERROR -> The set directory does not " - "compare to the built directory.\n"); - } - - - /* clean up */ - if (!RemoveDirectoryW(szwPtr)) - { - free(szwPtr); - Fail("SetCurrentDirectoryA: ERROR -> RemoveDirectoryW failed " - "with error code: %ld.\n", GetLastError()); - } - - free(szwPtr); - PAL_Terminate(); - - return PASS; -} - - diff --git a/src/pal/tests/palsuite/file_io/SetCurrentDirectoryA/test1/testinfo.dat b/src/pal/tests/palsuite/file_io/SetCurrentDirectoryA/test1/testinfo.dat deleted file mode 100644 index 743b2ea3d..000000000 --- a/src/pal/tests/palsuite/file_io/SetCurrentDirectoryA/test1/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = SetCurrentDirectoryA -Name = Test for SetCurrentDirectoryA (test 1) -Type = DEFAULT -EXE1 = setcurrentdirectorya -Description -= Change the current directory and verify the results. diff --git a/src/pal/tests/palsuite/file_io/SetCurrentDirectoryA/test2/CMakeLists.txt b/src/pal/tests/palsuite/file_io/SetCurrentDirectoryA/test2/CMakeLists.txt deleted file mode 100644 index 587ea20cf..000000000 --- a/src/pal/tests/palsuite/file_io/SetCurrentDirectoryA/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - setcurrentdirectorya.cpp -) - -add_executable(paltest_setcurrentdirectorya_test2 - ${SOURCES} -) - -add_dependencies(paltest_setcurrentdirectorya_test2 coreclrpal) - -target_link_libraries(paltest_setcurrentdirectorya_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/SetCurrentDirectoryA/test2/setcurrentdirectorya.cpp b/src/pal/tests/palsuite/file_io/SetCurrentDirectoryA/test2/setcurrentdirectorya.cpp deleted file mode 100644 index 4b1c1c879..000000000 --- a/src/pal/tests/palsuite/file_io/SetCurrentDirectoryA/test2/setcurrentdirectorya.cpp +++ /dev/null @@ -1,142 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: SetCurrentDirectoryA.c (test 2) -** -** Purpose: Tests the PAL implementation of the SetCurrentDirectoryA function -** by setting the current directory with ../ -** -** -**===================================================================*/ - -#include - -int __cdecl main(int argc, char *argv[]) -{ - const char szDirName[MAX_PATH] = "testing"; - char szBuiltDir[_MAX_DIR+1]; - char szHomeDirBefore[_MAX_DIR+1]; - char szHomeDirAfter[_MAX_DIR+1]; - WCHAR* szwPtr = NULL; - - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - /* create a temp directory off the current directory */ - szwPtr = convert((LPSTR)szDirName); - - if (CreateDirectoryA(szDirName, NULL) != TRUE) - { - free(szwPtr); - Fail("Unexpected error: CreateDirectoryW failed " - "with error code: %ld.\n", - GetLastError()); - } - - /* find out what the current "home" directory is */ - memset(szHomeDirBefore, 0, (_MAX_DIR+1)); - - if( 0 == GetCurrentDirectoryA((_MAX_DIR+1), szHomeDirBefore) ) - { - Trace("Unexpected error: Unable to get current directory " - "with GetCurrentDirectoryA that returned %ld\n", - GetLastError()); - - if (!RemoveDirectoryW(szwPtr)) - { - Trace("Unexpected error: RemoveDirectoryW failed " - "with error code: %ld.\n", - GetLastError()); - } - free(szwPtr); - - Fail(""); - } - - /* append the temp name to the "home" directory */ - memset(szBuiltDir, 0, (_MAX_DIR+1)); -#if WIN32 - sprintf_s(szBuiltDir, _countof(szBuiltDir),"%s\\..\\", szDirName); -#else - sprintf_s(szBuiltDir, _countof(szBuiltDir),"%s/../", szDirName); -#endif - - - /* set the current directory to the temp directory */ - if (SetCurrentDirectoryA(szBuiltDir) != TRUE) - { - Trace("ERROR: Unable to set current " - "directory to %s. Failed with error code: %ld.\n", - szBuiltDir, - GetLastError()); - - if (!RemoveDirectoryW(szwPtr)) - { - Trace("SetCurrentDirectoryA: ERROR -> RemoveDirectoryW failed " - "with error code: %ld.\n", - GetLastError()); - } - free(szwPtr); - Fail(""); - } - - /* find out what the current "home" directory is */ - memset(szHomeDirAfter, 0, (_MAX_DIR+1)); - - if( 0 == GetCurrentDirectoryA((_MAX_DIR+1), szHomeDirAfter) ) - { - Trace("Unexpected error: Unable to get current directory " - "with GetCurrentDirectoryA that returned %ld\n", - GetLastError()); - - if (!RemoveDirectoryW(szwPtr)) - { - Trace("Unexpected error: RemoveDirectoryW failed " - "with error code: %ld.\n", - GetLastError()); - } - free(szwPtr); - - Fail(""); - } - - /*compare the new current dir to the compiled current dir */ - if (strncmp(szHomeDirBefore, szHomeDirAfter, strlen(szHomeDirBefore)) != 0) - { - Trace("ERROR: The set directory \"%s\" does not " - "compare to the built directory \"%s\".\n", - szHomeDirAfter, - szHomeDirBefore); - - if (!RemoveDirectoryW(szwPtr)) - { - Trace("Unexpected error: RemoveDirectoryW failed " - "with error code: %ld.\n", - GetLastError()); - } - free(szwPtr); - Fail(""); - } - - /* clean up */ - if (!RemoveDirectoryW(szwPtr)) - { - free(szwPtr); - Fail("Unexpected error: RemoveDirectoryW failed " - "with error code: %ld.\n", - GetLastError()); - } - - free(szwPtr); - PAL_Terminate(); - - return PASS; -} - - diff --git a/src/pal/tests/palsuite/file_io/SetCurrentDirectoryA/test2/testinfo.dat b/src/pal/tests/palsuite/file_io/SetCurrentDirectoryA/test2/testinfo.dat deleted file mode 100644 index 677c48406..000000000 --- a/src/pal/tests/palsuite/file_io/SetCurrentDirectoryA/test2/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = SetCurrentDirectoryA -Name = Positive test for SetCurrentDirectoryA (test 2) -Type = DEFAULT -EXE1 = setcurrentdirectorya -Description -= Set the current directory with ../ and verify the results. diff --git a/src/pal/tests/palsuite/file_io/SetCurrentDirectoryA/test3/CMakeLists.txt b/src/pal/tests/palsuite/file_io/SetCurrentDirectoryA/test3/CMakeLists.txt deleted file mode 100644 index 7e2f3ada3..000000000 --- a/src/pal/tests/palsuite/file_io/SetCurrentDirectoryA/test3/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - setcurrentdirectorya.cpp -) - -add_executable(paltest_setcurrentdirectorya_test3 - ${SOURCES} -) - -add_dependencies(paltest_setcurrentdirectorya_test3 coreclrpal) - -target_link_libraries(paltest_setcurrentdirectorya_test3 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/SetCurrentDirectoryA/test3/setcurrentdirectorya.cpp b/src/pal/tests/palsuite/file_io/SetCurrentDirectoryA/test3/setcurrentdirectorya.cpp deleted file mode 100644 index a23a7a631..000000000 --- a/src/pal/tests/palsuite/file_io/SetCurrentDirectoryA/test3/setcurrentdirectorya.cpp +++ /dev/null @@ -1,56 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: SetCurrentDirectoryA.c (test 3) -** -** Purpose: Try calling SetCurrentDirectoryA with an invalid path, -** with a valid filename and with NULL -** -** -**===================================================================*/ - -#include - -int __cdecl main(int argc, char *argv[]) -{ - const char szDirName[MAX_PATH] = "testing"; - const char szFileName[MAX_PATH] = "setcurrentdirectorya.c"; - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - /* set the current directory to an unexistant folder */ - if (0 != SetCurrentDirectoryA(szDirName)) - { - Fail("ERROR: SetCurrentDirectoryA should have failed " - "when trying to set the current directory to " - "an invalid folder\n"); - } - - /* set the current directory to an unexistant folder */ - if (0 != SetCurrentDirectoryA(szFileName)) - { - Fail("ERROR: SetCurrentDirectoryA should have failed " - "when trying to set the current directory to " - "a valid file name\n"); - } - - /* set the current directory to NULL */ - if (0 != SetCurrentDirectoryA(NULL)) - { - Fail("ERROR: SetCurrentDirectoryA should have failed " - "when trying to set the current directory to " - "NULL\n"); - } - - PAL_Terminate(); - - return PASS; -} - - diff --git a/src/pal/tests/palsuite/file_io/SetCurrentDirectoryA/test3/testinfo.dat b/src/pal/tests/palsuite/file_io/SetCurrentDirectoryA/test3/testinfo.dat deleted file mode 100644 index d5520f799..000000000 --- a/src/pal/tests/palsuite/file_io/SetCurrentDirectoryA/test3/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = SetCurrentDirectoryA -Name = Negative test for SetCurrentDirectoryA (test 3) -Type = DEFAULT -EXE1 = setcurrentdirectorya -Description -= Try calling SetCurrentDirectoryA with an invalid path, -= with a valid filename and with NULL diff --git a/src/pal/tests/palsuite/file_io/SetCurrentDirectoryW/CMakeLists.txt b/src/pal/tests/palsuite/file_io/SetCurrentDirectoryW/CMakeLists.txt deleted file mode 100644 index 1962ade35..000000000 --- a/src/pal/tests/palsuite/file_io/SetCurrentDirectoryW/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) -add_subdirectory(test3) - diff --git a/src/pal/tests/palsuite/file_io/SetCurrentDirectoryW/test1/CMakeLists.txt b/src/pal/tests/palsuite/file_io/SetCurrentDirectoryW/test1/CMakeLists.txt deleted file mode 100644 index a68f87b5a..000000000 --- a/src/pal/tests/palsuite/file_io/SetCurrentDirectoryW/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - SetCurrentDirectoryW.cpp -) - -add_executable(paltest_setcurrentdirectoryw_test1 - ${SOURCES} -) - -add_dependencies(paltest_setcurrentdirectoryw_test1 coreclrpal) - -target_link_libraries(paltest_setcurrentdirectoryw_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/SetCurrentDirectoryW/test1/SetCurrentDirectoryW.cpp b/src/pal/tests/palsuite/file_io/SetCurrentDirectoryW/test1/SetCurrentDirectoryW.cpp deleted file mode 100644 index e10f2ea8a..000000000 --- a/src/pal/tests/palsuite/file_io/SetCurrentDirectoryW/test1/SetCurrentDirectoryW.cpp +++ /dev/null @@ -1,178 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: SetCurrentDirectoryW.c (test 1) -** -** Purpose: Tests the PAL implementation of the SetCurrentDirectoryW function. -** -** -**===================================================================*/ - -#include - -const char* szFileName = "blah"; -const char* szDirName = "testing"; - - -// In order to avoid the "chicken and egg" scenario, this is another -// method of getting the current directory. GetFullPathNameW is called with -// a dummy file name and then the file name is stripped off leaving the -// current working directory -BOOL GetCurrentDir(WCHAR* szwCurrentDir) -{ - DWORD dwRc = 0; - WCHAR szwReturnedPath[_MAX_DIR+1]; - LPWSTR pPathPtr; - WCHAR* szwFileName = NULL; - WCHAR* szwDirName = NULL; - int nCount = 0; - - // use GetFullPathName to to get the current path by stripping - // the file name off the end - memset(szwReturnedPath, 0, sizeof(WCHAR)*(_MAX_DIR+1)); - szwFileName = convert((char*)szFileName); - dwRc = GetFullPathNameW(szwFileName, - _MAX_DIR, - szwReturnedPath, - &pPathPtr); - - if (dwRc == 0) - { - // GetFullPathName failed - Trace("SetCurrentDirectoryW: ERROR -> GetFullPathNameW failed " - "with error code: %ld.\n", GetLastError()); - RemoveDirectoryW(szwDirName); - free(szwFileName); - return(FALSE); - } - - // now strip the file name from the full path to get the current path - nCount = lstrlenW(szwReturnedPath) - lstrlenW(szwFileName); - memset(szwCurrentDir, 0, sizeof(WCHAR)*(_MAX_DIR+1)); - wcsncpy(szwCurrentDir, szwReturnedPath, nCount - 1); - - free(szwFileName); - return(TRUE); -} - -int __cdecl main(int argc, char *argv[]) -{ - WCHAR* szwDirName = NULL; - WCHAR szwNewDir[_MAX_DIR+1]; - WCHAR szwBuiltDir[_MAX_DIR+1]; - WCHAR szwHomeDir[_MAX_DIR+1]; -#if WIN32 - WCHAR szwSlash[] = {'\\','\0'}; -#else - WCHAR szwSlash[] = {'/','\0'}; -#endif - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - // remove the directory just in case a previous run of the test didn't - szwDirName = convert((char*)szDirName); - RemoveDirectoryW(szwDirName); - - // create a temp directory off the current directory - if (CreateDirectoryW(szwDirName, NULL) != TRUE) - { - Trace("SetCurrentDirectoryW: ERROR -> CreateDirectoryW failed " - "with error code: %ld.\n", GetLastError()); - RemoveDirectoryW(szwDirName); - free(szwDirName); - Fail(""); - } - - // find out what the current "home" directory is - memset(szwHomeDir, 0, sizeof(WCHAR)*(_MAX_DIR+1)); - if(GetCurrentDir(szwHomeDir) != TRUE) - { - RemoveDirectoryW(szwDirName); - free(szwDirName); - PAL_TerminateEx(FAIL); - return FAIL; - } - - // set the current directory to the temp directory - if (SetCurrentDirectoryW(szwDirName) != TRUE) - { - Trace("SetCurrentDirectoryW: ERROR -> Unable to set current " - "directory. Failed with error code: %ld.\n", GetLastError()); - RemoveDirectoryW(szwDirName); - free(szwDirName); - Fail(""); - } - - // append the temp name to the "home" directory - memset(szwBuiltDir, 0, sizeof(WCHAR)*(_MAX_DIR+1)); - wcscpy(szwBuiltDir, szwHomeDir); - wcscat(szwBuiltDir, szwSlash); - wcscat(szwBuiltDir, szwDirName); - - // get the new current directory - memset(szwNewDir, 0, sizeof(WCHAR)*(_MAX_DIR+1)); - if(GetCurrentDir(szwNewDir) != TRUE) - { - RemoveDirectoryW(szwDirName); - free(szwDirName); - PAL_TerminateEx(FAIL); - return FAIL; - } - - // compare the new current dir to the compiled current dir - if (wcsncmp(szwNewDir, szwBuiltDir, wcslen(szwNewDir)) != 0) - { - RemoveDirectoryW(szwDirName); - free(szwDirName); - Fail("SetCurrentDirectoryW: ERROR -> The set directory does not " - "compare to the built directory.\n"); - } - - - - // set the current dir back to the original - if (SetCurrentDirectoryW(szwHomeDir) != TRUE) - { - Trace("SetCurrentDirectoryW: ERROR -> Unable to set current " - "directory. Failed with error code: %ld.\n", GetLastError()); - RemoveDirectoryW(szwDirName); - free(szwDirName); - Fail(""); - } - - - // get the new current directory - memset(szwNewDir, 0, sizeof(WCHAR)*(_MAX_DIR+1)); - if(GetCurrentDir(szwNewDir) != TRUE) - { - RemoveDirectoryW(szwDirName); - free(szwDirName); - PAL_TerminateEx(FAIL); - return FAIL; - } - - // ensure it compares to the "home" directory which is where - // we should be now - if (wcsncmp(szwNewDir, szwHomeDir, wcslen(szwNewDir)) != 0) - { - RemoveDirectoryW(szwDirName); - free(szwDirName); - Fail("SetCurrentDirectoryW: ERROR -> The set directory does not " - "compare to the built directory.\n"); - } - - - RemoveDirectoryW(szwDirName); - free(szwDirName); - PAL_Terminate(); - - return PASS; -} - - diff --git a/src/pal/tests/palsuite/file_io/SetCurrentDirectoryW/test1/testinfo.dat b/src/pal/tests/palsuite/file_io/SetCurrentDirectoryW/test1/testinfo.dat deleted file mode 100644 index 3a63887e0..000000000 --- a/src/pal/tests/palsuite/file_io/SetCurrentDirectoryW/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = SetCurrentDirectoryW -Name = Test for SetCurrentDirectoryW (test 1) -Type = DEFAULT -EXE1 = setcurrentdirectoryw -Description -= Change the current directory and verify the results. - diff --git a/src/pal/tests/palsuite/file_io/SetCurrentDirectoryW/test2/CMakeLists.txt b/src/pal/tests/palsuite/file_io/SetCurrentDirectoryW/test2/CMakeLists.txt deleted file mode 100644 index 9cc5ba1a5..000000000 --- a/src/pal/tests/palsuite/file_io/SetCurrentDirectoryW/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - setcurrentdirectoryw.cpp -) - -add_executable(paltest_setcurrentdirectoryw_test2 - ${SOURCES} -) - -add_dependencies(paltest_setcurrentdirectoryw_test2 coreclrpal) - -target_link_libraries(paltest_setcurrentdirectoryw_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/SetCurrentDirectoryW/test2/setcurrentdirectoryw.cpp b/src/pal/tests/palsuite/file_io/SetCurrentDirectoryW/test2/setcurrentdirectoryw.cpp deleted file mode 100644 index 7f833baab..000000000 --- a/src/pal/tests/palsuite/file_io/SetCurrentDirectoryW/test2/setcurrentdirectoryw.cpp +++ /dev/null @@ -1,147 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: SetCurrentDirectoryW.c (test 2) -** -** Purpose: Tests the PAL implementation of the SetCurrentDirectoryW function -** by setting the current directory with ../ -** -** -**===================================================================*/ - -#include - -int __cdecl main(int argc, char *argv[]) -{ - const char szDirName[MAX_PATH] = "testing"; - char szBuiltDir[MAX_PATH]; - WCHAR* szwBuiltDir = NULL; - WCHAR szwHomeDirBefore[MAX_PATH]; - WCHAR szwHomeDirAfter[MAX_PATH]; - WCHAR* szwPtr = NULL; - - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - /* create a temp directory off the current directory */ - szwPtr = convert((LPSTR)szDirName); - - if (CreateDirectoryW(szwPtr, NULL) != TRUE) - { - free(szwPtr); - Fail("Unexpected error: CreateDirectoryW failed " - "with error code: %ld.\n", - GetLastError()); - } - - /* find out what the current "home" directory is */ - memset(szwHomeDirBefore, 0, MAX_PATH * sizeof(WCHAR)); - - if( 0 == GetCurrentDirectoryW(MAX_PATH, szwHomeDirBefore) ) - { - Trace("Unexpected error: Unable to get current directory " - "with GetCurrentDirectoryW that returned %ld\n", - GetLastError()); - - if (!RemoveDirectoryW(szwPtr)) - { - Trace("Unexpected error: RemoveDirectoryW failed " - "with error code: %ld.\n", - GetLastError()); - } - free(szwPtr); - - Fail(""); - } - - /* append the temp name to the "home" directory */ - memset(szBuiltDir, 0, MAX_PATH); -#if WIN32 - sprintf_s(szBuiltDir, _countof(szBuiltDir),"%s\\..\\", szDirName); -#else - sprintf_s(szBuiltDir, _countof(szBuiltDir),"%s/../", szDirName); -#endif - - szwBuiltDir = convert(szBuiltDir); - - /* set the current directory to the temp directory */ - if (SetCurrentDirectoryW(szwBuiltDir) != TRUE) - { - Trace("ERROR: Unable to set current " - "directory to %S. Failed with error code: %ld.\n", - szwBuiltDir, - GetLastError()); - - if (!RemoveDirectoryW(szwPtr)) - { - Trace("Unexpected error: RemoveDirectoryW failed " - "with error code: %ld.\n", - GetLastError()); - } - free(szwPtr); - free(szwBuiltDir); - Fail(""); - } - - free(szwBuiltDir); - - /* find out what the current "home" directory is */ - memset(szwHomeDirAfter, 0, MAX_PATH * sizeof(WCHAR)); - - if( 0 == GetCurrentDirectoryW(MAX_PATH, szwHomeDirAfter) ) - { - Trace("Unexpected error: Unable to get current directory " - "with GetCurrentDirectoryW that returned %ld\n", - GetLastError()); - - if (!RemoveDirectoryW(szwPtr)) - { - Trace("ERROR: RemoveDirectoryW failed " - "with error code: %ld.\n", - GetLastError()); - } - free(szwPtr); - - Fail(""); - } - - /*compare the new current dir to the compiled current dir */ - if (wcsncmp(szwHomeDirBefore, szwHomeDirAfter, wcslen(szwHomeDirBefore)) != 0) - { - Trace("ERROR:The set directory \"%S\" does not " - "compare to the built directory \"%S\".\n", - szwHomeDirAfter, - szwHomeDirBefore); - - if (!RemoveDirectoryW(szwPtr)) - { - Trace("Unexpected error: RemoveDirectoryW failed " - "with error code: %ld.\n", - GetLastError()); - } - free(szwPtr); - Fail(""); - } - - /* clean up */ - if (!RemoveDirectoryW(szwPtr)) - { - free(szwPtr); - Fail("Unexpected error: RemoveDirectoryW failed " - "with error code: %ld.\n", - GetLastError()); - } - - free(szwPtr); - PAL_Terminate(); - - return PASS; -} - - diff --git a/src/pal/tests/palsuite/file_io/SetCurrentDirectoryW/test2/testinfo.dat b/src/pal/tests/palsuite/file_io/SetCurrentDirectoryW/test2/testinfo.dat deleted file mode 100644 index a739688d4..000000000 --- a/src/pal/tests/palsuite/file_io/SetCurrentDirectoryW/test2/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = SetCurrentDirectoryW -Name = Positive test for SetCurrentDirectoryW (test 2) -Type = DEFAULT -EXE1 = setcurrentdirectoryw -Description -= Set the current directory with ../ and verify the results. diff --git a/src/pal/tests/palsuite/file_io/SetCurrentDirectoryW/test3/CMakeLists.txt b/src/pal/tests/palsuite/file_io/SetCurrentDirectoryW/test3/CMakeLists.txt deleted file mode 100644 index 06da5a810..000000000 --- a/src/pal/tests/palsuite/file_io/SetCurrentDirectoryW/test3/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - setcurrentdirectoryw.cpp -) - -add_executable(paltest_setcurrentdirectoryw_test3 - ${SOURCES} -) - -add_dependencies(paltest_setcurrentdirectoryw_test3 coreclrpal) - -target_link_libraries(paltest_setcurrentdirectoryw_test3 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/SetCurrentDirectoryW/test3/setcurrentdirectoryw.cpp b/src/pal/tests/palsuite/file_io/SetCurrentDirectoryW/test3/setcurrentdirectoryw.cpp deleted file mode 100644 index e8c4be2ad..000000000 --- a/src/pal/tests/palsuite/file_io/SetCurrentDirectoryW/test3/setcurrentdirectoryw.cpp +++ /dev/null @@ -1,64 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: SetCurrentDirectoryW.c (test 3) -** -** Purpose: Try calling SetCurrentDirectoryW with an invalid path, -** with a valid filename and with NULL -** -** -**===================================================================*/ - -#include - -int __cdecl main(int argc, char *argv[]) -{ - char szDirName[MAX_PATH] = "testing"; - WCHAR* szwDirName = NULL; - char szFileName[MAX_PATH] = "setcurrentdirectorya.c"; - WCHAR* szwFileName = NULL; - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - /* set the current directory to an unexistant folder */ - szwDirName = convert(szDirName); - if (0 != SetCurrentDirectoryW(szwDirName)) - { - free(szwDirName); - Fail("ERROR: SetCurrentDirectoryW should have failed " - "when trying to set the current directory to " - "an invalid folder\n"); - } - free(szwDirName); - - /* set the current directory to an unexistant folder */ - szwFileName = convert(szFileName); - if (0 != SetCurrentDirectoryW(szwFileName)) - { - free(szwFileName); - Fail("ERROR: SetCurrentDirectoryW should have failed " - "when trying to set the current directory to " - "a valid file name\n"); - } - free(szwFileName); - - /* set the current directory to NULL */ - if (0 != SetCurrentDirectoryW(NULL)) - { - Fail("ERROR: SetCurrentDirectoryW should have failed " - "when trying to set the current directory to " - "NULL\n"); - } - - PAL_Terminate(); - - return PASS; -} - - diff --git a/src/pal/tests/palsuite/file_io/SetCurrentDirectoryW/test3/testinfo.dat b/src/pal/tests/palsuite/file_io/SetCurrentDirectoryW/test3/testinfo.dat deleted file mode 100644 index fc931291e..000000000 --- a/src/pal/tests/palsuite/file_io/SetCurrentDirectoryW/test3/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = SetCurrentDirectoryW -Name = Negative test for SetCurrentDirectoryW (test 3) -Type = DEFAULT -EXE1 = setcurrentdirectoryw -Description -= Try calling SetCurrentDirectoryW with an invalid path, -= with a valid filename and with NULL diff --git a/src/pal/tests/palsuite/file_io/SetEndOfFile/CMakeLists.txt b/src/pal/tests/palsuite/file_io/SetEndOfFile/CMakeLists.txt deleted file mode 100644 index 8083faf65..000000000 --- a/src/pal/tests/palsuite/file_io/SetEndOfFile/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) -add_subdirectory(test3) -add_subdirectory(test4) -add_subdirectory(test5) - diff --git a/src/pal/tests/palsuite/file_io/SetEndOfFile/test1/CMakeLists.txt b/src/pal/tests/palsuite/file_io/SetEndOfFile/test1/CMakeLists.txt deleted file mode 100644 index 5d9e8c061..000000000 --- a/src/pal/tests/palsuite/file_io/SetEndOfFile/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - SetEndOfFile.cpp -) - -add_executable(paltest_setendoffile_test1 - ${SOURCES} -) - -add_dependencies(paltest_setendoffile_test1 coreclrpal) - -target_link_libraries(paltest_setendoffile_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/SetEndOfFile/test1/SetEndOfFile.cpp b/src/pal/tests/palsuite/file_io/SetEndOfFile/test1/SetEndOfFile.cpp deleted file mode 100644 index 9078ddc65..000000000 --- a/src/pal/tests/palsuite/file_io/SetEndOfFile/test1/SetEndOfFile.cpp +++ /dev/null @@ -1,85 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: SetEndOfFile.c (test 1) -** -** Purpose: Tests the PAL implementation of the SetEndOfFile function. -** This test will attempt to operate on a NULL file handle and -** also test truncating a file not opened with GENERIC_WRITE -** -** Assumes successful: -** SetEndOfFile -** CreateFile -** CloseHandle -** - -** -**===================================================================*/ - -#include - -const char* szTextFile = "text.txt"; - - -int __cdecl main(int argc, char *argv[]) -{ - HANDLE hFile = NULL; - BOOL bRc = FALSE; - - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - bRc = SetEndOfFile(NULL); - if (bRc == TRUE) - { - Fail("SetEndOfFile: ERROR -> Operation succeeded on a NULL file " - "handle\n"); - } - - /* create a test file */ - hFile = CreateFile(szTextFile, - GENERIC_READ, - FILE_SHARE_READ, - NULL, - OPEN_ALWAYS, - FILE_ATTRIBUTE_NORMAL, - NULL); - - if(hFile == INVALID_HANDLE_VALUE) - { - Fail("SetEndOfFile: ERROR -> Unable to create file \"%s\".\n", - szTextFile); - } - - bRc = SetEndOfFile(hFile); - if (bRc == TRUE) - { - Trace("SetEndOfFile: ERROR -> Operation succeeded on read-only" - " file.\n"); - bRc = CloseHandle(hFile); - if (bRc != TRUE) - { - Trace("SetEndOfFile: ERROR -> Unable to close file \"%s\".\n", - szTextFile); - } - PAL_TerminateEx(FAIL); - return FAIL; - } - - bRc = CloseHandle(hFile); - if (bRc != TRUE) - { - Fail("SetEndOfFile: ERROR -> Unable to close file \"%s\".\n", - szTextFile); - } - - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/file_io/SetEndOfFile/test1/testinfo.dat b/src/pal/tests/palsuite/file_io/SetEndOfFile/test1/testinfo.dat deleted file mode 100644 index 72fc5e59e..000000000 --- a/src/pal/tests/palsuite/file_io/SetEndOfFile/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = SetEndOfFile -Name = Positive Test for SetEndOfFile -Type = DEFAULT -EXE1 = setendoffile -Description -=Truncate a file - diff --git a/src/pal/tests/palsuite/file_io/SetEndOfFile/test2/CMakeLists.txt b/src/pal/tests/palsuite/file_io/SetEndOfFile/test2/CMakeLists.txt deleted file mode 100644 index 47aa96c18..000000000 --- a/src/pal/tests/palsuite/file_io/SetEndOfFile/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - SetEndOfFile.cpp -) - -add_executable(paltest_setendoffile_test2 - ${SOURCES} -) - -add_dependencies(paltest_setendoffile_test2 coreclrpal) - -target_link_libraries(paltest_setendoffile_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/SetEndOfFile/test2/SetEndOfFile.cpp b/src/pal/tests/palsuite/file_io/SetEndOfFile/test2/SetEndOfFile.cpp deleted file mode 100644 index 6b3c05088..000000000 --- a/src/pal/tests/palsuite/file_io/SetEndOfFile/test2/SetEndOfFile.cpp +++ /dev/null @@ -1,154 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: SetEndOfFile.c (test 2) -** -** Purpose: Tests the PAL implementation of the SetEndOfFile function. -** This test will attempt to truncate a file -** -** -**===================================================================*/ - -#include - - -const char* szStringTest = "The quick fox jumped over the lazy dog's back."; -const char* szTextFile = "text.txt"; - - -int __cdecl main(int argc, char *argv[]) -{ - HANDLE hFile = NULL; - DWORD dwByteCount = 0; - DWORD dwBytesWritten; - BOOL bRc = FALSE; - char szBuffer[100]; - DWORD dwBytesRead = 0; - FILE *pFile = NULL; - - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - // create a test file - hFile = CreateFile(szTextFile, - GENERIC_READ | GENERIC_WRITE, - FILE_SHARE_READ | FILE_SHARE_WRITE, - NULL, - OPEN_ALWAYS, - FILE_ATTRIBUTE_NORMAL, - NULL); - - if(hFile == INVALID_HANDLE_VALUE) - { - Fail("SetEndOfFile: ERROR -> Unable to create file \"%s\".\n", - szTextFile); - } - - bRc = WriteFile(hFile, szStringTest, 20, &dwBytesWritten, NULL); - if (bRc != TRUE) - { - Trace("SetEndOfFile: ERROR -> Uable to write to \"%s\".\n", - szTextFile); - bRc = CloseHandle(hFile); - if (bRc != TRUE) - { - Trace("SetEndOfFile: ERROR -> Unable to close file \"%s\".\n", - szTextFile); - } - PAL_TerminateEx(FAIL); - return FAIL; - } - - bRc = CloseHandle(hFile); - if (bRc != TRUE) - { - Fail("SetEndOfFile: ERROR -> Unable to close file \"%s\".\n", - szTextFile); - } - - // open the test file - hFile = CreateFile(szTextFile, - GENERIC_READ | GENERIC_WRITE, - FILE_SHARE_READ | FILE_SHARE_WRITE, - NULL, - OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL, - NULL); - - if(hFile == INVALID_HANDLE_VALUE) - { - Fail("SetEndOfFile: ERROR -> Unable to open file \"%s\".\n", - szTextFile); - } - - // read a bit of the file to move the file pointer - dwByteCount = 10; - bRc = ReadFile(hFile, szBuffer, dwByteCount, &dwBytesRead, NULL); - if (bRc != TRUE) - { - Trace("SetEndOfFile: ERROR -> Uable to read from \"%s\".\n", - szTextFile); - bRc = CloseHandle(hFile); - if (bRc != TRUE) - { - Trace("SetEndOfFile: ERROR -> Unable to close file \"%s\".\n", - szTextFile); - } - PAL_TerminateEx(FAIL); - return FAIL; - } - - bRc = SetEndOfFile(hFile); - if (bRc != TRUE) - { - Trace("SetEndOfFile: ERROR -> Uable to set end of file.\n"); - bRc = CloseHandle(hFile); - if (bRc != TRUE) - { - Trace("SetEndOfFile: ERROR -> Unable to close file \"%s\".\n", - szTextFile); - } - PAL_TerminateEx(FAIL); - return FAIL; - } - - bRc = CloseHandle(hFile); - if (bRc != TRUE) - { - Fail("SetEndOfFile: ERROR -> Unable to close file \"%s\".\n", - szTextFile); - } - - // open and read the test file - pFile = fopen(szTextFile, "r"); - if (pFile == NULL) - { - Fail("SetEndOfFile: ERROR -> fopen was unable to open file \"%s\".\n", - szTextFile); - } - - // since we truncated the file at 10 characters, - // try reading 20 just to be safe - memset(szBuffer, 0, 100); - fgets(szBuffer, 20, pFile); - fclose(pFile); - if (strlen(szBuffer) != dwByteCount) - { - Fail("SetEndOfFile: ERROR -> file apparently not truncated at " - "correct position.\n"); - } - if (strncmp(szBuffer, szStringTest, dwByteCount) != 0) - { - Fail("SetEndOfFile: ERROR -> truncated file contents doesn't " - "compare with what should be there\n"); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/file_io/SetEndOfFile/test2/testinfo.dat b/src/pal/tests/palsuite/file_io/SetEndOfFile/test2/testinfo.dat deleted file mode 100644 index 555f0d823..000000000 --- a/src/pal/tests/palsuite/file_io/SetEndOfFile/test2/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = SetEndOfFile -Name = Positive Test for SetEndOfFile -Type = DEFAULT -EXE1 = setendoffile -Description -=Truncate the test file using SetEndOfFile diff --git a/src/pal/tests/palsuite/file_io/SetEndOfFile/test3/CMakeLists.txt b/src/pal/tests/palsuite/file_io/SetEndOfFile/test3/CMakeLists.txt deleted file mode 100644 index 87a2a47a6..000000000 --- a/src/pal/tests/palsuite/file_io/SetEndOfFile/test3/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - SetEndOfFile.cpp -) - -add_executable(paltest_setendoffile_test3 - ${SOURCES} -) - -add_dependencies(paltest_setendoffile_test3 coreclrpal) - -target_link_libraries(paltest_setendoffile_test3 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/SetEndOfFile/test3/SetEndOfFile.cpp b/src/pal/tests/palsuite/file_io/SetEndOfFile/test3/SetEndOfFile.cpp deleted file mode 100644 index dfd919446..000000000 --- a/src/pal/tests/palsuite/file_io/SetEndOfFile/test3/SetEndOfFile.cpp +++ /dev/null @@ -1,109 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: SetEndOfFile.c (test 3) -** -** Purpose: Tests the PAL implementation of the SetEndOfFile function. -** This test will attempt to expand a file. Assumes successful -** SetFilePointer and GetFileSize tests. -** -** -**===================================================================*/ - -#include - - -const char* szTextFile = "text.txt"; - - -int __cdecl main(int argc, char *argv[]) -{ - HANDLE hFile = NULL; - DWORD dwByteCount = 0; - DWORD dwOffset = 25; - DWORD dwRc = 0; - BOOL bRc = FALSE; - - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - /* create a test file */ - hFile = CreateFile(szTextFile, - GENERIC_READ | GENERIC_WRITE, - FILE_SHARE_READ | FILE_SHARE_WRITE, - NULL, - CREATE_ALWAYS, - FILE_ATTRIBUTE_NORMAL, - NULL); - - if(hFile == INVALID_HANDLE_VALUE) - { - Fail("SetEndOfFile: ERROR -> Unable to create file \"%s\".\n", - szTextFile); - } - - /* move the file pointer */ - /* assumes a successful SetFilePointer test */ - dwRc = SetFilePointer(hFile, dwOffset, NULL, FILE_BEGIN); - if (dwRc == INVALID_SET_FILE_POINTER) - { - Trace("SetEndOfFile: ERROR -> Call to SetFilePointer failed\n"); - bRc = CloseHandle(hFile); - if (bRc != TRUE) - { - Trace("SetEndOfFile: ERROR -> Unable to close file \"%s\".\n", - szTextFile); - } - PAL_Terminate(); - return FAIL; - } - - bRc = SetEndOfFile(hFile); - if (bRc != TRUE) - { - Trace("SetEndOfFile: ERROR -> Uable to set end of file.\n"); - bRc = CloseHandle(hFile); - if (bRc != TRUE) - { - Trace("SetEndOfFile: ERROR -> Unable to close file \"%s\".\n", - szTextFile); - } - PAL_TerminateEx(FAIL); - return FAIL; - } - - - /* call GetFileSize to verify pointer position */ - /* assumes a successful GetFileSize test */ - - dwByteCount = GetFileSize(hFile, NULL); - if (dwByteCount != dwOffset) - { - Trace("SetEndOfFile: ERROR -> file apparently not expanded to the" - " correct size.\n"); - bRc = CloseHandle(hFile); - if (bRc != TRUE) - { - Trace("SetEndOfFile: ERROR -> Unable to close file \"%s\".\n", - szTextFile); - } - PAL_TerminateEx(FAIL); - return FAIL; - } - - bRc = CloseHandle(hFile); - if (bRc != TRUE) - { - Fail("SetEndOfFile: ERROR -> Unable to close file \"%s\".\n", - szTextFile); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/file_io/SetEndOfFile/test3/testinfo.dat b/src/pal/tests/palsuite/file_io/SetEndOfFile/test3/testinfo.dat deleted file mode 100644 index 7f3868d6c..000000000 --- a/src/pal/tests/palsuite/file_io/SetEndOfFile/test3/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = SetEndOfFile -Name = Positive Test for SetEndOfFile -Type = DEFAULT -EXE1 = setendoffile -Description -=Set the end of file past the actual end -=of file thereby, extending it. - diff --git a/src/pal/tests/palsuite/file_io/SetEndOfFile/test4/CMakeLists.txt b/src/pal/tests/palsuite/file_io/SetEndOfFile/test4/CMakeLists.txt deleted file mode 100644 index ca5f00fe2..000000000 --- a/src/pal/tests/palsuite/file_io/SetEndOfFile/test4/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - setendoffile.cpp -) - -add_executable(paltest_setendoffile_test4 - ${SOURCES} -) - -add_dependencies(paltest_setendoffile_test4 coreclrpal) - -target_link_libraries(paltest_setendoffile_test4 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/SetEndOfFile/test4/setendoffile.cpp b/src/pal/tests/palsuite/file_io/SetEndOfFile/test4/setendoffile.cpp deleted file mode 100644 index 98a6ec63d..000000000 --- a/src/pal/tests/palsuite/file_io/SetEndOfFile/test4/setendoffile.cpp +++ /dev/null @@ -1,138 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: setendoffile.c (test 4) -** -** Purpose: Tests the PAL implementation of the SetEndOfFile function. -** Verify that the file pointer is the same before -** and after a SetEndOfFile using SetFilePointer with -** FILE_BEGIN, FILE_CURRENT and FILE_END -** -** -**===================================================================*/ - -#include - - -const char* szStringTest = "The quick fox jumped over the lazy dog's back."; -const char* szTextFile = "test.tmp"; - -static void Cleanup(HANDLE hFile) -{ - if (!CloseHandle(hFile)) - { - Trace("SetEndOfFile: ERROR -> Unable to close file \"%s\". ", - "GetLastError returned %u.\n", - szTextFile, - GetLastError()); - } - if (!DeleteFileA(szTextFile)) - { - Trace("SetEndOfFile: ERROR -> Unable to delete file \"%s\". ", - "GetLastError returned %u.\n", - szTextFile, - GetLastError()); - } -} - -static void DoTest(HANDLE hFile, DWORD dwOffset, DWORD dwMethod) -{ - DWORD dwFP1 = 0; - DWORD dwFP2 = 0; - DWORD dwError; - - /* set the pointer*/ - dwFP1 = SetFilePointer(hFile, dwOffset, NULL, dwMethod); - if ((dwFP1 == INVALID_SET_FILE_POINTER) && - ((dwError = GetLastError()) != ERROR_SUCCESS)) - { - Trace("SetEndOfFile: ERROR -> Unable to set the pointer to the " - "end of the file. GetLastError returned %u.\n", - dwError); - Cleanup(hFile); - Fail(""); - } - - /* set EOF */ - if (!SetEndOfFile(hFile)) - { - Trace("SetEndOfFile: ERROR -> Unable to set end of file. " - "GetLastError returned %u.\n", - GetLastError()); - Cleanup(hFile); - Fail(""); - } - - /* get current file pointer pointer */ - dwFP2 = SetFilePointer(hFile, 0, NULL, FILE_CURRENT); - if ((dwFP1 == INVALID_SET_FILE_POINTER) && - ((dwError = GetLastError()) != ERROR_SUCCESS)) - { - Trace("SetEndOfFile: ERROR -> Unable to set the pointer to the " - "end of the file. GetLastError returned %u.\n", - dwError); - Cleanup(hFile); - Fail(""); - } - - /* are they the same? */ - if (dwFP1 != dwFP2) - { - Trace("SetEndOfFile: ERROR -> File pointer before (%u) the " - "SetEndOfFile call was different than after (%u).\n", - dwFP1, - dwFP2); - Cleanup(hFile); - Fail(""); - } -} - -int __cdecl main(int argc, char *argv[]) -{ - HANDLE hFile = NULL; - DWORD dwBytesWritten; - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - /* create a test file */ - hFile = CreateFile(szTextFile, - GENERIC_READ | GENERIC_WRITE, - FILE_SHARE_READ | FILE_SHARE_WRITE, - NULL, - OPEN_ALWAYS, - FILE_ATTRIBUTE_NORMAL, - NULL); - - if(hFile == INVALID_HANDLE_VALUE) - { - Fail("SetEndOfFile: ERROR -> Unable to create file \"%s\". " - "GetLastError returned %u.\n", - szTextFile, - GetLastError()); - } - - if (!WriteFile(hFile, szStringTest, strlen(szStringTest), &dwBytesWritten, NULL)) - { - Trace("SetEndOfFile: ERROR -> Unable to write to \"%s\". ", - "GetLastError returned %u.\n", - szTextFile, - GetLastError()); - Cleanup(hFile); - Fail(""); - } - - DoTest(hFile, -2, FILE_END); /* test the end */ - DoTest(hFile, -10, FILE_CURRENT); /* test the middle-ish */ - DoTest(hFile, 0, FILE_BEGIN); /* test the start */ - - Cleanup(hFile); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/file_io/SetEndOfFile/test4/testinfo.dat b/src/pal/tests/palsuite/file_io/SetEndOfFile/test4/testinfo.dat deleted file mode 100644 index 51d918534..000000000 --- a/src/pal/tests/palsuite/file_io/SetEndOfFile/test4/testinfo.dat +++ /dev/null @@ -1,15 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = SetEndOfFile -Name = Positive Test for SetEndOfFile (test 4) -Type = DEFAULT -EXE1 = setendoffile -Description -= Tests the PAL implementation of the SetEndOfFile function. -= Verify that the file pointer is the same before -= and after a SetEndOfFile using SetFilePointer with -= FILE_BEGIN, FILE_CURRENT and FILE_END diff --git a/src/pal/tests/palsuite/file_io/SetEndOfFile/test5/CMakeLists.txt b/src/pal/tests/palsuite/file_io/SetEndOfFile/test5/CMakeLists.txt deleted file mode 100644 index 390ee11f4..000000000 --- a/src/pal/tests/palsuite/file_io/SetEndOfFile/test5/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test5.cpp -) - -add_executable(paltest_setendoffile_test5 - ${SOURCES} -) - -add_dependencies(paltest_setendoffile_test5 coreclrpal) - -target_link_libraries(paltest_setendoffile_test5 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/SetEndOfFile/test5/test5.cpp b/src/pal/tests/palsuite/file_io/SetEndOfFile/test5/test5.cpp deleted file mode 100644 index 7000d1af1..000000000 --- a/src/pal/tests/palsuite/file_io/SetEndOfFile/test5/test5.cpp +++ /dev/null @@ -1,183 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test5.c -** -** Purpose: Tests the PAL implementation of the SetEndOfFile function. -** Test attempts to read the number of characters up to -** the EOF pointer, which was specified. -** -** -**===================================================================*/ - -#include - -int __cdecl main(int argc, char *argv[]) -{ - HANDLE hFile = NULL; - DWORD dwBytesWritten; - DWORD retCode; - BOOL bRc = FALSE; - char szBuffer[256]; - DWORD dwBytesRead = 0; - char testFile[] = "testfile.tmp"; - char testString[] = "watch what happens"; - LONG shiftAmount = 10; - - /* Initialize the PAL. - */ - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - /* Initialize the buffer. - */ - memset(szBuffer, 0, 256); - - /* Create a file to test with. - */ - hFile = CreateFile(testFile, - GENERIC_WRITE|GENERIC_READ, - FILE_SHARE_WRITE|FILE_SHARE_READ, - NULL, - CREATE_ALWAYS, - FILE_ATTRIBUTE_NORMAL, - NULL); - - if(hFile == INVALID_HANDLE_VALUE) - { - Fail("ERROR:%u: Unable to create file \"%s\".\n", - GetLastError(), - testFile); - } - - /* Write to the File handle. - */ - bRc = WriteFile(hFile, - testString, - strlen(testString), - &dwBytesWritten, - NULL); - - if (bRc == FALSE) - { - Trace("ERROR:%u: Unable to write to file handle " - "hFile=0x%lx\n", - GetLastError(), - hFile); - if (!CloseHandle(hFile)) - { - Fail("ERROR:%u%: Unable to close handle 0x%lx.\n", - GetLastError(), - hFile); - } - Fail(""); - } - - /* Set the file pointer to shiftAmount bytes from the front of the file - */ - retCode = SetFilePointer(hFile, shiftAmount, NULL, FILE_BEGIN); - if(retCode == INVALID_SET_FILE_POINTER) - { - Trace("ERROR:%u: Unable to set the file pointer to %d\n", - GetLastError(), - shiftAmount); - if (!CloseHandle(hFile)) - { - Fail("ERROR:%u%: Unable to close handle 0x%lx.\n", - GetLastError(), - hFile); - } - Fail(""); - } - - /* set the end of file pointer to 'shiftAmount' */ - bRc = SetEndOfFile(hFile); - if (bRc == FALSE) - { - Trace("ERROR:%u: Unable to set file pointer of file handle 0x%lx.\n", - GetLastError(), - hFile); - if (!CloseHandle(hFile)) - { - Fail("ERROR:%u%: Unable to close handle 0x%lx.\n", - GetLastError(), - hFile); - } - Fail(""); - } - - /* Set the file pointer to 10 bytes from the front of the file - */ - retCode = SetFilePointer(hFile, (LONG)NULL, NULL, FILE_BEGIN); - if(retCode == INVALID_SET_FILE_POINTER) - { - Trace("ERROR:%u: Unable to set the file pointer to %d\n", - GetLastError(), - FILE_BEGIN); - if (!CloseHandle(hFile)) - { - Fail("ERROR:%u%: Unable to close handle 0x%lx.\n", - GetLastError(), - hFile); - } - Fail(""); - } - - /* Attempt to read the entire string, 'testString' from a file - * that has it's end of pointer set at shiftAmount; - */ - bRc = ReadFile(hFile, - szBuffer, - strlen(testString), - &dwBytesRead, - NULL); - - if (bRc == FALSE) - { - Trace("ERROR:%u: Unable to read from file handle 0x%lx.\n", - GetLastError(), - hFile); - if (!CloseHandle(hFile)) - { - Fail("ERROR:%u%: Unable to close handle 0x%lx.\n", - GetLastError(), - hFile); - } - Fail(""); - } - - /* Confirm the number of bytes read with that requested. - */ - if (dwBytesRead != shiftAmount) - { - Trace("ERROR: The number of bytes read \"%d\" is not equal to the " - "number that should have been written \"%d\".\n", - dwBytesRead, - shiftAmount); - if (!CloseHandle(hFile)) - { - Fail("ERROR:%u%: Unable to close handle 0x%lx.\n", - GetLastError(), - hFile); - } - Fail(""); - } - - bRc = CloseHandle(hFile); - if(!bRc) - { - Fail("ERROR:%u CloseHandle failed to close the handle\n", - GetLastError()); - } - - /* Terminate the PAL. - */ - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/file_io/SetEndOfFile/test5/testinfo.dat b/src/pal/tests/palsuite/file_io/SetEndOfFile/test5/testinfo.dat deleted file mode 100644 index 3a226ff8a..000000000 --- a/src/pal/tests/palsuite/file_io/SetEndOfFile/test5/testinfo.dat +++ /dev/null @@ -1,16 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = SetEndOfFile -Name = Positive Test for SetEndOfFile -Type = DEFAULT -EXE1 = test5 -Description -= Tests the PAL implementation of the SetEndOfFile function. -= Test attempts to set the end of file pointer to a position -= which has data before and after it. Then it attempts to -= read text beyond the end of file pointer. - diff --git a/src/pal/tests/palsuite/file_io/SetFileAttributesA/CMakeLists.txt b/src/pal/tests/palsuite/file_io/SetFileAttributesA/CMakeLists.txt deleted file mode 100644 index a3847f8ca..000000000 --- a/src/pal/tests/palsuite/file_io/SetFileAttributesA/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) -add_subdirectory(test3) -add_subdirectory(test4) - diff --git a/src/pal/tests/palsuite/file_io/SetFileAttributesA/test1/CMakeLists.txt b/src/pal/tests/palsuite/file_io/SetFileAttributesA/test1/CMakeLists.txt deleted file mode 100644 index b287ceca6..000000000 --- a/src/pal/tests/palsuite/file_io/SetFileAttributesA/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - SetFileAttributesA.cpp -) - -add_executable(paltest_setfileattributesa_test1 - ${SOURCES} -) - -add_dependencies(paltest_setfileattributesa_test1 coreclrpal) - -target_link_libraries(paltest_setfileattributesa_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/SetFileAttributesA/test1/SetFileAttributesA.cpp b/src/pal/tests/palsuite/file_io/SetFileAttributesA/test1/SetFileAttributesA.cpp deleted file mode 100644 index bacab2a0a..000000000 --- a/src/pal/tests/palsuite/file_io/SetFileAttributesA/test1/SetFileAttributesA.cpp +++ /dev/null @@ -1,168 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: SetFileAttributesA.c -** -** -** Purpose: Tests the PAL implementation of the SetFileAttributesA function -** Test that we can set a file READONLY, and then that we're unable to -** open that file with WRITE access. Then change it to NORMAL attributes, and -** try to open it again -- it should work now. -** -** Depends: -** CreateFile -** CloseHandle -** -** -**===================================================================*/ - -/* According to the spec, only READONLY attribute can be set - in FreeBSD. -*/ - -#include - - - -int __cdecl main(int argc, char **argv) -{ - DWORD TheResult; - HANDLE TheFile; - char* FileName = {"test_file"}; - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - // Create the test file - FILE *testFile = fopen(FileName, "w"); - if (testFile == NULL) - { - Fail("Unexpected error: Unable to open file %S with fopen. \n", FileName); - } - if (fputs("testing", testFile) == EOF) - { - Fail("Unexpected error: Unable to write to file %S with fputs. \n", FileName); - } - if (fclose(testFile) != 0) - { - Fail("Unexpected error: Unable to close file %S with fclose. \n", FileName); - } - testFile = NULL; - - /* Try to set the file to Read-only */ - - TheResult = SetFileAttributesA(FileName, FILE_ATTRIBUTE_READONLY); - - if(TheResult == 0) - { - Fail("ERROR: SetFileAttributesA returned 0, failure, when trying " - "to set the FILE_ATTRIBUTE_READONLY attribute."); - } - - /* Attempt to open this READONLY file with WRITE access, - The open should fail and the HANDLE should be invalid. - */ - - TheFile = CreateFileA( - FileName, // file name - GENERIC_READ|GENERIC_WRITE, // access mode - 0, // share mode - NULL, // SD - OPEN_ALWAYS, // how to create - FILE_ATTRIBUTE_NORMAL, // file attributes - NULL // handle to template file - ); - - if(TheFile != INVALID_HANDLE_VALUE) - { - TheResult = CloseHandle(TheFile); - if(TheResult == 0) - { - Fail("ERROR: CloseHandle failed. This tests relies upon it " - "working properly."); - } - Fail("ERROR: Tried to open a file that was created as " - "READONLY with the GENERIC_WRITE access mode. This should" - " cause CreateFile to return an INVALID_HANDLE_VALUE."); - } - - /* Try to open the file with READ access, this should be ok. - The HANDLE will be valid. - */ - - TheFile = CreateFileA( - FileName, // file name - GENERIC_READ, // access mode - 0, // share mode - NULL, // SD - OPEN_ALWAYS, // how to create - FILE_ATTRIBUTE_NORMAL, // file attributes - NULL // handle to template file - ); - - if(TheFile == INVALID_HANDLE_VALUE) - { - Fail("ERROR: Tried to open a file that was created as " - "READONLY with the GENERIC_READ access mode. This should" - " cause CreateFile to return an valid handle, but " - "INVALID_HANDLE_VALUE was returned!."); - } - - /* Close that HANDLE */ - - TheResult = CloseHandle(TheFile); - - if(TheResult == 0) - { - Fail("ERROR: CloseHandle failed. This tests relies upon it " - "working properly."); - } - - /* Set the file to NORMAL */ - - TheResult = SetFileAttributesA(FileName, FILE_ATTRIBUTE_NORMAL); - - if(TheResult == 0) - { - Fail("ERROR: SetFileAttributesA returned 0, failure, when trying " - "to set the FILE_ATTRIBUTE_NORMAL attribute."); - } - - /* To ensure that the set worked correctly, try to open the file - with WRITE access again -- this time it should succeed. - */ - - TheFile = CreateFileA( - FileName, // file name - GENERIC_READ|GENERIC_WRITE, // access mode - 0, // share mode - NULL, // SD - OPEN_ALWAYS, // how to create - FILE_ATTRIBUTE_NORMAL, // file attributes - NULL // handle to template file - ); - - if(TheFile == INVALID_HANDLE_VALUE) - { - Fail("ERROR: Tried to open a file that was created as " - "NORMAL with the GENERIC_WRITE access mode. This should" - " cause CreateFile to return an valid handle, but " - "INVALID_HANDLE_VALUE was returned!."); - } - - TheResult = CloseHandle(TheFile); - - if(TheResult == 0) - { - Fail("ERROR: CloseHandle failed. This tests relies upon it " - "working properly."); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/file_io/SetFileAttributesA/test1/test_file b/src/pal/tests/palsuite/file_io/SetFileAttributesA/test1/test_file deleted file mode 100644 index 1b4bcfe1b..000000000 --- a/src/pal/tests/palsuite/file_io/SetFileAttributesA/test1/test_file +++ /dev/null @@ -1 +0,0 @@ -Don't delete me. I'm needed. The File. \ No newline at end of file diff --git a/src/pal/tests/palsuite/file_io/SetFileAttributesA/test1/testinfo.dat b/src/pal/tests/palsuite/file_io/SetFileAttributesA/test1/testinfo.dat deleted file mode 100644 index e39eac71b..000000000 --- a/src/pal/tests/palsuite/file_io/SetFileAttributesA/test1/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = SetFileAttributesA -Name = Test for SetFileAttributesA which tests READONLY and NORMAL attributes -TYPE = DEFAULT -EXE1 = setfileattributesa -Description -= Test the SetFileAttributesA function. Set a file as READONLY and -= attempt to open it with WRITE access, to ensure that this doesn't work. -= Then switch to NORMAL attributes, and try again -- it should work. diff --git a/src/pal/tests/palsuite/file_io/SetFileAttributesA/test2/CMakeLists.txt b/src/pal/tests/palsuite/file_io/SetFileAttributesA/test2/CMakeLists.txt deleted file mode 100644 index ace67dcbd..000000000 --- a/src/pal/tests/palsuite/file_io/SetFileAttributesA/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - SetFileAttributesA.cpp -) - -add_executable(paltest_setfileattributesa_test2 - ${SOURCES} -) - -add_dependencies(paltest_setfileattributesa_test2 coreclrpal) - -target_link_libraries(paltest_setfileattributesa_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/SetFileAttributesA/test2/SetFileAttributesA.cpp b/src/pal/tests/palsuite/file_io/SetFileAttributesA/test2/SetFileAttributesA.cpp deleted file mode 100644 index 5c04a6b18..000000000 --- a/src/pal/tests/palsuite/file_io/SetFileAttributesA/test2/SetFileAttributesA.cpp +++ /dev/null @@ -1,114 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: SetFileAttributesA.c -** -** -** Purpose: Tests the PAL implementation of the SetFileAttributesA function -** Test that we can set the defined attributes aside from READONLY on a -** file, and that it doesn't return failure. Note, these attributes won't -** do anything to the file, however. -** -** -**===================================================================*/ - - -#include - -/* this cleanup method tries to revert the file back to its initial attributes */ -void do_cleanup(char* filename, DWORD attributes) -{ - DWORD result; - result = SetFileAttributesA(filename, attributes); - if (result == 0) - { - Fail("ERROR:SetFileAttributesA returned 0,failure in the do_cleanup " - "method when trying to revert the file back to its initial attributes (%u)", GetLastError()); - } -} - -int __cdecl main(int argc, char **argv) -{ - DWORD TheResult; - DWORD initialAttr; - - char* FileName = {"test_file"}; - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - // Create the test file - FILE *testFile = fopen(FileName, "w"); - if (testFile == NULL) - { - Fail("Unexpected error: Unable to open file %S with fopen. \n", FileName); - } - if (fputs("testing", testFile) == EOF) - { - Fail("Unexpected error: Unable to write to file %S with fputs. \n", FileName); - } - if (fclose(testFile) != 0) - { - Fail("Unexpected error: Unable to close file %S with fclose. \n", FileName); - } - testFile = NULL; - - /* Get the initial attributes of the file */ - - initialAttr = GetFileAttributesA(FileName); - - /* Try to set the file to HIDDEN */ - - TheResult = SetFileAttributesA(FileName, FILE_ATTRIBUTE_HIDDEN); - - if(TheResult == 0) - { - do_cleanup(FileName,initialAttr); - Fail("ERROR: SetFileAttributesA returned 0, failure, when trying " - "to set the FILE_ATTRIBUTE_HIDDEN attribute. This should " - "not do anything in FreeBSD, but it shouldn't fail."); - } - - /* Try to set the file to ARCHIVE */ - - TheResult = SetFileAttributesA(FileName, FILE_ATTRIBUTE_ARCHIVE); - - if(TheResult == 0) - { - do_cleanup(FileName,initialAttr); - Fail("ERROR: SetFileAttributesA returned 0, failure, when trying " - "to set the FILE_ATTRIBUTE_ARCHIVE attribute."); - } - - /* Try to set the file to SYSTEM */ - - TheResult = SetFileAttributesA(FileName, FILE_ATTRIBUTE_SYSTEM); - - if(TheResult == 0) - { - do_cleanup(FileName,initialAttr); - Fail("ERROR: SetFileAttributesA returned 0, failure, when trying " - "to set the FILE_ATTRIBUTE_SYSTEM attribute."); - } - - /* Try to set the file to DIRECTORY */ - - TheResult = SetFileAttributesA(FileName, FILE_ATTRIBUTE_DIRECTORY); - - if(TheResult == 0) - { - do_cleanup(FileName,initialAttr); - Fail("ERROR: SetFileAttributesA returned 0, failure, when trying " - "to set the FILE_ATTRIBUTE_DIRECTORY attribute."); - } - - - do_cleanup(FileName,initialAttr); - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/file_io/SetFileAttributesA/test2/test_file b/src/pal/tests/palsuite/file_io/SetFileAttributesA/test2/test_file deleted file mode 100644 index 18d630a34..000000000 --- a/src/pal/tests/palsuite/file_io/SetFileAttributesA/test2/test_file +++ /dev/null @@ -1 +0,0 @@ -The File. \ No newline at end of file diff --git a/src/pal/tests/palsuite/file_io/SetFileAttributesA/test2/testinfo.dat b/src/pal/tests/palsuite/file_io/SetFileAttributesA/test2/testinfo.dat deleted file mode 100644 index 778335258..000000000 --- a/src/pal/tests/palsuite/file_io/SetFileAttributesA/test2/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = SetFileAttributesA -Name = smoke test for SetFileAttributesA -TYPE = DEFAULT -EXE1 = setfileattributesa -Description -= Test the SetFileAttributesA function -= Try to set the attributes that are not valid in FreeBSD. These should -= return success in either WIN32 or FreeBSD, just have no effect in FreeBSD. diff --git a/src/pal/tests/palsuite/file_io/SetFileAttributesA/test3/CMakeLists.txt b/src/pal/tests/palsuite/file_io/SetFileAttributesA/test3/CMakeLists.txt deleted file mode 100644 index eb054ac91..000000000 --- a/src/pal/tests/palsuite/file_io/SetFileAttributesA/test3/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - SetFileAttributesA.cpp -) - -add_executable(paltest_setfileattributesa_test3 - ${SOURCES} -) - -add_dependencies(paltest_setfileattributesa_test3 coreclrpal) - -target_link_libraries(paltest_setfileattributesa_test3 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/SetFileAttributesA/test3/SetFileAttributesA.cpp b/src/pal/tests/palsuite/file_io/SetFileAttributesA/test3/SetFileAttributesA.cpp deleted file mode 100644 index 445b515c7..000000000 --- a/src/pal/tests/palsuite/file_io/SetFileAttributesA/test3/SetFileAttributesA.cpp +++ /dev/null @@ -1,48 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: SetFileAttributesA.c -** -** -** Purpose: Tests the PAL implementation of the SetFileAttributesA function -** Test that the function fails if the file doesn't exist.. -** -** -**===================================================================*/ - - -#include - - -int __cdecl main(int argc, char **argv) -{ - DWORD TheResult; - char* FileName = {"no_file"}; - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - - /* Try to set the file to NORMAL on a file that doesn't - exist. - */ - - TheResult = SetFileAttributesA(FileName, FILE_ATTRIBUTE_NORMAL); - - if(TheResult != 0) - { - Fail("ERROR: SetFileAttributesA returned non-zero0, success, when" - " trying to set the FILE_ATTRIBUTE_NORMAL attribute on a non " - "existant file. This should fail."); - } - - - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/file_io/SetFileAttributesA/test3/testinfo.dat b/src/pal/tests/palsuite/file_io/SetFileAttributesA/test3/testinfo.dat deleted file mode 100644 index 33a4b03d6..000000000 --- a/src/pal/tests/palsuite/file_io/SetFileAttributesA/test3/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = SetFileAttributesA -Name = Test SetFileAttributesA on an invalid file -TYPE = DEFAULT -EXE1 = setfileattributesa -Description -= Test the SetFileAttributesA function -= Try the function on a file that doesn't exist. It should fail. diff --git a/src/pal/tests/palsuite/file_io/SetFileAttributesA/test4/CMakeLists.txt b/src/pal/tests/palsuite/file_io/SetFileAttributesA/test4/CMakeLists.txt deleted file mode 100644 index d20ea5dc0..000000000 --- a/src/pal/tests/palsuite/file_io/SetFileAttributesA/test4/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - SetFileAttributesA.cpp -) - -add_executable(paltest_setfileattributesa_test4 - ${SOURCES} -) - -add_dependencies(paltest_setfileattributesa_test4 coreclrpal) - -target_link_libraries(paltest_setfileattributesa_test4 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/SetFileAttributesA/test4/SetFileAttributesA.cpp b/src/pal/tests/palsuite/file_io/SetFileAttributesA/test4/SetFileAttributesA.cpp deleted file mode 100644 index 240e89ff6..000000000 --- a/src/pal/tests/palsuite/file_io/SetFileAttributesA/test4/SetFileAttributesA.cpp +++ /dev/null @@ -1,128 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: SetFileAttributesA.c -** -** -** Purpose: Tests the PAL implementation of the SetFileAttributesA function -** Check that using two flags (READONLY and NORMAL) only sets the file -** as READONLY, as MSDN notes that everything else overrides NORMAL. -** -** Depends: -** CreateFileA -** CloseHandle -** -** -**===================================================================*/ - - -#include - - - -int __cdecl main(int argc, char **argv) -{ - DWORD TheResult; - HANDLE TheFile; - char* FileName = {"test_file"}; - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - // Create the test file - FILE *testFile = fopen(FileName, "w"); - if (testFile == NULL) - { - Fail("Unexpected error: Unable to open file %S with fopen. \n", FileName); - } - if (fputs("testing", testFile) == EOF) - { - Fail("Unexpected error: Unable to write to file %S with fputs. \n", FileName); - } - if (fclose(testFile) != 0) - { - Fail("Unexpected error: Unable to close file %S with fclose. \n", FileName); - } - testFile = NULL; - - /* Try to set the file to Read-only|Normal ... It should - end up as Readonly, since this overrides Normal*/ - - TheResult = SetFileAttributesA(FileName, - FILE_ATTRIBUTE_NORMAL| - FILE_ATTRIBUTE_READONLY); - - if(TheResult == 0) - { - Fail("ERROR: SetFileAttributesA returned 0, failure, when trying " - "to set the FILE_ATTRIBUTE_READONLY|FILE_ATTRIBUTE_NORMAL " - "attribute."); - } - - /* Attempt to open this READONLY file with WRITE access, - The open should fail and the HANDLE should be invalid. - */ - - TheFile = CreateFileA( - FileName, // file name - GENERIC_READ|GENERIC_WRITE, // access mode - 0, // share mode - NULL, // SD - OPEN_ALWAYS, // how to create - FILE_ATTRIBUTE_NORMAL, // file attributes - NULL // handle to template file - ); - - if(TheFile != INVALID_HANDLE_VALUE) - { - TheResult = CloseHandle(TheFile); - if(TheResult == 0) - { - Trace("ERROR: CloseHandle failed. This tests relies upon it " - "working properly."); - } - Fail("ERROR: Tried to open a file that was created as " - "READONLY with the GENERIC_WRITE access mode. This should" - " cause CreateFileA to return an INVALID_HANDLE_VALUE."); - } - - /* Try to open the file with READ access, this should be ok. - The HANDLE will be valid. - */ - - TheFile = CreateFileA( - FileName, // file name - GENERIC_READ, // access mode - 0, // share mode - NULL, // SD - OPEN_ALWAYS, // how to create - FILE_ATTRIBUTE_NORMAL, // file attributes - NULL // handle to template file - ); - - if(TheFile == INVALID_HANDLE_VALUE) - { - Fail("ERROR: Tried to open a file that was created as " - "READONLY with the GENERIC_READ access mode. This should" - " cause CreateFileA to return an valid handle, but " - "INVALID_HANDLE_VALUE was returned!."); - } - - /* Close that HANDLE */ - - TheResult = CloseHandle(TheFile); - - if(TheResult == 0) - { - Fail("ERROR: CloseHandle failed. This tests relies upon it " - "working properly."); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/file_io/SetFileAttributesA/test4/test_file b/src/pal/tests/palsuite/file_io/SetFileAttributesA/test4/test_file deleted file mode 100644 index 1b4bcfe1b..000000000 --- a/src/pal/tests/palsuite/file_io/SetFileAttributesA/test4/test_file +++ /dev/null @@ -1 +0,0 @@ -Don't delete me. I'm needed. The File. \ No newline at end of file diff --git a/src/pal/tests/palsuite/file_io/SetFileAttributesA/test4/testinfo.dat b/src/pal/tests/palsuite/file_io/SetFileAttributesA/test4/testinfo.dat deleted file mode 100644 index d8df0625b..000000000 --- a/src/pal/tests/palsuite/file_io/SetFileAttributesA/test4/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = SetFileAttributesA -Name = Tests SetFileAttributesA properly overrides NORMAL -TYPE = DEFAULT -EXE1 = setfileattributesa -Description -= Test the SetFileAttributesA function. Check that using two flags -= (READONLY and NORMAL) only sets the file as READONLY, as MSDN -= notes that everything else overrides NORMAL. diff --git a/src/pal/tests/palsuite/file_io/SetFileAttributesW/CMakeLists.txt b/src/pal/tests/palsuite/file_io/SetFileAttributesW/CMakeLists.txt deleted file mode 100644 index a3847f8ca..000000000 --- a/src/pal/tests/palsuite/file_io/SetFileAttributesW/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) -add_subdirectory(test3) -add_subdirectory(test4) - diff --git a/src/pal/tests/palsuite/file_io/SetFileAttributesW/test1/CMakeLists.txt b/src/pal/tests/palsuite/file_io/SetFileAttributesW/test1/CMakeLists.txt deleted file mode 100644 index 4d867c1a5..000000000 --- a/src/pal/tests/palsuite/file_io/SetFileAttributesW/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - SetFileAttributesW.cpp -) - -add_executable(paltest_setfileattributesw_test1 - ${SOURCES} -) - -add_dependencies(paltest_setfileattributesw_test1 coreclrpal) - -target_link_libraries(paltest_setfileattributesw_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/SetFileAttributesW/test1/SetFileAttributesW.cpp b/src/pal/tests/palsuite/file_io/SetFileAttributesW/test1/SetFileAttributesW.cpp deleted file mode 100644 index 753c396d1..000000000 --- a/src/pal/tests/palsuite/file_io/SetFileAttributesW/test1/SetFileAttributesW.cpp +++ /dev/null @@ -1,167 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: SetFileAttributesW.c -** -** Purpose: Tests the PAL implementation of the SetFileAttributesW function -** Test that we can set a file READONLY, and then that we're unable to -** open that file with WRITE access. Then change it to NORMAL attributes, and -** try to open it again -- it should work now. -** -** Depends: -** CreateFile -** CloseHandle -** -** -**===================================================================*/ - -/* According to the spec, only READONLY attribute can be set - in FreeBSD. -*/ - -#define UNICODE - -#include - - - -int __cdecl main(int argc, char **argv) -{ - DWORD TheResult; - HANDLE TheFile; - CHAR *FileName_Multibyte = "test_file"; - WCHAR FileName[MAX_PATH]; - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - // Create the test file - FILE *testFile = fopen(FileName_Multibyte, "w"); - if (testFile == NULL) - { - Fail("Unexpected error: Unable to open file %S with fopen. \n", FileName); - } - if (fputs("testing", testFile) == EOF) - { - Fail("Unexpected error: Unable to write to file %S with fputs. \n", FileName); - } - if (fclose(testFile) != 0) - { - Fail("Unexpected error: Unable to close file %S with fclose. \n", FileName); - } - testFile = NULL; - - /* Make a wide character string for the file name */ - - MultiByteToWideChar(CP_ACP, - 0, - FileName_Multibyte, - -1, - FileName, - MAX_PATH); - - - /* Try to set the file to Read-only */ - - TheResult = SetFileAttributes(FileName,FILE_ATTRIBUTE_READONLY); - - if(TheResult == 0) - { - Fail("ERROR: SetFileAttributes returned 0, failure, when trying " - "to set the FILE_ATTRIBUTE_READONLY attribute."); - } - - /* Attempt to open this READONLY file with WRITE access, - The open should fail and the HANDLE should be invalid. - */ - - TheFile = CreateFile( - FileName, // file name - GENERIC_READ|GENERIC_WRITE, // access mode - 0, // share mode - NULL, // SD - OPEN_ALWAYS, // how to create - FILE_ATTRIBUTE_NORMAL, // file attributes - NULL // handle to template file - ); - - if(TheFile != INVALID_HANDLE_VALUE) - { - Fail("ERROR: Tried to open a file that was created as " - "READONLY with the GENERIC_WRITE access mode. This should" - " cause CreateFile to return an INVALID_HANDLE_VALUE."); - } - - /* Try to open the file with READ access, this should be ok. - The HANDLE will be valid. - */ - - TheFile = CreateFile( - FileName, // file name - GENERIC_READ, // access mode - 0, // share mode - NULL, // SD - OPEN_ALWAYS, // how to create - FILE_ATTRIBUTE_NORMAL, // file attributes - NULL // handle to template file - ); - - if(TheFile == INVALID_HANDLE_VALUE) - { - Fail("ERROR: Tried to open a file that was created as " - "READONLY with the GENERIC_READ access mode. This should" - " cause CreateFile to return an valid handle, but " - "INVALID_HANDLE_VALUE was returned!."); - } - - /* Close that HANDLE */ - - TheResult = CloseHandle(TheFile); - - if(TheResult == 0) - { - Fail("ERROR: CloseHandle failed. This tests relies upon it " - "working properly."); - } - - /* Set the file to NORMAL */ - - TheResult = SetFileAttributes(FileName,FILE_ATTRIBUTE_NORMAL); - - if(TheResult == 0) - { - Fail("ERROR: SetFileAttributes returned 0, failure, when trying " - "to set the FILE_ATTRIBUTE_NORMAL attribute."); - } - - /* To ensure that the set worked correctly, try to open the file - with WRITE access again -- this time it should succeed. - */ - - TheFile = CreateFile( - FileName, // file name - GENERIC_READ|GENERIC_WRITE, // access mode - 0, // share mode - NULL, // SD - OPEN_ALWAYS, // how to create - FILE_ATTRIBUTE_NORMAL, // file attributes - NULL // handle to template file - ); - - if(TheFile == INVALID_HANDLE_VALUE) - { - Fail("ERROR: Tried to open a file that was created as " - "NORMAL with the GENERIC_WRITE access mode. This should" - " cause CreateFile to return an valid handle, but " - "INVALID_HANDLE_VALUE was returned!."); - } - - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/file_io/SetFileAttributesW/test1/test_file b/src/pal/tests/palsuite/file_io/SetFileAttributesW/test1/test_file deleted file mode 100644 index 1b4bcfe1b..000000000 --- a/src/pal/tests/palsuite/file_io/SetFileAttributesW/test1/test_file +++ /dev/null @@ -1 +0,0 @@ -Don't delete me. I'm needed. The File. \ No newline at end of file diff --git a/src/pal/tests/palsuite/file_io/SetFileAttributesW/test1/testinfo.dat b/src/pal/tests/palsuite/file_io/SetFileAttributesW/test1/testinfo.dat deleted file mode 100644 index 75cdc3b71..000000000 --- a/src/pal/tests/palsuite/file_io/SetFileAttributesW/test1/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = SetFileAttributesW -Name = Positive Test for SetFileAttributesW -TYPE = DEFAULT -EXE1 = setfileattributesw -Description -= Test the SetFileAttributesW function. Set a file as READONLY and -= attempt to open it with WRITE access, to ensure that this doesn't work. -= Then switch to NORMAL attributes, and try again -- it should work. diff --git a/src/pal/tests/palsuite/file_io/SetFileAttributesW/test2/CMakeLists.txt b/src/pal/tests/palsuite/file_io/SetFileAttributesW/test2/CMakeLists.txt deleted file mode 100644 index df1bbfad0..000000000 --- a/src/pal/tests/palsuite/file_io/SetFileAttributesW/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - SetFileAttributesW.cpp -) - -add_executable(paltest_setfileattributesw_test2 - ${SOURCES} -) - -add_dependencies(paltest_setfileattributesw_test2 coreclrpal) - -target_link_libraries(paltest_setfileattributesw_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/SetFileAttributesW/test2/SetFileAttributesW.cpp b/src/pal/tests/palsuite/file_io/SetFileAttributesW/test2/SetFileAttributesW.cpp deleted file mode 100644 index f65743684..000000000 --- a/src/pal/tests/palsuite/file_io/SetFileAttributesW/test2/SetFileAttributesW.cpp +++ /dev/null @@ -1,121 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: SetFileAttributesW.c -** -** Purpose: Tests the PAL implementation of the SetFileAttributesW function -** Test that we can set the defined attributes aside from READONLY on a -** file, and that it doesn't return failure. Note, these attributes won't -** do anything to the file, however. -** -** -**===================================================================*/ - -#define UNICODE - -#include - -/* this cleanup method tries to revert the file back to its initial attributes */ -void do_cleanup(WCHAR* filename, DWORD attributes) -{ - DWORD result; - result = SetFileAttributes(filename, attributes); - if (result == 0) - { - Fail("ERROR:SetFileAttributesW returned 0,failure in the do_cleanup " - "method when trying to revert the file back to its initial attributes (%u)", GetLastError()); - } -} - -int __cdecl main(int argc, char **argv) -{ - DWORD TheResult; - DWORD initialAttr; - CHAR *FileName_Multibyte = "test_file"; - WCHAR FileName[MAX_PATH]; - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - // Create the test file - FILE *testFile = fopen(FileName_Multibyte, "w"); - if (testFile == NULL) - { - Fail("Unexpected error: Unable to open file %S with fopen. \n", FileName); - } - if (fputs("testing", testFile) == EOF) - { - Fail("Unexpected error: Unable to write to file %S with fputs. \n", FileName); - } - if (fclose(testFile) != 0) - { - Fail("Unexpected error: Unable to close file %S with fclose. \n", FileName); - } - testFile = NULL; - - /* Make a wide character string for the file name */ - - MultiByteToWideChar(CP_ACP, - 0, - FileName_Multibyte, - -1, - FileName, - MAX_PATH); - - /* Get the initial attributes of the file */ - initialAttr = GetFileAttributesW(FileName); - - /* Try to set the file to HIDDEN */ - - TheResult = SetFileAttributes(FileName,FILE_ATTRIBUTE_HIDDEN); - - if(TheResult == 0) - { - do_cleanup(FileName,initialAttr); - Fail("ERROR: SetFileAttributes returned 0, failure, when trying " - "to set the FILE_ATTRIBUTE_HIDDEN attribute. This should " - "not do anything in FreeBSD, but it shouldn't fail."); - } - - /* Try to set the file to ARCHIVE */ - - TheResult = SetFileAttributes(FileName,FILE_ATTRIBUTE_ARCHIVE); - - if(TheResult == 0) - { - do_cleanup(FileName,initialAttr); - Fail("ERROR: SetFileAttributes returned 0, failure, when trying " - "to set the FILE_ATTRIBUTE_ARCHIVE attribute."); - } - - /* Try to set the file to SYSTEM */ - - TheResult = SetFileAttributes(FileName,FILE_ATTRIBUTE_SYSTEM); - - if(TheResult == 0) - { - do_cleanup(FileName,initialAttr); - Fail("ERROR: SetFileAttributes returned 0, failure, when trying " - "to set the FILE_ATTRIBUTE_SYSTEM attribute."); - } - - /* Try to set the file to DIRECTORY */ - - TheResult = SetFileAttributes(FileName,FILE_ATTRIBUTE_DIRECTORY); - - if(TheResult == 0) - { - do_cleanup(FileName,initialAttr); - Fail("ERROR: SetFileAttributes returned 0, failure, when trying " - "to set the FILE_ATTRIBUTE_DIRECTORY attribute."); - } - - do_cleanup(FileName,initialAttr); - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/file_io/SetFileAttributesW/test2/test_file b/src/pal/tests/palsuite/file_io/SetFileAttributesW/test2/test_file deleted file mode 100644 index 18d630a34..000000000 --- a/src/pal/tests/palsuite/file_io/SetFileAttributesW/test2/test_file +++ /dev/null @@ -1 +0,0 @@ -The File. \ No newline at end of file diff --git a/src/pal/tests/palsuite/file_io/SetFileAttributesW/test2/testinfo.dat b/src/pal/tests/palsuite/file_io/SetFileAttributesW/test2/testinfo.dat deleted file mode 100644 index e3161a9bd..000000000 --- a/src/pal/tests/palsuite/file_io/SetFileAttributesW/test2/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = SetFileAttributesW -Name = Positive Test for SetFileAttributesW -TYPE = DEFAULT -EXE1 = setfileattributesw -Description -= Test the SetFileAttributesW function -= Try to set the attributes that are not valid in FreeBSD. These should -= return success in either WIN32 or FreeBSD, just have no effect in FreeBSD. diff --git a/src/pal/tests/palsuite/file_io/SetFileAttributesW/test3/CMakeLists.txt b/src/pal/tests/palsuite/file_io/SetFileAttributesW/test3/CMakeLists.txt deleted file mode 100644 index f4cd725b7..000000000 --- a/src/pal/tests/palsuite/file_io/SetFileAttributesW/test3/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - SetFileAttributesW.cpp -) - -add_executable(paltest_setfileattributesw_test3 - ${SOURCES} -) - -add_dependencies(paltest_setfileattributesw_test3 coreclrpal) - -target_link_libraries(paltest_setfileattributesw_test3 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/SetFileAttributesW/test3/SetFileAttributesW.cpp b/src/pal/tests/palsuite/file_io/SetFileAttributesW/test3/SetFileAttributesW.cpp deleted file mode 100644 index 8a8bafac6..000000000 --- a/src/pal/tests/palsuite/file_io/SetFileAttributesW/test3/SetFileAttributesW.cpp +++ /dev/null @@ -1,57 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: SetFileAttributesW.c -** -** Purpose: Tests the PAL implementation of the SetFileAttributesW function -** Test that the function fails if the file doesn't exist.. -** -** -**===================================================================*/ - -#define UNICODE - -#include - - -int __cdecl main(int argc, char **argv) -{ - DWORD TheResult; - WCHAR FileName[MAX_PATH]; - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - /* Make a wide character string for the file name */ - - MultiByteToWideChar(CP_ACP, - 0, - "no_file", - -1, - FileName, - MAX_PATH); - - - /* Try to set the file to NORMAL on a file that doesn't - exist. - */ - - TheResult = SetFileAttributes(FileName,FILE_ATTRIBUTE_NORMAL); - - if(TheResult != 0) - { - Fail("ERROR: SetFileAttributes returned non-zero0, success, when" - " trying to set the FILE_ATTRIBUTE_NORMAL attribute on a non " - "existant file. This should fail."); - } - - - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/file_io/SetFileAttributesW/test3/testinfo.dat b/src/pal/tests/palsuite/file_io/SetFileAttributesW/test3/testinfo.dat deleted file mode 100644 index 4b264898d..000000000 --- a/src/pal/tests/palsuite/file_io/SetFileAttributesW/test3/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = SetFileAttributesW -Name = Positive Test for SetFileAttributesW -TYPE = DEFAULT -EXE1 = setfileattributesw -Description -= Test the SetFileAttributesW function -= Try the function on a file that doesn't exist. It should fail. diff --git a/src/pal/tests/palsuite/file_io/SetFileAttributesW/test4/CMakeLists.txt b/src/pal/tests/palsuite/file_io/SetFileAttributesW/test4/CMakeLists.txt deleted file mode 100644 index 986954b7d..000000000 --- a/src/pal/tests/palsuite/file_io/SetFileAttributesW/test4/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - SetFileAttributesW.cpp -) - -add_executable(paltest_setfileattributesw_test4 - ${SOURCES} -) - -add_dependencies(paltest_setfileattributesw_test4 coreclrpal) - -target_link_libraries(paltest_setfileattributesw_test4 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/SetFileAttributesW/test4/SetFileAttributesW.cpp b/src/pal/tests/palsuite/file_io/SetFileAttributesW/test4/SetFileAttributesW.cpp deleted file mode 100644 index bebadfa26..000000000 --- a/src/pal/tests/palsuite/file_io/SetFileAttributesW/test4/SetFileAttributesW.cpp +++ /dev/null @@ -1,133 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: SetFileAttributesW.c -** -** Purpose: Tests the PAL implementation of the SetFileAttributesW function -** Check that using two flags (READONLY and NORMAL) only sets the file -** as READONLY, as MSDN notes that everything else overrides NORMAL. -** -** Depends: -** CreateFile -** CloseHandle -** -** -**===================================================================*/ - -#define UNICODE - -#include - - - -int __cdecl main(int argc, char **argv) -{ - DWORD TheResult; - HANDLE TheFile; - CHAR *FileName_Multibyte = "test_file"; - WCHAR FileName[MAX_PATH]; - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - // Create the test file - FILE *testFile = fopen(FileName_Multibyte, "w"); - if (testFile == NULL) - { - Fail("Unexpected error: Unable to open file %S with fopen. \n", FileName); - } - if (fputs("testing", testFile) == EOF) - { - Fail("Unexpected error: Unable to write to file %S with fputs. \n", FileName); - } - if (fclose(testFile) != 0) - { - Fail("Unexpected error: Unable to close file %S with fclose. \n", FileName); - } - testFile = NULL; - - /* Make a wide character string for the file name */ - - MultiByteToWideChar(CP_ACP, - 0, - FileName_Multibyte, - -1, - FileName, - MAX_PATH); - - - /* Try to set the file to Read-only|Normal ... It should - end up as Readonly, since this overrides Normal*/ - - TheResult = SetFileAttributes(FileName, - FILE_ATTRIBUTE_NORMAL| - FILE_ATTRIBUTE_READONLY); - - if(TheResult == 0) - { - Fail("ERROR: SetFileAttributes returned 0, failure, when trying " - "to set the FILE_ATTRIBUTE_READONLY|FILE_ATTRIBUTE_NORMAL " - "attribute."); - } - - /* Attempt to open this READONLY file with WRITE access, - The open should fail and the HANDLE should be invalid. - */ - - TheFile = CreateFile( - FileName, // file name - GENERIC_READ|GENERIC_WRITE, // access mode - 0, // share mode - NULL, // SD - OPEN_ALWAYS, // how to create - FILE_ATTRIBUTE_NORMAL, // file attributes - NULL // handle to template file - ); - - if(TheFile != INVALID_HANDLE_VALUE) - { - Fail("ERROR: Tried to open a file that was created as " - "READONLY with the GENERIC_WRITE access mode. This should" - " cause CreateFile to return an INVALID_HANDLE_VALUE."); - } - - /* Try to open the file with READ access, this should be ok. - The HANDLE will be valid. - */ - - TheFile = CreateFile( - FileName, // file name - GENERIC_READ, // access mode - 0, // share mode - NULL, // SD - OPEN_ALWAYS, // how to create - FILE_ATTRIBUTE_NORMAL, // file attributes - NULL // handle to template file - ); - - if(TheFile == INVALID_HANDLE_VALUE) - { - Fail("ERROR: Tried to open a file that was created as " - "READONLY with the GENERIC_READ access mode. This should" - " cause CreateFile to return an valid handle, but " - "INVALID_HANDLE_VALUE was returned!."); - } - - /* Close that HANDLE */ - - TheResult = CloseHandle(TheFile); - - if(TheResult == 0) - { - Fail("ERROR: CloseHandle failed. This tests relies upon it " - "working properly."); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/file_io/SetFileAttributesW/test4/test_file b/src/pal/tests/palsuite/file_io/SetFileAttributesW/test4/test_file deleted file mode 100644 index 1b4bcfe1b..000000000 --- a/src/pal/tests/palsuite/file_io/SetFileAttributesW/test4/test_file +++ /dev/null @@ -1 +0,0 @@ -Don't delete me. I'm needed. The File. \ No newline at end of file diff --git a/src/pal/tests/palsuite/file_io/SetFileAttributesW/test4/testinfo.dat b/src/pal/tests/palsuite/file_io/SetFileAttributesW/test4/testinfo.dat deleted file mode 100644 index 75cdc3b71..000000000 --- a/src/pal/tests/palsuite/file_io/SetFileAttributesW/test4/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = SetFileAttributesW -Name = Positive Test for SetFileAttributesW -TYPE = DEFAULT -EXE1 = setfileattributesw -Description -= Test the SetFileAttributesW function. Set a file as READONLY and -= attempt to open it with WRITE access, to ensure that this doesn't work. -= Then switch to NORMAL attributes, and try again -- it should work. diff --git a/src/pal/tests/palsuite/file_io/SetFilePointer/CMakeLists.txt b/src/pal/tests/palsuite/file_io/SetFilePointer/CMakeLists.txt deleted file mode 100644 index 19ee487a6..000000000 --- a/src/pal/tests/palsuite/file_io/SetFilePointer/CMakeLists.txt +++ /dev/null @@ -1,10 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) -add_subdirectory(test3) -add_subdirectory(test4) -add_subdirectory(test5) -add_subdirectory(test6) -add_subdirectory(test7) - diff --git a/src/pal/tests/palsuite/file_io/SetFilePointer/test1/CMakeLists.txt b/src/pal/tests/palsuite/file_io/SetFilePointer/test1/CMakeLists.txt deleted file mode 100644 index c0594aac1..000000000 --- a/src/pal/tests/palsuite/file_io/SetFilePointer/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - SetFilePointer.cpp -) - -add_executable(paltest_setfilepointer_test1 - ${SOURCES} -) - -add_dependencies(paltest_setfilepointer_test1 coreclrpal) - -target_link_libraries(paltest_setfilepointer_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/SetFilePointer/test1/SetFilePointer.cpp b/src/pal/tests/palsuite/file_io/SetFilePointer/test1/SetFilePointer.cpp deleted file mode 100644 index 14b5f85e6..000000000 --- a/src/pal/tests/palsuite/file_io/SetFilePointer/test1/SetFilePointer.cpp +++ /dev/null @@ -1,123 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: SetFilePointer.c (test 1) -** -** Purpose: Tests the PAL implementation of the SetFilePointer function. -** Set the file pointer using a NULL handle and other invalid -** options. -** -** -**===================================================================*/ - -#include - - -const char* szTextFile = "text.txt"; - - -int __cdecl main(int argc, char *argv[]) -{ - HANDLE hFile = NULL; - DWORD dwByteCount = 0; - DWORD dwOffset = 25; - DWORD dwRc = 0; - BOOL bRc = FALSE; - char buffer[100]; - - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - /* set the file pointer on a NULL file handle */ - dwRc = SetFilePointer(NULL, dwOffset, NULL, FILE_BEGIN); - if (dwRc != INVALID_SET_FILE_POINTER) - { - Fail("SetFilePointer: ERROR -> Call to SetFilePointer succeeded " - "with a NULL pointer\n"); - } - - - /* create a test file without proper permission */ - hFile = CreateFile(szTextFile, - 0, - 0, - NULL, - CREATE_ALWAYS, - FILE_ATTRIBUTE_NORMAL, - NULL); - - if(hFile == INVALID_HANDLE_VALUE) - { - Fail("SetFilePointer: ERROR -> Unable to create file \"%s\".\n", - szTextFile); - } - - /* ReadFile fails as expected */ - bRc = ReadFile(hFile, buffer, 1, &dwByteCount, NULL); - if (bRc != FALSE) - { - Trace("SetFilePointer: ERROR -> ReadFile was successful when it was " - "expected to fail\n"); - if (!CloseHandle(hFile)) - { - Trace("SetFilePointer: ERROR -> Unable to close file \"%s\".\n", - szTextFile); - } - if (!DeleteFileA(szTextFile)) - { - Trace("SetFilePointer: ERROR -> Unable to delete file \"%s\".\n", - szTextFile); - } - PAL_TerminateEx(FAIL); - return FAIL; - } - - /* move the file pointer before the beginning of the file */ - dwRc = SetFilePointer(hFile, -1, NULL, FILE_BEGIN); - if (dwRc != INVALID_SET_FILE_POINTER) - { - Trace("SetFilePointer: ERROR -> Was able to move the pointer before " - "the beginning of the file.\n"); - bRc = CloseHandle(hFile); - if (bRc != TRUE) - { - Trace("SetFilePointer: ERROR -> Unable to close file \"%s\".\n", - szTextFile); - } - if (!DeleteFileA(szTextFile)) - { - Trace("SetFilePointer: ERROR -> Unable to delete file \"%s\".\n", - szTextFile); - } - PAL_TerminateEx(FAIL); - return FAIL; - } - - bRc = CloseHandle(hFile); - if (bRc != TRUE) - { - Trace("SetFilePointer: ERROR -> Unable to close file \"%s\".\n", - szTextFile); - if (!DeleteFileA(szTextFile)) - { - Trace("SetFilePointer: ERROR -> Unable to delete file \"%s\".\n", - szTextFile); - } - PAL_TerminateEx(FAIL); - return FAIL; - } - - if (!DeleteFileA(szTextFile)) - { - Fail("SetFilePointer: ERROR -> Unable to delete file \"%s\".\n", - szTextFile); - } - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/file_io/SetFilePointer/test1/testinfo.dat b/src/pal/tests/palsuite/file_io/SetFilePointer/test1/testinfo.dat deleted file mode 100644 index dfd4b6bd4..000000000 --- a/src/pal/tests/palsuite/file_io/SetFilePointer/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = SetFilePointer -Name = Test for SetFilePointer (test 1) -Type = DEFAULT -EXE1 = setfilepointer -Description -=Set the file pointer on a NULL file handle and other invalid options - diff --git a/src/pal/tests/palsuite/file_io/SetFilePointer/test2/CMakeLists.txt b/src/pal/tests/palsuite/file_io/SetFilePointer/test2/CMakeLists.txt deleted file mode 100644 index 4299b808d..000000000 --- a/src/pal/tests/palsuite/file_io/SetFilePointer/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - SetFilePointer.cpp -) - -add_executable(paltest_setfilepointer_test2 - ${SOURCES} -) - -add_dependencies(paltest_setfilepointer_test2 coreclrpal) - -target_link_libraries(paltest_setfilepointer_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/SetFilePointer/test2/SetFilePointer.cpp b/src/pal/tests/palsuite/file_io/SetFilePointer/test2/SetFilePointer.cpp deleted file mode 100644 index 19e99a74b..000000000 --- a/src/pal/tests/palsuite/file_io/SetFilePointer/test2/SetFilePointer.cpp +++ /dev/null @@ -1,356 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: SetFilePointer.c (test 2) -** -** Purpose: Tests the PAL implementation of the SetFilePointer function. -** Test the FILE_BEGIN option -** -** Assumes Successful: -** CreateFile -** ReadFile -** WriteFile -** strlen -** CloseHandle -** strcmp -** GetFileSize -** -** -**===================================================================*/ - -#include - -const char * const szText = - "The quick brown fox jumped over the lazy dog's back."; -const char* szTextFile = "text.txt"; - - -int __cdecl main(int argc, char *argv[]) -{ - HANDLE hFile = NULL; - DWORD dwByteCount = 0; - DWORD dwRc = 0; - BOOL bRc = FALSE; - char szBuffer[100]; - const char *szPtr; - - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - /* create a test file */ - hFile = CreateFile(szTextFile, - GENERIC_READ | GENERIC_WRITE, - FILE_SHARE_READ | FILE_SHARE_WRITE, - NULL, - CREATE_ALWAYS, - FILE_ATTRIBUTE_NORMAL, - NULL); - - if(hFile == INVALID_HANDLE_VALUE) - { - Fail("SetFilePointer: ERROR -> Unable to create file \"%s\".\n", - szTextFile); - } - - bRc = WriteFile(hFile, szText, (DWORD)strlen(szText), &dwByteCount, NULL); - if (bRc == FALSE) - { - Trace("SetFilePointer: ERROR -> Unable to write to file \"%s\".\n", - szTextFile); - bRc = CloseHandle(hFile); - if (bRc != TRUE) - { - Trace("SetFilePointer: ERROR -> Unable to close file \"%s\".\n", - szTextFile); - } - if (!DeleteFileA(szTextFile)) - { - Trace("SetFilePointer: ERROR -> Unable to delete file \"%s\".\n", - szTextFile); - } - PAL_TerminateEx(FAIL); - return FAIL; - } - - - /* move -1 from beginning which should fail */ - dwRc = SetFilePointer(hFile, -1, NULL, FILE_BEGIN); - if ((dwRc != INVALID_SET_FILE_POINTER) || - (GetLastError() == ERROR_SUCCESS)) - { - Trace("SetFilePointer: ERROR -> Succeeded to move the pointer " - "before the beginning of the file.\n"); - bRc = CloseHandle(hFile); - if (bRc != TRUE) - { - Trace("SetFilePointer: ERROR -> Unable to close file \"%s\".\n", - szTextFile); - } - if (!DeleteFileA(szTextFile)) - { - Trace("SetFilePointer: ERROR -> Unable to delete file \"%s\".\n", - szTextFile); - } - PAL_TerminateEx(FAIL); - return FAIL; - } - - /* move the file pointer 0 bytes from the beginning and verify */ - dwRc = SetFilePointer(hFile, 0, NULL, FILE_BEGIN); - if (dwRc != 0) - { - Trace("SetFilePointer: ERROR -> Asked to move 0 bytes from the " - "beginning of the file but moved %ld bytes.\n", dwRc); - bRc = CloseHandle(hFile); - if (bRc != TRUE) - { - Trace("SetFilePointer: ERROR -> Unable to close file \"%s\".\n", - szTextFile); - } - if (!DeleteFileA(szTextFile)) - { - Trace("SetFilePointer: ERROR -> Unable to delete file \"%s\".\n", - szTextFile); - } - PAL_TerminateEx(FAIL); - return FAIL; - } - - /* move the pointer ahead in the file and verify */ - dwRc = SetFilePointer(hFile, 20, NULL, FILE_BEGIN); - if (dwRc != 20) - { - Trace("SetFilePointer: ERROR -> Asked to move 0 bytes from the " - "beginning of the file but moved %ld bytes.\n", dwRc); - bRc = CloseHandle(hFile); - if (bRc != TRUE) - { - Trace("SetFilePointer: ERROR -> Unable to close file \"%s\".\n", - szTextFile); - } - if (!DeleteFileA(szTextFile)) - { - Trace("SetFilePointer: ERROR -> Unable to delete file \"%s\".\n", - szTextFile); - } - PAL_TerminateEx(FAIL); - return FAIL; - } - else - { - /* verify results */ - memset(szBuffer, 0, 100); - bRc = ReadFile(hFile, szBuffer, (DWORD)strlen(szText)-20, &dwByteCount, - NULL); - if ((bRc != TRUE) || (dwByteCount != strlen(szText)-20)) - { - Trace("SetFilePointer: ERROR -> ReadFile failed to read correctly"); - bRc = CloseHandle(hFile); - if (bRc != TRUE) - { - Trace("SetFilePointer: ERROR -> Unable to close file" - "\"%s\".\n", szTextFile); - } - if (!DeleteFileA(szTextFile)) - { - Trace("SetFilePointer: ERROR -> Unable to delete file" - "\"%s\".\n", szTextFile); - } - PAL_TerminateEx(FAIL); - return FAIL; - } - szPtr = szText + 20; - if (strcmp(szPtr, szBuffer) != 0) - { - Trace("SetFilePointer: ERROR -> Apparently failed to move the " - "pointer properly\n"); - bRc = CloseHandle(hFile); - if (bRc != TRUE) - { - Trace("SetFilePointer: ERROR -> Unable to close file" - " \"%s\".\n", szTextFile); - } - if (!DeleteFileA(szTextFile)) - { - Trace("SetFilePointer: ERROR -> Unable to delete file" - " \"%s\".\n", szTextFile); - } - PAL_TerminateEx(FAIL); - return FAIL; - } - } - - /* move the file pointer back to the beginning and verify */ - dwRc = SetFilePointer(hFile, 0, NULL, FILE_BEGIN); - if (dwRc != 0) - { - Trace("SetFilePointer: ERROR -> Asked to move 0 bytes from the " - "beginning of the file but moved %ld bytes.\n", dwRc); - bRc = CloseHandle(hFile); - if (bRc != TRUE) - { - Trace("SetFilePointer: ERROR -> Unable to close file \"%s\".\n", - szTextFile); - } - if (!DeleteFileA(szTextFile)) - { - Trace("SetFilePointer: ERROR -> Unable to delete file \"%s\".\n", - szTextFile); - } - PAL_TerminateEx(FAIL); - return FAIL; - } - else - { - /* verify results */ - memset(szBuffer, 0, 100); - bRc = ReadFile(hFile, szBuffer, (DWORD)strlen(szText), &dwByteCount, - NULL); - if ((bRc != TRUE) || (dwByteCount != strlen(szText))) - { - Trace("SetFilePointer: ERROR -> ReadFile failed to read correctly"); - bRc = CloseHandle(hFile); - if (bRc != TRUE) - { - Trace("SetFilePointer: ERROR -> Unable to close file" - " \"%s\".\n", szTextFile); - } - if (!DeleteFileA(szTextFile)) - { - Trace("SetFilePointer: ERROR -> Unable to delete file" - " \"%s\".\n", szTextFile); - } - PAL_TerminateEx(FAIL); - return FAIL; - } - if (strcmp(szText, szBuffer) != 0) - { - Trace("SetFilePointer: ERROR -> Failed to return the pointer " - "properly to the beginning of the file\n"); - bRc = CloseHandle(hFile); - if (bRc != TRUE) - { - Trace("SetFilePointer: ERROR -> Unable to close file" - " \"%s\".\n", szTextFile); - } - if (!DeleteFileA(szTextFile)) - { - Trace("SetFilePointer: ERROR -> Unable to delete file" - " \"%s\".\n", szTextFile); - } - PAL_TerminateEx(FAIL); - return FAIL; - } - } - - /* return the pointer to the beginning of the file */ - dwRc = SetFilePointer(hFile, 0, NULL, FILE_BEGIN); - if (dwRc != 0) - { - Trace("SetFilePointer: ERROR -> Asked to move 0 bytes from the " - "beginning of the file but moved %ld bytes.\n", dwRc); - bRc = CloseHandle(hFile); - if (bRc != TRUE) - { - Trace("SetFilePointer: ERROR -> Unable to close file \"%s\".\n", - szTextFile); - } - if (!DeleteFileA(szTextFile)) - { - Trace("SetFilePointer: ERROR -> Unable to delete file \"%s\".\n", - szTextFile); - } - PAL_TerminateEx(FAIL); - return FAIL; - } - - /* set the pointer past the end of the file and verify */ - dwRc = SetFilePointer(hFile, (DWORD)strlen(szText)+20, NULL, FILE_BEGIN); - if ((dwRc == INVALID_SET_FILE_POINTER) && (GetLastError() != ERROR_SUCCESS)) - { - Trace("SetFilePointer: ERROR -> Failed to move pointer past EOF.\n"); - bRc = CloseHandle(hFile); - if (bRc != TRUE) - { - Trace("SetFilePointer: ERROR -> Unable to close file \"%s\".\n", - szTextFile); - } - if (!DeleteFileA(szTextFile)) - { - Trace("SetFilePointer: ERROR -> Unable to delete file \"%s\".\n", - szTextFile); - } - PAL_TerminateEx(FAIL); - return FAIL; - } - else - { - /* verify */ - bRc = SetEndOfFile(hFile); - if (bRc != TRUE) - { - bRc = CloseHandle(hFile); - if (bRc != TRUE) - { - Trace("SetFilePointer: ERROR -> Unable to close file" - " \"%s\".\n", szTextFile); - } - if (!DeleteFileA(szTextFile)) - { - Trace("SetFilePointer: ERROR -> Unable to delete file" - " \"%s\".\n", szTextFile); - } - PAL_TerminateEx(FAIL); - return FAIL; - } - - if (GetFileSize(hFile, NULL) != strlen(szText)+20) - { - Trace("SetFilePointer: ERROR -> Failed to move pointer past" - " EOF.\n"); - bRc = CloseHandle(hFile); - if (bRc != TRUE) - { - Trace("SetFilePointer: ERROR -> Unable to close file" - " \"%s\".\n", szTextFile); - } - if (!DeleteFileA(szTextFile)) - { - Trace("SetFilePointer: ERROR -> Unable to delete file" - " \"%s\".\n", szTextFile); - } - PAL_TerminateEx(FAIL); - return FAIL; - } - } - - - - bRc = CloseHandle(hFile); - if (bRc != TRUE) - { - Trace("SetFilePointer: ERROR -> Unable to close file \"%s\".\n", - szTextFile); - if (!DeleteFileA(szTextFile)) - { - Trace("SetFilePointer: ERROR -> Unable to delete file \"%s\".\n", - szTextFile); - } - PAL_TerminateEx(FAIL); - return FAIL; - } - - if (!DeleteFileA(szTextFile)) - { - Fail("SetFilePointer: ERROR -> Unable to delete file \"%s\".\n", - szTextFile); - } - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/file_io/SetFilePointer/test2/testinfo.dat b/src/pal/tests/palsuite/file_io/SetFilePointer/test2/testinfo.dat deleted file mode 100644 index e3a0a861f..000000000 --- a/src/pal/tests/palsuite/file_io/SetFilePointer/test2/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = SetFilePointer -Name = Positive Test for SetFilePointer (test 2) -Type = DEFAULT -EXE1 = setfilepointer -Description -=Tests the FILE_BEGIN option - diff --git a/src/pal/tests/palsuite/file_io/SetFilePointer/test3/CMakeLists.txt b/src/pal/tests/palsuite/file_io/SetFilePointer/test3/CMakeLists.txt deleted file mode 100644 index 04589ea0d..000000000 --- a/src/pal/tests/palsuite/file_io/SetFilePointer/test3/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - SetFilePointer.cpp -) - -add_executable(paltest_setfilepointer_test3 - ${SOURCES} -) - -add_dependencies(paltest_setfilepointer_test3 coreclrpal) - -target_link_libraries(paltest_setfilepointer_test3 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/SetFilePointer/test3/SetFilePointer.cpp b/src/pal/tests/palsuite/file_io/SetFilePointer/test3/SetFilePointer.cpp deleted file mode 100644 index dd5382962..000000000 --- a/src/pal/tests/palsuite/file_io/SetFilePointer/test3/SetFilePointer.cpp +++ /dev/null @@ -1,350 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: SetFilePointer.c (test 3) -** -** Purpose: Tests the PAL implementation of the SetFilePointer function. -** Test the FILE_CURRENT option -** -** Assumes Successful: -** CreateFile -** ReadFile -** WriteFile -** strlen -** CloseHandle -** strcmp -** GetFileSize -** -** -**===================================================================*/ - -#include - -const char* const szText = - "The quick brown fox jumped over the lazy dog's back."; -const char* szTextFile = "text.txt"; - - -int __cdecl main(int argc, char *argv[]) -{ - HANDLE hFile = NULL; - DWORD dwByteCount = 0; - DWORD dwRc = 0; - BOOL bRc = FALSE; - char szBuffer[100]; - const char* szPtr; - - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - /* create a test file */ - hFile = CreateFile(szTextFile, - GENERIC_READ | GENERIC_WRITE, - FILE_SHARE_READ | FILE_SHARE_WRITE, - NULL, - CREATE_ALWAYS, - FILE_ATTRIBUTE_NORMAL, - NULL); - - if(hFile == INVALID_HANDLE_VALUE) - { - Fail("SetFilePointer: ERROR -> Unable to create file \"%s\".\n", - szTextFile); - } - - bRc = WriteFile(hFile, szText, (DWORD)strlen(szText), &dwByteCount, NULL); - if (bRc == FALSE) - { - Trace("SetFilePointer: ERROR -> Unable to write to file \"%s\".\n", - szTextFile); - if (CloseHandle(hFile) != TRUE) - { - Trace("SetFilePointer: ERROR -> Unable to close file \"%s\".\n", - szTextFile); - } - if (!DeleteFileA(szTextFile)) - { - Trace("SetFilePointer: ERROR -> Unable to delete file \"%s\".\n", - szTextFile); - } - PAL_TerminateEx(FAIL); - return FAIL; - } - - /* reset the pointer to the beginning */ - if (SetFilePointer(hFile, 0, NULL, FILE_BEGIN) == INVALID_SET_FILE_POINTER) - { - if (GetLastError() != ERROR_SUCCESS) - { - Trace("SetFilePointer: ERROR -> Unable to reset the pointer to the " - "beginning of the file"); - if (CloseHandle(hFile) != TRUE) - { - Trace("SetFilePointer: ERROR -> Unable to close file \"%s\".\n", - szTextFile); - } - if (!DeleteFileA(szTextFile)) - { - Trace("SetFilePointer: ERROR -> Unable to delete file" - " \"%s\".\n", szTextFile); - } - PAL_TerminateEx(FAIL); - return FAIL; - } - } - - /* move -1 from beginning which should fail */ - dwRc = SetFilePointer(hFile, -1, NULL, FILE_CURRENT); - if ((dwRc != INVALID_SET_FILE_POINTER) || - (GetLastError() == ERROR_SUCCESS)) - { - Trace("SetFilePointer: ERROR -> Succeeded to move the pointer " - "before the beginning of the file.\n"); - if (CloseHandle(hFile) != TRUE) - { - Trace("SetFilePointer: ERROR -> Unable to close file \"%s\".\n", - szTextFile); - } - if (!DeleteFileA(szTextFile)) - { - Trace("SetFilePointer: ERROR -> Unable to delete file \"%s\".\n", - szTextFile); - } - PAL_TerminateEx(FAIL); - return FAIL; - } - - - /* move the file pointer 0 bytes from the beginning and verify */ - dwRc = SetFilePointer(hFile, 0, NULL, FILE_CURRENT); - if (dwRc != 0) - { - Trace("SetFilePointer: ERROR -> Asked to move 0 bytes from the " - "beginning of the file but moved %ld bytes.\n", dwRc); - if (CloseHandle(hFile) != TRUE) - { - Trace("SetFilePointer: ERROR -> Unable to close file \"%s\".\n", - szTextFile); - } - if (!DeleteFileA(szTextFile)) - { - Trace("SetFilePointer: ERROR -> Unable to delete file \"%s\".\n", - szTextFile); - } - PAL_TerminateEx(FAIL); - return FAIL; - } - - /* move the pointer ahead in the file and verify */ - dwRc = SetFilePointer(hFile, 20, NULL, FILE_CURRENT); - if (dwRc != 20) - { - Trace("SetFilePointer: ERROR -> Asked to move 20 bytes from the " - "beginning of the file but moved %ld bytes.\n", dwRc); - if (CloseHandle(hFile) != TRUE) - { - Trace("SetFilePointer: ERROR -> Unable to close file \"%s\".\n", - szTextFile); - } - if (!DeleteFileA(szTextFile)) - { - Trace("SetFilePointer: ERROR -> Unable to delete file \"%s\".\n", - szTextFile); - } - PAL_TerminateEx(FAIL); - return FAIL; - } - else - { - /* verify results */ - memset(szBuffer, 0, 100); - bRc = ReadFile(hFile, szBuffer, (DWORD)strlen(szText)-20, &dwByteCount, - NULL); - if ((bRc != TRUE) || (dwByteCount != strlen(szText)-20)) - { - Trace("SetFilePointer: ERROR -> ReadFile failed to read correctly"); - if (CloseHandle(hFile) != TRUE) - { - Trace("SetFilePointer: ERROR -> Unable to close file \"%s\".\n", - szTextFile); - } - if (!DeleteFileA(szTextFile)) - { - Trace("SetFilePointer: ERROR -> Unable to delete file" - " \"%s\".\n", szTextFile); - } - PAL_TerminateEx(FAIL); - return FAIL; - } - szPtr = szText + 20;; - if (strcmp(szPtr, szBuffer) != 0) - { - Trace("SetFilePointer: ERROR -> Apparently failed to move the" - " pointer properly\n"); - if (CloseHandle(hFile) != TRUE) - { - Trace("SetFilePointer: ERROR -> Unable to close file \"%s\".\n", - szTextFile); - } - if (!DeleteFileA(szTextFile)) - { - Trace("SetFilePointer: ERROR -> Unable to delete file" - " \"%s\".\n", szTextFile); - } - PAL_TerminateEx(FAIL); - return FAIL; - } - } - - - /* get the current file pointer position (should be 52) */ - dwRc = SetFilePointer(hFile, 0, NULL, FILE_CURRENT); - if (dwRc != 52) - { - Trace("SetFilePointer: ERROR -> Asked for current position." - " Should be 52 but was %ld.\n", dwRc); - if (CloseHandle(hFile) != TRUE) - { - Trace("SetFilePointer: ERROR -> Unable to close file \"%s\".\n", - szTextFile); - } - if (!DeleteFileA(szTextFile)) - { - Trace("SetFilePointer: ERROR -> Unable to delete file \"%s\".\n", - szTextFile); - } - PAL_TerminateEx(FAIL); - return FAIL; - } - - - /* move the pointer backwards in the file and verify */ - dwRc = SetFilePointer(hFile, -10, NULL, FILE_CURRENT); - if (dwRc != 42) - { - Trace("SetFilePointer: ERROR -> Asked to move back 10 bytes from the" - "end of the file but moved it to position %ld.\n", dwRc); - if (CloseHandle(hFile) != TRUE) - { - Trace("SetFilePointer: ERROR -> Unable to close file \"%s\".\n", - szTextFile); - } - if (!DeleteFileA(szTextFile)) - { - Trace("SetFilePointer: ERROR -> Unable to delete file \"%s\".\n", - szTextFile); - } - PAL_TerminateEx(FAIL); - return FAIL; - } - else - { - /* verify results */ - memset(szBuffer, 0, 100); - bRc = ReadFile(hFile, szBuffer, 10, &dwByteCount, NULL); - if ((bRc != TRUE) || (dwByteCount != 10)) - { - Trace("SetFilePointer: ERROR -> ReadFile failed to read correctly"); - if (CloseHandle(hFile) != TRUE) - { - Trace("SetFilePointer: ERROR -> Unable to close file \"%s\".\n", - szTextFile); - } - if (!DeleteFileA(szTextFile)) - { - Trace("SetFilePointer: ERROR -> Unable to delete file" - " \"%s\".\n", szTextFile); - } - PAL_TerminateEx(FAIL); - return FAIL; - } - szPtr = szText + 42; - if (strcmp(szPtr, szBuffer) != 0) - { - Trace("SetFilePointer: ERROR -> Apparently failed to move the" - " pointer properly\n"); - if (CloseHandle(hFile) != TRUE) - { - Trace("SetFilePointer: ERROR -> Unable to close file \"%s\".\n", - szTextFile); - } - if (!DeleteFileA(szTextFile)) - { - Trace("SetFilePointer: ERROR -> Unable to delete file" - " \"%s\".\n", szTextFile); - } - PAL_TerminateEx(FAIL); - return FAIL; - } - } - - /* - * the file pointer is currently at the end of the file so... - * set the pointer past the end of the file and verify - */ - dwRc = SetFilePointer(hFile, 20, NULL, FILE_CURRENT); - if ((dwRc == INVALID_SET_FILE_POINTER) && (GetLastError() != ERROR_SUCCESS)) - { - Trace("SetFilePointer: ERROR -> Failed to move pointer past EOF.\n"); - if (CloseHandle(hFile) != TRUE) - { - Trace("SetFilePointer: ERROR -> Unable to close file \"%s\".\n", - szTextFile); - } - if (!DeleteFileA(szTextFile)) - { - Trace("SetFilePointer: ERROR -> Unable to delete file \"%s\".\n", - szTextFile); - } - PAL_TerminateEx(FAIL); - return FAIL; - } - else - { - if (SetFilePointer(hFile, 0, NULL, FILE_CURRENT) != strlen(szText)+20) - { - Trace("SetFilePointer: ERROR -> Failed to move pointer past" - " EOF.\n"); - if (CloseHandle(hFile) != TRUE) - { - Trace("SetFilePointer: ERROR -> Unable to close file \"%s\".\n", - szTextFile); - } - if (!DeleteFileA(szTextFile)) - { - Trace("SetFilePointer: ERROR -> Unable to delete file" - " \"%s\".\n", szTextFile); - } - PAL_TerminateEx(FAIL); - return FAIL; - } - } - - if (CloseHandle(hFile) != TRUE) - { - Trace("SetFilePointer: ERROR -> Unable to close file \"%s\".\n", - szTextFile); - if (!DeleteFileA(szTextFile)) - { - Trace("SetFilePointer: ERROR -> Unable to delete file \"%s\".\n", - szTextFile); - } - PAL_TerminateEx(FAIL); - return FAIL; - } - - if (!DeleteFileA(szTextFile)) - { - Fail("SetFilePointer: ERROR -> Unable to delete file \"%s\".\n", - szTextFile); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/file_io/SetFilePointer/test3/testinfo.dat b/src/pal/tests/palsuite/file_io/SetFilePointer/test3/testinfo.dat deleted file mode 100644 index 7c51fbc38..000000000 --- a/src/pal/tests/palsuite/file_io/SetFilePointer/test3/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = SetFilePointer -Name = Positive Test for SetFilePointer (test 3) -Type = DEFAULT -EXE1 = setfilepointer -Description -=Tests the FILE_CURRENT option - diff --git a/src/pal/tests/palsuite/file_io/SetFilePointer/test4/CMakeLists.txt b/src/pal/tests/palsuite/file_io/SetFilePointer/test4/CMakeLists.txt deleted file mode 100644 index 6fc811680..000000000 --- a/src/pal/tests/palsuite/file_io/SetFilePointer/test4/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - SetFilePointer.cpp -) - -add_executable(paltest_setfilepointer_test4 - ${SOURCES} -) - -add_dependencies(paltest_setfilepointer_test4 coreclrpal) - -target_link_libraries(paltest_setfilepointer_test4 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/SetFilePointer/test4/SetFilePointer.cpp b/src/pal/tests/palsuite/file_io/SetFilePointer/test4/SetFilePointer.cpp deleted file mode 100644 index 2993cfd35..000000000 --- a/src/pal/tests/palsuite/file_io/SetFilePointer/test4/SetFilePointer.cpp +++ /dev/null @@ -1,242 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: SetFilePointer.c (test 4) -** -** Purpose: Tests the PAL implementation of the SetFilePointer function. -** Test the FILE_END option -** -** Assumes Successful: -** CreateFile -** ReadFile -** WriteFile -** strlen -** CloseHandle -** strcmp -** GetFileSize -** -** -**===================================================================*/ - -#include - -const char* szText = "The quick brown fox jumped over the lazy dog's back."; -const char* szTextFile = "text.txt"; - - -int __cdecl main(int argc, char *argv[]) -{ - HANDLE hFile = NULL; - DWORD dwByteCount = 0; - DWORD dwOffset = 0; - DWORD dwRc = 0; - BOOL bRc = FALSE; - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - /* create a test file */ - hFile = CreateFile(szTextFile, - GENERIC_READ | GENERIC_WRITE, - FILE_SHARE_READ | FILE_SHARE_WRITE, - NULL, - CREATE_ALWAYS, - FILE_ATTRIBUTE_NORMAL, - NULL); - - if(hFile == INVALID_HANDLE_VALUE) - { - Fail("SetFilePointer: ERROR -> Unable to create file \"%s\".\n", - szTextFile); - } - - bRc = WriteFile(hFile, szText, (DWORD)strlen(szText), &dwByteCount, NULL); - if (bRc == FALSE) - { - Trace("SetFilePointer: ERROR -> Unable to write to file \"%s\".\n", - szTextFile); - if (CloseHandle(hFile) != TRUE) - { - Trace("SetFilePointer: ERROR -> Unable to close file \"%s\".\n", - szTextFile); - } - if (!DeleteFileA(szTextFile)) - { - Trace("SetFilePointer: ERROR -> Unable to delete file \"%s\".\n", - szTextFile); - } - PAL_TerminateEx(FAIL); - return FAIL; - } - - - /* - * move -1 from the end - */ - dwRc = SetFilePointer(hFile, -1, NULL, FILE_END); - if (dwRc == INVALID_SET_FILE_POINTER) - { - if (GetLastError() != ERROR_SUCCESS) - { - Trace("SetFilePointer: ERROR -> Failed to move the pointer " - "back one character from EOF.\n"); - if (CloseHandle(hFile) != TRUE) - { - Trace("SetFilePointer: ERROR -> Unable to close file" - " \"%s\".\n", szTextFile); - } - if (!DeleteFileA(szTextFile)) - { - Trace("SetFilePointer: ERROR -> Unable to delete file" - " \"%s\".\n", szTextFile); - } - PAL_TerminateEx(FAIL); - return FAIL; - } - } - else - { - /* verify */ - if ((dwRc != strlen(szText)-1)) - { - Trace("SetFilePointer: ERROR -> Failed to move the pointer" - " -1 bytes from EOF\n"); - if (CloseHandle(hFile) != TRUE) - { - Trace("SetFilePointer: ERROR -> Unable to close file" - " \"%s\".\n", szTextFile); - } - if (!DeleteFileA(szTextFile)) - { - Trace("SetFilePointer: ERROR -> Unable to delete file" - " \"%s\".\n", szTextFile); - } - PAL_TerminateEx(FAIL); - return FAIL; - } - } - - /* - * move the file pointer 0 bytes from the end and verify - */ - dwRc = SetFilePointer(hFile, 0, NULL, FILE_END); - if (dwRc != strlen(szText)) - { - Trace("SetFilePointer: ERROR -> Asked to move 0 bytes from the " - "end of the file. Function returned %ld instead of 52.\n", dwRc); - if (CloseHandle(hFile) != TRUE) - { - Trace("SetFilePointer: ERROR -> Unable to close file \"%s\".\n", - szTextFile); - } - if (!DeleteFileA(szTextFile)) - { - Trace("SetFilePointer: ERROR -> Unable to delete file \"%s\".\n", - szTextFile); - } - PAL_TerminateEx(FAIL); - return FAIL; - } - - /* - * move the pointer past the end of the file and verify - */ - dwRc = SetFilePointer(hFile, 20, NULL, FILE_END); - if (dwRc != strlen(szText)+20) - { - Trace("SetFilePointer: ERROR -> Asked to move 20 bytes past the " - "end of the file. Function returned %ld instead of %d.\n", - dwRc, - strlen(szText)+20); - if (CloseHandle(hFile) != TRUE) - { - Trace("SetFilePointer: ERROR -> Unable to close file \"%s\".\n", - szTextFile); - } - if (!DeleteFileA(szTextFile)) - { - Trace("SetFilePointer: ERROR -> Unable to delete file \"%s\".\n", - szTextFile); - } - PAL_TerminateEx(FAIL); - return FAIL; - } - else - { - /* verify results */ - bRc = SetEndOfFile(hFile); - if ((dwRc = GetFileSize(hFile, NULL)) != strlen(szText)+20) - { - Trace("SetFilePointer: ERROR -> Asked to move back 20 bytes past" - " theend of the file. GetFileSize returned %ld whereas it " - "should have been %d.\n", - dwRc, - strlen(szText)+20); - if (CloseHandle(hFile) != TRUE) - { - Trace("SetFilePointer: ERROR -> Unable to close file" - " \"%s\".\n", szTextFile); - } - if (!DeleteFileA(szTextFile)) - { - Trace("SetFilePointer: ERROR -> Unable to delete file" - " \"%s\".\n", szTextFile); - } - PAL_TerminateEx(FAIL); - return FAIL; - } - } - - - /* - * move the pointer backwards to before the start of the file and verify - */ - - dwOffset = (dwRc + 20) * -1; - dwRc = SetFilePointer(hFile, dwOffset, NULL, FILE_END); - if ((dwRc != INVALID_SET_FILE_POINTER) || - (GetLastError() == ERROR_SUCCESS)) - { - Trace("SetFilePointer: ERROR -> Was able to move the pointer " - "to before the beginning of the file.\n"); - if (CloseHandle(hFile) != TRUE) - { - Trace("SetFilePointer: ERROR -> Unable to close file \"%s\".\n", - szTextFile); - } - if (!DeleteFileA(szTextFile)) - { - Trace("SetFilePointer: ERROR -> Unable to delete file \"%s\".\n", - szTextFile); - } - PAL_TerminateEx(FAIL); - return FAIL; - } - - - if (CloseHandle(hFile) != TRUE) - { - Trace("SetFilePointer: ERROR -> Unable to close file \"%s\".\n", - szTextFile); - if (!DeleteFileA(szTextFile)) - { - Trace("SetFilePointer: ERROR -> Unable to delete file \"%s\".\n", - szTextFile); - } - PAL_TerminateEx(FAIL); - return FAIL; - } - - if (!DeleteFileA(szTextFile)) - { - Fail("SetFilePointer: ERROR -> Unable to delete file \"%s\".\n", - szTextFile); - } - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/file_io/SetFilePointer/test4/testinfo.dat b/src/pal/tests/palsuite/file_io/SetFilePointer/test4/testinfo.dat deleted file mode 100644 index dce6f9eb2..000000000 --- a/src/pal/tests/palsuite/file_io/SetFilePointer/test4/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = SetFilePointer -Name = Positive Test for SetFilePointer (test 4) -Type = DEFAULT -EXE1 = setfilepointer -Description -=Tests the FILE_END option - diff --git a/src/pal/tests/palsuite/file_io/SetFilePointer/test5/CMakeLists.txt b/src/pal/tests/palsuite/file_io/SetFilePointer/test5/CMakeLists.txt deleted file mode 100644 index 758434903..000000000 --- a/src/pal/tests/palsuite/file_io/SetFilePointer/test5/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - SetFilePointer.cpp -) - -add_executable(paltest_setfilepointer_test5 - ${SOURCES} -) - -add_dependencies(paltest_setfilepointer_test5 coreclrpal) - -target_link_libraries(paltest_setfilepointer_test5 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/SetFilePointer/test5/SetFilePointer.cpp b/src/pal/tests/palsuite/file_io/SetFilePointer/test5/SetFilePointer.cpp deleted file mode 100644 index f1d392da3..000000000 --- a/src/pal/tests/palsuite/file_io/SetFilePointer/test5/SetFilePointer.cpp +++ /dev/null @@ -1,182 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: SetFilePointer.c (test 5) -** -** Purpose: Tests the PAL implementation of the SetFilePointer function. -** Test the FILE_BEGIN option using the high word parameter -** -** Assumes Successful: -** CreateFile -** ReadFile -** WriteFile -** strlen -** CloseHandle -** strcmp -** GetFileSize -** -** -**===================================================================*/ - -#include - -const char* szTextFile = "text.txt"; - -int __cdecl main(int argc, char *argv[]) -{ - HANDLE hFile = NULL; - DWORD dwOffset = 1; - LONG dwHighWord = 1; - DWORD dwReturnedOffset = 0; - DWORD dwReturnedHighWord = 0; - DWORD dwRc = 0; - DWORD dwError = 0; - BOOL bRc = FALSE; - - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - /* create a test file */ - hFile = CreateFile(szTextFile, - GENERIC_READ | GENERIC_WRITE, - FILE_SHARE_READ | FILE_SHARE_WRITE, - NULL, - CREATE_ALWAYS, - FILE_ATTRIBUTE_NORMAL, - NULL); - - if(hFile == INVALID_HANDLE_VALUE) - { - dwError = GetLastError(); - Fail("SetFilePointer: ERROR -> Unable to create file \"%s\".\n with " - "error %ld", - szTextFile, - GetLastError()); - } - - - - /* move -1 from beginning which should fail */ - dwRc = SetFilePointer(hFile, -1, &dwHighWord, FILE_BEGIN); - if (dwRc != INVALID_SET_FILE_POINTER) - { - Trace("SetFilePointer: ERROR -> Succeeded to move the pointer " - "before the beginning of the file using the high word.\n"); - bRc = CloseHandle(hFile); - if (bRc != TRUE) - { - Trace("SetFilePointer: ERROR -> Unable to close file \"%s\".\n", - szTextFile); - } - if (!DeleteFileA(szTextFile)) - { - Trace("SetFilePointer: ERROR -> Unable to delete file \"%s\".\n", - szTextFile); - } - PAL_TerminateEx(FAIL); - return FAIL; - } - - /* set the pointer past the end of the file and verify */ - dwRc = SetFilePointer(hFile, dwOffset, &dwHighWord, FILE_BEGIN); - if ((dwRc == INVALID_SET_FILE_POINTER) && - ((dwError = GetLastError()) != ERROR_SUCCESS)) - { - Trace("SetFilePointer: ERROR -> Failed to move pointer past EOF.\n"); - bRc = CloseHandle(hFile); - if (bRc != TRUE) - { - Trace("SetFilePointer: ERROR -> Unable to close file \"%s\".\n", - szTextFile); - } - if (!DeleteFileA(szTextFile)) - { - Trace("SetFilePointer: ERROR -> Unable to delete file \"%s\".\n", - szTextFile); - } - PAL_TerminateEx(FAIL); - return FAIL; - } - else - { - /* verify */ - bRc = SetEndOfFile(hFile); - if (bRc != TRUE) - { - dwError = GetLastError(); - if (dwError == 112) - { - Trace("SetFilePointer: ERROR -> SetEndOfFile failed due to " - "lack of disk space\n"); - } - else - { - Trace("SetFilePointer: ERROR -> SetEndOfFile call failed with " - "error %ld\n", dwError); - } - bRc = CloseHandle(hFile); - if (bRc != TRUE) - { - Trace("SetFilePointer: ERROR -> Unable to close file" - " \"%s\".\n", szTextFile); - } - if (!DeleteFileA(szTextFile)) - { - Trace("SetFilePointer: ERROR -> Unable to delete file" - " \"%s\".\n", szTextFile); - } - PAL_TerminateEx(FAIL); - return FAIL; - } - - dwReturnedOffset = GetFileSize(hFile, &dwReturnedHighWord); - if ((dwOffset != dwReturnedOffset) || - (dwHighWord != dwReturnedHighWord)) - { - Trace("SetFilePointer: ERROR -> Failed to move pointer past" - " EOF.\n"); - bRc = CloseHandle(hFile); - if (bRc != TRUE) - { - Trace("SetFilePointer: ERROR -> Unable to close file" - " \"%s\".\n", szTextFile); - } - if (!DeleteFileA(szTextFile)) - { - Trace("SetFilePointer: ERROR -> Unable to delete file" - " \"%s\".\n", szTextFile); - } - PAL_TerminateEx(FAIL); - return FAIL; - } - } - - bRc = CloseHandle(hFile); - if (bRc != TRUE) - { - Trace("SetFilePointer: ERROR -> Unable to close file \"%s\".\n", - szTextFile); - if (!DeleteFileA(szTextFile)) - { - Trace("SetFilePointer: ERROR -> Unable to delete file \"%s\".\n", - szTextFile); - } - PAL_TerminateEx(FAIL); - return FAIL; - } - - if (!DeleteFileA(szTextFile)) - { - Fail("SetFilePointer: ERROR -> Unable to delete file \"%s\".\n", - szTextFile); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/file_io/SetFilePointer/test5/testinfo.dat b/src/pal/tests/palsuite/file_io/SetFilePointer/test5/testinfo.dat deleted file mode 100644 index 64745c0e9..000000000 --- a/src/pal/tests/palsuite/file_io/SetFilePointer/test5/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = SetFilePointer -Name = Positive Test for SetFilePointer (test 5) -Type = DEFAULT -EXE1 = setfilepointer -Description -=Tests the FILE_BEGIN option with the high word parameter. -=This test requires about 4 gig free disk space - diff --git a/src/pal/tests/palsuite/file_io/SetFilePointer/test6/CMakeLists.txt b/src/pal/tests/palsuite/file_io/SetFilePointer/test6/CMakeLists.txt deleted file mode 100644 index 3e9f6496c..000000000 --- a/src/pal/tests/palsuite/file_io/SetFilePointer/test6/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - SetFilePointer.cpp -) - -add_executable(paltest_setfilepointer_test6 - ${SOURCES} -) - -add_dependencies(paltest_setfilepointer_test6 coreclrpal) - -target_link_libraries(paltest_setfilepointer_test6 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/SetFilePointer/test6/SetFilePointer.cpp b/src/pal/tests/palsuite/file_io/SetFilePointer/test6/SetFilePointer.cpp deleted file mode 100644 index b35247ec2..000000000 --- a/src/pal/tests/palsuite/file_io/SetFilePointer/test6/SetFilePointer.cpp +++ /dev/null @@ -1,213 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: SetFilePointer.c (test 6) -** -** Purpose: Tests the PAL implementation of the SetFilePointer function. -** Test the FILE_CURRENT option with high order support -** -** Assumes Successful: -** CreateFile -** ReadFile -** WriteFile -** strlen -** CloseHandle -** strcmp -** GetFileSize -** -** -**===================================================================*/ - -#include - -const char* szTextFile = "text.txt"; - - -int __cdecl main(int argc, char *argv[]) -{ - HANDLE hFile = NULL; - DWORD dwOffset = 0; - LONG dwHighOrder = 0; - DWORD dwReturnedOffset = 0; - LONG dwReturnedHighOrder = 0; - DWORD dwRc = 0; - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - /* create a test file */ - hFile = CreateFile(szTextFile, - GENERIC_READ | GENERIC_WRITE, - FILE_SHARE_READ | FILE_SHARE_WRITE, - NULL, - CREATE_ALWAYS, - FILE_ATTRIBUTE_NORMAL, - NULL); - - if(hFile == INVALID_HANDLE_VALUE) - { - Fail("SetFilePointer: ERROR -> Unable to create file \"%s\".\n", - szTextFile); - } - - - /* move waaaay before the beginning which should fail */ - dwHighOrder = -1; - dwOffset = 0; - dwRc = SetFilePointer(hFile, dwOffset, &dwHighOrder, FILE_CURRENT); - if (dwRc != INVALID_SET_FILE_POINTER) - { - Trace("SetFilePointer: ERROR -> Succeeded to move the pointer " - "before the beginning of the file.\n"); - if (CloseHandle(hFile) != TRUE) - { - Trace("SetFilePointer: ERROR -> Unable to close file \"%s\".\n", - szTextFile); - } - if (!DeleteFileA(szTextFile)) - { - Trace("SetFilePointer: ERROR -> Unable to delete file \"%s\".\n", - szTextFile); - } - PAL_TerminateEx(FAIL); - return FAIL; - } - - /* move the pointer ahead in the file and verify */ - dwHighOrder = 1; - dwOffset = 10; - dwRc = SetFilePointer(hFile, dwOffset, &dwHighOrder, FILE_CURRENT); - if ((dwRc != 10) || (dwHighOrder != 1)) - { - Trace("SetFilePointer: ERROR -> Asked to move 2GB plus 10 bytes from " - "the beginning of the file but didn't.\n"); - if (CloseHandle(hFile) != TRUE) - { - Trace("SetFilePointer: ERROR -> Unable to close file \"%s\".\n", - szTextFile); - } - if (!DeleteFileA(szTextFile)) - { - Trace("SetFilePointer: ERROR -> Unable to delete file \"%s\".\n", - szTextFile); - } - PAL_TerminateEx(FAIL); - return FAIL; - } - else - { - /* verify results */ - if (SetEndOfFile(hFile) != TRUE) - { - Trace("SetFilePointer: ERROR -> Call to SetEndOfFile failed with " - "error code: %d\n", GetLastError()); - if (CloseHandle(hFile) != TRUE) - { - Trace("SetFilePointer: ERROR -> Unable to close file" - " \"%s\".\n", szTextFile); - } - if (!DeleteFileA(szTextFile)) - { - Trace("SetFilePointer: ERROR -> Unable to delete file" - " \"%s\".\n", szTextFile); - } - PAL_TerminateEx(FAIL); - return FAIL; - } - dwReturnedOffset = GetFileSize(hFile, (DWORD*)&dwReturnedHighOrder); - if ((dwReturnedOffset != dwOffset) || - (dwReturnedHighOrder != dwHighOrder)) - { - Trace("SetFilePointer: ERROR -> Asked to move far past the " - "current file pointer. " - "low order sent: %ld low order returned: %ld " - "high order sent: %ld high order returned: %ld", - dwOffset, dwReturnedOffset, - dwHighOrder, dwReturnedHighOrder); - if (!DeleteFileA(szTextFile)) - { - Trace("SetFilePointer: ERROR -> Unable to delete file" - " \"%s\".\n", szTextFile); - } - PAL_TerminateEx(FAIL); - return FAIL; - } - } - - - /* - * move the pointer backwards in the file and verify - */ - dwOffset = 0; - dwHighOrder = -1; - dwRc = SetFilePointer(hFile, dwOffset, &dwHighOrder, FILE_CURRENT); - if (dwRc != 10) - { - Trace("SetFilePointer: ERROR -> Asked to move back to 10 bytes from the" - "beginning of the file but moved it to position %ld.\n", dwRc); - if (CloseHandle(hFile) != TRUE) - { - Trace("SetFilePointer: ERROR -> Unable to close file \"%s\".\n", - szTextFile); - } - if (!DeleteFileA(szTextFile)) - { - Trace("SetFilePointer: ERROR -> Unable to delete file \"%s\".\n", - szTextFile); - } - PAL_TerminateEx(FAIL); - return FAIL; - } - else - { - /* verify results */ - dwReturnedHighOrder = 0; - dwRc = SetFilePointer(hFile, 0, &dwReturnedHighOrder, FILE_CURRENT); - if (dwRc != 10) - { - Trace("SetFilePointer: ERROR -> Asked for current position. " - "Should be 10 but was %ld.\n", dwRc); - if (CloseHandle(hFile) != TRUE) - { - Trace("SetFilePointer: ERROR -> Unable to close file" - " \"%s\".\n", szTextFile); - } - if (!DeleteFileA(szTextFile)) - { - Trace("SetFilePointer: ERROR -> Unable to delete file" - " \"%s\".\n", szTextFile); - } - PAL_TerminateEx(FAIL); - return FAIL; - } - } - - - /* clean up, clean up, everybody do their share... */ - if (CloseHandle(hFile) != TRUE) - { - Trace("SetFilePointer: ERROR -> Unable to close file \"%s\".\n", - szTextFile); - if (!DeleteFileA(szTextFile)) - { - Trace("SetFilePointer: ERROR -> Unable to delete file \"%s\".\n", - szTextFile); - } - PAL_TerminateEx(FAIL); - return FAIL; - } - - if (!DeleteFileA(szTextFile)) - { - Fail("SetFilePointer: ERROR -> Unable to delete file \"%s\".\n", - szTextFile); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/file_io/SetFilePointer/test6/testinfo.dat b/src/pal/tests/palsuite/file_io/SetFilePointer/test6/testinfo.dat deleted file mode 100644 index 3138e9bb4..000000000 --- a/src/pal/tests/palsuite/file_io/SetFilePointer/test6/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = SetFilePointer -Name = Positive Test for SetFilePointer (test 6) -Type = DEFAULT -EXE1 = setfilepointer -Description -=Tests the FILE_CURRENT option with the high word parameter. -=This test requires about 4 GB free disk space. - diff --git a/src/pal/tests/palsuite/file_io/SetFilePointer/test7/CMakeLists.txt b/src/pal/tests/palsuite/file_io/SetFilePointer/test7/CMakeLists.txt deleted file mode 100644 index 14f4910e3..000000000 --- a/src/pal/tests/palsuite/file_io/SetFilePointer/test7/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - SetFilePointer.cpp -) - -add_executable(paltest_setfilepointer_test7 - ${SOURCES} -) - -add_dependencies(paltest_setfilepointer_test7 coreclrpal) - -target_link_libraries(paltest_setfilepointer_test7 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/SetFilePointer/test7/SetFilePointer.cpp b/src/pal/tests/palsuite/file_io/SetFilePointer/test7/SetFilePointer.cpp deleted file mode 100644 index 33dfd5e71..000000000 --- a/src/pal/tests/palsuite/file_io/SetFilePointer/test7/SetFilePointer.cpp +++ /dev/null @@ -1,213 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: SetFilePointer.c (test 7) -** -** Purpose: Tests the PAL implementation of the SetFilePointer function. -** Test the FILE_END option with high order support -** -** Assumes Successful: -** CreateFile -** ReadFile -** WriteFile -** strlen -** CloseHandle -** strcmp -** GetFileSize -** -** -**===================================================================*/ - -#include - -const char* szTextFile = "text.txt"; - - -int __cdecl main(int argc, char *argv[]) -{ - HANDLE hFile = NULL; - DWORD dwOffset = 0; - LONG dwHighOrder = 0; - DWORD dwReturnedOffset = 0; - LONG dwReturnedHighOrder = 0; - DWORD dwRc = 0; - - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - /* create a test file */ - hFile = CreateFile(szTextFile, - GENERIC_READ | GENERIC_WRITE, - FILE_SHARE_READ | FILE_SHARE_WRITE, - NULL, - CREATE_ALWAYS, - FILE_ATTRIBUTE_NORMAL, - NULL); - - if(hFile == INVALID_HANDLE_VALUE) - { - Fail("SetFilePointer: ERROR -> Unable to create file \"%s\".\n", - szTextFile); - } - - - /* move -1 from beginning which should fail */ - dwHighOrder = -1; - dwOffset = 0; - dwRc = SetFilePointer(hFile, dwOffset, &dwHighOrder, FILE_END); - if (dwRc != INVALID_SET_FILE_POINTER) - { - Trace("SetFilePointer: ERROR -> Succeeded to move the pointer " - "before the beginning of the file.\n"); - if (CloseHandle(hFile) != TRUE) - { - Trace("SetFilePointer: ERROR -> Unable to close file \"%s\".\n", - szTextFile); - } - if (!DeleteFileA(szTextFile)) - { - Trace("SetFilePointer: ERROR -> Unable to delete file \"%s\".\n", - szTextFile); - } - PAL_TerminateEx(FAIL); - return FAIL; - } - - /* move the pointer ahead in the file and verify */ - dwHighOrder = 1; - dwOffset = 10; - dwRc = SetFilePointer(hFile, dwOffset, &dwHighOrder, FILE_END); - if ((dwRc != 10) || (dwHighOrder != 1)) - { - Trace("SetFilePointer: ERROR -> Asked to move 4GB plus 10 bytes from " - "the beginning of the file but didn't.\n"); - if (CloseHandle(hFile) != TRUE) - { - Trace("SetFilePointer: ERROR -> Unable to close file \"%s\".\n", - szTextFile); - } - if (!DeleteFileA(szTextFile)) - { - Trace("SetFilePointer: ERROR -> Unable to delete file \"%s\".\n", - szTextFile); - } - PAL_TerminateEx(FAIL); - return FAIL; - } - else - { - /* verify results */ - if (SetEndOfFile(hFile) != TRUE) - { - Trace("SetFilePointer: ERROR -> Call to SetEndOfFile failed with " - "error code: %d\n", - GetLastError()); - if (CloseHandle(hFile) != TRUE) - { - Trace("SetFilePointer: ERROR -> Unable to close file \"%s\".\n", - szTextFile); - } - if (!DeleteFileA(szTextFile)) - { - Trace("SetFilePointer: ERROR -> Unable to delete file \"%s\".\n", - szTextFile); - } - PAL_TerminateEx(FAIL); - return FAIL; - } - dwReturnedOffset = GetFileSize(hFile, (DWORD*)&dwReturnedHighOrder); - if ((dwReturnedOffset != dwOffset) || (dwReturnedHighOrder != dwHighOrder)) - { - Trace("SetFilePointer: ERROR -> Asked to move far past the " - "end of the file. low order sent: %ld low order returned: %ld " - "high order sent: %ld high order returned: %ld", - dwOffset, dwReturnedOffset, - dwHighOrder, dwReturnedHighOrder); - if (!DeleteFileA(szTextFile)) - { - Trace("SetFilePointer: ERROR -> Unable to delete file \"%s\".\n", - szTextFile); - } - PAL_TerminateEx(FAIL); - return FAIL; - } - } - - - /* - * move the pointer backwards in the file and verify - */ - dwOffset = 0; - dwHighOrder = -1; - dwRc = SetFilePointer(hFile, dwOffset, &dwHighOrder, FILE_END); - if (dwRc != 10) - { - Trace("SetFilePointer: ERROR -> Asked to move back to 10 bytes from the" - "beginning of the file but moved it to position %ld.\n", dwRc); - if (CloseHandle(hFile) != TRUE) - { - Trace("SetFilePointer: ERROR -> Unable to close file \"%s\".\n", - szTextFile); - } - if (!DeleteFileA(szTextFile)) - { - Trace("SetFilePointer: ERROR -> Unable to delete file \"%s\".\n", - szTextFile); - } - PAL_TerminateEx(FAIL); - return FAIL; - } - else - { - /* verify results */ - dwReturnedHighOrder = 0; - dwRc = SetFilePointer(hFile, 0, &dwReturnedHighOrder, FILE_CURRENT); - if (dwRc != 10) - { - Trace("SetFilePointer: ERROR -> Asked for current position. " - "Should be 10 but was %ld.\n", dwRc); - if (CloseHandle(hFile) != TRUE) - { - Trace("SetFilePointer: ERROR -> Unable to close file" - " \"%s\".\n", szTextFile); - } - if (!DeleteFileA(szTextFile)) - { - Trace("SetFilePointer: ERROR -> Unable to delete file" - " \"%s\".\n", szTextFile); - } - PAL_TerminateEx(FAIL); - return FAIL; - } - } - - - /* clean up, clean up, everybody do their share... */ - if (CloseHandle(hFile) != TRUE) - { - Trace("SetFilePointer: ERROR -> Unable to close file \"%s\".\n", - szTextFile); - if (!DeleteFileA(szTextFile)) - { - Trace("SetFilePointer: ERROR -> Unable to delete file \"%s\".\n", - szTextFile); - } - PAL_TerminateEx(FAIL); - return FAIL; - } - - if (!DeleteFileA(szTextFile)) - { - Fail("SetFilePointer: ERROR -> Unable to delete file \"%s\".\n", - szTextFile); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/file_io/SetFilePointer/test7/testinfo.dat b/src/pal/tests/palsuite/file_io/SetFilePointer/test7/testinfo.dat deleted file mode 100644 index 6e8826291..000000000 --- a/src/pal/tests/palsuite/file_io/SetFilePointer/test7/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = SetFilePointer -Name = Positive Test for SetFilePointer (test 7) -Type = DEFAULT -EXE1 = setfilepointer -Description -=Tests the FILE_END option with the high word parameter -=This test requires about 4 GB of free disk space. - diff --git a/src/pal/tests/palsuite/file_io/WriteFile/CMakeLists.txt b/src/pal/tests/palsuite/file_io/WriteFile/CMakeLists.txt deleted file mode 100644 index 8083faf65..000000000 --- a/src/pal/tests/palsuite/file_io/WriteFile/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) -add_subdirectory(test3) -add_subdirectory(test4) -add_subdirectory(test5) - diff --git a/src/pal/tests/palsuite/file_io/WriteFile/test1/CMakeLists.txt b/src/pal/tests/palsuite/file_io/WriteFile/test1/CMakeLists.txt deleted file mode 100644 index da7bbf764..000000000 --- a/src/pal/tests/palsuite/file_io/WriteFile/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - WriteFile.cpp -) - -add_executable(paltest_writefile_test1 - ${SOURCES} -) - -add_dependencies(paltest_writefile_test1 coreclrpal) - -target_link_libraries(paltest_writefile_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/WriteFile/test1/WriteFile.cpp b/src/pal/tests/palsuite/file_io/WriteFile/test1/WriteFile.cpp deleted file mode 100644 index 1ac38ddaf..000000000 --- a/src/pal/tests/palsuite/file_io/WriteFile/test1/WriteFile.cpp +++ /dev/null @@ -1,114 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: WriteFile.c (test 1) -** -** Purpose: Tests the PAL implementation of the WriteFile function. -** This test will attempt to write to a NULL handle and a -** read-only file -** -** -**===================================================================*/ - -#include - - -const char* szStringTest = "The quick fox jumped over the lazy dog's back."; -const char* szReadOnlyFile = "ReadOnly.txt"; -void do_cleanup() -{ - BOOL bRc = FALSE; - bRc = DeleteFileA(szReadOnlyFile); - if (bRc != TRUE) - { - Fail ("DeleteFileA: ERROR[%ld]: During Cleanup: Couldn't delete WriteFile's" - " \"ReadOnly.txt\"\n", GetLastError()); - } - -} - -int __cdecl main(int argc, char *argv[]) -{ - HANDLE hFile = NULL; - DWORD dwBytesWritten; - BOOL bRc = FALSE; - DWORD last_error; - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - // - // Write to a NULL handle - // - - bRc = WriteFile(hFile, szStringTest, 20, &dwBytesWritten, NULL); - - if (bRc == TRUE) - { - last_error = GetLastError(); - Fail("WriteFile: ERROR[%ld] -> Able to write to a NULL handle\n", last_error); - } - - - // - // Write to a file with read-only permissions - // - - // create a file without write permissions - hFile = CreateFile(szReadOnlyFile, - GENERIC_READ, - FILE_SHARE_READ, - NULL, - OPEN_ALWAYS, - FILE_ATTRIBUTE_NORMAL, - NULL); - - if(hFile == INVALID_HANDLE_VALUE) - { - last_error = GetLastError(); - Fail("WriteFile: ERROR[%ld] -> Unable to create file \"%s\".\n", - last_error, szReadOnlyFile); - } - - if (!SetFileAttributes(szReadOnlyFile, FILE_ATTRIBUTE_READONLY)) - { - last_error = GetLastError(); - Trace("WriteFile: ERROR[%ld] -> Unable to make the file read-only.\n", last_error); - do_cleanup(); - Fail("WriteFile: ERROR[%ld] -> Unable to make the file read-only.\n", last_error); - } - - bRc = WriteFile(hFile, szStringTest, 20, &dwBytesWritten, NULL); - if (bRc == TRUE) - { last_error = GetLastError(); - Trace("WriteFile: ERROR[%ld] -> Able to write to a read-only file.\n", last_error); - do_cleanup(); - Fail("WriteFile: ERROR[%ld] -> Able to write to a read-only file.\n", last_error); - } - - - bRc = CloseHandle(hFile); - if (bRc != TRUE) - { last_error = GetLastError(); - Trace("WriteFile: ERROR[%ld] -> Unable to close file \"%s\".\n", last_error, szReadOnlyFile); - do_cleanup(); - Fail("WriteFile: ERROR -> Unable to close file \"%s\".\n", - szReadOnlyFile); - } - - //To delete file need to make it normal - if(!SetFileAttributesA(szReadOnlyFile,FILE_ATTRIBUTE_NORMAL)) - { - last_error = GetLastError(); - Fail("WriteFile: ERROR[%ld] -> Unable to make the file attribute NORMAL.\n", last_error); - - } - do_cleanup(); - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/file_io/WriteFile/test1/testinfo.dat b/src/pal/tests/palsuite/file_io/WriteFile/test1/testinfo.dat deleted file mode 100644 index 148a2678e..000000000 --- a/src/pal/tests/palsuite/file_io/WriteFile/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = WriteFile -Name = test for WriteFile -Type = DEFAULT -EXE1 = writefile -Description -=Attempt to write to a NULL handle and to a read-only file - diff --git a/src/pal/tests/palsuite/file_io/WriteFile/test2/CMakeLists.txt b/src/pal/tests/palsuite/file_io/WriteFile/test2/CMakeLists.txt deleted file mode 100644 index 86530dea7..000000000 --- a/src/pal/tests/palsuite/file_io/WriteFile/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - WriteFile.cpp -) - -add_executable(paltest_writefile_test2 - ${SOURCES} -) - -add_dependencies(paltest_writefile_test2 coreclrpal) - -target_link_libraries(paltest_writefile_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/WriteFile/test2/Results.txt b/src/pal/tests/palsuite/file_io/WriteFile/test2/Results.txt deleted file mode 100644 index 1c4c37885..000000000 --- a/src/pal/tests/palsuite/file_io/WriteFile/test2/Results.txt +++ /dev/null @@ -1 +0,0 @@ -0011100111 \ No newline at end of file diff --git a/src/pal/tests/palsuite/file_io/WriteFile/test2/WriteFile.cpp b/src/pal/tests/palsuite/file_io/WriteFile/test2/WriteFile.cpp deleted file mode 100644 index 9345bc6c4..000000000 --- a/src/pal/tests/palsuite/file_io/WriteFile/test2/WriteFile.cpp +++ /dev/null @@ -1,105 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: WriteFile.c (test 2) -** -** Purpose: Tests the PAL implementation of the WriteFile function. -** Creates a number of files and writes different amounts of -** data and verifies the writes. -** -** -**===================================================================*/ - - -#include - - -char* writeBuffer; -const char* szWritableFile = "Writeable.txt"; -const char* szResultsFile = "Results.txt"; -const int PAGESIZE = 4096; - -BOOL writeTest(DWORD dwByteCount, DWORD dwBytesWrittenResult, BOOL bResult) -{ - HANDLE hFile = NULL; - DWORD dwBytesWritten; - BOOL bRc = FALSE; - - /* create the test file */ - DeleteFile(szWritableFile); - hFile = CreateFile(szWritableFile, GENERIC_WRITE, FILE_SHARE_WRITE, - NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); - - if(hFile == INVALID_HANDLE_VALUE) - { - Trace("WriteFile: ERROR -> Unable to create file \"%s\".\n", - szWritableFile); - return FALSE; - } - - bRc = WriteFile(hFile, writeBuffer, dwByteCount, &dwBytesWritten, NULL); - CloseHandle(hFile); - - if ((bRc != bResult) || (dwBytesWrittenResult != dwBytesWritten)) - { - Trace("WriteFile returned BOOL:%d and dwWritten:%d what we do expect is" - " BOOL:%d and dwWritten:%d\n", bRc, dwBytesWritten, bResult, - dwBytesWrittenResult); - return FALSE; - } - - return TRUE; -} - -int __cdecl main(int argc, char *argv[]) -{ - const char * testString = "The quick fox jumped over the lazy dog's back."; - const int testStringLen = strlen(testString); - - DWORD dwByteCount[4] = {-1, 10, testStringLen, 0}; - DWORD dwByteWritten[4] = {0, 10, testStringLen, 0}; - BOOL bResults[] = {FALSE, TRUE, TRUE, TRUE}; - - const int BUFFER_SIZE = 2 * PAGESIZE; - int j; - BOOL bRc = FALSE; - DWORD oldProt; - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - /* allocate read-write memery for writeBuffer */ - if (!(writeBuffer = (char*) VirtualAlloc(NULL, BUFFER_SIZE, MEM_COMMIT, - PAGE_READWRITE))) - { - Fail("VirtualAlloc failed: GetLastError returns %d\n", GetLastError()); - return FAIL; - } - - memset((void*) writeBuffer, '.', BUFFER_SIZE); - strcpy(writeBuffer, testString); - - /* write protect the second page of writeBuffer */ - if (!VirtualProtect(&writeBuffer[PAGESIZE], PAGESIZE, PAGE_NOACCESS, &oldProt)) - { - Fail("VirtualProtect failed: GetLastError returns %d\n", GetLastError()); - return FAIL; - } - - for (j = 0; j< 4; j++) - { - bRc = writeTest(dwByteCount[j], dwByteWritten[j], bResults[j]); - if (bRc != TRUE) - { - Fail("WriteFile: ERROR -> Failed on test[%d]\n", j); - } - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/file_io/WriteFile/test2/testinfo.dat b/src/pal/tests/palsuite/file_io/WriteFile/test2/testinfo.dat deleted file mode 100644 index a09df962f..000000000 --- a/src/pal/tests/palsuite/file_io/WriteFile/test2/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = WriteFile -Name = Positive Test for WriteFile -Type = DEFAULT -EXE1 = writefile -Description -=Multiple tests of writes of varying sizes with verification - diff --git a/src/pal/tests/palsuite/file_io/WriteFile/test3/CMakeLists.txt b/src/pal/tests/palsuite/file_io/WriteFile/test3/CMakeLists.txt deleted file mode 100644 index 143f537ad..000000000 --- a/src/pal/tests/palsuite/file_io/WriteFile/test3/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - WriteFile.cpp -) - -add_executable(paltest_writefile_test3 - ${SOURCES} -) - -add_dependencies(paltest_writefile_test3 coreclrpal) - -target_link_libraries(paltest_writefile_test3 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/WriteFile/test3/WriteFile.cpp b/src/pal/tests/palsuite/file_io/WriteFile/test3/WriteFile.cpp deleted file mode 100644 index 751f89ff2..000000000 --- a/src/pal/tests/palsuite/file_io/WriteFile/test3/WriteFile.cpp +++ /dev/null @@ -1,136 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: WriteFile.c (test 3) -** -** Purpose: Tests the PAL implementation of the WriteFile function. -** Performs multiple writes to a file and verifies the results. -** -** -**===================================================================*/ - - -#include - - -const char* szStringTest = "The quick fox jumped over the lazy dog's back.\0"; -const char* szWritableFile = "writeable.txt"; - - -BOOL validateResults(const char* szString) -{ - FILE *pFile = NULL; - char szReadString[100]; - DWORD dwBytesRead; - DWORD dwStringLength = strlen(szString); - - - - memset(szReadString, 0, 100); - - /* open the file */ - pFile = fopen(szWritableFile, "r"); - if (pFile == NULL) - { - Trace("couldn't open test file\n"); - return FALSE; - } - - dwBytesRead = fread(szReadString, sizeof(char), dwStringLength, pFile); - fclose(pFile); - - if(dwBytesRead != dwStringLength) - { - Trace("dwbyteread != string length\n"); - return FALSE; - } - - if (strcmp(szReadString, szString)) - { - Trace("read = %s string = %s", szReadString, szString); - return FALSE; - } - return TRUE; -} - - - - -BOOL writeTest(const char* szString) -{ - HANDLE hFile = NULL; - DWORD dwBytesWritten; - BOOL bRc = FALSE; - BOOL bAllPassed = TRUE; - int nStringLength = 0; - char* szPtr = NULL; - int i = 0; - - // create the test file - hFile = CreateFile(szWritableFile, - GENERIC_WRITE, - FILE_SHARE_WRITE, - NULL, - CREATE_ALWAYS, - FILE_ATTRIBUTE_NORMAL, - NULL); - - if(hFile == INVALID_HANDLE_VALUE) - { - Trace("WriteFile: ERROR -> Unable to create file \"%s\".\n", - szWritableFile); - return FALSE; - } - - nStringLength = strlen(szString); - szPtr = (char*) szString; - - for (i = 0; i < nStringLength; i++) - { - bRc = WriteFile(hFile, szPtr++, 1, &dwBytesWritten, NULL); - if ((bRc == FALSE) || (dwBytesWritten != 1)) - { - bAllPassed = FALSE; - } - } - CloseHandle(hFile); - - if (bAllPassed == FALSE) - { - Trace ("WriteFile: ERROR: Failed to write data.\n"); - return FALSE; - } - else - { - return (validateResults(szString)); - } - - return TRUE; -} - - - - -int __cdecl main(int argc, char *argv[]) -{ - const char *pString = szStringTest; - BOOL bRc = FALSE; - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - - bRc = writeTest(pString); - if (bRc != TRUE) - { - Fail("WriteFile: ERROR -> Failed\n"); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/file_io/WriteFile/test3/testinfo.dat b/src/pal/tests/palsuite/file_io/WriteFile/test3/testinfo.dat deleted file mode 100644 index e88e985b4..000000000 --- a/src/pal/tests/palsuite/file_io/WriteFile/test3/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = WriteFile -Name = Positive Test for WriteFile -Type = DEFAULT -EXE1 = writefile -Description -=Multiple consecutive writes to a file with verification - diff --git a/src/pal/tests/palsuite/file_io/WriteFile/test4/CMakeLists.txt b/src/pal/tests/palsuite/file_io/WriteFile/test4/CMakeLists.txt deleted file mode 100644 index b8e26ee57..000000000 --- a/src/pal/tests/palsuite/file_io/WriteFile/test4/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - writefile.cpp -) - -add_executable(paltest_writefile_test4 - ${SOURCES} -) - -add_dependencies(paltest_writefile_test4 coreclrpal) - -target_link_libraries(paltest_writefile_test4 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/WriteFile/test4/testinfo.dat b/src/pal/tests/palsuite/file_io/WriteFile/test4/testinfo.dat deleted file mode 100644 index 87ddf9d85..000000000 --- a/src/pal/tests/palsuite/file_io/WriteFile/test4/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = WriteFile -Name = Positive Test for WriteFile -Type = DEFAULT -EXE1 = writefile -Description -= writes to a file at different locations with verification - diff --git a/src/pal/tests/palsuite/file_io/WriteFile/test4/writefile.cpp b/src/pal/tests/palsuite/file_io/WriteFile/test4/writefile.cpp deleted file mode 100644 index 47a0066ec..000000000 --- a/src/pal/tests/palsuite/file_io/WriteFile/test4/writefile.cpp +++ /dev/null @@ -1,155 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: WriteFile.c (test 4) -** -** Purpose: Tests the PAL implementation of the WriteFile function. -** Performs multiple writes to a file at different locations -** then verifies the results with GetFileSize. -** -** dependency: -** CreateFile. -** GetFileSize. -** FlushFileBuffers -** SetFilePointer. -** CloseHandle. -** DeleteFile. -** -** -** -**===================================================================*/ - - -#include - -BOOL CleanUp(HANDLE hFile, const char * fileName) -{ - BOOL bRc = TRUE; - if (CloseHandle(hFile) != TRUE) - { - bRc = FALSE; - Trace("WriteFile: ERROR -> Unable to close file \"%s\"," - " error: %ld.\n", fileName, GetLastError()); - } - if (!DeleteFileA(fileName)) - { - bRc = FALSE; - Trace("WriteFile: ERROR -> Unable to delete file \"%s\"," - " error: %ld.\n", fileName, GetLastError()); - } - return bRc; -} - -int __cdecl main(int argc, char *argv[]) -{ - const char* szStringTest = "1234567890"; - const char* szWritableFile = "writeable.txt"; - HANDLE hFile = NULL; - DWORD dwBytesWritten; - - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - /* create the test file */ - hFile = CreateFile(szWritableFile, - GENERIC_WRITE, - FILE_SHARE_WRITE, - NULL, - CREATE_ALWAYS, - FILE_ATTRIBUTE_NORMAL, - NULL); - - if(hFile == INVALID_HANDLE_VALUE) - { - Fail("WriteFile: ERROR -> Unable to create file \"%s\".\n", - szWritableFile); - } - - - /* test wtriting to the file */ - if( WriteFile(hFile, /* HANDLE handle to file */ - szStringTest, /* data buffer */ - strlen(szStringTest), /* number of bytes to write */ - &dwBytesWritten, /* number of bytes written */ - NULL) /* overlapped buffer */ - ==0) - { - Trace("WriteFile: ERROR -> Unable to write to file error: %ld \n", - GetLastError()); - CleanUp(hFile,szWritableFile); - Fail(""); - } - - if(!FlushFileBuffers(hFile)) - { Trace("WriteFile: ERROR -> Call to FlushFile Buffers failed " - "error %ld \n",GetLastError()); - CleanUp(hFile,szWritableFile); - Fail(""); - } - - /* check the file size */ - if(GetFileSize(hFile, NULL)!=strlen(szStringTest)) - { - Trace("WriteFile: ERROR -> writing %u chars to empty file " - "caused its size to become %u\n",strlen(szStringTest), - GetFileSize(hFile, NULL)); - CleanUp(hFile,szWritableFile); - Fail(""); - } - - /* test writing to the file at position 5. */ - SetFilePointer( - hFile, /* handle to file */ - 0x5, /* bytes to move pointer */ - NULL, /* bytes to move pointer */ - FILE_BEGIN /* starting point */ - ); - - - if( WriteFile(hFile, /* HANDLE handle to file */ - szStringTest, /* data buffer */ - strlen(szStringTest), /* number of bytes to write */ - &dwBytesWritten, /* number of bytes written */ - NULL) /* overlapped buffer */ - ==0) - { - Trace("WriteFile: ERROR -> Unable to write to file after " - " moiving the file poiner to 5 error: %ld \n", - GetLastError()); - CleanUp(hFile,szWritableFile); - Fail(""); - } - - - if(!FlushFileBuffers(hFile)) - { - Trace("WriteFile: ERROR -> Call to FlushFile Buffers failed " - "error %ld \n",GetLastError()); - CleanUp(hFile,szWritableFile); - Fail(""); - } - - /* Check the file size */ - if(GetFileSize(hFile, NULL)!=(strlen(szStringTest)+5)) - { - Trace("WriteFile: ERROR -> writing %u chars to the file after " - "sitting the file pointer to 5 resulted in wrong file size; " - "Expected %u resulted %u.",strlen(szStringTest), - (strlen(szStringTest)+5),GetFileSize(hFile, NULL)); - CleanUp(hFile,szWritableFile); - Fail(""); - } - - if (!CleanUp(hFile,szWritableFile)) - { - Fail(""); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/file_io/WriteFile/test5/CMakeLists.txt b/src/pal/tests/palsuite/file_io/WriteFile/test5/CMakeLists.txt deleted file mode 100644 index 69d7034b8..000000000 --- a/src/pal/tests/palsuite/file_io/WriteFile/test5/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - writefile.cpp -) - -add_executable(paltest_writefile_test5 - ${SOURCES} -) - -add_dependencies(paltest_writefile_test5 coreclrpal) - -target_link_libraries(paltest_writefile_test5 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/WriteFile/test5/testinfo.dat b/src/pal/tests/palsuite/file_io/WriteFile/test5/testinfo.dat deleted file mode 100644 index ffde30ea2..000000000 --- a/src/pal/tests/palsuite/file_io/WriteFile/test5/testinfo.dat +++ /dev/null @@ -1,15 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = WriteFile -Name = Positive Test for WriteFile -Type = DEFAULT -EXE1 = writefile -Description -= write lots of data to a file. then check with -= GetFileSize -= This test is disabled due to its time overhead. - diff --git a/src/pal/tests/palsuite/file_io/WriteFile/test5/writefile.cpp b/src/pal/tests/palsuite/file_io/WriteFile/test5/writefile.cpp deleted file mode 100644 index 46920b333..000000000 --- a/src/pal/tests/palsuite/file_io/WriteFile/test5/writefile.cpp +++ /dev/null @@ -1,117 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: WriteFile.c (test 5) -** -** Purpose: Tests the PAL implementation of the WriteFile function. -** Performs writing a huge file. -** -** dependency: -** CreateFile. -** GetFileSize. -** FlushFileBuffers -** CloseHandle -** DeleteFile -** -** -**===================================================================*/ - - -#include - -BOOL CleanUp(HANDLE hFile, const char * fileName) -{ - BOOL bRc = TRUE; - if (CloseHandle(hFile) != TRUE) - { - bRc = FALSE; - Trace("WriteFile: ERROR -> Unable to close file \"%s\"," - " error: %ld.\n", fileName, GetLastError()); - } - if (!DeleteFileA(fileName)) - { - bRc = FALSE; - Trace("WriteFile: ERROR -> Unable to delete file \"%s\"," - " error: %ld.\n", fileName, GetLastError()); - } - return bRc; -} - - -int __cdecl main(int argc, char *argv[]) -{ - - HANDLE hFile = NULL; - DWORD dwBytesWritten; - const char* hugeStringTest = - "1234567890123456789012345678901234567890"; - const char* szWritableFile = "writeable.txt"; - int i =0; - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - /* create the test file */ - hFile = CreateFile(szWritableFile, - GENERIC_WRITE, - FILE_SHARE_WRITE, - NULL, - CREATE_ALWAYS, - FILE_ATTRIBUTE_NORMAL, - NULL); - - if(hFile == INVALID_HANDLE_VALUE) - { - Fail("WriteFile: ERROR -> Unable to create file \"%s\".\n", - szWritableFile); - } - - /* write 4000 000 chars to the file.*/ - for (i=0; i<100000;i++) - { - if( WriteFile(hFile, /* HANDLE handle to file */ - hugeStringTest, /* data buffer */ - strlen(hugeStringTest), /* number of bytes to write */ - &dwBytesWritten, /* number of bytes written */ - NULL) /* overlapped buffer */ - ==0) - { - Trace("WriteFile: ERROR -> Unable to write to file error: %ld \n", - GetLastError()); - CleanUp(hFile,szWritableFile); - Fail(""); - - } - } - - if(!FlushFileBuffers(hFile)) - { - Trace("WriteFile: ERROR -> Call to FlushFileBuffers failed" - "error %ld \n",GetLastError()); - CleanUp(hFile,szWritableFile); - Fail(""); - } - - /* test if the size changed properly. */ - if(GetFileSize(hFile,NULL) != 4000000) - { - Trace("WriteFile: ERROR -> file size did not change properly" - " after writing 4000 000 chars to it ( size= %u )\n", - GetFileSize(hFile,NULL)); - CleanUp(hFile,szWritableFile); - Fail(""); - - } - - if (!CleanUp(hFile,szWritableFile)) - { - Fail(""); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/file_io/errorpathnotfound/CMakeLists.txt b/src/pal/tests/palsuite/file_io/errorpathnotfound/CMakeLists.txt deleted file mode 100644 index 1962ade35..000000000 --- a/src/pal/tests/palsuite/file_io/errorpathnotfound/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) -add_subdirectory(test3) - diff --git a/src/pal/tests/palsuite/file_io/errorpathnotfound/test1/CMakeLists.txt b/src/pal/tests/palsuite/file_io/errorpathnotfound/test1/CMakeLists.txt deleted file mode 100644 index 14bed3463..000000000 --- a/src/pal/tests/palsuite/file_io/errorpathnotfound/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_errorpathnotfound_test1 - ${SOURCES} -) - -add_dependencies(paltest_errorpathnotfound_test1 coreclrpal) - -target_link_libraries(paltest_errorpathnotfound_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/errorpathnotfound/test1/test1.cpp b/src/pal/tests/palsuite/file_io/errorpathnotfound/test1/test1.cpp deleted file mode 100644 index eaf3db3a3..000000000 --- a/src/pal/tests/palsuite/file_io/errorpathnotfound/test1/test1.cpp +++ /dev/null @@ -1,783 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== - -** - -** Source: test1.c - -** - -** Purpose: Test the return value of GetLastError() after calling - -** some file_io functions with an invalid path. - -** - -** Functions covered by this test are: - -** CopyFileA, CopyFileW, CreateFileA,CreateFileW, - -** DeleteFileA and DeleteFileW. - -** -** - - - -** - -**===================================================================*/ - - - -#include - - - -int __cdecl main(int argc, char *argv[]) - -{ - - - - BOOL testPass = TRUE; - - BOOL bRc = TRUE; - - HANDLE hFile; - - - - const char* sBadFilePath = "bad/badPath.tmp"; - - const char* sBadFileName = "badName.tmp"; - - const char* sDest = "dest.tmp"; - - const WCHAR wBadFilePath[] = - - {'w','b','a','d','/','b','a', - - 'd','.','t','m','p','\0'}; - - const WCHAR wBadFileName[] = - - {'w','B','a','d','.','t','m','p','\0'}; - - const WCHAR wDest[] = - - {'w','d','e','s','t','.','t','m','p','\0'}; - - - - - - if (0 != PAL_Initialize(argc,argv)) - - { - - return FAIL; - - } - - - - /*...................Test CopyFileW.............................*/ - - - - /* test with an invalid path */ - - bRc = CopyFileW(wBadFilePath,wDest,TRUE); - - if(!bRc) - - { - - if(GetLastError()!= ERROR_PATH_NOT_FOUND) - - { - - Trace("CopyFileW: calling GetLastError() after copying a file" - - " with wrong path returned [%u] while it should return [%u]\n" - - ,GetLastError(), ERROR_PATH_NOT_FOUND); - - testPass = FALSE; - - } - - } - - else - - { - - testPass = FALSE; - - } - - - - /* test with invalid file name */ - - bRc = CopyFileW(wBadFileName,wDest,TRUE); - - if(!bRc) - - { - - if(GetLastError()!= ERROR_FILE_NOT_FOUND) - - { - - Trace("CopyFileW: calling GetLastError() after copying a file" - - " with wrong name returned [%u] while it should return [%u]\n" - - ,GetLastError(), ERROR_FILE_NOT_FOUND); - - testPass = FALSE; - - } - - - - } - - else - - { - - Trace("CopyFileW: managed to copy a file with wrong name\n"); - - testPass = FALSE; - - } - - - - - - - - /*..................CopyFileA...................................*/ - - - - /* test with an invalid path */ - - bRc = CopyFileA(sBadFilePath,sDest,TRUE); - - if(! bRc) - - { - - if(GetLastError()!= ERROR_PATH_NOT_FOUND) - - { - - Trace("CopyFileA: calling GetLastError() after copying a file" - - " with wrong path returned [%u] while it should return [%u]\n" - - ,GetLastError(), ERROR_PATH_NOT_FOUND); - - testPass = FALSE; - - } - - } - - else - - { - - Trace("CopyFileA: managed to copy a file with wrong path\n"); - - testPass = FALSE; - - } - - - - /* test with an invalid file name */ - - bRc = CopyFileA(sBadFileName,sDest,TRUE); - - if(! bRc) - - { - - if(GetLastError()!= ERROR_FILE_NOT_FOUND) - - { - - Trace("CopyFileA: calling GetLastError() after copying a file" - - " with wrong name returned [%u] while it should return [%u]\n" - - ,GetLastError(), ERROR_FILE_NOT_FOUND); - - testPass = FALSE; - - } - - } - - else - - { - - Trace("CopyFileA: managed to copy a file with wrong name\n"); - - testPass = FALSE; - - } - - - - - - - - /*............. Test CreateFileA..................................*/ - - - - /* test with an invalid file name */ - - hFile = CreateFileA(sBadFileName, - - GENERIC_READ, /* open for reading */ - - FILE_SHARE_READ, /* share for reading */ - - NULL, /* no security */ - - OPEN_EXISTING, /* existing file only */ - - FILE_ATTRIBUTE_NORMAL, /* normal file */ - - NULL); /* no attr. template */ - - - - if (hFile == INVALID_HANDLE_VALUE) - - { - - if(GetLastError() != ERROR_FILE_NOT_FOUND) - - { - - Trace("CreateFileA: calling GetLastError() returned [%u] " - - "while it should return [%u] for a bad File Name\n", - - GetLastError(),ERROR_FILE_NOT_FOUND); - - testPass = FALSE; - - } - - - - } - - else - - { - - Trace("CreateFileA: managed to create a file with an incorrect " - - "filename\n"); - - testPass = FALSE; - - - - if(!CloseHandle(hFile)) - - { - - Trace("CreateFileA: Call to CloseHandle failed with ErrorCode " - - "[%u]\n", GetLastError()); - - - - } - - if(!DeleteFile(sBadFileName)) - - { - - Trace("CreateFileA: Call to DeleteFile failed with ErrorCode " - - "[%u]\n", GetLastError()); - - } - - } - - - - /* test with an invalid path */ - - hFile = CreateFileA(sBadFilePath, - - GENERIC_READ, /* open for reading */ - - FILE_SHARE_READ, /* share for reading */ - - NULL, /* no security */ - - OPEN_EXISTING, /* existing file only */ - - FILE_ATTRIBUTE_NORMAL, /* normal file */ - - NULL); /* no attr. template */ - - - - if (hFile == INVALID_HANDLE_VALUE) - - { - - if(GetLastError() != ERROR_PATH_NOT_FOUND) - - { - - Trace("CreateFileA: calling GetLastError() returned [%u] " - - "while it should return [%u] for a bad file path name\n", - - GetLastError(), ERROR_PATH_NOT_FOUND); - - testPass = FALSE; - - } - - - - } - - else - - { - - Trace("CreateFileA: managed to create a file with an incorrect " - - "filename\n"); - - testPass = FALSE; - - /*this should not happen*/ - - if(!CloseHandle(hFile)) - - { - - Trace("CreateFileA: Call to CloseHandle Failed with ErrorCode " - - "[%u]\n", GetLastError()); - - - - } - - if(!DeleteFile(sBadFilePath)) - - { - - Trace("CreateFileA: Call to DeleteFile Failed with ErrorCode " - - "[%u]\n", GetLastError()); - - } - - } - - - - - - - - - - /*............. Test CreateFileW..................................*/ - - - - /* test with an invalid file name */ - - hFile = CreateFileW(wBadFileName, - - GENERIC_READ, /* open for reading */ - - FILE_SHARE_READ, /* share for reading */ - - NULL, /* no security */ - - OPEN_EXISTING, /* existing file only */ - - FILE_ATTRIBUTE_NORMAL, /* normal file */ - - NULL); /* no attr. template */ - - - - if (hFile == INVALID_HANDLE_VALUE) - - { - - if(GetLastError() != ERROR_FILE_NOT_FOUND) - - { - - Trace("CreateFileW: calling GetLastError() returned [%u] " - - "while it should return [%u] for a bad filename\n", - - GetLastError(), ERROR_FILE_NOT_FOUND); - - testPass = FALSE; - - } - - - - } - - else - - { - - Trace("CreateFileW: managed to create a file with an incorrect " - - "filename\n"); - - testPass = FALSE; - - - - if(!CloseHandle(hFile)) - - { - - Trace("CreateFileW: Call to CloseHandle Failed with ErrorCode " - - "[%u]\n", GetLastError()); - - - - } - - - - if(!DeleteFileW(wBadFileName)) - - { - - Trace("CreateFileW: Call to DeleteFile Failed with ErrorCode " - - "[%u]\n", GetLastError()); - - } - - } - - - - - - - - /* test with an invalid path */ - - hFile = CreateFileW(wBadFilePath, - - GENERIC_READ, /* open for reading */ - - FILE_SHARE_READ, /* share for reading */ - - NULL, /* no security */ - - OPEN_EXISTING, /* existing file only */ - - FILE_ATTRIBUTE_NORMAL, /* normal file */ - - NULL); /* no attr. template */ - - - - if (hFile == INVALID_HANDLE_VALUE) - - { - - - - if(GetLastError() != ERROR_PATH_NOT_FOUND) - - { - - Trace("CreateFileW: calling GetLastError() returned [%u] " - - "while it should return [%u] for a bad file path \n", - - GetLastError(), ERROR_FILE_NOT_FOUND); - - testPass = FALSE; - - } - - - - } - - else - - { - - Trace("CreateFileW: managed to create a file with an incorrect " - - "filename\n"); - - testPass = FALSE; - - - - if(!CloseHandle(hFile)) - - { - - Trace("CreateFileW: Call to CloseHandle Failed with ErrorCode " - - "[%u]\n", GetLastError()); - - - - } - - if(!DeleteFileW(wBadFilePath)) - - { - - Trace("CreateFileW: Call to DeleteFile Failed with ErrorCode " - - "[%u]\n", GetLastError()); - - } - - } - - - - - - - - /* ............. DeleteFileW..................................*/ - - - - /* test with an invalid path */ - - if(DeleteFileW(wBadFilePath)) - - { - - Trace("DeleteFileW: Call to DeleteFileW to delete a file" - - " that does not exist succeeded\n"); - - testPass = FALSE; - - - - } - - else - - { - - if(GetLastError() != ERROR_PATH_NOT_FOUND) - - { - - Trace("DeleteFileW: Call GetLastError()returned " - - "[%u] while it should return ERROR_PATH_NOT_FOUND [%u]\n", - - GetLastError(),ERROR_FILE_NOT_FOUND); - - testPass = FALSE; - - - - } - - - - } - - - - /* test with an invalid file name */ - - if(DeleteFileW(wBadFileName)) - - { - - Trace("DeleteFileW: Call to DeleteFileW to delete a file" - - " that does not exist succeeded\n"); - - testPass = FALSE; - - - - } - - else - - { - - if(GetLastError() != ERROR_FILE_NOT_FOUND) - - { - - Trace("DeleteFileW: Call GetLastError()returned [%u]" - - " while it should return ERROR_FILE_NOT_FOUND [%u]\n", - - GetLastError(),ERROR_FILE_NOT_FOUND); - - testPass = FALSE; - - - - } - - - - } - - - - - - /* ............. DeleteFileA..................................*/ - - - - /* test with an invalid path */ - - if(DeleteFileA(sBadFilePath)) - - { - - Trace("DeleteFileA: Call to DeleteFileA to delete a file" - - " that does not exist succeeded\n"); - - testPass = FALSE; - - - - } - - else - - { - - if(GetLastError() != ERROR_PATH_NOT_FOUND) - - { - - Trace("DeleteFileA: Call GetLastError() returned [%u]" - - " while it should return ERROR_PATH_NOT_FOUND [%u]\n", - - GetLastError(),ERROR_FILE_NOT_FOUND); - - testPass = FALSE; - - - - } - - - - } - - - - /* test with an invalid file name */ - - if(DeleteFileA(sBadFileName)) - - { - - Trace("DeleteFileA: Call to DeleteFileA to delete a file" - - " that does not exist succeeded\n"); - - testPass = FALSE; - - - - } - - else - - { - - if(GetLastError() != ERROR_FILE_NOT_FOUND) - - { - - Trace("DeleteFileA: Call GetLastError() returned [%u]" - - " while it should return ERROR_FILE_NOT_FOUND [%u]\n", - - GetLastError(),ERROR_FILE_NOT_FOUND); - - testPass = FALSE; - - - - } - - - - } - - - - - - - - if(! testPass) - - { - - Fail(""); - - } - - PAL_Terminate(); - - return PASS; - -} - - - diff --git a/src/pal/tests/palsuite/file_io/errorpathnotfound/test1/testinfo.dat b/src/pal/tests/palsuite/file_io/errorpathnotfound/test1/testinfo.dat deleted file mode 100644 index dc1ddc96f..000000000 --- a/src/pal/tests/palsuite/file_io/errorpathnotfound/test1/testinfo.dat +++ /dev/null @@ -1,31 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. - -# The .NET Foundation licenses this file to you under the MIT license. - -# See the LICENSE file in the project root for more information. - - - - -Version = 1.0 - -Section = file_io - -Function = some File_io functions - -Name = errorpathnotfound - checking GetLastError. - -Type = DEFAULT - -EXE1 = test1 - -Description - -= Test the return value of GetLastError() after calling - -= some file_io functions with an invalid path. - -= Functions covered by this test are: - -= CopyFile, CreateFile and DeleteFile. - diff --git a/src/pal/tests/palsuite/file_io/errorpathnotfound/test2/CMakeLists.txt b/src/pal/tests/palsuite/file_io/errorpathnotfound/test2/CMakeLists.txt deleted file mode 100644 index abbf494f0..000000000 --- a/src/pal/tests/palsuite/file_io/errorpathnotfound/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test2.cpp -) - -add_executable(paltest_errorpathnotfound_test2 - ${SOURCES} -) - -add_dependencies(paltest_errorpathnotfound_test2 coreclrpal) - -target_link_libraries(paltest_errorpathnotfound_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/errorpathnotfound/test2/test2.cpp b/src/pal/tests/palsuite/file_io/errorpathnotfound/test2/test2.cpp deleted file mode 100644 index b9177ece4..000000000 --- a/src/pal/tests/palsuite/file_io/errorpathnotfound/test2/test2.cpp +++ /dev/null @@ -1,711 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== - -** - -** Source: test2.c - -** - -** Purpose: Test the return value of GetLastError() after calling - -** some file_io functions with an invalid path. - -** - -** Functions covered by this test are: - -** FindFirstFileA, FindFirstFileW, - -** GetFileAttributesA, GetFileAttributesW, - -** SetFileAttributesA, SetFileAttributesW. - -** -** - -** - - - -** - -**===================================================================*/ - - - -#include - - - -int __cdecl main(int argc, char *argv[]) - -{ - - - - BOOL testPass = TRUE; - - BOOL bRc = TRUE; - - HANDLE hFile; - - WIN32_FIND_DATA findFileData; - - WIN32_FIND_DATAW wFindFileData; - - DWORD fileAttrib; - - - - const char* sBadFilePath = "bad/badPath.tmp"; - - const char* sBadFileName = "badName.tmp"; - - - - const WCHAR wBadFilePath[] = - - {'w','b','a','d','/','b','a', - - 'd','.','t','m','p','\0'}; - - const WCHAR wBadFileName[] = - - {'w','B','a','d','.','t','m','p','\0'}; - - const WCHAR wDest[] = - - {'w','d','e','s','t','.','t','m','p','\0'}; - - - - - - if (0 != PAL_Initialize(argc,argv)) - - { - - return FAIL; - - } - - - - /*............. Test FindFirstFileA..................................*/ - - - - /* test with an invalid file name */ - - hFile = FindFirstFileA(sBadFileName,&findFileData ); - - - - if (hFile == INVALID_HANDLE_VALUE) - - { - - if(GetLastError() != ERROR_FILE_NOT_FOUND) - - { - - Trace("FindFirstFileA: calling GetLastError() returned [%u] " - - "while it should return [%u] for a bad File Name\n", - - GetLastError(),ERROR_FILE_NOT_FOUND); - - testPass = FALSE; - - } - - - - } - - else - - { - - Trace("FindFirstFileA: managed to find a file with an incorrect " - - "filename\n"); - - testPass = FALSE; - - - - if(!FindClose(hFile)) - - { - - Trace("FindFirstFileA: Call to FindClose failed with ErrorCode" - - " [%u]\n", GetLastError()); - - - - } - - - - } - - - - /* test with an invalid path */ - - hFile = FindFirstFileA(sBadFilePath,&findFileData); - - - - if (hFile == INVALID_HANDLE_VALUE) - - { - - if(GetLastError() != ERROR_PATH_NOT_FOUND) - - { - - Trace("FindFirstFileA: calling GetLastError() returned [%u] " - - "while it should return [%u] for a bad file path name\n", - - GetLastError(), ERROR_PATH_NOT_FOUND); - - testPass = FALSE; - - } - - - - } - - else - - { - - Trace("FindFirstFileA: managed to find a file with an incorrect" - - " filename\n"); - - testPass = FALSE; - - /*this should not happen*/ - - if(!FindClose(hFile)) - - { - - Trace("FindFirstFileA: Call to FindClose Failed with ErrorCode" - - " [%u]\n", GetLastError()); - - - - } - - - - } - - - - - - - - /*............. Test FindFirstFileW..................................*/ - - - - /* test with an invalid file name */ - - hFile = FindFirstFileW(wBadFileName,&wFindFileData ); - - - - if (hFile == INVALID_HANDLE_VALUE) - - { - - if(GetLastError() != ERROR_FILE_NOT_FOUND) - - { - - Trace("FindFirstFileW: calling GetLastError() returned [%u] " - - "while it should return [%u] for a bad File Name\n", - - GetLastError(),ERROR_FILE_NOT_FOUND); - - testPass = FALSE; - - } - - - - } - - else - - { - - Trace("FindFirstFileW: managed to find a file with an incorrect " - - "filename\n"); - - testPass = FALSE; - - - - if(!FindClose(hFile)) - - { - - Trace("FindFirstFileW: Call to FindClose failed with ErrorCode" - - " [%u]\n", GetLastError()); - - - - } - - - - } - - - - /* test with an invalid path */ - - hFile = FindFirstFileW(wBadFilePath,&wFindFileData); - - - - if (hFile == INVALID_HANDLE_VALUE) - - { - - if(GetLastError() != ERROR_PATH_NOT_FOUND) - - { - - Trace("FindFirstFileW: calling GetLastError() returned [%u] " - - "while it should return [%u] for a bad file path name\n", - - GetLastError(), ERROR_PATH_NOT_FOUND); - - testPass = FALSE; - - } - - - - } - - else - - { - - Trace("FindFirstFileW: managed to find a file with an incorrect " - - "filename\n"); - - testPass = FALSE; - - /*this should not happen*/ - - if(!FindClose(hFile)) - - { - - Trace("FindFirstFileW: Call to FindClose Failed with ErrorCode " - - "[%u]\n", GetLastError()); - - - - } - - - - } - - - - - - /*...................Test GetFileAttributesW.............................*/ - - - - /* test with an invalid path */ - - fileAttrib = GetFileAttributesW(wBadFilePath); - - if(fileAttrib == -1) - - { - - if(GetLastError()!= ERROR_PATH_NOT_FOUND) - - { - - Trace("GetFileAttributesW: calling GetLastError() after getting" - - " the attributes of a file with wrong path returned [%u]" - - " while it should return [%u]\n", - - GetLastError(), ERROR_PATH_NOT_FOUND); - - testPass = FALSE; - - } - - } - - else - - { - - Trace("GetFileAttributesW: managed to get the attrib of a file" - - " with wrong path\n"); - - testPass = FALSE; - - } - - - - /* test with invalid file name */ - - fileAttrib = GetFileAttributesW(wBadFileName); - - if(fileAttrib == -1) - - { - - if(GetLastError()!= ERROR_FILE_NOT_FOUND) - - { - - Trace("GetFileAttributesW: calling GetLastError() after getting" - - " the attributes of a file with wrong name returned [%u] " - - "while it should return [%u]\n" - - ,GetLastError(), ERROR_FILE_NOT_FOUND); - - testPass = FALSE; - - } - - } - - else - - { - - Trace("GetFileAttributesW: managed to get the attrib of a file" - - " with wrong name\n"); - - testPass = FALSE; - - } - - - - /*...................Test GetFileAttributesA.............................*/ - - - - /* test with an invalid path */ - - fileAttrib = GetFileAttributesA(sBadFilePath); - - if(fileAttrib == -1) - - { - - if(GetLastError()!= ERROR_PATH_NOT_FOUND) - - { - - Trace("GetFileAttributesA: calling GetLastError() after getting" - - " the attributes of a file with wrong path returned [%u] while" - - " it should return [%u]\n", - - GetLastError(), ERROR_PATH_NOT_FOUND); - - testPass = FALSE; - - } - - } - - else - - { - - Trace("GetFileAttributesA: managed to get the attrib of a file" - - " with wrong path\n"); - - testPass = FALSE; - - } - - - - /* test with invalid file name */ - - fileAttrib = GetFileAttributesA(sBadFileName); - - if(fileAttrib == -1) - - { - - if(GetLastError()!= ERROR_FILE_NOT_FOUND) - - { - - Trace("GetFileAttributesA: calling GetLastError() after getting " - - "the attributes of a file with wrong name returned [%u] " - - "while it should return [%u]\n" - - ,GetLastError(), ERROR_FILE_NOT_FOUND); - - testPass = FALSE; - - } - - - - } - - else - - { - - Trace("GetFileAttributesA: managed to get the attrib of a file with" - - " wrong name\n"); - - testPass = FALSE; - - } - - - - - - - - - - /*...................Test SetFileAttributesW.............................*/ - - - - /* test with an invalid path */ - - bRc = SetFileAttributesW(wBadFilePath,FILE_ATTRIBUTE_NORMAL); - - if(!bRc) - - { - - if(GetLastError()!= ERROR_PATH_NOT_FOUND) - - { - - Trace("SetFileAttributesW: calling GetLastError() after setting" - - " the attributes of a file with wrong path returned [%u] " - - "while it should return [%u]\n", - - GetLastError(), ERROR_PATH_NOT_FOUND); - - testPass = FALSE; - - } - - } - - else - - { - - Trace("SetFileAttributesW: managed to get the attrib of a file" - - " with wrong path\n"); - - testPass = FALSE; - - } - - - - /* test with invalid file name */ - - bRc = SetFileAttributesW(wBadFileName,FILE_ATTRIBUTE_NORMAL); - - if(!bRc) - - { - - if(GetLastError()!= ERROR_FILE_NOT_FOUND) - - { - - Trace("SetFileAttributesW: calling GetLastError() after setting" - - " the attributes of a file with wrong name returned [%u]" - - " while it should return [%u]\n", - - GetLastError(), ERROR_FILE_NOT_FOUND); - - testPass = FALSE; - - } - - - - } - - else - - { - - Trace("SetFileAttributesW: managed to get the attrib of a file with" - - " wrong name\n"); - - testPass = FALSE; - - } - - - - - - /*...................Test SetFileAttributesA.............................*/ - - - - /* test with an invalid path */ - - bRc = SetFileAttributesA(sBadFilePath,FILE_ATTRIBUTE_NORMAL); - - if(!bRc) - - { - - if(GetLastError()!= ERROR_PATH_NOT_FOUND) - - { - - Trace("SetFileAttributesA: calling GetLastError() after setting " - - "the attributes of a file with wrong path returned [%u] " - - "while it should return [%u]\n" - - ,GetLastError(), ERROR_PATH_NOT_FOUND); - - testPass = FALSE; - - } - - } - - else - - { - - Trace("SetFileAttributesA: managed to get the attrib of a file " - - "with wrong path\n"); - - testPass = FALSE; - - } - - - - /* test with invalid file name */ - - bRc = SetFileAttributesA(sBadFileName,FILE_ATTRIBUTE_NORMAL); - - if(!bRc) - - { - - if(GetLastError()!= ERROR_FILE_NOT_FOUND) - - { - - Trace("SetFileAttributesA: calling GetLastError() after setting" - - " the attributes of a file with wrong name returned [%u]" - - " while it should return [%u]\n", - - GetLastError(), ERROR_FILE_NOT_FOUND); - - testPass = FALSE; - - } - - - - } - - else - - { - - Trace("SetFileAttributesA: managed to get the attrib of a file with " - - "wrong name\n"); - - testPass = FALSE; - - } - - - - - - if(! testPass) - - { - - Fail(""); - - } - - PAL_Terminate(); - - return PASS; - -} - - - diff --git a/src/pal/tests/palsuite/file_io/errorpathnotfound/test2/testinfo.dat b/src/pal/tests/palsuite/file_io/errorpathnotfound/test2/testinfo.dat deleted file mode 100644 index ddc5081c1..000000000 --- a/src/pal/tests/palsuite/file_io/errorpathnotfound/test2/testinfo.dat +++ /dev/null @@ -1,34 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. - -# The .NET Foundation licenses this file to you under the MIT license. - -# See the LICENSE file in the project root for more information. - - - -Version = 1.0 - -Section = file_io - -Function = some File_io functions - -Name = errorpathnotfound - checking GetLastError. - -Type = DEFAULT - -EXE1 = test2 - -Description - -= Test the return value of GetLastError() after calling - -= some file_io functions with an invalid path. - -= Functions covered by this test are: - -= FindFirstFileA, FindFirstFileW, - -= GetFileAttributesA, GetFileAttributesW, - -= SetFileAttributesA, SetFileAttributesW. - diff --git a/src/pal/tests/palsuite/file_io/errorpathnotfound/test3/CMakeLists.txt b/src/pal/tests/palsuite/file_io/errorpathnotfound/test3/CMakeLists.txt deleted file mode 100644 index a0e7dd60e..000000000 --- a/src/pal/tests/palsuite/file_io/errorpathnotfound/test3/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test3.cpp -) - -add_executable(paltest_errorpathnotfound_test3 - ${SOURCES} -) - -add_dependencies(paltest_errorpathnotfound_test3 coreclrpal) - -target_link_libraries(paltest_errorpathnotfound_test3 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/errorpathnotfound/test3/test3.cpp b/src/pal/tests/palsuite/file_io/errorpathnotfound/test3/test3.cpp deleted file mode 100644 index 414cbab17..000000000 --- a/src/pal/tests/palsuite/file_io/errorpathnotfound/test3/test3.cpp +++ /dev/null @@ -1,244 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== - -** - -** Source: test3.c - -** - -** Purpose: Test the return value of GetLastError() after calling - -** some file_io functions with an invalid path. - -** - -** Functions covered by this test are: - -** CreateDirectoryA, CreateDirectoryW, RemoveDirectoryW, - -** -** - - - -** - -**===================================================================*/ - - - -#include - - - -int __cdecl main(int argc, char *argv[]) - -{ - - - - BOOL testPass = TRUE; - - BOOL bRc = TRUE; - - DWORD errCode; - - - - const char* sBadSubDirectory = "bad/badDir"; - - - - /* Needed for RemoveDirectoryW */ - - const WCHAR tempName[] = {'b','a','d','/', - - 'b','a','d','D','i','r'}; - - - - const WCHAR wBadSubDirectory[] = - - {'w','b','a','d','/','b','a', - - 'd','D','i','r','\0'}; - - - - if (0 != PAL_Initialize(argc,argv)) - - { - - return FAIL; - - } - - - - /* ---------------------CreateDirectoryA------------------------- */ - - - - - - /* Testing of CreateDirectoryA */ - - bRc = CreateDirectoryA(sBadSubDirectory,NULL); - - if(!bRc) - - { - - errCode = GetLastError(); - - if(errCode != ERROR_PATH_NOT_FOUND) - - { - - Trace("CreateDirectoryA: calling GetLastError() after creating a " - - "directory with invalid path returned [%u] while it should " - - "return [%u]\n",errCode, ERROR_PATH_NOT_FOUND); - - testPass = FALSE; - - } - - } - - else - - { - - Trace("CreateDirectoryA: Created a directory with an invalid path.\n"); - - bRc = RemoveDirectoryW(tempName); - - if(!bRc) - - { - - Trace("Failed to remove %s with error %u.\n", - - sBadSubDirectory,GetLastError()); - - } - - testPass = FALSE; - - } - - - - /* ---------------------CreateDirectoryW------------------------- */ - - - - /* Testing of CreateDirectoryW */ - - bRc = CreateDirectoryW(wBadSubDirectory,NULL); - - if(!bRc) - - { - - errCode = GetLastError(); - - if(errCode != ERROR_PATH_NOT_FOUND) - - { - - Trace("CreateDirectoryW: calling GetLastError() after creating a " - - "directory with invalid path returned [%u] while it should " - - "return [%u]\n",errCode, ERROR_PATH_NOT_FOUND); - - testPass = FALSE; - - } - - } - - else - - { - - Trace("CreateDirectoryW: Created a directory with an invalid path.\n"); - - bRc = RemoveDirectoryW(wBadSubDirectory); - - if(!bRc) - - { - - Trace("Failed to remove %S with error %u.\n", - - wBadSubDirectory,GetLastError()); - - } - - testPass = FALSE; - - } - - - - /* ---------------------RemoveDirectoryW------------------------ */ - - - - /* Testing of RemoveDirectoryW */ - - bRc = RemoveDirectoryW(wBadSubDirectory); - - if(!bRc) - - { - - errCode = GetLastError(); - - if(errCode != ERROR_PATH_NOT_FOUND) - - { - - Trace("RemoveDirectoryW: calling GetLastError() after removing a " - - "sub directory with invalid path returned [%u] while it should " - - "return [%u]\n",errCode, ERROR_PATH_NOT_FOUND); - - testPass = FALSE; - - } - - } - - else - - { - - Trace("RemoveDirectoryW: Removed a directory that did not exist.\n"); - - } - - int exitCode = testPass ? PASS : FAIL; - PAL_TerminateEx(exitCode); - return exitCode; - - - - - - - - - - -} - diff --git a/src/pal/tests/palsuite/file_io/errorpathnotfound/test3/testinfo.dat b/src/pal/tests/palsuite/file_io/errorpathnotfound/test3/testinfo.dat deleted file mode 100644 index 7a9019f17..000000000 --- a/src/pal/tests/palsuite/file_io/errorpathnotfound/test3/testinfo.dat +++ /dev/null @@ -1,30 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. - -# The .NET Foundation licenses this file to you under the MIT license. - -# See the LICENSE file in the project root for more information. - - - -Version = 1.0 - -Section = file_io - -Function = some File_io functions - -Name = errorpathnotfound - checking GetLastError. - -Type = DEFAULT - -EXE1 = test3 - -Description - -= Test the return value of GetLastError() after calling - -= some file_io functions with an invalid path. - -= Functions covered by this test are: - -= CreateDirectory, RemoveDirectory - diff --git a/src/pal/tests/palsuite/file_io/gettemppatha/CMakeLists.txt b/src/pal/tests/palsuite/file_io/gettemppatha/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/file_io/gettemppatha/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/file_io/gettemppatha/test1/CMakeLists.txt b/src/pal/tests/palsuite/file_io/gettemppatha/test1/CMakeLists.txt deleted file mode 100644 index 9465bf2a4..000000000 --- a/src/pal/tests/palsuite/file_io/gettemppatha/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - gettemppatha.cpp -) - -add_executable(paltest_gettemppatha_test1 - ${SOURCES} -) - -add_dependencies(paltest_gettemppatha_test1 coreclrpal) - -target_link_libraries(paltest_gettemppatha_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/file_io/gettemppatha/test1/gettemppatha.cpp b/src/pal/tests/palsuite/file_io/gettemppatha/test1/gettemppatha.cpp deleted file mode 100644 index b0da528af..000000000 --- a/src/pal/tests/palsuite/file_io/gettemppatha/test1/gettemppatha.cpp +++ /dev/null @@ -1,103 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: gettemppatha.c (test 1) -** -** Purpose: Tests the PAL implementation of the GetTempPathA function. -** -** -**===================================================================*/ - -#include - -static void SetTmpDir(CHAR path[]) -{ - DWORD result = SetEnvironmentVariableA("TMPDIR", path); - if (!result) - { - Fail("ERROR -> SetEnvironmentVariableA failed with result %d and error code %d.\n", - result, GetLastError()); - } -} - -static void SetAndCompare(CHAR tmpDirPath[], CHAR expected[]) -{ - DWORD dwBufferLength = _MAX_DIR; - CHAR path[dwBufferLength]; - - SetTmpDir(tmpDirPath); - - DWORD dwResultLen = GetTempPathA(dwBufferLength, path); - if (dwResultLen <= 0) - { - Fail("ERROR: GetTempPathA returned %d with error code %d.\n", dwResultLen, GetLastError()); - } - if (dwResultLen >= dwBufferLength) - { - Fail("ERROR: Buffer of length %d passed to GetTempPathA was too small to hold %d chars..\n", dwBufferLength, dwResultLen); - } - if (strcmp(expected, path) != 0) - { - Fail("ERROR: GetTempPathA expected to get '%s' but instead got '%s'.\n", expected, path); - } - if (expected[dwResultLen - 1] != '/') - { - Fail("ERROR: GetTempPathA returned '%s', which should have ended in '/'.\n", path); - } -} - -static void SetAndCheckLength(CHAR tmpDirPath[], int bufferLength, int expectedResultLength) -{ - CHAR path[bufferLength]; - - SetTmpDir(tmpDirPath); - DWORD dwResultLen = GetTempPathA(bufferLength, path); - - if (dwResultLen != expectedResultLength) - { - Fail("GetTempPathA(%d, %s) expected to return %d but returned %d.\n", - bufferLength, tmpDirPath?tmpDirPath:"NULL", expectedResultLength, dwResultLen); - } -} - -int __cdecl main(int argc, char *argv[]) -{ - if (0 != PAL_Initialize(argc,argv)) - { - return FAIL; - } - - SetAndCompare("/tmp", "/tmp/"); - SetAndCompare("/tmp/", "/tmp/"); - SetAndCompare("", "/tmp/"); - SetAndCompare(NULL, "/tmp/"); - SetAndCompare("/", "/"); - SetAndCompare("/var/tmp", "/var/tmp/"); - SetAndCompare("/var/tmp/", "/var/tmp/"); - SetAndCompare("~", "~/"); - SetAndCompare("~/", "~/"); - SetAndCompare(".tmp", ".tmp/"); - SetAndCompare("./tmp", "./tmp/"); - SetAndCompare("/home/someuser/sometempdir", "/home/someuser/sometempdir/"); - SetAndCompare(NULL, "/tmp/"); - - DWORD dwResultLen = GetTempPathA(0, NULL); - if (dwResultLen != 0 || GetLastError() != ERROR_INVALID_PARAMETER) - { - Fail("GetTempPath(NULL, ...) returned %d with error code %d but " - "should have failed with ERROR_INVALID_PARAMETER (%d).\n", - dwResultLen, GetLastError(), ERROR_INVALID_PARAMETER); - } - - SetAndCheckLength("abc/", 5, 4); - SetAndCheckLength("abcd", 5, 6); - SetAndCheckLength("abcde", 5, 7); - SetAndCheckLength("abcdef/", 5, 9); - SetAndCheckLength(NULL, 5, 6); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/file_io/gettemppatha/test1/testinfo.dat b/src/pal/tests/palsuite/file_io/gettemppatha/test1/testinfo.dat deleted file mode 100644 index 71f8bef65..000000000 --- a/src/pal/tests/palsuite/file_io/gettemppatha/test1/testinfo.dat +++ /dev/null @@ -1,15 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = file_io -Function = GetTempPathA -Name = Test for GetTempPathA (test 1) -Type = DEFAULT -EXE1 = gettemppatha -Description -= Calls GetTempPathA and verifies by passing the returned -= value to CreateDirectoryA. If the returned path exists, -= CreateDirectoryA will fail. - diff --git a/src/pal/tests/palsuite/filemapping_memmgt/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/CMakeLists.txt deleted file mode 100644 index 4f996bded..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/CMakeLists.txt +++ /dev/null @@ -1,26 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(CreateFileMappingA) -add_subdirectory(CreateFileMappingW) -add_subdirectory(FreeLibrary) -add_subdirectory(FreeLibraryAndExitThread) -add_subdirectory(GetModuleFileNameA) -add_subdirectory(GetModuleFileNameW) -add_subdirectory(GetProcAddress) -add_subdirectory(GetProcessHeap) -add_subdirectory(HeapAlloc) -add_subdirectory(HeapFree) -add_subdirectory(HeapReAlloc) -add_subdirectory(LocalAlloc) -add_subdirectory(LocalFree) -add_subdirectory(MapViewOfFile) -add_subdirectory(OpenFileMappingA) -add_subdirectory(OpenFileMappingW) -add_subdirectory(ProbeMemory) -add_subdirectory(RtlMoveMemory) -add_subdirectory(UnmapViewOfFile) -add_subdirectory(VirtualAlloc) -add_subdirectory(VirtualFree) -add_subdirectory(VirtualProtect) -add_subdirectory(VirtualQuery) - diff --git a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingA/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingA/CMakeLists.txt deleted file mode 100644 index 0223c4d9b..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingA/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test3) -add_subdirectory(test4) -add_subdirectory(test5) -add_subdirectory(test6) -add_subdirectory(test7) -add_subdirectory(test8) -add_subdirectory(test9) - diff --git a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingA/test1/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingA/test1/CMakeLists.txt deleted file mode 100644 index c098dad90..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingA/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - CreateFileMapping.cpp -) - -add_executable(paltest_createfilemappinga_test1 - ${SOURCES} -) - -add_dependencies(paltest_createfilemappinga_test1 coreclrpal) - -target_link_libraries(paltest_createfilemappinga_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingA/test1/CreateFileMapping.cpp b/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingA/test1/CreateFileMapping.cpp deleted file mode 100644 index 91640bfd0..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingA/test1/CreateFileMapping.cpp +++ /dev/null @@ -1,173 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: createfilemapping.c (test 1) -** -** Purpose: Positive test the CreateFileMapping API. -** Call CreateFileMapping with access PAGE_READONLY. -** -** -**============================================================*/ -#include - -const int MAPPINGSIZE = 2048; - -int __cdecl main(int argc, char *argv[]) -{ - - HANDLE hFile; - char buf[] = "this is a test string"; - char ch[2048]; - char lpFileName[] = "test.tmp"; - DWORD dwBytesWritten; - BOOL err; - int RetVal = PASS; - - HANDLE hFileMapping; - LPVOID lpMapViewAddress; - - /* Initialize the PAL environment. - */ - if(0 != PAL_Initialize(argc, argv)) - { - return FAIL; - } - - /* Create a file handle with CreateFile. - */ - hFile = CreateFile( lpFileName, - GENERIC_WRITE|GENERIC_READ, - FILE_SHARE_READ|FILE_SHARE_WRITE, - NULL, - CREATE_ALWAYS, - FILE_ATTRIBUTE_NORMAL, - NULL); - - if (hFile == INVALID_HANDLE_VALUE) - { - Fail("ERROR: %u :unable to create file \"%s\".\n", - GetLastError(), - lpFileName); - } - - /* Initialize the buffers. - */ - memset(ch, 0, MAPPINGSIZE); - - /* Write to the File handle. - */ - err = WriteFile(hFile, - buf, - strlen(buf), - &dwBytesWritten, - NULL); - - if (err == FALSE) - { - Trace("ERROR: %u :unable to write to file handle " - "hFile=0x%lx\n", - GetLastError(), - hFile); - RetVal = FAIL; - goto CleanUpOne; - } - - /* Flush to the hard-drive. - */ - FlushFileBuffers(hFile); - - /* Create a unnamed file-mapping object with file handle FileHandle - * and with PAGE_READWRITE protection. - */ - hFileMapping = CreateFileMapping( - hFile, - NULL, /*not inherited*/ - PAGE_READONLY, /*read and wite*/ - 0, /*high-order size*/ - 0, /*low-order size*/ - NULL); /*unnamed object*/ - - if(NULL == hFileMapping) - { - Trace("ERROR:%u: Failed to create File Mapping.\n", - GetLastError()); - RetVal = FAIL; - goto CleanUpOne; - } - - /* maps a view of a file into the address space of the calling process. - */ - lpMapViewAddress = MapViewOfFile( - hFileMapping, - FILE_MAP_READ, /* access code */ - 0, /*high order offset*/ - 0, /*low order offset*/ - 0); /* number of bytes for map */ - - if(NULL == lpMapViewAddress) - { - Trace("ERROR:%u: Failed to call MapViewOfFile " - "API to map a view of file!\n", - GetLastError()); - RetVal = FAIL; - goto CleanUpTwo; - } - - /* Copy the MapViewOfFile to buffer, so we can - * compare with value read from file directly. - */ - memcpy(ch, (LPCSTR)lpMapViewAddress, MAPPINGSIZE); - if (memcmp(ch, buf, strlen(buf))!= 0) - { - Trace("ERROR: MapViewOfFile not equal to file contents " - "retrieved \"%s\", expected \"%s\".\n", - ch, buf); - RetVal = FAIL; - goto CleanUpThree; - } - -CleanUpThree: - - /* Unmap the view of file. - */ - if ( UnmapViewOfFile(lpMapViewAddress) == FALSE ) - { - Trace("ERROR:%u: Failed to UnmapViewOfFile of \"%0x%lx\".\n", - GetLastError(), - lpMapViewAddress); - RetVal = FAIL; - } - -CleanUpTwo: - - /* Close Handle to opend file mapping. - */ - if ( CloseHandle(hFileMapping) == FALSE ) - { - Trace("ERROR:%u: Failed to CloseHandle \"0x%lx\".\n", - GetLastError(), - hFileMapping); - RetVal = FAIL; - } - -CleanUpOne: - - /* Close Handle to create file mapping. - */ - if ( CloseHandle(hFile) == FALSE ) - { - Trace("ERROR:%u: Failed to CloseHandle \"0x%lx\".\n", - GetLastError(), - hFile); - RetVal = FAIL; - } - - /* Terminate the PAL. - */ - PAL_TerminateEx(RetVal); - return RetVal; -} - diff --git a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingA/test1/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingA/test1/testinfo.dat deleted file mode 100644 index 36ff3238c..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingA/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Filemapping_memmgt -Function = CreateFileMapping -Name = CreateFileMappingA with PAGE_READONLY -TYPE = DEFAULT -EXE1 = createfilemapping -Description -=Test the CreateFileMapping to create a named file-mapping object -=and with PAGE_READONLY protection diff --git a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingA/test3/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingA/test3/CMakeLists.txt deleted file mode 100644 index 4e5724648..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingA/test3/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - CreateFileMapping.cpp -) - -add_executable(paltest_createfilemappinga_test3 - ${SOURCES} -) - -add_dependencies(paltest_createfilemappinga_test3 coreclrpal) - -target_link_libraries(paltest_createfilemappinga_test3 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingA/test3/CreateFileMapping.cpp b/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingA/test3/CreateFileMapping.cpp deleted file mode 100644 index 2a849d86b..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingA/test3/CreateFileMapping.cpp +++ /dev/null @@ -1,155 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: createfilemapping.c (test 3) -** -** Purpose: Positive test the CreateFileMapping API. -** Call CreateFileMapping with access PAGE_READWRITE. -** -** -**============================================================*/ -#include - -const int MAPPINGSIZE = 2048; - -int __cdecl main(int argc, char *argv[]) -{ - - HANDLE hFile; - char buf[] = "this is a test string"; - char ch[2048]; - char lpFileName[] = "test.tmp"; - HANDLE hFileMapping; - LPVOID lpMapViewAddress; - int RetVal = PASS; - - /* Initialize the PAL environment. - */ - if(0 != PAL_Initialize(argc, argv)) - { - return FAIL; - } - - /* Create a file handle with CreateFile. - */ - hFile = CreateFile( lpFileName, - GENERIC_WRITE|GENERIC_READ, - FILE_SHARE_READ|FILE_SHARE_WRITE, - NULL, - CREATE_ALWAYS, - FILE_ATTRIBUTE_NORMAL, - NULL); - - if (hFile == INVALID_HANDLE_VALUE) - { - Fail("ERROR: %u :unable to create file \"%s\".\n", - GetLastError(), - lpFileName); - } - - /* Initialize the buffers. - */ - memset(ch, 0, MAPPINGSIZE); - - /* Create a unnamed file-mapping object with file handle FileHandle - * and with PAGE_READWRITE protection. - */ - hFileMapping = CreateFileMapping( - hFile, - NULL, /*not inherited*/ - PAGE_READWRITE, /*read and wite*/ - 0, /*high-order size*/ - MAPPINGSIZE, /*low-order size*/ - NULL); /*unnamed object*/ - - if(NULL == hFileMapping) - { - Trace("ERROR:%u: Failed to create File Mapping.\n", - GetLastError()); - RetVal = FAIL; - goto CleanUpOne; - } - - /* maps a view of a file into the address space of the calling process. - */ - lpMapViewAddress = MapViewOfFile( - hFileMapping, - FILE_MAP_ALL_ACCESS, /* access code */ - 0, /*high order offset*/ - 0, /*low order offset*/ - MAPPINGSIZE); /* number of bytes for map */ - - if(NULL == lpMapViewAddress) - { - Trace("ERROR:%u: Failed to call MapViewOfFile " - "API to map a view of file!\n", - GetLastError()); - RetVal = FAIL; - goto CleanUpTwo; - } - - /* Write to the Map view. - */ - memcpy(lpMapViewAddress, buf, strlen(buf)); - - /* Read from the Map view. - */ - memcpy(ch, (LPCSTR)lpMapViewAddress, MAPPINGSIZE); - - /* Copy the MapViewOfFile to buffer, so we can - * compare with value read from file directly. - */ - if (memcmp(ch, buf, strlen(buf))!= 0) - { - Trace("ERROR: MapViewOfFile not equal to file contents " - "retrieved \"%s\", expected \"%s\".\n", - ch, buf); - RetVal = FAIL; - goto CleanUpThree; - } - -CleanUpThree: - - /* Unmap the view of file. - */ - if ( UnmapViewOfFile(lpMapViewAddress) == FALSE ) - { - Trace("ERROR:%u: Failed to UnmapViewOfFile of \"%0x%lx\".\n", - GetLastError(), - lpMapViewAddress); - RetVal = FAIL; - } - -CleanUpTwo: - - /* Close Handle to opend file mapping. - */ - if ( CloseHandle(hFileMapping) == FALSE ) - { - Trace("ERROR:%u: Failed to CloseHandle \"0x%lx\".\n", - GetLastError(), - hFileMapping); - RetVal = FAIL; - } - -CleanUpOne: - - /* Close Handle to create file mapping. - */ - if ( CloseHandle(hFile) == FALSE ) - { - Trace("ERROR:%u: Failed to CloseHandle \"0x%lx\".\n", - GetLastError(), - hFile); - RetVal = FAIL; - } - - /* Terminate the PAL. - */ - PAL_TerminateEx(RetVal); - return RetVal; -} - diff --git a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingA/test3/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingA/test3/testinfo.dat deleted file mode 100644 index 4689ee6a0..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingA/test3/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Filemapping_memmgt -Function = CreateFileMapping -Name = CreateFileMappingA with PAGE_READWRITE -TYPE = DEFAULT -EXE1 = createfilemapping -Description -=Test the CreateFileMapping to create a unnamed file-mapping object -=and with PAGE_READWRITE protection diff --git a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingA/test4/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingA/test4/CMakeLists.txt deleted file mode 100644 index d5d5c8021..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingA/test4/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - CreateFileMapping.cpp -) - -add_executable(paltest_createfilemappinga_test4 - ${SOURCES} -) - -add_dependencies(paltest_createfilemappinga_test4 coreclrpal) - -target_link_libraries(paltest_createfilemappinga_test4 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingA/test4/CreateFileMapping.cpp b/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingA/test4/CreateFileMapping.cpp deleted file mode 100644 index 64caa88ca..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingA/test4/CreateFileMapping.cpp +++ /dev/null @@ -1,181 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: createfilemapping.c (test 4) -** -** Purpose: Positive test the CreateFileMapping API. -** Call CreateFileMapping with access PAGE_WRITECOPY. -** -** -**============================================================*/ -#include - -const int MAPPINGSIZE = 2048; - -int __cdecl main(int argc, char *argv[]) -{ - - HANDLE hFile; - char buf[] = "this is a test string"; - char ch[2048]; - char lpFileName[] = "test.tmp"; - HANDLE hFileMapping; - LPVOID lpMapViewAddress; - int RetVal = PASS; - int err; - DWORD dwBytesWritten; - - - /* Initialize the PAL environment. - */ - if(0 != PAL_Initialize(argc, argv)) - { - return FAIL; - } - - /* Create a file handle with CreateFile. - */ - hFile = CreateFile( lpFileName, - GENERIC_WRITE|GENERIC_READ, - FILE_SHARE_READ|FILE_SHARE_WRITE, - NULL, - CREATE_ALWAYS, - FILE_ATTRIBUTE_NORMAL, - NULL); - - if (hFile == INVALID_HANDLE_VALUE) - { - Fail("ERROR: %u :unable to create file \"%s\".\n", - GetLastError(), - lpFileName); - } - - /* Write to the File handle. - */ - err = WriteFile(hFile, - buf, - strlen(buf), - &dwBytesWritten, - NULL); - - if (err == FALSE) - { - Trace("ERROR: %u :unable to write to file handle " - "hFile=0x%lx\n", - GetLastError(), - hFile); - RetVal = FAIL; - goto CleanUpOne; - } - - /* Flush to the hard-drive. - */ - FlushFileBuffers(hFile); - - /* Initialize the buffers. - */ - memset(ch, 0, MAPPINGSIZE); - - /* Create a unnamed file-mapping object with file handle FileHandle - * and with PAGE_WRITECOPY protection. - */ - hFileMapping = CreateFileMapping( - hFile, - NULL, /*not inherited*/ - PAGE_WRITECOPY, /*write copy*/ - 0, /*high-order size*/ - 0, /*low-order size*/ - NULL); /*unnamed object*/ - - if(NULL == hFileMapping) - { - Trace("ERROR:%u: Failed to create File Mapping.\n", - GetLastError()); - RetVal = FAIL; - goto CleanUpOne; - } - - /* maps a view of a file into the address space of the calling process. - */ - lpMapViewAddress = MapViewOfFile( - hFileMapping, - FILE_MAP_COPY, /* access code */ - 0, /* high order offset*/ - 0, /* low order offset*/ - 0); /* number of bytes for map */ - - if(NULL == lpMapViewAddress) - { - Trace("ERROR:%u: Failed to call MapViewOfFile " - "API to map a view of file!\n", - GetLastError()); - RetVal = FAIL; - goto CleanUpTwo; - } - - /* Write to the Map view.3 - */ - memcpy(lpMapViewAddress, buf, strlen(buf)); - - /* Read from the Map view. - */ - memcpy(ch, (LPCSTR)lpMapViewAddress, MAPPINGSIZE); - - /* Copy the MapViewOfFile to buffer, so we can - * compare with value read from file directly. - */ - if (memcmp(ch, buf, strlen(buf))!= 0) - { - Trace("ERROR: MapViewOfFile not equal to file contents " - "retrieved \"%s\", expected \"%s\".\n", - ch, buf); - RetVal = FAIL; - goto CleanUpThree; - } - -CleanUpThree: - - /* Unmap the view of file. - */ - if ( UnmapViewOfFile(lpMapViewAddress) == FALSE ) - { - Trace("ERROR:%u: Failed to UnmapViewOfFile of \"%0x%lx\".\n", - GetLastError(), - lpMapViewAddress); - RetVal = FAIL; - } - -CleanUpTwo: - - /* Close Handle to opend file mapping. - */ - if ( CloseHandle(hFileMapping) == FALSE ) - { - Trace("ERROR:%u: Failed to CloseHandle \"0x%lx\".\n", - GetLastError(), - hFileMapping); - RetVal = FAIL; - } - -CleanUpOne: - - /* Close Handle to create file mapping. - */ - if ( CloseHandle(hFile) == FALSE ) - { - Trace("ERROR:%u: Failed to CloseHandle \"0x%lx\".\n", - GetLastError(), - hFile); - RetVal = FAIL; - } - - /* Terminate the PAL. - */ - PAL_TerminateEx(RetVal); - return RetVal; -} - - diff --git a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingA/test4/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingA/test4/testinfo.dat deleted file mode 100644 index 7d9dda1a9..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingA/test4/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Filemapping_memmgt -Function = CreateFileMapping -Name = CreateFileMappingA with PAGE_WRITECOPY. -TYPE = DEFAULT -EXE1 = createfilemapping -Description -= Positive test the CreateFileMapping API. -= Call CreateFileMapping with access PAGE_WRITECOPY. diff --git a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingA/test5/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingA/test5/CMakeLists.txt deleted file mode 100644 index 96cd09f95..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingA/test5/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - CreateFileMapping.cpp -) - -add_executable(paltest_createfilemappinga_test5 - ${SOURCES} -) - -add_dependencies(paltest_createfilemappinga_test5 coreclrpal) - -target_link_libraries(paltest_createfilemappinga_test5 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingA/test5/CreateFileMapping.cpp b/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingA/test5/CreateFileMapping.cpp deleted file mode 100644 index c7f9918b0..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingA/test5/CreateFileMapping.cpp +++ /dev/null @@ -1,193 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: createfilemapping.c (test 5) -** -** Purpose: Positive test the CreateFileMapping API. -** Test CreateFileMapping to a "swap" handle with -** access PAGE_READONLY. -** -** -**============================================================*/ -#include - -const int MAPPINGSIZE = 2048; -HANDLE SWAP_HANDLE = ((VOID *)(-1)); - -int __cdecl main(int argc, char *argv[]) -{ - char testString[] = "this is a test string"; - char lpObjectName[] = "myMappingObject"; - int RetVal = FAIL; - char results[2048]; - - HANDLE hFileMapRO; - HANDLE hFileMapRW; - LPVOID lpMapViewRO; - LPVOID lpMapViewRW; - - /* Initialize the PAL environment. - */ - if(0 != PAL_Initialize(argc, argv)) - { - return FAIL; - } - - /* Initialize the buffers. - */ - memset(results, 0, MAPPINGSIZE); - - /* Create a named file-mapping object with file handle FileHandle - * and with PAGE_READWRITE protection. - */ - hFileMapRW = CreateFileMapping( - SWAP_HANDLE, - NULL, /*not inherited*/ - PAGE_READWRITE, /*read only*/ - 0, /*high-order size*/ - MAPPINGSIZE, /*low-order size*/ - lpObjectName); /*named object*/ - - if(NULL == hFileMapRW) - { - Fail("ERROR:%u: Failed to create File Mapping.\n", - GetLastError()); - } - - /* maps a view of a file into the address space of the calling process. - */ - lpMapViewRW = MapViewOfFile( - hFileMapRW, - FILE_MAP_ALL_ACCESS, /* access code */ - 0, /* high order offset*/ - 0, /* low order offset*/ - MAPPINGSIZE); /* number of bytes for map */ - - if(NULL == lpMapViewRW) - { - Trace("ERROR:%u: Failed to call MapViewOfFile " - "API to map a view of file!\n", - GetLastError()); - RetVal = FAIL; - goto CleanUpOne; - } - - - hFileMapRO = CreateFileMapping( - SWAP_HANDLE, - NULL, /*not inherited*/ - PAGE_READONLY, /*read and write*/ - 0, /*high-order size*/ - MAPPINGSIZE, /*low-order size*/ - lpObjectName); /*named object*/ - - if(NULL == hFileMapRO) - { - Trace("ERROR:%u: Failed to create File Mapping.\n", - GetLastError()); - RetVal = FAIL; - goto CleanUpTwo; - } - - /* maps a view of a file into the address space of the calling process. - */ - lpMapViewRO = MapViewOfFile( - hFileMapRO, - FILE_MAP_READ, /* access code */ - 0, /* high order offset*/ - 0, /* low order offset*/ - MAPPINGSIZE); /* number of bytes for map */ - - if(NULL == lpMapViewRO) - { - Trace("ERROR:%u: Failed to call MapViewOfFile " - "API to map a view of file!\n", - GetLastError()); - RetVal = FAIL; - goto CleanUpThree; - } - - /* Write the test string to the Map view. - */ - memcpy(lpMapViewRW, testString, strlen(testString)); - - /* Read from the second Map view. - */ - memcpy(results, (LPCSTR)lpMapViewRO, MAPPINGSIZE); - - /* Verify the contents of the file mapping, - * by comparing what was written to what was read. - */ - if (memcmp(results, testString, strlen(testString))!= 0) - { - Trace("ERROR: MapViewOfFile not equal to file contents " - "retrieved \"%s\", expected \"%s\".\n", - results, - testString); - RetVal = FAIL; - goto CleanUpFour; - } - - /* Test was successful. - */ - RetVal = PASS; - -CleanUpFour: - - /* Unmap the view of file. - */ - if ( UnmapViewOfFile(lpMapViewRO) == FALSE ) - { - Trace("ERROR:%u: Failed to UnmapViewOfFile of \"%0x%lx\".\n", - GetLastError(), - lpMapViewRO); - RetVal = FAIL; - } - -CleanUpThree: - - /* Close Handle to opend file mapping. - */ - if ( CloseHandle(hFileMapRO) == FALSE ) - { - Trace("ERROR:%u: Failed to CloseHandle \"0x%lx\".\n", - GetLastError(), - hFileMapRO); - RetVal = FAIL; - } - - -CleanUpTwo: - /* Unmap the view of file. - */ - if ( UnmapViewOfFile(lpMapViewRW) == FALSE ) - { - Trace("ERROR:%u: Failed to UnmapViewOfFile of \"%0x%lx\".\n", - GetLastError(), - lpMapViewRW); - RetVal = FAIL; - } - - -CleanUpOne: - - /* Close Handle to opend file mapping. - */ - if ( CloseHandle(hFileMapRW) == FALSE ) - { - Trace("ERROR:%u: Failed to CloseHandle \"0x%lx\".\n", - GetLastError(), - hFileMapRW); - RetVal = FAIL; - } - - - /* Terminate the PAL. - */ - PAL_TerminateEx(RetVal); - return RetVal; -} - diff --git a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingA/test5/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingA/test5/testinfo.dat deleted file mode 100644 index 137db9d82..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingA/test5/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Filemapping_memmgt -Function = CreateFileMapping -Name = CreateFileMappingA - with PAGE_READWRITE and INVALID_HANDLE_VALUE file handle -TYPE = DEFAULT -EXE1 = createfilemapping -Description -=Test the CreateFileMapping to create a unnamed file-mapping object -=and with PAGE_READWRITE protection by passing INVALID_HANDLE_VALUE -=file handle diff --git a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingA/test6/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingA/test6/CMakeLists.txt deleted file mode 100644 index 383eb6e62..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingA/test6/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - CreateFileMapping.cpp -) - -add_executable(paltest_createfilemappinga_test6 - ${SOURCES} -) - -add_dependencies(paltest_createfilemappinga_test6 coreclrpal) - -target_link_libraries(paltest_createfilemappinga_test6 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingA/test6/CreateFileMapping.cpp b/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingA/test6/CreateFileMapping.cpp deleted file mode 100644 index 6445295de..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingA/test6/CreateFileMapping.cpp +++ /dev/null @@ -1,164 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: createfilemapping.c (test 6) -** -** Purpose: Positive test the CreateFileMapping API. -** Test CreateFileMapping to a "swap" handle with -** access PAGE_READWRITE. -** -** -**============================================================*/ -#include - -const int MAPPINGSIZE = 2048; -HANDLE SWAP_HANDLE = ((VOID *)(-1)); - -int __cdecl main(int argc, char *argv[]) -{ - char testString[] = "this is a test string"; - char lpObjectName[] = "myMappingObject"; - char results[2048]; - int RetVal = PASS; - - HANDLE hFileMapRW; - LPVOID lpMapViewRW; - LPVOID lpMapViewRW2; - - /* Initialize the PAL environment. - */ - if(0 != PAL_Initialize(argc, argv)) - { - return FAIL; - } - - /* Initialize the buffers. - */ - memset(results, 0, MAPPINGSIZE); - - /* Create a named file-mapping object with file handle FileHandle - * and with PAGE_READWRITE protection. - */ - hFileMapRW = CreateFileMapping( - SWAP_HANDLE, - NULL, /*not inherited*/ - PAGE_READWRITE, /*read write*/ - 0, /*high-order size*/ - MAPPINGSIZE, /*low-order size*/ - lpObjectName); /*unnamed object*/ - - if(NULL == hFileMapRW) - { - Fail("ERROR:%u: Failed to create File Mapping.\n", - GetLastError()); - } - - /* Create a map view of the READWRITE file mapping. - */ - lpMapViewRW = MapViewOfFile( - hFileMapRW, - FILE_MAP_ALL_ACCESS,/* access code */ - 0, /* high order offset*/ - 0, /* low order offset*/ - MAPPINGSIZE); /* number of bytes for map */ - - if(NULL == lpMapViewRW) - { - Trace("ERROR:%u: Failed to call MapViewOfFile " - "API to map a view of file!\n", - GetLastError()); - RetVal = FAIL; - goto CleanUpOne; - } - - - /* maps a view of a file into the address space of the calling process. - */ - lpMapViewRW2 = MapViewOfFile( - hFileMapRW, - FILE_MAP_ALL_ACCESS, /* access code */ - 0, /* high order offset*/ - 0, /* low order offset*/ - MAPPINGSIZE); /* number of bytes for map */ - - if(NULL == lpMapViewRW2) - { - Trace("ERROR:%u: Failed to call MapViewOfFile " - "API to map a view of file!\n", - GetLastError()); - RetVal = FAIL; - goto CleanUpTwo; - } - - /* Write the test string to the Map view. - */ - memcpy(lpMapViewRW, testString, strlen(testString)); - - /* Read from the second Map view. - */ - memcpy(results, (LPCSTR)lpMapViewRW2, MAPPINGSIZE); - - /* Verify the contents of the file mapping, - * by comparing what was written to what was read. - */ - if (memcmp(results, testString, strlen(testString))!= 0) - { - Trace("ERROR: MapViewOfFile not equal to file contents " - "retrieved \"%s\", expected \"%s\".\n", - results, - testString); - RetVal = FAIL; - goto CleanUpThree; - } - - /* Test successful. - */ - RetVal = PASS; - -CleanUpThree: - - /* Unmap the view of file. - */ - if ( UnmapViewOfFile(lpMapViewRW2) == FALSE ) - { - Trace("ERROR:%u: Failed to UnmapViewOfFile of \"%0x%lx\".\n", - GetLastError(), - lpMapViewRW2); - RetVal = FAIL; - } - -CleanUpTwo: - - /* Unmap the view of file. - */ - if ( UnmapViewOfFile(lpMapViewRW) == FALSE ) - { - Trace("ERROR:%u: Failed to UnmapViewOfFile of \"%0x%lx\".\n", - GetLastError(), - lpMapViewRW); - RetVal = FAIL; - } - - -CleanUpOne: - - /* Close Handle to create file mapping. - */ - if ( CloseHandle(hFileMapRW) == FALSE ) - { - Trace("ERROR:%u: Failed to CloseHandle \"0x%lx\".\n", - GetLastError(), - hFileMapRW); - RetVal = FAIL; - } - - - /* Terminate the PAL. - */ - PAL_TerminateEx(RetVal); - return RetVal; -} - diff --git a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingA/test6/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingA/test6/testinfo.dat deleted file mode 100644 index d088c5d56..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingA/test6/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Filemapping_memmgt -Function = CreateFileMapping -Name = CreateFileMappingA - with PAGE_READONLY -TYPE = DEFAULT -EXE1 = createfilemapping -Description -=Test the CreateFileMapping to create a named file-mapping object -=and with PAGE_READONLY protection diff --git a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingA/test7/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingA/test7/CMakeLists.txt deleted file mode 100644 index 8f8a2a454..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingA/test7/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - createfilemapping.cpp -) - -add_executable(paltest_createfilemappinga_test7 - ${SOURCES} -) - -add_dependencies(paltest_createfilemappinga_test7 coreclrpal) - -target_link_libraries(paltest_createfilemappinga_test7 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingA/test7/createfilemapping.cpp b/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingA/test7/createfilemapping.cpp deleted file mode 100644 index 7cef9ddcd..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingA/test7/createfilemapping.cpp +++ /dev/null @@ -1,164 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: createfilemapping.c (test 7) -** -** Purpose: Positive test the CreateFileMapping API. -** Test CreateFileMapping to a "swap" handle with -** access PAGE_READWRITE. -** -** -**============================================================*/ -#include - -const int MAPPINGSIZE = 2048; -HANDLE SWAP_HANDLE = ((VOID *)(-1)); - -int __cdecl main(int argc, char *argv[]) -{ - char testString[] = "this is a test string"; - char lpObjectName[] = "myMappingObject"; - char results[2048]; - int RetVal = PASS; - - HANDLE hFileMapRW; - LPVOID lpMapViewRW; - LPVOID lpMapViewRO; - - /* Initialize the PAL environment. - */ - if(0 != PAL_Initialize(argc, argv)) - { - return FAIL; - } - - /* Initialize the buffers. - */ - memset(results, 0, MAPPINGSIZE); - - /* Create a named file-mapping object with file handle FileHandle - * and with PAGE_READWRITE protection. - */ - hFileMapRW = CreateFileMapping( - SWAP_HANDLE, - NULL, /*not inherited*/ - PAGE_READWRITE, /*read write*/ - 0, /*high-order size*/ - MAPPINGSIZE, /*low-order size*/ - lpObjectName); /*unnamed object*/ - - if(NULL == hFileMapRW) - { - Fail("ERROR:%u: Failed to create File Mapping.\n", - GetLastError()); - } - - /* Create a map view to the READWRITE file mapping. - */ - lpMapViewRW = MapViewOfFile( - hFileMapRW, - FILE_MAP_ALL_ACCESS,/* access code */ - 0, /* high order offset*/ - 0, /* low order offset*/ - MAPPINGSIZE); /* number of bytes for map */ - - if(NULL == lpMapViewRW) - { - Trace("ERROR:%u: Failed to call MapViewOfFile " - "API to map a view of file!\n", - GetLastError()); - RetVal = FAIL; - goto CleanUpOne; - } - - - /* Create a map view to the READWRITE file mapping. - */ - lpMapViewRO = MapViewOfFile( - hFileMapRW, - FILE_MAP_READ, /* access code */ - 0, /* high order offset*/ - 0, /* low order offset*/ - MAPPINGSIZE); /* number of bytes for map */ - - if(NULL == lpMapViewRO) - { - Trace("ERROR:%u: Failed to call MapViewOfFile " - "API to map a view of file!\n", - GetLastError()); - RetVal = FAIL; - goto CleanUpTwo; - } - - /* Write the test string to the Map view. - */ - memcpy(lpMapViewRW, testString, strlen(testString)); - - /* Read from the second Map view. - */ - memcpy(results, (LPCSTR)lpMapViewRO, MAPPINGSIZE); - - /* Verify the contents of the file mapping, - * by comparing what was written to what was read. - */ - if (memcmp(results, testString, strlen(testString))!= 0) - { - Trace("ERROR: MapViewOfFile not equal to file contents " - "retrieved \"%s\", expected \"%s\".\n", - results, - testString); - RetVal = FAIL; - goto CleanUpThree; - } - - /* Test successful. - */ - RetVal = PASS; - -CleanUpThree: - - /* Unmap the view of file. - */ - if ( UnmapViewOfFile(lpMapViewRO) == FALSE ) - { - Trace("ERROR:%u: Failed to UnmapViewOfFile of \"%0x%lx\".\n", - GetLastError(), - lpMapViewRO); - RetVal = FAIL; - } - -CleanUpTwo: - - /* Unmap the view of file. - */ - if ( UnmapViewOfFile(lpMapViewRW) == FALSE ) - { - Trace("ERROR:%u: Failed to UnmapViewOfFile of \"%0x%lx\".\n", - GetLastError(), - lpMapViewRW); - RetVal = FAIL; - } - - -CleanUpOne: - - /* Close Handle to create file mapping. - */ - if ( CloseHandle(hFileMapRW) == FALSE ) - { - Trace("ERROR:%u: Failed to CloseHandle \"0x%lx\".\n", - GetLastError(), - hFileMapRW); - RetVal = FAIL; - } - - - /* Terminate the PAL. - */ - PAL_TerminateEx(RetVal); - return RetVal; -} - diff --git a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingA/test7/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingA/test7/testinfo.dat deleted file mode 100644 index c03d98a91..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingA/test7/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Filemapping_memmgt -Function = CreateFileMapping -Name = CreateFileMappingA - with PAGE_COPYWRITE -TYPE = DEFAULT -EXE1 = createfilemapping -Description -=Test the CreateFileMapping to create a named file-mapping object -=and with PAGE_READONLY protection diff --git a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingA/test8/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingA/test8/CMakeLists.txt deleted file mode 100644 index 5246d0d5f..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingA/test8/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - createfilemapping.cpp -) - -add_executable(paltest_createfilemappinga_test8 - ${SOURCES} -) - -add_dependencies(paltest_createfilemappinga_test8 coreclrpal) - -target_link_libraries(paltest_createfilemappinga_test8 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingA/test8/createfilemapping.cpp b/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingA/test8/createfilemapping.cpp deleted file mode 100644 index 02b2fb5e6..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingA/test8/createfilemapping.cpp +++ /dev/null @@ -1,79 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: createfilemapping.c (test 8) -** -** Purpose: Positive test the CreateFileMapping API. -** Test the un-verifiable parameter combinations. -** -** -**============================================================*/ -#include - -const int MAPPINGSIZE = 2048; -HANDLE SWAP_HANDLE = ((VOID *)(-1)); - -int __cdecl main(int argc, char *argv[]) -{ - HANDLE hFileMap; - - /* Initialize the PAL environment. - */ - if(0 != PAL_Initialize(argc, argv)) - { - return FAIL; - } - - /* Create a READONLY, "swap", un-named file mapping. - * This test is unverifiable since there is no hook back to the file map - * because it is un-named. As well, since it resides in "swap", and is - * initialized to zero, there is nothing to read. - */ - hFileMap = CreateFileMapping( - SWAP_HANDLE, - NULL, /*not inherited*/ - PAGE_READONLY, /*read only*/ - 0, /*high-order size*/ - MAPPINGSIZE, /*low-order size*/ - NULL); /*un-named object*/ - - if(NULL == hFileMap) - { - Fail("ERROR:%u: Failed to create File Mapping.\n", - GetLastError()); - } - - - /* Create a COPYWRITE, "swap", un-named file mapping. - * This test is unverifiable, here is a quote from MSDN: - * - * Copy on write access. If you create the map with PAGE_WRITECOPY and - * the view with FILE_MAP_COPY, you will receive a view to file. If you - * write to it, the pages are automatically swappable and the modifications - * you make will not go to the original data file. - * - */ - hFileMap = CreateFileMapping( - SWAP_HANDLE, - NULL, /*not inherited*/ - PAGE_WRITECOPY, /*read only*/ - 0, /*high-order size*/ - MAPPINGSIZE, /*low-order size*/ - NULL); /*unnamed object*/ - - if(NULL == hFileMap) - { - Fail("ERROR:%u: Failed to create File Mapping.\n", - GetLastError()); - } - - - /* Terminate the PAL. - */ - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingA/test8/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingA/test8/testinfo.dat deleted file mode 100644 index ebe138f65..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingA/test8/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Filemapping_memmgt -Function = CreateFileMapping -Name = CreateFileMappingA - unnamed swap, READWRITE. -TYPE = DEFAULT -EXE1 = createfilemapping -Description -= Positive test the CreateFileMapping API. -= Test an unnamed File Mapping to a "swap" -= handle with access PAGE_READWRITE. diff --git a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingA/test9/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingA/test9/CMakeLists.txt deleted file mode 100644 index b0a801701..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingA/test9/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - createfilemapping.cpp -) - -add_executable(paltest_createfilemappinga_test9 - ${SOURCES} -) - -add_dependencies(paltest_createfilemappinga_test9 coreclrpal) - -target_link_libraries(paltest_createfilemappinga_test9 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingA/test9/createfilemapping.cpp b/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingA/test9/createfilemapping.cpp deleted file mode 100644 index 9224c22b4..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingA/test9/createfilemapping.cpp +++ /dev/null @@ -1,150 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: createfilemapping.c (test 9) -** -** Purpose: Negative test the CreateFileMapping API. -** -** -**============================================================*/ -#include - -const int MAPPINGSIZE = 2048; - -int __cdecl main(int argc, char *argv[]) -{ - - HANDLE hFile; - char lpFileName[] = "test.tmp"; - - HANDLE hFileMapping; - - /* Initialize the PAL environment. - */ - if(0 != PAL_Initialize(argc, argv)) - { - return FAIL; - } - - /* Create a file handle with CreateFile, as READONLY - */ - hFile = CreateFile( lpFileName, - GENERIC_READ, - FILE_SHARE_READ, - NULL, - CREATE_ALWAYS, - FILE_ATTRIBUTE_NORMAL, - NULL); - - if (hFile == INVALID_HANDLE_VALUE) - { - Fail("ERROR: %u :unable to create file \"%s\".\n", - GetLastError(), - lpFileName); - } - - /* Attempt to create a unnamed file-mapping object to a READONLY file - * as READWRITE access. - */ - hFileMapping = CreateFileMapping( - hFile, - NULL, /*not inherited*/ - PAGE_READWRITE, /*read and write*/ - 0, /*high-order size*/ - MAPPINGSIZE, /*low-order size*/ - NULL); /*unnamed object*/ - - if(NULL != hFileMapping) - { - Trace("ERROR: Able to create READWRITE mapping to a " - "READONLY file.\n" ); - if( 0 == CloseHandle(hFile) ) - { - Trace("Unexpected Error: Unable to close file handle\n"); - } - Fail(""); - } - - /* Attempt to create a unnamed file-mapping object to a zero lenght - * file. - */ - hFileMapping = CreateFileMapping( - hFile, - NULL, /*not inherited*/ - PAGE_READWRITE, /*read and write*/ - 0, /*high-order size*/ - 0, /*low-order size*/ - NULL); /*unnamed object*/ - - if( NULL != hFileMapping ) - { - Trace("ERROR: Able to create READWRITE mapping to a " - "READONLY file.\n" ); - if( 0 == CloseHandle(hFile) ) - { - Trace("Unexpected Error: Unable to close file handle\n"); - } - Fail(""); - } - if(GetLastError() != ERROR_ACCESS_DENIED) - { - Trace("ERROR: Expected GetLastError() to return " - "ERROR_FILE_INVALID (%d), it returned %u.\n", - ERROR_FILE_INVALID, - GetLastError()); - if( 0 == CloseHandle(hFile) ) - { - Trace("Unexpected Error: Unable to close file handle\n"); - } - Fail(""); - } - - /* Attempt to create a file mapping that is larger than - * the file. - */ - hFileMapping = CreateFileMapping( - hFile, - NULL, /*not inherited*/ - PAGE_READONLY, /*read only*/ - 0, /*high-order size*/ - MAPPINGSIZE, /*low-order size*/ - NULL); /*unnamed object*/ - if(NULL != hFileMapping) - { - Trace("ERROR: Able to create file mapping of size %d to " - "file of size 0.\n", - MAPPINGSIZE); - if( 0 == CloseHandle(hFile) ) - { - Trace("Unexpected Error: Unable to close file handle\n"); - } - Fail(""); - } - - if(GetLastError() != ERROR_NOT_ENOUGH_MEMORY ) - { - Trace("ERROR: Expected GetLastError() to return " - "ERROR_NOT_ENOUGH_MEMORY (%d), it returned %u.\n", - ERROR_NOT_ENOUGH_MEMORY, - GetLastError()); - if( 0 == CloseHandle(hFile) ) - { - Trace("Unexpected Error: Unable to close file handle\n"); - } - Fail(""); - } - - if( 0 == CloseHandle(hFile) ) - { - Fail("Unexpected Error: Unable to close file handle\n"); - } - - /* Terminate the PAL. - */ - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingA/test9/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingA/test9/testinfo.dat deleted file mode 100644 index 11cbedc8c..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingA/test9/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Filemapping_memmgt -Function = CreateFileMapping -Name = CreateFileMappingA negative testing -TYPE = DEFAULT -EXE1 = createfilemapping -Description -= Negative test the CreateFileMapping API. diff --git a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/CMakeLists.txt deleted file mode 100644 index 85f5c90e2..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/CMakeLists.txt +++ /dev/null @@ -1,16 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(CreateFileMapping_neg1) -add_subdirectory(test1) - -# TODO: make this test compile -# add_subdirectory(test2) - -add_subdirectory(test3) -add_subdirectory(test4) -add_subdirectory(test5) -add_subdirectory(test6) -add_subdirectory(test7) -add_subdirectory(test8) -add_subdirectory(test9) - diff --git a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/CreateFileMapping_neg1/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/CreateFileMapping_neg1/CMakeLists.txt deleted file mode 100644 index 7cafe0971..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/CreateFileMapping_neg1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - CreateFileMapping_neg.cpp -) - -add_executable(paltest_createfilemappingw_createfilemapping_neg1 - ${SOURCES} -) - -add_dependencies(paltest_createfilemappingw_createfilemapping_neg1 coreclrpal) - -target_link_libraries(paltest_createfilemappingw_createfilemapping_neg1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/CreateFileMapping_neg1/CreateFileMapping_neg.cpp b/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/CreateFileMapping_neg1/CreateFileMapping_neg.cpp deleted file mode 100644 index 8cf79b3c5..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/CreateFileMapping_neg1/CreateFileMapping_neg.cpp +++ /dev/null @@ -1,93 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: createfilemapping_neg.c -** -** Purpose: Negative test the CreateFileMapping API. -** Call CreateFileMapping to create a unnamed -** file-mapping object with PAGE_READONLY -** protection and try to map a zero length file -** in UNICODE -** -** -**============================================================*/ -#define UNICODE -#include - -int __cdecl main(int argc, char *argv[]) -{ - - HANDLE FileHandle; - HANDLE FileMappingHandle; - int err; - WCHAR *lpFileName = NULL; - - //Initialize the PAL environment - err = PAL_Initialize(argc, argv); - if(0 != err) - { - ExitProcess(FAIL); - } - - //conver string to a unicode one - lpFileName = convert("temp.txt"); - - - //create a file and return the file handle - FileHandle = CreateFile(lpFileName, - GENERIC_READ, - FILE_SHARE_READ, - NULL, - CREATE_ALWAYS, - FILE_ATTRIBUTE_ARCHIVE, - NULL); - - //free this memory - free(lpFileName); - - if(INVALID_HANDLE_VALUE == FileHandle) - { - Fail("Failed to call CreateFile to create a file\n"); - } - - //create a unnamed file-mapping object with file handle FileHandle - //and with PAGE_READONLY protection - //try to map a file which is zero length. - FileMappingHandle = CreateFileMapping( - FileHandle, //File Handle - NULL, //not inherited - PAGE_READONLY, //access protection - 0, //high-order of object size - 0, //low-orger of object size - NULL); //unnamed object - - - if(NULL != FileMappingHandle || ERROR_FILE_INVALID != GetLastError()) - {//no error occurred - Trace("\nFailed to call CreateFileMapping API for a negative test!\n"); - err = CloseHandle(FileHandle); - if(0 == err) - { - Fail("\nFailed to call CloseHandle API\n"); - } - err = CloseHandle(FileMappingHandle); - if(0 == err) - { - Fail("\nFailed to call CloseHandle API\n"); - } - Fail(""); - } - - //close the file handle - err = CloseHandle(FileHandle); - if(0 == err) - { - Fail("\nFailed to call CloseHandle API\n"); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/CreateFileMapping_neg1/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/CreateFileMapping_neg1/testinfo.dat deleted file mode 100644 index a09487d4b..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/CreateFileMapping_neg1/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Filemapping_memmgt -Function = CreateFileMapping -Name = Negative test for CreateFileMappingW - with a zero length file -TYPE = DEFAULT -EXE1 = createfilemapping_neg -Description -=Test the CreateFileMapping to try to map a zero length file diff --git a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/test1/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/test1/CMakeLists.txt deleted file mode 100644 index 661fd5d3b..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - CreateFileMappingW.cpp -) - -add_executable(paltest_createfilemappingw_test1 - ${SOURCES} -) - -add_dependencies(paltest_createfilemappingw_test1 coreclrpal) - -target_link_libraries(paltest_createfilemappingw_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/test1/CreateFileMappingW.cpp b/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/test1/CreateFileMappingW.cpp deleted file mode 100644 index 4263a3ad2..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/test1/CreateFileMappingW.cpp +++ /dev/null @@ -1,174 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: createfilemappingw.c (test 1) -** -** Purpose: Positive test the CreateFileMappingW API. -** Call CreateFileMappingW with access PAGE_READONLY. -** -** -**============================================================*/ -#define UNICODE -#include - -const int MAPPINGSIZE = 2048; - -int __cdecl main(int argc, char *argv[]) -{ - - HANDLE hFile; - char buf[] = "this is a test string"; - char ch[2048]; - WCHAR lpFileName[] = {'t','e','s','t','.','t','m','p','\0'}; - DWORD dwBytesWritten; - BOOL err; - int RetVal = PASS; - - HANDLE hFileMapping; - LPVOID lpMapViewAddress; - - /* Initialize the PAL environment. - */ - if(0 != PAL_Initialize(argc, argv)) - { - return FAIL; - } - - /* Create a file handle with CreateFile. - */ - hFile = CreateFile( lpFileName, - GENERIC_WRITE|GENERIC_READ, - FILE_SHARE_READ|FILE_SHARE_WRITE, - NULL, - CREATE_ALWAYS, - FILE_ATTRIBUTE_NORMAL, - NULL); - - if (hFile == INVALID_HANDLE_VALUE) - { - Fail("ERROR: %u :unable to create file \"%s\".\n", - GetLastError(), - lpFileName); - } - - /* Initialize the buffers. - */ - memset(ch, 0, MAPPINGSIZE); - - /* Write to the File handle. - */ - err = WriteFile(hFile, - buf, - strlen(buf), - &dwBytesWritten, - NULL); - - if (err == FALSE) - { - Trace("ERROR: %u :unable to write to file handle " - "hFile=0x%lx\n", - GetLastError(), - hFile); - RetVal = FAIL; - goto CleanUpOne; - } - - /* Flush to the hard-drive. - */ - FlushFileBuffers(hFile); - - /* Create a unnamed file-mapping object with file handle FileHandle - * and with PAGE_READWRITE protection. - */ - hFileMapping = CreateFileMapping( - hFile, - NULL, /*not inherited*/ - PAGE_READONLY, /*read and wite*/ - 0, /*high-order size*/ - 0, /*low-order size*/ - NULL); /*unnamed object*/ - - if(NULL == hFileMapping) - { - Trace("ERROR:%u: Failed to create File Mapping.\n", - GetLastError()); - RetVal = FAIL; - goto CleanUpOne; - } - - /* maps a view of a file into the address space of the calling process. - */ - lpMapViewAddress = MapViewOfFile( - hFileMapping, - FILE_MAP_READ, /* access code */ - 0, /*high order offset*/ - 0, /*low order offset*/ - 0); /* number of bytes for map */ - - if(NULL == lpMapViewAddress) - { - Trace("ERROR:%u: Failed to call MapViewOfFile " - "API to map a view of file!\n", - GetLastError()); - RetVal = FAIL; - goto CleanUpTwo; - } - - /* Copy the MapViewOfFile to buffer, so we can - * compare with value read from file directly. - */ - memcpy(ch, (LPCSTR)lpMapViewAddress, MAPPINGSIZE); - if (memcmp(ch, buf, strlen(buf))!= 0) - { - Trace("ERROR: MapViewOfFile not equal to file contents " - "retrieved \"%s\", expected \"%s\".\n", - ch, buf); - RetVal = FAIL; - goto CleanUpThree; - } - -CleanUpThree: - - /* Unmap the view of file. - */ - if ( UnmapViewOfFile(lpMapViewAddress) == FALSE ) - { - Trace("ERROR:%u: Failed to UnmapViewOfFile of \"%0x%lx\".\n", - GetLastError(), - lpMapViewAddress); - RetVal = FAIL; - } - -CleanUpTwo: - - /* Close Handle to opend file mapping. - */ - if ( CloseHandle(hFileMapping) == FALSE ) - { - Trace("ERROR:%u: Failed to CloseHandle \"0x%lx\".\n", - GetLastError(), - hFileMapping); - RetVal = FAIL; - } - -CleanUpOne: - - /* Close Handle to create file mapping. - */ - if ( CloseHandle(hFile) == FALSE ) - { - Trace("ERROR:%u: Failed to CloseHandle \"0x%lx\".\n", - GetLastError(), - hFile); - RetVal = FAIL; - } - - /* Terminate the PAL. - */ - PAL_TerminateEx(RetVal); - return RetVal; -} - diff --git a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/test1/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/test1/testinfo.dat deleted file mode 100644 index 464679a45..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Filemapping_memmgt -Function = CreateFileMappingW -Name = CreateFileMappingW with PAGE_READONLY -TYPE = DEFAULT -EXE1 = createfilemappingw -Description -=Test the CreateFileMappingW to create a unnamed file-mapping object -=and with PAGE_READONLY protection diff --git a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/test2/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/test2/CMakeLists.txt deleted file mode 100644 index 7fac43a4a..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - CreateFileMappingW.cpp -) - -add_executable(paltest_createfilemappingw_test2 - ${SOURCES} -) - -add_dependencies(paltest_createfilemappingw_test2 coreclrpal) - -target_link_libraries(paltest_createfilemappingw_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/test2/CreateFileMappingW.cpp b/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/test2/CreateFileMappingW.cpp deleted file mode 100644 index 5cc6d7770..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/test2/CreateFileMappingW.cpp +++ /dev/null @@ -1,124 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: createfilemappingw.c -** -** Purpose: Positive test the CreateFileMapping API. -** Call CreateFileMapping to create a unnamed -** file-mapping object with PAGE_READONLY -** protection and SEC_IMAGE attribute in UNICODE -** -** -**============================================================*/ -#define UNICODE -#include - -int __cdecl main(int argc, char *argv[]) -{ - - HANDLE FileHandle; - HANDLE FileMappingHandle; - int err; - WCHAR *wpFileName = NULL; - char executableFileName[256]=""; - - - //Initialize the PAL environment - err = PAL_Initialize(argc, argv); - if(0 != err) - { - ExitProcess(FAIL); - } - -#if WIN32 - sprintf_s(executableFileName, _countof(executableFileName),"%s","executable.exe"); -#else - sprintf_s(executableFileName, _countof(executableFileName),"%s","executable"); -#endif - - //conver string to a unicode one - wpFileName = convert(executableFileName); - - - //create a file and return the file handle - FileHandle = CreateFile(wpFileName, - GENERIC_READ, - FILE_SHARE_READ, - NULL, - OPEN_EXISTING, - FILE_ATTRIBUTE_ARCHIVE, - NULL); - - //free this memory - free(wpFileName); - - if(INVALID_HANDLE_VALUE == FileHandle) - { - Fail("Failed to call CreateFile to create a file\n"); - } - - //create a unnamed file-mapping object with file handle FileHandle - //and with PAGE_READONLY protection - FileMappingHandle = CreateFileMapping( - FileHandle, //File Handle - NULL, //not inherited - PAGE_READONLY|SEC_IMAGE, //access protection and section attribute - 0, //high-order of object size - 0, //low-orger of object size - NULL); //unnamed object - - - if(NULL == FileMappingHandle) - { - Trace("\nFailed to call CreateFileMapping to create a mapping object!\n"); - err = CloseHandle(FileHandle); - if(0 == err) - { - Fail("\nFailed to call CloseHandle API\n"); - } - Fail(""); - } - if(GetLastError() == ERROR_ALREADY_EXISTS) - { - Trace("\nFile mapping object already exists!\n"); - err = CloseHandle(FileHandle); - if(0 == err) - { - Trace("\nFailed to call CloseHandle API to close a file handle\n"); - err = CloseHandle(FileMappingHandle); - if(0 == err) - { - Fail("\nFailed to call CloseHandle API to close a mapping object handle\n"); - } - Fail(""); - } - err = CloseHandle(FileMappingHandle); - if(0 == err) - { - Fail("\nFailed to call CloseHandle API to close a mapping object handle\n"); - } - Fail(""); - } - err = CloseHandle(FileMappingHandle); - if(0 == err) - { - Trace("\nFailed to call CloseHandle API to close a mapping object handle\n"); - err = CloseHandle(FileHandle); - if(0 == err) - { - Fail("\nFailed to call CloseHandle API to close a file handle\n"); - } - Fail(""); - } - err = CloseHandle(FileHandle); - if(0 == err) - { - Fail("\nFailed to call CloseHandle API to close a file handle\n"); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/test3/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/test3/CMakeLists.txt deleted file mode 100644 index 1e9596067..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/test3/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - CreateFileMappingW.cpp -) - -add_executable(paltest_createfilemappingw_test3 - ${SOURCES} -) - -add_dependencies(paltest_createfilemappingw_test3 coreclrpal) - -target_link_libraries(paltest_createfilemappingw_test3 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/test3/CreateFileMappingW.cpp b/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/test3/CreateFileMappingW.cpp deleted file mode 100644 index 1cbeff94a..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/test3/CreateFileMappingW.cpp +++ /dev/null @@ -1,156 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: createfilemappingw.c (test 3) -** -** Purpose: Positive test the CreateFileMappingW API. -** Call CreateFileMapping with access PAGE_READWRITE. -** -** -**============================================================*/ -#define UNICODE -#include - -const int MAPPINGSIZE = 2048; - -int __cdecl main(int argc, char *argv[]) -{ - - HANDLE hFile; - char buf[] = "this is a test string"; - char ch[2048]; - WCHAR lpFileName[] = {'t','e','s','t','.','t','m','p','\0'}; - HANDLE hFileMapping; - LPVOID lpMapViewAddress; - int RetVal = PASS; - - /* Initialize the PAL environment. - */ - if(0 != PAL_Initialize(argc, argv)) - { - return FAIL; - } - - /* Create a file handle with CreateFile. - */ - hFile = CreateFile( lpFileName, - GENERIC_WRITE|GENERIC_READ, - FILE_SHARE_READ|FILE_SHARE_WRITE, - NULL, - CREATE_ALWAYS, - FILE_ATTRIBUTE_NORMAL, - NULL); - - if (hFile == INVALID_HANDLE_VALUE) - { - Fail("ERROR: %u :unable to create file \"%s\".\n", - GetLastError(), - lpFileName); - } - - /* Initialize the buffers. - */ - memset(ch, 0, MAPPINGSIZE); - - /* Create a unnamed file-mapping object with file handle FileHandle - * and with PAGE_READWRITE protection. - */ - hFileMapping = CreateFileMapping( - hFile, - NULL, /*not inherited*/ - PAGE_READWRITE, /*read and wite*/ - 0, /*high-order size*/ - MAPPINGSIZE, /*low-order size*/ - NULL); /*unnamed object*/ - - if(NULL == hFileMapping) - { - Trace("ERROR:%u: Failed to create File Mapping.\n", - GetLastError()); - RetVal = FAIL; - goto CleanUpOne; - } - - /* maps a view of a file into the address space of the calling process. - */ - lpMapViewAddress = MapViewOfFile( - hFileMapping, - FILE_MAP_ALL_ACCESS, /* access code */ - 0, /*high order offset*/ - 0, /*low order offset*/ - MAPPINGSIZE); /* number of bytes for map */ - - if(NULL == lpMapViewAddress) - { - Trace("ERROR:%u: Failed to call MapViewOfFile " - "API to map a view of file!\n", - GetLastError()); - RetVal = FAIL; - goto CleanUpTwo; - } - - /* Write to the Map view. - */ - memcpy(lpMapViewAddress, buf, strlen(buf)); - - /* Read from the Map view. - */ - memcpy(ch, (LPCSTR)lpMapViewAddress, MAPPINGSIZE); - - /* Copy the MapViewOfFile to buffer, so we can - * compare with value read from file directly. - */ - if (memcmp(ch, buf, strlen(buf))!= 0) - { - Trace("ERROR: MapViewOfFile not equal to file contents " - "retrieved \"%s\", expected \"%s\".\n", - ch, buf); - RetVal = FAIL; - goto CleanUpThree; - } - -CleanUpThree: - - /* Unmap the view of file. - */ - if ( UnmapViewOfFile(lpMapViewAddress) == FALSE ) - { - Trace("ERROR:%u: Failed to UnmapViewOfFile of \"%0x%lx\".\n", - GetLastError(), - lpMapViewAddress); - RetVal = FAIL; - } - -CleanUpTwo: - - /* Close Handle to opend file mapping. - */ - if ( CloseHandle(hFileMapping) == FALSE ) - { - Trace("ERROR:%u: Failed to CloseHandle \"0x%lx\".\n", - GetLastError(), - hFileMapping); - RetVal = FAIL; - } - -CleanUpOne: - - /* Close Handle to create file mapping. - */ - if ( CloseHandle(hFile) == FALSE ) - { - Trace("ERROR:%u: Failed to CloseHandle \"0x%lx\".\n", - GetLastError(), - hFile); - RetVal = FAIL; - } - - /* Terminate the PAL. - */ - PAL_TerminateEx(RetVal); - return RetVal; -} - diff --git a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/test3/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/test3/testinfo.dat deleted file mode 100644 index 107731661..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/test3/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Filemapping_memmgt -Function = CreateFileMappingW -Name = CreateFileMappingW with PAGE_READWRITE -TYPE = DEFAULT -EXE1 = createfilemappingw -Description -=Test the CreateFileMappingW to create a unnamed file-mapping object -=and with PAGE_READWRITE protection diff --git a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/test4/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/test4/CMakeLists.txt deleted file mode 100644 index 955678e45..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/test4/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - CreateFileMappingW.cpp -) - -add_executable(paltest_createfilemappingw_test4 - ${SOURCES} -) - -add_dependencies(paltest_createfilemappingw_test4 coreclrpal) - -target_link_libraries(paltest_createfilemappingw_test4 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/test4/CreateFileMappingW.cpp b/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/test4/CreateFileMappingW.cpp deleted file mode 100644 index 265a317b2..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/test4/CreateFileMappingW.cpp +++ /dev/null @@ -1,182 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: createfilemappingw.c (test 4) -** -** Purpose: Positive test the CreateFileMappingW API. -** Call CreateFileMappingW with access PAGE_WRITECOPY. -** -** -**============================================================*/ -#define UNICODE -#include - -const int MAPPINGSIZE = 2048; - -int __cdecl main(int argc, char *argv[]) -{ - - HANDLE hFile; - char buf[] = "this is a test string"; - char ch[2048]; - WCHAR lpFileName[] = {'t','e','s','t','.','t','m','p','\0'}; - HANDLE hFileMapping; - LPVOID lpMapViewAddress; - int RetVal = PASS; - int err; - DWORD dwBytesWritten; - - - /* Initialize the PAL environment. - */ - if(0 != PAL_Initialize(argc, argv)) - { - return FAIL; - } - - /* Create a file handle with CreateFile. - */ - hFile = CreateFile( lpFileName, - GENERIC_WRITE|GENERIC_READ, - FILE_SHARE_READ|FILE_SHARE_WRITE, - NULL, - CREATE_ALWAYS, - FILE_ATTRIBUTE_NORMAL, - NULL); - - if (hFile == INVALID_HANDLE_VALUE) - { - Fail("ERROR: %u :unable to create file \"%s\".\n", - GetLastError(), - lpFileName); - } - - /* Write to the File handle. - */ - err = WriteFile(hFile, - buf, - strlen(buf), - &dwBytesWritten, - NULL); - - if (err == FALSE) - { - Trace("ERROR: %u :unable to write to file handle " - "hFile=0x%lx\n", - GetLastError(), - hFile); - RetVal = FAIL; - goto CleanUpOne; - } - - /* Flush to the hard-drive. - */ - FlushFileBuffers(hFile); - - /* Initialize the buffers. - */ - memset(ch, 0, MAPPINGSIZE); - - /* Create a unnamed file-mapping object with file handle FileHandle - * and with PAGE_WRITECOPY protection. - */ - hFileMapping = CreateFileMapping( - hFile, - NULL, /*not inherited*/ - PAGE_WRITECOPY, /*write copy*/ - 0, /*high-order size*/ - 0, /*low-order size*/ - NULL); /*unnamed object*/ - - if(NULL == hFileMapping) - { - Trace("ERROR:%u: Failed to create File Mapping.\n", - GetLastError()); - RetVal = FAIL; - goto CleanUpOne; - } - - /* maps a view of a file into the address space of the calling process. - */ - lpMapViewAddress = MapViewOfFile( - hFileMapping, - FILE_MAP_COPY, /* access code */ - 0, /* high order offset*/ - 0, /* low order offset*/ - 0); /* number of bytes for map */ - - if(NULL == lpMapViewAddress) - { - Trace("ERROR:%u: Failed to call MapViewOfFile " - "API to map a view of file!\n", - GetLastError()); - RetVal = FAIL; - goto CleanUpTwo; - } - - /* Write to the Map view.3 - */ - memcpy(lpMapViewAddress, buf, strlen(buf)); - - /* Read from the Map view. - */ - memcpy(ch, (LPCSTR)lpMapViewAddress, MAPPINGSIZE); - - /* Copy the MapViewOfFile to buffer, so we can - * compare with value read from file directly. - */ - if (memcmp(ch, buf, strlen(buf))!= 0) - { - Trace("ERROR: MapViewOfFile not equal to file contents " - "retrieved \"%s\", expected \"%s\".\n", - ch, buf); - RetVal = FAIL; - goto CleanUpThree; - } - -CleanUpThree: - - /* Unmap the view of file. - */ - if ( UnmapViewOfFile(lpMapViewAddress) == FALSE ) - { - Trace("ERROR:%u: Failed to UnmapViewOfFile of \"%0x%lx\".\n", - GetLastError(), - lpMapViewAddress); - RetVal = FAIL; - } - -CleanUpTwo: - - /* Close Handle to opend file mapping. - */ - if ( CloseHandle(hFileMapping) == FALSE ) - { - Trace("ERROR:%u: Failed to CloseHandle \"0x%lx\".\n", - GetLastError(), - hFileMapping); - RetVal = FAIL; - } - -CleanUpOne: - - /* Close Handle to create file mapping. - */ - if ( CloseHandle(hFile) == FALSE ) - { - Trace("ERROR:%u: Failed to CloseHandle \"0x%lx\".\n", - GetLastError(), - hFile); - RetVal = FAIL; - } - - /* Terminate the PAL. - */ - PAL_TerminateEx(RetVal); - return RetVal; -} - - diff --git a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/test4/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/test4/testinfo.dat deleted file mode 100644 index 472b857ef..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/test4/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Filemapping_memmgt -Function = CreateFileMappingW -Name = CreateFileMappingW with PAGE_WRITECOPY. -TYPE = DEFAULT -EXE1 = createfilemappingw -Description -=Test the CreateFileMapping to create a unnamed file-mapping object -=and with PAGE_WRITE protection diff --git a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/test5/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/test5/CMakeLists.txt deleted file mode 100644 index 6201940df..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/test5/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - CreateFileMappingW.cpp -) - -add_executable(paltest_createfilemappingw_test5 - ${SOURCES} -) - -add_dependencies(paltest_createfilemappingw_test5 coreclrpal) - -target_link_libraries(paltest_createfilemappingw_test5 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/test5/CreateFileMappingW.cpp b/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/test5/CreateFileMappingW.cpp deleted file mode 100644 index 21bf7c6d7..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/test5/CreateFileMappingW.cpp +++ /dev/null @@ -1,194 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: createfilemappingw.c (test 5) -** -** Purpose: Positive test the CreateFileMappingW API. -** Test CreateFileMappingW to a "swap" handle with -** access PAGE_READONLY. -** -** -**============================================================*/ -#define UNICODE -#include - -const int MAPPINGSIZE = 2048; -HANDLE SWAP_HANDLE = ((VOID *)(-1)); - -int __cdecl main(int argc, char *argv[]) -{ - char testString[] = "this is a test string"; - WCHAR lpObjectName[] = {'m','y','O','b','j','e','c','t','\0'}; - int RetVal = FAIL; - char results[2048]; - - HANDLE hFileMapRO; - HANDLE hFileMapRW; - LPVOID lpMapViewRO; - LPVOID lpMapViewRW; - - /* Initialize the PAL environment. - */ - if(0 != PAL_Initialize(argc, argv)) - { - return FAIL; - } - - /* Initialize the buffers. - */ - memset(results, 0, MAPPINGSIZE); - - /* Create a named file-mapping object with file handle FileHandle - * and with PAGE_READWRITE protection. - */ - hFileMapRW = CreateFileMapping( - SWAP_HANDLE, - NULL, /*not inherited*/ - PAGE_READWRITE, /*read only*/ - 0, /*high-order size*/ - MAPPINGSIZE, /*low-order size*/ - lpObjectName); /*named object*/ - - if(NULL == hFileMapRW) - { - Fail("ERROR:%u: Failed to create File Mapping.\n", - GetLastError()); - } - - /* maps a view of a file into the address space of the calling process. - */ - lpMapViewRW = MapViewOfFile( - hFileMapRW, - FILE_MAP_ALL_ACCESS, /* access code */ - 0, /* high order offset*/ - 0, /* low order offset*/ - MAPPINGSIZE); /* number of bytes for map */ - - if(NULL == lpMapViewRW) - { - Trace("ERROR:%u: Failed to call MapViewOfFile " - "API to map a view of file!\n", - GetLastError()); - RetVal = FAIL; - goto CleanUpOne; - } - - - hFileMapRO = CreateFileMapping( - SWAP_HANDLE, - NULL, /*not inherited*/ - PAGE_READONLY, /*read and write*/ - 0, /*high-order size*/ - MAPPINGSIZE, /*low-order size*/ - lpObjectName); /*named object*/ - - if(NULL == hFileMapRO) - { - Trace("ERROR:%u: Failed to create File Mapping.\n", - GetLastError()); - RetVal = FAIL; - goto CleanUpTwo; - } - - /* maps a view of a file into the address space of the calling process. - */ - lpMapViewRO = MapViewOfFile( - hFileMapRO, - FILE_MAP_READ, /* access code */ - 0, /* high order offset*/ - 0, /* low order offset*/ - MAPPINGSIZE); /* number of bytes for map */ - - if(NULL == lpMapViewRO) - { - Trace("ERROR:%u: Failed to call MapViewOfFile " - "API to map a view of file!\n", - GetLastError()); - RetVal = FAIL; - goto CleanUpThree; - } - - /* Write the test string to the Map view. - */ - memcpy(lpMapViewRW, testString, strlen(testString)); - - /* Read from the second Map view. - */ - memcpy(results, (LPCSTR)lpMapViewRO, MAPPINGSIZE); - - /* Verify the contents of the file mapping, - * by comparing what was written to what was read. - */ - if (memcmp(results, testString, strlen(testString))!= 0) - { - Trace("ERROR: MapViewOfFile not equal to file contents " - "retrieved \"%s\", expected \"%s\".\n", - results, - testString); - RetVal = FAIL; - goto CleanUpFour; - } - - /* Test was successful. - */ - RetVal = PASS; - -CleanUpFour: - - /* Unmap the view of file. - */ - if ( UnmapViewOfFile(lpMapViewRO) == FALSE ) - { - Trace("ERROR:%u: Failed to UnmapViewOfFile of \"%0x%lx\".\n", - GetLastError(), - lpMapViewRO); - RetVal = FAIL; - } - -CleanUpThree: - - /* Close Handle to opend file mapping. - */ - if ( CloseHandle(hFileMapRO) == FALSE ) - { - Trace("ERROR:%u: Failed to CloseHandle \"0x%lx\".\n", - GetLastError(), - hFileMapRO); - RetVal = FAIL; - } - - -CleanUpTwo: - /* Unmap the view of file. - */ - if ( UnmapViewOfFile(lpMapViewRW) == FALSE ) - { - Trace("ERROR:%u: Failed to UnmapViewOfFile of \"%0x%lx\".\n", - GetLastError(), - lpMapViewRW); - RetVal = FAIL; - } - - -CleanUpOne: - - /* Close Handle to opend file mapping. - */ - if ( CloseHandle(hFileMapRW) == FALSE ) - { - Trace("ERROR:%u: Failed to CloseHandle \"0x%lx\".\n", - GetLastError(), - hFileMapRW); - RetVal = FAIL; - } - - - /* Terminate the PAL. - */ - PAL_TerminateEx(RetVal); - return RetVal; -} - diff --git a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/test5/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/test5/testinfo.dat deleted file mode 100644 index 87e16d3d7..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/test5/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Filemapping_memmgt -Function = CreateFileMappingW -Name = CreateFileMappingW - PAGE_READWRITE -TYPE = DEFAULT -EXE1 = createfilemappingw -Description -= Positive test the CreateFileMappingW API. -= Test CreateFileMappingW to create a named -= "swap" handle with access PAGE_READONLY. diff --git a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/test6/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/test6/CMakeLists.txt deleted file mode 100644 index 4f8d83868..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/test6/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - CreateFileMappingW.cpp -) - -add_executable(paltest_createfilemappingw_test6 - ${SOURCES} -) - -add_dependencies(paltest_createfilemappingw_test6 coreclrpal) - -target_link_libraries(paltest_createfilemappingw_test6 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/test6/CreateFileMappingW.cpp b/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/test6/CreateFileMappingW.cpp deleted file mode 100644 index acf3ac6df..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/test6/CreateFileMappingW.cpp +++ /dev/null @@ -1,165 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: createfilemappingw.c (test 6) -** -** Purpose: Positive test the CreateFileMappingW API. -** Test CreateFileMappingW to a "swap" handle with -** access PAGE_READWRITE. -** -** -**============================================================*/ -#define UNICODE -#include - -const int MAPPINGSIZE = 2048; -HANDLE SWAP_HANDLE = ((VOID *)(-1)); - -int __cdecl main(int argc, char *argv[]) -{ - char testString[] = "this is a test string"; - WCHAR lpObjectName[] = {'m','y','O','b','j','e','c','t','\0'}; - char results[2048]; - int RetVal = PASS; - - HANDLE hFileMapRW; - LPVOID lpMapViewRW; - LPVOID lpMapViewRW2; - - /* Initialize the PAL environment. - */ - if(0 != PAL_Initialize(argc, argv)) - { - return FAIL; - } - - /* Initialize the buffers. - */ - memset(results, 0, MAPPINGSIZE); - - /* Create a named file-mapping object with file handle FileHandle - * and with PAGE_READWRITE protection. - */ - hFileMapRW = CreateFileMapping( - SWAP_HANDLE, - NULL, /*not inherited*/ - PAGE_READWRITE, /*read write*/ - 0, /*high-order size*/ - MAPPINGSIZE, /*low-order size*/ - lpObjectName); /*named object*/ - - if(NULL == hFileMapRW) - { - Fail("ERROR:%u: Failed to create File Mapping.\n", - GetLastError()); - } - - /* Create a map view of the READWRITE file mapping. - */ - lpMapViewRW = MapViewOfFile( - hFileMapRW, - FILE_MAP_ALL_ACCESS,/* access code */ - 0, /* high order offset*/ - 0, /* low order offset*/ - MAPPINGSIZE); /* number of bytes for map */ - - if(NULL == lpMapViewRW) - { - Trace("ERROR:%u: Failed to call MapViewOfFile " - "API to map a view of file!\n", - GetLastError()); - RetVal = FAIL; - goto CleanUpOne; - } - - - /* maps a view of a file into the address space of the calling process. - */ - lpMapViewRW2 = MapViewOfFile( - hFileMapRW, - FILE_MAP_ALL_ACCESS, /* access code */ - 0, /* high order offset*/ - 0, /* low order offset*/ - MAPPINGSIZE); /* number of bytes for map */ - - if(NULL == lpMapViewRW2) - { - Trace("ERROR:%u: Failed to call MapViewOfFile " - "API to map a view of file!\n", - GetLastError()); - RetVal = FAIL; - goto CleanUpTwo; - } - - /* Write the test string to the Map view. - */ - memcpy(lpMapViewRW, testString, strlen(testString)); - - /* Read from the second Map view. - */ - memcpy(results, (LPCSTR)lpMapViewRW2, MAPPINGSIZE); - - /* Verify the contents of the file mapping, - * by comparing what was written to what was read. - */ - if (memcmp(results, testString, strlen(testString))!= 0) - { - Trace("ERROR: MapViewOfFile not equal to file contents " - "retrieved \"%s\", expected \"%s\".\n", - results, - testString); - RetVal = FAIL; - goto CleanUpThree; - } - - /* Test successful. - */ - RetVal = PASS; - -CleanUpThree: - - /* Unmap the view of file. - */ - if ( UnmapViewOfFile(lpMapViewRW2) == FALSE ) - { - Trace("ERROR:%u: Failed to UnmapViewOfFile of \"%0x%lx\".\n", - GetLastError(), - lpMapViewRW2); - RetVal = FAIL; - } - -CleanUpTwo: - - /* Unmap the view of file. - */ - if ( UnmapViewOfFile(lpMapViewRW) == FALSE ) - { - Trace("ERROR:%u: Failed to UnmapViewOfFile of \"%0x%lx\".\n", - GetLastError(), - lpMapViewRW); - RetVal = FAIL; - } - - -CleanUpOne: - - /* Close Handle to create file mapping. - */ - if ( CloseHandle(hFileMapRW) == FALSE ) - { - Trace("ERROR:%u: Failed to CloseHandle \"0x%lx\".\n", - GetLastError(), - hFileMapRW); - RetVal = FAIL; - } - - - /* Terminate the PAL. - */ - PAL_TerminateEx(RetVal); - return RetVal; -} - diff --git a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/test6/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/test6/testinfo.dat deleted file mode 100644 index 7afae68f1..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/test6/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Filemapping_memmgt -Function = CreateFileMapping -Name = CreateFileMappingA - with PAGE_READONLY -TYPE = DEFAULT -EXE1 = createfilemappingw -Description -= Positive test the CreateFileMappingW API. -= Test CreateFileMappingW to create a named -= "swap" handle with access PAGE_READWRITE. diff --git a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/test7/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/test7/CMakeLists.txt deleted file mode 100644 index 154f75572..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/test7/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - createfilemapping.cpp -) - -add_executable(paltest_createfilemappingw_test7 - ${SOURCES} -) - -add_dependencies(paltest_createfilemappingw_test7 coreclrpal) - -target_link_libraries(paltest_createfilemappingw_test7 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/test7/createfilemapping.cpp b/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/test7/createfilemapping.cpp deleted file mode 100644 index e49b9f688..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/test7/createfilemapping.cpp +++ /dev/null @@ -1,165 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: createfilemappingw.c (test 7) -** -** Purpose: Positive test the CreateFileMappingW API. -** Test CreateFileMappingW to a "swap" handle with -** access PAGE_READWRITE. -** -** -**============================================================*/ -#define UNICODE -#include - -const int MAPPINGSIZE = 2048; -HANDLE SWAP_HANDLE = ((VOID *)(-1)); - -int __cdecl main(int argc, char *argv[]) -{ - char testString[] = "this is a test string"; - WCHAR lpObjectName[] = {'m','y','O','b','j','e','c','t','\0'}; - char results[2048]; - int RetVal = PASS; - - HANDLE hFileMapRW; - LPVOID lpMapViewRW; - LPVOID lpMapViewRO; - - /* Initialize the PAL environment. - */ - if(0 != PAL_Initialize(argc, argv)) - { - return FAIL; - } - - /* Initialize the buffers. - */ - memset(results, 0, MAPPINGSIZE); - - /* Create a named file-mapping object with file handle FileHandle - * and with PAGE_READWRITE protection. - */ - hFileMapRW = CreateFileMapping( - SWAP_HANDLE, - NULL, /*not inherited*/ - PAGE_READWRITE, /*read write*/ - 0, /*high-order size*/ - MAPPINGSIZE, /*low-order size*/ - lpObjectName); /*unnamed object*/ - - if(NULL == hFileMapRW) - { - Fail("ERROR:%u: Failed to create File Mapping.\n", - GetLastError()); - } - - /* Create a map view to the READWRITE file mapping. - */ - lpMapViewRW = MapViewOfFile( - hFileMapRW, - FILE_MAP_ALL_ACCESS,/* access code */ - 0, /* high order offset*/ - 0, /* low order offset*/ - MAPPINGSIZE); /* number of bytes for map */ - - if(NULL == lpMapViewRW) - { - Trace("ERROR:%u: Failed to call MapViewOfFile " - "API to map a view of file!\n", - GetLastError()); - RetVal = FAIL; - goto CleanUpOne; - } - - - /* Create a map view to the READWRITE file mapping. - */ - lpMapViewRO = MapViewOfFile( - hFileMapRW, - FILE_MAP_READ, /* access code */ - 0, /* high order offset*/ - 0, /* low order offset*/ - MAPPINGSIZE); /* number of bytes for map */ - - if(NULL == lpMapViewRO) - { - Trace("ERROR:%u: Failed to call MapViewOfFile " - "API to map a view of file!\n", - GetLastError()); - RetVal = FAIL; - goto CleanUpTwo; - } - - /* Write the test string to the Map view. - */ - memcpy(lpMapViewRW, testString, strlen(testString)); - - /* Read from the second Map view. - */ - memcpy(results, (LPCSTR)lpMapViewRO, MAPPINGSIZE); - - /* Verify the contents of the file mapping, - * by comparing what was written to what was read. - */ - if (memcmp(results, testString, strlen(testString))!= 0) - { - Trace("ERROR: MapViewOfFile not equal to file contents " - "retrieved \"%s\", expected \"%s\".\n", - results, - testString); - RetVal = FAIL; - goto CleanUpThree; - } - - /* Test successful. - */ - RetVal = PASS; - -CleanUpThree: - - /* Unmap the view of file. - */ - if ( UnmapViewOfFile(lpMapViewRO) == FALSE ) - { - Trace("ERROR:%u: Failed to UnmapViewOfFile of \"%0x%lx\".\n", - GetLastError(), - lpMapViewRO); - RetVal = FAIL; - } - -CleanUpTwo: - - /* Unmap the view of file. - */ - if ( UnmapViewOfFile(lpMapViewRW) == FALSE ) - { - Trace("ERROR:%u: Failed to UnmapViewOfFile of \"%0x%lx\".\n", - GetLastError(), - lpMapViewRW); - RetVal = FAIL; - } - - -CleanUpOne: - - /* Close Handle to create file mapping. - */ - if ( CloseHandle(hFileMapRW) == FALSE ) - { - Trace("ERROR:%u: Failed to CloseHandle \"0x%lx\".\n", - GetLastError(), - hFileMapRW); - RetVal = FAIL; - } - - - /* Terminate the PAL. - */ - PAL_TerminateEx(RetVal); - return RetVal; -} - diff --git a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/test7/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/test7/testinfo.dat deleted file mode 100644 index a68a665d7..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/test7/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Filemapping_memmgt -Function = CreateFileMappingW -Name = CreateFileMappingW - PAGE_COPYWRITE -TYPE = DEFAULT -EXE1 = createfilemapping -Description -= Positive test the CreateFileMappingW API. -= Test CreateFileMappingW to create a named -= "swap" handle with access PAGE_READWRITE diff --git a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/test8/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/test8/CMakeLists.txt deleted file mode 100644 index bb9e1cedc..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/test8/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - createfilemapping.cpp -) - -add_executable(paltest_createfilemappingw_test8 - ${SOURCES} -) - -add_dependencies(paltest_createfilemappingw_test8 coreclrpal) - -target_link_libraries(paltest_createfilemappingw_test8 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/test8/createfilemapping.cpp b/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/test8/createfilemapping.cpp deleted file mode 100644 index 1ff137d8d..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/test8/createfilemapping.cpp +++ /dev/null @@ -1,82 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: createfilemappingw.c (test 8) -** -** Purpose: Positive test the CreateFileMappingW API. -** Test the un-verifiable parameter combinations. -** -** -**============================================================*/ -#define UNICODE -#include - -const int MAPPINGSIZE = 2048; -HANDLE SWAP_HANDLE = ((VOID *)(-1)); - -int __cdecl main(int argc, char *argv[]) -{ - WCHAR lpObjectName[] = {'m','y','O','b','j','e','c','t','\0'}; - - HANDLE hFileMap; - - /* Initialize the PAL environment. - */ - if(0 != PAL_Initialize(argc, argv)) - { - return FAIL; - } - - /* Create a READONLY, "swap", un-named file mapping. - * This test is unverifiable since there is no hook back to the file map - * because it is un-named. As well, since it resides in "swap", and is - * initialized to zero, there is nothing to read. - */ - hFileMap = CreateFileMapping( - SWAP_HANDLE, - NULL, /*not inherited*/ - PAGE_READONLY, /*read only*/ - 0, /*high-order size*/ - MAPPINGSIZE, /*low-order size*/ - NULL); /*un-named object*/ - - if(NULL == hFileMap) - { - Fail("ERROR:%u: Failed to create File Mapping.\n", - GetLastError()); - } - - - /* Create a COPYWRITE, "swap", un-named file mapping. - * This test is unverifiable, here is a quote from MSDN: - * - * Copy on write access. If you create the map with PAGE_WRITECOPY and - * the view with FILE_MAP_COPY, you will receive a view to file. If you - * write to it, the pages are automatically swappable and the modifications - * you make will not go to the original data file. - * - */ - hFileMap = CreateFileMapping( - SWAP_HANDLE, - NULL, /*not inherited*/ - PAGE_WRITECOPY, /*write copy*/ - 0, /*high-order size*/ - MAPPINGSIZE, /*low-order size*/ - NULL); /*unnamed object*/ - - if(NULL == hFileMap) - { - Fail("ERROR:%u: Failed to create File Mapping.\n", - GetLastError()); - } - - - /* Terminate the PAL. - */ - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/test8/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/test8/testinfo.dat deleted file mode 100644 index 475d827af..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/test8/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Filemapping_memmgt -Function = CreateFileMappingW - Special cases -Name = CreateFileMappingW -TYPE = DEFAULT -EXE1 = createfilemapping -Description -= Positive test the CreateFileMappingW API. -= Test the un-verifiable parameter combinations. diff --git a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/test9/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/test9/CMakeLists.txt deleted file mode 100644 index 241e9f02b..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/test9/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - createfilemapping.cpp -) - -add_executable(paltest_createfilemappingw_test9 - ${SOURCES} -) - -add_dependencies(paltest_createfilemappingw_test9 coreclrpal) - -target_link_libraries(paltest_createfilemappingw_test9 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/test9/createfilemapping.cpp b/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/test9/createfilemapping.cpp deleted file mode 100644 index 16ae74c12..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/test9/createfilemapping.cpp +++ /dev/null @@ -1,151 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: createfilemapping.c (test 9) -** -** Purpose: Negative test the CreateFileMappingW API. -** -** -**============================================================*/ -#define UNICODE -#include - -const int MAPPINGSIZE = 2048; - -int __cdecl main(int argc, char *argv[]) -{ - - HANDLE hFile; - WCHAR lpFileName[] = {'t','e','s','t','.','t','m','p','\0'}; - - HANDLE hFileMapping; - - /* Initialize the PAL environment. - */ - if(0 != PAL_Initialize(argc, argv)) - { - return FAIL; - } - - /* Create a file handle with CreateFile, as READONLY - */ - hFile = CreateFile( lpFileName, - GENERIC_READ, - FILE_SHARE_READ, - NULL, - CREATE_ALWAYS, - FILE_ATTRIBUTE_NORMAL, - NULL); - - if (hFile == INVALID_HANDLE_VALUE) - { - Fail("ERROR: %u :unable to create file \"%s\".\n", - GetLastError(), - lpFileName); - } - - /* Attempt to create a unnamed file-mapping object to a READONLY file - * as READWRITE access. - */ - hFileMapping = CreateFileMapping( - hFile, - NULL, /*not inherited*/ - PAGE_READWRITE, /*read and write*/ - 0, /*high-order size*/ - MAPPINGSIZE, /*low-order size*/ - NULL); /*unnamed object*/ - - if(NULL != hFileMapping) - { - Trace("ERROR: Able to create READWRITE mapping to a " - "READONLY file.\n" ); - if( 0 == CloseHandle(hFile) ) - { - Trace("Unexpected Error: Unable to close file handle\n"); - } - Fail(""); - } - - /* Attempt to create a unnamed file-mapping object to a zero lenght - * file. - */ - hFileMapping = CreateFileMapping( - hFile, - NULL, /*not inherited*/ - PAGE_READWRITE, /*read and write*/ - 0, /*high-order size*/ - 0, /*low-order size*/ - NULL); /*unnamed object*/ - - if( NULL != hFileMapping ) - { - Trace("ERROR: Able to create READWRITE mapping to a " - "READONLY file.\n" ); - if( 0 == CloseHandle(hFile) ) - { - Trace("Unexpected Error: Unable to close file handle\n"); - } - Fail(""); - } - if(GetLastError() != ERROR_ACCESS_DENIED) - { - Trace("ERROR: Expected GetLastError() to return " - "ERROR_FILE_INVALID (%d), it returned %u.\n", - ERROR_FILE_INVALID, - GetLastError()); - if( 0 == CloseHandle(hFile) ) - { - Trace("Unexpected Error: Unable to close file handle\n"); - } - Fail(""); - } - - /* Attempt to create a file mapping that is larger than - * the file. - */ - hFileMapping = CreateFileMapping( - hFile, - NULL, /*not inherited*/ - PAGE_READONLY, /*read only*/ - 0, /*high-order size*/ - MAPPINGSIZE, /*low-order size*/ - NULL); /*unnamed object*/ - if(NULL != hFileMapping) - { - Trace("ERROR: Able to create file mapping of size %d to " - "file of size 0.\n", - MAPPINGSIZE); - if( 0 == CloseHandle(hFile) ) - { - Trace("Unexpected Error: Unable to close file handle\n"); - } - Fail(""); - } - - if(GetLastError() != ERROR_NOT_ENOUGH_MEMORY ) - { - Trace("ERROR: Expected GetLastError() to return " - "ERROR_NOT_ENOUGH_MEMORY (%d), it returned %u.\n", - ERROR_NOT_ENOUGH_MEMORY, - GetLastError()); - if( 0 == CloseHandle(hFile) ) - { - Trace("Unexpected Error: Unable to close file handle\n"); - } - Fail(""); - } - - if( 0 == CloseHandle(hFile) ) - { - Fail("Unexpected Error: Unable to close file handle\n"); - } - - /* Terminate the PAL. - */ - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/test9/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/test9/testinfo.dat deleted file mode 100644 index 2a7ecdbab..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/test9/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Filemapping_memmgt -Function = CreateFileMappingW -Name = CreateFileMappingW negative testing -TYPE = DEFAULT -EXE1 = createfilemapping -Description -= Negative test the CreateFileMapping API. diff --git a/src/pal/tests/palsuite/filemapping_memmgt/FreeLibrary/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/FreeLibrary/CMakeLists.txt deleted file mode 100644 index ef14ea535..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/FreeLibrary/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) - diff --git a/src/pal/tests/palsuite/filemapping_memmgt/FreeLibrary/test1/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/FreeLibrary/test1/CMakeLists.txt deleted file mode 100644 index 4a8b6daeb..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/FreeLibrary/test1/CMakeLists.txt +++ /dev/null @@ -1,18 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - dlltest.cpp - FreeLibrary.cpp -) - -add_executable(paltest_freelibrary_test1 - ${SOURCES} -) - -add_dependencies(paltest_freelibrary_test1 coreclrpal) - -target_link_libraries(paltest_freelibrary_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/FreeLibrary/test1/FreeLibrary.cpp b/src/pal/tests/palsuite/filemapping_memmgt/FreeLibrary/test1/FreeLibrary.cpp deleted file mode 100644 index a06a23158..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/FreeLibrary/test1/FreeLibrary.cpp +++ /dev/null @@ -1,128 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: -** -** Purpose: Positive test the FreeLibrary API. -** -** -**============================================================*/ -#include - -/*char LibraryName[] = "dlltest";*/ -/* SHLEXT is defined only for Unix variants */ - -#if defined(SHLEXT) -#define LibraryName "dlltest"SHLEXT -#else -#define LibraryName "dlltest" -#endif - - - - -BOOL PALAPI TestDll(HMODULE, int); - -int __cdecl main(int argc, char *argv[]) -{ - HANDLE hLib; - - /* Initialize the PAL. */ - if ((PAL_Initialize(argc, argv)) != 0) - { - return (FAIL); - } - - /*Load library (DLL). */ - hLib = LoadLibrary(LibraryName); - - if(hLib == NULL) - { - Fail("ERROR:%u:Unable to load library %s\n", - GetLastError(), - LibraryName); - } - - /* Test access to DLL. */ - if(!TestDll(hLib, PASS)) - { - Trace("ERROR: TestDll function returned FALSE " - "expected TRUE\n."); - FreeLibrary(hLib); - Fail(""); - } - - /* Call the FreeLibrary API. */ - if (!FreeLibrary(hLib)) - { - Fail("ERROR:%u: Unable to free library \"%s\"\n", - GetLastError(), - LibraryName); - } - - /* Test access to the free'd DLL. */ - if(!TestDll(hLib, FAIL)) - { - Fail("ERROR: TestDll function returned FALSE " - "expected TRUE\n."); - } - - PAL_Terminate(); - return PASS; - -} - - -BOOL PALAPI TestDll(HMODULE hLib, int testResult) -{ - int RetVal; -#if WIN32 - char FunctName[] = "_DllTest@0"; -#else - char FunctName[] = "DllTest"; -#endif - FARPROC DllAddr; - - /* Attempt to grab the proc address of the dll function. - * This one should succeed.*/ - if(testResult == PASS) - { - DllAddr = GetProcAddress(hLib, FunctName); - if(DllAddr == NULL) - { - Trace("ERROR: Unable to load function \"%s\" library \"%s\"\n", - FunctName, - LibraryName); - return (FALSE); - } - /* Run the function in the DLL, - * to ensure that the DLL was loaded properly.*/ - RetVal = DllAddr(); - if (RetVal != 1) - { - Trace("ERROR: Unable to receive correct information from DLL! " - ":expected \"1\", returned \"%d\"\n", - RetVal); - return (FALSE); - } - } - - /* Attempt to grab the proc address of the dll function. - * This one should fail.*/ - if(testResult == FAIL) - { - DllAddr = GetProcAddress(hLib, FunctName); - if(DllAddr != NULL) - { - Trace("ERROR: Able to load function \"%s\" from free'd" - " library \"%s\"\n", - FunctName, - LibraryName); - return (FALSE); - } - } - return (TRUE); -} diff --git a/src/pal/tests/palsuite/filemapping_memmgt/FreeLibrary/test1/dlltest.cpp b/src/pal/tests/palsuite/filemapping_memmgt/FreeLibrary/test1/dlltest.cpp deleted file mode 100644 index 3e6cff292..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/FreeLibrary/test1/dlltest.cpp +++ /dev/null @@ -1,32 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: dlltest.c (FreeLibrary test dll) -** -** Purpose: This file will be used to create the shared library -** that will be used in the FreeLibraryAndExitThread -** test. A very simple shared library, with one function -** "DllTest" which merely returns 1. -** -** -**===================================================================*/ -#include "pal.h" - -#if WIN32 -__declspec(dllexport) -#endif - -int PALAPI DllTest() -{ - return 1; -} - -#ifdef WIN32 -int PALAPI _DllMainCRTStartup(void *hinstDLL, int reason, void * lpvReserved) -{ - return 1; -} -#endif diff --git a/src/pal/tests/palsuite/filemapping_memmgt/FreeLibrary/test1/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/FreeLibrary/test1/testinfo.dat deleted file mode 100644 index a09d21428..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/FreeLibrary/test1/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Filemapping_memmgt -Function = FreeLibrary -Name = Positive test for FreeLibrary API -TYPE = DEFAULT -EXE1 = freelibrary -LIB1 = dlltest -Description -=Test the FreeLibrary to decrement the reference -=count of the loaded DLL diff --git a/src/pal/tests/palsuite/filemapping_memmgt/FreeLibrary/test2/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/FreeLibrary/test2/CMakeLists.txt deleted file mode 100644 index aa57e0926..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/FreeLibrary/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test2.cpp -) - -add_executable(paltest_freelibrary_test2 - ${SOURCES} -) - -add_dependencies(paltest_freelibrary_test2 coreclrpal) - -target_link_libraries(paltest_freelibrary_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/FreeLibrary/test2/test2.cpp b/src/pal/tests/palsuite/filemapping_memmgt/FreeLibrary/test2/test2.cpp deleted file mode 100644 index b43f74d6b..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/FreeLibrary/test2/test2.cpp +++ /dev/null @@ -1,52 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test2.c (FreeLibrary) -** -** Purpose: Tests the PAL implementation of the FreeLibrary function. -** This is a negative test that will pass an invalid and a -** null handle to FreeLibrary. -** -** -**===================================================================*/ - -#include - -int __cdecl main(int argc, char* argv[]) -{ - HANDLE hLib; - - /* Initialize the PAL. - */ - if ((PAL_Initialize(argc, argv)) != 0) - { - return (FAIL); - } - - /* Attempt to pass FreeLibrary an invalid handle. - */ - hLib = INVALID_HANDLE_VALUE; - if (FreeLibrary(hLib)) - { - Fail("ERROR: Able to free library handle = \"0x%lx\".\n", - hLib); - } - - /* Attempt to pass FreeLibrary a NULL handle. - */ - hLib = NULL; - if (FreeLibrary(hLib)) - { - Fail("ERROR: Able to free library handle = \"NULL\".\n"); - } - - - /* Terminate the PAL. - */ - PAL_Terminate(); - return PASS; - -} diff --git a/src/pal/tests/palsuite/filemapping_memmgt/FreeLibrary/test2/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/FreeLibrary/test2/testinfo.dat deleted file mode 100644 index 521fa6eae..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/FreeLibrary/test2/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Filemapping_memmgt -Function = FreeLibrary -Name = Negative test for FreeLibrary -TYPE = DEFAULT -EXE1 = test2 -Description -= Tests the PAL implementation of the FreeLibrary function. -= This is a negative test that will pass an invalid and a -= null handle to FreeLibrary. diff --git a/src/pal/tests/palsuite/filemapping_memmgt/FreeLibraryAndExitThread/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/FreeLibraryAndExitThread/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/FreeLibraryAndExitThread/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/filemapping_memmgt/FreeLibraryAndExitThread/test1/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/FreeLibraryAndExitThread/test1/CMakeLists.txt deleted file mode 100644 index 338aaf774..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/FreeLibraryAndExitThread/test1/CMakeLists.txt +++ /dev/null @@ -1,18 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - dlltest.cpp - test1.cpp -) - -add_executable(paltest_freelibraryandexitthread_test1 - ${SOURCES} -) - -add_dependencies(paltest_freelibraryandexitthread_test1 coreclrpal) - -target_link_libraries(paltest_freelibraryandexitthread_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/FreeLibraryAndExitThread/test1/dlltest.cpp b/src/pal/tests/palsuite/filemapping_memmgt/FreeLibraryAndExitThread/test1/dlltest.cpp deleted file mode 100644 index e66a9ebdb..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/FreeLibraryAndExitThread/test1/dlltest.cpp +++ /dev/null @@ -1,32 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: dlltest.c (FreeLibraryAndExitThread test dll) -** -** Purpose: This file will be used to create the shared library -** that will be used in the FreeLibraryAndExitThread -** test. A very simple shared library, with one function -** "DllTest" which merely returns 1. -** -** -**===================================================================*/ -#include "pal.h" - -#if WIN32 -__declspec(dllexport) -#endif - -int PALAPI DllTest() -{ - return 1; -} - -#if WIN32 -int PALAPI _DllMainCRTStartup(void *hinstDLL, int reason, void * lpvReserved) -{ - return 1; -} -#endif diff --git a/src/pal/tests/palsuite/filemapping_memmgt/FreeLibraryAndExitThread/test1/test1.cpp b/src/pal/tests/palsuite/filemapping_memmgt/FreeLibraryAndExitThread/test1/test1.cpp deleted file mode 100644 index 58f664372..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/FreeLibraryAndExitThread/test1/test1.cpp +++ /dev/null @@ -1,183 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test1.c (FreeLibraryAndExitThread) -** -** Purpose: Tests the PAL implementation of the FreeLibraryAndExitThread -** function. FreeLibraryAndExitThread when run will exit the -** process that it is called within, therefore we create a -** thread to run the API. Then test for the existance of the -** thread and access to the library. -** -** -**===================================================================*/ - -#include - -/*Define platform specific information*/ - -/* SHLEXT is defined only for Unix variants */ -#if defined(SHLEXT) -#define LibraryName "dlltest"SHLEXT -#else -#define LibraryName "dlltest" -#endif - -#define TIMEOUT 60000 - -BOOL PALAPI StartThreadTest(); -DWORD PALAPI CreateTestThread(LPVOID); -BOOL PALAPI TestDll(HMODULE, int); - -int __cdecl main(int argc, char* argv[]) -{ - /*Initialize the PAL*/ - if ((PAL_Initialize(argc, argv)) != 0) - { - return (FAIL); - } - - if (!StartThreadTest()) - { - Fail("ERROR: FreeLibraryAndExitThread test failed.\n"); - } - - /*Terminate the PAL*/ - PAL_Terminate(); - return PASS; - -} - - -BOOL PALAPI StartThreadTest() -{ - HMODULE hLib; - HANDLE hThread; - DWORD dwThreadId; - LPTHREAD_START_ROUTINE lpStartAddress = &CreateTestThread; - LPVOID lpParameter = (LPVOID)lpStartAddress; - DWORD rc = -1; - /*Load library (DLL).*/ - hLib = LoadLibrary(LibraryName); - if(hLib == NULL) - { - Trace("ERROR: Unable to load library %s\n", LibraryName); - - return (FALSE); - } - - /*Start the test thread*/ - hThread = CreateThread(NULL, - (DWORD)0, - lpStartAddress, - hLib, - (DWORD)NULL, - &dwThreadId); - if(hThread == NULL) - { - Trace("ERROR:%u: Unable to create thread.\n", - GetLastError()); - - FreeLibrary(hLib); - return (FALSE); - } - - /*Wait on thread.*/ - rc = WaitForSingleObject(hThread, TIMEOUT); - if( rc != WAIT_OBJECT_0 ) - { - Trace("ERROR:%u: hThread=0x%4.4lx not exited by " - "FreeLibraryAndExitThread, RC[%d]\n", - GetLastError(), - hThread, rc); - -// There is a possibility that the other thread might -// still be using the library VSW:337893 -// FreeLibrary(hLib); - CloseHandle(hThread); - return (FALSE); - } - - /*Test access to DLL.*/ - if(!TestDll(hLib, 0)) - { - Trace("ERROR: TestDll function returned FALSE " - "expected TRUE\n."); - - CloseHandle(hThread); - return (FALSE); - } - - FreeLibrary(hLib); - /*Clean-up thread.*/ - CloseHandle(hThread); - - return (TRUE); -} - -BOOL PALAPI TestDll(HMODULE hLib, int testResult) -{ - int RetVal; - char FunctName[] = "DllTest"; - FARPROC DllAddr; - - /* Attempt to grab the proc address of the dll function. - * This one should succeed.*/ - if(testResult == 1) - { - DllAddr = GetProcAddress(hLib, FunctName); - if(DllAddr == NULL) - { - Trace("ERROR: Unable to load function \"%s\" library \"%s\"\n", - FunctName, - LibraryName); - return (FALSE); - } - /* Run the function in the DLL, - * to ensure that the DLL was loaded properly.*/ - RetVal = DllAddr(); - if (RetVal != 1) - { - Trace("ERROR: Unable to receive correct information from DLL! " - ":expected \"1\", returned \"%d\"\n", - RetVal); - return (FALSE); - } - } - - /* Attempt to grab the proc address of the dll function. - * This one should fail.*/ - if(testResult == 0) - { - DllAddr = GetProcAddress(hLib, FunctName); - if(DllAddr != NULL) - { - Trace("ERROR: Able to load function \"%s\" from free'd" - " library \"%s\"\n", - FunctName, - LibraryName); - return (FALSE); - } - } - return (TRUE); -} - -DWORD PALAPI CreateTestThread(LPVOID lpParam) -{ - /* Test access to DLL.*/ - TestDll(lpParam, 1); - - /*Free library and exit thread.*/ - FreeLibraryAndExitThread(lpParam, (DWORD)0); - - /* NOT REACHED */ - - /*Infinite loop, we should not get here.*/ - while(1); - - return (DWORD)0; -} - diff --git a/src/pal/tests/palsuite/filemapping_memmgt/FreeLibraryAndExitThread/test1/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/FreeLibraryAndExitThread/test1/testinfo.dat deleted file mode 100644 index 455829c0d..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/FreeLibraryAndExitThread/test1/testinfo.dat +++ /dev/null @@ -1,17 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Filemapping_memmgt -Function = FreeLibraryAndExitThread -Name = Positive test for FreeLibraryAndExitThread -TYPE = DEFAULT -EXE1 = test1 -LIB1 = dlltest -Description -= Tests the PAL implementation of the FreeLibraryAndExitThread -= function. When run, FreeLibraryAndExitThread will exit the -= process that it is called within, therefore we create a -= thread to run the API. Then we test for the existance of the -= thread and access to the library. diff --git a/src/pal/tests/palsuite/filemapping_memmgt/GetModuleFileNameA/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/GetModuleFileNameA/CMakeLists.txt deleted file mode 100644 index ef14ea535..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/GetModuleFileNameA/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) - diff --git a/src/pal/tests/palsuite/filemapping_memmgt/GetModuleFileNameA/test1/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/GetModuleFileNameA/test1/CMakeLists.txt deleted file mode 100644 index 27eaec18d..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/GetModuleFileNameA/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - GetModuleFileNameA.cpp -) - -add_executable(paltest_getmodulefilenamea_test1 - ${SOURCES} -) - -add_dependencies(paltest_getmodulefilenamea_test1 coreclrpal) - -target_link_libraries(paltest_getmodulefilenamea_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/GetModuleFileNameA/test1/GetModuleFileNameA.cpp b/src/pal/tests/palsuite/filemapping_memmgt/GetModuleFileNameA/test1/GetModuleFileNameA.cpp deleted file mode 100644 index d05f0ac6a..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/GetModuleFileNameA/test1/GetModuleFileNameA.cpp +++ /dev/null @@ -1,92 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: getmodulefilenamea.c -** -** Purpose: Positive test the GetModuleFileName API. -** Call GetModuleFileName to retrieve the specified -** module full path and file name -** -** -**============================================================*/ - -#include - -#define MODULENAMEBUFFERSIZE 1024 - -/* SHLEXT is defined only for Unix variants */ - -#if defined(SHLEXT) -#define ModuleName "librotor_pal"SHLEXT -#define Delimiter "/" -#else -#define ModuleName "rotor_pal.dll" -#define Delimiter "\\" -#endif - -int __cdecl main(int argc, char *argv[]) -{ - HMODULE ModuleHandle; - int err; - DWORD ModuleNameLength; - char ModuleFileNameBuf[MODULENAMEBUFFERSIZE]=""; - char* TempBuf = NULL; - char* LastBuf = NULL; - - //Initialize the PAL environment - err = PAL_Initialize(argc, argv); - if(0 != err) - { - ExitProcess(FAIL); - } - - - //load a module - ModuleHandle = LoadLibrary(ModuleName); - if(!ModuleHandle) - { - Fail("Failed to call LoadLibrary API!\n"); - } - - - //retrieve the specified module full path and file name - ModuleNameLength = GetModuleFileName( - ModuleHandle,//specified module handle - ModuleFileNameBuf,//buffer for module file name - MODULENAMEBUFFERSIZE); - - //strip out all full path - TempBuf = strtok(ModuleFileNameBuf,Delimiter); - LastBuf = TempBuf; - while(NULL != TempBuf) - { - LastBuf = TempBuf; - TempBuf = strtok(NULL,Delimiter); - } - - - if(0 == ModuleNameLength || strcmp(ModuleName,LastBuf)) - { - Trace("\nFailed to all GetModuleFileName API!\n"); - err = FreeLibrary(ModuleHandle); - if(0 == err) - { - Fail("\nFailed to all FreeLibrary API!\n"); - } - Fail(""); - } - - //decrement the reference count of the loaded dll - err = FreeLibrary(ModuleHandle); - if(0 == err) - { - Fail("\nFailed to all FreeLibrary API!\n"); - } - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/filemapping_memmgt/GetModuleFileNameA/test1/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/GetModuleFileNameA/test1/testinfo.dat deleted file mode 100644 index 8075e840c..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/GetModuleFileNameA/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Filemapping_memmgt -Function = GetModuleFileNameA -Name = Positive test for GetModuleFileNameA API -TYPE = DEFAULT -EXE1 = getmodulefilenamea -Description -=Test the GetModuleFileNameA to retrieve the specified module -=full path and file name diff --git a/src/pal/tests/palsuite/filemapping_memmgt/GetModuleFileNameA/test2/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/GetModuleFileNameA/test2/CMakeLists.txt deleted file mode 100644 index e908eaf00..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/GetModuleFileNameA/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - GetModuleFileNameA.cpp -) - -add_executable(paltest_getmodulefilenamea_test2 - ${SOURCES} -) - -add_dependencies(paltest_getmodulefilenamea_test2 coreclrpal) - -target_link_libraries(paltest_getmodulefilenamea_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/GetModuleFileNameA/test2/GetModuleFileNameA.cpp b/src/pal/tests/palsuite/filemapping_memmgt/GetModuleFileNameA/test2/GetModuleFileNameA.cpp deleted file mode 100644 index e8aed6d30..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/GetModuleFileNameA/test2/GetModuleFileNameA.cpp +++ /dev/null @@ -1,49 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: getmodulefilenamea.c -** -** Purpose: Positive test the GetModuleFileNameA API. -** Call GetModuleFileName to retrieve current process -** full path and file name by passing a NULL module handle -** -** -**============================================================*/ -#include - - -#define MODULENAMEBUFFERSIZE 1024 - -int __cdecl main(int argc, char *argv[]) -{ - - DWORD ModuleNameLength; - char ModuleFileNameBuf[MODULENAMEBUFFERSIZE]=""; - int err; - - //Initialize the PAL environment - err = PAL_Initialize(argc, argv); - if(0 != err) - { - ExitProcess(FAIL); - } - - - //retrieve the current process full path and file name - //by passing a NULL module handle - ModuleNameLength = GetModuleFileName( - NULL, //a NULL handle - ModuleFileNameBuf,//buffer for module file name - MODULENAMEBUFFERSIZE); - - if(0 == ModuleNameLength) - { - Fail("\nFailed to all GetModuleFileName API!\n"); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/filemapping_memmgt/GetModuleFileNameA/test2/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/GetModuleFileNameA/test2/testinfo.dat deleted file mode 100644 index 45fdca6ae..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/GetModuleFileNameA/test2/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Filemapping_memmgt -Function = GetModuleFileNameA -Name = Positive test for GetModuleFileNameA API -TYPE = DEFAULT -EXE1 = getmodulefilenamea -Description -=Test the GetModuleFileNameA to retrieve current process full -=full path and file name by passing a NULL module handle diff --git a/src/pal/tests/palsuite/filemapping_memmgt/GetModuleFileNameW/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/GetModuleFileNameW/CMakeLists.txt deleted file mode 100644 index ef14ea535..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/GetModuleFileNameW/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) - diff --git a/src/pal/tests/palsuite/filemapping_memmgt/GetModuleFileNameW/test1/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/GetModuleFileNameW/test1/CMakeLists.txt deleted file mode 100644 index 6afc44e23..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/GetModuleFileNameW/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - GetModuleFileNameW.cpp -) - -add_executable(paltest_getmodulefilenamew_test1 - ${SOURCES} -) - -add_dependencies(paltest_getmodulefilenamew_test1 coreclrpal) - -target_link_libraries(paltest_getmodulefilenamew_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/GetModuleFileNameW/test1/GetModuleFileNameW.cpp b/src/pal/tests/palsuite/filemapping_memmgt/GetModuleFileNameW/test1/GetModuleFileNameW.cpp deleted file mode 100644 index c122312d8..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/GetModuleFileNameW/test1/GetModuleFileNameW.cpp +++ /dev/null @@ -1,112 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: getmodulefilenamew.c -** -** Purpose: Test the GetModuleFileNameW to retrieve the specified module -** full path and file name in UNICODE. -** -** -**============================================================*/ -#define UNICODE -#include - -#define MODULENAMEBUFFERSIZE 1024 - -/* SHLEXT is defined only for Unix variants */ - -#if defined(SHLEXT) -#define ModuleName "librotor_pal"SHLEXT -#define Delimiter "/" -#else -#define ModuleName "rotor_pal.dll" -#define Delimiter "\\" -#endif - -int __cdecl main(int argc, char *argv[]) -{ - HMODULE ModuleHandle; - int err; - WCHAR *lpModuleName; - DWORD ModuleNameLength; - WCHAR *ModuleFileNameBuf; - char* TempBuf = NULL; - char* LastBuf = NULL; - char NewModuleFileNameBuf[MODULENAMEBUFFERSIZE+200] = ""; - - - //Initialize the PAL environment - err = PAL_Initialize(argc, argv); - if(0 != err) - { - ExitProcess(FAIL); - } - - ModuleFileNameBuf = (WCHAR*)malloc(MODULENAMEBUFFERSIZE*sizeof(WCHAR)); - - //convert a normal string to a wide one - lpModuleName = convert(ModuleName); - - //load a module - ModuleHandle = LoadLibrary(lpModuleName); - - //free the memory - free(lpModuleName); - - if(!ModuleHandle) - { - Fail("Failed to call LoadLibrary API!\n"); - } - - - //retrieve the specified module full path and file name - ModuleNameLength = GetModuleFileName( - ModuleHandle,//specified module handle - ModuleFileNameBuf,//buffer for module file name - MODULENAMEBUFFERSIZE); - - - - //convert a wide full path name to a normal one - strcpy(NewModuleFileNameBuf,convertC(ModuleFileNameBuf)); - - //strip out all full path - TempBuf = strtok(NewModuleFileNameBuf,Delimiter); - LastBuf = TempBuf; - while(NULL != TempBuf) - { - LastBuf = TempBuf; - TempBuf = strtok(NULL,Delimiter); - } - - - //free the memory - free(ModuleFileNameBuf); - - if(0 == ModuleNameLength || strcmp(ModuleName,LastBuf)) - { - Trace("\nFailed to all GetModuleFileName API!\n"); - err = FreeLibrary(ModuleHandle); - if(0 == err) - { - Fail("\nFailed to all FreeLibrary API!\n"); - } - Fail(""); - } - - - - //decrement the reference count of the loaded dll - err = FreeLibrary(ModuleHandle); - if(0 == err) - { - Fail("\nFailed to all FreeLibrary API!\n"); - } - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/filemapping_memmgt/GetModuleFileNameW/test1/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/GetModuleFileNameW/test1/testinfo.dat deleted file mode 100644 index c8d94b73b..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/GetModuleFileNameW/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Filemapping_memmgt -Function = GetModuleFileNameW -Name = Positive test for GetModuleFileNameW API -TYPE = DEFAULT -EXE1 = getmodulefilenamew -Description -=Test the GetModuleFileNameW to retrieve the specified module -=full path and file name in UNICODE diff --git a/src/pal/tests/palsuite/filemapping_memmgt/GetModuleFileNameW/test2/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/GetModuleFileNameW/test2/CMakeLists.txt deleted file mode 100644 index 50a4dd8c1..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/GetModuleFileNameW/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - GetModuleFileNameW.cpp -) - -add_executable(paltest_getmodulefilenamew_test2 - ${SOURCES} -) - -add_dependencies(paltest_getmodulefilenamew_test2 coreclrpal) - -target_link_libraries(paltest_getmodulefilenamew_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/GetModuleFileNameW/test2/GetModuleFileNameW.cpp b/src/pal/tests/palsuite/filemapping_memmgt/GetModuleFileNameW/test2/GetModuleFileNameW.cpp deleted file mode 100644 index f23d97c13..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/GetModuleFileNameW/test2/GetModuleFileNameW.cpp +++ /dev/null @@ -1,57 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: getmodulefilenamew.c -** -** Purpose: Positive test the GetModuleFileName API. -** Call GetModuleFileName to retrieve current process -** full path and file name by passing a NULL module handle -** in UNICODE -** -** -**============================================================*/ -#define UNICODE -#include - -#define MODULENAMEBUFFERSIZE 1024 - - -int __cdecl main(int argc, char *argv[]) -{ - - DWORD ModuleNameLength; - WCHAR *ModuleFileNameBuf; - int err; - - - //Initialize the PAL environment - err = PAL_Initialize(argc, argv); - if(0 != err) - { - ExitProcess(FAIL); - } - - ModuleFileNameBuf = (WCHAR*)malloc(MODULENAMEBUFFERSIZE*sizeof(WCHAR)); - - //retrieve the current process full path and file name - //by passing a NULL module handle - ModuleNameLength = GetModuleFileName( - NULL, //a NULL handle - ModuleFileNameBuf,//buffer for module file name - MODULENAMEBUFFERSIZE); - - //free the memory - free(ModuleFileNameBuf); - - if(0 == ModuleNameLength) - { - Fail("\nFailed to all GetModuleFileName API!\n"); - } - - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/filemapping_memmgt/GetModuleFileNameW/test2/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/GetModuleFileNameW/test2/testinfo.dat deleted file mode 100644 index 8b8740149..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/GetModuleFileNameW/test2/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Filemapping_memmgt -Function = GetModuleFileNameW -Name = Positive test for GetModuleFileNameW API -TYPE = DEFAULT -EXE1 = getmodulefilenamew -Description -=Test the GetModuleFileNameW to retrieve current process full -=full path and file name by passing a NULL module handle in UNICODE diff --git a/src/pal/tests/palsuite/filemapping_memmgt/GetProcAddress/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/GetProcAddress/CMakeLists.txt deleted file mode 100644 index ef14ea535..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/GetProcAddress/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) - diff --git a/src/pal/tests/palsuite/filemapping_memmgt/GetProcAddress/test1/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/GetProcAddress/test1/CMakeLists.txt deleted file mode 100644 index a9a985fb0..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/GetProcAddress/test1/CMakeLists.txt +++ /dev/null @@ -1,18 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp - testlib.cpp -) - -add_executable(paltest_getprocaddress_test1 - ${SOURCES} -) - -add_dependencies(paltest_getprocaddress_test1 coreclrpal) - -target_link_libraries(paltest_getprocaddress_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/GetProcAddress/test1/test1.cpp b/src/pal/tests/palsuite/filemapping_memmgt/GetProcAddress/test1/test1.cpp deleted file mode 100644 index 5515ae456..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/GetProcAddress/test1/test1.cpp +++ /dev/null @@ -1,111 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================= -** -** Source: test1.c (filemapping_memmgt\getprocaddress\test1) -** -** Purpose: Positive test the GetProcAddress API. -** The first test calls GetProcAddress to retrieve the -** address of SimpleFunction inside testlib by its name, -** then calls the function and checks that it worked. -** -** -**===========================================================================*/ -#include - -typedef int (PALAPI *SIMPLEFUNCTION)(int); - -/* SHLEXT is defined only for Unix variants */ -#if defined(SHLEXT) -#define lpModuleName "testlib"SHLEXT -#else -#define lpModuleName "testlib.dll" -#endif - -int __cdecl main(int argc, char *argv[]) -{ - int err; - HMODULE hModule; - SIMPLEFUNCTION procAddressByName; - -#if WIN32 - const char *FunctionName = "_SimpleFunction@4"; -#else - const char *FunctionName = "SimpleFunction"; -#endif - - /* Initialize the PAL environment. */ - if(0 != PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - /* load a module */ - hModule = LoadLibrary(lpModuleName); - if(!hModule) - { - Fail("Unexpected error: " - "LoadLibrary(%s) failed.\n", - lpModuleName); - } - - /* - * Test 1 - * - * Get the address of a function - */ - procAddressByName = (SIMPLEFUNCTION) GetProcAddress(hModule,FunctionName); - if(!procAddressByName) - { - Trace("ERROR: Unable to get address of SimpleFunction by its name. " - "GetProcAddress returned NULL with error %d\n", - GetLastError()); - - /* Cleanup */ - err = FreeLibrary(hModule); - if(0 == err) - { - Fail("Unexpected error: Failed to FreeLibrary %s\n", - lpModuleName); - } - Fail(""); - } - - /* Call the function to see that it really worked */ - /* Simple function adds 1 to the argument passed */ - if( 2 != ((procAddressByName)(1))) - { - Trace("ERROR: Problem calling the function by its address.\n"); - - /* Cleanup */ - err = FreeLibrary(hModule); - if(0 == err) - { - Fail("Unexpected error: Failed to FreeLibrary %s\n", - lpModuleName); - } - Fail(""); - } - - /* Cleanup */ - err = FreeLibrary(hModule); - if(0 == err) - { - Fail("Unexpected error: Failed to FreeLibrary %s\n", - lpModuleName); - } - - PAL_Terminate(); - return PASS; -} - - - - - - - - diff --git a/src/pal/tests/palsuite/filemapping_memmgt/GetProcAddress/test1/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/GetProcAddress/test1/testinfo.dat deleted file mode 100644 index 31b262e31..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/GetProcAddress/test1/testinfo.dat +++ /dev/null @@ -1,19 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = filemapping_memmgt -Function = getprocaddress -Name = Positive test for GetProcAddress API -TYPE = DEFAULT -EXE1 = test1 -LIB1 = testlib -Description -=Positive test the GetProcAddress API. -=The first test calls GetProcAddress to retrieve the -=address of strcpy by its name, then calls the function and -=checks that it worked. The second part of the test -=calls GetProcAddress to retrieve the address of -=strcpy by its ordinal, then calls the function and -=checks that it worked. diff --git a/src/pal/tests/palsuite/filemapping_memmgt/GetProcAddress/test1/testlib.cpp b/src/pal/tests/palsuite/filemapping_memmgt/GetProcAddress/test1/testlib.cpp deleted file mode 100644 index 7b87ba7f7..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/GetProcAddress/test1/testlib.cpp +++ /dev/null @@ -1,33 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================= -** -** Source: testlib.c (filemapping_memmgt\getprocaddress\test1) -** -** Purpose: Create a simple library containing one function -** to test GetProcAddress -** -** -**===========================================================================*/ -#include "pal.h" - -#if WIN32 -__declspec(dllexport) -#endif - -/** - * Simple function that returns i+1 - */ -int PALAPI SimpleFunction(int i) -{ - return i+1; -} - -#if WIN32 -int PALAPI _DllMainCRTStartup(void *hinstDLL, int reason, void *lpvReserved) -{ - return 1; -} -#endif diff --git a/src/pal/tests/palsuite/filemapping_memmgt/GetProcAddress/test2/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/GetProcAddress/test2/CMakeLists.txt deleted file mode 100644 index 006916125..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/GetProcAddress/test2/CMakeLists.txt +++ /dev/null @@ -1,18 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test2.cpp - testlib.cpp -) - -add_executable(paltest_getprocaddress_test2 - ${SOURCES} -) - -add_dependencies(paltest_getprocaddress_test2 coreclrpal) - -target_link_libraries(paltest_getprocaddress_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/GetProcAddress/test2/test2.cpp b/src/pal/tests/palsuite/filemapping_memmgt/GetProcAddress/test2/test2.cpp deleted file mode 100644 index 910772842..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/GetProcAddress/test2/test2.cpp +++ /dev/null @@ -1,152 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================= -** -** Source: test2.c (filemapping_memmgt\getprocaddress\test2) -** -** Purpose: This test tries to call GetProcAddress with -** a NULL handle, with a NULL function name, with an empty -** function name, with an invalid name and with an -** invalid ordinal value. -** -** -**===========================================================================*/ -#include - - -/* SHLEXT is defined only for Unix variants */ -#if defined(SHLEXT) -#define lpModuleName "testlib"SHLEXT -#else -#define lpModuleName "testlib.dll" -#endif - - -/** - * main - */ -int __cdecl main(int argc, char *argv[]) -{ - int err; - HMODULE hModule; - FARPROC procAddress; - - /* Initialize the PAL environment. */ - if(0 != PAL_Initialize(argc, argv)) - { - return FAIL; - } - - /* load a module */ - hModule = LoadLibrary(lpModuleName); - if(!hModule) - { - Fail("Unexpected error: " - "LoadLibrary(%s) failed.\n", - lpModuleName); - } - - /* - * Test 1 - * - * Call GetProcAddress with a NULL handle - */ - procAddress = GetProcAddress(NULL,"SimpleFunction"); - if(procAddress != NULL) - { - Trace("ERROR: GetProcAddress with a NULL handle " - "returned a non-NULL value when it should have " - "returned a NULL value with an error\n"); - - /* Cleanup */ - err = FreeLibrary(hModule); - if(0 == err) - { - Fail("Unexpected error: Failed to FreeLibrary %s\n", - lpModuleName); - } - Fail(""); - } - - /** - * Test 2 - * - * Call GetProcAddress with a NULL function name - */ - - procAddress = GetProcAddress(hModule,NULL); - if(procAddress != NULL) - { - Trace("ERROR: GetProcAddress with a NULL function name " - "returned a non-NULL value when it should have " - "returned a NULL value with an error\n"); - - /* Cleanup */ - err = FreeLibrary(hModule); - if(0 == err) - { - Fail("Unexpected error: Failed to FreeLibrary %s\n", - lpModuleName); - } - Fail(""); - } - - /** - * Test 3 - * - * Call GetProcAddress with an empty function name string - */ - - procAddress = GetProcAddress(hModule,""); - if(procAddress != NULL) - { - Trace("ERROR: GetProcAddress with an empty function name " - "returned a non-NULL value when it should have " - "returned a NULL value with an error\n"); - - /* Cleanup */ - err = FreeLibrary(hModule); - if(0 == err) - { - Fail("Unexpected error: Failed to FreeLibrary %s\n", - lpModuleName); - } - Fail(""); - } - - /** - * Test 4 - * - * Call GetProcAddress with an invalid name - */ - - procAddress = GetProcAddress(hModule,"Simple Function"); - if(procAddress != NULL) - { - Trace("ERROR: GetProcAddress with an invalid function name " - "returned a non-NULL value when it should have " - "returned a NULL value with an error\n"); - - /* Cleanup */ - err = FreeLibrary(hModule); - if(0 == err) - { - Fail("Unexpected error: Failed to FreeLibrary %s\n", - lpModuleName); - } - Fail(""); - } - - /* cleanup */ - err = FreeLibrary(hModule); - if(0 == err) - { - Fail("Unexpected error: Failed to FreeLibrary %s\n", - lpModuleName); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/filemapping_memmgt/GetProcAddress/test2/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/GetProcAddress/test2/testinfo.dat deleted file mode 100644 index 8bf50ad81..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/GetProcAddress/test2/testinfo.dat +++ /dev/null @@ -1,18 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = filemapping_memmgt -Function = getprocaddress -Name = Negative test for GetProcAddress API -TYPE = DEFAULT -EXE1 = test2 -LIB1 = testlib -Description -=This test tries to call GetProcAddress with -=a NULL handle, with a NULL function name, with an empty -=function name, with an invalid name and with an -=nvalid ordinal value. - - diff --git a/src/pal/tests/palsuite/filemapping_memmgt/GetProcAddress/test2/testlib.cpp b/src/pal/tests/palsuite/filemapping_memmgt/GetProcAddress/test2/testlib.cpp deleted file mode 100644 index 47299a1b1..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/GetProcAddress/test2/testlib.cpp +++ /dev/null @@ -1,33 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================= -** -** Source: testlib.c (filemapping_memmgt\getprocaddress\test2) -** -** Purpose: Create a simple library containing one function -** to test GetProcAddress -** -** -**===========================================================================*/ -#include "pal.h" - -#if WIN32 -__declspec(dllexport) -#endif - -/** - * Simple function that returns i+1 - */ -int PALAPI SimpleFunction(int i) -{ - return i+1; -} - -#if WIN32 -int PALAPI _DllMainCRTStartup(void *hinstDLL, int reason, void *lpvReserved) -{ - return 1; -} -#endif diff --git a/src/pal/tests/palsuite/filemapping_memmgt/GetProcessHeap/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/GetProcessHeap/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/GetProcessHeap/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/filemapping_memmgt/GetProcessHeap/test1/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/GetProcessHeap/test1/CMakeLists.txt deleted file mode 100644 index d312ae95e..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/GetProcessHeap/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - GetProcessHeap.cpp -) - -add_executable(paltest_getprocessheap_test1 - ${SOURCES} -) - -add_dependencies(paltest_getprocessheap_test1 coreclrpal) - -target_link_libraries(paltest_getprocessheap_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/GetProcessHeap/test1/GetProcessHeap.cpp b/src/pal/tests/palsuite/filemapping_memmgt/GetProcessHeap/test1/GetProcessHeap.cpp deleted file mode 100644 index bec6b5c61..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/GetProcessHeap/test1/GetProcessHeap.cpp +++ /dev/null @@ -1,39 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: getprocheap.c -** -** Purpose: Positive test the GetProcessHeap API. -** Call GetProcessHeap to retrieve the handle of -** calling process heap -** -** -**============================================================*/ -#include - -int __cdecl main(int argc, char *argv[]) -{ - int err; - HANDLE ProcessHeapHandle; - - //Initialize the PAL environment - err = PAL_Initialize(argc, argv); - if(0 != err) - { - ExitProcess(FAIL); - } - - //Retrieve the calling process heap handle - ProcessHeapHandle = GetProcessHeap(); - - if(!ProcessHeapHandle) - { - Fail("\nFailed to call GetProcessHeap API!\n"); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/filemapping_memmgt/GetProcessHeap/test1/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/GetProcessHeap/test1/testinfo.dat deleted file mode 100644 index cec3dd12d..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/GetProcessHeap/test1/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Filemapping_memmgt -Function = GetProcessHeap -Name = Positive test for GetProcessHeap API retrieve the handle of calling process heap -TYPE = DEFAULT -EXE1 = getprocessheap -Description -=Test the GetProcessHeap to retrieve the handle of the calling process heap diff --git a/src/pal/tests/palsuite/filemapping_memmgt/HeapAlloc/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/HeapAlloc/CMakeLists.txt deleted file mode 100644 index 1962ade35..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/HeapAlloc/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) -add_subdirectory(test3) - diff --git a/src/pal/tests/palsuite/filemapping_memmgt/HeapAlloc/test1/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/HeapAlloc/test1/CMakeLists.txt deleted file mode 100644 index 69ee8bbe8..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/HeapAlloc/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - HeapAlloc.cpp -) - -add_executable(paltest_heapalloc_test1 - ${SOURCES} -) - -add_dependencies(paltest_heapalloc_test1 coreclrpal) - -target_link_libraries(paltest_heapalloc_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/HeapAlloc/test1/HeapAlloc.cpp b/src/pal/tests/palsuite/filemapping_memmgt/HeapAlloc/test1/HeapAlloc.cpp deleted file mode 100644 index 04de274e8..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/HeapAlloc/test1/HeapAlloc.cpp +++ /dev/null @@ -1,100 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: heapalloc.c -** -** Purpose: Positive test the HeapAlloc API. -** Call HeapAlloc by pssing zero as control flag -** Call HeapAlloc by passing HEAP_ZERO_MEMORY as control flag -** Call HeapAlloc to allocate one byte heap memory -** Call HeapAlloc to allocate maximum available heap memory -** -** -**============================================================*/ -#include - -#define HEAPSIZE 64 - -int __cdecl main(int argc, char *argv[]) -{ - int err; - HANDLE ProcessHeapHandle; - LPVOID lpHeap; - - /* Initialize the PAL environment */ - err = PAL_Initialize(argc, argv); - if(0 != 0) - { - ExitProcess(FAIL); - } - - /* Retrieve the calling process heap handle */ - ProcessHeapHandle = GetProcessHeap(); - - if(!ProcessHeapHandle) - { - Fail("\nFailed to call GetProcessHeap API!\n"); - } - - /* allocate a heap memory in specified size */ - lpHeap = HeapAlloc(ProcessHeapHandle, /* HeapHandle */ - 0, /* control flag */ - HEAPSIZE); /* /specify the heap size */ - if(NULL == lpHeap) - { - Fail("Failed to call HeapAlloc API!\n"); - } - - /* free the heap memory */ - err = HeapFree(ProcessHeapHandle, - 0, - lpHeap); - if(0 == err) - { - Fail("Failed to call HeapFree API!\n"); - } - - - /* allocate a heap memory in 1 byte size */ - lpHeap = HeapAlloc(ProcessHeapHandle, /* HeapHandle */ - 0, /* control flag */ - 1); /* specify the heap size*/ - if(NULL == lpHeap) - { - Fail("Failed to call HeapAlloc API to allocate one byte heap memory!\n"); - } - - /* free the heap memory */ - err = HeapFree(ProcessHeapHandle, - 0, - lpHeap); - if(0 == err) - { - Fail("Failed to call HeapFree API!\n"); - } - - /* allocate a heap memory and initialize it to zero */ - lpHeap = HeapAlloc(ProcessHeapHandle,/* HeapHandle */ - HEAP_ZERO_MEMORY,/* control flag */ - HEAPSIZE); /* specify the heap size */ - if(NULL == lpHeap) - { - Fail("Failed to call HeapAlloc API with HEAP_ZERO_MEMORY control flag!\n"); - } - - /* free the heap memory */ - err = HeapFree(ProcessHeapHandle, - 0, - lpHeap); - if(0 == err) - { - Fail("Failed to call HeapFree API!\n"); - } - - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/filemapping_memmgt/HeapAlloc/test1/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/HeapAlloc/test1/testinfo.dat deleted file mode 100644 index 9b6064349..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/HeapAlloc/test1/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Filemapping_memmgt -Function = HeapAlloc -Name = Positive test for HeapAlloc API -TYPE = DEFAULT -EXE1 = heapalloc -Description -=Test the HeapAlloc by passing zero as the control flag diff --git a/src/pal/tests/palsuite/filemapping_memmgt/HeapAlloc/test2/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/HeapAlloc/test2/CMakeLists.txt deleted file mode 100644 index f8084adf3..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/HeapAlloc/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - HeapAlloc.cpp -) - -add_executable(paltest_heapalloc_test2 - ${SOURCES} -) - -add_dependencies(paltest_heapalloc_test2 coreclrpal) - -target_link_libraries(paltest_heapalloc_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/HeapAlloc/test2/HeapAlloc.cpp b/src/pal/tests/palsuite/filemapping_memmgt/HeapAlloc/test2/HeapAlloc.cpp deleted file mode 100644 index 5f4ff9049..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/HeapAlloc/test2/HeapAlloc.cpp +++ /dev/null @@ -1,59 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: heapalloc.c -** -** Purpose: Positive test the HeapAlloc API. -** Call HeapAlloc with HEAP_ZERO_MEMORY control flag -** -** -**============================================================*/ -#include - -#define HEAPSIZE 64 - -int __cdecl main(int argc, char *argv[]) -{ - int err; - HANDLE ProcessHeapHandle; - LPVOID lpHeap; - - - //Initialize the PAL environment - err = PAL_Initialize(argc, argv); - if(0 != err) - { - ExitProcess(FAIL); - } - - //Retrieve the calling process heap handle - ProcessHeapHandle = GetProcessHeap(); - - if(!ProcessHeapHandle) - { - Fail("\nFailed to call GetProcessHeap API!\n"); - } - - lpHeap = HeapAlloc(ProcessHeapHandle,//HeapHandle - HEAP_ZERO_MEMORY,//control flag - HEAPSIZE); //specify the heap size - if(NULL == lpHeap) - { - Fail("Failed to call HeapAlloc API!\n"); - } - - //free the heap memory - err = HeapFree(ProcessHeapHandle, - 0, - lpHeap); - if(0 == err) - { - Fail("Failed to call HeapFree API!\n"); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/filemapping_memmgt/HeapAlloc/test2/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/HeapAlloc/test2/testinfo.dat deleted file mode 100644 index 5c6e77d2c..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/HeapAlloc/test2/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Filemapping_memmgt -Function = HeapAlloc -Name = Positive test for HeapAlloc API -TYPE = DEFAULT -EXE1 = heapalloc -Description -=Test the HeapAlloc with HEAP_ZERO_MEMORY control flag diff --git a/src/pal/tests/palsuite/filemapping_memmgt/HeapAlloc/test3/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/HeapAlloc/test3/CMakeLists.txt deleted file mode 100644 index 81bd6def2..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/HeapAlloc/test3/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - HeapAlloc.cpp -) - -add_executable(paltest_heapalloc_test3 - ${SOURCES} -) - -add_dependencies(paltest_heapalloc_test3 coreclrpal) - -target_link_libraries(paltest_heapalloc_test3 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/HeapAlloc/test3/HeapAlloc.cpp b/src/pal/tests/palsuite/filemapping_memmgt/HeapAlloc/test3/HeapAlloc.cpp deleted file mode 100644 index 4a74fe819..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/HeapAlloc/test3/HeapAlloc.cpp +++ /dev/null @@ -1,62 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: heapalloc.c -** -** Purpose: Positive test the HeapAlloc API. -** Call HeapAlloc asking for zero bytes -** with HEAP_ZERO_MEMORY control flag -** -** -**============================================================*/ -#include - -#define HEAPSIZE 0 - -int __cdecl main(int argc, char *argv[]) -{ - int err; - HANDLE ProcessHeapHandle; - LPVOID lpHeap; - - - //Initialize the PAL environment - err = PAL_Initialize(argc, argv); - if(0 != err) - { - ExitProcess(FAIL); - } - - //Retrieve the calling process heap handle - ProcessHeapHandle = GetProcessHeap(); - - if(!ProcessHeapHandle) - { - Fail("\nFailed to call GetProcessHeap API!\n"); - } - - lpHeap = HeapAlloc(ProcessHeapHandle,//HeapHandle - HEAP_ZERO_MEMORY,//control flag - HEAPSIZE); //specify the heap size - - //lpHeap should be non-NULL pointer - if(NULL == lpHeap) - { - Fail("Failed to call HeapAlloc API, when number of bytes to be allocated is zero!\n"); - } - - //free the heap memory - err = HeapFree(ProcessHeapHandle, - 0, - lpHeap); - if(0 == err) - { - Fail("Failed to call HeapFree API!\n"); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/filemapping_memmgt/HeapAlloc/test3/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/HeapAlloc/test3/testinfo.dat deleted file mode 100644 index c7d67d3b4..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/HeapAlloc/test3/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Filemapping_memmgt -Function = HeapAlloc -Name = Positive test for HeapAlloc API -TYPE = DEFAULT -EXE1 = heapalloc -Description -=Test the HeapAlloc asking for zero bytes with HEAP_ZERO_MEMORY control flag diff --git a/src/pal/tests/palsuite/filemapping_memmgt/HeapFree/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/HeapFree/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/HeapFree/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/filemapping_memmgt/HeapFree/test1/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/HeapFree/test1/CMakeLists.txt deleted file mode 100644 index 3f61a2f21..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/HeapFree/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - HeapFree.cpp -) - -add_executable(paltest_heapfree_test1 - ${SOURCES} -) - -add_dependencies(paltest_heapfree_test1 coreclrpal) - -target_link_libraries(paltest_heapfree_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/HeapFree/test1/HeapFree.cpp b/src/pal/tests/palsuite/filemapping_memmgt/HeapFree/test1/HeapFree.cpp deleted file mode 100644 index 37b6b3bf6..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/HeapFree/test1/HeapFree.cpp +++ /dev/null @@ -1,62 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: heapfree.c -** -** Purpose: Positive test the HeapFree API. -** Call HeapFree to free a memory block -** and try to free an invalid memory block -** -** -**============================================================*/ -#include - -#define HEAPSIZE 64 - -int __cdecl main(int argc, char *argv[]) -{ - int err; - HANDLE ProcessHeapHandle; - LPVOID lpHeap; - - - /* Initialize the PAL environment */ - if(0 != PAL_Initialize(argc, argv)) - { - return FAIL; - } - - /* Retrieve the calling process heap handle */ - ProcessHeapHandle = GetProcessHeap(); - - if(!ProcessHeapHandle) - { - Fail("\nFailed to call GetProcessHeap API!\n"); - } - - - lpHeap = HeapAlloc(ProcessHeapHandle,/* HeapHandle */ - HEAP_ZERO_MEMORY,/* control flag */ - HEAPSIZE); /* specify the heap size */ - if(NULL == lpHeap) - { - Fail("Failed to call HeapAlloc API!\n"); - } - - - /* free a allocate heap memory */ - err = HeapFree(ProcessHeapHandle, - 0, - lpHeap); - - if(0 == err) - { - Fail("Failed to call HeapFree API!\n"); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/filemapping_memmgt/HeapFree/test1/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/HeapFree/test1/testinfo.dat deleted file mode 100644 index c6f18167e..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/HeapFree/test1/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Filemapping_memmgt -Function = HeapFree -Name = Positive test for HeapFree API to free an allocated heap block -TYPE = DEFAULT -EXE1 = heapfree -Description -=Test the HeapFree to free a memory block diff --git a/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/CMakeLists.txt deleted file mode 100644 index 8083faf65..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) -add_subdirectory(test3) -add_subdirectory(test4) -add_subdirectory(test5) - diff --git a/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test1/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test1/CMakeLists.txt deleted file mode 100644 index acdb24e9e..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_heaprealloc_test1 - ${SOURCES} -) - -add_dependencies(paltest_heaprealloc_test1 coreclrpal) - -target_link_libraries(paltest_heaprealloc_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test1/test1.cpp b/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test1/test1.cpp deleted file mode 100644 index eedd45e45..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test1/test1.cpp +++ /dev/null @@ -1,72 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: test1.c -** -** Purpose: Allocate some memory. Then reallocate that memory. Ensure the -** return values are correct, and also that data placed in the allocated -** memory carries over to the reallocated block. -** -** -**============================================================*/ - -#include - -int __cdecl main(int argc, char *argv[]) -{ - - HANDLE TheHeap; - char* TheMemory; - char* ReAllocMemory; - int i; - - if(PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - TheHeap = GetProcessHeap(); - - if(TheHeap == NULL) - { - Fail("ERROR: GetProcessHeap() returned NULL when it was called. " - "GetLastError() returned %d.",GetLastError()); - } - - /* Allocate 100 bytes on the heap */ - if((TheMemory = (char*)HeapAlloc(TheHeap, 0, 100)) == NULL) - { - Fail("ERROR: HeapAlloc returned NULL when it was called. " - "GetLastError() returned %d.",GetLastError()); - } - - /* Set each byte of that memory block to 'x' */ - memset(TheMemory, 'X', 100); - - /* Reallocate the memory */ - ReAllocMemory = (char*)HeapReAlloc(TheHeap, 0, TheMemory, 100); - - if(ReAllocMemory == NULL) - { - Fail("ERROR: HeapReAlloc failed to reallocate the 100 bytes of " - "heap memory. GetLastError returns %d.",GetLastError()); - } - - /* Check that each byte of the memory Reallocated is 'x' */ - - for(i=0; i<100; ++i) - { - if(ReAllocMemory[i] != 'X') - { - Fail("ERROR: Byte number %d of the reallocated memory block " - "is not set to 'X' as it should be.",i); - } - } - - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test1/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test1/testinfo.dat deleted file mode 100644 index ad3a3ffc7..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test1/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Filemapping_memmgt -Function = HeapReAlloc -Name = Positive test for HeapReAlloc to check normal behaviour -TYPE = DEFAULT -EXE1 = test1 -Description -= Allocate some memory. Then reallocate that memory. Ensure the -= return values are correct, and also that data placed in the allocated -= memory carries over to the reallocated block. diff --git a/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test2/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test2/CMakeLists.txt deleted file mode 100644 index c2ce80b40..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test2.cpp -) - -add_executable(paltest_heaprealloc_test2 - ${SOURCES} -) - -add_dependencies(paltest_heaprealloc_test2 coreclrpal) - -target_link_libraries(paltest_heaprealloc_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test2/test2.cpp b/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test2/test2.cpp deleted file mode 100644 index a7e3b2a05..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test2/test2.cpp +++ /dev/null @@ -1,79 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: test2.c -** -** Purpose: Allocate some memory. Then reallocate that memory into less -** space than the original amount. Ensure the -** return values are correct, and also that data placed in the allocated -** memory carries over to the reallocated block. -** -** -**============================================================*/ - -#include - -int __cdecl main(int argc, char *argv[]) -{ - - HANDLE TheHeap; - char* TheMemory; - char* ReAllocMemory; - int i; - - if(PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - TheHeap = GetProcessHeap(); - - if(TheHeap == NULL) - { - Fail("ERROR: GetProcessHeap() returned NULL when it was called. " - "GetLastError() returned %d.",GetLastError()); - } - - /* Allocate 200 bytes on the heap */ - if((TheMemory = (char*)HeapAlloc(TheHeap, 0, 200)) == NULL) - { - Fail("ERROR: HeapAlloc returned NULL when it was called. " - "GetLastError() returned %d.",GetLastError()); - } - - /* Set the first 100 bytes to 'X' */ - memset(TheMemory, 'X', 100); - - /* Set the second 100 bytes to 'Z' */ - memset(TheMemory+100, 'Z', 100); - - /* Reallocate the memory to 100 bytes */ - ReAllocMemory = (char*)HeapReAlloc(TheHeap, 0, TheMemory, 100); - - if(ReAllocMemory == NULL) - { - Fail("ERROR: HeapReAlloc failed to reallocate the 100 bytes of " - "heap memory. GetLastError returns %d.",GetLastError()); - } - - /* Check that each of the first 100 bytes hasn't lost any data. - Anything beyond the first 100 might still be valid, but we can't - gaurentee it. - */ - - for(i=0; i<100; ++i) - { - /* Note: Cast to char* so the function knows the size is 1 */ - if(ReAllocMemory[i] != 'X') - { - Fail("ERROR: Byte number %d of the reallocated memory block " - "is not set to 'X' as it should be.",i); - } - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test2/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test2/testinfo.dat deleted file mode 100644 index 95a12aafd..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test2/testinfo.dat +++ /dev/null @@ -1,15 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Filemapping_memmgt -Function = HeapReAlloc -Name = Positive test for HeapReAlloc to reallocate into a smaller space -TYPE = DEFAULT -EXE1 = test2 -Description -= Allocate some memory. Then reallocate that memory into less -= space than the origional amount. Ensure the -= return values are correct, and also that data placed in the allocated -= memory carries over to the reallocated block. diff --git a/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test3/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test3/CMakeLists.txt deleted file mode 100644 index 7982b05c6..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test3/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test3.cpp -) - -add_executable(paltest_heaprealloc_test3 - ${SOURCES} -) - -add_dependencies(paltest_heaprealloc_test3 coreclrpal) - -target_link_libraries(paltest_heaprealloc_test3 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test3/test3.cpp b/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test3/test3.cpp deleted file mode 100644 index d4139e8d5..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test3/test3.cpp +++ /dev/null @@ -1,78 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: test3.c -** -** Purpose: Allocate some memory. Then reallocate that memory into a -** bigger space on the heap. Check that the first portion of the data is -** unchanged. Then set the new portion to a value, to ensure that it is -** properly writable memory. -** -** -**============================================================*/ - -#include - -int __cdecl main(int argc, char *argv[]) -{ - - HANDLE TheHeap; - char* TheMemory; - char* ReAllocMemory; - int i; - - if(PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - TheHeap = GetProcessHeap(); - - if(TheHeap == NULL) - { - Fail("ERROR: GetProcessHeap() returned NULL when it was called. " - "GetLastError() returned %d.",GetLastError()); - } - - /* Allocate 100 bytes on the heap */ - if((TheMemory = (char*)HeapAlloc(TheHeap, 0, 100)) == NULL) - { - Fail("ERROR: HeapAlloc returned NULL when it was called. " - "GetLastError() returned %d.",GetLastError()); - } - - /* Set the first 100 bytes to 'X' */ - memset(TheMemory, 'X', 100); - - /* Reallocate the memory to 200 bytes */ - ReAllocMemory = (char*)HeapReAlloc(TheHeap, 0, TheMemory, 200); - - if(ReAllocMemory == NULL) - { - Fail("ERROR: HeapReAlloc failed to reallocate the 100 bytes of " - "heap memory. GetLastError returns %d.",GetLastError()); - } - - /* Check that each of the first 100 bytes hasn't lost any data. */ - for(i=0; i<100; ++i) - { - - if(ReAllocMemory[i] != 'X') - { - Fail("ERROR: Byte number %d of the reallocated memory block " - "is not set to 'X' as it should be.",i); - } - } - - /* Beyond the first 100 bytes is valid free memory. We'll set all this - memory to a value -- though, even if HeapReAlloc didn't work, it might - still be possible to memset this memory without raising an exception. - */ - memset(ReAllocMemory+100, 'Z', 100); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test3/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test3/testinfo.dat deleted file mode 100644 index ed6da87c3..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test3/testinfo.dat +++ /dev/null @@ -1,16 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Filemapping_memmgt -Function = HeapReAlloc -Name = Positive test for HeapReAlloc to reallocate into a larger space -TYPE = DEFAULT -EXE1 = test3 -Description -= Allocate some memory. Then reallocate that memory into a -= bigger space on the heap. Check that the first portion of the data is -= unchanged. Then set the new portion to a value, to ensure that it is -= properly writable memory. - diff --git a/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test4/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test4/CMakeLists.txt deleted file mode 100644 index f178dacca..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test4/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test4.cpp -) - -add_executable(paltest_heaprealloc_test4 - ${SOURCES} -) - -add_dependencies(paltest_heaprealloc_test4 coreclrpal) - -target_link_libraries(paltest_heaprealloc_test4 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test4/test4.cpp b/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test4/test4.cpp deleted file mode 100644 index cebf90450..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test4/test4.cpp +++ /dev/null @@ -1,80 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: test4.c -** -** Purpose: Call HeapReAlloc with a NULL pointer to memory. It should -** return NULL. -** -** -**============================================================*/ - -/* Note: When attempted with a NULL Handle, this test crashes under win32. - As such, the behaviour isn't tested here. -*/ - -#include - -int __cdecl main(int argc, char *argv[]) -{ - - HANDLE TheHeap; - LPVOID TheMemory = NULL; - - if(PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - TheHeap = GetProcessHeap(); - - if(TheHeap == NULL) - { - Fail("ERROR: GetProcessHeap() returned NULL when it was called. " - "GetLastError() returned %d.",GetLastError()); - } - - /* Allocate 100 bytes on the heap */ - if(HeapAlloc(TheHeap, 0, 100) == NULL) - { - Fail("ERROR: HeapAlloc returned NULL when it was called. " - "GetLastError() returned %d.",GetLastError()); - } - - /* Call HeapReAlloc with a NULL memory pointer. It should fail */ - - if(HeapReAlloc(TheHeap, 0, TheMemory, 100) != NULL) - { - Fail("ERROR: HeapReAlloc was passed an invalid memory pointer. " - "It should have failed and returned NULL upon failure."); - } - - if(GetLastError() != 0) - { - Fail("ERROR: GetLastError should be zero after passing a NULL " - "memory pointer to HeapReAlloc.\n"); - } - - /* Call HeapReAlloc with a size of 0 bytes on a NULL memory pointer. - It should still fail. - */ - - if(HeapReAlloc(TheHeap, 0, TheMemory, 0) != NULL) - { - Fail("ERROR: HeapReAlloc was passed an invalid memory pointer and " - "the amount of memory to reallocate was 0. " - "It should have failed and returned NULL upon failure."); - } - - if(GetLastError() != 0) - { - Fail("ERROR: GetLastError should be zero after passing a NULL " - "memory pointer to HeapReAlloc.\n"); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test4/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test4/testinfo.dat deleted file mode 100644 index cfa5f5cee..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test4/testinfo.dat +++ /dev/null @@ -1,15 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Filemapping_memmgt -Function = HeapReAlloc -Name = Negative test for HeapReAlloc -TYPE = DEFAULT -EXE1 = test4 -Description -= Call HeapReAlloc with a NULL pointer to memory. It should -= return NULL. - - diff --git a/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test5/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test5/CMakeLists.txt deleted file mode 100644 index 2a493525a..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test5/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test5.cpp -) - -add_executable(paltest_heaprealloc_test5 - ${SOURCES} -) - -add_dependencies(paltest_heaprealloc_test5 coreclrpal) - -target_link_libraries(paltest_heaprealloc_test5 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test5/test5.cpp b/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test5/test5.cpp deleted file mode 100644 index fcd38376e..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test5/test5.cpp +++ /dev/null @@ -1,69 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: test5.c -** -** Purpose: Allocate some memory. Then call HeapRealloc with 0 as the -** amount of memory to reallocate. This should work, essentially freeing -** the memory (though we can't verfiy this) -** -** -**============================================================*/ - -#include - -int __cdecl main(int argc, char *argv[]) -{ - - HANDLE TheHeap; - char* TheMemory; - char* ReAllocMemory; - char* ReAllocMemory2; - - if(PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - TheHeap = GetProcessHeap(); - - if(TheHeap == NULL) - { - Fail("ERROR: GetProcessHeap() returned NULL when it was called. " - "GetLastError() returned %d.",GetLastError()); - } - - /* Allocate 100 bytes on the heap */ - if((TheMemory = (char*)HeapAlloc(TheHeap, 0, 100)) == NULL) - { - Fail("ERROR: HeapAlloc returned NULL when it was called. " - "GetLastError() returned %d.",GetLastError()); - } - - /* Set each byte of that memory block to 'x' */ - memset(TheMemory, 'X', 100); - - /* Reallocate the memory into 0 bytes */ - ReAllocMemory = (char*)HeapReAlloc(TheHeap, 0, TheMemory, 0); - - if(ReAllocMemory == NULL) - { - Fail("ERROR: HeapReAlloc failed to reallocate the 100 bytes of " - "heap memory. GetLastError returns %d.",GetLastError()); - } - - /* Reallocate the memory we just put into 0 bytes, into 100 bytes. */ - ReAllocMemory2 = (char*)HeapReAlloc(TheHeap, 0, ReAllocMemory, 100); - - if(ReAllocMemory2 == NULL) - { - Fail("ERROR: HeapReAlloc failed to reallocate the 0 bytes of " - "heap memory into 100. GetLastError returns %d.",GetLastError()); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test5/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test5/testinfo.dat deleted file mode 100644 index e36b9035c..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/HeapReAlloc/test5/testinfo.dat +++ /dev/null @@ -1,15 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Filemapping_memmgt -Function = HeapReAlloc -Name = Positive test for HeapReAlloc to check behaviour with byte size 0 -TYPE = DEFAULT -EXE1 = test5 -Description -= Allocate some memory. Then call HeapRealloc with 0 as the -= amount of memory to reallocate. This should work, essentially freeing -= the memory (though we can't verfiy this) - diff --git a/src/pal/tests/palsuite/filemapping_memmgt/LocalAlloc/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/LocalAlloc/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/LocalAlloc/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/filemapping_memmgt/LocalAlloc/test1/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/LocalAlloc/test1/CMakeLists.txt deleted file mode 100644 index 07d0c01c0..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/LocalAlloc/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - LocalAlloc.cpp -) - -add_executable(paltest_localalloc_test1 - ${SOURCES} -) - -add_dependencies(paltest_localalloc_test1 coreclrpal) - -target_link_libraries(paltest_localalloc_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/LocalAlloc/test1/LocalAlloc.cpp b/src/pal/tests/palsuite/filemapping_memmgt/LocalAlloc/test1/LocalAlloc.cpp deleted file mode 100644 index 17afbc602..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/LocalAlloc/test1/LocalAlloc.cpp +++ /dev/null @@ -1,49 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: LocalAlloc.c -** -** Purpose: Positive test the LocalAlloc API. -** Call LocalAlloc with zero as the allocation attribute -** -** -**============================================================*/ -#include - -int __cdecl main(int argc, char *argv[]) -{ - HLOCAL LocalHeap; - HLOCAL FreeHeap; - int err; - const SIZE_T heapSize = 64; - - /*Initialize the PAL environment*/ - err = PAL_Initialize(argc, argv); - if(0 != err) - { - return FAIL; - } - - /*Allocate the specified number of bytes from the heap*/ - /*with allocation attribute: zero which is required by PAL Doc*/ - LocalHeap = LocalAlloc(0, heapSize); - if(!LocalHeap) - { - Fail("\nFailed to call LocalAlloc API, " - "error code=%u\n", GetLastError()); - } - - /*Free the allocated local heap memory*/ - FreeHeap = LocalFree(LocalHeap); - if(FreeHeap) - { - Fail("Failed to call LocalFree API, " - "error code=%u\n", GetLastError()); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/filemapping_memmgt/LocalAlloc/test1/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/LocalAlloc/test1/testinfo.dat deleted file mode 100644 index 056d9ceb2..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/LocalAlloc/test1/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Filemapping_memmgt -Function = LocalAlloc -Name = Positive test LocalAlloc API to Allocate the specified number of bytes from the heap -TYPE = DEFAULT -EXE1 = localalloc -Description -=Test the LocalAlloc with zero ad allocation attribute diff --git a/src/pal/tests/palsuite/filemapping_memmgt/LocalFree/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/LocalFree/CMakeLists.txt deleted file mode 100644 index ef14ea535..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/LocalFree/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) - diff --git a/src/pal/tests/palsuite/filemapping_memmgt/LocalFree/test1/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/LocalFree/test1/CMakeLists.txt deleted file mode 100644 index 5e7aac4f5..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/LocalFree/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - LocalFree.cpp -) - -add_executable(paltest_localfree_test1 - ${SOURCES} -) - -add_dependencies(paltest_localfree_test1 coreclrpal) - -target_link_libraries(paltest_localfree_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/LocalFree/test1/LocalFree.cpp b/src/pal/tests/palsuite/filemapping_memmgt/LocalFree/test1/LocalFree.cpp deleted file mode 100644 index d9c062e76..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/LocalFree/test1/LocalFree.cpp +++ /dev/null @@ -1,49 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: LocalFree.c -** -** Purpose: Positive test the LocalFree API. -** Call LocalFree to free a specified local memory object -** -** -**============================================================*/ -#include - -int __cdecl main(int argc, char *argv[]) -{ - HLOCAL LocalHeap; - HLOCAL FreeHeap; - int err; - const SIZE_T heapSize = 64; - - /*Initialize the PAL environment*/ - err = PAL_Initialize(argc, argv); - if(0 != err) - { - return FAIL; - } - - /*Allocate the specified number of bytes from the heap*/ - /*with zero ad the allocation attribute*/ - LocalHeap = LocalAlloc(0, heapSize); - if(!LocalHeap) - { - Fail("\nFailed to call LocalAlloc API, " - "error code=%u\n", GetLastError()); - } - - /*Free the allocated local heap memory*/ - FreeHeap = LocalFree(LocalHeap); - if(FreeHeap) - { - Fail("Failed to call LocalFree API, " - "error code=%u\n", GetLastError()); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/filemapping_memmgt/LocalFree/test1/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/LocalFree/test1/testinfo.dat deleted file mode 100644 index 2c0611bde..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/LocalFree/test1/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Filemapping_memmgt -Function = LocalFree -Name = Positive test LocalFree API to free a specified local memory object -TYPE = DEFAULT -EXE1 = localfree -Description -=Test the LocalFree to free a specified local memory object diff --git a/src/pal/tests/palsuite/filemapping_memmgt/LocalFree/test2/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/LocalFree/test2/CMakeLists.txt deleted file mode 100644 index 1f04c7ab2..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/LocalFree/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - LocalFree.cpp -) - -add_executable(paltest_localfree_test2 - ${SOURCES} -) - -add_dependencies(paltest_localfree_test2 coreclrpal) - -target_link_libraries(paltest_localfree_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/LocalFree/test2/LocalFree.cpp b/src/pal/tests/palsuite/filemapping_memmgt/LocalFree/test2/LocalFree.cpp deleted file mode 100644 index 4d4567dc3..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/LocalFree/test2/LocalFree.cpp +++ /dev/null @@ -1,39 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: LocalFree.c -** -** Purpose: Positive test the LocalFree API. -** call LocalFree by passing NULL as local memory -** object handle -** -** -**============================================================*/ -#include - -int __cdecl main(int argc, char *argv[]) -{ - HLOCAL FreeHeap; - int err; - - /*Initialize the PAL environment*/ - err = PAL_Initialize(argc, argv); - if(0 != err) - { - return FAIL; - } - - /*call LocalFree by passing NULL as local memory object handle*/ - FreeHeap = LocalFree(NULL); - if(FreeHeap) - { - Fail("Failed to call LocalFree API, " - "error code=%u\n", GetLastError()); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/filemapping_memmgt/LocalFree/test2/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/LocalFree/test2/testinfo.dat deleted file mode 100644 index 1455fe93b..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/LocalFree/test2/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Filemapping_memmgt -Function = LocalFree -Name = Positive test LocalFree API by passing NULL as local memory object handle -TYPE = DEFAULT -EXE1 = localfree -Description -=Test the LocalFree by passing NULL -=as a local memory object handle diff --git a/src/pal/tests/palsuite/filemapping_memmgt/MapViewOfFile/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/MapViewOfFile/CMakeLists.txt deleted file mode 100644 index 7c2017935..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/MapViewOfFile/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) -add_subdirectory(test3) -add_subdirectory(test4) -add_subdirectory(test5) -add_subdirectory(test6) - diff --git a/src/pal/tests/palsuite/filemapping_memmgt/MapViewOfFile/test1/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/MapViewOfFile/test1/CMakeLists.txt deleted file mode 100644 index bdd664f0a..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/MapViewOfFile/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - MapViewOfFile.cpp -) - -add_executable(paltest_mapviewoffile_test1 - ${SOURCES} -) - -add_dependencies(paltest_mapviewoffile_test1 coreclrpal) - -target_link_libraries(paltest_mapviewoffile_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/MapViewOfFile/test1/MapViewOfFile.cpp b/src/pal/tests/palsuite/filemapping_memmgt/MapViewOfFile/test1/MapViewOfFile.cpp deleted file mode 100644 index 6bfb73f0e..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/MapViewOfFile/test1/MapViewOfFile.cpp +++ /dev/null @@ -1,244 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: MapViewOfFile.c -** -** -** Purpose: Positive test the MapViewOfFile API. -** Call MapViewOfFile with access FILE_MAP_READ. -** -** -**============================================================*/ -#include -#define MAPPINGSIZE 8192 - -// This test is special - it doesn't work when the file is created on a tmpfs, like the /tmp folder -// that is the default location for running PAL tests. The reason is that on such filesystem, -// it is not possible to create file with FILE_FLAG_NO_BUFFERING. -// So we explicitly use the /var/tmp that cannot be on tmpfs, since it it persistent over reboots. - -#ifndef __ANDROID__ -#define TEMP_DIRECTORY_PATH "/var/tmp/" -#else -// On Android, "/var/tmp/" doesn't exist; temporary files should go to /data/local/tmp/ -#define TEMP_DIRECTORY_PATH "/data/local/tmp/" -#endif - -int __cdecl main(int argc, char *argv[]) -{ - - HANDLE hFile = INVALID_HANDLE_VALUE; - LPSTR buf = NULL; - CHAR ch[MAPPINGSIZE]; - CHAR lpFilePath[MAX_PATH]; - DWORD dwBytesWritten = 0; - DWORD dwInitialSize = 0; - DWORD dwFinalSize = 0; - BOOL bRetVal = FALSE; - - HANDLE hFileMapping = 0; - LPVOID lpMapViewAddress = NULL; - - /* Initialize the PAL environment. - */ - if( 0 != PAL_Initialize(argc, argv)) - { - return FAIL; - } - - GetTempFileName(TEMP_DIRECTORY_PATH, "tst", 0, lpFilePath); - - /* Create a file handle with CreateFile. - */ - hFile = CreateFile( lpFilePath, - GENERIC_WRITE|GENERIC_READ, - FILE_SHARE_READ|FILE_SHARE_WRITE, - NULL, - OPEN_ALWAYS, - FILE_ATTRIBUTE_NORMAL | FILE_FLAG_NO_BUFFERING, - NULL); - - if (hFile == INVALID_HANDLE_VALUE) - { - Fail( "ERROR: %u :unable to create file \"%s\".\n", - GetLastError(), lpFilePath); - } - - /* Get the initial size of file, for latter tests. - */ - dwInitialSize = GetFileSize (hFile, NULL); - if ( INVALID_FILE_SIZE == dwInitialSize ) - { - Fail("ERROR:%u: The created file \"%s\" has an invalid " - "file size.\n",GetLastError(),lpFilePath); - } - - /* - * An application must meet certain requirements when working - * with files opened with FILE_FLAG_NO_BUFFERING: - * File access must begin at byte offsets within the file that - * are integer multiples of the volume's sector size. To determine a - * volume's sector size, call the GetDiskFreeSpace function. - * - * File access must be for numbers of bytes that are integer - * multiples of the volume's sector size. For example, if the - * sector size is 512 bytes, an application can request reads and - * writes of 512, 1024, or 2048 bytes, but not of 335, 981, or 7171 bytes. - * - * Buffer addresses for read and write operations must be sector - * aligned (aligned on addresses in memory that are integer multiples - * of the volume's sector size). One way to sector align buffers is to use the - * VirtualAlloc function to allocate the buffers. This function allocates memory - * that is aligned on addresses that are integer multiples of the system's page size. - * Because both page and volume sector sizes are powers of 2, memory aligned by multiples - * of the system's page size is also aligned by multiples of the volume's sector size. - */ - buf = (LPSTR)VirtualAlloc( NULL, /* Let the system decide the location. */ - MAPPINGSIZE / 2, /* One page, the smallest you can request */ - MEM_COMMIT, /* Reserve and commit in one pass */ - PAGE_READWRITE ); /* Allow reading and writting. */ - - if ( NULL == buf ) - { - Trace( "VirtualAlloc failed! LastError=%d\n", GetLastError() ); - CloseHandle( hFile ); - Fail(""); - } - - - /* - * Write to the File handle. - * The reminder will be padded with zeros. - */ - strncpy( buf, - "thats not a test string....THIS is a test string", - MAPPINGSIZE / 2 ); - - bRetVal = WriteFile(hFile, - buf, - MAPPINGSIZE / 2, - &dwBytesWritten, - NULL); - - if ( FALSE == bRetVal ) - { - Trace( "ERROR: %u :unable to write to file handle hFile=0x%lx\n", - GetLastError(), hFile); - CloseHandle(hFile); - VirtualFree( buf, 0, MEM_RELEASE ); - Fail(""); - } - - /* Create a unnamed file-mapping object with file handle FileHandle - * and with PAGE_READWRITE protection. - */ - hFileMapping = CreateFileMapping( hFile, - NULL, /*not inherited*/ - PAGE_READWRITE, /*read and wite*/ - 0, /*high-order of object size*/ - MAPPINGSIZE, /*low-orger of object size*/ - NULL); /*unnamed object*/ - - if( NULL == hFileMapping ) - { - Trace("ERROR:%u: Failed to create File Mapping.\n", GetLastError()); - CloseHandle(hFile); - VirtualFree( buf, 0, MEM_RELEASE ); - Fail(""); - } - - /* maps a view of a file into the address space of the calling process. - */ - lpMapViewAddress = MapViewOfFile( hFileMapping, - FILE_MAP_READ, /* access code */ - 0, /*high order offset*/ - 0, /*low order offset*/ - MAPPINGSIZE); /* number of bytes for map */ - - if( NULL == lpMapViewAddress ) - { - Trace( "ERROR:%u: Failed to call MapViewOfFile API to map" - " a view of file!\n", GetLastError()); - CloseHandle(hFile); - CloseHandle(hFileMapping); - VirtualFree( buf, 0, MEM_RELEASE ); - Fail(""); - } - - /* Verify that the size of the file has increased to - * accomidate the MapView. - */ - dwFinalSize = GetFileSize (hFile, NULL); - if ( (dwFinalSize <= dwInitialSize) && (dwFinalSize != MAPPINGSIZE)) - { - - CloseHandle(hFile); - CloseHandle(hFileMapping); - VirtualFree( buf, 0, MEM_RELEASE ); - UnmapViewOfFile(lpMapViewAddress); - - Fail( "ERROR: Size of the file was expected to " - "increase from \"%d\", to \"%d\".\n ", - dwInitialSize, - dwFinalSize); - } - - /* Copy the MapViewOfFile to buffer, so we can - * compare with value read from file directly. - */ - memcpy(ch, (LPCSTR)lpMapViewAddress, MAPPINGSIZE); - if (memcmp(ch, buf, strlen(buf)) != 0) - { - CloseHandle(hFile); - CloseHandle(hFileMapping); - UnmapViewOfFile(lpMapViewAddress) ; - VirtualFree( buf, 0, MEM_RELEASE ); - - Fail( "ERROR: MapViewOfFile not equal to file contents " - "retrieved \"%s\", expected \"%s\".\n", - ch, - buf); - } - - /* Unmap the view of file. - */ - if( FALSE == UnmapViewOfFile(lpMapViewAddress) ) - { - Trace( "\nFailed to call UnmapViewOfFile API to unmap the " - "view of a file, error code=%u\n", GetLastError()); - CloseHandle(hFile); - CloseHandle(hFileMapping); - VirtualFree( buf, 0, MEM_RELEASE ); - Fail(""); - } - - /* Close handle to create file. - */ - if( FALSE == CloseHandle(hFile) ) - { - Trace( "ERROR:%u:Failed to call CloseHandle API to close a file handle.", - GetLastError()); - CloseHandle(hFileMapping); - VirtualFree( buf, 0, MEM_RELEASE ); - Fail(""); - } - - if( FALSE == CloseHandle(hFileMapping) ) - { - Trace( "ERROR:%u:Failed to call CloseHandle API to close a " - "filemapping handle.",GetLastError()); - VirtualFree( buf, 0, MEM_RELEASE ); - Fail(""); - } - - VirtualFree( buf, 0, MEM_RELEASE ); - - DeleteFile(lpFilePath); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/filemapping_memmgt/MapViewOfFile/test1/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/MapViewOfFile/test1/testinfo.dat deleted file mode 100644 index f1d8451ef..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/MapViewOfFile/test1/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Filemapping_memmgt -Function = MapViewOfFile -Name = Positive test MapViewOfFile API with access FILE_MAP_READ -TYPE = DEFAULT -EXE1 = mapviewoffile -Description -=Test the MapViewOfFile with access FILE_MAP_READ diff --git a/src/pal/tests/palsuite/filemapping_memmgt/MapViewOfFile/test2/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/MapViewOfFile/test2/CMakeLists.txt deleted file mode 100644 index c24ade8ff..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/MapViewOfFile/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - MapViewOfFile.cpp -) - -add_executable(paltest_mapviewoffile_test2 - ${SOURCES} -) - -add_dependencies(paltest_mapviewoffile_test2 coreclrpal) - -target_link_libraries(paltest_mapviewoffile_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/MapViewOfFile/test2/MapViewOfFile.cpp b/src/pal/tests/palsuite/filemapping_memmgt/MapViewOfFile/test2/MapViewOfFile.cpp deleted file mode 100644 index c08f585c0..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/MapViewOfFile/test2/MapViewOfFile.cpp +++ /dev/null @@ -1,203 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: MapViewOfFile.c -** -** Purpose: Positive test the MapViewOfFile API. -** Call MapViewOfFile with access FILE_MAP_WRITE. -** -** Depends: CreateFile, -** GetFileSize, -** memset, -** CreateFileMapping, -** CloseHandle, -** memcpy, -** ReadFile, -** memcmp, -** UnMapViewOfFile. -** -** -**============================================================*/ -#include - -int __cdecl main(int argc, char *argv[]) -{ - - HANDLE hFile; - HANDLE hFileMapping; - LPVOID lpMapViewAddress; - char buf[] = "this is a test string"; - const int MAPPINGSIZE = 2048; - char ch[2048]; - char readString[2048]; - char lpFileName[] = "test.tmp"; - DWORD dwBytesRead; - DWORD dwInitialSize = 0; - DWORD dwFinalSize = 0; - BOOL bRetVal; - - /* Initialize the PAL environment. - */ - if(0 != PAL_Initialize(argc, argv)) - { - return FAIL; - } - - /* Create a file handle with CreateFile. - */ - hFile = CreateFile( lpFileName, - GENERIC_WRITE|GENERIC_READ, - FILE_SHARE_READ|FILE_SHARE_WRITE, - NULL, - CREATE_ALWAYS, - FILE_ATTRIBUTE_NORMAL, - NULL); - if (hFile == INVALID_HANDLE_VALUE) - { - Fail("ERROR: %u :unable to create file \"%s\".\n", - GetLastError(), - lpFileName); - } - - /* Get the initial size of file, for latter tests. - */ - dwInitialSize = GetFileSize (hFile, NULL); - if ( dwInitialSize == INVALID_FILE_SIZE ) - { - Fail("ERROR:%u: The created file \"%s\" has an invalid " - "file size.\n", - GetLastError(), - lpFileName); - } - - /* Initialize the buffers. - */ - memset(ch, 0, MAPPINGSIZE); - memset(readString, 0, MAPPINGSIZE); - - /* Create a unnamed file-mapping object with file handle FileHandle - * and with PAGE_READWRITE protection. - */ - hFileMapping = CreateFileMapping( - hFile, - NULL, /*not inherited*/ - PAGE_READWRITE, /*read and wite*/ - 0, /*high-order of object size*/ - MAPPINGSIZE, /*low-orger of object size*/ - NULL); /*unnamed object*/ - - if(NULL == hFileMapping) - { - Trace("ERROR:%u: Failed to create File Mapping.\n", - GetLastError()); - CloseHandle(hFile); - Fail(""); - } - - /* maps a view of a file into the address space of the calling process. - */ - lpMapViewAddress = MapViewOfFile( - hFileMapping, - FILE_MAP_WRITE, /* access code */ - 0, /*high order offset*/ - 0, /*low order offset*/ - MAPPINGSIZE); /* number of bytes for map */ - - if(NULL == lpMapViewAddress) - { - Trace("ERROR:%u: Failed to call MapViewOfFile API to map a view" - " of file!\n", - GetLastError()); - CloseHandle(hFile); - CloseHandle(hFileMapping); - Fail(""); - } - - /* Verify that the size of the file has increased to - * accomidate the MapView. - */ - dwFinalSize = GetFileSize (hFile, NULL); - if ( (dwFinalSize <= dwInitialSize) && (dwFinalSize != MAPPINGSIZE)) - { - CloseHandle(hFile); - CloseHandle(hFileMapping); - Fail("ERROR: Size of the file was expected to " - "increase from \"%d\", to \"%d\".\n ", - dwInitialSize, - MAPPINGSIZE); - } - - /* Write to the MapView and copy the MapViewOfFile - * to buffer, so we can compare with value read from - * file directly. - */ - memcpy(lpMapViewAddress, buf, strlen(buf)); - - /* Read from the File handle. - */ - bRetVal = ReadFile(hFile, - readString, - strlen(buf), - &dwBytesRead, - NULL); - - if (bRetVal == FALSE) - { - Trace("ERROR: %u :unable to read from file handle " - "hFile=0x%lx\n", - GetLastError(), - hFile); - CloseHandle(hFile); - CloseHandle(hFileMapping); - Fail(""); - } - - if (memcmp(buf, readString, strlen(readString)) != 0) - { - CloseHandle(hFile); - CloseHandle(hFileMapping); - Fail("ERROR: Read string from file \"%s\", is " - "not equal to string written through MapView " - "\"%s\".\n", - readString, - ch); - } - - /* Unmap the view of file. - */ - if(UnmapViewOfFile(lpMapViewAddress) == FALSE) - { - Trace("ERROR: Failed to call UnmapViewOfFile API to" - " unmap the view of a file, error code=%u\n", - GetLastError()); - CloseHandle(hFile); - CloseHandle(hFileMapping); - Fail(""); - } - - /* Close handle to create file. - */ - if(CloseHandle(hFile) == FALSE) - { - Trace("ERROR:%u:Failed to call CloseHandle API " - "to close a file handle.", - GetLastError()); - CloseHandle(hFileMapping); - Fail(""); - } - - if(CloseHandle(hFileMapping) == FALSE) - { - Fail("ERROR:%u:Failed to call CloseHandle API " - "to close a file mapping handle.", - GetLastError()); - } - - PAL_Terminate(); - return PASS; -} - - diff --git a/src/pal/tests/palsuite/filemapping_memmgt/MapViewOfFile/test2/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/MapViewOfFile/test2/testinfo.dat deleted file mode 100644 index 13b3f52cf..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/MapViewOfFile/test2/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Filemapping_memmgt -Function = MapViewOfFile -Name = Positive test for MapViewOfFile API with access FILE_MAP_WRITE -TYPE = DEFAULT -EXE1 = mapviewoffile -Description -=Test the MapViewOfFile with access FILE_MAP_WRITE diff --git a/src/pal/tests/palsuite/filemapping_memmgt/MapViewOfFile/test3/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/MapViewOfFile/test3/CMakeLists.txt deleted file mode 100644 index ce8ca02c4..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/MapViewOfFile/test3/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - MapViewOfFile.cpp -) - -add_executable(paltest_mapviewoffile_test3 - ${SOURCES} -) - -add_dependencies(paltest_mapviewoffile_test3 coreclrpal) - -target_link_libraries(paltest_mapviewoffile_test3 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/MapViewOfFile/test3/MapViewOfFile.cpp b/src/pal/tests/palsuite/filemapping_memmgt/MapViewOfFile/test3/MapViewOfFile.cpp deleted file mode 100644 index 63bee768f..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/MapViewOfFile/test3/MapViewOfFile.cpp +++ /dev/null @@ -1,209 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: MapViewOfFile.c -** -** Purpose: Positive test the MapViewOfFile API. -** Call MapViewOfFile with access FILE_MAP_ALL_ACCESS. -** -** Depends: CreateFile, -** GetFileSize, -** memset, -** memcpy, -** memcmp, -** ReadFile, -** UnMapViewOfFile, -** CreateFileMapping, -** CloseHandle. -** -** -**============================================================*/ -#include - -int __cdecl main(int argc, char *argv[]) -{ - - HANDLE hFile; - HANDLE hFileMapping; - LPVOID lpMapViewAddress; - char buf[] = "this is a test string"; - const int MAPPINGSIZE = 2048; - char ch[2048]; - char readString[2048]; - char lpFileName[] = "test.tmp"; - DWORD dwBytesRead; - DWORD dwInitialSize = 0; - DWORD dwFinalSize = 0; - BOOL bRetVal; - - /* Initialize the PAL environment. - */ - if(0 != PAL_Initialize(argc, argv)) - { - return FAIL; - } - - /* Create a file handle with CreateFile. - */ - hFile = CreateFile( lpFileName, - GENERIC_WRITE|GENERIC_READ, - FILE_SHARE_READ|FILE_SHARE_WRITE, - NULL, - CREATE_ALWAYS, - FILE_ATTRIBUTE_NORMAL, - NULL); - if (hFile == INVALID_HANDLE_VALUE) - { - Fail("ERROR: %u :unable to create file \"%s\".\n", - GetLastError(), - lpFileName); - } - - /* Get the initial size of file, for latter tests. - */ - dwInitialSize = GetFileSize (hFile, NULL); - if ( dwInitialSize == INVALID_FILE_SIZE ) - { - Trace("ERROR:%u: The created file \"%s\" has an invalid " - "file size.\n", - GetLastError(), - lpFileName); - CloseHandle(hFile); - Fail(""); - } - - /* Initialize the buffers. - */ - memset(ch, 0, MAPPINGSIZE); - memset(readString, 0, MAPPINGSIZE); - - /* Create a unnamed file-mapping object with file handle FileHandle - * and with PAGE_READWRITE protection. - */ - hFileMapping = CreateFileMapping( - hFile, - NULL, /*not inherited*/ - PAGE_READWRITE, /*read and wite*/ - 0, /*high-order of object size*/ - MAPPINGSIZE, /*low-orger of object size*/ - NULL); /*unnamed object*/ - - if(NULL == hFileMapping) - { - Trace("ERROR:%u: Failed to create File Mapping.\n", - GetLastError()); - CloseHandle(hFile); - Fail(""); - } - - /* maps a view of a file into the address space of the calling process. - */ - lpMapViewAddress = MapViewOfFile( - hFileMapping, - FILE_MAP_ALL_ACCESS, /*access code*/ - 0, /*high order offset*/ - 0, /*low order offset*/ - MAPPINGSIZE); /* number of bytes for map */ - - if(NULL == lpMapViewAddress) - { - Trace("ERROR:%u: Failed to call MapViewOfFile API to map a view" - " of file!\n", - GetLastError()); - CloseHandle(hFile); - CloseHandle(hFileMapping); - Fail(""); - } - - /* Verify that the size of the file has increased to - * accomidate the MapView. - */ - dwFinalSize = GetFileSize (hFile, NULL); - if ( (dwFinalSize <= dwInitialSize) && (dwFinalSize != MAPPINGSIZE)) - { - CloseHandle(hFile); - CloseHandle(hFileMapping); - Fail("ERROR: Size of the file was expected to " - "increase from \"%d\", to \"%d\".\n ", - dwInitialSize, - MAPPINGSIZE); - } - - /* Write to the MapView and copy the MapViewOfFile - * to buffer, so we can compare with value read from - * file directly. - */ - - memcpy(lpMapViewAddress, buf, strlen(buf)); - memcpy(ch, (LPCSTR)lpMapViewAddress, MAPPINGSIZE); - - /* Read from the File handle. - */ - bRetVal = ReadFile(hFile, - readString, - strlen(buf), - &dwBytesRead, - NULL); - - if (bRetVal == FALSE) - { - Trace("ERROR: %u :unable to read from file handle " - "hFile=0x%lx\n", - GetLastError(), - hFile); - CloseHandle(hFile); - CloseHandle(hFileMapping); - Fail(""); - } - - if (memcmp(ch, readString, strlen(readString)) != 0) - { - CloseHandle(hFile); - CloseHandle(hFileMapping); - Fail("ERROR: Read string from file \"%s\", is " - "not equal to string written through MapView " - "\"%s\".\n", - readString, - ch); - } - - /* Unmap the view of file. - */ - if(UnmapViewOfFile(lpMapViewAddress) == FALSE) - { - Trace("ERROR: Failed to call UnmapViewOfFile API to" - " unmap the view of a file, error code=%u\n", - GetLastError()); - CloseHandle(hFile); - CloseHandle(hFileMapping); - Fail(""); - } - - /* Close handle to create file. - */ - if(CloseHandle(hFile) == FALSE) - { - Trace("ERROR:%u:Failed to call CloseHandle API " - "to close a file handle.", - GetLastError()); - CloseHandle(hFileMapping); - Fail(""); - } - - /* Close handle to file mapping. - */ - if(CloseHandle(hFileMapping) == FALSE) - { - Fail("ERROR:%u:Failed to call CloseHandle API " - "to close a file handle.", - GetLastError()); - } - - PAL_Terminate(); - return PASS; -} - - diff --git a/src/pal/tests/palsuite/filemapping_memmgt/MapViewOfFile/test3/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/MapViewOfFile/test3/testinfo.dat deleted file mode 100644 index f76333e7e..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/MapViewOfFile/test3/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Filemapping_memmgt -Function = MapViewOfFile -Name = Positive test MapViewOfFile API with access FILE_MAP_ALL_ACCESS -TYPE = DEFAULT -EXE1 = mapviewoffile -Description -=Test the MapViewOfFile with access FILE_MAP_ALL_ACCESS diff --git a/src/pal/tests/palsuite/filemapping_memmgt/MapViewOfFile/test4/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/MapViewOfFile/test4/CMakeLists.txt deleted file mode 100644 index 29a0a1d8b..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/MapViewOfFile/test4/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - mapviewoffile.cpp -) - -add_executable(paltest_mapviewoffile_test4 - ${SOURCES} -) - -add_dependencies(paltest_mapviewoffile_test4 coreclrpal) - -target_link_libraries(paltest_mapviewoffile_test4 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/MapViewOfFile/test4/mapviewoffile.cpp b/src/pal/tests/palsuite/filemapping_memmgt/MapViewOfFile/test4/mapviewoffile.cpp deleted file mode 100644 index 7f3252144..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/MapViewOfFile/test4/mapviewoffile.cpp +++ /dev/null @@ -1,166 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: MapViewOfFile.c -** -** Purpose: Negative test the MapViewOfFile API. -** Call MapViewOfFile with all access modes, except -** read-only, on a read only map. -** -** Depends: CreateFile, -** CreateFileMapping, -** CloseHandle, -** UnMapViewOfFile. -** - -** -**============================================================*/ -#include - -int __cdecl main(int argc, char *argv[]) -{ - - HANDLE hFile; - BOOL err; - HANDLE hFileMapping; - LPVOID lpMapViewAddress; - DWORD dwBytesWritten; - const int MAPPINGSIZE = 2048; - char buf[] = "this is a test string"; - char lpFileName[] = "test.tmp"; - - /* Initialize the PAL environment. - */ - if(0 != PAL_Initialize(argc, argv)) - { - return FAIL; - } - - /* Create a file handle with CreateFile. - */ - hFile = CreateFile( lpFileName, - GENERIC_WRITE|GENERIC_READ, - FILE_SHARE_READ|FILE_SHARE_WRITE, - NULL, - CREATE_ALWAYS, - FILE_ATTRIBUTE_NORMAL, - NULL); - if (hFile == INVALID_HANDLE_VALUE) - { - Fail("ERROR: %u :unable to create file \"%s\".\n", - GetLastError(), - lpFileName); - } - - /* Write to the File handle. - */ - err = WriteFile(hFile, - buf, - strlen(buf), - &dwBytesWritten, - NULL); - - if ( !FlushFileBuffers( hFile ) ) - { - CloseHandle(hFile); - Fail("ERROR: Unable to flush the buffers\n"); - } - - if (err == FALSE) - { - Trace("ERROR: %u :unable to write to file handle " - "hFile=0x%lx\n", - GetLastError(), - hFile); - CloseHandle(hFile); - Fail(""); - } - - /* Create a unnamed file-mapping object with file handle FileHandle - * and with PAGE_READWRITE protection. - */ - hFileMapping = CreateFileMapping( - hFile, - NULL, /*not inherited*/ - PAGE_READONLY, /*read and wite*/ - 0, /*high-order of object size*/ - 0, /*low-orger of object size*/ - NULL); /*unnamed object*/ - - if(NULL == hFileMapping) - { - Trace("ERROR:%u: Failed to create File Mapping.\n", - GetLastError()); - CloseHandle(hFile); - Fail(""); - } - - /* map a writeable view of a file to a read-only file map. - */ - lpMapViewAddress = MapViewOfFile( - hFileMapping, - FILE_MAP_WRITE, /* access code */ - 0, /* high order offset */ - 0, /* low order offset */ - MAPPINGSIZE); /* number of bytes for map */ - - if(NULL != lpMapViewAddress) - { - Trace("ERROR:%u: Able to create a writeable MapViewOfFile" - " to a read-only file.\n", - GetLastError()); - CloseHandle(hFile); - CloseHandle(hFileMapping); - UnmapViewOfFile(lpMapViewAddress); - Fail(""); - } - - /* map an all access view of a file to a read-only file map. - */ - lpMapViewAddress = MapViewOfFile( - hFileMapping, - FILE_MAP_ALL_ACCESS, /* access code */ - 0, /* high order offset */ - 0, /* low order offset */ - MAPPINGSIZE); /* number of bytes for map */ - - if(NULL != lpMapViewAddress) - { - Trace("ERROR:%u: Able to create an all access MapViewOfFile" - " to a read-only file.\n", - GetLastError()); - CloseHandle(hFile); - CloseHandle(hFileMapping); - UnmapViewOfFile(lpMapViewAddress); - Fail(""); - } - - /* map an copy view of a file to a read-only file map. - */ - lpMapViewAddress = MapViewOfFile( - hFileMapping, - FILE_MAP_COPY, /* access code */ - 0, /* high order offset */ - 0, /* low order offset */ - MAPPINGSIZE); /* number of bytes for map */ - - if(NULL != lpMapViewAddress) - { - Trace("ERROR:%u: Able to create a copy access MapViewOfFile " - "to a read-only file.\n", - GetLastError()); - CloseHandle(hFile); - CloseHandle(hFileMapping); - Fail(""); - } - - /* Clean-up and Teminate. */ - CloseHandle(hFile); - CloseHandle(hFileMapping); - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/filemapping_memmgt/MapViewOfFile/test4/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/MapViewOfFile/test4/testinfo.dat deleted file mode 100644 index 37655eda5..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/MapViewOfFile/test4/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Filemapping_memmgt -Function = MapViewOfFile -Name = Negative test MapViewOfFile API -TYPE = DEFAULT -EXE1 = mapviewoffile -Description -= Negative test the MapViewOfFile API. -= Call MapViewOfFile with all access modes, -= except read-only, on a read only map. diff --git a/src/pal/tests/palsuite/filemapping_memmgt/MapViewOfFile/test5/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/MapViewOfFile/test5/CMakeLists.txt deleted file mode 100644 index 836a3c961..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/MapViewOfFile/test5/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - mapviewoffile.cpp -) - -add_executable(paltest_mapviewoffile_test5 - ${SOURCES} -) - -add_dependencies(paltest_mapviewoffile_test5 coreclrpal) - -target_link_libraries(paltest_mapviewoffile_test5 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/MapViewOfFile/test5/mapviewoffile.cpp b/src/pal/tests/palsuite/filemapping_memmgt/MapViewOfFile/test5/mapviewoffile.cpp deleted file mode 100644 index 219b3fa12..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/MapViewOfFile/test5/mapviewoffile.cpp +++ /dev/null @@ -1,131 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: MapViewOfFile.c -** -** Purpose: Negative test the MapViewOfFile API. -** Passing invalid values for the hFileMappingObject. -** -** Depends: CreatePipe, -** CreateFile, -** CreateFileMapping, -** CloseHandle. -** - -** -**============================================================*/ -#include - -int __cdecl main(int argc, char *argv[]) -{ - - const int MAPPINGSIZE = 2048; - HANDLE hFileMapping; - LPVOID lpMapViewAddress; - HANDLE hReadPipe = NULL; - HANDLE hWritePipe = NULL; - BOOL bRetVal; - - SECURITY_ATTRIBUTES lpPipeAttributes; - - /* Initialize the PAL environment. - */ - if(0 != PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - /* Attempt to create a MapViewOfFile with a NULL handle. - */ - hFileMapping = NULL; - - lpMapViewAddress = MapViewOfFile( - hFileMapping, - FILE_MAP_WRITE, /* access code */ - 0, /* high order offset */ - 0, /* low order offset */ - MAPPINGSIZE); /* number of bytes for map */ - - if((NULL != lpMapViewAddress) && - (GetLastError() != ERROR_INVALID_HANDLE)) - { - Trace("ERROR:%u: Able to create a MapViewOfFile with " - "hFileMapping=0x%lx.\n", - GetLastError()); - UnmapViewOfFile(lpMapViewAddress); - Fail(""); - } - - /* Attempt to create a MapViewOfFile with an invalid handle. - */ - hFileMapping = INVALID_HANDLE_VALUE; - - lpMapViewAddress = MapViewOfFile( - hFileMapping, - FILE_MAP_WRITE, /* access code */ - 0, /* high order offset */ - 0, /* low order offset */ - MAPPINGSIZE); /* number of bytes for map */ - - if((NULL != lpMapViewAddress) && - (GetLastError() != ERROR_INVALID_HANDLE)) - { - Trace("ERROR:%u: Able to create a MapViewOfFile with " - "hFileMapping=0x%lx.\n", - GetLastError()); - UnmapViewOfFile(lpMapViewAddress); - Fail(""); - } - - /* Setup SECURITY_ATTRIBUTES structure for CreatePipe. - */ - lpPipeAttributes.nLength = sizeof(lpPipeAttributes); - lpPipeAttributes.lpSecurityDescriptor = NULL; - lpPipeAttributes.bInheritHandle = TRUE; - - /* Create a Pipe. - */ - bRetVal = CreatePipe(&hReadPipe, /* read handle*/ - &hWritePipe, /* write handle */ - &lpPipeAttributes,/* security attributes*/ - 0); /* pipe size*/ - if (bRetVal == FALSE) - { - Fail("ERROR: %ld :Unable to create pipe\n", - GetLastError()); - } - - /* Attempt creating a MapViewOfFile with a Pipe Handle. - */ - lpMapViewAddress = MapViewOfFile( - hReadPipe, - FILE_MAP_WRITE, /* access code */ - 0, /* high order offset */ - 0, /* low order offset */ - MAPPINGSIZE); /* number of bytes for map */ - - if((NULL != lpMapViewAddress) && - (GetLastError() != ERROR_INVALID_HANDLE)) - { - Trace("ERROR:%u: Able to create a MapViewOfFile with " - "hFileMapping=0x%lx.\n", - GetLastError()); - CloseHandle(hReadPipe); - CloseHandle(hWritePipe); - UnmapViewOfFile(lpMapViewAddress); - Fail(""); - } - - /* Clean-up and Terminate the PAL. - */ - CloseHandle(hReadPipe); - CloseHandle(hWritePipe); - PAL_Terminate(); - return PASS; -} - - diff --git a/src/pal/tests/palsuite/filemapping_memmgt/MapViewOfFile/test5/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/MapViewOfFile/test5/testinfo.dat deleted file mode 100644 index e3ecb3277..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/MapViewOfFile/test5/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Filemapping_memmgt -Function = MapViewOfFile -Name = Negative test for MapViewOfFile API. -TYPE = DEFAULT -EXE1 = mapviewoffile -Description -= Negative test the MapViewOfFile API. -= Passing invalid values for the hFileMappingObject. diff --git a/src/pal/tests/palsuite/filemapping_memmgt/MapViewOfFile/test6/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/MapViewOfFile/test6/CMakeLists.txt deleted file mode 100644 index e3a7d09df..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/MapViewOfFile/test6/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - mapviewoffile.cpp -) - -add_executable(paltest_mapviewoffile_test6 - ${SOURCES} -) - -add_dependencies(paltest_mapviewoffile_test6 coreclrpal) - -target_link_libraries(paltest_mapviewoffile_test6 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/MapViewOfFile/test6/mapviewoffile.cpp b/src/pal/tests/palsuite/filemapping_memmgt/MapViewOfFile/test6/mapviewoffile.cpp deleted file mode 100644 index f7d7302a4..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/MapViewOfFile/test6/mapviewoffile.cpp +++ /dev/null @@ -1,85 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: MapViewOfFile.c -** -** Purpose: Positivve test the MapViewOfFile API. -** Mapping a pagefile allocation into memory -** -** Depends: CreateFileMappingW, -** UnmapViewOfFile -** CloseHandle. -** - -** -**============================================================*/ -#include - -int __cdecl main(int argc, char *argv[]) -{ - - const int MAPPINGSIZE = 2048; - HANDLE hFileMapping; - LPVOID lpMapViewAddress; - char *p; - int i; - - /* Initialize the PAL environment. - */ - if(0 != PAL_Initialize(argc, argv)) - { - return FAIL; - } - - hFileMapping = CreateFileMappingW(INVALID_HANDLE_VALUE, - NULL, - PAGE_READWRITE, - 0, - MAPPINGSIZE, - NULL); - - if (hFileMapping == NULL) { - Trace("ERROR:%u: CreateFileMappingW() failed\n", GetLastError()); - Fail(""); - } - - - lpMapViewAddress = MapViewOfFile( - hFileMapping, - FILE_MAP_WRITE, /* access code */ - 0, /* high order offset */ - 0, /* low order offset */ - MAPPINGSIZE); /* number of bytes for map */ - - if(NULL == lpMapViewAddress) - { - Trace("ERROR:%u: MapViewOfFile() failed.\n", - GetLastError()); - CloseHandle(hFileMapping); - Fail(""); - } - - p = (char *)lpMapViewAddress; - for (i=0; i - -int __cdecl main(int argc, char *argv[]) -{ - HANDLE FileMappingHandle; - HANDLE OpenFileMappingHandle; - HANDLE lpMapViewAddress; - const int LOWORDERSIZE = 1024; - char buf[] = "this is a test"; - char MapObject[] = "myMappingObject"; - char ch[1024]; - int err; - int RetVal = PASS; - - /* Initialize the PAL environment. - */ - err = PAL_Initialize(argc, argv); - if(0 != err) - { - return FAIL; - } - - - /* Create a named file-mapping object with - * file handle FileHandle. - */ - FileMappingHandle = CreateFileMapping( - INVALID_HANDLE_VALUE, - NULL, /* not inherited */ - PAGE_READWRITE, /* read and write */ - 0, /* high-order size */ - LOWORDERSIZE, /* low-order size */ - MapObject); /* named object */ - - if(NULL == FileMappingHandle) - { - Fail("ERROR:%u:Failed to call CreateFileMapping to " - "create a mapping object.\n", - GetLastError()); - } - if(GetLastError() == ERROR_ALREADY_EXISTS) - { - Trace("ERROR:File mapping object already exists\n"); - RetVal = FAIL; - goto CleanUpOne; - } - - /* Open a named file-mapping object with - * FILE_MAP_ALL_ACCESS access. - */ - OpenFileMappingHandle = OpenFileMapping( - FILE_MAP_ALL_ACCESS, - TRUE, - MapObject ); - - if(NULL == OpenFileMappingHandle) - { - Trace("ERROR:%u:Failed to Call OpenFileMapping API!\n", - GetLastError()); - RetVal = FAIL; - goto CleanUpOne; - } - - /* Test the opened map view. - */ - lpMapViewAddress = MapViewOfFile( - OpenFileMappingHandle, - FILE_MAP_ALL_ACCESS, /* access code */ - 0, /* high order offset */ - 0, /* low order offset */ - LOWORDERSIZE); /* number of bytes for map */ - - if(NULL == lpMapViewAddress) - { - Trace("ERROR:%u: Failed to call MapViewOfFile " - "API to map a view of file!\n", - GetLastError()); - RetVal = FAIL; - goto CleanUpTwo; - } - - /* Write to the Map View. - */ - memcpy(lpMapViewAddress, buf, strlen(buf)); - - /* Read from the Map View. - */ - memcpy(ch, (LPCSTR)lpMapViewAddress, LOWORDERSIZE); - - /* Compare what was written to the Map View, - * to what was read. - */ - if (memcmp(ch, buf, strlen(buf))!= 0) - { - Trace("ERROR: MapViewOfFile not equal to file contents " - "retrieved \"%s\", expected \"%s\".\n", - ch, buf); - RetVal = FAIL; - goto CleanUpThree; - - } - -CleanUpThree: - - /* Unmap the view of file. - */ - if ( UnmapViewOfFile(lpMapViewAddress) == FALSE ) - { - Trace("ERROR:%u: Failed to UnmapViewOfFile of \"%0x%lx\".\n", - GetLastError(), - lpMapViewAddress); - RetVal = FAIL; - } - -CleanUpTwo: - - /* Close Handle to opend file mapping. - */ - if ( CloseHandle(OpenFileMappingHandle) == 0 ) - { - Trace("ERROR:%u: Failed to CloseHandle \"0x%lx\".\n", - GetLastError(), - OpenFileMappingHandle); - RetVal = FAIL; - } - -CleanUpOne: - - /* Close Handle to create file mapping. - */ - if ( CloseHandle(FileMappingHandle) == 0 ) - { - Trace("ERROR:%u: Failed to CloseHandle \"0x%lx\".\n", - GetLastError(), - FileMappingHandle); - RetVal = FAIL; - } - - - /* Terminat the PAL.*/ - PAL_TerminateEx(RetVal); - return RetVal; -} diff --git a/src/pal/tests/palsuite/filemapping_memmgt/OpenFileMappingA/test1/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/OpenFileMappingA/test1/testinfo.dat deleted file mode 100644 index 010f2fe27..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/OpenFileMappingA/test1/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Filemapping_memmgt -Function = OpenFileMappingA -Name = Positive test for OpenFileMappingA API with FILE_MAP_ALL_ACCESS access -TYPE = DEFAULT -EXE1 = openfilemappinga -Description -=Test the OpenFileMappingA with FILE_MAP_ALL_ACCESS access diff --git a/src/pal/tests/palsuite/filemapping_memmgt/OpenFileMappingA/test2/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/OpenFileMappingA/test2/CMakeLists.txt deleted file mode 100644 index f8c08e9c9..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/OpenFileMappingA/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - OpenFileMappingA.cpp -) - -add_executable(paltest_openfilemappinga_test2 - ${SOURCES} -) - -add_dependencies(paltest_openfilemappinga_test2 coreclrpal) - -target_link_libraries(paltest_openfilemappinga_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/OpenFileMappingA/test2/OpenFileMappingA.cpp b/src/pal/tests/palsuite/filemapping_memmgt/OpenFileMappingA/test2/OpenFileMappingA.cpp deleted file mode 100644 index 5e41a9202..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/OpenFileMappingA/test2/OpenFileMappingA.cpp +++ /dev/null @@ -1,214 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: openfilemappinga.c (test 2) -** -** Purpose: Positive test the OpenFileMapping API. -** Call OpenFileMapping to open a named file-mapping -** object with FILE_MAP_WRITE access -** -** -**============================================================*/ -#include - -int __cdecl main(int argc, char *argv[]) -{ - HANDLE FileMappingHandle; - HANDLE OpenFileMappingHandle; - HANDLE lpMapViewAddress; - HANDLE OpenFileMappingHandle2; - HANDLE lpMapViewAddress2; - const int LOWORDERSIZE = 1024; - char MapObject[] = "myMappingObject"; - char buf[] = "this is a test"; - char ch[1024]; - int RetVal = PASS; - - - /* Initialize the PAL environment. - */ - if(0 != PAL_Initialize(argc, argv)) - { - return FAIL; - } - - /* Create a named file-mapping object with file handle FileHandle. - */ - FileMappingHandle = CreateFileMapping( - INVALID_HANDLE_VALUE, - NULL, /* not inherited */ - PAGE_READWRITE, /* read and write */ - 0, /* high-order size */ - LOWORDERSIZE, /* low-order size */ - MapObject); /* named object */ - - - if(NULL == FileMappingHandle) - { - Fail("\nFailed to call CreateFileMapping to create " - "a mapping object!\n"); - } - if(GetLastError() == ERROR_ALREADY_EXISTS) - { - Trace("\nFile mapping object already exists!\n"); - RetVal = FAIL; - goto CleanUpOne; - } - - /* Open a named file-mapping object with FILE_MAP_WRITE access. - */ - OpenFileMappingHandle = OpenFileMapping( - FILE_MAP_WRITE, - FALSE, - MapObject); - - if(NULL == OpenFileMappingHandle) - { - Trace("\nFailed to Call OpenFileMapping API!\n"); - RetVal = FAIL; - goto CleanUpOne; - } - - /* Open a named file-mapping object with - * FILE_MAP_ALL_ACCESS access, to verify - * the FILE_MAP_WRITE access map. - */ - OpenFileMappingHandle2 = OpenFileMapping( - FILE_MAP_ALL_ACCESS, - FALSE, - MapObject); - - if(NULL == OpenFileMappingHandle2) - { - Trace("\nFailed to Call OpenFileMapping API!\n"); - RetVal = FAIL; - goto CleanUpTwo; - } - - /* Create map view of the open mapping that has - * FILE_MAP_WRITE access. - */ - lpMapViewAddress = MapViewOfFile( - OpenFileMappingHandle, - FILE_MAP_WRITE, /* access code */ - 0, /* high order offset */ - 0, /* low order offset */ - LOWORDERSIZE); /* number of bytes for map */ - - if(NULL == lpMapViewAddress) - { - Trace("ERROR:%u: Failed to call MapViewOfFile " - "API to map a view of file!\n", - GetLastError()); - RetVal = FAIL; - goto CleanUpThree; - } - - /* Create map view of the open mapping that has - * FILE_MAP_ALL_ACCESS access. - */ - lpMapViewAddress2 = MapViewOfFile( - OpenFileMappingHandle2, - FILE_MAP_ALL_ACCESS, /* access code */ - 0, /* high order offset */ - 0, /* low order offset */ - LOWORDERSIZE); /* number of bytes for map */ - - if(NULL == lpMapViewAddress2) - { - Trace("ERROR:%u: Failed to call MapViewOfFile " - "API to map a view of file!\n", - GetLastError()); - RetVal = FAIL; - goto CleanUpFour; - } - - /* Write to the Map View. - */ - memcpy(lpMapViewAddress, buf, strlen(buf)); - - /* Read from the Map View. - */ - memcpy(ch, (LPCSTR)lpMapViewAddress, LOWORDERSIZE); - - /* Compare what was written to the Map View, - * to what was read. - */ - if (memcmp(ch, buf, strlen(buf))!= 0) - { - Fail("ERROR: MapViewOfFile not equal to file contents " - "retrieved \"%s\", expected \"%s\".\n", - ch, buf); - RetVal = FAIL; - goto CleanUpFive; - } - -CleanUpFive: - - /* Unmap the view of file. - */ - if ( UnmapViewOfFile(lpMapViewAddress2) == FALSE ) - { - Trace("ERROR:%u: Failed to UnmapViewOfFile of \"%0x%lx\".\n", - GetLastError(), - lpMapViewAddress2); - RetVal = FAIL; - } - -CleanUpFour: - - /* Unmap the view of file. - */ - if ( UnmapViewOfFile(lpMapViewAddress) == FALSE ) - { - Trace("ERROR:%u: Failed to UnmapViewOfFile of \"%0x%lx\".\n", - GetLastError(), - lpMapViewAddress); - RetVal = FAIL; - } - -CleanUpThree: - - /* Close Handle to opened file mapping. - */ - if ( CloseHandle(OpenFileMappingHandle2) == 0 ) - { - Trace("ERROR:%u: Failed to CloseHandle \"0x%lx\".\n", - GetLastError(), - OpenFileMappingHandle2); - RetVal = FAIL; - } - -CleanUpTwo: - - /* Close Handle to opened file mapping. - */ - if ( CloseHandle(OpenFileMappingHandle) == 0 ) - { - Trace("ERROR:%u: Failed to CloseHandle \"0x%lx\".\n", - GetLastError(), - OpenFileMappingHandle); - RetVal = FAIL; - } - -CleanUpOne: - - /* Close Handle to create file mapping. - */ - if ( CloseHandle(FileMappingHandle) == 0 ) - { - Trace("ERROR:%u: Failed to CloseHandle \"0x%lx\".\n", - GetLastError(), - FileMappingHandle); - RetVal = FAIL; - } - - - /* Terminate the PAL. - */ - PAL_TerminateEx(RetVal); - return RetVal; -} diff --git a/src/pal/tests/palsuite/filemapping_memmgt/OpenFileMappingA/test2/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/OpenFileMappingA/test2/testinfo.dat deleted file mode 100644 index 2a02128b6..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/OpenFileMappingA/test2/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Filemapping_memmgt -Function = OpenFileMappingA -Name = Positive test for OpenFileMappingA API with FILE_MAP_WRITE access -TYPE = DEFAULT -EXE1 = openfilemappinga -Description -=Test the OpenFileMappingA with FILE_MAP_WRITE access diff --git a/src/pal/tests/palsuite/filemapping_memmgt/OpenFileMappingA/test3/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/OpenFileMappingA/test3/CMakeLists.txt deleted file mode 100644 index 7357262e1..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/OpenFileMappingA/test3/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - OpenFileMappingA.cpp -) - -add_executable(paltest_openfilemappinga_test3 - ${SOURCES} -) - -add_dependencies(paltest_openfilemappinga_test3 coreclrpal) - -target_link_libraries(paltest_openfilemappinga_test3 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/OpenFileMappingA/test3/OpenFileMappingA.cpp b/src/pal/tests/palsuite/filemapping_memmgt/OpenFileMappingA/test3/OpenFileMappingA.cpp deleted file mode 100644 index b01a3e8c0..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/OpenFileMappingA/test3/OpenFileMappingA.cpp +++ /dev/null @@ -1,217 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: openfilemappinga.c -** -** Purpose: Positive test the OpenFileMapping API. -** Call OpenFileMapping to open a named file-mapping -** object with FILE_MAP_READ access -** -** -**============================================================*/ -#include - - -int __cdecl main(int argc, char *argv[]) -{ - - HANDLE FileMappingHandle; - HANDLE OpenFileMappingHandle; - HANDLE OpenFileMappingHandle2; - HANDLE lpMapViewAddress; - HANDLE lpMapViewAddress2; - const int LOWORDERSIZE = 1024; - char buf[] = "this is a test"; - char MapObject[] = "myMappingObject"; - char ch[1024]; - int RetVal = PASS; - - /* Initialize the PAL environment. - */ - if(0 != PAL_Initialize(argc, argv)) - { - return FAIL; - } - - /* Create a named file-mapping object with file handle FileHandle. - */ - FileMappingHandle = CreateFileMapping( - INVALID_HANDLE_VALUE, - NULL, /* Not inherited */ - PAGE_READWRITE, /* Read only */ - 0, /* High-order size */ - LOWORDERSIZE, /* Must be none 0 */ - MapObject); /* Named object */ - - - if(NULL == FileMappingHandle) - { - Fail("ERROR:%u:Failed to call CreateFileMapping to create " - "mapping object = \"%s\".\n", - GetLastError(), - MapObject); - } - if(GetLastError() == ERROR_ALREADY_EXISTS) - { - Trace("ERROR:File mapping object \"%s\" already exists!\n", - MapObject); - RetVal = FAIL; - goto CleanUpOne; - } - - /* Open a named file-mapping object with - * FILE_MAP_READ access. - */ - OpenFileMappingHandle = OpenFileMapping( - FILE_MAP_READ, - 0, - MapObject); - - if(NULL == OpenFileMappingHandle) - { - Trace("ERROR:%u: Failed to Call OpenFileMapping API.\n"); - RetVal = FAIL; - goto CleanUpOne; - } - - /* Open a named file-mapping object with - * FILE_MAP_ALL_ACCESS access, to verify the - * READ-ONLY Map view. - */ - OpenFileMappingHandle2 = OpenFileMapping( - FILE_MAP_ALL_ACCESS, - 0, - MapObject); - - if(NULL == OpenFileMappingHandle2) - { - Trace("Failed to Call OpenFileMapping API!\n"); - RetVal = FAIL; - goto CleanUpTwo; - } - - /* Test the opened map view. - */ - lpMapViewAddress = MapViewOfFile( - OpenFileMappingHandle, - FILE_MAP_READ, /* access code */ - 0, /* high order offset */ - 0, /* low order offset */ - LOWORDERSIZE); /* number of bytes for map */ - - if(NULL == lpMapViewAddress) - { - Trace("ERROR:%u: Failed to call MapViewOfFile " - "API to map a view of file!\n", - GetLastError()); - RetVal = FAIL; - goto CleanUpThree; - } - - /* Open the second Map view to verify the writing - * of the READ-ONLY Map view. - */ - lpMapViewAddress2 = MapViewOfFile( - OpenFileMappingHandle2, - FILE_MAP_ALL_ACCESS, /* access code */ - 0, /* high order offset */ - 0, /* low order offset */ - LOWORDERSIZE); /* number of bytes for map */ - - if(NULL == lpMapViewAddress2) - { - Trace("ERROR:%u: Failed to call MapViewOfFile " - "API to map a view of file!\n", - GetLastError()); - RetVal = FAIL; - goto CleanUpFour; - } - - /* Write to the ALL_ACCESS Map View. - */ - memcpy(lpMapViewAddress2, buf, strlen(buf)); - - /* Read from the READ-ONLY Map View. - */ - memcpy(ch, (LPCSTR)lpMapViewAddress, LOWORDERSIZE); - - /* Compare what was written to the Map View, - * to what was read. - */ - if (memcmp(ch, buf, strlen(buf))!= 0) - { - Trace("ERROR: MapViewOfFile not equal to file contents " - "retrieved \"%s\", expected \"%s\".\n", - ch, buf); - RetVal = FAIL; - goto CleanUpFive; - } - -CleanUpFive: - - /* Unmap the view of file. - */ - if ( UnmapViewOfFile(lpMapViewAddress2) == FALSE ) - { - Trace("ERROR:%u: Failed to UnmapViewOfFile of \"%0x%lx\".\n", - GetLastError(), - lpMapViewAddress2); - RetVal = FAIL; - } - -CleanUpFour: - - /* Unmap the view of file. - */ - if ( UnmapViewOfFile(lpMapViewAddress) == FALSE ) - { - Trace("ERROR:%u: Failed to UnmapViewOfFile of \"%0x%lx\".\n", - GetLastError(), - lpMapViewAddress); - RetVal = FAIL; - } - -CleanUpThree: - - /* Close Handle to opened file mapping. - */ - if ( CloseHandle(OpenFileMappingHandle2) == 0 ) - { - Trace("ERROR:%u: Failed to CloseHandle \"0x%lx\".\n", - GetLastError(), - OpenFileMappingHandle2); - RetVal = FAIL; - } - -CleanUpTwo: - - /* Close Handle to opened file mapping. - */ - if ( CloseHandle(OpenFileMappingHandle) == 0 ) - { - Trace("ERROR:%u: Failed to CloseHandle \"0x%lx\".\n", - GetLastError(), - OpenFileMappingHandle); - RetVal = FAIL; - } - -CleanUpOne: - - /* Close Handle to create file mapping. - */ - if ( CloseHandle(FileMappingHandle) == 0 ) - { - Trace("ERROR:%u: Failed to CloseHandle \"0x%lx\".\n", - GetLastError(), - FileMappingHandle); - RetVal = FAIL; - } - - /* Terminate the PAL. - */ - PAL_TerminateEx(RetVal); - return RetVal; -} diff --git a/src/pal/tests/palsuite/filemapping_memmgt/OpenFileMappingA/test3/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/OpenFileMappingA/test3/testinfo.dat deleted file mode 100644 index 4aff853f9..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/OpenFileMappingA/test3/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Filemapping_memmgt -Function = OpenFileMappingA -Name = Positive test for OpenFileMappingA API with FILE_MAP_READ access -TYPE = DEFAULT -EXE1 = openfilemappinga -Description -=Test the OpenFileMappingA with FILE_MAP_READ access diff --git a/src/pal/tests/palsuite/filemapping_memmgt/OpenFileMappingW/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/OpenFileMappingW/CMakeLists.txt deleted file mode 100644 index 1962ade35..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/OpenFileMappingW/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) -add_subdirectory(test3) - diff --git a/src/pal/tests/palsuite/filemapping_memmgt/OpenFileMappingW/test1/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/OpenFileMappingW/test1/CMakeLists.txt deleted file mode 100644 index 25a6b4ca5..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/OpenFileMappingW/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - OpenFileMappingW.cpp -) - -add_executable(paltest_openfilemappingw_test1 - ${SOURCES} -) - -add_dependencies(paltest_openfilemappingw_test1 coreclrpal) - -target_link_libraries(paltest_openfilemappingw_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/OpenFileMappingW/test1/OpenFileMappingW.cpp b/src/pal/tests/palsuite/filemapping_memmgt/OpenFileMappingW/test1/OpenFileMappingW.cpp deleted file mode 100644 index 079af4a5c..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/OpenFileMappingW/test1/OpenFileMappingW.cpp +++ /dev/null @@ -1,155 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: openfilemappingw.c (test 1) -** -** Purpose: Positive test the OpenFileMapping API. -** Call OpenFileMapping to open a named file-mapping -** object with FILE_MAP_ALL_ACCESS access -** -** -**============================================================*/ - -#define UNICODE -#include - -int __cdecl main(int argc, char *argv[]) -{ - - HANDLE lpMapViewAddress; - char buf[] = "this is a test"; - char ch[1024]; - - HANDLE FileMappingHandle; - HANDLE OpenFileMappingHandle; - const int LOWORDERSIZE = 1024; - int RetVal = PASS; - WCHAR wpMappingFileObject[] = {'m','y','O','b','j','e','c','t','\0'}; - - /* Initialize the PAL environment. - */ - if(0 != PAL_Initialize(argc, argv)) - { - return FAIL; - } - - /* Create a unnamed file-mapping object with file handle FileHandle. - */ - FileMappingHandle = CreateFileMapping( - INVALID_HANDLE_VALUE, - NULL, /* Not inherited*/ - PAGE_READWRITE, /* Read and write*/ - 0, /* High-order size*/ - LOWORDERSIZE, /* Low-order size*/ - wpMappingFileObject);/* Named object*/ - - - if(NULL == FileMappingHandle) - { - Fail("\nFailed to call CreateFileMapping to create a " - "mapping object!\n"); - } - if(GetLastError() == ERROR_ALREADY_EXISTS) - { - Trace("\nFile mapping object already exists!\n"); - RetVal = FAIL; - goto CleanUpOne; - } - - /* Open a named file-mapping object with FILE_MAP_ALL_ACCESS access. - */ - OpenFileMappingHandle = OpenFileMapping( - FILE_MAP_ALL_ACCESS, - FALSE, - wpMappingFileObject); - - if(NULL == OpenFileMappingHandle) - { - Trace("\nFailed to Call OpenFileMapping API!\n"); - RetVal = FAIL; - goto CleanUpOne; - } - - /* Test the opened map view. - */ - lpMapViewAddress = MapViewOfFile( - OpenFileMappingHandle, - FILE_MAP_ALL_ACCESS, /* access code */ - 0, /* high order offset */ - 0, /* low order offset */ - LOWORDERSIZE); /* number of bytes for map */ - - if(NULL == lpMapViewAddress) - { - Trace("ERROR:%u: Failed to call MapViewOfFile " - "API to map a view of file!\n", - GetLastError()); - RetVal = FAIL; - goto CleanUpTwo; - } - - /* Write to the Map View. - */ - memcpy(lpMapViewAddress, buf, strlen(buf)); - - /* Read from the Map View. - */ - memcpy(ch, (LPCSTR)lpMapViewAddress, LOWORDERSIZE); - - /* Compare what was written to the Map View, - * to what was read. - */ - if (memcmp(ch, buf, strlen(buf))!= 0) - { - Trace("ERROR: MapViewOfFile not equal to file contents " - "retrieved \"%s\", expected \"%s\".\n", - ch, buf); - RetVal = FAIL; - goto CleanUpThree; - } - -CleanUpThree: - - /* Unmap the view of file. - */ - if ( UnmapViewOfFile(lpMapViewAddress) == FALSE ) - { - Trace("ERROR:%u: Failed to UnmapViewOfFile of \"%0x%lx\".\n", - GetLastError(), - lpMapViewAddress); - RetVal = FAIL; - } - -CleanUpTwo: - - /* Close Handle to opend file mapping. - */ - if ( CloseHandle(OpenFileMappingHandle) == 0 ) - { - Trace("ERROR:%u: Failed to CloseHandle \"0x%lx\".\n", - GetLastError(), - OpenFileMappingHandle); - RetVal = FAIL; - } - -CleanUpOne: - - /* Close Handle to create file mapping. - */ - if ( CloseHandle(FileMappingHandle) == 0 ) - { - Trace("ERROR:%u: Failed to CloseHandle \"0x%lx\".\n", - GetLastError(), - FileMappingHandle); - RetVal = FAIL; - } - - /* Terminate the PAL. - */ - PAL_TerminateEx(RetVal); - return RetVal; -} - diff --git a/src/pal/tests/palsuite/filemapping_memmgt/OpenFileMappingW/test1/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/OpenFileMappingW/test1/testinfo.dat deleted file mode 100644 index e67f4775f..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/OpenFileMappingW/test1/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Filemapping_memmgt -Function = OpenFileMappingW -Name = Positive test for OpenFileMappingW API -TYPE = DEFAULT -EXE1 = openfilemappingw -Description -=Test the OpenFileMappingW with FILE_MAP_ALL_ACCESS access diff --git a/src/pal/tests/palsuite/filemapping_memmgt/OpenFileMappingW/test2/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/OpenFileMappingW/test2/CMakeLists.txt deleted file mode 100644 index f7ca6cf44..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/OpenFileMappingW/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - OpenFileMappingW.cpp -) - -add_executable(paltest_openfilemappingw_test2 - ${SOURCES} -) - -add_dependencies(paltest_openfilemappingw_test2 coreclrpal) - -target_link_libraries(paltest_openfilemappingw_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/OpenFileMappingW/test2/OpenFileMappingW.cpp b/src/pal/tests/palsuite/filemapping_memmgt/OpenFileMappingW/test2/OpenFileMappingW.cpp deleted file mode 100644 index e6a69651f..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/OpenFileMappingW/test2/OpenFileMappingW.cpp +++ /dev/null @@ -1,217 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: openfilemappingw.c (test 2) -** -** Purpose: Positive test the OpenFileMapping API. -** Call OpenFileMapping to open a named file-mapping -** object with FILE_MAP_WRITE access -** -** -**============================================================*/ -#define UNICODE -#include - -int __cdecl main(int argc, char *argv[]) -{ - HANDLE FileMappingHandle; - HANDLE OpenFileMappingHandle; - HANDLE lpMapViewAddress; - HANDLE OpenFileMappingHandle2; - HANDLE lpMapViewAddress2; - const int LOWORDERSIZE = 1024; - WCHAR MapObject[] = {'m','y','O','b','j','e','c','t','\0'}; - char buf[] = "this is a test"; - char ch[1024]; - int RetVal = PASS; - - - /* Initialize the PAL environment. - */ - if(0 != PAL_Initialize(argc, argv)) - { - return FAIL; - } - - /* Create a named file-mapping object with file handle FileHandle. - */ - FileMappingHandle = CreateFileMapping( - INVALID_HANDLE_VALUE, - NULL, /* not inherited */ - PAGE_READWRITE, /* read and wite */ - 0, /* high-order size */ - LOWORDERSIZE, /* low-order size */ - MapObject); /* named object */ - - if(NULL == FileMappingHandle) - { - Fail("\nFailed to call CreateFileMapping to " - "create a mapping object!\n"); - } - if(GetLastError() == ERROR_ALREADY_EXISTS) - { - Trace("\nFile mapping object already exists!\n"); - RetVal = FAIL; - goto CleanUpOne; - } - - /* Open a named file-mapping object with FILE_MAP_WRITE access. - */ - OpenFileMappingHandle = OpenFileMapping( - FILE_MAP_WRITE, - FALSE, - MapObject); - - if(NULL == OpenFileMappingHandle) - { - Trace("\nFailed to Call OpenFileMappingW API!\n"); - RetVal = FAIL; - goto CleanUpOne; - } - - /* Open a named file-mapping object with - * FILE_MAP_ALL_ACCESS access, to verify - * the FILE_MAP_WRITE access map. - */ - OpenFileMappingHandle2 = OpenFileMapping( - FILE_MAP_ALL_ACCESS, - FALSE, - MapObject); - - if(NULL == OpenFileMappingHandle2) - { - Trace("\nFailed to Call OpenFileMappingW API!\n"); - RetVal = FAIL; - goto CleanUpTwo; - } - - /* Create map view of the open mapping that has - * FILE_MAP_WRITE access. - */ - lpMapViewAddress = MapViewOfFile( - OpenFileMappingHandle, - FILE_MAP_WRITE, /* access code */ - 0, /* high order offset */ - 0, /* low order offset */ - LOWORDERSIZE); /* number of bytes for map */ - - if(NULL == lpMapViewAddress) - { - Trace("ERROR:%u: Failed to call MapViewOfFile " - "API to map a view of file!\n", - GetLastError()); - RetVal = FAIL; - goto CleanUpThree; - } - - /* Create map view of the open mapping that has - * FILE_MAP_ALL_ACCESS access. - */ - - lpMapViewAddress2 = MapViewOfFile( - OpenFileMappingHandle2, - FILE_MAP_ALL_ACCESS, /* access code */ - 0, /* high order offset */ - 0, /* low order offset */ - LOWORDERSIZE); /* number of bytes for map */ - - if(NULL == lpMapViewAddress2) - { - Trace("ERROR:%u: Failed to call MapViewOfFile " - "API to map a view of file!\n", - GetLastError()); - RetVal = FAIL; - goto CleanUpFour; - } - - /* Write to the Map View. - */ - memcpy(lpMapViewAddress, buf, strlen(buf)); - - /* Read from the Map View. - */ - memcpy(ch, (LPCSTR)lpMapViewAddress, LOWORDERSIZE); - - /* Compare what was written to the Map View, - * to what was read. - */ - if (memcmp(ch, buf, strlen(buf))!= 0) - { - - Trace("ERROR: MapViewOfFile not equal to file contents " - "retrieved \"%s\", expected \"%s\".\n", - ch, buf); - RetVal = FAIL; - goto CleanUpFive; - } - - -CleanUpFive: - - /* Unmap the view of file. - */ - if ( UnmapViewOfFile(lpMapViewAddress2) == FALSE ) - { - Trace("ERROR:%u: Failed to UnmapViewOfFile of \"%0x%lx\".\n", - GetLastError(), - lpMapViewAddress2); - RetVal = FAIL; - } - -CleanUpFour: - - /* Unmap the view of file. - */ - if ( UnmapViewOfFile(lpMapViewAddress) == FALSE ) - { - Trace("ERROR:%u: Failed to UnmapViewOfFile of \"%0x%lx\".\n", - GetLastError(), - lpMapViewAddress); - RetVal = FAIL; - } - -CleanUpThree: - - /* Close Handle to opened file mapping. - */ - if ( CloseHandle(OpenFileMappingHandle2) == 0 ) - { - Trace("ERROR:%u: Failed to CloseHandle \"0x%lx\".\n", - GetLastError(), - OpenFileMappingHandle2); - RetVal = FAIL; - } - -CleanUpTwo: - - /* Close Handle to opened file mapping. - */ - if ( CloseHandle(OpenFileMappingHandle) == 0 ) - { - Trace("ERROR:%u: Failed to CloseHandle \"0x%lx\".\n", - GetLastError(), - OpenFileMappingHandle); - RetVal = FAIL; - } - -CleanUpOne: - - /* Close Handle to create file mapping. - */ - if ( CloseHandle(FileMappingHandle) == 0 ) - { - Trace("ERROR:%u: Failed to CloseHandle \"0x%lx\".\n", - GetLastError(), - FileMappingHandle); - RetVal = FAIL; - } - - /* Terminate the PAL. - */ - PAL_TerminateEx(RetVal); - return RetVal; -} - diff --git a/src/pal/tests/palsuite/filemapping_memmgt/OpenFileMappingW/test2/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/OpenFileMappingW/test2/testinfo.dat deleted file mode 100644 index d481560a0..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/OpenFileMappingW/test2/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Filemapping_memmgt -Function = OpenFileMappingW -Name = Positive test for OpenFileMappingW API -TYPE = DEFAULT -EXE1 = openfilemappingw -Description -=Test the OpenFileMappingW with FILE_MAP_WRITE access diff --git a/src/pal/tests/palsuite/filemapping_memmgt/OpenFileMappingW/test3/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/OpenFileMappingW/test3/CMakeLists.txt deleted file mode 100644 index 002ea05d0..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/OpenFileMappingW/test3/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - OpenFileMappingW.cpp -) - -add_executable(paltest_openfilemappingw_test3 - ${SOURCES} -) - -add_dependencies(paltest_openfilemappingw_test3 coreclrpal) - -target_link_libraries(paltest_openfilemappingw_test3 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/OpenFileMappingW/test3/OpenFileMappingW.cpp b/src/pal/tests/palsuite/filemapping_memmgt/OpenFileMappingW/test3/OpenFileMappingW.cpp deleted file mode 100644 index 9c83491f6..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/OpenFileMappingW/test3/OpenFileMappingW.cpp +++ /dev/null @@ -1,210 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: openfilemappingw.c (test 3) -** -** Purpose: Positive test the OpenFileMappingW API. -** Call OpenFileMappingW to open a named file-mapping -** object with FILE_MAP_READ access -** -** -**============================================================*/ -#define UNICODE -#include - -int __cdecl main(int argc, char *argv[]) -{ - char buf[] = "this is a test"; - char ch[1024]; - HANDLE FileMappingHandle; - HANDLE OpenFileMappingHandle; - HANDLE OpenFileMappingHandle2; - HANDLE lpMapViewAddress; - HANDLE lpMapViewAddress2; - const int LOWORDERSIZE = 1024; - int RetVal = PASS; - WCHAR wpMappingFileObject[] = {'m','y','O','b','j','e','c','t','\0'}; - - - /* Initialize the PAL environment. - */ - if(0 != PAL_Initialize(argc, argv)) - { - return FAIL; - } - - /* Create a unnamed file-mapping object with file handle FileHandle. - */ - FileMappingHandle = CreateFileMapping( - INVALID_HANDLE_VALUE, - NULL, /* not inherited */ - PAGE_READWRITE, /* read and wite */ - 0, /* high-order size */ - LOWORDERSIZE, /* must be non-zero */ - wpMappingFileObject);/* named object */ - - if(NULL == FileMappingHandle) - { - Fail("\nFailed to call CreateFileMapping to create mapping object!\n"); - } - if(GetLastError() == ERROR_ALREADY_EXISTS) - { - Trace("\nFile mapping object already exists!\n"); - RetVal = FAIL; - goto CleanUpOne; - } - - /* Open a named file-mapping object with FILE_MAP_ALL_ACCESS access. - */ - OpenFileMappingHandle = OpenFileMapping( - FILE_MAP_READ, - FALSE, - wpMappingFileObject); - - if(NULL == OpenFileMappingHandle) - { - Trace("\nFailed to Call OpenFileMapping API!\n"); - RetVal = FAIL; - goto CleanUpOne; - } - - /* Open a file mapping with FILE_MAP_ALL_ACCESS access, - * to verify the FILE_MAP_READ. - */ - OpenFileMappingHandle2 = OpenFileMapping( - FILE_MAP_ALL_ACCESS, - FALSE, - wpMappingFileObject); - - if(NULL == OpenFileMappingHandle2) - { - Trace("\nFailed to Call OpenFileMapping API!\n"); - RetVal = FAIL; - goto CleanUpTwo; - } - - /* Test the opened map view. - */ - lpMapViewAddress = MapViewOfFile( - OpenFileMappingHandle, - FILE_MAP_READ, /* access code */ - 0, /* high order offset */ - 0, /* low order offset */ - LOWORDERSIZE); /* number of bytes for map */ - - if(NULL == lpMapViewAddress) - { - Trace("ERROR:%u: Failed to call MapViewOfFile " - "API to map a view of file!\n", - GetLastError()); - RetVal = FAIL; - goto CleanUpThree; - } - - /* Open a map view with FILE_MAP_ALL_ACCESS to verify, - * the FILE_MAP_READ view. - */ - lpMapViewAddress2 = MapViewOfFile( - OpenFileMappingHandle2, - FILE_MAP_ALL_ACCESS, /* access code */ - 0, /* high order offset */ - 0, /* low order offset */ - LOWORDERSIZE); /* number of bytes for map */ - - if(NULL == lpMapViewAddress2) - { - Trace("2ERROR:%u: Failed to call MapViewOfFile " - "API to map a view of file!\n", - GetLastError()); - RetVal = FAIL; - goto CleanUpFour; - } - - /* Write to the Map View. - */ - memcpy(lpMapViewAddress2, buf, strlen(buf)); - /* Read from the Map View. - */ - memcpy(ch, (LPCSTR)lpMapViewAddress, LOWORDERSIZE); - - /* Compare what was written to the Map View, - * to what was read. - */ - if (memcmp(ch, buf, strlen(buf))!= 0) - { - Trace("ERROR: MapViewOfFile not equal to file contents " - "retrieved \"%s\", expected \"%s\".\n", - ch, - buf); - RetVal = FAIL; - goto CleanUpFive; - } - -CleanUpFive: - - /* Unmap the view of file. - */ - if ( UnmapViewOfFile(lpMapViewAddress2) == FALSE ) - { - Trace("ERROR:%u: Failed to UnmapViewOfFile of \"%0x%lx\".\n", - GetLastError(), - lpMapViewAddress2); - RetVal = FAIL; - } - -CleanUpFour: - - /* Unmap the view of file. - */ - if ( UnmapViewOfFile(lpMapViewAddress) == FALSE ) - { - Trace("ERROR:%u: Failed to UnmapViewOfFile of \"%0x%lx\".\n", - GetLastError(), - lpMapViewAddress); - RetVal = FAIL; - } - -CleanUpThree: - - /* Close Handle to opened file mapping. - */ - if ( CloseHandle(OpenFileMappingHandle2) == 0 ) - { - Trace("ERROR:%u: Failed to CloseHandle \"0x%lx\".\n", - GetLastError(), - OpenFileMappingHandle2); - RetVal = FAIL; - } - -CleanUpTwo: - - /* Close Handle to opened file mapping. - */ - if ( CloseHandle(OpenFileMappingHandle) == 0 ) - { - Trace("ERROR:%u: Failed to CloseHandle \"0x%lx\".\n", - GetLastError(), - OpenFileMappingHandle); - RetVal = FAIL; - } - -CleanUpOne: - - /* Close Handle to create file mapping. - */ - if ( CloseHandle(FileMappingHandle) == 0 ) - { - Trace("ERROR:%u: Failed to CloseHandle \"0x%lx\".\n", - GetLastError(), - FileMappingHandle); - RetVal = FAIL; - } - - /* Terminate the PAL. - */ - PAL_TerminateEx(RetVal); - return RetVal; -} diff --git a/src/pal/tests/palsuite/filemapping_memmgt/OpenFileMappingW/test3/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/OpenFileMappingW/test3/testinfo.dat deleted file mode 100644 index b4ac69ec3..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/OpenFileMappingW/test3/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Filemapping_memmgt -Function = OpenFileMappingW -Name = Positive test for OpenFileMappingW API with FILE_MAP_READ access -TYPE = DEFAULT -EXE1 = openfilemappingw -Description -=Test the OpenFileMappingW with FILE_MAP_READ access diff --git a/src/pal/tests/palsuite/filemapping_memmgt/ProbeMemory/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/ProbeMemory/CMakeLists.txt deleted file mode 100644 index c6eddf74e..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/ProbeMemory/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(ProbeMemory_neg1) -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/filemapping_memmgt/ProbeMemory/ProbeMemory_neg1/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/ProbeMemory/ProbeMemory_neg1/CMakeLists.txt deleted file mode 100644 index cdd8be026..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/ProbeMemory/ProbeMemory_neg1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - ProbeMemory_neg.cpp -) - -add_executable(paltest_probememory_probememory_neg1 - ${SOURCES} -) - -add_dependencies(paltest_probememory_probememory_neg1 coreclrpal) - -target_link_libraries(paltest_probememory_probememory_neg1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/ProbeMemory/ProbeMemory_neg1/ProbeMemory_neg.cpp b/src/pal/tests/palsuite/filemapping_memmgt/ProbeMemory/ProbeMemory_neg1/ProbeMemory_neg.cpp deleted file mode 100644 index 80de809e1..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/ProbeMemory/ProbeMemory_neg1/ProbeMemory_neg.cpp +++ /dev/null @@ -1,95 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: ReadProcessMemory_neg.c -** -** Purpose: Negative test the ReadProcessMemory API. -** Call ReadProcessMemory to read unreadabel memory area -** -** -**============================================================*/ -#include - -#define REGIONSIZE 1024 - -int __cdecl main(int argc, char *argv[]) -{ - int err; - BOOL bResult; - LPVOID lpProcessAddress = NULL; - - /*Initialize the PAL environment*/ - err = PAL_Initialize(argc, argv); - if(0 != err) - { - return FAIL; - } - - /*allocate the virtual memory*/ - lpProcessAddress = VirtualAlloc( - NULL, /*system determine where to allocate the region*/ - REGIONSIZE, /*specify the size*/ - MEM_RESERVE, /*allocation type*/ - PAGE_READONLY); /*access protection*/ - - if(NULL == lpProcessAddress) - { - Fail("\nFailed to call VirtualAlloc API to allocate " - "virtual memory, error code=%u\n", GetLastError()); - } - - /*try to probe the unreadable memory area*/ - bResult = PAL_ProbeMemory( - lpProcessAddress, /*base of memory area*/ - REGIONSIZE, /*buffer length in bytes*/ - FALSE); /*read access*/ - - /*check the return value*/ - if(bResult) - { - Trace("\nProbeMemory for read didn't FAILED\n"); - - /*decommit the specified region*/ - err = VirtualFree(lpProcessAddress, REGIONSIZE, MEM_DECOMMIT); - if(0 == err) - { - Fail("\nFailed to call VirtualFree API, error code=%u\n", GetLastError()); - } - - Fail(""); - } - - /*try to probe the unwriteable memory area*/ - bResult = PAL_ProbeMemory( - lpProcessAddress, /*base of memory area*/ - REGIONSIZE, /*buffer length in bytes*/ - FALSE); /*write access */ - - /*check the return value*/ - if(bResult) - { - Trace("\nProbeMemory for write didn't FAILED\n"); - - /*decommit the specified region*/ - err = VirtualFree(lpProcessAddress, REGIONSIZE, MEM_DECOMMIT); - if(0 == err) - { - Fail("\nFailed to call VirtualFree API, error code=%u\n", GetLastError()); - } - - Fail(""); - } - - /*decommit the specified region*/ - err = VirtualFree(lpProcessAddress, REGIONSIZE, MEM_DECOMMIT); - if(0 == err) - { - Fail("\nFailed to call VirtualFree API, error code=%u\n", GetLastError()); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/filemapping_memmgt/ProbeMemory/ProbeMemory_neg1/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/ProbeMemory/ProbeMemory_neg1/testinfo.dat deleted file mode 100644 index 4d11a71bd..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/ProbeMemory/ProbeMemory_neg1/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Filemapping_memmgt -Function = PAL_ProbeMemory -Name = Negative test PAL_ProbeMemory API to read unreadable memory area -TYPE = DEFAULT -EXE1 = probememory_neg -Description -=Test the PAL_ProbeMemory to read unreadable memory area diff --git a/src/pal/tests/palsuite/filemapping_memmgt/ProbeMemory/test1/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/ProbeMemory/test1/CMakeLists.txt deleted file mode 100644 index 8103b1ecb..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/ProbeMemory/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - ProbeMemory.cpp -) - -add_executable(paltest_probememory_test1 - ${SOURCES} -) - -add_dependencies(paltest_probememory_test1 coreclrpal) - -target_link_libraries(paltest_probememory_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/ProbeMemory/test1/ProbeMemory.cpp b/src/pal/tests/palsuite/filemapping_memmgt/ProbeMemory/test1/ProbeMemory.cpp deleted file mode 100644 index 30b358d31..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/ProbeMemory/test1/ProbeMemory.cpp +++ /dev/null @@ -1,94 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: ReadProcessMemory.c -** -** Purpose: Positive test the ReadProcessMemory API. -** Call ReadProcessMemory to read memory contents -** inside current process. -** -** -**============================================================*/ -#include - -#define REGIONSIZE 1024 - -int __cdecl main(int argc, char *argv[]) -{ - int err; - BOOL bResult; - LPVOID lpProcessAddress = NULL; - - /*Initialize the PAL environment*/ - err = PAL_Initialize(argc, argv); - if(0 != err) - { - return FAIL; - } - - /*allocate the virtual memory*/ - lpProcessAddress = VirtualAlloc( - NULL, /*system determine where to allocate the region*/ - REGIONSIZE, /*specify the size*/ - MEM_COMMIT, /*allocation type*/ - PAGE_READWRITE); /*access protection*/ - - if(NULL == lpProcessAddress) - { - Fail("\nFailed to call VirtualAlloc API to allocate " - "virtual memory, error code=%u!\n", GetLastError()); - } - - /*probe the memory for read*/ - bResult = PAL_ProbeMemory( - lpProcessAddress, /*base of memory area*/ - REGIONSIZE, /*buffer length in bytes*/ - FALSE); /*read access*/ - - if(!bResult) - { - Trace("\nProbeMemory for read access FAILED\n"); - - /*decommit the specified region*/ - err = VirtualFree(lpProcessAddress, REGIONSIZE, MEM_DECOMMIT); - if(0 == err) - { - Fail("\nFailed to call VirtualFree API, error code=%u\n", GetLastError()); - } - - Fail(""); - } - - /*probe the memory for write */ - bResult = PAL_ProbeMemory( - lpProcessAddress, /*base of memory area*/ - REGIONSIZE, /*buffer length in bytes*/ - TRUE); /*write access*/ - - if(!bResult) - { - Trace("\nProbeMemory for write access FAILED\n"); - - /*decommit the specified region*/ - err = VirtualFree(lpProcessAddress, REGIONSIZE, MEM_DECOMMIT); - if(0 == err) - { - Fail("\nFailed to call VirtualFree API, error code=%u\n", GetLastError()); - } - - Fail(""); - } - - /*decommit the specified region*/ - err = VirtualFree(lpProcessAddress, REGIONSIZE, MEM_DECOMMIT); - if(0 == err) - { - Fail("\nFailed to call VirtualFree API, error code=%u\n", GetLastError()); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/filemapping_memmgt/ProbeMemory/test1/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/ProbeMemory/test1/testinfo.dat deleted file mode 100644 index 512b945c4..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/ProbeMemory/test1/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Filemapping_memmgt -Function = PAL_ProbeMemory -Name = Positive test for PAL_ProbeMemory API to probe for read/write -TYPE = DEFAULT -EXE1 = probememory -Description -=Test the PAL_ProbeMemory to probe for read and write diff --git a/src/pal/tests/palsuite/filemapping_memmgt/RtlMoveMemory/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/RtlMoveMemory/CMakeLists.txt deleted file mode 100644 index 393074b4e..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/RtlMoveMemory/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test3) -add_subdirectory(test4) -add_subdirectory(test5) - diff --git a/src/pal/tests/palsuite/filemapping_memmgt/RtlMoveMemory/test1/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/RtlMoveMemory/test1/CMakeLists.txt deleted file mode 100644 index 12aba80d0..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/RtlMoveMemory/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_rtlmovememory_test1 - ${SOURCES} -) - -add_dependencies(paltest_rtlmovememory_test1 coreclrpal) - -target_link_libraries(paltest_rtlmovememory_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/RtlMoveMemory/test1/test1.cpp b/src/pal/tests/palsuite/filemapping_memmgt/RtlMoveMemory/test1/test1.cpp deleted file mode 100644 index 7fc56510d..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/RtlMoveMemory/test1/test1.cpp +++ /dev/null @@ -1,56 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: test1.c -** -** Purpose: Simple test -- have two 128 blocks of memory allocated. Then -** move one block to the other and check to see that the data was not -** corrupted. -** -** -**============================================================*/ - -#include - -enum Memory -{ - MEMORY_AMOUNT = 128 -}; - -int __cdecl main(int argc, char *argv[]) -{ - char NewAddress[MEMORY_AMOUNT]; - char OldAddress[MEMORY_AMOUNT]; - int i; - char temp; - - if(PAL_Initialize(argc, argv)) - { - return FAIL; - } - - /* Put some data into the block we'll be moving */ - memset(OldAddress, 'X', MEMORY_AMOUNT); - - /* Move the block to the NewAddress */ - RtlMoveMemory(NewAddress, OldAddress, MEMORY_AMOUNT); - - /* Check to ensure the data didn't get corrupted */ - for(i=0; i - -enum Memory -{ - NEW_MEMORY_AMOUNT = 128, - OLD_MEMORY_AMOUNT = 10 -}; - -int __cdecl main(int argc, char *argv[]) -{ - char NewAddress[NEW_MEMORY_AMOUNT]; - char OldAddress[OLD_MEMORY_AMOUNT]; - int i; - - - if(PAL_Initialize(argc, argv)) - { - return FAIL; - } - - /* Put some data into the block we'll be moving */ - memset(OldAddress, 'X', OLD_MEMORY_AMOUNT); - - /* Put some data into the block we're moving to */ - memset(NewAddress, 'Z', NEW_MEMORY_AMOUNT); - - /* Move the block to the NewAddress */ - RtlMoveMemory(NewAddress, OldAddress, OLD_MEMORY_AMOUNT); - - /* Check to ensure the moved data didn't get corrupted */ - for(i=0; i i+50 Check to make sure -** no data is lost. -** -** -**============================================================*/ - -#include - -enum Memory -{ - MEMORY_AMOUNT = 128 -}; - -int __cdecl main(int argc, char *argv[]) -{ - char* NewAddress; - char OldAddress[MEMORY_AMOUNT]; - int i; - - if(PAL_Initialize(argc, argv)) - { - return FAIL; - } - - NewAddress = OldAddress+50; - - /* Put some data into the block we'll be moving - The first 50 byes will be 'X' and the rest set to 'Z' - */ - memset(OldAddress, 'X', 50); - memset(NewAddress, 'Z', MEMORY_AMOUNT-50); - - /* Move the first 50 bytes of OldAddress to OldAddress+50. This - is to test that the source and destination addresses can overlap. - */ - RtlMoveMemory(NewAddress, OldAddress, 50); - - /* Check to ensure the moved data didn't get corrupted - The first 50 bytes should be 'X' - */ - for(i=0; i<50; ++i) - { - if(NewAddress[i] != 'X') - { - Fail("ERROR: When the memory was moved to a new location, the " - "data which was stored in it was somehow corrupted. " - "Character %d should have been 'X' but instead is %c.\n", - i, NewAddress[i]); - } - } - - /* The rest of the memory should be 'Z' */ - for(i=50; i i+50 Check to make sure -= no data is lost. - - - - diff --git a/src/pal/tests/palsuite/filemapping_memmgt/RtlMoveMemory/test5/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/RtlMoveMemory/test5/CMakeLists.txt deleted file mode 100644 index f3c38f2e6..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/RtlMoveMemory/test5/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test5.cpp -) - -add_executable(paltest_rtlmovememory_test5 - ${SOURCES} -) - -add_dependencies(paltest_rtlmovememory_test5 coreclrpal) - -target_link_libraries(paltest_rtlmovememory_test5 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/RtlMoveMemory/test5/test5.cpp b/src/pal/tests/palsuite/filemapping_memmgt/RtlMoveMemory/test5/test5.cpp deleted file mode 100644 index affcb0abc..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/RtlMoveMemory/test5/test5.cpp +++ /dev/null @@ -1,63 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: test5.c -** -** Purpose: Do more complex overlapping. Move a section of memory back so -** that it actually ends up overlapping itself. -** -** -**============================================================*/ - -#include - -enum Memory -{ - MEMORY_AMOUNT = 128 -}; - -int __cdecl main(int argc, char *argv[]) -{ - char* NewAddress; - char* SectionToMove; - char TheMemory[MEMORY_AMOUNT]; - int i; - - if(PAL_Initialize(argc, argv)) - { - return FAIL; - } - - NewAddress = TheMemory; - SectionToMove = TheMemory+50; - - /* Put some data into the first 50 bytes */ - memset(TheMemory, 'X', 50); - - /* Put some data into the rest of the memory */ - memset(SectionToMove, 'Z', MEMORY_AMOUNT-50); - - /* Move the section in the middle of TheMemory back to the start of - TheMemory -- but have it also overlap itself. (ie. the section - to be move is overlapping itself) - */ - RtlMoveMemory(NewAddress, SectionToMove, MEMORY_AMOUNT-50); - - /* Check to ensure the moved data didn't get corrupted */ - for(i=0; i - -int __cdecl main(int argc, char *argv[]) -{ - const int MappingSize = 2048; - HANDLE hFile; - HANDLE hFileMapping; - LPVOID lpMapViewAddress; - char buf[] = "this is a test string"; - char ch[2048]; - char readString[2048]; - char lpFileName[] = "test.tmp"; - DWORD dwBytesRead; - BOOL bRetVal; - - /* Initialize the PAL environment. - */ - if(0 != PAL_Initialize(argc, argv)) - { - return FAIL; - } - - /* Create a file handle with CreateFile. - */ - hFile = CreateFile( lpFileName, - GENERIC_WRITE|GENERIC_READ, - FILE_SHARE_READ|FILE_SHARE_WRITE, - NULL, - OPEN_ALWAYS, - FILE_ATTRIBUTE_NORMAL, - NULL); - if (hFile == INVALID_HANDLE_VALUE) - { - Fail("ERROR: %u :unable to create file \"%s\".\n", - GetLastError(), - lpFileName); - } - - /* Initialize the buffers. - */ - memset(ch, 0, MappingSize); - memset(readString, 0, MappingSize); - - /* Create a unnamed file-mapping object with file handle FileHandle - * and with PAGE_READWRITE protection. - */ - hFileMapping = CreateFileMapping( - hFile, - NULL, /*not inherited*/ - PAGE_READWRITE, /*read and wite*/ - 0, /*high-order of object size*/ - MappingSize, /*low-orger of object size*/ - NULL); /*unnamed object*/ - - if(NULL == hFileMapping) - { - Trace("ERROR:%u: Failed to create File Mapping.\n", - GetLastError()); - CloseHandle(hFile); - Fail(""); - } - - /* maps a view of a file into the address space of the calling process. - */ - lpMapViewAddress = MapViewOfFile( - hFileMapping, - FILE_MAP_ALL_ACCESS, /* access code */ - 0, /* high order offset */ - 0, /* low order offset */ - MappingSize); /* number of bytes for map */ - - if(NULL == lpMapViewAddress) - { - Trace("ERROR:%u: Failed to call MapViewOfFile API to map a view" - " of file!\n", - GetLastError()); - CloseHandle(hFile); - CloseHandle(hFileMapping); - Fail(""); - } - - /* Write to the MapView and copy the MapViewOfFile - * to buffer, so we can compare with value read from - * file directly. - */ - - memcpy(lpMapViewAddress, buf, strlen(buf)); - memcpy(ch, (LPCSTR)lpMapViewAddress, MappingSize); - - /* Read from the File handle. - */ - bRetVal = ReadFile(hFile, - readString, - strlen(buf), - &dwBytesRead, - NULL); - - if (bRetVal == FALSE) - { - Trace("ERROR: %u :unable to read from file handle " - "hFile=0x%lx\n", - GetLastError(), - hFile); - CloseHandle(hFile); - CloseHandle(hFileMapping); - Fail(""); - } - - if (memcmp(ch, readString, strlen(readString)) != 0) - { - Trace("ERROR: Read string from file \"%s\", is " - "not equal to string written through MapView " - "\"%s\".\n", - readString, - ch); - CloseHandle(hFile); - CloseHandle(hFileMapping); - Fail(""); - } - - /* Unmap the view of file. - */ - if(UnmapViewOfFile(lpMapViewAddress) == FALSE) - { - Trace("ERROR: Failed to call UnmapViewOfFile API to" - " unmap the view of a file, error code=%u\n", - GetLastError()); - CloseHandle(hFile); - CloseHandle(hFileMapping); - Fail(""); - } - - /* Re-initialize the buffer. - */ - memset(ch, 0, MappingSize); - - /* Close handle to created file mapping. - */ - if(CloseHandle(hFileMapping) == FALSE) - { - Trace("ERROR:%u:Failed to call CloseHandle API " - "to close a file mapping handle.", - GetLastError()); - CloseHandle(hFile); - Fail(""); - } - - /* Close handle to create file. - */ - if(CloseHandle(hFile) == FALSE) - { - Fail("ERROR:%u:Failed to call CloseHandle API " - "to close a file handle.", - GetLastError()); - } - - PAL_Terminate(); - return PASS; -} - - diff --git a/src/pal/tests/palsuite/filemapping_memmgt/UnmapViewOfFile/test1/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/UnmapViewOfFile/test1/testinfo.dat deleted file mode 100644 index 841801536..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/UnmapViewOfFile/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Filemapping_memmgt -Function = UnmapViewOfFile -Name = Positive test UnmapViewOfFile API to unmap a view of file -TYPE = DEFAULT -EXE1 = unmapviewoffile -LANG = cpp -Description -= Test the UnmapViewOfFile to unmap a view of file. diff --git a/src/pal/tests/palsuite/filemapping_memmgt/UnmapViewOfFile/test2/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/UnmapViewOfFile/test2/CMakeLists.txt deleted file mode 100644 index 8aa842968..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/UnmapViewOfFile/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - unmapviewoffile.cpp -) - -add_executable(paltest_unmapviewoffile_test2 - ${SOURCES} -) - -add_dependencies(paltest_unmapviewoffile_test2 coreclrpal) - -target_link_libraries(paltest_unmapviewoffile_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/UnmapViewOfFile/test2/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/UnmapViewOfFile/test2/testinfo.dat deleted file mode 100644 index 29e847a82..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/UnmapViewOfFile/test2/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Filemapping_memmgt -Function = UnmapViewOfFile -Name = Negative test UnmapViewOfFile API to unmap a view of file -TYPE = DEFAULT -EXE1 = unmapviewoffile -Description -= Test the UnmapViewOfFile to unmap a view of file -= negative test by passing a NULL mapping address. diff --git a/src/pal/tests/palsuite/filemapping_memmgt/UnmapViewOfFile/test2/unmapviewoffile.cpp b/src/pal/tests/palsuite/filemapping_memmgt/UnmapViewOfFile/test2/unmapviewoffile.cpp deleted file mode 100644 index 2ca185d23..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/UnmapViewOfFile/test2/unmapviewoffile.cpp +++ /dev/null @@ -1,42 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: UnmapViewOfFile.c (test 2) -** -** Purpose: Negative test the UnmapViewOfFile API. -** Call UnmapViewOfFile to unmap a view of -** NULL. -** -** -**============================================================*/ -#include - -int __cdecl main(int argc, char *argv[]) -{ - int err; - - /*Initialize the PAL environment*/ - err = PAL_Initialize(argc, argv); - if(0 != err) - { - return FAIL; - } - - /* Negative test the UnmapViewOfFile by passing a NULL*/ - /* mapping address handle*/ - err = UnmapViewOfFile(NULL); - if(0 != err) - { - Fail("ERROR: Able to call UnmapViewOfFile API " - "by passing a NULL mapping address.\n" ); - - } - - /* Terminate the PAL. - */ - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/CMakeLists.txt deleted file mode 100644 index b2cafde93..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/CMakeLists.txt +++ /dev/null @@ -1,25 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test10) -add_subdirectory(test11) -add_subdirectory(test12) -add_subdirectory(test13) -add_subdirectory(test14) -add_subdirectory(test15) -add_subdirectory(test16) -add_subdirectory(test17) -add_subdirectory(test18) -add_subdirectory(test19) -add_subdirectory(test2) -add_subdirectory(test20) -add_subdirectory(test21) -add_subdirectory(test22) -add_subdirectory(test3) -add_subdirectory(test4) -add_subdirectory(test5) -add_subdirectory(test6) -add_subdirectory(test7) -add_subdirectory(test8) -add_subdirectory(test9) - diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test1/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test1/CMakeLists.txt deleted file mode 100644 index 9fe73ac00..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - VirtualAlloc.cpp -) - -add_executable(paltest_virtualalloc_test1 - ${SOURCES} -) - -add_dependencies(paltest_virtualalloc_test1 coreclrpal) - -target_link_libraries(paltest_virtualalloc_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test1/VirtualAlloc.cpp b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test1/VirtualAlloc.cpp deleted file mode 100644 index 26ee942ba..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test1/VirtualAlloc.cpp +++ /dev/null @@ -1,50 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: virtualalloc.c -** -** Purpose: Positive test the VirtualAlloc API. -** Call VirtualAlloc with MEM_COMMIT allocation type -** and PAGE_READONLY access protection - -** -**============================================================*/ -#include - -int __cdecl main(int argc, char *argv[]) -{ - int err; - LPVOID lpVirtualAddress; - - - //Initialize the PAL environment - err = PAL_Initialize(argc, argv); - if(0 != err) - { - ExitProcess(FAIL); - } - - //Allocate the physical storage in memory or in the paging file on disk - lpVirtualAddress = VirtualAlloc(NULL,//system determine where to allocate the region - 1024, //specify the size - MEM_COMMIT, //allocation type - PAGE_READONLY); //access protection - if(NULL == lpVirtualAddress) - { - Fail("\nFailed to call VirtualAlloc API!\n"); - } - - //decommit the specified region - err = VirtualFree(lpVirtualAddress,1024,MEM_DECOMMIT); - if(0 == err) - { - Fail("\nFailed to call VirtualFree API!\n"); - } - - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test1/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test1/testinfo.dat deleted file mode 100644 index 5b8311a05..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Filemapping_memmgt -Function = VirtualAlloc -Name = Positive test for VirtualAlloc API -TYPE = DEFAULT -EXE1 = virtualalloc -Description -=Test the VirtualAlloc with MEM_COMMIT allocation type -=and PAGE_READONLY access protection diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test10/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test10/CMakeLists.txt deleted file mode 100644 index 6ccecb60b..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test10/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - VirtualAlloc.cpp -) - -add_executable(paltest_virtualalloc_test10 - ${SOURCES} -) - -add_dependencies(paltest_virtualalloc_test10 coreclrpal) - -target_link_libraries(paltest_virtualalloc_test10 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test10/VirtualAlloc.cpp b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test10/VirtualAlloc.cpp deleted file mode 100644 index ac06b9b5c..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test10/VirtualAlloc.cpp +++ /dev/null @@ -1,48 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: virtualalloc.c -** -** Purpose: Positive test the VirtualAlloc API. -** Call VirtualAlloc with MEM_RESERVE allocation type -** and PAGE_EXECUTE_READ access protection - -** -**============================================================*/ -#include - -int __cdecl main(int argc, char *argv[]) -{ - int err; - LPVOID lpVirtualAddress; - - //Initialize the PAL environment - err = PAL_Initialize(argc, argv); - if(0 != err) - { - ExitProcess(FAIL); - } - - //Allocate the physical storage in memory or in the paging file on disk - lpVirtualAddress = VirtualAlloc(NULL,//system determine where to allocate the region - 1024, //specify the size - MEM_RESERVE, //allocation type - PAGE_EXECUTE_READ); //access protection - if(NULL == lpVirtualAddress) - { - Fail("\nFailed to call VirtualAlloc API!\n"); - } - - //decommit the specified region - err = VirtualFree(lpVirtualAddress,1024,MEM_DECOMMIT); - if(0 == err) - { - Fail("\nFailed to call VirtualFree API!\n"); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test10/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test10/testinfo.dat deleted file mode 100644 index 960f2265d..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test10/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Filemapping_memmgt -Function = VirtualAlloc -Name = Positive test for VirtualAlloc API -TYPE = DEFAULT -EXE1 = virtualalloc -Description -=Test the VirtualAlloc with MEM_RESERVE allocation type -=and PAGE_EXECUTE_READ access protection diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test11/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test11/CMakeLists.txt deleted file mode 100644 index fe848f0c4..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test11/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - VirtualAlloc.cpp -) - -add_executable(paltest_virtualalloc_test11 - ${SOURCES} -) - -add_dependencies(paltest_virtualalloc_test11 coreclrpal) - -target_link_libraries(paltest_virtualalloc_test11 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test11/VirtualAlloc.cpp b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test11/VirtualAlloc.cpp deleted file mode 100644 index a3df39b63..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test11/VirtualAlloc.cpp +++ /dev/null @@ -1,49 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: virtualalloc.c -** -** Purpose: Positive test the VirtualAlloc API. -** Call VirtualAlloc with MEM_RESERVE allocation type -** and PAGE_READONLY access protection -** - -** -**============================================================*/ -#include - -int __cdecl main(int argc, char *argv[]) -{ - int err; - LPVOID lpVirtualAddress; - - - //Initialize the PAL environment - err = PAL_Initialize(argc, argv); - if(0 != err) - { - ExitProcess(FAIL); - } - //Allocate the physical storage in memory or in the paging file on disk - lpVirtualAddress = VirtualAlloc(NULL,//system determine where to allocate the region - 1024, //specify the size - MEM_RESERVE, //allocation type - PAGE_EXECUTE_READWRITE); //access protection - if(NULL == lpVirtualAddress) - { - Fail("\nFailed to call VirtualAlloc API!\n"); - } - - //decommit the specified region - err = VirtualFree(lpVirtualAddress,1024,MEM_DECOMMIT); - if(0 == err) - { - Fail("\nFailed to call VirtualFree API!\n"); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test11/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test11/testinfo.dat deleted file mode 100644 index 5d9f0ad88..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test11/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Filemapping_memmgt -Function = VirtualAlloc -Name = Positive test for VirtualAlloc API -TYPE = DEFAULT -EXE1 = virtualalloc -Description -=Test the VirtualAlloc with MEM_RESERVE allocation type -=and PAGE_EXECUTE_READWRITE access protection diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test12/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test12/CMakeLists.txt deleted file mode 100644 index dc59a294a..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test12/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - VirtualAlloc.cpp -) - -add_executable(paltest_virtualalloc_test12 - ${SOURCES} -) - -add_dependencies(paltest_virtualalloc_test12 coreclrpal) - -target_link_libraries(paltest_virtualalloc_test12 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test12/VirtualAlloc.cpp b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test12/VirtualAlloc.cpp deleted file mode 100644 index 8b3508635..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test12/VirtualAlloc.cpp +++ /dev/null @@ -1,48 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: virtualalloc.c -** -** Purpose: Positive test the VirtualAlloc API. -** Call VirtualAlloc with MEM_RESERVE allocation type -** and PAGE_NOACCESS access protection - -** -**============================================================*/ -#include - -int __cdecl main(int argc, char *argv[]) -{ - int err; - LPVOID lpVirtualAddress; - - //Initialize the PAL environment - err = PAL_Initialize(argc, argv); - if(0 != err) - { - ExitProcess(FAIL); - } - - //Allocate the physical storage in memory or in the paging file on disk - lpVirtualAddress = VirtualAlloc(NULL,//system determine where to allocate the region - 1024, //specify the size - MEM_RESERVE, //allocation type - PAGE_NOACCESS); //access protection - if(NULL == lpVirtualAddress) - { - Fail("\nFailed to call VirtualAlloc API!\n"); - } - - //decommit the specified region - err = VirtualFree(lpVirtualAddress,1024,MEM_DECOMMIT); - if(0 == err) - { - Fail("\nFailed to call VirtualFree API!\n"); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test12/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test12/testinfo.dat deleted file mode 100644 index ac2b91c0d..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test12/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Filemapping_memmgt -Function = VirtualAlloc -Name = Positive test for VirtualAlloc API -TYPE = DEFAULT -EXE1 = virtualalloc -Description -=Test the VirtualAlloc with MEM_COMMIT allocation type -=and PAGE_NOACCESS access protection diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test13/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test13/CMakeLists.txt deleted file mode 100644 index 04cf162f3..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test13/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - VirtualAlloc.cpp -) - -add_executable(paltest_virtualalloc_test13 - ${SOURCES} -) - -add_dependencies(paltest_virtualalloc_test13 coreclrpal) - -target_link_libraries(paltest_virtualalloc_test13 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test13/VirtualAlloc.cpp b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test13/VirtualAlloc.cpp deleted file mode 100644 index d2109c033..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test13/VirtualAlloc.cpp +++ /dev/null @@ -1,48 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: virtualalloc.c -** -** Purpose: Positive test the VirtualAlloc API. -** Call VirtualAlloc with MEM_COMMIT|MEM_TOP_DOWN allocation type -** and PAGE_READONLY access protection - -** -**============================================================*/ -#include - -int __cdecl main(int argc, char *argv[]) -{ - int err; - LPVOID lpVirtualAddress; - - //Initialize the PAL environment - err = PAL_Initialize(argc, argv); - if(0 != err) - { - ExitProcess(FAIL); - } - - //Allocate the physical storage in memory or in the paging file on disk - lpVirtualAddress = VirtualAlloc(NULL,//system determine where to allocate the region - 1024, //specify the size - MEM_COMMIT|MEM_TOP_DOWN, //allocation type - PAGE_READONLY); //access protection - if(NULL == lpVirtualAddress) - { - Fail("\nFailed to call VirtualAlloc API!\n"); - } - - //decommit the specified region - err = VirtualFree(lpVirtualAddress,1024,MEM_DECOMMIT); - if(0 == err) - { - Fail("\nFailed to call VirtualFree API!\n"); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test13/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test13/testinfo.dat deleted file mode 100644 index a571e9f8d..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test13/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Filemapping_memmgt -Function = VirtualAlloc -Name = Positive test for VirtualAlloc API -TYPE = DEFAULT -EXE1 = virtualalloc -Description -=Test the VirtualAlloc with MEM_COMMIT|MEM_TOP_DOWN allocation type -=and PAGE_READONLY access protection diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test14/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test14/CMakeLists.txt deleted file mode 100644 index 0f18f9722..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test14/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - VirtualAlloc.cpp -) - -add_executable(paltest_virtualalloc_test14 - ${SOURCES} -) - -add_dependencies(paltest_virtualalloc_test14 coreclrpal) - -target_link_libraries(paltest_virtualalloc_test14 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test14/VirtualAlloc.cpp b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test14/VirtualAlloc.cpp deleted file mode 100644 index 49bd21875..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test14/VirtualAlloc.cpp +++ /dev/null @@ -1,48 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: virtualalloc.c -** -** Purpose: Positive test the VirtualAlloc API. -** Call VirtualAlloc with MEM_COMMIT|MEM_TOP_DOWN allocation type -** and PAGE_READWRITE access protection - -** -**============================================================*/ -#include - -int __cdecl main(int argc, char *argv[]) -{ - int err; - LPVOID lpVirtualAddress; - - //Initialize the PAL environment - err = PAL_Initialize(argc, argv); - if(0 != err) - { - ExitProcess(FAIL); - } - - //Allocate the physical storage in memory or in the paging file on disk - lpVirtualAddress = VirtualAlloc(NULL,//system determine where to allocate the region - 1024, //specify the size - MEM_COMMIT|MEM_TOP_DOWN, //allocation type - PAGE_READWRITE); //access protection - if(NULL == lpVirtualAddress) - { - Fail("\nFailed to call VirtualAlloc API!\n"); - } - - //decommit the specified region - err = VirtualFree(lpVirtualAddress,1024,MEM_DECOMMIT); - if(0 == err) - { - Fail("\nFailed to call VirtualFree API!\n"); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test14/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test14/testinfo.dat deleted file mode 100644 index 60decb846..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test14/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Filemapping_memmgt -Function = VirtualAlloc -Name = Positive test for VirtualAlloc API -TYPE = DEFAULT -EXE1 = virtualalloc -Description -=Test the VirtualAlloc with MEM_COMMIT|MEM_TOP_DOWN allocation type -=and PAGE_READWRITE access protection diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test15/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test15/CMakeLists.txt deleted file mode 100644 index 56f8be652..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test15/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - VirtualAlloc.cpp -) - -add_executable(paltest_virtualalloc_test15 - ${SOURCES} -) - -add_dependencies(paltest_virtualalloc_test15 coreclrpal) - -target_link_libraries(paltest_virtualalloc_test15 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test15/VirtualAlloc.cpp b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test15/VirtualAlloc.cpp deleted file mode 100644 index 3cf1502f2..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test15/VirtualAlloc.cpp +++ /dev/null @@ -1,48 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: virtualalloc.c -** -** Purpose: Positive test the VirtualAlloc API. -** Call VirtualAlloc with MEM_COMMIT|MEM_TOP_DOWN allocation type -** and PAGE_EXECUTE access protection - -** -**============================================================*/ -#include - -int __cdecl main(int argc, char *argv[]) -{ - int err; - LPVOID lpVirtualAddress; - - //Initialize the PAL environment - err = PAL_Initialize(argc, argv); - if(0 != err) - { - ExitProcess(FAIL); - } - - //Allocate the physical storage in memory or in the paging file on disk - lpVirtualAddress = VirtualAlloc(NULL,//system determine where to allocate the region - 1024, //specify the size - MEM_COMMIT|MEM_TOP_DOWN, //allocation type - PAGE_EXECUTE); //access protection - if(NULL == lpVirtualAddress) - { - Fail("\nFailed to call VirtualAlloc API!\n"); - } - - //decommit the specified region - err = VirtualFree(lpVirtualAddress,1024,MEM_DECOMMIT); - if(0 == err) - { - Fail("\nFailed to call VirtualFree API!\n"); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test15/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test15/testinfo.dat deleted file mode 100644 index 2d9845ded..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test15/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Filemapping_memmgt -Function = VirtualAlloc -Name = Positive test for VirtualAlloc API -TYPE = DEFAULT -EXE1 = virtualalloc -Description -=Test the VirtualAlloc with MEM_COMMIT|MEM_TOP_DOWN allocation type -=and PAGE_EXECUTE access protection diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test16/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test16/CMakeLists.txt deleted file mode 100644 index 9b00d20d8..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test16/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - VirtualAlloc.cpp -) - -add_executable(paltest_virtualalloc_test16 - ${SOURCES} -) - -add_dependencies(paltest_virtualalloc_test16 coreclrpal) - -target_link_libraries(paltest_virtualalloc_test16 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test16/VirtualAlloc.cpp b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test16/VirtualAlloc.cpp deleted file mode 100644 index ce61b9aa3..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test16/VirtualAlloc.cpp +++ /dev/null @@ -1,48 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: virtualalloc.c -** -** Purpose: Positive test the VirtualAlloc API. -** Call VirtualAlloc with MEM_COMMIT|MEM_TOP_DOWN allocation type -** and PAGE_EXECUTE_READ access protection - -** -**============================================================*/ -#include - -int __cdecl main(int argc, char *argv[]) -{ - int err; - LPVOID lpVirtualAddress; - - //Initialize the PAL environment - err = PAL_Initialize(argc, argv); - if(0 != err) - { - ExitProcess(FAIL); - } - - //Allocate the physical storage in memory or in the paging file on disk - lpVirtualAddress = VirtualAlloc(NULL,//system determine where to allocate the region - 1024, //specify the size - MEM_COMMIT|MEM_TOP_DOWN, //allocation type - PAGE_EXECUTE_READ); //access protection - if(NULL == lpVirtualAddress) - { - Fail("\nFailed to call VirtualAlloc API!\n"); - } - - //decommit the specified region - err = VirtualFree(lpVirtualAddress,1024,MEM_DECOMMIT); - if(0 == err) - { - Fail("\nFailed to call VirtualFree API!\n"); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test16/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test16/testinfo.dat deleted file mode 100644 index 1389f1f92..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test16/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Filemapping_memmgt -Function = VirtualAlloc -Name = Positive test for VirtualAlloc API -TYPE = DEFAULT -EXE1 = virtualalloc -Description -=Test the VirtualAlloc with MEM_COMMIT|MEM_TOP_DOWN allocation type -=and PAGE_EXECUTE_READ access protection diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test17/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test17/CMakeLists.txt deleted file mode 100644 index 07be5b3d3..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test17/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - VirtualAlloc.cpp -) - -add_executable(paltest_virtualalloc_test17 - ${SOURCES} -) - -add_dependencies(paltest_virtualalloc_test17 coreclrpal) - -target_link_libraries(paltest_virtualalloc_test17 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test17/VirtualAlloc.cpp b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test17/VirtualAlloc.cpp deleted file mode 100644 index eb609f14e..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test17/VirtualAlloc.cpp +++ /dev/null @@ -1,49 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: virtualalloc.c -** -** Purpose: Positive test the VirtualAlloc API. -** Call VirtualAlloc with MEM_COMMIT|MEM_TOP_DOWN allocation type -** and PAGE_READONLY access protection -** - -** -**============================================================*/ -#include - -int __cdecl main(int argc, char *argv[]) -{ - int err; - LPVOID lpVirtualAddress; - - //Initialize the PAL environment - err = PAL_Initialize(argc, argv); - if(0 != err) - { - ExitProcess(FAIL); - } - - //Allocate the physical storage in memory or in the paging file on disk - lpVirtualAddress = VirtualAlloc(NULL,//system determine where to allocate the region - 1024, //specify the size - MEM_COMMIT|MEM_TOP_DOWN, //allocation type - PAGE_EXECUTE_READWRITE); //access protection - if(NULL == lpVirtualAddress) - { - Fail("\nFailed to call VirtualAlloc API!\n"); - } - - //decommit the specified region - err = VirtualFree(lpVirtualAddress,1024,MEM_DECOMMIT); - if(0 == err) - { - Fail("\nFailed to call VirtualFree API!\n"); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test17/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test17/testinfo.dat deleted file mode 100644 index 49ced6383..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test17/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Filemapping_memmgt -Function = VirtualAlloc -Name = Positive test for VirtualAlloc API -TYPE = DEFAULT -EXE1 = virtualalloc -Description -=Test the VirtualAlloc with MEM_COMMIT|MEM_TOP_DOWN allocation type -=and PAGE_EXECUTE_READWRITE access protection diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test18/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test18/CMakeLists.txt deleted file mode 100644 index b6196846c..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test18/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - VirtualAlloc.cpp -) - -add_executable(paltest_virtualalloc_test18 - ${SOURCES} -) - -add_dependencies(paltest_virtualalloc_test18 coreclrpal) - -target_link_libraries(paltest_virtualalloc_test18 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test18/VirtualAlloc.cpp b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test18/VirtualAlloc.cpp deleted file mode 100644 index e46da851d..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test18/VirtualAlloc.cpp +++ /dev/null @@ -1,49 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: virtualalloc.c -** -** Purpose: Positive test the VirtualAlloc API. -** Call VirtualAlloc with MEM_COMMIT|MEM_TOP_DOWN allocation type -** and PAGE_NOACCESS access protection - -** -**============================================================*/ -#include - -int __cdecl main(int argc, char *argv[]) -{ - int err; - LPVOID lpVirtualAddress; - - //Initialize the PAL environment - err = PAL_Initialize(argc, argv); - if(0 != err) - { - ExitProcess(FAIL); - } - - - //Allocate the physical storage in memory or in the paging file on disk - lpVirtualAddress = VirtualAlloc(NULL,//system determine where to allocate the region - 1024, //specify the size - MEM_COMMIT|MEM_TOP_DOWN, //allocation type - PAGE_NOACCESS); //access protection - if(NULL == lpVirtualAddress) - { - Fail("\nFailed to call VirtualAlloc API!\n"); - } - - //decommit the specified region - err = VirtualFree(lpVirtualAddress,1024,MEM_DECOMMIT); - if(0 == err) - { - Fail("\nFailed to call VirtualFree API!\n"); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test18/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test18/testinfo.dat deleted file mode 100644 index 1fd4ac6f1..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test18/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Filemapping_memmgt -Function = VirtualAlloc -Name = Positive test for VirtualAlloc API -TYPE = DEFAULT -EXE1 = virtualalloc -Description -=Test the VirtualAlloc with MEM_COMMIT|MEM_TOP_DOWN allocation type -=and PAGE_NOACCESS access protection diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test19/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test19/CMakeLists.txt deleted file mode 100644 index 27690a2eb..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test19/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - VirtualAlloc.cpp -) - -add_executable(paltest_virtualalloc_test19 - ${SOURCES} -) - -add_dependencies(paltest_virtualalloc_test19 coreclrpal) - -target_link_libraries(paltest_virtualalloc_test19 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test19/VirtualAlloc.cpp b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test19/VirtualAlloc.cpp deleted file mode 100644 index 5cbe48b15..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test19/VirtualAlloc.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: virtualalloc.c -** -** Purpose: Positive test the VirtualAlloc API. -** Call VirtualAlloc to reserve and commit -** simultaneously with MEM_COMMIT|MEM_RESERVE|MEM_TOP_DOWN -** allocation type and PAGE_READONLY access -** protection -** -** -**============================================================*/ -#include - -int __cdecl main(int argc, char *argv[]) -{ - int err; - LPVOID lpVirtualAddress; - - //Initialize the PAL environment - err = PAL_Initialize(argc, argv); - if(0 != err) - { - ExitProcess(FAIL); - } - - //reserve and commit simultaneously by using MEM_COMMIT|MEM_RESERVE - lpVirtualAddress = VirtualAlloc(NULL,//system determine where to allocate the region - 1024, //specify the size - MEM_COMMIT|MEM_RESERVE|MEM_TOP_DOWN, //allocation type - PAGE_READONLY); //access protection - if(NULL == lpVirtualAddress) - { - Fail("\nFailed to call VirtualAlloc API!\n"); - } - - //decommit the specified region - err = VirtualFree(lpVirtualAddress,1024,MEM_DECOMMIT); - if(0 == err) - { - Fail("\nFailed to call VirtualFree API!\n"); - } - - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test19/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test19/testinfo.dat deleted file mode 100644 index 6e427da15..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test19/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Filemapping_memmgt -Function = VirtualAlloc -Name = Positive test for VirtualAlloc API -TYPE = DEFAULT -EXE1 = virtualalloc -Description -=Test the VirtualAlloc to reserve and commit -=simultaneously by using MEM_COMMIT|MEM_RESERVE|MEM_TOP_DOWN -=allocation type and PAGE_READONLY access protection diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test2/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test2/CMakeLists.txt deleted file mode 100644 index 8637ef84e..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - VirtualAlloc.cpp -) - -add_executable(paltest_virtualalloc_test2 - ${SOURCES} -) - -add_dependencies(paltest_virtualalloc_test2 coreclrpal) - -target_link_libraries(paltest_virtualalloc_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test2/VirtualAlloc.cpp b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test2/VirtualAlloc.cpp deleted file mode 100644 index 99cf76a52..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test2/VirtualAlloc.cpp +++ /dev/null @@ -1,49 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: virtualalloc.c -** -** Purpose: Positive test the VirtualAlloc API. -** Call VirtualAlloc with MEM_COMMIT allocation type -** and PAGE_READWRITE access protection - -** -**============================================================*/ -#include - -int __cdecl main(int argc, char *argv[]) -{ - int err; - LPVOID lpVirtualAddress; - - //Initialize the PAL environment - err = PAL_Initialize(argc, argv); - if(0 != err) - { - ExitProcess(FAIL); - } - - //Allocate the physical storage in memory or in the paging file on disk - lpVirtualAddress = VirtualAlloc(NULL,//system determine where to allocate the region - 1024, //specify the size - MEM_COMMIT, //allocation type - PAGE_READWRITE); //access protection - if(NULL == lpVirtualAddress) - { - Fail("\nFailed to call VirtualAlloc API!\n"); - } - - //decommit the specified region - err = VirtualFree(lpVirtualAddress,1024,MEM_DECOMMIT); - if(0 == err) - { - Fail("\nFailed to call VirtualFree API!\n"); - } - - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test2/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test2/testinfo.dat deleted file mode 100644 index c7d8b6783..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test2/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Filemapping_memmgt -Function = VirtualAlloc -Name = Positive test for VirtualAlloc API -TYPE = DEFAULT -EXE1 = virtualalloc -Description -=Test the VirtualAlloc with MEM_COMMIT allocation type -=and PAGE_READWRITE access protection diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test20/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test20/CMakeLists.txt deleted file mode 100644 index 83cadbe3d..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test20/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - virtualalloc.cpp -) - -add_executable(paltest_virtualalloc_test20 - ${SOURCES} -) - -add_dependencies(paltest_virtualalloc_test20 coreclrpal) - -target_link_libraries(paltest_virtualalloc_test20 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test20/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test20/testinfo.dat deleted file mode 100644 index 6010a18c8..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test20/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Filemapping_memmgt -Function = VirtualAlloc -Name = Positive test for VirtualAlloc API -TYPE = DEFAULT -EXE1 = virtualalloc -Description -=Test VirtualAlloc to ensure that re-committed memory is not changed. diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test20/virtualalloc.cpp b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test20/virtualalloc.cpp deleted file mode 100644 index 7aec3c7f5..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test20/virtualalloc.cpp +++ /dev/null @@ -1,50 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: virtualalloc.c -** -** Purpose: Positive test the VirtualAlloc API. -** Ensure that memory re-committed through VirtualAlloc -** is not changed. -** -** -**============================================================*/ -#include - -int __cdecl main(int argc, char *argv[]) -{ - int err; - int *ptr; - - //Initialize the PAL environment - err = PAL_Initialize(argc, argv); - if(0 != err) - { - ExitProcess(FAIL); - } - - ptr = (int *) VirtualAlloc(NULL, 4096, MEM_COMMIT | MEM_RESERVE, - PAGE_READWRITE); - if (ptr == NULL) - { - Fail("First VirtualAlloc failed!\n"); - } - - *ptr = 123; - - ptr = (int *) VirtualAlloc(ptr, 4096, MEM_COMMIT, PAGE_READWRITE); - if (ptr == NULL) - { - Fail("Second VirtualAlloc failed!\n"); - } - if (*ptr != 123) - { - Fail("VirtualAlloc modified (probably zeroed) re-committed memory!\n"); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test21/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test21/CMakeLists.txt deleted file mode 100644 index 437e06435..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test21/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - virtualalloc.cpp -) - -add_executable(paltest_virtualalloc_test21 - ${SOURCES} -) - -add_dependencies(paltest_virtualalloc_test21 coreclrpal) - -target_link_libraries(paltest_virtualalloc_test21 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test21/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test21/testinfo.dat deleted file mode 100644 index c32d352d1..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test21/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Filemapping_memmgt -Function = VirtualAlloc -Name = Positive test for VirtualAlloc API -TYPE = DEFAULT -EXE1 = virtualalloc -Description -=Test VirtualAlloc to ensure that freed memory that is committed again is zeroed. diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test21/virtualalloc.cpp b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test21/virtualalloc.cpp deleted file mode 100644 index 065a2ff5c..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test21/virtualalloc.cpp +++ /dev/null @@ -1,54 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: virtualalloc.c -** -** Purpose: Positive test the VirtualAlloc API. -** Ensure that memory committed through VirtualAlloc, -** then freed, then committed again is zeroed. -** -** -**============================================================*/ -#include - -int __cdecl main(int argc, char *argv[]) -{ - int err; - int *ptr; - - //Initialize the PAL environment - err = PAL_Initialize(argc, argv); - if(0 != err) - { - ExitProcess(FAIL); - } - - ptr = (int *) VirtualAlloc(NULL, 4096, MEM_COMMIT | MEM_RESERVE, - PAGE_READWRITE); - if (ptr == NULL) - { - Fail("First VirtualAlloc failed!\n"); - } - *ptr = 123; - - if (!VirtualFree(ptr, 4096, MEM_DECOMMIT)) - { - Fail("VirtualFree failed!\n"); - } - - ptr = (int *) VirtualAlloc(ptr, 4096, MEM_COMMIT, PAGE_READWRITE); - if (ptr == NULL) - { - Fail("Second VirtualAlloc failed!\n"); - } - if (*ptr != 0) - { - Fail("VirtualAlloc failed to zero its memory!\n"); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test22/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test22/CMakeLists.txt deleted file mode 100644 index 7c6cf0c88..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test22/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - VirtualAlloc.cpp -) - -add_executable(paltest_virtualalloc_test22 - ${SOURCES} -) - -add_dependencies(paltest_virtualalloc_test22 coreclrpal) - -target_link_libraries(paltest_virtualalloc_test22 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test22/VirtualAlloc.cpp b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test22/VirtualAlloc.cpp deleted file mode 100644 index 489926f48..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test22/VirtualAlloc.cpp +++ /dev/null @@ -1,44 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: virtualalloc.c -** -** Purpose: Negative test the VirtualAlloc API. -** Call VirtualAlloc with MEM_COMMIT allocation type -** and PAGE_READWRITE access protection - -** -**============================================================*/ -#include - -int __cdecl main(int argc, char *argv[]) -{ - int err; - LPVOID lpVirtualAddress; - - - //Initialize the PAL environment - err = PAL_Initialize(argc, argv); - if(0 != err) - { - ExitProcess(FAIL); - } - - //Allocate the physical storage in memory or in the paging file on disk - lpVirtualAddress = VirtualAlloc(NULL,//system determine where to allocate the region - (SIZE_T)(2147483647000000), //specify the size to be int32.maxvalue mega bytes - MEM_COMMIT, //allocation type - PAGE_READWRITE); //access protection - if(NULL != lpVirtualAddress) - { - Fail("\nWelcome to the Future, where Unlimited Memory is Available, disregard this test!\n"); - } - - - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test22/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test22/testinfo.dat deleted file mode 100644 index 3d5962c7a..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test22/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Filemapping_memmgt -Function = VirtualAlloc -Name = Negative test for VirtualAlloc API -TYPE = DEFAULT -EXE1 = virtualalloc -Description -=Test the VirtualAlloc with MEM_COMMIT allocation type -=and PAGE_READWRITEaccess protection diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test3/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test3/CMakeLists.txt deleted file mode 100644 index 8ca013c6a..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test3/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - VirtualAlloc.cpp -) - -add_executable(paltest_virtualalloc_test3 - ${SOURCES} -) - -add_dependencies(paltest_virtualalloc_test3 coreclrpal) - -target_link_libraries(paltest_virtualalloc_test3 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test3/VirtualAlloc.cpp b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test3/VirtualAlloc.cpp deleted file mode 100644 index 5c57ec337..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test3/VirtualAlloc.cpp +++ /dev/null @@ -1,48 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: virtualalloc.c -** -** Purpose: Positive test the VirtualAlloc API. -** Call VirtualAlloc with MEM_COMMIT allocation type -** and PAGE_EXECUTE access protection - -** -**============================================================*/ -#include - -int __cdecl main(int argc, char *argv[]) -{ - int err; - LPVOID lpVirtualAddress; - - //Initialize the PAL environment - err = PAL_Initialize(argc, argv); - if(0 != err) - { - ExitProcess(FAIL); - } - - //Allocate the physical storage in memory or in the paging file on disk - lpVirtualAddress = VirtualAlloc(NULL,//system determine where to allocate the region - 1024, //specify the size - MEM_COMMIT, //allocation type - PAGE_EXECUTE); //access protection - if(NULL == lpVirtualAddress) - { - Fail("\nFailed to call VirtualAlloc API!\n"); - } - - //decommit the specified region - err = VirtualFree(lpVirtualAddress,1024,MEM_DECOMMIT); - if(0 == err) - { - Fail("\nFailed to call VirtualFree API!\n"); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test3/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test3/testinfo.dat deleted file mode 100644 index a3d540149..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test3/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Filemapping_memmgt -Function = VirtualAlloc -Name = Positive test for VirtualAlloc API -TYPE = DEFAULT -EXE1 = virtualalloc -Description -=Test the VirtualAlloc with MEM_COMMIT allocation type -=and PAGE_EXECUTE access protection diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test4/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test4/CMakeLists.txt deleted file mode 100644 index 3c6c68920..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test4/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - VirtualAlloc.cpp -) - -add_executable(paltest_virtualalloc_test4 - ${SOURCES} -) - -add_dependencies(paltest_virtualalloc_test4 coreclrpal) - -target_link_libraries(paltest_virtualalloc_test4 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test4/VirtualAlloc.cpp b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test4/VirtualAlloc.cpp deleted file mode 100644 index c134a14eb..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test4/VirtualAlloc.cpp +++ /dev/null @@ -1,49 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: virtualalloc.c -** -** Purpose: Positive test the VirtualAlloc API. -** Call VirtualAlloc with MEM_COMMIT allocation type -** and PAGE_EXECUTE_READ access protection - -** -**============================================================*/ -#include - -int __cdecl main(int argc, char *argv[]) -{ - int err; - LPVOID lpVirtualAddress; - - //Initialize the PAL environment - err = PAL_Initialize(argc, argv); - if(0 != err) - { - ExitProcess(FAIL); - } - - //Allocate the physical storage in memory or in the paging file on disk - lpVirtualAddress = VirtualAlloc(NULL,//system determine where to allocate the region - 1024, //specify the size - MEM_COMMIT, //allocation type - PAGE_EXECUTE_READ); //access protection - if(NULL == lpVirtualAddress) - { - Fail("\nFailed to call VirtualAlloc API!\n"); - } - - //decommit the specified region - err = VirtualFree(lpVirtualAddress,1024,MEM_DECOMMIT); - if(0 == err) - { - Fail("\nFailed to call VirtualFree API!\n"); - } - - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test4/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test4/testinfo.dat deleted file mode 100644 index 0e84e7a3b..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test4/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Filemapping_memmgt -Function = VirtualAlloc -Name = Positive test for VirtualAlloc API -TYPE = DEFAULT -EXE1 = virtualalloc -Description -=Test the VirtualAlloc with MEM_COMMIT allocation type -=and PAGE_EXECUTE_READ access protection diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test5/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test5/CMakeLists.txt deleted file mode 100644 index 5646ec57b..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test5/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - VirtualAlloc.cpp -) - -add_executable(paltest_virtualalloc_test5 - ${SOURCES} -) - -add_dependencies(paltest_virtualalloc_test5 coreclrpal) - -target_link_libraries(paltest_virtualalloc_test5 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test5/VirtualAlloc.cpp b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test5/VirtualAlloc.cpp deleted file mode 100644 index 8c4f9dcdb..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test5/VirtualAlloc.cpp +++ /dev/null @@ -1,50 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: virtualalloc.c -** -** Purpose: Positive test the VirtualAlloc API. -** Call VirtualAlloc with MEM_COMMIT allocation type -** and PAGE_READONLY access protection -** - -** -**============================================================*/ -#include - -int __cdecl main(int argc, char *argv[]) -{ - int err; - LPVOID lpVirtualAddress; - - //Initialize the PAL environment - err = PAL_Initialize(argc, argv); - if(0 != err) - { - ExitProcess(FAIL); - } - - //Allocate the physical storage in memory or in the paging file on disk - lpVirtualAddress = VirtualAlloc(NULL,//system determine where to allocate the region - 1024, //specify the size - MEM_COMMIT, //allocation type - PAGE_EXECUTE_READWRITE); //access protection - if(NULL == lpVirtualAddress) - { - Fail("\nFailed to call VirtualAlloc API!\n"); - } - - //decommit the specified region - err = VirtualFree(lpVirtualAddress,1024,MEM_DECOMMIT); - if(0 == err) - { - Fail("\nFailed to call VirtualFree API!\n"); - } - - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test5/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test5/testinfo.dat deleted file mode 100644 index 332b88b07..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test5/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Filemapping_memmgt -Function = VirtualAlloc -Name = Positive test for VirtualAlloc API -TYPE = DEFAULT -EXE1 = virtualalloc -Description -=Test the VirtualAlloc with MEM_COMMIT allocation type -=and PAGE_EXECUTE_READWRITE access protection diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test6/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test6/CMakeLists.txt deleted file mode 100644 index 1dbadc95a..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test6/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - VirtualAlloc.cpp -) - -add_executable(paltest_virtualalloc_test6 - ${SOURCES} -) - -add_dependencies(paltest_virtualalloc_test6 coreclrpal) - -target_link_libraries(paltest_virtualalloc_test6 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test6/VirtualAlloc.cpp b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test6/VirtualAlloc.cpp deleted file mode 100644 index e9c33d86d..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test6/VirtualAlloc.cpp +++ /dev/null @@ -1,48 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: virtualalloc.c -** -** Purpose: Positive test the VirtualAlloc API. -** Call VirtualAlloc with MEM_COMMIT allocation type -** and PAGE_NOACCESS access protection - -** -**============================================================*/ -#include - -int __cdecl main(int argc, char *argv[]) -{ - int err; - LPVOID lpVirtualAddress; - - //Initialize the PAL environment - err = PAL_Initialize(argc, argv); - if(0 != err) - { - ExitProcess(FAIL); - } - - //Allocate the physical storage in memory or in the paging file on disk - lpVirtualAddress = VirtualAlloc(NULL,//system determine where to allocate the region - 1024, //specify the size - MEM_COMMIT, //allocation type - PAGE_NOACCESS); //access protection - if(NULL == lpVirtualAddress) - { - Fail("\nFailed to call VirtualAlloc API!\n"); - } - - //decommit the specified region - err = VirtualFree(lpVirtualAddress,1024,MEM_DECOMMIT); - if(0 == err) - { - Fail("\nFailed to call VirtualFree API!\n"); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test6/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test6/testinfo.dat deleted file mode 100644 index ac2b91c0d..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test6/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Filemapping_memmgt -Function = VirtualAlloc -Name = Positive test for VirtualAlloc API -TYPE = DEFAULT -EXE1 = virtualalloc -Description -=Test the VirtualAlloc with MEM_COMMIT allocation type -=and PAGE_NOACCESS access protection diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test7/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test7/CMakeLists.txt deleted file mode 100644 index e4ccebf5a..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test7/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - VirtualAlloc.cpp -) - -add_executable(paltest_virtualalloc_test7 - ${SOURCES} -) - -add_dependencies(paltest_virtualalloc_test7 coreclrpal) - -target_link_libraries(paltest_virtualalloc_test7 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test7/VirtualAlloc.cpp b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test7/VirtualAlloc.cpp deleted file mode 100644 index bee2735c9..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test7/VirtualAlloc.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: virtualalloc.c -** -** Purpose: Positive test the VirtualAlloc API. -** Call VirtualAlloc with MEM_RESERVE allocation type -** and PAGE_READONLY access protection - -** -**============================================================*/ -#include - -int __cdecl main(int argc, char *argv[]) -{ - int err; - LPVOID lpVirtualAddress; - - //Initialize the PAL environment - err = PAL_Initialize(argc, argv); - if(0 != err) - { - ExitProcess(FAIL); - } - - //Allocate the physical storage in memory or in the paging file on disk - lpVirtualAddress = VirtualAlloc(NULL,//system determine where to allocate the region - 1024, //specify the size - MEM_RESERVE, //allocation type - PAGE_READONLY); //access protection - if(NULL == lpVirtualAddress) - { - Fail("\nFailed to call VirtualAlloc API!\n"); - PAL_Terminate(); - return 1; - } - - //decommit the specified region - err = VirtualFree(lpVirtualAddress,1024,MEM_DECOMMIT); - if(0 == err) - { - Fail("\nFailed to call VirtualFree API!\n"); - PAL_Terminate(); - return 1; - } - - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test7/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test7/testinfo.dat deleted file mode 100644 index 2edcb56d3..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test7/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Filemapping_memmgt -Function = VirtualAlloc -Name = Positive test for VirtualAlloc API -TYPE = DEFAULT -EXE1 = virtualalloc -Description -=Test the VirtualAlloc with MEM_RESERVE allocation type -=and PAGE_READONLY access protection diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test8/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test8/CMakeLists.txt deleted file mode 100644 index e94e08122..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test8/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - VirtualAlloc.cpp -) - -add_executable(paltest_virtualalloc_test8 - ${SOURCES} -) - -add_dependencies(paltest_virtualalloc_test8 coreclrpal) - -target_link_libraries(paltest_virtualalloc_test8 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test8/VirtualAlloc.cpp b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test8/VirtualAlloc.cpp deleted file mode 100644 index d548e0c8d..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test8/VirtualAlloc.cpp +++ /dev/null @@ -1,48 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: virtualalloc.c -** -** Purpose: Positive test the VirtualAlloc API. -** Call VirtualAlloc with MEM_RESERVE allocation type -** and PAGE_READWRITE access protection - -** -**============================================================*/ -#include - -int __cdecl main(int argc, char *argv[]) -{ - int err; - LPVOID lpVirtualAddress; - - //Initialize the PAL environment - err = PAL_Initialize(argc, argv); - if(0 != err) - { - ExitProcess(FAIL); - } - - //Allocate the physical storage in memory or in the paging file on disk - lpVirtualAddress = VirtualAlloc(NULL,//system determine where to allocate the region - 1024, //specify the size - MEM_RESERVE, //allocation type - PAGE_READWRITE); //access protection - if(NULL == lpVirtualAddress) - { - Fail("\nFailed to call VirtualAlloc API!\n"); - } - - //decommit the specified region - err = VirtualFree(lpVirtualAddress,1024,MEM_DECOMMIT); - if(0 == err) - { - Fail("\nFailed to call VirtualFree API!\n"); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test8/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test8/testinfo.dat deleted file mode 100644 index c0ee6b6a6..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test8/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Filemapping_memmgt -Function = VirtualAlloc -Name = Positive test for VirtualAlloc API -TYPE = DEFAULT -EXE1 = virtualalloc -Description -=Test the VirtualAlloc with MEM_RESERVE allocation type -=and PAGE_READWRITE access protection diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test9/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test9/CMakeLists.txt deleted file mode 100644 index 7639adfc9..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test9/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - VirtualAlloc.cpp -) - -add_executable(paltest_virtualalloc_test9 - ${SOURCES} -) - -add_dependencies(paltest_virtualalloc_test9 coreclrpal) - -target_link_libraries(paltest_virtualalloc_test9 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test9/VirtualAlloc.cpp b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test9/VirtualAlloc.cpp deleted file mode 100644 index 2711addac..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test9/VirtualAlloc.cpp +++ /dev/null @@ -1,48 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: virtualalloc.c -** -** Purpose: Positive test the VirtualAlloc API. -** Call VirtualAlloc with MEM_RESERVE allocation type -** and PAGE_EXECUTE access protection - -** -**============================================================*/ -#include - -int __cdecl main(int argc, char *argv[]) -{ - int err; - LPVOID lpVirtualAddress; - - //Initialize the PAL environment - err = PAL_Initialize(argc, argv); - if(0 != err) - { - ExitProcess(FAIL); - } - - //Allocate the physical storage in memory or in the paging file on disk - lpVirtualAddress = VirtualAlloc(NULL,//system determine where to allocate the region - 1024, //specify the size - MEM_RESERVE, //allocation type - PAGE_EXECUTE); //access protection - if(NULL == lpVirtualAddress) - { - Fail("\nFailed to call VirtualAlloc API!\n"); - } - - //decommit the specified region - err = VirtualFree(lpVirtualAddress,1024,MEM_DECOMMIT); - if(0 == err) - { - Fail("\nFailed to call VirtualFree API!\n"); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test9/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test9/testinfo.dat deleted file mode 100644 index 1e83744bb..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test9/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Filemapping_memmgt -Function = VirtualAlloc -Name = Positive test for VirtualAlloc API -TYPE = DEFAULT -EXE1 = virtualalloc -Description -=Test the VirtualAlloc with MEM_RESERVE allocation type -=and PAGE_EXECUTE access protection diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualFree/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/VirtualFree/CMakeLists.txt deleted file mode 100644 index 1962ade35..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualFree/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) -add_subdirectory(test3) - diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualFree/test1/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/VirtualFree/test1/CMakeLists.txt deleted file mode 100644 index e16a7ff40..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualFree/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - VirtualFree.cpp -) - -add_executable(paltest_virtualfree_test1 - ${SOURCES} -) - -add_dependencies(paltest_virtualfree_test1 coreclrpal) - -target_link_libraries(paltest_virtualfree_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualFree/test1/VirtualFree.cpp b/src/pal/tests/palsuite/filemapping_memmgt/VirtualFree/test1/VirtualFree.cpp deleted file mode 100644 index 0f4f144aa..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualFree/test1/VirtualFree.cpp +++ /dev/null @@ -1,48 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: virtualfree.c -** -** Purpose: Positive test the VirtualFree API. -** Call VirtualFree with MEM_DECOMMIT -** free operation type -** -** -**============================================================*/ -#include - -int __cdecl main(int argc, char *argv[]) -{ - int err; - LPVOID lpVirtualAddress; - - //Initialize the PAL environment - err = PAL_Initialize(argc, argv); - if(0 != err) - { - ExitProcess(FAIL); - } - - //Allocate the physical storage in memory or in the paging file on disk - lpVirtualAddress = VirtualAlloc(NULL,//system determine where to allocate the region - 1024, //specify the size - MEM_COMMIT, //allocation type - PAGE_READONLY); //access protection - if(NULL == lpVirtualAddress) - { - Fail("\nFailed to call VirtualAlloc API!\n"); - } - - //decommit the specified region - err = VirtualFree(lpVirtualAddress,1024,MEM_DECOMMIT); - if(0 == err) - { - Fail("\nFailed to call VirtualFree API!\n"); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualFree/test1/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/VirtualFree/test1/testinfo.dat deleted file mode 100644 index 284863568..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualFree/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Filemapping_memmgt -Function = VirtualFree -Name = Positive test for VirtualFree API -TYPE = DEFAULT -EXE1 = virtualfree -Description -=Test the VirtualFree with MEM_DECOMMIT free -=operation type diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualFree/test2/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/VirtualFree/test2/CMakeLists.txt deleted file mode 100644 index 576dc05d1..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualFree/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - VirtualFree.cpp -) - -add_executable(paltest_virtualfree_test2 - ${SOURCES} -) - -add_dependencies(paltest_virtualfree_test2 coreclrpal) - -target_link_libraries(paltest_virtualfree_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualFree/test2/VirtualFree.cpp b/src/pal/tests/palsuite/filemapping_memmgt/VirtualFree/test2/VirtualFree.cpp deleted file mode 100644 index 70064a3bf..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualFree/test2/VirtualFree.cpp +++ /dev/null @@ -1,54 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: virtualfree.c -** -** Purpose: Positive test the VirtualFree API. -** Call VirtualFree with MEM_RELEASE -** free operation type -** -** -**============================================================*/ -#include - -int __cdecl main(int argc, char *argv[]) -{ - int err; - LPVOID lpVirtualAddress; - - //Initialize the PAL environment - err = PAL_Initialize(argc, argv); - if(0 != err) - { - ExitProcess(FAIL); - } - - //Allocate the physical storage in memory or in the paging file on disk - lpVirtualAddress = VirtualAlloc(NULL,//system determine where to allocate the region - 1024, //specify the size - MEM_COMMIT, //allocation type - PAGE_READONLY); //access protection - if(NULL == lpVirtualAddress) - { - Fail("\nFailed to call VirtualAlloc API!\n"); - PAL_Terminate(); - return 1; - } - - //decommit the specified region - err = VirtualFree(lpVirtualAddress,//base address - 0, //must be zero with MEM_RELEASE - MEM_RELEASE);//free operation - if(0 == err) - { - Fail("\nFailed to call VirtualFree API!\n"); - PAL_Terminate(); - return 1; - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualFree/test2/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/VirtualFree/test2/testinfo.dat deleted file mode 100644 index ea380c367..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualFree/test2/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Filemapping_memmgt -Function = VirtualFree -Name = Positive test for VirtualFree API -TYPE = DEFAULT -EXE1 = virtualfree -Description -=Test the VirtualFree with MEM_RELEASE free -=operation type diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualFree/test3/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/VirtualFree/test3/CMakeLists.txt deleted file mode 100644 index b56ed0714..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualFree/test3/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - VirtualFree.cpp -) - -add_executable(paltest_virtualfree_test3 - ${SOURCES} -) - -add_dependencies(paltest_virtualfree_test3 coreclrpal) - -target_link_libraries(paltest_virtualfree_test3 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualFree/test3/VirtualFree.cpp b/src/pal/tests/palsuite/filemapping_memmgt/VirtualFree/test3/VirtualFree.cpp deleted file mode 100644 index 27f1936be..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualFree/test3/VirtualFree.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: virtualfree.c -** -** Purpose: Positive test the VirtualFree API. -** Call VirtualFree with MEM_RELEASE -** and MEM_DECOMMIT free operation type -** -** -**============================================================*/ -#include - -#define VIRTUALSIZE 1024 - - -int __cdecl main(int argc, char *argv[]) -{ - int err; - LPVOID lpVirtualAddress; - - //Initialize the PAL environment - err = PAL_Initialize(argc, argv); - if(0 != err) - { - ExitProcess(FAIL); - } - - //Allocate the physical storage in memory or in the paging file on disk - lpVirtualAddress = VirtualAlloc(NULL,//system determine where to allocate the region - VIRTUALSIZE, //specify the size - MEM_RESERVE, //allocation type - PAGE_NOACCESS); //access protection - if(NULL == lpVirtualAddress) - { - Fail("\nFailed to call VirtualAlloc API!\n"); - } - - //decommit and release the specified region - err = VirtualFree(lpVirtualAddress, //base address - VIRTUALSIZE, //decommited size - MEM_DECOMMIT|MEM_RELEASE);//free operation - if(0 != err) - { - Fail("\nFailed to call VirtualFree API!\n"); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualFree/test3/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/VirtualFree/test3/testinfo.dat deleted file mode 100644 index c27b7ad3e..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualFree/test3/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Filemapping_memmgt -Function = VirtualFree -Name = Positive test for VirtualFree API -TYPE = DEFAULT -EXE1 = virtualfree -Description -=Test the VirtualFree with MEM_DECOMMIT|MEM_RELEASE free -=operation type diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/CMakeLists.txt deleted file mode 100644 index cac5452ec..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) -add_subdirectory(test3) -add_subdirectory(test4) -add_subdirectory(test6) -add_subdirectory(test7) - diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test1/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test1/CMakeLists.txt deleted file mode 100644 index 2e3d26c74..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - VirtualProtect.cpp -) - -add_executable(paltest_virtualprotect_test1 - ${SOURCES} -) - -add_dependencies(paltest_virtualprotect_test1 coreclrpal) - -target_link_libraries(paltest_virtualprotect_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test1/VirtualProtect.cpp b/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test1/VirtualProtect.cpp deleted file mode 100644 index 1a28bd156..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test1/VirtualProtect.cpp +++ /dev/null @@ -1,69 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: virtualprotect.c -** -** Purpose: Positive test the VirtualProtect API. -** Call VirtualProtect to set new protect as -** PAGE_READWRITE -** -** -**============================================================*/ -#include - -#define REGIONSIZE 1024 - -int __cdecl main(int argc, char *argv[]) -{ - int err; - LPVOID lpVirtualAddress; - DWORD OldProtect; - - //Initialize the PAL environment - err = PAL_Initialize(argc, argv); - if(0 != err) - { - ExitProcess(FAIL); - } - - //Allocate the physical storage in memory or in the paging file on disk - lpVirtualAddress = VirtualAlloc(NULL,//system determine where to allocate the region - REGIONSIZE, //specify the size - MEM_COMMIT, //allocation type - PAGE_READONLY); //access protection - if(NULL == lpVirtualAddress) - { - Fail("\nFailed to call VirtualAlloc API!\n"); - } - - OldProtect = PAGE_READONLY; - //Set new access protection - err = VirtualProtect(lpVirtualAddress, - REGIONSIZE, //specify the region size - PAGE_READWRITE,//desied access protection - &OldProtect);//old access protection - if(0 == err) - { - Trace("\nFailed to call VirtualProtect API!\n"); - err = VirtualFree(lpVirtualAddress,REGIONSIZE,MEM_DECOMMIT); - if(0 == err) - { - Fail("\nFailed to call VirtualFree API!\n"); - } - Fail(""); - } - - - //decommit the specified region - err = VirtualFree(lpVirtualAddress,REGIONSIZE,MEM_DECOMMIT); - if(0 == err) - { - Fail("\nFailed to call VirtualFree API!\n"); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test1/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test1/testinfo.dat deleted file mode 100644 index 6b78c079e..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Filemapping_memmgt -Function = VirtualProtect -Name = Positive test for VirtualProtect - with PAGE_READWRITE -TYPE = DEFAULT -EXE1 = virtualprotect -Description -=Test the VirtualProtect to set new access protection -=as PAGE_READWRITE diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test2/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test2/CMakeLists.txt deleted file mode 100644 index 4064bb5ec..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - VirtualProtect.cpp -) - -add_executable(paltest_virtualprotect_test2 - ${SOURCES} -) - -add_dependencies(paltest_virtualprotect_test2 coreclrpal) - -target_link_libraries(paltest_virtualprotect_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test2/VirtualProtect.cpp b/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test2/VirtualProtect.cpp deleted file mode 100644 index 64a08d788..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test2/VirtualProtect.cpp +++ /dev/null @@ -1,69 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: virtualprotect.c -** -** Purpose: Positive test the VirtualProtect API. -** Call VirtualProtect to set new protect as -** PAGE_EXECUTE -** -** -**============================================================*/ -#include - -#define REGIONSIZE 1024 - -int __cdecl main(int argc, char *argv[]) -{ - int err; - LPVOID lpVirtualAddress; - DWORD OldProtect; - - //Initialize the PAL environment - err = PAL_Initialize(argc, argv); - if(0 != err) - { - ExitProcess(FAIL); - } - - //Allocate the physical storage in memory or in the paging file on disk - lpVirtualAddress = VirtualAlloc(NULL,//determine where to allocate the region - REGIONSIZE, //specify the size - MEM_COMMIT, //allocation type - PAGE_READONLY); //access protection - if(NULL == lpVirtualAddress) - { - Fail("\nFailed to call VirtualAlloc API!\n"); - } - - OldProtect = PAGE_READONLY; - //Set new access protection - err = VirtualProtect(lpVirtualAddress, - REGIONSIZE, //specify the region size - PAGE_EXECUTE,//desied access protection - &OldProtect);//old access protection - if(0 == err) - { - Trace("\nFailed to call VirtualProtect API!\n"); - err = VirtualFree(lpVirtualAddress,REGIONSIZE,MEM_DECOMMIT); - if(0 == err) - { - Fail("\nFailed to call VirtualFree API!\n"); - } - Fail(""); - } - - - //decommit the specified region - err = VirtualFree(lpVirtualAddress,REGIONSIZE,MEM_DECOMMIT); - if(0 == err) - { - Fail("\nFailed to call VirtualFree API!\n"); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test2/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test2/testinfo.dat deleted file mode 100644 index d5fa0cfbc..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test2/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Filemapping_memmgt -Function = VirtualProtect -Name = Positive test for VirtualProtect - with PAGE_EXECUTE -TYPE = DEFAULT -EXE1 = virtualprotect -Description -=Test the VirtualProtect to set new access protection -=as PAGE_EXECUTE diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test3/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test3/CMakeLists.txt deleted file mode 100644 index 11347b92e..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test3/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - VirtualProtect.cpp -) - -add_executable(paltest_virtualprotect_test3 - ${SOURCES} -) - -add_dependencies(paltest_virtualprotect_test3 coreclrpal) - -target_link_libraries(paltest_virtualprotect_test3 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test3/VirtualProtect.cpp b/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test3/VirtualProtect.cpp deleted file mode 100644 index 0f738630e..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test3/VirtualProtect.cpp +++ /dev/null @@ -1,69 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: virtualprotect.c -** -** Purpose: Positive test the VirtualProtect API. -** Call VirtualProtect to set new protect as -** PAGE_EXECUTE_READ -** -** -**============================================================*/ -#include - -#define REGIONSIZE 1024 - -int __cdecl main(int argc, char *argv[]) -{ - int err; - LPVOID lpVirtualAddress; - DWORD OldProtect; - - //Initialize the PAL environment - err = PAL_Initialize(argc, argv); - if(0 != err) - { - ExitProcess(FAIL); - } - - //Allocate the physical storage in memory or in the paging file on disk - lpVirtualAddress = VirtualAlloc(NULL,//determine where to allocate the region - REGIONSIZE, //specify the size - MEM_COMMIT, //allocation type - PAGE_READONLY); //access protection - if(NULL == lpVirtualAddress) - { - Fail("\nFailed to call VirtualAlloc API!\n"); - } - - OldProtect = PAGE_READONLY; - //Set new access protection - err = VirtualProtect(lpVirtualAddress, - REGIONSIZE, //specify the region size - PAGE_EXECUTE_READ,//desied access protection - &OldProtect);//old access protection - if(0 == err) - { - Trace("\nFailed to call VirtualProtect API!\n"); - err = VirtualFree(lpVirtualAddress,REGIONSIZE,MEM_DECOMMIT); - if(0 == err) - { - Fail("\nFailed to call VirtualFree API!\n"); - } - Fail(""); - } - - - //decommit the specified region - err = VirtualFree(lpVirtualAddress,REGIONSIZE,MEM_DECOMMIT); - if(0 == err) - { - Fail("\nFailed to call VirtualFree API!\n"); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test3/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test3/testinfo.dat deleted file mode 100644 index 7c64c3092..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test3/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Filemapping_memmgt -Function = VirtualProtect -Name = Positive test for VirtualProtect - with PAGE_EXECUTE_READ -TYPE = DEFAULT -EXE1 = virtualprotect -Description -=Test the VirtualProtect to set new access protection -=as PAGE_EXECUTE_READ diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test4/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test4/CMakeLists.txt deleted file mode 100644 index ed891093f..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test4/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - VirtualProtect.cpp -) - -add_executable(paltest_virtualprotect_test4 - ${SOURCES} -) - -add_dependencies(paltest_virtualprotect_test4 coreclrpal) - -target_link_libraries(paltest_virtualprotect_test4 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test4/VirtualProtect.cpp b/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test4/VirtualProtect.cpp deleted file mode 100644 index 926d501d0..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test4/VirtualProtect.cpp +++ /dev/null @@ -1,68 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: virtualprotect.c -** -** Purpose: Positive test the VirtualProtect API. -** Call VirtualProtect to set new protect as -** PAGE_EXECUTE_READWRITE -** -** -**============================================================*/ -#include - -#define REGIONSIZE 1024 - -int __cdecl main(int argc, char *argv[]) -{ - int err; - LPVOID lpVirtualAddress; - DWORD OldProtect; - - //Initialize the PAL environment - err = PAL_Initialize(argc, argv); - if(0 != err) - { - ExitProcess(FAIL); - } - - //Allocate the physical storage in memory or in the paging file on disk - lpVirtualAddress = VirtualAlloc(NULL,//determine where to allocate the region - REGIONSIZE, //specify the size - MEM_COMMIT, //allocation type - PAGE_READONLY); //access protection - if(NULL == lpVirtualAddress) - { - Fail("\nFailed to call VirtualAlloc API!\n"); - } - - OldProtect = PAGE_READONLY; - //Set new access protection - err = VirtualProtect(lpVirtualAddress, - REGIONSIZE, //specify the region size - PAGE_EXECUTE_READWRITE,//desied access protection - &OldProtect);//old access protection - if(0 == err) - { - Trace("\nFailed to call VirtualProtect API!\n"); - err = VirtualFree(lpVirtualAddress,REGIONSIZE,MEM_DECOMMIT); - if(0 == err) - { - Fail("\nFailed to call VirtualFree API!\n"); - } - Fail(""); - } - - //decommit the specified region - err = VirtualFree(lpVirtualAddress,REGIONSIZE,MEM_DECOMMIT); - if(0 == err) - { - Fail("\nFailed to call VirtualFree API!\n"); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test4/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test4/testinfo.dat deleted file mode 100644 index c34407311..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test4/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Filemapping_memmgt -Function = VirtualProtect -Name = Positive test for VirtualProtect - with PAGE_EXECUTE_READWRITE -TYPE = DEFAULT -EXE1 = virtualprotect -Description -=Test the VirtualProtect to set new access protection -=as PAGE_EXECUTE_READWRITE diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test6/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test6/CMakeLists.txt deleted file mode 100644 index 5fc3da928..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test6/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - VirtualProtect.cpp -) - -add_executable(paltest_virtualprotect_test6 - ${SOURCES} -) - -add_dependencies(paltest_virtualprotect_test6 coreclrpal) - -target_link_libraries(paltest_virtualprotect_test6 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test6/VirtualProtect.cpp b/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test6/VirtualProtect.cpp deleted file mode 100644 index d60b323ec..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test6/VirtualProtect.cpp +++ /dev/null @@ -1,68 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: virtualprotect.c -** -** Purpose: Positive test the VirtualProtect API. -** Call VirtualProtect to set new protect as -** PAGE_NOACCESS -** -** -**============================================================*/ -#include - -#define REGIONSIZE 1024 - -int __cdecl main(int argc, char *argv[]) -{ - int err; - LPVOID lpVirtualAddress; - DWORD OldProtect; - - //Initialize the PAL environment - err = PAL_Initialize(argc, argv); - if(0 != err) - { - ExitProcess(FAIL); - } - //Allocate the physical storage in memory or in the paging file on disk - lpVirtualAddress = VirtualAlloc(NULL,//determine where to allocate the region - REGIONSIZE, //specify the size - MEM_COMMIT, //allocation type - PAGE_READONLY); //access protection - if(NULL == lpVirtualAddress) - { - Fail("\nFailed to call VirtualAlloc API!\n"); - } - - OldProtect = PAGE_READONLY; - //Set new access protection - err = VirtualProtect(lpVirtualAddress, - REGIONSIZE, //specify the region size - PAGE_NOACCESS,//desied access protection - &OldProtect);//old access protection - if(0 == err) - { - Trace("\nFailed to call VirtualProtect API!\n"); - err = VirtualFree(lpVirtualAddress,REGIONSIZE,MEM_DECOMMIT); - if(0 == err) - { - Fail("\nFailed to call VirtualFree API!\n"); - } - Fail(""); - } - - - //decommit the specified region - err = VirtualFree(lpVirtualAddress,REGIONSIZE,MEM_DECOMMIT); - if(0 == err) - { - Fail("\nFailed to call VirtualFree API!\n"); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test6/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test6/testinfo.dat deleted file mode 100644 index 71ccad563..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test6/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Filemapping_memmgt -Function = VirtualProtect -Name = Positive test for VirtualProtect - with PAGE_NOACCESS -TYPE = DEFAULT -EXE1 = virtualprotect -Description -=Test the VirtualProtect to set new access protection -=as PAGE_NOACCESS diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test7/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test7/CMakeLists.txt deleted file mode 100644 index 8f47e6029..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test7/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - VirtualProtect.cpp -) - -add_executable(paltest_virtualprotect_test7 - ${SOURCES} -) - -add_dependencies(paltest_virtualprotect_test7 coreclrpal) - -target_link_libraries(paltest_virtualprotect_test7 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test7/VirtualProtect.cpp b/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test7/VirtualProtect.cpp deleted file mode 100644 index edc37711f..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test7/VirtualProtect.cpp +++ /dev/null @@ -1,69 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: virtualprotect.c -** -** Purpose: Positive test the VirtualProtect API. -** Call VirtualProtect to set new protect as -** PAGE_READONLY -** -** -**============================================================*/ -#include - -#define REGIONSIZE 1024 - -int __cdecl main(int argc, char *argv[]) -{ - int err; - LPVOID lpVirtualAddress; - DWORD OldProtect; - - //Initialize the PAL environment - err = PAL_Initialize(argc, argv); - if(0 != err) - { - ExitProcess(FAIL); - } - - //Allocate the physical storage in memory or in the paging file on disk - lpVirtualAddress = VirtualAlloc(NULL,//determine where to allocate the region - REGIONSIZE, //specify the size - MEM_COMMIT, //allocation type - PAGE_READWRITE); //access protection - if(NULL == lpVirtualAddress) - { - Fail("\nFailed to call VirtualAlloc API!\n"); - } - - OldProtect = PAGE_READONLY; - //Set new access protection - err = VirtualProtect(lpVirtualAddress, - REGIONSIZE, //specify the region size - PAGE_READONLY,//desied access protection - &OldProtect);//old access protection - if(0 == err) - { - Trace("\nFailed to call VirtualProtect API!\n"); - err = VirtualFree(lpVirtualAddress,REGIONSIZE,MEM_DECOMMIT); - if(0 == err) - { - Fail("\nFailed to call VirtualFree API!\n"); - } - Fail(""); - } - - - //decommit the specified region - err = VirtualFree(lpVirtualAddress,REGIONSIZE,MEM_DECOMMIT); - if(0 == err) - { - Fail("\nFailed to call VirtualFree API!\n"); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test7/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test7/testinfo.dat deleted file mode 100644 index 6b6eb58b3..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualProtect/test7/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Filemapping_memmgt -Function = VirtualProtect -Name = Positive test for VirtualProtect - with PAGE_READONLY -TYPE = DEFAULT -EXE1 = virtualprotect -Description -=Test the VirtualProtect to set new access protection -=as PAGE_READONLY diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualQuery/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/VirtualQuery/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualQuery/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualQuery/test1/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/VirtualQuery/test1/CMakeLists.txt deleted file mode 100644 index 16ec598f3..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualQuery/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - VirtualQuery.cpp -) - -add_executable(paltest_virtualquery_test1 - ${SOURCES} -) - -add_dependencies(paltest_virtualquery_test1 coreclrpal) - -target_link_libraries(paltest_virtualquery_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualQuery/test1/VirtualQuery.cpp b/src/pal/tests/palsuite/filemapping_memmgt/VirtualQuery/test1/VirtualQuery.cpp deleted file mode 100644 index 44216ae56..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualQuery/test1/VirtualQuery.cpp +++ /dev/null @@ -1,68 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: virtualquery.c -** -** Purpose: Positive test the VirtualQuery API. -** Call VirtualQuery to get the virtual -** page info -** -** -**============================================================*/ -#include - -#define VIRTUALMEMORYSIZE 1024 - -int __cdecl main(int argc, char *argv[]) -{ - int err; - LPVOID lpVirtualAddress; - MEMORY_BASIC_INFORMATION PageInfo; - DWORD dwBufferSize; - - //Initialize the PAL environment - err = PAL_Initialize(argc, argv); - if(0 != err) - { - ExitProcess(FAIL); - } - - //Allocate the physical storage in memory or in the paging file on disk - lpVirtualAddress = VirtualAlloc(NULL,//determine where to allocate the region - VIRTUALMEMORYSIZE, //specify the size - MEM_COMMIT, //allocation type - PAGE_READONLY); //access protection - if(NULL == lpVirtualAddress) - { - Fail("\nFailed to call VirtualAlloc API!\n"); - } - - //get the virtual page info - dwBufferSize = - VirtualQuery(lpVirtualAddress,&PageInfo,sizeof(MEMORY_BASIC_INFORMATION)); - - if(dwBufferSize <= 0 || - PageInfo.RegionSize <=0 || - PAGE_READONLY != PageInfo.AllocationProtect || - MEM_COMMIT != PageInfo.State) - { - Fail("\nFailed to call VirtualQuery API!\n"); - } - - - - //decommit the specified region - err = VirtualFree(lpVirtualAddress, //virtual page base address - VIRTUALMEMORYSIZE,//specify the size - MEM_DECOMMIT);//free operation - if(0 == err) - { - Fail("\nFailed to call VirtualFree API!\n"); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualQuery/test1/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/VirtualQuery/test1/testinfo.dat deleted file mode 100644 index b3462cd2f..000000000 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualQuery/test1/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Filemapping_memmgt -Function = VirtualQuery -Name = Positive test for VirtualQuery API -TYPE = DEFAULT -EXE1 = virtualquery -Description -=Test the VirtualQuery to get the virtual page info diff --git a/src/pal/tests/palsuite/loader/CMakeLists.txt b/src/pal/tests/palsuite/loader/CMakeLists.txt deleted file mode 100644 index 2c213b842..000000000 --- a/src/pal/tests/palsuite/loader/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(LoadLibraryA) -add_subdirectory(LoadLibraryW) - diff --git a/src/pal/tests/palsuite/loader/LoadLibraryA/CMakeLists.txt b/src/pal/tests/palsuite/loader/LoadLibraryA/CMakeLists.txt deleted file mode 100644 index ff4c550d3..000000000 --- a/src/pal/tests/palsuite/loader/LoadLibraryA/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) -add_subdirectory(test3) -add_subdirectory(test5) -add_subdirectory(test7) - diff --git a/src/pal/tests/palsuite/loader/LoadLibraryA/test1/CMakeLists.txt b/src/pal/tests/palsuite/loader/LoadLibraryA/test1/CMakeLists.txt deleted file mode 100644 index 319dcab32..000000000 --- a/src/pal/tests/palsuite/loader/LoadLibraryA/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - LoadLibraryA.cpp -) - -add_executable(paltest_loadlibrarya_test1 - ${SOURCES} -) - -add_dependencies(paltest_loadlibrarya_test1 coreclrpal) - -target_link_libraries(paltest_loadlibrarya_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/loader/LoadLibraryA/test1/LoadLibraryA.cpp b/src/pal/tests/palsuite/loader/LoadLibraryA/test1/LoadLibraryA.cpp deleted file mode 100644 index b4a8de136..000000000 --- a/src/pal/tests/palsuite/loader/LoadLibraryA/test1/LoadLibraryA.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: loadlibrarya.c -** -** Purpose: Positive test the LoadLibrary API. -** Call LoadLibrary to map a module into the calling -** process address space(DLL file) -** -** -**============================================================*/ -#include - -/* SHLEXT is defined only for Unix variants */ - -#if defined(SHLEXT) -#define ModuleName "librotor_pal"SHLEXT -#else -#define ModuleName "rotor_pal.dll" -#endif - -int __cdecl main(int argc, char *argv[]) -{ - HMODULE ModuleHandle; - int err; - - /* Initialize the PAL environment */ - err = PAL_Initialize(argc, argv); - if(0 != err) - { - ExitProcess(FAIL); - } - - /* load a module */ - ModuleHandle = LoadLibrary(ModuleName); - if(!ModuleHandle) - { - Fail("Failed to call LoadLibrary API!\n"); - } - - /* decrement the reference count of the loaded dll */ - err = FreeLibrary(ModuleHandle); - if(0 == err) - { - Fail("\nFailed to all FreeLibrary API!\n"); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/loader/LoadLibraryA/test1/testinfo.dat b/src/pal/tests/palsuite/loader/LoadLibraryA/test1/testinfo.dat deleted file mode 100644 index 096aab958..000000000 --- a/src/pal/tests/palsuite/loader/LoadLibraryA/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Loader -Function = LoadLibraryA -Name = Positive test for LoadLibraryA API to load Dynamic library module -TYPE = DEFAULT -EXE1 = loadlibrarya -Description -=Test the LoadLibraryA to map module into calling process address space - diff --git a/src/pal/tests/palsuite/loader/LoadLibraryA/test2/CMakeLists.txt b/src/pal/tests/palsuite/loader/LoadLibraryA/test2/CMakeLists.txt deleted file mode 100644 index e82b88a47..000000000 --- a/src/pal/tests/palsuite/loader/LoadLibraryA/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - LoadLibraryA.cpp -) - -add_executable(paltest_loadlibrarya_test2 - ${SOURCES} -) - -add_dependencies(paltest_loadlibrarya_test2 coreclrpal) - -target_link_libraries(paltest_loadlibrarya_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/loader/LoadLibraryA/test2/LoadLibraryA.cpp b/src/pal/tests/palsuite/loader/LoadLibraryA/test2/LoadLibraryA.cpp deleted file mode 100644 index d7cd9cb87..000000000 --- a/src/pal/tests/palsuite/loader/LoadLibraryA/test2/LoadLibraryA.cpp +++ /dev/null @@ -1,52 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: loadlibrarya.c -** -** Purpose: Negative test the LoadLibraryA API. -** Call LoadLibraryA with a not exist module Name -** -** -**============================================================*/ -#include - -int __cdecl main(int argc, char *argv[]) -{ - HMODULE ModuleHandle; - int err; - const char *pModuleName = "Not-exist-module-name"; - - /* Initialize the PAL environment */ - err = PAL_Initialize(argc, argv); - if(0 != err) - { - return FAIL; - } - - /*try to load a not exist module */ - ModuleHandle = LoadLibraryA(pModuleName); - if(NULL != ModuleHandle) - { - Trace("Failed to call LoadLibraryA with a not exist mudule name, " - "a NULL module handle is expected, but no NULL module handle " - "is returned, error code=%u\n", GetLastError()); - - /* decrement the reference count of the loaded module */ - err = FreeLibrary(ModuleHandle); - if(0 == err) - { - Trace("\nFailed to all FreeLibrary API to decrement " - "the reference count of the loaded module, " - "error code = %u\n", GetLastError()); - - } - - Fail(""); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/loader/LoadLibraryA/test2/MyModule.cpp b/src/pal/tests/palsuite/loader/LoadLibraryA/test2/MyModule.cpp deleted file mode 100644 index 883b3fbc4..000000000 --- a/src/pal/tests/palsuite/loader/LoadLibraryA/test2/MyModule.cpp +++ /dev/null @@ -1,19 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: mymoduale.c -** -** Purpose: Positive test the LoadLibrary API. -** - -** -**============================================================*/ - -int __cdecl main(int argc, char *argv[]) -{ - //only for testing LoadLibrary - return 0; -} diff --git a/src/pal/tests/palsuite/loader/LoadLibraryA/test2/testinfo.dat b/src/pal/tests/palsuite/loader/LoadLibraryA/test2/testinfo.dat deleted file mode 100644 index 97b7222b9..000000000 --- a/src/pal/tests/palsuite/loader/LoadLibraryA/test2/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Loader -Function = LoadLibraryA -Name = Negative test LoadLibraryA API to load a not exist module -TYPE = DEFAULT -EXE1 = loadlibrarya -Description -=Test the LoadLibraryA to load a not exist module - diff --git a/src/pal/tests/palsuite/loader/LoadLibraryA/test3/CMakeLists.txt b/src/pal/tests/palsuite/loader/LoadLibraryA/test3/CMakeLists.txt deleted file mode 100644 index 084dcbc5f..000000000 --- a/src/pal/tests/palsuite/loader/LoadLibraryA/test3/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - loadlibrarya.cpp -) - -add_executable(paltest_loadlibrarya_test3 - ${SOURCES} -) - -add_dependencies(paltest_loadlibrarya_test3 coreclrpal) - -target_link_libraries(paltest_loadlibrarya_test3 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/loader/LoadLibraryA/test3/loadlibrarya.cpp b/src/pal/tests/palsuite/loader/LoadLibraryA/test3/loadlibrarya.cpp deleted file mode 100644 index da38f98d0..000000000 --- a/src/pal/tests/palsuite/loader/LoadLibraryA/test3/loadlibrarya.cpp +++ /dev/null @@ -1,40 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: loadlibrarya.c -** -** Purpose: Negative test the LoadLibrary API with NULL module -** name. -** -** -**============================================================*/ -#include - -int __cdecl main(int argc, char *argv[]) -{ - HMODULE ModuleHandle; - int err; - - /*Initialize the PAL environment*/ - err = PAL_Initialize(argc, argv); - if(0 != err) - { - return FAIL; - } - - /*load a module by passing a NULL module name*/ - ModuleHandle = LoadLibraryA(NULL); - if(NULL != ModuleHandle) - { - Fail("\nFailed to call loadlibrarya API for a negative test, " - "call loadibrarya with NULL moudle name, a NULL module " - "handle is expected, but no NULL module handle is returned, " - "error code =%u\n", GetLastError()); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/loader/LoadLibraryA/test3/testinfo.dat b/src/pal/tests/palsuite/loader/LoadLibraryA/test3/testinfo.dat deleted file mode 100644 index c27c8e0ee..000000000 --- a/src/pal/tests/palsuite/loader/LoadLibraryA/test3/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Loader -Function = LoadLibraryA -Name = Negative test LoadLibraryA API with a NULL module name -TYPE = DEFAULT -EXE1 = loadlibrarya -Description -=Test the LoadLibraryA to map NULL module into calling -=process address space - diff --git a/src/pal/tests/palsuite/loader/LoadLibraryA/test5/CMakeLists.txt b/src/pal/tests/palsuite/loader/LoadLibraryA/test5/CMakeLists.txt deleted file mode 100644 index 7555d26ef..000000000 --- a/src/pal/tests/palsuite/loader/LoadLibraryA/test5/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - loadlibrarya.cpp -) - -add_executable(paltest_loadlibrarya_test5 - ${SOURCES} -) - -add_dependencies(paltest_loadlibrarya_test5 coreclrpal) - -target_link_libraries(paltest_loadlibrarya_test5 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/loader/LoadLibraryA/test5/loadlibrarya.cpp b/src/pal/tests/palsuite/loader/LoadLibraryA/test5/loadlibrarya.cpp deleted file mode 100644 index ab38d1a63..000000000 --- a/src/pal/tests/palsuite/loader/LoadLibraryA/test5/loadlibrarya.cpp +++ /dev/null @@ -1,67 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: loadlibrarya.c -** -** Purpose: Negative test the LoadLibraryA API. -** Call LoadLibraryA by passing a module name -** without extension but with a trailing dot. -** -** -**============================================================*/ -#include - -int __cdecl main(int argc, char *argv[]) -{ - HMODULE ModuleHandle; - char ModuleName[_MAX_FNAME]; - int err; - - /* Initialize the PAL environment */ - err = PAL_Initialize(argc, argv); - if(0 != err) - { - return FAIL; - } - - memset(ModuleName, 0, _MAX_FNAME); - - /*Module name without extension but with a trailing dot*/ -#if WIN32 - sprintf_s(ModuleName, _countof(ModuleName), "%s", "rotor_pal."); -#else - /* Under FreeBSD */ - sprintf_s(ModuleName, _countof(ModuleName), "%s", "librotor_pal."); -#endif - - /* load a module which does not have the file extension, - * but has a trailing dot - */ - ModuleHandle = LoadLibraryA(ModuleName); - if(NULL != ModuleHandle) - { - Trace("Failed to call LoadLibraryA API for a negative test " - "call LoadLibraryA with module name which does not have " - "extension except a trailing dot, a NULL module handle is" - "expected, but no NULL module handle is returned, " - "error code = %u\n", GetLastError()); - - - /* decrement the reference count of the loaded dll */ - err = FreeLibrary(ModuleHandle); - if(0 == err) - { - Trace("\nFailed to call FreeLibrary API, " - "error code = %u\n", GetLastError()); - } - - Fail(""); - } - - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/loader/LoadLibraryA/test5/testinfo.dat b/src/pal/tests/palsuite/loader/LoadLibraryA/test5/testinfo.dat deleted file mode 100644 index e2cd16c6f..000000000 --- a/src/pal/tests/palsuite/loader/LoadLibraryA/test5/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Loader -Function = LoadLibraryA -Name = Negative test for LoadLibraryA API by passing a module name without extension but with a trailing dot. -TYPE = DEFAULT -EXE1 = loadlibrarya -Description -=Test the LoadLibraryA by passing a module name without extension -=but with a trailing dot. - diff --git a/src/pal/tests/palsuite/loader/LoadLibraryA/test6/CMakeLists.txt b/src/pal/tests/palsuite/loader/LoadLibraryA/test6/CMakeLists.txt deleted file mode 100644 index c256ff567..000000000 --- a/src/pal/tests/palsuite/loader/LoadLibraryA/test6/CMakeLists.txt +++ /dev/null @@ -1,32 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(TESTSOURCES - loadlibrarya.cpp -) - -add_executable(paltest_loadlibrarya_test6 - ${TESTSOURCES} -) - -add_dependencies(paltest_loadlibrarya_test6 coreclrpal) - -target_link_libraries(paltest_loadlibrarya_test6 - ${COMMON_TEST_LIBRARIES} -) - - -set(HELPERSOURCES - dlltest.cpp -) - -add_executable(paltest_loadlibrarya_test6_dlltest - ${HELPERSOURCES} -) - -add_dependencies(paltest_loadlibrarya_test6_dlltest coreclrpal) - -target_link_libraries(paltest_loadlibrarya_test6_dlltest - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/loader/LoadLibraryA/test6/dlltest.cpp b/src/pal/tests/palsuite/loader/LoadLibraryA/test6/dlltest.cpp deleted file mode 100644 index 372657605..000000000 --- a/src/pal/tests/palsuite/loader/LoadLibraryA/test6/dlltest.cpp +++ /dev/null @@ -1,72 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================= -** -** Source: dllmain.c -** -** Purpose: Test to ensure DllMain() is called with DLL_THREAD_DETACH -** only the initial time that the library is loaded. -** -** Depends: None -** - -** -**===========================================================================*/ - -#include - -/* count of the number of times DllMain() - * was called with THREAD_ATTACH. - */ -static int g_attachCount = 0; - -/* standard DllMain() */ -BOOL PALAPI DllMain(HINSTANCE hinstDLL, DWORD reason, LPVOID lpvReserved) -{ - switch( reason ) - { - case DLL_PROCESS_ATTACH: - { - g_attachCount++; - break; - } - - case DLL_PROCESS_DETACH: - { - break; - } - - case DLL_THREAD_ATTACH: - { - break; - } - - case DLL_THREAD_DETACH: - { - break; - } - } - - return TRUE; -} - -#if _WIN32 -BOOL PALAPI _DllMainCRTStartup(HINSTANCE hinstDLL, DWORD reason, LPVOID lpvReserved) -{ - return DllMain(hinstDLL, reason, lpvReserved); -} -#endif - - - -/* function to return the current attach count */ -#if _WIN32 -__declspec(dllexport) -#endif -int PALAPI GetAttachCount( void ) -{ - return g_attachCount; -} - diff --git a/src/pal/tests/palsuite/loader/LoadLibraryA/test6/loadlibrarya.cpp b/src/pal/tests/palsuite/loader/LoadLibraryA/test6/loadlibrarya.cpp deleted file mode 100644 index ee825e643..000000000 --- a/src/pal/tests/palsuite/loader/LoadLibraryA/test6/loadlibrarya.cpp +++ /dev/null @@ -1,172 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: loadlibrary.c (test 6) -** -** Purpose: Positive test the LoadLibrary API. Test will verify -** that it is unable to load the library twice. Once by -** using the full path name and secondly by using the -** short name. -** - -** -**============================================================*/ -#include - -/*Define platform specific information*/ -#if defined(SHLEXT) -#define LibraryName "dlltest"SHLEXT -#define GETATTACHCOUNTNAME "GetAttachCount" -#else -typedef int (*dllfunct)(); -#define LibraryName "dlltest.dll" -#define GETATTACHCOUNTNAME "_GetAttachCount@0" -#endif - - -/* Helper function to test the loaded library. - */ -BOOL PALAPI TestDll(HMODULE hLib) -{ - int RetVal; - char FunctName[] = GETATTACHCOUNTNAME; - FARPROC DllFunc; - - /* Access a function from the loaded library. - */ - DllFunc = GetProcAddress(hLib, FunctName); - if(DllFunc == NULL) - { - Trace("ERROR: Unable to load function \"%s\" from library \"%s\"\n", - FunctName, - LibraryName); - return (FALSE); - } - - /* Verify that the DLL_PROCESS_ATTACH is only - * accessed once.*/ - RetVal = DllFunc(); - if (RetVal != 1) - { - Trace("ERROR: Unable to receive correct information from DLL! " - ":expected \"1\", returned \"%d\"\n", - RetVal); - return (FALSE); - } - - return (TRUE); -} - -int __cdecl main(int argc, char *argv[]) -{ - HANDLE hFullLib; - HANDLE hShortLib; - int iRetVal = FAIL; - char fullPath[_MAX_DIR]; - char drive[_MAX_DRIVE]; - char dir[_MAX_DIR]; - char fname[_MAX_FNAME]; - char ext[_MAX_EXT]; - - - - /* Initialize the PAL. */ - if ((PAL_Initialize(argc, argv)) != 0) - { - return (FAIL); - } - - /* Initalize the buffer. - */ - memset(fullPath, 0, _MAX_DIR); - - /* Get the full path to the library (DLL). - */ - - if (NULL != _fullpath(fullPath,argv[0],_MAX_DIR)) { - - _splitpath(fullPath,drive,dir,fname,ext); - _makepath(fullPath,drive,dir,LibraryName,""); - - - } else { - Fail("ERROR: conversion from relative path \" %s \" to absolute path failed. _fullpath returned NULL\n",argv[0]); - } - - /* Call Load library with the short name of - * the dll. - */ - hShortLib = LoadLibrary(LibraryName); - if(hShortLib == NULL) - { - Fail("ERROR:%u:Unable to load library %s\n", - GetLastError(), - LibraryName); - } - - /* Test the loaded library. - */ - if (!TestDll(hShortLib)) - { - iRetVal = FAIL; - goto cleanUpOne; - } - - /* Call Load library with the full name of - * the dll. - */ - hFullLib = LoadLibrary(fullPath); - if(hFullLib == NULL) - { - Trace("ERROR:%u:Unable to load library %s\n", - GetLastError(), - fullPath); - iRetVal = FAIL; - goto cleanUpTwo; - } - - /* Test the loaded library. - */ - if (!TestDll(hFullLib)) - { - iRetVal = FAIL; - goto cleanUpTwo; - } - - /* Test Succeeded. - */ - iRetVal = PASS; - -cleanUpTwo: - - /* Call the FreeLibrary API. - */ - if (!FreeLibrary(hFullLib)) - { - Trace("ERROR:%u: Unable to free library \"%s\"\n", - GetLastError(), - fullPath); - iRetVal = FAIL; - } - -cleanUpOne: - - /* Call the FreeLibrary API. - */ - if (!FreeLibrary(hShortLib)) - { - Trace("ERROR:%u: Unable to free library \"%s\"\n", - GetLastError(), - LibraryName); - iRetVal = FAIL; - } - - /* Terminate the PAL. - */ - PAL_Terminate(); - return iRetVal; - -} diff --git a/src/pal/tests/palsuite/loader/LoadLibraryA/test6/testinfo.dat b/src/pal/tests/palsuite/loader/LoadLibraryA/test6/testinfo.dat deleted file mode 100644 index 4be93b809..000000000 --- a/src/pal/tests/palsuite/loader/LoadLibraryA/test6/testinfo.dat +++ /dev/null @@ -1,17 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Loader -Function = LoadLibraryA -Name = Positive test for LoadLibrary API -TYPE = DEFAULT -EXE1 = loadlibrarya -LIB1 = dlltest -Description -= Positive test the LoadLibrary API. Test will verify -= that it is unable to load the library twice. Once by -= using the full path name and secondly by using the -= short name. - diff --git a/src/pal/tests/palsuite/loader/LoadLibraryA/test7/CMakeLists.txt b/src/pal/tests/palsuite/loader/LoadLibraryA/test7/CMakeLists.txt deleted file mode 100644 index 154f26f6f..000000000 --- a/src/pal/tests/palsuite/loader/LoadLibraryA/test7/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - LoadLibraryA.cpp -) - -add_executable(paltest_loadlibrarya_test7 - ${SOURCES} -) - -add_dependencies(paltest_loadlibrarya_test7 coreclrpal) - -target_link_libraries(paltest_loadlibrarya_test7 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/loader/LoadLibraryA/test7/LoadLibraryA.cpp b/src/pal/tests/palsuite/loader/LoadLibraryA/test7/LoadLibraryA.cpp deleted file mode 100644 index 5e6db8bb6..000000000 --- a/src/pal/tests/palsuite/loader/LoadLibraryA/test7/LoadLibraryA.cpp +++ /dev/null @@ -1,83 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: loadlibrarya.c -** -** Purpose: Positive test the LoadLibrary API by calling it multiple times. -** Call LoadLibrary to map a module into the calling -** process address space(DLL file) -** -** -**============================================================*/ -#include - -/* SHLEXT is defined only for Unix variants */ - -#if defined(SHLEXT) -#define ModuleName "librotor_pal"SHLEXT -#else -#define ModuleName "rotor_pal.dll" -#endif - -int __cdecl main(int argc, char *argv[]) -{ - HMODULE ModuleHandle; - HMODULE ReturnHandle; - int err; - - /* Initialize the PAL environment */ - err = PAL_Initialize(argc, argv); - if(0 != err) - { - ExitProcess(FAIL); - } - - /* load a module */ - ModuleHandle = LoadLibrary(ModuleName); - if(!ModuleHandle) - { - Fail("Error[%u]:Failed to call LoadLibrary API!\n", GetLastError()); - } - - /* Call LoadLibrary again, should return same handle as returned for first time */ - ReturnHandle = LoadLibrary(ModuleName); - if(!ReturnHandle) - { - Fail("Error[%u]:Failed to call LoadLibrary API second time!\n", GetLastError()); - } - - if(ModuleHandle != ReturnHandle) - { - Fail("Error[%u]:Failed to return the same handle while calling LoadLibrary API twice!\n", GetLastError()); - } - - Trace("Value of handle ModuleHandle[%x], ReturnHandle[%x]\n", ModuleHandle, ReturnHandle); - /* decrement the reference count of the loaded dll */ - err = FreeLibrary(ModuleHandle); - - if(0 == err) - { - Fail("Error[%u]:Failed to FreeLibrary API!\n", GetLastError()); - } - - /* Try Freeing a library again, should not fail */ - err = FreeLibrary(ReturnHandle); - - if(0 == err) - { - Fail("Error[%u][%d]: Was not successful in freeing a Library twice using FreeLibrary!\n", GetLastError(), err); - } - - /* Try Freeing a library again, should fail */ - err = FreeLibrary(ReturnHandle); - - if(1 != err) - { - Fail("Error[%u][%d]: Was successful in freeing a Library thrice using FreeLibrary!\n", GetLastError(), err); - } - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/loader/LoadLibraryA/test7/testinfo.dat b/src/pal/tests/palsuite/loader/LoadLibraryA/test7/testinfo.dat deleted file mode 100644 index 416caf34f..000000000 --- a/src/pal/tests/palsuite/loader/LoadLibraryA/test7/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Loader -Function = LoadLibraryA -Name = Positive and Negative test for LoadLibraryA API to load Dynamic library module -TYPE = DEFAULT -EXE1 = loadlibrarya -Description -=Test the LoadLibraryA to load multiple times and call unload more times than load - diff --git a/src/pal/tests/palsuite/loader/LoadLibraryA/test8/CMakeLists.txt b/src/pal/tests/palsuite/loader/LoadLibraryA/test8/CMakeLists.txt deleted file mode 100644 index 2bdbfb570..000000000 --- a/src/pal/tests/palsuite/loader/LoadLibraryA/test8/CMakeLists.txt +++ /dev/null @@ -1,32 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(TESTSOURCES - loadlibrarya.cpp -) - -add_executable(paltest_loadlibrarya_test8 - ${TESTSOURCES} -) - -add_dependencies(paltest_loadlibrarya_test8 coreclrpal) - -target_link_libraries(paltest_loadlibrarya_test8 - ${COMMON_TEST_LIBRARIES} -) - - -set(HELPERSOURCES - dlltest.cpp -) - -add_executable(paltest_loadlibrarya_test8_dlltest - ${HELPERSOURCES} -) - -add_dependencies(paltest_loadlibrarya_test8_dlltest coreclrpal) - -target_link_libraries(paltest_loadlibrarya_test8_dlltest - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/loader/LoadLibraryA/test8/dlltest.cpp b/src/pal/tests/palsuite/loader/LoadLibraryA/test8/dlltest.cpp deleted file mode 100644 index 372657605..000000000 --- a/src/pal/tests/palsuite/loader/LoadLibraryA/test8/dlltest.cpp +++ /dev/null @@ -1,72 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================= -** -** Source: dllmain.c -** -** Purpose: Test to ensure DllMain() is called with DLL_THREAD_DETACH -** only the initial time that the library is loaded. -** -** Depends: None -** - -** -**===========================================================================*/ - -#include - -/* count of the number of times DllMain() - * was called with THREAD_ATTACH. - */ -static int g_attachCount = 0; - -/* standard DllMain() */ -BOOL PALAPI DllMain(HINSTANCE hinstDLL, DWORD reason, LPVOID lpvReserved) -{ - switch( reason ) - { - case DLL_PROCESS_ATTACH: - { - g_attachCount++; - break; - } - - case DLL_PROCESS_DETACH: - { - break; - } - - case DLL_THREAD_ATTACH: - { - break; - } - - case DLL_THREAD_DETACH: - { - break; - } - } - - return TRUE; -} - -#if _WIN32 -BOOL PALAPI _DllMainCRTStartup(HINSTANCE hinstDLL, DWORD reason, LPVOID lpvReserved) -{ - return DllMain(hinstDLL, reason, lpvReserved); -} -#endif - - - -/* function to return the current attach count */ -#if _WIN32 -__declspec(dllexport) -#endif -int PALAPI GetAttachCount( void ) -{ - return g_attachCount; -} - diff --git a/src/pal/tests/palsuite/loader/LoadLibraryA/test8/loadlibrarya.cpp b/src/pal/tests/palsuite/loader/LoadLibraryA/test8/loadlibrarya.cpp deleted file mode 100644 index 6556e9c89..000000000 --- a/src/pal/tests/palsuite/loader/LoadLibraryA/test8/loadlibrarya.cpp +++ /dev/null @@ -1,235 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: loadlibrary.c (test 8) -** -** Purpose: Positive test the LoadLibrary API. Test will verify -** that it is unable to load the library twice. Once by -** using the full path name and secondly by using the -** short name. -** - -** -**============================================================*/ -#include - -/*Define platform specific information*/ -#if defined(SHLEXT) -#define LibraryName "dlltest"SHLEXT -#define GETATTACHCOUNTNAME "GetAttachCount" -#else -typedef int (*dllfunct)(); -#define LibraryName "dlltest.dll" -#define GETATTACHCOUNTNAME "_GetAttachCount@0" -#endif - - -/* Helper function to test the loaded library. - */ -BOOL PALAPI TestDll(HMODULE hLib) -{ - int RetVal; - char FunctName[] = GETATTACHCOUNTNAME; - FARPROC DllFunc; - - /* Access a function from the loaded library. - */ - DllFunc = GetProcAddress(hLib, FunctName); - if(DllFunc == NULL) - { - Trace("ERROR: Unable to load function \"%s\" from library \"%s\"\n", - FunctName, - LibraryName); - return (FALSE); - } - - /* Verify that the DLL_PROCESS_ATTACH is only - * accessed once.*/ - RetVal = DllFunc(); - if (RetVal != 1) - { - Trace("ERROR: Unable to receive correct information from DLL! " - ":expected \"1\", returned \"%d\"\n", - RetVal); - return (FALSE); - } - - return (TRUE); -} - -int __cdecl main(int argc, char *argv[]) -{ - HANDLE hFullLib; - HANDLE hShortLib; - HANDLE hRelLib; - - int iRetVal = FAIL; - char fullPath[_MAX_DIR]; - char drive[_MAX_DRIVE]; - char dir[_MAX_DIR]; - char relTestDir[_MAX_DIR]; - char fname[_MAX_FNAME]; - char ext[_MAX_EXT]; - - BOOL bRc = FALSE; - char relLibPath[_MAX_DIR]; - - - /* Initialize the PAL. */ - if ((PAL_Initialize(argc, argv)) != 0) - { - return (FAIL); - } - - /* Initalize the buffer. - */ - memset(fullPath, 0, _MAX_DIR); - - /* Get the full path to the library (DLL). - */ - - if (NULL != _fullpath(fullPath,argv[0],_MAX_DIR)) { - - _splitpath(fullPath,drive,dir,fname,ext); - _makepath(fullPath,drive,dir,LibraryName,""); - - - } else { - Fail("ERROR: conversion from relative path \" %s \" to absolute path failed. _fullpath returned NULL\n",argv[0]); - } - - /* Get relative path to the library - */ - _splitpath(argv[0], drive, relTestDir, fname, ext); - _makepath(relLibPath,drive,relTestDir,LibraryName,""); - - - /* Call Load library with the short name of - * the dll. - */ - hShortLib = LoadLibrary(LibraryName); - if(hShortLib == NULL) - { - Fail("ERROR:%u:Short:Unable to load library %s\n", - GetLastError(), - LibraryName); - } - - /* Test the loaded library. - */ - if (!TestDll(hShortLib)) - { - iRetVal = FAIL; - goto cleanUpOne; - } - - /* Call Load library with the full name of - * the dll. - */ - hFullLib = LoadLibrary(fullPath); - if(hFullLib == NULL) - { - Trace("ERROR:%u:Full:Unable to load library %s\n", - GetLastError(), - fullPath); - iRetVal = FAIL; - goto cleanUpTwo; - } - - /* Test the loaded library. - */ - if (!TestDll(hFullLib)) - { - iRetVal = FAIL; - goto cleanUpTwo; - } - - /* - ** Call the load library with the relative path - ** wrt to the directory ./testloadlibrary/.. - ** since we don't want to make any assumptions - ** regarding the type of build - */ - hRelLib = LoadLibrary(relLibPath); - if(hRelLib == NULL) - { - Trace("ERROR:%u:Rel:Unable to load library at %s\n", - GetLastError(), relLibPath); - iRetVal = FAIL; - goto cleanUpTwo; - } - - /* Test the loaded library. - */ - if (!TestDll(hRelLib)) - { - iRetVal = FAIL; - goto cleanUpThree; - } - - if( hRelLib != hFullLib ) - { - Trace("Relative and Absolute Paths to libraries don't have same handle\n"); - iRetVal = FAIL; - goto cleanUpThree; - } - - if( hRelLib != hShortLib ) - { - Trace("Relative and Short Paths to libraries don't have same handle\n"); - iRetVal = FAIL; - goto cleanUpThree; - } - - - /* Test Succeeded. - */ - iRetVal = PASS; - -cleanUpThree: - - /* Call the FreeLibrary API. - */ - - if (!FreeLibrary(hRelLib)) - { - Trace("ERROR:%u: Unable to free library \"%s\"\n", - GetLastError(), - relLibPath); - iRetVal = FAIL; - } - -cleanUpTwo: - - /* Call the FreeLibrary API. - */ - if (!FreeLibrary(hFullLib)) - { - Trace("ERROR:%u: Unable to free library \"%s\"\n", - GetLastError(), - fullPath); - iRetVal = FAIL; - } - -cleanUpOne: - - /* Call the FreeLibrary API. - */ - if (!FreeLibrary(hShortLib)) - { - Trace("ERROR:%u: Unable to free library \"%s\"\n", - GetLastError(), - LibraryName); - iRetVal = FAIL; - } - - - /* Terminate the PAL. - */ - PAL_TerminateEx(iRetVal); - return iRetVal; - -} diff --git a/src/pal/tests/palsuite/loader/LoadLibraryA/test8/testinfo.dat b/src/pal/tests/palsuite/loader/LoadLibraryA/test8/testinfo.dat deleted file mode 100644 index b552b7208..000000000 --- a/src/pal/tests/palsuite/loader/LoadLibraryA/test8/testinfo.dat +++ /dev/null @@ -1,17 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Loader -Function = LoadLibraryA -Name = Positive test for LoadLibrary API -TYPE = DEFAULT -EXE1 = loadlibrarya -LIB1 = dlltest -Description -= Positive test the LoadLibrary API. Test will verify -= that it is able to load the library thrice. Once by -= using the full path name, second by using the -= short name and third by using relative paths - diff --git a/src/pal/tests/palsuite/loader/LoadLibraryW/CMakeLists.txt b/src/pal/tests/palsuite/loader/LoadLibraryW/CMakeLists.txt deleted file mode 100644 index 37abc032a..000000000 --- a/src/pal/tests/palsuite/loader/LoadLibraryW/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) -add_subdirectory(test3) -add_subdirectory(test5) - diff --git a/src/pal/tests/palsuite/loader/LoadLibraryW/test1/CMakeLists.txt b/src/pal/tests/palsuite/loader/LoadLibraryW/test1/CMakeLists.txt deleted file mode 100644 index 569f6f792..000000000 --- a/src/pal/tests/palsuite/loader/LoadLibraryW/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - LoadLibraryW.cpp -) - -add_executable(paltest_loadlibraryw_test1 - ${SOURCES} -) - -add_dependencies(paltest_loadlibraryw_test1 coreclrpal) - -target_link_libraries(paltest_loadlibraryw_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/loader/LoadLibraryW/test1/LoadLibraryW.cpp b/src/pal/tests/palsuite/loader/LoadLibraryW/test1/LoadLibraryW.cpp deleted file mode 100644 index 4c1a551de..000000000 --- a/src/pal/tests/palsuite/loader/LoadLibraryW/test1/LoadLibraryW.cpp +++ /dev/null @@ -1,62 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: loadlibraryw.c -** -** Purpose: Positive test the LoadLibrary API. -** Call LoadLibrary to map a module into the calling -** process address space(DLL file) -** -** -**============================================================*/ -#define UNICODE -#include -/* SHLEXT is defined only for Unix variants */ - -#if defined(SHLEXT) -#define ModuleName "librotor_pal"SHLEXT -#else -#define ModuleName "rotor_pal.dll" -#endif - -int __cdecl main(int argc, char *argv[]) -{ - HMODULE ModuleHandle; - int err; - WCHAR *lpModuleName; - - /* Initialize the PAL environment */ - err = PAL_Initialize(argc, argv); - if(0 != err) - { - ExitProcess(FAIL); - } - - /* convert a normal string to a wide one */ - lpModuleName = convert(ModuleName); - - /* load a module */ - ModuleHandle = LoadLibrary(lpModuleName); - - /* free the memory */ - free(lpModuleName); - - if(!ModuleHandle) - { - Fail("Failed to call LoadLibrary API!\n"); - } - - - /* decrement the reference count of the loaded dll */ - err = FreeLibrary(ModuleHandle); - if(0 == err) - { - Fail("\nFailed to all FreeLibrary API!\n"); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/loader/LoadLibraryW/test1/testinfo.dat b/src/pal/tests/palsuite/loader/LoadLibraryW/test1/testinfo.dat deleted file mode 100644 index c5c4adc75..000000000 --- a/src/pal/tests/palsuite/loader/LoadLibraryW/test1/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Loader -Function = LoadLibraryW -Name = Positive test for LoadLibraryW API to load a dynamic library module -TYPE = DEFAULT -EXE1 = loadlibraryw -Description -=Test the LoadLibraryW to map module into calling process address space diff --git a/src/pal/tests/palsuite/loader/LoadLibraryW/test2/CMakeLists.txt b/src/pal/tests/palsuite/loader/LoadLibraryW/test2/CMakeLists.txt deleted file mode 100644 index e37f19a45..000000000 --- a/src/pal/tests/palsuite/loader/LoadLibraryW/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - loadlibraryw.cpp -) - -add_executable(paltest_loadlibraryw_test2 - ${SOURCES} -) - -add_dependencies(paltest_loadlibraryw_test2 coreclrpal) - -target_link_libraries(paltest_loadlibraryw_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/loader/LoadLibraryW/test2/loadlibraryw.cpp b/src/pal/tests/palsuite/loader/LoadLibraryW/test2/loadlibraryw.cpp deleted file mode 100644 index e8aebf77e..000000000 --- a/src/pal/tests/palsuite/loader/LoadLibraryW/test2/loadlibraryw.cpp +++ /dev/null @@ -1,62 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: loadlibraryw.c -** -** Purpose: Negative test the LoadLibraryW API. -** Call LoadLibraryW with a not exist module Name -** -** -**============================================================*/ -#define UNICODE -#include - -int __cdecl main(int argc, char *argv[]) -{ - HMODULE ModuleHandle; - int err; - WCHAR *pwModuleName; - const char *pModuleName = "Not-exist-module-name"; - - /* Initialize the PAL environment */ - err = PAL_Initialize(argc, argv); - if(0 != err) - { - return FAIL; - } - - /* convert a normal string to a wide one */ - pwModuleName = convert((char *)pModuleName); - - - /*try to load a not exist module */ - ModuleHandle = LoadLibraryW(pwModuleName); - - /* free the memory */ - free(pwModuleName); - - if(NULL != ModuleHandle) - { - Trace("Failed to call LoadLibraryW with a not exist mudule name, " - "a NULL module handle is expected, but no NULL module handle " - "is returned, error code=%u\n", GetLastError()); - - /* decrement the reference count of the loaded module */ - err = FreeLibrary(ModuleHandle); - if(0 == err) - { - Trace("\nFailed to all FreeLibrary API to decrement " - "the reference count of the loaded module, " - "error code = %u\n", GetLastError()); - - } - - Fail(""); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/loader/LoadLibraryW/test2/testinfo.dat b/src/pal/tests/palsuite/loader/LoadLibraryW/test2/testinfo.dat deleted file mode 100644 index bc107f006..000000000 --- a/src/pal/tests/palsuite/loader/LoadLibraryW/test2/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Loader -Function = LoadLibraryW -Name = Negative test LoadLibraryW API to load a not exist module -TYPE = DEFAULT -EXE1 = loadlibraryw -Description -=Test the LoadLibraryW to load a not exist module - diff --git a/src/pal/tests/palsuite/loader/LoadLibraryW/test3/CMakeLists.txt b/src/pal/tests/palsuite/loader/LoadLibraryW/test3/CMakeLists.txt deleted file mode 100644 index 73638dd62..000000000 --- a/src/pal/tests/palsuite/loader/LoadLibraryW/test3/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - loadlibraryw.cpp -) - -add_executable(paltest_loadlibraryw_test3 - ${SOURCES} -) - -add_dependencies(paltest_loadlibraryw_test3 coreclrpal) - -target_link_libraries(paltest_loadlibraryw_test3 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/loader/LoadLibraryW/test3/loadlibraryw.cpp b/src/pal/tests/palsuite/loader/LoadLibraryW/test3/loadlibraryw.cpp deleted file mode 100644 index c722edaf1..000000000 --- a/src/pal/tests/palsuite/loader/LoadLibraryW/test3/loadlibraryw.cpp +++ /dev/null @@ -1,41 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: loadlibraryw.c -** -** Purpose: Negative test the loadlibraryw API. -** Call loadlibraryw with NULL module name -** -** -**============================================================*/ -#define UNICODE -#include - -int __cdecl main(int argc, char *argv[]) -{ - HMODULE ModuleHandle; - int err; - - /* Initialize the PAL environment */ - err = PAL_Initialize(argc, argv); - if(0 != err) - { - return FAIL; - } - - /* load a module with a NULL module name */ - ModuleHandle = LoadLibraryW(NULL); - if(NULL != ModuleHandle) - { - Fail("\nFailed to call loadlibraryw API for a negative test, " - "call loadibraryw with NULL moudle name, a NULL module " - "handle is expected, but no NULL module handle is returned, " - "error code =%u\n", GetLastError()); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/loader/LoadLibraryW/test3/testinfo.dat b/src/pal/tests/palsuite/loader/LoadLibraryW/test3/testinfo.dat deleted file mode 100644 index bd20aaf99..000000000 --- a/src/pal/tests/palsuite/loader/LoadLibraryW/test3/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Loader -Function = LoadLibraryW -Name = Negative test loadlibraryw API with a NULL module name -TYPE = DEFAULT -EXE1 = loadlibraryw -Description -=Test the LoadLibraryW with a NULL module name diff --git a/src/pal/tests/palsuite/loader/LoadLibraryW/test5/CMakeLists.txt b/src/pal/tests/palsuite/loader/LoadLibraryW/test5/CMakeLists.txt deleted file mode 100644 index 5ab178d87..000000000 --- a/src/pal/tests/palsuite/loader/LoadLibraryW/test5/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - loadlibraryw.cpp -) - -add_executable(paltest_loadlibraryw_test5 - ${SOURCES} -) - -add_dependencies(paltest_loadlibraryw_test5 coreclrpal) - -target_link_libraries(paltest_loadlibraryw_test5 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/loader/LoadLibraryW/test5/loadlibraryw.cpp b/src/pal/tests/palsuite/loader/LoadLibraryW/test5/loadlibraryw.cpp deleted file mode 100644 index 6d92f029e..000000000 --- a/src/pal/tests/palsuite/loader/LoadLibraryW/test5/loadlibraryw.cpp +++ /dev/null @@ -1,71 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: loadlibraryw.c -** -** Purpose: Negative test the LoadLibraryW API. -** Call LoadLibraryW by passing a module name -** without extension but with a trailing dot. -** -** -**============================================================*/ -#define UNICODE -#include - -int __cdecl main(int argc, char *argv[]) -{ - HMODULE ModuleHandle; - int err; - WCHAR *lpModuleName; - char ModuleName[_MAX_FNAME]; - - /* Initialize the PAL environment */ - err = PAL_Initialize(argc, argv); - if(0 != err) - { - return FAIL; - } - - memset(ModuleName, 0, _MAX_FNAME); - - /*Module name without extension but with a trailing dot*/ -#if WIN32 - sprintf_s(ModuleName, _countof(ModuleName),"%s","rotor_pal."); -#else - sprintf_s(ModuleName, _countof(ModuleName),"%s","librotor_pal."); -#endif - - /* convert a normal string to a wide one */ - lpModuleName = convert(ModuleName); - - /* load a module */ - ModuleHandle = LoadLibraryW(lpModuleName); - - /* free the memory */ - free(lpModuleName); - - if(NULL != ModuleHandle) - { - Trace("Failed to call LoadLibraryW API for a negative test " - "call LoadLibraryW with module name which does not have " - "extension except a trailing dot, a NULL module handle is" - "expected, but no NULL module handle is returned, " - "error code = %u\n", GetLastError()); - - /* decrement the reference count of the loaded dll */ - err = FreeLibrary(ModuleHandle); - if(0 == err) - { - Trace("\nFailed to call FreeLibrary API, " - "error code = %u\n", GetLastError()); - } - - Fail(""); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/loader/LoadLibraryW/test5/testinfo.dat b/src/pal/tests/palsuite/loader/LoadLibraryW/test5/testinfo.dat deleted file mode 100644 index 8275f4164..000000000 --- a/src/pal/tests/palsuite/loader/LoadLibraryW/test5/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Loader -Function = LoadLibraryw -Name = Negative test for LoadLibraryW API by passing a module name without extension but with a trailing dot. -TYPE = DEFAULT -EXE1 = loadlibraryw -Description -=Test the LoadLibraryW by passing a module name without extension -=but with a trailing dot. - diff --git a/src/pal/tests/palsuite/locale_info/CMakeLists.txt b/src/pal/tests/palsuite/locale_info/CMakeLists.txt deleted file mode 100644 index c9756e97a..000000000 --- a/src/pal/tests/palsuite/locale_info/CMakeLists.txt +++ /dev/null @@ -1,25 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -# TODO: make the following tests compile if they are needed -# add_subdirectory(CompareStringA) -# add_subdirectory(CompareStringW) -# add_subdirectory(GetLocaleInfoW) -# add_subdirectory(GetSystemDefaultLangID) -# add_subdirectory(GetThreadLocale) -# add_subdirectory(GetTimeZoneInformation) -# add_subdirectory(GetUserDefaultLangID) -# add_subdirectory(GetUserDefaultLCID) -# add_subdirectory(IsValidLocale) -# add_subdirectory(SetThreadLocale) - -add_subdirectory(GetACP) -add_subdirectory(GetCPInfo) -add_subdirectory(IsDBCSLeadByte) -add_subdirectory(IsDBCSLeadByteEx) -add_subdirectory(IsValidCodePage) -add_subdirectory(MultiByteToWideChar) -add_subdirectory(WideCharToMultiByte) - - - - diff --git a/src/pal/tests/palsuite/locale_info/CompareStringA/CMakeLists.txt b/src/pal/tests/palsuite/locale_info/CompareStringA/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/locale_info/CompareStringA/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/locale_info/CompareStringA/test1/CMakeLists.txt b/src/pal/tests/palsuite/locale_info/CompareStringA/test1/CMakeLists.txt deleted file mode 100644 index 2ea8b71ae..000000000 --- a/src/pal/tests/palsuite/locale_info/CompareStringA/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_comparestringa_test1 - ${SOURCES} -) - -add_dependencies(paltest_comparestringa_test1 coreclrpal) - -target_link_libraries(paltest_comparestringa_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/locale_info/CompareStringA/test1/test1.cpp b/src/pal/tests/palsuite/locale_info/CompareStringA/test1/test1.cpp deleted file mode 100644 index 98c147af4..000000000 --- a/src/pal/tests/palsuite/locale_info/CompareStringA/test1/test1.cpp +++ /dev/null @@ -1,99 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: Tests that CompareStringA returns the correct value and can handle -** invalid parameters. -** -** -**==========================================================================*/ - -#define CSTR_LESS_THAN 1 -#define CSTR_EQUAL 2 -#define CSTR_GREATER_THAN 3 - -#include - -int __cdecl main(int argc, char *argv[]) -{ - char str1[] = {'f','o','o',0}; - char str2[] = {'f','o','o','x',0}; - char str3[] = {'f','O','o',0}; - int flags = NORM_IGNORECASE | NORM_IGNOREWIDTH; - int ret; - - if (0 != PAL_Initialize(argc, argv)) - { - return FAIL; - } - - ret = CompareStringA(0x0409, flags, str1, -1, str2, -1); - if (ret != CSTR_LESS_THAN) - { - Fail("CompareStringA with \"%S\" (%d) and \"%S\" (%d) did not return " - "CSTR_LESS_THAN!\n", str1, -1, str2, -1); - } - - ret = CompareStringA(0x0409, flags, str1, -1, str2, 3); - if (ret != CSTR_EQUAL) - { - Fail("CompareStringA with \"%S\" (%d) and \"%S\" (%d) did not return " - "CSTR_EQUAL!\n", str1, -1, str2, 3); - } - - ret = CompareStringA(0x0409, flags, str2, -1, str1, -1); - if (ret != CSTR_GREATER_THAN) - { - Fail("CompareStringA with \"%S\" (%d) and \"%S\" (%d) did not return " - "CSTR_GREATER_THAN!\n", str2, -1, str1, -1); - } - - ret = CompareStringA(0x0409, flags, str1, -1, str3, -1); - if (ret != CSTR_EQUAL) - { - Fail("CompareStringA with \"%S\" (%d) and \"%S\" (%d) did not return " - "CSTR_EQUAL!\n", str1, -1, str3, -1); - } - - ret = CompareStringA(0x0409, flags, str3, -1, str1, -1); - if (ret != CSTR_EQUAL) - { - Fail("CompareStringA with \"%S\" (%d) and \"%S\" (%d) did not return " - "CSTR_EQUAL!\n", str3, -1, str1, -1); - } - - ret = CompareStringA(0x0409, flags, str3, -1, str1, -1); - if (ret != CSTR_EQUAL) - { - Fail("CompareStringA with \"%S\" (%d) and \"%S\" (%d) did not return " - "CSTR_EQUAL!\n", str3, -1, str1, -1); - } - - ret = CompareStringA(0x0409, flags, str1, 0, str3, -1); - if (ret != CSTR_LESS_THAN) - { - Fail("CompareStringA with \"%S\" (%d) and \"%S\" (%d) did not return " - "CSTR_GREATER_THAN!\n", str1, 0, str3, -1); - } - - - ret = CompareStringA(0x0409, flags, NULL, -1, str3, -1); - if (ret != 0) - { - Fail("CompareStringA should have returned 0, got %d!\n", ret); - } - if (GetLastError() != ERROR_INVALID_PARAMETER) - { - Fail("CompareStringA should have set the last error to " - "ERROR_INVALID_PARAMETER!\n"); - } - - PAL_Terminate(); - - return PASS; -} - diff --git a/src/pal/tests/palsuite/locale_info/CompareStringA/test1/testinfo.dat b/src/pal/tests/palsuite/locale_info/CompareStringA/test1/testinfo.dat deleted file mode 100644 index e934b1376..000000000 --- a/src/pal/tests/palsuite/locale_info/CompareStringA/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Locale Information -Function = CompareStringA -Name = Test #1 for CompareStringA -TYPE = DEFAULT -EXE1 = test1 -Description -=Tests that CompareStringA returns the correct value and can handle -=invalid parameters. diff --git a/src/pal/tests/palsuite/locale_info/CompareStringW/CMakeLists.txt b/src/pal/tests/palsuite/locale_info/CompareStringW/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/locale_info/CompareStringW/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/locale_info/CompareStringW/test1/CMakeLists.txt b/src/pal/tests/palsuite/locale_info/CompareStringW/test1/CMakeLists.txt deleted file mode 100644 index 8f283a55d..000000000 --- a/src/pal/tests/palsuite/locale_info/CompareStringW/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_comparestringw_test1 - ${SOURCES} -) - -add_dependencies(paltest_comparestringw_test1 coreclrpal) - -target_link_libraries(paltest_comparestringw_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/locale_info/CompareStringW/test1/test1.cpp b/src/pal/tests/palsuite/locale_info/CompareStringW/test1/test1.cpp deleted file mode 100644 index bdf2c3dcf..000000000 --- a/src/pal/tests/palsuite/locale_info/CompareStringW/test1/test1.cpp +++ /dev/null @@ -1,99 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: Tests that CompareStringW returns the correct value and can handle -** invalid parameters. -** -** -**==========================================================================*/ - -#define CSTR_LESS_THAN 1 -#define CSTR_EQUAL 2 -#define CSTR_GREATER_THAN 3 - -#include - -int __cdecl main(int argc, char *argv[]) -{ - WCHAR str1[] = {'f','o','o',0}; - WCHAR str2[] = {'f','o','o','x',0}; - WCHAR str3[] = {'f','O','o',0}; - int flags = NORM_IGNORECASE | NORM_IGNOREWIDTH; - int ret; - - if (0 != PAL_Initialize(argc, argv)) - { - return FAIL; - } - - ret = CompareStringW(0x0409, flags, str1, -1, str2, -1); - if (ret != CSTR_LESS_THAN) - { - Fail("CompareStringW with \"%S\" (%d) and \"%S\" (%d) did not return " - "CSTR_LESS_THAN!\n", str1, -1, str2, -1); - } - - ret = CompareStringW(0x0409, flags, str1, -1, str2, 3); - if (ret != CSTR_EQUAL) - { - Fail("CompareStringW with \"%S\" (%d) and \"%S\" (%d) did not return " - "CSTR_EQUAL!\n", str1, -1, str2, 3); - } - - ret = CompareStringW(0x0409, flags, str2, -1, str1, -1); - if (ret != CSTR_GREATER_THAN) - { - Fail("CompareStringW with \"%S\" (%d) and \"%S\" (%d) did not return " - "CSTR_GREATER_THAN!\n", str2, -1, str1, -1); - } - - ret = CompareStringW(0x0409, flags, str1, -1, str3, -1); - if (ret != CSTR_EQUAL) - { - Fail("CompareStringW with \"%S\" (%d) and \"%S\" (%d) did not return " - "CSTR_EQUAL!\n", str1, -1, str3, -1); - } - - ret = CompareStringW(0x0409, flags, str3, -1, str1, -1); - if (ret != CSTR_EQUAL) - { - Fail("CompareStringW with \"%S\" (%d) and \"%S\" (%d) did not return " - "CSTR_EQUAL!\n", str3, -1, str1, -1); - } - - ret = CompareStringW(0x0409, flags, str3, -1, str1, -1); - if (ret != CSTR_EQUAL) - { - Fail("CompareStringW with \"%S\" (%d) and \"%S\" (%d) did not return " - "CSTR_EQUAL!\n", str3, -1, str1, -1); - } - - ret = CompareStringW(0x0409, flags, str1, 0, str3, -1); - if (ret != CSTR_LESS_THAN) - { - Fail("CompareStringW with \"%S\" (%d) and \"%S\" (%d) did not return " - "CSTR_GREATER_THAN!\n", str1, 0, str3, -1); - } - - - ret = CompareStringW(0x0409, flags, NULL, -1, str3, -1); - if (ret != 0) - { - Fail("CompareStringW should have returned 0, got %d!\n", ret); - } - if (GetLastError() != ERROR_INVALID_PARAMETER) - { - Fail("CompareStringW should have set the last error to " - "ERROR_INVALID_PARAMETER!\n"); - } - - PAL_Terminate(); - - return PASS; -} - diff --git a/src/pal/tests/palsuite/locale_info/CompareStringW/test1/testinfo.dat b/src/pal/tests/palsuite/locale_info/CompareStringW/test1/testinfo.dat deleted file mode 100644 index d41de3ee6..000000000 --- a/src/pal/tests/palsuite/locale_info/CompareStringW/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Locale Information -Function = CompareStringW -Name = Test #1 for CompareStringW -TYPE = DEFAULT -EXE1 = test1 -Description -=Tests that CompareStringW returns the correct value and can handle -=invalid parameters. diff --git a/src/pal/tests/palsuite/locale_info/GetACP/CMakeLists.txt b/src/pal/tests/palsuite/locale_info/GetACP/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/locale_info/GetACP/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/locale_info/GetACP/test1/CMakeLists.txt b/src/pal/tests/palsuite/locale_info/GetACP/test1/CMakeLists.txt deleted file mode 100644 index be766d7e8..000000000 --- a/src/pal/tests/palsuite/locale_info/GetACP/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_getacp_test1 - ${SOURCES} -) - -add_dependencies(paltest_getacp_test1 coreclrpal) - -target_link_libraries(paltest_getacp_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/locale_info/GetACP/test1/test1.cpp b/src/pal/tests/palsuite/locale_info/GetACP/test1/test1.cpp deleted file mode 100644 index 8ea078ee6..000000000 --- a/src/pal/tests/palsuite/locale_info/GetACP/test1/test1.cpp +++ /dev/null @@ -1,42 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: Tests that GetACP returns the expected default code page. -** -** -**==========================================================================*/ - - -#include - -/* - * NOTE: We only support code page 65001 (UTF-8). - */ - -#define EXPECTED_CP 65001 - -int __cdecl main(int argc, char *argv[]) -{ - int ret; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - ret = GetACP(); - if (ret != EXPECTED_CP) - { - Fail("ERROR: got incorrect result for current ANSI code page!\n" - "Expected %d, got %d\n", EXPECTED_CP, ret); - } - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/locale_info/GetACP/test1/testinfo.dat b/src/pal/tests/palsuite/locale_info/GetACP/test1/testinfo.dat deleted file mode 100644 index 63a58f681..000000000 --- a/src/pal/tests/palsuite/locale_info/GetACP/test1/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Locale Information -Function = GetACP -Name = Test #1 for GetACP -TYPE = DEFAULT -EXE1 = test1 -Description -=Tests that GetACP returns code-page 1252. diff --git a/src/pal/tests/palsuite/locale_info/GetCPInfo/CMakeLists.txt b/src/pal/tests/palsuite/locale_info/GetCPInfo/CMakeLists.txt deleted file mode 100644 index 1962ade35..000000000 --- a/src/pal/tests/palsuite/locale_info/GetCPInfo/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) -add_subdirectory(test3) - diff --git a/src/pal/tests/palsuite/locale_info/GetCPInfo/test1/CMakeLists.txt b/src/pal/tests/palsuite/locale_info/GetCPInfo/test1/CMakeLists.txt deleted file mode 100644 index e8c907759..000000000 --- a/src/pal/tests/palsuite/locale_info/GetCPInfo/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_getcpinfo_test1 - ${SOURCES} -) - -add_dependencies(paltest_getcpinfo_test1 coreclrpal) - -target_link_libraries(paltest_getcpinfo_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/locale_info/GetCPInfo/test1/test1.cpp b/src/pal/tests/palsuite/locale_info/GetCPInfo/test1/test1.cpp deleted file mode 100644 index ed9bbf93f..000000000 --- a/src/pal/tests/palsuite/locale_info/GetCPInfo/test1/test1.cpp +++ /dev/null @@ -1,54 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: Tests that GetCPInfo works for CP_ACP and 0x4E4 (default codepage) -** Also makes sure it correctly handles an invalid code page. -** -** -**==========================================================================*/ - - -#include - - -int __cdecl main(int argc, char *argv[]) -{ - CPINFO cpinfo; - - if (0 != PAL_Initialize(argc, argv)) - { - return FAIL; - } - - if (!GetCPInfo(CP_ACP, &cpinfo)) - { - Fail("GetCPInfo() unable to get info for CP_ACP\n"); - } - - if (!GetCPInfo(65001, &cpinfo)) - { - Fail("GetCPInfo() unable to get info for code page 65001 (utf8)\n"); - } - - if (GetCPInfo(-1, &cpinfo)) - { - Fail("GetCPInfo() did not error on invalid code page!\n"); - } - - if (GetLastError() != ERROR_INVALID_PARAMETER) - { - Fail("GetCPInfo() failed to set the last error to" - " ERROR_INVALID_PARAMETER!\n"); - } - - - PAL_Terminate(); - - return PASS; -} - diff --git a/src/pal/tests/palsuite/locale_info/GetCPInfo/test1/testinfo.dat b/src/pal/tests/palsuite/locale_info/GetCPInfo/test1/testinfo.dat deleted file mode 100644 index 31be1d553..000000000 --- a/src/pal/tests/palsuite/locale_info/GetCPInfo/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Locale Information -Function = GetCPInfo -Name = Test #1 for GetCPInfo -TYPE = DEFAULT -EXE1 = test1 -Description -=Tests that GetCPInfo works for CP_ACP and 0x4E4 (default codepage) -=Also makes sure it correctly handles an invalid code page. diff --git a/src/pal/tests/palsuite/locale_info/GetCPInfo/test2/CMakeLists.txt b/src/pal/tests/palsuite/locale_info/GetCPInfo/test2/CMakeLists.txt deleted file mode 100644 index 3ce744e94..000000000 --- a/src/pal/tests/palsuite/locale_info/GetCPInfo/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test2.cpp -) - -add_executable(paltest_getcpinfo_test2 - ${SOURCES} -) - -add_dependencies(paltest_getcpinfo_test2 coreclrpal) - -target_link_libraries(paltest_getcpinfo_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/locale_info/GetCPInfo/test2/test2.cpp b/src/pal/tests/palsuite/locale_info/GetCPInfo/test2/test2.cpp deleted file mode 100644 index f52320f16..000000000 --- a/src/pal/tests/palsuite/locale_info/GetCPInfo/test2/test2.cpp +++ /dev/null @@ -1,60 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test2.c -** -** Purpose: Tests that GetCPInfo gives the correct information for codepage 0x4E4 -** (the default). -** -** -**==========================================================================*/ - - -#include - - -int __cdecl main(int argc, char *argv[]) -{ - CPINFO cpinfo; - int codepage; - unsigned int i; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - /* - * codepage 1252 (0x4E4): Windows 3.1 Latin 1 (U.S., Western Europe) - */ - codepage = 1252; - - if (!GetCPInfo(codepage, &cpinfo)) - { - Fail("GetCPInfo() failed on default ansi code page!\n"); - } - if (cpinfo.MaxCharSize != 1) - { - Fail("GetCPInfo() returned incorrect MaxCharSize information!\n"); - } - if (cpinfo.DefaultChar[0] != '?' || cpinfo.DefaultChar[1] != 0) - { - Fail("GetCPInfo() returned incorrect DefaultChar information"); - } - - for (i = 0; i - -/* Currently only one CodePage "CP_ACP" is supported by the PAL */ - -int __cdecl main(int argc, char *argv[]) -{ - CPINFO cpinfo; - - /* Initialize the PAL. - */ - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - /* Test GetCPInfo with CP_ACP. - */ - if (!GetCPInfo(CP_ACP, &cpinfo)) - { - Fail("GetCPInfo() unable to get info for code page %d!\n", CP_ACP); - } - - /* Terminate the PAL. - */ - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/locale_info/GetCPInfo/test3/testinfo.dat b/src/pal/tests/palsuite/locale_info/GetCPInfo/test3/testinfo.dat deleted file mode 100644 index 13f7a2926..000000000 --- a/src/pal/tests/palsuite/locale_info/GetCPInfo/test3/testinfo.dat +++ /dev/null @@ -1,8 +0,0 @@ -Version = 1.0 -Section = Locale Information -Function = GetCPInfo -Name = Test #3 for GetCPInfo -TYPE = DEFAULT -EXE1 = test3 -Description -=Tests that GetCPInfo passes for all valid code pages diff --git a/src/pal/tests/palsuite/locale_info/GetLocaleInfoW/CMakeLists.txt b/src/pal/tests/palsuite/locale_info/GetLocaleInfoW/CMakeLists.txt deleted file mode 100644 index ef14ea535..000000000 --- a/src/pal/tests/palsuite/locale_info/GetLocaleInfoW/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) - diff --git a/src/pal/tests/palsuite/locale_info/GetLocaleInfoW/test1/CMakeLists.txt b/src/pal/tests/palsuite/locale_info/GetLocaleInfoW/test1/CMakeLists.txt deleted file mode 100644 index ea574a8bd..000000000 --- a/src/pal/tests/palsuite/locale_info/GetLocaleInfoW/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_getlocaleinfow_test1 - ${SOURCES} -) - -add_dependencies(paltest_getlocaleinfow_test1 coreclrpal) - -target_link_libraries(paltest_getlocaleinfow_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/locale_info/GetLocaleInfoW/test1/test1.cpp b/src/pal/tests/palsuite/locale_info/GetLocaleInfoW/test1/test1.cpp deleted file mode 100644 index 0994940a5..000000000 --- a/src/pal/tests/palsuite/locale_info/GetLocaleInfoW/test1/test1.cpp +++ /dev/null @@ -1,89 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: Tests that GetLocaleInfoW gives the correction information for -** LOCALE_NEUTRAL. -** -** -**==========================================================================*/ - -#include - - -int Types[] = { LOCALE_SDECIMAL, LOCALE_STHOUSAND, LOCALE_ILZERO, - LOCALE_SCURRENCY, LOCALE_SMONDECIMALSEP, LOCALE_SMONTHOUSANDSEP }; - -char *TypeStrings[] = { "LOCALE_SDECIMAL", "LOCALE_STHOUSAND", "LOCALE_ILZERO", - "LOCALE_SCURRENCY", "LOCALE_SMONDECIMALSEP", "LOCALE_SMONTHOUSANDSEP" }; - -#define NUM_TYPES (sizeof(Types) / sizeof(Types[0])) - -typedef WCHAR InfoStrings[NUM_TYPES][4]; - -typedef struct -{ - LCID lcid; - InfoStrings Strings; -} LocalInfoType; - -LocalInfoType Locales[] = -{ - {LOCALE_NEUTRAL, - {{'.',0}, {',',0}, {'1',0}, {'$',0}, {'.',0}, {',',0}}}, -}; - -int NumLocales = sizeof(Locales) / sizeof(Locales[0]); - - -int __cdecl main(int argc, char *argv[]) -{ - WCHAR buffer[256] = { 0 }; - int ret; - int i,j; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - for (i=0; i - -int __cdecl main(int argc, char *argv[]) -{ - WCHAR buffer[256] = { 0 }; - int ret; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - ret = GetLocaleInfoW(LOCALE_NEUTRAL, LOCALE_SDECIMAL, buffer, 0); - if (ret != 2) - { - Fail("GetLocaleInfoW gave incorrect desired length for buffer.\n" - "Expected 2, got %d.\n", ret); - } - - ret = GetLocaleInfoW(LOCALE_NEUTRAL, LOCALE_SDECIMAL, buffer, 1); - if (ret != 0) - { - Fail("GetLocaleInfoW expected to return 0, returned %d", ret); - } - - if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) - { - Fail("GetLocaleInfoW failed to set last error to " - "ERROR_INSUFFICIENT_BUFFER!\n"); - } - - PAL_Terminate(); - - return PASS; -} - diff --git a/src/pal/tests/palsuite/locale_info/GetLocaleInfoW/test2/testinfo.dat b/src/pal/tests/palsuite/locale_info/GetLocaleInfoW/test2/testinfo.dat deleted file mode 100644 index b9fc4886e..000000000 --- a/src/pal/tests/palsuite/locale_info/GetLocaleInfoW/test2/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Locale Information -Function = GetLocaleInfoW -Name = Test #2 for GetLocaleInfoW -TYPE = DEFAULT -EXE1 = test2 -Description -=Tests that GetLocaleInfoW will correctly return the amount of -=buffer space required. Also tests that it correctly handles a -=buffer of insufficient space. diff --git a/src/pal/tests/palsuite/locale_info/GetSystemDefaultLangID/CMakeLists.txt b/src/pal/tests/palsuite/locale_info/GetSystemDefaultLangID/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/locale_info/GetSystemDefaultLangID/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/locale_info/GetSystemDefaultLangID/test1/CMakeLists.txt b/src/pal/tests/palsuite/locale_info/GetSystemDefaultLangID/test1/CMakeLists.txt deleted file mode 100644 index acbe40d84..000000000 --- a/src/pal/tests/palsuite/locale_info/GetSystemDefaultLangID/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_getsystemdefaultlangid_test1 - ${SOURCES} -) - -add_dependencies(paltest_getsystemdefaultlangid_test1 coreclrpal) - -target_link_libraries(paltest_getsystemdefaultlangid_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/locale_info/GetSystemDefaultLangID/test1/test1.cpp b/src/pal/tests/palsuite/locale_info/GetSystemDefaultLangID/test1/test1.cpp deleted file mode 100644 index 1bc512081..000000000 --- a/src/pal/tests/palsuite/locale_info/GetSystemDefaultLangID/test1/test1.cpp +++ /dev/null @@ -1,59 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: Checks that GetSystemDefaultLangID can be used to make a valid -** locale, and that it is consistent with LOCALE_USER_DEFAULT. -** -** -**==========================================================================*/ - -#include - -int __cdecl main(int argc, char *argv[]) -{ - - LCID lcid; - LANGID LangID; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - LangID = GetSystemDefaultLangID(); - if (LangID == 0) - { - Fail("GetSystemDefaultLangID failed!\n"); - } - - /* Try using the langid (with default sort) as a locale */ - if (!SetThreadLocale(MAKELCID(LangID, SORT_DEFAULT))) - { - Fail("Unable to use GetSystemDefaultLangID as a locale!\n"); - } - lcid = GetThreadLocale(); - if (!IsValidLocale(lcid, LCID_INSTALLED)) - { - Fail("Unable to use GetSystemDefaultLangID as a locale!\n"); - } - - /* Make sure results consistent with using LOCALE_USER_DEFAULT */ - if (!SetThreadLocale(LOCALE_USER_DEFAULT)) - { - Fail("Unexpected error testing GetSystemDefaultLangID!\n"); - } - if (GetThreadLocale() != lcid) - { - Fail("Results from GetSystemDefaultLangID inconsistent with " - "LOCALE_USER_DEFAULT!\n"); - } - - PAL_Terminate(); - - return PASS; -} diff --git a/src/pal/tests/palsuite/locale_info/GetSystemDefaultLangID/test1/testinfo.dat b/src/pal/tests/palsuite/locale_info/GetSystemDefaultLangID/test1/testinfo.dat deleted file mode 100644 index e37ce45a4..000000000 --- a/src/pal/tests/palsuite/locale_info/GetSystemDefaultLangID/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Locale Information -Function = GetSystemDefaultLangID -Name = Test #1 for GetSystemDefaultLangID -TYPE = DEFAULT -EXE1 = test1 -Description -=Checks that GetSystemDefaultLangID can be used to make a valid -=locale, and that it is consistent with LOCALE_USER_DEFAULT. diff --git a/src/pal/tests/palsuite/locale_info/GetThreadLocale/CMakeLists.txt b/src/pal/tests/palsuite/locale_info/GetThreadLocale/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/locale_info/GetThreadLocale/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/locale_info/GetThreadLocale/test1/CMakeLists.txt b/src/pal/tests/palsuite/locale_info/GetThreadLocale/test1/CMakeLists.txt deleted file mode 100644 index b6d0f270d..000000000 --- a/src/pal/tests/palsuite/locale_info/GetThreadLocale/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_getthreadlocale_test1 - ${SOURCES} -) - -add_dependencies(paltest_getthreadlocale_test1 coreclrpal) - -target_link_libraries(paltest_getthreadlocale_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/locale_info/GetThreadLocale/test1/test1.cpp b/src/pal/tests/palsuite/locale_info/GetThreadLocale/test1/test1.cpp deleted file mode 100644 index 8eb7252e3..000000000 --- a/src/pal/tests/palsuite/locale_info/GetThreadLocale/test1/test1.cpp +++ /dev/null @@ -1,36 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: Tests that GetThreadLocale returns a valid locale. -** -** -**==========================================================================*/ - -#include - -int __cdecl main(int argc, char *argv[]) -{ - LCID lcid; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - lcid = GetThreadLocale(); - - if (!IsValidLocale(lcid, LCID_INSTALLED)) - { - Fail("GetThreadLocale returned a locale that is not installed!\n"); - } - - PAL_Terminate(); - - return PASS; -} - diff --git a/src/pal/tests/palsuite/locale_info/GetThreadLocale/test1/testinfo.dat b/src/pal/tests/palsuite/locale_info/GetThreadLocale/test1/testinfo.dat deleted file mode 100644 index a58782a38..000000000 --- a/src/pal/tests/palsuite/locale_info/GetThreadLocale/test1/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Locale Information -Function = GetThreadLocale -Name = Test #1 for GetThreadLocale -TYPE = DEFAULT -EXE1 = test1 -Description -=Tests that GetThreadLocale returns a valid locale diff --git a/src/pal/tests/palsuite/locale_info/GetTimeZoneInformation/CMakeLists.txt b/src/pal/tests/palsuite/locale_info/GetTimeZoneInformation/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/locale_info/GetTimeZoneInformation/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/locale_info/GetTimeZoneInformation/test1/CMakeLists.txt b/src/pal/tests/palsuite/locale_info/GetTimeZoneInformation/test1/CMakeLists.txt deleted file mode 100644 index d62a4c22a..000000000 --- a/src/pal/tests/palsuite/locale_info/GetTimeZoneInformation/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_gettimezoneinformation_test1 - ${SOURCES} -) - -add_dependencies(paltest_gettimezoneinformation_test1 coreclrpal) - -target_link_libraries(paltest_gettimezoneinformation_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/locale_info/GetTimeZoneInformation/test1/test1.cpp b/src/pal/tests/palsuite/locale_info/GetTimeZoneInformation/test1/test1.cpp deleted file mode 100644 index bb83ade23..000000000 --- a/src/pal/tests/palsuite/locale_info/GetTimeZoneInformation/test1/test1.cpp +++ /dev/null @@ -1,73 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: Tests that GetTimeZoneInformation gives reasonable values. -** -** -**==========================================================================*/ - - -#include - -int __cdecl main(int argc, char *argv[]) -{ - TIME_ZONE_INFORMATION tzi; - DWORD ret; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - ret = GetTimeZoneInformation(&tzi); - if (ret == TIME_ZONE_ID_UNKNOWN) - { - /* Occurs in time zones that do not use daylight savings time. */ - if (tzi.StandardBias != 0) - { - Fail("GetTimeZoneInformation() gave invalid data!\n" - "Returned TIME_ZONE_ID_UNKNOWN but StandardBias != 0!\n"); - } - if (tzi.DaylightBias != 0) - { - Fail("GetTimeZoneInformation() gave invalid data!\n" - "Returned TIME_ZONE_ID_UNKNOWN but DaylightBias != 0!\n"); - } - } - else if (ret == TIME_ZONE_ID_STANDARD) - { - if (tzi.StandardBias != 0) - { - Fail("GetTimeZoneInformation() gave invalid data!\n" - "StandardBias is %d, should be 0!\n", tzi.StandardBias); - } - } - else if (ret == TIME_ZONE_ID_DAYLIGHT) - { - if (tzi.DaylightBias != -60 && tzi.DaylightBias != 0) - { - Fail("GetTimeZoneInformation() gave invalid data!\n" - "DaylightBias is %d, should be 0 or -60!\n", tzi.DaylightBias); - } - } - else - { - Fail("GetTimeZoneInformation() returned an invalid value!\n"); - } - - if (tzi.Bias % 30 != 0) - { - Fail("GetTimeZoneInformation() gave an invalid bias of %d!\n", - tzi.Bias); - } - - PAL_Terminate(); - - return PASS; -} - diff --git a/src/pal/tests/palsuite/locale_info/GetTimeZoneInformation/test1/testinfo.dat b/src/pal/tests/palsuite/locale_info/GetTimeZoneInformation/test1/testinfo.dat deleted file mode 100644 index 382b8d535..000000000 --- a/src/pal/tests/palsuite/locale_info/GetTimeZoneInformation/test1/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Locale Information -Function = GetTimeZoneInformation -Name = Test #1 for GetTimeZoneInformation -TYPE = DEFAULT -EXE1 = test1 -Description -=Tests that GetTimeZoneInformation gives reasonable values. diff --git a/src/pal/tests/palsuite/locale_info/GetUserDefaultLCID/CMakeLists.txt b/src/pal/tests/palsuite/locale_info/GetUserDefaultLCID/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/locale_info/GetUserDefaultLCID/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/locale_info/GetUserDefaultLCID/test1/CMakeLists.txt b/src/pal/tests/palsuite/locale_info/GetUserDefaultLCID/test1/CMakeLists.txt deleted file mode 100644 index 256d81877..000000000 --- a/src/pal/tests/palsuite/locale_info/GetUserDefaultLCID/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_getuserdefaultlcid_test1 - ${SOURCES} -) - -add_dependencies(paltest_getuserdefaultlcid_test1 coreclrpal) - -target_link_libraries(paltest_getuserdefaultlcid_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/locale_info/GetUserDefaultLCID/test1/test1.cpp b/src/pal/tests/palsuite/locale_info/GetUserDefaultLCID/test1/test1.cpp deleted file mode 100644 index 4a336f9bb..000000000 --- a/src/pal/tests/palsuite/locale_info/GetUserDefaultLCID/test1/test1.cpp +++ /dev/null @@ -1,52 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: Tests that GetUserDefaultLCID returns a valid locale that is -** consistent with LOCALE_USER_DEFAULT. -** -** -**==========================================================================*/ - -#include - -int __cdecl main(int argc, char *argv[]) -{ - LCID lcid; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - lcid = GetUserDefaultLCID(); - if (lcid == 0) - { - Fail("GetUserDefaultLCID failed!\n"); - } - - if (!IsValidLocale(lcid, LCID_INSTALLED)) - { - Fail("GetUserDefaultLCID gave an invalid locale!\n"); - } - - /* Make sure results consistent with using LOCALE_USER_DEFAULT */ - if (!SetThreadLocale(LOCALE_USER_DEFAULT)) - { - Fail("Unexpected error testing GetUserDefaultLCID!\n"); - } - if (GetThreadLocale() != lcid) - { - Fail("Results from GetUserDefaultLCID inconsistent with " - "LOCALE_USER_DEFAULT!\n"); - } - - PAL_Terminate(); - - return PASS; -} - diff --git a/src/pal/tests/palsuite/locale_info/GetUserDefaultLCID/test1/testinfo.dat b/src/pal/tests/palsuite/locale_info/GetUserDefaultLCID/test1/testinfo.dat deleted file mode 100644 index 73565b03c..000000000 --- a/src/pal/tests/palsuite/locale_info/GetUserDefaultLCID/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Locale Information -Function = GetUserDefaultLCID -Name = Test #1 for GetUserDefaultLCID -TYPE = DEFAULT -EXE1 = test1 -Description -=Tests that GetUserDefaultLCID returns a valid locale that is -=consistent with LOCALE_USER_DEFAULT. diff --git a/src/pal/tests/palsuite/locale_info/GetUserDefaultLangID/CMakeLists.txt b/src/pal/tests/palsuite/locale_info/GetUserDefaultLangID/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/locale_info/GetUserDefaultLangID/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/locale_info/GetUserDefaultLangID/test1/CMakeLists.txt b/src/pal/tests/palsuite/locale_info/GetUserDefaultLangID/test1/CMakeLists.txt deleted file mode 100644 index ac3c78a2b..000000000 --- a/src/pal/tests/palsuite/locale_info/GetUserDefaultLangID/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_getuserdefaultlangid_test1 - ${SOURCES} -) - -add_dependencies(paltest_getuserdefaultlangid_test1 coreclrpal) - -target_link_libraries(paltest_getuserdefaultlangid_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/locale_info/GetUserDefaultLangID/test1/test1.cpp b/src/pal/tests/palsuite/locale_info/GetUserDefaultLangID/test1/test1.cpp deleted file mode 100644 index 51c567808..000000000 --- a/src/pal/tests/palsuite/locale_info/GetUserDefaultLangID/test1/test1.cpp +++ /dev/null @@ -1,60 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: Checks that GetUserDefaultLangID can be used to make a valid -** locale, and that it is consistent with LOCALE_USER_DEFAULT. -** -** -**==========================================================================*/ - -#include - -int __cdecl main(int argc, char *argv[]) -{ - - LCID lcid; - LANGID LangID; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - LangID = GetUserDefaultLangID(); - if (LangID == 0) - { - Fail("GetUserDefaultLangID failed!\n"); - } - - /* Try using the langid (with default sort) as a locale */ - if (!SetThreadLocale(MAKELCID(LangID, SORT_DEFAULT))) - { - Fail("Unable to use GetUserDefaultLangID as a locale!\n"); - } - lcid = GetThreadLocale(); - if (!IsValidLocale(lcid, LCID_INSTALLED)) - { - Fail("Unable to use GetUserDefaultLangID as a locale!\n"); - } - - /* Make sure results consistent with using LOCALE_USER_DEFAULT */ - if (!SetThreadLocale(LOCALE_USER_DEFAULT)) - { - Fail("Unexpected error testing GetUserDefaultLangID!\n"); - } - if (GetThreadLocale() != lcid) - { - Fail("Results from GetUserDefaultLangID inconsistent with " - "LOCALE_USER_DEFAULT!\n"); - } - - PAL_Terminate(); - - return PASS; -} - diff --git a/src/pal/tests/palsuite/locale_info/GetUserDefaultLangID/test1/testinfo.dat b/src/pal/tests/palsuite/locale_info/GetUserDefaultLangID/test1/testinfo.dat deleted file mode 100644 index a46125757..000000000 --- a/src/pal/tests/palsuite/locale_info/GetUserDefaultLangID/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Locale Information -Function = GetUserDefaultLangID -Name = Test #1 for GetUserDefaultLangID -TYPE = DEFAULT -EXE1 = test1 -Description -=Checks that GetUserDefaultLangID can be used to make a valid -=locale, and that it is consistent with LOCALE_USER_DEFAULT. diff --git a/src/pal/tests/palsuite/locale_info/IsDBCSLeadByte/CMakeLists.txt b/src/pal/tests/palsuite/locale_info/IsDBCSLeadByte/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/locale_info/IsDBCSLeadByte/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/locale_info/IsDBCSLeadByte/test1/CMakeLists.txt b/src/pal/tests/palsuite/locale_info/IsDBCSLeadByte/test1/CMakeLists.txt deleted file mode 100644 index 2264d3e8f..000000000 --- a/src/pal/tests/palsuite/locale_info/IsDBCSLeadByte/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_isdbcsleadbyte_test1 - ${SOURCES} -) - -add_dependencies(paltest_isdbcsleadbyte_test1 coreclrpal) - -target_link_libraries(paltest_isdbcsleadbyte_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/locale_info/IsDBCSLeadByte/test1/test1.cpp b/src/pal/tests/palsuite/locale_info/IsDBCSLeadByte/test1/test1.cpp deleted file mode 100644 index ad326be08..000000000 --- a/src/pal/tests/palsuite/locale_info/IsDBCSLeadByte/test1/test1.cpp +++ /dev/null @@ -1,64 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: Tests that IsDBCSLeadByte does not find any lead-bytes in the -** current ansi code page -** -** -** TODO: Test for positive, i.e., if it is potentially isdbcsleadbyte -**==========================================================================*/ - - -#include - -void DoTest() -{ - int value; - int ret; - int i; - - - for (i=0; i<256; i++) - { - value = IsDBCSLeadByte(i); - - ret = GetLastError(); - if (ret == ERROR_INVALID_PARAMETER) - { - Fail("IsDBCSLeadByte unexpectedly errored with ERROR_INVALID_PARAMETER for %d!\n", i); - } - else if (ret != 0) - { - Fail("IsDBCSLeadByte had an unexpected error [%d] for %d!\n", ret, i); - } - else if (value) - { - Fail("IsDBCSLeadByte incorrectly found a lead byte in value [%d] for" - " %d\n", value, i); - } - - } -} - -int __cdecl main(int argc, char *argv[]) -{ - - if (0 != PAL_Initialize(argc, argv)) - { - return FAIL; - } - - DoTest(); - - PAL_Terminate(); - -// setlocale( "japan", ); - - return PASS; -} - diff --git a/src/pal/tests/palsuite/locale_info/IsDBCSLeadByte/test1/testinfo.dat b/src/pal/tests/palsuite/locale_info/IsDBCSLeadByte/test1/testinfo.dat deleted file mode 100644 index 43cd2aebb..000000000 --- a/src/pal/tests/palsuite/locale_info/IsDBCSLeadByte/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Locale Information -Function = IsDBCSLeadByte -Name = Test #1 for IsDBCSLeadByte -TYPE = DEFAULT -EXE1 = test1 -Description -=Tests that IsDBCSLeadByte does not find any lead-bytes in the -=current ansi code page diff --git a/src/pal/tests/palsuite/locale_info/IsDBCSLeadByteEx/CMakeLists.txt b/src/pal/tests/palsuite/locale_info/IsDBCSLeadByteEx/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/locale_info/IsDBCSLeadByteEx/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/locale_info/IsDBCSLeadByteEx/test1/CMakeLists.txt b/src/pal/tests/palsuite/locale_info/IsDBCSLeadByteEx/test1/CMakeLists.txt deleted file mode 100644 index 3109b7173..000000000 --- a/src/pal/tests/palsuite/locale_info/IsDBCSLeadByteEx/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_isdbcsleadbyteex_test1 - ${SOURCES} -) - -add_dependencies(paltest_isdbcsleadbyteex_test1 coreclrpal) - -target_link_libraries(paltest_isdbcsleadbyteex_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/locale_info/IsDBCSLeadByteEx/test1/test1.cpp b/src/pal/tests/palsuite/locale_info/IsDBCSLeadByteEx/test1/test1.cpp deleted file mode 100644 index 9466f4817..000000000 --- a/src/pal/tests/palsuite/locale_info/IsDBCSLeadByteEx/test1/test1.cpp +++ /dev/null @@ -1,72 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: Tests that IsDBCSLeadByteEx does not find any lead-bytes in the -** current ansi code page or the default code page. Also tests that -** it correctly handles an invalid codepage. -** -** -**==========================================================================*/ - - -#include - -void DoTest(int codepage) -{ - int value; - int ret; - int i; - - - for (i=0; i<256; i++) - { - value = IsDBCSLeadByteEx(codepage, i); - - ret = GetLastError(); - if (ret == ERROR_INVALID_PARAMETER) - { - Fail("IsDBCSLeadByteEx unexpectedly errored with ERROR_INVALID_PARAMETER!\n"); - } - else if (ret != 0) - { - Fail("IsDBCSLeadByteEx had an unexpected error!\n"); - } - else if (value) - { - Fail("IsDBCSLeadByteEx incorrectly found a lead byte in code " - "page %d\n", codepage); - } - - } -} - -int __cdecl main(int argc, char *argv[]) -{ - - if (0 != PAL_Initialize(argc, argv)) - { - return FAIL; - } - - if (IsDBCSLeadByteEx(-1, 0)) - { - Fail("IsDBCSLeadByteEx did not error on an invalid code page!\n"); - } - - /* Clear the last error. */ - SetLastError(0); - - - DoTest(0); - DoTest(CP_ACP); - - PAL_Terminate(); - - return PASS; -} - diff --git a/src/pal/tests/palsuite/locale_info/IsDBCSLeadByteEx/test1/testinfo.dat b/src/pal/tests/palsuite/locale_info/IsDBCSLeadByteEx/test1/testinfo.dat deleted file mode 100644 index b85e38727..000000000 --- a/src/pal/tests/palsuite/locale_info/IsDBCSLeadByteEx/test1/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Locale Information -Function = IsDBCSLeadByteEx -Name = Test #1 for IsDBCSLeadByteEx -TYPE = DEFAULT -EXE1 = test1 -Description -=Tests that IsDBCSLeadByteEx does not find any lead-bytes in the -=current ansi code page or the default code page. Also tests that -=it correctly handles an invalid codepage. diff --git a/src/pal/tests/palsuite/locale_info/IsValidCodePage/CMakeLists.txt b/src/pal/tests/palsuite/locale_info/IsValidCodePage/CMakeLists.txt deleted file mode 100644 index ef14ea535..000000000 --- a/src/pal/tests/palsuite/locale_info/IsValidCodePage/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) - diff --git a/src/pal/tests/palsuite/locale_info/IsValidCodePage/test1/CMakeLists.txt b/src/pal/tests/palsuite/locale_info/IsValidCodePage/test1/CMakeLists.txt deleted file mode 100644 index a90784818..000000000 --- a/src/pal/tests/palsuite/locale_info/IsValidCodePage/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_isvalidcodepage_test1 - ${SOURCES} -) - -add_dependencies(paltest_isvalidcodepage_test1 coreclrpal) - -target_link_libraries(paltest_isvalidcodepage_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/locale_info/IsValidCodePage/test1/test1.cpp b/src/pal/tests/palsuite/locale_info/IsValidCodePage/test1/test1.cpp deleted file mode 100644 index deb6a7ae7..000000000 --- a/src/pal/tests/palsuite/locale_info/IsValidCodePage/test1/test1.cpp +++ /dev/null @@ -1,50 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: Tests IsValidCodePage with a collection of valid and invalid -** code pages. -** -** -**==========================================================================*/ - - -#include - - -UINT InvalidCodePages[] = -{ - 0, 0x1, 0x2, 0x3, 0xfff -}; - -int NumInvalidPages = sizeof(InvalidCodePages) / sizeof(InvalidCodePages[0]); - -int __cdecl main(int argc, char *argv[]) -{ - int i; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - - for (i=0; i - -UINT ValidCodePages[] = -{ - 0x25, 0x1b5, 0x1f4, 0x352, 0x35c, 0x35d, 0x35f, 0x361, - 0x36a, 0x3a4, 0x3a8, 0x3b5, 0x3b6, 0x4e2, 0x4e3, 0x4e4, 0x4e5, 0x4e6, - 0x4e7, 0x4e8, 0x4e9, 0x4ea, 0x2710, 0x275f, 0x4e9f, 0x4f25, 0x5182, 0x6faf, - 0x6fb0, 0x6fbd, 0xfde8, 0xfde9 -}; - - -int NumValidPages = sizeof(ValidCodePages) / sizeof(ValidCodePages[0]); -int __cdecl main(int argc, char *argv[]) -{ - int i; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - for (i=0; i - - -int __cdecl main(int argc, char *argv[]) -{ - - LCID lcid; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - /* - * Passing LOCALE_USER_DEFAULT to IsValidLocale will fail, so instead - * the current thread localed is changed to it, and that lcid is passed - * to IsValidLocale (which should always pass) - */ - if (!SetThreadLocale(LOCALE_USER_DEFAULT)) - { - Fail("Unable to set locale to LOCALE_USER_DEFAULT!\n"); - } - - lcid = GetThreadLocale(); - - if (!IsValidLocale(lcid, LCID_SUPPORTED)) - { - Fail("IsValidLocale found the default user locale unsupported!\n"); - } - if (!IsValidLocale(lcid, LCID_INSTALLED)) - { - Fail("IsValidLocale found the default user locale uninstalled!\n"); - } - - /* - * Test out bad parameters - */ - if (IsValidLocale(-1, LCID_SUPPORTED)) - { - Fail("IsValideLocale passed with an invalid LCID!\n"); - } - if (IsValidLocale(-1, LCID_INSTALLED)) - { - Fail("IsValideLocale passed with an invalid LCID!\n"); - } - - if (IsValidLocale(LOCALE_USER_DEFAULT, LCID_SUPPORTED)) - { - Fail("IsValidLocale passed with LOCALE_USER_DEFAULT!\n"); - } - if (IsValidLocale(LOCALE_USER_DEFAULT, LCID_INSTALLED)) - { - Fail("IsValidLocale passed with LOCALE_USER_DEFAULT!\n"); - } - - PAL_Terminate(); - - return PASS; -} - diff --git a/src/pal/tests/palsuite/locale_info/IsValidLocale/test1/testinfo.dat b/src/pal/tests/palsuite/locale_info/IsValidLocale/test1/testinfo.dat deleted file mode 100644 index e9fcc18cf..000000000 --- a/src/pal/tests/palsuite/locale_info/IsValidLocale/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Locale Information -Function = IsValidLocale -Name = Test #1 for IsValidLocale -TYPE = DEFAULT -EXE1 = test1 -Description -=Tests IsValidLocale with the current locale, -1, and LOCALE_USER_DEFAULT -=(which actually isn't valid). diff --git a/src/pal/tests/palsuite/locale_info/MultiByteToWideChar/CMakeLists.txt b/src/pal/tests/palsuite/locale_info/MultiByteToWideChar/CMakeLists.txt deleted file mode 100644 index 0b8ae6062..000000000 --- a/src/pal/tests/palsuite/locale_info/MultiByteToWideChar/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) -add_subdirectory(test3) -add_subdirectory(test4) diff --git a/src/pal/tests/palsuite/locale_info/MultiByteToWideChar/test1/CMakeLists.txt b/src/pal/tests/palsuite/locale_info/MultiByteToWideChar/test1/CMakeLists.txt deleted file mode 100644 index f400843bd..000000000 --- a/src/pal/tests/palsuite/locale_info/MultiByteToWideChar/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_multibytetowidechar_test1 - ${SOURCES} -) - -add_dependencies(paltest_multibytetowidechar_test1 coreclrpal) - -target_link_libraries(paltest_multibytetowidechar_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/locale_info/MultiByteToWideChar/test1/test1.cpp b/src/pal/tests/palsuite/locale_info/MultiByteToWideChar/test1/test1.cpp deleted file mode 100644 index 81f58a532..000000000 --- a/src/pal/tests/palsuite/locale_info/MultiByteToWideChar/test1/test1.cpp +++ /dev/null @@ -1,81 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: Tests MultiByteToWideChar with all the ASCII characters (0-127). -** Also tests that WideCharToMultiByte handles different buffer -** lengths correctly (0, -1, and a valid length) -** -** -**==========================================================================*/ - -#include - -/* - * For now, it is assumed that MultiByteToWideChar will only be used in the PAL - * with CP_ACP, and that dwFlags will be 0. - */ - -int __cdecl main(int argc, char *argv[]) -{ - char mbStr[128]; - WCHAR wideStr[128]; - int ret; - int i; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - for (i=0; i<128; i++) - { - mbStr[i] = 127 - i; - wideStr[i] = 0; - } - - - ret = MultiByteToWideChar(CP_ACP, 0, mbStr, -1, wideStr, 0); - if (ret != 128) - { - Fail("MultiByteToWideChar did not return correct string length!\n" - "Got %d, expected %d\n", ret, 128); - } - - /* Make sure the ASCII set (0-127) gets translated correctly */ - ret = MultiByteToWideChar(CP_ACP, 0, mbStr, -1, wideStr, 128); - if (ret != 128) - { - Fail("MultiByteToWideChar did not return correct string length!\n" - "Got %d, expected %d\n", ret, 128); - } - - for (i=0; i<128; i++) - { - if (wideStr[i] != (WCHAR)(127 - i)) - { - Fail("MultiByteToWideChar failed to translate correctly!\n" - "Expected character %d to be %c (%x), got %c (%x)\n", - i, 127 - i, 127 - i,wideStr[i], wideStr[i]); - } - } - - - /* try a 0 length string */ - mbStr[0] = 0; - ret = MultiByteToWideChar(CP_ACP, 0, mbStr, -1, wideStr, 0); - if (ret != 1) - { - Fail("MultiByteToWideChar did not return correct string length!\n" - "Got %d, expected %d\n", ret, 1); - } - - PAL_Terminate(); - - return PASS; -} - diff --git a/src/pal/tests/palsuite/locale_info/MultiByteToWideChar/test1/testinfo.dat b/src/pal/tests/palsuite/locale_info/MultiByteToWideChar/test1/testinfo.dat deleted file mode 100644 index 0e4591d24..000000000 --- a/src/pal/tests/palsuite/locale_info/MultiByteToWideChar/test1/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Locale Information -Function = MultiByteToWideChar -Name = Test #1 for MultiByteToWideChar -TYPE = DEFAULT -EXE1 = test1 -Description -=Tests MultiByteToWideChar with all the ASCII characters (0-127). -=Also tests that WideCharToMultiByte handles different buffer -=lengths correctly (0, -1, and a valid length) diff --git a/src/pal/tests/palsuite/locale_info/MultiByteToWideChar/test2/CMakeLists.txt b/src/pal/tests/palsuite/locale_info/MultiByteToWideChar/test2/CMakeLists.txt deleted file mode 100644 index c51cfd646..000000000 --- a/src/pal/tests/palsuite/locale_info/MultiByteToWideChar/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test2.cpp -) - -add_executable(paltest_multibytetowidechar_test2 - ${SOURCES} -) - -add_dependencies(paltest_multibytetowidechar_test2 coreclrpal) - -target_link_libraries(paltest_multibytetowidechar_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/locale_info/MultiByteToWideChar/test2/test2.cpp b/src/pal/tests/palsuite/locale_info/MultiByteToWideChar/test2/test2.cpp deleted file mode 100644 index 1370dba89..000000000 --- a/src/pal/tests/palsuite/locale_info/MultiByteToWideChar/test2/test2.cpp +++ /dev/null @@ -1,68 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test2.c -** -** Purpose: Tests that MultiByteToWideChar respects the length of the wide -** character string. - -** -**==========================================================================*/ - -#include - -/* - * For now, it is assumed that MultiByteToWideChar will only be used in the PAL - * with CP_ACP, and that dwFlags will be 0. - */ - -int __cdecl main(int argc, char *argv[]) -{ - char mbStr[128]; - WCHAR wideStr[128]; - int ret; - int i; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - for (i=0; i<128; i++) - { - mbStr[i] = 'a'; - wideStr[i] = 0; - } - - mbStr[127] = 0; - - - ret = MultiByteToWideChar(CP_ACP, 0, mbStr, 10, wideStr, 0); - if (ret != 10) - { - Fail("MultiByteToWideChar did not return correct string length!\n" - "Got %d, expected %d\n", ret, 10); - } - - wideStr[10] = (WCHAR) 'b'; - - ret = MultiByteToWideChar(CP_ACP, 0, mbStr, 10, wideStr, 128); - if (ret != 10) - { - Fail("MultiByteToWideChar did not return correct string length!\n" - "Got %d, expected %d\n", ret, 10); - } - - if (wideStr[10] != 'b') - { - Fail("WideCharToMultiByte overflowed the destination buffer!\n"); - } - - PAL_Terminate(); - - return PASS; -} - diff --git a/src/pal/tests/palsuite/locale_info/MultiByteToWideChar/test2/testinfo.dat b/src/pal/tests/palsuite/locale_info/MultiByteToWideChar/test2/testinfo.dat deleted file mode 100644 index 5211db125..000000000 --- a/src/pal/tests/palsuite/locale_info/MultiByteToWideChar/test2/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Locale Information -Function = MultiByteToWideChar -Name = Test #2 for MultiByteToWideChar -TYPE = DEFAULT -EXE1 = test2 -Description -=Tests that MultiByteToWideChar respects the length of the wide -=character string. diff --git a/src/pal/tests/palsuite/locale_info/MultiByteToWideChar/test3/CMakeLists.txt b/src/pal/tests/palsuite/locale_info/MultiByteToWideChar/test3/CMakeLists.txt deleted file mode 100644 index 386425f90..000000000 --- a/src/pal/tests/palsuite/locale_info/MultiByteToWideChar/test3/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test3.cpp -) - -add_executable(paltest_multibytetowidechar_test3 - ${SOURCES} -) - -add_dependencies(paltest_multibytetowidechar_test3 coreclrpal) - -target_link_libraries(paltest_multibytetowidechar_test3 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/locale_info/MultiByteToWideChar/test3/test3.cpp b/src/pal/tests/palsuite/locale_info/MultiByteToWideChar/test3/test3.cpp deleted file mode 100644 index 1b3a4bd4f..000000000 --- a/src/pal/tests/palsuite/locale_info/MultiByteToWideChar/test3/test3.cpp +++ /dev/null @@ -1,73 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test3.c -** -** Purpose: Tests that MultiByteToWideChar correctly handles the following -** error conditions: insufficient buffer space, invalid code pages, -** and invalid flags. -** -** -**==========================================================================*/ - -#include - - -int __cdecl main(int argc, char *argv[]) -{ - char mbStr[128]; - WCHAR wideStr[128]; - int ret; - int i; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - for (i=0; i<128; i++) - { - mbStr[i] = 'a'; - wideStr[i] = 0; - } - - mbStr[127] = 0; - - /* try with insufficient buffer space */ - ret = MultiByteToWideChar(CP_ACP, 0, mbStr, -1, wideStr, 10); - if (ret != 0) - { - Fail("MultiByteToWideChar did not return an error!\n" - "Expected return of 0, got %d", ret); - } - - ret = GetLastError(); - if (ret != ERROR_INSUFFICIENT_BUFFER) - { - Fail("MultiByteToWideChar did not set the last error to " - "ERROR_INSUFFICIENT_BUFFER!\n"); - } - - /* try with a wacky code page */ - ret = MultiByteToWideChar(-1, 0, mbStr, -1, wideStr, 128); - if (ret != 0) - { - Fail("MultiByteToWideChar did not return an error!\n" - "Expected return of 0, got %d", ret); - } - - ret = GetLastError(); - if (ret != ERROR_INVALID_PARAMETER) - { - Fail("MultiByteToWideChar did not set the last error to " - "ERROR_INVALID_PARAMETER!\n"); - } - - PAL_Terminate(); - - return PASS; -} - diff --git a/src/pal/tests/palsuite/locale_info/MultiByteToWideChar/test3/testinfo.dat b/src/pal/tests/palsuite/locale_info/MultiByteToWideChar/test3/testinfo.dat deleted file mode 100644 index c59f285dc..000000000 --- a/src/pal/tests/palsuite/locale_info/MultiByteToWideChar/test3/testinfo.dat +++ /dev/null @@ -1,15 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Locale Information -Function = MultiByteToWideChar -Name = Test #3 for MultiByteToWideChar -TYPE = DEFAULT -EXE1 = test3 -Description -=Tests that MultiByteToWideChar correctly handles the following -=error conditions: insufficient buffer space, invalid code pages, -=and invalid flags. - diff --git a/src/pal/tests/palsuite/locale_info/MultiByteToWideChar/test4/CMakeLists.txt b/src/pal/tests/palsuite/locale_info/MultiByteToWideChar/test4/CMakeLists.txt deleted file mode 100644 index dc119abd0..000000000 --- a/src/pal/tests/palsuite/locale_info/MultiByteToWideChar/test4/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test4.cpp -) - -add_executable(paltest_multibytetowidechar_test4 - ${SOURCES} -) - -add_dependencies(paltest_multibytetowidechar_test4 coreclrpal) - -target_link_libraries(paltest_multibytetowidechar_test4 - ${COMMON_TEST_LIBRARIES} -) \ No newline at end of file diff --git a/src/pal/tests/palsuite/locale_info/MultiByteToWideChar/test4/test4.cpp b/src/pal/tests/palsuite/locale_info/MultiByteToWideChar/test4/test4.cpp deleted file mode 100644 index 7d382de29..000000000 --- a/src/pal/tests/palsuite/locale_info/MultiByteToWideChar/test4/test4.cpp +++ /dev/null @@ -1,230 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test4.c -** -** Purpose: Tests MultiByteToWideChar with a UTF-8 encoding -** -** -**==========================================================================*/ - -#include - -int __cdecl main(int argc, char *argv[]) -{ - int ret; - int ret2; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - const char * const utf8Strings[] = - { - // Correct strings - - // Empty string - "", - // 1 byte encoded 1 character long string - "A", - // 2 byte encoded 1 character long string - "\xC2\x80", - // 3 byte encoded 1 character long string - "\xE0\xA0\x80", - // 1 byte encoded characters only - "ABCDEFGHIJKLMNOPQRSTUVWXYZ", - // valid 2 byte encoded characters only - "\xC2\x80\xC3\xBF\xC7\x81\xDF\xBF", - // valid 3 byte encoded characters only - "\xE0\xA0\x80\xE1\xB6\x88\xE1\x80\x80\xEF\xBF\xBF", - // 1 byte and 2 byte encoded characters interleaved 1:1 starting and ending with 1 byte char - "\x41\xC2\x80\x42\xC3\xBF\x43\xC7\x81\x44\xDF\xBF\x45", - // 1 byte and 2 byte encoded characters interleaved 1:1 starting with 1 byte char, ending with 2 byte one - "\x41\xC2\x80\x42\xC3\xBF\x43\xC7\x81\x44\xDF\xBF", - // 1 byte and 2 byte encoded characters interleaved 1:1 starting with 2 byte char, ending with 1 byte one - "\xC2\x80\x42\xC3\xBF\x43\xC7\x81\x44\xDF\xBF\x45", - // 1 byte and 2 byte encoded characters interleaved 1:1 starting and ending with 2 byte char - "\xC2\x80\x42\xC3\xBF\x43\xC7\x81\x44\xDF\xBF", - // 1 byte and 2 byte encoded characters interleaved 2:2 starting and ending with 1 byte char - "\x41\x42\xC2\x80\xC3\xBF\x43\x44\xC7\x81\xDF\xBF\x45\x46", - // 1 byte and 2 byte encoded characters interleaved 2:2 starting with 1 byte char, ending with 2 byte one - "\x41\x42\xC2\x80\xC3\xBF\x43\x44\xC7\x81\xDF\xBF", - // 1 byte and 2 byte encoded characters interleaved 2:2 starting with 2 byte char, ending with 1 byte one - "\xC2\x80\xC3\xBF\x43\x44\xC7\x81\xDF\xBF\x45\x46", - // 1 byte and 2 byte encoded characters interleaved 2:2 starting and ending with 2 byte char - "\xC2\x80\xC3\xBF\x43\x44\xC7\x81\xDF\xBF", - // surrogates - "\xF0\x90\x80\x80\xF0\x90\x89\x80\xF3\x80\x8E\xB0\xF4\x8F\xBF\xBF", - - // Strings with errors - // Incomplete 2 byte encoded character 1 byte missing standalone - "\xC2", - // Incomplete 3 byte encoded character 1 byte missing standalone - "\xE0\xA0", - // Incomplete 3 byte encoded character 2 bytes missing standalone - "\xE0", - // Incomplete surrogate character 1 byte missing standalone - "\xF0\x90\x80", - // Incomplete surrogate character 2 bytes missing standalone - "\xF0\x90", - // Incomplete surrogate character 3 bytes missing standalone - "\xF0", - // Trailing byte with no lead byte standalone - "\x80", - // Incomplete 2 byte encoded character 1 byte missing between 1 byte chars - "\x41\xC2\x42", - // Incomplete 3 byte encoded character 1 byte missing between 1 byte chars - "\x41\xE0\xA0\x42", - // Incomplete 3 byte encoded character 2 bytes missing between 1 byte chars - "\x41\xE0\x42", - // Trailing byte with no lead byte between 1 byte chars - "\x41\x80\x42", - // Incomplete 2 byte encoded character 1 byte missing before 1 byte char - "\xC2\x42", - // Incomplete 3 byte encoded character 1 byte missing before 1 byte char - "\xE0\xA0\x42", - // Incomplete 3 byte encoded character 2 bytes missing before 1 byte char - "\xE0\x42", - // Trailing byte with no lead byte before 1 byte char - "\x80\x42", - // Incomplete 2 byte encoded character 1 byte missing after 1 byte char - "\x41\xC2", - // Incomplete 3 byte encoded character 1 byte missing after 1 byte char - "\x41\xE0\xA0", - // Incomplete 3 byte encoded character 2 bytes missing after 1 byte char - "\x41\xE0", - // Trailing byte with no lead byte after 1 byte char - "\x41\x80", - // Incomplete 2 byte encoded character 1 byte missing between 2 byte chars - "\xC2\x80\xC2\xC3\xBF", - // Incomplete 3 byte encoded character 1 byte missing between 2 byte chars - "\xC2\x80\xE0\xA0\xC3\xBF", - // Incomplete 3 byte encoded character 2 bytes missing between 2 byte chars - "\xC2\x80\xE0\xC3\xBF", - // Trailing byte with no lead byte between 2 byte chars - "\xC2\x80\x80\xC3\xBF", - // 2 byte encoded character in non-shortest form encodings (these are not allowed) - "\xC0\x80", - // 3 byte encoded character in non-shortest form encodings (these are not allowed) - "\xE0\x80\x80", - // 4 byte encoded character in non-shortest form encodings (these are not allowed) - "\xF0\x80\x80\x80", - }; - - const WCHAR * const unicodeStrings[] = - { - // Empty string - W(""), - // 1 byte encoded 1 character long string - W("A"), - // 2 byte encoded 1 character long string - W("\x0080"), - // 3 byte encoded 1 character long string - W("\x0800"), - // 1 byte encoded characters only - W("ABCDEFGHIJKLMNOPQRSTUVWXYZ"), - // 2 byte encoded characters only - W("\x0080\x00FF\x01C1\x07FF"), - // valid 3 byte encoded characters only - W("\x0800\x1D88\x1000\xFFFF"), - // 1 byte and 2 byte encoded characters interleaved 1:1 starting and ending with 1 byte char - W("\x0041\x0080\x0042\x00FF\x0043\x01C1\x0044\x07FF\x0045"), - // 1 byte and 2 byte encoded characters interleaved 1:1 starting with 1 byte char, ending with 2 byte one - W("\x0041\x0080\x0042\x00FF\x0043\x01C1\x0044\x07FF"), - // 1 byte and 2 byte encoded characters interleaved 1:1 starting with 2 byte char, ending with 1 byte one - W("\x0080\x0042\x00FF\x0043\x01C1\x0044\x07FF\x0045"), - // 1 byte and 2 byte encoded characters interleaved 1:1 starting and ending with 2 byte char - W("\x0080\x0042\x00FF\x0043\x01C1\x0044\x07FF"), - // 1 byte and 2 byte encoded characters interleaved 2:2 starting and ending with 1 byte char - W("\x0041\x0042\x0080\x00FF\x0043\x0044\x01C1\x07FF\x0045\x0046"), - // 1 byte and 2 byte encoded characters interleaved 2:2 starting with 1 byte char, ending with 2 byte one - W("\x0041\x0042\x0080\x00FF\x0043\x0044\x01C1\x07FF"), - // 1 byte and 2 byte encoded characters interleaved 2:2 starting with 2 byte char, ending with 1 byte one - W("\x0080\x00FF\x0043\x0044\x01C1\x07FF\x0045\x0046"), - // 1 byte and 2 byte encoded characters interleaved 2:2 starting and ending with 2 byte char - W("\x0080\x00FF\x0043\x0044\x01C1\x07FF"), - // surrogates - W("\xD800\xDC00\xD800\xDE40\xDAC0\xDFB0\xDBFF\xDFFF"), - - // Strings with errors - // Incomplete 2 byte encoded character standalone - W("\xFFFD"), - // Incomplete 3 byte encoded character 1 byte missing standalone - W("\xFFFD"), - // Incomplete 3 byte encoded character 2 bytes missing standalone - W("\xFFFD"), - // Incomplete surrogate character 1 byte missing standalone - W("\xFFFD"), - // Incomplete surrogate character 2 bytes missing standalone - W("\xFFFD"), - // Incomplete surrogate character 3 bytes missing standalone - W("\xFFFD"), - // Trailing byte with no lead byte standalone - W("\xFFFD"), - // Incomplete 2 byte encoded character 1 byte missing between 1 byte chars - W("\x0041\xFFFD\x0042"), - // Incomplete 3 byte encoded character 1 byte missing between 1 byte chars - W("\x0041\xFFFD\x0042"), - // Incomplete 3 byte encoded character 2 bytes missing between 1 byte chars - W("\x0041\xFFFD\x0042"), - // Trailing byte with no lead byte between 1 byte chars - W("\x0041\xFFFD\x0042"), - // Incomplete 2 byte encoded character 1 byte missing before 1 byte char - W("\xFFFD\x0042"), - // Incomplete 3 byte encoded character 1 byte missing before 1 byte char - W("\xFFFD\x0042"), - // Incomplete 3 byte encoded character 2 bytes missing before 1 byte char - W("\xFFFD\x0042"), - // Trailing byte with no lead byte before 1 byte char - W("\xFFFD\x0042"), - // Incomplete 2 byte encoded character 1 byte missing after 1 byte char - W("\x0041\xFFFD"), - // Incomplete 3 byte encoded character 1 byte missing after 1 byte char - W("\x0041\xFFFD"), - // Incomplete 3 byte encoded character 2 bytes missing after 1 byte char - W("\x0041\xFFFD"), - // Trailing byte with no lead byte after 1 byte char - W("\x0041\xFFFD"), - // Incomplete 2 byte encoded character 1 byte missing between 2 byte chars - W("\x0080\xFFFD\x00FF"), - // Incomplete 3 byte encoded character 1 byte missing between 2 byte chars - W("\x0080\xFFFD\x00FF"), - // Incomplete 3 byte encoded character 2 bytes missing between 2 byte chars - W("\x0080\xFFFD\x00FF"), - // Trailing byte with no lead byte between 2 byte chars - W("\x0080\xFFFD\x00FF"), - // 2 byte encoded character in non-shortest form encodings (these are not allowed) - W("\xFFFD\xFFFD"), - // 3 byte encoded character in non-shortest form encodings (these are not allowed) - W("\xFFFD\xFFFD"), - // 4 byte encoded character in non-shortest form encodings (these are not allowed) - W("\xFFFD\xFFFD\xFFFD"), - }; - - for (int i = 0; i < (sizeof(utf8Strings) / sizeof(utf8Strings[0])); i++) - { - ret = MultiByteToWideChar(CP_UTF8, 0, utf8Strings[i], -1, NULL, 0); - WCHAR* wideBuffer = (WCHAR*)malloc(ret * sizeof(WCHAR)); - ret2 = MultiByteToWideChar(CP_UTF8, 0, utf8Strings[i], -1, wideBuffer, ret); - if (ret != ret2) - { - Fail("MultiByteToWideChar string %d: returned different string length for empty and real dest buffers!\n" - "Got %d for the empty one, %d for real one.\n", i, ret2, ret); - } - - if (wcscmp(wideBuffer, unicodeStrings[i]) != 0) - { - Fail("MultiByteToWideChar string %d: the resulting string doesn't match the expected one!\n", i); - } - - free(wideBuffer); - } - - PAL_Terminate(); - - return PASS; -} diff --git a/src/pal/tests/palsuite/locale_info/MultiByteToWideChar/test4/testinfo.dat b/src/pal/tests/palsuite/locale_info/MultiByteToWideChar/test4/testinfo.dat deleted file mode 100644 index e95f41390..000000000 --- a/src/pal/tests/palsuite/locale_info/MultiByteToWideChar/test4/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# -# Copyright (c) Microsoft Corporation. All rights reserved. -# - -Version = 1.0 -Section = Locale Information -Function = MultiByteToWideChar -Name = Test #4 for MultiByteToWideChar -TYPE = DEFAULT -EXE1 = test4 -Description -=Tests MultiByteToWideChar with UTF-8 encoded strings -=containing various corner cases \ No newline at end of file diff --git a/src/pal/tests/palsuite/locale_info/SetThreadLocale/CMakeLists.txt b/src/pal/tests/palsuite/locale_info/SetThreadLocale/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/locale_info/SetThreadLocale/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/locale_info/SetThreadLocale/test1/CMakeLists.txt b/src/pal/tests/palsuite/locale_info/SetThreadLocale/test1/CMakeLists.txt deleted file mode 100644 index 7b0cde4a1..000000000 --- a/src/pal/tests/palsuite/locale_info/SetThreadLocale/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_setthreadlocale_test1 - ${SOURCES} -) - -add_dependencies(paltest_setthreadlocale_test1 coreclrpal) - -target_link_libraries(paltest_setthreadlocale_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/locale_info/SetThreadLocale/test1/test1.cpp b/src/pal/tests/palsuite/locale_info/SetThreadLocale/test1/test1.cpp deleted file mode 100644 index 794093cf4..000000000 --- a/src/pal/tests/palsuite/locale_info/SetThreadLocale/test1/test1.cpp +++ /dev/null @@ -1,50 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: Tests SetThreadLocale with every valid locale to see that it passes -** and that it actually sets the locale. -** -** -**==========================================================================*/ - -#include - -int __cdecl main(int argc, char *argv[]) -{ - int i; - - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - /* Try all possible locale's */ - for (i=0; i<0x000fffff; i++) - { - if (!IsValidLocale(i, LCID_INSTALLED)) - { - continue; - } - - if (!SetThreadLocale(i)) - { - Fail("SetThreadLocale failed for an installed locale!\n"); - } - - if (GetThreadLocale() != i) - { - Fail("SetThreadLocale didn't actually change to LCID %#x!\n", i); - } - } - - PAL_Terminate(); - - return PASS; -} - diff --git a/src/pal/tests/palsuite/locale_info/SetThreadLocale/test1/testinfo.dat b/src/pal/tests/palsuite/locale_info/SetThreadLocale/test1/testinfo.dat deleted file mode 100644 index ba0f5b7ee..000000000 --- a/src/pal/tests/palsuite/locale_info/SetThreadLocale/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Locale Information -Function = SetThreadLocale -Name = Test #1 for SetThreadLocale -TYPE = DEFAULT -EXE1 = test1 -Description -=Tests SetThreadLocale with every valid locale to see that it passes -=and that it actually sets the locale. diff --git a/src/pal/tests/palsuite/locale_info/WideCharToMultiByte/CMakeLists.txt b/src/pal/tests/palsuite/locale_info/WideCharToMultiByte/CMakeLists.txt deleted file mode 100644 index dc5d5131e..000000000 --- a/src/pal/tests/palsuite/locale_info/WideCharToMultiByte/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) -add_subdirectory(test3) -add_subdirectory(test4) -add_subdirectory(test5) diff --git a/src/pal/tests/palsuite/locale_info/WideCharToMultiByte/test1/CMakeLists.txt b/src/pal/tests/palsuite/locale_info/WideCharToMultiByte/test1/CMakeLists.txt deleted file mode 100644 index 913cccc8e..000000000 --- a/src/pal/tests/palsuite/locale_info/WideCharToMultiByte/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_widechartomultibyte_test1 - ${SOURCES} -) - -add_dependencies(paltest_widechartomultibyte_test1 coreclrpal) - -target_link_libraries(paltest_widechartomultibyte_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/locale_info/WideCharToMultiByte/test1/test1.cpp b/src/pal/tests/palsuite/locale_info/WideCharToMultiByte/test1/test1.cpp deleted file mode 100644 index cd763f33b..000000000 --- a/src/pal/tests/palsuite/locale_info/WideCharToMultiByte/test1/test1.cpp +++ /dev/null @@ -1,102 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: Tests WideCharToMultiByte with all the ASCII characters (0-127). -** Also tests that WideCharToMultiByte handles different buffer -** lengths correctly (0, -1, and a valid length) -** -** -**==========================================================================*/ - -#include - -int __cdecl main(int argc, char *argv[]) -{ - char mbStr[128]; - WCHAR wideStr[128]; - int ret; - int i; - int k; - BOOL bRet=TRUE; - - /* These codepages are currently supported by the PAL */ - int codePages[] ={ - CP_ACP, - CP_UTF8 - }; - - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - /* Go through all of the code pages */ - for(i=0; i<(sizeof(codePages)/sizeof(int)); i++) - { - - for (k=0; k<128; k++) - { - wideStr[k] = 127 - k; - mbStr[k] = 0; - } - - /* Convert with buffer size of 0 */ - ret = WideCharToMultiByte(codePages[i], 0, wideStr, -1, - mbStr, 0, NULL, NULL); - if (ret != 128) - { - Trace("WideCharToMultiByte did not return correct string length!\n" - "Got %d, expected %d for code page %d with error %u.\n", - ret, 128,codePages[i],GetLastError()); - bRet=FALSE; - } - - /* Make sure the ASCII set (0-127) gets translated correctly */ - ret = WideCharToMultiByte(codePages[i], 0, wideStr, -1, - mbStr, 128, NULL, NULL); - if (ret != 128) - { - Trace("WideCharToMultiByte did not return correct string length!\n" - "Got %d, expected %d for code page %d with error %u.\n", - ret, 128,codePages[i],GetLastError()); - bRet=FALSE; - } - - for (k=0; k<128; k++) - { - if (mbStr[k] != 127 - k) - { - Trace("WideCharToMultiByte failed to translate correctly!\n" - "Expected character %d to be %c (%x), got %c (%x) for " - "code page %d\n",k, 127 - k, 127 - k,mbStr[k], mbStr[k], - codePages[i]); - bRet=FALSE; - } - } - - - /* try a 0 length string ("") */ - wideStr[0] = '\0'; - ret = WideCharToMultiByte(codePages[i], 0, wideStr, -1, - mbStr, 0, NULL, NULL); - if (ret != 1) - { - Trace("WideCharToMultiByte did not return correct string length!\n" - "Got %d, expected %d for code page %d with error %u.\n", - ret, 1,codePages[i],GetLastError()); - bRet=FALSE; - } - } - - int result = bRet ? PASS : FAIL; - PAL_TerminateEx(result); - return result; -} - diff --git a/src/pal/tests/palsuite/locale_info/WideCharToMultiByte/test1/testinfo.dat b/src/pal/tests/palsuite/locale_info/WideCharToMultiByte/test1/testinfo.dat deleted file mode 100644 index 9fb5f0f03..000000000 --- a/src/pal/tests/palsuite/locale_info/WideCharToMultiByte/test1/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Locale Information -Function = WideCharToMultiByte -Name = Test #1 for WideCharToMultiByte -TYPE = DEFAULT -EXE1 = test1 -Description -=Tests WideCharToMultiByte with all the ASCII characters (0-127). -=Also tests that WideCharToMultiByte handles different buffer -=lengths correctly (0, -1, and a valid length) diff --git a/src/pal/tests/palsuite/locale_info/WideCharToMultiByte/test2/CMakeLists.txt b/src/pal/tests/palsuite/locale_info/WideCharToMultiByte/test2/CMakeLists.txt deleted file mode 100644 index 305348cd1..000000000 --- a/src/pal/tests/palsuite/locale_info/WideCharToMultiByte/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test2.cpp -) - -add_executable(paltest_widechartomultibyte_test2 - ${SOURCES} -) - -add_dependencies(paltest_widechartomultibyte_test2 coreclrpal) - -target_link_libraries(paltest_widechartomultibyte_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/locale_info/WideCharToMultiByte/test2/test2.cpp b/src/pal/tests/palsuite/locale_info/WideCharToMultiByte/test2/test2.cpp deleted file mode 100644 index f5d40ae90..000000000 --- a/src/pal/tests/palsuite/locale_info/WideCharToMultiByte/test2/test2.cpp +++ /dev/null @@ -1,88 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test2.c -** -** Purpose: Tests that WideCharToMultiByte respects the length of the wide -** character string. -** -** -**==========================================================================*/ - -#include - - -int __cdecl main(int argc, char *argv[]) -{ - char mbStr[128]; - WCHAR wideStr[128]; - int ret; - int i; - int k; - BOOL bRet=TRUE; - - /* These codepages are currently supported by the PAL */ - int codePages[] ={ - CP_ACP, - CP_UTF8 - }; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - /* Go through all of the code pages */ - for(i=0; i<(sizeof(codePages)/sizeof(int)); i++) - { - - /* Filling the arrays */ - for (k=0; k<128; k++) - { - wideStr[k] = 'a'; - mbStr[i] = 0; - } - - wideStr[127] = 0; - - /* Passing a buffer that is too small */ - ret = WideCharToMultiByte(codePages[i], 0, wideStr, 10, - mbStr, 0, NULL, NULL); - if (ret != 10) - { - Trace("WideCharToMultiByte did not return correct string length!\n" - "Got %d, expected %d for %d with error %u.\n", ret, 10, - codePages[i], GetLastError()); - bRet = FALSE; - } - - /* Passing a sufficiently large buffer */ - mbStr[10] = 'b'; - ret = WideCharToMultiByte(codePages[i], 0, wideStr, 10, - mbStr, 128, NULL, NULL); - if (ret != 10) - { - Trace("WideCharToMultiByte did not return correct string length!\n" - "Got %d, expected %d for code page %d with error %u.\n", - ret, 10, codePages[i], GetLastError()); - bRet = FALSE; - } - - /* Verifying overflow of the destination string did not occur */ - if (mbStr[10] != 'b') - { - Trace("WideCharToMultiByte overflowed the destination buffer for " - "code page %d.\n", codePages[i]); - bRet = FALSE; - } - - } - - int result = bRet ? PASS : FAIL; - PAL_TerminateEx(result); - return result; -} - diff --git a/src/pal/tests/palsuite/locale_info/WideCharToMultiByte/test2/testinfo.dat b/src/pal/tests/palsuite/locale_info/WideCharToMultiByte/test2/testinfo.dat deleted file mode 100644 index e5b50b814..000000000 --- a/src/pal/tests/palsuite/locale_info/WideCharToMultiByte/test2/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Locale Information -Function = WideCharToMultiByte -Name = Test #2 for WideCharToMultiByte -TYPE = DEFAULT -EXE1 = test2 -Description -=Tests that WideCharToMultiByte respects the length of the wide -=character string. diff --git a/src/pal/tests/palsuite/locale_info/WideCharToMultiByte/test3/CMakeLists.txt b/src/pal/tests/palsuite/locale_info/WideCharToMultiByte/test3/CMakeLists.txt deleted file mode 100644 index f5a8bf977..000000000 --- a/src/pal/tests/palsuite/locale_info/WideCharToMultiByte/test3/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test3.cpp -) - -add_executable(paltest_widechartomultibyte_test3 - ${SOURCES} -) - -add_dependencies(paltest_widechartomultibyte_test3 coreclrpal) - -target_link_libraries(paltest_widechartomultibyte_test3 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/locale_info/WideCharToMultiByte/test3/test3.cpp b/src/pal/tests/palsuite/locale_info/WideCharToMultiByte/test3/test3.cpp deleted file mode 100644 index ecd26addb..000000000 --- a/src/pal/tests/palsuite/locale_info/WideCharToMultiByte/test3/test3.cpp +++ /dev/null @@ -1,100 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test3.c -** -** Purpose: Tests that WideCharToMultiByte correctly handles the following -** error conditions: insufficient buffer space, invalid code pages, -** and invalid flags. -** -** -**==========================================================================*/ - - -#include - - -int __cdecl main(int argc, char *argv[]) -{ - char mbStr[128]; - WCHAR wideStr[128]; - int ret; - int i; - int k; - BOOL bRet=TRUE; - - /* These codepages are currently supported by the PAL */ - int codePages[] ={ - CP_ACP, - CP_UTF8 - }; - - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - /* Go through all of the code pages */ - for(i=0; i<(sizeof(codePages)/sizeof(int)); i++) - { - - for (k=0; k<128; k++) - { - wideStr[k] = 'a'; - mbStr[k] = 0; - } - - wideStr[127] = 0; - - /* try with insufficient buffer space */ - ret = WideCharToMultiByte(codePages[i], 0, wideStr, -1, - mbStr, 10, NULL, NULL); - if (ret != 0) - { - Trace("WideCharToMultiByte did not return an error!\n" - "Expected return of 0, got %d for code page %d.\n", ret, - codePages[i]); - bRet = FALSE; - } - - ret = GetLastError(); - if (ret != ERROR_INSUFFICIENT_BUFFER) - { - Fail("WideCharToMultiByte set the last error to %u instead of " - "ERROR_INSUFFICIENT_BUFFER for code page %d.\n", - GetLastError(),codePages[i]); - bRet = FALSE; - } - } - - /* Return failure if any of the code pages returned the wrong results */ - if(!bRet) - { - return FAIL; - } - - /* try with a wacky code page */ - ret = WideCharToMultiByte(-1, 0, wideStr, -1, mbStr, 128, NULL, NULL); - if (ret != 0) - { - Fail("WideCharToMultiByte did not return an error!\n" - "Expected return of 0, got %d for invalid code page.\n", ret); - } - - ret = GetLastError(); - if (ret != ERROR_INVALID_PARAMETER) - { - Fail("WideCharToMultiByte set the last error to %u instead of " - "ERROR_INVALID_PARAMETER for invalid code page -1.\n", - GetLastError()); - } - - PAL_Terminate(); - - return PASS; -} - diff --git a/src/pal/tests/palsuite/locale_info/WideCharToMultiByte/test3/testinfo.dat b/src/pal/tests/palsuite/locale_info/WideCharToMultiByte/test3/testinfo.dat deleted file mode 100644 index b737686c3..000000000 --- a/src/pal/tests/palsuite/locale_info/WideCharToMultiByte/test3/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Locale Information -Function = WideCharToMultiByte -Name = Test #3 for WideCharToMultiByte -TYPE = DEFAULT -EXE1 = test3 -Description -=Tests that WideCharToMultiByte correctly handles the following -=error conditions: insufficient buffer space and invalid code pages. - diff --git a/src/pal/tests/palsuite/locale_info/WideCharToMultiByte/test4/CMakeLists.txt b/src/pal/tests/palsuite/locale_info/WideCharToMultiByte/test4/CMakeLists.txt deleted file mode 100644 index bea8e1aac..000000000 --- a/src/pal/tests/palsuite/locale_info/WideCharToMultiByte/test4/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test4.cpp -) - -add_executable(paltest_widechartomultibyte_test4 - ${SOURCES} -) - -add_dependencies(paltest_widechartomultibyte_test4 coreclrpal) - -target_link_libraries(paltest_widechartomultibyte_test4 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/locale_info/WideCharToMultiByte/test4/test4.cpp b/src/pal/tests/palsuite/locale_info/WideCharToMultiByte/test4/test4.cpp deleted file mode 100644 index 8ab5fe90a..000000000 --- a/src/pal/tests/palsuite/locale_info/WideCharToMultiByte/test4/test4.cpp +++ /dev/null @@ -1,131 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test4.c -** -** Purpose: Tests that WideCharToMultiByte correctly handles WC_NO_BEST_FIT_CHARS -** -** -**==========================================================================*/ - - -#include - -/* C with a circumflex */ -wchar_t ustr[2] = { 0x108, 0 }; - -/* expected conversion when best fit is allowed on Windows */ -char* lpBestFitRes = "C"; - -/* expected conversion when no default character is specified */ -char* lpResStr1 = "?"; - -/* expected conversion when the default character is 'k' */ -char myDefaultChar = 'k'; -char* lpResStr2 = "k"; - -int -TestWideCharToMultiByte( - IN UINT CodePage, - IN DWORD dwFlags, - IN LPCSTR lpDefaultChar, - IN LPSTR lpResStr) -{ - char mbstr[30]; - int ret; - int testStatus = PASS; - BOOL usedDefaultChar = FALSE; - - printf("WideCharToMultiByte (CodePage=%d, dwFlags=%#x, default=%c)\n", - CodePage, dwFlags, lpDefaultChar?*lpDefaultChar:' '); - ret = WideCharToMultiByte(CodePage, dwFlags, ustr, -1, mbstr, sizeof(mbstr), - lpDefaultChar, &usedDefaultChar); - if (ret != 0) { - printf(" converted C with circumflex to in Unicode to multibyte: " - "\"%s\"\n", mbstr); - printf(" used default character?: %d\n", usedDefaultChar); - if (strcmp(mbstr, lpResStr) != 0 || usedDefaultChar != TRUE) - { - printf("!!!! failed conversion !!!!\n"); - testStatus = FAIL; - } - } - else { - printf("!!!! failed conversion !!!!\n"); - testStatus = FAIL; - } - return testStatus; -} - -int __cdecl main(int argc, char *argv[]) -{ - int testStatus = PASS; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - /* Use WideCharToMultiByte to convert the string in code page CP_ACP. - * Note that the resulting string will be different on Windows PAL and - * Unix PAL. On Windows, the default best fit behavior will map C with - * circumflex to C. - * - * testStatus |= TestWideCharToMultiByte(CP_ACP, 0, NULL, lpBestFitRes); - * - * On Unix, where there is no support for finding best fit, it will be - * mapped to a '?'. In addition, it will trigger an ASSERT in the dbg/chk - * builds. - * - * testStatus |= TestWideCharToMultiByte(CP_ACP, 0, NULL, lpResStr1); - */ - - /* Use WideCharToMultiByte with WC_NO_BEST_FIR_CHARS to convert the string - * in CP_ACP (1252 by default). This will prevent it from mapping the C - * with circumflex to its closest match in the ANSI code page: C - */ - testStatus |= TestWideCharToMultiByte(CP_ACP, WC_NO_BEST_FIT_CHARS, NULL, lpResStr1); - - - /* Use WideCharToMultiByte with WC_NO_BEST_FIR_CHARS and a default character - * to convert the string. This will prevent it from mapping the C with - * circumflex to its closest match in the ANSI code page: C. It will be - * replaced with the specified default character. - */ - testStatus |= TestWideCharToMultiByte(CP_ACP, WC_NO_BEST_FIT_CHARS, &myDefaultChar, lpResStr2); - - /* Use WideCharToMultiByte to convert the string in code page 1253 - * Note that the resulting string will be different on Windows PAL and - * Unix PAL. On Windows, the default best fit behavior will map C with - * circumflex to C. - * - * testStatus |= TestWideCharToMultiByte(1253, 0, NULL, lpBestFitRes); - * - * On Unix, where there is no support for finding best fit, it will be - * mapped to a '?'. In addition, it will trigger an ASSERT in the dbg/chk - * builds. - * - * testStatus |= TestWideCharToMultiByte(1253, 0, NULL, lpResStr1); - */ - - /* Use WideCharToMultiByte with WC_NO_BEST_FIR_CHARS to convert the string - * in 1253. This will prevent it from mapping the C - * with circumflex to its closest match in the ANSI code page: C - */ - testStatus |= TestWideCharToMultiByte(1253, WC_NO_BEST_FIT_CHARS, NULL, lpResStr1); - - /* Use WideCharToMultiByte with WC_NO_BEST_FIR_CHARS and a default - * character to convert the string in 1253. This will prevent it from - * mapping the C with circumflex to its closest match in the ANSI code - * page: C. It will be replaced with the specified default character. - */ - testStatus |= TestWideCharToMultiByte(1253, WC_NO_BEST_FIT_CHARS, &myDefaultChar, lpResStr2); - - PAL_TerminateEx(testStatus); - - return testStatus; -} - diff --git a/src/pal/tests/palsuite/locale_info/WideCharToMultiByte/test4/testinfo.dat b/src/pal/tests/palsuite/locale_info/WideCharToMultiByte/test4/testinfo.dat deleted file mode 100644 index 03b00d354..000000000 --- a/src/pal/tests/palsuite/locale_info/WideCharToMultiByte/test4/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Locale Information -Function = WideCharToMultiByte -Name = Test #4 for WideCharToMultiByte -TYPE = DEFAULT -EXE1 = test4 -Description -=Tests that WideCharToMultiByte correctly handles WC_NO_BEST_FIT_CHARS diff --git a/src/pal/tests/palsuite/locale_info/WideCharToMultiByte/test5/CMakeLists.txt b/src/pal/tests/palsuite/locale_info/WideCharToMultiByte/test5/CMakeLists.txt deleted file mode 100644 index 51851e45d..000000000 --- a/src/pal/tests/palsuite/locale_info/WideCharToMultiByte/test5/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test5.cpp -) - -add_executable(paltest_widechartomultibyte_test5 - ${SOURCES} -) - -add_dependencies(paltest_widechartomultibyte_test5 coreclrpal) - -target_link_libraries(paltest_widechartomultibyte_test5 - ${COMMON_TEST_LIBRARIES} -) \ No newline at end of file diff --git a/src/pal/tests/palsuite/locale_info/WideCharToMultiByte/test5/test5.cpp b/src/pal/tests/palsuite/locale_info/WideCharToMultiByte/test5/test5.cpp deleted file mode 100644 index 393516a19..000000000 --- a/src/pal/tests/palsuite/locale_info/WideCharToMultiByte/test5/test5.cpp +++ /dev/null @@ -1,154 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test4.c -** -** Purpose: Tests WideCharMultiByte with UTF-8 encoding -** -** -**==========================================================================*/ - -#include - -int __cdecl main(int argc, char *argv[]) -{ - int ret; - int ret2; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - const WCHAR * const unicodeStrings[] = - { - // Correct strings - - // Empty string - W(""), - // 1 byte encoded 1 character long string - W("A"), - // 2 byte encoded 1 character long string - W("\x0080"), - // 3 byte encoded 1 character long string - W("\x0800"), - // 1 byte encoded characters only - W("ABCDEFGHIJKLMNOPQRSTUVWXYZ"), - // 2 byte encoded characters only - W("\x0080\x00FF\x01C1\x07FF"), - // valid 3 byte encoded characters only - W("\x0800\x1D88\x1000\xFFFF"), - // 1 byte and 2 byte encoded characters interleaved 1:1 starting and ending with 1 byte char - W("\x0041\x0080\x0042\x00FF\x0043\x01C1\x0044\x07FF\x0045"), - // 1 byte and 2 byte encoded characters interleaved 1:1 starting with 1 byte char, ending with 2 byte one - W("\x0041\x0080\x0042\x00FF\x0043\x01C1\x0044\x07FF"), - // 1 byte and 2 byte encoded characters interleaved 1:1 starting with 2 byte char, ending with 1 byte one - W("\x0080\x0042\x00FF\x0043\x01C1\x0044\x07FF\x0045"), - // 1 byte and 2 byte encoded characters interleaved 1:1 starting and ending with 2 byte char - W("\x0080\x0042\x00FF\x0043\x01C1\x0044\x07FF"), - // 1 byte and 2 byte encoded characters interleaved 2:2 starting and ending with 1 byte char - W("\x0041\x0042\x0080\x00FF\x0043\x0044\x01C1\x07FF\x0045\x0046"), - // 1 byte and 2 byte encoded characters interleaved 2:2 starting with 1 byte char, ending with 2 byte one - W("\x0041\x0042\x0080\x00FF\x0043\x0044\x01C1\x07FF"), - // 1 byte and 2 byte encoded characters interleaved 2:2 starting with 2 byte char, ending with 1 byte one - W("\x0080\x00FF\x0043\x0044\x01C1\x07FF\x0045\x0046"), - // 1 byte and 2 byte encoded characters interleaved 2:2 starting and ending with 2 byte char - W("\x0080\x00FF\x0043\x0044\x01C1\x07FF"), - // Surrogates - W("\xD800\xDC00\xD800\xDE40\xDAC0\xDFB0\xDBFF\xDFFF"), - - // Strings with errors - - // Single high surrogate - W("\xD800"), - // Single low surrogate - W("\xDC00"), - // Character followed by single high surrogate - W("\x0041\xD800"), - // Character followed by single low surrogate - W("\x0041\xDC00"), - // Single high surrogate between two characters - W("\x0041\xD800\x0042"), - // Single low surrogate between two characters - W("\x0041\xDC00\x0042"), - }; - - const char * const utf8Strings[] = - { - // Correct strings - - // Empty string - "", - // 1 byte encoded 1 character long string - "A", - // 2 byte encoded 1 character long string - "\xC2\x80", - // 3 byte encoded 1 character long string - "\xE0\xA0\x80", - // 1 byte encoded characters only - "ABCDEFGHIJKLMNOPQRSTUVWXYZ", - // valid 2 byte encoded characters only - "\xC2\x80\xC3\xBF\xC7\x81\xDF\xBF", - // valid 3 byte encoded characters only - "\xE0\xA0\x80\xE1\xB6\x88\xE1\x80\x80\xEF\xBF\xBF", - // 1 byte and 2 byte encoded characters interleaved 1:1 starting and ending with 1 byte char - "\x41\xC2\x80\x42\xC3\xBF\x43\xC7\x81\x44\xDF\xBF\x45", - // 1 byte and 2 byte encoded characters interleaved 1:1 starting with 1 byte char, ending with 2 byte one - "\x41\xC2\x80\x42\xC3\xBF\x43\xC7\x81\x44\xDF\xBF", - // 1 byte and 2 byte encoded characters interleaved 1:1 starting with 2 byte char, ending with 1 byte one - "\xC2\x80\x42\xC3\xBF\x43\xC7\x81\x44\xDF\xBF\x45", - // 1 byte and 2 byte encoded characters interleaved 1:1 starting and ending with 2 byte char - "\xC2\x80\x42\xC3\xBF\x43\xC7\x81\x44\xDF\xBF", - // 1 byte and 2 byte encoded characters interleaved 2:2 starting and ending with 1 byte char - "\x41\x42\xC2\x80\xC3\xBF\x43\x44\xC7\x81\xDF\xBF\x45\x46", - // 1 byte and 2 byte encoded characters interleaved 2:2 starting with 1 byte char, ending with 2 byte one - "\x41\x42\xC2\x80\xC3\xBF\x43\x44\xC7\x81\xDF\xBF", - // 1 byte and 2 byte encoded characters interleaved 2:2 starting with 2 byte char, ending with 1 byte one - "\xC2\x80\xC3\xBF\x43\x44\xC7\x81\xDF\xBF\x45\x46", - // 1 byte and 2 byte encoded characters interleaved 2:2 starting and ending with 2 byte char - "\xC2\x80\xC3\xBF\x43\x44\xC7\x81\xDF\xBF", - // Surrogates - "\xF0\x90\x80\x80\xF0\x90\x89\x80\xF3\x80\x8E\xB0\xF4\x8F\xBF\xBF", - - // Strings with errors - - // Single high surrogate - "\xEF\xBF\xBD", - // Single low surrogate - "\xEF\xBF\xBD", - // Character followed by single high surrogate - "\x41\xEF\xBF\xBD", - // Character followed by single low surrogate - "\x41\xEF\xBF\xBD", - // Single high surrogate between two characters - "\x41\xEF\xBF\xBD\x42", - // Single low surrogate between two characters - "\x41\xEF\xBF\xBD\x42", - }; - - for (int i = 0; i < (sizeof(unicodeStrings) / sizeof(unicodeStrings[0])); i++) - { - ret = WideCharToMultiByte(CP_UTF8, 0, unicodeStrings[i], -1, NULL, 0, NULL, NULL); - CHAR* utf8Buffer = (CHAR*)malloc(ret * sizeof(CHAR)); - ret2 = WideCharToMultiByte(CP_UTF8, 0, unicodeStrings[i], -1, utf8Buffer, ret, NULL, NULL); - if (ret != ret2) - { - Fail("WideCharToMultiByte string %d: returned different string length for empty and real dest buffers!\n" - "Got %d for the empty one, %d for real one.\n", i, ret2, ret); - } - - if (strcmp(utf8Buffer, utf8Strings[i]) != 0) - { - Fail("WideCharToMultiByte string %d: the resulting string doesn't match the expected one!\n", i); - } - - free(utf8Buffer); - } - - PAL_Terminate(); - - return PASS; -} diff --git a/src/pal/tests/palsuite/locale_info/WideCharToMultiByte/test5/testinfo.dat b/src/pal/tests/palsuite/locale_info/WideCharToMultiByte/test5/testinfo.dat deleted file mode 100644 index 485d9401e..000000000 --- a/src/pal/tests/palsuite/locale_info/WideCharToMultiByte/test5/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# -# Copyright (c) Microsoft Corporation. All rights reserved. -# - -Version = 1.0 -Section = Locale Information -Function = WideCharToMultiByte -Name = Test #5 for WideCharToMultiByte -TYPE = DEFAULT -EXE1 = test5 -Description -=Tests WideCharToMultiByte conversion to UTF-8 -=containing various corner cases \ No newline at end of file diff --git a/src/pal/tests/palsuite/manual-inspect.dat b/src/pal/tests/palsuite/manual-inspect.dat deleted file mode 100644 index c541b2ff8..000000000 --- a/src/pal/tests/palsuite/manual-inspect.dat +++ /dev/null @@ -1,17 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -# Automatable to detect gross errors; also manually inspect for proper behaviour -miscellaneous/messageboxw/test1,1 -# Automatable to detect gross errors; also manually inspect for proper behaviour -# Env var PAL_DISABLE_MESSAGEBOX=1 disables msg boxes for automation on Windows -miscellaneous/messageboxw/test2,1 -# Automatable to detect gross errors; also manually inspect for proper behaviour -pal_specific/pal_get_stderr/test1,1 -pal_specific/pal_get_stdout/test1,1 -# The tests for the sleep api may fail depending upon what other -# processes are running and their relative priority. -threading/sleep/test1,1 -threading/sleepex/test1,1 - diff --git a/src/pal/tests/palsuite/manual-unautomatable.dat b/src/pal/tests/palsuite/manual-unautomatable.dat deleted file mode 100644 index 0a9a7a1b6..000000000 --- a/src/pal/tests/palsuite/manual-unautomatable.dat +++ /dev/null @@ -1,35 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -#This test is negative and will exit with exit(1). -#Therefore, the harness would record it as a failure -c_runtime/exit/test2,1 -# A successful DebugBreak test run dumps core or throws up an ASSERT -# dialog box (or...) and returns an exit code != 0 -debug_api/debugbreak/test1,1 -# debug_api/outputdebugstringa/test1 attempts to send "Foo!" to the debugger -# The PAL behaviour is implementation dependant and can include an interactive -# dialog -debug_api/outputdebugstringw/test1,1 -debug_api/outputdebugstringa/test1,1 -# The return code on success is NOT the usual 0, instead it's 3 -exception_handling/setunhandledexceptionfilter/test1,1 -# These tests require user intervention and cannot be automated -pal_specific/pal_get_stdin/test1,1 -threading/setconsolectrlhandler/test1,1 -threading/setconsolectrlhandler/test4,1 -# These tests take several minutes to run and time out when run with the harness -file_io/gettempfilenamea/test2,1 -file_io/gettempfilenamew/test2,1 -# getstdhandle fails under Windows if the output is redirected so -# it must be run from the command line -file_io/getstdhandle/test1,1 -# This test runs calculations in a nested loop to occupy the processor. -# This causes the test harness to time out on some machines. -threading/threadpriority/test1,1 -# This test runs for 96 minutes and will time out with the harness. -threading/sleep/test2,1 -# This test runs forever by design. -threading/waitformultipleobjects/test2,1 - diff --git a/src/pal/tests/palsuite/miscellaneous/CGroup/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/CGroup/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/miscellaneous/CGroup/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/miscellaneous/CGroup/test1/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/CGroup/test1/CMakeLists.txt deleted file mode 100644 index cdd7fa99d..000000000 --- a/src/pal/tests/palsuite/miscellaneous/CGroup/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test.cpp -) - -add_executable(paltest_cgroup_test1 - ${SOURCES} -) - -add_dependencies(paltest_cgroup_test1 coreclrpal) - -target_link_libraries(paltest_cgroup_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/miscellaneous/CGroup/test1/test.cpp b/src/pal/tests/palsuite/miscellaneous/CGroup/test1/test.cpp deleted file mode 100644 index 44b970a23..000000000 --- a/src/pal/tests/palsuite/miscellaneous/CGroup/test1/test.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source: test.c -** -** Purpose: Test for CGroup -** -** -** Steps to run this test on ubuntu: -** 1. sudo apt-get install cgroup-bin -** 2. sudo vi /etc/default/grub -** Add cgroup_enable=memory swapaccount=1 to GRUB_CMDLINE_LINUX_DEFAULT -** 3. sudo update-grub -** 4. reboot -** 5. sudo cgcreate -g cpu,memory:/myGroup -a : -t : -** 6. echo 4M > /sys/fs/cgroup/memory/mygroup/memory.limit_in_bytes -** 7. echo 4M > /sys/fs/cgroup/memory/mygroup/memory.memsw.limit_in_bytes -** 8. cgexe -g memory:/mygroup --sticky -**=========================================================*/ - -#include - -int __cdecl main(int argc,char *argv[]) -{ - - /* - * Initialize the PAL and return FAILURE if this fails - */ - - if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - size_t mem_limit = PAL_GetRestrictedPhysicalMemoryLimit(); - - FILE* file = fopen("/sys/fs/cgroup/memory/mygroup/memory.limit_in_bytes", "r"); - if(file != NULL) - { - if(mem_limit != 4194304) - Fail("Memory limit obtained from PAL_GetRestrictedPhysicalMemory is not 4MB\n"); - fclose(file); - } - - PAL_Terminate(); - return PASS; -} - - - diff --git a/src/pal/tests/palsuite/miscellaneous/CGroup/test1/testinfo.dat b/src/pal/tests/palsuite/miscellaneous/CGroup/test1/testinfo.dat deleted file mode 100644 index 86da2d151..000000000 --- a/src/pal/tests/palsuite/miscellaneous/CGroup/test1/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Miscellaneous -Function = CGroup -Name = Positive Test for CGroup -TYPE = DEFAULT -EXE1 = test -Description -= Test to see if Cgroup memory limit works properly diff --git a/src/pal/tests/palsuite/miscellaneous/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/CMakeLists.txt deleted file mode 100644 index d437fc932..000000000 --- a/src/pal/tests/palsuite/miscellaneous/CMakeLists.txt +++ /dev/null @@ -1,39 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(CGroup) -add_subdirectory(CharNextA) -add_subdirectory(CharNextExA) -add_subdirectory(CloseHandle) -add_subdirectory(CreatePipe) -add_subdirectory(FlushInstructionCache) -add_subdirectory(FormatMessageW) -add_subdirectory(FreeEnvironmentStringsW) -add_subdirectory(GetCommandLineW) -add_subdirectory(GetEnvironmentStringsW) -add_subdirectory(GetEnvironmentVariableA) -add_subdirectory(GetEnvironmentVariableW) -add_subdirectory(GetLastError) -add_subdirectory(GetSystemInfo) -add_subdirectory(GlobalMemoryStatusEx) -add_subdirectory(GetTickCount) -add_subdirectory(InterlockedBit) -add_subdirectory(InterlockedCompareExchange) -add_subdirectory(InterlockedCompareExchange64) -add_subdirectory(InterlockedCompareExchangePointer) -add_subdirectory(InterlockedDecrement) -add_subdirectory(InterlockedDecrement64) -add_subdirectory(InterlockedExchange) -add_subdirectory(InterlockedExchange64) -add_subdirectory(InterLockedExchangeAdd) -add_subdirectory(InterlockedExchangePointer) -add_subdirectory(InterlockedIncrement) -add_subdirectory(InterlockedIncrement64) -add_subdirectory(lstrlenA) -add_subdirectory(lstrlenW) -add_subdirectory(queryperformancecounter) -add_subdirectory(queryperformancefrequency) -add_subdirectory(SetEnvironmentVariableA) -add_subdirectory(SetEnvironmentVariableW) -add_subdirectory(SetLastError) -add_subdirectory(_i64tow) - diff --git a/src/pal/tests/palsuite/miscellaneous/CharNextA/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/CharNextA/CMakeLists.txt deleted file mode 100644 index ef14ea535..000000000 --- a/src/pal/tests/palsuite/miscellaneous/CharNextA/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) - diff --git a/src/pal/tests/palsuite/miscellaneous/CharNextA/test1/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/CharNextA/test1/CMakeLists.txt deleted file mode 100644 index aa7abfbee..000000000 --- a/src/pal/tests/palsuite/miscellaneous/CharNextA/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test.cpp -) - -add_executable(paltest_charnexta_test1 - ${SOURCES} -) - -add_dependencies(paltest_charnexta_test1 coreclrpal) - -target_link_libraries(paltest_charnexta_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/miscellaneous/CharNextA/test1/test.cpp b/src/pal/tests/palsuite/miscellaneous/CharNextA/test1/test.cpp deleted file mode 100644 index d2a3db31d..000000000 --- a/src/pal/tests/palsuite/miscellaneous/CharNextA/test1/test.cpp +++ /dev/null @@ -1,62 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source: test.c -** -** Purpose: Test for CharNextA, ensures it returns the proper char for an -** entire string -** -** -**=========================================================*/ - -#include - -int __cdecl main(int argc,char *argv[]) -{ - - char * AnExampleString = "this is the string"; - char * StringPointer = AnExampleString; - int count = 0; - - /* - * Initialize the PAL and return FAILURE if this fails - */ - - if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - /* Use CharNext to move through an entire string. Ensure the pointer that - is returned points to the correct character, by comparing it with - 'StringPointer' which isn't touched by CharNext. - */ - - while(*AnExampleString != '\0') - { - - /* Fail if any characters are different. This is comparing the - * addresses of both characters, not the characters themselves. - */ - - if(AnExampleString != &StringPointer[count]) - { - Fail("ERROR: %#x and %#x are different. These should be the same " - " address.\n",AnExampleString,&StringPointer[count]); - - - } - - AnExampleString = CharNextA(AnExampleString); - ++count; - } - - PAL_Terminate(); - return PASS; -} - - - diff --git a/src/pal/tests/palsuite/miscellaneous/CharNextA/test1/testinfo.dat b/src/pal/tests/palsuite/miscellaneous/CharNextA/test1/testinfo.dat deleted file mode 100644 index e2b5e501d..000000000 --- a/src/pal/tests/palsuite/miscellaneous/CharNextA/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Miscellaneous -Function = CharNextA -Name = Positive Test for CharNextA -TYPE = DEFAULT -EXE1 = test -Description -= Test to see if CharNextA works properly -= when calling it repeatedly on a single string. diff --git a/src/pal/tests/palsuite/miscellaneous/CharNextA/test2/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/CharNextA/test2/CMakeLists.txt deleted file mode 100644 index 3339e097d..000000000 --- a/src/pal/tests/palsuite/miscellaneous/CharNextA/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test.cpp -) - -add_executable(paltest_charnexta_test2 - ${SOURCES} -) - -add_dependencies(paltest_charnexta_test2 coreclrpal) - -target_link_libraries(paltest_charnexta_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/miscellaneous/CharNextA/test2/test.cpp b/src/pal/tests/palsuite/miscellaneous/CharNextA/test2/test.cpp deleted file mode 100644 index 726195902..000000000 --- a/src/pal/tests/palsuite/miscellaneous/CharNextA/test2/test.cpp +++ /dev/null @@ -1,67 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source: test.c -** -** Purpose: Test for CharNextA, ensures it returns an LPTSTR -** -** -**=========================================================*/ - -/* Depends on strcmp() */ - -#include - -void testString(LPSTR input, LPSTR expected) -{ - - LPTSTR pReturned = NULL; - - pReturned = CharNextA(input); - - /* Compare the Returned String to what it should be */ - if(strcmp(expected,pReturned) != 0) - { - Fail("ERROR: CharNextA Failed: [%s] and [%s] are not equal, " - "they should be after calling CharNextA.\n", - pReturned,expected); - } - - -} - -int __cdecl main(int argc, char *argv[]) -{ - - /* - * Initialize the PAL and return FAILURE if this fails - */ - - if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - /* test several Strings */ - testString("this is the string", "his is the string"); - testString("t", ""); - testString("", ""); - testString("a\t", "\t"); - testString("a\a", "\a"); - testString("a\b", "\b"); - testString("a\"", "\""); - testString("a\\", "\\"); - testString("\\", ""); - testString("\f", ""); - testString("\b", ""); - - PAL_Terminate(); - return PASS; -} - - - - diff --git a/src/pal/tests/palsuite/miscellaneous/CharNextA/test2/testinfo.dat b/src/pal/tests/palsuite/miscellaneous/CharNextA/test2/testinfo.dat deleted file mode 100644 index 4b663851b..000000000 --- a/src/pal/tests/palsuite/miscellaneous/CharNextA/test2/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Miscellaneous -Function = CharNextA -Name = Positive Test for CharNextA -TYPE = DEFAULT -EXE1 = test -Description -= Test to ensure it returns an LPTSTR when called on a string diff --git a/src/pal/tests/palsuite/miscellaneous/CharNextExA/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/CharNextExA/CMakeLists.txt deleted file mode 100644 index ef14ea535..000000000 --- a/src/pal/tests/palsuite/miscellaneous/CharNextExA/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) - diff --git a/src/pal/tests/palsuite/miscellaneous/CharNextExA/test1/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/CharNextExA/test1/CMakeLists.txt deleted file mode 100644 index 959a661b7..000000000 --- a/src/pal/tests/palsuite/miscellaneous/CharNextExA/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test.cpp -) - -add_executable(paltest_charnextexa_test1 - ${SOURCES} -) - -add_dependencies(paltest_charnextexa_test1 coreclrpal) - -target_link_libraries(paltest_charnextexa_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/miscellaneous/CharNextExA/test1/test.cpp b/src/pal/tests/palsuite/miscellaneous/CharNextExA/test1/test.cpp deleted file mode 100644 index 9671ca86b..000000000 --- a/src/pal/tests/palsuite/miscellaneous/CharNextExA/test1/test.cpp +++ /dev/null @@ -1,63 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source: test.c -** -** Purpose: Test for CharNextExA function -** -** -**=========================================================*/ - -/* - This test is FINISHED. This function is the same as CharNextA it seems, - since the only fields that differ are always 0. -*/ - -#include - -int __cdecl main(int argc, char *argv[]) -{ - - char * AnExampleString = "this is the string"; - char * StringPointer = AnExampleString; - int count = 0; - - /* - * Initialize the PAL and return FAILURE if this fails - */ - - if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - /* Use CharNext to move through an entire string. Ensure the pointer - * that is returned points to the correct character, by comparing it with - * 'stringPointer' which isn't touched by CharNext. - */ - - while(*AnExampleString != 0) - { - /* Fail if any characters are different. This is comparing the - * addresses of both characters, not the characters themselves. - */ - - if(AnExampleString != &StringPointer[count]) - { - Fail("ERROR: %#x and %#x are different. These should be the " - "same address.\n",AnExampleString,&StringPointer[count]); - } - - AnExampleString = CharNextExA(0,AnExampleString,0); - ++count; - } - - PAL_Terminate(); - return PASS; -} - - - diff --git a/src/pal/tests/palsuite/miscellaneous/CharNextExA/test1/testinfo.dat b/src/pal/tests/palsuite/miscellaneous/CharNextExA/test1/testinfo.dat deleted file mode 100644 index ea36fa61e..000000000 --- a/src/pal/tests/palsuite/miscellaneous/CharNextExA/test1/testinfo.dat +++ /dev/null @@ -1,16 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Miscellaneous -Function = CharNextA -Name = Positive Test for CharNextExA -TYPE = DEFAULT -EXE1 = test -Description -= Test to see if CharNextExA works properly -= when calling it repeatedly on a single string. - - - diff --git a/src/pal/tests/palsuite/miscellaneous/CharNextExA/test2/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/CharNextExA/test2/CMakeLists.txt deleted file mode 100644 index 7c0427127..000000000 --- a/src/pal/tests/palsuite/miscellaneous/CharNextExA/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test.cpp -) - -add_executable(paltest_charnextexa_test2 - ${SOURCES} -) - -add_dependencies(paltest_charnextexa_test2 coreclrpal) - -target_link_libraries(paltest_charnextexa_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/miscellaneous/CharNextExA/test2/test.cpp b/src/pal/tests/palsuite/miscellaneous/CharNextExA/test2/test.cpp deleted file mode 100644 index ffc153f5e..000000000 --- a/src/pal/tests/palsuite/miscellaneous/CharNextExA/test2/test.cpp +++ /dev/null @@ -1,66 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source: test.c -** -** Purpose: Test for CharNextExA, ensures it returns an LPTSTR -** -** -**=========================================================*/ - -/* Depends on strcmp() */ - -#include - -void testString(LPSTR input, LPSTR expected) -{ - - LPTSTR pReturned = NULL; - - pReturned = CharNextExA(0,input,0); - - /* Compare the Returned String to what it should be */ - if(strcmp(expected,pReturned) != 0) - { - Fail("ERROR: CharNextExA Failed: [%s] and [%s] are not equal, " - "they should be after calling CharNextExA.\n", - pReturned,expected); - } - - -} - -int __cdecl main(int argc, char *argv[]) -{ - - /* - * Initialize the PAL and return FAILURE if this fails - */ - - if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - /* test several Strings */ - testString("this is the string", "his is the string"); - testString("t", ""); - testString("", ""); - testString("a\t", "\t"); - testString("a\a", "\a"); - testString("a\b", "\b"); - testString("a\"", "\""); - testString("a\\", "\\"); - testString("\\", ""); - testString("\f", ""); - testString("\bx", "x"); - - PAL_Terminate(); - return PASS; -} - - - diff --git a/src/pal/tests/palsuite/miscellaneous/CharNextExA/test2/testinfo.dat b/src/pal/tests/palsuite/miscellaneous/CharNextExA/test2/testinfo.dat deleted file mode 100644 index adc110769..000000000 --- a/src/pal/tests/palsuite/miscellaneous/CharNextExA/test2/testinfo.dat +++ /dev/null @@ -1,15 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Miscellaneous -Function = CharNextExA -Name = Return Value test for CharNextExA -TYPE = DEFAULT -EXE1 = test -Description -= Test to ensure it returns an LPTSTR when called on a string - - - diff --git a/src/pal/tests/palsuite/miscellaneous/CloseHandle/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/CloseHandle/CMakeLists.txt deleted file mode 100644 index ef14ea535..000000000 --- a/src/pal/tests/palsuite/miscellaneous/CloseHandle/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) - diff --git a/src/pal/tests/palsuite/miscellaneous/CloseHandle/test1/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/CloseHandle/test1/CMakeLists.txt deleted file mode 100644 index f35d6fb10..000000000 --- a/src/pal/tests/palsuite/miscellaneous/CloseHandle/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test.cpp -) - -add_executable(paltest_closehandle_test1 - ${SOURCES} -) - -add_dependencies(paltest_closehandle_test1 coreclrpal) - -target_link_libraries(paltest_closehandle_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/miscellaneous/CloseHandle/test1/test.cpp b/src/pal/tests/palsuite/miscellaneous/CloseHandle/test1/test.cpp deleted file mode 100644 index 443f89bac..000000000 --- a/src/pal/tests/palsuite/miscellaneous/CloseHandle/test1/test.cpp +++ /dev/null @@ -1,64 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source: test.c -** -** Purpose: Test for CloseHandle function -** -** -**=========================================================*/ - -/* Depends on: CreateFile and WriteFile */ - -#include - -int __cdecl main(int argc, char *argv[]) -{ - - HANDLE FileHandle = NULL; - LPDWORD WriteBuffer; /* Used with WriteFile */ - - /* - * Initialize the PAL and return FAILURE if this fails - */ - - if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - WriteBuffer = (LPDWORD)malloc(sizeof(WORD)); - - if ( WriteBuffer == NULL ) - { - Fail("ERROR: Failed to allocate memory for WriteBuffer pointer. " - "Can't properly exec test case without this.\n"); - } - - - /* Create a file, since this returns to us a HANDLE we can use */ - FileHandle = CreateFile("testfile", - GENERIC_READ | GENERIC_WRITE,0,NULL,CREATE_ALWAYS, - FILE_ATTRIBUTE_NORMAL, - NULL); - - /* Should be able to close this handle */ - if(CloseHandle(FileHandle) == 0) - { - free(WriteBuffer); - Fail("ERROR: (Test 1) Attempted to close a HANDLE on a file, but the " - "return value was <=0, indicating failure.\n"); - } - - free(WriteBuffer); - - PAL_Terminate(); - return PASS; -} - - - - diff --git a/src/pal/tests/palsuite/miscellaneous/CloseHandle/test1/testinfo.dat b/src/pal/tests/palsuite/miscellaneous/CloseHandle/test1/testinfo.dat deleted file mode 100644 index 891e1dfcf..000000000 --- a/src/pal/tests/palsuite/miscellaneous/CloseHandle/test1/testinfo.dat +++ /dev/null @@ -1,15 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Miscellaneous -Function = CloseHandle -Name = Positive Test for CloseHandle -TYPE = DEFAULT -EXE1 = test -Description -= Open a file to get a handle, and then close the file using CloseHandle - - - diff --git a/src/pal/tests/palsuite/miscellaneous/CloseHandle/test2/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/CloseHandle/test2/CMakeLists.txt deleted file mode 100644 index 691d44b82..000000000 --- a/src/pal/tests/palsuite/miscellaneous/CloseHandle/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test.cpp -) - -add_executable(paltest_closehandle_test2 - ${SOURCES} -) - -add_dependencies(paltest_closehandle_test2 coreclrpal) - -target_link_libraries(paltest_closehandle_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/miscellaneous/CloseHandle/test2/test.cpp b/src/pal/tests/palsuite/miscellaneous/CloseHandle/test2/test.cpp deleted file mode 100644 index c1eea4407..000000000 --- a/src/pal/tests/palsuite/miscellaneous/CloseHandle/test2/test.cpp +++ /dev/null @@ -1,46 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source: test.c -** -** Purpose: Test for CloseHandle function, try to close an unopened HANDLE -** -** -**=========================================================*/ - -#include - -int __cdecl main(int argc, char *argv[]) -{ - - HANDLE SomeHandle = NULL; - - /* - * Initialize the PAL and return FAILURE if this fails - */ - - if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - /* If the handle is already closed and you can close it again, - * something is wrong. - */ - - if(CloseHandle(SomeHandle) != 0) - { - Fail("ERROR: Called CloseHandle on an already closed Handle " - "and it still returned as a success.\n"); - } - - - PAL_Terminate(); - return PASS; -} - - - diff --git a/src/pal/tests/palsuite/miscellaneous/CloseHandle/test2/testinfo.dat b/src/pal/tests/palsuite/miscellaneous/CloseHandle/test2/testinfo.dat deleted file mode 100644 index 6917e8586..000000000 --- a/src/pal/tests/palsuite/miscellaneous/CloseHandle/test2/testinfo.dat +++ /dev/null @@ -1,15 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Miscellaneous -Function = CloseHandle -Name = Positive Test for CloseHandle -TYPE = DEFAULT -EXE1 = test -Description -= Attempt to close an unintialized HANDLE, should be unable to do this. - - - diff --git a/src/pal/tests/palsuite/miscellaneous/CreatePipe/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/CreatePipe/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/miscellaneous/CreatePipe/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/miscellaneous/CreatePipe/test1/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/CreatePipe/test1/CMakeLists.txt deleted file mode 100644 index 494c948ab..000000000 --- a/src/pal/tests/palsuite/miscellaneous/CreatePipe/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_createpipe_test1 - ${SOURCES} -) - -add_dependencies(paltest_createpipe_test1 coreclrpal) - -target_link_libraries(paltest_createpipe_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/miscellaneous/CreatePipe/test1/test1.cpp b/src/pal/tests/palsuite/miscellaneous/CreatePipe/test1/test1.cpp deleted file mode 100644 index 3930183b6..000000000 --- a/src/pal/tests/palsuite/miscellaneous/CreatePipe/test1/test1.cpp +++ /dev/null @@ -1,113 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test1.c (CreatePipe) -** -** Purpose: Tests the PAL implementation of the CreatePipe function. -** This test will create two pipes, a read and a write. Once -** the pipes have been created, they will be tested by writing -** and then reading, then comparing the results. -** -** Depends: WriteFile -** ReadFile -** memcmp -** CloseHandle -** -** -**===================================================================*/ - -#include - -const char* cTestString = "one fish, two fish, red fish, blue fish."; - -int __cdecl main(int argc, char **argv) -{ - HANDLE hReadPipe = NULL; - HANDLE hWritePipe = NULL; - BOOL bRetVal = FALSE; - DWORD dwBytesWritten; - DWORD dwBytesRead; - char buffer[256]; - - SECURITY_ATTRIBUTES lpPipeAttributes; - - /*Initialize the PAL*/ - if ((PAL_Initialize(argc, argv)) != 0) - { - return (FAIL); - } - - /*Setup SECURITY_ATTRIBUTES structure for CreatePipe*/ - lpPipeAttributes.nLength = sizeof(lpPipeAttributes); - lpPipeAttributes.lpSecurityDescriptor = NULL; - lpPipeAttributes.bInheritHandle = TRUE; - - /*Create a Pipe*/ - bRetVal = CreatePipe(&hReadPipe, /* read handle*/ - &hWritePipe, /* write handle */ - &lpPipeAttributes, /* security attributes*/ - 0); /* pipe size*/ - if (bRetVal == FALSE) - { - Fail("ERROR: %ld :Unable to create pipe\n", GetLastError()); - } - - /*Write to the write pipe handle*/ - bRetVal = WriteFile(hWritePipe, /* handle to write pipe*/ - cTestString, /* buffer to write*/ - strlen(cTestString),/* number of bytes to write*/ - &dwBytesWritten, /* number of bytes written*/ - NULL); /* overlapped buffer*/ - if (bRetVal == FALSE) - { - Fail("ERROR: %ld :unable to write to write pipe handle " - "hWritePipe=0x%lx\n", GetLastError(), hWritePipe); - } - - /*Read, 256 bytes, more bytes then actually written. - This will give allow us to use the value that ReadFile - returns for comparision.*/ - bRetVal = ReadFile(hReadPipe, /* handle to read pipe*/ - buffer, /* buffer to write to*/ - 256, /* number of bytes to read*/ - &dwBytesRead, /* number of bytes read*/ - NULL); /* overlapped buffer*/ - if (bRetVal == FALSE) - { - Fail("ERROR: %ld : unable read hWritePipe=0x%lx\n", - GetLastError(), hWritePipe); - } - - /*Compare what was read with what was written.*/ - if ((memcmp(cTestString, buffer, dwBytesRead)) != 0) - { - Fail("ERROR: read \"%s\" expected \"%s\" \n", buffer, cTestString); - } - - /*Compare values returned from WriteFile and ReadFile.*/ - if (dwBytesWritten != dwBytesRead) - { - Fail("ERROR: WriteFile wrote \"%d\", but ReadFile read \"%d\"," - " these should be the same\n", buffer, cTestString); - } - - /*Close write pipe handle*/ - if (CloseHandle(hWritePipe) == 0) - { - Fail("ERROR: %ld : Unable to close write pipe handle " - "hWritePipe=0x%lx\n",GetLastError(), hWritePipe); - } - - /*Close Read pipe handle*/ - if (CloseHandle(hReadPipe) == 0) - { - Fail("ERROR: %ld : Unable to close read pipe handle " - "hReadPipe=0x%lx\n", GetLastError(), hReadPipe); - } - - PAL_Terminate(); - return (PASS); -} diff --git a/src/pal/tests/palsuite/miscellaneous/CreatePipe/test1/testinfo.dat b/src/pal/tests/palsuite/miscellaneous/CreatePipe/test1/testinfo.dat deleted file mode 100644 index b9422b062..000000000 --- a/src/pal/tests/palsuite/miscellaneous/CreatePipe/test1/testinfo.dat +++ /dev/null @@ -1,15 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Miscellaneous -Function = CreatePipe -Name = Test for CreatePipe -TYPE = DEFAULT -EXE1 = test1 -Description -= Tests the PAL implementation of the CreatePipe function. -= This test will create two pipes, a read and a write. Once -= the pipes have been created, they will be tested by writing -= and then reading, then comparing the results. diff --git a/src/pal/tests/palsuite/miscellaneous/FlushInstructionCache/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/FlushInstructionCache/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/miscellaneous/FlushInstructionCache/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/miscellaneous/FlushInstructionCache/test1/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/FlushInstructionCache/test1/CMakeLists.txt deleted file mode 100644 index 57b925c8a..000000000 --- a/src/pal/tests/palsuite/miscellaneous/FlushInstructionCache/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_flushinstructioncache_test1 - ${SOURCES} -) - -add_dependencies(paltest_flushinstructioncache_test1 coreclrpal) - -target_link_libraries(paltest_flushinstructioncache_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/miscellaneous/FlushInstructionCache/test1/test1.cpp b/src/pal/tests/palsuite/miscellaneous/FlushInstructionCache/test1/test1.cpp deleted file mode 100644 index cdbefd01c..000000000 --- a/src/pal/tests/palsuite/miscellaneous/FlushInstructionCache/test1/test1.cpp +++ /dev/null @@ -1,66 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source: test1.c -** -** Purpose: Tests that FlushInstructionCache returns the correct value for a -** number of different inputs. -** -** -** Note : -** For this function, what constitutes "invalid parameters" will depend entirely -** on the platform; because of this we can't simply test values on Windows and -** then ask for the same results everywhere. Because of this, this test can -** ensure that the function succeeds for some "obviously" valid values, but -** can't make sure that it fails for invalid values. -** -**=========================================================*/ - -#include - -void DoTest(void *Buffer, int Size, int Expected) -{ - int ret; - - SetLastError(0); - ret = FlushInstructionCache(GetCurrentProcess(), Buffer, Size); - if (!ret && Expected) - { - Fail("Expected FlushInstructionCache to return non-zero, got zero!\n" - "region: %p, size: %d, GetLastError: %d\n", Buffer, Size, - GetLastError()); - } - else if (ret && !Expected) - { - Fail("Expected FlushInstructionCache to return zero, got non-zero!\n" - "region: %p, size: %d, GetLastError: %d\n", Buffer, Size, - GetLastError()); - } - - if (!Expected && ERROR_NOACCESS != GetLastError()) - { - Fail("FlushInstructionCache failed to set the last error to " - "ERROR_NOACCESS!\n"); - } - -} - -int __cdecl main(int argc,char *argv[]) -{ - char ValidPtr[256]; - - if(PAL_Initialize(argc, argv)) - { - return FAIL; - } - - /* with valid pointer, zero-size and valid size must succeed */ - DoTest(ValidPtr, 0, 1); - DoTest(ValidPtr, 42, 1); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/miscellaneous/FlushInstructionCache/test1/testinfo.dat b/src/pal/tests/palsuite/miscellaneous/FlushInstructionCache/test1/testinfo.dat deleted file mode 100644 index 78ab5f77f..000000000 --- a/src/pal/tests/palsuite/miscellaneous/FlushInstructionCache/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Miscellaneous -Function = FlushInstructionCache -Name = Positive Test #1 for FlushInstructionCache -TYPE = DEFAULT -EXE1 = test1 -Description -=Tests that FlushInstructionCache returns the correct value for a -=number of different inputs. diff --git a/src/pal/tests/palsuite/miscellaneous/FormatMessageW/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/FormatMessageW/CMakeLists.txt deleted file mode 100644 index 7c2017935..000000000 --- a/src/pal/tests/palsuite/miscellaneous/FormatMessageW/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) -add_subdirectory(test3) -add_subdirectory(test4) -add_subdirectory(test5) -add_subdirectory(test6) - diff --git a/src/pal/tests/palsuite/miscellaneous/FormatMessageW/test1/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/FormatMessageW/test1/CMakeLists.txt deleted file mode 100644 index f0e366ec8..000000000 --- a/src/pal/tests/palsuite/miscellaneous/FormatMessageW/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test.cpp -) - -add_executable(paltest_formatmessagew_test1 - ${SOURCES} -) - -add_dependencies(paltest_formatmessagew_test1 coreclrpal) - -target_link_libraries(paltest_formatmessagew_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/miscellaneous/FormatMessageW/test1/test.cpp b/src/pal/tests/palsuite/miscellaneous/FormatMessageW/test1/test.cpp deleted file mode 100644 index 0cc4c4343..000000000 --- a/src/pal/tests/palsuite/miscellaneous/FormatMessageW/test1/test.cpp +++ /dev/null @@ -1,63 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source : test.c -** -** Purpose: Test for FormatMessageW() function -** -** -**=========================================================*/ - -#define UNICODE -#include - - -int __cdecl main(int argc, char *argv[]) { - - WCHAR TheString[] = {'P','a','l',' ','T','e','s','t','\0'}; - WCHAR OutBuffer[128]; - int ReturnResult; - - /* - * Initialize the PAL and return FAILURE if this fails - */ - - if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - - ReturnResult = FormatMessage( - FORMAT_MESSAGE_FROM_STRING, /* source and processing options */ - TheString, /* message source */ - 0, /* message identifier */ - 0, /* language identifier */ - OutBuffer, /* message buffer */ - 1024, /* maximum size of message buffer */ - NULL /* array of message inserts */ - ); - - - if(ReturnResult == 0) - { - Fail("ERROR: The return value was 0, which indicates failure. " - "The function failed when trying to Format a simple string" - ", with no formatters in it."); - } - - if(memcmp(OutBuffer,TheString,wcslen(OutBuffer)*2+2) != 0) - { - Fail("ERROR: The formatted string should be %s but is really %s.", - convertC(TheString), - convertC(OutBuffer)); - } - - PAL_Terminate(); - return PASS; -} - - diff --git a/src/pal/tests/palsuite/miscellaneous/FormatMessageW/test1/testinfo.dat b/src/pal/tests/palsuite/miscellaneous/FormatMessageW/test1/testinfo.dat deleted file mode 100644 index 5bd46bf60..000000000 --- a/src/pal/tests/palsuite/miscellaneous/FormatMessageW/test1/testinfo.dat +++ /dev/null @@ -1,16 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Miscellaneous -Function = FormatMessageW -Name = Positive test of FormatMessageW -TYPE = DEFAULT -EXE1 = test -Description -= Test a very simple case -- basically just copy a string into a buffer, -= no formatting. - - - diff --git a/src/pal/tests/palsuite/miscellaneous/FormatMessageW/test2/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/FormatMessageW/test2/CMakeLists.txt deleted file mode 100644 index 564830acd..000000000 --- a/src/pal/tests/palsuite/miscellaneous/FormatMessageW/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test.cpp -) - -add_executable(paltest_formatmessagew_test2 - ${SOURCES} -) - -add_dependencies(paltest_formatmessagew_test2 coreclrpal) - -target_link_libraries(paltest_formatmessagew_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/miscellaneous/FormatMessageW/test2/test.cpp b/src/pal/tests/palsuite/miscellaneous/FormatMessageW/test2/test.cpp deleted file mode 100644 index d45dc92f0..000000000 --- a/src/pal/tests/palsuite/miscellaneous/FormatMessageW/test2/test.cpp +++ /dev/null @@ -1,581 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source : test.c -** -** Purpose: Test for FormatMessageW() function -** -** -**=========================================================*/ - -#define UNICODE -#include - -WCHAR OutBuffer[1024]; - -/* Pass this test the string "INSERT" and it will succeed */ - -int test1(int num, ...) -{ - - WCHAR * TheString = convert("Pal %1!s! Testing"); - int ReturnResult; - va_list TheList; - va_start(TheList,num); - memset( OutBuffer, 0, 1024 ); - - ReturnResult = FormatMessage( - FORMAT_MESSAGE_FROM_STRING, /* source and processing options */ - TheString, /* message source */ - 0, /* message identifier */ - 0, /* language identifier */ - OutBuffer, /* message buffer */ - 1024, /* maximum size of message buffer */ - &TheList /* array of message inserts */ - ); - - va_end(TheList); - - if(ReturnResult == 0) - { - Fail("ERROR: The return value was 0, which indicates failure. " - "The function failed when trying to Format a simple string," - " with the 's' formatter."); - - } - - if(memcmp(OutBuffer, convert("Pal INSERT Testing"), - wcslen(OutBuffer)*2+2) != 0) - { - Fail("ERROR: The formated string should have been 'Pal INSERT " - "Testing' but '%s' was returned.", - convertC(OutBuffer)); - } - - - return PASS; -} - -/* Pass this test the int 40 and it will succeed */ - -int test2(int num, ...) -{ - - WCHAR * TheString = convert("Pal %1!i! Testing"); - int ReturnResult; - va_list TheList; - va_start(TheList,num); - - memset( OutBuffer, 0, 1024 ); - - ReturnResult = FormatMessage( - FORMAT_MESSAGE_FROM_STRING, /* source and processing options */ - TheString, /* message source */ - 0, /* message identifier */ - 0, /* language identifier */ - OutBuffer, /* message buffer */ - 1024, /* maximum size of message buffer */ - &TheList /* array of message inserts */ - ); - - va_end(TheList); - - if(ReturnResult == 0) - { - Fail("ERROR: The return value was 0, which indicates failure. " - "The function failed when trying to Format a simple string," - " with the 'i' formatter."); - } - - if(memcmp(OutBuffer, convert("Pal 40 Testing"),wcslen(OutBuffer)*2+2) != 0) - { - Fail("ERROR: The formated string should have been 'Pal 40 Testing' " - "but '%s' was returned.", convertC(OutBuffer)); - } - return PASS; -} - -/* Pass this test the character 'a' and it will succeed */ - -int test3(int num, ...) { - - WCHAR * TheString = convert("Pal %1!c! Testing"); - int ReturnResult; - va_list TheList; - va_start(TheList,num); - memset( OutBuffer, 0, 1024 ); - ReturnResult = FormatMessage( - FORMAT_MESSAGE_FROM_STRING, /* source and processing options */ - TheString, /* message source */ - 0, /* message identifier */ - 0, /* language identifier */ - OutBuffer, /* message buffer */ - 1024, /* maximum size of message buffer */ - &TheList /* array of message inserts */ - ); - - va_end(TheList); - - if(ReturnResult == 0) - { - Fail("ERROR: The return value was 0, which indicates failure. " - "The function failed when trying to Format a simple string," - " with the 'c' formatter."); - } - - if(memcmp(OutBuffer, convert("Pal a Testing"),wcslen(OutBuffer)*2+2) != 0) - { - Fail("ERROR: The formated string should have been 'Pal a Testing' " - "but '%s' was returned.", convertC(OutBuffer)); - - } - - return PASS; -} - -/* Pass this test the character 'a' and it will succeed */ - -int test4(int num, ...) { - - WCHAR * TheString = convert("Pal %1!C! Testing"); - int ReturnResult; - va_list TheList; - va_start(TheList,num); - memset( OutBuffer, 0, 1024 ); - ReturnResult = FormatMessage( - FORMAT_MESSAGE_FROM_STRING, /* source and processing options */ - TheString, /* message source */ - 0, /* message identifier */ - 0, /* language identifier */ - OutBuffer, /* message buffer */ - 1024, /* maximum size of message buffer */ - &TheList /* array of message inserts */ - ); - - va_end(TheList); - - if(ReturnResult == 0) - { - Fail("ERROR: The return value was 0, which indicates failure. " - "The function failed when trying to Format a simple string," - " with the 'C' formatter."); - } - - if(memcmp(OutBuffer, convert("Pal a Testing"),wcslen(OutBuffer)*2+2) != 0) - { - Fail("ERROR: The formated string should have been 'Pal a Testing' " - "but '%s' was returned.",convertC(OutBuffer)); - } - - return PASS; -} - -/* Pass this test the number 57 and it will succeed */ - -int test5(int num, ...) -{ - - WCHAR * TheString = convert("Pal %1!d! Testing"); - int ReturnResult; - va_list TheList; - va_start(TheList,num); - memset( OutBuffer, 0, 1024 ); - - ReturnResult = FormatMessage( - FORMAT_MESSAGE_FROM_STRING, /* source and processing options */ - TheString, /* message source */ - 0, /* message identifier */ - 0, /* language identifier */ - OutBuffer, /* message buffer */ - 1024, /* maximum size of message buffer */ - &TheList /* array of message inserts */ - ); - - va_end(TheList); - - if(ReturnResult == 0) - { - Fail("ERROR: The return value was 0, which indicates failure. " - "The function failed when trying to Format a simple string, " - "with the 'd' formatter."); - - } - - if(memcmp(OutBuffer, convert("Pal 57 Testing"),wcslen(OutBuffer)*2+2) != 0) - { - Fail("ERROR: The formated string should have been 'Pal 57 Testing' " - "but '%s' was returned.",convertC(OutBuffer)); - - } - - return PASS; -} - -/* Pass this test the characters 'a' and 'b' and it will succeed. */ - -int test6(int num, ...) { - - WCHAR * TheString = convert("Pal %1!hc! and %2!hC! Testing"); - int ReturnResult; - va_list TheList; - va_start(TheList,num); - memset( OutBuffer, 0, 1024 ); - - ReturnResult = FormatMessage( - FORMAT_MESSAGE_FROM_STRING, /* source and processing options */ - TheString, /* message source */ - 0, /* message identifier */ - 0, /* language identifier */ - OutBuffer, /* message buffer */ - 1024, /* maximum size of message buffer */ - &TheList /* array of message inserts */ - ); - - va_end(TheList); - - if(ReturnResult == 0) - { - Fail("ERROR: The return value was 0, which indicates failure. " - "The function failed when trying to Format a simple string, " - "with the 'hc' and 'hC' formatters."); - - } - - if(memcmp(OutBuffer, convert("Pal a and b Testing"), - wcslen(OutBuffer)*2+2) != 0) - { - Fail("ERROR: The formated string should have been 'Pal a and b " - "Testing' but '%s' was returned.", convertC(OutBuffer)); - - } - - return PASS; -} - -/* Pass this test 90, the string 'foo' and the string 'bar' to succeed */ - -int test7(int num, ...) -{ - - WCHAR * TheString = convert("Pal %1!hd! and %2!hs! and %3!hS! Testing"); - int ReturnResult; - va_list TheList; - va_start(TheList,num); - memset( OutBuffer, 0, 1024 ); - - ReturnResult = FormatMessage( - FORMAT_MESSAGE_FROM_STRING, /* source and processing options */ - TheString, /* message source */ - 0, /* message identifier */ - 0, /* language identifier */ - OutBuffer, /* message buffer */ - 1024, /* maximum size of message buffer */ - &TheList /* array of message inserts */ - ); - - va_end(TheList); - - if(ReturnResult == 0) - { - Fail("ERROR: The return value was 0, which indicates failure. " - "The function failed when trying to Format a simple string, " - "with the 'hd', 'hs' and 'hS' formatters."); - - } - - if(memcmp(OutBuffer, - convert("Pal 90 and foo and bar Testing"), - wcslen(OutBuffer)*2+2) != 0) - { - Fail("ERROR: The formated string should have been 'Pal 90 and foo " - "and bar Testing' but '%s' was returned.",convertC(OutBuffer)); - } - - return PASS; -} - -/* Pass this test the characters 'a', 'b' and the numbers 50 and 100 */ - -int test8(int num, ...) -{ - - WCHAR * TheString = - convert("Pal %1!lc! and %2!lC! and %3!ld! and %4!li! Testing"); - int ReturnResult; - va_list TheList; - va_start(TheList,num); - memset( OutBuffer, 0, 1024 ); - - ReturnResult = FormatMessage( - FORMAT_MESSAGE_FROM_STRING, /* source and processing options */ - TheString, /* message source */ - 0, /* message identifier */ - 0, /* language identifier */ - OutBuffer, /* message buffer */ - 1024, /* maximum size of message buffer */ - &TheList /* array of message inserts */ - ); - - va_end(TheList); - - if(ReturnResult == 0) - { - Fail("ERROR: The return value was 0, which indicates failure. " - "The function failed when trying to Format a simple string, " - "with the 'lc', 'lC', 'ld' and 'li' formatters."); - - } - - if(memcmp(OutBuffer, - convert("Pal a and b and 50 and 100 Testing"), - wcslen(OutBuffer)*2+2) != 0) - { - Fail("ERROR: The formated string should have been 'Pal a and b and 50" - " and 100 Testing' but '%s' was returned.",convertC(OutBuffer)); - - } - - return PASS; -} - -/* Pass this test the wide string 'foo' and 'bar' and the unsigned - int 56 to pass -*/ - -int test9(int num, ...) { - - WCHAR * TheString = convert("Pal %1!ls! and %2!ls! and %3!lu! Testing"); - int ReturnResult; - va_list TheList; - va_start(TheList,num); - memset( OutBuffer, 0, 1024 ); - ReturnResult = FormatMessage( - FORMAT_MESSAGE_FROM_STRING, /* source and processing options */ - TheString, /* message source */ - 0, /* message identifier */ - 0, /* language identifier */ - OutBuffer, /* message buffer */ - 1024, /* maximum size of message buffer */ - &TheList /* array of message inserts */ - ); - - va_end(TheList); - - if(ReturnResult == 0) - { - Fail("ERROR: The return value was 0, which indicates failure. " - "The function failed when trying to Format a simple string," - " with the 'ls', 'lS' and 'lu' formatters."); - - } - - if(memcmp(OutBuffer, - convert("Pal foo and bar and 56 Testing"), - wcslen(OutBuffer)*2+2) != 0) - { - Fail("ERROR: The formated string should have been 'Pal foo and bar " - "and 56 Testing' but '%s' was returned.",convertC(OutBuffer)); - - } - - return PASS; -} - -/* Pass this test the hex values 0x123ab and 0x123cd */ - -int test10(int num, ...) -{ - - WCHAR * TheString = convert("Pal %1!lx! and %2!lX! Testing"); - int ReturnResult; - va_list TheList; - va_start(TheList,num); - memset( OutBuffer, 0, 1024 ); - ReturnResult = FormatMessage( - FORMAT_MESSAGE_FROM_STRING, /* source and processing options */ - TheString, /* message source */ - 0, /* message identifier */ - 0, /* language identifier */ - OutBuffer, /* message buffer */ - 1024, /* maximum size of message buffer */ - &TheList /* array of message inserts */ - ); - - va_end(TheList); - - if(ReturnResult == 0) - { - Fail("ERROR: The return value was 0, which indicates failure. " - "The function failed when trying to Format a simple string, " - "with the 'lx' and 'lX' formatters."); - - } - - if(memcmp(OutBuffer, - convert("Pal 123ab and 123CD Testing"), - wcslen(OutBuffer)*2+2) != 0) - { - Fail("ERROR: The formated string should have been 'Pal 123ab and " - "123CD Testing' but '%s' was returned.", convertC(OutBuffer)); - - } - - return PASS; -} - -/* Pass this test a pointer to 0x123ab and the string 'foo' to pass */ - -int test11(int num, ...) -{ - - WCHAR * TheString = convert("Pal %1!p! and %2!S! Testing"); - int ReturnResult; - va_list TheList; - va_start(TheList,num); - memset( OutBuffer, 0, 1024 ); - - ReturnResult = FormatMessage( - FORMAT_MESSAGE_FROM_STRING, /* source and processing options */ - TheString, /* message source */ - 0, /* message identifier */ - 0, /* language identifier */ - OutBuffer, /* message buffer */ - 1024, /* maximum size of message buffer */ - &TheList /* array of message inserts */ - ); - - va_end(TheList); - - if(ReturnResult == 0) - { - Fail("ERROR: The return value was 0, which indicates failure. " - "The function failed when trying to Format a simple string, " - "with the 'p' and 'S' formatters."); - - } - -/* -** Run only on 64 bit platforms -*/ -#if defined(BIT64) - Trace("Testing for 64 Bit Platforms \n"); - if(memcmp(OutBuffer, - convert("Pal 00000000000123AB and foo Testing"), - wcslen(OutBuffer)*2+2) != 0 && - /* BSD style */ - memcmp( OutBuffer, - convert( "Pal 0x123ab and foo Testing" ), - wcslen(OutBuffer)*2+2 ) != 0 ) - { - Fail("ERROR: The formated string should have been 'Pal 000123AB and " - "foo Testing' but '%s' was returned.",convertC(OutBuffer)); - - } - -#else - Trace("Testing for Non 64 Bit Platforms \n"); - if(memcmp(OutBuffer, - convert("Pal 000123AB and foo Testing"), - wcslen(OutBuffer)*2+2) != 0 && - /* BSD style */ - memcmp( OutBuffer, - convert( "Pal 0x123ab and foo Testing" ), - wcslen(OutBuffer)*2+2 ) != 0 ) - { - Fail("ERROR: The formated string should have been 'Pal 000123AB and " - "foo Testing' but '%s' was returned.",convertC(OutBuffer)); - - } - -#endif - - return PASS; -} - -/* Pass this test the unsigned int 100 and the hex values 0x123ab and 0x123cd -to succeed */ - -int test12(int num, ...) -{ - - WCHAR * TheString = convert("Pal %1!u! and %2!x! and %3!X! Testing"); - int ReturnResult; - va_list TheList; - va_start(TheList,num); - memset( OutBuffer, 0, 1024 ); - - ReturnResult = FormatMessage( - FORMAT_MESSAGE_FROM_STRING, /* source and processing options */ - TheString, /* message source */ - 0, /* message identifier */ - 0, /* language identifier */ - OutBuffer, /* message buffer */ - 1024, /* maximum size of message buffer */ - &TheList /* array of message inserts */ - ); - - va_end(TheList); - - if(ReturnResult == 0) - { - Fail("ERROR: The return value was 0, which indicates failure. " - "The function failed when trying to Format a simple string, " - "with the 'u', 'x' and 'X' formatters."); - - } - - if(memcmp(OutBuffer, - convert("Pal 100 and 123ab and 123CD Testing"), - wcslen(OutBuffer)*2+2) != 0) - { - Fail("ERROR: The formated string should have been 'Pal 100 and " - "123ab and 123CD Testing' but '%s' was returned.", - convertC(OutBuffer)); - - } - - return PASS; -} - -int __cdecl main(int argc, char *argv[]) -{ - WCHAR szwInsert[] = {'I','N','S','E','R','T','\0'}; - WCHAR szwFoo[] = {'f','o','o','\0'}; - WCHAR szwBar[] = {'b','a','r','\0'}; - - /* - * Initialize the PAL and return FAILURE if this fails - */ - - if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - if(test1(0,szwInsert) || /* Test %s */ - test2(0,40) || /* Test %i */ - test3(0,'a') || /* Test %c */ - test4(0,'a') || /* Test %C */ - test5(0,57) || /* Test %d */ - test6(0,'a','b') || /* Test %hc, %hC */ - test7(0,90,"foo","bar") || /* Test %hd,hs,hS */ - test8(0,'a','b',50,100) || /* Test %lc, lC, ld, li */ - test9(0,szwFoo,szwBar,56) || /* Test %ls,lS,lu */ - test10(0,0x123ab,0x123cd) || /* Test %lx, %lX */ - test11(0,(void *)0x123ab,"foo") || /* Test %p, %S */ - test12(0,100,0x123ab,0x123cd)) /* Test %u,x,X */ - { - - - } - - PAL_Terminate(); - return PASS; - -} - - - diff --git a/src/pal/tests/palsuite/miscellaneous/FormatMessageW/test2/testinfo.dat b/src/pal/tests/palsuite/miscellaneous/FormatMessageW/test2/testinfo.dat deleted file mode 100644 index 5e4a35428..000000000 --- a/src/pal/tests/palsuite/miscellaneous/FormatMessageW/test2/testinfo.dat +++ /dev/null @@ -1,15 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Miscellaneous -Function = FormatMessageW -Name = Positive test of FormatMessageW -TYPE = DEFAULT -EXE1 = test -Description -= A collection of tests to check and make sure all the standard formatters work. - - - diff --git a/src/pal/tests/palsuite/miscellaneous/FormatMessageW/test3/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/FormatMessageW/test3/CMakeLists.txt deleted file mode 100644 index 70b039bf0..000000000 --- a/src/pal/tests/palsuite/miscellaneous/FormatMessageW/test3/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test.cpp -) - -add_executable(paltest_formatmessagew_test3 - ${SOURCES} -) - -add_dependencies(paltest_formatmessagew_test3 coreclrpal) - -target_link_libraries(paltest_formatmessagew_test3 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/miscellaneous/FormatMessageW/test3/test.cpp b/src/pal/tests/palsuite/miscellaneous/FormatMessageW/test3/test.cpp deleted file mode 100644 index a390c00fe..000000000 --- a/src/pal/tests/palsuite/miscellaneous/FormatMessageW/test3/test.cpp +++ /dev/null @@ -1,85 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source : test.c -** -** Purpose: Test for FormatMessageW() function -** -** -**=========================================================*/ - -#define UNICODE -#include - -WCHAR OutBuffer[1024]; - -int __cdecl main(int argc, char *argv[]) -{ - - WCHAR * TheString; - WCHAR * CorrectString; - int ReturnResult; - - /* - * Initialize the PAL and return FAILURE if this fails - */ - - if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - TheString = convert("Pal %1!u! %2!i! %3!s! Testing"); - - /* The resulting value in the buffer shouldn't be formatted at all, - because the inserts are being ignored. - */ - - ReturnResult = FormatMessage( - FORMAT_MESSAGE_FROM_STRING | - FORMAT_MESSAGE_IGNORE_INSERTS, /* source and processing options */ - TheString, /* message source */ - 0, /* message identifier */ - 0, /* language identifier */ - OutBuffer, /* message buffer */ - 1024, /* maximum size of message buffer */ - NULL /* array of message inserts */ - ); - - - - if(ReturnResult == 0) - { - free(TheString); - Fail("ERROR: The return value was 0, which indicates failure. " - "The function failed when trying to Format a simple string, " - "using the IGNORE_INSERTS flag.\n"); - } - - - /* Note: Since 's' is the default insert, when this function is called - with ignore inserts, it strips %3!s! down to just %3 -- as they're - equal. - */ - if(memcmp(OutBuffer, - (CorrectString = convert("Pal %1!u! %2!i! %3 Testing")), - wcslen(OutBuffer)*2+2) != 0) - { - free(TheString); - free(CorrectString); - Fail("ERROR: Since the IGNORE_INSERTS flag was set, the result " - "should have been 'Pal %%1!u! %%2!i! %%3 Testing' but was " - "really '%S'.\n",OutBuffer); - } - - free(TheString); - free(CorrectString); - PAL_Terminate(); - return PASS; - -} - - diff --git a/src/pal/tests/palsuite/miscellaneous/FormatMessageW/test3/testinfo.dat b/src/pal/tests/palsuite/miscellaneous/FormatMessageW/test3/testinfo.dat deleted file mode 100644 index cad1f6381..000000000 --- a/src/pal/tests/palsuite/miscellaneous/FormatMessageW/test3/testinfo.dat +++ /dev/null @@ -1,15 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Miscellaneous -Function = FormatMessageW -Name = Positive test of FormatMessageW -TYPE = DEFAULT -EXE1 = test -Description -= Test to ensure the IGNORE_INSERTS flag works properly. - - - diff --git a/src/pal/tests/palsuite/miscellaneous/FormatMessageW/test4/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/FormatMessageW/test4/CMakeLists.txt deleted file mode 100644 index c4ecccf7d..000000000 --- a/src/pal/tests/palsuite/miscellaneous/FormatMessageW/test4/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test.cpp -) - -add_executable(paltest_formatmessagew_test4 - ${SOURCES} -) - -add_dependencies(paltest_formatmessagew_test4 coreclrpal) - -target_link_libraries(paltest_formatmessagew_test4 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/miscellaneous/FormatMessageW/test4/test.cpp b/src/pal/tests/palsuite/miscellaneous/FormatMessageW/test4/test.cpp deleted file mode 100644 index 4f865efe7..000000000 --- a/src/pal/tests/palsuite/miscellaneous/FormatMessageW/test4/test.cpp +++ /dev/null @@ -1,77 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source : test.c -** -** Purpose: Test for FormatMessageW() function -** -** -**=========================================================*/ - -#define UNICODE -#include - -WCHAR OutBuffer[1024]; - -int __cdecl main(int argc, char *argv[]) -{ - - WCHAR * TheString; - WCHAR* TheArray[3]; - int ReturnResult; - - /* - * Initialize the PAL and return FAILURE if this fails - */ - - if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - TheString = convert("Pal %1 %2 %3 Testing"); - TheArray[0] = convert("Foo"); - TheArray[1] = convert("Bar"); - TheArray[2] = convert("FooBar"); - - /* This should just use the 3 strings in the array to replace - inserts in the given string. - */ - - ReturnResult = FormatMessage( - FORMAT_MESSAGE_FROM_STRING | - FORMAT_MESSAGE_ARGUMENT_ARRAY, /* source and processing options */ - TheString, /* message source */ - 0, /* message identifier */ - 0, /* language identifier */ - OutBuffer, /* message buffer */ - 1024, /* maximum size of message buffer */ - (va_list *) TheArray /* array of message inserts */ - ); - - if(ReturnResult == 0) - { - Fail("ERROR: The return value was 0, which indicates failure. " - "The function failed when trying to Format a simple string, " - "usin gthe ARGUMENT_ARRAY flag."); - } - - if(memcmp(OutBuffer, - convert("Pal Foo Bar FooBar Testing"), - wcslen(OutBuffer)*2+2) != 0) - { - Fail("ERROR: Since the FORMAT_MESSAGE_ARGUMENT_ARRAY flag was set, " - "the result should have been 'Pal Foo Bar FooBar Testing' but was" - " really '%s'.",convertC(OutBuffer)); - } - - - PAL_Terminate(); - return PASS; - -} - - diff --git a/src/pal/tests/palsuite/miscellaneous/FormatMessageW/test4/testinfo.dat b/src/pal/tests/palsuite/miscellaneous/FormatMessageW/test4/testinfo.dat deleted file mode 100644 index 33e0cfa82..000000000 --- a/src/pal/tests/palsuite/miscellaneous/FormatMessageW/test4/testinfo.dat +++ /dev/null @@ -1,15 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Miscellaneous -Function = FormatMessageW -Name = Positive test of FormatMessageW -TYPE = DEFAULT -EXE1 = test -Description -= Test to ensure the FORMAT_MESSAGE_ARGUMENT_ARRAY flag works properly. - - - diff --git a/src/pal/tests/palsuite/miscellaneous/FormatMessageW/test5/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/FormatMessageW/test5/CMakeLists.txt deleted file mode 100644 index 2d4e2a2c4..000000000 --- a/src/pal/tests/palsuite/miscellaneous/FormatMessageW/test5/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test.cpp -) - -add_executable(paltest_formatmessagew_test5 - ${SOURCES} -) - -add_dependencies(paltest_formatmessagew_test5 coreclrpal) - -target_link_libraries(paltest_formatmessagew_test5 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/miscellaneous/FormatMessageW/test5/test.cpp b/src/pal/tests/palsuite/miscellaneous/FormatMessageW/test5/test.cpp deleted file mode 100644 index 148c2ff23..000000000 --- a/src/pal/tests/palsuite/miscellaneous/FormatMessageW/test5/test.cpp +++ /dev/null @@ -1,76 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source : test.c -** -** Purpose: Test for FormatMessageW() function -** -** -**=========================================================*/ - - -#define UNICODE -#include - -int __cdecl main(int argc, char *argv[]) { - - WCHAR * TheString; - LPWSTR OutBuffer; - WCHAR* TheArray[3]; - int ReturnResult; - - /* - * Initialize the PAL and return FAILURE if this fails - */ - - if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - TheString = convert("Pal %1 %2 %3 Testing"); - TheArray[0] = convert("Foo"); - TheArray[1] = convert("Bar"); - TheArray[2] = convert("FooBar"); - - /* OutBuffer will be allocated in the function, if the flag - is working properly. - */ - - ReturnResult = FormatMessage( - FORMAT_MESSAGE_FROM_STRING | - FORMAT_MESSAGE_ARGUMENT_ARRAY | - FORMAT_MESSAGE_ALLOCATE_BUFFER, /* source and processing options */ - TheString, /* message source */ - 0, /* message identifier */ - 0, /* language identifier */ - (LPWSTR)&OutBuffer, /* message buffer */ - 0, /* maximum size of message buffer */ - (va_list *) TheArray /* array of message inserts */ - ); - - if(ReturnResult == 0) - { - Fail("ERROR: The return value was 0, which indicates failure. " - "The function failed when trying to Format a simple string, " - "using the ALLOCATE_BUFFER flag."); - } - - if(memcmp(OutBuffer, - convert("Pal Foo Bar FooBar Testing"), - wcslen(OutBuffer)*2+2) != 0) - { - Fail("ERROR: Since the FORMAT_MESSAGE_ALLOCATE_BUFFER flag was set, " - "the result should have been 'Pal Foo Bar FooBar Testing' but " - "was really '%s'.",convertC(OutBuffer)); - } - - PAL_Terminate(); - return PASS; - -} - - diff --git a/src/pal/tests/palsuite/miscellaneous/FormatMessageW/test5/testinfo.dat b/src/pal/tests/palsuite/miscellaneous/FormatMessageW/test5/testinfo.dat deleted file mode 100644 index 6f497c23c..000000000 --- a/src/pal/tests/palsuite/miscellaneous/FormatMessageW/test5/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Miscellaneous -Function = FormatMessageW -Name = Positive test of FormatMessageW -TYPE = DEFAULT -EXE1 = test -Description -= Test to ensure the FORMAT_MESSAGE_ALLOCATE_BUFFER flag works properly. diff --git a/src/pal/tests/palsuite/miscellaneous/FormatMessageW/test6/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/FormatMessageW/test6/CMakeLists.txt deleted file mode 100644 index 33ca130e2..000000000 --- a/src/pal/tests/palsuite/miscellaneous/FormatMessageW/test6/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test.cpp -) - -add_executable(paltest_formatmessagew_test6 - ${SOURCES} -) - -add_dependencies(paltest_formatmessagew_test6 coreclrpal) - -target_link_libraries(paltest_formatmessagew_test6 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/miscellaneous/FormatMessageW/test6/test.cpp b/src/pal/tests/palsuite/miscellaneous/FormatMessageW/test6/test.cpp deleted file mode 100644 index 48f5e3e93..000000000 --- a/src/pal/tests/palsuite/miscellaneous/FormatMessageW/test6/test.cpp +++ /dev/null @@ -1,78 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source : test.c -** -** Purpose: Test for FormatMessageW() function -** -** -**=========================================================*/ - - -#define UNICODE -#include - - -int __cdecl main(int argc, char *argv[]) { - - - LPWSTR OutBuffer; - int ReturnResult; - - /* - * Initialize the PAL and return FAILURE if this fails - */ - - if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - - /* This is testing the use of FROM_SYSTEM. We can't check to ensure - the error message it extracts is correct, only that it does place some - information into the buffer when it is called. - */ - - /* - - ERROR_SUCCESS (0L) is normally returned by GetLastError, - But, the ERROR_SUCCESS is removed from messages for Unix based Systems - To ensure that we have some information into the buffer we are using the message - identifier value 2L (ERROR_FILE_NOT_FOUND) - */ - ReturnResult = FormatMessage( - FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_ALLOCATE_BUFFER, /* source and processing options */ - NULL, /* message source */ - 2L, /* message identifier */ - 0, /* language identifier */ - (LPWSTR)&OutBuffer, /* message buffer */ - 0, /* maximum size of message buffer */ - NULL /* array of message inserts */ - ); - - if(ReturnResult == 0) - { - Fail("ERROR: The return value was 0, which indicates failure. The " - "function failed when trying to Format a FROM_SYSTEM message."); - } - - if(wcslen(OutBuffer) <= 0) - { - Fail("ERROR: There are no characters in the buffer, and when the " - "FORMAT_MESSAGE_FROM_SYSTEM flag is used with ERROR_FILE_NOT_FOUND error, " - "something should be put into the buffer."); - } - - LocalFree(OutBuffer); - - PAL_Terminate(); - return PASS; - -} - - diff --git a/src/pal/tests/palsuite/miscellaneous/FormatMessageW/test6/testinfo.dat b/src/pal/tests/palsuite/miscellaneous/FormatMessageW/test6/testinfo.dat deleted file mode 100644 index 7eda50527..000000000 --- a/src/pal/tests/palsuite/miscellaneous/FormatMessageW/test6/testinfo.dat +++ /dev/null @@ -1,15 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Miscellaneous -Function = FormatMessageW -Name = Positive test of FormatMessageW -TYPE = DEFAULT -EXE1 = test -Description -= Test to ensure the FORMAT_SYSTEM_MESSAGE flag works properly. - - - diff --git a/src/pal/tests/palsuite/miscellaneous/FreeEnvironmentStringsW/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/FreeEnvironmentStringsW/CMakeLists.txt deleted file mode 100644 index ef14ea535..000000000 --- a/src/pal/tests/palsuite/miscellaneous/FreeEnvironmentStringsW/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) - diff --git a/src/pal/tests/palsuite/miscellaneous/FreeEnvironmentStringsW/test1/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/FreeEnvironmentStringsW/test1/CMakeLists.txt deleted file mode 100644 index 081df3253..000000000 --- a/src/pal/tests/palsuite/miscellaneous/FreeEnvironmentStringsW/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test.cpp -) - -add_executable(paltest_freeenvironmentstringsw_test1 - ${SOURCES} -) - -add_dependencies(paltest_freeenvironmentstringsw_test1 coreclrpal) - -target_link_libraries(paltest_freeenvironmentstringsw_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/miscellaneous/FreeEnvironmentStringsW/test1/test.cpp b/src/pal/tests/palsuite/miscellaneous/FreeEnvironmentStringsW/test1/test.cpp deleted file mode 100644 index 56010039d..000000000 --- a/src/pal/tests/palsuite/miscellaneous/FreeEnvironmentStringsW/test1/test.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source: test.c -** -** Purpose: Test for FreeEnvironmentStringsW() function -** -** -**=========================================================*/ - -#define UNICODE -#include - -int __cdecl main(int argc, char *argv[]) -{ - - LPWSTR CapturedEnvironment = NULL; - BOOL TheResult = 0; - - /* - * Initialize the PAL and return FAILURE if this fails - */ - - if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - CapturedEnvironment = GetEnvironmentStrings(); - - /* If it's pointing to NULL, it failed. This checks the dependency */ - if(CapturedEnvironment == NULL) { - Fail("The function GetEnvironmentStrings() failed, and the " - "FreeEnvironmentStrings() tests is dependant on it.\n"); - } - - /* This should return 1, if it succeeds, otherwise, test fails */ - TheResult = FreeEnvironmentStrings(CapturedEnvironment); - if(TheResult != 1) { - Fail("The function returned %d which indicates failure to Free the " - "Environment Strings.\n",TheResult); - } - - - PAL_Terminate(); - return PASS; -} - - - diff --git a/src/pal/tests/palsuite/miscellaneous/FreeEnvironmentStringsW/test1/testinfo.dat b/src/pal/tests/palsuite/miscellaneous/FreeEnvironmentStringsW/test1/testinfo.dat deleted file mode 100644 index f653bf5dc..000000000 --- a/src/pal/tests/palsuite/miscellaneous/FreeEnvironmentStringsW/test1/testinfo.dat +++ /dev/null @@ -1,15 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Miscellaneous -Function = FreeEnvironmentStringsW -Name = Return value test for FreeEnvironmentStringsW -TYPE = DEFAULT -EXE1 = test -Description -= Get a set of strings and then free it to see if function returns success - - - diff --git a/src/pal/tests/palsuite/miscellaneous/FreeEnvironmentStringsW/test2/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/FreeEnvironmentStringsW/test2/CMakeLists.txt deleted file mode 100644 index 7a69e103f..000000000 --- a/src/pal/tests/palsuite/miscellaneous/FreeEnvironmentStringsW/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test.cpp -) - -add_executable(paltest_freeenvironmentstringsw_test2 - ${SOURCES} -) - -add_dependencies(paltest_freeenvironmentstringsw_test2 coreclrpal) - -target_link_libraries(paltest_freeenvironmentstringsw_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/miscellaneous/FreeEnvironmentStringsW/test2/test.cpp b/src/pal/tests/palsuite/miscellaneous/FreeEnvironmentStringsW/test2/test.cpp deleted file mode 100644 index 1bb05cdb1..000000000 --- a/src/pal/tests/palsuite/miscellaneous/FreeEnvironmentStringsW/test2/test.cpp +++ /dev/null @@ -1,71 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source: test.c -** -** Purpose: Test for FreeEnvironmentStringsW() function -** -** -**=========================================================*/ - -#define UNICODE -#include - -int __cdecl main(int argc, char *argv[]) -{ - - WCHAR CapturedEnvironment[] = {'T','E','S','T','\0'}; - BOOL TheResult = 0; - LPWSTR lpCapturedEnvironment = NULL; - - /* - * Initialize the PAL and return FAILURE if this fails - */ - - if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - lpCapturedEnvironment = (LPWSTR)malloc( sizeof(CapturedEnvironment) / - sizeof(CapturedEnvironment[0]) ); - - if ( lpCapturedEnvironment ) - { - memcpy( lpCapturedEnvironment, CapturedEnvironment, - sizeof(CapturedEnvironment) / sizeof(CapturedEnvironment[0]) ); - } - else - { - Fail( "malloc() failed to allocate memory.\n" ); - } - /* Even if this is not a valid Environment block, the function will - still return success - */ - - TheResult = FreeEnvironmentStrings( lpCapturedEnvironment ); - if(TheResult == 0) - { - Fail("The function should still return a success value even if it is " - "passed a LPWSTR which is not an environment block properly " - "aquired from GetEnvironmentStrings\n"); - } - - /* Even passing this function NULL, should still return a success value */ - TheResult = FreeEnvironmentStrings(NULL); - if(TheResult == 0) - { - Fail("The function should still return a success value even if pass " - "NULL.\n"); - } - - - PAL_Terminate(); - return PASS; -} - - - diff --git a/src/pal/tests/palsuite/miscellaneous/FreeEnvironmentStringsW/test2/testinfo.dat b/src/pal/tests/palsuite/miscellaneous/FreeEnvironmentStringsW/test2/testinfo.dat deleted file mode 100644 index c426a7ccb..000000000 --- a/src/pal/tests/palsuite/miscellaneous/FreeEnvironmentStringsW/test2/testinfo.dat +++ /dev/null @@ -1,16 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Miscellaneous -Function = FreeEnvironmentStringsW -Name = Positive Return value test for FreeEnvironmentStringsW -TYPE = DEFAULT -EXE1 = test -Description -= Ensure that FreeEnvironmentStringsW returns success when passed pointers -= that don't point to an environment block. - - - diff --git a/src/pal/tests/palsuite/miscellaneous/GetCalendarInfoW/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/GetCalendarInfoW/CMakeLists.txt deleted file mode 100644 index ef14ea535..000000000 --- a/src/pal/tests/palsuite/miscellaneous/GetCalendarInfoW/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) - diff --git a/src/pal/tests/palsuite/miscellaneous/GetCalendarInfoW/test1/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/GetCalendarInfoW/test1/CMakeLists.txt deleted file mode 100644 index 11c278015..000000000 --- a/src/pal/tests/palsuite/miscellaneous/GetCalendarInfoW/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - GetCalendarInfoW.cpp -) - -add_executable(paltest_getcalendarinfow_test1 - ${SOURCES} -) - -add_dependencies(paltest_getcalendarinfow_test1 coreclrpal) - -target_link_libraries(paltest_getcalendarinfow_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/miscellaneous/GetCalendarInfoW/test1/GetCalendarInfoW.cpp b/src/pal/tests/palsuite/miscellaneous/GetCalendarInfoW/test1/GetCalendarInfoW.cpp deleted file mode 100644 index 4876fe180..000000000 --- a/src/pal/tests/palsuite/miscellaneous/GetCalendarInfoW/test1/GetCalendarInfoW.cpp +++ /dev/null @@ -1,57 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: GetCalendarInfoW.c -** -** Purpose: Positive test the GetCalendarInfoW API. -** Call GetCalendarInfoW to retrieve the information of a -** calendar -** -** -**============================================================*/ -#define UNICODE -#include - -int __cdecl main(int argc, char *argv[]) -{ - int err; - LCID Locale = LOCALE_USER_DEFAULT; - CALTYPE CalType = CAL_ITWODIGITYEARMAX|CAL_RETURN_NUMBER; - DWORD dwValue; - - /*Initialize the PAL environment*/ - err = PAL_Initialize(argc, argv); - if(0 != err) - { - return FAIL; - } - - err = GetCalendarInfoW(Locale,/*locale idendifier*/ - CAL_GREGORIAN, /*calendar identifier*/ - CalType, /*calendar tyope*/ - NULL, /*buffer to store the retrieve info*/ - 0, /*alwayse zero*/ - &dwValue);/*to store the requrest data*/ - if (0 == err) - { - Fail("GetCalendarInfoW failed for CAL_GREGORIAN!\n"); - } - - err = GetCalendarInfoW(Locale,/*locale idendifier*/ - CAL_GREGORIAN_US, /*calendar identifier*/ - CalType, /*calendar tyope*/ - NULL, /*buffer to store the retreive info*/ - 0, /*alwayse zero*/ - &dwValue);/*to store the requrest data*/ - if (0 == err) - { - Fail("GetCalendarInfoW failed for CAL_GREGORIAN_US!\n"); - } - - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/miscellaneous/GetCalendarInfoW/test1/testinfo.dat b/src/pal/tests/palsuite/miscellaneous/GetCalendarInfoW/test1/testinfo.dat deleted file mode 100644 index 59c806c22..000000000 --- a/src/pal/tests/palsuite/miscellaneous/GetCalendarInfoW/test1/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = miscellaneous -Function = GetCalendarInfoW -Name = Positive test for GetCalendarInfoW API to retrieve the info of a calendar -TYPE = DEFAULT -EXE1 = getcalendarinfow -Description -= Test the GetCalendarInfoW to retrieve the information of a calendar -= This test for US English - diff --git a/src/pal/tests/palsuite/miscellaneous/GetCalendarInfoW/test2/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/GetCalendarInfoW/test2/CMakeLists.txt deleted file mode 100644 index 2abf2901c..000000000 --- a/src/pal/tests/palsuite/miscellaneous/GetCalendarInfoW/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - GetCalendarInfoW.cpp -) - -add_executable(paltest_getcalendarinfow_test2 - ${SOURCES} -) - -add_dependencies(paltest_getcalendarinfow_test2 coreclrpal) - -target_link_libraries(paltest_getcalendarinfow_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/miscellaneous/GetCalendarInfoW/test2/GetCalendarInfoW.cpp b/src/pal/tests/palsuite/miscellaneous/GetCalendarInfoW/test2/GetCalendarInfoW.cpp deleted file mode 100644 index d8a59a0fc..000000000 --- a/src/pal/tests/palsuite/miscellaneous/GetCalendarInfoW/test2/GetCalendarInfoW.cpp +++ /dev/null @@ -1,79 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: GetCalendarInfoW.c -** -** Purpose: Positive test the GetCalendarInfoW API. -** Call GetCalendarInfoW to retrieve the information of all -** calendars -** -** -**============================================================*/ -#define UNICODE -#include - -int __cdecl main(int argc, char *argv[]) -{ - int err; - int index = 0; - LCID Locale = LOCALE_USER_DEFAULT; - CALID Calendar; - CALTYPE CalType = CAL_ITWODIGITYEARMAX|CAL_RETURN_NUMBER; - DWORD dwValue; - char *CalendarID[]={"CAL_GREGORIAN", - "CAL_GREGORIAN_US", - "CAL_JAPAN", - "CAL_TAIWAN", - "CAL_KOREA", - "CAL_HIJRI", - "CAL_THAI", - "CAL_HEBREW", - "CAL_GREGORIAN_ME_FRENCH", - "CAL_GREGORIAN_ARABIC", - "CAL_GREGORIAN_XLIT_ENGLISH", - "CAL_GREGORIAN_XLIT_FRENCH", - "CAL_JULIAN"}; - - char errBuffer[1024]; - - - /*Initialize the PAL environment*/ - err = PAL_Initialize(argc, argv); - if(0 != err) - { - return FAIL; - } - - memset(errBuffer, 0, 1024); - - for(index=0; index<13; index++) - { - Calendar = index + 1; - /*retrieve the specified calendar info*/ - err = GetCalendarInfoW(Locale,/*locale idendifier*/ - Calendar, /*calendar identifier*/ - CalType, /*calendar tyope*/ - NULL, /*buffer to store the retreive info*/ - 0, /*alwayse zero*/ - &dwValue);/*to store the requrest data*/ - if(0 == err) - { - strcat(errBuffer, CalendarID[index]); - strcat(errBuffer, ", "); - } - } - - - if(strlen(errBuffer) > 0) - { - Fail("\nFailed to call GetCalendarInfoW API by passing %s" - " Calendar identifier(s)\n",errBuffer); - } - - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/miscellaneous/GetCalendarInfoW/test2/testinfo.dat b/src/pal/tests/palsuite/miscellaneous/GetCalendarInfoW/test2/testinfo.dat deleted file mode 100644 index ea85e99a3..000000000 --- a/src/pal/tests/palsuite/miscellaneous/GetCalendarInfoW/test2/testinfo.dat +++ /dev/null @@ -1,11 +0,0 @@ -Version = 1.0 -Section = miscellaneous -Function = GetCalendarInfoW -Name = Positive test #2 for GetCalendarInfoW API to retrieve the info of a -calendar -TYPE = DEFAULT -EXE1 = getcalendarinfow -Description -= Test the GetCalendarInfoW to retrieve the information of all calendars -= but US English - diff --git a/src/pal/tests/palsuite/miscellaneous/GetCommandLineW/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/GetCommandLineW/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/miscellaneous/GetCommandLineW/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/miscellaneous/GetCommandLineW/test1/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/GetCommandLineW/test1/CMakeLists.txt deleted file mode 100644 index 6d00bf85c..000000000 --- a/src/pal/tests/palsuite/miscellaneous/GetCommandLineW/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test.cpp -) - -add_executable(paltest_getcommandlinew_test1 - ${SOURCES} -) - -add_dependencies(paltest_getcommandlinew_test1 coreclrpal) - -target_link_libraries(paltest_getcommandlinew_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/miscellaneous/GetCommandLineW/test1/test.cpp b/src/pal/tests/palsuite/miscellaneous/GetCommandLineW/test1/test.cpp deleted file mode 100644 index 3417c149a..000000000 --- a/src/pal/tests/palsuite/miscellaneous/GetCommandLineW/test1/test.cpp +++ /dev/null @@ -1,71 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source : test.c -** -** Purpose: Test for GetCommandLineW() function -** -** -**=========================================================*/ - -#define UNICODE -#include - -int __cdecl main(int argc, char *argv[]) -{ - - LPWSTR TheResult = NULL; - WCHAR *CommandLine; - int i; - WCHAR * p; - - /* - * Initialize the PAL and return FAILURE if this fails - */ - - if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - CommandLine = (WCHAR*)malloc(1024); - wcscpy(CommandLine,convert(argv[0])); - - for(i=1;i - -int __cdecl main(int argc, char *argv[]) -{ - int err; - WCHAR *wpFormat; - LPCSTR lpString = "gg"; - CONST SYSTEMTIME *lpDate = NULL; - LCID DefaultLocale; - DWORD dwFlags; - int DateSize; - WCHAR *wpBuffer = NULL; - - /*Initialize the PAL environment*/ - err = PAL_Initialize(argc, argv); - if(0 != err) - { - return FAIL; - } - - /*convert to a wide character string*/ - wpFormat = convert((char *)lpString); - - dwFlags = DATE_USE_ALT_CALENDAR; /*set the flags*/ - - - DateSize = 0; - - /*retrieve the buffer size*/ - DateSize = GetDateFormatW( - DefaultLocale, /*system default locale*/ - dwFlags, /*function option*/ - (SYSTEMTIME *)lpDate, /*always is NULL*/ - wpFormat, /*pointer to a picture string*/ - wpBuffer, /*out buffer*/ - DateSize); /*buffer size*/ - - if(DateSize <= 0) - { - free(wpFormat); - Fail("\nRetrieved an invalid buffer size\n"); - } - - wpBuffer = (WCHAR*)malloc((DateSize + 1)*sizeof(WCHAR)); - if(NULL == wpBuffer) - { - free(wpFormat); - Fail("\nFailed to allocate memory to store the formatted string\n"); - } - - /*format a date by passing an invalid locale indentifier*/ - err = GetDateFormatW( - -1, /*invalid locale identifier*/ - dwFlags, /*function option*/ - (SYSTEMTIME *)lpDate, /*always is NULL, or use system date*/ - wpFormat, /*pointer to a picture string*/ - wpBuffer, /*out buffer*/ - DateSize); /*buffer size*/ - - free(wpBuffer); - free(wpFormat); - - if(0 != err || GetLastError() != ERROR_INVALID_PARAMETER) - { - Fail("\nFailed to call GetDateFormatW for a negative test by " - "passing an invalid parameter, error code=%d\n", GetLastError()); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/miscellaneous/GetDateFormatW/GetDateFormatW_neg1/testinfo.dat b/src/pal/tests/palsuite/miscellaneous/GetDateFormatW/GetDateFormatW_neg1/testinfo.dat deleted file mode 100644 index f02271650..000000000 --- a/src/pal/tests/palsuite/miscellaneous/GetDateFormatW/GetDateFormatW_neg1/testinfo.dat +++ /dev/null @@ -1,8 +0,0 @@ -Version = 1.0 -Section = miscellaneous -Function = GetDateFormatW -Name = Negative test for GetDateFormatW by passing an invlid locale identifier -TYPE = DEFAULT -EXE1 = getdateformatw_neg -Description -=negative test GetDateFormatW by passing an invalid locale identifier diff --git a/src/pal/tests/palsuite/miscellaneous/GetDateFormatW/GetDateFormatW_neg2/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/GetDateFormatW/GetDateFormatW_neg2/CMakeLists.txt deleted file mode 100644 index dc4215ea5..000000000 --- a/src/pal/tests/palsuite/miscellaneous/GetDateFormatW/GetDateFormatW_neg2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - GetDateFormatW_neg.cpp -) - -add_executable(paltest_getdateformatw_getdateformatw_neg2 - ${SOURCES} -) - -add_dependencies(paltest_getdateformatw_getdateformatw_neg2 coreclrpal) - -target_link_libraries(paltest_getdateformatw_getdateformatw_neg2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/miscellaneous/GetDateFormatW/GetDateFormatW_neg2/GetDateFormatW_neg.cpp b/src/pal/tests/palsuite/miscellaneous/GetDateFormatW/GetDateFormatW_neg2/GetDateFormatW_neg.cpp deleted file mode 100644 index 43f32cf69..000000000 --- a/src/pal/tests/palsuite/miscellaneous/GetDateFormatW/GetDateFormatW_neg2/GetDateFormatW_neg.cpp +++ /dev/null @@ -1,98 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: GetDateFormatW_neg.c -** -** Purpose: Negative test the GetDateFormatW API. -** Call GetDateFormatW by passing an invalid flag -** -** -**============================================================*/ -#define UNICODE -#include - -int __cdecl main(int argc, char *argv[]) -{ - int err; - WCHAR *wpFormat; - LPCSTR lpString = "gg"; - CONST SYSTEMTIME *lpDate = NULL; - LCID DefaultLocale; - DWORD dwFlags; - int DateSize; - WCHAR *wpBuffer = NULL; - - /*Initialize the PAL environment*/ - err = PAL_Initialize(argc, argv); - if(0 != err) - { - return FAIL; - } - - /*convert to a wide character string*/ - wpFormat = convert((char *)lpString); - - /* - DefaultLocale = GetSystemDefaultLCID() which is not defined in PAL; - - LOCALE_SYSTEM_DEFAULT = MAKELCID(LANG_SYSTEM_DEFAULT, SORT_DEFAULT) - - LANG_SYSTEM_DEFAULT = MAKELANGID(LANG_NEUTRAL,SUBLANG_SYS_DEFAULT); - SUBLANG_SYS_DEFAULT is not defined in PAL, here use hardcoding, - the value is from winnt.h - */ - - DefaultLocale = MAKELCID(MAKELANGID(LANG_NEUTRAL, 0x02), SORT_DEFAULT); - - dwFlags = DATE_USE_ALT_CALENDAR; /*set the flags*/ - - - DateSize = 0; - - /*retrieve the buffer size*/ - DateSize = GetDateFormatW( - DefaultLocale, /*system default locale*/ - dwFlags, /*function option*/ - (SYSTEMTIME *)lpDate, /*always is NULL*/ - wpFormat, /*pointer to a picture string*/ - wpBuffer, /*out buffer*/ - DateSize); /*buffer size*/ - - if(DateSize <= 0) - { - free(wpFormat); - Fail("\nRetrieved an invalid buffer size\n"); - } - - wpBuffer = (WCHAR*)malloc((DateSize + 1)*sizeof(WCHAR)); - if(NULL == wpBuffer) - { - free(wpFormat); - Fail("\nFailed to allocate memory to store the formatted string\n"); - } - - err = GetDateFormatW( - DefaultLocale, /*system default locale*/ - 0x00000001|0x00000008,/*DATE_SHORTDATE|DATE_YEARMONTH */ - /*an invalid flag*/ - (SYSTEMTIME *)lpDate, /*always is NULL, or use system date*/ - wpFormat, /*pointer to a picture string*/ - wpBuffer, /*out buffer*/ - DateSize); /*buffer size*/ - - free(wpBuffer); - free(wpFormat); - - if(0 != err || GetLastError() != ERROR_INVALID_FLAGS) - { - Fail("\nFailed to call GetDateFormatW for a negative test by " - "passing an invalid flag, error code=%d\n", GetLastError()); - } - - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/miscellaneous/GetDateFormatW/GetDateFormatW_neg2/testinfo.dat b/src/pal/tests/palsuite/miscellaneous/GetDateFormatW/GetDateFormatW_neg2/testinfo.dat deleted file mode 100644 index fe5bc9b06..000000000 --- a/src/pal/tests/palsuite/miscellaneous/GetDateFormatW/GetDateFormatW_neg2/testinfo.dat +++ /dev/null @@ -1,9 +0,0 @@ -Version = 1.0 -Section = miscellaneous -Function = GetDateFormatW -Name = Negative test for GetDateFormatW by passing an invalid flag -TYPE = DEFAULT -EXE1 = getdateformatw_neg -Description -=test for GetDateFormatW by passing an invalid flag which is not -=supported diff --git a/src/pal/tests/palsuite/miscellaneous/GetDateFormatW/test1/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/GetDateFormatW/test1/CMakeLists.txt deleted file mode 100644 index b392d02ca..000000000 --- a/src/pal/tests/palsuite/miscellaneous/GetDateFormatW/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - GetDateFormatW.cpp -) - -add_executable(paltest_getdateformatw_test1 - ${SOURCES} -) - -add_dependencies(paltest_getdateformatw_test1 coreclrpal) - -target_link_libraries(paltest_getdateformatw_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/miscellaneous/GetDateFormatW/test1/GetDateFormatW.cpp b/src/pal/tests/palsuite/miscellaneous/GetDateFormatW/test1/GetDateFormatW.cpp deleted file mode 100644 index 6e3c3b489..000000000 --- a/src/pal/tests/palsuite/miscellaneous/GetDateFormatW/test1/GetDateFormatW.cpp +++ /dev/null @@ -1,100 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: GetDateFormatW.c -** -** Purpose: Positive test the GetDateFormatW API. -** Call GetDateFormatW to format a date string for -** a specified locale -** -** -**============================================================*/ -#define UNICODE -#include - -int __cdecl main(int argc, char *argv[]) -{ - int err; - WCHAR *wpFormat; - LPCSTR lpString = "gg"; - CONST SYSTEMTIME *lpDate = NULL; - LCID DefaultLocale; - DWORD dwFlags; - int DateSize; - WCHAR *wpBuffer = NULL; - - /*Initialize the PAL environment*/ - err = PAL_Initialize(argc, argv); - if(0 != err) - { - return FAIL; - } - - /*convert to a wide character string*/ - wpFormat = convert((char *)lpString); - - /* - DefaultLocale = GetSystemDefaultLCID() which is not defined in PAL; - - LOCALE_SYSTEM_DEFAULT = MAKELCID(LANG_SYSTEM_DEFAULT, SORT_DEFAULT) - - LANG_SYSTEM_DEFAULT = MAKELANGID(LANG_NEUTRAL,SUBLANG_SYS_DEFAULT); - SUBLANG_SYS_DEFAULT is not defined in PAL, here use hardcoding, - the value is from winnt.h - */ - DefaultLocale = MAKELCID(MAKELANGID(LANG_NEUTRAL, 0x02), SORT_DEFAULT); - - dwFlags = DATE_USE_ALT_CALENDAR; /*set the flags*/ - - - DateSize = 0; - - /*retrieve the buffer size*/ - DateSize = GetDateFormatW( - DefaultLocale, /*system default locale*/ - dwFlags, /*function option*/ - (SYSTEMTIME *)lpDate, /*always is NULL*/ - wpFormat, /*pointer to a picture string*/ - wpBuffer, /*out buffer*/ - DateSize); /*buffer size*/ - - if(DateSize <= 0) - { - free(wpFormat); - Fail("\nRetrieved an invalid buffer size\n"); - } - - - wpBuffer = (WCHAR*)malloc((DateSize+1)*sizeof(WCHAR)); - if(NULL == wpBuffer) - { - free(wpFormat); - Fail("\nFailed to allocate memory to store a formatted string\n"); - } - - /*retrieve the formatted string for a specified locale*/ - err = GetDateFormatW( - DefaultLocale, /*system default locale*/ - dwFlags, /*function option*/ - (SYSTEMTIME *)lpDate, /*always is NULL*/ - wpFormat, /*pointer to a picture string*/ - wpBuffer, /*out buffer*/ - DateSize); /*buffer size*/ - - if(0 == err) - { - free(wpBuffer); - free(wpFormat); - Fail("\nFailed to call GetDateFormatW to format a system data " - "as a data string for system default locale!\n"); - } - - free(wpBuffer); - free(wpFormat); - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/miscellaneous/GetDateFormatW/test1/testinfo.dat b/src/pal/tests/palsuite/miscellaneous/GetDateFormatW/test1/testinfo.dat deleted file mode 100644 index 6ed9ee7ce..000000000 --- a/src/pal/tests/palsuite/miscellaneous/GetDateFormatW/test1/testinfo.dat +++ /dev/null @@ -1,9 +0,0 @@ -Version = 1.0 -Section = miscellaneous -Function = GetDateFormatW -Name = Positive test for GetDateFormatW to format a date as a date string -TYPE = DEFAULT -EXE1 = getdateformatw -Description -=test for GetDateFormatW to format a date as a date string -=for a specified locale diff --git a/src/pal/tests/palsuite/miscellaneous/GetEnvironmentStringsW/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/GetEnvironmentStringsW/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/miscellaneous/GetEnvironmentStringsW/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/miscellaneous/GetEnvironmentStringsW/test1/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/GetEnvironmentStringsW/test1/CMakeLists.txt deleted file mode 100644 index 378390b15..000000000 --- a/src/pal/tests/palsuite/miscellaneous/GetEnvironmentStringsW/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test.cpp -) - -add_executable(paltest_getenvironmentstringsw_test1 - ${SOURCES} -) - -add_dependencies(paltest_getenvironmentstringsw_test1 coreclrpal) - -target_link_libraries(paltest_getenvironmentstringsw_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/miscellaneous/GetEnvironmentStringsW/test1/test.cpp b/src/pal/tests/palsuite/miscellaneous/GetEnvironmentStringsW/test1/test.cpp deleted file mode 100644 index 2bd9153e5..000000000 --- a/src/pal/tests/palsuite/miscellaneous/GetEnvironmentStringsW/test1/test.cpp +++ /dev/null @@ -1,81 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source : test.c -** -** Purpose: Test for GetEnvironmentStringsW() function -** -** -**=========================================================*/ - -/* Depends on SetEnvironmentVariable(), wcsstr() and wcslen() */ - -#define UNICODE -#include - -int __cdecl main(int argc, char *argv[]) { - - LPWSTR CapturedEnvironmentStrings = NULL; - LPWSTR EnviroStringReturned = NULL; - WCHAR EnvironmentVariableBuffer[] = - {'P','A','L','T','E','S','T','I','N','G','\0'}; - WCHAR EnvironmentValueBuffer[] = {'T','e','s','t','i','n','g','\0'}; - - /* - * Initialize the PAL and return FAILURE if this fails - */ - - if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - /* This test depends on SetEnvironmentVariableW working. - We need to set a variable so we can test and ensure it's there - when we get them back - */ - - SetEnvironmentVariable(EnvironmentVariableBuffer,EnvironmentValueBuffer); - - CapturedEnvironmentStrings = GetEnvironmentStrings(); - - /* If it's pointing to NULL, it failed. */ - if(CapturedEnvironmentStrings == NULL) { - Fail("The function returned a pointer to NULL, which it shouldn't do. " - "It should point to a block of Environment Strings.\n"); - } - - /* Now that we've grabbed the list of envrionment strings, go through - each one, and check for a match to 'PALTESTING'. If this is missing - it's not pointing at the environment block. - */ - - while(*CapturedEnvironmentStrings != 0) - { - EnviroStringReturned = wcsstr(CapturedEnvironmentStrings, - EnvironmentVariableBuffer); - CapturedEnvironmentStrings += wcslen(CapturedEnvironmentStrings)+1; - if(EnviroStringReturned != NULL) - { - break; - } - } - - if(EnviroStringReturned == NULL) - { - Fail("The memory block returned was searched, but nothing was found to " - "prove this was really the environment block. Either this " - "function, SetEnvironmentVariable or wcsstr() is broken.\n"); - } - - - PAL_Terminate(); - return PASS; -} - - - - diff --git a/src/pal/tests/palsuite/miscellaneous/GetEnvironmentStringsW/test1/testinfo.dat b/src/pal/tests/palsuite/miscellaneous/GetEnvironmentStringsW/test1/testinfo.dat deleted file mode 100644 index fa712ab82..000000000 --- a/src/pal/tests/palsuite/miscellaneous/GetEnvironmentStringsW/test1/testinfo.dat +++ /dev/null @@ -1,16 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Miscellaneous -Function = GetEnvironmentStringsW -Name = Test for correct return of GetEnvironmentStringsW -TYPE = DEFAULT -EXE1 = test -Description -= Get a set of strings, and check to make sure it contains a predetermined -= string that was placed there. - - - diff --git a/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableA/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableA/CMakeLists.txt deleted file mode 100644 index 7c2017935..000000000 --- a/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableA/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) -add_subdirectory(test3) -add_subdirectory(test4) -add_subdirectory(test5) -add_subdirectory(test6) - diff --git a/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableA/test1/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableA/test1/CMakeLists.txt deleted file mode 100644 index 2af3c9de8..000000000 --- a/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableA/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test.cpp -) - -add_executable(paltest_getenvironmentvariablea_test1 - ${SOURCES} -) - -add_dependencies(paltest_getenvironmentvariablea_test1 coreclrpal) - -target_link_libraries(paltest_getenvironmentvariablea_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableA/test1/test.cpp b/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableA/test1/test.cpp deleted file mode 100644 index 23e997446..000000000 --- a/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableA/test1/test.cpp +++ /dev/null @@ -1,84 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source : test.c -** -** Purpose: Test for GetEnvironmentVariable() function -** Assign a properly sized buffer and get an environment -** variable, check to ensure it returns the correct values. -** -** -**=========================================================*/ - -#include - -int __cdecl main(int argc, char *argv[]) { - - /* Define some buffers needed for the function */ - char * pResultBuffer = NULL; - int size = 0; - - /* A place to stash the returned values */ - int ReturnValueForLargeBuffer = 0; - - /* - * Initialize the PAL and return FAILURE if this fails - */ - - if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - /* Recieve and allocate the correct amount of memory for the buffer */ - size = ReturnValueForLargeBuffer = GetEnvironmentVariable("PATH", - pResultBuffer, - 0); - pResultBuffer = (char*)malloc(size); - if ( pResultBuffer == NULL ) - { - Fail("ERROR: Failed to allocate memory for pResultBuffer pointer. " - "Can't properly exec test case without this.\n"); - } - - - /* Normal case, PATH should fit into this buffer */ - ReturnValueForLargeBuffer = GetEnvironmentVariable("PATH", - pResultBuffer, - size); - - /* Ensure that it returned a positive value */ - if(ReturnValueForLargeBuffer <= 0) - { - free(pResultBuffer); - - Fail("The return was %d, which indicates that the function failed.\n", - ReturnValueForLargeBuffer); - } - - /* Ensure that it succeeded and copied the correct number of characters. - If this is true, then the return value should be one less of the size of - the buffer. (Doesn't include that NULL byte) - */ - - if(ReturnValueForLargeBuffer != size-1) - { - free(pResultBuffer); - - Fail("The value returned was %d when it should have been %d. " - "This should be the number of characters copied, minus the " - "NULL byte.\n",ReturnValueForLargeBuffer, size-1); - } - - - free(pResultBuffer); - - PAL_Terminate(); - return PASS; -} - - - diff --git a/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableA/test1/testinfo.dat b/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableA/test1/testinfo.dat deleted file mode 100644 index ee81e2ec3..000000000 --- a/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableA/test1/testinfo.dat +++ /dev/null @@ -1,16 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Miscellaneous -Function = GetEnvironmentVariableA -Name = Return value test for GetEnvironmentVariableA -TYPE = DEFAULT -EXE1 = test -Description -= Assign a properly sized buffer and get an environment variable, check to -= ensure it returns the correct values. - - - diff --git a/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableA/test2/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableA/test2/CMakeLists.txt deleted file mode 100644 index 64da266af..000000000 --- a/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableA/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test.cpp -) - -add_executable(paltest_getenvironmentvariablea_test2 - ${SOURCES} -) - -add_dependencies(paltest_getenvironmentvariablea_test2 coreclrpal) - -target_link_libraries(paltest_getenvironmentvariablea_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableA/test2/test.cpp b/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableA/test2/test.cpp deleted file mode 100644 index d26588e90..000000000 --- a/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableA/test2/test.cpp +++ /dev/null @@ -1,56 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source : test.c -** -** Purpose: Test for GetEnvironmentVariable() function -** Pass a small buffer to GetEnvironmentVariableA to ensure -** it returns the size it requires. -** -** -**=========================================================*/ - -#include - -#define SMALL_BUFFER_SIZE 1 - -int __cdecl main(int argc, char *argv[]) { - - /* A place to stash the returned values */ - int ReturnValueForSmallBuffer = 0; - - char pSmallBuffer[SMALL_BUFFER_SIZE]; - - /* - * Initialize the PAL and return FAILURE if this fails - */ - - if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - /* PATH won't fit in this buffer, it should return how many - characters it needs - */ - - ReturnValueForSmallBuffer = GetEnvironmentVariable("PATH", - pSmallBuffer, - SMALL_BUFFER_SIZE); - if(ReturnValueForSmallBuffer <= 0) - { - Fail("The return value was %d when it should have been greater " - "than 0. " - "This should return the number of characters needed to contained " - "the contents of PATH in a buffer.\n",ReturnValueForSmallBuffer); - } - - PAL_Terminate(); - return PASS; -} - - - diff --git a/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableA/test2/testinfo.dat b/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableA/test2/testinfo.dat deleted file mode 100644 index 990649fad..000000000 --- a/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableA/test2/testinfo.dat +++ /dev/null @@ -1,16 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Miscellaneous -Function = GetEnvironmentVariableA -Name = Return value test on GetEnvironmentVariableA -TYPE = DEFAULT -EXE1 = test -Description -= Pass a small buffer to GetEnvironmentVariableA -= to ensure it returns the size it requires. - - - diff --git a/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableA/test3/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableA/test3/CMakeLists.txt deleted file mode 100644 index 65ff93736..000000000 --- a/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableA/test3/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test.cpp -) - -add_executable(paltest_getenvironmentvariablea_test3 - ${SOURCES} -) - -add_dependencies(paltest_getenvironmentvariablea_test3 coreclrpal) - -target_link_libraries(paltest_getenvironmentvariablea_test3 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableA/test3/test.cpp b/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableA/test3/test.cpp deleted file mode 100644 index b51e139c9..000000000 --- a/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableA/test3/test.cpp +++ /dev/null @@ -1,67 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source : test.c -** -** Purpose: Test for GetEnvironmentVariable() function -** Pass a nonexisting environment variable and a null to -** the function to check return values. -** -** -**=========================================================*/ - -#include - -#define BUFFER_SIZE 5000 -#define SMALL_BUFFER_SIZE 5 - -int __cdecl main(int argc, char *argv[]) -{ - - int ReturnValueForNonExisting = 0; - int ReturnValueForNull = 0; - - char pResultBuffer[BUFFER_SIZE]; - char pSmallBuffer[SMALL_BUFFER_SIZE]; - - if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - /* This variable doesn't exist, it should return 0 */ - ReturnValueForNonExisting = GetEnvironmentVariable("NonExistingVariable", - pSmallBuffer, - SMALL_BUFFER_SIZE); - - if(ReturnValueForNonExisting != 0) - { - Fail("ERROR: The return should have been 0, but it was %d. " - "The function attempted to get an Environment Variable that " - "doesn't exist and should return 0 as a result.\n", - ReturnValueForNonExisting); - } - - - /* Passing a NULL string should return 0 */ - ReturnValueForNull = GetEnvironmentVariable(NULL, - pResultBuffer, - BUFFER_SIZE); - - if(ReturnValueForNull != 0) - { - Fail("ERROR: The return should have been 0, but it was %d. " - "The function attempted to get a NULL pointer and should return " - "0 as a result.\n",ReturnValueForNull); - - } - - PAL_Terminate(); - return PASS; - } - - - diff --git a/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableA/test3/testinfo.dat b/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableA/test3/testinfo.dat deleted file mode 100644 index afaa04b8f..000000000 --- a/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableA/test3/testinfo.dat +++ /dev/null @@ -1,16 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Miscellaneous -Function = GetEnvironmentVariableA -Name = Return value test for GetEnvironmentVariableA -TYPE = DEFAULT -EXE1 = test -Description -= Pass a nonexisting environment variable and a null to the function -= to check return values. - - - diff --git a/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableA/test4/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableA/test4/CMakeLists.txt deleted file mode 100644 index df7697bef..000000000 --- a/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableA/test4/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test.cpp -) - -add_executable(paltest_getenvironmentvariablea_test4 - ${SOURCES} -) - -add_dependencies(paltest_getenvironmentvariablea_test4 coreclrpal) - -target_link_libraries(paltest_getenvironmentvariablea_test4 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableA/test4/test.cpp b/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableA/test4/test.cpp deleted file mode 100644 index a09eb883e..000000000 --- a/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableA/test4/test.cpp +++ /dev/null @@ -1,75 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source : test.c -** -** Purpose: Test for GetEnvironmentVariable() function -** Set an Environment Variable, then use GetEnvironmentVariable to -** retrieve it -- ensure that it retrieves properly. -** -** -**=========================================================*/ - -/* Depends on SetEnvironmentVariableW (because we're implmenting - the wide version) and strcmp() -*/ - -#include - -int __cdecl main(int argc, char *argv[]) { - - /* Define some buffers needed for the function */ - char * pResultBuffer = NULL; - WCHAR SomeEnvironmentVariable[] = {'P','A','L','T','E','S','T','\0'}; - WCHAR TheEnvironmentValue[] = {'T','E','S','T','\0'}; - int size = 0; - - /* - * Initialize the PAL and return FAILURE if this fails - */ - - if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - SetEnvironmentVariableW(SomeEnvironmentVariable, - TheEnvironmentValue); - - - /* Normal case, PATH should fit into this buffer */ - size = GetEnvironmentVariable("PALTEST", // Variable Name - pResultBuffer, // Buffer for Value - 0); // Buffer size - - pResultBuffer = (char*)malloc(size); - if ( pResultBuffer == NULL ) - { - Fail("ERROR: Failed to allocate memory for pResultBuffer pointer. " - "Can't properly exec test case without this.\n"); - } - - - GetEnvironmentVariable("PALTEST", - pResultBuffer, - size); - - if(strcmp(pResultBuffer,"TEST") != 0) - { - free(pResultBuffer); - Fail("ERROR: The value in the buffer should have been 'TEST' but " - "was really '%s'.\n",pResultBuffer); - - } - - free(pResultBuffer); - - PAL_Terminate(); - return PASS; -} - - - diff --git a/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableA/test4/testinfo.dat b/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableA/test4/testinfo.dat deleted file mode 100644 index 8fb16c778..000000000 --- a/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableA/test4/testinfo.dat +++ /dev/null @@ -1,16 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Miscellaneous -Function = GetEnvironmentVariableA -Name = Positive Test for GetEnvironmentVariableA -TYPE = DEFAULT -EXE1 = test -Description -= Set an Environment Variable, then use GetEnvironmentVariable -= to retrieve it ensure that it retrieves properly. - - - diff --git a/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableA/test5/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableA/test5/CMakeLists.txt deleted file mode 100644 index 8e6e26363..000000000 --- a/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableA/test5/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test5.cpp -) - -add_executable(paltest_getenvironmentvariablea_test5 - ${SOURCES} -) - -add_dependencies(paltest_getenvironmentvariablea_test5 coreclrpal) - -target_link_libraries(paltest_getenvironmentvariablea_test5 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableA/test5/test5.cpp b/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableA/test5/test5.cpp deleted file mode 100644 index 19a4d25b6..000000000 --- a/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableA/test5/test5.cpp +++ /dev/null @@ -1,145 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** Source : test5.c -** -** Purpose: Test for GetEnvironmentVariableA() function -** Create environment variables that differ only -** in case and verify that they return the appropriate -** value on the BSD environment. -** -** -===========================================================*/ - -#include - -int __cdecl main(int argc, char *argv[]) -{ - -#if WIN32 - - return PASS; - -#else - - /* Define some buffers needed for the function */ - char * pResultBuffer = NULL; - - char FirstEnvironmentVariable[] = {"PALTEST"}; - char FirstEnvironmentValue[] = {"FIRST"}; - - char SecondEnvironmentVariable[] = {"paltest"}; - char SecondEnvironmentValue[] = {"SECOND"}; - - DWORD size = 0; - BOOL bRc = TRUE; - - /* - * Initialize the PAL and return FAILURE if this fails - */ - - if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - /* Set the first environment variable */ - bRc = SetEnvironmentVariableA(FirstEnvironmentVariable, - FirstEnvironmentValue); - - if(!bRc) - { - Fail("ERROR: SetEnvironmentVariable failed to set a " - "proper environment variable with error %u.\n", GetLastError()); - } - - - /* Normal case, PATH should fit into this buffer */ - size = GetEnvironmentVariableA(FirstEnvironmentVariable, - pResultBuffer, - 0); - - /* To account for the null character at the end of the string */ - size = size + 1; - - pResultBuffer = (char*)malloc(sizeof(char)*size); - if ( pResultBuffer == NULL ) - { - Fail("ERROR: Failed to allocate memory for pResultBuffer pointer\n."); - } - - /* Try to retrieve the value of the first environment variable */ - GetEnvironmentVariableA(FirstEnvironmentVariable, - pResultBuffer, - size); - - if ( pResultBuffer == NULL ) - { - free(pResultBuffer); - Fail("ERROR: GetEnvironmentVariable failed to return a value " - "from a proper environment variable with error %u.\n", - GetLastError()); - } - - /* Compare the strings to see that the correct variable was returned */ - if(strcmp(pResultBuffer,FirstEnvironmentValue) != 0) - { - free(pResultBuffer); - Fail("ERROR: The value in the buffer should have been '%s' but " - "was really '%s'.\n",FirstEnvironmentValue, pResultBuffer); - } - - free(pResultBuffer); - - /* Set the second environment Variable */ - bRc = SetEnvironmentVariableA(SecondEnvironmentVariable, - SecondEnvironmentValue); - - if(!bRc) - { - Fail("ERROR: SetEnvironmentVariable failed to set a " - "proper environment variable with error %u.\n", - GetLastError()); - } - - /* Reallocate the memory for the string */ - pResultBuffer = (char*)malloc(sizeof(char)*size); - if ( pResultBuffer == NULL ) - { - Fail("ERROR: Failed to allocate memory for pResultBuffer pointer."); - } - - /* Try retrieving the value of the first variable, even though the - second variable has the same spelling and only differs in case */ - GetEnvironmentVariableA(FirstEnvironmentVariable, - pResultBuffer, - size); - - if ( pResultBuffer == NULL ) - { - free(pResultBuffer); - Fail("ERROR: GetEnvironmentVariable failed to return a value " - "from a proper environment variable with error %u.\n", - GetLastError()); - } - - /* Compare the two strings to confirm that the right value is returned */ - if(strcmp(pResultBuffer,FirstEnvironmentValue) != 0) - { - free(pResultBuffer); - Fail("ERROR: The value in the buffer should have been '%s' but " - "was really '%s'.\n",FirstEnvironmentValue,pResultBuffer); - } - - free(pResultBuffer); - - PAL_Terminate(); - return PASS; - -#endif -} - - - diff --git a/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableA/test5/testinfo.dat b/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableA/test5/testinfo.dat deleted file mode 100644 index 0bcec5973..000000000 --- a/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableA/test5/testinfo.dat +++ /dev/null @@ -1,17 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Miscellaneous -Function = GetEnvironmentVariableA -Name = Positive Test for GetEnvironmentVariableA -TYPE = DEFAULT -EXE1 = test5 -Description -= Set environment variables that differ only in case -= and verify that on BSD they return two different -= values. - - - diff --git a/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableA/test6/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableA/test6/CMakeLists.txt deleted file mode 100644 index ac25f769f..000000000 --- a/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableA/test6/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test6.cpp -) - -add_executable(paltest_getenvironmentvariablea_test6 - ${SOURCES} -) - -add_dependencies(paltest_getenvironmentvariablea_test6 coreclrpal) - -target_link_libraries(paltest_getenvironmentvariablea_test6 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableA/test6/test6.cpp b/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableA/test6/test6.cpp deleted file mode 100644 index 837036a0a..000000000 --- a/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableA/test6/test6.cpp +++ /dev/null @@ -1,99 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** Source : test6.c -** -** Purpose: Test for GetEnvironmentVariableA() function -** Create environment variables that differ only -** in case and verify that they return the appropriate -** value on the BSD environment. -** - -** -===========================================================*/ - -#include - -int __cdecl main(int argc, char *argv[]) -{ - -#if WIN32 - - /* Define some buffers needed for the function */ - char * pResultBuffer = NULL; - - char FirstEnvironmentVariable[] = {"PALTEST"}; - char FirstEnvironmentValue[] = {"FIRST"}; - char ModifiedEnvVar[] = {"paltest"}; - - DWORD size = 0; - BOOL bRc = TRUE; - - /* - * Initialize the PAL and return FAILURE if this fails - */ - - if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - /* Set the first environment variable */ - bRc = SetEnvironmentVariableA(FirstEnvironmentVariable, - FirstEnvironmentValue); - - if(!bRc) - { - Fail("ERROR: SetEnvironmentVariable failed to set a " - "proper environment variable with error %u.\n", - GetLastError()); - } - - /* Normal case, PATH should fit into this buffer */ - size = GetEnvironmentVariableA(ModifiedEnvVar, - pResultBuffer, - 0); - - /* To account for the nul character at the end of the string */ - size = size + 1; - - pResultBuffer = (char*)malloc(sizeof(char)*size); - if ( pResultBuffer == NULL ) - { - Fail("ERROR: Failed to allocate memory for pResultBuffer pointer.\n"); - } - - /* Try to retrieve the value of the first environment variable */ - GetEnvironmentVariableA(ModifiedEnvVar, - pResultBuffer, - size); - - if ( pResultBuffer == NULL ) - { - free(pResultBuffer); - Fail("ERROR: GetEnvironmentVariable failed to return a value " - "from a proper environment variable with error %u.\n", - GetLastError()); - } - - /* Compare the strings to see that the correct variable was returned */ - if(strcmp(pResultBuffer,FirstEnvironmentValue) != 0) - { - free(pResultBuffer); - Fail("ERROR: The value in the buffer should have been '%s' but " - "was really '%s'.\n",FirstEnvironmentValue, pResultBuffer); - } - - free(pResultBuffer); - - PAL_Terminate(); - return PASS; - - -#else - - return PASS; -#endif -} diff --git a/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableA/test6/testinfo.dat b/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableA/test6/testinfo.dat deleted file mode 100644 index 5de219a95..000000000 --- a/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableA/test6/testinfo.dat +++ /dev/null @@ -1,15 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Miscellaneous -Function = GetEnvironmentVariableA -Name = Positive Test for GetEnvironmentVariableA -TYPE = DEFAULT -EXE1 = test6 -Description -= Set an Environment Variable, then use GetEnvironmentVariable -= to retrieve the Variable, using a name that differs only in -= Case. In Windows this should not affect the return value -= of the function. diff --git a/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableW/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableW/CMakeLists.txt deleted file mode 100644 index 7c2017935..000000000 --- a/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableW/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) -add_subdirectory(test3) -add_subdirectory(test4) -add_subdirectory(test5) -add_subdirectory(test6) - diff --git a/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableW/test1/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableW/test1/CMakeLists.txt deleted file mode 100644 index e87cbf4da..000000000 --- a/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableW/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test.cpp -) - -add_executable(paltest_getenvironmentvariablew_test1 - ${SOURCES} -) - -add_dependencies(paltest_getenvironmentvariablew_test1 coreclrpal) - -target_link_libraries(paltest_getenvironmentvariablew_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableW/test1/test.cpp b/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableW/test1/test.cpp deleted file mode 100644 index cb5fc0055..000000000 --- a/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableW/test1/test.cpp +++ /dev/null @@ -1,79 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source : test.c -** -** Purpose: Test for GetEnvironmentVariable() function -** -** -**=========================================================*/ - -#define UNICODE -#include - -int __cdecl main(int argc, char *argv[]) -{ - - /* Define some buffers needed for the function */ - WCHAR * pResultBuffer = NULL; - int size = 0; - - /* A place to stash the returned values */ - int ReturnValueForLargeBuffer = 0; - - /* - * Initialize the PAL and return FAILURE if this fails - */ - - if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - /* Recieve and allocate the correct amount of memory for the buffer */ - size = ReturnValueForLargeBuffer = - GetEnvironmentVariable(convert("PATH"), - pResultBuffer, - 0); - - pResultBuffer = (WCHAR*)malloc(size*sizeof(WCHAR)); - if ( pResultBuffer == NULL ) - { - Fail("ERROR: Failed to allocate memory for pResultBuffer pointer. " - "Can't properly exec test case without this.\n"); - } - - - /* Normal case, PATH should fit into this buffer */ - ReturnValueForLargeBuffer = GetEnvironmentVariable(convert("PATH"), - pResultBuffer, - size); - free(pResultBuffer); - - /* Ensure that it returned a positive value */ - if(ReturnValueForLargeBuffer <= 0) - { - Fail("The return was %d, which indicates that the function failed.\n", - ReturnValueForLargeBuffer); - } - - /* Ensure that it succeeded and copied the correct number of characters. - If this is true, then the return value should be one less of the - size of the buffer. (Doesn't include that NULL byte) - */ - if(ReturnValueForLargeBuffer != size-1) - { - Fail("The value returned was %d when it should have been %d. This " - "should be the number of characters copied, " - "minus the NULL byte.\n", ReturnValueForLargeBuffer, size-1); - } - - PAL_Terminate(); - return PASS; -} - - - diff --git a/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableW/test1/testinfo.dat b/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableW/test1/testinfo.dat deleted file mode 100644 index 467f2b7b9..000000000 --- a/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableW/test1/testinfo.dat +++ /dev/null @@ -1,16 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Miscellaneous -Function = GetEnvironmentVariableW -Name = Return value test for GetEnvironmentVariableW -TYPE = DEFAULT -EXE1 = test -Description -= Assign a properly sized buffer and get an environment variable, -= check to ensure it returns the correct values. - - - diff --git a/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableW/test2/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableW/test2/CMakeLists.txt deleted file mode 100644 index 2e6f61a4b..000000000 --- a/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableW/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test.cpp -) - -add_executable(paltest_getenvironmentvariablew_test2 - ${SOURCES} -) - -add_dependencies(paltest_getenvironmentvariablew_test2 coreclrpal) - -target_link_libraries(paltest_getenvironmentvariablew_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableW/test2/test.cpp b/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableW/test2/test.cpp deleted file mode 100644 index 6fa753c8d..000000000 --- a/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableW/test2/test.cpp +++ /dev/null @@ -1,56 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source : test.c -** -** Purpose: Test for GetEnvironmentVariable() function -** -** -**=========================================================*/ - -#define UNICODE - -#include - -#define SMALL_BUFFER_SIZE 1 - -int __cdecl main(int argc, char *argv[]) -{ - - WCHAR pSmallBuffer[SMALL_BUFFER_SIZE]; - - /* A place to stash the returned values */ - int ReturnValueForSmallBuffer; - - /* - * Initialize the PAL and return FAILURE if this fails - */ - - if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - /* PATH won't fit in this buffer, it should return how many characters - it needs - */ - - ReturnValueForSmallBuffer = GetEnvironmentVariable(convert("PATH"), - pSmallBuffer, - SMALL_BUFFER_SIZE); - - if(ReturnValueForSmallBuffer <= 0) - { - Fail("The return value was %d when it should have been greater " - "than 0. This should return the number of characters needed " - "to contained the contents of PATH in a buffer.\n", - ReturnValueForSmallBuffer); - } - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableW/test2/testinfo.dat b/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableW/test2/testinfo.dat deleted file mode 100644 index 372f5af31..000000000 --- a/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableW/test2/testinfo.dat +++ /dev/null @@ -1,16 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Miscellaneous -Function = GetEnvironmentVariableW -Name = Return value test on GetEnvironmentVariableW -TYPE = DEFAULT -EXE1 = test -Description -= Pass a small buffer to GetEnvironmentVariableW -= to ensure it returns the size it requires. - - - diff --git a/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableW/test3/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableW/test3/CMakeLists.txt deleted file mode 100644 index 70151c419..000000000 --- a/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableW/test3/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test.cpp -) - -add_executable(paltest_getenvironmentvariablew_test3 - ${SOURCES} -) - -add_dependencies(paltest_getenvironmentvariablew_test3 coreclrpal) - -target_link_libraries(paltest_getenvironmentvariablew_test3 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableW/test3/test.cpp b/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableW/test3/test.cpp deleted file mode 100644 index 03781e723..000000000 --- a/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableW/test3/test.cpp +++ /dev/null @@ -1,71 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source : test.c -** -** Purpose: Test for GetEnvironmentVariable() function -** -** -**=========================================================*/ - -#define UNICODE -#include - -#define BUFFER_SIZE 5000 -#define SMALL_BUFFER_SIZE 5 - -int __cdecl main(int argc, char *argv[]) -{ - - /* Define some buffers needed for the function */ - WCHAR pResultBuffer[BUFFER_SIZE]; - WCHAR pSmallBuffer[SMALL_BUFFER_SIZE]; - - /* A place to stash the returned values */ - int ReturnValueForNonExisting, ReturnValueForNull; - - /* - * Initialize the PAL and return FAILURE if this fails - */ - - if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - /* This variable doesn't exist, it should return 0 */ - ReturnValueForNonExisting = - GetEnvironmentVariable(convert("NonExistingVariable"), - pSmallBuffer, - SMALL_BUFFER_SIZE); - - if(ReturnValueForNonExisting != 0) - { - Fail("ERROR: The return should have been 0, but it was %d. The " - "function attempted to get an Environment Variable that doesn't " - "exist and should return 0 as a result.\n", - ReturnValueForNonExisting); - } - - - /* Passing a NULL string should return 0 */ - ReturnValueForNull = GetEnvironmentVariable(NULL, - pResultBuffer, - BUFFER_SIZE); - - if(ReturnValueForNull != 0) - { - Fail("ERROR: The return should have been 0, but it was %d. The " - "function attempted to get a NULL pointer and should return 0 " - "as a result.\n",ReturnValueForNull); - } - - - PAL_Terminate(); - return PASS; -} - - diff --git a/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableW/test3/testinfo.dat b/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableW/test3/testinfo.dat deleted file mode 100644 index d41c19c90..000000000 --- a/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableW/test3/testinfo.dat +++ /dev/null @@ -1,16 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Miscellaneous -Function = GetEnvironmentVariableW -Name = Return value test for GetEnvironmentVariableW -TYPE = DEFAULT -EXE1 = test -Description -= Pass a nonexisting environment variable and a null to the function -= to check return values. - - - diff --git a/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableW/test4/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableW/test4/CMakeLists.txt deleted file mode 100644 index 56de6a1cc..000000000 --- a/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableW/test4/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test.cpp -) - -add_executable(paltest_getenvironmentvariablew_test4 - ${SOURCES} -) - -add_dependencies(paltest_getenvironmentvariablew_test4 coreclrpal) - -target_link_libraries(paltest_getenvironmentvariablew_test4 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableW/test4/test.cpp b/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableW/test4/test.cpp deleted file mode 100644 index 1ee3e72c9..000000000 --- a/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableW/test4/test.cpp +++ /dev/null @@ -1,63 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source : test.c -** -** Purpose: Test for GetEnvironmentVariable() function -** -** -**=========================================================*/ - -/* Depends on SetEnvironmentVariableW (because we're implmenting the wide - version) and strcmp() */ - -#define UNICODE -#include - -int __cdecl main(int argc, char *argv[]) { - - /* Define some buffers needed for the function */ - WCHAR * pResultBuffer = NULL; - WCHAR SomeEnvironmentVariable[] = {'P','A','L','T','E','S','T','\0'}; - WCHAR TheEnvironmentValue[] = {'T','E','S','T','\0'}; - int size; - - /* - * Initialize the PAL and return FAILURE if this fails - */ - - if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - SetEnvironmentVariable(SomeEnvironmentVariable, - TheEnvironmentValue); - - - /* Normal case, PATH should fit into this buffer */ - size = GetEnvironmentVariable(convert("PALTEST"), // Variable Name - pResultBuffer, // Buffer for Value - 0); // Buffer size - - pResultBuffer = (WCHAR*)malloc(size*sizeof(WCHAR)); - - GetEnvironmentVariable(convert("PALTEST"), - pResultBuffer, - size); - - if(wcsncmp(pResultBuffer,convert("TEST"),wcslen(pResultBuffer) * 2) != 0) - { - Fail("ERROR: The value in the buffer should have been 'TEST' but was " - "really '%s'.",convertC(pResultBuffer)); - } - - free(pResultBuffer); - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableW/test4/testinfo.dat b/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableW/test4/testinfo.dat deleted file mode 100644 index 64204fa69..000000000 --- a/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableW/test4/testinfo.dat +++ /dev/null @@ -1,16 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Miscellaneous -Function = GetEnvironmentVariableW -Name = Positive Test for GetEnvironmentVariableW -TYPE = DEFAULT -EXE1 = test -Description -= Set an Environment Variable, then use GetEnvironmentVariable -= to retrieve it -- ensure that it retrieves properly. - - - diff --git a/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableW/test5/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableW/test5/CMakeLists.txt deleted file mode 100644 index 9d73780c9..000000000 --- a/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableW/test5/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test5.cpp -) - -add_executable(paltest_getenvironmentvariablew_test5 - ${SOURCES} -) - -add_dependencies(paltest_getenvironmentvariablew_test5 coreclrpal) - -target_link_libraries(paltest_getenvironmentvariablew_test5 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableW/test5/test5.cpp b/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableW/test5/test5.cpp deleted file mode 100644 index 179fc17f0..000000000 --- a/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableW/test5/test5.cpp +++ /dev/null @@ -1,144 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** Source : test5.c -** -** Purpose: Test for GetEnvironmentVariableW() function -** Create environment variables that differ only -** in case and verify that they return the appropriate -** value on the BSD environment. -** -** -===========================================================*/ - -#include - -int __cdecl main(int argc, char *argv[]) -{ - -#if WIN32 - - return PASS; - -#else - - /* Define some buffers needed for the function */ - WCHAR * pResultBuffer = NULL; - - WCHAR FirstEnvironmentVariable[] = {'P','A','L','T','E','S','T','\0'}; - WCHAR FirstEnvironmentValue[] = {'F','I','R','S','T','\0'}; - - WCHAR SecondEnvironmentVariable[] = {'p','a','l','t','e','s','t','\0'}; - WCHAR SecondEnvironmentValue[] = {'S','E','C','O','N','D','\0'}; - - DWORD size = 0; - BOOL bRc = TRUE; - - /* - * Initialize the PAL and return FAILURE if this fails - */ - - if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - /* Set the first environment variable */ - bRc = SetEnvironmentVariableW(FirstEnvironmentVariable, - FirstEnvironmentValue); - - if(!bRc) - { - Fail("ERROR: SetEnvironmentVariable failed to set a " - "proper environment variable with error %u.\n", GetLastError()); - } - - /* Normal case, PATH should fit into this buffer */ - size = GetEnvironmentVariableW(FirstEnvironmentVariable, - pResultBuffer, - 0); - - /* To account for the nul character at the end of the string */ - size = size + 1; - - pResultBuffer = (WCHAR*)malloc(sizeof(WCHAR)*size); - if ( pResultBuffer == NULL ) - { - Fail("ERROR: Failed to allocate memory for pResultBuffer pointer.\n"); - } - - /* Try to retrieve the value of the first environment variable */ - GetEnvironmentVariableW(FirstEnvironmentVariable, - pResultBuffer, - size); - - if ( pResultBuffer == NULL ) - { - free(pResultBuffer); - Fail("ERROR: GetEnvironmentVariable failed to return a value " - "from a proper environment variable with error %u.\n", - GetLastError()); - } - - /* Compare the strings to see that the correct variable was returned */ - if(wcsncmp(pResultBuffer,FirstEnvironmentValue,wcslen(pResultBuffer)) != 0) - { - free(pResultBuffer); - Fail("ERROR: The value in the buffer should have been '%S' but " - "was really '%S'.\n",FirstEnvironmentValue, pResultBuffer); - } - - free(pResultBuffer); - - /* Set the second environment Variable */ - bRc = SetEnvironmentVariableW(SecondEnvironmentVariable, - SecondEnvironmentValue); - - if(!bRc) - { - Fail("ERROR: SetEnvironmentVariable failed to set a " - "proper environment variable with error %u.\n", - GetLastError()); - } - - /* Reallocate the memory for the string */ - pResultBuffer = (WCHAR*)malloc(sizeof(WCHAR)*size); - if ( pResultBuffer == NULL ) - { - Fail("ERROR: Failed to allocate memory for pResultBuffer pointer.\n"); - } - - /* Try retrieving the value of the first variable, even though the - second variable has the same spelling and only differs in case */ - GetEnvironmentVariableW(FirstEnvironmentVariable, - pResultBuffer, - size); - - if ( pResultBuffer == NULL ) - { - free(pResultBuffer); - Fail("ERROR: GetEnvironmentVariable failed to return a value " - "from a proper environment variable with error %u.\n", - GetLastError()); - } - - /* Compare the two strings to confirm that the right value is returned */ - if(wcsncmp(pResultBuffer,FirstEnvironmentValue,wcslen(pResultBuffer)) != 0) - { - free(pResultBuffer); - Fail("ERROR: The value in the buffer should have been '%S' but " - "was really '%S'.\n",FirstEnvironmentValue,pResultBuffer); - } - - free(pResultBuffer); - - PAL_Terminate(); - return PASS; - -#endif -} - - - diff --git a/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableW/test5/testinfo.dat b/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableW/test5/testinfo.dat deleted file mode 100644 index cbc214e8c..000000000 --- a/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableW/test5/testinfo.dat +++ /dev/null @@ -1,17 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Miscellaneous -Function = GetEnvironmentVariableW -Name = Positive Test for GetEnvironmentVariableW -TYPE = DEFAULT -EXE1 = test5 -Description -= Set an Environment Variable, then use GetEnvironmentVariable -= to retrieve it. Then set another environment variable that differs -= from the original variable only by case and verify that -= GetEnvironmnetVariable returns the correct value. - - diff --git a/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableW/test6/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableW/test6/CMakeLists.txt deleted file mode 100644 index f331a8974..000000000 --- a/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableW/test6/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test6.cpp -) - -add_executable(paltest_getenvironmentvariablew_test6 - ${SOURCES} -) - -add_dependencies(paltest_getenvironmentvariablew_test6 coreclrpal) - -target_link_libraries(paltest_getenvironmentvariablew_test6 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableW/test6/test6.cpp b/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableW/test6/test6.cpp deleted file mode 100644 index e37695084..000000000 --- a/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableW/test6/test6.cpp +++ /dev/null @@ -1,99 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** Source : test6.c -** -** Purpose: Test for GetEnvironmentVariableW() function -** Create environment variables that differ only -** in case and verify that they return the appropriate -** value on the BSD environment. -** -** -===========================================================*/ - -#include - -int __cdecl main(int argc, char *argv[]) -{ - -#if WIN32 - - /* Define some buffers needed for the function */ - WCHAR * pResultBuffer = NULL; - - WCHAR FirstEnvironmentVariable[] = {'P','A','L','T','E','S','T','\0'}; - WCHAR FirstEnvironmentValue[] = {'F','I','R','S','T','\0'}; - - WCHAR ModifiedEnvironmentVariable[] = {'p','a','l','t','e','s','t','\0'}; - - DWORD size = 0; - BOOL bRc = TRUE; - - /* - * Initialize the PAL and return FAILURE if this fails - */ - - if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - /* Set the first environment variable */ - bRc = SetEnvironmentVariableW(FirstEnvironmentVariable, - FirstEnvironmentValue); - - if(!bRc) - { - Fail("ERROR: SetEnvironmentVariable failed to set a " - "proper environment variable with error %u.\n", - GetLastError()); - } - - /* Normal case, PATH should fit into this buffer */ - size = GetEnvironmentVariableW(ModifiedEnvironmentVariable, - pResultBuffer, - 0); - - /* To account for the nul character at the end of the string */ - size = size + 1; - - pResultBuffer = (WCHAR*)malloc(sizeof(WCHAR)*size); - if ( pResultBuffer == NULL ) - { - Fail("ERROR: Failed to allocate memory for pResultBuffer pointer.\n"); - } - - /* Try to retrieve the value of the first environment variable */ - GetEnvironmentVariableW(ModifiedEnvironmentVariable, - pResultBuffer, - size); - - if ( pResultBuffer == NULL ) - { - free(pResultBuffer); - Fail("ERROR: GetEnvironmentVariable failed to return a value " - "from a proper environment variable with error %u.\n", - GetLastError()); - } - - /* Compare the strings to see that the correct variable was returned */ - if(wcsncmp(pResultBuffer,FirstEnvironmentValue,wcslen(pResultBuffer)) != 0) - { - free(pResultBuffer); - Fail("ERROR: The value in the buffer should have been '%S' but " - "was really '%S'.\n",FirstEnvironmentValue, pResultBuffer); - } - - free(pResultBuffer); - - PAL_Terminate(); - return PASS; - - -#else - - return PASS; -#endif -} diff --git a/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableW/test6/testinfo.dat b/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableW/test6/testinfo.dat deleted file mode 100644 index fad1ad69a..000000000 --- a/src/pal/tests/palsuite/miscellaneous/GetEnvironmentVariableW/test6/testinfo.dat +++ /dev/null @@ -1,15 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Miscellaneous -Function = GetEnvironmentVariableW -Name = Positive Test for GetEnvironmentVariableW -TYPE = DEFAULT -EXE1 = test6 -Description -= Set an Environment Variable, then use GetEnvironmentVariable -= to retrieve the Variable, using a name that differs only in -= Case. In Windows this should not affect the return value -= of the function. diff --git a/src/pal/tests/palsuite/miscellaneous/GetLastError/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/GetLastError/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/miscellaneous/GetLastError/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/miscellaneous/GetLastError/test1/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/GetLastError/test1/CMakeLists.txt deleted file mode 100644 index 1bf640731..000000000 --- a/src/pal/tests/palsuite/miscellaneous/GetLastError/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test.cpp -) - -add_executable(paltest_getlasterror_test1 - ${SOURCES} -) - -add_dependencies(paltest_getlasterror_test1 coreclrpal) - -target_link_libraries(paltest_getlasterror_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/miscellaneous/GetLastError/test1/test.cpp b/src/pal/tests/palsuite/miscellaneous/GetLastError/test1/test.cpp deleted file mode 100644 index 65f56e595..000000000 --- a/src/pal/tests/palsuite/miscellaneous/GetLastError/test1/test.cpp +++ /dev/null @@ -1,63 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source : test.c -** -** Purpose: Test for GetLastError() function -** -** -**=========================================================*/ - -/* Depends on SetLastError() */ - -#include - -/** - * Helper functions that does the actual test - */ -static void test(DWORD error ) -{ - DWORD TheResult; - - /* Set error */ - SetLastError(error); - - /* Check to make sure it returns the error value we just set */ - TheResult = GetLastError(); - if(TheResult!= error) - { - Fail("ERROR: The last error should have been %u, but when " - "GetLastError was called, it returned %u.\n",error,TheResult); - } - -} - -int __cdecl main(int argc, char *argv[]) { - - - /* - * Initialize the PAL and return FAILURE if this fails - */ - - if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - /* test setting and getting some values */ - test(5); - test(0xffffffff); - test(0xEEEEEEEE); - test(0xAAAAAAAA); - - PAL_Terminate(); - return PASS; -} - - - - - diff --git a/src/pal/tests/palsuite/miscellaneous/GetLastError/test1/testinfo.dat b/src/pal/tests/palsuite/miscellaneous/GetLastError/test1/testinfo.dat deleted file mode 100644 index be41f52c6..000000000 --- a/src/pal/tests/palsuite/miscellaneous/GetLastError/test1/testinfo.dat +++ /dev/null @@ -1,15 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Miscellaneous -Function = GetLastError -Name = Positive Test for GetLastError -TYPE = DEFAULT -EXE1 = test -Description -= Ensure GetLastError returns the error message which was set. - - - diff --git a/src/pal/tests/palsuite/miscellaneous/GetSystemInfo/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/GetSystemInfo/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/miscellaneous/GetSystemInfo/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/miscellaneous/GetSystemInfo/test1/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/GetSystemInfo/test1/CMakeLists.txt deleted file mode 100644 index 3fd07c4de..000000000 --- a/src/pal/tests/palsuite/miscellaneous/GetSystemInfo/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test.cpp -) - -add_executable(paltest_getsysteminfo_test1 - ${SOURCES} -) - -add_dependencies(paltest_getsysteminfo_test1 coreclrpal) - -target_link_libraries(paltest_getsysteminfo_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/miscellaneous/GetSystemInfo/test1/test.cpp b/src/pal/tests/palsuite/miscellaneous/GetSystemInfo/test1/test.cpp deleted file mode 100644 index 5f3608fb7..000000000 --- a/src/pal/tests/palsuite/miscellaneous/GetSystemInfo/test1/test.cpp +++ /dev/null @@ -1,70 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source : test.c -** -** Purpose: Test for GetSystemInfo() function -** -** -**=========================================================*/ - -#include - -int __cdecl main(int argc, char *argv[]) { - - SYSTEM_INFO TheSystemInfo; - SYSTEM_INFO* pSystemInfo = &TheSystemInfo; - - /* - * Initialize the PAL and return FAILURE if this fails - */ - - if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - GetSystemInfo(pSystemInfo); - - /* Ensure both valules are > than 0 */ - if(pSystemInfo->dwNumberOfProcessors < 1) - { - Fail("ERROR: The dwNumberofProcessors values should be > 0."); - } - - if(pSystemInfo->dwPageSize < 1) - { - Fail("ERROR: The dwPageSize should be greater than 0."); - } - - /* If this isn't WIN32, ensure all the other variables are 0 */ - -#if UNIX - if(pSystemInfo->dwOemId != 0 || - pSystemInfo->wProcessorArchitecture != 0 || - pSystemInfo->wReserved != 0 || - pSystemInfo->lpMinimumApplicationAddress != 0 || - pSystemInfo->lpMaximumApplicationAddress != 0 || - pSystemInfo->dwActiveProcessorMask != 0 || - pSystemInfo->dwProcessorType !=0 || - pSystemInfo->dwAllocationGranularity !=0 || - pSystemInfo->wProcessorLevel != 0 || - pSystemInfo->wProcessorRevision != 0) { - Fail("ERROR: Under FreeBSD, OemId, ProcessorArchitecture, Reserved, " - "MinimumApplicationAddress, MaximumApplicationAddress, " - "ActiveProcessorMask, ProcessorType, AllocationGranularity, " - "ProcessorLevel and ProcessorRevision should be equal to 0."); - - - } -#endif - - - PAL_Terminate(); - return PASS; -} - - diff --git a/src/pal/tests/palsuite/miscellaneous/GetSystemInfo/test1/testinfo.dat b/src/pal/tests/palsuite/miscellaneous/GetSystemInfo/test1/testinfo.dat deleted file mode 100644 index 7f03c6355..000000000 --- a/src/pal/tests/palsuite/miscellaneous/GetSystemInfo/test1/testinfo.dat +++ /dev/null @@ -1,16 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Miscellaneous -Function = GetSystemInfo -Name = Positive Test for GetSystemInfo -TYPE = DEFAULT -EXE1 = test -Description -= Ensures the two required System Info fields can be aquired, -= and the others are all 0. - - - diff --git a/src/pal/tests/palsuite/miscellaneous/GetTickCount/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/GetTickCount/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/miscellaneous/GetTickCount/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/miscellaneous/GetTickCount/test1/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/GetTickCount/test1/CMakeLists.txt deleted file mode 100644 index fcf7cb4c0..000000000 --- a/src/pal/tests/palsuite/miscellaneous/GetTickCount/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test.cpp -) - -add_executable(paltest_gettickcount_test1 - ${SOURCES} -) - -add_dependencies(paltest_gettickcount_test1 coreclrpal) - -target_link_libraries(paltest_gettickcount_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/miscellaneous/GetTickCount/test1/test.cpp b/src/pal/tests/palsuite/miscellaneous/GetTickCount/test1/test.cpp deleted file mode 100644 index ad71ba5d6..000000000 --- a/src/pal/tests/palsuite/miscellaneous/GetTickCount/test1/test.cpp +++ /dev/null @@ -1,58 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source: -** -** Source : test1.c -** -** Purpose: Test for GetTickCount() function -** -** -**=========================================================*/ - -#include - -int __cdecl main(int argc, char *argv[]) { - - DWORD FirstCount = 0; - DWORD SecondCount = 0; - - /* - * Initialize the PAL and return FAILURE if this fails - */ - - if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - /* Grab a FirstCount, then loop for a bit to make the clock increase */ - FirstCount = GetTickCount(); - - /* Make sure some time passes */ - Sleep(60); //Since the get tick count is accurate within 55 milliseconds. - - /* Get a second count */ - SecondCount = GetTickCount(); - - /* Make sure the second one is bigger than the first. - This isn't the best test, but it at least shows that it's returning a - DWORD which is increasing. - */ - - if(FirstCount >= SecondCount) - { - Fail("ERROR: The first time (%d) was greater/equal than the second time " - " (%d). The tick count should have increased.\n", - FirstCount,SecondCount); - } - - PAL_Terminate(); - return PASS; -} - - - diff --git a/src/pal/tests/palsuite/miscellaneous/GetTickCount/test1/testinfo.dat b/src/pal/tests/palsuite/miscellaneous/GetTickCount/test1/testinfo.dat deleted file mode 100644 index 78888abd5..000000000 --- a/src/pal/tests/palsuite/miscellaneous/GetTickCount/test1/testinfo.dat +++ /dev/null @@ -1,16 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Miscellaneous -Function = GetTickCount -Name = Positive Test for GetTickCount -TYPE = DEFAULT -EXE1 = test -Description -= Grab two Tick Counts with this function, and ensure that -= the second is larger to show that the tick count is increasing. - - - diff --git a/src/pal/tests/palsuite/miscellaneous/GlobalMemoryStatusEx/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/GlobalMemoryStatusEx/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/miscellaneous/GlobalMemoryStatusEx/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/miscellaneous/GlobalMemoryStatusEx/test1/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/GlobalMemoryStatusEx/test1/CMakeLists.txt deleted file mode 100644 index 6e74f22ba..000000000 --- a/src/pal/tests/palsuite/miscellaneous/GlobalMemoryStatusEx/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test.cpp -) - -add_executable(paltest_globalmemorystatusex_test1 - ${SOURCES} -) - -add_dependencies(paltest_globalmemorystatusex_test1 coreclrpal) - -target_link_libraries(paltest_globalmemorystatusex_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/miscellaneous/GlobalMemoryStatusEx/test1/test.cpp b/src/pal/tests/palsuite/miscellaneous/GlobalMemoryStatusEx/test1/test.cpp deleted file mode 100644 index 460edade6..000000000 --- a/src/pal/tests/palsuite/miscellaneous/GlobalMemoryStatusEx/test1/test.cpp +++ /dev/null @@ -1,55 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source : test.c -** -** Purpose: Test for GlobalMemoryStatusEx() function -** -** -**=========================================================*/ - -#include - -int __cdecl main(int argc, char *argv[]) { - - MEMORYSTATUSEX memoryStatus; - - /* - * Initialize the PAL and return FAILURE if this fails - */ - - if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - if (!GlobalMemoryStatusEx(&memoryStatus)) - { - Fail("ERROR: GlobalMemoryStatusEx failed."); - } - - printf("GlobalMemoryStatusEx:\n"); - printf(" ullTotalPhys: %llu\n", memoryStatus.ullTotalPhys); - printf(" ullAvailPhys: %llu\n", memoryStatus.ullAvailPhys); - printf(" ullTotalVirtual: %llu\n", memoryStatus.ullTotalVirtual); - printf(" ullAvailVirtual: %llu\n", memoryStatus.ullAvailVirtual); - printf(" ullTotalPageFile: %llu\n", memoryStatus.ullTotalPageFile); - printf(" ullAvailPageFile: %llu\n", memoryStatus.ullAvailPageFile); - printf(" ullAvailExtendedVirtual: %llu\n", memoryStatus.ullAvailExtendedVirtual); - printf(" dwMemoryLoad: %u\n", memoryStatus.dwMemoryLoad); - - if (memoryStatus.ullTotalPhys == 0 || - memoryStatus.ullAvailPhys == 0 || - memoryStatus.ullTotalVirtual == 0 || - memoryStatus.ullAvailVirtual == 0 - ) - { - Fail("ERROR: GlobalMemoryStatusEx succeeded, but returned zero physical of virtual memory sizes."); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/miscellaneous/GlobalMemoryStatusEx/test1/testinfo.dat b/src/pal/tests/palsuite/miscellaneous/GlobalMemoryStatusEx/test1/testinfo.dat deleted file mode 100644 index 7ae3b5142..000000000 --- a/src/pal/tests/palsuite/miscellaneous/GlobalMemoryStatusEx/test1/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Miscellaneous -Function = GlobalMemoryStatusEx -Name = Positive Test for GlobalMemoryStatusEx -TYPE = DEFAULT -EXE1 = test -Description -= Ensures that invocation of GlobalMemoryStatusEx succeeds and -= that it returns nonzero virtual and physical memory sizes - diff --git a/src/pal/tests/palsuite/miscellaneous/InterLockedExchangeAdd/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/InterLockedExchangeAdd/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/miscellaneous/InterLockedExchangeAdd/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/miscellaneous/InterLockedExchangeAdd/test1/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/InterLockedExchangeAdd/test1/CMakeLists.txt deleted file mode 100644 index 47af14e0f..000000000 --- a/src/pal/tests/palsuite/miscellaneous/InterLockedExchangeAdd/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test.cpp -) - -add_executable(paltest_interlockedexchangeadd_test1 - ${SOURCES} -) - -add_dependencies(paltest_interlockedexchangeadd_test1 coreclrpal) - -target_link_libraries(paltest_interlockedexchangeadd_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/miscellaneous/InterLockedExchangeAdd/test1/test.cpp b/src/pal/tests/palsuite/miscellaneous/InterLockedExchangeAdd/test1/test.cpp deleted file mode 100644 index a68a1f609..000000000 --- a/src/pal/tests/palsuite/miscellaneous/InterLockedExchangeAdd/test1/test.cpp +++ /dev/null @@ -1,102 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source : test.c -** -** Purpose: InterlockedExchangeAdd() function -** -** -**=========================================================*/ - -/* -** The InterlockedExchangeAdd function performs an atomic addition of Value -** to the value pointed to by Addend. -** The result is stored in the address specified by Addend. -** The initial value of the variable pointed to by Addend is returned as the function value. -*/ -#include - -int __cdecl main(int argc, char *argv[]) -{ - - LONG TheReturn; - - LONG *ptrValue = NULL; - /* - * Initialize the PAL and return FAILURE if this fails - */ - - if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - - -#if defined(BIT64) - ptrValue = (LONG *) malloc(sizeof(LONG)); - - if(ptrValue == NULL) - { - Fail("Error:%d:Malloc failed for ptrValue\n", GetLastError()); - } - - *ptrValue = (LONG) 0; - - TheReturn = InterlockedExchangeAdd( ptrValue, (LONG) 5); - - - /* Added, it should be 5 now */ - if(*ptrValue != 5) - { - - Trace("ERROR: After an add operation, the value should be 5, " - "but it is really %d.", *ptrValue); - free(ptrValue); - Fail(""); - } - - /* Check to make sure the function returns the original value (5 in this case) */ - if(TheReturn != 0) - { - Trace("ERROR: The function should have returned the new value of %d " - "but instead returned %d.", *ptrValue, TheReturn); - free(ptrValue); - Fail(""); - } - - TheReturn = InterlockedExchangeAdd( ptrValue, (LONG) 1); - - - /* Added twice, it should be 6 now */ - if(*ptrValue != 6) - { - - Trace("ERROR: After having two add operations, the value should be 6, " - "but it is really %d.", *ptrValue); - free(ptrValue); - Fail(""); - } - - /* Check to make sure the function returns the original value (5 in this case) */ - if(TheReturn != 5) - { - Trace("ERROR: The function should have returned the new value of %d " - "but instead returned %d.", *ptrValue, TheReturn); - free(ptrValue); - Fail(""); - } - - free(ptrValue); -#endif - PAL_Terminate(); - return PASS; -} - - - - - diff --git a/src/pal/tests/palsuite/miscellaneous/InterlockedBit/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/InterlockedBit/CMakeLists.txt deleted file mode 100644 index ef14ea535..000000000 --- a/src/pal/tests/palsuite/miscellaneous/InterlockedBit/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) - diff --git a/src/pal/tests/palsuite/miscellaneous/InterlockedBit/test1/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/InterlockedBit/test1/CMakeLists.txt deleted file mode 100644 index 2fe88a3fa..000000000 --- a/src/pal/tests/palsuite/miscellaneous/InterlockedBit/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test.cpp -) - -add_executable(paltest_interlockedbit_test1 - ${SOURCES} -) - -add_dependencies(paltest_interlockedbit_test1 coreclrpal) - -target_link_libraries(paltest_interlockedbit_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/miscellaneous/InterlockedBit/test1/test.cpp b/src/pal/tests/palsuite/miscellaneous/InterlockedBit/test1/test.cpp deleted file mode 100644 index 1f7c43cdd..000000000 --- a/src/pal/tests/palsuite/miscellaneous/InterlockedBit/test1/test.cpp +++ /dev/null @@ -1,77 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source : test.c -** -** Purpose: Test for InterlockedBitTestAndReset() function -** -** -**=========================================================*/ - -#include - -typedef struct tag_TEST_DATA -{ - LONG baseValue; - UINT bitPosition; - LONG expectedValue; - UCHAR expectedReturnValue; -} TEST_DATA; - -TEST_DATA test_data[] = -{ - { (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[]) { - - /* - * Initialize the PAL and return FAILURE if this fails - */ - - if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - for (int i = 0; i < sizeof (test_data) / sizeof (TEST_DATA); i++) - { - LONG baseVal = test_data[i].baseValue; - LONG bitPosition = test_data[i].bitPosition; - - UCHAR ret = InterlockedBitTestAndReset( - &baseVal, /* Variable to manipulate */ - bitPosition); - - if (ret != test_data[i].expectedReturnValue) - { - Fail("ERROR: InterlockedBitTestAndReset(%d): Expected return value is %d," - "Actual return value is %d.", - i, - test_data[i].expectedReturnValue, - ret); - } - - if (baseVal != test_data[i].expectedValue) - { - Fail("ERROR: InterlockedBitTestAndReset(%d): Expected value is %x," - "Actual value is %x.", - i, - test_data[i].expectedValue, - baseVal); - } - - } - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/miscellaneous/InterlockedBit/test1/testinfo.dat b/src/pal/tests/palsuite/miscellaneous/InterlockedBit/test1/testinfo.dat deleted file mode 100644 index 677999906..000000000 --- a/src/pal/tests/palsuite/miscellaneous/InterlockedBit/test1/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Miscellaneous -Function = InterlockedBitTestAndReset -Name = Test for InterlockedBitTestAndReset -TYPE = DEFAULT -EXE1 = test -Description -Test validates that function InterlockedBitTestAndReset work as intended. - - diff --git a/src/pal/tests/palsuite/miscellaneous/InterlockedBit/test2/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/InterlockedBit/test2/CMakeLists.txt deleted file mode 100644 index 3a6854b84..000000000 --- a/src/pal/tests/palsuite/miscellaneous/InterlockedBit/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test.cpp -) - -add_executable(paltest_interlockedbit_test2 - ${SOURCES} -) - -add_dependencies(paltest_interlockedbit_test2 coreclrpal) - -target_link_libraries(paltest_interlockedbit_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/miscellaneous/InterlockedBit/test2/test.cpp b/src/pal/tests/palsuite/miscellaneous/InterlockedBit/test2/test.cpp deleted file mode 100644 index 4230c8a80..000000000 --- a/src/pal/tests/palsuite/miscellaneous/InterlockedBit/test2/test.cpp +++ /dev/null @@ -1,77 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source : test.c -** -** Purpose: Test for InterlockedBitTestAndSet() function -** -** -**=========================================================*/ - -#include - -typedef struct tag_TEST_DATA -{ - LONG baseValue; - UINT bitPosition; - LONG expectedValue; - UCHAR expectedReturnValue; -} TEST_DATA; - -TEST_DATA test_data[] = -{ - { (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[]) { - - /* - * Initialize the PAL and return FAILURE if this fails - */ - - if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - for (int i = 0; i < sizeof (test_data) / sizeof (TEST_DATA); i++) - { - LONG baseVal = test_data[i].baseValue; - LONG bitPosition = test_data[i].bitPosition; - - UCHAR ret = InterlockedBitTestAndSet( - &baseVal, /* Variable to manipulate */ - bitPosition); - - if (ret != test_data[i].expectedReturnValue) - { - Fail("ERROR: InterlockedBitTestAndSet(%d): Expected return value is %d," - "Actual return value is %d.", - i, - test_data[i].expectedReturnValue, - ret); - } - - if (baseVal != test_data[i].expectedValue) - { - Fail("ERROR: InterlockedBitTestAndSet(%d): Expected value is %x," - "Actual value is %x.", - i, - test_data[i].expectedValue, - baseVal); - } - - } - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/miscellaneous/InterlockedBit/test2/testinfo.dat b/src/pal/tests/palsuite/miscellaneous/InterlockedBit/test2/testinfo.dat deleted file mode 100644 index 3ad431701..000000000 --- a/src/pal/tests/palsuite/miscellaneous/InterlockedBit/test2/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Miscellaneous -Function = InterlockedBitTestAndSet -Name = Test for InterlockedBitTestAndSet -TYPE = DEFAULT -EXE1 = test -Description -Test validates that function InterlockedBitTestAndSet work as intended. - - diff --git a/src/pal/tests/palsuite/miscellaneous/InterlockedCompareExchange/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/InterlockedCompareExchange/CMakeLists.txt deleted file mode 100644 index ef14ea535..000000000 --- a/src/pal/tests/palsuite/miscellaneous/InterlockedCompareExchange/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) - diff --git a/src/pal/tests/palsuite/miscellaneous/InterlockedCompareExchange/test1/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/InterlockedCompareExchange/test1/CMakeLists.txt deleted file mode 100644 index e62ba779d..000000000 --- a/src/pal/tests/palsuite/miscellaneous/InterlockedCompareExchange/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test.cpp -) - -add_executable(paltest_interlockedcompareexchange_test1 - ${SOURCES} -) - -add_dependencies(paltest_interlockedcompareexchange_test1 coreclrpal) - -target_link_libraries(paltest_interlockedcompareexchange_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/miscellaneous/InterlockedCompareExchange/test1/test.cpp b/src/pal/tests/palsuite/miscellaneous/InterlockedCompareExchange/test1/test.cpp deleted file mode 100644 index 77f2c4c44..000000000 --- a/src/pal/tests/palsuite/miscellaneous/InterlockedCompareExchange/test1/test.cpp +++ /dev/null @@ -1,100 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source : test.c -** -** Purpose: Test for InterlockedCompareExchange() function -** -** -**=========================================================*/ - -/* This test is FINISHED. Note: The biggest feature of this function is that - it locks the value before it increments it -- in order to make it so only - one thread can access it. But, I really don't have a great test to make - sure it's thread safe. Any ideas? -*/ - -#include - -#define START_VALUE 0 -#define SECOND_VALUE 5 -#define THIRD_VALUE 10 - -int __cdecl main(int argc, char *argv[]) { - - int BaseVariableToManipulate = START_VALUE; - int ValueToExchange = SECOND_VALUE; - int TempValue; - int TheReturn; - - /* - * Initialize the PAL and return FAILURE if this fails - */ - - if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - /* Compare START_VALUE with BaseVariableToManipulate, they're equal, - so exchange - */ - - TheReturn = InterlockedCompareExchange( - &BaseVariableToManipulate, /* Destination */ - ValueToExchange, /* Exchange value */ - START_VALUE); /* Compare value */ - - /* Exchanged, these should be equal now */ - if(BaseVariableToManipulate != ValueToExchange) - { - Fail("ERROR: A successful compare and exchange should have occurred, " - "making the variable have the value of %d, as opposed to the " - "current value of %d.", - ValueToExchange,BaseVariableToManipulate); - } - - /* Check to make sure it returns the original number which - 'BaseVariableToManipulate' was set to. - */ - if(TheReturn != START_VALUE) - { - Fail("ERROR: The return value after the first exchange should be the " - "former value of the variable, which was %d, but it is now %d.", - START_VALUE,TheReturn); - } - - - - ValueToExchange = THIRD_VALUE; /* Give this a new value */ - TempValue = BaseVariableToManipulate; /* Note value of Base */ - - /* - Do an exchange where 'BaseVariableToManipulate' doesn't - match -- therefore the exchange shouldn't happen. - So, it should end up the same as the 'TempValue' we saved. - */ - - InterlockedCompareExchange(&BaseVariableToManipulate, - ValueToExchange, - START_VALUE); - - if(BaseVariableToManipulate != TempValue) - { - Fail("ERROR: An attempted exchange should have failed due to " - "the compare failing. But, it seems to have succeeded. The " - "value should be %d but is %d in this case.", - TempValue,BaseVariableToManipulate); - } - - PAL_Terminate(); - return PASS; -} - - - - - diff --git a/src/pal/tests/palsuite/miscellaneous/InterlockedCompareExchange/test1/testinfo.dat b/src/pal/tests/palsuite/miscellaneous/InterlockedCompareExchange/test1/testinfo.dat deleted file mode 100644 index 04b1dfe78..000000000 --- a/src/pal/tests/palsuite/miscellaneous/InterlockedCompareExchange/test1/testinfo.dat +++ /dev/null @@ -1,16 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Miscellaneous -Function = InterlockedCompareExchange -Name = Positive test of InterlockedCompareExchange -TYPE = DEFAULT -EXE1 = test -Description -= Test to see if both successful and unsuccessful compare exchanges workp -= roperly -- ie. Exchange and don't exchange. - - - diff --git a/src/pal/tests/palsuite/miscellaneous/InterlockedCompareExchange/test2/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/InterlockedCompareExchange/test2/CMakeLists.txt deleted file mode 100644 index ef7d64f72..000000000 --- a/src/pal/tests/palsuite/miscellaneous/InterlockedCompareExchange/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test.cpp -) - -add_executable(paltest_interlockedcompareexchange_test2 - ${SOURCES} -) - -add_dependencies(paltest_interlockedcompareexchange_test2 coreclrpal) - -target_link_libraries(paltest_interlockedcompareexchange_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/miscellaneous/InterlockedCompareExchange/test2/test.cpp b/src/pal/tests/palsuite/miscellaneous/InterlockedCompareExchange/test2/test.cpp deleted file mode 100644 index 902f626d4..000000000 --- a/src/pal/tests/palsuite/miscellaneous/InterlockedCompareExchange/test2/test.cpp +++ /dev/null @@ -1,168 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source : test.c -** -** Purpose: Test for InterlockedCompareExchange() function using multiple threads -** -** -**=========================================================*/ - - - -#include - -#define MAX_THREADS 10 -#define REPEAT_COUNT 10 - -//Global Variable Declaration -LONG g_Total = 0; -LONG Lock=0; - - -void ModifyGlobalResource(void); -void AcquireLock(PLONG pLock); -void ReleaseLock(PLONG pLock); - - - -//Main entry point of the program -int __cdecl main(int argc, char *argv[]) { - - int i = 0; - DWORD dwThreadID=0; - LONG totalOperations = 0; - - HANDLE hThread[MAX_THREADS]; - - /* - * Initialize the PAL and return FAILURE if this fails - */ - - if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - - totalOperations = MAX_THREADS * REPEAT_COUNT; - - - //Create MAX_THREADS threads that will operate on the global counter - for (i=0;i - -#define START_VALUE 0 -#define SECOND_VALUE 5 -#define THIRD_VALUE 10 - -int __cdecl main(int argc, char *argv[]) { - - LONGLONG BaseVariableToManipulate = START_VALUE; - LONGLONG ValueToExchange = SECOND_VALUE; - LONGLONG TempValue; - LONGLONG TheReturn; - - /* - * Initialize the PAL and return FAILURE if this fails - */ - - if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - -/* -** Run only on 64 bit platforms -*/ -#if defined(BIT64) - /* Compare START_VALUE with BaseVariableToManipulate, they're equal, - so exchange - */ - - TheReturn = InterlockedCompareExchange64( - &BaseVariableToManipulate, /* Destination */ - ValueToExchange, /* Exchange value */ - START_VALUE); /* Compare value */ - - /* Exchanged, these should be equal now */ - if(BaseVariableToManipulate != ValueToExchange) - { - Fail("ERROR: A successful compare and exchange should have occurred, " - "making the variable have the value of %ll, as opposed to the " - "current value of %ll.", - ValueToExchange,BaseVariableToManipulate); - } - - /* Check to make sure it returns the original number which - 'BaseVariableToManipulate' was set to. - */ - if(TheReturn != START_VALUE) - { - Fail("ERROR: The return value after the first exchange should be the " - "former value of the variable, which was %ll, but it is now %ll.", - START_VALUE,TheReturn); - - } - - - - ValueToExchange = THIRD_VALUE; /* Give this a new value */ - TempValue = BaseVariableToManipulate; /* Note value of Base */ - - /* - Do an exchange where 'BaseVariableToManipulate' doesn't - match -- therefore the exchange shouldn't happen. - So, it should end up the same as the 'TempValue' we saved. - */ - - InterlockedCompareExchange64(&BaseVariableToManipulate, - ValueToExchange, - START_VALUE); - - if(BaseVariableToManipulate != TempValue) - { - Fail("ERROR: An attempted exchange should have failed due to " - "the compare failing. But, it seems to have succeeded. The " - "value should be %ll but is %ll in this case.", - TempValue,BaseVariableToManipulate); - } - -#endif //if defined(BIT64) - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/miscellaneous/InterlockedCompareExchange64/test1/testinfo.dat b/src/pal/tests/palsuite/miscellaneous/InterlockedCompareExchange64/test1/testinfo.dat deleted file mode 100644 index 184927734..000000000 --- a/src/pal/tests/palsuite/miscellaneous/InterlockedCompareExchange64/test1/testinfo.dat +++ /dev/null @@ -1,16 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Miscellaneous -Function = InterlockedCompareExchange64 -Name = Positive test of InterlockedCompareExchange64 -TYPE = DEFAULT -EXE1 = test -Description -= Test to see if both successful and unsuccessful compare exchanges workp -= roperly -- ie. Exchange and don't exchange. - - - diff --git a/src/pal/tests/palsuite/miscellaneous/InterlockedCompareExchange64/test2/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/InterlockedCompareExchange64/test2/CMakeLists.txt deleted file mode 100644 index 0f8e390ac..000000000 --- a/src/pal/tests/palsuite/miscellaneous/InterlockedCompareExchange64/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test.cpp -) - -add_executable(paltest_interlockedcompareexchange64_test2 - ${SOURCES} -) - -add_dependencies(paltest_interlockedcompareexchange64_test2 coreclrpal) - -target_link_libraries(paltest_interlockedcompareexchange64_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/miscellaneous/InterlockedCompareExchange64/test2/test.cpp b/src/pal/tests/palsuite/miscellaneous/InterlockedCompareExchange64/test2/test.cpp deleted file mode 100644 index b2b0b6337..000000000 --- a/src/pal/tests/palsuite/miscellaneous/InterlockedCompareExchange64/test2/test.cpp +++ /dev/null @@ -1,104 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source : test.c -** -** Purpose: InterlockedIncrement64() function -** -** The test case spawns MAX_THREADS Threads, and each thread call InterlockedDecrement Function to decrement a -** global counter REPEAT_COUNT Times. The Test case sets the global counter to Zero at the begining of the test. -** The test cases passes if at the end the test the value of the global counter is MAX_THREADS * REPEAT_COUNT. -** -** -**=========================================================*/ - -#include -#define MAX_THREADS 64 -#define REPEAT_COUNT 10000 - -LONG GlobalCounter = 0; -void IncrementCounter(void); - -int __cdecl main(int argc, char *argv[]) -{ - - LONG TotalOperations=0; - int i=0; - DWORD dwThreadID = 0; - - HANDLE hThread[MAX_THREADS]; - - TotalOperations = MAX_THREADS * REPEAT_COUNT; - - GlobalCounter = 0; - - /* - * Initialize the PAL and return FAILURE if this fails - */ - - if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - /* - ** Run only on 64 bit platforms - */ - #if defined(BIT64) - - //Create MAX_THREADS threads that will operate on the global counter - for (i=0;i - -int __cdecl main(int argc, char *argv[]) -{ - - long StartValue = 5; - long NewValue = 10; - PVOID ReturnValue = NULL; - - /* - * Initialize the PAL and return FAILURE if this fails - */ - - if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - ReturnValue = InterlockedCompareExchangePointer((PVOID)&StartValue, - (PVOID)NewValue, - (PVOID)StartValue); - - /* StartValue and NewValue should be equal now */ - if(StartValue != NewValue) - { - Fail("ERROR: These values should be equal after the exchange. " - "They should both be %d, however the value that should have " - "been exchanged is %d.\n",NewValue,StartValue); - } - - /* Returnvalue should have been set to what 'StartValue' was - (5 in this case) - */ - - 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. " - "But, the return value was %d.\n",ReturnValue); - } - - /* This is a mismatch, so no exchange should happen */ - InterlockedCompareExchangePointer((PVOID)&StartValue, - ReturnValue, - ReturnValue); - if(StartValue != NewValue) - { - Fail("ERROR: The compare should have failed and no exchange should " - "have been made, but it seems the exchange still happened.\n"); - } - - - PAL_Terminate(); - return PASS; -} - - - - - - diff --git a/src/pal/tests/palsuite/miscellaneous/InterlockedCompareExchangePointer/test1/testinfo.dat b/src/pal/tests/palsuite/miscellaneous/InterlockedCompareExchangePointer/test1/testinfo.dat deleted file mode 100644 index d78515e7c..000000000 --- a/src/pal/tests/palsuite/miscellaneous/InterlockedCompareExchangePointer/test1/testinfo.dat +++ /dev/null @@ -1,16 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Miscellaneous -Function = InterlockedCompareExchangePointer -Name = Positive test of InterlockedCompareExchangePointer -TYPE = DEFAULT -EXE1 = test -Description -= Test to see if both successful and unsuccessful compare exchanges work -= properly -- ie. Exchange and don't exchange. - - - diff --git a/src/pal/tests/palsuite/miscellaneous/InterlockedDecrement/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/InterlockedDecrement/CMakeLists.txt deleted file mode 100644 index ef14ea535..000000000 --- a/src/pal/tests/palsuite/miscellaneous/InterlockedDecrement/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) - diff --git a/src/pal/tests/palsuite/miscellaneous/InterlockedDecrement/test1/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/InterlockedDecrement/test1/CMakeLists.txt deleted file mode 100644 index 54004bc9a..000000000 --- a/src/pal/tests/palsuite/miscellaneous/InterlockedDecrement/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test.cpp -) - -add_executable(paltest_interlockeddecrement_test1 - ${SOURCES} -) - -add_dependencies(paltest_interlockeddecrement_test1 coreclrpal) - -target_link_libraries(paltest_interlockeddecrement_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/miscellaneous/InterlockedDecrement/test1/test.cpp b/src/pal/tests/palsuite/miscellaneous/InterlockedDecrement/test1/test.cpp deleted file mode 100644 index 9c9a50c73..000000000 --- a/src/pal/tests/palsuite/miscellaneous/InterlockedDecrement/test1/test.cpp +++ /dev/null @@ -1,60 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source : test.c -** -** Purpose: InterlockedDecrement() function -** -** -**=========================================================*/ - -/* This test is FINISHED. Note: The biggest feature of this function is that - it locks the value before it increments it -- in order to make it so only - one thread can access it. But, I really don't have a great test to make - sure it's thread safe. Any ideas? -*/ - -#include - -int __cdecl main(int argc, char *argv[]) -{ - int TheValue = 0; - int TheReturn; - - /* - * Initialize the PAL and return FAILURE if this fails - */ - - if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - InterlockedDecrement(&TheValue); - TheReturn = InterlockedDecrement(&TheValue); - - /* Decremented twice, it should be -2 now */ - if(TheValue != -2) - { - Fail("ERROR: After being decremented twice, the value should be -2, " - "but it is really %d.",TheValue); - } - - /* Check to make sure it returns itself */ - if(TheReturn != TheValue) - { - Fail("ERROR: The function should have returned the new value of %d " - "but instead returned %d.",TheValue,TheReturn); - } - - PAL_Terminate(); - return PASS; -} - - - - - diff --git a/src/pal/tests/palsuite/miscellaneous/InterlockedDecrement/test1/testinfo.dat b/src/pal/tests/palsuite/miscellaneous/InterlockedDecrement/test1/testinfo.dat deleted file mode 100644 index 57ee3835c..000000000 --- a/src/pal/tests/palsuite/miscellaneous/InterlockedDecrement/test1/testinfo.dat +++ /dev/null @@ -1,16 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Miscellaneous -Function = InterlockedDecrement -Name = Positive test of InterlockedDecrement -TYPE = DEFAULT -EXE1 = test -Description -= Test to see if this decrements the variable correctly and -= has the correct return value. - - - diff --git a/src/pal/tests/palsuite/miscellaneous/InterlockedDecrement/test2/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/InterlockedDecrement/test2/CMakeLists.txt deleted file mode 100644 index cf049672e..000000000 --- a/src/pal/tests/palsuite/miscellaneous/InterlockedDecrement/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test.cpp -) - -add_executable(paltest_interlockeddecrement_test2 - ${SOURCES} -) - -add_dependencies(paltest_interlockeddecrement_test2 coreclrpal) - -target_link_libraries(paltest_interlockeddecrement_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/miscellaneous/InterlockedDecrement/test2/test.cpp b/src/pal/tests/palsuite/miscellaneous/InterlockedDecrement/test2/test.cpp deleted file mode 100644 index 2f214e29e..000000000 --- a/src/pal/tests/palsuite/miscellaneous/InterlockedDecrement/test2/test.cpp +++ /dev/null @@ -1,94 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source : test.c -** -** Purpose: InterlockedDecrement() function -** -** The test case spawns MAX_THREADS Threads, and each thread call InterlockedDecrement Function to decrement a -** global counter REPEAT_COUNT Times. The Test case sets the global counter to MAX_THREADS * REPEAT_COUNT -** at the begining of the test. The test cases passes if at the end the test the value of the global counter is Zero. -** -** -**=========================================================*/ - -#include -#define MAX_THREADS 64 -#define REPEAT_COUNT 10000 - -LONG GlobalCounter = 0; -void DecrementCounter(void); - -int __cdecl main(int argc, char *argv[]) -{ - - LONG TotalOperations=0; - int i=0; - DWORD dwThreadID = 0; - HANDLE hThread[MAX_THREADS]; - TotalOperations = MAX_THREADS * REPEAT_COUNT; - GlobalCounter = TotalOperations; - - /* - * Initialize the PAL and return FAILURE if this fails - */ - if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - //Create MAX_THREADS threads that will operate on the global counter - for (i=0;i - -int __cdecl main(int argc, char *argv[]) -{ - LONGLONG TheValue = 0; - LONGLONG TheReturn; - - /* - * Initialize the PAL and return FAILURE if this fails - */ - - if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - -/* -** Run only on 64 bit platforms -*/ -#if defined(BIT64) - /* Compare START_VALUE with BaseVariableToManipulate, they're equal, - so exchange - */ - InterlockedDecrement64(&TheValue); - TheReturn = InterlockedDecrement64(&TheValue); - - /* Decremented twice, it should be -2 now */ - if(TheValue != -2) - { - Fail("ERROR: After being decremented twice, the value should be -2, " - "but it is really %ll.",TheValue); - } - - /* Check to make sure it returns itself */ - if(TheReturn != TheValue) - { - Fail("ERROR: The function should have returned the new value of %d " - "but instead returned %ll.",TheValue,TheReturn); - } -#endif //defined(BIT64) - PAL_Terminate(); - return PASS; -} - - - - - diff --git a/src/pal/tests/palsuite/miscellaneous/InterlockedDecrement64/test1/testinfo.dat b/src/pal/tests/palsuite/miscellaneous/InterlockedDecrement64/test1/testinfo.dat deleted file mode 100644 index 8c5b1f087..000000000 --- a/src/pal/tests/palsuite/miscellaneous/InterlockedDecrement64/test1/testinfo.dat +++ /dev/null @@ -1,16 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Miscellaneous -Function = InterlockedDecrement64 -Name = Positive test of InterlockedDecrement64 -TYPE = DEFAULT -EXE1 = test -Description -= Test to see if this decrements the variable correctly and -= has the correct return value. - - - diff --git a/src/pal/tests/palsuite/miscellaneous/InterlockedDecrement64/test2/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/InterlockedDecrement64/test2/CMakeLists.txt deleted file mode 100644 index 0031928b5..000000000 --- a/src/pal/tests/palsuite/miscellaneous/InterlockedDecrement64/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test.cpp -) - -add_executable(paltest_interlockeddecrement64_test2 - ${SOURCES} -) - -add_dependencies(paltest_interlockeddecrement64_test2 coreclrpal) - -target_link_libraries(paltest_interlockeddecrement64_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/miscellaneous/InterlockedDecrement64/test2/test.cpp b/src/pal/tests/palsuite/miscellaneous/InterlockedDecrement64/test2/test.cpp deleted file mode 100644 index 98560a668..000000000 --- a/src/pal/tests/palsuite/miscellaneous/InterlockedDecrement64/test2/test.cpp +++ /dev/null @@ -1,99 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source : test.c -** -** Purpose: InterlockedDecrement64() function -** -** The test case spawns MAX_THREADS Threads, and each thread call InterlockedDecrement Function to decrement a -** global counter REPEAT_COUNT Times. The Test case sets the global counter to MAX_THREADS * REPEAT_COUNT -** at the begining of the test. The test cases passes if at the end the test the value of the global counter is Zero. -** -** -**=========================================================*/ - -#include -#define MAX_THREADS 64 -#define REPEAT_COUNT 10000 - -LONG GlobalCounter = 0; -void DecrementCounter(void); - -int __cdecl main(int argc, char *argv[]) -{ - LONG TotalOperations=0; - int i=0; - DWORD dwThreadID = 0; - HANDLE hThread[MAX_THREADS]; - TotalOperations = MAX_THREADS * REPEAT_COUNT; - GlobalCounter = TotalOperations; - - /* - * Initialize the PAL and return FAILURE if this fails - */ - - if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - #if defined(BIT64) - - //Create MAX_THREADS threads that will operate on the global counter - for (i=0;i - -#define START_VALUE 0 - -int __cdecl main(int argc, char *argv[]) { - - int TheValue = START_VALUE; - int NewValue = 5; - int TheReturn; - - /* - * Initialize the PAL and return FAILURE if this fails - */ - - if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - TheReturn = InterlockedExchange(&TheValue,NewValue); - - /* Compare the exchanged value with the value we exchanged it with. Should - be the same. - */ - if(TheValue != NewValue) - { - Fail("ERROR: The value which was exchanged should now be %d, but " - "instead it is %d.",NewValue,TheValue); - } - - /* Check to make sure it returns the origional number which 'TheValue' was - set to. - */ - - if(TheReturn != START_VALUE) - { - Fail("ERROR: The value returned should be the value before the " - "exchange happened, which was %d, but %d was returned.", - START_VALUE,TheReturn); - } - - - PAL_Terminate(); - return PASS; -} - - - - - diff --git a/src/pal/tests/palsuite/miscellaneous/InterlockedExchange/test1/testinfo.dat b/src/pal/tests/palsuite/miscellaneous/InterlockedExchange/test1/testinfo.dat deleted file mode 100644 index 4b7c20a42..000000000 --- a/src/pal/tests/palsuite/miscellaneous/InterlockedExchange/test1/testinfo.dat +++ /dev/null @@ -1,16 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Miscellaneous -Function = InterlockedExchange -Name = Positive test of InterlockedExchange -TYPE = DEFAULT -EXE1 = test -Description -= Test to see if this exchanges the variables correctly and -= has the correct return value. - - - diff --git a/src/pal/tests/palsuite/miscellaneous/InterlockedExchange64/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/InterlockedExchange64/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/miscellaneous/InterlockedExchange64/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/miscellaneous/InterlockedExchange64/test1/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/InterlockedExchange64/test1/CMakeLists.txt deleted file mode 100644 index 5a3e8c4ff..000000000 --- a/src/pal/tests/palsuite/miscellaneous/InterlockedExchange64/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test.cpp -) - -add_executable(paltest_interlockedexchange64_test1 - ${SOURCES} -) - -add_dependencies(paltest_interlockedexchange64_test1 coreclrpal) - -target_link_libraries(paltest_interlockedexchange64_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/miscellaneous/InterlockedExchange64/test1/test.cpp b/src/pal/tests/palsuite/miscellaneous/InterlockedExchange64/test1/test.cpp deleted file mode 100644 index 3dd1cddd9..000000000 --- a/src/pal/tests/palsuite/miscellaneous/InterlockedExchange64/test1/test.cpp +++ /dev/null @@ -1,74 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source: test.c -** -** Purpose: InterlockedExchange64() function -** -** -**=========================================================*/ - -/* This test is FINISHED. Note: The biggest feature of this function is that - it locks the value before it increments it -- in order to make it so only - one thread can access it. But, I really don't have a great test to make - sure it's thread safe. Any ideas? -*/ - -#include - -#define START_VALUE 0 - -int __cdecl main(int argc, char *argv[]) { - - LONGLONG TheValue = START_VALUE; - LONGLONG NewValue = 5; - LONGLONG TheReturn; - - /* - * Initialize the PAL and return FAILURE if this fails - */ - - if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - -/* -** Run only on 64 bit platforms -*/ -#if defined(BIT64) - - TheReturn = InterlockedExchange64(&TheValue,NewValue); - - /* Compare the exchanged value with the value we exchanged it with. Should - be the same. - */ - if(TheValue != NewValue) - { - Fail("ERROR: The value which was exchanged should now be %ll, but " - "instead it is %ll.",NewValue,TheValue); - } - - /* Check to make sure it returns the origional number which 'TheValue' was - set to. - */ - - if(TheReturn != START_VALUE) - { - Fail("ERROR: The value returned should be the value before the " - "exchange happened, which was %ll, but %ll was returned.", - START_VALUE,TheReturn); - } - -#endif // BIT64 - PAL_Terminate(); - return PASS; -} - - - - - diff --git a/src/pal/tests/palsuite/miscellaneous/InterlockedExchange64/test1/testinfo.dat b/src/pal/tests/palsuite/miscellaneous/InterlockedExchange64/test1/testinfo.dat deleted file mode 100644 index 3669e9961..000000000 --- a/src/pal/tests/palsuite/miscellaneous/InterlockedExchange64/test1/testinfo.dat +++ /dev/null @@ -1,16 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Miscellaneous -Function = InterlockedExchange64 -Name = Positive test of InterlockedExchange64 -TYPE = DEFAULT -EXE1 = test -Description -= Test to see if this exchanges the variables correctly and -= has the correct return value. - - - diff --git a/src/pal/tests/palsuite/miscellaneous/InterlockedExchangePointer/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/InterlockedExchangePointer/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/miscellaneous/InterlockedExchangePointer/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/miscellaneous/InterlockedExchangePointer/test1/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/InterlockedExchangePointer/test1/CMakeLists.txt deleted file mode 100644 index cbc30c144..000000000 --- a/src/pal/tests/palsuite/miscellaneous/InterlockedExchangePointer/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - InterlockedExchangePointer.cpp -) - -add_executable(paltest_interlockedexchangepointer_test1 - ${SOURCES} -) - -add_dependencies(paltest_interlockedexchangepointer_test1 coreclrpal) - -target_link_libraries(paltest_interlockedexchangepointer_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/miscellaneous/InterlockedExchangePointer/test1/InterlockedExchangePointer.cpp b/src/pal/tests/palsuite/miscellaneous/InterlockedExchangePointer/test1/InterlockedExchangePointer.cpp deleted file mode 100644 index d36c96724..000000000 --- a/src/pal/tests/palsuite/miscellaneous/InterlockedExchangePointer/test1/InterlockedExchangePointer.cpp +++ /dev/null @@ -1,64 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: InterlockedExchangePointer -** -** Purpose: Positive test the InterlockedExchangePointer API. -** Call InterlockedExchangePointer to exchange a pair of -** value -** -** -** -**============================================================*/ -#include - -int __cdecl main(int argc, char *argv[]) -{ - int err; - int i1 = 10; - int i2 = 20; - int *pOldValue = &i1; - int *pNewValue = &i2; - PVOID pReturnValue; - - /*Initialize the PAL environment*/ - err = PAL_Initialize(argc, argv); - if(0 != err) - { - return FAIL; - } - - - - /* - Testing - ======= - */ - - pReturnValue = InterlockedExchangePointer((PVOID)&pOldValue, - (PVOID)pNewValue); - /*check the returned value*/ - if(*(int *)pReturnValue != i1) - { - Fail("\nFailed to call InterlockedExchangePointer API, " - "return pointer does not point to the origional value\n"); - } - - /*check the exchanged value*/ - if(*pOldValue != *pNewValue) - { - Fail("\nFailed to call InterlockedExchangePointer API, " - "exchanged value is not right\n"); - } - - - - /* - Clean Up - */ - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/miscellaneous/InterlockedExchangePointer/test1/testinfo.dat b/src/pal/tests/palsuite/miscellaneous/InterlockedExchangePointer/test1/testinfo.dat deleted file mode 100644 index 5e0a36627..000000000 --- a/src/pal/tests/palsuite/miscellaneous/InterlockedExchangePointer/test1/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = miscellaneous -Function = InterlockedExchangePointer -Name = Pos test for InterlockedExchangePointer API to excnage a pair of value -TYPE = DEFAULT -EXE1 = interlockedexchangepointer -Description -=Test the InterlockedExchangePointer to exchange a pair of value diff --git a/src/pal/tests/palsuite/miscellaneous/InterlockedIncrement/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/InterlockedIncrement/CMakeLists.txt deleted file mode 100644 index ef14ea535..000000000 --- a/src/pal/tests/palsuite/miscellaneous/InterlockedIncrement/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) - diff --git a/src/pal/tests/palsuite/miscellaneous/InterlockedIncrement/test1/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/InterlockedIncrement/test1/CMakeLists.txt deleted file mode 100644 index 8689e5c37..000000000 --- a/src/pal/tests/palsuite/miscellaneous/InterlockedIncrement/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test.cpp -) - -add_executable(paltest_interlockedincrement_test1 - ${SOURCES} -) - -add_dependencies(paltest_interlockedincrement_test1 coreclrpal) - -target_link_libraries(paltest_interlockedincrement_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/miscellaneous/InterlockedIncrement/test1/test.cpp b/src/pal/tests/palsuite/miscellaneous/InterlockedIncrement/test1/test.cpp deleted file mode 100644 index 8b4b3e914..000000000 --- a/src/pal/tests/palsuite/miscellaneous/InterlockedIncrement/test1/test.cpp +++ /dev/null @@ -1,62 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source: test.c -** -** Purpose: InterlockedIncrement() function -** -** -**=========================================================*/ - -/* This test is FINISHED. Note: The biggest feature of this function is that - it locks the value before it increments it -- in order to make it so only - one thread can access it. But, I really don't have a great test to make - sure it's thread safe. Any ideas? Nothing I've tried has worked. -*/ - - -#include - -int __cdecl main(int argc, char *argv[]) -{ - - int TheValue = 0; - int TheReturn; - - /* - * Initialize the PAL and return FAILURE if this fails - */ - - if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - InterlockedIncrement(&TheValue); - TheReturn = InterlockedIncrement(&TheValue); - - /* Incremented twice, it should be 2 now */ - if(TheValue != 2) - { - Fail("ERROR: The value was incremented twice and shoud now be 2, " - "but it is really %d",TheValue); - } - - /* Check to make sure it returns itself */ - if(TheReturn != TheValue) - { - Fail("ERROR: The function should return the new value, which shoud " - "have been %d, but it returned %d.",TheValue,TheReturn); - } - - PAL_Terminate(); - return PASS; -} - - - - - diff --git a/src/pal/tests/palsuite/miscellaneous/InterlockedIncrement/test1/testinfo.dat b/src/pal/tests/palsuite/miscellaneous/InterlockedIncrement/test1/testinfo.dat deleted file mode 100644 index c30496003..000000000 --- a/src/pal/tests/palsuite/miscellaneous/InterlockedIncrement/test1/testinfo.dat +++ /dev/null @@ -1,16 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Miscellaneous -Function = InterlockedIncreement -Name = Positive test of InterlockedIncrement -TYPE = DEFAULT -EXE1 = test -Description -= Test to see if this increments the variable correctly and -= has the correct return value. - - - diff --git a/src/pal/tests/palsuite/miscellaneous/InterlockedIncrement/test2/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/InterlockedIncrement/test2/CMakeLists.txt deleted file mode 100644 index 049e0ed3f..000000000 --- a/src/pal/tests/palsuite/miscellaneous/InterlockedIncrement/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test.cpp -) - -add_executable(paltest_interlockedincrement_test2 - ${SOURCES} -) - -add_dependencies(paltest_interlockedincrement_test2 coreclrpal) - -target_link_libraries(paltest_interlockedincrement_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/miscellaneous/InterlockedIncrement/test2/test.cpp b/src/pal/tests/palsuite/miscellaneous/InterlockedIncrement/test2/test.cpp deleted file mode 100644 index 280a2ea70..000000000 --- a/src/pal/tests/palsuite/miscellaneous/InterlockedIncrement/test2/test.cpp +++ /dev/null @@ -1,95 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source : test.c -** -** Purpose: InterlockedIncrement() function -** -** The test case spawns MAX_THREADS Threads, and each thread call InterlockedDecrement Function to decrement a -** global counter REPEAT_COUNT Times. The Test case sets the global counter to Zero at the begining of the test. -** The test cases passes if at the end the test the value of the global counter is MAX_THREADS * REPEAT_COUNT. -** -** -**=========================================================*/ - -#include -#define MAX_THREADS 64 -#define REPEAT_COUNT 10000 - -LONG GlobalCounter = 0; - -void IncrementCounter(void); - - - -int __cdecl main(int argc, char *argv[]) -{ - - LONG TotalOperations=0; - int i=0; - DWORD dwThreadID = 0; - HANDLE hThread[MAX_THREADS]; - TotalOperations = MAX_THREADS * REPEAT_COUNT; - GlobalCounter = 0; - - /* - * Initialize the PAL and return FAILURE if this fails - */ - if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - //Create MAX_THREADS threads that will operate on the global counter - for (i=0;i - -int __cdecl main(int argc, char *argv[]) -{ - - LONGLONG TheValue = 0; - LONGLONG TheReturn; - - /* - * Initialize the PAL and return FAILURE if this fails - */ - - if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } -/* -** Run only on 64 bit platforms -*/ -#if defined(BIT64) - - InterlockedIncrement64(&TheValue); - TheReturn = InterlockedIncrement64(&TheValue); - - /* Incremented twice, it should be 2 now */ - if(TheValue != 2) - { - Fail("ERROR: The value was incremented twice and shoud now be 2, " - "but it is really %ll",TheValue); - } - - /* Check to make sure it returns itself */ - if(TheReturn != TheValue) - { - Fail("ERROR: The function should return the new value, which shoud " - "have been %d, but it returned %ll.",TheValue,TheReturn); - } - -#endif //defined(BIT64) - PAL_Terminate(); - return PASS; -} - - - - - diff --git a/src/pal/tests/palsuite/miscellaneous/InterlockedIncrement64/test1/testinfo.dat b/src/pal/tests/palsuite/miscellaneous/InterlockedIncrement64/test1/testinfo.dat deleted file mode 100644 index fff0c701c..000000000 --- a/src/pal/tests/palsuite/miscellaneous/InterlockedIncrement64/test1/testinfo.dat +++ /dev/null @@ -1,16 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Miscellaneous -Function = InterlockedIncrement64 -Name = Positive test of InterlockedIncrement64 -TYPE = DEFAULT -EXE1 = test -Description -= Test to see if this increments the variable correctly and -= has the correct return value. - - - diff --git a/src/pal/tests/palsuite/miscellaneous/InterlockedIncrement64/test2/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/InterlockedIncrement64/test2/CMakeLists.txt deleted file mode 100644 index ec8e0684d..000000000 --- a/src/pal/tests/palsuite/miscellaneous/InterlockedIncrement64/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test.cpp -) - -add_executable(paltest_interlockedincrement64_test2 - ${SOURCES} -) - -add_dependencies(paltest_interlockedincrement64_test2 coreclrpal) - -target_link_libraries(paltest_interlockedincrement64_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/miscellaneous/InterlockedIncrement64/test2/test.cpp b/src/pal/tests/palsuite/miscellaneous/InterlockedIncrement64/test2/test.cpp deleted file mode 100644 index ffddc9d41..000000000 --- a/src/pal/tests/palsuite/miscellaneous/InterlockedIncrement64/test2/test.cpp +++ /dev/null @@ -1,101 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source : test.c -** -** Purpose: InterlockedIncrement64() function -** -** The test case spawns MAX_THREADS Threads, and each thread call InterlockedDecrement Function to decrement a -** global counter REPEAT_COUNT Times. The Test case sets the global counter to Zero at the begining of the test. -** The test cases passes if at the end the test the value of the global counter is MAX_THREADS * REPEAT_COUNT. -** -** -**=========================================================*/ - -#include -#define MAX_THREADS 64 -#define REPEAT_COUNT 10000 - -LONG GlobalCounter = 0; -void IncrementCounter(void); - -int __cdecl main(int argc, char *argv[]) -{ - - LONG TotalOperations=0; - int i=0; - DWORD dwThreadID = 0; - HANDLE hThread[MAX_THREADS]; - TotalOperations = MAX_THREADS * REPEAT_COUNT; - GlobalCounter = 0; - - /* - * Initialize the PAL and return FAILURE if this fails - */ - if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - /* - ** Run only on 64 bit platforms - */ - #if defined(BIT64) - - //Create MAX_THREADS threads that will operate on the global counter - for (i=0;i - -/** - * main - * - * executable entry point - */ -INT __cdecl main(INT argc, CHAR **argv) -{ - BOOL ResultValue = 0; - - /* - * Initialize the PAL and return FAILURE if this fails - */ - - if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - /* This should be readable, and return 0 */ - ResultValue = IsBadCodePtr((FARPROC)main); - if(ResultValue != 0) - { - Fail("ERROR: IsBadCodePtr returned %d instead of 0, when pointing " - "at readable memory.\n",ResultValue); - } - - /* 0x00 is usually unreadable memory so the function should - return non zero */ - ResultValue = IsBadCodePtr((FARPROC)0x00); - - if(ResultValue == 0) - { - Fail("ERROR: IsBadCodePtr returned %d instead of non zero " - "when checking on unreadable memory.\n",ResultValue); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/miscellaneous/IsBadCodePtr/test1/testinfo.dat b/src/pal/tests/palsuite/miscellaneous/IsBadCodePtr/test1/testinfo.dat deleted file mode 100644 index 8b73c0dfc..000000000 --- a/src/pal/tests/palsuite/miscellaneous/IsBadCodePtr/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = C Runtime -Function = IsBadCodePtr -Name = Positive Test for IsBadCodePtr -TYPE = DEFAULT -EXE1 = test1 -Description -= ensure that IsBadCodePtr return 0 when -= it can read memory or non zero when it can't. diff --git a/src/pal/tests/palsuite/miscellaneous/IsBadReadPtr/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/IsBadReadPtr/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/miscellaneous/IsBadReadPtr/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/miscellaneous/IsBadReadPtr/test1/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/IsBadReadPtr/test1/CMakeLists.txt deleted file mode 100644 index db19d5bff..000000000 --- a/src/pal/tests/palsuite/miscellaneous/IsBadReadPtr/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test.cpp -) - -add_executable(paltest_isbadreadptr_test1 - ${SOURCES} -) - -add_dependencies(paltest_isbadreadptr_test1 coreclrpal) - -target_link_libraries(paltest_isbadreadptr_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/miscellaneous/IsBadReadPtr/test1/test.cpp b/src/pal/tests/palsuite/miscellaneous/IsBadReadPtr/test1/test.cpp deleted file mode 100644 index 24b7ceb7e..000000000 --- a/src/pal/tests/palsuite/miscellaneous/IsBadReadPtr/test1/test.cpp +++ /dev/null @@ -1,138 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source: test.c -** -** Purpose: IsBadReadPtr() function -** -** -**=========================================================*/ - -#include - -#define MEMORY_AMOUNT 16 - -int __cdecl main(int argc, char *argv[]) -{ - LPVOID TestingPointer = NULL; - BOOL ResultValue = 0; - - /* - * Initialize the PAL and return FAILURE if this fails - */ - - if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - TestingPointer = malloc(MEMORY_AMOUNT); - if ( TestingPointer == NULL ) - { - Fail("ERROR: Failed to allocate memory for TestingPointer pointer. " - "Can't properly exec test case without this.\n"); - } - - - /* This should be readable, and return 0 */ - ResultValue = IsBadReadPtr(TestingPointer,MEMORY_AMOUNT); - if(ResultValue != 0) - { - free(TestingPointer); - - Fail("ERROR: The function returned %d instead of 0, when pointing " - "at readable memory.\n",ResultValue); - } - - /* If we pass 0, the result should be 0 as well */ - ResultValue = IsBadReadPtr(TestingPointer,0); - if(ResultValue != 0) - { - free(TestingPointer); - - Fail("ERROR: The function returned %d instead of 0, when the " - "function was passed a range of 0 bytes.\n",ResultValue); - } - free(TestingPointer); /* we are done with this */ - - /* create a READABLE address */ - TestingPointer = VirtualAlloc( - NULL, /* system selects address */ - 80, /* size of allocation*/ - MEM_COMMIT, /* commit */ - PAGE_READONLY); /* protection = read only */ - - if (TestingPointer == NULL ) - { - Fail("ERROR: call to VirtualAlloc failed\n"); - } - - ResultValue = IsBadReadPtr(TestingPointer,16); - if(ResultValue != 0) /* if no access */ - { - if(!VirtualFree(TestingPointer, 0, MEM_RELEASE)) - { - Trace("ERROR: Call to VirtualFree failed with error" - " code[ %u ]\n",GetLastError()); - } - - Fail("ERROR: The function returned %d instead of 1 when checking " - "on unreadable memory.\n",ResultValue); - } - - if(!VirtualFree(TestingPointer,0, MEM_RELEASE)) - { - Fail("ERROR: Call to VirtualFree failed with error" - " code[ %u ]\n",GetLastError()); - } - - /* create an unreadable address */ - TestingPointer = VirtualAlloc( - NULL, /* system selects address */ - 80, /* size of allocation */ - MEM_COMMIT, /* commit */ - PAGE_NOACCESS); /* protection = no access */ - - if (TestingPointer == NULL ) - { - Fail("ERROR: call to VirtualAlloc failed\n"); - } - - ResultValue = IsBadReadPtr(TestingPointer,16); - - if(ResultValue == 0) /* if access */ - { - if(!VirtualFree(TestingPointer, 0, MEM_RELEASE)) - { - Trace("ERROR: Call to VirtualFree failed with error" - " code[ %u ]\n",GetLastError()); - } - - Fail("ERROR: The function returned %d instead of 1 when checking " - "on unreadable memory.\n",ResultValue); - } - - if(!VirtualFree(TestingPointer,0, MEM_RELEASE)) - { - Fail("ERROR: Call to VirtualFree failed with error" - " code[ %u ]\n",GetLastError()); - } - - - /* This should be unreadable and return 1 */ - ResultValue = IsBadReadPtr(NULL,16); - if(ResultValue != 1) - { - Fail("ERROR: The function returned %d instead of 1 when checking " - "to see if NULL was readable.\n",ResultValue); - } - - PAL_Terminate(); - return PASS; -} - - - diff --git a/src/pal/tests/palsuite/miscellaneous/IsBadReadPtr/test1/testinfo.dat b/src/pal/tests/palsuite/miscellaneous/IsBadReadPtr/test1/testinfo.dat deleted file mode 100644 index 27668b66c..000000000 --- a/src/pal/tests/palsuite/miscellaneous/IsBadReadPtr/test1/testinfo.dat +++ /dev/null @@ -1,15 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Miscellaneous -Function = IsBadReadPtr -Name = Return value tests for IsBadReadPtr -TYPE = DEFAULT -EXE1 = test -Description -= Ensure that this returns true and false when it is supposed to. - - - diff --git a/src/pal/tests/palsuite/miscellaneous/IsBadWritePtr/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/IsBadWritePtr/CMakeLists.txt deleted file mode 100644 index 1962ade35..000000000 --- a/src/pal/tests/palsuite/miscellaneous/IsBadWritePtr/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) -add_subdirectory(test3) - diff --git a/src/pal/tests/palsuite/miscellaneous/IsBadWritePtr/test1/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/IsBadWritePtr/test1/CMakeLists.txt deleted file mode 100644 index 89966056c..000000000 --- a/src/pal/tests/palsuite/miscellaneous/IsBadWritePtr/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test.cpp -) - -add_executable(paltest_isbadwriteptr_test1 - ${SOURCES} -) - -add_dependencies(paltest_isbadwriteptr_test1 coreclrpal) - -target_link_libraries(paltest_isbadwriteptr_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/miscellaneous/IsBadWritePtr/test1/test.cpp b/src/pal/tests/palsuite/miscellaneous/IsBadWritePtr/test1/test.cpp deleted file mode 100644 index 018d7beae..000000000 --- a/src/pal/tests/palsuite/miscellaneous/IsBadWritePtr/test1/test.cpp +++ /dev/null @@ -1,81 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source: test.c -** -** Purpose: IsBadWritePtr() function -** -** -**=========================================================*/ - -#include - -#define MEMORY_AMOUNT 16 - -int __cdecl main(int argc, char *argv[]) { - - void * TestingPointer = NULL; - BOOL ResultValue = 0; - - /* - * Initialize the PAL and return FAILURE if this fails - */ - - if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - TestingPointer = malloc(MEMORY_AMOUNT); - if ( TestingPointer == NULL ) - { - Fail("ERROR: Failed to allocate memory for TestingPointer pointer. " - "Can't properly exec test case without this.\n"); - } - - - /* This should be writeable, return 0 */ - ResultValue = IsBadWritePtr(TestingPointer,MEMORY_AMOUNT); - - if(ResultValue != 0) - { - free(TestingPointer); - - Fail("ERROR: Returned %d when 0 should have been returned, checking " - "to see if writable memory is unwriteable.\n",ResultValue); - } - - free(TestingPointer); - - /* This should be !writeable, return nonezero */ - TestingPointer = (void*)0x08; /* non writeable address */ - ResultValue = IsBadWritePtr(TestingPointer,sizeof(int)); - - if(ResultValue == 0) - { - Fail("ERROR: Returned %d when nonezero should have been returned, " - "checking to see if unwriteable memory is writeable.\n", - ResultValue); - } - - /* This should be !writeable, return Nonezero */ - ResultValue = IsBadWritePtr(NULL,MEMORY_AMOUNT); - - if(ResultValue == 0) - { - Fail("ERROR: Returned %d when nonezero should have been " - "returned,checking " - "to see if a NULL pointer is writeable.\n", - ResultValue); - } - - PAL_Terminate(); - return PASS; -} - - - - diff --git a/src/pal/tests/palsuite/miscellaneous/IsBadWritePtr/test1/testinfo.dat b/src/pal/tests/palsuite/miscellaneous/IsBadWritePtr/test1/testinfo.dat deleted file mode 100644 index ba4e97ebb..000000000 --- a/src/pal/tests/palsuite/miscellaneous/IsBadWritePtr/test1/testinfo.dat +++ /dev/null @@ -1,16 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Miscellaneous -Function = IsBadWritePtr -Name = Return Value test IsBadWritePtr -TYPE = DEFAULT -EXE1 = test -Description -= Test to ensure that the function returns true and -= false when it is supposed to. - - - diff --git a/src/pal/tests/palsuite/miscellaneous/IsBadWritePtr/test2/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/IsBadWritePtr/test2/CMakeLists.txt deleted file mode 100644 index ff0dbdce9..000000000 --- a/src/pal/tests/palsuite/miscellaneous/IsBadWritePtr/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test2.cpp -) - -add_executable(paltest_isbadwriteptr_test2 - ${SOURCES} -) - -add_dependencies(paltest_isbadwriteptr_test2 coreclrpal) - -target_link_libraries(paltest_isbadwriteptr_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/miscellaneous/IsBadWritePtr/test2/test2.cpp b/src/pal/tests/palsuite/miscellaneous/IsBadWritePtr/test2/test2.cpp deleted file mode 100644 index b5e22ea70..000000000 --- a/src/pal/tests/palsuite/miscellaneous/IsBadWritePtr/test2/test2.cpp +++ /dev/null @@ -1,127 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source: test2.c -** -** Purpose: -** Create three consecuative pages, NOACCES, READWRITE and -** NOACCESS. Check to ensure that the READWRITE page returns 0, to -** ensure that IsBadWritePtr isn't overflowing. Also check the other two -** pages to see that they return non-zero. -** -** -**=========================================================*/ - -#include - -int __cdecl main(int argc, char *argv[]) { - - LPVOID PageOne, PageTwo, PageThree; - - if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - /* Reserve enough space for four pages. We'll commit this memory - and set the correct access for each page below. - */ - - PageOne = VirtualAlloc(NULL, - GetOsPageSize()*4, - MEM_RESERVE, - PAGE_NOACCESS); - - if(PageOne == NULL) - { - Fail("ERROR: VirtualAlloc failed to reserve the required memory.\n"); - } - - /* Set the first Page to PAGE_NOACCESS */ - - PageOne = VirtualAlloc(PageOne, - GetOsPageSize(), - MEM_COMMIT, - PAGE_NOACCESS); - - if(PageOne == NULL) - { - VirtualFree(PageOne,0,MEM_RELEASE); - - Fail("ERROR: VirtualAlloc failed to commit the required memory " - "for the first page.\n"); - } - - /* Set the second Page to PAGE_READWRITE */ - - PageTwo = VirtualAlloc(((BYTE*)PageOne)+GetOsPageSize(), - GetOsPageSize(), - MEM_COMMIT, - PAGE_READWRITE); - if(PageTwo == NULL) - { - VirtualFree(PageOne,0,MEM_RELEASE); - - Fail("ERROR: VirtualAlloc failed to allocate the required memory " - "for the second page. %d\n",GetLastError()); - } - - /* Set the third Page to PAGE_NOACCESS */ - - PageThree = VirtualAlloc(((BYTE*)PageTwo) + (2 * GetOsPageSize()), - GetOsPageSize(), - MEM_COMMIT, - PAGE_NOACCESS); - - if(PageThree == NULL) - { - VirtualFree(PageOne,0,MEM_RELEASE); - - Fail("ERROR: VirtualAlloc failed to allocate the required memory. " - "For the third page.\n"); - } - - -/* Check that calling IsBadWritePtr on the first page returns non-zero */ - - if(IsBadWritePtr(PageThree,GetOsPageSize()) == 0) - { - VirtualFree(PageOne,0,MEM_RELEASE); - - Fail("ERROR: Called IsBadWritePtr on a page which was set NOACCESS " - "but the return value was 0, indicating that the memory is " - "writable.\n"); - } - - /* Check that calling IsBadWritePtr on the middle page returns 0 */ - - if(IsBadWritePtr(PageTwo,GetOsPageSize()) != 0) - { - VirtualFree(PageOne,0,MEM_RELEASE); - - Fail("ERROR: IsBadWritePtr didn't return 0 when called on a " - "page which should have been writable.\n"); - } - - /* Check that calling IsBadWritePtr on the third page returns non-zero */ - - if(IsBadWritePtr(PageThree,GetOsPageSize()) == 0) - { - VirtualFree(PageOne,0,MEM_RELEASE); - - Fail("ERROR: Called IsBadWritePtr on a page which was set NOACCESS " - "but the return value was 0, indicating that the memory is " - "writable.\n"); - } - VirtualFree(PageOne,0,MEM_RELEASE); - PAL_Terminate(); - return PASS; -} - - - - - diff --git a/src/pal/tests/palsuite/miscellaneous/IsBadWritePtr/test2/testinfo.dat b/src/pal/tests/palsuite/miscellaneous/IsBadWritePtr/test2/testinfo.dat deleted file mode 100644 index ad0a5fe90..000000000 --- a/src/pal/tests/palsuite/miscellaneous/IsBadWritePtr/test2/testinfo.dat +++ /dev/null @@ -1,19 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Miscellaneous -Function = IsBadWritePtr -Name = Return Value test IsBadWritePtr -TYPE = DEFAULT -EXE1 = test2 -Description -= Create three consecuative pages, NOACCES, READWRITE and -= NOACCESS. Check to ensure that the READWRITE page returns 0, to -= ensure that IsBadWritePtr isn't overflowing. Also check the other two -= pages to see that they return non-zero. - - - - diff --git a/src/pal/tests/palsuite/miscellaneous/IsBadWritePtr/test3/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/IsBadWritePtr/test3/CMakeLists.txt deleted file mode 100644 index 30a2de300..000000000 --- a/src/pal/tests/palsuite/miscellaneous/IsBadWritePtr/test3/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test3.cpp -) - -add_executable(paltest_isbadwriteptr_test3 - ${SOURCES} -) - -add_dependencies(paltest_isbadwriteptr_test3 coreclrpal) - -target_link_libraries(paltest_isbadwriteptr_test3 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/miscellaneous/IsBadWritePtr/test3/test3.cpp b/src/pal/tests/palsuite/miscellaneous/IsBadWritePtr/test3/test3.cpp deleted file mode 100644 index 7b04c548c..000000000 --- a/src/pal/tests/palsuite/miscellaneous/IsBadWritePtr/test3/test3.cpp +++ /dev/null @@ -1,56 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source: test3.c -** -** Purpose: -** Check that IsBadWritePtr returns non-zero on Read-only memory. -** -** -**=========================================================*/ - -#include - -int __cdecl main(int argc, char *argv[]) { - - LPVOID PageOne; - - if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - /* Reserve enough space for four pages. We'll commit this memory - and set the correct access for each page below. - */ - - PageOne = VirtualAlloc(NULL, - GetOsPageSize(), - MEM_COMMIT, - PAGE_READONLY); - - if(PageOne == NULL) - { - Fail("ERROR: VirtualAlloc failed to commit the required memory.\n"); - } - - if(IsBadWritePtr(PageOne,GetOsPageSize()) == 0) - { - VirtualFree(PageOne,0,MEM_RELEASE); - - Fail("ERROR: IsBadWritePtr returned 0 when checking a section of " - "read-only memory. It should be non-zero.\n"); - } - - VirtualFree(PageOne,0,MEM_RELEASE); - PAL_Terminate(); - return PASS; -} - - - - - diff --git a/src/pal/tests/palsuite/miscellaneous/IsBadWritePtr/test3/testinfo.dat b/src/pal/tests/palsuite/miscellaneous/IsBadWritePtr/test3/testinfo.dat deleted file mode 100644 index 18851d2fd..000000000 --- a/src/pal/tests/palsuite/miscellaneous/IsBadWritePtr/test3/testinfo.dat +++ /dev/null @@ -1,17 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Miscellaneous -Function = IsBadWritePtr -Name = Return Value test IsBadWritePtr -TYPE = DEFAULT -EXE1 = test3 -Description -= Check that IsBadWritePtr returns non-zero on Read-only memory. - - - - - diff --git a/src/pal/tests/palsuite/miscellaneous/MessageBoxW/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/MessageBoxW/CMakeLists.txt deleted file mode 100644 index ef14ea535..000000000 --- a/src/pal/tests/palsuite/miscellaneous/MessageBoxW/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) - diff --git a/src/pal/tests/palsuite/miscellaneous/MessageBoxW/test1/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/MessageBoxW/test1/CMakeLists.txt deleted file mode 100644 index 458b95266..000000000 --- a/src/pal/tests/palsuite/miscellaneous/MessageBoxW/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test.cpp -) - -add_executable(paltest_messageboxw_test1 - ${SOURCES} -) - -add_dependencies(paltest_messageboxw_test1 coreclrpal) - -target_link_libraries(paltest_messageboxw_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/miscellaneous/MessageBoxW/test1/test.cpp b/src/pal/tests/palsuite/miscellaneous/MessageBoxW/test1/test.cpp deleted file mode 100644 index 8eb8c0eb7..000000000 --- a/src/pal/tests/palsuite/miscellaneous/MessageBoxW/test1/test.cpp +++ /dev/null @@ -1,81 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source: test.c -** -** Purpose: Test for MessageBoxW() function -** -** -**=========================================================*/ - -#define UNICODE - -#include - -int __cdecl main(int argc, char *argv[]) -{ - /* Declare Variables to use with convert()*/ - WCHAR * PalTitle = NULL; - WCHAR * OkTesting = NULL; - WCHAR * AbortTesting = NULL; - WCHAR * YesTesting = NULL; - /* - * Initialize the PAL and return FAILURE if this fails - */ - - if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - PalTitle = convert("Pal Testing"); - OkTesting = convert("Click OK Please!"); - - /* Handle, text, title, style */ - if(MessageBox(NULL, OkTesting, - PalTitle, - MB_OK) != IDOK) - { - free(OkTesting); - free(PalTitle); - Fail("ERROR: The MB_OK style should return IDOK."); - } - - free(OkTesting); - AbortTesting = convert("Click Abort Please!"); - if(MessageBox(NULL, - AbortTesting, - PalTitle, - MB_ABORTRETRYIGNORE) != IDABORT) - { - free(AbortTesting); - free(PalTitle); - Fail("ERROR: The MB_ABORTRETRYIGNORE style should " - "return IDABORT."); - } - - free(AbortTesting); - YesTesting = convert("Click No Please!"); - - if(MessageBox(NULL, - YesTesting, - PalTitle, - MB_YESNO) != IDNO) - { - free(PalTitle); - free(YesTesting); - Fail("ERROR: The MB_YESNO style should return IDNO."); - } - - free(YesTesting); - free(PalTitle); - - PAL_Terminate(); - return PASS; -} - - - diff --git a/src/pal/tests/palsuite/miscellaneous/MessageBoxW/test1/testinfo.dat b/src/pal/tests/palsuite/miscellaneous/MessageBoxW/test1/testinfo.dat deleted file mode 100644 index e4d46c986..000000000 --- a/src/pal/tests/palsuite/miscellaneous/MessageBoxW/test1/testinfo.dat +++ /dev/null @@ -1,15 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Miscellaneous -Function = MessageBoxW -Name = Positive test of MessageBoxW -TYPE = DEFAULT -EXE1 = test -Description -= Ensure that the return values are correct for each type of Message Style. - - - diff --git a/src/pal/tests/palsuite/miscellaneous/MessageBoxW/test2/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/MessageBoxW/test2/CMakeLists.txt deleted file mode 100644 index d86d99c33..000000000 --- a/src/pal/tests/palsuite/miscellaneous/MessageBoxW/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test.cpp -) - -add_executable(paltest_messageboxw_test2 - ${SOURCES} -) - -add_dependencies(paltest_messageboxw_test2 coreclrpal) - -target_link_libraries(paltest_messageboxw_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/miscellaneous/MessageBoxW/test2/test.cpp b/src/pal/tests/palsuite/miscellaneous/MessageBoxW/test2/test.cpp deleted file mode 100644 index e2ff0cf6d..000000000 --- a/src/pal/tests/palsuite/miscellaneous/MessageBoxW/test2/test.cpp +++ /dev/null @@ -1,76 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source: test.c -** -** Purpose: Test for MessageBoxW() function -** -** -**=========================================================*/ - -#define UNICODE - -#include - -int __cdecl main(int argc, char *argv[]) { - - /* - * Initialize the PAL and return FAILURE if this fails - */ - - if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - /* Check to make sure there are no problems accepting all the ICON - styles and FLAG styles. These don't change anything, unless - they don't work at all. - */ - - if(MessageBox(NULL, - convert("Pal Testing"), - convert("Pal Title"), - MB_OK |MB_ICONEXCLAMATION|MB_TASKMODAL) != IDOK) - { - Fail("ERROR: The MB_OK style should always return IDOK."); - } - - if(MessageBox(NULL, - convert("Pal Testing"), - convert("Pal Title"), - MB_OK |MB_ICONINFORMATION|MB_SYSTEMMODAL) != IDOK) - { - Fail("ERROR: The MB_OK style should always return IDOK."); - } - - /* MB_SERVICE_NOTIFICATION doesn't seem to be available under windows? - It claims it exists and it should be supported under FreeBSD. - */ - -#if UNIX - if(MessageBox(NULL, - convert("Pal Testing"), - convert("Pal Title"), - MB_OK |MB_ICONSTOP|MB_SERVICE_NOTIFICATION) != IDOK) - { - Fail("ERROR: The MB_OK style should always return IDOK."); - } -#endif - - if(MessageBox(NULL, - convert("Pal Testing"), - convert("Pal Title"), - MB_OK |MB_ICONQUESTION) != IDOK) - { - Fail("ERROR: The MB_OK style should always return IDOK."); - } - - PAL_Terminate(); - return PASS; -} - - diff --git a/src/pal/tests/palsuite/miscellaneous/MessageBoxW/test2/testinfo.dat b/src/pal/tests/palsuite/miscellaneous/MessageBoxW/test2/testinfo.dat deleted file mode 100644 index e4d46c986..000000000 --- a/src/pal/tests/palsuite/miscellaneous/MessageBoxW/test2/testinfo.dat +++ /dev/null @@ -1,15 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Miscellaneous -Function = MessageBoxW -Name = Positive test of MessageBoxW -TYPE = DEFAULT -EXE1 = test -Description -= Ensure that the return values are correct for each type of Message Style. - - - diff --git a/src/pal/tests/palsuite/miscellaneous/SetEnvironmentVariableA/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/SetEnvironmentVariableA/CMakeLists.txt deleted file mode 100644 index a3847f8ca..000000000 --- a/src/pal/tests/palsuite/miscellaneous/SetEnvironmentVariableA/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) -add_subdirectory(test3) -add_subdirectory(test4) - diff --git a/src/pal/tests/palsuite/miscellaneous/SetEnvironmentVariableA/test1/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/SetEnvironmentVariableA/test1/CMakeLists.txt deleted file mode 100644 index 19ae51935..000000000 --- a/src/pal/tests/palsuite/miscellaneous/SetEnvironmentVariableA/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_setenvironmentvariablea_test1 - ${SOURCES} -) - -add_dependencies(paltest_setenvironmentvariablea_test1 coreclrpal) - -target_link_libraries(paltest_setenvironmentvariablea_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/miscellaneous/SetEnvironmentVariableA/test1/test1.cpp b/src/pal/tests/palsuite/miscellaneous/SetEnvironmentVariableA/test1/test1.cpp deleted file mode 100644 index 86a44218f..000000000 --- a/src/pal/tests/palsuite/miscellaneous/SetEnvironmentVariableA/test1/test1.cpp +++ /dev/null @@ -1,168 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source: test1.c -** -** Purpose: Test for SetEnvironmentVariableA() function. Set an -** environment variable and check to ensure success was returned. Then -** get the environment variable and compare to the correct value. Also, check -** that calling the function again, resets the variable properly. And that -** calling with NULL deletes the variable. -** -** Depends: -** GetEnvironmentVariable -** memcmp -** memset -** strlen -** -** -**=========================================================*/ - -#include -#define BUF_SIZE 128 - -int __cdecl main(int argc, char *argv[]) -{ - - /* Define some buffers needed for the function */ - char* VariableBuffer = "PALTEST"; - char* ValueBuffer = "Testing"; - char* SecondValueBuffer = "SecondTest"; - char NewValue[BUF_SIZE]; - int SetResult = 0; - - /* - * Initialize the PAL and return FAILURE if this fails - */ - - if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - - - /* - Test #1 - ======= - */ - - SetResult = SetEnvironmentVariable(VariableBuffer, - ValueBuffer); - - /* If result is 0, the SetEnviron function failed */ - if(SetResult == 0) - { - Fail("ERROR: SetEnvironmentVariable returned 0, which indicates that " - "it failed, even though it should have succeeded in setting the " - "variable PALTEST.\n"); - } - - memset(NewValue,0,BUF_SIZE); - - /* Grab the Environment variable we just set */ - if(GetEnvironmentVariable(VariableBuffer,NewValue,BUF_SIZE) <= 0) - { - Fail("ERROR: GetEnvironmentVariable returned 0 or less, which " - "indicates that no value was read in from the given variable."); - } - - /* Make sure that the value put into NewValue was indeed the environment - variable we set. - */ - - if(memcmp(NewValue,ValueBuffer,strlen(ValueBuffer)+1) != 0) - { - Fail("ERROR: When retrieving the variable that was just set, a " - "difference was found. Instead of the value being '%s' it " - "was instead '%s'.\n",ValueBuffer,NewValue); - } - - - - /* - Test #2 - ======= - */ - - /* If we set the same environment variable with a different value, the - old value should be replaced. - */ - - SetResult = SetEnvironmentVariable(VariableBuffer, - SecondValueBuffer); - - /* If result is 0, the SetEnviron function failed */ - if(SetResult == 0) - { - Fail("ERROR: SetEnvironmentVariable returned 0, which indicates that " - "it failed, even though it should have succeeded in re-setting " - "the variable PALTEST.\n"); - } - - memset(NewValue,0,BUF_SIZE); - - /* Grab the Environment variable we just set */ - if(GetEnvironmentVariable(VariableBuffer,NewValue,BUF_SIZE) <= 0) - { - Fail("ERROR: GetEnvironmentVariable returned 0 or less, which " - "indicates that no value was read in from the given variable."); - } - - /* Make sure that the value put into NewValue was indeed the environment - variable we set. - */ - - if(memcmp(NewValue,SecondValueBuffer,strlen(SecondValueBuffer)+1) != 0) - { - Fail("ERROR: When retrieving the variable that was just set, a " - "difference was found. Instead of the value being '%s' it " - "was instead '%s'.\n",SecondValueBuffer,NewValue); - } - - - - /* - Test #3 - ======= - */ - - /* Finally, set this variable with NULL, which should delete it from the - current environment. - */ - - SetResult = SetEnvironmentVariable(VariableBuffer, NULL); - - /* If result is 0, the SetEnviron function failed */ - if(SetResult == 0) - { - Fail("ERROR: SetEnvironmentVariable returned 0, which indicates that " - "it failed, even though it should have succeeded in deleting " - "the variable PALTEST.\n"); - } - - memset(NewValue,0,BUF_SIZE); - - /* Grab the Environment variable we just set, ensure that it's - empty now. - */ - if(GetEnvironmentVariable(VariableBuffer,NewValue,BUF_SIZE) != 0) - { - Fail("ERROR: GetEnvironmentVariable returned a non-zero value, " - "even though the environment variable which was checked should " - "have been empty."); - } - - - /* - Clean Up - */ - PAL_Terminate(); - return PASS; -} - - - diff --git a/src/pal/tests/palsuite/miscellaneous/SetEnvironmentVariableA/test1/testinfo.dat b/src/pal/tests/palsuite/miscellaneous/SetEnvironmentVariableA/test1/testinfo.dat deleted file mode 100644 index 561cd943f..000000000 --- a/src/pal/tests/palsuite/miscellaneous/SetEnvironmentVariableA/test1/testinfo.dat +++ /dev/null @@ -1,19 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Miscellaneous -Function = SetEnvironmentVariableA -Name = Positive test of SetEnvironmentVariableA -TYPE = DEFAULT -EXE1 = test1 -Description -= Set an environment variable and check to ensure success was returned. Then -= get the environment variable and compare to the correct value. Also, check -= that calling the function again, resets the variable properly. And that -= calling with NULL deletes the variable. - - - - diff --git a/src/pal/tests/palsuite/miscellaneous/SetEnvironmentVariableA/test2/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/SetEnvironmentVariableA/test2/CMakeLists.txt deleted file mode 100644 index 483d0302c..000000000 --- a/src/pal/tests/palsuite/miscellaneous/SetEnvironmentVariableA/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test2.cpp -) - -add_executable(paltest_setenvironmentvariablea_test2 - ${SOURCES} -) - -add_dependencies(paltest_setenvironmentvariablea_test2 coreclrpal) - -target_link_libraries(paltest_setenvironmentvariablea_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/miscellaneous/SetEnvironmentVariableA/test2/test2.cpp b/src/pal/tests/palsuite/miscellaneous/SetEnvironmentVariableA/test2/test2.cpp deleted file mode 100644 index 984007e6f..000000000 --- a/src/pal/tests/palsuite/miscellaneous/SetEnvironmentVariableA/test2/test2.cpp +++ /dev/null @@ -1,85 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source: test2.c -** -** Purpose: Test for SetEnvironmentVariableA() function -** Test to see that passing NULL to the first param fails. -** Test that passing NULL to both params fails. -** Set an environment variable, then pass NULL to the second param -** to delete it. Then make the same call again, to check that it fails. -** -** -**=========================================================*/ - -#include - -int __cdecl main(int argc, char *argv[]) -{ - - /* Define some buffers needed for the function */ - char* VariableBuffer = "PALTEST"; - char* ValueBuffer = "testing"; - int SetResult; - - if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - /* Check that it fails if the first param is NULL */ - - SetResult = SetEnvironmentVariable(NULL,ValueBuffer); - - if(SetResult != 0) - { - Fail("ERROR: SetEnvironmentVariable returned a success value, " - "even though it was passed NULL as the first parameter and " - "should have failed.\n"); - } - - /* Check that it fails when both params are NULL */ - SetResult = SetEnvironmentVariable(NULL,NULL); - if(SetResult != 0) - { - Fail("ERROR: SetEnvironmentVariable returned a success value, even " - "though it was passed NULL as the first and second parameter and " - "should have failed.\n"); - } - - - /* First, set the variable, which should be ok. Then call the - function with the second parameter NULL twice -- the first call should - pass, the second should fail. - */ - - SetResult = SetEnvironmentVariable(VariableBuffer,ValueBuffer); - if(SetResult == 0) - { - Fail("ERROR: SetEnvironmentVariable returned failure, when " - "attempting to set a valid variable.\n"); - } - - SetResult = SetEnvironmentVariable(VariableBuffer,NULL); - if(SetResult == 0) - { - Fail("ERROR: SetEnvironmentVariable returned failure, when " - "attempting to delete a variable.\n"); - } - - SetResult = SetEnvironmentVariable(VariableBuffer,NULL); - if(SetResult != 0) - { - Fail("ERROR: SetEnvironmentVariable returned success, when " - "attempting to delete a variable which doesn't exist.\n"); - } - - PAL_Terminate(); - return PASS; -} - - - diff --git a/src/pal/tests/palsuite/miscellaneous/SetEnvironmentVariableA/test2/testinfo.dat b/src/pal/tests/palsuite/miscellaneous/SetEnvironmentVariableA/test2/testinfo.dat deleted file mode 100644 index 446e30150..000000000 --- a/src/pal/tests/palsuite/miscellaneous/SetEnvironmentVariableA/test2/testinfo.dat +++ /dev/null @@ -1,19 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Miscellaneous -Function = SetEnvironmentVariableA -Name = Return value test of SetEnvironmentVariableA -TYPE = DEFAULT -EXE1 = test2 -Description -= Test to see that passing NULL to the first param fails. -= Test that passing NULL to both params fails. -= Set an environment variable, then pass NULL to the second param -= to delete it. Then make the same call again, to check that it fails. - - - - diff --git a/src/pal/tests/palsuite/miscellaneous/SetEnvironmentVariableA/test3/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/SetEnvironmentVariableA/test3/CMakeLists.txt deleted file mode 100644 index 27c96d950..000000000 --- a/src/pal/tests/palsuite/miscellaneous/SetEnvironmentVariableA/test3/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test3.cpp -) - -add_executable(paltest_setenvironmentvariablea_test3 - ${SOURCES} -) - -add_dependencies(paltest_setenvironmentvariablea_test3 coreclrpal) - -target_link_libraries(paltest_setenvironmentvariablea_test3 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/miscellaneous/SetEnvironmentVariableA/test3/test3.cpp b/src/pal/tests/palsuite/miscellaneous/SetEnvironmentVariableA/test3/test3.cpp deleted file mode 100644 index 539e33004..000000000 --- a/src/pal/tests/palsuite/miscellaneous/SetEnvironmentVariableA/test3/test3.cpp +++ /dev/null @@ -1,144 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** Source : test3.c -** -** Purpose: Test for SetEnvironmentVariableA() function -** Create environment variables that differ only -** in case and verify that they return the appropriate -** value on the BSD environment. -** -** -===========================================================*/ - -#include - -int __cdecl main(int argc, char *argv[]) -{ - -#if WIN32 - - return PASS; - -#else - - /* Define some buffers needed for the function */ - char * pResultBuffer = NULL; - - char FirstEnvironmentVariable[] = {"PALTEST"}; - char FirstEnvironmentValue[] = {"FIRST"}; - - char SecondEnvironmentVariable[] = {"paltest"}; - char SecondEnvironmentValue[] = {"SECOND"}; - - DWORD size = 0; - BOOL bRc = TRUE; - - /* - * Initialize the PAL and return FAILURE if this fails - */ - - if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - /* Set the first environment variable */ - bRc = SetEnvironmentVariableA(FirstEnvironmentVariable, - FirstEnvironmentValue); - - if(!bRc) - { - Fail("ERROR: SetEnvironmentVariable failed to set a " - "proper environment variable with error %u.\n", - GetLastError()); - } - - /* Set the second environment Variable */ - bRc = SetEnvironmentVariableA(SecondEnvironmentVariable, - SecondEnvironmentValue); - - if(!bRc) - { - Fail("ERROR: SetEnvironmentVariable failed to set a " - "proper environment variable with error %u.\n", - GetLastError()); - } - - - /* Normal case, PATH should fit into this buffer */ - size = GetEnvironmentVariableA(FirstEnvironmentVariable, - pResultBuffer, - 0); - - /* increase size to account for the null char at the end */ - size = size + 1; - - pResultBuffer = (char*)malloc(sizeof(char)*size); - if ( pResultBuffer == NULL ) - { - Fail("ERROR: Failed to allocate memory for pResultBuffer pointer.\n"); - } - - /* Try to retrieve the value of the first environment variable */ - GetEnvironmentVariable(FirstEnvironmentVariable, - pResultBuffer, - size); - - if ( pResultBuffer == NULL ) - { - free(pResultBuffer); - Fail("ERROR: GetEnvironmentVariable failed to return a value " - "from a proper environment variable with error %u.\n", - GetLastError()); - } - - /* Compare the strings to see that the correct variable was returned */ - if(strcmp(pResultBuffer,FirstEnvironmentValue) != 0) - { - Trace("ERROR: The value in the buffer should have been '%s' but " - "was really '%s'.\n",FirstEnvironmentValue, pResultBuffer); - free(pResultBuffer); - Fail(""); - } - - free(pResultBuffer); - - /* Reallocate the memory for the string */ - pResultBuffer = (char*)malloc(sizeof(char)*size); - if ( pResultBuffer == NULL ) - { - Fail("ERROR: Failed to allocate memory for pResultBuffer pointer.\n"); - } - - /* Try retrieving the value of the first variable, even though the - second variable has the same spelling and only differs in case */ - GetEnvironmentVariable(SecondEnvironmentVariable, - pResultBuffer, - size); - - if ( pResultBuffer == NULL ) - { - Fail("ERROR: GetEnvironmentVariable failed to return a value " - "from a proper environment variable with error %u.\n", - GetLastError()); - } - - /* Compare the two strings to confirm that the right value is returned */ - if(strcmp(pResultBuffer,SecondEnvironmentValue) != 0) - { - Trace("ERROR: The value in the buffer should have been '%s' but " - "was really '%s'.\n",SecondEnvironmentValue,pResultBuffer); - free(pResultBuffer); - Fail(""); - } - - free(pResultBuffer); - - PAL_Terminate(); - return PASS; - -#endif -} diff --git a/src/pal/tests/palsuite/miscellaneous/SetEnvironmentVariableA/test3/testinfo.dat b/src/pal/tests/palsuite/miscellaneous/SetEnvironmentVariableA/test3/testinfo.dat deleted file mode 100644 index 05076bb37..000000000 --- a/src/pal/tests/palsuite/miscellaneous/SetEnvironmentVariableA/test3/testinfo.dat +++ /dev/null @@ -1,18 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Miscellaneous -Function = SetEnvironmentVariableA -Name = Return value test of SetEnvironmentVariableA -TYPE = DEFAULT -EXE1 = test3 -Description -= Test creating environment variables that differ only -= by case and check that they are treated as separate -= variables in the BSD operating system. - - - - diff --git a/src/pal/tests/palsuite/miscellaneous/SetEnvironmentVariableA/test4/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/SetEnvironmentVariableA/test4/CMakeLists.txt deleted file mode 100644 index 4ffaaa31e..000000000 --- a/src/pal/tests/palsuite/miscellaneous/SetEnvironmentVariableA/test4/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test4.cpp -) - -add_executable(paltest_setenvironmentvariablea_test4 - ${SOURCES} -) - -add_dependencies(paltest_setenvironmentvariablea_test4 coreclrpal) - -target_link_libraries(paltest_setenvironmentvariablea_test4 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/miscellaneous/SetEnvironmentVariableA/test4/test4.cpp b/src/pal/tests/palsuite/miscellaneous/SetEnvironmentVariableA/test4/test4.cpp deleted file mode 100644 index de3059c8d..000000000 --- a/src/pal/tests/palsuite/miscellaneous/SetEnvironmentVariableA/test4/test4.cpp +++ /dev/null @@ -1,100 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** Source : test4.c -** -** Purpose: Test for SetEnvironmentVariableA() function -** Create environment variables that differ only -** in case and verify that they return the appropriate -** value in the WIN32 Environment -** - -** -===========================================================*/ - -#include - -int __cdecl main(int argc, char *argv[]) -{ - -#if WIN32 - - /* Define some buffers needed for the function */ - char * pResultBuffer = NULL; - - char FirstEnvironmentVariable[] = {"PALTEST"}; - char FirstEnvironmentValue[] = {"FIRST"}; - char ModifiedEnvVar[] = {"paltest"}; - - DWORD size = 0; - BOOL bRc = TRUE; - - /* - * Initialize the PAL and return FAILURE if this fails - */ - - if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - /* Set the first environment variable */ - bRc = SetEnvironmentVariableA(FirstEnvironmentVariable, - FirstEnvironmentValue); - - if(!bRc) - { - Fail("ERROR: SetEnvironmentVariable failed to set a " - "proper environment variable with error %u.\n", - GetLastError()); - } - - /* Normal case, PATH should fit into this buffer */ - size = GetEnvironmentVariableA(ModifiedEnvVar, - pResultBuffer, - 0); - - /* To account for the null character at the end of the string */ - size = size + 1; - - pResultBuffer = (char*)malloc(sizeof(char)*size); - if ( pResultBuffer == NULL ) - { - Fail("ERROR: Failed to allocate memory for pResultBuffer pointer.\n"); - } - - /* Try to retrieve the value of the first environment variable */ - GetEnvironmentVariableA(ModifiedEnvVar, - pResultBuffer, - size); - - if ( pResultBuffer == NULL ) - { - free(pResultBuffer); - Fail("ERROR: GetEnvironmentVariable failed to return a value " - "from a proper environment variable with error %u.\n", - GetLastError()); - } - - /* Compare the strings to see that the correct variable was returned */ - if(strcmp(pResultBuffer,FirstEnvironmentValue) != 0) - { - Trace("ERROR: The value in the buffer should have been '%s' but " - "was really '%s'.\n",FirstEnvironmentValue, pResultBuffer); - free(pResultBuffer); - Fail(""); - } - - free(pResultBuffer); - - PAL_Terminate(); - return PASS; - - -#else - - return PASS; -#endif -} diff --git a/src/pal/tests/palsuite/miscellaneous/SetEnvironmentVariableA/test4/testinfo.dat b/src/pal/tests/palsuite/miscellaneous/SetEnvironmentVariableA/test4/testinfo.dat deleted file mode 100644 index 925a91787..000000000 --- a/src/pal/tests/palsuite/miscellaneous/SetEnvironmentVariableA/test4/testinfo.dat +++ /dev/null @@ -1,18 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Miscellaneous -Function = SetEnvironmentVariableA -Name = Return value test of SetEnvironmentVariableA -TYPE = DEFAULT -EXE1 = test4 -Description -= Test that creating an environment variable and trying -= to attain the value of the environment variable using -= a name with different case works in the Windows -= Environment. - - - diff --git a/src/pal/tests/palsuite/miscellaneous/SetEnvironmentVariableW/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/SetEnvironmentVariableW/CMakeLists.txt deleted file mode 100644 index a3847f8ca..000000000 --- a/src/pal/tests/palsuite/miscellaneous/SetEnvironmentVariableW/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) -add_subdirectory(test3) -add_subdirectory(test4) - diff --git a/src/pal/tests/palsuite/miscellaneous/SetEnvironmentVariableW/test1/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/SetEnvironmentVariableW/test1/CMakeLists.txt deleted file mode 100644 index 2433b1578..000000000 --- a/src/pal/tests/palsuite/miscellaneous/SetEnvironmentVariableW/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test.cpp -) - -add_executable(paltest_setenvironmentvariablew_test1 - ${SOURCES} -) - -add_dependencies(paltest_setenvironmentvariablew_test1 coreclrpal) - -target_link_libraries(paltest_setenvironmentvariablew_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/miscellaneous/SetEnvironmentVariableW/test1/test.cpp b/src/pal/tests/palsuite/miscellaneous/SetEnvironmentVariableW/test1/test.cpp deleted file mode 100644 index bddbba794..000000000 --- a/src/pal/tests/palsuite/miscellaneous/SetEnvironmentVariableW/test1/test.cpp +++ /dev/null @@ -1,142 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source: test.c -** -** Purpose: -** Set an environment variable and check to ensure success was returned. Then -** get the environment variable and compare to the correct value. Also, check -** that calling the function again, resets the variable properly. And that -** calling with NULL deletes the variable. -** -** -**=========================================================*/ - -#define UNICODE -#define BUF_SIZE 128 - -#include - -/* Depends on GetEnvironmentVariable */ - -int __cdecl main(int argc, char *argv[]) -{ - - /* Define some buffers needed for the function */ - WCHAR VariableBuffer[] = {'P','A','L','T','E','S','T','\0'}; - WCHAR ValueBuffer[] = {'T','e','s','t','i','n','g','\0'}; - WCHAR SecondValueBuffer[] = {'S','e','c','o','n','d','T','e','s','t','\0'}; - WCHAR NewValue[BUF_SIZE]; - int SetResult = 0; - - /* - * Initialize the PAL and return FAILURE if this fails - */ - - if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - SetResult = SetEnvironmentVariable(VariableBuffer, - ValueBuffer); - - /* If result is 0, the SetEnviron function failed */ - if(SetResult == 0) - { - Fail("ERROR: SetEnvironmentVariable returned 0, which indicates that " - "it failed, even though it should have succeeded in setting the " - "variable PALTEST.\n"); - } - - - /* Grab the Environment variable we just set */ - if(GetEnvironmentVariable(VariableBuffer,NewValue,BUF_SIZE) <= 0) - { - Fail("ERROR: GetEnvironmentVariable returned 0 or less, which " - "indicates that no value was read in from the given variable."); - } - - /* Make sure that the value put into NewValue was indeed the environment - variable we set. - */ - - if(memcmp(NewValue,ValueBuffer,wcslen(ValueBuffer)*sizeof(WCHAR)+2) != 0) - { - Fail("ERROR: When retrieving the variable that was just set, a " - "difference was found. Instead of the value being '%s' it " - "was instead '%s'.\n",convertC(ValueBuffer),convertC(NewValue)); - } - - /* If we set the same environment variable with a different value, the - old value should be replaced. - */ - - SetResult = SetEnvironmentVariable(VariableBuffer, - SecondValueBuffer); - - /* If result is 0, the SetEnviron function failed */ - if(SetResult == 0) - { - Fail("ERROR: SetEnvironmentVariable returned 0, which indicates that " - "it failed, even though it should have succeeded in re-setting " - "the variable PALTEST.\n"); - } - - memset(NewValue,0,BUF_SIZE); - - /* Grab the Environment variable we just set */ - if(GetEnvironmentVariable(VariableBuffer,NewValue,BUF_SIZE) <= 0) - { - Fail("ERROR: GetEnvironmentVariable returned 0 or less, which " - "indicates that no value was read in from the given variable."); - } - - /* Make sure that the value put into NewValue was indeed the environment - variable we set. - */ - - if(memcmp(NewValue,SecondValueBuffer, - wcslen(SecondValueBuffer)*sizeof(WCHAR)+2) != 0) - { - Fail("ERROR: When retrieving the variable that was just set, a " - "difference was found. Instead of the value being '%s' it " - "was instead '%s'.\n", - convertC(SecondValueBuffer),convertC(NewValue)); - } - - /* Finally, set this variable with NULL, which should delete it from the - current environment. - */ - - SetResult = SetEnvironmentVariable(VariableBuffer, NULL); - - /* If result is 0, the SetEnviron function failed */ - if(SetResult == 0) - { - Fail("ERROR: SetEnvironmentVariable returned 0, which indicates that " - "it failed, even though it should have succeeded in deleting " - "the variable PALTEST.\n"); - } - - memset(NewValue,0,BUF_SIZE); - - /* Grab the Environment variable we just set, ensure that it's - empty now. - */ - if(GetEnvironmentVariable(VariableBuffer,NewValue,BUF_SIZE) != 0) - { - Fail("ERROR: GetEnvironmentVariable returned a non-zero value, " - "even though the environment variable which was checked should " - "have been empty."); - } - - PAL_Terminate(); - return PASS; -} - - - diff --git a/src/pal/tests/palsuite/miscellaneous/SetEnvironmentVariableW/test1/testinfo.dat b/src/pal/tests/palsuite/miscellaneous/SetEnvironmentVariableW/test1/testinfo.dat deleted file mode 100644 index a44f4674c..000000000 --- a/src/pal/tests/palsuite/miscellaneous/SetEnvironmentVariableW/test1/testinfo.dat +++ /dev/null @@ -1,18 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Miscellaneous -Function = SetEnvironmentVariableW -Name = Positive test of SetEnvironmentVariableW -TYPE = DEFAULT -EXE1 = test -Description -= Set an environment variable and check to ensure success was returned. Then -= get the environment variable and compare to the correct value. Also, check -= that calling the function again, resets the variable properly. And that -= calling with NULL deletes the variable. - - - diff --git a/src/pal/tests/palsuite/miscellaneous/SetEnvironmentVariableW/test2/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/SetEnvironmentVariableW/test2/CMakeLists.txt deleted file mode 100644 index c9ecdf78f..000000000 --- a/src/pal/tests/palsuite/miscellaneous/SetEnvironmentVariableW/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test.cpp -) - -add_executable(paltest_setenvironmentvariablew_test2 - ${SOURCES} -) - -add_dependencies(paltest_setenvironmentvariablew_test2 coreclrpal) - -target_link_libraries(paltest_setenvironmentvariablew_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/miscellaneous/SetEnvironmentVariableW/test2/test.cpp b/src/pal/tests/palsuite/miscellaneous/SetEnvironmentVariableW/test2/test.cpp deleted file mode 100644 index 12f4887b6..000000000 --- a/src/pal/tests/palsuite/miscellaneous/SetEnvironmentVariableW/test2/test.cpp +++ /dev/null @@ -1,88 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source: test.c -** -** Purpose: Test for SetEnvironmentVariableW() function -** Test to see that passing NULL to the first param fails. -** Test that passing NULL to both params fails. -** Set an environment variable, then pass NULL to the second param -** to delete it. Then make the same call again, to check that it fails. -** -** -**=========================================================*/ - -#define UNICODE - -#include - -int __cdecl main(int argc, char *argv[]) -{ - - /* Define some buffers needed for the function */ - WCHAR VariableBuffer[] = {'P','A','L','T','E','S','T','\0'}; - WCHAR ValueBuffer[] = {'T','e','s','t','i','n','g','\0'}; - int SetResult; - - /* - * Initialize the PAL and return FAILURE if this fails - */ - - if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - SetResult = SetEnvironmentVariable(NULL,ValueBuffer); - - /* Check that it fails if the first param is NULL */ - if(SetResult != 0) - { - Fail("ERROR: SetEnvironmentVariable returned a success value, " - "even though it was passed NULL as the first parameter and " - "should have failed.\n"); - } - - /* Check that it fails when both params are NULL */ - SetResult = SetEnvironmentVariable(NULL,NULL); - if(SetResult != 0) - { - Fail("ERROR: SetEnvironmentVariable returned a success value, even " - "though it was passed NULL as the first and second parameter and " - "should have failed.\n"); - } - - /* First, set the variable, which should be ok. Then call the - function with the second parameter NULL twice -- the first call should - pass, the second should fail. - */ - SetResult = SetEnvironmentVariable(VariableBuffer,ValueBuffer); - if(SetResult == 0) - { - Fail("ERROR: SetEnvironmentVariable returned failure, when " - "attempting to set a valid variable.\n"); - } - - SetResult = SetEnvironmentVariable(VariableBuffer,NULL); - if(SetResult == 0) - { - Fail("ERROR: SetEnvironmentVariable returned failure, when " - "attempting to delete a variable.\n"); - } - - SetResult = SetEnvironmentVariable(VariableBuffer,NULL); - if(SetResult != 0) - { - Fail("ERROR: SetEnvironmentVariable returned success, when " - "attempting to delete a variable which doesn't exist.\n"); - } - - PAL_Terminate(); - return PASS; -} - - - diff --git a/src/pal/tests/palsuite/miscellaneous/SetEnvironmentVariableW/test2/testinfo.dat b/src/pal/tests/palsuite/miscellaneous/SetEnvironmentVariableW/test2/testinfo.dat deleted file mode 100644 index 4df82daad..000000000 --- a/src/pal/tests/palsuite/miscellaneous/SetEnvironmentVariableW/test2/testinfo.dat +++ /dev/null @@ -1,18 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Miscellaneous -Function = SetEnvironmentVariableW -Name = Return value test of SetEnvironmentVariableW -TYPE = DEFAULT -EXE1 = test -Description -= Test to see that passing NULL to the first param fails. -= Test that passing NULL to both params fails. -= Set an environment variable, then pass NULL to the second param -= to delete it. Then make the same call again, to check that it fails. - - - diff --git a/src/pal/tests/palsuite/miscellaneous/SetEnvironmentVariableW/test3/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/SetEnvironmentVariableW/test3/CMakeLists.txt deleted file mode 100644 index e9dd681f7..000000000 --- a/src/pal/tests/palsuite/miscellaneous/SetEnvironmentVariableW/test3/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test3.cpp -) - -add_executable(paltest_setenvironmentvariablew_test3 - ${SOURCES} -) - -add_dependencies(paltest_setenvironmentvariablew_test3 coreclrpal) - -target_link_libraries(paltest_setenvironmentvariablew_test3 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/miscellaneous/SetEnvironmentVariableW/test3/test3.cpp b/src/pal/tests/palsuite/miscellaneous/SetEnvironmentVariableW/test3/test3.cpp deleted file mode 100644 index 5c4d4eba4..000000000 --- a/src/pal/tests/palsuite/miscellaneous/SetEnvironmentVariableW/test3/test3.cpp +++ /dev/null @@ -1,143 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** Source : test3.c -** -** Purpose: Test for SetEnvironmentVariableW() function -** Create environment variables that differ only -** in case and verify that they return the appropriate -** value on the BSD environment. -** -** -===========================================================*/ - -#include - -int __cdecl main(int argc, char *argv[]) -{ - -#if WIN32 - - return PASS; - -#else - - /* Define some buffers needed for the function */ - WCHAR * pResultBuffer = NULL; - - WCHAR FirstEnvironmentVariable[] = {'P','A','L','T','E','S','T','\0'}; - WCHAR FirstEnvironmentValue[] = {'F','I','R','S','T','\0'}; - - WCHAR SecondEnvironmentVariable[] = {'p','a','l','t','e','s','t','\0'}; - WCHAR SecondEnvironmentValue[] = {'S','E','C','O','N','D','\0'}; - - DWORD size = 0; - BOOL bRc = TRUE; - - /* - * Initialize the PAL and return FAILURE if this fails - */ - - if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - /* Set the first environment variable */ - bRc = SetEnvironmentVariableW(FirstEnvironmentVariable, - FirstEnvironmentValue); - - if(!bRc) - { - Fail("ERROR: SetEnvironmentVariable failed to set a " - "proper environment variable with error %u.\n", - GetLastError()); - } - - /* Set the second environment Variable */ - bRc = SetEnvironmentVariableW(SecondEnvironmentVariable, - SecondEnvironmentValue); - - if(!bRc) - { - Fail("ERROR: SetEnvironmentVariable failed to set a " - "proper environment variable with error %u.\n", - GetLastError()); - } - - - /* Normal case, PATH should fit into this buffer */ - size = GetEnvironmentVariableW(FirstEnvironmentVariable, - pResultBuffer, - 0); - - /* Increase size to account for the null char at the end */ - size = size + 1; - - pResultBuffer = (WCHAR*)malloc(sizeof(WCHAR)*size); - if ( pResultBuffer == NULL ) - { - Fail("ERROR: Failed to allocate memory for pResultBuffer pointer.\n"); - } - - /* Try to retrieve the value of the first environment variable */ - GetEnvironmentVariableW(FirstEnvironmentVariable, - pResultBuffer, - size); - - if ( pResultBuffer == NULL ) - { - Fail("ERROR: GetEnvironmentVariable failed to return a value " - "from a proper environment variable with error %u.\n", - GetLastError()); - } - - /* Compare the strings to see that the correct variable was returned */ - if(wcscmp(pResultBuffer,FirstEnvironmentValue) != 0) - { - Trace("ERROR: The value in the buffer should have been '%S' but " - "was really '%S'.\n",FirstEnvironmentValue, pResultBuffer); - free(pResultBuffer); - Fail(""); - } - - free(pResultBuffer); - - /* Reallocate the memory for the string */ - pResultBuffer = (WCHAR*)malloc(sizeof(WCHAR)*size); - if ( pResultBuffer == NULL ) - { - Fail("ERROR: Failed to allocate memory for pResultBuffer pointer.\n"); - } - - /* Try retrieving the value of the first variable, even though the - second variable has the same spelling and only differs in case */ - GetEnvironmentVariableW(SecondEnvironmentVariable, - pResultBuffer, - size); - - if ( pResultBuffer == NULL ) - { - Fail("ERROR: GetEnvironmentVariable failed to return a value " - "from a proper environment variable with error %u.\n", - GetLastError()); - } - - /* Compare the two strings to confirm that the right value is returned */ - if(wcscmp(pResultBuffer,SecondEnvironmentValue) != 0) - { - Trace("ERROR: The value in the buffer should have been '%S' but " - "was really '%S'.\n",SecondEnvironmentValue,pResultBuffer); - free(pResultBuffer); - Fail(""); - } - - free(pResultBuffer); - - PAL_Terminate(); - return PASS; - -#endif -} diff --git a/src/pal/tests/palsuite/miscellaneous/SetEnvironmentVariableW/test3/testinfo.dat b/src/pal/tests/palsuite/miscellaneous/SetEnvironmentVariableW/test3/testinfo.dat deleted file mode 100644 index 43a457a76..000000000 --- a/src/pal/tests/palsuite/miscellaneous/SetEnvironmentVariableW/test3/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Miscellaneous -Function = SetEnvironmentVariableW -Name = Return value test of SetEnvironmentVariableW -TYPE = DEFAULT -EXE1 = test3 -Description -= Create environment variables that differ only by case -= and verify that they are treated distinctly in the -= BSD Operating System. diff --git a/src/pal/tests/palsuite/miscellaneous/SetEnvironmentVariableW/test4/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/SetEnvironmentVariableW/test4/CMakeLists.txt deleted file mode 100644 index cfc139fcf..000000000 --- a/src/pal/tests/palsuite/miscellaneous/SetEnvironmentVariableW/test4/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test4.cpp -) - -add_executable(paltest_setenvironmentvariablew_test4 - ${SOURCES} -) - -add_dependencies(paltest_setenvironmentvariablew_test4 coreclrpal) - -target_link_libraries(paltest_setenvironmentvariablew_test4 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/miscellaneous/SetEnvironmentVariableW/test4/test4.cpp b/src/pal/tests/palsuite/miscellaneous/SetEnvironmentVariableW/test4/test4.cpp deleted file mode 100644 index 50c59d6e9..000000000 --- a/src/pal/tests/palsuite/miscellaneous/SetEnvironmentVariableW/test4/test4.cpp +++ /dev/null @@ -1,99 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** Source : test4.c -** -** Purpose: Test for SetEnvironmentVariableW() function -** Create environment variables that differ only -** in case and verify that they return the appropriate -** value on the BSD environment. -** -** -===========================================================*/ - -#include - -int __cdecl main(int argc, char *argv[]) -{ - -#if WIN32 - - /* Define some buffers needed for the function */ - WCHAR * pResultBuffer = NULL; - - WCHAR FirstEnvironmentVariable[] = {'P','A','L','T','E','S','T','\0'}; - WCHAR FirstEnvironmentValue[] = {'F','I','R','S','T','\0'}; - - WCHAR ModifiedEnvironmentVariable[] = {'p','a','l','t','e','s','t','\0'}; - - DWORD size = 0; - BOOL bRc = TRUE; - - /* - * Initialize the PAL and return FAILURE if this fails - */ - - if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - /* Set the first environment variable */ - bRc = SetEnvironmentVariableW(FirstEnvironmentVariable, - FirstEnvironmentValue); - - if(!bRc) - { - Fail("ERROR: SetEnvironmentVariable failed to set a " - "proper environment variable with error %u.\n", - GetLastError()); - } - - /* Normal case, PATH should fit into this buffer */ - size = GetEnvironmentVariableW(ModifiedEnvironmentVariable, - pResultBuffer, - 0); - - /* To account for the nul character at the end of the string */ - size = size + 1; - - pResultBuffer = (WCHAR*)malloc(sizeof(WCHAR)*size); - if ( pResultBuffer == NULL ) - { - Fail("ERROR: Failed to allocate memory for pResultBuffer pointer.\n"); - } - - /* Try to retrieve the value of the first environment variable */ - GetEnvironmentVariableW(ModifiedEnvironmentVariable, - pResultBuffer, - size); - - if ( pResultBuffer == NULL ) - { - Fail("ERROR: GetEnvironmentVariable failed to return a value " - "from a proper environment variable with error %u.\n", - GetLastError()); - } - - /* Compare the strings to see that the correct variable was returned */ - if(wcsncmp(pResultBuffer,FirstEnvironmentValue,wcslen(pResultBuffer)) != 0) - { - Trace("ERROR: The value in the buffer should have been '%S' but " - "was really '%S'.\n",FirstEnvironmentValue, pResultBuffer); - free(pResultBuffer); - Fail(""); - } - - free(pResultBuffer); - - PAL_Terminate(); - return PASS; - - -#else - - return PASS; -#endif -} diff --git a/src/pal/tests/palsuite/miscellaneous/SetEnvironmentVariableW/test4/testinfo.dat b/src/pal/tests/palsuite/miscellaneous/SetEnvironmentVariableW/test4/testinfo.dat deleted file mode 100644 index ac3c4325e..000000000 --- a/src/pal/tests/palsuite/miscellaneous/SetEnvironmentVariableW/test4/testinfo.dat +++ /dev/null @@ -1,15 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Miscellaneous -Function = SetEnvironmentVariableW -Name = Return value test of SetEnvironmentVariableW -TYPE = DEFAULT -EXE1 = test4 -Description -= Create environment variable and try to retreive -= the value of the variable by using a variable name -= that differs in case. This should not affect the -= return value in the Windows Operating System. diff --git a/src/pal/tests/palsuite/miscellaneous/SetLastError/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/SetLastError/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/miscellaneous/SetLastError/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/miscellaneous/SetLastError/test1/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/SetLastError/test1/CMakeLists.txt deleted file mode 100644 index 740ce9796..000000000 --- a/src/pal/tests/palsuite/miscellaneous/SetLastError/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test.cpp -) - -add_executable(paltest_setlasterror_test1 - ${SOURCES} -) - -add_dependencies(paltest_setlasterror_test1 coreclrpal) - -target_link_libraries(paltest_setlasterror_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/miscellaneous/SetLastError/test1/test.cpp b/src/pal/tests/palsuite/miscellaneous/SetLastError/test1/test.cpp deleted file mode 100644 index d414626dd..000000000 --- a/src/pal/tests/palsuite/miscellaneous/SetLastError/test1/test.cpp +++ /dev/null @@ -1,59 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source: test.c -** -** Purpose: Test for SetLastError() function -** -** -**=========================================================*/ -/* Depends on GetLastError() */ - - -#include - -int __cdecl main(int argc, char *argv[]) { - - /* Error value that we can set to test */ - const unsigned int FAKE_ERROR = 5; - const int NEGATIVE_ERROR = -1; - - /* - * Initialize the PAL and return FAILURE if this fails - */ - - if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - /* Set error */ - SetLastError(FAKE_ERROR); - - /* Check to make sure it returns the error value we just set */ - if(GetLastError() != FAKE_ERROR) - { - Fail("ERROR: The last error should have been '%d' but the error " - "returned was '%d'\n",FAKE_ERROR,GetLastError()); - } - - /* Set the error to a negative */ - SetLastError(NEGATIVE_ERROR); - - /* Check to make sure it returns the error value we just set */ - if((signed)GetLastError() != NEGATIVE_ERROR) - { - Fail("ERROR: The last error should have been '%d' but the error " - "returned was '%d'\n",NEGATIVE_ERROR,GetLastError()); - } - - - PAL_Terminate(); - return PASS; -} - - - diff --git a/src/pal/tests/palsuite/miscellaneous/SetLastError/test1/testinfo.dat b/src/pal/tests/palsuite/miscellaneous/SetLastError/test1/testinfo.dat deleted file mode 100644 index 5333a4bb3..000000000 --- a/src/pal/tests/palsuite/miscellaneous/SetLastError/test1/testinfo.dat +++ /dev/null @@ -1,16 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Miscellaneous -Function = SetLastError -Name = Positive test of SetLastError -TYPE = DEFAULT -EXE1 = test -Description -= Set the Last Error and then use GetLastError to make sure -= it was set properly. Assumes GetLastError is working. - - - diff --git a/src/pal/tests/palsuite/miscellaneous/_i64tow/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/_i64tow/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/miscellaneous/_i64tow/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/miscellaneous/_i64tow/test1/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/_i64tow/test1/CMakeLists.txt deleted file mode 100644 index 718c20883..000000000 --- a/src/pal/tests/palsuite/miscellaneous/_i64tow/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_i64tow_test1 - ${SOURCES} -) - -add_dependencies(paltest_i64tow_test1 coreclrpal) - -target_link_libraries(paltest_i64tow_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/miscellaneous/_i64tow/test1/test1.cpp b/src/pal/tests/palsuite/miscellaneous/_i64tow/test1/test1.cpp deleted file mode 100644 index 9a8ae0708..000000000 --- a/src/pal/tests/palsuite/miscellaneous/_i64tow/test1/test1.cpp +++ /dev/null @@ -1,76 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: test1.c -** -** Purpose: Tests _i64tow_s with normal values and different radices, negative -** values, as well as the highest and lowest values. -** -** -**============================================================*/ - -#include - -typedef struct -{ - INT64 value; - int radix; - char *result; -} testCase; - - -int __cdecl main(int argc, char *argv[]) -{ - WCHAR buffer[256]; - WCHAR *testStr; - WCHAR *ret; - int i; - testCase testCases[] = - { - {42, 10, "42"}, - {42, 2, "101010"}, - {29, 32, "t"}, - {-1, 10, "-1"}, - {-1, 8, "1777777777777777777777"}, - {-1, 32, "fvvvvvvvvvvvv"}, - {I64(0x7FFFFFFFFFFFFFFF), 10, "9223372036854775807"}, - {I64(0x8000000000000000), 10, "-9223372036854775808"}, - {0,2,"0"}, - {0,16,"0"}, - {3,16,"3"}, - {15,16,"f"}, - {16,16,"10"}, - - }; - - - if (0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - for (i=0; i - -int __cdecl main(int argc, char *argv[]) { - - char * FirstString = "Pal Testing"; /* 11 characters */ - - /* - * Initialize the PAL and return FAILURE if this fails - */ - - if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - /* The string size should be 11 */ - if(lstrlen(FirstString) != 11) - { - Fail("ERROR: The string size returned was %d but it should have " - "been 11 in this test.\n",lstrlen(FirstString)); - } - - /* A NULL pointer should return 0 length */ - if(lstrlen(NULL) != 0) - { - Fail("ERROR: Checking the length of NULL pointer should return " - "a value of 0, but %d was returned.\n",lstrlen(NULL)); - } - - - PAL_Terminate(); - return PASS; -} - - - diff --git a/src/pal/tests/palsuite/miscellaneous/lstrlenA/test1/testinfo.dat b/src/pal/tests/palsuite/miscellaneous/lstrlenA/test1/testinfo.dat deleted file mode 100644 index 2c8b795f6..000000000 --- a/src/pal/tests/palsuite/miscellaneous/lstrlenA/test1/testinfo.dat +++ /dev/null @@ -1,16 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Miscellaneous -Function = lstrlenA -Name = Positive test of lstrlenA -TYPE = DEFAULT -EXE1 = test -Description -= Test a standard NULL terminated string and a NULL pointer -= to ensure values are correct. - - - diff --git a/src/pal/tests/palsuite/miscellaneous/lstrlenW/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/lstrlenW/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/miscellaneous/lstrlenW/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/miscellaneous/lstrlenW/test1/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/lstrlenW/test1/CMakeLists.txt deleted file mode 100644 index a036291da..000000000 --- a/src/pal/tests/palsuite/miscellaneous/lstrlenW/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test.cpp -) - -add_executable(paltest_lstrlenw_test1 - ${SOURCES} -) - -add_dependencies(paltest_lstrlenw_test1 coreclrpal) - -target_link_libraries(paltest_lstrlenw_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/miscellaneous/lstrlenW/test1/test.cpp b/src/pal/tests/palsuite/miscellaneous/lstrlenW/test1/test.cpp deleted file mode 100644 index 49bc6d8f6..000000000 --- a/src/pal/tests/palsuite/miscellaneous/lstrlenW/test1/test.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source: test.c -** -** Purpose: Test for lstrlenW() function -** -** -**=========================================================*/ - -#define UNICODE - -#include - -int __cdecl main(int argc, char *argv[]) { - - WCHAR FirstString[] = {'T','E','S','T','\0'}; /* 4 characters */ - - /* - * Initialize the PAL and return FAILURE if this fails - */ - - if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - /* The string size should be 4, as noted just above */ - if(lstrlen(FirstString) != 4) - { - Fail("ERROR: The return value was %d when it should have shown the " - "size to be 4 characters.\n",lstrlen(FirstString)); - } - - /* A NULL pointer should return 0 length */ - if(lstrlen(NULL) != 0) - { - Fail("ERROR: The return value was %d when it should have been 0, the " - "length of a NULL pointer.\n",lstrlen(NULL)); - } - - - PAL_Terminate(); - return PASS; -} - - - diff --git a/src/pal/tests/palsuite/miscellaneous/lstrlenW/test1/testinfo.dat b/src/pal/tests/palsuite/miscellaneous/lstrlenW/test1/testinfo.dat deleted file mode 100644 index 4e9a4eb2b..000000000 --- a/src/pal/tests/palsuite/miscellaneous/lstrlenW/test1/testinfo.dat +++ /dev/null @@ -1,16 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Miscellaneous -Function = lstrlenW -Name = Positive test of lstrlenW -TYPE = DEFAULT -EXE1 = test -Description -= Test a standard NULL terminated string and -= a NULL pointer to ensure values are correct. - - - diff --git a/src/pal/tests/palsuite/miscellaneous/queryperformancecounter/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/queryperformancecounter/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/miscellaneous/queryperformancecounter/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/miscellaneous/queryperformancecounter/test1/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/queryperformancecounter/test1/CMakeLists.txt deleted file mode 100644 index 6ff03558d..000000000 --- a/src/pal/tests/palsuite/miscellaneous/queryperformancecounter/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_queryperformancecounter_test1 - ${SOURCES} -) - -add_dependencies(paltest_queryperformancecounter_test1 coreclrpal) - -target_link_libraries(paltest_queryperformancecounter_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/miscellaneous/queryperformancecounter/test1/test1.cpp b/src/pal/tests/palsuite/miscellaneous/queryperformancecounter/test1/test1.cpp deleted file mode 100644 index 55b173add..000000000 --- a/src/pal/tests/palsuite/miscellaneous/queryperformancecounter/test1/test1.cpp +++ /dev/null @@ -1,107 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source: test1.c -** -** Purpose: Test for QueryPerformanceCounter function -** -** -**=========================================================*/ - -/* Depends on: QueryPerformanceFrequency. */ - -#include - -/* Milliseconds of error which are acceptable Function execution time, etc. - FreeBSD has a "standard" resolution of 50ms for waiting operations, so we - must take that into account as well */ -DWORD AcceptableTimeError = 15; - -int __cdecl main(int argc, char *argv[]) -{ - - int i; - int NumIterations = 100; - DWORD AvgTimeDiff; - DWORD TimeDiff[100]; - DWORD TotalTimeDiff = 0; - DWORD SleepInterval = 50; - LARGE_INTEGER StartTime; - LARGE_INTEGER EndTime; - LARGE_INTEGER Freq; - - /* Initialize the PAL. - */ - - if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - /* Get the frequency of the High-Performance Counter, - * in order to convert counter time to milliseconds. - */ - if (!QueryPerformanceFrequency(&Freq)) - { - Fail("ERROR:%u:Unable to retrieve the frequency of the " - "high-resolution performance counter.\n", - GetLastError()); - } - - /* Perform this set of sleep timings a number of times. - */ - for(i=0; i < NumIterations; i++) - { - - /* Get the current counter value. - */ - if (!QueryPerformanceCounter(&StartTime)) - { - Fail("ERROR:%u:Unable to retrieve the current value of the " - "high-resolution performance counter.\n", - GetLastError()); - } - - /* Sleep a predetermined interval. - */ - Sleep(SleepInterval); - - /* Get the new current counter value. - */ - if (!QueryPerformanceCounter(&EndTime)) - { - Fail("ERROR:%u:Unable to retrieve the current value of the " - "high-resolution performance counter.\n", - GetLastError()); - } - - /* Determine elapsed time, in milliseconds. Compare the elapsed time - * with the sleep interval, and add to counter. - */ - TimeDiff[i] = (DWORD)(((EndTime.QuadPart - StartTime.QuadPart)*1000)/ - (Freq.QuadPart)); - TotalTimeDiff += TimeDiff[i] - SleepInterval; - - } - - /* Verify that the average of the difference between the performance - * counter and the sleep interval is within our acceptable range. - */ - AvgTimeDiff = TotalTimeDiff / NumIterations; - if (AvgTimeDiff > AcceptableTimeError) - { - Fail("ERROR: average diff %u acceptable %u.\n", - AvgTimeDiff, - AcceptableTimeError); - } - - /* Terminate the PAL. - */ - PAL_Terminate(); - return PASS; -} - - diff --git a/src/pal/tests/palsuite/miscellaneous/queryperformancecounter/test1/testinfo.dat b/src/pal/tests/palsuite/miscellaneous/queryperformancecounter/test1/testinfo.dat deleted file mode 100644 index 56f11fc91..000000000 --- a/src/pal/tests/palsuite/miscellaneous/queryperformancecounter/test1/testinfo.dat +++ /dev/null @@ -1,11 +0,0 @@ -Version = 1.0 -Section = Miscellaneous -Function = QueryPerformanceCounter -Name = Positive Test for QueryPerformanceCounter -TYPE = DEFAULT -EXE1 = test1 -Description -= This test will verify with QueryPerformanceCounter -= and QueryPerformanceFrequency that an API call of Sleep -= of 100 milliseconds takes 100 milliseconds, taking into -= account the error tolerance. diff --git a/src/pal/tests/palsuite/miscellaneous/queryperformancefrequency/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/queryperformancefrequency/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/miscellaneous/queryperformancefrequency/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/miscellaneous/queryperformancefrequency/test1/CMakeLists.txt b/src/pal/tests/palsuite/miscellaneous/queryperformancefrequency/test1/CMakeLists.txt deleted file mode 100644 index 4125ff0e7..000000000 --- a/src/pal/tests/palsuite/miscellaneous/queryperformancefrequency/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_queryperformancefrequency_test1 - ${SOURCES} -) - -add_dependencies(paltest_queryperformancefrequency_test1 coreclrpal) - -target_link_libraries(paltest_queryperformancefrequency_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/miscellaneous/queryperformancefrequency/test1/test1.cpp b/src/pal/tests/palsuite/miscellaneous/queryperformancefrequency/test1/test1.cpp deleted file mode 100644 index de08063a7..000000000 --- a/src/pal/tests/palsuite/miscellaneous/queryperformancefrequency/test1/test1.cpp +++ /dev/null @@ -1,59 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source: test1.c -** -** Purpose: Test for QueryPerformanceFrequency function -** -** -**=========================================================*/ - -#include - -int __cdecl main(int argc, char *argv[]) -{ - - LARGE_INTEGER Freq; - - /* Initialize the PAL. - */ - - if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - /* Check the return value of the performance - * frequency, a value of zero indicates that - * either the call has failed or the - * high-resolution performance counter is not - * installed. - */ - if (!QueryPerformanceFrequency(&Freq)) - { - - Fail("ERROR:%u:Unable to retrieve the frequency of the " - "high-resolution performance counter.\n", - GetLastError()); - } - - - /* Check the return value the frequency the - * value should be non-zero. - */ - if (Freq.QuadPart == 0) - { - - Fail("ERROR: The frequency has been determined to be 0 " - "the frequency should be non-zero.\n"); - - } - - /* Terminate the PAL. - */ - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/miscellaneous/queryperformancefrequency/test1/testinfo.dat b/src/pal/tests/palsuite/miscellaneous/queryperformancefrequency/test1/testinfo.dat deleted file mode 100644 index ea561422c..000000000 --- a/src/pal/tests/palsuite/miscellaneous/queryperformancefrequency/test1/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -Version = 1.0 -Section = Miscellaneous -Function = QueryPerformanceFrequency -Name = Positive Test for QueryPerformanceFrequency -TYPE = DEFAULT -EXE1 = test1 -Description -= This test will verify that QueryPerformanceFrequency -= returns a valid return value. -= The value of the count is processor dependent. On -= some processors, for example, the count might be the -= cycle rate of the processor clock. diff --git a/src/pal/tests/palsuite/pal_specific/CMakeLists.txt b/src/pal/tests/palsuite/pal_specific/CMakeLists.txt deleted file mode 100644 index aaf1f2718..000000000 --- a/src/pal/tests/palsuite/pal_specific/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -# TODO: make these tests compile -# add_subdirectory(PAL_get_stderr) -# add_subdirectory(PAL_get_stdin) -# add_subdirectory(PAL_get_stdout) - -add_subdirectory(pal_entrypoint) -add_subdirectory(PAL_errno) -add_subdirectory(PAL_GetPALDirectoryW) -add_subdirectory(pal_initializedebug) -add_subdirectory(PAL_Initialize_Terminate) - diff --git a/src/pal/tests/palsuite/pal_specific/PAL_GetPALDirectoryW/CMakeLists.txt b/src/pal/tests/palsuite/pal_specific/PAL_GetPALDirectoryW/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/pal_specific/PAL_GetPALDirectoryW/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/pal_specific/PAL_GetPALDirectoryW/test1/CMakeLists.txt b/src/pal/tests/palsuite/pal_specific/PAL_GetPALDirectoryW/test1/CMakeLists.txt deleted file mode 100644 index ffab57f00..000000000 --- a/src/pal/tests/palsuite/pal_specific/PAL_GetPALDirectoryW/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - PAL_GetPALDirectoryW.cpp -) - -add_executable(paltest_pal_getpaldirectoryw_test1 - ${SOURCES} -) - -add_dependencies(paltest_pal_getpaldirectoryw_test1 coreclrpal) - -target_link_libraries(paltest_pal_getpaldirectoryw_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/pal_specific/PAL_GetPALDirectoryW/test1/PAL_GetPALDirectoryW.cpp b/src/pal/tests/palsuite/pal_specific/PAL_GetPALDirectoryW/test1/PAL_GetPALDirectoryW.cpp deleted file mode 100644 index 856bfe865..000000000 --- a/src/pal/tests/palsuite/pal_specific/PAL_GetPALDirectoryW/test1/PAL_GetPALDirectoryW.cpp +++ /dev/null @@ -1,78 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: pal_getpaldirectoryw.c -** -** Purpose: Positive test the PAL_GetPALDirectoryW API. -** Call this API to retrieve a fully-qualified -** directory name where the PAL DLL is loaded from. -** -** -**============================================================*/ -#define UNICODE -#include - -int __cdecl main(int argc, char *argv[]) -{ - int err; - BOOL bValue; - DWORD dwFileAttribute; - WCHAR *wpDirectoryName = NULL; - char *pDirectoryName = NULL; - - /*Initialize the PAL environment*/ - err = PAL_Initialize(argc, argv); - if(0 != err) - { - return FAIL; - } - - /*allocate momory to store the directory name*/ - wpDirectoryName = (WCHAR*)malloc(MAX_PATH*sizeof(WCHAR)); - if(NULL == wpDirectoryName) - { - Fail("\nFailed to allocate memory for storing directory name!\n"); - } - - UINT size = MAX_PATH; - /*retrieve the machine configuration directory*/ - bValue = PAL_GetPALDirectoryW(wpDirectoryName, &size); - if(FALSE == bValue) - { - free(wpDirectoryName); - Fail("Failed to call PAL_GetPALDirectoryW API, " - "error code =%u\n", GetLastError()); - } - - - /*convert wide char string to a standard one*/ - pDirectoryName = convertC(wpDirectoryName); - if(0 == strlen(pDirectoryName)) - { - free(wpDirectoryName); - free(pDirectoryName); - Fail("The retrieved directory name string is empty!\n"); - } - - /*free the memory*/ - free(pDirectoryName); - - /*retrieve the attribute of a file or directory*/ - dwFileAttribute = GetFileAttributesW(wpDirectoryName); - - /*free the memory*/ - free(wpDirectoryName); - - /*check if the attribute indicates a directory*/ - if(FILE_ATTRIBUTE_DIRECTORY != - (dwFileAttribute & FILE_ATTRIBUTE_DIRECTORY)) - { - Fail("The retrieved directory name is not a valid directory!\n"); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/pal_specific/PAL_GetPALDirectoryW/test1/testinfo.dat b/src/pal/tests/palsuite/pal_specific/PAL_GetPALDirectoryW/test1/testinfo.dat deleted file mode 100644 index dca92b046..000000000 --- a/src/pal/tests/palsuite/pal_specific/PAL_GetPALDirectoryW/test1/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = PAL_Specific -Function = PAL_GetPALDirectoryW -Name = Positive test for PAL_GetPALDirectoryW to retrieve fully-qualified directory name. -TYPE = DEFAULT -EXE1 = pal_getpaldirectoryw -Description -=Retrieve the fully-qualified directory name where the PAL DLL is loaded from diff --git a/src/pal/tests/palsuite/pal_specific/PAL_GetUserTempDirectoryW/CMakeLists.txt b/src/pal/tests/palsuite/pal_specific/PAL_GetUserTempDirectoryW/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/pal_specific/PAL_GetUserTempDirectoryW/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/pal_specific/PAL_GetUserTempDirectoryW/test1/CMakeLists.txt b/src/pal/tests/palsuite/pal_specific/PAL_GetUserTempDirectoryW/test1/CMakeLists.txt deleted file mode 100644 index 17baa9f6e..000000000 --- a/src/pal/tests/palsuite/pal_specific/PAL_GetUserTempDirectoryW/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - PAL_GetUserTempDirectoryW.cpp -) - -add_executable(paltest_pal_getusertempdirectoryw_test1 - ${SOURCES} -) - -add_dependencies(paltest_pal_getusertempdirectoryw_test1 coreclrpal) - -target_link_libraries(paltest_pal_getusertempdirectoryw_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/pal_specific/PAL_GetUserTempDirectoryW/test1/PAL_GetUserTempDirectoryW.cpp b/src/pal/tests/palsuite/pal_specific/PAL_GetUserTempDirectoryW/test1/PAL_GetUserTempDirectoryW.cpp deleted file mode 100644 index 65cc426c7..000000000 --- a/src/pal/tests/palsuite/pal_specific/PAL_GetUserTempDirectoryW/test1/PAL_GetUserTempDirectoryW.cpp +++ /dev/null @@ -1,58 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: pal_getusertempdirectoryw.c -** -** Purpose: Positive test the PAL_GetUserTempDirectoryW API. -** Call PAL_GetUserTempDirectoryW to retrieve the user -** temp directory. -** -** -**============================================================*/ -#define UNICODE -#include - -#define DIRECTORYLENGTH 1024 - -int __cdecl main(int argc, char *argv[]) -{ - int err; - DWORD dwFileAttribute; - DWORD cch = DIRECTORYLENGTH; - WCHAR wDirectoryName[DIRECTORYLENGTH]; - - //Initialize the PAL environment - err = PAL_Initialize(argc, argv); - if(0 != err) - { - ExitProcess(FAIL); - } - - //retrieve the user temp directory - err = PAL_GetUserTempDirectory(ddtInstallationDependentDirectory, wDirectoryName, &cch); - - if(0 == err || 0 == strlen(convertC(wDirectoryName))) - { - Fail("Failed to call PAL_GetUserTempDirectoryW API!\n"); - } - - - //retrieve the attributes of a file or directory - dwFileAttribute = GetFileAttributesW(wDirectoryName); - - - //check if the retrieved attribute indicates a directory - if( FILE_ATTRIBUTE_DIRECTORY != (FILE_ATTRIBUTE_DIRECTORY & dwFileAttribute)) - { - Fail("PAL_GetUserTempDirectoryW API returned a non-directory name!\n"); - } - - printf ("PAL_GetUserTempDirectoryW returns %S\n", wDirectoryName); - - PAL_Terminate(); - return PASS; - -} diff --git a/src/pal/tests/palsuite/pal_specific/PAL_GetUserTempDirectoryW/test1/testinfo.dat b/src/pal/tests/palsuite/pal_specific/PAL_GetUserTempDirectoryW/test1/testinfo.dat deleted file mode 100644 index d530ca5fc..000000000 --- a/src/pal/tests/palsuite/pal_specific/PAL_GetUserTempDirectoryW/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = pal_specific -Function = PAL_GetUserTempDirectoryW -Name = Positive test for PAL_GetUserTempDirectoryW API -TYPE = DEFAULT -EXE1 = pal_getusertempdirectoryw -Description -=Test the PAL_GetUserTempDirectoryW to retrieve the user temp -=directory name diff --git a/src/pal/tests/palsuite/pal_specific/PAL_Initialize_Terminate/CMakeLists.txt b/src/pal/tests/palsuite/pal_specific/PAL_Initialize_Terminate/CMakeLists.txt deleted file mode 100644 index ef14ea535..000000000 --- a/src/pal/tests/palsuite/pal_specific/PAL_Initialize_Terminate/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) - diff --git a/src/pal/tests/palsuite/pal_specific/PAL_Initialize_Terminate/test1/CMakeLists.txt b/src/pal/tests/palsuite/pal_specific/PAL_Initialize_Terminate/test1/CMakeLists.txt deleted file mode 100644 index 27750bb26..000000000 --- a/src/pal/tests/palsuite/pal_specific/PAL_Initialize_Terminate/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - PAL_Initialize_Terminate.cpp -) - -add_executable(paltest_pal_initialize_terminate_test1 - ${SOURCES} -) - -add_dependencies(paltest_pal_initialize_terminate_test1 coreclrpal) - -target_link_libraries(paltest_pal_initialize_terminate_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/pal_specific/PAL_Initialize_Terminate/test1/PAL_Initialize_Terminate.cpp b/src/pal/tests/palsuite/pal_specific/PAL_Initialize_Terminate/test1/PAL_Initialize_Terminate.cpp deleted file mode 100644 index 29bb2c3b4..000000000 --- a/src/pal/tests/palsuite/pal_specific/PAL_Initialize_Terminate/test1/PAL_Initialize_Terminate.cpp +++ /dev/null @@ -1,33 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: pal_initialize_terminate.c -** -** Purpose: Positive test the PAL_Initialize and PAL_Terminate API. -** Call PAL_Initialize to initialize the PAL -** environment and call PAL_Terminate to clean up the PAL -** environment. -** - -** -**============================================================*/ -#include - -int __cdecl main(int argc, char *argv[]) -{ - int err; - - /* Initialize the PAL environment */ - err = PAL_Initialize(argc, argv); - - if(0 != err) - { - ExitProcess(1); - } - - PAL_Terminate(); - return 0; -} diff --git a/src/pal/tests/palsuite/pal_specific/PAL_Initialize_Terminate/test1/testinfo.dat b/src/pal/tests/palsuite/pal_specific/PAL_Initialize_Terminate/test1/testinfo.dat deleted file mode 100644 index 8ffe3bb7c..000000000 --- a/src/pal/tests/palsuite/pal_specific/PAL_Initialize_Terminate/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = PAL_Specific -Function = PAL_Initialize and PAL_Terminate -Name = Positive test for PAL_Initialize and PAL_Terminate -TYPE = DEFAULT -EXE1 = pal_initialize_terminate -Description -=Test the PAL_Initialize to initialize the PAL environment -=Test the PAL_Terminate to clean up the PAL environment diff --git a/src/pal/tests/palsuite/pal_specific/PAL_Initialize_Terminate/test2/CMakeLists.txt b/src/pal/tests/palsuite/pal_specific/PAL_Initialize_Terminate/test2/CMakeLists.txt deleted file mode 100644 index 951aa5d59..000000000 --- a/src/pal/tests/palsuite/pal_specific/PAL_Initialize_Terminate/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - pal_initialize_twice.cpp -) - -add_executable(paltest_pal_initialize_terminate_test2 - ${SOURCES} -) - -add_dependencies(paltest_pal_initialize_terminate_test2 coreclrpal) - -target_link_libraries(paltest_pal_initialize_terminate_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/pal_specific/PAL_Initialize_Terminate/test2/pal_initialize_twice.cpp b/src/pal/tests/palsuite/pal_specific/PAL_Initialize_Terminate/test2/pal_initialize_twice.cpp deleted file mode 100644 index fc460bc1a..000000000 --- a/src/pal/tests/palsuite/pal_specific/PAL_Initialize_Terminate/test2/pal_initialize_twice.cpp +++ /dev/null @@ -1,41 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: pal_initialize_twice.c -** -** Purpose: Positive test of PAL_Initialize and PAL_Terminate APIs. -** Calls PAL_Initialize twice to ensure that doing so -** will not cause unexpected failures in the PAL. -** Calls PAL_Terminate twice to clean up the PAL. -** - -** -**============================================================*/ -#include - -int __cdecl main(int argc, char *argv[]) -{ - /* Initialize the PAL environment */ - if (0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - /* Try calling PAL_Initialize again - should just increment the init_count. */ - if (0 != (PAL_Initialize(argc, argv))) - { - // Call terminate due to the first PAL initialization. - PAL_TerminateEx(FAIL); - return FAIL; - } - - /* If both calls to PAL_Initialize succeed, then PAL_Terminate must be - called twice. The first call just decrements the init_count to 1. */ - - PAL_Terminate(); - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/pal_specific/PAL_Initialize_Terminate/test2/testinfo.dat b/src/pal/tests/palsuite/pal_specific/PAL_Initialize_Terminate/test2/testinfo.dat deleted file mode 100644 index 31ceaf054..000000000 --- a/src/pal/tests/palsuite/pal_specific/PAL_Initialize_Terminate/test2/testinfo.dat +++ /dev/null @@ -1,15 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = PAL_Specific -Function = PAL_Initialize and PAL_Terminate -Name = Positive test for calling PAL_Initialize twice -TYPE = DEFAULT -EXE1 = pal_initialize_twice -Description -=Test calling PAL_Initialize twice to initialize the PAL environment -=and increment the init_count. -=Test calling PAL_Terminate twice to decrement the init_count -=and then clean up the PAL environment. diff --git a/src/pal/tests/palsuite/pal_specific/PAL_RegisterLibraryW_UnregisterLibraryW/CMakeLists.txt b/src/pal/tests/palsuite/pal_specific/PAL_RegisterLibraryW_UnregisterLibraryW/CMakeLists.txt deleted file mode 100644 index 37b29c0d6..000000000 --- a/src/pal/tests/palsuite/pal_specific/PAL_RegisterLibraryW_UnregisterLibraryW/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2_neg) - diff --git a/src/pal/tests/palsuite/pal_specific/PAL_RegisterLibraryW_UnregisterLibraryW/test1/CMakeLists.txt b/src/pal/tests/palsuite/pal_specific/PAL_RegisterLibraryW_UnregisterLibraryW/test1/CMakeLists.txt deleted file mode 100644 index 850c44f77..000000000 --- a/src/pal/tests/palsuite/pal_specific/PAL_RegisterLibraryW_UnregisterLibraryW/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - PAL_RegisterLibraryW_UnregisterLibraryW.cpp -) - -add_executable(paltest_pal_registerlibraryw_unregisterlibraryw_test1 - ${SOURCES} -) - -add_dependencies(paltest_pal_registerlibraryw_unregisterlibraryw_test1 coreclrpal) - -target_link_libraries(paltest_pal_registerlibraryw_unregisterlibraryw_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/pal_specific/PAL_RegisterLibraryW_UnregisterLibraryW/test1/PAL_RegisterLibraryW_UnregisterLibraryW.cpp b/src/pal/tests/palsuite/pal_specific/PAL_RegisterLibraryW_UnregisterLibraryW/test1/PAL_RegisterLibraryW_UnregisterLibraryW.cpp deleted file mode 100644 index 8eb877610..000000000 --- a/src/pal/tests/palsuite/pal_specific/PAL_RegisterLibraryW_UnregisterLibraryW/test1/PAL_RegisterLibraryW_UnregisterLibraryW.cpp +++ /dev/null @@ -1,64 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: pal_registerlibrary_unregisterlibrary -** -** Purpose: Positive test the PAL_RegisterLibrary API and -** PAL_UnRegisterLibrary. -** Call PAL_RegisterLibrary to map a module into the calling -** process address space and call PAL_UnRegisterLibrary -** to unmap this module. -** -** -**============================================================*/ -#define UNICODE -#include - -int __cdecl main(int argc, char *argv[]) -{ - HMODULE ModuleHandle; - char ModuleName[64]; - WCHAR *wpModuleName = NULL; - int err; - - /*Initialize the PAL environment*/ - err = PAL_Initialize(argc, argv); - if(0 != err) - { - return FAIL; - } - - /*zero the buffer*/ - memset(ModuleName,0,64); - sprintf_s(ModuleName, _countof(ModuleName), "%s", "rotor_pal"); - - /*convert a normal string to a wide one*/ - wpModuleName = convert(ModuleName); - - /*load a module*/ - ModuleHandle = PAL_RegisterLibrary(wpModuleName); - - /*free the memory*/ - free(wpModuleName); - - if(!ModuleHandle) - { - Fail("Failed to call PAL_RegisterLibrary API to map a module " - "into calling process, error code=%u!\n", GetLastError()); - } - - /*decrement the reference count of the loaded DLL*/ - err = PAL_UnregisterLibrary(ModuleHandle); - if(0 == err) - { - Fail("\nFailed to call PAL_UnregisterLibrary API to " - "decrement the count of the loaded DLL module, " - "error code=%u!\n", GetLastError()); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/pal_specific/PAL_RegisterLibraryW_UnregisterLibraryW/test1/testinfo.dat b/src/pal/tests/palsuite/pal_specific/PAL_RegisterLibraryW_UnregisterLibraryW/test1/testinfo.dat deleted file mode 100644 index abbd28c23..000000000 --- a/src/pal/tests/palsuite/pal_specific/PAL_RegisterLibraryW_UnregisterLibraryW/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = pal_specific -Function = PAL_RegisterLibraryW and PAL_UnregisterLibraryW API -Name = Positive test PAL_RegisterLibraryW and PAL_UnregisterLibaryW API -TYPE = DEFAULT -EXE1 = pal_registerlibraryw_unregisterlibraryw -Description -=Test the PAL_RegisterLibraryW and PAL_UnregisterLibraryW to map an executable -=module into calling process address space and unmap this module diff --git a/src/pal/tests/palsuite/pal_specific/PAL_RegisterLibraryW_UnregisterLibraryW/test2_neg/CMakeLists.txt b/src/pal/tests/palsuite/pal_specific/PAL_RegisterLibraryW_UnregisterLibraryW/test2_neg/CMakeLists.txt deleted file mode 100644 index 707d34792..000000000 --- a/src/pal/tests/palsuite/pal_specific/PAL_RegisterLibraryW_UnregisterLibraryW/test2_neg/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - reg_unreg_libraryw_neg.cpp -) - -add_executable(paltest_reg_unreg_libraryw_neg - ${SOURCES} -) - -add_dependencies(paltest_reg_unreg_libraryw_neg coreclrpal) - -target_link_libraries(paltest_reg_unreg_libraryw_neg - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/pal_specific/PAL_RegisterLibraryW_UnregisterLibraryW/test2_neg/reg_unreg_libraryw_neg.cpp b/src/pal/tests/palsuite/pal_specific/PAL_RegisterLibraryW_UnregisterLibraryW/test2_neg/reg_unreg_libraryw_neg.cpp deleted file mode 100644 index c6fa4ad07..000000000 --- a/src/pal/tests/palsuite/pal_specific/PAL_RegisterLibraryW_UnregisterLibraryW/test2_neg/reg_unreg_libraryw_neg.cpp +++ /dev/null @@ -1,62 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: pal_registerlibraryw_unregisterlibraryw_neg.c -** -** Purpose: Negative test the PAL_RegisterLibrary API. -** Call PAL_RegisterLibrary to map a non-existant module -** into the calling process address space. -** -** -**============================================================*/ -#define UNICODE -#include - -int __cdecl main(int argc, char *argv[]) -{ - HMODULE ModuleHandle; - char ModuleName[64]; - WCHAR *wpModuleName = NULL; - int err; - - /*Initialize the PAL environment*/ - err = PAL_Initialize(argc, argv); - if(0 != err) - { - return FAIL; - } - - memset(ModuleName, 0, 64); - sprintf_s(ModuleName, _countof(ModuleName), "%s", "not_exist_module_name"); - - /*convert a normal string to a wide one*/ - wpModuleName = convert(ModuleName); - - /*load a not exist module*/ - ModuleHandle = PAL_RegisterLibrary(wpModuleName); - - /*free the memory*/ - free(wpModuleName); - - if(NULL != ModuleHandle) - { - Trace("ERROR: PAL_RegisterLibrary successfully mapped " - "a module that does not exist into the calling process\n"); - - /*decrement the reference count of the loaded DLL*/ - err = PAL_UnregisterLibrary(ModuleHandle); - if(0 == err) - { - Trace("\nFailed to call PAL_UnregisterLibrary API to decrement the " - "count of the loaded DLL module!\n"); - } - Fail(""); - - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/pal_specific/PAL_RegisterLibraryW_UnregisterLibraryW/test2_neg/testinfo.dat b/src/pal/tests/palsuite/pal_specific/PAL_RegisterLibraryW_UnregisterLibraryW/test2_neg/testinfo.dat deleted file mode 100644 index 332263329..000000000 --- a/src/pal/tests/palsuite/pal_specific/PAL_RegisterLibraryW_UnregisterLibraryW/test2_neg/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = pal_specific -Function = PAL_RegisterLibraryW and PAL_UnregisterLibraryW API -Name = Negative test for PAL_RegisterLibraryW and PAL_UnregisterLibaryW API to map and unmap a non-existant module -TYPE = DEFAULT -EXE1 = pal_registerlibraryw_unregisterlibraryw_neg -Description -=Test the PAL_RegisterLibraryW and PAL_UnregisterLibraryW to map a non-existant -=module into calling process address space - diff --git a/src/pal/tests/palsuite/pal_specific/PAL_errno/CMakeLists.txt b/src/pal/tests/palsuite/pal_specific/PAL_errno/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/pal_specific/PAL_errno/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/pal_specific/PAL_errno/test1/CMakeLists.txt b/src/pal/tests/palsuite/pal_specific/PAL_errno/test1/CMakeLists.txt deleted file mode 100644 index 2938189f1..000000000 --- a/src/pal/tests/palsuite/pal_specific/PAL_errno/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - PAL_errno.cpp -) - -add_executable(paltest_pal_errno_test1 - ${SOURCES} -) - -add_dependencies(paltest_pal_errno_test1 coreclrpal) - -target_link_libraries(paltest_pal_errno_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/pal_specific/PAL_errno/test1/PAL_errno.cpp b/src/pal/tests/palsuite/pal_specific/PAL_errno/test1/PAL_errno.cpp deleted file mode 100644 index 32e8487d0..000000000 --- a/src/pal/tests/palsuite/pal_specific/PAL_errno/test1/PAL_errno.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: pal_errno.c -** -** Purpose: Positive test the PAL_errno API. -** call PAL_errno to retrieve the pointer to -** the per-thread errno value. -** -** -**============================================================*/ -#include - -int __cdecl main(int argc, char *argv[]) -{ - int err; - FILE *pFile = NULL; - - /*Initialize the PAL environment*/ - err = PAL_Initialize(argc, argv); - if( 0 != err) - { - return FAIL; - } - - /*Try to open a not-exist file to read to generate an error*/ - pFile = fopen( "no_exist_file_name", "r" ); - - if( NULL != pFile ) - { - Trace("\nFailed to call fopen to open a not exist for reading, " - "an error is expected, but no error occurred\n"); - - if( EOF == fclose( pFile ) ) - { - Trace("\nFailed to call fclose to close a file stream\n"); - } - Fail( "Test failed! fopen() Should not have worked!" ); - } - - /*retrieve the per-thread error value pointer*/ - if( 2 != errno ) - { - Fail("\nFailed to call PAL_errno API, this value is not correct." - " The correct value is ENOENT[2] ( No such file or directory.).\n"); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/pal_specific/PAL_errno/test1/testinfo.dat b/src/pal/tests/palsuite/pal_specific/PAL_errno/test1/testinfo.dat deleted file mode 100644 index a35e1d23f..000000000 --- a/src/pal/tests/palsuite/pal_specific/PAL_errno/test1/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = PAL_Specific -Function = PAL_errno -Name = Positive test PAL_errno API to retrieve the pre-thread errno value -TYPE = DEFAULT -EXE1 = pal_errno -Description -=Test the PAL_errno to retrieve a pointer to per-thread errno value diff --git a/src/pal/tests/palsuite/pal_specific/PAL_get_stderr/CMakeLists.txt b/src/pal/tests/palsuite/pal_specific/PAL_get_stderr/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/pal_specific/PAL_get_stderr/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/pal_specific/PAL_get_stderr/test1/CMakeLists.txt b/src/pal/tests/palsuite/pal_specific/PAL_get_stderr/test1/CMakeLists.txt deleted file mode 100644 index 3d177074e..000000000 --- a/src/pal/tests/palsuite/pal_specific/PAL_get_stderr/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - PAL_get_stderr.cpp -) - -add_executable(paltest_pal_get_stderr_test1 - ${SOURCES} -) - -add_dependencies(paltest_pal_get_stderr_test1 coreclrpal) - -target_link_libraries(paltest_pal_get_stderr_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/pal_specific/PAL_get_stderr/test1/PAL_get_stderr.cpp b/src/pal/tests/palsuite/pal_specific/PAL_get_stderr/test1/PAL_get_stderr.cpp deleted file mode 100644 index da5346010..000000000 --- a/src/pal/tests/palsuite/pal_specific/PAL_get_stderr/test1/PAL_get_stderr.cpp +++ /dev/null @@ -1,52 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: pal_get_stderr.c -** -** Purpose: Positive test the PAL_get_stderr API. -** Call PAL_get_stderr to retrieve the PAL standard error -** output stream pointer. -** This test case should be run manually and automatically. -** - -** -**============================================================*/ -#include - -int __cdecl main(int argc, char *argv[]) -{ - int err; - FILE *pPAL_stderr = NULL; - const char *pMsg = "\nThis is a PAL_get_stderr test message, " - "not an error message!\n"; - - /*Initialize the PAL environment*/ - err = PAL_Initialize(argc, argv); - if(0 != err) - { - return FAIL; - } - - /*retrieve the PAL standard error output stream pointer*/ - pPAL_stderr = PAL_get_stderr(); - - if(NULL == pPAL_stderr) - { - Fail("\nFailed to call PAL_get_stderr API, error code = %u\n", - GetLastError()); - } - - /*output a test message through PAL standard error stream*/ - err = fputs(pMsg, pPAL_stderr); - if(EOF == err) - { - Fail("\nFailed to call fputs to output message to PAL stdandard " - "error stream, error code=%u\n", GetLastError()); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/pal_specific/PAL_get_stderr/test1/testinfo.dat b/src/pal/tests/palsuite/pal_specific/PAL_get_stderr/test1/testinfo.dat deleted file mode 100644 index a633c68e3..000000000 --- a/src/pal/tests/palsuite/pal_specific/PAL_get_stderr/test1/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = PAL_Specific -Function = PAL_get_stderr -Name = Positive test PAL_get_stderr to retrieve the PAL standard error stream pointer -TYPE = DEFAULT -EXE1 = pal_get_stderr -Description -=Test the PAL_get_stderr to retrieve the PAL standard error output stream pointer and -=output a test message to this error stream -=this test case will be run both manually and automatically diff --git a/src/pal/tests/palsuite/pal_specific/PAL_get_stdin/CMakeLists.txt b/src/pal/tests/palsuite/pal_specific/PAL_get_stdin/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/pal_specific/PAL_get_stdin/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/pal_specific/PAL_get_stdin/test1/CMakeLists.txt b/src/pal/tests/palsuite/pal_specific/PAL_get_stdin/test1/CMakeLists.txt deleted file mode 100644 index 75469a293..000000000 --- a/src/pal/tests/palsuite/pal_specific/PAL_get_stdin/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - PAL_get_stdin.cpp -) - -add_executable(paltest_pal_get_stdin_test1 - ${SOURCES} -) - -add_dependencies(paltest_pal_get_stdin_test1 coreclrpal) - -target_link_libraries(paltest_pal_get_stdin_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/pal_specific/PAL_get_stdin/test1/PAL_get_stdin.cpp b/src/pal/tests/palsuite/pal_specific/PAL_get_stdin/test1/PAL_get_stdin.cpp deleted file mode 100644 index 5d1fd23f9..000000000 --- a/src/pal/tests/palsuite/pal_specific/PAL_get_stdin/test1/PAL_get_stdin.cpp +++ /dev/null @@ -1,68 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: pal_get_stdin.c -** -** Purpose: Positive test the PAL_get_stdout API. -** Call PAL_get_stdin to retrieve the PAL standard input -** stream pointer. -** This test case should be run manually. -** - -** -**============================================================*/ -#include - -int __cdecl main(int argc, char *argv[]) -{ - int err; - FILE *pPAL_stdin = NULL; - char Buffer[256]; - - /*Initialize the PAL environment*/ - err = PAL_Initialize(argc, argv); - if(0 != err) - { - return FAIL; - } - - /*retrieve the PAL standard input stream pointer*/ - pPAL_stdin = PAL_get_stdin(); - if(NULL == pPAL_stdin) - { - Fail("\nFailed to call PAL_get_stdin API to retrieve the " - "PAL standard input stream pointer, " - "error code = %u\n", GetLastError()); - } - - /*zero the buffer*/ - memset(Buffer, 0, 256); - - printf("\nPlease input some words: (less than 255 characters)\n"); - - /*further test the input stream*/ - /*read message from the PAL standard input stream*/ - if(NULL == fgets(Buffer, 255, pPAL_stdin)) - { - Fail( "Failed to call fgets to get a string from PAL standard " - "input stream, error code=%u\n", GetLastError()); - } - else - { - if(1 == strlen(Buffer) && Buffer[0] == '\n') - { - printf("\nEmpty input!\n"); - } - else - { - printf("\nYour input words are:\n%s\n", Buffer); - } - } - - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/pal_specific/PAL_get_stdin/test1/testinfo.dat b/src/pal/tests/palsuite/pal_specific/PAL_get_stdin/test1/testinfo.dat deleted file mode 100644 index d1c572323..000000000 --- a/src/pal/tests/palsuite/pal_specific/PAL_get_stdin/test1/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = PAL_Specific -Function = PAL_get_stdin -Name = Positive test PAL_get_stdin to retrieve the PAL standard stdin stream pointer -TYPE = DEFAULT -EXE1 = pal_get_stdin -Description -=Test the PAL_get_stdin to retrieve the PAL standard input stream pointer -=if success, display the input string to screen -=this test case should be run manually diff --git a/src/pal/tests/palsuite/pal_specific/PAL_get_stdout/CMakeLists.txt b/src/pal/tests/palsuite/pal_specific/PAL_get_stdout/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/pal_specific/PAL_get_stdout/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/pal_specific/PAL_get_stdout/test1/CMakeLists.txt b/src/pal/tests/palsuite/pal_specific/PAL_get_stdout/test1/CMakeLists.txt deleted file mode 100644 index bd78218d6..000000000 --- a/src/pal/tests/palsuite/pal_specific/PAL_get_stdout/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - PAL_get_stdout.cpp -) - -add_executable(paltest_pal_get_stdout_test1 - ${SOURCES} -) - -add_dependencies(paltest_pal_get_stdout_test1 coreclrpal) - -target_link_libraries(paltest_pal_get_stdout_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/pal_specific/PAL_get_stdout/test1/PAL_get_stdout.cpp b/src/pal/tests/palsuite/pal_specific/PAL_get_stdout/test1/PAL_get_stdout.cpp deleted file mode 100644 index ebfee47ae..000000000 --- a/src/pal/tests/palsuite/pal_specific/PAL_get_stdout/test1/PAL_get_stdout.cpp +++ /dev/null @@ -1,52 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: pal_get_stdout.c -** -** Purpose: Positive test the PAL_get_stdout API. -** Call PAL_get_stdout to retrieve the PAL standard output -** stream pointer. -** This test case should be run manually and automatically. -** - -** -**============================================================*/ -#include - -int __cdecl main(int argc, char *argv[]) -{ - int err; - FILE *pPAL_stdout = NULL; - const char *pMsg = "\nThis is a PAL_get_stdout test output message, " - "not an error message!\n"; - - /*Initialize the PAL environment*/ - err = PAL_Initialize(argc, argv); - if(0 != err) - { - return FAIL; - } - - /*retrieve the PAL output stream pointer*/ - pPAL_stdout = PAL_get_stdout(); - if(NULL == pPAL_stdout) - { - Fail("\nFailed to call PAL_get_stdout API to retrieve the " - "standard PAL output stream pointer, error code=%u\n", - GetLastError()); - } - - /*output a test message through PAL standard output stream*/ - err = fputs(pMsg, pPAL_stdout); - if(EOF == err) - { - Fail("\nFailed to call fputs to output message to PAL stdandard " - "output stream, error code=%u\n", GetLastError()); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/pal_specific/PAL_get_stdout/test1/testinfo.dat b/src/pal/tests/palsuite/pal_specific/PAL_get_stdout/test1/testinfo.dat deleted file mode 100644 index ed370981a..000000000 --- a/src/pal/tests/palsuite/pal_specific/PAL_get_stdout/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = PAL_Specific -Function = PAL_get_stdout -Name = Positive test PAL_get_stdout to retrieve PAL standard output stream pointer -TYPE = DEFAULT -EXE1 = pal_get_stdout -Description -=Test the PAL_get_stdout to retrieve the PAL standard output stream pointer -=This test case will be run both manually and automatically diff --git a/src/pal/tests/palsuite/pal_specific/pal_entrypoint/CMakeLists.txt b/src/pal/tests/palsuite/pal_specific/pal_entrypoint/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/pal_specific/pal_entrypoint/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/pal_specific/pal_entrypoint/test1/CMakeLists.txt b/src/pal/tests/palsuite/pal_specific/pal_entrypoint/test1/CMakeLists.txt deleted file mode 100644 index 154791c20..000000000 --- a/src/pal/tests/palsuite/pal_specific/pal_entrypoint/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - pal_entrypoint.cpp -) - -add_executable(paltest_pal_entrypoint_test1 - ${SOURCES} -) - -add_dependencies(paltest_pal_entrypoint_test1 coreclrpal) - -target_link_libraries(paltest_pal_entrypoint_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/pal_specific/pal_entrypoint/test1/pal_entrypoint.cpp b/src/pal/tests/palsuite/pal_specific/pal_entrypoint/test1/pal_entrypoint.cpp deleted file mode 100644 index c1b66944a..000000000 --- a/src/pal/tests/palsuite/pal_specific/pal_entrypoint/test1/pal_entrypoint.cpp +++ /dev/null @@ -1,54 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: pal_entrypoint.c -** -** Purpose: Positive test the PAL_EntryPoint API. -** -** Test the PAL_EntryPoint, Call a PAL function, and let main return -** as expected.. -** - -** -**============================================================*/ - -#include "palstartup.h" - -/* Test case copied and stream lined from isalpha\test1*/ -struct testCase -{ - int CorrectResult; - int character; -}; - -int __cdecl main(int argc, char *argv[]) -{ - int result; - int i; - - struct testCase testCases[] = - { - {1, 'a'} - }; - - - i = 0; - result = isalpha(testCases[i].character); - /* The return value is 'non-zero' for success. This if condition - * will still work if that non-zero isn't just 1 - */ - if ( ((testCases[i].CorrectResult == 1) && (result == 0)) || - ( (testCases[i].CorrectResult == 0) && (result != 0) )) - { - Fail("ERROR: isalpha returned %i instead of %i for character " - "%c.\n", - result, - testCases[i].CorrectResult, - testCases[i].character); - } - - return PASS; -} diff --git a/src/pal/tests/palsuite/pal_specific/pal_entrypoint/test1/palstartup.h b/src/pal/tests/palsuite/pal_specific/pal_entrypoint/test1/palstartup.h deleted file mode 100644 index 1947b59b7..000000000 --- a/src/pal/tests/palsuite/pal_specific/pal_entrypoint/test1/palstartup.h +++ /dev/null @@ -1,52 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -// =========================================================================== -// File: palstartup.h -// -// An implementation of startup code for Rotor's Unix PAL. This file should -// be included by any file in a PAL application that defines main. -// we have added palsuite.h to include test related macros etc... -// =========================================================================== - -#ifndef __PALSTARTUP_H__ -#define __PALSTARTUP_H__ - -#include - -int __cdecl PAL_startup_main(int argc, char **argv); - -struct _mainargs -{ - int argc; - char ** argv; -}; - -static DWORD PALAPI run_main(struct _mainargs *args) -{ - return (DWORD) PAL_startup_main(args->argc, args->argv); -} - -static void terminate(void) -{ - PAL_Terminate(); -} - -int __cdecl main(int argc, char **argv) { - struct _mainargs mainargs; - - if (PAL_Initialize(argc, argv)) { - return FAIL;; - } - - atexit(terminate); - - mainargs.argc = argc; - mainargs.argv = argv; - exit((int)PAL_EntryPoint((PTHREAD_START_ROUTINE)run_main, &mainargs)); - return 0; // Quiet a compiler warning -} - -#define main PAL_startup_main - -#endif // __PALSTARTUP_H__ diff --git a/src/pal/tests/palsuite/pal_specific/pal_entrypoint/test1/testinfo.dat b/src/pal/tests/palsuite/pal_specific/pal_entrypoint/test1/testinfo.dat deleted file mode 100644 index 01ac3d6f9..000000000 --- a/src/pal/tests/palsuite/pal_specific/pal_entrypoint/test1/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = PAL_Specific -Function = PAL_entrypoint -Name = Positive test entrypoint API -TYPE = DEFAULT -EXE1 = pal_errno -Description -=Test the PAL_entrypoint to call a PAL api diff --git a/src/pal/tests/palsuite/pal_specific/pal_initializedebug/CMakeLists.txt b/src/pal/tests/palsuite/pal_specific/pal_initializedebug/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/pal_specific/pal_initializedebug/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/pal_specific/pal_initializedebug/test1/CMakeLists.txt b/src/pal/tests/palsuite/pal_specific/pal_initializedebug/test1/CMakeLists.txt deleted file mode 100644 index 198e582ec..000000000 --- a/src/pal/tests/palsuite/pal_specific/pal_initializedebug/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - pal_initializedebug.cpp -) - -add_executable(paltest_pal_initializedebug_test1 - ${SOURCES} -) - -add_dependencies(paltest_pal_initializedebug_test1 coreclrpal) - -target_link_libraries(paltest_pal_initializedebug_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/pal_specific/pal_initializedebug/test1/pal_initializedebug.cpp b/src/pal/tests/palsuite/pal_specific/pal_initializedebug/test1/pal_initializedebug.cpp deleted file mode 100644 index d14c31601..000000000 --- a/src/pal/tests/palsuite/pal_specific/pal_initializedebug/test1/pal_initializedebug.cpp +++ /dev/null @@ -1,36 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: pal_initializedebug.c -** -** Purpose: Positive test the PAL_InitializeDebug API. -** -** Test the PAL_InitializeDebug, it will be NOPs for all -** platforms other than Mac. There is no other way of testing it -** currently -** - -** -**============================================================*/ -#include - -int __cdecl main(int argc, char *argv[]) -{ - int err; - - /* Initialize the PAL environment */ - err = PAL_Initialize(argc, argv); - - if(0 != err) - { - return FAIL; - } - - PAL_InitializeDebug(); - - PAL_Terminate(); - return 0; -} diff --git a/src/pal/tests/palsuite/pal_specific/pal_initializedebug/test1/testinfo.dat b/src/pal/tests/palsuite/pal_specific/pal_initializedebug/test1/testinfo.dat deleted file mode 100644 index 45c40e50d..000000000 --- a/src/pal/tests/palsuite/pal_specific/pal_initializedebug/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = PAL_Specific -Function = PAL_InitializeDebug -Name = Positive test for PAL_InitializeDebug -TYPE = DEFAULT -EXE1 = pal_initializedebug -Description -=Test the PAL_InitializeDebug, it will be NOPs for all -=platforms other than Mac diff --git a/src/pal/tests/palsuite/paltestlist.txt b/src/pal/tests/palsuite/paltestlist.txt deleted file mode 100644 index 43998d0e8..000000000 --- a/src/pal/tests/palsuite/paltestlist.txt +++ /dev/null @@ -1,771 +0,0 @@ -c_runtime/abs/test1/paltest_abs_test1 -c_runtime/acos/test1/paltest_acos_test1 -c_runtime/acosf/test1/paltest_acosf_test1 -c_runtime/acosh/test1/paltest_acosh_test1 -c_runtime/acoshf/test1/paltest_acoshf_test1 -c_runtime/asin/test1/paltest_asin_test1 -c_runtime/asinf/test1/paltest_asinf_test1 -c_runtime/asinh/test1/paltest_asinh_test1 -c_runtime/asinhf/test1/paltest_asinhf_test1 -c_runtime/atan/test1/paltest_atan_test1 -c_runtime/atan2/test1/paltest_atan2_test1 -c_runtime/atan2f/test1/paltest_atan2f_test1 -c_runtime/atanf/test1/paltest_atanf_test1 -c_runtime/atanh/test1/paltest_atanh_test1 -c_runtime/atanhf/test1/paltest_atanhf_test1 -c_runtime/atof/test1/paltest_atof_test1 -c_runtime/atoi/test1/paltest_atoi_test1 -c_runtime/atol/test1/paltest_atol_test1 -c_runtime/bsearch/test1/paltest_bsearch_test1 -c_runtime/bsearch/test2/paltest_bsearch_test2 -c_runtime/cbrt/test1/paltest_cbrt_test1 -c_runtime/cbrtf/test1/paltest_cbrtf_test1 -c_runtime/ceil/test1/paltest_ceil_test1 -c_runtime/ceilf/test1/paltest_ceilf_test1 -c_runtime/cos/test1/paltest_cos_test1 -c_runtime/cosf/test1/paltest_cosf_test1 -c_runtime/cosh/test1/paltest_cosh_test1 -c_runtime/coshf/test1/paltest_coshf_test1 -c_runtime/errno/test1/paltest_errno_test1 -c_runtime/errno/test2/paltest_errno_test2 -c_runtime/exit/test1/paltest_exit_test1 -c_runtime/exp/test1/paltest_exp_test1 -c_runtime/expf/test1/paltest_expf_test1 -c_runtime/fabs/test1/paltest_fabs_test1 -c_runtime/fabsf/test1/paltest_fabsf_test1 -c_runtime/fclose/test1/paltest_fclose_test1 -c_runtime/fclose/test2/paltest_fclose_test2 -c_runtime/fflush/test1/paltest_fflush_test1 -c_runtime/fgets/test1/paltest_fgets_test1 -c_runtime/fgets/test2/paltest_fgets_test2 -c_runtime/fgets/test3/paltest_fgets_test3 -c_runtime/floor/test1/paltest_floor_test1 -c_runtime/floorf/test1/paltest_floorf_test1 -c_runtime/fmod/test1/paltest_fmod_test1 -c_runtime/fmodf/test1/paltest_fmodf_test1 -c_runtime/fopen/test1/paltest_fopen_test1 -c_runtime/fopen/test2/paltest_fopen_test2 -c_runtime/fopen/test3/paltest_fopen_test3 -c_runtime/fopen/test4/paltest_fopen_test4 -c_runtime/fopen/test5/paltest_fopen_test5 -c_runtime/fopen/test6/paltest_fopen_test6 -c_runtime/fopen/test7/paltest_fopen_test7 -c_runtime/fprintf/test1/paltest_fprintf_test1 -c_runtime/fprintf/test10/paltest_fprintf_test10 -c_runtime/fprintf/test11/paltest_fprintf_test11 -c_runtime/fprintf/test12/paltest_fprintf_test12 -c_runtime/fprintf/test13/paltest_fprintf_test13 -c_runtime/fprintf/test14/paltest_fprintf_test14 -c_runtime/fprintf/test15/paltest_fprintf_test15 -c_runtime/fprintf/test16/paltest_fprintf_test16 -c_runtime/fprintf/test17/paltest_fprintf_test17 -c_runtime/fprintf/test18/paltest_fprintf_test18 -c_runtime/fprintf/test19/paltest_fprintf_test19 -c_runtime/fprintf/test2/paltest_fprintf_test2 -c_runtime/fprintf/test3/paltest_fprintf_test3 -c_runtime/fprintf/test4/paltest_fprintf_test4 -c_runtime/fprintf/test5/paltest_fprintf_test5 -c_runtime/fprintf/test6/paltest_fprintf_test6 -c_runtime/fprintf/test7/paltest_fprintf_test7 -c_runtime/fprintf/test8/paltest_fprintf_test8 -c_runtime/fprintf/test9/paltest_fprintf_test9 -c_runtime/fputs/test1/paltest_fputs_test1 -c_runtime/free/test1/paltest_free_test1 -c_runtime/fseek/test1/paltest_fseek_test1 -c_runtime/fwprintf/test1/paltest_fwprintf_test1 -c_runtime/fwprintf/test10/paltest_fwprintf_test10 -c_runtime/fwprintf/test11/paltest_fwprintf_test11 -c_runtime/fwprintf/test12/paltest_fwprintf_test12 -c_runtime/fwprintf/test13/paltest_fwprintf_test13 -c_runtime/fwprintf/test14/paltest_fwprintf_test14 -c_runtime/fwprintf/test15/paltest_fwprintf_test15 -c_runtime/fwprintf/test16/paltest_fwprintf_test16 -c_runtime/fwprintf/test17/paltest_fwprintf_test17 -c_runtime/fwprintf/test18/paltest_fwprintf_test18 -c_runtime/fwprintf/test3/paltest_fwprintf_test3 -c_runtime/fwprintf/test4/paltest_fwprintf_test4 -c_runtime/fwprintf/test5/paltest_fwprintf_test5 -c_runtime/fwprintf/test6/paltest_fwprintf_test6 -c_runtime/fwprintf/test8/paltest_fwprintf_test8 -c_runtime/fwprintf/test9/paltest_fwprintf_test9 -c_runtime/fwrite/test1/paltest_fwrite_test1 -c_runtime/getc/test1/paltest_getc_test1 -c_runtime/getenv/test1/paltest_getenv_test1 -c_runtime/getenv/test2/paltest_getenv_test2 -c_runtime/getenv/test3/paltest_getenv_test3 -c_runtime/isalnum/test1/paltest_isalnum_test1 -c_runtime/isalpha/test1/paltest_isalpha_test1 -c_runtime/isdigit/test1/paltest_isdigit_test1 -c_runtime/islower/test1/paltest_islower_test1 -c_runtime/isprint/test1/paltest_isprint_test1 -c_runtime/isprint/test2/paltest_isprint_test2 -c_runtime/isspace/test1/paltest_isspace_test1 -c_runtime/isupper/test1/paltest_isupper_test1 -c_runtime/iswdigit/test1/paltest_iswdigit_test1 -c_runtime/iswspace/test1/paltest_iswspace_test1 -c_runtime/iswupper/test1/paltest_iswupper_test1 -c_runtime/iswxdigit/test1/paltest_iswxdigit_test1 -c_runtime/isxdigit/test1/paltest_isxdigit_test1 -c_runtime/labs/test1/paltest_labs_test1 -c_runtime/llabs/test1/paltest_llabs_test1 -c_runtime/localtime/test1/paltest_localtime_test1 -c_runtime/log/test1/paltest_log_test1 -c_runtime/log10/test1/paltest_log10_test1 -c_runtime/log10f/test1/paltest_log10f_test1 -c_runtime/logf/test1/paltest_logf_test1 -c_runtime/malloc/test1/paltest_malloc_test1 -c_runtime/malloc/test2/paltest_malloc_test2 -c_runtime/memchr/test1/paltest_memchr_test1 -c_runtime/memcmp/test1/paltest_memcmp_test1 -c_runtime/memcpy/test1/paltest_memcpy_test1 -c_runtime/memmove/test1/paltest_memmove_test1 -c_runtime/memset/test1/paltest_memset_test1 -c_runtime/modf/test1/paltest_modf_test1 -c_runtime/modff/test1/paltest_modff_test1 -c_runtime/pow/test1/paltest_pow_test1 -c_runtime/powf/test1/paltest_powf_test1 -c_runtime/printf/test1/paltest_printf_test1 -c_runtime/printf/test10/paltest_printf_test10 -c_runtime/printf/test11/paltest_printf_test11 -c_runtime/printf/test12/paltest_printf_test12 -c_runtime/printf/test13/paltest_printf_test13 -c_runtime/printf/test14/paltest_printf_test14 -c_runtime/printf/test15/paltest_printf_test15 -c_runtime/printf/test16/paltest_printf_test16 -c_runtime/printf/test17/paltest_printf_test17 -c_runtime/printf/test18/paltest_printf_test18 -c_runtime/printf/test19/paltest_printf_test19 -c_runtime/printf/test2/paltest_printf_test2 -c_runtime/printf/test3/paltest_printf_test3 -c_runtime/printf/test4/paltest_printf_test4 -c_runtime/printf/test5/paltest_printf_test5 -c_runtime/printf/test6/paltest_printf_test6 -c_runtime/printf/test7/paltest_printf_test7 -c_runtime/printf/test8/paltest_printf_test8 -c_runtime/printf/test9/paltest_printf_test9 -c_runtime/qsort/test1/paltest_qsort_test1 -c_runtime/qsort/test2/paltest_qsort_test2 -c_runtime/rand_srand/test1/paltest_rand_srand_test1 -c_runtime/realloc/test1/paltest_realloc_test1 -c_runtime/sin/test1/paltest_sin_test1 -c_runtime/sinf/test1/paltest_sinf_test1 -c_runtime/sinh/test1/paltest_sinh_test1 -c_runtime/sinhf/test1/paltest_sinhf_test1 -c_runtime/sprintf_s/test1/paltest_sprintf_test1 -c_runtime/sprintf_s/test10/paltest_sprintf_test10 -c_runtime/sprintf_s/test11/paltest_sprintf_test11 -c_runtime/sprintf_s/test12/paltest_sprintf_test12 -c_runtime/sprintf_s/test13/paltest_sprintf_test13 -c_runtime/sprintf_s/test14/paltest_sprintf_test14 -c_runtime/sprintf_s/test15/paltest_sprintf_test15 -c_runtime/sprintf_s/test16/paltest_sprintf_test16 -c_runtime/sprintf_s/test17/paltest_sprintf_test17 -c_runtime/sprintf_s/test18/paltest_sprintf_test18 -c_runtime/sprintf_s/test19/paltest_sprintf_test19 -c_runtime/sprintf_s/test2/paltest_sprintf_test2 -c_runtime/sprintf_s/test3/paltest_sprintf_test3 -c_runtime/sprintf_s/test4/paltest_sprintf_test4 -c_runtime/sprintf_s/test6/paltest_sprintf_test6 -c_runtime/sprintf_s/test7/paltest_sprintf_test7 -c_runtime/sprintf_s/test8/paltest_sprintf_test8 -c_runtime/sprintf_s/test9/paltest_sprintf_test9 -c_runtime/sqrt/test1/paltest_sqrt_test1 -c_runtime/sqrtf/test1/paltest_sqrtf_test1 -c_runtime/sscanf_s/test1/paltest_sscanf_test1 -c_runtime/sscanf_s/test10/paltest_sscanf_test10 -c_runtime/sscanf_s/test11/paltest_sscanf_test11 -c_runtime/sscanf_s/test12/paltest_sscanf_test12 -c_runtime/sscanf_s/test13/paltest_sscanf_test13 -c_runtime/sscanf_s/test14/paltest_sscanf_test14 -c_runtime/sscanf_s/test15/paltest_sscanf_test15 -c_runtime/sscanf_s/test16/paltest_sscanf_test16 -c_runtime/sscanf_s/test17/paltest_sscanf_test17 -c_runtime/sscanf_s/test2/paltest_sscanf_test2 -c_runtime/sscanf_s/test3/paltest_sscanf_test3 -c_runtime/sscanf_s/test4/paltest_sscanf_test4 -c_runtime/sscanf_s/test5/paltest_sscanf_test5 -c_runtime/sscanf_s/test6/paltest_sscanf_test6 -c_runtime/sscanf_s/test7/paltest_sscanf_test7 -c_runtime/sscanf_s/test8/paltest_sscanf_test8 -c_runtime/sscanf_s/test9/paltest_sscanf_test9 -c_runtime/strcat/test1/paltest_strcat_test1 -c_runtime/strchr/test1/paltest_strchr_test1 -c_runtime/strcmp/test1/paltest_strcmp_test1 -c_runtime/strcpy/test1/paltest_strcpy_test1 -c_runtime/strcspn/test1/paltest_strcspn_test1 -c_runtime/strlen/test1/paltest_strlen_test1 -c_runtime/strncat/test1/paltest_strncat_test1 -c_runtime/strncmp/test1/paltest_strncmp_test1 -c_runtime/strncpy/test1/paltest_strncpy_test1 -c_runtime/strpbrk/test1/paltest_strpbrk_test1 -c_runtime/strrchr/test1/paltest_strrchr_test1 -c_runtime/strspn/test1/paltest_strspn_test1 -c_runtime/strstr/test1/paltest_strstr_test1 -c_runtime/strtod/test1/paltest_strtod_test1 -c_runtime/strtod/test2/paltest_strtod_test2 -c_runtime/strtok/test1/paltest_strtok_test1 -c_runtime/strtoul/test1/paltest_strtoul_test1 -c_runtime/swprintf/test1/paltest_swprintf_test1 -c_runtime/swprintf/test10/paltest_swprintf_test10 -c_runtime/swprintf/test11/paltest_swprintf_test11 -c_runtime/swprintf/test12/paltest_swprintf_test12 -c_runtime/swprintf/test13/paltest_swprintf_test13 -c_runtime/swprintf/test14/paltest_swprintf_test14 -c_runtime/swprintf/test15/paltest_swprintf_test15 -c_runtime/swprintf/test16/paltest_swprintf_test16 -c_runtime/swprintf/test17/paltest_swprintf_test17 -c_runtime/swprintf/test18/paltest_swprintf_test18 -c_runtime/swprintf/test19/paltest_swprintf_test19 -c_runtime/swprintf/test3/paltest_swprintf_test3 -c_runtime/swprintf/test4/paltest_swprintf_test4 -c_runtime/swprintf/test6/paltest_swprintf_test6 -c_runtime/swprintf/test8/paltest_swprintf_test8 -c_runtime/swprintf/test9/paltest_swprintf_test9 -c_runtime/swscanf/test1/paltest_swscanf_test1 -c_runtime/swscanf/test10/paltest_swscanf_test10 -c_runtime/swscanf/test11/paltest_swscanf_test11 -c_runtime/swscanf/test12/paltest_swscanf_test12 -c_runtime/swscanf/test13/paltest_swscanf_test13 -c_runtime/swscanf/test14/paltest_swscanf_test14 -c_runtime/swscanf/test15/paltest_swscanf_test15 -c_runtime/swscanf/test16/paltest_swscanf_test16 -c_runtime/swscanf/test17/paltest_swscanf_test17 -c_runtime/swscanf/test2/paltest_swscanf_test2 -c_runtime/swscanf/test3/paltest_swscanf_test3 -c_runtime/swscanf/test4/paltest_swscanf_test4 -c_runtime/swscanf/test5/paltest_swscanf_test5 -c_runtime/swscanf/test6/paltest_swscanf_test6 -c_runtime/swscanf/test7/paltest_swscanf_test7 -c_runtime/swscanf/test8/paltest_swscanf_test8 -c_runtime/swscanf/test9/paltest_swscanf_test9 -c_runtime/tan/test1/paltest_tan_test1 -c_runtime/tanf/test1/paltest_tanf_test1 -c_runtime/tanh/test1/paltest_tanh_test1 -c_runtime/tanhf/test1/paltest_tanhf_test1 -c_runtime/time/test1/paltest_time_test1 -c_runtime/tolower/test1/paltest_tolower_test1 -c_runtime/toupper/test1/paltest_toupper_test1 -c_runtime/towlower/test1/paltest_towlower_test1 -c_runtime/towupper/test1/paltest_towupper_test1 -c_runtime/ungetc/test1/paltest_ungetc_test1 -c_runtime/vfprintf/test1/paltest_vfprintf_test1 -c_runtime/vfprintf/test10/paltest_vfprintf_test10 -c_runtime/vfprintf/test11/paltest_vfprintf_test11 -c_runtime/vfprintf/test12/paltest_vfprintf_test12 -c_runtime/vfprintf/test13/paltest_vfprintf_test13 -c_runtime/vfprintf/test14/paltest_vfprintf_test14 -c_runtime/vfprintf/test15/paltest_vfprintf_test15 -c_runtime/vfprintf/test16/paltest_vfprintf_test16 -c_runtime/vfprintf/test17/paltest_vfprintf_test17 -c_runtime/vfprintf/test18/paltest_vfprintf_test18 -c_runtime/vfprintf/test19/paltest_vfprintf_test19 -c_runtime/vfprintf/test2/paltest_vfprintf_test2 -c_runtime/vfprintf/test3/paltest_vfprintf_test3 -c_runtime/vfprintf/test4/paltest_vfprintf_test4 -c_runtime/vfprintf/test5/paltest_vfprintf_test5 -c_runtime/vfprintf/test6/paltest_vfprintf_test6 -c_runtime/vfprintf/test7/paltest_vfprintf_test7 -c_runtime/vfprintf/test8/paltest_vfprintf_test8 -c_runtime/vfprintf/test9/paltest_vfprintf_test9 -c_runtime/vprintf/test10/paltest_vprintf_test10 -c_runtime/vprintf/test11/paltest_vprintf_test11 -c_runtime/vprintf/test12/paltest_vprintf_test12 -c_runtime/vprintf/test13/paltest_vprintf_test13 -c_runtime/vprintf/test14/paltest_vprintf_test14 -c_runtime/vprintf/test15/paltest_vprintf_test15 -c_runtime/vprintf/test16/paltest_vprintf_test16 -c_runtime/vprintf/test17/paltest_vprintf_test17 -c_runtime/vprintf/test18/paltest_vprintf_test18 -c_runtime/vprintf/test19/paltest_vprintf_test19 -c_runtime/vprintf/test2/paltest_vprintf_test2 -c_runtime/vprintf/test3/paltest_vprintf_test3 -c_runtime/vprintf/test4/paltest_vprintf_test4 -c_runtime/vprintf/test5/paltest_vprintf_test5 -c_runtime/vprintf/test6/paltest_vprintf_test6 -c_runtime/vprintf/test7/paltest_vprintf_test7 -c_runtime/vprintf/test8/paltest_vprintf_test8 -c_runtime/vprintf/test9/paltest_vprintf_test9 -c_runtime/vsprintf/test1/paltest_vsprintf_test1 -c_runtime/vsprintf/test10/paltest_vsprintf_test10 -c_runtime/vsprintf/test11/paltest_vsprintf_test11 -c_runtime/vsprintf/test12/paltest_vsprintf_test12 -c_runtime/vsprintf/test13/paltest_vsprintf_test13 -c_runtime/vsprintf/test14/paltest_vsprintf_test14 -c_runtime/vsprintf/test15/paltest_vsprintf_test15 -c_runtime/vsprintf/test16/paltest_vsprintf_test16 -c_runtime/vsprintf/test17/paltest_vsprintf_test17 -c_runtime/vsprintf/test18/paltest_vsprintf_test18 -c_runtime/vsprintf/test19/paltest_vsprintf_test19 -c_runtime/vsprintf/test2/paltest_vsprintf_test2 -c_runtime/vsprintf/test3/paltest_vsprintf_test3 -c_runtime/vsprintf/test4/paltest_vsprintf_test4 -c_runtime/vsprintf/test6/paltest_vsprintf_test6 -c_runtime/vsprintf/test7/paltest_vsprintf_test7 -c_runtime/vsprintf/test8/paltest_vsprintf_test8 -c_runtime/vsprintf/test9/paltest_vsprintf_test9 -c_runtime/vswprintf/test1/paltest_vswprintf_test1 -c_runtime/vswprintf/test10/paltest_vswprintf_test10 -c_runtime/vswprintf/test11/paltest_vswprintf_test11 -c_runtime/vswprintf/test12/paltest_vswprintf_test12 -c_runtime/vswprintf/test13/paltest_vswprintf_test13 -c_runtime/vswprintf/test14/paltest_vswprintf_test14 -c_runtime/vswprintf/test15/paltest_vswprintf_test15 -c_runtime/vswprintf/test16/paltest_vswprintf_test16 -c_runtime/vswprintf/test17/paltest_vswprintf_test17 -c_runtime/vswprintf/test18/paltest_vswprintf_test18 -c_runtime/vswprintf/test19/paltest_vswprintf_test19 -c_runtime/vswprintf/test3/paltest_vswprintf_test3 -c_runtime/vswprintf/test4/paltest_vswprintf_test4 -c_runtime/vswprintf/test6/paltest_vswprintf_test6 -c_runtime/vswprintf/test8/paltest_vswprintf_test8 -c_runtime/vswprintf/test9/paltest_vswprintf_test9 -c_runtime/wcscat/test1/paltest_wcscat_test1 -c_runtime/wcschr/test1/paltest_wcschr_test1 -c_runtime/wcscmp/test1/paltest_wcscmp_test1 -c_runtime/wcscpy/test1/paltest_wcscpy_test1 -c_runtime/wcslen/test1/paltest_wcslen_test1 -c_runtime/wcsncat/test1/paltest_wcsncat_test1 -c_runtime/wcsncmp/test1/paltest_wcsncmp_test1 -c_runtime/wcsncpy/test1/paltest_wcsncpy_test1 -c_runtime/wcspbrk/test1/paltest_wcspbrk_test1 -c_runtime/wcsrchr/test1/paltest_wcsrchr_test1 -c_runtime/wcsstr/test1/paltest_wcsstr_test1 -c_runtime/wcstod/test1/paltest_wcstod_test1 -c_runtime/wcstod/test2/paltest_wcstod_test2 -c_runtime/wcstok/test1/paltest_wcstok_test1 -c_runtime/wcstol/test1/paltest_wcstol_test1 -c_runtime/wcstol/test2/paltest_wcstol_test2 -c_runtime/wcstol/test3/paltest_wcstol_test3 -c_runtime/wcstol/test4/paltest_wcstol_test4 -c_runtime/wcstol/test5/paltest_wcstol_test5 -c_runtime/wcstol/test6/paltest_wcstol_test6 -c_runtime/wcstoul/test1/paltest_wcstoul_test1 -c_runtime/wcstoul/test2/paltest_wcstoul_test2 -c_runtime/wcstoul/test3/paltest_wcstoul_test3 -c_runtime/wcstoul/test4/paltest_wcstoul_test4 -c_runtime/wcstoul/test5/paltest_wcstoul_test5 -c_runtime/wcstoul/test6/paltest_wcstoul_test6 -c_runtime/wprintf/test1/paltest_wprintf_test1 -c_runtime/_alloca/test1/paltest_alloca_test1 -c_runtime/_fdopen/test1/paltest_fdopen_test1 -c_runtime/_finite/test1/paltest_finite_test1 -c_runtime/_finitef/test1/paltest_finitef_test1 -c_runtime/_fullpath/test1/paltest_fullpath_test1 -c_runtime/_isnan/test1/paltest_isnan_test1 -c_runtime/_isnanf/test1/paltest_isnanf_test1 -c_runtime/_itow/test1/paltest_itow_test1 -c_runtime/_mbsdec/test1/paltest_mbsdec_test1 -c_runtime/_mbsinc/test1/paltest_mbsinc_test1 -c_runtime/_mbsninc/test1/paltest_mbsninc_test1 -c_runtime/_open_osfhandle/test1/paltest_open_osfhandle_test1 -c_runtime/_open_osfhandle/test2/paltest_open_osfhandle_test2 -c_runtime/_putenv/test1/paltest_putenv_test1 -c_runtime/_putenv/test2/paltest_putenv_test2 -c_runtime/_putenv/test3/paltest_putenv_test3 -c_runtime/_putenv/test4/paltest_putenv_test4 -c_runtime/_rotl/test1/paltest_rotl_test1 -c_runtime/_rotr/test1/paltest_rotr_test1 -c_runtime/_snprintf_s/test1/paltest_snprintf_test1 -c_runtime/_snprintf_s/test10/paltest_snprintf_test10 -c_runtime/_snprintf_s/test11/paltest_snprintf_test11 -c_runtime/_snprintf_s/test12/paltest_snprintf_test12 -c_runtime/_snprintf_s/test13/paltest_snprintf_test13 -c_runtime/_snprintf_s/test14/paltest_snprintf_test14 -c_runtime/_snprintf_s/test15/paltest_snprintf_test15 -c_runtime/_snprintf_s/test16/paltest_snprintf_test16 -c_runtime/_snprintf_s/test17/paltest_snprintf_test17 -c_runtime/_snprintf_s/test18/paltest_snprintf_test18 -c_runtime/_snprintf_s/test19/paltest_snprintf_test19 -c_runtime/_snprintf_s/test2/paltest_snprintf_test2 -c_runtime/_snprintf_s/test3/paltest_snprintf_test3 -c_runtime/_snprintf_s/test4/paltest_snprintf_test4 -c_runtime/_snprintf_s/test6/paltest_snprintf_test6 -c_runtime/_snprintf_s/test7/paltest_snprintf_test7 -c_runtime/_snprintf_s/test8/paltest_snprintf_test8 -c_runtime/_snprintf_s/test9/paltest_snprintf_test9 -c_runtime/_snwprintf_s/test1/paltest_snwprintf_test1 -c_runtime/_snwprintf_s/test10/paltest_snwprintf_test10 -c_runtime/_snwprintf_s/test11/paltest_snwprintf_test11 -c_runtime/_snwprintf_s/test12/paltest_snwprintf_test12 -c_runtime/_snwprintf_s/test13/paltest_snwprintf_test13 -c_runtime/_snwprintf_s/test14/paltest_snwprintf_test14 -c_runtime/_snwprintf_s/test15/paltest_snwprintf_test15 -c_runtime/_snwprintf_s/test16/paltest_snwprintf_test16 -c_runtime/_snwprintf_s/test17/paltest_snwprintf_test17 -c_runtime/_snwprintf_s/test18/paltest_snwprintf_test18 -c_runtime/_snwprintf_s/test19/paltest_snwprintf_test19 -c_runtime/_snwprintf_s/test3/paltest_snwprintf_test3 -c_runtime/_snwprintf_s/test4/paltest_snwprintf_test4 -c_runtime/_snwprintf_s/test6/paltest_snwprintf_test6 -c_runtime/_snwprintf_s/test8/paltest_snwprintf_test8 -c_runtime/_snwprintf_s/test9/paltest_snwprintf_test9 -c_runtime/_stricmp/test1/paltest_stricmp_test1 -c_runtime/_strlwr/test1/paltest_strlwr_test1 -c_runtime/_strnicmp/test1/paltest_strnicmp_test1 -c_runtime/_vsnprintf_s/test1/paltest_vsnprintf_test1 -c_runtime/_vsnprintf_s/test10/paltest_vsnprintf_test10 -c_runtime/_vsnprintf_s/test11/paltest_vsnprintf_test11 -c_runtime/_vsnprintf_s/test12/paltest_vsnprintf_test12 -c_runtime/_vsnprintf_s/test13/paltest_vsnprintf_test13 -c_runtime/_vsnprintf_s/test14/paltest_vsnprintf_test14 -c_runtime/_vsnprintf_s/test15/paltest_vsnprintf_test15 -c_runtime/_vsnprintf_s/test16/paltest_vsnprintf_test16 -c_runtime/_vsnprintf_s/test17/paltest_vsnprintf_test17 -c_runtime/_vsnprintf_s/test18/paltest_vsnprintf_test18 -c_runtime/_vsnprintf_s/test19/paltest_vsnprintf_test19 -c_runtime/_vsnprintf_s/test2/paltest_vsnprintf_test2 -c_runtime/_vsnprintf_s/test3/paltest_vsnprintf_test3 -c_runtime/_vsnprintf_s/test4/paltest_vsnprintf_test4 -c_runtime/_vsnprintf_s/test6/paltest_vsnprintf_test6 -c_runtime/_vsnprintf_s/test7/paltest_vsnprintf_test7 -c_runtime/_vsnprintf_s/test8/paltest_vsnprintf_test8 -c_runtime/_vsnprintf_s/test9/paltest_vsnprintf_test9 -c_runtime/_vsnwprintf_s/test1/paltest_vsnwprintf_test1 -c_runtime/_vsnwprintf_s/test10/paltest_vsnwprintf_test10 -c_runtime/_vsnwprintf_s/test11/paltest_vsnwprintf_test11 -c_runtime/_vsnwprintf_s/test12/paltest_vsnwprintf_test12 -c_runtime/_vsnwprintf_s/test13/paltest_vsnwprintf_test13 -c_runtime/_vsnwprintf_s/test14/paltest_vsnwprintf_test14 -c_runtime/_vsnwprintf_s/test15/paltest_vsnwprintf_test15 -c_runtime/_vsnwprintf_s/test16/paltest_vsnwprintf_test16 -c_runtime/_vsnwprintf_s/test17/paltest_vsnwprintf_test17 -c_runtime/_vsnwprintf_s/test18/paltest_vsnwprintf_test18 -c_runtime/_vsnwprintf_s/test19/paltest_vsnwprintf_test19 -c_runtime/_vsnwprintf_s/test3/paltest_vsnwprintf_test3 -c_runtime/_vsnwprintf_s/test4/paltest_vsnwprintf_test4 -c_runtime/_vsnwprintf_s/test6/paltest_vsnwprintf_test6 -c_runtime/_vsnwprintf_s/test8/paltest_vsnwprintf_test8 -c_runtime/_vsnwprintf_s/test9/paltest_vsnwprintf_test9 -c_runtime/_wcsicmp/test1/paltest_wcsicmp_test1 -c_runtime/_wcslwr/test1/paltest_wcslwr_test1 -c_runtime/_wcsnicmp/test1/paltest_wcsnicmp_test1 -c_runtime/_wfopen/test1/paltest_wfopen_test1 -c_runtime/_wfopen/test2/paltest_wfopen_test2 -c_runtime/_wfopen/test3/paltest_wfopen_test3 -c_runtime/_wfopen/test4/paltest_wfopen_test4 -c_runtime/_wfopen/test5/paltest_wfopen_test5 -c_runtime/_wfopen/test6/paltest_wfopen_test6 -c_runtime/_wfopen/test7/paltest_wfopen_test7 -c_runtime/_wtoi/test1/paltest_wtoi_test1 -c_runtime/__iscsym/test1/paltest_iscsym_test1 -debug_api/OutputDebugStringW/test1/paltest_outputdebugstringw_test1 -exception_handling/RaiseException/test1/paltest_raiseexception_test1 -exception_handling/RaiseException/test2/paltest_raiseexception_test2 -exception_handling/RaiseException/test3/paltest_raiseexception_test3 -exception_handling/pal_sxs/test1/paltest_pal_sxs_test1 -filemapping_memmgt/CreateFileMappingA/test1/paltest_createfilemappinga_test1 -filemapping_memmgt/CreateFileMappingA/test3/paltest_createfilemappinga_test3 -filemapping_memmgt/CreateFileMappingA/test4/paltest_createfilemappinga_test4 -filemapping_memmgt/CreateFileMappingA/test8/paltest_createfilemappinga_test8 -filemapping_memmgt/CreateFileMappingA/test9/paltest_createfilemappinga_test9 -filemapping_memmgt/CreateFileMappingW/test1/paltest_createfilemappingw_test1 -filemapping_memmgt/CreateFileMappingW/test3/paltest_createfilemappingw_test3 -filemapping_memmgt/CreateFileMappingW/test4/paltest_createfilemappingw_test4 -filemapping_memmgt/CreateFileMappingW/test8/paltest_createfilemappingw_test8 -filemapping_memmgt/CreateFileMappingW/test9/paltest_createfilemappingw_test9 -filemapping_memmgt/FreeLibrary/test2/paltest_freelibrary_test2 -filemapping_memmgt/GetModuleFileNameA/test2/paltest_getmodulefilenamea_test2 -filemapping_memmgt/GetModuleFileNameW/test2/paltest_getmodulefilenamew_test2 -filemapping_memmgt/GetProcessHeap/test1/paltest_getprocessheap_test1 -filemapping_memmgt/HeapAlloc/test1/paltest_heapalloc_test1 -filemapping_memmgt/HeapAlloc/test2/paltest_heapalloc_test2 -filemapping_memmgt/HeapAlloc/test3/paltest_heapalloc_test3 -filemapping_memmgt/HeapFree/test1/paltest_heapfree_test1 -filemapping_memmgt/HeapReAlloc/test1/paltest_heaprealloc_test1 -filemapping_memmgt/HeapReAlloc/test2/paltest_heaprealloc_test2 -filemapping_memmgt/HeapReAlloc/test3/paltest_heaprealloc_test3 -filemapping_memmgt/HeapReAlloc/test4/paltest_heaprealloc_test4 -filemapping_memmgt/HeapReAlloc/test5/paltest_heaprealloc_test5 -filemapping_memmgt/LocalAlloc/test1/paltest_localalloc_test1 -filemapping_memmgt/LocalFree/test1/paltest_localfree_test1 -filemapping_memmgt/LocalFree/test2/paltest_localfree_test2 -filemapping_memmgt/MapViewOfFile/test1/paltest_mapviewoffile_test1 -filemapping_memmgt/MapViewOfFile/test2/paltest_mapviewoffile_test2 -filemapping_memmgt/MapViewOfFile/test3/paltest_mapviewoffile_test3 -filemapping_memmgt/MapViewOfFile/test4/paltest_mapviewoffile_test4 -filemapping_memmgt/MapViewOfFile/test5/paltest_mapviewoffile_test5 -filemapping_memmgt/MapViewOfFile/test6/paltest_mapviewoffile_test6 -filemapping_memmgt/ProbeMemory/test1/paltest_probememory_test1 -filemapping_memmgt/ProbeMemory/ProbeMemory_neg1/paltest_probememory_probememory_neg1 -filemapping_memmgt/RtlMoveMemory/test1/paltest_rtlmovememory_test1 -filemapping_memmgt/RtlMoveMemory/test3/paltest_rtlmovememory_test3 -filemapping_memmgt/RtlMoveMemory/test4/paltest_rtlmovememory_test4 -filemapping_memmgt/RtlMoveMemory/test5/paltest_rtlmovememory_test5 -filemapping_memmgt/UnmapViewOfFile/test1/paltest_unmapviewoffile_test1 -filemapping_memmgt/UnmapViewOfFile/test2/paltest_unmapviewoffile_test2 -filemapping_memmgt/VirtualAlloc/test1/paltest_virtualalloc_test1 -filemapping_memmgt/VirtualAlloc/test10/paltest_virtualalloc_test10 -filemapping_memmgt/VirtualAlloc/test11/paltest_virtualalloc_test11 -filemapping_memmgt/VirtualAlloc/test12/paltest_virtualalloc_test12 -filemapping_memmgt/VirtualAlloc/test13/paltest_virtualalloc_test13 -filemapping_memmgt/VirtualAlloc/test14/paltest_virtualalloc_test14 -filemapping_memmgt/VirtualAlloc/test15/paltest_virtualalloc_test15 -filemapping_memmgt/VirtualAlloc/test16/paltest_virtualalloc_test16 -filemapping_memmgt/VirtualAlloc/test17/paltest_virtualalloc_test17 -filemapping_memmgt/VirtualAlloc/test18/paltest_virtualalloc_test18 -filemapping_memmgt/VirtualAlloc/test19/paltest_virtualalloc_test19 -filemapping_memmgt/VirtualAlloc/test2/paltest_virtualalloc_test2 -filemapping_memmgt/VirtualAlloc/test20/paltest_virtualalloc_test20 -filemapping_memmgt/VirtualAlloc/test21/paltest_virtualalloc_test21 -filemapping_memmgt/VirtualAlloc/test3/paltest_virtualalloc_test3 -filemapping_memmgt/VirtualAlloc/test4/paltest_virtualalloc_test4 -filemapping_memmgt/VirtualAlloc/test5/paltest_virtualalloc_test5 -filemapping_memmgt/VirtualAlloc/test6/paltest_virtualalloc_test6 -filemapping_memmgt/VirtualAlloc/test7/paltest_virtualalloc_test7 -filemapping_memmgt/VirtualAlloc/test8/paltest_virtualalloc_test8 -filemapping_memmgt/VirtualAlloc/test9/paltest_virtualalloc_test9 -filemapping_memmgt/VirtualFree/test1/paltest_virtualfree_test1 -filemapping_memmgt/VirtualFree/test2/paltest_virtualfree_test2 -filemapping_memmgt/VirtualFree/test3/paltest_virtualfree_test3 -filemapping_memmgt/VirtualProtect/test1/paltest_virtualprotect_test1 -filemapping_memmgt/VirtualProtect/test2/paltest_virtualprotect_test2 -filemapping_memmgt/VirtualProtect/test3/paltest_virtualprotect_test3 -filemapping_memmgt/VirtualProtect/test4/paltest_virtualprotect_test4 -filemapping_memmgt/VirtualProtect/test6/paltest_virtualprotect_test6 -filemapping_memmgt/VirtualProtect/test7/paltest_virtualprotect_test7 -filemapping_memmgt/VirtualQuery/test1/paltest_virtualquery_test1 -file_io/CompareFileTime/test1/paltest_comparefiletime_test1 -file_io/CopyFileA/test1/paltest_copyfilea_test1 -file_io/CopyFileA/test2/paltest_copyfilea_test2 -file_io/CopyFileA/test3/paltest_copyfilea_test3 -file_io/CopyFileA/test4/paltest_copyfilea_test4 -file_io/CopyFileW/test2/paltest_copyfilew_test2 -file_io/CopyFileW/test3/paltest_copyfilew_test3 -file_io/CreateDirectoryA/test1/paltest_createdirectorya_test1 -file_io/CreateDirectoryW/test1/paltest_createdirectoryw_test1 -file_io/DeleteFileA/test1/paltest_deletefilea_test1 -file_io/DeleteFileW/test1/paltest_deletefilew_test1 -file_io/errorpathnotfound/test2/paltest_errorpathnotfound_test2 -file_io/errorpathnotfound/test3/paltest_errorpathnotfound_test3 -file_io/FILECanonicalizePath/paltest_filecanonicalizepath_test1 -file_io/FindClose/test1/paltest_findclose_test1 -file_io/FindFirstFileA/test1/paltest_findfirstfilea_test1 -file_io/FindFirstFileW/test1/paltest_findfirstfilew_test1 -file_io/FindNextFileA/test1/paltest_findnextfilea_test1 -file_io/FindNextFileA/test2/paltest_findnextfilea_test2 -file_io/FindNextFileW/test1/paltest_findnextfilew_test1 -file_io/FindNextFileW/test2/paltest_findnextfilew_test2 -file_io/FlushFileBuffers/test1/paltest_flushfilebuffers_test1 -file_io/GetConsoleOutputCP/test1/paltest_getconsoleoutputcp_test1 -file_io/GetCurrentDirectoryA/test1/paltest_getcurrentdirectorya_test1 -file_io/GetCurrentDirectoryW/test1/paltest_getcurrentdirectoryw_test1 -file_io/GetFileAttributesA/test1/paltest_getfileattributesa_test1 -file_io/GetFileAttributesExW/test2/paltest_getfileattributesexw_test2 -file_io/GetFileAttributesW/test1/paltest_getfileattributesw_test1 -file_io/GetFileSize/test1/paltest_getfilesize_test1 -file_io/GetFileSizeEx/test1/paltest_getfilesizeex_test1 -file_io/GetFullPathNameA/test1/paltest_getfullpathnamea_test1 -file_io/GetFullPathNameA/test3/paltest_getfullpathnamea_test3 -file_io/GetFullPathNameA/test4/paltest_getfullpathnamea_test4 -file_io/GetFullPathNameW/test1/paltest_getfullpathnamew_test1 -file_io/GetFullPathNameW/test3/paltest_getfullpathnamew_test3 -file_io/GetFullPathNameW/test4/paltest_getfullpathnamew_test4 -file_io/GetLongPathNameW/test1/paltest_getlongpathnamew_test1 -file_io/GetLongPathNameW/test2/paltest_getlongpathnamew_test2 -file_io/GetStdHandle/test2/paltest_getstdhandle_test2 -file_io/GetSystemTime/test1/paltest_getsystemtime_test1 -file_io/GetSystemTimeAsFileTime/test1/paltest_getsystemtimeasfiletime_test1 -file_io/GetTempFileNameA/test1/paltest_gettempfilenamea_test1 -file_io/GetTempFileNameA/test2/paltest_gettempfilenamea_test2 -file_io/GetTempFileNameA/test3/paltest_gettempfilenamea_test3 -file_io/GetTempFileNameW/test3/paltest_gettempfilenamew_test3 -file_io/gettemppatha/test1/paltest_gettemppatha_test1 -file_io/GetTempPathW/test1/paltest_gettemppathw_test1 -file_io/ReadFile/test2/paltest_readfile_test2 -file_io/ReadFile/test3/paltest_readfile_test3 -file_io/ReadFile/test4/paltest_readfile_test4 -file_io/RemoveDirectoryA/test1/paltest_removedirectorya_test1 -file_io/RemoveDirectoryW/test1/paltest_removedirectoryw_test1 -file_io/SearchPathA/test1/paltest_searchpatha_test1 -file_io/SearchPathW/test1/paltest_searchpathw_test1 -file_io/SetCurrentDirectoryA/test1/paltest_setcurrentdirectorya_test1 -file_io/SetCurrentDirectoryA/test2/paltest_setcurrentdirectorya_test2 -file_io/SetCurrentDirectoryA/test3/paltest_setcurrentdirectorya_test3 -file_io/SetCurrentDirectoryW/test1/paltest_setcurrentdirectoryw_test1 -file_io/SetCurrentDirectoryW/test2/paltest_setcurrentdirectoryw_test2 -file_io/SetCurrentDirectoryW/test3/paltest_setcurrentdirectoryw_test3 -file_io/SetEndOfFile/test1/paltest_setendoffile_test1 -file_io/SetEndOfFile/test2/paltest_setendoffile_test2 -file_io/SetEndOfFile/test3/paltest_setendoffile_test3 -file_io/SetEndOfFile/test4/paltest_setendoffile_test4 -file_io/SetEndOfFile/test5/paltest_setendoffile_test5 -file_io/SetFileAttributesA/test2/paltest_setfileattributesa_test2 -file_io/SetFileAttributesA/test3/paltest_setfileattributesa_test3 -file_io/SetFileAttributesW/test2/paltest_setfileattributesw_test2 -file_io/SetFileAttributesW/test3/paltest_setfileattributesw_test3 -file_io/SetFilePointer/test1/paltest_setfilepointer_test1 -file_io/SetFilePointer/test2/paltest_setfilepointer_test2 -file_io/SetFilePointer/test3/paltest_setfilepointer_test3 -file_io/SetFilePointer/test4/paltest_setfilepointer_test4 -file_io/SetFilePointer/test5/paltest_setfilepointer_test5 -file_io/SetFilePointer/test6/paltest_setfilepointer_test6 -file_io/SetFilePointer/test7/paltest_setfilepointer_test7 -file_io/WriteFile/test1/paltest_writefile_test1 -file_io/WriteFile/test3/paltest_writefile_test3 -file_io/WriteFile/test4/paltest_writefile_test4 -file_io/WriteFile/test5/paltest_writefile_test5 -loader/LoadLibraryA/test2/paltest_loadlibrarya_test2 -loader/LoadLibraryA/test3/paltest_loadlibrarya_test3 -loader/LoadLibraryA/test5/paltest_loadlibrarya_test5 -loader/LoadLibraryW/test2/paltest_loadlibraryw_test2 -loader/LoadLibraryW/test3/paltest_loadlibraryw_test3 -loader/LoadLibraryW/test5/paltest_loadlibraryw_test5 -locale_info/GetACP/test1/paltest_getacp_test1 -locale_info/GetCPInfo/test1/paltest_getcpinfo_test1 -locale_info/GetCPInfo/test3/paltest_getcpinfo_test3 -locale_info/IsDBCSLeadByte/test1/paltest_isdbcsleadbyte_test1 -locale_info/IsDBCSLeadByteEx/test1/paltest_isdbcsleadbyteex_test1 -locale_info/IsValidCodePage/test1/paltest_isvalidcodepage_test1 -locale_info/MultiByteToWideChar/test1/paltest_multibytetowidechar_test1 -locale_info/MultiByteToWideChar/test2/paltest_multibytetowidechar_test2 -locale_info/MultiByteToWideChar/test3/paltest_multibytetowidechar_test3 -locale_info/MultiByteToWideChar/test4/paltest_multibytetowidechar_test4 -locale_info/WideCharToMultiByte/test1/paltest_widechartomultibyte_test1 -locale_info/WideCharToMultiByte/test2/paltest_widechartomultibyte_test2 -locale_info/WideCharToMultiByte/test3/paltest_widechartomultibyte_test3 -locale_info/WideCharToMultiByte/test5/paltest_widechartomultibyte_test5 -miscellaneous/CharNextA/test1/paltest_charnexta_test1 -miscellaneous/CharNextA/test2/paltest_charnexta_test2 -miscellaneous/CharNextExA/test1/paltest_charnextexa_test1 -miscellaneous/CharNextExA/test2/paltest_charnextexa_test2 -miscellaneous/CloseHandle/test1/paltest_closehandle_test1 -miscellaneous/CloseHandle/test2/paltest_closehandle_test2 -miscellaneous/CreatePipe/test1/paltest_createpipe_test1 -miscellaneous/FlushInstructionCache/test1/paltest_flushinstructioncache_test1 -miscellaneous/FormatMessageW/test1/paltest_formatmessagew_test1 -miscellaneous/FormatMessageW/test2/paltest_formatmessagew_test2 -miscellaneous/FormatMessageW/test3/paltest_formatmessagew_test3 -miscellaneous/FreeEnvironmentStringsW/test1/paltest_freeenvironmentstringsw_test1 -miscellaneous/FreeEnvironmentStringsW/test2/paltest_freeenvironmentstringsw_test2 -miscellaneous/GetCommandLineW/test1/paltest_getcommandlinew_test1 -miscellaneous/GetEnvironmentStringsW/test1/paltest_getenvironmentstringsw_test1 -miscellaneous/GetEnvironmentVariableA/test1/paltest_getenvironmentvariablea_test1 -miscellaneous/GetEnvironmentVariableA/test2/paltest_getenvironmentvariablea_test2 -miscellaneous/GetEnvironmentVariableA/test3/paltest_getenvironmentvariablea_test3 -miscellaneous/GetEnvironmentVariableA/test4/paltest_getenvironmentvariablea_test4 -miscellaneous/GetEnvironmentVariableA/test5/paltest_getenvironmentvariablea_test5 -miscellaneous/GetEnvironmentVariableA/test6/paltest_getenvironmentvariablea_test6 -miscellaneous/GetEnvironmentVariableW/test1/paltest_getenvironmentvariablew_test1 -miscellaneous/GetEnvironmentVariableW/test2/paltest_getenvironmentvariablew_test2 -miscellaneous/GetEnvironmentVariableW/test3/paltest_getenvironmentvariablew_test3 -miscellaneous/GetEnvironmentVariableW/test4/paltest_getenvironmentvariablew_test4 -miscellaneous/GetEnvironmentVariableW/test5/paltest_getenvironmentvariablew_test5 -miscellaneous/GetEnvironmentVariableW/test6/paltest_getenvironmentvariablew_test6 -miscellaneous/GetLastError/test1/paltest_getlasterror_test1 -miscellaneous/GetSystemInfo/test1/paltest_getsysteminfo_test1 -miscellaneous/GlobalMemoryStatusEx/test1/paltest_globalmemorystatusex_test1 -miscellaneous/GetTickCount/test1/paltest_gettickcount_test1 -miscellaneous/InterlockedCompareExchange/test1/paltest_interlockedcompareexchange_test1 -miscellaneous/InterlockedCompareExchange/test2/paltest_interlockedcompareexchange_test2 -miscellaneous/InterlockedCompareExchange64/test1/paltest_interlockedcompareexchange64_test1 -miscellaneous/InterlockedCompareExchange64/test2/paltest_interlockedcompareexchange64_test2 -miscellaneous/InterlockedCompareExchangePointer/test1/paltest_interlockedcompareexchangepointer_test1 -miscellaneous/InterlockedDecrement/test1/paltest_interlockeddecrement_test1 -miscellaneous/InterlockedDecrement/test2/paltest_interlockeddecrement_test2 -miscellaneous/InterlockedDecrement64/test1/paltest_interlockeddecrement64_test1 -miscellaneous/InterlockedDecrement64/test2/paltest_interlockeddecrement64_test2 -miscellaneous/InterlockedExchange/test1/paltest_interlockedexchange_test1 -miscellaneous/InterlockedExchange64/test1/paltest_interlockedexchange64_test1 -miscellaneous/InterlockedExchangePointer/test1/paltest_interlockedexchangepointer_test1 -miscellaneous/InterlockedIncrement/test1/paltest_interlockedincrement_test1 -miscellaneous/InterlockedIncrement/test2/paltest_interlockedincrement_test2 -miscellaneous/InterlockedIncrement64/test1/paltest_interlockedincrement64_test1 -miscellaneous/InterlockedIncrement64/test2/paltest_interlockedincrement64_test2 -miscellaneous/lstrlenA/test1/paltest_lstrlena_test1 -miscellaneous/lstrlenW/test1/paltest_lstrlenw_test1 -miscellaneous/queryperformancefrequency/test1/paltest_queryperformancefrequency_test1 -miscellaneous/SetEnvironmentVariableA/test1/paltest_setenvironmentvariablea_test1 -miscellaneous/SetEnvironmentVariableA/test2/paltest_setenvironmentvariablea_test2 -miscellaneous/SetEnvironmentVariableA/test3/paltest_setenvironmentvariablea_test3 -miscellaneous/SetEnvironmentVariableA/test4/paltest_setenvironmentvariablea_test4 -miscellaneous/SetEnvironmentVariableW/test1/paltest_setenvironmentvariablew_test1 -miscellaneous/SetEnvironmentVariableW/test2/paltest_setenvironmentvariablew_test2 -miscellaneous/SetEnvironmentVariableW/test3/paltest_setenvironmentvariablew_test3 -miscellaneous/SetEnvironmentVariableW/test4/paltest_setenvironmentvariablew_test4 -miscellaneous/SetLastError/test1/paltest_setlasterror_test1 -miscellaneous/_i64tow/test1/paltest_i64tow_test1 -pal_specific/pal_entrypoint/test1/paltest_pal_entrypoint_test1 -pal_specific/PAL_errno/test1/paltest_pal_errno_test1 -pal_specific/pal_initializedebug/test1/paltest_pal_initializedebug_test1 -pal_specific/PAL_Initialize_Terminate/test1/paltest_pal_initialize_terminate_test1 -pal_specific/PAL_Initialize_Terminate/test2/paltest_pal_initialize_terminate_test2 -samples/test1/paltest_samples_test1 -threading/CreateEventA/test1/paltest_createeventa_test1 -threading/CreateEventA/test2/paltest_createeventa_test2 -threading/CreateEventW/test1/paltest_createeventw_test1 -threading/CreateEventW/test2/paltest_createeventw_test2 -threading/CreateMutexA_ReleaseMutex/test1/paltest_createmutexa_releasemutex_test1 -threading/CreateMutexW_ReleaseMutex/test1/paltest_createmutexw_releasemutex_test1 -threading/CreateProcessA/test1/paltest_createprocessa_test1 -threading/CreateProcessA/test2/paltest_createprocessa_test2 -threading/CreateProcessW/test1/paltest_createprocessw_test1 -threading/CreateProcessW/test2/paltest_createprocessw_test2 -threading/CreateSemaphoreA_ReleaseSemaphore/test1/paltest_createsemaphorea_releasesemaphore_test1 -threading/CreateSemaphoreA_ReleaseSemaphore/test2/paltest_createsemaphorea_releasesemaphore_test2 -threading/CreateSemaphoreW_ReleaseSemaphore/test1/paltest_createsemaphorew_releasesemaphore_test1 -threading/CreateSemaphoreW_ReleaseSemaphore/test2/paltest_createsemaphorew_releasesemaphore_test2 -threading/CreateThread/test1/paltest_createthread_test1 -threading/CreateThread/test3/paltest_createthread_test3 -threading/CriticalSectionFunctions/test1/paltest_criticalsectionfunctions_test1 -threading/CriticalSectionFunctions/test2/paltest_criticalsectionfunctions_test2 -threading/CriticalSectionFunctions/test3/paltest_criticalsectionfunctions_test3 -threading/CriticalSectionFunctions/test4/paltest_criticalsectionfunctions_test4 -threading/CriticalSectionFunctions/test7/paltest_criticalsectionfunctions_test7 -threading/CriticalSectionFunctions/test8/paltest_criticalsectionfunctions_test8 -threading/DuplicateHandle/test10/paltest_duplicatehandle_test10 -threading/DuplicateHandle/test2/paltest_duplicatehandle_test2 -threading/DuplicateHandle/test4/paltest_duplicatehandle_test4 -threading/DuplicateHandle/test5/paltest_duplicatehandle_test5 -threading/DuplicateHandle/test6/paltest_duplicatehandle_test6 -threading/DuplicateHandle/test7/paltest_duplicatehandle_test7 -threading/DuplicateHandle/test8/paltest_duplicatehandle_test8 -threading/ExitProcess/test1/paltest_exitprocess_test1 -threading/ExitProcess/test2/paltest_exitprocess_test2 -threading/ExitProcess/test3/paltest_exitprocess_test3 -threading/ExitThread/test1/paltest_exitthread_test1 -threading/GetCurrentProcessId/test1/paltest_getcurrentprocessid_test1 -threading/GetCurrentThread/test1/paltest_getcurrentthread_test1 -threading/GetCurrentThread/test2/paltest_getcurrentthread_test2 -threading/GetProcessTimes/test2/paltest_getprocesstimes_test2 -threading/GetThreadTimes/test1/paltest_getthreadtimes_test1 -threading/NamedMutex/test1/paltest_namedmutex_test1 -threading/QueryThreadCycleTime/test1/paltest_querythreadcycletime_test1 -threading/QueueUserAPC/test2/paltest_queueuserapc_test2 -threading/QueueUserAPC/test3/paltest_queueuserapc_test3 -threading/QueueUserAPC/test4/paltest_queueuserapc_test4 -threading/QueueUserAPC/test5/paltest_queueuserapc_test5 -threading/QueueUserAPC/test6/paltest_queueuserapc_test6 -threading/QueueUserAPC/test7/paltest_queueuserapc_test7 -threading/ReleaseMutex/test3/paltest_releasemutex_test3 -threading/releasesemaphore/test1/paltest_releasesemaphore_test1 -threading/ResetEvent/test1/paltest_resetevent_test1 -threading/ResetEvent/test2/paltest_resetevent_test2 -threading/ResetEvent/test3/paltest_resetevent_test3 -threading/ResetEvent/test4/paltest_resetevent_test4 -threading/ResumeThread/test1/paltest_resumethread_test1 -threading/SetErrorMode/test1/paltest_seterrormode_test1 -threading/SetEvent/test1/paltest_setevent_test1 -threading/SetEvent/test2/paltest_setevent_test2 -threading/SetEvent/test3/paltest_setevent_test3 -threading/SetEvent/test4/paltest_setevent_test4 -threading/SwitchToThread/test1/paltest_switchtothread_test1 -threading/ThreadPriority/test1/paltest_threadpriority_test1 -threading/TLS/test1/paltest_tls_test1 -threading/TLS/test2/paltest_tls_test2 -threading/TLS/test3/paltest_tls_test3 -threading/TLS/test4/paltest_tls_test4 -threading/TLS/test5/paltest_tls_test5 -threading/WaitForMultipleObjects/test1/paltest_waitformultipleobjects_test1 -threading/WaitForMultipleObjectsEx/test1/paltest_waitformultipleobjectsex_test1 -threading/WaitForMultipleObjectsEx/test2/paltest_waitformultipleobjectsex_test2 -threading/WaitForMultipleObjectsEx/test3/paltest_waitformultipleobjectsex_test3 -threading/WaitForMultipleObjectsEx/test4/paltest_waitformultipleobjectsex_test4 -threading/WaitForSingleObject/test1/paltest_waitforsingleobject_test1 -threading/WaitForSingleObject/WFSOExMutexTest/paltest_waitforsingleobject_wfsoexmutextest -threading/WaitForSingleObject/WFSOExSemaphoreTest/paltest_waitforsingleobject_wfsoexsemaphoretest -threading/WaitForSingleObject/WFSOExThreadTest/paltest_waitforsingleobject_wfsoexthreadtest -threading/WaitForSingleObject/WFSOMutexTest/paltest_waitforsingleobject_wfsomutextest -threading/WaitForSingleObject/WFSOSemaphoreTest/paltest_waitforsingleobject_wfsosemaphoretest -threading/WaitForSingleObject/WFSOThreadTest/paltest_waitforsingleobject_wfsothreadtest -threading/YieldProcessor/test1/paltest_yieldprocessor_test1 -eventprovider/eventprovidertest diff --git a/src/pal/tests/palsuite/paltestlist_to_be_reviewed.txt b/src/pal/tests/palsuite/paltestlist_to_be_reviewed.txt deleted file mode 100644 index 16be5e676..000000000 --- a/src/pal/tests/palsuite/paltestlist_to_be_reviewed.txt +++ /dev/null @@ -1,189 +0,0 @@ -This is a list of failing PAL tests that need to be reviewed because. -They should either be fixed or deleted if they are no longer applicable. - -c_runtime/ctime/test1/paltest_ctime_test1 -c_runtime/exit/test2/paltest_exit_test2 -c_runtime/feof/test1/paltest_feof_test1 -c_runtime/ferror/test1/paltest_ferror_test1 -c_runtime/ferror/test2/paltest_ferror_test2 -c_runtime/fputs/test2/paltest_fputs_test2 -c_runtime/fread/test1/paltest_fread_test1 -c_runtime/fread/test2/paltest_fread_test2 -c_runtime/fread/test3/paltest_fread_test3 -c_runtime/ftell/test1/paltest_ftell_test1 -c_runtime/fwprintf/test19/paltest_fwprintf_test19 -c_runtime/fwprintf/test2/paltest_fwprintf_test2 -c_runtime/fwprintf/test7/paltest_fwprintf_test7 -c_runtime/iswprint/test1/paltest_iswprint_test1 -c_runtime/swprintf/test2/paltest_swprintf_test2 -c_runtime/swprintf/test7/paltest_swprintf_test7 -c_runtime/ungetc/test2/paltest_ungetc_test2 -c_runtime/vprintf/test1/paltest_vprintf_test1 -c_runtime/vswprintf/test2/paltest_vswprintf_test2 -c_runtime/vswprintf/test7/paltest_vswprintf_test7 -c_runtime/wprintf/test2/paltest_wprintf_test2 -c_runtime/_gcvt/test1/paltest_gcvt_test1 -c_runtime/_gcvt/test2/paltest_gcvt_test2 -c_runtime/_getw/test1/paltest_getw_test1 -c_runtime/_snwprintf_s/test2/paltest_snwprintf_test2 -c_runtime/_snwprintf_s/test7/paltest_snwprintf_test7 -c_runtime/_vsnwprintf_s/test2/paltest_vsnwprintf_test2 -c_runtime/_vsnwprintf_s/test7/paltest_vsnwprintf_test7 -debug_api/DebugBreak/test1/paltest_debugbreak_test1 -debug_api/OutputDebugStringA/test1/paltest_outputdebugstringa_test1 -debug_api/WriteProcessMemory/test1/paltest_writeprocessmemory_test1 -debug_api/WriteProcessMemory/test3/paltest_writeprocessmemory_test3 -debug_api/WriteProcessMemory/test4/paltest_writeprocessmemory_test4 -exception_handling/pal_except/test1/paltest_pal_except_test1 -exception_handling/pal_except/test2/paltest_pal_except_test2 -exception_handling/pal_except/test3/paltest_pal_except_test3 -exception_handling/pal_except/test4/paltest_pal_except_test4 -exception_handling/pal_except/test5/paltest_pal_except_test5 -exception_handling/pal_except/test6/paltest_pal_except_test6 -exception_handling/pal_except/test7/paltest_pal_except_test7 -exception_handling/PAL_EXCEPT_FILTER/test1/paltest_pal_except_filter_test1 -exception_handling/PAL_EXCEPT_FILTER/test2/paltest_pal_except_filter_test2 -exception_handling/PAL_EXCEPT_FILTER/test3/paltest_pal_except_filter_test3 -exception_handling/PAL_EXCEPT_FILTER_EX/test1/paltest_pal_except_filter_ex_test1 -exception_handling/PAL_EXCEPT_FILTER_EX/test2/paltest_pal_except_filter_ex_test2 -exception_handling/PAL_EXCEPT_FILTER_EX/test3/paltest_pal_except_filter_ex_test3 -exception_handling/pal_finally/test1/paltest_pal_finally_test1 -exception_handling/PAL_GetBottommostRegistration/test1/paltest_pal_getbottommostregistration_test1 -exception_handling/PAL_GetBottommostRegistration/test2/paltest_pal_getbottommostregistration_test2 -exception_handling/PAL_TRY_EXCEPT/test1/paltest_pal_try_except_test1 -exception_handling/PAL_TRY_EXCEPT/test2/paltest_pal_try_except_test2 -exception_handling/PAL_TRY_EXCEPT_EX/test1/paltest_pal_try_except_ex_test1 -exception_handling/PAL_TRY_EXCEPT_EX/test2/paltest_pal_try_except_ex_test2 -exception_handling/PAL_TRY_EXCEPT_EX/test3/paltest_pal_try_except_ex_test3 -exception_handling/PAL_TRY_LEAVE_FINALLY/test1/paltest_pal_try_leave_finally_test1 -exception_handling/SetUnhandledExceptionFilter/test1/paltest_setunhandledexceptionfilter_test1 -filemapping_memmgt/CreateFileMappingA/test5/paltest_createfilemappinga_test5 -filemapping_memmgt/CreateFileMappingA/test6/paltest_createfilemappinga_test6 -filemapping_memmgt/CreateFileMappingA/test7/paltest_createfilemappinga_test7 -filemapping_memmgt/CreateFileMappingW/CreateFileMapping_neg1/paltest_createfilemappingw_createfilemapping_neg1 -filemapping_memmgt/CreateFileMappingW/test2/paltest_createfilemappingw_test2 -filemapping_memmgt/CreateFileMappingW/test5/paltest_createfilemappingw_test5 -filemapping_memmgt/CreateFileMappingW/test6/paltest_createfilemappingw_test6 -filemapping_memmgt/CreateFileMappingW/test7/paltest_createfilemappingw_test7 -filemapping_memmgt/FreeLibrary/test1/paltest_freelibrary_test1 -filemapping_memmgt/FreeLibraryAndExitThread/test1/paltest_freelibraryandexitthread_test1 -filemapping_memmgt/GetModuleFileNameA/test1/paltest_getmodulefilenamea_test1 -filemapping_memmgt/GetModuleFileNameW/test1/paltest_getmodulefilenamew_test1 -filemapping_memmgt/GetProcAddress/test1/paltest_getprocaddress_test1 -filemapping_memmgt/GetProcAddress/test2/paltest_getprocaddress_test2 -filemapping_memmgt/OpenFileMappingA/test1/paltest_openfilemappinga_test1 -filemapping_memmgt/OpenFileMappingA/test2/paltest_openfilemappinga_test2 -filemapping_memmgt/OpenFileMappingA/test3/paltest_openfilemappinga_test3 -filemapping_memmgt/OpenFileMappingW/test1/paltest_openfilemappingw_test1 -filemapping_memmgt/OpenFileMappingW/test2/paltest_openfilemappingw_test2 -filemapping_memmgt/OpenFileMappingW/test3/paltest_openfilemappingw_test3 -filemapping_memmgt/ReadProcessMemory/ReadProcessMemory_neg1/paltest_readprocessmemory_readprocessmemory_neg1 -filemapping_memmgt/ReadProcessMemory/test1/paltest_readprocessmemory_test1 -filemapping_memmgt/ReadProcessMemory/test2/paltest_readprocessmemory_test2 -file_io/CopyFileW/test1/paltest_copyfilew_test1 -file_io/CreateDirectoryA/test2/paltest_createdirectorya_test2 -file_io/CreateDirectoryW/test2/paltest_createdirectoryw_test2 -file_io/CreateFileA/test1/paltest_createfilea_test1 -file_io/CreateFileW/test1/paltest_createfilew_test1 -file_io/errorpathnotfound/test1/paltest_errorpathnotfound_test1 -file_io/GetFileAttributesExW/test1/paltest_getfileattributesexw_test1 -file_io/GetFullPathNameA/test2/paltest_getfullpathnamea_test2 -file_io/GetFullPathNameW/test2/paltest_getfullpathnamew_test2 -file_io/GetStdHandle/test1/paltest_getstdhandle_test1 -file_io/GetTempFileNameW/test1/paltest_gettempfilenamew_test1 -file_io/GetTempFileNameW/test2/paltest_gettempfilenamew_test2 -file_io/gettemppatha/test1/paltest_gettemppatha_test1 -file_io/GetTempPathW/test1/paltest_gettemppathw_test1 -file_io/MoveFileExA/test1/paltest_movefileexa_test1 -file_io/MoveFileExW/test1/paltest_movefileexw_test1 -file_io/ReadFile/test1/paltest_readfile_test1 -file_io/SetFileAttributesA/test1/paltest_setfileattributesa_test1 -file_io/SetFileAttributesA/test4/paltest_setfileattributesa_test4 -file_io/SetFileAttributesW/test1/paltest_setfileattributesw_test1 -file_io/SetFileAttributesW/test4/paltest_setfileattributesw_test4 -file_io/WriteFile/test2/paltest_writefile_test2 -loader/LoadLibraryA/test1/paltest_loadlibrarya_test1 -loader/LoadLibraryA/test6/paltest_loadlibrarya_test6 -loader/LoadLibraryA/test7/paltest_loadlibrarya_test7 -loader/LoadLibraryA/test8/paltest_loadlibrarya_test8 -loader/LoadLibraryW/test1/paltest_loadlibraryw_test1 -locale_info/CompareStringA/test1/paltest_comparestringa_test1 -locale_info/CompareStringW/test1/paltest_comparestringw_test1 -locale_info/GetCPInfo/test2/paltest_getcpinfo_test2 -locale_info/GetLocaleInfoW/test1/paltest_getlocaleinfow_test1 -locale_info/GetLocaleInfoW/test2/paltest_getlocaleinfow_test2 -locale_info/GetStringTypeExW/test1/paltest_getstringtypeexw_test1 -locale_info/GetStringTypeExW/test2/paltest_getstringtypeexw_test2 -locale_info/GetSystemDefaultLangID/test1/paltest_getsystemdefaultlangid_test1 -locale_info/GetThreadLocale/test1/paltest_getthreadlocale_test1 -locale_info/GetTimeZoneInformation/test1/paltest_gettimezoneinformation_test1 -locale_info/GetUserDefaultLangID/test1/paltest_getuserdefaultlangid_test1 -locale_info/GetUserDefaultLCID/test1/paltest_getuserdefaultlcid_test1 -locale_info/IsValidCodePage/test2/paltest_isvalidcodepage_test2 -locale_info/IsValidLocale/test1/paltest_isvalidlocale_test1 -locale_info/SetThreadLocale/test1/paltest_setthreadlocale_test1 -locale_info/WideCharToMultiByte/test4/paltest_widechartomultibyte_test4 -miscellaneous/FormatMessageW/test4/paltest_formatmessagew_test4 -miscellaneous/FormatMessageW/test5/paltest_formatmessagew_test5 -miscellaneous/FormatMessageW/test6/paltest_formatmessagew_test6 -miscellaneous/GetCalendarInfoW/test1/paltest_getcalendarinfow_test1 -miscellaneous/GetCalendarInfoW/test2/paltest_getcalendarinfow_test2 -miscellaneous/GetDateFormatW/GetDateFormatW_neg1/paltest_getdateformatw_getdateformatw_neg1 -miscellaneous/GetDateFormatW/GetDateFormatW_neg2/paltest_getdateformatw_getdateformatw_neg2 -miscellaneous/GetDateFormatW/test1/paltest_getdateformatw_test1 -miscellaneous/InterLockedExchangeAdd/test1/paltest_interlockedexchangeadd_test1 -miscellaneous/IsBadCodePtr/test1/paltest_isbadcodeptr_test1 -miscellaneous/IsBadReadPtr/test1/paltest_isbadreadptr_test1 -miscellaneous/IsBadWritePtr/test1/paltest_isbadwriteptr_test1 -miscellaneous/IsBadWritePtr/test2/paltest_isbadwriteptr_test2 -miscellaneous/IsBadWritePtr/test3/paltest_isbadwriteptr_test3 -miscellaneous/MessageBoxW/test1/paltest_messageboxw_test1 -miscellaneous/MessageBoxW/test2/paltest_messageboxw_test2 -miscellaneous/queryperformancecounter/test1/paltest_queryperformancecounter_test1 -miscellaneous/wsprintfW/test2/paltest_wsprintfw_test2 -miscellaneous/wsprintfW/test7/paltest_wsprintfw_test7 -pal_specific/PAL_GetMachineConfigurationDirectoryW/test1/paltest_pal_getmachineconfigurationdirectoryw_test1 -pal_specific/PAL_GetPALDirectoryW/test1/paltest_pal_getpaldirectoryw_test1 -pal_specific/PAL_GetUserConfigurationDirectoryW/test1/paltest_pal_getuserconfigurationdirectoryw_test1 -pal_specific/PAL_GetUserTempDirectoryW/test1/paltest_pal_getusertempdirectoryw_test1 -pal_specific/PAL_get_stderr/test1/paltest_pal_get_stderr_test1 -pal_specific/PAL_get_stdin/test1/paltest_pal_get_stdin_test1 -pal_specific/PAL_get_stdout/test1/paltest_pal_get_stdout_test1 -pal_specific/PAL_RegisterLibraryW_UnregisterLibraryW/test1/paltest_pal_registerlibraryw_unregisterlibraryw_test1 -samples/test2/paltest_samples_test2 -threading/CreateEventA/test3/paltest_createeventa_test3 -threading/CreateEventW/test3/paltest_createeventw_test3 -threading/CreateMutexA_ReleaseMutex/test2/paltest_createmutexa_releasemutex_test2 -threading/CreateMutexW_ReleaseMutex/test2/paltest_createmutexw_releasemutex_test2 -threading/CreateSemaphoreA_ReleaseSemaphore/test3/paltest_createsemaphorea_releasesemaphore_test3 -threading/CreateSemaphoreW_ReleaseSemaphore/test3/paltest_createsemaphorew_releasesemaphore_test3 -threading/CreateThread/test2/paltest_createthread_test2 -threading/CriticalSectionFunctions/test5/paltest_criticalsectionfunctions_test5 -threading/CriticalSectionFunctions/test6/paltest_criticalsectionfunctions_test6 -threading/DuplicateHandle/test1/paltest_duplicatehandle_test1 -threading/DuplicateHandle/test11/paltest_duplicatehandle_test11 -threading/DuplicateHandle/test12/paltest_duplicatehandle_test12 -threading/DuplicateHandle/test3/paltest_duplicatehandle_test3 -threading/DuplicateHandle/test9/paltest_duplicatehandle_test9 -threading/ExitThread/test2/paltest_exitthread_test2 -threading/GetCurrentProcess/test1/paltest_getcurrentprocess_test1 -threading/GetCurrentThreadId/test1/paltest_getcurrentthreadid_test1 -threading/GetExitCodeProcess/test1/paltest_getexitcodeprocess_test1 -threading/OpenEventW/test1/paltest_openeventw_test1 -threading/OpenEventW/test2/paltest_openeventw_test2 -threading/OpenEventW/test3/paltest_openeventw_test3 -threading/OpenEventW/test4/paltest_openeventw_test4 -threading/OpenEventW/test5/paltest_openeventw_test5 -threading/OpenProcess/test1/paltest_openprocess_test1 -threading/QueueUserAPC/test1/paltest_queueuserapc_test1 -threading/setthreadcontext/test1/paltest_setthreadcontext_test1 -threading/Sleep/test1/paltest_sleep_test1 -threading/SleepEx/test1/paltest_sleepex_test1 -threading/SleepEx/test2/paltest_sleepex_test2 -threading/SuspendThread/test2/paltest_suspendthread_test2 -threading/SuspendThread/test3/paltest_suspendthread_test3 -threading/TerminateProcess/test1/paltest_terminateprocess_test1 -threading/TLS/test6_optimizedtls/paltest_tls_test6_optimizedtls -threading/WaitForMultipleObjectsEx/test5/paltest_waitformultipleobjectsex_test5 -threading/WaitForMultipleObjectsEx/test6/paltest_waitformultipleobjectsex_test6 -threading/WaitForSingleObject/WFSOProcessTest/paltest_waitforsingleobject_wfsoprocesstest diff --git a/src/pal/tests/palsuite/palverify.dat b/src/pal/tests/palsuite/palverify.dat deleted file mode 100644 index 697a080f5..000000000 --- a/src/pal/tests/palsuite/palverify.dat +++ /dev/null @@ -1,885 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -c_runtime/__iscsym/test1,1 -c_runtime/_alloca/test1,1 -c_runtime/_fdopen/test1,1 -c_runtime/_finite/test1,1 -c_runtime/_finitef/test1,1 -c_runtime/_fullpath/test1,1 -c_runtime/_gcvt/test1,1 -c_runtime/_gcvt/test2,1 -c_runtime/_getw/test1,1 -c_runtime/_isnan/test1,1 -c_runtime/_isnanf/test1,1 -c_runtime/_itow/test1,1 -c_runtime/_mbsdec/test1,1 -c_runtime/_mbsinc/test1,1 -c_runtime/_mbsninc/test1,1 -c_runtime/_open_osfhandle/test1,1 -c_runtime/_open_osfhandle/test2,1 -c_runtime/_putenv/test1,1 -c_runtime/_putenv/test2,1 -c_runtime/_putenv/test3,1 -c_runtime/_putenv/test4,1 -c_runtime/_putw/test1,1 -c_runtime/_rotl/test1,1 -c_runtime/_rotr/test1,1 -c_runtime/_snprintf_s/test1,1 -c_runtime/_snprintf_s/test2,1 -c_runtime/_snprintf_s/test3,1 -c_runtime/_snprintf_s/test4,1 -c_runtime/_snprintf_s/test6,1 -c_runtime/_snprintf_s/test7,1 -c_runtime/_snprintf_s/test8,1 -c_runtime/_snprintf_s/test9,1 -c_runtime/_snprintf_s/test10,1 -c_runtime/_snprintf_s/test11,1 -c_runtime/_snprintf_s/test12,1 -c_runtime/_snprintf_s/test13,1 -c_runtime/_snprintf_s/test14,1 -c_runtime/_snprintf_s/test15,1 -c_runtime/_snprintf_s/test16,1 -c_runtime/_snprintf_s/test17,1 -c_runtime/_snprintf_s/test18,1 -c_runtime/_snprintf_s/test19,1 -c_runtime/_snwprintf_s/test1,1 -c_runtime/_snwprintf_s/test2,1 -c_runtime/_snwprintf_s/test3,1 -c_runtime/_snwprintf_s/test4,1 -c_runtime/_snwprintf_s/test6,1 -c_runtime/_snwprintf_s/test7,1 -c_runtime/_snwprintf_s/test8,1 -c_runtime/_snwprintf_s/test9,1 -c_runtime/_snwprintf_s/test10,1 -c_runtime/_snwprintf_s/test11,1 -c_runtime/_snwprintf_s/test12,1 -c_runtime/_snwprintf_s/test13,1 -c_runtime/_snwprintf_s/test14,1 -c_runtime/_snwprintf_s/test15,1 -c_runtime/_snwprintf_s/test16,1 -c_runtime/_snwprintf_s/test17,1 -c_runtime/_snwprintf_s/test18,1 -c_runtime/_snwprintf_s/test19,1 -c_runtime/_stricmp/test1,1 -c_runtime/_strlwr/test1,1 -c_runtime/_strnicmp/test1,1 -c_runtime/_vsnprintf_s/test1,1 -c_runtime/_vsnprintf_s/test2,1 -c_runtime/_vsnprintf_s/test3,1 -c_runtime/_vsnprintf_s/test4,1 -c_runtime/_vsnprintf_s/test6,1 -c_runtime/_vsnprintf_s/test7,1 -c_runtime/_vsnprintf_s/test8,1 -c_runtime/_vsnprintf_s/test9,1 -c_runtime/_vsnprintf_s/test10,1 -c_runtime/_vsnprintf_s/test11,1 -c_runtime/_vsnprintf_s/test12,1 -c_runtime/_vsnprintf_s/test13,1 -c_runtime/_vsnprintf_s/test14,1 -c_runtime/_vsnprintf_s/test15,1 -c_runtime/_vsnprintf_s/test16,1 -c_runtime/_vsnprintf_s/test17,1 -c_runtime/_vsnprintf_s/test18,1 -c_runtime/_vsnprintf_s/test19,1 -c_runtime/_vsnwprintf_s/test1,1 -c_runtime/_vsnwprintf_s/test2,1 -c_runtime/_vsnwprintf_s/test3,1 -c_runtime/_vsnwprintf_s/test4,1 -c_runtime/_vsnwprintf_s/test5,1 -c_runtime/_vsnwprintf_s/test6,1 -c_runtime/_vsnwprintf_s/test7,1 -c_runtime/_vsnwprintf_s/test8,1 -c_runtime/_vsnwprintf_s/test9,1 -c_runtime/_vsnwprintf_s/test10,1 -c_runtime/_vsnwprintf_s/test11,1 -c_runtime/_vsnwprintf_s/test12,1 -c_runtime/_vsnwprintf_s/test13,1 -c_runtime/_vsnwprintf_s/test14,1 -c_runtime/_vsnwprintf_s/test15,1 -c_runtime/_vsnwprintf_s/test16,1 -c_runtime/_vsnwprintf_s/test17,1 -c_runtime/_vsnwprintf_s/test18,1 -c_runtime/_vsnwprintf_s/test19,1 -c_runtime/_wcsicmp/test1,1 -c_runtime/_wcslwr/test1,1 -c_runtime/_wcsnicmp/test1,1 -c_runtime/_wfopen/test1,1 -c_runtime/_wfopen/test2,1 -c_runtime/_wfopen/test3,1 -c_runtime/_wfopen/test4,1 -c_runtime/_wfopen/test5,1 -c_runtime/_wfopen/test6,1 -c_runtime/_wfopen/test7,1 -c_runtime/_wtoi/test1,1 -c_runtime/abs/test1,1 -c_runtime/acos/test1,1 -c_runtime/acosf/test1,1 -c_runtime/acosh/test1,1 -c_runtime/acoshf/test1,1 -c_runtime/asin/test1,1 -c_runtime/asinf/test1,1 -c_runtime/asinh/test1,1 -c_runtime/asinhf/test1,1 -c_runtime/atan/test1,1 -c_runtime/atan2/test1,1 -c_runtime/atan2f/test1,1 -c_runtime/atanf/test1,1 -c_runtime/atanh/test1,1 -c_runtime/atanhf/test1,1 -c_runtime/atof/test1,1 -c_runtime/atoi/test1,1 -c_runtime/atol/test1,1 -c_runtime/bsearch/test1,1 -c_runtime/bsearch/test2,1 -c_runtime/cbrt/test1,1 -c_runtime/cbrtf/test1,1 -c_runtime/ceil/test1,1 -c_runtime/ceilf/test1,1 -c_runtime/cos/test1,1 -c_runtime/cosf/test1,1 -c_runtime/cosh/test1,1 -c_runtime/coshf/test1,1 -c_runtime/ctime/test1,1 -c_runtime/errno/test1,1 -c_runtime/errno/test2,1 -c_runtime/exit/test1,1 -c_runtime/exp/test1,1 -c_runtime/expf/test1,1 -c_runtime/fabs/test1,1 -c_runtime/fabsf/test1,1 -c_runtime/fclose/test1,1 -c_runtime/fclose/test2,1 -c_runtime/feof/test1,1 -c_runtime/ferror/test1,1 -c_runtime/ferror/test2,1 -c_runtime/fflush/test1,1 -c_runtime/fgets/test1,1 -c_runtime/fgets/test2,1 -c_runtime/fgets/test3,1 -c_runtime/floor/test1,1 -c_runtime/floorf/test1,1 -c_runtime/fmod/test1,1 -c_runtime/fmodf/test1,1 -c_runtime/fopen/test1,1 -c_runtime/fopen/test2,1 -c_runtime/fopen/test3,1 -c_runtime/fopen/test4,1 -c_runtime/fopen/test5,1 -c_runtime/fopen/test6,1 -c_runtime/fopen/test7,1 -c_runtime/fprintf/test1,1 -c_runtime/fprintf/test2,1 -c_runtime/fprintf/test3,1 -c_runtime/fprintf/test4,1 -c_runtime/fprintf/test5,1 -c_runtime/fprintf/test6,1 -c_runtime/fprintf/test7,1 -c_runtime/fprintf/test8,1 -c_runtime/fprintf/test9,1 -c_runtime/fprintf/test10,1 -c_runtime/fprintf/test11,1 -c_runtime/fprintf/test12,1 -c_runtime/fprintf/test13,1 -c_runtime/fprintf/test14,1 -c_runtime/fprintf/test15,1 -c_runtime/fprintf/test16,1 -c_runtime/fprintf/test17,1 -c_runtime/fprintf/test18,1 -c_runtime/fprintf/test19,1 -c_runtime/fputs/test1,1 -c_runtime/fputs/test2,1 -c_runtime/fread/test1,1 -c_runtime/fread/test2,1 -c_runtime/fread/test3,1 -c_runtime/free/test1,1 -c_runtime/fseek/test1,1 -c_runtime/ftell/test1,1 -c_runtime/fwprintf/test1,1 -c_runtime/fwprintf/test2,1 -c_runtime/fwprintf/test3,1 -c_runtime/fwprintf/test4,1 -c_runtime/fwprintf/test5,1 -c_runtime/fwprintf/test6,1 -c_runtime/fwprintf/test7,1 -c_runtime/fwprintf/test8,1 -c_runtime/fwprintf/test9,1 -c_runtime/fwprintf/test10,1 -c_runtime/fwprintf/test11,1 -c_runtime/fwprintf/test12,1 -c_runtime/fwprintf/test13,1 -c_runtime/fwprintf/test14,1 -c_runtime/fwprintf/test15,1 -c_runtime/fwprintf/test16,1 -c_runtime/fwprintf/test17,1 -c_runtime/fwprintf/test18,1 -c_runtime/fwprintf/test19,1 -c_runtime/fwrite/test1,1 -c_runtime/getc/test1,1 -c_runtime/getenv/test1,0 -c_runtime/getenv/test2,1 -c_runtime/getenv/test3,1 -c_runtime/isalnum/test1,1 -c_runtime/isalpha/test1,1 -c_runtime/isdigit/test1,1 -c_runtime/islower/test1,1 -c_runtime/isprint/test1,1 -c_runtime/isprint/test2,1 -c_runtime/isspace/test1,1 -c_runtime/isupper/test1,1 -c_runtime/iswdigit/test1,1 -c_runtime/iswprint/test1,1 -c_runtime/iswspace/test1,1 -c_runtime/iswupper/test1,1 -c_runtime/iswxdigit/test1,1 -c_runtime/isxdigit/test1,1 -c_runtime/labs/test1,1 -c_runtime/llabs/test1,1 -c_runtime/localtime/test1,1 -c_runtime/log/test1,1 -c_runtime/log10/test1,1 -c_runtime/log10f/test1,1 -c_runtime/logf/test1,1 -c_runtime/malloc/test1,1 -c_runtime/memchr/test1,1 -c_runtime/memcmp/test1,1 -c_runtime/memcpy/test1,1 -c_runtime/memmove/test1,1 -c_runtime/memset/test1,1 -c_runtime/modf/test1,1 -c_runtime/pow/test1,1 -c_runtime/powf/test1,1 -c_runtime/printf/test1,1 -c_runtime/printf/test2,1 -c_runtime/printf/test3,1 -c_runtime/printf/test4,1 -c_runtime/printf/test5,1 -c_runtime/printf/test6,1 -c_runtime/printf/test7,1 -c_runtime/printf/test8,1 -c_runtime/printf/test9,1 -c_runtime/printf/test10,1 -c_runtime/printf/test11,1 -c_runtime/printf/test12,1 -c_runtime/printf/test13,1 -c_runtime/printf/test14,1 -c_runtime/printf/test15,1 -c_runtime/printf/test16,1 -c_runtime/printf/test17,1 -c_runtime/printf/test18,1 -c_runtime/printf/test19,1 -c_runtime/qsort/test1,1 -c_runtime/qsort/test2,1 -c_runtime/rand_srand/test1,1 -c_runtime/realloc/test1,1 -c_runtime/sin/test1,1 -c_runtime/sinf/test1,1 -c_runtime/sinh/test1,1 -c_runtime/sinhf/test1,1 -c_runtime/sprintf_s/test1,1 -c_runtime/sprintf_s/test2,1 -c_runtime/sprintf_s/test3,1 -c_runtime/sprintf_s/test4,1 -c_runtime/sprintf_s/test6,1 -c_runtime/sprintf_s/test7,1 -c_runtime/sprintf_s/test8,1 -c_runtime/sprintf_s/test9,1 -c_runtime/sprintf_s/test10,1 -c_runtime/sprintf_s/test11,1 -c_runtime/sprintf_s/test12,1 -c_runtime/sprintf_s/test13,1 -c_runtime/sprintf_s/test14,1 -c_runtime/sprintf_s/test15,1 -c_runtime/sprintf_s/test16,1 -c_runtime/sprintf_s/test17,1 -c_runtime/sprintf_s/test18,1 -c_runtime/sprintf_s/test19,1 -c_runtime/sqrt/test1,1 -c_runtime/sqrtf/test1,1 -c_runtime/sscanf_s/test1,1 -c_runtime/sscanf_s/test2,1 -c_runtime/sscanf_s/test3,1 -c_runtime/sscanf_s/test4,1 -c_runtime/sscanf_s/test5,1 -c_runtime/sscanf_s/test6,1 -c_runtime/sscanf_s/test7,1 -c_runtime/sscanf_s/test8,1 -c_runtime/sscanf_s/test9,1 -c_runtime/sscanf_s/test10,1 -c_runtime/sscanf_s/test11,1 -c_runtime/sscanf_s/test12,1 -c_runtime/sscanf_s/test13,1 -c_runtime/sscanf_s/test14,1 -c_runtime/sscanf_s/test15,1 -c_runtime/sscanf_s/test16,1 -c_runtime/sscanf_s/test17,1 -c_runtime/strcat/test1,1 -c_runtime/strchr/test1,1 -c_runtime/strcmp/test1,1 -c_runtime/strcpy/test1,1 -c_runtime/strcspn/test1,1 -c_runtime/strlen/test1,1 -c_runtime/strncat/test1,1 -c_runtime/strncmp/test1,1 -c_runtime/strncpy/test1,1 -c_runtime/strpbrk/test1,1 -c_runtime/strrchr/test1,1 -c_runtime/strspn/test1,1 -c_runtime/strstr/test1,1 -c_runtime/strtod/test1,1 -c_runtime/strtod/test2,1 -c_runtime/strtok/test1,1 -c_runtime/strtoul/test1,1 -c_runtime/swprintf/test1,1 -c_runtime/swprintf/test2,1 -c_runtime/swprintf/test3,1 -c_runtime/swprintf/test4,1 -c_runtime/swprintf/test5,1 -c_runtime/swprintf/test6,1 -c_runtime/swprintf/test7,1 -c_runtime/swprintf/test8,1 -c_runtime/swprintf/test9,1 -c_runtime/swprintf/test10,1 -c_runtime/swprintf/test11,1 -c_runtime/swprintf/test12,1 -c_runtime/swprintf/test13,1 -c_runtime/swprintf/test14,1 -c_runtime/swprintf/test15,1 -c_runtime/swprintf/test16,1 -c_runtime/swprintf/test17,1 -c_runtime/swprintf/test18,1 -c_runtime/swprintf/test19,1 -c_runtime/swscanf/test1,1 -c_runtime/swscanf/test2,1 -c_runtime/swscanf/test3,1 -c_runtime/swscanf/test4,1 -c_runtime/swscanf/test5,1 -c_runtime/swscanf/test6,1 -c_runtime/swscanf/test7,1 -c_runtime/swscanf/test8,1 -c_runtime/swscanf/test9,1 -c_runtime/swscanf/test10,1 -c_runtime/swscanf/test11,1 -c_runtime/swscanf/test12,1 -c_runtime/swscanf/test13,1 -c_runtime/swscanf/test14,1 -c_runtime/swscanf/test15,1 -c_runtime/swscanf/test16,1 -c_runtime/swscanf/test17,1 -c_runtime/tan/test1,1 -c_runtime/tanf/test1,1 -c_runtime/tanh/test1,1 -c_runtime/tanhf/test1,1 -c_runtime/time/test1,1 -c_runtime/tolower/test1,1 -c_runtime/toupper/test1,1 -c_runtime/towlower/test1,1 -c_runtime/towupper/test1,1 -c_runtime/ungetc/test1,1 -c_runtime/vfprintf/test1,1 -c_runtime/vfprintf/test2,1 -c_runtime/vfprintf/test3,1 -c_runtime/vfprintf/test4,1 -c_runtime/vfprintf/test5,1 -c_runtime/vfprintf/test6,1 -c_runtime/vfprintf/test7,1 -c_runtime/vfprintf/test8,1 -c_runtime/vfprintf/test9,1 -c_runtime/vfprintf/test10,1 -c_runtime/vfprintf/test11,1 -c_runtime/vfprintf/test12,1 -c_runtime/vfprintf/test13,1 -c_runtime/vfprintf/test14,1 -c_runtime/vfprintf/test15,1 -c_runtime/vfprintf/test16,1 -c_runtime/vfprintf/test17,1 -c_runtime/vfprintf/test18,1 -c_runtime/vfprintf/test19,1 -c_runtime/vprintf/test1,1 -c_runtime/vprintf/test2,1 -c_runtime/vprintf/test3,1 -c_runtime/vprintf/test4,1 -c_runtime/vprintf/test5,1 -c_runtime/vprintf/test6,1 -c_runtime/vprintf/test7,1 -c_runtime/vprintf/test8,1 -c_runtime/vprintf/test9,1 -c_runtime/vprintf/test10,1 -c_runtime/vprintf/test11,1 -c_runtime/vprintf/test12,1 -c_runtime/vprintf/test13,1 -c_runtime/vprintf/test14,1 -c_runtime/vprintf/test15,1 -c_runtime/vprintf/test16,1 -c_runtime/vprintf/test17,1 -c_runtime/vprintf/test18,1 -c_runtime/vprintf/test19,1 -c_runtime/vsprintf/test1,1 -c_runtime/vsprintf/test2,1 -c_runtime/vsprintf/test3,1 -c_runtime/vsprintf/test4,1 -c_runtime/vsprintf/test5,1 -c_runtime/vsprintf/test6,1 -c_runtime/vsprintf/test7,1 -c_runtime/vsprintf/test8,1 -c_runtime/vsprintf/test9,1 -c_runtime/vsprintf/test10,1 -c_runtime/vsprintf/test11,1 -c_runtime/vsprintf/test12,1 -c_runtime/vsprintf/test13,1 -c_runtime/vsprintf/test14,1 -c_runtime/vsprintf/test15,1 -c_runtime/vsprintf/test16,1 -c_runtime/vsprintf/test17,1 -c_runtime/vsprintf/test18,1 -c_runtime/vsprintf/test19,1 -c_runtime/vswprintf/test1,1 -c_runtime/vswprintf/test2,1 -c_runtime/vswprintf/test3,1 -c_runtime/vswprintf/test4,1 -c_runtime/vswprintf/test5,1 -c_runtime/vswprintf/test6,1 -c_runtime/vswprintf/test7,1 -c_runtime/vswprintf/test8,1 -c_runtime/vswprintf/test9,1 -c_runtime/vswprintf/test10,1 -c_runtime/vswprintf/test11,1 -c_runtime/vswprintf/test12,1 -c_runtime/vswprintf/test13,1 -c_runtime/vswprintf/test14,1 -c_runtime/vswprintf/test15,1 -c_runtime/vswprintf/test16,1 -c_runtime/vswprintf/test17,1 -c_runtime/vswprintf/test18,1 -c_runtime/vswprintf/test19,1 -c_runtime/wcscat/test1,1 -c_runtime/wcschr/test1,1 -c_runtime/wcscmp/test1,1 -c_runtime/wcscpy/test1,1 -c_runtime/wcslen/test1,1 -c_runtime/wcsncat/test1,1 -c_runtime/wcsncmp/test1,1 -c_runtime/wcsncpy/test1,1 -c_runtime/wcspbrk/test1,1 -c_runtime/wcsrchr/test1,1 -c_runtime/wcsstr/test1,1 -c_runtime/wcstod/test1,1 -c_runtime/wcstod/test2,1 -c_runtime/wcstok/test1,1 -c_runtime/wcstol/test1,1 -c_runtime/wcstol/test2,1 -c_runtime/wcstol/test3,1 -c_runtime/wcstol/test4,1 -c_runtime/wcstol/test5,1 -c_runtime/wcstol/test6,1 -c_runtime/wcstoul/test1,1 -c_runtime/wcstoul/test2,1 -c_runtime/wcstoul/test3,1 -c_runtime/wcstoul/test4,1 -c_runtime/wcstoul/test5,1 -c_runtime/wcstoul/test6,1 -debug_api/writeprocessmemory/test1,1 -exception_handling/pal_except/test1,1 -exception_handling/pal_except/test2,1 -exception_handling/pal_except/test3,1 -exception_handling/pal_except/test4,1 -exception_handling/pal_except/test5,1 -exception_handling/pal_except/test6,1 -exception_handling/pal_except/test7,1 -exception_handling/pal_except_filter/test1,1 -exception_handling/pal_except_filter/test2,1 -exception_handling/pal_except_filter/test3,1 -exception_handling/pal_except_filter_ex/test1,1 -exception_handling/pal_except_filter_ex/test2,1 -exception_handling/pal_except_filter_ex/test3,1 -exception_handling/pal_getbottommostregistration/test1,1 -exception_handling/pal_getbottommostregistration/test2,1 -exception_handling/pal_finally/test1,1 -exception_handling/pal_try_except/test1,1 -exception_handling/pal_try_except/test2,1 -exception_handling/pal_try_except_ex/test1,1 -exception_handling/pal_try_except_ex/test2,1 -exception_handling/pal_try_except_ex/test3,1 -exception_handling/pal_try_leave_finally/test1,1 -exception_handling/raiseexception/test1,1 -exception_handling/raiseexception/test2,1 -exception_handling/raiseexception/test3,1 -file_io/comparefiletime/test1,1 -file_io/copyfilea/test1,1 -file_io/copyfilea/test2,1 -file_io/copyfilea/test3,1 -file_io/copyfilea/test4,1 -file_io/copyfilew/test1,1 -file_io/copyfilew/test2,1 -file_io/createdirectorya/test1,1 -file_io/createdirectoryw/test1,1 -file_io/createfilea/test1,1 -file_io/createfilew/test1,1 -file_io/deletefilea/test1,1 -file_io/deletefilew/test1,1 -file_io/errorpathnotfound/test1,1 -file_io/errorpathnotfound/test2,1 -file_io/errorpathnotfound/test3,1 -file_io/findclose/test1,1 -file_io/findfirstfilea/test1,1 -#file_io/findfirstfilew/test1,1 -file_io/findnextfilea/test1,1 -file_io/findnextfilew/test1,1 -file_io/flushfilebuffers/test1,1 -file_io/getconsoleoutputcp/test1,1 -file_io/getcurrentdirectorya/test1,1 -file_io/getcurrentdirectoryw/test1,1 -#file_io/getfileattributesa/test1,1 -#file_io/getfileattributesexw/test1,1 -file_io/getfileattributesexw/test2,1 -#file_io/getfileattributesw/test1,1 -file_io/getfullpathnamea/test1,1 -file_io/getfullpathnamea/test2,1 -file_io/getfullpathnamea/test3,1 -file_io/getfullpathnamea/test4,1 -file_io/getfullpathnamew/test1,1 -file_io/getfullpathnamew/test2,1 -#file_io/getfullpathnamew/test3,1 -#file_io/getfullpathnamew/test4,1 -file_io/getlongpathnamew/test1,1 -file_io/getlongpathnamew/test2,1 -file_io/getsystemtime/test1,1 -file_io/getsystemtimeasfiletime/test1,1 -file_io/gettempfilenamea/test1,1 -file_io/gettempfilenamea/test3,1 -file_io/gettempfilenamew/test1,1 -file_io/gettempfilenamew/test3,1 -file_io/gettemppatha/test1,1 -file_io/gettemppathw/test1,1 -file_io/movefileexw/test1,1 -#file_io/readfile/test1,1 -file_io/readfile/test2,1 -file_io/readfile/test3,1 -file_io/readfile/test4,1 -file_io/removedirectoryw/test1,1 -file_io/setcurrentdirectorya/test1,1 -file_io/setcurrentdirectorya/test2,1 -file_io/setcurrentdirectorya/test3,1 -file_io/setcurrentdirectoryw/test1,1 -file_io/setcurrentdirectoryw/test2,1 -#file_io/setcurrentdirectoryw/test3,1 -file_io/setendoffile/test1,1 -file_io/setendoffile/test2,1 -file_io/setendoffile/test3,1 -file_io/setendoffile/test4,1 -file_io/setendoffile/test5,1 -file_io/setfileattributesa/test2,1 -file_io/setfileattributesa/test3,1 -file_io/setfileattributesw/test2,1 -file_io/setfileattributesw/test3,1 -file_io/setfilepointer/test1,1 -file_io/setfilepointer/test2,1 -file_io/setfilepointer/test3,1 -file_io/setfilepointer/test4,1 -file_io/writefile/test1,1 -file_io/writefile/test2,1 -file_io/writefile/test3,1 -file_io/writefile/test4,1 -file_io/writefile/test5,1 -filemapping_memmgt/createfilemappinga/test1,1 -filemapping_memmgt/createfilemappinga/test3,1 -filemapping_memmgt/createfilemappinga/test4,1 -filemapping_memmgt/createfilemappinga/test5,1 -filemapping_memmgt/createfilemappinga/test6,1 -filemapping_memmgt/createfilemappinga/test7,1 -filemapping_memmgt/createfilemappinga/test8,1 -filemapping_memmgt/createfilemappinga/test9,1 -filemapping_memmgt/createfilemappingw/test1,1 -filemapping_memmgt/createfilemappingw/test3,1 -filemapping_memmgt/createfilemappingw/test4,1 -filemapping_memmgt/createfilemappingw/test5,1 -filemapping_memmgt/createfilemappingw/test6,1 -filemapping_memmgt/createfilemappingw/test7,1 -filemapping_memmgt/createfilemappingw/test8,1 -filemapping_memmgt/createfilemappingw/test9,1 -filemapping_memmgt/freelibrary/test1,1 -filemapping_memmgt/freelibrary/test2,1 -filemapping_memmgt/freelibraryandexitthread/test1,1 -filemapping_memmgt/getmodulefilenamea/test1,1 -filemapping_memmgt/getmodulefilenamea/test2,1 -filemapping_memmgt/getmodulefilenamew/test1,1 -filemapping_memmgt/getmodulefilenamew/test2,1 -filemapping_memmgt/getprocaddress/test1,1 -filemapping_memmgt/getprocaddress/test2,1 -filemapping_memmgt/getprocessheap/test1,1 -filemapping_memmgt/heapalloc/test1,1 -filemapping_memmgt/heapalloc/test2,1 -filemapping_memmgt/heapfree/test1,1 -filemapping_memmgt/heaprealloc/test1,1 -filemapping_memmgt/heaprealloc/test2,1 -filemapping_memmgt/heaprealloc/test3,1 -filemapping_memmgt/heaprealloc/test4,1 -filemapping_memmgt/heaprealloc/test5,1 -filemapping_memmgt/localalloc/test1,1 -filemapping_memmgt/localfree/test1,1 -filemapping_memmgt/localfree/test2,1 -filemapping_memmgt/lockfile/test1,1 -filemapping_memmgt/lockfile/test2,1 -filemapping_memmgt/lockfile/test3,1 -filemapping_memmgt/lockfile/test4,1 -filemapping_memmgt/lockfile/test5,1 -filemapping_memmgt/lockfile/test6,1 -filemapping_memmgt/lockfile/test7,1 -filemapping_memmgt/mapviewoffile/test1,1 -filemapping_memmgt/mapviewoffile/test2,1 -filemapping_memmgt/mapviewoffile/test3,1 -filemapping_memmgt/mapviewoffile/test4,1 -filemapping_memmgt/mapviewoffile/test5,1 -filemapping_memmgt/mapviewoffile/test6,1 -filemapping_memmgt/openfilemappinga/test1,1 -filemapping_memmgt/openfilemappinga/test2,1 -filemapping_memmgt/openfilemappinga/test3,1 -filemapping_memmgt/openfilemappingw/test1,1 -filemapping_memmgt/openfilemappingw/test2,1 -filemapping_memmgt/openfilemappingw/test3,1 -filemapping_memmgt/readprocessmemory/readprocessmemory_neg1,1 -filemapping_memmgt/readprocessmemory/test1,1 -filemapping_memmgt/rtlmovememory/test1,1 -filemapping_memmgt/rtlmovememory/test3,1 -filemapping_memmgt/rtlmovememory/test4,1 -filemapping_memmgt/rtlmovememory/test5,1 -filemapping_memmgt/unlockfile/test1,1 -filemapping_memmgt/unlockfile/test2,1 -filemapping_memmgt/unlockfile/test3,1 -filemapping_memmgt/unlockfile/test4,1 -filemapping_memmgt/unmapviewoffile/test1,1 -filemapping_memmgt/virtualalloc/test1,1 -filemapping_memmgt/virtualalloc/test2,1 -filemapping_memmgt/virtualalloc/test3,1 -filemapping_memmgt/virtualalloc/test4,1 -filemapping_memmgt/virtualalloc/test5,1 -filemapping_memmgt/virtualalloc/test6,1 -filemapping_memmgt/virtualalloc/test7,1 -filemapping_memmgt/virtualalloc/test8,1 -filemapping_memmgt/virtualalloc/test9,1 -filemapping_memmgt/virtualalloc/test10,1 -filemapping_memmgt/virtualalloc/test11,1 -filemapping_memmgt/virtualalloc/test12,1 -filemapping_memmgt/virtualalloc/test13,1 -filemapping_memmgt/virtualalloc/test14,1 -filemapping_memmgt/virtualalloc/test15,1 -filemapping_memmgt/virtualalloc/test16,1 -filemapping_memmgt/virtualalloc/test17,1 -filemapping_memmgt/virtualalloc/test18,1 -filemapping_memmgt/virtualalloc/test19,1 -filemapping_memmgt/virtualalloc/test20,1 -filemapping_memmgt/virtualalloc/test21,1 -filemapping_memmgt/virtualfree/test1,1 -filemapping_memmgt/virtualfree/test2,1 -filemapping_memmgt/virtualfree/test3,1 -filemapping_memmgt/virtualprotect/test1,1 -filemapping_memmgt/virtualprotect/test2,1 -filemapping_memmgt/virtualprotect/test3,1 -filemapping_memmgt/virtualprotect/test4,1 -filemapping_memmgt/virtualprotect/test6,1 -filemapping_memmgt/virtualprotect/test7,1 -filemapping_memmgt/virtualquery/test1,1 -loader/loadlibrarya/test1,1 -loader/loadlibrarya/test2,1 -loader/loadlibrarya/test3,0 -loader/loadlibrarya/test5,1 -loader/loadlibrarya/test6,1 -loader/loadlibraryw/test1,1 -loader/loadlibraryw/test2,1 -loader/loadlibraryw/test3,1 -loader/loadlibraryw/test5,1 -locale_info/comparestringw/test1,1 -locale_info/getacp/test1,1 -locale_info/getcpinfo/test1,1 -locale_info/getlocaleinfow/test1,1 -locale_info/getlocaleinfow/test2,1 -locale_info/getstringtypeexw/test1,1 -locale_info/getstringtypeexw/test2,0 -locale_info/getsystemdefaultlangid/test1,1 -locale_info/getthreadlocale/test1,1 -locale_info/gettimezoneinformation/test1,1 -locale_info/getuserdefaultlangid/test1,1 -locale_info/getuserdefaultlcid/test1,1 -locale_info/isdbcsleadbyteex/test1,1 -locale_info/isvalidcodepage/test1,1 -locale_info/isvalidlocale/test1,1 -locale_info/multibytetowidechar/test1,1 -locale_info/multibytetowidechar/test2,1 -locale_info/multibytetowidechar/test3,1 -locale_info/setthreadlocale/test1,1 -locale_info/widechartomultibyte/test1,1 -locale_info/widechartomultibyte/test2,1 -locale_info/widechartomultibyte/test3,1 -miscellaneous/_i64tow/test1,1 -miscellaneous/charnexta/test1,1 -miscellaneous/charnexta/test2,1 -miscellaneous/charnextexa/test1,1 -miscellaneous/charnextexa/test2,1 -miscellaneous/closehandle/test1,1 -miscellaneous/closehandle/test2,1 -miscellaneous/createpipe/test1,1 -miscellaneous/flushinstructioncache/test1,1 -miscellaneous/formatmessagew/test1,1 -miscellaneous/formatmessagew/test2,1 -miscellaneous/formatmessagew/test3,1 -miscellaneous/formatmessagew/test4,1 -miscellaneous/formatmessagew/test5,1 -miscellaneous/formatmessagew/test6,1 -miscellaneous/freeenvironmentstringsw/test1,1 -miscellaneous/freeenvironmentstringsw/test2,1 -miscellaneous/getcalendarinfow/test1,1 -miscellaneous/getcommandlinew/test1,1 -miscellaneous/getenvironmentstringsw/test1,1 -miscellaneous/getenvironmentvariablea/test1,1 -miscellaneous/getenvironmentvariablea/test2,1 -miscellaneous/getenvironmentvariablea/test3,1 -miscellaneous/getenvironmentvariablea/test4,1 -miscellaneous/getenvironmentvariablew/test1,1 -miscellaneous/getenvironmentvariablew/test2,1 -miscellaneous/getenvironmentvariablew/test3,1 -miscellaneous/getenvironmentvariablew/test4,1 -miscellaneous/getlasterror/test1,1 -miscellaneous/getsysteminfo/test1,1 -miscellaneous/getglobalmemorystatusex/test1,1 -miscellaneous/gettickcount/test1,1 -miscellaneous/getversionexa/test1,1 -miscellaneous/getversionexw/test1,1 -miscellaneous/interlockedcompareexchange/test1,1 -miscellaneous/interlockedcompareexchangepointer/test1,1 -miscellaneous/interlockeddecrement/test1,1 -miscellaneous/interlockedexchange/test1,1 -miscellaneous/interlockedexchangepointer/test1,1 -miscellaneous/interlockedincrement/test1,1 -miscellaneous/isbadcodeptr/test1,1 -miscellaneous/isbadreadptr/test1,1 -miscellaneous/isbadwriteptr/test1,1 -miscellaneous/isbadwriteptr/test2,1 -miscellaneous/isbadwriteptr/test3,1 -miscellaneous/lstrcatw/test1,1 -miscellaneous/lstrcatw/test2,1 -miscellaneous/lstrcatw/test3,1 -miscellaneous/lstrcatw/test4,1 -miscellaneous/lstrcpynw/test1,1 -miscellaneous/lstrcpyw/test1,1 -miscellaneous/lstrlena/test1,1 -miscellaneous/lstrlenw/test1,1 -miscellaneous/queryperformancecounter/test1,1 -miscellaneous/queryperformancefrequency/test1,1 -miscellaneous/setenvironmentvariablea/test1,1 -miscellaneous/setenvironmentvariablea/test2,1 -miscellaneous/setenvironmentvariablew/test1,1 -miscellaneous/setenvironmentvariablew/test2,1 -miscellaneous/setlasterror/test1,1 -miscellaneous/wsprintfa/test1,1 -miscellaneous/wsprintfa/test2,1 -miscellaneous/wsprintfa/test3,1 -miscellaneous/wsprintfa/test6,1 -miscellaneous/wsprintfa/test7,1 -miscellaneous/wsprintfa/test8,1 -miscellaneous/wsprintfa/test9,1 -miscellaneous/wsprintfa/test11,1 -miscellaneous/wsprintfa/test12,1 -miscellaneous/wsprintfa/test13,1 -miscellaneous/wsprintfw/test1,1 -miscellaneous/wsprintfw/test2,1 -miscellaneous/wsprintfw/test3,1 -miscellaneous/wsprintfw/test6,1 -miscellaneous/wsprintfw/test7,1 -miscellaneous/wsprintfw/test8,1 -miscellaneous/wsprintfw/test9,1 -miscellaneous/wsprintfw/test11,1 -miscellaneous/wsprintfw/test12,1 -miscellaneous/wsprintfw/test13,1 -pal_specific/pal_errno/test1,1 -pal_specific/pal_getpaldirectoryw/test1,1 -pal_specific/pal_getuserconfigurationdirectoryw/test1,1 -pal_specific/pal_initialize_terminate/test1,1 -threading/createeventa/test1,1 -threading/createeventa/test2,1 -threading/createeventa/test3,1 -threading/createeventw/test1,1 -threading/createeventw/test2,1 -threading/createeventw/test3,1 -threading/createmutexw_releasemutex/test1,1 -threading/createmutexw_releasemutex/test2,1 -threading/createprocessa/test1,1 -threading/createprocessa/test2,1 -threading/createprocessw/test1,1 -threading/createprocessw/test2,1 -threading/createsemaphorea_releasesemaphore/test1,1 -threading/createsemaphorea_releasesemaphore/test2,1 -threading/createsemaphorea_releasesemaphore/test3,1 -threading/createsemaphorew_releasesemaphore/test1,1 -threading/createsemaphorew_releasesemaphore/test2,1 -threading/createsemaphorew_releasesemaphore/test3,1 -threading/createthread/test1,1 -threading/createthread/test2,1 -threading/createthread/test3,1 -threading/criticalsectionfunctions/test1,1 -threading/criticalsectionfunctions/test2,1 -threading/criticalsectionfunctions/test3,1 -threading/criticalsectionfunctions/test4,1 -threading/criticalsectionfunctions/test5,1 -threading/criticalsectionfunctions/test6,1 -threading/criticalsectionfunctions/test7,1 -threading/disablethreadlibrarycalls/test1,1 -threading/disablethreadlibrarycalls/test2,1 -threading/duplicatehandle/test1,1 -threading/duplicatehandle/test2,1 -threading/duplicatehandle/test3,1 -threading/duplicatehandle/test4,1 -threading/duplicatehandle/test5,1 -threading/duplicatehandle/test6,1 -threading/duplicatehandle/test7,1 -threading/duplicatehandle/test8,1 -threading/duplicatehandle/test9,1 -threading/duplicatehandle/test10,1 -threading/duplicatehandle/test11,1 -threading/exitprocess/test1,1 -threading/exitthread/test1,1 -#threading/exitthread/test2,1 -threading/exitthread/test3,1 -threading/getcurrentprocess/test1,1 -threading/getcurrentprocessid/test1,1 -threading/getcurrentthread/test1,1 -threading/getcurrentthread/test2,1 -threading/getcurrentthreadid/test1,1 -threading/getexitcodeprocess/test1,1 -threading/getprocesstimes/test2,1 -threading/openeventw/test1,1 -threading/openeventw/test2,1 -threading/openeventw/test3,1 -threading/openeventw/test4,1 -threading/openeventw/test5,1 -threading/openprocess/test1,1 -threading/queueuserapc/test1,1 -threading/queueuserapc/test2,1 -threading/queueuserapc/test3,1 -threading/queueuserapc/test4,1 -threading/queueuserapc/test5,0 -threading/queueuserapc/test6,0 -threading/queueuserapc/test7,1 -threading/releasemutex/test3,1 -threading/releasesemaphore/test1,1 -threading/resetevent/test1,1 -threading/resumethread/test1,1 -threading/seterrormode/test1,1 -threading/setevent/test1,1 -threading/setthreadcontext/test1,1 -threading/sleepex/test2,1 -threading/suspendthread/test1,1 -threading/terminateprocess/test1,1 -threading/tls/test1,1 -threading/tls/test2,1 -threading/tls/test3,1 -threading/tls/test4,1 -threading/tls/test5,1 -threading/waitformultipleobjects/test1,1 -threading/waitformultipleobjectsex/test1,1 -threading/waitformultipleobjectsex/test2,1 -threading/waitformultipleobjectsex/test3,1 -threading/waitformultipleobjectsex/test4,1 -threading/waitformultipleobjectsex/test5,1 - - diff --git a/src/pal/tests/palsuite/runpaltests.sh b/src/pal/tests/palsuite/runpaltests.sh deleted file mode 100644 index cc8ffd6b9..000000000 --- a/src/pal/tests/palsuite/runpaltests.sh +++ /dev/null @@ -1,213 +0,0 @@ -#!/usr/bin/env bash -# -# This script executes PAL tests from the specified build location. -# - -if [ $# -lt 1 -o $# -gt 3 ] -then - echo "Usage..." - echo "runpaltests.sh []" - echo - echo "For example:" - echo "runpaltests.sh /projectk/build/debug" - echo - exit 1 -fi - -echo -echo "***** Testing PAL *****" -echo - -# Store the location of the root of build directory -BUILD_ROOD_DIR=$1 -# Create path to the compiled PAL tets in the build directory -PAL_TEST_BUILD=$BUILD_ROOD_DIR/src/pal/tests/palsuite -echo Running PAL tests from $PAL_TEST_BUILD - -# Create absolute path to the file that contains a list of PAL tests to execute. -# This file is located next to this script in the source tree -RELATIVE_PATH_TO_PAL_TESTS=$0 -# Remove the name of this script from the path -RELATIVE_PATH_TO_PAL_TESTS=${RELATIVE_PATH_TO_PAL_TESTS%/*.*} -# Change current directory to the location of this script -cd $RELATIVE_PATH_TO_PAL_TESTS -# Environment variable PWD contains absolute path to the current folder -# so use it to create absolute path to the file with a list of tests. -PAL_TEST_LIST=$PWD/paltestlist.txt -# Change current directory back to the original location -cd $OLDPWD -echo The list of PAL tests to run will be read from $PAL_TEST_LIST - -# Create the test output root directory -mkdir -p /tmp/PalTestOutput -if [ ! -d /tmp/PalTestOutput ]; then - rm -f -r /tmp/PalTestOutput - mkdir -p /tmp/PalTestOutput -fi - -# Determine the folder to use for PAL test output during the run, and the folder where output files were requested to be copied. -# First check if the output folder was passed as a parameter to the script. It is supposed be the second parameter so check if -# we have more than 1 argument. -PAL_TEST_OUTPUT_DIR=/tmp/PalTestOutput/default -if [ $# -gt 1 ] -then - COPY_TO_TEST_OUTPUT_DIR=$2 -else - COPY_TO_TEST_OUTPUT_DIR=$PAL_TEST_OUTPUT_DIR -fi - -# Determine the folder to use for PAL test output during the run -if [ "$COPY_TO_TEST_OUTPUT_DIR" != "$PAL_TEST_OUTPUT_DIR" ]; then - # Output files were requested to be copied to a specific folder. In this mode, we need to support parallel runs of PAL tests - # on the same machine. Make a unique temp folder for working output inside /tmp/PalTestOutput. - PAL_TEST_OUTPUT_DIR=$(mktemp -d /tmp/PalTestOutput/tmp.XXXXXXXX) -fi - -echo PAL tests will store their temporary files and output in $PAL_TEST_OUTPUT_DIR. -if [ "$COPY_TO_TEST_OUTPUT_DIR" != "$PAL_TEST_OUTPUT_DIR" ]; then - echo Output files will be copied to $COPY_TO_TEST_OUTPUT_DIR at the end. -fi - -# Path to a file that will contains a list PAL tests that failed during the test run. -PAL_FAILED_TEST_LIST=$PAL_TEST_OUTPUT_DIR/palfailedtests.txt - -# Path to a file that will contain the XUnit style test result for Jenkins -# We use a temp file as at the end we have to prepend with the number of tests -# and failures -PAL_XUNIT_TEST_LIST_TMP=$PAL_TEST_OUTPUT_DIR/pal_tests.xml.tmp -PAL_XUNIT_TEST_LIST=$PAL_TEST_OUTPUT_DIR/pal_tests.xml - -# Capturing stdout and stderr -PAL_OUT_FILE=$PAL_TEST_OUTPUT_DIR/pal_test_out - -# Remove and recreate the temporary test output directory, and the directory where output files were requested to be copied. -if [ "$COPY_TO_TEST_OUTPUT_DIR" == "$PAL_TEST_OUTPUT_DIR" ]; then - if [ -e $PAL_TEST_OUTPUT_DIR ]; then - rm -f -r $PAL_TEST_OUTPUT_DIR - fi - mkdir -p $PAL_TEST_OUTPUT_DIR -else - # No need to recreate the temp output directory, as mktemp would have created a unique empty directory - if [ -e $COPY_TO_TEST_OUTPUT_DIR ]; then - rm -f -r $COPY_TO_TEST_OUTPUT_DIR - fi - mkdir -p $COPY_TO_TEST_OUTPUT_DIR - if [ ! -d $COPY_TO_TEST_OUTPUT_DIR ]; then - echo Failed to create $COPY_TO_TEST_OUTPUT_DIR. - COPY_TO_TEST_OUTPUT_DIR=$PAL_TEST_OUTPUT_DIR - fi -fi -cd $PAL_TEST_OUTPUT_DIR - -echo -echo "Running tests..." -echo - -NUMBER_OF_PASSED_TESTS=0 -NUMBER_OF_FAILED_TESTS=0 - -# Read PAL tests names from the $PAL_TEST_LIST file and run them one by one. -while read TEST_NAME -do - # Remove stdout/stderr file if it exists - rm -f $PAL_OUT_FILE - - # Create a folder with the test name, and use that as the working directory for the test. Many PAL tests don't clean up after - # themselves and may leave files/directories around, but even to handle test failures that result in a dirty state, run each - # test in its own folder. - TEST_WORKING_DIR=$(basename $TEST_NAME) - if [ -e $TEST_WORKING_DIR ]; then - rm -f -r $TEST_WORKING_DIR - fi - mkdir $TEST_WORKING_DIR - cd $TEST_WORKING_DIR - - # Create path to a test executable to run - TEST_COMMAND="$PAL_TEST_BUILD/$TEST_NAME" - echo -n . - # Redirect to temp file - $TEST_COMMAND 2>&1 | tee ${PAL_OUT_FILE} ; ( exit ${PIPESTATUS[0]} ) - - # Get exit code of the test process. - TEST_EXIT_CODE=$? - - # Change back to the output directory, and remove the test's working directory if it's empty - cd $PAL_TEST_OUTPUT_DIR - rmdir $TEST_WORKING_DIR 2>/dev/null - - TEST_XUNIT_NAME=$(dirname $TEST_NAME) - TEST_XUNIT_CLASSNAME=$(dirname $TEST_XUNIT_NAME) - TEST_XUNIT_NAME=${TEST_XUNIT_NAME#*/} - TEST_XUNIT_NAME=${TEST_XUNIT_NAME#*/} - - TEST_XUNIT_NAME=$(echo $TEST_XUNIT_NAME | tr / .) - TEST_XUNIT_CLASSNAME=$(echo $TEST_XUNIT_CLASSNAME | tr / .) - - echo -n "> $PAL_XUNIT_TEST_LIST_TMP - - # If the exit code is 0 then the test passed, otherwise record a failure. - if [ "$TEST_EXIT_CODE" -eq "0" ]; then - NUMBER_OF_PASSED_TESTS=$(($NUMBER_OF_PASSED_TESTS + 1)) - echo "Pass\" />" >> $PAL_XUNIT_TEST_LIST_TMP - else - echo "Fail\" >" >> $PAL_XUNIT_TEST_LIST_TMP - echo "" >> $PAL_XUNIT_TEST_LIST_TMP - echo "" >> $PAL_XUNIT_TEST_LIST_TMP - echo "" >> $PAL_XUNIT_TEST_LIST_TMP - echo "" >> $PAL_XUNIT_TEST_LIST_TMP - FAILED_TEST="$TEST_NAME. Exit code: $TEST_EXIT_CODE" - echo - echo FAILED: $FAILED_TEST - echo - - # Store the name of the failed test in the list of failed tests. - echo $FAILED_TEST >> $PAL_FAILED_TEST_LIST - - NUMBER_OF_FAILED_TESTS=$(($NUMBER_OF_FAILED_TESTS + 1)) - fi -done < $PAL_TEST_LIST - -# We are done running tests. -echo -echo Finished running PAL tests. -echo - -# Finish XUnit file, output to finished file with the number of failures, tests etc -NUMBER_OF_TESTS=$(($NUMBER_OF_PASSED_TESTS + $NUMBER_OF_FAILED_TESTS)) - -XUNIT_SUFFIX="\n" -XUNIT_SUFFIX+="\n" -XUNIT_SUFFIX+="" - -XUNIT_PREFIX="\n" -XUNIT_PREFIX+="\n" -XUNIT_PREFIX+="\n" -XUNIT_PREFIX+="" - -printf "$XUNIT_SUFFIX" >> $PAL_XUNIT_TEST_LIST_TMP -printf "$XUNIT_PREFIX" | cat - $PAL_XUNIT_TEST_LIST_TMP > $PAL_XUNIT_TEST_LIST - -# If there were tests failures then print the list of failed tests -if [ $NUMBER_OF_FAILED_TESTS -gt "0" ]; then - echo "The following test(s) failed:" - while read FAILED_TEST_NAME - do - echo $FAILED_TEST_NAME - done < $PAL_FAILED_TEST_LIST - echo -fi - -echo PAL Test Results: -echo " Passed: $NUMBER_OF_PASSED_TESTS" -echo " Failed: $NUMBER_OF_FAILED_TESTS" -echo - -if [ "$COPY_TO_TEST_OUTPUT_DIR" != "$PAL_TEST_OUTPUT_DIR" ]; then - mv -f $PAL_TEST_OUTPUT_DIR/* $COPY_TO_TEST_OUTPUT_DIR/ - rm -f -r $PAL_TEST_OUTPUT_DIR - echo Copied PAL test output files to $COPY_TO_TEST_OUTPUT_DIR. -fi - -# Set exit code to be equal to the number PAL tests that have failed. -# Exit code 0 indicates success. -exit $NUMBER_OF_FAILED_TESTS diff --git a/src/pal/tests/palsuite/samples/CMakeLists.txt b/src/pal/tests/palsuite/samples/CMakeLists.txt deleted file mode 100644 index ef14ea535..000000000 --- a/src/pal/tests/palsuite/samples/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) - diff --git a/src/pal/tests/palsuite/samples/test1/CMakeLists.txt b/src/pal/tests/palsuite/samples/test1/CMakeLists.txt deleted file mode 100644 index 9db683907..000000000 --- a/src/pal/tests/palsuite/samples/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test.cpp -) - -add_executable(paltest_samples_test1 - ${SOURCES} -) - -add_dependencies(paltest_samples_test1 coreclrpal) - -target_link_libraries(paltest_samples_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/samples/test1/test.cpp b/src/pal/tests/palsuite/samples/test1/test.cpp deleted file mode 100644 index 2eed6f6f4..000000000 --- a/src/pal/tests/palsuite/samples/test1/test.cpp +++ /dev/null @@ -1,41 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test.c -** -** Purpose: This test is an example of the basic structure of a PAL test -** suite test case. -** -** -**==========================================================================*/ - -#include - -int __cdecl main(int argc, char **argv) -{ - /* Initialize the PAL. - */ - if(0 != PAL_Initialize(argc, argv)) - { - return FAIL; - } - - Trace("\nTest #1...\n"); - -#ifdef WIN32 - Trace("\nWe are testing under Win32 environment.\n"); -#else - Trace("\nWe are testing under Non-Win32 environment.\n"); -#endif - - Trace("\nThis test has passed.\n"); - - /* Shutdown the PAL. - */ - PAL_Terminate(); - - return PASS; -} diff --git a/src/pal/tests/palsuite/samples/test1/testinfo.dat b/src/pal/tests/palsuite/samples/test1/testinfo.dat deleted file mode 100644 index 0459d24d6..000000000 --- a/src/pal/tests/palsuite/samples/test1/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Samples -Function = sample -Name = Sample Test #1 -TYPE = DEFAULT -EXE1 = test -Description -=This is a sample test case. It will always pass. - - diff --git a/src/pal/tests/palsuite/samples/test2/CMakeLists.txt b/src/pal/tests/palsuite/samples/test2/CMakeLists.txt deleted file mode 100644 index 9e7fb7b93..000000000 --- a/src/pal/tests/palsuite/samples/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test.cpp -) - -add_executable(paltest_samples_test2 - ${SOURCES} -) - -add_dependencies(paltest_samples_test2 coreclrpal) - -target_link_libraries(paltest_samples_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/samples/test2/test.cpp b/src/pal/tests/palsuite/samples/test2/test.cpp deleted file mode 100644 index 53d4158b9..000000000 --- a/src/pal/tests/palsuite/samples/test2/test.cpp +++ /dev/null @@ -1,48 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test.c -** -** Purpose: A sample to show how to structure a test case. -** -** -**===================================================================*/ - -#include - -int __cdecl main(int argc, char **argv) -{ - int exampleInt = 9; - - /* Initialize the PAL. - */ - if(0 != PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - Trace("\nTest #2...\n"); - -#ifdef WIN32 - Trace("\nWe are testing under Win32 environment.\n"); -#else - Trace("\nWe are testing under Non-Win32 environment.\n"); -#endif - - if (exampleInt == 9) - { - Fail("This is an example to how to code a failure. " - "This failure was caused by exampleInt equalling %d\n", - exampleInt); - } - - /* Shutdown the PAL. - */ - PAL_Terminate(); - - return PASS; -} diff --git a/src/pal/tests/palsuite/samples/test2/testinfo.dat b/src/pal/tests/palsuite/samples/test2/testinfo.dat deleted file mode 100644 index eb6e38db8..000000000 --- a/src/pal/tests/palsuite/samples/test2/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Samples -Function = sample -Name = Sample Test #2 -TYPE = DEFAULT -EXE1 = test -Description -=This is a sample test case. It will always fail. - diff --git a/src/pal/tests/palsuite/smoketest.script b/src/pal/tests/palsuite/smoketest.script deleted file mode 100644 index 19bb8cd6d..000000000 --- a/src/pal/tests/palsuite/smoketest.script +++ /dev/null @@ -1,100 +0,0 @@ -#!/bin/csh - -# Smoketest v1.1 -# -# This smoketest is intended to stress briefly every part of PAL, -# and is to be run before submitting or approving a patch, to ensure -# that it is not breaking the PAL. It should run in about 30 seconds -# -# Installation: -# smoketest.dat and this script should be placed in xxx/xport/tests/palsuite. -# Execute smoketest with the location of rotor as a commandline arg -# with no trailing -# -# Be sure that xrun and testharness are built. (in xport/tests/harness, -# cd test_harness, gmake, cd ../xrun, gmake) -# -if ($#argv != 1) then - echo smoketest v1.1 - echo " " - echo Usage: smoketest location-of-xport - echo " " - echo "where location-of-xport is the location of your xport checkout" - echo "ie. xxxx/xport (with NO TRAILING /)" - echo " (For example: smoketest ~/xport)" - exit -endif - -setenv ROTOR_DIR $argv[1] -setenv TH_BIN $argv[1]/tests/harness/test_harness/testharness -setenv TH_CONFIG $argv[1]/tests/palsuite/smoketest.dat -setenv TH_RESULTS $argv[1]/tests/palsuite/smoketest.log -setenv TH_DIR $argv[1]/tests/palsuite -setenv TH_XRUN $argv[1]/tests/harness/xrun/xrun -setenv PAL_DBG_CHANNELS "" - - -# Let's check to make sure that the developer has built xrun -# and testharness for us and/or that the variables above were set -# properly -if ((-e $TH_BIN) != 1) then - echo $TH_BIN was not found. - echo Did you forget to build the test harness\? - exit -endif - -if ((-e $TH_XRUN) != 1) then - echo $TH_XRUN was not found. - echo Did you forget to build Xrun\? - exit -endif - - -$TH_BIN 2>&1 /dev/null - - -set FAILING = `grep EXEC,FAIL $TH_RESULTS | wc -l` -set PASSING = `grep EXEC,PASS $TH_RESULTS | wc -l` -set DISABLED = `grep EXEC,DISABLED $TH_RESULTS | wc -l` -set TOTAL_TESTS = `grep BUILD $TH_RESULTS | wc -l` -set OTHERS = $TOTAL_TESTS -@ OTHERS = ((($OTHERS - $FAILING) - $PASSING ) - $DISABLED) - -clear -echo Summary: -echo ======== -echo Total Number of Tests: $TOTAL_TESTS -echo Total Passing: $PASSING / $TOTAL_TESTS -echo Total Failing: $FAILING / $TOTAL_TESTS -echo Total Disabled: $DISABLED / $TOTAL_TESTS -echo Other Problems: $OTHERS / $TOTAL_TESTS - -if ($FAILING > 0) then - echo " " - echo "*******************************************" - echo "*******************************************" - echo "*******************************************" - echo "*******************************************" - echo "WARNING WARNING WARNING WARNING WARNING" - echo " " - - if ($FAILING > 1) then - echo There are now $FAILING tests failing. - else - echo There is now 1 test failing. - endif - - echo Please run: - echo " " - echo grep \"EXEC,FAIL\" $TH_RESULTS - echo " " - echo to figure out what is going wrong. - echo "*******************************************" - echo "*******************************************" - echo "*******************************************" - echo "*******************************************" -else - echo " " - echo "Smoketest executed OK." - rm $TH_RESULTS -endif diff --git a/src/pal/tests/palsuite/tests-manual.dat b/src/pal/tests/palsuite/tests-manual.dat deleted file mode 100644 index 402e819ce..000000000 --- a/src/pal/tests/palsuite/tests-manual.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -c_runtime/exit/test2,1 -pal_specific/pal_get_stderr/test1,1 -pal_specific/pal_get_stdin/test1,1 -pal_specific/pal_get_stdout/test1,1 -threading/setconsolectrlhandler/test1,1 -threading/setconsolectrlhandler/test2,1 -threading/setconsolectrlhandler/test3,1 -threading/setconsolectrlhandler/test4,1 diff --git a/src/pal/tests/palsuite/threading/CMakeLists.txt b/src/pal/tests/palsuite/threading/CMakeLists.txt deleted file mode 100644 index 32e66b751..000000000 --- a/src/pal/tests/palsuite/threading/CMakeLists.txt +++ /dev/null @@ -1,45 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(CreateEventA) -add_subdirectory(CreateEventW) -add_subdirectory(CreateMutexA_ReleaseMutex) -add_subdirectory(CreateMutexW_ReleaseMutex) -add_subdirectory(CreateProcessA) -add_subdirectory(CreateProcessW) -add_subdirectory(CreateSemaphoreA_ReleaseSemaphore) -add_subdirectory(CreateSemaphoreW_ReleaseSemaphore) -add_subdirectory(CreateThread) -add_subdirectory(CriticalSectionFunctions) -add_subdirectory(DuplicateHandle) -add_subdirectory(ExitProcess) -add_subdirectory(ExitThread) -add_subdirectory(GetCurrentProcess) -add_subdirectory(GetCurrentProcessId) -add_subdirectory(GetCurrentThread) -add_subdirectory(GetCurrentThreadId) -add_subdirectory(GetExitCodeProcess) -add_subdirectory(GetProcessTimes) -add_subdirectory(GetThreadTimes) -add_subdirectory(NamedMutex) -add_subdirectory(OpenEventW) -add_subdirectory(OpenProcess) -add_subdirectory(QueryThreadCycleTime) -add_subdirectory(QueueUserAPC) -add_subdirectory(ReleaseMutex) -add_subdirectory(releasesemaphore) -add_subdirectory(ResetEvent) -add_subdirectory(ResumeThread) -add_subdirectory(SetErrorMode) -add_subdirectory(SetEvent) -add_subdirectory(SignalObjectAndWait) -add_subdirectory(Sleep) -add_subdirectory(SleepEx) -add_subdirectory(SwitchToThread) -add_subdirectory(TerminateProcess) -add_subdirectory(ThreadPriority) -add_subdirectory(TLS) -add_subdirectory(WaitForMultipleObjects) -add_subdirectory(WaitForMultipleObjectsEx) -add_subdirectory(WaitForSingleObject) -add_subdirectory(YieldProcessor) - diff --git a/src/pal/tests/palsuite/threading/CreateEventA/CMakeLists.txt b/src/pal/tests/palsuite/threading/CreateEventA/CMakeLists.txt deleted file mode 100644 index 1962ade35..000000000 --- a/src/pal/tests/palsuite/threading/CreateEventA/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) -add_subdirectory(test3) - diff --git a/src/pal/tests/palsuite/threading/CreateEventA/test1/CMakeLists.txt b/src/pal/tests/palsuite/threading/CreateEventA/test1/CMakeLists.txt deleted file mode 100644 index 44a6d9849..000000000 --- a/src/pal/tests/palsuite/threading/CreateEventA/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_createeventa_test1 - ${SOURCES} -) - -add_dependencies(paltest_createeventa_test1 coreclrpal) - -target_link_libraries(paltest_createeventa_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/CreateEventA/test1/test1.cpp b/src/pal/tests/palsuite/threading/CreateEventA/test1/test1.cpp deleted file mode 100644 index d8ef0f58a..000000000 --- a/src/pal/tests/palsuite/threading/CreateEventA/test1/test1.cpp +++ /dev/null @@ -1,95 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source: test1.c -** -** Purpose: Test for CreateEvent. Create an event, ensure the -** HANDLE is valid. Then check to ensure that the object is in the -** signaled state. Close the HANDLE and done. -** -** -**=========================================================*/ - -/* - Note: From the rotor_pal documentation: - - lpEventAttributes will always be NULL, bManualReset can be either - TRUE or FALSE, bInitialState can be either TRUE or FALSE, the lpName - may be non-NULL - -*/ - - -#include - -BOOL CreateEventTest() -{ - BOOL bRet = FALSE; - DWORD dwRet = 0; - - LPSECURITY_ATTRIBUTES lpEventAttributes = NULL; - BOOL bManualReset = TRUE; - BOOL bInitialState = TRUE; - - /* Call CreateEvent, and check to ensure the returned HANDLE is a - valid event HANDLE - */ - - HANDLE hEvent = CreateEvent( lpEventAttributes, - bManualReset, - bInitialState, - NULL); - - if (hEvent != NULL) - { - /* Wait for the Object (for 0 time) and ensure that it returns - the value indicating that the event is signaled. - */ - dwRet = WaitForSingleObject(hEvent,0); - - if (dwRet != WAIT_OBJECT_0) - { - Trace("CreateEventTest:WaitForSingleObject failed (%x)\n", GetLastError()); - } - else - { - /* If we make it here, and CloseHandle succeeds, then the - entire test has passed. Otherwise bRet will still show - failure - */ - bRet = CloseHandle(hEvent); - - if (!bRet) - { - Trace("CreateEventTest:CloseHandle failed (%x)\n", GetLastError()); - } - } - } - else - { - Trace("CreateEventTest:CreateEvent failed (%x)\n", GetLastError()); - } - - return bRet; -} - -int __cdecl main(int argc, char **argv) -{ - - if(0 != (PAL_Initialize(argc, argv))) - { - return ( FAIL ); - } - - if(!CreateEventTest()) - { - Fail ("Test failed\n"); - } - - PAL_Terminate(); - return ( PASS ); - -} diff --git a/src/pal/tests/palsuite/threading/CreateEventA/test1/testinfo.dat b/src/pal/tests/palsuite/threading/CreateEventA/test1/testinfo.dat deleted file mode 100644 index c0d169ccd..000000000 --- a/src/pal/tests/palsuite/threading/CreateEventA/test1/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = threading -Function = CreateEvent -Name = Positive Test for CreateEvent -TYPE = DEFAULT -EXE1 = test1 -Description -= Test for CreateEvent. Create an event, ensure the -= HANDLE is valid. Then check to ensure that the object is in the -= signaled state. Close the HANDLE and done. diff --git a/src/pal/tests/palsuite/threading/CreateEventA/test2/CMakeLists.txt b/src/pal/tests/palsuite/threading/CreateEventA/test2/CMakeLists.txt deleted file mode 100644 index 3b7daaa53..000000000 --- a/src/pal/tests/palsuite/threading/CreateEventA/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test2.cpp -) - -add_executable(paltest_createeventa_test2 - ${SOURCES} -) - -add_dependencies(paltest_createeventa_test2 coreclrpal) - -target_link_libraries(paltest_createeventa_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/CreateEventA/test2/test2.cpp b/src/pal/tests/palsuite/threading/CreateEventA/test2/test2.cpp deleted file mode 100644 index a24d20eee..000000000 --- a/src/pal/tests/palsuite/threading/CreateEventA/test2/test2.cpp +++ /dev/null @@ -1,84 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source: test2.c -** -** Purpose: Test for CreateEvent. Create the event with the -** initial state being not signaled. Check to ensure that it -** times out when the event is triggered. -** -** -**=========================================================*/ - -#include - -BOOL CreateEventTest() -{ - BOOL bRet = FALSE; - DWORD dwRet = 0; - - LPSECURITY_ATTRIBUTES lpEventAttributes = 0; - BOOL bManualReset = TRUE; - BOOL bInitialState = FALSE; - - /* Create an event with the Initial State set to FALSE */ - - HANDLE hEvent = CreateEvent( lpEventAttributes, - bManualReset, - bInitialState, - NULL); - - if (hEvent != NULL) - { - /* This should ensure that the object is reset, or - non-signaled. - */ - - dwRet = WaitForSingleObject(hEvent,0); - - if (dwRet != WAIT_TIMEOUT) - { - Trace("CloseEventTest:WaitForSingleObject failed (%x)\n", GetLastError()); - } - else - { - /* At this point, we've tested the function with success. - So long as the HANDLE can be closed, this test should - pass. - */ - - bRet = CloseHandle(hEvent); - - if (!bRet) - { - Trace("CloseEventTest:CloseHandle failed (%x)\n", GetLastError()); - } - } - } - else - { - Trace("CloseEventTest:CreateEvent failed (%x)\n", GetLastError()); - } - - return bRet; -} - -int __cdecl main(int argc, char **argv) -{ - if(0 != (PAL_Initialize(argc, argv))) - { - return ( FAIL ); - } - - if(!CreateEventTest()) - { - Fail ("Test failed\n"); - } - - PAL_Terminate(); - return ( PASS ); - -} diff --git a/src/pal/tests/palsuite/threading/CreateEventA/test2/testinfo.dat b/src/pal/tests/palsuite/threading/CreateEventA/test2/testinfo.dat deleted file mode 100644 index 4af65f18d..000000000 --- a/src/pal/tests/palsuite/threading/CreateEventA/test2/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = threading -Function = CreateEvent -Name = Positive Test for CreateEvent -TYPE = DEFAULT -EXE1 = test2 -Description -= Test for CreateEvent. Create the event with the -= initial state being not signaled. Check to ensure that it -= times out when the event is triggered. diff --git a/src/pal/tests/palsuite/threading/CreateEventA/test3/CMakeLists.txt b/src/pal/tests/palsuite/threading/CreateEventA/test3/CMakeLists.txt deleted file mode 100644 index c3d110d73..000000000 --- a/src/pal/tests/palsuite/threading/CreateEventA/test3/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test3.cpp -) - -add_executable(paltest_createeventa_test3 - ${SOURCES} -) - -add_dependencies(paltest_createeventa_test3 coreclrpal) - -target_link_libraries(paltest_createeventa_test3 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/CreateEventA/test3/test3.cpp b/src/pal/tests/palsuite/threading/CreateEventA/test3/test3.cpp deleted file mode 100644 index 56d107b22..000000000 --- a/src/pal/tests/palsuite/threading/CreateEventA/test3/test3.cpp +++ /dev/null @@ -1,219 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source: test3.c -** -** Purpose: Tests for CreateEventA. Create an event with an empty name, -** create an event with the same name as an already created event -** object. -** -** -**=========================================================*/ - -#include - -#define SWAPPTR ((VOID *)(-1)) - -struct testCase -{ - LPSECURITY_ATTRIBUTES lpEventAttributes; - BOOL bManualReset; - BOOL bInitialState; - char lpName[MAX_PATH + 2]; - DWORD dwNameLen; - DWORD lastError; - BOOL bResult; -}; - -struct testCase testCases[]= -{ - {0, TRUE, FALSE, "", 0, ERROR_SUCCESS, PASS}, - {0, TRUE, FALSE, "", 5, ERROR_SUCCESS, PASS}, - {0, TRUE, FALSE, "", 5, ERROR_ALREADY_EXISTS, PASS}, - {0, TRUE, FALSE, "", 6, ERROR_INVALID_HANDLE, PASS}, - {0, TRUE, FALSE, "", MAX_PATH - 1 - 60, ERROR_SUCCESS, PASS}, - {0, TRUE, FALSE, "", MAX_PATH + 1, ERROR_FILENAME_EXCED_RANGE, PASS} -}; - -static HANDLE hEvent[sizeof(testCases)/sizeof(struct testCase)]; - -DWORD result[sizeof(testCases)/sizeof(struct testCase)]; - -int __cdecl main(int argc, char **argv) -{ - - BOOL bRet = TRUE; - const char *nonEventName = "aaaaaa"; - HANDLE hUnnamedEvent; - HANDLE hFMap; - DWORD dwRet; - int i; - - if(0 != (PAL_Initialize(argc, argv))) - { - return ( FAIL ); - } - - hUnnamedEvent = CreateEventA(0, TRUE, FALSE, NULL); - - if ( NULL == hUnnamedEvent ) - { - bRet = FALSE; - Trace ( "PALSUITE ERROR: CreateEventA (%d, %d, %d, NULL) call " - "returned NULL.\nGetLastError returned %u.\n", 0, TRUE, FALSE, - GetLastError()); - } - - if (!CloseHandle(hUnnamedEvent)) - { - bRet = FALSE; - Trace("PALSUITE ERROR: CreateEventA: CloseHandle(%lp); call " - "failed\nGetLastError returned '%u'.\n", hUnnamedEvent, - GetLastError()); - } - - /* Create non-event with the same name as one of the testCases */ - hFMap = CreateFileMappingA( SWAPPTR, NULL, PAGE_READONLY, 0, 1, - nonEventName ); - - if ( NULL == hFMap ) - { - bRet = FALSE; - Trace ( "PALSUITE ERROR: CreateFileMapping (%p, %p, %d, %d, %d, %s)" - " call returned NULL.\nGetLastError returned %u.\n", - SWAPPTR, NULL, PAGE_READONLY, 0, 0, nonEventName, - GetLastError()); - goto done; - } - - /* Create Events */ - for (i = 0; i < sizeof(testCases)/sizeof(struct testCase); i++) - { - /* create name */ - memset (testCases[i].lpName, '\0', (MAX_PATH + 2)); - memset (testCases[i].lpName, 'a', testCases[i].dwNameLen ); - - SetLastError(ERROR_SUCCESS); - - hEvent[i] = CreateEventA( testCases[i].lpEventAttributes, - testCases[i].bManualReset, - testCases[i].bInitialState, - testCases[i].lpName); - - if (hEvent[i] != INVALID_HANDLE_VALUE) - { - DWORD dwError = GetLastError(); - - if (dwError != testCases[i].lastError) - { - bRet = FALSE; - Trace ("PALSUITE ERROR:\nCreateEventA(%lp, %d, %d, %s)" - "\nGetLastError returned '%u', it should have returned" - "'%d' at index '%d'.\n", testCases[i].lpEventAttributes, - testCases[i].bManualReset, testCases[i].bInitialState, - testCases[i].lpName, dwError, - testCases[i].lastError, i); - } - if ( ERROR_FILENAME_EXCED_RANGE == testCases[i].lastError ) - { - result [i] = 1; - } - if ( ERROR_INVALID_HANDLE == testCases[i].lastError ) - { - result [i] = 1; - } - /* - * If we expected the testcase to FAIL and it passed, - * report an error. - */ - if (testCases[i].bResult == FAIL) - { - bRet = FALSE; - Trace ("PALSUITE ERROR:\nCreateEventA(%lp, %d, %d, %s)" - "\nShould have returned INVALID_HANDLE_VALUE but " - "didn't at index '%d'.\n", - testCases[i].lpEventAttributes, - testCases[i].bManualReset, - testCases[i].bInitialState, - testCases[i].lpName, i); - } - /* - * If result hasn't been set already set it to 0 so all the - * resources will be freed. - */ - if (!result[i] ) - { - result[i] = 0; - } - } - else - { - /* - * If we get an INVALID_HANDLE_VALUE and we expected the - * test case to pass, report an error. - */ - result[i] = 1; - - if (testCases[i].bResult == PASS) - { - bRet = FALSE; - Trace ("PALSUITE ERROR:\nCreateEventA(%lp, %d, %d, %s);" - "\nReturned INVALID_HANDLE_VALUE at index '%d'.\n", - testCases[i].lpEventAttributes, - testCases[i].bManualReset, testCases[i].bInitialState, - testCases[i].lpName, i); - } - } - } - - /* cleanup */ - for (i = 0; i < sizeof(testCases)/sizeof(struct testCase); i++) - { - if (result[i]) - { - continue; - } - dwRet = WaitForSingleObject ( hEvent[i], 0 ); - - if (dwRet != WAIT_TIMEOUT) - { - bRet = FALSE; - Trace("PALSUITE ERROR: CreateEventA:\nWaitForSingleObject (%lp, " - "%d) call failed at index %d .\nGetLastError returned " - "'%u'.\n", hEvent[i], 0, i, GetLastError()); - } - - if (!CloseHandle(hEvent[i])) - { - bRet = FALSE; - Trace("PALSUITE ERROR: CreateEventA: CloseHandle(%lp) call " - "failed at index %d\nGetLastError returned '%u'.\n", - hEvent[i], i, GetLastError()); - } - } - -done: - if (!CloseHandle(hFMap)) - { - bRet = FALSE; - Trace("PALSUITE ERROR: CreateEventW: CloseHandle(%p) call " - "failed\nGetLastError returned '%u'.\n", hFMap, - GetLastError()); - } - - if (FALSE == bRet) - { - bRet = FAIL; - } - else - { - bRet = PASS; - } - - PAL_TerminateEx(bRet); - - return(bRet); -} diff --git a/src/pal/tests/palsuite/threading/CreateEventA/test3/testinfo.dat b/src/pal/tests/palsuite/threading/CreateEventA/test3/testinfo.dat deleted file mode 100644 index c3a344a2d..000000000 --- a/src/pal/tests/palsuite/threading/CreateEventA/test3/testinfo.dat +++ /dev/null @@ -1,16 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = threading -Function = CreateEventA -Name = Positive Test for CreateEventA -TYPE = DEFAULT -EXE1 = test3 -Description -= Tests for CreateEventA. Create an unnamed event, create -= an event with an empty name, create an event with a name longer than -= MAX_PATH, MAX_PATH + 1, create an event with a name already taken -= by a non-event object, create an event with a name already taken -= by an event object. diff --git a/src/pal/tests/palsuite/threading/CreateEventW/CMakeLists.txt b/src/pal/tests/palsuite/threading/CreateEventW/CMakeLists.txt deleted file mode 100644 index 1962ade35..000000000 --- a/src/pal/tests/palsuite/threading/CreateEventW/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) -add_subdirectory(test3) - diff --git a/src/pal/tests/palsuite/threading/CreateEventW/test1/CMakeLists.txt b/src/pal/tests/palsuite/threading/CreateEventW/test1/CMakeLists.txt deleted file mode 100644 index 989bc44d6..000000000 --- a/src/pal/tests/palsuite/threading/CreateEventW/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_createeventw_test1 - ${SOURCES} -) - -add_dependencies(paltest_createeventw_test1 coreclrpal) - -target_link_libraries(paltest_createeventw_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/CreateEventW/test1/test1.cpp b/src/pal/tests/palsuite/threading/CreateEventW/test1/test1.cpp deleted file mode 100644 index 8d99e4193..000000000 --- a/src/pal/tests/palsuite/threading/CreateEventW/test1/test1.cpp +++ /dev/null @@ -1,93 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source: test1.c -** -** Purpose: Test for CreateEventW -** -** -**=========================================================*/ - -/* - * Note: From the rotor_pal documentation: lpEventAttributes will - * always be NULL, bManualReset can be either TRUE or FALSE, - * bInitialState can be either TRUE or FALSE, the lpName may be - * non-NULL. -*/ -#define UNICODE -#include - -BOOL CreateEventTest() -{ - BOOL bRet = FALSE; - DWORD dwRet = 0; - - LPSECURITY_ATTRIBUTES lpEventAttributes = NULL; - BOOL bManualReset = TRUE; - BOOL bInitialState = TRUE; - - /* - * Call CreateEvent, and check to ensure the returned HANDLE is a - * valid event HANDLE - */ - - HANDLE hEvent = CreateEventW(lpEventAttributes, - bManualReset, - bInitialState, - NULL); - - if (hEvent != NULL) - { - /* - * Wait for the Object (for 0 time) and ensure that it returns - * the value indicating that the event is signaled. - */ - dwRet = WaitForSingleObject(hEvent,0); - - if (dwRet != WAIT_OBJECT_0) - { - Trace("CreateEventTest:WaitForSingleObject failed (%x)\n", GetLastError()); - } - else - { - /* - * If we make it here, and CloseHandle succeeds, then the - * entire test has passed. Otherwise bRet will still show - * failure - */ - bRet = CloseHandle(hEvent); - - if (!bRet) - { - Trace("CreateEventTest:CloseHandle failed (%x)\n", GetLastError()); - } - } - } - else - { - Trace("CreateEventTest:CreateEvent failed (%x)\n", GetLastError()); - } - - return bRet; -} - -int __cdecl main(int argc, char **argv) -{ - - if(0 != (PAL_Initialize(argc, argv))) - { - return ( FAIL ); - } - - if(!CreateEventTest()) - { - Fail ("Test failed\n"); - } - - PAL_Terminate(); - return ( PASS ); - -} diff --git a/src/pal/tests/palsuite/threading/CreateEventW/test1/testinfo.dat b/src/pal/tests/palsuite/threading/CreateEventW/test1/testinfo.dat deleted file mode 100644 index 204ad1f4d..000000000 --- a/src/pal/tests/palsuite/threading/CreateEventW/test1/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = threading -Function = CreateEventW -Name = Positive Test for CreateEventW -TYPE = DEFAULT -EXE1 = test1 -Description -= Test for CreateEventW. Create an event, ensure the -= HANDLE is valid. Then check to ensure that the object is in the -= signaled state. Close the HANDLE and done. diff --git a/src/pal/tests/palsuite/threading/CreateEventW/test2/CMakeLists.txt b/src/pal/tests/palsuite/threading/CreateEventW/test2/CMakeLists.txt deleted file mode 100644 index f8ebb5319..000000000 --- a/src/pal/tests/palsuite/threading/CreateEventW/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test2.cpp -) - -add_executable(paltest_createeventw_test2 - ${SOURCES} -) - -add_dependencies(paltest_createeventw_test2 coreclrpal) - -target_link_libraries(paltest_createeventw_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/CreateEventW/test2/test2.cpp b/src/pal/tests/palsuite/threading/CreateEventW/test2/test2.cpp deleted file mode 100644 index 4df218995..000000000 --- a/src/pal/tests/palsuite/threading/CreateEventW/test2/test2.cpp +++ /dev/null @@ -1,85 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source: test2.c -** -** Purpose: Test for CreateEventW. Create the event with the -** initial state being not signaled. Check to ensure that it -** times out when the event is triggered. -** -** -**=========================================================*/ -#define UNICODE -#include - -BOOL CreateEventTest() -{ - BOOL bRet = FALSE; - DWORD dwRet = 0; - - LPSECURITY_ATTRIBUTES lpEventAttributes = 0; - BOOL bManualReset = TRUE; - BOOL bInitialState = FALSE; - - - /* Create an event with the Initial State set to FALSE */ - - HANDLE hEvent = CreateEventW(lpEventAttributes, - bManualReset, - bInitialState, - NULL); - - if (hEvent != NULL) - { - /* This should ensure that the object is reset, or - non-signaled. - */ - - dwRet = WaitForSingleObject(hEvent,0); - - if (dwRet != WAIT_TIMEOUT) - { - Trace("CloseEventTest:WaitForSingleObject failed (%x)\n", GetLastError()); - } - else - { - /* At this point, we've tested the function with success. - So long as the HANDLE can be closed, this test should - pass. - */ - - bRet = CloseHandle(hEvent); - - if (!bRet) - { - Trace("CloseEventTest:CloseHandle failed (%x)\n", GetLastError()); - } - } - } - else - { - Trace("CloseEventTest:CreateEvent failed (%x)\n", GetLastError()); - } - - return bRet; -} - -int __cdecl main(int argc, char **argv) -{ - if(0 != (PAL_Initialize(argc, argv))) - { - return ( FAIL ); - } - - if(!CreateEventTest()) - { - Fail ("Test failed\n"); - } - - PAL_Terminate(); - return ( PASS ); - -} diff --git a/src/pal/tests/palsuite/threading/CreateEventW/test2/testinfo.dat b/src/pal/tests/palsuite/threading/CreateEventW/test2/testinfo.dat deleted file mode 100644 index 01f7519ae..000000000 --- a/src/pal/tests/palsuite/threading/CreateEventW/test2/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = threading -Function = CreateEventW -Name = Positive Test for CreateEventW -TYPE = DEFAULT -EXE1 = test2 -Description -= Test for CreateEvent. Create the event with the -= initial state being not signaled. Check to ensure that it -= times out when the event is triggered. diff --git a/src/pal/tests/palsuite/threading/CreateEventW/test3/CMakeLists.txt b/src/pal/tests/palsuite/threading/CreateEventW/test3/CMakeLists.txt deleted file mode 100644 index b6ba370d5..000000000 --- a/src/pal/tests/palsuite/threading/CreateEventW/test3/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test3.cpp -) - -add_executable(paltest_createeventw_test3 - ${SOURCES} -) - -add_dependencies(paltest_createeventw_test3 coreclrpal) - -target_link_libraries(paltest_createeventw_test3 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/CreateEventW/test3/test3.cpp b/src/pal/tests/palsuite/threading/CreateEventW/test3/test3.cpp deleted file mode 100644 index 22f0fcfc4..000000000 --- a/src/pal/tests/palsuite/threading/CreateEventW/test3/test3.cpp +++ /dev/null @@ -1,233 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source: test3.c -** -** Purpose: Tests for CreateEvent. Create an unnamed event, create -** an event with an empty name, create an event with a name longer than -** MAX_PATH, MAX_PATH + 1, create an event with a name already taken -** by a non-event object, create an event with a name already taken -** by an event object. -** -** -**=========================================================*/ -#include - -#define SWAPPTR ((VOID *) (-1)) - -struct testCase -{ - LPSECURITY_ATTRIBUTES lpEventAttributes; - BOOL bManualReset; - BOOL bInitialState; - WCHAR lpName[MAX_PATH + 2]; - DWORD dwNameLen; - DWORD lastError; - BOOL bResult; -}; - -struct testCase testCases[]= -{ - {0, TRUE, FALSE, {'\0'}, 0, ERROR_SUCCESS, PASS}, - {0, TRUE, FALSE, {'\0'}, 5, ERROR_SUCCESS, PASS}, - {0, TRUE, FALSE, {'\0'}, 5, ERROR_ALREADY_EXISTS, PASS}, - {0, TRUE, FALSE, {'\0'}, 6, ERROR_INVALID_HANDLE, PASS}, - {0, TRUE, FALSE, {'\0'}, MAX_PATH - 1 - 60, ERROR_SUCCESS, PASS}, - {0, TRUE, FALSE, {'\0'}, MAX_PATH - 60, ERROR_SUCCESS, PASS}, -}; - -static HANDLE hEvent[sizeof(testCases)/sizeof(struct testCase)]; - -DWORD result[sizeof(testCases)/sizeof(struct testCase)]; - -int __cdecl main(int argc, char **argv) -{ - - BOOL bRet = TRUE; - WCHAR nonEventName[] = {'a','a','a','a','a','a','\0'}; - char name[MAX_PATH + 2]; - WCHAR *wName; - HANDLE hFMap = NULL; - HANDLE hUnnamedEvent; - DWORD dwRet; - int i; - - if(0 != (PAL_Initialize(argc, argv))) - { - return ( FAIL ); - } - - hUnnamedEvent = CreateEventW(0, TRUE, FALSE, NULL); - - if ( NULL == hUnnamedEvent ) - { - bRet = FALSE; - Trace ( "PALSUITE ERROR: CreateEventW (%d, %d, %d, NULL) call " - "returned NULL.\nGetLastError returned %u.\n", 0, TRUE, FALSE, - GetLastError()); - goto done; - } - - if (!CloseHandle(hUnnamedEvent)) - { - bRet = FALSE; - Trace("PALSUITE ERROR: CreateEventW: CloseHandle(%lp); call " - "failed\nGetLastError returned '%u'.\n", hUnnamedEvent, - GetLastError()); - } - - /* Create non-event with the same name as one of the testCases */ - hFMap = CreateFileMappingW( SWAPPTR, NULL, PAGE_READONLY, 0, 1, - nonEventName ); - - if ( NULL == hFMap ) - { - bRet = FALSE; - Trace ( "PALSUITE ERROR: CreateFileMapping (%p, %p, %d, %d, %d, %S)" - " call returned NULL.\nGetLastError returned %u\n", - SWAPPTR, NULL, PAGE_READONLY, 0, 0, nonEventName, - GetLastError()); - } - - /* Create Events */ - for (i = 0; i < sizeof(testCases)/sizeof(struct testCase); i++) - { - /* create name */ - memset (name, '\0', MAX_PATH + 2); - memset (name, 'a', testCases[i].dwNameLen ); - - wName = convert(name); - - wcsncpy(testCases[i].lpName, wName, - testCases[i].dwNameLen); - - free(wName); - - SetLastError(ERROR_SUCCESS); - - hEvent[i] = CreateEventW( testCases[i].lpEventAttributes, - testCases[i].bManualReset, - testCases[i].bInitialState, - testCases[i].lpName); - - if (hEvent[i] != INVALID_HANDLE_VALUE) - { - DWORD dwError = GetLastError(); - - if (dwError != testCases[i].lastError) - { - bRet = FALSE; - Trace ("PALSUITE ERROR:\nCreateEvent(%lp, %d, %d, %S)" - "\nGetLastError returned '%u', it should have returned" - "'%d' at index '%d'.\n", testCases[i].lpEventAttributes, - testCases[i].bManualReset, testCases[i].bInitialState, - testCases[i].lpName, dwError, - testCases[i].lastError, i); - } - if ( ERROR_FILENAME_EXCED_RANGE == testCases[i].lastError ) - { - result [i] = 1; - } - if ( ERROR_INVALID_HANDLE == testCases[i].lastError ) - { - result [i] = 1; - } - /* - * If we expected the testcase to FAIL and it passed, - * report an error. - */ - if (testCases[i].bResult == FAIL) - { - bRet = FALSE; - Trace ("PALSUITE ERROR:\nCreateEvent(%lp, %d, %d, %S)" - "\nShould have returned INVALID_HANDLE_VALUE but " - "didn't at index '%d'.\n", - testCases[i].lpEventAttributes, - testCases[i].bManualReset, - testCases[i].bInitialState, - testCases[i].lpName, i); - } - /* - * If result hasn't been set already set it to 0 so all the - * resources will be freed. - */ - if (!result[i]) - { - result[i] = 0; - } - } - else - { - /* - * If we get an INVALID_HANDLE_VALUE and we expected the - * test case to pass, report an error. - */ - result[i] = 1; - - if (testCases[i].bResult == PASS) - { - bRet = FALSE; - Trace ("PALSUITE ERROR:\nCreateEvent(%lp, %d, %d, %S);" - "\nReturned INVALID_HANDLE_VALUE at index '%d'.\n", - testCases[i].lpEventAttributes, - testCases[i].bManualReset, testCases[i].bInitialState, - testCases[i].lpName, i); - } - } - } - - /* cleanup */ - for (i = 0; i < sizeof(testCases)/sizeof(struct testCase); i++) - { - if (result[i]) - { - continue; - } - dwRet = WaitForSingleObject ( hEvent[i], 0 ); - - if (dwRet != WAIT_TIMEOUT) - { - bRet = FALSE; - Trace("PALSUITE ERROR: CreateEventW:\nWaitForSingleObject (%lp, " - "%d) call failed at index %d .\nGetLastError returned " - "'%u'.\n", hEvent[i], 0, i, GetLastError()); - } - - if (!CloseHandle(hEvent[i])) - { - bRet = FALSE; - Trace("PALSUITE ERROR: CreateEventW: CloseHandle(%lp) call " - "failed at index %d\nGetLastError returned '%u'.\n", - hEvent[i], i, GetLastError()); - } - } - -done: - if (hFMap != NULL && !CloseHandle(hFMap)) - { - bRet = FALSE; - Trace("PALSUITE ERROR: CreateEventW: CloseHandle(%p) call " - "failed\nGetLastError returned '%u'.\n", hFMap, - GetLastError()); - } - - if (FALSE == bRet) - { - bRet = FAIL; - } - else - { - bRet = PASS; - } - - PAL_TerminateEx(bRet); - - return(bRet); - -} - - - diff --git a/src/pal/tests/palsuite/threading/CreateEventW/test3/testinfo.dat b/src/pal/tests/palsuite/threading/CreateEventW/test3/testinfo.dat deleted file mode 100644 index 4776ed239..000000000 --- a/src/pal/tests/palsuite/threading/CreateEventW/test3/testinfo.dat +++ /dev/null @@ -1,16 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = threading -Function = CreateEventW -Name = Positive Test for CreateEventW -TYPE = DEFAULT -EXE1 = test3 -Description -= Tests for CreateEventW. Create an unnamed event, create -= an event with an empty name, create an event with a name longer than -= MAX_PATH, MAX_PATH + 1, create an event with a name already taken -= by a non-event object, create an event with a name already taken -= by an event object. diff --git a/src/pal/tests/palsuite/threading/CreateMutexA_ReleaseMutex/CMakeLists.txt b/src/pal/tests/palsuite/threading/CreateMutexA_ReleaseMutex/CMakeLists.txt deleted file mode 100644 index ef14ea535..000000000 --- a/src/pal/tests/palsuite/threading/CreateMutexA_ReleaseMutex/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) - diff --git a/src/pal/tests/palsuite/threading/CreateMutexA_ReleaseMutex/test1/CMakeLists.txt b/src/pal/tests/palsuite/threading/CreateMutexA_ReleaseMutex/test1/CMakeLists.txt deleted file mode 100644 index 40ed5848c..000000000 --- a/src/pal/tests/palsuite/threading/CreateMutexA_ReleaseMutex/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - CreateMutexA.cpp -) - -add_executable(paltest_createmutexa_releasemutex_test1 - ${SOURCES} -) - -add_dependencies(paltest_createmutexa_releasemutex_test1 coreclrpal) - -target_link_libraries(paltest_createmutexa_releasemutex_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/CreateMutexA_ReleaseMutex/test1/CreateMutexA.cpp b/src/pal/tests/palsuite/threading/CreateMutexA_ReleaseMutex/test1/CreateMutexA.cpp deleted file mode 100644 index 3074fa03f..000000000 --- a/src/pal/tests/palsuite/threading/CreateMutexA_ReleaseMutex/test1/CreateMutexA.cpp +++ /dev/null @@ -1,344 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source: CreateMutexA_ReleaseMutex/test1/CreateMutexA.c -** -** Purpose: This test case tests whether a Mutex object created -** with CreateMutex really works by mutually excluding -** threads from accessing a data structure at the same -** time. Here we have a buffer that can be filled or -** emptied, we use a Mutex object to ensure that one -** operation cannot be started until the other is -** finished. If one operation detects that the other -** has not finished, it fails. There is a Producer -** thread which will try to fill the buffer 25 times, -** and a consumer thread which try to empty the buffer -** 25 times. If either the fill or empty operations -** fails because the Mutex failed to mutually exclude -** them, the corresponding thread will set an error -** flag and return. This will cause the test case to -** fail. -** -** To increase the probability of identifying problems, -** the Fill opeartion has been slowed down with a call -** to Sleep. This ensures that one operation will try -** to access the shared buffer while the other is in -** progress. -** -** NOTE: this test case also serves as a test case for -** WaitForSingleObject. -** -** -** Dependencies: CreateThread -** ReleaseMutex -** WaitForSingleObject -** WaitForMultipleObjects -** Sleep -** memset -** - -** -**=========================================================*/ - -#define UNICODE -#include - -/* Define some values that we will using many times */ -#define MAIN_BUF_SIZE 40 -#define NUM_OF_CYCLES 40 - -/* Buffer Operation return codes */ -#define OP_OK 0 -#define OP_ERR 1 -#define OP_NONE 2 - - -HANDLE hMutex; /* handle to mutex */ - -BOOL bProdErr; /* Producer error Flag */ -BOOL bConErr; /* Consumer error Flag */ - -/* Test Buffer */ -char Buffer[MAIN_BUF_SIZE]; - -/* - * EmptyBuffer implements the empty operation for test buffer. - */ -int -EmptyBuffer() -{ - int i; - - if ( WaitForSingleObject(hMutex, INFINITE) == WAIT_FAILED) - { - Fail("ERROR: WaitForSingleObject failed.\n"); - } - - /* Check to see if the buffer is already completely empty */ - for (i=0; i - -const char *szMutex = "MyMutex"; -const char *szEmpty = ""; - -/* Function Prototypes */ -BOOL TestNamedMutex(const char *szMutexName); -DWORD NamedMutexThread(LPVOID lpParam); -BOOL NegativeReleaseMutexTests(); - -struct ThreadData -{ - HANDLE hMutex; - BOOL bReturnCode; -}; -typedef struct ThreadData THREADDATA; - - -int __cdecl main (int argc, char **argv) -{ - BOOL bFailures = FALSE; - char *szMaxPath; - - if(0 != (PAL_Initialize(argc, argv))) - { - return ( FAIL ); - } - - - /* - * Test named Mutexes with ordinary string - */ - - if (!TestNamedMutex(szMutex)) - { - bFailures = TRUE; - } - - - /* - * Test named Mutexes with empty ("") string - */ - - if (!TestNamedMutex(szEmpty)) - { - bFailures = TRUE; - } - - - /* - * Test named Mutexes with string of length MAX_LONGPATHPATH - */ - - szMaxPath = (char *)malloc(MAX_LONGPATH+2); - memset(szMaxPath, 'A', MAX_LONGPATH-60); - szMaxPath[MAX_LONGPATH-60] = 0; - - if (!TestNamedMutex(szMaxPath)) - { - bFailures = TRUE; - } - - free((void*)szMaxPath); - - - /* - * Run some negative tests on ReleaseMutex - */ - - if (!NegativeReleaseMutexTests()) - { - bFailures = TRUE; - } - - - /* - * If there were any failures, then abort with a call to Fail - */ - - if (bFailures == TRUE) - { - Fail("ERROR: There some failures in the Mutex tests.\n"); - } - - PAL_Terminate(); - return ( PASS ); -} - - -/* - * Testing Function - * - * Try to get multiple handles to a named Mutex and test - * to make sure they actually refer to same Mutex object. - */ -BOOL TestNamedMutex(const char *szMutexName) -{ - DWORD dwData; - HANDLE hMutex1; - HANDLE hMutex2; - HANDLE hThread; - THREADDATA threadData; - - /* Create a mutex and take ownership immediately */ - hMutex1 = CreateMutexA (NULL, TRUE, szMutexName); - - if (NULL == hMutex1) - { - Trace("ERROR: CreateMutexA #1 failed. GetLastError returned %u\n", - GetLastError()); - return FALSE; - } - - /* Try to wait on the Mutex we just created. We should not block. */ - if (WaitForSingleObject(hMutex1, 1000) == WAIT_TIMEOUT) - { - Trace("WaitForSingleObject blocked on a Mutex that we owned.\n"); - return FALSE; - } - /* We have to call ReleaseMutex here because of the Wait */ - if (ReleaseMutex(hMutex1) == FALSE) - { - Trace("ReleaseMutex Failed.\n"); - return FALSE; - } - - /* Get a second handle to the same mutex */ - hMutex2 = CreateMutexA (NULL, FALSE, szMutexName); - - if (NULL == hMutex2) - { - Trace("ERROR: CreateMutex #2 failed. GetLastError returned %u\n", - GetLastError()); - free((void*)szMutexName); - return FALSE; - } - - /* - * Create a thread that will Wait on the second handle. - */ - threadData.hMutex = hMutex2; - hThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)NamedMutexThread, - (LPVOID)&threadData, 0, &dwData); - - if (NULL == hThread) - { - Trace("ERROR: CreateThread failed. GetLastError returned %u\n", - GetLastError()); - return FALSE; - } - - /* Give the thread a little time to execute & wait*/ - Sleep(500); - - /* Signal the the first handle */ - if (ReleaseMutex(hMutex1) == FALSE) - { - Trace("ReleaseMutex Failed.\n"); - return FALSE; - } - - /* Give the thread some time to finish */ - Sleep(2000); - - /* Clean Up */ - if (CloseHandle(hMutex1) == FALSE || - CloseHandle(hMutex2) == FALSE || - CloseHandle(hThread) == FALSE) - { - Trace("ERROR: CloseHandle failed.\n"); - return FALSE; - } - - /* Check the return code to see if signalling the first */ - /* Mutex handle woke up the thread which was Waiting on */ - /* the second handle. */ - if (threadData.bReturnCode != FALSE) - { - Trace("ERROR: The handles did not refer to the same Mutex object.\n"); - return FALSE; - } - - return TRUE; -} - - -/* - * Thread function used with above testing function. - */ -DWORD NamedMutexThread(LPVOID lpParam) -{ - BOOL bTimedOut = FALSE; - THREADDATA *lpThreadData = (THREADDATA *)lpParam; - - /* Wait on the Mutex that was passed to us */ - if (WaitForSingleObject(lpThreadData->hMutex, 10000) == WAIT_TIMEOUT) - { - /* The Mutex was not signaled in the allotted time */ - bTimedOut = TRUE; - } - if (ReleaseMutex(lpThreadData->hMutex) == FALSE) - { - Trace("ERROR: ReleaseMutex failed.\n"); - lpThreadData->bReturnCode = FALSE; - return 0; - } - - /* Indicate whether we timed out Waiting on the Mutex */ - lpThreadData->bReturnCode = bTimedOut; - - return 0; -} - - -/* - * Testing Function - * - * Try some negative tests on ReleaseMutex - */ -BOOL NegativeReleaseMutexTests() -{ - HANDLE hMutex; - BOOL bRet; - BOOL bResults = TRUE; - - - /* - * Try calling ReleaseMutex on a null handle - */ - hMutex = 0; - bRet = ReleaseMutex(hMutex); - - if (bRet != 0) - { - Trace("Error: ReleaseMutex accepted null handle.\n"); - bResults = FALSE; - } - - - /* - * Try calling ReleaseMutex on an handle that we don't own - */ - hMutex = CreateMutexA (NULL, TRUE, NULL); - if (hMutex == 0) - { - Trace("Error: CreateMutex failed.\n"); - bResults = FALSE; - } - - bRet = ReleaseMutex(hMutex); - bRet = ReleaseMutex(hMutex); - - if (bRet != FALSE) - { - Trace("Error: ReleaseMutex accepted unowned handle.\n"); - bResults = FALSE; - } - - if (CloseHandle(hMutex) == FALSE) - { - Trace("Error: CloseHandle failed.\n"); - bResults = FALSE; - } - - - - /* - * Try calling ReleaseMutex on an handle that has been closed - */ - hMutex = CreateMutexA (NULL, TRUE, NULL); - if (hMutex == 0) - { - Trace("Error: CreateMutex failed.\n"); - bResults = FALSE; - } - - if (ReleaseMutex(hMutex) == FALSE) - { - Trace("Error: ReleaseMutex failed.\n"); - bResults = FALSE; - } - if (CloseHandle(hMutex) == FALSE) - { - Trace("Error: CloseHandle failed.\n"); - bResults = FALSE; - } - - bRet = ReleaseMutex(hMutex); - - if (bRet != FALSE) - { - Trace("Error: ReleaseMutex accepted invalid handle.\n"); - bResults = FALSE; - } - - return bResults; -} diff --git a/src/pal/tests/palsuite/threading/CreateMutexA_ReleaseMutex/test2/testinfo.dat b/src/pal/tests/palsuite/threading/CreateMutexA_ReleaseMutex/test2/testinfo.dat deleted file mode 100644 index 7e37528c1..000000000 --- a/src/pal/tests/palsuite/threading/CreateMutexA_ReleaseMutex/test2/testinfo.dat +++ /dev/null @@ -1,24 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = threading -Function = CreateMutexA / ReleaseMutex -Name = Basic validity Tests for CreateMutexA / ReleaseMutex -TYPE = DEFAULT -EXE1 = createmutexa -Description -= This test case tests the following things -= - Creation of named Mutexes -= - Creating multiple handles to a single named Mutex -= - Ensuring that these handles work interchangeably -= - Setting bInitialOwnerFlag to TRUE will cause the -= initial call to a Wait function on the same Mutex -= to actually wait. -= - Waiting on a Mutex that a thread already owns should -= not block. -= - Create Named mutex with empty string ("") -= - Create Named mutex with string of MAX_PATH length -= - Calling RelaseMutex with invalid Mutex handles and -= valid but unowned Mutexes. diff --git a/src/pal/tests/palsuite/threading/CreateMutexW_ReleaseMutex/CMakeLists.txt b/src/pal/tests/palsuite/threading/CreateMutexW_ReleaseMutex/CMakeLists.txt deleted file mode 100644 index ef14ea535..000000000 --- a/src/pal/tests/palsuite/threading/CreateMutexW_ReleaseMutex/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) - diff --git a/src/pal/tests/palsuite/threading/CreateMutexW_ReleaseMutex/test1/CMakeLists.txt b/src/pal/tests/palsuite/threading/CreateMutexW_ReleaseMutex/test1/CMakeLists.txt deleted file mode 100644 index c30bad275..000000000 --- a/src/pal/tests/palsuite/threading/CreateMutexW_ReleaseMutex/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - CreateMutexW.cpp -) - -add_executable(paltest_createmutexw_releasemutex_test1 - ${SOURCES} -) - -add_dependencies(paltest_createmutexw_releasemutex_test1 coreclrpal) - -target_link_libraries(paltest_createmutexw_releasemutex_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/CreateMutexW_ReleaseMutex/test1/CreateMutexW.cpp b/src/pal/tests/palsuite/threading/CreateMutexW_ReleaseMutex/test1/CreateMutexW.cpp deleted file mode 100644 index ec8e0c66b..000000000 --- a/src/pal/tests/palsuite/threading/CreateMutexW_ReleaseMutex/test1/CreateMutexW.cpp +++ /dev/null @@ -1,344 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source: CreateMutexW_ReleaseMutex/test1/CreateMutexW.c -** -** Purpose: This test case tests whether a Mutex object created -** with CreateMutex really works by mutually excluding -** threads from accessing a data structure at the same -** time. Here we have a buffer that can be filled or -** emptied, we use a Mutex object to ensure that one -** operation cannot be started until the other is -** finished. If one operation detects that the other -** has not finished, it fails. There is a Producer -** thread which will try to fill the buffer 25 times, -** and a consumer thread which try to empty the buffer -** 25 times. If either the fill or empty operations -** fails because the Mutex failed to mutually exclude -** them, the corresponding thread will set an error -** flag and return. This will cause the test case to -** fail. -** -** To increase the probability of identifying problems, -** the Fill opeartion has been slowed dowm with a call -** to Sleep. This ensures that one operation will try -** to access the shared buffer while the other is in -** progress. -** -** NOTE: this test case also serves as a test case for -** WaitForSingleObject. -** -** -** Dependencies: CreateThread -** ReleaseMutex -** WaitForSingleObject -** WaitForMultipleObjects -** Sleep -** memset -** - -** -**=========================================================*/ - -#define UNICODE -#include - -/* Define some values that we will using many times */ -#define MAIN_BUF_SIZE 40 -#define NUM_OF_CYCLES 40 - -/* Buffer Operation return codes */ -#define OP_OK 0 -#define OP_ERR 1 -#define OP_NONE 2 - - -HANDLE hMutex; /* handle to mutex */ - -BOOL bProdErr; /* Producer error Flag */ -BOOL bConErr; /* Consumer error Flag */ - -/* Test Buffer */ -char Buffer[MAIN_BUF_SIZE]; - -/* - * EmptyBuffer implements the empty operation for test buffer. - */ -int -EmptyBuffer() -{ - int i; - - if ( WaitForSingleObject(hMutex, INFINITE) == WAIT_FAILED) - { - Fail("ERROR: WaitForSingleObject failed.\n"); - } - - /* Check to see if the buffer is already completely empty */ - for (i=0; i - -const char *szMutex = "MyMutex"; -const char *szEmpty = ""; - -/* Function Prototypes */ -BOOL TestNamedMutex(const char *szMutexName); -DWORD NamedMutexThread(LPVOID lpParam); -BOOL NegativeReleaseMutexTests(); - -struct ThreadData -{ - HANDLE hMutex; - BOOL bReturnCode; -}; -typedef struct ThreadData THREADDATA; - - -int __cdecl main (int argc, char **argv) -{ - BOOL bFailures = FALSE; - char *szMaxPath; - - if(0 != (PAL_Initialize(argc, argv))) - { - return ( FAIL ); - } - - - /* - * Test named Mutexes with ordinary string - */ - - if (!TestNamedMutex(szMutex)) - { - bFailures = TRUE; - } - - - /* - * Test named Mutexes with empty ("") string - */ - - if (!TestNamedMutex(szEmpty)) - { - bFailures = TRUE; - } - - - /* - * Test named Mutexes with string of length MAX_LONGPATH - */ - - szMaxPath = (char *)malloc(MAX_LONGPATH+2); - memset(szMaxPath, 'A', MAX_LONGPATH-60); - szMaxPath[MAX_LONGPATH-60] = 0; - - if (!TestNamedMutex(szMaxPath)) - { - bFailures = TRUE; - } - - free(szMaxPath); - - - /* - * Run some negative tests on ReleaseMutex - */ - - if (!NegativeReleaseMutexTests()) - { - bFailures = TRUE; - } - - - /* - * If there were any failures, then abort with a call to Fail - */ - - if (bFailures == TRUE) - { - Fail("ERROR: There some failures in the Mutex tests.\n"); - } - - PAL_Terminate(); - return ( PASS ); -} - - -/* - * Testing Function - * - * Try to get multiple handles to a named Mutex and test - * to make sure they actually refer to same Mutex object. - */ -BOOL TestNamedMutex(const char *szMutexName) -{ - DWORD dwData; - HANDLE hMutex1; - HANDLE hMutex2; - HANDLE hThread; - WCHAR *swzMutexName; - THREADDATA threadData; - - /* Convert the Mutex name to wide characters */ - swzMutexName = convert((char *)szMutexName); - - /* Create a mutex and take ownership immediately */ - hMutex1 = CreateMutexW (NULL, TRUE, swzMutexName); - - if (NULL == hMutex1) - { - Trace("ERROR: CreateMutex #1 failed. GetLastError returned %u\n", - GetLastError()); - free(swzMutexName); - return FALSE; - } - - /* Try to wait on the Mutex we just created. We should not block. */ - if (WaitForSingleObject(hMutex1, 1000) == WAIT_TIMEOUT) - { - Trace("WaitForSingleObject blocked on a Mutex that we owned.\n"); - free(swzMutexName); - return FALSE; - } - /* We have to call ReleaseMutex here because of the Wait */ - if (ReleaseMutex(hMutex1) == FALSE) - { - Trace("ReleaseMutex Failed.\n"); - return FALSE; - } - - /* Get a second handle to the same mutex */ - hMutex2 = CreateMutexW (NULL, FALSE, swzMutexName); - - if (NULL == hMutex2) - { - Trace("ERROR: CreateMutex #2 failed. GetLastError returned %u\n", - GetLastError()); - free(swzMutexName); - return FALSE; - } - - /* Get rid of the wide character string */ - free(swzMutexName); - - /* - * Create a thread that will Wait on the second handle. - */ - threadData.hMutex = hMutex2; - hThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)NamedMutexThread, - (LPVOID)&threadData, 0, &dwData); - - if (NULL == hThread) - { - Trace("ERROR: CreateThread failed. GetLastError returned %u\n", - GetLastError()); - return FALSE; - } - - /* Give the thread a little time to execute & wait*/ - Sleep(500); - - /* Signal the the first handle */ - if (ReleaseMutex(hMutex1) == FALSE) - { - Trace("ReleaseMutex Failed.\n"); - return FALSE; - } - - /* Give the thread some time to finish */ - Sleep(2000); - - /* Clean Up */ - if (CloseHandle(hMutex1) == FALSE || - CloseHandle(hMutex2) == FALSE || - CloseHandle(hThread) == FALSE) - { - Trace("ERROR: CloseHandle failed.\n"); - return FALSE; - } - - /* Check the return code to see if signalling the first */ - /* Mutex handle woke up the thread which was Waiting on */ - /* the second handle. */ - if (threadData.bReturnCode != FALSE) - { - Trace("ERROR: The handles did not refer to the same Mutex object.\n"); - return FALSE; - } - - return TRUE; -} - - -/* - * Thread function used with above testing function. - */ -DWORD NamedMutexThread(LPVOID lpParam) -{ - BOOL bTimedOut = FALSE; - THREADDATA *lpThreadData = (THREADDATA *)lpParam; - - /* Wait on the Mutex that was passed to us */ - if (WaitForSingleObject(lpThreadData->hMutex, 10000) == WAIT_TIMEOUT) - { - /* The Mutex was not signaled in the allotted time */ - bTimedOut = TRUE; - } - if (ReleaseMutex(lpThreadData->hMutex) == FALSE) - { - Trace("ERROR: ReleaseMutex failed.\n"); - lpThreadData->bReturnCode = FALSE; - return 0; - } - - /* Indicate whether we timed out Waiting on the Mutex */ - lpThreadData->bReturnCode = bTimedOut; - - return 0; -} - - -/* - * Testing Function - * - * Try some negative tests on ReleaseMutex - */ -BOOL NegativeReleaseMutexTests() -{ - HANDLE hMutex; - BOOL bRet; - BOOL bResults = TRUE; - - - /* - * Try calling ReleaseMutex on a null handle - */ - hMutex = 0; - bRet = ReleaseMutex(hMutex); - - if (bRet != 0) - { - Trace("Error: ReleaseMutex accepted null handle.\n"); - bResults = FALSE; - } - - - /* - * Try calling ReleaseMutex on an handle that we don't own - */ - hMutex = CreateMutexW (NULL, TRUE, NULL); - if (hMutex == 0) - { - Trace("Error: CreateMutex failed.\n"); - bResults = FALSE; - } - - bRet = ReleaseMutex(hMutex); - bRet = ReleaseMutex(hMutex); - - if (bRet != FALSE) - { - Trace("Error: ReleaseMutex accepted unowned handle.\n"); - bResults = FALSE; - } - - if (CloseHandle(hMutex) == FALSE) - { - Trace("Error: CloseHandle failed.\n"); - bResults = FALSE; - } - - - - /* - * Try calling ReleaseMutex on an handle that has been closed - */ - hMutex = CreateMutexW (NULL, TRUE, NULL); - if (hMutex == 0) - { - Trace("Error: CreateMutex failed.\n"); - bResults = FALSE; - } - - if (ReleaseMutex(hMutex) == FALSE) - { - Trace("Error: ReleaseMutex failed.\n"); - bResults = FALSE; - } - if (CloseHandle(hMutex) == FALSE) - { - Trace("Error: CloseHandle failed.\n"); - bResults = FALSE; - } - - bRet = ReleaseMutex(hMutex); - - if (bRet != FALSE) - { - Trace("Error: ReleaseMutex accepted invalid handle.\n"); - bResults = FALSE; - } - - return bResults; -} diff --git a/src/pal/tests/palsuite/threading/CreateMutexW_ReleaseMutex/test2/testinfo.dat b/src/pal/tests/palsuite/threading/CreateMutexW_ReleaseMutex/test2/testinfo.dat deleted file mode 100644 index c5769e3ad..000000000 --- a/src/pal/tests/palsuite/threading/CreateMutexW_ReleaseMutex/test2/testinfo.dat +++ /dev/null @@ -1,24 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = threading -Function = CreateMutexW / ReleaseMutex -Name = Basic validity Tests for CreateMutexW / ReleaseMutex -TYPE = DEFAULT -EXE1 = createmutexw -Description -= This test case tests the following things -= - Creation of named Mutexes -= - Creating multiple handles to a single named Mutex -= - Ensuring that these handles work interchangeably -= - Setting bInitialOwnerFlag to TRUE will cause the -= initial call to a Wait function on the same Mutex -= to actually wait. -= - Waiting on a Mutex that a thread already owns should -= not block. -= - Create Named mutex with empty string ("") -= - Create Named mutex with string of MAX_PATH length -= - Calling RelaseMutex with invalid Mutex handles and -= valid but unowned Mutexes. diff --git a/src/pal/tests/palsuite/threading/CreateProcessA/CMakeLists.txt b/src/pal/tests/palsuite/threading/CreateProcessA/CMakeLists.txt deleted file mode 100644 index ef14ea535..000000000 --- a/src/pal/tests/palsuite/threading/CreateProcessA/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) - diff --git a/src/pal/tests/palsuite/threading/CreateProcessA/test1/CMakeLists.txt b/src/pal/tests/palsuite/threading/CreateProcessA/test1/CMakeLists.txt deleted file mode 100644 index 32ef24243..000000000 --- a/src/pal/tests/palsuite/threading/CreateProcessA/test1/CMakeLists.txt +++ /dev/null @@ -1,32 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(TESTSOURCES - parentProcess.cpp -) - -add_executable(paltest_createprocessa_test1 - ${TESTSOURCES} -) - -add_dependencies(paltest_createprocessa_test1 coreclrpal) - -target_link_libraries(paltest_createprocessa_test1 - ${COMMON_TEST_LIBRARIES} -) - - -set(HELPERSOURCES - childProcess.cpp -) - -add_executable(paltest_createprocessa_test1_child - ${HELPERSOURCES} -) - -add_dependencies(paltest_createprocessa_test1_child coreclrpal) - -target_link_libraries(paltest_createprocessa_test1_child - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/CreateProcessA/test1/childProcess.cpp b/src/pal/tests/palsuite/threading/CreateProcessA/test1/childProcess.cpp deleted file mode 100644 index ccbb050c0..000000000 --- a/src/pal/tests/palsuite/threading/CreateProcessA/test1/childProcess.cpp +++ /dev/null @@ -1,131 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source: CreateProcessA/test1/childprocess.c -** -** Purpose: Test to ensure CreateProcessA starts a new process. This test -** launches a child process, and examines a file written by the child. -** This code is the child code. -** -** Dependencies: GetCurrentDirectory -** strlen -** fopen -** fclose -** fprintf -** - -** -**=========================================================*/ - -#include - -const char *szCommonFileA = "childdata.tmp"; - -const char *szPathDelimA = "\\"; - -const char *szCommonStringA = "058d2d057111a313aa82401c2e856002\0"; - -/* - * Take two wide strings representing file and directory names - * (dirName, fileName), join the strings with the appropriate path - * delimiter and populate a wide character buffer (absPathName) with - * the resulting string. - * - * Returns: The number of wide characters in the resulting string. - * 0 is returned on Error. - */ -int -mkAbsoluteFilenameA ( - LPSTR dirName, - DWORD dwDirLength, - LPCSTR fileName, - DWORD dwFileLength, - LPSTR absPathName ) -{ - extern const char *szPathDelimA; - - DWORD sizeDN, sizeFN, sizeAPN; - - sizeDN = strlen( dirName ); - sizeFN = strlen( fileName ); - sizeAPN = (sizeDN + 1 + sizeFN + 1); - - /* insure ((dirName + DELIM + fileName + \0) =< _MAX_PATH ) */ - if ( sizeAPN > _MAX_PATH ) - { - return ( 0 ); - } - - strncpy(absPathName, dirName, dwDirLength +1); - strncpy(absPathName, szPathDelimA, 2); - strncpy(absPathName, fileName, dwFileLength +1); - - return (sizeAPN); - -} - -int __cdecl main( int argc, char **argv ) -{ - - static FILE * fp; - - DWORD dwFileLength; - DWORD dwDirLength; - DWORD dwSize; - - char szDirNameA[_MAX_DIR]; - char szAbsPathNameA[_MAX_PATH]; - - if(0 != (PAL_Initialize(argc, argv))) - { - return ( FAIL ); - } - - dwDirLength = GetCurrentDirectory( _MAX_PATH, szDirNameA ); - - if (0 == dwDirLength) - { - Fail ("GetCurrentDirectory call failed. Could not get " - "current working directory\n. Exiting.\n"); - } - - dwFileLength = strlen( szCommonFileA ); - - dwSize = mkAbsoluteFilenameA( szDirNameA, dwDirLength, szCommonFileA, - dwFileLength, szAbsPathNameA ); - - if (0 == dwSize) - { - Fail ("Palsuite Code: mkAbsoluteFilename() call failed. Could " - "not build absolute path name to file\n. Exiting.\n"); - } - - if ( NULL == ( fp = fopen ( szAbsPathNameA , "w+" ) ) ) - { - /* - * A return value of NULL indicates an error condition or an - * EOF condition - */ - Fail ("%s unable to open %s for writing. Exiting.\n", argv[0] - , szAbsPathNameA ); - } - - if ( 0 >= ( fprintf ( fp, "%s", szCommonStringA ))) - { - Fail("%s unable to write to %s. Exiting.\n", argv[0] - , szAbsPathNameA ); - } - - if (0 != (fclose ( fp ))) - { - Fail ("%s unable to close file %s. Pid may not be " - "written to file. Exiting.\n", argv[0], szAbsPathNameA ); - } - - PAL_Terminate(); - return ( PASS ); - -} diff --git a/src/pal/tests/palsuite/threading/CreateProcessA/test1/parentProcess.cpp b/src/pal/tests/palsuite/threading/CreateProcessA/test1/parentProcess.cpp deleted file mode 100644 index b0c5808a7..000000000 --- a/src/pal/tests/palsuite/threading/CreateProcessA/test1/parentProcess.cpp +++ /dev/null @@ -1,201 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source: CreateProcessA/test1/parentprocess.c -** -** Purpose: Test to ensure CreateProcessA starts a new process. This test -** launches a child process, and examines a file written by the child. -** This process (the parent process) reads the file created by the child and -** compares the value the child wrote to the file. (a const char *) -** -** Dependencies: GetCurrentDirectory -** strlen -** WaitForSingleObject -** fopen -** fclose -** Fail -** - -** -**=========================================================*/ - -#include - -const char *szCommonFileA = "childdata.tmp"; - -const char *szChildFileA = "paltest_createprocessa_test1_child"; - -const char *szPathDelimA = "\\"; - -const char *szCommonStringA = "058d2d057111a313aa82401c2e856002\0"; - -/* - * Take two wide strings representing file and directory names - * (dirName, fileName), join the strings with the appropriate path - * delimiter and populate a wide character buffer (absPathName) with - * the resulting string. - * - * Returns: The number of wide characters in the resulting string. - * 0 is returned on Error. - */ -int -mkAbsoluteFilenameA ( - LPSTR dirName, - DWORD dwDirLength, - LPCSTR fileName, - DWORD dwFileLength, - LPSTR absPathName ) -{ - extern const char *szPathDelimA; - - DWORD sizeDN, sizeFN, sizeAPN; - - sizeDN = strlen( dirName ); - sizeFN = strlen( fileName ); - sizeAPN = (sizeDN + 1 + sizeFN + 1); - - /* insure ((dirName + DELIM + fileName + \0) =< _MAX_PATH ) */ - if ( sizeAPN > _MAX_PATH ) - { - return ( 0 ); - } - - strncpy(absPathName, dirName, dwDirLength +1); - strncpy(absPathName, szPathDelimA, 2); - strncpy(absPathName, fileName, dwFileLength +1); - - return (sizeAPN); - -} - -int __cdecl main( int argc, char **argv ) - -{ - - STARTUPINFO si; - PROCESS_INFORMATION pi; - - static FILE * fp; - - DWORD dwFileLength; - DWORD dwDirLength; - DWORD dwSize; - - size_t cslen; - - char szReadStringA[256]; - - char szDirNameA[_MAX_DIR]; - char absPathBuf[_MAX_PATH]; - char *szAbsPathNameA; - - - if(0 != (PAL_Initialize(argc, argv))) - { - return ( FAIL ); - } - - ZeroMemory ( &si, sizeof(si) ); - si.cb = sizeof(si); - ZeroMemory ( &pi, sizeof(pi) ); - - szAbsPathNameA=&absPathBuf[0]; - dwFileLength = strlen( szChildFileA ); - - dwDirLength = GetCurrentDirectory(_MAX_PATH, szDirNameA); - - if (0 == dwDirLength) - { - Fail ("GetCurrentDirectory call failed. Could not get " - "current working directory\n. Exiting.\n"); - } - - dwSize = mkAbsoluteFilenameA( szDirNameA, dwDirLength, szChildFileA, - dwFileLength, szAbsPathNameA ); - - if (0 == dwSize) - { - Fail ("Palsuite Code: mkAbsoluteFilename() call failed. Could " - "not build absolute path name to file\n. Exiting.\n"); - } - - if ( !CreateProcessA ( NULL, - szAbsPathNameA, - NULL, - NULL, - FALSE, - CREATE_NEW_CONSOLE, - NULL, - NULL, - &si, - &pi ) - ) - { - Fail ( "CreateProcess call failed. GetLastError returned %d\n", - GetLastError() ); - } - - WaitForSingleObject ( pi.hProcess, INFINITE ); - - szAbsPathNameA=&absPathBuf[0]; - - dwFileLength = strlen( szCommonFileA ); - - dwSize = mkAbsoluteFilenameA( szDirNameA, dwDirLength, szCommonFileA, - dwFileLength, szAbsPathNameA ); - - /* set the string length for the open call*/ - - if (0 == dwSize) - { - Fail ("Palsuite Code: mkAbsoluteFilename() call failed. Could " - "not build absolute path name to file\n. Exiting.\n"); - } - - if ( NULL == ( fp = fopen ( szAbsPathNameA , "r" ) ) ) - { - Fail ("%s\nunable to open %s\nfor reading. Exiting.\n", argv[0], - szAbsPathNameA ); - } - - cslen = strlen ( szCommonStringA ); - - if ( NULL == fgets( szReadStringA, (cslen + 1), fp )) - { - /* - * A return value of NULL indicates an error condition or an - * EOF condition - */ - Fail ("%s\nunable to read file\n%s\nszReadStringA is %s\n" - "Exiting.\n", argv[0], szAbsPathNameA, - szReadStringA ); - - } - if ( 0 != strncmp( szReadStringA, szCommonStringA, cslen )) - { - Fail ("string comparison failed.\n szReadStringA is %s and\n" - "szCommonStringA is %s\n", szReadStringA, - szCommonStringA ); - } - else - { - Trace ("string comparison passed.\n"); - } - - if (0 != (fclose ( fp ))) - { - Trace ("%s unable to close file %s. This may cause a file pointer " - "leak. Continuing.\n", argv[0], szAbsPathNameA ); - } - - /* Close process and thread handle */ - CloseHandle ( pi.hProcess ); - CloseHandle ( pi.hThread ); - - PAL_Terminate(); - return ( PASS ); - -} diff --git a/src/pal/tests/palsuite/threading/CreateProcessA/test1/testinfo.dat b/src/pal/tests/palsuite/threading/CreateProcessA/test1/testinfo.dat deleted file mode 100644 index 02c25444f..000000000 --- a/src/pal/tests/palsuite/threading/CreateProcessA/test1/testinfo.dat +++ /dev/null @@ -1,17 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = threading -Function = CreateProcessA -Name = Positive Test for CreateProcessA -TYPE = DEFAULT -EXE1 = parentprocess -EXE2 = childprocess -Description -= Test the CreateProcessA function. The test executes the childprocess -= program. The childprocess program launches and writes a const char string -= to a file childdata. The parent waits for the completion of childprocess -= and then reads the string from the childdata file. If the string in the -= file matches it's copy of the const char string, then the test succeeds. diff --git a/src/pal/tests/palsuite/threading/CreateProcessA/test2/CMakeLists.txt b/src/pal/tests/palsuite/threading/CreateProcessA/test2/CMakeLists.txt deleted file mode 100644 index 4f4bc850b..000000000 --- a/src/pal/tests/palsuite/threading/CreateProcessA/test2/CMakeLists.txt +++ /dev/null @@ -1,32 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(TESTSOURCES - parentprocess.cpp -) - -add_executable(paltest_createprocessa_test2 - ${TESTSOURCES} -) - -add_dependencies(paltest_createprocessa_test2 coreclrpal) - -target_link_libraries(paltest_createprocessa_test2 - ${COMMON_TEST_LIBRARIES} -) - - -set(HELPERSOURCES - childprocess.cpp -) - -add_executable(paltest_createprocessa_test2_child - ${HELPERSOURCES} -) - -add_dependencies(paltest_createprocessa_test2_child coreclrpal) - -target_link_libraries(paltest_createprocessa_test2_child - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/CreateProcessA/test2/childprocess.cpp b/src/pal/tests/palsuite/threading/CreateProcessA/test2/childprocess.cpp deleted file mode 100644 index baa20c2d3..000000000 --- a/src/pal/tests/palsuite/threading/CreateProcessA/test2/childprocess.cpp +++ /dev/null @@ -1,69 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source: createprocessa/test2/childprocess.c -** -** Purpose: This child process reads a string from stdin -** and writes it out to stdout & stderr -** -** Dependencies: memset -** fgets -** gputs -** - -** -**=========================================================*/ - -#include -#include "test2.h" - - - -int __cdecl main( int argc, char **argv ) -{ - int iRetCode = EXIT_OK_CODE; /* preset exit code to OK */ - char szBuf[BUF_LEN]; - - - if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - if (argc != 4) - { - return EXIT_ERR_CODE3; - } - - if (strcmp(argv[1], szArg1) != 0 - || strcmp(argv[2], szArg2) != 0 - || strcmp(argv[3], szArg3) != 0) - { - return EXIT_ERR_CODE4; - } - - - memset(szBuf, 0, BUF_LEN); - - /* Read the string that was written by the parent */ - if (fgets(szBuf, BUF_LEN, stdin) == NULL) - { - return EXIT_ERR_CODE1; - } - - /* Write the string out to the stdout & stderr pipes */ - if (fputs(szBuf, stdout) == EOF - || fputs(szBuf, stderr) == EOF) - { - return EXIT_ERR_CODE2; - } - - /* The exit code will indicate success or failure */ - PAL_TerminateEx(iRetCode); - - /* Return special exit code to indicate success or failure */ - return iRetCode; -} diff --git a/src/pal/tests/palsuite/threading/CreateProcessA/test2/parentprocess.cpp b/src/pal/tests/palsuite/threading/CreateProcessA/test2/parentprocess.cpp deleted file mode 100644 index ef3340c5d..000000000 --- a/src/pal/tests/palsuite/threading/CreateProcessA/test2/parentprocess.cpp +++ /dev/null @@ -1,243 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source: createprocessa/test2/parentprocess.c -** -** Purpose: Test the following features of CreateProcessA: -** - Check to see if hProcess & hThread are set in -** return PROCESS_INFORMATION structure -** - Check to see if stdin, stdout, & stderr handles -** are used when STARTF_USESTDHANDLES is specified -** in STARUPINFO flags and bInheritHandles = TRUE -** - Check to see that proper arguments are passed to -** child process -** -** Dependencies: CreatePipe -** strcpy, strlen, strncmp, memset -** WaitForSingleObject -** WriteFile, ReadFile -** GetExitCodeProcess -** - -** -**=========================================================*/ - -#include -#include "test2.h" - - - -int __cdecl main( int argc, char **argv ) -{ - - /******************************************* - * Declarations - *******************************************/ - STARTUPINFO si; - PROCESS_INFORMATION pi; - - HANDLE hTestStdInR = NULL; - HANDLE hTestStdInW = NULL; - HANDLE hTestStdOutR = NULL; - HANDLE hTestStdOutW = NULL; - HANDLE hTestStdErrR = NULL; - HANDLE hTestStdErrW = NULL; - - BOOL bRetVal = FALSE; - DWORD dwBytesWritten = 0; - DWORD dwBytesRead = 0; - DWORD dwExitCode = 0; - - SECURITY_ATTRIBUTES pipeAttributes; - - char szStdOutBuf[BUF_LEN]; - char szStdErrBuf[BUF_LEN]; - char szFullPathNameA[_MAX_PATH]; - - - /******************************************* - * Initialization - *******************************************/ - - if(0 != (PAL_Initialize(argc, argv))) - { - return ( FAIL ); - } - - /*Setup SECURITY_ATTRIBUTES structure for CreatePipe*/ - pipeAttributes.nLength = sizeof(SECURITY_ATTRIBUTES); - pipeAttributes.lpSecurityDescriptor = NULL; - pipeAttributes.bInheritHandle = TRUE; - - - /*Create a StdIn pipe for child*/ - bRetVal = CreatePipe(&hTestStdInR, /* read handle*/ - &hTestStdInW, /* write handle */ - &pipeAttributes, /* security attributes*/ - 1024); /* pipe size*/ - - if (bRetVal == FALSE) - { - Fail("ERROR: %ld :Unable to create stdin pipe\n", GetLastError()); - } - - - /*Create a StdOut pipe for child*/ - bRetVal = CreatePipe(&hTestStdOutR, /* read handle*/ - &hTestStdOutW, /* write handle */ - &pipeAttributes, /* security attributes*/ - 0); /* pipe size*/ - - if (bRetVal == FALSE) - { - Fail("ERROR: %ld :Unable to create stdout pipe\n", GetLastError()); - } - - - /*Create a StdErr pipe for child*/ - bRetVal = CreatePipe(&hTestStdErrR, /* read handle*/ - &hTestStdErrW, /* write handle */ - &pipeAttributes, /* security attributes*/ - 0); /* pipe size*/ - - if (bRetVal == FALSE) - { - Fail("ERROR: %ld :Unable to create stderr pipe\n", GetLastError()); - } - - /* Zero the data structure space */ - ZeroMemory ( &pi, sizeof(pi) ); - ZeroMemory ( &si, sizeof(si) ); - - /* Set the process flags and standard io handles */ - si.cb = sizeof(si); - si.dwFlags = STARTF_USESTDHANDLES; - si.hStdInput = hTestStdInR; - si.hStdOutput = hTestStdOutW; - si.hStdError = hTestStdErrW; - - strcpy(szFullPathNameA, szChildFileA); - strcat(szFullPathNameA, szArgs); - - /******************************************* - * Start Testing - *******************************************/ - - /* Launch the child */ - if ( !CreateProcessA (NULL, szFullPathNameA, NULL, NULL, TRUE, 0, NULL, NULL, &si, &pi )) - { - Fail("ERROR: CreateProcess call failed. GetLastError returned %d\n", - GetLastError() ); - } - - /* Check the returned process information for validity */ - if (pi.hProcess == 0 || pi.hThread == 0) - { - Fail("ERROR: CreateProcess Error: Process Handle = %u, Thread Handle = %u\n", - pi.hProcess, pi.hThread); - } - - /* Write the Constructed string to stdin pipe for the child process */ - if (WriteFile(hTestStdInW, szTestString, strlen(szTestString), &dwBytesWritten, NULL) == FALSE - || WriteFile(hTestStdInW, "\n", strlen("\n"), &dwBytesWritten, NULL) == FALSE) - { - Fail("ERROR: %ld :unable to write to write pipe handle " - "hTestStdInW=0x%lx\n", GetLastError(), hTestStdInW); - } - - /* Wait for the child to finish, Max 20 seconds */ - dwExitCode = WaitForSingleObject(pi.hProcess, 20000); - - /* If the child failed then whole thing fails */ - if (dwExitCode != WAIT_OBJECT_0) - { - TerminateProcess(pi.hProcess, 0); - Fail("ERROR: The child failed to run properly.\n"); - } - - /* Check for problems in the child process */ - if (GetExitCodeProcess(pi.hProcess, &dwExitCode) == FALSE) - { - Fail("ERROR: Call to GetExitCodeProcess failed.\n"); - } - else if (dwExitCode == EXIT_ERR_CODE1) - { - Fail("ERROR: The Child process could not reead the string " - "written to the stdin pipe.\n"); - } - else if (dwExitCode == EXIT_ERR_CODE2) - { - Fail("ERROR: The Child process could not write the string " - "the stdout pipe or stderr pipe.\n"); - } - else if (dwExitCode == EXIT_ERR_CODE3) - { - Fail("ERROR: The Child received the wrong number of " - "command line arguments.\n"); - } - else if (dwExitCode == EXIT_ERR_CODE4) - { - Fail("ERROR: The Child received the wrong " - "command line arguments.\n"); - } - else if (dwExitCode != EXIT_OK_CODE) - { - Fail("ERROR: Unexpected exit code returned: %u. Child process " - "did not complete its part of the test.\n", dwExitCode); - } - - - /* The child ran ok, so check to see if we received the proper */ - /* strings through the pipes. */ - - /* clear our buffers */ - memset(szStdOutBuf, 0, BUF_LEN); - memset(szStdErrBuf, 0, BUF_LEN); - - /* Read the data back from the child process stdout */ - bRetVal = ReadFile(hTestStdOutR, /* handle to read pipe*/ - szStdOutBuf, /* buffer to write to*/ - BUF_LEN, /* number of bytes to read*/ - &dwBytesRead, /* number of bytes read*/ - NULL); /* overlapped buffer*/ - - /*Read the data back from the child process stderr */ - bRetVal = ReadFile(hTestStdErrR, /* handle to read pipe*/ - szStdErrBuf, /* buffer to write to*/ - BUF_LEN, /* number of bytes to read*/ - &dwBytesRead, /* number of bytes read*/ - NULL); /* overlapped buffer*/ - - - /* Confirm that we recieved the same string that we originally */ - /* wrote to the child and was received on both stdout & stderr.*/ - if (strncmp(szTestString, szStdOutBuf, strlen(szTestString)) != 0 - || strncmp(szTestString, szStdErrBuf, strlen(szTestString)) != 0) - { - Fail("ERROR: The data read back from child does not match " - "what was written. STDOUT: %s STDERR: %s\n", - szStdOutBuf, szStdErrBuf); - } - - - /******************************************* - * Clean Up - *******************************************/ - - /* Close process and thread handle */ - CloseHandle ( pi.hProcess ); - CloseHandle ( pi.hThread ); - - CloseHandle(hTestStdInR); - CloseHandle(hTestStdInW); - CloseHandle(hTestStdOutR); - CloseHandle(hTestStdOutW); - CloseHandle(hTestStdErrR); - CloseHandle(hTestStdErrW); - - PAL_Terminate(); - return ( PASS ); -} diff --git a/src/pal/tests/palsuite/threading/CreateProcessA/test2/test2.h b/src/pal/tests/palsuite/threading/CreateProcessA/test2/test2.h deleted file mode 100644 index 8cdff3b93..000000000 --- a/src/pal/tests/palsuite/threading/CreateProcessA/test2/test2.h +++ /dev/null @@ -1,72 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source: test2.h -** - -** -**===========================================================*/ - - -const char *szChildFileA = "paltest_createprocessa_test2_child"; -const char *szArgs = " A B C"; -const char *szArg1 = "A"; -const char *szArg2 = "B"; -const char *szArg3 = "C"; - -const char *szPathDelimA = "\\"; - -const char *szTestString = "Copyright (c) Microsoft"; - -const DWORD EXIT_OK_CODE = 100; -const DWORD EXIT_ERR_CODE1 = 101; -const DWORD EXIT_ERR_CODE2 = 102; -const DWORD EXIT_ERR_CODE3 = 103; -const DWORD EXIT_ERR_CODE4 = 104; -const DWORD EXIT_ERR_CODE5 = 105; - -#define BUF_LEN 64 - -/* - * Take two wide strings representing file and directory names - * (dirName, fileName), join the strings with the appropriate path - * delimiter and populate a wide character buffer (absPathName) with - * the resulting string. - * - * Returns: The number of wide characters in the resulting string. - * 0 is returned on Error. - */ -int -mkAbsoluteFilenameA ( - LPSTR dirName, - DWORD dwDirLength, - LPCSTR fileName, - DWORD dwFileLength, - LPSTR absPathName ) -{ - extern const char *szPathDelimA; - - DWORD sizeDN; - DWORD sizeFN; - DWORD sizeAPN; - - sizeDN = strlen( dirName ); - sizeFN = strlen( fileName ); - sizeAPN = (sizeDN + 1 + sizeFN + 1); - - /* insure ((dirName + DELIM + fileName + \0) =< _MAX_PATH ) */ - if ( sizeAPN > _MAX_PATH ) - { - return ( 0 ); - } - - strncpy(absPathName, dirName, dwDirLength +1); - strcat(absPathName, szPathDelimA); - strcat(absPathName, fileName); - - return (sizeAPN); - -} diff --git a/src/pal/tests/palsuite/threading/CreateProcessA/test2/testinfo.dat b/src/pal/tests/palsuite/threading/CreateProcessA/test2/testinfo.dat deleted file mode 100644 index 23fcdf93a..000000000 --- a/src/pal/tests/palsuite/threading/CreateProcessA/test2/testinfo.dat +++ /dev/null @@ -1,20 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = threading -Function = CreateProcessA -Name = PROCESS_INFORMATION and HANDLE Inheritance -TYPE = DEFAULT -EXE1 = parentprocess -EXE2 = childprocess -Description -= Test the following features of CreateProcessA: -= - Check to see if hProcess & hThread are set in -= return PROCESS_INFORMATION structure -= - Check to see if stdin, stdout, & stderr handles -= are used when STARTF_USESTDHANDLES is specified -= in STARUPINFO flags and bInheritHandles = TRUE -= - Check to see that proper arguments are passed to -= child process diff --git a/src/pal/tests/palsuite/threading/CreateProcessW/CMakeLists.txt b/src/pal/tests/palsuite/threading/CreateProcessW/CMakeLists.txt deleted file mode 100644 index ef14ea535..000000000 --- a/src/pal/tests/palsuite/threading/CreateProcessW/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) - diff --git a/src/pal/tests/palsuite/threading/CreateProcessW/test1/CMakeLists.txt b/src/pal/tests/palsuite/threading/CreateProcessW/test1/CMakeLists.txt deleted file mode 100644 index a5a0ca8b0..000000000 --- a/src/pal/tests/palsuite/threading/CreateProcessW/test1/CMakeLists.txt +++ /dev/null @@ -1,32 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(TESTSOURCES - parentProcess.cpp -) - -add_executable(paltest_createprocessw_test1 - ${TESTSOURCES} -) - -add_dependencies(paltest_createprocessw_test1 coreclrpal) - -target_link_libraries(paltest_createprocessw_test1 - ${COMMON_TEST_LIBRARIES} -) - - -set(HELPERSOURCES - childProcess.cpp -) - -add_executable(paltest_createprocessw_test1_child - ${HELPERSOURCES} -) - -add_dependencies(paltest_createprocessw_test1_child coreclrpal) - -target_link_libraries(paltest_createprocessw_test1_child - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/CreateProcessW/test1/childProcess.cpp b/src/pal/tests/palsuite/threading/CreateProcessW/test1/childProcess.cpp deleted file mode 100644 index a7730c6d5..000000000 --- a/src/pal/tests/palsuite/threading/CreateProcessW/test1/childProcess.cpp +++ /dev/null @@ -1,150 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source: CreateProcessW/test1/childprocess.c -** -** Purpose: Test to ensure CreateProcessW starts a new process. This test -** launches a child process, and examines a file written by the child. -** This code is the child code. -** -** Dependencies: GetCurrentDirectory -** MultiByteToWideChar -** wcslen -** strlen -** WideCharToMultiByte -** fopen -** fclose -** fprintf -** - -** -**=========================================================*/ - -#define UNICODE -#include - -const WCHAR szCommonFileW[] = - {'c','h','i','l','d','d','a','t','a','.','t','m','p','\0'}; - -const WCHAR szPathDelimW[] = {'\\','\0'}; - -const char *szCommonStringA = "058d2d057111a313aa82401c2e856002\0"; - -/* - * Take two wide strings representing file and directory names - * (dirName, fileName), join the strings with the appropriate path - * delimiter and populate a wide character buffer (absPathName) with - * the resulting string. - * - * Returns: The number of wide characters in the resulting string. - * 0 is returned on Error. - */ -int -mkAbsoluteFilenameW ( - LPWSTR dirName, - DWORD dwDirLength, - LPCWSTR fileName, - DWORD dwFileLength, - LPWSTR absPathName ) -{ - extern const WCHAR szPathDelimW[]; - - DWORD sizeDN, sizeFN, sizeAPN; - - sizeDN = wcslen( dirName ); - sizeFN = wcslen( fileName ); - sizeAPN = (sizeDN + 1 + sizeFN + 1); - - /* insure ((dirName + DELIM + fileName + \0) =< _MAX_PATH ) */ - if ( sizeAPN > _MAX_PATH ) - { - return ( 0 ); - } - - wcsncpy(absPathName, dirName, dwDirLength +1); - wcsncpy(absPathName, szPathDelimW, 2); - wcsncpy(absPathName, fileName, dwFileLength +1); - - return (sizeAPN); - -} - -int __cdecl main( int argc, char **argv ) -{ - - static FILE * fp; - - DWORD dwFileLength; - DWORD dwDirLength; - DWORD dwSize; - - char *szAbsPathNameA; - WCHAR szDirNameW[_MAX_DIR]; - WCHAR szAbsPathNameW[_MAX_PATH]; - - if(0 != (PAL_Initialize(argc, argv))) - { - return ( FAIL ); - } - - dwDirLength = GetCurrentDirectory( _MAX_PATH, szDirNameW ); - - if (0 == dwDirLength) - { - Fail ("GetCurrentDirectory call failed. Could not get " - "current working directory\n. Exiting.\n"); - } - - dwFileLength = wcslen( szCommonFileW ); - - dwSize = mkAbsoluteFilenameW( szDirNameW, dwDirLength, szCommonFileW, - dwFileLength, szAbsPathNameW ); - - if (0 == dwSize) - { - Fail ("Palsuite Code: mkAbsoluteFilename() call failed. Could " - "not build absolute path name to file\n. Exiting.\n"); - } - - /* set the string length for the open call */ - szAbsPathNameA = (char*)malloc(dwSize +1); - - if (NULL == szAbsPathNameA) - { - Fail ("Unable to malloc (%d) bytes. Exiting\n", (dwSize +1) ); - } - - WideCharToMultiByte (CP_ACP, 0, szAbsPathNameW, -1, szAbsPathNameA, - (dwSize + 1), NULL, NULL); - - if ( NULL == ( fp = fopen ( szAbsPathNameA , "w+" ) ) ) - { - /* - * A return value of NULL indicates an error condition or an - * EOF condition - */ - Fail ("%s unable to open %s for writing. Exiting.\n", argv[0] - , szAbsPathNameA ); - } - - free (szAbsPathNameA); - - if ( 0 >= ( fprintf ( fp, "%s", szCommonStringA ))) - { - Fail("%s unable to write to %s. Exiting.\n", argv[0] - , szAbsPathNameA ); - } - - if (0 != (fclose ( fp ))) - { - Fail ("%s unable to close file %s. Pid may not be " - "written to file. Exiting.\n", argv[0], szAbsPathNameA ); - } - - PAL_Terminate(); - return ( PASS ); - -} diff --git a/src/pal/tests/palsuite/threading/CreateProcessW/test1/parentProcess.cpp b/src/pal/tests/palsuite/threading/CreateProcessW/test1/parentProcess.cpp deleted file mode 100644 index db1fb6356..000000000 --- a/src/pal/tests/palsuite/threading/CreateProcessW/test1/parentProcess.cpp +++ /dev/null @@ -1,210 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source: CreateProcessW/test1/parentprocess.c -** -** Purpose: Test to ensure CreateProcessW starts a new process. This test -** launches a child process, and examines a file written by the child. -** This process (the parent process) reads the file created by the child and -** compares the value the child wrote to the file. (a const char *) -** -** Dependencies: GetCurrentDirectory -** MultiByteToWideChar -** wcslen -** strlen -** WideCharToMultiByte -** WaitForSingleObject -** fopen -** fclose -** Fail -** - -** -**=========================================================*/ - -#define UNICODE -#include - -const WCHAR szCommonFileW[] = - {'c','h','i','l','d','d','a','t','a','.','t','m','p','\0'}; - -const WCHAR szChildFileW[] = u"paltest_createprocessw_test1_child"; - -const WCHAR szPathDelimW[] = {'\\','\0'}; - -const char *szCommonStringA = "058d2d057111a313aa82401c2e856002\0"; - -/* - * Take two wide strings representing file and directory names - * (dirName, fileName), join the strings with the appropriate path - * delimiter and populate a wide character buffer (absPathName) with - * the resulting string. - * - * Returns: The number of wide characters in the resulting string. - * 0 is returned on Error. - */ -int -mkAbsoluteFilenameW ( - LPWSTR dirName, - DWORD dwDirLength, - LPCWSTR fileName, - DWORD dwFileLength, - LPWSTR absPathName ) -{ - extern const WCHAR szPathDelimW[]; - - DWORD sizeDN, sizeFN, sizeAPN; - - sizeDN = wcslen( dirName ); - sizeFN = wcslen( fileName ); - sizeAPN = (sizeDN + 1 + sizeFN + 1); - - /* insure ((dirName + DELIM + fileName + \0) =< _MAX_PATH ) */ - if ( sizeAPN > _MAX_PATH ) - { - return ( 0 ); - } - - wcsncpy(absPathName, dirName, dwDirLength +1); - wcsncpy(absPathName, szPathDelimW, 2); - wcsncpy(absPathName, fileName, dwFileLength +1); - - return (sizeAPN); - -} - -int __cdecl main( int argc, char **argv ) - -{ - - STARTUPINFOW si; - PROCESS_INFORMATION pi; - - static FILE * fp; - - DWORD dwFileLength; - DWORD dwDirLength; - DWORD dwSize; - - size_t cslen; - - char szReadStringA[256]; - - char szAbsPathNameA[_MAX_PATH]; - WCHAR szDirNameW[_MAX_DIR]; - WCHAR absPathBuf[_MAX_PATH]; - WCHAR *szAbsPathNameW; - - - if(0 != (PAL_Initialize(argc, argv))) - { - return ( FAIL ); - } - - ZeroMemory ( &si, sizeof(si) ); - si.cb = sizeof(si); - ZeroMemory ( &pi, sizeof(pi) ); - - szAbsPathNameW=&absPathBuf[0]; - dwFileLength = wcslen( szChildFileW ); - - dwDirLength = GetCurrentDirectory(_MAX_PATH, szDirNameW); - - if (0 == dwDirLength) - { - Fail ("GetCurrentDirectory call failed. Could not get " - "current working directory\n. Exiting.\n"); - } - - dwSize = mkAbsoluteFilenameW( szDirNameW, dwDirLength, szChildFileW, - dwFileLength, szAbsPathNameW ); - - if (0 == dwSize) - { - Fail ("Palsuite Code: mkAbsoluteFilename() call failed. Could " - "not build absolute path name to file\n. Exiting.\n"); - } - - if ( !CreateProcessW ( NULL, - szAbsPathNameW, - NULL, - NULL, - FALSE, - CREATE_NEW_CONSOLE, - NULL, - NULL, - &si, - &pi ) - ) - { - Fail ( "CreateProcess call failed. GetLastError returned %d\n", - GetLastError() ); - } - - WaitForSingleObject ( pi.hProcess, INFINITE ); - - szAbsPathNameW=&absPathBuf[0]; - - dwFileLength = wcslen( szCommonFileW ); - - dwSize = mkAbsoluteFilenameW( szDirNameW, dwDirLength, szCommonFileW, - dwFileLength, szAbsPathNameW ); - - /* set the string length for the open call*/ - - if (0 == dwSize) - { - Fail ("Palsuite Code: mkAbsoluteFilename() call failed. Could " - "not build absolute path name to file\n. Exiting.\n"); - } - - WideCharToMultiByte (CP_ACP, 0, szAbsPathNameW, -1, szAbsPathNameA, - (dwSize + 1), NULL, NULL); - - if ( NULL == ( fp = fopen ( szAbsPathNameA , "r" ) ) ) - { - Fail ("%s\nunable to open %s\nfor reading. Exiting.\n", argv[0], - szAbsPathNameA ); - } - - cslen = strlen ( szCommonStringA ); - - if ( NULL == fgets( szReadStringA, (cslen + 1), fp )) - { - /* - * A return value of NULL indicates an error condition or an - * EOF condition - */ - Fail ("%s\nunable to read file\n%s\nszReadStringA is %s\n" - "Exiting.\n", argv[0], szAbsPathNameA, - szReadStringA ); - } - - if ( 0 != strncmp( szReadStringA, szCommonStringA, cslen )) - { - Fail ("string comparison failed.\n szReadStringA is %s and\n" - "szCommonStringA is %s\n", szReadStringA, - szCommonStringA ); - } - else - { - Trace ("string comparison passed.\n"); - } - - if (0 != (fclose ( fp ))) - { - Trace ("%s unable to close file %s. This may cause a file pointer " - "leak. Continuing.\n", argv[0], szAbsPathNameA ); - } - - /* Close process and thread handle */ - CloseHandle ( pi.hProcess ); - CloseHandle ( pi.hThread ); - - PAL_Terminate(); - return ( PASS ); - -} diff --git a/src/pal/tests/palsuite/threading/CreateProcessW/test1/testinfo.dat b/src/pal/tests/palsuite/threading/CreateProcessW/test1/testinfo.dat deleted file mode 100644 index 2acf2c928..000000000 --- a/src/pal/tests/palsuite/threading/CreateProcessW/test1/testinfo.dat +++ /dev/null @@ -1,17 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = threading -Function = CreateProcessW -Name = Positive Test for CreateProcessW -TYPE = DEFAULT -EXE1 = parentprocess -EXE2 = childprocess -Description -= Test the CreateProcessW function. The test executes the childprocess -= program. The childprocess program launches and writes a const char string -= to a file childdata. The parent waits for the completion of childprocess -= and then reads the string from the childdata file. If the string in the -= file matches it's copy of the const char string, then the test succeeds. diff --git a/src/pal/tests/palsuite/threading/CreateProcessW/test2/CMakeLists.txt b/src/pal/tests/palsuite/threading/CreateProcessW/test2/CMakeLists.txt deleted file mode 100644 index f32924b8b..000000000 --- a/src/pal/tests/palsuite/threading/CreateProcessW/test2/CMakeLists.txt +++ /dev/null @@ -1,32 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(TESTSOURCES - parentprocess.cpp -) - -add_executable(paltest_createprocessw_test2 - ${TESTSOURCES} -) - -add_dependencies(paltest_createprocessw_test2 coreclrpal) - -target_link_libraries(paltest_createprocessw_test2 - ${COMMON_TEST_LIBRARIES} -) - - -set(HELPERSOURCES - childprocess.cpp -) - -add_executable(paltest_createprocessw_test2_child - ${HELPERSOURCES} -) - -add_dependencies(paltest_createprocessw_test2_child coreclrpal) - -target_link_libraries(paltest_createprocessw_test2_child - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/CreateProcessW/test2/childprocess.cpp b/src/pal/tests/palsuite/threading/CreateProcessW/test2/childprocess.cpp deleted file mode 100644 index b4ab9366d..000000000 --- a/src/pal/tests/palsuite/threading/CreateProcessW/test2/childprocess.cpp +++ /dev/null @@ -1,78 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source: createprocessw/test2/childprocess.c -** -** Purpose: This child process reads a string from stdin -** and writes it out to stdout & stderr -** -** Dependencies: memset -** fgets -** gputs -** - -** -**=========================================================*/ - -#define UNICODE -#include -#include "test2.h" - - -int __cdecl main( int argc, char **argv ) -{ - int iRetCode = EXIT_OK_CODE; /* preset exit code to OK */ - char szBuf[BUF_LEN]; - - WCHAR *swzParam1, *swzParam2, *swzParam3 = NULL; - - - if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - if (argc != 4) - { - return EXIT_ERR_CODE3; - } - - swzParam1 = convert(argv[1]); - swzParam2 = convert(argv[2]); - swzParam3 = convert(argv[3]); - - if (wcscmp(swzParam1, szArg1) != 0 - || wcscmp(swzParam2, szArg2) != 0 - || wcscmp(swzParam3, szArg3) != 0) - { - return EXIT_ERR_CODE4; - } - - free(swzParam1); - free(swzParam2); - free(swzParam3); - - memset(szBuf, 0, BUF_LEN); - - /* Read the string that was written by the parent */ - if (fgets(szBuf, BUF_LEN, stdin) == NULL) - { - return EXIT_ERR_CODE1; - } - - - /* Write the string out to the stdout & stderr pipes */ - if (fputs(szBuf, stdout) == EOF - || fputs(szBuf, stderr) == EOF) - { - return EXIT_ERR_CODE2; - } - - /* The exit code will indicate success or failure */ - PAL_TerminateEx(iRetCode); - - /* Return special exit code to indicate success or failure */ - return iRetCode; -} diff --git a/src/pal/tests/palsuite/threading/CreateProcessW/test2/parentprocess.cpp b/src/pal/tests/palsuite/threading/CreateProcessW/test2/parentprocess.cpp deleted file mode 100644 index 439b7b5ee..000000000 --- a/src/pal/tests/palsuite/threading/CreateProcessW/test2/parentprocess.cpp +++ /dev/null @@ -1,245 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source: createprocessw/test2/parentprocess.c -** -** Purpose: Test the following features of CreateProcessW: -** - Check to see if hProcess & hThread are set in -** return PROCESS_INFORMATION structure -** - Check to see if stdin, stdout, & stderr handles -** are used when STARTF_USESTDHANDLES is specified -** in STARUPINFO flags and bInheritHandles = TRUE -** - Check to see that proper arguments are passed to -** child process -** -** Dependencies: CreatePipe -** strcpy, strlen, strncmp, memset -** WaitForSingleObject -** WriteFile, ReadFile -** GetExitCodeProcess -** - -** -**=========================================================*/ - -#define UNICODE -#include -#include "test2.h" - - - -int __cdecl main( int argc, char **argv ) -{ - - /******************************************* - * Declarations - *******************************************/ - STARTUPINFO si; - PROCESS_INFORMATION pi; - - HANDLE hTestStdInR = NULL; - HANDLE hTestStdInW = NULL; - HANDLE hTestStdOutR = NULL; - HANDLE hTestStdOutW = NULL; - HANDLE hTestStdErrR = NULL; - HANDLE hTestStdErrW = NULL; - - BOOL bRetVal = FALSE; - DWORD dwBytesWritten = 0; - DWORD dwBytesRead = 0; - DWORD dwExitCode = 0; - - SECURITY_ATTRIBUTES pipeAttributes; - - char szStdOutBuf[BUF_LEN]; - char szStdErrBuf[BUF_LEN]; - WCHAR szFullPathNameW[_MAX_PATH]; - - - /******************************************* - * Initialization - *******************************************/ - - if(0 != (PAL_Initialize(argc, argv))) - { - return ( FAIL ); - } - - /*Setup SECURITY_ATTRIBUTES structure for CreatePipe*/ - pipeAttributes.nLength = sizeof(SECURITY_ATTRIBUTES); - pipeAttributes.lpSecurityDescriptor = NULL; - pipeAttributes.bInheritHandle = TRUE; - - - /*Create a StdIn pipe for child*/ - bRetVal = CreatePipe(&hTestStdInR, /* read handle*/ - &hTestStdInW, /* write handle */ - &pipeAttributes, /* security attributes*/ - 1024); /* pipe size*/ - - if (bRetVal == FALSE) - { - Fail("ERROR: %ld :Unable to create stdin pipe\n", GetLastError()); - } - - - /*Create a StdOut pipe for child*/ - bRetVal = CreatePipe(&hTestStdOutR, /* read handle*/ - &hTestStdOutW, /* write handle */ - &pipeAttributes, /* security attributes*/ - 0); /* pipe size*/ - - if (bRetVal == FALSE) - { - Fail("ERROR: %ld :Unable to create stdout pipe\n", GetLastError()); - } - - - /*Create a StdErr pipe for child*/ - bRetVal = CreatePipe(&hTestStdErrR, /* read handle*/ - &hTestStdErrW, /* write handle */ - &pipeAttributes, /* security attributes*/ - 0); /* pipe size*/ - - if (bRetVal == FALSE) - { - Fail("ERROR: %ld :Unable to create stderr pipe\n", GetLastError()); - } - - /* Zero the data structure space */ - ZeroMemory ( &pi, sizeof(pi) ); - ZeroMemory ( &si, sizeof(si) ); - - /* Set the process flags and standard io handles */ - si.cb = sizeof(si); - si.dwFlags = STARTF_USESTDHANDLES; - si.hStdInput = hTestStdInR; - si.hStdOutput = hTestStdOutW; - si.hStdError = hTestStdErrW; - - wcscpy(szFullPathNameW, szChildFileW); - wcscat(szFullPathNameW, szArgs); - - /******************************************* - * Start Testing - *******************************************/ - - /* Launch the child */ - if ( !CreateProcess (NULL, szFullPathNameW, NULL, NULL, TRUE, 0, NULL, NULL, &si, &pi )) - { - Fail("ERROR: CreateProcess call failed. GetLastError returned %d\n", - GetLastError() ); - } - - /* Check the returned process information for validity */ - if (pi.hProcess == 0 || pi.hThread == 0) - { - Fail("ERROR: CreateProcess Error: Process Handle = %u, Thread Handle = %u\n", - pi.hProcess, pi.hThread); - } - - - /* Write the Constructed string to stdin pipe for the child process */ - if (WriteFile(hTestStdInW, szTestString, strlen(szTestString), &dwBytesWritten, NULL) == FALSE - || WriteFile(hTestStdInW, "\n", strlen("\n"), &dwBytesWritten, NULL) == FALSE) - { - Fail("ERROR: %ld :unable to write to write pipe handle " - "hTestStdInW=0x%lx\n", GetLastError(), hTestStdInW); - } - - /* Wait for the child to finish, Max 20 seconds */ - dwExitCode = WaitForSingleObject(pi.hProcess, 20000); - - /* If the child failed then whole thing fails */ - if (dwExitCode != WAIT_OBJECT_0) - { - TerminateProcess(pi.hProcess, 0); - Fail("ERROR: The child failed to run properly.\n"); - } - - /* Check for problems in the child process */ - if (GetExitCodeProcess(pi.hProcess, &dwExitCode) == FALSE) - { - Fail("ERROR: Call to GetExitCodeProcess failed.\n"); - } - else if (dwExitCode == EXIT_ERR_CODE1) - { - Fail("ERROR: The Child process could not reead the string " - "written to the stdin pipe.\n"); - } - else if (dwExitCode == EXIT_ERR_CODE2) - { - Fail("ERROR: The Child process could not write the string " - "the stdout pipe or stderr pipe.\n"); - } - else if (dwExitCode == EXIT_ERR_CODE3) - { - Fail("ERROR: The Child received the wrong number of " - "command line arguments.\n"); - } - else if (dwExitCode == EXIT_ERR_CODE4) - { - Fail("ERROR: The Child received the wrong " - "command line arguments.\n"); - } - else if (dwExitCode != EXIT_OK_CODE) - { - Fail("ERROR: Unexpected exit code returned: %u. Child process " - "did not complete its part of the test.\n", dwExitCode); - } - - - /* The child ran ok, so check to see if we received the proper */ - /* strings through the pipes. */ - - /* clear our buffers */ - memset(szStdOutBuf, 0, BUF_LEN); - memset(szStdErrBuf, 0, BUF_LEN); - - /* Read the data back from the child process stdout */ - bRetVal = ReadFile(hTestStdOutR, /* handle to read pipe*/ - szStdOutBuf, /* buffer to write to*/ - BUF_LEN, /* number of bytes to read*/ - &dwBytesRead, /* number of bytes read*/ - NULL); /* overlapped buffer*/ - - /*Read the data back from the child process stderr */ - bRetVal = ReadFile(hTestStdErrR, /* handle to read pipe*/ - szStdErrBuf, /* buffer to write to*/ - BUF_LEN, /* number of bytes to read*/ - &dwBytesRead, /* number of bytes read*/ - NULL); /* overlapped buffer*/ - - - /* Confirm that we recieved the same string that we originally */ - /* wrote to the child and was received on both stdout & stderr.*/ - if (strncmp(szTestString, szStdOutBuf, strlen(szTestString)) != 0 - || strncmp(szTestString, szStdErrBuf, strlen(szTestString)) != 0) - { - Fail("ERROR: The data read back from child does not match " - "what was written. STDOUT: %s STDERR: %s\n", - szStdOutBuf, szStdErrBuf); - } - - - /******************************************* - * Clean Up - *******************************************/ - - /* Close process and thread handle */ - CloseHandle ( pi.hProcess ); - CloseHandle ( pi.hThread ); - - CloseHandle(hTestStdInR); - CloseHandle(hTestStdInW); - CloseHandle(hTestStdOutR); - CloseHandle(hTestStdOutW); - CloseHandle(hTestStdErrR); - CloseHandle(hTestStdErrW); - - PAL_Terminate(); - return ( PASS ); -} diff --git a/src/pal/tests/palsuite/threading/CreateProcessW/test2/test2.h b/src/pal/tests/palsuite/threading/CreateProcessW/test2/test2.h deleted file mode 100644 index 07d40b894..000000000 --- a/src/pal/tests/palsuite/threading/CreateProcessW/test2/test2.h +++ /dev/null @@ -1,31 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source: test2.h -** -** - -** -**=========================================================*/ - - -const WCHAR szChildFileW[] = u"paltest_createprocessw_test2_child"; -const WCHAR szArgs[] = {' ',0x41,' ','B',' ','C','\0'}; -const WCHAR szArg1[] = {0x41,'\0'}; -const WCHAR szArg2[] = {'B','\0'}; -const WCHAR szArg3[] = {'C','\0'}; - -const char *szTestString = "An uninteresting test string (it works though)"; - -const DWORD EXIT_OK_CODE = 100; -const DWORD EXIT_ERR_CODE1 = 101; -const DWORD EXIT_ERR_CODE2 = 102; -const DWORD EXIT_ERR_CODE3 = 103; -const DWORD EXIT_ERR_CODE4 = 104; -const DWORD EXIT_ERR_CODE5 = 105; - -#define BUF_LEN 128 - diff --git a/src/pal/tests/palsuite/threading/CreateProcessW/test2/testinfo.dat b/src/pal/tests/palsuite/threading/CreateProcessW/test2/testinfo.dat deleted file mode 100644 index d16ae593f..000000000 --- a/src/pal/tests/palsuite/threading/CreateProcessW/test2/testinfo.dat +++ /dev/null @@ -1,20 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = threading -Function = CreateProcessW -Name = PROCESS_INFORMATION and HANDLE Inheritance -TYPE = DEFAULT -EXE1 = parentprocess -EXE2 = childprocess -Description -= Test the following features of CreateProcessW: -= - Check to see if hProcess & hThread are set in -= return PROCESS_INFORMATION structure -= - Check to see if stdin, stdout, & stderr handles -= are used when STARTF_USESTDHANDLES is specified -= in STARUPINFO flags and bInheritHandles = TRUE -= - Check to see that proper arguments are passed to -= child process diff --git a/src/pal/tests/palsuite/threading/CreateSemaphoreA_ReleaseSemaphore/CMakeLists.txt b/src/pal/tests/palsuite/threading/CreateSemaphoreA_ReleaseSemaphore/CMakeLists.txt deleted file mode 100644 index 1962ade35..000000000 --- a/src/pal/tests/palsuite/threading/CreateSemaphoreA_ReleaseSemaphore/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) -add_subdirectory(test3) - diff --git a/src/pal/tests/palsuite/threading/CreateSemaphoreA_ReleaseSemaphore/test1/CMakeLists.txt b/src/pal/tests/palsuite/threading/CreateSemaphoreA_ReleaseSemaphore/test1/CMakeLists.txt deleted file mode 100644 index 76b2dd690..000000000 --- a/src/pal/tests/palsuite/threading/CreateSemaphoreA_ReleaseSemaphore/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - CreateSemaphore.cpp -) - -add_executable(paltest_createsemaphorea_releasesemaphore_test1 - ${SOURCES} -) - -add_dependencies(paltest_createsemaphorea_releasesemaphore_test1 coreclrpal) - -target_link_libraries(paltest_createsemaphorea_releasesemaphore_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/CreateSemaphoreA_ReleaseSemaphore/test1/CreateSemaphore.cpp b/src/pal/tests/palsuite/threading/CreateSemaphoreA_ReleaseSemaphore/test1/CreateSemaphore.cpp deleted file mode 100644 index 342b15ec2..000000000 --- a/src/pal/tests/palsuite/threading/CreateSemaphoreA_ReleaseSemaphore/test1/CreateSemaphore.cpp +++ /dev/null @@ -1,322 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source: createsemaphorea_releasesemaphore/test1/createsemaphore.c -** -** Purpose: Test Semaphore operation using classic IPC problem: -** "Producer-Consumer Problem". -** -** Dependencies: CreateThread -** ReleaseSemaphore -** WaitForSingleObject -** Sleep -** fflush -** - -** -**=========================================================*/ - -#include - -#define PRODUCTION_TOTAL 26 - -#define _BUF_SIZE 10 - -DWORD dwThreadId; /* consumer thread identifier */ - -HANDLE hThread; /* handle to consumer thread */ - -HANDLE hSemaphoreM; /* handle to mutual exclusion semaphore */ - -HANDLE hSemaphoreE; /* handle to semaphore that counts empty buffer slots */ - -HANDLE hSemaphoreF; /* handle to semaphore that counts full buffer slots */ - -typedef struct Buffer -{ - short readIndex; - short writeIndex; - CHAR message[_BUF_SIZE]; - -} BufferStructure; - -CHAR producerItems[PRODUCTION_TOTAL + 1]; - -CHAR consumerItems[PRODUCTION_TOTAL + 1]; - -/* - * Read next message from the Buffer into provided pointer. - * Returns: 0 on failure, 1 on success. - */ -int -readBuf(BufferStructure *Buffer, char *c) -{ - if( Buffer -> writeIndex == Buffer -> readIndex ) - { - return 0; - } - *c = Buffer -> message[Buffer -> readIndex++]; - Buffer -> readIndex %= _BUF_SIZE; - return 1; -} - -/* - * Write message generated by the producer to Buffer. - * Returns: 0 on failure, 1 on success. - */ -int -writeBuf(BufferStructure *Buffer, CHAR c) -{ - if( ( ((Buffer -> writeIndex) + 1) % _BUF_SIZE) == - (Buffer -> readIndex) ) - { - return 0; - } - Buffer -> message[Buffer -> writeIndex++] = c; - Buffer -> writeIndex %= _BUF_SIZE; - return 1; -} - -/* - * Atomic decrement of semaphore value. - */ -VOID -down(HANDLE hSemaphore) -{ - switch ( (WaitForSingleObject ( - hSemaphore, - 10000))) /* Wait 10 seconds */ - { - case WAIT_OBJECT_0: /* - * Semaphore was signaled. OK to access - * semaphore. - */ - break; - case WAIT_ABANDONED: /* - * Object was mutex object whose owning - * thread has terminated. Shouldn't occur. - */ - Fail("WaitForSingleObject call returned 'WAIT_ABANDONED'.\n" - "Failing Test.\n"); - break; - case WAIT_FAILED: /* WaitForSingleObject function failed */ - Fail("WaitForSingleObject call returned 'WAIT_FAILED'.\n" - "GetLastError returned %d\nFailing Test.\n",GetLastError()); - break; - default: - Fail("WaitForSingleObject call returned an unexpected value.\n" - "Failing Test.\n"); - break; - } - -} - -/* - * Atomic increment of semaphore value. - */ -VOID -up(HANDLE hSemaphore) -{ - if (!ReleaseSemaphore ( - hSemaphore, - 1, - NULL) - ) - { - Fail("ReleaseSemaphore call failed. GetLastError returned %d\n", - GetLastError()); - } -} - -/* - * Sleep 500 milleseconds. - */ -VOID -consumerSleep(VOID) -{ - Sleep(500); -} - -/* - * Sleep between 10 milleseconds. - */ -VOID -producerSleep(VOID) -{ - Sleep(10); -} - -/* - * Produce a message and write the message to Buffer. - */ -VOID -producer(BufferStructure *Buffer) -{ - - int n = 0; - char c; - - while (n < PRODUCTION_TOTAL) - { - c = 'A' + n ; /* Produce Item */ - - down(hSemaphoreE); - down(hSemaphoreM); - - if (writeBuf(Buffer, c)) - { - Trace("Producer produces %c.\n", c); - fflush(stdout); - producerItems[n++] = c; - } - - up(hSemaphoreM); - up(hSemaphoreF); - - producerSleep(); - } - - return; -} - -/* - * Read and "Consume" the messages in Buffer. - */ -DWORD -PALAPI -consumer( LPVOID lpParam ) -{ - int n = 0; - char c; - - consumerSleep(); - - while (n < PRODUCTION_TOTAL) - { - - down(hSemaphoreF); - down(hSemaphoreM); - - if (readBuf((BufferStructure*)lpParam, &c)) - { - Trace("\tConsumer consumes %c.\n", c); - fflush(stdout); - consumerItems[n++] = c; - } - - up(hSemaphoreM); - up(hSemaphoreE); - - consumerSleep(); - } - - return 0; -} - -int __cdecl main (int argc, char **argv) -{ - - BufferStructure Buffer, *pBuffer; - - pBuffer = &Buffer; - - if(0 != (PAL_Initialize(argc, argv))) - { - return ( FAIL ); - } - - /* - * Create Semaphores - */ - hSemaphoreM = CreateSemaphoreA ( - NULL, - 1, - 1, - NULL); - - if ( NULL == hSemaphoreM ) - { - Fail ( "hSemaphoreM = CreateSemaphoreA () - returned NULL\n" - "Failing Test.\nGetLastError returned %d\n", GetLastError()); - } - - - hSemaphoreE = CreateSemaphoreA ( - NULL, - _BUF_SIZE , - _BUF_SIZE , - NULL); - - if ( NULL == hSemaphoreE ) - { - Fail ( "hSemaphoreE = CreateSemaphoreA () - returned NULL\n" - "Failing Test.\nGetLastError returned %d\n", GetLastError()); - } - - hSemaphoreF = CreateSemaphoreA ( - NULL, - 0, - _BUF_SIZE , - NULL); - - if ( NULL == hSemaphoreF ) - { - Fail ( "hSemaphoreF = CreateSemaphoreA () - returned NULL\n" - "Failing Test.\nGetLastError returned %d\n", GetLastError()); - } - - - /* - * Initialize Buffer - */ - pBuffer->writeIndex = pBuffer->readIndex = 0; - - /* - * Create Consumer - */ - hThread = CreateThread( - NULL, - 0, - consumer, - &Buffer, - 0, - &dwThreadId); - - if ( NULL == hThread ) - { - Fail ( "CreateThread() returned NULL. Failing test.\n" - "GetLastError returned %d\n", GetLastError()); - } - - /* - * Start producing - */ - producer(pBuffer); - - /* - * Wait for consumer to complete - */ - WaitForSingleObject (hThread, INFINITE); - - /* - * Compare items produced vs. items consumed - */ - if ( 0 != strncmp (producerItems, consumerItems, PRODUCTION_TOTAL) ) - { - Fail("The producerItems string %s\n and the consumerItems string " - "%s\ndo not match. This could be a problem with the strncmp()" - " function\n FailingTest\nGetLastError() returned %d\n", - producerItems, consumerItems, GetLastError()); - } - - Trace ("producerItems and consumerItems arrays match. All %d\nitems " - "were produced and consumed in order.\nTest passed.\n", - PRODUCTION_TOTAL); - - PAL_Terminate(); - return ( PASS ); - -} diff --git a/src/pal/tests/palsuite/threading/CreateSemaphoreA_ReleaseSemaphore/test1/testinfo.dat b/src/pal/tests/palsuite/threading/CreateSemaphoreA_ReleaseSemaphore/test1/testinfo.dat deleted file mode 100644 index 880746e43..000000000 --- a/src/pal/tests/palsuite/threading/CreateSemaphoreA_ReleaseSemaphore/test1/testinfo.dat +++ /dev/null @@ -1,18 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = threading -Function = CreateSemaphoreA / ReleaseSemaphore -Name = Positive Test for CreateSemaphoreA and ReleaseSemaphore -TYPE = DEFAULT -EXE1 = createsemaphore -Description -= Implementation of Producer / Consumer IPC problem using CreateSemaphoreA -= and ReleaseSemaphore functions. This test case exercises CreateSemaphoreA -= , ReleaseSemaphore, CreateThread and WaitForSingleObject functions. -= Since there is no way to currently create "pseudo" random events in the -= pal, this example does not behave as classic bounded buffers would. This -= test case is designed to starve the consumer and have the producer fill -= the buffer. diff --git a/src/pal/tests/palsuite/threading/CreateSemaphoreA_ReleaseSemaphore/test2/CMakeLists.txt b/src/pal/tests/palsuite/threading/CreateSemaphoreA_ReleaseSemaphore/test2/CMakeLists.txt deleted file mode 100644 index 1f01ed012..000000000 --- a/src/pal/tests/palsuite/threading/CreateSemaphoreA_ReleaseSemaphore/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - CreateSemaphore.cpp -) - -add_executable(paltest_createsemaphorea_releasesemaphore_test2 - ${SOURCES} -) - -add_dependencies(paltest_createsemaphorea_releasesemaphore_test2 coreclrpal) - -target_link_libraries(paltest_createsemaphorea_releasesemaphore_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/CreateSemaphoreA_ReleaseSemaphore/test2/CreateSemaphore.cpp b/src/pal/tests/palsuite/threading/CreateSemaphoreA_ReleaseSemaphore/test2/CreateSemaphore.cpp deleted file mode 100644 index bff5b51c3..000000000 --- a/src/pal/tests/palsuite/threading/CreateSemaphoreA_ReleaseSemaphore/test2/CreateSemaphore.cpp +++ /dev/null @@ -1,313 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source: CreateSemaphoreA_ReleaseSemaphore/test2/createsemaphore.c -** -** Purpose: Test Semaphore operation using classic IPC problem: -** "Producer-Consumer Problem". -** -** Dependencies: CreateThread -** ReleaseSemaphore -** WaitForSingleObject -** Sleep -** fflush -** - -** -**=========================================================*/ - -#include - -#define PRODUCTION_TOTAL 26 - -#define _BUF_SIZE 10 - -DWORD dwThreadId; /* consumer thread identifier */ - -HANDLE hThread; /* handle to consumer thread */ - -HANDLE hSemaphoreM; /* handle to mutual exclusion semaphore */ - -HANDLE hSemaphoreE; /* handle to semaphore that counts empty buffer slots */ - -HANDLE hSemaphoreF; /* handle to semaphore that counts full buffer slots */ - -typedef struct Buffer -{ - short readIndex; - short writeIndex; - CHAR message[_BUF_SIZE]; - -} BufferStructure; - -CHAR producerItems[PRODUCTION_TOTAL + 1]; - -CHAR consumerItems[PRODUCTION_TOTAL + 1]; - -/* - * Read next message from the Buffer into provided pointer. - * Returns: 0 on failure, 1 on success. - */ -int -readBuf(BufferStructure *Buffer, char *c) -{ - if( Buffer -> writeIndex == Buffer -> readIndex ) - { - return 0; - } - *c = Buffer -> message[Buffer -> readIndex++]; - Buffer -> readIndex %= _BUF_SIZE; - return 1; -} - -/* - * Write message generated by the producer to Buffer. - * Returns: 0 on failure, 1 on success. - */ -int -writeBuf(BufferStructure *Buffer, CHAR c) -{ - if( ( ((Buffer -> writeIndex) + 1) % _BUF_SIZE) == - (Buffer -> readIndex) ) - { - return 0; - } - Buffer -> message[Buffer -> writeIndex++] = c; - Buffer -> writeIndex %= _BUF_SIZE; - return 1; -} - -/* - * Atomic decrement of semaphore value. - */ -VOID -down(HANDLE hSemaphore) -{ - switch ( (WaitForSingleObject ( - hSemaphore, - 10000))) - { - case WAIT_OBJECT_0: /* - * Semaphore was signaled. OK to access semaphore. - */ - break; - case WAIT_ABANDONED: /* - * Object was mutex object whose owning - * thread has terminated. Shouldn't occur. - */ - Fail("WaitForSingleObject call returned 'WAIT_ABANDONED'.\n" - "Failing Test.\n"); - break; - case WAIT_FAILED: /* WaitForSingleObject function failed */ - Fail("WaitForSingleObject call returned 'WAIT_FAILED'.\n" - "GetLastError returned %d\nFailing Test.\n",GetLastError()); - break; - default: - Fail("WaitForSingleObject call returned an unexpected value.\n" - "Failing Test.\n"); - break; - } - -} - -/* - * Atomic increment of semaphore value. - */ -VOID -up(HANDLE hSemaphore) -{ - if (!ReleaseSemaphore ( - hSemaphore, - 1, - NULL) - ) - { - Fail("ReleaseSemaphore call failed. GetLastError returned %d\n", - GetLastError()); - } -} - -/* - * Sleep 10 milleseconds. - */ -VOID -consumerSleep(VOID) -{ - Sleep(10); -} - -/* - * Sleep 500 milleseconds. - */ -VOID -producerSleep(VOID) -{ - Sleep(500); -} - -/* - * Produce a message and write the message to Buffer. - */ -VOID -producer(BufferStructure *Buffer) -{ - - int n = 0; - char c; - - while (n < PRODUCTION_TOTAL) - { - c = 'A' + n ; /* Produce Item */ - - down(hSemaphoreE); - down(hSemaphoreM); - - if (writeBuf(Buffer, c)) - { - Trace("Producer produces %c.\n", c); - fflush(stdout); - producerItems[n++] = c; - } - - up(hSemaphoreM); - up(hSemaphoreF); - - producerSleep(); - } - return; -} - -/* - * Read and "Consume" the messages in Buffer. - */ -DWORD -PALAPI -consumer( LPVOID lpParam ) -{ - int n = 0; - char c; - - consumerSleep(); - - while (n < PRODUCTION_TOTAL) - { - - down(hSemaphoreF); - down(hSemaphoreM); - - if (readBuf((BufferStructure*)lpParam, &c)) - { - Trace("\tConsumer consumes %c.\n", c); - fflush(stdout); - consumerItems[n++] = c; - } - - up(hSemaphoreM); - up(hSemaphoreE); - - consumerSleep(); - } - return 0; -} - -int __cdecl main (int argc, char **argv) -{ - - BufferStructure Buffer, *pBuffer; - - pBuffer = &Buffer; - - if(0 != (PAL_Initialize(argc, argv))) - { - return (FAIL); - } - - /* - * Create Semaphores - */ - hSemaphoreM = CreateSemaphoreA ( - NULL, - 1, - 1, - NULL); - - if ( NULL == hSemaphoreM ) - { - Fail ( "hSemaphoreM = CreateSemaphoreA () - returned NULL\n" - "Failing Test.\n"); - } - - hSemaphoreE = CreateSemaphoreA ( - NULL, - _BUF_SIZE , - _BUF_SIZE , - NULL); - - if ( NULL == hSemaphoreE ) - { - Fail ( "hSemaphoreE = CreateSemaphoreA () - returned NULL\n" - "Failing Test.\n"); - } - - hSemaphoreF = CreateSemaphoreA ( - NULL, - 0, - _BUF_SIZE , - NULL); - - if ( NULL == hSemaphoreF ) - { - Fail ( "hSemaphoreF = CreateSemaphoreA () - returned NULL\n" - "Failing Test.\n"); - } - - /* - * Initialize Buffer - */ - pBuffer->writeIndex = pBuffer->readIndex = 0; - - /* - * Create Consumer - */ - hThread = CreateThread( - NULL, - 0, - consumer, - &Buffer, - 0, - &dwThreadId); - - if ( NULL == hThread ) - { - Fail ( "CreateThread() returned NULL. Failing test.\n"); - } - - /* - * Start producing - */ - producer(pBuffer); - - /* - * Wait for consumer to complete - */ - WaitForSingleObject (hThread, INFINITE); - - if ( 0 != strncmp (producerItems, consumerItems, PRODUCTION_TOTAL) ) - { - Fail("The producerItems string %s\n and the consumerItems string " - "%s\ndo not match. This could be a problem with the strncmp()" - " function\n FailingTest\nGetLastError() returned %d\n", - producerItems, consumerItems, GetLastError()); - } - - Trace ("producerItems and consumerItems arrays match. All %d\nitems " - "were produced and consumed in order.\nTest passed.\n", - PRODUCTION_TOTAL); - - PAL_Terminate(); - return ( PASS ); - -} diff --git a/src/pal/tests/palsuite/threading/CreateSemaphoreA_ReleaseSemaphore/test2/testinfo.dat b/src/pal/tests/palsuite/threading/CreateSemaphoreA_ReleaseSemaphore/test2/testinfo.dat deleted file mode 100644 index 5a6c2e790..000000000 --- a/src/pal/tests/palsuite/threading/CreateSemaphoreA_ReleaseSemaphore/test2/testinfo.dat +++ /dev/null @@ -1,18 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = threading -Function = CreateSemaphoreA / ReleaseSemaphore -Name = Positive Test for CreateSemaphoreA and ReleaseSemaphore -TYPE = DEFAULT -EXE1 = createsemaphore -Description -= Implementation of Producer / Consumer IPC problem using CreateSemaphoreA -= and ReleaseSemaphore functions. This test case exercises CreateSemaphoreA -= , ReleaseSemaphore, CreateThread and WaitForSingleObject functions. -= Since there is no way to currently create "pseudo" random events in the -= pal, this example does not behave as classic bounded buffers would. This -= test case is designed to starve the producer and have the consumer fill -= the buffer. diff --git a/src/pal/tests/palsuite/threading/CreateSemaphoreA_ReleaseSemaphore/test3/CMakeLists.txt b/src/pal/tests/palsuite/threading/CreateSemaphoreA_ReleaseSemaphore/test3/CMakeLists.txt deleted file mode 100644 index a7dcfdd32..000000000 --- a/src/pal/tests/palsuite/threading/CreateSemaphoreA_ReleaseSemaphore/test3/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - createsemaphore.cpp -) - -add_executable(paltest_createsemaphorea_releasesemaphore_test3 - ${SOURCES} -) - -add_dependencies(paltest_createsemaphorea_releasesemaphore_test3 coreclrpal) - -target_link_libraries(paltest_createsemaphorea_releasesemaphore_test3 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/CreateSemaphoreA_ReleaseSemaphore/test3/createsemaphore.cpp b/src/pal/tests/palsuite/threading/CreateSemaphoreA_ReleaseSemaphore/test3/createsemaphore.cpp deleted file mode 100644 index 7c6db6b05..000000000 --- a/src/pal/tests/palsuite/threading/CreateSemaphoreA_ReleaseSemaphore/test3/createsemaphore.cpp +++ /dev/null @@ -1,200 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: createsemaphorea_releasesemaphore/test3/createsemaphore.c -** -** Purpose: Test attributes of CreateSemaphoreA and ReleaseSemaphore. -** Insure for CreateSemaphore that lInitialCount and lMaximumCount -** constraints are respected. Validate that CreateSemaphore rejects -** conditions where initial count and / or maximum count are negative -** and conditions where the initial count is greater than the maximum -** count. For ReleaseSemaphore validate that lpPreviousCount gets set -** to the previous semaphore count and lpPreviousCount can be NULL. -** Also establish ReleaseSemaphore fails when called in a semaphore -** with count equal to lMaximumCount. -** -** -**==========================================================================*/ - -#include - -struct testcase -{ - LPSECURITY_ATTRIBUTES lpSemaphoreAttributes; - LONG lInitialCount; - LONG lMaximumCount; - LPCTSTR lpName; - BOOL bNegativeTest; -}; - -struct testcase testCases[] = -{ - {NULL, -1, 1, NULL, TRUE}, - {NULL, 1, -1, NULL, TRUE}, - {NULL, -1, -1, NULL, TRUE}, - {NULL, 2, 1, NULL, TRUE}, - {NULL, 1, 2, NULL, FALSE}, - {NULL, 0, 10, NULL, FALSE}, - {NULL, INT_MAX - 1, INT_MAX, NULL, FALSE}, - {NULL, INT_MAX, INT_MAX, NULL, FALSE} -}; - -HANDLE hSemaphore[sizeof(testCases)/sizeof(struct testcase)]; - -BOOL cleanup(int index) -{ - int i; - BOOL bRet = TRUE; - for (i = 0; i < index; i++) - { - if (!CloseHandle(hSemaphore[i])) - { - bRet = FALSE; - Trace("PALSUITE ERROR: CloseHandle(%p) call failed for index %d\n", - hSemaphore[i], i); - } - } - return(bRet); -} - -int __cdecl main (int argc, char **argv) -{ - int i; - int j; - - if(0 != (PAL_Initialize(argc, argv))) - { - return (FAIL); - } - /* create semaphores */ - for (i = 0; i < sizeof(testCases)/sizeof(struct testcase); i++) - { - hSemaphore[i] = CreateSemaphoreA (testCases[i].lpSemaphoreAttributes, - testCases[i].lInitialCount, - testCases[i].lMaximumCount, - testCases[i].lpName); - - if (NULL == hSemaphore[i]) - { - if (!testCases[i].bNegativeTest) - { - Trace("PALSUITE ERROR: CreateSemaphoreA('%p' '%ld' '%ld' " - "'%p') returned NULL at index %d.\nGetLastError " - "returned %d.\n", testCases[i].lpSemaphoreAttributes, - testCases[i].lInitialCount, testCases[i].lMaximumCount, - testCases[i].lpName, i, GetLastError()); - if (i > 0) - { - cleanup(i - 1); - } - Fail(""); - } - else - { - continue; - } - } - - /* increment semaphore count to lMaximumCount */ - for (j = testCases[i].lInitialCount; (ULONG)j <= (ULONG)testCases[i].lMaximumCount; - j++) - { - if (testCases[i].lMaximumCount == j) - { - /* Call ReleaseSemaphore once more to ensure ReleaseSemaphore - fails */ - if(ReleaseSemaphore(hSemaphore[i], 1, NULL)) - { - Trace("PALSUITE ERROR: ReleaseSemaphore('%p' '%ld' '%p') " - "call returned %d\nwhen it should have returned " - "%d.\nThe semaphore's count was %d.\nGetLastError " - "returned %d.\n", hSemaphore[i], 1, NULL, TRUE, - FALSE, j, GetLastError()); - cleanup(i); - Fail(""); - } - } - else - { - int previous; - BOOL bRet = ReleaseSemaphore(hSemaphore[i], 1, &previous); - DWORD dwError = GetLastError(); - - if(!bRet) - { - Trace("PALSUITE ERROR: ReleaseSemaphore('%p' '%ld' '%p') " - "call returned %d\nwhen it should have returned " - "%d.\nThe semaphore count was %d and it's " - "lMaxCount was %d.\nGetLastError returned %d.\n", - hSemaphore[i], 1, &previous, bRet, TRUE, j, - testCases[i].lMaximumCount, dwError); - cleanup(i); - Fail(""); - } - if (previous != j) - { - Trace("PALSUITE ERROR: ReleaseSemaphore('%p' '%ld' '%p') " - "call set %p to %d instead of %d.\n The semaphore " - "count was %d and GetLastError returned %d.\n", - hSemaphore[i], 1, &previous, &previous, previous, - j, j, dwError); - cleanup(i); - Fail(""); - } - } - } - - // Skip exhaustive decrement tests for too large an initial count - if(testCases[i].lInitialCount >= INT_MAX - 1) - { - continue; - } - - /* decrement semaphore count to 0 */ - for (j = testCases[i].lMaximumCount; j >= 0; j--) - { - DWORD dwRet = WaitForSingleObject(hSemaphore[i], 0); - DWORD dwError = GetLastError(); - - if (0 == j) - { - /* WaitForSingleObject should report that the - semaphore is nonsignaled */ - if (WAIT_TIMEOUT != dwRet) - { - Trace("PALSUITE ERROR: WaitForSingleObject('%p' '%u') " - "call returned %d\nwhen it should have returned " - "%d.\nThe semaphore's count was %d.\nGetLastError " - "returned %d.\n", hSemaphore[i], 0, dwRet, - WAIT_TIMEOUT, j, dwError); - cleanup(i); - Fail(""); - } - } - else - { - /* WaitForSingleObject should report that the - semaphore is signaled */ - if (WAIT_OBJECT_0 != dwRet) - { - Trace("PALSUITE ERROR: WaitForSingleObject('%p' '%u') " - "call returned %d\nwhen it should have returned " - "%d.\nThe semaphore's count was %d.\nGetLastError " - "returned %d.\n", hSemaphore[i], 0, dwRet, - WAIT_OBJECT_0, j, dwError); - cleanup(i); - Fail(""); - } - } - } - } - PAL_Terminate(); - return (PASS); -} - - - - diff --git a/src/pal/tests/palsuite/threading/CreateSemaphoreA_ReleaseSemaphore/test3/testinfo.dat b/src/pal/tests/palsuite/threading/CreateSemaphoreA_ReleaseSemaphore/test3/testinfo.dat deleted file mode 100644 index d8cd59092..000000000 --- a/src/pal/tests/palsuite/threading/CreateSemaphoreA_ReleaseSemaphore/test3/testinfo.dat +++ /dev/null @@ -1,20 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = threading -Function = CreateSemaphoreA / ReleaseSemaphore -Name = Positive Test for CreateSemaphoreA and ReleaseSemaphore -TYPE = DEFAULT -EXE1 = createsemaphore -Description -= Test attributes of CreateSemaphoreA and ReleaseSemaphore. -= Insure for CreateSemaphore that lInitialCount and lMaximumCount -= constraints are respected. Validate that CreateSemaphore rejects -= conditions where, initial count and / or maximum count are negative -= and conditions where the initial count is greater than the maximum -= count. For ReleaseSemaphore validate that lpPreviousCount gets set -= to the previous semaphore count and lpPreviousCount can be NULL. -= Also establish ReleaseSemaphore fails when called in a semaphore -= with count equal to lMaximumCount. diff --git a/src/pal/tests/palsuite/threading/CreateSemaphoreW_ReleaseSemaphore/CMakeLists.txt b/src/pal/tests/palsuite/threading/CreateSemaphoreW_ReleaseSemaphore/CMakeLists.txt deleted file mode 100644 index 1962ade35..000000000 --- a/src/pal/tests/palsuite/threading/CreateSemaphoreW_ReleaseSemaphore/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) -add_subdirectory(test3) - diff --git a/src/pal/tests/palsuite/threading/CreateSemaphoreW_ReleaseSemaphore/test1/CMakeLists.txt b/src/pal/tests/palsuite/threading/CreateSemaphoreW_ReleaseSemaphore/test1/CMakeLists.txt deleted file mode 100644 index 47b09e8e9..000000000 --- a/src/pal/tests/palsuite/threading/CreateSemaphoreW_ReleaseSemaphore/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - CreateSemaphore.cpp -) - -add_executable(paltest_createsemaphorew_releasesemaphore_test1 - ${SOURCES} -) - -add_dependencies(paltest_createsemaphorew_releasesemaphore_test1 coreclrpal) - -target_link_libraries(paltest_createsemaphorew_releasesemaphore_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/CreateSemaphoreW_ReleaseSemaphore/test1/CreateSemaphore.cpp b/src/pal/tests/palsuite/threading/CreateSemaphoreW_ReleaseSemaphore/test1/CreateSemaphore.cpp deleted file mode 100644 index 854d16d0e..000000000 --- a/src/pal/tests/palsuite/threading/CreateSemaphoreW_ReleaseSemaphore/test1/CreateSemaphore.cpp +++ /dev/null @@ -1,323 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source: CreateSemaphoreW_ReleaseSemaphore/test1/CreateSemaphore.c -** -** Purpose: Test Semaphore operation using classic IPC problem: -** "Producer-Consumer Problem". -** -** Dependencies: CreateThread -** ReleaseSemaphore -** WaitForSingleObject -** Sleep -** fflush -** - -** -**=========================================================*/ - -#define UNICODE -#include - -#define PRODUCTION_TOTAL 26 - -#define _BUF_SIZE 10 - -DWORD dwThreadId; /* consumer thread identifier */ - -HANDLE hThread; /* handle to consumer thread */ - -HANDLE hSemaphoreM; /* handle to mutual exclusion semaphore */ - -HANDLE hSemaphoreE; /* handle to semaphore that counts empty buffer slots */ - -HANDLE hSemaphoreF; /* handle to semaphore that counts full buffer slots */ - -typedef struct Buffer -{ - short readIndex; - short writeIndex; - CHAR message[_BUF_SIZE]; - -} BufferStructure; - -CHAR producerItems[PRODUCTION_TOTAL + 1]; - -CHAR consumerItems[PRODUCTION_TOTAL + 1]; - -/* - * Read next message from the Buffer into provided pointer. - * Returns: 0 on failure, 1 on success. - */ -int -readBuf(BufferStructure *Buffer, char *c) -{ - if( Buffer -> writeIndex == Buffer -> readIndex ) - { - return 0; - } - *c = Buffer -> message[Buffer -> readIndex++]; - Buffer -> readIndex %= _BUF_SIZE; - return 1; -} - -/* - * Write message generated by the producer to Buffer. - * Returns: 0 on failure, 1 on success. - */ -int -writeBuf(BufferStructure *Buffer, CHAR c) -{ - if( ( ((Buffer -> writeIndex) + 1) % _BUF_SIZE) == - (Buffer -> readIndex) ) - { - return 0; - } - Buffer -> message[Buffer -> writeIndex++] = c; - Buffer -> writeIndex %= _BUF_SIZE; - return 1; -} - -/* - * Atomic decrement of semaphore value. - */ -VOID -down(HANDLE hSemaphore) -{ - switch ( (WaitForSingleObject ( - hSemaphore, - 10000))) /* Wait 10 seconds */ - { - case WAIT_OBJECT_0: /* - * Semaphore was signaled. OK to access - * semaphore. - */ - break; - case WAIT_ABANDONED: /* - * Object was mutex object whose owning - * thread has terminated. Shouldn't occur. - */ - Fail("WaitForSingleObject call returned 'WAIT_ABANDONED'.\n" - "Failing Test.\n"); - break; - case WAIT_FAILED: /* WaitForSingleObject function failed */ - Fail("WaitForSingleObject call returned 'WAIT_FAILED'.\n" - "GetLastError returned %d\nFailing Test.\n",GetLastError()); - break; - default: - Fail("WaitForSingleObject call returned an unexpected value.\n" - "Failing Test.\n"); - break; - } - -} - -/* - * Atomic increment of semaphore value. - */ -VOID -up(HANDLE hSemaphore) -{ - if (!ReleaseSemaphore ( - hSemaphore, - 1, - NULL) - ) - { - Fail("ReleaseSemaphore call failed. GetLastError returned %d\n", - GetLastError()); - } -} - -/* - * Sleep 500 milleseconds. - */ -VOID -consumerSleep(VOID) -{ - Sleep(500); -} - -/* - * Sleep between 10 milleseconds. - */ -VOID -producerSleep(VOID) -{ - Sleep(10); -} - -/* - * Produce a message and write the message to Buffer. - */ -VOID -producer(BufferStructure *Buffer) -{ - - int n = 0; - char c; - - while (n < PRODUCTION_TOTAL) - { - c = 'A' + n ; /* Produce Item */ - - down(hSemaphoreE); - down(hSemaphoreM); - - if (writeBuf(Buffer, c)) - { - Trace("Producer produces %c.\n", c); - fflush(stdout); - producerItems[n++] = c; - } - - up(hSemaphoreM); - up(hSemaphoreF); - - producerSleep(); - } - - return; -} - -/* - * Read and "Consume" the messages in Buffer. - */ -DWORD -PALAPI -consumer( LPVOID lpParam ) -{ - int n = 0; - char c; - - consumerSleep(); - - while (n < PRODUCTION_TOTAL) - { - - down(hSemaphoreF); - down(hSemaphoreM); - - if (readBuf((BufferStructure*)lpParam, &c)) - { - Trace("\tConsumer consumes %c.\n", c); - fflush(stdout); - consumerItems[n++] = c; - } - - up(hSemaphoreM); - up(hSemaphoreE); - - consumerSleep(); - } - - return 0; -} - -int __cdecl main (int argc, char **argv) -{ - - BufferStructure Buffer, *pBuffer; - - pBuffer = &Buffer; - - if(0 != (PAL_Initialize(argc, argv))) - { - return ( FAIL ); - } - - /* - * Create Semaphores - */ - hSemaphoreM = CreateSemaphoreW ( - NULL, - 1, - 1, - NULL); - - if ( NULL == hSemaphoreM ) - { - Fail ( "hSemaphoreM = CreateSemaphoreW () - returned NULL\n" - "Failing Test.\nGetLastError returned %d\n", GetLastError()); - } - - - hSemaphoreE = CreateSemaphoreW ( - NULL, - _BUF_SIZE , - _BUF_SIZE , - NULL); - - if ( NULL == hSemaphoreE ) - { - Fail ( "hSemaphoreE = CreateSemaphoreW () - returned NULL\n" - "Failing Test.\nGetLastError returned %d\n", GetLastError()); - } - - hSemaphoreF = CreateSemaphoreW ( - NULL, - 0, - _BUF_SIZE , - NULL); - - if ( NULL == hSemaphoreF ) - { - Fail ( "hSemaphoreF = CreateSemaphoreW () - returned NULL\n" - "Failing Test.\nGetLastError returned %d\n", GetLastError()); - } - - - /* - * Initialize Buffer - */ - pBuffer->writeIndex = pBuffer->readIndex = 0; - - /* - * Create Consumer - */ - hThread = CreateThread( - NULL, - 0, - consumer, - &Buffer, - 0, - &dwThreadId); - - if ( NULL == hThread ) - { - Fail ( "CreateThread() returned NULL. Failing test.\n" - "GetLastError returned %d\n", GetLastError()); - } - - /* - * Start producing - */ - producer(pBuffer); - - /* - * Wait for consumer to complete - */ - WaitForSingleObject (hThread, INFINITE); - - /* - * Compare items produced vs. items consumed - */ - if ( 0 != strncmp (producerItems, consumerItems, PRODUCTION_TOTAL) ) - { - Fail("The producerItems string %s\n and the consumerItems string " - "%s\ndo not match. This could be a problem with the strncmp()" - " function\n FailingTest\nGetLastError() returned %d\n", - producerItems, consumerItems, GetLastError()); - } - - Trace ("producerItems and consumerItems arrays match. All %d\nitems " - "were produced and consumed in order.\nTest passed.\n", - PRODUCTION_TOTAL); - - PAL_Terminate(); - return ( PASS ); - -} diff --git a/src/pal/tests/palsuite/threading/CreateSemaphoreW_ReleaseSemaphore/test1/testinfo.dat b/src/pal/tests/palsuite/threading/CreateSemaphoreW_ReleaseSemaphore/test1/testinfo.dat deleted file mode 100644 index 912758933..000000000 --- a/src/pal/tests/palsuite/threading/CreateSemaphoreW_ReleaseSemaphore/test1/testinfo.dat +++ /dev/null @@ -1,18 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = threading -Function = CreateSemaphoreW / ReleaseSemaphore -Name = Positive Test for CreateSemaphoreW and ReleaseSemaphore -TYPE = DEFAULT -EXE1 = createsemaphore -Description -= Implementation of Producer / Consumer IPC problem using CreateSemaphoreW -= and ReleaseSemaphore functions. This test case exercises CreateSemaphoreW -= , ReleaseSemaphore, CreateThread and WaitForSingleObject functions. -= Since there is no way to currently create "pseudo" random events in the -= pal, this example does not behave as classic bounded buffers would. This -= test case is designed to starve the consumer and have the producer fill -= the buffer. diff --git a/src/pal/tests/palsuite/threading/CreateSemaphoreW_ReleaseSemaphore/test2/CMakeLists.txt b/src/pal/tests/palsuite/threading/CreateSemaphoreW_ReleaseSemaphore/test2/CMakeLists.txt deleted file mode 100644 index 374f02c21..000000000 --- a/src/pal/tests/palsuite/threading/CreateSemaphoreW_ReleaseSemaphore/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - CreateSemaphore.cpp -) - -add_executable(paltest_createsemaphorew_releasesemaphore_test2 - ${SOURCES} -) - -add_dependencies(paltest_createsemaphorew_releasesemaphore_test2 coreclrpal) - -target_link_libraries(paltest_createsemaphorew_releasesemaphore_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/CreateSemaphoreW_ReleaseSemaphore/test2/CreateSemaphore.cpp b/src/pal/tests/palsuite/threading/CreateSemaphoreW_ReleaseSemaphore/test2/CreateSemaphore.cpp deleted file mode 100644 index 62532737a..000000000 --- a/src/pal/tests/palsuite/threading/CreateSemaphoreW_ReleaseSemaphore/test2/CreateSemaphore.cpp +++ /dev/null @@ -1,314 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source: CreateSemaphoreW_ReleaseSemaphore/test1/CreateSemaphore.c -** -** Purpose: Test Semaphore operation using classic IPC problem: -** "Producer-Consumer Problem". -** -** Dependencies: CreateThread -** ReleaseSemaphore -** WaitForSingleObject -** Sleep -** fflush -** - -** -**=========================================================*/ - -#define UNICODE -#include - -#define PRODUCTION_TOTAL 26 - -#define _BUF_SIZE 10 - -DWORD dwThreadId; /* consumer thread identifier */ - -HANDLE hThread; /* handle to consumer thread */ - -HANDLE hSemaphoreM; /* handle to mutual exclusion semaphore */ - -HANDLE hSemaphoreE; /* handle to semaphore that counts empty buffer slots */ - -HANDLE hSemaphoreF; /* handle to semaphore that counts full buffer slots */ - -typedef struct Buffer -{ - short readIndex; - short writeIndex; - CHAR message[_BUF_SIZE]; - -} BufferStructure; - -CHAR producerItems[PRODUCTION_TOTAL + 1]; - -CHAR consumerItems[PRODUCTION_TOTAL + 1]; - -/* - * Read next message from the Buffer into provided pointer. - * Returns: 0 on failure, 1 on success. - */ -int -readBuf(BufferStructure *Buffer, char *c) -{ - if( Buffer -> writeIndex == Buffer -> readIndex ) - { - return 0; - } - *c = Buffer -> message[Buffer -> readIndex++]; - Buffer -> readIndex %= _BUF_SIZE; - return 1; -} - -/* - * Write message generated by the producer to Buffer. - * Returns: 0 on failure, 1 on success. - */ -int -writeBuf(BufferStructure *Buffer, CHAR c) -{ - if( ( ((Buffer -> writeIndex) + 1) % _BUF_SIZE) == - (Buffer -> readIndex) ) - { - return 0; - } - Buffer -> message[Buffer -> writeIndex++] = c; - Buffer -> writeIndex %= _BUF_SIZE; - return 1; -} - -/* - * Atomic decrement of semaphore value. - */ -VOID -down(HANDLE hSemaphore) -{ - switch ( (WaitForSingleObject ( - hSemaphore, - 10000))) - { - case WAIT_OBJECT_0: /* - * Semaphore was signaled. OK to access semaphore. - */ - break; - case WAIT_ABANDONED: /* - * Object was mutex object whose owning - * thread has terminated. Shouldn't occur. - */ - Fail("WaitForSingleObject call returned 'WAIT_ABANDONED'.\n" - "Failing Test.\n"); - break; - case WAIT_FAILED: /* WaitForSingleObject function failed */ - Fail("WaitForSingleObject call returned 'WAIT_FAILED'.\n" - "GetLastError returned %d\nFailing Test.\n",GetLastError()); - break; - default: - Fail("WaitForSingleObject call returned an unexpected value.\n" - "Failing Test.\n"); - break; - } - -} - -/* - * Atomic increment of semaphore value. - */ -VOID -up(HANDLE hSemaphore) -{ - if (!ReleaseSemaphore ( - hSemaphore, - 1, - NULL) - ) - { - Fail("ReleaseSemaphore call failed. GetLastError returned %d\n", - GetLastError()); - } -} - -/* - * Sleep 10 milleseconds. - */ -VOID -consumerSleep(VOID) -{ - Sleep(10); -} - -/* - * Sleep 500 milleseconds. - */ -VOID -producerSleep(VOID) -{ - Sleep(500); -} - -/* - * Produce a message and write the message to Buffer. - */ -VOID -producer(BufferStructure *Buffer) -{ - - int n = 0; - char c; - - while (n < PRODUCTION_TOTAL) - { - c = 'A' + n ; /* Produce Item */ - - down(hSemaphoreE); - down(hSemaphoreM); - - if (writeBuf(Buffer, c)) - { - Trace("Producer produces %c.\n", c); - fflush(stdout); - producerItems[n++] = c; - } - - up(hSemaphoreM); - up(hSemaphoreF); - - producerSleep(); - } - return; -} - -/* - * Read and "Consume" the messages in Buffer. - */ -DWORD -PALAPI -consumer( LPVOID lpParam ) -{ - int n = 0; - char c; - - consumerSleep(); - - while (n < PRODUCTION_TOTAL) - { - - down(hSemaphoreF); - down(hSemaphoreM); - - if (readBuf((BufferStructure*)lpParam, &c)) - { - Trace("\tConsumer consumes %c.\n", c); - fflush(stdout); - consumerItems[n++] = c; - } - - up(hSemaphoreM); - up(hSemaphoreE); - - consumerSleep(); - } - return 0; -} - -int __cdecl main (int argc, char **argv) -{ - - BufferStructure Buffer, *pBuffer; - - pBuffer = &Buffer; - - if(0 != (PAL_Initialize(argc, argv))) - { - return (FAIL); - } - - /* - * Create Semaphores - */ - hSemaphoreM = CreateSemaphoreW ( - NULL, - 1, - 1, - NULL); - - if ( NULL == hSemaphoreM ) - { - Fail ( "hSemaphoreM = CreateSemaphoreW () - returned NULL\n" - "Failing Test.\n"); - } - - hSemaphoreE = CreateSemaphoreW ( - NULL, - _BUF_SIZE , - _BUF_SIZE , - NULL); - - if ( NULL == hSemaphoreE ) - { - Fail ( "hSemaphoreE = CreateSemaphoreW () - returned NULL\n" - "Failing Test.\n"); - } - - hSemaphoreF = CreateSemaphoreW ( - NULL, - 0, - _BUF_SIZE , - NULL); - - if ( NULL == hSemaphoreF ) - { - Fail ( "hSemaphoreF = CreateSemaphoreW () - returned NULL\n" - "Failing Test.\n"); - } - - /* - * Initialize Buffer - */ - pBuffer->writeIndex = pBuffer->readIndex = 0; - - /* - * Create Consumer - */ - hThread = CreateThread( - NULL, - 0, - consumer, - &Buffer, - 0, - &dwThreadId); - - if ( NULL == hThread ) - { - Fail ( "CreateThread() returned NULL. Failing test.\n"); - } - - /* - * Start producing - */ - producer(pBuffer); - - /* - * Wait for consumer to complete - */ - WaitForSingleObject (hThread, INFINITE); - - if ( 0 != strncmp (producerItems, consumerItems, PRODUCTION_TOTAL) ) - { - Fail("The producerItems string %s\n and the consumerItems string " - "%s\ndo not match. This could be a problem with the strncmp()" - " function\n FailingTest\nGetLastError() returned %d\n", - producerItems, consumerItems, GetLastError()); - } - - Trace ("producerItems and consumerItems arrays match. All %d\nitems " - "were produced and consumed in order.\nTest passed.\n", - PRODUCTION_TOTAL); - - PAL_Terminate(); - return ( PASS ); - -} diff --git a/src/pal/tests/palsuite/threading/CreateSemaphoreW_ReleaseSemaphore/test2/testinfo.dat b/src/pal/tests/palsuite/threading/CreateSemaphoreW_ReleaseSemaphore/test2/testinfo.dat deleted file mode 100644 index 32b107fd9..000000000 --- a/src/pal/tests/palsuite/threading/CreateSemaphoreW_ReleaseSemaphore/test2/testinfo.dat +++ /dev/null @@ -1,18 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = threading -Function = CreateSemaphoreW / ReleaseSemaphore -Name = Positive Test for CreateSemaphoreW and ReleaseSemaphore -TYPE = DEFAULT -EXE1 = createsemaphore -Description -= Implementation of Producer / Consumer IPC problem using CreateSemaphoreW -= and ReleaseSemaphore functions. This test case exercises CreateSemaphoreW -= , ReleaseSemaphore, CreateThread and WaitForSingleObject functions. -= Since there is no way to currently create "pseudo" random events in the -= pal, this example does not behave as classic bounded buffers would. This -= test case is designed to starve the producer and have the consumer fill -= the buffer. diff --git a/src/pal/tests/palsuite/threading/CreateSemaphoreW_ReleaseSemaphore/test3/CMakeLists.txt b/src/pal/tests/palsuite/threading/CreateSemaphoreW_ReleaseSemaphore/test3/CMakeLists.txt deleted file mode 100644 index 6e12df92b..000000000 --- a/src/pal/tests/palsuite/threading/CreateSemaphoreW_ReleaseSemaphore/test3/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - createsemaphore.cpp -) - -add_executable(paltest_createsemaphorew_releasesemaphore_test3 - ${SOURCES} -) - -add_dependencies(paltest_createsemaphorew_releasesemaphore_test3 coreclrpal) - -target_link_libraries(paltest_createsemaphorew_releasesemaphore_test3 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/CreateSemaphoreW_ReleaseSemaphore/test3/createsemaphore.cpp b/src/pal/tests/palsuite/threading/CreateSemaphoreW_ReleaseSemaphore/test3/createsemaphore.cpp deleted file mode 100644 index ea0a5e084..000000000 --- a/src/pal/tests/palsuite/threading/CreateSemaphoreW_ReleaseSemaphore/test3/createsemaphore.cpp +++ /dev/null @@ -1,201 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: createsemaphorew_releasesemaphore/test3/createsemaphore.c -** -** Purpose: Test attributes of CreateSemaphoreW and ReleaseSemaphore. -** Insure for CreateSemaphore that lInitialCount and lMaximumCount -** constraints are respected. Validate that CreateSemaphore rejects -** conditions where initial count and / or maximum count are negative -** and conditions where the initial count is greater than the maximum -** count. For ReleaseSemaphore validate that lpPreviousCount gets set -** to the previous semaphore count and lpPreviousCount can be NULL. -** Also establish ReleaseSemaphore fails when called in a semaphore -** with count equal to lMaximumCount. -** -** -**==========================================================================*/ - -#include - -struct testcase -{ - LPSECURITY_ATTRIBUTES lpSemaphoreAttributes; - LONG lInitialCount; - LONG lMaximumCount; - LPCWSTR lpName; - BOOL bNegativeTest; -}; - -struct testcase testCases[] = -{ - {NULL, -1, 1, NULL, TRUE}, - {NULL, 1, -1, NULL, TRUE}, - {NULL, -1, -1, NULL, TRUE}, - {NULL, 2, 1, NULL, TRUE}, - {NULL, 1, 2, NULL, FALSE}, - {NULL, 0, 10, NULL, FALSE}, - {NULL, INT_MAX - 1, INT_MAX, NULL, FALSE}, - {NULL, INT_MAX, INT_MAX, NULL, FALSE} -}; - -HANDLE hSemaphore[sizeof(testCases)/sizeof(struct testcase)]; - -BOOL cleanup(int index) -{ - int i; - BOOL bRet = TRUE; - for (i = 0; i < index; i++) - { - if (!CloseHandle(hSemaphore[i])) - { - bRet = FALSE; - Trace("PALSUITE ERROR: CloseHandle(%p) call failed for index %d\n", - hSemaphore[i], i); - } - } - return(bRet); -} - -int __cdecl main (int argc, char **argv) -{ - int i; - int j; - - if(0 != (PAL_Initialize(argc, argv))) - { - return (FAIL); - } - /* create semaphores */ - for (i = 0; i < sizeof(testCases)/sizeof(struct testcase); i++) - { - hSemaphore[i] = CreateSemaphoreW (testCases[i].lpSemaphoreAttributes, - testCases[i].lInitialCount, - testCases[i].lMaximumCount, - testCases[i].lpName); - - if (NULL == hSemaphore[i]) - { - if (!testCases[i].bNegativeTest) - { - Trace("PALSUITE ERROR: CreateSemaphoreW('%p' '%ld' '%ld' " - "'%p') returned NULL at index %d.\nGetLastError " - "returned %d.\n", testCases[i].lpSemaphoreAttributes, - testCases[i].lInitialCount, testCases[i].lMaximumCount, - testCases[i].lpName, i, GetLastError()); - if (i > 0) - { - cleanup(i - 1); - } - Fail(""); - } - else - { - continue; - } - } - - /* increment semaphore count to lMaximumCount */ - for (j = testCases[i].lInitialCount; (ULONG)j <= (ULONG)testCases[i].lMaximumCount; - j++) - { - if (testCases[i].lMaximumCount == j) - { - /* Call ReleaseSemaphore once more to ensure ReleaseSemaphore - fails */ - if(ReleaseSemaphore(hSemaphore[i], 1, NULL)) - { - Trace("PALSUITE ERROR: ReleaseSemaphore('%p' '%ld' '%p') " - "call returned %d\nwhen it should have returned " - "%d.\nThe semaphore's count was %d.\nGetLastError " - "returned %d.\n", hSemaphore[i], 1, NULL, TRUE, - FALSE, j, GetLastError()); - cleanup(i); - Fail(""); - } - } - else - { - int previous; - BOOL bRet = ReleaseSemaphore(hSemaphore[i], 1, &previous); - DWORD dwError = GetLastError(); - - if(!bRet) - { - Trace("PALSUITE ERROR: ReleaseSemaphore('%p' '%ld' '%p') " - "call returned %d\nwhen it should have returned " - "%d.\nThe semaphore count was %d and it's " - "lMaxCount was %d.\nGetLastError returned %d.\n", - hSemaphore[i], 1, &previous, bRet, TRUE, j, - testCases[i].lMaximumCount, dwError); - cleanup(i); - Fail(""); - } - if (previous != j) - { - Trace("PALSUITE ERROR: ReleaseSemaphore('%p' '%ld' '%p') " - "call set %p to %d instead of %d.\n The semaphore " - "count was %d and GetLastError returned %d.\n", - hSemaphore[i], 1, &previous, &previous, previous, - j, j, dwError); - cleanup(i); - Fail(""); - } - } - } - - // Skip exhaustive decrement tests for too large an initial count - if(testCases[i].lInitialCount >= INT_MAX - 1) - { - continue; - } - - /* decrement semaphore count to 0 */ - for (j = testCases[i].lMaximumCount; j >= 0; j--) - { - DWORD dwRet = WaitForSingleObject(hSemaphore[i], 0); - DWORD dwError = GetLastError(); - - if (0 == j) - { - /* WaitForSingleObject should report that the - semaphore is nonsignaled */ - if (WAIT_TIMEOUT != dwRet) - { - Trace("PALSUITE ERROR: WaitForSingleObject('%p' '%u') " - "call returned %d\nwhen it should have returned " - "%d.\nThe semaphore's count was %d.\nGetLastError " - "returned %d.\n", hSemaphore[i], 0, dwRet, - WAIT_TIMEOUT, j, dwError); - cleanup(i); - Fail(""); - } - } - else - { - /* WaitForSingleObject should report that the - semaphore is signaled */ - if (WAIT_OBJECT_0 != dwRet) - { - Trace("PALSUITE ERROR: WaitForSingleObject('%p' '%u') " - "call returned %d\nwhen it should have returned " - "%d.\nThe semaphore's count was %d.\nGetLastError " - "returned %d.\n", hSemaphore[i], 0, dwRet, - WAIT_OBJECT_0, j, dwError); - cleanup(i); - Fail(""); - } - } - } - } - PAL_Terminate(); - return (PASS); -} - - - - - diff --git a/src/pal/tests/palsuite/threading/CreateSemaphoreW_ReleaseSemaphore/test3/testinfo.dat b/src/pal/tests/palsuite/threading/CreateSemaphoreW_ReleaseSemaphore/test3/testinfo.dat deleted file mode 100644 index beaac95f9..000000000 --- a/src/pal/tests/palsuite/threading/CreateSemaphoreW_ReleaseSemaphore/test3/testinfo.dat +++ /dev/null @@ -1,20 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = threading -Function = CreateSemaphoreW / ReleaseSemaphore -Name = Positive Test for CreateSemaphoreW and ReleaseSemaphore -TYPE = DEFAULT -EXE1 = createsemaphore -Description -= Test attributes of CreateSemaphoreW and ReleaseSemaphore. -= Insure for CreateSemaphore that lInitialCount and lMaximumCount -= constraints are respected. Validate that CreateSemaphore rejects -= conditions where, initial count and / or maximum count are negative -= and conditions where the initial count is greater than the maximum -= count. For ReleaseSemaphore validate that lpPreviousCount gets set -= to the previous semaphore count and lpPreviousCount can be NULL. -= Also establish ReleaseSemaphore fails when called in a semaphore -= with count equal to lMaximumCount. diff --git a/src/pal/tests/palsuite/threading/CreateThread/CMakeLists.txt b/src/pal/tests/palsuite/threading/CreateThread/CMakeLists.txt deleted file mode 100644 index 1962ade35..000000000 --- a/src/pal/tests/palsuite/threading/CreateThread/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) -add_subdirectory(test3) - diff --git a/src/pal/tests/palsuite/threading/CreateThread/test1/CMakeLists.txt b/src/pal/tests/palsuite/threading/CreateThread/test1/CMakeLists.txt deleted file mode 100644 index e190800e3..000000000 --- a/src/pal/tests/palsuite/threading/CreateThread/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_createthread_test1 - ${SOURCES} -) - -add_dependencies(paltest_createthread_test1 coreclrpal) - -target_link_libraries(paltest_createthread_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/CreateThread/test1/test1.cpp b/src/pal/tests/palsuite/threading/CreateThread/test1/test1.cpp deleted file mode 100644 index 4084e1f9c..000000000 --- a/src/pal/tests/palsuite/threading/CreateThread/test1/test1.cpp +++ /dev/null @@ -1,115 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source: test1.c -** -** Purpose: Test for CreateThread. Call CreateThread and ensure -** that it succeeds. Also check to ensure the paramater is passed -** properly. -** -** -**=========================================================*/ - -#include - -#define LLFORMAT "%llu" - -ULONGLONG dwCreateThreadTestParameter = 0; - -DWORD PALAPI CreateThreadTestThread( LPVOID lpParameter) -{ - DWORD dwRet = 0; - - /* save parameter for test */ - dwCreateThreadTestParameter = (ULONGLONG)lpParameter; - - return dwRet; -} - -BOOL CreateThreadTest() -{ - BOOL bRet = FALSE; - DWORD dwRet = 0; - - LPSECURITY_ATTRIBUTES lpThreadAttributes = NULL; - DWORD dwStackSize = 0; - LPTHREAD_START_ROUTINE lpStartAddress = &CreateThreadTestThread; - LPVOID lpParameter = (LPVOID)lpStartAddress; - DWORD dwCreationFlags = 0; /* run immediately */ - DWORD dwThreadId = 0; - - HANDLE hThread = 0; - - dwCreateThreadTestParameter = 0; - - /* Create a thread, passing the appropriate paramaters as declared - above. - */ - - hThread = CreateThread( lpThreadAttributes, - dwStackSize, - lpStartAddress, - lpParameter, - dwCreationFlags, - &dwThreadId ); - - /* Ensure that the HANDLE is not invalid! */ - if (hThread != INVALID_HANDLE_VALUE) - { - dwRet = WaitForSingleObject(hThread,INFINITE); - - if (dwRet != WAIT_OBJECT_0) - { - Trace("CreateThreadTest:WaitForSingleObject " - "failed (%x)\n",GetLastError()); - } - else - { - /* Check to ensure that the parameter passed to the thread - function is the same in the function as what we passed. - */ - - if (dwCreateThreadTestParameter != (ULONGLONG)lpParameter) - { - Trace("CreateThreadTest:parameter error. The " - "parameter passed should have been " LLFORMAT " but when " - "passed to the Thread function it was " LLFORMAT " . GetLastError[%x]\n", - dwCreateThreadTestParameter,lpParameter, GetLastError()); - } - else - { - bRet = TRUE; - } - - } - CloseHandle(hThread); - } - else - { - Trace("CreateThreadTest:CreateThread failed (%x)\n",GetLastError()); - } - - return bRet; -} - - -int __cdecl main(int argc, char **argv) -{ - if(0 != (PAL_Initialize(argc, argv))) - { - return ( FAIL ); - } - - if(!CreateThreadTest()) - { - Fail ("Test failed\n"); - } - - Trace("Test Passed\n"); - PAL_Terminate(); - return ( PASS ); - -} diff --git a/src/pal/tests/palsuite/threading/CreateThread/test1/testinfo.dat b/src/pal/tests/palsuite/threading/CreateThread/test1/testinfo.dat deleted file mode 100644 index 3ae70625c..000000000 --- a/src/pal/tests/palsuite/threading/CreateThread/test1/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = threading -Function = CreateThread -Name = Positive Test for CreateThread -TYPE = DEFAULT -EXE1 = test1 -Description -= Test for CreateThread. Call CreateThread and ensure -= that it succeeds. Also check to ensure the paramater is passed -= properly. diff --git a/src/pal/tests/palsuite/threading/CreateThread/test2/CMakeLists.txt b/src/pal/tests/palsuite/threading/CreateThread/test2/CMakeLists.txt deleted file mode 100644 index aed986fd5..000000000 --- a/src/pal/tests/palsuite/threading/CreateThread/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test2.cpp -) - -add_executable(paltest_createthread_test2 - ${SOURCES} -) - -add_dependencies(paltest_createthread_test2 coreclrpal) - -target_link_libraries(paltest_createthread_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/CreateThread/test2/test2.cpp b/src/pal/tests/palsuite/threading/CreateThread/test2/test2.cpp deleted file mode 100644 index 1ee410a6c..000000000 --- a/src/pal/tests/palsuite/threading/CreateThread/test2/test2.cpp +++ /dev/null @@ -1,184 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*=========================================================== -** -** Source: test2.c -** -** Purpose: Test that lpThreadId is assigned the correct -** threadId value and that lpThreadId can be NULL. -** -** -**=========================================================*/ - -#include - -#define NUM_TESTS 3 - -HANDLE hThread[NUM_TESTS]; -DWORD dwThreadId[NUM_TESTS]; -volatile BOOL bResult[NUM_TESTS]; -volatile DWORD dwThreadId1[NUM_TESTS]; - -DWORD PALAPI Thread( LPVOID lpParameter) -{ - dwThreadId1[(DWORD) lpParameter] = GetCurrentThreadId(); - bResult[(DWORD) lpParameter] = TRUE; - return (DWORD) lpParameter; -} - -struct testCase -{ - LPSECURITY_ATTRIBUTES lpThreadAttributes; - DWORD dwStackSize; - LPTHREAD_START_ROUTINE lpStartAddress; - DWORD dwCreationFlags; - LPDWORD lpThreadId; -}; - -struct testCase testCases[]= -{ - {NULL, 0, &Thread, 0, NULL}, - {NULL, 0, &Thread, CREATE_SUSPENDED, NULL}, - {NULL, 0, &Thread, 0, (LPDWORD) 1} -}; - -/* - * close handles - */ -BOOL cleanup(int index) -{ - int i; - BOOL bRet = TRUE; - - for (i = 0; i < index; i++) - { - if (!CloseHandle(hThread[i])) - { - bRet = FALSE; - Trace("PALSUITE ERROR: CloseHandle(%p) call failed for index %d\n", - hThread[i], i); - } - } - - return(bRet); -} - -int __cdecl main(int argc, char **argv) -{ - SIZE_T i; - DWORD dwRetWFSO; - DWORD dwRetRT; - BOOL bRet = TRUE; - - if(0 != (PAL_Initialize(argc, argv))) - { - return (FAIL); - } - - /* set results array to FALSE */ - for (i = 0; i < NUM_TESTS; i++) - { - bResult[i]=FALSE; - dwThreadId[i]=0; - } - - for (i = 0; i < NUM_TESTS; i++) - { - if (NULL != testCases[i].lpThreadId) - { - testCases[i].lpThreadId = &dwThreadId[i]; - } - /* pass the index as the thread argument */ - hThread[i] = CreateThread( testCases[i].lpThreadAttributes, - testCases[i].dwStackSize, - testCases[i].lpStartAddress, - (LPVOID)i, - testCases[i].dwCreationFlags, - testCases[i].lpThreadId); - if (hThread[i] == NULL) - { - Trace("PALSUITE ERROR: CreateThread('%p' '%d' '%p' '%p' '%d' " - "'%p') call failed.\nGetLastError returned '%u'.\n", - testCases[i].lpThreadAttributes, testCases[i].dwStackSize, - testCases[i].lpStartAddress, (LPVOID)i, - testCases[i].dwCreationFlags, - testCases[i].lpThreadId, GetLastError()); - cleanup(i - 1); - Fail(""); - } - - /* Resume suspended threads */ - if (testCases[i].dwCreationFlags == CREATE_SUSPENDED) - { - dwRetRT = ResumeThread (hThread[i]); - if (dwRetRT != 1) - { - Trace ("PALSUITE ERROR: ResumeThread(%p) " - "call returned %d it should have returned %d.\n" - "GetLastError returned %u.\n", hThread[i], dwRetRT, - 1, GetLastError()); - cleanup(i); - Fail(""); - } - } - } - - /* cleanup */ - for (i = 0; i < NUM_TESTS; i++) - { - dwRetWFSO = WaitForSingleObject(hThread[i], 10000); - if (dwRetWFSO != WAIT_OBJECT_0) - { - Trace ("PALSUITE ERROR: WaitForSingleObject('%p' '%d') " - "call returned %d instead of WAIT_OBJECT_0 ('%d').\n" - "GetLastError returned %u.\n", hThread[i], 10000, - dwRetWFSO, WAIT_OBJECT_0, GetLastError()); - cleanup(i); - Fail(""); - } - } - if(!cleanup(NUM_TESTS)) - { - Fail(""); - } - - for (i = 0; i < NUM_TESTS; i++) - { - /* - * check to see that all threads were created and were passed - * the array index as an argument. - */ - if (FALSE == bResult[i]) - { - bRet = FALSE; - Trace("PALSUITE ERROR: result[%d]=%d. It should be %d\n", i, - FALSE, TRUE); - } - /* - * check to see that lpThreadId received the correct value. - */ - if (0 != dwThreadId[i]) - { - if (dwThreadId[i] != dwThreadId1[i]) - { - bRet = FALSE; - Trace("PALSUITE ERROR: dwThreadId[%d]=%p and dwThreadId1[%d]" - "=%p\nThese values should be identical.\n", i, - dwThreadId[i], i, dwThreadId1[i]); - } - } - } - if (!bRet) - { - cleanup(NUM_TESTS); - Fail(""); - } - - PAL_Terminate(); - return (PASS); -} - - - diff --git a/src/pal/tests/palsuite/threading/CreateThread/test2/testinfo.dat b/src/pal/tests/palsuite/threading/CreateThread/test2/testinfo.dat deleted file mode 100644 index 0333beb36..000000000 --- a/src/pal/tests/palsuite/threading/CreateThread/test2/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = threading -Function = CreateThread -Name = Positive Test for CreateThread -TYPE = DEFAULT -EXE1 = test2 -Description -= Test that lpThreadId is assigned the correct threadId value and -= that lpThreadId can be NULL. diff --git a/src/pal/tests/palsuite/threading/CreateThread/test3/CMakeLists.txt b/src/pal/tests/palsuite/threading/CreateThread/test3/CMakeLists.txt deleted file mode 100644 index 398666525..000000000 --- a/src/pal/tests/palsuite/threading/CreateThread/test3/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test3.cpp -) - -add_executable(paltest_createthread_test3 - ${SOURCES} -) - -add_dependencies(paltest_createthread_test3 coreclrpal) - -target_link_libraries(paltest_createthread_test3 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/CreateThread/test3/test3.cpp b/src/pal/tests/palsuite/threading/CreateThread/test3/test3.cpp deleted file mode 100644 index 0c44d1fdd..000000000 --- a/src/pal/tests/palsuite/threading/CreateThread/test3/test3.cpp +++ /dev/null @@ -1,101 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*=========================================================== -** -** Source: test3.c -** -** Purpose: Check to see that the handle CreateThread returns -** can be closed while the thread is still running. -** -** -**=========================================================*/ - -#include - -HANDLE hThread; -HANDLE hEvent; - -DWORD PALAPI Thread( LPVOID lpParameter) -{ - DWORD dwRet; - dwRet = WaitForSingleObject(hEvent, INFINITE); - /* if this thread continues beyond here, fail */ - Fail(""); - - return 0; -} - -int __cdecl main(int argc, char **argv) -{ - DWORD dwThreadId; - DWORD dwRet; - - if(0 != (PAL_Initialize(argc, argv))) - { - return (FAIL); - } - - hEvent = CreateEvent(NULL, TRUE, FALSE, NULL); - - if (hEvent == NULL) - { - Fail("PALSUITE ERROR: CreateEvent call #0 failed. GetLastError " - "returned %u.\n", GetLastError()); - } - - /* pass the index as the thread argument */ - hThread = CreateThread( NULL, - 0, - &Thread, - (LPVOID) 0, - 0, - &dwThreadId); - if (hThread == NULL) - { - Trace("PALSUITE ERROR: CreateThread('%p' '%d' '%p' '%p' '%d' '%p') " - "call failed.\nGetLastError returned '%u'.\n", NULL, - 0, &Thread, (LPVOID) 0, 0, &dwThreadId, GetLastError()); - if (0 == CloseHandle(hEvent)) - { - Trace("PALSUITE ERROR: Unable to execute CloseHandle(%p) during " - "clean up.\nGetLastError returned '%u'.\n", hEvent); - } - Fail(""); - } - - dwRet = WaitForSingleObject(hThread, 10000); - if (dwRet != WAIT_TIMEOUT) - { - Trace ("PALSUITE ERROR: WaitForSingleObject('%p' '%d') " - "call returned %d instead of WAIT_TIMEOUT ('%d').\n" - "GetLastError returned '%u'.\n", hThread, 10000, - dwRet, WAIT_TIMEOUT, GetLastError()); - Fail(""); - } - - if (0 == CloseHandle(hThread)) - { - Trace("PALSUITE ERROR: Unable to CloseHandle(%p) on a running thread." - "\nGetLastError returned '%u'.\n", hThread, GetLastError()); - if (0 == CloseHandle(hEvent)) - { - Trace("PALSUITE ERROR: Unable to execute CloseHandle(%p) during " - "cleanup.\nGetLastError returned '%u'.\n", hEvent, - GetLastError()); - } - Fail(""); - } - if (0 == CloseHandle(hEvent)) - { - Trace("PALSUITE ERROR: Unable to execute CloseHandle(%p) during " - "cleanup.\nGetLastError returned '%u'.\n", hEvent, - GetLastError()); - Fail(""); - } - - PAL_Terminate(); - return (PASS); -} - diff --git a/src/pal/tests/palsuite/threading/CreateThread/test3/testinfo.dat b/src/pal/tests/palsuite/threading/CreateThread/test3/testinfo.dat deleted file mode 100644 index 712c3a665..000000000 --- a/src/pal/tests/palsuite/threading/CreateThread/test3/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = threading -Function = CreateThread -Name = Positive Test for CreateThread -TYPE = DEFAULT -EXE1 = test3 -Description -= Check to see that the handle CreateThread returns can be closed while -= the thread is still running. - diff --git a/src/pal/tests/palsuite/threading/CriticalSectionFunctions/CMakeLists.txt b/src/pal/tests/palsuite/threading/CriticalSectionFunctions/CMakeLists.txt deleted file mode 100644 index b7c6e394b..000000000 --- a/src/pal/tests/palsuite/threading/CriticalSectionFunctions/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) -add_subdirectory(test3) -add_subdirectory(test4) -add_subdirectory(test5) -add_subdirectory(test6) -add_subdirectory(test7) -add_subdirectory(test8) - diff --git a/src/pal/tests/palsuite/threading/CriticalSectionFunctions/test1/CMakeLists.txt b/src/pal/tests/palsuite/threading/CriticalSectionFunctions/test1/CMakeLists.txt deleted file mode 100644 index 204b316b2..000000000 --- a/src/pal/tests/palsuite/threading/CriticalSectionFunctions/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - InitializeCriticalSection.cpp -) - -add_executable(paltest_criticalsectionfunctions_test1 - ${SOURCES} -) - -add_dependencies(paltest_criticalsectionfunctions_test1 coreclrpal) - -target_link_libraries(paltest_criticalsectionfunctions_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/CriticalSectionFunctions/test1/InitializeCriticalSection.cpp b/src/pal/tests/palsuite/threading/CriticalSectionFunctions/test1/InitializeCriticalSection.cpp deleted file mode 100644 index f294cea47..000000000 --- a/src/pal/tests/palsuite/threading/CriticalSectionFunctions/test1/InitializeCriticalSection.cpp +++ /dev/null @@ -1,235 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source: criticalsectionfunctions/test1/initializecriticalsection.c -** -** Purpose: Test Semaphore operation using classic IPC problem: -** "Producer-Consumer Problem". -** -** Dependencies: CreateThread -** InitializeCriticalSection -** EnterCriticalSection -** LeaveCriticalSection -** DeleteCriticalSection -** WaitForSingleObject -** Sleep -** - -** -**=========================================================*/ - -#include - -#define PRODUCTION_TOTAL 26 - -#define _BUF_SIZE 10 - -DWORD dwThreadId; /* consumer thread identifier */ - -HANDLE hThread; /* handle to consumer thread */ - -CRITICAL_SECTION CriticalSectionM; /* Critical Section Object (used as mutex) */ - -typedef struct Buffer -{ - short readIndex; - short writeIndex; - CHAR message[_BUF_SIZE]; - -} BufferStructure; - -CHAR producerItems[PRODUCTION_TOTAL + 1]; - -CHAR consumerItems[PRODUCTION_TOTAL + 1]; - -/* - * Read next message from the Buffer into provided pointer. - * Returns: 0 on failure, 1 on success. - */ -int -readBuf(BufferStructure *Buffer, char *c) -{ - if( Buffer -> writeIndex == Buffer -> readIndex ) - { - return 0; - } - *c = Buffer -> message[Buffer -> readIndex++]; - Buffer -> readIndex %= _BUF_SIZE; - return 1; -} - -/* - * Write message generated by the producer to Buffer. - * Returns: 0 on failure, 1 on success. - */ -int -writeBuf(BufferStructure *Buffer, CHAR c) -{ - if( ( ((Buffer -> writeIndex) + 1) % _BUF_SIZE) == - (Buffer -> readIndex) ) - { - return 0; - } - Buffer -> message[Buffer -> writeIndex++] = c; - Buffer -> writeIndex %= _BUF_SIZE; - return 1; -} - -/* - * Sleep 500 milleseconds. - */ -VOID -consumerSleep(VOID) -{ - Sleep(500); -} - -/* - * Sleep between 10 milleseconds. - */ -VOID -producerSleep(VOID) -{ - Sleep(10); -} - -/* - * Produce a message and write the message to Buffer. - */ -VOID -producer(BufferStructure *Buffer) -{ - - int n = 0; - char c; - - while (n < PRODUCTION_TOTAL) - { - c = 'A' + n ; /* Produce Item */ - - EnterCriticalSection(&CriticalSectionM); - - if (writeBuf(Buffer, c)) - { - printf("Producer produces %c.\n", c); - producerItems[n++] = c; - } - - LeaveCriticalSection(&CriticalSectionM); - - producerSleep(); - } - - return; -} - -/* - * Read and "Consume" the messages in Buffer. - */ -DWORD -PALAPI -consumer( LPVOID lpParam ) -{ - int n = 0; - char c; - - consumerSleep(); - - while (n < PRODUCTION_TOTAL) - { - - EnterCriticalSection(&CriticalSectionM); - - if (readBuf((BufferStructure*)lpParam, &c)) - { - printf("\tConsumer consumes %c.\n", c); - consumerItems[n++] = c; - } - - LeaveCriticalSection(&CriticalSectionM); - - consumerSleep(); - } - - return 0; -} - -int __cdecl main (int argc, char **argv) -{ - - BufferStructure Buffer, *pBuffer; - - pBuffer = &Buffer; - - if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - /* - * Create mutual exclusion mechanisms - */ - - InitializeCriticalSection ( &CriticalSectionM ); - - /* - * Initialize Buffer - */ - pBuffer->writeIndex = pBuffer->readIndex = 0; - - - - /* - * Create Consumer - */ - hThread = CreateThread( - NULL, - 0, - consumer, - &Buffer, - 0, - &dwThreadId); - - if ( NULL == hThread ) - { - Fail ( "CreateThread() returned NULL. Failing test.\n" - "GetLastError returned %d\n", GetLastError()); - } - - /* - * Start producing - */ - producer(pBuffer); - - /* - * Wait for consumer to complete - */ - WaitForSingleObject (hThread, INFINITE); - - /* - * Compare items produced vs. items consumed - */ - if ( 0 != strncmp (producerItems, consumerItems, PRODUCTION_TOTAL) ) - { - Fail("The producerItems string %s\n and the consumerItems string " - "%s\ndo not match. This could be a problem with the strncmp()" - " function\n FailingTest\nGetLastError() returned %d\n", - producerItems, consumerItems, GetLastError()); - } - - /* - * Clean up Critical Section object - */ - DeleteCriticalSection(&CriticalSectionM); - - Trace("producerItems and consumerItems arrays match. All %d\nitems " - "were produced and consumed in order.\nTest passed.\n", - PRODUCTION_TOTAL); - - PAL_Terminate(); - return (PASS); - -} diff --git a/src/pal/tests/palsuite/threading/CriticalSectionFunctions/test1/testinfo.dat b/src/pal/tests/palsuite/threading/CriticalSectionFunctions/test1/testinfo.dat deleted file mode 100644 index 494b899b9..000000000 --- a/src/pal/tests/palsuite/threading/CriticalSectionFunctions/test1/testinfo.dat +++ /dev/null @@ -1,21 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = threading -Function = InitializeCriticalSection / EnterCriticalSection / LeaveCriticalSection / DeleteCriticalSection -Name = Positive Test for InitializeCriticalSection, EnterCriticalSection, LeaveCriticalSection and DeleteCriticalSection -TYPE = DEFAULT -EXE1 = initializecriticalsection -Description -= Implementation of Producer / Consumer IPC problem using the -= "CriticalSection" functions to provide a mutual exclusion mechanism. -= This test case exercises InitializeCriticalSection, EnterCriticalSection, -= LeaveCriticalSection, DeleteCriticalSection, and WaitForSingleObject -= functions. -= This case doesn't work with more than one producer and one consumer. -= The producer thread and consumer thread each take turns blocking on -= the CriticalSection object and do not have any other synchronization -= mechanisms. This prevents adding producers or consumers as there are -= no mechanisms to block them once the buffer is full. diff --git a/src/pal/tests/palsuite/threading/CriticalSectionFunctions/test2/CMakeLists.txt b/src/pal/tests/palsuite/threading/CriticalSectionFunctions/test2/CMakeLists.txt deleted file mode 100644 index dba47f6ee..000000000 --- a/src/pal/tests/palsuite/threading/CriticalSectionFunctions/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test2.cpp -) - -add_executable(paltest_criticalsectionfunctions_test2 - ${SOURCES} -) - -add_dependencies(paltest_criticalsectionfunctions_test2 coreclrpal) - -target_link_libraries(paltest_criticalsectionfunctions_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/CriticalSectionFunctions/test2/test2.cpp b/src/pal/tests/palsuite/threading/CriticalSectionFunctions/test2/test2.cpp deleted file mode 100644 index 47659a1c1..000000000 --- a/src/pal/tests/palsuite/threading/CriticalSectionFunctions/test2/test2.cpp +++ /dev/null @@ -1,226 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source: CriticalSectionFunctions/test2/test2.c -** -** Purpose: Test that we are able to nest critical section calls. -** The initial thread makes a call to EnterCriticalSection once, -** blocking on a CRITICAL_SECTION object and creates a new thread. -** The newly created thread blocks on the same CRITICAL_SECTION object. -** The first thread now makes a call to LeaveCriticalSection. -** Test to see that the new thread doesn't get unblocked. -** -** Dependencies: CreateThread -** InitializeCriticalSection -** EnterCriticalSection -** LeaveCriticalSection -** DeleteCriticalSection -** WaitForSingleObject -** - -** -**=========================================================*/ - -#include - -CRITICAL_SECTION CriticalSection; - -volatile BOOL t0_tflag = FAIL; /* thread 0 timeout flag */ -volatile BOOL t1_aflag = FAIL; /* thread 1 access flag */ -volatile BOOL t1_cflag = FAIL; /* thread 1 critical section flag */ -volatile BOOL bTestResult = FAIL; - -DWORD PALAPI Thread(LPVOID lpParam) -{ - t1_aflag = PASS; - EnterCriticalSection(&CriticalSection); - t1_cflag = PASS; - LeaveCriticalSection(&CriticalSection); - return 0; -} - -int __cdecl main (int argc, char **argv) -{ - HANDLE hThread; - DWORD dwThreadId; - DWORD dwRet; - - if(0 != (PAL_Initialize(argc, argv))) - { - return (bTestResult); - } - - /* - * Create critical section object and enter it - */ - InitializeCriticalSection ( &CriticalSection ); - EnterCriticalSection(&CriticalSection); - - /* - * Create a suspended thread - */ - hThread = CreateThread(NULL, - 0, - &Thread, - (LPVOID) NULL, - CREATE_SUSPENDED, - &dwThreadId); - - if (hThread == NULL) - { - Trace("PALSUITE ERROR: CreateThread call failed. GetLastError " - "returned %d.\n", GetLastError()); - LeaveCriticalSection(&CriticalSection); - DeleteCriticalSection(&CriticalSection); - Fail(""); - } - - EnterCriticalSection(&CriticalSection); - /* - * Set priority of the thread to greater than that of the currently - * running thread so it is guaranteed to run. - */ - dwRet = (DWORD) SetThreadPriority(hThread, THREAD_PRIORITY_ABOVE_NORMAL); - - if (0 == dwRet) - { - Trace("PALSUITE ERROR: SetThreadPriority (%p, %d) call failed.\n" - "GetLastError returned %d.\n", hThread, - THREAD_PRIORITY_NORMAL, GetLastError()); - LeaveCriticalSection(&CriticalSection); - CloseHandle(hThread); - DeleteCriticalSection(&CriticalSection); - Fail(""); - } - - dwRet = ResumeThread(hThread); - - if (-1 == dwRet) - { - Trace("PALSUITE ERROR: ResumeThread(%p) call failed.\nGetLastError " - "returned %d.\n", hThread, GetLastError()); - LeaveCriticalSection(&CriticalSection); - CloseHandle(hThread); - DeleteCriticalSection(&CriticalSection); - Fail(""); - } - /* - * Sleep until we know the thread has been invoked. This sleep in - * combination with the higher priority of the other thread should - * guarantee both threads block on the critical section. - */ - while (t1_aflag == FAIL) - { - Sleep(1); - } - - LeaveCriticalSection(&CriticalSection); - - switch ((WaitForSingleObject( - hThread, - 10000))) /* Wait 10 seconds */ - { - case WAIT_OBJECT_0: - /* Object (thread) is signaled */ - LeaveCriticalSection(&CriticalSection); - CloseHandle(hThread); - DeleteCriticalSection(&CriticalSection); - Fail("PALSUITE ERROR: WaitForSingleObject(%p,%d) should have " - "returned\nWAIT_TIMEOUT ('%d'), instead it returned " - "WAIT_OBJECT_0 ('%d').\nA nested LeaveCriticalSection(%p) " - "call released both threads that were waiting on it!\n", - hThread, 10000, WAIT_TIMEOUT, WAIT_OBJECT_0, &CriticalSection); - break; - case WAIT_ABANDONED: - /* - * Object was mutex object whose owning - * thread has terminated. Shouldn't occur. - */ - Trace("PALSUITE ERROR: WaitForSingleObject(%p,%d) should have " - "returned\nWAIT_TIMEOUT ('%d'), instead it returned " - "WAIT_ABANDONED ('%d').\nGetLastError returned '%d'\n", - hThread, 10000, WAIT_TIMEOUT, WAIT_ABANDONED, GetLastError()); - LeaveCriticalSection(&CriticalSection); - CloseHandle(hThread); - DeleteCriticalSection(&CriticalSection); - Fail(""); - break; - case WAIT_FAILED: /* WaitForSingleObject function failed */ - Trace("PALSUITE ERROR: WaitForSingleObject(%p,%d) should have " - "returned\nWAIT_TIMEOUT ('%d'), instead it returned " - "WAIT_FAILED ('%d').\nGetLastError returned '%d'\n", - hThread, 10000, WAIT_TIMEOUT, WAIT_FAILED, GetLastError()); - LeaveCriticalSection(&CriticalSection); - CloseHandle(hThread); - DeleteCriticalSection(&CriticalSection); - Fail(""); - break; - case WAIT_TIMEOUT: - /* - * We expect this thread to timeout waiting for the - * critical section object to become available. - */ - t0_tflag = PASS; - break; - } - - LeaveCriticalSection(&CriticalSection); - - if (WAIT_OBJECT_0 != WaitForSingleObject (hThread, 10000)) - { - if (0 == CloseHandle(hThread)) - { - Trace("PALSUITE ERROR: CloseHandle(%p) call failed.\n" - "WaitForSingleObject(%p,%d) should have returned " - "WAIT_OBJECT_0 ('%d').\nBoth calls failed. " - "Deleted CRITICAL_SECTION object which likely means\n" - "thread %p is now in an undefined state. GetLastError " - "returned '%d'.\n", hThread, hThread, 10000, WAIT_OBJECT_0, - hThread, GetLastError()); - DeleteCriticalSection(&CriticalSection); - Fail(""); - } - else - { - Trace("PALSUITE ERROR: WaitForSingleObject(%p,%d) should have " - "returned WAIT_OBJECT_0 ('%d').\n GetLastError returned " - "'%d'.\n", hThread, hThread, 10000, WAIT_OBJECT_0, - hThread, GetLastError()); - DeleteCriticalSection(&CriticalSection); - Fail(""); - } - } - - if (0 == CloseHandle(hThread)) - { - Trace("PALSUITE ERROR: CloseHandle(%p) call failed.\n" - "Deleted CRITICAL_SECTION object which likely means\n" - "thread %p is now in an undefined state. GetLastError " - "returned '%d'.\n", hThread, hThread, GetLastError()); - DeleteCriticalSection(&CriticalSection); - Fail(""); - - } - DeleteCriticalSection(&CriticalSection); - /* - * Ensure both thread 0 experienced a wait timeout and thread 1 - * accessed the critical section or fail the test, otherwise pass it. - */ - if ((t0_tflag == FAIL) || (t1_cflag == FAIL)) - { - Trace("PALSUITE ERROR: Thread 0 returned %d when %d was expected.\n" - "Thread 1 returned %d when %d was expected.\n", t0_tflag, - PASS, t1_cflag, PASS); - bTestResult=FAIL; - } - else - { - bTestResult=PASS; - } - - PAL_TerminateEx(bTestResult); - return (bTestResult); -} diff --git a/src/pal/tests/palsuite/threading/CriticalSectionFunctions/test2/testinfo.dat b/src/pal/tests/palsuite/threading/CriticalSectionFunctions/test2/testinfo.dat deleted file mode 100644 index 06842124b..000000000 --- a/src/pal/tests/palsuite/threading/CriticalSectionFunctions/test2/testinfo.dat +++ /dev/null @@ -1,18 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = threading -Function = CriticalSectionFunctions -Name = Positive test to ensure CRITICAL_SECTION objects can be nested -TYPE = DEFAULT -EXE1 = test2 -Description -= Test that we are able to nest critical section calls. -= The initial thread makes a call to EnterCriticalSection once, -= blocking on a CRITICAL_SECTION object and creates a new thread. -= The newly created thread blocks on the same CRITICAL_SECTION object. -= The first thread now makes a call to LeaveCriticalSection. -= Test to see that the new thread doesn't get unblocked. - diff --git a/src/pal/tests/palsuite/threading/CriticalSectionFunctions/test3/CMakeLists.txt b/src/pal/tests/palsuite/threading/CriticalSectionFunctions/test3/CMakeLists.txt deleted file mode 100644 index 599572b99..000000000 --- a/src/pal/tests/palsuite/threading/CriticalSectionFunctions/test3/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test3.cpp -) - -add_executable(paltest_criticalsectionfunctions_test3 - ${SOURCES} -) - -add_dependencies(paltest_criticalsectionfunctions_test3 coreclrpal) - -target_link_libraries(paltest_criticalsectionfunctions_test3 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/CriticalSectionFunctions/test3/test3.cpp b/src/pal/tests/palsuite/threading/CriticalSectionFunctions/test3/test3.cpp deleted file mode 100644 index d5911267b..000000000 --- a/src/pal/tests/palsuite/threading/CriticalSectionFunctions/test3/test3.cpp +++ /dev/null @@ -1,376 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: CriticalSectionFunctions/test3/test3.c -** -** Purpose: Create two threads to exercise TryEnterCriticalSection -** and EnterCriticalSection. TryEnterCriticalSection acquires -** and holds a CRITICAL_SECTION object. Another call to -** TryEnterCriticalSection is made from a different thread, at -** this time, to establish a call to TryEnterCriticalSection -** will return immediatly and to establish -** TryEnterCriticalSection returns the proper value when it -** attempts to lock a CRITICAL_SECTION that is already owned -** by another thread. The CRITICAL_SECTION object is then -** released and held by a call to EnterCriticalSection. A new -** thread is invoked and attempts to acquire the held -** CRITICAL_SECTION with a call to TryEnterCriticalSection. -** TryEnterCriticalSection returns immediatly and returns -** with the value that states the CRITICAL_SECTION object is -** held by another thread. This establishes -** TryEnterCriticalSection behaves the same way with -** CriticalSections locked by TryEnterCriticalSection and -** EnterCriticalSection. -** -** -**===================================================================*/ -#include - -#define NUM_THREADS 2 - -HANDLE hThread[NUM_THREADS]; -HANDLE hEvent[NUM_THREADS]; -CRITICAL_SECTION CriticalSection; -BOOL bRet = FAIL; - -DWORD PALAPI Thread(LPVOID lpParam) -{ - DWORD dwRet; - - if (0 == TryEnterCriticalSection(&CriticalSection)) - { - dwRet = WaitForMultipleObjects(NUM_THREADS, hEvent, TRUE, 10000); - if ((WAIT_OBJECT_0 > dwRet) || - ((WAIT_OBJECT_0 + NUM_THREADS - 1) < dwRet)) - { -#if 0 - if (0 == CloseHandle(hThread[1])) - { - Trace("PALSUITE ERROR: Unable to execute CloseHandle(%p) " - "during clean up.\nGetLastError returned '%d'.\n", - hThread[1], GetLastError()); - } -#endif - Trace("PALSUITE ERROR: WaitForMultipleObjects(%d, %p, %d, %d) call" - "returned an unexpected value, '%d'.\nGetLastError returned " - "%d.\n", NUM_THREADS, hEvent, TRUE, 10000, dwRet, - GetLastError()); - } - else - { - bRet = PASS; - } - } - else - { - /* signal thread 0 */ - if (0 == SetEvent(hEvent[0])) - { - Trace("PALSUITE ERROR: Unable to execute SetEvent(%p) during " - "clean up.\nGetLastError returned '%d'.\n", hEvent[0], - GetLastError()); - LeaveCriticalSection(&CriticalSection); - if (0 == CloseHandle(hThread[0])) - { - Trace("PALSUITE ERROR: Unable to execute CloseHandle(%p) " - "during clean up\nGetLastError returned '%d'.\n", - hThread[0], GetLastError()); - } - if (0 == CloseHandle(hEvent[0])) - { - Trace("PALSUITE ERROR: Unable to execute CloseHandle(%p) " - "during clean up\nGetLastError returned '%d'.\n", - hEvent[0], GetLastError()); - } - if (0 == CloseHandle(hEvent[1])) - { - Trace("PALSUITE ERROR: Unable to execute CloseHandle(%p) " - "during clean up\nGetLastError returned '%d'.\n", - hEvent[1], GetLastError()); - } - DeleteCriticalSection(&CriticalSection); - Fail(""); - } - - /* wait to be signaled */ - dwRet = WaitForSingleObject(hEvent[1], 10000); - if (WAIT_OBJECT_0 != dwRet) - { - Trace("PALSUITE ERROR: WaitForSingleObject(%p,%d) should have " - "returned\nWAIT_OBJECT_0 ('%d'), instead it returned " - "('%d').\nGetLastError returned '%d'.\n", - hEvent[0], 10000, WAIT_OBJECT_0, dwRet, GetLastError()); - if (0 == CloseHandle(hThread[0])) - { - Trace("PALSUITE ERROR: Unable to execute CloseHandle(%p) " - "during clean up.\nGetLastError returned '%d'.\n", - hThread[0], GetLastError()); - } - if (0 == CloseHandle(hEvent[0])) - { - Trace("PALSUITE ERROR: Unable to execute CloseHandle(%p) " - "during clean up.\nGetLastError returned '%d'.\n", - hEvent[0], GetLastError()); - } - if (0 == CloseHandle(hEvent[1])) - { - Trace("PALSUITE ERROR: Unable to execute CloseHandle(%p) " - "during clean up.\nGetLastError returned '%d.'\n", - hEvent[1], GetLastError()); - } - DeleteCriticalSection(&CriticalSection); - Fail(""); - } - LeaveCriticalSection(&CriticalSection); - } - return FAIL; -} - -int __cdecl main(int argc, char **argv) -{ - HANDLE hThread[NUM_THREADS]; - DWORD dwThreadId[NUM_THREADS]; - DWORD dwRet; - - if ((PAL_Initialize(argc,argv)) != 0) - { - return(bRet); - } - - /* thread 0 event */ - hEvent[0] = CreateEvent(NULL, TRUE, FALSE, NULL); - - if (hEvent[0] == NULL) - { - Fail("PALSUITE ERROR: CreateEvent call #0 failed. GetLastError " - "returned %d.\n", GetLastError()); - } - - /* thread 1 event */ - hEvent[1] = CreateEvent(NULL, TRUE, FALSE, NULL); - - if (hEvent[1] == NULL) - { - Trace("PALSUITE ERROR: CreateEvent call #1 failed. GetLastError " - "returned %d.\n", GetLastError()); - if (0 == CloseHandle(hEvent[0])) - { - Trace("PALSUITE ERROR: Unable to execute CloseHandle(%p) during " - "clean up.\nGetLastError returned '%d'.\n", hEvent[0]); - } - Fail(""); - } - - InitializeCriticalSection ( &CriticalSection ); - - hThread[0] = CreateThread(NULL, - 0, - &Thread, - (LPVOID) NULL, - 0, - &dwThreadId[0]); - - if (hThread[0] == NULL) - { - Trace("PALSUITE ERROR: CreateThread call #0 failed. GetLastError " - "returned %d.\n", GetLastError()); - if (0 == CloseHandle(hEvent[0])) - { - Trace("PALSUITE ERROR: Unable to execute CloseHandle(%p) during " - "clean up.\nGetLastError returned '%d'.\n", hEvent[0], - GetLastError()); - } - if (0 == CloseHandle(hEvent[1])) - { - Trace("PALSUITE ERROR: Unable to execute CloseHandle(%p) during " - "clean up.\nGetLastError returned '%d'.\n", hEvent[1], - GetLastError()); - } - DeleteCriticalSection(&CriticalSection); - Fail(""); - } - - - /* wait for thread 0 to be signaled */ - dwRet = WaitForSingleObject(hEvent[0], 10000); - if (WAIT_OBJECT_0 != dwRet) - { - Trace("PALSUITE ERROR: WaitForSingleObject(%p,%d) should have " - "returned\nWAIT_OBJECT_0 ('%d'), instead it returned " - "('%d').\nGetLastError returned '%d'.\n", hEvent[0], 10000, - WAIT_OBJECT_0, dwRet, GetLastError()); - if (0 == CloseHandle(hThread[0])) - { - Trace("PALSUITE ERROR: Unable to execute CloseHandle(%p) during " - "clean up.\nGetLastError returned '%d'.\n", hThread[0], - GetLastError()); - } - if (0 == CloseHandle(hEvent[0])) - { - Trace("PALSUITE ERROR: Unable to execute CloseHandle(%p) during " - "clean up.\nGetLastError returned '%d'.\n", hEvent[0], - GetLastError()); - } - if (0 == CloseHandle(hEvent[1])) - { - Trace("PALSUITE ERROR: Unable to execute CloseHandle(%p) during " - "clean up.\nGetLastError returned '%d'.\n", hEvent[1], - GetLastError()); - } - Fail(""); - } - - /* - * Attempting to enter CRITICAL_SECTION object owned by the - * created thread and locked with TryEnterCriticalSection - */ - if (0 == TryEnterCriticalSection(&CriticalSection)) - { - /* signal thread 1 */ - if (0 == SetEvent(hEvent[1])) - { - Trace("PALSUITE ERROR: Unable to execute SetEvent(%p) call.\n" - "GetLastError returned '%d'.\n", hEvent[1], - GetLastError()); - goto done; - } - } - else - { - Trace("PALSUITE_ERROR: TryEnterCriticalSection was able to grab a" - " CRITICAL_SECTION object\nwhich was already owned.\n"); - LeaveCriticalSection(&CriticalSection); - if (0 == CloseHandle(hThread[0])) - { - Trace("PALSUITE ERROR: Unable to execute CloseHandle(%p) during " - "clean up.\nGetLastError returned '%d'.\n", hThread[0], - GetLastError()); - } - if (0 == CloseHandle(hEvent[0])) - { - Trace("PALSUITE ERROR: Unable to execute CloseHandle(%p) during " - "clean up.\nGetLastError returned '%d'.\n", hEvent[0], - GetLastError()); - } - if (0 == CloseHandle(hEvent[1])) - { - Trace("PALSUITE ERROR: Unable to execute CloseHandle(%p) during " - "clean up.\nGetLastError returned '%d'.\n", hEvent[1], - GetLastError()); - } - DeleteCriticalSection(&CriticalSection); - Fail(""); - } - /* - * Enter the CRITICAL_SECTION and launch another thread to attempt - * to access the CRITICAL_SECTION with a call to TryEnterCriticalSection. - */ - EnterCriticalSection(&CriticalSection); - - hThread[1] = CreateThread(NULL, - 0, - &Thread, - (LPVOID) NULL, - 0, - &dwThreadId[1]); - - if (hThread[1] == NULL) - { - Trace("PALSUITE ERROR: CreateThread call #1 failed. GetLastError " - "returned %d.\n", GetLastError()); - LeaveCriticalSection(&CriticalSection); - if (0 == CloseHandle(hThread[0])) - { - Trace("PALSUITE ERROR: Unable to execute CloseHandle(%p) during " - "clean up.\nGetLastError returned '%d'.\n", hThread[0], - GetLastError()); - } - if (0 == CloseHandle(hEvent[0])) - { - Trace("PALSUITE ERROR: Unable to execute CloseHandle(%p) during " - "clean up.\nGetLastError returned '%d'.\n", hEvent[0], - GetLastError()); - } - if (0 == CloseHandle(hEvent[1])) - { - Trace("PALSUITE ERROR: Unable to execute CloseHandle(%p) during " - "clean up.\nGetLastError returned '%d'.\n", hEvent[1], - GetLastError()); - } - DeleteCriticalSection(&CriticalSection); - Fail(""); - } - - dwRet = WaitForMultipleObjects(NUM_THREADS, hThread, TRUE, 10000); - if ((WAIT_OBJECT_0 > dwRet) || - ((WAIT_OBJECT_0 + NUM_THREADS - 1) < dwRet)) - { - Trace("PALSUITE ERROR: WaitForMultipleObjects(%d, %p, %d, %d) call " - "returned an unexpected value, '%d'.\nGetLastError returned " - "%d.\n", NUM_THREADS, hThread, TRUE, 10000, dwRet, - GetLastError()); - LeaveCriticalSection(&CriticalSection); - if (0 == CloseHandle(hThread[0])) - { - Trace("PALSUITE ERROR: Unable to execute CloseHandle(%p) during " - "clean up.\nGetLastError returned '%d'.\n", hThread[0], - GetLastError()); - } - if (0 == CloseHandle(hThread[1])) - { - Trace("PALSUITE ERROR: Unable to execute CloseHandle(%p) during " - "clean up.\nGetLastError returned '%d'.\n", hThread[1], - GetLastError()); - } - if (0 == CloseHandle(hEvent[0])) - { - Trace("PALSUITE ERROR: Unable to execute CloseHandle(%p) during " - "clean up.\nGetLastError returned '%d'.\n", hEvent[0], - GetLastError()); - } - if (0 == CloseHandle(hEvent[1])) - { - Trace("PALSUITE ERROR: Unable to execute CloseHandle(%p) during " - "clean up.\nGetLastError returned '%d'.\n", hEvent[1], - GetLastError()); - } - DeleteCriticalSection(&CriticalSection); - Fail(""); - } - - LeaveCriticalSection(&CriticalSection); - if (0 == CloseHandle(hThread[1])) - { - Trace("PALSUITE ERROR: Unable to execute CloseHandle(%p) during " - "clean up.\nGetLastError returned '%d'.\n", hThread[1], - GetLastError()); - } -done: - if (0 == CloseHandle(hThread[0])) - { - Trace("PALSUITE ERROR: Unable to execute CloseHandle(%p) during " - "clean up.\nGetLastError returned '%d'.\n", hThread[0], - GetLastError()); - } - if (0 == CloseHandle(hEvent[0])) - { - Trace("PALSUITE ERROR: Unable to execute CloseHandle(%p) during " - "clean up.\nGetLastError returned '%d'.\n", hEvent[0], - GetLastError()); - } - if (0 == CloseHandle(hEvent[1])) - { - Trace("PALSUITE ERROR: Unable to execute CloseHandle(%p) during " - "clean up.\nGetLastError returned '%d'.\n", hEvent[1], - GetLastError()); - } - DeleteCriticalSection(&CriticalSection); - - PAL_TerminateEx(bRet); - - return (bRet); -} - diff --git a/src/pal/tests/palsuite/threading/CriticalSectionFunctions/test3/testinfo.dat b/src/pal/tests/palsuite/threading/CriticalSectionFunctions/test3/testinfo.dat deleted file mode 100644 index 818b4870a..000000000 --- a/src/pal/tests/palsuite/threading/CriticalSectionFunctions/test3/testinfo.dat +++ /dev/null @@ -1,29 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = threading -Function = CriticalSectionFunctions -Name = Positive Test for TryEnterCriticalSection -TYPE = DEFAULT -EXE1 = test3 -Description -= Create two threads to exercise TryEnterCriticalSection -= and EnterCriticalSection. TryEnterCriticalSection acquires -= and holds a CRITICAL_SECTION object. Another call to -= TryEnterCriticalSection is made from a different thread, at -= this time, to establish a call to TryEnterCriticalSection -= will return immediatly and to establish -= TryEnterCriticalSection returns the proper value when it -= attempts to lock a CRITICAL_SECTION that is already owned -= by another thread. The CRITICAL_SECTION object is then -= released and held by a call to EnterCriticalSection. A new -= thread is invoked and attempts to acquire the held -= CRITICAL_SECTION with a call to TryEnterCriticalSection. -= TryEnterCriticalSection returns immediatly and returns -= with the value that states the CRITICAL_SECTION object is -= held by another thread. This establishes -= TryEnterCriticalSection behaves the same way with -= CriticalSections locked by TryEnterCriticalSection and -= EnterCriticalSection. diff --git a/src/pal/tests/palsuite/threading/CriticalSectionFunctions/test4/CMakeLists.txt b/src/pal/tests/palsuite/threading/CriticalSectionFunctions/test4/CMakeLists.txt deleted file mode 100644 index 71c49248a..000000000 --- a/src/pal/tests/palsuite/threading/CriticalSectionFunctions/test4/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test4.cpp -) - -add_executable(paltest_criticalsectionfunctions_test4 - ${SOURCES} -) - -add_dependencies(paltest_criticalsectionfunctions_test4 coreclrpal) - -target_link_libraries(paltest_criticalsectionfunctions_test4 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/CriticalSectionFunctions/test4/test4.cpp b/src/pal/tests/palsuite/threading/CriticalSectionFunctions/test4/test4.cpp deleted file mode 100644 index 8a245a477..000000000 --- a/src/pal/tests/palsuite/threading/CriticalSectionFunctions/test4/test4.cpp +++ /dev/null @@ -1,241 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source: criticalsectionfunctions/test4/test4.c -** -** Purpose: Test to see if threads blocked on a CRITICAL_SECTION object will -** be released in an orderly manner. This case looks at the following -** scenario. If one thread owns a CRITICAL_SECTION object and two threads -** block in EnterCriticalSection, trying to hold the already owned -** CRITICAL_SECTION object, when the first thread releases the CRITICAL_SECTION -** object, will one and only one of the waiters get unblocked? -** -** Dependencies: CreateThread -** InitializeCriticalSection -** EnterCriticalSection -** LeaveCriticalSection -** DeleteCriticalSection -** Sleep -** WaitForSingleObject -** - -** -**=========================================================*/ - -#include - -#define NUM_BLOCKING_THREADS 2 - -BOOL bTestResult; -CRITICAL_SECTION CriticalSection; -HANDLE hThread[NUM_BLOCKING_THREADS]; -HANDLE hEvent; -DWORD dwThreadId[NUM_BLOCKING_THREADS]; -volatile int flags[NUM_BLOCKING_THREADS] = {0,0}; - -DWORD PALAPI ThreadTest1(LPVOID lpParam) -{ - - EnterCriticalSection ( &CriticalSection ); - - flags[0] = 1; - - return 0; - -} - -DWORD PALAPI ThreadTest2(LPVOID lpParam) -{ - - EnterCriticalSection ( &CriticalSection ); - - flags[1] = 1; - - return 0; - -} - -int __cdecl main(int argc, char **argv) -{ - - DWORD dwRet; - DWORD dwRet1; - bTestResult = FAIL; - - if ((PAL_Initialize(argc,argv)) != 0) - { - return(bTestResult); - } - - /* - * Create Critical Section Object - */ - InitializeCriticalSection ( &CriticalSection ); - - EnterCriticalSection ( &CriticalSection ); - - hThread[0] = CreateThread(NULL, - 0, - &ThreadTest1, - (LPVOID) 0, - CREATE_SUSPENDED, - &dwThreadId[0]); - if (hThread[0] == NULL) - { - Trace("PALSUITE ERROR: CreateThread(%p, %d, %p, %p, %d, %p) call " - "failed.\nGetLastError returned %d.\n", NULL, 0, &ThreadTest1, - (LPVOID) 0, CREATE_SUSPENDED, &dwThreadId[0], GetLastError()); - LeaveCriticalSection(&CriticalSection); - DeleteCriticalSection ( &CriticalSection ); - Fail(""); - } - - hThread[1] = CreateThread(NULL, - 0, - &ThreadTest2, - (LPVOID) 0, - CREATE_SUSPENDED, - &dwThreadId[1]); - if (hThread[1] == NULL) - { - Trace("PALSUITE ERROR: CreateThread(%p, %d, %p, %p, %d, %p) call " - "failed.\nGetLastError returned %d.\n", NULL, 0, &ThreadTest2, - (LPVOID) 0, CREATE_SUSPENDED, &dwThreadId[1], GetLastError()); - LeaveCriticalSection(&CriticalSection); - - dwRet = ResumeThread(hThread[0]); - if (-1 == dwRet) - { - Trace("PALSUITE ERROR: ResumeThread(%p) call failed.\n" - "GetLastError returned '%d'.\n", hThread[0], - GetLastError()); - } - - dwRet = WaitForSingleObject(hThread[0], 10000); - if (WAIT_OBJECT_0 == dwRet) - { - Trace("PALSUITE ERROR: WaitForSingleObject(%p, %d) call " - "failed. '%d' was returned instead of the expected '%d'.\n" - "GetLastError returned '%d'.\n", hThread[0], 10000, dwRet, - WAIT_OBJECT_0, GetLastError()); - } - - if (0 == CloseHandle(hThread[0])) - { - Trace("PALSUITE NOTIFICATION: CloseHandle(%p) call failed.\n" - "GetLastError returned %d. Not failing tests.\n", - hThread[0], GetLastError()); - } - - DeleteCriticalSection(&CriticalSection); - Fail(""); - } - - /* - * Set other thread priorities to be higher than ours & Sleep to ensure - * we give up the processor. - */ - dwRet = (DWORD) SetThreadPriority(hThread[0], - THREAD_PRIORITY_ABOVE_NORMAL); - if (0 == dwRet) - { - Trace("PALSUITE ERROR: SetThreadPriority(%p, %d) call failed.\n" - "GetLastError returned %d", hThread[0], - THREAD_PRIORITY_ABOVE_NORMAL, GetLastError()); - } - - dwRet = (DWORD) SetThreadPriority(hThread[1], - THREAD_PRIORITY_ABOVE_NORMAL); - if (0 == dwRet) - { - Trace("PALSUITE ERROR: SetThreadPriority(%p, %d) call failed.\n" - "GetLastError returned %d", hThread[1], - THREAD_PRIORITY_ABOVE_NORMAL, GetLastError()); - } - - dwRet = ResumeThread(hThread[0]); - if (-1 == dwRet) - { - Trace("PALSUITE ERROR: ResumeThread(%p, %d) call failed.\n" - "GetLastError returned %d", hThread[0], - GetLastError() ); - } - - dwRet = ResumeThread(hThread[1]); - if (-1 == dwRet) - { - Trace("PALSUITE ERROR: ResumeThread(%p, %d) call failed.\n" - "GetLastError returned %d", hThread[0], - GetLastError()); - } - - Sleep (0); - - LeaveCriticalSection (&CriticalSection); - - dwRet = WaitForSingleObject(hThread[0], 10000); - dwRet1 = WaitForSingleObject(hThread[1], 10000); - - if ((WAIT_OBJECT_0 == dwRet) || - (WAIT_OBJECT_0 == dwRet1)) - { - if ((1 == flags[0] && 0 == flags[1]) || - (0 == flags[0] && 1 == flags[1])) - { - bTestResult = PASS; - } - else - { - bTestResult = FAIL; - Trace ("PALSUITE ERROR: flags[%d] = {%d,%d}. These values are" - "inconsistent.\nCriticalSection test failed.\n", - NUM_BLOCKING_THREADS, flags[0], flags[1]); - } - - /* Fail the test if both threads returned WAIT_OBJECT_0 */ - if ((WAIT_OBJECT_0 == dwRet) && (WAIT_OBJECT_0 == dwRet1)) - { - bTestResult = FAIL; - Trace ("PALSUITE ERROR: WaitForSingleObject(%p, %d) and " - "WaitForSingleObject(%p, %d)\nboth returned dwRet = '%d'\n" - "One should have returned WAIT_TIMEOUT ('%d').\n", - hThread[0], 10000, hThread[1], 10000, dwRet, WAIT_TIMEOUT); - } - } - else - { - bTestResult = FAIL; - Trace ("PALSUITE ERROR: WaitForSingleObject(%p, %d) and " - "WaitForSingleObject(%p, %d)\nReturned dwRet = '%d' and\n" - "dwRet1 = '%d' respectively.\n", hThread[0], 10000, hThread[1], - 10000, dwRet, dwRet1); - } - - if (WAIT_OBJECT_0 == dwRet) - { - if (0 == CloseHandle(hThread[0])) - { - Trace("PALSUITE NOTIFICATION: CloseHandle(%p) call failed.\n" - "GetLastError returned %d. Not failing tests.\n", - hThread[0], GetLastError()); - } - } - if (WAIT_OBJECT_0 == dwRet1) - { - if (0 == CloseHandle(hThread[1])) - { - Trace("PALSUITE NOTIFICATION: CloseHandle(%p) call failed.\n" - "GetLastError returned %d. Not failing tests.\n", - hThread[1], GetLastError()); - } - } - - /* Leaking the CS on purpose, since there is still a thread - waiting on it */ - - PAL_TerminateEx(bTestResult); - return (bTestResult); -} diff --git a/src/pal/tests/palsuite/threading/CriticalSectionFunctions/test4/testinfo.dat b/src/pal/tests/palsuite/threading/CriticalSectionFunctions/test4/testinfo.dat deleted file mode 100644 index 9c07c2411..000000000 --- a/src/pal/tests/palsuite/threading/CriticalSectionFunctions/test4/testinfo.dat +++ /dev/null @@ -1,17 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = threading -Function = LeaveCriticalSection -Name = Positive test to ensure CRITICAL_SECTION objects are released properly -TYPE = DEFAULT -EXE1 = test4 -Description -= Test to see if threads blocked on a CRITICAL_SECTION object will -= be released in an orderly manner. This case looks at the following -= scenario. If one thread owns a CRITICAL_SECTION object and two threads -= block in EnterCriticalSection, trying to hold the already owned -= CRITICAL_SECTION object, when the first thread releases the CRITICAL_SECTION -= object, will one and only one of the waiters get unblocked? diff --git a/src/pal/tests/palsuite/threading/CriticalSectionFunctions/test5/CMakeLists.txt b/src/pal/tests/palsuite/threading/CriticalSectionFunctions/test5/CMakeLists.txt deleted file mode 100644 index 16a0ccdb4..000000000 --- a/src/pal/tests/palsuite/threading/CriticalSectionFunctions/test5/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test5.cpp -) - -add_executable(paltest_criticalsectionfunctions_test5 - ${SOURCES} -) - -add_dependencies(paltest_criticalsectionfunctions_test5 coreclrpal) - -target_link_libraries(paltest_criticalsectionfunctions_test5 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/CriticalSectionFunctions/test5/test5.cpp b/src/pal/tests/palsuite/threading/CriticalSectionFunctions/test5/test5.cpp deleted file mode 100644 index 8dfa4f5f3..000000000 --- a/src/pal/tests/palsuite/threading/CriticalSectionFunctions/test5/test5.cpp +++ /dev/null @@ -1,187 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: CriticalSectionFunctions/test5/test5.c -** -** Purpose: Attempt to delete a critical section owned by another -** thread. -** -** -**===================================================================*/ -#include - -/* - * Tokens 0 and 1 are events. Token 2 is the thread. - */ -#define NUM_TOKENS 3 - -HANDLE hToken[NUM_TOKENS]; -CRITICAL_SECTION CriticalSection; - -BOOL CleanupHelper (HANDLE *hArray, DWORD dwIndex) -{ - BOOL bCHRet; - - bCHRet = CloseHandle(hArray[dwIndex]); - if (!bCHRet) - { - Trace("PALSUITE ERROR: Unable to execute CloseHandle(%p) during " - "clean up.\nGetLastError returned '%u'.\n", hArray[dwIndex], - GetLastError()); - } - - return (bCHRet); -} - -BOOL Cleanup(HANDLE *hArray, DWORD dwIndex) -{ - BOOL bCRet; - BOOL bCHRet = FALSE; - - while (--dwIndex > 0) - { - bCHRet = CleanupHelper(&hArray[0], dwIndex); - } - - bCRet = CloseHandle(hArray[0]); - if (!bCRet) - { - Trace("PALSUITE ERROR: Unable to execute CloseHandle(%p) during " - "clean up.\nGetLastError returned '%u'.\n", hArray[dwIndex], - GetLastError()); - } - - return (bCRet&&bCHRet); -} - -DWORD PALAPI Thread(LPVOID lpParam) -{ - DWORD dwTRet; - - EnterCriticalSection(&CriticalSection); - - /* signal thread 0 */ - if (0 == SetEvent(hToken[0])) - { - Trace("PALSUITE ERROR: Unable to execute SetEvent(%p) during " - "clean up.\nGetLastError returned '%u'.\n", hToken[0], - GetLastError()); - LeaveCriticalSection(&CriticalSection); - Cleanup (&hToken[0], NUM_TOKENS); - DeleteCriticalSection(&CriticalSection); - Fail(""); - } - - /* wait to be signaled */ - dwTRet = WaitForSingleObject(hToken[1], 10000); - if (WAIT_OBJECT_0 != dwTRet) - - { - Trace("PALSUITE ERROR: WaitForSingleObject(%p,%d) should have " - "returned\nWAIT_OBJECT_0 ('%d'), instead it returned " - "('%d').\nGetLastError returned '%u'.\n", - hToken[1], 10000, WAIT_OBJECT_0, dwTRet, GetLastError()); - LeaveCriticalSection(&CriticalSection); - Cleanup (&hToken[0], NUM_TOKENS); - DeleteCriticalSection(&CriticalSection); - Fail(""); - } - - LeaveCriticalSection(&CriticalSection); - return 0; -} - -int __cdecl main(int argc, char **argv) -{ - DWORD dwThreadId; - DWORD dwMRet; - - if ((PAL_Initialize(argc,argv)) != 0) - { - return(FAIL); - } - - /* thread 0 event */ - hToken[0] = CreateEvent(NULL, TRUE, FALSE, NULL); - if (NULL == hToken[0]) - { - Fail("PALSUITE ERROR: CreateEvent call #0 failed. GetLastError " - "returned %u.\n", GetLastError()); - } - - /* thread 1 event */ - hToken[1] = CreateEvent(NULL, TRUE, FALSE, NULL); - if (NULL == hToken[1]) - { - Trace("PALSUITE ERROR: CreateEvent call #1 failed. GetLastError " - "returned %u.\n", GetLastError()); - Cleanup(&hToken[0], (NUM_TOKENS - 2)); - Fail(""); - } - - InitializeCriticalSection(&CriticalSection); - - hToken[2] = CreateThread(NULL, - 0, - &Thread, - (LPVOID) NULL, - 0, - &dwThreadId); - if (hToken[2] == NULL) - { - Trace("PALSUITE ERROR: CreateThread call #0 failed. GetLastError " - "returned %u.\n", GetLastError()); - Cleanup(&hToken[0], (NUM_TOKENS - 1)); - DeleteCriticalSection(&CriticalSection); - Fail(""); - } - - /* wait for thread 0 to be signaled */ - dwMRet = WaitForSingleObject(hToken[0], 10000); - if (WAIT_OBJECT_0 != dwMRet) - { - Trace("PALSUITE ERROR: WaitForSingleObject(%p,%d) should have " - "returned\nWAIT_OBJECT_0 ('%d'), instead it returned " - "('%d').\nGetLastError returned '%u'.\n", hToken[0], 10000, - WAIT_OBJECT_0, dwMRet, GetLastError()); - Cleanup(&hToken[0], NUM_TOKENS); - Fail(""); - } - - /* - * Attempt to do delete CriticalSection object owned by other thread - */ - DeleteCriticalSection(&CriticalSection); - - /* signal thread 1 */ - if (0 == SetEvent(hToken[1])) - { - Trace("PALSUITE ERROR: Unable to execute SetEvent(%p) call.\n" - "GetLastError returned '%u'.\n", hToken[1], - GetLastError()); - Cleanup(&hToken[0], NUM_TOKENS); - Fail(""); - } - - dwMRet = WaitForSingleObject(hToken[2], 10000); - if (WAIT_OBJECT_0 != dwMRet) - { - Trace("PALSUITE ERROR: WaitForSingleObject(%p, %d) call " - "returned an unexpected value '%d'.\nGetLastError returned " - "%u.\n", hToken[2], 10000, dwMRet, GetLastError()); - Cleanup(&hToken[0], NUM_TOKENS); - Fail(""); - } - - if (!Cleanup(&hToken[0], NUM_TOKENS)) - { - Fail(""); - } - - PAL_Terminate(); - - return (PASS); -} diff --git a/src/pal/tests/palsuite/threading/CriticalSectionFunctions/test5/testinfo.dat b/src/pal/tests/palsuite/threading/CriticalSectionFunctions/test5/testinfo.dat deleted file mode 100644 index aa1124925..000000000 --- a/src/pal/tests/palsuite/threading/CriticalSectionFunctions/test5/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = threading -Function = CriticalSectionFunctions -Name = Positive test for DeleteCriticalSection -TYPE = DEFAULT -EXE1 = test5 -Description -= Attempt to delete a critical section owned by another thread. diff --git a/src/pal/tests/palsuite/threading/CriticalSectionFunctions/test6/CMakeLists.txt b/src/pal/tests/palsuite/threading/CriticalSectionFunctions/test6/CMakeLists.txt deleted file mode 100644 index 3f463940b..000000000 --- a/src/pal/tests/palsuite/threading/CriticalSectionFunctions/test6/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test6.cpp -) - -add_executable(paltest_criticalsectionfunctions_test6 - ${SOURCES} -) - -add_dependencies(paltest_criticalsectionfunctions_test6 coreclrpal) - -target_link_libraries(paltest_criticalsectionfunctions_test6 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/CriticalSectionFunctions/test6/test6.cpp b/src/pal/tests/palsuite/threading/CriticalSectionFunctions/test6/test6.cpp deleted file mode 100644 index c27db86e5..000000000 --- a/src/pal/tests/palsuite/threading/CriticalSectionFunctions/test6/test6.cpp +++ /dev/null @@ -1,190 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: CriticalSectionFunctions/test6/test6.c -** -** Purpose: Attempt to leave a critical section which is owned by -** another thread. -** -** -**===================================================================*/ -#include - -/* - * Tokens 0 and 1 are events. Token 2 is the thread. - */ -#define NUM_TOKENS 3 - -HANDLE hToken[NUM_TOKENS]; -CRITICAL_SECTION CriticalSection; - -BOOL CleanupHelper (HANDLE *hArray, DWORD dwIndex) -{ - BOOL bCHRet; - - bCHRet = CloseHandle(hArray[dwIndex]); - if (!bCHRet) - { - Trace("PALSUITE ERROR: Unable to execute CloseHandle(%p) during " - "clean up.\nGetLastError returned '%u'.\n", hArray[dwIndex], - GetLastError()); - } - - return (bCHRet); -} - -BOOL Cleanup(HANDLE *hArray, DWORD dwIndex) -{ - BOOL bCRet; - BOOL bCHRet; - - while (--dwIndex > 0) - { - bCHRet = CleanupHelper(&hArray[0], dwIndex); - } - - bCRet = CloseHandle(hArray[0]); - if (!bCRet) - { - Trace("PALSUITE ERROR: Unable to execute CloseHandle(%p) during " - "clean up.\nGetLastError returned '%u'.\n", hArray[dwIndex], - GetLastError()); - } - - return (bCRet&&bCHRet); -} - -DWORD PALAPI Thread(LPVOID lpParam) -{ - DWORD dwTRet; - - EnterCriticalSection(&CriticalSection); - - /* signal thread 0 */ - if (0 == SetEvent(hToken[0])) - { - Trace("PALSUITE ERROR: Unable to execute SetEvent(%p) during " - "clean up.\nGetLastError returned '%u'.\n", hToken[0], - GetLastError()); - LeaveCriticalSection(&CriticalSection); - Cleanup (&hToken[0], NUM_TOKENS); - DeleteCriticalSection(&CriticalSection); - Fail(""); - } - - /* wait to be signaled */ - dwTRet = WaitForSingleObject(hToken[1], 10000); - if (WAIT_OBJECT_0 != dwTRet) - { - Trace("PALSUITE ERROR: WaitForSingleObject(%p,%d) should have " - "returned\nWAIT_OBJECT_0 ('%d'), instead it returned " - "('%d').\nGetLastError returned '%u'.\n", - hToken[1], 10000, WAIT_OBJECT_0, dwTRet, GetLastError()); - LeaveCriticalSection(&CriticalSection); - Cleanup (&hToken[0], NUM_TOKENS); - DeleteCriticalSection(&CriticalSection); - Fail(""); - } - - LeaveCriticalSection(&CriticalSection); - - return 0; -} - -int __cdecl main(int argc, char **argv) -{ - DWORD dwThreadId; - DWORD dwMRet; - - if ((PAL_Initialize(argc,argv)) != 0) - { - return(FAIL); - } - - /* thread 0 event */ - hToken[0] = CreateEvent(NULL, TRUE, FALSE, NULL); - - if (hToken[0] == NULL) - { - Fail("PALSUITE ERROR: CreateEvent call #0 failed. GetLastError " - "returned %u.\n", GetLastError()); - } - - /* thread 1 event */ - hToken[1] = CreateEvent(NULL, TRUE, FALSE, NULL); - - if (hToken[1] == NULL) - { - Trace("PALSUITE ERROR: CreateEvent call #1 failed. GetLastError " - "returned %u.\n", GetLastError()); - Cleanup(&hToken[0], (NUM_TOKENS - 2)); - Fail(""); - } - - InitializeCriticalSection(&CriticalSection); - - hToken[2] = CreateThread(NULL, - 0, - &Thread, - (LPVOID) NULL, - 0, - &dwThreadId); - - if (hToken[2] == NULL) - { - Trace("PALSUITE ERROR: CreateThread call #0 failed. GetLastError " - "returned %u.\n", GetLastError()); - Cleanup(&hToken[0], (NUM_TOKENS - 1)); - DeleteCriticalSection(&CriticalSection); - Fail(""); - } - - /* wait for thread 0 to be signaled */ - dwMRet = WaitForSingleObject(hToken[0], 10000); - if (WAIT_OBJECT_0 != dwMRet) - { - Trace("PALSUITE ERROR: WaitForSingleObject(%p,%d) should have " - "returned\nWAIT_OBJECT_0 ('%d'), instead it returned " - "('%d').\nGetLastError returned '%u'.\n", hToken[0], 10000, - WAIT_OBJECT_0, dwMRet, GetLastError()); - Cleanup(&hToken[0], NUM_TOKENS); - Fail(""); - } - - /* - * Attempt to leave critical section which is owned by the other thread. - */ - LeaveCriticalSection(&CriticalSection); - - /* signal thread 1 */ - if (0 == SetEvent(hToken[1])) - { - Trace("PALSUITE ERROR: Unable to execute SetEvent(%p) call.\n" - "GetLastError returned '%u'.\n", hToken[1], - GetLastError()); - Cleanup(&hToken[0], NUM_TOKENS); - Fail(""); - } - - dwMRet = WaitForSingleObject(hToken[2], 10000); - if (WAIT_OBJECT_0 != dwMRet) - { - Trace("PALSUITE ERROR: WaitForSingleObject(%p, %d) call " - "returned an unexpected value '%d'.\nGetLastError returned " - "%u.\n", hToken[2], 10000, dwMRet, GetLastError()); - Cleanup(&hToken[0], NUM_TOKENS); - Fail(""); - } - - if (!Cleanup(&hToken[0], NUM_TOKENS)) - { - Fail(""); - } - - PAL_Terminate(); - - return(PASS); -} diff --git a/src/pal/tests/palsuite/threading/CriticalSectionFunctions/test6/testinfo.dat b/src/pal/tests/palsuite/threading/CriticalSectionFunctions/test6/testinfo.dat deleted file mode 100644 index 151e1ed4d..000000000 --- a/src/pal/tests/palsuite/threading/CriticalSectionFunctions/test6/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = threading -Function = CriticalSectionFunctions -Name = Positive Test for LeaveCriticalSection -TYPE = DEFAULT -EXE1 = test6 -Description -= Attempt to leave a critical section which is owned by another thread. diff --git a/src/pal/tests/palsuite/threading/CriticalSectionFunctions/test7/CMakeLists.txt b/src/pal/tests/palsuite/threading/CriticalSectionFunctions/test7/CMakeLists.txt deleted file mode 100644 index 21b813ba3..000000000 --- a/src/pal/tests/palsuite/threading/CriticalSectionFunctions/test7/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test7.cpp -) - -add_executable(paltest_criticalsectionfunctions_test7 - ${SOURCES} -) - -add_dependencies(paltest_criticalsectionfunctions_test7 coreclrpal) - -target_link_libraries(paltest_criticalsectionfunctions_test7 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/CriticalSectionFunctions/test7/test7.cpp b/src/pal/tests/palsuite/threading/CriticalSectionFunctions/test7/test7.cpp deleted file mode 100644 index 1c030d3c0..000000000 --- a/src/pal/tests/palsuite/threading/CriticalSectionFunctions/test7/test7.cpp +++ /dev/null @@ -1,188 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: CriticalSectionFunctions/test7/test7.c -** -** Purpose: Attempt to delete a critical section owned by the current -** thread. -** -** -**===================================================================*/ -#include - -/* - * Tokens 0 and 1 are events. Token 2 is the thread. - */ -#define NUM_TOKENS 3 - -HANDLE hToken[NUM_TOKENS]; -CRITICAL_SECTION CriticalSection; - -BOOL CleanupHelper (HANDLE *hArray, DWORD dwIndex) -{ - BOOL bCHRet; - - bCHRet = CloseHandle(hArray[dwIndex]); - if (!bCHRet) - { - Trace("PALSUITE ERROR: Unable to execute CloseHandle(%p) during " - "clean up.\nGetLastError returned '%u'.\n", hArray[dwIndex], - GetLastError()); - } - - return (bCHRet); -} - -BOOL Cleanup(HANDLE *hArray, DWORD dwIndex) -{ - BOOL bCRet; - BOOL bCHRet = 0; - - while (--dwIndex > 0) - { - bCHRet = CleanupHelper(&hArray[0], dwIndex); - } - - bCRet = CloseHandle(hArray[0]); - if (!bCRet) - { - Trace("PALSUITE ERROR: Unable to execute CloseHandle(%p) during " - "clean up.\nGetLastError returned '%u'.\n", hArray[dwIndex], - GetLastError()); - } - - return (bCRet&&bCHRet); -} - -DWORD PALAPI Thread(LPVOID lpParam) -{ - DWORD dwTRet; - - EnterCriticalSection(&CriticalSection); - - /* signal thread 0 */ - if (0 == SetEvent(hToken[0])) - { - Trace("PALSUITE ERROR: Unable to execute SetEvent(%p) during " - "clean up.\nGetLastError returned '%u'.\n", hToken[0], - GetLastError()); - LeaveCriticalSection(&CriticalSection); - Cleanup (&hToken[0], NUM_TOKENS); - DeleteCriticalSection(&CriticalSection); - Fail(""); - } - - /* wait to be signaled */ - dwTRet = WaitForSingleObject(hToken[1], 10000); - if (WAIT_OBJECT_0 != dwTRet) - { - Trace("PALSUITE ERROR: WaitForSingleObject(%p,%d) should have " - "returned\nWAIT_OBJECT_0 ('%d'), instead it returned " - "('%d').\nGetLastError returned '%u'.\n", - hToken[0], 10000, WAIT_OBJECT_0, dwTRet, GetLastError()); - LeaveCriticalSection(&CriticalSection); - Cleanup (&hToken[0], NUM_TOKENS); - DeleteCriticalSection(&CriticalSection); - Fail(""); - } - - DeleteCriticalSection(&CriticalSection); - - return 0; -} - -int __cdecl main(int argc, char **argv) -{ - DWORD dwThreadId; - DWORD dwMRet; - - if ((PAL_Initialize(argc,argv)) != 0) - { - return(FAIL); - } - - /* thread 0 event */ - hToken[0] = CreateEvent(NULL, TRUE, FALSE, NULL); - - if (hToken[0] == NULL) - { - Fail("PALSUITE ERROR: CreateEvent call #0 failed. GetLastError " - "returned %u.\n", GetLastError()); - } - - /* thread 1 event */ - hToken[1] = CreateEvent(NULL, TRUE, FALSE, NULL); - - if (hToken[1] == NULL) - { - Trace("PALSUITE ERROR: CreateEvent call #1 failed. GetLastError " - "returned %u.\n", GetLastError()); - Cleanup (&hToken[0], (NUM_TOKENS - 2)); - Fail(""); - } - - InitializeCriticalSection(&CriticalSection); - - hToken[2] = CreateThread(NULL, - 0, - &Thread, - (LPVOID) NULL, - 0, - &dwThreadId); - - if (hToken[2] == NULL) - { - Trace("PALSUITE ERROR: CreateThread call #0 failed. GetLastError " - "returned %u.\n", GetLastError()); - Cleanup (&hToken[0], (NUM_TOKENS - 1)); - DeleteCriticalSection(&CriticalSection); - Fail(""); - } - - /* wait for thread 0 to be signaled */ - dwMRet = WaitForSingleObject(hToken[0], 10000); - if (WAIT_OBJECT_0 != dwMRet) - { - Trace("PALSUITE ERROR: WaitForSingleObject(%p,%d) should have " - "returned\nWAIT_OBJECT_0 ('%d'), instead it returned " - "('%d').\nGetLastError returned '%u'.\n", hToken[0], 10000, - WAIT_OBJECT_0, dwMRet, GetLastError()); - Cleanup (&hToken[0], NUM_TOKENS); - Fail(""); - } - - /* signal thread 1 */ - if (0 == SetEvent(hToken[1])) - { - Trace("PALSUITE ERROR: Unable to execute SetEvent(%p) call.\n" - "GetLastError returned '%u'.\n", hToken[1], - GetLastError()); - Cleanup (&hToken[0], NUM_TOKENS); - Fail(""); - } - - dwMRet = WaitForSingleObject(hToken[2], 10000); - if (WAIT_OBJECT_0 != dwMRet) - { - Trace("PALSUITE ERROR: WaitForSingleObject(%p, %d) call " - "returned an unexpected value '%d'.\nGetLastError returned " - "%u.\n", hToken[2], 10000, dwMRet, GetLastError()); - Cleanup (&hToken[0], NUM_TOKENS); - Fail(""); - } - - if (!Cleanup(&hToken[0], NUM_TOKENS)) - { - Fail(""); - } - - PAL_Terminate(); - - return (PASS); -} - - - diff --git a/src/pal/tests/palsuite/threading/CriticalSectionFunctions/test7/testinfo.dat b/src/pal/tests/palsuite/threading/CriticalSectionFunctions/test7/testinfo.dat deleted file mode 100644 index 5cf580962..000000000 --- a/src/pal/tests/palsuite/threading/CriticalSectionFunctions/test7/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = threading -Function = CriticalSectionFunctions -Name = Positive test for DeleteCriticalSection -TYPE = DEFAULT -EXE1 = test7 -Description -= Attempt to delete a critical section owned by the current thread. diff --git a/src/pal/tests/palsuite/threading/CriticalSectionFunctions/test8/CMakeLists.txt b/src/pal/tests/palsuite/threading/CriticalSectionFunctions/test8/CMakeLists.txt deleted file mode 100644 index a8ab4b0aa..000000000 --- a/src/pal/tests/palsuite/threading/CriticalSectionFunctions/test8/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test8.cpp -) - -add_executable(paltest_criticalsectionfunctions_test8 - ${SOURCES} -) - -add_dependencies(paltest_criticalsectionfunctions_test8 coreclrpal) - -target_link_libraries(paltest_criticalsectionfunctions_test8 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/CriticalSectionFunctions/test8/test8.cpp b/src/pal/tests/palsuite/threading/CriticalSectionFunctions/test8/test8.cpp deleted file mode 100644 index 7f0c58cd2..000000000 --- a/src/pal/tests/palsuite/threading/CriticalSectionFunctions/test8/test8.cpp +++ /dev/null @@ -1,217 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: CriticalSectionFunctions/test8/test8.c -** -** Pyrpose: Ensure critical section functionality is working by -** having multiple threads racing on a CS under different -** scenarios -** -** -**===================================================================*/ -#include - -#define MAX_THREAD_COUNT 128 -#define DEFAULT_THREAD_COUNT 10 -#define DEFAULT_LOOP_COUNT 1000 - -#ifndef MIN -#define MIN(a,b) (((a)<(b)) ? (a) : (b)) -#endif - -int g_iThreadCount = DEFAULT_THREAD_COUNT; -int g_iLoopCount = DEFAULT_LOOP_COUNT; -volatile LONG g_lCriticalCount = 0; -HANDLE g_hEvStart = NULL; - -CRITICAL_SECTION g_cs; -DWORD PALAPI Thread(LPVOID lpParam) -{ - int i, j, iLpCnt; - DWORD dwRet = 0; - DWORD dwTid = GetCurrentThreadId(); - LONG lRet; - BOOL bSleepInside; - BOOL bSleepOutside; - - Trace("[tid=%u] Thread starting\n", dwTid); - - dwRet = WaitForSingleObject(g_hEvStart, INFINITE); - if (WAIT_OBJECT_0 != dwRet) - { - Fail("WaitForSingleObject returned unexpected %u [GetLastError()=%u]\n", - dwRet, GetLastError()); - } - - for (j=0;j<8;j++) - { - bSleepInside = 2 & j; - bSleepOutside = 4 & j; - - iLpCnt = g_iLoopCount; - if (bSleepInside || bSleepOutside) - { - iLpCnt /= 10; - } - - for (i=0;i= iVal) - { - g_iThreadCount = iVal; - } - } - break; - default: - break; - } - } - } - - Trace ("Iterations:\t%d\n", g_iLoopCount); - Trace ("Threads:\t%d\n", g_iThreadCount); - - g_hEvStart = CreateEvent(NULL, TRUE, FALSE, NULL); - - if (g_hEvStart == NULL) - { - Fail("CreateEvent call failed. GetLastError " - "returned %u.\n", GetLastError()); - } - - InitializeCriticalSection(&g_cs); - - for (i=0;i iThreadCount) - { - Fail("Failed to create minimum number if threads, i.e. 2\n"); - } - - if (!SetEvent(g_hEvStart)) - { - Fail("SetEvent failed [GetLastError()=%u]\n", GetLastError()); - } - - for (i=0; i - - -/* SHLEXT is defined only for Unix variants */ - -#if defined(SHLEXT) -#define LibName "testlib"SHLEXT -#define GETCALLCOUNT "GetCallCount" -#else -#define LibName "testlib" -#define GETCALLCOUNT "_GetCallCount@0" -#endif - -DWORD PALAPI ThreadFunc(LPVOID lpParam); -int RunTest(int DisableThreadCalls); - -int __cdecl main(int argc, char **argv) -{ - int ret; - - if ((PAL_Initialize(argc,argv)) != 0) - { - return (FAIL); - } - - - /* - * Although MSDN says that DisableThreadLibraryCalls will fail if passed - * an invalid handle, it actually returns success! - */ - ret = DisableThreadLibraryCalls(NULL); - if (!ret) - { - Fail("DisableThreadLibraryCalls failed on an invalid module " - "handle (it actually should pass)!\n"); - } - - - /* - * Test once without calling DisableThreadLibraryCalls and make sure we - * get expected results. - */ - ret = RunTest(0); - if (ret != 2) - { - Fail("Expected to get 2 thread library calls, got %d!\n", ret); - } - - - /* - * Test again, this time calling DisableThreadLibraryCalls. - */ - ret = RunTest(1); - if (ret != 0) - { - Fail("Expected to get 0 thread library calls, got %d!\n", ret); - } - - PAL_Terminate(); - return PASS; -} - -/* - * Thread entry point. Doesn't do anything. - */ -DWORD PALAPI ThreadFunc(LPVOID lpParam) -{ - return 0; -} - - -int RunTest(int DisableThreadCalls) -{ - HMODULE LibMod; - HANDLE hThread; - DWORD threadID; - DWORD WaitRet; - int (*GetCallCount)(); - int count; - - LibMod = LoadLibrary(LibName); - if (LibMod == NULL) - { - Fail("Unable to load test library!\nGetLastError returned %d\n", - GetLastError()); - } - - GetCallCount = (int(*)())GetProcAddress(LibMod, GETCALLCOUNT); - if (GetCallCount == NULL) - { - Fail("Unable to get function GetCallCount from library!\n" - "GetLastError returned %d\n", GetLastError()); - } - - if (DisableThreadCalls) - { - if (!DisableThreadLibraryCalls(LibMod)) - { - Fail("DisabledThreadLibraryCalls failed!\n" - "GetLastError returned %d!\n", GetLastError()); - } - } - - hThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) ThreadFunc, - NULL, 0, &threadID); - - if (hThread == NULL) - { - Fail("Unable to create a thread!\n"); - } - - WaitRet = WaitForSingleObject(hThread, INFINITE); - if (WaitRet == WAIT_FAILED) - { - Fail("Unable to wait on thread!\nGetLastError returned %d\n", - GetLastError()); - } - - count = GetCallCount(); - - CloseHandle(hThread); - - if (!FreeLibrary(LibMod)) - { - Fail("Failed freeing library!\nGetLastError returned %d\n", - GetLastError()); - } - - return count; -} diff --git a/src/pal/tests/palsuite/threading/DisableThreadLibraryCalls/test1/testinfo.dat b/src/pal/tests/palsuite/threading/DisableThreadLibraryCalls/test1/testinfo.dat deleted file mode 100644 index 6d32f3591..000000000 --- a/src/pal/tests/palsuite/threading/DisableThreadLibraryCalls/test1/testinfo.dat +++ /dev/null @@ -1,15 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Threading -Function = DisableThreadLibraryCalls -Name = Positive Test #1 for DisableThreadLibraryCalls -TYPE = DEFAULT -EXE1 = test1 -LIB1 = testlib -Description -=Tests that DisableThreadLibraryCalls actually stops thread -=attach/detach notifications to a library. Also tests how it -=handles an invalid module handle. diff --git a/src/pal/tests/palsuite/threading/DisableThreadLibraryCalls/test1/testlib.cpp b/src/pal/tests/palsuite/threading/DisableThreadLibraryCalls/test1/testlib.cpp deleted file mode 100644 index 057dfde66..000000000 --- a/src/pal/tests/palsuite/threading/DisableThreadLibraryCalls/test1/testlib.cpp +++ /dev/null @@ -1,47 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: testlib.c -** -** Purpose: Simple library that counts thread attach/detach notifications -** -** -**===================================================================*/ - -#include - -static int Count; - -BOOL PALAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) -{ - - if (fdwReason == DLL_PROCESS_ATTACH) - { - Count = 0; - } - else if (fdwReason == DLL_THREAD_ATTACH || - fdwReason == DLL_THREAD_DETACH) - { - Count++; - } - - return TRUE; -} - -#ifdef WIN32 -BOOL PALAPI _DllMainCRTStartup(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) -{ - return DllMain(hinstDLL, fdwReason, lpvReserved); -} -#endif - -#ifdef WIN32 -__declspec(dllexport) -#endif -int PALAPI GetCallCount() -{ - return Count; -} diff --git a/src/pal/tests/palsuite/threading/DisableThreadLibraryCalls/test2/dllmain1.cpp b/src/pal/tests/palsuite/threading/DisableThreadLibraryCalls/test2/dllmain1.cpp deleted file mode 100644 index b65bb66a5..000000000 --- a/src/pal/tests/palsuite/threading/DisableThreadLibraryCalls/test2/dllmain1.cpp +++ /dev/null @@ -1,66 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================= -** -** Source: dllmain1.c -** -** Purpose: Test to ensure DllMain() is called with THREAD_ATTACH -** when a thread in the application is started. -** -** Dependencies: none -** -** -**===========================================================================*/ - -#include - -/* count of the number of times DllMain() was called with THREAD_DETACH */ -static int g_attachCount = 0; - - -/* standard DllMain() */ -BOOL PALAPI DllMain(HINSTANCE hinstDLL, DWORD reason, LPVOID lpvReserved) -{ - BOOL bResult = TRUE; - - switch( reason ) - { - case DLL_PROCESS_ATTACH: - { - break; - } - - case DLL_PROCESS_DETACH: - { - break; - } - - case DLL_THREAD_ATTACH: - /* increment g_attachCount */ - g_attachCount++; - break; - - case DLL_THREAD_DETACH: - break; - } - return bResult; -} - - -#ifdef WIN32 -BOOL PALAPI _DllMainCRTStartup(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) -{ - return DllMain(hinstDLL, fdwReason, lpvReserved); -} -#endif - -/* function to return the current attach count */ -#ifdef WIN32 -__declspec(dllexport) -#endif -int PALAPI GetAttachCount( void ) -{ - return g_attachCount; -} diff --git a/src/pal/tests/palsuite/threading/DisableThreadLibraryCalls/test2/dllmain2.cpp b/src/pal/tests/palsuite/threading/DisableThreadLibraryCalls/test2/dllmain2.cpp deleted file mode 100644 index 519083bba..000000000 --- a/src/pal/tests/palsuite/threading/DisableThreadLibraryCalls/test2/dllmain2.cpp +++ /dev/null @@ -1,66 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================= -** -** Source: dllmain2.c -** -** Purpose: Test to ensure DllMain() is called with THREAD_ATTACH -** when a thread in the application is started. -** -** Dependencies: none -** -** -**===========================================================================*/ - -#include - -/* count of the number of times DllMain() was called with THREAD_DETACH */ -static int g_attachCount = 0; - - -/* standard DllMain() */ -BOOL PALAPI DllMain(HINSTANCE hinstDLL, DWORD reason, LPVOID lpvReserved) -{ - BOOL bResult = TRUE; - - switch( reason ) - { - case DLL_PROCESS_ATTACH: - { - break; - } - - case DLL_PROCESS_DETACH: - { - break; - } - - case DLL_THREAD_ATTACH: - /* increment g_attachCount */ - g_attachCount++; - break; - - case DLL_THREAD_DETACH: - break; - } - return bResult; -} - - -#ifdef WIN32 -BOOL PALAPI _DllMainCRTStartup(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) -{ - return DllMain(hinstDLL, fdwReason, lpvReserved); -} -#endif - -/* function to return the current attach count */ -#ifdef WIN32 -__declspec(dllexport) -#endif -int PALAPI GetAttachCount( void ) -{ - return g_attachCount; -} diff --git a/src/pal/tests/palsuite/threading/DisableThreadLibraryCalls/test2/test2.cpp b/src/pal/tests/palsuite/threading/DisableThreadLibraryCalls/test2/test2.cpp deleted file mode 100644 index 5fb694ea1..000000000 --- a/src/pal/tests/palsuite/threading/DisableThreadLibraryCalls/test2/test2.cpp +++ /dev/null @@ -1,237 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================= -** -** Source: test2.c -** -** Purpose: Test to ensure DisableThreadLibraryCalls() called for one -** library will not disrupt THREAD_ATTACH notifications etc. by -** other loaded modules. -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** Fail -** CreateThread -** ResumeThread -** LoadLibrary -** FreeLibrary -** GetProcAddress -** WaitForSingleObject -** GetLastError -** -** -**===========================================================================*/ -#include - -/* SHLEXT is defined only for Unix variants */ - -#if defined(SHLEXT) -#define rgchLibraryFile1 "dllmain1"SHLEXT -#define rgchLibraryFile2 "dllmain2"SHLEXT -#define szFunction "GetAttachCount" -#else -#define rgchLibraryFile1 "dllmain1" -#define rgchLibraryFile2 "dllmain2" -#define szFunction "_GetAttachCount@0" -#endif - -/* define our test function type */ -typedef int ( PALAPI *LPTESTFUNC )( void ); - - - -/** - * ThreadFunc - * - * Dummy thread function for causing DLL thread notifications. - */ -DWORD PALAPI ThreadFunc( LPVOID param ) -{ - /* simulate some brief "work" */ - int i; - for( i=0; i<100000; i++ ) - { - } - - return 0; -} - - -/* main program entry point */ -int __cdecl main( int argc, char **argv ) - -{ - /* local variables */ - - HANDLE hLib1 = NULL; - HANDLE hLib2 = NULL; - LPTESTFUNC pFunc1; - LPTESTFUNC pFunc2; - int attachCount1a = 0; - int attachCount1b = 0; - int attachCount2a = 0; - int attachCount2b = 0; - - HANDLE hThread = NULL; - DWORD IDThread; - DWORD dwRet; - - BOOL bResult = FAIL; - - /* initialize the PAL */ - if( PAL_Initialize(argc, argv) != 0 ) - { - return( FAIL ); - } - - /* Load the first test library */ - hLib1 = LoadLibrary( rgchLibraryFile1 ); - if(hLib1 == NULL) - { - Fail( "ERROR:%lu:LoadLibrary() call failed for %s\n", - GetLastError(), - rgchLibraryFile1 ); - } - - /* Load the second test library */ - hLib2 = LoadLibrary( rgchLibraryFile2 ); - if(hLib2 == NULL) - { - Trace( "ERROR:%lu:LoadLibrary() call failed for %s\n", - GetLastError(), - rgchLibraryFile2 ); - if( ! FreeLibrary( hLib1 ) ) - { - Trace( "ERROR:%lu:FreeLibrary() call failed\n", GetLastError() ); - } - Fail( "test failed\n" ); - } - - - /* Get the addresses of our test functions in the dlls */ - pFunc1 = (LPTESTFUNC)GetProcAddress( hLib1, szFunction ); - if( pFunc1 == NULL ) - { - Trace( "ERROR:%lu%:Unable to find \"%s\" in library \"%s\"\n", - GetLastError(), - szFunction, - rgchLibraryFile1 ); - goto cleanup; - } - - pFunc2 = (LPTESTFUNC)GetProcAddress( hLib2, szFunction ); - if( pFunc1 == NULL ) - { - Trace( "ERROR:%lu%:Unable to find \"%s\" in library \"%s\"\n", - GetLastError(), - szFunction, - rgchLibraryFile2 ); - goto cleanup; - } - - /* disable thread library calls for the first library */ - if( ! DisableThreadLibraryCalls( (HMODULE)hLib1 ) ) - { - Trace( "ERROR:%lu:DisableThreadLibraryCalls() call failed\n", - GetLastError() ); - goto cleanup; - } - - /* Execute the test function to get the attach count */ - attachCount1a = pFunc1(); - attachCount2a = pFunc2(); - - /* run another dummy thread to cause notification of the libraries */ - hThread = CreateThread( NULL, /* no security attributes */ - 0, /* use default stack size */ - (LPTHREAD_START_ROUTINE) ThreadFunc, /* thread function */ - (LPVOID) NULL, /* pass thread index as */ - /* function argument */ - CREATE_SUSPENDED, /* create suspended */ - &IDThread ); /* returns thread id */ - - /* Check the return value for success. */ - if( hThread == NULL ) - { - /* error creating thread */ - Trace( "ERROR:%lu:CreateThread() call failed\n", - GetLastError() ); - goto cleanup; - } - - /* Resume the suspended thread */ - if( ResumeThread( hThread ) == -1 ) - { - Trace( "ERROR:%lu:ResumeThread() call failed\n", GetLastError() ); - goto cleanup; - } - - - /* wait for the thread to complete */ - dwRet = WaitForSingleObject( hThread, INFINITE ); - if( dwRet != WAIT_OBJECT_0 ) - { - Trace( "ERROR: WaitForSingleObject returned %lu, " - "expected WAIT_OBJECT_0\n", - dwRet ); - goto cleanup; - } - - - /* Execute the test function to get the new detach count */ - attachCount1b = pFunc1(); - attachCount2b = pFunc2(); - - /* validate the result */ - if( attachCount1b != attachCount1a ) - { - Trace( "FAIL: unexpected DLL attach count %d, expected %d\n", - attachCount1b, - attachCount1a ); - goto cleanup; - } - - /* validate the result */ - if( attachCount2b != (attachCount2a + 1) ) - { - Trace( "FAIL: unexpected DLL attach count %d, expected %d\n", - attachCount2b, - (attachCount2a + 1) ); - goto cleanup; - } - - bResult = PASS; - -cleanup: - /* Unload the test libraries */ - if( !FreeLibrary( hLib1 ) ) - { - Trace( "ERROR:%u:FreeLibrary() failed on library \"%s\"\n", - GetLastError(), - rgchLibraryFile1 ); - bResult = FAIL; - } - - if( !FreeLibrary( hLib2 ) ) - { - Trace( "ERROR:%u:FreeLibrary() failed on library \"%s\"\n", - GetLastError(), - rgchLibraryFile2 ); - bResult = FAIL; - } - - /* check for failure */ - if( bResult == FAIL ) - { - Fail( "test failed\n" ); - } - - /* terminate the PAL */ - PAL_Terminate(); - - /* return success */ - return PASS; -} - diff --git a/src/pal/tests/palsuite/threading/DisableThreadLibraryCalls/test2/testinfo.dat b/src/pal/tests/palsuite/threading/DisableThreadLibraryCalls/test2/testinfo.dat deleted file mode 100644 index 6d2859562..000000000 --- a/src/pal/tests/palsuite/threading/DisableThreadLibraryCalls/test2/testinfo.dat +++ /dev/null @@ -1,18 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = threading -Function = DisableThreadLibraryCalls -Name = Test for DisableThreadLibraryCalls -TYPE = DEFAULT -EXE1 = test2 -LIB1 = dllmain1 -LIB2 = dllmain2 -Description -= Test to ensure proper operation of the DisableThreadLibraryCalls() -= API. This tests to make sure the DisableThreadLibraryCalls() called -= for one DLL loaded by a process takes effect *only* for that DLL -= and not for any others, by checking the THREAD_ATTACH notifications -= in each. diff --git a/src/pal/tests/palsuite/threading/DuplicateHandle/CMakeLists.txt b/src/pal/tests/palsuite/threading/DuplicateHandle/CMakeLists.txt deleted file mode 100644 index 9d5fc53a2..000000000 --- a/src/pal/tests/palsuite/threading/DuplicateHandle/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test10) -add_subdirectory(test11) -add_subdirectory(test12) -add_subdirectory(test2) -add_subdirectory(test3) -add_subdirectory(test4) -add_subdirectory(test5) -add_subdirectory(test6) -add_subdirectory(test7) -add_subdirectory(test8) - diff --git a/src/pal/tests/palsuite/threading/DuplicateHandle/test1/CMakeLists.txt b/src/pal/tests/palsuite/threading/DuplicateHandle/test1/CMakeLists.txt deleted file mode 100644 index f5fb47c0f..000000000 --- a/src/pal/tests/palsuite/threading/DuplicateHandle/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_duplicatehandle_test1 - ${SOURCES} -) - -add_dependencies(paltest_duplicatehandle_test1 coreclrpal) - -target_link_libraries(paltest_duplicatehandle_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/DuplicateHandle/test1/test1.cpp b/src/pal/tests/palsuite/threading/DuplicateHandle/test1/test1.cpp deleted file mode 100644 index e080e98ae..000000000 --- a/src/pal/tests/palsuite/threading/DuplicateHandle/test1/test1.cpp +++ /dev/null @@ -1,152 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test1.c (DuplicateHandle) -** -** Purpose: Tests the PAL implementation of the DuplicateHandle function. -** This test will create two handles to file, one to write and -** one to read what was written. Test on a closed handle and a -** NULL handle, both should fail. -** -** -**===================================================================*/ -#include - -int __cdecl main(int argc, char **argv) -{ - HANDLE hFile; - HANDLE hDupFile; - char buf[256]; - char teststr[] = "A uNiQuE tEsT sTrInG"; - char lpFileName[] = "testfile.txt"; - DWORD dwBytesWritten; - DWORD dwBytesRead; - BOOL bRetVal; - - /*Initalize the PAL*/ - if ((PAL_Initialize(argc,argv)) != 0) - { - return (FAIL); - } - - /*Create a file handle with CreateFile*/ - hFile = CreateFile(lpFileName, - GENERIC_WRITE|GENERIC_READ, - FILE_SHARE_WRITE|FILE_SHARE_READ, - NULL, - OPEN_ALWAYS, - FILE_ATTRIBUTE_NORMAL, - NULL); - if (hFile == INVALID_HANDLE_VALUE) - { - Fail("ERROR: %u :unable to create file \"%s\".\n", - GetLastError(), - lpFileName); - } - - /*Write test string to the file.*/ - bRetVal = WriteFile(hFile, // handle to file - teststr, // data buffer - strlen(teststr), // number of bytes to write - &dwBytesWritten, // number of bytes written - NULL); // overlapped buffer - - if (bRetVal == FALSE) - { - Trace("ERROR: %u : unable to write to file handle " - "hFile=0x%lx\n", - GetLastError(), - hFile); - CloseHandle(hFile); - Fail(""); - } - - /*Create a duplicate handle with DuplicateHandle.*/ - if (!(DuplicateHandle( - GetCurrentProcess(), - hFile, - GetCurrentProcess(), - &hDupFile, - GENERIC_READ|GENERIC_WRITE, - FALSE, - DUPLICATE_SAME_ACCESS))) - { - Trace("ERROR: %u : Fail to create the duplicate handle" - " to hFile=0x%lx\n", - GetLastError(), - hFile); - CloseHandle(hFile); - Fail(""); - } - - memset(buf, 0, 256); - - /*Read from the Duplicated handle.*/ - bRetVal = ReadFile(hDupFile, - buf, - 256, - &dwBytesRead, - NULL); - if (bRetVal == FALSE) - { - Trace("ERROR: %u :unable to read from file handle " - "hFile=0x%lx\n", - GetLastError(), - hFile); - CloseHandle(hFile); - CloseHandle(hDupFile); - Fail(""); - } - - /*Compare what was written to what was read.*/ - if (memcmp(teststr, buf, dwBytesRead) != 0) - { - Trace("ERROR: expected %s, got %s\n", teststr, buf); - CloseHandle(hFile); - CloseHandle(hDupFile); - Fail(""); - } - - /*Close the handles*/ - CloseHandle(hFile); - CloseHandle(hDupFile); - - /*Failure test: Create DuplicateHandle to a closed handle*/ - if ((DuplicateHandle( - GetCurrentProcess(), - hFile, - GetCurrentProcess(), - &hDupFile, - GENERIC_READ|GENERIC_WRITE, - FALSE, - DUPLICATE_SAME_ACCESS))) - { - Fail("ERROR: %u :Created a duplicate handle to" - " a closed handle hFile=0x%lx\n", - GetLastError(), - hFile); - } - - /*Failure test: Create DuplicateHandle to a NULL handle*/ - hFile = NULL; - if ((DuplicateHandle( - GetCurrentProcess(), - hFile, - GetCurrentProcess(), - &hDupFile, - GENERIC_READ|GENERIC_WRITE, - FALSE, - DUPLICATE_SAME_ACCESS))) - { - Fail("ERROR: %u :Created a duplicate handle to " - " a NULL handle hFile=0x%lx\n", - GetLastError(), - hFile); - } - - PAL_Terminate(); - return (PASS); -} diff --git a/src/pal/tests/palsuite/threading/DuplicateHandle/test1/testinfo.dat b/src/pal/tests/palsuite/threading/DuplicateHandle/test1/testinfo.dat deleted file mode 100644 index e22b0bea6..000000000 --- a/src/pal/tests/palsuite/threading/DuplicateHandle/test1/testinfo.dat +++ /dev/null @@ -1,15 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Threading -Function = DuplicateHandle -Name = Positive Test for DuplicateHandle -TYPE = DEFAULT -EXE1 = test1 -Description -= Tests the PAL implementation of the DuplicateHandle function. -= This test will create two handles to file, one to write and -= one to read what was written. Test on a closed handle and a -= NULL handle, both should fail. diff --git a/src/pal/tests/palsuite/threading/DuplicateHandle/test10/CMakeLists.txt b/src/pal/tests/palsuite/threading/DuplicateHandle/test10/CMakeLists.txt deleted file mode 100644 index 135f1494a..000000000 --- a/src/pal/tests/palsuite/threading/DuplicateHandle/test10/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test10.cpp -) - -add_executable(paltest_duplicatehandle_test10 - ${SOURCES} -) - -add_dependencies(paltest_duplicatehandle_test10 coreclrpal) - -target_link_libraries(paltest_duplicatehandle_test10 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/DuplicateHandle/test10/test10.cpp b/src/pal/tests/palsuite/threading/DuplicateHandle/test10/test10.cpp deleted file mode 100644 index 108d748de..000000000 --- a/src/pal/tests/palsuite/threading/DuplicateHandle/test10/test10.cpp +++ /dev/null @@ -1,239 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test10.c (DuplicateHandle) -** -** Purpose: Tests the PAL implementation of the DuplicateHandle function. -** This tests the operation of a duplicated Semaphore handle -** -** -**===================================================================*/ - -#include - -enum wait_results -{ - WR_WAITING, - WR_GOT_MUTEX, - WR_TIMED_OUT, - WR_RELEASED -}; - - -volatile int t1_result=WR_WAITING; -volatile int t2_result=WR_WAITING; - - -DWORD PALAPI ThreadTest1(LPVOID lpParam) -{ - DWORD dwWait; - - dwWait = WaitForSingleObject((HANDLE)lpParam, 0); - if (dwWait == WAIT_OBJECT_0) - { - /* tell the main thread we got the mutex */ - t1_result=WR_GOT_MUTEX; - - /* wait for main thread to tell us to release the mutex */ - while(WR_GOT_MUTEX == t1_result) - Sleep(1); - ReleaseSemaphore((HANDLE)lpParam, 1, NULL); - - /* tell the main thread we released the mutex */ - t1_result = WR_RELEASED; - } - else - { - t1_result = WR_TIMED_OUT; - } - return 0; -} - -DWORD PALAPI ThreadTest2(LPVOID lpParam) -{ - DWORD dwWait; - - dwWait = WaitForSingleObject((HANDLE)lpParam, 0 ); - if (dwWait == WAIT_OBJECT_0) - { - ReleaseSemaphore((HANDLE)lpParam, 1, NULL); - t2_result = WR_GOT_MUTEX; - } - else - { - t2_result = WR_TIMED_OUT; - } - - return 0; -} - - -int __cdecl main(int argc, char **argv) -{ - - HANDLE hDupSemaphore; - HANDLE hSemaphore; - HANDLE hThread; - HANDLE hThread2; - BOOL bDupHandle=FALSE; - DWORD dwThreadId = 0; - - if ((PAL_Initialize(argc,argv)) != 0) - { - return(FAIL); - } - - hSemaphore = CreateSemaphoreW( NULL, - 1, - 1, - NULL); - if (hSemaphore == NULL) - { - Fail("PALSUITE ERROR:%u: Unable to create mutex\n", - GetLastError()); - } - - /*Create Duplicate of the Semaphore above*/ - bDupHandle = DuplicateHandle(GetCurrentProcess(), - hSemaphore, - GetCurrentProcess(), - &hDupSemaphore, - GENERIC_READ|GENERIC_WRITE, - FALSE, - DUPLICATE_SAME_ACCESS); - if (!bDupHandle) - { - Trace("PALSUITE ERROR:%u: Created the duplicate handle to " - "closed event handle hSemaphore=0x%lx\n", - GetLastError(), - hSemaphore); - CloseHandle(hSemaphore); - Fail(""); - } - - /*Create a thread to test the Semaphore*/ - hThread = CreateThread(NULL, - 0, - &ThreadTest1, - hSemaphore, - 0, - &dwThreadId); - if (hThread == NULL) - { - Trace("PALSUITE ERROR:%u: unable to create thread\n", - GetLastError()); - CloseHandle(hSemaphore); - CloseHandle(hDupSemaphore); - Fail(""); - } - - /* wait until thread has taken the mutex */ - while (WR_WAITING == t1_result) - Sleep(1); - - if(WR_TIMED_OUT == t1_result) - { - Trace("PALSUITE ERROR: %u: thread couldn't acquire the semaphore\n", - GetLastError()); - CloseHandle(hSemaphore); - CloseHandle(hDupSemaphore); - CloseHandle(hThread); - Fail(""); - } - - /*Create a second thread to use the Semaphore's duplicate handle*/ - /*This thread should block since the Semaphore is owned by another - thread*/ - hThread2 = CreateThread(NULL, - 0, - &ThreadTest2, - hDupSemaphore, - 0, - &dwThreadId); - - if (hThread2 == NULL) - { - Trace("PALSUITE ERROR:%u: unable to create thread\n", - GetLastError()); - CloseHandle(hSemaphore); - CloseHandle(hDupSemaphore); - CloseHandle(hThread); - Fail(""); - } - - /* wait until thread has tried to take the mutex */ - while (WR_WAITING == t2_result) - Sleep(1); - - if (WR_TIMED_OUT != t2_result ) - { - Trace("PALSUITE ERROR:%u: Able to take mutex %#x while its " - "duplicate %#x is held\n", GetLastError(), hDupSemaphore, - hSemaphore); - CloseHandle(hSemaphore); - CloseHandle(hDupSemaphore); - CloseHandle(hThread); - CloseHandle(hThread2); - Fail(""); - } - - /* reset second thread status */ - t2_result = WR_WAITING; - - /* tell thread 1 to release the mutex */ - t1_result = WR_WAITING; - - /* wait for thread 1 to release the mutex */ - while (WR_WAITING == t1_result) - Sleep(1); - - CloseHandle(hThread2); - - /*Re-Create the second thread to reuse the duplicated Semaphore*/ - /*Since the Semaphore has since been released, the thread should - put WR_GOT_MUTEX into t2_result */ - hThread2 = CreateThread(NULL, - 0, - &ThreadTest2, - hDupSemaphore, - 0, - &dwThreadId); - - if (hThread2 == NULL) - { - Trace("PALSUITE ERROR:%u: unable to create thread\n", - GetLastError()); - CloseHandle(hSemaphore); - CloseHandle(hDupSemaphore); - CloseHandle(hThread); - Fail(""); - } - - /* wait until thread has taken the semaphore */ - while (WR_WAITING == t2_result) - Sleep(1); - - if (WR_GOT_MUTEX != t2_result ) - { - Trace("PALSUITE ERROR:%u: Unable to take semaphore %#x after its" - " duplicate %#x was released\n", GetLastError(), hDupSemaphore, - hSemaphore); - CloseHandle(hSemaphore); - CloseHandle(hDupSemaphore); - CloseHandle(hThread); - CloseHandle(hThread2); - Fail(""); - } - - /*Cleanup.*/ - CloseHandle(hSemaphore); - CloseHandle(hDupSemaphore); - CloseHandle(hThread); - CloseHandle(hThread2); - - PAL_Terminate(); - return (PASS); -} diff --git a/src/pal/tests/palsuite/threading/DuplicateHandle/test10/testinfo.dat b/src/pal/tests/palsuite/threading/DuplicateHandle/test10/testinfo.dat deleted file mode 100644 index 674c71c2b..000000000 --- a/src/pal/tests/palsuite/threading/DuplicateHandle/test10/testinfo.dat +++ /dev/null @@ -1,17 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Threading -Function = DuplicateHandle -Name = Test for DuplicateHandle (CreateSemaphore) -TYPE = DEFAULT -EXE1 = test10 -Description -= Tests the PAL implementation of the DuplicateHandle function. -= This test duplication of a Semaphore handle. The test will -= create a Semaphore and duplicate a handle to it. -= Then two subthreads will be used to verify that they can selectively -= block each other with different handles that refer to the -= same Semaphore diff --git a/src/pal/tests/palsuite/threading/DuplicateHandle/test11/CMakeLists.txt b/src/pal/tests/palsuite/threading/DuplicateHandle/test11/CMakeLists.txt deleted file mode 100644 index 5584b9d1e..000000000 --- a/src/pal/tests/palsuite/threading/DuplicateHandle/test11/CMakeLists.txt +++ /dev/null @@ -1,32 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(TESTSOURCES - test11.cpp -) - -add_executable(paltest_duplicatehandle_test11 - ${TESTSOURCES} -) - -add_dependencies(paltest_duplicatehandle_test11 coreclrpal) - -target_link_libraries(paltest_duplicatehandle_test11 - ${COMMON_TEST_LIBRARIES} -) - - -set(HELPERSOURCES - childprocess.cpp -) - -add_executable(paltest_duplicatehandle_test11_child - ${HELPERSOURCES} -) - -add_dependencies(paltest_duplicatehandle_test11_child coreclrpal) - -target_link_libraries(paltest_duplicatehandle_test11_child - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/DuplicateHandle/test11/childprocess.cpp b/src/pal/tests/palsuite/threading/DuplicateHandle/test11/childprocess.cpp deleted file mode 100644 index d5b310e46..000000000 --- a/src/pal/tests/palsuite/threading/DuplicateHandle/test11/childprocess.cpp +++ /dev/null @@ -1,74 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source: childprocess.c -** -** Purpose: Test to ensure DuplicateHandle works properly. -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** CreateMutexW -** WaitForSingleObject -** CloseHandle -** -** -**=========================================================*/ - -#include -#include "myexitcode.h" - - -int __cdecl main( int argc, char **argv ) -{ - HANDLE hMutex; - WCHAR wszMutexName[] = { 'T','E','S','T','1','1','\0' }; - DWORD dwRet; - int i; - - /* initialize the PAL */ - if( PAL_Initialize(argc, argv) != 0 ) - { - return( FAIL ); - } - - /* open a mutex to synchronize with the parent process */ - hMutex = CreateMutexW( NULL, FALSE, wszMutexName ); - if( hMutex == NULL ) - { - Fail( "ERROR:%lu:CreateMutex() call failed\r\n", GetLastError() ); - } - - /* acquire the mutex lock */ - dwRet = WaitForSingleObject( hMutex, 10000 ); - if( dwRet != WAIT_OBJECT_0 ) - { - Trace( "ERROR:WaitForSingleObject() returned %lu, " - "expected WAIT_OBJECT_0", - dwRet ); - if( ! CloseHandle( hMutex ) ) - { - Trace( "ERROR:%lu:CloseHandle() call failed\n", GetLastError() ); - } - Fail( "test failed\n" ); - } - - - /* simulate some activity */ - for( i=0; i<50000; i++ ) - ; - - /* close our mutex handle */ - if( ! CloseHandle( hMutex ) ) - { - Fail( "ERROR:%lu:CloseHandle() call failed\n", GetLastError() ); - } - - /* terminate the PAL */ - PAL_Terminate(); - - /* return the predefined exit code */ - return TEST_EXIT_CODE; -} diff --git a/src/pal/tests/palsuite/threading/DuplicateHandle/test11/myexitcode.h b/src/pal/tests/palsuite/threading/DuplicateHandle/test11/myexitcode.h deleted file mode 100644 index 84801cbb5..000000000 --- a/src/pal/tests/palsuite/threading/DuplicateHandle/test11/myexitcode.h +++ /dev/null @@ -1,13 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source: duplicatehandle/test11/myexitcode.h -** -** Purpose: Define an exit code constant. -** -** -**=========================================================*/ -#define TEST_EXIT_CODE 31 diff --git a/src/pal/tests/palsuite/threading/DuplicateHandle/test11/test11.cpp b/src/pal/tests/palsuite/threading/DuplicateHandle/test11/test11.cpp deleted file mode 100644 index b05244c4b..000000000 --- a/src/pal/tests/palsuite/threading/DuplicateHandle/test11/test11.cpp +++ /dev/null @@ -1,364 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================= -** -** Source: test11.c -** -** Purpose: -** -** Test to ensure proper operation of the DuplicateHandle API. -** The test launches a trivial child process, then opens -** a handle to it using OpenProcess. It then duplicates that -** handle and uses it to wait for the child process to terminate, -** and then checks the exit code of the child process in order to -** verify that it was in fact a handle to the correct -** process. The test tries to duplicate the handle again after -** the process has been closed, to verify that failure ensues. -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** Fail -** ZeroMemory -** GetCurrentDirectoryW -** CreateProcessW -** WaitForSingleObject -** CreateMutexW -** ReleaseMutex -** CloseHandle -** GetLastError -** strlen -** strncpy -** -** -**===========================================================================*/ -#include -#include "myexitcode.h" - - -static const char* rgchPathDelim = "\\"; - - -int -mkAbsoluteFilename( LPSTR dirName, - DWORD dwDirLength, - LPCSTR fileName, - DWORD dwFileLength, - LPSTR absPathName ) -{ - DWORD sizeDN, sizeFN, sizeAPN; - - sizeDN = strlen( dirName ); - sizeFN = strlen( fileName ); - sizeAPN = (sizeDN + 1 + sizeFN + 1); - - /* ensure ((dirName + DELIM + fileName + \0) =< _MAX_PATH ) */ - if( sizeAPN > _MAX_PATH ) - { - return ( 0 ); - } - - strncpy( absPathName, dirName, dwDirLength +1 ); - strncpy( absPathName, rgchPathDelim, 2 ); - strncpy( absPathName, fileName, dwFileLength +1 ); - - return (sizeAPN); - -} - - -int __cdecl main( int argc, char **argv ) - -{ - const char* rgchChildFile = "childprocess"; - - STARTUPINFO si; - PROCESS_INFORMATION pi; - - DWORD dwError; - DWORD dwExitCode; - DWORD dwFileLength; - DWORD dwDirLength; - DWORD dwSize; - DWORD dwRet; - - HANDLE hMutex; - HANDLE hChildProcess; - HANDLE hDupChildProcess; - - char rgchDirName[_MAX_DIR]; - char absPathBuf[_MAX_PATH]; - char* rgchAbsPathName; - - BOOL ret = FAIL; - BOOL bChildDone = FALSE; - WCHAR wszMutexName[] = { 'T','E','S','T','1','1','\0' }; - - /* initialize the PAL */ - if( PAL_Initialize(argc, argv) != 0 ) - { - return( FAIL ); - } - - /* create a mutex to synchronize with the child process */ - hMutex = CreateMutexW( NULL, TRUE, wszMutexName ); - if( hMutex == NULL ) - { - Fail( "ERROR:%lu:CreateMutex() call failed\r\n", GetLastError() ); - } - - /* zero our process and startup info structures */ - ZeroMemory( &si, sizeof(si) ); - si.cb = sizeof( si ); - ZeroMemory( &pi, sizeof(pi) ); - - /* build the absolute path to the child process */ - rgchAbsPathName = &absPathBuf[0]; - dwFileLength = strlen( rgchChildFile ); - - dwDirLength = GetCurrentDirectory( _MAX_PATH, rgchDirName ); - if( dwDirLength == 0 ) - { - dwError = GetLastError(); - if( ReleaseMutex( hMutex ) == 0 ) - { - Trace( "ERROR:%lu:ReleaseMutex() call failed\n", GetLastError() ); - } - if( CloseHandle( hMutex ) == 0 ) - { - Trace( "ERROR:%lu:CloseHandle() call failed\n", GetLastError() ); - } - Fail( "GetCurrentDirectory call failed with error code %d\n", - dwError ); - } - - dwSize = mkAbsoluteFilename( rgchDirName, - dwDirLength, - rgchChildFile, - dwFileLength, - rgchAbsPathName ); - if( dwSize == 0 ) - { - if( ReleaseMutex( hMutex ) == 0 ) - { - Trace( "ERROR:%lu:ReleaseMutex() call failed\n", GetLastError() ); - } - if( CloseHandle( hMutex ) == 0 ) - { - Trace( "ERROR:%lu:CloseHandle() call failed\n", GetLastError() ); - } - Fail( "Palsuite Code: mkAbsoluteFilename() call failed. Could ", - "not build absolute path name to file\n. Exiting.\n" ); - } - - /* launch the child process */ - if( !CreateProcess( NULL, /* module name to execute */ - rgchAbsPathName, /* command line */ - NULL, /* process handle not */ - /* inheritable */ - NULL, /* thread handle not */ - /*inheritable */ - FALSE, /* handle inheritance */ - CREATE_NEW_CONSOLE, /* dwCreationFlags */ - NULL, /* use parent's environment */ - NULL, /* use parent's starting */ - /* directory */ - &si, /* startup info struct */ - &pi ) /* process info struct */ - ) - { - dwError = GetLastError(); - if( ReleaseMutex( hMutex ) == 0 ) - { - Trace( "ERROR:%lu:ReleaseMutex() call failed\n", GetLastError() ); - } - if( CloseHandle( hMutex ) == 0 ) - { - Trace( "ERROR:%lu:CloseHandle() call failed\n", GetLastError() ); - } - Fail( "CreateProcess call failed with error code %d\n", - dwError ); - } - - /* open another handle to the child process */ - hChildProcess = OpenProcess( PROCESS_ALL_ACCESS, /* access */ - FALSE, /* inheritable */ - pi.dwProcessId /* process id */ - ); - if( hChildProcess == NULL ) - { - dwError = GetLastError(); - if( ReleaseMutex( hMutex ) == 0 ) - { - Trace( "ERROR:%lu:ReleaseMutex() call failed\n", GetLastError() ); - } - Trace( "ERROR:%lu:OpenProcess call failed\n", dwError ); - goto cleanup3; - } - - /* duplicate the child process handle */ - if( ! DuplicateHandle( GetCurrentProcess(), - hChildProcess, - GetCurrentProcess(), - &hDupChildProcess, - GENERIC_READ|GENERIC_WRITE, - FALSE, - DUPLICATE_SAME_ACCESS) ) - { - Trace( "ERROR:%lu:DuplicateHandle() call failed\n", GetLastError() ); - if( ReleaseMutex( hMutex ) == 0 ) - { - Trace( "ERROR:%lu:ReleaseMutex() call failed\n", GetLastError() ); - } - goto cleanup2; - } - - /* release the mutex so the child can proceed */ - if( ReleaseMutex( hMutex ) == 0 ) - { - Trace( "ERROR:%lu:ReleaseMutex() call failed\n", GetLastError() ); - goto cleanup1; - } - - /* wait for the child process to complete, using the new handle */ - dwRet = WaitForSingleObject( hDupChildProcess, 10000 ); - if( dwRet != WAIT_OBJECT_0 ) - { - Trace( "ERROR:WaitForSingleObject call returned %lu, " - "expected WAIT_OBJECT_0", - dwRet ); - goto cleanup1; - } - - /* remember that we waited until the child was finished */ - bChildDone = TRUE; - - /* check the exit code from the process -- this is a bit of an */ - /* extra verification that we opened the correct process handle */ - if( ! GetExitCodeProcess( hDupChildProcess, &dwExitCode ) ) - { - Trace( "ERROR:%lu:GetExitCodeProcess call failed\n", GetLastError() ); - goto cleanup1; - } - - /* verification */ - if( (dwExitCode & 0xFF) != (TEST_EXIT_CODE & 0xFF) ) - { - Trace( "GetExitCodeProcess returned an incorrect exit code %d, " - "expected value is %d\n", - (dwExitCode & 0xFF), - (TEST_EXIT_CODE & 0xFF)); - goto cleanup1; - } - - /* close the duplicate handle */ - if( ! CloseHandle( hDupChildProcess ) ) - { - Trace( "ERROR:%lu:CloseHandle call failed\n", GetLastError() ); - goto cleanup2; - } - - /* close the child process handle */ - if( ! CloseHandle ( hChildProcess ) ) - { - Trace( "ERROR:%lu:CloseHandle() call failed\n", GetLastError() ); - goto cleanup3; - } - - /* try to call duplicate handle on the closed child process handle */ - if( DuplicateHandle( GetCurrentProcess(), - hChildProcess, - GetCurrentProcess(), - &hDupChildProcess, - GENERIC_READ|GENERIC_WRITE, - FALSE, - DUPLICATE_SAME_ACCESS) ) - { - Trace( "ERROR:%lu:DuplicateHandle call succeeded on " - "a closed process handle, expected ERROR_INVALID_HANDLE\n" ); - if( ! CloseHandle( hDupChildProcess ) ) - { - Trace( "ERROR:%lu:CloseHandle call failed\n", GetLastError() ); - } - goto cleanup3; - } - - /* verify that the last error was ERROR_INVALID_HANDLE */ - dwRet = GetLastError(); - if( dwRet != ERROR_INVALID_HANDLE ) - { - Trace( "ERROR:DuplicateHandle returned %lu, " - "expected ERROR_INVALID_HANDLE\n", - dwRet ); - goto cleanup3; - } - - - /* success if we get here */ - ret = PASS; - - /* skip the cleanup stuff that's already done */ - goto cleanup3; - - -cleanup1: - /* close our duplicate handle */ - if( ! CloseHandle( hDupChildProcess ) ) - { - Trace( "ERROR:%lu:CloseHandle call failed\n", GetLastError() ); - ret = FAIL; - } - -cleanup2: - /* wait on the child process to complete if necessary */ - if( ! bChildDone ) - { - dwRet = WaitForSingleObject( hChildProcess, 10000 ); - if( dwRet != WAIT_OBJECT_0 ) - { - Trace( "ERROR:WaitForSingleObject call returned %lu, " - "expected WAIT_OBJECT_0", - dwRet ); - ret = FAIL; - } - } - - /* close our child process handle */ - if( CloseHandle ( hChildProcess ) == 0 ) - { - Trace( "ERROR:%lu:CloseHandle() call failed\n", GetLastError() ); - ret = FAIL; - } - -cleanup3: - /* close all our other handles */ - if( CloseHandle ( pi.hProcess ) == 0 ) - { - Trace( "ERROR:%lu:CloseHandle() call failed\n", GetLastError() ); - ret = FAIL; - } - if( CloseHandle ( pi.hThread ) == 0 ) - { - Trace( "ERROR:%lu:CloseHandle() call failed\n", GetLastError() ); - ret = FAIL; - } - if( CloseHandle( hMutex ) == 0 ) - { - Trace( "ERROR:%lu:CloseHandle() call failed\n", GetLastError() ); - ret = FAIL; - } - - if( ret == FAIL ) - { - Fail( "test failed\n" ); - } - - - - /* terminate the PAL */ - PAL_Terminate(); - - /* return success */ - return PASS; -} diff --git a/src/pal/tests/palsuite/threading/DuplicateHandle/test11/testinfo.dat b/src/pal/tests/palsuite/threading/DuplicateHandle/test11/testinfo.dat deleted file mode 100644 index 193787788..000000000 --- a/src/pal/tests/palsuite/threading/DuplicateHandle/test11/testinfo.dat +++ /dev/null @@ -1,19 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = threading -Function = DuplicateHandle -Name = Test for DuplicateHandle -TYPE = DEFAULT -EXE1 = test11 -EXE2 = childprocess -Description -= Test to ensure proper operation of the DuplicateHandle API. -= The test launches a trivial child process, then opens -= a handle to it using OpenProcess. It then duplicates that -= handle and uses it to wait for the child process to terminate, -= and then checks the exit code of the child process in order to -= verify that it was in fact a handle to the correct= process. The test tries to duplicate the handle again after -= the process has been closed, to verify that failure ensues. diff --git a/src/pal/tests/palsuite/threading/DuplicateHandle/test12/CMakeLists.txt b/src/pal/tests/palsuite/threading/DuplicateHandle/test12/CMakeLists.txt deleted file mode 100644 index fb5ed234c..000000000 --- a/src/pal/tests/palsuite/threading/DuplicateHandle/test12/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test12.cpp -) - -add_executable(paltest_duplicatehandle_test12 - ${SOURCES} -) - -add_dependencies(paltest_duplicatehandle_test12 coreclrpal) - -target_link_libraries(paltest_duplicatehandle_test12 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/DuplicateHandle/test12/test12.cpp b/src/pal/tests/palsuite/threading/DuplicateHandle/test12/test12.cpp deleted file mode 100644 index 519194bc3..000000000 --- a/src/pal/tests/palsuite/threading/DuplicateHandle/test12/test12.cpp +++ /dev/null @@ -1,129 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test12.c (DuplicateHandle) -** -** Purpose: Tests the PAL implementation of the DuplicateHandle function. -** This test will create handle to file (to write) and close it, -** then call duplicate handle to read what was written. -** -** -**===================================================================*/ -#include - -int __cdecl main(int argc, char **argv) -{ - HANDLE hFile; - HANDLE hDupFile; - char buf[256]; - char teststr[] = "A uNiQuE tEsT sTrInG"; - char lpFileName[] = "testfile.txt"; - DWORD dwBytesWritten; - DWORD dwBytesRead; - BOOL bRetVal; - - /*Initalize the PAL*/ - if ((PAL_Initialize(argc,argv)) != 0) - { - return (FAIL); - } - - /*Create a file handle with CreateFile*/ - hFile = CreateFile(lpFileName, - GENERIC_WRITE|GENERIC_READ, - FILE_SHARE_WRITE|FILE_SHARE_READ, - NULL, - OPEN_ALWAYS, - FILE_ATTRIBUTE_NORMAL, - NULL); - if (hFile == INVALID_HANDLE_VALUE) - { - Fail("ERROR: %u :unable to create file \"%s\".\n", - GetLastError(), - lpFileName); - } - - /*Write test string to the file.*/ - bRetVal = WriteFile(hFile, // handle to file - teststr, // data buffer - strlen(teststr), // number of bytes to write - &dwBytesWritten, // number of bytes written - NULL); // overlapped buffer - - if (bRetVal == FALSE) - { - Trace("ERROR: %u : unable to write to file handle " - "hFile=0x%lx\n", - GetLastError(), - hFile); - CloseHandle(hFile); - Fail(""); - } - - /*Create a duplicate handle with DuplicateHandle.*/ - if (!(DuplicateHandle( - GetCurrentProcess(), - hFile, - GetCurrentProcess(), - &hDupFile, - GENERIC_READ|GENERIC_WRITE, - FALSE, - DUPLICATE_SAME_ACCESS))) - { - Trace("ERROR: %u : Fail to create the duplicate handle" - " to hFile=0x%lx\n", - GetLastError(), - hFile); - CloseHandle(hFile); - Fail(""); - } - - if( !CloseHandle(hFile) ) - { - Fail("Duplicate Handle:Unable to close original file: Error[%u]\n", GetLastError()); - } - - memset(buf, 0, 256); - - /*Read from the Duplicated handle.*/ - bRetVal = ReadFile(hDupFile, - buf, - 256, - &dwBytesRead, - NULL); - if (bRetVal == FALSE) - { - Trace("ERROR: %u :unable to read from file handle " - "hFile=0x%lx\n", - GetLastError(), - hDupFile); - CloseHandle(hDupFile); - Fail(""); - } - - /*Compare what was written to what was read.*/ - if (memcmp(teststr, buf, dwBytesRead) != 0) - { - Trace("ERROR: expected %s, got %s\n", teststr, buf); - CloseHandle(hDupFile); - Fail(""); - } - - /*Close the handles*/ - CloseHandle(hDupFile); - - bRetVal = DeleteFileA(lpFileName); - if (bRetVal != TRUE) - { - Trace("Error:%u: DuplicateHandle, DeleteFileA: Couldn't delete DeleteFileA's" - " %s\n", GetLastError(), lpFileName); - Fail(""); - } - - - PAL_Terminate(); - return (PASS); -} diff --git a/src/pal/tests/palsuite/threading/DuplicateHandle/test12/testinfo.dat b/src/pal/tests/palsuite/threading/DuplicateHandle/test12/testinfo.dat deleted file mode 100644 index 3d73362eb..000000000 --- a/src/pal/tests/palsuite/threading/DuplicateHandle/test12/testinfo.dat +++ /dev/null @@ -1,15 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Threading -Function = DuplicateHandle -Name = Positive Test for DuplicateHandle -TYPE = DEFAULT -EXE1 = test1 -Description -= Tests the PAL implementation of the DuplicateHandle function. -= This test will create handle to file (to write), -= then call duplicate handle, and close the original handle -= and then use duplicated handle to read what was written. diff --git a/src/pal/tests/palsuite/threading/DuplicateHandle/test2/CMakeLists.txt b/src/pal/tests/palsuite/threading/DuplicateHandle/test2/CMakeLists.txt deleted file mode 100644 index 9668dfd10..000000000 --- a/src/pal/tests/palsuite/threading/DuplicateHandle/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test2.cpp -) - -add_executable(paltest_duplicatehandle_test2 - ${SOURCES} -) - -add_dependencies(paltest_duplicatehandle_test2 coreclrpal) - -target_link_libraries(paltest_duplicatehandle_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/DuplicateHandle/test2/test2.cpp b/src/pal/tests/palsuite/threading/DuplicateHandle/test2/test2.cpp deleted file mode 100644 index d1411e62d..000000000 --- a/src/pal/tests/palsuite/threading/DuplicateHandle/test2/test2.cpp +++ /dev/null @@ -1,96 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test2.c (DuplicateHandle) -** -** Purpose: Tests the PAL implementation of the DuplicateHandle function. -** This will test duplication of an CreateEvent handle. Test an -** event in a signaled state to wait, and then set the duplicate -** to nonsignaled state and perform the wait again. The wait on -** the event should fail. Test the duplication of closed and NULL -** events, these should fail. -** -** -**===================================================================*/ -#include - -int __cdecl main(int argc, char **argv) -{ - HANDLE hEvent; - HANDLE hDupEvent; - - /*Initalize the PAL.*/ - if ((PAL_Initialize(argc,argv)) != 0) - { - return (FAIL); - } - - /*Create an Event, and set it in the signaled state.*/ - hEvent = CreateEvent(0, TRUE, TRUE, 0); - if (hEvent == NULL) - { - Fail("ERROR: %u :unable to create event\n", - GetLastError()); - } - - /*Create a duplicate Event handle.*/ - if (!(DuplicateHandle(GetCurrentProcess(), - hEvent,GetCurrentProcess(), - &hDupEvent, - GENERIC_READ|GENERIC_WRITE, - FALSE, DUPLICATE_SAME_ACCESS))) - { - Trace("ERROR: %u :Fail to create the duplicate handle" - " to hEvent=0x%lx\n", - GetLastError(), - hEvent); - CloseHandle(hEvent); - Fail(""); - } - - /*Perform wait on Event that is in signaled state.*/ - if ((WaitForSingleObject(hEvent, 1000)) != WAIT_OBJECT_0) - { - Trace("ERROR: %u :WaitForSignalObject on Event=0x%lx set to " - " signaled state failed", - GetLastError(), - hEvent); - CloseHandle(hEvent); - CloseHandle(hDupEvent); - Fail(""); - } - - /*Set the Duplicate Event handle to nonsignaled state.*/ - if ((ResetEvent(hDupEvent)) == 0) - { - Trace("ERROR: %u :unable to reset dup event\n", - GetLastError()); - CloseHandle(hEvent); - CloseHandle(hDupEvent); - Fail(""); - } - - /*Perform wait on Event that is in signaled state.*/ - if ((WaitForSingleObject(hEvent, 1000)) == WAIT_OBJECT_0) - { - Trace("ERROR: %u: WaitForSignalObject succeeded on Event=0x%lx " - " when Duplicate Event=0x%lx set to nonsignaled state" - " succeeded\n", - GetLastError(), - hEvent, - hDupEvent); - CloseHandle(hEvent); - CloseHandle(hDupEvent); - Fail(""); - } - - /*Close handles to events.*/ - CloseHandle(hEvent); - CloseHandle(hDupEvent); - - PAL_Terminate(); - return (PASS); -} diff --git a/src/pal/tests/palsuite/threading/DuplicateHandle/test2/testinfo.dat b/src/pal/tests/palsuite/threading/DuplicateHandle/test2/testinfo.dat deleted file mode 100644 index 273440804..000000000 --- a/src/pal/tests/palsuite/threading/DuplicateHandle/test2/testinfo.dat +++ /dev/null @@ -1,17 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Threading -Function = DuplicateHandle -Name = Test for DuplicateHandle -TYPE = DEFAULT -EXE1 = test2 -Description -= Tests the PAL implementation of the DuplicateHandle function. -= This will test duplication of an CreateEvent handle. Test an -= event in a signaled state to wait, and then set the duplicate -= to nonsignaled state and perform the wait again. The wait on -= the event should fail. Test the duplication of closed and NULL -= events, these should fail. diff --git a/src/pal/tests/palsuite/threading/DuplicateHandle/test3/CMakeLists.txt b/src/pal/tests/palsuite/threading/DuplicateHandle/test3/CMakeLists.txt deleted file mode 100644 index e44c2a2f7..000000000 --- a/src/pal/tests/palsuite/threading/DuplicateHandle/test3/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test3.cpp -) - -add_executable(paltest_duplicatehandle_test3 - ${SOURCES} -) - -add_dependencies(paltest_duplicatehandle_test3 coreclrpal) - -target_link_libraries(paltest_duplicatehandle_test3 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/DuplicateHandle/test3/test3.cpp b/src/pal/tests/palsuite/threading/DuplicateHandle/test3/test3.cpp deleted file mode 100644 index fc91b5ec2..000000000 --- a/src/pal/tests/palsuite/threading/DuplicateHandle/test3/test3.cpp +++ /dev/null @@ -1,123 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test3.c (DuplicateHandle) -** -** Purpose: Tests the PAL implementation of the DuplicateHandle function. -** This will test duplication of an OpenEvent handle. Test an -** event in a signaled state to wait, and then set the duplicate -** to nonsignaled state and perform the wait again. The wait on -** the event should fail. Test the duplication of closed and NULL -** events, these should fail. -** -** -**===================================================================*/ -#include - -int __cdecl main(int argc, char **argv) -{ - HANDLE hCreateEvent; - HANDLE hOpenEvent; - HANDLE hDupEvent; - WCHAR lpEventName[]={'E','v','e','n','t','\0'}; - - /*Initialize the PAL.*/ - if ((PAL_Initialize(argc,argv)) != 0) - { - return (FAIL); - } - - /*Create an Event, and set it in the signaled state.*/ - hCreateEvent = CreateEventW(0, - TRUE, - TRUE, - lpEventName); - if (hCreateEvent == NULL) - { - Fail("ERROR: %u :unable to create event %s\n", - GetLastError(), - lpEventName); - } - - /*Open another handle to hCreateHandle with OpenEvent*/ - hOpenEvent = OpenEventW(EVENT_ALL_ACCESS, - TRUE, - lpEventName); - if (hOpenEvent == NULL) - { - Trace("ERROR: %u :unable to create handle with OpenEvent to %s\n", - GetLastError(), - lpEventName); - CloseHandle(hCreateEvent); - Fail(""); - } - - /*Create a duplicate Event handle*/ - if (!(DuplicateHandle(GetCurrentProcess(), - hOpenEvent, - GetCurrentProcess(), - &hDupEvent, - GENERIC_READ|GENERIC_WRITE, - FALSE, - DUPLICATE_SAME_ACCESS))) - { - Trace("ERROR: %u :Fail to create the duplicate handle" - " to hCreateEvent=0x%lx\n", - GetLastError(), - hCreateEvent); - CloseHandle(hCreateEvent); - CloseHandle(hOpenEvent); - Fail(""); - } - - /*Perform wait on Event that is in signaled state*/ - if ((WaitForSingleObject(hOpenEvent, 1000)) != WAIT_OBJECT_0) - { - Trace("ERROR: %u :WaitForSignalObject on hOpenEvent=0x%lx set to " - " signaled state failed\n", - GetLastError(), - hOpenEvent); - CloseHandle(hCreateEvent); - CloseHandle(hOpenEvent); - CloseHandle(hDupEvent); - Fail(""); - } - - /*Set the Duplicate Event handle to nonsignaled state*/ - if ((ResetEvent(hDupEvent)) == 0) - { - Trace("ERROR: %u: unable to reset hDupEvent=0x%lx\n", - GetLastError(), - hDupEvent); - CloseHandle(hCreateEvent); - CloseHandle(hOpenEvent); - CloseHandle(hDupEvent); - Fail(""); - } - - /*Perform wait on Event that is in signaled state*/ - if ((WaitForSingleObject(hOpenEvent, 1000)) == WAIT_OBJECT_0) - { - Trace("ERROR: %u :WaitForSignalObject succeeded on hOpenEvent=0x%lx " - " when Duplicate hDupEvent=0x%lx set to nonsignaled state" - " succeeded\n", - GetLastError(), - hOpenEvent, - hDupEvent); - CloseHandle(hCreateEvent); - CloseHandle(hOpenEvent); - CloseHandle(hDupEvent); - Fail(""); - } - - /*Close handles the events*/ - CloseHandle(hCreateEvent); - CloseHandle(hOpenEvent); - CloseHandle(hDupEvent); - - PAL_Terminate(); - return (PASS); -} diff --git a/src/pal/tests/palsuite/threading/DuplicateHandle/test3/testinfo.dat b/src/pal/tests/palsuite/threading/DuplicateHandle/test3/testinfo.dat deleted file mode 100644 index a10adb9a8..000000000 --- a/src/pal/tests/palsuite/threading/DuplicateHandle/test3/testinfo.dat +++ /dev/null @@ -1,17 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Threading -Function = DuplicateHandle -Name = Test for DuplicateHandle -TYPE = DEFAULT -EXE1 = test3 -Description -= Tests the PAL implementation of the DuplicateHandle function. -= This will test duplication of an OpenEvent handle. Test an -= event in a signaled state to wait, and then set the duplicate -= to nonsignaled state and perform the wait again. The wait on -= the event should fail. Test the duplication of closed and NULL -= events, these should fail. diff --git a/src/pal/tests/palsuite/threading/DuplicateHandle/test4/CMakeLists.txt b/src/pal/tests/palsuite/threading/DuplicateHandle/test4/CMakeLists.txt deleted file mode 100644 index 2261e6e1c..000000000 --- a/src/pal/tests/palsuite/threading/DuplicateHandle/test4/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test4.cpp -) - -add_executable(paltest_duplicatehandle_test4 - ${SOURCES} -) - -add_dependencies(paltest_duplicatehandle_test4 coreclrpal) - -target_link_libraries(paltest_duplicatehandle_test4 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/DuplicateHandle/test4/test4.cpp b/src/pal/tests/palsuite/threading/DuplicateHandle/test4/test4.cpp deleted file mode 100644 index 14a72db46..000000000 --- a/src/pal/tests/palsuite/threading/DuplicateHandle/test4/test4.cpp +++ /dev/null @@ -1,239 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test4.c (DuplicateHandle) -** -** Purpose: Tests the PAL implementation of the DuplicateHandle function. -** This test duplication of a Mutex handle. The test will comprise -** of creating a Mutex and its duplicate and create a thread that -** will get ownership. Another thread will be create that will -** attempt to get ownership of the duplicate Mutex, this will -** fail, since the Mutex is owned by another thread. The Mutex -** will be released and then the thread will attempt to get -** ownership of the duplicate Mutex, this will succeed. -** -** -**===================================================================*/ -#include - -enum wait_results -{ - WR_WAITING, - WR_GOT_MUTEX, - WR_TIMED_OUT, - WR_RELEASED -}; - - -volatile int t1_result=WR_WAITING; -volatile int t2_result=WR_WAITING; - - -DWORD PALAPI ThreadTest1(LPVOID lpParam) -{ - DWORD dwWait; - - dwWait = WaitForSingleObject((HANDLE)lpParam, 0); - if (dwWait == WAIT_OBJECT_0) - { - /* tell the main thread we got the mutex */ - t1_result=WR_GOT_MUTEX; - - /* wait for main thread to tell us to release the mutex */ - while(WR_GOT_MUTEX == t1_result) - Sleep(1); - ReleaseMutex((HANDLE)lpParam); - - /* tell the main thread we released the mutex */ - t1_result = WR_RELEASED; - } - else - { - t1_result = WR_TIMED_OUT; - } - return 0; -} - -DWORD PALAPI ThreadTest2(LPVOID lpParam) -{ - DWORD dwWait; - - dwWait = WaitForSingleObject((HANDLE)lpParam, 0 ); - if (dwWait == WAIT_OBJECT_0) - { - ReleaseMutex((HANDLE)lpParam); - t2_result = WR_GOT_MUTEX; - } - else - { - t2_result = WR_TIMED_OUT; - } - - return 0; -} - - -int __cdecl main(int argc, char **argv) -{ - - HANDLE hDupMutex; - HANDLE hMutex; - HANDLE hThread; - HANDLE hThread2; - BOOL bDupHandle=FALSE; - DWORD dwThreadId = 0; - - if ((PAL_Initialize(argc,argv)) != 0) - { - return(FAIL); - } - - /*Create Mutex without ownership*/ - hMutex = CreateMutexW(NULL, // no security attributes - FALSE, // initially not owned - NULL); // name of mutex - if (hMutex == NULL) - { - Fail("ERROR:%u: Unable to create mutex\n", - GetLastError()); - } - - /*Create Duplicate of the Mutex above*/ - bDupHandle = DuplicateHandle(GetCurrentProcess(), - hMutex, - GetCurrentProcess(), - &hDupMutex, - GENERIC_READ|GENERIC_WRITE, - FALSE, - DUPLICATE_SAME_ACCESS); - if (!bDupHandle) - { - Trace("ERROR:%u: Created the duplicate handle to " - "closed event handle hMutex=0x%lx\n", - GetLastError(), - hMutex); - CloseHandle(hMutex); - Fail(""); - } - - /*Create a thread to test the Mutex*/ - hThread = CreateThread(NULL, - 0, - &ThreadTest1, - hMutex, - 0, - &dwThreadId); - if (hThread == NULL) - { - Trace("ERROR:%u: unable to create thread\n", - GetLastError()); - CloseHandle(hMutex); - CloseHandle(hDupMutex); - Fail(""); - } - - /* wait until thread has taken the mutex */ - while (WR_WAITING == t1_result) - Sleep(1); - - if(WR_TIMED_OUT == t1_result) - { - Trace("ERROR: %u: thread 1 couldn't acquire the mutex\n"); - CloseHandle(hMutex); - CloseHandle(hDupMutex); - CloseHandle(hThread); - Fail(""); - } - - /*Create a second thread to use the duplicate Mutex*/ - /*This should fail since the Mutex is owned hThread*/ - hThread2 = CreateThread(NULL, - 0, - &ThreadTest2, - hDupMutex, - 0, - &dwThreadId); - - if (hThread2 == NULL) - { - Trace("ERROR:%u: unable to create thread\n", - GetLastError()); - CloseHandle(hMutex); - CloseHandle(hDupMutex); - CloseHandle(hThread); - Fail(""); - } - - /* wait until thread has tried to take the mutex */ - while (WR_WAITING == t2_result) - Sleep(1); - - if (WR_TIMED_OUT != t2_result ) - { - Trace("ERROR:%u: Able to take mutex %#x while its duplicate %#x is " - "held\n", hDupMutex, hMutex); - CloseHandle(hMutex); - CloseHandle(hDupMutex); - CloseHandle(hThread); - CloseHandle(hThread2); - Fail(""); - } - - /* reset second thread status */ - t2_result = WR_WAITING; - - /* tell thread 1 to release the mutex */ - t1_result = WR_WAITING; - - /* wait for thread 1 to release the mutex */ - while (WR_WAITING == t1_result) - Sleep(1); - - CloseHandle(hThread2); - - /*Re-Create the second thread to reuse the duplicated Mutex*/ - /*This test should pass, the Mutex has since been released*/ - hThread2 = CreateThread(NULL, - 0, - &ThreadTest2, - hDupMutex, - 0, - &dwThreadId); - - if (hThread2 == NULL) - { - Trace("ERROR:%u: unable to create thread\n", - GetLastError()); - CloseHandle(hMutex); - CloseHandle(hDupMutex); - CloseHandle(hThread); - Fail(""); - } - - /* wait until thread has taken the mutex */ - while (WR_WAITING == t2_result) - Sleep(1); - - if (WR_GOT_MUTEX != t2_result ) - { - Trace("ERROR:%u: Unable to take mutex %#x after its duplicate %#x was " - "released\n", hDupMutex, hMutex); - CloseHandle(hMutex); - CloseHandle(hDupMutex); - CloseHandle(hThread); - CloseHandle(hThread2); - Fail(""); - } - - /*Cleanup.*/ - CloseHandle(hMutex); - CloseHandle(hDupMutex); - CloseHandle(hThread); - CloseHandle(hThread2); - - PAL_Terminate(); - return (PASS); -} diff --git a/src/pal/tests/palsuite/threading/DuplicateHandle/test4/testinfo.dat b/src/pal/tests/palsuite/threading/DuplicateHandle/test4/testinfo.dat deleted file mode 100644 index 64842f871..000000000 --- a/src/pal/tests/palsuite/threading/DuplicateHandle/test4/testinfo.dat +++ /dev/null @@ -1,19 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Threading -Function = DuplicateHandle -Name = Test for DuplicateHandle (CreateMutex) -TYPE = DEFAULT -EXE1 = test4 -Description -= Tests the PAL implementation of the DuplicateHandle function. -= This test duplication of a Mutex handle. The test will comprise -= of creating a Mutex and its duplicate and create a thread that will -= get ownership. Another thread will be create that will attempt to -= get ownership of the duplicate Mutex, this will fail, since the -= Mutex is owned by another thread. The Mutex will be released and -= then the thread will attempt to get ownership of the duplicate -= Mutex, this will succeed. diff --git a/src/pal/tests/palsuite/threading/DuplicateHandle/test5/CMakeLists.txt b/src/pal/tests/palsuite/threading/DuplicateHandle/test5/CMakeLists.txt deleted file mode 100644 index 72e77aab1..000000000 --- a/src/pal/tests/palsuite/threading/DuplicateHandle/test5/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test5.cpp -) - -add_executable(paltest_duplicatehandle_test5 - ${SOURCES} -) - -add_dependencies(paltest_duplicatehandle_test5 coreclrpal) - -target_link_libraries(paltest_duplicatehandle_test5 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/DuplicateHandle/test5/test5.cpp b/src/pal/tests/palsuite/threading/DuplicateHandle/test5/test5.cpp deleted file mode 100644 index a588928f0..000000000 --- a/src/pal/tests/palsuite/threading/DuplicateHandle/test5/test5.cpp +++ /dev/null @@ -1,145 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test5.c (DuplicateHandle) -** -** Purpose: Tests the PAL implementation of the DuplicateHandle function, -** with CreatePipe. This test will create a pipe and write to it, -** the duplicate the read handle and read what was written. -** -** Depends: WriteFile -** ReadFile -** memcmp -** CloseHandle -** -** -**===================================================================*/ - -#include - -const char* cTestString = "one fish, two fish, red fish, blue fish."; - -int __cdecl main(int argc, char **argv) -{ - HANDLE hReadPipe = NULL; - HANDLE hWritePipe = NULL; - HANDLE hDupPipe = NULL; - BOOL bRetVal = FALSE; - DWORD dwBytesWritten; - DWORD dwBytesRead; - char buffer[256]; - - SECURITY_ATTRIBUTES lpPipeAttributes; - - /*Initialize the PAL*/ - if ((PAL_Initialize(argc, argv)) != 0) - { - return (FAIL); - } - - /*Setup SECURITY_ATTRIBUTES structure for CreatePipe*/ - lpPipeAttributes.nLength = sizeof(lpPipeAttributes); - lpPipeAttributes.lpSecurityDescriptor = NULL; - lpPipeAttributes.bInheritHandle = TRUE; - - /*Create a Pipe*/ - bRetVal = CreatePipe(&hReadPipe, /* read handle*/ - &hWritePipe, /* write handle */ - &lpPipeAttributes,/* security attributes*/ - 0); /* pipe size*/ - if (bRetVal == FALSE) - { - Fail("ERROR:%u:Unable to create pipe\n", GetLastError()); - } - - /*Write to the write pipe handle*/ - bRetVal = WriteFile(hWritePipe, /* handle to write pipe*/ - cTestString, /* buffer to write*/ - strlen(cTestString),/* number of bytes to write*/ - &dwBytesWritten, /* number of bytes written*/ - NULL); /* overlapped buffer*/ - if (bRetVal == FALSE) - { - Trace("ERROR:%u:unable to write to write pipe handle " - "hWritePipe=0x%lx\n", GetLastError(), hWritePipe); - CloseHandle(hReadPipe); - CloseHandle(hWritePipe); - Fail(""); - } - - /*Duplicate the pipe handle*/ - if (!(DuplicateHandle(GetCurrentProcess(), /* source handle process*/ - hReadPipe, /* handle to duplicate*/ - GetCurrentProcess(), /* target process handle*/ - &hDupPipe, /* duplicate handle*/ - GENERIC_READ|GENERIC_WRITE,/* requested access*/ - FALSE, /* handle inheritance*/ - DUPLICATE_SAME_ACCESS))) /* optional actions*/ - { - Trace("ERROR:%u:Fail to create the duplicate handle" - " to hReadPipe=0x%lx", - GetLastError(), - hReadPipe); - CloseHandle(hReadPipe); - CloseHandle(hWritePipe); - Fail(""); - } - - /*Read from the duplicated handle, 256 bytes, more bytes - than actually written. This will allow us to use the - value that ReadFile returns for comparision.*/ - bRetVal = ReadFile(hDupPipe, /* handle to read pipe*/ - buffer, /* buffer to write to*/ - 256, /* number of bytes to read*/ - &dwBytesRead, /* number of bytes read*/ - NULL); /* overlapped buffer*/ - if (bRetVal == FALSE) - { - Trace("ERROR:%u:unable read from the duplicated pipe " - "hDupPipe=0x%lx\n", - GetLastError(), - hDupPipe); - CloseHandle(hReadPipe); - CloseHandle(hWritePipe); - CloseHandle(hDupPipe); - Fail(""); - } - - /*Compare what was read with what was written.*/ - if ((memcmp(cTestString, buffer, dwBytesRead)) != 0) - { - Trace("ERROR:%u: read \"%s\" expected \"%s\" \n", - GetLastError(), - buffer, - cTestString); - CloseHandle(hReadPipe); - CloseHandle(hWritePipe); - CloseHandle(hDupPipe); - Fail(""); - } - - /*Compare values returned from WriteFile and ReadFile.*/ - if (dwBytesWritten != dwBytesRead) - { - Trace("ERROR:%u: WriteFile wrote \"%s\", but ReadFile read \"%s\"," - " these should be the same\n", - GetLastError(), - buffer, - cTestString); - CloseHandle(hReadPipe); - CloseHandle(hWritePipe); - CloseHandle(hDupPipe); - Fail(""); - } - - /*Cleanup.*/ - CloseHandle(hWritePipe); - CloseHandle(hReadPipe); - CloseHandle(hDupPipe); - - PAL_Terminate(); - return (PASS); -} diff --git a/src/pal/tests/palsuite/threading/DuplicateHandle/test5/testinfo.dat b/src/pal/tests/palsuite/threading/DuplicateHandle/test5/testinfo.dat deleted file mode 100644 index 97e42a978..000000000 --- a/src/pal/tests/palsuite/threading/DuplicateHandle/test5/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Threading -Function = DuplicateHandle -Name = Test for DuplicateHandle (CreatePipe) -TYPE = DEFAULT -EXE1 = test5 -Description -= Tests the PAL implementation of the DuplicateHandle function, -= with CreatePipe. This test will create a pipe and write to it, -= then duplicate the read handle and read what was written. diff --git a/src/pal/tests/palsuite/threading/DuplicateHandle/test6/CMakeLists.txt b/src/pal/tests/palsuite/threading/DuplicateHandle/test6/CMakeLists.txt deleted file mode 100644 index 620d78843..000000000 --- a/src/pal/tests/palsuite/threading/DuplicateHandle/test6/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test6.cpp -) - -add_executable(paltest_duplicatehandle_test6 - ${SOURCES} -) - -add_dependencies(paltest_duplicatehandle_test6 coreclrpal) - -target_link_libraries(paltest_duplicatehandle_test6 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/DuplicateHandle/test6/test6.cpp b/src/pal/tests/palsuite/threading/DuplicateHandle/test6/test6.cpp deleted file mode 100644 index 026f315a4..000000000 --- a/src/pal/tests/palsuite/threading/DuplicateHandle/test6/test6.cpp +++ /dev/null @@ -1,146 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test6.c (DuplicateHandle) -** -** Purpose: Tests the PAL implementation of the DuplicateHandle function, -** with CreatePipe. This test will create a pipe, then duplicate -** the write handle, write to the handle, and use the read to -** verify. -** -** Depends: WriteFile -** ReadFile -** memcmp -** CloseHandle -** -** -**===================================================================*/ - -#include - -const char* cTestString = "one fish, two fish, red fish, blue fish."; - -int __cdecl main(int argc, char **argv) -{ - HANDLE hReadPipe = NULL; - HANDLE hWritePipe = NULL; - HANDLE hDupPipe = NULL; - BOOL bRetVal = FALSE; - DWORD dwBytesWritten; - DWORD dwBytesRead; - char buffer[256]; - - SECURITY_ATTRIBUTES lpPipeAttributes; - - /*Initialize the PAL*/ - if ((PAL_Initialize(argc, argv)) != 0) - { - return (FAIL); - } - - /*Setup SECURITY_ATTRIBUTES structure for CreatePipe*/ - lpPipeAttributes.nLength = sizeof(lpPipeAttributes); - lpPipeAttributes.lpSecurityDescriptor = NULL; - lpPipeAttributes.bInheritHandle = TRUE; - - /*Create a Pipe*/ - bRetVal = CreatePipe(&hReadPipe, /* read handle*/ - &hWritePipe, /* write handle */ - &lpPipeAttributes,/* security attributes*/ - 0); /* pipe size*/ - if (bRetVal == FALSE) - { - Fail("ERROR: %ld :Unable to create pipe\n", GetLastError()); - } - - /*Duplicate the pipe handle*/ - if (!(DuplicateHandle(GetCurrentProcess(), /* source handle process*/ - hWritePipe, /* handle to duplicate*/ - GetCurrentProcess(), /* target process handle*/ - &hDupPipe, /* duplicate handle*/ - GENERIC_READ|GENERIC_WRITE,/* requested access*/ - FALSE, /* handle inheritance*/ - DUPLICATE_SAME_ACCESS))) /* optional actions*/ - { - Trace("ERROR: %ld :Fail to create the duplicate handle" - " to hWritePipe=0x%lx", - GetLastError(), - hWritePipe); - CloseHandle(hReadPipe); - CloseHandle(hWritePipe); - Fail(""); - } - - /*Write to the duplicate write pipe handle*/ - bRetVal = WriteFile(hDupPipe, /* handle to write pipe*/ - cTestString, /* buffer to write*/ - strlen(cTestString),/* number of bytes to write*/ - &dwBytesWritten, /* number of bytes written*/ - NULL); /* overlapped buffer*/ - if (bRetVal == FALSE) - { - Trace("ERROR: %ld :unable to write to duplicate write pipe handle " - "hDupPipe=0x%lx\n", - GetLastError(), - hDupPipe); - CloseHandle(hReadPipe); - CloseHandle(hWritePipe); - CloseHandle(hDupPipe); - Fail(""); - } - - /*Read from the read handle, 256 bytes, more bytes - then actually written. This will give allow us to use - the value that ReadFile returns for comparision.*/ - bRetVal = ReadFile(hReadPipe, /* handle to read pipe*/ - buffer, /* buffer to write to*/ - 256, /* number of bytes to read*/ - &dwBytesRead, /* number of bytes read*/ - NULL); /* overlapped buffer*/ - if (bRetVal == FALSE) - { - Trace("ERROR: %ld : unable read hReadPipe=0x%lx\n", - GetLastError(), hReadPipe); - CloseHandle(hReadPipe); - CloseHandle(hWritePipe); - CloseHandle(hDupPipe); - Fail(""); - } - - /*Compare what was read with what was written.*/ - if ((memcmp(cTestString, buffer, dwBytesRead)) != 0) - { - Trace("ERROR: read \"%s\" expected \"%s\" \n", - buffer, - cTestString); - CloseHandle(hReadPipe); - CloseHandle(hWritePipe); - CloseHandle(hDupPipe); - Fail(""); - } - - /*Compare values returned from WriteFile and ReadFile.*/ - if (dwBytesWritten != dwBytesRead) - { - Trace("ERROR: WriteFile wrote \"%s\", but ReadFile read \"%s\"," - " these should be the same\n", - buffer, - cTestString); - CloseHandle(hReadPipe); - CloseHandle(hWritePipe); - CloseHandle(hDupPipe); - Fail(""); - } - - /*Cleanup.*/ - CloseHandle(hReadPipe); - CloseHandle(hWritePipe); - CloseHandle(hDupPipe); - - - PAL_Terminate(); - return (PASS); -} diff --git a/src/pal/tests/palsuite/threading/DuplicateHandle/test6/testinfo.dat b/src/pal/tests/palsuite/threading/DuplicateHandle/test6/testinfo.dat deleted file mode 100644 index 6c49d64f8..000000000 --- a/src/pal/tests/palsuite/threading/DuplicateHandle/test6/testinfo.dat +++ /dev/null @@ -1,15 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Threading -Function = DuplicateHandle -Name = Test for DuplicateHandle (CreatePipe) -TYPE = DEFAULT -EXE1 = test6 -Description -= Tests the PAL implementation of the DuplicateHandle function, -= with CreatePipe. This test will create a pipe, then duplicate -= the write handle, write to the handle, and use the read to -= verify. diff --git a/src/pal/tests/palsuite/threading/DuplicateHandle/test7/CMakeLists.txt b/src/pal/tests/palsuite/threading/DuplicateHandle/test7/CMakeLists.txt deleted file mode 100644 index fff3ba528..000000000 --- a/src/pal/tests/palsuite/threading/DuplicateHandle/test7/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test7.cpp -) - -add_executable(paltest_duplicatehandle_test7 - ${SOURCES} -) - -add_dependencies(paltest_duplicatehandle_test7 coreclrpal) - -target_link_libraries(paltest_duplicatehandle_test7 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/DuplicateHandle/test7/test7.cpp b/src/pal/tests/palsuite/threading/DuplicateHandle/test7/test7.cpp deleted file mode 100644 index bd09283b7..000000000 --- a/src/pal/tests/palsuite/threading/DuplicateHandle/test7/test7.cpp +++ /dev/null @@ -1,178 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test7.c (DuplicateHandle) -** -** Purpose: Tests the PAL implementation of the DuplicateHandle function, -** with a handle from CreateThread. The test will create a thread -** handle and its duplicate. Then get the priorities of the threads, -** set the priority of one and the change should be seen in the -** other. -** -** -**===================================================================*/ - -#include - -DWORD PALAPI CreateTestThread(LPVOID lpParam); - -int __cdecl main(int argc, char* argv[]) -{ - HANDLE hThread; - HANDLE hDupThread; - DWORD dwThreadId = 0; - LPTHREAD_START_ROUTINE lpStartAddress = &CreateTestThread; - HANDLE hSyncEvent; - - int threadPriority; - int duplicatePriority; - int finalPriority; - - /* Initialize the PAL.*/ - if ((PAL_Initialize(argc, argv)) != 0) - { - return (FAIL); - } - - LPSECURITY_ATTRIBUTES lpEventAttributes = NULL; - BOOL bManualReset = TRUE; - BOOL bInitialState = FALSE; - hSyncEvent = CreateEvent(lpEventAttributes, - bManualReset, - bInitialState, - NULL); - - if (hSyncEvent == NULL) - { - Fail("ERROR:%u: Unable to create sync event.\n", - GetLastError()); - } - - /* Create a thread.*/ - hThread = CreateThread(NULL, /* SD*/ - (DWORD)0, /* initial stack size*/ - lpStartAddress, /* thread function*/ - (VOID*)hSyncEvent,/* thread argument*/ - (DWORD)0, /* creation option*/ - &dwThreadId); /* thread identifier*/ - if (hThread == NULL) - { - Fail("ERROR:%u: Unable to create thread.\n", - GetLastError()); - } - - /* Duplicate the thread handle.*/ - if (!(DuplicateHandle(GetCurrentProcess(), /* source handle process*/ - hThread, /* handle to duplicate*/ - GetCurrentProcess(), /* target process handle*/ - &hDupThread, /* duplicate handle*/ - (DWORD)0, /* requested access*/ - FALSE, /* handle inheritance*/ - DUPLICATE_SAME_ACCESS))) /* optional actions*/ - { - Trace("ERROR: %ld :Fail to create the duplicate handle" - " to hThread=0x%lx", - GetLastError(), - hThread); - CloseHandle(hThread); - Fail(""); - } - - /* Get the priority of the thread.*/ - threadPriority = GetThreadPriority(hThread); - if(threadPriority != 0) - { - Trace("ERROR: Thread priority of hThread=0x%lx should be " - "set to normal THREAD_PRIORITY_NORMAL=%d\n", - hThread, - THREAD_PRIORITY_NORMAL); - CloseHandle(hThread); - CloseHandle(hDupThread); - Fail(""); - } - - /* Get the priority of the duplicated handle, and compare it to - * the priority of the original thread. Should be the same.*/ - duplicatePriority = GetThreadPriority(hThread); - if(duplicatePriority != threadPriority) - { - Trace("ERROR: Expected priority of hThread=0x%lx and hDupThread=0x%lx" - " to be the same. Priorities:hThread=\"%d\":hDupThread=\"%d\"\n", - hThread, - hDupThread, - threadPriority, - duplicatePriority); - CloseHandle(hThread); - CloseHandle(hDupThread); - Fail(""); - } - - /* Set the priority of the duplicate thread.*/ - if(!SetThreadPriority (hDupThread,THREAD_PRIORITY_HIGHEST)) - { - Trace("ERROR:%u: SetThreadPriority failed on hThread=0x%lx\n", - GetLastError(), - hDupThread); - CloseHandle(hThread); - CloseHandle(hDupThread); - Fail(""); - } - - /* Get the priority of the origianl thread, and - * compare it to what the duplicate was set to.*/ - finalPriority = GetThreadPriority(hThread); - if (finalPriority != THREAD_PRIORITY_HIGHEST) - { - Trace("ERROR: Expected priority of hThread=0x%lw and " - "hDupThread=0x%lw to be set the same. Priorities:" - "hThread=\"%d\":hDupThread=\"%d\".\n", - hThread, - hDupThread, - threadPriority, - duplicatePriority); - CloseHandle(hThread); - CloseHandle(hDupThread); - Fail(""); - } - - /* Signal the helper thread that it can shut down */ - if (!SetEvent(hSyncEvent)) - { - Fail("ERROR:%u: Failed to set event.\n", - GetLastError()); - } - - /* Wait on the original thread.*/ - if((WaitForSingleObject(hThread, 100)) != WAIT_OBJECT_0) - { - Trace("ERROR:%u: hThread=0x%lx is in a non-signalled " - "mode, yet created signalled.\n", - GetLastError(), - hThread); - CloseHandle(hThread); - CloseHandle(hDupThread); - Fail(""); - } - - /* Clean-up thread and Terminate the PAL.*/ - CloseHandle(hSyncEvent); - CloseHandle(hThread); - CloseHandle(hDupThread); - PAL_Terminate(); - return PASS; -} - -/*Thread testing function*/ -DWORD PALAPI CreateTestThread(LPVOID lpParam) -{ - HANDLE hSyncEvent = (HANDLE)lpParam; - - /* Wait until the main thread signals that this helper thread should shut down */ - WaitForSingleObject(hSyncEvent, INFINITE); - - return (DWORD)0; -} - diff --git a/src/pal/tests/palsuite/threading/DuplicateHandle/test7/testinfo.dat b/src/pal/tests/palsuite/threading/DuplicateHandle/test7/testinfo.dat deleted file mode 100644 index b8092d615..000000000 --- a/src/pal/tests/palsuite/threading/DuplicateHandle/test7/testinfo.dat +++ /dev/null @@ -1,16 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Threading -Function = DuplicateHandle -Name = Test for DuplicateHandle (CreateThread) -TYPE = DEFAULT -EXE1 = test7 -Description -= Tests the PAL implementation of the DuplicateHandle function, -= with a handle from CreateThread. The test will create a thread -= handle and its duplicate. Then get the priorities of the threads, -= set the priority of one and the change should be seen in the -= other. diff --git a/src/pal/tests/palsuite/threading/DuplicateHandle/test8/CMakeLists.txt b/src/pal/tests/palsuite/threading/DuplicateHandle/test8/CMakeLists.txt deleted file mode 100644 index 2fb32aa3f..000000000 --- a/src/pal/tests/palsuite/threading/DuplicateHandle/test8/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test8.cpp -) - -add_executable(paltest_duplicatehandle_test8 - ${SOURCES} -) - -add_dependencies(paltest_duplicatehandle_test8 coreclrpal) - -target_link_libraries(paltest_duplicatehandle_test8 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/DuplicateHandle/test8/test8.cpp b/src/pal/tests/palsuite/threading/DuplicateHandle/test8/test8.cpp deleted file mode 100644 index 6748c5dff..000000000 --- a/src/pal/tests/palsuite/threading/DuplicateHandle/test8/test8.cpp +++ /dev/null @@ -1,164 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test8.c (DuplicateHandle) -** -** Purpose: Tests the PAL implementation of the DuplicateHandle function, -** with a handle from GetCurrentThread. The test will create a thread -** handle, get the current thread and its duplicate. Then get the -** priorities of the threads, set the priority of one and the change -** should be seen in the other. -** -** -**===================================================================*/ - -#include - -DWORD PALAPI CreateTestThread(LPVOID lpParam); - -int __cdecl main(int argc, char* argv[]) -{ - HANDLE hThread; - HANDLE hCurrentThread; - HANDLE hDupThread; - DWORD dwThreadId = 0; - LPTHREAD_START_ROUTINE lpStartAddress = &CreateTestThread; - - int threadPriority; - int duplicatePriority; - int finalPriority; - - /* Initialize the PAL.*/ - if ((PAL_Initialize(argc, argv)) != 0) - { - return (FAIL); - } - -#if !HAVE_SCHED_OTHER_ASSIGNABLE - /* Defining thread priority for SCHED_OTHER is implementation defined. - Some platforms like NetBSD cannot reassign it as they are dynamic. - */ - printf("paltest_duplicatehandle_test8 has been disabled on this platform\n"); -#else - - /* Create a thread.*/ - hThread = CreateThread(NULL, /* SD*/ - (DWORD)0, /* initial stack size*/ - lpStartAddress, /* thread function*/ - NULL, /* thread argument*/ - (DWORD)0, /* creation option*/ - &dwThreadId); /* thread identifier*/ - if (hThread == NULL) - { - Fail("ERROR:%u: Unable to create thread.\n", - GetLastError()); - } - - /*Get a psuedo handle to the current thread.*/ - hCurrentThread = GetCurrentThread(); - - /* Duplicate the psuedo thread handle.*/ - if (!(DuplicateHandle(GetCurrentProcess(), /* source handle process*/ - hCurrentThread, /* handle to duplicate*/ - GetCurrentProcess(), /* target process handle*/ - &hDupThread, /* duplicate handle*/ - (DWORD)0, /* requested access*/ - FALSE, /* handle inheritance*/ - DUPLICATE_SAME_ACCESS))) /* optional actions*/ - { - Trace("ERROR: %ld :Fail to create the duplicate handle" - " to hThread=0x%lx", - GetLastError(), - hThread); - CloseHandle(hThread); - Fail(""); - } - - /* Get the priority of the thread.*/ - threadPriority = GetThreadPriority(hCurrentThread); - if(threadPriority != 0) - { - Trace("ERROR: Thread priority of hCurrentThread=0x%lx should be " - "set to normal THREAD_PRIORITY_NORMAL=%d\n", - hCurrentThread, - THREAD_PRIORITY_NORMAL); - CloseHandle(hThread); - CloseHandle(hDupThread); - Fail(""); - } - - /* Get the priority of the duplicated handle, and compare it to - * the priority of the original thread. Should be the same.*/ - duplicatePriority = GetThreadPriority(hCurrentThread); - if(duplicatePriority != threadPriority) - { - Trace("ERROR: Expected priority of hCurrentThread=0x%lx and " - "hDupThread=0x%lx to be the same. Priorities:hThread=" - "\"%d\":hDupThread=\"%d\"\n", - hCurrentThread, - hDupThread, - threadPriority, - duplicatePriority); - CloseHandle(hThread); - CloseHandle(hDupThread); - Fail(""); - } - - /* Set the priority of the original thread.*/ - if(!SetThreadPriority (hCurrentThread,THREAD_PRIORITY_HIGHEST)) - { - Trace("ERROR:%u: SetThreadPriority failed on hCurrentThread=0x%lx\n", - GetLastError(), - hCurrentThread); - CloseHandle(hThread); - CloseHandle(hDupThread); - Fail(""); - } - - /* Get the priority of the duplicate thread, and - * compare it to what the original was set to.*/ - finalPriority = GetThreadPriority(hDupThread); - if (finalPriority != THREAD_PRIORITY_HIGHEST) - { - Trace("ERROR: Expected priority of hCurrentThread=0x%lw and " - "hDupThread=0x%lw to be set the same. Priorities:" - "hCurrentThread=\"%d\":hDupThread=\"%d\".\n", - hCurrentThread, - hDupThread, - threadPriority, - duplicatePriority); - CloseHandle(hThread); - CloseHandle(hDupThread); - Fail(""); - } - - /* Wait on the original thread.*/ - if((WaitForSingleObject(hThread, 100)) != WAIT_OBJECT_0) - { - Trace("ERROR:%u: hCurrentThread=0x%lx is in a non-signalled " - "mode, yet created signalled.\n", - GetLastError(), - hThread); - CloseHandle(hThread); - CloseHandle(hDupThread); - Fail(""); - } - - /* Clean-up thread and Terminate the PAL.*/ - CloseHandle(hThread); - CloseHandle(hDupThread); - -#endif - - PAL_Terminate(); - return PASS; -} - -/*Thread testing function, only return '0'*/ -DWORD PALAPI CreateTestThread(LPVOID lpParam) -{ - return (DWORD)0; -} diff --git a/src/pal/tests/palsuite/threading/DuplicateHandle/test8/testinfo.dat b/src/pal/tests/palsuite/threading/DuplicateHandle/test8/testinfo.dat deleted file mode 100644 index ae1353af1..000000000 --- a/src/pal/tests/palsuite/threading/DuplicateHandle/test8/testinfo.dat +++ /dev/null @@ -1,16 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Threading -Function = DuplicateHandle -Name = Test for DuplicateHandle (GetCurrentThread) -TYPE = DEFAULT -EXE1 = test8 -Description -=Tests the PAL implementation of the DuplicateHandle function, -=with a handle from GetCurrentThread. The test will create a thread -=handle, get the current thread and its duplicate. Then get the -=priorities of the threads, set the priority of one and the change -=should be seen in the other. diff --git a/src/pal/tests/palsuite/threading/DuplicateHandle/test9/CMakeLists.txt b/src/pal/tests/palsuite/threading/DuplicateHandle/test9/CMakeLists.txt deleted file mode 100644 index f2bca8293..000000000 --- a/src/pal/tests/palsuite/threading/DuplicateHandle/test9/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test9.cpp -) - -add_executable(paltest_duplicatehandle_test9 - ${SOURCES} -) - -add_dependencies(paltest_duplicatehandle_test9 coreclrpal) - -target_link_libraries(paltest_duplicatehandle_test9 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/DuplicateHandle/test9/test9.cpp b/src/pal/tests/palsuite/threading/DuplicateHandle/test9/test9.cpp deleted file mode 100644 index f15871c57..000000000 --- a/src/pal/tests/palsuite/threading/DuplicateHandle/test9/test9.cpp +++ /dev/null @@ -1,127 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test9.c (DuplicateHandle) -** -** Purpose: Tests the PAL implementation of the DuplicateHandle function, -** with a handle from GetCurrentProcess. The test will create a -** process, duplicate it, then using ReadProcessMemory will -** read from the memory location of the CreateProcess process -** memory and the DuplicateHandle process memory. If the -** duplication is correct the memory will be the same for both. -** -** -**===================================================================*/ - -#include - -int __cdecl main(int argc, char* argv[]) -{ - HANDLE hProcess; - HANDLE hDupProcess; - char lpBuffer[64]; - char lpDupBuffer[64]; - SIZE_T lpNumberOfBytesRead; - SIZE_T lpDupNumberOfBytesRead; - char lpTestBuffer[] = "abcdefghijklmnopqrstuvwxyz"; - - /* Initalize the PAL. - */ - if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - /* Initalize the buffers. - */ - ZeroMemory( &lpBuffer, sizeof(lpBuffer) ); - ZeroMemory( &lpDupBuffer, sizeof(lpDupBuffer) ); - - /* Get current proces, this will be duplicated. - */ - hProcess = GetCurrentProcess(); - if(hProcess == NULL) - { - Fail("ERROR: Unable to get the current process\n"); - } - - /* Duplicate the current process handle. - */ - if (!(DuplicateHandle(GetCurrentProcess(), /* source handle process*/ - hProcess, /* handle to duplicate*/ - GetCurrentProcess(), /* target process handle*/ - &hDupProcess, /* duplicate handle*/ - (DWORD)0, /* requested access*/ - FALSE, /* handle inheritance*/ - DUPLICATE_SAME_ACCESS))) /* optional actions*/ - { - Trace("ERROR:%u: Failed to create the duplicate handle" - " to hProcess=0x%lx", - GetLastError(), - hProcess); - CloseHandle(hProcess); - Fail(""); - } - - /* Get memory read of the current process. - */ - if ((ReadProcessMemory(hDupProcess, &lpTestBuffer, - lpDupBuffer, sizeof(lpDupBuffer), &lpDupNumberOfBytesRead)) == 0) - { - Trace("ERROR:%u: Unable to read the process memory of " - "hDupProcess=0x%lx.\n", - GetLastError(), - hDupProcess); - CloseHandle(hProcess); - CloseHandle(hDupProcess); - Fail(""); - } - - /* Get read memory of the created process. - */ - if ((ReadProcessMemory(hProcess, &lpTestBuffer, - lpBuffer, sizeof(lpBuffer), &lpNumberOfBytesRead)) == 0) - { - Trace("ERROR:%u: Unable to read the process memory of " - "hProcess=0x%lx.\n", - GetLastError(), - hProcess); - CloseHandle(hProcess); - CloseHandle(hDupProcess); - Fail(""); - } - - /* Compare the number of bytes that were read by each - * ReadProcessMemory.*/ - if (lpDupNumberOfBytesRead != lpNumberOfBytesRead) - { - Trace("ERROR: ReadProcessMemory read different numbers of bytes " - "from duplicate process handles.\n"); - CloseHandle(hProcess); - CloseHandle(hDupProcess); - Fail(""); - } - - /* Compare the two buffers to make sure they are equal. - */ - if ((strcmp(lpBuffer, lpDupBuffer)) != 0) - { - Trace("ERROR: ReadProcessMemory read different numbers of bytes " - "from duplicate process handles. hProcess read \"%s\" and " - "hDupProcess read \"%s\"\n", - lpBuffer, - lpDupBuffer); - CloseHandle(hProcess); - CloseHandle(hDupProcess); - Fail(""); - } - - /* Clean-up thread and Terminate the PAL.*/ - CloseHandle(hProcess); - CloseHandle(hDupProcess); - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/threading/DuplicateHandle/test9/testinfo.dat b/src/pal/tests/palsuite/threading/DuplicateHandle/test9/testinfo.dat deleted file mode 100644 index c7122908f..000000000 --- a/src/pal/tests/palsuite/threading/DuplicateHandle/test9/testinfo.dat +++ /dev/null @@ -1,17 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Threading -Function = DuplicateHandle -Name = Test for DuplicateHandle (GetCurrentProcess) -TYPE = DEFAULT -EXE1 = test9 -Description -= Tests the PAL implementation of the DuplicateHandle function, -= with a handle from GetCurrentProcess. The test will create a -= process, duplicate it, then using ReadProcessMemory will -= read from the memory location of the CreateProcess process -= memory and the DuplicateHandle process memory. If the -= duplication is correct the memory will be the same for both. diff --git a/src/pal/tests/palsuite/threading/ExitProcess/CMakeLists.txt b/src/pal/tests/palsuite/threading/ExitProcess/CMakeLists.txt deleted file mode 100644 index 1962ade35..000000000 --- a/src/pal/tests/palsuite/threading/ExitProcess/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) -add_subdirectory(test3) - diff --git a/src/pal/tests/palsuite/threading/ExitProcess/test1/CMakeLists.txt b/src/pal/tests/palsuite/threading/ExitProcess/test1/CMakeLists.txt deleted file mode 100644 index 28f124765..000000000 --- a/src/pal/tests/palsuite/threading/ExitProcess/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - ExitProcess.cpp -) - -add_executable(paltest_exitprocess_test1 - ${SOURCES} -) - -add_dependencies(paltest_exitprocess_test1 coreclrpal) - -target_link_libraries(paltest_exitprocess_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/ExitProcess/test1/ExitProcess.cpp b/src/pal/tests/palsuite/threading/ExitProcess/test1/ExitProcess.cpp deleted file mode 100644 index 2b089a0b8..000000000 --- a/src/pal/tests/palsuite/threading/ExitProcess/test1/ExitProcess.cpp +++ /dev/null @@ -1,32 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source: exitprocess/test1/exitprocess.c -** -** Purpose: Test to ensure ExitProcess returns the argument given -** to it. -** -** -**=========================================================*/ - -#include - -int __cdecl main( int argc, char **argv ) - -{ - - if(0 != (PAL_Initialize(argc, argv))) - { - return ( FAIL ); - } - - ExitProcess(PASS); - - Fail ("ExitProcess(0) failed to exit.\n Test Failed.\n"); - - return ( FAIL); - -} diff --git a/src/pal/tests/palsuite/threading/ExitProcess/test1/testinfo.dat b/src/pal/tests/palsuite/threading/ExitProcess/test1/testinfo.dat deleted file mode 100644 index d8b85abad..000000000 --- a/src/pal/tests/palsuite/threading/ExitProcess/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = threading -Function = ExitProcess -Name = Positive Test for ExitProcess -TYPE = DEFAULT -EXE1 = exitprocess -Description -= Test the ExitProcess function. The test runs the ExitProcess function -= with the TEST_RETURN enumeration value PASS diff --git a/src/pal/tests/palsuite/threading/ExitProcess/test2/CMakeLists.txt b/src/pal/tests/palsuite/threading/ExitProcess/test2/CMakeLists.txt deleted file mode 100644 index 6b9202e58..000000000 --- a/src/pal/tests/palsuite/threading/ExitProcess/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test2.cpp -) - -add_executable(paltest_exitprocess_test2 - ${SOURCES} -) - -add_dependencies(paltest_exitprocess_test2 coreclrpal) - -target_link_libraries(paltest_exitprocess_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/ExitProcess/test2/test2.cpp b/src/pal/tests/palsuite/threading/ExitProcess/test2/test2.cpp deleted file mode 100644 index 8023ad7ba..000000000 --- a/src/pal/tests/palsuite/threading/ExitProcess/test2/test2.cpp +++ /dev/null @@ -1,30 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================= -** -** Source: test2.c -** -** Purpose: Positive test for ExitProcess. -** -** Dependencies: none -** - -** -**===========================================================================*/ -#include - - - -int __cdecl main( int argc, char **argv ) - -{ - /* call ExitProcess() -- should work without PAL_Initialize() */ - ExitProcess(PASS); - - - /* return failure if we reach here -- note no attempt at */ - /* meaningful output because we never called PAL_Initialize(). */ - return FAIL; -} diff --git a/src/pal/tests/palsuite/threading/ExitProcess/test2/testinfo.dat b/src/pal/tests/palsuite/threading/ExitProcess/test2/testinfo.dat deleted file mode 100644 index 0aa07eb15..000000000 --- a/src/pal/tests/palsuite/threading/ExitProcess/test2/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = threading -Function = ExitProcess -Name = Positive test for ExitProcess -TYPE = DEFAULT -EXE1 = test2 -Description -= Test to ensure proper operation of the ExitProcess() -= API by ensuring it works before PAL_Initialize() is -= called. diff --git a/src/pal/tests/palsuite/threading/ExitProcess/test3/CMakeLists.txt b/src/pal/tests/palsuite/threading/ExitProcess/test3/CMakeLists.txt deleted file mode 100644 index c4152181c..000000000 --- a/src/pal/tests/palsuite/threading/ExitProcess/test3/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test3.cpp -) - -add_executable(paltest_exitprocess_test3 - ${SOURCES} -) - -add_dependencies(paltest_exitprocess_test3 coreclrpal) - -target_link_libraries(paltest_exitprocess_test3 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/ExitProcess/test3/test3.cpp b/src/pal/tests/palsuite/threading/ExitProcess/test3/test3.cpp deleted file mode 100644 index aea485e5e..000000000 --- a/src/pal/tests/palsuite/threading/ExitProcess/test3/test3.cpp +++ /dev/null @@ -1,40 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================= -** -** Source: test3.c -** -** Purpose: Positive test for ExitProcess. -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** - -** -**===========================================================================*/ -#include - - - -int __cdecl main( int argc, char **argv ) - -{ - /* initialize the PAL */ - if( PAL_Initialize(argc, argv) != 0 ) - { - return( FAIL ); - } - - /* terminate the PAL */ - PAL_Terminate(); - - /* call ExitProcess() -- should work after PAL_Terminate() */ - ExitProcess( PASS ); - - - /* return failure if we reach here -- note no attempt at */ - /* meaningful output because we've called PAL_Terminte(). */ - return FAIL; -} diff --git a/src/pal/tests/palsuite/threading/ExitProcess/test3/testinfo.dat b/src/pal/tests/palsuite/threading/ExitProcess/test3/testinfo.dat deleted file mode 100644 index c857d885c..000000000 --- a/src/pal/tests/palsuite/threading/ExitProcess/test3/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = threading -Function = ExitProcess -Name = Positive test for ExitProcess -TYPE = DEFAULT -EXE1 = test3 -Description -= Test to ensure proper operation of the ExitProcess() -= API by ensuring it works after PAL_Terminate() is -= called. diff --git a/src/pal/tests/palsuite/threading/ExitThread/CMakeLists.txt b/src/pal/tests/palsuite/threading/ExitThread/CMakeLists.txt deleted file mode 100644 index ef14ea535..000000000 --- a/src/pal/tests/palsuite/threading/ExitThread/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) - diff --git a/src/pal/tests/palsuite/threading/ExitThread/test1/CMakeLists.txt b/src/pal/tests/palsuite/threading/ExitThread/test1/CMakeLists.txt deleted file mode 100644 index 3f8531a33..000000000 --- a/src/pal/tests/palsuite/threading/ExitThread/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_exitthread_test1 - ${SOURCES} -) - -add_dependencies(paltest_exitthread_test1 coreclrpal) - -target_link_libraries(paltest_exitthread_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/ExitThread/test1/test1.cpp b/src/pal/tests/palsuite/threading/ExitThread/test1/test1.cpp deleted file mode 100644 index caf140940..000000000 --- a/src/pal/tests/palsuite/threading/ExitThread/test1/test1.cpp +++ /dev/null @@ -1,114 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source: test1.c -** -** Purpose: Test for ExitThread. Create a thread and then call -** exit thread within the threading function. Ensure that it exits -** immediatly. -** -** -**=========================================================*/ - -#include - -DWORD dwExitThreadTestParameter = 0; - -DWORD PALAPI ExitThreadTestThread( LPVOID lpParameter) -{ - DWORD dwRet = 0; - - /* Save parameter for test */ - dwExitThreadTestParameter = (DWORD)lpParameter; - - /* Call the ExitThread function */ - ExitThread(dwRet); - - /* If we didn't exit, get caught in this loop. But, the - program will exit. - */ - while (!dwRet) - { - Fail("ERROR: Entered an infinite loop because ExitThread " - "failed to exit from the thread. Forcing exit from " - "the test now."); - } - - return dwRet; -} - -BOOL ExitThreadTest() -{ - BOOL bRet = FALSE; - DWORD dwRet = 0; - - LPSECURITY_ATTRIBUTES lpThreadAttributes = NULL; - DWORD dwStackSize = 0; - LPTHREAD_START_ROUTINE lpStartAddress = &ExitThreadTestThread; - LPVOID lpParameter = (LPVOID)lpStartAddress; - DWORD dwCreationFlags = 0; //run immediately - DWORD dwThreadId = 0; - - HANDLE hThread = 0; - - dwExitThreadTestParameter = 0; - - /* Create a Thread. We'll need this to test that we're able - to exit the thread. - */ - hThread = CreateThread( lpThreadAttributes, - dwStackSize, lpStartAddress, lpParameter, - dwCreationFlags, &dwThreadId ); - - if (hThread != INVALID_HANDLE_VALUE) - { - dwRet = WaitForSingleObject(hThread,INFINITE); - - if (dwRet != WAIT_OBJECT_0) - { - Trace("ExitThreadTest:WaitForSingleObject failed " - "(%x)\n",GetLastError()); - } - else - { - /* Check to ensure that the parameter set in the Thread - function is correct. - */ - if (dwExitThreadTestParameter != (DWORD)lpParameter) - { - Trace("ERROR: The paramater passed should have been " - "%d but turned up as %d.", - dwExitThreadTestParameter, lpParameter); - } - else - { - bRet = TRUE; - } - } - } - else - { - Trace("ExitThreadTest:CreateThread failed (%x)\n",GetLastError()); - } - - return bRet; -} - -int __cdecl main(int argc, char **argv) -{ - if(0 != (PAL_Initialize(argc, argv))) - { - return ( FAIL ); - } - - if(!ExitThreadTest()) - { - Fail ("Test failed\n"); - } - - PAL_Terminate(); - return ( PASS ); -} diff --git a/src/pal/tests/palsuite/threading/ExitThread/test1/testinfo.dat b/src/pal/tests/palsuite/threading/ExitThread/test1/testinfo.dat deleted file mode 100644 index a526f8e12..000000000 --- a/src/pal/tests/palsuite/threading/ExitThread/test1/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = threading -Function = ExitThread -Name = Positive Test for ExitThread -TYPE = DEFAULT -EXE1 = test1 -Description -= Test for ExitThread. Create a thread and then call -= exit thread within the threading function. Ensure that it exits -= immediatly. diff --git a/src/pal/tests/palsuite/threading/ExitThread/test2/CMakeLists.txt b/src/pal/tests/palsuite/threading/ExitThread/test2/CMakeLists.txt deleted file mode 100644 index 606e02774..000000000 --- a/src/pal/tests/palsuite/threading/ExitThread/test2/CMakeLists.txt +++ /dev/null @@ -1,32 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(TESTSOURCES - test2.cpp -) - -add_executable(paltest_exitthread_test2 - ${TESTSOURCES} -) - -add_dependencies(paltest_exitthread_test2 coreclrpal) - -target_link_libraries(paltest_exitthread_test2 - ${COMMON_TEST_LIBRARIES} -) - - -set(HELPERSOURCES - childprocess.cpp -) - -add_executable(paltest_exitthread_test2_child - ${HELPERSOURCES} -) - -add_dependencies(paltest_exitthread_test2_child coreclrpal) - -target_link_libraries(paltest_exitthread_test2_child - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/ExitThread/test2/childprocess.cpp b/src/pal/tests/palsuite/threading/ExitThread/test2/childprocess.cpp deleted file mode 100644 index 7fbe208f9..000000000 --- a/src/pal/tests/palsuite/threading/ExitThread/test2/childprocess.cpp +++ /dev/null @@ -1,41 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source: childprocess.c -** -** Purpose: Test to ensure ExitThread returns the right -** value when shutting down the last thread of a process. -** All this program does is call ExitThread() with a predefined -** value. -** -** Dependencies: none -** - -** -**=========================================================*/ - -#include -#include "myexitcode.h" - -int __cdecl main( int argc, char **argv ) -{ - /* initialize the PAL */ - if( PAL_Initialize(argc, argv) != 0 ) - { - return( FAIL ); - } - - /* exit the current thread with a magic test value -- it should */ - /* terminate the process and return that test value from this */ - /* program. */ - ExitThread( TEST_EXIT_CODE ); - - /* technically we should never get here */ - PAL_Terminate(); - - /* return failure */ - return FAIL; -} diff --git a/src/pal/tests/palsuite/threading/ExitThread/test2/myexitcode.h b/src/pal/tests/palsuite/threading/ExitThread/test2/myexitcode.h deleted file mode 100644 index 566becb9a..000000000 --- a/src/pal/tests/palsuite/threading/ExitThread/test2/myexitcode.h +++ /dev/null @@ -1,14 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: myexitcode.h -** -** Purpose: Define an exit code. -** -** -**==========================================================================*/ - -#define TEST_EXIT_CODE 316 diff --git a/src/pal/tests/palsuite/threading/ExitThread/test2/test2.cpp b/src/pal/tests/palsuite/threading/ExitThread/test2/test2.cpp deleted file mode 100644 index c31af8a07..000000000 --- a/src/pal/tests/palsuite/threading/ExitThread/test2/test2.cpp +++ /dev/null @@ -1,168 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================= -** -** Source: test2.c -** -** Purpose: Test to ensure ExitThread() called from the last thread of -** a process shuts down that process and returns the proper -** exit code as specified in the ExitThread() call. -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** Fail -** ZeroMemory -** GetCurrentDirectoryW -** CreateProcessW -** WaitForSingleObject -** GetLastError -** strlen -** strncpy -** - -** -**===========================================================================*/ -#include -#include "myexitcode.h" - - -static const char* rgchPathDelim = "\\"; - - -int -mkAbsoluteFilename( LPSTR dirName, - DWORD dwDirLength, - LPCSTR fileName, - DWORD dwFileLength, - LPSTR absPathName ) -{ - DWORD sizeDN, sizeFN, sizeAPN; - - sizeDN = strlen( dirName ); - sizeFN = strlen( fileName ); - sizeAPN = (sizeDN + 1 + sizeFN + 1); - - /* ensure ((dirName + DELIM + fileName + \0) =< _MAX_PATH ) */ - if( sizeAPN > _MAX_PATH ) - { - return ( 0 ); - } - - strncpy( absPathName, dirName, dwDirLength +1 ); - strncpy( absPathName, rgchPathDelim, 2 ); - strncpy( absPathName, fileName, dwFileLength +1 ); - - return (sizeAPN); - -} - - -int __cdecl main( int argc, char **argv ) - -{ - const char* rgchChildFile = "childprocess"; - - STARTUPINFO si; - PROCESS_INFORMATION pi; - - DWORD dwError; - DWORD dwExitCode; - DWORD dwFileLength; - DWORD dwDirLength; - DWORD dwSize; - DWORD dwExpected = TEST_EXIT_CODE; - - char rgchDirName[_MAX_DIR]; - char absPathBuf[_MAX_PATH]; - char* rgchAbsPathName; - - /* initialize the PAL */ - if( PAL_Initialize(argc, argv) != 0 ) - { - return( FAIL ); - } - - /* zero our process and startup info structures */ - ZeroMemory( &si, sizeof(si) ); - si.cb = sizeof( si ); - ZeroMemory( &pi, sizeof(pi) ); - - /* build the absolute path to the child process */ - rgchAbsPathName = &absPathBuf[0]; - dwFileLength = strlen( rgchChildFile ); - - dwDirLength = GetCurrentDirectory( _MAX_PATH, rgchDirName ); - if( dwDirLength == 0 ) - { - dwError = GetLastError(); - Fail( "GetCurrentDirectory call failed with error code %d\n", - dwError ); - } - - dwSize = mkAbsoluteFilename( rgchDirName, - dwDirLength, - rgchChildFile, - dwFileLength, - rgchAbsPathName ); - if( dwSize == 0 ) - { - Fail( "Palsuite Code: mkAbsoluteFilename() call failed. Could ", - "not build absolute path name to file\n. Exiting.\n" ); - } - - /* launch the child process */ - if( !CreateProcess( NULL, /* module name to execute */ - rgchAbsPathName, /* command line */ - NULL, /* process handle not */ - /* inheritable */ - NULL, /* thread handle not */ - /* inheritable */ - FALSE, /* handle inheritance */ - CREATE_NEW_CONSOLE, /* dwCreationFlags */ - NULL, /* use parent's environment */ - NULL, /* use parent's starting */ - /* directory */ - &si, /* startup info struct */ - &pi ) /* process info struct */ - ) - { - dwError = GetLastError(); - Fail( "CreateProcess call failed with error code %d\n", - dwError ); - } - - /* wait for the child process to complete */ - WaitForSingleObject ( pi.hProcess, INFINITE ); - - /* check the exit code from the process */ - if( ! GetExitCodeProcess( pi.hProcess, &dwExitCode ) ) - { - dwError = GetLastError(); - CloseHandle ( pi.hProcess ); - CloseHandle ( pi.hThread ); - Fail( "GetExitCodeProcess call failed with error code %d\n", - dwError ); - } - - /* close process and thread handle */ - CloseHandle ( pi.hProcess ); - CloseHandle ( pi.hThread ); - - /* check for the expected exit code */ - /* exit code for some systems is as small as a char, so that's all */ - /* we'll compare for checking success */ - if( LOBYTE(LOWORD(dwExitCode)) != LOBYTE(LOWORD(dwExpected)) ) - { - Fail( "GetExitCodeProcess returned an incorrect exit code %d, " - "expected value is %d\n", - LOWORD(dwExitCode), dwExpected ); - } - - /* terminate the PAL */ - PAL_Terminate(); - - /* return success */ - return PASS; -} diff --git a/src/pal/tests/palsuite/threading/ExitThread/test2/testinfo.dat b/src/pal/tests/palsuite/threading/ExitThread/test2/testinfo.dat deleted file mode 100644 index 4b5bdc2ac..000000000 --- a/src/pal/tests/palsuite/threading/ExitThread/test2/testinfo.dat +++ /dev/null @@ -1,19 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = threading -Function = ExitThread -Name = Test for ExitThread -TYPE = DEFAULT -EXE1 = test2 -EXE2 = childprocess -Description -= Test to ensure proper operation of the ExitThread -= API. This test launches a simple child process that exits -= by calling ExitThread() with a known value, and checks -= that the correct value is returned to the parent process. -= This verifies that when the last thread of a process exits -= via ExitThread, the process exits with the proper return -= code. diff --git a/src/pal/tests/palsuite/threading/ExitThread/test3/dllmain.cpp b/src/pal/tests/palsuite/threading/ExitThread/test3/dllmain.cpp deleted file mode 100644 index 862aff5f0..000000000 --- a/src/pal/tests/palsuite/threading/ExitThread/test3/dllmain.cpp +++ /dev/null @@ -1,65 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================= -** -** Source: dllmain.c -** -** Purpose: Test to ensure DllMain() is called with THREAD_DETACH -** when a thread in the application calls ExitThread(). -** -** Dependencies: none -** - -** -**===========================================================================*/ - -#include - -/* count of the number of times DllMain() was called with THREAD_DETACH */ -static int g_detachCount = 0; - - -/* standard DllMain() */ -BOOL PALAPI DllMain(HINSTANCE hinstDLL, DWORD reason, LPVOID lpvReserved) -{ - switch( reason ) - { - case DLL_PROCESS_ATTACH: - { - break; - } - - case DLL_PROCESS_DETACH: - { - break; - } - - case DLL_THREAD_ATTACH: - break; - - case DLL_THREAD_DETACH: - /* increment g_detachCount */ - g_detachCount++; - break; - } - return TRUE; -} - -#ifdef WIN32 -BOOL PALAPI _DllMainCRTStartup(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) -{ - return DllMain(hinstDLL, fdwReason, lpvReserved); -} -#endif - - -/* function to return the current detach count */ -#ifdef WIN32 -__declspec(dllexport) -#endif -int PALAPI GetDetachCount( void ) -{ - return g_detachCount; -} diff --git a/src/pal/tests/palsuite/threading/ExitThread/test3/test3.cpp b/src/pal/tests/palsuite/threading/ExitThread/test3/test3.cpp deleted file mode 100644 index 8a71c7cc9..000000000 --- a/src/pal/tests/palsuite/threading/ExitThread/test3/test3.cpp +++ /dev/null @@ -1,162 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================= -** -** Source: test3.c -** -** Purpose: Test to ensure ExitThread() results in any loaded dynamic -** libraries having their entry point called with a THREAD_DETACH -** notification. -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** Fail -** GetCurrentDirectoryW -** CreateThread -** ResumeThread -** LoadLibrary -** FreeLibrary -** GetProcAddress -** WaitForSingleObject -** GetLastError -** strlen -** strncpy -** - -** -**===========================================================================*/ -#include - -/* SHLEXT is defined only for Unix variants */ - -#if defined(SHLEXT) -#define rgchLibraryFile "dllmain"SHLEXT -#define szFunction "GetDetachCount" -#else -#define rgchLibraryFile "dllmain" -#define szFunction "_GetDetachCount@0" -#endif - -/* define our test function type */ -typedef int ( PALAPI *LPTESTFUNC )( void ); - - -/** - * ThreadFunc - * - * Dummy thread function for causing DLL thread notifications. - */ -DWORD PALAPI ThreadFunc( LPVOID param ) -{ - /* simulate some brief "work" */ - int i; - for( i=0; i<100000; i++ ) - ; - - ExitThread( 0 ); - return (0); -} - - -/* main program entry point */ -int __cdecl main( int argc, char **argv ) - -{ - /* local variables */ - - HANDLE hLib = NULL; - LPTESTFUNC pFunc; - int detachCount1 = 0; - int detachCount2 = 0; - - HANDLE hThread = NULL; - DWORD IDThread; - - /* initialize the PAL */ - if( PAL_Initialize(argc, argv) != 0 ) - { - return( FAIL ); - } - - /* Load the test library */ - hLib = LoadLibrary( rgchLibraryFile ); - if(hLib == NULL) - { - Fail("ERROR: Unable to load library %s\n", rgchLibraryFile ); - } - - - /* Get the address of our test function in the dll */ - pFunc = (LPTESTFUNC)GetProcAddress( hLib, szFunction ); - if( pFunc == NULL ) - { - Trace( "ERROR:%lu%:Unable to load function \"%s\" library \"%s\"\n", - GetLastError(), - szFunction, - rgchLibraryFile ); - if( ! FreeLibrary( hLib ) ) { - Trace( "FreeLibrary() failed with error code %lu\n", - GetLastError() ); - } - Fail( "Exiting\n" ); - } - - /* Execute the test function to get the detach count */ - detachCount1 = pFunc(); - - /* run another dummy thread to cause notification of the library */ - hThread = CreateThread( NULL, /* no security attributes */ - 0, /* use default stack size */ - (LPTHREAD_START_ROUTINE) ThreadFunc, /* thread function */ - (LPVOID) NULL, /* pass thread index as */ - /* function argument */ - CREATE_SUSPENDED, /* create suspended */ - &IDThread ); /* returns thread id */ - - /* Check the return value for success. */ - if( hThread == NULL ) - { - /* error creating thread */ - Trace( "Unexpected CreateThread error %d\n", - GetLastError() ); - if( ! FreeLibrary( hLib ) ) { - Trace( "FreeLibrary() failed with error code %lu\n", - GetLastError() ); - } - Fail( "Exiting\n" ); - } - - /* Resume the suspended thread */ - ResumeThread( hThread ); - - /* wait for the thread to complete */ - WaitForSingleObject( hThread, INFINITE ); - - /* Execute the test function to get the new detach count */ - detachCount2 = pFunc(); - - /* Unload the test library */ - if( !FreeLibrary( hLib ) ) - { - Fail( "ERROR:%u: Unable to free library \"%s\"\n", - GetLastError(), - rgchLibraryFile ); - } - - /* validate the result */ - if( detachCount2 != (detachCount1 + 1) ) - { - Fail( "FAIL: unexpected DLL detach count %d, expected %d\n", - detachCount2, - (detachCount1 + 1) ); - } - - - /* terminate the PAL */ - PAL_Terminate(); - - /* return success */ - return PASS; -} diff --git a/src/pal/tests/palsuite/threading/ExitThread/test3/testinfo.dat b/src/pal/tests/palsuite/threading/ExitThread/test3/testinfo.dat deleted file mode 100644 index 1c9e8c756..000000000 --- a/src/pal/tests/palsuite/threading/ExitThread/test3/testinfo.dat +++ /dev/null @@ -1,16 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = threading -Function = ExitThread -Name = Test for ExitThread -TYPE = DEFAULT -EXE1 = test3 -LIB1 = dllmain -Description -= Test to ensure proper operation of the ExitThread -= API. This tests to make sure ExitThread() results -= in any loaded dynamic libraries having their entry -= point called with a THREAD_DETACH notification. diff --git a/src/pal/tests/palsuite/threading/GetCurrentProcess/CMakeLists.txt b/src/pal/tests/palsuite/threading/GetCurrentProcess/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/threading/GetCurrentProcess/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/threading/GetCurrentProcess/test1/CMakeLists.txt b/src/pal/tests/palsuite/threading/GetCurrentProcess/test1/CMakeLists.txt deleted file mode 100644 index be17127c1..000000000 --- a/src/pal/tests/palsuite/threading/GetCurrentProcess/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - process.cpp -) - -add_executable(paltest_getcurrentprocess_test1 - ${SOURCES} -) - -add_dependencies(paltest_getcurrentprocess_test1 coreclrpal) - -target_link_libraries(paltest_getcurrentprocess_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/GetCurrentProcess/test1/process.cpp b/src/pal/tests/palsuite/threading/GetCurrentProcess/test1/process.cpp deleted file mode 100644 index 17d9af628..000000000 --- a/src/pal/tests/palsuite/threading/GetCurrentProcess/test1/process.cpp +++ /dev/null @@ -1,40 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source: GetCurrentProcess/test1/process.c -** -** Purpose: Test for to see if the process GetCurrentProcess -** returns a handle to the current process or not. -** -** Dependencies: TerminateProcess -** -** -**=========================================================*/ - -#include - -INT __cdecl main( int argc, char **argv ) -{ - - HANDLE hProcess; - - if(0 != (PAL_Initialize(argc, argv))) - { - return ( FAIL ); - } - - hProcess = GetCurrentProcess(); - Trace ("Testing the handle returned by GetCurrentProcess\n"); - if ( 0 == ( TerminateProcess ( hProcess, PASS ) ) ) - { - Fail ("Testing GetCurrentProcess, the TerminateProcess function " - "failed.\n"); - } - - PAL_Terminate(); - return ( PASS ); - -} diff --git a/src/pal/tests/palsuite/threading/GetCurrentProcess/test1/testinfo.dat b/src/pal/tests/palsuite/threading/GetCurrentProcess/test1/testinfo.dat deleted file mode 100644 index 8eb2759fb..000000000 --- a/src/pal/tests/palsuite/threading/GetCurrentProcess/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = threading -Function = GetCurrentProcess -Name = Positive Test for GetCurrentProcess -TYPE = DEFAULT -EXE1 = process -Description -= Test to see if the function GetCurrentProcess returns a handle to the -= current process or not. diff --git a/src/pal/tests/palsuite/threading/GetCurrentProcessId/CMakeLists.txt b/src/pal/tests/palsuite/threading/GetCurrentProcessId/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/threading/GetCurrentProcessId/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/threading/GetCurrentProcessId/test1/CMakeLists.txt b/src/pal/tests/palsuite/threading/GetCurrentProcessId/test1/CMakeLists.txt deleted file mode 100644 index f1ac1e0d4..000000000 --- a/src/pal/tests/palsuite/threading/GetCurrentProcessId/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - processId.cpp -) - -add_executable(paltest_getcurrentprocessid_test1 - ${SOURCES} -) - -add_dependencies(paltest_getcurrentprocessid_test1 coreclrpal) - -target_link_libraries(paltest_getcurrentprocessid_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/GetCurrentProcessId/test1/processId.cpp b/src/pal/tests/palsuite/threading/GetCurrentProcessId/test1/processId.cpp deleted file mode 100644 index cc689b3f8..000000000 --- a/src/pal/tests/palsuite/threading/GetCurrentProcessId/test1/processId.cpp +++ /dev/null @@ -1,41 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source: getcurrentprocessid/test1/processid.c -** -** Purpose: Test to ensure GetCurrentProcessId returns the current -** process id number. This test compares the result of -** GetCurrentProcessId to getpid. -** -** -**=========================================================*/ - -#include - -INT __cdecl main( int argc, char **argv ) -{ - - DWORD dwProcessId; - - if(0 != (PAL_Initialize(argc, argv))) - { - return ( FAIL ); - } - - dwProcessId = GetCurrentProcessId(); - - if ( 0 >= dwProcessId ) - { - Fail ("%s has dwProcessId has id value %d\n", argv[0], - dwProcessId ); - } - Trace ("%s has dwProcessId %d\nPassing test as dwProcessId is > 0\n" - , argv[0], dwProcessId); - - PAL_Terminate(); - return ( PASS ); - -} diff --git a/src/pal/tests/palsuite/threading/GetCurrentProcessId/test1/testinfo.dat b/src/pal/tests/palsuite/threading/GetCurrentProcessId/test1/testinfo.dat deleted file mode 100644 index db615c0bf..000000000 --- a/src/pal/tests/palsuite/threading/GetCurrentProcessId/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = threading -Function = GetCurrentProcessId -Name = Positive Test for GetCurrentProcessId -TYPE = DEFAULT -EXE1 = processid -Description -= Test to ensure GetCurrentProcessId returns the current process id number. -= This test compares the result of GetCurrentProcessId to getpid. diff --git a/src/pal/tests/palsuite/threading/GetCurrentThread/CMakeLists.txt b/src/pal/tests/palsuite/threading/GetCurrentThread/CMakeLists.txt deleted file mode 100644 index ef14ea535..000000000 --- a/src/pal/tests/palsuite/threading/GetCurrentThread/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) - diff --git a/src/pal/tests/palsuite/threading/GetCurrentThread/test1/CMakeLists.txt b/src/pal/tests/palsuite/threading/GetCurrentThread/test1/CMakeLists.txt deleted file mode 100644 index dacb9b40c..000000000 --- a/src/pal/tests/palsuite/threading/GetCurrentThread/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - thread.cpp -) - -add_executable(paltest_getcurrentthread_test1 - ${SOURCES} -) - -add_dependencies(paltest_getcurrentthread_test1 coreclrpal) - -target_link_libraries(paltest_getcurrentthread_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/GetCurrentThread/test1/testinfo.dat b/src/pal/tests/palsuite/threading/GetCurrentThread/test1/testinfo.dat deleted file mode 100644 index 29c9767ed..000000000 --- a/src/pal/tests/palsuite/threading/GetCurrentThread/test1/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = threading -Function = GetCurrentThread -Name = Positive Test for GetCurrentThread -TYPE = DEFAULT -EXE1 = thread -Description -= Test to ensure GetCurrentThread returns a handle to the current thread. diff --git a/src/pal/tests/palsuite/threading/GetCurrentThread/test1/thread.cpp b/src/pal/tests/palsuite/threading/GetCurrentThread/test1/thread.cpp deleted file mode 100644 index b2bb97fd6..000000000 --- a/src/pal/tests/palsuite/threading/GetCurrentThread/test1/thread.cpp +++ /dev/null @@ -1,93 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source: GetCurrentThread/test1/thread.c -** -** Purpose: Test to ensure GetCurrentThread returns a handle to -** the current thread. -** -** Dependencies: GetThreadPriority -** SetThreadPriority -** Fail -** Trace -** - -** -**=========================================================*/ - -#include - -int __cdecl main( int argc, char **argv ) -{ - - HANDLE hThread; - int nPriority; - - if(0 != (PAL_Initialize(argc, argv))) - { - return ( FAIL ); - } - -#if !HAVE_SCHED_OTHER_ASSIGNABLE - /* Defining thread priority for SCHED_OTHER is implementation defined. - Some platforms like NetBSD cannot reassign it as they are dynamic. - */ - printf("paltest_getcurrentthread_test1 has been disabled on this platform\n"); -#else - hThread = GetCurrentThread(); - - nPriority = GetThreadPriority(hThread); - - if ( THREAD_PRIORITY_NORMAL != nPriority ) - { - if ( THREAD_PRIORITY_ERROR_RETURN == nPriority ) - { - Fail ("GetThreadPriority function call failed for %s\n" - "GetLastError returned %d\n", argv[0], GetLastError()); - } - else - { - Fail ("GetThreadPriority function call failed for %s\n" - "The priority returned was %d\n", argv[0], nPriority); - } - } - else - { - nPriority = 0; - - if (0 == SetThreadPriority(hThread, THREAD_PRIORITY_HIGHEST)) - { - Fail ("Unable to set thread priority. Either handle doesn't" - " point to current thread \nor SetThreadPriority " - "function failed. Failing test.\n"); - } - - nPriority = GetThreadPriority(hThread); - - if ( THREAD_PRIORITY_ERROR_RETURN == nPriority ) - { - Fail ("GetThreadPriority function call failed for %s\n" - "GetLastError returned %d\n", argv[0], GetLastError()); - } - else if ( THREAD_PRIORITY_HIGHEST == nPriority ) - { - Trace ("GetCurrentThread returns handle to the current " - "thread.\n"); - exit ( PASS ); - } - else - { - Fail ("Unable to set thread priority. Either handle doesn't" - " point to current thread \nor SetThreadPriority " - "function failed. Failing test.\n"); - } - } -#endif - - PAL_Terminate(); - return ( PASS ); - -} diff --git a/src/pal/tests/palsuite/threading/GetCurrentThread/test2/CMakeLists.txt b/src/pal/tests/palsuite/threading/GetCurrentThread/test2/CMakeLists.txt deleted file mode 100644 index 58419a869..000000000 --- a/src/pal/tests/palsuite/threading/GetCurrentThread/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test2.cpp -) - -add_executable(paltest_getcurrentthread_test2 - ${SOURCES} -) - -add_dependencies(paltest_getcurrentthread_test2 coreclrpal) - -target_link_libraries(paltest_getcurrentthread_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/GetCurrentThread/test2/test2.cpp b/src/pal/tests/palsuite/threading/GetCurrentThread/test2/test2.cpp deleted file mode 100644 index beeb5ec24..000000000 --- a/src/pal/tests/palsuite/threading/GetCurrentThread/test2/test2.cpp +++ /dev/null @@ -1,144 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================= -** -** Source: test2.c -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** Fail -** CreateThread -** SetThreadPriority -** GetThreadPriority -** ResumeThread -** WaitForSingleObject -** GetLastError -** -** Purpose: -** -** Test to ensure proper operation of the GetCurrentThread() -** API. The test launches a thread in suspended mode, and sets -** its priority to a non-default value using the handle returned -** by CreateThread(). The new thread calls GetCurrentThred() to -** retrieve a handle to itself, and calls GetThreadPriority() -** to verify that its priority matches what it was set to on -** the main execution thread. -** - -** -**===========================================================================*/ -#include - - -/* we store the return code from the child thread here because */ -/* we're missing the GetExitCodeThread() API */ - -static int g_priority = 0; - -/** - * ThreadFunc - * - * Thread function that calls GetCurrentThread() to get a pseudo-handle - * to itself, then checks its priority and exits with that value. - */ -DWORD PALAPI ThreadFunc( LPVOID param ) -{ - int priority; - HANDLE hThread; - - /* call GetCurrentThread() to get a pseudo-handle to */ - /* the current thread */ - hThread = GetCurrentThread(); - if( hThread == NULL ) - { - Fail( "GetCurrentThread() call failed\n" ); - } - - - /* get the current thread priority */ - priority = GetThreadPriority( hThread ); - if( priority == THREAD_PRIORITY_ERROR_RETURN ) - { - /* GetThreadPriority call failed */ - Fail( "ERROR:%lu:GetThreadPriority() call failed\n", GetLastError() ); - } - - /* store this globally because we don't have GetExitCodeThread() */ - g_priority = priority; - return (DWORD)priority; -} - - -/** - * main - * - * executable entry point - */ -INT __cdecl main( INT argc, CHAR **argv ) -{ - HANDLE hThread = NULL; - DWORD IDThread; - DWORD dwRet; - - SIZE_T i = 0; - - /* PAL initialization */ - if( (PAL_Initialize(argc, argv)) != 0 ) - { - return( FAIL ); - } - -#if !HAVE_SCHED_OTHER_ASSIGNABLE - /* Defining thread priority for SCHED_OTHER is implementation defined. - Some platforms like NetBSD cannot reassign it as they are dynamic. - */ - printf("paltest_getcurrentthread_test2 has been disabled on this platform\n"); -#else - /* Create multiple threads. */ - hThread = CreateThread( NULL, /* no security attributes */ - 0, /* use default stack size */ - (LPTHREAD_START_ROUTINE) ThreadFunc, /* thread function */ - (LPVOID) i, /* pass thread index as */ - /* function argument */ - CREATE_SUSPENDED, /* create suspended */ - &IDThread ); /* returns thread identifier */ - - /* Check the return value for success. */ - if( hThread == NULL ) - { - /* ERROR */ - Fail( "ERROR:%lu:CreateThread failed\n", GetLastError() ); - } - - /* set the thread priority of the new thread to the highest value */ - if( ! SetThreadPriority( hThread, THREAD_PRIORITY_TIME_CRITICAL) ) - { - Fail( "ERROR:%lu:SetThreadPriority() call failed\n", GetLastError() ); - } - - /* let the child thread run now */ - ResumeThread( hThread ); - - - /* wait for the thread to finish */ - dwRet = WaitForSingleObject( hThread, INFINITE ); - if( dwRet == WAIT_FAILED ) - { - /* ERROR */ - Fail( "ERROR:%lu:WaitForSingleObject call failed\n", GetLastError() ); - } - - /* validate the thread's exit code */ - if( g_priority != THREAD_PRIORITY_TIME_CRITICAL ) - { - /* ERROR */ - Fail( "FAIL:Unexpected thread priority %d returned, expected %d\n", - g_priority, THREAD_PRIORITY_TIME_CRITICAL ); - } -#endif - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/threading/GetCurrentThread/test2/testinfo.dat b/src/pal/tests/palsuite/threading/GetCurrentThread/test2/testinfo.dat deleted file mode 100644 index 96a6d403b..000000000 --- a/src/pal/tests/palsuite/threading/GetCurrentThread/test2/testinfo.dat +++ /dev/null @@ -1,18 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = threading -Function = GetCurrentThread -Name = Test for GetCurrentThread -TYPE = DEFAULT -EXE1 = test2 -Description -= Test to ensure proper operation of the GetCurrentThread() -= API. The test launches a thread in suspended mode, and sets -= its priority to a non-default value using the handle returned -= by CreateThread(). The new thread calls GetCurrentThred() to -= retrieve a handle to itself, and calls GetThreadPriority() -= to verify that its priority matches what it was set to on -= the main execution thread. diff --git a/src/pal/tests/palsuite/threading/GetCurrentThreadId/CMakeLists.txt b/src/pal/tests/palsuite/threading/GetCurrentThreadId/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/threading/GetCurrentThreadId/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/threading/GetCurrentThreadId/test1/CMakeLists.txt b/src/pal/tests/palsuite/threading/GetCurrentThreadId/test1/CMakeLists.txt deleted file mode 100644 index ecad3d287..000000000 --- a/src/pal/tests/palsuite/threading/GetCurrentThreadId/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - threadId.cpp -) - -add_executable(paltest_getcurrentthreadid_test1 - ${SOURCES} -) - -add_dependencies(paltest_getcurrentthreadid_test1 coreclrpal) - -target_link_libraries(paltest_getcurrentthreadid_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/GetCurrentThreadId/test1/testinfo.dat b/src/pal/tests/palsuite/threading/GetCurrentThreadId/test1/testinfo.dat deleted file mode 100644 index 4d1e056b7..000000000 --- a/src/pal/tests/palsuite/threading/GetCurrentThreadId/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = threading -Function = GetCurrentThreadId -Name = Positive Test for GetCurrentThreadId -TYPE = DEFAULT -EXE1 = threadid -Description -= Test to ensure GetCurrentThreadId returns the threadId of the current -= thread. diff --git a/src/pal/tests/palsuite/threading/GetCurrentThreadId/test1/threadId.cpp b/src/pal/tests/palsuite/threading/GetCurrentThreadId/test1/threadId.cpp deleted file mode 100644 index acbb1ff37..000000000 --- a/src/pal/tests/palsuite/threading/GetCurrentThreadId/test1/threadId.cpp +++ /dev/null @@ -1,82 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source: getcurrentthreadid/test1/threadid.c -** -** Purpose: Test to ensure GetCurrentThreadId returns the threadId of the -** current thread. -** -** Dependencies: CloseHandle -** WaitForSingleObject -** CreateThread -** - -** -**=========================================================*/ - - -#include - -DWORD dwThreadIdTF; - -DWORD PALAPI ThreadFunction ( LPVOID lpParam ) -{ - Trace ("thread code executed\n"); - dwThreadIdTF = GetCurrentThreadId(); - return 0; -} - -int __cdecl main( int argc, char **argv ) -{ - extern DWORD dwThreadIdTF; - DWORD dwThreadIdCT; - HANDLE hThread; - DWORD dwThreadParam = 1; - DWORD dwThreadWait; - - if(0 != (PAL_Initialize(argc, argv))) - { - return ( FAIL ); - } - - hThread = CreateThread( - NULL, - 0, - ThreadFunction, - &dwThreadParam, - 0, - &dwThreadIdCT); - - if ( NULL == hThread ) - { - Fail ( "CreateThread() call failed - returned NULL"); - } - else - { - dwThreadWait = WaitForSingleObject( hThread, INFINITE ); - - Trace ("dwThreadWait returned %d\n", dwThreadWait ); - - if ( dwThreadIdCT == dwThreadIdTF ) - { - Trace ( "ThreadId numbers match - GetCurrentThreadId" - " works. dwThreadIdCT == dwThreadIdTF == %d\n", - dwThreadIdTF ); - PAL_Terminate(); - return ( PASS ); - } - else - { - Fail ( "ThreadId numbers don't match - " - "GetCurrentThreadId fails dwThreadIdCT = %d " - "and dwThreadIdTF = %d\n", dwThreadIdCT, dwThreadIdTF); - } - } - - PAL_TerminateEx(FAIL); - return (FAIL); - -} diff --git a/src/pal/tests/palsuite/threading/GetExitCodeProcess/CMakeLists.txt b/src/pal/tests/palsuite/threading/GetExitCodeProcess/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/threading/GetExitCodeProcess/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/threading/GetExitCodeProcess/test1/CMakeLists.txt b/src/pal/tests/palsuite/threading/GetExitCodeProcess/test1/CMakeLists.txt deleted file mode 100644 index 184470aee..000000000 --- a/src/pal/tests/palsuite/threading/GetExitCodeProcess/test1/CMakeLists.txt +++ /dev/null @@ -1,32 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(TESTSOURCES - test1.cpp -) - -add_executable(paltest_getexitcodeprocess_test1 - ${TESTSOURCES} -) - -add_dependencies(paltest_getexitcodeprocess_test1 coreclrpal) - -target_link_libraries(paltest_getexitcodeprocess_test1 - ${COMMON_TEST_LIBRARIES} -) - - -set(HELPERSOURCES - childProcess.cpp -) - -add_executable(paltest_getexitcodeprocess_test1_child - ${HELPERSOURCES} -) - -add_dependencies(paltest_getexitcodeprocess_test1_child coreclrpal) - -target_link_libraries(paltest_getexitcodeprocess_test1_child - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/GetExitCodeProcess/test1/childProcess.cpp b/src/pal/tests/palsuite/threading/GetExitCodeProcess/test1/childProcess.cpp deleted file mode 100644 index fe1b38fb3..000000000 --- a/src/pal/tests/palsuite/threading/GetExitCodeProcess/test1/childProcess.cpp +++ /dev/null @@ -1,31 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source: childprocess.c -** -** Purpose: Test to ensure GetExitCodeProcess returns the right -** value. All this program does is return a predefined value. -** -** Dependencies: none -** - -** -**=========================================================*/ - -#include -#include "myexitcode.h" - -int __cdecl main( int argc, char **argv ) -{ - int i; - - // simulate some activity - for( i=0; i<10000; i++ ) - ; - - // return the predefined exit code - return TEST_EXIT_CODE; -} diff --git a/src/pal/tests/palsuite/threading/GetExitCodeProcess/test1/myexitcode.h b/src/pal/tests/palsuite/threading/GetExitCodeProcess/test1/myexitcode.h deleted file mode 100644 index 60a140d1f..000000000 --- a/src/pal/tests/palsuite/threading/GetExitCodeProcess/test1/myexitcode.h +++ /dev/null @@ -1,14 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: myexitcode.h -** -** Purpose: Define an exit code. -** -** -**==========================================================================*/ - -#define TEST_EXIT_CODE 104 diff --git a/src/pal/tests/palsuite/threading/GetExitCodeProcess/test1/test1.cpp b/src/pal/tests/palsuite/threading/GetExitCodeProcess/test1/test1.cpp deleted file mode 100644 index 0f98cf8f5..000000000 --- a/src/pal/tests/palsuite/threading/GetExitCodeProcess/test1/test1.cpp +++ /dev/null @@ -1,163 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================= -** -** Source: test1.c -** -** Purpose: Test to ensure GetExitCodeProcess works properly. -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** Fail -** ZeroMemory -** GetCurrentDirectoryW -** CreateProcessW -** WaitForSingleObject -** GetLastError -** strlen -** strncpy -** - -** -**===========================================================================*/ -#include -#include "myexitcode.h" - - -static const char* rgchPathDelim = "\\"; - - -int -mkAbsoluteFilename( LPSTR dirName, - DWORD dwDirLength, - LPCSTR fileName, - DWORD dwFileLength, - LPSTR absPathName ) -{ - DWORD sizeDN, sizeFN, sizeAPN; - - sizeDN = strlen( dirName ); - sizeFN = strlen( fileName ); - sizeAPN = (sizeDN + 1 + sizeFN + 1); - - /* ensure ((dirName + DELIM + fileName + \0) =< _MAX_PATH ) */ - if( sizeAPN > _MAX_PATH ) - { - return ( 0 ); - } - - strncpy( absPathName, dirName, dwDirLength +1 ); - strncpy( absPathName, rgchPathDelim, 2 ); - strncpy( absPathName, fileName, dwFileLength +1 ); - - return (sizeAPN); - -} - - -int __cdecl main( int argc, char **argv ) - -{ - const char* rgchChildFile = "childprocess"; - - STARTUPINFO si; - PROCESS_INFORMATION pi; - - DWORD dwError; - DWORD dwExitCode; - DWORD dwFileLength; - DWORD dwDirLength; - DWORD dwSize; - - char rgchDirName[_MAX_DIR]; - char absPathBuf[_MAX_PATH]; - char* rgchAbsPathName; - - /* initialize the PAL */ - if( PAL_Initialize(argc, argv) != 0 ) - { - return( FAIL ); - } - - /* zero our process and startup info structures */ - ZeroMemory( &si, sizeof(si) ); - si.cb = sizeof( si ); - ZeroMemory( &pi, sizeof(pi) ); - - /* build the absolute path to the child process */ - rgchAbsPathName = &absPathBuf[0]; - dwFileLength = strlen( rgchChildFile ); - - dwDirLength = GetCurrentDirectory( _MAX_PATH, rgchDirName ); - if( dwDirLength == 0 ) - { - dwError = GetLastError(); - Fail( "GetCurrentDirectory call failed with error code %d\n", - dwError ); - } - - dwSize = mkAbsoluteFilename( rgchDirName, - dwDirLength, - rgchChildFile, - dwFileLength, - rgchAbsPathName ); - if( dwSize == 0 ) - { - Fail( "Palsuite Code: mkAbsoluteFilename() call failed. Could ", - "not build absolute path name to file\n. Exiting.\n" ); - } - - /* launch the child process */ - if( !CreateProcess( NULL, /* module name to execute */ - rgchAbsPathName, /* command line */ - NULL, /* process handle not */ - /* inheritable */ - NULL, /* thread handle not */ - /* inheritable */ - FALSE, /* handle inheritance */ - CREATE_NEW_CONSOLE, /* dwCreationFlags */ - NULL, /* use parent's environment */ - NULL, /* use parent's starting */ - /* directory */ - &si, /* startup info struct */ - &pi ) /* process info struct */ - ) - { - dwError = GetLastError(); - Fail( "CreateProcess call failed with error code %d\n", - dwError ); - } - - /* wait for the child process to complete */ - WaitForSingleObject ( pi.hProcess, INFINITE ); - - /* check the exit code from the process */ - if( ! GetExitCodeProcess( pi.hProcess, &dwExitCode ) ) - { - dwError = GetLastError(); - CloseHandle ( pi.hProcess ); - CloseHandle ( pi.hThread ); - Fail( "GetExitCodeProcess call failed with error code %d\n", - dwError ); - } - - /* close process and thread handle */ - CloseHandle ( pi.hProcess ); - CloseHandle ( pi.hThread ); - - /* check for the expected exit code */ - if( dwExitCode != TEST_EXIT_CODE ) - { - Fail( "GetExitCodeProcess returned an incorrect exit code %d, " - "expected value is %d\n", - dwExitCode, TEST_EXIT_CODE ); - } - - /* terminate the PAL */ - PAL_Terminate(); - - /* return success */ - return PASS; -} diff --git a/src/pal/tests/palsuite/threading/GetExitCodeProcess/test1/testinfo.dat b/src/pal/tests/palsuite/threading/GetExitCodeProcess/test1/testinfo.dat deleted file mode 100644 index d06719f0b..000000000 --- a/src/pal/tests/palsuite/threading/GetExitCodeProcess/test1/testinfo.dat +++ /dev/null @@ -1,16 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = threading -Function = GetExitCodeProcess -Name = Test for GetExitCodeProcess -TYPE = DEFAULT -EXE1 = test1 -EXE2 = childprocess -Description -= Test to ensure proper operation of the GetExitCodeProcess -= API. This test launches a simple child process that exits -= with a known value, and checks that the correct value is -= returned by the function. diff --git a/src/pal/tests/palsuite/threading/GetProcessTimes/CMakeLists.txt b/src/pal/tests/palsuite/threading/GetProcessTimes/CMakeLists.txt deleted file mode 100644 index f4796dc1d..000000000 --- a/src/pal/tests/palsuite/threading/GetProcessTimes/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test2) - diff --git a/src/pal/tests/palsuite/threading/GetProcessTimes/test2/CMakeLists.txt b/src/pal/tests/palsuite/threading/GetProcessTimes/test2/CMakeLists.txt deleted file mode 100644 index b062b349a..000000000 --- a/src/pal/tests/palsuite/threading/GetProcessTimes/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test2.cpp -) - -add_executable(paltest_getprocesstimes_test2 - ${SOURCES} -) - -add_dependencies(paltest_getprocesstimes_test2 coreclrpal) - -target_link_libraries(paltest_getprocesstimes_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/GetProcessTimes/test2/test2.cpp b/src/pal/tests/palsuite/threading/GetProcessTimes/test2/test2.cpp deleted file mode 100644 index cc39de609..000000000 --- a/src/pal/tests/palsuite/threading/GetProcessTimes/test2/test2.cpp +++ /dev/null @@ -1,122 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================= -** -** Source: test2.c -** -** Purpose: Test to ensure GetProcessTimes works properly. -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** Fail -** ZeroMemory -** CompareFileTime -** GetLastError -** - -** -**===========================================================================*/ -#include - - -int __cdecl main( int argc, char **argv ) - -{ - int i, j, k; - int *total; - - HANDLE hProcess; - FILETIME createTime; - FILETIME exitTime; - FILETIME kernelTime1; - FILETIME userTime1; - FILETIME kernelTime2; - FILETIME userTime2; - - DWORD dwError; - - /* initialize the PAL */ - if( PAL_Initialize(argc, argv) != 0 ) - { - return( FAIL ); - } - - /* get our own process handle */ - hProcess = GetCurrentProcess(); - if( hProcess == NULL ) - { - Fail( "GetCurrentProcess() returned a NULL handle.\n" ); - } - - /* zero our time structures */ - ZeroMemory( &createTime, sizeof(createTime) ); - ZeroMemory( &exitTime, sizeof(exitTime) ); - ZeroMemory( &kernelTime1, sizeof(kernelTime1) ); - ZeroMemory( &userTime1, sizeof(userTime1) ); - ZeroMemory( &kernelTime2, sizeof(kernelTime2) ); - ZeroMemory( &userTime2, sizeof(userTime2) ); - - /* check the process times for the child process */ - if( ! GetProcessTimes( hProcess, - &createTime, - &exitTime, - &kernelTime1, - &userTime1 ) ) - { - dwError = GetLastError(); - Fail( "GetProcessTimes() call failed with error code %d\n", - dwError ); - } - - - /* simulate some activity */ - for( i=0; i<1000; i++ ) - { - for( j=0; j<1000; j++ ) - { - /* do kernel work to increase system usage counters */ - total = (int*)malloc(1024 * 1024); - - *total = j * i; - for( k=0; k<1000; k++ ) - { - *total += k + i; - } - - free(total); - } - } - - /* check the process times for the child process */ - if( ! GetProcessTimes( hProcess, - &createTime, - &exitTime, - &kernelTime2, - &userTime2 ) ) - { - dwError = GetLastError(); - Fail( "GetProcessTimes() call failed with error code %d\n", - dwError ); - } - - - /* very simple logical checking of the results */ - if( CompareFileTime( &kernelTime1, &kernelTime2 ) > 0 ) - { - Fail( "Unexpected kernel time value reported.\n" ); - } - - if( CompareFileTime( &userTime1, &userTime2 ) > 0 ) - { - Fail( "Unexpected user time value reported.\n" ); - } - - - /* terminate the PAL */ - PAL_Terminate(); - - /* return success */ - return PASS; -} diff --git a/src/pal/tests/palsuite/threading/GetProcessTimes/test2/testinfo.dat b/src/pal/tests/palsuite/threading/GetProcessTimes/test2/testinfo.dat deleted file mode 100644 index d0d3b75f0..000000000 --- a/src/pal/tests/palsuite/threading/GetProcessTimes/test2/testinfo.dat +++ /dev/null @@ -1,15 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = threading -Function = GetProcessTimes -Name = Test for GetProcessTimes -TYPE = DEFAULT -EXE1 = test2 -Description -= Test to ensure proper operation of the GetProcessTimes() -= API. This test simply checks the kernel/user times for the -= the current process, which is the only thing supported -= for this function under the PAL. diff --git a/src/pal/tests/palsuite/threading/GetThreadTimes/CMakeLists.txt b/src/pal/tests/palsuite/threading/GetThreadTimes/CMakeLists.txt deleted file mode 100644 index 5e1ef7f28..000000000 --- a/src/pal/tests/palsuite/threading/GetThreadTimes/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) diff --git a/src/pal/tests/palsuite/threading/GetThreadTimes/test1/CMakeLists.txt b/src/pal/tests/palsuite/threading/GetThreadTimes/test1/CMakeLists.txt deleted file mode 100644 index 23ae7abc5..000000000 --- a/src/pal/tests/palsuite/threading/GetThreadTimes/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_getthreadtimes_test1 - ${SOURCES} -) - -add_dependencies(paltest_getthreadtimes_test1 coreclrpal) - -target_link_libraries(paltest_getthreadtimes_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/GetThreadTimes/test1/test1.cpp b/src/pal/tests/palsuite/threading/GetThreadTimes/test1/test1.cpp deleted file mode 100644 index e57a7d08b..000000000 --- a/src/pal/tests/palsuite/threading/GetThreadTimes/test1/test1.cpp +++ /dev/null @@ -1,102 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source: -** -** Source : test1.c -** -** Purpose: Test for GetThreadTimes() function -** -** -**=========================================================*/ - -#include - -int __cdecl main(int argc, char *argv[]) { - int ret = FAIL; - - //Test is failing unreliably, so for now we always return pass. - if (TRUE){ - ret = PASS; - goto EXIT; - } - { - FILETIME kernelTime1, userTime1, kernelTime2, userTime2; - /* Delta = .01 sec */ - LONG64 Actual, Expected, Delta = 850000000; - Actual = 0; - Expected = 0; - const ULONG64 MSEC_TO_NSEC = 1000000; - - /* - * Initialize the PAL and return FAILURE if this fails - */ - - if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - HANDLE cThread = GetCurrentThread(); - - int i; - /* Take 2000 tiny measurements */ - for (i = 0; i < 2000; i++){ - ULONG64 Time1, Time2; - - Sleep(1); - - /* Grab a FirstCount, then loop for a bit to make the clock increase */ - if (!GetThreadTimes(cThread, NULL, NULL, &kernelTime1, &userTime1)) - { - Fail("ERROR: GetThreadTimes returned failure.\n"); - } - LONG64 x, Init; - /* Init is in milliseconds, so we will convert later */ - Init = (ULONG64)GetTickCount(); - /* Spin for < 1 Quantum so we don't get interrupted */ - x = Init + 3; - volatile int counter; - do { - for (counter = 0; counter < 100000; counter++) - { - // spin to consume CPU time - } - - } while (x > GetTickCount()); - Expected += (GetTickCount() - Init) * MSEC_TO_NSEC; - /* Get a second count */ - if (!GetThreadTimes(cThread, NULL, NULL, &kernelTime2, &userTime2)) - { - Fail("ERROR: GetThreadTimes returned failure.\n"); - } - - Time1 = ((ULONG64)kernelTime1.dwHighDateTime << 32); - Time1 += (ULONG64)kernelTime1.dwLowDateTime; - Time1 += ((ULONG64)userTime1.dwHighDateTime << 32); - Time1 += (ULONG64)userTime1.dwLowDateTime; - - Time2 = ((ULONG64)kernelTime2.dwHighDateTime << 32); - Time2 += (ULONG64)kernelTime2.dwLowDateTime; - Time2 += ((ULONG64)userTime2.dwHighDateTime << 32); - Time2 += (ULONG64)userTime2.dwLowDateTime; - - Actual += (Time2 - Time1) * 100; - } - - if(labs(Expected - Actual) > Delta) - { - Fail("ERROR: The measured time (%llu millisecs) was not within Delta %llu " - "of the expected time (%llu millisecs).\n", - (Actual / MSEC_TO_NSEC), (Delta / MSEC_TO_NSEC), (Expected / MSEC_TO_NSEC)); - } - //printf("%llu, %llu\n", Expected, Actual); - PAL_Terminate(); - ret = PASS; - } -EXIT: - return ret; -} diff --git a/src/pal/tests/palsuite/threading/NamedMutex/CMakeLists.txt b/src/pal/tests/palsuite/threading/NamedMutex/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/threading/NamedMutex/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/threading/NamedMutex/test1/CMakeLists.txt b/src/pal/tests/palsuite/threading/NamedMutex/test1/CMakeLists.txt deleted file mode 100644 index 8e3e75463..000000000 --- a/src/pal/tests/palsuite/threading/NamedMutex/test1/CMakeLists.txt +++ /dev/null @@ -1,18 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - namedmutex.cpp - nopal.cpp -) - -add_executable(paltest_namedmutex_test1 - ${SOURCES} -) - -add_dependencies(paltest_namedmutex_test1 coreclrpal) - -target_link_libraries(paltest_namedmutex_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/NamedMutex/test1/namedmutex.cpp b/src/pal/tests/palsuite/threading/NamedMutex/test1/namedmutex.cpp deleted file mode 100644 index a9d46b3d7..000000000 --- a/src/pal/tests/palsuite/threading/NamedMutex/test1/namedmutex.cpp +++ /dev/null @@ -1,1058 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -// These test cases test named mutexes, including positive -// and negative cases, cross - thread and cross - process, mutual -// exclusion, abandon detection, etc. - -#include - -#ifndef _countof -#define _countof(a) (sizeof(a) / sizeof(a[0])) -#endif // !_countof - -const char *const SessionPrefix = "Local\\"; -const char *const GlobalPrefix = "Global\\"; - -const char *const NamePrefix = "paltest_namedmutex_test1_"; -const char *const TempNamePrefix = "paltest_namedmutex_test1_temp_"; -const char *const InvalidNamePrefix0 = "paltest\\namedmutex_"; -const char *const InvalidNamePrefix1 = "paltest/namedmutex_"; -const char *const ParentEventNamePrefix0 = "paltest_namedmutex_test1_pe0_"; -const char *const ParentEventNamePrefix1 = "paltest_namedmutex_test1_pe1_"; -const char *const ChildEventNamePrefix0 = "paltest_namedmutex_test1_ce0_"; -const char *const ChildEventNamePrefix1 = "paltest_namedmutex_test1_ce1_"; -const char *const ChildRunningEventNamePrefix = "paltest_namedmutex_test1_cr_"; - -const char *const GlobalShmFilePathPrefix = "/tmp/.dotnet/shm/global/"; - -#define MaxPathSize (200) -const DWORD PollLoopSleepMilliseconds = 100; -const DWORD FailTimeoutMilliseconds = 30000; -DWORD g_expectedTimeoutMilliseconds = 500; - -bool g_isParent = true; -bool g_isStress = false; -char g_processPath[4096], g_processCommandLinePath[4096]; -DWORD g_parentPid = static_cast(-1); - -extern char *(*test_strcpy)(char *dest, const char *src); -extern int (*test_strcmp)(const char *s1, const char *s2); -extern size_t (*test_strlen)(const char *s); -extern int (*test_sprintf)(char *str, const char *format, ...); -extern int (*test_sscanf)(const char *str, const char *format, ...); -extern int(*test_close)(int fd); -extern int (*test_unlink)(const char *pathname); -extern unsigned int test_getpid(); -extern int test_kill(unsigned int pid); - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// Test helpers - -extern bool TestFileExists(const char *path); -extern bool WriteHeaderInfo(const char *path, char sharedMemoryType, char version, int *fdRef); - -#define TestAssert(expression) \ - do \ - { \ - if (!(expression)) \ - { \ - if (!g_isParent) \ - { \ - Trace("Child process: "); \ - } \ - Trace("'paltest_namedmutex_test1' failed at line %u. Expression: " #expression "\n", __LINE__); \ - fflush(stdout); \ - return false; \ - } \ - } while(false) - -char *BuildName(const char *testName, char *buffer, const char *prefix0, const char *prefix1 = nullptr) -{ - size_t nameLength = 0; - const char *prefixes[] = {prefix0, prefix1}; - for (int i = 0; i < 2; ++i) - { - const char *prefix = prefixes[i]; - if (prefix == nullptr) - { - break; - } - test_strcpy(&buffer[nameLength], prefix); - nameLength += test_strlen(prefix); - } - - if (g_isStress) - { - // Append the test name so that tests can run in parallel - nameLength += test_sprintf(&buffer[nameLength], "%s", testName); - buffer[nameLength++] = '_'; - } - - nameLength += test_sprintf(&buffer[nameLength], "%u", g_parentPid); - return buffer; -} - -char *BuildGlobalShmFilePath(const char *testName, char *buffer, const char *namePrefix) -{ - size_t pathLength = 0; - test_strcpy(&buffer[pathLength], GlobalShmFilePathPrefix); - pathLength += test_strlen(GlobalShmFilePathPrefix); - test_strcpy(&buffer[pathLength], namePrefix); - pathLength += test_strlen(namePrefix); - - if (g_isStress) - { - // Append the test name so that tests can run in parallel - pathLength += test_sprintf(&buffer[pathLength], "%s", testName); - buffer[pathLength++] = '_'; - } - - pathLength += test_sprintf(&buffer[pathLength], "%u", g_parentPid); - return buffer; -} - -class AutoCloseMutexHandle -{ -private: - HANDLE m_handle; - -public: - AutoCloseMutexHandle(HANDLE handle = nullptr) : m_handle(handle) - { - } - - ~AutoCloseMutexHandle() - { - Close(); - } - -public: - HANDLE GetHandle() const - { - return m_handle; - } - - bool Release() - { - return !!ReleaseMutex(m_handle); - } - - void Close() - { - if (m_handle != nullptr) - { - CloseHandle(m_handle); - m_handle = nullptr; - } - } - - void Abandon() - { - // Don't close the handle - m_handle = nullptr; - } - - AutoCloseMutexHandle &operator =(HANDLE handle) - { - Close(); - m_handle = handle; - return *this; - } - - operator HANDLE() const - { - return m_handle; - } - -private: - AutoCloseMutexHandle(const AutoCloseMutexHandle &other); - AutoCloseMutexHandle(AutoCloseMutexHandle &&other); - AutoCloseMutexHandle &operator =(const AutoCloseMutexHandle &other); -}; - -void TestCreateMutex(AutoCloseMutexHandle &m, const char *name, bool initiallyOwned = false) -{ - m.Close(); - m = CreateMutexA(nullptr, initiallyOwned, name); -} - -HANDLE TestOpenMutex(const char *name) -{ - return OpenMutexA(SYNCHRONIZE, false, name); -} - -bool StartProcess(const char *funcName) -{ - // Command line format: [stress] - - size_t processCommandLinePathLength = 0; - g_processCommandLinePath[processCommandLinePathLength++] = '\"'; - test_strcpy(&g_processCommandLinePath[processCommandLinePathLength], g_processPath); - processCommandLinePathLength += test_strlen(g_processPath); - g_processCommandLinePath[processCommandLinePathLength++] = '\"'; - g_processCommandLinePath[processCommandLinePathLength++] = ' '; - processCommandLinePathLength += test_sprintf(&g_processCommandLinePath[processCommandLinePathLength], "%u", g_parentPid); - g_processCommandLinePath[processCommandLinePathLength++] = ' '; - test_strcpy(&g_processCommandLinePath[processCommandLinePathLength], funcName); - processCommandLinePathLength += test_strlen(funcName); - - if (g_isStress) - { - test_strcpy(&g_processCommandLinePath[processCommandLinePathLength], " stress"); - processCommandLinePathLength += _countof("stress") - 1; - } - - STARTUPINFO si; - memset(&si, 0, sizeof(si)); - si.cb = sizeof(si); - PROCESS_INFORMATION pi; - memset(&pi, 0, sizeof(pi)); - if (!CreateProcessA(nullptr, g_processCommandLinePath, nullptr, nullptr, false, 0, nullptr, nullptr, &si, &pi)) - { - return false; - } - CloseHandle(pi.hProcess); - CloseHandle(pi.hThread); - return true; -} - -bool StartThread(LPTHREAD_START_ROUTINE func, void *arg = nullptr, HANDLE *threadHandleRef = nullptr) -{ - DWORD threadId; - HANDLE handle = CreateThread(nullptr, 0, func, arg, 0, &threadId); - if (handle != nullptr) - { - if (threadHandleRef == nullptr) - { - CloseHandle(handle); - } - else - { - *threadHandleRef = handle; - } - return true; - } - return false; -} - -bool WaitForMutexToBeCreated(const char *testName, AutoCloseMutexHandle &m, const char *eventNamePrefix) -{ - char eventName[MaxPathSize]; - BuildName(testName, eventName, GlobalPrefix, eventNamePrefix); - DWORD startTime = GetTickCount(); - while (true) - { - m = TestOpenMutex(eventName); - if (m != nullptr) - { - return true; - } - if (GetTickCount() - startTime >= FailTimeoutMilliseconds) - { - return false; - } - Sleep(PollLoopSleepMilliseconds); - } -} - -// The following functions are used for parent/child tests, where the child runs in a separate thread or process. The tests are -// organized such that one the parent or child is ever running code, and they yield control and wait for the other. Since the -// named mutex is the only type of cross-process sync object available, they are used as events to synchronize. The parent and -// child have a pair of event mutexes each, which they own initially. To release the other waiting thread/process, the -// thread/process releases one of its mutexes, which the other thread/process would be waiting on. To wait, the thread/process -// waits on one of the other thread/process' mutexes. All the while, they ping-pong between the two mutexes. YieldToChild() and -// YieldToParent() below control the releasing, waiting, and ping-ponging, to help create a deterministic path through the -// parent and child tests while both are running concurrently. - -bool AcquireChildRunningEvent(const char *testName, AutoCloseMutexHandle &childRunningEvent) -{ - char name[MaxPathSize]; - TestCreateMutex(childRunningEvent, BuildName(testName, name, GlobalPrefix, ChildRunningEventNamePrefix)); - TestAssert(WaitForSingleObject(childRunningEvent, FailTimeoutMilliseconds) == WAIT_OBJECT_0); - return true; -} - -bool InitializeParent(const char *testName, AutoCloseMutexHandle parentEvents[2], AutoCloseMutexHandle childEvents[2]) -{ - // Create parent events - char name[MaxPathSize]; - for (int i = 0; i < 2; ++i) - { - TestCreateMutex( - parentEvents[i], - BuildName(testName, name, GlobalPrefix, i == 0 ? ParentEventNamePrefix0 : ParentEventNamePrefix1), - true); - TestAssert(parentEvents[i] != nullptr); - TestAssert(GetLastError() != ERROR_ALREADY_EXISTS); - } - - // Wait for the child to create and acquire locks on its events so that the parent can wait on them - TestAssert(WaitForMutexToBeCreated(testName, childEvents[0], ChildEventNamePrefix0)); - TestAssert(WaitForMutexToBeCreated(testName, childEvents[1], ChildEventNamePrefix1)); - return true; -} - -bool UninitializeParent(const char *testName, AutoCloseMutexHandle parentEvents[2], bool releaseParentEvents = true) -{ - if (releaseParentEvents) - { - TestAssert(parentEvents[0].Release()); - TestAssert(parentEvents[1].Release()); - } - - // Wait for the child to finish its test. Child tests will release and close 'childEvents' before releasing - // 'childRunningEvent', so after this wait, the parent process can freely start another child that will deterministically - // recreate the 'childEvents', which the next parent test will wait on, upon its initialization. - AutoCloseMutexHandle childRunningEvent; - TestAssert(AcquireChildRunningEvent(testName, childRunningEvent)); - TestAssert(childRunningEvent.Release()); - return true; -} - -bool InitializeChild( - const char *testName, - AutoCloseMutexHandle &childRunningEvent, - AutoCloseMutexHandle parentEvents[2], - AutoCloseMutexHandle childEvents[2]) -{ - TestAssert(AcquireChildRunningEvent(testName, childRunningEvent)); - - // Create child events - char name[MaxPathSize]; - for (int i = 0; i < 2; ++i) - { - TestCreateMutex( - childEvents[i], - BuildName(testName, name, GlobalPrefix, i == 0 ? ChildEventNamePrefix0 : ChildEventNamePrefix1), - true); - TestAssert(childEvents[i] != nullptr); - TestAssert(GetLastError() != ERROR_ALREADY_EXISTS); - } - - // Wait for the parent to create and acquire locks on its events so that the child can wait on them - TestAssert(WaitForMutexToBeCreated(testName, parentEvents[0], ParentEventNamePrefix0)); - TestAssert(WaitForMutexToBeCreated(testName, parentEvents[1], ParentEventNamePrefix1)); - - // Parent/child tests start with the parent, so after initialization, wait for the parent to tell the child test to start - TestAssert(WaitForSingleObject(parentEvents[0], FailTimeoutMilliseconds) == WAIT_OBJECT_0); - TestAssert(parentEvents[0].Release()); - return true; -} - -bool UninitializeChild( - AutoCloseMutexHandle &childRunningEvent, - AutoCloseMutexHandle parentEvents[2], - AutoCloseMutexHandle childEvents[2]) -{ - // Release and close 'parentEvents' and 'childEvents' before releasing 'childRunningEvent' to avoid races, see - // UnitializeParent() for more info - TestAssert(childEvents[0].Release()); - TestAssert(childEvents[1].Release()); - childEvents[0].Close(); - childEvents[1].Close(); - parentEvents[0].Close(); - parentEvents[1].Close(); - TestAssert(childRunningEvent.Release()); - return true; -} - -bool YieldToChild(AutoCloseMutexHandle parentEvents[2], AutoCloseMutexHandle childEvents[2], int &ei) -{ - TestAssert(parentEvents[ei].Release()); - TestAssert(WaitForSingleObject(childEvents[ei], FailTimeoutMilliseconds) == WAIT_OBJECT_0); - TestAssert(childEvents[ei].Release()); - TestAssert(WaitForSingleObject(parentEvents[ei], 0) == WAIT_OBJECT_0); - ei = 1 - ei; - return true; -} - -bool YieldToParent(AutoCloseMutexHandle parentEvents[2], AutoCloseMutexHandle childEvents[2], int &ei) -{ - TestAssert(childEvents[ei].Release()); - ei = 1 - ei; - TestAssert(WaitForSingleObject(parentEvents[ei], FailTimeoutMilliseconds) == WAIT_OBJECT_0); - TestAssert(parentEvents[ei].Release()); - TestAssert(WaitForSingleObject(childEvents[1 - ei], 0) == WAIT_OBJECT_0); - return true; -} - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// Tests - -bool NameTests() -{ - const char *testName = "NameTests"; - - AutoCloseMutexHandle m; - char name[MaxPathSize]; - - // Empty name - TestCreateMutex(m, ""); - TestAssert(m != nullptr); - - // Normal name - TestCreateMutex(m, BuildName(testName, name, NamePrefix)); - TestAssert(m != nullptr); - TestAssert(AutoCloseMutexHandle(TestOpenMutex(BuildName(testName, name, NamePrefix))) != nullptr); - TestCreateMutex(m, BuildName(testName, name, SessionPrefix, NamePrefix)); - TestAssert(m != nullptr); - TestAssert(AutoCloseMutexHandle(TestOpenMutex(BuildName(testName, name, SessionPrefix, NamePrefix))) != nullptr); - TestCreateMutex(m, BuildName(testName, name, GlobalPrefix, NamePrefix)); - TestAssert(m != nullptr); - TestAssert(AutoCloseMutexHandle(TestOpenMutex(BuildName(testName, name, GlobalPrefix, NamePrefix))) != nullptr); - - // Name too long. The maximum allowed length depends on the file system, so we're not checking for that. - { - char name[257]; - memset(name, 'a', _countof(name) - 1); - name[_countof(name) - 1] = '\0'; - TestCreateMutex(m, name); - TestAssert(m == nullptr); - TestAssert(GetLastError() == ERROR_FILENAME_EXCED_RANGE); - TestAssert(AutoCloseMutexHandle(TestOpenMutex(name)) == nullptr); - TestAssert(GetLastError() == ERROR_FILENAME_EXCED_RANGE); - } - - // Invalid characters in name - TestCreateMutex(m, BuildName(testName, name, InvalidNamePrefix0)); - TestAssert(m == nullptr); - TestAssert(GetLastError() == ERROR_INVALID_NAME); - TestAssert(AutoCloseMutexHandle(TestOpenMutex(BuildName(testName, name, InvalidNamePrefix0))) == nullptr); - TestAssert(GetLastError() == ERROR_INVALID_NAME); - TestCreateMutex(m, BuildName(testName, name, InvalidNamePrefix1)); - TestAssert(m == nullptr); - TestAssert(GetLastError() == ERROR_INVALID_NAME); - TestAssert(AutoCloseMutexHandle(TestOpenMutex(BuildName(testName, name, InvalidNamePrefix1))) == nullptr); - TestAssert(GetLastError() == ERROR_INVALID_NAME); - TestCreateMutex(m, BuildName(testName, name, SessionPrefix, InvalidNamePrefix0)); - TestAssert(m == nullptr); - TestAssert(GetLastError() == ERROR_INVALID_NAME); - TestAssert(AutoCloseMutexHandle(TestOpenMutex(BuildName(testName, name, SessionPrefix, InvalidNamePrefix0))) == nullptr); - TestAssert(GetLastError() == ERROR_INVALID_NAME); - TestCreateMutex(m, BuildName(testName, name, GlobalPrefix, InvalidNamePrefix1)); - TestAssert(m == nullptr); - TestAssert(GetLastError() == ERROR_INVALID_NAME); - TestAssert(AutoCloseMutexHandle(TestOpenMutex(BuildName(testName, name, GlobalPrefix, InvalidNamePrefix1))) == nullptr); - TestAssert(GetLastError() == ERROR_INVALID_NAME); - - // Creating a second reference to the same named mutex yields an error indicating that it was opened, not created - { - TestCreateMutex(m, BuildName(testName, name, NamePrefix)); - TestAssert(m != nullptr); - AutoCloseMutexHandle m2; - TestCreateMutex(m2, BuildName(testName, name, NamePrefix)); - TestAssert(m2 != nullptr); - TestAssert(GetLastError() == ERROR_ALREADY_EXISTS); - } - - return true; -} - -bool HeaderMismatchTests() -{ - const char *testName = "HeaderMismatchTests"; - - AutoCloseMutexHandle m, m2; - char name[MaxPathSize]; - int fd; - - // Create and hold onto a mutex during this test to create the shared memory directory - TestCreateMutex(m2, BuildName(testName, name, GlobalPrefix, TempNamePrefix)); - TestAssert(m2 != nullptr); - - // Unknown shared memory type - TestAssert(WriteHeaderInfo(BuildGlobalShmFilePath(testName, name, NamePrefix), -1, 1, &fd)); - TestCreateMutex(m, BuildName(testName, name, GlobalPrefix, NamePrefix)); - TestAssert(m == nullptr); - TestAssert(GetLastError() == ERROR_INVALID_HANDLE); - TestAssert(test_close(fd) == 0); - TestAssert(test_unlink(BuildGlobalShmFilePath(testName, name, NamePrefix)) == 0); - - // Mismatched version - TestAssert(WriteHeaderInfo(BuildGlobalShmFilePath(testName, name, NamePrefix), 0, -1, &fd)); - TestCreateMutex(m, BuildName(testName, name, GlobalPrefix, NamePrefix)); - TestAssert(m == nullptr); - TestAssert(GetLastError() == ERROR_INVALID_HANDLE); - TestAssert(test_close(fd) == 0); - TestAssert(test_unlink(BuildGlobalShmFilePath(testName, name, NamePrefix)) == 0); - - return true; -} - -bool MutualExclusionTests_Parent() -{ - const char *testName = "MutualExclusionTests"; - - AutoCloseMutexHandle parentEvents[2], childEvents[2]; - TestAssert(InitializeParent(testName, parentEvents, childEvents)); - int ei = 0; - char name[MaxPathSize]; - AutoCloseMutexHandle m; - - TestCreateMutex(m, BuildName(testName, name, GlobalPrefix, NamePrefix)); - TestAssert(m != nullptr); - - // Recursive locking with various timeouts - TestAssert(WaitForSingleObject(m, 0) == WAIT_OBJECT_0); - TestAssert(WaitForSingleObject(m, FailTimeoutMilliseconds) == WAIT_OBJECT_0); - TestAssert(WaitForSingleObject(m, static_cast(-1)) == WAIT_OBJECT_0); - TestAssert(m.Release()); - TestAssert(m.Release()); - TestAssert(m.Release()); - TestAssert(!m.Release()); // try to release the lock while nobody owns it, and verify recursive lock counting - TestAssert(GetLastError() == ERROR_NOT_OWNER); - - TestAssert(YieldToChild(parentEvents, childEvents, ei)); // child takes the lock - - TestAssert(WaitForSingleObject(m, 0) == WAIT_TIMEOUT); // try to lock the mutex without waiting - TestAssert(WaitForSingleObject(m, g_expectedTimeoutMilliseconds) == WAIT_TIMEOUT); // try to lock the mutex with a timeout - TestAssert(!m.Release()); // try to release the lock while another thread owns it - TestAssert(GetLastError() == ERROR_NOT_OWNER); - - TestAssert(YieldToChild(parentEvents, childEvents, ei)); // child releases the lock - - TestAssert(WaitForSingleObject(m, static_cast(-1)) == WAIT_OBJECT_0); // lock the mutex with no timeout and release - TestAssert(m.Release()); - - UninitializeParent(testName, parentEvents); - return true; -} - -DWORD PALAPI MutualExclusionTests_Child(void *arg = nullptr) -{ - const char *testName = "MutualExclusionTests"; - - AutoCloseMutexHandle childRunningEvent, parentEvents[2], childEvents[2]; - TestAssert(InitializeChild(testName, childRunningEvent, parentEvents, childEvents)); - int ei = 0; - - { - char name[MaxPathSize]; - AutoCloseMutexHandle m; - - TestCreateMutex(m, BuildName(testName, name, GlobalPrefix, NamePrefix)); - TestAssert(m != nullptr); - TestAssert(WaitForSingleObject(m, 0) == WAIT_OBJECT_0); // lock the mutex - YieldToParent(parentEvents, childEvents, ei); // parent attempts to lock/release, and fails - TestAssert(m.Release()); // release the lock - } - - UninitializeChild(childRunningEvent, parentEvents, childEvents); - return 0; -} - -bool MutualExclusionTests() -{ - const char *testName = "MutualExclusionTests"; - - { - AutoCloseMutexHandle m; - char name[MaxPathSize]; - - // Releasing a lock that is not owned by any thread fails - TestCreateMutex(m, BuildName(testName, name, NamePrefix)); - TestAssert(m != nullptr); - TestAssert(!m.Release()); - TestAssert(GetLastError() == ERROR_NOT_OWNER); - - // Acquire a lock during upon creation, and release - TestCreateMutex(m, BuildName(testName, name, NamePrefix), true); - TestAssert(m != nullptr); - TestAssert(m.Release()); - - // Multi-waits including a named mutex are not supported - AutoCloseMutexHandle m2; - TestCreateMutex(m2, nullptr); - TestAssert(m2 != nullptr); - HANDLE waitHandles[] = {m2.GetHandle(), m.GetHandle()}; - TestAssert( - WaitForMultipleObjects( - _countof(waitHandles), - waitHandles, - false /* waitAll */, - FailTimeoutMilliseconds) == - WAIT_FAILED); - TestAssert(GetLastError() == ERROR_NOT_SUPPORTED); - TestAssert( - WaitForMultipleObjects( - _countof(waitHandles), - waitHandles, - true /* waitAll */, - FailTimeoutMilliseconds) == - WAIT_FAILED); - TestAssert(GetLastError() == ERROR_NOT_SUPPORTED); - } - - // When another thread or process owns the lock, this process should not be able to acquire a lock, and the converse - TestAssert(StartThread(MutualExclusionTests_Child)); - TestAssert(MutualExclusionTests_Parent()); - TestAssert(StartProcess("MutualExclusionTests_Child")); - TestAssert(MutualExclusionTests_Parent()); - - return true; -} - -bool LifetimeTests_Parent() -{ - const char *testName = "LifetimeTests"; - - AutoCloseMutexHandle parentEvents[2], childEvents[2]; - TestAssert(InitializeParent(testName, parentEvents, childEvents)); - int ei = 0; - char name[MaxPathSize]; - AutoCloseMutexHandle m; - - TestCreateMutex(m, BuildName(testName, name, GlobalPrefix, NamePrefix)); // create first reference to mutex - TestAssert(m != nullptr); - TestAssert(TestFileExists(BuildGlobalShmFilePath(testName, name, NamePrefix))); - TestAssert(YieldToChild(parentEvents, childEvents, ei)); // child creates second reference to mutex using CreateMutex - m.Close(); // close first reference - TestAssert(TestFileExists(BuildGlobalShmFilePath(testName, name, NamePrefix))); - TestAssert(YieldToChild(parentEvents, childEvents, ei)); // child closes second reference - TestAssert(!TestFileExists(BuildGlobalShmFilePath(testName, name, NamePrefix))); - - TestCreateMutex(m, BuildName(testName, name, GlobalPrefix, NamePrefix)); // create first reference to mutex - TestAssert(m != nullptr); - TestAssert(TestFileExists(BuildGlobalShmFilePath(testName, name, NamePrefix))); - TestAssert(YieldToChild(parentEvents, childEvents, ei)); // child creates second reference to mutex using OpenMutex - m.Close(); // close first reference - TestAssert(TestFileExists(BuildGlobalShmFilePath(testName, name, NamePrefix))); - TestAssert(YieldToChild(parentEvents, childEvents, ei)); // child closes second reference - TestAssert(!TestFileExists(BuildGlobalShmFilePath(testName, name, NamePrefix))); - - UninitializeParent(testName, parentEvents); - return true; -} - -DWORD PALAPI LifetimeTests_Child(void *arg = nullptr) -{ - const char *testName = "LifetimeTests"; - - AutoCloseMutexHandle childRunningEvent, parentEvents[2], childEvents[2]; - TestAssert(InitializeChild(testName, childRunningEvent, parentEvents, childEvents)); - int ei = 0; - - { - char name[MaxPathSize]; - AutoCloseMutexHandle m; - - // ... parent creates first reference to mutex - TestCreateMutex(m, BuildName(testName, name, GlobalPrefix, NamePrefix)); // create second reference to mutex using CreateMutex - TestAssert(m != nullptr); - TestAssert(YieldToParent(parentEvents, childEvents, ei)); // parent closes first reference - m.Close(); // close second reference - - TestAssert(YieldToParent(parentEvents, childEvents, ei)); // parent verifies, and creates first reference to mutex again - m = TestOpenMutex(BuildName(testName, name, GlobalPrefix, NamePrefix)); // create second reference to mutex using OpenMutex - TestAssert(m != nullptr); - TestAssert(YieldToParent(parentEvents, childEvents, ei)); // parent closes first reference - m.Close(); // close second reference - - TestAssert(YieldToParent(parentEvents, childEvents, ei)); // parent verifies - } - - UninitializeChild(childRunningEvent, parentEvents, childEvents); - return 0; -} - -bool LifetimeTests() -{ - const char *testName = "LifetimeTests"; - - { - AutoCloseMutexHandle m; - char name[MaxPathSize]; - - // Shm file should be created and deleted - TestCreateMutex(m, BuildName(testName, name, GlobalPrefix, NamePrefix)); - TestAssert(m != nullptr); - TestAssert(TestFileExists(BuildGlobalShmFilePath(testName, name, NamePrefix))); - m.Close(); - TestAssert(!TestFileExists(BuildGlobalShmFilePath(testName, name, NamePrefix))); - } - - // Shm file should not be deleted until last reference is released - TestAssert(StartThread(LifetimeTests_Child)); - TestAssert(LifetimeTests_Parent()); - TestAssert(StartProcess("LifetimeTests_Child")); - TestAssert(LifetimeTests_Parent()); - - return true; -} - -DWORD PALAPI AbandonTests_Child_TryLock(void *arg = nullptr); - -bool AbandonTests_Parent() -{ - const char *testName = "AbandonTests"; - - char name[MaxPathSize]; - AutoCloseMutexHandle m; - { - AutoCloseMutexHandle parentEvents[2], childEvents[2]; - TestAssert(InitializeParent(testName, parentEvents, childEvents)); - int ei = 0; - - TestCreateMutex(m, BuildName(testName, name, GlobalPrefix, NamePrefix)); - TestAssert(m != nullptr); - TestAssert(YieldToChild(parentEvents, childEvents, ei)); // child locks mutex - TestAssert(parentEvents[0].Release()); - TestAssert(parentEvents[1].Release()); // child sleeps for short duration and abandons the mutex - TestAssert(WaitForSingleObject(m, FailTimeoutMilliseconds) == WAIT_ABANDONED_0); // attempt to lock and see abandoned mutex - - UninitializeParent(testName, parentEvents, false /* releaseParentEvents */); // parent events are released above - } - - // Verify that the mutex lock is owned by this thread, by starting a new thread and trying to lock it - StartThread(AbandonTests_Child_TryLock); - { - AutoCloseMutexHandle parentEvents[2], childEvents[2]; - TestAssert(InitializeParent(testName, parentEvents, childEvents)); - int ei = 0; - - TestAssert(YieldToChild(parentEvents, childEvents, ei)); // child tries to lock mutex - - UninitializeParent(testName, parentEvents); - } - - // Verify that the mutex lock is owned by this thread, by starting a new process and trying to lock it - StartProcess("AbandonTests_Child_TryLock"); - AutoCloseMutexHandle parentEvents[2], childEvents[2]; - TestAssert(InitializeParent(testName, parentEvents, childEvents)); - int ei = 0; - - TestAssert(YieldToChild(parentEvents, childEvents, ei)); // child tries to lock mutex - - // Continue verification - TestAssert(m.Release()); - TestAssert(WaitForSingleObject(m, FailTimeoutMilliseconds) == WAIT_OBJECT_0); // lock again to see it's not abandoned anymore - TestAssert(m.Release()); - - UninitializeParent(testName, parentEvents, false /* releaseParentEvents */); // parent events are released above - - // Since the child abandons the mutex, and a child process may not release the file lock on the shared memory file before - // indicating completion to the parent, make sure to delete the shared memory file by repeatedly opening/closing the mutex - // until the parent process becomes the last process to reference the mutex and closing it deletes the file. - DWORD startTime = GetTickCount(); - while (true) - { - m.Close(); - if (!TestFileExists(BuildGlobalShmFilePath(testName, name, NamePrefix))) - { - break; - } - - TestAssert(GetTickCount() - startTime < FailTimeoutMilliseconds); - m = TestOpenMutex(BuildName(testName, name, GlobalPrefix, NamePrefix)); - } - - return true; -} - -DWORD PALAPI AbandonTests_Child_GracefulExit_Close(void *arg = nullptr) -{ - const char *testName = "AbandonTests"; - - AutoCloseMutexHandle childRunningEvent, parentEvents[2], childEvents[2]; - TestAssert(InitializeChild(testName, childRunningEvent, parentEvents, childEvents)); - int ei = 0; - - { - char name[MaxPathSize]; - AutoCloseMutexHandle m; - - // ... parent waits for child to lock mutex - TestCreateMutex(m, BuildName(testName, name, GlobalPrefix, NamePrefix)); - TestAssert(m != nullptr); - TestAssert(WaitForSingleObject(m, 0) == WAIT_OBJECT_0); - TestAssert(YieldToParent(parentEvents, childEvents, ei)); // parent waits on mutex - Sleep(g_expectedTimeoutMilliseconds); // wait for parent to wait on mutex - m.Close(); // close mutex without releasing lock - } - - UninitializeChild(childRunningEvent, parentEvents, childEvents); - return 0; -} - -DWORD AbandonTests_Child_GracefulExit_NoClose(void *arg = nullptr) -{ - const char *testName = "AbandonTests"; - - // This test needs to run in a separate process because it does not close the mutex handle. Running it in a separate thread - // causes the mutex object to retain a reference until the process terminates. - TestAssert(test_getpid() != g_parentPid); - - AutoCloseMutexHandle childRunningEvent, parentEvents[2], childEvents[2]; - TestAssert(InitializeChild(testName, childRunningEvent, parentEvents, childEvents)); - int ei = 0; - - { - char name[MaxPathSize]; - AutoCloseMutexHandle m; - - // ... parent waits for child to lock mutex - TestCreateMutex(m, BuildName(testName, name, GlobalPrefix, NamePrefix)); - TestAssert(m != nullptr); - TestAssert(WaitForSingleObject(m, 0) == WAIT_OBJECT_0); - TestAssert(YieldToParent(parentEvents, childEvents, ei)); // parent waits on mutex - Sleep(g_expectedTimeoutMilliseconds); // wait for parent to wait on mutex - m.Abandon(); // don't close the mutex - } - - UninitializeChild(childRunningEvent, parentEvents, childEvents); - return 0; -} - -DWORD AbandonTests_Child_AbruptExit(void *arg = nullptr) -{ - const char *testName = "AbandonTests"; - - DWORD currentPid = test_getpid(); - TestAssert(currentPid != g_parentPid); // this test needs to run in a separate process - - { - AutoCloseMutexHandle childRunningEvent, parentEvents[2], childEvents[2]; - TestAssert(InitializeChild(testName, childRunningEvent, parentEvents, childEvents)); - int ei = 0; - - { - char name[MaxPathSize]; - AutoCloseMutexHandle m; - - // ... parent waits for child to lock mutex - TestCreateMutex(m, BuildName(testName, name, GlobalPrefix, NamePrefix)); - TestAssert(m != nullptr); - TestAssert(WaitForSingleObject(m, 0) == WAIT_OBJECT_0); - TestAssert(YieldToParent(parentEvents, childEvents, ei)); // parent waits on mutex - Sleep(g_expectedTimeoutMilliseconds); // wait for parent to wait on mutex - m.Abandon(); // don't close the mutex - } - - UninitializeChild(childRunningEvent, parentEvents, childEvents); - } - - TestAssert(test_kill(currentPid) == 0); // abandon the mutex abruptly - return 0; -} - -DWORD PALAPI AbandonTests_Child_TryLock(void *arg) -{ - const char *testName = "AbandonTests"; - - AutoCloseMutexHandle childRunningEvent, parentEvents[2], childEvents[2]; - TestAssert(InitializeChild(testName, childRunningEvent, parentEvents, childEvents)); - int ei = 0; - - { - char name[MaxPathSize]; - AutoCloseMutexHandle m; - - // ... parent waits for child to lock mutex - TestCreateMutex(m, BuildName(testName, name, GlobalPrefix, NamePrefix)); - TestAssert(m != nullptr); - TestAssert(WaitForSingleObject(m, 0) == WAIT_TIMEOUT); // try to lock the mutex while the parent holds the lock - TestAssert(WaitForSingleObject(m, g_expectedTimeoutMilliseconds) == WAIT_TIMEOUT); - } - - UninitializeChild(childRunningEvent, parentEvents, childEvents); - return 0; -} - -bool AbandonTests() -{ - const char *testName = "AbandonTests"; - - // Abandon by graceful exit where the lock owner closes the mutex before releasing it, unblocks a waiter - TestAssert(StartThread(AbandonTests_Child_GracefulExit_Close)); - TestAssert(AbandonTests_Parent()); - TestAssert(StartProcess("AbandonTests_Child_GracefulExit_Close")); - TestAssert(AbandonTests_Parent()); - - // Abandon by graceful exit without closing the mutex unblocks a waiter - TestAssert(StartProcess("AbandonTests_Child_GracefulExit_NoClose")); - TestAssert(AbandonTests_Parent()); - - // Abandon by abrupt exit unblocks a waiter - TestAssert(StartProcess("AbandonTests_Child_AbruptExit")); - TestAssert(AbandonTests_Parent()); - - return true; -} - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// Test harness - -bool (*const (TestList[]))() = -{ - NameTests, - HeaderMismatchTests, - MutualExclusionTests, - LifetimeTests, - AbandonTests -}; - -bool RunTests() -{ - bool allPassed = true; - for (SIZE_T i = 0; i < _countof(TestList); ++i) - { - if (!TestList[i]()) - { - allPassed = false; - } - } - return allPassed; -} - -DWORD g_stressDurationMilliseconds = 0; -LONG g_stressTestCounts[_countof(TestList)] = {0}; -LONG g_stressResult = true; - -DWORD PALAPI StressTest(void *arg) -{ - // Run the specified test continuously for the stress duration - SIZE_T testIndex = reinterpret_cast(arg); - DWORD startTime = GetTickCount(); - do - { - ++g_stressTestCounts[testIndex]; - if (!TestList[testIndex]()) - { - InterlockedExchange(&g_stressResult, false); - break; - } - } while ( - InterlockedCompareExchange(&g_stressResult, false, false) == true && - GetTickCount() - startTime < g_stressDurationMilliseconds); - return 0; -} - -bool StressTests(DWORD durationMinutes) -{ - g_isStress = true; - g_expectedTimeoutMilliseconds = 1; - g_stressDurationMilliseconds = durationMinutes * (60 * 1000); - - // Start a thread for each test - HANDLE threadHandles[_countof(TestList)]; - for (SIZE_T i = 0; i < _countof(threadHandles); ++i) - { - TestAssert(StartThread(StressTest, reinterpret_cast(i), &threadHandles[i])); - } - - while (true) - { - DWORD waitResult = - WaitForMultipleObjects(_countof(threadHandles), threadHandles, true /* bWaitAll */, 10 * 1000 /* dwMilliseconds */); - TestAssert(waitResult == WAIT_OBJECT_0 || waitResult == WAIT_TIMEOUT); - if (waitResult == WAIT_OBJECT_0) - { - break; - } - - Trace("'paltest_namedmutex_test1' stress test counts: "); - for (SIZE_T i = 0; i < _countof(g_stressTestCounts); ++i) - { - if (i != 0) - { - Trace(", "); - } - Trace("%u", g_stressTestCounts[i]); - } - Trace("\n"); - fflush(stdout); - } - - for (SIZE_T i = 0; i < _countof(threadHandles); ++i) - { - CloseHandle(threadHandles[i]); - } - return static_cast(g_stressResult); -} - -int __cdecl main(int argc, char **argv) -{ - if (argc < 1 || argc > 4) - { - return FAIL; - } - - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - test_strcpy(g_processPath, argv[0]); - - if (argc == 1) - { - // Unit test arguments: - - g_parentPid = test_getpid(); - int result = RunTests() ? PASS : FAIL; - ExitProcess(result); - return result; - } - - if (test_strcmp(argv[1], "stress") == 0) - { - // Stress test arguments: stress [durationMinutes] - - DWORD durationMinutes = 1; - if (argc >= 3 && test_sscanf(argv[2], "%u", &durationMinutes) != 1) - { - ExitProcess(FAIL); - return FAIL; - } - - g_parentPid = test_getpid(); - int result = StressTests(durationMinutes) ? PASS : FAIL; - ExitProcess(result); - return result; - } - - // Child test process arguments: [stress] - - g_isParent = false; - - // Get parent process' ID from argument - if (test_sscanf(argv[1], "%u", &g_parentPid) != 1) - { - ExitProcess(FAIL); - return FAIL; - } - - if (argc >= 4 && test_strcmp(argv[3], "stress") == 0) - { - g_isStress = true; - } - - if (test_strcmp(argv[2], "MutualExclusionTests_Child") == 0) - { - MutualExclusionTests_Child(); - } - else if (test_strcmp(argv[2], "LifetimeTests_Child") == 0) - { - LifetimeTests_Child(); - } - else if (test_strcmp(argv[2], "AbandonTests_Child_GracefulExit_Close") == 0) - { - AbandonTests_Child_GracefulExit_Close(); - } - else if (test_strcmp(argv[2], "AbandonTests_Child_GracefulExit_NoClose") == 0) - { - AbandonTests_Child_GracefulExit_NoClose(); - } - else if (test_strcmp(argv[2], "AbandonTests_Child_AbruptExit") == 0) - { - AbandonTests_Child_AbruptExit(); - } - else if (test_strcmp(argv[2], "AbandonTests_Child_TryLock") == 0) - { - AbandonTests_Child_TryLock(); - } - ExitProcess(PASS); - return PASS; -} diff --git a/src/pal/tests/palsuite/threading/NamedMutex/test1/nopal.cpp b/src/pal/tests/palsuite/threading/NamedMutex/test1/nopal.cpp deleted file mode 100644 index ae3ebc361..000000000 --- a/src/pal/tests/palsuite/threading/NamedMutex/test1/nopal.cpp +++ /dev/null @@ -1,66 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -// Contains wrappers for functions whose required headers conflict with the PAL - -#include -#include -#include - -#include -#include -#include -#include -#include - -#define _countof(a) (sizeof(a) / sizeof(a[0])) - -#undef PAGE_SIZE -#define PAGE_SIZE (4096) - -auto test_strcpy = strcpy; -auto test_strcmp = strcmp; -auto test_strlen = strlen; -auto test_sprintf = sprintf; -auto test_sscanf = sscanf; -auto test_close = close; -auto test_unlink = unlink; - -unsigned int test_getpid() -{ - return getpid(); -} - -int test_kill(unsigned int pid) -{ - return kill(pid, SIGKILL); -} - -bool TestFileExists(const char *path) -{ - int fd = open(path, O_RDWR); - if (fd == -1) - return false; - close(fd); - return true; -} - -bool WriteHeaderInfo(const char *path, char sharedMemoryType, char version, int *fdRef) -{ - int fd = open(path, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH); - if (fd == -1) - return false; - *fdRef = fd; - if (ftruncate(fd, PAGE_SIZE) != 0) - return false; - if (lseek(fd, 0, SEEK_SET) != 0) - return false; - - // See SharedMemorySharedDataHeader for format - char buffer[] = {sharedMemoryType, version}; - if (write(fd, buffer, _countof(buffer)) != _countof(buffer)) - return false; - - return flock(fd, LOCK_SH | LOCK_NB) == 0; -} diff --git a/src/pal/tests/palsuite/threading/NamedMutex/test1/testinfo.dat b/src/pal/tests/palsuite/threading/NamedMutex/test1/testinfo.dat deleted file mode 100644 index e3090093e..000000000 --- a/src/pal/tests/palsuite/threading/NamedMutex/test1/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = threading -Function = Named mutex -Name = Tests for named mutexes -TYPE = DEFAULT -EXE1 = namedmutex -Description -= These test cases test named mutexes, including positive -= and negative cases, cross-thread and cross-process, mutual -= exclusion, abandon detection, etc. diff --git a/src/pal/tests/palsuite/threading/OpenEventW/CMakeLists.txt b/src/pal/tests/palsuite/threading/OpenEventW/CMakeLists.txt deleted file mode 100644 index 8083faf65..000000000 --- a/src/pal/tests/palsuite/threading/OpenEventW/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) -add_subdirectory(test3) -add_subdirectory(test4) -add_subdirectory(test5) - diff --git a/src/pal/tests/palsuite/threading/OpenEventW/test1/CMakeLists.txt b/src/pal/tests/palsuite/threading/OpenEventW/test1/CMakeLists.txt deleted file mode 100644 index e6470c599..000000000 --- a/src/pal/tests/palsuite/threading/OpenEventW/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_openeventw_test1 - ${SOURCES} -) - -add_dependencies(paltest_openeventw_test1 coreclrpal) - -target_link_libraries(paltest_openeventw_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/OpenEventW/test1/test1.cpp b/src/pal/tests/palsuite/threading/OpenEventW/test1/test1.cpp deleted file mode 100644 index 9dcb3a4a6..000000000 --- a/src/pal/tests/palsuite/threading/OpenEventW/test1/test1.cpp +++ /dev/null @@ -1,134 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: Test for OpenEventW. This test creates an event, -** opens a handle to the same event, then waits on both handles -** in both a signalled and non-signalled state to verify they're. -** pointing to the same event object. -** -** -**==========================================================================*/ -#include - -int __cdecl main(int argc, char **argv) -{ - BOOL bRet = FAIL; - DWORD dwRet; - HANDLE hEvent; - HANDLE hOpenEvent; - WCHAR theName[] = {'E','v','e','n','t','\0'}; - LPCWSTR lpName = theName; - - /* PAL initialization */ - if( (PAL_Initialize(argc, argv)) != 0 ) - { - return( FAIL ); - } - - /* Create an event (with a 0 intial state!) and ensure that the - HANDLE is valid - */ - hEvent = CreateEventW( NULL, TRUE, FALSE, lpName ); - if( hEvent == NULL ) - { - Fail( "ERROR:%lu:CreateEvent call failed\n", GetLastError() ); - } - - - /* Call OpenEventW to get another HANDLE on - this event. Ensure the HANDLE is valid. - */ - hOpenEvent = OpenEventW( EVENT_ALL_ACCESS, TRUE, lpName ); - if( hOpenEvent == NULL ) - { - Trace( "ERROR:%lu:OpenEventW call failed\n", GetLastError() ); - goto cleanup2; - } - - /* wait on the original event to verify that it's not signalled */ - dwRet = WaitForSingleObject( hEvent, 0 ); - if( dwRet != WAIT_TIMEOUT ) - { - Trace( "ERROR:WaitForSingleObject returned %lu, " - "expected WAIT_TIMEOUT\n", - dwRet ); - goto cleanup; - } - - /* wait on the opened event to verify that it's not signalled either */ - dwRet = WaitForSingleObject( hOpenEvent, 0 ); - if( dwRet != WAIT_TIMEOUT ) - { - Trace( "ERROR:WaitForSingleObject returned %lu, " - "expected WAIT_TIMEOUT\n", - dwRet ); - goto cleanup; - } - - - /* Set this opened HANDLE */ - if( ! SetEvent( hOpenEvent ) ) - { - Trace( "ERROR:%lu:SetEvent call failed\n", GetLastError() ); - goto cleanup; - } - - /* wait on the original event to verify that it's signalled */ - dwRet = WaitForSingleObject( hEvent, 0 ); - if( dwRet != WAIT_OBJECT_0 ) - { - Trace( "ERROR:WaitForSingleObject returned %lu, " - "expected WAIT_OBJECT_0\n", - dwRet ); - goto cleanup; - } - - /* wait on the opened event to verify that it's signalled too */ - dwRet = WaitForSingleObject( hOpenEvent, 0 ); - if( dwRet != WAIT_OBJECT_0 ) - { - Trace( "ERROR:WaitForSingleObject returned %lu, " - "expected WAIT_OBJECT_0\n", - dwRet ); - goto cleanup; - } - - /* success if we get here */ - bRet = PASS; - -cleanup: - /* close the opened handle */ - if( ! CloseHandle( hOpenEvent ) ) - { - Trace( "ERROR:%lu:CloseHandle call failed\n", GetLastError() ); - bRet = FAIL; - } - -cleanup2: - /* close the original event handle */ - if( ! CloseHandle( hEvent ) ) - { - Trace( "ERROR:%lu:CloseHandle call failed\n", GetLastError() ); - bRet = FAIL; - } - - /* check for failure */ - if( bRet == FAIL ) - { - Fail( "test failed\n" ); - } - - - /* terminate the PAL */ - PAL_Terminate(); - - /* return success */ - return ( PASS ); - -} - diff --git a/src/pal/tests/palsuite/threading/OpenEventW/test1/testinfo.dat b/src/pal/tests/palsuite/threading/OpenEventW/test1/testinfo.dat deleted file mode 100644 index cc9be7104..000000000 --- a/src/pal/tests/palsuite/threading/OpenEventW/test1/testinfo.dat +++ /dev/null @@ -1,15 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = threading -Function = OpenEventW -Name = Positive Test for OpenEventW -TYPE = DEFAULT -EXE1 = test1 -Description -= Purpose: Test for OpenEventW. This test creates an event, -= opens a handle to the same event, then waits on both handles -= in both a signalled and non-signalled state to verify they're -= pointing to the same event object. diff --git a/src/pal/tests/palsuite/threading/OpenEventW/test2/CMakeLists.txt b/src/pal/tests/palsuite/threading/OpenEventW/test2/CMakeLists.txt deleted file mode 100644 index 4fd04737c..000000000 --- a/src/pal/tests/palsuite/threading/OpenEventW/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test2.cpp -) - -add_executable(paltest_openeventw_test2 - ${SOURCES} -) - -add_dependencies(paltest_openeventw_test2 coreclrpal) - -target_link_libraries(paltest_openeventw_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/OpenEventW/test2/test2.cpp b/src/pal/tests/palsuite/threading/OpenEventW/test2/test2.cpp deleted file mode 100644 index 9cbf872b9..000000000 --- a/src/pal/tests/palsuite/threading/OpenEventW/test2/test2.cpp +++ /dev/null @@ -1,194 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================= -** -** Source: test2.c -** -** Purpose: Positive test for OpenEventW. -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** CreateEvent -** CloseHandle -** WaitForSingleObject -** -** Purpose: -** -** Test to ensure proper operation of the OpenEventW() -** API by creating a new named event and verifying that -** it can be used interchangeably by setting the event -** with the original handle and waiting on it with the -** new one, then resetting it with the new one and waiting -** on it with the original one. -** -** -**===========================================================================*/ -#include - - - -int __cdecl main( int argc, char **argv ) - -{ - /* local variables */ - BOOL ret = FAIL; - DWORD dwRet = 0; - HANDLE hEvent = NULL; - HANDLE hTestEvent = NULL; - LPSECURITY_ATTRIBUTES lpEventAttributes = NULL; - BOOL bManualReset = TRUE; - BOOL bInitialState = FALSE; - WCHAR wcName[] = {'W','o','o','B','a','b','y','\0'}; - LPWSTR lpName = wcName; - - - /* PAL initialization */ - if( (PAL_Initialize(argc, argv)) != 0 ) - { - return( FAIL ); - } - - - /* create an event which we can use with SetEvent */ - hEvent = CreateEventW( lpEventAttributes, - bManualReset, - bInitialState, - lpName ); - - if( hEvent == NULL ) - { - /* ERROR */ - Fail( "ERROR:%lu:CreateEvent() call failed\n", GetLastError() ); - } - - /* open a new handle to our event */ - hTestEvent = OpenEventW(EVENT_ALL_ACCESS, /* we want all rights */ - FALSE, /* no inherit */ - lpName ); - - if( hTestEvent == NULL ) - { - /* ERROR */ - Trace( "ERROR:%lu:OpenEventW() call failed\n", GetLastError() ); - goto cleanup; - } - - /* verify that the event isn't signalled yet by waiting on both */ - /* handles to the event object */ - dwRet = WaitForSingleObject( hEvent, 0 ); - if( dwRet != WAIT_TIMEOUT ) - { - /* ERROR */ - Trace( "ERROR:WaitForSingleObject() call returned %lu, " - "expected WAIT_TIMEOUT\n", - dwRet ); - goto cleanup; - } - - dwRet = WaitForSingleObject( hTestEvent, 0 ); - if( dwRet != WAIT_TIMEOUT ) - { - /* ERROR */ - Trace( "ERROR:WaitForSingleObject() call returned %lu, " - "expected WAIT_TIMEOUT\n", - dwRet ); - goto cleanup; - } - - - /* set the event using the original handle */ - if( ! SetEvent( hEvent ) ) - { - /* ERROR */ - Trace( "ERROR:%lu:SetEvent() call failed\n", GetLastError() ); - goto cleanup; - } - - /* verify that the event is signalled by waiting on both handles */ - dwRet = WaitForSingleObject( hEvent, 0 ); - if( dwRet != WAIT_OBJECT_0 ) - { - /* ERROR */ - Trace( "ERROR:WaitForSingleObject() call returned %lu, " - "expected WAIT_OBJECT_0\n", - dwRet ); - goto cleanup; - } - - dwRet = WaitForSingleObject( hTestEvent, 0 ); - if( dwRet != WAIT_OBJECT_0 ) - { - /* ERROR */ - Trace( "ERROR:WaitForSingleObject() call returned %lu, " - "expected WAIT_OBJECT_0\n", - dwRet ); - goto cleanup; - } - - /* reset the event using the new handle */ - if( ! ResetEvent( hTestEvent ) ) - { - /* ERROR */ - Trace( "ERROR:%lu:ResetEvent() call failed\n", GetLastError() ); - goto cleanup; - } - - /* verify that the event isn't signalled by waiting on both handles */ - dwRet = WaitForSingleObject( hEvent, 0 ); - if( dwRet != WAIT_TIMEOUT ) - { - /* ERROR */ - Trace( "ERROR:WaitForSingleObject() call returned %lu, " - "expected WAIT_TIMEOUT\n", - dwRet ); - goto cleanup; - } - - dwRet = WaitForSingleObject( hTestEvent, 0 ); - if( dwRet != WAIT_TIMEOUT ) - { - /* ERROR */ - Trace( "ERROR:WaitForSingleObject() call returned %lu, " - "expected WAIT_TIMEOUT\n", - dwRet ); - goto cleanup; - } - - - /* test was successful */ - ret = PASS; - - -cleanup: - /* close the new event handle */ - if( hTestEvent != NULL ) - { - if( ! CloseHandle( hTestEvent ) ) - { - ret = FAIL; - Trace( "ERROR:%lu:CloseHandle() call failed\n", GetLastError() ); - } - } - - /* close the original event handle */ - if( ! CloseHandle( hEvent ) ) - { - ret = FAIL; - Trace( "ERROR:%lu:CloseHandle() call failed\n", GetLastError() ); - } - - /* failure message */ - if( ret != PASS ) - { - Fail( "Test failed\n" ); - } - - - /* PAL termination */ - PAL_Terminate(); - - /* return success or failure */ - return ret; -} diff --git a/src/pal/tests/palsuite/threading/OpenEventW/test2/testinfo.dat b/src/pal/tests/palsuite/threading/OpenEventW/test2/testinfo.dat deleted file mode 100644 index ad3f22eea..000000000 --- a/src/pal/tests/palsuite/threading/OpenEventW/test2/testinfo.dat +++ /dev/null @@ -1,17 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = threading -Function = OpenEventW -Name = Positive test for OpenEventW -TYPE = DEFAULT -EXE1 = test2 -Description -= Test to ensure proper operation of the OpenEventW() -= API by creating a new named event and verifying that -= it can be used interchangeably by setting the event -= with the original handle and waiting on it with the -= new one, then resetting it with the new one and waiting -= on it with the original one. diff --git a/src/pal/tests/palsuite/threading/OpenEventW/test3/CMakeLists.txt b/src/pal/tests/palsuite/threading/OpenEventW/test3/CMakeLists.txt deleted file mode 100644 index 2ccd175c4..000000000 --- a/src/pal/tests/palsuite/threading/OpenEventW/test3/CMakeLists.txt +++ /dev/null @@ -1,32 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(TESTSOURCES - test3.cpp -) - -add_executable(paltest_openeventw_test3 - ${TESTSOURCES} -) - -add_dependencies(paltest_openeventw_test3 coreclrpal) - -target_link_libraries(paltest_openeventw_test3 - ${COMMON_TEST_LIBRARIES} -) - - -set(HELPERSOURCES - childprocess.cpp -) - -add_executable(paltest_openeventw_test3_child - ${HELPERSOURCES} -) - -add_dependencies(paltest_openeventw_test3_child coreclrpal) - -target_link_libraries(paltest_openeventw_test3_child - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/OpenEventW/test3/childprocess.cpp b/src/pal/tests/palsuite/threading/OpenEventW/test3/childprocess.cpp deleted file mode 100644 index b5149e006..000000000 --- a/src/pal/tests/palsuite/threading/OpenEventW/test3/childprocess.cpp +++ /dev/null @@ -1,81 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source: childprocess.c -** -** Purpose: Test to ensure that OpenEventW() works when -** opening an event created by another process. The test -** program launches this program as a child, which creates -** a named, initially-unset event. The child waits up to -** 10 seconds for the parent process to open that event -** and set it, and returns PASS if the event was set or FAIL -** otherwise. The parent process checks the return value -** from the child to verify that the opened event was -** properly used across processes. -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** CreateEventW -** WaitForSingleObject -** CloseHandle -** -** -**=========================================================*/ - -#include - -int __cdecl main( int argc, char **argv ) -{ - /* local variables */ - HANDLE hEvent = NULL; - WCHAR wcName[] = {'P','A','L','R','o','c','k','s','\0'}; - LPWSTR lpName = wcName; - - int result = PASS; - - /* initialize the PAL */ - if( PAL_Initialize(argc, argv) != 0 ) - { - return( FAIL ); - } - - - /* open a handle to the event created in the child process */ - hEvent = OpenEventW( EVENT_ALL_ACCESS, /* we want all rights */ - FALSE, /* no inherit */ - lpName ); - - if( hEvent == NULL ) - { - /* ERROR */ - Trace( "ERROR:%lu:OpenEventW() call failed\n", GetLastError() ); - result = FAIL; - goto parentwait; - } - - /* set the event -- should take effect in the child process */ - if( ! SetEvent( hEvent ) ) - { - /* ERROR */ - Trace( "ERROR:%lu:SetEvent() call failed\n", GetLastError() ); - result = FAIL; - } - -parentwait: - /* close the event handle */ - if( ! CloseHandle( hEvent ) ) - { - /* ERROR */ - Fail( "ERROR:%lu:CloseHandle() call failed in child\n", - GetLastError()); - } - - /* terminate the PAL */ - PAL_TerminateEx(result); - - /* return success or failure */ - return result; -} diff --git a/src/pal/tests/palsuite/threading/OpenEventW/test3/test3.cpp b/src/pal/tests/palsuite/threading/OpenEventW/test3/test3.cpp deleted file mode 100644 index c4edf22a7..000000000 --- a/src/pal/tests/palsuite/threading/OpenEventW/test3/test3.cpp +++ /dev/null @@ -1,187 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================= -** -** Source: test3.c -** -** Purpose: Test to ensure that OpenEventW() works when -** opening an event created by another process. This test -** program launches a child process which creates a -** named, initially-unset event. The child waits up to -** 10 seconds for the parent process to open that event -** and set it, and returns PASS if the event was set or FAIL -** otherwise. The parent process checks the return value -** from the child to verify that the opened event was -** properly used across processes. -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** Fail -** ZeroMemory -** GetCurrentDirectoryW -** CreateProcessW -** WaitForSingleObject -** GetExitCodeProcess -** GetLastError -** strlen -** strncpy -** -** -**===========================================================================*/ -#include - -#define TIMEOUT 60000 - -int __cdecl main( int argc, char **argv ) -{ - BOOL ret = FAIL; - LPSECURITY_ATTRIBUTES lpEventAttributes = NULL; - - STARTUPINFO si; - PROCESS_INFORMATION pi; - - DWORD dwExitCode; - - DWORD dwRet = 0; - HANDLE hEvent = NULL; - WCHAR wcName[] = {'P','A','L','R','o','c','k','s','\0'}; - LPWSTR lpName = wcName; - char lpCommandLine[MAX_PATH] = ""; - - /* initialize the PAL */ - if( PAL_Initialize(argc, argv) != 0 ) - { - return( FAIL ); - } - - /* zero our process and startup info structures */ - ZeroMemory( &si, sizeof(si) ); - si.cb = sizeof( si ); - ZeroMemory( &pi, sizeof(pi) ); - - /* create an event which we can use with SetEvent */ - hEvent = CreateEventW( lpEventAttributes, - TRUE, /* manual reset */ - FALSE, /* unsignalled */ - lpName ); - - if( hEvent == NULL ) - { - /* ERROR */ - Fail( "ERROR:%lu:CreateEventW() call failed in child\n", - GetLastError()); - } - - ZeroMemory( lpCommandLine, MAX_PATH ); - if ( sprintf_s( lpCommandLine, MAX_PATH-1, "childprocess ") < 0 ) - { - Fail ("Error: Insufficient lpCommandline for\n"); - } - - /* launch the child process */ - if( !CreateProcess( NULL, /* module name to execute */ - lpCommandLine, /* command line */ - NULL, /* process handle not */ - /* inheritable */ - NULL, /* thread handle not */ - /* inheritable */ - FALSE, /* handle inheritance */ - CREATE_NEW_CONSOLE, /* dwCreationFlags */ - NULL, /* use parent's environment */ - NULL, /* use parent's starting */ - /* directory */ - &si, /* startup info struct */ - &pi ) /* process info struct */ - ) - { - Fail( "ERROR:%lu:CreateProcess call failed\n", - GetLastError() ); - } - - /* verify that the event is signalled by the child process */ - dwRet = WaitForSingleObject( hEvent, TIMEOUT ); - if( dwRet != WAIT_OBJECT_0 ) - { - ret = FAIL; - /* ERROR */ - Trace( "ERROR:WaitForSingleObject() call returned %lu, " - "expected WAIT_TIMEOUT\n", - "expected WAIT_OBJECT_0\n", - dwRet ); - - goto cleanup; - - if( !CloseHandle( hEvent ) ) - { - Trace( "ERROR:%lu:CloseHandle() call failed in child\n", - GetLastError()); - } - goto cleanup; - } - - /* wait for the child process to complete */ - dwRet = WaitForSingleObject ( pi.hProcess, TIMEOUT ); - if( dwRet != WAIT_OBJECT_0 ) - { - ret = FAIL; - Trace( "ERROR:WaitForSingleObject() returned %lu, " - "expected %lu\n", - dwRet, - WAIT_OBJECT_0 ); - goto cleanup; - } - - /* check the exit code from the process */ - if( ! GetExitCodeProcess( pi.hProcess, &dwExitCode ) ) - { - ret = FAIL; - Trace( "ERROR:%lu:GetExitCodeProcess call failed\n", - GetLastError() ); - goto cleanup; - } - - /* check for success */ - ret = (dwExitCode == PASS) ? PASS : FAIL; - -cleanup: - if( hEvent != NULL ) - { - if( ! CloseHandle ( hEvent ) ) - { - Trace( "ERROR:%lu:CloseHandle call failed on event handle\n", - GetLastError() ); - ret = FAIL; - } - } - - - /* close process and thread handle */ - if( ! CloseHandle ( pi.hProcess ) ) - { - Trace( "ERROR:%lu:CloseHandle call failed on process handle\n", - GetLastError() ); - ret = FAIL; - } - - if( ! CloseHandle ( pi.hThread ) ) - { - Trace( "ERROR:%lu:CloseHandle call failed on thread handle\n", - GetLastError() ); - ret = FAIL; - } - - /* output a convenient error message and exit if we failed */ - if( ret == FAIL ) - { - Fail( "test failed\n" ); - } - - - /* terminate the PAL */ - PAL_Terminate(); - - /* return success */ - return ret; -} diff --git a/src/pal/tests/palsuite/threading/OpenEventW/test3/testinfo.dat b/src/pal/tests/palsuite/threading/OpenEventW/test3/testinfo.dat deleted file mode 100644 index 96b2c0664..000000000 --- a/src/pal/tests/palsuite/threading/OpenEventW/test3/testinfo.dat +++ /dev/null @@ -1,21 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = threading -Function = OpenEventW -Name = Test for OpenEventW -TYPE = DEFAULT -EXE1 = test3 -EXE2 = childprocess -Description -= Purpose: Test to ensure that OpenEventW() works when -= opening an event created by another process. This test -= program launches a child process which creates a -= named, initially-unset event. The child waits up to -= 10 seconds for the parent process to open that event -= and set it, and returns PASS if the event was set or FAIL -= otherwise. The parent process checks the return value -= from the child to verify that the opened event was -= properly used across processes. diff --git a/src/pal/tests/palsuite/threading/OpenEventW/test4/CMakeLists.txt b/src/pal/tests/palsuite/threading/OpenEventW/test4/CMakeLists.txt deleted file mode 100644 index dbf3a276b..000000000 --- a/src/pal/tests/palsuite/threading/OpenEventW/test4/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test4.cpp -) - -add_executable(paltest_openeventw_test4 - ${SOURCES} -) - -add_dependencies(paltest_openeventw_test4 coreclrpal) - -target_link_libraries(paltest_openeventw_test4 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/OpenEventW/test4/test4.cpp b/src/pal/tests/palsuite/threading/OpenEventW/test4/test4.cpp deleted file mode 100644 index ae657a051..000000000 --- a/src/pal/tests/palsuite/threading/OpenEventW/test4/test4.cpp +++ /dev/null @@ -1,112 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================= -** -** Source: test4.c -** -** Purpose: Positive test for OpenEventW. -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** CreateEvent -** CloseHandle -** WaitForSingleObject -** -** Purpose: -** -** Test to ensure proper operation of the OpenEventW() -** API by trying to open an event with a name that is -** already taken by a non-event object. -** -** -**===========================================================================*/ -#include - - - -int __cdecl main( int argc, char **argv ) - -{ - /* local variables */ - BOOL bRet = PASS; - DWORD dwLastError = 0; - HANDLE hMutex = NULL; - HANDLE hTestEvent = NULL; - LPSECURITY_ATTRIBUTES lpSecurityAttributes = NULL; - BOOL bInitialState = TRUE; - WCHAR wcName[] = {'I','m','A','M','u','t','e','x','\0'}; - LPWSTR lpName = wcName; - - - /* PAL initialization */ - if( (PAL_Initialize(argc, argv)) != 0 ) - { - return( FAIL ); - } - - /* create a mutex object */ - hMutex = CreateMutexW( lpSecurityAttributes, - bInitialState, - lpName ); - - if( hMutex == NULL ) - { - /* ERROR */ - Fail( "ERROR:%lu:CreateMutexW() call failed\n", GetLastError() ); - } - - /* open a new handle to our event */ - hTestEvent = OpenEventW(EVENT_ALL_ACCESS, /* we want all rights */ - FALSE, /* no inherit */ - lpName ); - - if( hTestEvent != NULL ) - { - /* ERROR */ - Trace( "ERROR:OpenEventW() call succeeded against a named " - "mutex, should have returned NULL\n" ); - if( ! CloseHandle( hTestEvent ) ) - { - Trace( "ERROR:%lu:CloseHandle() call failed \n", GetLastError() ); - } - bRet = FAIL; - } - else - { - dwLastError = GetLastError(); - if( dwLastError != ERROR_INVALID_HANDLE ) - { - /* ERROR */ - Trace( "ERROR:OpenEventW() call failed against a named " - "mutex, but returned an unexpected result: %lu\n", - dwLastError ); - bRet = FAIL; - } - } - - - /* close the mutex handle */ - if( ! CloseHandle( hMutex ) ) - { - Trace( "ERROR:%lu:CloseHandle() call failed \n", GetLastError() ); - bRet = FAIL; - } - - - /* fail here if we weren't successful */ - if( bRet == FAIL ) - { - Fail( "" ); - } - - - /* PAL termination */ - PAL_Terminate(); - - /* return success or failure */ - return PASS; -} - - diff --git a/src/pal/tests/palsuite/threading/OpenEventW/test4/testinfo.dat b/src/pal/tests/palsuite/threading/OpenEventW/test4/testinfo.dat deleted file mode 100644 index 1b3f2d83c..000000000 --- a/src/pal/tests/palsuite/threading/OpenEventW/test4/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = threading -Function = OpenEventW -Name = Negative test for OpenEventW -TYPE = DEFAULT -EXE1 = test4 -Description -= Test to ensure proper operation of the OpenEventW() -= API by trying to open an event with a name that is -= already taken by a non-event object. diff --git a/src/pal/tests/palsuite/threading/OpenEventW/test5/CMakeLists.txt b/src/pal/tests/palsuite/threading/OpenEventW/test5/CMakeLists.txt deleted file mode 100644 index 2830182e5..000000000 --- a/src/pal/tests/palsuite/threading/OpenEventW/test5/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test5.cpp -) - -add_executable(paltest_openeventw_test5 - ${SOURCES} -) - -add_dependencies(paltest_openeventw_test5 coreclrpal) - -target_link_libraries(paltest_openeventw_test5 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/OpenEventW/test5/test5.cpp b/src/pal/tests/palsuite/threading/OpenEventW/test5/test5.cpp deleted file mode 100644 index 43b585765..000000000 --- a/src/pal/tests/palsuite/threading/OpenEventW/test5/test5.cpp +++ /dev/null @@ -1,197 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================= -** -** Source: test5.c -** -** Purpose: Positive test for OpenEventW. -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** CreateEvent -** CloseHandle -** WaitForSingleObject -** -** Purpose: -** -** Test to ensure proper operation of the OpenEventW() -** API by creating a new named event with CreateEventA() -** and verifying that it can be opened with OpenEventW(). -** It should be possible to use the event handles -** interchangeably, we test by setting the event with the -** original handle and waiting on it with the new one, -** then resetting it with the new one and waiting -** on it with the original one. -** -** -**===========================================================================*/ -#include - - - -int __cdecl main( int argc, char **argv ) - -{ - /* local variables */ - BOOL ret = FAIL; - DWORD dwRet = 0; - HANDLE hEvent = NULL; - HANDLE hTestEvent = NULL; - LPSECURITY_ATTRIBUTES lpEventAttributes = NULL; - BOOL bManualReset = TRUE; - BOOL bInitialState = FALSE; - LPSTR lpNameA = "ShakeIt"; - WCHAR wcName[] = {'S','h','a','k','e','I','t','\0'}; - LPWSTR lpNameW = wcName; - - - /* PAL initialization */ - if( (PAL_Initialize(argc, argv)) != 0 ) - { - return( FAIL ); - } - - - /* create an event which we can use with SetEvent */ - hEvent = CreateEventA( lpEventAttributes, - bManualReset, - bInitialState, - lpNameA ); - - if( hEvent == NULL ) - { - /* ERROR */ - Fail( "ERROR:%lu:CreateEvent() call failed\n", GetLastError() ); - } - - /* open a new handle to our event */ - hTestEvent = OpenEventW(EVENT_ALL_ACCESS, /* we want all rights */ - FALSE, /* no inherit */ - lpNameW ); - - if( hTestEvent == NULL ) - { - /* ERROR */ - Trace( "ERROR:%lu:OpenEventW() call failed\n", GetLastError() ); - goto cleanup; - } - - /* verify that the event isn't signalled yet by waiting on both */ - /* handles to the event object */ - dwRet = WaitForSingleObject( hEvent, 0 ); - if( dwRet != WAIT_TIMEOUT ) - { - /* ERROR */ - Trace( "ERROR:WaitForSingleObject() call returned %lu, " - "expected WAIT_TIMEOUT\n", - dwRet ); - goto cleanup; - } - - dwRet = WaitForSingleObject( hTestEvent, 0 ); - if( dwRet != WAIT_TIMEOUT ) - { - /* ERROR */ - Trace( "ERROR:WaitForSingleObject() call returned %lu, " - "expected WAIT_TIMEOUT\n", - dwRet ); - goto cleanup; - } - - - /* set the event using the original handle */ - if( ! SetEvent( hEvent ) ) - { - /* ERROR */ - Trace( "ERROR:%lu:SetEvent() call failed\n", GetLastError() ); - goto cleanup; - } - - /* verify that the event is signalled by waiting on both handles */ - dwRet = WaitForSingleObject( hEvent, 0 ); - if( dwRet != WAIT_OBJECT_0 ) - { - /* ERROR */ - Trace( "ERROR:WaitForSingleObject() call returned %lu, " - "expected WAIT_OBJECT_0\n", - dwRet ); - goto cleanup; - } - - dwRet = WaitForSingleObject( hTestEvent, 0 ); - if( dwRet != WAIT_OBJECT_0 ) - { - /* ERROR */ - Trace( "ERROR:WaitForSingleObject() call returned %lu, " - "expected WAIT_OBJECT_0\n", - dwRet ); - goto cleanup; - } - - /* reset the event using the new handle */ - if( ! ResetEvent( hTestEvent ) ) - { - /* ERROR */ - Trace( "ERROR:%lu:ResetEvent() call failed\n", GetLastError() ); - goto cleanup; - } - - /* verify that the event isn't signalled by waiting on both handles */ - dwRet = WaitForSingleObject( hEvent, 0 ); - if( dwRet != WAIT_TIMEOUT ) - { - /* ERROR */ - Trace( "ERROR:WaitForSingleObject() call returned %lu, " - "expected WAIT_TIMEOUT\n", - dwRet ); - goto cleanup; - } - - dwRet = WaitForSingleObject( hTestEvent, 0 ); - if( dwRet != WAIT_TIMEOUT ) - { - /* ERROR */ - Trace( "ERROR:WaitForSingleObject() call returned %lu, " - "expected WAIT_TIMEOUT\n", - dwRet ); - goto cleanup; - } - - - /* test was successful */ - ret = PASS; - - -cleanup: - /* close the new event handle */ - if( hTestEvent != NULL ) - { - if( ! CloseHandle( hTestEvent ) ) - { - ret = FAIL; - Trace( "ERROR:%lu:CloseHandle() call failed\n", GetLastError() ); - } - } - - /* close the original event handle */ - if( ! CloseHandle( hEvent ) ) - { - ret = FAIL; - Trace( "ERROR:%lu:CloseHandle() call failed\n", GetLastError() ); - } - - /* failure message */ - if( ret != PASS ) - { - Fail( "Test failed\n" ); - } - - - /* PAL termination */ - PAL_Terminate(); - - /* return success or failure */ - return ret; -} diff --git a/src/pal/tests/palsuite/threading/OpenEventW/test5/testinfo.dat b/src/pal/tests/palsuite/threading/OpenEventW/test5/testinfo.dat deleted file mode 100644 index f5af943a7..000000000 --- a/src/pal/tests/palsuite/threading/OpenEventW/test5/testinfo.dat +++ /dev/null @@ -1,19 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = threading -Function = OpenEventW -Name = Positive test for OpenEventW -TYPE = DEFAULT -EXE1 = test5 -Description -= Test to ensure proper operation of the OpenEventW() -= API by creating a new named event with CreateEventA() -= and verifying that it can be opened with OpenEventW(). -= It should be possible to use the event handles -= interchangeably, we test by setting the event with the -= original handle and waiting on it with the new one, -= then resetting it with the new one and waiting -= on it with the original one. diff --git a/src/pal/tests/palsuite/threading/OpenProcess/CMakeLists.txt b/src/pal/tests/palsuite/threading/OpenProcess/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/threading/OpenProcess/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/threading/OpenProcess/test1/CMakeLists.txt b/src/pal/tests/palsuite/threading/OpenProcess/test1/CMakeLists.txt deleted file mode 100644 index df66c3f2d..000000000 --- a/src/pal/tests/palsuite/threading/OpenProcess/test1/CMakeLists.txt +++ /dev/null @@ -1,32 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(TESTSOURCES - test1.cpp -) - -add_executable(paltest_openprocess_test1 - ${TESTSOURCES} -) - -add_dependencies(paltest_openprocess_test1 coreclrpal) - -target_link_libraries(paltest_openprocess_test1 - ${COMMON_TEST_LIBRARIES} -) - - -set(HELPERSOURCES - childProcess.cpp -) - -add_executable(paltest_openprocess_test1_child - ${HELPERSOURCES} -) - -add_dependencies(paltest_openprocess_test1_child coreclrpal) - -target_link_libraries(paltest_openprocess_test1_child - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/OpenProcess/test1/childProcess.cpp b/src/pal/tests/palsuite/threading/OpenProcess/test1/childProcess.cpp deleted file mode 100644 index 9ef07433f..000000000 --- a/src/pal/tests/palsuite/threading/OpenProcess/test1/childProcess.cpp +++ /dev/null @@ -1,75 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source: childprocess.c -** -** Purpose: Test to ensure OpenProcess works properly. -** All this program does is return a predefined value. -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** CreateMutexW -** WaitForSingleObject -** CloseHandle -** -** -**=========================================================*/ - -#include -#include "myexitcode.h" - - -int __cdecl main( int argc, char **argv ) -{ - HANDLE hMutex; - WCHAR wszMutexName[] = { 'T','E','S','T','1','\0' }; - DWORD dwRet; - int i; - - /* initialize the PAL */ - if( PAL_Initialize(argc, argv) != 0 ) - { - return( FAIL ); - } - - /* open a mutex to synchronize with the parent process */ - hMutex = CreateMutexW( NULL, FALSE, wszMutexName ); - if( hMutex == NULL ) - { - Fail( "ERROR:%lu:CreateMutex() call failed\r\n", GetLastError() ); - } - - /* acquire the mutex lock */ - dwRet = WaitForSingleObject( hMutex, 10000 ); - if( dwRet != WAIT_OBJECT_0 ) - { - Trace( "ERROR:WaitForSingleObject() returned %lu, " - "expected WAIT_OBJECT_0", - dwRet ); - if( ! CloseHandle( hMutex ) ) - { - Trace( "ERROR:%lu:CloseHandle() call failed\n", GetLastError() ); - } - Fail( "test failed\n" ); - } - - - /* simulate some activity */ - for( i=0; i<50000; i++ ) - ; - - /* close our mutex handle */ - if( ! CloseHandle( hMutex ) ) - { - Fail( "ERROR:%lu:CloseHandle() call failed\n", GetLastError() ); - } - - /* terminate the PAL */ - PAL_Terminate(); - - /* return the predefined exit code */ - return TEST_EXIT_CODE; -} diff --git a/src/pal/tests/palsuite/threading/OpenProcess/test1/myexitcode.h b/src/pal/tests/palsuite/threading/OpenProcess/test1/myexitcode.h deleted file mode 100644 index 66b8f43a9..000000000 --- a/src/pal/tests/palsuite/threading/OpenProcess/test1/myexitcode.h +++ /dev/null @@ -1,14 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: myexitcode.h -** -** Purpose: Define an exit code. -** -** -**==========================================================================*/ - -#define TEST_EXIT_CODE 317 diff --git a/src/pal/tests/palsuite/threading/OpenProcess/test1/test1.cpp b/src/pal/tests/palsuite/threading/OpenProcess/test1/test1.cpp deleted file mode 100644 index d0f901964..000000000 --- a/src/pal/tests/palsuite/threading/OpenProcess/test1/test1.cpp +++ /dev/null @@ -1,282 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================= -** -** Source: test1.c -** -** Purpose: Test to ensure OpenProcess works properly. -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** Fail -** ZeroMemory -** GetCurrentDirectoryW -** CreateProcessW -** WaitForSingleObject -** CreateMutexW -** ReleaseMutex -** CloseHandle -** GetLastError -** strlen -** strncpy -** -** -**===========================================================================*/ -#include -#include "myexitcode.h" - - -static const char* rgchPathDelim = "\\"; - - -int -mkAbsoluteFilename( LPSTR dirName, - DWORD dwDirLength, - LPCSTR fileName, - DWORD dwFileLength, - LPSTR absPathName ) -{ - DWORD sizeDN, sizeFN, sizeAPN; - - sizeDN = strlen( dirName ); - sizeFN = strlen( fileName ); - sizeAPN = (sizeDN + 1 + sizeFN + 1); - - /* ensure ((dirName + DELIM + fileName + \0) =< _MAX_PATH ) */ - if( sizeAPN > _MAX_PATH ) - { - return ( 0 ); - } - - strncpy( absPathName, dirName, dwDirLength +1 ); - strncpy( absPathName, rgchPathDelim, 2 ); - strncpy( absPathName, fileName, dwFileLength +1 ); - - return (sizeAPN); - -} - - -int __cdecl main( int argc, char **argv ) - -{ - const char* rgchChildFile = "childprocess"; - - STARTUPINFO si; - PROCESS_INFORMATION pi; - - DWORD dwError; - DWORD dwExitCode; - DWORD dwFileLength; - DWORD dwDirLength; - DWORD dwSize; - DWORD dwRet; - - HANDLE hMutex; - HANDLE hChildProcess; - - char rgchDirName[_MAX_DIR]; - char absPathBuf[_MAX_PATH]; - char* rgchAbsPathName; - - BOOL ret = FAIL; - BOOL bChildDone = FALSE; - WCHAR wszMutexName[] = { 'T','E','S','T','1','\0' }; - - /* initialize the PAL */ - if( PAL_Initialize(argc, argv) != 0 ) - { - return( FAIL ); - } - - /* create a mutex to synchronize with the child process */ - hMutex = CreateMutexW( NULL, TRUE, wszMutexName ); - if( hMutex == NULL ) - { - Fail( "ERROR:%lu:CreateMutex() call failed\r\n", GetLastError() ); - } - - /* zero our process and startup info structures */ - ZeroMemory( &si, sizeof(si) ); - si.cb = sizeof( si ); - ZeroMemory( &pi, sizeof(pi) ); - - /* build the absolute path to the child process */ - rgchAbsPathName = &absPathBuf[0]; - dwFileLength = strlen( rgchChildFile ); - - dwDirLength = GetCurrentDirectory( _MAX_PATH, rgchDirName ); - if( dwDirLength == 0 ) - { - dwError = GetLastError(); - if( ReleaseMutex( hMutex ) == 0 ) - { - Trace( "ERROR:%lu:ReleaseMutex() call failed\n", GetLastError() ); - } - if( CloseHandle( hMutex ) == 0 ) - { - Trace( "ERROR:%lu:CloseHandle() call failed\n", GetLastError() ); - } - Fail( "GetCurrentDirectory call failed with error code %d\n", - dwError ); - } - - dwSize = mkAbsoluteFilename( rgchDirName, - dwDirLength, - rgchChildFile, - dwFileLength, - rgchAbsPathName ); - if( dwSize == 0 ) - { - if( ReleaseMutex( hMutex ) == 0 ) - { - Trace( "ERROR:%lu:ReleaseMutex() call failed\n", GetLastError() ); - } - if( CloseHandle( hMutex ) == 0 ) - { - Trace( "ERROR:%lu:CloseHandle() call failed\n", GetLastError() ); - } - Fail( "Palsuite Code: mkAbsoluteFilename() call failed. Could ", - "not build absolute path name to file\n. Exiting.\n" ); - } - - /* launch the child process */ - if( !CreateProcess( NULL, /* module name to execute */ - rgchAbsPathName, /* command line */ - NULL, /* process handle not */ - /* inheritable */ - NULL, /* thread handle not */ - /*inheritable */ - FALSE, /* handle inheritance */ - CREATE_NEW_CONSOLE, /* dwCreationFlags */ - NULL, /* use parent's environment */ - NULL, /* use parent's starting */ - /* directory */ - &si, /* startup info struct */ - &pi ) /* process info struct */ - ) - { - dwError = GetLastError(); - if( ReleaseMutex( hMutex ) == 0 ) - { - Trace( "ERROR:%lu:ReleaseMutex() call failed\n", GetLastError() ); - } - if( CloseHandle( hMutex ) == 0 ) - { - Trace( "ERROR:%lu:CloseHandle() call failed\n", GetLastError() ); - } - Fail( "CreateProcess call failed with error code %d\n", - dwError ); - } - - /* open another handle to the child process */ - hChildProcess = OpenProcess( PROCESS_ALL_ACCESS, /* access */ - FALSE, /* inheritable */ - pi.dwProcessId /* process id */ - ); - if( hChildProcess == NULL ) - { - dwError = GetLastError(); - if( ReleaseMutex( hMutex ) == 0 ) - { - Trace( "ERROR:%lu:ReleaseMutex() call failed\n", GetLastError() ); - } - Trace( "ERROR:%lu:OpenProcess call failed\n", dwError ); - goto cleanup2; - } - - /* release the mutex so the child can proceed */ - if( ReleaseMutex( hMutex ) == 0 ) - { - Trace( "ERROR:%lu:ReleaseMutex() call failed\n", GetLastError() ); - goto cleanup; - } - - /* wait for the child process to complete, using the new handle */ - dwRet = WaitForSingleObject( hChildProcess, 10000 ); - if( dwRet != WAIT_OBJECT_0 ) - { - Trace( "ERROR:WaitForSingleObject call returned %lu, " - "expected WAIT_OBJECT_0", - dwRet ); - goto cleanup; - } - - /* remember that we waited until the child was finished */ - bChildDone = TRUE; - - /* check the exit code from the process -- this is a bit of an */ - /* extra verification that we opened the correct process handle */ - if( ! GetExitCodeProcess( hChildProcess, &dwExitCode ) ) - { - Trace( "ERROR:%lu:GetExitCodeProcess call failed\n", GetLastError() ); - goto cleanup; - } - - /* verification */ - if( (dwExitCode & 0xFF) != (TEST_EXIT_CODE & 0xFF) ) - { - Trace( "GetExitCodeProcess returned an incorrect exit code %d, " - "expected value is %d\n", - (dwExitCode & 0xFF), - (TEST_EXIT_CODE & 0xFF)); - goto cleanup; - } - - /* success if we get here */ - ret = PASS; - - -cleanup: - /* wait on the child process to complete if necessary */ - if( ! bChildDone ) - { - dwRet = WaitForSingleObject( hChildProcess, 10000 ); - if( dwRet != WAIT_OBJECT_0 ) - { - Trace( "ERROR:WaitForSingleObject call returned %lu, " - "expected WAIT_OBJECT_0", - dwRet ); - ret = FAIL; - } - } - - /* close all our handles */ - if( CloseHandle ( hChildProcess ) == 0 ) - { - Trace( "ERROR:%lu:CloseHandle() call failed\n", GetLastError() ); - ret = FAIL; - } - -cleanup2: - if( CloseHandle ( pi.hProcess ) == 0 ) - { - Trace( "ERROR:%lu:CloseHandle() call failed\n", GetLastError() ); - ret = FAIL; - } - if( CloseHandle ( pi.hThread ) == 0 ) - { - Trace( "ERROR:%lu:CloseHandle() call failed\n", GetLastError() ); - ret = FAIL; - } - if( CloseHandle( hMutex ) == 0 ) - { - Trace( "ERROR:%lu:CloseHandle() call failed\n", GetLastError() ); - ret = FAIL; - } - - if( ret == FAIL ) - { - Fail( "test failed\n" ); - } - - - - /* terminate the PAL */ - PAL_Terminate(); - - /* return success */ - return PASS; -} diff --git a/src/pal/tests/palsuite/threading/OpenProcess/test1/testinfo.dat b/src/pal/tests/palsuite/threading/OpenProcess/test1/testinfo.dat deleted file mode 100644 index dd6b2c0ff..000000000 --- a/src/pal/tests/palsuite/threading/OpenProcess/test1/testinfo.dat +++ /dev/null @@ -1,19 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = threading -Function = OpenProcess -Name = Test for OpenProcess -TYPE = DEFAULT -EXE1 = test1 -EXE2 = childprocess -Description -= Test to ensure proper operation of the OpenProcess API. -= The test launches a trivial child process, then opens -= a handle to it using OpenProcess. It uses that handle -= to wait for the child process to terminate, and then -= checks the exit code of the child process in order to -= verify that it was in fact a handle to the correct -= process. diff --git a/src/pal/tests/palsuite/threading/QueryThreadCycleTime/CMakeLists.txt b/src/pal/tests/palsuite/threading/QueryThreadCycleTime/CMakeLists.txt deleted file mode 100644 index 5e1ef7f28..000000000 --- a/src/pal/tests/palsuite/threading/QueryThreadCycleTime/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) diff --git a/src/pal/tests/palsuite/threading/QueryThreadCycleTime/test1/CMakeLists.txt b/src/pal/tests/palsuite/threading/QueryThreadCycleTime/test1/CMakeLists.txt deleted file mode 100644 index 12a575926..000000000 --- a/src/pal/tests/palsuite/threading/QueryThreadCycleTime/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_querythreadcycletime_test1 - ${SOURCES} -) - -add_dependencies(paltest_querythreadcycletime_test1 coreclrpal) - -target_link_libraries(paltest_querythreadcycletime_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/QueryThreadCycleTime/test1/test1.cpp b/src/pal/tests/palsuite/threading/QueryThreadCycleTime/test1/test1.cpp deleted file mode 100644 index 026243c81..000000000 --- a/src/pal/tests/palsuite/threading/QueryThreadCycleTime/test1/test1.cpp +++ /dev/null @@ -1,98 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source: -** -** Source : test1.c -** -** Purpose: Test for QueryThreadCycleTime() function -** -** -**=========================================================*/ - -#include - -int __cdecl main(int argc, char *argv[]) { - int ret = FAIL; - - //Test is failing unreliably, so for now we always return pass. - if (TRUE){ - ret = PASS; - goto EXIT; - } - { - LONG64 Actual, Expected, Delta = 850000000; - Actual = 0; - Expected = 0; - const LONG64 MSEC_TO_NSEC = 1000000; - - /* - * Initialize the PAL and return FAILURE if this fails - */ - - if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - HANDLE cThread = GetCurrentThread(); - - int i; - /* Take 2000 tiny measurements */ - for (i = 0; i < 2000; i++){ - ULONG64 FirstCount, SecondCount; - LONG64 Init; - - Sleep(1); - - /* Grab a FirstCount, then loop for a bit to make the clock increase */ - if (!QueryThreadCycleTime(cThread, (PULONG64)&FirstCount)) - { - Fail("ERROR: QueryThreadCycleTime returned failure.\n"); - } - - LONG64 x; - /* Init is in milliseconds, so we will convert later */ - Init = (LONG64)GetTickCount(); - x = Init + 3; - volatile int counter; - do { - for (counter = 0; counter < 100000; counter++) - { - // spin to consume CPU time - } - - } while (x > GetTickCount()); - Expected += (GetTickCount() - Init) * MSEC_TO_NSEC; - /* Get a second count */ - if (!QueryThreadCycleTime(cThread, (PULONG64)&SecondCount)) - { - Fail("ERROR: QueryThreadCycleTime returned failure.\n"); - } - - LONG64 trial = (LONG64)SecondCount - (LONG64)FirstCount; - if (trial < 0){ - printf("Negative value %llu measured", trial); - } - Actual += (trial); - - } - - - - if(labs(Expected - Actual) > Delta) - { - Fail("ERROR: The measured time (%llu millisecs) was not within Delta %llu " - "of the expected time (%llu millisecs).\n", - (Actual / MSEC_TO_NSEC), (Delta / MSEC_TO_NSEC), (Expected / MSEC_TO_NSEC)); - } - //printf("%llu, %llu\n", Expected, Actual); - PAL_Terminate(); - ret = PASS; - } -EXIT: - return ret; -} diff --git a/src/pal/tests/palsuite/threading/QueueUserAPC/CMakeLists.txt b/src/pal/tests/palsuite/threading/QueueUserAPC/CMakeLists.txt deleted file mode 100644 index 19ee487a6..000000000 --- a/src/pal/tests/palsuite/threading/QueueUserAPC/CMakeLists.txt +++ /dev/null @@ -1,10 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) -add_subdirectory(test3) -add_subdirectory(test4) -add_subdirectory(test5) -add_subdirectory(test6) -add_subdirectory(test7) - diff --git a/src/pal/tests/palsuite/threading/QueueUserAPC/test1/CMakeLists.txt b/src/pal/tests/palsuite/threading/QueueUserAPC/test1/CMakeLists.txt deleted file mode 100644 index 402188d27..000000000 --- a/src/pal/tests/palsuite/threading/QueueUserAPC/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_queueuserapc_test1 - ${SOURCES} -) - -add_dependencies(paltest_queueuserapc_test1 coreclrpal) - -target_link_libraries(paltest_queueuserapc_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/QueueUserAPC/test1/test1.cpp b/src/pal/tests/palsuite/threading/QueueUserAPC/test1/test1.cpp deleted file mode 100644 index 3637897ba..000000000 --- a/src/pal/tests/palsuite/threading/QueueUserAPC/test1/test1.cpp +++ /dev/null @@ -1,313 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test1.c -** -** Purpose: Tests that APCs sent to a thread in an alertable state via -** QueueUserAPC are executed in FIFO order. Also tests that the APC -** function is executed within the context of the correct thread and -** that the dwData parameter gets sent correctly. -** -** -**===================================================================*/ - -#include - -const int ChildThreadSleepTime = 2000; -const int InterruptTime = 1000; - -VOID PALAPI APCFuncA(ULONG_PTR dwParam); -VOID PALAPI APCFuncB(ULONG_PTR dwParam); -VOID PALAPI APCFuncC(ULONG_PTR dwParam); -VOID PALAPI APCFuncD(ULONG_PTR dwParam); -DWORD PALAPI SleeperProc(LPVOID lpParameter); - -const char *ExpectedResults = "A0B0C0D0A1B1C1D1A2B2C2D2A3B3C3D3"; -char ResultBuffer[256]; -char *ResultPtr; -DWORD ChildThread; - -/* synchronization events */ -static HANDLE hSyncEvent1 = NULL; -static HANDLE hSyncEvent2 = NULL; - -/* thread result because we have no GetExitCodeThread() API */ -BOOL bThreadResult = FAIL; - -int __cdecl main (int argc, char **argv) -{ - HANDLE hThread = NULL; - int ret; - int i,j; - BOOL bResult = FAIL; - - PAPCFUNC APCFuncs[] = - { - APCFuncA, - APCFuncB, - APCFuncC, - APCFuncD, - }; - - /* initialize the PAL */ - if (0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - ResultPtr = ResultBuffer; - - /* create a pair of synchronization events to coordinate our threads */ - hSyncEvent1 = CreateEvent( NULL, FALSE, FALSE, NULL ); - if( hSyncEvent1 == NULL ) - { - Trace( "ERROR:%lu:CreateEvent() call failed\n", GetLastError() ); - goto cleanup; - } - - hSyncEvent2 = CreateEvent( NULL, FALSE, FALSE, NULL ); - if( hSyncEvent2 == NULL ) - { - Trace( "ERROR:%lu:CreateEvent() call failed\n", GetLastError() ); - goto cleanup; - } - - /* create a child thread which will call SleepEx */ - hThread = CreateThread( NULL, - 0, - (LPTHREAD_START_ROUTINE)SleeperProc, - 0, - 0, - &ChildThread); - - if( hThread == NULL ) - { - Trace( "ERROR:%lu:CreateThread() call failed\n", - GetLastError()); - goto cleanup; - } - - - /* wait on our synchronization event to ensure the thread is running */ - ret = WaitForSingleObject( hSyncEvent1, 20000 ); - if( ret != WAIT_OBJECT_0 ) - { - Trace( "ERROR:WaitForSingleObject() returned %lu, " - "expected WAIT_OBJECT_0\n", - ret ); - goto cleanup; - } - - - /* queue our user APC functions on the thread */ - for (i=0; i<4; i++) - { - for (j=0; j - -const int ChildThreadSleepTime = 2000; -const int InterruptTime = 1000; - -DWORD ChildThread; -BOOL InAPC; - -/* synchronization events */ -static HANDLE hSyncEvent1 = NULL; -static HANDLE hSyncEvent2 = NULL; - -/* thread result because we have no GetExitCodeThread() API */ -static BOOL bThreadResult = FAIL; - - -VOID PALAPI APCFunc(ULONG_PTR dwParam) -{ - InAPC = TRUE; -} - -DWORD PALAPI SleeperProc(LPVOID lpParameter) -{ - DWORD ret; - - /* signal the main thread that we're ready to proceed */ - if( ! SetEvent( hSyncEvent1 ) ) - { - Trace( "ERROR:%lu:SetEvent() call failed\n", GetLastError() ); - bThreadResult = FAIL; - goto done; - } - - /* wait for notification from the main thread */ - ret = WaitForSingleObject( hSyncEvent2, 20000 ); - if( ret != WAIT_OBJECT_0 ) - { - Trace( "ERROR:WaitForSingleObject() returned %lu, " - "expected WAIT_OBJECT_0\n", - ret ); - bThreadResult = FAIL; - goto done; - } - - /* call our sleep function */ - Sleep( ChildThreadSleepTime ); - - /* success if we reach here */ - bThreadResult = PASS; - - -done: - - /* signal the main thread that we're finished */ - if( ! SetEvent( hSyncEvent1 ) ) - { - Trace( "ERROR:%lu:SetEvent() call failed\n", GetLastError() ); - bThreadResult = FAIL; - } - - /* return success or failure */ - return bThreadResult; -} - - -int __cdecl main (int argc, char **argv) -{ - /* local variables */ - HANDLE hThread = 0; - int ret; - BOOL bResult = FAIL; - - /* initialize the PAL */ - if (0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - InAPC = FALSE; - - /* create a pair of synchronization events to coordinate our threads */ - hSyncEvent1 = CreateEvent( NULL, FALSE, FALSE, NULL ); - if( hSyncEvent1 == NULL ) - { - Trace( "ERROR:%lu:CreateEvent() call failed\n", GetLastError() ); - goto cleanup; - } - - hSyncEvent2 = CreateEvent( NULL, FALSE, FALSE, NULL ); - if( hSyncEvent2 == NULL ) - { - Trace( "ERROR:%lu:CreateEvent() call failed\n", GetLastError() ); - goto cleanup; - } - - /* create a child thread */ - hThread = CreateThread( NULL, - 0, - (LPTHREAD_START_ROUTINE)SleeperProc, - 0, - 0, - &ChildThread); - - if (hThread == NULL) - { - Trace( "ERROR:%lu:CreateThread() call failed\n", - GetLastError()); - goto cleanup; - } - - - /* wait on our synchronization event to ensure the thread is running */ - ret = WaitForSingleObject( hSyncEvent1, 20000 ); - if( ret != WAIT_OBJECT_0 ) - { - Trace( "ERROR:WaitForSingleObject() returned %lu, " - "expected WAIT_OBJECT_0\n", - ret ); - goto cleanup; - } - - /* queue a user APC on the child thread */ - ret = QueueUserAPC(APCFunc, hThread, 0); - if (ret == 0) - { - Trace( "ERROR:%lu:QueueUserAPC() call failed\n", - GetLastError()); - goto cleanup; - } - - /* signal the child thread to continue */ - if( ! SetEvent( hSyncEvent2 ) ) - { - Trace( "ERROR:%lu:SetEvent() call failed\n", GetLastError() ); - goto cleanup; - } - - /* wait on our synchronization event to ensure the other thread is done */ - ret = WaitForSingleObject( hSyncEvent1, 20000 ); - if( ret != WAIT_OBJECT_0 ) - { - Trace( "ERROR:WaitForSingleObject() returned %lu, " - "expected WAIT_OBJECT_0\n", - ret ); - goto cleanup; - } - - /* check that the thread executed successfully */ - if( bThreadResult == FAIL ) - { - goto cleanup; - } - - - /* check whether the APC function was executed */ - if( InAPC ) - { - Trace( "FAIL:APC function was executed but shouldn't have been\n" ); - goto cleanup; - } - - /* success if we reach here */ - bResult = PASS; - - -cleanup: - /* wait for the other thread to finish */ - if( hThread != NULL ) - { - ret = WaitForSingleObject( hThread, INFINITE ); - if (ret == WAIT_FAILED) - { - Trace( "ERROR:%lu:WaitForSingleObject() returned %lu, " - "expected WAIT_OBJECT_0\n", - ret ); - bResult = FAIL; - } - } - - /* close our synchronization handles */ - if( hSyncEvent1 != NULL ) - { - if( ! CloseHandle( hSyncEvent1 ) ) - { - Trace( "ERROR:%lu:CloseHandle() call failed\n", GetLastError() ); - bResult = FAIL; - } - } - - if( hSyncEvent2 != NULL ) - { - if( ! CloseHandle( hSyncEvent2 ) ) - { - Trace( "ERROR:%lu:CloseHandle() call failed\n", GetLastError() ); - bResult = FAIL; - } - } - - if( bResult == FAIL ) - { - Fail( "test failed\n" ); - } - - - /* terminate the PAL */ - PAL_Terminate(); - - /* return success */ - return PASS; -} diff --git a/src/pal/tests/palsuite/threading/QueueUserAPC/test2/testinfo.dat b/src/pal/tests/palsuite/threading/QueueUserAPC/test2/testinfo.dat deleted file mode 100644 index 42d942df3..000000000 --- a/src/pal/tests/palsuite/threading/QueueUserAPC/test2/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = threading -Function = QueueUserAPC -Name = Test #2 for QueueUserAPC -TYPE = DEFAULT -EXE1 = test2 -Description -=Tests that APCs are not executed if a thread never enters an -=alertable state after they are queued. diff --git a/src/pal/tests/palsuite/threading/QueueUserAPC/test3/CMakeLists.txt b/src/pal/tests/palsuite/threading/QueueUserAPC/test3/CMakeLists.txt deleted file mode 100644 index 8a4c9f26a..000000000 --- a/src/pal/tests/palsuite/threading/QueueUserAPC/test3/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test3.cpp -) - -add_executable(paltest_queueuserapc_test3 - ${SOURCES} -) - -add_dependencies(paltest_queueuserapc_test3 coreclrpal) - -target_link_libraries(paltest_queueuserapc_test3 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/QueueUserAPC/test3/test3.cpp b/src/pal/tests/palsuite/threading/QueueUserAPC/test3/test3.cpp deleted file mode 100644 index 933f41a5b..000000000 --- a/src/pal/tests/palsuite/threading/QueueUserAPC/test3/test3.cpp +++ /dev/null @@ -1,33 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test3.c -** -** Purpose: Tests how QueueUserAPC handles an invalid thread. -** -** -**===================================================================*/ - -#include - -int __cdecl main (int argc, char **argv) -{ - int ret; - - if (0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - ret = QueueUserAPC(NULL, NULL, 0); - if (ret != 0) - { - Fail("QueueUserAPC passed with an invalid thread!\n"); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/threading/QueueUserAPC/test3/testinfo.dat b/src/pal/tests/palsuite/threading/QueueUserAPC/test3/testinfo.dat deleted file mode 100644 index 0b96349f1..000000000 --- a/src/pal/tests/palsuite/threading/QueueUserAPC/test3/testinfo.dat +++ /dev/null @@ -1,12 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = threading -Function = QueueUserAPC -Name = Test #3 for QueueUserAPC -TYPE = DEFAULT -EXE1 = test3 -Description -=Tests how QueueUserAPC handles an invalid thread. diff --git a/src/pal/tests/palsuite/threading/QueueUserAPC/test4/CMakeLists.txt b/src/pal/tests/palsuite/threading/QueueUserAPC/test4/CMakeLists.txt deleted file mode 100644 index dd9749079..000000000 --- a/src/pal/tests/palsuite/threading/QueueUserAPC/test4/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test4.cpp -) - -add_executable(paltest_queueuserapc_test4 - ${SOURCES} -) - -add_dependencies(paltest_queueuserapc_test4 coreclrpal) - -target_link_libraries(paltest_queueuserapc_test4 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/QueueUserAPC/test4/test4.cpp b/src/pal/tests/palsuite/threading/QueueUserAPC/test4/test4.cpp deleted file mode 100644 index c28709db8..000000000 --- a/src/pal/tests/palsuite/threading/QueueUserAPC/test4/test4.cpp +++ /dev/null @@ -1,72 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================= -** -** Source: test4.c -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** GetCurrentThread -** SleepEx -** -** Purpose: -** -** Test to ensure proper operation of the QueueUserAPC() -** API by trying to queue APC functions on the current -** thread. -** -** -**===========================================================================*/ -#include - - -static BOOL bAPCExecuted = FALSE; - -VOID PALAPI APCFunc( ULONG_PTR dwParam ) -{ - bAPCExecuted = TRUE; -} - -int __cdecl main( int argc, char **argv ) - -{ - /* local variables */ - HANDLE hThread = NULL; - DWORD ret; - - /* PAL initialization */ - if( (PAL_Initialize(argc, argv)) != 0 ) - { - return( FAIL ); - } - - /* get the current thread */ - hThread = GetCurrentThread(); - ret = QueueUserAPC( APCFunc, hThread, 0 ); - if( ret == 0 ) - { - Fail( "ERROR:%lu:QueueUserAPC call failed\n", GetLastError() ); - } - - /* call SleepEx() to put the thread in an alertable state */ - ret = SleepEx( 2000, TRUE ); - if( ret != WAIT_IO_COMPLETION ) - { - Fail( "ERROR:Expected sleep to return WAIT_IO_COMPLETION, got %lu\n", - ret ); - } - - /* check that the APC function was executed */ - if( bAPCExecuted == FALSE ) - { - Fail( "ERROR:APC function was not executed\n" ); - } - - /* PAL termination */ - PAL_Terminate(); - - /* return success */ - return PASS; -} diff --git a/src/pal/tests/palsuite/threading/QueueUserAPC/test4/testinfo.dat b/src/pal/tests/palsuite/threading/QueueUserAPC/test4/testinfo.dat deleted file mode 100644 index cd7b7c2f2..000000000 --- a/src/pal/tests/palsuite/threading/QueueUserAPC/test4/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = threading -Function = QueueUserAPC -Name = Positive test for QueueUserAPC -TYPE = DEFAULT -EXE1 = test4 -Description -= Test to ensure proper operation of the QueueUserAPC() -= API by trying to queue APC functions on the current -= thread. diff --git a/src/pal/tests/palsuite/threading/QueueUserAPC/test5/CMakeLists.txt b/src/pal/tests/palsuite/threading/QueueUserAPC/test5/CMakeLists.txt deleted file mode 100644 index a45171223..000000000 --- a/src/pal/tests/palsuite/threading/QueueUserAPC/test5/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test5.cpp -) - -add_executable(paltest_queueuserapc_test5 - ${SOURCES} -) - -add_dependencies(paltest_queueuserapc_test5 coreclrpal) - -target_link_libraries(paltest_queueuserapc_test5 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/QueueUserAPC/test5/test5.cpp b/src/pal/tests/palsuite/threading/QueueUserAPC/test5/test5.cpp deleted file mode 100644 index 3d26a55f5..000000000 --- a/src/pal/tests/palsuite/threading/QueueUserAPC/test5/test5.cpp +++ /dev/null @@ -1,200 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================= -** -** Source: test5.c -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** CreateEvent -** SetEvent -** CreateThread -** ResumeThread -** WaitForSingleObject -** CloseHandle -** -** Purpose: -** -** Test to ensure proper operation of the QueueUserAPC() -** API by trying to queue and activate APC functions on -** a thread that was created suspended, prior to resuming -** it. We're verifying the following behavior: -** -** "If an application queues an APC before the thread begins -** running, the thread begins by calling the APC function. -** After the thread calls an APC function, it calls the APC -** functions for all APCs in its APC queue." -** -** -**===========================================================================*/ -#include - - -static HANDLE hEvent = NULL; -static BOOL bAPCExecuted = FALSE; - -VOID PALAPI APCFunc( ULONG_PTR dwParam ) -{ - bAPCExecuted = TRUE; -} - -/** - * ThreadFunc - * - * Dummy thread function for APC queuing. - */ -DWORD PALAPI ThreadFunc( LPVOID param ) -{ - DWORD ret = 0; - - /* alertable wait until the global event is signalled */ - ret = WaitForSingleObject( hEvent, INFINITE ); - if( ret != WAIT_OBJECT_0 ) - { - Fail( "ERROR:WaitForSingleObject() returned %lu, " - "expected WAIT_OBJECT_0\n", - ret ); - } - - return 0; -} - - -int __cdecl main( int argc, char **argv ) - -{ - /* local variables */ - HANDLE hThread = NULL; - DWORD IDThread; - DWORD ret; - BOOL bResult = FALSE; - - /* PAL initialization */ - if( (PAL_Initialize(argc, argv)) != 0 ) - { - return( FAIL ); - } - - /* create an event for the other thread to wait on */ - hEvent = CreateEvent( NULL, TRUE, FALSE, NULL ); - if( hEvent == NULL ) - { - Fail( "ERROR:%lu:CreateEvent() call failed\n", GetLastError() ); - } - - /* run another dummy thread to cause notification of the library */ - hThread = CreateThread( NULL, /* no security attributes */ - 0, /* use default stack size */ - (LPTHREAD_START_ROUTINE) ThreadFunc, /* thread function */ - (LPVOID) NULL, /* pass thread index as */ - /* function argument */ - CREATE_SUSPENDED, /* create suspended */ - &IDThread ); /* returns thread id */ - - /* Check the return value for success. */ - if( hThread == NULL ) - { - /* error creating thread */ - Trace( "ERROR:%lu:CreateThread call failed\n", GetLastError() ); - if( ! CloseHandle( hEvent ) ) - { - Trace( "ERROR:%lu:CloseHandle() call failed\n", GetLastError() ); - } - Fail( "test failed\n" ); - } - - /* queue our APC on the suspended thread */ - ret = QueueUserAPC( APCFunc, hThread, 0 ); - if( ret == 0 ) - { - Fail( "ERROR:%lu:QueueUserAPC call failed\n", GetLastError() ); - } - - /* wait on the suspended thread */ - ret = WaitForSingleObject( hThread, 2000 ); - if( ret != WAIT_TIMEOUT ) - { - Trace( "ERROR:WaitForSingleObject() returned %lu, " - "expected WAIT_TIMEOUT\n", - ret ); - goto cleanup; - } - - /* verify that the APC function was not executed */ - if( bAPCExecuted == TRUE ) - { - Trace( "ERROR:APC function was executed for a suspended thread\n" ); - goto cleanup; - } - - /* Resume the suspended thread */ - ResumeThread( hThread ); - - /* do another wait on the resumed thread */ - ret = WaitForSingleObject( hThread, 2000 ); - - /* verify that we got a WAIT_TIMEOUT result */ - if( ret != WAIT_TIMEOUT ) - { - Trace( "ERROR:WaitForSingleObject() returned %lu, " - "expected WAIT_TIMEOUT\n", - ret ); - goto cleanup; - } - - /* check that the APC function was actually executed */ - if( bAPCExecuted == FALSE ) - { - Trace( "ERROR:APC function was not executed\n" ); - goto cleanup; - } - - /* set the success flag */ - bResult = PASS; - -cleanup: - /* signal the event so the other thread will exit */ - if( ! SetEvent( hEvent ) ) - { - Trace( "ERROR:%lu:SetEvent() call failed\n", GetLastError() ); - bResult = FAIL; - } - - /* close the global event handle */ - if( ! CloseHandle( hEvent ) ) - { - Trace( "ERROR:%lu:CloseHandle() call failed\n", GetLastError() ); - bResult = FAIL; - } - - /* wait on the other thread to complete */ - ret = WaitForSingleObject( hThread, 2000 ); - if( ret != WAIT_OBJECT_0 ) - { - Trace( "ERROR:WaitForSingleObject() returned %lu, " - "expected WAIT_OBJECT_0\n", - ret ); - bResult = FAIL; - } - - /* close the thread handle */ - if( ! CloseHandle( hThread ) ) - { - Trace( "ERROR:%lu:CloseHandle() call failed\n", GetLastError() ); - bResult = FAIL; - } - - /* output final failure result for failure case */ - if( bResult == FAIL ) - { - Fail( "test failed\n" ); - } - - /* PAL termination */ - PAL_Terminate(); - - /* return success */ - return PASS; -} diff --git a/src/pal/tests/palsuite/threading/QueueUserAPC/test5/testinfo.dat b/src/pal/tests/palsuite/threading/QueueUserAPC/test5/testinfo.dat deleted file mode 100644 index f1775aabe..000000000 --- a/src/pal/tests/palsuite/threading/QueueUserAPC/test5/testinfo.dat +++ /dev/null @@ -1,20 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = threading -Function = QueueUserAPC -Name = Positive test for QueueUserAPC -TYPE = DEFAULT -EXE1 = test5 -Description -= Test to ensure proper operation of the QueueUserAPC() -= API by trying to queue and activate APC functions on -= a thread that was created suspended, prior to resuming -= it. We're verifying the following behavior: -= -= "If an application queues an APC before the thread begins -= running, the thread begins by calling the APC function. -= After the thread calls an APC function, it calls the APC -= functions for all APCs in its APC queue." diff --git a/src/pal/tests/palsuite/threading/QueueUserAPC/test6/CMakeLists.txt b/src/pal/tests/palsuite/threading/QueueUserAPC/test6/CMakeLists.txt deleted file mode 100644 index 440b24cf8..000000000 --- a/src/pal/tests/palsuite/threading/QueueUserAPC/test6/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test6.cpp -) - -add_executable(paltest_queueuserapc_test6 - ${SOURCES} -) - -add_dependencies(paltest_queueuserapc_test6 coreclrpal) - -target_link_libraries(paltest_queueuserapc_test6 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/QueueUserAPC/test6/test6.cpp b/src/pal/tests/palsuite/threading/QueueUserAPC/test6/test6.cpp deleted file mode 100644 index e2e246472..000000000 --- a/src/pal/tests/palsuite/threading/QueueUserAPC/test6/test6.cpp +++ /dev/null @@ -1,129 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================= -** -** Source: test6.c -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** CreateEvent -** SetEvent -** CreateThread -** ResumeThread -** WaitForMultipleObjectsEx -** CloseHandle -** -** Purpose: -** -** Test to ensure proper operation of the QueueUserAPC() -** API by trying to queue APC functions on a thread that -** has already terminated. -** -** -**===========================================================================*/ -#include - - -static BOOL bAPCExecuted = FALSE; - -VOID PALAPI APCFunc( ULONG_PTR dwParam ) -{ - bAPCExecuted = TRUE; -} - -/** - * ThreadFunc - * - * Dummy thread function for APC queuing. - */ -DWORD PALAPI ThreadFunc( LPVOID param ) -{ - int i; - - /* simulate some activity */ - for( i=0; i<250000; i++ ) - ; - - return 0; -} - - -int __cdecl main( int argc, char **argv ) - -{ - /* local variables */ - HANDLE hThread = NULL; - DWORD IDThread; - DWORD ret; - - /* PAL initialization */ - if( (PAL_Initialize(argc, argv)) != 0 ) - { - return( FAIL ); - } - - /* run another dummy thread to cause notification of the library */ - hThread = CreateThread( NULL, /* no security attributes */ - 0, /* use default stack size */ - (LPTHREAD_START_ROUTINE) ThreadFunc, /* thread function */ - (LPVOID) NULL, /* pass thread index as */ - /* function argument */ - CREATE_SUSPENDED, /* create suspended */ - &IDThread ); /* returns thread id */ - - /* Check the return value for success. */ - if( hThread == NULL ) - { - /* error creating thread */ - Fail( "ERROR:%lu:CreateThread call failed\n", GetLastError() ); - } - - /* Resume the suspended thread */ - ResumeThread( hThread ); - - /* wait on the other thread to complete */ - ret = WaitForSingleObject( hThread, INFINITE ); - if( ret != WAIT_OBJECT_0 ) - { - Trace( "ERROR:WaitForSingleObject() returned %lu, " - "expected WAIT_OBJECT_0\n", - ret ); - if( ! CloseHandle( hThread ) ) - { - Trace( "ERROR:%lu:CloseHandle() call failed\n", GetLastError() ); - } - Fail( "test failed\n" ); - } - - /* queue our APC on the finished thread */ - ret = QueueUserAPC( APCFunc, hThread, 0 ); - if( ret != 0 ) - { - Trace( "ERROR:QueueUserAPC call succeeded on a terminated thread\n" ); - if( ! CloseHandle( hThread ) ) - { - Trace( "ERROR:%lu:CloseHandle() call failed\n", GetLastError() ); - } - Fail( "test failed\n" ); - } - - if( ! CloseHandle( hThread ) ) - { - Fail( "ERROR:%lu:CloseHandle() call failed\n", GetLastError() ); - } - - /* dummy check that the APC function wasn't actually executed */ - if( bAPCExecuted != FALSE ) - { - Fail( "ERROR:APC function was executed\n" ); - } - - - /* PAL termination */ - PAL_Terminate(); - - /* return success */ - return PASS; -} diff --git a/src/pal/tests/palsuite/threading/QueueUserAPC/test6/testinfo.dat b/src/pal/tests/palsuite/threading/QueueUserAPC/test6/testinfo.dat deleted file mode 100644 index 4d806184e..000000000 --- a/src/pal/tests/palsuite/threading/QueueUserAPC/test6/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = threading -Function = QueueUserAPC -Name = Negative test for QueueUserAPC -TYPE = DEFAULT -EXE1 = test6 -Description -= Test to ensure proper operation of the QueueUserAPC() -= API by trying to queue APC functions on a thread that -= has already terminated. diff --git a/src/pal/tests/palsuite/threading/QueueUserAPC/test7/CMakeLists.txt b/src/pal/tests/palsuite/threading/QueueUserAPC/test7/CMakeLists.txt deleted file mode 100644 index 6dbeb07e2..000000000 --- a/src/pal/tests/palsuite/threading/QueueUserAPC/test7/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test7.cpp -) - -add_executable(paltest_queueuserapc_test7 - ${SOURCES} -) - -add_dependencies(paltest_queueuserapc_test7 coreclrpal) - -target_link_libraries(paltest_queueuserapc_test7 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/QueueUserAPC/test7/test7.cpp b/src/pal/tests/palsuite/threading/QueueUserAPC/test7/test7.cpp deleted file mode 100644 index 54a63982f..000000000 --- a/src/pal/tests/palsuite/threading/QueueUserAPC/test7/test7.cpp +++ /dev/null @@ -1,253 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================= -** -** Source: test7.c -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** CreateEvent -** SetEvent -** CreateThread -** ResumeThread -** WaitForMultipleObjectsEx -** CloseHandle -** -** Purpose: -** -** Test to ensure proper operation of the QueueUserAPC() -** API by trying to queue an APC function on a thread and -** activating it with WaitForMultipleObjectsEx. -** -** -**===========================================================================*/ -#include - - -static HANDLE hSyncEvent = NULL; -static HANDLE hTestEvent = NULL; -static int nAPCExecuted = 0; -static BOOL bThreadResult = FALSE; - -VOID PALAPI APCFunc( ULONG_PTR dwParam ) -{ - ++nAPCExecuted; -} - -/** - * ThreadFunc - * - * Dummy thread function for APC queuing. - */ -DWORD PALAPI ThreadFunc( LPVOID param ) -{ - DWORD ret = 0; - - /* pessimism */ - bThreadResult = FALSE; - - /* set the sync event to notify the main thread */ - if( ! SetEvent( hSyncEvent ) ) - { - Trace( "ERROR:%lu:SetEvent() call failed\n", GetLastError() ); - goto done; - } - - /* wait until the test event is signalled */ - ret = WaitForSingleObject( hTestEvent, INFINITE ); - if( ret != WAIT_OBJECT_0 ) - { - Trace( "ERROR:WaitForSingleObject() returned %lu, " - "expected WAIT_OBJECT_0\n", - ret ); - goto done; - } - - /* now do an alertable wait on the same event, which is now - in an unsignalled state */ - ret = WaitForMultipleObjectsEx( 1, &hTestEvent, TRUE, 2000, TRUE ); - - /* verify that we got a WAIT_IO_COMPLETION result */ - if( ret != WAIT_IO_COMPLETION ) - { - Trace( "ERROR:WaitForMultipleObjectsEx returned %lu, " - "expected WAIT_IO_COMPLETION\n", - ret ); - goto done; - } - - /* set the event again */ - if( ! SetEvent( hTestEvent ) ) - { - Trace( "ERROR:%lu:SetEvent() call failed\n", GetLastError() ); - goto done; - } - - /* do a non-alertable wait on the same event */ - ret = WaitForMultipleObjectsEx( 1, &hTestEvent, TRUE, INFINITE, FALSE ); - - /* verify that we got a WAIT_OBJECT_0 result */ - if( ret != WAIT_OBJECT_0 ) - { - Trace( "ERROR:WaitForMultipleObjectsEx returned %lu, " - "expected WAIT_OBJECT_0\n", - ret ); - goto done; - } - - /* success at this point */ - bThreadResult = TRUE; - - -done: - return bThreadResult; -} - - -int __cdecl main( int argc, char **argv ) - -{ - /* local variables */ - HANDLE hThread = NULL; - DWORD IDThread; - DWORD ret; - BOOL bResult = FALSE; - - /* PAL initialization */ - if( (PAL_Initialize(argc, argv)) != 0 ) - { - return( FAIL ); - } - - /* create an auto-reset event for the other thread to wait on */ - hTestEvent = CreateEvent( NULL, FALSE, FALSE, NULL ); - if( hTestEvent == NULL ) - { - Fail( "ERROR:%lu:CreateEvent() call failed\n", GetLastError() ); - } - - /* create an auto-reset event for synchronization */ - hSyncEvent = CreateEvent( NULL, FALSE, FALSE, NULL ); - if( hSyncEvent == NULL ) - { - Trace( "ERROR:%lu:CreateEvent() call failed\n", GetLastError() ); - if( ! CloseHandle( hTestEvent ) ) - { - Trace( "ERROR:%lu:CreateEvent() call failed\n", GetLastError() ); - } - Fail( "test failed\n" ); - } - - /* run another dummy thread to cause notification of the library */ - hThread = CreateThread( NULL, /* no security attributes */ - 0, /* use default stack size */ - (LPTHREAD_START_ROUTINE) ThreadFunc, /* thread function */ - (LPVOID) NULL, /* pass thread index as */ - /* function argument */ - CREATE_SUSPENDED, /* create suspended */ - &IDThread ); /* returns thread id */ - - /* Check the return value for success. */ - if( hThread == NULL ) - { - /* error creating thread */ - Trace( "ERROR:%lu:CreateThread call failed\n", GetLastError() ); - if( ! CloseHandle( hTestEvent ) ) - { - Trace( "ERROR:%lu:CloseHandle() call failed\n", GetLastError() ); - } - Fail( "test failed\n" ); - } - - /* Resume the suspended thread */ - ResumeThread( hThread ); - - /* wait until the other thread is ready to proceed */ - ret = WaitForSingleObject( hSyncEvent, 10000 ); - if( ret != WAIT_OBJECT_0 ) - { - Trace( "ERROR:WaitForSingleObject returned %lu, " - "expected WAIT_OBJECT_0\n", - ret ); - goto cleanup; - } - - - /* now queue our APC on the test thread */ - ret = QueueUserAPC( APCFunc, hThread, 0 ); - if( ret == 0 ) - { - Trace( "ERROR:%lu:QueueUserAPC call failed\n", GetLastError() ); - goto cleanup; - } - - /* signal the test event so the other thread will proceed */ - if( ! SetEvent( hTestEvent ) ) - { - Trace( "ERROR:%lu:SetEvent() call failed\n", GetLastError() ); - goto cleanup; - } - - /* wait on the other thread to complete */ - ret = WaitForSingleObject( hThread, INFINITE ); - if( ret != WAIT_OBJECT_0 ) - { - Trace( "ERROR:WaitForSingleObject() returned %lu, " - "expected WAIT_OBJECT_0\n", - ret ); - goto cleanup; - } - - /* check the result of the other thread */ - if( bThreadResult == FALSE ) - { - goto cleanup; - } - - /* check that the APC function was actually executed exactly one time */ - if( nAPCExecuted != 1 ) - { - Trace( "ERROR:APC function was executed %d times, " - "expected once\n", nAPCExecuted ); - goto cleanup; - } - - /* set the success flag */ - bResult = PASS; - - -cleanup: - /* close the global event handles */ - if( ! CloseHandle( hTestEvent ) ) - { - Trace( "ERROR:%lu:CloseHandle() call failed\n", GetLastError() ); - bResult = FAIL; - } - - if( ! CloseHandle( hSyncEvent ) ) - { - Trace( "ERROR:%lu:CloseHandle() call failed\n", GetLastError() ); - bResult = FAIL; - } - - /* close the thread handle */ - if( ! CloseHandle( hThread ) ) - { - Trace( "ERROR:%lu:CloseHandle() call failed\n", GetLastError() ); - bResult = FAIL; - } - - /* output final failure result for failure case */ - if( bResult == FAIL ) - { - Fail( "test failed\n" ); - } - - /* PAL termination */ - PAL_Terminate(); - - /* return success */ - return PASS; -} diff --git a/src/pal/tests/palsuite/threading/QueueUserAPC/test7/testinfo.dat b/src/pal/tests/palsuite/threading/QueueUserAPC/test7/testinfo.dat deleted file mode 100644 index d92d9496d..000000000 --- a/src/pal/tests/palsuite/threading/QueueUserAPC/test7/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = threading -Function = QueueUserAPC -Name = Positive test for QueueUserAPC -TYPE = DEFAULT -EXE1 = test7 -Description -= Test to ensure proper operation of the QueueUserAPC() -= API by trying to queue an APC function on a thread and -= activating it with WaitForMultipleObjectsEx. diff --git a/src/pal/tests/palsuite/threading/ReleaseMutex/CMakeLists.txt b/src/pal/tests/palsuite/threading/ReleaseMutex/CMakeLists.txt deleted file mode 100644 index f9524196e..000000000 --- a/src/pal/tests/palsuite/threading/ReleaseMutex/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test3) - diff --git a/src/pal/tests/palsuite/threading/ReleaseMutex/test3/CMakeLists.txt b/src/pal/tests/palsuite/threading/ReleaseMutex/test3/CMakeLists.txt deleted file mode 100644 index f8f0d8fb8..000000000 --- a/src/pal/tests/palsuite/threading/ReleaseMutex/test3/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - ReleaseMutex.cpp -) - -add_executable(paltest_releasemutex_test3 - ${SOURCES} -) - -add_dependencies(paltest_releasemutex_test3 coreclrpal) - -target_link_libraries(paltest_releasemutex_test3 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/ReleaseMutex/test3/ReleaseMutex.cpp b/src/pal/tests/palsuite/threading/ReleaseMutex/test3/ReleaseMutex.cpp deleted file mode 100644 index 5f6adb041..000000000 --- a/src/pal/tests/palsuite/threading/ReleaseMutex/test3/ReleaseMutex.cpp +++ /dev/null @@ -1,103 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source: ReleaseMutex/test3/ReleaseMutex.c -** -** Purpose: Test failure code for ReleaseMutex. -** -** Dependencies: CreateMutex -** ReleaseMutex -** CreateThread -** - -** -**=========================================================*/ - -#include - -DWORD dwTestResult; /* global for test result */ - -DWORD dwThreadId; /* consumer thread identifier */ - -HANDLE hMutex; /* handle to mutex */ - -HANDLE hThread; /* handle to thread */ - -/* - * Thread function. - */ -DWORD -PALAPI -ThreadFunction( LPVOID lpNoArg ) -{ - - dwTestResult = ReleaseMutex(hMutex); - - return 0; -} - -int __cdecl main (int argc, char **argv) -{ - - if(0 != (PAL_Initialize(argc, argv))) - { - return (FAIL); - } - - /* - * set dwTestResult so test fails even if ReleaseMutex is not called - */ - dwTestResult = 1; - - /* - * Create mutex - */ - hMutex = CreateMutexW ( - NULL, - TRUE, - NULL); - - if ( NULL == hMutex ) - { - Fail ( "hMutex = CreateMutex () - returned NULL\n" - "Failing Test.\nGetLastError returned %d\n", GetLastError()); - } - - /* - * Create ThreadFunction - */ - hThread = CreateThread( - NULL, - 0, - ThreadFunction, - NULL, - 0, - &dwThreadId); - - if ( NULL == hThread ) - { - - Fail ( "CreateThread() returned NULL. Failing test.\n" - "GetLastError returned %d\n", GetLastError()); - } - - /* - * Wait for ThreadFunction to complete - */ - WaitForSingleObject (hThread, INFINITE); - - if (dwTestResult) - { - Fail ("ReleaseMutex() test was expected to return 0.\n" - "It returned %d. Failing test.\n", dwTestResult ); - } - - Trace ("ReleaseMutex() test returned 0.\nTest passed.\n"); - - PAL_Terminate(); - return ( PASS ); - -} diff --git a/src/pal/tests/palsuite/threading/ReleaseMutex/test3/testinfo.dat b/src/pal/tests/palsuite/threading/ReleaseMutex/test3/testinfo.dat deleted file mode 100644 index 3f06757eb..000000000 --- a/src/pal/tests/palsuite/threading/ReleaseMutex/test3/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = threading -Function = ReleaseMutex -Name = Positive Test for ReleaseMutex -TYPE = DEFAULT -EXE1 = releasemutex -Description -= Calls ReleaseMutex from a thread which should not have ownership of the -= mutex. If ReleaseMutex fails correctly this test will succeed. diff --git a/src/pal/tests/palsuite/threading/ResetEvent/CMakeLists.txt b/src/pal/tests/palsuite/threading/ResetEvent/CMakeLists.txt deleted file mode 100644 index a3847f8ca..000000000 --- a/src/pal/tests/palsuite/threading/ResetEvent/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) -add_subdirectory(test3) -add_subdirectory(test4) - diff --git a/src/pal/tests/palsuite/threading/ResetEvent/test1/CMakeLists.txt b/src/pal/tests/palsuite/threading/ResetEvent/test1/CMakeLists.txt deleted file mode 100644 index 769c1f382..000000000 --- a/src/pal/tests/palsuite/threading/ResetEvent/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_resetevent_test1 - ${SOURCES} -) - -add_dependencies(paltest_resetevent_test1 coreclrpal) - -target_link_libraries(paltest_resetevent_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/ResetEvent/test1/test1.cpp b/src/pal/tests/palsuite/threading/ResetEvent/test1/test1.cpp deleted file mode 100644 index 20a0d5dff..000000000 --- a/src/pal/tests/palsuite/threading/ResetEvent/test1/test1.cpp +++ /dev/null @@ -1,99 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source: test1.c -** -** Purpose: Test for ResetEvent. Create an event with an intial -** state signaled. Then reset that signal, and check to see that -** the event is now not signaled. -** -** -**=========================================================*/ - -#include - -BOOL ResetEventTest() -{ - BOOL bRet = FALSE; - DWORD dwRet = 0; - - LPSECURITY_ATTRIBUTES lpEventAttributes = 0; - BOOL bManualReset = TRUE; - BOOL bInitialState = TRUE; - - /* Create an Event, ensure it is valid */ - HANDLE hEvent = CreateEvent( lpEventAttributes, - bManualReset, bInitialState, NULL); - - if (hEvent != INVALID_HANDLE_VALUE) - { - /* Check that WaitFor returns WAIT_OBJECT_0, indicating that - the event is signaled. - */ - - dwRet = WaitForSingleObject(hEvent,0); - - if (dwRet != WAIT_OBJECT_0) - { - Fail("ResetEventTest:WaitForSingleObject failed (%x)\n", GetLastError()); - } - else - { - /* Call ResetEvent, which will reset the signal */ - bRet = ResetEvent(hEvent); - - if (!bRet) - { - Fail("ResetEventTest:ResetEvent failed (%x)\n", GetLastError()); - } - else - { - /* Call WaitFor again, and since it has been reset, - the return value should now be WAIT_TIMEOUT - */ - dwRet = WaitForSingleObject(hEvent,0); - - if (dwRet != WAIT_TIMEOUT) - { - Fail("ResetEventTest:WaitForSingleObject %s failed (%x)\n", GetLastError()); - } - else - { - bRet = CloseHandle(hEvent); - - if (!bRet) - { - Fail("ResetEventTest:CloseHandle failed (%x)\n", GetLastError()); - } - } - } - } - } - else - { - Fail("ResetEventTest:CreateEvent failed (%x)\n", GetLastError()); - } - - return bRet; -} - -int __cdecl main(int argc, char **argv) -{ - - if(0 != (PAL_Initialize(argc, argv))) - { - return ( FAIL ); - } - - if(!ResetEventTest()) - { - Fail ("Test failed\n"); - } - - PAL_Terminate(); - return ( PASS ); - -} diff --git a/src/pal/tests/palsuite/threading/ResetEvent/test1/testinfo.dat b/src/pal/tests/palsuite/threading/ResetEvent/test1/testinfo.dat deleted file mode 100644 index ed27f13db..000000000 --- a/src/pal/tests/palsuite/threading/ResetEvent/test1/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = threading -Function = ResetEvent -Name = Positive Test for ResetEvent -TYPE = DEFAULT -EXE1 = test1 -Description -= Test for ResetEvent. Create an event with an intial -= state signaled. Then reset that signal, and check to see that -= the event is now not signaled. diff --git a/src/pal/tests/palsuite/threading/ResetEvent/test2/CMakeLists.txt b/src/pal/tests/palsuite/threading/ResetEvent/test2/CMakeLists.txt deleted file mode 100644 index 69c7b7cc6..000000000 --- a/src/pal/tests/palsuite/threading/ResetEvent/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test2.cpp -) - -add_executable(paltest_resetevent_test2 - ${SOURCES} -) - -add_dependencies(paltest_resetevent_test2 coreclrpal) - -target_link_libraries(paltest_resetevent_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/ResetEvent/test2/test2.cpp b/src/pal/tests/palsuite/threading/ResetEvent/test2/test2.cpp deleted file mode 100644 index 8117f4435..000000000 --- a/src/pal/tests/palsuite/threading/ResetEvent/test2/test2.cpp +++ /dev/null @@ -1,89 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================= -** -** Source: test2.c -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** CreateEvent -** CloseHandle -** WaitForSingleObject -** -** Purpose: Test to ensure proper operation of the ResetEvent() -** API by calling it on an event handle that's already -** unsignalled. -** - -** -**===========================================================================*/ -#include - - - -int __cdecl main( int argc, char **argv ) - -{ - /* local variables */ - DWORD dwRet = 0; - HANDLE hEvent = NULL; - LPSECURITY_ATTRIBUTES lpEventAttributes = NULL; - BOOL bManualReset = TRUE; - BOOL bInitialState = FALSE; - - - /* PAL initialization */ - if( (PAL_Initialize(argc, argv)) != 0 ) - { - return( FAIL ); - } - - - /* create an unsignalled event which we can use with ResetEvent */ - hEvent = CreateEvent( lpEventAttributes, - bManualReset, - bInitialState, - NULL ); - - if( hEvent == INVALID_HANDLE_VALUE ) - { - /* ERROR */ - Fail( "ERROR:%lu:CreateEvent() call failed\n", GetLastError() ); - } - - /* verify that the event isn't signalled yet */ - dwRet = WaitForSingleObject( hEvent, 0 ); - if( dwRet != WAIT_TIMEOUT ) - { - /* ERROR */ - Trace( "ERROR:WaitForSingleObject() call returned %lu, " - "expected WAIT_TIMEOUT\n", - dwRet ); - CloseHandle( hEvent ); - Fail( "Test failed\n" ); - } - - /* try to reset the event */ - if( ! ResetEvent( hEvent ) ) - { - /* ERROR */ - Trace( "FAIL:%lu:ResetEvent() call failed\n", GetLastError() ); - CloseHandle( hEvent ); - Fail( "Test failed\n" ); - } - - /* close the event handle */ - if( ! CloseHandle( hEvent ) ) - { - Fail( "ERROR:%lu:CloseHandle() call failed\n", GetLastError() ); - } - - - /* PAL termination */ - PAL_Terminate(); - - /* return success */ - return PASS; -} diff --git a/src/pal/tests/palsuite/threading/ResetEvent/test2/testinfo.dat b/src/pal/tests/palsuite/threading/ResetEvent/test2/testinfo.dat deleted file mode 100644 index 4af1769cd..000000000 --- a/src/pal/tests/palsuite/threading/ResetEvent/test2/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = threading -Function = ResetEvent -Name = Positive test for ResetEvent -TYPE = DEFAULT -EXE1 = test2 -Description -= Test to ensure proper operation of the ResetEvent() -= API by calling it on an event handle that's already -= unsignalled. diff --git a/src/pal/tests/palsuite/threading/ResetEvent/test3/CMakeLists.txt b/src/pal/tests/palsuite/threading/ResetEvent/test3/CMakeLists.txt deleted file mode 100644 index acb31489c..000000000 --- a/src/pal/tests/palsuite/threading/ResetEvent/test3/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test3.cpp -) - -add_executable(paltest_resetevent_test3 - ${SOURCES} -) - -add_dependencies(paltest_resetevent_test3 coreclrpal) - -target_link_libraries(paltest_resetevent_test3 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/ResetEvent/test3/test3.cpp b/src/pal/tests/palsuite/threading/ResetEvent/test3/test3.cpp deleted file mode 100644 index 9bc068ea7..000000000 --- a/src/pal/tests/palsuite/threading/ResetEvent/test3/test3.cpp +++ /dev/null @@ -1,86 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================= -** -** Source: test3.c -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** CreateEvent -** CloseHandle -** -** Purpose: -** -** Test to ensure proper operation of the ResetEvent() -** API by calling it on an event handle that's been -** closed. We expect it to return an appropriate error -** result. -** -** - -** -**===========================================================================*/ -#include - - - -int __cdecl main( int argc, char **argv ) - -{ - /* local variables */ - HANDLE hEvent = NULL; - LPSECURITY_ATTRIBUTES lpEventAttributes = NULL; - BOOL bManualReset = TRUE; - BOOL bInitialState = FALSE; - - - /* PAL initialization */ - if( (PAL_Initialize(argc, argv)) != 0 ) - { - return( FAIL ); - } - - - /* create an event which we can use with ResetEvent */ - hEvent = CreateEvent( lpEventAttributes, - bManualReset, - bInitialState, - NULL ); - - if( hEvent == INVALID_HANDLE_VALUE ) - { - /* ERROR */ - Fail( "ERROR:%lu:CreateEvent() call failed\n", GetLastError() ); - } - - /* close the event handle */ - if( ! CloseHandle( hEvent ) ) - { - Fail( "ERROR:%lu:CloseHandle() call failed\n", GetLastError() ); - } - - /* try to reset the event */ - if( ResetEvent( hEvent ) ) - { - /* ERROR */ - Fail( "FAIL:ResetEvent() call succeeded on a closed event handle\n" ); - } - - /* verify the result of GetLastError() */ - if( GetLastError() != ERROR_INVALID_HANDLE ) - { - /* ERROR */ - Fail( "FAIL:ResetEvent() call failed on a closed event handle " - "but returned an unexpected error result %lu\n" ); - } - - - - /* PAL termination */ - PAL_Terminate(); - - /* return success */ - return PASS; -} diff --git a/src/pal/tests/palsuite/threading/ResetEvent/test3/testinfo.dat b/src/pal/tests/palsuite/threading/ResetEvent/test3/testinfo.dat deleted file mode 100644 index 4abeeded0..000000000 --- a/src/pal/tests/palsuite/threading/ResetEvent/test3/testinfo.dat +++ /dev/null @@ -1,15 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = threading -Function = ResetEvent -Name = Negative test for ResetEvent -TYPE = DEFAULT -EXE1 = test3 -Description -= Test to ensure proper operation of the ResetEvent() -= API by calling it on an event handle that's been -= closed. We expect it to return an appropriate error -= result. diff --git a/src/pal/tests/palsuite/threading/ResetEvent/test4/CMakeLists.txt b/src/pal/tests/palsuite/threading/ResetEvent/test4/CMakeLists.txt deleted file mode 100644 index d20135a04..000000000 --- a/src/pal/tests/palsuite/threading/ResetEvent/test4/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test4.cpp -) - -add_executable(paltest_resetevent_test4 - ${SOURCES} -) - -add_dependencies(paltest_resetevent_test4 coreclrpal) - -target_link_libraries(paltest_resetevent_test4 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/ResetEvent/test4/test4.cpp b/src/pal/tests/palsuite/threading/ResetEvent/test4/test4.cpp deleted file mode 100644 index 0cc68fd9a..000000000 --- a/src/pal/tests/palsuite/threading/ResetEvent/test4/test4.cpp +++ /dev/null @@ -1,161 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================= -** -** Source: test4.c -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** CreateEvent -** CloseHandle -** WaitForSingleObject -** DuplicateHandle -** GetCurrentProcess -** -** Purpose: -** -** Test to ensure proper operation of the ResetEvent() -** API by calling it on an event handle that's the -** result of a DuplicateHandle() call on another event -** handle. -** - -** -**===========================================================================*/ -#include - - - -int __cdecl main( int argc, char **argv ) - -{ - /* local variables */ - DWORD dwRet = 0; - HANDLE hEvent = NULL; - HANDLE hDupEvent = NULL; - LPSECURITY_ATTRIBUTES lpEventAttributes = NULL; - BOOL bManualReset = TRUE; - BOOL bInitialState = TRUE; - - - /* PAL initialization */ - if( (PAL_Initialize(argc, argv)) != 0 ) - { - return( FAIL ); - } - - - /* create an event which we can use with ResetEvent */ - hEvent = CreateEvent( lpEventAttributes, - bManualReset, - bInitialState, - NULL ); - - if( hEvent == INVALID_HANDLE_VALUE ) - { - /* ERROR */ - Fail( "ERROR:%lu:CreateEvent() call failed\n", GetLastError() ); - } - - /* verify that the event is signalled already */ - dwRet = WaitForSingleObject( hEvent, 0 ); - if( dwRet != WAIT_OBJECT_0 ) - { - /* ERROR */ - Trace( "ERROR:WaitForSingleObject() call returned %lu, " - "expected WAIT_OBJECT_0\n", - dwRet ); - CloseHandle( hEvent ); - Fail( "Test failed\n" ); - } - - - /* duplicate the event handle */ - if( ! (DuplicateHandle( - GetCurrentProcess(), - hEvent, - GetCurrentProcess(), - &hDupEvent, - GENERIC_READ|GENERIC_WRITE, /* ignored in PAL */ - FALSE, - DUPLICATE_SAME_ACCESS ) ) ) - { - Trace("ERROR:%u:DuplicateHandle() call failed\n", - GetLastError() ); - CloseHandle( hEvent ); - Fail("Test failed\n"); - } - - /* verify that the event is signalled with the duplicate handle */ - dwRet = WaitForSingleObject( hDupEvent, 0 ); - if( dwRet != WAIT_OBJECT_0 ) - { - /* ERROR */ - Trace( "ERROR:WaitForSingleObject() call returned %lu, " - "expected WAIT_OBJECT_0\n", - dwRet ); - CloseHandle( hEvent ); - CloseHandle( hDupEvent ); - Fail( "Test failed\n" ); - } - - - /* reset the event using the duplicate handle */ - if( ! ResetEvent( hDupEvent ) ) - { - /* ERROR */ - Trace( "ERROR:%lu:ResetEvent() call failed\n", GetLastError() ); - CloseHandle( hEvent ); - CloseHandle( hDupEvent ); - Fail( "Test failed\n" ); - } - - /* verify that the event isn't signalled using the duplicate handle*/ - dwRet = WaitForSingleObject( hDupEvent, 0 ); - if( dwRet != WAIT_TIMEOUT ) - { - /* ERROR */ - Trace( "ERROR:WaitForSingleObject() call returned %lu, " - "expected WAIT_TIMEOUT\n", - dwRet ); - CloseHandle( hEvent ); - Fail( "Test failed\n" ); - } - - /* check that the event isn't signalled using the original event handle */ - dwRet = WaitForSingleObject( hEvent, 0 ); - if( dwRet != WAIT_TIMEOUT ) - { - /* ERROR */ - Trace( "ERROR:WaitForSingleObject() call returned %lu, " - "expected WAIT_TIMEOUT\n", - dwRet ); - CloseHandle( hEvent ); - Fail( "Test failed\n" ); - } - - - /* close the duplicate event handle */ - if( ! CloseHandle( hDupEvent ) ) - { - Fail( "ERROR:%lu:CloseHandle() call failed for duplicate handle\n", - GetLastError() ); - } - - - /* close the event handle */ - if( ! CloseHandle( hEvent ) ) - { - Fail( "ERROR:%lu:CloseHandle() call failed for original handle\n", - GetLastError() ); - } - - - /* PAL termination */ - PAL_Terminate(); - - /* return success */ - return PASS; -} diff --git a/src/pal/tests/palsuite/threading/ResetEvent/test4/testinfo.dat b/src/pal/tests/palsuite/threading/ResetEvent/test4/testinfo.dat deleted file mode 100644 index 0223246c6..000000000 --- a/src/pal/tests/palsuite/threading/ResetEvent/test4/testinfo.dat +++ /dev/null @@ -1,15 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = threading -Function = ResetEvent -Name = Positive test for ResetEvent -TYPE = DEFAULT -EXE1 = test4 -Description -= Test to ensure proper operation of the ResetEvent() -= API by calling it on an event handle that's the -= result of a DuplicateHandle() call on another event -= handle. diff --git a/src/pal/tests/palsuite/threading/ResumeThread/CMakeLists.txt b/src/pal/tests/palsuite/threading/ResumeThread/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/threading/ResumeThread/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/threading/ResumeThread/test1/CMakeLists.txt b/src/pal/tests/palsuite/threading/ResumeThread/test1/CMakeLists.txt deleted file mode 100644 index 0321a28b8..000000000 --- a/src/pal/tests/palsuite/threading/ResumeThread/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_resumethread_test1 - ${SOURCES} -) - -add_dependencies(paltest_resumethread_test1 coreclrpal) - -target_link_libraries(paltest_resumethread_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/ResumeThread/test1/test1.cpp b/src/pal/tests/palsuite/threading/ResumeThread/test1/test1.cpp deleted file mode 100644 index d2be262e4..000000000 --- a/src/pal/tests/palsuite/threading/ResumeThread/test1/test1.cpp +++ /dev/null @@ -1,141 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source: test1.c -** -** Purpose: Test for ResumeThread. Create a suspended Thread. -** First, ensure that it is indeed suspended. Then call resumethread -** and check to ensure that the function has now run. -** -** -**=========================================================*/ - -#include - -DWORD dwResumeThreadTestParameter = 0; - -DWORD PALAPI ResumeThreadTestThread( LPVOID lpParameter) -{ - DWORD dwRet = 0; - - /* Save parameter so we can check and ensure this function ran - properly. - */ - - dwResumeThreadTestParameter = (DWORD)lpParameter; - - return dwRet; -} - -BOOL ResumeThreadTest() -{ - BOOL bRet = FALSE; - DWORD dwRet = 0; - - LPSECURITY_ATTRIBUTES lpThreadAttributes = NULL; - DWORD dwStackSize = 0; - LPTHREAD_START_ROUTINE lpStartAddress = &ResumeThreadTestThread; - LPVOID lpParameter = (LPVOID)lpStartAddress; - DWORD dwCreationFlags = CREATE_SUSPENDED; - DWORD dwThreadId = 0; - - HANDLE hThread = 0; - - dwResumeThreadTestParameter = 0; - - /* Create a thread, with CREATE_SUSPENDED, so we can resume it! */ - - hThread = CreateThread( lpThreadAttributes, - dwStackSize, lpStartAddress, lpParameter, - dwCreationFlags, &dwThreadId ); - - if (hThread != INVALID_HANDLE_VALUE) - { - /* Wait for one second. This should return WAIT_TIMEOUT */ - dwRet = WaitForSingleObject(hThread,1000); - - if (dwRet != WAIT_TIMEOUT) - { - Trace("ResumeThreadTest:WaitForSingleObject " - "failed (%x)\n",GetLastError()); - } - else - { - /* Check to ensure the parameter hasn't changed. The - function shouldn't have occurred yet. - */ - if (dwResumeThreadTestParameter != 0) - { - Trace("ResumeThreadTest:parameter error\n"); - } - else - { - /* Call ResumeThread and ensure the return value is - correct. - */ - - dwRet = ResumeThread(hThread); - - if (dwRet != 1) - { - Trace("ResumeThreadTest:ResumeThread " - "failed (%x)\n",GetLastError()); - } - else - { - /* Wait again, now that the thread has been - resumed, and the return should be WAIT_OBJECT_0 - */ - dwRet = WaitForSingleObject(hThread,INFINITE); - - if (dwRet != WAIT_OBJECT_0) - { - Trace("ResumeThreadTest:WaitForSingleObject " - "failed (%x)\n",GetLastError()); - } - else - { - /* Check the param now and it should have been - set. - */ - if (dwResumeThreadTestParameter != (DWORD)lpParameter) - { - Trace("ResumeThreadTest:parameter error\n"); - } - else - { - bRet = TRUE; - } - } - } - } - } - } - else - { - Trace("ResumeThreadTest:CreateThread failed (%x)\n",GetLastError()); - } - - return bRet; -} - -int __cdecl main(int argc, char **argv) -{ - - if(0 != (PAL_Initialize(argc, argv))) - { - return ( FAIL ); - } - - if(!ResumeThreadTest()) - { - Fail("Test Failed\n"); - } - - PAL_Terminate(); - return (PASS); - -} diff --git a/src/pal/tests/palsuite/threading/ResumeThread/test1/testinfo.dat b/src/pal/tests/palsuite/threading/ResumeThread/test1/testinfo.dat deleted file mode 100644 index 8472165d5..000000000 --- a/src/pal/tests/palsuite/threading/ResumeThread/test1/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = threading -Function = ResumeThread -Name = Positive Test for ResumeThread -TYPE = DEFAULT -EXE1 = test1 -Description -= Test for ResumeThread. Create a suspended Thread. -= First, ensure that it is indeed suspended. Then call resumethread -= and check to ensure that the function has now run. diff --git a/src/pal/tests/palsuite/threading/SetErrorMode/CMakeLists.txt b/src/pal/tests/palsuite/threading/SetErrorMode/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/threading/SetErrorMode/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/threading/SetErrorMode/test1/CMakeLists.txt b/src/pal/tests/palsuite/threading/SetErrorMode/test1/CMakeLists.txt deleted file mode 100644 index ff90b41ab..000000000 --- a/src/pal/tests/palsuite/threading/SetErrorMode/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_seterrormode_test1 - ${SOURCES} -) - -add_dependencies(paltest_seterrormode_test1 coreclrpal) - -target_link_libraries(paltest_seterrormode_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/SetErrorMode/test1/test1.cpp b/src/pal/tests/palsuite/threading/SetErrorMode/test1/test1.cpp deleted file mode 100644 index 238cec442..000000000 --- a/src/pal/tests/palsuite/threading/SetErrorMode/test1/test1.cpp +++ /dev/null @@ -1,50 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test1.c (SetErrorMode) -** -** Purpose: Tests the PAL implementation of the SetErrorMode function. -** This test will set the error mode and then read the error -** set with GetLastError(). -** -** -**===================================================================*/ - -#include - -int __cdecl main(int argc, char **argv) -{ - DWORD dErrorReturn; - UINT dErrorModes[] = {SEM_NOOPENFILEERRORBOX, SEM_FAILCRITICALERRORS, 0}; - int i; - - /* - * Initialize the Pal - */ - if ((PAL_Initialize(argc,argv)) != 0) - { - return (FAIL); - } - - /* - * Loop through the supported Error Modes and verify - * that GetLastError() returns the correct Error Mode - */ - for (i=0; i < (sizeof(dErrorModes) / sizeof(UINT)); i++) - { - SetLastError(dErrorModes[i]); - if ((dErrorReturn = GetLastError()) != dErrorModes[i]) - { - Fail("ERROR: SetLastError was set to 0x%4.4x but," - " GetLastError returned 0x%4.4x\n", - dErrorModes[i], - dErrorReturn); - } - } - - PAL_Terminate(); - return (PASS); -} diff --git a/src/pal/tests/palsuite/threading/SetErrorMode/test1/testinfo.dat b/src/pal/tests/palsuite/threading/SetErrorMode/test1/testinfo.dat deleted file mode 100644 index 875ac2a22..000000000 --- a/src/pal/tests/palsuite/threading/SetErrorMode/test1/testinfo.dat +++ /dev/null @@ -1,16 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = Threading -Function = SetErrorMode -Name = Positive Test for SetErrorMode -TYPE = DEFAULT -EXE1 = test1 -Description -= Tests the PAL implementation of the SetErrorMode function. -= This test will set the error mode and then read the error -= set with GetLastError(). - - diff --git a/src/pal/tests/palsuite/threading/SetEvent/CMakeLists.txt b/src/pal/tests/palsuite/threading/SetEvent/CMakeLists.txt deleted file mode 100644 index a3847f8ca..000000000 --- a/src/pal/tests/palsuite/threading/SetEvent/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) -add_subdirectory(test3) -add_subdirectory(test4) - diff --git a/src/pal/tests/palsuite/threading/SetEvent/test1/CMakeLists.txt b/src/pal/tests/palsuite/threading/SetEvent/test1/CMakeLists.txt deleted file mode 100644 index 56081c181..000000000 --- a/src/pal/tests/palsuite/threading/SetEvent/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_setevent_test1 - ${SOURCES} -) - -add_dependencies(paltest_setevent_test1 coreclrpal) - -target_link_libraries(paltest_setevent_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/SetEvent/test1/test1.cpp b/src/pal/tests/palsuite/threading/SetEvent/test1/test1.cpp deleted file mode 100644 index d5a29ce3f..000000000 --- a/src/pal/tests/palsuite/threading/SetEvent/test1/test1.cpp +++ /dev/null @@ -1,94 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source: test1.c -** -** Purpose: Test for SetEvent. Create an Event and then set -** this event, checking the return value. Ensure that it returns -** positive. -** -** -**=========================================================*/ - -#include - -BOOL SetEventTest() -{ - int bRet = 0; - DWORD dwRet = 0; - - LPSECURITY_ATTRIBUTES lpEventAttributes = 0; - BOOL bManualReset = TRUE; - BOOL bInitialState = FALSE; - - /* Create an event which we can use with SetEvent */ - HANDLE hEvent = CreateEvent( lpEventAttributes, - bManualReset, bInitialState, NULL); - - if (hEvent != INVALID_HANDLE_VALUE) - { - dwRet = WaitForSingleObject(hEvent,0); - - if (dwRet != WAIT_TIMEOUT) - { - Trace("SetEventTest:WaitForSingleObject failed (%x)\n", GetLastError()); - } - else - { - /* Set the event to the previously created event and check - the return value. - */ - bRet = SetEvent(hEvent); - - if (!bRet) - { - Trace("SetEventTest:SetEvent failed (%x)\n", GetLastError()); - } - else - { - dwRet = WaitForSingleObject(hEvent,0); - - if (dwRet != WAIT_OBJECT_0) - { - Trace("SetEventTest:WaitForSingleObject failed (%x)\n", GetLastError()); - } - else - { - dwRet = CloseHandle(hEvent); - - if (!dwRet) - { - Trace("SetEventTest:CloseHandle failed (%x)\n", GetLastError()); - } - } - } - } - } - else - { - Trace("SetEventTest:CreateEvent failed (%x)\n", GetLastError()); - } - - return bRet; -} - - -int __cdecl main(int argc, char **argv) -{ - if(0 != (PAL_Initialize(argc, argv))) - { - return ( FAIL ); - } - - if(SetEventTest() == 0) - { - Fail ("Test failed\n"); - } - - PAL_Terminate(); - return ( PASS ); - -} diff --git a/src/pal/tests/palsuite/threading/SetEvent/test1/testinfo.dat b/src/pal/tests/palsuite/threading/SetEvent/test1/testinfo.dat deleted file mode 100644 index 9bfd80829..000000000 --- a/src/pal/tests/palsuite/threading/SetEvent/test1/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = threading -Function = SetEvent -Name = Positive Test for SetEvent -TYPE = DEFAULT -EXE1 = test1 -Description -=Test for SetEvent. Create an Event and then set -=this event, checking the return value. Ensure that it returns -=positive. diff --git a/src/pal/tests/palsuite/threading/SetEvent/test2/CMakeLists.txt b/src/pal/tests/palsuite/threading/SetEvent/test2/CMakeLists.txt deleted file mode 100644 index f94fb486b..000000000 --- a/src/pal/tests/palsuite/threading/SetEvent/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test2.cpp -) - -add_executable(paltest_setevent_test2 - ${SOURCES} -) - -add_dependencies(paltest_setevent_test2 coreclrpal) - -target_link_libraries(paltest_setevent_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/SetEvent/test2/test2.cpp b/src/pal/tests/palsuite/threading/SetEvent/test2/test2.cpp deleted file mode 100644 index 5fd283395..000000000 --- a/src/pal/tests/palsuite/threading/SetEvent/test2/test2.cpp +++ /dev/null @@ -1,125 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================= -** -** Source: test2.c -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** CreateEvent -** CloseHandle -** WaitForSingleObject -** -** Purpose: -** -** Test to ensure proper operation of the SetEvent() -** API by calling it on an event handle that's already set. -** - -** -**===========================================================================*/ -#include - - - -int __cdecl main( int argc, char **argv ) - -{ - /* local variables */ - DWORD dwRet = 0; - HANDLE hEvent = NULL; - LPSECURITY_ATTRIBUTES lpEventAttributes = NULL; - BOOL bManualReset = TRUE; - BOOL bInitialState = FALSE; - - - /* PAL initialization */ - if( (PAL_Initialize(argc, argv)) != 0 ) - { - return( FAIL ); - } - - - /* create an event which we can use with SetEvent */ - hEvent = CreateEvent( lpEventAttributes, - bManualReset, - bInitialState, - NULL ); - - if( hEvent == INVALID_HANDLE_VALUE ) - { - /* ERROR */ - Fail( "ERROR:%lu:CreateEvent() call failed\n", GetLastError() ); - } - - /* verify that the event isn't signalled yet */ - dwRet = WaitForSingleObject( hEvent, 0 ); - if( dwRet != WAIT_TIMEOUT ) - { - /* ERROR */ - Trace( "ERROR:WaitForSingleObject() call returned %lu, " - "expected WAIT_TIMEOUT\n", - dwRet ); - CloseHandle( hEvent ); - Fail( "Test failed\n" ); - } - - /* set the event */ - if( ! SetEvent( hEvent ) ) - { - /* ERROR */ - Trace( "ERROR:%lu:SetEvent() call failed\n", GetLastError() ); - CloseHandle( hEvent ); - Fail( "Test failed\n" ); - } - - /* verify that the event is signalled */ - dwRet = WaitForSingleObject( hEvent, 0 ); - if( dwRet != WAIT_OBJECT_0 ) - { - /* ERROR */ - Trace( "ERROR:WaitForSingleObject() call returned %lu, " - "expected WAIT_OBJECT_0\n", - dwRet ); - CloseHandle( hEvent ); - Fail( "Test failed\n" ); - } - - /* try to set the event again */ - if( ! SetEvent( hEvent ) ) - { - /* ERROR */ - Trace( "FAIL:%lu:SetEvent() call failed on signalled event\n", - GetLastError() ); - CloseHandle( hEvent ); - Fail( "Test failed\n" ); - } - - /* verify that the event is still signalled */ - dwRet = WaitForSingleObject( hEvent, 0 ); - if( dwRet != WAIT_OBJECT_0 ) - { - /* ERROR */ - Trace( "ERROR:WaitForSingleObject() call returned %lu, " - "expected WAIT_OBJECT_0\n", - dwRet ); - CloseHandle( hEvent ); - Fail( "Test failed\n" ); - } - - - /* close the event handle */ - if( ! CloseHandle( hEvent ) ) - { - Fail( "ERROR:%lu:CloseHandle() call failed\n", GetLastError() ); - } - - - /* PAL termination */ - PAL_Terminate(); - - /* return success */ - return PASS; -} diff --git a/src/pal/tests/palsuite/threading/SetEvent/test2/testinfo.dat b/src/pal/tests/palsuite/threading/SetEvent/test2/testinfo.dat deleted file mode 100644 index f2153052b..000000000 --- a/src/pal/tests/palsuite/threading/SetEvent/test2/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = threading -Function = SetEvent -Name = Positive test for SetEvent -TYPE = DEFAULT -EXE1 = test2 -Description -= Test to ensure proper operation of the SetEvent() -= API by calling it on an event handle that's already set. diff --git a/src/pal/tests/palsuite/threading/SetEvent/test3/CMakeLists.txt b/src/pal/tests/palsuite/threading/SetEvent/test3/CMakeLists.txt deleted file mode 100644 index c2d48ba48..000000000 --- a/src/pal/tests/palsuite/threading/SetEvent/test3/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test3.cpp -) - -add_executable(paltest_setevent_test3 - ${SOURCES} -) - -add_dependencies(paltest_setevent_test3 coreclrpal) - -target_link_libraries(paltest_setevent_test3 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/SetEvent/test3/test3.cpp b/src/pal/tests/palsuite/threading/SetEvent/test3/test3.cpp deleted file mode 100644 index 21601f00b..000000000 --- a/src/pal/tests/palsuite/threading/SetEvent/test3/test3.cpp +++ /dev/null @@ -1,85 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================= -** -** Source: test3.c -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** CreateEvent -** CloseHandle -** -** Purpose: -** -** Test to ensure proper operation of the SetEvent() -** API by calling it on an event handle that's been -** closed. We expect it to return an appropriate error -** result. -** - -** -**===========================================================================*/ -#include - - - -int __cdecl main( int argc, char **argv ) - -{ - /* local variables */ - HANDLE hEvent = NULL; - LPSECURITY_ATTRIBUTES lpEventAttributes = NULL; - BOOL bManualReset = TRUE; - BOOL bInitialState = FALSE; - - - /* PAL initialization */ - if( (PAL_Initialize(argc, argv)) != 0 ) - { - return( FAIL ); - } - - - /* create an event which we can use with SetEvent */ - hEvent = CreateEvent( lpEventAttributes, - bManualReset, - bInitialState, - NULL ); - - if( hEvent == INVALID_HANDLE_VALUE ) - { - /* ERROR */ - Fail( "ERROR:%lu:CreateEvent() call failed\n", GetLastError() ); - } - - /* close the event handle */ - if( ! CloseHandle( hEvent ) ) - { - Fail( "ERROR:%lu:CloseHandle() call failed\n", GetLastError() ); - } - - /* try to set the event */ - if( SetEvent( hEvent ) ) - { - /* ERROR */ - Fail( "FAIL:SetEvent() call succeeded on a closed event handle\n" ); - } - - /* verify the result of GetLastError() */ - if( GetLastError() != ERROR_INVALID_HANDLE ) - { - /* ERROR */ - Fail( "FAIL:SetEvent() call failed on a closed event handle" - "but returned an unexpected error result %lu\n" ); - } - - - - /* PAL termination */ - PAL_Terminate(); - - /* return success */ - return PASS; -} diff --git a/src/pal/tests/palsuite/threading/SetEvent/test3/testinfo.dat b/src/pal/tests/palsuite/threading/SetEvent/test3/testinfo.dat deleted file mode 100644 index 7b8f43013..000000000 --- a/src/pal/tests/palsuite/threading/SetEvent/test3/testinfo.dat +++ /dev/null @@ -1,15 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = threading -Function = SetEvent -Name = Negative test for SetEvent -TYPE = DEFAULT -EXE1 = test3 -Description -= Test to ensure proper operation of the SetEvent() -= API by calling it on an event handle that's been -= closed. We expect it to return an appropriate error -= result. diff --git a/src/pal/tests/palsuite/threading/SetEvent/test4/CMakeLists.txt b/src/pal/tests/palsuite/threading/SetEvent/test4/CMakeLists.txt deleted file mode 100644 index ae8adecb9..000000000 --- a/src/pal/tests/palsuite/threading/SetEvent/test4/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test4.cpp -) - -add_executable(paltest_setevent_test4 - ${SOURCES} -) - -add_dependencies(paltest_setevent_test4 coreclrpal) - -target_link_libraries(paltest_setevent_test4 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/SetEvent/test4/test4.cpp b/src/pal/tests/palsuite/threading/SetEvent/test4/test4.cpp deleted file mode 100644 index 7a79a9d70..000000000 --- a/src/pal/tests/palsuite/threading/SetEvent/test4/test4.cpp +++ /dev/null @@ -1,161 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================= -** -** Source: test4.c -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** CreateEvent -** CloseHandle -** WaitForSingleObject -** DuplicateHandle -** GetCurrentProcess -** -** Purpose: -** -** Test to ensure proper operation of the SetEvent() -** API by calling it on an event handle that's the -** result of a DuplicateHandle() call on another event -** handle. -** - -** -**===========================================================================*/ -#include - - - -int __cdecl main( int argc, char **argv ) - -{ - /* local variables */ - DWORD dwRet = 0; - HANDLE hEvent = NULL; - HANDLE hDupEvent = NULL; - LPSECURITY_ATTRIBUTES lpEventAttributes = NULL; - BOOL bManualReset = TRUE; - BOOL bInitialState = FALSE; - - - /* PAL initialization */ - if( (PAL_Initialize(argc, argv)) != 0 ) - { - return( FAIL ); - } - - - /* create an event which we can use with SetEvent */ - hEvent = CreateEvent( lpEventAttributes, - bManualReset, - bInitialState, - NULL ); - - if( hEvent == INVALID_HANDLE_VALUE ) - { - /* ERROR */ - Fail( "ERROR:%lu:CreateEvent() call failed\n", GetLastError() ); - } - - /* verify that the event isn't signalled yet */ - dwRet = WaitForSingleObject( hEvent, 0 ); - if( dwRet != WAIT_TIMEOUT ) - { - /* ERROR */ - Trace( "ERROR:WaitForSingleObject() call returned %lu, " - "expected WAIT_TIMEOUT\n", - dwRet ); - CloseHandle( hEvent ); - Fail( "Test failed\n" ); - } - - - /* duplicate the event handle */ - if( ! (DuplicateHandle( - GetCurrentProcess(), - hEvent, - GetCurrentProcess(), - &hDupEvent, - GENERIC_READ|GENERIC_WRITE, /* ignored in PAL */ - FALSE, - DUPLICATE_SAME_ACCESS ) ) ) - { - Trace("ERROR:%u:DuplicateHandle() call failed\n", - GetLastError() ); - CloseHandle( hEvent ); - Fail("Test failed\n"); - } - - /* verify that the event isn't signalled yet with the duplicate handle */ - dwRet = WaitForSingleObject( hDupEvent, 0 ); - if( dwRet != WAIT_TIMEOUT ) - { - /* ERROR */ - Trace( "ERROR:WaitForSingleObject() call returned %lu, " - "expected WAIT_TIMEOUT\n", - dwRet ); - CloseHandle( hEvent ); - CloseHandle( hDupEvent ); - Fail( "Test failed\n" ); - } - - - /* set the event using the duplicate handle */ - if( ! SetEvent( hDupEvent ) ) - { - /* ERROR */ - Trace( "ERROR:%lu:SetEvent() call failed\n", GetLastError() ); - CloseHandle( hEvent ); - CloseHandle( hDupEvent ); - Fail( "Test failed\n" ); - } - - /* verify that the event is signalled using the duplicate handle*/ - dwRet = WaitForSingleObject( hDupEvent, 0 ); - if( dwRet != WAIT_OBJECT_0 ) - { - /* ERROR */ - Trace( "ERROR:WaitForSingleObject() call returned %lu, " - "expected WAIT_OBJECT_0\n", - dwRet ); - CloseHandle( hEvent ); - Fail( "Test failed\n" ); - } - - /* verify that the event is signalled using the original event handle */ - dwRet = WaitForSingleObject( hEvent, 0 ); - if( dwRet != WAIT_OBJECT_0 ) - { - /* ERROR */ - Trace( "ERROR:WaitForSingleObject() call returned %lu, " - "expected WAIT_OBJECT_0\n", - dwRet ); - CloseHandle( hEvent ); - Fail( "Test failed\n" ); - } - - - /* close the duplicate event handle */ - if( ! CloseHandle( hDupEvent ) ) - { - Fail( "ERROR:%lu:CloseHandle() call failed for duplicate handle\n", - GetLastError() ); - } - - - /* close the event handle */ - if( ! CloseHandle( hEvent ) ) - { - Fail( "ERROR:%lu:CloseHandle() call failed for original handle\n", - GetLastError() ); - } - - - /* PAL termination */ - PAL_Terminate(); - - /* return success */ - return PASS; -} diff --git a/src/pal/tests/palsuite/threading/SetEvent/test4/testinfo.dat b/src/pal/tests/palsuite/threading/SetEvent/test4/testinfo.dat deleted file mode 100644 index 9a7f7ddb3..000000000 --- a/src/pal/tests/palsuite/threading/SetEvent/test4/testinfo.dat +++ /dev/null @@ -1,15 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = threading -Function = SetEvent -Name = Positive test for SetEvent -TYPE = DEFAULT -EXE1 = test4 -Description -= Test to ensure proper operation of the SetEvent() -= API by calling it on an event handle that's the -= result of a DuplicateHandle() call on another event -= handle. diff --git a/src/pal/tests/palsuite/threading/SignalObjectAndWait/CMakeLists.txt b/src/pal/tests/palsuite/threading/SignalObjectAndWait/CMakeLists.txt deleted file mode 100644 index 464386c5b..000000000 --- a/src/pal/tests/palsuite/threading/SignalObjectAndWait/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - SignalObjectAndWaitTest.cpp -) - -add_executable(paltest_signalobjectandwaittest - ${SOURCES} -) - -add_dependencies(paltest_signalobjectandwaittest coreclrpal) - -target_link_libraries(paltest_signalobjectandwaittest - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/SignalObjectAndWait/SignalObjectAndWaitTest.cpp b/src/pal/tests/palsuite/threading/SignalObjectAndWait/SignalObjectAndWaitTest.cpp deleted file mode 100644 index 9ec1ed3dc..000000000 --- a/src/pal/tests/palsuite/threading/SignalObjectAndWait/SignalObjectAndWaitTest.cpp +++ /dev/null @@ -1,414 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#include - -enum class SignalableObjectType -{ - First = 0, - - Invalid = First, - ManualResetEvent, - AutoResetEvent, - Semaphore, - FullSemaphore, - Mutex, - UnlockedMutex, - - Last = UnlockedMutex -}; - -enum class WaitableObjectType -{ - First = 0, - - Invalid = First, - ManualResetEvent, - UnsignaledManualResetEvent, - AutoResetEvent, - UnsignaledAutoResetEvent, - Semaphore, - EmptySemaphore, - Mutex, - LockedMutex, - - Last = LockedMutex -}; - -void operator ++(SignalableObjectType &objectType) -{ - ++(int &)objectType; -} - -void operator ++(WaitableObjectType &objectType) -{ - ++(int &)objectType; -} - -struct AssertionFailureException -{ - const int lineNumber; - const char *const expression; - SignalableObjectType signalableObjectType; - WaitableObjectType waitableObjectType; - DWORD waitResult; - DWORD errorCode; - - AssertionFailureException(int lineNumber, const char *expression) - : lineNumber(lineNumber), - expression(expression), - signalableObjectType(SignalableObjectType::Invalid), - waitableObjectType(WaitableObjectType::Invalid), - waitResult(WAIT_OBJECT_0), - errorCode(ERROR_SUCCESS) - { - } -}; - -#define TestAssert(expression) \ - do \ - { \ - if (!(expression)) \ - { \ - throw AssertionFailureException(__LINE__, "" #expression ""); \ - } \ - } while (false) - -HANDLE CreateObjectToSignal(SignalableObjectType objectType) -{ - switch (objectType) - { - case SignalableObjectType::Invalid: - return nullptr; - - case SignalableObjectType::ManualResetEvent: - return CreateEvent(nullptr, true, false, nullptr); - - case SignalableObjectType::AutoResetEvent: - return CreateEvent(nullptr, false, false, nullptr); - - case SignalableObjectType::Semaphore: - return CreateSemaphore(nullptr, 0, 1, nullptr); - - case SignalableObjectType::FullSemaphore: - return CreateSemaphore(nullptr, 1, 1, nullptr); - - case SignalableObjectType::Mutex: - return CreateMutex(nullptr, true, nullptr); - - case SignalableObjectType::UnlockedMutex: - return CreateMutex(nullptr, false, nullptr); - - default: - TestAssert(false); - } -} - -void VerifySignal(HANDLE h, SignalableObjectType objectType) -{ - switch (objectType) - { - case SignalableObjectType::ManualResetEvent: - TestAssert(WaitForSingleObject(h, 0) == WAIT_OBJECT_0); - break; - - case SignalableObjectType::AutoResetEvent: - TestAssert(WaitForSingleObject(h, 0) == WAIT_OBJECT_0); - SetEvent(h); - break; - - case SignalableObjectType::Semaphore: - TestAssert(!ReleaseSemaphore(h, 1, nullptr)); - break; - - case SignalableObjectType::Mutex: - TestAssert(!ReleaseMutex(h)); - break; - - default: - TestAssert(false); - } -} - -void CloseObjectToSignal(HANDLE h, SignalableObjectType objectType) -{ - if (objectType != SignalableObjectType::Invalid) - { - CloseHandle(h); - } -} - -HANDLE CreateObjectToWaitOn(WaitableObjectType objectType) -{ - switch (objectType) - { - case WaitableObjectType::Invalid: - return nullptr; - - case WaitableObjectType::ManualResetEvent: - return CreateEvent(nullptr, true, true, nullptr); - - case WaitableObjectType::UnsignaledManualResetEvent: - return CreateEvent(nullptr, true, false, nullptr); - - case WaitableObjectType::AutoResetEvent: - return CreateEvent(nullptr, false, true, nullptr); - - case WaitableObjectType::UnsignaledAutoResetEvent: - return CreateEvent(nullptr, false, false, nullptr); - - case WaitableObjectType::Semaphore: - return CreateSemaphore(nullptr, 1, 1, nullptr); - - case WaitableObjectType::EmptySemaphore: - return CreateSemaphore(nullptr, 0, 1, nullptr); - - case WaitableObjectType::Mutex: - return CreateMutex(nullptr, false, nullptr); - - case WaitableObjectType::LockedMutex: - return CreateMutex(nullptr, true, nullptr); - - default: - TestAssert(false); - } -} - -void VerifyWait(HANDLE h, WaitableObjectType objectType) -{ - switch (objectType) - { - case WaitableObjectType::ManualResetEvent: - case WaitableObjectType::UnsignaledManualResetEvent: - break; - - case WaitableObjectType::AutoResetEvent: - case WaitableObjectType::UnsignaledAutoResetEvent: - case WaitableObjectType::Semaphore: - case WaitableObjectType::EmptySemaphore: - TestAssert(WaitForSingleObject(h, 0) == WAIT_TIMEOUT); - break; - - case WaitableObjectType::Mutex: - TestAssert(ReleaseMutex(h)); - TestAssert(!ReleaseMutex(h)); - TestAssert(WaitForSingleObject(h, 0) == WAIT_OBJECT_0); - break; - - case WaitableObjectType::LockedMutex: - TestAssert(ReleaseMutex(h)); - TestAssert(ReleaseMutex(h)); - TestAssert(!ReleaseMutex(h)); - TestAssert(WaitForSingleObject(h, 0) == WAIT_OBJECT_0); - TestAssert(WaitForSingleObject(h, 0) == WAIT_OBJECT_0); - break; - - default: - TestAssert(false); - } -} - -void CloseObjectToWaitOn(HANDLE h, WaitableObjectType objectType) -{ - switch (objectType) - { - case WaitableObjectType::ManualResetEvent: - case WaitableObjectType::UnsignaledManualResetEvent: - case WaitableObjectType::AutoResetEvent: - case WaitableObjectType::UnsignaledAutoResetEvent: - CloseHandle(h); - break; - - case WaitableObjectType::Semaphore: - case WaitableObjectType::EmptySemaphore: - ReleaseSemaphore(h, 1, nullptr); - CloseHandle(h); - break; - - case WaitableObjectType::Mutex: - ReleaseMutex(h); - CloseHandle(h); - break; - - case WaitableObjectType::LockedMutex: - ReleaseMutex(h); - ReleaseMutex(h); - CloseHandle(h); - break; - - default: - break; - } -} - -bool Verify(SignalableObjectType signalableObjectType, WaitableObjectType waitableObjectType, DWORD waitResult, DWORD errorCode) -{ - if (signalableObjectType == SignalableObjectType::Invalid || waitableObjectType == WaitableObjectType::Invalid) - { - TestAssert(waitResult == WAIT_FAILED); - TestAssert(errorCode == ERROR_INVALID_HANDLE); - return false; - } - - switch (signalableObjectType) - { - case SignalableObjectType::FullSemaphore: - TestAssert(waitResult == WAIT_FAILED); - TestAssert(errorCode == ERROR_TOO_MANY_POSTS); - return false; - - case SignalableObjectType::UnlockedMutex: - TestAssert(waitResult == WAIT_FAILED); - TestAssert(errorCode == ERROR_NOT_OWNER); - return false; - - default: - break; - } - - switch (waitableObjectType) - { - case WaitableObjectType::UnsignaledManualResetEvent: - case WaitableObjectType::UnsignaledAutoResetEvent: - case WaitableObjectType::EmptySemaphore: - TestAssert(waitResult == WAIT_TIMEOUT); - break; - - default: - TestAssert(waitResult == WAIT_OBJECT_0); - break; - } - TestAssert(errorCode == ERROR_SUCCESS); - return true; -} - -void Run(SignalableObjectType signalableObjectType, WaitableObjectType waitableObjectType) -{ - HANDLE objectToSignal = CreateObjectToSignal(signalableObjectType); - TestAssert(signalableObjectType == SignalableObjectType::Invalid || objectToSignal != nullptr); - HANDLE objectToWaitOn = CreateObjectToWaitOn(waitableObjectType); - TestAssert(waitableObjectType == WaitableObjectType::Invalid || objectToWaitOn != nullptr); - DWORD waitResult = SignalObjectAndWait(objectToSignal, objectToWaitOn, 0, true); - DWORD errorCode = waitResult == WAIT_FAILED ? GetLastError() : ERROR_SUCCESS; - - try - { - if (Verify(signalableObjectType, waitableObjectType, waitResult, errorCode)) - { - VerifySignal(objectToSignal, signalableObjectType); - VerifyWait(objectToWaitOn, waitableObjectType); - } - } - catch (AssertionFailureException ex) - { - ex.signalableObjectType = signalableObjectType; - ex.waitableObjectType = waitableObjectType; - ex.waitResult = waitResult; - ex.errorCode = errorCode; - throw ex; - } -} - -static bool s_apcCalled = false; - -void CALLBACK ApcCallback(ULONG_PTR dwParam) -{ - s_apcCalled = true; - HANDLE *objects = (HANDLE *)dwParam; - HANDLE objectToSignal = objects[0]; - HANDLE objectToWaitOn = objects[1]; - TestAssert(WaitForSingleObject(objectToSignal, 0) == WAIT_OBJECT_0); // signal has occurred - TestAssert(WaitForSingleObject(objectToWaitOn, 0) == WAIT_OBJECT_0); // wait has not occurred yet - SetEvent(objectToWaitOn); -} - -void Run() -{ - for (SignalableObjectType signalableObjectType = SignalableObjectType::First; - signalableObjectType <= SignalableObjectType::Last; - ++signalableObjectType) - { - for (WaitableObjectType waitableObjectType = WaitableObjectType::First; - waitableObjectType <= WaitableObjectType::Last; - ++waitableObjectType) - { - Run(signalableObjectType, waitableObjectType); - } - } - - DWORD waitResult = WAIT_FAILED; - try - { - HANDLE objectToSignal = CreateObjectToSignal(SignalableObjectType::ManualResetEvent); - TestAssert(objectToSignal != nullptr); - HANDLE objectToWaitOn = CreateObjectToWaitOn(WaitableObjectType::AutoResetEvent); - TestAssert(objectToWaitOn != nullptr); - HANDLE objects[] = {objectToSignal, objectToWaitOn}; - - // Verify that a queued APC is not called if the wait is not alertable - QueueUserAPC(&ApcCallback, GetCurrentThread(), (ULONG_PTR)&objects); - waitResult = SignalObjectAndWait(objectToSignal, objectToWaitOn, 0, false); - TestAssert(waitResult == WAIT_OBJECT_0); - TestAssert(!s_apcCalled); - TestAssert(WaitForSingleObject(objectToSignal, 0) == WAIT_OBJECT_0); // signal has occurred - TestAssert(WaitForSingleObject(objectToWaitOn, 0) == WAIT_TIMEOUT); // wait has occurred - - // Verify that signal, call APC, wait, occur in that order - ResetEvent(objectToSignal); - SetEvent(objectToWaitOn); - waitResult = SignalObjectAndWait(objectToSignal, objectToWaitOn, 0, true); - TestAssert(waitResult == WAIT_IO_COMPLETION); - TestAssert(s_apcCalled); - TestAssert(WaitForSingleObject(objectToSignal, 0) == WAIT_OBJECT_0); // signal has occurred - TestAssert(WaitForSingleObject(objectToWaitOn, 0) == WAIT_OBJECT_0); // wait has not occurred yet - s_apcCalled = false; - ResetEvent(objectToSignal); - SetEvent(objectToWaitOn); - waitResult = SignalObjectAndWait(objectToSignal, objectToWaitOn, 0, true); - TestAssert(waitResult == WAIT_OBJECT_0); - TestAssert(!s_apcCalled); - TestAssert(WaitForSingleObject(objectToSignal, 0) == WAIT_OBJECT_0); // signal has occurred - TestAssert(WaitForSingleObject(objectToWaitOn, 0) == WAIT_TIMEOUT); // wait has occurred - - CloseHandle(objectToSignal); - CloseHandle(objectToWaitOn); - } - catch (AssertionFailureException ex) - { - ex.signalableObjectType = SignalableObjectType::ManualResetEvent; - ex.waitableObjectType = WaitableObjectType::AutoResetEvent; - ex.waitResult = waitResult; - throw ex; - } -} - -int _cdecl main(int argc, char **argv) -{ - if (PAL_Initialize(argc, argv) != 0) - { - return FAIL; - } - - int testReturnCode = PASS; - try - { - Run(); - } - catch (AssertionFailureException ex) - { - printf( - "SignalObjectAndWaitTest - Assertion failure (line %d, signalable object type %d, waitable object type %d, wait result 0x%x, error code %u): '%s'\n", - ex.lineNumber, - ex.signalableObjectType, - ex.waitableObjectType, - ex.waitResult, - ex.errorCode, - ex.expression); - fflush(stdout); - testReturnCode = FAIL; - } - - PAL_TerminateEx(testReturnCode); - return testReturnCode; -} diff --git a/src/pal/tests/palsuite/threading/Sleep/CMakeLists.txt b/src/pal/tests/palsuite/threading/Sleep/CMakeLists.txt deleted file mode 100644 index ef14ea535..000000000 --- a/src/pal/tests/palsuite/threading/Sleep/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) - diff --git a/src/pal/tests/palsuite/threading/Sleep/test1/CMakeLists.txt b/src/pal/tests/palsuite/threading/Sleep/test1/CMakeLists.txt deleted file mode 100644 index ec9d04f53..000000000 --- a/src/pal/tests/palsuite/threading/Sleep/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - Sleep.cpp -) - -add_executable(paltest_sleep_test1 - ${SOURCES} -) - -add_dependencies(paltest_sleep_test1 coreclrpal) - -target_link_libraries(paltest_sleep_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/Sleep/test1/Sleep.cpp b/src/pal/tests/palsuite/threading/Sleep/test1/Sleep.cpp deleted file mode 100644 index f7f7c9173..000000000 --- a/src/pal/tests/palsuite/threading/Sleep/test1/Sleep.cpp +++ /dev/null @@ -1,80 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source: Sleep.c -** -** Purpose: Test to establish whether the Sleep function stops the thread from -** executing for the specified times. -** -** Dependencies: GetSystemTime -** Fail -** Trace -** - -** -**=========================================================*/ - -#include - -DWORD SleepTimes[] = -{ - 0, - 50, - 100, - 500, - 2000 -}; - -/* Milliseconds of error which are acceptable Function execution time, etc. */ -DWORD AcceptableTimeError = 150; - -int __cdecl main( int argc, char **argv ) -{ - UINT64 OldTimeStamp; - UINT64 NewTimeStamp; - DWORD MaxDelta; - DWORD TimeDelta; - DWORD i; - - if(0 != (PAL_Initialize(argc, argv))) - { - return ( FAIL ); - } - - LARGE_INTEGER performanceFrequency; - if (!QueryPerformanceFrequency(&performanceFrequency)) - { - return FAIL; - } - - for( i = 0; i < sizeof(SleepTimes) / sizeof(DWORD); i++) - { - OldTimeStamp = GetHighPrecisionTimeStamp(performanceFrequency); - Sleep(SleepTimes[i]); - NewTimeStamp = GetHighPrecisionTimeStamp(performanceFrequency); - - TimeDelta = NewTimeStamp - OldTimeStamp; - - /* For longer intervals use a 10 percent tolerance */ - if ((SleepTimes[i] * 0.1) > AcceptableTimeError) - { - MaxDelta = SleepTimes[i] + (DWORD)(SleepTimes[i] * 0.1); - } - else - { - MaxDelta = SleepTimes[i] + AcceptableTimeError; - } - - if ( TimeDeltaMaxDelta ) - { - Fail("The sleep function slept for %d ms when it should have " - "slept for %d ms\n", TimeDelta, SleepTimes[i]); - } - } - PAL_Terminate(); - return ( PASS ); - -} diff --git a/src/pal/tests/palsuite/threading/Sleep/test1/testinfo.dat b/src/pal/tests/palsuite/threading/Sleep/test1/testinfo.dat deleted file mode 100644 index 433a061f2..000000000 --- a/src/pal/tests/palsuite/threading/Sleep/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = threading -Function = Sleep -Name = Positive Test for Sleep -TYPE = DEFAULT -EXE1 = sleep -Description -= Test to see if the Sleep function stops the thread from executing for the -= specified amount of time. diff --git a/src/pal/tests/palsuite/threading/Sleep/test2/CMakeLists.txt b/src/pal/tests/palsuite/threading/Sleep/test2/CMakeLists.txt deleted file mode 100644 index b24f5e280..000000000 --- a/src/pal/tests/palsuite/threading/Sleep/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - sleep.cpp -) - -add_executable(paltest_sleep_test2 - ${SOURCES} -) - -add_dependencies(paltest_sleep_test2 coreclrpal) - -target_link_libraries(paltest_sleep_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/Sleep/test2/sleep.cpp b/src/pal/tests/palsuite/threading/Sleep/test2/sleep.cpp deleted file mode 100644 index eb30e34f2..000000000 --- a/src/pal/tests/palsuite/threading/Sleep/test2/sleep.cpp +++ /dev/null @@ -1,73 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source: Sleep.c -** -** Purpose: Test to establish whether the Sleep function stops the thread from -** executing for the specified times. -** -** Dependencies: GetTickCount -** - -** -**=========================================================*/ - -#include - -/* - * times in 10^(-3) seconds - */ - -DWORD SleepTimes[] = -{ - 60000, - 300000, - 1800000, - 3200000 -}; - -/* Milliseconds of error which are acceptable Function execution time, etc. */ -DWORD AcceptableTimeError = 150; - -int __cdecl main( int argc, char **argv ) -{ - UINT64 OldTimeStamp; - UINT64 NewTimeStamp; - DWORD MaxDelta; - DWORD TimeDelta; - DWORD i; - - if(0 != (PAL_Initialize(argc, argv))) - { - return ( FAIL ); - } - - LARGE_INTEGER performanceFrequency; - if (!QueryPerformanceFrequency(&performanceFrequency)) - { - return FAIL; - } - - for( i = 0; i < sizeof(SleepTimes) / sizeof(DWORD); i++) - { - OldTimeStamp = GetHighPrecisionTimeStamp(performanceFrequency); - Sleep(SleepTimes[i]); - NewTimeStamp = GetHighPrecisionTimeStamp(performanceFrequency); - - TimeDelta = NewTimeStamp - OldTimeStamp; - - MaxDelta = SleepTimes[i] + AcceptableTimeError; - - if ( TimeDeltaMaxDelta ) - { - Fail("The sleep function slept for %u ms when it should have " - "slept for %u ms\n", TimeDelta, SleepTimes[i]); - } - } - PAL_Terminate(); - return ( PASS ); - -} diff --git a/src/pal/tests/palsuite/threading/Sleep/test2/testinfo.dat b/src/pal/tests/palsuite/threading/Sleep/test2/testinfo.dat deleted file mode 100644 index 433a061f2..000000000 --- a/src/pal/tests/palsuite/threading/Sleep/test2/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = threading -Function = Sleep -Name = Positive Test for Sleep -TYPE = DEFAULT -EXE1 = sleep -Description -= Test to see if the Sleep function stops the thread from executing for the -= specified amount of time. diff --git a/src/pal/tests/palsuite/threading/SleepEx/CMakeLists.txt b/src/pal/tests/palsuite/threading/SleepEx/CMakeLists.txt deleted file mode 100644 index ef14ea535..000000000 --- a/src/pal/tests/palsuite/threading/SleepEx/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) - diff --git a/src/pal/tests/palsuite/threading/SleepEx/test1/CMakeLists.txt b/src/pal/tests/palsuite/threading/SleepEx/test1/CMakeLists.txt deleted file mode 100644 index cf240d7f1..000000000 --- a/src/pal/tests/palsuite/threading/SleepEx/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_sleepex_test1 - ${SOURCES} -) - -add_dependencies(paltest_sleepex_test1 coreclrpal) - -target_link_libraries(paltest_sleepex_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/SleepEx/test1/test1.cpp b/src/pal/tests/palsuite/threading/SleepEx/test1/test1.cpp deleted file mode 100644 index 7ccfe0ce8..000000000 --- a/src/pal/tests/palsuite/threading/SleepEx/test1/test1.cpp +++ /dev/null @@ -1,89 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test1.c -** -** Purpose: Tests that SleepEx correctly sleeps for a given amount of time, -** regardless of the alertable flag. -** -** -**===================================================================*/ - -#include - -typedef struct -{ - DWORD SleepTime; - BOOL Alertable; -} testCase; - -testCase testCases[] = -{ - {0, FALSE}, - {50, FALSE}, - {100, FALSE}, - {500, FALSE}, - {2000, FALSE}, - - {0, TRUE}, - {50, TRUE}, - {100, TRUE}, - {500, TRUE}, - {2000, TRUE}, -}; - -/* Milliseconds of error which are acceptable Function execution time, etc. */ -DWORD AcceptableTimeError = 150; - -int __cdecl main( int argc, char **argv ) -{ - UINT64 OldTimeStamp; - UINT64 NewTimeStamp; - DWORD MaxDelta; - DWORD TimeDelta; - DWORD i; - - if (0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - LARGE_INTEGER performanceFrequency; - if (!QueryPerformanceFrequency(&performanceFrequency)) - { - return FAIL; - } - - for (i = 0; i AcceptableTimeError) - { - MaxDelta = testCases[i].SleepTime + (DWORD)(testCases[i].SleepTime * 0.1); - } - else - { - MaxDelta = testCases[i].SleepTime + AcceptableTimeError; - } - - if (TimeDelta < testCases[i].SleepTime || TimeDelta > MaxDelta) - { - Fail("The sleep function slept for %d ms when it should have " - "slept for %d ms\n", TimeDelta, testCases[i].SleepTime); - } - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/threading/SleepEx/test1/testinfo.dat b/src/pal/tests/palsuite/threading/SleepEx/test1/testinfo.dat deleted file mode 100644 index 124276874..000000000 --- a/src/pal/tests/palsuite/threading/SleepEx/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = threading -Function = SleepEx -Name = Test #1 for SleepEx -TYPE = DEFAULT -EXE1 = test1 -Description -=Tests that SleepEx correctly sleeps for a given amount of time, -=regardless of the alertable flag. diff --git a/src/pal/tests/palsuite/threading/SleepEx/test2/CMakeLists.txt b/src/pal/tests/palsuite/threading/SleepEx/test2/CMakeLists.txt deleted file mode 100644 index 6762ec78d..000000000 --- a/src/pal/tests/palsuite/threading/SleepEx/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test2.cpp -) - -add_executable(paltest_sleepex_test2 - ${SOURCES} -) - -add_dependencies(paltest_sleepex_test2 coreclrpal) - -target_link_libraries(paltest_sleepex_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/SleepEx/test2/test2.cpp b/src/pal/tests/palsuite/threading/SleepEx/test2/test2.cpp deleted file mode 100644 index c2ba4e704..000000000 --- a/src/pal/tests/palsuite/threading/SleepEx/test2/test2.cpp +++ /dev/null @@ -1,183 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test2.c -** -** Purpose: Tests that a child thread in the middle of a SleepEx call will be -** interrupted by QueueUserAPC if the alert flag was set. -** -** -**===================================================================*/ - -#include - -const int ChildThreadSleepTime = 2000; -const int InterruptTime = 1000; -/* We need to keep in mind that BSD has a timer resolution of 10ms, so - we need to adjust our delta to keep that in mind. Besides we need some - tolerance to account for different scheduling strategies, heavy load - scenarios, etc. - - Real-world data also tells us we can expect a big difference between - values when run on real iron vs run in a hypervisor. - - Thread-interruption times when run on bare metal will typically yield - around 0ms on Linux and between 0 and 16ms on FreeBSD. However, when run - in a hypervisor (like VMWare ESXi) we may get values around an order of - magnitude higher, up to 110 ms for some tests. -*/ -const DWORD AcceptableDelta = 150; - -const int Iterations = 5; - -void RunTest(BOOL AlertThread); -VOID PALAPI APCFunc(ULONG_PTR dwParam); -DWORD PALAPI SleeperProc(LPVOID lpParameter); - -DWORD ThreadSleepDelta; - -int __cdecl main( int argc, char **argv ) -{ - int i; - DWORD dwAvgDelta; - - if (0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - /* - On some platforms (e.g. FreeBSD 4.9) the first call to some synch objects - (such as conditions) involves some pthread internal initialization that - can make the first wait slighty longer, potentially going above the - acceptable delta for this test. Let's add a dummy wait to preinitialize - internal structures - */ - Sleep(100); - - /* - * Check that Queueing an APC in the middle of a sleep does interrupt - * it, if it's in an alertable state. - */ - dwAvgDelta = 0; - for (i=0;i AcceptableDelta) - { - Fail("Expected thread to sleep for %d ms (and get interrupted).\n" - "Average delta: %u ms, acceptable delta: %u\n", - InterruptTime, dwAvgDelta, AcceptableDelta); - } - - /* - * Check that Queueing an APC in the middle of a sleep does NOT interrupt - * it, if it is not in an alertable state. - */ - dwAvgDelta = 0; - for (i=0;i AcceptableDelta) - { - Fail("Expected thread to sleep for %d ms (and not be interrupted).\n" - "Average delta: %u ms, acceptable delta: %u\n", - ChildThreadSleepTime, dwAvgDelta, AcceptableDelta); - } - - PAL_Terminate(); - return PASS; -} - -void RunTest(BOOL AlertThread) -{ - HANDLE hThread = 0; - DWORD dwThreadId = 0; - int ret; - - hThread = CreateThread( NULL, - 0, - (LPTHREAD_START_ROUTINE)SleeperProc, - (LPVOID) AlertThread, - 0, - &dwThreadId); - - if (hThread == NULL) - { - Fail("ERROR: Was not able to create the thread to test SleepEx!\n" - "GetLastError returned %d\n", GetLastError()); - } - - if (SleepEx(InterruptTime, FALSE) != 0) - { - Fail("The creating thread did not sleep!\n"); - } - - ret = QueueUserAPC(APCFunc, hThread, 0); - if (ret == 0) - { - Fail("QueueUserAPC failed! GetLastError returned %d\n", GetLastError()); - } - - ret = WaitForSingleObject(hThread, INFINITE); - if (ret == WAIT_FAILED) - { - Fail("Unable to wait on child thread!\nGetLastError returned %d.", - GetLastError()); - } -} - -/* Function doesn't do anything, just needed to interrupt SleepEx */ -VOID PALAPI APCFunc(ULONG_PTR dwParam) -{ - -} - -/* Entry Point for child thread. */ -DWORD PALAPI SleeperProc(LPVOID lpParameter) -{ - UINT64 OldTimeStamp; - UINT64 NewTimeStamp; - BOOL Alertable; - DWORD ret; - - Alertable = (BOOL) lpParameter; - - LARGE_INTEGER performanceFrequency; - if (!QueryPerformanceFrequency(&performanceFrequency)) - { - return FAIL; - } - - OldTimeStamp = GetHighPrecisionTimeStamp(performanceFrequency); - - ret = SleepEx(ChildThreadSleepTime, Alertable); - - NewTimeStamp = GetHighPrecisionTimeStamp(performanceFrequency); - - if (Alertable && ret != WAIT_IO_COMPLETION) - { - Fail("Expected the interrupted sleep to return WAIT_IO_COMPLETION.\n" - "Got %d\n", ret); - } - else if (!Alertable && ret != 0) - { - Fail("Sleep did not timeout. Expected return of 0, got %d.\n", ret); - } - - - ThreadSleepDelta = NewTimeStamp - OldTimeStamp; - - return 0; -} diff --git a/src/pal/tests/palsuite/threading/SleepEx/test2/testinfo.dat b/src/pal/tests/palsuite/threading/SleepEx/test2/testinfo.dat deleted file mode 100644 index 52f3ce0af..000000000 --- a/src/pal/tests/palsuite/threading/SleepEx/test2/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = threading -Function = SleepEx -Name = Test #2 for SleepEx -TYPE = DEFAULT -EXE1 = test2 -Description -=Tests that a child thread in the middle of a SleepEx call will be -=interrupted by QueueUserAPC if the alert flag was set. - diff --git a/src/pal/tests/palsuite/threading/SwitchToThread/CMakeLists.txt b/src/pal/tests/palsuite/threading/SwitchToThread/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/threading/SwitchToThread/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/threading/SwitchToThread/test1/CMakeLists.txt b/src/pal/tests/palsuite/threading/SwitchToThread/test1/CMakeLists.txt deleted file mode 100644 index 18390a605..000000000 --- a/src/pal/tests/palsuite/threading/SwitchToThread/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_switchtothread_test1 - ${SOURCES} -) - -add_dependencies(paltest_switchtothread_test1 coreclrpal) - -target_link_libraries(paltest_switchtothread_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/SwitchToThread/test1/test1.cpp b/src/pal/tests/palsuite/threading/SwitchToThread/test1/test1.cpp deleted file mode 100644 index 76ecdd357..000000000 --- a/src/pal/tests/palsuite/threading/SwitchToThread/test1/test1.cpp +++ /dev/null @@ -1,97 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================= -** -** Source: test1.c -** -** Purpose: Test to ensure SwitchToThread works, without -** causing test to hang -** -** Dependencies: PAL_Initialize -** Fail -** SwitchToThread -** WaitForMultipleObject -** CreateThread -** GetLastError -** - -** -**===========================================================================*/ - - -#include -#define THREAD_COUNT 10 -#define REPEAT_COUNT 1000 -#define TIMEOUT 60000 -void PALAPI Run_Thread(LPVOID lpParam); - -/** - * main - * - * executable entry point - */ -INT __cdecl main( INT argc, CHAR **argv ) -{ - DWORD dwParam; - HANDLE hThread[THREAD_COUNT]; - DWORD threadId[THREAD_COUNT]; - - int i = 0; - int returnCode = 0; - - /*PAL initialization */ - if( (PAL_Initialize(argc, argv)) != 0 ) - { - return FAIL; - } - - - for( i = 0; i < THREAD_COUNT; i++ ) - { - dwParam = (int) i; - //Create thread - hThread[i] = CreateThread( - NULL, /* no security attributes */ - 0, /* use default stack size */ - (LPTHREAD_START_ROUTINE)Run_Thread,/* thread function */ - (LPVOID)dwParam, /* argument to thread function */ - 0, /* use default creation flags */ - &threadId[i] /* returns the thread identifier*/ - ); - - if(hThread[i] == NULL) - { - Fail("Create Thread failed for iteration %d GetLastError value is %d\n", i, GetLastError()); - } - - } - - - returnCode = WaitForMultipleObjects(THREAD_COUNT, hThread, TRUE, TIMEOUT); - if( WAIT_OBJECT_0 != returnCode ) - { - Trace("Wait for Object(s) returned %d, expected value is %d, and GetLastError value is %d\n", returnCode, WAIT_OBJECT_0, GetLastError()); - } - - PAL_Terminate(); - return PASS; - -} - -void PALAPI Run_Thread (LPVOID lpParam) -{ - int i = 0; - int Id=(int)lpParam; - - for(i=0; i < REPEAT_COUNT; i++ ) - { - // No Last Error is set.. - if(!SwitchToThread()) - { - Trace( "The operating system did not switch execution to another thread," - "for thread id[%d], iteration [%d]\n", Id, i ); - } - } -} diff --git a/src/pal/tests/palsuite/threading/SwitchToThread/test1/testinfo.dat b/src/pal/tests/palsuite/threading/SwitchToThread/test1/testinfo.dat deleted file mode 100644 index 15ee8d4d4..000000000 --- a/src/pal/tests/palsuite/threading/SwitchToThread/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = threading -Function = SwitchToThread -Name = Test for SwitchToThread -TYPE = DEFAULT -EXE1 = test -Description -= Purpose: Test to ensure SwitchToThread is -= working properly on supported platforms diff --git a/src/pal/tests/palsuite/threading/TLS/CMakeLists.txt b/src/pal/tests/palsuite/threading/TLS/CMakeLists.txt deleted file mode 100644 index bffdf7f71..000000000 --- a/src/pal/tests/palsuite/threading/TLS/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) -add_subdirectory(test3) -add_subdirectory(test4) -add_subdirectory(test5) - - diff --git a/src/pal/tests/palsuite/threading/TLS/test1/CMakeLists.txt b/src/pal/tests/palsuite/threading/TLS/test1/CMakeLists.txt deleted file mode 100644 index 85795fa2e..000000000 --- a/src/pal/tests/palsuite/threading/TLS/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - TLS.cpp -) - -add_executable(paltest_tls_test1 - ${SOURCES} -) - -add_dependencies(paltest_tls_test1 coreclrpal) - -target_link_libraries(paltest_tls_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/TLS/test1/TLS.cpp b/src/pal/tests/palsuite/threading/TLS/test1/TLS.cpp deleted file mode 100644 index 4300c3f98..000000000 --- a/src/pal/tests/palsuite/threading/TLS/test1/TLS.cpp +++ /dev/null @@ -1,182 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================= -** -** Source: tls.c -** -** Purpose: Test to ensure TlsAlloc, TlsGetValue, TlsSetValue -** and TlsFree are working properly together. -** -** Dependencies: PAL_Initialize -** Fail -** Sleep -** LocalAlloc -** LocalFree -** WaitForSingleObject -** CreateThread -** GetLastError -** - -** -**===========================================================================*/ -#include - -#define NUM_OF_THREADS 10 - -DWORD dwTlsIndex; /* TLS index */ - -/** - * CommonFunction - * - * Helper function that calls TlsGetValue - */ -VOID CommonFunction(VOID) -{ - LPVOID lpvData; - DWORD dwError; - - /* Retrieve a data pointer for the current thread. */ - lpvData = TlsGetValue(dwTlsIndex); - - if ( (lpvData == 0) && - ((dwError = GetLastError()) != NO_ERROR) ) - {/*ERROR */ - Fail("TlsGetValue(%d) returned 0 with error %d\n", - dwTlsIndex, - dwError); - } - - Sleep(5000); -} - -/** - * ThreadFunc - * - * Thread function that stores a value in the thread's tls slot - * for the predefined tls index - */ -DWORD PALAPI ThreadFunc(LPVOID lpThreadParameter) -{ - LPVOID lpvData; - DWORD dwError; - - /* Initialize the TLS index for this thread.*/ - lpvData = (LPVOID) LocalAlloc(0, 256); - - if( lpvData == NULL ) - {/*ERROR */ - dwError = GetLastError(); - Fail("Unexpected LocalAlloc(0, 256) failure with error %d\n", - dwError); - } - - - if ( TlsSetValue(dwTlsIndex, lpvData) == 0 ) - {/*ERROR */ - dwError = GetLastError(); - Fail("TlsSetValue(%d, %x) returned 0 with error %d\n", - dwTlsIndex, - lpvData, - dwError); - } - - CommonFunction(); - - /* Release the dynamic memory. */ - lpvData = TlsGetValue(dwTlsIndex); - - if ( (lpvData == 0) && - ((dwError = GetLastError()) != NO_ERROR) ) - {/*ERROR */ - Fail("TlsGetValue(%d) returned 0 with error %d\n", - dwTlsIndex, - dwError); - } - else - { - if( LocalFree((HLOCAL) lpvData) != NULL ) - { - dwError = GetLastError(); - Fail("Unexpected LocalFree(%x) failure with error %d\n", - lpvData, - dwError); - } - } - - return PASS; -} - -/** - * main - * - * executable entry point - */ -INT __cdecl main( INT argc, CHAR **argv ) -{ - DWORD IDThread; - HANDLE hThread[NUM_OF_THREADS]; - int i; - - /*PAL initialization */ - if( (PAL_Initialize(argc, argv)) != 0 ) - { - return FAIL; - } - - /*Allocate a TLS index. */ - if ((dwTlsIndex = TlsAlloc()) == TLS_OUT_OF_INDEXES) - {/*RROR*/ - DWORD dwError = GetLastError(); - Fail("TlsAlloc() returned error %d\n", - dwError); - } - - /*Create multiple threads.*/ - - for (i = 0; i < NUM_OF_THREADS; i++) - { - hThread[i] = CreateThread(NULL, /* no security attributes*/ - 0, /* use default stack size */ - ThreadFunc, /* thread function */ - NULL, /* no thread function argument */ - 0, /* use default creation flags */ - &IDThread); /* returns thread identifier */ - - /* Check the return value for success. */ - if (hThread[i] == NULL) - {/* ERROR */ - DWORD dwError = GetLastError(); - Fail("Unexpected CreateThread error %d\n", - dwError); - } - } - - /* Wait for all threads to finish */ - for (i = 0; i < NUM_OF_THREADS; i++) - { - DWORD dwRet; - - dwRet = WaitForSingleObject(hThread[i], INFINITE); - - if( dwRet == WAIT_FAILED ) - {/* ERROR */ - DWORD dwError = GetLastError(); - Fail("Unexpected WaitForSingleObject error %d\n", - dwError); - } - } - - /* Release the TLS index */ - if( TlsFree( dwTlsIndex ) == 0 ) - {/* ERROR */ - DWORD dwError = GetLastError(); - Fail("TlsFree() returned 0 with error %d\n", - dwError); - } - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/threading/TLS/test1/testinfo.dat b/src/pal/tests/palsuite/threading/TLS/test1/testinfo.dat deleted file mode 100644 index 544e39126..000000000 --- a/src/pal/tests/palsuite/threading/TLS/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = threading -Function = TLS -Name = Test for TlsAlloc, TlsGetValue, TlsSetValue and TlsFree -TYPE = DEFAULT -EXE1 = tls -Description -= Test to ensure TlsAlloc, TlsGetValue, TlsSetValue -= and TlsFree are working properly together. diff --git a/src/pal/tests/palsuite/threading/TLS/test2/CMakeLists.txt b/src/pal/tests/palsuite/threading/TLS/test2/CMakeLists.txt deleted file mode 100644 index 1dde9e6cb..000000000 --- a/src/pal/tests/palsuite/threading/TLS/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - TLS.cpp -) - -add_executable(paltest_tls_test2 - ${SOURCES} -) - -add_dependencies(paltest_tls_test2 coreclrpal) - -target_link_libraries(paltest_tls_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/TLS/test2/TLS.cpp b/src/pal/tests/palsuite/threading/TLS/test2/TLS.cpp deleted file mode 100644 index 96a6011f9..000000000 --- a/src/pal/tests/palsuite/threading/TLS/test2/TLS.cpp +++ /dev/null @@ -1,66 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================= -** -** Source: tls.c -** -** Purpose: Test to ensure TlsAlloc and TlsFree are working when we try -** to allocate the guaranted minimum number of indicies. -** - -** -**===========================================================================*/ -#include - -#define NUM_OF_INDEX 64 -/* Minimum guaranteed is at least 64 for all systems.*/ - -/** - * main - * - * executable entry point - */ -INT __cdecl main( INT argc, CHAR **argv ) -{ - DWORD dwIndexes[NUM_OF_INDEX]; - int i,j; - - /* PAL initialization */ - if( (PAL_Initialize(argc, argv)) != 0 ) - { - return FAIL; - } - - /* Allocate a bunch of TLS indexes. */ - for( i = 0; i < NUM_OF_INDEX; i++ ) - { - if( (dwIndexes[i] = TlsAlloc()) == TLS_OUT_OF_INDEXES ) - {/*ERROR */ - DWORD dwError = GetLastError(); - Fail("TlsAlloc() returned -1 with error %d" - "when trying to allocate %d index\n", - dwError, - i); - } - } - - /* Free the TLS indexes.*/ - for( j = 0; j < NUM_OF_INDEX; j++ ) - { - if( TlsFree(dwIndexes[j]) == 0 ) - {/* ERROR */ - DWORD dwError = GetLastError(); - Fail("TlsFree() returned 0 with error %d" - "when trying to free %d index\n", - dwError, - i); - } - } - - PAL_Terminate(); - - return PASS; -} - diff --git a/src/pal/tests/palsuite/threading/TLS/test2/testinfo.dat b/src/pal/tests/palsuite/threading/TLS/test2/testinfo.dat deleted file mode 100644 index 3a672a5f3..000000000 --- a/src/pal/tests/palsuite/threading/TLS/test2/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = threading -Function = TLS -Name = Test for TlsAlloc and TlsFree -TYPE = DEFAULT -EXE1 = tls -Description -= Test to ensure TlsAlloc and TlsFree are working when we try -= to allocate the guaranted minimum number of index. diff --git a/src/pal/tests/palsuite/threading/TLS/test3/CMakeLists.txt b/src/pal/tests/palsuite/threading/TLS/test3/CMakeLists.txt deleted file mode 100644 index ac814bba9..000000000 --- a/src/pal/tests/palsuite/threading/TLS/test3/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - TLS.cpp -) - -add_executable(paltest_tls_test3 - ${SOURCES} -) - -add_dependencies(paltest_tls_test3 coreclrpal) - -target_link_libraries(paltest_tls_test3 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/TLS/test3/TLS.cpp b/src/pal/tests/palsuite/threading/TLS/test3/TLS.cpp deleted file mode 100644 index 4acaef502..000000000 --- a/src/pal/tests/palsuite/threading/TLS/test3/TLS.cpp +++ /dev/null @@ -1,90 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================= -** -** Source: tls.c -** -** Purpose: Test to ensure TlsGetValue, TlsSetValue and TlsFree -** are not working with an invalid index -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** LocalAlloc -** LocalFree -** - -** -**===========================================================================*/ -#include - -DWORD dwTlsIndex; /* TLS index */ - -/** - * main - * - * executable entry point - */ -INT __cdecl main( INT argc, CHAR **argv ) -{ - CHAR lpstrData[256] = ""; - LPVOID lpvData = NULL; - BOOL bRet; - - /* PAL initialization */ - if( (PAL_Initialize(argc, argv)) != 0 ) - { - return FAIL; - } - - /* Invalid TLS index */ - dwTlsIndex = -1; - - /* - * Set some data in the invalid TLS index - *Should return 0 and an error - */ - bRet = TlsSetValue(dwTlsIndex, (LPVOID)lpstrData); - - if ( bRet != 0) - {/*ERROR */ - Fail("TlsSetValue(%d, %x) returned %d " - "when it should have returned 0 and an error\n", - dwTlsIndex, - lpvData, - bRet); - } - - /* - * Get the data at the invalid index - * Should return 0 and an error - */ - lpvData = TlsGetValue(dwTlsIndex); - - if ( lpvData != 0 ) - {/* ERROR */ - Fail("TlsGetValue(%d) returned %d " - "when it should have returned 0 and an error\n", - dwTlsIndex, - lpvData); - } - - /* - * Release the invalid TLS index - * Should return 0 and an error - */ - bRet = TlsFree( dwTlsIndex ); - - if( bRet != 0 ) - {/* ERROR */ - Fail("TlsFree() returned %d " - "when it should have returned 0 and an error\n", - bRet); - } - - PAL_Terminate(); - return PASS; -} - - diff --git a/src/pal/tests/palsuite/threading/TLS/test3/testinfo.dat b/src/pal/tests/palsuite/threading/TLS/test3/testinfo.dat deleted file mode 100644 index 63ce59f35..000000000 --- a/src/pal/tests/palsuite/threading/TLS/test3/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = threading -Function = TLS -Name = TlsGetValue, TlsSetValue and TlsFree -TYPE = DEFAULT -EXE1 = tls -Description -= Test to ensure TlsGetValue, TlsSetValue and TlsFree -= are not working with an invalid index diff --git a/src/pal/tests/palsuite/threading/TLS/test4/CMakeLists.txt b/src/pal/tests/palsuite/threading/TLS/test4/CMakeLists.txt deleted file mode 100644 index 40c1752f6..000000000 --- a/src/pal/tests/palsuite/threading/TLS/test4/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test4.cpp -) - -add_executable(paltest_tls_test4 - ${SOURCES} -) - -add_dependencies(paltest_tls_test4 coreclrpal) - -target_link_libraries(paltest_tls_test4 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/TLS/test4/test4.cpp b/src/pal/tests/palsuite/threading/TLS/test4/test4.cpp deleted file mode 100644 index 8c3603cdb..000000000 --- a/src/pal/tests/palsuite/threading/TLS/test4/test4.cpp +++ /dev/null @@ -1,137 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================= -** -** Source: test4.c (threading/tls) -** -** Purpose: Test to ensure that upon key creation, the value NULL -** is associated with the new key in all active threads. -** Upon thread creation, the value NULL is associated -** with all defined keys in the new thread. -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** LocalAlloc -** LocalFree -** - -** -**===========================================================================*/ -#include - -#define NUM_OF_THREADS 10 - -DWORD dwTlsIndex; /* TLS index */ - -/** - * ThreadFunc - * - * Thread function that checks that NULL is associated with the tls index - */ -DWORD PALAPI ThreadFunc(VOID) -{ - LPVOID lpvData; - DWORD dwError; - - /* Retrieve a data pointer for the current thread. - The return value should be NULL since no data has been - set in the index */ - lpvData = TlsGetValue(dwTlsIndex); - - if ( (lpvData != NULL) && - ((dwError = GetLastError()) == NO_ERROR) ) - {/*ERROR */ - Fail("TlsGetValue(%d) returned data " - "even if no data was associated with the index\n", - dwTlsIndex); - } - - return PASS; -} - -/** - * main - * - * executable entry point - */ -INT __cdecl main( INT argc, CHAR **argv ) -{ - DWORD IDThread; - LPVOID lpvData; - DWORD dwError; - HANDLE hThread[NUM_OF_THREADS]; - int i; - - /*PAL initialization */ - if( (PAL_Initialize(argc, argv)) != 0 ) - { - return FAIL; - } - - /*Allocate a TLS index. */ - if ((dwTlsIndex = TlsAlloc()) == TLS_OUT_OF_INDEXES) - {/*ERROR*/ - DWORD dwError = GetLastError(); - Fail("TlsAlloc() returned error %d\n", - dwError); - } - - /*Check that the value associated with the tls index is NULL*/ - lpvData = TlsGetValue(dwTlsIndex); - - if ( (lpvData != NULL) && - ((dwError = GetLastError()) == NO_ERROR) ) - {/*ERROR */ - Fail("TlsGetValue(%d) returned non-null data " - "even if no data was associated with the index\n", - dwTlsIndex); - } - - /*Create multiple threads.*/ - for (i = 0; i < NUM_OF_THREADS; i++) - { - hThread[i] = CreateThread(NULL, /* no security attributes*/ - 0, /* use default stack size */ - (LPTHREAD_START_ROUTINE) ThreadFunc, /* thread function */ - NULL, /* no thread function argument */ - 0, /* use default creation flags */ - &IDThread); /* returns thread identifier */ - - /* Check the return value for success. */ - if (hThread[i] == NULL) - {/* ERROR */ - DWORD dwError = GetLastError(); - Fail("Unexpected CreateThread error %d\n", - dwError); - } - } - - /* Wait for all threads to finish */ - for (i = 0; i < NUM_OF_THREADS; i++) - { - DWORD dwRet; - - dwRet = WaitForSingleObject(hThread[i], INFINITE); - - if( dwRet == WAIT_FAILED ) - {/* ERROR */ - DWORD dwError = GetLastError(); - Fail("Unexpected WaitForSingleObject error %d\n", - dwError); - } - } - - /* Release the TLS index */ - if( TlsFree( dwTlsIndex ) == 0 ) - {/* ERROR */ - DWORD dwError = GetLastError(); - Fail("TlsFree() returned 0 with error %d\n", - dwError); - } - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/threading/TLS/test4/testinfo.dat b/src/pal/tests/palsuite/threading/TLS/test4/testinfo.dat deleted file mode 100644 index 600177064..000000000 --- a/src/pal/tests/palsuite/threading/TLS/test4/testinfo.dat +++ /dev/null @@ -1,15 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = threading -Function = TLS -Name = TlsAlloc, TlsGetValue -TYPE = DEFAULT -EXE1 = test4 -Description -=Test to ensure that upon key creation, the value NULL -=is associated with the new key in all active threads. -=Upon thread creation, the value NULL is associated -=with all defined keys in the new thread. diff --git a/src/pal/tests/palsuite/threading/TLS/test5/CMakeLists.txt b/src/pal/tests/palsuite/threading/TLS/test5/CMakeLists.txt deleted file mode 100644 index c6367f566..000000000 --- a/src/pal/tests/palsuite/threading/TLS/test5/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test5.cpp -) - -add_executable(paltest_tls_test5 - ${SOURCES} -) - -add_dependencies(paltest_tls_test5 coreclrpal) - -target_link_libraries(paltest_tls_test5 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/TLS/test5/test5.cpp b/src/pal/tests/palsuite/threading/TLS/test5/test5.cpp deleted file mode 100644 index c1cd13293..000000000 --- a/src/pal/tests/palsuite/threading/TLS/test5/test5.cpp +++ /dev/null @@ -1,108 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================= -** -** Source: test5.c (threading/tls) -** -** Purpose: Test that creates a key, sets its value, deletes the key, -** creates a new key, and gets its value to make sure its NULL. -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** LocalAlloc -** LocalFree -** - -** -**===========================================================================*/ -#include - -DWORD dwTlsIndex; /* TLS index */ - -/** - * main - * - * executable entry point - */ -INT __cdecl main( INT argc, CHAR **argv ) -{ - LPVOID lpvData; - DWORD dwError; - - /*PAL initialization */ - if( (PAL_Initialize(argc, argv)) != 0 ) - { - return FAIL; - } - - /** - * create a key, set its value, delete the key - */ - - /*Allocate a TLS index. */ - if ((dwTlsIndex = TlsAlloc()) == TLS_OUT_OF_INDEXES) - {/*ERROR*/ - DWORD dwError = GetLastError(); - Fail("TlsAlloc() returned error %d\n", - dwError); - } - - /* Initialize the TLS index for this thread.*/ - lpvData = (LPVOID) LocalAlloc(0, 256); - - if( lpvData == NULL ) - {/*ERROR */ - dwError = GetLastError(); - Fail("Unexpected LocalAlloc(0, 256) failure with error %d\n", - dwError); - } - - if ( TlsSetValue(dwTlsIndex, lpvData) == 0 ) - {/*ERROR */ - dwError = GetLastError(); - Fail("TlsSetValue(%d, %x) returned 0 with error %d\n", - dwTlsIndex, - lpvData, - dwError); - } - - /* Release the TLS index */ - if( TlsFree( dwTlsIndex ) == 0 ) - {/* ERROR */ - DWORD dwError = GetLastError(); - Fail("TlsFree() returned 0 with error %d\n", - dwError); - } - - - /** - * create a new key, and get its value - */ - - /*Allocate a TLS index. */ - if ((dwTlsIndex = TlsAlloc()) == TLS_OUT_OF_INDEXES) - {/*ERROR*/ - DWORD dwError = GetLastError(); - Fail("TlsAlloc() returned error %d\n", - dwError); - } - - /* Retrieve a data pointer for the current thread. - The return value should be NULL since no data has been - set in the index */ - lpvData = TlsGetValue(dwTlsIndex); - - if ( (lpvData != NULL) && - ((dwError = GetLastError()) == NO_ERROR) ) - {/*ERROR */ - Fail("TlsGetValue(%d) returned data " - "even if no data was associated with the index\n", - dwTlsIndex); - } - - PAL_Terminate(); - return PASS; -} - diff --git a/src/pal/tests/palsuite/threading/TLS/test5/testinfo.dat b/src/pal/tests/palsuite/threading/TLS/test5/testinfo.dat deleted file mode 100644 index 4b3e2a64c..000000000 --- a/src/pal/tests/palsuite/threading/TLS/test5/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = threading -Function = TLS -Name = TlsAlloc and TlsGetValue -TYPE = DEFAULT -EXE1 = test5 -Description -= Test that creates a key, sets its value, deletes the key, -= creates a new key, and gets its value to make sure its NULL. diff --git a/src/pal/tests/palsuite/threading/TLS/test6_optimizedtls/CMakeLists.txt b/src/pal/tests/palsuite/threading/TLS/test6_optimizedtls/CMakeLists.txt deleted file mode 100644 index b1ca82c30..000000000 --- a/src/pal/tests/palsuite/threading/TLS/test6_optimizedtls/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test.cpp -) - -add_executable(paltest_tls_test6_optimizedtls - ${SOURCES} -) - -add_dependencies(paltest_tls_test6_optimizedtls coreclrpal) - -target_link_libraries(paltest_tls_test6_optimizedtls - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/TLS/test6_optimizedtls/test.cpp b/src/pal/tests/palsuite/threading/TLS/test6_optimizedtls/test.cpp deleted file mode 100644 index 02419dc90..000000000 --- a/src/pal/tests/palsuite/threading/TLS/test6_optimizedtls/test.cpp +++ /dev/null @@ -1,190 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================= -** -** Source: test.c -** -** Purpose: Test to ensure TlsAlloc, PAL_MakeOptimizedTlsGetter, -** PAL_FreeOptimizedTlsGetter and TlsFree are working properly -** on supported platforms -** -** Dependencies: PAL_Initialize -** Fail -** Sleep -** LocalAlloc -** LocalFree -** WaitForSingleObject -** CreateThread -** GetLastError -** - -** -**===========================================================================*/ - - -#include -#define THREAD_COUNT 5 -DWORD dwTlsIndex; /* TLS index */ - -void PALAPI Run_Thread(LPVOID lpParam); - -/** - * main - * - * executable entry point - */ -INT __cdecl main( INT argc, CHAR **argv ) -{ - DWORD dwParam; - DWORD dwError; - HANDLE hThread[THREAD_COUNT]; - DWORD threadId[THREAD_COUNT]; - - int i = 0; - int returnCode = 0; - - /*PAL initialization */ - if( (PAL_Initialize(argc, argv)) != 0 ) - { - return FAIL; - } - - /*Allocate a TLS index. */ - if ((dwTlsIndex = TlsAlloc()) == TLS_OUT_OF_INDEXES) - { - /*ERROR*/ - dwError = GetLastError(); - Fail("TlsAlloc() returned error %d\n", - dwError); - } - - - for( i = 0; i < THREAD_COUNT; i++ ) - { - dwParam = (int) i; - //Create thread - hThread[i] = CreateThread( - NULL, /* no security attributes */ - 0, /* use default stack size */ - (LPTHREAD_START_ROUTINE)Run_Thread,/* thread function */ - (LPVOID)dwParam, /* argument to thread function */ - 0, /* use default creation flags */ - &threadId[i] /* returns the thread identifier*/ - ); - - if(hThread[i] == NULL) - { - Fail("Create Thread failed for iteration %d GetLastError value is %d\n", i, GetLastError()); - } - - } - - - returnCode = WaitForMultipleObjects(THREAD_COUNT, hThread, TRUE, INFINITE); - if( WAIT_OBJECT_0 != returnCode ) - { - Trace("Wait for Object(s) returned %d, expected value is %d, and GetLastError value is %d\n", returnCode, WAIT_OBJECT_0, GetLastError()); - } - - /* Release the TLS index */ - if( TlsFree( dwTlsIndex ) == 0 ) - { - /* ERROR */ - dwError = GetLastError(); - Fail("TlsFree() returned 0 with error %d\n", - dwError); - } - - PAL_Terminate(); - return PASS; - -} - -void PALAPI Run_Thread (LPVOID lpParam) -{ - unsigned int i = 0; - - LPVOID lpvData; - DWORD dwError; - PAL_POPTIMIZEDTLSGETTER ptrOptimizedTlsGetter; - - int Id=(int)lpParam; - - - lpvData = TlsGetValue(dwTlsIndex); - if ( (lpvData != NULL) && - ((dwError = GetLastError()) == NO_ERROR) ) - { - /*ERROR */ - Fail("Error:%d:TlsGetValue(%d) returned data " - "even if data was not associated with the index, for thread id [%d]\n", - dwError, dwTlsIndex, Id); - } - - - /* Initialize the TLS index for this thread.*/ - lpvData = (LPVOID) LocalAlloc(0, 256); - - if( lpvData == NULL ) - { - /*ERROR */ - dwError = GetLastError(); - Fail("Unexpected LocalAlloc(0, 256) failure with error %d\n", - dwError); - } - - if ( TlsSetValue(dwTlsIndex, lpvData) == 0 ) - { - /*ERROR */ - dwError = GetLastError(); - Fail("TlsSetValue(%d, %x) returned 0 with error %d\n", - dwTlsIndex, - lpvData, - dwError); - } - - ptrOptimizedTlsGetter = PAL_MakeOptimizedTlsGetter(dwTlsIndex); - if( ptrOptimizedTlsGetter == NULL ) - { - /* Retrieve a data pointer for the current thread. - The return value should be NULL since no data has been - set in the index */ - lpvData = TlsGetValue(dwTlsIndex); - Trace("Not Inside the optimizer loop for thread [%d]\n", Id); - - if ( (lpvData == NULL) && - ((dwError = GetLastError()) == NO_ERROR) ) - { - /*ERROR */ - Fail("Error:%d:TlsGetValue(%d) returned data " - "as NULL even if data was associated with the index, for thread id [%d]\n", - dwError, dwTlsIndex, Id); - } - } - else - { - /* Retrieve a data pointer for the current thread. - The return value should be NULL since no data has been - set in the index */ - lpvData = ptrOptimizedTlsGetter(); - - if ( (lpvData == NULL) && - ((dwError = GetLastError()) == NO_ERROR) ) - { - /*ERROR */ - Fail(" Error:%d: MakeOptimizedTlsGetter for dwTlsIndex (%d) returned data " - "as NULL even if no data was associated with the index, for thread id [%d]\n", - dwError, dwTlsIndex, Id); - } - - Trace("Inside the optimizer loop for thread [%d]\n", Id); - PAL_FreeOptimizedTlsGetter(ptrOptimizedTlsGetter); - } - - - - -} - diff --git a/src/pal/tests/palsuite/threading/TLS/test6_optimizedtls/testinfo.dat b/src/pal/tests/palsuite/threading/TLS/test6_optimizedtls/testinfo.dat deleted file mode 100644 index 2193edcab..000000000 --- a/src/pal/tests/palsuite/threading/TLS/test6_optimizedtls/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = threading -Function = PAL_MakeOptimizedTlsGetter and PAL_FreeOptimizedTlsGetter -Name = Test for PAL_MakeOptimizedTlsGetterandPAL_FreeOptimizedTlsGetter -TYPE = DEFAULT -EXE1 = test -Description -= Purpose: Test to ensure TlsAlloc, PAL_MakeOptimizedTlsGetter, -= PAL_FreeOptimizedTlsGetter and TlsFree are working properly -= on supported platforms diff --git a/src/pal/tests/palsuite/threading/TerminateProcess/CMakeLists.txt b/src/pal/tests/palsuite/threading/TerminateProcess/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/threading/TerminateProcess/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/threading/TerminateProcess/test1/CMakeLists.txt b/src/pal/tests/palsuite/threading/TerminateProcess/test1/CMakeLists.txt deleted file mode 100644 index 6cac1488e..000000000 --- a/src/pal/tests/palsuite/threading/TerminateProcess/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - TerminateProcess.cpp -) - -add_executable(paltest_terminateprocess_test1 - ${SOURCES} -) - -add_dependencies(paltest_terminateprocess_test1 coreclrpal) - -target_link_libraries(paltest_terminateprocess_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/TerminateProcess/test1/TerminateProcess.cpp b/src/pal/tests/palsuite/threading/TerminateProcess/test1/TerminateProcess.cpp deleted file mode 100644 index 6feedfce7..000000000 --- a/src/pal/tests/palsuite/threading/TerminateProcess/test1/TerminateProcess.cpp +++ /dev/null @@ -1,41 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source: terminateprocess/test1/terminateprocess.c -** -** Purpose: Test to see if TerminateProcess will -** terminate the current process. -** -** Dependencies: GetCurrentProcess -** -** -**=========================================================*/ - -#include - -INT __cdecl main( int argc, char **argv ) -{ - - HANDLE hProcess; - - if(0 != (PAL_Initialize(argc, argv))) - { - return (FAIL); - } - - hProcess = GetCurrentProcess(); - - Trace ("Testing TerminateProcess function.\n"); - - if ( 0 == ( TerminateProcess ( hProcess, PASS ) ) ) - { - Fail ("TerminateProcess failed.\n"); - } - - PAL_TerminateEx(FAIL); - return (FAIL); - -} diff --git a/src/pal/tests/palsuite/threading/TerminateProcess/test1/testinfo.dat b/src/pal/tests/palsuite/threading/TerminateProcess/test1/testinfo.dat deleted file mode 100644 index 7ee69bfa2..000000000 --- a/src/pal/tests/palsuite/threading/TerminateProcess/test1/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = threading -Function = TerminateProcess -Name = Positive Test for TerminateProcess -TYPE = DEFAULT -EXE1 = terminateprocess -Description -= Test to see if the function TerminateProcess terminates the currently -= running process and passes the appropriate value through uExitCode. - diff --git a/src/pal/tests/palsuite/threading/ThreadPriority/CMakeLists.txt b/src/pal/tests/palsuite/threading/ThreadPriority/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/threading/ThreadPriority/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/threading/ThreadPriority/test1/CMakeLists.txt b/src/pal/tests/palsuite/threading/ThreadPriority/test1/CMakeLists.txt deleted file mode 100644 index 7ca88c700..000000000 --- a/src/pal/tests/palsuite/threading/ThreadPriority/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - ThreadPriority.cpp -) - -add_executable(paltest_threadpriority_test1 - ${SOURCES} -) - -add_dependencies(paltest_threadpriority_test1 coreclrpal) - -target_link_libraries(paltest_threadpriority_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/ThreadPriority/test1/ThreadPriority.cpp b/src/pal/tests/palsuite/threading/ThreadPriority/test1/ThreadPriority.cpp deleted file mode 100644 index 95bcdac52..000000000 --- a/src/pal/tests/palsuite/threading/ThreadPriority/test1/ThreadPriority.cpp +++ /dev/null @@ -1,83 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================= -** -** Source: threadpriority.c -** -** Purpose: Test to ensure GetThreadPriority works properly. -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** Fail -** CreateThread -** WaitForSingleObject -** GetLastError -** time() -** - -** -**===========================================================================*/ -#include - -/** - * CheckThreadPriority - * - * Helper function that checks the current thread priority - * against an expected value. - */ -static VOID CheckThreadPriority( HANDLE hThread, int expectedPriority ) -{ - int priority; - DWORD dwError = 0; - - /* get the current thread priority */ - priority = GetThreadPriority( hThread ); - if( priority == THREAD_PRIORITY_ERROR_RETURN ) - { - /* GetThreadPriority call failed */ - dwError = GetLastError(); - Fail( "Unexpected GetThreadPriority() failure " - "with error %d\n", dwError ); - } - else if( priority != expectedPriority ) - { - /* unexpected thread priority detected */ - Fail( "Unexpected initial thread priority value %d reported\n", - priority ); - } -} - - -/** - * main - * - * executable entry point - */ -INT __cdecl main( INT argc, CHAR **argv ) -{ - - /* PAL initialization */ - if( (PAL_Initialize(argc, argv)) != 0 ) - { - return( FAIL ); - } - - /* set the thread priority of the main to the highest possible value - this will give the chance to the main thread to create all the - other threads */ - if(!SetThreadPriority( GetCurrentThread(), THREAD_PRIORITY_NORMAL)) - { - DWORD dwError; - - dwError = GetLastError(); - Fail( "Unexpected SetThreadPriority() failure with error %d\n", - dwError ); - } - - CheckThreadPriority( GetCurrentThread(), THREAD_PRIORITY_NORMAL ); - //Add verification of timing out here.. - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/threading/ThreadPriority/test1/testinfo.dat b/src/pal/tests/palsuite/threading/ThreadPriority/test1/testinfo.dat deleted file mode 100644 index 0abd9c1e0..000000000 --- a/src/pal/tests/palsuite/threading/ThreadPriority/test1/testinfo.dat +++ /dev/null @@ -1,17 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = threading -Function = ThreadPriority -Name = Test for GetThreadPriority and SetThreadPriority -TYPE = DEFAULT -EXE1 = threadpriority -Description -= Test to ensure proper operation of the GetThreadPriority -= and SetThreadPriority APIs. The test launches several threads -= of varying priorities, and verifies that the correct priority -= is reported for each. It also verifies that the processing -= time for each test thread is consistent with the priority -= that's set for it. diff --git a/src/pal/tests/palsuite/threading/WaitForMultipleObjects/CMakeLists.txt b/src/pal/tests/palsuite/threading/WaitForMultipleObjects/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/threading/WaitForMultipleObjects/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/threading/WaitForMultipleObjects/test1/CMakeLists.txt b/src/pal/tests/palsuite/threading/WaitForMultipleObjects/test1/CMakeLists.txt deleted file mode 100644 index f7ab13861..000000000 --- a/src/pal/tests/palsuite/threading/WaitForMultipleObjects/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_waitformultipleobjects_test1 - ${SOURCES} -) - -add_dependencies(paltest_waitformultipleobjects_test1 coreclrpal) - -target_link_libraries(paltest_waitformultipleobjects_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/WaitForMultipleObjects/test1/test1.cpp b/src/pal/tests/palsuite/threading/WaitForMultipleObjects/test1/test1.cpp deleted file mode 100644 index 8249c38d9..000000000 --- a/src/pal/tests/palsuite/threading/WaitForMultipleObjects/test1/test1.cpp +++ /dev/null @@ -1,224 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source: test1.c -** -** Purpose: Test for WaitForMultipleObjects. Call the function -** on an array of 4 events, and ensure that it returns correct -** results when we do so. -** -** -**=========================================================*/ - -#include - -/* Number of events in array */ -#define MAX_EVENTS 4 - -BOOL WaitForMultipleObjectsTest() -{ - BOOL bRet = TRUE; - DWORD dwRet = 0; - - DWORD i = 0, j = 0; - - LPSECURITY_ATTRIBUTES lpEventAttributes = NULL; - BOOL bManualReset = TRUE; - BOOL bInitialState = TRUE; - - HANDLE hEvent[MAX_EVENTS]; - - /* Run through this for loop and create 4 events */ - for (i = 0; i < MAX_EVENTS; i++) - { - hEvent[i] = CreateEvent( lpEventAttributes, - bManualReset, bInitialState, NULL); - - if (hEvent[i] == INVALID_HANDLE_VALUE) - { - Trace("WaitForMultipleObjectsTest:CreateEvent %u failed (%x)\n", i, GetLastError()); - bRet = FALSE; - break; - } - - /* Set the current event */ - bRet = SetEvent(hEvent[i]); - - if (!bRet) - { - Trace("WaitForMultipleObjectsTest:SetEvent %u failed (%x)\n", i, GetLastError()); - bRet = FALSE; - break; - } - - /* Ensure that this returns the correct value */ - dwRet = WaitForSingleObject(hEvent[i],0); - - if (dwRet != WAIT_OBJECT_0) - { - Trace("WaitForMultipleObjectsTest:WaitForSingleObject %u failed (%x)\n", i, GetLastError()); - bRet = FALSE; - break; - } - - /* Reset the event, and again ensure that the return value of - WaitForSingle is correct. - */ - bRet = ResetEvent(hEvent[i]); - - if (!bRet) - { - Trace("WaitForMultipleObjectsTest:ResetEvent %u failed (%x)\n", i, GetLastError()); - bRet = FALSE; - break; - } - - dwRet = WaitForSingleObject(hEvent[i],0); - - if (dwRet != WAIT_TIMEOUT) - { - Trace("WaitForMultipleObjectsTest:WaitForSingleObject %u failed (%x)\n", i, GetLastError()); - bRet = FALSE; - break; - } - } - - /* - * If the first section of the test passed, move on to the - * second. - */ - - if (bRet) - { - BOOL bWaitAll = TRUE; - DWORD nCount = MAX_EVENTS; - CONST HANDLE *lpHandles = &hEvent[0]; - - /* Call WaitForMultipleOjbects on all the events, the return - should be WAIT_TIMEOUT - */ - dwRet = WaitForMultipleObjects( nCount, - lpHandles, - bWaitAll, - 0); - - if (dwRet != WAIT_TIMEOUT) - { - Trace("WaitForMultipleObjectsTest:WaitForMultipleObjects failed (%x)\n", GetLastError()); - } - else - { - /* Step through each event and one at a time, set the - currect test, while reseting all the other tests - */ - - for (i = 0; i < MAX_EVENTS; i++) - { - for (j = 0; j < MAX_EVENTS; j++) - { - if (j == i) - { - - bRet = SetEvent(hEvent[j]); - - if (!bRet) - { - Trace("WaitForMultipleObjectsTest:SetEvent %u failed (%x)\n", j, GetLastError()); - break; - } - } - else - { - bRet = ResetEvent(hEvent[j]); - - if (!bRet) - { - Trace("WaitForMultipleObjectsTest:ResetEvent %u failed (%x)\n", j, GetLastError()); - } - } - } - - bWaitAll = FALSE; - - /* Check that WaitFor returns WAIT_OBJECT + i */ - dwRet = WaitForMultipleObjects( nCount, - lpHandles, bWaitAll, 0); - - if (dwRet != WAIT_OBJECT_0+i) - { - Trace("WaitForMultipleObjectsTest:WaitForMultipleObjects failed (%x)\n", GetLastError()); - bRet = FALSE; - break; - } - } - } - - for (i = 0; i < MAX_EVENTS; i++) - { - bRet = CloseHandle(hEvent[i]); - - if (!bRet) - { - Trace("WaitForMultipleObjectsTest:CloseHandle %u failed (%x)\n", i, GetLastError()); - } - } - } - - return bRet; -} - -BOOL WaitMultipleDuplicateHandleTest() -{ - BOOL testResult = TRUE; - const HANDLE eventHandle = CreateEvent(NULL, TRUE, TRUE, NULL); - HANDLE eventHandles[] = {eventHandle, eventHandle}; - - // WaitAny - Wait for any of the events (no error expected) - DWORD result = WaitForMultipleObjects(sizeof(eventHandles) / sizeof(eventHandles[0]), eventHandles, FALSE, 0); - if (result != WAIT_OBJECT_0) - { - Trace("WaitMultipleDuplicateHandleTest:WaitAny failed (%x)\n", GetLastError()); - testResult = FALSE; - } - - // WaitAll - Wait for all of the events (error expected) - result = WaitForMultipleObjects(sizeof(eventHandles) / sizeof(eventHandles[0]), eventHandles, TRUE, 0); - if (result != WAIT_FAILED) - { - Trace("WaitMultipleDuplicateHandleTest:WaitAll failed: call unexpectedly succeeded\n"); - testResult = FALSE; - } - else if (GetLastError() != ERROR_INVALID_PARAMETER) - { - Trace("WaitMultipleDuplicateHandleTest:WaitAll failed: unexpected last error (%x)\n"); - testResult = FALSE; - } - - return testResult; -} - -int __cdecl main(int argc, char **argv) -{ - - if(0 != (PAL_Initialize(argc, argv))) - { - return ( FAIL ); - } - - if(!WaitForMultipleObjectsTest()) - { - Fail ("Test failed\n"); - } - - if (!WaitMultipleDuplicateHandleTest()) - { - Fail("Test failed\n"); - } - - PAL_Terminate(); - return ( PASS ); - -} diff --git a/src/pal/tests/palsuite/threading/WaitForMultipleObjects/test1/testinfo.dat b/src/pal/tests/palsuite/threading/WaitForMultipleObjects/test1/testinfo.dat deleted file mode 100644 index 38bd350d6..000000000 --- a/src/pal/tests/palsuite/threading/WaitForMultipleObjects/test1/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = threading -Function = WaitForMultipleObjects -Name = Positive Test for WaitForMultipleObjects -TYPE = DEFAULT -EXE1 = test1 -Description -= Test for WaitForMultipleObjects. Call the function -= on an array of 4 events, and ensure that it returns correct -= results when we do so. diff --git a/src/pal/tests/palsuite/threading/WaitForMultipleObjectsEx/CMakeLists.txt b/src/pal/tests/palsuite/threading/WaitForMultipleObjectsEx/CMakeLists.txt deleted file mode 100644 index 7c2017935..000000000 --- a/src/pal/tests/palsuite/threading/WaitForMultipleObjectsEx/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(test2) -add_subdirectory(test3) -add_subdirectory(test4) -add_subdirectory(test5) -add_subdirectory(test6) - diff --git a/src/pal/tests/palsuite/threading/WaitForMultipleObjectsEx/test1/CMakeLists.txt b/src/pal/tests/palsuite/threading/WaitForMultipleObjectsEx/test1/CMakeLists.txt deleted file mode 100644 index 605c59f7e..000000000 --- a/src/pal/tests/palsuite/threading/WaitForMultipleObjectsEx/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_waitformultipleobjectsex_test1 - ${SOURCES} -) - -add_dependencies(paltest_waitformultipleobjectsex_test1 coreclrpal) - -target_link_libraries(paltest_waitformultipleobjectsex_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/WaitForMultipleObjectsEx/test1/test1.cpp b/src/pal/tests/palsuite/threading/WaitForMultipleObjectsEx/test1/test1.cpp deleted file mode 100644 index df3233fa5..000000000 --- a/src/pal/tests/palsuite/threading/WaitForMultipleObjectsEx/test1/test1.cpp +++ /dev/null @@ -1,226 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source: test1.c -** -** Purpose: Test for WaitForMultipleObjectsEx. Call the function -** on an array of 4 events, and ensure that it returns correct -** results when we do so. -** -** -**=========================================================*/ - -#include - -/* Originally written as WaitForMultipleObjects/test1 */ - - -/* Number of events in array */ -#define MAX_EVENTS 4 - -BOOL WaitForMultipleObjectsExTest() -{ - BOOL bRet = TRUE; - DWORD dwRet = 0; - DWORD i = 0, j = 0; - - LPSECURITY_ATTRIBUTES lpEventAttributes = NULL; - BOOL bManualReset = TRUE; - BOOL bInitialState = TRUE; - - HANDLE hEvent[MAX_EVENTS]; - - /* Run through this for loop and create 4 events */ - for (i = 0; i < MAX_EVENTS; i++) - { - hEvent[i] = CreateEvent( lpEventAttributes, - bManualReset, bInitialState, NULL); - - if (hEvent[i] == INVALID_HANDLE_VALUE) - { - Trace("WaitForMultipleObjectsExTest:CreateEvent %u failed (%x)\n", i, GetLastError()); - bRet = FALSE; - break; - } - - /* Set the current event */ - bRet = SetEvent(hEvent[i]); - - if (!bRet) - { - Trace("WaitForMultipleObjectsExTest:SetEvent %u failed (%x)\n", i, GetLastError()); - bRet = FALSE; - break; - } - - /* Ensure that this returns the correct value */ - dwRet = WaitForSingleObject(hEvent[i],0); - - if (dwRet != WAIT_OBJECT_0) - { - Trace("WaitForMultipleObjectsExTest:WaitForSingleObject %u failed (%x)\n", i, GetLastError()); - bRet = FALSE; - break; - } - - /* Reset the event, and again ensure that the return value of - WaitForSingle is correct. - */ - bRet = ResetEvent(hEvent[i]); - - if (!bRet) - { - Trace("WaitForMultipleObjectsExTest:ResetEvent %u failed (%x)\n", i, GetLastError()); - bRet = FALSE; - break; - } - - dwRet = WaitForSingleObject(hEvent[i],0); - - if (dwRet != WAIT_TIMEOUT) - { - Trace("WaitForMultipleObjectsExTest:WaitForSingleObject %u failed (%x)\n", i, GetLastError()); - bRet = FALSE; - break; - } - } - - /* - * If the first section of the test passed, move on to the - * second. - */ - - if (bRet) - { - BOOL bWaitAll = TRUE; - DWORD nCount = MAX_EVENTS; - CONST HANDLE *lpHandles = &hEvent[0]; - - /* Call WaitForMultipleObjectsEx on all the events, the return - should be WAIT_TIMEOUT - */ - dwRet = WaitForMultipleObjectsEx(nCount, - lpHandles, - bWaitAll, - 0, - FALSE); - - if (dwRet != WAIT_TIMEOUT) - { - Trace("WaitForMultipleObjectsExTest: WaitForMultipleObjectsEx failed (%x)\n", GetLastError()); - } - else - { - /* Step through each event and one at a time, set the - currect test, while reseting all the other tests - */ - - for (i = 0; i < MAX_EVENTS; i++) - { - for (j = 0; j < MAX_EVENTS; j++) - { - if (j == i) - { - - bRet = SetEvent(hEvent[j]); - - if (!bRet) - { - Trace("WaitForMultipleObjectsExTest:SetEvent %j failed (%x)\n", j, GetLastError()); - break; - } - } - else - { - bRet = ResetEvent(hEvent[j]); - - if (!bRet) - { - Trace("WaitForMultipleObjectsExTest:ResetEvent %u failed (%x)\n", j, GetLastError()); - } - } - } - - bWaitAll = FALSE; - - /* Check that WaitFor returns WAIT_OBJECT + i */ - dwRet = WaitForMultipleObjectsEx( nCount, - lpHandles, bWaitAll, 0, FALSE); - - if (dwRet != WAIT_OBJECT_0+i) - { - Trace("WaitForMultipleObjectsExTest: WaitForMultipleObjectsEx failed (%x)\n", GetLastError()); - bRet = FALSE; - break; - } - } - } - - for (i = 0; i < MAX_EVENTS; i++) - { - bRet = CloseHandle(hEvent[i]); - - if (!bRet) - { - Trace("WaitForMultipleObjectsExTest:CloseHandle %u failed (%x)\n", i, GetLastError()); - } - } - } - - return bRet; -} - -BOOL WaitMultipleDuplicateHandleTest() -{ - BOOL testResult = TRUE; - const HANDLE eventHandle = CreateEvent(NULL, TRUE, TRUE, NULL); - HANDLE eventHandles[] = {eventHandle, eventHandle}; - - // WaitAny - Wait for any of the events (no error expected) - DWORD result = WaitForMultipleObjects(sizeof(eventHandles) / sizeof(eventHandles[0]), eventHandles, FALSE, 0); - if (result != WAIT_OBJECT_0) - { - Trace("WaitMultipleDuplicateHandleTest:WaitAny failed (%x)\n", GetLastError()); - testResult = FALSE; - } - - // WaitAll - Wait for all of the events (error expected) - result = WaitForMultipleObjects(sizeof(eventHandles) / sizeof(eventHandles[0]), eventHandles, TRUE, 0); - if (result != WAIT_FAILED) - { - Trace("WaitMultipleDuplicateHandleTest:WaitAll failed: call unexpectedly succeeded\n"); - testResult = FALSE; - } - else if (GetLastError() != ERROR_INVALID_PARAMETER) - { - Trace("WaitMultipleDuplicateHandleTest:WaitAll failed: unexpected last error (%x)\n"); - testResult = FALSE; - } - - return testResult; -} - -int __cdecl main(int argc, char **argv) -{ - - if(0 != (PAL_Initialize(argc, argv))) - { - return ( FAIL ); - } - - if(!WaitForMultipleObjectsExTest()) - { - Fail ("Test failed\n"); - } - - if (!WaitMultipleDuplicateHandleTest()) - { - Fail("Test failed\n"); - } - - PAL_Terminate(); - return PASS; -} diff --git a/src/pal/tests/palsuite/threading/WaitForMultipleObjectsEx/test1/testinfo.dat b/src/pal/tests/palsuite/threading/WaitForMultipleObjectsEx/test1/testinfo.dat deleted file mode 100644 index 596c4bbf3..000000000 --- a/src/pal/tests/palsuite/threading/WaitForMultipleObjectsEx/test1/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = threading -Function = WaitForMultipleObjectsEx -Name = Test #1 for WaitForMultipleObjectsEx -TYPE = DEFAULT -EXE1 = test1 -Description -= Test for WaitForMultipleObjectsEx. Call the function -= on an array of 4 events, and ensure that it returns correct -= results when we do so. diff --git a/src/pal/tests/palsuite/threading/WaitForMultipleObjectsEx/test2/CMakeLists.txt b/src/pal/tests/palsuite/threading/WaitForMultipleObjectsEx/test2/CMakeLists.txt deleted file mode 100644 index fb74acc28..000000000 --- a/src/pal/tests/palsuite/threading/WaitForMultipleObjectsEx/test2/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test2.cpp -) - -add_executable(paltest_waitformultipleobjectsex_test2 - ${SOURCES} -) - -add_dependencies(paltest_waitformultipleobjectsex_test2 coreclrpal) - -target_link_libraries(paltest_waitformultipleobjectsex_test2 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/WaitForMultipleObjectsEx/test2/test2.cpp b/src/pal/tests/palsuite/threading/WaitForMultipleObjectsEx/test2/test2.cpp deleted file mode 100644 index b2bc30112..000000000 --- a/src/pal/tests/palsuite/threading/WaitForMultipleObjectsEx/test2/test2.cpp +++ /dev/null @@ -1,188 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test2.c -** -** Purpose: Tests that a child thread in the middle of a -** WaitForMultipleObjectsEx call will be interrupted by QueueUserAPC -** if the alert flag was set. -** -** -**===================================================================*/ - -#include - -/* Based on SleepEx/test2 */ - -const unsigned int ChildThreadWaitTime = 1000; -const unsigned int InterruptTime = 500; - -#define TOLERANCE 10 - -void RunTest(BOOL AlertThread); -VOID PALAPI APCFunc(ULONG_PTR dwParam); -DWORD PALAPI WaiterProc(LPVOID lpParameter); - -DWORD ThreadWaitDelta; - -int __cdecl main( int argc, char **argv ) -{ - - DWORD delta = 0; - - if (0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - /* - On some platforms (e.g. FreeBSD 4.9) the first call to some synch objects - (such as conditions) involves some pthread internal initialization that - can make the first wait slighty longer, potentially going above the - acceptable delta for this test. Let's add a dummy wait to preinitialize - internal structures - */ - Sleep(100); - - - /* - * Check that Queueing an APC in the middle of a wait does interrupt - * it, if it's in an alertable state. - */ - RunTest(TRUE); - // Make sure that the wait returns in time greater than interrupt and less than - // wait timeout - if ( - ((ThreadWaitDelta >= ChildThreadWaitTime) && (ThreadWaitDelta - ChildThreadWaitTime) > TOLERANCE) - || (( ThreadWaitDelta < InterruptTime) && (ThreadWaitDelta - InterruptTime) > TOLERANCE) - ) - { - Fail("Expected thread to wait for %d ms (and get interrupted).\n" - "Interrupt Time: %d ms, ThreadWaitDelta %u\n", - ChildThreadWaitTime, InterruptTime, ThreadWaitDelta); - } - - /* - * Check that Queueing an APC in the middle of a wait does NOT interrupt - * it, if it is not in an alertable state. - */ - RunTest(FALSE); - - // Make sure that time taken for thread to return from wait is more than interrupt - // and also not less than the complete child thread wait time - - delta = ThreadWaitDelta - ChildThreadWaitTime; - if( (ThreadWaitDelta < ChildThreadWaitTime) && ( delta > TOLERANCE) ) - { - Fail("Expected thread to wait for %d ms (and not get interrupted).\n" - "Interrupt Time: %d ms, ThreadWaitDelta %u\n", - ChildThreadWaitTime, InterruptTime, ThreadWaitDelta); - } - - - PAL_Terminate(); - return PASS; -} - -void RunTest(BOOL AlertThread) -{ - HANDLE hThread = 0; - DWORD dwThreadId = 0; - int ret; - - hThread = CreateThread( NULL, - 0, - (LPTHREAD_START_ROUTINE)WaiterProc, - (LPVOID) AlertThread, - 0, - &dwThreadId); - - if (hThread == NULL) - { - Fail("ERROR: Was not able to create the thread to test!\n" - "GetLastError returned %d\n", GetLastError()); - } - - Sleep(InterruptTime); - - ret = QueueUserAPC(APCFunc, hThread, 0); - if (ret == 0) - { - Fail("QueueUserAPC failed! GetLastError returned %d\n", - GetLastError()); - } - - ret = WaitForSingleObject(hThread, INFINITE); - if (ret == WAIT_FAILED) - { - Fail("Unable to wait on child thread!\nGetLastError returned %d.\n", - GetLastError()); - } -} - -/* Function doesn't do anything, just needed to interrupt the wait*/ -VOID PALAPI APCFunc(ULONG_PTR dwParam) -{ -} - -/* Entry Point for child thread. */ -DWORD PALAPI WaiterProc(LPVOID lpParameter) -{ - HANDLE Semaphore; - UINT64 OldTimeStamp; - UINT64 NewTimeStamp; - BOOL Alertable; - DWORD ret; - - /* Create a semaphore that is not in the signalled state */ - Semaphore = CreateSemaphoreW(NULL, 0, 1, NULL); - - if (Semaphore == NULL) - { - Fail("Failed to create semaphore! GetLastError returned %d.\n", - GetLastError()); - } - - Alertable = (BOOL) lpParameter; - - LARGE_INTEGER performanceFrequency; - if (!QueryPerformanceFrequency(&performanceFrequency)) - { - Fail("Failed to query performance frequency!"); - } - - OldTimeStamp = GetHighPrecisionTimeStamp(performanceFrequency); - - ret = WaitForMultipleObjectsEx(1, &Semaphore, FALSE, ChildThreadWaitTime, - Alertable); - - NewTimeStamp = GetHighPrecisionTimeStamp(performanceFrequency); - - - if (Alertable && ret != WAIT_IO_COMPLETION) - { - Fail("Expected the interrupted wait to return WAIT_IO_COMPLETION.\n" - "Got %d\n", ret); - } - else if (!Alertable && ret != WAIT_TIMEOUT) - { - Fail("WaitForMultipleObjectsEx did not timeout.\n" - "Expected return of WAIT_TIMEOUT, got %d.\n", ret); - } - - ThreadWaitDelta = NewTimeStamp - OldTimeStamp; - - ret = CloseHandle(Semaphore); - if (!ret) - { - Fail("Unable to close handle to semaphore!\n" - "GetLastError returned %d\n", GetLastError()); - } - - return 0; -} - - diff --git a/src/pal/tests/palsuite/threading/WaitForMultipleObjectsEx/test2/testinfo.dat b/src/pal/tests/palsuite/threading/WaitForMultipleObjectsEx/test2/testinfo.dat deleted file mode 100644 index e8e781a7f..000000000 --- a/src/pal/tests/palsuite/threading/WaitForMultipleObjectsEx/test2/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = threading -Function = WaitForMultipleObjectsEx -Name = Test #2 for WaitForMultipleObjectsEx -TYPE = DEFAULT -EXE1 = test2 -Description -=Tests that a child thread in the middle of a -=WaitForMultipleObjectsEx call will be interrupted by QueueUserAPC -=if the alert flag was set. diff --git a/src/pal/tests/palsuite/threading/WaitForMultipleObjectsEx/test3/CMakeLists.txt b/src/pal/tests/palsuite/threading/WaitForMultipleObjectsEx/test3/CMakeLists.txt deleted file mode 100644 index a00e2fdce..000000000 --- a/src/pal/tests/palsuite/threading/WaitForMultipleObjectsEx/test3/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test3.cpp -) - -add_executable(paltest_waitformultipleobjectsex_test3 - ${SOURCES} -) - -add_dependencies(paltest_waitformultipleobjectsex_test3 coreclrpal) - -target_link_libraries(paltest_waitformultipleobjectsex_test3 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/WaitForMultipleObjectsEx/test3/test3.cpp b/src/pal/tests/palsuite/threading/WaitForMultipleObjectsEx/test3/test3.cpp deleted file mode 100644 index b78b0540d..000000000 --- a/src/pal/tests/palsuite/threading/WaitForMultipleObjectsEx/test3/test3.cpp +++ /dev/null @@ -1,106 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test3.c -** -** Purpose: Tests that waiting on an open mutex will a return -** WAIT_OBJECT_0. Does this by creating a child thread that -** acquires the mutex, releases it, and exits. -** -** -**===================================================================*/ - -#include - - -const int ChildThreadWaitTime = 1000; -const int ParentDelayTime = 2000; - -DWORD PALAPI AcquiringProc(LPVOID lpParameter); - -int __cdecl main( int argc, char **argv) -{ - HANDLE Mutex; - HANDLE hThread = 0; - DWORD dwThreadId = 0; - int ret; - - if (0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - Mutex = CreateMutexW(NULL, FALSE, NULL); - if (Mutex == NULL) - { - Fail("Unable to create the mutex. GetLastError returned %d\n", - GetLastError()); - } - - hThread = CreateThread( NULL, - 0, - (LPTHREAD_START_ROUTINE)AcquiringProc, - (LPVOID) Mutex, - 0, - &dwThreadId); - - if (hThread == NULL) - { - Fail("ERROR: Was not able to create the thread to test!\n" - "GetLastError returned %d\n", GetLastError()); - } - - Sleep(ParentDelayTime); - - ret = WaitForMultipleObjectsEx(1, &Mutex, FALSE, INFINITE, FALSE); - if (ret != WAIT_OBJECT_0) - { - Fail("Expected WaitForMultipleObjectsEx to return WAIT_OBJECT_0\n" - "Got %d\n", ret); - } - - if (!CloseHandle(Mutex)) - { - Fail("CloseHandle on the mutex failed!\n"); - } - - if (!CloseHandle(hThread)) - { - Fail("CloseHandle on the thread failed!\n"); - } - - PAL_Terminate(); - return PASS; -} - -/* - * Entry Point for child thread. Acquries a mutex, releases it, and exits. - */ -DWORD PALAPI AcquiringProc(LPVOID lpParameter) -{ - HANDLE Mutex; - DWORD ret; - - Mutex = (HANDLE) lpParameter; - - Sleep(ChildThreadWaitTime); - - ret = WaitForSingleObject(Mutex, 0); - if (ret != WAIT_OBJECT_0) - { - Fail("Expected the WaitForSingleObject call on the mutex to succeed\n" - "Expected return of WAIT_OBJECT_0, got %d\n", ret); - } - - ret = ReleaseMutex(Mutex); - if (!ret) - { - Fail("Unable to release mutex! GetLastError returned %d\n", - GetLastError()); - } - - return 0; -} diff --git a/src/pal/tests/palsuite/threading/WaitForMultipleObjectsEx/test3/testinfo.dat b/src/pal/tests/palsuite/threading/WaitForMultipleObjectsEx/test3/testinfo.dat deleted file mode 100644 index 991b93489..000000000 --- a/src/pal/tests/palsuite/threading/WaitForMultipleObjectsEx/test3/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = threading -Function = WaitForMultipleObjectsEx -Name = Test #3 for WaitForMultipleObjectsEx -TYPE = DEFAULT -EXE1 = test3 -Description -=Tests that waiting on an open mutex will a return -=WAIT_OBJECT_0. Does this by creating a child thread that -=acquires the mutex, releases it, and exits. diff --git a/src/pal/tests/palsuite/threading/WaitForMultipleObjectsEx/test4/CMakeLists.txt b/src/pal/tests/palsuite/threading/WaitForMultipleObjectsEx/test4/CMakeLists.txt deleted file mode 100644 index 85be0e77a..000000000 --- a/src/pal/tests/palsuite/threading/WaitForMultipleObjectsEx/test4/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test4.cpp -) - -add_executable(paltest_waitformultipleobjectsex_test4 - ${SOURCES} -) - -add_dependencies(paltest_waitformultipleobjectsex_test4 coreclrpal) - -target_link_libraries(paltest_waitformultipleobjectsex_test4 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/WaitForMultipleObjectsEx/test4/test4.cpp b/src/pal/tests/palsuite/threading/WaitForMultipleObjectsEx/test4/test4.cpp deleted file mode 100644 index 15d0a386d..000000000 --- a/src/pal/tests/palsuite/threading/WaitForMultipleObjectsEx/test4/test4.cpp +++ /dev/null @@ -1,101 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: test4.c -** -** Purpose: Tests that waiting on an abandonded mutex will a return -** WAIT_ABANDONED_0. Does this by creating a child thread that -** acquires the mutex and exits. -** -** -**===================================================================*/ - -#include - - -const int ChildThreadWaitTime = 1000; -const int ParentDelayTime = 2000; - -DWORD PALAPI AbandoningProc(LPVOID lpParameter); - -int __cdecl main( int argc, char **argv ) -{ - HANDLE Mutex; - HANDLE hThread = 0; - DWORD dwThreadId = 0; - int ret; - - if (0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - Mutex = CreateMutexW(NULL, FALSE, NULL); - if (Mutex == NULL) - { - Fail("Unable to create the mutex. GetLastError returned %d\n", - GetLastError()); - } - - hThread = CreateThread( NULL, - 0, - (LPTHREAD_START_ROUTINE)AbandoningProc, - (LPVOID) Mutex, - 0, - &dwThreadId); - - if (hThread == NULL) - { - Fail("ERROR: Was not able to create the thread to test!\n" - "GetLastError returned %d\n", GetLastError()); - } - - Sleep(ParentDelayTime); - - ret = WaitForMultipleObjectsEx(1, &Mutex, FALSE, INFINITE, FALSE); - if (ret != WAIT_ABANDONED_0) - { - Fail("Expected WaitForMultipleObjectsEx to return WAIT_ABANDONED_0\n" - "Got %d\n", ret); - } - - ReleaseMutex(Mutex); - if (!CloseHandle(Mutex)) - { - Fail("CloseHandle on the mutex failed!\n"); - } - - if (!CloseHandle(hThread)) - { - Fail("CloseHandle on the thread failed!\n"); - } - - PAL_Terminate(); - return PASS; -} - -/* - * Entry Point for child thread. Acquries a mutex and exit's without - * releasing it. - */ -DWORD PALAPI AbandoningProc(LPVOID lpParameter) -{ - HANDLE Mutex; - DWORD ret; - - Mutex = (HANDLE) lpParameter; - - Sleep(ChildThreadWaitTime); - - ret = WaitForSingleObject(Mutex, 0); - if (ret != WAIT_OBJECT_0) - { - Fail("Expected the WaitForSingleObject call on the mutex to succeed\n" - "Expected return of WAIT_OBJECT_0, got %d\n", ret); - } - - return 0; -} diff --git a/src/pal/tests/palsuite/threading/WaitForMultipleObjectsEx/test4/testinfo.dat b/src/pal/tests/palsuite/threading/WaitForMultipleObjectsEx/test4/testinfo.dat deleted file mode 100644 index 16f3468ac..000000000 --- a/src/pal/tests/palsuite/threading/WaitForMultipleObjectsEx/test4/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = threading -Function = WaitForMultipleObjectsEx -Name = Test #4 for WaitForMultipleObjectsEx -TYPE = DEFAULT -EXE1 = test4 -Description -=Tests that waiting on an abandonded mutex will a return -=WAIT_ABANDONED_0. Does this by creating a child thread that -=acquires the mutex and exits. diff --git a/src/pal/tests/palsuite/threading/WaitForMultipleObjectsEx/test5/CMakeLists.txt b/src/pal/tests/palsuite/threading/WaitForMultipleObjectsEx/test5/CMakeLists.txt deleted file mode 100644 index 14b8dc175..000000000 --- a/src/pal/tests/palsuite/threading/WaitForMultipleObjectsEx/test5/CMakeLists.txt +++ /dev/null @@ -1,32 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(TESTSOURCES - test5.cpp -) - -add_executable(paltest_waitformultipleobjectsex_test5 - ${TESTSOURCES} -) - -add_dependencies(paltest_waitformultipleobjectsex_test5 coreclrpal) - -target_link_libraries(paltest_waitformultipleobjectsex_test5 - ${COMMON_TEST_LIBRARIES} -) - - -set(HELPERSOURCES - helper.cpp -) - -add_executable(paltest_waitformultipleobjectsex_test5_helper - ${HELPERSOURCES} -) - -add_dependencies(paltest_waitformultipleobjectsex_test5_helper coreclrpal) - -target_link_libraries(paltest_waitformultipleobjectsex_test5_helper - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/WaitForMultipleObjectsEx/test5/commonconsts.h b/src/pal/tests/palsuite/threading/WaitForMultipleObjectsEx/test5/commonconsts.h deleted file mode 100644 index b746616b5..000000000 --- a/src/pal/tests/palsuite/threading/WaitForMultipleObjectsEx/test5/commonconsts.h +++ /dev/null @@ -1,42 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: commonconsts.h -** -** -**============================================================*/ - -#ifndef _COMMONCONSTS_H_ -#define _COMMONCONSTS_H_ - -#include - -const int TIMEOUT = 60 * 5 * 1000; - -char *szcHelperProcessStartEvName = "start"; -char *szcHelperProcessReadyEvName = "ready"; -char *szcHelperProcessFinishEvName = "finish"; - -/* PEDANTIC and PEDANTIC0 is a helper macro that just grumps about any - * zero return codes in a generic way. with little typing */ -#define PEDANTIC(function, parameters) \ -{ \ - if (! (function parameters) ) \ - { \ - Trace("%s: NonFatal failure of %s%s for reasons %u and %u\n", \ - __FILE__, #function, #parameters, GetLastError(), errno); \ - } \ -} -#define PEDANTIC1(function, parameters) \ -{ \ - if ( (function parameters) ) \ - { \ - Trace("%s: NonFatal failure of %s%s for reasons %u and %u\n", \ - __FILE__, #function, #parameters, GetLastError(), errno); \ - } \ -} - -#endif diff --git a/src/pal/tests/palsuite/threading/WaitForMultipleObjectsEx/test5/helper.cpp b/src/pal/tests/palsuite/threading/WaitForMultipleObjectsEx/test5/helper.cpp deleted file mode 100644 index caa0206a1..000000000 --- a/src/pal/tests/palsuite/threading/WaitForMultipleObjectsEx/test5/helper.cpp +++ /dev/null @@ -1,122 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: helper.c -** -** Purpose: This helper process sets up signals to communicate -** with the test thread in the parent process, and let the test -** thread signal this process when to exit. -** -** -**============================================================*/ - -#include "commonconsts.h" - -#include - -HANDLE hProcessStartEvent; -HANDLE hProcessReadyEvent; -HANDLE hProcessFinishEvent; -HANDLE hProcessCleanupEvent; - - -int __cdecl main(int argc, char *argv[]) -{ - - BOOL success = TRUE; /* assume success */ - DWORD dwRet; - DWORD dwProcessId; - char szEventName[MAX_LONGPATH]; - PWCHAR uniString; - - if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - /* Open the event to let test thread tell us to get started. */ - uniString = convert(szcHelperProcessStartEvName); - hProcessStartEvent = OpenEventW(EVENT_ALL_ACCESS, 0, uniString); - free(uniString); - if (!hProcessStartEvent) - { - Fail("helper.main: OpenEvent of '%S' failed (%u). " - "(the event should already exist!)\n", - szcHelperProcessStartEvName, GetLastError()); - } - - /* Wait for signal from test thread. */ - dwRet = WaitForSingleObject(hProcessStartEvent, TIMEOUT); - if (dwRet != WAIT_OBJECT_0) - { - Fail("helper.main: WaitForSingleObject '%s' failed\n" - "LastError:(%u)\n", szcHelperProcessStartEvName, GetLastError()); - } - - dwProcessId = GetCurrentProcessId(); - - if ( 0 >= dwProcessId ) - { - Fail ("helper.main: %s has invalid pid %d\n", argv[0], dwProcessId ); - } - - /* Open the event to tell test thread we are ready. */ - if (sprintf_s(szEventName, MAX_LONGPATH-1, "%s%d", szcHelperProcessReadyEvName, dwProcessId) < 0) - { - Fail ("helper.main: Insufficient event name string length for pid=%d\n", dwProcessId); - } - - uniString = convert(szEventName); - - hProcessReadyEvent = OpenEventW(EVENT_ALL_ACCESS, 0, uniString); - free(uniString); - if (!hProcessReadyEvent) - { - Fail("helper.main: OpenEvent of '%s' failed (%u). " - "(the event should already exist!)\n", - szEventName, GetLastError()); - } - - /* Open the event to let test thread tell us to exit. */ - if (sprintf_s(szEventName, MAX_LONGPATH-1, "%s%d", szcHelperProcessFinishEvName, dwProcessId) < 0) - { - Fail ("helper.main: Insufficient event name string length for pid=%d\n", dwProcessId); - } - - uniString = convert(szEventName); - - hProcessFinishEvent = OpenEventW(EVENT_ALL_ACCESS, 0, uniString); - free(uniString); - if (!hProcessFinishEvent) - { - Fail("helper.main: OpenEvent of '%s' failed LastError:(%u).\n", - szEventName, GetLastError()); - } - - /* Tell the test thread we are ready. */ - if (!SetEvent(hProcessReadyEvent)) - { - Fail("helper.main: SetEvent '%s' failed LastError:(%u)\n", - hProcessReadyEvent, GetLastError()); - } - - /* Wait for signal from test thread before exit. */ - dwRet = WaitForSingleObject(hProcessFinishEvent, TIMEOUT); - if (WAIT_OBJECT_0 != dwRet) - { - Fail("helper.main: WaitForSingleObject '%s' failed pid=%d\n" - "LastError:(%u)\n", - szcHelperProcessFinishEvName, dwProcessId, GetLastError()); - } - - PEDANTIC(CloseHandle, (hProcessStartEvent)); - PEDANTIC(CloseHandle, (hProcessReadyEvent)); - PEDANTIC(CloseHandle, (hProcessFinishEvent)); - - PAL_Terminate(); - - return success ? PASS : FAIL; -} diff --git a/src/pal/tests/palsuite/threading/WaitForMultipleObjectsEx/test5/test5.cpp b/src/pal/tests/palsuite/threading/WaitForMultipleObjectsEx/test5/test5.cpp deleted file mode 100644 index a0216494b..000000000 --- a/src/pal/tests/palsuite/threading/WaitForMultipleObjectsEx/test5/test5.cpp +++ /dev/null @@ -1,506 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================= -** -** Source: test5.c -** -** Purpose: Test the functionality of simultaneously waiting -** on multiple processes. Create the same number of helper -** processes and helper threads. -** Helper threads wait on helper processes to finish. -** Helper processes wait on the event signal from test -** thread before exit. -** The test thread can wake up one helper -** thread at a time by signaling the corresponding helper -** process to finish. -** The test thread can also wake up all helper threads at once -** by signaling help process 0 to exit. -** -** -**============================================================*/ - -#define UNICODE - -#include "commonconsts.h" - -#include - -/* The maximum number of objects a thread can wait is MAXIMUM_WAIT_OBJECTS. - The last helper thread in this test case will wait on all helper processes - plus a thread finish event so the maximum number of helper processes - can be created in this test case is (MAXIMUM_WAIT_OBJECTS-1). */ -#define MAX_HELPER_PROCESS (MAXIMUM_WAIT_OBJECTS-1) - -int MaxNumHelperProcess = MAX_HELPER_PROCESS; - -/* indicate how the test thread wake up helper thread. */ -typedef enum _TestCaseType { - WakeUpOneThread, /* wake up one helper thread at a time. */ - WakeUpAllThread /* wake up all helper threads at once */ -} TestCaseType; - -TestCaseType TestCase = WakeUpOneThread; - -/* When the test thread wakes up one thread at a time, - ThreadIndexOfThreadFinishEvent specifies the index of the thread that - should be waked up using hThreadFinishEvent instead of helper process. */ -DWORD ThreadIndexOfThreadFinishEvent = 0; - -struct helper_process_t -{ - PROCESS_INFORMATION pi; - HANDLE hProcessReadyEvent; - HANDLE hProcessFinishEvent; -} helper_process[MAX_HELPER_PROCESS]; - -HANDLE hProcessStartEvent; - -struct helper_thread_t -{ - HANDLE hThread; - DWORD dwThreadId; - HANDLE hThreadReadyEvent; - HANDLE hThreadFinishEvent; -} helper_thread[MAX_HELPER_PROCESS]; - -/* - * Entry Point for helper thread. - */ -DWORD PALAPI WaitForProcess(LPVOID lpParameter) -{ - DWORD index, i; - DWORD dwRet; - HANDLE handles[MAX_HELPER_PROCESS+1]; - - index = (DWORD) lpParameter; - - /* The helper thread 0 will wait for helper process 0, helper thread 1 will - wait for helper process 0 and 1, helper thread 2 will wait for helper - process 0, 1, and 2, and so on ..., and the last helper thread will wait - on all helper processes. - Each helper thread also waits on hThreadFinishEvent so that - it can exit without waiting on any process to finish. */ - - for (i = 0; i <= index; i++) - { - handles[i] = helper_process[i].pi.hProcess; - } - - handles[index+1] = helper_thread[index].hThreadFinishEvent; - - if(!SetEvent(helper_thread[index].hThreadReadyEvent)) - { - Fail("test5.WaitProcess: SetEvent of hThreadReadyEvent failed for thread %d. " - "GetLastError() returned %d.\n", index, - GetLastError()); - } - - dwRet = WaitForMultipleObjectsEx(index+2, &handles[0], FALSE, TIMEOUT, TRUE); - if (WakeUpAllThread == TestCase) - { - /* If the test thread signals helper process 0 to exit, all threads will be waked up, - and the return value must be (WAIT_OBJECT_0+0) because the handle of helper process 0 - is in handle[0]. */ - if (dwRet != (WAIT_OBJECT_0+0)) - { - Fail("test5.WaitForProcess: invalid return value %d for WakupAllThread from WaitForMultipleObjectsEx for thread %d\n" - "LastError:(%u)\n", - dwRet, index, - GetLastError()); - } - } - else if (WakeUpOneThread == TestCase) - { - /* If the test thread wakes up one helper thread at a time, - the return value must be either (WAIT_OBJECT_0+index) if the helper thread - wakes up because the corresponding help process exits, - or (index+1) if the helper thread wakes up because of hThreadReadyEvent. */ - if ((index != ThreadIndexOfThreadFinishEvent && dwRet != (WAIT_OBJECT_0+index)) || - (index == ThreadIndexOfThreadFinishEvent && dwRet != (index+1))) - { - Fail("test5.WaitForProcess: invalid return value %d for WakupOneThread from WaitForMultipleObjectsEx for thread %d\n" - "LastError:(%u)\n", - dwRet, index, - GetLastError()); - } - } - else - { - Fail("Unknown TestCase %d\n", TestCase); - } - return 0; -} - -/* - * Setup the helper processes and helper threads. - */ -void -Setup() -{ - - STARTUPINFO si; - DWORD dwRet; - int i; - - char szEventName[MAX_PATH]; - PWCHAR uniStringHelper; - PWCHAR uniString; - - /* Create the event to start helper process after it was created. */ - uniString = convert(szcHelperProcessStartEvName); - hProcessStartEvent = CreateEvent(NULL, TRUE, FALSE, uniString); - free(uniString); - if (!hProcessStartEvent) - { - Fail("test5.Setup: CreateEvent of '%s' failed. " - "GetLastError() returned %d.\n", szcHelperProcessStartEvName, - GetLastError()); - } - - /* Create the helper processes. */ - ZeroMemory( &si, sizeof(si) ); - si.cb = sizeof(si); - uniStringHelper = convert("helper"); - for (i = 0; i < MaxNumHelperProcess; i++) - { - ZeroMemory( &helper_process[i].pi, sizeof(PROCESS_INFORMATION)); - - if(!CreateProcess( NULL, uniStringHelper, NULL, NULL, - FALSE, 0, NULL, NULL, &si, &helper_process[i].pi)) - { - Fail("test5.Setup: CreateProcess failed to load executable for helper process %d. " - "GetLastError() returned %u.\n", - i, GetLastError()); - } - - /* Create the event to let helper process tell us it is ready. */ - if (sprintf_s(szEventName, MAX_PATH-1, "%s%d", - szcHelperProcessReadyEvName, helper_process[i].pi.dwProcessId) < 0) - { - Fail ("test5.Setup: Insufficient event name string length for %s\n", szcHelperProcessReadyEvName); - } - - uniString = convert(szEventName); - - helper_process[i].hProcessReadyEvent = CreateEvent(NULL, FALSE, FALSE, uniString); - free(uniString); - if (!helper_process[i].hProcessReadyEvent) - { - Fail("test5.Setup: CreateEvent of '%s' failed. " - "GetLastError() returned %d.\n", szEventName, - GetLastError()); - } - - /* Create the event to tell helper process to exit. */ - if (sprintf_s(szEventName, MAX_PATH-1, "%s%d", - szcHelperProcessFinishEvName, helper_process[i].pi.dwProcessId) < 0) - { - Fail ("test5.Setup: Insufficient event name string length for %s\n", szcHelperProcessFinishEvName); - } - - uniString = convert(szEventName); - - helper_process[i].hProcessFinishEvent = CreateEvent(NULL, TRUE, FALSE, uniString); - free(uniString); - if (!helper_process[i].hProcessFinishEvent) - { - Fail("test5.Setup: CreateEvent of '%s' failed. " - "GetLastError() returned %d.\n", szEventName, - GetLastError()); - } - - } - free(uniStringHelper); - - /* Signal all helper processes to start. */ - if (!SetEvent(hProcessStartEvent)) - { - Fail("test5.Setup: SetEvent '%s' failed\n", - "LastError:(%u)\n", - szcHelperProcessStartEvName, GetLastError()); - } - - /* Wait for ready signals from all helper processes. */ - for (i = 0; i < MaxNumHelperProcess; i++) - { - dwRet = WaitForSingleObject(helper_process[i].hProcessReadyEvent, TIMEOUT); - if (dwRet != WAIT_OBJECT_0) - { - Fail("test5.Setup: WaitForSingleObject %s failed for helper process %d\n" - "LastError:(%u)\n", - szcHelperProcessReadyEvName, i, GetLastError()); - } - } - - /* Create the same number of helper threads as helper processes. */ - for (i = 0; i < MaxNumHelperProcess; i++) - { - /* Create the event to let helper thread tell us it is ready. */ - helper_thread[i].hThreadReadyEvent = CreateEvent(NULL, FALSE, FALSE, NULL); - if (!helper_thread[i].hThreadReadyEvent) - { - Fail("test5.Setup: CreateEvent of hThreadReadyEvent failed for thread %d\n" - "LastError:(%u)\n", i, GetLastError()); - } - - /* Create the event to tell helper thread to exit without waiting for helper process. */ - helper_thread[i].hThreadFinishEvent = CreateEvent(NULL, FALSE, FALSE, NULL); - if (!helper_thread[i].hThreadFinishEvent) - { - Fail("test5.Setup: CreateEvent of hThreadFinishEvent failed for thread %d\n" - "LastError:(%u)\n", i, GetLastError()); - } - - /* Create the helper thread. */ - helper_thread[i].hThread = CreateThread( NULL, - 0, - (LPTHREAD_START_ROUTINE)WaitForProcess, - (LPVOID)i, - 0, - &helper_thread[i].dwThreadId); - if (NULL == helper_thread[i].hThread) - { - Fail("test5.Setup: Unable to create the helper thread %d\n" - "LastError:(%u)\n", i, GetLastError()); - } - } - - /* Wait for ready signals from all helper threads. */ - for (i = 0; i < MaxNumHelperProcess; i++) - { - dwRet = WaitForSingleObject(helper_thread[i].hThreadReadyEvent, TIMEOUT); - if (dwRet != WAIT_OBJECT_0) - { - Fail("test5.Setup: WaitForSingleObject hThreadReadyEvent for thread %d\n" - "LastError:(%u)\n", i, GetLastError()); - } - } -} - -/* - * Cleanup the helper processes and helper threads. - */ -DWORD -Cleanup() -{ - DWORD dwExitCode; - DWORD dwRet; - int i; - - /* Wait for all helper process to finish and close their handles - and associated events. */ - for (i = 0; i < MaxNumHelperProcess; i++) - { - - /* wait for the child process to complete */ - dwRet = WaitForSingleObject ( helper_process[i].pi.hProcess, TIMEOUT ); - if (WAIT_OBJECT_0 != dwRet) - { - Fail("test5.Cleanup: WaitForSingleObject hThreadReadyEvent failed for thread %d\n" - "LastError:(%u)\n", i, GetLastError()); - } - - /* check the exit code from the process */ - if (!GetExitCodeProcess(helper_process[i].pi.hProcess, &dwExitCode)) - { - Trace( "test5.Cleanup: GetExitCodeProcess %d call failed LastError:(%u)\n", - i, GetLastError()); - dwExitCode = FAIL; - } - PEDANTIC(CloseHandle, (helper_process[i].pi.hThread)); - PEDANTIC(CloseHandle, (helper_process[i].pi.hProcess)); - PEDANTIC(CloseHandle, (helper_process[i].hProcessReadyEvent)); - PEDANTIC(CloseHandle, (helper_process[i].hProcessFinishEvent)); - } - - /* Close all helper threads' handles */ - for (i = 0; i < MaxNumHelperProcess; i++) - { - PEDANTIC(CloseHandle, (helper_thread[i].hThread)); - PEDANTIC(CloseHandle, (helper_thread[i].hThreadReadyEvent)); - PEDANTIC(CloseHandle, (helper_thread[i].hThreadFinishEvent)); - } - - /* Close all process start event. */ - PEDANTIC(CloseHandle, (hProcessStartEvent)); - - return dwExitCode; -} - -/* - * In this test case, the test thread will signal one helper - * process to exit at a time starting from the last helper - * process and then wait for the corresponding helper thread to exit. - * The ThreadIndexOfThreadFinishEvent specifies the index of the thread that - * should be waked up using hThreadFinishEvent instead of helper process. - */ -void -TestWakeupOneThread() -{ - DWORD dwRet; - int i; - - TestCase = WakeUpOneThread; - - if (((LONG)ThreadIndexOfThreadFinishEvent) < 0 || - ThreadIndexOfThreadFinishEvent >= MAX_HELPER_PROCESS) - Fail("test5.TestWaitOnOneThread: Invalid ThreadIndexOfThreadFinishEvent %d\n", ThreadIndexOfThreadFinishEvent); - - /* Since helper thread 0 waits on helper process 0, - thread 1 waits on on process 0, and 1, - thread 2 waits on process 0, 1, and 2, and so on ..., - and the last helper thread will wait on all helper processes, - the helper thread can be waked up one at a time by - waking up the help process one at a time starting from the - last helper process. */ - for (i = MaxNumHelperProcess-1; i >= 0; i--) - { - /* make sure the helper thread has not exited yet. */ - dwRet = WaitForSingleObject(helper_thread[i].hThread, 0); - if (WAIT_TIMEOUT != dwRet) - { - Fail("test5.TestWaitOnOneThread: helper thread %d already exited %d\n", i); - } - - /* Decide how to wakeup the helper thread: - using event or using helper process. */ - if (i == ThreadIndexOfThreadFinishEvent) - { - if (!SetEvent(helper_thread[i].hThreadFinishEvent)) - { - Fail("test5.TestWaitOnOneThread: SetEvent hThreadFinishEvent failed for thread %d\n", - "LastError:(%u)\n", i, GetLastError()); - } - } - else - { - if (!SetEvent(helper_process[i].hProcessFinishEvent)) - { - Fail("test5.TestWaitOnOneThread: SetEvent %s%d failed for helper process %d\n", - "LastError:(%u)\n", - szcHelperProcessFinishEvName, helper_process[i].pi.dwProcessId, i, - GetLastError()); - } - } - - dwRet = WaitForSingleObject(helper_thread[i].hThread, TIMEOUT); - if (WAIT_OBJECT_0 != dwRet) - { - Fail("test5.TestWaitOnOneThread: WaitForSingleObject helper thread %d" - "LastError:(%u)\n", - i, GetLastError()); - } - } - - /* Finally, need to wake up the helper process which the test thread - skips waking up in the last loop. */ - if (!SetEvent(helper_process[ThreadIndexOfThreadFinishEvent].hProcessFinishEvent)) - { - Fail("test5.TestWaitOnOneThread: SetEvent %s%d failed\n", - "LastError:(%u)\n", - szcHelperProcessFinishEvName, helper_process[ThreadIndexOfThreadFinishEvent].pi.dwProcessId, - GetLastError()); - } -} - -/* - * In this test case, the test thread will signal the helper - * process 0 to exit. Since all helper threads wait on process 0, - * all helper threads will wake up and exit, and the test thread - * will wait for all of them to exit. - */ -void -TestWakeupAllThread() -{ - DWORD dwRet; - int i; - - TestCase = WakeUpAllThread; - - /* make sure none of the helper thread exits. */ - for (i = 0; i < MaxNumHelperProcess; i++) - { - dwRet = WaitForSingleObject(helper_thread[i].hThread, 0); - if (WAIT_TIMEOUT != dwRet) - { - Fail("test5.TestWaitOnAllThread: helper thread %d already exited %d\n", i); - } - } - - /* Signal helper process 0 to exit. */ - if (!SetEvent(helper_process[0].hProcessFinishEvent)) - { - Fail("test5.TestWaitOnAllThread: SetEvent %s%d failed\n", - "LastError:(%u)\n", - szcHelperProcessFinishEvName, helper_process[0].pi.dwProcessId, - GetLastError()); - } - - /* Wait for all helper threads to exit. */ - for (i = 0; i < MaxNumHelperProcess; i++) - { - - dwRet = WaitForSingleObject(helper_thread[i].hThread, TIMEOUT); - if (WAIT_OBJECT_0 != dwRet) - { - Fail("test5.TestWaitOnAllThread: WaitForSingleObject failed for helper thread %d\n" - "LastError:(%u)\n", - i, GetLastError()); - } - } - - /* Signal the rest of helper processes to exit. */ - for (i = 1; i < MaxNumHelperProcess; i++) - { - if (!SetEvent(helper_process[i].hProcessFinishEvent)) - { - Fail("test5.TestWaitOnAllThread: SetEvent %s%d failed\n", - "LastError:(%u)\n", - szcHelperProcessFinishEvName, helper_process[i].pi.dwProcessId, - GetLastError()); - } - } -} - -int __cdecl main(int argc, char *argv[]) -{ - DWORD dwExitCode; - - if(0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - switch (argc) - { - case 1: - MaxNumHelperProcess = MAX_HELPER_PROCESS; - break; - case 2: - MaxNumHelperProcess = atol(argv[1]); - break; - default: - Fail("Invalid number of arguments\n"); - } - - if (MaxNumHelperProcess < 1 || - MaxNumHelperProcess > MAX_HELPER_PROCESS) - Fail("test5.main: Invalid MaxNumHelperProcess %d\n", MaxNumHelperProcess); - - Setup(); - ThreadIndexOfThreadFinishEvent = 3; - TestWakeupOneThread(); - dwExitCode = Cleanup(); - - if (PASS == dwExitCode) - { - Setup(); - TestWakeupAllThread(); - dwExitCode = Cleanup(); - } - - PAL_TerminateEx(dwExitCode); - return dwExitCode; -} diff --git a/src/pal/tests/palsuite/threading/WaitForMultipleObjectsEx/test5/testinfo.dat b/src/pal/tests/palsuite/threading/WaitForMultipleObjectsEx/test5/testinfo.dat deleted file mode 100644 index 5efc75f77..000000000 --- a/src/pal/tests/palsuite/threading/WaitForMultipleObjectsEx/test5/testinfo.dat +++ /dev/null @@ -1,18 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = threading -Function = WaitForMultipleObjectsEx -Name = Check simultaneously waiting on multiple processes. -TYPE = DEFAULT -EXE1 = test5 -EXE2 = helper -Description -= Create a number of helper processes and helper threads. -= Helper threads wait on helper processes to finish. -= Helper processes wait on the event signal from test -= thread before exit. The test thread then selectively -= signals helper process to finish and then wait on the -= selected helper thread to finish. diff --git a/src/pal/tests/palsuite/threading/WaitForMultipleObjectsEx/test6/CMakeLists.txt b/src/pal/tests/palsuite/threading/WaitForMultipleObjectsEx/test6/CMakeLists.txt deleted file mode 100644 index 88254b9eb..000000000 --- a/src/pal/tests/palsuite/threading/WaitForMultipleObjectsEx/test6/CMakeLists.txt +++ /dev/null @@ -1,32 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(TESTSOURCES - test6.cpp -) - -add_executable(paltest_waitformultipleobjectsex_test6 - ${TESTSOURCES} -) - -add_dependencies(paltest_waitformultipleobjectsex_test6 coreclrpal) - -target_link_libraries(paltest_waitformultipleobjectsex_test6 - ${COMMON_TEST_LIBRARIES} -) - - -set(HELPERSOURCES - child6.cpp -) - -add_executable(paltest_waitformultipleobjectsex_test6_child - ${HELPERSOURCES} -) - -add_dependencies(paltest_waitformultipleobjectsex_test6_child coreclrpal) - -target_link_libraries(paltest_waitformultipleobjectsex_test6_child - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/WaitForMultipleObjectsEx/test6/child6.cpp b/src/pal/tests/palsuite/threading/WaitForMultipleObjectsEx/test6/child6.cpp deleted file mode 100644 index a53b6c972..000000000 --- a/src/pal/tests/palsuite/threading/WaitForMultipleObjectsEx/test6/child6.cpp +++ /dev/null @@ -1,211 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source: child6.c -** -** Purpose: Test for WaitForMultipleObjectsEx in multiple -** scenarios - child process -** -** -**=========================================================*/ - -#include - -int __cdecl main(int argc, char **argv) -{ - int i, iRet; - BOOL bRet; - BOOL bNamedEvent = 0; - BOOL bMutex = 0; - BOOL bMutexAndNamedEvent = 0; - BOOL bSemaphore = 0; - DWORD dwRet; - HANDLE hNamedEvent; - HANDLE hMutex; - char szTestName[256]; - WCHAR wszTestName[256] = { 0 }; - char szEventName[128] = { 0 }; - char szMutexName[128] = { 0 }; - char szSemName[128] = { 0 }; - WCHAR wszEventName[128]; - WCHAR wszMutexName[128]; - WCHAR wszSemName[128]; - DWORD iExitCode = 0; - HANDLE hSemaphore; - - if(0 != (PAL_Initialize(argc, argv))) - { - return ( FAIL ); - } - - Trace("[child] Starting\n"); - - for (i=1; i - -#define MAX_COUNT 10000 -#define MAX_THREADS 256 - -BOOL g_bMutex = 0; -BOOL g_bEvent = 0; -BOOL g_bNamedEvent = 0; -BOOL g_bSemaphore = 0; -BOOL g_bProcess = 0; -BOOL g_bLocalWaitAll = 0; -BOOL g_bRemoteWaitAll = 0; -BOOL g_bRandom = 0; - -int iCount = 1; -int iThreads = 1; -HANDLE hThreads[MAX_THREADS]; - -#ifndef MIN -#define MIN(a,b) (((a)<(b)) ? (a) : (b)) -#endif - -DWORD PALAPI EventTestThread(PVOID pArg) -{ - BOOL bRet; - DWORD dwRet; - HANDLE hEvent[2]; - HANDLE (*prgHandles)[] = (HANDLE (*)[])pArg; - - Trace("[EventTestThread] Starting\n"); - - bRet = DuplicateHandle(GetCurrentProcess(), (*prgHandles)[0], GetCurrentProcess(), - &hEvent[0], 0, FALSE, DUPLICATE_SAME_ACCESS); - bRet &= DuplicateHandle(GetCurrentProcess(), (*prgHandles)[1], GetCurrentProcess(), - &hEvent[1], 0, FALSE, DUPLICATE_SAME_ACCESS); - if (FALSE == bRet) - { - Fail("[EventTestThread] Failed to duplicate handles\n"); - } - - Sleep(1000); - bRet = SetEvent(hEvent[1]); - if (FALSE == bRet) - { - Fail("SetEvent failed\n"); - Fail("[EventTestThread] SetEvent failed [GetLastError()=%u]\n", - GetLastError()); - } - - dwRet = WaitForSingleObject(hEvent[1], INFINITE); - if (WAIT_FAILED == dwRet) - { - Fail("[EventTestThread] WaitForMultipleObjects failed [GetLastError()=%u]\n", - GetLastError()); - } - - Sleep(1000); - bRet = SetEvent(hEvent[0]); - if (FALSE == bRet) - { - Fail("[EventTestThread] SetEvent failed [GetLastError()=%u]\n", - GetLastError()); - } - - Sleep(1000); - bRet = SetEvent(hEvent[1]); - if (FALSE == bRet) - { - Fail("[EventTestThread] SetEvent failed [GetLastError()=%u]\n", - GetLastError()); - } - - CloseHandle(hEvent[0]); - CloseHandle(hEvent[1]); - - Trace("[EventTestThread] Done\n"); - return 0; -} - -DWORD PALAPI MutexTestThread(PVOID pArg) -{ - BOOL bRet; - DWORD dwRet; - HANDLE hMutex; - - Trace("[MutexTestThread] Starting\n"); - - bRet = DuplicateHandle(GetCurrentProcess(), (HANDLE)pArg, GetCurrentProcess(), &hMutex, - 0, FALSE, DUPLICATE_SAME_ACCESS); - if (FALSE == bRet) - { - Fail("[EventTestThread] DuplicateHandle failed [GetLastError()=%u]\n", - GetLastError()); - } - - dwRet = WaitForSingleObject(hMutex, INFINITE); - if (WAIT_FAILED == dwRet) - { - Fail("[EventTestThread] WaitForMultipleObjects failed [GetLastError()=%u]\n", - GetLastError()); - } - - Sleep(1000); - CloseHandle(hMutex); - - Trace("[MutexTestThread] Done\n"); - - return 0; -} - -DWORD PALAPI TestThread(PVOID pArg) -{ - BOOL bRet; - DWORD dwRet; - PROCESS_INFORMATION pi; - STARTUPINFO si; - HANDLE hNamedEvent; - HANDLE hEvent[2] = { 0, 0 }; - HANDLE hMutex = 0; - HANDLE hSemaphore = 0; - HANDLE hObjs[2]; - DWORD dwThreadNum; - DWORD dwSlaveThreadTid = 0; - HANDLE hThread; - int i, iCnt, iRet; - char szTestName[128]; - char szCmd[128]; - char szEventName[128] = { 0 }; - char szMutexName[128] = { 0 }; - char szSemName[128] = { 0 }; - WCHAR wszEventName[128] = { 0 }; - WCHAR wszMutexName[128] = { 0 }; - WCHAR wszSemName[128] = { 0 }; - BOOL bMutex = g_bMutex; - BOOL bEvent = g_bEvent; - BOOL bNamedEvent = g_bNamedEvent; - BOOL bSemaphore = g_bSemaphore; - BOOL bProcess = g_bProcess; - BOOL bLocalWaitAll = g_bLocalWaitAll; - BOOL bRemoteWaitAll = g_bRemoteWaitAll; - int iDesiredExitCode; - - dwThreadNum = (DWORD)pArg; - - sprintf_s (szTestName, 128, "Test6_%u", dwThreadNum); - szTestName[127] = 0; - - sprintf_s(szEventName, 128, "%s_Event", szTestName); - szEventName[127] = 0; - sprintf_s(szMutexName, 128, "%s_Mutex", szTestName); - szMutexName[127] = 0; - sprintf_s(szSemName, 128, "%s_Semaphore", szTestName); - szSemName[127] = 0; - - iRet = MultiByteToWideChar(CP_ACP, 0, szEventName, strlen(szEventName)+1, wszEventName, 128); - iRet &= MultiByteToWideChar(CP_ACP, 0, szMutexName, strlen(szMutexName)+1, wszMutexName, 128); - iRet &= MultiByteToWideChar(CP_ACP, 0, szSemName, strlen(szSemName)+1, wszSemName, 128); - - if (0 == iRet) - { - Fail("[TestThread] Failed to convert strings\n"); - } - - Trace("[TestThread] TestName=%s Event: %S, Mutex: %S, Semaphore = %S\n", - szTestName, wszEventName, wszMutexName, wszSemName); - - hEvent[0] = CreateEventA(NULL, FALSE, FALSE, NULL); - hEvent[1] = CreateEventA(NULL, FALSE, FALSE, NULL); - - hNamedEvent = CreateEventW(NULL, FALSE, FALSE, wszEventName); - hMutex = CreateMutexW(NULL, FALSE, wszMutexName); - hSemaphore = CreateSemaphoreW(NULL, 0, 256, wszSemName); - - if (NULL == hEvent[0] || NULL == hEvent[1] || NULL == hMutex || - NULL == hNamedEvent || NULL == hSemaphore) - { - Fail("[TestThread] Failed to create objects " - "[hNamedEvent=%p hMutex=%p hSemaphore=%p]\n", - (VOID*)hNamedEvent, (VOID*)hMutex, (VOID*)hSemaphore); - } - - for (iCnt=0; iCnt i+1)) - { - i++; - iCnt = atoi(argv[i]); - if (iCnt > 0 && iCnt < MAX_COUNT) - { - iCount = iCnt; - } - } - else if ((0 == strcmp(argv[i], "-threads")) && (argc > i+1)) - { - i++; - iCnt = atoi(argv[i]); - if (iCnt > 0 && iCnt <= MAX_THREADS) - { - iThreads = iCnt; - } - } - else - { - Trace("Unknown option %s ignored\n", argv[i]); - } - } - } - - - iCnt = 0; - for (i=0;i diff --git a/src/pal/tests/palsuite/threading/WaitForSingleObject/CMakeLists.txt b/src/pal/tests/palsuite/threading/WaitForSingleObject/CMakeLists.txt deleted file mode 100644 index 94bd51caa..000000000 --- a/src/pal/tests/palsuite/threading/WaitForSingleObject/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) -add_subdirectory(WFSOExMutexTest) -add_subdirectory(WFSOExSemaphoreTest) -add_subdirectory(WFSOExThreadTest) -add_subdirectory(WFSOMutexTest) -add_subdirectory(WFSOProcessTest) -add_subdirectory(WFSOSemaphoreTest) -add_subdirectory(WFSOThreadTest) - diff --git a/src/pal/tests/palsuite/threading/WaitForSingleObject/WFSOExMutexTest/CMakeLists.txt b/src/pal/tests/palsuite/threading/WaitForSingleObject/WFSOExMutexTest/CMakeLists.txt deleted file mode 100644 index 1e51e47f6..000000000 --- a/src/pal/tests/palsuite/threading/WaitForSingleObject/WFSOExMutexTest/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - WFSOExMutexTest.cpp -) - -add_executable(paltest_waitforsingleobject_wfsoexmutextest - ${SOURCES} -) - -add_dependencies(paltest_waitforsingleobject_wfsoexmutextest coreclrpal) - -target_link_libraries(paltest_waitforsingleobject_wfsoexmutextest - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/WaitForSingleObject/WFSOExMutexTest/WFSOExMutexTest.cpp b/src/pal/tests/palsuite/threading/WaitForSingleObject/WFSOExMutexTest/WFSOExMutexTest.cpp deleted file mode 100644 index 3737f9cc1..000000000 --- a/src/pal/tests/palsuite/threading/WaitForSingleObject/WFSOExMutexTest/WFSOExMutexTest.cpp +++ /dev/null @@ -1,214 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: WFSOExMutex.c -** -** Purpose: Tests a child thread in the middle of a -** WaitForSingleObjectEx call will be interrupted by QueueUserAPC -** if the alert flag was set. -** -** -**===================================================================*/ - -#include - -/*Based on SleepEx/test2 */ - -const int ChildThreadWaitTime = 4000; -const int InterruptTime = 2000; -const DWORD AcceptableDelta = 300; - -void RunTest(BOOL AlertThread); -VOID PALAPI APCFunc(ULONG_PTR dwParam); -DWORD PALAPI WaiterProc(LPVOID lpParameter); - -DWORD ThreadWaitDelta; -HANDLE hMutex; - - - -int __cdecl main( int argc, char **argv ) -{ - int ret=0; - - if (0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - /* - On some platforms (e.g. FreeBSD 4.9) the first call to some synch objects - (such as conditions) involves some pthread internal initialization that - can make the first wait slighty longer, potentially going above the - acceptable delta for this test. Let's add a dummy wait to preinitialize - internal structures - */ - Sleep(100); - - /* - The state of a mutex object is signaled when it is not owned by any thread. - The creating thread can use the bInitialOwner flag to request immediate ownership - of the mutex. Otherwise, a thread must use one of the wait functions to request - ownership. When the mutex's state is signaled, one waiting thread is granted - ownership, the mutex's state changes to nonsignaled, and the wait function returns. - Only one thread can own a mutex at any given time. The owning thread uses the - ReleaseMutex function to release its ownership. - */ - - /* Create a mutex that is not in the signalled state */ - hMutex = CreateMutex(NULL, //No security attributes - TRUE, //Iniitally owned - NULL); //Name of mutex - - if (hMutex == NULL) - { - Fail("Failed to create mutex! GetLastError returned %d.\n", - GetLastError()); - } - /* - * Check that Queueing an APC in the middle of a wait does interrupt - * it, if it's in an alertable state. - */ - - RunTest(TRUE); - if ((ThreadWaitDelta - InterruptTime) > AcceptableDelta) - { - Fail("Expected thread to wait for %d ms (and get interrupted).\n" - "Thread waited for %d ms! (Acceptable delta: %d)\n", - InterruptTime, ThreadWaitDelta, AcceptableDelta); - } - - - /* - * Check that Queueing an APC in the middle of a wait does NOT interrupt - * it, if it is not in an alertable state. - */ - RunTest(FALSE); - if ((ThreadWaitDelta - ChildThreadWaitTime) > AcceptableDelta) - { - Fail("Expected thread to wait for %d ms (and not be interrupted).\n" - "Thread waited for %d ms! (Acceptable delta: %d)\n", - ChildThreadWaitTime, ThreadWaitDelta, AcceptableDelta); - } - - - - //Release Mutex - ret = ReleaseMutex(hMutex); - if (0==ret) - { - Fail("Unable to Release Mutex!\n" - "GetLastError returned %d\n", GetLastError()); - } - - //Close Mutex Handle - ret = CloseHandle(hMutex); - if (!ret) - { - Fail("Unable to close handle to Mutex!\n" - "GetLastError returned %d\n", GetLastError()); - } - - PAL_Terminate(); - return PASS; -} - -void RunTest(BOOL AlertThread) -{ - - HANDLE hThread = 0; - DWORD dwThreadId = 0; - - int ret=0; - - hThread = CreateThread( NULL, - 0, - (LPTHREAD_START_ROUTINE)WaiterProc, - (LPVOID) AlertThread, - 0, - &dwThreadId); - - if (hThread == NULL) - { - Fail("ERROR: Was not able to create the thread to test!\n" - "GetLastError returned %d\n", GetLastError()); - } - - - - Sleep(InterruptTime); - - ret = QueueUserAPC(APCFunc, hThread, 0); - - if (ret == 0) - { - Fail("QueueUserAPC failed! GetLastError returned %d\n", - GetLastError()); - } - - ret = WaitForSingleObject(hThread, INFINITE); - - if (ret == WAIT_FAILED) - { - Fail("Unable to wait on child thread!\nGetLastError returned %d.\n", - GetLastError()); - } - - - if (0==CloseHandle(hThread)) - { - Trace("Could not close Thread handle\n"); - Fail ( "GetLastError returned %d\n", GetLastError()); - } -} - -/* Function doesn't do anything, just needed to interrupt the wait*/ -VOID PALAPI APCFunc(ULONG_PTR dwParam) -{ -} - -/* Entry Point for child thread. */ -DWORD PALAPI WaiterProc(LPVOID lpParameter) -{ - UINT64 OldTimeStamp; - UINT64 NewTimeStamp; - BOOL Alertable; - DWORD ret; - - Alertable = (BOOL) lpParameter; - - LARGE_INTEGER performanceFrequency; - if (!QueryPerformanceFrequency(&performanceFrequency)) - { - Fail("Failed to query performance frequency!"); - } - - OldTimeStamp = GetHighPrecisionTimeStamp(performanceFrequency); - - ret = WaitForSingleObjectEx( hMutex, - ChildThreadWaitTime, - Alertable); - - NewTimeStamp = GetHighPrecisionTimeStamp(performanceFrequency); - - if (Alertable && ret != WAIT_IO_COMPLETION) - { - Fail("Expected the interrupted wait to return WAIT_IO_COMPLETION.\n" - "Got %d\n", ret); - } - else if (!Alertable && ret != WAIT_TIMEOUT) - { - Fail("WaitForSingleObjectEx did not timeout.\n" - "Expected return of WAIT_TIMEOUT, got %d.\n", ret); - } - - ThreadWaitDelta = NewTimeStamp - OldTimeStamp; - - return 0; -} - - - diff --git a/src/pal/tests/palsuite/threading/WaitForSingleObject/WFSOExSemaphoreTest/CMakeLists.txt b/src/pal/tests/palsuite/threading/WaitForSingleObject/WFSOExSemaphoreTest/CMakeLists.txt deleted file mode 100644 index a36649178..000000000 --- a/src/pal/tests/palsuite/threading/WaitForSingleObject/WFSOExSemaphoreTest/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - WFSOExSemaphoreTest.cpp -) - -add_executable(paltest_waitforsingleobject_wfsoexsemaphoretest - ${SOURCES} -) - -add_dependencies(paltest_waitforsingleobject_wfsoexsemaphoretest coreclrpal) - -target_link_libraries(paltest_waitforsingleobject_wfsoexsemaphoretest - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/WaitForSingleObject/WFSOExSemaphoreTest/WFSOExSemaphoreTest.cpp b/src/pal/tests/palsuite/threading/WaitForSingleObject/WFSOExSemaphoreTest/WFSOExSemaphoreTest.cpp deleted file mode 100644 index 793c50995..000000000 --- a/src/pal/tests/palsuite/threading/WaitForSingleObject/WFSOExSemaphoreTest/WFSOExSemaphoreTest.cpp +++ /dev/null @@ -1,184 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: WFSOExSemaphore.c -** -** Purpose: Tests a child thread in the middle of a -** WaitForSingleObjectEx call will be interrupted by QueueUserAPC -** if the alert flag was set. -** -** -**===================================================================*/ - -#include - -/*Based on SleepEx/test2 */ - -const int ChildThreadWaitTime = 4000; -const int InterruptTime = 2000; -const DWORD AcceptableDelta = 300; - -void RunTest(BOOL AlertThread); -VOID PALAPI APCFunc(ULONG_PTR dwParam); -DWORD PALAPI WaiterProc(LPVOID lpParameter); - -DWORD ThreadWaitDelta; - -int __cdecl main( int argc, char **argv ) -{ - if (0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - /* - On some platforms (e.g. FreeBSD 4.9) the first call to some synch objects - (such as conditions) involves some pthread internal initialization that - can make the first wait slighty longer, potentially going above the - acceptable delta for this test. Let's add a dummy wait to preinitialize - internal structures - */ - Sleep(100); - - /* - * Check that Queueing an APC in the middle of a wait does interrupt - * it, if it's in an alertable state. - */ - - RunTest(TRUE); - if ((ThreadWaitDelta - InterruptTime) > AcceptableDelta) - { - Fail("Expected thread to wait for %d ms (and get interrupted).\n" - "Thread waited for %d ms! (Acceptable delta: %d)\n", - InterruptTime, ThreadWaitDelta, AcceptableDelta); - } - - - /* - * Check that Queueing an APC in the middle of a wait does NOT interrupt - * it, if it is not in an alertable state. - */ - RunTest(FALSE); - if ((ThreadWaitDelta - ChildThreadWaitTime) > AcceptableDelta) - { - Fail("Expected thread to wait for %d ms (and not be interrupted).\n" - "Thread waited for %d ms! (Acceptable delta: %d)\n", - ChildThreadWaitTime, ThreadWaitDelta, AcceptableDelta); - } - - - PAL_Terminate(); - return PASS; -} - -void RunTest(BOOL AlertThread) -{ - HANDLE hThread = 0; - DWORD dwThreadId = 0; - int ret; - - hThread = CreateThread( NULL, - 0, - (LPTHREAD_START_ROUTINE)WaiterProc, - (LPVOID) AlertThread, - 0, - &dwThreadId); - - if (hThread == NULL) - { - Fail("ERROR: Was not able to create the thread to test!\n" - "GetLastError returned %d\n", GetLastError()); - } - - Sleep(InterruptTime); - - ret = QueueUserAPC(APCFunc, hThread, 0); - if (ret == 0) - { - Fail("QueueUserAPC failed! GetLastError returned %d\n", - GetLastError()); - } - - ret = WaitForSingleObject(hThread, INFINITE); - if (ret == WAIT_FAILED) - { - Fail("Unable to wait on child thread!\nGetLastError returned %d.\n", - GetLastError()); - } - - if (0==CloseHandle(hThread)) - { - Trace("Could not close Thread handle\n"); - Fail ( "GetLastError returned %d\n", GetLastError()); - } -} - -/* Function doesn't do anything, just needed to interrupt the wait*/ -VOID PALAPI APCFunc(ULONG_PTR dwParam) -{ -} - -/* Entry Point for child thread. */ -DWORD PALAPI WaiterProc(LPVOID lpParameter) -{ - HANDLE hSemaphore; - UINT64 OldTimeStamp; - UINT64 NewTimeStamp; - BOOL Alertable; - DWORD ret; - - LARGE_INTEGER performanceFrequency; - if (!QueryPerformanceFrequency(&performanceFrequency)) - { - Fail("Failed to query performance frequency!"); - } - - /* Create a semaphore that is not in the signalled state */ - hSemaphore = CreateSemaphoreW(NULL, 0, 1, NULL); - - if (hSemaphore == NULL) - { - Fail("Failed to create semaphore! GetLastError returned %d.\n", - GetLastError()); - } - - Alertable = (BOOL) lpParameter; - - OldTimeStamp = GetHighPrecisionTimeStamp(performanceFrequency); - - ret = WaitForSingleObjectEx( hSemaphore, - ChildThreadWaitTime, - Alertable); - - NewTimeStamp = GetHighPrecisionTimeStamp(performanceFrequency); - - - if (Alertable && ret != WAIT_IO_COMPLETION) - { - Fail("Expected the interrupted wait to return WAIT_IO_COMPLETION.\n" - "Got %d\n", ret); - } - else if (!Alertable && ret != WAIT_TIMEOUT) - { - Fail("WaitForSingleObjectEx did not timeout.\n" - "Expected return of WAIT_TIMEOUT, got %d.\n", ret); - } - - - ThreadWaitDelta = NewTimeStamp - OldTimeStamp; - - ret = CloseHandle(hSemaphore); - if (!ret) - { - Fail("Unable to close handle to semaphore!\n" - "GetLastError returned %d\n", GetLastError()); - } - - return 0; -} - - - diff --git a/src/pal/tests/palsuite/threading/WaitForSingleObject/WFSOExThreadTest/CMakeLists.txt b/src/pal/tests/palsuite/threading/WaitForSingleObject/WFSOExThreadTest/CMakeLists.txt deleted file mode 100644 index b7940cdee..000000000 --- a/src/pal/tests/palsuite/threading/WaitForSingleObject/WFSOExThreadTest/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - WFSOExThreadTest.cpp -) - -add_executable(paltest_waitforsingleobject_wfsoexthreadtest - ${SOURCES} -) - -add_dependencies(paltest_waitforsingleobject_wfsoexthreadtest coreclrpal) - -target_link_libraries(paltest_waitforsingleobject_wfsoexthreadtest - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/WaitForSingleObject/WFSOExThreadTest/WFSOExThreadTest.cpp b/src/pal/tests/palsuite/threading/WaitForSingleObject/WFSOExThreadTest/WFSOExThreadTest.cpp deleted file mode 100644 index 894d2804a..000000000 --- a/src/pal/tests/palsuite/threading/WaitForSingleObject/WFSOExThreadTest/WFSOExThreadTest.cpp +++ /dev/null @@ -1,204 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*===================================================================== -** -** Source: WFSOExThreadTest.c -** -** Purpose: Tests a child thread in the middle of a -** WaitForSingleObjectEx call will be interrupted by QueueUserAPC -** if the alert flag was set. -** -** -**===================================================================*/ - -#include - -/*Based on SleepEx/test2 */ - -const int ChildThreadWaitTime = 4000; -const int InterruptTime = 2000; -const DWORD AcceptableDelta = 300; - -void RunTest(BOOL AlertThread); -VOID PALAPI APCFunc(ULONG_PTR dwParam); -DWORD PALAPI WaiterProc(LPVOID lpParameter); -void WorkerThread(void); - -int ThreadWaitDelta; - -int __cdecl main( int argc, char **argv ) -{ - if (0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - /* - On some platforms (e.g. FreeBSD 4.9) the first call to some synch objects - (such as conditions) involves some pthread internal initialization that - can make the first wait slighty longer, potentially going above the - acceptable delta for this test. Let's add a dummy wait to preinitialize - internal structures - */ - Sleep(100); - - /* - * Check that Queueing an APC in the middle of a wait does interrupt - * it, if it's in an alertable state. - */ - - RunTest(TRUE); - if (abs(ThreadWaitDelta - InterruptTime) > AcceptableDelta) - { - Fail("Expected thread to wait for %d ms (and get interrupted).\n" - "Thread waited for %d ms! (Acceptable delta: %d)\n", - InterruptTime, ThreadWaitDelta, AcceptableDelta); - } - - - /* - * Check that Queueing an APC in the middle of a wait does NOT interrupt - * it, if it is not in an alertable state. - */ - RunTest(FALSE); - if (abs(ThreadWaitDelta - ChildThreadWaitTime) > AcceptableDelta) - { - Fail("Expected thread to wait for %d ms (and not be interrupted).\n" - "Thread waited for %d ms! (Acceptable delta: %d)\n", - ChildThreadWaitTime, ThreadWaitDelta, AcceptableDelta); - } - - - PAL_Terminate(); - return PASS; -} - -void RunTest(BOOL AlertThread) -{ - HANDLE hThread = 0; - DWORD dwThreadId = 0; - int ret; - - //Create thread - hThread = CreateThread( NULL, - 0, - (LPTHREAD_START_ROUTINE)WaiterProc, - (LPVOID) AlertThread, - 0, - &dwThreadId); - - if (hThread == NULL) - { - Fail("ERROR: Was not able to create the thread to test!\n" - "GetLastError returned %d\n", GetLastError()); - } - - Sleep(InterruptTime); - - ret = QueueUserAPC(APCFunc, hThread, 0); - if (ret == 0) - { - Fail("QueueUserAPC failed! GetLastError returned %d\n", - GetLastError()); - } - - - ret = WaitForSingleObject(hThread, INFINITE); - if (ret == WAIT_FAILED) - { - Fail("Unable to wait on child thread!\nGetLastError returned %d.\n", - GetLastError()); - } - - if (0==CloseHandle(hThread)) - { - Trace("Could not close Thread handle\n"); - Fail ( "GetLastError returned %d\n", GetLastError()); - } -} - -/* Function doesn't do anything, just needed to interrupt the wait*/ -VOID PALAPI APCFunc(ULONG_PTR dwParam) -{ -} - -/* Entry Point for child thread. */ -DWORD PALAPI WaiterProc(LPVOID lpParameter) -{ - HANDLE hWaitThread; - UINT64 OldTimeStamp; - UINT64 NewTimeStamp; - BOOL Alertable; - DWORD ret; - DWORD dwThreadId = 0; - -/* -When a thread terminates, the thread object attains a signaled state, -satisfying any threads that were waiting on the object. -*/ - -/* Create a thread that does not return immediately to maintain a non signaled test*/ - hWaitThread = CreateThread( NULL, - 0, - (LPTHREAD_START_ROUTINE)WorkerThread, - NULL, - 0, - &dwThreadId); - - if (hWaitThread == NULL) - { - Fail("ERROR: Was not able to create worker thread to wait on!\n" - "GetLastError returned %d\n", GetLastError()); - } - - Alertable = (BOOL) lpParameter; - - LARGE_INTEGER performanceFrequency; - if (!QueryPerformanceFrequency(&performanceFrequency)) - { - Fail("Failed to query performance frequency!"); - } - - OldTimeStamp = GetHighPrecisionTimeStamp(performanceFrequency); - - ret = WaitForSingleObjectEx( hWaitThread, - ChildThreadWaitTime, - Alertable); - - NewTimeStamp = GetHighPrecisionTimeStamp(performanceFrequency); - - - if (Alertable && ret != WAIT_IO_COMPLETION) - { - Fail("Expected the interrupted wait to return WAIT_IO_COMPLETION.\n" - "Got %d\n", ret); - } - else if (!Alertable && ret != WAIT_TIMEOUT) - { - Fail("WaitForSingleObjectEx did not timeout.\n" - "Expected return of WAIT_TIMEOUT, got %d.\n", ret); - } - - ThreadWaitDelta = NewTimeStamp - OldTimeStamp; - - ret = CloseHandle(hWaitThread); - if (!ret) - { - Fail("Unable to close handle to Thread!\n" - "GetLastError returned %d\n", GetLastError()); - } - - return 0; -} - - -void WorkerThread(void) -{ - - //Make the worker thread sleep to test WFSOEx Functionality - - Sleep(2*ChildThreadWaitTime); -} - diff --git a/src/pal/tests/palsuite/threading/WaitForSingleObject/WFSOMutexTest/CMakeLists.txt b/src/pal/tests/palsuite/threading/WaitForSingleObject/WFSOMutexTest/CMakeLists.txt deleted file mode 100644 index 0446a9aee..000000000 --- a/src/pal/tests/palsuite/threading/WaitForSingleObject/WFSOMutexTest/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - WFSOMutexTest.cpp -) - -add_executable(paltest_waitforsingleobject_wfsomutextest - ${SOURCES} -) - -add_dependencies(paltest_waitforsingleobject_wfsomutextest coreclrpal) - -target_link_libraries(paltest_waitforsingleobject_wfsomutextest - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/WaitForSingleObject/WFSOMutexTest/WFSOMutexTest.cpp b/src/pal/tests/palsuite/threading/WaitForSingleObject/WFSOMutexTest/WFSOMutexTest.cpp deleted file mode 100644 index f2537fa77..000000000 --- a/src/pal/tests/palsuite/threading/WaitForSingleObject/WFSOMutexTest/WFSOMutexTest.cpp +++ /dev/null @@ -1,184 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source: WFSOMutexTest.c -** -** Purpose: Test for WaitForSingleObjectTest. -** Create Mutex Object -** Create Two Threads, Each Threads does WFSO for the Mutex Object -** Increments Counter -** Releases Mutex -** Test Passes if the above operations are successful -** -** -** -**=========================================================*/ - - - -#include - - -#define NUMBER_OF_WORKER_THREADS 2 - -//Declaring Variables -HANDLE hMutex = NULL; -unsigned int globalcounter =0; -int testReturnCode = PASS; - -//Declaring Function Prototypes -DWORD PALAPI WFSOMutexTest(LPVOID params); -void incrementCounter(void); - - - -int __cdecl main(int argc, char **argv) -{ - - //Declare local variables - int i =0; - - // 2 dimensional array to hold thread handles for each worker thread - HANDLE hThread[NUMBER_OF_WORKER_THREADS]; - DWORD dwThreadId=0; - int returnCode = 0; - - //Initialize PAL - if(0 != (PAL_Initialize(argc, argv))) - { - return ( FAIL ); - } - - //Create Mutex - hMutex = CreateMutex(NULL, // no security attributes - FALSE, // initially not owned - NULL); // name of mutex - - //Check for Mutex Creation - - if (hMutex == NULL) - { - Fail("Create Mutex Failed, GetLastError: %d\n", GetLastError()); - } - - - //Spawn 2 worker threads - for (i=0;i - -int __cdecl main(int argc, char **argv) -{ - -//Declare local variables -int i =0; - - - -//Initialize PAL -if(0 != (PAL_Initialize(argc, argv))) - { - return ( FAIL ); - } - -//Do some work -for (i=0; i<100000; i++); - -Trace("Counter Value was incremented to %d \n ",i); - -PAL_Terminate(); -return ( PASS ); - -} - - - - - - - - diff --git a/src/pal/tests/palsuite/threading/WaitForSingleObject/WFSOProcessTest/WFSOProcessTest.cpp b/src/pal/tests/palsuite/threading/WaitForSingleObject/WFSOProcessTest/WFSOProcessTest.cpp deleted file mode 100644 index 2711e26c2..000000000 --- a/src/pal/tests/palsuite/threading/WaitForSingleObject/WFSOProcessTest/WFSOProcessTest.cpp +++ /dev/null @@ -1,119 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source: WFSOProcessTest.c -** -** Purpose: Test for WaitForSingleObjectTest. -** Create One Process and do some work -** Use WFSO For the Process to finish -** -** Test Passes if the above operations are successful -** -** -** -**=========================================================*/ - - - -#include - -int __cdecl main(int argc, char **argv) -{ - -//Declare local variables -STARTUPINFO si; -PROCESS_INFORMATION pi; - -DWORD dwWaitResult=0; - -//Initialize PAL -if(0 != (PAL_Initialize(argc, argv))) - { - return ( FAIL ); - } - - -ZeroMemory( &si, sizeof(si) ); -si.cb = sizeof(si); -ZeroMemory( &pi, sizeof(pi) ); - -// Start the child process. -if( !CreateProcess( NULL, // No module name (use command line). - "childprocess", // Command line. - NULL, // Process handle not inheritable. - NULL, // Thread handle not inheritable. - FALSE, // Set handle inheritance to FALSE. - 0, // No creation flags. - NULL, // Use parent's environment block. - NULL, // Use parent's starting directory. - &si, // Pointer to STARTUPINFO structure. - &pi ) // Pointer to PROCESS_INFORMATION structure. -) - -{ -Fail ( "Create Process Failed. Failing test.\n" - "GetLastError returned %d\n", GetLastError()); -} - -// Wait until child process exits. - dwWaitResult = WaitForSingleObject( pi.hProcess, INFINITE ); -switch (dwWaitResult) - { - // The Process wait was successful - case WAIT_OBJECT_0: - { - - Trace("Wait for Process was successful\n"); - break; - } - - // Time-out. - case WAIT_TIMEOUT: - { - Fail ( "Time -out. Failing test.\n" - "GetLastError returned %d\n", GetLastError()); - return FALSE; - } - - // Got ownership of the abandoned process object. - case WAIT_ABANDONED: - { - Fail ( "Got ownership of the abandoned Process object. Failing test.\n" - "GetLastError returned %d\n", GetLastError()); - return FALSE; - } - - //Error condition - case WAIT_FAILED: - { - Fail ( "Wait for Process Failed. Failing test.\n" - "GetLastError returned %d\n", GetLastError()); - return FALSE; - } - -} - - - -// Close process handle -if (0==CloseHandle(pi.hProcess)) - { - Trace("Could not close process handle\n"); - Fail ( "GetLastError returned %d\n", GetLastError()); - } - - -PAL_Terminate(); -return ( PASS ); - -} - - - - - - - diff --git a/src/pal/tests/palsuite/threading/WaitForSingleObject/WFSOSemaphoreTest/CMakeLists.txt b/src/pal/tests/palsuite/threading/WaitForSingleObject/WFSOSemaphoreTest/CMakeLists.txt deleted file mode 100644 index 474edde7f..000000000 --- a/src/pal/tests/palsuite/threading/WaitForSingleObject/WFSOSemaphoreTest/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - WFSOSemaphoreTest.cpp -) - -add_executable(paltest_waitforsingleobject_wfsosemaphoretest - ${SOURCES} -) - -add_dependencies(paltest_waitforsingleobject_wfsosemaphoretest coreclrpal) - -target_link_libraries(paltest_waitforsingleobject_wfsosemaphoretest - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/WaitForSingleObject/WFSOSemaphoreTest/WFSOSemaphoreTest.cpp b/src/pal/tests/palsuite/threading/WaitForSingleObject/WFSOSemaphoreTest/WFSOSemaphoreTest.cpp deleted file mode 100644 index b743b4454..000000000 --- a/src/pal/tests/palsuite/threading/WaitForSingleObject/WFSOSemaphoreTest/WFSOSemaphoreTest.cpp +++ /dev/null @@ -1,183 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source: WFSOMutexTest.c -** -** Purpose: Test for WaitForSingleObjectTest. -** Create Semaphore Object -** Create Two Threads, Each Threads does WFSO for the Semaphore Object -** Increments Counter -** Releases Semaphore -** Test Passes if the above operations are successful -** -** -** -**=========================================================*/ - - - -#include - - -#define NUMBER_OF_WORKER_THREADS 2 - - -//Declaring Variables -HANDLE hSemaphore = NULL; -unsigned int globalcounter =0; -int testReturnCode = PASS; - -//Declaring Function Prototypes -DWORD PALAPI WFSOSemaphoreTest(LPVOID params); -void incrementCounter(void); - -int __cdecl main(int argc, char **argv) -{ - - //Declare local variables - int i =0; - int cMax = 2; - - int returnCode = 0; - - // 2 dimensional array to hold thread handles for each worker thread - HANDLE hThread[NUMBER_OF_WORKER_THREADS]; - DWORD dwThreadId=0; - - //Initialize PAL - if(0 != (PAL_Initialize(argc, argv))) - { - return ( FAIL ); - } - - //Create Semaphore - hSemaphore = CreateSemaphore( - NULL, // no security attributes - cMax, // initial count - cMax, // maximum count - NULL); // unnamed semaphore - - if (hSemaphore == NULL) - { - // Check for error. - Fail("Create Semaphore Failed, GetLastError: %d\n", GetLastError()); - } - - - - //Spawn 2 worker threads - for (i=0;i - - -//Declaring Variables -HANDLE hThread = NULL; -HANDLE hEvent = NULL; - -unsigned int globalcounter =0; - -//Declaring Function Prototypes -DWORD PALAPI incrementCounter(LPVOID params); - -int __cdecl main(int argc, char **argv) -{ - - //Declare local variables - DWORD dwThreadId=0; - DWORD dwWaitResult=0; - - //Initialize PAL - if(0 != (PAL_Initialize(argc, argv))) - { - return ( FAIL ); - } - - - //Create Event - hEvent = CreateEvent(NULL,TRUE,FALSE, NULL); - if(hEvent == NULL) - { - Fail("Create Event Failed\n" - "GetLastError returned %d\n", GetLastError()); - } - - - //Create Thread - hThread = CreateThread( - NULL, - 0, - incrementCounter, - NULL, - 0, - &dwThreadId); - - if ( NULL == hThread ) - { - Fail ( "CreateThread() returned NULL. Failing test.\n" - "GetLastError returned %d\n", GetLastError()); - } - - - //Wait For Thread to signal start - dwWaitResult = WaitForSingleObject(hEvent,INFINITE); - - switch (dwWaitResult) - { - // The thread wait was successful - case WAIT_OBJECT_0: - { - - Trace ("Wait for Single Object (hEvent) was successful.\n"); - break; - } - - // Time-out. - case WAIT_TIMEOUT: - { - Fail ( "Time -out. Failing test.\n" - "GetLastError returned %d\n", GetLastError()); - return FALSE; - } - - // Got ownership of the abandoned event object. - case WAIT_ABANDONED: - { - Fail ( "Got ownership of the abandoned event object. Failing test.\n" - "GetLastError returned %d\n", GetLastError()); - return FALSE; - } - - } - - - //Wait for Thread to finish - dwWaitResult = WaitForSingleObject( - hThread, //handle to thread - 5000L); //Wait Indefinitely - - - switch (dwWaitResult) - { - // The thread wait was successful - case WAIT_OBJECT_0: - { - - Trace("Wait for thread was successful\n"); - - break; - } - - // Time-out. - case WAIT_TIMEOUT: - { - Fail ( "Time -out. Failing test.\n" - "GetLastError returned %d\n", GetLastError()); - return FALSE; - } - - // Got ownership of the abandoned thread object. - case WAIT_ABANDONED: - { - Fail ( "Got ownership of the abandoned thread object. Failing test.\n" - "GetLastError returned %d\n", GetLastError()); - return FALSE; - } - - } - - -//Close Handles -if (0==CloseHandle(hEvent)) - { - Trace("Could not Close event handle\n"); - Fail ( "GetLastError returned %d\n", GetLastError()); - } -if (0==CloseHandle(hThread)) - { - Trace("Could not Close thread handle\n"); - Fail ( "GetLastError returned %d\n", GetLastError()); - } - -PAL_Terminate(); -return ( PASS ); - -} - -DWORD PALAPI incrementCounter(LPVOID params) -{ - - //Signal Event so that main thread can start to wait for thread object - if (0==SetEvent(hEvent)) - { - Fail ( "SetEvent returned Zero. Failing test.\n" - "GetLastError returned %d\n", GetLastError()); - } - - for (globalcounter=0;globalcounter<100000;globalcounter++); - - //Sleep(5000); - - Trace("Global Counter Value: %d \n", globalcounter); - return 0; -} - - - - - - diff --git a/src/pal/tests/palsuite/threading/WaitForSingleObject/test1/CMakeLists.txt b/src/pal/tests/palsuite/threading/WaitForSingleObject/test1/CMakeLists.txt deleted file mode 100644 index 44a9d8fe6..000000000 --- a/src/pal/tests/palsuite/threading/WaitForSingleObject/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_waitforsingleobject_test1 - ${SOURCES} -) - -add_dependencies(paltest_waitforsingleobject_test1 coreclrpal) - -target_link_libraries(paltest_waitforsingleobject_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/WaitForSingleObject/test1/test1.cpp b/src/pal/tests/palsuite/threading/WaitForSingleObject/test1/test1.cpp deleted file mode 100644 index 2af80df67..000000000 --- a/src/pal/tests/palsuite/threading/WaitForSingleObject/test1/test1.cpp +++ /dev/null @@ -1,121 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** Source: test1.c -** -** Purpose: Test for WaitForSingleObjectTest. Create two events, one -** with a TRUE and one with FALSE intial state. Ensure that WaitForSingle -** returns correct values for each of these. -** -** -**=========================================================*/ - -#include - -BOOL WaitForSingleObjectTest() -{ - - BOOL bRet = FALSE; - DWORD dwRet = 0; - - LPSECURITY_ATTRIBUTES lpEventAttributes = 0; - BOOL bManualReset = TRUE; - BOOL bInitialState = TRUE; - - HANDLE hEvent; - - /* Create an event, and ensure the HANDLE is valid */ - hEvent = CreateEvent(lpEventAttributes, bManualReset, - bInitialState, NULL); - - if (hEvent != INVALID_HANDLE_VALUE) - { - - /* Call WaitForSingleObject with 0 time on the event. It - should return WAIT_OBJECT_0 - */ - - dwRet = WaitForSingleObject(hEvent,0); - - if (dwRet != WAIT_OBJECT_0) - { - Trace("WaitForSingleObjectTest:WaitForSingleObject failed (%x)\n", GetLastError()); - } - else - { - bRet = CloseHandle(hEvent); - - if (!bRet) - { - Trace("WaitForSingleObjectTest:CloseHandle failed (%x)\n", GetLastError()); - } - } - } - else - { - Trace("WaitForSingleObjectTest:CreateEvent failed (%x)\n", GetLastError()); - } - - /* If the first section passed, Create another event, with the - intial state being FALSE this time. - */ - - if (bRet) - { - bRet = FALSE; - - bInitialState = FALSE; - - hEvent = CreateEvent( lpEventAttributes, - bManualReset, bInitialState, NULL); - - if (hEvent != INVALID_HANDLE_VALUE) - { - - /* Test WaitForSingleObject and ensure that it returns - WAIT_TIMEOUT in this case. - */ - - dwRet = WaitForSingleObject(hEvent,0); - - if (dwRet != WAIT_TIMEOUT) - { - Trace("WaitForSingleObjectTest:WaitForSingleObject failed (%x)\n", GetLastError()); - } - else - { - bRet = CloseHandle(hEvent); - - if (!bRet) - { - Trace("WaitForSingleObjectTest:CloseHandle failed (%x)\n", GetLastError()); - } - } - } - else - { - Trace("WaitForSingleObjectTest::CreateEvent failed (%x)\n", GetLastError()); - } - } - return bRet; -} - -int __cdecl main(int argc, char **argv) -{ - if(0 != (PAL_Initialize(argc, argv))) - { - return ( FAIL ); - } - - if(!WaitForSingleObjectTest()) - { - Fail ("Test failed\n"); - } - - PAL_Terminate(); - return ( PASS ); - -} diff --git a/src/pal/tests/palsuite/threading/WaitForSingleObject/test1/testinfo.dat b/src/pal/tests/palsuite/threading/WaitForSingleObject/test1/testinfo.dat deleted file mode 100644 index 89193d1c2..000000000 --- a/src/pal/tests/palsuite/threading/WaitForSingleObject/test1/testinfo.dat +++ /dev/null @@ -1,14 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = threading -Function = WaitForSingleObject -Name = Positive Test for WaitForSingleObject -TYPE = DEFAULT -EXE1 = test1 -Description -= Test for WaitForSingleObject. Create two events, one -= with a TRUE and one with FALSE intial state. Ensure that WaitForSingle -= returns correct values for each of these. diff --git a/src/pal/tests/palsuite/threading/YieldProcessor/CMakeLists.txt b/src/pal/tests/palsuite/threading/YieldProcessor/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/threading/YieldProcessor/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/threading/YieldProcessor/test1/CMakeLists.txt b/src/pal/tests/palsuite/threading/YieldProcessor/test1/CMakeLists.txt deleted file mode 100644 index 83a561614..000000000 --- a/src/pal/tests/palsuite/threading/YieldProcessor/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test1.cpp -) - -add_executable(paltest_yieldprocessor_test1 - ${SOURCES} -) - -add_dependencies(paltest_yieldprocessor_test1 coreclrpal) - -target_link_libraries(paltest_yieldprocessor_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/YieldProcessor/test1/test1.cpp b/src/pal/tests/palsuite/threading/YieldProcessor/test1/test1.cpp deleted file mode 100644 index 6adbe989c..000000000 --- a/src/pal/tests/palsuite/threading/YieldProcessor/test1/test1.cpp +++ /dev/null @@ -1,92 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================= -** -** Source: test1.c -** -** Purpose: Test to ensure YieldProcessor works, without -** causing test to hang -** -** Dependencies: PAL_Initialize -** Fail -** YieldProcessor -** WaitForMultipleObject -** CreateThread -** GetLastError -** - -** -**===========================================================================*/ - - -#include -#define THREAD_COUNT 10 -#define REPEAT_COUNT 1000 -#define TIMEOUT 60000 -void PALAPI Run_Thread(LPVOID lpParam); - -/** - * main - * - * executable entry point - */ -INT __cdecl main( INT argc, CHAR **argv ) -{ - DWORD dwParam; - HANDLE hThread[THREAD_COUNT]; - DWORD threadId[THREAD_COUNT]; - - int i = 0; - int returnCode = 0; - - /*PAL initialization */ - if( (PAL_Initialize(argc, argv)) != 0 ) - { - return FAIL; - } - - - for( i = 0; i < THREAD_COUNT; i++ ) - { - dwParam = (int) i; - //Create thread - hThread[i] = CreateThread( - NULL, /* no security attributes */ - 0, /* use default stack size */ - (LPTHREAD_START_ROUTINE)Run_Thread,/* thread function */ - (LPVOID)dwParam, /* argument to thread function */ - 0, /* use default creation flags */ - &threadId[i] /* returns the thread identifier*/ - ); - - if(hThread[i] == NULL) - { - Fail("Create Thread failed for iteration %d GetLastError value is %d\n", i, GetLastError()); - } - - } - - - returnCode = WaitForMultipleObjects(THREAD_COUNT, hThread, TRUE, TIMEOUT); - if( WAIT_OBJECT_0 != returnCode ) - { - Trace("Wait for Object(s) returned %d, expected value is %d, and GetLastError value is %d\n", returnCode, WAIT_OBJECT_0, GetLastError()); - } - - PAL_Terminate(); - return PASS; - -} - -void PALAPI Run_Thread (LPVOID lpParam) -{ - int i = 0; - - for(i=0; i < REPEAT_COUNT; i++ ) - { - // No error code set nor does it have any return code - YieldProcessor(); - } -} diff --git a/src/pal/tests/palsuite/threading/YieldProcessor/test1/testinfo.dat b/src/pal/tests/palsuite/threading/YieldProcessor/test1/testinfo.dat deleted file mode 100644 index 6d12110c3..000000000 --- a/src/pal/tests/palsuite/threading/YieldProcessor/test1/testinfo.dat +++ /dev/null @@ -1,13 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = threading -Function = YieldProcessor -Name = Test for YieldProcessor -TYPE = DEFAULT -EXE1 = test -Description -= Purpose: Test to ensure YieldProcessor is -= working properly on supported platforms diff --git a/src/pal/tests/palsuite/threading/releasesemaphore/CMakeLists.txt b/src/pal/tests/palsuite/threading/releasesemaphore/CMakeLists.txt deleted file mode 100644 index f6aa0cb2d..000000000 --- a/src/pal/tests/palsuite/threading/releasesemaphore/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -add_subdirectory(test1) - diff --git a/src/pal/tests/palsuite/threading/releasesemaphore/test1/CMakeLists.txt b/src/pal/tests/palsuite/threading/releasesemaphore/test1/CMakeLists.txt deleted file mode 100644 index 6941fb06b..000000000 --- a/src/pal/tests/palsuite/threading/releasesemaphore/test1/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12.2) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(SOURCES - test.cpp -) - -add_executable(paltest_releasesemaphore_test1 - ${SOURCES} -) - -add_dependencies(paltest_releasesemaphore_test1 coreclrpal) - -target_link_libraries(paltest_releasesemaphore_test1 - ${COMMON_TEST_LIBRARIES} -) diff --git a/src/pal/tests/palsuite/threading/releasesemaphore/test1/test.cpp b/src/pal/tests/palsuite/threading/releasesemaphore/test1/test.cpp deleted file mode 100644 index 4d736b7d9..000000000 --- a/src/pal/tests/palsuite/threading/releasesemaphore/test1/test.cpp +++ /dev/null @@ -1,68 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================ -** -** Source: releasesemaphore/test1/createsemaphore.c -** -** Purpose: Check that ReleaseSemaphore fails when using a semaphore handle -** which has been closed by a call to CloseHandle. Check that -** ReleaseSemaphore fails when using a ReleaseCount of zero or less than -** zero. -** -** -**==========================================================================*/ - -#include - -HANDLE hSemaphore; - -int __cdecl main (int argc, char **argv) -{ - if(0 != (PAL_Initialize(argc, argv))) - { - return (FAIL); - } - hSemaphore = CreateSemaphoreA (NULL, 1, 2, NULL); - - if (NULL == hSemaphore) - { - Fail("PALSUITE ERROR: CreateSemaphoreA ('%p' '%ld' '%ld' " - "'%p') returned NULL.\nGetLastError returned %d.\n", - NULL, 1, 2, NULL, GetLastError()); - } - - if(ReleaseSemaphore(hSemaphore, 0, NULL)) - { - Fail("PALSUITE ERROR: ReleaseSemaphore('%p' '%ld' '%p') " - "call returned %d\nwhen it should have returned " - "%d.\nGetLastError returned %d.\n", - hSemaphore, 0, NULL, FALSE, TRUE, GetLastError()); - } - - if(ReleaseSemaphore(hSemaphore, -1, NULL)) - { - Fail("PALSUITE ERROR: ReleaseSemaphore('%p' '%ld' '%p') " - "call returned %d\nwhen it should have returned " - "%d.\nGetLastError returned %d.\n", - hSemaphore, -1, NULL, TRUE, FALSE, GetLastError()); - } - - if(!CloseHandle(hSemaphore)) - { - Fail("PALSUITE ERROR: CloseHandle(%p) call failed. GetLastError " - "returned %d.\n", hSemaphore, GetLastError()); - } - - if(ReleaseSemaphore(hSemaphore, 1, NULL)) - { - Fail("PALSUITE ERROR: ReleaseSemaphore('%p' '%ld' '%p') " - "call incremented semaphore %p count\nafter the handle " - "was closed by a call to CloseHandle.\n GetLastError returned " - "%d.\n", hSemaphore, -1, NULL, hSemaphore, GetLastError()); - } - - PAL_Terminate(); - return (PASS); -} diff --git a/src/pal/tests/palsuite/threading/releasesemaphore/test1/testinfo.dat b/src/pal/tests/palsuite/threading/releasesemaphore/test1/testinfo.dat deleted file mode 100644 index b4d647a59..000000000 --- a/src/pal/tests/palsuite/threading/releasesemaphore/test1/testinfo.dat +++ /dev/null @@ -1,15 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. -# See the LICENSE file in the project root for more information. - -Version = 1.0 -Section = threading -Function = ReleaseSemaphore -Name = Positive Test for ReleaseSemaphore -TYPE = DEFAULT -EXE1 = test -Description -= Check that ReleaseSemaphore fails when using a semaphore handle -= which has been closed by a call to CloseHandle. Check that -= ReleaseSemaphore fails when using a ReleaseCount of zero or less than -= zero. diff --git a/src/pal/tools/clang-compiler-override-arm.txt b/src/pal/tools/clang-compiler-override-arm.txt deleted file mode 100644 index da25715ad..000000000 --- a/src/pal/tools/clang-compiler-override-arm.txt +++ /dev/null @@ -1,20 +0,0 @@ -SET (CMAKE_C_FLAGS_INIT "-Wall -std=c11") -SET (CMAKE_C_FLAGS_DEBUG_INIT "-g -O0") -SET (CLR_C_FLAGS_CHECKED_INIT "-g -O1") -# Refer to the below instruction to support __thread with -O2/-O3 on Linux/ARM -# https://github.com/dotnet/coreclr/blob/master/Documentation/building/linux-instructions.md -SET (CMAKE_C_FLAGS_RELEASE_INIT "-g -O1") -SET (CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "-g -O1") - -SET (CMAKE_CXX_FLAGS_INIT "-Wall -Wno-null-conversion -std=c++11") -SET (CMAKE_CXX_FLAGS_DEBUG_INIT "-g -O0") -SET (CLR_CXX_FLAGS_CHECKED_INIT "-g -O1") -SET (CMAKE_CXX_FLAGS_RELEASE_INIT "-g -O1") -SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "-g -O1") - -SET (CLR_DEFINES_DEBUG_INIT DEBUG _DEBUG _DBG URTBLDENV_FRIENDLY=Checked BUILDENV_CHECKED=1) -SET (CLR_DEFINES_CHECKED_INIT DEBUG _DEBUG _DBG URTBLDENV_FRIENDLY=Checked BUILDENV_CHECKED=1) -SET (CLR_DEFINES_RELEASE_INIT NDEBUG URTBLDENV_FRIENDLY=Retail) -SET (CLR_DEFINES_RELWITHDEBINFO_INIT NDEBUG URTBLDENV_FRIENDLY=Retail) - -SET (CMAKE_INSTALL_PREFIX $ENV{__CMakeBinDir}) diff --git a/src/pal/tools/clang-compiler-override.txt b/src/pal/tools/clang-compiler-override.txt deleted file mode 100644 index ee1e63b63..000000000 --- a/src/pal/tools/clang-compiler-override.txt +++ /dev/null @@ -1,20 +0,0 @@ -SET (CMAKE_C_FLAGS_INIT "-Wall -std=c11") -SET (CMAKE_C_FLAGS_DEBUG_INIT "-g -O0") -SET (CLR_C_FLAGS_CHECKED_INIT "-g -O2") -# Refer to the below instruction to support __thread with -O2/-O3 on Linux/ARM -# https://github.com/dotnet/coreclr/blob/master/Documentation/building/linux-instructions.md -SET (CMAKE_C_FLAGS_RELEASE_INIT "-g -O3") -SET (CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "-g -O2") - -SET (CMAKE_CXX_FLAGS_INIT "-Wall -Wno-null-conversion -std=c++11") -SET (CMAKE_CXX_FLAGS_DEBUG_INIT "-g -O0") -SET (CLR_CXX_FLAGS_CHECKED_INIT "-g -O2") -SET (CMAKE_CXX_FLAGS_RELEASE_INIT "-g -O3") -SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "-g -O2") - -SET (CLR_DEFINES_DEBUG_INIT DEBUG _DEBUG _DBG URTBLDENV_FRIENDLY=Checked BUILDENV_CHECKED=1) -SET (CLR_DEFINES_CHECKED_INIT DEBUG _DEBUG _DBG URTBLDENV_FRIENDLY=Checked BUILDENV_CHECKED=1) -SET (CLR_DEFINES_RELEASE_INIT NDEBUG URTBLDENV_FRIENDLY=Retail) -SET (CLR_DEFINES_RELWITHDEBINFO_INIT NDEBUG URTBLDENV_FRIENDLY=Retail) - -SET (CMAKE_INSTALL_PREFIX $ENV{__CMakeBinDir}) diff --git a/src/pal/tools/gen-buildsys-clang.sh b/src/pal/tools/gen-buildsys-clang.sh deleted file mode 100644 index b5726c82e..000000000 --- a/src/pal/tools/gen-buildsys-clang.sh +++ /dev/null @@ -1,182 +0,0 @@ -#!/usr/bin/env bash -# -# This file invokes cmake and generates the build system for Clang. -# - -if [ $# -lt 4 ] -then - echo "Usage..." - echo "gen-buildsys-clang.sh [build flavor] [coverage] [ninja] [cmakeargs]" - echo "Specify the path to the top level CMake file - /src/NDP" - echo "Specify the clang version to use, split into major and minor version" - echo "Specify the target architecture." - echo "Optionally specify the build configuration (flavor.) Defaults to DEBUG." - echo "Optionally specify 'coverage' to enable code coverage build." - echo "Target ninja instead of make. ninja must be on the PATH." - echo "Pass additional arguments to CMake call." - exit 1 -fi - -# Set up the environment to be used for building with clang. -if command -v "clang-$2.$3" > /dev/null - then - export CC="$(command -v clang-$2.$3)" - export CXX="$(command -v clang++-$2.$3)" -elif command -v "clang$2$3" > /dev/null - then - export CC="$(command -v clang$2$3)" - export CXX="$(command -v clang++$2$3)" -elif command -v clang > /dev/null - then - export CC="$(command -v clang)" - export CXX="$(command -v clang++)" -else - echo "Unable to find Clang Compiler" - exit 1 -fi - -build_arch="$4" -buildtype=DEBUG -code_coverage=OFF -build_tests=OFF -generator="Unix Makefiles" -__UnprocessedCMakeArgs="" - -for i in "${@:5}"; do - upperI="$(echo $i | awk '{print toupper($0)}')" - case $upperI in - # Possible build types are DEBUG, CHECKED, RELEASE, RELWITHDEBINFO, MINSIZEREL. - DEBUG | CHECKED | RELEASE | RELWITHDEBINFO | MINSIZEREL) - buildtype=$upperI - ;; - COVERAGE) - echo "Code coverage is turned on for this build." - code_coverage=ON - ;; - INCLUDE_TESTS) - echo "Including tests directory in build." - build_tests=ON - ;; - NINJA) - generator=Ninja - ;; - *) - __UnprocessedCMakeArgs="${__UnprocessedCMakeArgs}${__UnprocessedCMakeArgs:+ }$i" - esac -done - -OS=`uname` - -# Locate llvm -# This can be a little complicated, because the common use-case of Ubuntu with -# llvm-3.5 installed uses a rather unusual llvm installation with the version -# number postfixed (i.e. llvm-ar-3.5), so we check for that first. -# On FreeBSD the version number is appended without point and dash (i.e. -# llvm-ar35). -# Additionally, OSX doesn't use the llvm- prefix. -if [ $OS = "Linux" -o $OS = "FreeBSD" -o $OS = "OpenBSD" -o $OS = "NetBSD" -o $OS = "SunOS" ]; then - llvm_prefix="llvm-" -elif [ $OS = "Darwin" ]; then - llvm_prefix="" -else - echo "Unable to determine build platform" - exit 1 -fi - -desired_llvm_major_version=$2 -desired_llvm_minor_version=$3 -if [ $OS = "FreeBSD" ]; then - desired_llvm_version="$desired_llvm_major_version$desired_llvm_minor_version" -elif [ $OS = "OpenBSD" ]; then - desired_llvm_version="" -elif [ $OS = "NetBSD" ]; then - desired_llvm_version="" -elif [ $OS = "SunOS" ]; then - desired_llvm_version="" -else - desired_llvm_version="-$desired_llvm_major_version.$desired_llvm_minor_version" -fi -locate_llvm_exec() { - if command -v "$llvm_prefix$1$desired_llvm_version" > /dev/null 2>&1 - then - echo "$(command -v $llvm_prefix$1$desired_llvm_version)" - elif command -v "$llvm_prefix$1" > /dev/null 2>&1 - then - echo "$(command -v $llvm_prefix$1)" - else - exit 1 - fi -} - -llvm_ar="$(locate_llvm_exec ar)" -[[ $? -eq 0 ]] || { echo "Unable to locate llvm-ar"; exit 1; } -llvm_link="$(locate_llvm_exec link)" -[[ $? -eq 0 ]] || { echo "Unable to locate llvm-link"; exit 1; } -llvm_nm="$(locate_llvm_exec nm)" -[[ $? -eq 0 ]] || { echo "Unable to locate llvm-nm"; exit 1; } -if [ $OS = "Linux" -o $OS = "FreeBSD" -o $OS = "OpenBSD" -o $OS = "NetBSD" -o $OS = "SunOS" ]; then - llvm_objdump="$(locate_llvm_exec objdump)" - [[ $? -eq 0 ]] || { echo "Unable to locate llvm-objdump"; exit 1; } -fi - -cmake_extra_defines= -if [[ -n "$LLDB_LIB_DIR" ]]; then - cmake_extra_defines="$cmake_extra_defines -DWITH_LLDB_LIBS=$LLDB_LIB_DIR" -fi -if [[ -n "$LLDB_INCLUDE_DIR" ]]; then - cmake_extra_defines="$cmake_extra_defines -DWITH_LLDB_INCLUDES=$LLDB_INCLUDE_DIR" -fi -if [[ -n "$CROSSCOMPONENT" ]]; then - cmake_extra_defines="$cmake_extra_defines -DCLR_CROSS_COMPONENTS_BUILD=1" -fi -if [ "$CROSSCOMPILE" == "1" ]; then - if ! [[ -n "$ROOTFS_DIR" ]]; then - echo "ROOTFS_DIR not set for crosscompile" - exit 1 - fi - if [[ -z $CONFIG_DIR ]]; then - CONFIG_DIR="$1/cross" - fi - export TARGET_BUILD_ARCH=$build_arch - cmake_extra_defines="$cmake_extra_defines -C $CONFIG_DIR/tryrun.cmake" - cmake_extra_defines="$cmake_extra_defines -DCMAKE_TOOLCHAIN_FILE=$CONFIG_DIR/toolchain.cmake" - cmake_extra_defines="$cmake_extra_defines -DCLR_UNIX_CROSS_BUILD=1" -fi -if [ $OS == "Linux" ]; then - linux_id_file="/etc/os-release" - if [[ -n "$CROSSCOMPILE" ]]; then - linux_id_file="$ROOTFS_DIR/$linux_id_file" - fi - if [[ -e $linux_id_file ]]; then - source $linux_id_file - cmake_extra_defines="$cmake_extra_defines -DCLR_CMAKE_LINUX_ID=$ID" - fi -fi -if [ "$build_arch" == "armel" ]; then - cmake_extra_defines="$cmake_extra_defines -DARM_SOFTFP=1" -fi - -clang_version=$( $CC --version | head -1 | sed 's/[^0-9]*\([0-9]*\.[0-9]*\).*/\1/' ) -# Use O1 option when the clang version is smaller than 3.9 -# Otherwise use O3 option in release build -if [[ ( ${clang_version%.*} -eq 3 && ${clang_version#*.} -lt 9 ) && - ( "$build_arch" == "arm" || "$build_arch" == "armel" ) ]]; then - overridefile=clang-compiler-override-arm.txt -else - overridefile=clang-compiler-override.txt -fi - -cmake \ - -G "$generator" \ - "-DCMAKE_USER_MAKE_RULES_OVERRIDE=$1/src/pal/tools/$overridefile" \ - "-DCMAKE_AR=$llvm_ar" \ - "-DCMAKE_LINKER=$llvm_link" \ - "-DCMAKE_NM=$llvm_nm" \ - "-DCMAKE_OBJDUMP=$llvm_objdump" \ - "-DCMAKE_BUILD_TYPE=$buildtype" \ - "-DCMAKE_EXPORT_COMPILE_COMMANDS=1 " \ - "-DCLR_CMAKE_ENABLE_CODE_COVERAGE=$code_coverage" \ - "-DCLR_CMAKE_BUILD_TESTS=$build_tests" \ - $cmake_extra_defines \ - $__UnprocessedCMakeArgs \ - "$1" diff --git a/src/pal/tools/gen-dactable-rva.sh b/src/pal/tools/gen-dactable-rva.sh deleted file mode 100644 index dd200068e..000000000 --- a/src/pal/tools/gen-dactable-rva.sh +++ /dev/null @@ -1 +0,0 @@ -nm $1 | grep g_dacTable | cut -f 1 -d' ' | head -n 1 | awk '{ print "#define DAC_TABLE_RVA 0x" $1}' > $2 diff --git a/src/pal/tools/preptests.sh b/src/pal/tools/preptests.sh deleted file mode 100644 index 704f86962..000000000 --- a/src/pal/tools/preptests.sh +++ /dev/null @@ -1,69 +0,0 @@ -# PrepTests.sh -# Initializes our test running environment by setting environment variables appropriately. Already set variables -# are not overwritten. This is intended for use on unix. -# -# Created 10/28/2014 - mmitche - -ExecPrepTestsCore() -{ - unset -f ExecPrepTestsCore - - echo - echo Preparing this window to run tests - echo Setting up Exernal Environment Variables - echo _TGTCPU - Target CPU - echo BVT_ROOT - Root of tests to run - echo CORE_RUN - Test host - echo CORE_ROOT - Root of CLR drop. - echo - - # Set $_TGTCPU based on the processor arch. In bash on an x64 linux machine, that will show up as x86_x64. - # If so, then set to AMD64. Otherwise I386. - if ! test $_TGTCPU - then - export _TGTCPU=`arch` - if test $_TGTCPU = "x86_x64" - then - export _TGTCPU="AMD64" - else - export _TGTCPU="i386" - fi - fi - - # Set $BVT_ROOT based on current directory - if ! test $BVT_ROOT - then - export BVT_ROOT=$PWD - fi - - # Set $CORE_RUN based on current directory - if ! test $CORE_RUN - then - if test -e $BVT_ROOT/Hosting/CoreClr/Activation/Host/TestHost.exe - then - export CORE_RUN=$BVT_ROOT/Hosting/CoreClr/Activation/Host/TestHost.exe - else - echo !!!ERROR: $BVT_ROOT/Hosting/CoreClr/Activation/Host/TestHost.exe does not exist. CORE_RUN not set. - return 1 - fi - fi - - # Set $CORE_ROOT base to $PWD unless otherwise set. - if ! test "$CORE_ROOT" - then - echo Warning. CORE_ROOT is not set at the moment. Setting it to $PWD - export CORE_ROOT=$PWD - fi - - # Report the current state of the environment - echo _TGCPU is set to: $_TGTCPU - echo BVT_ROOT is set to: $BVT_ROOT - echo CORE_ROOT is set to: $CORE_ROOT - echo CORE_RUN is set to $CORE_RUN - echo - - return 0 -} - -# This is explicitly so that we can RETURN and not exit this script. -ExecPrepTestsCore $* diff --git a/src/pal/tools/setup-ubuntuvm.sh b/src/pal/tools/setup-ubuntuvm.sh deleted file mode 100644 index 89d8ea37b..000000000 --- a/src/pal/tools/setup-ubuntuvm.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env bash - -echo Installing basic Ubuntu \(VM\) XPlat environment - -function Install-Packages { - echo Installing Packages - apt-get install clang -y - apt-get install cmake -y -} - -function Enable-Integration-Services { - echo Checking for integration services - res=$(grep -c "hv_vmbus" /etc/initramfs-tools/modules) - if [ $res -eq 0 ] - then - echo Installing integration services - echo hv_vmbus >> /etc/initramfs-tools/modules - echo hv_storvsc >> /etc/initramfs-tools/modules - echo hv_blkvsc >> /etc/initramfs-tools/modules - echo hv_netvsc >> /etc/initramfs-tools/modules - else - echo Integration Services already installed - fi -} - -Install-Packages -Enable-Integration-Services diff --git a/src/pal/tools/smarty.sh b/src/pal/tools/smarty.sh deleted file mode 100644 index d8b407e72..000000000 --- a/src/pal/tools/smarty.sh +++ /dev/null @@ -1,26 +0,0 @@ -if ! test "$_TGTCPU" -then - echo !!!ERROR: _TGTCPU not set. Please run preptests.sh -fi -if ! test "$CORE_RUN" -then - echo !!!ERROR: CORE_RUN not set. Please run preptests.sh -fi -if ! test "$CORE_ROOT" -then - echo !!!ERROR: CORE_ROOT not set. Please run preptests.sh -fi -if ! test "$BVT_ROOT" -then - export BVT_ROOT=$PWD -fi - -if [ -n "$PERL5LIB" ] ; then - if [ -z "`expr $PERL5LIB : ".*\($BVT_ROOT/Common/Smarty\)"`" ] ; then - export PERL5LIB="$PERL5LIB:$BVT_ROOT/Common/Smarty" - fi -else - export PERL5LIB=$BVT_ROOT/Common/Smarty -fi - -perl Common/Smarty/Smarty.pl $* diff --git a/src/palrt/CMakeLists.txt b/src/palrt/CMakeLists.txt index e19b55d9d..2631a03fe 100644 --- a/src/palrt/CMakeLists.txt +++ b/src/palrt/CMakeLists.txt @@ -1,6 +1,18 @@ - set(CMAKE_INCLUDE_CURRENT_DIR ON) +include_directories(${ROOT_DIR}/src/pal/inc) +include_directories(${ROOT_DIR}/src/pal/inc/rt) + +# Include the dummy c++ include files +include_directories(${ROOT_DIR}/src/pal/inc/rt/cpp) + +# This prevents inclusion of standard C compiler headers +add_compile_options(-nostdinc) + +add_compile_options(-fPIC) +add_definitions(-DUNICODE) +add_definitions(-D_UNICODE) + set(PALRT_SOURCES bstr.cpp coguid.cpp @@ -15,12 +27,7 @@ set(PALRT_SOURCES variant.cpp ) -add_compile_options(-fPIC) - add_library_clr(palrt STATIC ${PALRT_SOURCES} ) - -# Install the static PAL library for VS -_install (TARGETS palrt DESTINATION lib) diff --git a/src/palrt/common.h b/src/palrt/common.h index b61a93467..7fb214519 100644 --- a/src/palrt/common.h +++ b/src/palrt/common.h @@ -13,6 +13,8 @@ #define _COMMON_H_ #include -#include +#include +#include "palclr.h" #include "shlwapip.h" + #endif // _COMMON_H_ diff --git a/src/vm/hillclimbing.h b/src/vm/hillclimbing.h deleted file mode 100644 index 9c85877ea..000000000 --- a/src/vm/hillclimbing.h +++ /dev/null @@ -1,97 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -//========================================================================= - -// -// HillClimbing.h -// -// Defines classes for the ThreadPool's HillClimbing concurrency-optimization -// algorithm. -// - -//========================================================================= - -#ifndef _HILLCLIMBING_H -#define _HILLCLIMBING_H - -#include "complex.h" -#include "random.h" - -enum HillClimbingStateTransition -{ - Warmup, - Initializing, - RandomMove, - ClimbingMove, - ChangePoint, - Stabilizing, - Starvation, //used by ThreadpoolMgr - ThreadTimedOut, //used by ThreadpoolMgr - Undefined, -}; - - -class HillClimbing -{ -private: - int m_wavePeriod; - int m_samplesToMeasure; - double m_targetThroughputRatio; - double m_targetSignalToNoiseRatio; - double m_maxChangePerSecond; - double m_maxChangePerSample; - int m_maxThreadWaveMagnitude; - DWORD m_sampleIntervalLow; - double m_threadMagnitudeMultiplier; - DWORD m_sampleIntervalHigh; - double m_throughputErrorSmoothingFactor; - double m_gainExponent; - double m_maxSampleError; - - double m_currentControlSetting; - LONGLONG m_totalSamples; - int m_lastThreadCount; - double m_elapsedSinceLastChange; //elapsed seconds since last thread count change - double m_completionsSinceLastChange; //number of completions since last thread count change - - double m_averageThroughputNoise; - - double* m_samples; //Circular buffer of the last m_samplesToMeasure samples - double* m_threadCounts; //Thread counts effective at each of m_samples - - unsigned int m_currentSampleInterval; - CLRRandom m_randomIntervalGenerator; - - int m_accumulatedCompletionCount; - double m_accumulatedSampleDuration; - - void ChangeThreadCount(int newThreadCount, HillClimbingStateTransition transition); - void LogTransition(int threadCount, double throughput, HillClimbingStateTransition transition); - - Complex GetWaveComponent(double* samples, int sampleCount, double period); - -public: - void Initialize(); - int Update(int currentThreadCount, double sampleDuration, int numCompletions, int* pNewSampleInterval); - void ForceChange(int newThreadCount, HillClimbingStateTransition transition); -}; - -#define HillClimbingLogCapacity 200 - -struct HillClimbingLogEntry -{ - DWORD TickCount; - HillClimbingStateTransition Transition; - int NewControlSetting; - int LastHistoryCount; - float LastHistoryMean; -}; - -GARY_DECL(HillClimbingLogEntry, HillClimbingLog, HillClimbingLogCapacity); -GVAL_DECL(int, HillClimbingLogFirstIndex); -GVAL_DECL(int, HillClimbingLogSize); -typedef DPTR(HillClimbingLogEntry) PTR_HillClimbingLogEntry; - -#endif